diff -Nru rustc-1.30.0+dfsg1+llvm/config.toml.example rustc-1.31.0+dfsg1+llvm/config.toml.example --- rustc-1.30.0+dfsg1+llvm/config.toml.example 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/config.toml.example 2018-12-04 23:41:40.000000000 +0000 @@ -182,10 +182,9 @@ # Build the profiler runtime #profiler = false -# Indicates whether the OpenSSL linked into Cargo will be statically linked or -# not. If static linkage is specified then the build system will download a -# known-good version of OpenSSL, compile it, and link it to Cargo. -#openssl-static = false +# Indicates whether the native libraries linked into Cargo will be statically +# linked or not. +#cargo-native-static = false # Run the build with low priority, by setting the process group's "nice" value # to +10 on Unix platforms, and by using a "low priority" job object on Windows. @@ -243,19 +242,36 @@ # ============================================================================= [rust] -# Indicates that the build should be optimized for debugging Rust. Note that -# this is typically not what you want as it takes an incredibly large amount of -# time to have a debug-mode rustc compile any code (notably libstd). If this -# value is set to `true` it will affect a number of configuration options below -# as well, if unconfigured. -#debug = false - -# Whether or not to optimize the compiler and standard library +# Whether or not to optimize the compiler and standard library. +# # Note: the slowness of the non optimized compiler compiling itself usually # outweighs the time gains in not doing optimizations, therefore a -# full bootstrap takes much more time with optimize set to false. +# full bootstrap takes much more time with `optimize` set to false. #optimize = true +# Indicates that the build should be configured for debugging Rust. A +# `debug`-enabled compiler and standard library will be somewhat +# slower (due to e.g. checking of debug assertions) but should remain +# usable. +# +# Note: If this value is set to `true`, it will affect a number of +# configuration options below as well, if they have been left +# unconfigured in this file. +# +# Note: changes to the `debug` setting do *not* affect `optimize` +# above. In theory, a "maximally debuggable" environment would +# set `optimize` to `false` above to assist the introspection +# facilities of debuggers like lldb and gdb. To recreate such an +# environment, explicitly set `optimize` to `false` and `debug` +# to `true`. In practice, everyone leaves `optimize` set to +# `true`, because an unoptimized rustc with debugging +# enabled becomes *unusably slow* (e.g. rust-lang/rust#24840 +# reported a 25x slowdown) and bootstrapping the supposed +# "maximally debuggable" environment (notably libstd) takes +# hours to build. +# +#debug = false + # Number of codegen units to use for each compiler invocation. A value of 0 # means "the number of cores on this machine", and 1+ is passed through to the # compiler. @@ -322,6 +338,7 @@ # Flag indicating whether codegen tests will be run or not. If you get an error # saying that the FileCheck executable is missing, you may want to disable this. +# Also see the target's llvm-filecheck option. #codegen-tests = true # Flag indicating whether git info will be retrieved from .git automatically. @@ -416,6 +433,10 @@ # target. #llvm-config = "../path/to/llvm/root/bin/llvm-config" +# Normally the build system can find LLVM's FileCheck utility, but if +# not, you can specify an explicit file name for it. +#llvm-filecheck = "/path/to/FileCheck" + # Path to the custom jemalloc static library to link into the standard library # by default. This is only used if jemalloc is still enabled above #jemalloc = "/path/to/jemalloc/libjemalloc_pic.a" @@ -476,3 +497,7 @@ # as the one built on Windows will contain backslashes in paths causing problems # on linux #src-tarball = true +# + +# Whether to allow failures when building tools +#missing-tools = false diff -Nru rustc-1.30.0+dfsg1+llvm/CONTRIBUTING.md rustc-1.31.0+dfsg1+llvm/CONTRIBUTING.md --- rustc-1.30.0+dfsg1+llvm/CONTRIBUTING.md 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/CONTRIBUTING.md 2018-12-04 23:41:40.000000000 +0000 @@ -566,7 +566,7 @@ to fix the issue. * The dark blue **final-comment-period** label marks bugs that are using the - RFC signoff functionality of [rfcbot][rfcbot] and are currenty in the final + RFC signoff functionality of [rfcbot][rfcbot] and are currently in the final comment period. * Red, **I**-prefixed labels indicate the **importance** of the issue. The @@ -646,7 +646,7 @@ * Don't be afraid to ask! The Rust community is friendly and helpful. [rustc guide]: https://rust-lang-nursery.github.io/rustc-guide/about-this-guide.html -[gdfrustc]: http://manishearth.github.io/rust-internals-docs/rustc/ +[gdfrustc]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ [gsearchdocs]: https://www.google.com/search?q=site:doc.rust-lang.org+your+query+here [rif]: http://internals.rust-lang.org [rr]: https://doc.rust-lang.org/book/README.html diff -Nru rustc-1.30.0+dfsg1+llvm/debian/changelog rustc-1.31.0+dfsg1+llvm/debian/changelog --- rustc-1.30.0+dfsg1+llvm/debian/changelog 2018-11-12 22:42:07.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/debian/changelog 2019-01-22 23:11:37.000000000 +0000 @@ -1,4 +1,4 @@ -rustc (1.30.0+dfsg1+llvm-2ubuntu1~14.04.1) trusty; urgency=medium +rustc (1.31.0+dfsg1+llvm-2ubuntu1~14.04.1) trusty; urgency=medium * Backport 1.30.0 to trusty * Relax the gdb build requirement @@ -12,7 +12,89 @@ on a binutils-2.26, we've never actually used it - update debian/control - -- Michael Hudson-Doyle Tue, 13 Nov 2018 11:42:07 +1300 + -- Michael Hudson-Doyle Wed, 23 Jan 2019 12:11:37 +1300 + +rustc (1.31.0+dfsg1+llvm-2ubuntu1) disco; urgency=medium + + * Merge from Debian unstable. Remaining changes: + - Use the bundled llvm to avoid having to do llvm updates in order to + deliver rust updates + - update debian/config.toml.in + - update debian/control + - update debian/copyright + - update debian/rules + - Build-Depend on libc6-dbg on armhf, to workaround a crash in ld.so + during some debuginfo tests + - update debian/control + - Add a hack to ensure the stage0 compiler is extracted to the correct + location + - update debian/make_orig-stage0_tarball.sh + - Scrub -g from CFLAGS and CXXFLAGS in order to let rustbuild control + whether LLVM is compiled with debug symbols + - update debian/rules + - On i386, only build debuginfo for libstd + - update debian/rules + - Ignore all test failures on every architecture + - update debian/rules + - Version the Build-Conflict on gdb-minimal as gdb now Provides it + - update debian/control + - Adjust the rustc Breaks/Replaces libstd-rust-dev version to fix an + upgrade issue + - update debian/control + - Adjust debian/watch to include +llvm in upstream version. + + -- Michael Hudson-Doyle Fri, 18 Jan 2019 11:43:00 +1300 + +rustc (1.31.0+dfsg1-2) unstable; urgency=medium + + * Bump mips mipsel s390x allowed-failures to 24. + + -- Ximin Luo Sun, 16 Dec 2018 14:34:44 -0800 + +rustc (1.31.0+dfsg1-1) unstable; urgency=medium + + * Revert debuginfo patches, they're not ready yet. + + -- Ximin Luo Sun, 16 Dec 2018 09:58:06 -0800 + +rustc (1.31.0+dfsg1-1~exp2) experimental; urgency=medium + + * Drop redundant patches. + * Fix line numbers in some test-case patches. + * Backport an updated patch for gdb 8.2. + + -- Ximin Luo Sat, 15 Dec 2018 13:52:26 -0800 + +rustc (1.31.0+dfsg1-1~exp1) experimental; urgency=medium + + * New upstream release. + + -- Ximin Luo Fri, 14 Dec 2018 21:30:56 -0800 + +rustc (1.31.0~beta.19+dfsg1-1~exp2) experimental; urgency=medium + + * Filter LLVM build flags to not be stupid. + + -- Ximin Luo Sat, 01 Dec 2018 12:17:52 -0800 + +rustc (1.31.0~beta.19+dfsg1-1~exp1) experimental; urgency=medium + + * New upstream release. + + -- Ximin Luo Thu, 29 Nov 2018 22:29:16 -0800 + +rustc (1.31.0~beta.4+dfsg1-1~exp2) experimental; urgency=medium + + * Merge changes from Debian unstable. + + -- Ximin Luo Tue, 06 Nov 2018 19:45:26 -0800 + +rustc (1.31.0~beta.4+dfsg1-1~exp1) experimental; urgency=medium + + * New upstream release. + * Drop old maintainers from Uploaders. + + -- Ximin Luo Sun, 04 Nov 2018 19:00:16 -0800 rustc (1.30.0+dfsg1+llvm-2ubuntu1) disco; urgency=medium diff -Nru rustc-1.30.0+dfsg1+llvm/debian/control rustc-1.31.0+dfsg1+llvm/debian/control --- rustc-1.30.0+dfsg1+llvm/debian/control 2018-11-12 22:42:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/debian/control 2019-01-22 23:11:37.000000000 +0000 @@ -3,18 +3,16 @@ Priority: optional Maintainer: Ubuntu Developers XSBC-Original-Maintainer: Debian Rust Maintainers -Uploaders: Jordan Justen , - Luca Bruno , - Sylvestre Ledru , - Angus Lees , - Ximin Luo +Uploaders: + Ximin Luo , + Sylvestre Ledru # :native annotations are to support cross-compiling, see README.Debian Build-Depends: debhelper (>= 9), dpkg-dev (>= 1.17.5), python:native, - cargo:native (>= 0.19.0) , - rustc:native (>= 1.29.0+dfsg) , - rustc:native (<= 1.30++) , + cargo:native (>= 0.31.0) , + rustc:native (>= 1.30.0+dfsg) , + rustc:native (<= 1.31.0++) , autotools-dev, cmake (>= 3.0) | cmake3, # this is sometimes needed by rustc_llvm @@ -50,7 +48,7 @@ Pre-Depends: ${misc:Pre-Depends} Depends: ${shlibs:Depends}, ${misc:Depends}, libstd-rust-dev (= ${binary:Version}), gcc, libc-dev, binutils -Recommends: cargo (>= 0.31.0~~), cargo (<< 0.32.0~~), rust-gdb | rust-lldb +Recommends: cargo (>= 0.32.0~~), cargo (<< 0.33.0~~), rust-gdb | rust-lldb Suggests: rust-doc, rust-src Replaces: libstd-rust-dev (<< 1.26.2+dfsg1+llvm-0ubuntu1~~) Breaks: libstd-rust-dev (<< 1.26.2+dfsg1+llvm-0ubuntu1~~) @@ -67,7 +65,7 @@ generic programming and meta-programming, in both static and dynamic styles. -Package: libstd-rust-1.30 +Package: libstd-rust-1.31 Section: libs Architecture: any Multi-Arch: same @@ -92,7 +90,7 @@ Section: libdevel Architecture: any Multi-Arch: same -Depends: ${shlibs:Depends}, ${misc:Depends}, libstd-rust-1.30 (= ${binary:Version}) +Depends: ${shlibs:Depends}, ${misc:Depends}, libstd-rust-1.31 (= ${binary:Version}) Description: Rust standard libraries - development files Rust is a curly-brace, block-structured expression language. It visually resembles the C language family, but differs significantly diff -Nru rustc-1.30.0+dfsg1+llvm/debian/copyright rustc-1.31.0+dfsg1+llvm/debian/copyright --- rustc-1.30.0+dfsg1+llvm/debian/copyright 2018-11-12 22:23:20.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/debian/copyright 2019-01-22 23:11:37.000000000 +0000 @@ -54,7 +54,11 @@ # unused dependencies, generated by debian/prune-unused-deps # DO NOT EDIT below, AUTOGENERATED src/vendor/assert_cli + src/vendor/bit-set + src/vendor/bit-vec src/vendor/bufstream + src/vendor/bytecount + src/vendor/bytesize src/vendor/cargo_metadata src/vendor/colored src/vendor/commoncrypto @@ -65,7 +69,6 @@ src/vendor/crossbeam src/vendor/crossbeam-channel src/vendor/crossbeam-epoch - src/vendor/crossbeam-utils-0.4.1 src/vendor/crossbeam-utils src/vendor/crypto-hash src/vendor/curl @@ -80,7 +83,6 @@ src/vendor/fst src/vendor/futures src/vendor/fwdansi - src/vendor/getset src/vendor/git2 src/vendor/git2-curl src/vendor/glob @@ -89,13 +91,13 @@ src/vendor/home src/vendor/if_chain src/vendor/ignore - src/vendor/isatty src/vendor/json src/vendor/jsonrpc-core src/vendor/kernel32-sys src/vendor/languageserver-types src/vendor/lazycell src/vendor/libgit2-sys + src/vendor/libnghttp2-sys src/vendor/libssh2-sys src/vendor/libz-sys src/vendor/log-0.3.9 @@ -106,7 +108,8 @@ src/vendor/openssl-src src/vendor/openssl-sys src/vendor/ordslice - src/vendor/parking_lot-0.5.5 + src/vendor/packed_simd + src/vendor/proptest src/vendor/quine-mc_cluskey src/vendor/racer src/vendor/rls-analysis @@ -114,6 +117,7 @@ src/vendor/rls-rustc src/vendor/rls-vfs src/vendor/rustc-ap-arena + src/vendor/rustc-ap-graphviz src/vendor/rustc-ap-rustc_cratesio_shim src/vendor/rustc-ap-rustc_data_structures src/vendor/rustc-ap-rustc_errors @@ -122,20 +126,21 @@ src/vendor/rustc-ap-syntax src/vendor/rustc-ap-syntax_pos src/vendor/rustc_version + src/vendor/rusty-fork src/vendor/schannel src/vendor/semver src/vendor/semver-parser src/vendor/serde_ignored src/vendor/shell-escape + src/vendor/syn src/vendor/term - src/vendor/termcolor-0.3.6 src/vendor/unicode-segmentation src/vendor/url_serde src/vendor/vcpkg src/vendor/vergen + src/vendor/wait-timeout src/vendor/winapi-0.2.8 src/vendor/winapi-build - src/vendor/wincolor-0.1.6 # DO NOT EDIT above, AUTOGENERATED Files: C*.md diff -Nru rustc-1.30.0+dfsg1+llvm/debian/libstd-rust-1.30.lintian-overrides rustc-1.31.0+dfsg1+llvm/debian/libstd-rust-1.30.lintian-overrides --- rustc-1.30.0+dfsg1+llvm/debian/libstd-rust-1.30.lintian-overrides 2018-11-12 22:23:20.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/debian/libstd-rust-1.30.lintian-overrides 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -# "libstd" just seemed too generic -libstd-rust-1.30 binary: package-name-doesnt-match-sonames - -# Rust doesn't use dev shlib symlinks nor any of the other shlib support stuff -libstd-rust-1.30 binary: dev-pkg-without-shlib-symlink -libstd-rust-1.30 binary: shlib-without-versioned-soname -libstd-rust-1.30 binary: unused-shlib-entry-in-control-file - -# Libraries that use libc symbols (libterm, libstd, etc) *are* linked -# to libc. Lintian gets upset that some Rust libraries don't need -# libc, boo hoo. -libstd-rust-1.30 binary: library-not-linked-against-libc diff -Nru rustc-1.30.0+dfsg1+llvm/debian/libstd-rust-1.31.lintian-overrides rustc-1.31.0+dfsg1+llvm/debian/libstd-rust-1.31.lintian-overrides --- rustc-1.30.0+dfsg1+llvm/debian/libstd-rust-1.31.lintian-overrides 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/debian/libstd-rust-1.31.lintian-overrides 2019-01-22 23:11:37.000000000 +0000 @@ -0,0 +1,12 @@ +# "libstd" just seemed too generic +libstd-rust-1.31 binary: package-name-doesnt-match-sonames + +# Rust doesn't use dev shlib symlinks nor any of the other shlib support stuff +libstd-rust-1.31 binary: dev-pkg-without-shlib-symlink +libstd-rust-1.31 binary: shlib-without-versioned-soname +libstd-rust-1.31 binary: unused-shlib-entry-in-control-file + +# Libraries that use libc symbols (libterm, libstd, etc) *are* linked +# to libc. Lintian gets upset that some Rust libraries don't need +# libc, boo hoo. +libstd-rust-1.31 binary: library-not-linked-against-libc diff -Nru rustc-1.30.0+dfsg1+llvm/debian/patches/d-ignore-avx-44056.patch rustc-1.31.0+dfsg1+llvm/debian/patches/d-ignore-avx-44056.patch --- rustc-1.30.0+dfsg1+llvm/debian/patches/d-ignore-avx-44056.patch 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/debian/patches/d-ignore-avx-44056.patch 2019-01-22 23:11:37.000000000 +0000 @@ -0,0 +1,12 @@ +Bug: https://github.com/rust-lang/rust/pull/55667 +--- a/src/test/ui/issues/issue-44056.rs ++++ b/src/test/ui/issues/issue-44056.rs +@@ -9,7 +9,7 @@ + // except according to those terms. + + // compile-pass +-// only-x86_64 ++// ignore-test + // no-prefer-dynamic + // compile-flags: -Ctarget-feature=+avx -Clto + diff -Nru rustc-1.30.0+dfsg1+llvm/debian/patches/d-ignore-error-detail-diff.patch rustc-1.31.0+dfsg1+llvm/debian/patches/d-ignore-error-detail-diff.patch --- rustc-1.30.0+dfsg1+llvm/debian/patches/d-ignore-error-detail-diff.patch 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/debian/patches/d-ignore-error-detail-diff.patch 2019-01-22 23:11:37.000000000 +0000 @@ -0,0 +1,36 @@ +Description: Ignore error details with $SRC_DIR + We build with --remap-path-prefix so it doesn't work, see bug below +Bug: https://github.com/rust-lang/rust/issues/53081 +--- a/src/test/ui/impl-trait/impl-generic-mismatch.stderr ++++ b/src/test/ui/impl-trait/impl-generic-mismatch.stderr +@@ -29,11 +29,6 @@ + | + LL | fn hash(&self, hasher: &mut impl Hasher) {} + | ^^^^^^^^^^^ expected generic parameter, found `impl Trait` +- | +- ::: $SRC_DIR/libcore/hash/mod.rs:LL:COL +- | +-LL | fn hash(&self, state: &mut H); +- | - declaration in trait here + + error: aborting due to 3 previous errors + +--- a/src/test/ui/consts/const-size_of-cycle.stderr ++++ b/src/test/ui/consts/const-size_of-cycle.stderr +@@ -2,16 +2,8 @@ + | + note: ...which requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All }, value: [u8; _] }`... + note: ...which requires const-evaluating `Foo::bytes::{{constant}}`... +- --> $SRC_DIR/libcore/mem.rs:LL:COL +- | +-LL | intrinsics::size_of::() +- | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: ...which again requires computing layout of `Foo`, completing the cycle + note: cycle used when const-evaluating `Foo::bytes::{{constant}}` +- --> $SRC_DIR/libcore/mem.rs:LL:COL +- | +-LL | intrinsics::size_of::() +- | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + + error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/debian/patches/d-ignore-impl-generic-mismatch-diff.patch rustc-1.31.0+dfsg1+llvm/debian/patches/d-ignore-impl-generic-mismatch-diff.patch --- rustc-1.30.0+dfsg1+llvm/debian/patches/d-ignore-impl-generic-mismatch-diff.patch 2018-11-12 22:23:20.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/debian/patches/d-ignore-impl-generic-mismatch-diff.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -Bug: https://github.com/rust-lang/rust/issues/53081 ---- a/src/test/ui/impl-trait/impl-generic-mismatch.stderr -+++ b/src/test/ui/impl-trait/impl-generic-mismatch.stderr -@@ -29,11 +29,6 @@ - | - LL | fn hash(&self, hasher: &mut impl Hasher) {} - | ^^^^^^^^^^^ expected generic parameter, found `impl Trait` -- | -- ::: $SRC_DIR/libcore/hash/mod.rs:LL:COL -- | --LL | fn hash(&self, state: &mut H); -- | - declaration in trait here - - error: aborting due to 3 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/debian/patches/d-ignore-removed-submodules.patch rustc-1.31.0+dfsg1+llvm/debian/patches/d-ignore-removed-submodules.patch --- rustc-1.30.0+dfsg1+llvm/debian/patches/d-ignore-removed-submodules.patch 2018-10-10 22:45:57.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/debian/patches/d-ignore-removed-submodules.patch 2019-01-22 23:11:37.000000000 +0000 @@ -26,7 +26,7 @@ "tools/rustdoc-themes", ] exclude = [ -@@ -44,23 +37,7 @@ +@@ -44,24 +37,7 @@ debug = false debug-assertions = false @@ -48,8 +48,9 @@ # here rustc-workspace-hack = { path = 'tools/rustc-workspace-hack' } - --[patch."https://github.com/rust-lang-nursery/rust-clippy"] +-[patch."https://github.com/rust-lang/rust-clippy"] -clippy_lints = { path = "tools/clippy/clippy_lints" } +-rustc_tools_util = { path = "tools/clippy/rustc_tools_util" } --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -639,10 +639,6 @@ diff -Nru rustc-1.30.0+dfsg1+llvm/debian/patches/d-no-web-dependencies-in-doc.patch rustc-1.31.0+dfsg1+llvm/debian/patches/d-no-web-dependencies-in-doc.patch --- rustc-1.30.0+dfsg1+llvm/debian/patches/d-no-web-dependencies-in-doc.patch 2018-09-27 03:01:46.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/debian/patches/d-no-web-dependencies-in-doc.patch 2019-01-22 23:11:37.000000000 +0000 @@ -23,129 +23,6 @@ let mut parts = url.splitn(2, "#"); let url = parts.next().unwrap(); let fragment = parts.next(); ---- a/src/doc/rust-by-example/theme/index.hbs -+++ b/src/doc/rust-by-example/theme/index.hbs -@@ -10,15 +10,13 @@ - - - -- -- - - - - -- -+ - -- -+ - - - -@@ -29,27 +27,10 @@ - - {{#if mathjax_support}} - -- -+ - {{/if}} - -- -- -- -- -- -- -- -- -- -- -+ - - - {{#each additional_js}} -@@ -58,20 +39,6 @@ - - - -- -- -- -- -- -- - -@@ -134,42 +101,9 @@ - - - -- -- -- - - {{{livereload}}} - -- {{#if google_analytics}} -- -- {{/if}} -- -- {{#if playpens_editable}} -- -- -- -- -- -- {{/if}} -- - {{#if is_print}} - - {{/if}} - -- -+ - - - --- a/src/vendor/mdbook/src/book/init.rs +++ b/src/vendor/mdbook/src/book/init.rs @@ -136,12 +136,6 @@ diff -Nru rustc-1.30.0+dfsg1+llvm/debian/patches/d-relax-xz-utils-dependency.patch rustc-1.31.0+dfsg1+llvm/debian/patches/d-relax-xz-utils-dependency.patch --- rustc-1.30.0+dfsg1+llvm/debian/patches/d-relax-xz-utils-dependency.patch 2018-11-12 22:42:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/debian/patches/d-relax-xz-utils-dependency.patch 2019-01-22 23:11:37.000000000 +0000 @@ -6,7 +6,7 @@ --- a/src/vendor/xz2/src/stream.rs +++ b/src/vendor/xz2/src/stream.rs -@@ -29,6 +29,7 @@ +@@ -32,6 +32,7 @@ } /// Builder to create a multi-threaded stream encoder. @@ -14,7 +14,7 @@ pub struct MtStreamBuilder { raw: lzma_sys::lzma_mt, filters: Option, -@@ -688,6 +689,7 @@ +@@ -691,6 +692,7 @@ } } diff -Nru rustc-1.30.0+dfsg1+llvm/debian/patches/series rustc-1.31.0+dfsg1+llvm/debian/patches/series --- rustc-1.30.0+dfsg1+llvm/debian/patches/series 2018-11-12 22:42:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/debian/patches/series 2019-01-22 23:11:37.000000000 +0000 @@ -8,16 +8,13 @@ u-make-tests-work-without-rpath.patch u-mips-fixes.diff -# https://github.com/rust-lang/compiler-rt/pull/35/ -u-compiler-rt.patch - -# Extra ignored tests. We now instead raise FAILURES_ALLOWED in d/rules but -# these patches are kept in case they are useful for derivatives. -#u-ignoretest-ppc64el_02.patch - # not forwarded, or forwarded but unlikely to be merged u-reproducible-dl-stage0.patch +# this isn't ready yet for 1.31.0, causes segfaults compiling with LTO +#u-debuginfo-gdb-8.2.patch +d-temp-ignore-debuginfo-gdb-enum.patch + gcc-4.8-aarch64-ice.diff # Porter fixes under discussion, not suitable for upstreaming # as-is but a proper fix is being discussed @@ -25,15 +22,15 @@ d-sparc64-dont-pack-spans.patch # Debian-specific patches, not suitable for upstream +d-ignore-error-detail-diff.patch d-disable-cargo-vendor.patch -d-temp-ignore-debuginfo-gdb-enum.patch d-rust-gdb-paths d-rust-lldb-paths d-add-soname.patch d-dont-download-stage0.patch d-ignore-removed-submodules.patch d-read-beta-version-from-file.patch -d-ignore-impl-generic-mismatch-diff.patch +d-ignore-avx-44056.patch d-i686-baseline.patch d-no-web-dependencies-in-doc.patch diff -Nru rustc-1.30.0+dfsg1+llvm/debian/patches/u-compiler-rt.patch rustc-1.31.0+dfsg1+llvm/debian/patches/u-compiler-rt.patch --- rustc-1.30.0+dfsg1+llvm/debian/patches/u-compiler-rt.patch 2018-10-10 22:45:57.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/debian/patches/u-compiler-rt.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -From 7e62cd4e886a0e3f08e710e0625a7bed9ccbdf51 Mon Sep 17 00:00:00 2001 -From: John Paul Adrian Glaubitz -Date: Tue, 30 Jan 2018 03:00:16 +0100 -Subject: [PATCH] Re-add workaround for LLVM bug 11663 - ---- - lib/builtins/int_lib.h | 22 ++++++++++++++++++++++ - 1 file changed, 22 insertions(+) - ---- a/src/libcompiler_builtins/compiler-rt/lib/builtins/int_lib.h -+++ b/src/libcompiler_builtins/compiler-rt/lib/builtins/int_lib.h -@@ -99,6 +99,28 @@ - #define __builtin_ctz __ctzsi2 - #endif /* sparc64 || mips_n64 || mips_o64 || riscv */ - -+/* -+ * Workaround for LLVM bug 11663. Prevent endless recursion in -+ * __c?zdi2(), where calls to __builtin_c?z() are expanded to -+ * __c?zdi2() instead of __c?zsi2(). -+ * -+ * Instead of placing this workaround in c?zdi2.c, put it in this -+ * global header to prevent other C files from making the detour -+ * through __c?zdi2() as well. -+ * -+ * This problem has been observed on FreeBSD for sparc64 and -+ * mips64 with GCC 4.2.1, and for riscv with GCC 5.2.0. -+ * Presumably it's any version of GCC, and targeting an arch that -+ * does not have dedicated bit counting instructions. -+ */ -+#if ((defined(__sparc__) && defined(__arch64__)) || defined(__mips_n64) || defined(__mips_o64) || defined(__riscv__) \ -+ || (defined(_MIPS_SIM) && ((_MIPS_SIM == _ABI64) || (_MIPS_SIM == _ABIO64)))) -+si_int __clzsi2(si_int); -+si_int __ctzsi2(si_int); -+#define __builtin_clz __clzsi2 -+#define __builtin_ctz __ctzsi2 -+#endif /* sparc64 || mips_n64 || mips_o64 || riscv */ -+ - COMPILER_RT_ABI si_int __paritysi2(si_int a); - COMPILER_RT_ABI si_int __paritydi2(di_int a); - diff -Nru rustc-1.30.0+dfsg1+llvm/debian/patches/u-debuginfo-gdb-8.2.patch rustc-1.31.0+dfsg1+llvm/debian/patches/u-debuginfo-gdb-8.2.patch --- rustc-1.30.0+dfsg1+llvm/debian/patches/u-debuginfo-gdb-8.2.patch 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/debian/patches/u-debuginfo-gdb-8.2.patch 2019-01-22 23:11:37.000000000 +0000 @@ -0,0 +1,1642 @@ +Bug: https://github.com/rust-lang/rust/pull/54004 +Description: Fix DWARF generation for enums + git diff e8aef7cae1..8bbb62f849 +--- a/src/ci/docker/x86_64-gnu/Dockerfile ++++ b/src/ci/docker/x86_64-gnu/Dockerfile +@@ -1,4 +1,4 @@ +-FROM ubuntu:16.04 ++FROM ubuntu:18.10 + + RUN apt-get update && apt-get install -y --no-install-recommends \ + g++ \ +--- a/src/librustc_codegen_llvm/debuginfo/metadata.rs ++++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs +@@ -31,9 +31,10 @@ + use rustc::ich::NodeIdHashingMode; + use rustc_data_structures::fingerprint::Fingerprint; + use rustc::ty::Instance; +-use common::CodegenCx; ++use common::{CodegenCx, C_u64}; + use rustc::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt}; +-use rustc::ty::layout::{self, Align, LayoutOf, PrimitiveExt, Size, TyLayout}; ++use rustc::ty::layout::{self, Align, HasDataLayout, Integer, IntegerExt, LayoutOf, ++ PrimitiveExt, Size, TyLayout}; + use rustc::session::config; + use rustc::util::nodemap::FxHashMap; + use rustc_fs_util::path2cstr; +@@ -205,6 +206,7 @@ + unfinished_type: Ty<'tcx>, + unique_type_id: UniqueTypeId, + metadata_stub: &'ll DICompositeType, ++ member_holding_stub: &'ll DICompositeType, + member_description_factory: MemberDescriptionFactory<'ll, 'tcx>, + }, + FinalMetadata(&'ll DICompositeType) +@@ -215,6 +217,7 @@ + unfinished_type: Ty<'tcx>, + unique_type_id: UniqueTypeId, + metadata_stub: &'ll DICompositeType, ++ member_holding_stub: &'ll DICompositeType, + member_description_factory: MemberDescriptionFactory<'ll, 'tcx>, + ) -> RecursiveTypeDescription<'ll, 'tcx> { + +@@ -227,6 +230,7 @@ + unfinished_type, + unique_type_id, + metadata_stub, ++ member_holding_stub, + member_description_factory, + } + } +@@ -242,6 +246,7 @@ + unfinished_type, + unique_type_id, + metadata_stub, ++ member_holding_stub, + ref member_description_factory, + } => { + // Make sure that we have a forward declaration of the type in +@@ -266,7 +271,7 @@ + + // ... and attach them to the stub to complete it. + set_members_of_composite_type(cx, +- metadata_stub, ++ member_holding_stub, + member_descriptions); + return MetadataCreationResult::new(metadata_stub, true); + } +@@ -350,6 +355,7 @@ + size: pointer_size, + align: pointer_align, + flags: DIFlags::FlagZero, ++ discriminant: None, + }, + MemberDescription { + name: "length".to_owned(), +@@ -358,6 +364,7 @@ + size: usize_size, + align: usize_align, + flags: DIFlags::FlagZero, ++ discriminant: None, + }, + ]; + +@@ -458,6 +465,7 @@ + size: data_ptr_field.size, + align: data_ptr_field.align, + flags: DIFlags::FlagArtificial, ++ discriminant: None, + }, + MemberDescription { + name: "vtable".to_owned(), +@@ -466,6 +474,7 @@ + size: vtable_field.size, + align: vtable_field.align, + flags: DIFlags::FlagArtificial, ++ discriminant: None, + }, + ]; + +@@ -914,6 +923,7 @@ + size: Size, + align: Align, + flags: DIFlags, ++ discriminant: Option, + } + + // A factory for MemberDescriptions. It produces a list of member descriptions +@@ -981,6 +991,7 @@ + size, + align, + flags: DIFlags::FlagZero, ++ discriminant: None, + } + }).collect() + } +@@ -1013,6 +1024,7 @@ + struct_type, + unique_type_id, + struct_metadata_stub, ++ struct_metadata_stub, + StructMDF(StructMemberDescriptionFactory { + ty: struct_type, + variant, +@@ -1045,6 +1057,7 @@ + size, + align, + flags: DIFlags::FlagZero, ++ discriminant: None, + } + }).collect() + } +@@ -1059,15 +1072,18 @@ + ) -> RecursiveTypeDescription<'ll, 'tcx> { + let tuple_name = compute_debuginfo_type_name(cx, tuple_type, false); + ++ let struct_stub = create_struct_stub(cx, ++ tuple_type, ++ &tuple_name[..], ++ unique_type_id, ++ NO_SCOPE_METADATA); ++ + create_and_register_recursive_type_forward_declaration( + cx, + tuple_type, + unique_type_id, +- create_struct_stub(cx, +- tuple_type, +- &tuple_name[..], +- unique_type_id, +- NO_SCOPE_METADATA), ++ struct_stub, ++ struct_stub, + TupleMDF(TupleMemberDescriptionFactory { + ty: tuple_type, + component_types: component_types.to_vec(), +@@ -1099,6 +1115,7 @@ + size, + align, + flags: DIFlags::FlagZero, ++ discriminant: None, + } + }).collect() + } +@@ -1130,6 +1147,7 @@ + union_type, + unique_type_id, + union_metadata_stub, ++ union_metadata_stub, + UnionMDF(UnionMemberDescriptionFactory { + layout: cx.layout_of(union_type), + variant, +@@ -1142,6 +1160,20 @@ + // Enums + //=----------------------------------------------------------------------------- + ++// DWARF variant support is only available starting in LLVM 7. ++// Although the earlier enum debug info output did not work properly ++// in all situations, it is better for the time being to continue to ++// sometimes emit the old style rather than emit something completely ++// useless when rust is compiled against LLVM 6 or older. This ++// function decides which representation will be emitted. ++fn use_enum_fallback(cx: &CodegenCx) -> bool { ++ // On MSVC we have to use the fallback mode, because LLVM doesn't ++ // lower variant parts to PDB. ++ return cx.sess().target.target.options.is_like_msvc || unsafe { ++ llvm::LLVMRustVersionMajor() < 7 ++ }; ++} ++ + // Describes the members of an enum value: An enum is described as a union of + // structs in DWARF. This MemberDescriptionFactory provides the description for + // the members of this union; so for every variant of the given enum, this +@@ -1159,6 +1191,15 @@ + fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>) + -> Vec> { + let adt = &self.enum_type.ty_adt_def().unwrap(); ++ ++ // This will always find the metadata in the type map. ++ let fallback = use_enum_fallback(cx); ++ let self_metadata = if fallback { ++ self.containing_scope ++ } else { ++ type_metadata(cx, self.enum_type, self.span) ++ }; ++ + match self.layout.variants { + layout::Variants::Single { .. } if adt.variants.is_empty() => vec![], + layout::Variants::Single { index } => { +@@ -1167,7 +1208,7 @@ + self.layout, + &adt.variants[index], + NoDiscriminant, +- self.containing_scope, ++ self_metadata, + self.span); + + let member_descriptions = +@@ -1178,18 +1219,28 @@ + member_descriptions); + vec![ + MemberDescription { +- name: String::new(), ++ name: if fallback { ++ String::new() ++ } else { ++ adt.variants[index].name.as_str().to_string() ++ }, + type_metadata: variant_type_metadata, + offset: Size::ZERO, + size: self.layout.size, + align: self.layout.align, +- flags: DIFlags::FlagZero ++ flags: DIFlags::FlagZero, ++ discriminant: None, + } + ] + } + layout::Variants::Tagged { ref variants, .. } => { +- let discriminant_info = RegularDiscriminant(self.discriminant_type_metadata +- .expect("")); ++ let discriminant_info = if fallback { ++ RegularDiscriminant(self.discriminant_type_metadata ++ .expect("")) ++ } else { ++ // This doesn't matter in this case. ++ NoDiscriminant ++ }; + (0..variants.len()).map(|i| { + let variant = self.layout.for_variant(cx, i); + let (variant_type_metadata, member_desc_factory) = +@@ -1197,7 +1248,7 @@ + variant, + &adt.variants[i], + discriminant_info, +- self.containing_scope, ++ self_metadata, + self.span); + + let member_descriptions = member_desc_factory +@@ -1207,75 +1258,127 @@ + variant_type_metadata, + member_descriptions); + MemberDescription { +- name: String::new(), ++ name: if fallback { ++ String::new() ++ } else { ++ adt.variants[i].name.as_str().to_string() ++ }, + type_metadata: variant_type_metadata, + offset: Size::ZERO, +- size: variant.size, +- align: variant.align, +- flags: DIFlags::FlagZero ++ size: self.layout.size, ++ align: self.layout.align, ++ flags: DIFlags::FlagZero, ++ discriminant: Some(self.layout.ty.ty_adt_def().unwrap() ++ .discriminant_for_variant(cx.tcx, i) ++ .val as u64), + } + }).collect() + } +- layout::Variants::NicheFilling { dataful_variant, ref niche_variants, .. } => { +- let variant = self.layout.for_variant(cx, dataful_variant); +- // Create a description of the non-null variant +- let (variant_type_metadata, member_description_factory) = +- describe_enum_variant(cx, +- variant, +- &adt.variants[dataful_variant], +- OptimizedDiscriminant, +- self.containing_scope, +- self.span); ++ layout::Variants::NicheFilling { ++ ref niche_variants, ++ niche_start, ++ ref variants, ++ dataful_variant, ++ .. ++ } => { ++ if fallback { ++ let variant = self.layout.for_variant(cx, dataful_variant); ++ // Create a description of the non-null variant ++ let (variant_type_metadata, member_description_factory) = ++ describe_enum_variant(cx, ++ variant, ++ &adt.variants[dataful_variant], ++ OptimizedDiscriminant, ++ self.containing_scope, ++ self.span); + +- let variant_member_descriptions = +- member_description_factory.create_member_descriptions(cx); ++ let variant_member_descriptions = ++ member_description_factory.create_member_descriptions(cx); + +- set_members_of_composite_type(cx, +- variant_type_metadata, +- variant_member_descriptions); ++ set_members_of_composite_type(cx, ++ variant_type_metadata, ++ variant_member_descriptions); + +- // Encode the information about the null variant in the union +- // member's name. +- let mut name = String::from("RUST$ENCODED$ENUM$"); +- // HACK(eddyb) the debuggers should just handle offset+size +- // of discriminant instead of us having to recover its path. +- // Right now it's not even going to work for `niche_start > 0`, +- // and for multiple niche variants it only supports the first. +- fn compute_field_path<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, +- name: &mut String, +- layout: TyLayout<'tcx>, +- offset: Size, +- size: Size) { +- for i in 0..layout.fields.count() { +- let field_offset = layout.fields.offset(i); +- if field_offset > offset { +- continue; +- } +- let inner_offset = offset - field_offset; +- let field = layout.field(cx, i); +- if inner_offset + size <= field.size { +- write!(name, "{}$", i).unwrap(); +- compute_field_path(cx, name, field, inner_offset, size); ++ // Encode the information about the null variant in the union ++ // member's name. ++ let mut name = String::from("RUST$ENCODED$ENUM$"); ++ // Right now it's not even going to work for `niche_start > 0`, ++ // and for multiple niche variants it only supports the first. ++ fn compute_field_path<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, ++ name: &mut String, ++ layout: TyLayout<'tcx>, ++ offset: Size, ++ size: Size) { ++ for i in 0..layout.fields.count() { ++ let field_offset = layout.fields.offset(i); ++ if field_offset > offset { ++ continue; ++ } ++ let inner_offset = offset - field_offset; ++ let field = layout.field(cx, i); ++ if inner_offset + size <= field.size { ++ write!(name, "{}$", i).unwrap(); ++ compute_field_path(cx, name, field, inner_offset, size); ++ } + } + } ++ compute_field_path(cx, &mut name, ++ self.layout, ++ self.layout.fields.offset(0), ++ self.layout.field(cx, 0).size); ++ name.push_str(&adt.variants[*niche_variants.start()].name.as_str()); ++ ++ // Create the (singleton) list of descriptions of union members. ++ vec![ ++ MemberDescription { ++ name, ++ type_metadata: variant_type_metadata, ++ offset: Size::ZERO, ++ size: variant.size, ++ align: variant.align, ++ flags: DIFlags::FlagZero, ++ discriminant: None, ++ } ++ ] ++ } else { ++ (0..variants.len()).map(|i| { ++ let variant = self.layout.for_variant(cx, i); ++ let (variant_type_metadata, member_desc_factory) = ++ describe_enum_variant(cx, ++ variant, ++ &adt.variants[i], ++ OptimizedDiscriminant, ++ self_metadata, ++ self.span); ++ ++ let member_descriptions = member_desc_factory ++ .create_member_descriptions(cx); ++ ++ set_members_of_composite_type(cx, ++ variant_type_metadata, ++ member_descriptions); ++ ++ let niche_value = if i == dataful_variant { ++ None ++ } else { ++ let niche = (i as u128) ++ .wrapping_sub(*niche_variants.start() as u128) ++ .wrapping_add(niche_start); ++ assert_eq!(niche as u64 as u128, niche); ++ Some(niche as u64) ++ }; ++ ++ MemberDescription { ++ name: adt.variants[i].name.as_str().to_string(), ++ type_metadata: variant_type_metadata, ++ offset: Size::ZERO, ++ size: self.layout.size, ++ align: self.layout.align, ++ flags: DIFlags::FlagZero, ++ discriminant: niche_value, ++ } ++ }).collect() + } +- compute_field_path(cx, &mut name, +- self.layout, +- self.layout.fields.offset(0), +- self.layout.field(cx, 0).size); +- name.push_str(&adt.variants[*niche_variants.start()].name.as_str()); +- +- // Create the (singleton) list of descriptions of union members. +- vec![ +- MemberDescription { +- name, +- type_metadata: variant_type_metadata, +- offset: Size::ZERO, +- size: variant.size, +- align: variant.align, +- flags: DIFlags::FlagZero +- } +- ] + } + } + } +@@ -1297,14 +1400,19 @@ + let (size, align) = cx.size_and_align_of(ty); + MemberDescription { + name: name.to_string(), +- type_metadata: match self.discriminant_type_metadata { +- Some(metadata) if i == 0 => metadata, +- _ => type_metadata(cx, ty, self.span) ++ type_metadata: if use_enum_fallback(cx) { ++ match self.discriminant_type_metadata { ++ Some(metadata) if i == 0 => metadata, ++ _ => type_metadata(cx, ty, self.span) ++ } ++ } else { ++ type_metadata(cx, ty, self.span) + }, + offset: self.offsets[i], + size, + align, +- flags: DIFlags::FlagZero ++ flags: DIFlags::FlagZero, ++ discriminant: None, + } + }).collect() + } +@@ -1317,10 +1425,10 @@ + NoDiscriminant + } + +-// Returns a tuple of (1) type_metadata_stub of the variant, (2) the llvm_type +-// of the variant, and (3) a MemberDescriptionFactory for producing the +-// descriptions of the fields of the variant. This is a rudimentary version of a +-// full RecursiveTypeDescription. ++// Returns a tuple of (1) type_metadata_stub of the variant, (2) a ++// MemberDescriptionFactory for producing the descriptions of the ++// fields of the variant. This is a rudimentary version of a full ++// RecursiveTypeDescription. + fn describe_enum_variant( + cx: &CodegenCx<'ll, 'tcx>, + layout: layout::TyLayout<'tcx>, +@@ -1343,29 +1451,46 @@ + unique_type_id, + Some(containing_scope)); + +- // If this is not a univariant enum, there is also the discriminant field. +- let (discr_offset, discr_arg) = match discriminant_info { +- RegularDiscriminant(_) => { +- // We have the layout of an enum variant, we need the layout of the outer enum +- let enum_layout = cx.layout_of(layout.ty); +- (Some(enum_layout.fields.offset(0)), +- Some(("RUST$ENUM$DISR".to_owned(), enum_layout.field(cx, 0).ty))) +- } +- _ => (None, None), +- }; +- let offsets = discr_offset.into_iter().chain((0..layout.fields.count()).map(|i| { +- layout.fields.offset(i) +- })).collect(); +- + // Build an array of (field name, field type) pairs to be captured in the factory closure. +- let args = discr_arg.into_iter().chain((0..layout.fields.count()).map(|i| { +- let name = if variant.ctor_kind == CtorKind::Fn { +- format!("__{}", i) +- } else { +- variant.fields[i].ident.to_string() ++ let (offsets, args) = if use_enum_fallback(cx) { ++ // If this is not a univariant enum, there is also the discriminant field. ++ let (discr_offset, discr_arg) = match discriminant_info { ++ RegularDiscriminant(_) => { ++ // We have the layout of an enum variant, we need the layout of the outer enum ++ let enum_layout = cx.layout_of(layout.ty); ++ (Some(enum_layout.fields.offset(0)), ++ Some(("RUST$ENUM$DISR".to_owned(), enum_layout.field(cx, 0).ty))) ++ } ++ _ => (None, None), + }; +- (name, layout.field(cx, i).ty) +- })).collect(); ++ ( ++ discr_offset.into_iter().chain((0..layout.fields.count()).map(|i| { ++ layout.fields.offset(i) ++ })).collect(), ++ discr_arg.into_iter().chain((0..layout.fields.count()).map(|i| { ++ let name = if variant.ctor_kind == CtorKind::Fn { ++ format!("__{}", i) ++ } else { ++ variant.fields[i].ident.to_string() ++ }; ++ (name, layout.field(cx, i).ty) ++ })).collect() ++ ) ++ } else { ++ ( ++ (0..layout.fields.count()).map(|i| { ++ layout.fields.offset(i) ++ }).collect(), ++ (0..layout.fields.count()).map(|i| { ++ let name = if variant.ctor_kind == CtorKind::Fn { ++ format!("__{}", i) ++ } else { ++ variant.fields[i].ident.to_string() ++ }; ++ (name, layout.field(cx, i).ty) ++ }).collect() ++ ) ++ }; + + let member_description_factory = + VariantMDF(VariantMemberDescriptionFactory { +@@ -1401,22 +1526,22 @@ + // + let file_metadata = unknown_file_metadata(cx); + +- let def = enum_type.ty_adt_def().unwrap(); +- let enumerators_metadata: Vec<_> = def.discriminants(cx.tcx) +- .zip(&def.variants) +- .map(|(discr, v)| { +- let name = SmallCStr::new(&v.name.as_str()); +- unsafe { +- Some(llvm::LLVMRustDIBuilderCreateEnumerator( +- DIB(cx), +- name.as_ptr(), +- // FIXME: what if enumeration has i128 discriminant? +- discr.val as u64)) +- } +- }) +- .collect(); +- + let discriminant_type_metadata = |discr: layout::Primitive| { ++ let def = enum_type.ty_adt_def().unwrap(); ++ let enumerators_metadata: Vec<_> = def.discriminants(cx.tcx) ++ .zip(&def.variants) ++ .map(|(discr, v)| { ++ let name = SmallCStr::new(&v.name.as_str()); ++ unsafe { ++ Some(llvm::LLVMRustDIBuilderCreateEnumerator( ++ DIB(cx), ++ name.as_ptr(), ++ // FIXME: what if enumeration has i128 discriminant? ++ discr.val as u64)) ++ } ++ }) ++ .collect(); ++ + let disr_type_key = (enum_def_id, discr); + let cached_discriminant_type_metadata = debug_context(cx).created_enum_disr_types + .borrow() +@@ -1441,7 +1566,7 @@ + discriminant_size.bits(), + discriminant_align.abi_bits() as u32, + create_DIArray(DIB(cx), &enumerators_metadata), +- discriminant_base_type_metadata) ++ discriminant_base_type_metadata, true) + }; + + debug_context(cx).created_enum_disr_types +@@ -1455,16 +1580,10 @@ + + let layout = cx.layout_of(enum_type); + +- let discriminant_type_metadata = match layout.variants { +- layout::Variants::Single { .. } | +- layout::Variants::NicheFilling { .. } => None, +- layout::Variants::Tagged { ref tag, .. } => { +- Some(discriminant_type_metadata(tag.value)) +- } +- }; +- +- if let (&layout::Abi::Scalar(_), Some(discr)) = (&layout.abi, discriminant_type_metadata) { +- return FinalMetadata(discr); ++ match (&layout.abi, &layout.variants) { ++ (&layout::Abi::Scalar(_), &layout::Variants::Tagged {ref tag, .. }) => ++ return FinalMetadata(discriminant_type_metadata(tag.value)), ++ _ => {} + } + + let (enum_type_size, enum_type_align) = layout.size_and_align(); +@@ -1473,30 +1592,145 @@ + let unique_type_id_str = SmallCStr::new( + debug_context(cx).type_map.borrow().get_unique_type_id_as_string(unique_type_id) + ); +- let enum_metadata = unsafe { +- llvm::LLVMRustDIBuilderCreateUnionType( +- DIB(cx), +- containing_scope, +- enum_name.as_ptr(), +- file_metadata, +- UNKNOWN_LINE_NUMBER, +- enum_type_size.bits(), +- enum_type_align.abi_bits() as u32, +- DIFlags::FlagZero, +- None, +- 0, // RuntimeLang +- unique_type_id_str.as_ptr()) ++ ++ if use_enum_fallback(cx) { ++ let discriminant_type_metadata = match layout.variants { ++ layout::Variants::Single { .. } | ++ layout::Variants::NicheFilling { .. } => None, ++ layout::Variants::Tagged { ref tag, .. } => { ++ Some(discriminant_type_metadata(tag.value)) ++ } ++ }; ++ ++ let enum_metadata = unsafe { ++ llvm::LLVMRustDIBuilderCreateUnionType( ++ DIB(cx), ++ containing_scope, ++ enum_name.as_ptr(), ++ file_metadata, ++ UNKNOWN_LINE_NUMBER, ++ enum_type_size.bits(), ++ enum_type_align.abi_bits() as u32, ++ DIFlags::FlagZero, ++ None, ++ 0, // RuntimeLang ++ unique_type_id_str.as_ptr()) ++ }; ++ ++ return create_and_register_recursive_type_forward_declaration( ++ cx, ++ enum_type, ++ unique_type_id, ++ enum_metadata, ++ enum_metadata, ++ EnumMDF(EnumMemberDescriptionFactory { ++ enum_type, ++ layout, ++ discriminant_type_metadata, ++ containing_scope, ++ span, ++ }), ++ ); ++ } ++ ++ let discriminator_metadata = match &layout.variants { ++ // A single-variant enum has no discriminant. ++ &layout::Variants::Single { .. } => None, ++ ++ &layout::Variants::NicheFilling { ref niche, .. } => { ++ // Find the integer type of the correct size. ++ let size = niche.value.size(cx); ++ let align = niche.value.align(cx); ++ ++ let discr_type = match niche.value { ++ layout::Int(t, _) => t, ++ layout::Float(layout::FloatTy::F32) => Integer::I32, ++ layout::Float(layout::FloatTy::F64) => Integer::I64, ++ layout::Pointer => cx.data_layout().ptr_sized_integer(), ++ }.to_ty(cx.tcx, false); ++ ++ let discr_metadata = basic_type_metadata(cx, discr_type); ++ unsafe { ++ Some(llvm::LLVMRustDIBuilderCreateMemberType( ++ DIB(cx), ++ containing_scope, ++ ptr::null_mut(), ++ file_metadata, ++ UNKNOWN_LINE_NUMBER, ++ size.bits(), ++ align.abi_bits() as u32, ++ layout.fields.offset(0).bits(), ++ DIFlags::FlagArtificial, ++ discr_metadata)) ++ } ++ }, ++ ++ &layout::Variants::Tagged { ref tag, .. } => { ++ let discr_type = tag.value.to_ty(cx.tcx); ++ let (size, align) = cx.size_and_align_of(discr_type); ++ ++ let discr_metadata = basic_type_metadata(cx, discr_type); ++ unsafe { ++ Some(llvm::LLVMRustDIBuilderCreateMemberType( ++ DIB(cx), ++ containing_scope, ++ ptr::null_mut(), ++ file_metadata, ++ UNKNOWN_LINE_NUMBER, ++ size.bits(), ++ align.abi_bits() as u32, ++ layout.fields.offset(0).bits(), ++ DIFlags::FlagArtificial, ++ discr_metadata)) ++ } ++ }, ++ }; ++ ++ let empty_array = create_DIArray(DIB(cx), &[]); ++ let variant_part = unsafe { ++ llvm::LLVMRustDIBuilderCreateVariantPart( ++ DIB(cx), ++ containing_scope, ++ ptr::null_mut(), ++ file_metadata, ++ UNKNOWN_LINE_NUMBER, ++ enum_type_size.bits(), ++ enum_type_align.abi_bits() as u32, ++ DIFlags::FlagZero, ++ discriminator_metadata, ++ empty_array, ++ unique_type_id_str.as_ptr()) ++ }; ++ ++ // The variant part must be wrapped in a struct according to DWARF. ++ let type_array = create_DIArray(DIB(cx), &[Some(variant_part)]); ++ let struct_wrapper = unsafe { ++ llvm::LLVMRustDIBuilderCreateStructType( ++ DIB(cx), ++ Some(containing_scope), ++ enum_name.as_ptr(), ++ file_metadata, ++ UNKNOWN_LINE_NUMBER, ++ enum_type_size.bits(), ++ enum_type_align.abi_bits() as u32, ++ DIFlags::FlagZero, ++ None, ++ type_array, ++ 0, ++ None, ++ unique_type_id_str.as_ptr()) + }; + + return create_and_register_recursive_type_forward_declaration( + cx, + enum_type, + unique_type_id, +- enum_metadata, ++ struct_wrapper, ++ variant_part, + EnumMDF(EnumMemberDescriptionFactory { + enum_type, + layout, +- discriminant_type_metadata, ++ discriminant_type_metadata: None, + containing_scope, + span, + }), +@@ -1565,7 +1799,7 @@ + .map(|member_description| { + let member_name = CString::new(member_description.name).unwrap(); + unsafe { +- Some(llvm::LLVMRustDIBuilderCreateMemberType( ++ Some(llvm::LLVMRustDIBuilderCreateVariantMemberType( + DIB(cx), + composite_type_metadata, + member_name.as_ptr(), +@@ -1574,6 +1808,10 @@ + member_description.size.bits(), + member_description.align.abi_bits() as u32, + member_description.offset.bits(), ++ match member_description.discriminant { ++ None => None, ++ Some(value) => Some(C_u64(cx, value)), ++ }, + member_description.flags, + member_description.type_metadata)) + } +--- a/src/librustc_codegen_llvm/llvm/ffi.rs ++++ b/src/librustc_codegen_llvm/llvm/ffi.rs +@@ -1307,6 +1307,19 @@ + Ty: &'a DIType) + -> &'a DIDerivedType; + ++ pub fn LLVMRustDIBuilderCreateVariantMemberType(Builder: &DIBuilder<'a>, ++ Scope: &'a DIScope, ++ Name: *const c_char, ++ File: &'a DIFile, ++ LineNumber: c_uint, ++ SizeInBits: u64, ++ AlignInBits: u32, ++ OffsetInBits: u64, ++ Discriminant: Option<&'a Value>, ++ Flags: DIFlags, ++ Ty: &'a DIType) ++ -> &'a DIType; ++ + pub fn LLVMRustDIBuilderCreateLexicalBlock(Builder: &DIBuilder<'a>, + Scope: &'a DIScope, + File: &'a DIFile, +@@ -1384,7 +1397,8 @@ + SizeInBits: u64, + AlignInBits: u32, + Elements: &'a DIArray, +- ClassType: &'a DIType) ++ ClassType: &'a DIType, ++ IsFixed: bool) + -> &'a DIType; + + pub fn LLVMRustDIBuilderCreateUnionType(Builder: &DIBuilder<'a>, +@@ -1400,6 +1414,19 @@ + UniqueId: *const c_char) + -> &'a DIType; + ++ pub fn LLVMRustDIBuilderCreateVariantPart(Builder: &DIBuilder<'a>, ++ Scope: &'a DIScope, ++ Name: *const c_char, ++ File: &'a DIFile, ++ LineNo: c_uint, ++ SizeInBits: u64, ++ AlignInBits: u32, ++ Flags: DIFlags, ++ Discriminator: Option<&'a DIDerivedType>, ++ Elements: &'a DIArray, ++ UniqueId: *const c_char) ++ -> &'a DIDerivedType; ++ + pub fn LLVMSetUnnamedAddr(GlobalVar: &Value, UnnamedAddr: Bool); + + pub fn LLVMRustDIBuilderCreateTemplateTypeParameter(Builder: &DIBuilder<'a>, +--- a/src/rustllvm/RustWrapper.cpp ++++ b/src/rustllvm/RustWrapper.cpp +@@ -713,6 +713,21 @@ + unwrapDI(VTableHolder), UniqueId)); + } + ++extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariantPart( ++ LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, ++ LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, ++ uint32_t AlignInBits, LLVMRustDIFlags Flags, LLVMMetadataRef Discriminator, ++ LLVMMetadataRef Elements, const char *UniqueId) { ++#if LLVM_VERSION_GE(7, 0) ++ return wrap(Builder->createVariantPart( ++ unwrapDI(Scope), Name, unwrapDI(File), LineNumber, ++ SizeInBits, AlignInBits, fromRust(Flags), unwrapDI(Discriminator), ++ DINodeArray(unwrapDI(Elements)), UniqueId)); ++#else ++ abort(); ++#endif ++} ++ + extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateMemberType( + LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, + LLVMMetadataRef File, unsigned LineNo, uint64_t SizeInBits, +@@ -724,6 +739,28 @@ + fromRust(Flags), unwrapDI(Ty))); + } + ++extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariantMemberType( ++ LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, ++ const char *Name, LLVMMetadataRef File, unsigned LineNo, uint64_t SizeInBits, ++ uint32_t AlignInBits, uint64_t OffsetInBits, LLVMValueRef Discriminant, ++ LLVMRustDIFlags Flags, LLVMMetadataRef Ty) { ++#if LLVM_VERSION_GE(7, 0) ++ llvm::ConstantInt* D = nullptr; ++ if (Discriminant) { ++ D = unwrap(Discriminant); ++ } ++ return wrap(Builder->createVariantMemberType(unwrapDI(Scope), Name, ++ unwrapDI(File), LineNo, ++ SizeInBits, AlignInBits, OffsetInBits, D, ++ fromRust(Flags), unwrapDI(Ty))); ++#else ++ return wrap(Builder->createMemberType(unwrapDI(Scope), Name, ++ unwrapDI(File), LineNo, ++ SizeInBits, AlignInBits, OffsetInBits, ++ fromRust(Flags), unwrapDI(Ty))); ++#endif ++} ++ + extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateLexicalBlock( + LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, + LLVMMetadataRef File, unsigned Line, unsigned Col) { +@@ -826,11 +863,19 @@ + LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, + LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, + uint32_t AlignInBits, LLVMMetadataRef Elements, +- LLVMMetadataRef ClassTy) { ++ LLVMMetadataRef ClassTy, bool IsFixed) { ++#if LLVM_VERSION_GE(7, 0) ++ return wrap(Builder->createEnumerationType( ++ unwrapDI(Scope), Name, unwrapDI(File), LineNumber, ++ SizeInBits, AlignInBits, DINodeArray(unwrapDI(Elements)), ++ unwrapDI(ClassTy), "", IsFixed)); ++#else ++ // Ignore IsFixed on older LLVM. + return wrap(Builder->createEnumerationType( + unwrapDI(Scope), Name, unwrapDI(File), LineNumber, + SizeInBits, AlignInBits, DINodeArray(unwrapDI(Elements)), +- unwrapDI(ClassTy))); ++ unwrapDI(ClassTy), "")); ++#endif + } + + extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateUnionType( +--- /dev/null ++++ b/src/test/codegen/enum-debug-clike.rs +@@ -0,0 +1,35 @@ ++// 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 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++// This test depends on a patch that was committed to upstream LLVM ++// before 7.0, then backported to the Rust LLVM fork. It tests that ++// debug info for "c-like" enums is properly emitted. ++ ++// ignore-tidy-linelength ++// ignore-windows ++// min-system-llvm-version 7.0 ++ ++// compile-flags: -g -C no-prepopulate-passes ++ ++// CHECK-LABEL: @main ++// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_enumeration_type,{{.*}}name: "E",{{.*}}flags: DIFlagFixedEnum,{{.*}} ++// CHECK: {{.*}}DIEnumerator{{.*}}name: "A",{{.*}}value: {{[0-9].*}} ++// CHECK: {{.*}}DIEnumerator{{.*}}name: "B",{{.*}}value: {{[0-9].*}} ++// CHECK: {{.*}}DIEnumerator{{.*}}name: "C",{{.*}}value: {{[0-9].*}} ++ ++#![allow(dead_code)] ++#![allow(unused_variables)] ++#![allow(unused_assignments)] ++ ++enum E { A, B, C } ++ ++pub fn main() { ++ let e = E::C; ++} +--- /dev/null ++++ b/src/test/codegen/enum-debug-niche.rs +@@ -0,0 +1,42 @@ ++// 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 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++// This test depends on a patch that was committed to upstream LLVM ++// before 7.0, then backported to the Rust LLVM fork. It tests that ++// optimized enum debug info accurately reflects the enum layout. ++ ++// ignore-tidy-linelength ++// ignore-windows ++// min-system-llvm-version 7.0 ++ ++// compile-flags: -g -C no-prepopulate-passes ++ ++// CHECK-LABEL: @main ++// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}discriminator:{{.*}} ++// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "A",{{.*}}extraData:{{.*}} ++// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "A",{{.*}} ++// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "B",{{.*}}extraData:{{.*}} ++// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "B",{{.*}} ++// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "C",{{.*}}extraData:{{.*}} ++// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "C",{{.*}} ++// CHECK-NOT: {{.*}}DIDerivedType{{.*}}name: "D",{{.*}}extraData:{{.*}} ++// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "D",{{.*}} ++// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "D",{{.*}} ++// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}flags: DIFlagArtificial{{.*}} ++ ++#![allow(dead_code)] ++#![allow(unused_variables)] ++#![allow(unused_assignments)] ++ ++enum E { A, B, C, D(bool) } ++ ++pub fn main() { ++ let e = E::D(true); ++} +--- /dev/null ++++ b/src/test/codegen/enum-debug-tagged.rs +@@ -0,0 +1,40 @@ ++// 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 or the MIT license ++// , at your ++// option. This file may not be copied, modified, or distributed ++// except according to those terms. ++ ++// This test depends on a patch that was committed to upstream LLVM ++// before 7.0, then backported to the Rust LLVM fork. It tests that ++// debug info for tagged (ordinary) enums is properly emitted. ++ ++// ignore-tidy-linelength ++// ignore-windows ++// min-system-llvm-version 7.0 ++ ++// compile-flags: -g -C no-prepopulate-passes ++ ++// CHECK-LABEL: @main ++// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "E",{{.*}} ++// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_variant_part,{{.*}}discriminator:{{.*}} ++// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "A",{{.*}}extraData:{{.*}} ++// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "A",{{.*}} ++// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "__0",{{.*}} ++// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "B",{{.*}}extraData:{{.*}} ++// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_structure_type,{{.*}}name: "B",{{.*}} ++// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}name: "__0",{{.*}} ++// CHECK: {{.*}}DIDerivedType{{.*}}tag: DW_TAG_member,{{.*}}flags: DIFlagArtificial{{.*}} ++ ++#![allow(dead_code)] ++#![allow(unused_variables)] ++#![allow(unused_assignments)] ++ ++enum E { A(u32), B(u32) } ++ ++pub fn main() { ++ let e = E::A(23); ++} +--- a/src/test/debuginfo/basic-types.rs ++++ b/src/test/debuginfo/basic-types.rs +@@ -16,6 +16,10 @@ + + // min-lldb-version: 310 + ++// This fails on lldb 6.0.1 on x86-64 Fedora 28; so mark it macOS-only ++// for now. ++// only-macos ++ + // compile-flags:-g + + // === GDB TESTS =================================================================================== +--- a/src/test/debuginfo/borrowed-enum.rs ++++ b/src/test/debuginfo/borrowed-enum.rs +@@ -9,8 +9,11 @@ + // except according to those terms. + + // ignore-tidy-linelength +-// min-lldb-version: 310 +-// ignore-gdb-version: 7.11.90 - 7.12.9 ++ ++// Require LLVM with DW_TAG_variant_part and a gdb or lldb that can read it. ++// min-system-llvm-version: 7.0 ++// min-gdb-version: 8.2 ++// rust-lldb + + // compile-flags:-g + +@@ -19,15 +22,12 @@ + // gdb-command:run + + // gdb-command:print *the_a_ref +-// gdbg-check:$1 = {{RUST$ENUM$DISR = TheA, x = 0, y = 8970181431921507452}, {RUST$ENUM$DISR = TheA, [...]}} + // gdbr-check:$1 = borrowed_enum::ABC::TheA{x: 0, y: 8970181431921507452} + + // gdb-command:print *the_b_ref +-// gdbg-check:$2 = {{RUST$ENUM$DISR = TheB, [...]}, {RUST$ENUM$DISR = TheB, __0 = 0, __1 = 286331153, __2 = 286331153}} + // gdbr-check:$2 = borrowed_enum::ABC::TheB(0, 286331153, 286331153) + + // gdb-command:print *univariant_ref +-// gdbg-check:$3 = {{__0 = 4820353753753434}} + // gdbr-check:$3 = borrowed_enum::Univariant::TheOnlyCase(4820353753753434) + + +@@ -36,14 +36,11 @@ + // lldb-command:run + + // lldb-command:print *the_a_ref +-// lldbg-check:[...]$0 = TheA { x: 0, y: 8970181431921507452 } +-// lldbr-check:(borrowed_enum::ABC::TheA) *the_a_ref = TheA { borrowed_enum::ABC::TheA: 0, borrowed_enum::ABC::TheB: 8970181431921507452 } ++// lldbr-check:(borrowed_enum::ABC::TheA) *the_a_ref = TheA { TheA: 0, TheB: 8970181431921507452 } + // lldb-command:print *the_b_ref +-// lldbg-check:[...]$1 = TheB(0, 286331153, 286331153) + // lldbr-check:(borrowed_enum::ABC::TheB) *the_b_ref = { = 0 = 286331153 = 286331153 } + // lldb-command:print *univariant_ref +-// lldbg-check:[...]$2 = TheOnlyCase(4820353753753434) +-// lldbr-check:(borrowed_enum::Univariant) *univariant_ref = { borrowed_enum::TheOnlyCase = { = 4820353753753434 } } ++// lldbr-check:(borrowed_enum::Univariant) *univariant_ref = { TheOnlyCase = { = 4820353753753434 } } + + #![allow(unused_variables)] + #![feature(omit_gdb_pretty_printer_section)] +--- a/src/test/debuginfo/cross-crate-spans.rs ++++ b/src/test/debuginfo/cross-crate-spans.rs +@@ -13,6 +13,10 @@ + + // min-lldb-version: 310 + ++// This fails on lldb 6.0.1 on x86-64 Fedora 28; so mark it macOS-only ++// for now. ++// only-macos ++ + // aux-build:cross_crate_spans.rs + extern crate cross_crate_spans; + +--- a/src/test/debuginfo/destructured-for-loop-variable.rs ++++ b/src/test/debuginfo/destructured-for-loop-variable.rs +@@ -12,6 +12,10 @@ + + // min-lldb-version: 310 + ++// This fails on lldb 6.0.1 on x86-64 Fedora 28; so mark it macOS-only ++// for now. ++// only-macos ++ + // compile-flags:-g + + // === GDB TESTS =================================================================================== +--- a/src/test/debuginfo/generic-enum-with-different-disr-sizes.rs ++++ b/src/test/debuginfo/generic-enum-with-different-disr-sizes.rs +@@ -12,43 +12,39 @@ + // ignore-lldb: FIXME(#27089) + // min-lldb-version: 310 + ++// Require LLVM with DW_TAG_variant_part and a gdb that can read it. ++// min-system-llvm-version: 7.0 ++// min-gdb-version: 8.2 ++ + // compile-flags:-g + + // === GDB TESTS =================================================================================== + // gdb-command:run + + // gdb-command:print eight_bytes1 +-// gdbg-check:$1 = {{RUST$ENUM$DISR = Variant1, __0 = 100}, {RUST$ENUM$DISR = Variant1, __0 = 100}} +-// gdbr-check:$1 = generic_enum_with_different_disr_sizes::Enum::Variant1(100) ++// gdbr-check:$1 = generic_enum_with_different_disr_sizes::Enum::Variant1(100) + + // gdb-command:print four_bytes1 +-// gdbg-check:$2 = {{RUST$ENUM$DISR = Variant1, __0 = 101}, {RUST$ENUM$DISR = Variant1, __0 = 101}} +-// gdbr-check:$2 = generic_enum_with_different_disr_sizes::Enum::Variant1(101) ++// gdbr-check:$2 = generic_enum_with_different_disr_sizes::Enum::Variant1(101) + + // gdb-command:print two_bytes1 +-// gdbg-check:$3 = {{RUST$ENUM$DISR = Variant1, __0 = 102}, {RUST$ENUM$DISR = Variant1, __0 = 102}} +-// gdbr-check:$3 = generic_enum_with_different_disr_sizes::Enum::Variant1(102) ++// gdbr-check:$3 = generic_enum_with_different_disr_sizes::Enum::Variant1(102) + + // gdb-command:print one_byte1 +-// gdbg-check:$4 = {{RUST$ENUM$DISR = Variant1, __0 = 65 'A'}, {RUST$ENUM$DISR = Variant1, __0 = 65 'A'}} +-// gdbr-check:$4 = generic_enum_with_different_disr_sizes::Enum::Variant1(65) ++// gdbr-check:$4 = generic_enum_with_different_disr_sizes::Enum::Variant1(65) + + + // gdb-command:print eight_bytes2 +-// gdbg-check:$5 = {{RUST$ENUM$DISR = Variant2, __0 = 100}, {RUST$ENUM$DISR = Variant2, __0 = 100}} +-// gdbr-check:$5 = generic_enum_with_different_disr_sizes::Enum::Variant2(100) ++// gdbr-check:$5 = generic_enum_with_different_disr_sizes::Enum::Variant2(100) + + // gdb-command:print four_bytes2 +-// gdbg-check:$6 = {{RUST$ENUM$DISR = Variant2, __0 = 101}, {RUST$ENUM$DISR = Variant2, __0 = 101}} +-// gdbr-check:$6 = generic_enum_with_different_disr_sizes::Enum::Variant2(101) ++// gdbr-check:$6 = generic_enum_with_different_disr_sizes::Enum::Variant2(101) + + // gdb-command:print two_bytes2 +-// gdbg-check:$7 = {{RUST$ENUM$DISR = Variant2, __0 = 102}, {RUST$ENUM$DISR = Variant2, __0 = 102}} +-// gdbr-check:$7 = generic_enum_with_different_disr_sizes::Enum::Variant2(102) ++// gdbr-check:$7 = generic_enum_with_different_disr_sizes::Enum::Variant2(102) + + // gdb-command:print one_byte2 +-// gdbg-check:$8 = {{RUST$ENUM$DISR = Variant2, __0 = 65 'A'}, {RUST$ENUM$DISR = Variant2, __0 = 65 'A'}} +-// gdbr-check:$8 = generic_enum_with_different_disr_sizes::Enum::Variant2(65) ++// gdbr-check:$8 = generic_enum_with_different_disr_sizes::Enum::Variant2(65) + + // gdb-command:continue + +--- a/src/test/debuginfo/generic-struct-style-enum.rs ++++ b/src/test/debuginfo/generic-struct-style-enum.rs +@@ -10,7 +10,10 @@ + + // ignore-tidy-linelength + // min-lldb-version: 310 +-// ignore-gdb-version: 7.11.90 - 7.12.9 ++ ++// Require LLVM with DW_TAG_variant_part and a gdb that can read it. ++// min-system-llvm-version: 7.0 ++// min-gdb-version: 8.2 + + // compile-flags:-g + +@@ -18,19 +21,15 @@ + // gdb-command:run + + // gdb-command:print case1 +-// gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, a = 0, b = 31868, c = 31868, d = 31868, e = 31868}, {RUST$ENUM$DISR = Case1, [...]}, {RUST$ENUM$DISR = Case1, [...]}} +-// gdbr-check:$1 = generic_struct_style_enum::Regular::Case1{a: 0, b: 31868, c: 31868, d: 31868, e: 31868} ++// gdbr-check:$1 = generic_struct_style_enum::Regular::Case1{a: 0, b: 31868, c: 31868, d: 31868, e: 31868} + + // gdb-command:print case2 +-// gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, [...]}, {RUST$ENUM$DISR = Case2, a = 0, b = 286331153, c = 286331153}, {RUST$ENUM$DISR = Case2, [...]}} +-// gdbr-check:$2 = generic_struct_style_enum::Regular::Case2{a: 0, b: 286331153, c: 286331153} ++// gdbr-check:$2 = generic_struct_style_enum::Regular::Case2{a: 0, b: 286331153, c: 286331153} + + // gdb-command:print case3 +-// gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, a = 0, b = 6438275382588823897}} +-// gdbr-check:$3 = generic_struct_style_enum::Regular::Case3{a: 0, b: 6438275382588823897} ++// gdbr-check:$3 = generic_struct_style_enum::Regular::Case3{a: 0, b: 6438275382588823897} + + // gdb-command:print univariant +-// gdbg-check:$4 = {{a = -1}} + // gdbr-check:$4 = generic_struct_style_enum::Univariant::TheOnlyCase{a: -1} + + +--- a/src/test/debuginfo/generic-tuple-style-enum.rs ++++ b/src/test/debuginfo/generic-tuple-style-enum.rs +@@ -9,8 +9,12 @@ + // except according to those terms. + + // ignore-tidy-linelength +-// min-lldb-version: 310 +-// ignore-gdb-version: 7.11.90 - 7.12.9 ++ ++// Require LLVM with DW_TAG_variant_part and a gdb and lldb that can ++// read it. ++// min-system-llvm-version: 7.0 ++// min-gdb-version: 8.2 ++// rust-lldb + + // compile-flags:-g + +@@ -20,19 +24,15 @@ + // gdb-command:run + + // gdb-command:print case1 +-// gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, __0 = 0, __1 = 31868, __2 = 31868, __3 = 31868, __4 = 31868}, {RUST$ENUM$DISR = Case1, [...]}, {RUST$ENUM$DISR = Case1, [...]}} +-// gdbr-check:$1 = generic_tuple_style_enum::Regular::Case1(0, 31868, 31868, 31868, 31868) ++// gdbr-check:$1 = generic_tuple_style_enum::Regular::Case1(0, 31868, 31868, 31868, 31868) + + // gdb-command:print case2 +-// gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, [...]}, {RUST$ENUM$DISR = Case2, __0 = 0, __1 = 286331153, __2 = 286331153}, {RUST$ENUM$DISR = Case2, [...]}} +-// gdbr-check:$2 = generic_tuple_style_enum::Regular::Case2(0, 286331153, 286331153) ++// gdbr-check:$2 = generic_tuple_style_enum::Regular::Case2(0, 286331153, 286331153) + + // gdb-command:print case3 +-// gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, __0 = 0, __1 = 6438275382588823897}} +-// gdbr-check:$3 = generic_tuple_style_enum::Regular::Case3(0, 6438275382588823897) ++// gdbr-check:$3 = generic_tuple_style_enum::Regular::Case3(0, 6438275382588823897) + + // gdb-command:print univariant +-// gdbg-check:$4 = {{__0 = -1}} + // gdbr-check:$4 = generic_tuple_style_enum::Univariant::TheOnlyCase(-1) + + +@@ -41,20 +41,16 @@ + // lldb-command:run + + // lldb-command:print case1 +-// lldbg-check:[...]$0 = Case1(0, 31868, 31868, 31868, 31868) + // lldbr-check:(generic_tuple_style_enum::Regular::Case1) case1 = { = 0 = 31868 = 31868 = 31868 = 31868 } + + // lldb-command:print case2 +-// lldbg-check:[...]$1 = Case2(0, 286331153, 286331153) +-// lldbr-check:(generic_tuple_style_enum::Regular::Case2) case2 = Regular::Case2 { generic_tuple_style_enum::Regular::Case1: 0, generic_tuple_style_enum::Regular::Case2: 286331153, generic_tuple_style_enum::Regular::Case3: 286331153 } ++// lldbr-check:(generic_tuple_style_enum::Regular::Case2) case2 = Regular::Case2 { Case1: 0, Case2: 286331153, Case3: 286331153 } + + // lldb-command:print case3 +-// lldbg-check:[...]$2 = Case3(0, 6438275382588823897) +-// lldbr-check:(generic_tuple_style_enum::Regular::Case3) case3 = Regular::Case3 { generic_tuple_style_enum::Regular::Case1: 0, generic_tuple_style_enum::Regular::Case2: 6438275382588823897 } ++// lldbr-check:(generic_tuple_style_enum::Regular::Case3) case3 = Regular::Case3 { Case1: 0, Case2: 6438275382588823897 } + + // lldb-command:print univariant +-// lldbg-check:[...]$3 = TheOnlyCase(-1) +-// lldbr-check:(generic_tuple_style_enum::Univariant) univariant = { generic_tuple_style_enum::TheOnlyCase = { = -1 } } ++// lldbr-check:(generic_tuple_style_enum::Univariant) univariant = { TheOnlyCase = { = -1 } } + + #![feature(omit_gdb_pretty_printer_section)] + #![omit_gdb_pretty_printer_section] +--- a/src/test/debuginfo/method-on-tuple-struct.rs ++++ b/src/test/debuginfo/method-on-tuple-struct.rs +@@ -74,7 +74,7 @@ + // STACK BY REF + // lldb-command:print *self + // lldbg-check:[...]$0 = TupleStruct(100, -100.5) +-// lldbr-check:(method_on_tuple_struct::TupleStruct) *self = { = 100 = -100.5 } ++// lldbr-check:(method_on_tuple_struct::TupleStruct) *self = TupleStruct(100, -100.5) + // lldb-command:print arg1 + // lldbg-check:[...]$1 = -1 + // lldbr-check:(isize) arg1 = -1 +@@ -86,7 +86,7 @@ + // STACK BY VAL + // lldb-command:print self + // lldbg-check:[...]$3 = TupleStruct(100, -100.5) +-// lldbr-check:(method_on_tuple_struct::TupleStruct) self = { = 100 = -100.5 } ++// lldbr-check:(method_on_tuple_struct::TupleStruct) self = TupleStruct(100, -100.5) + // lldb-command:print arg1 + // lldbg-check:[...]$4 = -3 + // lldbr-check:(isize) arg1 = -3 +@@ -98,7 +98,7 @@ + // OWNED BY REF + // lldb-command:print *self + // lldbg-check:[...]$6 = TupleStruct(200, -200.5) +-// lldbr-check:(method_on_tuple_struct::TupleStruct) *self = { = 200 = -200.5 } ++// lldbr-check:(method_on_tuple_struct::TupleStruct) *self = TupleStruct(200, -200.5) + // lldb-command:print arg1 + // lldbg-check:[...]$7 = -5 + // lldbr-check:(isize) arg1 = -5 +@@ -110,7 +110,7 @@ + // OWNED BY VAL + // lldb-command:print self + // lldbg-check:[...]$9 = TupleStruct(200, -200.5) +-// lldbr-check:(method_on_tuple_struct::TupleStruct) self = { = 200 = -200.5 } ++// lldbr-check:(method_on_tuple_struct::TupleStruct) self = TupleStruct(200, -200.5) + // lldb-command:print arg1 + // lldbg-check:[...]$10 = -7 + // lldbr-check:(isize) arg1 = -7 +@@ -122,7 +122,7 @@ + // OWNED MOVED + // lldb-command:print *self + // lldbg-check:[...]$12 = TupleStruct(200, -200.5) +-// lldbr-check:(method_on_tuple_struct::TupleStruct) *self = { = 200 = -200.5 } ++// lldbr-check:(method_on_tuple_struct::TupleStruct) *self = TupleStruct(200, -200.5) + // lldb-command:print arg1 + // lldbg-check:[...]$13 = -9 + // lldbr-check:(isize) arg1 = -9 +--- a/src/test/debuginfo/nil-enum.rs ++++ b/src/test/debuginfo/nil-enum.rs +@@ -14,16 +14,21 @@ + // ignore-lldb + + ++// Require LLVM with DW_TAG_variant_part and a gdb that can read it. ++// gdb 8.2.0 crashes on this test case, see ++// https://sourceware.org/bugzilla/show_bug.cgi?id=23626 ++// This will be fixed in the next release, which will be >= 8.2.1. ++// min-system-llvm-version: 7.0 ++// min-gdb-version: 8.2.1 ++ + // compile-flags:-g + // gdb-command:run + + // gdb-command:print first +-// gdbg-check:$1 = {} +-// gdbr-check:$1 = ++// gdbr-check:$1 = nil_enum::ANilEnum {} + + // gdb-command:print second +-// gdbg-check:$2 = {} +-// gdbr-check:$2 = ++// gdbr-check:$2 = nil_enum::AnotherNilEnum {} + + #![allow(unused_variables)] + #![feature(omit_gdb_pretty_printer_section)] +--- a/src/test/debuginfo/recursive-struct.rs ++++ b/src/test/debuginfo/recursive-struct.rs +@@ -10,7 +10,10 @@ + + // ignore-tidy-linelength + // ignore-lldb +-// ignore-gdb-version: 7.11.90 - 7.12.9 ++ ++// Require LLVM with DW_TAG_variant_part and a gdb that can read it. ++// min-system-llvm-version: 7.0 ++// min-gdb-version: 8.2 + + // compile-flags:-g + +@@ -18,66 +21,52 @@ + + // gdb-command:print stack_unique.value + // gdb-check:$1 = 0 +-// gdbg-command:print stack_unique.next.RUST$ENCODED$ENUM$0$Empty.val->value + // gdbr-command:print stack_unique.next.val.value + // gdb-check:$2 = 1 + +-// gdbg-command:print unique_unique->value + // gdbr-command:print unique_unique.value + // gdb-check:$3 = 2 +-// gdbg-command:print unique_unique->next.RUST$ENCODED$ENUM$0$Empty.val->value + // gdbr-command:print unique_unique.next.val.value + // gdb-check:$4 = 3 + + // gdb-command:print vec_unique[0].value + // gdb-check:$5 = 6.5 +-// gdbg-command:print vec_unique[0].next.RUST$ENCODED$ENUM$0$Empty.val->value + // gdbr-command:print vec_unique[0].next.val.value + // gdb-check:$6 = 7.5 + +-// gdbg-command:print borrowed_unique->value + // gdbr-command:print borrowed_unique.value + // gdb-check:$7 = 8.5 +-// gdbg-command:print borrowed_unique->next.RUST$ENCODED$ENUM$0$Empty.val->value + // gdbr-command:print borrowed_unique.next.val.value + // gdb-check:$8 = 9.5 + + // LONG CYCLE + // gdb-command:print long_cycle1.value + // gdb-check:$9 = 20 +-// gdbg-command:print long_cycle1.next->value + // gdbr-command:print long_cycle1.next.value + // gdb-check:$10 = 21 +-// gdbg-command:print long_cycle1.next->next->value + // gdbr-command:print long_cycle1.next.next.value + // gdb-check:$11 = 22 +-// gdbg-command:print long_cycle1.next->next->next->value + // gdbr-command:print long_cycle1.next.next.next.value + // gdb-check:$12 = 23 + + // gdb-command:print long_cycle2.value + // gdb-check:$13 = 24 +-// gdbg-command:print long_cycle2.next->value + // gdbr-command:print long_cycle2.next.value + // gdb-check:$14 = 25 +-// gdbg-command:print long_cycle2.next->next->value + // gdbr-command:print long_cycle2.next.next.value + // gdb-check:$15 = 26 + + // gdb-command:print long_cycle3.value + // gdb-check:$16 = 27 +-// gdbg-command:print long_cycle3.next->value + // gdbr-command:print long_cycle3.next.value + // gdb-check:$17 = 28 + + // gdb-command:print long_cycle4.value + // gdb-check:$18 = 29.5 + +-// gdbg-command:print (*****long_cycle_w_anonymous_types).value + // gdbr-command:print long_cycle_w_anonymous_types.value + // gdb-check:$19 = 30 + +-// gdbg-command:print (*****((*****long_cycle_w_anonymous_types).next.RUST$ENCODED$ENUM$0$Empty.val)).value + // gdbr-command:print long_cycle_w_anonymous_types.next.val.value + // gdb-check:$20 = 31 + +--- a/src/test/debuginfo/struct-style-enum.rs ++++ b/src/test/debuginfo/struct-style-enum.rs +@@ -9,8 +9,12 @@ + // except according to those terms. + + // ignore-tidy-linelength +-// min-lldb-version: 310 +-// ignore-gdb-version: 7.11.90 - 7.12.9 ++ ++// Require LLVM with DW_TAG_variant_part and a gdb and lldb that can ++// read it. ++// min-system-llvm-version: 7.0 ++// min-gdb-version: 8.2 ++// rust-lldb + + // compile-flags:-g + +@@ -20,19 +24,15 @@ + // gdb-command:run + + // gdb-command:print case1 +-// gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, a = 0, b = 31868, c = 31868, d = 31868, e = 31868}, {RUST$ENUM$DISR = Case1, [...]}, {RUST$ENUM$DISR = Case1, [...]}} + // gdbr-check:$1 = struct_style_enum::Regular::Case1{a: 0, b: 31868, c: 31868, d: 31868, e: 31868} + + // gdb-command:print case2 +-// gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, [...]}, {RUST$ENUM$DISR = Case2, a = 0, b = 286331153, c = 286331153}, {RUST$ENUM$DISR = Case2, [...]}} + // gdbr-check:$2 = struct_style_enum::Regular::Case2{a: 0, b: 286331153, c: 286331153} + + // gdb-command:print case3 +-// gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, a = 0, b = 6438275382588823897}} + // gdbr-check:$3 = struct_style_enum::Regular::Case3{a: 0, b: 6438275382588823897} + + // gdb-command:print univariant +-// gdbg-check:$4 = {{a = -1}} + // gdbr-check:$4 = struct_style_enum::Univariant::TheOnlyCase{a: -1} + + +@@ -41,20 +41,16 @@ + // lldb-command:run + + // lldb-command:print case1 +-// lldbg-check:[...]$0 = Case1 { a: 0, b: 31868, c: 31868, d: 31868, e: 31868 } + // lldbr-check:(struct_style_enum::Regular::Case1) case1 = { a = 0 b = 31868 c = 31868 d = 31868 e = 31868 } + + // lldb-command:print case2 +-// lldbg-check:[...]$1 = Case2 { a: 0, b: 286331153, c: 286331153 } +-// lldbr-check:(struct_style_enum::Regular::Case2) case2 = Case2 { struct_style_enum::Regular::Case1: 0, struct_style_enum::Regular::Case2: 286331153, struct_style_enum::Regular::Case3: 286331153 } ++// lldbr-check:(struct_style_enum::Regular::Case2) case2 = Case2 { Case1: 0, Case2: 286331153, Case3: 286331153 } + + // lldb-command:print case3 +-// lldbg-check:[...]$2 = Case3 { a: 0, b: 6438275382588823897 } +-// lldbr-check:(struct_style_enum::Regular::Case3) case3 = Case3 { struct_style_enum::Regular::Case1: 0, struct_style_enum::Regular::Case2: 6438275382588823897 } ++// lldbr-check:(struct_style_enum::Regular::Case3) case3 = Case3 { Case1: 0, Case2: 6438275382588823897 } + + // lldb-command:print univariant +-// lldbg-check:[...]$3 = TheOnlyCase { a: -1 } +-// lldbr-check:(struct_style_enum::Univariant) univariant = Univariant { struct_style_enum::TheOnlyCase: TheOnlyCase { a: -1 } } ++// lldbr-check:(struct_style_enum::Univariant) univariant = Univariant { TheOnlyCase: TheOnlyCase { a: -1 } } + + #![allow(unused_variables)] + #![feature(omit_gdb_pretty_printer_section)] +--- a/src/test/debuginfo/tuple-style-enum.rs ++++ b/src/test/debuginfo/tuple-style-enum.rs +@@ -9,8 +9,12 @@ + // except according to those terms. + + // ignore-tidy-linelength +-// min-lldb-version: 310 +-// ignore-gdb-version: 7.11.90 - 7.12.9 ++ ++// Require LLVM with DW_TAG_variant_part and a gdb and lldb that can ++// read it. ++// min-system-llvm-version: 7.0 ++// min-gdb-version: 8.2 ++// rust-lldb + + // compile-flags:-g + +@@ -20,19 +24,15 @@ + // gdb-command:run + + // gdb-command:print case1 +-// gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, __0 = 0, __1 = 31868, __2 = 31868, __3 = 31868, __4 = 31868}, {RUST$ENUM$DISR = Case1, [...]}, {RUST$ENUM$DISR = Case1, [...]}} + // gdbr-check:$1 = tuple_style_enum::Regular::Case1(0, 31868, 31868, 31868, 31868) + + // gdb-command:print case2 +-// gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, [...]}, {RUST$ENUM$DISR = Case2, __0 = 0, __1 = 286331153, __2 = 286331153}, {RUST$ENUM$DISR = Case2, [...]}} + // gdbr-check:$2 = tuple_style_enum::Regular::Case2(0, 286331153, 286331153) + + // gdb-command:print case3 +-// gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, __0 = 0, __1 = 6438275382588823897}} + // gdbr-check:$3 = tuple_style_enum::Regular::Case3(0, 6438275382588823897) + + // gdb-command:print univariant +-// gdbg-check:$4 = {{__0 = -1}} + // gdbr-check:$4 = tuple_style_enum::Univariant::TheOnlyCase(-1) + + +@@ -41,20 +41,16 @@ + // lldb-command:run + + // lldb-command:print case1 +-// lldbg-check:[...]$0 = Case1(0, 31868, 31868, 31868, 31868) + // lldbr-check:(tuple_style_enum::Regular::Case1) case1 = { = 0 = 31868 = 31868 = 31868 = 31868 } + + // lldb-command:print case2 +-// lldbg-check:[...]$1 = Case2(0, 286331153, 286331153) +-// lldbr-check:(tuple_style_enum::Regular::Case2) case2 = Case2 { tuple_style_enum::Regular::Case1: 0, tuple_style_enum::Regular::Case2: 286331153, tuple_style_enum::Regular::Case3: 286331153 } ++// lldbr-check:(tuple_style_enum::Regular::Case2) case2 = Case2 { Case1: 0, Case2: 286331153, Case3: 286331153 } + + // lldb-command:print case3 +-// lldbg-check:[...]$2 = Case3(0, 6438275382588823897) +-// lldbr-check:(tuple_style_enum::Regular::Case3) case3 = Case3 { tuple_style_enum::Regular::Case1: 0, tuple_style_enum::Regular::Case2: 6438275382588823897 } ++// lldbr-check:(tuple_style_enum::Regular::Case3) case3 = Case3 { Case1: 0, Case2: 6438275382588823897 } + + // lldb-command:print univariant +-// lldbg-check:[...]$3 = TheOnlyCase(-1) +-// lldbr-check:(tuple_style_enum::Univariant) univariant = { tuple_style_enum::TheOnlyCase = { = -1 } } ++// lldbr-check:(tuple_style_enum::Univariant) univariant = { TheOnlyCase = { = -1 } } + + #![allow(unused_variables)] + #![feature(omit_gdb_pretty_printer_section)] +--- a/src/test/debuginfo/unique-enum.rs ++++ b/src/test/debuginfo/unique-enum.rs +@@ -9,8 +9,12 @@ + // except according to those terms. + + // ignore-tidy-linelength +-// min-lldb-version: 310 +-// ignore-gdb-version: 7.11.90 - 7.12.9 ++ ++// Require LLVM with DW_TAG_variant_part and a gdb and lldb that can ++// read it. ++// min-system-llvm-version: 7.0 ++// min-gdb-version: 8.2 ++// rust-lldb + + // compile-flags:-g + +@@ -19,15 +23,12 @@ + // gdb-command:run + + // gdb-command:print *the_a +-// gdbg-check:$1 = {{RUST$ENUM$DISR = TheA, x = 0, y = 8970181431921507452}, {RUST$ENUM$DISR = TheA, [...]}} + // gdbr-check:$1 = unique_enum::ABC::TheA{x: 0, y: 8970181431921507452} + + // gdb-command:print *the_b +-// gdbg-check:$2 = {{RUST$ENUM$DISR = TheB, [...]}, {RUST$ENUM$DISR = TheB, __0 = 0, __1 = 286331153, __2 = 286331153}} + // gdbr-check:$2 = unique_enum::ABC::TheB(0, 286331153, 286331153) + + // gdb-command:print *univariant +-// gdbg-check:$3 = {{__0 = 123234}} + // gdbr-check:$3 = unique_enum::Univariant::TheOnlyCase(123234) + + +@@ -36,16 +37,13 @@ + // lldb-command:run + + // lldb-command:print *the_a +-// lldbg-check:[...]$0 = TheA { x: 0, y: 8970181431921507452 } +-// lldbr-check:(unique_enum::ABC::TheA) *the_a = TheA { unique_enum::ABC::TheA: 0, unique_enum::ABC::TheB: 8970181431921507452 } ++// lldbr-check:(unique_enum::ABC::TheA) *the_a = TheA { TheA: 0, TheB: 8970181431921507452 } + + // lldb-command:print *the_b +-// lldbg-check:[...]$1 = TheB(0, 286331153, 286331153) + // lldbr-check:(unique_enum::ABC::TheB) *the_b = { = 0 = 286331153 = 286331153 } + + // lldb-command:print *univariant +-// lldbg-check:[...]$2 = TheOnlyCase(123234) +-// lldbr-check:(unique_enum::Univariant) *univariant = { unique_enum::TheOnlyCase = { = 123234 } } ++// lldbr-check:(unique_enum::Univariant) *univariant = { TheOnlyCase = { = 123234 } } + + #![allow(unused_variables)] + #![feature(box_syntax)] +--- a/src/test/debuginfo/vec-slices.rs ++++ b/src/test/debuginfo/vec-slices.rs +@@ -99,7 +99,7 @@ + + // lldb-command:print padded_tuple + // lldbg-check:[...]$4 = &[(6, 7), (8, 9)] +-// lldbr-check:(&[(i32, i16)]) padded_tuple = { data_ptr = *0x555555554ff0 length = 2 } ++// lldbr-check:(&[(i32, i16)]) padded_tuple = { data_ptr = *0x555555555030 length = 2 } + + // lldb-command:print padded_struct + // lldbg-check:[...]$5 = &[AStruct { x: 10, y: 11, z: 12 }, AStruct { x: 13, y: 14, z: 15 }] diff -Nru rustc-1.30.0+dfsg1+llvm/debian/patches/u-ignoretest-ppc64el_02.patch rustc-1.31.0+dfsg1+llvm/debian/patches/u-ignoretest-ppc64el_02.patch --- rustc-1.30.0+dfsg1+llvm/debian/patches/u-ignoretest-ppc64el_02.patch 2018-09-27 03:01:46.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/debian/patches/u-ignoretest-ppc64el_02.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -Description: Ignore failing tests on ppc64el -Author: Ximin Luo -Bug: https://github.com/rust-lang/rust/issues/44670 ---- a/src/test/run-pass/simd-intrinsic-generic-cast.rs -+++ b/src/test/run-pass/simd-intrinsic-generic-cast.rs -@@ -71,6 +71,10 @@ - fn in_range(_: i32) -> bool { true } - } - -+#[cfg(target_arch = "powerpc64")] -+fn main() {} -+ -+#[cfg(not(target_arch = "powerpc64"))] - fn main() { - macro_rules! test { - ($from: ident, $to: ident) => {{ diff -Nru rustc-1.30.0+dfsg1+llvm/debian/patches/u-mips-fixes.diff rustc-1.31.0+dfsg1+llvm/debian/patches/u-mips-fixes.diff --- rustc-1.30.0+dfsg1+llvm/debian/patches/u-mips-fixes.diff 2018-11-12 22:23:20.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/debian/patches/u-mips-fixes.diff 2019-01-22 23:11:37.000000000 +0000 @@ -5,24 +5,25 @@ --- a/src/librustc_codegen_llvm/llvm_util.rs +++ b/src/librustc_codegen_llvm/llvm_util.rs -@@ -68,6 +68,8 @@ +@@ -71,6 +71,9 @@ add("-disable-preinline"); } -+ if sess.target.target.arch == "mips" || sess.target.target.arch == "mips64" { add("-fast-isel=0"); } ++ if sess.target.target.arch == "mips" || ++ sess.target.target.arch == "mips64" { add("-fast-isel=0"); } + for arg in &sess.opts.cg.llvm_args { add(&(*arg)); } --- a/src/test/run-pass/invalid_const_promotion.rs +++ b/src/test/run-pass/invalid_const_promotion.rs -@@ -35,7 +35,8 @@ +@@ -39,7 +39,8 @@ use std::os::unix::process::ExitStatusExt; assert!(status.signal() == Some(libc::SIGILL) - || status.signal() == Some(libc::SIGABRT)); + || status.signal() == Some(libc::SIGABRT) -+ || status.signal() == Some(libc::SIGTRAP)); ++ || status.signal() == Some(libc::SIGTRAP)); } #[cfg(not(unix))] @@ -37,3 +38,21 @@ // ignore-powerpc // ignore-powerpc64 // ignore-powerpc64le +--- a/src/test/ui/asm/asm-out-assign-imm.nll.stderr ++++ b/src/test/ui/asm/asm-out-assign-imm.nll.stderr +@@ -1,5 +1,5 @@ + error[E0384]: cannot assign twice to immutable variable `x` +- --> $DIR/asm-out-assign-imm.rs:34:34 ++ --> $DIR/asm-out-assign-imm.rs:36:34 + | + LL | let x: isize; + | - help: make this binding mutable: `mut x` +--- a/src/test/ui/asm/asm-out-assign-imm.stderr ++++ b/src/test/ui/asm/asm-out-assign-imm.stderr +@@ -1,5 +1,5 @@ + error[E0384]: cannot assign twice to immutable variable `x` +- --> $DIR/asm-out-assign-imm.rs:34:34 ++ --> $DIR/asm-out-assign-imm.rs:36:34 + | + LL | x = 1; + | ----- first assignment to `x` diff -Nru rustc-1.30.0+dfsg1+llvm/debian/upstream-tarball-unsuspicious.txt rustc-1.31.0+dfsg1+llvm/debian/upstream-tarball-unsuspicious.txt --- rustc-1.30.0+dfsg1+llvm/debian/upstream-tarball-unsuspicious.txt 2018-11-12 22:23:20.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/debian/upstream-tarball-unsuspicious.txt 2019-01-22 23:11:37.000000000 +0000 @@ -57,8 +57,13 @@ src/doc/nomicon/src/img/safeandunsafe.svg src/doc/book/second-edition/src/img/*.png src/doc/book/second-edition/src/img/*.svg +src/doc/book/src/img/ferris/*.svg +src/doc/book/src/img/*.png +src/doc/book/src/img/*.svg +src/doc/book/2018-edition/src/img/ferris/*.svg src/doc/book/2018-edition/src/img/*.svg src/doc/book/2018-edition/src/img/*.png +src/doc/book/tools/docx-to-md.xsl src/librustdoc/html/static/*.svg src/vendor/difference/assets/*.png src/vendor/mdbook/src/theme/favicon.png @@ -76,6 +81,7 @@ src/stdsimd/stdsimd/arch/detect/test_data src/test/compile-fail/not-utf8.bin src/test/*/*.rs +src/test/*/issues/*.rs src/test/*/*/issues/*.rs src/test/*/*.stderr src/test/*/*/*.stderr diff -Nru rustc-1.30.0+dfsg1+llvm/debian/watch rustc-1.31.0+dfsg1+llvm/debian/watch --- rustc-1.30.0+dfsg1+llvm/debian/watch 2018-11-08 03:05:58.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/debian/watch 2019-01-22 23:11:37.000000000 +0000 @@ -13,5 +13,5 @@ repacksuffix=+dfsg1+llvm,\ compression=xz,\ " \ - https://static.rust-lang.org/dist/index.html \ + https://forge.rust-lang.org/other-installation-methods.html \ (?:.*/)rustc?-(\d[\d.]*(?:-[\w.]+)?)-src\.tar\.[gx]z diff -Nru rustc-1.30.0+dfsg1+llvm/git-commit-hash rustc-1.31.0+dfsg1+llvm/git-commit-hash --- rustc-1.30.0+dfsg1+llvm/git-commit-hash 2018-10-24 21:34:08.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/git-commit-hash 2018-12-05 01:22:15.000000000 +0000 @@ -1 +1 @@ -da5f414c2c0bfe5198934493f04c676e2b23ff2e \ No newline at end of file +abe02cefd6cd1916df62ad7dc80161bea50b72e8 \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/RELEASES.md rustc-1.31.0+dfsg1+llvm/RELEASES.md --- rustc-1.30.0+dfsg1+llvm/RELEASES.md 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/RELEASES.md 2018-12-04 23:41:40.000000000 +0000 @@ -1,3 +1,88 @@ +Version 1.31.0 (2018-12-06) +========================== + +Language +-------- +- 🎉 [This version marks the release of the 2018 edition of Rust.][54057] 🎉 +- [New lifetime elision rules now allow for eliding lifetimes in functions and + impl headers.][54778] E.g. `impl<'a> Reader for BufReader<'a> {}` can now be + `impl Reader for BufReader<'_> {}`. Lifetimes are still required to be defined + in structs. +- [You can now define and use `const` functions.][54835] These are currently + a strict minimal subset of the [const fn RFC][RFC-911]. Refer to the + [language reference][const-reference] for what exactly is available. +- [You can now use tool lints, which allow you to scope lints from external + tools using attributes.][54870] E.g. `#[allow(clippy::filter_map)]`. +- [`#[no_mangle]` and `#[export_name]` attributes can now be located anywhere in + a crate, not just in exported functions.][54451] +- [You can now use parentheses in pattern matches.][54497] + +Compiler +-------- +- [Updated musl to 1.1.20][54430] + +Libraries +--------- +- [You can now convert `num::NonZero*` types to their raw equivalvents using the + `From` trait.][54240] E.g. `u8` now implements `From`. +- [You can now convert a `&Option` into `Option<&T>` and `&mut Option` + into `Option<&mut T>` using the `From` trait.][53218] +- [You can now multiply (`*`) a `time::Duration` by a `u32`.][52813] + + +Stabilized APIs +--------------- +- [`slice::align_to`] +- [`slice::align_to_mut`] +- [`slice::chunks_exact`] +- [`slice::chunks_exact_mut`] +- [`slice::rchunks`] +- [`slice::rchunks_mut`] +- [`slice::rchunks_exact`] +- [`slice::rchunks_exact_mut`] +- [`Option::replace`] + +Cargo +----- +- [Cargo will now download crates in parallel using HTTP/2.][cargo/6005] +- [You can now rename packages in your Cargo.toml][cargo/6319] We have a guide + on [how to use the `package` key in your dependencies.][cargo-rename-reference] + +[52813]: https://github.com/rust-lang/rust/pull/52813/ +[53218]: https://github.com/rust-lang/rust/pull/53218/ +[53555]: https://github.com/rust-lang/rust/issues/53555/ +[54057]: https://github.com/rust-lang/rust/pull/54057/ +[54240]: https://github.com/rust-lang/rust/pull/54240/ +[54430]: https://github.com/rust-lang/rust/pull/54430/ +[54451]: https://github.com/rust-lang/rust/pull/54451/ +[54497]: https://github.com/rust-lang/rust/pull/54497/ +[54778]: https://github.com/rust-lang/rust/pull/54778/ +[54835]: https://github.com/rust-lang/rust/pull/54835/ +[54870]: https://github.com/rust-lang/rust/pull/54870/ +[RFC-911]: https://github.com/rust-lang/rfcs/pull/911 +[`Option::replace`]: https://doc.rust-lang.org/std/option/enum.Option.html#method.replace +[`slice::align_to_mut`]: https://doc.rust-lang.org/std/primitive.slice.html#method.align_to_mut +[`slice::align_to`]: https://doc.rust-lang.org/std/primitive.slice.html#method.align_to +[`slice::chunks_exact_mut`]: https://doc.rust-lang.org/std/primitive.slice.html#method.chunks_exact_mut +[`slice::chunks_exact`]: https://doc.rust-lang.org/std/primitive.slice.html#method.chunks_exact +[`slice::rchunks_exact_mut`]: https://doc.rust-lang.org/std/primitive.slice.html#method.rchunks_mut +[`slice::rchunks_exact`]: https://doc.rust-lang.org/std/primitive.slice.html#method.rchunks_exact +[`slice::rchunks_mut`]: https://doc.rust-lang.org/std/primitive.slice.html#method.rchunks_mut +[`slice::rchunks`]: https://doc.rust-lang.org/std/primitive.slice.html#method.rchunks +[cargo/6005]: https://github.com/rust-lang/cargo/pull/6005/ +[cargo/6319]: https://github.com/rust-lang/cargo/pull/6319/ +[cargo-rename-reference]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#renaming-dependencies-in-cargotoml +[const-reference]: https://doc.rust-lang.org/reference/items/functions.html#const-functions + +Version 1.30.1 (2018-11-08) +=========================== + +- [Fixed overflow ICE in rustdoc][54199] +- [Cap Cargo progress bar width at 60 in MSYS terminals][cargo/6122] + +[54199]: https://github.com/rust-lang/rust/pull/54199 +[cargo/6122]: https://github.com/rust-lang/cargo/pull/6122 + Version 1.30.0 (2018-10-25) ========================== @@ -64,9 +149,6 @@ - [`cargo run` doesn't require specifying a package in workspaces.][cargo/5877] - [`cargo doc` now supports `--message-format=json`.][cargo/5878] This is equivalent to calling `rustdoc --error-format=json`. -- [You can specify which edition to create a project in cargo - with `cargo new --edition`.][cargo/5984] Currently only `2015` is a - valid option. - [Cargo will now provide a progress bar for builds.][cargo/5995] Misc @@ -100,9 +182,8 @@ [54404]: https://github.com/rust-lang/rust/pull/54404/ [cargo/5877]: https://github.com/rust-lang/cargo/pull/5877/ [cargo/5878]: https://github.com/rust-lang/cargo/pull/5878/ -[cargo/5984]: https://github.com/rust-lang/cargo/pull/5984/ [cargo/5995]: https://github.com/rust-lang/cargo/pull/5995/ -[proc-macros]: https://doc.rust-lang.org/book/2018-edition/ch19-06-macros.html +[proc-macros]: https://doc.rust-lang.org/stable/book/2018-edition/ch19-06-macros.html [`Ipv4Addr::BROADCAST`]: https://doc.rust-lang.org/nightly/std/net/struct.Ipv4Addr.html#associatedconstant.BROADCAST [`Ipv4Addr::LOCALHOST`]: https://doc.rust-lang.org/nightly/std/net/struct.Ipv4Addr.html#associatedconstant.LOCALHOST diff -Nru rustc-1.30.0+dfsg1+llvm/src/bootstrap/bin/rustc.rs rustc-1.31.0+dfsg1+llvm/src/bootstrap/bin/rustc.rs --- rustc-1.30.0+dfsg1+llvm/src/bootstrap/bin/rustc.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/bootstrap/bin/rustc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -287,10 +287,6 @@ cmd.arg("--cfg").arg("parallel_queries"); } - if env::var_os("RUSTC_VERIFY_LLVM_IR").is_some() { - cmd.arg("-Z").arg("verify-llvm-ir"); - } - if env::var_os("RUSTC_DENY_WARNINGS").is_some() && env::var_os("RUSTC_EXTERNAL_TOOL").is_none() { cmd.arg("-Dwarnings"); diff -Nru rustc-1.30.0+dfsg1+llvm/src/bootstrap/bootstrap.py rustc-1.31.0+dfsg1+llvm/src/bootstrap/bootstrap.py --- rustc-1.30.0+dfsg1+llvm/src/bootstrap/bootstrap.py 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/bootstrap/bootstrap.py 2018-12-04 23:41:40.000000000 +0000 @@ -594,7 +594,7 @@ return '' def bootstrap_binary(self): - """Return the path of the boostrap binary + """Return the path of the bootstrap binary >>> rb = RustBuild() >>> rb.build_dir = "build" @@ -632,6 +632,9 @@ target_features += ["-crt-static"] if target_features: env["RUSTFLAGS"] += "-C target-feature=" + (",".join(target_features)) + " " + target_linker = self.get_toml("linker", build_section) + if target_linker is not None: + env["RUSTFLAGS"] += "-C linker=" + target_linker + " " env["PATH"] = os.path.join(self.bin_root(), "bin") + \ os.pathsep + env["PATH"] @@ -844,6 +847,11 @@ def main(): """Entry point for the bootstrap process""" start_time = time() + + # x.py help ... + if len(sys.argv) > 1 and sys.argv[1] == 'help': + sys.argv = sys.argv[:1] + [sys.argv[2], '-h'] + sys.argv[3:] + help_triggered = ( '-h' in sys.argv) or ('--help' in sys.argv) or (len(sys.argv) == 1) try: diff -Nru rustc-1.30.0+dfsg1+llvm/src/bootstrap/builder.rs rustc-1.31.0+dfsg1+llvm/src/bootstrap/builder.rs --- rustc-1.30.0+dfsg1+llvm/src/bootstrap/builder.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/bootstrap/builder.rs 2018-12-04 23:41:40.000000000 +0000 @@ -130,7 +130,7 @@ fn has(&self, needle: &Path) -> bool { match self { PathSet::Set(set) => set.iter().any(|p| p.ends_with(needle)), - PathSet::Suite(_) => false, + PathSet::Suite(suite) => suite.ends_with(needle), } } @@ -379,7 +379,6 @@ test::Ui, test::RunPass, test::CompileFail, - test::ParseFail, test::RunFail, test::RunPassValgrind, test::MirOpt, @@ -444,7 +443,8 @@ doc::RustdocBook, doc::RustByExample, doc::RustcBook, - doc::CargoBook + doc::CargoBook, + doc::EditionGuide, ), Kind::Dist => describe!( dist::Docs, @@ -1000,10 +1000,6 @@ cargo.env("RUSTC_BACKTRACE_ON_ICE", "1"); } - if self.config.rust_verify_llvm_ir { - cargo.env("RUSTC_VERIFY_LLVM_IR", "1"); - } - cargo.env("RUSTC_VERBOSE", self.verbosity.to_string()); // in std, we want to avoid denying warnings for stage 0 as that makes cfg's painful. @@ -1849,7 +1845,7 @@ ); // Ensure we don't build any compiler artifacts. - assert!(builder.cache.all::().is_empty()); + assert!(!builder.cache.contains::()); assert_eq!( first(builder.cache.all::()), &[test::Crate { @@ -1861,4 +1857,34 @@ },] ); } + + #[test] + fn test_exclude() { + let mut config = configure(&[], &[]); + config.exclude = vec![ + "src/test/run-pass".into(), + "src/tools/tidy".into(), + ]; + config.cmd = Subcommand::Test { + paths: Vec::new(), + test_args: Vec::new(), + rustc_args: Vec::new(), + fail_fast: true, + doc_tests: DocTests::No, + bless: false, + compare_mode: None, + }; + + let build = Build::new(config); + let builder = Builder::new(&build); + builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Test), &[]); + + // Ensure we have really excluded run-pass & tidy + assert!(!builder.cache.contains::()); + assert!(!builder.cache.contains::()); + + // Ensure other tests are not affected. + assert!(builder.cache.contains::()); + assert!(builder.cache.contains::()); + } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/bootstrap/cache.rs rustc-1.31.0+dfsg1+llvm/src/bootstrap/cache.rs --- rustc-1.30.0+dfsg1+llvm/src/bootstrap/cache.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/bootstrap/cache.rs 2018-12-04 23:41:40.000000000 +0000 @@ -169,19 +169,21 @@ } } -struct TyIntern { +struct TyIntern { items: Vec, set: HashMap>, } -impl TyIntern { - fn new() -> TyIntern { +impl Default for TyIntern { + fn default() -> Self { TyIntern { items: Vec::new(), - set: HashMap::new(), + set: Default::default(), } } +} +impl TyIntern { fn intern_borrow(&mut self, item: &B) -> Interned where B: Eq + Hash + ToOwned + ?Sized, @@ -212,19 +214,13 @@ } } +#[derive(Default)] pub struct Interner { strs: Mutex>, paths: Mutex>, } impl Interner { - fn new() -> Interner { - Interner { - strs: Mutex::new(TyIntern::new()), - paths: Mutex::new(TyIntern::new()), - } - } - pub fn intern_str(&self, s: &str) -> Interned { self.strs.lock().unwrap().intern_borrow(s) } @@ -238,7 +234,7 @@ } lazy_static! { - pub static ref INTERNER: Interner = Interner::new(); + pub static ref INTERNER: Interner = Interner::default(); } /// This is essentially a HashMap which allows storing any type in its input and @@ -290,4 +286,9 @@ v.sort_by_key(|&(a, _)| a); v } + + #[cfg(test)] + pub fn contains(&self) -> bool { + self.0.borrow().contains_key(&TypeId::of::()) + } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/bootstrap/channel.rs rustc-1.31.0+dfsg1+llvm/src/bootstrap/channel.rs --- rustc-1.30.0+dfsg1+llvm/src/bootstrap/channel.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/bootstrap/channel.rs 2018-12-04 23:41:40.000000000 +0000 @@ -24,7 +24,7 @@ use config::Config; // The version number -pub const CFG_RELEASE_NUM: &str = "1.30.0"; +pub const CFG_RELEASE_NUM: &str = "1.31.0"; pub struct GitInfo { inner: Option, diff -Nru rustc-1.30.0+dfsg1+llvm/src/bootstrap/check.rs rustc-1.31.0+dfsg1+llvm/src/bootstrap/check.rs --- rustc-1.30.0+dfsg1+llvm/src/bootstrap/check.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/bootstrap/check.rs 2018-12-04 23:41:40.000000000 +0000 @@ -224,7 +224,8 @@ target, "check", "src/tools/rustdoc", - SourceType::InTree); + SourceType::InTree, + &[]); let _folder = builder.fold_output(|| format!("stage{}-rustdoc", compiler.stage)); println!("Checking rustdoc artifacts ({} -> {})", &compiler.host, target); diff -Nru rustc-1.30.0+dfsg1+llvm/src/bootstrap/compile.rs rustc-1.31.0+dfsg1+llvm/src/bootstrap/compile.rs --- rustc-1.30.0+dfsg1+llvm/src/bootstrap/compile.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/bootstrap/compile.rs 2018-12-04 23:41:40.000000000 +0000 @@ -249,7 +249,7 @@ fn copy_apple_sanitizer_dylibs(builder: &Builder, native_dir: &Path, platform: &str, into: &Path) { for &sanitizer in &["asan", "tsan"] { - let filename = format!("libclang_rt.{}_{}_dynamic.dylib", sanitizer, platform); + let filename = format!("lib__rustc__clang_rt.{}_{}_dynamic.dylib", sanitizer, platform); let mut src_path = native_dir.join(sanitizer); src_path.push("build"); src_path.push("lib"); @@ -569,6 +569,9 @@ if builder.config.rustc_parallel_queries { cargo.env("RUSTC_PARALLEL_QUERIES", "1"); } + if builder.config.rust_verify_llvm_ir { + cargo.env("RUSTC_VERIFY_LLVM_IR", "1"); + } } #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/bootstrap/config.rs rustc-1.31.0+dfsg1+llvm/src/bootstrap/config.rs --- rustc-1.30.0+dfsg1+llvm/src/bootstrap/config.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/bootstrap/config.rs 2018-12-04 23:41:40.000000000 +0000 @@ -134,6 +134,7 @@ pub test_miri: bool, pub save_toolstates: Option, pub print_step_timings: bool, + pub missing_tools: bool, // Fallback musl-root for all targets pub musl_root: Option, @@ -148,7 +149,7 @@ pub nodejs: Option, pub gdb: Option, pub python: Option, - pub openssl_static: bool, + pub cargo_native_static: bool, pub configure_args: Vec, // These are either the stage0 downloaded binaries or the locally installed ones. @@ -162,6 +163,8 @@ pub struct Target { /// Some(path to llvm-config) if using an external LLVM. pub llvm_config: Option, + /// Some(path to FileCheck) if one was specified. + pub llvm_filecheck: Option, pub jemalloc: Option, pub cc: Option, pub cxx: Option, @@ -218,7 +221,7 @@ verbose: Option, sanitizers: Option, profiler: Option, - openssl_static: Option, + cargo_native_static: Option, configure_args: Option>, local_rebuild: Option, print_step_timings: Option, @@ -269,6 +272,7 @@ gpg_password_file: Option, upload_addr: Option, src_tarball: Option, + missing_tools: Option, } #[derive(Deserialize)] @@ -330,6 +334,7 @@ #[serde(deny_unknown_fields, rename_all = "kebab-case")] struct TomlTarget { llvm_config: Option, + llvm_filecheck: Option, jemalloc: Option, cc: Option, cxx: Option, @@ -372,6 +377,7 @@ config.rust_codegen_backends = vec![INTERNER.intern_str("llvm")]; config.rust_codegen_backends_dir = "codegen-backends".to_owned(); config.deny_warnings = true; + config.missing_tools = false; // set by bootstrap.py config.build = INTERNER.intern_str(&env::var("BUILD").expect("'BUILD' to be set")); @@ -424,7 +430,7 @@ } }).unwrap_or_else(|| TomlConfig::default()); - let build = toml.build.clone().unwrap_or(Build::default()); + let build = toml.build.clone().unwrap_or_default(); // set by bootstrap.py config.hosts.push(config.build.clone()); for host in build.host.iter() { @@ -468,7 +474,7 @@ set(&mut config.verbose, build.verbose); set(&mut config.sanitizers, build.sanitizers); set(&mut config.profiler, build.profiler); - set(&mut config.openssl_static, build.openssl_static); + set(&mut config.cargo_native_static, build.cargo_native_static); set(&mut config.configure_args, build.configure_args); set(&mut config.local_rebuild, build.local_rebuild); set(&mut config.print_step_timings, build.print_step_timings); @@ -518,7 +524,7 @@ set(&mut config.llvm_link_shared, llvm.link_shared); config.llvm_targets = llvm.targets.clone(); config.llvm_experimental_targets = llvm.experimental_targets.clone() - .unwrap_or("WebAssembly;RISCV".to_string()); + .unwrap_or_else(|| "WebAssembly;RISCV".to_string()); config.llvm_link_jobs = llvm.link_jobs; config.llvm_version_suffix = llvm.version_suffix.clone(); config.llvm_clang_cl = llvm.clang_cl.clone(); @@ -583,6 +589,9 @@ if let Some(ref s) = cfg.llvm_config { target.llvm_config = Some(config.src.join(s)); } + if let Some(ref s) = cfg.llvm_filecheck { + target.llvm_filecheck = Some(config.src.join(s)); + } if let Some(ref s) = cfg.jemalloc { target.jemalloc = Some(config.src.join(s)); } @@ -607,6 +616,7 @@ config.dist_gpg_password_file = t.gpg_password_file.clone().map(PathBuf::from); config.dist_upload_addr = t.upload_addr.clone(); set(&mut config.rust_dist_src, t.src_tarball); + set(&mut config.missing_tools, t.missing_tools); } // Now that we've reached the end of our configuration, infer the @@ -618,6 +628,9 @@ let default = false; config.llvm_assertions = llvm_assertions.unwrap_or(default); + let default = true; + config.rust_optimize = optimize.unwrap_or(default); + let default = match &config.channel[..] { "stable" | "beta" | "nightly" => true, _ => false, @@ -630,7 +643,6 @@ config.debug_jemalloc = debug_jemalloc.unwrap_or(default); config.rust_debuginfo = debuginfo.unwrap_or(default); config.rust_debug_assertions = debug_assertions.unwrap_or(default); - config.rust_optimize = optimize.unwrap_or(!default); let default = config.channel == "dev"; config.ignore_git = ignore_git.unwrap_or(default); diff -Nru rustc-1.30.0+dfsg1+llvm/src/bootstrap/configure.py rustc-1.31.0+dfsg1+llvm/src/bootstrap/configure.py --- rustc-1.30.0+dfsg1+llvm/src/bootstrap/configure.py 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/bootstrap/configure.py 2018-12-04 23:41:40.000000000 +0000 @@ -64,11 +64,12 @@ o("vendor", "build.vendor", "enable usage of vendored Rust crates") o("sanitizers", "build.sanitizers", "build the sanitizer runtimes (asan, lsan, msan, tsan)") o("dist-src", "rust.dist-src", "when building tarballs enables building a source tarball") -o("cargo-openssl-static", "build.openssl-static", "static openssl in cargo") +o("cargo-native-static", "build.cargo-native-static", "static native libraries in cargo") o("profiler", "build.profiler", "build the profiler runtime") o("emscripten", None, "compile the emscripten backend as well as LLVM") o("full-tools", None, "enable all tools") o("lldb", "rust.lldb", "build lldb") +o("missing-tools", "dist.missing-tools", "allow failures when building tools") # Optimization and debugging options. These may be overridden by the release # channel, etc. @@ -95,6 +96,8 @@ v("bindir", "install.bindir", "install binaries") v("llvm-root", None, "set LLVM root") +v("llvm-config", None, "set path to llvm-config") +v("llvm-filecheck", None, "set path to LLVM's FileCheck utility") v("python", "build.python", "set path to python") v("jemalloc-root", None, "set directory where libjemalloc_pic.a is located") v("android-cross-path", "target.arm-linux-androideabi.android-ndk", @@ -323,6 +326,10 @@ set('build.cargo', value + '/bin/cargo') elif option.name == 'llvm-root': set('target.{}.llvm-config'.format(build()), value + '/bin/llvm-config') + elif option.name == 'llvm-config': + set('target.{}.llvm-config'.format(build()), value) + elif option.name == 'llvm-filecheck': + set('target.{}.llvm-filecheck'.format(build()), value) elif option.name == 'jemalloc-root': set('target.{}.jemalloc'.format(build()), value + '/libjemalloc_pic.a') elif option.name == 'tools': diff -Nru rustc-1.30.0+dfsg1+llvm/src/bootstrap/dist.rs rustc-1.31.0+dfsg1+llvm/src/bootstrap/dist.rs --- rustc-1.30.0+dfsg1+llvm/src/bootstrap/dist.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/bootstrap/dist.rs 2018-12-04 23:41:40.000000000 +0000 @@ -31,7 +31,6 @@ use util::{libdir, is_dylib, exe}; use builder::{Builder, RunConfig, ShouldRun, Step}; use compile; -use native; use tool::{self, Tool}; use cache::{INTERNER, Interned}; use time; @@ -67,6 +66,14 @@ builder.tool_cmd(Tool::RustInstaller) } +fn missing_tool(tool_name: &str, skip: bool) { + if skip { + println!("Unable to build {}, skipping dist", tool_name) + } else { + panic!("Unable to build {}", tool_name) + } +} + #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] pub struct Docs { pub stage: u32, @@ -982,12 +989,6 @@ .arg("--debug") .arg("--vers").arg(CARGO_VENDOR_VERSION) .arg("cargo-vendor"); - if let Some(dir) = builder.openssl_install_dir(builder.config.build) { - builder.ensure(native::Openssl { - target: builder.config.build, - }); - cmd.env("OPENSSL_DIR", dir); - } builder.run(&mut cmd); } @@ -1166,7 +1167,7 @@ let rls = builder.ensure(tool::Rls { compiler: builder.compiler(stage, builder.config.build), target, extra_features: Vec::new() - }).or_else(|| { println!("Unable to build RLS, skipping dist"); None })?; + }).or_else(|| { missing_tool("RLS", builder.build.config.missing_tools); None })?; builder.install(&rls, &image.join("bin"), 0o755); let doc = image.join("share/doc/rls"); @@ -1245,24 +1246,26 @@ let clippy = builder.ensure(tool::Clippy { compiler: builder.compiler(stage, builder.config.build), target, extra_features: Vec::new() - }).or_else(|| { println!("Unable to build clippy, skipping dist"); None })?; + }).or_else(|| { missing_tool("clippy", builder.build.config.missing_tools); None })?; let cargoclippy = builder.ensure(tool::CargoClippy { compiler: builder.compiler(stage, builder.config.build), target, extra_features: Vec::new() - }).or_else(|| { println!("Unable to build cargo clippy, skipping dist"); None })?; + }).or_else(|| { missing_tool("cargo clippy", builder.build.config.missing_tools); None })?; builder.install(&clippy, &image.join("bin"), 0o755); builder.install(&cargoclippy, &image.join("bin"), 0o755); let doc = image.join("share/doc/clippy"); builder.install(&src.join("README.md"), &doc, 0o644); - builder.install(&src.join("LICENSE"), &doc, 0o644); + builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644); + builder.install(&src.join("LICENSE-MIT"), &doc, 0o644); // Prepare the overlay let overlay = tmp.join("clippy-overlay"); drop(fs::remove_dir_all(&overlay)); t!(fs::create_dir_all(&overlay)); builder.install(&src.join("README.md"), &overlay, 0o644); - builder.install(&src.join("LICENSE"), &doc, 0o644); + builder.install(&src.join("LICENSE-APACHE"), &doc, 0o644); + builder.install(&src.join("LICENSE-MIT"), &doc, 0o644); builder.create(&overlay.join("version"), &version); // Generate the installer tarball @@ -1324,11 +1327,11 @@ let rustfmt = builder.ensure(tool::Rustfmt { compiler: builder.compiler(stage, builder.config.build), target, extra_features: Vec::new() - }).or_else(|| { println!("Unable to build Rustfmt, skipping dist"); None })?; + }).or_else(|| { missing_tool("Rustfmt", builder.build.config.missing_tools); None })?; let cargofmt = builder.ensure(tool::Cargofmt { compiler: builder.compiler(stage, builder.config.build), target, extra_features: Vec::new() - }).or_else(|| { println!("Unable to build Cargofmt, skipping dist"); None })?; + }).or_else(|| { missing_tool("Cargofmt", builder.build.config.missing_tools); None })?; builder.install(&rustfmt, &image.join("bin"), 0o755); builder.install(&cargofmt, &image.join("bin"), 0o755); @@ -1444,8 +1447,8 @@ tarballs.extend(rls_installer.clone()); tarballs.extend(clippy_installer.clone()); tarballs.extend(rustfmt_installer.clone()); - tarballs.extend(llvm_tools_installer.clone()); - tarballs.extend(lldb_installer.clone()); + tarballs.extend(llvm_tools_installer); + tarballs.extend(lldb_installer); tarballs.push(analysis_installer); tarballs.push(std_installer); if builder.config.docs { diff -Nru rustc-1.30.0+dfsg1+llvm/src/bootstrap/doc.rs rustc-1.31.0+dfsg1+llvm/src/bootstrap/doc.rs --- rustc-1.30.0+dfsg1+llvm/src/bootstrap/doc.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/bootstrap/doc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -70,6 +70,7 @@ book!( Nomicon, "src/doc/nomicon", "nomicon"; Reference, "src/doc/reference", "reference"; + EditionGuide, "src/doc/edition-guide", "edition-guide"; RustdocBook, "src/doc/rustdoc", "rustdoc"; RustcBook, "src/doc/rustc", "rustc"; RustByExample, "src/doc/rust-by-example", "rust-by-example"; @@ -260,22 +261,31 @@ let compiler = self.compiler; let target = self.target; let name = self.name; - // build book first edition + + // build book builder.ensure(Rustbook { target, - name: INTERNER.intern_string(format!("{}/first-edition", name)), + name: INTERNER.intern_string(name.to_string()), }); - // build book second edition + // building older edition redirects + + let source_name = format!("{}/first-edition", name); builder.ensure(Rustbook { target, - name: INTERNER.intern_string(format!("{}/second-edition", name)), + name: INTERNER.intern_string(source_name), }); - // build book 2018 edition + let source_name = format!("{}/second-edition", name); builder.ensure(Rustbook { target, - name: INTERNER.intern_string(format!("{}/2018-edition", name)), + name: INTERNER.intern_string(source_name), + }); + + let source_name = format!("{}/2018-edition", name); + builder.ensure(Rustbook { + target, + name: INTERNER.intern_string(source_name), }); // build the version info page and CSS @@ -284,11 +294,6 @@ target, }); - // build the index page - let index = format!("{}/index.md", name); - builder.info(&format!("Documenting book index ({})", target)); - invoke_rustdoc(builder, compiler, target, &index); - // build the redirect pages builder.info(&format!("Documenting book redirect pages ({})", target)); for file in t!(fs::read_dir(builder.src.join("src/doc/book/redirects"))) { @@ -805,6 +810,7 @@ "doc", "src/tools/rustdoc", SourceType::InTree, + &[] ); cargo.env("RUSTDOCFLAGS", "--document-private-items"); diff -Nru rustc-1.30.0+dfsg1+llvm/src/bootstrap/lib.rs rustc-1.31.0+dfsg1+llvm/src/bootstrap/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/bootstrap/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/bootstrap/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -278,10 +278,6 @@ initial_rustc: PathBuf, initial_cargo: PathBuf, - // Probed tools at runtime - lldb_version: Option, - lldb_python_dir: Option, - // Runtime state filled in later on // C/C++ compilers and archiver for all targets cc: HashMap, cc::Tool>, @@ -416,8 +412,6 @@ ar: HashMap::new(), ranlib: HashMap::new(), crates: HashMap::new(), - lldb_version: None, - lldb_python_dir: None, is_sudo, ci_env: CiEnv::current(), delayed_failures: RefCell::new(Vec::new()), @@ -641,9 +635,28 @@ /// Returns the path to `FileCheck` binary for the specified target fn llvm_filecheck(&self, target: Interned) -> PathBuf { let target_config = self.config.target_config.get(&target); - if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) { + if let Some(s) = target_config.and_then(|c| c.llvm_filecheck.as_ref()) { + s.to_path_buf() + } else if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) { let llvm_bindir = output(Command::new(s).arg("--bindir")); - Path::new(llvm_bindir.trim()).join(exe("FileCheck", &*target)) + let filecheck = Path::new(llvm_bindir.trim()).join(exe("FileCheck", &*target)); + if filecheck.exists() { + filecheck + } else { + // On Fedora the system LLVM installs FileCheck in the + // llvm subdirectory of the libdir. + let llvm_libdir = output(Command::new(s).arg("--libdir")); + let lib_filecheck = Path::new(llvm_libdir.trim()) + .join("llvm").join(exe("FileCheck", &*target)); + if lib_filecheck.exists() { + lib_filecheck + } else { + // Return the most normal file name, even though + // it doesn't exist, so that any error message + // refers to that. + filecheck + } + } } else { let base = self.llvm_out(self.config.build).join("build"); let base = if !self.config.ninja && self.config.build.contains("msvc") { @@ -752,7 +765,7 @@ let path = match which { GitRepo::Rustc => { - let sha = self.rust_info.sha().expect("failed to find sha"); + let sha = self.rust_sha().unwrap_or(channel::CFG_RELEASE_NUM); format!("/rustc/{}", sha) } GitRepo::Llvm => format!("/rustc/llvm"), @@ -913,25 +926,6 @@ (self.hosts.iter().any(|h| *h == target) || target == self.build) } - /// Returns the directory that OpenSSL artifacts are compiled into if - /// configured to do so. - fn openssl_dir(&self, target: Interned) -> Option { - // OpenSSL not used on Windows - if target.contains("windows") { - None - } else if self.config.openssl_static { - Some(self.out.join(&*target).join("openssl")) - } else { - None - } - } - - /// Returns the directory that OpenSSL artifacts are installed into if - /// configured as such. - fn openssl_install_dir(&self, target: Interned) -> Option { - self.openssl_dir(target).map(|p| p.join("install")) - } - /// Given `num` in the form "a.b.c" return a "release string" which /// describes the release version number. /// @@ -1275,6 +1269,9 @@ t!(fs::create_dir_all(dstdir)); drop(fs::remove_file(&dst)); { + if !src.exists() { + panic!("Error: File \"{}\" not found!", src.display()); + } let mut s = t!(fs::File::open(&src)); let mut d = t!(fs::File::create(&dst)); io::copy(&mut s, &mut d).expect("failed to copy"); diff -Nru rustc-1.30.0+dfsg1+llvm/src/bootstrap/mk/Makefile.in rustc-1.31.0+dfsg1+llvm/src/bootstrap/mk/Makefile.in --- rustc-1.30.0+dfsg1+llvm/src/bootstrap/mk/Makefile.in 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/bootstrap/mk/Makefile.in 2018-12-04 23:41:40.000000000 +0000 @@ -85,7 +85,12 @@ check-stage2-T-x86_64-unknown-linux-musl-H-x86_64-unknown-linux-gnu: $(Q)$(BOOTSTRAP) test --target x86_64-unknown-linux-musl -TESTS_IN_2 := src/test/run-pass src/test/compile-fail src/test/run-pass-fulldeps +TESTS_IN_2 := \ + src/test/ui \ + src/test/run-pass \ + src/test/compile-fail \ + src/test/run-pass-fulldeps \ + src/tools/linkchecker appveyor-subset-1: $(Q)$(BOOTSTRAP) test $(TESTS_IN_2:%=--exclude %) diff -Nru rustc-1.30.0+dfsg1+llvm/src/bootstrap/native.rs rustc-1.31.0+dfsg1+llvm/src/bootstrap/native.rs --- rustc-1.30.0+dfsg1+llvm/src/bootstrap/native.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/bootstrap/native.rs 2018-12-04 23:41:40.000000000 +0000 @@ -531,189 +531,3 @@ .compile("rust_test_helpers"); } } - -const OPENSSL_VERS: &'static str = "1.0.2n"; -const OPENSSL_SHA256: &'static str = - "370babb75f278c39e0c50e8c4e7493bc0f18db6867478341a832a982fd15a8fe"; - -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub struct Openssl { - pub target: Interned, -} - -impl Step for Openssl { - type Output = (); - - fn should_run(run: ShouldRun) -> ShouldRun { - run.never() - } - - fn run(self, builder: &Builder) { - if builder.config.dry_run { - return; - } - let target = self.target; - let out = match builder.openssl_dir(target) { - Some(dir) => dir, - None => return, - }; - - let stamp = out.join(".stamp"); - let mut contents = String::new(); - drop(File::open(&stamp).and_then(|mut f| f.read_to_string(&mut contents))); - if contents == OPENSSL_VERS { - return - } - t!(fs::create_dir_all(&out)); - - let name = format!("openssl-{}.tar.gz", OPENSSL_VERS); - let tarball = out.join(&name); - if !tarball.exists() { - let tmp = tarball.with_extension("tmp"); - // originally from https://www.openssl.org/source/... - let url = format!("https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/{}", - name); - let mut last_error = None; - for _ in 0..3 { - let status = Command::new("curl") - .arg("-o").arg(&tmp) - .arg("-f") // make curl fail if the URL does not return HTTP 200 - .arg(&url) - .status() - .expect("failed to spawn curl"); - - // Retry if download failed. - if !status.success() { - last_error = Some(status.to_string()); - continue; - } - - // Ensure the hash is correct. - let mut shasum = if target.contains("apple") || - builder.config.build.contains("netbsd") { - let mut cmd = Command::new("shasum"); - cmd.arg("-a").arg("256"); - cmd - } else { - Command::new("sha256sum") - }; - let output = output(&mut shasum.arg(&tmp)); - let found = output.split_whitespace().next().unwrap(); - - // If the hash is wrong, probably the download is incomplete or S3 served an error - // page. In any case, retry. - if found != OPENSSL_SHA256 { - last_error = Some(format!( - "downloaded openssl sha256 different\n\ - expected: {}\n\ - found: {}\n", - OPENSSL_SHA256, - found - )); - continue; - } - - // Everything is fine, so exit the retry loop. - last_error = None; - break; - } - if let Some(error) = last_error { - panic!("failed to download openssl source: {}", error); - } - t!(fs::rename(&tmp, &tarball)); - } - let obj = out.join(format!("openssl-{}", OPENSSL_VERS)); - let dst = builder.openssl_install_dir(target).unwrap(); - drop(fs::remove_dir_all(&obj)); - drop(fs::remove_dir_all(&dst)); - builder.run(Command::new("tar").arg("zxf").arg(&tarball).current_dir(&out)); - - let mut configure = Command::new("perl"); - configure.arg(obj.join("Configure")); - configure.arg(format!("--prefix={}", dst.display())); - configure.arg("no-dso"); - configure.arg("no-ssl2"); - configure.arg("no-ssl3"); - - let os = match &*target { - "aarch64-linux-android" => "linux-aarch64", - "aarch64-unknown-linux-gnu" => "linux-aarch64", - "aarch64-unknown-linux-musl" => "linux-aarch64", - "aarch64-unknown-netbsd" => "BSD-generic64", - "arm-linux-androideabi" => "android", - "arm-unknown-linux-gnueabi" => "linux-armv4", - "arm-unknown-linux-gnueabihf" => "linux-armv4", - "armv6-unknown-netbsd-eabihf" => "BSD-generic32", - "armv7-linux-androideabi" => "android-armv7", - "armv7-unknown-linux-gnueabihf" => "linux-armv4", - "armv7-unknown-netbsd-eabihf" => "BSD-generic32", - "i586-unknown-linux-gnu" => "linux-elf", - "i586-unknown-linux-musl" => "linux-elf", - "i686-apple-darwin" => "darwin-i386-cc", - "i686-linux-android" => "android-x86", - "i686-unknown-freebsd" => "BSD-x86-elf", - "i686-unknown-linux-gnu" => "linux-elf", - "i686-unknown-linux-musl" => "linux-elf", - "i686-unknown-netbsd" => "BSD-x86-elf", - "mips-unknown-linux-gnu" => "linux-mips32", - "mips64-unknown-linux-gnuabi64" => "linux64-mips64", - "mips64el-unknown-linux-gnuabi64" => "linux64-mips64", - "mipsel-unknown-linux-gnu" => "linux-mips32", - "powerpc-unknown-linux-gnu" => "linux-ppc", - "powerpc-unknown-linux-gnuspe" => "linux-ppc", - "powerpc-unknown-netbsd" => "BSD-generic32", - "powerpc64-unknown-linux-gnu" => "linux-ppc64", - "powerpc64le-unknown-linux-gnu" => "linux-ppc64le", - "powerpc64le-unknown-linux-musl" => "linux-ppc64le", - "s390x-unknown-linux-gnu" => "linux64-s390x", - "sparc-unknown-linux-gnu" => "linux-sparcv9", - "sparc64-unknown-linux-gnu" => "linux64-sparcv9", - "sparc64-unknown-netbsd" => "BSD-sparc64", - "x86_64-apple-darwin" => "darwin64-x86_64-cc", - "x86_64-linux-android" => "linux-x86_64", - "x86_64-unknown-freebsd" => "BSD-x86_64", - "x86_64-unknown-dragonfly" => "BSD-x86_64", - "x86_64-unknown-linux-gnu" => "linux-x86_64", - "x86_64-unknown-linux-gnux32" => "linux-x32", - "x86_64-unknown-linux-musl" => "linux-x86_64", - "x86_64-unknown-netbsd" => "BSD-x86_64", - _ => panic!("don't know how to configure OpenSSL for {}", target), - }; - configure.arg(os); - configure.env("CC", builder.cc(target)); - for flag in builder.cflags(target, GitRepo::Rustc) { - configure.arg(flag); - } - // There is no specific os target for android aarch64 or x86_64, - // so we need to pass some extra cflags - if target == "aarch64-linux-android" || target == "x86_64-linux-android" { - configure.arg("-mandroid"); - configure.arg("-fomit-frame-pointer"); - } - if target == "sparc64-unknown-netbsd" { - // Need -m64 to get assembly generated correctly for sparc64. - configure.arg("-m64"); - if builder.config.build.contains("netbsd") { - // Disable sparc64 asm on NetBSD builders, it uses - // m4(1)'s -B flag, which NetBSD m4 does not support. - configure.arg("no-asm"); - } - } - // Make PIE binaries - // Non-PIE linker support was removed in Lollipop - // https://source.android.com/security/enhancements/enhancements50 - if target == "i686-linux-android" { - configure.arg("no-asm"); - } - configure.current_dir(&obj); - builder.info(&format!("Configuring openssl for {}", target)); - builder.run_quiet(&mut configure); - builder.info(&format!("Building openssl for {}", target)); - builder.run_quiet(Command::new("make").arg("-j1").current_dir(&obj)); - builder.info(&format!("Installing openssl for {}", target)); - builder.run_quiet(Command::new("make").arg("install").arg("-j1").current_dir(&obj)); - - let mut f = t!(File::create(&stamp)); - t!(f.write_all(OPENSSL_VERS.as_bytes())); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/bootstrap/sanity.rs rustc-1.31.0+dfsg1+llvm/src/bootstrap/sanity.rs --- rustc-1.30.0+dfsg1+llvm/src/bootstrap/sanity.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/bootstrap/sanity.rs 2018-12-04 23:41:40.000000000 +0000 @@ -236,19 +236,6 @@ } } - let run = |cmd: &mut Command| { - cmd.output().map(|output| { - String::from_utf8_lossy(&output.stdout) - .lines().next().unwrap_or_else(|| { - panic!("{:?} failed {:?}", cmd, output) - }).to_string() - }) - }; - build.lldb_version = run(Command::new("lldb").arg("--version")).ok(); - if build.lldb_version.is_some() { - build.lldb_python_dir = run(Command::new("lldb").arg("-P")).ok(); - } - if let Some(ref s) = build.config.ccache { cmd_finder.must_have(s); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/bootstrap/test.rs rustc-1.31.0+dfsg1+llvm/src/bootstrap/test.rs --- rustc-1.30.0+dfsg1+llvm/src/bootstrap/test.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/bootstrap/test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -228,7 +228,8 @@ self.host, "test", "src/tools/cargo", - SourceType::Submodule); + SourceType::Submodule, + &[]); if !builder.fail_fast { cargo.arg("--no-fail-fast"); @@ -290,7 +291,8 @@ host, "test", "src/tools/rls", - SourceType::Submodule); + SourceType::Submodule, + &[]); // Copy `src/tools/rls/test_data` to a writable drive. let test_workspace_path = builder.out.join("rls-test-data"); @@ -352,7 +354,8 @@ host, "test", "src/tools/rustfmt", - SourceType::Submodule); + SourceType::Submodule, + &[]); let dir = testdir(builder, compiler.host); t!(fs::create_dir_all(&dir)); @@ -407,7 +410,8 @@ host, "test", "src/tools/miri", - SourceType::Submodule); + SourceType::Submodule, + &[]); // miri tests need to know about the stage sysroot cargo.env("MIRI_SYSROOT", builder.sysroot(compiler)); @@ -466,7 +470,8 @@ host, "test", "src/tools/clippy", - SourceType::Submodule); + SourceType::Submodule, + &[]); // clippy tests need to know about the stage sysroot cargo.env("SYSROOT", builder.sysroot(compiler)); @@ -755,10 +760,11 @@ compare_mode: "nll" }); -default_test!(RunPass { +default_test_with_compare_mode!(RunPass { path: "src/test/run-pass", mode: "run-pass", - suite: "run-pass" + suite: "run-pass", + compare_mode: "nll" }); default_test!(CompileFail { @@ -767,12 +773,6 @@ suite: "compile-fail" }); -default_test!(ParseFail { - path: "src/test/parse-fail", - mode: "parse-fail", - suite: "parse-fail" -}); - default_test!(RunFail { path: "src/test/run-fail", mode: "run-fail", @@ -811,8 +811,7 @@ default_test!(Debuginfo { path: "src/test/debuginfo", - // What this runs varies depending on the native platform being apple - mode: "debuginfo-XXX", + mode: "debuginfo", suite: "debuginfo" }); @@ -949,18 +948,11 @@ return; } - if mode == "debuginfo-XXX" { - return if builder.config.build.contains("apple") { - builder.ensure(Compiletest { - mode: "debuginfo-lldb", - ..self - }); - } else { - builder.ensure(Compiletest { - mode: "debuginfo-gdb", - ..self - }); - }; + if mode == "debuginfo" { + return builder.ensure(Compiletest { + mode: "debuginfo-both", + ..self + }); } builder.ensure(dist::DebuggerScripts { @@ -1060,7 +1052,7 @@ let hostflags = flags.clone(); cmd.arg("--host-rustcflags").arg(hostflags.join(" ")); - let mut targetflags = flags.clone(); + let mut targetflags = flags; targetflags.push(format!( "-Lnative={}", builder.test_helpers_out(target).display() @@ -1081,11 +1073,34 @@ if let Some(ref gdb) = builder.config.gdb { cmd.arg("--gdb").arg(gdb); } - if let Some(ref vers) = builder.lldb_version { + + let run = |cmd: &mut Command| { + cmd.output().map(|output| { + String::from_utf8_lossy(&output.stdout) + .lines().next().unwrap_or_else(|| { + panic!("{:?} failed {:?}", cmd, output) + }).to_string() + }) + }; + let lldb_exe = if builder.config.lldb_enabled && !target.contains("emscripten") { + // Test against the lldb that was just built. + builder.llvm_out(target) + .join("bin") + .join("lldb") + } else { + PathBuf::from("lldb") + }; + let lldb_version = Command::new(&lldb_exe) + .arg("--version") + .output() + .map(|output| { String::from_utf8_lossy(&output.stdout).to_string() }) + .ok(); + if let Some(ref vers) = lldb_version { cmd.arg("--lldb-version").arg(vers); - } - if let Some(ref dir) = builder.lldb_python_dir { - cmd.arg("--lldb-python-dir").arg(dir); + let lldb_python_dir = run(Command::new(&lldb_exe).arg("-P")).ok(); + if let Some(ref dir) = lldb_python_dir { + cmd.arg("--lldb-python-dir").arg(dir); + } } // Get paths from cmd args @@ -1761,7 +1776,8 @@ target, test_kind.subcommand(), "src/tools/rustdoc", - SourceType::InTree); + SourceType::InTree, + &[]); if test_kind.subcommand() == "test" && !builder.fail_fast { cargo.arg("--no-fail-fast"); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/bootstrap/tool.rs rustc-1.31.0+dfsg1+llvm/src/bootstrap/tool.rs --- rustc-1.30.0+dfsg1+llvm/src/bootstrap/tool.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/bootstrap/tool.rs 2018-12-04 23:41:40.000000000 +0000 @@ -22,6 +22,7 @@ use compile; use native; use channel::GitInfo; +use channel; use cache::Interned; use toolstate::ToolState; @@ -80,8 +81,8 @@ "build", path, self.source_type, + &self.extra_features, ); - cargo.arg("--features").arg(self.extra_features.join(" ")); let _folder = builder.fold_output(|| format!("stage{}-{}", compiler.stage, tool)); builder.info(&format!("Building stage{} tool {} ({})", compiler.stage, tool, target)); @@ -208,6 +209,7 @@ command: &'static str, path: &'static str, source_type: SourceType, + extra_features: &[String], ) -> Command { let mut cargo = builder.cargo(compiler, mode, target, command); let dir = builder.src.join(path); @@ -221,10 +223,16 @@ cargo.env("RUSTC_EXTERNAL_TOOL", "1"); } - if let Some(dir) = builder.openssl_install_dir(target) { - cargo.env("OPENSSL_STATIC", "1"); - cargo.env("OPENSSL_DIR", dir); - cargo.env("LIBZ_SYS_STATIC", "1"); + let mut features = extra_features.iter().cloned().collect::>(); + if builder.build.config.cargo_native_static { + if path.ends_with("cargo") || + path.ends_with("rls") || + path.ends_with("clippy") || + path.ends_with("rustfmt") + { + cargo.env("LIBZ_SYS_STATIC", "1"); + features.push("rustc-workspace-hack/all-static".to_string()); + } } // if tools are using lzma we want to force the build script to build its @@ -233,6 +241,7 @@ cargo.env("CFG_RELEASE_CHANNEL", &builder.config.channel); cargo.env("CFG_VERSION", builder.rust_version()); + cargo.env("CFG_RELEASE_NUM", channel::CFG_RELEASE_NUM); let info = GitInfo::new(&builder.config, &dir); if let Some(sha) = info.sha() { @@ -244,6 +253,9 @@ if let Some(date) = info.commit_date() { cargo.env("CFG_COMMIT_DATE", date); } + if features.len() > 0 { + cargo.arg("--features").arg(&features.join(", ")); + } cargo } @@ -439,6 +451,7 @@ "build", "src/tools/rustdoc", SourceType::InTree, + &[], ); // Most tools don't get debuginfo, but rustdoc should. @@ -495,9 +508,6 @@ } fn run(self, builder: &Builder) -> PathBuf { - builder.ensure(native::Openssl { - target: self.target, - }); // Cargo depends on procedural macros, which requires a full host // compiler to be available, so we need to depend on that. builder.ensure(compile::Rustc { @@ -597,9 +607,6 @@ if clippy.is_some() { self.extra_features.push("clippy".to_owned()); } - builder.ensure(native::Openssl { - target: self.target, - }); // RLS depends on procedural macros, which requires a full host // compiler to be available, so we need to depend on that. builder.ensure(compile::Rustc { diff -Nru rustc-1.30.0+dfsg1+llvm/src/build_helper/lib.rs rustc-1.31.0+dfsg1+llvm/src/build_helper/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/build_helper/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/build_helper/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -91,13 +91,13 @@ output.status.success() } -pub fn gnu_target(target: &str) -> String { +pub fn gnu_target(target: &str) -> &str { match target { - "i686-pc-windows-msvc" => "i686-pc-win32".to_string(), - "x86_64-pc-windows-msvc" => "x86_64-pc-win32".to_string(), - "i686-pc-windows-gnu" => "i686-w64-mingw32".to_string(), - "x86_64-pc-windows-gnu" => "x86_64-w64-mingw32".to_string(), - s => s.to_string(), + "i686-pc-windows-msvc" => "i686-pc-win32", + "x86_64-pc-windows-msvc" => "x86_64-pc-win32", + "i686-pc-windows-gnu" => "i686-w64-mingw32", + "x86_64-pc-windows-gnu" => "x86_64-w64-mingw32", + s => s, } } @@ -178,6 +178,37 @@ pub out_dir: PathBuf, } +impl NativeLibBoilerplate { + /// On OSX we don't want to ship the exact filename that compiler-rt builds. + /// This conflicts with the system and ours is likely a wildly different + /// version, so they can't be substituted. + /// + /// As a result, we rename it here but we need to also use + /// `install_name_tool` on OSX to rename the commands listed inside of it to + /// ensure it's linked against correctly. + pub fn fixup_sanitizer_lib_name(&self, sanitizer_name: &str) { + if env::var("TARGET").unwrap() != "x86_64-apple-darwin" { + return + } + + let dir = self.out_dir.join("build/lib/darwin"); + let name = format!("clang_rt.{}_osx_dynamic", sanitizer_name); + let src = dir.join(&format!("lib{}.dylib", name)); + let new_name = format!("lib__rustc__{}.dylib", name); + let dst = dir.join(&new_name); + + println!("{} => {}", src.display(), dst.display()); + fs::rename(&src, &dst).unwrap(); + let status = Command::new("install_name_tool") + .arg("-id") + .arg(format!("@rpath/{}", new_name)) + .arg(&dst) + .status() + .expect("failed to execute `install_name_tool`"); + assert!(status.success()); + } +} + impl Drop for NativeLibBoilerplate { fn drop(&mut self) { if !thread::panicking() { @@ -202,7 +233,8 @@ let src_dir = current_dir.join("..").join(src_name); rerun_if_changed_anything_in_dir(&src_dir); - let out_dir = env::var_os("RUSTBUILD_NATIVE_DIR").unwrap_or(env::var_os("OUT_DIR").unwrap()); + let out_dir = env::var_os("RUSTBUILD_NATIVE_DIR").unwrap_or_else(|| + env::var_os("OUT_DIR").unwrap()); let out_dir = PathBuf::from(out_dir).join(out_name); t!(fs::create_dir_all(&out_dir)); if link_name.contains('=') { @@ -229,7 +261,7 @@ pub fn sanitizer_lib_boilerplate(sanitizer_name: &str) -> Result<(NativeLibBoilerplate, String), ()> { - let (link_name, search_path, dynamic) = match &*env::var("TARGET").unwrap() { + let (link_name, search_path, apple) = match &*env::var("TARGET").unwrap() { "x86_64-unknown-linux-gnu" => ( format!("clang_rt.{}-x86_64", sanitizer_name), "build/lib/linux", @@ -242,8 +274,8 @@ ), _ => return Err(()), }; - let to_link = if dynamic { - format!("dylib={}", link_name) + let to_link = if apple { + format!("dylib=__rustc__{}", link_name) } else { format!("static={}", link_name) }; diff -Nru rustc-1.30.0+dfsg1+llvm/src/Cargo.lock rustc-1.31.0+dfsg1+llvm/src/Cargo.lock --- rustc-1.30.0+dfsg1+llvm/src/Cargo.lock 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/Cargo.lock 2018-12-04 23:41:40.000000000 +0000 @@ -54,7 +54,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -82,7 +82,7 @@ "environment 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -92,7 +92,7 @@ dependencies = [ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -104,7 +104,7 @@ "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -117,6 +117,19 @@ ] [[package]] +name = "bit-set" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bit-vec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "bit-vec" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "bitflags" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -142,7 +155,7 @@ "pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -166,44 +179,60 @@ version = "0.1.0" [[package]] +name = "bytecount" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "packed_simd 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "byteorder" version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] +name = "bytesize" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "cargo" -version = "0.31.0" +version = "0.32.0" dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "bufstream 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "bytesize 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crates-io 0.19.0", + "crates-io 0.20.0", "crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "crypto-hash 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "curl 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.4.18 (registry+https://github.com/rust-lang/crates.io-index)", + "curl-sys 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fs2 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "fwdansi 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)", - "git2-curl 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "git2-curl 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "home 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "ignore 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "jobserver 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazycell 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazycell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "opener 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.10.11 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)", + "proptest 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-workspace-hack 1.0.0", "rustfix 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "same-file 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -211,7 +240,7 @@ "serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", "serde_ignored 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", "shell-escape 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.16 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -219,19 +248,19 @@ "toml 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cargo_metadata" -version = "0.6.0" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -250,7 +279,7 @@ [[package]] name = "chalk-engine" -version = "0.7.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "chalk-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -294,7 +323,7 @@ name = "clippy" version = "0.0.212" dependencies = [ - "cargo_metadata 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cargo_metadata 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "clippy-mini-macro-test 0.2.0", "clippy_dev 0.0.1", "clippy_lints 0.0.212", @@ -321,13 +350,14 @@ "itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "walkdir 2.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "clippy_lints" version = "0.0.212" dependencies = [ - "cargo_metadata 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cargo_metadata 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "if_chain 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -338,6 +368,7 @@ "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-normalization 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -401,14 +432,14 @@ "getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "rustfix 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -420,13 +451,13 @@ "filetime 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -452,13 +483,13 @@ [[package]] name = "crates-io" -version = "0.19.0" +version = "0.20.0" dependencies = [ - "curl 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.4.18 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -469,12 +500,12 @@ [[package]] name = "crossbeam-channel" -version = "0.2.3" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "crossbeam-epoch 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-epoch 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -504,12 +535,12 @@ [[package]] name = "crossbeam-epoch" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "crossbeam-utils 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -525,11 +556,6 @@ [[package]] name = "crossbeam-utils" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "crossbeam-utils" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -540,37 +566,38 @@ dependencies = [ "commoncrypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.10.11 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "curl" -version = "0.4.14" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "curl-sys 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "curl-sys 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.35 (registry+https://github.com/rust-lang/crates.io-index)", - "schannel 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", - "socket2 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.38 (registry+https://github.com/rust-lang/crates.io-index)", + "schannel 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "socket2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "curl-sys" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.35 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", + "libnghttp2-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libz-sys 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.38 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -590,12 +617,13 @@ [[package]] name = "derive_more" -version = "0.11.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.13.11 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -630,7 +658,7 @@ "regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", "strum 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "strum_macros 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -640,7 +668,7 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -650,7 +678,7 @@ dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -697,7 +725,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -720,7 +748,7 @@ [[package]] name = "flate2" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", @@ -755,7 +783,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -809,37 +837,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "getset" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.13.11 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "git2" version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libgit2-sys 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.35 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.38 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "git2-curl" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "curl 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)", + "curl 0.4.18 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -855,7 +873,7 @@ dependencies = [ "aho-corasick 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -870,13 +888,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "pest 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "pest_derive 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -890,7 +908,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -898,7 +916,7 @@ version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "mac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "markup5ever 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -937,13 +955,13 @@ "crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "globset 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "same-file 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -952,12 +970,12 @@ dependencies = [ "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "tar 0.4.16 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "xz2 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -967,16 +985,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "isatty" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] name = "itertools" version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -986,7 +994,7 @@ [[package]] name = "itoa" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -995,7 +1003,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1013,7 +1021,7 @@ "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1027,7 +1035,7 @@ [[package]] name = "languageserver-types" -version = "0.45.0" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1035,7 +1043,7 @@ "num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "url_serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1050,12 +1058,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "lazycell" -version = "1.0.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1073,16 +1081,24 @@ [[package]] name = "libgit2-sys" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "curl-sys 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)", + "curl-sys 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "libssh2-sys 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.35 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", + "libz-sys 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.38 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "libnghttp2-sys" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1092,20 +1108,20 @@ dependencies = [ "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.35 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", + "libz-sys 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.38 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libz-sys" -version = "1.0.22" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1127,12 +1143,12 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "log" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1154,7 +1170,7 @@ "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1181,7 +1197,7 @@ "phf_codegen 0.7.22 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", "string_cache_codegen 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "tendril 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1206,14 +1222,14 @@ "handlebars 0.32.4 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.0.2 (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.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", "shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1234,7 +1250,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1244,7 +1260,7 @@ [[package]] name = "minifier" -version = "0.0.19" +version = "0.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "macro-utils 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1264,8 +1280,8 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "socket2 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "socket2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1273,12 +1289,12 @@ version = "0.1.0" dependencies = [ "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "cargo_metadata 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cargo_metadata 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "compiletest_rs 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "vergen 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "vergen 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1300,7 +1316,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1338,12 +1354,12 @@ dependencies = [ "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "openssl" -version = "0.10.11" +version = "0.10.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1351,7 +1367,7 @@ "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.35 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.38 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1361,7 +1377,7 @@ [[package]] name = "openssl-src" -version = "110.0.7+1.1.0i" +version = "111.0.1+1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1369,13 +1385,13 @@ [[package]] name = "openssl-sys" -version = "0.9.35" +version = "0.9.38" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-src 110.0.7+1.1.0i (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-src 111.0.1+1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1398,6 +1414,14 @@ ] [[package]] +name = "packed_simd" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "panic_abort" version = "0.0.0" dependencies = [ @@ -1419,15 +1443,6 @@ [[package]] name = "parking_lot" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "parking_lot" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ @@ -1443,7 +1458,7 @@ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1454,7 +1469,7 @@ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1522,7 +1537,7 @@ [[package]] name = "pkg-config" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1531,7 +1546,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "datafrog 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1559,7 +1574,7 @@ [[package]] name = "proc-macro2" -version = "0.4.13" +version = "0.4.24" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1585,6 +1600,23 @@ ] [[package]] +name = "proptest" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bit-set 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rusty-fork 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "pulldown-cmark" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1621,23 +1653,23 @@ version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "racer" -version = "2.1.5" +version = "2.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", - "derive_more 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "derive_more 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)", "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1647,7 +1679,7 @@ dependencies = [ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1659,7 +1691,7 @@ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1754,69 +1786,71 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rls" -version = "0.130.5" +version = "1.31.6" dependencies = [ - "cargo 0.31.0", - "cargo_metadata 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cargo 0.32.0", + "cargo_metadata 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "clippy_lints 0.0.212", - "crossbeam-channel 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-channel 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "languageserver-types 0.45.0 (registry+https://github.com/rust-lang/crates.io-index)", + "languageserver-types 0.51.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "ordslice 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "racer 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "racer 2.1.13 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rls-analysis 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rls-blacklist 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rls-data 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rls-analysis 0.16.10 (registry+https://github.com/rust-lang/crates.io-index)", + "rls-blacklist 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rls-data 0.18.1 (registry+https://github.com/rust-lang/crates.io-index)", "rls-rustc 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rls-vfs 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rls-vfs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-workspace-hack 1.0.0", - "rustfmt-nightly 0.99.4", + "rustc_tools_util 0.1.0", + "rustfmt-nightly 1.0.0", "serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rls-analysis" -version = "0.16.0" +version = "0.16.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "derive-new 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "fst 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", "json 0.11.13 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rls-data 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rls-data 0.18.1 (registry+https://github.com/rust-lang/crates.io-index)", "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rls-blacklist" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rls-data" -version = "0.18.0" +version = "0.18.1" 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)", @@ -1842,9 +1876,10 @@ [[package]] name = "rls-vfs" -version = "0.4.6" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1864,13 +1899,13 @@ "backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "chalk-engine 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "chalk-engine 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fmt_macros 0.0.0", "graphviz 0.0.0", "jobserver 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "polonius-engine 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc_macro 0.0.0", @@ -1891,33 +1926,40 @@ [[package]] name = "rustc-ap-arena" -version = "237.0.0" +version = "297.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rustc-ap-rustc_data_structures 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] +name = "rustc-ap-graphviz" +version = "297.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "rustc-ap-rustc_cratesio_shim" -version = "237.0.0" +version = "297.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-ap-rustc_data_structures" -version = "237.0.0" +version = "297.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "ena 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_cratesio_shim 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-graphviz 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_cratesio_shim 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-rayon-core 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1927,31 +1969,34 @@ [[package]] name = "rustc-ap-rustc_errors" -version = "237.0.0" +version = "297.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_data_structures 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax_pos 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_cratesio_shim 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax_pos 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-ap-rustc_target" -version = "237.0.0" +version = "297.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_cratesio_shim 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_cratesio_shim 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-ap-serialize" -version = "237.0.0" +version = "297.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1959,29 +2004,29 @@ [[package]] name = "rustc-ap-syntax" -version = "237.0.0" +version = "297.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_data_structures 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_errors 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_target 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax_pos 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_errors 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_target 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax_pos 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-ap-syntax_pos" -version = "237.0.0" +version = "297.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-arena 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_data_structures 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-arena 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2037,15 +2082,17 @@ name = "rustc-workspace-hack" version = "1.0.0" dependencies = [ + "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc_allocator" version = "0.0.0" dependencies = [ - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc 0.0.0", "rustc_data_structures 0.0.0", "rustc_errors 0.0.0", @@ -2080,7 +2127,7 @@ version = "0.0.0" dependencies = [ "graphviz 0.0.0", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc 0.0.0", "rustc_data_structures 0.0.0", "rustc_errors 0.0.0", @@ -2104,8 +2151,8 @@ name = "rustc_codegen_utils" version = "0.0.0" dependencies = [ - "flate2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc 0.0.0", "rustc_data_structures 0.0.0", "rustc_incremental 0.0.0", @@ -2121,7 +2168,7 @@ version = "0.0.0" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2131,7 +2178,8 @@ dependencies = [ "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "ena 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "graphviz 0.0.0", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2150,7 +2198,7 @@ "arena 0.0.0", "env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)", "graphviz 0.0.0", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc 0.0.0", "rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_allocator 0.0.0", @@ -2172,6 +2220,7 @@ "rustc_typeck 0.0.0", "scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "serialize 0.0.0", + "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "syntax 0.0.0", "syntax_ext 0.0.0", "syntax_pos 0.0.0", @@ -2182,6 +2231,7 @@ version = "0.0.0" dependencies = [ "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_cratesio_shim 0.0.0", "rustc_data_structures 0.0.0", "serialize 0.0.0", @@ -2199,7 +2249,7 @@ version = "0.0.0" dependencies = [ "graphviz 0.0.0", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc 0.0.0", "rustc_data_structures 0.0.0", @@ -2213,7 +2263,7 @@ name = "rustc_lint" version = "0.0.0" dependencies = [ - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc 0.0.0", "rustc_mir 0.0.0", "rustc_target 0.0.0", @@ -2245,8 +2295,8 @@ name = "rustc_metadata" version = "0.0.0" dependencies = [ - "flate2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "proc_macro 0.0.0", "rustc 0.0.0", "rustc_data_structures 0.0.0", @@ -2277,7 +2327,7 @@ "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "graphviz 0.0.0", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "log_settings 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "polonius-engine 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc 0.0.0", @@ -2307,7 +2357,7 @@ name = "rustc_passes" version = "0.0.0" dependencies = [ - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc 0.0.0", "rustc_data_structures 0.0.0", "rustc_errors 0.0.0", @@ -2347,7 +2397,8 @@ version = "0.0.0" dependencies = [ "arena 0.0.0", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc 0.0.0", "rustc_data_structures 0.0.0", "rustc_errors 0.0.0", @@ -2360,11 +2411,12 @@ name = "rustc_save_analysis" version = "0.0.0" dependencies = [ - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rls-data 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rls-data 0.18.1 (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)", + "rustc_codegen_utils 0.0.0", "rustc_data_structures 0.0.0", "rustc_target 0.0.0", "rustc_typeck 0.0.0", @@ -2377,7 +2429,7 @@ version = "0.0.0" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_cratesio_shim 0.0.0", "serialize 0.0.0", ] @@ -2391,9 +2443,9 @@ version = "0.0.0" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "chalk-engine 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "chalk-engine 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "graphviz 0.0.0", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc 0.0.0", "rustc_data_structures 0.0.0", "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2418,7 +2470,7 @@ version = "0.0.0" dependencies = [ "arena 0.0.0", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc 0.0.0", "rustc_data_structures 0.0.0", "rustc_errors 0.0.0", @@ -2441,7 +2493,8 @@ name = "rustdoc" version = "0.0.0" dependencies = [ - "minifier 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)", + "minifier 0.0.20 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "pulldown-cmark 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2463,40 +2516,53 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustfmt-nightly" -version = "0.99.4" +version = "1.0.0" dependencies = [ "assert_cli 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cargo_metadata 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "bytecount 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cargo_metadata 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "derive-new 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", "diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.12 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)", - "isatty 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_target 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax_pos 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_target 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax_pos 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-workspace-hack 1.0.0", "serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] +name = "rusty-fork" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "wait-timeout 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "ryu" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2511,11 +2577,11 @@ [[package]] name = "schannel" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2552,7 +2618,7 @@ version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2567,10 +2633,10 @@ [[package]] name = "serde_json" -version = "1.0.26" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "itoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2607,13 +2673,13 @@ [[package]] name = "socket2" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2690,7 +2756,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2720,7 +2786,17 @@ version = "0.14.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syn" +version = "0.15.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2738,7 +2814,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2749,7 +2825,7 @@ version = "0.0.0" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_data_structures 0.0.0", "rustc_errors 0.0.0", "rustc_target 0.0.0", @@ -2764,7 +2840,7 @@ version = "0.0.0" dependencies = [ "fmt_macros 0.0.0", - "log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "proc_macro 0.0.0", "rustc_data_structures 0.0.0", "rustc_errors 0.0.0", @@ -2806,7 +2882,7 @@ "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", "remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2829,15 +2905,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "termcolor" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2888,7 +2956,7 @@ dependencies = [ "serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2898,7 +2966,7 @@ dependencies = [ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3025,18 +3093,17 @@ [[package]] name = "vergen" -version = "2.0.0" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "getset 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "version_check" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -3045,12 +3112,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] +name = "wait-timeout" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "walkdir" version = "2.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "same-file 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3061,7 +3136,7 @@ [[package]] name = "winapi" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3083,7 +3158,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3093,18 +3168,10 @@ [[package]] name = "wincolor" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wincolor" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3138,14 +3205,18 @@ "checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" "checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" "checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0" +"checksum bit-set 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f1efcc46c18245a69c38fcc5cc650f16d3a59d034f3106e9ed63748f695730a" +"checksum bit-vec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4440d5cb623bb7390ae27fec0bb6c61111969860f8e3ae198bfa0663645e67cf" "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum bufstream 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f382711e76b9de6c744cc00d0497baba02fb00a787f088c879f01d09468e32" +"checksum bytecount 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b92204551573580e078dc80017f36a213eb77a0450e4ddd8cfa0f3f2d1f0178f" "checksum byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "74c0b906e9446b0a2e4f760cdb3fa4b2c48cdc6db8766a845c54b6ff063fd2e9" -"checksum cargo_metadata 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d6809b327f87369e6f3651efd2c5a96c49847a3ed2559477ecba79014751ee1" +"checksum bytesize 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "716960a18f978640f25101b5cbf1c6f6b0d3192fab36a2d98ca96f0ecbe41010" +"checksum cargo_metadata 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d8dfe3adeb30f7938e6c1dd5327f29235d8ada3e898aeb08c343005ec2915a2" "checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16" "checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3" -"checksum chalk-engine 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "25ce2f28f55ed544a2a3756b7acf41dd7d6f27acffb2086439950925506af7d0" +"checksum chalk-engine 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9adbe0fe1d6e937c3ee0571739a78f53c1de22f59df616060e868cf13c6c4ce5" "checksum chalk-macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "295635afd6853aa9f20baeb7f0204862440c0fe994c5a253d5f479dac41d047e" "checksum chrono 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6962c635d530328acc53ac6a955e83093fedc91c5809dfac1fa60fa470830a37" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" @@ -3158,19 +3229,18 @@ "checksum core-foundation 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cc3532ec724375c7cb7ff0a097b714fde180bb1f6ed2ab27cfcd99ffca873cd2" "checksum core-foundation-sys 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a3fb15cdbdd9cf8b82d97d0296bb5cd3631bba58d6e31650a002a8e7fb5721f9" "checksum crossbeam 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "24ce9782d4d5c53674646a6a4c1863a21a8fc0cb649b3c94dfc16e45071dea19" -"checksum crossbeam-channel 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "efff2d411e0ac3731b9f6de882b2790fdd2de651577500a806ce78b95b2b9f31" +"checksum crossbeam-channel 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7b85741761b7f160bc5e7e0c14986ef685b7f8bf9b7ad081c60c604bb4649827" "checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" "checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150" -"checksum crossbeam-epoch 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "285987a59c4d91388e749850e3cb7b3a92299668528caaacd08005b8f238c0ea" +"checksum crossbeam-epoch 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c90f1474584f38e270b5b613e898c8c328aa4f3dea85e0a27ac2e642f009416" "checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9" -"checksum crossbeam-utils 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ea52fab26a99d96cdff39d0ca75c9716125937f5dba2ab83923aaaf5928f684a" "checksum crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "677d453a17e8bd2b913fa38e8b9cf04bcdbb5be790aa294f2389661d72036015" "checksum crypto-hash 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "09de9ee0fc255ace04c7fa0763c9395a945c37c8292bb554f8d48361d1dcf1b4" -"checksum curl 0.4.14 (registry+https://github.com/rust-lang/crates.io-index)" = "444c2f9e71458b34e75471ed8d756947a0bb920b8b8b9bfc56dfcc4fc6819a13" -"checksum curl-sys 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)" = "78800a6de442f65dab6ce26c6f369c14fc585686432bf4b77119d2d384216c31" +"checksum curl 0.4.18 (registry+https://github.com/rust-lang/crates.io-index)" = "a9e5285b49b44401518c947d3b808d14d99a538a6c9ffb3ec0205c11f9fc4389" +"checksum curl-sys 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)" = "08459503c415173da1ce6b41036a37b8bfdd86af46d45abb9964d4c61fe670ef" "checksum datafrog 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "16d724bf4ffe77cdceeecd461009b5f8d9e23c5d645d68bedb4586bf43e7e142" "checksum derive-new 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ceed73957c449214f8440eec8ad7fa282b67dc9eacbb24a3085b15d60397a17a" -"checksum derive_more 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46c7f14685a20f5dd08e7f754f2ea8cc064d8f4214ae21116c106a2768ba7b9b" +"checksum derive_more 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3f57d78cf3bd45270dad4e70c21ec77a960b36c7a841ff9db76aaa775a8fb871" "checksum diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "3c2b69f912779fbb121ceb775d74d51e915af17aaebc38d28a592843a2dd0a3a" "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" @@ -3184,7 +3254,7 @@ "checksum failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "946d0e98a50d9831f5d589038d2ca7f8f455b1c21028c0db0e84116a12696426" "checksum filetime 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "da4b9849e77b13195302c174324b5ba73eec9b236b24c221a61000daefb95c5f" "checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" -"checksum flate2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "37847f133aae7acf82bb9577ccd8bda241df836787642654286e79679826a54b" +"checksum flate2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4af030962d89d62aa52cd9492083b1cd9b2d1a77764878102a6c0f86b4d5444d" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" "checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" @@ -3196,9 +3266,8 @@ "checksum futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "1a70b146671de62ec8c8ed572219ca5d594d9b06c0b364d5e67b722fc559b48c" "checksum fwdansi 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "34dd4c507af68d37ffef962063dfa1944ce0dd4d5b82043dbab1dabe088610c3" "checksum getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "b900c08c1939860ce8b54dc6a89e26e00c04c380fd0e09796799bd7f12861e05" -"checksum getset 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "54c7f36a235738bb25904d6a2b3dbb28f6f5736cd3918c4bf80d6bb236200782" "checksum git2 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "591f8be1674b421644b6c030969520bc3fa12114d2eb467471982ed3e9584e71" -"checksum git2-curl 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b502f6b1b467957403d168f0039e0c46fa6a1220efa2adaef25d5b267b5fe024" +"checksum git2-curl 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0173e317f8ba21f3fff0f71549fead5e42e67961dbd402bf69f42775f3cc78b4" "checksum glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb" "checksum globset 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8e49edbcc9c7fc5beb8c0a54e7319ff8bed353a2b55e85811c6281188c2a6c84" "checksum handlebars 0.32.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d89ec99d1594f285d4590fc32bac5f75cdab383f1123d504d27862c644a807dd" @@ -3210,24 +3279,24 @@ "checksum if_chain 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4bac95d9aa0624e7b78187d6fb8ab012b41d9f6f54b1bcb61e61c4845f8357ec" "checksum ignore 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3e9faa7c84064f07b40da27044af629f578bc7994b650d3e458d0c29183c1d91" "checksum is-match 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7e5b386aef33a1c677be65237cb9d32c3f3ef56bd035949710c4bb13083eb053" -"checksum isatty 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6c324313540cd4d7ba008d43dc6606a32a5579f13cc17b2804c13096f0a5c522" "checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450" -"checksum itoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5adb58558dcd1d786b5f0bd15f3226ee23486e24b7b58304b60f64dc68e62606" +"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" "checksum jobserver 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "60af5f849e1981434e4a31d3d782c4774ae9b434ce55b101a96ecfd09147e8be" "checksum json 0.11.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9ad0485404155f45cce53a40d4b2d6ac356418300daed05273d9e26f91c390be" "checksum jsonrpc-core 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ddf83704f4e79979a424d1082dd2c1e52683058056c9280efa19ac5f6bc9033c" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum languageserver-types 0.45.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9d91d91d1c23db74187096d191967cb49f49bb175ad6d855fa9229d16ef2c982" +"checksum languageserver-types 0.51.1 (registry+https://github.com/rust-lang/crates.io-index)" = "68de833188ada4e175d04a028f03f244f6370eedbcc75a05604d47d925933f69" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" "checksum lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7" -"checksum lazycell 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d33a48d0365c96081958cc663eef834975cb1e8d8bea3378513fc72bdbf11e50" +"checksum lazycell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ddba4c30a78328befecec92fc94970e53b3ae385827d28620f0f5bb2493081e0" "checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d" -"checksum libgit2-sys 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)" = "93f2b22fce91fb820363cf88a849a8f8fdfd8be37774b6a9dd6cbda05cf940e6" +"checksum libgit2-sys 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4916b5addc78ec36cc309acfcdf0b9f9d97ab7b84083118b248709c5b7029356" +"checksum libnghttp2-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ffbfb81475cc9f625e44f3a8f8b9cf7173815ae1c7cc2fa91853ec009e38198" "checksum libssh2-sys 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "126a1f4078368b163bfdee65fbab072af08a1b374a5551b21e87ade27b1fbf9d" -"checksum libz-sys 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)" = "65ff614643d7635dfa2151913d95c4ee90ee1fe15d9e0980f4dcb1a7e5837c18" +"checksum libz-sys 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "4401fe74560a0d46fce3464625ac8aa7a79d291dd28cee021d18852d5191c280" "checksum lock_api 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "949826a5ccf18c1b3a7c3d57692778d21768b79e46eb9dd07bfc4c2160036c54" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" -"checksum log 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cba860f648db8e6f269df990180c2217f333472b4a6e901e97446858487971e2" +"checksum log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f" "checksum log_settings 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19af41f0565d7c19b2058153ad0b42d4d5ce89ec4dbf06ed6741114a8b63e7cd" "checksum lzma-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "d1eaa027402541975218bb0eec67d6b0412f6233af96e0d096d31dbdfd22e614" "checksum mac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" @@ -3239,7 +3308,7 @@ "checksum memchr 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a3b4142ab8738a78c51896f704f83c11df047ff1bda9a92a661aa6361552d93d" "checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" -"checksum minifier 0.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "9908ed7c62f990c21ab41fdca53a864a3ada0da69d8729c4de727b397e27bc11" +"checksum minifier 0.0.20 (registry+https://github.com/rust-lang/crates.io-index)" = "96c269bb45c39b333392b2b18ad71760b34ac65666591386b0e959ed58b3f474" "checksum miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "609ce024854aeb19a0ef7567d348aaa5a746b32fb72e336df7fcc16869d7e2b4" "checksum miow 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "396aa0f2003d7df8395cb93e09871561ccc3e785f0acb369170e8cc74ddf9226" "checksum new_debug_unreachable 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0cdc457076c78ab54d5e0d6fa7c47981757f1e34dc39ff92787f217dede586c4" @@ -3250,14 +3319,14 @@ "checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" "checksum open 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c281318d992e4432cfa799969467003d05921582a7489a8325e37f8a450d5113" "checksum opener 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "176cd8eadff5ef9fa5c6d19452535662c02c6bf29b3d594a3fc01f749bb24c94" -"checksum openssl 0.10.11 (registry+https://github.com/rust-lang/crates.io-index)" = "6c24d3508b4fb6da175c10baac54c578b33f09c89ae90c6fe9788b3b4768efdc" +"checksum openssl 0.10.13 (registry+https://github.com/rust-lang/crates.io-index)" = "5af9e83eb3c51ee806387d26a43056f3246d865844caa6dd704d2ba7e831c264" "checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" -"checksum openssl-src 110.0.7+1.1.0i (registry+https://github.com/rust-lang/crates.io-index)" = "c02d15268b7d1b3f0c83a2358f3d981139b54079440f1e2a29c60c1818ad5516" -"checksum openssl-sys 0.9.35 (registry+https://github.com/rust-lang/crates.io-index)" = "912f301a749394e1025d9dcddef6106ddee9252620e6d0a0e5f8d0681de9b129" +"checksum openssl-src 111.0.1+1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d1edaed888fd85a54a2646bf02992931ddefdda3b1a748fc79f088a8db27fcbe" +"checksum openssl-sys 0.9.38 (registry+https://github.com/rust-lang/crates.io-index)" = "ff3d1b390ab1b9700f682ad95a30dc9c0f40dd212ca57266012cfc678b0e365a" "checksum ordermap 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063" "checksum ordslice 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dd20eec3dbe4376829cb7d80ae6ac45e0a766831dca50202ff2d40db46a8a024" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" -"checksum parking_lot 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4d05f1349491390b1730afba60bb20d55761bef489a954546b58b4b34e1e2ac" +"checksum packed_simd 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "25d36de864f7218ec5633572a800109bbe5a1cc8d9d95a967f3daf93ea7e6ddc" "checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5" "checksum parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "4db1a8ccf734a7bce794cc19b3df06ed87ab2f3907036b693c68f56b4d4537fa" "checksum parking_lot_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "06a2b6aae052309c2fd2161ef58f5067bc17bb758377a0de9d4b279d603fdd8a" @@ -3269,19 +3338,20 @@ "checksum phf_codegen 0.7.22 (registry+https://github.com/rust-lang/crates.io-index)" = "4e4048fe7dd7a06b8127ecd6d3803149126e9b33c7558879846da3a63f734f2b" "checksum phf_generator 0.7.22 (registry+https://github.com/rust-lang/crates.io-index)" = "05a079dd052e7b674d21cb31cbb6c05efd56a2cd2827db7692e2f1a507ebd998" "checksum phf_shared 0.7.22 (registry+https://github.com/rust-lang/crates.io-index)" = "c2261d544c2bb6aa3b10022b0be371b9c7c64f762ef28c6f5d4f1ef6d97b5930" -"checksum pkg-config 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "104630aa1c83213cbc76db0703630fcb0421dac3585063be4ce9a8a2feeaa745" +"checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" "checksum polonius-engine 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b6b0a7f5f4278b991ffd14abce1d01b013121ad297460237ef0a2f08d43201" "checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" "checksum pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a029430f0d744bc3d15dd474d591bed2402b645d024583082b9f63bb936dac6" "checksum proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1b06e2f335f48d24442b35a19df506a835fb3547bc3c06ef27340da9acf5cae7" -"checksum proc-macro2 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)" = "ee5697238f0d893c7f0ecc59c0999f18d2af85e424de441178bcacc9f9e6cf67" +"checksum proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)" = "77619697826f31a02ae974457af0b29b723e5619e113e9397b8b82c6bd253f09" +"checksum proptest 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)" = "926d0604475349f463fe44130aae73f2294b5309ab2ca0310b998bd334ef191f" "checksum pulldown-cmark 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d6fdf85cda6cadfae5428a54661d431330b312bc767ddbc57adbedc24da66e32" "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0" "checksum quine-mc_cluskey 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "07589615d719a60c8dd8a4622e7946465dfef20d1a428f969e3443e7386d5f45" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9949cfe66888ffe1d53e6ec9d9f3b70714083854be20fd5e271b232a017401e8" "checksum quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dd636425967c33af890042c483632d33fa7a18f19ad1d7ea72e8998c6ef8dea5" -"checksum racer 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1e4bc3847329b20ff5ba56c298938c179ae9911af15c9c10553f683b65164533" +"checksum racer 2.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "344a53b68d889ab5f44d0617f2bbe1f696abe6a730bd41fa619cfc6fa83a6078" "checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd" "checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c" "checksum rand_core 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "edecf0f94da5551fc9b492093e30b041a891657db7940ee221f9d2f66e82eef2" @@ -3294,20 +3364,21 @@ "checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7" "checksum regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "747ba3b235651f6e2f67dfa8bcdcd073ddb7c243cb21c442fc12395dfcac212d" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" -"checksum rls-analysis 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c18011f4654e9f1c41717c5ac1323768af34de0f41e421bbe913d7e9b93581fd" -"checksum rls-blacklist 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e4a9cc2545ccb7e05b355bfe047b8039a6ec12270d5f3c996b766b340a50f7d2" -"checksum rls-data 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4f81e838ecff6830ed33c2907fd236f38d441c206e983a2aa29fbce99295fab9" +"checksum rls-analysis 0.16.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2de1187cceaf16d7642cc78835a2890b55b35ed9e8a8e3c6348a6297d8dd0fb1" +"checksum rls-blacklist 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b8ce1fdac03e138c4617ff87b194e1ff57a39bb985a044ccbd8673d30701e411" +"checksum rls-data 0.18.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a209ce46bb52813cbe0786a7baadc0c1a3f5543ef93f179eda3b841ed72cf2e" "checksum rls-rustc 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9dba7390427aefa953608429701e3665192ca810ba8ae09301e001b7c7bed0" "checksum rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d7c7046dc6a92f2ae02ed302746db4382e75131b9ce20ce967259f6b5867a6a" -"checksum rls-vfs 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ecbc8541b4c341d6271eae10f869dd9d36db871afe184f5b6f9bffbd6ed0373f" -"checksum rustc-ap-arena 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d24c8b3c1437fad023cb9472381216a1d41d82dbb2d2e6c7858bd6f50317719" -"checksum rustc-ap-rustc_cratesio_shim 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9c5b02c76cd1ee4e9c97c8228701796d6b7431e8f100dea2d8af1d6c2c2bad56" -"checksum rustc-ap-rustc_data_structures 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4076388154497fb9a007e3badd78e415402a5594111cd6bc7ce1420dd1b1818b" -"checksum rustc-ap-rustc_errors 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c6c11e4789cbc276ceaa87d326c234b1a2d1e0fe6017b88a8a25903200060acb" -"checksum rustc-ap-rustc_target 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "25f711bb152b9d7cdd69410cfe6d99aeb1409c959e0fdf3c8ca4d220e568aa52" -"checksum rustc-ap-serialize 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "57638db658d4942d3f30a12566836f9a67a636ed8002c8cae1c9231214e39929" -"checksum rustc-ap-syntax 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d6dbcf07abf7a9957dce8d34353d55dfb4cd882153181f24349f4690facb58f0" -"checksum rustc-ap-syntax_pos 237.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0915cb5e166cabe588a129dec2d47357077e96fb1f9b57318fbe217eac4ce508" +"checksum rls-vfs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "72d56425bd5aa86d9d4372b76f0381d3b4bda9c0220e71956c9fcc929f45c1f1" +"checksum rustc-ap-arena 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b69fd4a0e8a3ecd99b497965d05f6f04dd2e4601a6146a841dbe4c8e77c2b30c" +"checksum rustc-ap-graphviz 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8136418dbc491bab74aa0565eaa2086754a7a81a5e74a1d84d6168d18e889e7" +"checksum rustc-ap-rustc_cratesio_shim 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a972feda82332d1d05b1ba5a097e915cd9c9c8f1af2bd7b08af09fb88c753d5f" +"checksum rustc-ap-rustc_data_structures 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "582584c6c48b0ece4b8aef3f9bb59d94d17c5665612bc87a71f509e45a3113b5" +"checksum rustc-ap-rustc_errors 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cd852096944d0ac6af1aefa9639a2ae6dede217606ce97f88ff0dcc8c86d6ff6" +"checksum rustc-ap-rustc_target 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "98301a272ecfeec29d2d4e97b07238707c2b89d86fc3a4a5f31a00728f14e288" +"checksum rustc-ap-serialize 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f13510e617e2e322e3297038fd6a7346f2297124af9e10e33a627c5d544e9d" +"checksum rustc-ap-syntax 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0792f5a9ccfc5ec13bb5b0472fa49e145481029c39f6bf5b1a36decc99c3328f" +"checksum rustc-ap-syntax_pos 297.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0df9f97f41650d23b14f92f7267f8c61089655efb4533d82bf8991f99245198d" "checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395" "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" "checksum rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c6d5a683c6ba4ed37959097e88d71c9e8e26659a3cb5be8b389078e7ad45306" @@ -3315,9 +3386,10 @@ "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum rustc_version 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a54aa04a10c68c1c4eacb4337fd883b435997ede17a9385784b990777686b09a" "checksum rustfix 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "756567f00f7d89c9f89a5c401b8b1caaa122e27240b9eaadd0bb52ee0b680b1b" +"checksum rusty-fork 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9591f190d2852720b679c21f66ad929f9f1d7bb09d1193c26167586029d8489c" "checksum ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7153dd96dade874ab973e098cb62fcdbb89a03682e46b144fd09550998d4a4a7" "checksum same-file 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "10f7794e2fda7f594866840e95f5c5962e886e228e68b6505885811a94dd728c" -"checksum schannel 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "dc1fabf2a7b6483a141426e1afd09ad543520a77ac49bd03c286e7696ccfd77f" +"checksum schannel 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "0e1a231dc10abf6749cfa5d7767f25888d484201accbd919b66ab5413c502d56" "checksum scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "332ffa32bf586782a3efaeb58f127980944bbc8c4d6913a86107ac2a5ab24b28" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" @@ -3325,12 +3397,12 @@ "checksum serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)" = "22d340507cea0b7e6632900a176101fea959c7065d93ba555072da90aaaafc87" "checksum serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)" = "234fc8b737737b148ccd625175fc6390f5e4dacfdaa543cb93a3430d984a9119" "checksum serde_ignored 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "190e9765dcedb56be63b6e0993a006c7e3b071a016a304736e4a315dc01fb142" -"checksum serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)" = "44dd2cfde475037451fa99b7e5df77aa3cfd1536575fa8e7a538ab36dcde49ae" +"checksum serde_json 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)" = "bb47a3d5c84320222f66d7db21157c4a7407755de41798f9b4c1c40593397b1a" "checksum shell-escape 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "170a13e64f2a51b77a45702ba77287f5c6829375b04a69cf2222acd17d0cfab9" "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.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "153ffa32fd170e9944f7e0838edf824a754ec4c1fc64746fcc9fe1f8fa602e5d" -"checksum socket2 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "962a516af4d3a7c272cb3a1d50a8cc4e5b41802e4ad54cfb7bee8ba61d37d703" +"checksum socket2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c4d11a52082057d87cb5caa31ad812f4504b97ab44732cd8359df2e9ff9f48e7" "checksum stable_deref_trait 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ffbc596e092fe5f598b12ef46cc03754085ac2f4d8c739ad61c4ae266cc3b3fa" "checksum string_cache 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25d70109977172b127fe834e5449e5ab1740b9ba49fa18a2020f509174f25423" "checksum string_cache_codegen 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "35293b05cf1494e8ddd042a7df6756bf18d07f42d234f32e71dce8a7aabb0191" @@ -3341,13 +3413,13 @@ "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" "checksum syn 0.13.11 (registry+https://github.com/rust-lang/crates.io-index)" = "14f9bf6292f3a61d2c716723fdb789a41bbe104168e6f496dc6497e531ea1b9b" "checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" +"checksum syn 0.15.21 (registry+https://github.com/rust-lang/crates.io-index)" = "816b7af21405b011a23554ea2dc3f6576dc86ca557047c34098c1d741f10f823" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "85bb9b7550d063ea184027c9b8c20ac167cd36d3e06b3a40bceb9d746dc1a7b7" "checksum tar 0.4.16 (registry+https://github.com/rust-lang/crates.io-index)" = "e8f41ca4a5689f06998f0247fcb60da6c760f1950cc9df2a10d71575ad0b062a" "checksum tempfile 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c4b103c6d08d323b92ff42c8ce62abcd83ca8efa7fd5bf7927efefec75f58c76" "checksum tendril 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9de21546595a0873061940d994bbbc5c35f024ae4fd61ec5c5b159115684f508" "checksum term 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5e6b677dd1e8214ea1ef4297f85dbcbed8e8cdddb561040cc998ca2551c37561" -"checksum termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "adc4587ead41bf016f11af03e55a624c06568b5a19db4e90fde573d805074f83" "checksum termcolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3390f44f1f706d8870297b6a2c4f92d9ab65a37c265fbbc6ac4ee72bcc2f3698" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" "checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" @@ -3369,17 +3441,17 @@ "checksum utf8-ranges 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd70f467df6810094968e2fce0ee1bd0e87157aceb026a8c083bcf5e25b9efe4" "checksum vcpkg 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "def296d3eb3b12371b2c7d0e83bfe1403e4db2d7a0bba324a12b21c4ee13143d" "checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" -"checksum vergen 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9a16834fc61e1492c07dae49b6c14b55f8b1d43a5f5f9e9a2ecc063f47b9f93c" -"checksum version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7716c242968ee87e5542f8021178248f267f295a5c4803beae8b8b7fd9bc6051" +"checksum vergen 3.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1b9696d96ec5d68984d060af80d7ba0ed4eb533978a0efb05ed4b8465f20d04f" +"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +"checksum wait-timeout 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b9f3bf741a801531993db6478b95682117471f76916f5e690dd8d45395b09349" "checksum walkdir 2.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "af464bc7be7b785c7ac72e266a6b67c4c9070155606f51655a650a6686204e35" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd" +"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5508759c5bf4285e61feb862b6083c8480aec864fa17a81fdec6f69b461ab" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -"checksum wincolor 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eeb06499a3a4d44302791052df005d5232b927ed1a9658146d842165c4de7767" "checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba" "checksum xattr 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "244c3741f4240ef46274860397c7c74e50eb23624996930e484c16679633a54c" "checksum xz2 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "df8bf41d3030c3577c9458fd6640a05afbf43b150d0b531b16bd77d3f794f27a" diff -Nru rustc-1.30.0+dfsg1+llvm/src/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/Cargo.toml 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/Cargo.toml 2018-12-04 23:41:40.000000000 +0000 @@ -62,5 +62,6 @@ # here rustc-workspace-hack = { path = 'tools/rustc-workspace-hack' } -[patch."https://github.com/rust-lang-nursery/rust-clippy"] +[patch."https://github.com/rust-lang/rust-clippy"] clippy_lints = { path = "tools/clippy/clippy_lints" } +rustc_tools_util = { path = "tools/clippy/rustc_tools_util" } diff -Nru rustc-1.30.0+dfsg1+llvm/src/ci/docker/dist-i686-linux/Dockerfile rustc-1.31.0+dfsg1+llvm/src/ci/docker/dist-i686-linux/Dockerfile --- rustc-1.30.0+dfsg1+llvm/src/ci/docker/dist-i686-linux/Dockerfile 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/ci/docker/dist-i686-linux/Dockerfile 2018-12-04 23:41:40.000000000 +0000 @@ -83,6 +83,11 @@ COPY dist-x86_64-linux/build-headers.sh /tmp/ RUN ./build-headers.sh +# OpenSSL requires a more recent version of perl +# with so we install newer ones here +COPY dist-x86_64-linux/build-perl.sh /tmp/ +RUN ./build-perl.sh + COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh @@ -110,3 +115,5 @@ # When we build cargo in this container, we don't want it to use the system # libcurl, instead it should compile its own. ENV LIBCURL_NO_PKG_CONFIG 1 + +ENV DIST_REQUIRE_ALL_TOOLS 1 diff -Nru rustc-1.30.0+dfsg1+llvm/src/ci/docker/dist-x86_64-linux/build-perl.sh rustc-1.31.0+dfsg1+llvm/src/ci/docker/dist-x86_64-linux/build-perl.sh --- rustc-1.30.0+dfsg1+llvm/src/ci/docker/dist-x86_64-linux/build-perl.sh 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/ci/docker/dist-x86_64-linux/build-perl.sh 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# 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 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -ex +source shared.sh + +curl https://www.cpan.org/src/5.0/perl-5.28.0.tar.gz | \ + tar xzf - + +cd perl-5.28.0 + +# Gotta do some hackery to tell python about our custom OpenSSL build, but other +# than that fairly normal. +CC=gcc \ +CFLAGS='-I /rustroot/include' LDFLAGS='-L /rustroot/lib -L /rustroot/lib64' \ + hide_output ./configure.gnu +hide_output make -j10 +hide_output make install + +cd .. +rm -rf perl-5.28.0 diff -Nru rustc-1.30.0+dfsg1+llvm/src/ci/docker/dist-x86_64-linux/Dockerfile rustc-1.31.0+dfsg1+llvm/src/ci/docker/dist-x86_64-linux/Dockerfile --- rustc-1.30.0+dfsg1+llvm/src/ci/docker/dist-x86_64-linux/Dockerfile 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/ci/docker/dist-x86_64-linux/Dockerfile 2018-12-04 23:41:40.000000000 +0000 @@ -83,6 +83,11 @@ COPY dist-x86_64-linux/build-headers.sh /tmp/ RUN ./build-headers.sh +# OpenSSL requires a more recent version of perl +# with so we install newer ones here +COPY dist-x86_64-linux/build-perl.sh /tmp/ +RUN ./build-perl.sh + COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh @@ -106,3 +111,5 @@ # When we build cargo in this container, we don't want it to use the system # libcurl, instead it should compile its own. ENV LIBCURL_NO_PKG_CONFIG 1 + +ENV DIST_REQUIRE_ALL_TOOLS 1 diff -Nru rustc-1.30.0+dfsg1+llvm/src/ci/docker/scripts/musl.sh rustc-1.31.0+dfsg1+llvm/src/ci/docker/scripts/musl.sh --- rustc-1.30.0+dfsg1+llvm/src/ci/docker/scripts/musl.sh 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/ci/docker/scripts/musl.sh 2018-12-04 23:41:40.000000000 +0000 @@ -32,17 +32,11 @@ export CFLAGS="-fPIC $CFLAGS" -# FIXME: remove the patch when updating to 1.1.20 -MUSL=musl-1.1.19 +MUSL=musl-1.1.20 # may have been downloaded in a previous run if [ ! -d $MUSL ]; then curl https://www.musl-libc.org/releases/$MUSL.tar.gz | tar xzf - - # Patch to fix https://github.com/rust-lang/rust/issues/48967 - cd $MUSL && \ - curl "https://git.musl-libc.org/cgit/musl/patch/?id=610c5a8524c3d6cd3ac5a5f1231422e7648a3791" |\ - patch -p1 && \ - cd - fi cd $MUSL diff -Nru rustc-1.30.0+dfsg1+llvm/src/ci/docker/wasm32-unknown/Dockerfile rustc-1.31.0+dfsg1+llvm/src/ci/docker/wasm32-unknown/Dockerfile --- rustc-1.30.0+dfsg1+llvm/src/ci/docker/wasm32-unknown/Dockerfile 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/ci/docker/wasm32-unknown/Dockerfile 2018-12-04 23:41:40.000000000 +0000 @@ -36,7 +36,6 @@ src/test/ui \ src/test/run-pass \ src/test/compile-fail \ - src/test/parse-fail \ src/test/mir-opt \ src/test/codegen-units \ src/libcore \ diff -Nru rustc-1.30.0+dfsg1+llvm/src/ci/run.sh rustc-1.31.0+dfsg1+llvm/src/ci/run.sh --- rustc-1.30.0+dfsg1+llvm/src/ci/run.sh 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/ci/run.sh 2018-12-04 23:41:40.000000000 +0000 @@ -39,7 +39,7 @@ RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-sccache" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-manage-submodules" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-locked-deps" -RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-cargo-openssl-static" +RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-cargo-native-static" if [ "$DIST_SRC" = "" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-dist-src" @@ -61,6 +61,7 @@ RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions" elif [ "$DEPLOY_ALT" != "" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-assertions" + RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.verify-llvm-ir" fi else # We almost always want debug assertions enabled, but sometimes this takes too @@ -74,6 +75,12 @@ if [ "$NO_LLVM_ASSERTIONS" = "" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-assertions" fi + + RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.verify-llvm-ir" +fi + +if [ "$RUST_RELEASE_CHANNEL" = "nightly" ] || [ "$DIST_REQUIRE_ALL_TOOLS" = "" ]; then + RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-missing-tools" fi # We've had problems in the past of shell scripts leaking fds into the sccache diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/book.toml rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/book.toml --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/book.toml 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/book.toml 2018-11-21 02:20:59.000000000 +0000 @@ -1,3 +1,7 @@ [book] title = "The Rust Programming Language" author = "Steve Klabnik and Carol Nichols, with Contributions from the Rust Community" + +[output.html] +additional-css = ["ferris.css", "src/theme/2018-edition.css"] +additional-js = ["ferris.js"] diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/ferris.css rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/ferris.css --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/ferris.css 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/ferris.css 2018-11-21 02:20:59.000000000 +0000 @@ -0,0 +1,33 @@ +body.light .does_not_compile, +body.light .panics, +body.light .not_desired_behavior, +body.rust .does_not_compile, +body.rust .panics, +body.rust .not_desired_behavior { + background: #fff1f1; +} + +body.coal .does_not_compile, +body.coal .panics, +body.coal .not_desired_behavior, +body.navy .does_not_compile, +body.navy .panics, +body.navy .not_desired_behavior, +body.ayu .does_not_compile, +body.ayu .panics, +body.ayu .not_desired_behavior { + background: #501f21; +} + +.ferris { + position: absolute; + z-index: 99; + right: 5px; + top: 30px; + width: 10%; + height: auto; +} + +.ferris-explain { + width: 100px; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/ferris.js rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/ferris.js --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/ferris.js 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/ferris.js 2018-11-21 02:20:59.000000000 +0000 @@ -0,0 +1,51 @@ +var ferrisTypes = [ + { + attr: 'does_not_compile', + title: 'This code does not compile!' + }, + { + attr: 'panics', + title: 'This code panics!' + }, + { + attr: 'unsafe', + title: 'This code block contains unsafe code.' + }, + { + attr: 'not_desired_behavior', + title: 'This code does not produce the desired behavior.' + } +] + +document.addEventListener('DOMContentLoaded', () => { + for (var ferrisType of ferrisTypes) { + attachFerrises(ferrisType) + } +}) + +function attachFerrises (type) { + var elements = document.getElementsByClassName(type.attr) + + for (var codeBlock of elements) { + var lines = codeBlock.textContent.split(/\r|\r\n|\n/).length - 1; + + if (lines >= 4) { + attachFerris(codeBlock, type) + } + } +} + +function attachFerris (element, type) { + var a = document.createElement('a') + a.setAttribute('href', 'ch00-00-introduction.html#ferris') + a.setAttribute('target', '_blank') + + var img = document.createElement('img') + img.setAttribute('src', 'img/ferris/' + type.attr + '.svg') + img.setAttribute('title', type.title) + img.className = 'ferris' + + a.appendChild(img) + + element.parentElement.insertBefore(a, element) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/nostarch/appendices-d-and-e.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/nostarch/appendices-d-and-e.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/nostarch/appendices-d-and-e.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/nostarch/appendices-d-and-e.md 2018-11-21 02:20:59.000000000 +0000 @@ -0,0 +1,245 @@ +# Appendix D - Useful Development Tools + +In this appendix, we’ll talk about tools provided by the Rust project that are +useful when developing Rust code. + +## Automatic Formatting with `rustfmt` + +The tool `rustfmt` reformats your code according to the community code style. +Many projects use `rustfmt` to prevent arguments about which style to use when +writing Rust: everyone formats their code with the tool! + +The `rustfmt` tool is not yet at the quality of a version 1.0 release, but +a preview is available for you to use in the meantime. Please give it a try and +let us know how it goes! + +To install `rustfmt`: + +``` +$ rustup component add rustfmt-preview +``` + +This will give you both `rustfmt` and `cargo-fmt`, similar to how Rust gives +you both `rustc` and `cargo`. To take any Cargo project and format it: + +``` +$ cargo fmt +``` + +Running this command will reformat all of the Rust code in the current crate. +This should only change the code style, not the code semantics. For more +information on `rustfmt`, see its documentation at +*https://github.com/rust-lang-nursery/rustfmt*. + +## Fix Up Your Code with `rustfix` + +If you’ve written code in Rust, you’ve probably seen compiler warnings. For +example, consider this code: + +Filename: src/main.rs + +``` +fn do_something() {} + +fn main() { + for i in 0..100 { + do_something(); + } +} +``` + +Here, we’re calling the `do_something` function 100 times, but we never use the +variable `i` in the body of the `for` loop. Rust warns us about that: + +``` +$ cargo build + Compiling myprogram v0.1.0 (file:///projects/myprogram) +warning: unused variable: `i` + --> src/main.rs:4:9 + | +4 | for i in 1..100 { + | ^ help: consider using `_i` instead + | + = note: #[warn(unused_variables)] on by default + + Finished dev [unoptimized + debuginfo] target(s) in 0.50s +``` + +The warning suggests that we use `_i` as a name instead: the underscore +indicates that we intend for this variable to be unused. We can automatically +apply that suggestion using the `rustfix` tool by running the command `cargo +fix`: + +``` +$ cargo fix + Checking myprogram v0.1.0 (file:///projects/myprogram) + Fixing src/main.rs (1 fix) + Finished dev [unoptimized + debuginfo] target(s) in 0.59s +``` + +If we look at *src/main.rs* again, we’ll see that `cargo fix` has changed the +code: + +Filename: src/main.rs + +``` +fn do_something() {} + +fn main() { + for _i in 0..100 { + do_something(); + } +} +``` + +The `for` loop variable is now named `_i`, and the warning will no longer +appear. + +The `cargo fix` command can also be used to transition your code between +different editions of Rust. Editions are covered in Appendix E. + +## More Lints with `clippy` + +The `clippy` tool is a collection of lints to catch common mistakes and improve +your Rust code. + +The `clippy` tool is not yet at the quality of a version 1.0 release, but a +preview is available for you to use in the meantime. Please give it a try and +let us know how it goes! + +To install `clippy`: + +``` +$ rustup component add clippy-preview +``` + +To take any Cargo project and run clippy’s lints on it: + +``` +$ cargo clippy +``` + +For example, if you write a program that uses an approximation of a +mathematical constant such as pi, as this program does: + +Filename: src/main.rs + +``` +fn main() { + let x = 3.1415; + let r = 8.0; + println!("the area of the circle is {}", x * r * r); +} +``` + +Running `cargo clippy` on this project will result in this error: + +``` +error: approximate value of `f{32, 64}::consts::PI` found. Consider using it directly + --> src/main.rs:2:13 + | +2 | let x = 3.1415; + | ^^^^^^ + | + = note: #[deny(clippy::approx_constant)] on by default + = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#approx_constant +``` + +This lets you know that Rust has this constant defined more precisely, and that +your program would be more correct if you used the constant instead. This code +doesn’t result in any errors or warnings from `clippy`: + +Filename: src/main.rs + +``` +fn main() { + let x = std::f64::consts::PI; + let r = 8.0; + println!("the area of the circle is {}", x * r * r); +} +``` + +For more information on `clippy`, see its documentation at +*https://github.com/rust-lang-nursery/rust-clippy*. + +## IDE Integration Using the Rust Language Server + +To help IDE integration, the Rust project distributes the `rls`, which stands +for the Rust Language Server. This tool speaks the Language Server Protocol +described at *http://langserver.org/*, which is a specification for IDEs and +programming languages to communicate with each other. The `rls` can be used by +different clients, such as the Rust plugin for Visual Studio: Code at +*https://marketplace.visualstudio.com/items?itemName=rust-lang.rust*. + +The `rls` is not yet at the quality of a version 1.0 release, but a preview is +available for you to use in the meantime. Please give it a try and let us know +how it goes! + +To install the `rls`: + +``` +$ rustup component add rls-preview +``` + +Then install the language server support in your particular IDE, and you will +gain abilities such as autocompletion, jump to definition, and inline errors. + +For more information on the `rls`, see its documentation at +*https://github.com/rust-lang-nursery/rls*. + +# Appendix E - Editions + +Way back in Chapter 1, we saw that `cargo new` adds a bit of metadata to your +*Cargo.toml* about an `edition`. This appendix talks about what that means! + +The Rust language and compiler have a six-week release cycle. This means users +get a constant stream of new features. Other programming languages release +larger changes less often; Rust chooses to release smaller updates more +frequently. After a while, all of those tiny changes add up. But from release +to release, it can be hard to look back and say “Wow, between Rust 1.10 and +Rust 1.31, Rust has changed a lot!” + +Every two or three years, the Rust team produces a new *edition* of Rust. +Each edition brings together the features that have landed into a clear +package with fully updated documentation and tooling. New editions ship +as part of the usual six-week release process. + +This serves different purposes for different people: + +* For active Rust users, it brings together incremental changes into an + easy-to-understand package. +* For non-users, it signals that some major advancements have landed, which + might make Rust worth another look. +* For those developing Rust itself, it provides a rallying point for the + project as a whole. + +At the time of writing, there are two editions: Rust 2015 and Rust 2018. +This book is written using Rust 2018 edition idioms. + +The `edition` key in *Cargo.toml* indicates which edition your code should be +compiled under. If the key does not exist, it defaults to `2015` for backwards +compatibility reasons. + +Each project can choose to opt in to an edition other than the default 2015 +edition. By doing so, editions can contain incompatible changes, such as adding +a new keyword that might conflict with identifiers in code or turning warnings +into errors. But unless you opt in to those changes, your code will continue to +compile even as you upgrade the version of the Rust compiler that you use. All +Rust compiler versions support any edition that existed prior to that +compiler’s release, and they can link crates of any supported editions +together. Edition changes only affect the way the compiler initially parses +code. Therefore, if you’re using Rust 2015 and one of your dependencies uses +Rust 2018, your project will compile and be able to use that dependency. The +opposite situation, where your project uses Rust 2018 and a dependency uses +Rust 2015, works as well. + +To be clear: most features will be available on all editions. Developers using +any edition of Rust will continue to see improvements as new stable releases +are made. In some cases, however, mainly when new keywords are added, there may +be new features that are only available in later editions. You only need to +switch editions if you want to take advantage of such features. + +For more details, the Edition +Guide at *https://rust-lang-nursery.github.io/edition-guide/* is a complete +book about editions, including how to automatically upgrade your code to +a new edition via `cargo fix`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/nostarch/chapter07.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/nostarch/chapter07.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/nostarch/chapter07.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/nostarch/chapter07.md 2018-11-21 02:20:59.000000000 +0000 @@ -0,0 +1,1024 @@ + +[TOC] + +# Packages, Crates, and Modules + +A key question when writing programs is *scope*: what names does the compiler +know about at this location in the code? What functions am I allowed to call? +What does this variable refer to? + +Rust has a number of features related to scopes. This is sometimes called +“the module system,” but it encompases more than just modules: + +* *Packages* are a Cargo feature that let you build, test, and share crates. +* *Crates* are a tree of modules that produce a library or executable. +* *Modules* and the *use* keyword let you control the scope and privacy of paths. +* A *path* is a way of naming an item such as a struct, function, or module. + +This chapter will cover all of these concepts. You’ll be bringing names into +scopes, defining scopes, and exporting names to scopes like a pro soon! + +## Packages and Crates for Making Libraries and Executables + +Let’s talk about *packages* and *crates*. Here’s a summary: + +* A *crate* is a binary or library. +* The *crate root* is a source file that is used to know how to build a crate. +* A *package* has a *Cargo.toml* that describes how to build one or more crates. + At most one crate in a package can be a library. + +So when we type `cargo new`, we’re creating a package: + +``` +$ cargo new my-project + Created binary (application) `my-project` package +$ ls my-project +Cargo.toml +src +$ ls my-project/src +main.rs +``` + +Because Cargo created a *Cargo.toml*, that means we now have a package. If we +look at the contents of *Cargo.toml*, there’s no mention of *src/main.rs*. +However, Cargo’s conventions are that if you have a *src* directory containing +*main.rs* in the same directory as a package’s *Cargo.toml*, Cargo knows this +package contains a binary crate with the same name as the package, and +*src/main.rs* is its crate root. Another convention of Cargo’s is that if the +package directory contains *src/lib.rs*, the package contains a library crate +with the same name as the package, and *src/lib.rs* is its crate root. The +crate root files are passed by Cargo to `rustc` to actually build the library +or binary. + +A package can contain zero or one library crates and as many binary crates as +you’d like. There must be at least one crate (either a library or a binary) in +a package. + +If a package contains both *src/main.rs* and *src/lib.rs*, then it has two +crates: a library and a binary, both with the same name. If we only had one of +the two, the package would have either a single library or binary crate. A +package can have multiple binary crates by placing files in the *src/bin* +directory: each file will be a separate binary crate. + +Next, let’s talk about modules! + +## The Module System to Control Scope and Privacy + +Rust has a feature that’s often referred to as “the module system,” but it +encompasses a few more features than modules. In this section, we’ll talk about: + +* Modules, a way to organize code and control the privacy of paths +* Paths, a way to name items +* `use` a keyword to bring a path into scope +* `pub`, a keyword to make items public +* Renaming items when bringing them into scope with the `as` keyword +* Using external packages +* Nested paths to clean up large `use` lists +* Using the glob operator to bring everything in a module into scope +* How to split modules into individual files + +First up, modules. Modules let us organize code into groups. Listing 7-1 has an +example of some code that defines a module named `sound` that contains a +function named `guitar`. + +Filename: src/main.rs + +``` +mod sound { + fn guitar() { + // Function body code goes here + } +} + +fn main() { + +} +``` + +Listing 7-1: A `sound` module containing a `guitar` function and a `main` +function + +We’ve defined two functions, `guitar` and `main`. We’ve defined the `guitar` +function within a `mod` block. This block defines a module named `sound`. + +To organize code into a hierarchy of modules, you can nest modules inside of +other modules, as shown in Listing 7-2: + +Filename: src/main.rs + +``` +mod sound { + mod instrument { + mod woodwind { + fn clarinet() { + // Function body code goes here + } + } + } + + mod voice { + + } +} + +fn main() { + +} +``` + +Listing 7-2: Modules inside modules + +In this example, we defined a `sound` module in the same way as we did in +Listing 7-1. We then defined two modules within the `sound` module named +`instrument` and `voice`. The `instrument` module has another module defined +within it, `woodwind`, and that module contains a function named `clarinet`. + +We mentioned in the “Packages and Crates for Making Libraries and Executables” +section that *src/main.rs* and *src/lib.rs* are called *crate roots*. They are +called crate roots because the contents of either of these two files form a +module named `crate` at the root of the crate’s module tree. So in Listing 7-2, +we have a module tree that looks like Listing 7-3: + +``` +crate + └── sound + └── instrument + └── woodwind + └── voice +``` + +Listing 7-3: The module tree for the code in Listing 7-2 + +This tree shows how some of the modules nest inside one another (such as +`woodwind` nests inside `instrument`) and how some modules are siblings to +each other (`instrument` and `voice` are both defined within `sound`). The +entire module tree is rooted under the implicit module named `crate`. + +This tree might remind you of the directory tree of the filesystem you have on +your computer; this is a very apt comparison! Just like directories in a +filesystem, you place code inside whichever module will create the organization +you’d like. Another similarity is that to refer to an item in a filesystem or a +module tree, you use its *path*. + +### Paths for Referring to an Item in the Module Tree + +If we want to call a function, we need to know its *path*. “Path” is a synonym +for “name” in a way, but it evokes that filesystem metaphor. Additionally, +functions, structs, and other items may have multiple paths that refer to the +same item, so “name” isn’t quite the right concept. + +A *path* can take two forms: + +* An *absolute path* starts from a crate root by using a crate name or a + literal `crate`. +* A *relative path* starts from the current module and uses `self`, `super`, or + an identifier in the current module. + +Both absolute and relative paths are followed by one or more identifiers +separated by double colons (`::`). + +How do we call the `clarinet` function in the `main` function in Listing 7-2? +That is, what’s the path of the `clarinet` function? In Listing 7-4, let’s +simplify our code a bit by removing some of the modules, and we’ll show two +ways to call the `clarinet` function from `main`. This example won’t compile +just yet, we’ll explain why in a bit. + +Filename: src/main.rs + +``` +mod sound { + mod instrument { + fn clarinet() { + // Function body code goes here + } + } +} + +fn main() { + // Absolute path + crate::sound::instrument::clarinet(); + + // Relative path + sound::instrument::clarinet(); +} +``` + +Listing 7-4: Calling the `clarinet` function in a simplified module tree from +the `main` function using absolute and relative paths + +The first way we’re calling the `clarinet` function from the `main` function +uses an absolute path. Because `clarinet` is defined within the same crate as +`main`, we use the `crate` keyword to start an absolute path. Then we include +each of the modules until we make our way to `clarinet`. This is similar to +specifying the path `/sound/instrument/clarinet` to run the program at that +location on your computer; using the `crate` name to start from the crate root +is like using `/` to start from the filesystem root in your shell. + +The second way we’re calling the `clarinet` function from the `main` function +uses a relative path. The path starts with the name `sound`, a module defined +at the same level of the module tree as the `main` function. This is similar to +specifying the path `sound/instrument/clarinet` to run the program at that +location on your computer; starting with a name means that the path is relative. + +We mentioned that Listing 7-4 won’t compile yet, let’s try to compile it and +find out why not! The error we get is shown in Listing 7-5. + +``` +$ cargo build + Compiling sampleproject v0.1.0 (file:///projects/sampleproject) +error[E0603]: module `instrument` is private + --> src/main.rs:11:19 + | +11 | crate::sound::instrument::clarinet(); + | ^^^^^^^^^^ + +error[E0603]: module `instrument` is private + --> src/main.rs:14:12 + | +14 | sound::instrument::clarinet(); + | ^^^^^^^^^^ +``` + +Listing 7-5: Compiler errors from building the code in Listing 7-4 + +The error messsages say that module `instrument` is private. We can see that we +have the correct paths for the `instrument` module and the `clarinet` function, +but Rust won’t let us use them because they’re private. It’s time to learn +about the `pub` keyword! + +### Modules as the Privacy Boundary + +Earlier, we talked about the syntax of modules and that they can be used for +organization. There’s another reason Rust has modules: modules are the *privacy +boundary* in Rust. If you want to make an item like a function or struct +private, you put it in a module. Here are the privacy rules: + +* All items (functions, methods, structs, enums, modules, annd constants) are + private by default. +* You can use the `pub` keyword to make an item public. +* You aren’t allowed to use private code defined in modules that are children + of the current module. +* You are allowed to use any code defined in ancestor modules or the current + module. + +In other words, items without the `pub` keyword are private as you look “down” +the module tree from the current module, but items without the `pub` keyword +are public as you look “up” the tree from the current module. Again, think of a +filesystem: if you don’t have permissions to a directory, you can’t look into +it from its parent directory. If you do have permissions to a directory, you +can look inside it and any of its ancestor directories. + +### Using the `pub` Keyword to Make Items Public + +The error in Listing 7-5 said the `instrument` module is private. Let’s mark +the `instrument` module with the `pub` keyword so that we can use it from the +`main` function. This change is shown in Listing 7-6, which still won’t +compile, but we’ll get a different error: + +Filename: src/main.rs + +``` +mod sound { + pub mod instrument { + fn clarinet() { + // Function body code goes here + } + } +} + +fn main() { + // Absolute path + crate::sound::instrument::clarinet(); + + // Relative path + sound::instrument::clarinet(); +} +``` + +Listing 7-6: Declaring the `instrument` module as `pub` so that we’re allowed +to use it from `main` + +Adding the `pub` keyword in front of `mod instrument` makes the module public. +With this change, if we’re allowed to access `sound`, we can access +`instrument`. The contents of `instrument` are still private; making the module +public does not make its contents public. The `pub` keyword on a module lets +code in its parent module refer to it. + +The code in Listing 7-6 still results in an error, though, as shown in Listing +7-7: + +``` +$ cargo build + Compiling sampleproject v0.1.0 (file:///projects/sampleproject) +error[E0603]: function `clarinet` is private + --> src/main.rs:11:31 + | +11 | crate::sound::instrument::clarinet(); + | ^^^^^^^^ + +error[E0603]: function `clarinet` is private + --> src/main.rs:14:24 + | +14 | sound::instrument::clarinet(); + | ^^^^^^^^ +``` + +Listing 7-7: Compiler errors from building the code in Listing 7-6 + +The errors now say that the `clarinet` function is private. The privacy rules +apply to structs, enums, functions, and methods as well as modules. + +Let’s make the `clarinet` function public as well by adding the `pub` keyword +before its definition, as shown in Listing 7-8: + +Filename: src/main.rs + +``` +mod sound { + pub mod instrument { + pub fn clarinet() { + // Function body code goes here + } + } +} + +fn main() { + // Absolute path + crate::sound::instrument::clarinet(); + + // Relative path + sound::instrument::clarinet(); +} +``` + +Listing 7-8: Adding the `pub` keyword to both `mod instrument` and `fn +clarinet` lets us call the function from `main` + +This will now compile! Let’s look at both the absolute and the relative path +and double check why adding the `pub` keyword lets us use these paths in `main`. + +In the absolute path case, we start with `crate`, the root of our crate. From +there, we have `sound`, and it is a module that is defined in the crate root. +The `sound` module isn’t public, but because the `main` function is defined in +the same module that `sound` is defined, we’re allowed to refer to `sound` from +`main`. Next is `instrument`, which is a module marked with `pub`. We can +access the parent module of `instrument`, so we’re allowed to access +`instrument`. Finally, `clarinet` is a function marked with `pub` and we can +access its parent module, so this function call works! + +In the relative path case, the logic is the same as the absolute path except +for the first step. Rather than starting from the crate root, the path starts +from `sound`. The `sound` module is defined within the same module as `main` +is, so the relative path starting from the module in which `main` is defined +works. Then because `instrument` and `clarinet` are marked with `pub`, the rest +of the path works and this function call is valid as well! + +### Starting Relative Paths with `super` + +You can also construct relative paths beginning with `super`. Doing so is like +starting a filesystem path with `..`: the path starts from the *parent* module, +rather than the current module. This is useful in situations such as the +example in Listing 7-9, where the function `clarinet` calls the function +`breathe_in` by specifying the path to `breathe_in` start with `super`: + +Filename: src/lib.rs + +``` +mod instrument { + fn clarinet() { + super::breathe_in(); + } +} + +fn breathe_in() { + // Function body code goes here +} +``` + +Listing 7-9: Calling a function using a relative path starting with `super` to +look in the parent module + +The `clarinet` function is in the `instrument` module, so we can use `super` to +go to the parent module of `instrument`, which in this case is `crate`, the +root. From there, we look for `breathe_in`, and find it. Success! + +The reason you might want to choose a relative path starting with `super` +rather than an absolute path starting with `crate` is that using `super` may +make it easier to update your code to have a different module hierarchy, if the +code defining the item and the code calling the item are moved together. For +example, if we decide to put the `instrument` module and the `breathe_in` +function into a module named `sound`, we would only need to add the `sound` +module, as shown in Listing 7-10. + +Filename: src/lib.rs + +``` +mod sound { + mod instrument { + fn clarinet() { + super::breathe_in(); + } + } + + fn breathe_in() { + // Function body code goes here + } +} +``` + +Listing 7-10: Adding a parent module named `sound` doesn’t affect the relative +path `super::breathe_in` + +The call to `super::breathe_in` from the `clarinet` function will continue to +work in Listing 7-10 as it did in Listing 7-9, without needing to update the +path. If instead of `super::breathe_in` we had used `crate::breathe_in` in the +`clarinet` function, when we add the parent `sound` module, we would need to +update the `clarinet` function to use the path `crate::sound::breathe_in` +instead. Using a relative path can mean fewer updates are necessary when +rearranging modules. + +### Using `pub` with Structs and Enums + +You can designate structs and enums to be public in a similar way as we’ve +shown with modules and functions, with a few additional details. + +If you use `pub` before a struct definition, you make the struct public. +However, the struct’s fields are still private. You can choose to make each +field public or not on a case-by-case basis. In Listing 7-11, we’ve defined a +public `plant::Vegetable` struct with a public `name` field but a private `id` +field. + +Filename: src/main.rs + +``` +mod plant { + pub struct Vegetable { + pub name: String, + id: i32, + } + + impl Vegetable { + pub fn new(name: &str) -> Vegetable { + Vegetable { + name: String::from(name), + id: 1, + } + } + } +} + +fn main() { + let mut v = plant::Vegetable::new("squash"); + + v.name = String::from("butternut squash"); + println!("{} are delicious", v.name); + + // The next line won't compile if we uncomment it: + // println!("The ID is {}", v.id); +} +``` + +Listing 7-11: A struct with some public fields and some private fields + +Because the `name` field of the `plant::Vegetable` struct is public, in `main` +we can write and read to the `name` field by using dot notation. We’re not +allowed to use the `id` field in `main` because it’s private. Try uncommenting +the line printing the `id` field value to see what error you get! Also note +that because `plant::Vegetable` has a private field, the struct needs to +provide a public associated function that constructs an instance of `Vegetable` +(we’ve used the conventional name `new` here). If `Vegetable` didn’t have such +a function, we wouldn’t be able to create an instance of `Vegetable` in `main` +because we’re not allowed to set the value of the private `id` field in `main`. + +In contrast, if you make a public enum, all of its variants are public. You +only need the `pub` before the `enum` keyword, as shown in Listing 7-12. + +Filename: src/main.rs + +``` +mod menu { + pub enum Appetizer { + Soup, + Salad, + } +} + +fn main() { + let order1 = menu::Appetizer::Soup; + let order2 = menu::Appetizer::Salad; +} +``` + +Listing 7-12: Designating an enum as public makes all its variants public + +Because we made the `Appetizer` enum public, we’re able to use the `Soup` and +`Salad` variants in `main`. + +There’s one more situation involving `pub` that we haven’t covered, and that’s +with our last module system feature: the `use` keyword. Let’s cover `use` by +itself, and then we’ll show how `pub` and `use` can be combined. + +### The `use` Keyword to Bring Paths into a Scope + +You may have been thinking that many of the paths we’ve written to call +functions in the listings in this chapter are long and repetitive. For example, +in Listing 7-8, whether we chose the absolute or relative path to the +`clarinet` function, every time we wanted to call `clarinet` we had to specify +`sound` and `instrument` too. Luckily, there’s a way to bring a path into a +scope once and then call the items in that path as if they’re local items: with +the `use` keyword. In Listing 7-13, we bring the `crate::sound::instrument` +module into the scope of the `main` function so that we only have to specify +`instrument::clarinet` to call the `clarinet` function in `main`. + +Filename: src/main.rs + +``` +mod sound { + pub mod instrument { + pub fn clarinet() { + // Function body code goes here + } + } +} + +use crate::sound::instrument; + +fn main() { + instrument::clarinet(); + instrument::clarinet(); + instrument::clarinet(); +} +``` + +Listing 7-13: Bringing a module into scope with `use` and an absolute path to +shorten the path we have to specify to call an item within that module + +Adding `use` and a path in a scope is similar to creating a symbolic link in +the filesystem. By adding `use crate::sound::instrument` in the crate root, +`instrument` is now a valid name in that scope as if the `instrument` module +had been defined in the crate root. We can now reach items in the `instrument` +module through the older, full paths, or we can reach items through the new, +shorter path that we’ve created with `use`. Paths brought into scope with `use` +also check privacy, like any other paths. + +If you want to bring an item into scope with `use` and a relative path, there’s +a small difference from directly calling the item using a relative path: +instead of starting from a name in the current scope, you must start the path +given to `use` with `self`. Listing 7-14 shows how to specify a relative path +to get the same behavior as Listing 7-13 that used an absolute path. + +Filename: src/main.rs + +``` +mod sound { + pub mod instrument { + pub fn clarinet() { + // Function body code goes here + } + } +} + +use self::sound::instrument; + +fn main() { + instrument::clarinet(); + instrument::clarinet(); + instrument::clarinet(); +} +``` + +Listing 7-14: Bringing a module into scope with `use` and a relative path +starting with `self` + +Starting relative paths with `self` when specified after `use` might not be +neccesary in the future; it’s an inconsistency in the language that people are +working on eliminating. + +Choosing to specify absolute paths with `use` can make updates easier if the +code calling the items moves to a different place in the module tree but the +code defining the items does not, as opposed to when they moved together in the +changes we made in Listing 7-10. For example, if we decide to take the code +from Listing 7-13, extract the behavior in the `main` function to a function +called `clarinet_trio`, and move that function into a module named +`performance_group`, the path specified in `use` wouldn’t need to change, as +shown in Listing 7-15. + +Filename: src/main.rs + +``` +mod sound { + pub mod instrument { + pub fn clarinet() { + // Function body code goes here + } + } +} + +mod performance_group { + use crate::sound::instrument; + + pub fn clarinet_trio() { + instrument::clarinet(); + instrument::clarinet(); + instrument::clarinet(); + } +} + +fn main() { + performance_group::clarinet_trio(); +} +``` + +Listing 7-15: The absolute path doesn’t need to be updated when moving the code +that calls the item + +In contrast, if we made the same change to the code in Listing 7-14 that +specifies a relative path, we would need to change `use +self::sound::instrument` to `use super::sound::instrument`. Choosing whether +relative or absolute paths will result in fewer updates can be a guess if +you’re not sure how your module tree will change in the future, but your +authors tend to specify absolute paths starting with `crate` because code +defining and calling items is more likely to be moved around the module tree +independently of each other, rather than together as we saw in Listing 7-10. + +### Idiomatic `use` Paths for Functions vs. Other Items + +In Listing 7-13, you may have wondered why we specified `use +crate::sound::instrument` and then called `instrument::clarinet` in `main`, +rather than the code shown in Listing 7-16 that has the same behavior: + +Filename: src/main.rs + +``` +mod sound { + pub mod instrument { + pub fn clarinet() { + // Function body code goes here + } + } +} + +use crate::sound::instrument::clarinet; + +fn main() { + clarinet(); + clarinet(); + clarinet(); +} +``` + +Listing 7-16: Bringing the `clarinet` function into scoope with `use`, which is +unidiomatic + +For functions, it’s considered idiomatic to specify the function’s parent +module with `use`, and then specify the parent module when calling the +function. Doing so rather than specifying the path to the function with `use`, +as Listing 7-16 does, makes it clear that the function isn’t locally defined, +while still minimizing repetition of the full path. + +For structs, enums, and other items, specifying the full path to the item with +`use` is idiomatic. For example, Listing 7-17 shows the idiomatic way to bring +the standard library’s `HashMap` struct into scope. + +Filename: src/main.rs + +``` +use std::collections::HashMap; + +fn main() { + let mut map = HashMap::new(); + map.insert(1, 2); +} +``` + +Listing 7-17: Bringing `HashMap` into scope in an idiomatic way + +In contrast, the code in Listing 7-18 that brings the parent module of +`HashMap` into scope would not be considered idiomatic. There’s not a strong +reason for this idiom; this is the convention that has emerged and folks have +gotten used to reading and writing. + +Filename: src/main.rs + +``` +use std::collections; + +fn main() { + let mut map = collections::HashMap::new(); + map.insert(1, 2); +} +``` + +Listing 7-18: Bringing `HashMap` into scope in an unidiomatic way + +The exception to this idiom is if the `use` statements would bring two items +with the same name into scope, which isn’t allowed. Listing 7-19 shows how to +bring two `Result` types that have different parent modules into scope and +refer to them. + +Filename: src/lib.rs + +``` +use std::fmt; +use std::io; + +fn function1() -> fmt::Result { +} +fn function2() -> io::Result<()> { +} +``` + +Listing 7-19: Bringing two types with the same name into the same scope +requires using their parent modules + +If instead we specified `use std::fmt::Result` and `use std::io::Result`, we’d +have two `Result` types in the same scope and Rust wouldn’t know which one we +meant when we used `Result`. Try it and see what compiler error you get! + +### Renaming Types Brought Into Scope with the `as` Keyword + +There’s another solution to the problem of bringing two types of the same name +into the same scope: we can specify a new local name for the type by adding +`as` and a new name after the `use`. Listing 7-20 shows another way to write +the code from Listing 7-19 by renaming one of the two `Result` types using `as`. + +Filename: src/lib.rs + +``` +use std::fmt::Result; +use std::io::Result as IoResult; + +fn function1() -> Result { +} +fn function2() -> IoResult<()> { +} +``` + +Listing 7-20: Renaming a type when it’s brought into scope with the `as` keyword + +In the second `use` statement, we chose the new name `IoResult` for the +`std::io::Result` type, which won’t conflict with the `Result` from `std::fmt` +that we’ve also brought into scope. This is also considered idiomatic; choosing +between the code in Listing 7-19 and Listing 7-20 is up to you. + +### Re-exporting Names with `pub use` + +When you bring a name into scope with the `use` keyword, the name being +available in the new scope is private. If you want to enable code calling your +code to be able to refer to the type as if it was defined in that scope just as +your code does, you can combine `pub` and `use`. This technique is called +*re-exporting* because you’re bringing an item into scope but also making that +item available for others to bring into their scope. + +For example, Listing 7-21 shows the code from Listing 7-15 with the `use` +within the `performance_group` module changed to `pub use`. + +Filename: src/main.rs + +``` +mod sound { + pub mod instrument { + pub fn clarinet() { + // Function body code goes here + } + } +} + +mod performance_group { + pub use crate::sound::instrument; + + pub fn clarinet_trio() { + instrument::clarinet(); + instrument::clarinet(); + instrument::clarinet(); + } +} + +fn main() { + performance_group::clarinet_trio(); + performance_group::instrument::clarinet(); +} +``` + +Listing 7-21: Making a name available for any code to use from a new scope with +`pub use` + +By using `pub use`, the `main` function can now call the `clarinet` function +through this new path with `performance_group::instrument::clarinet`. If we +hadn’t specified `pub use`, the `clarinet_trio` function can call +`instrument::clarinet` in its scope but `main` wouldn’t be allowed to take +advantage of this new path. + +### Using External Packages + +In Chapter 2, we programmed a guessing game. That project used an external +package, `rand`, to get random numbers. To use `rand` in our project, we added +this line to *Cargo.toml*: + +Filename: Cargo.toml + +``` +[dependencies] +rand = "0.5.5" +``` + +Adding `rand` as a dependency in *Cargo.toml* tells Cargo to download the +`rand` package and its dependencies from *https://crates.io* and make its code +available to our project. + +Then, to bring `rand` definitions into the scope of our package, we added a +`use` line starting with the name of the package, `rand`, and listing the items +we wanted to bring into scope. Recall that in the “Generating a Random Number” +section in Chapter 2, we brought the `Rng` trait into scope and called the +`rand::thread_rng` function: + +``` +use rand::Rng; + +fn main() { + let secret_number = rand::thread_rng().gen_range(1, 101); +} +``` + +There are many packages that members of the community have published on +*https://crates.io*, and pulling any of them in to your package involves these +same steps: listing them in your package’s *Cargo.toml* and bringing items +defined in them into a scope in your package with `use`. + +Note that the standard library (`std`) is also a crate that’s external to your +package. Because the standard library is shipped with the Rust language, you +don’t need to change *Cargo.toml* to include `std`, but you refer to it in +`use` to bring items the standard library defines into your package’s scope, +such as with `HashMap`: + +``` +use std::collections::HashMap; +``` + +This is an absolute path starting with `std`, the name of the standard library +crate. + +### Nested Paths for Cleaning Up Large `use` Lists + +When you use many items defined by the same package or in the same module, +listing each item on its own line can take up a lot of vertical space in your +files. For example, these two `use` statements we had in Listing 2-4 in the +Guessing Game both bring items from `std` into scope: + +Filename: src/main.rs + +``` +use std::cmp::Ordering; +use std::io; +// ---snip--- +``` + +We can use nested paths to bring the same items into scope in one line instead +of two, by specifying the common part of the path, then two colons, then curly +brackets around a list of the parts of the paths that differ, as shown in +Listing 7-22. + +Filename: src/main.rs + +``` +use std::{cmp::Ordering, io}; +// ---snip--- +``` + +Listing 7-22: Specifying a nested path to bring multiple +items with the same prefix into scope in one line instead of two + +In programs bringing many items into scope from the same package or module, +using nested paths can reduce the number of separate `use` statements needed by +a lot! + +We can also deduplicate paths where one path is completely shared with part of +another path. For example, Listing 7-23 shows two `use` statements: one that +brings `std::io` into scope, and one that brings `std::io::Write` into scope: + +Filename: src/lib.rs + +``` +use std::io; +use std::io::Write; +``` + +Listing 7-23: Bringing two paths into scope in two `use` statements where one +is a sub-path of the other + +The common part between these two paths is `std::io`, and that’s the complete +first path. To deduplicate these two paths into one `use` statement, we can use +`self` in the nested path as shown in Listing 7-24. + +Filename: src/lib.rs + +``` +use std::io::{self, Write}; +``` + +Listing 7-24: Deduplicating the paths from Listing 7-23 into one `use` statement + +This brings both `std::io` and `std::io::Write` into scope. + +### Bringing All Public Definitions into Scope with the Glob Operator + +If you’d like to bring *all* public items defined in a path into scope, you can +use specify that path followed by `*`, the glob operator: + +``` +use std::collections::*; +``` + +This `use` statements brings all public items defined in `std::collections` +into the current scope. + +Be careful with using the glob operator! It makes it harder to tell what names +are in scope and where a name your program uses was defined. + +The glob operator is often used when testing to bring everything under test +into the `tests` module; we’ll talk about that in the “How to Write Tests” +section of Chapter 11. The glob operator is also sometimes used as part of the +prelude pattern; see the standard library +documentation at *../../std/prelude/index.html#other-preludes* for more +information on that pattern. + +### Separating Modules into Different Files + +All of the examples in this chapter so far defined multiple modules in one +file. When modules get large, you may want to move their definitions to a +separate file to make the code easier to navigate. + +For example, if we started from the code in Listing 7-8, we can move the +`sound` module to its own file *src/sound.rs* by changing the crate root file +(in this case, *src/main.rs*) to contain the code shown in Listing 7-25. + +Filename: src/main.rs + +``` +mod sound; + +fn main() { + // Absolute path + crate::sound::instrument::clarinet(); + + // Relative path + sound::instrument::clarinet(); +} +``` + +Listing 7-25: Declaring the `sound` module whose body will be in *src/sound.rs* + +And *src/sound.rs* gets the definitions from the body of the `sound` module, +shown in Listing 7-26. + +Filename: src/sound.rs + +``` +pub mod instrument { + pub fn clarinet() { + // Function body code goes here + } +} +``` + +Listing 7-26: Definitions inside the `sound` module in *src/sound.rs* + +Using a semicolon after `mod sound` instead of a block tells Rust to load the +contents of the module from another file with the same name as the module. + +To continue with our example and extract the `instrument` module to its own +file as well, we change *src/sound.rs* to contain only the declaration of the +`instrument` module: + +Filename: src/sound.rs + +``` +pub mod instrument; +``` + +Then we create a *src/sound* directory and a file *src/sound/instrument.rs* to +contain the definitions made in the `instrument` module: + +Filename: src/sound/instrument.rs + +``` +pub fn clarinet() { + // Function body code goes here +} +``` + +The module tree remains the same and the function calls in `main` continue to +work without any modification, even though the definitions live in different +files. This lets you move modules to new files as they grow in size. + +## Summary + +Rust provides ways to organize your packages into crates, your crates into +modules, and to refer to items defined in one module from another by specifying +absolute or relative paths. These paths can be brought into a scope with a +`use` statement so that you can use a shorter path for multiple uses of the +item in that scope. Modules define code that’s private by default, but you can +choose to make definitions public by adding the `pub` keyword. + +Next, we’ll look at some collection data structures in the standard library +that you can use in your nice, neat code. diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/nostarch/chapter19.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/nostarch/chapter19.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/nostarch/chapter19.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/nostarch/chapter19.md 2018-11-21 02:20:59.000000000 +0000 @@ -0,0 +1,595 @@ + + +This code will compile just fine. For more about trait objects, refer to the +“Using Trait Objects That Allow for Values of Different Types” section in +Chapter 17. + + + +Next, let’s look at macros! + +## Macros + + + +We’ve used macros like `println!` throughout this book, but we haven’t fully +explored what a macro is and how it works. *Macros* refers to a family of +features in Rust: + +* *Declarative* macros with `macro_rules!` +* *Procedural* macros, which come in three kinds: + * Custom `#[derive]` macros + * Attribute-like macros + * Function-like macros + +We’ll talk about each of these in turn, but first, why do we even need macros +when we already have functions? + +### The Difference Between Macros and Functions + + + +Fundamentally, macros are a way of writing code that writes other code, which +is known as *metaprogramming*. In Appendix C, we discuss the `derive` +attribute, which generates an implementation of various traits for you. We’ve +also used the `println!` and `vec!` macros throughout the book. All of these +macros *expand* to produce more code than the code you’ve written manually. + +Metaprogramming is useful for reducing the amount of code you have to write and +maintain, which is also one of the roles of functions. However, macros have +some additional powers that functions don’t have. + +A function signature must declare the number and type of parameters the +function has. Macros, on the other hand, can take a variable number of +parameters: we can call `println!("hello")` with one argument or +`println!("hello {}", name)` with two arguments. Also, macros are expanded +before the compiler interprets the meaning of the code, so a macro can, for +example, implement a trait on a given type. A function can’t, because it gets +called at runtime and a trait needs to be implemented at compile time. + +The downside to implementing a macro instead of a function is that macro +definitions are more complex than function definitions because you’re writing +Rust code that writes Rust code. Due to this indirection, macro definitions are +generally more difficult to read, understand, and maintain than function +definitions. + +There is one last important difference between macros and functions: you must +define or bring macros into scope *before* you call them in a file, whereas you +can define functions anywhere and call them anywhere. + +### Declarative Macros with `macro_rules!` for General Metaprogramming + + + +The most widely used form of macros in Rust are *declarative macros*. These are +also sometimes referred to as “macros by example”, “`macro_rules!` macros”, or +just plain “macros”. At their core, declarative macros allow you to write +something similar to a Rust `match` expression. As discussed in Chapter 6, +`match` expressions are control structures that take an expression, compare the +resulting value of the expression to patterns, and then run the code associated +with the matching pattern. Macros also compare a value to patterns that have +code associated with them; in this situation, the value is the literal Rust +source code passed to the macro, the patterns are compared with the structure +of that source code, and the code associated with each pattern is the code that +replaces the code passed to the macro. This all happens during compilation. + +To define a macro, you use the `macro_rules!` construct. Let’s explore how to +use `macro_rules!` by looking at how the `vec!` macro is defined. Chapter 8 +covered how we can use the `vec!` macro to create a new vector with particular +values. For example, the following macro creates a new vector with three +integers inside: + +``` +let v: Vec = vec![1, 2, 3]; +``` + +We could also use the `vec!` macro to make a vector of two integers or a vector +of five string slices. We wouldn’t be able to use a function to do the same +because we wouldn’t know the number or type of values up front. + +Let’s look at a slightly simplified definition of the `vec!` macro in Listing +19-36. + +Filename: src/lib.rs + +``` +#[macro_export] +macro_rules! vec { + ( $( $x:expr ),* ) => { + { + let mut temp_vec = Vec::new(); + $( + temp_vec.push($x); + )* + temp_vec + } + }; +} +``` + +Listing 19-36: A simplified version of the `vec!` macro definition + +> Note: The actual definition of the `vec!` macro in the standard library +> includes code to preallocate the correct amount of memory up front. That code +> is an optimization that we don’t include here to make the example simpler. + +The `#[macro_export]` annotation indicates that this macro should be made +available whenever the crate in which we’re defining the macro is brought into +scope. Without this annotation, the macro can’t be brought into scope. + +We then start the macro definition with `macro_rules!` and the name of the +macro we’re defining *without* the exclamation mark. The name, in this case +`vec`, is followed by curly brackets denoting the body of the macro definition. + +The structure in the `vec!` body is similar to the structure of a `match` +expression. Here we have one arm with the pattern `( $( $x:expr ),* )`, +followed by `=>` and the block of code associated with this pattern. If the +pattern matches, the associated block of code will be emitted. Given that this +is the only pattern in this macro, there is only one valid way to match; any +other will be an error. More complex macros will have more than one arm. + +Valid pattern syntax in macro definitions is different than the pattern syntax +covered in Chapter 18 because macro patterns are matched against Rust code +structure rather than values. Let’s walk through what the pieces of the pattern +in Listing D-1 mean; for the full macro pattern syntax, see the reference at +*https://doc.rust-lang.org/stable/reference/macros.html*. + +First, a set of parentheses encompasses the whole pattern. Next comes a dollar +sign (`$`) followed by a set of parentheses, which captures values that match +the pattern within the parentheses for use in the replacement code. Within +`$()` is `$x:expr`, which matches any Rust expression and gives the expression +the name `$x`. + +The comma following `$()` indicates that a literal comma separator character +could optionally appear after the code that matches the code captured in `$()`. +The `*` following the comma specifies that the pattern matches zero or more of +whatever precedes the `*`. + +When we call this macro with `vec![1, 2, 3];`, the `$x` pattern matches three +times with the three expressions `1`, `2`, and `3`. + +Now let’s look at the pattern in the body of the code associated with this arm: +the `temp_vec.push()` code within the `$()*` part is generated for each part +that matches `$()` in the pattern, zero or more times depending on how many +times the pattern matches. The `$x` is replaced with each expression matched. +When we call this macro with `vec![1, 2, 3];`, the code generated that replaces +this macro call will be the following: + +``` +let mut temp_vec = Vec::new(); +temp_vec.push(1); +temp_vec.push(2); +temp_vec.push(3); +temp_vec +``` + +We’ve defined a macro that can take any number of arguments of any type and can +generate code to create a vector containing the specified elements. + +There are some strange corners with `macro_rules!`. In the future, there +will be a second kind of declarative macro with the `macro` keyword that +will work in a similar fashion but fix some of these edge cases. After that +is done, `macro_rules!` will be effectively deprecated. With this +in mind, as well as the fact that most Rust programmers will *use* macros +more than *write* macros, we won’t discuss `macro_rules!` any further. To +learn more about how to write macros, consult the online documentation or +other resources, such as “The Little Book of Rust Macros” at +*https://danielkeep.github.io/tlborm/book/index.html*. + +### Procedural Macros for Generating Code from Attributes + + + +The second form of macros is called *procedural macros* because they’re more +like functions (which are a type of procedure). Procedural macros accept some +Rust code as an input, operate on that code, and produce some Rust code as an +output rather than matching against patterns and replacing the code with other +code as declarative macros do. + +There are three kinds of procedural macros, but they all work in a similar +fashion. First, the definitions must reside in their own crate with a special +crate type. This is for complex technical reasons that we hope to eliminate in +the future. + +Second, using any of these kinds of macros takes on a form like the code shown +in Listing 19-37, where `some_attribute` is a placeholder for using a specific +macro. + +Filename: src/lib.rs + +``` +use proc_macro; + +#[some_attribute] +pub fn some_name(input: TokenStream) -> TokenStream { +} +``` + +Listing 19-37: An example of using a procedural +macro + +Procedural macros consist of a function, which is how they get their name: +“procedure” is a synonym for “function.” Why not call them “functional macros”? +Well, one of the types is “function-like,” and that would get confusing. +Anyway, the function defining a procedural macro takes a `TokenStream` as an +input and produces a `TokenStream` as an output. This is the core of the macro: +the source code that the macro is operating on makes up the input +`TokenStream`, and the code the macro produces is the output `TokenStream`. +Finally, the function has an attribute on it; this attribute says which kind of +procedural macro we’re creating. We can have multiple kinds of procedural +macros in the same crate. + +Given that the kinds of macros are so similar, we’ll start with a custom derive +macro. Then we’ll explain the small differences that make the other forms +different. + +### How to Write a Custom `derive` Macro + + + +Let’s create a crate named `hello_macro` that defines a trait named +`HelloMacro` with one associated function named `hello_macro`. Rather than +making our crate users implement the `HelloMacro` trait for each of their +types, we’ll provide a procedural macro so users can annotate their type with +`#[derive(HelloMacro)]` to get a default implementation of the `hello_macro` +function. The default implementation will print `Hello, Macro! My name is +TypeName!` where `TypeName` is the name of the type on which this trait has +been defined. In other words, we’ll write a crate that enables another +programmer to write code like Listing 19-38 using our crate. + +Filename: src/main.rs + +``` +use hello_macro::HelloMacro; +use hello_macro_derive::HelloMacro; + +#[derive(HelloMacro)] +struct Pancakes; + +fn main() { + Pancakes::hello_macro(); +} +``` + +Listing 19-38: The code a user of our crate will be able to write when using +our procedural macro + +This code will print `Hello, Macro! My name is Pancakes!` when we’re done. The +first step is to make a new library crate, like this: + +``` +$ cargo new hello_macro --lib +``` + +Next, we’ll define the `HelloMacro` trait and its associated function: + +Filename: src/lib.rs + +``` +pub trait HelloMacro { + fn hello_macro(); +} +``` + +We have a trait and its function. At this point, our crate user could implement +the trait to achieve the desired functionality, like so: + +``` +use hello_macro::HelloMacro; + +struct Pancakes; + +impl HelloMacro for Pancakes { + fn hello_macro() { + println!("Hello, Macro! My name is Pancakes!"); + } +} + +fn main() { + Pancakes::hello_macro(); +} +``` + +However, they would need to write the implementation block for each type they +wanted to use with `hello_macro`; we want to spare them from having to do this +work. + +Additionally, we can’t yet provide a default implementation for the +`hello_macro` function that will print the name of the type the trait is +implemented on: Rust doesn’t have reflection capabilities, so it can’t look up +the type’s name at runtime. We need a macro to generate code at compile time. + +The next step is to define the procedural macro. At the time of this writing, +procedural macros need to be in their own crate. Eventually, this restriction +might be lifted. The convention for structuring crates and macro crates is as +follows: for a crate named `foo`, a custom derive procedural macro crate is +called `foo_derive`. Let’s start a new crate called `hello_macro_derive` inside +our `hello_macro` project: + +``` +$ cargo new hello_macro_derive --lib +``` + +Our two crates are tightly related, so we create the procedural macro crate +within the directory of our `hello_macro` crate. If we change the trait +definition in `hello_macro`, we’ll have to change the implementation of the +procedural macro in `hello_macro_derive` as well. The two crates will need to +be published separately, and programmers using these crates will need to add +both as dependencies and bring them both into scope. We could instead have the +`hello_macro` crate use `hello_macro_derive` as a dependency and reexport the +procedural macro code. But the way we’ve structured the project makes it +possible for programmers to use `hello_macro` even if they don’t want the +`derive` functionality. + +We need to declare the `hello_macro_derive` crate as a procedural macro crate. +We’ll also need functionality from the `syn` and `quote` crates, as you’ll see +in a moment, so we need to add them as dependencies. Add the following to the +*Cargo.toml* file for `hello_macro_derive`: + +Filename: hello_macro_derive/Cargo.toml + +``` +[lib] +proc-macro = true + +[dependencies] +syn = "0.14.4" +quote = "0.6.3" +``` + +To start defining the procedural macro, place the code in Listing 19-39 into +your *src/lib.rs* file for the `hello_macro_derive` crate. Note that this code +won’t compile until we add a definition for the `impl_hello_macro` function. + +Filename: hello_macro_derive/src/lib.rs + +``` +extern crate proc_macro; + +use crate::proc_macro::TokenStream; +use quote::quote; +use syn; + +#[proc_macro_derive(HelloMacro)] +pub fn hello_macro_derive(input: TokenStream) -> TokenStream { + // Construct a representation of Rust code as a syntax tree + // that we can manipulate + let ast = syn::parse(input).unwrap(); + + // Build the trait implementation + impl_hello_macro(&ast) +} +``` + +Listing 19-39: Code that most procedural macro crates will need to have for +processing Rust code + +Notice the way we’ve split the functions in Listing 19-39; this will be the +same for almost every procedural macro crate you see or create, because it +makes writing a procedural macro more convenient. What you choose to do in the +place where the `impl_hello_macro` function is called will be different +depending on your procedural macro’s purpose. + +We’ve introduced three new crates: `proc_macro`, `syn` (available from +*https://crates.io/crates/syn*), and `quote` (available from +*https://crates.io/crates/quote*). The `proc_macro` crate comes with Rust, so +we didn’t need to add that to the dependencies in *Cargo.toml*. The +`proc_macro` crate is the compiler’s API to be able to read and manipulate Rust +code from our code. The `syn` crate parses Rust code from a string into a data +structure that we can perform operations on. The `quote` crate takes `syn` data +structures and turns them back into Rust code. These crates make it much +simpler to parse any sort of Rust code we might want to handle: writing a full +parser for Rust code is no simple task. + +The `hello_macro_derive` function will get called when a user of our library +specifies `#[derive(HelloMacro)]` on a type. The reason is that we’ve annotated +the `hello_macro_derive` function here with `proc_macro_derive` and specified +the name, `HelloMacro`, which matches our trait name; that’s the convention +most procedural macros follow. + +This function first converts the `input` from a `TokenStream` to a data +structure that we can then interpret and perform operations on. This is where +`syn` comes into play. The `parse` function in `syn` takes a `TokenStream` and +returns a `DeriveInput` struct representing the parsed Rust code. Listing 19-40 +shows the relevant parts of the `DeriveInput` struct we get from parsing the +string `struct Pancakes;`: + +``` +DeriveInput { + // --snip-- + + ident: Ident { + ident: "Pancakes", + span: #0 bytes(95..103) + }, + data: Struct( + DataStruct { + struct_token: Struct, + fields: Unit, + semi_token: Some( + Semi + ) + } + ) +} +``` + +Listing 19-40: The `DeriveInput` instance we get when parsing the code that has +the macro’s attribute in Listing 19-38 + +The fields of this struct show that the Rust code we’ve parsed is a unit struct +with the `ident` (identifier, meaning the name) of `Pancakes`. There are more +fields on this struct for describing all sorts of Rust code; check the `syn` +documentation for `DeriveInput` at +*https://docs.rs/syn/0.14.4/syn/struct.DeriveInput.html* for more information. + +At this point, we haven’t defined the `impl_hello_macro` function, which is +where we’ll build the new Rust code we want to include. But before we do, note +that its output is also a `TokenStream`. The returned `TokenStream` is added to +the code that our crate users write, so when they compile their crate, they’ll +get extra functionality that we provide. + +You might have noticed that we’re calling `unwrap` to panic if the call to the +`syn::parse` function fails here. Panicking on errors is necessary in +procedural macro code because `proc_macro_derive` functions must return +`TokenStream` rather than `Result` to conform to the procedural macro API. +We’ve chosen to simplify this example by using `unwrap`; in production code, +you should provide more specific error messages about what went wrong by using +`panic!` or `expect`. + +Now that we have the code to turn the annotated Rust code from a `TokenStream` +into a `DeriveInput` instance, let’s generate the code that implements the +`HelloMacro` trait on the annotated type as shown in Listing 19-41. + +Filename: hello_macro_derive/src/lib.rs + +``` +fn impl_hello_macro(ast: &syn::DeriveInput) -> TokenStream { + let name = &ast.ident; + let gen = quote! { + impl HelloMacro for #name { + fn hello_macro() { + println!("Hello, Macro! My name is {}", stringify!(#name)); + } + } + }; + gen.into() +} +``` + +Listing 19-41: Implementing the `HelloMacro` trait using the parsed Rust code + +We get an `Ident` struct instance containing the name (identifier) of the +annotated type using `ast.ident`. The struct in Listing 19-40 shows that the +`ident` we get when the `impl_hello_macro` function is run on the code in +Listing 19-38 will have the `ident` field with a value of `"Pancakes"`. Thus, +the `name` variable in Listing 19-41 will contain an `Ident` struct instance +that, when printed, will be the string `"Pancakes"`, the name of the struct in +Listing 19-38. + +The `quote!` macro lets us write the Rust code that we want to return. The +direct result of the `quote!` macro’s execution isn’t what’s expected by the +compiler and needs to be converted to a `TokenStream`. We do this by calling +the `into` method, which consumes this intermediate representation and returns +a value of the required `TokenStream` type. + +The `quote!` macro also provides some very cool templating mechanics; we can +write `#name`, and `quote!` will replace it with the value in the variable +named `name`. You can even do some repetition similar to the way regular macros +work. Check out the `quote` crate’s docs at *https://docs.rs/quote* for a +thorough introduction. + +We want our procedural macro to generate an implementation of our `HelloMacro` +trait for the type the user annotated, which we can get by using `#name`. The +trait implementation has one function, `hello_macro`, whose body contains the +functionality we want to provide: printing `Hello, Macro! My name is` and then +the name of the annotated type. + +The `stringify!` macro used here is built into Rust. It takes a Rust +expression, such as `1 + 2`, and at compile time turns the expression into a +string literal, such as `"1 + 2"`. This is different than `format!` or +`println!`, which evaluate the expression and then turn the result into a +`String`. There is a possibility that the `#name` input might be an expression +to print literally, so we use `stringify!`. Using `stringify!` also saves an +allocation by converting `#name` to a string literal at compile time. + +At this point, `cargo build` should complete successfully in both `hello_macro` +and `hello_macro_derive`. Let’s hook up these crates to the code in Listing +19-38 to see the procedural macro in action! Create a new binary project in +your *projects* directory using `cargo new pancakes`. We need to add +`hello_macro` and `hello_macro_derive` as dependencies in the `pancakes` +crate’s *Cargo.toml*. If you’re publishing your versions of `hello_macro` and +`hello_macro_derive` to *https://crates.io/*, they would be regular +dependencies; if not, you can specify them as `path` dependencies as follows: + +``` +[dependencies] +hello_macro = { path = "../hello_macro" } +hello_macro_derive = { path = "../hello_macro/hello_macro_derive" } +``` + +Put the code from Listing 19-38 into *src/main.rs*, and run `cargo run`: it +should print `Hello, Macro! My name is Pancakes!` The implementation of the +`HelloMacro` trait from the procedural macro was included without the +`pancakes` crate needing to implement it; the `#[derive(HelloMacro)]` added the +trait implementation. + +Next, let’s explore how the other kinds of procedural macros differ from custom +derive macros. + +### Attribute-like macros + + + +Attribute-like macros are similar to custom derive macros, but instead of +generating code for the `derive` attribute, they allow you to create new +attributes. They’re also more flexible; `derive` only works for structs and +enums; attributes can go on other items as well, like functions. As an example +of using an attribute-like macro, you might have an attribute named `route` +that annotates functions when using a web application framework: + +``` +#[route(GET, "/")] +fn index() { +``` + +This `#[route]` attribute would be defined by the framework itself as a +procedural macro. The macro definition function’s signature would look like +this: + +``` +#[proc_macro_attribute] +pub fn route(attr: TokenStream, item: TokenStream) -> TokenStream { +``` + +Here, we have two parameters of type `TokenStream`; the first is for the +contents of the attribute itself, that is, the `GET, "/"` part. The second is +the body of the item the attribute is attached to, in this case, `fn index() +{}` and the rest of the function’s body. + +Other than that, attribute-like macros work the same way as custom derive +macros: create a crate with the `proc-macro` crate type and implement a +function that generates the code you want! + +### Function-like macros + + + +Finally, function-like macros define macros that look like function calls. For +example, an `sql!` macro that might be called like so: + +``` +let sql = sql!(SELECT * FROM posts WHERE id=1); +``` + +This macro would parse the SQL statement inside of it and check that it’s +syntactically correct. This macro would be defined like this: + +``` +#[proc_macro] +pub fn sql(input: TokenStream) -> TokenStream { +``` + +This is similar to the custom derive macro’s signature: we get in the tokens +that are inside of the parentheses, and return the code we wanted to generate. + +## Summary + + + +Whew! Now you have some features of Rust in your toolbox that you won’t use +often, but you’ll know they’re available in very particular circumstances. +We’ve introduced several complex topics so that when you encounter them in +error message suggestions or in other peoples’ code, you’ll be able to +recognize these concepts and syntax. Use this chapter as a reference to guide +you to solutions. + +Next, we’ll put everything we’ve discussed throughout the book into practice +and do one more project! diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/nostarch.sh rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/nostarch.sh --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/nostarch.sh 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/nostarch.sh 2018-11-21 02:20:59.000000000 +0000 @@ -0,0 +1,33 @@ +#!/bin/bash +# Copyright 2016 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +set -eu + +cargo build --release + +mkdir -p tmp +rm -rf tmp/*.md + +# Get all the markdown files in the src dir, +ls src/${1:-""}*.md | \ +# except for SUMMARY.md. +grep -v SUMMARY.md | \ +# Extract just the filename so we can reuse it easily. +xargs -n 1 basename | \ +# Remove all links followed by , then +# Change all remaining links from markdown to italicized inline text. +while IFS= read -r filename; do + < "src/$filename" ./target/release/remove_links \ + | ./target/release/link2print \ + | ./target/release/remove_markup > "tmp/$filename" +done +# Concat the files into the nostarch dir. +./target/release/concat_chapters tmp nostarch diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-00.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-00.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-00.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-00.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,4 +1,10 @@ # Appendix -The following sections contain reference material you may find useful in your -Rust journey. +The 2018 edition of the book is no longer distributed with Rust's documentation. + +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. + +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/appendix-00.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-01-keywords.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-01-keywords.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-01-keywords.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-01-keywords.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,119 +1,10 @@ ## Appendix A: Keywords -The following list contains keywords that are reserved for current or future -use by the Rust language. As such, they cannot be used as identifiers (except as -[raw identifiers][raw-identifiers]), including names of functions, variables, -parameters, struct fields, modules, crates, constants, macros, static values, -attributes, types, traits, or lifetimes. +The 2018 edition of the book is no longer distributed with Rust's documentation. -### Keywords Currently in Use +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -The following keywords currently have the functionality described. - -* `as` - perform primitive casting, disambiguate the specific trait containing - an item, or rename items in `use` and `extern crate` statements -* `break` - exit a loop immediately -* `const` - define constant items or constant raw pointers -* `continue` - continue to the next loop iteration -* `crate` - link an external crate or a macro variable representing the crate in - which the macro is defined -* `else` - fallback for `if` and `if let` control flow constructs -* `enum` - define an enumeration -* `extern` - link an external crate, function, or variable -* `false` - Boolean false literal -* `fn` - define a function or the function pointer type -* `for` - loop over items from an iterator, implement a trait, or specify a - higher-ranked lifetime -* `if` - branch based on the result of a conditional expression -* `impl` - implement inherent or trait functionality -* `in` - part of `for` loop syntax -* `let` - bind a variable -* `loop` - loop unconditionally -* `match` - match a value to patterns -* `mod` - define a module -* `move` - make a closure take ownership of all its captures -* `mut` - denote mutability in references, raw pointers, or pattern bindings -* `pub` - denote public visibility in struct fields, `impl` blocks, or modules -* `ref` - bind by reference -* `return` - return from function -* `Self` - a type alias for the type implementing a trait -* `self` - method subject or current module -* `static` - global variable or lifetime lasting the entire program execution -* `struct` - define a structure -* `super` - parent module of the current module -* `trait` - define a trait -* `true` - Boolean true literal -* `type` - define a type alias or associated type -* `unsafe` - denote unsafe code, functions, traits, or implementations -* `use` - import symbols into scope -* `where` - denote clauses that constrain a type -* `while` - loop conditionally based on the result of an expression - -### Keywords Reserved for Future Use - -The following keywords do not have any functionality but are reserved by Rust -for potential future use. - -* `abstract` -* `alignof` -* `become` -* `box` -* `do` -* `final` -* `macro` -* `offsetof` -* `override` -* `priv` -* `proc` -* `pure` -* `sizeof` -* `typeof` -* `unsized` -* `virtual` -* `yield` - -### Raw identifiers -[raw-identifiers]: #raw-identifiers - -Raw identifiers let you use keywords where they would not normally be allowed by -prefixing them with `r#`. - -For example, `match` is a keyword. If you try to compile this function: - -```rust,ignore -fn match(needle: &str, haystack: &str) -> bool { - haystack.contains(needle) -} -``` - -You'll get this error: - -```text -error: expected identifier, found keyword `match` - --> src/main.rs:4:4 - | -4 | fn match(needle: &str, haystack: &str) -> bool { - | ^^^^^ expected identifier, found keyword -``` - -You can write this with a raw identifier: - -```rust -fn r#match(needle: &str, haystack: &str) -> bool { - haystack.contains(needle) -} - -fn main() { - assert!(r#match("foo", "foobar")); -} -``` - -Note the `r#` prefix on both the function name as well as the call. - -#### Motivation - -This feature is useful for a few reasons, but the primary motivation was -inter-edition situations. For example, `try` is not a keyword in the 2015 -edition, but is in the 2018 edition. So if you have a library that is written -in Rust 2015 and has a `try` function, to call it in Rust 2018, you'll need -to use the raw identifier. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/appendix-01-keywords.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-02-operators.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-02-operators.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-02-operators.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-02-operators.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,205 +1,10 @@ ## Appendix B: Operators and Symbols -This appendix contains a glossary of Rust’s syntax, including operators and -other symbols that appear by themselves or in the context of paths, generics, -trait bounds, macros, attributes, comments, tuples, and brackets. +The 2018 edition of the book is no longer distributed with Rust's documentation. -### Operators +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -Table B-1 contains the operators in Rust, an example of how the operator would -appear in context, a short explanation, and whether that operator is -overloadable. If an operator is overloadable, the relevant trait to use to -overload that operator is listed. - -Table B-1: Operators - -| Operator | Example | Explanation | Overloadable? | -|----------|---------|-------------|---------------| -| `!` | `ident!(...)`, `ident!{...}`, `ident![...]` | Macro expansion | | -| `!` | `!expr` | Bitwise or logical complement | `Not` | -| `!=` | `var != expr` | Nonequality comparison | `PartialEq` | -| `%` | `expr % expr` | Arithmetic remainder | `Rem` | -| `%=` | `var %= expr` | Arithmetic remainder and assignment | `RemAssign` | -| `&` | `&expr`, `&mut expr` | Borrow | | -| `&` | `&type`, `&mut type`, `&'a type`, `&'a mut type` | Borrowed pointer type | | -| `&` | `expr & expr` | Bitwise AND | `BitAnd` | -| `&=` | `var &= expr` | Bitwise AND and assignment | `BitAndAssign` | -| `&&` | `expr && expr` | Logical AND | | -| `*` | `expr * expr` | Arithmetic multiplication | `Mul` | -| `*=` | `var *= expr` | Arithmetic multiplication and assignment | `MulAssign` | -| `*` | `*expr` | Dereference | | -| `*` | `*const type`, `*mut type` | Raw pointer | | -| `+` | `trait + trait`, `'a + trait` | Compound type constraint | | -| `+` | `expr + expr` | Arithmetic addition | `Add` | -| `+=` | `var += expr` | Arithmetic addition and assignment | `AddAssign` | -| `,` | `expr, expr` | Argument and element separator | | -| `-` | `- expr` | Arithmetic negation | `Neg` | -| `-` | `expr - expr` | Arithmetic subtraction | `Sub` | -| `-=` | `var -= expr` | Arithmetic subtraction and assignment | `SubAssign` | -| `->` | `fn(...) -> type`, \|...\| -> type | Function and closure return type | | -| `.` | `expr.ident` | Member access | | -| `..` | `..`, `expr..`, `..expr`, `expr..expr` | Right-exclusive range literal | | -| `..=` | `..=expr`, `expr..=expr` | Right-inclusive range literal | | -| `..` | `..expr` | Struct literal update syntax | | -| `..` | `variant(x, ..)`, `struct_type { x, .. }` | “And the rest” pattern binding | | -| `...` | `expr...expr` | In a pattern: inclusive range pattern | | -| `/` | `expr / expr` | Arithmetic division | `Div` | -| `/=` | `var /= expr` | Arithmetic division and assignment | `DivAssign` | -| `:` | `pat: type`, `ident: type` | Constraints | | -| `:` | `ident: expr` | Struct field initializer | | -| `:` | `'a: loop {...}` | Loop label | | -| `;` | `expr;` | Statement and item terminator | | -| `;` | `[...; len]` | Part of fixed-size array syntax | | -| `<<` | `expr << expr` | Left-shift | `Shl` | -| `<<=` | `var <<= expr` | Left-shift and assignment | `ShlAssign` | -| `<` | `expr < expr` | Less than comparison | `PartialOrd` | -| `<=` | `expr <= expr` | Less than or equal to comparison | `PartialOrd` | -| `=` | `var = expr`, `ident = type` | Assignment/equivalence | | -| `==` | `expr == expr` | Equality comparison | `PartialEq` | -| `=>` | `pat => expr` | Part of match arm syntax | | -| `>` | `expr > expr` | Greater than comparison | `PartialOrd` | -| `>=` | `expr >= expr` | Greater than or equal to comparison | `PartialOrd` | -| `>>` | `expr >> expr` | Right-shift | `Shr` | -| `>>=` | `var >>= expr` | Right-shift and assignment | `ShrAssign` | -| `@` | `ident @ pat` | Pattern binding | | -| `^` | `expr ^ expr` | Bitwise exclusive OR | `BitXor` | -| `^=` | `var ^= expr` | Bitwise exclusive OR and assignment | `BitXorAssign` | -| \| | pat \| pat | Pattern alternatives | | -| \| | expr \| expr | Bitwise OR | `BitOr` | -| \|= | var \|= expr | Bitwise OR and assignment | `BitOrAssign` | -| \|\| | expr \|\| expr | Logical OR | | -| `?` | `expr?` | Error propagation | | - -### Non-operator Symbols - -The following list contains all non-letters that don’t function as operators; -that is, they don’t behave like a function or method call. - -Table B-2 shows symbols that appear on their own and are valid in a variety of -locations. - -Table B-2: Stand-Alone Syntax - -| Symbol | Explanation | -|--------|-------------| -| `'ident` | Named lifetime or loop label | -| `...u8`, `...i32`, `...f64`, `...usize`, etc. | Numeric literal of specific type | -| `"..."` | String literal | -| `r"..."`, `r#"..."#`, `r##"..."##`, etc. | Raw string literal, escape characters not processed | -| `b"..."` | Byte string literal; constructs a `[u8]` instead of a string | -| `br"..."`, `br#"..."#`, `br##"..."##`, etc. | Raw byte string literal, combination of raw and byte string literal | -| `'...'` | Character literal | -| `b'...'` | ASCII byte literal | -| \|...\| expr | Closure | -| `!` | Always empty bottom type for diverging functions | -| `_` | “Ignored” pattern binding; also used to make integer literals readable | - -Table B-3 shows symbols that appear in the context of a path through the module -hierarchy to an item. - -Table B-3: Path-Related Syntax - -| Symbol | Explanation | -|--------|-------------| -| `ident::ident` | Namespace path | -| `::path` | Path relative to the crate root (i.e., an explicitly absolute path) | -| `self::path` | Path relative to the current module (i.e., an explicitly relative path). -| `super::path` | Path relative to the parent of the current module | -| `type::ident`, `::ident` | Associated constants, functions, and types | -| `::...` | Associated item for a type that cannot be directly named (e.g., `<&T>::...`, `<[T]>::...`, etc.) | -| `trait::method(...)` | Disambiguating a method call by naming the trait that defines it | -| `type::method(...)` | Disambiguating a method call by naming the type for which it’s defined | -| `::method(...)` | Disambiguating a method call by naming the trait and type | - -Table B-4 shows symbols that appear in the context of using generic type -parameters. - -Table B-4: Generics - -| Symbol | Explanation | -|--------|-------------| -| `path<...>` | Specifies parameters to generic type in a type (e.g., `Vec`) | -| `path::<...>`, `method::<...>` | Specifies parameters to generic type, function, or method in an expression; often referred to as turbofish (e.g., `"42".parse::()`) | -| `fn ident<...> ...` | Define generic function | -| `struct ident<...> ...` | Define generic structure | -| `enum ident<...> ...` | Define generic enumeration | -| `impl<...> ...` | Define generic implementation | -| `for<...> type` | Higher-ranked lifetime bounds | -| `type` | A generic type where one or more associated types have specific assignments (e.g., `Iterator`) | - -Table B-5 shows symbols that appear in the context of constraining generic type -parameters with trait bounds. - -Table B-5: Trait Bound Constraints - -| Symbol | Explanation | -|--------|-------------| -| `T: U` | Generic parameter `T` constrained to types that implement `U` | -| `T: 'a` | Generic type `T` must outlive lifetime `'a` (meaning the type cannot transitively contain any references with lifetimes shorter than `'a`) | -| `T : 'static` | Generic type `T` contains no borrowed references other than `'static` ones | -| `'b: 'a` | Generic lifetime `'b` must outlive lifetime `'a` | -| `T: ?Sized` | Allow generic type parameter to be a dynamically sized type | -| `'a + trait`, `trait + trait` | Compound type constraint | - -Table B-6 shows symbols that appear in the context of calling or defining -macros and specifying attributes on an item. - -Table B-6: Macros and Attributes - -| Symbol | Explanation | -|--------|-------------| -| `#[meta]` | Outer attribute | -| `#![meta]` | Inner attribute | -| `$ident` | Macro substitution | -| `$ident:kind` | Macro capture | -| `$(…)…` | Macro repetition | - -Table B-7 shows symbols that create comments. - -Table B-7: Comments - -| Symbol | Explanation | -|--------|-------------| -| `//` | Line comment | -| `//!` | Inner line doc comment | -| `///` | Outer line doc comment | -| `/*...*/` | Block comment | -| `/*!...*/` | Inner block doc comment | -| `/**...*/` | Outer block doc comment | - -Table B-8 shows symbols that appear in the context of using tuples. - -Table B-8: Tuples - -| Symbol | Explanation | -|--------|-------------| -| `()` | Empty tuple (aka unit), both literal and type | -| `(expr)` | Parenthesized expression | -| `(expr,)` | Single-element tuple expression | -| `(type,)` | Single-element tuple type | -| `(expr, ...)` | Tuple expression | -| `(type, ...)` | Tuple type | -| `expr(expr, ...)` | Function call expression; also used to initialize tuple `struct`s and tuple `enum` variants | -| `ident!(...)`, `ident!{...}`, `ident![...]` | Macro invocation | -| `expr.0`, `expr.1`, etc. | Tuple indexing | - -Table B-9 shows the contexts in which curly braces are used. - -Table B-9: Curly Brackets - -| Context | Explanation | -|---------|-------------| -| `{...}` | Block expression | -| `Type {...}` | `struct` literal | - -Table B-10 shows the contexts in which square brackets are used. - -Table B-10: Square Brackets - -| Context | Explanation | -|---------|-------------| -| `[...]` | Array literal | -| `[expr; len]` | Array literal containing `len` copies of `expr` | -| `[type; len]` | Array type containing `len` instances of `type` | -| `expr[expr]` | Collection indexing. Overloadable (`Index`, `IndexMut`) | -| `expr[..]`, `expr[a..]`, `expr[..b]`, `expr[a..b]` | Collection indexing pretending to be collection slicing, using `Range`, `RangeFrom`, `RangeTo`, or `RangeFull` as the “index” | +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/appendix-02-operators.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-03-derivable-traits.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-03-derivable-traits.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-03-derivable-traits.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-03-derivable-traits.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,174 +1,10 @@ ## Appendix C: Derivable Traits -In various places in the book, we’ve discussed the `derive` attribute, which -you can apply to a struct or enum definition. The `derive` attribute generates -code that will implement a trait with its own default implementation on the -type you’ve annotated with the `derive` syntax. +The 2018 edition of the book is no longer distributed with Rust's documentation. -In this appendix, we provide a reference of all the traits in the standard -library that you can use with `derive`. Each section covers: +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -* What operators and methods deriving this trait will enable -* What the implementation of the trait provided by `derive` does -* What implementing the trait signifies about the type -* The conditions in which you’re allowed or not allowed to implement the trait -* Examples of operations that require the trait - -If you want different behavior than that provided by the `derive` attribute, -consult the [standard library documentation](../../std/index.html) -for each trait for details of how to manually implement them. - -The rest of the traits defined in the standard library can’t be implemented on -your types using `derive`. These traits don’t have sensible default behavior, -so it’s up to you to implement them in the way that makes sense for what you’re -trying to accomplish. - -An example of a trait that can’t be derived is `Display`, which handles -formatting for end users. You should always consider the appropriate way to -display a type to an end user. What parts of the type should an end user be -allowed to see? What parts would they find relevant? What format of the data -would be most relevant to them? The Rust compiler doesn’t have this insight, so -it can’t provide appropriate default behavior for you. - -The list of derivable traits provided in this appendix is not comprehensive: -libraries can implement `derive` for their own traits, making the list of -traits you can use `derive` with truly open-ended. Implementing `derive` -involves using a procedural macro, which is covered in Appendix D. - -### `Debug` for Programmer Output - -The `Debug` trait enables debug formatting in format strings, which you -indicate by adding `:?` within `{}` placeholders. - -The `Debug` trait allows you to print instances of a type for debugging -purposes, so you and other programmers using your type can inspect an instance -at a particular point in a program’s execution. - -The `Debug` trait is required, for example, in use of the `assert_eq!` macro. -This macro prints the values of instances given as arguments if the equality -assertion fails so programmers can see why the two instances weren’t equal. - -### `PartialEq` and `Eq` for Equality Comparisons - -The `PartialEq` trait allows you to compare instances of a type to check for -equality and enables use of the `==` and `!=` operators. - -Deriving `PartialEq` implements the `eq` method. When `PartialEq` is derived on -structs, two instances are equal only if *all* fields are equal, and the -instances are not equal if any fields are not equal. When derived on enums, -each variant is equal to itself and not equal to the other variants. - -The `PartialEq` trait is required, for example, with the use of the -`assert_eq!` macro, which needs to be able to compare two instances of a type -for equality. - -The `Eq` trait has no methods. Its purpose is to signal that for every value of -the annotated type, the value is equal to itself. The `Eq` trait can only be -applied to types that also implement `PartialEq`, although not all types that -implement `PartialEq` can implement `Eq`. One example of this is floating point -number types: the implementation of floating point numbers states that two -instances of the not-a-number (`NaN`) value are not equal to each other. - -An example of when `Eq` is required is for keys in a `HashMap` so the -`HashMap` can tell whether two keys are the same. - -### `PartialOrd` and `Ord` for Ordering Comparisons - -The `PartialOrd` trait allows you to compare instances of a type for sorting -purposes. A type that implements `PartialOrd` can be used with the `<`, `>`, -`<=`, and `>=` operators. You can only apply the `PartialOrd` trait to types -that also implement `PartialEq`. - -Deriving `PartialOrd` implements the `partial_cmp` method, which returns an -`Option` that will be `None` when the values given don’t produce an -ordering. An example of a value that doesn’t produce an ordering, even though -most values of that type can be compared, is the not-a-number (`NaN`) floating -point value. Calling `partial_cmp` with any floating point number and the `NaN` -floating point value will return `None`. - -When derived on structs, `PartialOrd` compares two instances by comparing the -value in each field in the order in which the fields appear in the struct -definition. When derived on enums, variants of the enum declared earlier in the -enum definition are considered less than the variants listed later. - -The `PartialOrd` trait is required, for example, for the `gen_range` method -from the `rand` crate that generates a random value in the range specified by a -low value and a high value. - -The `Ord` trait allows you to know that for any two values of the annotated -type, a valid ordering will exist. The `Ord` trait implements the `cmp` method, -which returns an `Ordering` rather than an `Option` because a valid -ordering will always be possible. You can only apply the `Ord` trait to types -that also implement `PartialOrd` and `Eq` (and `Eq` requires `PartialEq`). When -derived on structs and enums, `cmp` behaves the same way as the derived -implementation for `partial_cmp` does with `PartialOrd`. - -An example of when `Ord` is required is when storing values in a `BTreeSet`, -a data structure that stores data based on the sort order of the values. - -### `Clone` and `Copy` for Duplicating Values - -The `Clone` trait allows you to explicitly create a deep copy of a value, and -the duplication process might involve running arbitrary code and copying heap -data. See the “Ways Variables and Data Interact: Clone” section in Chapter 4 -for more information on `Clone`. - -Deriving `Clone` implements the `clone` method, which when implemented for the -whole type, calls `clone` on each of the parts of the type. This means all the -fields or values in the type must also implement `Clone` to derive `Clone`. - -An example of when `Clone` is required is when calling the `to_vec` method on a -slice. The slice doesn’t own the type instances it contains, but the vector -returned from `to_vec` will need to own its instances, so `to_vec` calls -`clone` on each item. Thus, the type stored in the slice must implement `Clone`. - -The `Copy` trait allows you to duplicate a value by only copying bits stored on -the stack; no arbitrary code is necessary. See the “Stack-Only Data: Copy” -section in Chapter 4 for more information on `Copy`. - -The `Copy` trait doesn’t define any methods to prevent programmers from -overloading those methods and violating the assumption that no arbitrary code -is being run. That way, all programmers can assume that copying a value will be -very fast. - -You can derive `Copy` on any type whose parts all implement `Copy`. You can -only apply the `Copy` trait to types that also implement `Clone`, because a -type that implements `Copy` has a trivial implementation of `Clone` that -performs the same task as `Copy`. - -The `Copy` trait is rarely required; types that implement `Copy` have -optimizations available, meaning you don’t have to call `clone`, which makes -the code more concise. - -Everything possible with `Copy` you can also accomplish with `Clone`, but the -code might be slower or have to use `clone` in places. - -### `Hash` for Mapping a Value to a Value of Fixed Size - -The `Hash` trait allows you to take an instance of a type of arbitrary size and -map that instance to a value of fixed size using a hash function. Deriving -`Hash` implements the `hash` method. The derived implementation of the `hash` -method combines the result of calling `hash` on each of the parts of the type, -meaning all fields or values must also implement `Hash` to derive `Hash`. - -An example of when `Hash` is required is in storing keys in a `HashMap` -to store data efficiently. - -### `Default` for Default Values - -The `Default` trait allows you to create a default value for a type. Deriving -`Default` implements the `default` function. The derived implementation of the -`default` function calls the `default` function on each part of the type, -meaning all fields or values in the type must also implement `Default` to -derive `Default`. - -The `Default::default` function is commonly used in combination with the struct -update syntax discussed in the “Creating Instances From Other Instances With -Struct Update Syntax” section in Chapter 5. You can customize a few fields of a -struct and then set and use a default value for the rest of the fields by using -`..Default::default()`. - -The `Default` trait is required when you use the method `unwrap_or_default` on -`Option` instances, for example. If the `Option` is `None`, the method -`unwrap_or_default` will return the result of `Default::default` for the type -`T` stored in the `Option`. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/appendix-03-derivable-traits.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-04-macros.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-04-macros.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-04-macros.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-04-macros.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,478 +0,0 @@ -## Appendix D: Macros - -We’ve used macros like `println!` throughout this book but haven’t fully -explored what a macro is and how it works. This appendix explains macros as -follows: - -* What macros are and how they differ from functions -* How to define a declarative macro to do metaprogramming -* How to define a procedural macro to create custom `derive` traits - -We’re covering the details of macros in an appendix because they’re still -evolving in Rust. Macros have changed and, in the near future, will change at a -quicker rate than the rest of the language and standard library since Rust 1.0, -so this section is more likely to become out-of-date than the rest of the book. -Due to Rust’s stability guarantees, the code shown here will continue to work -with future versions, but there may be additional capabilities or easier ways -to write macros that weren’t available at the time of this publication. Bear -that in mind when you try to implement anything from this appendix. - -### The Difference Between Macros and Functions - -Fundamentally, macros are a way of writing code that writes other code, which -is known as *metaprogramming*. In Appendix C, we discussed the `derive` -attribute, which generates an implementation of various traits for you. We’ve -also used the `println!` and `vec!` macros throughout the book. All of these -macros *expand* to produce more code than the code you’ve written manually. - -Metaprogramming is useful for reducing the amount of code you have to write and -maintain, which is also one of the roles of functions. However, macros have -some additional powers that functions don’t have. - -A function signature must declare the number and type of parameters the -function has. Macros, on the other hand, can take a variable number of -parameters: we can call `println!("hello")` with one argument or -`println!("hello {}", name)` with two arguments. Also, macros are expanded -before the compiler interprets the meaning of the code, so a macro can, for -example, implement a trait on a given type. A function can’t, because it gets -called at runtime and a trait needs to be implemented at compile time. - -The downside to implementing a macro instead of a function is that macro -definitions are more complex than function definitions because you’re writing -Rust code that writes Rust code. Due to this indirection, macro definitions are -generally more difficult to read, understand, and maintain than function -definitions. - -Another difference between macros and functions is that macro definitions -aren’t namespaced within modules like function definitions are. To prevent -unexpected name clashes when using external crates, you have to explicitly -bring the macros into the scope of your project at the same time as you bring -the external crate into scope, using the `#[macro_use]` annotation. The -following example would bring all the macros defined in the `serde` crate into -the scope of the current crate: - -```rust,ignore -#[macro_use] -extern crate serde; -``` - -If `extern crate` was able to bring macros into scope by default without this -explicit annotation, you would be prevented from using two crates that happened -to define macros with the same name. In practice, this conflict doesn’t occur -often, but the more crates you use, the more likely it is. - -There is one last important difference between macros and functions: you must -define or bring macros into scope *before* you call them in a file, whereas you -can define functions anywhere and call them anywhere. - -### Declarative Macros with `macro_rules!` for General Metaprogramming - -The most widely used form of macros in Rust are *declarative macros*. These are -also sometimes referred to as *macros by example*, *`macro_rules!` macros*, or -just plain *macros*. At their core, declarative macros allow you to write -something similar to a Rust `match` expression. As discussed in Chapter 6, -`match` expressions are control structures that take an expression, compare the -resulting value of the expression to patterns, and then run the code associated -with the matching pattern. Macros also compare a value to patterns that have -code associated with them; in this situation, the value is the literal Rust -source code passed to the macro, the patterns are compared with the structure -of that source code, and the code associated with each pattern is the code that -replaces the code passed to the macro. This all happens during compilation. - -To define a macro, you use the `macro_rules!` construct. Let’s explore how to -use `macro_rules!` by looking at how the `vec!` macro is defined. Chapter 8 -covered how we can use the `vec!` macro to create a new vector with particular -values. For example, the following macro creates a new vector with three -integers inside: - -```rust -let v: Vec = vec![1, 2, 3]; -``` - -We could also use the `vec!` macro to make a vector of two integers or a vector -of five string slices. We wouldn’t be able to use a function to do the same -because we wouldn’t know the number or type of values up front. - -Let’s look at a slightly simplified definition of the `vec!` macro in Listing -D-1. - -```rust -#[macro_export] -macro_rules! vec { - ( $( $x:expr ),* ) => { - { - let mut temp_vec = Vec::new(); - $( - temp_vec.push($x); - )* - temp_vec - } - }; -} -``` - -Listing D-1: A simplified version of the `vec!` macro -definition - -> Note: The actual definition of the `vec!` macro in the standard library -> includes code to preallocate the correct amount of memory up front. That code -> is an optimization that we don’t include here to make the example simpler. - -The `#[macro_export]` annotation indicates that this macro should be made -available whenever the crate in which we’re defining the macro is imported. -Without this annotation, even if someone depending on this crate uses the -`#[macro_use]` annotation, the macro wouldn’t be brought into scope. - -We then start the macro definition with `macro_rules!` and the name of the -macro we’re defining *without* the exclamation mark. The name, in this case -`vec`, is followed by curly brackets denoting the body of the macro definition. - -The structure in the `vec!` body is similar to the structure of a `match` -expression. Here we have one arm with the pattern `( $( $x:expr ),* )`, -followed by `=>` and the block of code associated with this pattern. If the -pattern matches, the associated block of code will be emitted. Given that this -is the only pattern in this macro, there is only one valid way to match; any -other will be an error. More complex macros will have more than one arm. - -Valid pattern syntax in macro definitions is different than the pattern syntax -covered in Chapter 18 because macro patterns are matched against Rust code -structure rather than values. Let’s walk through what the pieces of the pattern -in Listing D-1 mean; for the full macro pattern syntax, see [the reference]. - -[the reference]: ../../reference/macros.html - -First, a set of parentheses encompasses the whole pattern. Next comes a dollar -sign (`$`) followed by a set of parentheses, which captures values that match -the pattern within the parentheses for use in the replacement code. Within -`$()` is `$x:expr`, which matches any Rust expression and gives the expression -the name `$x`. - -The comma following `$()` indicates that a literal comma separator character -could optionally appear after the code that matches the code captured in `$()`. -The `*` following the comma specifies that the pattern matches zero or more of -whatever precedes the `*`. - -When we call this macro with `vec![1, 2, 3];`, the `$x` pattern matches three -times with the three expressions `1`, `2`, and `3`. - -Now let’s look at the pattern in the body of the code associated with this arm: -the `temp_vec.push()` code within the `$()*` part is generated for each part -that matches `$()` in the pattern, zero or more times depending on how many -times the pattern matches. The `$x` is replaced with each expression matched. -When we call this macro with `vec![1, 2, 3];`, the code generated that replaces -this macro call will be the following: - -```rust,ignore -let mut temp_vec = Vec::new(); -temp_vec.push(1); -temp_vec.push(2); -temp_vec.push(3); -temp_vec -``` - -We’ve defined a macro that can take any number of arguments of any type and can -generate code to create a vector containing the specified elements. - -Given that most Rust programmers will *use* macros more than *write* macros, we -won’t discuss `macro_rules!` any further. To learn more about how to write -macros, consult the online documentation or other resources, such as [“The -Little Book of Rust Macros”][tlborm]. - -[tlborm]: https://danielkeep.github.io/tlborm/book/index.html - -### Procedural Macros for Custom `derive` - -The second form of macros is called *procedural macros* because they’re more -like functions (which are a type of procedure). Procedural macros accept some -Rust code as an input, operate on that code, and produce some Rust code as an -output rather than matching against patterns and replacing the code with other -code as declarative macros do. At the time of this writing, you can only define -procedural macros to allow your traits to be implemented on a type by -specifying the trait name in a `derive` annotation. - -We’ll create a crate named `hello_macro` that defines a trait named -`HelloMacro` with one associated function named `hello_macro`. Rather than -making our crate users implement the `HelloMacro` trait for each of their -types, we’ll provide a procedural macro so users can annotate their type with -`#[derive(HelloMacro)]` to get a default implementation of the `hello_macro` -function. The default implementation will print `Hello, Macro! My name is -TypeName!` where `TypeName` is the name of the type on which this trait has -been defined. In other words, we’ll write a crate that enables another -programmer to write code like Listing D-2 using our crate. - -Filename: src/main.rs - -```rust,ignore -extern crate hello_macro; -#[macro_use] -extern crate hello_macro_derive; - -use hello_macro::HelloMacro; - -#[derive(HelloMacro)] -struct Pancakes; - -fn main() { - Pancakes::hello_macro(); -} -``` - -Listing D-2: The code a user of our crate will be able to -write when using our procedural macro - -This code will print `Hello, Macro! My name is Pancakes!` when we’re done. The -first step is to make a new library crate, like this: - -```text -$ cargo new hello_macro --lib -``` - -Next, we’ll define the `HelloMacro` trait and its associated function: - -Filename: src/lib.rs - -```rust -pub trait HelloMacro { - fn hello_macro(); -} -``` - -We have a trait and its function. At this point, our crate user could implement -the trait to achieve the desired functionality, like so: - -```rust,ignore -extern crate hello_macro; - -use hello_macro::HelloMacro; - -struct Pancakes; - -impl HelloMacro for Pancakes { - fn hello_macro() { - println!("Hello, Macro! My name is Pancakes!"); - } -} - -fn main() { - Pancakes::hello_macro(); -} -``` - -However, they would need to write the implementation block for each type they -wanted to use with `hello_macro`; we want to spare them from having to do this -work. - -Additionally, we can’t yet provide a default implementation for the -`hello_macro` function that will print the name of the type the trait is -implemented on: Rust doesn’t have reflection capabilities, so it can’t look up -the type’s name at runtime. We need a macro to generate code at compile time. - -The next step is to define the procedural macro. At the time of this writing, -procedural macros need to be in their own crate. Eventually, this restriction -might be lifted. The convention for structuring crates and macro crates is as -follows: for a crate named `foo`, a custom derive procedural macro crate is -called `foo_derive`. Let’s start a new crate called `hello_macro_derive` inside -our `hello_macro` project: - -```text -$ cargo new hello_macro_derive --lib -``` - -Our two crates are tightly related, so we create the procedural macro crate -within the directory of our `hello_macro` crate. If we change the trait -definition in `hello_macro`, we’ll have to change the implementation of the -procedural macro in `hello_macro_derive` as well. The two crates will need to -be published separately, and programmers using these crates will need to add -both as dependencies and bring them both into scope. We could instead have the -`hello_macro` crate use `hello_macro_derive` as a dependency and reexport the -procedural macro code. But the way we’ve structured the project makes it -possible for programmers to use `hello_macro` even if they don’t want the -`derive` functionality. - -We need to declare the `hello_macro_derive` crate as a procedural macro crate. -We’ll also need functionality from the `syn` and `quote` crates, as you’ll see -in a moment, so we need to add them as dependencies. Add the following to the -*Cargo.toml* file for `hello_macro_derive`: - -Filename: hello_macro_derive/Cargo.toml - -```toml -[lib] -proc-macro = true - -[dependencies] -syn = "0.14.4" -quote = "0.6.3" -``` - -To start defining the procedural macro, place the code in Listing D-3 into your -*src/lib.rs* file for the `hello_macro_derive` crate. Note that this code won’t -compile until we add a definition for the `impl_hello_macro` function. - -Filename: hello_macro_derive/src/lib.rs - -```rust,ignore -extern crate proc_macro; -extern crate syn; -#[macro_use] -extern crate quote; - -use proc_macro::TokenStream; - -#[proc_macro_derive(HelloMacro)] -pub fn hello_macro_derive(input: TokenStream) -> TokenStream { - // Construct a represntation of Rust code as a syntax tree - // that we can manipulate - let ast = syn::parse(input).unwrap(); - - // Build the trait implementation - impl_hello_macro(&ast) -} -``` - -Listing D-3: Code that most procedural macro crates will -need to have for processing Rust code - -Notice the way we’ve split the functions in D-3; this will be the same for -almost every procedural macro crate you see or create, because it makes writing -a procedural macro more convenient. What you choose to do in the place where -the `impl_hello_macro` function is called will be different depending on your -procedural macro’s purpose. - -We’ve introduced three new crates: `proc_macro`, [`syn`], and [`quote`]. The -`proc_macro` crate comes with Rust, so we didn’t need to add that to the -dependencies in *Cargo.toml*. The `proc_macro` crate allows us to convert Rust -code into a string containing that Rust code. The `syn` crate parses Rust code -from a string into a data structure that we can perform operations on. The -`quote` crate takes `syn` data structures and turns them back into Rust code. -These crates make it much simpler to parse any sort of Rust code we might want -to handle: writing a full parser for Rust code is no simple task. - -[`syn`]: https://crates.io/crates/syn -[`quote`]: https://crates.io/crates/quote - -The `hello_macro_derive` function will get called when a user of our library -specifies `#[derive(HelloMacro)]` on a type. The reason is that we’ve annotated -the `hello_macro_derive` function here with `proc_macro_derive` and specified -the name, `HelloMacro`, which matches our trait name; that’s the convention -most procedural macros follow. - -This function first converts the `input` from a `TokenStream` to a data -structure that we can then interpret and perform operations on. This is where -`syn` comes into play. The `parse` function in `syn` takes a `TokenStream` and -returns a `DeriveInput` struct representing the parsed Rust code. The following -code shows the relevant parts of the `DeriveInput` struct we get from parsing -the string `struct Pancakes;`: - -```rust,ignore -DeriveInput { - // --snip-- - - ident: Ident( - "Pancakes" - ), - body: Struct( - Unit - ) -} -``` - -The fields of this struct show that the Rust code we’ve parsed is a unit struct -with the `ident` (identifier, meaning the name) of `Pancakes`. There are more -fields on this struct for describing all sorts of Rust code; check the [`syn` -documentation for `DeriveInput`][syn-docs] for more information. - -[syn-docs]: https://docs.rs/syn/0.11.11/syn/struct.DeriveInput.html - -At this point, we haven’t defined the `impl_hello_macro` function, which is -where we’ll build the new Rust code we want to include. But before we do, note -that its output is also a `TokenStream` which is added to the code that our -crate users write, so when they compile their crate, they’ll get extra -functionality that we provide. - -You might have noticed that we’re calling `unwrap` to panic if the call to the -`syn::parse`function fails here. Panicking on errors is necessary in procedural -macro code because `proc_macro_derive` functions must return `TokenStream` -rather than `Result` to conform to the procedural macro API. We’ve chosen to -simplify this example by using `unwrap`; in production code, you should provide -more specific error messages about what went wrong by using `panic!` or `expect`. - -Now that we have the code to turn the annotated Rust code from a `TokenStream` -into a `DeriveInput` instance, let’s generate the code that implements the -`HelloMacro` trait on the annotated type: - -Filename: hello_macro_derive/src/lib.rs - -```rust,ignore -fn impl_hello_macro(ast: &syn::DeriveInput) -> TokenStream { - let name = &ast.ident; - let gen = quote! { - impl HelloMacro for #name { - fn hello_macro() { - println!("Hello, Macro! My name is {}", stringify!(#name)); - } - } - }; - gen.into() -} -``` - -We get an `Ident` struct instance containing the name (identifier) of the -annotated type using `ast.ident`. The code in Listing D-2 specifies that the -`name` will be `Ident("Pancakes")`. - -The `quote!` macro lets us write the Rust code that we want to return, but the -direct result of its execution is not what is expected by the compiler and needs -to be converted to a `TokenStream` by calling the `into` method. `into` consumes -this intermediate representation and returns a value of the required type. - -This macro also provides some very cool templating mechanics; we can write -`#name`, and `quote!` will replace it with the value in the variable named -`name`. You can even do some repetition similar -to the way regular macros work. Check out [the `quote` crate’s docs][quote-docs] -for a thorough introduction. - -[quote-docs]: https://docs.rs/quote - -We want our procedural macro to generate an implementation of our `HelloMacro` -trait for the type the user annotated, which we can get by using `#name`. The -trait implementation has one function, `hello_macro`, whose body contains the -functionality we want to provide: printing `Hello, Macro! My name is` and then -the name of the annotated type. - -The `stringify!` macro used here is built into Rust. It takes a Rust -expression, such as `1 + 2`, and at compile time turns the expression into a -string literal, such as `"1 + 2"`. This is different than `format!` or -`println!`, which evaluate the expression and then turn the result into a -`String`. There is a possibility that the `#name` input might be an expression -to print literally, so we use `stringify!`. Using `stringify!` also saves an -allocation by converting `#name` to a string literal at compile time. - -At this point, `cargo build` should complete successfully in both `hello_macro` -and `hello_macro_derive`. Let’s hook up these crates to the code in Listing D-2 -to see the procedural macro in action! Create a new binary project in your -*projects* directory using `cargo new pancakes`. We need to add -`hello_macro` and `hello_macro_derive` as dependencies in the `pancakes` -crate’s *Cargo.toml*. If you’re publishing your versions of `hello_macro` and -`hello_macro_derive` to *https://crates.io/*, they would be regular -dependencies; if not, you can specify them as `path` dependencies as follows: - -```toml -[dependencies] -hello_macro = { path = "../hello_macro" } -hello_macro_derive = { path = "../hello_macro/hello_macro_derive" } -``` - -Put the code from Listing D-2 into *src/main.rs*, and run `cargo run`: it -should print `Hello, Macro! My name is Pancakes!` The implementation of the -`HelloMacro` trait from the procedural macro was included without the -`pancakes` crate needing to implement it; the `#[derive(HelloMacro)]` added the -trait implementation. - -### The Future of Macros - -In the future, Rust will expand declarative and procedural macros. Rust will -use a better declarative macro system with the `macro` keyword and will add -more types of procedural macros for more powerful tasks than just `derive`. -These systems are still under development at the time of this publication; -please consult the online Rust documentation for the latest information. diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-04-useful-development-tools.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-04-useful-development-tools.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-04-useful-development-tools.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-04-useful-development-tools.md 2018-11-21 02:20:59.000000000 +0000 @@ -0,0 +1,10 @@ +# Appendix D - Useful Development Tools + +The 2018 edition of the book is no longer distributed with Rust's documentation. + +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. + +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/appendix-04-useful-development-tools.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-05-editions.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-05-editions.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-05-editions.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-05-editions.md 2018-11-21 02:20:59.000000000 +0000 @@ -0,0 +1,10 @@ +# Appendix E - Editions + +The 2018 edition of the book is no longer distributed with Rust's documentation. + +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. + +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/appendix-05-editions.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-05-translation.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-05-translation.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-05-translation.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-05-translation.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -## Appendix E: Translations of the Book - -For resources in languages other than English. Most are still in progress; see -[the Translations label][label] to help or let us know about a new translation! - -[label]: https://github.com/rust-lang/book/issues?q=is%3Aopen+is%3Aissue+label%3ATranslations - -- [Português](https://github.com/rust-br/rust-book-pt-br) (BR) -- [Português](https://github.com/nunojesus/rust-book-pt-pt) (PT) -- [Tiếng việt](https://github.com/hngnaig/rust-lang-book/tree/vi-VN) -- [简体中文](http://www.broadview.com.cn/article/144), [alternate](https://github.com/KaiserY/trpl-zh-cn) -- [Українська](https://github.com/pavloslav/rust-book-uk-ua) -- [Español](https://github.com/thecodix/book) -- [Italiano](https://github.com/AgeOfWar/rust-book-it) -- [Русский](https://github.com/iDeBugger/rust-book-ru) -- [한국어](https://github.com/rinthel/rust-lang-book-ko) -- [日本語](https://github.com/hazama-yuinyan/book) -- [Français](https://github.com/quadrifoglio/rust-book-fr) -- [Polski](https://github.com/paytchoo/book-pl) -- [עברית](https://github.com/idanmel/rust-book-heb) -- [Cebuano](https://github.com/agentzero1/book) -- [Tagalog](https://github.com/josephace135/book) diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-06-nightly-rust.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-06-nightly-rust.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-06-nightly-rust.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-06-nightly-rust.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,201 +0,0 @@ -# Appendix F - How Rust is Made and “Nightly Rust” - -This appendix is about how Rust is made and how that affects you as a Rust -developer. - -### Stability Without Stagnation - -As a language, Rust cares a *lot* about the stability of your code. We want -Rust to be a rock-solid foundation you can build on, and if things were -constantly changing, that would be impossible. At the same time, if we can’t -experiment with new features, we may not find out important flaws until after -their release, when we can no longer change things. - -Our solution to this problem is what we call “stability without stagnation”, -and our guiding principle is this: you should never have to fear upgrading to a -new version of stable Rust. Each upgrade should be painless, but should also -bring you new features, fewer bugs, and faster compile times. - -### Choo, Choo! Release Channels and Riding the Trains - -Rust development operates on a *train schedule*. That is, all development is -done on the `master` branch of the Rust repository. Releases follow a software -release train model, which has been used by Cisco IOS and other software -projects. There are three *release channels* for Rust: - -* Nightly -* Beta -* Stable - -Most Rust developers primarily use the stable channel, but those who want to -try out experimental new features may use nightly or beta. - -Here’s an example of how the development and release process works: let’s -assume that the Rust team is working on the release of Rust 1.5. That release -happened in December of 2015, but it will provide us with realistic version -numbers. A new feature is added to Rust: a new commit lands on the `master` -branch. Each night, a new nightly version of Rust is produced. Every day is a -release day, and these releases are created by our release infrastructure -automatically. So as time passes, our releases look like this, once a night: - -```text -nightly: * - - * - - * -``` - -Every six weeks, it’s time to prepare a new release! The `beta` branch of the -Rust repository branches off from the `master` branch used by nightly. Now, -there are two releases: - -```text -nightly: * - - * - - * - | -beta: * -``` - -Most Rust users do not use beta releases actively, but test against beta in -their CI system to help Rust discover possible regressions. In the meantime, -there’s still a nightly release every night: - -```text -nightly: * - - * - - * - - * - - * - | -beta: * -``` - -Let’s say a regression is found. Good thing we had some time to test the beta -release before the regression snuck into a stable release! The fix is applied -to `master`, so that nightly is fixed, and then the fix is backported to the -`beta` branch, and a new release of beta is produced: - -```text -nightly: * - - * - - * - - * - - * - - * - | -beta: * - - - - - - - - * -``` - -Six weeks after the first beta was created, it’s time for a stable release! The -`stable` branch is produced from the `beta` branch: - -```text -nightly: * - - * - - * - - * - - * - - * - * - * - | -beta: * - - - - - - - - * - | -stable: * -``` - -Hooray! Rust 1.5 is done! However, we’ve forgotten one thing: because the six -weeks have gone by, we also need a new beta of the *next* version of Rust, 1.6. -So after `stable` branches off of `beta`, the next version of `beta` branches -off of `nightly` again: - -```text -nightly: * - - * - - * - - * - - * - - * - * - * - | | -beta: * - - - - - - - - * * - | -stable: * -``` - -This is called the “train model” because every six weeks, a release “leaves the -station”, but still has to take a journey through the beta channel before it -arrives as a stable release. - -Rust releases every six weeks, like clockwork. If you know the date of one Rust -release, you can know the date of the next one: it’s six weeks later. A nice -aspect of having releases scheduled every six weeks is that the next train is -coming soon. If a feature happens to miss a particular release, there’s no need -to worry: another one is happening in a short time! This helps reduce pressure -to sneak possibly unpolished features in close to the release deadline. - -Thanks to this process, you can always check out the next build of Rust and -verify for yourself that it’s easy to upgrade to: if a beta release doesn’t -work as expected, you can report it to the team and get it fixed before the -next stable release happens! Breakage in a beta release is relatively rare, but -`rustc` is still a piece of software, and bugs do exist. - -### Unstable Features - -There’s one more catch with this release model: unstable features. Rust uses a -technique called “feature flags” to determine what features are enabled in a -given release. If a new feature is under active development, it lands on -`master`, and therefore, in nightly, but behind a *feature flag*. If you, as a -user, wish to try out the work-in-progress feature, you can, but you must be -using a nightly release of Rust and annotate your source code with the -appropriate flag to opt in. - -If you’re using a beta or stable release of Rust, you can’t use any feature -flags. This is the key that allows us to get practical use with new features -before we declare them stable forever. Those who wish to opt into the bleeding -edge can do so, and those who want a rock-solid experience can stick with -stable and know that their code won’t break. Stability without stagnation. - -This book only contains information about stable features, as in-progress -features are still changing, and surely they’ll be different between when this -book was written and when they get enabled in stable builds. You can find -documentation for nightly-only features online. - -### Rustup and the Role of Rust Nightly - -Rustup makes it easy to change between different release channels of Rust, on a -global or per-project basis. By default, you’ll have stable Rust installed. To -install nightly, for example: - -```text -$ rustup install nightly -``` - -You can see all of the *toolchains* (releases of Rust and associated -components) you have installed with `rustup` as well. Here’s an example on one -of your authors’ Windows computer: - -```powershell -> rustup toolchain list -stable-x86_64-pc-windows-msvc (default) -beta-x86_64-pc-windows-msvc -nightly-x86_64-pc-windows-msvc -``` - -As you can see, the stable toolchain is the default. Most Rust users use stable -most of the time. You might want to use stable most of the time, but use -nightly on a specific project, because you care about a cutting-edge feature. -To do so, you can use `rustup override` in that project’s directory to set the -nightly toolchain as the one `rustup` should use when you’re in that directory: - -```text -$ cd ~/projects/needs-nightly -$ rustup override set nightly -``` - -Now, every time you call `rustc` or `cargo` inside of -*~/projects/needs-nightly*, `rustup` will make sure that you are using nightly -Rust, rather than your default of stable Rust. This comes in handy when you -have a lot of Rust projects! - -### The RFC Process and Teams - -So how do you learn about these new features? Rust’s development model follows -a *Request For Comments (RFC) process*. If you’d like an improvement in Rust, -you can write up a proposal, called an RFC. - -Anyone can write RFCs to improve Rust, and the proposals are reviewed and -discussed by the Rust team, which is comprised of many topic subteams. There’s -a full list of the teams [on Rust’s -website](https://www.rust-lang.org/en-US/team.html), which includes teams for -each area of the project: language design, compiler implementation, -infrastructure, documentation, and more. The appropriate team reads the -proposal and the comments, writes some comments of their own, and eventually, -there’s consensus to accept or reject the feature. - -If the feature is accepted, an issue is opened on the Rust repository, and -someone can implement it. The person who implements it very well may not be the -person who proposed the feature in the first place! When the implementation is -ready, it lands on the `master` branch behind a feature gate, as we discussed -in the “Unstable Features” section. - -After some time, once Rust developers who use nightly releases have been able -to try out the new feature, team members will discuss the feature, how it’s -worked out on nightly, and decide if it should make it into stable Rust or not. -If the decision is to move forward, the feature gate is removed, and the -feature is now considered stable! It rides the trains into a new stable release -of Rust. diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-06-translation.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-06-translation.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-06-translation.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-06-translation.md 2018-11-21 02:20:59.000000000 +0000 @@ -0,0 +1,10 @@ +## Appendix F: Translations of the Book + +The 2018 edition of the book is no longer distributed with Rust's documentation. + +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. + +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/appendix-06-translation.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-07-nightly-rust.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-07-nightly-rust.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-07-nightly-rust.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-07-nightly-rust.md 2018-11-21 02:20:59.000000000 +0000 @@ -0,0 +1,10 @@ +# Appendix G - How Rust is Made and “Nightly Rust” + +The 2018 edition of the book is no longer distributed with Rust's documentation. + +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. + +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/appendix-07-nightly-rust.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-07-other-useful-tools.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-07-other-useful-tools.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-07-other-useful-tools.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/appendix-07-other-useful-tools.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -# G - Other useful tools - -In this appendix, we'll talk about some additional tools that are provided by -the Rust project, and are useful when developing Rust code. - -## Automatic formatting with `rustfmt` - -`rustfmt` is a tool that can re-format your code according to community -norms. Many projects use `rustfmt` to prevent arguments about which style to -use when writing Rust: just do what the tool does! - -`rustfmt` is not at 1.0 yet, but a preview is available for you to use in -the meantime. Please give it a try and let us know how it goes! - -To install `rustfmt`: - -```shell -$ rustup component add rustfmt-preview -``` - -This will give you both `rustfmt` and `cargo-fmt`, similar to how Rust gives -you both `rustc` and `cargo`. To take any Cargo project and format it: - -```shell -$ cargo fmt -``` - -## IDE integration with the Rust Language Server - -To help IDE integration, the Rust project distributes `rls`, the Rust -Language Server, as in . This can be used by -different clients, such as [the Rust plugin for Visual Studio: -Code](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust). - -The `rls` is not at 1.0 yet, but a preview is available for you to use in the -meantime. Please give it a try and let us know how it goes! - -To install the `rls`: - -```shell -$ rustup component add rls-preview -``` - -Then, install the language server support in your particular IDE, and it -should all work. \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch00-00-introduction.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch00-00-introduction.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch00-00-introduction.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch00-00-introduction.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,179 +1,10 @@ # Introduction -> Note: This edition of the book is the same as [The Rust Programming -> Language][nsprust] available in print and ebook format from [No Starch -> Press][nsp]. +The 2018 edition of the book is no longer distributed with Rust's documentation. -[nsprust]: https://nostarch.com/rust -[nsp]: https://nostarch.com/ +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -Welcome to *The Rust Programming Language*, an introductory book about Rust. -The Rust programming language helps you write faster, more reliable software. -High-level ergonomics and low-level control are often at odds in programming -language design; Rust challenges that conflict. Through balancing powerful -technical capacity and a great developer experience, Rust gives you the option -to control low-level details (such as memory usage) without all the hassle -traditionally associated with such control. - -## Who Rust Is For - -Rust is ideal for many people for a variety of reasons. Let’s look at a few of -the most important groups. - -### Teams of Developers - -Rust is proving to be a productive tool for collaborating among large teams of -developers with varying levels of systems programming knowledge. Low-level code -is prone to a variety of subtle bugs, which in most other languages can be -caught only through extensive testing and careful code review by experienced -developers. In Rust, the compiler plays a gatekeeper role by refusing to -compile code with these elusive bugs, including concurrency bugs. By working -alongside the compiler, the team can spend their time focusing on the program’s -logic rather than chasing down bugs. - -Rust also brings contemporary developer tools to the systems programming world: - -* Cargo, the included dependency manager and build tool, makes adding, - compiling, and managing dependencies painless and consistent across the Rust - ecosystem. -* Rustfmt ensures a consistent coding style across developers. -* The Rust Language Server powers Integrated Development Environment (IDE) - integration for code completion and inline error messages. - -By using these and other tools in the Rust ecosystem, developers can be -productive while writing systems-level code. - -### Students - -Rust is for students and those who are interested in learning about systems -concepts. Using Rust, many people have learned about topics like operating -systems development. The community is very welcoming and happy to answer -student questions. Through efforts such as this book, the Rust teams want to -make systems concepts more accessible to more people, especially those new to -programming. - -### Companies - -Hundreds of companies, large and small, use Rust in production for a variety of -tasks. Those tasks include command line tools, web services, DevOps tooling, -embedded devices, audio and video analysis and transcoding, cryptocurrencies, -bioinformatics, search engines, Internet of Things applications, machine -learning, and even major parts of the Firefox web browser. - -### Open Source Developers - -Rust is for people who want to build the Rust programming language, community, -developer tools, and libraries. We’d love to have you contribute to the Rust -language. - -### People Who Value Speed and Stability - -Rust is for people who crave speed and stability in a language. By speed, we -mean the speed of the programs that you can create with Rust and the speed at -which Rust lets you write them. The Rust compiler’s checks ensure stability -through feature additions and refactoring. This is in contrast to the brittle -legacy code in languages without these checks, which developers are often -afraid to modify. By striving for zero-cost abstractions, higher-level features -that compile to lower-level code as fast as code written manually, Rust -endeavors to make safe code be fast code as well. - -The Rust language hopes to support many other users as well; those mentioned -here are merely some of the biggest stakeholders. Overall, Rust’s greatest -ambition is to eliminate the trade-offs that programmers have accepted for -decades by providing safety *and* productivity, speed *and* ergonomics. Give -Rust a try and see if its choices work for you. - -## Who This Book Is For - -This book assumes that you’ve written code in another programming language but -doesn’t make any assumptions about which one. We’ve tried to make the material -broadly accessible to those from a wide variety of programming backgrounds. We -don’t spend a lot of time talking about what programming *is* or how to think -about it. If you’re entirely new to programming, you would be better served by -reading a book that specifically provides an introduction to programming. - -## How to Use This Book - -In general, this book assumes that you’re reading it in sequence from front to -back. Later chapters build on concepts in earlier chapters, and earlier -chapters might not delve into details on a topic; we typically revisit the -topic in a later chapter. - -You’ll find two kinds of chapters in this book: concept chapters and project -chapters. In concept chapters, you’ll learn about an aspect of Rust. In project -chapters, we’ll build small programs together, applying what you’ve learned so -far. Chapters 2, 12, and 20 are project chapters; the rest are concept chapters. - -Chapter 1 explains how to install Rust, how to write a Hello, world! program, -and how to use Cargo, Rust’s package manager and build tool. Chapter 2 is a -hands-on introduction to the Rust language. Here we cover concepts at a high -level, and later chapters will provide additional detail. If you want to get -your hands dirty right away, Chapter 2 is the place for that. At first, you -might even want to skip Chapter 3, which covers Rust features similar to those -of other programming languages, and head straight to Chapter 4 to learn about -Rust’s ownership system. However, if you’re a particularly meticulous learner -who prefers to learn every detail before moving on to the next, you might want -to skip Chapter 2 and go straight to Chapter 3, returning to Chapter 2 when -you’d like to work on a project applying the details you’ve learned. - -Chapter 5 discusses structs and methods, and Chapter 6 covers enums, `match` -expressions, and the `if let` control flow construct. You’ll use structs and -enums to make custom types in Rust. - -In Chapter 7, you’ll learn about Rust’s module system and about privacy rules -for organizing your code and its public Application Programming Interface -(API). Chapter 8 discusses some common collection data structures that the -standard library provides, such as vectors, strings, and hash maps. Chapter 9 -explores Rust’s error-handling philosophy and techniques. - -Chapter 10 digs into generics, traits, and lifetimes, which give you the power -to define code that applies to multiple types. Chapter 11 is all about testing, -which even with Rust’s safety guarantees is necessary to ensure your program’s -logic is correct. In Chapter 12, we’ll build our own implementation of a subset -of functionality from the `grep` command line tool that searches for text -within files. For this, we’ll use many of the concepts we discussed in the -previous chapters. - -Chapter 13 explores closures and iterators: features of Rust that come from -functional programming languages. In Chapter 14, we’ll examine Cargo in more -depth and talk about best practices for sharing your libraries with others. -Chapter 15 discusses smart pointers that the standard library provides and the -traits that enable their functionality. - -In Chapter 16, we’ll walk through different models of concurrent programming -and talk about how Rust helps you to program in multiple threads fearlessly. -Chapter 17 looks at how Rust idioms compare to object-oriented programming -principles you might be familiar with. - -Chapter 18 is a reference on patterns and pattern matching, which are powerful -ways of expressing ideas throughout Rust programs. Chapter 19 contains a -smorgasbord of advanced topics of interest, including unsafe Rust and more -about lifetimes, traits, types, functions, and closures. - -In Chapter 20, we’ll complete a project in which we’ll implement a low-level -multithreaded web server! - -Finally, some appendixes contain useful information about the language in a -more reference-like format. Appendix A covers Rust’s keywords, Appendix B -covers Rust’s operators and symbols, Appendix C covers derivable traits -provided by the standard library, and Appendix D covers macros. - -There is no wrong way to read this book: if you want to skip ahead, go for it! -You might have to jump back to earlier chapters if you experience any -confusion. But do whatever works for you. - -An important part of the process of learning Rust is learning how to read the -error messages the compiler displays: these will guide you toward working code. -As such, we’ll provide many examples of code that doesn’t compile along with -the error message the compiler will show you in each situation. Know that if -you enter and run a random example, it may not compile! Make sure you read the -surrounding text to see whether the example you’re trying to run is meant to -error. In most situations, we’ll lead you to the correct version of any code -that doesn’t compile. - -## Source Code - -The source files from which this book is generated can be found on -[GitHub][book]. - -[book]: https://github.com/rust-lang/book/tree/master/second-edition/src +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch00-00-introduction.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch01-00-getting-started.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch01-00-getting-started.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch01-00-getting-started.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch01-00-getting-started.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,8 +1,10 @@ # Getting Started -Let’s start your Rust journey! There’s a lot to learn, but every journey starts -somewhere. In this chapter, we’ll discuss: +The 2018 edition of the book is no longer distributed with Rust's documentation. -* Installing Rust on Linux, macOS, and Windows -* Writing a program that prints `Hello, world!` -* Using `cargo`, Rust’s package manager and build system +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. + +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch10-00-getting-started.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch01-01-installation.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch01-01-installation.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch01-01-installation.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch01-01-installation.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,137 +1,10 @@ ## Installation -The first step is to install Rust. We’ll download Rust through `rustup`, a -command line tool for managing Rust versions and associated tools. You’ll need -an internet connection for the download. +The 2018 edition of the book is no longer distributed with Rust's documentation. -> Note: If you prefer not to use `rustup` for some reason, please see [the Rust -> installation page](https://www.rust-lang.org/install.html) for other options. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -The following steps install the latest stable version of the Rust compiler. -Rust’s stability guarantees ensure that all the examples in the book that -compile will continue to compile with newer Rust versions. The output might -differ slightly between versions, because Rust often improves error messages -and warnings. In other words, any newer, stable version of Rust you install -using these steps should work as expected with the content of this book. - -> ### Command Line Notation -> -> In this chapter and throughout the book, we’ll show some commands used in the -> terminal. Lines that you should enter in a terminal all start with `$`. You -> don’t need to type in the `$` character; it indicates the start of each -> command. Lines that don’t start with `$` typically show the output of the -> previous command. Additionally, PowerShell-specific examples will use `>` -> rather than `$`. - -### Installing `rustup` on Linux or macOS - -If you’re using Linux or macOS, open a terminal and enter the following command: - -```text -$ curl https://sh.rustup.rs -sSf | sh -``` - -The command downloads a script and starts the installation of the `rustup` -tool, which installs the latest stable version of Rust. You might be prompted -for your password. If the install is successful, the following line will appear: - -```text -Rust is installed now. Great! -``` - -If you prefer, feel free to download the script and inspect it before running -it. - -The installation script automatically adds Rust to your system PATH after your -next login. If you want to start using Rust right away instead of restarting -your terminal, run the following command in your shell to add Rust to your -system PATH manually: - -```text -$ source $HOME/.cargo/env -``` - -Alternatively, you can add the following line to your *~/.bash_profile*: - -```text -$ export PATH="$HOME/.cargo/bin:$PATH" -``` - -Additionally, you’ll need a linker of some kind. It’s likely one is already -installed, but when you try to compile a Rust program and get errors indicating -that a linker could not execute, that means a linker isn’t installed on your -system and you’ll need to install one manually. C compilers usually come with -the correct linker. Check your platform’s documentation for how to install a C -compiler. Also, some common Rust packages depend on C code and will need a C -compiler. Therefore, it might be worth installing one now. - -### Installing `rustup` on Windows - -On Windows, go to [https://www.rust-lang.org/install.html][install] and follow -the instructions for installing Rust. At some point in the installation, you’ll -receive a message explaining that you’ll also need the C++ build tools for -Visual Studio 2013 or later. The easiest way to acquire the build tools is to -install [Build Tools for Visual Studio 2017][visualstudio]. The tools are in -the Other Tools and Frameworks section. - -[install]: https://www.rust-lang.org/install.html -[visualstudio]: https://www.visualstudio.com/downloads/ - -The rest of this book uses commands that work in both *cmd.exe* and PowerShell. -If there are specific differences, we’ll explain which to use. - -### Updating and Uninstalling - -After you’ve installed Rust via `rustup`, updating to the latest version is -easy. From your shell, run the following update script: - -```text -$ rustup update -``` - -To uninstall Rust and `rustup`, run the following uninstall script from your -shell: - -```text -$ rustup self uninstall -``` - -### Troubleshooting - -To check whether you have Rust installed correctly, open a shell and enter this -line: - -```text -$ rustc --version -``` - -You should see the version number, commit hash, and commit date for the latest -stable version that has been released in the following format: - -```text -rustc x.y.z (abcabcabc yyyy-mm-dd) -``` - -If you see this information, you have installed Rust successfully! If you don’t -see this information and you’re on Windows, check that Rust is in your `%PATH%` -system variable. If that’s all correct and Rust still isn’t working, there are -a number of places you can get help. The easiest is [the #rust IRC channel on -irc.mozilla.org][irc], which you can access through -[Mibbit][mibbit]. At that address you can chat with other Rustaceans (a silly -nickname we call ourselves) who can help you out. Other great resources include -[the Users forum][users] and [Stack Overflow][stackoverflow]. - -[irc]: irc://irc.mozilla.org/#rust -[mibbit]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust -[users]: https://users.rust-lang.org/ -[stackoverflow]: http://stackoverflow.com/questions/tagged/rust - -### Local Documentation - -The installer also includes a copy of the documentation locally, so you can -read it offline. Run `rustup doc` to open the local documentation in your -browser. - -Any time a type or function is provided by the standard library and you’re not -sure what it does or how to use it, use the application programming interface -(API) documentation to find out! +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch01-01-installation.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch01-02-hello-world.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch01-02-hello-world.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch01-02-hello-world.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch01-02-hello-world.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,218 +1,10 @@ ## Hello, World! -Now that you’ve installed Rust, let’s write your first Rust program. It’s -traditional when learning a new language to write a little program that prints -the text `Hello, world!` to the screen, so we’ll do the same here! +The 2018 edition of the book is no longer distributed with Rust's documentation. -> Note: This book assumes basic familiarity with the command line. Rust makes -> no specific demands about your editing or tooling or where your code lives, so -> if you prefer to use an integrated development environment (IDE) instead of -> the command line, feel free to use your favorite IDE. Many IDEs now have some -> degree of Rust support; check the IDE’s documentation for details. Recently, -> the Rust team has been focusing on enabling great IDE support, and progress -> has been made rapidly on that front! +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -### Creating a Project Directory - -You’ll start by making a directory to store your Rust code. It doesn’t matter -to Rust where your code lives, but for the exercises and projects in this book, -we suggest making a *projects* directory in your home directory and keeping all -your projects there. - -Open a terminal and enter the following commands to make a *projects* directory -and a directory for the Hello, world! project within the *projects* directory. - -For Linux and macOS, enter this: - -```text -$ mkdir ~/projects -$ cd ~/projects -$ mkdir hello_world -$ cd hello_world -``` - -For Windows CMD, enter this: - -```cmd -> mkdir "%USERPROFILE%\projects" -> cd /d "%USERPROFILE%\projects" -> mkdir hello_world -> cd hello_world -``` - -For Windows PowerShell, enter this: - -```powershell -> mkdir $env:USERPROFILE\projects -> cd $env:USERPROFILE\projects -> mkdir hello_world -> cd hello_world -``` - -### Writing and Running a Rust Program - -Next, make a new source file and call it *main.rs*. Rust files always end with -the *.rs* extension. If you’re using more than one word in your filename, use -an underscore to separate them. For example, use *hello_world.rs* rather than -*helloworld.rs*. - -Now open the *main.rs* file you just created and enter the code in Listing 1-1. - -Filename: main.rs - -```rust -fn main() { - println!("Hello, world!"); -} -``` - -Listing 1-1: A program that prints `Hello, world!` - -Save the file and go back to your terminal window. On Linux or macOS, enter -the following commands to compile and run the file: - -```text -$ rustc main.rs -$ ./main -Hello, world! -``` - -On Windows, enter the command `.\main.exe` instead of `./main`: - -```powershell -> rustc main.rs -> .\main.exe -Hello, world! -``` - -Regardless of your operating system, the string `Hello, world!` should print to -the terminal. If you don’t see this output, refer back to the “Troubleshooting” -part of the Installation section for ways to get help. - -If `Hello, world!` did print, congratulations! You’ve officially written a Rust -program. That makes you a Rust programmer—welcome! - -### Anatomy of a Rust Program - -Let’s review in detail what just happened in your Hello, world! program. -Here’s the first piece of the puzzle: - -```rust -fn main() { - -} -``` - -These lines define a function in Rust. The `main` function is special: it is -always the first code that runs in every executable Rust program. The first -line declares a function named `main` that has no parameters and returns -nothing. If there were parameters, they would go inside the parentheses, `()`. - -Also, note that the function body is wrapped in curly brackets, `{}`. Rust -requires these around all function bodies. It’s good style to place the opening -curly bracket on the same line as the function declaration, adding one space in -between. - -At the time of this writing, an automatic formatter tool called `rustfmt` is -under development. If you want to stick to a standard style across Rust -projects, `rustfmt` will format your code in a particular style. The Rust team -plans to eventually include this tool with the standard Rust distribution, like -`rustc`. So depending on when you read this book, it might already be installed -on your computer! Check the online documentation for more details. - -Inside the `main` function is the following code: - -```rust - println!("Hello, world!"); -``` - -This line does all the work in this little program: it prints text to the -screen. There are four important details to notice here. First, Rust style is -to indent with four spaces, not a tab. - -Second, `println!` calls a Rust macro. If it called a function instead, it -would be entered as `println` (without the `!`). We’ll discuss Rust macros in -more detail in Appendix D. For now, you just need to know that using a `!` -means that you’re calling a macro instead of a normal function. - -Third, you see the `"Hello, world!"` string. We pass this string as an argument -to `println!`, and the string is printed to the screen. - -Fourth, we end the line with a semicolon (`;`), which indicates that this -expression is over and the next one is ready to begin. Most lines of Rust code -end with a semicolon. - -### Compiling and Running Are Separate Steps - -You’ve just run a newly created program, so let’s examine each step in the -process. - -Before running a Rust program, you must compile it using the Rust compiler by -entering the `rustc` command and passing it the name of your source file, like -this: - -```text -$ rustc main.rs -``` - -If you have a C or C++ background, you’ll notice that this is similar to `gcc` -or `clang`. After compiling successfully, Rust outputs a binary executable. - -On Linux and macOS you can see the executable by entering the `ls` command in -your shell as follows: - -```text -$ ls -main main.rs -``` - -With PowerShell on Windows, you can use `ls` as well, but you'll see three files: - -```text -> ls - - - Directory: Path:\to\the\project - - -Mode LastWriteTime Length Name ----- ------------- ------ ---- --a---- 6/1/2018 7:31 AM 137728 main.exe --a---- 6/1/2018 7:31 AM 1454080 main.pdb --a---- 6/1/2018 7:31 AM 14 main.rs -``` - -With CMD on Windows, you would enter the following: - -```cmd -> dir /B %= the /B option says to only show the file names =% -main.exe -main.pdb -main.rs -``` - -This shows the source code file with the *.rs* extension, the executable file -(*main.exe* on Windows, but *main* on all other platforms), and, when using -CMD, a file containing debugging information with the *.pdb* extension. From -here, you run the *main* or *main.exe* file, like this: - -```text -$ ./main # or .\main.exe on Windows -``` - -If *main.rs* was your Hello, world! program, this line would print `Hello, -world!` to your terminal. - -If you’re more familiar with a dynamic language, such as Ruby, Python, or -JavaScript, you might not be used to compiling and running a program as -separate steps. Rust is an *ahead-of-time compiled* language, meaning you can -compile a program and give the executable to someone else, and they can run it -even without having Rust installed. If you give someone a *.rb*, *.py*, or -*.js* file, they need to have a Ruby, Python, or JavaScript implementation -installed (respectively). But in those languages, you only need one command to -compile and run your program. Everything is a trade-off in language design. - -Just compiling with `rustc` is fine for simple programs, but as your project -grows, you’ll want to manage all the options and make it easy to share your -code. Next, we’ll introduce you to the Cargo tool, which will help you write -real-world Rust programs. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch01-02-hello-world.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch01-03-hello-cargo.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch01-03-hello-cargo.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch01-03-hello-cargo.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch01-03-hello-cargo.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,243 +1,10 @@ ## Hello, Cargo! -Cargo is Rust’s build system and package manager. Most Rustaceans use this tool -to manage their Rust projects because Cargo handles a lot of tasks for you, -such as building your code, downloading the libraries your code depends on, and -building those libraries. (We call libraries your code needs *dependencies*.) +The 2018 edition of the book is no longer distributed with Rust's documentation. -The simplest Rust programs, like the one we’ve written so far, don’t have any -dependencies. So if we had built the Hello, world! project with Cargo, it would -only use the part of Cargo that handles building your code. As you write more -complex Rust programs, you’ll add dependencies, and if you start a project -using Cargo, adding dependencies will be much easier to do. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -Because the vast majority of Rust projects use Cargo, the rest of this book -assumes that you’re using Cargo too. Cargo comes installed with Rust if you -used the official installers discussed in the “Installation” section. If you -installed Rust through some other means, check whether Cargo is installed by -entering the following into your terminal: - -```text -$ cargo --version -``` - -If you see a version number, you have it! If you see an error, such as `command -not found`, look at the documentation for your method of installation to -determine how to install Cargo separately. - -### Creating a Project with Cargo - -Let’s create a new project using Cargo and look at how it differs from our -original Hello, world! project. Navigate back to your *projects* directory (or -wherever you decided to store your code). Then, on any operating system, run -the following: - -```text -$ cargo new hello_cargo -$ cd hello_cargo -``` - -The first command creates a new directory called *hello_cargo*. We’ve named -our project *hello_cargo*, and Cargo creates its files in a directory of the -same name. - -Go into the *hello_cargo* directory and list the files. You’ll see that Cargo -has generated two files and one directory for us: a *Cargo.toml* file and a -*src* directory with a *main.rs* file inside. It has also initialized a new Git -repository along with a *.gitignore* file. - -> Note: Git is a common version control system. You can change `cargo new` to -> use a different version control system or no version control system by using -> the `--vcs` flag. Run `cargo new --help` to see the available options. - -Open *Cargo.toml* in your text editor of choice. It should look similar to the -code in Listing 1-2. - -Filename: Cargo.toml - -```toml -[package] -name = "hello_cargo" -version = "0.1.0" -authors = ["Your Name "] - -[dependencies] -``` - -Listing 1-2: Contents of *Cargo.toml* generated by `cargo -new` - -This file is in the [*TOML*][toml] (*Tom’s Obvious, Minimal -Language*) format, which is Cargo’s configuration format. - -[toml]: https://github.com/toml-lang/toml - -The first line, `[package]`, is a section heading that indicates that the -following statements are configuring a package. As we add more information to -this file, we’ll add other sections. - -The next three lines set the configuration information Cargo needs to compile -your program: the name, the version, and who wrote it. Cargo gets your name and -email information from your environment, so if that information is not correct, -fix the information now and then save the file. - -The last line, `[dependencies]`, is the start of a section for you to list any -of your project’s dependencies. In Rust, packages of code are referred to as -*crates*. We won’t need any other crates for this project, but we will in the -first project in Chapter 2, so we’ll use this dependencies section then. - -Now open *src/main.rs* and take a look: - -Filename: src/main.rs - -```rust -fn main() { - println!("Hello, world!"); -} -``` - -Cargo has generated a Hello, world! program for you, just like the one we wrote -in Listing 1-1! So far, the differences between our previous project and the -project Cargo generates are that Cargo placed the code in the *src* directory, -and we have a *Cargo.toml* configuration file in the top directory. - -Cargo expects your source files to live inside the *src* directory. The -top-level project directory is just for README files, license information, -configuration files, and anything else not related to your code. Using Cargo -helps you organize your projects. There’s a place for everything, and -everything is in its place. - -If you started a project that doesn’t use Cargo, as we did with the Hello, -world! project, you can convert it to a project that does use Cargo. Move the -project code into the *src* directory and create an appropriate *Cargo.toml* -file. - -### Building and Running a Cargo Project - -Now let’s look at what’s different when we build and run the Hello, world! -program with Cargo! From your *hello_cargo* directory, build your project by -entering the following command: - -```text -$ cargo build - Compiling hello_cargo v0.1.0 (file:///projects/hello_cargo) - Finished dev [unoptimized + debuginfo] target(s) in 2.85 secs -``` - -This command creates an executable file in *target/debug/hello_cargo* (or -*target\debug\hello_cargo.exe* on Windows) rather than in your current -directory. You can run the executable with this command: - -```text -$ ./target/debug/hello_cargo # or .\target\debug\hello_cargo.exe on Windows -Hello, world! -``` - -If all goes well, `Hello, world!` should print to the terminal. Running `cargo -build` for the first time also causes Cargo to create a new file at the top -level: *Cargo.lock*. This file keeps track of the exact versions of -dependencies in your project. This project doesn’t have dependencies, so the -file is a bit sparse. You won’t ever need to change this file manually; Cargo -manages its contents for you. - -We just built a project with `cargo build` and ran it with -`./target/debug/hello_cargo`, but we can also use `cargo run` to compile the -code and then run the resulting executable all in one command: - -```text -$ cargo run - Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs - Running `target/debug/hello_cargo` -Hello, world! -``` - -Notice that this time we didn’t see output indicating that Cargo was compiling -`hello_cargo`. Cargo figured out that the files hadn’t changed, so it just ran -the binary. If you had modified your source code, Cargo would have rebuilt the -project before running it, and you would have seen this output: - -```text -$ cargo run - Compiling hello_cargo v0.1.0 (file:///projects/hello_cargo) - Finished dev [unoptimized + debuginfo] target(s) in 0.33 secs - Running `target/debug/hello_cargo` -Hello, world! -``` - -Cargo also provides a command called `cargo check`. This command quickly checks -your code to make sure it compiles but doesn’t produce an executable: - -```text -$ cargo check - Checking hello_cargo v0.1.0 (file:///projects/hello_cargo) - Finished dev [unoptimized + debuginfo] target(s) in 0.32 secs -``` - -Why would you not want an executable? Often, `cargo check` is much faster than -`cargo build`, because it skips the step of producing an executable. If you’re -continually checking your work while writing the code, using `cargo check` will -speed up the process! As such, many Rustaceans run `cargo check` periodically -as they write their program to make sure it compiles. Then they run `cargo -build` when they’re ready to use the executable. - -Let’s recap what we’ve learned so far about Cargo: - -* We can build a project using `cargo build` or `cargo check`. -* We can build and run a project in one step using `cargo run`. -* Instead of saving the result of the build in the same directory as our code, - Cargo stores it in the *target/debug* directory. - -An additional advantage of using Cargo is that the commands are the same no -matter which operating system you’re working on. So, at this point, we’ll no -longer provide specific instructions for Linux and macOS versus Windows. - -### Building for Release - -When your project is finally ready for release, you can use `cargo build ---release` to compile it with optimizations. This command will create an -executable in *target/release* instead of *target/debug*. The optimizations -make your Rust code run faster, but turning them on lengthens the time it takes -for your program to compile. This is why there are two different profiles: one -for development, when you want to rebuild quickly and often, and another for -building the final program you’ll give to a user that won’t be rebuilt -repeatedly and that will run as fast as possible. If you’re benchmarking your -code’s running time, be sure to run `cargo build --release` and benchmark with -the executable in *target/release*. - -### Cargo as Convention - -With simple projects, Cargo doesn’t provide a lot of value over just using -`rustc`, but it will prove its worth as your programs become more intricate. -With complex projects composed of multiple crates, it’s much easier to let -Cargo coordinate the build. - -Even though the `hello_cargo` project is simple, it now uses much of the real -tooling you’ll use in the rest of your Rust career. In fact, to work on any -existing projects, you can use the following commands to check out the code -using Git, change to that project’s directory, and build: - -```text -$ git clone someurl.com/someproject -$ cd someproject -$ cargo build -``` - -For more information about Cargo, check out [its documentation]. - -[its documentation]: https://doc.rust-lang.org/cargo/ - -## Summary - -You’re already off to a great start on your Rust journey! In this chapter, -you’ve learned how to: - -* Install the latest stable version of Rust using `rustup` -* Update to a newer Rust version -* Open locally installed documentation -* Write and run a Hello, world! program using `rustc` directly -* Create and run a new project using the conventions of Cargo - -This is a great time to build a more substantial program to get used to reading -and writing Rust code. So, in Chapter 2, we’ll build a guessing game program. -If you would rather start by learning how common programming concepts work in -Rust, see Chapter 3 and then return to Chapter 2. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch01-03-hello-cargo.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch02-00-guessing-game-tutorial.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch02-00-guessing-game-tutorial.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch02-00-guessing-game-tutorial.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch02-00-guessing-game-tutorial.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,1010 +1,10 @@ # Programming a Guessing Game -Let’s jump into Rust by working through a hands-on project together! This -chapter introduces you to a few common Rust concepts by showing you how to use -them in a real program. You’ll learn about `let`, `match`, methods, associated -functions, using external crates, and more! The following chapters will explore -these ideas in more detail. In this chapter, you’ll practice the fundamentals. +The 2018 edition of the book is no longer distributed with Rust's documentation. -We’ll implement a classic beginner programming problem: a guessing game. Here’s -how it works: the program will generate a random integer between 1 and 100. It -will then prompt the player to enter a guess. After a guess is entered, the -program will indicate whether the guess is too low or too high. If the guess is -correct, the game will print a congratulatory message and exit. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -## Setting Up a New Project - -To set up a new project, go to the *projects* directory that you created in -Chapter 1 and make a new project using Cargo, like so: - -```text -$ cargo new guessing_game -$ cd guessing_game -``` - -The first command, `cargo new`, takes the name of the project (`guessing_game`) -as the first argument. The second command changes to the new project’s -directory. - -Look at the generated *Cargo.toml* file: - -Filename: Cargo.toml - -```toml -[package] -name = "guessing_game" -version = "0.1.0" -authors = ["Your Name "] - -[dependencies] -``` - -If the author information that Cargo obtained from your environment is not -correct, fix that in the file and save it again. - -As you saw in Chapter 1, `cargo new` generates a “Hello, world!” program for -you. Check out the *src/main.rs* file: - -Filename: src/main.rs - -```rust -fn main() { - println!("Hello, world!"); -} -``` - -Now let’s compile this “Hello, world!” program and run it in the same step -using the `cargo run` command: - -```text -$ cargo run - Compiling guessing_game v0.1.0 (file:///projects/guessing_game) - Finished dev [unoptimized + debuginfo] target(s) in 1.50 secs - Running `target/debug/guessing_game` -Hello, world! -``` - -The `run` command comes in handy when you need to rapidly iterate on a project, -as we’ll do in this game, quickly testing each iteration before moving on to -the next one. - -Reopen the *src/main.rs* file. You’ll be writing all the code in this file. - -## Processing a Guess - -The first part of the guessing game program will ask for user input, process -that input, and check that the input is in the expected form. To start, we’ll -allow the player to input a guess. Enter the code in Listing 2-1 into -*src/main.rs*. - -Filename: src/main.rs - -```rust,ignore -use std::io; - -fn main() { - println!("Guess the number!"); - - println!("Please input your guess."); - - let mut guess = String::new(); - - io::stdin().read_line(&mut guess) - .expect("Failed to read line"); - - println!("You guessed: {}", guess); -} -``` - -Listing 2-1: Code that gets a guess from the user and -prints it - -This code contains a lot of information, so let’s go over it line by line. To -obtain user input and then print the result as output, we need to bring the -`io` (input/output) library into scope. The `io` library comes from the -standard library (which is known as `std`): - -```rust,ignore -use std::io; -``` - -By default, Rust brings only a few types into the scope of every program in -[the *prelude*][prelude]. If a type you want to use isn’t in the -prelude, you have to bring that type into scope explicitly with a `use` -statement. Using the `std::io` library provides you with a number of useful -features, including the ability to accept user input. - -[prelude]: ../../std/prelude/index.html - -As you saw in Chapter 1, the `main` function is the entry point into the -program: - -```rust,ignore -fn main() { -``` - -The `fn` syntax declares a new function, the parentheses, `()`, indicate there -are no parameters, and the curly bracket, `{`, starts the body of the function. - -As you also learned in Chapter 1, `println!` is a macro that prints a string to -the screen: - -```rust,ignore -println!("Guess the number!"); - -println!("Please input your guess."); -``` - -This code is printing a prompt stating what the game is and requesting input -from the user. - -### Storing Values with Variables - -Next, we’ll create a place to store the user input, like this: - -```rust,ignore -let mut guess = String::new(); -``` - -Now the program is getting interesting! There’s a lot going on in this little -line. Notice that this is a `let` statement, which is used to create a -*variable*. Here’s another example: - -```rust,ignore -let foo = bar; -``` - -This line creates a new variable named `foo` and binds it to the value of the -`bar` variable. In Rust, variables are immutable by default. We’ll be -discussing this concept in detail in the “Variables and Mutability” section in -Chapter 3. The following example shows how to use `mut` before the variable -name to make a variable mutable: - -```rust,ignore -let foo = 5; // immutable -let mut bar = 5; // mutable -``` - -> Note: The `//` syntax starts a comment that continues until the end of the -> line. Rust ignores everything in comments, which are discussed in more detail -> in Chapter 3. - -Now you know that `let mut guess` will introduce a mutable variable named -`guess`. On the other side of the equal sign (`=`) is the value that `guess` is -bound to, which is the result of calling `String::new`, a function that returns -a new instance of a `String`. [`String`][string] is a string -type provided by the standard library that is a growable, UTF-8 encoded bit of -text. - -[string]: ../../std/string/struct.String.html - -The `::` syntax in the `::new` line indicates that `new` is an *associated -function* of the `String` type. An associated function is implemented on a type, -in this case `String`, rather than on a particular instance of a `String`. Some -languages call this a *static method*. - -This `new` function creates a new, empty string. You’ll find a `new` function -on many types, because it’s a common name for a function that makes a new value -of some kind. - -To summarize, the `let mut guess = String::new();` line has created a mutable -variable that is currently bound to a new, empty instance of a `String`. Whew! - -Recall that we included the input/output functionality from the standard -library with `use std::io;` on the first line of the program. Now we’ll call an -associated function, `stdin`, on `io`: - -```rust,ignore -io::stdin().read_line(&mut guess) - .expect("Failed to read line"); -``` - -If we hadn’t listed the `use std::io` line at the beginning of the program, we -could have written this function call as `std::io::stdin`. The `stdin` function -returns an instance of [`std::io::Stdin`][iostdin], which is a -type that represents a handle to the standard input for your terminal. - -[iostdin]: ../../std/io/struct.Stdin.html - -The next part of the code, `.read_line(&mut guess)`, calls the -[`read_line`][read_line] method on the standard input handle to -get input from the user. We’re also passing one argument to `read_line`: `&mut -guess`. - -[read_line]: ../../std/io/struct.Stdin.html#method.read_line - -The job of `read_line` is to take whatever the user types into standard input -and place that into a string, so it takes that string as an argument. The -string argument needs to be mutable so the method can change the string’s -content by adding the user input. - -The `&` indicates that this argument is a *reference*, which gives you a way to -let multiple parts of your code access one piece of data without needing to -copy that data into memory multiple times. References are a complex feature, -and one of Rust’s major advantages is how safe and easy it is to use -references. You don’t need to know a lot of those details to finish this -program. For now, all you need to know is that like variables, references are -immutable by default. Hence, you need to write `&mut guess` rather than -`&guess` to make it mutable. (Chapter 4 will explain references more -thoroughly.) - -### Handling Potential Failure with the `Result` Type - -We’re not quite done with this line of code. Although what we’ve discussed so -far is a single line of text, it’s only the first part of the single logical -line of code. The second part is this method: - -```rust,ignore -.expect("Failed to read line"); -``` - -When you call a method with the `.foo()` syntax, it’s often wise to introduce a -newline and other whitespace to help break up long lines. We could have -written this code as: - -```rust,ignore -io::stdin().read_line(&mut guess).expect("Failed to read line"); -``` - -However, one long line is difficult to read, so it’s best to divide it: two -lines for two method calls. Now let’s discuss what this line does. - -As mentioned earlier, `read_line` puts what the user types into the string -we’re passing it, but it also returns a value—in this case, an -[`io::Result`][ioresult]. Rust has a number of types named -`Result` in its standard library: a generic [`Result`][result] -as well as specific versions for submodules, such as `io::Result`. - -[ioresult]: ../../std/io/type.Result.html -[result]: ../../std/result/enum.Result.html - -The `Result` types are [*enumerations*][enums], often referred -to as *enums*. An enumeration is a type that can have a fixed set of values, -and those values are called the enum’s *variants*. Chapter 6 will cover enums -in more detail. - -[enums]: ch06-00-enums.html - -For `Result`, the variants are `Ok` or `Err`. The `Ok` variant indicates the -operation was successful, and inside `Ok` is the successfully generated value. -The `Err` variant means the operation failed, and `Err` contains information -about how or why the operation failed. - -The purpose of these `Result` types is to encode error-handling information. -Values of the `Result` type, like any type, have methods defined on them. An -instance of `io::Result` has an [`expect` method][expect] that -you can call. If this instance of `io::Result` is an `Err` value, `expect` will -cause the program to crash and display the message that you passed as an -argument to `expect`. If the `read_line` method returns an `Err`, it would -likely be the result of an error coming from the underlying operating system. -If this instance of `io::Result` is an `Ok` value, `expect` will take the -return value that `Ok` is holding and return just that value to you so you -can use it. In this case, that value is the number of bytes in what the user -entered into standard input. - -[expect]: ../../std/result/enum.Result.html#method.expect - -If you don’t call `expect`, the program will compile, but you’ll get a warning: - -```text -$ cargo build - Compiling guessing_game v0.1.0 (file:///projects/guessing_game) -warning: unused `std::result::Result` which must be used - --> src/main.rs:10:5 - | -10 | io::stdin().read_line(&mut guess); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: #[warn(unused_must_use)] on by default -``` - -Rust warns that you haven’t used the `Result` value returned from `read_line`, -indicating that the program hasn’t handled a possible error. - -The right way to suppress the warning is to actually write error handling, but -since you just want to crash this program when a problem occurs, you can use -`expect`. You’ll learn about recovering from errors in Chapter 9. - -### Printing Values with `println!` Placeholders - -Aside from the closing curly brackets, there’s only one more line to discuss in -the code added so far, which is the following: - -```rust,ignore -println!("You guessed: {}", guess); -``` - -This line prints the string we saved the user’s input in. The set of curly -brackets, `{}`, is a placeholder: think of `{}` as little crab pincers that -hold a value in place. You can print more than one value using curly brackets: -the first set of curly brackets holds the first value listed after the format -string, the second set holds the second value, and so on. Printing multiple -values in one call to `println!` would look like this: - -```rust -let x = 5; -let y = 10; - -println!("x = {} and y = {}", x, y); -``` - -This code would print `x = 5 and y = 10`. - -### Testing the First Part - -Let’s test the first part of the guessing game. Run it using `cargo run`: - -```text -$ cargo run - Compiling guessing_game v0.1.0 (file:///projects/guessing_game) - Finished dev [unoptimized + debuginfo] target(s) in 2.53 secs - Running `target/debug/guessing_game` -Guess the number! -Please input your guess. -6 -You guessed: 6 -``` - -At this point, the first part of the game is done: we’re getting input from the -keyboard and then printing it. - -## Generating a Secret Number - -Next, we need to generate a secret number that the user will try to guess. The -secret number should be different every time so the game is fun to play more -than once. Let’s use a random number between 1 and 100 so the game isn’t too -difficult. Rust doesn’t yet include random number functionality in its standard -library. However, the Rust team does provide a [`rand` crate][randcrate]. - -[randcrate]: https://crates.io/crates/rand - -### Using a Crate to Get More Functionality - -Remember that a crate is a package of Rust code. The project we’ve been -building is a *binary crate*, which is an executable. The `rand` crate is a -*library crate*, which contains code intended to be used in other programs. - -Cargo’s use of external crates is where it really shines. Before we can write -code that uses `rand`, we need to modify the *Cargo.toml* file to include the -`rand` crate as a dependency. Open that file now and add the following line to -the bottom beneath the `[dependencies]` section header that Cargo created for -you: - -Filename: Cargo.toml - -```toml -[dependencies] - -rand = "0.3.14" -``` - -In the *Cargo.toml* file, everything that follows a header is part of a section -that continues until another section starts. The `[dependencies]` section is -where you tell Cargo which external crates your project depends on and which -versions of those crates you require. In this case, we’ll specify the `rand` -crate with the semantic version specifier `0.3.14`. Cargo understands [Semantic -Versioning][semver] (sometimes called *SemVer*), which is a -standard for writing version numbers. The number `0.3.14` is actually shorthand -for `^0.3.14`, which means “any version that has a public API compatible with -version 0.3.14.” - -[semver]: http://semver.org - -Now, without changing any of the code, let’s build the project, as shown in -Listing 2-2: - -```text -$ cargo build - Updating registry `https://github.com/rust-lang/crates.io-index` - Downloading rand v0.3.14 - Downloading libc v0.2.14 - Compiling libc v0.2.14 - Compiling rand v0.3.14 - Compiling guessing_game v0.1.0 (file:///projects/guessing_game) - Finished dev [unoptimized + debuginfo] target(s) in 2.53 secs -``` - -Listing 2-2: The output from running `cargo build` after -adding the rand crate as a dependency - -You may see different version numbers (but they will all be compatible with -the code, thanks to SemVer!), and the lines may be in a different order. - -Now that we have an external dependency, Cargo fetches the latest versions of -everything from the *registry*, which is a copy of data from -[Crates.io][cratesio]. Crates.io is where people in the Rust ecosystem post -their open source Rust projects for others to use. - -[cratesio]: https://crates.io - -After updating the registry, Cargo checks the `[dependencies]` section and -downloads any crates you don’t have yet. In this case, although we only listed -`rand` as a dependency, Cargo also grabbed a copy of `libc`, because `rand` -depends on `libc` to work. After downloading the crates, Rust compiles them and -then compiles the project with the dependencies available. - -If you immediately run `cargo build` again without making any changes, you -won’t get any output aside from the `Finished` line. Cargo knows it has already -downloaded and compiled the dependencies, and you haven’t changed anything -about them in your *Cargo.toml* file. Cargo also knows that you haven’t changed -anything about your code, so it doesn’t recompile that either. With nothing to -do, it simply exits. - -If you open up the *src/main.rs* file, make a trivial change, and then save it -and build again, you’ll only see two lines of output: - -```text -$ cargo build - Compiling guessing_game v0.1.0 (file:///projects/guessing_game) - Finished dev [unoptimized + debuginfo] target(s) in 2.53 secs -``` - -These lines show Cargo only updates the build with your tiny change to the -*src/main.rs* file. Your dependencies haven’t changed, so Cargo knows it can -reuse what it has already downloaded and compiled for those. It just rebuilds -your part of the code. - -#### Ensuring Reproducible Builds with the *Cargo.lock* File - -Cargo has a mechanism that ensures you can rebuild the same artifact every time -you or anyone else builds your code: Cargo will use only the versions of the -dependencies you specified until you indicate otherwise. For example, what -happens if next week version `v0.3.15` of the `rand` crate comes out and -contains an important bug fix but also contains a regression that will break -your code? - -The answer to this problem is the *Cargo.lock* file, which was created the -first time you ran `cargo build` and is now in your *guessing_game* directory. -When you build a project for the first time, Cargo figures out all the -versions of the dependencies that fit the criteria and then writes them to -the *Cargo.lock* file. When you build your project in the future, Cargo will -see that the *Cargo.lock* file exists and use the versions specified there -rather than doing all the work of figuring out versions again. This lets you -have a reproducible build automatically. In other words, your project will -remain at `0.3.14` until you explicitly upgrade, thanks to the *Cargo.lock* -file. - -#### Updating a Crate to Get a New Version - -When you *do* want to update a crate, Cargo provides another command, `update`, -which will ignore the *Cargo.lock* file and figure out all the latest versions -that fit your specifications in *Cargo.toml*. If that works, Cargo will write -those versions to the *Cargo.lock* file. - -But by default, Cargo will only look for versions larger than `0.3.0` and -smaller than `0.4.0`. If the `rand` crate has released two new versions, -`0.3.15` and `0.4.0`, you would see the following if you ran `cargo update`: - -```text -$ cargo update - Updating registry `https://github.com/rust-lang/crates.io-index` - Updating rand v0.3.14 -> v0.3.15 -``` - -At this point, you would also notice a change in your *Cargo.lock* file noting -that the version of the `rand` crate you are now using is `0.3.15`. - -If you wanted to use `rand` version `0.4.0` or any version in the `0.4.x` -series, you’d have to update the *Cargo.toml* file to look like this instead: - -```toml -[dependencies] - -rand = "0.4.0" -``` - -The next time you run `cargo build`, Cargo will update the registry of crates -available and reevaluate your `rand` requirements according to the new version -you have specified. - -There’s a lot more to say about [Cargo][doccargo] and [its -ecosystem][doccratesio] which we’ll discuss in Chapter 14, but -for now, that’s all you need to know. Cargo makes it very easy to reuse -libraries, so Rustaceans are able to write smaller projects that are assembled -from a number of packages. - -[doccargo]: http://doc.crates.io -[doccratesio]: http://doc.crates.io/crates-io.html - -### Generating a Random Number - -Now that you’ve added the `rand` crate to *Cargo.toml*, let’s start using -`rand`. The next step is to update *src/main.rs*, as shown in Listing 2-3: - -Filename: src/main.rs - -```rust,ignore -extern crate rand; - -use std::io; -use rand::Rng; - -fn main() { - println!("Guess the number!"); - - let secret_number = rand::thread_rng().gen_range(1, 101); - - println!("The secret number is: {}", secret_number); - - println!("Please input your guess."); - - let mut guess = String::new(); - - io::stdin().read_line(&mut guess) - .expect("Failed to read line"); - - println!("You guessed: {}", guess); -} -``` - -Listing 2-3: Adding code to generate a random -number - -First, we add a line that lets Rust know we’ll be using the `rand` crate as an -external dependency. This also does the equivalent of calling `use rand`, so -now we can call anything in the `rand` crate by placing `rand::` before it. - -Next, we add another `use` line: `use rand::Rng`. The `Rng` trait defines -methods that random number generators implement, and this trait must be in -scope for us to use those methods. Chapter 10 will cover traits in detail. - -Also, we’re adding two more lines in the middle. The `rand::thread_rng` function -will give us the particular random number generator that we’re going to use: -one that is local to the current thread of execution and seeded by the -operating system. Next, we call the `gen_range` method on the random number -generator. This method is defined by the `Rng` trait that we brought into -scope with the `use rand::Rng` statement. The `gen_range` method takes two -numbers as arguments and generates a random number between them. It’s inclusive -on the lower bound but exclusive on the upper bound, so we need to specify `1` -and `101` to request a number between 1 and 100. - -> Note: You won’t just know which traits to use and which methods and functions -> to call from a crate. Instructions for using a crate are in each crate’s -> documentation. Another neat feature of Cargo is that you can run the `cargo -> doc --open` command, which will build documentation provided by all of your -> dependencies locally and open it in your browser. If you’re interested in -> other functionality in the `rand` crate, for example, run `cargo doc --open` -> and click `rand` in the sidebar on the left. - -The second line that we added to the code prints the secret number. This is -useful while we’re developing the program to be able to test it, but we’ll -delete it from the final version. It’s not much of a game if the program prints -the answer as soon as it starts! - -Try running the program a few times: - -```text -$ cargo run - Compiling guessing_game v0.1.0 (file:///projects/guessing_game) - Finished dev [unoptimized + debuginfo] target(s) in 2.53 secs - Running `target/debug/guessing_game` -Guess the number! -The secret number is: 7 -Please input your guess. -4 -You guessed: 4 -$ cargo run - Running `target/debug/guessing_game` -Guess the number! -The secret number is: 83 -Please input your guess. -5 -You guessed: 5 -``` - -You should get different random numbers, and they should all be numbers between -1 and 100. Great job! - -## Comparing the Guess to the Secret Number - -Now that we have user input and a random number, we can compare them. That step -is shown in Listing 2-4. Note that this code won’t compile quite yet, as we -will explain. - -Filename: src/main.rs - -```rust,ignore -extern crate rand; - -use std::io; -use std::cmp::Ordering; -use rand::Rng; - -fn main() { - // ---snip--- - - println!("You guessed: {}", guess); - - match guess.cmp(&secret_number) { - Ordering::Less => println!("Too small!"), - Ordering::Greater => println!("Too big!"), - Ordering::Equal => println!("You win!"), - } -} -``` - -Listing 2-4: Handling the possible return values of -comparing two numbers - -The first new bit here is another `use` statement, bringing a type called -`std::cmp::Ordering` into scope from the standard library. Like `Result`, -`Ordering` is another enum, but the variants for `Ordering` are `Less`, -`Greater`, and `Equal`. These are the three outcomes that are possible when you -compare two values. - -Then we add five new lines at the bottom that use the `Ordering` type. - -The `cmp` method compares two values and can be called on anything that can be -compared. It takes a reference to whatever you want to compare with: here it’s -comparing the `guess` to the `secret_number`. Then it returns a variant of the -`Ordering` enum we brought into scope with the `use` statement. We use a -[`match`][match] expression to decide what to do next based on -which variant of `Ordering` was returned from the call to `cmp` with the values -in `guess` and `secret_number`. - -[match]: ch06-02-match.html - -A `match` expression is made up of *arms*. An arm consists of a *pattern* and -the code that should be run if the value given to the beginning of the `match` -expression fits that arm’s pattern. Rust takes the value given to `match` and -looks through each arm’s pattern in turn. The `match` construct and patterns -are powerful features in Rust that let you express a variety of situations your -code might encounter and make sure that you handle them all. These features -will be covered in detail in Chapter 6 and Chapter 18, respectively. - -Let’s walk through an example of what would happen with the `match` expression -used here. Say that the user has guessed 50 and the randomly generated secret -number this time is 38. When the code compares 50 to 38, the `cmp` method will -return `Ordering::Greater`, because 50 is greater than 38. The `match` -expression gets the `Ordering::Greater` value and starts checking each arm’s -pattern. It looks at the first arm’s pattern, `Ordering::Less`, and sees that -the value `Ordering::Greater` does not match `Ordering::Less`, so it ignores -the code in that arm and moves to the next arm. The next arm’s pattern, -`Ordering::Greater`, *does* match `Ordering::Greater`! The associated code in -that arm will execute and print `Too big!` to the screen. The `match` -expression ends because it has no need to look at the last arm in this scenario. - -However, the code in Listing 2-4 won’t compile yet. Let’s try it: - -```text -$ cargo build - Compiling guessing_game v0.1.0 (file:///projects/guessing_game) -error[E0308]: mismatched types - --> src/main.rs:23:21 - | -23 | match guess.cmp(&secret_number) { - | ^^^^^^^^^^^^^^ expected struct `std::string::String`, found integral variable - | - = note: expected type `&std::string::String` - = note: found type `&{integer}` - -error: aborting due to previous error -Could not compile `guessing_game`. -``` - -The core of the error states that there are *mismatched types*. Rust has a -strong, static type system. However, it also has type inference. When we wrote -`let mut guess = String::new();`, Rust was able to infer that `guess` should be -a `String` and didn’t make us write the type. The `secret_number`, on the other -hand, is a number type. A few number types can have a value between 1 and 100: -`i32`, a 32-bit number; `u32`, an unsigned 32-bit number; `i64`, a 64-bit -number; as well as others. Rust defaults to an `i32`, which is the type of -`secret_number` unless you add type information elsewhere that would cause Rust -to infer a different numerical type. The reason for the error is that Rust -cannot compare a string and a number type. - -Ultimately, we want to convert the `String` the program reads as input into a -real number type so we can compare it numerically to the guess. We can do that -by adding the following two lines to the `main` function body: - -Filename: src/main.rs - -```rust,ignore -// --snip-- - - let mut guess = String::new(); - - io::stdin().read_line(&mut guess) - .expect("Failed to read line"); - - let guess: u32 = guess.trim().parse() - .expect("Please type a number!"); - - println!("You guessed: {}", guess); - - match guess.cmp(&secret_number) { - Ordering::Less => println!("Too small!"), - Ordering::Greater => println!("Too big!"), - Ordering::Equal => println!("You win!"), - } -} -``` - -The two new lines are: - -```rust,ignore -let guess: u32 = guess.trim().parse() - .expect("Please type a number!"); -``` - -We create a variable named `guess`. But wait, doesn’t the program already have -a variable named `guess`? It does, but Rust allows us to *shadow* the previous -value of `guess` with a new one. This feature is often used in situations in -which you want to convert a value from one type to another type. Shadowing lets -us reuse the `guess` variable name rather than forcing us to create two unique -variables, like `guess_str` and `guess` for example. (Chapter 3 covers -shadowing in more detail.) - -We bind `guess` to the expression `guess.trim().parse()`. The `guess` in the -expression refers to the original `guess` that was a `String` with the input in -it. The `trim` method on a `String` instance will eliminate any whitespace at -the beginning and end. Although `u32` can contain only numerical characters, -the user must press enter to satisfy -`read_line`. When the user presses enter, a -newline character is added to the string. For example, if the user types 5 and presses enter, -`guess` looks like this: `5\n`. The `\n` represents “newline,” the result of -pressing enter. The `trim` method eliminates -`\n`, resulting in just `5`. - -The [`parse` method on strings][parse] parses a string into some -kind of number. Because this method can parse a variety of number types, we -need to tell Rust the exact number type we want by using `let guess: u32`. The -colon (`:`) after `guess` tells Rust we’ll annotate the variable’s type. Rust -has a few built-in number types; the `u32` seen here is an unsigned, 32-bit -integer. It’s a good default choice for a small positive number. You’ll learn -about other number types in Chapter 3. Additionally, the `u32` annotation in -this example program and the comparison with `secret_number` means that Rust -will infer that `secret_number` should be a `u32` as well. So now the -comparison will be between two values of the same type! - -[parse]: ../../std/primitive.str.html#method.parse - -The call to `parse` could easily cause an error. If, for example, the string -contained `A👍%`, there would be no way to convert that to a number. Because it -might fail, the `parse` method returns a `Result` type, much as the `read_line` -method does (discussed earlier in “Handling Potential Failure with the Result -Type”). We’ll treat this `Result` the same way by using the `expect` method -again. If `parse` returns an `Err` `Result` variant because it couldn’t create -a number from the string, the `expect` call will crash the game and print the -message we give it. If `parse` can successfully convert the string to a number, -it will return the `Ok` variant of `Result`, and `expect` will return the -number that we want from the `Ok` value. - -Let’s run the program now! - -```text -$ cargo run - Compiling guessing_game v0.1.0 (file:///projects/guessing_game) - Finished dev [unoptimized + debuginfo] target(s) in 0.43 secs - Running `target/guessing_game` -Guess the number! -The secret number is: 58 -Please input your guess. - 76 -You guessed: 76 -Too big! -``` - -Nice! Even though spaces were added before the guess, the program still figured -out that the user guessed 76. Run the program a few times to verify the -different behavior with different kinds of input: guess the number correctly, -guess a number that is too high, and guess a number that is too low. - -We have most of the game working now, but the user can make only one guess. -Let’s change that by adding a loop! - -## Allowing Multiple Guesses with Looping - -The `loop` keyword creates an infinite loop. We’ll add that now to give users -more chances at guessing the number: - -Filename: src/main.rs - -```rust,ignore -// --snip-- - - println!("The secret number is: {}", secret_number); - - loop { - println!("Please input your guess."); - - // --snip-- - - match guess.cmp(&secret_number) { - Ordering::Less => println!("Too small!"), - Ordering::Greater => println!("Too big!"), - Ordering::Equal => println!("You win!"), - } - } -} -``` - -As you can see, we’ve moved everything into a loop from the guess input prompt -onward. Be sure to indent the lines inside the loop another four spaces each -and run the program again. Notice that there is a new problem because the -program is doing exactly what we told it to do: ask for another guess forever! -It doesn’t seem like the user can quit! - -The user could always halt the program by using the keyboard shortcut ctrl-c. But there’s another way to escape this -insatiable monster, as mentioned in the `parse` discussion in “Comparing the -Guess to the Secret Number”: if the user enters a non-number answer, the -program will crash. The user can take advantage of that in order to quit, as -shown here: - -```text -$ cargo run - Compiling guessing_game v0.1.0 (file:///projects/guessing_game) - Finished dev [unoptimized + debuginfo] target(s) in 1.50 secs - Running `target/guessing_game` -Guess the number! -The secret number is: 59 -Please input your guess. -45 -You guessed: 45 -Too small! -Please input your guess. -60 -You guessed: 60 -Too big! -Please input your guess. -59 -You guessed: 59 -You win! -Please input your guess. -quit -thread 'main' panicked at 'Please type a number!: ParseIntError { kind: InvalidDigit }', src/libcore/result.rs:785 -note: Run with `RUST_BACKTRACE=1` for a backtrace. -error: Process didn't exit successfully: `target/debug/guess` (exit code: 101) -``` - -Typing `quit` actually quits the game, but so will any other non-number input. -However, this is suboptimal to say the least. We want the game to automatically -stop when the correct number is guessed. - -### Quitting After a Correct Guess - -Let’s program the game to quit when the user wins by adding a `break` statement: - -Filename: src/main.rs - -```rust,ignore -// --snip-- - - match guess.cmp(&secret_number) { - Ordering::Less => println!("Too small!"), - Ordering::Greater => println!("Too big!"), - Ordering::Equal => { - println!("You win!"); - break; - } - } - } -} -``` - -Adding the `break` line after `You win!` makes the program exit the loop when -the user guesses the secret number correctly. Exiting the loop also means -exiting the program, because the loop is the last part of `main`. - -### Handling Invalid Input - -To further refine the game’s behavior, rather than crashing the program when -the user inputs a non-number, let’s make the game ignore a non-number so the -user can continue guessing. We can do that by altering the line where `guess` -is converted from a `String` to a `u32`: - -```rust,ignore -let guess: u32 = match guess.trim().parse() { - Ok(num) => num, - Err(_) => continue, -}; -``` - -Switching from an `expect` call to a `match` expression is how you generally -move from crashing on an error to handling the error. Remember that `parse` -returns a `Result` type and `Result` is an enum that has the variants `Ok` or -`Err`. We’re using a `match` expression here, as we did with the `Ordering` -result of the `cmp` method. - -If `parse` is able to successfully turn the string into a number, it will -return an `Ok` value that contains the resulting number. That `Ok` value will -match the first arm’s pattern, and the `match` expression will just return the -`num` value that `parse` produced and put inside the `Ok` value. That number -will end up right where we want it in the new `guess` variable we’re creating. - -If `parse` is *not* able to turn the string into a number, it will return an -`Err` value that contains more information about the error. The `Err` value -does not match the `Ok(num)` pattern in the first `match` arm, but it does -match the `Err(_)` pattern in the second arm. The underscore, `_`, is a -catchall value; in this example, we’re saying we want to match all `Err` -values, no matter what information they have inside them. So the program will -execute the second arm’s code, `continue`, which means to go to the next -iteration of the `loop` and ask for another guess. So effectively, the program -ignores all errors that `parse` might encounter! - -Now everything in the program should work as expected. Let’s try it: - -```text -$ cargo run - Compiling guessing_game v0.1.0 (file:///projects/guessing_game) - Running `target/guessing_game` -Guess the number! -The secret number is: 61 -Please input your guess. -10 -You guessed: 10 -Too small! -Please input your guess. -99 -You guessed: 99 -Too big! -Please input your guess. -foo -Please input your guess. -61 -You guessed: 61 -You win! -``` - -Awesome! With one tiny final tweak, we will finish the guessing game. Recall -that the program is still printing the secret number. That worked well for -testing, but it ruins the game. Let’s delete the `println!` that outputs the -secret number. Listing 2-5 shows the final code: - -Filename: src/main.rs - -```rust,ignore -extern crate rand; - -use std::io; -use std::cmp::Ordering; -use rand::Rng; - -fn main() { - println!("Guess the number!"); - - let secret_number = rand::thread_rng().gen_range(1, 101); - - loop { - println!("Please input your guess."); - - let mut guess = String::new(); - - io::stdin().read_line(&mut guess) - .expect("Failed to read line"); - - let guess: u32 = match guess.trim().parse() { - Ok(num) => num, - Err(_) => continue, - }; - - println!("You guessed: {}", guess); - - match guess.cmp(&secret_number) { - Ordering::Less => println!("Too small!"), - Ordering::Greater => println!("Too big!"), - Ordering::Equal => { - println!("You win!"); - break; - } - } - } -} -``` - -Listing 2-5: Complete guessing game code - -## Summary - -At this point, you’ve successfully built the guessing game! Congratulations! - -This project was a hands-on way to introduce you to many new Rust concepts: -`let`, `match`, methods, associated functions, the use of external crates, and -more. In the next few chapters, you’ll learn about these concepts in more -detail. Chapter 3 covers concepts that most programming languages have, such as -variables, data types, and functions, and shows how to use them in Rust. -Chapter 4 explores ownership, a feature that makes Rust different from other -languages. Chapter 5 discusses structs and method syntax, and Chapter 6 -explains how enums work. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch02-00-guessing-game-tutorial.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-00-common-programming-concepts.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-00-common-programming-concepts.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-00-common-programming-concepts.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-00-common-programming-concepts.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,21 +1,10 @@ # Common Programming Concepts -This chapter covers concepts that appear in almost every programming language -and how they work in Rust. Many programming languages have much in common at -their core. None of the concepts presented in this chapter are unique to Rust, -but we’ll discuss them in the context of Rust and explain the conventions -around using these concepts. +The 2018 edition of the book is no longer distributed with Rust's documentation. -Specifically, you’ll learn about variables, basic types, functions, comments, -and control flow. These foundations will be in every Rust program, and learning -them early will give you a strong core to start from. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -> ### Keywords -> -> The Rust language has a set of *keywords* that are reserved for use by -> the language only, much as in other languages. Keep in mind that you cannot -> use these words as names of variables or functions. Most of the keywords have -> special meanings, and you’ll be using them to do various tasks in your Rust -> programs; a few have no current functionality associated with them but have -> been reserved for functionality that might be added to Rust in the future. You -> can find a list of the keywords in Appendix A. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch03-00-common-programming-concepts.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-01-variables-and-mutability.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-01-variables-and-mutability.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-01-variables-and-mutability.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-01-variables-and-mutability.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,229 +1,10 @@ ## Variables and Mutability -As mentioned in Chapter 2, by default variables are immutable. This is one of -many nudges Rust gives you to write your code in a way that takes advantage of -the safety and easy concurrency that Rust offers. However, you still have the -option to make your variables mutable. Let’s explore how and why Rust -encourages you to favor immutability and why sometimes you might want to opt -out. +The 2018 edition of the book is no longer distributed with Rust's documentation. -When a variable is immutable, once a value is bound to a name, you can’t change -that value. To illustrate this, let’s generate a new project called *variables* -in your *projects* directory by using `cargo new variables`. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -Then, in your new *variables* directory, open *src/main.rs* and replace its -code with the following code that won’t compile just yet: - -Filename: src/main.rs - -```rust,ignore -fn main() { - let x = 5; - println!("The value of x is: {}", x); - x = 6; - println!("The value of x is: {}", x); -} -``` - -Save and run the program using `cargo run`. You should receive an error -message, as shown in this output: - -```text -error[E0384]: cannot assign twice to immutable variable `x` - --> src/main.rs:4:5 - | -2 | let x = 5; - | - first assignment to `x` -3 | println!("The value of x is: {}", x); -4 | x = 6; - | ^^^^^ cannot assign twice to immutable variable -``` - -This example shows how the compiler helps you find errors in your programs. -Even though compiler errors can be frustrating, they only mean your program -isn’t safely doing what you want it to do yet; they do *not* mean that you’re -not a good programmer! Experienced Rustaceans still get compiler errors. - -The error indicates that the cause of the error is that you `cannot assign twice -to immutable variable x`, because you tried to assign a second value to the -immutable `x` variable. - -It’s important that we get compile-time errors when we attempt to change a -value that we previously designated as immutable because this very situation -can lead to bugs. If one part of our code operates on the assumption that a -value will never change and another part of our code changes that value, it’s -possible that the first part of the code won’t do what it was designed to do. -The cause of this kind of bug can be difficult to track down after the fact, -especially when the second piece of code changes the value only *sometimes*. - -In Rust, the compiler guarantees that when you state that a value won’t change, -it really won’t change. That means that when you’re reading and writing code, -you don’t have to keep track of how and where a value might change. Your code -is thus easier to reason through. - -But mutability can be very useful. Variables are immutable only by default; as -you did in Chapter 2, you can make them mutable by adding `mut` in front of the -variable name. In addition to allowing this value to change, `mut` conveys -intent to future readers of the code by indicating that other parts of the code -will be changing this variable value. - -For example, let’s change *src/main.rs* to the following: - -Filename: src/main.rs - -```rust -fn main() { - let mut x = 5; - println!("The value of x is: {}", x); - x = 6; - println!("The value of x is: {}", x); -} -``` - -When we run the program now, we get this: - -```text -$ cargo run - Compiling variables v0.1.0 (file:///projects/variables) - Finished dev [unoptimized + debuginfo] target(s) in 0.30 secs - Running `target/debug/variables` -The value of x is: 5 -The value of x is: 6 -``` - -We’re allowed to change the value that `x` binds to from `5` to `6` when `mut` -is used. In some cases, you’ll want to make a variable mutable because it makes -the code more convenient to write than if it had only immutable variables. - -There are multiple trade-offs to consider in addition to the prevention of -bugs. For example, in cases where you’re using large data structures, mutating -an instance in place may be faster than copying and returning newly allocated -instances. With smaller data structures, creating new instances and writing in -a more functional programming style may be easier to think through, so lower -performance might be a worthwhile penalty for gaining that clarity. - -### Differences Between Variables and Constants - -Being unable to change the value of a variable might have reminded you of -another programming concept that most other languages have: *constants*. Like -immutable variables, constants are values that are bound to a name and are not -allowed to change, but there are a few differences between constants and -variables. - -First, you aren’t allowed to use `mut` with constants. Constants aren’t just -immutable by default—they’re always immutable. - -You declare constants using the `const` keyword instead of the `let` keyword, -and the type of the value *must* be annotated. We’re about to cover types and -type annotations in the next section, “Data Types,” so don’t worry about the -details right now. Just know that you must always annotate the type. - -Constants can be declared in any scope, including the global scope, which makes -them useful for values that many parts of code need to know about. - -The last difference is that constants may be set only to a constant expression, -not the result of a function call or any other value that could only be -computed at runtime. - -Here’s an example of a constant declaration where the constant’s name is -`MAX_POINTS` and its value is set to 100,000. (Rust’s constant naming -convention is to use all uppercase with underscores between words, -and underscores can be inserted in numeric literals to improve readability): - -```rust -const MAX_POINTS: u32 = 100_000; -``` - -Constants are valid for the entire time a program runs, within the scope they -were declared in, making them a useful choice for values in your application -domain that multiple parts of the program might need to know about, such as the -maximum number of points any player of a game is allowed to earn or the speed -of light. - -Naming hardcoded values used throughout your program as constants is useful in -conveying the meaning of that value to future maintainers of the code. It also -helps to have only one place in your code you would need to change if the -hardcoded value needed to be updated in the future. - -### Shadowing - -As you saw in the “Comparing the Guess to the Secret Number” section in Chapter -2, you can declare a new variable with the same name as a previous variable, -and the new variable shadows the previous variable. Rustaceans say that the -first variable is *shadowed* by the second, which means that the second -variable’s value is what appears when the variable is used. We can shadow a -variable by using the same variable’s name and repeating the use of the `let` -keyword as follows: - -Filename: src/main.rs - -```rust -fn main() { - let x = 5; - - let x = x + 1; - - let x = x * 2; - - println!("The value of x is: {}", x); -} -``` - -This program first binds `x` to a value of `5`. Then it shadows `x` by -repeating `let x =`, taking the original value and adding `1` so the value of -`x` is then `6`. The third `let` statement also shadows `x`, multiplying the -previous value by `2` to give `x` a final value of `12`. When we run this -program, it will output the following: - -```text -$ cargo run - Compiling variables v0.1.0 (file:///projects/variables) - Finished dev [unoptimized + debuginfo] target(s) in 0.31 secs - Running `target/debug/variables` -The value of x is: 12 -``` - -Shadowing is different than marking a variable as `mut`, because we’ll get a -compile-time error if we accidentally try to reassign to this variable without -using the `let` keyword. By using `let`, we can perform a few transformations -on a value but have the variable be immutable after those transformations have -been completed. - -The other difference between `mut` and shadowing is that because we’re -effectively creating a new variable when we use the `let` keyword again, we can -change the type of the value but reuse the same name. For example, say our -program asks a user to show how many spaces they want between some text by -inputting space characters, but we really want to store that input as a number: - -```rust -let spaces = " "; -let spaces = spaces.len(); -``` - -This construct is allowed because the first `spaces` variable is a string type -and the second `spaces` variable, which is a brand-new variable that happens to -have the same name as the first one, is a number type. Shadowing thus spares us -from having to come up with different names, such as `spaces_str` and -`spaces_num`; instead, we can reuse the simpler `spaces` name. However, if we -try to use `mut` for this, as shown here, we’ll get a compile-time error: - -```rust,ignore -let mut spaces = " "; -spaces = spaces.len(); -``` - -The error says we’re not allowed to mutate a variable’s type: - -```text -error[E0308]: mismatched types - --> src/main.rs:3:14 - | -3 | spaces = spaces.len(); - | ^^^^^^^^^^^^ expected &str, found usize - | - = note: expected type `&str` - found type `usize` -``` - -Now that we’ve explored how variables work, let’s look at more data types they -can have. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch03-01-variables-and-mutability.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-02-data-types.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-02-data-types.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-02-data-types.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-02-data-types.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,398 +1,10 @@ ## Data Types -Every value in Rust is of a certain *data type*, which tells Rust what kind of -data is being specified so it knows how to work with that data. We’ll look at -two data type subsets: scalar and compound. +The 2018 edition of the book is no longer distributed with Rust's documentation. -Keep in mind that Rust is a *statically typed* language, which means that it -must know the types of all variables at compile time. The compiler can usually -infer what type we want to use based on the value and how we use it. In cases -when many types are possible, such as when we converted a `String` to a numeric -type using `parse` in the “Comparing the Guess to the Secret Number” section in -Chapter 2, we must add a type annotation, like this: +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -```rust -let guess: u32 = "42".parse().expect("Not a number!"); -``` - -If we don’t add the type annotation here, Rust will display the following -error, which means the compiler needs more information from us to know which -type we want to use: - -```text -error[E0282]: type annotations needed - --> src/main.rs:2:9 - | -2 | let guess = "42".parse().expect("Not a number!"); - | ^^^^^ - | | - | cannot infer type for `_` - | consider giving `guess` a type -``` - -You’ll see different type annotations for other data types. - -### Scalar Types - -A *scalar* type represents a single value. Rust has four primary scalar types: -integers, floating-point numbers, Booleans, and characters. You may recognize -these from other programming languages. Let’s jump into how they work in Rust. - -#### Integer Types - -An *integer* is a number without a fractional component. We used one integer -type in Chapter 2, the `u32` type. This type declaration indicates that the -value it’s associated with should be an unsigned integer (signed integer types -start with `i`, instead of `u`) that takes up 32 bits of space. Table 3-1 shows -the built-in integer types in Rust. Each variant in the Signed and Unsigned -columns (for example, `i16`) can be used to declare the type of an integer -value. - -Table 3-1: Integer Types in Rust - -| Length | Signed | Unsigned | -|---------|---------|----------| -| 8-bit | `i8` | `u8` | -| 16-bit | `i16` | `u16` | -| 32-bit | `i32` | `u32` | -| 64-bit | `i64` | `u64` | -| 128-bit | `i128` | `u128` | -| arch | `isize` | `usize` | - -Each variant can be either signed or unsigned and has an explicit size. -*Signed* and *unsigned* refer to whether it’s possible for the number to be -negative or positive—in other words, whether the number needs to have a sign -with it (signed) or whether it will only ever be positive and can therefore be -represented without a sign (unsigned). It’s like writing numbers on paper: when -the sign matters, a number is shown with a plus sign or a minus sign; however, -when it’s safe to assume the number is positive, it’s shown with no sign. -Signed numbers are stored using two’s complement representation (if you’re -unsure what this is, you can search for it online; an explanation is outside -the scope of this book). - -Each signed variant can store numbers from -(2n - 1) to 2n - -1 - 1 inclusive, where *n* is the number of bits that variant uses. So an -`i8` can store numbers from -(27) to 27 - 1, which equals --128 to 127. Unsigned variants can store numbers from 0 to 2n - 1, -so a `u8` can store numbers from 0 to 28 - 1, which equals 0 to 255. - -Additionally, the `isize` and `usize` types depend on the kind of computer your -program is running on: 64 bits if you’re on a 64-bit architecture and 32 bits -if you’re on a 32-bit architecture. - -You can write integer literals in any of the forms shown in Table 3-2. Note -that all number literals except the byte literal allow a type suffix, such as -`57u8`, and `_` as a visual separator, such as `1_000`. - -Table 3-2: Integer Literals in Rust - -| Number literals | Example | -|------------------|---------------| -| Decimal | `98_222` | -| Hex | `0xff` | -| Octal | `0o77` | -| Binary | `0b1111_0000` | -| Byte (`u8` only) | `b'A'` | - -So how do you know which type of integer to use? If you’re unsure, Rust’s -defaults are generally good choices, and integer types default to `i32`: this -type is generally the fastest, even on 64-bit systems. The primary situation in -which you’d use `isize` or `usize` is when indexing some sort of collection. - -##### Integer Overflow - -Let's say that you have a `u8`, which can hold values between zero and `255`. -What happens if you try to change it to `256`? This is called "integer -overflow", and Rust has some interesting rules around this behavior. When -compiling in debug mode, Rust checks for this kind of issue and will cause -your program to *panic*, which is the term Rust uses when a program exits -with an error. We'll discuss panics more in Chapter 9. - -In release builds, Rust does not check for overflow, and instead will -do something called "two's complement wrapping." In short, `256` becomes -`0`, `257` becomes `1`, etc. Relying on overflow is considered an error, -even if this behavior happens. If you want this behavior explicitly, the -standard library has a type, `Wrapping`, that provides it explicitly. - -#### Floating-Point Types - -Rust also has two primitive types for *floating-point numbers*, which are -numbers with decimal points. Rust’s floating-point types are `f32` and `f64`, -which are 32 bits and 64 bits in size, respectively. The default type is `f64` -because on modern CPUs it’s roughly the same speed as `f32` but is capable of -more precision. - -Here’s an example that shows floating-point numbers in action: - -Filename: src/main.rs - -```rust -fn main() { - let x = 2.0; // f64 - - let y: f32 = 3.0; // f32 -} -``` - -Floating-point numbers are represented according to the IEEE-754 standard. The -`f32` type is a single-precision float, and `f64` has double precision. - -#### Numeric Operations - -Rust supports the basic mathematical operations you’d expect for all of the -number types: addition, subtraction, multiplication, division, and remainder. -The following code shows how you’d use each one in a `let` statement: - -Filename: src/main.rs - -```rust -fn main() { - // addition - let sum = 5 + 10; - - // subtraction - let difference = 95.5 - 4.3; - - // multiplication - let product = 4 * 30; - - // division - let quotient = 56.7 / 32.2; - - // remainder - let remainder = 43 % 5; -} -``` - -Each expression in these statements uses a mathematical operator and evaluates -to a single value, which is then bound to a variable. Appendix B contains a -list of all operators that Rust provides. - -#### The Boolean Type - -As in most other programming languages, a Boolean type in Rust has two possible -values: `true` and `false`. The Boolean type in Rust is specified using `bool`. -For example: - -Filename: src/main.rs - -```rust -fn main() { - let t = true; - - let f: bool = false; // with explicit type annotation -} -``` - -The main way to consume Boolean values is through conditionals, such as an `if` -expression. We’ll cover how `if` expressions work in Rust in the “Control Flow” -section. - -Booleans are one byte in size. - -#### The Character Type - -So far we’ve worked only with numbers, but Rust supports letters too. Rust’s -`char` type is the language’s most primitive alphabetic type, and the following -code shows one way to use it. (Note that the `char` literal is specified with -single quotes, as opposed to string literals, which use double quotes.) - -Filename: src/main.rs - -```rust -fn main() { - let c = 'z'; - let z = 'ℤ'; - let heart_eyed_cat = '😻'; -} -``` - -Rust’s `char` type represents a Unicode Scalar Value, which means it can -represent a lot more than just ASCII. Accented letters; Chinese, Japanese, and -Korean characters; emoji; and zero-width spaces are all valid `char` values in -Rust. Unicode Scalar Values range from `U+0000` to `U+D7FF` and `U+E000` to -`U+10FFFF` inclusive. However, a “character” isn’t really a concept in Unicode, -so your human intuition for what a “character” is may not match up with what a -`char` is in Rust. We’ll discuss this topic in detail in “Strings” in Chapter 8. - -### Compound Types - -*Compound types* can group multiple values into one type. Rust has two -primitive compound types: tuples and arrays. - -#### The Tuple Type - -A tuple is a general way of grouping together some number of other values -with a variety of types into one compound type. Tuples have a fixed length: -once declared, they cannot grow or shrink in size. - -We create a tuple by writing a comma-separated list of values inside -parentheses. Each position in the tuple has a type, and the types of the -different values in the tuple don’t have to be the same. We’ve added optional -type annotations in this example: - -Filename: src/main.rs - -```rust -fn main() { - let tup: (i32, f64, u8) = (500, 6.4, 1); -} -``` - -The variable `tup` binds to the entire tuple, because a tuple is considered a -single compound element. To get the individual values out of a tuple, we can -use pattern matching to destructure a tuple value, like this: - -Filename: src/main.rs - -```rust -fn main() { - let tup = (500, 6.4, 1); - - let (x, y, z) = tup; - - println!("The value of y is: {}", y); -} -``` - -This program first creates a tuple and binds it to the variable `tup`. It then -uses a pattern with `let` to take `tup` and turn it into three separate -variables, `x`, `y`, and `z`. This is called *destructuring*, because it breaks -the single tuple into three parts. Finally, the program prints the value of -`y`, which is `6.4`. - -In addition to destructuring through pattern matching, we can access a tuple -element directly by using a period (`.`) followed by the index of the value we -want to access. For example: - -Filename: src/main.rs - -```rust -fn main() { - let x: (i32, f64, u8) = (500, 6.4, 1); - - let five_hundred = x.0; - - let six_point_four = x.1; - - let one = x.2; -} -``` - -This program creates a tuple, `x`, and then makes new variables for each -element by using their index. As with most programming languages, the first -index in a tuple is 0. - -#### The Array Type - -Another way to have a collection of multiple values is with an *array*. Unlike -a tuple, every element of an array must have the same type. Arrays in Rust are -different from arrays in some other languages because arrays in Rust have a -fixed length, like tuples. - -In Rust, the values going into an array are written as a comma-separated list -inside square brackets: - -Filename: src/main.rs - -```rust -fn main() { - let a = [1, 2, 3, 4, 5]; -} -``` - -Arrays are useful when you want your data allocated on the stack rather than -the heap (we will discuss the stack and the heap more in Chapter 4), or when -you want to ensure you always have a fixed number of elements. An array isn’t -as flexible as the vector type, though. A vector is a similar collection type -provided by the standard library that *is* allowed to grow or shrink in size. -If you’re unsure whether to use an array or a vector, you should probably use a -vector. Chapter 8 discusses vectors in more detail. - -An example of when you might want to use an array rather than a vector is in a -program that needs to know the names of the months of the year. It’s very -unlikely that such a program will need to add or remove months, so you can use -an array because you know it will always contain 12 items: - -```rust -let months = ["January", "February", "March", "April", "May", "June", "July", - "August", "September", "October", "November", "December"]; -``` - -Arrays have an interesting type; it looks like this: `[type; number]`. For -example: - -```rust -let a: [i32; 5] = [1, 2, 3, 4, 5]; -``` - -First, there's square brackets; they look like the syntax for creating an -array. Inside, there's two pieces of information, separated by a semicolon. -The first is the type of each element of the array. Since all elements have -the same type, we only need to list it once. After the semicolon, there's -a number that indicates the length of the array. Since an array has a fixed size, -this number is always the same, even if the array's elements are modified, it -cannot grow or shrink. - -##### Accessing Array Elements - -An array is a single chunk of memory allocated on the stack. You can access -elements of an array using indexing, like this: - -Filename: src/main.rs - -```rust -fn main() { - let a = [1, 2, 3, 4, 5]; - - let first = a[0]; - let second = a[1]; -} -``` - -In this example, the variable named `first` will get the value `1`, because -that is the value at index `[0]` in the array. The variable named `second` will -get the value `2` from index `[1]` in the array. - -##### Invalid Array Element Access - -What happens if you try to access an element of an array that is past the end -of the array? Say you change the example to the following code, which will -compile but exit with an error when it runs: - -Filename: src/main.rs - -```rust,ignore -fn main() { - let a = [1, 2, 3, 4, 5]; - let index = 10; - - let element = a[index]; - - println!("The value of element is: {}", element); -} -``` - -Running this code using `cargo run` produces the following result: - -```text -$ cargo run - Compiling arrays v0.1.0 (file:///projects/arrays) - Finished dev [unoptimized + debuginfo] target(s) in 0.31 secs - Running `target/debug/arrays` -thread '
' panicked at 'index out of bounds: the len is 5 but the index is - 10', src/main.rs:6 -note: Run with `RUST_BACKTRACE=1` for a backtrace. -``` - -The compilation didn’t produce any errors, but the program resulted in a -*runtime* error and didn’t exit successfully. When you attempt to access an -element using indexing, Rust will check that the index you’ve specified is less -than the array length. If the index is greater than the length, Rust will -panic. - -This is the first example of Rust’s safety principles in action. In many -low-level languages, this kind of check is not done, and when you provide an -incorrect index, invalid memory can be accessed. Rust protects you against this -kind of error by immediately exiting instead of allowing the memory access and -continuing. Chapter 9 discusses more of Rust’s error handling. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch03-02-data-types.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-03-how-functions-work.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-03-how-functions-work.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-03-how-functions-work.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-03-how-functions-work.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,346 +1,10 @@ ## Functions -Functions are pervasive in Rust code. You’ve already seen one of the most -important functions in the language: the `main` function, which is the entry -point of many programs. You’ve also seen the `fn` keyword, which allows you to -declare new functions. +The 2018 edition of the book is no longer distributed with Rust's documentation. -Rust code uses *snake case* as the conventional style for function and variable -names. In snake case, all letters are lowercase and underscores separate words. -Here’s a program that contains an example function definition: +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -Filename: src/main.rs - -```rust -fn main() { - println!("Hello, world!"); - - another_function(); -} - -fn another_function() { - println!("Another function."); -} -``` - -Function definitions in Rust start with `fn` and have a set of parentheses -after the function name. The curly brackets tell the compiler where the -function body begins and ends. - -We can call any function we’ve defined by entering its name followed by a set -of parentheses. Because `another_function` is defined in the program, it can be -called from inside the `main` function. Note that we defined `another_function` -*after* the `main` function in the source code; we could have defined it before -as well. Rust doesn’t care where you define your functions, only that they’re -defined somewhere. - -Let’s start a new binary project named *functions* to explore functions -further. Place the `another_function` example in *src/main.rs* and run it. You -should see the following output: - -```text -$ cargo run - Compiling functions v0.1.0 (file:///projects/functions) - Finished dev [unoptimized + debuginfo] target(s) in 0.28 secs - Running `target/debug/functions` -Hello, world! -Another function. -``` - -The lines execute in the order in which they appear in the `main` function. -First, the “Hello, world!” message prints, and then `another_function` is -called and its message is printed. - -### Function Parameters - -Functions can also be defined to have *parameters*, which are special variables -that are part of a function’s signature. When a function has parameters, you -can provide it with concrete values for those parameters. Technically, the -concrete values are called *arguments*, but in casual conversation, people tend -to use the words *parameter* and *argument* interchangeably for either the -variables in a function’s definition or the concrete values passed in when you -call a function. - -The following rewritten version of `another_function` shows what parameters -look like in Rust: - -Filename: src/main.rs - -```rust -fn main() { - another_function(5); -} - -fn another_function(x: i32) { - println!("The value of x is: {}", x); -} -``` - -Try running this program; you should get the following output: - -```text -$ cargo run - Compiling functions v0.1.0 (file:///projects/functions) - Finished dev [unoptimized + debuginfo] target(s) in 1.21 secs - Running `target/debug/functions` -The value of x is: 5 -``` - -The declaration of `another_function` has one parameter named `x`. The type of -`x` is specified as `i32`. When `5` is passed to `another_function`, the -`println!` macro puts `5` where the pair of curly brackets were in the format -string. - -In function signatures, you *must* declare the type of each parameter. This is -a deliberate decision in Rust’s design: requiring type annotations in function -definitions means the compiler almost never needs you to use them elsewhere in -the code to figure out what you mean. - -When you want a function to have multiple parameters, separate the parameter -declarations with commas, like this: - -Filename: src/main.rs - -```rust -fn main() { - another_function(5, 6); -} - -fn another_function(x: i32, y: i32) { - println!("The value of x is: {}", x); - println!("The value of y is: {}", y); -} -``` - -This example creates a function with two parameters, both of which are `i32` -types. The function then prints the values in both of its parameters. Note that -function parameters don’t all need to be the same type, they just happen to be -in this example. - -Let’s try running this code. Replace the program currently in your *functions* -project’s *src/main.rs* file with the preceding example and run it using `cargo -run`: - -```text -$ cargo run - Compiling functions v0.1.0 (file:///projects/functions) - Finished dev [unoptimized + debuginfo] target(s) in 0.31 secs - Running `target/debug/functions` -The value of x is: 5 -The value of y is: 6 -``` - -Because we called the function with `5` as the value for `x` and `6` is passed -as the value for `y`, the two strings are printed with these values. - -### Function Bodies - -Function bodies are made up of a series of statements optionally ending in an -expression. So far, we’ve only covered functions without an ending expression, -but you have seen an expression as part of statements. Because Rust is an -expression-based language, this is an important distinction to understand. -Other languages don’t have the same distinctions, so let’s look at what -statements and expressions are and how their differences affect the bodies of -functions. - -### Statements and Expressions - -We’ve actually already used statements and expressions. *Statements* are -instructions that perform some action and do not return a value. *Expressions* -evaluate to a resulting value. Let’s look at some examples. - -Creating a variable and assigning a value to it with the `let` keyword is a -statement. In Listing 3-1, `let y = 6;` is a statement: - -Filename: src/main.rs - -```rust -fn main() { - let y = 6; -} -``` - -Listing 3-1: A `main` function declaration containing one statement - -Function definitions are also statements; the entire preceding example is a -statement in itself. - -Statements do not return values. Therefore, you can’t assign a `let` statement -to another variable, as the following code tries to do; you’ll get an error: - -Filename: src/main.rs - -```rust,ignore -fn main() { - let x = (let y = 6); -} -``` - -When you run this program, the error you’ll get looks like this: - -```text -$ cargo run - Compiling functions v0.1.0 (file:///projects/functions) -error: expected expression, found statement (`let`) - --> src/main.rs:2:14 - | -2 | let x = (let y = 6); - | ^^^ - | - = note: variable declaration using `let` is a statement -``` - -The `let y = 6` statement does not return a value, so there isn’t anything for -`x` to bind to. This is different from what happens in other languages, such as -C and Ruby, where the assignment returns the value of the assignment. In those -languages, you can write `x = y = 6` and have both `x` and `y` have the value -`6`; that is not the case in Rust. - -Expressions evaluate to something and make up most of the rest of the code that -you’ll write in Rust. Consider a simple math operation, such as `5 + 6`, which -is an expression that evaluates to the value `11`. Expressions can be part of -statements: in Listing 3-1, the `6` in the statement `let y = 6;` is an -expression that evaluates to the value `6`. Calling a function is an -expression. Calling a macro is an expression. The block that we use to create -new scopes, `{}`, is an expression, for example: - -Filename: src/main.rs - -```rust -fn main() { - let x = 5; - - let y = { - let x = 3; - x + 1 - }; - - println!("The value of y is: {}", y); -} -``` - -This expression: - -```rust,ignore -{ - let x = 3; - x + 1 -} -``` - -is a block that, in this case, evaluates to `4`. That value gets bound to `y` -as part of the `let` statement. Note the `x + 1` line without a semicolon at -the end, which is unlike most of the lines you’ve seen so far. Expressions do -not include ending semicolons. If you add a semicolon to the end of an -expression, you turn it into a statement, which will then not return a value. -Keep this in mind as you explore function return values and expressions next. - -### Functions with Return Values - -Functions can return values to the code that calls them. We don’t name return -values, but we do declare their type after an arrow (`->`). In Rust, the return -value of the function is synonymous with the value of the final expression in -the block of the body of a function. You can return early from a function by -using the `return` keyword and specifying a value, but most functions return -the last expression implicitly. Here’s an example of a function that returns a -value: - -Filename: src/main.rs - -```rust -fn five() -> i32 { - 5 -} - -fn main() { - let x = five(); - - println!("The value of x is: {}", x); -} -``` - -There are no function calls, macros, or even `let` statements in the `five` -function—just the number `5` by itself. That’s a perfectly valid function in -Rust. Note that the function’s return type is specified, too, as `-> i32`. Try -running this code; the output should look like this: - -```text -$ cargo run - Compiling functions v0.1.0 (file:///projects/functions) - Finished dev [unoptimized + debuginfo] target(s) in 0.30 secs - Running `target/debug/functions` -The value of x is: 5 -``` - -The `5` in `five` is the function’s return value, which is why the return type -is `i32`. Let’s examine this in more detail. There are two important bits: -first, the line `let x = five();` shows that we’re using the return value of a -function to initialize a variable. Because the function `five` returns a `5`, -that line is the same as the following: - -```rust -let x = 5; -``` - -Second, the `five` function has no parameters and defines the type of the -return value, but the body of the function is a lonely `5` with no semicolon -because it’s an expression whose value we want to return. - -Let’s look at another example: - -Filename: src/main.rs - -```rust -fn main() { - let x = plus_one(5); - - println!("The value of x is: {}", x); -} - -fn plus_one(x: i32) -> i32 { - x + 1 -} -``` - -Running this code will print `The value of x is: 6`. But if we place a -semicolon at the end of the line containing `x + 1`, changing it from an -expression to a statement, we’ll get an error. - -Filename: src/main.rs - -```rust,ignore -fn main() { - let x = plus_one(5); - - println!("The value of x is: {}", x); -} - -fn plus_one(x: i32) -> i32 { - x + 1; -} -``` - -Compiling this code produces an error, as follows: - -```text -error[E0308]: mismatched types - --> src/main.rs:7:28 - | -7 | fn plus_one(x: i32) -> i32 { - | ____________________________^ -8 | | x + 1; - | | - help: consider removing this semicolon -9 | | } - | |_^ expected i32, found () - | - = note: expected type `i32` - found type `()` -``` - -The main error message, “mismatched types,” reveals the core issue with this -code. The definition of the function `plus_one` says that it will return an -`i32`, but statements don’t evaluate to a value, which is expressed by `()`, -the empty tuple. Therefore, nothing is returned, which contradicts the function -definition and results in an error. In this output, Rust provides a message to -possibly help rectify this issue: it suggests removing the semicolon, which -would fix the error. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch03-03-how-functions-work.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-04-comments.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-04-comments.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-04-comments.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-04-comments.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,47 +1,10 @@ ## Comments -All programmers strive to make their code easy to understand, but sometimes -extra explanation is warranted. In these cases, programmers leave notes, or -*comments*, in their source code that the compiler will ignore but people -reading the source code may find useful. +The 2018 edition of the book is no longer distributed with Rust's documentation. -Here’s a simple comment: +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -```rust -// Hello, world. -``` - -In Rust, comments must start with two slashes and continue until the end of the -line. For comments that extend beyond a single line, you’ll need to include -`//` on each line, like this: - -```rust -// So we’re doing something complicated here, long enough that we need -// multiple lines of comments to do it! Whew! Hopefully, this comment will -// explain what’s going on. -``` - -Comments can also be placed at the end of lines containing code: - -Filename: src/main.rs - -```rust -fn main() { - let lucky_number = 7; // I’m feeling lucky today. -} -``` - -But you’ll more often see them used in this format, with the comment on a -separate line above the code it’s annotating: - -Filename: src/main.rs - -```rust -fn main() { - // I’m feeling lucky today. - let lucky_number = 7; -} -``` - -Rust also has another kind of comment, documentation comments, which we’ll -discuss in Chapter 14. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch03-04-comments.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-05-control-flow.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-05-control-flow.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-05-control-flow.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch03-05-control-flow.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,486 +1,10 @@ ## Control Flow -Deciding whether or not to run some code depending on if a condition is true -and deciding to run some code repeatedly while a condition is true are basic -building blocks in most programming languages. The most common constructs that -let you control the flow of execution of Rust code are `if` expressions and -loops. +The 2018 edition of the book is no longer distributed with Rust's documentation. -### `if` Expressions +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -An `if` expression allows you to branch your code depending on conditions. You -provide a condition and then state, “If this condition is met, run this block -of code. If the condition is not met, do not run this block of code.” - -Create a new project called *branches* in your *projects* directory to explore -the `if` expression. In the *src/main.rs* file, input the following: - -Filename: src/main.rs - -```rust -fn main() { - let number = 3; - - if number < 5 { - println!("condition was true"); - } else { - println!("condition was false"); - } -} -``` - - - -All `if` expressions start with the keyword `if`, which is followed by a -condition. In this case, the condition checks whether or not the variable -`number` has a value less than 5. The block of code we want to execute if the -condition is true is placed immediately after the condition inside curly -brackets. Blocks of code associated with the conditions in `if` expressions are -sometimes called *arms*, just like the arms in `match` expressions that we -discussed in the “Comparing the Guess to the Secret Number” section of -Chapter 2. - -Optionally, we can also include an `else` expression, which we chose -to do here, to give the program an alternative block of code to execute should -the condition evaluate to false. If you don’t provide an `else` expression and -the condition is false, the program will just skip the `if` block and move on -to the next bit of code. - -Try running this code; you should see the following output: - -```text -$ cargo run - Compiling branches v0.1.0 (file:///projects/branches) - Finished dev [unoptimized + debuginfo] target(s) in 0.31 secs - Running `target/debug/branches` -condition was true -``` - -Let’s try changing the value of `number` to a value that makes the condition -`false` to see what happens: - -```rust,ignore -let number = 7; -``` - -Run the program again, and look at the output: - -```text -$ cargo run - Compiling branches v0.1.0 (file:///projects/branches) - Finished dev [unoptimized + debuginfo] target(s) in 0.31 secs - Running `target/debug/branches` -condition was false -``` - -It’s also worth noting that the condition in this code *must* be a `bool`. If -the condition isn’t a `bool`, we’ll get an error. For example: - -Filename: src/main.rs - -```rust,ignore -fn main() { - let number = 3; - - if number { - println!("number was three"); - } -} -``` - -The `if` condition evaluates to a value of `3` this time, and Rust throws an -error: - -```text -error[E0308]: mismatched types - --> src/main.rs:4:8 - | -4 | if number { - | ^^^^^^ expected bool, found integral variable - | - = note: expected type `bool` - found type `{integer}` -``` - -The error indicates that Rust expected a `bool` but got an integer. Unlike -languages such as Ruby and JavaScript, Rust will not automatically try to -convert non-Boolean types to a Boolean. You must be explicit and always provide -`if` with a Boolean as its condition. If we want the `if` code block to run -only when a number is not equal to `0`, for example, we can change the `if` -expression to the following: - -Filename: src/main.rs - -```rust -fn main() { - let number = 3; - - if number != 0 { - println!("number was something other than zero"); - } -} -``` - -Running this code will print `number was something other than zero`. - -#### Handling Multiple Conditions with `else if` - -You can have multiple conditions by combining `if` and `else` in an `else if` -expression. For example: - -Filename: src/main.rs - -```rust -fn main() { - let number = 6; - - if number % 4 == 0 { - println!("number is divisible by 4"); - } else if number % 3 == 0 { - println!("number is divisible by 3"); - } else if number % 2 == 0 { - println!("number is divisible by 2"); - } else { - println!("number is not divisible by 4, 3, or 2"); - } -} -``` - -This program has four possible paths it can take. After running it, you should -see the following output: - -```text -$ cargo run - Compiling branches v0.1.0 (file:///projects/branches) - Finished dev [unoptimized + debuginfo] target(s) in 0.31 secs - Running `target/debug/branches` -number is divisible by 3 -``` - -When this program executes, it checks each `if` expression in turn and executes -the first body for which the condition holds true. Note that even though 6 is -divisible by 2, we don’t see the output `number is divisible by 2`, nor do we -see the `number is not divisible by 4, 3, or 2` text from the `else` block. -That’s because Rust only executes the block for the first true condition, and -once it finds one, it doesn’t even check the rest. - -Using too many `else if` expressions can clutter your code, so if you have more -than one, you might want to refactor your code. Chapter 6 describes a powerful -Rust branching construct called `match` for these cases. - -#### Using `if` in a `let` Statement - -Because `if` is an expression, we can use it on the right side of a `let` -statement, as in Listing 3-2: - -Filename: src/main.rs - -```rust -fn main() { - let condition = true; - let number = if condition { - 5 - } else { - 6 - }; - - println!("The value of number is: {}", number); -} -``` - -Listing 3-2: Assigning the result of an `if` expression -to a variable - -The `number` variable will be bound to a value based on the outcome of the `if` -expression. Run this code to see what happens: - -```text -$ cargo run - Compiling branches v0.1.0 (file:///projects/branches) - Finished dev [unoptimized + debuginfo] target(s) in 0.30 secs - Running `target/debug/branches` -The value of number is: 5 -``` - -Remember that blocks of code evaluate to the last expression in them, and -numbers by themselves are also expressions. In this case, the value of the -whole `if` expression depends on which block of code executes. This means the -values that have the potential to be results from each arm of the `if` must be -the same type; in Listing 3-2, the results of both the `if` arm and the `else` -arm were `i32` integers. If the types are mismatched, as in the following -example, we’ll get an error: - -Filename: src/main.rs - -```rust,ignore -fn main() { - let condition = true; - - let number = if condition { - 5 - } else { - "six" - }; - - println!("The value of number is: {}", number); -} -``` - -When we try to compile this code, we’ll get an error. The `if` and `else` arms have -value types that are incompatible, and Rust indicates exactly where to find the -problem in the program: - -```text -error[E0308]: if and else have incompatible types - --> src/main.rs:4:18 - | -4 | let number = if condition { - | __________________^ -5 | | 5 -6 | | } else { -7 | | "six" -8 | | }; - | |_____^ expected integral variable, found &str - | - = note: expected type `{integer}` - found type `&str` -``` - -The expression in the `if` block evaluates to an integer, and the expression in -the `else` block evaluates to a string. This won’t work because variables must -have a single type. Rust needs to know at compile time what type the `number` -variable is, definitively, so it can verify at compile time that its type is -valid everywhere we use `number`. Rust wouldn’t be able to do that if the type -of `number` was only determined at runtime; the compiler would be more complex -and would make fewer guarantees about the code if it had to keep track of -multiple hypothetical types for any variable. - -### Repetition with Loops - -It’s often useful to execute a block of code more than once. For this task, -Rust provides several *loops*. A loop runs through the code inside the loop -body to the end and then starts immediately back at the beginning. To -experiment with loops, let’s make a new project called *loops*. - -Rust has three kinds of loops: `loop`, `while`, and `for`. Let’s try each one. - -#### Repeating Code with `loop` - -The `loop` keyword tells Rust to execute a block of code over and over again -forever or until you explicitly tell it to stop. - -As an example, change the *src/main.rs* file in your *loops* directory to look -like this: - -Filename: src/main.rs - -```rust,ignore -fn main() { - loop { - println!("again!"); - } -} -``` - -When we run this program, we’ll see `again!` printed over and over continuously -until we stop the program manually. Most terminals support a keyboard shortcut, -ctrl-c, to halt a program that is stuck in a -continual loop. Give it a try: - -```text -$ cargo run - Compiling loops v0.1.0 (file:///projects/loops) - Finished dev [unoptimized + debuginfo] target(s) in 0.29 secs - Running `target/debug/loops` -again! -again! -again! -again! -^Cagain! -``` - -The symbol `^C` represents where you pressed ctrl-c -. You may or may not see the word `again!` printed after the `^C`, -depending on where the code was in the loop when it received the halt signal. - -Fortunately, Rust provides another, more reliable way to break out of a loop. -You can place the `break` keyword within the loop to tell the program when to -stop executing the loop. Recall that we did this in the guessing game in the -“Quitting After a Correct Guess” section of Chapter 2 to exit the -program when the user won the game by guessing the correct number. - - -#### Returning from loops - -One of the uses of a `loop` is to retry an operation you know can fail, such as -checking if a thread completed its job. However, you might need to pass the -result of that operation to the rest of your code. If you add it to the `break` -expression you use to stop the loop, it will be returned by the broken loop: - -```rust -fn main() { - let mut counter = 0; - - let result = loop { - counter += 1; - - if counter == 10 { - break counter * 2; - } - }; - - assert_eq!(result, 20); -} -``` - -#### Conditional Loops with `while` - -It’s often useful for a program to evaluate a condition within a loop. While -the condition is true, the loop runs. When the condition ceases to be true, the -program calls `break`, stopping the loop. This loop type could be implemented -using a combination of `loop`, `if`, `else`, and `break`; you could try that -now in a program, if you’d like. - -However, this pattern is so common that Rust has a built-in language construct -for it, called a `while` loop. Listing 3-3 uses `while`: the program loops -three times, counting down each time, and then, after the loop, it prints -another message and exits. - -Filename: src/main.rs - -```rust -fn main() { - let mut number = 3; - - while number != 0 { - println!("{}!", number); - - number = number - 1; - } - - println!("LIFTOFF!!!"); -} -``` - -Listing 3-3: Using a `while` loop to run code while a -condition holds true - -This construct eliminates a lot of nesting that would be necessary if you used -`loop`, `if`, `else`, and `break`, and it’s clearer. While a condition holds -true, the code runs; otherwise, it exits the loop. - -#### Looping Through a Collection with `for` - -You could use the `while` construct to loop over the elements of a collection, -such as an array. For example, let’s look at Listing 3-4: - -Filename: src/main.rs - -```rust -fn main() { - let a = [10, 20, 30, 40, 50]; - let mut index = 0; - - while index < 5 { - println!("the value is: {}", a[index]); - - index = index + 1; - } -} -``` - -Listing 3-4: Looping through each element of a collection -using a `while` loop - -Here, the code counts up through the elements in the array. It starts at index -`0`, and then loops until it reaches the final index in the array (that is, -when `index < 5` is no longer true). Running this code will print every element -in the array: - -```text -$ cargo run - Compiling loops v0.1.0 (file:///projects/loops) - Finished dev [unoptimized + debuginfo] target(s) in 0.32 secs - Running `target/debug/loops` -the value is: 10 -the value is: 20 -the value is: 30 -the value is: 40 -the value is: 50 -``` - -All five array values appear in the terminal, as expected. Even though `index` -will reach a value of `5` at some point, the loop stops executing before trying -to fetch a sixth value from the array. - -But this approach is error prone; we could cause the program to panic if the -index length is incorrect. It’s also slow, because the compiler adds runtime -code to perform the conditional check on every element on every iteration -through the loop. - -As a more concise alternative, you can use a `for` loop and execute some code -for each item in a collection. A `for` loop looks like this code in Listing 3-5: - -Filename: src/main.rs - -```rust -fn main() { - let a = [10, 20, 30, 40, 50]; - - for element in a.iter() { - println!("the value is: {}", element); - } -} -``` - -Listing 3-5: Looping through each element of a collection -using a `for` loop - -When we run this code, we’ll see the same output as in Listing 3-4. More -importantly, we’ve now increased the safety of the code and eliminated the -chance of bugs that might result from going beyond the end of the array or not -going far enough and missing some items. - -For example, in the code in Listing 3-4, if you removed an item from the `a` -array but forgot to update the condition to `while index < 4`, the code would -panic. Using the `for` loop, you wouldn’t need to remember to change any other -code if you changed the number of values in the array. - -The safety and conciseness of `for` loops make them the most commonly used loop -construct in Rust. Even in situations in which you want to run some code a -certain number of times, as in the countdown example that used a `while` loop -in Listing 3-3, most Rustaceans would use a `for` loop. The way to do that -would be to use a `Range`, which is a type provided by the standard library -that generates all numbers in sequence starting from one number and ending -before another number. - -Here’s what the countdown would look like using a `for` loop and another method -we’ve not yet talked about, `rev`, to reverse the range: - -Filename: src/main.rs - -```rust -fn main() { - for number in (1..4).rev() { - println!("{}!", number); - } - println!("LIFTOFF!!!"); -} -``` - -This code is a bit nicer, isn’t it? - -## Summary - -You made it! That was a sizable chapter: you learned about variables, scalar -and compound data types, functions, comments, `if` expressions, and loops! If -you want to practice with the concepts discussed in this chapter, try building -programs to do the following: - -* Convert temperatures between Fahrenheit and Celsius. -* Generate the nth Fibonacci number. -* Print the lyrics to the Christmas carol “The Twelve Days of Christmas,” -taking advantage of the repetition in the song. - -When you’re ready to move on, we’ll talk about a concept in Rust that *doesn’t* -commonly exist in other programming languages: ownership. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch03-05-control-flow.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch04-00-understanding-ownership.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch04-00-understanding-ownership.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch04-00-understanding-ownership.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch04-00-understanding-ownership.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,7 +1,10 @@ # Understanding Ownership -Ownership is Rust’s most unique feature, and it enables Rust to make memory -safety guarantees without needing a garbage collector. Therefore, it’s -important to understand how ownership works in Rust. In this chapter, we’ll -talk about ownership as well as several related features: borrowing, slices, -and how Rust lays data out in memory. +The 2018 edition of the book is no longer distributed with Rust's documentation. + +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. + +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch04-00-understanding-ownership.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch04-01-what-is-ownership.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch04-01-what-is-ownership.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch04-01-what-is-ownership.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch04-01-what-is-ownership.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,552 +1,10 @@ ## What Is Ownership? -Rust’s central feature is *ownership*. Although the feature is straightforward -to explain, it has deep implications for the rest of the language. +The 2018 edition of the book is no longer distributed with Rust's documentation. -All programs have to manage the way they use a computer’s memory while running. -Some languages have garbage collection that constantly looks for no longer used -memory as the program runs; in other languages, the programmer must explicitly -allocate and free the memory. Rust uses a third approach: memory is managed -through a system of ownership with a set of rules that the compiler checks at -compile time. None of the ownership features slow down your program while it’s -running. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -Because ownership is a new concept for many programmers, it does take some time -to get used to. The good news is that the more experienced you become with Rust -and the rules of the ownership system, the more you’ll be able to naturally -develop code that is safe and efficient. Keep at it! - -When you understand ownership, you’ll have a solid foundation for understanding -the features that make Rust unique. In this chapter, you’ll learn ownership by -working through some examples that focus on a very common data structure: -strings. - -> ### The Stack and the Heap -> -> In many programming languages, you don’t have to think about the stack and -> the heap very often. But in a systems programming language like Rust, whether -> a value is on the stack or the heap has more of an effect on how the language -> behaves and why you have to make certain decisions. Parts of ownership will -> be described in relation to the stack and the heap later in this chapter, so -> here is a brief explanation in preparation. -> -> Both the stack and the heap are parts of memory that are available to your code -> to use at runtime, but they are structured in different ways. The stack stores -> values in the order it gets them and removes the values in the opposite order. -> This is referred to as *last in, first out*. Think of a stack of plates: when -> you add more plates, you put them on top of the pile, and when you need a -> plate, you take one off the top. Adding or removing plates from the middle or -> bottom wouldn’t work as well! Adding data is called *pushing onto the stack*, -> and removing data is called *popping off the stack*. -> -> The stack is fast because of the way it accesses the data: it never has to -> search for a place to put new data or a place to get data from because that -> place is always the top. Another property that makes the stack fast is that -> all data on the stack must take up a known, fixed size. -> -> Data with a size unknown at compile time or a size that might change can be -> stored on the heap instead. The heap is less organized: when you put data on -> the heap, you ask for some amount of space. The operating system finds an -> empty spot somewhere in the heap that is big enough, marks it as being in -> use, and returns a *pointer*, which is the address of that location. This -> process is called *allocating on the heap*, sometimes abbreviated as just -> “allocating.” Pushing values onto the stack is not considered allocating. -> Because the pointer is a known, fixed size, you can store the pointer on the -> stack, but when you want the actual data, you have to follow the pointer. -> -> Think of being seated at a restaurant. When you enter, you state the number of -> people in your group, and the staff finds an empty table that fits everyone -> and leads you there. If someone in your group comes late, they can ask where -> you’ve been seated to find you. -> -> Accessing data in the heap is slower than accessing data on the stack because -> you have to follow a pointer to get there. Contemporary processors are faster -> if they jump around less in memory. Continuing the analogy, consider a server -> at a restaurant taking orders from many tables. It’s most efficient to get -> all the orders at one table before moving on to the next table. Taking an -> order from table A, then an order from table B, then one from A again, and -> then one from B again would be a much slower process. By the same token, a -> processor can do its job better if it works on data that’s close to other -> data (as it is on the stack) rather than farther away (as it can be on the -> heap). Allocating a large amount of space on the heap can also take time. -> -> When your code calls a function, the values passed into the function -> (including, potentially, pointers to data on the heap) and the function’s -> local variables get pushed onto the stack. When the function is over, those -> values get popped off the stack. -> -> Keeping track of what parts of code are using what data on the heap, -> minimizing the amount of duplicate data on the heap, and cleaning up unused -> data on the heap so you don’t run out of space are all problems that ownership -> addresses. Once you understand ownership, you won’t need to think about the -> stack and the heap very often, but knowing that managing heap data is why -> ownership exists can help explain why it works the way it does. - -### Ownership Rules - -First, let’s take a look at the ownership rules. Keep these rules in mind as we -work through the examples that illustrate them: - -> 1. Each value in Rust has a variable that’s called its *owner*. -> 2. There can only be one owner at a time. -> 3. When the owner goes out of scope, the value will be dropped. - -### Variable Scope - -We’ve walked through an example of a Rust program already in Chapter 2. Now -that we’re past basic syntax, we won’t include all the `fn main() {` code in -examples, so if you’re following along, you’ll have to put the following -examples inside a `main` function manually. As a result, our examples will be a -bit more concise, letting us focus on the actual details rather than -boilerplate code. - -As a first example of ownership, we’ll look at the *scope* of some variables. A -scope is the range within a program for which an item is valid. Let’s say we -have a variable that looks like this: - -```rust -let s = "hello"; -``` - -The variable `s` refers to a string literal, where the value of the string is -hardcoded into the text of our program. The variable is valid from the point at -which it’s declared until the end of the current *scope*. Listing 4-1 has -comments annotating where the variable `s` is valid: - -```rust -{ // s is not valid here, it’s not yet declared - let s = "hello"; // s is valid from this point forward - - // do stuff with s -} // this scope is now over, and s is no longer valid -``` - -Listing 4-1: A variable and the scope in which it is -valid - -In other words, there are two important points in time here: - -* When `s` comes *into scope*, it is valid. -* It remains valid until it goes *out of scope*. - -At this point, the relationship between scopes and when variables are valid is -similar to that in other programming languages. Now we’ll build on top of this -understanding by introducing the `String` type. - -### The `String` Type - -To illustrate the rules of ownership, we need a data type that is more complex -than the ones we covered in the “Data Types” section of Chapter 3. The types -covered previously are all stored on the stack and popped off the stack when -their scope is over, but we want to look at data that is stored on the heap and -explore how Rust knows when to clean up that data. - -We’ll use `String` as the example here and concentrate on the parts of `String` -that relate to ownership. These aspects also apply to other complex data types -provided by the standard library and that you create. We’ll discuss `String` in -more depth in Chapter 8. - -We’ve already seen string literals, where a string value is hardcoded into our -program. String literals are convenient, but they aren’t suitable for every -situation in which we may want to use text. One reason is that they’re -immutable. Another is that not every string value can be known when we write -our code: for example, what if we want to take user input and store it? For -these situations, Rust has a second string type, `String`. This type is -allocated on the heap and as such is able to store an amount of text that is -unknown to us at compile time. You can create a `String` from a string literal -using the `from` function, like so: - -```rust -let s = String::from("hello"); -``` - -The double colon (`::`) is an operator that allows us to namespace this -particular `from` function under the `String` type rather than using some sort -of name like `string_from`. We’ll discuss this syntax more in the “Method -Syntax” section of Chapter 5 and when we talk about namespacing with modules in -“Module Definitions” in Chapter 7. - -This kind of string *can* be mutated: - -```rust -let mut s = String::from("hello"); - -s.push_str(", world!"); // push_str() appends a literal to a String - -println!("{}", s); // This will print `hello, world!` -``` - -So, what’s the difference here? Why can `String` be mutated but literals -cannot? The difference is how these two types deal with memory. - -### Memory and Allocation - -In the case of a string literal, we know the contents at compile time, so the -text is hardcoded directly into the final executable. This is why string -literals are fast and efficient. But these properties only come from the string -literal’s immutability. Unfortunately, we can’t put a blob of memory into the -binary for each piece of text whose size is unknown at compile time and whose -size might change while running the program. - -With the `String` type, in order to support a mutable, growable piece of text, -we need to allocate an amount of memory on the heap, unknown at compile time, -to hold the contents. This means: - -* The memory must be requested from the operating system at runtime. -* We need a way of returning this memory to the operating system when we’re - done with our `String`. - -That first part is done by us: when we call `String::from`, its implementation -requests the memory it needs. This is pretty much universal in programming -languages. - -However, the second part is different. In languages with a *garbage collector -(GC)*, the GC keeps track and cleans up memory that isn’t being used anymore, -and we don’t need to think about it. Without a GC, it’s our responsibility to -identify when memory is no longer being used and call code to explicitly return -it, just as we did to request it. Doing this correctly has historically been a -difficult programming problem. If we forget, we’ll waste memory. If we do it -too early, we’ll have an invalid variable. If we do it twice, that’s a bug too. -We need to pair exactly one `allocate` with exactly one `free`. - -Rust takes a different path: the memory is automatically returned once the -variable that owns it goes out of scope. Here’s a version of our scope example -from Listing 4-1 using a `String` instead of a string literal: - -```rust -{ - let s = String::from("hello"); // s is valid from this point forward - - // do stuff with s -} // this scope is now over, and s is no - // longer valid -``` - -There is a natural point at which we can return the memory our `String` needs -to the operating system: when `s` goes out of scope. When a variable goes out -of scope, Rust calls a special function for us. This function is called `drop`, -and it’s where the author of `String` can put the code to return the memory. -Rust calls `drop` automatically at the closing `}`. - -> Note: In C++, this pattern of deallocating resources at the end of an item’s -> lifetime is sometimes called *Resource Acquisition Is Initialization (RAII)*. -> The `drop` function in Rust will be familiar to you if you’ve used RAII -> patterns. - -This pattern has a profound impact on the way Rust code is written. It may seem -simple right now, but the behavior of code can be unexpected in more -complicated situations when we want to have multiple variables use the data -we’ve allocated on the heap. Let’s explore some of those situations now. - -#### Ways Variables and Data Interact: Move - -Multiple variables can interact with the same data in different ways in Rust. -Let’s look at an example using an integer in Listing 4-2: - -```rust -let x = 5; -let y = x; -``` - -Listing 4-2: Assigning the integer value of variable `x` -to `y` - -We can probably guess what this is doing: “bind the value `5` to `x`; then make -a copy of the value in `x` and bind it to `y`.” We now have two variables, `x` -and `y`, and both equal `5`. This is indeed what is happening, because integers -are simple values with a known, fixed size, and these two `5` values are pushed -onto the stack. - -Now let’s look at the `String` version: - -```rust -let s1 = String::from("hello"); -let s2 = s1; -``` - -This looks very similar to the previous code, so we might assume that the way -it works would be the same: that is, the second line would make a copy of the -value in `s1` and bind it to `s2`. But this isn’t quite what happens. - -Take a look at Figure 4-1 to see what is happening to `String` under the -covers. A `String` is made up of three parts, shown on the left: a pointer to -the memory that holds the contents of the string, a length, and a capacity. -This group of data is stored on the stack. On the right is the memory on the -heap that holds the contents. - -String in memory - -Figure 4-1: Representation in memory of a `String` -holding the value `"hello"` bound to `s1` - -The length is how much memory, in bytes, the contents of the `String` is -currently using. The capacity is the total amount of memory, in bytes, that the -`String` has received from the operating system. The difference between length -and capacity matters, but not in this context, so for now, it’s fine to ignore -the capacity. - -When we assign `s1` to `s2`, the `String` data is copied, meaning we copy the -pointer, the length, and the capacity that are on the stack. We do not copy the -data on the heap that the pointer refers to. In other words, the data -representation in memory looks like Figure 4-2. - -s1 and s2 pointing to the same value - -Figure 4-2: Representation in memory of the variable `s2` -that has a copy of the pointer, length, and capacity of `s1` - -The representation does *not* look like Figure 4-3, which is what memory would -look like if Rust instead copied the heap data as well. If Rust did this, the -operation `s2 = s1` could be very expensive in terms of runtime performance if -the data on the heap were large. - -s1 and s2 to two places - -Figure 4-3: Another possibility for what `s2 = s1` might -do if Rust copied the heap data as well - -Earlier, we said that when a variable goes out of scope, Rust automatically -calls the `drop` function and cleans up the heap memory for that variable. But -Figure 4-2 shows both data pointers pointing to the same location. This is a -problem: when `s2` and `s1` go out of scope, they will both try to free the -same memory. This is known as a *double free* error and is one of the memory -safety bugs we mentioned previously. Freeing memory twice can lead to memory -corruption, which can potentially lead to security vulnerabilities. - -To ensure memory safety, there’s one more detail to what happens in this -situation in Rust. Instead of trying to copy the allocated memory, Rust -considers `s1` to no longer be valid and, therefore, Rust doesn’t need to free -anything when `s1` goes out of scope. Check out what happens when you try to -use `s1` after `s2` is created; it won’t work: - -```rust,ignore -let s1 = String::from("hello"); -let s2 = s1; - -println!("{}, world!", s1); -``` - -You’ll get an error like this because Rust prevents you from using the -invalidated reference: - -```text -error[E0382]: use of moved value: `s1` - --> src/main.rs:5:28 - | -3 | let s2 = s1; - | -- value moved here -4 | -5 | println!("{}, world!", s1); - | ^^ value used here after move - | - = note: move occurs because `s1` has type `std::string::String`, which does - not implement the `Copy` trait -``` - -If you’ve heard the terms *shallow copy* and *deep copy* while working with -other languages, the concept of copying the pointer, length, and capacity -without copying the data probably sounds like making a shallow copy. But -because Rust also invalidates the first variable, instead of being called a -shallow copy, it’s known as a *move*. Here we would read this by saying that -`s1` was *moved* into `s2`. So what actually happens is shown in Figure 4-4. - -s1 moved to s2 - -Figure 4-4: Representation in memory after `s1` has been -invalidated - -That solves our problem! With only `s2` valid, when it goes out of scope, it -alone will free the memory, and we’re done. - -In addition, there’s a design choice that’s implied by this: Rust will never -automatically create “deep” copies of your data. Therefore, any *automatic* -copying can be assumed to be inexpensive in terms of runtime performance. - -#### Ways Variables and Data Interact: Clone - -If we *do* want to deeply copy the heap data of the `String`, not just the -stack data, we can use a common method called `clone`. We’ll discuss method -syntax in Chapter 5, but because methods are a common feature in many -programming languages, you’ve probably seen them before. - -Here’s an example of the `clone` method in action: - -```rust -let s1 = String::from("hello"); -let s2 = s1.clone(); - -println!("s1 = {}, s2 = {}", s1, s2); -``` - -This works just fine and explicitly produces the behavior shown in Figure 4-3, -where the heap data *does* get copied. - -When you see a call to `clone`, you know that some arbitrary code is being -executed and that code may be expensive. It’s a visual indicator that something -different is going on. - -#### Stack-Only Data: Copy - -There’s another wrinkle we haven’t talked about yet. This code using integers, -part of which was shown earlier in Listing 4-2, works and is valid: - -```rust -let x = 5; -let y = x; - -println!("x = {}, y = {}", x, y); -``` - -But this code seems to contradict what we just learned: we don’t have a call to -`clone`, but `x` is still valid and wasn’t moved into `y`. - -The reason is that types such as integers that have a known size at compile -time are stored entirely on the stack, so copies of the actual values are quick -to make. That means there’s no reason we would want to prevent `x` from being -valid after we create the variable `y`. In other words, there’s no difference -between deep and shallow copying here, so calling `clone` wouldn’t do anything -different from the usual shallow copying and we can leave it out. - -Rust has a special annotation called the `Copy` trait that we can place on -types like integers that are stored on the stack (we’ll talk more about traits -in Chapter 10). If a type has the `Copy` trait, an older variable is still -usable after assignment. Rust won’t let us annotate a type with the `Copy` -trait if the type, or any of its parts, has implemented the `Drop` trait. If -the type needs something special to happen when the value goes out of scope and -we add the `Copy` annotation to that type, we’ll get a compile time error. To -learn about how to add the `Copy` annotation to your type, see “Derivable -Traits” in Appendix C. - -So what types are `Copy`? You can check the documentation for the given type to -be sure, but as a general rule, any group of simple scalar values can be -`Copy`, and nothing that requires allocation or is some form of resource is -`Copy`. Here are some of the types that are `Copy`: - -* All the integer types, such as `u32`. -* The Boolean type, `bool`, with values `true` and `false`. -* All the floating point types, such as `f64`. -* The character type, `char`. -* Tuples, but only if they contain types that are also `Copy`. For example, - `(i32, i32)` is `Copy`, but `(i32, String)` is not. - -### Ownership and Functions - -The semantics for passing a value to a function are similar to those for -assigning a value to a variable. Passing a variable to a function will move or -copy, just as assignment does. Listing 4-3 has an example with some annotations -showing where variables go into and out of scope: - -Filename: src/main.rs - -```rust -fn main() { - let s = String::from("hello"); // s comes into scope - - takes_ownership(s); // s's value moves into the function... - // ... and so is no longer valid here - - let x = 5; // x comes into scope - - makes_copy(x); // x would move into the function, - // but i32 is Copy, so it’s okay to still - // use x afterward - -} // Here, x goes out of scope, then s. But because s's value was moved, nothing - // special happens. - -fn takes_ownership(some_string: String) { // some_string comes into scope - println!("{}", some_string); -} // Here, some_string goes out of scope and `drop` is called. The backing - // memory is freed. - -fn makes_copy(some_integer: i32) { // some_integer comes into scope - println!("{}", some_integer); -} // Here, some_integer goes out of scope. Nothing special happens. -``` - -Listing 4-3: Functions with ownership and scope -annotated - -If we tried to use `s` after the call to `takes_ownership`, Rust would throw a -compile time error. These static checks protect us from mistakes. Try adding -code to `main` that uses `s` and `x` to see where you can use them and where -the ownership rules prevent you from doing so. - -### Return Values and Scope - -Returning values can also transfer ownership. Listing 4-4 is an example with -similar annotations to those in Listing 4-3: - -Filename: src/main.rs - -```rust -fn main() { - let s1 = gives_ownership(); // gives_ownership moves its return - // value into s1 - - let s2 = String::from("hello"); // s2 comes into scope - - let s3 = takes_and_gives_back(s2); // s2 is moved into - // takes_and_gives_back, which also - // moves its return value into s3 -} // Here, s3 goes out of scope and is dropped. s2 goes out of scope but was - // moved, so nothing happens. s1 goes out of scope and is dropped. - -fn gives_ownership() -> String { // gives_ownership will move its - // return value into the function - // that calls it - - let some_string = String::from("hello"); // some_string comes into scope - - some_string // some_string is returned and - // moves out to the calling - // function. -} - -// takes_and_gives_back will take a String and return one. -fn takes_and_gives_back(a_string: String) -> String { // a_string comes into - // scope - - a_string // a_string is returned and moves out to the calling function -} -``` - -Listing 4-4: Transferring ownership of return -values - -The ownership of a variable follows the same pattern every time: assigning a -value to another variable moves it. When a variable that includes data on the -heap goes out of scope, the value will be cleaned up by `drop` unless the data -has been moved to be owned by another variable. - -Taking ownership and then returning ownership with every function is a bit -tedious. What if we want to let a function use a value but not take ownership? -It’s quite annoying that anything we pass in also needs to be passed back if we -want to use it again, in addition to any data resulting from the body of the -function that we might want to return as well. - -It’s possible to return multiple values using a tuple, as shown in Listing 4-5: - -Filename: src/main.rs - -```rust -fn main() { - let s1 = String::from("hello"); - - let (s2, len) = calculate_length(s1); - - println!("The length of '{}' is {}.", s2, len); -} - -fn calculate_length(s: String) -> (String, usize) { - let length = s.len(); // len() returns the length of a String - - (s, length) -} -``` - -Listing 4-5: Returning ownership of parameters - -But this is too much ceremony and a lot of work for a concept that should be -common. Luckily for us, Rust has a feature for this concept, called -*references*. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch04-01-what-is-ownership.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch04-02-references-and-borrowing.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch04-02-references-and-borrowing.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch04-02-references-and-borrowing.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch04-02-references-and-borrowing.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,322 +1,10 @@ ## References and Borrowing -The issue with the tuple code in Listing 4-5 is that we have to return the -`String` to the calling function so we can still use the `String` after the -call to `calculate_length`, because the `String` was moved into -`calculate_length`. +The 2018 edition of the book is no longer distributed with Rust's documentation. -Here is how you would define and use a `calculate_length` function that has a -reference to an object as a parameter instead of taking ownership of the -value: +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -Filename: src/main.rs - -```rust -fn main() { - let s1 = String::from("hello"); - - let len = calculate_length(&s1); - - println!("The length of '{}' is {}.", s1, len); -} - -fn calculate_length(s: &String) -> usize { - s.len() -} -``` - -First, notice that all the tuple code in the variable declaration and the -function return value is gone. Second, note that we pass `&s1` into -`calculate_length` and, in its definition, we take `&String` rather than -`String`. - -These ampersands are *references*, and they allow you to refer to some value -without taking ownership of it. Figure 4-5 shows a diagram. - -&String s pointing at String s1 - -Figure 4-5: A diagram of `&String s` pointing at `String -s1` - -> Note: The opposite of referencing by using `&` is *dereferencing*, which is -> accomplished with the dereference operator, `*`. We’ll see some uses of the -> dereference operator in Chapter 8 and discuss details of dereferencing in -> Chapter 15. - -Let’s take a closer look at the function call here: - -```rust -# fn calculate_length(s: &String) -> usize { -# s.len() -# } -let s1 = String::from("hello"); - -let len = calculate_length(&s1); -``` - -The `&s1` syntax lets us create a reference that *refers* to the value of `s1` -but does not own it. Because it does not own it, the value it points to will -not be dropped when the reference goes out of scope. - -Likewise, the signature of the function uses `&` to indicate that the type of -the parameter `s` is a reference. Let’s add some explanatory annotations: - -```rust -fn calculate_length(s: &String) -> usize { // s is a reference to a String - s.len() -} // Here, s goes out of scope. But because it does not have ownership of what - // it refers to, nothing happens. -``` - -The scope in which the variable `s` is valid is the same as any function -parameter’s scope, but we don’t drop what the reference points to when it goes -out of scope because we don’t have ownership. When functions have references as -parameters instead of the actual values, we won’t need to return the values in -order to give back ownership, because we never had ownership. - -We call having references as function parameters *borrowing*. As in real life, -if a person owns something, you can borrow it from them. When you’re done, you -have to give it back. - -So what happens if we try to modify something we’re borrowing? Try the code in -Listing 4-6. Spoiler alert: it doesn’t work! - -Filename: src/main.rs - -```rust,ignore -fn main() { - let s = String::from("hello"); - - change(&s); -} - -fn change(some_string: &String) { - some_string.push_str(", world"); -} -``` - -Listing 4-6: Attempting to modify a borrowed value - -Here’s the error: - -```text -error[E0596]: cannot borrow immutable borrowed content `*some_string` as mutable - --> error.rs:8:5 - | -7 | fn change(some_string: &String) { - | ------- use `&mut String` here to make mutable -8 | some_string.push_str(", world"); - | ^^^^^^^^^^^ cannot borrow as mutable -``` - -Just as variables are immutable by default, so are references. We’re not -allowed to modify something we have a reference to. - -### Mutable References - -We can fix the error in the code from Listing 4-6 with just a small tweak: - -Filename: src/main.rs - -```rust -fn main() { - let mut s = String::from("hello"); - - change(&mut s); -} - -fn change(some_string: &mut String) { - some_string.push_str(", world"); -} -``` - -First, we had to change `s` to be `mut`. Then we had to create a mutable -reference with `&mut s` and accept a mutable reference with `some_string: &mut -String`. - -But mutable references have one big restriction: you can only have one mutable -reference to a particular piece of data in a particular scope. This code will -fail: - -Filename: src/main.rs - -```rust,ignore -let mut s = String::from("hello"); - -let r1 = &mut s; -let r2 = &mut s; -``` - -Here’s the error: - -```text -error[E0499]: cannot borrow `s` as mutable more than once at a time - --> borrow_twice.rs:5:19 - | -4 | let r1 = &mut s; - | - first mutable borrow occurs here -5 | let r2 = &mut s; - | ^ second mutable borrow occurs here -6 | } - | - first borrow ends here -``` - -This restriction allows for mutation but in a very controlled fashion. It’s -something that new Rustaceans struggle with, because most languages let you -mutate whenever you’d like. - -The benefit of having this restriction is that Rust can prevent data races at -compile time. A *data race* is similar to a race condition and happens when -these three behaviors occur: - -* Two or more pointers access the same data at the same time. -* At least one of the pointers is being used to write to the data. -* There’s no mechanism being used to synchronize access to the data. - -Data races cause undefined behavior and can be difficult to diagnose and fix -when you’re trying to track them down at runtime; Rust prevents this problem -from happening because it won’t even compile code with data races! - -As always, we can use curly brackets to create a new scope, allowing for -multiple mutable references, just not *simultaneous* ones: - -```rust -let mut s = String::from("hello"); - -{ - let r1 = &mut s; - -} // r1 goes out of scope here, so we can make a new reference with no problems. - -let r2 = &mut s; -``` - -A similar rule exists for combining mutable and immutable references. This code -results in an error: - -```rust,ignore -let mut s = String::from("hello"); - -let r1 = &s; // no problem -let r2 = &s; // no problem -let r3 = &mut s; // BIG PROBLEM -``` - -Here’s the error: - -```text -error[E0502]: cannot borrow `s` as mutable because it is also borrowed as -immutable - --> borrow_thrice.rs:6:19 - | -4 | let r1 = &s; // no problem - | - immutable borrow occurs here -5 | let r2 = &s; // no problem -6 | let r3 = &mut s; // BIG PROBLEM - | ^ mutable borrow occurs here -7 | } - | - immutable borrow ends here -``` - -Whew! We *also* cannot have a mutable reference while we have an immutable one. -Users of an immutable reference don’t expect the values to suddenly change out -from under them! However, multiple immutable references are okay because no one -who is just reading the data has the ability to affect anyone else’s reading of -the data. - -Even though these errors may be frustrating at times, remember that it’s the -Rust compiler pointing out a potential bug early (at compile time rather than -at runtime) and showing you exactly where the problem is. Then you don’t have -to track down why your data isn’t what you thought it was. - -### Dangling References - -In languages with pointers, it’s easy to erroneously create a *dangling -pointer*, a pointer that references a location in memory that may have been -given to someone else, by freeing some memory while preserving a pointer to -that memory. In Rust, by contrast, the compiler guarantees that references will -never be dangling references: if you have a reference to some data, the -compiler will ensure that the data will not go out of scope before the -reference to the data does. - -Let’s try to create a dangling reference, which Rust will prevent with a -compile-time error: - -Filename: src/main.rs - -```rust,ignore -fn main() { - let reference_to_nothing = dangle(); -} - -fn dangle() -> &String { - let s = String::from("hello"); - - &s -} -``` - -Here’s the error: - -```text -error[E0106]: missing lifetime specifier - --> dangle.rs:5:16 - | -5 | fn dangle() -> &String { - | ^ expected lifetime parameter - | - = help: this function's return type contains a borrowed value, but there is - no value for it to be borrowed from - = help: consider giving it a 'static lifetime -``` - -This error message refers to a feature we haven’t covered yet: *lifetimes*. -We’ll discuss lifetimes in detail in Chapter 10. But, if you disregard the -parts about lifetimes, the message does contain the key to why this code is a -problem: - -```text -this function's return type contains a borrowed value, but there is no value -for it to be borrowed from. -``` - -Let’s take a closer look at exactly what’s happening at each stage of our -`dangle` code: - -```rust,ignore -fn dangle() -> &String { // dangle returns a reference to a String - - let s = String::from("hello"); // s is a new String - - &s // we return a reference to the String, s -} // Here, s goes out of scope, and is dropped. Its memory goes away. - // Danger! -``` - -Because `s` is created inside `dangle`, when the code of `dangle` is finished, -`s` will be deallocated. But we tried to return a reference to it. That means -this reference would be pointing to an invalid `String`. That’s no good! Rust -won’t let us do this. - -The solution here is to return the `String` directly: - -```rust -fn no_dangle() -> String { - let s = String::from("hello"); - - s -} -``` - -This works without any problems. Ownership is moved out, and nothing is -deallocated. - -### The Rules of References - -Let’s recap what we’ve discussed about references: - -* At any given time, you can have *either* (but not both of) one mutable - reference or any number of immutable references. -* References must always be valid. - -Next, we’ll look at a different kind of reference: slices. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch04-02-references-and-borrowing.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch04-03-slices.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch04-03-slices.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch04-03-slices.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch04-03-slices.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,397 +1,10 @@ ## The Slice Type -Another data type that does not have ownership is the *slice*. Slices let you -reference a contiguous sequence of elements in a collection rather than the -whole collection. +The 2018 edition of the book is no longer distributed with Rust's documentation. -Here’s a small programming problem: write a function that takes a string and -returns the first word it finds in that string. If the function doesn’t find a -space in the string, the whole string must be one word, so the entire string -should be returned. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -Let’s think about the signature of this function: - -```rust,ignore -fn first_word(s: &String) -> ? -``` - -This function, `first_word`, has a `&String` as a parameter. We don’t want -ownership, so this is fine. But what should we return? We don’t really have a -way to talk about *part* of a string. However, we could return the index of the -end of the word. Let’s try that, as shown in Listing 4-7: - -Filename: src/main.rs - -```rust -fn first_word(s: &String) -> usize { - let bytes = s.as_bytes(); - - for (i, &item) in bytes.iter().enumerate() { - if item == b' ' { - return i; - } - } - - s.len() -} -``` - -Listing 4-7: The `first_word` function that returns a -byte index value into the `String` parameter - -Because we need to go through the `String` element by element and check whether -a value is a space, we’ll convert our `String` to an array of bytes using the -`as_bytes` method: - -```rust,ignore -let bytes = s.as_bytes(); -``` - -Next, we create an iterator over the array of bytes using the `iter` method: - -```rust,ignore -for (i, &item) in bytes.iter().enumerate() { -``` - -We’ll discuss iterators in more detail in Chapter 13. For now, know that `iter` -is a method that returns each element in a collection and that `enumerate` -wraps the result of `iter` and returns each element as part of a tuple instead. -The first element of the tuple returned from `enumerate` is the index, and the -second element is a reference to the element. This is a bit more convenient -than calculating the index ourselves. - -Because the `enumerate` method returns a tuple, we can use patterns to -destructure that tuple, just like everywhere else in Rust. So in the `for` -loop, we specify a pattern that has `i` for the index in the tuple and `&item` -for the single byte in the tuple. Because we get a reference to the element -from `.iter().enumerate()`, we use `&` in the pattern. - -Inside the `for` loop, we search for the byte that represents the space by -using the byte literal syntax. If we find a space, we return the position. -Otherwise, we return the length of the string by using `s.len()`: - -```rust,ignore - if item == b' ' { - return i; - } -} -s.len() -``` - -We now have a way to find out the index of the end of the first word in the -string, but there’s a problem. We’re returning a `usize` on its own, but it’s -only a meaningful number in the context of the `&String`. In other words, -because it’s a separate value from the `String`, there’s no guarantee that it -will still be valid in the future. Consider the program in Listing 4-8 that -uses the `first_word` function from Listing 4-7: - -Filename: src/main.rs - -```rust -# fn first_word(s: &String) -> usize { -# let bytes = s.as_bytes(); -# -# for (i, &item) in bytes.iter().enumerate() { -# if item == b' ' { -# return i; -# } -# } -# -# s.len() -# } -# -fn main() { - let mut s = String::from("hello world"); - - let word = first_word(&s); // word will get the value 5 - - s.clear(); // This empties the String, making it equal to "" - - // word still has the value 5 here, but there's no more string that - // we could meaningfully use the value 5 with. word is now totally invalid! -} -``` - -Listing 4-8: Storing the result from calling the -`first_word` function and then changing the `String` contents - -This program compiles without any errors and would also do so if we used `word` -after calling `s.clear()`. Because `word` isn’t connected to the state of `s` -at all, `word` still contains the value `5`. We could use that value `5` with -the variable `s` to try to extract the first word out, but this would be a bug -because the contents of `s` have changed since we saved `5` in `word`. - -Having to worry about the index in `word` getting out of sync with the data in -`s` is tedious and error prone! Managing these indices is even more brittle if -we write a `second_word` function. Its signature would have to look like this: - -```rust,ignore -fn second_word(s: &String) -> (usize, usize) { -``` - -Now we’re tracking a starting *and* an ending index, and we have even more -values that were calculated from data in a particular state but aren’t tied to -that state at all. We now have three unrelated variables floating around that -need to be kept in sync. - -Luckily, Rust has a solution to this problem: string slices. - -### String Slices - -A *string slice* is a reference to part of a `String`, and it looks like this: - -```rust -let s = String::from("hello world"); - -let hello = &s[0..5]; -let world = &s[6..11]; -``` - -This is similar to taking a reference to the whole `String` but with the extra -`[0..5]` bit. Rather than a reference to the entire `String`, it’s a reference -to a portion of the `String`. The `start..end` syntax is a range that begins at -`start` and continues up to, but not including, `end`. If we wanted to include -`end`, we can use `..=` instead of `..`: - -```rust -let s = String::from("hello world"); - -let hello = &s[0..=4]; -let world = &s[6..=10]; -``` - -The `=` means that we're including the last number, if that helps you remember -the difference between `..` and `..=`. - -We can create slices using a range within brackets by specifying -`[starting_index..ending_index]`, where `starting_index` is the first position -in the slice and `ending_index` is one more than the last position in the -slice. Internally, the slice data structure stores the starting position and -the length of the slice, which corresponds to `ending_index` minus -`starting_index`. So in the case of `let world = &s[6..11];`, `world` would be -a slice that contains a pointer to the 7th byte of `s` and a length value of 5. - -Figure 4-6 shows this in a diagram. - -world containing a pointer to the 6th byte of String s and a length 5 - -Figure 4-6: String slice referring to part of a -`String` - -With Rust’s `..` range syntax, if you want to start at the first index (zero), -you can drop the value before the two periods. In other words, these are equal: - -```rust -let s = String::from("hello"); - -let slice = &s[0..2]; -let slice = &s[..2]; -``` - -By the same token, if your slice includes the last byte of the `String`, you -can drop the trailing number. That means these are equal: - -```rust -let s = String::from("hello"); - -let len = s.len(); - -let slice = &s[3..len]; -let slice = &s[3..]; -``` - -You can also drop both values to take a slice of the entire string. So these -are equal: - -```rust -let s = String::from("hello"); - -let len = s.len(); - -let slice = &s[0..len]; -let slice = &s[..]; -``` - -> Note: String slice range indices must occur at valid UTF-8 character -> boundaries. If you attempt to create a string slice in the middle of a -> multibyte character, your program will exit with an error. For the purposes -> of introducing string slices, we are assuming ASCII only in this section; a -> more thorough discussion of UTF-8 handling is in the “Strings” section of -> Chapter 8. - -With all this information in mind, let’s rewrite `first_word` to return a -slice. The type that signifies “string slice” is written as `&str`: - -Filename: src/main.rs - -```rust -fn first_word(s: &String) -> &str { - let bytes = s.as_bytes(); - - for (i, &item) in bytes.iter().enumerate() { - if item == b' ' { - return &s[0..i]; - } - } - - &s[..] -} -``` - -We get the index for the end of the word in the same way as we did in Listing -4-7, by looking for the first occurrence of a space. When we find a space, we -return a string slice using the start of the string and the index of the space -as the starting and ending indices. - -Now when we call `first_word`, we get back a single value that is tied to the -underlying data. The value is made up of a reference to the starting point of -the slice and the number of elements in the slice. - -Returning a slice would also work for a `second_word` function: - -```rust,ignore -fn second_word(s: &String) -> &str { -``` - -We now have a straightforward API that’s much harder to mess up, because the -compiler will ensure the references into the `String` remain valid. Remember -the bug in the program in Listing 4-8, when we got the index to the end of the -first word but then cleared the string so our index was invalid? That code was -logically incorrect but didn’t show any immediate errors. The problems would -show up later if we kept trying to use the first word index with an emptied -string. Slices make this bug impossible and let us know we have a problem with -our code much sooner. Using the slice version of `first_word` will throw a -compile time error: - -Filename: src/main.rs - -```rust,ignore -fn main() { - let mut s = String::from("hello world"); - - let word = first_word(&s); - - s.clear(); // Error! -} -``` - -Here’s the compiler error: - -```text -error[E0502]: cannot borrow `s` as mutable because it is also borrowed as immutable - --> src/main.rs:6:5 - | -4 | let word = first_word(&s); - | - immutable borrow occurs here -5 | -6 | s.clear(); // Error! - | ^ mutable borrow occurs here -7 | } - | - immutable borrow ends here -``` - -Recall from the borrowing rules that if we have an immutable reference to -something, we cannot also take a mutable reference. Because `clear` needs to -truncate the `String`, it tries to take a mutable reference, which fails. Not -only has Rust made our API easier to use, but it has also eliminated an entire -class of errors at compile time! - -#### String Literals Are Slices - -Recall that we talked about string literals being stored inside the binary. Now -that we know about slices, we can properly understand string literals: - -```rust -let s = "Hello, world!"; -``` - -The type of `s` here is `&str`: it’s a slice pointing to that specific point of -the binary. This is also why string literals are immutable; `&str` is an -immutable reference. - -#### String Slices as Parameters - -Knowing that you can take slices of literals and `String`s leads us to one more -improvement on `first_word`, and that’s its signature: - -```rust,ignore -fn first_word(s: &String) -> &str { -``` - -A more experienced Rustacean would write the following line instead because it -allows us to use the same function on both `String`s and `&str`s: - -```rust,ignore -fn first_word(s: &str) -> &str { -``` - -If we have a string slice, we can pass that directly. If we have a `String`, we -can pass a slice of the entire `String`. Defining a function to take a string -slice instead of a reference to a `String` makes our API more general and useful -without losing any functionality: - -Filename: src/main.rs - -```rust -# fn first_word(s: &str) -> &str { -# let bytes = s.as_bytes(); -# -# for (i, &item) in bytes.iter().enumerate() { -# if item == b' ' { -# return &s[0..i]; -# } -# } -# -# &s[..] -# } -fn main() { - let my_string = String::from("hello world"); - - // first_word works on slices of `String`s - let word = first_word(&my_string[..]); - - let my_string_literal = "hello world"; - - // first_word works on slices of string literals - let word = first_word(&my_string_literal[..]); - - // Because string literals *are* string slices already, - // this works too, without the slice syntax! - let word = first_word(my_string_literal); -} -``` - -### Other Slices - -String slices, as you might imagine, are specific to strings. But there’s a -more general slice type, too. Consider this array: - -```rust -let a = [1, 2, 3, 4, 5]; -``` - -Just as we might want to refer to a part of a string, we might want to refer -to part of an array. We’d do so like this: - -```rust -let a = [1, 2, 3, 4, 5]; - -let slice = &a[1..3]; -``` - -This slice has the type `&[i32]`. It works the same way as string slices do, by -storing a reference to the first element and a length. You’ll use this kind of -slice for all sorts of other collections. We’ll discuss these collections in -detail when we talk about vectors in Chapter 8. - -## Summary - -The concepts of ownership, borrowing, and slices ensure memory safety in Rust -programs at compile time. The Rust language gives you control over your memory -usage in the same way as other systems programming languages, but having the -owner of data automatically clean up that data when the owner goes out of scope -means you don’t have to write and debug extra code to get this control. - -Ownership affects how lots of other parts of Rust work, so we’ll talk about -these concepts further throughout the rest of the book. Let’s move on to -Chapter 5 and look at grouping pieces of data together in a `struct`. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch04-03-slices.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch05-00-structs.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch05-00-structs.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch05-00-structs.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch05-00-structs.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,11 +1,10 @@ # Using Structs to Structure Related Data -A *struct*, or *structure*, is a custom data type that lets you name and -package together multiple related values that make up a meaningful group. If -you’re familiar with an object-oriented language, a *struct* is like an -object’s data attributes. In this chapter, we’ll compare and contrast tuples -with structs, demonstrate how to use structs, and discuss how to define methods -and associated functions to specify behavior associated with a struct’s data. -Structs and enums (discussed in Chapter 6) are the building blocks for creating -new types in your program’s domain to take full advantage of Rust’s compile -time type checking. +The 2018 edition of the book is no longer distributed with Rust's documentation. + +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. + +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch05-00-structs.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch05-01-defining-structs.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch05-01-defining-structs.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch05-01-defining-structs.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch05-01-defining-structs.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,310 +1,10 @@ ## Defining and Instantiating Structs -Structs are similar to tuples, which were discussed in Chapter 3. Like tuples, -the pieces of a struct can be different types. Unlike with tuples, you’ll name -each piece of data so it’s clear what the values mean. As a result of these -names, structs are more flexible than tuples: you don’t have to rely on the -order of the data to specify or access the values of an instance. +The 2018 edition of the book is no longer distributed with Rust's documentation. -To define a struct, we enter the keyword `struct` and name the entire struct. A -struct’s name should describe the significance of the pieces of data being -grouped together. Then, inside curly brackets, we define the names and types of -the pieces of data, which we call *fields*. For example, Listing 5-1 shows a -struct that stores information about a user account: +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -```rust -struct User { - username: String, - email: String, - sign_in_count: u64, - active: bool, -} -``` - -Listing 5-1: A `User` struct definition - -To use a struct after we’ve defined it, we create an *instance* of that struct -by specifying concrete values for each of the fields. We create an instance by -stating the name of the struct and then add curly brackets containing `key: -value` pairs, where the keys are the names of the fields and the values are the -data we want to store in those fields. We don’t have to specify the fields in -the same order in which we declared them in the struct. In other words, the -struct definition is like a general template for the type, and instances fill -in that template with particular data to create values of the type. For -example, we can declare a particular user as shown in Listing 5-2: - -```rust -# struct User { -# username: String, -# email: String, -# sign_in_count: u64, -# active: bool, -# } -# -let user1 = User { - email: String::from("someone@example.com"), - username: String::from("someusername123"), - active: true, - sign_in_count: 1, -}; -``` - -Listing 5-2: Creating an instance of the `User` -struct - -To get a specific value from a struct, we can use dot notation. If we wanted -just this user’s email address, we could use `user1.email` wherever we wanted -to use this value. If the instance is mutable, we can change a value by using -the dot notation and assigning into a particular field. Listing 5-3 shows how -to change the value in the `email` field of a mutable `User` instance: - -```rust -# struct User { -# username: String, -# email: String, -# sign_in_count: u64, -# active: bool, -# } -# -let mut user1 = User { - email: String::from("someone@example.com"), - username: String::from("someusername123"), - active: true, - sign_in_count: 1, -}; - -user1.email = String::from("anotheremail@example.com"); -``` - -Listing 5-3: Changing the value in the `email` field of a -`User` instance - -Note that the entire instance must be mutable; Rust doesn’t allow us to mark -only certain fields as mutable. - -As with any expression, we can construct a new instance of the struct as the -last expression in the function body to implicitly return that new instance. -Listing 5-4 shows a `build_user` function that returns a `User` instance with -the given email and username. The `active` field gets the value of `true`, and -the `sign_in_count` gets a value of `1`. - -```rust -# struct User { -# username: String, -# email: String, -# sign_in_count: u64, -# active: bool, -# } -# -fn build_user(email: String, username: String) -> User { - User { - email: email, - username: username, - active: true, - sign_in_count: 1, - } -} -``` - -Listing 5-4: A `build_user` function that takes an email -and username and returns a `User` instance - -It makes sense to name the function parameters with the same name as the struct -fields, but having to repeat the `email` and `username` field names and -variables is a bit tedious. If the struct had more fields, repeating each name -would get even more annoying. Luckily, there’s a convenient shorthand! - -### Using the Field Init Shorthand when Variables and Fields Have the Same Name - -Because the parameter names and the struct field names are exactly the same in -Listing 5-4, we can use the *field init shorthand* syntax to rewrite -`build_user` so that it behaves exactly the same but doesn’t have the -repetition of `email` and `username` as shown in Listing 5-5. - -```rust -# struct User { -# username: String, -# email: String, -# sign_in_count: u64, -# active: bool, -# } -# -fn build_user(email: String, username: String) -> User { - User { - email, - username, - active: true, - sign_in_count: 1, - } -} -``` - -Listing 5-5: A `build_user` function that uses field init -shorthand because the `email` and `username` parameters have the same name as -struct fields - -Here, we’re creating a new instance of the `User` struct, which has a field -named `email`. We want to set the `email` field’s value to the value in the -`email` parameter of the `build_user` function. Because the `email` field and -the `email` parameter have the same name, we only need to write `email` rather -than `email: email`. - -### Creating Instances From Other Instances With Struct Update Syntax - -It’s often useful to create a new instance of a struct that uses most of an old -instance’s values but changes some. You’ll do this using *struct update syntax*. - -First, Listing 5-6 shows how we create a new `User` instance in `user2` without -the update syntax. We set new values for `email` and `username` but otherwise -use the same values from `user1` that we created in Listing 5-2: - -```rust -# struct User { -# username: String, -# email: String, -# sign_in_count: u64, -# active: bool, -# } -# -# let user1 = User { -# email: String::from("someone@example.com"), -# username: String::from("someusername123"), -# active: true, -# sign_in_count: 1, -# }; -# -let user2 = User { - email: String::from("another@example.com"), - username: String::from("anotherusername567"), - active: user1.active, - sign_in_count: user1.sign_in_count, -}; -``` - -Listing 5-6: Creating a new `User` instance using some of -the values from `user1` - -Using struct update syntax, we can achieve the same effect with less code, as -shown in Listing 5-7. The syntax `..` specifies that the remaining fields not -explicitly set should have the same value as the fields in the given instance. - -```rust -# struct User { -# username: String, -# email: String, -# sign_in_count: u64, -# active: bool, -# } -# -# let user1 = User { -# email: String::from("someone@example.com"), -# username: String::from("someusername123"), -# active: true, -# sign_in_count: 1, -# }; -# -let user2 = User { - email: String::from("another@example.com"), - username: String::from("anotherusername567"), - ..user1 -}; -``` - -Listing 5-7: Using struct update syntax to set new -`email` and `username` values for a `User` instance but use the rest of the -values from the fields of the instance in the `user1` variable - -The code in Listing 5-7 also creates an instance in `user2` that has a -different value for `email` and `username` but has the same values for the -`active` and `sign_in_count` fields from `user1`. - -### Tuple Structs without Named Fields to Create Different Types - -You can also define structs that look similar to tuples, called *tuple -structs*. Tuple structs have the added meaning the struct name provides but -don’t have names associated with their fields; rather, they just have the types -of the fields. Tuple structs are useful when you want to give the whole tuple a -name and make the tuple be a different type than other tuples, and naming each -field as in a regular struct would be verbose or redundant. - -To define a tuple struct start with the `struct` keyword and the struct name -followed by the types in the tuple. For example, here are definitions and -usages of two tuple structs named `Color` and `Point`: - -```rust -struct Color(i32, i32, i32); -struct Point(i32, i32, i32); - -let black = Color(0, 0, 0); -let origin = Point(0, 0, 0); -``` - -Note that the `black` and `origin` values are different types, because they’re -instances of different tuple structs. Each struct you define is its own type, -even though the fields within the struct have the same types. For example, a -function that takes a parameter of type `Color` cannot take a `Point` as an -argument, even though both types are made up of three `i32` values. Otherwise, -tuple struct instances behave like tuples: you can destructure them into their -individual pieces, you can use a `.` followed by the index to access an -individual value, and so on. - -### Unit-Like Structs Without Any Fields - -You can also define structs that don’t have any fields! These are called -*unit-like structs* because they behave similarly to `()`, the unit type. -Unit-like structs can be useful in situations in which you need to implement a -trait on some type but don’t have any data that you want to store in the type -itself. We’ll discuss traits in Chapter 10. - -> ### Ownership of Struct Data -> -> In the `User` struct definition in Listing 5-1, we used the owned `String` -> type rather than the `&str` string slice type. This is a deliberate choice -> because we want instances of this struct to own all of its data and for that -> data to be valid for as long as the entire struct is valid. -> -> It’s possible for structs to store references to data owned by something else, -> but to do so requires the use of *lifetimes*, a Rust feature that we’ll -> discuss in Chapter 10. Lifetimes ensure that the data referenced by a struct -> is valid for as long as the struct is. Let’s say you try to store a reference -> in a struct without specifying lifetimes, like this, which won’t work: -> -> Filename: src/main.rs -> -> ```rust,ignore -> struct User { -> username: &str, -> email: &str, -> sign_in_count: u64, -> active: bool, -> } -> -> fn main() { -> let user1 = User { -> email: "someone@example.com", -> username: "someusername123", -> active: true, -> sign_in_count: 1, -> }; -> } -> ``` -> -> The compiler will complain that it needs lifetime specifiers: -> -> ```text -> error[E0106]: missing lifetime specifier -> --> -> | -> 2 | username: &str, -> | ^ expected lifetime parameter -> -> error[E0106]: missing lifetime specifier -> --> -> | -> 3 | email: &str, -> | ^ expected lifetime parameter -> ``` -> -> In Chapter 10, we’ll discuss how to fix these errors so you can store -> references in structs, but for now, we’ll fix errors like these using owned -> types like `String` instead of references like `&str`. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch05-01-defining-structs.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch05-02-example-structs.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch05-02-example-structs.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch05-02-example-structs.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch05-02-example-structs.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,264 +1,10 @@ ## An Example Program Using Structs -To understand when we might want to use structs, let’s write a program that -calculates the area of a rectangle. We’ll start with single variables, and then -refactor the program until we’re using structs instead. +The 2018 edition of the book is no longer distributed with Rust's documentation. -Let’s make a new binary project with Cargo called *rectangles* that will take -the width and height of a rectangle specified in pixels and calculate the area -of the rectangle. Listing 5-8 shows a short program with one way of doing -exactly that in our project’s *src/main.rs*: +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -Filename: src/main.rs - -```rust -fn main() { - let width1 = 30; - let height1 = 50; - - println!( - "The area of the rectangle is {} square pixels.", - area(width1, height1) - ); -} - -fn area(width: u32, height: u32) -> u32 { - width * height -} -``` - -Listing 5-8: Calculating the area of a rectangle -specified by separate width and height variables - -Now, run this program using `cargo run`: - -```text -The area of the rectangle is 1500 square pixels. -``` - -Even though Listing 5-8 works and figures out the area of the rectangle by -calling the `area` function with each dimension, we can do better. The width -and the height are related to each other because together they describe one -rectangle. - -The issue with this code is evident in the signature of `area`: - -```rust,ignore -fn area(width: u32, height: u32) -> u32 { -``` - -The `area` function is supposed to calculate the area of one rectangle, but the -function we wrote has two parameters. The parameters are related, but that’s -not expressed anywhere in our program. It would be more readable and more -manageable to group width and height together. We’ve already discussed one way -we might do that in “The Tuple Type” section of Chapter 3: by using tuples. - -### Refactoring with Tuples - -Listing 5-9 shows another version of our program that uses tuples: - -Filename: src/main.rs - -```rust -fn main() { - let rect1 = (30, 50); - - println!( - "The area of the rectangle is {} square pixels.", - area(rect1) - ); -} - -fn area(dimensions: (u32, u32)) -> u32 { - dimensions.0 * dimensions.1 -} -``` - -Listing 5-9: Specifying the width and height of the -rectangle with a tuple - -In one way, this program is better. Tuples let us add a bit of structure, and -we’re now passing just one argument. But in another way, this version is less -clear: tuples don’t name their elements, so our calculation has become more -confusing because we have to index into the parts of the tuple. - -It doesn’t matter if we mix up width and height for the area calculation, but -if we want to draw the rectangle on the screen, it would matter! We would have -to keep in mind that `width` is the tuple index `0` and `height` is the tuple -index `1`. If someone else worked on this code, they would have to figure this -out and keep it in mind as well. It would be easy to forget or mix up these -values and cause errors, because we haven’t conveyed the meaning of our data in -our code. - -### Refactoring with Structs: Adding More Meaning - -We use structs to add meaning by labeling the data. We can transform the tuple -we’re using into a data type with a name for the whole as well as names for the -parts, as shown in Listing 5-10: - -Filename: src/main.rs - -```rust -struct Rectangle { - width: u32, - height: u32, -} - -fn main() { - let rect1 = Rectangle { width: 30, height: 50 }; - - println!( - "The area of the rectangle is {} square pixels.", - area(&rect1) - ); -} - -fn area(rectangle: &Rectangle) -> u32 { - rectangle.width * rectangle.height -} -``` - -Listing 5-10: Defining a `Rectangle` struct - -Here we’ve defined a struct and named it `Rectangle`. Inside the curly -brackets, we defined the fields as `width` and `height`, both of which have -type `u32`. Then in `main`, we created a particular instance of `Rectangle` -that has a width of 30 and a height of 50. - -Our `area` function is now defined with one parameter, which we’ve named -`rectangle`, whose type is an immutable borrow of a struct `Rectangle` -instance. As mentioned in Chapter 4, we want to borrow the struct rather than -take ownership of it. This way, `main` retains its ownership and can continue -using `rect1`, which is the reason we use the `&` in the function signature and -where we call the function. - -The `area` function accesses the `width` and `height` fields of the `Rectangle` -instance. Our function signature for `area` now says exactly what we mean: -calculate the area of `Rectangle`, using its `width` and `height` fields. This -conveys that the width and height are related to each other, and it gives -descriptive names to the values rather than using the tuple index values of `0` -and `1`. This is a win for clarity. - -### Adding Useful Functionality with Derived Traits - -It’d be nice to be able to print an instance of `Rectangle` while we’re -debugging our program and see the values for all its fields. Listing 5-11 tries -using the `println!` macro as we have used in previous chapters. This won’t -work, however: - -Filename: src/main.rs - -```rust,ignore -struct Rectangle { - width: u32, - height: u32, -} - -fn main() { - let rect1 = Rectangle { width: 30, height: 50 }; - - println!("rect1 is {}", rect1); -} -``` - -Listing 5-11: Attempting to print a `Rectangle` -instance - -When we run this code, we get an error with this core message: - -```text -error[E0277]: the trait bound `Rectangle: std::fmt::Display` is not satisfied -``` - -The `println!` macro can do many kinds of formatting, and by default, curly -brackets tell `println!` to use formatting known as `Display`: output intended -for direct end user consumption. The primitive types we’ve seen so far -implement `Display` by default, because there’s only one way you’d want to show -a `1` or any other primitive type to a user. But with structs, the way -`println!` should format the output is less clear because there are more -display possibilities: Do you want commas or not? Do you want to print the -curly brackets? Should all the fields be shown? Due to this ambiguity, Rust -doesn’t try to guess what we want, and structs don’t have a provided -implementation of `Display`. - -If we continue reading the errors, we’ll find this helpful note: - -```text -`Rectangle` cannot be formatted with the default formatter; try using -`:?` instead if you are using a format string -``` - -Let’s try it! The `println!` macro call will now look like `println!("rect1 is -{:?}", rect1);`. Putting the specifier `:?` inside the curly brackets tells -`println!` we want to use an output format called `Debug`. `Debug` is a trait -that enables us to print our struct in a way that is useful for developers so -we can see its value while we’re debugging our code. - -Run the code with this change. Drat! We still get an error: - -```text -error[E0277]: the trait bound `Rectangle: std::fmt::Debug` is not satisfied -``` - -But again, the compiler gives us a helpful note: - -```text -`Rectangle` cannot be formatted using `:?`; if it is defined in your -crate, add `#[derive(Debug)]` or manually implement it -``` - -Rust *does* include functionality to print out debugging information, but we -have to explicitly opt in to make that functionality available for our struct. -To do that, we add the annotation `#[derive(Debug)]` just before the struct -definition, as shown in Listing 5-12: - -Filename: src/main.rs - -```rust -#[derive(Debug)] -struct Rectangle { - width: u32, - height: u32, -} - -fn main() { - let rect1 = Rectangle { width: 30, height: 50 }; - - println!("rect1 is {:?}", rect1); -} -``` - -Listing 5-12: Adding the annotation to derive the `Debug` -trait and printing the `Rectangle` instance using debug formatting - -Now when we run the program, we won’t get any errors, and we’ll see the -following output: - -```text -rect1 is Rectangle { width: 30, height: 50 } -``` - -Nice! It’s not the prettiest output, but it shows the values of all the fields -for this instance, which would definitely help during debugging. When we have -larger structs, it’s useful to have output that’s a bit easier to read; in -those cases, we can use `{:#?}` instead of `{:?}` in the `println!` string. -When we use the `{:#?}` style in the example, the output will look like this: - -```text -rect1 is Rectangle { - width: 30, - height: 50 -} -``` - -Rust has provided a number of traits for us to use with the `derive` annotation -that can add useful behavior to our custom types. Those traits and their -behaviors are listed in Appendix C, “Derivable Traits.” We’ll cover how to -implement these traits with custom behavior as well as how to create your own -traits in Chapter 10. - -Our `area` function is very specific: it only computes the area of rectangles. -It would be helpful to tie this behavior more closely to our `Rectangle` -struct, because it won’t work with any other type. Let’s look at how we can -continue to refactor this code by turning the `area` function into an `area` -*method* defined on our `Rectangle` type. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch05-02-example-structs.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch05-03-method-syntax.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch05-03-method-syntax.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch05-03-method-syntax.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch05-03-method-syntax.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,276 +1,10 @@ ## Method Syntax -*Methods* are similar to functions: they’re declared with the `fn` keyword and -their name, they can have parameters and a return value, and they contain some -code that is run when they’re called from somewhere else. However, methods are -different from functions in that they’re defined within the context of a struct -(or an enum or a trait object, which we cover in Chapters 6 and 17, -respectively), and their first parameter is always `self`, which represents the -instance of the struct the method is being called on. +The 2018 edition of the book is no longer distributed with Rust's documentation. -### Defining Methods +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -Let’s change the `area` function that has a `Rectangle` instance as a parameter -and instead make an `area` method defined on the `Rectangle` struct, as shown -in Listing 5-13: - -Filename: src/main.rs - -```rust -#[derive(Debug)] -struct Rectangle { - width: u32, - height: u32, -} - -impl Rectangle { - fn area(&self) -> u32 { - self.width * self.height - } -} - -fn main() { - let rect1 = Rectangle { width: 30, height: 50 }; - - println!( - "The area of the rectangle is {} square pixels.", - rect1.area() - ); -} -``` - -Listing 5-13: Defining an `area` method on the -`Rectangle` struct - -To define the function within the context of `Rectangle`, we start an `impl` -(implementation) block. Then we move the `area` function within the `impl` -curly brackets and change the first (and in this case, only) parameter to be -`self` in the signature and everywhere within the body. In `main`, where we -called the `area` function and passed `rect1` as an argument, we can instead -use *method syntax* to call the `area` method on our `Rectangle` instance. -The method syntax goes after an instance: we add a dot followed by the method -name, parentheses, and any arguments. - -In the signature for `area`, we use `&self` instead of `rectangle: &Rectangle` -because Rust knows the type of `self` is `Rectangle` due to this method’s being -inside the `impl Rectangle` context. Note that we still need to use the `&` -before `self`, just as we did in `&Rectangle`. Methods can take ownership of -`self`, borrow `self` immutably as we’ve done here, or borrow `self` mutably, -just as they can any other parameter. - -We’ve chosen `&self` here for the same reason we used `&Rectangle` in the -function version: we don’t want to take ownership, and we just want to read the -data in the struct, not write to it. If we wanted to change the instance that -we’ve called the method on as part of what the method does, we’d use `&mut -self` as the first parameter. Having a method that takes ownership of the -instance by using just `self` as the first parameter is rare; this technique is -usually used when the method transforms `self` into something else and you want -to prevent the caller from using the original instance after the transformation. - -The main benefit of using methods instead of functions, in addition to using -method syntax and not having to repeat the type of `self` in every method’s -signature, is for organization. We’ve put all the things we can do with an -instance of a type in one `impl` block rather than making future users of our -code search for capabilities of `Rectangle` in various places in the library we -provide. - -> ### Where’s the `->` Operator? -> -> In C and C++, two different operators are used for calling methods: you use -> `.` if you’re calling a method on the object directly and `->` if you’re -> calling the method on a pointer to the object and need to dereference the -> pointer first. In other words, if `object` is a pointer, -> `object->something()` is similar to `(*object).something()`. -> -> Rust doesn’t have an equivalent to the `->` operator; instead, Rust has a -> feature called *automatic referencing and dereferencing*. Calling methods is -> one of the few places in Rust that has this behavior. -> -> Here’s how it works: when you call a method with `object.something()`, Rust -> automatically adds in `&`, `&mut`, or `*` so `object` matches the signature of -> the method. In other words, the following are the same: -> -> ```rust -> # #[derive(Debug,Copy,Clone)] -> # struct Point { -> # x: f64, -> # y: f64, -> # } -> # -> # impl Point { -> # fn distance(&self, other: &Point) -> f64 { -> # let x_squared = f64::powi(other.x - self.x, 2); -> # let y_squared = f64::powi(other.y - self.y, 2); -> # -> # f64::sqrt(x_squared + y_squared) -> # } -> # } -> # let p1 = Point { x: 0.0, y: 0.0 }; -> # let p2 = Point { x: 5.0, y: 6.5 }; -> p1.distance(&p2); -> (&p1).distance(&p2); -> ``` -> -> The first one looks much cleaner. This automatic referencing behavior works -> because methods have a clear receiver—the type of `self`. Given the receiver -> and name of a method, Rust can figure out definitively whether the method is -> reading (`&self`), mutating (`&mut self`), or consuming (`self`). The fact -> that Rust makes borrowing implicit for method receivers is a big part of -> making ownership ergonomic in practice. - -### Methods with More Parameters - -Let’s practice using methods by implementing a second method on the `Rectangle` -struct. This time, we want an instance of `Rectangle` to take another instance -of `Rectangle` and return `true` if the second `Rectangle` can fit completely -within `self`; otherwise it should return `false`. That is, we want to be able -to write the program shown in Listing 5-14, once we’ve defined the `can_hold` -method: - -Filename: src/main.rs - -```rust,ignore -fn main() { - let rect1 = Rectangle { width: 30, height: 50 }; - let rect2 = Rectangle { width: 10, height: 40 }; - let rect3 = Rectangle { width: 60, height: 45 }; - - println!("Can rect1 hold rect2? {}", rect1.can_hold(&rect2)); - println!("Can rect1 hold rect3? {}", rect1.can_hold(&rect3)); -} -``` - -Listing 5-14: Using the as-yet-unwritten `can_hold` -method - -And the expected output would look like the following, because both dimensions -of `rect2` are smaller than the dimensions of `rect1` but `rect3` is wider than -`rect1`: - -```text -Can rect1 hold rect2? true -Can rect1 hold rect3? false -``` - -We know we want to define a method, so it will be within the `impl Rectangle` -block. The method name will be `can_hold`, and it will take an immutable borrow -of another `Rectangle` as a parameter. We can tell what the type of the -parameter will be by looking at the code that calls the method: -`rect1.can_hold(&rect2)` passes in `&rect2`, which is an immutable borrow to -`rect2`, an instance of `Rectangle`. This makes sense because we only need to -read `rect2` (rather than write, which would mean we’d need a mutable borrow), -and we want `main` to retain ownership of `rect2` so we can use it again after -calling the `can_hold` method. The return value of `can_hold` will be a -Boolean, and the implementation will check whether the width and height of -`self` are both greater than the width and height of the other `Rectangle`, -respectively. Let’s add the new `can_hold` method to the `impl` block from -Listing 5-13, shown in Listing 5-15: - -Filename: src/main.rs - -```rust -# #[derive(Debug)] -# struct Rectangle { -# width: u32, -# height: u32, -# } -# -impl Rectangle { - fn area(&self) -> u32 { - self.width * self.height - } - - fn can_hold(&self, other: &Rectangle) -> bool { - self.width > other.width && self.height > other.height - } -} -``` - -Listing 5-15: Implementing the `can_hold` method on -`Rectangle` that takes another `Rectangle` instance as a parameter - -When we run this code with the `main` function in Listing 5-14, we’ll get our -desired output. Methods can take multiple parameters that we add to the -signature after the `self` parameter, and those parameters work just like -parameters in functions. - -### Associated Functions - -Another useful feature of `impl` blocks is that we’re allowed to define -functions within `impl` blocks that *don’t* take `self` as a parameter. These -are called *associated functions* because they’re associated with the struct. -They’re still functions, not methods, because they don’t have an instance of -the struct to work with. You’ve already used the `String::from` associated -function. - -Associated functions are often used for constructors that will return a new -instance of the struct. For example, we could provide an associated function -that would have one dimension parameter and use that as both width and height, -thus making it easier to create a square `Rectangle` rather than having to -specify the same value twice: - -Filename: src/main.rs - -```rust -# #[derive(Debug)] -# struct Rectangle { -# width: u32, -# height: u32, -# } -# -impl Rectangle { - fn square(size: u32) -> Rectangle { - Rectangle { width: size, height: size } - } -} -``` - -To call this associated function, we use the `::` syntax with the struct name; -`let sq = Rectangle::square(3);` is an example. This function is namespaced by -the struct: the `::` syntax is used for both associated functions and -namespaces created by modules. We’ll discuss modules in Chapter 7. - -### Multiple `impl` Blocks - -Each struct is allowed to have multiple `impl` blocks. For example, Listing -5-15 is equivalent to the code shown in Listing 5-16, which has each method -in its own `impl` block: - -```rust -# #[derive(Debug)] -# struct Rectangle { -# width: u32, -# height: u32, -# } -# -impl Rectangle { - fn area(&self) -> u32 { - self.width * self.height - } -} - -impl Rectangle { - fn can_hold(&self, other: &Rectangle) -> bool { - self.width > other.width && self.height > other.height - } -} -``` - -Listing 5-16: Rewriting Listing 5-15 using multiple `impl` -blocks - -There’s no reason to separate these methods into multiple `impl` blocks here, -but this is valid syntax. We’ll see a case in which multiple `impl` blocks are -useful in Chapter 10 where we discuss generic types and traits. - -## Summary - -Structs let you create custom types that are meaningful for your domain. By -using structs, you can keep associated pieces of data connected to each other -and name each piece to make your code clear. Methods let you specify the -behavior that instances of your structs have, and associated functions let you -namespace functionality that is particular to your struct without having an -instance available. - -But structs aren’t the only way you can create custom types: let’s turn to -Rust’s enum feature to add another tool to your toolbox. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch05-03-method-syntax.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch06-00-enums.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch06-00-enums.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch06-00-enums.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch06-00-enums.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,15 +1,10 @@ # Enums and Pattern Matching -In this chapter we’ll look at *enumerations*, also referred to as *enums*. -Enums allow you to define a type by enumerating its possible values. First, -we’ll define and use an enum to show how an enum can encode meaning along with -data. Next, we’ll explore a particularly useful enum, called `Option`, which -expresses that a value can be either something or nothing. Then we’ll look at -how pattern matching in the `match` expression makes it easy to run different -code for different values of an enum. Finally, we’ll cover how the `if let` -construct is another convenient and concise idiom available to you to handle -enums in your code. +The 2018 edition of the book is no longer distributed with Rust's documentation. -Enums are a feature in many languages, but their capabilities differ in each -language. Rust’s enums are most similar to *algebraic data types* in functional -languages, such as F#, OCaml, and Haskell. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. + +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch06-00-enums.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch06-01-defining-an-enum.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch06-01-defining-an-enum.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch06-01-defining-an-enum.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch06-01-defining-an-enum.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,399 +1,10 @@ ## Defining an Enum -Let’s look at a situation we might want to express in code and see why enums -are useful and more appropriate than structs in this case. Say we need to work -with IP addresses. Currently, two major standards are used for IP addresses: -version four and version six. These are the only possibilities for an IP -address that our program will come across: we can *enumerate* all possible -values, which is where enumeration gets its name. +The 2018 edition of the book is no longer distributed with Rust's documentation. -Any IP address can be either a version four or a version six address, but not -both at the same time. That property of IP addresses makes the enum data -structure appropriate, because enum values can only be one of the variants. -Both version four and version six addresses are still fundamentally IP -addresses, so they should be treated as the same type when the code is handling -situations that apply to any kind of IP address. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -We can express this concept in code by defining an `IpAddrKind` enumeration and -listing the possible kinds an IP address can be, `V4` and `V6`. These are known -as the *variants* of the enum: - -```rust -enum IpAddrKind { - V4, - V6, -} -``` - -`IpAddrKind` is now a custom data type that we can use elsewhere in our code. - -### Enum Values - -We can create instances of each of the two variants of `IpAddrKind` like this: - -```rust -# enum IpAddrKind { -# V4, -# V6, -# } -# -let four = IpAddrKind::V4; -let six = IpAddrKind::V6; -``` - -Note that the variants of the enum are namespaced under its identifier, and we -use a double colon to separate the two. The reason this is useful is that now -both values `IpAddrKind::V4` and `IpAddrKind::V6` are of the same type: -`IpAddrKind`. We can then, for instance, define a function that takes any -`IpAddrKind`: - -```rust -# enum IpAddrKind { -# V4, -# V6, -# } -# -fn route(ip_type: IpAddrKind) { } -``` - -And we can call this function with either variant: - -```rust -# enum IpAddrKind { -# V4, -# V6, -# } -# -# fn route(ip_type: IpAddrKind) { } -# -route(IpAddrKind::V4); -route(IpAddrKind::V6); -``` - -Using enums has even more advantages. Thinking more about our IP address type, -at the moment we don’t have a way to store the actual IP address *data*; we -only know what *kind* it is. Given that you just learned about structs in -Chapter 5, you might tackle this problem as shown in Listing 6-1: - -```rust -enum IpAddrKind { - V4, - V6, -} - -struct IpAddr { - kind: IpAddrKind, - address: String, -} - -let home = IpAddr { - kind: IpAddrKind::V4, - address: String::from("127.0.0.1"), -}; - -let loopback = IpAddr { - kind: IpAddrKind::V6, - address: String::from("::1"), -}; -``` - -Listing 6-1: Storing the data and `IpAddrKind` variant of -an IP address using a `struct` - -Here, we’ve defined a struct `IpAddr` that has two fields: a `kind` field that -is of type `IpAddrKind` (the enum we defined previously) and an `address` field -of type `String`. We have two instances of this struct. The first, `home`, has -the value `IpAddrKind::V4` as its `kind` with associated address data of -`127.0.0.1`. The second instance, `loopback`, has the other variant of -`IpAddrKind` as its `kind` value, `V6`, and has address `::1` associated with -it. We’ve used a struct to bundle the `kind` and `address` values together, so -now the variant is associated with the value. - -We can represent the same concept in a more concise way using just an enum, -rather than an enum inside a struct, by putting data directly into each enum -variant. This new definition of the `IpAddr` enum says that both `V4` and `V6` -variants will have associated `String` values: - -```rust -enum IpAddr { - V4(String), - V6(String), -} - -let home = IpAddr::V4(String::from("127.0.0.1")); - -let loopback = IpAddr::V6(String::from("::1")); -``` - -We attach data to each variant of the enum directly, so there is no need for an -extra struct. - -There’s another advantage to using an enum rather than a struct: each variant -can have different types and amounts of associated data. Version four type IP -addresses will always have four numeric components that will have values -between 0 and 255. If we wanted to store `V4` addresses as four `u8` values but -still express `V6` addresses as one `String` value, we wouldn’t be able to with -a struct. Enums handle this case with ease: - -```rust -enum IpAddr { - V4(u8, u8, u8, u8), - V6(String), -} - -let home = IpAddr::V4(127, 0, 0, 1); - -let loopback = IpAddr::V6(String::from("::1")); -``` - -We’ve shown several different ways to define data structures to store version -four and version six IP addresses. However, as it turns out, wanting to store -IP addresses and encode which kind they are is so common that [the standard -library has a definition we can use!][IpAddr] Let’s look at how -the standard library defines `IpAddr`: it has the exact enum and variants that -we’ve defined and used, but it embeds the address data inside the variants in -the form of two different structs, which are defined differently for each -variant: - -[IpAddr]: ../../std/net/enum.IpAddr.html - -```rust -struct Ipv4Addr { - // --snip-- -} - -struct Ipv6Addr { - // --snip-- -} - -enum IpAddr { - V4(Ipv4Addr), - V6(Ipv6Addr), -} -``` - -This code illustrates that you can put any kind of data inside an enum variant: -strings, numeric types, or structs, for example. You can even include another -enum! Also, standard library types are often not much more complicated than -what you might come up with. - -Note that even though the standard library contains a definition for `IpAddr`, -we can still create and use our own definition without conflict because we -haven’t brought the standard library’s definition into our scope. We’ll talk -more about bringing types into scope in Chapter 7. - -Let’s look at another example of an enum in Listing 6-2: this one has a wide -variety of types embedded in its variants: - -```rust -enum Message { - Quit, - Move { x: i32, y: i32 }, - Write(String), - ChangeColor(i32, i32, i32), -} -``` - -Listing 6-2: A `Message` enum whose variants each store -different amounts and types of values - -This enum has four variants with different types: - -* `Quit` has no data associated with it at all. -* `Move` includes an anonymous struct inside it. -* `Write` includes a single `String`. -* `ChangeColor` includes three `i32` values. - -Defining an enum with variants like the ones in Listing 6-2 is similar to -defining different kinds of struct definitions, except the enum doesn’t use the -`struct` keyword and all the variants are grouped together under the `Message` -type. The following structs could hold the same data that the preceding enum -variants hold: - -```rust -struct QuitMessage; // unit struct -struct MoveMessage { - x: i32, - y: i32, -} -struct WriteMessage(String); // tuple struct -struct ChangeColorMessage(i32, i32, i32); // tuple struct -``` - -But if we used the different structs, which each have their own type, we -couldn’t as easily define a function to take any of these kinds of messages as -we could with the `Message` enum defined in Listing 6-2, which is a single type. - -There is one more similarity between enums and structs: just as we’re able to -define methods on structs using `impl`, we’re also able to define methods on -enums. Here’s a method named `call` that we could define on our `Message` enum: - -```rust -# enum Message { -# Quit, -# Move { x: i32, y: i32 }, -# Write(String), -# ChangeColor(i32, i32, i32), -# } -# -impl Message { - fn call(&self) { - // method body would be defined here - } -} - -let m = Message::Write(String::from("hello")); -m.call(); -``` - -The body of the method would use `self` to get the value that we called the -method on. In this example, we’ve created a variable `m` that has the value -`Message::Write(String::from("hello"))`, and that is what `self` will be in the -body of the `call` method when `m.call()` runs. - -Let’s look at another enum in the standard library that is very common and -useful: `Option`. - -### The `Option` Enum and Its Advantages Over Null Values - -In the previous section, we looked at how the `IpAddr` enum let us use Rust’s -type system to encode more information than just the data into our program. -This section explores a case study of `Option`, which is another enum defined -by the standard library. The `Option` type is used in many places because it -encodes the very common scenario in which a value could be something or it -could be nothing. Expressing this concept in terms of the type system means the -compiler can check whether you’ve handled all the cases you should be handling; -this functionality can prevent bugs that are extremely common in other -programming languages. - -Programming language design is often thought of in terms of which features you -include, but the features you exclude are important too. Rust doesn’t have the -null feature that many other languages have. *Null* is a value that means there -is no value there. In languages with null, variables can always be in one of -two states: null or not-null. - -In his 2009 presentation “Null References: The Billion Dollar Mistake,” Tony -Hoare, the inventor of null, has this to say: - -> I call it my billion-dollar mistake. At that time, I was designing the first -> comprehensive type system for references in an object-oriented language. My -> goal was to ensure that all use of references should be absolutely safe, with -> checking performed automatically by the compiler. But I couldn’t resist the -> temptation to put in a null reference, simply because it was so easy to -> implement. This has led to innumerable errors, vulnerabilities, and system -> crashes, which have probably caused a billion dollars of pain and damage in -> the last forty years. - -The problem with null values is that if you try to use a null value as a -not-null value, you’ll get an error of some kind. Because this null or not-null -property is pervasive, it’s extremely easy to make this kind of error. - -However, the concept that null is trying to express is still a useful one: a -null is a value that is currently invalid or absent for some reason. - -The problem isn’t really with the concept but with the particular -implementation. As such, Rust does not have nulls, but it does have an enum -that can encode the concept of a value being present or absent. This enum is -`Option`, and it is [defined by the standard library][option] -as follows: - -[option]: ../../std/option/enum.Option.html - -```rust -enum Option { - Some(T), - None, -} -``` - -The `Option` enum is so useful that it’s even included in the prelude; you -don’t need to bring it into scope explicitly. In addition, so are its variants: -you can use `Some` and `None` directly without the `Option::` prefix. The -`Option` enum is still just a regular enum, and `Some(T)` and `None` are -still variants of type `Option`. - -The `` syntax is a feature of Rust we haven’t talked about yet. It’s a -generic type parameter, and we’ll cover generics in more detail in Chapter 10. -For now, all you need to know is that `` means the `Some` variant of the -`Option` enum can hold one piece of data of any type. Here are some examples of -using `Option` values to hold number types and string types: - -```rust -let some_number = Some(5); -let some_string = Some("a string"); - -let absent_number: Option = None; -``` - -If we use `None` rather than `Some`, we need to tell Rust what type of -`Option` we have, because the compiler can’t infer the type that the `Some` -variant will hold by looking only at a `None` value. - -When we have a `Some` value, we know that a value is present and the value is -held within the `Some`. When we have a `None` value, in some sense, it means -the same thing as null: we don’t have a valid value. So why is having -`Option` any better than having null? - -In short, because `Option` and `T` (where `T` can be any type) are different -types, the compiler won’t let us use an `Option` value as if it were -definitely a valid value. For example, this code won’t compile because it’s -trying to add an `i8` to an `Option`: - -```rust,ignore -let x: i8 = 5; -let y: Option = Some(5); - -let sum = x + y; -``` - -If we run this code, we get an error message like this: - -```text -error[E0277]: the trait bound `i8: std::ops::Add>` is -not satisfied - --> - | -5 | let sum = x + y; - | ^ no implementation for `i8 + std::option::Option` - | -``` - -Intense! In effect, this error message means that Rust doesn’t understand how -to add an `i8` and an `Option`, because they’re different types. When we -have a value of a type like `i8` in Rust, the compiler will ensure that we -always have a valid value. We can proceed confidently without having to check -for null before using that value. Only when we have an `Option` (or -whatever type of value we’re working with) do we have to worry about possibly -not having a value, and the compiler will make sure we handle that case before -using the value. - -In other words, you have to convert an `Option` to a `T` before you can -perform `T` operations with it. Generally, this helps catch one of the most -common issues with null: assuming that something isn’t null when it actually -is. - -Not having to worry about incorrectly assuming a not-null value helps you to be -more confident in your code. In order to have a value that can possibly be -null, you must explicitly opt in by making the type of that value `Option`. -Then, when you use that value, you are required to explicitly handle the case -when the value is null. Everywhere that a value has a type that isn’t an -`Option`, you *can* safely assume that the value isn’t null. This was a -deliberate design decision for Rust to limit null’s pervasiveness and increase -the safety of Rust code. - -So, how do you get the `T` value out of a `Some` variant when you have a value -of type `Option` so you can use that value? The `Option` enum has a large -number of methods that are useful in a variety of situations; you can check -them out in [its documentation][docs]. Becoming familiar with -the methods on `Option` will be extremely useful in your journey with Rust. - -[docs]: ../../std/option/enum.Option.html - -In general, in order to use an `Option` value, you want to have code that -will handle each variant. You want some code that will run only when you have a -`Some(T)` value, and this code is allowed to use the inner `T`. You want some -other code to run if you have a `None` value, and that code doesn’t have a `T` -value available. The `match` expression is a control flow construct that does -just this when used with enums: it will run different code depending on which -variant of the enum it has, and that code can use the data inside the matching -value. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch06-01-defining-an-enum.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch06-02-match.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch06-02-match.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch06-02-match.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch06-02-match.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,295 +1,10 @@ ## The `match` Control Flow Operator -Rust has an extremely powerful control flow operator called `match` that allows -you to compare a value against a series of patterns and then execute code based -on which pattern matches. Patterns can be made up of literal values, variable -names, wildcards, and many other things; Chapter 18 covers all the different -kinds of patterns and what they do. The power of `match` comes from the -expressiveness of the patterns and the fact that the compiler confirms that all -possible cases are handled. +The 2018 edition of the book is no longer distributed with Rust's documentation. -Think of a `match` expression as being like a coin-sorting machine: coins slide -down a track with variously sized holes along it, and each coin falls through -the first hole it encounters that it fits into. In the same way, values go -through each pattern in a `match`, and at the first pattern the value “fits,” -the value falls into the associated code block to be used during execution. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -Because we just mentioned coins, let’s use them as an example using `match`! We -can write a function that can take an unknown United States coin and, in a -similar way as the counting machine, determine which coin it is and return its -value in cents, as shown here in Listing 6-3: - -```rust -enum Coin { - Penny, - Nickel, - Dime, - Quarter, -} - -fn value_in_cents(coin: Coin) -> u32 { - match coin { - Coin::Penny => 1, - Coin::Nickel => 5, - Coin::Dime => 10, - Coin::Quarter => 25, - } -} -``` - -Listing 6-3: An enum and a `match` expression that has -the variants of the enum as its patterns - -Let’s break down the `match` in the `value_in_cents` function. First, we list -the `match` keyword followed by an expression, which in this case is the value -`coin`. This seems very similar to an expression used with `if`, but there’s a -big difference: with `if`, the expression needs to return a Boolean value, but -here, it can be any type. The type of `coin` in this example is the `Coin` enum -that we defined on line 1. - -Next are the `match` arms. An arm has two parts: a pattern and some code. The -first arm here has a pattern that is the value `Coin::Penny` and then the `=>` -operator that separates the pattern and the code to run. The code in this case -is just the value `1`. Each arm is separated from the next with a comma. - -When the `match` expression executes, it compares the resulting value against -the pattern of each arm, in order. If a pattern matches the value, the code -associated with that pattern is executed. If that pattern doesn’t match the -value, execution continues to the next arm, much as in a coin-sorting machine. -We can have as many arms as we need: in Listing 6-3, our `match` has four arms. - -The code associated with each arm is an expression, and the resulting value of -the expression in the matching arm is the value that gets returned for the -entire `match` expression. - -Curly brackets typically aren’t used if the match arm code is short, as it is -in Listing 6-3 where each arm just returns a value. If you want to run multiple -lines of code in a match arm, you can use curly brackets. For example, the -following code would print “Lucky penny!” every time the method was called with -a `Coin::Penny` but would still return the last value of the block, `1`: - -```rust -# enum Coin { -# Penny, -# Nickel, -# Dime, -# Quarter, -# } -# -fn value_in_cents(coin: Coin) -> u32 { - match coin { - Coin::Penny => { - println!("Lucky penny!"); - 1 - }, - Coin::Nickel => 5, - Coin::Dime => 10, - Coin::Quarter => 25, - } -} -``` - -### Patterns that Bind to Values - -Another useful feature of match arms is that they can bind to the parts of the -values that match the pattern. This is how we can extract values out of enum -variants. - -As an example, let’s change one of our enum variants to hold data inside it. -From 1999 through 2008, the United States minted quarters with different -designs for each of the 50 states on one side. No other coins got state -designs, so only quarters have this extra value. We can add this information to -our `enum` by changing the `Quarter` variant to include a `UsState` value stored -inside it, which we’ve done here in Listing 6-4: - -```rust -#[derive(Debug)] // So we can inspect the state in a minute -enum UsState { - Alabama, - Alaska, - // --snip-- -} - -enum Coin { - Penny, - Nickel, - Dime, - Quarter(UsState), -} -``` - -Listing 6-4: A `Coin` enum in which the `Quarter` variant -also holds a `UsState` value - -Let’s imagine that a friend of ours is trying to collect all 50 state quarters. -While we sort our loose change by coin type, we’ll also call out the name of -the state associated with each quarter so if it’s one our friend doesn’t have, -they can add it to their collection. - -In the match expression for this code, we add a variable called `state` to the -pattern that matches values of the variant `Coin::Quarter`. When a -`Coin::Quarter` matches, the `state` variable will bind to the value of that -quarter’s state. Then we can use `state` in the code for that arm, like so: - -```rust -# #[derive(Debug)] -# enum UsState { -# Alabama, -# Alaska, -# } -# -# enum Coin { -# Penny, -# Nickel, -# Dime, -# Quarter(UsState), -# } -# -fn value_in_cents(coin: Coin) -> u32 { - match coin { - Coin::Penny => 1, - Coin::Nickel => 5, - Coin::Dime => 10, - Coin::Quarter(state) => { - println!("State quarter from {:?}!", state); - 25 - }, - } -} -``` - -If we were to call `value_in_cents(Coin::Quarter(UsState::Alaska))`, `coin` -would be `Coin::Quarter(UsState::Alaska)`. When we compare that value with each -of the match arms, none of them match until we reach `Coin::Quarter(state)`. At -that point, the binding for `state` will be the value `UsState::Alaska`. We can -then use that binding in the `println!` expression, thus getting the inner -state value out of the `Coin` enum variant for `Quarter`. - -### Matching with `Option` - -In the previous section, we wanted to get the inner `T` value out of the `Some` -case when using `Option`; we can also handle `Option` using `match` as we -did with the `Coin` enum! Instead of comparing coins, we’ll compare the -variants of `Option`, but the way that the `match` expression works remains -the same. - -Let’s say we want to write a function that takes an `Option` and, if -there’s a value inside, adds 1 to that value. If there isn’t a value inside, -the function should return the `None` value and not attempt to perform any -operations. - -This function is very easy to write, thanks to `match`, and will look like -Listing 6-5: - -```rust -fn plus_one(x: Option) -> Option { - match x { - None => None, - Some(i) => Some(i + 1), - } -} - -let five = Some(5); -let six = plus_one(five); -let none = plus_one(None); -``` - -Listing 6-5: A function that uses a `match` expression on -an `Option` - -Let’s examine the first execution of `plus_one` in more detail. When we call -`plus_one(five)`, the variable `x` in the body of `plus_one` will have the -value `Some(5)`. We then compare that against each match arm. - -```rust,ignore -None => None, -``` - -The `Some(5)` value doesn’t match the pattern `None`, so we continue to the -next arm. - -```rust,ignore -Some(i) => Some(i + 1), -``` - -Does `Some(5)` match `Some(i)`? Why yes it does! We have the same variant. The -`i` binds to the value contained in `Some`, so `i` takes the value `5`. The -code in the match arm is then executed, so we add 1 to the value of `i` and -create a new `Some` value with our total `6` inside. - -Now let’s consider the second call of `plus_one` in Listing 6-5, where `x` is -`None`. We enter the `match` and compare to the first arm. - -```rust,ignore -None => None, -``` - -It matches! There’s no value to add to, so the program stops and returns the -`None` value on the right side of `=>`. Because the first arm matched, no other -arms are compared. - -Combining `match` and enums is useful in many situations. You’ll see this -pattern a lot in Rust code: `match` against an enum, bind a variable to the -data inside, and then execute code based on it. It’s a bit tricky at first, but -once you get used to it, you’ll wish you had it in all languages. It’s -consistently a user favorite. - -### Matches Are Exhaustive - -There’s one other aspect of `match` we need to discuss. Consider this version -of our `plus_one` function that has a bug and won’t compile: - -```rust,ignore -fn plus_one(x: Option) -> Option { - match x { - Some(i) => Some(i + 1), - } -} -``` - -We didn’t handle the `None` case, so this code will cause a bug. Luckily, it’s -a bug Rust knows how to catch. If we try to compile this code, we’ll get this -error: - -```text -error[E0004]: non-exhaustive patterns: `None` not covered - --> - | -6 | match x { - | ^ pattern `None` not covered -``` - -Rust knows that we didn’t cover every possible case and even knows which -pattern we forgot! Matches in Rust are *exhaustive*: we must exhaust every last -possibility in order for the code to be valid. Especially in the case of -`Option`, when Rust prevents us from forgetting to explicitly handle the -`None` case, it protects us from assuming that we have a value when we might -have null, thus making the billion-dollar mistake discussed earlier. - -### The `_` Placeholder - -Rust also has a pattern we can use when we don’t want to list all possible -values. For example, a `u8` can have valid values of 0 through 255. If we only -care about the values 1, 3, 5, and 7, we don’t want to have to list out 0, 2, -4, 6, 8, 9 all the way up to 255. Fortunately, we don’t have to: we can use the -special pattern `_` instead: - -```rust -let some_u8_value = 0u8; -match some_u8_value { - 1 => println!("one"), - 3 => println!("three"), - 5 => println!("five"), - 7 => println!("seven"), - _ => (), -} -``` - -The `_` pattern will match any value. By putting it after our other arms, the -`_` will match all the possible cases that aren’t specified before it. The `()` -is just the unit value, so nothing will happen in the `_` case. As a result, we -can say that we want to do nothing for all the possible values that we don’t -list before the `_` placeholder. - -However, the `match` expression can be a bit wordy in a situation in which we -only care about *one* of the cases. For this situation, Rust provides `if let`. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch06-02-match.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch06-03-if-let.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch06-03-if-let.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch06-03-if-let.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch06-03-if-let.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,118 +1,10 @@ ## Concise Control Flow with `if let` -The `if let` syntax lets you combine `if` and `let` into a less verbose way to -handle values that match one pattern while ignoring the rest. Consider the -program in Listing 6-6 that matches on an `Option` value but only wants to -execute code if the value is 3: +The 2018 edition of the book is no longer distributed with Rust's documentation. -```rust -let some_u8_value = Some(0u8); -match some_u8_value { - Some(3) => println!("three"), - _ => (), -} -``` +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -Listing 6-6: A `match` that only cares about executing -code when the value is `Some(3)` - -We want to do something with the `Some(3)` match but do nothing with any other -`Some` value or the `None` value. To satisfy the `match` expression, we -have to add `_ => ()` after processing just one variant, which is a lot of -boilerplate code to add. - -Instead, we could write this in a shorter way using `if let`. The following -code behaves the same as the `match` in Listing 6-6: - -```rust -# let some_u8_value = Some(0u8); -if let Some(3) = some_u8_value { - println!("three"); -} -``` - -The syntax `if let` takes a pattern and an expression separated by an `=`. It -works the same way as a `match`, where the expression is given to the `match` -and the pattern is its first arm. - -Using `if let` means you have less typing, less indentation, and less -boilerplate code. However, you lose the exhaustive checking that `match` -enforces. Choosing between `match` and `if let` depends on what you’re doing in -your particular situation and whether gaining conciseness is an appropriate -trade-off for losing exhaustive checking. - -In other words, you can think of `if let` as syntax sugar for a `match` that -runs code when the value matches one pattern and then ignores all other values. - -We can include an `else` with an `if let`. The block of code that goes with the -`else` is the same as the block of code that would go with the `_` case in the -`match` expression that is equivalent to the `if let` and `else`. Recall the -`Coin` enum definition in Listing 6-4, where the `Quarter` variant also held a -`UsState` value. If we wanted to count all non-quarter coins we see while also -announcing the state of the quarters, we could do that with a `match` -expression like this: - -```rust -# #[derive(Debug)] -# enum UsState { -# Alabama, -# Alaska, -# } -# -# enum Coin { -# Penny, -# Nickel, -# Dime, -# Quarter(UsState), -# } -# let coin = Coin::Penny; -let mut count = 0; -match coin { - Coin::Quarter(state) => println!("State quarter from {:?}!", state), - _ => count += 1, -} -``` - -Or we could use an `if let` and `else` expression like this: - -```rust -# #[derive(Debug)] -# enum UsState { -# Alabama, -# Alaska, -# } -# -# enum Coin { -# Penny, -# Nickel, -# Dime, -# Quarter(UsState), -# } -# let coin = Coin::Penny; -let mut count = 0; -if let Coin::Quarter(state) = coin { - println!("State quarter from {:?}!", state); -} else { - count += 1; -} -``` - -If you have a situation in which your program has logic that is too verbose to -express using a `match`, remember that `if let` is in your Rust toolbox as well. - -## Summary - -We’ve now covered how to use enums to create custom types that can be one of a -set of enumerated values. We’ve shown how the standard library’s `Option` -type helps you use the type system to prevent errors. When enum values have -data inside them, you can use `match` or `if let` to extract and use those -values, depending on how many cases you need to handle. - -Your Rust programs can now express concepts in your domain using structs and -enums. Creating custom types to use in your API ensures type safety: the -compiler will make certain your functions get only values of the type each -function expects. - -In order to provide a well-organized API to your users that is straightforward -to use and only exposes exactly what your users will need, let’s now turn to -Rust’s modules. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch06-03-if-let.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-00-modules.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-00-modules.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-00-modules.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-00-modules.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -# Using Modules to Reuse and Organize Code - -When you start writing programs in Rust, your code might live solely in the -`main` function. As your code grows, you’ll eventually move functionality into -other functions for reuse and better organization. By splitting your code into -smaller chunks, you make each chunk easier to understand on its own. But what -happens if you have too many functions? Rust has a module system that enables -the reuse of code in an organized fashion. - -In the same way that you extract lines of code into a function, you can extract -functions (and other code, like structs and enums) into different modules. A -*module* is a namespace that contains definitions of functions or types, and -you can choose whether those definitions are visible outside their module -(public) or not (private). Here’s an overview of how modules work: - -* The `mod` keyword declares a new module. Code within the module appears - either immediately following this declaration within curly brackets or in - another file. -* By default, functions, types, constants, and modules are private. The `pub` - keyword makes an item public and therefore visible outside its namespace. -* The `use` keyword brings modules, or the definitions inside modules, into - scope so it’s easier to refer to them. - -We’ll look at each of these parts to see how they fit into the whole. diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-00-packages-crates-and-modules.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-00-packages-crates-and-modules.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-00-packages-crates-and-modules.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-00-packages-crates-and-modules.md 2018-11-21 02:20:59.000000000 +0000 @@ -0,0 +1,10 @@ +# Packages, Crates, and Modules + +The 2018 edition of the book is no longer distributed with Rust's documentation. + +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. + +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch07-00-packages-crates-and-modules.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-01-mod-and-the-filesystem.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-01-mod-and-the-filesystem.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-01-mod-and-the-filesystem.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-01-mod-and-the-filesystem.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,480 +0,0 @@ -## `mod` and the Filesystem - -We’ll start our module example by making a new project with Cargo, but instead -of creating a binary crate, we’ll make a library crate: a project that other -people can pull into their projects as a dependency. For example, the `rand` -crate discussed in Chapter 2 is a library crate that we used as a dependency in -the guessing game project. - -We’ll create a skeleton of a library that provides some general networking -functionality; we’ll concentrate on the organization of the modules and -functions, but we won’t worry about what code goes in the function bodies. -We’ll call our library `communicator`. To create a library, pass the `--lib` -option: - -```text -$ cargo new communicator --lib -$ cd communicator -``` - -Notice that Cargo generated *src/lib.rs* instead of *src/main.rs*. Inside -*src/lib.rs* we’ll find the following: - -Filename: src/lib.rs - -```rust -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - assert_eq!(2 + 2, 4); - } -} -``` - -Cargo creates an example test to help us get our library started. We’ll -look at the `#[]` and `mod tests` syntax in the “Using `super` to Access a -Parent Module” section later in this chapter, but for now, leave this code at -the bottom of *src/lib.rs*. - -Because we don’t have a *src/main.rs* file, there’s nothing for Cargo to -execute with the `cargo run` command. Therefore, we’ll use the `cargo build` -command to compile our library crate’s code. - -We’ll look at different options for organizing your library’s code that will be -suitable in a variety of situations, depending on the intent of the code. - -### Module Definitions - -For our `communicator` networking library, we’ll first define a module named -`network` that contains the definition of a function called `connect`. Every -module definition in Rust starts with the `mod` keyword. Add this code to the -beginning of the *src/lib.rs* file, above the test code: - -Filename: src/lib.rs - -```rust -mod network { - fn connect() { - } -} -``` - -After the `mod` keyword, we put the name of the module, `network`, and then a -block of code in curly brackets. Everything inside this block is inside the -namespace `network`. In this case, we have a single function, `connect`. If we -wanted to call this function from code outside the `network` module, we -would need to specify the module and use the namespace syntax `::` like so: -`network::connect()`. - -We can also have multiple modules, side by side, in the same *src/lib.rs* file. -For example, to also have a `client` module that has a function named -`connect`, we can add it as shown in Listing 7-1: - -Filename: src/lib.rs - -```rust -mod network { - fn connect() { - } -} - -mod client { - fn connect() { - } -} -``` - -Listing 7-1: The `network` module and the `client` module -defined side by side in *src/lib.rs* - -Now we have a `network::connect` function and a `client::connect` function. -These can have completely different functionality, and the function names do -not conflict with each other because they’re in different modules. - -In this case, because we’re building a library, the file that serves as the -entry point for building our library is *src/lib.rs*. However, in respect to -creating modules, there’s nothing special about *src/lib.rs*. We could also -create modules in *src/main.rs* for a binary crate in the same way as we’re -creating modules in *src/lib.rs* for the library crate. In fact, we can put -modules inside of modules, which can be useful as your modules grow to keep -related functionality organized together and separate functionality apart. The -way you choose to organize your code depends on how you think about the -relationship between the parts of your code. For instance, the `client` code -and its `connect` function might make more sense to users of our library if -they were inside the `network` namespace instead, as in Listing 7-2: - -Filename: src/lib.rs - -```rust -mod network { - fn connect() { - } - - mod client { - fn connect() { - } - } -} -``` - -Listing 7-2: Moving the `client` module inside the -`network` module - -In your *src/lib.rs* file, replace the existing `mod network` and `mod client` -definitions with the ones in Listing 7-2, which have the `client` module as an -inner module of `network`. The functions `network::connect` and -`network::client::connect` are both named `connect`, but they don’t conflict -with each other because they’re in different namespaces. - -In this way, modules form a hierarchy. The contents of *src/lib.rs* are at the -topmost level, and the submodules are at lower levels. Here’s what the -organization of our example in Listing 7-1 looks like when thought of as a -hierarchy: - -```text -communicator - ├── network - └── client -``` - -And here’s the hierarchy corresponding to the example in Listing 7-2: - -```text -communicator - └── network - └── client -``` - -The hierarchy shows that in Listing 7-2, `client` is a child of the `network` -module rather than a sibling. More complicated projects can have many modules, -and they’ll need to be organized logically in order for you to keep track of -them. What “logically” means in your project is up to you and depends on how -you and your library’s users think about your project’s domain. Use the -techniques shown here to create side-by-side modules and nested modules in -whatever structure you would like. - -### Moving Modules to Other Files - -Modules form a hierarchical structure, much like another structure in computing -that you’re used to: filesystems! We can use Rust’s module system along with -multiple files to split up Rust projects so not everything lives in -*src/lib.rs* or *src/main.rs*. For this example, let’s start with the code in -Listing 7-3: - -Filename: src/lib.rs - -```rust -mod client { - fn connect() { - } -} - -mod network { - fn connect() { - } - - mod server { - fn connect() { - } - } -} -``` - -Listing 7-3: Three modules, `client`, `network`, and -`network::server`, all defined in *src/lib.rs* - -The file *src/lib.rs* has this module hierarchy: - -```text -communicator - ├── client - └── network - └── server -``` - -If these modules had many functions, and those functions were becoming lengthy, -it would be difficult to scroll through this file to find the code we wanted to -work with. Because the functions are nested inside one or more `mod` blocks, -the lines of code inside the functions will start getting lengthy as well. -These would be good reasons to separate the `client`, `network`, and `server` -modules from *src/lib.rs* and place them into their own files. - -First, let’s replace the `client` module code with only the declaration of the -`client` module so that *src/lib.rs* looks like code shown in Listing 7-4: - -Filename: src/lib.rs - -```rust,ignore -mod client; - -mod network { - fn connect() { - } - - mod server { - fn connect() { - } - } -} -``` - -Listing 7-4: Extracting the contents of the `client` module but leaving the declaration in *src/lib.rs* - -We’re still *declaring* the `client` module here, but by replacing the block -with a semicolon, we’re telling Rust to look in another location for the code -defined within the scope of the `client` module. In other words, the line `mod -client;` means this: - -```rust,ignore -mod client { - // contents of client.rs -} -``` - -Now we need to create the external file with that module name. Create a -*client.rs* file in your *src/* directory and open it. Then enter the -following, which is the `connect` function in the `client` module that we -removed in the previous step: - -Filename: src/client.rs - -```rust -fn connect() { -} -``` - -Note that we don’t need a `mod` declaration in this file because we already -declared the `client` module with `mod` in *src/lib.rs*. This file just -provides the *contents* of the `client` module. If we put a `mod client` here, -we’d be giving the `client` module its own submodule named `client`! - -Rust only knows to look in *src/lib.rs* by default. If we want to add more -files to our project, we need to tell Rust in *src/lib.rs* to look in other -files; this is why `mod client` needs to be defined in *src/lib.rs* and can’t -be defined in *src/client.rs*. - -Now the project should compile successfully, although you’ll get a few -warnings. Remember to use `cargo build` instead of `cargo run` because we have -a library crate rather than a binary crate: - -```text -$ cargo build - Compiling communicator v0.1.0 (file:///projects/communicator) -warning: function is never used: `connect` - --> src/client.rs:1:1 - | -1 | / fn connect() { -2 | | } - | |_^ - | - = note: #[warn(dead_code)] on by default - -warning: function is never used: `connect` - --> src/lib.rs:4:5 - | -4 | / fn connect() { -5 | | } - | |_____^ - -warning: function is never used: `connect` - --> src/lib.rs:8:9 - | -8 | / fn connect() { -9 | | } - | |_________^ -``` - -These warnings tell us that we have functions that are never used. Don’t worry -about these warnings for now; we’ll address them later in this chapter in the -“Controlling Visibility with `pub`” section. The good news is that they’re just -warnings; our project built successfully! - -Next, let’s extract the `network` module into its own file using the same -pattern. In *src/lib.rs*, delete the body of the `network` module and add a -semicolon to the declaration, like so: - -Filename: src/lib.rs - -```rust,ignore -mod client; - -mod network; -``` - -Then create a new *src/network.rs* file and enter the following: - -Filename: src/network.rs - -```rust -fn connect() { -} - -mod server { - fn connect() { - } -} -``` - -Notice that we still have a `mod` declaration within this module file; this is -because we still want `server` to be a submodule of `network`. - -Run `cargo build` again. Success! We have one more module to extract: `server`. -Because it’s a submodule—that is, a module within a module—our current tactic -of extracting a module into a file named after that module won’t work. We’ll -try anyway so you can see the error. First, change *src/network.rs* to have -`mod server;` instead of the `server` module’s contents: - -Filename: src/network.rs - -```rust,ignore -fn connect() { -} - -mod server; -``` - -Then create a *src/server.rs* file and enter the contents of the `server` -module that we extracted: - -Filename: src/server.rs - -```rust -fn connect() { -} -``` - -When we try to `cargo build`, we’ll get the error shown in Listing 7-5: - -```text -$ cargo build - Compiling communicator v0.1.0 (file:///projects/communicator) -error: cannot declare a new module at this location - --> src/network.rs:4:5 - | -4 | mod server; - | ^^^^^^ - | -note: maybe move this module `src/network.rs` to its own directory via `src/network/mod.rs` - --> src/network.rs:4:5 - | -4 | mod server; - | ^^^^^^ -note: ... or maybe `use` the module `server` instead of possibly redeclaring it - --> src/network.rs:4:5 - | -4 | mod server; - | ^^^^^^ -``` - -Listing 7-5: Error when trying to extract the `server` -submodule into *src/server.rs* - -The error says we `cannot declare a new module at this location` and is -pointing to the `mod server;` line in *src/network.rs*. So *src/network.rs* is -different than *src/lib.rs* somehow: keep reading to understand why. - -The note in the middle of Listing 7-5 is actually very helpful because it -points out something we haven’t yet talked about doing: - -```text -note: maybe move this module `network` to its own directory via -`network/mod.rs` -``` - -Instead of continuing to follow the same file-naming pattern we used -previously, we can do what the note suggests: - -1. Make a new *directory* named *network*, the parent module’s name. -2. Move the *src/network.rs* file into the new *network* directory and - rename it *src/network/mod.rs*. -3. Move the submodule file *src/server.rs* into the *network* directory. - -Here are commands to carry out these steps: - -```text -$ mkdir src/network -$ mv src/network.rs src/network/mod.rs -$ mv src/server.rs src/network -``` - -Now when we try to run `cargo build`, compilation will work (we’ll still have -warnings though). Our module layout still looks exactly the same as it did when -we had all the code in *src/lib.rs* in Listing 7-3: - -```text -communicator - ├── client - └── network - └── server -``` - -The corresponding file layout now looks like this: - -```text -└── src - ├── client.rs - ├── lib.rs - └── network - ├── mod.rs - └── server.rs -``` - -So when we wanted to extract the `network::server` module, why did we have to -also change the *src/network.rs* file to the *src/network/mod.rs* file and put -the code for `network::server` in the *network* directory in -*src/network/server.rs*? Why couldn’t we just extract the `network::server` -module into *src/server.rs*? The reason is that Rust wouldn’t be able to -recognize that `server` was supposed to be a submodule of `network` if the -*server.rs* file was in the *src* directory. To clarify Rust’s behavior here, -let’s consider a different example with the following module hierarchy, where -all the definitions are in *src/lib.rs*: - -```text -communicator - ├── client - └── network - └── client -``` - -In this example, we have three modules again: `client`, `network`, and -`network::client`. Following the same steps we did earlier for extracting -modules into files, we would create *src/client.rs* for the `client` module. -For the `network` module, we would create *src/network.rs*. But we wouldn’t be -able to extract the `network::client` module into a *src/client.rs* file -because that already exists for the top-level `client` module! If we could put -the code for *both* the `client` and `network::client` modules in the -*src/client.rs* file, Rust wouldn’t have any way to know whether the code was -for `client` or for `network::client`. - -Therefore, in order to extract a file for the `network::client` submodule of -the `network` module, we needed to create a directory for the `network` module -instead of a *src/network.rs* file. The code that is in the `network` module -then goes into the *src/network/mod.rs* file, and the submodule -`network::client` can have its own *src/network/client.rs* file. Now the -top-level *src/client.rs* is unambiguously the code that belongs to the -`client` module. - -### Rules of Module Filesystems - -Let’s summarize the rules of modules with regard to files: - -* If a module named `foo` has no submodules, you should put the declarations - for `foo` in a file named *foo.rs*. -* If a module named `foo` does have submodules, you should put the declarations - for `foo` in a file named *foo/mod.rs*. - -These rules apply recursively, so if a module named `foo` has a submodule named -`bar` and `bar` does not have submodules, you should have the following files -in your *src* directory: - -```text -└── foo - ├── bar.rs (contains the declarations in `foo::bar`) - └── mod.rs (contains the declarations in `foo`, including `mod bar`) -``` - -The modules should be declared in their parent module’s file using the `mod` -keyword. - -Next, we’ll talk about the `pub` keyword and get rid of those warnings! diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-01-packages-and-crates-for-making-libraries-and-executables.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-01-packages-and-crates-for-making-libraries-and-executables.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-01-packages-and-crates-for-making-libraries-and-executables.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-01-packages-and-crates-for-making-libraries-and-executables.md 2018-11-21 02:20:59.000000000 +0000 @@ -0,0 +1,10 @@ +## Packages and Crates for Making Libraries and Executables + +The 2018 edition of the book is no longer distributed with Rust's documentation. + +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. + +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch07-01-packages-and-crates-for-making-libraries-and-executables.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-02-controlling-visibility-with-pub.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-02-controlling-visibility-with-pub.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-02-controlling-visibility-with-pub.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-02-controlling-visibility-with-pub.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,288 +0,0 @@ -## Controlling Visibility with `pub` - -We resolved the error messages shown in Listing 7-5 by moving the `network` and -`network::server` code into the *src/network/mod.rs* and -*src/network/server.rs* files, respectively. At that point, `cargo build` was -able to build our project, but we still get warning messages about the -`client::connect`, `network::connect`, and `network::server::connect` functions -not being used. - -So why are we receiving these warnings? After all, we’re building a library -with functions that are intended to be used by our *users*, not necessarily by -us within our own project, so it shouldn’t matter that these `connect` -functions go unused. The point of creating them is that they will be used by -another project, not our own. - -To understand why this program invokes these warnings, let’s try using the -`communicator` library from another project, calling it externally. To do that, -we’ll create a binary crate in the same directory as our library crate by -making a *src/main.rs* file containing this code: - -Filename: src/main.rs - -```rust,ignore -extern crate communicator; - -fn main() { - communicator::client::connect(); -} -``` - -We use the `extern crate` command to bring the `communicator` library crate -into scope. Our package now contains *two* crates. Cargo treats *src/main.rs* -as the root file of a binary crate, which is separate from the existing library -crate whose root file is *src/lib.rs*. This pattern is quite common for -executable projects: most functionality is in a library crate, and the binary -crate uses that library crate. As a result, other programs can also use the -library crate, and it’s a nice separation of concerns. - -From the point of view of a crate outside the `communicator` library looking -in, all the modules we’ve been creating are within a module that has the same -name as the crate, `communicator`. We call the top-level module of a crate the -*root module*. - -Also note that even if we’re using an external crate within a submodule of our -project, the `extern crate` should go in our root module (so in *src/main.rs* -or *src/lib.rs*). Then, in our submodules, we can refer to items from external -crates as if the items are top-level modules. - -Right now, our binary crate just calls our library’s `connect` function from -the `client` module. However, invoking `cargo build` will now give us an error -after the warnings: - -```text -error[E0603]: module `client` is private - --> src/main.rs:4:5 - | -4 | communicator::client::connect(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -``` - -Ah ha! This error tells us that the `client` module is private, which is the -crux of the warnings. It’s also the first time we’ve run into the concepts of -*public* and *private* in the context of Rust. The default state of all code in -Rust is private: no one else is allowed to use the code. If you don’t use a -private function within your program, because your program is the only code -allowed to use that function, Rust will warn you that the function has gone -unused. - -After you specify that a function such as `client::connect` is public, not only -will your call to that function from your binary crate be allowed, but also the -warning that the function is unused will go away. Marking a function as public -lets Rust know that the function will be used by code outside of your program. -Rust considers the theoretical external usage that’s now possible as the -function “being used.” Thus, when a function is marked public, Rust will not -require that it be used in your program and will stop warning that the function -is unused. - -### Making a Function Public - -To tell Rust to make a function public, we add the `pub` keyword to the start -of the declaration. We’ll focus on fixing the warning that indicates -`client::connect` has gone unused for now, as well as the `` module `client` is -private `` error from our binary crate. Modify *src/lib.rs* to make the -`client` module public, like so: - -Filename: src/lib.rs - -```rust,ignore -pub mod client; - -mod network; -``` - -The `pub` keyword is placed right before `mod`. Let’s try building again: - -```text -error[E0603]: function `connect` is private - --> src/main.rs:4:5 - | -4 | communicator::client::connect(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -``` - -Hooray! We have a different error! Yes, different error messages are a cause -for celebration. The new error shows `` function `connect` is private ``, so -let’s edit *src/client.rs* to make `client::connect` public too: - -Filename: src/client.rs - -```rust -pub fn connect() { -} -``` - -Now run `cargo build` again: - -```text -warning: function is never used: `connect` - --> src/network/mod.rs:1:1 - | -1 | / fn connect() { -2 | | } - | |_^ - | - = note: #[warn(dead_code)] on by default - -warning: function is never used: `connect` - --> src/network/server.rs:1:1 - | -1 | / fn connect() { -2 | | } - | |_^ -``` - -The code compiled, and the warning that `client::connect` is not being used is -gone! - -Unused code warnings don’t always indicate that an item in your code needs to -be made public: if you *didn’t* want these functions to be part of your public -API, unused code warnings could be alerting you to code you no longer need that -you can safely delete. They could also be alerting you to a bug if you had just -accidentally removed all places within your library where this function is -called. - -But in this case, we *do* want the other two functions to be part of our -crate’s public API, so let’s mark them as `pub` as well to get rid of the -remaining warnings. Modify *src/network/mod.rs* to look like the following: - -Filename: src/network/mod.rs - -```rust,ignore -pub fn connect() { -} - -mod server; -``` - -Then compile the code: - -```text -warning: function is never used: `connect` - --> src/network/mod.rs:1:1 - | -1 | / pub fn connect() { -2 | | } - | |_^ - | - = note: #[warn(dead_code)] on by default - -warning: function is never used: `connect` - --> src/network/server.rs:1:1 - | -1 | / fn connect() { -2 | | } - | |_^ -``` - -Hmmm, we’re still getting an unused function warning, even though -`network::connect` is set to `pub`. The reason is that the function is public -within the module, but the `network` module that the function resides in is not -public. We’re working from the interior of the library out this time, whereas -with `client::connect` we worked from the outside in. We need to change -*src/lib.rs* to make `network` public too, like so: - -Filename: src/lib.rs - -```rust,ignore -pub mod client; - -pub mod network; -``` - -Now when we compile, that warning is gone: - -```text -warning: function is never used: `connect` - --> src/network/server.rs:1:1 - | -1 | / fn connect() { -2 | | } - | |_^ - | - = note: #[warn(dead_code)] on by default -``` - -Only one warning is left—try to fix this one on your own! - -### Privacy Rules - -Overall, these are the rules for item visibility: - -- If an item is public, it can be accessed through any of its parent modules. -- If an item is private, it can be accessed only by its immediate parent - module and any of the parent’s child modules. - -### Privacy Examples - -Let’s look at a few more privacy examples to get some practice. Create a new -library project and enter the code in Listing 7-6 into your new project’s -*src/lib.rs*: - -Filename: src/lib.rs - -```rust,ignore -mod outermost { - pub fn middle_function() {} - - fn middle_secret_function() {} - - mod inside { - pub fn inner_function() {} - - fn secret_function() {} - } -} - -fn try_me() { - outermost::middle_function(); - outermost::middle_secret_function(); - outermost::inside::inner_function(); - outermost::inside::secret_function(); -} -``` - -Listing 7-6: Examples of private and public functions, -some of which are incorrect - -Before you try to compile this code, make a guess about which lines in the -`try_me` function will have errors. Then, try compiling the code to see whether -you were right—and read on for the discussion of the errors! - -#### Looking at the Errors - -The `try_me` function is in the root module of our project. The module named -`outermost` is private, but the second privacy rule states that the `try_me` -function is allowed to access the `outermost` module because `outermost` is in -the current (root) module, as is `try_me`. - -The call to `outermost::middle_function` will work because `middle_function` is -public and `try_me` is accessing `middle_function` through its parent module -`outermost`. We determined in the previous paragraph that this module is -accessible. - -The call to `outermost::middle_secret_function` will cause a compilation error. -Because `middle_secret_function` is private, the second rule applies. The root -module is neither the current module of `middle_secret_function` (`outermost` -is), nor is it a child module of the current module of `middle_secret_function`. - -The module named `inside` is private and has no child modules, so it can be -accessed only by its current module `outermost`. That means the `try_me` -function is not allowed to call `outermost::inside::inner_function` or -`outermost::inside::secret_function`. - -#### Fixing the Errors - -Here are some suggestions for changing the code in an attempt to fix the -errors. Make a guess as to whether it will fix the errors before you try each -one. Then compile the code to see whether or not you’re right, using the -privacy rules to understand why. Feel free to design more experiments and try -them out! - -* What if the `inside` module were public? -* What if `outermost` were public and `inside` were private? -* What if, in the body of `inner_function`, you called - `::outermost::middle_secret_function()`? (The two colons at the beginning mean - that we want to refer to the modules starting from the root module.) - -Next, let’s talk about bringing items into scope with the `use` keyword. diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-02-modules-and-use-to-control-scope-and-privacy.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-02-modules-and-use-to-control-scope-and-privacy.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-02-modules-and-use-to-control-scope-and-privacy.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-02-modules-and-use-to-control-scope-and-privacy.md 2018-11-21 02:20:59.000000000 +0000 @@ -0,0 +1,10 @@ +## The Module System to Control Scope and Privacy + +The 2018 edition of the book is no longer distributed with Rust's documentation. + +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. + +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch07-02-modules-and-use-to-control-scope-and-privacy.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-03-importing-names-with-use.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-03-importing-names-with-use.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-03-importing-names-with-use.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch07-03-importing-names-with-use.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,304 +0,0 @@ -## Referring to Names in Different Modules - -We’ve covered how to call functions defined within a module using the module -name as part of the call, as in the call to the `nested_modules` function shown -here in Listing 7-7: - -Filename: src/main.rs - -```rust -pub mod a { - pub mod series { - pub mod of { - pub fn nested_modules() {} - } - } -} - -fn main() { - a::series::of::nested_modules(); -} -``` - -Listing 7-7: Calling a function by fully specifying its -enclosing module’s path - -As you can see, referring to the fully qualified name can get quite lengthy. -Fortunately, Rust has a keyword to make these calls more concise. - -### Bringing Names into Scope with the `use` Keyword - -Rust’s `use` keyword shortens lengthy function calls by bringing the modules of -the function you want to call into scope. Here’s an example of bringing the -`a::series::of` module into a binary crate’s root scope: - -Filename: src/main.rs - -```rust -pub mod a { - pub mod series { - pub mod of { - pub fn nested_modules() {} - } - } -} - -use a::series::of; - -fn main() { - of::nested_modules(); -} -``` - -The line `use a::series::of;` means that rather than using the full -`a::series::of` path wherever we want to refer to the `of` module, we can use -`of`. - -The `use` keyword brings only what we’ve specified into scope: it does not -bring children of modules into scope. That’s why we still have to use -`of::nested_modules` when we want to call the `nested_modules` function. - -We could have chosen to bring the function into scope by instead specifying the -function in the `use` as follows: - -```rust -pub mod a { - pub mod series { - pub mod of { - pub fn nested_modules() {} - } - } -} - -use a::series::of::nested_modules; - -fn main() { - nested_modules(); -} -``` - -Doing so allows us to exclude all the modules and reference the function -directly. - -Because enums also form a sort of namespace like modules, we can bring an -enum’s variants into scope with `use` as well. For any kind of `use` statement, -if you’re bringing multiple items from one namespace into scope, you can list -them using curly brackets and commas in the last position, like so: - -```rust -enum TrafficLight { - Red, - Yellow, - Green, -} - -use TrafficLight::{Red, Yellow}; - -fn main() { - let red = Red; - let yellow = Yellow; - let green = TrafficLight::Green; -} -``` - -We’re still specifying the `TrafficLight` namespace for the `Green` variant -because we didn’t include `Green` in the `use` statement. - -#### 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 -# #![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() {} -``` - -### Bringing All Names into Scope with a Glob - -To bring all the items in a namespace into scope at once, we can use the `*` -syntax, which is called the *glob operator*. This example brings all the -variants of an enum into scope without having to list each specifically: - -```rust -enum TrafficLight { - Red, - Yellow, - Green, -} - -use TrafficLight::*; - -fn main() { - let red = Red; - let yellow = Yellow; - let green = Green; -} -``` - -The `*` will bring into scope all the visible items in the `TrafficLight` -namespace. You should use globs sparingly: they are convenient, but a glob -might also pull in more items than you expected and cause naming conflicts. - -### Using `super` to Access a Parent Module - -As you saw at the beginning of this chapter, when you create a library crate, -Cargo makes a `tests` module for you. Let’s go into more detail about that now. -In your `communicator` project, open *src/lib.rs*: - -Filename: src/lib.rs - -```rust,ignore -pub mod client; - -pub mod network; - -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - assert_eq!(2 + 2, 4); - } -} -``` - -Chapter 11 explains more about testing, but parts of this example should make -sense now: we have a module named `tests` that lives next to our other modules -and contains one function named `it_works`. Even though there are special -annotations, the `tests` module is just another module! So our module hierarchy -looks like this: - -```text -communicator - ├── client - ├── network - | └── client - └── tests -``` - -Tests are for exercising the code within our library, so let’s try to call our -`client::connect` function from this `it_works` function, even though we won’t -be checking any functionality right now. This won’t work yet: - -Filename: src/lib.rs - -```rust -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - client::connect(); - } -} -``` - -Run the tests by invoking the `cargo test` command: - -```text -$ cargo test - Compiling communicator v0.1.0 (file:///projects/communicator) -error[E0433]: failed to resolve. Use of undeclared type or module `client` - --> src/lib.rs:9:9 - | -9 | client::connect(); - | ^^^^^^ Use of undeclared type or module `client` -``` - -The compilation failed, but why? We don’t need to place `communicator::` in -front of the function, as we did in *src/main.rs*, because we are definitely -within the `communicator` library crate here. The reason is that paths are -always relative to the current module, which here is `tests`. The only -exception is in a `use` statement, where paths are relative to the crate root -by default. Our `tests` module needs the `client` module in its scope! - -So how do we get back up one module in the module hierarchy to call the -`client::connect` function in the `tests` module? In the `tests` module, we can -either use leading colons to let Rust know that we want to start from the root -and list the whole path, like this: - -```rust,ignore -::client::connect(); -``` - -Or, we can use `super` to move up one module in the hierarchy from our current -module, like this: - -```rust,ignore -super::client::connect(); -``` - -These two options don’t look that different in this example, but if you’re -deeper in a module hierarchy, starting from the root every time would make your -code lengthy. In those cases, using `super` to get from the current module to -sibling modules is a good shortcut. Plus, if you’ve specified the path from the -root in many places in your code and then rearrange your modules by moving a -subtree to another place, you’ll end up needing to update the path in several -places, which would be tedious. - -It would also be annoying to have to type `super::` in each test, but you’ve -already seen the tool for that solution: `use`! The `super::` functionality -changes the path you give to `use` so it is relative to the parent module -instead of to the root module. - -For these reasons, in the `tests` module especially, `use super::something` is -usually the best solution. So now our test looks like this: - -Filename: src/lib.rs - -```rust -#[cfg(test)] -mod tests { - use super::client; - - #[test] - fn it_works() { - client::connect(); - } -} -``` - -When we run `cargo test` again, the test will pass, and the first part of the -test result output will be the following: - -```text -$ cargo test - Compiling communicator v0.1.0 (file:///projects/communicator) - Running target/debug/communicator-92007ddb5330fa5a - -running 1 test -test tests::it_works ... ok - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out -``` - -## Summary - -Now you know some new techniques for organizing your code! Use these techniques -to group related functionality together, keep files from becoming too long, and -present a tidy public API to your library users. - -Next, we’ll look at some collection data structures in the standard library -that you can use in your nice, neat code. diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch08-00-common-collections.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch08-00-common-collections.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch08-00-common-collections.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch08-00-common-collections.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,25 +1,10 @@ # Common Collections -Rust’s standard library includes a number of very useful data structures called -*collections*. Most other data types represent one specific value, but -collections can contain multiple values. Unlike the built-in array and tuple -types, the data these collections point to is stored on the heap, which means -the amount of data does not need to be known at compile time and can grow or -shrink as the program runs. Each kind of collection has different capabilities -and costs, and choosing an appropriate one for your current situation is a -skill you’ll develop over time. In this chapter, we’ll discuss three -collections that are used very often in Rust programs: +The 2018 edition of the book is no longer distributed with Rust's documentation. -* A *vector* allows you to store a variable number of values next to each other. -* A *string* is a collection of characters. We’ve mentioned the `String` type - previously, but in this chapter we’ll talk about it in depth. -* A *hash map* allows you to associate a value with a particular key. It’s a - particular implementation of the more general data structure called a *map*. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -To learn about the other kinds of collections provided by the standard library, -see [the documentation][collections]. - -[collections]: ../../std/collections/index.html - -We’ll discuss how to create and update vectors, strings, and hash maps, as well -as what makes each special. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch08-00-common-collections.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch08-01-vectors.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch08-01-vectors.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch08-01-vectors.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch08-01-vectors.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,295 +1,10 @@ ## Storing Lists of Values with Vectors -The first collection type we’ll look at is `Vec`, also known as a *vector*. -Vectors allow you to store more than one value in a single data structure that -puts all the values next to each other in memory. Vectors can only store values -of the same type. They are useful when you have a list of items, such as the -lines of text in a file or the prices of items in a shopping cart. +The 2018 edition of the book is no longer distributed with Rust's documentation. -### Creating a New Vector +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -To create a new, empty vector, we can call the `Vec::new` function, as shown in -Listing 8-1: - -```rust -let v: Vec = Vec::new(); -``` - -Listing 8-1: Creating a new, empty vector to hold values -of type `i32` - -Note that we added a type annotation here. Because we aren’t inserting any -values into this vector, Rust doesn’t know what kind of elements we intend to -store. This is an important point. Vectors are implemented using generics; -we’ll cover how to use generics with your own types in Chapter 10. For now, -know that the `Vec` type provided by the standard library can hold any type, -and when a specific vector holds a specific type, the type is specified within -angle brackets. In Listing 8-1, we’ve told Rust that the `Vec` in `v` will -hold elements of the `i32` type. - -In more realistic code, Rust can often infer the type of value you want to -store once you insert values, so you rarely need to do this type annotation. -It’s more common to create a `Vec` that has initial values, and Rust -provides the `vec!` macro for convenience. The macro will create a new vector -that holds the values you give it. Listing 8-2 creates a new `Vec` that -holds the values `1`, `2`, and `3`: - -```rust -let v = vec![1, 2, 3]; -``` - -Listing 8-2: Creating a new vector containing -values - -Because we’ve given initial `i32` values, Rust can infer that the type of `v` -is `Vec`, and the type annotation isn’t necessary. Next, we’ll look at how -to modify a vector. - -### Updating a Vector - -To create a vector and then add elements to it, we can use the `push` method, -as shown in Listing 8-3: - -```rust -let mut v = Vec::new(); - -v.push(5); -v.push(6); -v.push(7); -v.push(8); -``` - -Listing 8-3: Using the `push` method to add values to a -vector - -As with any variable, if we want to be able to change its value, we need to -make it mutable using the `mut` keyword, as discussed in Chapter 3. The numbers -we place inside are all of type `i32`, and Rust infers this from the data, so -we don’t need the `Vec` annotation. - -### Dropping a Vector Drops Its Elements - -Like any other `struct`, a vector is freed when it goes out of scope, as -annotated in Listing 8-4: - -```rust -{ - let v = vec![1, 2, 3, 4]; - - // do stuff with v - -} // <- v goes out of scope and is freed here -``` - -Listing 8-4: Showing where the vector and its elements -are dropped - -When the vector gets dropped, all of its contents are also dropped, meaning -those integers it holds will be cleaned up. This may seem like a -straightforward point but can get a bit more complicated when you start to -introduce references to the elements of the vector. Let’s tackle that next! - -### Reading Elements of Vectors - -Now that you know how to create, update, and destroy vectors, knowing how to -read their contents is a good next step. There are two ways to reference a -value stored in a vector. In the examples, we’ve annotated the types of the -values that are returned from these functions for extra clarity. - -Listing 8-5 shows the method of accessing a value in a vector with -indexing syntax: - -```rust -let v = vec![1, 2, 3, 4, 5]; - -let third: &i32 = &v[2]; -``` - -Listing 8-5: Using indexing syntax to -access an item in a vector - -Listing 8-6 shows the method of accessing a value in a vector, with -the `get` method: - -```rust -let v = vec![1, 2, 3, 4, 5]; -let v_index = 2; - -match v.get(v_index) { - Some(_) => { println!("Reachable element at index: {}", v_index); }, - None => { println!("Unreachable element at index: {}", v_index); } -} -``` - -Listing 8-6: Using the `get` method to -access an item in a vector - -Note two details here. First, we use the index value of `2` to get the third -element: vectors are indexed by number, starting at zero. Second, the two ways -to get the third element are by using `&` and `[]`, which gives us a reference, -or by using the `get` method with the index passed as an argument, which gives -us an `Option<&T>`. - -Rust has two ways to reference an element so you can choose how the program -behaves when you try to use an index value that the vector doesn’t have an -element for. As an example, let’s see what a program will do if it has a vector -that holds five elements and then tries to access an element at index 100, as -shown in Listing 8-7: - -```rust,should_panic -let v = vec![1, 2, 3, 4, 5]; - -let does_not_exist = &v[100]; -let does_not_exist = v.get(100); -``` - -Listing 8-7: Attempting to access the element at index -100 in a vector containing five elements - -When we run this code, the first `[]` method will cause the program to panic -because it references a nonexistent element. This method is best used when you -want your program to crash if there’s an attempt to access an element past the -end of the vector. - -When the `get` method is passed an index that is outside the vector, it returns -`None` without panicking. You would use this method if accessing an element -beyond the range of the vector happens occasionally under normal circumstances. -Your code will then have logic to handle having either `Some(&element)` or -`None`, as discussed in Chapter 6. For example, the index could be coming from -a person entering a number. If they accidentally enter a number that’s too -large and the program gets a `None` value, you could tell the user how many -items are in the current vector and give them another chance to enter a valid -value. That would be more user-friendly than crashing the program due to a typo! - -When the program has a valid reference, the borrow checker enforces the -ownership and borrowing rules (covered in Chapter 4) to ensure this reference -and any other references to the contents of the vector remain valid. Recall the -rule that states you can’t have mutable and immutable references in the same -scope. That rule applies in Listing 8-8, where we hold an immutable reference to -the first element in a vector and try to add an element to the end, which won’t -work: - -```rust,ignore -let mut v = vec![1, 2, 3, 4, 5]; - -let first = &v[0]; - -v.push(6); -``` - -Listing 8-8: Attempting to add an element to a vector -while holding a reference to an item - -Compiling this code will result in this error: - -```text -error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable - --> - | -4 | let first = &v[0]; - | - immutable borrow occurs here -5 | -6 | v.push(6); - | ^ mutable borrow occurs here -7 | -8 | } - | - immutable borrow ends here -``` - -The code in Listing 8-8 might look like it should work: why should a reference -to the first element care about what changes at the end of the vector? This -error is due to the way vectors work: adding a new element onto the end of the -vector might require allocating new memory and copying the old elements to the -new space, if there isn’t enough room to put all the elements next to each -other where the vector currently is. In that case, the reference to the first -element would be pointing to deallocated memory. The borrowing rules prevent -programs from ending up in that situation. - -> Note: For more on the implementation details of the `Vec` type, see “The -> Rustonomicon” at https://doc.rust-lang.org/stable/nomicon/vec.html. - -### Iterating over the Values in a Vector - -If we want to access each element in a vector in turn, we can iterate through -all of the elements rather than use indexes to access one at a time. Listing -8-9 shows how to use a `for` loop to get immutable references to each element -in a vector of `i32` values and print them: - -```rust -let v = vec![100, 32, 57]; -for i in &v { - println!("{}", i); -} -``` - -Listing 8-9: Printing each element in a vector by -iterating over the elements using a `for` loop - -We can also iterate over mutable references to each element in a mutable vector -in order to make changes to all the elements. The `for` loop in Listing 8-10 -will add `50` to each element: - -```rust -let mut v = vec![100, 32, 57]; -for i in &mut v { - *i += 50; -} -``` - -Listing 8-10: Iterating over mutable references to -elements in a vector - -To change the value that the mutable reference refers to, we have to use the -dereference operator (`*`) to get to the value in `i` before we can use the -`+=` operator . We'll talk more about `*` in Chapter 15. - -### Using an Enum to Store Multiple Types - -At the beginning of this chapter, we said that vectors can only store values -that are the same type. This can be inconvenient; there are definitely use -cases for needing to store a list of items of different types. Fortunately, the -variants of an enum are defined under the same enum type, so when we need to -store elements of a different type in a vector, we can define and use an enum! - -For example, say we want to get values from a row in a spreadsheet in which -some of the columns in the row contain integers, some floating-point numbers, -and some strings. We can define an enum whose variants will hold the different -value types, and then all the enum variants will be considered the same type: -that of the enum. Then we can create a vector that holds that enum and so, -ultimately, holds different types. We’ve demonstrated this in Listing 8-11: - -```rust -enum SpreadsheetCell { - Int(i32), - Float(f64), - Text(String), -} - -let row = vec![ - SpreadsheetCell::Int(3), - SpreadsheetCell::Text(String::from("blue")), - SpreadsheetCell::Float(10.12), -]; -``` - -Listing 8-11: Defining an `enum` to store values of -different types in one vector - -Rust needs to know what types will be in the vector at compile time so it knows -exactly how much memory on the heap will be needed to store each element. A -secondary advantage is that we can be explicit about what types are allowed in -this vector. If Rust allowed a vector to hold any type, there would be a chance -that one or more of the types would cause errors with the operations performed -on the elements of the vector. Using an enum plus a `match` expression means -that Rust will ensure at compile time that every possible case is handled, as -discussed in Chapter 6. - -When you’re writing a program, if you don’t know the exhaustive set of types -the program will get at runtime to store in a vector, the enum technique won’t -work. Instead, you can use a trait object, which we’ll cover in Chapter 17. - -Now that we’ve discussed some of the most common ways to use vectors, be sure -to review the API documentation for all the many useful methods defined on -`Vec` by the standard library. For example, in addition to `push`, a `pop` -method removes and returns the last element. Let’s move on to the next -collection type: `String`! +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch08-01-vectors.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch08-02-strings.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch08-02-strings.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch08-02-strings.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch08-02-strings.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,452 +1,10 @@ ## Storing UTF-8 Encoded Text with Strings -We talked about strings in Chapter 4, but we’ll look at them in more depth now. -New Rustaceans commonly get stuck on strings due to a combination of three -reasons: Rust’s propensity for exposing possible errors, strings being a more -complicated data structure than many programmers give them credit for, and -UTF-8. These factors combine in a way that can seem difficult when you’re -coming from other programming languages. +The 2018 edition of the book is no longer distributed with Rust's documentation. -It’s useful to discuss strings in the context of collections because strings -are implemented as a collection of bytes, plus some methods to provide useful -functionality when those bytes are interpreted as text. In this section, we’ll -talk about the operations on `String` that every collection type has, such as -creating, updating, and reading. We’ll also discuss the ways in which `String` -is different from the other collections, namely how indexing into a `String` is -complicated by the differences between how people and computers interpret -`String` data. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -### What Is a String? - -We’ll first define what we mean by the term *string*. Rust has only one string -type in the core language, which is the string slice `str` that is usually seen -in its borrowed form `&str`. In Chapter 4, we talked about *string slices*, -which are references to some UTF-8 encoded string data stored elsewhere. String -literals, for example, are stored in the binary output of the program and are -therefore string slices. - -The `String` type, which is provided by Rust’s standard library rather than -coded into the core language, is a growable, mutable, owned, UTF-8 encoded -string type. When Rustaceans refer to “strings” in Rust, they usually mean the -`String` and the string slice `&str` types, not just one of those types. -Although this section is largely about `String`, both types are used heavily in -Rust’s standard library, and both `String` and string slices are UTF-8 encoded. - -Rust’s standard library also includes a number of other string types, such as -`OsString`, `OsStr`, `CString`, and `CStr`. Library crates can provide even -more options for storing string data. See how those names all end in `String` -or `Str`? They refer to owned and borrowed variants, just like the `String` and -`str` types you’ve seen previously. These string types can store text in -different encodings or be represented in memory in a different way, for -example. We won’t discuss these other string types in this chapter; see their -API documentation for more about how to use them and when each is appropriate. - -### Creating a New String - -Many of the same operations available with `Vec` are available with `String` -as well, starting with the `new` function to create a string, shown in Listing -8-11: - -```rust -let mut s = String::new(); -``` - -Listing 8-11: Creating a new, empty `String` - -This line creates a new empty string called `s`, which we can then load data -into. Often, we’ll have some initial data that we want to start the string -with. For that, we use the `to_string` method, which is available on any type -that implements the `Display` trait, as string literals do. Listing 8-12 shows -two examples: - -```rust -let data = "initial contents"; - -let s = data.to_string(); - -// the method also works on a literal directly: -let s = "initial contents".to_string(); -``` - -Listing 8-12: Using the `to_string` method to create a -`String` from a string literal - -This code creates a string containing `initial contents`. - -We can also use the function `String::from` to create a `String` from a string -literal. The code in Listing 8-13 is equivalent to the code from Listing 8-12 -that uses `to_string`: - -```rust -let s = String::from("initial contents"); -``` - -Listing 8-13: Using the `String::from` function to create -a `String` from a string literal - -Because strings are used for so many things, we can use many different generic -APIs for strings, providing us with a lot of options. Some of them can seem -redundant, but they all have their place! In this case, `String::from` and -`to_string` do the same thing, so which you choose is a matter of style. - -Remember that strings are UTF-8 encoded, so we can include any properly encoded -data in them, as shown in Listing 8-14: - -```rust -let hello = String::from("السلام عليكم"); -let hello = String::from("Dobrý den"); -let hello = String::from("Hello"); -let hello = String::from("שָׁלוֹם"); -let hello = String::from("नमस्ते"); -let hello = String::from("こんにちは"); -let hello = String::from("안녕하세요"); -let hello = String::from("你好"); -let hello = String::from("Olá"); -let hello = String::from("Здравствуйте"); -let hello = String::from("Hola"); -``` - -Listing 8-14: Storing greetings in different languages in -strings - -All of these are valid `String` values. - -### Updating a String - -A `String` can grow in size and its contents can change, just like the contents -of a `Vec`, if you push more data into it. In addition, you can conveniently -use the `+` operator or the `format!` macro to concatenate `String` values. - -#### Appending to a String with `push_str` and `push` - -We can grow a `String` by using the `push_str` method to append a string slice, -as shown in Listing 8-15: - -```rust -let mut s = String::from("foo"); -s.push_str("bar"); -``` - -Listing 8-15: Appending a string slice to a `String` -using the `push_str` method - -After these two lines, `s` will contain `foobar`. The `push_str` method takes a -string slice because we don’t necessarily want to take ownership of the -parameter. For example, the code in Listing 8-16 shows that it would be -unfortunate if we weren’t able to use `s2` after appending its contents to `s1`: - -```rust -let mut s1 = String::from("foo"); -let s2 = "bar"; -s1.push_str(s2); -println!("s2 is {}", s2); -``` - -Listing 8-16: Using a string slice after appending its -contents to a `String` - -If the `push_str` method took ownership of `s2`, we wouldn’t be able to print -its value on the last line. However, this code works as we’d expect! - -The `push` method takes a single character as a parameter and adds it to the -`String`. Listing 8-17 shows code that adds the letter l to a `String` using -the `push` method: - -```rust -let mut s = String::from("lo"); -s.push('l'); -``` - -Listing 8-17: Adding one character to a `String` value -using `push` - -As a result of this code, `s` will contain `lol`. - -#### Concatenation with the `+` Operator or the `format!` Macro - -Often, you’ll want to combine two existing strings. One way is to use the `+` -operator, as shown in Listing 8-18: - -```rust -let s1 = String::from("Hello, "); -let s2 = String::from("world!"); -let s3 = s1 + &s2; // Note s1 has been moved here and can no longer be used -``` - -Listing 8-18: Using the `+` operator to combine two -`String` values into a new `String` value - -The string `s3` will contain `Hello, world!` as a result of this code. The -reason `s1` is no longer valid after the addition and the reason we used a -reference to `s2` has to do with the signature of the method that gets called -when we use the `+` operator. The `+` operator uses the `add` method, whose -signature looks something like this: - -```rust,ignore -fn add(self, s: &str) -> String { -``` - -This isn’t the exact signature that’s in the standard library: in the standard -library, `add` is defined using generics. Here, we’re looking at the signature -of `add` with concrete types substituted for the generic ones, which is what -happens when we call this method with `String` values. We’ll discuss generics -in Chapter 10. This signature gives us the clues we need to understand the -tricky bits of the `+` operator. - -First, `s2` has an `&`, meaning that we’re adding a *reference* of the second -string to the first string because of the `s` parameter in the `add` function: -we can only add a `&str` to a `String`; we can’t add two `String` values -together. But wait—the type of `&s2` is `&String`, not `&str`, as specified in -the second parameter to `add`. So why does Listing 8-18 compile? - -The reason we’re able to use `&s2` in the call to `add` is that the compiler -can *coerce* the `&String` argument into a `&str`. When we call the `add` -method, Rust uses a *deref coercion*, which here turns `&s2` into `&s2[..]`. -We’ll discuss deref coercion in more depth in Chapter 15. Because `add` does -not take ownership of the `s` parameter, `s2` will still be a valid `String` -after this operation. - -Second, we can see in the signature that `add` takes ownership of `self`, -because `self` does *not* have an `&`. This means `s1` in Listing 8-18 will be -moved into the `add` call and no longer be valid after that. So although `let -s3 = s1 + &s2;` looks like it will copy both strings and create a new one, this -statement actually takes ownership of `s1`, appends a copy of the contents of -`s2`, and then returns ownership of the result. In other words, it looks like -it’s making a lot of copies but isn’t; the implementation is more efficient -than copying. - -If we need to concatenate multiple strings, the behavior of the `+` operator -gets unwieldy: - -```rust -let s1 = String::from("tic"); -let s2 = String::from("tac"); -let s3 = String::from("toe"); - -let s = s1 + "-" + &s2 + "-" + &s3; -``` - -At this point, `s` will be `tic-tac-toe`. With all of the `+` and `"` -characters, it’s difficult to see what’s going on. For more complicated string -combining, we can use the `format!` macro: - -```rust -let s1 = String::from("tic"); -let s2 = String::from("tac"); -let s3 = String::from("toe"); - -let s = format!("{}-{}-{}", s1, s2, s3); -``` - -This code also sets `s` to `tic-tac-toe`. The `format!` macro works in the same -way as `println!`, but instead of printing the output to the screen, it returns -a `String` with the contents. The version of the code using `format!` is much -easier to read and doesn’t take ownership of any of its parameters. - -### Indexing into Strings - -In many other programming languages, accessing individual characters in a -string by referencing them by index is a valid and common operation. However, -if you try to access parts of a `String` using indexing syntax in Rust, you’ll -get an error. Consider the invalid code in Listing 8-19: - -```rust,ignore -let s1 = String::from("hello"); -let h = s1[0]; -``` - -Listing 8-19: Attempting to use indexing syntax with a -String - -This code will result in the following error: - -```text -error[E0277]: the trait bound `std::string::String: std::ops::Index<{integer}>` is not satisfied - --> - | -3 | let h = s1[0]; - | ^^^^^ the type `std::string::String` cannot be indexed by `{integer}` - | - = help: the trait `std::ops::Index<{integer}>` is not implemented for `std::string::String` -``` - -The error and the note tell the story: Rust strings don’t support indexing. But -why not? To answer that question, we need to discuss how Rust stores strings in -memory. - -#### Internal Representation - -A `String` is a wrapper over a `Vec`. Let’s look at some of our properly -encoded UTF-8 example strings from Listing 8-14. First, this one: - -```rust -let len = String::from("Hola").len(); -``` - -In this case, `len` will be 4, which means the vector storing the string “Hola” -is 4 bytes long. Each of these letters takes 1 byte when encoded in UTF-8. But -what about the following line? (Note that this line begins with the capital -Cyrillic letter Ze, not the Arabic number 3.) - -```rust -let len = String::from("Здравствуйте").len(); -``` - -Asked how long the string is, you might say 12. However, Rust’s answer is 24: -that’s the number of bytes it takes to encode “Здравствуйте” in UTF-8, because -each Unicode scalar value in that string takes 2 bytes of storage. Therefore, -an index into the string’s bytes will not always correlate to a valid Unicode -scalar value. To demonstrate, consider this invalid Rust code: - -```rust,ignore -let hello = "Здравствуйте"; -let answer = &hello[0]; -``` - -What should the value of `answer` be? Should it be `З`, the first letter? When -encoded in UTF-8, the first byte of `З` is `208` and the second is `151`, so -`answer` should in fact be `208`, but `208` is not a valid character on its -own. Returning `208` is likely not what a user would want if they asked for the -first letter of this string; however, that’s the only data that Rust has at -byte index 0. Users generally don’t want the byte value returned, even if the -string contains only Latin letters: if `&"hello"[0]` were valid code that -returned the byte value, it would return `104`, not `h`. To avoid returning an -unexpected value and causing bugs that might not be discovered immediately, -Rust doesn’t compile this code at all and prevents misunderstandings early in -the development process. - -#### Bytes and Scalar Values and Grapheme Clusters! Oh My! - -Another point about UTF-8 is that there are actually three relevant ways to -look at strings from Rust’s perspective: as bytes, scalar values, and grapheme -clusters (the closest thing to what we would call *letters*). - -If we look at the Hindi word “नमस्ते” written in the Devanagari script, it is -stored as a vector of `u8` values that looks like this: - -```text -[224, 164, 168, 224, 164, 174, 224, 164, 184, 224, 165, 141, 224, 164, 164, -224, 165, 135] -``` - -That’s 18 bytes and is how computers ultimately store this data. If we look at -them as Unicode scalar values, which are what Rust’s `char` type is, those -bytes look like this: - -```text -['न', 'म', 'स', '्', 'त', 'े'] -``` - -There are six `char` values here, but the fourth and sixth are not letters: -they’re diacritics that don’t make sense on their own. Finally, if we look at -them as grapheme clusters, we’d get what a person would call the four letters -that make up the Hindi word: - -```text -["न", "म", "स्", "ते"] -``` - -Rust provides different ways of interpreting the raw string data that computers -store so that each program can choose the interpretation it needs, no matter -what human language the data is in. - -A final reason Rust doesn’t allow us to index into a `String` to get a -character is that indexing operations are expected to always take constant time -(O(1)). But it isn’t possible to guarantee that performance with a `String`, -because Rust would have to walk through the contents from the beginning to the -index to determine how many valid characters there were. - -### Slicing Strings - -Indexing into a string is often a bad idea because it’s not clear what the -return type of the string-indexing operation should be: a byte value, a -character, a grapheme cluster, or a string slice. Therefore, Rust asks you to -be more specific if you really need to use indices to create string slices. To -be more specific in your indexing and indicate that you want a string slice, -rather than indexing using `[]` with a single number, you can use `[]` with a -range to create a string slice containing particular bytes: - -```rust -let hello = "Здравствуйте"; - -let s = &hello[0..4]; -``` - -Here, `s` will be a `&str` that contains the first 4 bytes of the string. -Earlier, we mentioned that each of these characters was 2 bytes, which means -`s` will be `Зд`. - -What would happen if we used `&hello[0..1]`? The answer: Rust would panic at -runtime in the same way as if an invalid index were accessed in a vector: - -```text -thread 'main' panicked at 'byte index 1 is not a char boundary; it is inside 'З' (bytes 0..2) of `Здравствуйте`', src/libcore/str/mod.rs:2188:4 -``` - -You should use ranges to create string slices with caution, because doing so -can crash your program. - -### Methods for Iterating Over Strings - -Fortunately, you can access elements in a string in other ways. - -If you need to perform operations on individual Unicode scalar values, the best -way to do so is to use the `chars` method. Calling `chars` on “नमस्ते” separates -out and returns six values of type `char`, and you can iterate over the result -in order to access each element: - -```rust -for c in "नमस्ते".chars() { - println!("{}", c); -} -``` - -This code will print the following: - -```text -न -म -स -् -त -े -``` - -The `bytes` method returns each raw byte, which might be appropriate for your -domain: - -```rust -for b in "नमस्ते".bytes() { - println!("{}", b); -} -``` - -This code will print the 18 bytes that make up this `String`: - -```text -224 -164 -// --snip-- -165 -135 -``` - -But be sure to remember that valid Unicode scalar values may be made up of more -than 1 byte. - -Getting grapheme clusters from strings is complex, so this functionality is not -provided by the standard library. Crates are available on -[crates.io](https://crates.io) if this is the functionality you need. - -### Strings Are Not So Simple - -To summarize, strings are complicated. Different programming languages make -different choices about how to present this complexity to the programmer. Rust -has chosen to make the correct handling of `String` data the default behavior -for all Rust programs, which means programmers have to put more thought into -handling UTF-8 data upfront. This trade-off exposes more of the complexity of -strings than is apparent in other programming languages, but it prevents you -from having to handle errors involving non-ASCII characters later in your -development life cycle. - -Let’s switch to something a bit less complex: hash maps! +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch08-02-strings.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch08-03-hash-maps.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch08-03-hash-maps.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch08-03-hash-maps.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch08-03-hash-maps.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,299 +1,10 @@ ## Storing Keys with Associated Values in Hash Maps -The last of our common collections is the *hash map*. The type `HashMap` -stores a mapping of keys of type `K` to values of type `V`. It does this via a -*hashing function*, which determines how it places these keys and values into -memory. Many programming languages support this kind of data structure, but -they often use a different name, such as hash, map, object, hash table, -dictionary, or associative array, just to name a few. +The 2018 edition of the book is no longer distributed with Rust's documentation. -Hash maps are useful when you want to look up data not by using an index, as -you can with vectors, but by using a key that can be of any type. For example, -in a game, you could keep track of each team’s score in a hash map in which -each key is a team’s name and the values are each team’s score. Given a team -name, you can retrieve its score. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -We’ll go over the basic API of hash maps in this section, but many more goodies -are hiding in the functions defined on `HashMap` by the standard library. -As always, check the standard library documentation for more information. - -### Creating a New Hash Map - -You can create an empty hash map with `new` and add elements with `insert`. In -Listing 8-20, we’re keeping track of the scores of two teams whose names are -Blue and Yellow. The Blue team starts with 10 points, and the Yellow team -starts with 50: - -```rust -use std::collections::HashMap; - -let mut scores = HashMap::new(); - -scores.insert(String::from("Blue"), 10); -scores.insert(String::from("Yellow"), 50); -``` - -Listing 8-20: Creating a new hash map and inserting some -keys and values - -Note that we need to first `use` the `HashMap` from the collections portion of -the standard library. Of our three common collections, this one is the least -often used, so it’s not included in the features brought into scope -automatically in the prelude. Hash maps also have less support from the -standard library; there’s no built-in macro to construct them, for example. - -Just like vectors, hash maps store their data on the heap. This `HashMap` has -keys of type `String` and values of type `i32`. Like vectors, hash maps are -homogeneous: all of the keys must have the same type, and all of the values -must have the same type. - -Another way of constructing a hash map is by using the `collect` method on a -vector of tuples, where each tuple consists of a key and its value. The -`collect` method gathers data into a number of collection types, including -`HashMap`. For example, if we had the team names and initial scores in two -separate vectors, we could use the `zip` method to create a vector of tuples -where “Blue” is paired with 10, and so forth. Then we could use the `collect` -method to turn that vector of tuples into a hash map, as shown in Listing 8-21: - -```rust -use std::collections::HashMap; - -let teams = vec![String::from("Blue"), String::from("Yellow")]; -let initial_scores = vec![10, 50]; - -let scores: HashMap<_, _> = teams.iter().zip(initial_scores.iter()).collect(); -``` - -Listing 8-21: Creating a hash map from a list of teams -and a list of scores - -The type annotation `HashMap<_, _>` is needed here because it’s possible to -`collect` into many different data structures and Rust doesn’t know which you -want unless you specify. For the parameters for the key and value types, -however, we use underscores, and Rust can infer the types that the hash map -contains based on the types of the data in the vectors. - -### Hash Maps and Ownership - -For types that implement the `Copy` trait, like `i32`, the values are copied -into the hash map. For owned values like `String`, the values will be moved and -the hash map will be the owner of those values, as demonstrated in Listing 8-22: - -```rust -use std::collections::HashMap; - -let field_name = String::from("Favorite color"); -let field_value = String::from("Blue"); - -let mut map = HashMap::new(); -map.insert(field_name, field_value); -// field_name and field_value are invalid at this point, try using them and -// see what compiler error you get! -``` - -Listing 8-22: Showing that keys and values are owned by -the hash map once they’re inserted - -We aren’t able to use the variables `field_name` and `field_value` after -they’ve been moved into the hash map with the call to `insert`. - -If we insert references to values into the hash map, the values won’t be moved -into the hash map. The values that the references point to must be valid for at -least as long as the hash map is valid. We’ll talk more about these issues in -the “Validating References with Lifetimes” section in Chapter 10. - -### Accessing Values in a Hash Map - -We can get a value out of the hash map by providing its key to the `get` -method, as shown in Listing 8-23: - -```rust -use std::collections::HashMap; - -let mut scores = HashMap::new(); - -scores.insert(String::from("Blue"), 10); -scores.insert(String::from("Yellow"), 50); - -let team_name = String::from("Blue"); -let score = scores.get(&team_name); -``` - -Listing 8-23: Accessing the score for the Blue team -stored in the hash map - -Here, `score` will have the value that’s associated with the Blue team, and the -result will be `Some(&10)`. The result is wrapped in `Some` because `get` -returns an `Option<&V>`; if there’s no value for that key in the hash map, -`get` will return `None`. The program will need to handle the `Option` in one -of the ways that we covered in Chapter 6. - -We can iterate over each key/value pair in a hash map in a similar manner as we -do with vectors, using a `for` loop: - -```rust -use std::collections::HashMap; - -let mut scores = HashMap::new(); - -scores.insert(String::from("Blue"), 10); -scores.insert(String::from("Yellow"), 50); - -for (key, value) in &scores { - println!("{}: {}", key, value); -} -``` - -This code will print each pair in an arbitrary order: - -```text -Yellow: 50 -Blue: 10 -``` - -### Updating a Hash Map - -Although the number of keys and values is growable, each key can only have one -value associated with it at a time. When you want to change the data in a hash -map, you have to decide how to handle the case when a key already has a value -assigned. You could replace the old value with the new value, completely -disregarding the old value. You could keep the old value and ignore the new -value, only adding the new value if the key *doesn’t* already have a value. Or -you could combine the old value and the new value. Let’s look at how to do each -of these! - -#### Overwriting a Value - -If we insert a key and a value into a hash map and then insert that same key -with a different value, the value associated with that key will be replaced. -Even though the code in Listing 8-24 calls `insert` twice, the hash map will -only contain one key/value pair because we’re inserting the value for the Blue -team’s key both times: - -```rust -use std::collections::HashMap; - -let mut scores = HashMap::new(); - -scores.insert(String::from("Blue"), 10); -scores.insert(String::from("Blue"), 25); - -println!("{:?}", scores); -``` - -Listing 8-24: Replacing a value stored with a particular -key - -This code will print `{"Blue": 25}`. The original value of `10` has been -overwritten. - -#### Only Inserting a Value If the Key Has No Value - -It’s common to check whether a particular key has a value and, if it doesn’t, -insert a value for it. Hash maps have a special API for this called `entry` -that takes the key you want to check as a parameter. The return value of the -`entry` function is an enum called `Entry` that represents a value that might -or might not exist. Let’s say we want to check whether the key for the Yellow -team has a value associated with it. If it doesn’t, we want to insert the value -50, and the same for the Blue team. Using the `entry` API, the code looks like -Listing 8-25: - -```rust -use std::collections::HashMap; - -let mut scores = HashMap::new(); -scores.insert(String::from("Blue"), 10); - -scores.entry(String::from("Yellow")).or_insert(50); -scores.entry(String::from("Blue")).or_insert(50); - -println!("{:?}", scores); -``` - -Listing 8-25: Using the `entry` method to only insert if -the key does not already have a value - -The `or_insert` method on `Entry` is defined to return a mutable reference to -the value for the corresponding `Entry` key if that key exists, and if not, -inserts the parameter as the new value for this key and returns a mutable -reference to the new value. This technique is much cleaner than writing the -logic ourselves and, in addition, plays more nicely with the borrow checker. - -Running the code in Listing 8-25 will print `{"Yellow": 50, "Blue": 10}`. The -first call to `entry` will insert the key for the Yellow team with the value -`50` because the Yellow team doesn’t have a value already. The second call to -`entry` will not change the hash map because the Blue team already has the -value `10`. - -#### Updating a Value Based on the Old Value - -Another common use case for hash maps is to look up a key’s value and then -update it based on the old value. For instance, Listing 8-26 shows code that -counts how many times each word appears in some text. We use a hash map with -the words as keys and increment the value to keep track of how many times we’ve -seen that word. If it’s the first time we’ve seen a word, we’ll first insert -the value `0`: - -```rust -use std::collections::HashMap; - -let text = "hello world wonderful world"; - -let mut map = HashMap::new(); - -for word in text.split_whitespace() { - let count = map.entry(word).or_insert(0); - *count += 1; -} - -println!("{:?}", map); -``` - -Listing 8-26: Counting occurrences of words using a hash -map that stores words and counts - -This code will print `{"world": 2, "hello": 1, "wonderful": 1}`. The -`or_insert` method actually returns a mutable reference (`&mut V`) to the value -for this key. Here we store that mutable reference in the `count` variable, so -in order to assign to that value, we must first dereference `count` using the -asterisk (`*`). The mutable reference goes out of scope at the end of the `for` -loop, so all of these changes are safe and allowed by the borrowing rules. - -### Hashing Functions - -By default, `HashMap` uses a cryptographically secure hashing function that can -provide resistance to Denial of Service (DoS) attacks. This is not the fastest -hashing algorithm available, but the trade-off for better security that comes -with the drop in performance is worth it. If you profile your code and find -that the default hash function is too slow for your purposes, you can switch to -another function by specifying a different *hasher*. A hasher is a type that -implements the `BuildHasher` trait. We’ll talk about traits and how to -implement them in Chapter 10. You don’t necessarily have to implement your own -hasher from scratch; [crates.io](https://crates.io) has libraries shared by -other Rust users that provide hashers implementing many common hashing -algorithms. - -## Summary - -Vectors, strings, and hash maps will provide a large amount of functionality -necessary in programs when you need to store, access, and modify data. Here are -some exercises you should now be equipped to solve: - -* Given a list of integers, use a vector and return the mean (the average - value), median (when sorted, the value in the middle position), and mode (the - value that occurs most often; a hash map will be helpful here) of the list. -* Convert strings to pig latin. The first consonant of each word is moved to - the end of the word and “ay” is added, so “first” becomes “irst-fay.” Words - that start with a vowel have “hay” added to the end instead (“apple” becomes - “apple-hay”). Keep in mind the details about UTF-8 encoding! -* Using a hash map and vectors, create a text interface to allow a user to add - employee names to a department in a company. For example, “Add Sally to - Engineering” or “Add Amir to Sales.” Then let the user retrieve a list of all - people in a department or all people in the company by department, sorted - alphabetically. - -The standard library API documentation describes methods that vectors, strings, -and hash maps have that will be helpful for these exercises! - -We’re getting into more complex programs in which operations can fail, so, it’s -a perfect time to discuss error handling. We’ll do that next! +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch08-03-hash-maps.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch09-00-error-handling.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch09-00-error-handling.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch09-00-error-handling.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch09-00-error-handling.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,24 +1,10 @@ # Error Handling -Rust’s commitment to reliability extends to error handling. Errors are a fact -of life in software, so Rust has a number of features for handling situations -in which something goes wrong. In many cases, Rust requires you to acknowledge -the possibility of an error and take some action before your code will compile. -This requirement makes your program more robust by ensuring that you’ll -discover errors and handle them appropriately before you’ve deployed your code -to production! +The 2018 edition of the book is no longer distributed with Rust's documentation. -Rust groups errors into two major categories: *recoverable* and *unrecoverable* -errors. For a recoverable error, such as a file not found error, it’s -reasonable to report the problem to the user and retry the operation. -Unrecoverable errors are always symptoms of bugs, like trying to access a -location beyond the end of an array. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -Most languages don’t distinguish between these two kinds of errors and handle -both in the same way, using mechanisms such as exceptions. Rust doesn’t have -exceptions. Instead, it has the type `Result` for recoverable errors and -the `panic!` macro that stops execution when the program encounters an -unrecoverable error. This chapter covers calling `panic!` first and then talks -about returning `Result` values. Additionally, we’ll explore -considerations when deciding whether to try to recover from an error or to stop -execution. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch09-00-error-handling.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch09-01-unrecoverable-errors-with-panic.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch09-01-unrecoverable-errors-with-panic.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch09-01-unrecoverable-errors-with-panic.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch09-01-unrecoverable-errors-with-panic.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,191 +1,10 @@ ## Unrecoverable Errors with `panic!` -Sometimes, bad things happen in your code, and there’s nothing you can do about -it. In these cases, Rust has the `panic!` macro. When the `panic!` macro -executes, your program will print a failure message, unwind and clean up the -stack, and then quit. This most commonly occurs when a bug of some kind has -been detected and it’s not clear to the programmer how to handle the error. +The 2018 edition of the book is no longer distributed with Rust's documentation. -> ### Unwinding the Stack or Aborting in Response to a Panic -> -> By default, when a panic occurs, the program starts *unwinding*, which -> means Rust walks back up the stack and cleans up the data from each function -> it encounters. But this walking back and cleanup is a lot of work. The -> alternative is to immediately *abort*, which ends the program without -> cleaning up. Memory that the program was using will then need to be cleaned -> up by the operating system. If in your project you need to make the resulting -> binary as small as possible, you can switch from unwinding to aborting upon a -> panic by adding `panic = 'abort'` to the appropriate `[profile]` sections in -> your *Cargo.toml* file. For example, if you want to abort on panic in release -> mode, add this: -> -> ```toml -> [profile.release] -> panic = 'abort' -> ``` +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -Let’s try calling `panic!` in a simple program: - -Filename: src/main.rs - -```rust,should_panic -fn main() { - panic!("crash and burn"); -} -``` - -When you run the program, you’ll see something like this: - -```text -$ cargo run - Compiling panic v0.1.0 (file:///projects/panic) - Finished dev [unoptimized + debuginfo] target(s) in 0.25 secs - Running `target/debug/panic` -thread 'main' panicked at 'crash and burn', src/main.rs:2:4 -note: Run with `RUST_BACKTRACE=1` for a backtrace. -``` - -The call to `panic!` causes the error message contained in the last two -lines. The first line shows our panic message and the place in our source code -where the panic occurred: *src/main.rs:2:4* indicates that it’s the second -line, fourth character of our *src/main.rs* file. - -In this case, the line indicated is part of our code, and if we go to that -line, we see the `panic!` macro call. In other cases, the `panic!` call might -be in code that our code calls, and the filename and line number reported by -the error message will be someone else’s code where the `panic!` macro is -called, not the line of our code that eventually led to the `panic!` call. We -can use the backtrace of the functions the `panic!` call came from to figure -out the part of our code that is causing the problem. We’ll discuss what a -backtrace is in more detail next. - -### Using a `panic!` Backtrace - -Let’s look at another example to see what it’s like when a `panic!` call comes -from a library because of a bug in our code instead of from our code calling -the macro directly. Listing 9-1 has some code that attempts to access an -element by index in a vector: - -Filename: src/main.rs - -```rust,should_panic -fn main() { - let v = vec![1, 2, 3]; - - v[99]; -} -``` - -Listing 9-1: Attempting to access an element beyond the -end of a vector, which will cause a `panic!` - -Here, we’re attempting to access the hundredth element of our vector (which is -at index 99 because indexing starts at zero), but it has only three elements. -In this situation, Rust will panic. Using `[]` is supposed to return an -element, but if you pass an invalid index, there’s no element that Rust could -return here that would be correct. - -Other languages, like C, will attempt to give you exactly what you asked for in -this situation, even though it isn’t what you want: you’ll get whatever is at -the location in memory that would correspond to that element in the vector, -even though the memory doesn’t belong to the vector. This is called a *buffer -overread* and can lead to security vulnerabilities if an attacker is able to -manipulate the index in such a way as to read data they shouldn’t be allowed to -that is stored after the array. - -To protect your program from this sort of vulnerability, if you try to read an -element at an index that doesn’t exist, Rust will stop execution and refuse to -continue. Let’s try it and see: - -```text -$ cargo run - Compiling panic v0.1.0 (file:///projects/panic) - Finished dev [unoptimized + debuginfo] target(s) in 0.27 secs - Running `target/debug/panic` -thread 'main' panicked at 'index out of bounds: the len is 3 but the index is -99', /checkout/src/liballoc/vec.rs:1555:10 -note: Run with `RUST_BACKTRACE=1` for a backtrace. -``` - -This error points at a file we didn’t write, *vec.rs*. That’s the -implementation of `Vec` in the standard library. The code that gets run when -we use `[]` on our vector `v` is in *vec.rs*, and that is where the `panic!` is -actually happening. - -The next note line tells us that we can set the `RUST_BACKTRACE` environment -variable to get a backtrace of exactly what happened to cause the error. A -*backtrace* is a list of all the functions that have been called to get to this -point. Backtraces in Rust work as they do in other languages: the key to -reading the backtrace is to start from the top and read until you see files you -wrote. That’s the spot where the problem originated. The lines above the lines -mentioning your files are code that your code called; the lines below are code -that called your code. These lines might include core Rust code, standard -library code, or crates that you’re using. Let’s try getting a backtrace by -setting the `RUST_BACKTRACE` environment variable to any value except 0. -Listing 9-2 shows output similar to what you’ll see: - -```text -$ RUST_BACKTRACE=1 cargo run - Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs - Running `target/debug/panic` -thread 'main' panicked at 'index out of bounds: the len is 3 but the index is 99', /checkout/src/liballoc/vec.rs:1555:10 -stack backtrace: - 0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace - at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49 - 1: std::sys_common::backtrace::_print - at /checkout/src/libstd/sys_common/backtrace.rs:71 - 2: std::panicking::default_hook::{{closure}} - at /checkout/src/libstd/sys_common/backtrace.rs:60 - at /checkout/src/libstd/panicking.rs:381 - 3: std::panicking::default_hook - at /checkout/src/libstd/panicking.rs:397 - 4: std::panicking::rust_panic_with_hook - at /checkout/src/libstd/panicking.rs:611 - 5: std::panicking::begin_panic - at /checkout/src/libstd/panicking.rs:572 - 6: std::panicking::begin_panic_fmt - at /checkout/src/libstd/panicking.rs:522 - 7: rust_begin_unwind - at /checkout/src/libstd/panicking.rs:498 - 8: core::panicking::panic_fmt - at /checkout/src/libcore/panicking.rs:71 - 9: core::panicking::panic_bounds_check - at /checkout/src/libcore/panicking.rs:58 - 10: as core::ops::index::Index>::index - at /checkout/src/liballoc/vec.rs:1555 - 11: panic::main - at src/main.rs:4 - 12: __rust_maybe_catch_panic - at /checkout/src/libpanic_unwind/lib.rs:99 - 13: std::rt::lang_start - at /checkout/src/libstd/panicking.rs:459 - at /checkout/src/libstd/panic.rs:361 - at /checkout/src/libstd/rt.rs:61 - 14: main - 15: __libc_start_main - 16: -``` - -Listing 9-2: The backtrace generated by a call to -`panic!` displayed when the environment variable `RUST_BACKTRACE` is set - -That’s a lot of output! The exact output you see might be different depending -on your operating system and Rust version. In order to get backtraces with this -information, debug symbols must be enabled. Debug symbols are enabled by -default when using `cargo build` or `cargo run` without the `--release` flag, -as we have here. - -In the output in Listing 9-2, line 11 of the backtrace points to the line in -our project that’s causing the problem: line 4 of *src/main.rs*. If we don’t -want our program to panic, the location pointed to by the first line mentioning -a file we wrote is where we should start investigating. In Listing 9-1, where -we deliberately wrote code that would panic in order to demonstrate how to use -backtraces, the way to fix the panic is to not request an element at index 99 -from a vector that only contains 3 items. When your code panics in the future, -you’ll need to figure out what action the code is taking with what values to -cause the panic and what the code should do instead. - -We’ll come back to `panic!` and when we should and should not use `panic!` to -handle error conditions in the “To `panic!` or Not to `panic!`” section later -in this chapter. Next, we’ll look at how to recover from an error using -`Result`. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch09-01-unrecoverable-errors-with-panic.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch09-02-recoverable-errors-with-result.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch09-02-recoverable-errors-with-result.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch09-02-recoverable-errors-with-result.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch09-02-recoverable-errors-with-result.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,515 +1,10 @@ ## Recoverable Errors with `Result` -Most errors aren’t serious enough to require the program to stop entirely. -Sometimes, when a function fails, it’s for a reason that you can easily -interpret and respond to. For example, if you try to open a file and that -operation fails because the file doesn’t exist, you might want to create the -file instead of terminating the process. +The 2018 edition of the book is no longer distributed with Rust's documentation. -Recall from “[Handling Potential Failure with the `Result` -Type][handle_failure]” in Chapter 2 that the `Result` enum is -defined as having two variants, `Ok` and `Err`, as follows: +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -[handle_failure]: ch02-00-guessing-game-tutorial.html#handling-potential-failure-with-the-result-type - -```rust -enum Result { - Ok(T), - Err(E), -} -``` - -The `T` and `E` are generic type parameters: we’ll discuss generics in more -detail in Chapter 10. What you need to know right now is that `T` represents -the type of the value that will be returned in a success case within the `Ok` -variant, and `E` represents the type of the error that will be returned in a -failure case within the `Err` variant. Because `Result` has these generic type -parameters, we can use the `Result` type and the functions that the standard -library has defined on it in many different situations where the successful -value and error value we want to return may differ. - -Let’s call a function that returns a `Result` value because the function could -fail. In Listing 9-3 we try to open a file: - -Filename: src/main.rs - -```rust -use std::fs::File; - -fn main() { - let f = File::open("hello.txt"); -} -``` - -Listing 9-3: Opening a file - -How do we know `File::open` returns a `Result`? We could look at the -[standard library API documentation](../../std/index.html), -or we could ask the compiler! If we give `f` a type -annotation that we know is *not* the return type of the function and then try -to compile the code, the compiler will tell us that the types don’t match. The -error message will then tell us what the type of `f` *is*. Let’s try it! We -know that the return type of `File::open` isn’t of type `u32`, so let’s change -the `let f` statement to this: - -```rust,ignore -let f: u32 = File::open("hello.txt"); -``` - -Attempting to compile now gives us the following output: - -```text -error[E0308]: mismatched types - --> src/main.rs:4:18 - | -4 | let f: u32 = File::open("hello.txt"); - | ^^^^^^^^^^^^^^^^^^^^^^^ expected u32, found enum -`std::result::Result` - | - = note: expected type `u32` - found type `std::result::Result` -``` - -This tells us the return type of the `File::open` function is a `Result`. -The generic parameter `T` has been filled in here with the type of the success -value, `std::fs::File`, which is a file handle. The type of `E` used in the -error value is `std::io::Error`. - -This return type means the call to `File::open` might succeed and return a file -handle that we can read from or write to. The function call also might fail: -for example, the file might not exist, or we might not have permission to -access the file. The `File::open` function needs to have a way to tell us -whether it succeeded or failed and at the same time give us either the file -handle or error information. This information is exactly what the `Result` enum -conveys. - -In the case where `File::open` succeeds, the value in the variable `f` will be -an instance of `Ok` that contains a file handle. In the case where it fails, -the value in `f` will be an instance of `Err` that contains more information -about the kind of error that happened. - -We need to add to the code in Listing 9-3 to take different actions depending -on the value `File::open` returns. Listing 9-4 shows one way to handle the -`Result` using a basic tool, the `match` expression that we discussed in -Chapter 6. - -Filename: src/main.rs - -```rust,should_panic -use std::fs::File; - -fn main() { - let f = File::open("hello.txt"); - - let f = match f { - Ok(file) => file, - Err(error) => { - panic!("There was a problem opening the file: {:?}", error) - }, - }; -} -``` - -Listing 9-4: Using a `match` expression to handle the -`Result` variants that might be returned - -Note that, like the `Option` enum, the `Result` enum and its variants have been -imported in the prelude, so we don’t need to specify `Result::` before the `Ok` -and `Err` variants in the `match` arms. - -Here we tell Rust that when the result is `Ok`, return the inner `file` value -out of the `Ok` variant, and we then assign that file handle value to the -variable `f`. After the `match`, we can use the file handle for reading or -writing. - -The other arm of the `match` handles the case where we get an `Err` value from -`File::open`. In this example, we’ve chosen to call the `panic!` macro. If -there’s no file named *hello.txt* in our current directory and we run this -code, we’ll see the following output from the `panic!` macro: - -```text -thread 'main' panicked at 'There was a problem opening the file: Error { repr: -Os { code: 2, message: "No such file or directory" } }', src/main.rs:9:12 -``` - -As usual, this output tells us exactly what has gone wrong. - -### Matching on Different Errors - -The code in Listing 9-4 will `panic!` no matter why `File::open` failed. What -we want to do instead is take different actions for different failure reasons: -if `File::open` failed because the file doesn’t exist, we want to create the -file and return the handle to the new file. If `File::open` failed for any -other reason—for example, because we didn’t have permission to open the file—we -still want the code to `panic!` in the same way as it did in Listing 9-4. Look -at Listing 9-5, which adds another arm to the `match`: - -Filename: src/main.rs - - - -```rust,ignore -use std::fs::File; -use std::io::ErrorKind; - -fn main() { - let f = File::open("hello.txt"); - - let f = match f { - Ok(file) => file, - Err(error) => match error.kind() { - ErrorKind::NotFound => match File::create("hello.txt") { - Ok(fc) => fc, - Err(e) => panic!("Tried to create file but there was a problem: {:?}", e), - }, - other_error => panic!("There was a problem opening the file: {:?}", other_error), - }, - }; -} -``` - -Listing 9-5: Handling different kinds of errors in -different ways - -The type of the value that `File::open` returns inside the `Err` variant is -`io::Error`, which is a struct provided by the standard library. This struct -has a method `kind` that we can call to get an `io::ErrorKind` value. The enum -`io::ErrorKind` is provided by the standard library and has variants -representing the different kinds of errors that might result from an `io` -operation. The variant we want to use is `ErrorKind::NotFound`, which indicates -the file we’re trying to open doesn’t exist yet. So, we `match` on `f`, but we -also then have an inner `match` on `error.kind()`. - -The condition we want to check in the match guard is whether the value returned -by `error.kind()` is the `NotFound` variant of the `ErrorKind` enum. If it is, -we try to create the file with `File::create`. However, because `File::create` -could also fail, we need to add another inner `match` statement as well. When -the file can’t be opened, a different error message will be printed. The last -arm of the outer `match` stays the same so the program panics on any error -besides the missing file error. - -That's a lot of `match`! `match` is very powerful, but also very much a primitive. -In Chapter 13, we'll learn about closures. The `Result` type has many -methods that accept a closure, and are implemented as `match` statements. A more -seasoned Rustacean might write this: - -```rust,ignore -use std::fs::File; -use std::io::ErrorKind; - -fn main() { - let f = File::open("hello.txt").map_err(|error| { - if error.kind() == ErrorKind::NotFound { - File::create("hello.txt").unwrap_or_else(|error| { - panic!("Tried to create file but there was a problem: {:?}", error); - }) - } else { - panic!("There was a problem opening the file: {:?}", error); - } - }); -} -``` - -Come back to this example after you've read Chapter 13, and look up what the -`map_err` and `unwrap_or_else` methods do in the standard library -documentation. There's many more of these methods that can clean up huge -nested `match`es when dealing with errors. We'll be looking at some other -strategies shortly! - -### Shortcuts for Panic on Error: `unwrap` and `expect` - -Using `match` works well enough, but it can be a bit verbose and doesn’t always -communicate intent well. The `Result` type has many helper methods -defined on it to do various tasks. One of those methods, called `unwrap`, is a -shortcut method that is implemented just like the `match` statement we wrote in -Listing 9-4. If the `Result` value is the `Ok` variant, `unwrap` will return -the value inside the `Ok`. If the `Result` is the `Err` variant, `unwrap` will -call the `panic!` macro for us. Here is an example of `unwrap` in action: - -Filename: src/main.rs - -```rust,should_panic -use std::fs::File; - -fn main() { - let f = File::open("hello.txt").unwrap(); -} -``` - -If we run this code without a *hello.txt* file, we’ll see an error message from -the `panic!` call that the `unwrap` method makes: - -```text -thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { -repr: Os { code: 2, message: "No such file or directory" } }', -src/libcore/result.rs:906:4 -``` - -Another method, `expect`, which is similar to `unwrap`, lets us also choose the -`panic!` error message. Using `expect` instead of `unwrap` and providing good -error messages can convey your intent and make tracking down the source of a -panic easier. The syntax of `expect` looks like this: - -Filename: src/main.rs - -```rust,should_panic -use std::fs::File; - -fn main() { - let f = File::open("hello.txt").expect("Failed to open hello.txt"); -} -``` - -We use `expect` in the same way as `unwrap`: to return the file handle or call -the `panic!` macro. The error message used by `expect` in its call to `panic!` -will be the parameter that we pass to `expect`, rather than the default -`panic!` message that `unwrap` uses. Here’s what it looks like: - -```text -thread 'main' panicked at 'Failed to open hello.txt: Error { repr: Os { code: -2, message: "No such file or directory" } }', src/libcore/result.rs:906:4 -``` - -Because this error message starts with the text we specified, `Failed to open -hello.txt`, it will be easier to find where in the code this error message is -coming from. If we use `unwrap` in multiple places, it can take more time to -figure out exactly which `unwrap` is causing the panic because all `unwrap` -calls that panic print the same message. - -### Propagating Errors - -When you’re writing a function whose implementation calls something that might -fail, instead of handling the error within this function, you can return the -error to the calling code so that it can decide what to do. This is known as -*propagating* the error and gives more control to the calling code, where there -might be more information or logic that dictates how the error should be -handled than what you have available in the context of your code. - -For example, Listing 9-6 shows a function that reads a username from a file. If -the file doesn’t exist or can’t be read, this function will return those errors -to the code that called this function: - -Filename: src/main.rs - -```rust -use std::io; -use std::io::Read; -use std::fs::File; - -fn read_username_from_file() -> Result { - let f = File::open("hello.txt"); - - let mut f = match f { - Ok(file) => file, - Err(e) => return Err(e), - }; - - let mut s = String::new(); - - match f.read_to_string(&mut s) { - Ok(_) => Ok(s), - Err(e) => Err(e), - } -} -``` - -Listing 9-6: A function that returns errors to the -calling code using `match` - -This function can be written in a much shorter way, but we're going to start by -doing a lot of it manually in order to explore error handling; at the end, -we'll show the easy way. Let’s look at the return type of the function first: -`Result`. This means the function is returning a value of -the type `Result` where the generic parameter `T` has been filled in -with the concrete type `String`, and the generic type `E` has been filled in -with the concrete type `io::Error`. If this function succeeds without any -problems, the code that calls this function will receive an `Ok` value that -holds a `String`—the username that this function read from the file. If this -function encounters any problems, the code that calls this function will -receive an `Err` value that holds an instance of `io::Error` that contains -more information about what the problems were. We chose `io::Error` as the -return type of this function because that happens to be the type of the error -value returned from both of the operations we’re calling in this function’s -body that might fail: the `File::open` function and the `read_to_string` -method. - -The body of the function starts by calling the `File::open` function. Then we -handle the `Result` value returned with a `match` similar to the `match` in -Listing 9-4, only instead of calling `panic!` in the `Err` case, we return -early from this function and pass the error value from `File::open` back to the -calling code as this function’s error value. If `File::open` succeeds, we store -the file handle in the variable `f` and continue. - -Then we create a new `String` in variable `s` and call the `read_to_string` -method on the file handle in `f` to read the contents of the file into `s`. The -`read_to_string` method also returns a `Result` because it might fail, even -though `File::open` succeeded. So we need another `match` to handle that -`Result`: if `read_to_string` succeeds, then our function has succeeded, and we -return the username from the file that’s now in `s` wrapped in an `Ok`. If -`read_to_string` fails, we return the error value in the same way that we -returned the error value in the `match` that handled the return value of -`File::open`. However, we don’t need to explicitly say `return`, because this -is the last expression in the function. - -The code that calls this code will then handle getting either an `Ok` value -that contains a username or an `Err` value that contains an `io::Error`. We -don’t know what the calling code will do with those values. If the calling code -gets an `Err` value, it could call `panic!` and crash the program, use a -default username, or look up the username from somewhere other than a file, for -example. We don’t have enough information on what the calling code is actually -trying to do, so we propagate all the success or error information upward for -it to handle appropriately. - -This pattern of propagating errors is so common in Rust that Rust provides the -question mark operator `?` to make this easier. - -#### A Shortcut for Propagating Errors: the `?` Operator - -Listing 9-7 shows an implementation of `read_username_from_file` that has the -same functionality as it had in Listing 9-6, but this implementation uses the -question mark operator: - -Filename: src/main.rs - -```rust -use std::io; -use std::io::Read; -use std::fs::File; - -fn read_username_from_file() -> Result { - let mut f = File::open("hello.txt")?; - let mut s = String::new(); - f.read_to_string(&mut s)?; - Ok(s) -} -``` - -Listing 9-7: A function that returns errors to the -calling code using `?` - -The `?` placed after a `Result` value is defined to work in almost the same way -as the `match` expressions we defined to handle the `Result` values in Listing -9-6. If the value of the `Result` is an `Ok`, the value inside the `Ok` will -get returned from this expression, and the program will continue. If the value -is an `Err`, the `Err` will be returned from the whole function as if we had -used the `return` keyword so the error value gets propagated to the calling -code. - -There is a difference between what the `match` expression from Listing 9-6 and -`?` do: error values taken by `?` go through the `from` function, defined in -the `From` trait in the standard library, which is used to convert errors from -one type into another. When `?` calls the `from` function, the error type -received is converted into the error type defined in the return type of the -current function. This is useful when a function returns one error type to -represent all the ways a function might fail, even if parts might fail for many -different reasons. As long as each error type implements the `from` function to -define how to convert itself to the returned error type, `?` takes care of the -conversion automatically. - -In the context of Listing 9-7, the `?` at the end of the `File::open` call will -return the value inside an `Ok` to the variable `f`. If an error occurs, `?` -will return early out of the whole function and give any `Err` value to the -calling code. The same thing applies to the `?` at the end of the -`read_to_string` call. - -The `?` operator eliminates a lot of boilerplate and makes this function’s -implementation simpler. We could even shorten this code further by chaining -method calls immediately after the `?`, as shown in Listing 9-8: - -Filename: src/main.rs - -```rust -use std::io; -use std::io::Read; -use std::fs::File; - -fn read_username_from_file() -> Result { - let mut s = String::new(); - - File::open("hello.txt")?.read_to_string(&mut s)?; - - Ok(s) -} -``` - -Listing 9-8: Chaining method calls after `?` - -We’ve moved the creation of the new `String` in `s` to the beginning of the -function; that part hasn’t changed. Instead of creating a variable `f`, we’ve -chained the call to `read_to_string` directly onto the result of -`File::open("hello.txt")?`. We still have a `?` at the end of the -`read_to_string` call, and we still return an `Ok` value containing the -username in `s` when both `File::open` and `read_to_string` succeed rather than -returning errors. The functionality is again the same as in Listing 9-6 and -Listing 9-7; this is just a different, more ergonomic way to write it. - -Speaking of different ways to write this function, there's a way to make this even -shorter: - -Filename: src/main.rs - -```rust -use std::io; -use std::io::Read; -use std::fs; - -fn read_username_from_file() -> Result { - fs::read_to_string("hello.txt") -} -``` - -Listing 9-9: Using `fs::read_to_string` - -Reading a file into a string is a fairly common operation, and so Rust -provides a convenience function called `fs::read_to_string` that will -open the file, create a new `String`, read the contents of the file, -and put the contents into that `String`, and then return it. Of course, -this doesn't give us the opportunity to show off all of this error handling, -so we did it the hard way at first. - -#### The `?` Operator Can Only Be Used in Functions That Return `Result` - -The `?` operator can only be used in functions that have a return type of -`Result`, because it is defined to work in the same way as the `match` -expression we defined in Listing 9-6. The part of the `match` that requires a -return type of `Result` is `return Err(e)`, so the return type of the function -must be a `Result` to be compatible with this `return`. - -Let’s look at what happens if we use `?` in the `main` function, which you’ll -recall has a return type of `()`: - -```rust,ignore -use std::fs::File; - -fn main() { - let f = File::open("hello.txt")?; -} -``` - -When we compile this code, we get the following error message: - -```text -error[E0277]: the trait bound `(): std::ops::Try` is not satisfied - --> src/main.rs:4:13 - | -4 | let f = File::open("hello.txt")?; - | ------------------------ - | | - | the `?` operator can only be used in a function that returns - `Result` (or another type that implements `std::ops::Try`) - | in this macro invocation - | - = help: the trait `std::ops::Try` is not implemented for `()` - = note: required by `std::ops::Try::from_error` -``` - -This error points out that we’re only allowed to use `?` in a function that -returns `Result`. In functions that don’t return `Result`, when you call other -functions that return `Result`, you’ll need to use a `match` or one of the -`Result` methods to handle the `Result` instead of using `?` to potentially -propagate the error to the calling code. - -Now that we’ve discussed the details of calling `panic!` or returning `Result`, -let’s return to the topic of how to decide which is appropriate to use in which -cases. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch09-02-recoverable-errors-with-result.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch09-03-to-panic-or-not-to-panic.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch09-03-to-panic-or-not-to-panic.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch09-03-to-panic-or-not-to-panic.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch09-03-to-panic-or-not-to-panic.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,240 +1,10 @@ ## To `panic!` or Not to `panic!` -So how do you decide when you should call `panic!` and when you should return -`Result`? When code panics, there’s no way to recover. You could call `panic!` -for any error situation, whether there’s a possible way to recover or not, but -then you’re making the decision on behalf of the code calling your code that a -situation is unrecoverable. When you choose to return a `Result` value, you -give the calling code options rather than making the decision for it. The -calling code could choose to attempt to recover in a way that’s appropriate for -its situation, or it could decide that an `Err` value in this case is -unrecoverable, so it can call `panic!` and turn your recoverable error into an -unrecoverable one. Therefore, returning `Result` is a good default choice when -you’re defining a function that might fail. +The 2018 edition of the book is no longer distributed with Rust's documentation. -In rare situations, it’s more appropriate to write code that panics instead of -returning a `Result`. Let’s explore why it’s appropriate to panic in examples, -prototype code, and tests. Then we’ll discuss situations in which the compiler -can’t tell that failure is impossible, but you as a human can. The chapter will -conclude with some general guidelines on how to decide whether to panic in -library code. - -### Examples, Prototype Code, and Tests - -When you’re writing an example to illustrate some concept, having robust -error-handling code in the example as well can make the example less clear. In -examples, it’s understood that a call to a method like `unwrap` that could -panic is meant as a placeholder for the way you’d want your application to -handle errors, which can differ based on what the rest of your code is doing. - -Similarly, the `unwrap` and `expect` methods are very handy when prototyping, -before you’re ready to decide how to handle errors. They leave clear markers in -your code for when you’re ready to make your program more robust. - -If a method call fails in a test, you’d want the whole test to fail, even if -that method isn’t the functionality under test. Because `panic!` is how a test -is marked as a failure, calling `unwrap` or `expect` is exactly what should -happen. - -### Cases in Which You Have More Information Than the Compiler - -It would also be appropriate to call `unwrap` when you have some other logic -that ensures the `Result` will have an `Ok` value, but the logic isn’t -something the compiler understands. You’ll still have a `Result` value that you -need to handle: whatever operation you’re calling still has the possibility of -failing in general, even though it’s logically impossible in your particular -situation. If you can ensure by manually inspecting the code that you’ll never -have an `Err` variant, it’s perfectly acceptable to call `unwrap`. Here’s an -example: - -```rust -use std::net::IpAddr; - -let home: IpAddr = "127.0.0.1".parse().unwrap(); -``` - -We’re creating an `IpAddr` instance by parsing a hardcoded string. We can see -that `127.0.0.1` is a valid IP address, so it’s acceptable to use `unwrap` -here. However, having a hardcoded, valid string doesn’t change the return type -of the `parse` method: we still get a `Result` value, and the compiler will -still make us handle the `Result` as if the `Err` variant is a possibility -because the compiler isn’t smart enough to see that this string is always a -valid IP address. If the IP address string came from a user rather than being -hardcoded into the program and therefore *did* have a possibility of failure, -we’d definitely want to handle the `Result` in a more robust way instead. - -### Guidelines for Error Handling - -It’s advisable to have your code panic when it’s possible that your code -could end up in a bad state. In this context, a *bad state* is when some -assumption, guarantee, contract, or invariant has been broken, such as when -invalid values, contradictory values, or missing values are passed to your -code—plus one or more of the following: - -* The bad state is not something that’s *expected* to happen occasionally. -* Your code after this point needs to rely on not being in this bad state. -* There’s not a good way to encode this information in the types you use. - -If someone calls your code and passes in values that don’t make sense, the best -choice might be to call `panic!` and alert the person using your library to the -bug in their code so they can fix it during development. Similarly, `panic!` is -often appropriate if you’re calling external code that is out of your control -and it returns an invalid state that you have no way of fixing. - -However, when failure is expected, it is more appropriate to return a `Result` -than to make a `panic!` call. Examples include a parser being given malformed -data or an HTTP request returning a status that indicates you have hit a rate -limit. In these cases, returning a `Result` indicates that failure is an -expected possibility that the calling code must decide how to handle. - -When your code performs operations on values, your code should verify the -values are valid first and panic if the values aren’t valid. This is mostly for -safety reasons: attempting to operate on invalid data can expose your code to -vulnerabilities. This is the main reason the standard library will call -`panic!` if you attempt an out-of-bounds memory access: trying to access memory -that doesn’t belong to the current data structure is a common security problem. -Functions often have *contracts*: their behavior is only guaranteed if the -inputs meet particular requirements. Panicking when the contract is violated -makes sense because a contract violation always indicates a caller-side bug and -it’s not a kind of error you want the calling code to have to explicitly -handle. In fact, there’s no reasonable way for calling code to recover; the -calling *programmers* need to fix the code. Contracts for a function, -especially when a violation will cause a panic, should be explained in the API -documentation for the function. - -However, having lots of error checks in all of your functions would be verbose -and annoying. Fortunately, you can use Rust’s type system (and thus the type -checking the compiler does) to do many of the checks for you. If your function -has a particular type as a parameter, you can proceed with your code’s logic -knowing that the compiler has already ensured you have a valid value. For -example, if you have a type rather than an `Option`, your program expects to -have *something* rather than *nothing*. Your code then doesn’t have to handle -two cases for the `Some` and `None` variants: it will only have one case for -definitely having a value. Code trying to pass nothing to your function won’t -even compile, so your function doesn’t have to check for that case at runtime. -Another example is using an unsigned integer type such as `u32`, which ensures -the parameter is never negative. - -Let’s take the idea of using Rust’s type system to ensure we have a valid value -one step further and look at creating a custom type for validation. Recall the -guessing game in Chapter 2 in which our code asked the user to guess a number -between 1 and 100. We never validated that the user’s guess was between those -numbers before checking it against our secret number; we only validated that -the guess was positive. In this case, the consequences were not very dire: our -output of “Too high” or “Too low” would still be correct. But it would be a -useful enhancement to guide the user toward valid guesses and have different -behavior when a user guesses a number that’s out of range versus when a user -types, for example, letters instead. - -One way to do this would be to parse the guess as an `i32` instead of only a -`u32` to allow potentially negative numbers, and then add a check for the -number being in range, like so: - -```rust,ignore -loop { - // --snip-- - - let guess: i32 = match guess.trim().parse() { - Ok(num) => num, - Err(_) => continue, - }; - - if guess < 1 || guess > 100 { - println!("The secret number will be between 1 and 100."); - continue; - } - - match guess.cmp(&secret_number) { - // --snip-- -} -``` - -The `if` expression checks whether our value is out of range, tells the user -about the problem, and calls `continue` to start the next iteration of the loop -and ask for another guess. After the `if` expression, we can proceed with the -comparisons between `guess` and the secret number knowing that `guess` is -between 1 and 100. - -However, this is not an ideal solution: if it was absolutely critical that the -program only operated on values between 1 and 100, and it had many functions -with this requirement, having a check like this in every function would be -tedious (and might impact performance). - -Instead, we can make a new type and put the validations in a function to create -an instance of the type rather than repeating the validations everywhere. That -way, it’s safe for functions to use the new type in their signatures and -confidently use the values they receive. Listing 9-9 shows one way to define a -`Guess` type that will only create an instance of `Guess` if the `new` function -receives a value between 1 and 100: - -```rust -pub struct Guess { - value: i32, -} - -impl Guess { - pub fn new(value: i32) -> Guess { - if value < 1 || value > 100 { - panic!("Guess value must be between 1 and 100, got {}.", value); - } - - Guess { - value - } - } - - pub fn value(&self) -> i32 { - self.value - } -} -``` - -Listing 9-10: A `Guess` type that will only continue with -values between 1 and 100 - -First, we define a struct named `Guess` that has a field named `value` that -holds a `i32`. This is where the number will be stored. - -Then we implement an associated function named `new` on `Guess` that creates -instances of `Guess` values. The `new` function is defined to have one -parameter named `value` of type `i32` and to return a `Guess`. The code in the -body of the `new` function tests `value` to make sure it’s between 1 and 100. -If `value` doesn’t pass this test, we make a `panic!` call, which will alert -the programmer who is writing the calling code that they have a bug they need -to fix, because creating a `Guess` with a `value` outside this range would -violate the contract that `Guess::new` is relying on. The conditions in which -`Guess::new` might panic should be discussed in its public-facing API -documentation; we’ll cover documentation conventions indicating the possibility -of a `panic!` in the API documentation that you create in Chapter 14. If -`value` does pass the test, we create a new `Guess` with its `value` field set -to the `value` parameter and return the `Guess`. - -Next, we implement a method named `value` that borrows `self`, doesn’t have any -other parameters, and returns a `i32`. This kind of method is sometimes called -a *getter*, because its purpose is to get some data from its fields and return -it. This public method is necessary because the `value` field of the `Guess` -struct is private. It’s important that the `value` field be private so code -using the `Guess` struct is not allowed to set `value` directly: code outside -the module *must* use the `Guess::new` function to create an instance of -`Guess`, thereby ensuring there’s no way for a `Guess` to have a `value` that -hasn’t been checked by the conditions in the `Guess::new` function. - -A function that has a parameter or returns only numbers between 1 and 100 could -then declare in its signature that it takes or returns a `Guess` rather than a -`i32` and wouldn’t need to do any additional checks in its body. - -## Summary - -Rust’s error handling features are designed to help you write more robust code. -The `panic!` macro signals that your program is in a state it can’t handle and -lets you tell the process to stop instead of trying to proceed with invalid or -incorrect values. The `Result` enum uses Rust’s type system to indicate that -operations might fail in a way that your code could recover from. You can use -`Result` to tell code that calls your code that it needs to handle potential -success or failure as well. Using `panic!` and `Result` in the appropriate -situations will make your code more reliable in the face of inevitable problems. - -Now that you’ve seen useful ways that the standard library uses generics with -the `Option` and `Result` enums, we’ll talk about how generics work and how you -can use them in your code. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch09-03-to-panic-or-not-to-panic.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch10-00-generics.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch10-00-generics.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch10-00-generics.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch10-00-generics.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,175 +1,10 @@ # Generic Types, Traits, and Lifetimes -Every programming language has tools for effectively handling the duplication -of concepts. In Rust, one such tool is *generics*. Generics are abstract -stand-ins for concrete types or other properties. When we’re writing code, we -can express the behavior of generics or how they relate to other generics -without knowing what will be in their place when compiling and running the code. +The 2018 edition of the book is no longer distributed with Rust's documentation. -Similar to the way a function takes parameters with unknown values to run the -same code on multiple concrete values, functions can take parameters of some -generic type instead of a concrete type, like `i32` or `String`. In fact, we’ve -already used generics in Chapter 6 with `Option`, Chapter 8 with `Vec` -and `HashMap`, and Chapter 9 with `Result`. In this chapter, you’ll -explore how to define your own types, functions, and methods with generics! +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -First, we’ll review how to extract a function to reduce code duplication. Next, -we’ll use the same technique to make a generic function from two functions that -differ only in the types of their parameters. We’ll also explain how to use -generic types in struct and enum definitions. - -Then you’ll learn how to use *traits* to define behavior in a generic way. You -can combine traits with generic types to constrain a generic type to only -those types that have a particular behavior, as opposed to just any type. - -Finally, we’ll discuss *lifetimes*, a variety of generics that give the -compiler information about how references relate to each other. Lifetimes allow -us to borrow values in many situations while still enabling the compiler to -check that the references are valid. - -## Removing Duplication by Extracting a Function - -Before diving into generics syntax, let’s first look at how to remove -duplication that doesn’t involve generic types by extracting a function. Then -we’ll apply this technique to extract a generic function! In the same way that -you recognize duplicated code to extract into a function, you’ll start to -recognize duplicated code that can use generics. - -Consider a short program that finds the largest number in a list, as shown in -Listing 10-1. - -Filename: src/main.rs - -```rust -fn main() { - let number_list = vec![34, 50, 25, 100, 65]; - - let mut largest = number_list[0]; - - for number in number_list { - if number > largest { - largest = number; - } - } - - println!("The largest number is {}", largest); -# assert_eq!(largest, 100); -} -``` - -Listing 10-1: Code to find the largest number in a list -of numbers - -This code stores a list of integers in the variable `number_list` and places -the first number in the list in a variable named `largest`. Then it iterates -through all the numbers in the list, and if the current number is greater than -the number stored in `largest`, it replaces the number in that variable. -However, if the current number is less than the largest number seen so far, the -variable doesn’t change, and the code moves on to the next number in the list. -After considering all the numbers in the list, `largest` should hold the -largest number, which in this case is 100. - -To find the largest number in two different lists of numbers, we can duplicate -the code in Listing 10-1 and use the same logic at two different places in the -program, as shown in Listing 10-2. - -Filename: src/main.rs - -```rust -fn main() { - let number_list = vec![34, 50, 25, 100, 65]; - - let mut largest = number_list[0]; - - for number in number_list { - if number > largest { - largest = number; - } - } - - println!("The largest number is {}", largest); - - let number_list = vec![102, 34, 6000, 89, 54, 2, 43, 8]; - - let mut largest = number_list[0]; - - for number in number_list { - if number > largest { - largest = number; - } - } - - println!("The largest number is {}", largest); -} -``` - -Listing 10-2: Code to find the largest number in *two* -lists of numbers - -Although this code works, duplicating code is tedious and error prone. We also -have to update the code in multiple places when we want to change it. - -To eliminate this duplication, we can create an abstraction by defining a -function that operates on any list of integers given to it in a parameter. This -solution makes our code clearer and lets us express the concept of finding the -largest number in a list abstractly. - -In Listing 10-3, we extracted the code that finds the largest number into a -function named `largest`. Unlike the code in Listing 10-1, which can find the -largest number in only one particular list, this program can find the largest -number in two different lists. - -Filename: src/main.rs - -```rust -fn largest(list: &[i32]) -> i32 { - let mut largest = list[0]; - - for &item in list.iter() { - if item > largest { - largest = item; - } - } - - largest -} - -fn main() { - let number_list = vec![34, 50, 25, 100, 65]; - - let result = largest(&number_list); - println!("The largest number is {}", result); -# assert_eq!(result, 100); - - let number_list = vec![102, 34, 6000, 89, 54, 2, 43, 8]; - - let result = largest(&number_list); - println!("The largest number is {}", result); -# assert_eq!(result, 6000); -} -``` - -Listing 10-3: Abstracted code to find the largest number -in two lists - -The `largest` function has a parameter called `list`, which represents any -concrete slice of `i32` values that we might pass into the function. As a -result, when we call the function, the code runs on the specific values that we -pass in. - -In sum, here are the steps we took to change the code from Listing 10-2 to -Listing 10-3: - -1. Identify duplicate code. -2. Extract the duplicate code into the body of the function and specify the - inputs and return values of that code in the function signature. -3. Update the two instances of duplicated code to call the function instead. - -Next, we’ll use these same steps with generics to reduce code duplication in -different ways. In the same way that the function body can operate on an -abstract `list` instead of specific values, generics allow code to operate on -abstract types. - -For example, say we had two functions: one that finds the largest item in a -slice of `i32` values and one that finds the largest item in a slice of `char` -values. How would we eliminate that duplication? Let’s find out! +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch10-00-generics.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch10-01-syntax.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch10-01-syntax.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch10-01-syntax.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch10-01-syntax.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,462 +1,10 @@ ## Generic Data Types -We can use generics to create definitions for items like function signatures or -structs, which we can then use with many different concrete data types. Let’s -first look at how to define functions, structs, enums, and methods using -generics. Then we’ll discuss how generics affect code performance. +The 2018 edition of the book is no longer distributed with Rust's documentation. -### In Function Definitions +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -When defining a function that uses generics, we place the generics in the -signature of the function where we would usually specify the data types of the -parameters and return value. Doing so makes our code more flexible and provides -more functionality to callers of our function while preventing code duplication. - -Continuing with our `largest` function, Listing 10-4 shows two functions that -both find the largest value in a slice. - -Filename: src/main.rs - -```rust -fn largest_i32(list: &[i32]) -> i32 { - let mut largest = list[0]; - - for &item in list.iter() { - if item > largest { - largest = item; - } - } - - largest -} - -fn largest_char(list: &[char]) -> char { - let mut largest = list[0]; - - for &item in list.iter() { - if item > largest { - largest = item; - } - } - - largest -} - -fn main() { - let number_list = vec![34, 50, 25, 100, 65]; - - let result = largest_i32(&number_list); - println!("The largest number is {}", result); -# assert_eq!(result, 100); - - let char_list = vec!['y', 'm', 'a', 'q']; - - let result = largest_char(&char_list); - println!("The largest char is {}", result); -# assert_eq!(result, 'y'); -} -``` - -Listing 10-4: Two functions that differ only in their -names and the types in their signatures - -The `largest_i32` function is the one we extracted in Listing 10-3 that finds -the largest `i32` in a slice. The `largest_char` function finds the largest -`char` in a slice. The function bodies have the same code, so let’s eliminate -the duplication by introducing a generic type parameter in a single function. - -To parameterize the types in the new function we’ll define, we need to name the -type parameter, just as we do for the value parameters to a function. You can -use any identifier as a type parameter name. But we’ll use `T` because, by -convention, parameter names in Rust are short, often just a letter, and Rust’s -type-naming convention is CamelCase. Short for “type,” `T` is the default -choice of most Rust programmers. - -When we use a parameter in the body of the function, we have to declare the -parameter name in the signature so the compiler knows what that name means. -Similarly, when we use a type parameter name in a function signature, we have -to declare the type parameter name before we use it. To define the generic -`largest` function, place type name declarations inside angle brackets, `<>`, -between the name of the function and the parameter list, like this: - -```rust,ignore -fn largest(list: &[T]) -> T { -``` - -We read this definition as: the function `largest` is generic over some type -`T`. This function has one parameter named `list`, which is a slice of values -of type `T`. The `largest` function will return a value of the same type `T`. - -Listing 10-5 shows the combined `largest` function definition using the generic -data type in its signature. The listing also shows how we can call the function -with either a slice of `i32` values or `char` values. Note that this code won’t -compile yet, but we’ll fix it later in this chapter. - -Filename: src/main.rs - -```rust,ignore -fn largest(list: &[T]) -> T { - let mut largest = list[0]; - - for &item in list.iter() { - if item > largest { - largest = item; - } - } - - largest -} - -fn main() { - let number_list = vec![34, 50, 25, 100, 65]; - - let result = largest(&number_list); - println!("The largest number is {}", result); - - let char_list = vec!['y', 'm', 'a', 'q']; - - let result = largest(&char_list); - println!("The largest char is {}", result); -} -``` - -Listing 10-5: A definition of the `largest` function that -uses generic type parameters but doesn’t compile yet - -If we compile this code right now, we’ll get this error: - -```text -error[E0369]: binary operation `>` cannot be applied to type `T` - --> src/main.rs:5:12 - | -5 | if item > largest { - | ^^^^^^^^^^^^^^ - | - = note: an implementation of `std::cmp::PartialOrd` might be missing for `T` -``` - -The note mentions `std::cmp::PartialOrd`, which is a *trait*. We’ll talk about -traits in the next section. For now, this error states that the body of -`largest` won’t work for all possible types that `T` could be. Because we want -to compare values of type `T` in the body, we can only use types whose values -can be ordered. To enable comparisons, the standard library has the -`std::cmp::PartialOrd` trait that you can implement on types (see Appendix C -for more on this trait). You’ll learn how to specify that a generic type has a -particular trait in the “Trait Bounds” section, but let’s first explore other -ways of using generic type parameters. - -### In Struct Definitions - -We can also define structs to use a generic type parameter in one or more -fields using the `<>` syntax. Listing 10-6 shows how to define a `Point` -struct to hold `x` and `y` coordinate values of any type. - -Filename: src/main.rs - -```rust -struct Point { - x: T, - y: T, -} - -fn main() { - let integer = Point { x: 5, y: 10 }; - let float = Point { x: 1.0, y: 4.0 }; -} -``` - -Listing 10-6: A `Point` struct that holds `x` and `y` -values of type `T` - -The syntax for using generics in struct definitions is similar to that used in -function definitions. First, we declare the name of the type parameter inside -angle brackets just after the name of the struct. Then we can use the generic -type in the struct definition where we would otherwise specify concrete data -types. - -Note that because we’ve used only one generic type to define `Point`, this -definition says that the `Point` struct is generic over some type `T`, and -the fields `x` and `y` are *both* that same type, whatever that type may be. If -we create an instance of a `Point` that has values of different types, as in -Listing 10-7, our code won’t compile. - -Filename: src/main.rs - -```rust,ignore -struct Point { - x: T, - y: T, -} - -fn main() { - let wont_work = Point { x: 5, y: 4.0 }; -} -``` - -Listing 10-7: The fields `x` and `y` must be the same -type because both have the same generic data type `T`. - -In this example, when we assign the integer value 5 to `x`, we let the -compiler know that the generic type `T` will be an integer for this instance of -`Point`. Then when we specify 4.0 for `y`, which we’ve defined to have the -same type as `x`, we’ll get a type mismatch error like this: - -```text -error[E0308]: mismatched types - --> src/main.rs:7:38 - | -7 | let wont_work = Point { x: 5, y: 4.0 }; - | ^^^ expected integral variable, found -floating-point variable - | - = note: expected type `{integer}` - found type `{float}` -``` - -To define a `Point` struct where `x` and `y` are both generics but could have -different types, we can use multiple generic type parameters. For example, in -Listing 10-8, we can change the definition of `Point` to be generic over types -`T` and `U` where `x` is of type `T` and `y` is of type `U`. - -Filename: src/main.rs - -```rust -struct Point { - x: T, - y: U, -} - -fn main() { - let both_integer = Point { x: 5, y: 10 }; - let both_float = Point { x: 1.0, y: 4.0 }; - let integer_and_float = Point { x: 5, y: 4.0 }; -} -``` - -Listing 10-8: A `Point` generic over two types so -that `x` and `y` can be values of different types - -Now all the instances of `Point` shown are allowed! You can use as many generic -type parameters in a definition as you want, but using more than a few makes -your code hard to read. When you need lots of generic types in your code, it -could indicate that your code needs restructuring into smaller pieces. - -### In Enum Definitions - -As we did with structs, we can define enums to hold generic data types in their -variants. Let’s take another look at the `Option` enum that the standard -library provides, which we used in Chapter 6: - -```rust -enum Option { - Some(T), - None, -} -``` - -This definition should now make more sense to you. As you can see, `Option` -is an enum that is generic over type `T` and has two variants: `Some`, which -holds one value of type `T`, and a `None` variant that doesn’t hold any value. -By using the `Option` enum, we can express the abstract concept of having an -optional value, and because `Option` is generic, we can use this abstraction -no matter what the type of the optional value is. - -Enums can use multiple generic types as well. The definition of the `Result` -enum that we used in Chapter 9 is one example: - -```rust -enum Result { - Ok(T), - Err(E), -} -``` - -The `Result` enum is generic over two types, `T` and `E`, and has two variants: -`Ok`, which holds a value of type `T`, and `Err`, which holds a value of type -`E`. This definition makes it convenient to use the `Result` enum anywhere we -have an operation that might succeed (return a value of some type `T`) or fail -(return an error of some type `E`). In fact, this is what we used to open a -file in Listing 9-3, where `T` was filled in with the type `std::fs::File` when -the file was opened successfully and `E` was filled in with the type -`std::io::Error` when there were problems opening the file. - -When you recognize situations in your code with multiple struct or enum -definitions that differ only in the types of the values they hold, you can -avoid duplication by using generic types instead. - -### In Method Definitions - -We can implement methods on structs and enums (as we did in Chapter 5) and use -generic types in their definitions, too. Listing 10-9 shows the `Point` -struct we defined in Listing 10-6 with a method named `x` implemented on it. - -Filename: src/main.rs - -```rust -struct Point { - x: T, - y: T, -} - -impl Point { - fn x(&self) -> &T { - &self.x - } -} - -fn main() { - let p = Point { x: 5, y: 10 }; - - println!("p.x = {}", p.x()); -} -``` - -Listing 10-9: Implementing a method named `x` on the -`Point` struct that will return a reference to the `x` field of type -`T` - -Here, we’ve defined a method named `x` on `Point` that returns a reference -to the data in the field `x`. - -Note that we have to declare `T` just after `impl` so we can use it to specify -that we’re implementing methods on the type `Point`. By declaring `T` as a -generic type after `impl`, Rust can identify that the type in the angle -brackets in `Point` is a generic type rather than a concrete type. - -We could, for example, implement methods only on `Point` instances rather -than on `Point` instances with any generic type. In Listing 10-10 we use the -concrete type `f32`, meaning we don’t declare any types after `impl`. - -```rust -# struct Point { -# x: T, -# y: T, -# } -# -impl Point { - fn distance_from_origin(&self) -> f32 { - (self.x.powi(2) + self.y.powi(2)).sqrt() - } -} -``` - -Listing 10-10: An `impl` block that only applies to a -struct with a particular concrete type for the generic type parameter `T` - -This code means the type `Point` will have a method named -`distance_from_origin` and other instances of `Point` where `T` is not of -type `f32` will not have this method defined. The method measures how far our -point is from the point at coordinates (0.0, 0.0) and uses mathematical -operations that are available only for floating point types. - -Generic type parameters in a struct definition aren’t always the same as those -you use in that struct’s method signatures. For example, Listing 10-11 defines -the method `mixup` on the `Point` struct from Listing 10-8. The method -takes another `Point` as a parameter, which might have different types than the -`self` `Point` we’re calling `mixup` on. The method creates a new `Point` -instance with the `x` value from the `self` `Point` (of type `T`) and the `y` -value from the passed-in `Point` (of type `W`). - -Filename: src/main.rs - -```rust -struct Point { - x: T, - y: U, -} - -impl Point { - fn mixup(self, other: Point) -> Point { - Point { - x: self.x, - y: other.y, - } - } -} - -fn main() { - let p1 = Point { x: 5, y: 10.4 }; - let p2 = Point { x: "Hello", y: 'c'}; - - let p3 = p1.mixup(p2); - - println!("p3.x = {}, p3.y = {}", p3.x, p3.y); -} -``` - -Listing 10-11: A method that uses different generic types -than its struct’s definition - -In `main`, we’ve defined a `Point` that has an `i32` for `x` (with value `5`) -and an `f64` for `y` (with value `10.4`). The `p2` variable is a `Point` struct -that has a string slice for `x` (with value `"Hello"`) and a `char` for `y` -(with value `c`). Calling `mixup` on `p1` with the argument `p2` gives us `p3`, -which will have an `i32` for `x`, because `x` came from `p1`. The `p3` variable -will have a `char` for `y`, because `y` came from `p2`. The `println!` macro -call will print `p3.x = 5, p3.y = c`. - -The purpose of this example is to demonstrate a situation in which some generic -parameters are declared with `impl` and some are declared with the method -definition. Here, the generic parameters `T` and `U` are declared after `impl`, -because they go with the struct definition. The generic parameters `V` and `W` -are declared after `fn mixup`, because they’re only relevant to the method. - -### Performance of Code Using Generics - -You might be wondering whether there is a runtime cost when you’re using -generic type parameters. The good news is that Rust implements generics in such -a way that your code doesn’t run any slower using generic types than it would -with concrete types. - -Rust accomplishes this by performing monomorphization of the code that is using -generics at compile time. *Monomorphization* is the process of turning generic -code into specific code by filling in the concrete types that are used when -compiled. - -In this process, the compiler does the opposite of the steps we used to create -the generic function in Listing 10-5: the compiler looks at all the places -where generic code is called and generates code for the concrete types the -generic code is called with. - -Let’s look at how this works with an example that uses the standard library’s -`Option` enum: - -```rust -let integer = Some(5); -let float = Some(5.0); -``` - -When Rust compiles this code, it performs monomorphization. During that -process, the compiler reads the values that have been used in `Option` -instances and identifies two kinds of `Option`: one is `i32` and the other -is `f64`. As such, it expands the generic definition of `Option` into -`Option_i32` and `Option_f64`, thereby replacing the generic definition with -the specific ones. - -The monomorphized version of the code looks like the following. The generic -`Option` is replaced with the specific definitions created by the compiler: - -Filename: src/main.rs - -```rust -enum Option_i32 { - Some(i32), - None, -} - -enum Option_f64 { - Some(f64), - None, -} - -fn main() { - let integer = Option_i32::Some(5); - let float = Option_f64::Some(5.0); -} -``` - -Because Rust compiles generic code into code that specifies the type in each -instance, we pay no runtime cost for using generics. When the code runs, it -performs just as it would if we had duplicated each definition by hand. The -process of monomorphization makes Rust’s generics extremely efficient at -runtime. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch10-01-syntax.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch10-02-traits.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch10-02-traits.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch10-02-traits.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch10-02-traits.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,590 +1,10 @@ ## Traits: Defining Shared Behavior -A *trait* tells the Rust compiler about functionality a particular type has and -can share with other types. We can use traits to define shared behavior in an -abstract way. We can use trait bounds to specify that a generic can be any type -that has certain behavior. +The 2018 edition of the book is no longer distributed with Rust's documentation. -> Note: Traits are similar to a feature often called *interfaces* in other -> languages, although with some differences. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -### Defining a Trait - -A type’s behavior consists of the methods we can call on that type. Different -types share the same behavior if we can call the same methods on all of those -types. Trait definitions are a way to group method signatures together to -define a set of behaviors necessary to accomplish some purpose. - -For example, let’s say we have multiple structs that hold various kinds and -amounts of text: a `NewsArticle` struct that holds a news story filed in a -particular location and a `Tweet` that can have at most 280 characters along -with metadata that indicates whether it was a new tweet, a retweet, or a reply -to another tweet. - -We want to make a media aggregator library that can display summaries of data -that might be stored in a `NewsArticle` or `Tweet` instance. To do this, we -need a summary from each type, and we need to request that summary by calling a -`summarize` method on an instance. Listing 10-12 shows the definition of a -`Summary` trait that expresses this behavior. - -Filename: src/lib.rs - -```rust -pub trait Summary { - fn summarize(&self) -> String; -} -``` - -Listing 10-12: A `Summary` trait that consists of the -behavior provided by a `summarize` method - -Here, we declare a trait using the `trait` keyword and then the trait’s name, -which is `Summary` in this case. Inside the curly brackets, we declare the -method signatures that describe the behaviors of the types that implement this -trait, which in this case is `fn summarize(&self) -> String`. - -After the method signature, instead of providing an implementation within curly -brackets, we use a semicolon. Each type implementing this trait must provide -its own custom behavior for the body of the method. The compiler will enforce -that any type that has the `Summary` trait will have the method `summarize` -defined with this signature exactly. - -A trait can have multiple methods in its body: the method signatures are listed -one per line and each line ends in a semicolon. - -### Implementing a Trait on a Type - -Now that we’ve defined the desired behavior using the `Summary` trait, we can -implement it on the types in our media aggregator. Listing 10-13 shows an -implementation of the `Summary` trait on the `NewsArticle` struct that uses the -headline, the author, and the location to create the return value of -`summarize`. For the `Tweet` struct, we define `summarize` as the username -followed by the entire text of the tweet, assuming that tweet content is -already limited to 280 characters. - -Filename: src/lib.rs - -```rust -# pub trait Summary { -# fn summarize(&self) -> String; -# } -# -pub struct NewsArticle { - pub headline: String, - pub location: String, - pub author: String, - pub content: String, -} - -impl Summary for NewsArticle { - fn summarize(&self) -> String { - format!("{}, by {} ({})", self.headline, self.author, self.location) - } -} - -pub struct Tweet { - pub username: String, - pub content: String, - pub reply: bool, - pub retweet: bool, -} - -impl Summary for Tweet { - fn summarize(&self) -> String { - format!("{}: {}", self.username, self.content) - } -} -``` - -Listing 10-13: Implementing the `Summary` trait on the -`NewsArticle` and `Tweet` types - -Implementing a trait on a type is similar to implementing regular methods. The -difference is that after `impl`, we put the trait name that we want to -implement, then use the `for` keyword, and then specify the name of the type we -want to implement the trait for. Within the `impl` block, we put the method -signatures that the trait definition has defined. Instead of adding a semicolon -after each signature, we use curly brackets and fill in the method body with -the specific behavior that we want the methods of the trait to have for the -particular type. - -After implementing the trait, we can call the methods on instances of -`NewsArticle` and `Tweet` in the same way we call regular methods, like this: - -```rust,ignore -let tweet = Tweet { - username: String::from("horse_ebooks"), - content: String::from("of course, as you probably already know, people"), - reply: false, - retweet: false, -}; - -println!("1 new tweet: {}", tweet.summarize()); -``` - -This code prints `1 new tweet: horse_ebooks: of course, as you probably already -know, people`. - -Note that because we defined the `Summary` trait and the `NewsArticle` and -`Tweet` types in the same *lib.rs* in Listing 10-13, they’re all in the same -scope. Let’s say this *lib.rs* is for a crate we’ve called `aggregator` and -someone else wants to use our crate’s functionality to implement the `Summary` -trait on a struct defined within their library’s scope. They would need to -import the trait into their scope first. They would do so by specifying `use -aggregator::Summary;`, which then would enable them to implement `Summary` for -their type. The `Summary` trait would also need to be a public trait for -another crate to implement it, which it is because we put the `pub` keyword -before `trait` in Listing 10-12. - -One restriction to note with trait implementations is that we can implement a -trait on a type only if either the trait or the type is local to our crate. -For example, we can implement standard library traits like `Display` on a -custom type like `Tweet` as part of our `aggregator` crate functionality, -because the type `Tweet` is local to our `aggregator` crate. We can also -implement `Summary` on `Vec` in our `aggregator` crate, because the -trait `Summary` is local to our `aggregator` crate. - -But we can’t implement external traits on external types. For example, we can’t -implement the `Display` trait on `Vec` within our `aggregator` crate, -because `Display` and `Vec` are defined in the standard library and aren’t -local to our `aggregator` crate. This restriction is part of a property of -programs called *coherence*, and more specifically the *orphan rule*, so named -because the parent type is not present. This rule ensures that other people’s -code can’t break your code and vice versa. Without the rule, two crates could -implement the same trait for the same type, and Rust wouldn’t know which -implementation to use. - -### Default Implementations - -Sometimes it’s useful to have default behavior for some or all of the methods -in a trait instead of requiring implementations for all methods on every type. -Then, as we implement the trait on a particular type, we can keep or override -each method’s default behavior. - -Listing 10-14 shows how to specify a default string for the `summarize` method -of the `Summary` trait instead of only defining the method signature, as we did -in Listing 10-12. - -Filename: src/lib.rs - -```rust -pub trait Summary { - fn summarize(&self) -> String { - String::from("(Read more...)") - } -} -``` - -Listing 10-14: Definition of a `Summary` trait with a -default implementation of the `summarize` method - -To use a default implementation to summarize instances of `NewsArticle` instead -of defining a custom implementation, we specify an empty `impl` block with -`impl Summary for NewsArticle {}`. - -Even though we’re no longer defining the `summarize` method on `NewsArticle` -directly, we’ve provided a default implementation and specified that -`NewsArticle` implements the `Summary` trait. As a result, we can still call -the `summarize` method on an instance of `NewsArticle`, like this: - -```rust,ignore -let article = NewsArticle { - headline: String::from("Penguins win the Stanley Cup Championship!"), - location: String::from("Pittsburgh, PA, USA"), - author: String::from("Iceburgh"), - content: String::from("The Pittsburgh Penguins once again are the best - hockey team in the NHL."), -}; - -println!("New article available! {}", article.summarize()); -``` - -This code prints `New article available! (Read more...)`. - -Creating a default implementation for `summarize` doesn’t require us to change -anything about the implementation of `Summary` on `Tweet` in Listing 10-13. The -reason is that the syntax for overriding a default implementation is the same -as the syntax for implementing a trait method that doesn’t have a default -implementation. - -Default implementations can call other methods in the same trait, even if those -other methods don’t have a default implementation. In this way, a trait can -provide a lot of useful functionality and only require implementors to specify -a small part of it. For example, we could define the `Summary` trait to have a -`summarize_author` method whose implementation is required, and then define a -`summarize` method that has a default implementation that calls the -`summarize_author` method: - -```rust -pub trait Summary { - fn summarize_author(&self) -> String; - - fn summarize(&self) -> String { - format!("(Read more from {}...)", self.summarize_author()) - } -} -``` - -To use this version of `Summary`, we only need to define `summarize_author` -when we implement the trait on a type: - -```rust,ignore -impl Summary for Tweet { - fn summarize_author(&self) -> String { - format!("@{}", self.username) - } -} -``` - -After we define `summarize_author`, we can call `summarize` on instances of the -`Tweet` struct, and the default implementation of `summarize` will call the -definition of `summarize_author` that we’ve provided. Because we’ve implemented -`summarize_author`, the `Summary` trait has given us the behavior of the -`summarize` method without requiring us to write any more code. - -```rust,ignore -let tweet = Tweet { - username: String::from("horse_ebooks"), - content: String::from("of course, as you probably already know, people"), - reply: false, - retweet: false, -}; - -println!("1 new tweet: {}", tweet.summarize()); -``` - -This code prints `1 new tweet: (Read more from @horse_ebooks...)`. - -Note that it isn’t possible to call the default implementation from an -overriding implementation of that same method. - -### Traits as arguments - -Now that you know how to define traits and implement those traits on types, we -can explore how to use traits to accept arguments of many different types. - -For example, in Listing 10-13, we implemented the `Summary` trait on the types -`NewsArticle` and `Tweet`. We can define a function `notify` that calls the -`summarize` method on its parameter `item`, which is of some type that implements -the `Summary` trait. To do this, we can use the '`impl Trait`' syntax, like this: - -```rust,ignore -pub fn notify(item: impl Summary) { - println!("Breaking news! {}", item.summarize()); -} -``` - -In the body of `notify`, we can call any methods on `item` that come from -the `Summary` trait, like `summarize`. - -#### Trait Bounds - -The `impl Trait` syntax works for short examples, but is syntax sugar for a -longer form. This is called a 'trait bound', and it looks like this: - -```rust,ignore -pub fn notify(item: T) { - println!("Breaking news! {}", item.summarize()); -} -``` - -This is equivalent to the example above, but is a bit more verbose. We place -trait bounds with the declaration of the generic type parameter, after a -colon and inside angle brackets. Because of the trait bound on `T`, we can -call `notify` and pass in any instance of `NewsArticle` or `Tweet`. Code that -calls the function with any other type, like a `String` or an `i32`, won’t -compile, because those types don’t implement `Summary`. - -When should you use this form over `impl Trait`? While `impl Trait` is nice for -shorter examples, trait bounds are nice for more complex ones. For example, -say we wanted to take two things that implement `Summary`: - -```rust,ignore -pub fn notify(item1: impl Summary, item2: impl Summary) { -pub fn notify(item1: T, item2: T) { -``` - -The version with the bound is a bit easier. In general, you should use whatever -form makes your code the most understandable. - -##### Multiple trait bounds with `+` - -We can specify multiple trait bounds on a generic type using the `+` syntax. -For example, to use display formatting on the type `T` in a function as well as -the `summarize` method, we can use `T: Summary + Display` to say `T` can be any -type that implements `Summary` and `Display`. This can grow quite complex! - -#### `where` clauses for clearer code - -However, there are downsides to using too many trait bounds. Each generic has -its own trait bounds, so functions with multiple generic type parameters can -have lots of trait bound information between a function’s name and its -parameter list, making the function signature hard to read. For this reason, -Rust has alternate syntax for specifying trait bounds inside a `where` clause -after the function signature. So instead of writing this: - -```rust,ignore -fn some_function(t: T, u: U) -> i32 { -``` - -we can use a `where` clause, like this: - -```rust,ignore -fn some_function(t: T, u: U) -> i32 - where T: Display + Clone, - U: Clone + Debug -{ -``` - -This function’s signature is less cluttered in that the function name, -parameter list, and return type are close together, similar to a function -without lots of trait bounds. - -### Returning Traits - -We can use the `impl Trait` syntax in return position as well, to return -something that implements a trait: - -```rust,ignore -fn returns_summarizable() -> impl Summary { - Tweet { - username: String::from("horse_ebooks"), - content: String::from("of course, as you probably already know, people"), - reply: false, - retweet: false, - } -} -``` - -This signature says, "I'm going to return something that implements the -`Summary` trait, but I'm not going to tell you the exact type." In our case, -we're returning a `Tweet`, but the caller doesn't know that. - -Why is this useful? In chapter 13, we're going to learn about two features -that rely heavily on traits: closures, and iterators. These features create -types that only the compiler knows, or types that are very, very long. -`impl Trait` lets you simply say "this returns an `Iterator`" without -needing to write out a really long type. - -This only works if you have a single type that you're returning, however. -For example, this would *not* work: - -```rust,ignore -fn returns_summarizable(switch: bool) -> impl Summary { - if switch { - NewsArticle { - headline: String::from("Penguins win the Stanley Cup Championship!"), - location: String::from("Pittsburgh, PA, USA"), - author: String::from("Iceburgh"), - content: String::from("The Pittsburgh Penguins once again are the best - hockey team in the NHL."), - } - } else { - Tweet { - username: String::from("horse_ebooks"), - content: String::from("of course, as you probably already know, people"), - reply: false, - retweet: false, - } - } -} -``` - -Here, we try to return either a `NewsArticle` or a `Tweet`. This cannot work, -due to restrictions around how `impl Trait` works. To write this code, you'll -have to wait until Chapter 17, "trait objects". - -### Fixing the `largest` Function with Trait Bounds - -Now that you know how to specify the behavior you want to use using the generic -type parameter’s bounds, let’s return to Listing 10-5 to fix the definition of -the `largest` function that uses a generic type parameter! Last time we tried -to run that code, we received this error: - -```text -error[E0369]: binary operation `>` cannot be applied to type `T` - --> src/main.rs:5:12 - | -5 | if item > largest { - | ^^^^^^^^^^^^^^ - | - = note: an implementation of `std::cmp::PartialOrd` might be missing for `T` -``` - -In the body of `largest` we wanted to compare two values of type `T` using the -greater than (`>`) operator. Because that operator is defined as a default -method on the standard library trait `std::cmp::PartialOrd`, we need to specify -`PartialOrd` in the trait bounds for `T` so the `largest` function can work on -slices of any type that we can compare. We don’t need to bring `PartialOrd` -into scope because it’s in the prelude. Change the signature of `largest` to -look like this: - -```rust,ignore -fn largest(list: &[T]) -> T { -``` - -This time when we compile the code, we get a different set of errors: - -```text -error[E0508]: cannot move out of type `[T]`, a non-copy slice - --> src/main.rs:2:23 - | -2 | let mut largest = list[0]; - | ^^^^^^^ - | | - | cannot move out of here - | help: consider using a reference instead: `&list[0]` - -error[E0507]: cannot move out of borrowed content - --> src/main.rs:4:9 - | -4 | for &item in list.iter() { - | ^---- - | || - | |hint: to prevent move, use `ref item` or `ref mut item` - | cannot move out of borrowed content -``` - -The key line in this error is `cannot move out of type [T], a non-copy slice`. -With our non-generic versions of the `largest` function, we were only trying to -find the largest `i32` or `char`. As discussed in the “Stack-Only Data: Copy” -section in Chapter 4, types like `i32` and `char` that have a known size can be -stored on the stack, so they implement the `Copy` trait. But when we made the -`largest` function generic, it became possible for the `list` parameter to have -types in it that don’t implement the `Copy` trait. Consequently, we wouldn’t be -able to move the value out of `list[0]` and into the `largest` variable, -resulting in this error. - -To call this code with only those types that implement the `Copy` trait, we can -add `Copy` to the trait bounds of `T`! Listing 10-15 shows the complete code of -a generic `largest` function that will compile as long as the types of the -values in the slice that we pass into the function implement the `PartialOrd` -*and* `Copy` traits, like `i32` and `char` do. - -Filename: src/main.rs - -```rust -fn largest(list: &[T]) -> T { - let mut largest = list[0]; - - for &item in list.iter() { - if item > largest { - largest = item; - } - } - - largest -} - -fn main() { - let number_list = vec![34, 50, 25, 100, 65]; - - let result = largest(&number_list); - println!("The largest number is {}", result); - - let char_list = vec!['y', 'm', 'a', 'q']; - - let result = largest(&char_list); - println!("The largest char is {}", result); -} -``` - -Listing 10-15: A working definition of the `largest` -function that works on any generic type that implements the `PartialOrd` and -`Copy` traits - -If we don’t want to restrict the `largest` function to the types that implement -the `Copy` trait, we could specify that `T` has the trait bound `Clone` instead -of `Copy`. Then we could clone each value in the slice when we want the -`largest` function to have ownership. Using the `clone` function means we’re -potentially making more heap allocations in the case of types that own heap -data like `String`, and heap allocations can be slow if we’re working with -large amounts of data. - -Another way we could implement `largest` is for the function to return a -reference to a `T` value in the slice. If we change the return type to `&T` -instead of `T`, thereby changing the body of the function to return a -reference, we wouldn’t need the `Clone` or `Copy` trait bounds and we could -avoid heap allocations. Try implementing these alternate solutions on your own! - -### Using Trait Bounds to Conditionally Implement Methods - -By using a trait bound with an `impl` block that uses generic type parameters, -we can implement methods conditionally for types that implement the specified -traits. For example, the type `Pair` in Listing 10-16 always implements the -`new` function. But `Pair` only implements the `cmp_display` method if its -inner type `T` implements the `PartialOrd` trait that enables comparison *and* -the `Display` trait that enables printing. - -```rust -use std::fmt::Display; - -struct Pair { - x: T, - y: T, -} - -impl Pair { - fn new(x: T, y: T) -> Self { - Self { - x, - y, - } - } -} - -impl Pair { - fn cmp_display(&self) { - if self.x >= self.y { - println!("The largest member is x = {}", self.x); - } else { - println!("The largest member is y = {}", self.y); - } - } -} -``` - -Listing 10-16: Conditionally implement methods on a -generic type depending on trait bounds - -We can also conditionally implement a trait for any type that implements -another trait. Implementations of a trait on any type that satisfies the trait -bounds are called *blanket implementations* and are extensively used in the -Rust standard library. For example, the standard library implements the -`ToString` trait on any type that implements the `Display` trait. The `impl` -block in the standard library looks similar to this code: - -```rust,ignore -impl ToString for T { - // --snip-- -} -``` - -Because the standard library has this blanket implementation, we can call the -`to_string` method defined by the `ToString` trait on any type that implements -the `Display` trait. For example, we can turn integers into their corresponding -`String` values like this because integers implement `Display`: - -```rust -let s = 3.to_string(); -``` - -Blanket implementations appear in the documentation for the trait in the -“Implementors” section. - -Traits and trait bounds let us write code that uses generic type parameters to -reduce duplication but also specify to the compiler that we want the generic -type to have particular behavior. The compiler can then use the trait bound -information to check that all the concrete types used with our code provide the -correct behavior. In dynamically typed languages, we would get an error at -runtime if we called a method on a type that the type didn’t implement. But -Rust moves these errors to compile time so we’re forced to fix the problems -before our code is even able to run. Additionally, we don’t have to write code -that checks for behavior at runtime because we’ve already checked at compile -time. Doing so improves performance without having to give up the flexibility -of generics. - -Another kind of generic that we’ve already been using is called *lifetimes*. -Rather than ensuring that a type has the behavior we want, lifetimes ensure -that references are valid as long as we need them to be. Let’s look at how -lifetimes do that. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch10-02-traits.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch10-03-lifetime-syntax.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch10-03-lifetime-syntax.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch10-03-lifetime-syntax.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch10-03-lifetime-syntax.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,771 +1,10 @@ ## Validating References with Lifetimes -One detail we didn’t discuss in the “References and Borrowing” section in -Chapter 4 is that every reference in Rust has a *lifetime*, which is the scope -for which that reference is valid. Most of the time, lifetimes are implicit and -inferred, just like most of the time, types are inferred. We must annotate types -when multiple types are possible. In a similar way, we must annotate lifetimes -when the lifetimes of references could be related in a few different ways. Rust -requires us to annotate the relationships using generic lifetime parameters to -ensure the actual references used at runtime will definitely be valid. +The 2018 edition of the book is no longer distributed with Rust's documentation. -The concept of lifetimes is somewhat different from tools in other programming -languages, arguably making lifetimes Rust’s most distinctive feature. Although -we won’t cover lifetimes in their entirety in this chapter, we’ll discuss -common ways you might encounter lifetime syntax so you can become familiar with -the concepts. See the “Advanced Lifetimes” section in Chapter 19 for more -detailed information. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -### Preventing Dangling References with Lifetimes - -The main aim of lifetimes is to prevent dangling references, which cause a -program to reference data other than the data it’s intended to reference. -Consider the program in Listing 10-17, which has an outer scope and an inner -scope. - -```rust,ignore -{ - let r; - - { - let x = 5; - r = &x; - } - - println!("r: {}", r); -} -``` - -Listing 10-17: An attempt to use a reference whose value -has gone out of scope - -> Note: The examples in Listings 10-17, 10-18, and 10-24 declare variables -> without giving them an initial value, so the variable name exists in the -> outer scope. At first glance, this might appear to be in conflict with Rust’s -> having no null values. However, if we try to use a variable before giving it -> a value, we’ll get a compile-time error, which shows that Rust indeed does -> not allow null values. - -The outer scope declares a variable named `r` with no initial value, and the -inner scope declares a variable named `x` with the initial value of 5. Inside -the inner scope, we attempt to set the value of `r` as a reference to `x`. Then -the inner scope ends, and we attempt to print the value in `r`. This code won’t -compile because the value `r` is referring to has gone out of scope before we -try to use it. Here is the error message: - -```text -error[E0597]: `x` does not live long enough - --> src/main.rs:7:5 - | -6 | r = &x; - | - borrow occurs here -7 | } - | ^ `x` dropped here while still borrowed -... -10 | } - | - borrowed value needs to live until here -``` - -The variable `x` doesn’t “live long enough.” The reason is that `x` will be out -of scope when the inner scope ends on line 7. But `r` is still valid for the -outer scope; because its scope is larger, we say that it “lives longer.” If -Rust allowed this code to work, `r` would be referencing memory that was -deallocated when `x` went out of scope, and anything we tried to do with `r` -wouldn’t work correctly. So how does Rust determine that this code is invalid? -It uses a borrow checker. - -### The Borrow Checker - -The Rust compiler has a *borrow checker* that compares scopes to determine -whether all borrows are valid. Listing 10-18 shows the same code as Listing -10-17 but with annotations showing the lifetimes of the variables. - -```rust,ignore -{ - let r; // ---------+-- 'a - // | - { // | - let x = 5; // -+-- 'b | - r = &x; // | | - } // -+ | - // | - println!("r: {}", r); // | -} // ---------+ -``` - -Listing 10-18: Annotations of the lifetimes of `r` and -`x`, named `'a` and `'b`, respectively - -Here, we’ve annotated the lifetime of `r` with `'a` and the lifetime of `x` -with `'b`. As you can see, the inner `'b` block is much smaller than the outer -`'a` lifetime block. At compile time, Rust compares the size of the two -lifetimes and sees that `r` has a lifetime of `'a` but that it refers to memory -with a lifetime of `'b`. The program is rejected because `'b` is shorter than -`'a`: the subject of the reference doesn’t live as long as the reference. - -Listing 10-19 fixes the code so it doesn’t have a dangling reference and -compiles without any errors. - -```rust -{ - let x = 5; // ----------+-- 'b - // | - let r = &x; // --+-- 'a | - // | | - println!("r: {}", r); // | | - // --+ | -} // ----------+ -``` - -Listing 10-19: A valid reference because the data has a -longer lifetime than the reference - -Here, `x` has the lifetime `'b`, which in this case is larger than `'a`. This -means `r` can reference `x` because Rust knows that the reference in `r` will -always be valid while `x` is valid. - -Now that you know where the lifetimes of references are and how Rust analyzes -lifetimes to ensure references will always be valid, let’s explore generic -lifetimes of parameters and return values in the context of functions. - -### Generic Lifetimes in Functions - -Let’s write a function that returns the longer of two string slices. This -function will take two string slices and return a string slice. After we’ve -implemented the `longest` function, the code in Listing 10-20 should print `The -longest string is abcd`. - -Filename: src/main.rs - -```rust,ignore -fn main() { - let string1 = String::from("abcd"); - let string2 = "xyz"; - - let result = longest(string1.as_str(), string2); - println!("The longest string is {}", result); -} -``` - -Listing 10-20: A `main` function that calls the `longest` -function to find the longer of two string slices - -Note that we want the function to take string slices, which are references, -because we don’t want the `longest` function to take ownership of its -parameters. We want to allow the function to accept slices of a `String` (the -type stored in the variable `string1`) as well as string literals (which is -what variable `string2` contains). - -Refer to the “String Slices as Parameters” section in Chapter 4 for more -discussion about why the parameters we use in Listing 10-20 are the ones we -want. - -If we try to implement the `longest` function as shown in Listing 10-21, it -won’t compile. - -Filename: src/main.rs - -```rust,ignore -fn longest(x: &str, y: &str) -> &str { - if x.len() > y.len() { - x - } else { - y - } -} -``` - -Listing 10-21: An implementation of the `longest` -function that returns the longer of two string slices but does not yet -compile - -Instead, we get the following error that talks about lifetimes: - -```text -error[E0106]: missing lifetime specifier - --> src/main.rs:1:33 - | -1 | fn longest(x: &str, y: &str) -> &str { - | ^ expected lifetime parameter - | - = help: this function's return type contains a borrowed value, but the -signature does not say whether it is borrowed from `x` or `y` -``` - -The help text reveals that the return type needs a generic lifetime parameter -on it because Rust can’t tell whether the reference being returned refers to -`x` or `y`. Actually, we don’t know either, because the `if` block in the body -of this function returns a reference to `x` and the `else` block returns a -reference to `y`! - -When we’re defining this function, we don’t know the concrete values that will -be passed into this function, so we don’t know whether the `if` case or the -`else` case will execute. We also don’t know the concrete lifetimes of the -references that will be passed in, so we can’t look at the scopes as we did in -Listings 10-18 and 10-19 to determine whether the reference we return will -always be valid. The borrow checker can’t determine this either, because it -doesn’t know how the lifetimes of `x` and `y` relate to the lifetime of the -return value. To fix this error, we’ll add generic lifetime parameters that -define the relationship between the references so the borrow checker can -perform its analysis. - -### Lifetime Annotation Syntax - -Lifetime annotations don’t change how long any of the references live. Just -as functions can accept any type when the signature specifies a generic type -parameter, functions can accept references with any lifetime by specifying a -generic lifetime parameter. Lifetime annotations describe the relationships of -the lifetimes of multiple references to each other without affecting the -lifetimes. - -Lifetime annotations have a slightly unusual syntax: the names of lifetime -parameters must start with an apostrophe (`'`) and are usually all lowercase and -very short, like generic types. Most people use the name `'a`. We place -lifetime parameter annotations after the `&` of a reference, using a space to -separate the annotation from the reference’s type. - -Here are some examples: a reference to an `i32` without a lifetime parameter, a -reference to an `i32` that has a lifetime parameter named `'a`, and a mutable -reference to an `i32` that also has the lifetime `'a`. - -```rust,ignore -&i32 // a reference -&'a i32 // a reference with an explicit lifetime -&'a mut i32 // a mutable reference with an explicit lifetime -``` - -One lifetime annotation by itself doesn’t have much meaning, because the -annotations are meant to tell Rust how generic lifetime parameters of multiple -references relate to each other. For example, let’s say we have a function with -the parameter `first` that is a reference to an `i32` with lifetime `'a`. The -function also has another parameter named `second` that is another reference to -an `i32` that also has the lifetime `'a`. The lifetime annotations indicate -that the references `first` and `second` must both live as long as that generic -lifetime. - -### Lifetime Annotations in Function Signatures - -Now let’s examine lifetime annotations in the context of the `longest` -function. As with generic type parameters, we need to declare generic lifetime -parameters inside angle brackets between the function name and the parameter -list. The constraint we want to express in this signature is that all the -references in the parameters and the return value must have the same lifetime. -We’ll name the lifetime `'a` and then add it to each reference, as shown in -Listing 10-22. - -Filename: src/main.rs - -```rust -fn longest<'a>(x: &'a str, y: &'a str) -> &'a str { - if x.len() > y.len() { - x - } else { - y - } -} -``` - -Listing 10-22: The `longest` function definition -specifying that all the references in the signature must have the same lifetime -`'a` - -This code should compile and produce the result we want when we use it with the -`main` function in Listing 10-20. - -The function signature now tells Rust that for some lifetime `'a`, the function -takes two parameters, both of which are string slices that live at least as -long as lifetime `'a`. The function signature also tells Rust that the string -slice returned from the function will live at least as long as lifetime `'a`. -These constraints are what we want Rust to enforce. Remember, when we specify -the lifetime parameters in this function signature, we’re not changing the -lifetimes of any values passed in or returned. Rather, we’re specifying that -the borrow checker should reject any values that don’t adhere to these -constraints. Note that the `longest` function doesn’t need to know exactly how -long `x` and `y` will live, only that some scope can be substituted for `'a` -that will satisfy this signature. - -When annotating lifetimes in functions, the annotations go in the function -signature, not in the function body. Rust can analyze the code within the -function without any help. However, when a function has references to or from -code outside that function, it becomes almost impossible for Rust to figure out -the lifetimes of the parameters or return values on its own. The lifetimes -might be different each time the function is called. This is why we need to -annotate the lifetimes manually. - -When we pass concrete references to `longest`, the concrete lifetime that is -substituted for `'a` is the part of the scope of `x` that overlaps with the -scope of `y`. In other words, the generic lifetime `'a` will get the concrete -lifetime that is equal to the smaller of the lifetimes of `x` and `y`. Because -we’ve annotated the returned reference with the same lifetime parameter `'a`, -the returned reference will also be valid for the length of the smaller of the -lifetimes of `x` and `y`. - -Let’s look at how the lifetime annotations restrict the `longest` function by -passing in references that have different concrete lifetimes. Listing 10-23 is -a straightforward example. - -Filename: src/main.rs - -```rust -# fn longest<'a>(x: &'a str, y: &'a str) -> &'a str { -# if x.len() > y.len() { -# x -# } else { -# y -# } -# } -# -fn main() { - let string1 = String::from("long string is long"); - - { - let string2 = String::from("xyz"); - let result = longest(string1.as_str(), string2.as_str()); - println!("The longest string is {}", result); - } -} -``` - -Listing 10-23: Using the `longest` function with -references to `String` values that have different concrete lifetimes - -In this example, `string1` is valid until the end of the outer scope, `string2` -is valid until the end of the inner scope, and `result` references something -that is valid until the end of the inner scope. Run this code, and you’ll see -that the borrow checker approves of this code; it will compile and print `The -longest string is long string is long`. - -Next, let’s try an example that shows that the lifetime of the reference in -`result` must be the smaller lifetime of the two arguments. We’ll move the -declaration of the `result` variable outside the inner scope but leave the -assignment of the value to the `result` variable inside the scope with -`string2`. Then we’ll move the `println!` that uses `result` outside the inner -scope, after the inner scope has ended. The code in Listing 10-24 will not -compile. - -Filename: src/main.rs - -```rust,ignore -fn main() { - let string1 = String::from("long string is long"); - let result; - { - let string2 = String::from("xyz"); - result = longest(string1.as_str(), string2.as_str()); - } - println!("The longest string is {}", result); -} -``` - -Listing 10-24: Attempting to use `result` after `string2` -has gone out of scope - -When we try to compile this code, we’ll get this error: - -```text -error[E0597]: `string2` does not live long enough - --> src/main.rs:15:5 - | -14 | result = longest(string1.as_str(), string2.as_str()); - | ------- borrow occurs here -15 | } - | ^ `string2` dropped here while still borrowed -16 | println!("The longest string is {}", result); -17 | } - | - borrowed value needs to live until here -``` - -The error shows that for `result` to be valid for the `println!` statement, -`string2` would need to be valid until the end of the outer scope. Rust knows -this because we annotated the lifetimes of the function parameters and return -values using the same lifetime parameter `'a`. - -As humans, we can look at this code and see that `string1` is longer than -`string2` and therefore `result` will contain a reference to `string1`. -Because `string1` has not gone out of scope yet, a reference to `string1` will -still be valid for the `println!` statement. However, the compiler can’t see -that the reference is valid in this case. We’ve told Rust that the lifetime of -the reference returned by the `longest` function is the same as the smaller of -the lifetimes of the references passed in. Therefore, the borrow checker -disallows the code in Listing 10-24 as possibly having an invalid reference. - -Try designing more experiments that vary the values and lifetimes of the -references passed in to the `longest` function and how the returned reference -is used. Make hypotheses about whether or not your experiments will pass the -borrow checker before you compile; then check to see if you’re right! - -### Thinking in Terms of Lifetimes - -The way in which you need to specify lifetime parameters depends on what your -function is doing. For example, if we changed the implementation of the -`longest` function to always return the first parameter rather than the longest -string slice, we wouldn’t need to specify a lifetime on the `y` parameter. The -following code will compile: - -Filename: src/main.rs - -```rust -fn longest<'a>(x: &'a str, y: &str) -> &'a str { - x -} -``` - -In this example, we’ve specified a lifetime parameter `'a` for the parameter -`x` and the return type, but not for the parameter `y`, because the lifetime of -`y` does not have any relationship with the lifetime of `x` or the return value. - -When returning a reference from a function, the lifetime parameter for the -return type needs to match the lifetime parameter for one of the parameters. If -the reference returned does *not* refer to one of the parameters, it must refer -to a value created within this function, which would be a dangling reference -because the value will go out of scope at the end of the function. Consider -this attempted implementation of the `longest` function that won’t compile: - -Filename: src/main.rs - -```rust,ignore -fn longest<'a>(x: &str, y: &str) -> &'a str { - let result = String::from("really long string"); - result.as_str() -} -``` - -Here, even though we’ve specified a lifetime parameter `'a` for the return -type, this implementation will fail to compile because the return value -lifetime is not related to the lifetime of the parameters at all. Here is the -error message we get: - -```text -error[E0597]: `result` does not live long enough - --> src/main.rs:3:5 - | -3 | result.as_str() - | ^^^^^^ does not live long enough -4 | } - | - borrowed value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the -function body at 1:1... - --> src/main.rs:1:1 - | -1 | / fn longest<'a>(x: &str, y: &str) -> &'a str { -2 | | let result = String::from("really long string"); -3 | | result.as_str() -4 | | } - | |_^ -``` - -The problem is that `result` goes out of scope and gets cleaned up at the end -of the `longest` function. We’re also trying to return a reference to `result` -from the function. There is no way we can specify lifetime parameters that -would change the dangling reference, and Rust won’t let us create a dangling -reference. In this case, the best fix would be to return an owned data type -rather than a reference so the calling function is then responsible for -cleaning up the value. - -Ultimately, lifetime syntax is about connecting the lifetimes of various -parameters and return values of functions. Once they’re connected, Rust has -enough information to allow memory-safe operations and disallow operations that -would create dangling pointers or otherwise violate memory safety. - -### Lifetime Annotations in Struct Definitions - -So far, we’ve only defined structs to hold owned types. It’s possible for -structs to hold references, but in that case we would need to add a lifetime -annotation on every reference in the struct’s definition. Listing 10-25 has a -struct named `ImportantExcerpt` that holds a string slice. - -Filename: src/main.rs - -```rust -struct ImportantExcerpt<'a> { - part: &'a str, -} - -fn main() { - let novel = String::from("Call me Ishmael. Some years ago..."); - let first_sentence = novel.split('.') - .next() - .expect("Could not find a '.'"); - let i = ImportantExcerpt { part: first_sentence }; -} -``` - -Listing 10-25: A struct that holds a reference, so its -definition needs a lifetime annotation - -This struct has one field, `part`, that holds a string slice, which is a -reference. As with generic data types, we declare the name of the generic -lifetime parameter inside angle brackets after the name of the struct so we can -use the lifetime parameter in the body of the struct definition. This -annotation means an instance of `ImportantExcerpt` can’t outlive the reference -it holds in its `part` field. - -The `main` function here creates an instance of the `ImportantExcerpt` struct -that holds a reference to the first sentence of the `String` owned by the -variable `novel`. The data in `novel` exists before the `ImportantExcerpt` -instance is created. In addition, `novel` doesn’t go out of scope until after -the `ImportantExcerpt` goes out of scope, so the reference in the -`ImportantExcerpt` instance is valid. - -### Lifetime Elision - -You’ve learned that every reference has a lifetime and that you need to specify -lifetime parameters for functions or structs that use references. However, in -Chapter 4 we had a function in Listing 4-9, which is shown again in Listing -10-26, that compiled without lifetime annotations. - -Filename: src/lib.rs - -```rust -fn first_word(s: &str) -> &str { - let bytes = s.as_bytes(); - - for (i, &item) in bytes.iter().enumerate() { - if item == b' ' { - return &s[0..i]; - } - } - - &s[..] -} -``` - -Listing 10-26: A function we defined in Listing 4-9 that -compiled without lifetime annotations, even though the parameter and return -type are references - -The reason this function compiles without lifetime annotations is historical: -in early versions (pre-1.0) of Rust, this code wouldn’t have compiled because -every reference needed an explicit lifetime. At that time, the function -signature would have been written like this: - -```rust,ignore -fn first_word<'a>(s: &'a str) -> &'a str { -``` - -After writing a lot of Rust code, the Rust team found that Rust programmers -were entering the same lifetime annotations over and over in particular -situations. These situations were predictable and followed a few deterministic -patterns. The developers programmed these patterns into the compiler’s code so -the borrow checker could infer the lifetimes in these situations and wouldn’t -need explicit annotations. - -This piece of Rust history is relevant because it’s possible that more -deterministic patterns will emerge and be added to the compiler. In the future, -even fewer lifetime annotations might be required. - -The patterns programmed into Rust’s analysis of references are called the -*lifetime elision rules*. These aren’t rules for programmers to follow; they’re -a set of particular cases that the compiler will consider, and if your code -fits these cases, you don’t need to write the lifetimes explicitly. - -The elision rules don’t provide full inference. If Rust deterministically -applies the rules but there is still ambiguity as to what lifetimes the -references have, the compiler won’t guess what the lifetime of the remaining -references should be. In this case, instead of guessing, the compiler will give -you an error that you can resolve by adding the lifetime annotations that -specify how the references relate to each other. - -Lifetimes on function or method parameters are called *input lifetimes*, and -lifetimes on return values are called *output lifetimes*. - -The compiler uses three rules to figure out what lifetimes references have when -there aren’t explicit annotations. The first rule applies to input lifetimes, -and the second and third rules apply to output lifetimes. If the compiler gets -to the end of the three rules and there are still references for which it can’t -figure out lifetimes, the compiler will stop with an error. - -The first rule is that each parameter that is a reference gets its own lifetime -parameter. In other words, a function with one parameter gets one lifetime -parameter: `fn foo<'a>(x: &'a i32)`; a function with two parameters gets two -separate lifetime parameters: `fn foo<'a, 'b>(x: &'a i32, y: &'b i32)`; and so -on. - -The second rule is if there is exactly one input lifetime parameter, that -lifetime is assigned to all output lifetime parameters: `fn foo<'a>(x: &'a i32) --> &'a i32`. - -The third rule is if there are multiple input lifetime parameters, but one of -them is `&self` or `&mut self` because this is a method, the lifetime of `self` -is assigned to all output lifetime parameters. This third rule makes methods -much nicer to read and write because fewer symbols are necessary. - -Let’s pretend we’re the compiler. We’ll apply these rules to figure out what -the lifetimes of the references in the signature of the `first_word` function -in Listing 10-26 are. The signature starts without any lifetimes associated -with the references: - -```rust,ignore -fn first_word(s: &str) -> &str { -``` - -Then the compiler applies the first rule, which specifies that each parameter -gets its own lifetime. We’ll call it `'a` as usual, so now the signature is -this: - -```rust,ignore -fn first_word<'a>(s: &'a str) -> &str { -``` - -The second rule applies because there is exactly one input lifetime. The second -rule specifies that the lifetime of the one input parameter gets assigned to -the output lifetime, so the signature is now this: - -```rust,ignore -fn first_word<'a>(s: &'a str) -> &'a str { -``` - -Now all the references in this function signature have lifetimes, and the -compiler can continue its analysis without needing the programmer to annotate -the lifetimes in this function signature. - -Let’s look at another example, this time using the `longest` function that had -no lifetime parameters when we started working with it in Listing 10-21: - -```rust,ignore -fn longest(x: &str, y: &str) -> &str { -``` - -Let’s apply the first rule: each parameter gets its own lifetime. This time we -have two parameters instead of one, so we have two lifetimes: - -```rust,ignore -fn longest<'a, 'b>(x: &'a str, y: &'b str) -> &str { -``` - -You can see that the second rule doesn’t apply because there is more than one -input lifetime. The third rule doesn’t apply either, because `longest` is a -function rather than a method, so none of the parameters are `self`. After -working through all three rules, we still haven’t figured out what the return -type’s lifetime is. This is why we got an error trying to compile the code in -Listing 10-21: the compiler worked through the lifetime elision rules but still -couldn’t figure out all the lifetimes of the references in the signature. - -Because the third rule really only applies in method signatures, we’ll look at -lifetimes in that context next to see why the third rule means we don’t have to -annotate lifetimes in method signatures very often. - -### Lifetime Annotations in Method Definitions - -When we implement methods on a struct with lifetimes, we use the same syntax as -that of generic type parameters shown in Listing 10-11. Where we declare and -use the lifetime parameters depends on whether they’re related to the struct -fields or the method parameters and return values. - -Lifetime names for struct fields always need to be declared after the `impl` -keyword and then used after the struct’s name, because those lifetimes are part -of the struct’s type. - -In method signatures inside the `impl` block, references might be tied to the -lifetime of references in the struct’s fields, or they might be independent. In -addition, the lifetime elision rules often make it so that lifetime annotations -aren’t necessary in method signatures. Let’s look at some examples using the -struct named `ImportantExcerpt` that we defined in Listing 10-25. - -First, we’ll use a method named `level` whose only parameter is a reference to -`self` and whose return value is an `i32`, which is not a reference to anything: - -```rust -# struct ImportantExcerpt<'a> { -# part: &'a str, -# } -# -impl<'a> ImportantExcerpt<'a> { - fn level(&self) -> i32 { - 3 - } -} -``` - -The lifetime parameter declaration after `impl` and use after the type name is -required, but we’re not required to annotate the lifetime of the reference to -`self` because of the first elision rule. - -Here is an example where the third lifetime elision rule applies: - -```rust -# struct ImportantExcerpt<'a> { -# part: &'a str, -# } -# -impl<'a> ImportantExcerpt<'a> { - fn announce_and_return_part(&self, announcement: &str) -> &str { - println!("Attention please: {}", announcement); - self.part - } -} -``` - -There are two input lifetimes, so Rust applies the first lifetime elision rule -and gives both `&self` and `announcement` their own lifetimes. Then, because -one of the parameters is `&self`, the return type gets the lifetime of `&self`, -and all lifetimes have been accounted for. - -### The Static Lifetime - -One special lifetime we need to discuss is `'static`, which denotes the entire -duration of the program. All string literals have the `'static` lifetime, which -we can annotate as follows: - -```rust -let s: &'static str = "I have a static lifetime."; -``` - -The text of this string is stored directly in the binary of your program, which -is always available. Therefore, the lifetime of all string literals is -`'static`. - -You might see suggestions to use the `'static` lifetime in error messages. But -before specifying `'static` as the lifetime for a reference, think about -whether the reference you have actually lives the entire lifetime of your -program or not. You might consider whether you want it to live that long, even -if it could. Most of the time, the problem results from attempting to create a -dangling reference or a mismatch of the available lifetimes. In such cases, the -solution is fixing those problems, not specifying the `'static` lifetime. - -## Generic Type Parameters, Trait Bounds, and Lifetimes Together - -Let’s briefly look at the syntax of specifying generic type parameters, trait -bounds, and lifetimes all in one function! - -```rust -use std::fmt::Display; - -fn longest_with_an_announcement<'a, T>(x: &'a str, y: &'a str, ann: T) -> &'a str - where T: Display -{ - println!("Announcement! {}", ann); - if x.len() > y.len() { - x - } else { - y - } -} -``` - -This is the `longest` function from Listing 10-22 that returns the longer of -two string slices. But now it has an extra parameter named `ann` of the generic -type `T`, which can be filled in by any type that implements the `Display` -trait as specified by the `where` clause. This extra parameter will be printed -before the function compares the lengths of the string slices, which is why the -`Display` trait bound is necessary. Because lifetimes are a type of generic, -the declarations of the lifetime parameter `'a` and the generic type parameter -`T` go in the same list inside the angle brackets after the function name. - -## Summary - -We covered a lot in this chapter! Now that you know about generic type -parameters, traits and trait bounds, and generic lifetime parameters, you’re -ready to write code without repetition that works in many different situations. -Generic type parameters let you apply the code to different types. Traits and -trait bounds ensure that even though the types are generic, they’ll have the -behavior the code needs. You learned how to use lifetime annotations to ensure -that this flexible code won’t have any dangling references. And all of this -analysis happens at compile time, which doesn’t affect runtime performance! - -Believe it or not, there is much more to learn on the topics we discussed in -this chapter: Chapter 17 discusses trait objects, which are another way to use -traits. Chapter 19 covers more complex scenarios involving lifetime annotations -as well as some advanced type system features. But next, you’ll learn how to -write tests in Rust so you can make sure your code is working the way it should. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch10-03-lifetime-syntax.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch11-00-testing.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch11-00-testing.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch11-00-testing.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch11-00-testing.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,34 +1,10 @@ # Writing Automated Tests -In his 1972 essay “The Humble Programmer,” Edsger W. Dijkstra said that -“Program testing can be a very effective way to show the presence of bugs, but -it is hopelessly inadequate for showing their absence.” That doesn’t mean we -shouldn’t try to test as much as we can! +The 2018 edition of the book is no longer distributed with Rust's documentation. -Correctness in our programs is the extent to which our code does what we intend -it to do. Rust is designed with a high degree of concern about the correctness -of programs, but correctness is complex and not easy to prove. Rust’s type -system shoulders a huge part of this burden, but the type system cannot catch -every kind of incorrectness. As such, Rust includes support for writing -automated software tests within the language. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -As an example, say we write a function called `add_two` that adds 2 to whatever -number is passed to it. This function’s signature accepts an integer as a -parameter and returns an integer as a result. When we implement and compile -that function, Rust does all the type checking and borrow checking that you’ve -learned so far to ensure that, for instance, we aren’t passing a `String` value -or an invalid reference to this function. But Rust *can’t* check that this -function will do precisely what we intend, which is return the parameter plus 2 -rather than, say, the parameter plus 10 or the parameter minus 50! That’s where -tests come in. - -We can write tests that assert, for example, that when we pass `3` to the -`add_two` function, the returned value is `5`. We can run these tests whenever -we make changes to our code to make sure any existing correct behavior has not -changed. - -Testing is a complex skill: although we can’t cover every detail about how to -write good tests in one chapter, we’ll discuss the mechanics of Rust’s testing -facilities. We’ll talk about the annotations and macros available to you when -writing your tests, the default behavior and options provided for running your -tests, and how to organize tests into unit tests and integration tests. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch11-00-testing.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch11-01-writing-tests.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch11-01-writing-tests.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch11-01-writing-tests.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch11-01-writing-tests.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,832 +1,10 @@ ## How to Write Tests -Tests are Rust functions that verify that the non-test code is functioning in -the expected manner. The bodies of test functions typically perform these three -actions: +The 2018 edition of the book is no longer distributed with Rust's documentation. -1. Set up any needed data or state. -2. Run the code you want to test. -3. Assert the results are what you expect. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -Let’s look at the features Rust provides specifically for writing tests that -take these actions, which include the `test` attribute, a few macros, and the -`should_panic` attribute. - -### The Anatomy of a Test Function - -At its simplest, a test in Rust is a function that’s annotated with the `test` -attribute. Attributes are metadata about pieces of Rust code; one example is -the `derive` attribute we used with structs in Chapter 5. To change a function -into a test function, add `#[test]` on the line before `fn`. When you run your -tests with the `cargo test` command, Rust builds a test runner binary that runs -the functions annotated with the `test` attribute and reports on whether each -test function passes or fails. - -In Chapter 7, we saw that when we make a new library project with Cargo, a test -module with a test function in it is automatically generated for us. This -module helps you start writing your tests so you don’t have to look up the -exact structure and syntax of test functions every time you start a new -project. You can add as many additional test functions and as many test modules -as you want! - -We’ll explore some aspects of how tests work by experimenting with the template -test generated for us without actually testing any code. Then we’ll write some -real-world tests that call some code that we’ve written and assert that its -behavior is correct. - -Let’s create a new library project called `adder`: - -```text -$ cargo new adder --lib - Created library `adder` project -$ cd adder -``` - -The contents of the *src/lib.rs* file in your `adder` library should look like -Listing 11-1: - -Filename: src/lib.rs - -```rust -# fn main() {} -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - assert_eq!(2 + 2, 4); - } -} -``` - -Listing 11-1: The test module and function generated -automatically by `cargo new` - -For now, let’s ignore the top two lines and focus on the function to see how it -works. Note the `#[test]` annotation before the `fn` line: this attribute -indicates this is a test function, so the test runner knows to treat this -function as a test. We could also have non-test functions in the `tests` module -to help set up common scenarios or perform common operations, so we need to -indicate which functions are tests by using the `#[test]` attribute. - -The function body uses the `assert_eq!` macro to assert that 2 + 2 equals 4. -This assertion serves as an example of the format for a typical test. Let’s run -it to see that this test passes. - -The `cargo test` command runs all tests in our project, as shown in Listing -11-2: - -```text -$ cargo test - Compiling adder v0.1.0 (file:///projects/adder) - Finished dev [unoptimized + debuginfo] target(s) in 0.22 secs - Running target/debug/deps/adder-ce99bcc2479f4607 - -running 1 test -test tests::it_works ... ok - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out - - Doc-tests adder - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out -``` - -Listing 11-2: The output from running the automatically -generated test - -Cargo compiled and ran the test. After the `Compiling`, `Finished`, and -`Running` lines is the line `running 1 test`. The next line shows the name -of the generated test function, called `it_works`, and the result of running -that test, `ok`. The overall summary of running the tests appears next. The -text `test result: ok.` means that all the tests passed, and the portion that -reads `1 passed; 0 failed` totals the number of tests that passed or failed. - -Because we don’t have any tests we’ve marked as ignored, the summary shows `0 -ignored`. We also haven’t filtered the tests being run, so the end of the -summary shows `0 filtered out`. We’ll talk about ignoring and filtering out -tests in the next section, “Controlling How Tests Are Run.” - -The `0 measured` statistic is for benchmark tests that measure performance. -Benchmark tests are, as of this writing, only available in nightly Rust. See -[the documentation about benchmark tests][bench] to learn more. - -[bench]: ../../unstable-book/library-features/test.html - -The next part of the test output, which starts with `Doc-tests adder`, is for -the results of any documentation tests. We don’t have any documentation tests -yet, but Rust can compile any code examples that appear in our API -documentation. This feature helps us keep our docs and our code in sync! We’ll -discuss how to write documentation tests in the “Documentation Comments” -section of Chapter 14. For now, we’ll ignore the `Doc-tests` output. - -Let’s change the name of our test to see how that changes the test output. -Change the `it_works` function to a different name, such as `exploration`, like -so: - -Filename: src/lib.rs - -```rust -# fn main() {} -#[cfg(test)] -mod tests { - #[test] - fn exploration() { - assert_eq!(2 + 2, 4); - } -} -``` - -Then run `cargo test` again. The output now shows `exploration` instead of -`it_works`: - -```text -running 1 test -test tests::exploration ... ok - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out -``` - -Let’s add another test, but this time we’ll make a test that fails! Tests fail -when something in the test function panics. Each test is run in a new thread, -and when the main thread sees that a test thread has died, the test is marked -as failed. We talked about the simplest way to cause a panic in Chapter 9, -which is to call the `panic!` macro. Enter the new test, `another`, so your -*src/lib.rs* file looks like Listing 11-3: - -Filename: src/lib.rs - -```rust -# fn main() {} -#[cfg(test)] -mod tests { - #[test] - fn exploration() { - assert_eq!(2 + 2, 4); - } - - #[test] - fn another() { - panic!("Make this test fail"); - } -} -``` - -Listing 11-3: Adding a second test that will fail because -we call the `panic!` macro - -Run the tests again using `cargo test`. The output should look like Listing -11-4, which shows that our `exploration` test passed and `another` failed: - -```text -running 2 tests -test tests::exploration ... ok -test tests::another ... FAILED - -failures: - ----- tests::another stdout ---- - thread 'tests::another' panicked at 'Make this test fail', src/lib.rs:10:8 -note: Run with `RUST_BACKTRACE=1` for a backtrace. - -failures: - tests::another - -test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out - -error: test failed -``` - -Listing 11-4: Test results when one test passes and one -test fails - -Instead of `ok`, the line `test tests::another` shows `FAILED`. Two new -sections appear between the individual results and the summary: the first -section displays the detailed reason for each test failure. In this case, -`another` failed because it `panicked at 'Make this test fail'`, which happened -on line 10 in the *src/lib.rs* file. The next section lists just the names of -all the failing tests, which is useful when there are lots of tests and lots of -detailed failing test output. We can use the name of a failing test to run just -that test to more easily debug it; we’ll talk more about ways to run tests in -the “Controlling How Tests Are Run” section. - -The summary line displays at the end: overall, our test result is `FAILED`. -We had one test pass and one test fail. - -Now that you’ve seen what the test results look like in different scenarios, -let’s look at some macros other than `panic!` that are useful in tests. - -### Checking Results with the `assert!` Macro - -The `assert!` macro, provided by the standard library, is useful when you want -to ensure that some condition in a test evaluates to `true`. We give the -`assert!` macro an argument that evaluates to a Boolean. If the value is -`true`, `assert!` does nothing and the test passes. If the value is `false`, -the `assert!` macro calls the `panic!` macro, which causes the test to fail. -Using the `assert!` macro helps us check that our code is functioning in the -way we intend. - -In Chapter 5, Listing 5-15, we used a `Rectangle` struct and a `can_hold` -method, which are repeated here in Listing 11-5. Let’s put this code in the -*src/lib.rs* file and write some tests for it using the `assert!` macro. - -Filename: src/lib.rs - -```rust -# fn main() {} -#[derive(Debug)] -pub struct Rectangle { - length: u32, - width: u32, -} - -impl Rectangle { - pub fn can_hold(&self, other: &Rectangle) -> bool { - self.length > other.length && self.width > other.width - } -} -``` - -Listing 11-5: Using the `Rectangle` struct and its -`can_hold` method from Chapter 5 - -The `can_hold` method returns a Boolean, which means it’s a perfect use case -for the `assert!` macro. In Listing 11-6, we write a test that exercises the -`can_hold` method by creating a `Rectangle` instance that has a length of 8 and -a width of 7 and asserting that it can hold another `Rectangle` instance that -has a length of 5 and a width of 1: - -Filename: src/lib.rs - -```rust -# fn main() {} -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn larger_can_hold_smaller() { - let larger = Rectangle { length: 8, width: 7 }; - let smaller = Rectangle { length: 5, width: 1 }; - - assert!(larger.can_hold(&smaller)); - } -} -``` - -Listing 11-6: A test for `can_hold` that checks whether a -larger rectangle can indeed hold a smaller rectangle - -Note that we’ve added a new line inside the `tests` module: `use super::*;`. -The `tests` module is a regular module that follows the usual visibility rules -we covered in Chapter 7 in the “Privacy Rules” section. Because the `tests` -module is an inner module, we need to bring the code under test in the outer -module into the scope of the inner module. We use a glob here so anything we -define in the outer module is available to this `tests` module. - -We’ve named our test `larger_can_hold_smaller`, and we’ve created the two -`Rectangle` instances that we need. Then we called the `assert!` macro and -passed it the result of calling `larger.can_hold(&smaller)`. This expression -is supposed to return `true`, so our test should pass. Let’s find out! - -```text -running 1 test -test tests::larger_can_hold_smaller ... ok - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out -``` - -It does pass! Let’s add another test, this time asserting that a smaller -rectangle cannot hold a larger rectangle: - -Filename: src/lib.rs - -```rust -# fn main() {} -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn larger_can_hold_smaller() { - // --snip-- - } - - #[test] - fn smaller_cannot_hold_larger() { - let larger = Rectangle { length: 8, width: 7 }; - let smaller = Rectangle { length: 5, width: 1 }; - - assert!(!smaller.can_hold(&larger)); - } -} -``` - -Because the correct result of the `can_hold` function in this case is `false`, -we need to negate that result before we pass it to the `assert!` macro. As a -result, our test will pass if `can_hold` returns `false`: - -```text -running 2 tests -test tests::smaller_cannot_hold_larger ... ok -test tests::larger_can_hold_smaller ... ok - -test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out -``` - -Two tests that pass! Now let’s see what happens to our test results when we -introduce a bug in our code. Let’s change the implementation of the `can_hold` -method by replacing the greater-than sign with a less-than sign when it -compares the lengths: - -```rust -# fn main() {} -# #[derive(Debug)] -# pub struct Rectangle { -# length: u32, -# width: u32, -# } -// --snip-- - -impl Rectangle { - pub fn can_hold(&self, other: &Rectangle) -> bool { - self.length < other.length && self.width > other.width - } -} -``` - -Running the tests now produces the following: - -```text -running 2 tests -test tests::smaller_cannot_hold_larger ... ok -test tests::larger_can_hold_smaller ... FAILED - -failures: - ----- tests::larger_can_hold_smaller stdout ---- - thread 'tests::larger_can_hold_smaller' panicked at 'assertion failed: - larger.can_hold(&smaller)', src/lib.rs:22:8 -note: Run with `RUST_BACKTRACE=1` for a backtrace. - -failures: - tests::larger_can_hold_smaller - -test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out -``` - -Our tests caught the bug! Because `larger.length` is 8 and `smaller.length` is -5, the comparison of the lengths in `can_hold` now returns `false`: 8 is not -less than 5. - -### Testing Equality with the `assert_eq!` and `assert_ne!` Macros - -A common way to test functionality is to compare the result of the code under -test to the value you expect the code to return to make sure they’re equal. You -could do this using the `assert!` macro and passing it an expression using the -`==` operator. However, this is such a common test that the standard library -provides a pair of macros—`assert_eq!` and `assert_ne!`—to perform this test -more conveniently. These macros compare two arguments for equality or -inequality, respectively. They’ll also print the two values if the assertion -fails, which makes it easier to see *why* the test failed; conversely, the -`assert!` macro only indicates that it got a `false` value for the `==` -expression, not the values that lead to the `false` value. - -In Listing 11-7, we write a function named `add_two` that adds `2` to its -parameter and returns the result. Then we test this function using the -`assert_eq!` macro. - -Filename: src/lib.rs - -```rust -# fn main() {} -pub fn add_two(a: i32) -> i32 { - a + 2 -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn it_adds_two() { - assert_eq!(4, add_two(2)); - } -} -``` - -Listing 11-7: Testing the function `add_two` using the -`assert_eq!` macro - -Let’s check that it passes! - -```text -running 1 test -test tests::it_adds_two ... ok - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out -``` - -The first argument we gave to the `assert_eq!` macro, `4`, is equal to the -result of calling `add_two(2)`. The line for this test is `test -tests::it_adds_two ... ok`, and the `ok` text indicates that our test passed! - -Let’s introduce a bug into our code to see what it looks like when a test that -uses `assert_eq!` fails. Change the implementation of the `add_two` function to -instead add `3`: - -```rust -# fn main() {} -pub fn add_two(a: i32) -> i32 { - a + 3 -} -``` - -Run the tests again: - -```text -running 1 test -test tests::it_adds_two ... FAILED - -failures: - ----- tests::it_adds_two stdout ---- - thread 'tests::it_adds_two' panicked at 'assertion failed: `(left == right)` - left: `4`, - right: `5`', src/lib.rs:11:8 -note: Run with `RUST_BACKTRACE=1` for a backtrace. - -failures: - tests::it_adds_two - -test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out -``` - -Our test caught the bug! The `it_adds_two` test failed, displaying the message -`` assertion failed: `(left == right)` `` and showing that `left` was `4` and -`right` was `5`. This message is useful and helps us start debugging: it means -the `left` argument to `assert_eq!` was `4` but the `right` argument, where we -had `add_two(2)`, was `5`. - -Note that in some languages and test frameworks, the parameters to the -functions that assert two values are equal are called `expected` and `actual`, -and the order in which we specify the arguments matters. However, in Rust, -they’re called `left` and `right`, and the order in which we specify the value -we expect and the value that the code under test produces doesn’t matter. We -could write the assertion in this test as `assert_eq!(add_two(2), 4)`, which -would result in a failure message that displays `` assertion failed: `(left == -right)` `` and that `left` was `5` and `right` was `4`. - -The `assert_ne!` macro will pass if the two values we give it are not equal and -fail if they’re equal. This macro is most useful for cases when we’re not sure -what a value *will* be, but we know what the value definitely *won’t* be if our -code is functioning as we intend. For example, if we’re testing a function that -is guaranteed to change its input in some way, but the way in which the input -is changed depends on the day of the week that we run our tests, the best thing -to assert might be that the output of the function is not equal to the input. - -Under the surface, the `assert_eq!` and `assert_ne!` macros use the operators -`==` and `!=`, respectively. When the assertions fail, these macros print their -arguments using debug formatting, which means the values being compared must -implement the `PartialEq` and `Debug` traits. All the primitive types and most -of the standard library types implement these traits. For structs and enums -that you define, you’ll need to implement `PartialEq` to assert that values of -those types are equal or not equal. You’ll need to implement `Debug` to print -the values when the assertion fails. Because both traits are derivable traits, -as mentioned in Listing 5-12 in Chapter 5, this is usually as straightforward -as adding the `#[derive(PartialEq, Debug)]` annotation to your struct or enum -definition. See Appendix C, “Derivable Traits,” for more details about these -and other derivable traits. - -### Adding Custom Failure Messages - -You can also add a custom message to be printed with the failure message as -optional arguments to the `assert!`, `assert_eq!`, and `assert_ne!` macros. Any -arguments specified after the one required argument to `assert!` or the two -required arguments to `assert_eq!` and `assert_ne!` are passed along to the -`format!` macro (discussed in Chapter 8 in the “Concatenation with the `+` -Operator or the `format!` Macro” section), so you can pass a format string that -contains `{}` placeholders and values to go in those placeholders. Custom -messages are useful to document what an assertion means; when a test fails, -you’ll have a better idea of what the problem is with the code. - -For example, let’s say we have a function that greets people by name and we -want to test that the name we pass into the function appears in the output: - -Filename: src/lib.rs - -```rust -# fn main() {} -pub fn greeting(name: &str) -> String { - format!("Hello {}!", name) -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn greeting_contains_name() { - let result = greeting("Carol"); - assert!(result.contains("Carol")); - } -} -``` - -The requirements for this program haven’t been agreed upon yet, and we’re -pretty sure the `Hello` text at the beginning of the greeting will change. We -decided we don’t want to have to update the test when the requirements change, -so instead of checking for exact equality to the value returned from the -`greeting` function, we’ll just assert that the output contains the text of the -input parameter. - -Let’s introduce a bug into this code by changing `greeting` to not include -`name` to see what this test failure looks like: - -```rust -# fn main() {} -pub fn greeting(name: &str) -> String { - String::from("Hello!") -} -``` - -Running this test produces the following: - -```text -running 1 test -test tests::greeting_contains_name ... FAILED - -failures: - ----- tests::greeting_contains_name stdout ---- - thread 'tests::greeting_contains_name' panicked at 'assertion failed: -result.contains("Carol")', src/lib.rs:12:8 -note: Run with `RUST_BACKTRACE=1` for a backtrace. - -failures: - tests::greeting_contains_name -``` - -This result just indicates that the assertion failed and which line the -assertion is on. A more useful failure message in this case would print the -value we got from the `greeting` function. Let’s change the test function, -giving it a custom failure message made from a format string with a placeholder -filled in with the actual value we got from the `greeting` function: - -```rust,ignore -#[test] -fn greeting_contains_name() { - let result = greeting("Carol"); - assert!( - result.contains("Carol"), - "Greeting did not contain name, value was `{}`", result - ); -} -``` - -Now when we run the test, we’ll get a more informative error message: - -```text ----- tests::greeting_contains_name stdout ---- - thread 'tests::greeting_contains_name' panicked at 'Greeting did not -contain name, value was `Hello!`', src/lib.rs:12:8 -note: Run with `RUST_BACKTRACE=1` for a backtrace. -``` - -We can see the value we actually got in the test output, which would help us -debug what happened instead of what we were expecting to happen. - -### Checking for Panics with `should_panic` - -In addition to checking that our code returns the correct values we expect, -it’s also important to check that our code handles error conditions as we -expect. For example, consider the `Guess` type that we created in Chapter 9, -Listing 9-9. Other code that uses `Guess` depends on the guarantee that `Guess` -instances will contain only values between 1 and 100. We can write a test that -ensures that attempting to create a `Guess` instance with a value outside that -range panics. - -We do this by adding another attribute, `should_panic`, to our test function. -This attribute makes a test pass if the code inside the function panics; the -test will fail if the code inside the function doesn’t panic. - -Listing 11-8 shows a test that checks that the error conditions of `Guess::new` -happen when we expect them to: - -Filename: src/lib.rs - -```rust -# fn main() {} -pub struct Guess { - value: i32, -} - -impl Guess { - pub fn new(value: i32) -> Guess { - if value < 1 || value > 100 { - panic!("Guess value must be between 1 and 100, got {}.", value); - } - - Guess { - value - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - #[should_panic] - fn greater_than_100() { - Guess::new(200); - } -} -``` - -Listing 11-8: Testing that a condition will cause a -`panic!` - -We place the `#[should_panic]` attribute after the `#[test]` attribute and -before the test function it applies to. Let’s look at the result when this test -passes: - -```text -running 1 test -test tests::greater_than_100 ... ok - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out -``` - -Looks good! Now let’s introduce a bug in our code by removing the condition -that the `new` function will panic if the value is greater than 100: - -```rust -# fn main() {} -# pub struct Guess { -# value: i32, -# } -# -// --snip-- - -impl Guess { - pub fn new(value: i32) -> Guess { - if value < 1 { - panic!("Guess value must be between 1 and 100, got {}.", value); - } - - Guess { - value - } - } -} -``` - -When we run the test in Listing 11-8, it will fail: - -```text -running 1 test -test tests::greater_than_100 ... FAILED - -failures: - -failures: - tests::greater_than_100 - -test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out -``` - -We don’t get a very helpful message in this case, but when we look at the test -function, we see that it’s annotated with `#[should_panic]`. The failure we got -means that the code in the test function did not cause a panic. - -Tests that use `should_panic` can be imprecise because they only indicate that -the code has caused some panic. A `should_panic` test would pass even if the -test panics for a different reason than the one we were expecting to happen. To -make `should_panic` tests more precise, we can add an optional `expected` -parameter to the `should_panic` attribute. The test harness will make sure that -the failure message contains the provided text. For example, consider the -modified code for `Guess` in Listing 11-9 where the `new` function panics with -different messages depending on whether the value is too small or too large: - -Filename: src/lib.rs - -```rust -# fn main() {} -# pub struct Guess { -# value: i32, -# } -# -// --snip-- - -impl Guess { - pub fn new(value: i32) -> Guess { - if value < 1 { - panic!("Guess value must be greater than or equal to 1, got {}.", - value); - } else if value > 100 { - panic!("Guess value must be less than or equal to 100, got {}.", - value); - } - - Guess { - value - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - #[should_panic(expected = "Guess value must be less than or equal to 100")] - fn greater_than_100() { - Guess::new(200); - } -} -``` - -Listing 11-9: Testing that a condition will cause a -`panic!` with a particular panic message - -This test will pass because the value we put in the `should_panic` attribute’s -`expected` parameter is a substring of the message that the `Guess::new` -function panics with. We could have specified the entire panic message that we -expect, which in this case would be `Guess value must be less than or equal to -100, got 200.` What you choose to specify in the expected parameter for -`should_panic` depends on how much of the panic message is unique or dynamic -and how precise you want your test to be. In this case, a substring of the -panic message is enough to ensure that the code in the test function executes -the `else if value > 100` case. - -To see what happens when a `should_panic` test with an `expected` message -fails, let’s again introduce a bug into our code by swapping the bodies of the -`if value < 1` and the `else if value > 100` blocks: - -```rust,ignore -if value < 1 { - panic!("Guess value must be less than or equal to 100, got {}.", value); -} else if value > 100 { - panic!("Guess value must be greater than or equal to 1, got {}.", value); -} -``` - -This time when we run the `should_panic` test, it will fail: - -```text -running 1 test -test tests::greater_than_100 ... FAILED - -failures: - ----- tests::greater_than_100 stdout ---- - thread 'tests::greater_than_100' panicked at 'Guess value must be -greater than or equal to 1, got 200.', src/lib.rs:11:12 -note: Run with `RUST_BACKTRACE=1` for a backtrace. -note: Panic did not include expected string 'Guess value must be less than or -equal to 100' - -failures: - tests::greater_than_100 - -test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out -``` - -The failure message indicates that this test did indeed panic as we expected, -but the panic message did not include the expected string `'Guess value must be -less than or equal to 100'`. The panic message that we did get in this case was -`Guess value must be greater than or equal to 1, got 200.` Now we can start -figuring out where our bug is! - -### Using `Result` in tests - -So far, we've written tests that panic when they fail. We can also write tests -that use `Result` too! Here's that first example, but with results instead: - -```rust -#[cfg(test)] -mod tests { - #[test] - fn it_works() -> Result<(), String> { - if 2 + 2 == 4 { - Ok(()) - } else { - Err(String::from("two plus two does not equal four")) - } - } -} -``` - -Here, we've changed the `it_works` function to return a result. And in the body, -rather than `assert_eq!`, we return `Ok(())` for the success case, and an `Err` -with a `String` inside for the failure case. As before, this test will fail or -succeed, but instead of being based on panics, it will use the `Result` to -make that determination. Because of this, you can't use `#[should_panic]` with one -of these functions; you should have it be returning an `Err` instead! - -Now that you know several ways to write tests, let’s look at what is happening -when we run our tests and explore the different options we can use with `cargo -test`. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch11-01-writing-tests.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch11-02-running-tests.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch11-02-running-tests.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch11-02-running-tests.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch11-02-running-tests.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,306 +1,10 @@ ## Controlling How Tests Are Run -Just as `cargo run` compiles your code and then runs the resulting binary, -`cargo test` compiles your code in test mode and runs the resulting test -binary. You can specify command line options to change the default behavior of -`cargo test`. For example, the default behavior of the binary produced by -`cargo test` is to run all the tests in parallel and capture output generated -during test runs, preventing the output from being displayed and making it -easier to read the output related to the test results. +The 2018 edition of the book is no longer distributed with Rust's documentation. -Some command line options go to `cargo test`, and some go to the resulting test -binary. To separate these two types of arguments, you list the arguments that -go to `cargo test` followed by the separator `--` and then the ones that go to -the test binary. Running `cargo test --help` displays the options you can use -with `cargo test`, and running `cargo test -- --help` displays the options you -can use after the separator `--`. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -### Running Tests in Parallel or Consecutively - -When you run multiple tests, by default they run in parallel using threads. -This means the tests will finish running faster so you can get feedback quicker -on whether or not your code is working. Because the tests are running at the -same time, make sure your tests don’t depend on each other or on any shared -state, including a shared environment, such as the current working directory or -environment variables. - -For example, say each of your tests runs some code that creates a file on disk -named *test-output.txt* and writes some data to that file. Then each test reads -the data in that file and asserts that the file contains a particular value, -which is different in each test. Because the tests run at the same time, one -test might overwrite the file between when another test writes and reads the -file. The second test will then fail, not because the code is incorrect but -because the tests have interfered with each other while running in parallel. -One solution is to make sure each test writes to a different file; another -solution is to run the tests one at a time. - -If you don’t want to run the tests in parallel or if you want more fine-grained -control over the number of threads used, you can send the `--test-threads` flag -and the number of threads you want to use to the test binary. Take a look at -the following example: - -```text -$ cargo test -- --test-threads=1 -``` - -We set the number of test threads to `1`, telling the program not to use any -parallelism. Running the tests using one thread will take longer than running -them in parallel, but the tests won’t interfere with each other if they share -state. - -### Showing Function Output - -By default, if a test passes, Rust’s test library captures anything printed to -standard output. For example, if we call `println!` in a test and the test -passes, we won’t see the `println!` output in the terminal; we’ll see only the -line that indicates the test passed. If a test fails, we’ll see whatever was -printed to standard output with the rest of the failure message. - -As an example, Listing 11-10 has a silly function that prints the value of its -parameter and returns 10, as well as a test that passes and a test that fails. - -Filename: src/lib.rs - -```rust -fn prints_and_returns_10(a: i32) -> i32 { - println!("I got the value {}", a); - 10 -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn this_test_will_pass() { - let value = prints_and_returns_10(4); - assert_eq!(10, value); - } - - #[test] - fn this_test_will_fail() { - let value = prints_and_returns_10(8); - assert_eq!(5, value); - } -} -``` - -Listing 11-10: Tests for a function that calls -`println!` - -When we run these tests with `cargo test`, we’ll see the following output: - -```text -running 2 tests -test tests::this_test_will_pass ... ok -test tests::this_test_will_fail ... FAILED - -failures: - ----- tests::this_test_will_fail stdout ---- - I got the value 8 -thread 'tests::this_test_will_fail' panicked at 'assertion failed: `(left == right)` - left: `5`, - right: `10`', src/lib.rs:19:8 -note: Run with `RUST_BACKTRACE=1` for a backtrace. - -failures: - tests::this_test_will_fail - -test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out -``` - -Note that nowhere in this output do we see `I got the value 4`, which is what -is printed when the test that passes runs. That output has been captured. The -output from the test that failed, `I got the value 8`, appears in the section -of the test summary output, which also shows the cause of the test failure. - -If we want to see printed values for passing tests as well, we can disable the -output capture behavior by using the `--nocapture` flag: - -```text -$ cargo test -- --nocapture -``` - -When we run the tests in Listing 11-10 again with the `--nocapture` flag, we -see the following output: - -```text -running 2 tests -I got the value 4 -I got the value 8 -test tests::this_test_will_pass ... ok -thread 'tests::this_test_will_fail' panicked at 'assertion failed: `(left == right)` - left: `5`, - right: `10`', src/lib.rs:19:8 -note: Run with `RUST_BACKTRACE=1` for a backtrace. -test tests::this_test_will_fail ... FAILED - -failures: - -failures: - tests::this_test_will_fail - -test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out -``` - -Note that the output for the tests and the test results are interleaved; the -reason is that the tests are running in parallel, as we talked about in the -previous section. Try using the `--test-threads=1` option and the `--nocapture` -flag, and see what the output looks like then! - -### Running a Subset of Tests by Name - -Sometimes, running a full test suite can take a long time. If you’re working on -code in a particular area, you might want to run only the tests pertaining to -that code. You can choose which tests to run by passing `cargo test` the name -or names of the test(s) you want to run as an argument. - -To demonstrate how to run a subset of tests, we’ll create three tests for our -`add_two` function, as shown in Listing 11-11, and choose which ones to run: - -Filename: src/lib.rs - -```rust -pub fn add_two(a: i32) -> i32 { - a + 2 -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn add_two_and_two() { - assert_eq!(4, add_two(2)); - } - - #[test] - fn add_three_and_two() { - assert_eq!(5, add_two(3)); - } - - #[test] - fn one_hundred() { - assert_eq!(102, add_two(100)); - } -} -``` - -Listing 11-11: Three tests with three different -names - -If we run the tests without passing any arguments, as we saw earlier, all the -tests will run in parallel: - -```text -running 3 tests -test tests::add_two_and_two ... ok -test tests::add_three_and_two ... ok -test tests::one_hundred ... ok - -test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out -``` - -#### Running Single Tests - -We can pass the name of any test function to `cargo test` to run only that test: - -```text -$ cargo test one_hundred - Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs - Running target/debug/deps/adder-06a75b4a1f2515e9 - -running 1 test -test tests::one_hundred ... ok - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 2 filtered out -``` - -Only the test with the name `one_hundred` ran; the other two tests didn’t match -that name. The test output lets us know we had more tests than what this -command ran by displaying `2 filtered out` at the end of the summary line. - -We can’t specify the names of multiple tests in this way; only the first value -given to `cargo test` will be used. But there is a way to run multiple tests. - -#### Filtering to Run Multiple Tests - -We can specify part of a test name, and any test whose name matches that value -will be run. For example, because two of our tests’ names contain `add`, we can -run those two by running `cargo test add`: - -```text -$ cargo test add - Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs - Running target/debug/deps/adder-06a75b4a1f2515e9 - -running 2 tests -test tests::add_two_and_two ... ok -test tests::add_three_and_two ... ok - -test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out -``` - -This command ran all tests with `add` in the name and filtered out the test -named `one_hundred`. Also note that the module in which tests appear becomes -part of the test’s name, so we can run all the tests in a module by filtering -on the module’s name. - -### Ignoring Some Tests Unless Specifically Requested - -Sometimes a few specific tests can be very time-consuming to execute, so you -might want to exclude them during most runs of `cargo test`. Rather than -listing as arguments all tests you do want to run, you can instead annotate the -time-consuming tests using the `ignore` attribute to exclude them, as shown -here: - -Filename: src/lib.rs - -```rust -#[test] -fn it_works() { - assert_eq!(2 + 2, 4); -} - -#[test] -#[ignore] -fn expensive_test() { - // code that takes an hour to run -} -``` - -After `#[test]` we add the `#[ignore]` line to the test we want to exclude. Now -when we run our tests, `it_works` runs, but `expensive_test` doesn’t: - -```text -$ cargo test - Compiling adder v0.1.0 (file:///projects/adder) - Finished dev [unoptimized + debuginfo] target(s) in 0.24 secs - Running target/debug/deps/adder-ce99bcc2479f4607 - -running 2 tests -test expensive_test ... ignored -test it_works ... ok - -test result: ok. 1 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out -``` - -The `expensive_test` function is listed as `ignored`. If we want to run only -the ignored tests, we can use `cargo test -- --ignored`: - -```text -$ cargo test -- --ignored - Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs - Running target/debug/deps/adder-ce99bcc2479f4607 - -running 1 test -test expensive_test ... ok - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out -``` - -By controlling which tests run, you can make sure your `cargo test` results -will be fast. When you’re at a point where it makes sense to check the results -of the `ignored` tests and you have time to wait for the results, you can run -`cargo test -- --ignored` instead. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch11-02-running-tests.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch11-03-test-organization.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch11-03-test-organization.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch11-03-test-organization.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch11-03-test-organization.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,326 +1,10 @@ ## Test Organization -As mentioned at the start of the chapter, testing is a complex discipline, and -different people use different terminology and organization. The Rust community -thinks about tests in terms of two main categories: *unit tests* and -*integration tests*. Unit tests are small and more focused, testing one module -in isolation at a time, and can test private interfaces. Integration tests are -entirely external to your library and use your code in the same way any other -external code would, using only the public interface and potentially exercising -multiple modules per test. +The 2018 edition of the book is no longer distributed with Rust's documentation. -Writing both kinds of tests is important to ensure that the pieces of your -library are doing what you expect them to separately and together. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -### Unit Tests - -The purpose of unit tests is to test each unit of code in isolation from the -rest of the code to quickly pinpoint where code is and isn’t working as -expected. You’ll put unit tests in the *src* directory in each file with the -code that they’re testing. The convention is to create a module named `tests` -in each file to contain the test functions and to annotate the module with -`cfg(test)`. - -#### The Tests Module and `#[cfg(test)]` - -The `#[cfg(test)]` annotation on the tests module tells Rust to compile and run -the test code only when you run `cargo test`, not when you run `cargo build`. -This saves compile time when you only want to build the library and saves space -in the resulting compiled artifact because the tests are not included. You’ll -see that because integration tests go in a different directory, they don’t need -the `#[cfg(test)]` annotation. However, because unit tests go in the same files -as the code, you’ll use `#[cfg(test)]` to specify that they shouldn’t be -included in the compiled result. - -Recall that when we generated the new `adder` project in the first section of -this chapter, Cargo generated this code for us: - -Filename: src/lib.rs - -```rust -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - assert_eq!(2 + 2, 4); - } -} -``` - -This code is the automatically generated test module. The attribute `cfg` -stands for *configuration* and tells Rust that the following item should only -be included given a certain configuration option. In this case, the -configuration option is `test`, which is provided by Rust for compiling and -running tests. By using the `cfg` attribute, Cargo compiles our test code only -if we actively run the tests with `cargo test`. This includes any helper -functions that might be within this module, in addition to the functions -annotated with `#[test]`. - -#### Testing Private Functions - -There’s debate within the testing community about whether or not private -functions should be tested directly, and other languages make it difficult or -impossible to test private functions. Regardless of which testing ideology you -adhere to, Rust’s privacy rules do allow you to test private functions. -Consider the code in Listing 11-12 with the private function `internal_adder`: - -Filename: src/lib.rs - -```rust -# fn main() {} - -pub fn add_two(a: i32) -> i32 { - internal_adder(a, 2) -} - -fn internal_adder(a: i32, b: i32) -> i32 { - a + b -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn internal() { - assert_eq!(4, internal_adder(2, 2)); - } -} -``` - -Listing 11-12: Testing a private function - -Note that the `internal_adder` function is not marked as `pub`, but because -tests are just Rust code and the `tests` module is just another module, you can -import and call `internal_adder` in a test just fine. If you don’t think -private functions should be tested, there’s nothing in Rust that will compel -you to do so. - -### Integration Tests - -In Rust, integration tests are entirely external to your library. They use your -library in the same way any other code would, which means they can only call -functions that are part of your library’s public API. Their purpose is to test -whether many parts of your library work together correctly. Units of code that -work correctly on their own could have problems when integrated, so test -coverage of the integrated code is important as well. To create integration -tests, you first need a *tests* directory. - -#### The *tests* Directory - -We create a *tests* directory at the top level of our project directory, next -to *src*. Cargo knows to look for integration test files in this directory. We -can then make as many test files as we want to in this directory, and Cargo -will compile each of the files as an individual crate. - -Let’s create an integration test. With the code in Listing 11-12 still in the -*src/lib.rs* file, make a *tests* directory, create a new file named -*tests/integration_test.rs*, and enter the code in Listing 11-13: - -Filename: tests/integration_test.rs - -```rust,ignore -extern crate adder; - -#[test] -fn it_adds_two() { - assert_eq!(4, adder::add_two(2)); -} -``` - -Listing 11-13: An integration test of a function in the -`adder` crate - -We’ve added `extern crate adder` at the top of the code, which we didn’t need -in the unit tests. The reason is that each test in the `tests` directory is a -separate crate, so we need to import our library into each of them. - -We don’t need to annotate any code in *tests/integration_test.rs* with -`#[cfg(test)]`. Cargo treats the `tests` directory specially and compiles files -in this directory only when we run `cargo test`. Run `cargo test` now: - -```text -$ cargo test - Compiling adder v0.1.0 (file:///projects/adder) - Finished dev [unoptimized + debuginfo] target(s) in 0.31 secs - Running target/debug/deps/adder-abcabcabc - -running 1 test -test tests::internal ... ok - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out - - Running target/debug/deps/integration_test-ce99bcc2479f4607 - -running 1 test -test it_adds_two ... ok - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out - - Doc-tests adder - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out -``` - -The three sections of output include the unit tests, the integration test, and -the doc tests. The first section for the unit tests is the same as we’ve been -seeing: one line for each unit test (one named `internal` that we added in -Listing 11-12) and then a summary line for the unit tests. - -The integration tests section starts with the line `Running -target/debug/deps/integration_test-ce99bcc2479f4607` (the hash at the end of -your output will be different). Next, there is a line for each test function in -that integration test and a summary line for the results of the integration -test just before the `Doc-tests adder` section starts. - -Similarly to how adding more unit test functions adds more result lines to the -unit tests section, adding more test functions to the integration test file -adds more result lines to this integration test file’s section. Each -integration test file has its own section, so if we add more files in the -*tests* directory, there will be more integration test sections. - -We can still run a particular integration test function by specifying the test -function’s name as an argument to `cargo test`. To run all the tests in a -particular integration test file, use the `--test` argument of `cargo test` -followed by the name of the file: - -```text -$ cargo test --test integration_test - Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs - Running target/debug/integration_test-952a27e0126bb565 - -running 1 test -test it_adds_two ... ok - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out -``` - -This command runs only the tests in the *tests/integration_test.rs* file. - -#### Submodules in Integration Tests - -As you add more integration tests, you might want to make more than one file in -the *tests* directory to help organize them; for example, you can group the -test functions by the functionality they’re testing. As mentioned earlier, each -file in the *tests* directory is compiled as its own separate crate. - -Treating each integration test file as its own crate is useful to create -separate scopes that are more like the way end users will be using your crate. -However, this means files in the *tests* directory don’t share the same -behavior as files in *src* do, as you learned in Chapter 7 regarding how to -separate code into modules and files. - -The different behavior of files in the *tests* directory is most noticeable -when you have a set of helper functions that would be useful in multiple -integration test files and you try to follow the steps in the “Moving Modules -to Other Files” section of Chapter 7 to extract them into a common module. For -example, if we create *tests/common.rs* and place a function named `setup` in -it, we can add some code to `setup` that we want to call from multiple test -functions in multiple test files: - -Filename: tests/common.rs - -```rust -pub fn setup() { - // setup code specific to your library's tests would go here -} -``` - -When we run the tests again, we’ll see a new section in the test output for the -*common.rs* file, even though this file doesn’t contain any test functions nor -did we call the `setup` function from anywhere: - -```text -running 1 test -test tests::internal ... ok - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out - - Running target/debug/deps/common-b8b07b6f1be2db70 - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out - - Running target/debug/deps/integration_test-d993c68b431d39df - -running 1 test -test it_adds_two ... ok - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out - - Doc-tests adder - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out -``` - -Having `common` appear in the test results with `running 0 tests` displayed for -it is not what we wanted. We just wanted to share some code with the other -integration test files. - -To avoid having `common` appear in the test output, instead of creating -*tests/common.rs*, we’ll create *tests/common/mod.rs*. In the “Rules of Module -Filesystems” section of Chapter 7, we used the naming convention -*module_name/mod.rs* for files of modules that have submodules. We don’t have -submodules for `common` here, but naming the file this way tells Rust not to -treat the `common` module as an integration test file. When we move the `setup` -function code into *tests/common/mod.rs* and delete the *tests/common.rs* file, -the section in the test output will no longer appear. Files in subdirectories -of the *tests* directory don’t get compiled as separate crates or have sections -in the test output. - -After we’ve created *tests/common/mod.rs*, we can use it from any of the -integration test files as a module. Here’s an example of calling the `setup` -function from the `it_adds_two` test in *tests/integration_test.rs*: - -Filename: tests/integration_test.rs - -```rust,ignore -extern crate adder; - -mod common; - -#[test] -fn it_adds_two() { - common::setup(); - assert_eq!(4, adder::add_two(2)); -} -``` - -Note that the `mod common;` declaration is the same as the module declarations -we demonstrated in Listing 7-4. Then in the test function, we can call the -`common::setup()` function. - -#### Integration Tests for Binary Crates - -If our project is a binary crate that only contains a *src/main.rs* file and -doesn’t have a *src/lib.rs* file, we can’t create integration tests in the -*tests* directory and use `extern crate` to import functions defined in the -*src/main.rs* file. Only library crates expose functions that other crates can -call and use; binary crates are meant to be run on their own. - -This is one of the reasons Rust projects that provide a binary have a -straightforward *src/main.rs* file that calls logic that lives in the -*src/lib.rs* file. Using that structure, integration tests *can* test the -library crate by using `extern crate` to exercise the important functionality. -If the important functionality works, the small amount of code in the -*src/main.rs* file will work as well, and that small amount of code doesn’t -need to be tested. - -## Summary - -Rust’s testing features provide a way to specify how code should function to -ensure it continues to work as you expect, even as you make changes. Unit tests -exercise different parts of a library separately and can test private -implementation details. Integration tests check that many parts of the library -work together correctly, and they use the library’s public API to test the code -in the same way external code will use it. Even though Rust’s type system and -ownership rules help prevent some kinds of bugs, tests are still important to -reduce logic bugs having to do with how your code is expected to behave. - -Let’s combine the knowledge you learned in this chapter and in previous -chapters to work on a project! +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch11-03-test-organization.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-00-an-io-project.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-00-an-io-project.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-00-an-io-project.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-00-an-io-project.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,38 +1,10 @@ # An I/O Project: Building a Command Line Program -This chapter is a recap of the many skills you’ve learned so far and an -exploration of a few more standard library features. We’ll build a command line -tool that interacts with file and command line input/output to practice some of -the Rust concepts you now have under your belt. +The 2018 edition of the book is no longer distributed with Rust's documentation. -Rust’s speed, safety, single binary output, and cross-platform support make it -an ideal language for creating command line tools, so for our project, we’ll -make our own version of the classic command line tool `grep` (**g**lobally -search a **r**egular **e**xpression and **p**rint). In the simplest use case, -`grep` searches a specified file for a specified string. To do so, `grep` takes -as its arguments a filename and a string. Then it reads the file, finds lines -in that file that contain the string argument, and prints those lines. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -Along the way, we’ll show how to make our command line tool use features of the -terminal that many command line tools use. We’ll read the value of an -environment variable to allow the user to configure the behavior of our tool. -We’ll also print to the standard error console stream (`stderr`) instead of -standard output (`stdout`), so, for example, the user can redirect successful -output to a file while still seeing error messages onscreen. - -One Rust community member, Andrew Gallant, has already created a fully -featured, very fast version of `grep`, called `ripgrep`. By comparison, our -version of `grep` will be fairly simple, but this chapter will give you some of -the background knowledge you need to understand a real-world project such as -`ripgrep`. - -Our `grep` project will combine a number of concepts you’ve learned so far: - -* Organizing code (using what you learned in modules, Chapter 7) -* Using vectors and strings (collections, Chapter 8) -* Handling errors (Chapter 9) -* Using traits and lifetimes where appropriate (Chapter 10) -* Writing tests (Chapter 11) - -We’ll also briefly introduce closures, iterators, and trait objects, which -Chapters 13 and 17 will cover in detail. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch12-00-an-io-project.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-01-accepting-command-line-arguments.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-01-accepting-command-line-arguments.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-01-accepting-command-line-arguments.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-01-accepting-command-line-arguments.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,153 +1,10 @@ ## Accepting Command Line Arguments -Let’s create a new project with, as always, `cargo new`. We’ll call our project -`minigrep` to distinguish it from the `grep` tool that you might already have -on your system. +The 2018 edition of the book is no longer distributed with Rust's documentation. -```text -$ cargo new minigrep - Created binary (application) `minigrep` project -$ cd minigrep -``` +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -The first task is to make `minigrep` accept its two command line arguments: the -filename and a string to search for. That is, we want to be able to run our -program with `cargo run`, a string to search for, and a path to a file to -search in, like so: - -```text -$ cargo run searchstring example-filename.txt -``` - -Right now, the program generated by `cargo new` cannot process arguments we -give it. Some existing libraries on [Crates.io](https://crates.io/) can help -with writing a program that accepts command line arguments, but because you’re -just learning this concept, let’s implement this capability ourselves. - -### Reading the Argument Values - -To enable `minigrep` to read the values of command line arguments we pass to -it, we’ll need a function provided in Rust’s standard library, which is -`std::env::args`. This function returns an *iterator* of the command line -arguments that were given to `minigrep`. We haven’t discussed iterators yet -(we’ll cover them fully in Chapter 13), but for now, you only need to know two -details about iterators: iterators produce a series of values, and we can call -the `collect` method on an iterator to turn it into a collection, such as a -vector, containing all the elements the iterator produces. - -Use the code in Listing 12-1 to allow your `minigrep` program to read any -command line arguments passed to it and then collect the values into a vector: - -Filename: src/main.rs - -```rust -use std::env; - -fn main() { - let args: Vec = env::args().collect(); - println!("{:?}", args); -} -``` - -Listing 12-1: Collecting the command line arguments into -a vector and printing them - -First, we bring the `std::env` module into scope with a `use` statement so we -can use its `args` function. Notice that the `std::env::args` function is -nested in two levels of modules. As we discussed in Chapter 7, in cases where -the desired function is nested in more than one module, it’s conventional to -bring the parent module into scope rather than the function. By doing so, we -can easily use other functions from `std::env`. It’s also less ambiguous than -adding `use std::env::args` and then calling the function with just `args`, -because `args` might easily be mistaken for a function that’s defined in the -current module. - -> ### The `args` Function and Invalid Unicode -> -> Note that `std::env::args` will panic if any argument contains invalid -> Unicode. If your program needs to accept arguments containing invalid -> Unicode, use `std::env::args_os` instead. That function returns an iterator -> that produces `OsString` values instead of `String` values. We’ve chosen to -> use `std::env::args` here for simplicity, because `OsString` values differ -> per platform and are more complex to work with than `String` values. - -On the first line of `main`, we call `env::args`, and we immediately use -`collect` to turn the iterator into a vector containing all the values produced -by the iterator. We can use the `collect` function to create many kinds of -collections, so we explicitly annotate the type of `args` to specify that we -want a vector of strings. Although we very rarely need to annotate types in -Rust, `collect` is one function you do often need to annotate because Rust -isn’t able to infer the kind of collection you want. - -Finally, we print the vector using the debug formatter, `:?`. Let’s try running -the code first with no arguments and then with two arguments: - -```text -$ cargo run ---snip-- -["target/debug/minigrep"] - -$ cargo run needle haystack ---snip-- -["target/debug/minigrep", "needle", "haystack"] -``` - -Notice that the first value in the vector is `"target/debug/minigrep"`, which -is the name of our binary. This matches the behavior of the arguments list in -C, letting programs use the name by which they were invoked in their execution. -It’s often convenient to have access to the program name in case you want to -print it in messages or change behavior of the program based on what command -line alias was used to invoke the program. But for the purposes of this -chapter, we’ll ignore it and save only the two arguments we need. - -### Saving the Argument Values in Variables - -Printing the value of the vector of arguments illustrated that the program is -able to access the values specified as command line arguments. Now we need to -save the values of the two arguments in variables so we can use the values -throughout the rest of the program. We do that in Listing 12-2: - -Filename: src/main.rs - -```rust,should_panic -use std::env; - -fn main() { - let args: Vec = env::args().collect(); - - let query = &args[1]; - let filename = &args[2]; - - println!("Searching for {}", query); - println!("In file {}", filename); -} -``` - -Listing 12-2: Creating variables to hold the query -argument and filename argument - -As we saw when we printed the vector, the program’s name takes up the first -value in the vector at `args[0]`, so we’re starting at index `1`. The first -argument `minigrep` takes is the string we’re searching for, so we put a -reference to the first argument in the variable `query`. The second argument -will be the filename, so we put a reference to the second argument in the -variable `filename`. - -We temporarily print the values of these variables to prove that the code is -working as we intend. Let’s run this program again with the arguments `test` -and `sample.txt`: - -```text -$ cargo run test sample.txt - Compiling minigrep v0.1.0 (file:///projects/minigrep) - Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs - Running `target/debug/minigrep test sample.txt` -Searching for test -In file sample.txt -``` - -Great, the program is working! The values of the arguments we need are being -saved into the right variables. Later we’ll add some error handling to deal -with certain potential erroneous situations, such as when the user provides no -arguments; for now, we’ll ignore that situation and work on adding file-reading -capabilities instead. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch12-01-accepting-command-line-arguments.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-02-reading-a-file.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-02-reading-a-file.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-02-reading-a-file.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-02-reading-a-file.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,97 +1,10 @@ ## Reading a File -Now we’ll add functionality to read the file that is specified in the -`filename` command line argument. First, we need a sample file to test it with: -the best kind of file to use to make sure `minigrep` is working is one with a -small amount of text over multiple lines with some repeated words. Listing 12-3 -has an Emily Dickinson poem that will work well! Create a file called -*poem.txt* at the root level of your project, and enter the poem “I’m Nobody! -Who are you?” +The 2018 edition of the book is no longer distributed with Rust's documentation. -Filename: poem.txt +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -```text -I’m nobody! Who are you? -Are you nobody, too? -Then there’s a pair of us — don’t tell! -They’d banish us, you know. - -How dreary to be somebody! -How public, like a frog -To tell your name the livelong day -To an admiring bog! -``` - -Listing 12-3: A poem by Emily Dickinson makes a good test -case - -With the text in place, edit *src/main.rs* and add code to open the file, as -shown in Listing 12-4: - -Filename: src/main.rs - -```rust,should_panic -use std::env; -use std::fs; - -fn main() { -# let args: Vec = env::args().collect(); -# -# let query = &args[1]; -# let filename = &args[2]; -# -# println!("Searching for {}", query); - // --snip-- - println!("In file {}", filename); - - let contents = fs::read_to_string(filename) - .expect("Something went wrong reading the file"); - - println!("With text:\n{}", contents); -} -``` - -Listing 12-4: Reading the contents of the file specified -by the second argument - -First, we add another `use` statement to bring in a relevant part of the -standard library: we need `std::fs` to handle files. - -In `main`, we’ve added a new statement: `fs::read_to_string` will take the -`filename`, open that file, and then produce a new `String` with its contents. - -After that line, we’ve again added a temporary `println!` statement that -prints the value of `contents` after the file is read, so we can check that the -program is working so far. - -Let’s run this code with any string as the first command line argument (because -we haven’t implemented the searching part yet) and the *poem.txt* file as the -second argument: - -```text -$ cargo run the poem.txt - Compiling minigrep v0.1.0 (file:///projects/minigrep) - Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs - Running `target/debug/minigrep the poem.txt` -Searching for the -In file poem.txt -With text: -I’m nobody! Who are you? -Are you nobody, too? -Then there’s a pair of us — don’t tell! -They’d banish us, you know. - -How dreary to be somebody! -How public, like a frog -To tell your name the livelong day -To an admiring bog! -``` - -Great! The code read and then printed the contents of the file. But the code -has a few flaws. The `main` function has multiple responsibilities: generally, -functions are clearer and easier to maintain if each function is responsible -for only one idea. The other problem is that we’re not handling errors as well -as we could. The program is still small, so these flaws aren’t a big problem, -but as the program grows, it will be harder to fix them cleanly. It’s good -practice to begin refactoring early on when developing a program, because it’s -much easier to refactor smaller amounts of code. We’ll do that next. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch12-02-reading-a-file.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-03-improving-error-handling-and-modularity.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-03-improving-error-handling-and-modularity.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-03-improving-error-handling-and-modularity.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-03-improving-error-handling-and-modularity.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,672 +1,10 @@ ## Refactoring to Improve Modularity and Error Handling -To improve our program, we’ll fix four problems that have to do with the -program’s structure and how it’s handling potential errors. +The 2018 edition of the book is no longer distributed with Rust's documentation. -First, our `main` function now performs two tasks: it parses arguments and -opens files. For such a small function, this isn’t a major problem. However, if -we continue to grow our program inside `main`, the number of separate tasks the -`main` function handles will increase. As a function gains responsibilities, it -becomes more difficult to reason about, harder to test, and harder to change -without breaking one of its parts. It’s best to separate functionality so each -function is responsible for one task. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -This issue also ties into the second problem: although `query` and `filename` -are configuration variables to our program, variables like `contents` are used -to perform the program’s logic. The longer `main` becomes, the more variables -we’ll need to bring into scope; the more variables we have in scope, the harder -it will be to keep track of the purpose of each. It’s best to group the -configuration variables into one structure to make their purpose clear. - -The third problem is that we’ve used `expect` to print an error message when -opening the file fails, but the error message just prints -`something went wrong`. Opening a file can fail in a number of ways: for -example, the file could be missing, or we might not have permission to open -it. Right now, regardless of the situation, we’d print the -`something went wrong` error message, which wouldn't give the user any -information! - -Fourth, we use `expect` repeatedly to handle different errors, and if the user -runs our program without specifying enough arguments, they’ll get an `index out -of bounds` error from Rust that doesn’t clearly explain the problem. It would -be best if all the error-handling code were in one place so future maintainers -had only one place to consult in the code if the error-handling logic needed to -change. Having all the error-handling code in one place will also ensure that -we’re printing messages that will be meaningful to our end users. - -Let’s address these four problems by refactoring our project. - -### Separation of Concerns for Binary Projects - -The organizational problem of allocating responsibility for multiple tasks to -the `main` function is common to many binary projects. As a result, the Rust -community has developed a process to use as a guideline for splitting the -separate concerns of a binary program when `main` starts getting large. The -process has the following steps: - -* Split your program into a *main.rs* and a *lib.rs* and move your program’s - logic to *lib.rs*. -* As long as your command line parsing logic is small, it can remain in - *main.rs*. -* When the command line parsing logic starts getting complicated, extract it - from *main.rs* and move it to *lib.rs*. -* The responsibilities that remain in the `main` function after this process - should be limited to the following: - - * Calling the command line parsing logic with the argument values - * Setting up any other configuration - * Calling a `run` function in *lib.rs* - * Handling the error if `run` returns an error - -This pattern is about separating concerns: *main.rs* handles running the -program, and *lib.rs* handles all the logic of the task at hand. Because you -can’t test the `main` function directly, this structure lets you test all of -your program’s logic by moving it into functions in *lib.rs*. The only code -that remains in *main.rs* will be small enough to verify its correctness by -reading it. Let’s rework our program by following this process. - -#### Extracting the Argument Parser - -We’ll extract the functionality for parsing arguments into a function that -`main` will call to prepare for moving the command line parsing logic to -*src/lib.rs*. Listing 12-5 shows the new start of `main` that calls a new -function `parse_config`, which we’ll define in *src/main.rs* for the moment. - -Filename: src/main.rs - -```rust,ignore -fn main() { - let args: Vec = env::args().collect(); - - let (query, filename) = parse_config(&args); - - // --snip-- -} - -fn parse_config(args: &[String]) -> (&str, &str) { - let query = &args[1]; - let filename = &args[2]; - - (query, filename) -} -``` - -Listing 12-5: Extracting a `parse_config` function from -`main` - -We’re still collecting the command line arguments into a vector, but instead of -assigning the argument value at index `1` to the variable `query` and the -argument value at index `2` to the variable `filename` within the `main` -function, we pass the whole vector to the `parse_config` function. The -`parse_config` function then holds the logic that determines which argument -goes in which variable and passes the values back to `main`. We still create -the `query` and `filename` variables in `main`, but `main` no longer has the -responsibility of determining how the command line arguments and variables -correspond. - -This rework may seem like overkill for our small program, but we’re refactoring -in small, incremental steps. After making this change, run the program again to -verify that the argument parsing still works. It’s good to check your progress -often, to help identify the cause of problems when they occur. - -#### Grouping Configuration Values - -We can take another small step to improve the `parse_config` function further. -At the moment, we’re returning a tuple, but then we immediately break that -tuple into individual parts again. This is a sign that perhaps we don’t have -the right abstraction yet. - -Another indicator that shows there’s room for improvement is the `config` part -of `parse_config`, which implies that the two values we return are related and -are both part of one configuration value. We’re not currently conveying this -meaning in the structure of the data other than by grouping the two values into -a tuple; we could put the two values into one struct and give each of the -struct fields a meaningful name. Doing so will make it easier for future -maintainers of this code to understand how the different values relate to each -other and what their purpose is. - -> Note: Some people call this anti-pattern of using primitive values when a -> complex type would be more appropriate *primitive obsession*. - -Listing 12-6 shows the addition of a struct named `Config` defined to have -fields named `query` and `filename`. We’ve also changed the `parse_config` -function to return an instance of the `Config` struct and updated `main` to use -the struct fields rather than having separate variables: - -Filename: src/main.rs - -```rust,should_panic -# use std::env; -# use std::fs; -# -fn main() { - let args: Vec = env::args().collect(); - - let config = parse_config(&args); - - println!("Searching for {}", config.query); - println!("In file {}", config.filename); - - let contents = fs::read_to_string(config.filename) - .expect("Something went wrong reading the file"); - - // --snip-- -} - -struct Config { - query: String, - filename: String, -} - -fn parse_config(args: &[String]) -> Config { - let query = args[1].clone(); - let filename = args[2].clone(); - - Config { query, filename } -} -``` - -Listing 12-6: Refactoring `parse_config` to return an -instance of a `Config` struct - -The signature of `parse_config` now indicates that it returns a `Config` value. -In the body of `parse_config`, where we used to return string slices that -reference `String` values in `args`, we now define `Config` to contain owned -`String` values. The `args` variable in `main` is the owner of the argument -values and is only letting the `parse_config` function borrow them, which means -we’d violate Rust’s borrowing rules if `Config` tried to take ownership of the -values in `args`. - -We could manage the `String` data in a number of different ways, but the -easiest, though somewhat inefficient, route is to call the `clone` method on -the values. This will make a full copy of the data for the `Config` instance to -own, which takes more time and memory than storing a reference to the string -data. However, cloning the data also makes our code very straightforward -because we don’t have to manage the lifetimes of the references; in this -circumstance, giving up a little performance to gain simplicity is a worthwhile -trade-off. - -> ### The Trade-Offs of Using `clone` -> -> There’s a tendency among many Rustaceans to avoid using `clone` to fix -> ownership problems because of its runtime cost. In Chapter 13, you’ll learn -> how to use more efficient methods in this type of situation. But for now, -> it’s okay to copy a few strings to continue making progress because you’ll -> make these copies only once and your filename and query string are very -> small. It’s better to have a working program that’s a bit inefficient than to -> try to hyperoptimize code on your first pass. As you become more experienced -> with Rust, it’ll be easier to start with the most efficient solution, but for -> now, it’s perfectly acceptable to call `clone`. - -We’ve updated `main` so it places the instance of `Config` returned by -`parse_config` into a variable named `config`, and we updated the code that -previously used the separate `query` and `filename` variables so it now uses -the fields on the `Config` struct instead. - -Now our code more clearly conveys that `query` and `filename` are related and -that their purpose is to configure how the program will work. Any code that -uses these values knows to find them in the `config` instance in the fields -named for their purpose. - -#### Creating a Constructor for `Config` - -So far, we’ve extracted the logic responsible for parsing the command line -arguments from `main` and placed it in the `parse_config` function. Doing so -helped us to see that the `query` and `filename` values were related and that -relationship should be conveyed in our code. We then added a `Config` struct to -name the related purpose of `query` and `filename` and to be able to return the -values’ names as struct field names from the `parse_config` function. - -So now that the purpose of the `parse_config` function is to create a `Config` -instance, we can change `parse_config` from a plain function to a function -named `new` that is associated with the `Config` struct. Making this change -will make the code more idiomatic. We can create instances of types in the -standard library, such as `String`, by calling `String::new`. Similarly, by -changing `parse_config` into a `new` function associated with `Config`, we’ll -be able to create instances of `Config` by calling `Config::new`. Listing 12-7 -shows the changes we need to make: - -Filename: src/main.rs - -```rust,should_panic -# use std::env; -# -fn main() { - let args: Vec = env::args().collect(); - - let config = Config::new(&args); - - // --snip-- -} - -# struct Config { -# query: String, -# filename: String, -# } -# -// --snip-- - -impl Config { - fn new(args: &[String]) -> Config { - let query = args[1].clone(); - let filename = args[2].clone(); - - Config { query, filename } - } -} -``` - -Listing 12-7: Changing `parse_config` into -`Config::new` - -We’ve updated `main` where we were calling `parse_config` to instead call -`Config::new`. We’ve changed the name of `parse_config` to `new` and moved it -within an `impl` block, which associates the `new` function with `Config`. Try -compiling this code again to make sure it works. - -### Fixing the Error Handling - -Now we’ll work on fixing our error handling. Recall that attempting to access -the values in the `args` vector at index `1` or index `2` will cause the -program to panic if the vector contains fewer than three items. Try running the -program without any arguments; it will look like this: - -```text -$ cargo run - Compiling minigrep v0.1.0 (file:///projects/minigrep) - Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs - Running `target/debug/minigrep` -thread 'main' panicked at 'index out of bounds: the len is 1 -but the index is 1', src/main.rs:29:21 -note: Run with `RUST_BACKTRACE=1` for a backtrace. -``` - -The line `index out of bounds: the len is 1 but the index is 1` is an error -message intended for programmers. It won’t help our end users understand what -happened and what they should do instead. Let’s fix that now. - -#### Improving the Error Message - -In Listing 12-8, we add a check in the `new` function that will verify that the -slice is long enough before accessing index `1` and `2`. If the slice isn’t -long enough, the program panics and displays a better error message than the -`index out of bounds` message. - -Filename: src/main.rs - -```rust,ignore -// --snip-- -fn new(args: &[String]) -> Config { - if args.len() < 3 { - panic!("not enough arguments"); - } - // --snip-- -``` - -Listing 12-8: Adding a check for the number of -arguments - -This code is similar to the `Guess::new` function we wrote in Listing 9-9, where -we called `panic!` when the `value` argument was out of the range of valid -values. Instead of checking for a range of values here, we’re checking that the -length of `args` is at least `3` and the rest of the function can operate under -the assumption that this condition has been met. If `args` has fewer than three -items, this condition will be true, and we call the `panic!` macro to end the -program immediately. - -With these extra few lines of code in `new`, let’s run the program without any -arguments again to see what the error looks like now: - -```text -$ cargo run - Compiling minigrep v0.1.0 (file:///projects/minigrep) - Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs - Running `target/debug/minigrep` -thread 'main' panicked at 'not enough arguments', src/main.rs:30:12 -note: Run with `RUST_BACKTRACE=1` for a backtrace. -``` - -This output is better: we now have a reasonable error message. However, we also -have extraneous information we don’t want to give to our users. Perhaps using -the technique we used in Listing 9-9 isn’t the best to use here: a call to -`panic!` is more appropriate for a programming problem rather than a usage -problem, as discussed in Chapter 9. Instead, we can use the other technique you -learned about in Chapter 9—returning a `Result` that indicates either success -or an error. - -#### Returning a `Result` from `new` Instead of Calling `panic!` - -We can instead return a `Result` value that will contain a `Config` instance in -the successful case and will describe the problem in the error case. When -`Config::new` is communicating to `main`, we can use the `Result` type to -signal there was a problem. Then we can change `main` to convert an `Err` -variant into a more practical error for our users without the surrounding text -about `thread 'main'` and `RUST_BACKTRACE` that a call to `panic!` causes. - -Listing 12-9 shows the changes we need to make to the return value of -`Config::new` and the body of the function needed to return a `Result`. Note -that this won’t compile until we update `main` as well, which we’ll do in the -next listing. - -Filename: src/main.rs - -```rust,ignore -impl Config { - fn new(args: &[String]) -> Result { - if args.len() < 3 { - return Err("not enough arguments"); - } - - let query = args[1].clone(); - let filename = args[2].clone(); - - Ok(Config { query, filename }) - } -} -``` - -Listing 12-9: Returning a `Result` from -`Config::new` - -Our `new` function now returns a `Result` with a `Config` instance in the -success case and a `&'static str` in the error case. Recall from “The Static -Lifetime” section in Chapter 10 that `&'static str` is the type of string -literals, which is our error message type for now. - -We’ve made two changes in the body of the `new` function: instead of calling -`panic!` when the user doesn’t pass enough arguments, we now return an `Err` -value, and we’ve wrapped the `Config` return value in an `Ok`. These changes -make the function conform to its new type signature. - -Returning an `Err` value from `Config::new` allows the `main` function to -handle the `Result` value returned from the `new` function and exit the process -more cleanly in the error case. - -#### Calling `Config::new` and Handling Errors - -To handle the error case and print a user-friendly message, we need to update -`main` to handle the `Result` being returned by `Config::new`, as shown in -Listing 12-10. We’ll also take the responsibility of exiting the command line -tool with a nonzero error code from `panic!` and implement it by hand. A -nonzero exit status is a convention to signal to the process that called our -program that the program exited with an error state. - -Filename: src/main.rs - -```rust,ignore -use std::process; - -fn main() { - let args: Vec = env::args().collect(); - - let config = Config::new(&args).unwrap_or_else(|err| { - println!("Problem parsing arguments: {}", err); - process::exit(1); - }); - - // --snip-- -``` - -Listing 12-10: Exiting with an error code if creating a -new `Config` fails - -In this listing, we’ve used a method we haven’t covered before: -`unwrap_or_else`, which is defined on `Result` by the standard library. -Using `unwrap_or_else` allows us to define some custom, non-`panic!` error -handling. If the `Result` is an `Ok` value, this method’s behavior is similar -to `unwrap`: it returns the inner value `Ok` is wrapping. However, if the value -is an `Err` value, this method calls the code in the *closure*, which is an -anonymous function we define and pass as an argument to `unwrap_or_else`. We’ll -cover closures in more detail in Chapter 13. For now, you just need to know -that `unwrap_or_else` will pass the inner value of the `Err`, which in this -case is the static string `not enough arguments` that we added in Listing 12-9, -to our closure in the argument `err` that appears between the vertical pipes. -The code in the closure can then use the `err` value when it runs. - -We’ve added a new `use` line to import `process` from the standard library. The -code in the closure that will be run in the error case is only two lines: we -print the `err` value and then call `process::exit`. The `process::exit` -function will stop the program immediately and return the number that was -passed as the exit status code. This is similar to the `panic!`-based handling -we used in Listing 12-8, but we no longer get all the extra output. Let’s try -it: - -```text -$ cargo run - Compiling minigrep v0.1.0 (file:///projects/minigrep) - Finished dev [unoptimized + debuginfo] target(s) in 0.48 secs - Running `target/debug/minigrep` -Problem parsing arguments: not enough arguments -``` - -Great! This output is much friendlier for our users. - -### Extracting Logic from `main` - -Now that we’ve finished refactoring the configuration parsing, let’s turn to -the program’s logic. As we stated in “Separation of Concerns for Binary -Projects”, we’ll extract a function named `run` that will hold all the logic -currently in the `main` function that isn’t involved with setting up -configuration or handling errors. When we’re done, `main` will be concise and -easy to verify by inspection, and we’ll be able to write tests for all the -other logic. - -Listing 12-11 shows the extracted `run` function. For now, we’re just making -the small, incremental improvement of extracting the function. We’re still -defining the function in *src/main.rs*. - -Filename: src/main.rs - -```rust,ignore -fn main() { - // --snip-- - - println!("Searching for {}", config.query); - println!("In file {}", config.filename); - - run(config); -} - -fn run(config: Config) { - let contents = fs::read_to_string(config.filename) - .expect("something went wrong reading the file"); - - println!("With text:\n{}", contents); -} - -// --snip-- -``` - -Listing 12-11: Extracting a `run` function containing the -rest of the program logic - -The `run` function now contains all the remaining logic from `main`, starting -from reading the file. The `run` function takes the `Config` instance as an -argument. - -#### Returning Errors from the `run` Function - -With the remaining program logic separated into the `run` function, we can -improve the error handling, as we did with `Config::new` in Listing 12-9. -Instead of allowing the program to panic by calling `expect`, the `run` -function will return a `Result` when something goes wrong. This will let -us further consolidate into `main` the logic around handling errors in a -user-friendly way. Listing 12-12 shows the changes we need to make to the -signature and body of `run`: - -Filename: src/main.rs - -```rust,ignore -use std::error::Error; - -// --snip-- - -fn run(config: Config) -> Result<(), Box> { - let contents = fs::read_to_string(config.filename)?; - - println!("With text:\n{}", contents); - - Ok(()) -} -``` - -Listing 12-12: Changing the `run` function to return -`Result` - -We’ve made three significant changes here. First, we changed the return type of -the `run` function to `Result<(), Box>`. This function previously -returned the unit type, `()`, and we keep that as the value returned in the -`Ok` case. - -For the error type, we used the *trait object* `Box` (and we’ve -brought `std::error::Error` into scope with a `use` statement at the top). -We’ll cover trait objects in Chapter 17. For now, just know that `Box` means the function will return a type that implements the `Error` -trait, but we don’t have to specify what particular type the return value -will be. This gives us flexibility to return error values that may be of -different types in different error cases. This is what the `dyn` means, it's -short for "dynamic." - -Second, we’ve removed the call to `expect` in favor of `?`, as we talked about -in Chapter 9. Rather than `panic!` on an error, `?` will return the error value -from the current function for the caller to handle. - -Third, the `run` function now returns an `Ok` value in the success case. We’ve -declared the `run` function’s success type as `()` in the signature, which -means we need to wrap the unit type value in the `Ok` value. This `Ok(())` -syntax might look a bit strange at first, but using `()` like this is the -idiomatic way to indicate that we’re calling `run` for its side effects only; -it doesn’t return a value we need. - -When you run this code, it will compile but will display a warning: - -```text -warning: unused `std::result::Result` which must be used - --> src/main.rs:18:5 - | -18 | run(config); - | ^^^^^^^^^^^^ -= note: #[warn(unused_must_use)] on by default -``` - -Rust tells us that our code ignored the `Result` value and the `Result` value -might indicate that an error occurred. But we’re not checking to see whether or -not there was an error, and the compiler reminds us that we probably meant to -have some error handling code here! Let’s rectify that problem now. - -#### Handling Errors Returned from `run` in `main` - -We’ll check for errors and handle them using a technique similar to one we used -with `Config::new` in Listing 12-10, but with a slight difference: - -Filename: src/main.rs - -```rust,ignore -fn main() { - // --snip-- - - println!("Searching for {}", config.query); - println!("In file {}", config.filename); - - if let Err(e) = run(config) { - println!("Application error: {}", e); - - process::exit(1); - } -} -``` - -We use `if let` rather than `unwrap_or_else` to check whether `run` returns an -`Err` value and call `process::exit(1)` if it does. The `run` function doesn’t -return a value that we want to `unwrap` in the same way that `Config::new` -returns the `Config` instance. Because `run` returns `()` in the success case, -we only care about detecting an error, so we don’t need `unwrap_or_else` to -return the unwrapped value because it would only be `()`. - -The bodies of the `if let` and the `unwrap_or_else` functions are the same in -both cases: we print the error and exit. - -### Splitting Code into a Library Crate - -Our `minigrep` project is looking good so far! Now we’ll split the -*src/main.rs* file and put some code into the *src/lib.rs* file so we can test -it and have a *src/main.rs* file with fewer responsibilities. - -Let’s move all the code that isn’t the `main` function from *src/main.rs* to -*src/lib.rs*: - -* The `run` function definition -* The relevant `use` statements -* The definition of `Config` -* The `Config::new` function definition - -The contents of *src/lib.rs* should have the signatures shown in Listing 12-13 -(we’ve omitted the bodies of the functions for brevity). Note that this won’t -compile until we modify *src/main.rs* in the listing after this one. - -Filename: src/lib.rs - -```rust,ignore -use std::error::Error; -use std::fs; - -pub struct Config { - pub query: String, - pub filename: String, -} - -impl Config { - pub fn new(args: &[String]) -> Result { - // --snip-- - } -} - -pub fn run(config: Config) -> Result<(), Box> { - // --snip-- -} -``` - -Listing 12-13: Moving `Config` and `run` into -*src/lib.rs* - -We’ve made liberal use of the `pub` keyword: on `Config`, on its fields and its -`new` method, and on the `run` function. We now have a library crate that has a -public API that we can test! - -Now we need to bring the code we moved to *src/lib.rs* into the scope of the -binary crate in *src/main.rs*, as shown in Listing 12-14: - -Filename: src/main.rs - -```rust,ignore -extern crate minigrep; - -use std::env; -use std::process; - -use minigrep::Config; - -fn main() { - // --snip-- - if let Err(e) = minigrep::run(config) { - // --snip-- - } -} -``` - -Listing 12-14: Bringing the `minigrep` crate into the -scope of *src/main.rs* - -To bring the library crate into the binary crate, we use `extern crate -minigrep`. Then we add a `use minigrep::Config` line to bring the `Config` type -into scope, and we prefix the `run` function with our crate name. Now all the -functionality should be connected and should work. Run the program with `cargo -run` and make sure everything works correctly. - -Whew! That was a lot of work, but we’ve set ourselves up for success in the -future. Now it’s much easier to handle errors, and we’ve made the code more -modular. Almost all of our work will be done in *src/lib.rs* from here on out. - -Let’s take advantage of this newfound modularity by doing something that would -have been difficult with the old code but is easy with the new code: we’ll -write some tests! +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch12-03-improving-error-handling-and-modularity.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-04-testing-the-librarys-functionality.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-04-testing-the-librarys-functionality.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-04-testing-the-librarys-functionality.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-04-testing-the-librarys-functionality.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,329 +1,10 @@ ## Developing the Library’s Functionality with Test-Driven Development -Now that we’ve extracted the logic into *src/lib.rs* and left the argument -collecting and error handling in *src/main.rs*, it’s much easier to write tests -for the core functionality of our code. We can call functions directly with -various arguments and check return values without having to call our binary -from the command line. Feel free to write some tests for the functionality in -the `Config::new` and `run` functions on your own. +The 2018 edition of the book is no longer distributed with Rust's documentation. -In this section, we’ll add the searching logic to the `minigrep` program by -using the Test-driven development (TDD) process. This software development -technique follows these steps: +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -1. Write a test that fails and run it to make sure it fails for the reason you - expect. -2. Write or modify just enough code to make the new test pass. -3. Refactor the code you just added or changed and make sure the tests - continue to pass. -4. Repeat from step 1! - -This process is just one of many ways to write software, but TDD can help drive -code design as well. Writing the test before you write the code that makes the -test pass helps to maintain high test coverage throughout the process. - -We’ll test drive the implementation of the functionality that will actually do -the searching for the query string in the file contents and produce a list of -lines that match the query. We’ll add this functionality in a function called -`search`. - -### Writing a Failing Test - -Because we don’t need them anymore, let’s remove the `println!` statements from -*src/lib.rs* and *src/main.rs* that we used to check the program’s behavior. -Then, in *src/lib.rs*, we’ll add a `tests` module with a test function, as we -did in Chapter 11. The test function specifies the behavior we want the -`search` function to have: it will take a query and the text to search for the -query in, and it will return only the lines from the text that contain the -query. Listing 12-15 shows this test, which won’t compile yet: - -Filename: src/lib.rs - -```rust -# fn search<'a>(query: &str, contents: &'a str) -> Vec<&'a str> { -# vec![] -# } -# -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn one_result() { - let query = "duct"; - let contents = "\ -Rust: -safe, fast, productive. -Pick three."; - - assert_eq!( - vec!["safe, fast, productive."], - search(query, contents) - ); - } -} -``` - -Listing 12-15: Creating a failing test for the `search` -function we wish we had - -This test searches for the string `"duct"`. The text we’re searching is three -lines, only one of which contains `"duct"`. We assert that the value returned -from the `search` function contains only the line we expect. - -We aren’t able to run this test and watch it fail because the test doesn’t even -compile: the `search` function doesn’t exist yet! So now we’ll add just enough -code to get the test to compile and run by adding a definition of the `search` -function that always returns an empty vector, as shown in Listing 12-16. Then -the test should compile and fail because an empty vector doesn’t match a vector -containing the line `"safe, fast, productive."` - -Filename: src/lib.rs - -```rust -fn search<'a>(query: &str, contents: &'a str) -> Vec<&'a str> { - vec![] -} -``` - -Listing 12-16: Defining just enough of the `search` -function so our test will compile - -Notice that we need an explicit lifetime `'a` defined in the signature of -`search` and used with the `contents` argument and the return value. Recall in -Chapter 10 that the lifetime parameters specify which argument lifetime is -connected to the lifetime of the return value. In this case, we indicate that -the returned vector should contain string slices that reference slices of the -argument `contents` (rather than the argument `query`). - -In other words, we tell Rust that the data returned by the `search` function -will live as long as the data passed into the `search` function in the -`contents` argument. This is important! The data referenced *by* a slice needs -to be valid for the reference to be valid; if the compiler assumes we’re making -string slices of `query` rather than `contents`, it will do its safety checking -incorrectly. - -If we forget the lifetime annotations and try to compile this function, we’ll -get this error: - -```text -error[E0106]: missing lifetime specifier - --> src/lib.rs:5:51 - | -5 | fn search(query: &str, contents: &str) -> Vec<&str> { - | ^ expected lifetime -parameter - | - = help: this function's return type contains a borrowed value, but the - signature does not say whether it is borrowed from `query` or `contents` -``` - -Rust can’t possibly know which of the two arguments we need, so we need to tell -it. Because `contents` is the argument that contains all of our text and we -want to return the parts of that text that match, we know `contents` is the -argument that should be connected to the return value using the lifetime syntax. - -Other programming languages don’t require you to connect arguments to return -values in the signature. So although this might seem strange, it will get -easier over time. You might want to compare this example with the “Validating -References with Lifetimes” section in Chapter 10. - -Now let’s run the test: - -```text -$ cargo test - Compiling minigrep v0.1.0 (file:///projects/minigrep) ---warnings-- - Finished dev [unoptimized + debuginfo] target(s) in 0.43 secs - Running target/debug/deps/minigrep-abcabcabc - -running 1 test -test tests::one_result ... FAILED - -failures: - ----- tests::one_result stdout ---- - thread 'tests::one_result' panicked at 'assertion failed: `(left == -right)` -left: `["safe, fast, productive."]`, -right: `[]`)', src/lib.rs:48:8 -note: Run with `RUST_BACKTRACE=1` for a backtrace. - - -failures: - tests::one_result - -test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out - -error: test failed, to rerun pass '--lib' -``` - -Great, the test fails, exactly as we expected. Let’s get the test to pass! - -### Writing Code to Pass the Test - -Currently, our test is failing because we always return an empty vector. To fix -that and implement `search`, our program needs to follow these steps: - -* Iterate through each line of the contents. -* Check whether the line contains our query string. -* If it does, add it to the list of values we’re returning. -* If it doesn’t, do nothing. -* Return the list of results that match. - -Let’s work through each step, starting with iterating through lines. - -#### Iterating Through Lines with the `lines` Method - -Rust has a helpful method to handle line-by-line iteration of strings, -conveniently named `lines`, that works as shown in Listing 12-17. Note this -won’t compile yet: - -Filename: src/lib.rs - -```rust,ignore -fn search<'a>(query: &str, contents: &'a str) -> Vec<&'a str> { - for line in contents.lines() { - // do something with line - } -} -``` - -Listing 12-17: Iterating through each line in `contents` - - -The `lines` method returns an iterator. We’ll talk about iterators in depth in -Chapter 13, but recall that you saw this way of using an iterator in Listing -3-5, where we used a `for` loop with an iterator to run some code on each item -in a collection. - -#### Searching Each Line for the Query - -Next, we’ll check whether the current line contains our query string. -Fortunately, strings have a helpful method named `contains` that does this for -us! Add a call to the `contains` method in the `search` function, as shown in -Listing 12-18. Note this still won’t compile yet: - -Filename: src/lib.rs - -```rust,ignore -fn search<'a>(query: &str, contents: &'a str) -> Vec<&'a str> { - for line in contents.lines() { - if line.contains(query) { - // do something with line - } - } -} -``` - -Listing 12-18: Adding functionality to see whether the -line contains the string in `query` - -#### Storing Matching Lines - -We also need a way to store the lines that contain our query string. For that, -we can make a mutable vector before the `for` loop and call the `push` method -to store a `line` in the vector. After the `for` loop, we return the vector, as -shown in Listing 12-19: - -Filename: src/lib.rs - -```rust,ignore -fn search<'a>(query: &str, contents: &'a str) -> Vec<&'a str> { - let mut results = Vec::new(); - - for line in contents.lines() { - if line.contains(query) { - results.push(line); - } - } - - results -} -``` - -Listing 12-19: Storing the lines that match so we can -return them - -Now the `search` function should return only the lines that contain `query`, -and our test should pass. Let’s run the test: - -```text -$ cargo test ---snip-- -running 1 test -test tests::one_result ... ok - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out -``` - -Our test passed, so we know it works! - -At this point, we could consider opportunities for refactoring the -implementation of the search function while keeping the tests passing to -maintain the same functionality. The code in the search function isn’t too bad, -but it doesn’t take advantage of some useful features of iterators. We’ll -return to this example in Chapter 13, where we’ll explore iterators in detail, -and look at how to improve it. - -#### Using the `search` Function in the `run` Function - -Now that the `search` function is working and tested, we need to call `search` -from our `run` function. We need to pass the `config.query` value and the -`contents` that `run` reads from the file to the `search` function. Then `run` -will print each line returned from `search`: - -Filename: src/lib.rs - -```rust,ignore -pub fn run(config: Config) -> Result<(), Box> { - let contents = fs::read_to_string(config.filename)?; - - for line in search(&config.query, &contents) { - println!("{}", line); - } - - Ok(()) -} -``` - -We’re still using a `for` loop to return each line from `search` and print it. - -Now the entire program should work! Let’s try it out, first with a word that -should return exactly one line from the Emily Dickinson poem, “frog”: - -```text -$ cargo run frog poem.txt - Compiling minigrep v0.1.0 (file:///projects/minigrep) - Finished dev [unoptimized + debuginfo] target(s) in 0.38 secs - Running `target/debug/minigrep frog poem.txt` -How public, like a frog -``` - -Cool! Now let’s try a word that will match multiple lines, like “body”: - -```text -$ cargo run body poem.txt - Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs - Running `target/debug/minigrep body poem.txt` -I’m nobody! Who are you? -Are you nobody, too? -How dreary to be somebody! -``` - -And finally, let’s make sure that we don’t get any lines when we search for a -word that isn’t anywhere in the poem, such as “monomorphization”: - -```text -$ cargo run monomorphization poem.txt - Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs - Running `target/debug/minigrep monomorphization poem.txt` -``` - -Excellent! We’ve built our own mini version of a classic tool and learned a lot -about how to structure applications. We’ve also learned a bit about file input -and output, lifetimes, testing, and command line parsing. - -To round out this project, we’ll briefly demonstrate how to work with -environment variables and how to print to standard error, both of which are -useful when you’re writing command line programs. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch12-04-testing-the-librarys-functionality.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-05-working-with-environment-variables.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-05-working-with-environment-variables.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-05-working-with-environment-variables.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-05-working-with-environment-variables.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,302 +1,10 @@ ## Working with Environment Variables -We’ll improve `minigrep` by adding an extra feature: an option for -case-insensitive searching that the user can turn on via an environment -variable. We could make this feature a command line option and require that -users enter it each time they want it to apply, but instead we’ll use an -environment variable. Doing so allows our users to set the environment variable -once and have all their searches be case insensitive in that terminal session. +The 2018 edition of the book is no longer distributed with Rust's documentation. -### Writing a Failing Test for the Case-Insensitive `search` Function +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -We want to add a new `search_case_insensitive` function that we’ll call when -the environment variable is on. We’ll continue to follow the TDD process, so -the first step is again to write a failing test. We’ll add a new test for the -new `search_case_insensitive` function and rename our old test from -`one_result` to `case_sensitive` to clarify the differences between the two -tests, as shown in Listing 12-20: - -Filename: src/lib.rs - -```rust -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn case_sensitive() { - let query = "duct"; - let contents = "\ -Rust: -safe, fast, productive. -Pick three. -Duct tape."; - - assert_eq!( - vec!["safe, fast, productive."], - search(query, contents) - ); - } - - #[test] - fn case_insensitive() { - let query = "rUsT"; - let contents = "\ -Rust: -safe, fast, productive. -Pick three. -Trust me."; - - assert_eq!( - vec!["Rust:", "Trust me."], - search_case_insensitive(query, contents) - ); - } -} -``` - -Listing 12-20: Adding a new failing test for the -case-insensitive function we’re about to add - -Note that we’ve edited the old test’s `contents` too. We’ve added a new line -with the text `"Duct tape."` using a capital D that shouldn’t match the query -“duct” when we’re searching in a case-sensitive manner. Changing the old test -in this way helps ensure that we don’t accidentally break the case-sensitive -search functionality that we’ve already implemented. This test should pass now -and should continue to pass as we work on the case-insensitive search. - -The new test for the case-*insensitive* search uses `"rUsT"` as its query. In -the `search_case_insensitive` function we’re about to add, the query `"rUsT"` -should match the line containing `"Rust:"` with a capital R and match the line -`"Trust me."` even though both have different casing than the query. This is -our failing test, and it will fail to compile because we haven’t yet defined -the `search_case_insensitive` function. Feel free to add a skeleton -implementation that always returns an empty vector, similar to the way we did -for the `search` function in Listing 12-16 to see the test compile and fail. - -### Implementing the `search_case_insensitive` Function - -The `search_case_insensitive` function, shown in Listing 12-21, will be almost -the same as the `search` function. The only difference is that we’ll lowercase -the `query` and each `line` so whatever the case of the input arguments, -they’ll be the same case when we check whether the line contains the query. - -Filename: src/lib.rs - -```rust -fn search_case_insensitive<'a>(query: &str, contents: &'a str) -> Vec<&'a str> { - let query = query.to_lowercase(); - let mut results = Vec::new(); - - for line in contents.lines() { - if line.to_lowercase().contains(&query) { - results.push(line); - } - } - - results -} -``` - -Listing 12-21: Defining the `search_case_insensitive` -function to lowercase the query and the line before comparing them - -First, we lowercase the `query` string and store it in a shadowed variable with -the same name. Calling `to_lowercase` on the query is necessary so no matter -whether the user’s query is `"rust"`, `"RUST"`, `"Rust"`, or `"rUsT"`, we’ll -treat the query as if it were `"rust"` and be insensitive to the case. - -Note that `query` is now a `String` rather than a string slice, because calling -`to_lowercase` creates new data rather than referencing existing data. Say the -query is `"rUsT"`, as an example: that string slice doesn’t contain a lowercase -`u` or `t` for us to use, so we have to allocate a new `String` containing -`"rust"`. When we pass `query` as an argument to the `contains` method now, we -need to add an ampersand because the signature of `contains` is defined to take -a string slice. - -Next, we add a call to `to_lowercase` on each `line` before we check whether it -contains `query` to lowercase all characters. Now that we’ve converted `line` -and `query` to lowercase, we’ll find matches no matter what the case of the -query is. - -Let’s see if this implementation passes the tests: - -```text -running 2 tests -test tests::case_insensitive ... ok -test tests::case_sensitive ... ok - -test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out -``` - -Great! They passed. Now, let’s call the new `search_case_insensitive` function -from the `run` function. First, we’ll add a configuration option to the -`Config` struct to switch between case-sensitive and case-insensitive search. -Adding this field will cause compiler errors since we aren’t initializing this -field anywhere yet: - -Filename: src/lib.rs - -```rust -pub struct Config { - pub query: String, - pub filename: String, - pub case_sensitive: bool, -} -``` - -Note that we added the `case_sensitive` field that holds a Boolean. Next, we -need the `run` function to check the `case_sensitive` field’s value and use -that to decide whether to call the `search` function or the -`search_case_insensitive` function, as shown in Listing 12-22. Note this still -won’t compile yet: - -Filename: src/lib.rs - -```rust -# use std::error::Error; -# use std::fs::{self, File}; -# use std::io::prelude::*; -# -# fn search<'a>(query: &str, contents: &'a str) -> Vec<&'a str> { -# vec![] -# } -# -# fn search_case_insensitive<'a>(query: &str, contents: &'a str) -> Vec<&'a str> { -# vec![] -# } -# -# pub struct Config { -# query: String, -# filename: String, -# case_sensitive: bool, -# } -# -pub fn run(config: Config) -> Result<(), Box> { - let contents = fs::read_to_string(config.filename)?; - - let results = if config.case_sensitive { - search(&config.query, &contents) - } else { - search_case_insensitive(&config.query, &contents) - }; - - for line in results { - println!("{}", line); - } - - Ok(()) -} -``` - -Listing 12-22: Calling either `search` or -`search_case_insensitive` based on the value in `config.case_sensitive` - -Finally, we need to check for the environment variable. The functions for -working with environment variables are in the `env` module in the standard -library, so we want to bring that module into scope with a `use std::env;` line -at the top of *src/lib.rs*. Then we’ll use the `var` method from the `env` -module to check for an environment variable named `CASE_INSENSITIVE`, as shown -in Listing 12-23: - -Filename: src/lib.rs - -```rust -use std::env; -# struct Config { -# query: String, -# filename: String, -# case_sensitive: bool, -# } - -// --snip-- - -impl Config { - pub fn new(args: &[String]) -> Result { - if args.len() < 3 { - return Err("not enough arguments"); - } - - let query = args[1].clone(); - let filename = args[2].clone(); - - let case_sensitive = env::var("CASE_INSENSITIVE").is_err(); - - Ok(Config { query, filename, case_sensitive }) - } -} -``` - -Listing 12-23: Checking for an environment variable named -`CASE_INSENSITIVE` - -Here, we create a new variable `case_sensitive`. To set its value, we call the -`env::var` function and pass it the name of the `CASE_INSENSITIVE` environment -variable. The `env::var` method returns a `Result` that will be the successful -`Ok` variant that contains the value of the environment variable if the -environment variable is set. It will return the `Err` variant if the -environment variable is not set. - -We’re using the `is_err` method on the `Result` to check whether it’s an error -and therefore unset, which means it *should* do a case-sensitive search. If the -`CASE_INSENSITIVE` environment variable is set to anything, `is_err` will -return false and the program will perform a case-insensitive search. We don’t -care about the *value* of the environment variable, just whether it’s set or -unset, so we’re checking `is_err` rather than using `unwrap`, `expect`, or any -of the other methods we’ve seen on `Result`. - -We pass the value in the `case_sensitive` variable to the `Config` instance so -the `run` function can read that value and decide whether to call `search` or -`search_case_insensitive`, as we implemented in Listing 12-22. - -Let’s give it a try! First, we’ll run our program without the environment -variable set and with the query `to`, which should match any line that contains -the word “to” in all lowercase: - -```text -$ cargo run to poem.txt - Compiling minigrep v0.1.0 (file:///projects/minigrep) - Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs - Running `target/debug/minigrep to poem.txt` -Are you nobody, too? -How dreary to be somebody! -``` - -Looks like that still works! Now, let’s run the program with `CASE_INSENSITIVE` -set to `1` but with the same query `to`. - -If you’re using PowerShell, you will need to set the environment variable and -run the program in two commands rather than one: - -```text -$ $env:CASE_INSENSITIVE=1 -$ cargo run to poem.txt -``` - -We should get lines that contain “to” that might have uppercase letters: - -```text -$ CASE_INSENSITIVE=1 cargo run to poem.txt - Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs - Running `target/debug/minigrep to poem.txt` -Are you nobody, too? -How dreary to be somebody! -To tell your name the livelong day -To an admiring bog! -``` - -Excellent, we also got lines containing “To”! Our `minigrep` program can now do -case-insensitive searching controlled by an environment variable. Now you know -how to manage options set using either command line arguments or environment -variables. - -Some programs allow arguments *and* environment variables for the same -configuration. In those cases, the programs decide that one or the other takes -precedence. For another exercise on your own, try controlling case -insensitivity through either a command line argument or an environment -variable. Decide whether the command line argument or the environment variable -should take precedence if the program is run with one set to case sensitive and -one set to case insensitive. - -The `std::env` module contains many more useful features for dealing with -environment variables: check out its documentation to see what is available. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch12-05-working-with-environment-variables.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-06-writing-to-stderr-instead-of-stdout.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-06-writing-to-stderr-instead-of-stdout.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-06-writing-to-stderr-instead-of-stdout.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch12-06-writing-to-stderr-instead-of-stdout.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,121 +1,10 @@ ## Writing Error Messages to Standard Error Instead of Standard Output -At the moment, we’re writing all of our output to the terminal using the -`println!` function. Most terminals provide two kinds of output: *standard -output* (`stdout`) for general information and *standard error* (`stderr`) -for error messages. This distinction enables users to choose to direct the -successful output of a program to a file but still print error messages to the -screen. +The 2018 edition of the book is no longer distributed with Rust's documentation. -The `println!` function is only capable of printing to standard output, so we -have to use something else to print to standard error. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -### Checking Where Errors Are Written - -First, let’s observe how the content printed by `minigrep` is currently being -written to standard output, including any error messages we want to write to -standard error instead. We’ll do that by redirecting the standard output stream -to a file while also intentionally causing an error. We won’t redirect the -standard error stream, so any content sent to standard error will continue to -display on the screen. - -Command line programs are expected to send error messages to the standard error -stream so we can still see error messages on the screen even if we redirect the -standard output stream to a file. Our program is not currently well-behaved: -we’re about to see that it saves the error message output to a file instead! - -The way to demonstrate this behavior is by running the program with `>` and the -filename, *output.txt*, that we want to redirect the standard output stream to. -We won’t pass any arguments, which should cause an error: - -```text -$ cargo run > output.txt -``` - -The `>` syntax tells the shell to write the contents of standard output to -*output.txt* instead of the screen. We didn’t see the error message we were -expecting printed to the screen, so that means it must have ended up in the -file. This is what *output.txt* contains: - -```text -Problem parsing arguments: not enough arguments -``` - -Yup, our error message is being printed to standard output. It’s much more -useful for error messages like this to be printed to standard error so only -data from a successful run ends up in the file. We’ll change that. - -### Printing Errors to Standard Error - -We’ll use the code in Listing 12-24 to change how error messages are printed. -Because of the refactoring we did earlier in this chapter, all the code that -prints error messages is in one function, `main`. The standard library provides -the `eprintln!` macro that prints to the standard error stream, so let’s change -the two places we were calling `println!` to print errors to use `eprintln!` -instead. - -Filename: src/main.rs - -```rust,ignore -fn main() { - let args: Vec = env::args().collect(); - - let config = Config::new(&args).unwrap_or_else(|err| { - eprintln!("Problem parsing arguments: {}", err); - process::exit(1); - }); - - if let Err(e) = minigrep::run(config) { - eprintln!("Application error: {}", e); - - process::exit(1); - } -} -``` - -Listing 12-24: Writing error messages to standard error -instead of standard output using `eprintln!` - -After changing `println!` to `eprintln!`, let’s run the program again in the -same way, without any arguments and redirecting standard output with `>`: - -```text -$ cargo run > output.txt -Problem parsing arguments: not enough arguments -``` - -Now we see the error onscreen and *output.txt* contains nothing, which is the -behavior we expect of command line programs. - -Let’s run the program again with arguments that don’t cause an error but still -redirect standard output to a file, like so: - -```text -$ cargo run to poem.txt > output.txt -``` - -We won’t see any output to the terminal, and *output.txt* will contain our -results: - -Filename: output.txt - -```text -Are you nobody, too? -How dreary to be somebody! -``` - -This demonstrates that we’re now using standard output for successful output -and standard error for error output as appropriate. - -## Summary - -This chapter recapped some of the major concepts you’ve learned so far and -covered how to perform common I/O operations in Rust. By using command line -arguments, files, environment variables, and the `eprintln!` macro for printing -errors, you’re now prepared to write command line applications. By using the -concepts in previous chapters, your code will be well organized, store data -effectively in the appropriate data structures, handle errors nicely, and be -well tested. - -Next, we’ll explore some Rust features that were influenced by functional -languages: closures and iterators. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch12-06-writing-to-stderr-instead-of-stdout.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch13-00-functional-features.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch13-00-functional-features.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch13-00-functional-features.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch13-00-functional-features.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,24 +1,10 @@ # Functional Language Features: Iterators and Closures -Rust’s design has taken inspiration from many existing languages and -techniques, and one significant influence is *functional programming*. -Programming in a functional style often includes using functions as values by -passing them in arguments, returning them from other functions, assigning them -to variables for later execution, and so forth. +The 2018 edition of the book is no longer distributed with Rust's documentation. -In this chapter, we won’t debate the issue of what functional programming is or -isn’t but will instead discuss some features of Rust that are similar to -features in many languages often referred to as functional. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -More specifically, we’ll cover: - -* *Closures*, a function-like construct you can store in a variable -* *Iterators*, a way of processing a series of elements -* How to use these two features to improve the I/O project in Chapter 12 -* The performance of these two features (Spoiler alert: they’re faster than you - might think!) - -Other Rust features, such as pattern matching and enums, which we’ve covered in -other chapters, are influenced by the functional style as well. Mastering -closures and iterators is an important part of writing idiomatic, fast Rust -code, so we’ll devote this entire chapter to them. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch13-00-functional-features.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch13-01-closures.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch13-01-closures.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch13-01-closures.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch13-01-closures.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,823 +1,10 @@ ## Closures: Anonymous Functions that Can Capture Their Environment -Rust’s closures are anonymous functions you can save in a variable or pass as -arguments to other functions. You can create the closure in one place and then -call the closure to evaluate it in a different context. Unlike functions, -closures can capture values from the scope in which they’re called. We’ll -demonstrate how these closure features allow for code reuse and behavior -customization. +The 2018 edition of the book is no longer distributed with Rust's documentation. -### Creating an Abstraction of Behavior with Closures +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -Let’s work on an example of a situation in which it’s useful to store a closure -to be executed later. Along the way, we’ll talk about the syntax of closures, -type inference, and traits. - -Consider this hypothetical situation: we work at a startup that’s making an app -to generate custom exercise workout plans. The backend is written in Rust, and -the algorithm that generates the workout plan takes into account many factors, -such as the app user’s age, body mass index, exercise preferences, recent -workouts, and an intensity number they specify. The actual algorithm used isn’t -important in this example; what’s important is that this calculation takes a -few seconds. We want to call this algorithm only when we need to and only call -it once so we don’t make the user wait more than necessary. - -We’ll simulate calling this hypothetical algorithm with the function -`simulated_expensive_calculation` shown in Listing 13-1, which will print -`calculating slowly...`, wait for two seconds, and then return whatever number -we passed in: - -Filename: src/main.rs - -```rust -use std::thread; -use std::time::Duration; - -fn simulated_expensive_calculation(intensity: u32) -> u32 { - println!("calculating slowly..."); - thread::sleep(Duration::from_secs(2)); - intensity -} -``` - -Listing 13-1: A function to stand in for a hypothetical -calculation that takes about 2 seconds to run - -Next is the `main` function, which contains the parts of the workout app -important for this example. This function represents the code that the app will -call when a user asks for a workout plan. Because the interaction with the -app’s frontend isn’t relevant to the use of closures, we’ll hardcode values -representing inputs to our program and print the outputs. - -The required inputs are these: - -* An intensity number from the user, which is specified when they request - a workout to indicate whether they want a low-intensity workout or a - high-intensity workout -* A random number that will generate some variety in the workout plans - -The output will be the recommended workout plan. Listing 13-2 shows the `main` -function we’ll use: - -Filename: src/main.rs - -```rust -fn main() { - let simulated_user_specified_value = 10; - let simulated_random_number = 7; - - generate_workout( - simulated_user_specified_value, - simulated_random_number - ); -} -# fn generate_workout(intensity: u32, random_number: u32) {} -``` - -Listing 13-2: A `main` function with hardcoded values to -simulate user input and random number generation - -We’ve hardcoded the variable `simulated_user_specified_value` as 10 and the -variable `simulated_random_number` as 7 for simplicity’s sake; in an actual -program, we’d get the intensity number from the app frontend, and we’d use the -`rand` crate to generate a random number, as we did in the Guessing Game -example in Chapter 2. The `main` function calls a `generate_workout` function -with the simulated input values. - -Now that we have the context, let’s get to the algorithm. The function -`generate_workout` in Listing 13-3 contains the business logic of the -app that we’re most concerned with in this example. The rest of the code -changes in this example will be made to this function. - -Filename: src/main.rs - -```rust -# use std::thread; -# use std::time::Duration; -# -# fn simulated_expensive_calculation(num: u32) -> u32 { -# println!("calculating slowly..."); -# thread::sleep(Duration::from_secs(2)); -# num -# } -# -fn generate_workout(intensity: u32, random_number: u32) { - if intensity < 25 { - println!( - "Today, do {} pushups!", - simulated_expensive_calculation(intensity) - ); - println!( - "Next, do {} situps!", - simulated_expensive_calculation(intensity) - ); - } else { - if random_number == 3 { - println!("Take a break today! Remember to stay hydrated!"); - } else { - println!( - "Today, run for {} minutes!", - simulated_expensive_calculation(intensity) - ); - } - } -} -``` - -Listing 13-3: The business logic that prints the workout -plans based on the inputs and calls to the `simulated_expensive_calculation` -function - -The code in Listing 13-3 has multiple calls to the slow calculation function. -The first `if` block calls `simulated_expensive_calculation` twice, the `if` -inside the outer `else` doesn’t call it at all, and the code inside the -second `else` case calls it once. - - - -The desired behavior of the `generate_workout` function is to first check -whether the user wants a low-intensity workout (indicated by a number less -than 25) or a high-intensity workout (a number of 25 or greater). - -Low-intensity workout plans will recommend a number of push-ups and sit-ups -based on the complex algorithm we’re simulating. - -If the user wants a high-intensity workout, there’s some additional logic: if -the value of the random number generated by the app happens to be 3, the app -will recommend a break and hydration. If not, the user will get a number of -minutes of running based on the complex algorithm. - -This code works the way the business wants it to now, but let’s say the data -science team decides that we need to make some changes to the way we call the -`simulated_expensive_calculation` function in the future. To simplify the -update when those changes happen, we want to refactor this code so it calls the -`simulated_expensive_calculation` function only once. We also want to cut the -place where we’re currently unnecessarily calling the function twice without -adding any other calls to that function in the process. That is, we don’t want -to call it if the result isn’t needed, and we still want to call it only once. - -#### Refactoring Using Functions - -We could restructure the workout program in many ways. First, we’ll try -extracting the duplicated call to the `simulated_expensive_calculation` -function into a variable, as shown in Listing 13-4: - -Filename: src/main.rs - -```rust -# use std::thread; -# use std::time::Duration; -# -# fn simulated_expensive_calculation(num: u32) -> u32 { -# println!("calculating slowly..."); -# thread::sleep(Duration::from_secs(2)); -# num -# } -# -fn generate_workout(intensity: u32, random_number: u32) { - let expensive_result = - simulated_expensive_calculation(intensity); - - if intensity < 25 { - println!( - "Today, do {} pushups!", - expensive_result - ); - println!( - "Next, do {} situps!", - expensive_result - ); - } else { - if random_number == 3 { - println!("Take a break today! Remember to stay hydrated!"); - } else { - println!( - "Today, run for {} minutes!", - expensive_result - ); - } - } -} -``` - -Listing 13-4: Extracting the calls to -`simulated_expensive_calculation` to one place and storing the result in the -`expensive_result` variable - -This change unifies all the calls to `simulated_expensive_calculation` and -solves the problem of the first `if` block unnecessarily calling the function -twice. Unfortunately, we’re now calling this function and waiting for the -result in all cases, which includes the inner `if` block that doesn’t use the -result value at all. - -We want to define code in one place in our program, but only *execute* that -code where we actually need the result. This is a use case for closures! - -#### Refactoring with Closures to Store Code - -Instead of always calling the `simulated_expensive_calculation` function before -the `if` blocks, we can define a closure and store the *closure* in a variable -rather than storing the result of the function call, as shown in Listing 13-5. -We can actually move the whole body of `simulated_expensive_calculation` within -the closure we’re introducing here: - -Filename: src/main.rs - -```rust -# use std::thread; -# use std::time::Duration; -# -let expensive_closure = |num| { - println!("calculating slowly..."); - thread::sleep(Duration::from_secs(2)); - num -}; -# expensive_closure(5); -``` - -Listing 13-5: Defining a closure and storing it in the -`expensive_closure` variable - -The closure definition comes after the `=` to assign it to the variable -`expensive_closure`. To define a closure, we start with a pair of vertical -pipes (`|`), inside which we specify the parameters to the closure; this syntax -was chosen because of its similarity to closure definitions in Smalltalk and -Ruby. This closure has one parameter named `num`: if we had more than one -parameter, we would separate them with commas, like `|param1, param2|`. - -After the parameters, we place curly brackets that hold the body of the -closure—these are optional if the closure body is a single expression. The end -of the closure, after the curly brackets, needs a semicolon to complete the -`let` statement. The value returned from the last line in the closure body -(`num`) will be the value returned from the closure when it’s called, because -that line doesn’t end in a semicolon; just like in function bodies. - -Note that this `let` statement means `expensive_closure` contains the -*definition* of an anonymous function, not the *resulting value* of calling the -anonymous function. Recall that we’re using a closure because we want to define -the code to call at one point, store that code, and call it at a later point; -the code we want to call is now stored in `expensive_closure`. - -With the closure defined, we can change the code in the `if` blocks to call the -closure to execute the code and get the resulting value. We call a closure like -we do a function: we specify the variable name that holds the closure -definition and follow it with parentheses containing the argument values we -want to use, as shown in Listing 13-6: - -Filename: src/main.rs - -```rust -# use std::thread; -# use std::time::Duration; -# -fn generate_workout(intensity: u32, random_number: u32) { - let expensive_closure = |num| { - println!("calculating slowly..."); - thread::sleep(Duration::from_secs(2)); - num - }; - - if intensity < 25 { - println!( - "Today, do {} pushups!", - expensive_closure(intensity) - ); - println!( - "Next, do {} situps!", - expensive_closure(intensity) - ); - } else { - if random_number == 3 { - println!("Take a break today! Remember to stay hydrated!"); - } else { - println!( - "Today, run for {} minutes!", - expensive_closure(intensity) - ); - } - } -} -``` - -Listing 13-6: Calling the `expensive_closure` we’ve -defined - -Now the expensive calculation is called in only one place, and we’re only -executing that code where we need the results. - -However, we’ve reintroduced one of the problems from Listing 13-3: we’re still -calling the closure twice in the first `if` block, which will call the -expensive code twice and make the user wait twice as long as they need to. We -could fix this problem by creating a variable local to that `if` block to hold -the result of calling the closure, but closures provide us with another -solution. We’ll talk about that solution in a bit. But first let’s talk about -why there aren’t type annotations in the closure definition and the traits -involved with closures. - -### Closure Type Inference and Annotation - -Closures don’t require you to annotate the types of the parameters or the -return value like `fn` functions do. Type annotations are required on functions -because they’re part of an explicit interface exposed to your users. Defining -this interface rigidly is important for ensuring that everyone agrees on what -types of values a function uses and returns. But closures aren’t used in an -exposed interface like this: they’re stored in variables and used without -naming them and exposing them to users of our library. - -Closures are usually short and relevant only within a narrow context rather -than in any arbitrary scenario. Within these limited contexts, the compiler is -reliably able to infer the types of the parameters and the return type, similar -to how it’s able to infer the types of most variables. - -Making programmers annotate the types in these small, anonymous functions would -be annoying and largely redundant with the information the compiler already has -available. - -As with variables, we can add type annotations if we want to increase -explicitness and clarity at the cost of being more verbose than is strictly -necessary. Annotating the types for the closure we defined in Listing 13-5 -would look like the definition shown in Listing 13-7: - -Filename: src/main.rs - -```rust -# use std::thread; -# use std::time::Duration; -# -let expensive_closure = |num: u32| -> u32 { - println!("calculating slowly..."); - thread::sleep(Duration::from_secs(2)); - num -}; -``` - -Listing 13-7: Adding optional type annotations of the -parameter and return value types in the closure - -With type annotations added, the syntax of closures looks more similar to the -syntax of functions. The following is a vertical comparison of the syntax for -the definition of a function that adds 1 to its parameter and a closure that -has the same behavior. We’ve added some spaces to line up the relevant parts. -This illustrates how closure syntax is similar to function syntax except for -the use of pipes and the amount of syntax that is optional: - -```rust,ignore -fn add_one_v1 (x: u32) -> u32 { x + 1 } -let add_one_v2 = |x: u32| -> u32 { x + 1 }; -let add_one_v3 = |x| { x + 1 }; -let add_one_v4 = |x| x + 1 ; -``` - -The first line shows a function definition, and the second line shows a fully -annotated closure definition. The third line removes the type annotations from -the closure definition, and the fourth line removes the brackets, which are -optional because the closure body has only one expression. These are all valid -definitions that will produce the same behavior when they’re called. - -Closure definitions will have one concrete type inferred for each of their -parameters and for their return value. For instance, Listing 13-8 shows the -definition of a short closure that just returns the value it receives as a -parameter. This closure isn’t very useful except for the purposes of this -example. Note that we haven’t added any type annotations to the definition: if -we then try to call the closure twice, using a `String` as an argument the -first time and a `u32` the second time, we’ll get an error. - -Filename: src/main.rs - -```rust,ignore -let example_closure = |x| x; - -let s = example_closure(String::from("hello")); -let n = example_closure(5); -``` - -Listing 13-8: Attempting to call a closure whose types -are inferred with two different types - -The compiler gives us this error: - -```text -error[E0308]: mismatched types - --> src/main.rs - | - | let n = example_closure(5); - | ^ expected struct `std::string::String`, found - integral variable - | - = note: expected type `std::string::String` - found type `{integer}` -``` - -The first time we call `example_closure` with the `String` value, the compiler -infers the type of `x` and the return type of the closure to be `String`. Those -types are then locked in to the closure in `example_closure`, and we get a type -error if we try to use a different type with the same closure. - -### Storing Closures Using Generic Parameters and the `Fn` Traits - -Let’s return to our workout generation app. In Listing 13-6, our code was still -calling the expensive calculation closure more times than it needed to. One -option to solve this issue is to save the result of the expensive closure in a -variable for reuse and use the variable in each place we need the result, -instead of calling the closure again. However, this method could result in a -lot of repeated code. - -Fortunately, another solution is available to us. We can create a struct that -will hold the closure and the resulting value of calling the closure. The -struct will execute the closure only if we need the resulting value, and it -will cache the resulting value so the rest of our code doesn’t have to be -responsible for saving and reusing the result. You may know this pattern as -*memoization* or *lazy evaluation*. - -To make a struct that holds a closure, we need to specify the type of the -closure, because a struct definition needs to know the types of each of its -fields. Each closure instance has its own unique anonymous type: that is, even -if two closures have the same signature, their types are still considered -different. To define structs, enums, or function parameters that use closures, -we use generics and trait bounds, as we discussed in Chapter 10. - -The `Fn` traits are provided by the standard library. All closures implement at -least one of the traits: `Fn`, `FnMut`, or `FnOnce`. We’ll discuss the -difference between these traits in the “Capturing the Environment with -Closures” section; in this example, we can use the `Fn` trait. - -We add types to the `Fn` trait bound to represent the types of the parameters -and return values the closures must have to match this trait bound. In this -case, our closure has a parameter of type `u32` and returns a `u32`, so the -trait bound we specify is `Fn(u32) -> u32`. - -Listing 13-9 shows the definition of the `Cacher` struct that holds a closure -and an optional result value: - -Filename: src/main.rs - -```rust -struct Cacher - where T: Fn(u32) -> u32 -{ - calculation: T, - value: Option, -} -``` - -Listing 13-9: Defining a `Cacher` struct that holds a -closure in `calculation` and an optional result in `value` - -The `Cacher` struct has a `calculation` field of the generic type `T`. The -trait bounds on `T` specify that it’s a closure by using the `Fn` trait. Any -closure we want to store in the `calculation` field must have one `u32` -parameter (specified within the parentheses after `Fn`) and must return a -`u32` (specified after the `->`). - -> Note: Functions can implement all three of the `Fn` traits too. If what we -> want to do doesn’t require capturing a value from the environment, we can use -> a function rather than a closure where we need something that implements an -> `Fn` trait. - -The `value` field is of type `Option`. Before we execute the closure, -`value` will be `None`. When code using a `Cacher` asks for the *result* of the -closure, the `Cacher` will execute the closure at that time and store the -result within a `Some` variant in the `value` field. Then if the code asks for -the result of the closure again, instead of executing the closure again, the -`Cacher` will return the result held in the `Some` variant. - -The logic around the `value` field we’ve just described is defined in Listing -13-10: - -Filename: src/main.rs - -```rust -# struct Cacher -# where T: Fn(u32) -> u32 -# { -# calculation: T, -# value: Option, -# } -# -impl Cacher - where T: Fn(u32) -> u32 -{ - fn new(calculation: T) -> Cacher { - Cacher { - calculation, - value: None, - } - } - - fn value(&mut self, arg: u32) -> u32 { - match self.value { - Some(v) => v, - None => { - let v = (self.calculation)(arg); - self.value = Some(v); - v - }, - } - } -} -``` - -Listing 13-10: The caching logic of `Cacher` - -We want `Cacher` to manage the struct fields’ values rather than letting the -calling code potentially change the values in these fields directly, so these -fields are private. - -The `Cacher::new` function takes a generic parameter `T`, which we’ve defined -as having the same trait bound as the `Cacher` struct. Then `Cacher::new` -returns a `Cacher` instance that holds the closure specified in the -`calculation` field and a `None` value in the `value` field, because we haven’t -executed the closure yet. - -When the calling code needs the result of evaluating the closure, instead of -calling the closure directly, it will call the `value` method. This method -checks whether we already have a resulting value in `self.value` in a `Some`; -if we do, it returns the value within the `Some` without executing the closure -again. - -If `self.value` is `None`, the code calls the closure stored in -`self.calculation`, saves the result in `self.value` for future use, and -returns the value as well. - -Listing 13-11 shows how we can use this `Cacher` struct in the function -`generate_workout` from Listing 13-6: - -Filename: src/main.rs - -```rust -# use std::thread; -# use std::time::Duration; -# -# struct Cacher -# where T: Fn(u32) -> u32 -# { -# calculation: T, -# value: Option, -# } -# -# impl Cacher -# where T: Fn(u32) -> u32 -# { -# fn new(calculation: T) -> Cacher { -# Cacher { -# calculation, -# value: None, -# } -# } -# -# fn value(&mut self, arg: u32) -> u32 { -# match self.value { -# Some(v) => v, -# None => { -# let v = (self.calculation)(arg); -# self.value = Some(v); -# v -# }, -# } -# } -# } -# -fn generate_workout(intensity: u32, random_number: u32) { - let mut expensive_result = Cacher::new(|num| { - println!("calculating slowly..."); - thread::sleep(Duration::from_secs(2)); - num - }); - - if intensity < 25 { - println!( - "Today, do {} pushups!", - expensive_result.value(intensity) - ); - println!( - "Next, do {} situps!", - expensive_result.value(intensity) - ); - } else { - if random_number == 3 { - println!("Take a break today! Remember to stay hydrated!"); - } else { - println!( - "Today, run for {} minutes!", - expensive_result.value(intensity) - ); - } - } -} -``` - -Listing 13-11: Using `Cacher` in the `generate_workout` -function to abstract away the caching logic - -Instead of saving the closure in a variable directly, we save a new instance of -`Cacher` that holds the closure. Then, in each place we want the result, we -call the `value` method on the `Cacher` instance. We can call the `value` -method as many times as we want, or not call it at all, and the expensive -calculation will be run a maximum of once. - -Try running this program with the `main` function from Listing 13-2. Change the -values in the `simulated_user_specified_value` and `simulated_random_number` -variables to verify that in all the cases in the various `if` and `else` -blocks, `calculating slowly...` appears only once and only when needed. The -`Cacher` takes care of the logic necessary to ensure we aren’t calling the -expensive calculation more than we need to so `generate_workout` can focus on -the business logic. - -### Limitations of the `Cacher` Implementation - -Caching values is a generally useful behavior that we might want to use in -other parts of our code with different closures. However, there are two -problems with the current implementation of `Cacher` that would make reusing it -in different contexts difficult. - -The first problem is that a `Cacher` instance assumes it will always get the -same value for the parameter `arg` to the `value` method. That is, this test of -`Cacher` will fail: - -```rust,ignore -#[test] -fn call_with_different_values() { - let mut c = Cacher::new(|a| a); - - let v1 = c.value(1); - let v2 = c.value(2); - - assert_eq!(v2, 2); -} -``` - -This test creates a new `Cacher` instance with a closure that returns the value -passed into it. We call the `value` method on this `Cacher` instance with an -`arg` value of 1 and then an `arg` value of 2, and we expect the call to -`value` with the `arg` value of 2 should return 2. - -Run this test with the `Cacher` implementation in Listing 13-9 and Listing -13-10, and the test will fail on the `assert_eq!` with this message: - -```text -thread 'call_with_different_values' panicked at 'assertion failed: `(left == right)` - left: `1`, - right: `2`', src/main.rs -``` - -The problem is that the first time we called `c.value` with 1, the `Cacher` -instance saved `Some(1)` in `self.value`. Thereafter, no matter what we pass in -to the `value` method, it will always return 1. - -Try modifying `Cacher` to hold a hash map rather than a single value. The keys -of the hash map will be the `arg` values that are passed in, and the values of -the hash map will be the result of calling the closure on that key. Instead of -looking at whether `self.value` directly has a `Some` or a `None` value, the -`value` function will look up the `arg` in the hash map and return the value if -it’s present. If it’s not present, the `Cacher` will call the closure and save -the resulting value in the hash map associated with its `arg` value. - -The second problem with the current `Cacher` implementation is that it only -accepts closures that take one parameter of type `u32` and return a `u32`. We -might want to cache the results of closures that take a string slice and return -`usize` values, for example. To fix this issue, try introducing more generic -parameters to increase the flexibility of the `Cacher` functionality. - -### Capturing the Environment with Closures - -In the workout generator example, we only used closures as inline anonymous -functions. However, closures have an additional capability that functions don’t -have: they can capture their environment and access variables from the scope in -which they’re defined. - -Listing 13-12 has an example of a closure stored in the `equal_to_x` variable -that uses the `x` variable from the closure’s surrounding environment: - -Filename: src/main.rs - -```rust -fn main() { - let x = 4; - - let equal_to_x = |z| z == x; - - let y = 4; - - assert!(equal_to_x(y)); -} -``` - -Listing 13-12: Example of a closure that refers to a -variable in its enclosing scope - -Here, even though `x` is not one of the parameters of `equal_to_x`, the -`equal_to_x` closure is allowed to use the `x` variable that’s defined in the -same scope that `equal_to_x` is defined in. - -We can’t do the same with functions; if we try with the following example, our -code won’t compile: - -Filename: src/main.rs - -```rust,ignore -fn main() { - let x = 4; - - fn equal_to_x(z: i32) -> bool { z == x } - - let y = 4; - - assert!(equal_to_x(y)); -} -``` - -We get an error: - -```text -error[E0434]: can't capture dynamic environment in a fn item; use the || { ... -} closure form instead - --> src/main.rs - | -4 | fn equal_to_x(z: i32) -> bool { z == x } - | ^ -``` - -The compiler even reminds us that this only works with closures! - -When a closure captures a value from its environment, it uses memory to store -the values for use in the closure body. This use of memory is overhead that we -don’t want to pay in more common cases where we want to execute code that -doesn’t capture its environment. Because functions are never allowed to capture -their environment, defining and using functions will never incur this overhead. - -Closures can capture values from their environment in three ways, which -directly map to the three ways a function can take a parameter: taking -ownership, borrowing mutably, and borrowing immutably. These are encoded in the -three `Fn` traits as follows: - -* `FnOnce` consumes the variables it captures from its enclosing scope, known - as the closure’s *environment*. To consume the captured variables, the - closure must take ownership of these variables and move them into the closure - when it is defined. The `Once` part of the name represents the fact that the - closure can’t take ownership of the same variables more than once, so it can - be called only once. -* `FnMut` can change the environment because it mutably borrows values. -* `Fn` borrows values from the environment immutably. - -When you create a closure, Rust infers which trait to use based on how the -closure uses the values from the environment. All closures implement `FnOnce` -because they can all be called at least once. Closures that don’t move the -captured variables also implement `FnMut`, and closures that don’t need mutable -access to the captured variables also implement `Fn`. In Listing 13-12, the -`equal_to_x` closure borrows `x` immutably (so `equal_to_x` has the `Fn` trait) -because the body of the closure only needs to read the value in `x`. - -If you want to force the closure to take ownership of the values it uses in the -environment, you can use the `move` keyword before the parameter list. This -technique is mostly useful when passing a closure to a new thread to move the -data so it’s owned by the new thread. - -We’ll have more examples of `move` closures in Chapter 16 when we talk about -concurrency. For now, here’s the code from Listing 13-12 with the `move` -keyword added to the closure definition and using vectors instead of integers, -because integers can be copied rather than moved; note that this code will not -yet compile. - -Filename: src/main.rs - -```rust,ignore -fn main() { - let x = vec![1, 2, 3]; - - let equal_to_x = move |z| z == x; - - println!("can't use x here: {:?}", x); - - let y = vec![1, 2, 3]; - - assert!(equal_to_x(y)); -} -``` - -We receive the following error: - -```text -error[E0382]: use of moved value: `x` - --> src/main.rs:6:40 - | -4 | let equal_to_x = move |z| z == x; - | -------- value moved (into closure) here -5 | -6 | println!("can't use x here: {:?}", x); - | ^ value used here after move - | - = note: move occurs because `x` has type `std::vec::Vec`, which does not - implement the `Copy` trait -``` - -The `x` value is moved into the closure when the closure is defined, because we -added the `move` keyword. The closure then has ownership of `x`, and `main` -isn’t allowed to use `x` anymore in the `println!` statement. Removing -`println!` will fix this example. - -Most of the time when specifying one of the `Fn` trait bounds, you can start -with `Fn` and the compiler will tell you if you need `FnMut` or `FnOnce` based -on what happens in the closure body. - -To illustrate situations where closures that can capture their environment are -useful as function parameters, let’s move on to our next topic: iterators. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch13-01-closures.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch13-02-iterators.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch13-02-iterators.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch13-02-iterators.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch13-02-iterators.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,482 +1,10 @@ ## Processing a Series of Items with Iterators -The iterator pattern allows you to perform some task on a sequence of items in -turn. An iterator is responsible for the logic of iterating over each item and -determining when the sequence has finished. When you use iterators, you don’t -have to reimplement that logic yourself. +The 2018 edition of the book is no longer distributed with Rust's documentation. -In Rust, iterators are *lazy*, meaning they have no effect until you call -methods that consume the iterator to use it up. For example, the code in -Listing 13-13 creates an iterator over the items in the vector `v1` by calling -the `iter` method defined on `Vec`. This code by itself doesn’t do anything -useful. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -```rust -let v1 = vec![1, 2, 3]; - -let v1_iter = v1.iter(); -``` - -Listing 13-13: Creating an iterator - -Once we’ve created an iterator, we can use it in a variety of ways. In Listing -3-5 in Chapter 3, we used iterators with `for` loops to execute some code on -each item, although we glossed over what the call to `iter` did until now. - -The example in Listing 13-14 separates the creation of the iterator from the -use of the iterator in the `for` loop. The iterator is stored in the `v1_iter` -variable, and no iteration takes place at that time. When the `for` loop is -called using the iterator in `v1_iter`, each element in the iterator is used in -one iteration of the loop, which prints out each value. - -```rust -let v1 = vec![1, 2, 3]; - -let v1_iter = v1.iter(); - -for val in v1_iter { - println!("Got: {}", val); -} -``` - -Listing 13-14: Using an iterator in a `for` loop - -In languages that don’t have iterators provided by their standard libraries, -you would likely write this same functionality by starting a variable at index -0, using that variable to index into the vector to get a value, and -incrementing the variable value in a loop until it reached the total number of -items in the vector. - -Iterators handle all that logic for you, cutting down on repetitive code you -could potentially mess up. Iterators give you more flexibility to use the same -logic with many different kinds of sequences, not just data structures you can -index into, like vectors. Let’s examine how iterators do that. - -### The `Iterator` Trait and the `next` Method - -All iterators implement a trait named `Iterator` that is defined in the -standard library. The definition of the trait looks like this: - -```rust -trait Iterator { - type Item; - - fn next(&mut self) -> Option; - - // methods with default implementations elided -} -``` - -Notice this definition uses some new syntax: `type Item` and `Self::Item`, -which are defining an *associated type* with this trait. We’ll talk about -associated types in depth in Chapter 19. For now, all you need to know is that -this code says implementing the `Iterator` trait requires that you also define -an `Item` type, and this `Item` type is used in the return type of the `next` -method. In other words, the `Item` type will be the type returned from the -iterator. - -The `Iterator` trait only requires implementors to define one method: the -`next` method, which returns one item of the iterator at a time wrapped in -`Some` and, when iteration is over, returns `None`. - -We can call the `next` method on iterators directly; Listing 13-15 demonstrates -what values are returned from repeated calls to `next` on the iterator created -from the vector: - -Filename: src/lib.rs - -```rust -#[test] -fn iterator_demonstration() { - let v1 = vec![1, 2, 3]; - - let mut v1_iter = v1.iter(); - - assert_eq!(v1_iter.next(), Some(&1)); - assert_eq!(v1_iter.next(), Some(&2)); - assert_eq!(v1_iter.next(), Some(&3)); - assert_eq!(v1_iter.next(), None); -} -``` - -Listing 13-15: Calling the `next` method on an -iterator - -Note that we needed to make `v1_iter` mutable: calling the `next` method on an -iterator changes internal state that the iterator uses to keep track of where -it is in the sequence. In other words, this code *consumes*, or uses up, the -iterator. Each call to `next` eats up an item from the iterator. We didn’t need -to make `v1_iter` mutable when we used a `for` loop because the loop took -ownership of `v1_iter` and made it mutable behind the scenes. - -Also note that the values we get from the calls to `next` are immutable -references to the values in the vector. The `iter` method produces an iterator -over immutable references. If we want to create an iterator that takes -ownership of `v1` and returns owned values, we can call `into_iter` instead of -`iter`. Similarly, if we want to iterate over mutable references, we can call -`iter_mut` instead of `iter`. - -### Methods that Consume the Iterator - -The `Iterator` trait has a number of different methods with default -implementations provided by the standard library; you can find out about these -methods by looking in the standard library API documentation for the `Iterator` -trait. Some of these methods call the `next` method in their definition, which -is why you’re required to implement the `next` method when implementing the -`Iterator` trait. - -Methods that call `next` are called *consuming adaptors*, because calling them -uses up the iterator. One example is the `sum` method, which takes ownership of -the iterator and iterates through the items by repeatedly calling `next`, thus -consuming the iterator. As it iterates through, it adds each item to a running -total and returns the total when iteration is complete. Listing 13-16 has a -test illustrating a use of the `sum` method: - -Filename: src/lib.rs - -```rust -#[test] -fn iterator_sum() { - let v1 = vec![1, 2, 3]; - - let v1_iter = v1.iter(); - - let total: i32 = v1_iter.sum(); - - assert_eq!(total, 6); -} -``` - -Listing 13-16: Calling the `sum` method to get the total -of all items in the iterator - -We aren’t allowed to use `v1_iter` after the call to `sum` because `sum` takes -ownership of the iterator we call it on. - -### Methods that Produce Other Iterators - -Other methods defined on the `Iterator` trait, known as *iterator adaptors*, -allow you to change iterators into different kinds of iterators. You can chain -multiple calls to iterator adaptors to perform complex actions in a readable -way. But because all iterators are lazy, you have to call one of the consuming -adaptor methods to get results from calls to iterator adaptors. - -Listing 13-17 shows an example of calling the iterator adaptor method `map`, -which takes a closure to call on each item to produce a new iterator. The -closure here creates a new iterator in which each item from the vector has been -incremented by 1. However, this code produces a warning: - -Filename: src/main.rs - -```rust -let v1: Vec = vec![1, 2, 3]; - -v1.iter().map(|x| x + 1); -``` - -Listing 13-17: Calling the iterator adaptor `map` to -create a new iterator - -The warning we get is this: - -```text -warning: unused `std::iter::Map` which must be used: iterator adaptors are lazy -and do nothing unless consumed - --> src/main.rs:4:5 - | -4 | v1.iter().map(|x| x + 1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: #[warn(unused_must_use)] on by default -``` - -The code in Listing 13-17 doesn’t do anything; the closure we’ve specified -never gets called. The warning reminds us why: iterator adaptors are lazy, and -we need to consume the iterator here. - -To fix this and consume the iterator, we’ll use the `collect` method, which we -used in Chapter 12 with `env::args` in Listing 12-1. This method consumes the -iterator and collects the resulting values into a collection data type. - -In Listing 13-18, we collect the results of iterating over the iterator that’s -returned from the call to `map` into a vector. This vector will end up -containing each item from the original vector incremented by 1. - -Filename: src/main.rs - -```rust -let v1: Vec = vec![1, 2, 3]; - -let v2: Vec<_> = v1.iter().map(|x| x + 1).collect(); - -assert_eq!(v2, vec![2, 3, 4]); -``` - -Listing 13-18: Calling the `map` method to create a new -iterator and then calling the `collect` method to consume the new iterator and -create a vector - -Because `map` takes a closure, we can specify any operation we want to perform -on each item. This is a great example of how closures let you customize some -behavior while reusing the iteration behavior that the `Iterator` trait -provides. - -### Using Closures that Capture Their Environment - -Now that we’ve introduced iterators, we can demonstrate a common use of -closures that capture their environment by using the `filter` iterator adaptor. -The `filter` method on an iterator takes a closure that takes each item from -the iterator and returns a Boolean. If the closure returns `true`, the value -will be included in the iterator produced by `filter`. If the closure returns -`false`, the value won’t be included in the resulting iterator. - -In Listing 13-19, we use `filter` with a closure that captures the `shoe_size` -variable from its environment to iterate over a collection of `Shoe` struct -instances. It will return only shoes that are the specified size. - -Filename: src/lib.rs - -```rust -#[derive(PartialEq, Debug)] -struct Shoe { - size: u32, - style: String, -} - -fn shoes_in_my_size(shoes: Vec, shoe_size: u32) -> Vec { - shoes.into_iter() - .filter(|s| s.size == shoe_size) - .collect() -} - -#[test] -fn filters_by_size() { - let shoes = vec![ - Shoe { size: 10, style: String::from("sneaker") }, - Shoe { size: 13, style: String::from("sandal") }, - Shoe { size: 10, style: String::from("boot") }, - ]; - - let in_my_size = shoes_in_my_size(shoes, 10); - - assert_eq!( - in_my_size, - vec![ - Shoe { size: 10, style: String::from("sneaker") }, - Shoe { size: 10, style: String::from("boot") }, - ] - ); -} -``` - -Listing 13-19: Using the `filter` method with a closure -that captures `shoe_size` - -The `shoes_in_my_size` function takes ownership of a vector of shoes and a shoe -size as parameters. It returns a vector containing only shoes of the specified -size. - -In the body of `shoes_in_my_size`, we call `into_iter` to create an iterator -that takes ownership of the vector. Then we call `filter` to adapt that -iterator into a new iterator that only contains elements for which the closure -returns `true`. - -The closure captures the `shoe_size` parameter from the environment and -compares the value with each shoe’s size, keeping only shoes of the size -specified. Finally, calling `collect` gathers the values returned by the -adapted iterator into a vector that’s returned by the function. - -The test shows that when we call `shoes_in_my_size`, we get back only shoes -that have the same size as the value we specified. - -### Creating Our Own Iterators with the `Iterator` Trait - -We’ve shown that you can create an iterator by calling `iter`, `into_iter`, or -`iter_mut` on a vector. You can create iterators from the other collection -types in the standard library, such as hash map. You can also create iterators -that do anything you want by implementing the `Iterator` trait on your own -types. As previously mentioned, the only method you’re required to provide a -definition for is the `next` method. Once you’ve done that, you can use all -other methods that have default implementations provided by the `Iterator` -trait! - -To demonstrate, let’s create an iterator that will only ever count from 1 to 5. -First, we’ll create a struct to hold some values. Then we’ll make this struct -into an iterator by implementing the `Iterator` trait and using the values in -that implementation. - -Listing 13-20 has the definition of the `Counter` struct and an associated -`new` function to create instances of `Counter`: - -Filename: src/lib.rs - -```rust -struct Counter { - count: u32, -} - -impl Counter { - fn new() -> Counter { - Counter { count: 0 } - } -} -``` - -Listing 13-20: Defining the `Counter` struct and a `new` -function that creates instances of `Counter` with an initial value of 0 for -`count` - -The `Counter` struct has one field named `count`. This field holds a `u32` -value that will keep track of where we are in the process of iterating from 1 -to 5. The `count` field is private because we want the implementation of -`Counter` to manage its value. The `new` function enforces the behavior of -always starting new instances with a value of 0 in the `count` field. - -Next, we’ll implement the `Iterator` trait for our `Counter` type by defining -the body of the `next` method to specify what we want to happen when this -iterator is used, as shown in Listing 13-21: - -Filename: src/lib.rs - -```rust -# struct Counter { -# count: u32, -# } -# -impl Iterator for Counter { - type Item = u32; - - fn next(&mut self) -> Option { - self.count += 1; - - if self.count < 6 { - Some(self.count) - } else { - None - } - } -} -``` - -Listing 13-21: Implementing the `Iterator` trait on our -`Counter` struct - -We set the associated `Item` type for our iterator to `u32`, meaning the -iterator will return `u32` values. Again, don’t worry about associated types -yet, we’ll cover them in Chapter 19. - -We want our iterator to add 1 to the current state, so we initialized `count` -to 0 so it would return 1 first. If the value of `count` is less than 6, `next` -will return the current value wrapped in `Some`, but if `count` is 6 or higher, -our iterator will return `None`. - -#### Using Our `Counter` Iterator’s `next` Method - -Once we’ve implemented the `Iterator` trait, we have an iterator! Listing 13-22 -shows a test demonstrating that we can use the iterator functionality of our -`Counter` struct by calling the `next` method on it directly, just as we did -with the iterator created from a vector in Listing 13-15. - -Filename: src/lib.rs - -```rust -# struct Counter { -# count: u32, -# } -# -# impl Iterator for Counter { -# type Item = u32; -# -# fn next(&mut self) -> Option { -# self.count += 1; -# -# if self.count < 6 { -# Some(self.count) -# } else { -# None -# } -# } -# } -# -#[test] -fn calling_next_directly() { - let mut counter = Counter::new(); - - assert_eq!(counter.next(), Some(1)); - assert_eq!(counter.next(), Some(2)); - assert_eq!(counter.next(), Some(3)); - assert_eq!(counter.next(), Some(4)); - assert_eq!(counter.next(), Some(5)); - assert_eq!(counter.next(), None); -} -``` - -Listing 13-22: Testing the functionality of the `next` -method implementation - -This test creates a new `Counter` instance in the `counter` variable and then -calls `next` repeatedly, verifying that we have implemented the behavior we -want this iterator to have: returning the values from 1 to 5. - -#### Using Other `Iterator` Trait Methods - -We implemented the `Iterator` trait by defining the `next` method, so we -can now use any `Iterator` trait method’s default implementations as defined in -the standard library, because they all use the `next` method’s functionality. - -For example, if for some reason we wanted to take the values produced by an -instance of `Counter`, pair them with values produced by another `Counter` -instance after skipping the first value, multiply each pair together, keep only -those results that are divisible by 3, and add all the resulting values -together, we could do so, as shown in the test in Listing 13-23: - -Filename: src/lib.rs - -```rust -# struct Counter { -# count: u32, -# } -# -# impl Counter { -# fn new() -> Counter { -# Counter { count: 0 } -# } -# } -# -# impl Iterator for Counter { -# // Our iterator will produce u32s -# type Item = u32; -# -# fn next(&mut self) -> Option { -# // increment our count. This is why we started at zero. -# self.count += 1; -# -# // check to see if we've finished counting or not. -# if self.count < 6 { -# Some(self.count) -# } else { -# None -# } -# } -# } -# -#[test] -fn using_other_iterator_trait_methods() { - let sum: u32 = Counter::new().zip(Counter::new().skip(1)) - .map(|(a, b)| a * b) - .filter(|x| x % 3 == 0) - .sum(); - assert_eq!(18, sum); -} -``` - -Listing 13-23: Using a variety of `Iterator` trait -methods on our `Counter` iterator - -Note that `zip` produces only four pairs; the theoretical fifth pair `(5, -None)` is never produced because `zip` returns `None` when either of its input -iterators return `None`. - -All of these method calls are possible because we specified how the `next` -method works, and the standard library provides default implementations for -other methods that call `next`. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch13-02-iterators.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch13-03-improving-our-io-project.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch13-03-improving-our-io-project.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch13-03-improving-our-io-project.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch13-03-improving-our-io-project.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,240 +1,10 @@ ## Improving Our I/O Project -With this new knowledge about iterators, we can improve the I/O project in -Chapter 12 by using iterators to make places in the code clearer and more -concise. Let’s look at how iterators can improve our implementation of the -`Config::new` function and the `search` function. +The 2018 edition of the book is no longer distributed with Rust's documentation. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -### Removing a `clone` Using an Iterator - -In Listing 12-6, we added code that took a slice of `String` values and created -an instance of the `Config` struct by indexing into the slice and cloning the -values, allowing the `Config` struct to own those values. In Listing 13-24, -we’ve reproduced the implementation of the `Config::new` function as it was in -Listing 12-23: - -Filename: src/lib.rs - -```rust,ignore -impl Config { - pub fn new(args: &[String]) -> Result { - if args.len() < 3 { - return Err("not enough arguments"); - } - - let query = args[1].clone(); - let filename = args[2].clone(); - - let case_sensitive = env::var("CASE_INSENSITIVE").is_err(); - - Ok(Config { query, filename, case_sensitive }) - } -} -``` - -Listing 13-24: Reproduction of the `Config::new` function -from Listing 12-23 - -At the time, we said not to worry about the inefficient `clone` calls because -we would remove them in the future. Well, that time is now! - -We needed `clone` here because we have a slice with `String` elements in the -parameter `args`, but the `new` function doesn’t own `args`. To return -ownership of a `Config` instance, we had to clone the values from the `query` -and `filename` fields of `Config` so the `Config` instance can own its values. - -With our new knowledge about iterators, we can change the `new` function to -take ownership of an iterator as its argument instead of borrowing a slice. -We’ll use the iterator functionality instead of the code that checks the length -of the slice and indexes into specific locations. This will clarify what the -`Config::new` function is doing because the iterator will access the values. - -Once `Config::new` takes ownership of the iterator and stops using indexing -operations that borrow, we can move the `String` values from the iterator into -`Config` rather than calling `clone` and making a new allocation. - -#### Using the Returned Iterator Directly - -Open your I/O project’s *src/main.rs* file, which should look like this: - -Filename: src/main.rs - -```rust,ignore -fn main() { - let args: Vec = env::args().collect(); - - let config = Config::new(&args).unwrap_or_else(|err| { - eprintln!("Problem parsing arguments: {}", err); - process::exit(1); - }); - - // --snip-- -} -``` - -We’ll change the start of the `main` function that we had in Listing 12-24 at -to the code in Listing 13-25. This won’t compile until we update `Config::new` -as well. - -Filename: src/main.rs - -```rust,ignore -fn main() { - let config = Config::new(env::args()).unwrap_or_else(|err| { - eprintln!("Problem parsing arguments: {}", err); - process::exit(1); - }); - - // --snip-- -} -``` - -Listing 13-25: Passing the return value of `env::args` to -`Config::new` - -The `env::args` function returns an iterator! Rather than collecting the -iterator values into a vector and then passing a slice to `Config::new`, now -we’re passing ownership of the iterator returned from `env::args` to -`Config::new` directly. - -Next, we need to update the definition of `Config::new`. In your I/O project’s -*src/lib.rs* file, let’s change the signature of `Config::new` to look like -Listing 13-26. This still won’t compile because we need to update the function -body. - -Filename: src/lib.rs - -```rust,ignore -impl Config { - pub fn new(mut args: std::env::Args) -> Result { - // --snip-- -``` - -Listing 13-26: Updating the signature of `Config::new` to -expect an iterator - -The standard library documentation for the `env::args` function shows that the -type of the iterator it returns is `std::env::Args`. We’ve updated the -signature of the `Config::new` function so the parameter `args` has the type -`std::env::Args` instead of `&[String]`. Because we’re taking ownership of -`args` and we’ll be mutating `args` by iterating over it, we can add the `mut` -keyword into the specification of the `args` parameter to make it mutable. - -#### Using `Iterator` Trait Methods Instead of Indexing - -Next, we’ll fix the body of `Config::new`. The standard library documentation -also mentions that `std::env::Args` implements the `Iterator` trait, so we know -we can call the `next` method on it! Listing 13-27 updates the code from -Listing 12-23 to use the `next` method: - -Filename: src/lib.rs - -```rust -# fn main() {} -# use std::env; -# -# struct Config { -# query: String, -# filename: String, -# case_sensitive: bool, -# } -# -impl Config { - pub fn new(mut args: std::env::Args) -> Result { - args.next(); - - let query = match args.next() { - Some(arg) => arg, - None => return Err("Didn't get a query string"), - }; - - let filename = match args.next() { - Some(arg) => arg, - None => return Err("Didn't get a file name"), - }; - - let case_sensitive = env::var("CASE_INSENSITIVE").is_err(); - - Ok(Config { query, filename, case_sensitive }) - } -} -``` - -Listing 13-27: Changing the body of `Config::new` to use -iterator methods - -Remember that the first value in the return value of `env::args` is the name of -the program. We want to ignore that and get to the next value, so first we call -`next` and do nothing with the return value. Second, we call `next` to get the -value we want to put in the `query` field of `Config`. If `next` returns a -`Some`, we use a `match` to extract the value. If it returns `None`, it means -not enough arguments were given and we return early with an `Err` value. We do -the same thing for the `filename` value. - -### Making Code Clearer with Iterator Adaptors - -We can also take advantage of iterators in the `search` function in our I/O -project, which is reproduced here in Listing 13-28 as it was in Listing 12-19: - -Filename: src/lib.rs - -```rust,ignore -pub fn search<'a>(query: &str, contents: &'a str) -> Vec<&'a str> { - let mut results = Vec::new(); - - for line in contents.lines() { - if line.contains(query) { - results.push(line); - } - } - - results -} -``` - -Listing 13-28: The implementation of the `search` -function from Listing 12-19 - -We can write this code in a more concise way using iterator adaptor methods. -Doing so also lets us avoid having a mutable intermediate `results` vector. The -functional programming style prefers to minimize the amount of mutable state to -make code clearer. Removing the mutable state might enable a future enhancement -to make searching happen in parallel, because we wouldn’t have to manage -concurrent access to the `results` vector. Listing 13-29 shows this change: - -Filename: src/lib.rs - -```rust,ignore -pub fn search<'a>(query: &str, contents: &'a str) -> Vec<&'a str> { - contents.lines() - .filter(|line| line.contains(query)) - .collect() -} -``` - -Listing 13-29: Using iterator adaptor methods in the -implementation of the `search` function - -Recall that the purpose of the `search` function is to return all lines in -`contents` that contain the `query`. Similar to the `filter` example in Listing -13-19, this code uses the `filter` adaptor to keep only the lines that -`line.contains(query)` returns `true` for. We then collect the matching lines -into another vector with `collect`. Much simpler! Feel free to make the same -change to use iterator methods in the `search_case_insensitive` function as -well. - -The next logical question is which style you should choose in your own code and -why: the original implementation in Listing 13-28 or the version using -iterators in Listing 13-29. Most Rust programmers prefer to use the iterator -style. It’s a bit tougher to get the hang of at first, but once you get a feel -for the various iterator adaptors and what they do, iterators can be easier to -understand. Instead of fiddling with the various bits of looping and building -new vectors, the code focuses on the high-level objective of the loop. This -abstracts away some of the commonplace code so it’s easier to see the concepts -that are unique to this code, such as the filtering condition each element in -the iterator must pass. - -But are the two implementations truly equivalent? The intuitive assumption -might be that the more low-level loop will be faster. Let’s talk about -performance. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch13-03-improving-our-io-project.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch13-04-performance.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch13-04-performance.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch13-04-performance.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch13-04-performance.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,94 +1,10 @@ ## Comparing Performance: Loops vs. Iterators -To determine whether to use loops or iterators, you need to know which version -of our `search` functions is faster: the version with an explicit `for` loop or -the version with iterators. +The 2018 edition of the book is no longer distributed with Rust's documentation. -We ran a benchmark by loading the entire contents of *The Adventures of -Sherlock Holmes* by Sir Arthur Conan Doyle into a `String` and looking for the -word *the* in the contents. Here are the results of the benchmark on the -version of `search` using the `for` loop and the version using iterators: +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -```text -test bench_search_for ... bench: 19,620,300 ns/iter (+/- 915,700) -test bench_search_iter ... bench: 19,234,900 ns/iter (+/- 657,200) -``` - -The iterator version was slightly faster! We won’t explain the benchmark code -here, because the point is not to prove that the two versions are equivalent -but to get a general sense of how these two implementations compare -performance-wise. - -For a more comprehensive benchmark, you should check using various texts of -various sizes as the `contents`, different words and words of different lengths -as the `query`, and all kinds of other variations. The point is this: -iterators, although a high-level abstraction, get compiled down to roughly the -same code as if you’d written the lower-level code yourself. Iterators are one -of Rust’s *zero-cost abstractions*, by which we mean using the abstraction -imposes no additional runtime overhead. This is analogous to how Bjarne -Stroustrup, the original designer and implementor of C++, defines -*zero-overhead* in “Foundations of C++” (2012): - -> In general, C++ implementations obey the zero-overhead principle: What you -> don’t use, you don’t pay for. And further: What you do use, you couldn’t hand -> code any better. - -As another example, the following code is taken from an audio decoder. The -decoding algorithm uses the linear prediction mathematical operation to -estimate future values based on a linear function of the previous samples. This -code uses an iterator chain to do some math on three variables in scope: a -`buffer` slice of data, an array of 12 `coefficients`, and an amount by which -to shift data in `qlp_shift`. We’ve declared the variables within this example -but not given them any values; although this code doesn’t have much meaning -outside of its context, it’s still a concise, real-world example of how Rust -translates high-level ideas to low-level code. - -```rust,ignore -let buffer: &mut [i32]; -let coefficients: [i64; 12]; -let qlp_shift: i16; - -for i in 12..buffer.len() { - let prediction = coefficients.iter() - .zip(&buffer[i - 12..i]) - .map(|(&c, &s)| c * s as i64) - .sum::() >> qlp_shift; - let delta = buffer[i]; - buffer[i] = prediction as i32 + delta; -} -``` - -To calculate the value of `prediction`, this code iterates through each of the -12 values in `coefficients` and uses the `zip` method to pair the coefficient -values with the previous 12 values in `buffer`. Then, for each pair, we -multiply the values together, sum all the results, and shift the bits in the -sum `qlp_shift` bits to the right. - -Calculations in applications like audio decoders often prioritize performance -most highly. Here, we’re creating an iterator, using two adaptors, and then -consuming the value. What assembly code would this Rust code compile to? Well, -as of this writing, it compiles down to the same assembly you’d write by hand. -There’s no loop at all corresponding to the iteration over the values in -`coefficients`: Rust knows that there are 12 iterations, so it “unrolls” the -loop. *Unrolling* is an optimization that removes the overhead of the loop -controlling code and instead generates repetitive code for each iteration of -the loop. - -All of the coefficients get stored in registers, which means accessing the -values is very fast. There are no bounds checks on the array access at runtime. -All these optimizations that Rust is able to apply make the resulting code -extremely efficient. Now that you know this, you can use iterators and closures -without fear! They make code seem like it’s higher level but don’t impose a -runtime performance penalty for doing so. - -## Summary - -Closures and iterators are Rust features inspired by functional programming -language ideas. They contribute to Rust’s capability to clearly express -high-level ideas at low-level performance. The implementations of closures and -iterators are such that runtime performance is not affected. This is part of -Rust’s goal to strive to provide zero-cost abstractions. - -Now that we’ve improved the expressiveness of our I/O project, let’s look at -some more features of `cargo` that will help us share the project with the -world. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch13-04-performance.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-00-more-about-cargo.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-00-more-about-cargo.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-00-more-about-cargo.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-00-more-about-cargo.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,15 +1,10 @@ # More About Cargo and Crates.io -So far we’ve used only the most basic features of Cargo to build, run, and test -our code, but it can do a lot more. In this chapter, we’ll discuss some of its -other, more advanced features to show you how to do the following: +The 2018 edition of the book is no longer distributed with Rust's documentation. -* Customize your build through release profiles -* Publish libraries on [crates.io](https://crates.io) -* Organize large projects with workspaces -* Install binaries from [crates.io](https://crates.io) -* Extend Cargo using custom commands +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -Cargo can do even more than what we cover in this chapter, so for a full -explanation of all its features, see [its -documentation](https://doc.rust-lang.org/cargo/). +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch14-00-more-about-cargo.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-01-release-profiles.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-01-release-profiles.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-01-release-profiles.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-01-release-profiles.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,69 +1,10 @@ ## Customizing Builds with Release Profiles -In Rust, *release profiles* are predefined and customizable profiles with -different configurations that allow a programmer to have more control over -various options for compiling code. Each profile is configured independently of -the others. +The 2018 edition of the book is no longer distributed with Rust's documentation. -Cargo has two main profiles: the `dev` profile Cargo uses when you run `cargo -build` and the `release` profile Cargo uses when you run `cargo build ---release`. The `dev` profile is defined with good defaults for development, -and the `release` profile has good defaults for release builds. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -These profile names might be familiar from the output of your builds: - -```text -$ cargo build - Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs -$ cargo build --release - Finished release [optimized] target(s) in 0.0 secs -``` - -The `dev` and `release` shown in this build output indicate that the compiler -is using different profiles. - -Cargo has default settings for each of the profiles that apply when there -aren’t any `[profile.*]` sections in the project’s *Cargo.toml* file. By adding -`[profile.*]` sections for any profile you want to customize, you can override -any subset of the default settings. For example, here are the default values -for the `opt-level` setting for the `dev` and `release` profiles: - -Filename: Cargo.toml - -```toml -[profile.dev] -opt-level = 0 - -[profile.release] -opt-level = 3 -``` - -The `opt-level` setting controls the number of optimizations Rust will apply to -your code, with a range of 0 to 3. Applying more optimizations extends -compiling time, so if you’re in development and compiling your code often, -you'll want faster compiling even if the resulting code runs slower. That is -the reason the default `opt-level` for `dev` is `0`. When you’re ready to -release your code, it’s best to spend more time compiling. You’ll only compile -in release mode once, but you'll run the compiled program many times, so -release mode trades longer compile time for code that runs faster. That is why -the default `opt-level` for the `release` profile is `3`. - -You can override any default setting by adding a different value for it in -*Cargo.toml*. For example, if we want to use optimization level 1 in the -development profile, we can add these two lines to our project’s *Cargo.toml* -file: - -Filename: Cargo.toml - -```toml -[profile.dev] -opt-level = 1 -``` - -This code overrides the default setting of `0`. Now when we run `cargo build`, -Cargo will use the defaults for the `dev` profile plus our customization to -`opt-level`. Because we set `opt-level` to `1`, Cargo will apply more -optimizations than the default, but not as many as in a release build. - -For the full list of configuration options and defaults for each profile, see -[Cargo’s documentation](https://doc.rust-lang.org/cargo/). +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch14-01-release-profiles.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-02-publishing-to-crates-io.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-02-publishing-to-crates-io.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-02-publishing-to-crates-io.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-02-publishing-to-crates-io.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,516 +1,10 @@ ## Publishing a Crate to Crates.io -We’ve used packages from [crates.io](https://crates.io) as -dependencies of our project, but you can also share your code with other people -by publishing your own packages. The crate registry at -[crates.io](https://crates.io) distributes the source code of -your packages, so it primarily hosts code that is open source. +The 2018 edition of the book is no longer distributed with Rust's documentation. -Rust and Cargo have features that help make your published package easier for -people to use and to find in the first place. We’ll talk about some of these -features next and then explain how to publish a package. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -### Making Useful Documentation Comments - -Accurately documenting your packages will help other users know how and when to -use them, so it’s worth investing the time to write documentation. In Chapter -3, we discussed how to comment Rust code using two slashes, `//`. Rust also has -a particular kind of comment for documentation, known conveniently as a -*documentation comment*, that will generate HTML documentation. The HTML -displays the contents of documentation comments for public API items intended -for programmers interested in knowing how to *use* your crate as opposed to how -your crate is *implemented*. - -Documentation comments use three slashes, `///`, instead of two and support -Markdown notation for formatting the text. Place documentation comments just -before the item they’re documenting. Listing 14-1 shows documentation comments -for an `add_one` function in a crate named `my_crate`: - -Filename: src/lib.rs - -```rust,ignore -/// Adds one to the number given. -/// -/// # Examples -/// -/// ``` -/// let five = 5; -/// -/// assert_eq!(6, my_crate::add_one(5)); -/// ``` -pub fn add_one(x: i32) -> i32 { - x + 1 -} -``` - -Listing 14-1: A documentation comment for a -function - -Here, we give a description of what the `add_one` function does, start a -section with the heading `Examples`, and then provide code that demonstrates -how to use the `add_one` function. We can generate the HTML documentation from -this documentation comment by running `cargo doc`. This command runs the -`rustdoc` tool distributed with Rust and puts the generated HTML documentation -in the *target/doc* directory. - -For convenience, running `cargo doc --open` will build the HTML for your -current crate’s documentation (as well as the documentation for all of your -crate’s dependencies) and open the result in a web browser. Navigate to the -`add_one` function and you’ll see how the text in the documentation comments is -rendered, as shown in Figure 14-1: - -Rendered HTML documentation for the `add_one` function of `my_crate` - -Figure 14-1: HTML documentation for the `add_one` -function - -#### Commonly Used Sections - -We used the `# Examples` Markdown heading in Listing 14-1 to create a section -in the HTML with the title “Examples.” Here are some other sections that crate -authors commonly use in their documentation: - -* **Panics**: The scenarios in which the function being documented could - panic. Callers of the function who don’t want their programs to panic should - make sure they don’t call the function in these situations. -* **Errors**: If the function returns a `Result`, describing the kinds of - errors that might occur and what conditions might cause those errors to be - returned can be helpful to callers so they can write code to handle the - different kinds of errors in different ways. -* **Safety**: If the function is `unsafe` to call (we discuss unsafety in - Chapter 19), there should be a section explaining why the function is unsafe - and covering the invariants that the function expects callers to uphold. - -Most documentation comments don’t need all of these sections, but this is a -good checklist to remind you of the aspects of your code that people calling -your code will be interested in knowing about. - -#### Documentation Comments as Tests - -Adding example code blocks in your documentation comments can help demonstrate -how to use your library, and doing so has an additional bonus: running `cargo -test` will run the code examples in your documentation as tests! Nothing is -better than documentation with examples. But nothing is worse than examples -that don’t work because the code has changed since the documentation was -written. If we run `cargo test` with the documentation for the `add_one` -function from Listing 14-1, we will see a section in the test results like this: - -```text - Doc-tests my_crate - -running 1 test -test src/lib.rs - add_one (line 5) ... ok - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out -``` - -Now if we change either the function or the example so the `assert_eq!` in the -example panics and run `cargo test` again, we’ll see that the doc tests catch -that the example and the code are out of sync with each other! - -#### Commenting Contained Items - -Another style of doc comment, `//!`, adds documentation to the item that -contains the comments rather than adding documentation to the items following -the comments. We typically use these doc comments inside the crate root file -(*src/lib.rs* by convention) or inside a module to document the crate or the -module as a whole. - -For example, if we want to add documentation that describes the purpose of the -`my_crate` crate that contains the `add_one` function, we can add documentation -comments that start with `//!` to the beginning of the *src/lib.rs* file, as -shown in Listing 14-2: - -Filename: src/lib.rs - -```rust,ignore -//! # My Crate -//! -//! `my_crate` is a collection of utilities to make performing certain -//! calculations more convenient. - -/// Adds one to the number given. -// --snip-- -``` - -Listing 14-2: Documentation for the `my_crate` crate as a -whole - -Notice there isn’t any code after the last line that begins with `//!`. Because -we started the comments with `//!` instead of `///`, we’re documenting the item -that contains this comment rather than an item that follows this comment. In -this case, the item that contains this comment is the *src/lib.rs* file, which -is the crate root. These comments describe the entire crate. - -When we run `cargo doc --open`, these comments will display on the front -page of the documentation for `my_crate` above the list of public items in the -crate, as shown in Figure 14-2: - -Rendered HTML documentation with a comment for the crate as a whole - -Figure 14-2: Rendered documentation for `my_crate`, -including the comment describing the crate as a whole - -Documentation comments within items are useful for describing crates and -modules especially. Use them to explain the overall purpose of the container to -help your users understand the crate's organization. - -### Exporting a Convenient Public API with `pub use` - -In Chapter 7, we covered how to organize our code into modules using the `mod` -keyword, how to make items public using the `pub` keyword, and how to bring -items into a scope with the `use` keyword. However, the structure that makes -sense to you while you’re developing a crate might not be very convenient for -your users. You might want to organize your structs in a hierarchy containing -multiple levels, but then people who want to use a type you’ve defined deep in -the hierarchy might have trouble finding out that type exists. They might also -be annoyed at having to enter `use` -`my_crate::some_module::another_module::UsefulType;` rather than `use` -`my_crate::UsefulType;`. - -The structure of your public API is a major consideration when publishing a -crate. People who use your crate are less familiar with the structure than you -are and might have difficulty finding the pieces they want to use if your crate -has a large module hierarchy. - -The good news is that if the structure *isn’t* convenient for others to use -from another library, you don’t have to rearrange your internal organization: -instead, you can re-export items to make a public structure that’s different -from your private structure by using `pub use`. Re-exporting takes a public -item in one location and makes it public in another location, as if it were -defined in the other location instead. - -For example, say we made a library named `art` for modeling artistic concepts. -Within this library are two modules: a `kinds` module containing two enums -named `PrimaryColor` and `SecondaryColor` and a `utils` module containing a -function named `mix`, as shown in Listing 14-3: - -Filename: src/lib.rs - -```rust,ignore -//! # Art -//! -//! A library for modeling artistic concepts. - -pub mod kinds { - /// The primary colors according to the RYB color model. - pub enum PrimaryColor { - Red, - Yellow, - Blue, - } - - /// The secondary colors according to the RYB color model. - pub enum SecondaryColor { - Orange, - Green, - Purple, - } -} - -pub mod utils { - use kinds::*; - - /// Combines two primary colors in equal amounts to create - /// a secondary color. - pub fn mix(c1: PrimaryColor, c2: PrimaryColor) -> SecondaryColor { - // --snip-- - } -} -``` - -Listing 14-3: An `art` library with items organized into -`kinds` and `utils` modules - -Figure 14-3 shows what the front page of the documentation for this crate -generated by `cargo doc` would look like: - -Rendered documentation for the `art` crate that lists the `kinds` and `utils` modules - -Figure 14-3: Front page of the documentation for `art` -that lists the `kinds` and `utils` modules - -Note that the `PrimaryColor` and `SecondaryColor` types aren’t listed on the -front page, nor is the `mix` function. We have to click `kinds` and `utils` to -see them. - -Another crate that depends on this library would need `use` statements that -import the items from `art`, specifying the module structure that’s currently -defined. Listing 14-4 shows an example of a crate that uses the `PrimaryColor` -and `mix` items from the `art` crate: - -Filename: src/main.rs - -```rust,ignore -extern crate art; - -use art::kinds::PrimaryColor; -use art::utils::mix; - -fn main() { - let red = PrimaryColor::Red; - let yellow = PrimaryColor::Yellow; - mix(red, yellow); -} -``` - -Listing 14-4: A crate using the `art` crate’s items with -its internal structure exported - -The author of the code in Listing 14-4, which uses the `art` crate, had to -figure out that `PrimaryColor` is in the `kinds` module and `mix` is in the -`utils` module. The module structure of the `art` crate is more relevant to -developers working on the `art` crate than to developers using the `art` crate. -The internal structure that organizes parts of the crate into the `kinds` -module and the `utils` module doesn’t contain any useful information for -someone trying to understand how to use the `art` crate. Instead, the `art` -crate’s module structure causes confusion because developers have to figure out -where to look, and the structure is inconvenient because developers must -specify the module names in the `use` statements. - -To remove the internal organization from the public API, we can modify the -`art` crate code in Listing 14-3 to add `pub use` statements to re-export the -items at the top level, as shown in Listing 14-5: - -Filename: src/lib.rs - -```rust,ignore -//! # Art -//! -//! A library for modeling artistic concepts. - -pub use kinds::PrimaryColor; -pub use kinds::SecondaryColor; -pub use utils::mix; - -pub mod kinds { - // --snip-- -} - -pub mod utils { - // --snip-- -} -``` - -Listing 14-5: Adding `pub use` statements to re-export -items - -The API documentation that `cargo doc` generates for this crate will now list -and link re-exports on the front page, as shown in Figure 14-4, making the -`PrimaryColor` and `SecondaryColor` types and the `mix` function easier to find. - -Rendered documentation for the `art` crate with the re-exports on the front page - -Figure 14-4: The front page of the documentation for `art` -that lists the re-exports - -The `art` crate users can still see and use the internal structure from Listing -14-3 as demonstrated in Listing 14-4, or they can use the more convenient -structure in Listing 14-5, as shown in Listing 14-6: - -Filename: src/main.rs - -```rust,ignore -extern crate art; - -use art::PrimaryColor; -use art::mix; - -fn main() { - // --snip-- -} -``` - -Listing 14-6: A program using the re-exported items from -the `art` crate - -In cases where there are many nested modules, re-exporting the types at the top -level with `pub use` can make a significant difference in the experience of -people who use the crate. - -Creating a useful public API structure is more of an art than a science, and -you can iterate to find the API that works best for your users. Choosing `pub -use` gives you flexibility in how you structure your crate internally and -decouples that internal structure from what you present to your users. Look at -some of the code of crates you’ve installed to see if their internal structure -differs from their public API. - -### Setting Up a Crates.io Account - -Before you can publish any crates, you need to create an account on -[crates.io](https://crates.io) and get an API token. To do so, -visit the home page at [crates.io](https://crates.io) and log in -via a GitHub account. (The GitHub account is currently a requirement, but the -site might support other ways of creating an account in the future.) Once -you’re logged in, visit your account settings at -[https://crates.io/me/](https://crates.io/me/) and retrieve your -API key. Then run the `cargo login` command with your API key, like this: - -```text -$ cargo login abcdefghijklmnopqrstuvwxyz012345 -``` - -This command will inform Cargo of your API token and store it locally in -*~/.cargo/credentials*. Note that this token is a *secret*: do not share it -with anyone else. If you do share it with anyone for any reason, you should -revoke it and generate a new token on [crates.io](https://crates.io). - -### Adding Metadata to a New Crate - -Now that you have an account, let’s say you have a crate you want to publish. -Before publishing, you’ll need to add some metadata to your crate by adding it -to the `[package]` section of the crate’s *Cargo.toml* file. - -Your crate will need a unique name. While you’re working on a crate locally, -you can name a crate whatever you’d like. However, crate names on -[crates.io](https://crates.io) are allocated on a first-come, -first-served basis. Once a crate name is taken, no one else can publish a crate -with that name. Search for the name you want to use on the site to find out -whether it has been used. If it hasn’t, edit the name in the *Cargo.toml* file -under `[package]` to use the name for publishing, like so: - -Filename: Cargo.toml - -```toml -[package] -name = "guessing_game" -``` - -Even if you’ve chosen a unique name, when you run `cargo publish` to publish -the crate at this point, you’ll get a warning and then an error: - -```text -$ cargo publish - Updating registry `https://github.com/rust-lang/crates.io-index` -warning: manifest has no description, license, license-file, documentation, -homepage or repository. ---snip-- -error: api errors: missing or empty metadata fields: description, license. -``` - -The reason is that you’re missing some crucial information: a description and -license are required so people will know what your crate does and under what -terms they can use it. To rectify this error, you need to include this -information in the *Cargo.toml* file. - -Add a description that is just a sentence or two, because it will appear with -your crate in search results. For the `license` field, you need to give a -*license identifier value*. The [Linux Foundation’s Software Package Data -Exchange (SPDX)][spdx] lists the identifiers you can use for this value. For -example, to specify that you’ve licensed your crate using the MIT License, add -the `MIT` identifier: - -[spdx]: http://spdx.org/licenses/ - -Filename: Cargo.toml - -```toml -[package] -name = "guessing_game" -license = "MIT" -``` - -If you want to use a license that doesn’t appear in the SPDX, you need to place -the text of that license in a file, include the file in your project, and then -use `license-file` to specify the name of that file instead of using the -`license` key. - -Guidance on which license is appropriate for your project is beyond the scope -of this book. Many people in the Rust community license their projects in the -same way as Rust by using a dual license of `MIT OR Apache-2.0`. This practice -demonstrates that you can also specify multiple license identifiers separated -by `OR` to have multiple licenses for your project. - -With a unique name, the version, the author details that `cargo new` added -when you created the crate, your description, and a license added, the -*Cargo.toml* file for a project that is ready to publish might look like this: - -Filename: Cargo.toml - -```toml -[package] -name = "guessing_game" -version = "0.1.0" -authors = ["Your Name "] -description = "A fun game where you guess what number the computer has chosen." -license = "MIT OR Apache-2.0" - -[dependencies] -``` - -[Cargo’s documentation](https://doc.rust-lang.org/cargo/) describes other -metadata you can specify to ensure others can discover and use your crate more -easily. - -### Publishing to Crates.io - -Now that you’ve created an account, saved your API token, chosen a name for -your crate, and specified the required metadata, you’re ready to publish! -Publishing a crate uploads a specific version to -[crates.io](https://crates.io) for others to use. - -Be careful when publishing a crate because a publish is *permanent*. The -version can never be overwritten, and the code cannot be deleted. One major -goal of [crates.io](https://crates.io) is to act as a permanent -archive of code so that builds of all projects that depend on crates from -[crates.io](https://crates.io) will continue to work. Allowing -version deletions would make fulfilling that goal impossible. However, there is -no limit to the number of crate versions you can publish. - -Run the `cargo publish` command again. It should succeed now: - -```text -$ cargo publish - Updating registry `https://github.com/rust-lang/crates.io-index` -Packaging guessing_game v0.1.0 (file:///projects/guessing_game) -Verifying guessing_game v0.1.0 (file:///projects/guessing_game) -Compiling guessing_game v0.1.0 -(file:///projects/guessing_game/target/package/guessing_game-0.1.0) - Finished dev [unoptimized + debuginfo] target(s) in 0.19 secs -Uploading guessing_game v0.1.0 (file:///projects/guessing_game) -``` - -Congratulations! You’ve now shared your code with the Rust community, and -anyone can easily add your crate as a dependency of their project. - -### Publishing a New Version of an Existing Crate - -When you’ve made changes to your crate and are ready to release a new version, -you change the `version` value specified in your *Cargo.toml* file and -republish. Use the [Semantic Versioning rules][semver] to decide what an -appropriate next version number is based on the kinds of changes you’ve made. -Then run `cargo publish` to upload the new version. - -[semver]: http://semver.org/ - -### Removing Versions from Crates.io with `cargo yank` - -Although you can’t remove previous versions of a crate, you can prevent any -future projects from adding them as a new dependency. This is useful when a -crate version is broken for one reason or another. In such situations, Cargo -supports *yanking* a crate version. - -Yanking a version prevents new projects from starting to depend on that version -while allowing all existing projects that depend on it to continue to download -and depend on that version. Essentially, a yank means that all projects with a -*Cargo.lock* will not break, and any future *Cargo.lock* files generated will -not use the yanked version. - -To yank a version of a crate, run `cargo yank` and specify which version you -want to yank: - -```text -$ cargo yank --vers 1.0.1 -``` - -By adding `--undo` to the command, you can also undo a yank and allow projects -to start depending on a version again: - -```text -$ cargo yank --vers 1.0.1 --undo -``` - -A yank *does not* delete any code. For example, the yank feature is not -intended for deleting accidentally uploaded secrets. If that happens, you must -reset those secrets immediately. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch14-02-publishing-to-crates-io.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-03-cargo-workspaces.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-03-cargo-workspaces.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-03-cargo-workspaces.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-03-cargo-workspaces.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,336 +1,10 @@ ## Cargo Workspaces -In Chapter 12, we built a package that included a binary crate and a library -crate. As your project develops, you might find that the library crate -continues to get bigger and you want to split up your package further into -multiple library crates. In this situation, Cargo offers a feature called -*workspaces* that can help manage multiple related packages that are developed -in tandem. +The 2018 edition of the book is no longer distributed with Rust's documentation. -### Creating a Workspace +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -A *workspace* is a set of packages that share the same *Cargo.lock* and output -directory. Let’s make a project using a workspace—we’ll use trivial code so we -can concentrate on the structure of the workspace. There are multiple ways to -structure a workspace; we’re going to show one common way. We’ll have a -workspace containing a binary and two libraries. The binary, which will provide -the main functionality, will depend on the two libraries. One library will -provide an `add_one` function, and a second library an `add_two` function. -These three crates will be part of the same workspace. We’ll start by creating -a new directory for the workspace: - -```text -$ mkdir add -$ cd add -``` - -Next, in the *add* directory, we create the *Cargo.toml* file that will -configure the entire workspace. This file won’t have a `[package]` section or -the metadata we’ve seen in other *Cargo.toml* files. Instead, it will start -with a `[workspace]` section that will allow us to add members to the workspace -by specifying the path to our binary crate; in this case, that path is *adder*: - -Filename: Cargo.toml - -```toml -[workspace] - -members = [ - "adder", -] -``` - -Next, we’ll create the `adder` binary crate by running `cargo new` within the -*add* directory: - -```text -$ cargo new adder - Created binary (application) `adder` project -``` - -At this point, we can build the workspace by running `cargo build`. The files -in your *add* directory should look like this: - -```text -├── Cargo.lock -├── Cargo.toml -├── adder -│ ├── Cargo.toml -│ └── src -│ └── main.rs -└── target -``` - -The workspace has one *target* directory at the top level for the compiled -artifacts to be placed into; the `adder` crate doesn’t have its own *target* -directory. Even if we were to run `cargo build` from inside the *adder* -directory, the compiled artifacts would still end up in *add/target* rather -than *add/adder/target*. Cargo structures the *target* directory in a workspace -like this because the crates in a workspace are meant to depend on each other. -If each crate had its own *target* directory, each crate would have to -recompile each of the other crates in the workspace to have the artifacts in -its own *target* directory. By sharing one *target* directory, the crates can -avoid unnecessary rebuilding. - -### Creating the Second Crate in the Workspace - -Next, let’s create another member crate in the workspace and call it `add-one`. -Change the top-level *Cargo.toml* to specify the *add-one* path in the -`members` list: - -Filename: Cargo.toml - -```toml -[workspace] - -members = [ - "adder", - "add-one", -] -``` - -Then generate a new library crate named `add-one`: - -```text -$ cargo new add-one --lib - Created library `add-one` project -``` - -Your *add* directory should now have these directories and files: - -```text -├── Cargo.lock -├── Cargo.toml -├── add-one -│ ├── Cargo.toml -│ └── src -│ └── lib.rs -├── adder -│ ├── Cargo.toml -│ └── src -│ └── main.rs -└── target -``` - -In the *add-one/src/lib.rs* file, let’s add an `add_one` function: - -Filename: add-one/src/lib.rs - -```rust -pub fn add_one(x: i32) -> i32 { - x + 1 -} -``` - -Now that we have a library crate in the workspace, we can have the binary crate -`adder` depend on the library crate `add-one`. First, we’ll need to add a path -dependency on `add-one` to *adder/Cargo.toml*. - -Filename: adder/Cargo.toml - -```toml -[dependencies] - -add-one = { path = "../add-one" } -``` - -Cargo doesn’t assume that crates in a workspace will depend on each other, so -we need to be explicit about the dependency relationships between the crates. - -Next, let’s use the `add_one` function from the `add-one` crate in the `adder` -crate. Open the *adder/src/main.rs* file and add an `extern crate` line at -the top to bring the new `add-one` library crate into scope. Then change the -`main` function to call the `add_one` function, as in Listing 14-7: - -Filename: adder/src/main.rs - -```rust,ignore -extern crate add_one; - -fn main() { - let num = 10; - println!("Hello, world! {} plus one is {}!", num, add_one::add_one(num)); -} -``` - -Listing 14-7: Using the `add-one` library crate from the -`adder` crate - -Let’s build the workspace by running `cargo build` in the top-level *add* -directory! - -```text -$ cargo build - Compiling add-one v0.1.0 (file:///projects/add/add-one) - Compiling adder v0.1.0 (file:///projects/add/adder) - Finished dev [unoptimized + debuginfo] target(s) in 0.68 secs -``` - -To run the binary crate from the *add* directory, we need to specify which -package in the workspace we want to use by using the `-p` argument and the -package name with `cargo run`: - -```text -$ cargo run -p adder - Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs - Running `target/debug/adder` -Hello, world! 10 plus one is 11! -``` - -This runs the code in *adder/src/main.rs*, which depends on the `add-one` crate. - -#### Depending on an External Crate in a Workspace - -Notice that the workspace has only one *Cargo.lock* file at the top level of -the workspace rather than having a *Cargo.lock* in each crate’s directory. This -ensures that all crates are using the same version of all dependencies. If we -add the `rand` crate to the *adder/Cargo.toml* and *add-one/Cargo.toml* -files, Cargo will resolve both of those to one version of `rand` and record -that in the one *Cargo.lock*. Making all crates in the workspace use the same -dependencies means the crates in the workspace will always be compatible with -each other. Let’s add the `rand` crate to the `[dependencies]` section in the -*add-one/Cargo.toml* file to be able to use the `rand` crate in the `add-one` -crate: - -Filename: add-one/Cargo.toml - -```toml -[dependencies] - -rand = "0.3.14" -``` - -We can now add `extern crate rand;` to the *add-one/src/lib.rs* file, and -building the whole workspace by running `cargo build` in the *add* directory -will bring in and compile the `rand` crate: - -```text -$ cargo build - Updating registry `https://github.com/rust-lang/crates.io-index` - Downloading rand v0.3.14 - --snip-- - Compiling rand v0.3.14 - Compiling add-one v0.1.0 (file:///projects/add/add-one) - Compiling adder v0.1.0 (file:///projects/add/adder) - Finished dev [unoptimized + debuginfo] target(s) in 10.18 secs -``` - -The top-level *Cargo.lock* now contains information about the dependency of -`add-one` on `rand`. However, even though `rand` is used somewhere in the -workspace, we can’t use it in other crates in the workspace unless we add -`rand` to their *Cargo.toml* files as well. For example, if we add `extern -crate rand;` to the *adder/src/main.rs* file for the `adder` crate, we’ll get -an error: - -```text -$ cargo build - Compiling adder v0.1.0 (file:///projects/add/adder) -error: use of unstable library feature 'rand': use `rand` from crates.io (see -issue #27703) - --> adder/src/main.rs:1:1 - | -1 | extern crate rand; -``` - -To fix this, edit the *Cargo.toml* file for the `adder` crate and indicate that -`rand` is a dependency for that crate as well. Building the `adder` crate will -add `rand` to the list of dependencies for `adder` in *Cargo.lock*, but no -additional copies of `rand` will be downloaded. Cargo has ensured that every -crate in the workspace using the `rand` crate will be using the same version. -Using the same version of `rand` across the workspace saves space because we -won’t have multiple copies and ensures that the crates in the workspace will be -compatible with each other. - -#### Adding a Test to a Workspace - -For another enhancement, let’s add a test of the `add_one::add_one` function -within the `add_one` crate: - -Filename: add-one/src/lib.rs - -```rust -pub fn add_one(x: i32) -> i32 { - x + 1 -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn it_works() { - assert_eq!(3, add_one(2)); - } -} -``` - -Now run `cargo test` in the top-level *add* directory: - -```text -$ cargo test - Compiling add-one v0.1.0 (file:///projects/add/add-one) - Compiling adder v0.1.0 (file:///projects/add/adder) - Finished dev [unoptimized + debuginfo] target(s) in 0.27 secs - Running target/debug/deps/add_one-f0253159197f7841 - -running 1 test -test tests::it_works ... ok - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out - - Running target/debug/deps/adder-f88af9d2cc175a5e - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out - - Doc-tests add-one - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out -``` - -The first section of the output shows that the `it_works` test in the `add-one` -crate passed. The next section shows that zero tests were found in the `adder` -crate, and then the last section shows zero documentation tests were found in -the `add-one` crate. Running `cargo test` in a workspace structured like this -one will run the tests for all the crates in the workspace. - -We can also run tests for one particular crate in a workspace from the -top-level directory by using the `-p` flag and specifying the name of the crate -we want to test: - -```text -$ cargo test -p add-one - Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs - Running target/debug/deps/add_one-b3235fea9a156f74 - -running 1 test -test tests::it_works ... ok - -test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out - - Doc-tests add-one - -running 0 tests - -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out -``` - -This output shows `cargo test` only ran the tests for the `add-one` crate and -didn’t run the `adder` crate tests. - -If you publish the crates in the workspace to *https://crates.io/*, each crate -in the workspace will need to be published separately. The `cargo publish` -command does not have an `--all` flag or a `-p` flag, so you must change to -each crate’s directory and run `cargo publish` on each crate in the workspace -to publish the crates. - -For additional practice, add an `add-two` crate to this workspace in a similar -way as the `add-one` crate! - -As your project grows, consider using a workspace: it’s easier to understand -smaller, individual components than one big blob of code. Furthermore, keeping -the crates in a workspace can make coordination between them easier if they are -often changed at the same time. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch14-03-cargo-workspaces.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-04-installing-binaries.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-04-installing-binaries.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-04-installing-binaries.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-04-installing-binaries.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,37 +1,10 @@ ## Installing Binaries from Crates.io with `cargo install` -The `cargo install` command allows you to install and use binary crates -locally. This isn’t intended to replace system packages; it’s meant to be a -convenient way for Rust developers to install tools that others have shared on -[crates.io](https://crates.io). Note that you can only install -packages that have binary targets. A *binary target* is the runnable program -that is created if the crate has a *src/main.rs* file or another file specified -as a binary, as opposed to a library target that isn’t runnable on its own but -is suitable for including within other programs. Usually, crates have -information in the *README* file about whether a crate is a library, has a -binary target, or both. +The 2018 edition of the book is no longer distributed with Rust's documentation. -All binaries installed with `cargo install` are stored in the installation -root’s *bin* folder. If you installed Rust using *rustup.rs* and don’t have any -custom configurations, this directory will be *$HOME/.cargo/bin*. Ensure that -directory is in your `$PATH` to be able to run programs you’ve installed with -`cargo install`. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -For example, in Chapter 12 we mentioned that there’s a Rust implementation of -the `grep` tool called `ripgrep` for searching files. If we want to install -`ripgrep`, we can run the following: - -```text -$ cargo install ripgrep -Updating registry `https://github.com/rust-lang/crates.io-index` - Downloading ripgrep v0.3.2 - --snip-- - Compiling ripgrep v0.3.2 - Finished release [optimized + debuginfo] target(s) in 97.91 secs - Installing ~/.cargo/bin/rg -``` - -The last line of the output shows the location and the name of the installed -binary, which in the case of `ripgrep` is `rg`. As long as the installation -directory is in your `$PATH`, as mentioned previously, you can then run `rg ---help` and start using a faster, rustier tool for searching files! +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch14-04-installing-binaries.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-05-extending-cargo.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-05-extending-cargo.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-05-extending-cargo.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch14-05-extending-cargo.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,17 +1,10 @@ ## Extending Cargo with Custom Commands -Cargo is designed so you can extend it with new subcommands without having to -modify Cargo. If a binary in your `$PATH` is named `cargo-something`, you can -run it as if it was a Cargo subcommand by running `cargo something`. Custom -commands like this are also listed when you run `cargo --list`. Being able to -use `cargo install` to install extensions and then run them just like the -built-in Cargo tools is a super convenient benefit of Cargo’s design! +The 2018 edition of the book is no longer distributed with Rust's documentation. -## Summary +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -Sharing code with Cargo and [crates.io](https://crates.io) is -part of what makes the Rust ecosystem useful for many different tasks. Rust’s -standard library is small and stable, but crates are easy to share, use, and -improve on a timeline different from that of the language. Don’t be shy about -sharing code that’s useful to you on [crates.io](https://crates.io); it’s likely that it will be useful to someone else as well! +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch14-05-extending-cargo.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-00-smart-pointers.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-00-smart-pointers.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-00-smart-pointers.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-00-smart-pointers.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,56 +1,10 @@ # Smart Pointers -A *pointer* is a general concept for a variable that contains an address in -memory. This address refers to, or “points at,” some other data. The most -common kind of pointer in Rust is a reference, which you learned about in -Chapter 4. References are indicated by the `&` symbol and borrow the value they -point to. They don’t have any special capabilities other than referring to -data. Also, they don’t have any overhead and are the kind of pointer we use -most often. +The 2018 edition of the book is no longer distributed with Rust's documentation. -*Smart pointers*, on the other hand, are data structures that not only act like -a pointer but also have additional metadata and capabilities. The concept of -smart pointers isn’t unique to Rust: smart pointers originated in C++ and exist -in other languages as well. In Rust, the different smart pointers defined in -the standard library provide functionality beyond that provided by references. -One example that we’ll explore in this chapter is the *reference counting* -smart pointer type. This pointer enables you to have multiple owners of data by -keeping track of the number of owners and, when no owners remain, cleaning up -the data. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -In Rust, which uses the concept of ownership and borrowing, an additional -difference between references and smart pointers is that references are -pointers that only borrow data; in contrast, in many cases, smart pointers -*own* the data they point to. - -We’ve already encountered a few smart pointers in this book, such as `String` -and `Vec` in Chapter 8, although we didn’t call them smart pointers at the -time. Both these types count as smart pointers because they own some memory and -allow you to manipulate it. They also have metadata (such as their capacity) -and extra capabilities or guarantees (such as with `String` ensuring its data -will always be valid UTF-8). - -Smart pointers are usually implemented using structs. The characteristic that -distinguishes a smart pointer from an ordinary struct is that smart pointers -implement the `Deref` and `Drop` traits. The `Deref` trait allows an instance -of the smart pointer struct to behave like a reference so you can write code -that works with either references or smart pointers. The `Drop` trait allows -you to customize the code that is run when an instance of the smart pointer -goes out of scope. In this chapter, we’ll discuss both traits and demonstrate -why they’re important to smart pointers. - -Given that the smart pointer pattern is a general design pattern used -frequently in Rust, this chapter won’t cover every existing smart pointer. Many -libraries have their own smart pointers, and you can even write your own. We’ll -cover the most common smart pointers in the standard library: - -* `Box` for allocating values on the heap -* `Rc`, a reference counting type that enables multiple ownership -* `Ref` and `RefMut`, accessed through `RefCell`, a type that enforces - the borrowing rules at runtime instead of compile time - -In addition, we’ll cover the *interior mutability* pattern where an immutable -type exposes an API for mutating an interior value. We’ll also discuss -*reference cycles*: how they can leak memory and how to prevent them. - -Let’s dive in! +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch15-00-smart-pointers.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-01-box.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-01-box.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-01-box.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-01-box.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,280 +1,10 @@ ## Using `Box` to Point to Data on the Heap -The most straightforward smart pointer is a *box*, whose type is written -`Box`. Boxes allow you to store data on the heap rather than the stack. What -remains on the stack is the pointer to the heap data. Refer to Chapter 4 to -review the difference between the stack and the heap. +The 2018 edition of the book is no longer distributed with Rust's documentation. -Boxes don’t have performance overhead, other than storing their data on the -heap instead of on the stack. But they don’t have many extra capabilities -either. You’ll use them most often in these situations: +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -* When you have a type whose size can’t be known at compile time and you want - to use a value of that type in a context that requires an exact size -* When you have a large amount of data and you want to transfer ownership but - ensure the data won’t be copied when you do so -* When you want to own a value and you care only that it’s a type that - implements a particular trait rather than being of a specific type - -We’ll demonstrate the first situation in the “Enabling Recursive Types with -Boxes” section. In the second case, transferring ownership of a large amount of -data can take a long time because the data is copied around on the stack. To -improve performance in this situation, we can store the large amount of data on -the heap in a box. Then, only the small amount of pointer data is copied around -on the stack, while the data it references stays in one place on the heap. The -third case is known as a *trait object*, and Chapter 17 devotes an entire -section, “Using Trait Objects That Allow for Values of Different Types,” just -to that topic. So what you learn here you’ll apply again in Chapter 17! - -### Using a `Box` to Store Data on the Heap - -Before we discuss this use case for `Box`, we’ll cover the syntax and how to -interact with values stored within a `Box`. - -Listing 15-1 shows how to use a box to store an `i32` value on the heap: - -Filename: src/main.rs - -```rust -fn main() { - let b = Box::new(5); - println!("b = {}", b); -} -``` - -Listing 15-1: Storing an `i32` value on the heap using a -box - -We define the variable `b` to have the value of a `Box` that points to the -value `5`, which is allocated on the heap. This program will print `b = 5`; in -this case, we can access the data in the box similar to how we would if this -data were on the stack. Just like any owned value, when a box goes out of -scope, as `b` does at the end of `main`, it will be deallocated. The -deallocation happens for the box (stored on the stack) and the data it points -to (stored on the heap). - -Putting a single value on the heap isn’t very useful, so you won’t use boxes by -themselves in this way very often. Having values like a single `i32` on the -stack, where they’re stored by default, is more appropriate in the majority of -situations. Let’s look at a case where boxes allow us to define types that we -wouldn’t be allowed to if we didn’t have boxes. - -### Enabling Recursive Types with Boxes - -At compile time, Rust needs to know how much space a type takes up. One type -whose size can’t be known at compile time is a *recursive type*, where a value -can have as part of itself another value of the same type. Because this nesting -of values could theoretically continue infinitely, Rust doesn’t know how much -space a value of a recursive type needs. However, boxes have a known size, so -by inserting a box in a recursive type definition, you can have recursive types. - -Let’s explore the *cons list*, which is a data type common in functional -programming languages, as an example of a recursive type. The cons list type -we’ll define is straightforward except for the recursion; therefore, the -concepts in the example we’ll work with will be useful any time you get into -more complex situations involving recursive types. - -#### More Information About the Cons List - -A *cons list* is a data structure that comes from the Lisp programming language -and its dialects. In Lisp, the `cons` function (short for “construct function”) -constructs a new pair from its two arguments, which usually are a single value -and another pair. These pairs containing pairs form a list. - -The cons function concept has made its way into more general functional -programming jargon: “to cons *x* onto *y*” informally means to construct a new -container instance by putting the element *x* at the start of this new -container, followed by the container *y*. - -Each item in a cons list contains two elements: the value of the current item -and the next item. The last item in the list contains only a value called `Nil` -without a next item. A cons list is produced by recursively calling the `cons` -function. The canonical name to denote the base case of the recursion is `Nil`. -Note that this is not the same as the “null” or “nil” concept in Chapter 6, -which is an invalid or absent value. - -Although functional programming languages use cons lists frequently, the cons -list isn’t a commonly used data structure in Rust. Most of the time when you -have a list of items in Rust, `Vec` is a better choice to use. Other, more -complex recursive data types *are* useful in various situations, but by -starting with the cons list, we can explore how boxes let us define a recursive -data type without much distraction. - -Listing 15-2 contains an enum definition for a cons list. Note that this code -won’t compile yet because the `List` type doesn’t have a known size, which -we’ll demonstrate. - -Filename: src/main.rs - -```rust,ignore -enum List { - Cons(i32, List), - Nil, -} -``` - -Listing 15-2: The first attempt at defining an enum to -represent a cons list data structure of `i32` values - -> Note: We’re implementing a cons list that holds only `i32` values for the -> purposes of this example. We could have implemented it using generics, as we -> discussed in Chapter 10, to define a cons list type that could store values of -> any type. - -Using the `List` type to store the list `1, 2, 3` would look like the code in -Listing 15-3: - -Filename: src/main.rs - -```rust,ignore -use List::{Cons, Nil}; - -fn main() { - let list = Cons(1, Cons(2, Cons(3, Nil))); -} -``` - -Listing 15-3: Using the `List` enum to store the list `1, -2, 3` - -The first `Cons` value holds `1` and another `List` value. This `List` value is -another `Cons` value that holds `2` and another `List` value. This `List` value -is one more `Cons` value that holds `3` and a `List` value, which is finally -`Nil`, the non-recursive variant that signals the end of the list. - -If we try to compile the code in Listing 15-3, we get the error shown in -Listing 15-4: - -```text -error[E0072]: recursive type `List` has infinite size - --> src/main.rs:1:1 - | -1 | enum List { - | ^^^^^^^^^ recursive type has infinite size -2 | Cons(i32, List), - | ----- recursive without indirection - | - = help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to - make `List` representable -``` - -Listing 15-4: The error we get when attempting to define -a recursive enum - -The error shows this type “has infinite size.” The reason is that we’ve defined -`List` with a variant that is recursive: it holds another value of itself -directly. As a result, Rust can’t figure out how much space it needs to store a -`List` value. Let’s break down why we get this error a bit. First, let’s look -at how Rust decides how much space it needs to store a value of a non-recursive -type. - -#### Computing the Size of a Non-Recursive Type - -Recall the `Message` enum we defined in Listing 6-2 when we discussed enum -definitions in Chapter 6: - -```rust -enum Message { - Quit, - Move { x: i32, y: i32 }, - Write(String), - ChangeColor(i32, i32, i32), -} -``` - -To determine how much space to allocate for a `Message` value, Rust goes -through each of the variants to see which variant needs the most space. Rust -sees that `Message::Quit` doesn’t need any space, `Message::Move` needs enough -space to store two `i32` values, and so forth. Because only one variant will be -used, the most space a `Message` value will need is the space it would take to -store the largest of its variants. - -Contrast this with what happens when Rust tries to determine how much space a -recursive type like the `List` enum in Listing 15-2 needs. The compiler starts -by looking at the `Cons` variant, which holds a value of type `i32` and a value -of type `List`. Therefore, `Cons` needs an amount of space equal to the size of -an `i32` plus the size of a `List`. To figure out how much memory the `List` -type needs, the compiler looks at the variants, starting with the `Cons` -variant. The `Cons` variant holds a value of type `i32` and a value of type -`List`, and this process continues infinitely, as shown in Figure 15-1. - -An infinite Cons list - -Figure 15-1: An infinite `List` consisting of infinite -`Cons` variants - -#### Using `Box` to Get a Recursive Type with a Known Size - -Rust can’t figure out how much space to allocate for recursively defined types, -so the compiler gives the error in Listing 15-4. But the error does include -this helpful suggestion: - -```text - = help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to - make `List` representable -``` - -In this suggestion, “indirection” means that instead of storing a value -directly, we’ll change the data structure to store the value indirectly by -storing a pointer to the value instead. - -Because a `Box` is a pointer, Rust always knows how much space a `Box` -needs: a pointer’s size doesn’t change based on the amount of data it’s -pointing to. This means we can put a `Box` inside the `Cons` variant instead -of another `List` value directly. The `Box` will point to the next `List` -value that will be on the heap rather than inside the `Cons` variant. -Conceptually, we still have a list, created with lists “holding” other lists, -but this implementation is now more like placing the items next to one another -rather than inside one another. - -We can change the definition of the `List` enum in Listing 15-2 and the usage -of the `List` in Listing 15-3 to the code in Listing 15-5, which will compile: - -Filename: src/main.rs - -```rust -enum List { - Cons(i32, Box), - Nil, -} - -use List::{Cons, Nil}; - -fn main() { - let list = Cons(1, - Box::new(Cons(2, - Box::new(Cons(3, - Box::new(Nil)))))); -} -``` - -Listing 15-5: Definition of `List` that uses `Box` in -order to have a known size - -The `Cons` variant will need the size of an `i32` plus the space to store the -box’s pointer data. The `Nil` variant stores no values, so it needs less space -than the `Cons` variant. We now know that any `List` value will take up the -size of an `i32` plus the size of a box’s pointer data. By using a box, we’ve -broken the infinite, recursive chain, so the compiler can figure out the size -it needs to store a `List` value. Figure 15-2 shows what the `Cons` variant -looks like now. - -A finite Cons list - -Figure 15-2: A `List` that is not infinitely sized -because `Cons` holds a `Box` - -Boxes provide only the indirection and heap allocation; they don’t have any -other special capabilities, like those we’ll see with the other smart pointer -types. They also don’t have any performance overhead that these special -capabilities incur, so they can be useful in cases like the cons list where the -indirection is the only feature we need. We’ll look at more use cases for boxes -in Chapter 17, too. - -The `Box` type is a smart pointer because it implements the `Deref` trait, -which allows `Box` values to be treated like references. When a `Box` -value goes out of scope, the heap data that the box is pointing to is cleaned -up as well because of the `Drop` trait implementation. Let’s explore these two -traits in more detail. These two traits will be even more important to the -functionality provided by the other smart pointer types we’ll discuss in the -rest of this chapter. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch15-01-box.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-02-deref.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-02-deref.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-02-deref.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-02-deref.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,382 +1,10 @@ ## Treating Smart Pointers Like Regular References with the `Deref` Trait -Implementing the `Deref` trait allows you to customize the behavior of the -*dereference operator*, `*` (as opposed to the multiplication or glob -operator). By implementing `Deref` in such a way that a smart pointer can be -treated like a regular reference, you can write code that operates on -references and use that code with smart pointers too. +The 2018 edition of the book is no longer distributed with Rust's documentation. -Let’s first look at how the dereference operator works with regular references. -Then we’ll try to define a custom type that behaves like `Box`, and see why -the dereference operator doesn’t work like a reference on our newly defined -type. We’ll explore how implementing the `Deref` trait makes it possible for -smart pointers to work in a similar way as references. Then we’ll look at -Rust’s *deref coercion* feature and how it lets us work with either references -or smart pointers. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -> There's one big difference between the `MyBox` type we're about to build -> and the real `Box`: our version will not store its data on the heap. We -> are focusing this example on `Deref`, and so where the data is actually stored -> is less important than the pointer-like behavior. - -### Following the Pointer to the Value with the Dereference Operator - -A regular reference is a type of pointer, and one way to think of a pointer is -as an arrow to a value stored somewhere else. In Listing 15-6, we create a -reference to an `i32` value and then use the dereference operator to follow the -reference to the data: - -Filename: src/main.rs - -```rust -fn main() { - let x = 5; - let y = &x; - - assert_eq!(5, x); - assert_eq!(5, *y); -} -``` - -Listing 15-6: Using the dereference operator to follow a -reference to an `i32` value - -The variable `x` holds an `i32` value, `5`. We set `y` equal to a reference to -`x`. We can assert that `x` is equal to `5`. However, if we want to make an -assertion about the value in `y`, we have to use `*y` to follow the reference -to the value it’s pointing to (hence *dereference*). Once we dereference `y`, -we have access to the integer value `y` is pointing to that we can compare with -`5`. - -If we tried to write `assert_eq!(5, y);` instead, we would get this compilation -error: - -```text -error[E0277]: the trait bound `{integer}: std::cmp::PartialEq<&{integer}>` is -not satisfied - --> src/main.rs:6:5 - | -6 | assert_eq!(5, y); - | ^^^^^^^^^^^^^^^^^ can't compare `{integer}` with `&{integer}` - | - = help: the trait `std::cmp::PartialEq<&{integer}>` is not implemented for - `{integer}` -``` - -Comparing a number and a reference to a number isn’t allowed because they’re -different types. We must use the dereference operator to follow the reference -to the value it’s pointing to. - -### Using `Box` Like a Reference - -We can rewrite the code in Listing 15-6 to use a `Box` instead of a -reference; the dereference operator will work as shown in Listing 15-7: - -Filename: src/main.rs - -```rust -fn main() { - let x = 5; - let y = Box::new(x); - - assert_eq!(5, x); - assert_eq!(5, *y); -} -``` - -Listing 15-7: Using the dereference operator on a -`Box` - -The only difference between Listing 15-7 and Listing 15-6 is that here we set -`y` to be an instance of a box pointing to the value in `x` rather than a -reference pointing to the value of `x`. In the last assertion, we can use the -dereference operator to follow the box’s pointer in the same way that we did -when `y` was a reference. Next, we’ll explore what is special about `Box` -that enables us to use the dereference operator by defining our own box type. - -### Defining Our Own Smart Pointer - -Let’s build a smart pointer similar to the `Box` type provided by the -standard library to experience how smart pointers behave differently than -references by default. Then we’ll look at how to add the ability to use the -dereference operator. - -The `Box` type is ultimately defined as a tuple struct with one element, so -Listing 15-8 defines a `MyBox` type in the same way. We’ll also define a -`new` function to match the `new` function defined on `Box`. - -Filename: src/main.rs - -```rust -struct MyBox(T); - -impl MyBox { - fn new(x: T) -> MyBox { - MyBox(x) - } -} -``` - -Listing 15-8: Defining a `MyBox` type - -We define a struct named `MyBox` and declare a generic parameter `T`, because -we want our type to hold values of any type. The `MyBox` type is a tuple struct -with one element of type `T`. The `MyBox::new` function takes one parameter of -type `T` and returns a `MyBox` instance that holds the value passed in. - -Let’s try adding the `main` function in Listing 15-7 to Listing 15-8 and -changing it to use the `MyBox` type we’ve defined instead of `Box`. The -code in Listing 15-9 won’t compile because Rust doesn’t know how to dereference -`MyBox`. - -Filename: src/main.rs - -```rust,ignore -fn main() { - let x = 5; - let y = MyBox::new(x); - - assert_eq!(5, x); - assert_eq!(5, *y); -} -``` - -Listing 15-9: Attempting to use `MyBox` in the same -way we used references and `Box` - -Here’s the resulting compilation error: - -```text -error[E0614]: type `MyBox<{integer}>` cannot be dereferenced - --> src/main.rs:14:19 - | -14 | assert_eq!(5, *y); - | ^^ -``` - -Our `MyBox` type can’t be dereferenced because we haven’t implemented that -ability on our type. To enable dereferencing with the `*` operator, we -implement the `Deref` trait. - -### Treating a Type Like a Reference by Implementing the `Deref` Trait - -As discussed in Chapter 10, to implement a trait, we need to provide -implementations for the trait’s required methods. The `Deref` trait, provided -by the standard library, requires us to implement one method named `deref` that -borrows `self` and returns a reference to the inner data. Listing 15-10 -contains an implementation of `Deref` to add to the definition of `MyBox`: - -Filename: src/main.rs - -```rust -use std::ops::Deref; - -# struct MyBox(T); -impl Deref for MyBox { - type Target = T; - - fn deref(&self) -> &T { - &self.0 - } -} -``` - -Listing 15-10: Implementing `Deref` on `MyBox` - -The `type Target = T;` syntax defines an associated type for the `Deref` trait -to use. Associated types are a slightly different way of declaring a generic -parameter, but you don’t need to worry about them for now; we’ll cover them in -more detail in Chapter 19. - -We fill in the body of the `deref` method with `&self.0` so `deref` returns a -reference to the value we want to access with the `*` operator. The `main` -function in Listing 15-9 that calls `*` on the `MyBox` value now compiles, -and the assertions pass! - -Without the `Deref` trait, the compiler can only dereference `&` references. -The `deref` method gives the compiler the ability to take a value of any type -that implements `Deref` and call the `deref` method to get a `&` reference that -it knows how to dereference. - -When we entered `*y` in Listing 15-9, behind the scenes Rust actually ran this -code: - -```rust,ignore -*(y.deref()) -``` - -Rust substitutes the `*` operator with a call to the `deref` method and then a -plain dereference so we don’t have to think about whether or not we need to -call the `deref` method. This Rust feature lets us write code that functions -identically whether we have a regular reference or a type that implements -`Deref`. - -The reason the `deref` method returns a reference to a value, and that the plain -dereference outside the parentheses in `*(y.deref())` is still necessary, is the -ownership system. If the `deref` method returned the value directly instead of -a reference to the value, the value would be moved out of `self`. We don’t want -to take ownership of the inner value inside `MyBox` in this case or in most -cases where we use the dereference operator. - -Note that the `*` operator is replaced with a call to the `deref` method and -then a call to the `*` operator just once, each time we use a `*` in our code. -Because the substitution of the `*` operator does not recurse infinitely, we -end up with data of type `i32`, which matches the `5` in `assert_eq!` in -Listing 15-9. - -### Implicit Deref Coercions with Functions and Methods - -*Deref coercion* is a convenience that Rust performs on arguments to functions -and methods. Deref coercion converts a reference to a type that implements -`Deref` into a reference to a type that `Deref` can convert the original type -into. Deref coercion happens automatically when we pass a reference to a -particular type’s value as an argument to a function or method that doesn’t -match the parameter type in the function or method definition. A sequence of -calls to the `deref` method converts the type we provided into the type the -parameter needs. - -Deref coercion was added to Rust so that programmers writing function and -method calls don’t need to add as many explicit references and dereferences -with `&` and `*`. The deref coercion feature also lets us write more code that -can work for either references or smart pointers. - -To see deref coercion in action, let’s use the `MyBox` type we defined in -Listing 15-8 as well as the implementation of `Deref` that we added in Listing -15-10. Listing 15-11 shows the definition of a function that has a string slice -parameter: - -Filename: src/main.rs - -```rust -fn hello(name: &str) { - println!("Hello, {}!", name); -} -``` - -Listing 15-11: A `hello` function that has the parameter -`name` of type `&str` - -We can call the `hello` function with a string slice as an argument, such as -`hello("Rust");` for example. Deref coercion makes it possible to call `hello` -with a reference to a value of type `MyBox`, as shown in Listing 15-12: - -Filename: src/main.rs - -```rust -# use std::ops::Deref; -# -# struct MyBox(T); -# -# impl MyBox { -# fn new(x: T) -> MyBox { -# MyBox(x) -# } -# } -# -# impl Deref for MyBox { -# type Target = T; -# -# fn deref(&self) -> &T { -# &self.0 -# } -# } -# -# fn hello(name: &str) { -# println!("Hello, {}!", name); -# } -# -fn main() { - let m = MyBox::new(String::from("Rust")); - hello(&m); -} -``` - -Listing 15-12: Calling `hello` with a reference to a -`MyBox` value, which works because of deref coercion - -Here we’re calling the `hello` function with the argument `&m`, which is a -reference to a `MyBox` value. Because we implemented the `Deref` trait -on `MyBox` in Listing 15-10, Rust can turn `&MyBox` into `&String` -by calling `deref`. The standard library provides an implementation of `Deref` -on `String` that returns a string slice, and this is in the API documentation -for `Deref`. Rust calls `deref` again to turn the `&String` into `&str`, which -matches the `hello` function’s definition. - -If Rust didn’t implement deref coercion, we would have to write the code in -Listing 15-13 instead of the code in Listing 15-12 to call `hello` with a value -of type `&MyBox`. - -Filename: src/main.rs - -```rust -# use std::ops::Deref; -# -# struct MyBox(T); -# -# impl MyBox { -# fn new(x: T) -> MyBox { -# MyBox(x) -# } -# } -# -# impl Deref for MyBox { -# type Target = T; -# -# fn deref(&self) -> &T { -# &self.0 -# } -# } -# -# fn hello(name: &str) { -# println!("Hello, {}!", name); -# } -# -fn main() { - let m = MyBox::new(String::from("Rust")); - hello(&(*m)[..]); -} -``` - -Listing 15-13: The code we would have to write if Rust -didn’t have deref coercion - -The `(*m)` dereferences the `MyBox` into a `String`. Then the `&` and -`[..]` take a string slice of the `String` that is equal to the whole string to -match the signature of `hello`. The code without deref coercions is harder to -read, write, and understand with all of these symbols involved. Deref coercion -allows Rust to handle these conversions for us automatically. - -When the `Deref` trait is defined for the types involved, Rust will analyze the -types and use `Deref::deref` as many times as necessary to get a reference to -match the parameter’s type. The number of times that `Deref::deref` needs to be -inserted is resolved at compile time, so there is no runtime penalty for taking -advantage of deref coercion! - -### How Deref Coercion Interacts with Mutability - -Similar to how you use the `Deref` trait to override the `*` operator on -immutable references, you can use the `DerefMut` trait to override the `*` -operator on mutable references. - -Rust does deref coercion when it finds types and trait implementations in three -cases: - -* From `&T` to `&U` when `T: Deref` -* From `&mut T` to `&mut U` when `T: DerefMut` -* From `&mut T` to `&U` when `T: Deref` - -The first two cases are the same except for mutability. The first case states -that if you have a `&T`, and `T` implements `Deref` to some type `U`, you can -get a `&U` transparently. The second case states that the same deref coercion -happens for mutable references. - -The third case is trickier: Rust will also coerce a mutable reference to an -immutable one. But the reverse is *not* possible: immutable references will -never coerce to mutable references. Because of the borrowing rules, if you have -a mutable reference, that mutable reference must be the only reference to that -data (otherwise, the program wouldn’t compile). Converting one mutable -reference to one immutable reference will never break the borrowing rules. -Converting an immutable reference to a mutable reference would require that -there is only one immutable reference to that data, and the borrowing rules -don’t guarantee that. Therefore, Rust can’t make the assumption that converting -an immutable reference to a mutable reference is possible. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch15-02-deref.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-03-drop.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-03-drop.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-03-drop.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-03-drop.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,189 +1,10 @@ ## Running Code on Cleanup with the `Drop` Trait -The second trait important to the smart pointer pattern is `Drop`, which lets -you customize what happens when a value is about to go out of scope. You can -provide an implementation for the `Drop` trait on any type, and the code you -specify can be used to release resources like files or network connections. -We’re introducing `Drop` in the context of smart pointers because the -functionality of the `Drop` trait is almost always used when implementing a -smart pointer. For example, `Box` customizes `Drop` to deallocate the space -on the heap that the box points to. +The 2018 edition of the book is no longer distributed with Rust's documentation. -In some languages, the programmer must call code to free memory or resources -every time they finish using an instance of a smart pointer. If they forget, -the system might become overloaded and crash. In Rust, you can specify that a -particular bit of code be run whenever a value goes out of scope, and the -compiler will insert this code automatically. As a result, you don’t need to be -careful about placing cleanup code everywhere in a program that an instance of -a particular type is finished with—you still won’t leak resources! +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -Specify the code to run when a value goes out of scope by implementing the -`Drop` trait. The `Drop` trait requires you to implement one method named -`drop` that takes a mutable reference to `self`. To see when Rust calls `drop`, -let’s implement `drop` with `println!` statements for now. - -Listing 15-14 shows a `CustomSmartPointer` struct whose only custom -functionality is that it will print `Dropping CustomSmartPointer!` when the -instance goes out of scope. This example demonstrates when Rust runs the `drop` -function. - -Filename: src/main.rs - -```rust -struct CustomSmartPointer { - data: String, -} - -impl Drop for CustomSmartPointer { - fn drop(&mut self) { - println!("Dropping CustomSmartPointer with data `{}`!", self.data); - } -} - -fn main() { - let c = CustomSmartPointer { data: String::from("my stuff") }; - let d = CustomSmartPointer { data: String::from("other stuff") }; - println!("CustomSmartPointers created."); -} -``` - -Listing 15-14: A `CustomSmartPointer` struct that -implements the `Drop` trait where we would put our cleanup code - -The `Drop` trait is included in the prelude, so we don’t need to import it. We -implement the `Drop` trait on `CustomSmartPointer` and provide an -implementation for the `drop` method that calls `println!`. The body of the -`drop` function is where you would place any logic that you wanted to run when -an instance of your type goes out of scope. We’re printing some text here to -demonstrate when Rust will call `drop`. - -In `main`, we create two instances of `CustomSmartPointer` and then print -`CustomSmartPointers created.`. At the end of `main`, our instances of -`CustomSmartPointer` will go out of scope, and Rust will call the code we put -in the `drop` method, printing our final message. Note that we didn’t need to -call the `drop` method explicitly. - -When we run this program, we’ll see the following output: - -```text -CustomSmartPointers created. -Dropping CustomSmartPointer with data `other stuff`! -Dropping CustomSmartPointer with data `my stuff`! -``` - -Rust automatically called `drop` for us when our instances went out of scope, -calling the code we specified. Variables are dropped in the reverse order of -their creation, so `d` was dropped before `c`. This example gives you a visual -guide to how the `drop` method works; usually you would specify the cleanup -code that your type needs to run rather than a print message. - -### Dropping a Value Early with `std::mem::drop` - -Unfortunately, it’s not straightforward to disable the automatic `drop` -functionality. Disabling `drop` isn’t usually necessary; the whole point of the -`Drop` trait is that it’s taken care of automatically. Occasionally, however, -you might want to clean up a value early. One example is when using smart -pointers that manage locks: you might want to force the `drop` method that -releases the lock to run so other code in the same scope can acquire the lock. -Rust doesn’t let you call the `Drop` trait’s `drop` method manually; instead -you have to call the `std::mem::drop` function provided by the standard library -if you want to force a value to be dropped before the end of its scope. - -If we try to call the `Drop` trait’s `drop` method manually by modifying the -`main` function from Listing 15-14, as shown in Listing 15-15, we’ll get a -compiler error: - -Filename: src/main.rs - -```rust,ignore -fn main() { - let c = CustomSmartPointer { data: String::from("some data") }; - println!("CustomSmartPointer created."); - c.drop(); - println!("CustomSmartPointer dropped before the end of main."); -} -``` - -Listing 15-15: Attempting to call the `drop` method from -the `Drop` trait manually to clean up early - -When we try to compile this code, we’ll get this error: - -```text -error[E0040]: explicit use of destructor method - --> src/main.rs:14:7 - | -14 | c.drop(); - | ^^^^ explicit destructor calls not allowed -``` - -This error message states that we’re not allowed to explicitly call `drop`. The -error message uses the term *destructor*, which is the general programming term -for a function that cleans up an instance. A *destructor* is analogous to a -*constructor*, which creates an instance. The `drop` function in Rust is one -particular destructor. - -Rust doesn’t let us call `drop` explicitly because Rust would still -automatically call `drop` on the value at the end of `main`. This would be a -*double free* error because Rust would be trying to clean up the same value -twice. - -We can’t disable the automatic insertion of `drop` when a value goes out of -scope, and we can’t call the `drop` method explicitly. So, if we need to force -a value to be cleaned up early, we can use the `std::mem::drop` function. - -The `std::mem::drop` function is different than the `drop` method in the `Drop` -trait. We call it by passing the value we want to force to be dropped early as -an argument. The function is in the prelude, so we can modify `main` in Listing -15-15 to call the `drop` function, as shown in Listing 15-16: - -Filename: src/main.rs - -```rust -# struct CustomSmartPointer { -# data: String, -# } -# -# impl Drop for CustomSmartPointer { -# fn drop(&mut self) { -# println!("Dropping CustomSmartPointer!"); -# } -# } -# -fn main() { - let c = CustomSmartPointer { data: String::from("some data") }; - println!("CustomSmartPointer created."); - drop(c); - println!("CustomSmartPointer dropped before the end of main."); -} -``` - -Listing 15-16: Calling `std::mem::drop` to explicitly -drop a value before it goes out of scope - -Running this code will print the following: - -```text -CustomSmartPointer created. -Dropping CustomSmartPointer with data `some data`! -CustomSmartPointer dropped before the end of main. -``` - -The text ```Dropping CustomSmartPointer with data `some data`!``` is printed -between the `CustomSmartPointer created.` and `CustomSmartPointer dropped -before the end of main.` text, showing that the `drop` method code is called to -drop `c` at that point. - -You can use code specified in a `Drop` trait implementation in many ways to -make cleanup convenient and safe: for instance, you could use it to create your -own memory allocator! With the `Drop` trait and Rust’s ownership system, you -don’t have to remember to clean up because Rust does it automatically. - -You also don’t have to worry about problems resulting from accidentally -cleaning up values still in use: the ownership system that makes sure -references are always valid also ensures that `drop` gets called only once when -the value is no longer being used. - -Now that we’ve examined `Box` and some of the characteristics of smart -pointers, let’s look at a few other smart pointers defined in the standard -library. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch15-03-drop.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-04-rc.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-04-rc.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-04-rc.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-04-rc.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,217 +1,10 @@ ## `Rc`, the Reference Counted Smart Pointer -In the majority of cases, ownership is clear: you know exactly which variable -owns a given value. However, there are cases when a single value might have -multiple owners. For example, in graph data structures, multiple edges might -point to the same node, and that node is conceptually owned by all of the edges -that point to it. A node shouldn’t be cleaned up unless it doesn’t have any -edges pointing to it. +The 2018 edition of the book is no longer distributed with Rust's documentation. -To enable multiple ownership, Rust has a type called `Rc`, which is an -abbreviation for *reference counting*. The `Rc` type keeps track of the -number of references to a value which determines whether or not a value is -still in use. If there are zero references to a value, the value can be cleaned -up without any references becoming invalid. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -Imagine `Rc` as a TV in a family room. When one person enters to watch TV, -they turn it on. Others can come into the room and watch the TV. When the last -person leaves the room, they turn off the TV because it’s no longer being used. -If someone turns off the TV while others are still watching it, there would be -uproar from the remaining TV watchers! - -We use the `Rc` type when we want to allocate some data on the heap for -multiple parts of our program to read and we can’t determine at compile time -which part will finish using the data last. If we knew which part would finish -last, we could just make that part the data’s owner, and the normal ownership -rules enforced at compile time would take effect. - -Note that `Rc` is only for use in single-threaded scenarios. When we discuss -concurrency in Chapter 16, we’ll cover how to do reference counting in -multithreaded programs. - -### Using `Rc` to Share Data - -Let’s return to our cons list example in Listing 15-5. Recall that we defined -it using `Box`. This time, we’ll create two lists that both share ownership -of a third list. Conceptually, this looks similar to Figure 15-3: - -Two lists that share ownership of a third list - -Figure 15-3: Two lists, `b` and `c`, sharing ownership of -a third list, `a` - -We’ll create list `a` that contains 5 and then 10. Then we’ll make two more -lists: `b` that starts with 3 and `c` that starts with 4. Both `b` and `c` -lists will then continue on to the first `a` list containing 5 and 10. In other -words, both lists will share the first list containing 5 and 10. - -Trying to implement this scenario using our definition of `List` with `Box` -won’t work, as shown in Listing 15-17: - -Filename: src/main.rs - -```rust,ignore -enum List { - Cons(i32, Box), - Nil, -} - -use List::{Cons, Nil}; - -fn main() { - let a = Cons(5, - Box::new(Cons(10, - Box::new(Nil)))); - let b = Cons(3, Box::new(a)); - let c = Cons(4, Box::new(a)); -} -``` - -Listing 15-17: Demonstrating we’re not allowed to have -two lists using `Box` that try to share ownership of a third list - -When we compile this code, we get this error: - -```text -error[E0382]: use of moved value: `a` - --> src/main.rs:13:30 - | -12 | let b = Cons(3, Box::new(a)); - | - value moved here -13 | let c = Cons(4, Box::new(a)); - | ^ value used here after move - | - = note: move occurs because `a` has type `List`, which does not implement - the `Copy` trait -``` - -The `Cons` variants own the data they hold, so when we create the `b` list, `a` -is moved into `b` and `b` owns `a`. Then, when we try to use `a` again when -creating `c`, we’re not allowed to because `a` has been moved. - -We could change the definition of `Cons` to hold references instead, but then -we would have to specify lifetime parameters. By specifying lifetime -parameters, we would be specifying that every element in the list will live at -least as long as the entire list. The borrow checker wouldn’t let us compile -`let a = Cons(10, &Nil);` for example, because the temporary `Nil` value would -be dropped before `a` could take a reference to it. - -Instead, we’ll change our definition of `List` to use `Rc` in place of -`Box`, as shown in Listing 15-18. Each `Cons` variant will now hold a value -and an `Rc` pointing to a `List`. When we create `b`, instead of taking -ownership of `a`, we’ll clone the `Rc` that `a` is holding, thereby -increasing the number of references from one to two and letting `a` and `b` -share ownership of the data in that `Rc`. We’ll also clone `a` when -creating `c`, increasing the number of references from two to three. Every time -we call `Rc::clone`, the reference count to the data within the `Rc` will -increase, and the data won’t be cleaned up unless there are zero references to -it. - -Filename: src/main.rs - -```rust -enum List { - Cons(i32, Rc), - Nil, -} - -use List::{Cons, Nil}; -use std::rc::Rc; - -fn main() { - let a = Rc::new(Cons(5, Rc::new(Cons(10, Rc::new(Nil))))); - let b = Cons(3, Rc::clone(&a)); - let c = Cons(4, Rc::clone(&a)); -} -``` - -Listing 15-18: A definition of `List` that uses -`Rc` - -We need to add a `use` statement to bring `Rc` into scope because it’s not -in the prelude. In `main`, we create the list holding 5 and 10 and store it in -a new `Rc` in `a`. Then when we create `b` and `c`, we call the -`Rc::clone` function and pass a reference to the `Rc` in `a` as an -argument. - -We could have called `a.clone()` rather than `Rc::clone(&a)`, but Rust’s -convention is to use `Rc::clone` in this case. The implementation of -`Rc::clone` doesn’t make a deep copy of all the data like most types’ -implementations of `clone` do. The call to `Rc::clone` only increments the -reference count, which doesn’t take much time. Deep copies of data can take a -lot of time. By using `Rc::clone` for reference counting, we can visually -distinguish between the deep-copy kinds of clones and the kinds of clones that -increase the reference count. When looking for performance problems in the -code, we only need to consider the deep-copy clones and can disregard calls to -`Rc::clone`. - -### Cloning an `Rc` Increases the Reference Count - -Let’s change our working example in Listing 15-18 so we can see the reference -counts changing as we create and drop references to the `Rc` in `a`. - -In Listing 15-19, we’ll change `main` so it has an inner scope around list `c`; -then we can see how the reference count changes when `c` goes out of scope. - -Filename: src/main.rs - -```rust -# enum List { -# Cons(i32, Rc), -# Nil, -# } -# -# use List::{Cons, Nil}; -# use std::rc::Rc; -# -fn main() { - let a = Rc::new(Cons(5, Rc::new(Cons(10, Rc::new(Nil))))); - println!("count after creating a = {}", Rc::strong_count(&a)); - let b = Cons(3, Rc::clone(&a)); - println!("count after creating b = {}", Rc::strong_count(&a)); - { - let c = Cons(4, Rc::clone(&a)); - println!("count after creating c = {}", Rc::strong_count(&a)); - } - println!("count after c goes out of scope = {}", Rc::strong_count(&a)); -} -``` - -Listing 15-19: Printing the reference count - -At each point in the program where the reference count changes, we print the -reference count, which we can get by calling the `Rc::strong_count` function. -This function is named `strong_count` rather than `count` because the `Rc` -type also has a `weak_count`; we’ll see what `weak_count` is used for in the -“Preventing Reference Cycles” section. - -This code prints the following: - -```text -count after creating a = 1 -count after creating b = 2 -count after creating c = 3 -count after c goes out of scope = 2 -``` - -We can see that the `Rc` in `a` has an initial reference count of 1; then -each time we call `clone`, the count goes up by 1. When `c` goes out of scope, -the count goes down by 1. We don’t have to call a function to decrease the -reference count like we have to call `Rc::clone` to increase the reference -count: the implementation of the `Drop` trait decreases the reference count -automatically when an `Rc` value goes out of scope. - -What we can’t see in this example is that when `b` and then `a` go out of scope -at the end of `main`, the count is then 0, and the `Rc` is cleaned up -completely at that point. Using `Rc` allows a single value to have -multiple owners, and the count ensures that the value remains valid as long as -any of the owners still exist. - -Via immutable references, `Rc` allows you to share data between multiple -parts of your program for reading only. If `Rc` allowed you to have multiple -mutable references too, you might violate one of the borrowing rules discussed -in Chapter 4: multiple mutable borrows to the same place can cause data races -and inconsistencies. But being able to mutate data is very useful! In the next -section, we’ll discuss the interior mutability pattern and the `RefCell` -type that you can use in conjunction with an `Rc` to work with this -immutability restriction. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch15-04-rc.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-05-interior-mutability.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-05-interior-mutability.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-05-interior-mutability.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-05-interior-mutability.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,483 +1,10 @@ ## `RefCell` and the Interior Mutability Pattern - +The 2018 edition of the book is no longer distributed with Rust's documentation. -*Interior mutability* is a design pattern in Rust that allows you to mutate -data even when there are immutable references to that data; normally, this -action is disallowed by the borrowing rules. To mutate data, the pattern uses -`unsafe` code inside a data structure to bend Rust’s usual rules that govern -mutation and borrowing. We haven’t yet covered unsafe code; we will in -Chapter 19. We can use types that use the interior mutability pattern when we -can ensure that the borrowing rules will be followed at runtime, even though -the compiler can’t guarantee that. The `unsafe` code involved is then wrapped -in a safe API, and the outer type is still immutable. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -Let’s explore this concept by looking at the `RefCell` type that follows the -interior mutability pattern. - -### Enforcing Borrowing Rules at Runtime with `RefCell` - -Unlike `Rc`, the `RefCell` type represents single ownership over the data -it holds. So, what makes `RefCell` different from a type like `Box`? -Recall the borrowing rules you learned in Chapter 4: - -* At any given time, you can have *either* (but not both of) one mutable - reference or any number of immutable references. -* References must always be valid. - -With references and `Box`, the borrowing rules’ invariants are enforced at -compile time. With `RefCell`, these invariants are enforced *at runtime*. -With references, if you break these rules, you’ll get a compiler error. With -`RefCell`, if you break these rules, your program will panic and exit. - -The advantages of checking the borrowing rules at compile time are that errors -will be caught sooner in the development process, and there is no impact on -runtime performance because all the analysis is completed beforehand. For those -reasons, checking the borrowing rules at compile time is the best choice in the -majority of cases, which is why this is Rust’s default. - -The advantage of checking the borrowing rules at runtime instead is that -certain memory-safe scenarios are then allowed, whereas they are disallowed by -the compile-time checks. Static analysis, like the Rust compiler, is inherently -conservative. Some properties of code are impossible to detect by analyzing the -code: the most famous example is the Halting Problem, which is beyond the scope -of this book but is an interesting topic to research. - -Because some analysis is impossible, if the Rust compiler can’t be sure the -code complies with the ownership rules, it might reject a correct program; in -this way, it’s conservative. If Rust accepted an incorrect program, users -wouldn’t be able to trust in the guarantees Rust makes. However, if Rust -rejects a correct program, the programmer will be inconvenienced, but nothing -catastrophic can occur. The `RefCell` type is useful when you’re sure your -code follows the borrowing rules but the compiler is unable to understand and -guarantee that. - -Similar to `Rc`, `RefCell` is only for use in single-threaded scenarios -and will give you a compile-time error if you try using it in a multithreaded -context. We’ll talk about how to get the functionality of `RefCell` in a -multithreaded program in Chapter 16. - -Here is a recap of the reasons to choose `Box`, `Rc`, or `RefCell`: - -* `Rc` enables multiple owners of the same data; `Box` and `RefCell` - have single owners. -* `Box` allows immutable or mutable borrows checked at compile time; `Rc` - allows only immutable borrows checked at compile time; `RefCell` allows - immutable or mutable borrows checked at runtime. -* Because `RefCell` allows mutable borrows checked at runtime, you can - mutate the value inside the `RefCell` even when the `RefCell` is - immutable. - -Mutating the value inside an immutable value is the *interior mutability* -pattern. Let’s look at a situation in which interior mutability is useful and -examine how it’s possible. - -### Interior Mutability: A Mutable Borrow to an Immutable Value - -A consequence of the borrowing rules is that when you have an immutable value, -you can’t borrow it mutably. For example, this code won’t compile: - -```rust,ignore -fn main() { - let x = 5; - let y = &mut x; -} -``` - -If you tried to compile this code, you’d get the following error: - -```text -error[E0596]: cannot borrow immutable local variable `x` as mutable - --> src/main.rs:3:18 - | -2 | let x = 5; - | - consider changing this to `mut x` -3 | let y = &mut x; - | ^ cannot borrow mutably -``` - -However, there are situations in which it would be useful for a value to mutate -itself in its methods but appear immutable to other code. Code outside the -value’s methods would not be able to mutate the value. Using `RefCell` is -one way to get the ability to have interior mutability. But `RefCell` -doesn’t get around the borrowing rules completely: the borrow checker in the -compiler allows this interior mutability, and the borrowing rules are checked -at runtime instead. If you violate the rules, you’ll get a `panic!` instead of -a compiler error. - -Let’s work through a practical example where we can use `RefCell` to mutate -an immutable value and see why that is useful. - -#### A Use Case for Interior Mutability: Mock Objects - -A *test double* is the general programming concept for a type used in place of -another type during testing. *Mock objects* are specific types of test doubles -that record what happens during a test so you can assert that the correct -actions took place. - -Rust doesn’t have objects in the same sense as other languages have objects, -and Rust doesn’t have mock object functionality built into the standard library -as some other languages do. However, you can definitely create a struct that -will serve the same purposes as a mock object. - -Here’s the scenario we’ll test: we’ll create a library that tracks a value -against a maximum value and sends messages based on how close to the maximum -value the current value is. This library could be used to keep track of a -user’s quota for the number of API calls they’re allowed to make, for example. - -Our library will only provide the functionality of tracking how close to the -maximum a value is and what the messages should be at what times. Applications -that use our library will be expected to provide the mechanism for sending the -messages: the application could put a message in the application, send an -email, send a text message, or something else. The library doesn’t need to know -that detail. All it needs is something that implements a trait we’ll provide -called `Messenger`. Listing 15-20 shows the library code: - -Filename: src/lib.rs - -```rust -pub trait Messenger { - fn send(&self, msg: &str); -} - -pub struct LimitTracker<'a, T: 'a + Messenger> { - messenger: &'a T, - value: usize, - max: usize, -} - -impl<'a, T> LimitTracker<'a, T> - where T: Messenger { - pub fn new(messenger: &T, max: usize) -> LimitTracker { - LimitTracker { - messenger, - value: 0, - max, - } - } - - pub fn set_value(&mut self, value: usize) { - self.value = value; - - let percentage_of_max = self.value as f64 / self.max as f64; - - if percentage_of_max >= 0.75 && percentage_of_max < 0.9 { - self.messenger.send("Warning: You've used up over 75% of your quota!"); - } else if percentage_of_max >= 0.9 && percentage_of_max < 1.0 { - self.messenger.send("Urgent warning: You've used up over 90% of your quota!"); - } else if percentage_of_max >= 1.0 { - self.messenger.send("Error: You are over your quota!"); - } - } -} -``` - -Listing 15-20: A library to keep track of how close a -value is to a maximum value and warn when the value is at certain levels - -One important part of this code is that the `Messenger` trait has one method -called `send` that takes an immutable reference to `self` and the text of the -message. This is the interface our mock object needs to have. The other -important part is that we want to test the behavior of the `set_value` method -on the `LimitTracker`. We can change what we pass in for the `value` parameter, -but `set_value` doesn’t return anything for us to make assertions on. We want -to be able to say that if we create a `LimitTracker` with something that -implements the `Messenger` trait and a particular value for `max`, when we pass -different numbers for `value`, the messenger is told to send the appropriate -messages. - -We need a mock object that, instead of sending an email or text message when we -call `send`, will only keep track of the messages it’s told to send. We can -create a new instance of the mock object, create a `LimitTracker` that uses the -mock object, call the `set_value` method on `LimitTracker`, and then check that -the mock object has the messages we expect. Listing 15-21 shows an attempt to -implement a mock object to do just that, but the borrow checker won’t allow it: - -Filename: src/lib.rs - -```rust -#[cfg(test)] -mod tests { - use super::*; - - struct MockMessenger { - sent_messages: Vec, - } - - impl MockMessenger { - fn new() -> MockMessenger { - MockMessenger { sent_messages: vec![] } - } - } - - impl Messenger for MockMessenger { - fn send(&self, message: &str) { - self.sent_messages.push(String::from(message)); - } - } - - #[test] - fn it_sends_an_over_75_percent_warning_message() { - let mock_messenger = MockMessenger::new(); - let mut limit_tracker = LimitTracker::new(&mock_messenger, 100); - - limit_tracker.set_value(80); - - assert_eq!(mock_messenger.sent_messages.len(), 1); - } -} -``` - -Listing 15-21: An attempt to implement a `MockMessenger` -that isn’t allowed by the borrow checker - -This test code defines a `MockMessenger` struct that has a `sent_messages` -field with a `Vec` of `String` values to keep track of the messages it’s told -to send. We also define an associated function `new` to make it convenient to -create new `MockMessenger` values that start with an empty list of messages. We -then implement the `Messenger` trait for `MockMessenger` so we can give a -`MockMessenger` to a `LimitTracker`. In the definition of the `send` method, we -take the message passed in as a parameter and store it in the `MockMessenger` -list of `sent_messages`. - -In the test, we’re testing what happens when the `LimitTracker` is told to set -`value` to something that is more than 75 percent of the `max` value. First, we -create a new `MockMessenger`, which will start with an empty list of messages. -Then we create a new `LimitTracker` and give it a reference to the new -`MockMessenger` and a `max` value of 100. We call the `set_value` method on the -`LimitTracker` with a value of 80, which is more than 75 percent of 100. Then -we assert that the list of messages that the `MockMessenger` is keeping track -of should now have one message in it. - -However, there’s one problem with this test, as shown here: - -```text -error[E0596]: cannot borrow immutable field `self.sent_messages` as mutable - --> src/lib.rs:52:13 - | -51 | fn send(&self, message: &str) { - | ----- use `&mut self` here to make mutable -52 | self.sent_messages.push(String::from(message)); - | ^^^^^^^^^^^^^^^^^^ cannot mutably borrow immutable field -``` - -We can’t modify the `MockMessenger` to keep track of the messages, because the -`send` method takes an immutable reference to `self`. We also can’t take the -suggestion from the error text to use `&mut self` instead, because then the -signature of `send` wouldn’t match the signature in the `Messenger` trait -definition (feel free to try and see what error message you get). - -This is a situation in which interior mutability can help! We’ll store the -`sent_messages` within a `RefCell`, and then the `send` message will be -able to modify `sent_messages` to store the messages we’ve seen. Listing 15-22 -shows what that looks like: - -Filename: src/lib.rs - -```rust -#[cfg(test)] -mod tests { - use super::*; - use std::cell::RefCell; - - struct MockMessenger { - sent_messages: RefCell>, - } - - impl MockMessenger { - fn new() -> MockMessenger { - MockMessenger { sent_messages: RefCell::new(vec![]) } - } - } - - impl Messenger for MockMessenger { - fn send(&self, message: &str) { - self.sent_messages.borrow_mut().push(String::from(message)); - } - } - - #[test] - fn it_sends_an_over_75_percent_warning_message() { - // --snip-- -# let mock_messenger = MockMessenger::new(); -# let mut limit_tracker = LimitTracker::new(&mock_messenger, 100); -# limit_tracker.set_value(75); - - assert_eq!(mock_messenger.sent_messages.borrow().len(), 1); - } -} -``` - -Listing 15-22: Using `RefCell` to mutate an inner -value while the outer value is considered immutable - -The `sent_messages` field is now of type `RefCell>` instead of -`Vec`. In the `new` function, we create a new `RefCell>` -instance around the empty vector. - -For the implementation of the `send` method, the first parameter is still an -immutable borrow of `self`, which matches the trait definition. We call -`borrow_mut` on the `RefCell>` in `self.sent_messages` to get a -mutable reference to the value inside the `RefCell>`, which is -the vector. Then we can call `push` on the mutable reference to the vector to -keep track of the messages sent during the test. - -The last change we have to make is in the assertion: to see how many items are -in the inner vector, we call `borrow` on the `RefCell>` to get an -immutable reference to the vector. - -Now that you’ve seen how to use `RefCell`, let’s dig into how it works! - -#### Keeping Track of Borrows at Runtime with `RefCell` - -When creating immutable and mutable references, we use the `&` and `&mut` -syntax, respectively. With `RefCell`, we use the `borrow` and `borrow_mut` -methods, which are part of the safe API that belongs to `RefCell`. The -`borrow` method returns the smart pointer type `Ref`, and `borrow_mut` -returns the smart pointer type `RefMut`. Both types implement `Deref`, so we -can treat them like regular references. - -The `RefCell` keeps track of how many `Ref` and `RefMut` smart -pointers are currently active. Every time we call `borrow`, the `RefCell` -increases its count of how many immutable borrows are active. When a `Ref` -value goes out of scope, the count of immutable borrows goes down by one. Just -like the compile-time borrowing rules, `RefCell` lets us have many immutable -borrows or one mutable borrow at any point in time. - -If we try to violate these rules, rather than getting a compiler error as we -would with references, the implementation of `RefCell` will panic at -runtime. Listing 15-23 shows a modification of the implementation of `send` in -Listing 15-22. We’re deliberately trying to create two mutable borrows active -for the same scope to illustrate that `RefCell` prevents us from doing this -at runtime. - -Filename: src/lib.rs - -```rust,ignore -impl Messenger for MockMessenger { - fn send(&self, message: &str) { - let mut one_borrow = self.sent_messages.borrow_mut(); - let mut two_borrow = self.sent_messages.borrow_mut(); - - one_borrow.push(String::from(message)); - two_borrow.push(String::from(message)); - } -} -``` - -Listing 15-23: Creating two mutable references in the -same scope to see that `RefCell` will panic - -We create a variable `one_borrow` for the `RefMut` smart pointer returned -from `borrow_mut`. Then we create another mutable borrow in the same way in the -variable `two_borrow`. This makes two mutable references in the same scope, -which isn’t allowed. When we run the tests for our library, the code in Listing -15-23 will compile without any errors, but the test will fail: - -```text ----- tests::it_sends_an_over_75_percent_warning_message stdout ---- - thread 'tests::it_sends_an_over_75_percent_warning_message' panicked at -'already borrowed: BorrowMutError', src/libcore/result.rs:906:4 -note: Run with `RUST_BACKTRACE=1` for a backtrace. -``` - -Notice that the code panicked with the message `already borrowed: -BorrowMutError`. This is how `RefCell` handles violations of the borrowing -rules at runtime. - -Catching borrowing errors at runtime rather than compile time means that you -would find a mistake in your code later in the development process and possibly -not until your code was deployed to production. Also, your code would incur a -small runtime performance penalty as a result of keeping track of the borrows -at runtime rather than compile time. However, using `RefCell` makes it -possible to write a mock object that can modify itself to keep track of the -messages it has seen while you’re using it in a context where only immutable -values are allowed. You can use `RefCell` despite its trade-offs to get more -functionality than regular references provide. - -### Having Multiple Owners of Mutable Data by Combining `Rc` and `RefCell` - -A common way to use `RefCell` is in combination with `Rc`. Recall that -`Rc` lets you have multiple owners of some data, but it only gives immutable -access to that data. If you have an `Rc` that holds a `RefCell`, you can -get a value that can have multiple owners *and* that you can mutate! - -For example, recall the cons list example in Listing 15-18 where we used -`Rc` to allow multiple lists to share ownership of another list. Because -`Rc` holds only immutable values, we can’t change any of the values in the -list once we’ve created them. Let’s add in `RefCell` to gain the ability to -change the values in the lists. Listing 15-24 shows that by using a -`RefCell` in the `Cons` definition, we can modify the value stored in all -the lists: - -Filename: src/main.rs - -```rust -#[derive(Debug)] -enum List { - Cons(Rc>, Rc), - Nil, -} - -use List::{Cons, Nil}; -use std::rc::Rc; -use std::cell::RefCell; - -fn main() { - let value = Rc::new(RefCell::new(5)); - - let a = Rc::new(Cons(Rc::clone(&value), Rc::new(Nil))); - - let b = Cons(Rc::new(RefCell::new(6)), Rc::clone(&a)); - let c = Cons(Rc::new(RefCell::new(10)), Rc::clone(&a)); - - *value.borrow_mut() += 10; - - println!("a after = {:?}", a); - println!("b after = {:?}", b); - println!("c after = {:?}", c); -} -``` - -Listing 15-24: Using `Rc>` to create a -`List` that we can mutate - -We create a value that is an instance of `Rc>` and store it in a -variable named `value` so we can access it directly later. Then we create a -`List` in `a` with a `Cons` variant that holds `value`. We need to clone -`value` so both `a` and `value` have ownership of the inner `5` value rather -than transferring ownership from `value` to `a` or having `a` borrow from -`value`. - -We wrap the list `a` in an `Rc` so when we create lists `b` and `c`, they -can both refer to `a`, which is what we did in Listing 15-18. - -After we’ve created the lists in `a`, `b`, and `c`, we add 10 to the value in -`value`. We do this by calling `borrow_mut` on `value`, which uses the -automatic dereferencing feature we discussed in Chapter 5 (see the section -“Where’s the `->` Operator?”) to dereference the `Rc` to the inner -`RefCell` value. The `borrow_mut` method returns a `RefMut` smart -pointer, and we use the dereference operator on it and change the inner value. - -When we print `a`, `b`, and `c`, we can see that they all have the modified -value of 15 rather than 5: - -```text -a after = Cons(RefCell { value: 15 }, Nil) -b after = Cons(RefCell { value: 6 }, Cons(RefCell { value: 15 }, Nil)) -c after = Cons(RefCell { value: 10 }, Cons(RefCell { value: 15 }, Nil)) -``` - -This technique is pretty neat! By using `RefCell`, we have an outwardly -immutable `List` value. But we can use the methods on `RefCell` that provide -access to its interior mutability so we can modify our data when we need to. -The runtime checks of the borrowing rules protect us from data races, and it’s -sometimes worth trading a bit of speed for this flexibility in our data -structures. - -The standard library has other types that provide interior mutability, such as -`Cell`, which is similar except that instead of giving references to the -inner value, the value is copied in and out of the `Cell`. There’s also -`Mutex`, which offers interior mutability that’s safe to use across threads; -we’ll discuss its use in Chapter 16. Check out the standard library docs for -more details on the differences between these types. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch15-05-interior-mutability.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-06-reference-cycles.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-06-reference-cycles.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-06-reference-cycles.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch15-06-reference-cycles.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,498 +1,10 @@ ## Reference Cycles Can Leak Memory -Rust’s memory safety guarantees make it difficult, but not impossible, to -accidentally create memory that is never cleaned up (known as a *memory leak*). -Preventing memory leaks entirely is not one of Rust’s guarantees in the same -way that disallowing data races at compile time is, meaning memory leaks are -memory safe in Rust. We can see that Rust allows memory leaks by using `Rc` -and `RefCell`: it’s possible to create references where items refer to each -other in a cycle. This creates memory leaks because the reference count of each -item in the cycle will never reach 0, and the values will never be dropped. +The 2018 edition of the book is no longer distributed with Rust's documentation. -### Creating a Reference Cycle +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -Let’s look at how a reference cycle might happen and how to prevent it, -starting with the definition of the `List` enum and a `tail` method in Listing -15-25: - -Filename: src/main.rs - - - -```rust -# fn main() {} -use std::rc::Rc; -use std::cell::RefCell; -use List::{Cons, Nil}; - -#[derive(Debug)] -enum List { - Cons(i32, RefCell>), - Nil, -} - -impl List { - fn tail(&self) -> Option<&RefCell>> { - match self { - Cons(_, item) => Some(item), - Nil => None, - } - } -} -``` - -Listing 15-25: A cons list definition that holds a -`RefCell` so we can modify what a `Cons` variant is referring to - -We’re using another variation of the `List` definition in Listing 15-25. The -second element in the `Cons` variant is now `RefCell>`, meaning that -instead of having the ability to modify the `i32` value as we did in Listing -15-24, we want to modify which `List` value a `Cons` variant is pointing to. -We’re also adding a `tail` method to make it convenient for us to access the -second item if we have a `Cons` variant. - -In Listing 15-26, we’re adding a `main` function that uses the definitions in -Listing 15-25. This code creates a list in `a` and a list in `b` that points to -the list in `a`. Then it modifies the list in `a` to point to `b`, creating a -reference cycle. There are `println!` statements along the way to show what the -reference counts are at various points in this process. - -Filename: src/main.rs - -```rust -# use List::{Cons, Nil}; -# use std::rc::Rc; -# use std::cell::RefCell; -# #[derive(Debug)] -# enum List { -# Cons(i32, RefCell>), -# Nil, -# } -# -# impl List { -# fn tail(&self) -> Option<&RefCell>> { -# match self { -# Cons(_, item) => Some(item), -# Nil => None, -# } -# } -# } -# -fn main() { - let a = Rc::new(Cons(5, RefCell::new(Rc::new(Nil)))); - - println!("a initial rc count = {}", Rc::strong_count(&a)); - println!("a next item = {:?}", a.tail()); - - let b = Rc::new(Cons(10, RefCell::new(Rc::clone(&a)))); - - println!("a rc count after b creation = {}", Rc::strong_count(&a)); - println!("b initial rc count = {}", Rc::strong_count(&b)); - println!("b next item = {:?}", b.tail()); - - if let Some(link) = a.tail() { - *link.borrow_mut() = Rc::clone(&b); - } - - println!("b rc count after changing a = {}", Rc::strong_count(&b)); - println!("a rc count after changing a = {}", Rc::strong_count(&a)); - - // Uncomment the next line to see that we have a cycle; - // it will overflow the stack - // println!("a next item = {:?}", a.tail()); -} -``` - -Listing 15-26: Creating a reference cycle of two `List` -values pointing to each other - -We create an `Rc` instance holding a `List` value in the variable `a` -with an initial list of `5, Nil`. We then create an `Rc` instance -holding another `List` value in the variable `b` that contains the value 10 and -points to the list in `a`. - -We modify `a` so it points to `b` instead of `Nil`, creating a cycle. We -do that by using the `tail` method to get a reference to the -`RefCell>` in `a`, which we put in the variable `link`. Then we use -the `borrow_mut` method on the `RefCell>` to change the value inside -from an `Rc` that holds a `Nil` value to the `Rc` in `b`. - -When we run this code, keeping the last `println!` commented out for the -moment, we’ll get this output: - -```text -a initial rc count = 1 -a next item = Some(RefCell { value: Nil }) -a rc count after b creation = 2 -b initial rc count = 1 -b next item = Some(RefCell { value: Cons(5, RefCell { value: Nil }) }) -b rc count after changing a = 2 -a rc count after changing a = 2 -``` - -The reference count of the `Rc` instances in both `a` and `b` are 2 -after we change the list in `a` to point to `b`. At the end of `main`, Rust -will try to drop `b` first, which will decrease the count in each of the -`Rc` instances in `a` and `b` by 1. - -However, because `a` is still referencing the `Rc` that was in `b`, that -`Rc` has a count of 1 rather than 0, so the memory the `Rc` has on -the heap won’t be dropped. The memory will just sit there with a count of 1, -forever. To visualize this reference cycle, we’ve created a diagram in Figure -15-4. - -Reference cycle of lists - -Figure 15-4: A reference cycle of lists `a` and `b` -pointing to each other - -If you uncomment the last `println!` and run the program, Rust will try to -print this cycle with `a` pointing to `b` pointing to `a` and so forth until it -overflows the stack. - -In this case, right after we create the reference cycle, the program ends. The -consequences of this cycle aren’t very dire. However, if a more complex program -allocated lots of memory in a cycle and held onto it for a long time, the -program would use more memory than it needed and might overwhelm the system, -causing it to run out of available memory. - -Creating reference cycles is not easily done, but it’s not impossible either. -If you have `RefCell` values that contain `Rc` values or similar nested -combinations of types with interior mutability and reference counting, you must -ensure that you don’t create cycles; you can’t rely on Rust to catch them. -Creating a reference cycle would be a logic bug in your program that you should -use automated tests, code reviews, and other software development practices to -minimize. - -Another solution for avoiding reference cycles is reorganizing your data -structures so that some references express ownership and some references don’t. -As a result, you can have cycles made up of some ownership relationships and -some non-ownership relationships, and only the ownership relationships affect -whether or not a value can be dropped. In Listing 15-25, we always want `Cons` -variants to own their list, so reorganizing the data structure isn’t possible. -Let’s look at an example using graphs made up of parent nodes and child nodes -to see when non-ownership relationships are an appropriate way to prevent -reference cycles. - -### Preventing Reference Cycles: Turning an `Rc` into a `Weak` - -So far, we’ve demonstrated that calling `Rc::clone` increases the -`strong_count` of an `Rc` instance, and an `Rc` instance is only cleaned -up if its `strong_count` is 0. You can also create a *weak reference* to the -value within an `Rc` instance by calling `Rc::downgrade` and passing a -reference to the `Rc`. When you call `Rc::downgrade`, you get a smart -pointer of type `Weak`. Instead of increasing the `strong_count` in the -`Rc` instance by 1, calling `Rc::downgrade` increases the `weak_count` by 1. -The `Rc` type uses `weak_count` to keep track of how many `Weak` -references exist, similar to `strong_count`. The difference is the `weak_count` -doesn’t need to be 0 for the `Rc` instance to be cleaned up. - -Strong references are how you can share ownership of an `Rc` instance. Weak -references don’t express an ownership relationship. They won’t cause a -reference cycle because any cycle involving some weak references will be broken -once the strong reference count of values involved is 0. - -Because the value that `Weak` references might have been dropped, to do -anything with the value that a `Weak` is pointing to, you must make sure the -value still exists. Do this by calling the `upgrade` method on a `Weak` -instance, which will return an `Option>`. You’ll get a result of `Some` -if the `Rc` value has not been dropped yet and a result of `None` if the -`Rc` value has been dropped. Because `upgrade` returns an `Option`, Rust -will ensure that the `Some` case and the `None` case are handled, and there -won’t be an invalid pointer. - -As an example, rather than using a list whose items know only about the next -item, we’ll create a tree whose items know about their children items *and* -their parent items. - -#### Creating a Tree Data Structure: a `Node` with Child Nodes - -To start, we’ll build a tree with nodes that know about their child nodes. -We’ll create a struct named `Node` that holds its own `i32` value as well as -references to its children `Node` values: - -Filename: src/main.rs - -```rust -use std::rc::Rc; -use std::cell::RefCell; - -#[derive(Debug)] -struct Node { - value: i32, - children: RefCell>>, -} -``` - -We want a `Node` to own its children, and we want to share that ownership with -variables so we can access each `Node` in the tree directly. To do this, we -define the `Vec` items to be values of type `Rc`. We also want to -modify which nodes are children of another node, so we have a `RefCell` in -`children` around the `Vec>`. - -Next, we’ll use our struct definition and create one `Node` instance named -`leaf` with the value 3 and no children, and another instance named `branch` -with the value 5 and `leaf` as one of its children, as shown in Listing 15-27: - -Filename: src/main.rs - -```rust -# use std::rc::Rc; -# use std::cell::RefCell; -# -# #[derive(Debug)] -# struct Node { -# value: i32, -# children: RefCell>>, -# } -# -fn main() { - let leaf = Rc::new(Node { - value: 3, - children: RefCell::new(vec![]), - }); - - let branch = Rc::new(Node { - value: 5, - children: RefCell::new(vec![Rc::clone(&leaf)]), - }); -} -``` - -Listing 15-27: Creating a `leaf` node with no children -and a `branch` node with `leaf` as one of its children - -We clone the `Rc` in `leaf` and store that in `branch`, meaning the -`Node` in `leaf` now has two owners: `leaf` and `branch`. We can get from -`branch` to `leaf` through `branch.children`, but there’s no way to get from -`leaf` to `branch`. The reason is that `leaf` has no reference to `branch` and -doesn’t know they’re related. We want `leaf` to know that `branch` is its -parent. We’ll do that next. - -#### Adding a Reference from a Child to Its Parent - -To make the child node aware of its parent, we need to add a `parent` field to -our `Node` struct definition. The trouble is in deciding what the type of -`parent` should be. We know it can’t contain an `Rc`, because that would -create a reference cycle with `leaf.parent` pointing to `branch` and -`branch.children` pointing to `leaf`, which would cause their `strong_count` -values to never be 0. - -Thinking about the relationships another way, a parent node should own its -children: if a parent node is dropped, its child nodes should be dropped as -well. However, a child should not own its parent: if we drop a child node, the -parent should still exist. This is a case for weak references! - -So instead of `Rc`, we’ll make the type of `parent` use `Weak`, -specifically a `RefCell>`. Now our `Node` struct definition looks -like this: - -Filename: src/main.rs - -```rust -use std::rc::{Rc, Weak}; -use std::cell::RefCell; - -#[derive(Debug)] -struct Node { - value: i32, - parent: RefCell>, - children: RefCell>>, -} -``` - -A node will be able to refer to its parent node but doesn’t own its parent. -In Listing 15-28, we update `main` to use this new definition so the `leaf` -node will have a way to refer to its parent, `branch`: - -Filename: src/main.rs - -```rust -# use std::rc::{Rc, Weak}; -# use std::cell::RefCell; -# -# #[derive(Debug)] -# struct Node { -# value: i32, -# parent: RefCell>, -# children: RefCell>>, -# } -# -fn main() { - let leaf = Rc::new(Node { - value: 3, - parent: RefCell::new(Weak::new()), - children: RefCell::new(vec![]), - }); - - println!("leaf parent = {:?}", leaf.parent.borrow().upgrade()); - - let branch = Rc::new(Node { - value: 5, - parent: RefCell::new(Weak::new()), - children: RefCell::new(vec![Rc::clone(&leaf)]), - }); - - *leaf.parent.borrow_mut() = Rc::downgrade(&branch); - - println!("leaf parent = {:?}", leaf.parent.borrow().upgrade()); -} -``` - -Listing 15-28: A `leaf` node with a weak reference to its -parent node `branch` - -Creating the `leaf` node looks similar to how creating the `leaf` node looked -in Listing 15-27 with the exception of the `parent` field: `leaf` starts out -without a parent, so we create a new, empty `Weak` reference instance. - -At this point, when we try to get a reference to the parent of `leaf` by using -the `upgrade` method, we get a `None` value. We see this in the output from the -first `println!` statement: - -```text -leaf parent = None -``` - -When we create the `branch` node, it will also have a new `Weak` -reference in the `parent` field, because `branch` doesn’t have a parent node. -We still have `leaf` as one of the children of `branch`. Once we have the -`Node` instance in `branch`, we can modify `leaf` to give it a `Weak` -reference to its parent. We use the `borrow_mut` method on the -`RefCell>` in the `parent` field of `leaf`, and then we use the -`Rc::downgrade` function to create a `Weak` reference to `branch` from -the `Rc` in `branch.` - -When we print the parent of `leaf` again, this time we’ll get a `Some` variant -holding `branch`: now `leaf` can access its parent! When we print `leaf`, we -also avoid the cycle that eventually ended in a stack overflow like we had in -Listing 15-26; the `Weak` references are printed as `(Weak)`: - -```text -leaf parent = Some(Node { value: 5, parent: RefCell { value: (Weak) }, -children: RefCell { value: [Node { value: 3, parent: RefCell { value: (Weak) }, -children: RefCell { value: [] } }] } }) -``` - -The lack of infinite output indicates that this code didn’t create a reference -cycle. We can also tell this by looking at the values we get from calling -`Rc::strong_count` and `Rc::weak_count`. - -#### Visualizing Changes to `strong_count` and `weak_count` - -Let’s look at how the `strong_count` and `weak_count` values of the `Rc` -instances change by creating a new inner scope and moving the creation of -`branch` into that scope. By doing so, we can see what happens when `branch` is -created and then dropped when it goes out of scope. The modifications are shown -in Listing 15-29: - -Filename: src/main.rs - -```rust -# use std::rc::{Rc, Weak}; -# use std::cell::RefCell; -# -# #[derive(Debug)] -# struct Node { -# value: i32, -# parent: RefCell>, -# children: RefCell>>, -# } -# -fn main() { - let leaf = Rc::new(Node { - value: 3, - parent: RefCell::new(Weak::new()), - children: RefCell::new(vec![]), - }); - - println!( - "leaf strong = {}, weak = {}", - Rc::strong_count(&leaf), - Rc::weak_count(&leaf), - ); - - { - let branch = Rc::new(Node { - value: 5, - parent: RefCell::new(Weak::new()), - children: RefCell::new(vec![Rc::clone(&leaf)]), - }); - - *leaf.parent.borrow_mut() = Rc::downgrade(&branch); - - println!( - "branch strong = {}, weak = {}", - Rc::strong_count(&branch), - Rc::weak_count(&branch), - ); - - println!( - "leaf strong = {}, weak = {}", - Rc::strong_count(&leaf), - Rc::weak_count(&leaf), - ); - } - - println!("leaf parent = {:?}", leaf.parent.borrow().upgrade()); - println!( - "leaf strong = {}, weak = {}", - Rc::strong_count(&leaf), - Rc::weak_count(&leaf), - ); -} -``` - -Listing 15-29: Creating `branch` in an inner scope and -examining strong and weak reference counts - -After `leaf` is created, its `Rc` has a strong count of 1 and a weak -count of 0. In the inner scope, we create `branch` and associate it with -`leaf`, at which point when we print the counts, the `Rc` in `branch` -will have a strong count of 1 and a weak count of 1 (for `leaf.parent` pointing -to `branch` with a `Weak`). When we print the counts in `leaf`, we’ll see -it will have a strong count of 2, because `branch` now has a clone of the -`Rc` of `leaf` stored in `branch.children`, but will still have a weak -count of 0. - -When the inner scope ends, `branch` goes out of scope and the strong count of -the `Rc` decreases to 0, so its `Node` is dropped. The weak count of 1 -from `leaf.parent` has no bearing on whether or not `Node` is dropped, so we -don’t get any memory leaks! - -If we try to access the parent of `leaf` after the end of the scope, we’ll get -`None` again. At the end of the program, the `Rc` in `leaf` has a strong -count of 1 and a weak count of 0, because the variable `leaf` is now the only -reference to the `Rc` again. - -All of the logic that manages the counts and value dropping is built into -`Rc` and `Weak` and their implementations of the `Drop` trait. By -specifying that the relationship from a child to its parent should be a -`Weak` reference in the definition of `Node`, you’re able to have parent -nodes point to child nodes and vice versa without creating a reference cycle -and memory leaks. - -## Summary - -This chapter covered how to use smart pointers to make different guarantees and -trade-offs than those Rust makes by default with regular references. The -`Box` type has a known size and points to data allocated on the heap. The -`Rc` type keeps track of the number of references to data on the heap so -that data can have multiple owners. The `RefCell` type with its interior -mutability gives us a type that we can use when we need an immutable type but -need to change an inner value of that type; it also enforces the borrowing -rules at runtime instead of at compile time. - -Also discussed were the `Deref` and `Drop` traits, which enable a lot of the -functionality of smart pointers. We explored reference cycles that can cause -memory leaks and how to prevent them using `Weak`. - -If this chapter has piqued your interest and you want to implement your own -smart pointers, check out [“The Rustonomicon”][nomicon] for more useful -information. - -[nomicon]: https://doc.rust-lang.org/stable/nomicon/ - -Next, we’ll talk about concurrency in Rust. You’ll even learn about a few new -smart pointers. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch15-06-reference-cycles.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch16-00-concurrency.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch16-00-concurrency.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch16-00-concurrency.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch16-00-concurrency.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,49 +1,10 @@ # Fearless Concurrency -Handling concurrent programming safely and efficiently is another of Rust’s -major goals. *Concurrent programming*, where different parts of a program -execute independently, and *parallel programming*, where different parts of a -program execute at the same time, are becoming increasingly important as more -computers take advantage of their multiple processors. Historically, -programming in these contexts has been difficult and error prone: Rust hopes to -change that. +The 2018 edition of the book is no longer distributed with Rust's documentation. -Initially, the Rust team thought that ensuring memory safety and preventing -concurrency problems were two separate challenges to be solved with different -methods. Over time, the team discovered that the ownership and type systems are -a powerful set of tools to help manage memory safety *and* concurrency -problems! By leveraging ownership and type checking, many concurrency errors -are compile-time errors in Rust rather than runtime errors. Therefore, rather -than making you spend lots of time trying to reproduce the exact circumstances -under which a runtime concurrency bug occurs, incorrect code will refuse to -compile and present an error explaining the problem. As a result, you can fix -your code while you’re working on it rather than potentially after it has been -shipped to production. We’ve nicknamed this aspect of Rust *fearless* -*concurrency*. Fearless concurrency allows you to write code that is free of -subtle bugs and is easy to refactor without introducing new bugs. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -> Note: For simplicity’s sake, we’ll refer to many of the problems as -> *concurrent* rather than being more precise by saying *concurrent and/or -> parallel*. If this book were about concurrency and/or parallelism, we’d be -> more specific. For this chapter, please mentally substitute *concurrent -> and/or parallel* whenever we use *concurrent*. - -Many languages are dogmatic about the solutions they offer for handling -concurrent problems. For example, Erlang has elegant functionality for -message-passing concurrency but has only obscure ways to share state between -threads. Supporting only a subset of possible solutions is a reasonable -strategy for higher-level languages, because a higher-level language promises -benefits from giving up some control to gain abstractions. However, lower-level -languages are expected to provide the solution with the best performance in any -given situation and have fewer abstractions over the hardware. Therefore, Rust -offers a variety of tools for modeling problems in whatever way is appropriate -for your situation and requirements. - -Here are the topics we’ll cover in this chapter: - -* How to create threads to run multiple pieces of code at the same time -* *Message-passing* concurrency, where channels send messages between threads -* *Shared-state* concurrency, where multiple threads have access to some piece - of data -* The `Sync` and `Send` traits, which extend Rust’s concurrency guarantees to - user-defined types as well as types provided by the standard library +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch16-00-concurrency.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch16-01-threads.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch16-01-threads.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch16-01-threads.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch16-01-threads.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,399 +1,10 @@ ## Using Threads to Run Code Simultaneously -In most current operating systems, an executed program’s code is run in a -*process*, and the operating system manages multiple processes at once. Within -your program, you can also have independent parts that run simultaneously. The -features that run these independent parts are called *threads*. +The 2018 edition of the book is no longer distributed with Rust's documentation. -Splitting the computation in your program into multiple threads can improve -performance because the program does multiple tasks at the same time, but it -also adds complexity. Because threads can run simultaneously, there’s no -inherent guarantee about the order in which parts of your code on different -threads will run. This can lead to problems, such as: +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -* Race conditions, where threads are accessing data or resources in an - inconsistent order -* Deadlocks, where two threads are waiting for each other to finish using a - resource the other thread has, preventing both threads from continuing -* Bugs that happen only in certain situations and are hard to reproduce and fix - reliably - -Rust attempts to mitigate the negative effects of using threads, but -programming in a multithreaded context still takes careful thought and requires -a code structure that is different from that in programs running in a single -thread. - -Programming languages implement threads in a few different ways. Many operating -systems provide an API for creating new threads. This model where a language -calls the operating system APIs to create threads is sometimes called *1:1*, -meaning one operating system thread per one language thread. - -Many programming languages provide their own special implementation of threads. -Programming language-provided threads are known as *green* threads, and -languages that use these green threads will execute them in the context of a -different number of operating system threads. For this reason, the -green-threaded model is called the *M:N* model: there are `M` green threads per -`N` operating system threads, where `M` and `N` are not necessarily the same -number. - -Each model has its own advantages and trade-offs, and the trade-off most -important to Rust is runtime support. *Runtime* is a confusing term and can -have different meanings in different contexts. - -In this context, by *runtime* we mean code that is included by the language in -every binary. This code can be large or small depending on the language, but -every non-assembly language will have some amount of runtime code. For that -reason, colloquially when people say a language has “no runtime,” they often -mean “small runtime.” Smaller runtimes have fewer features but have the -advantage of resulting in smaller binaries, which make it easier to combine the -language with other languages in more contexts. Although many languages are -okay with increasing the runtime size in exchange for more features, Rust needs -to have nearly no runtime and cannot compromise on being able to call into C to -maintain performance. - -The green-threading M:N model requires a larger language runtime to manage -threads. As such, the Rust standard library only provides an implementation of -1:1 threading. Because Rust is such a low-level language, there are crates that -implement M:N threading if you would rather trade overhead for aspects such as -more control over which threads run when and lower costs of context switching, -for example. - -Now that we’ve defined threads in Rust, let’s explore how to use the -thread-related API provided by the standard library. - -### Creating a New Thread with `spawn` - -To create a new thread, we call the `thread::spawn` function and pass it a -closure (we talked about closures in Chapter 13) containing the code we want to -run in the new thread. The example in Listing 16-1 prints some text from a main -thread and other text from a new thread: - -Filename: src/main.rs - -```rust -use std::thread; -use std::time::Duration; - -fn main() { - thread::spawn(|| { - for i in 1..10 { - println!("hi number {} from the spawned thread!", i); - thread::sleep(Duration::from_millis(1)); - } - }); - - for i in 1..5 { - println!("hi number {} from the main thread!", i); - thread::sleep(Duration::from_millis(1)); - } -} -``` - -Listing 16-1: Creating a new thread to print one thing -while the main thread prints something else - -Note that with this function, the new thread will be stopped when the main -thread ends, whether or not it has finished running. The output from this -program might be a little different every time, but it will look similar to the -following: - -```text -hi number 1 from the main thread! -hi number 1 from the spawned thread! -hi number 2 from the main thread! -hi number 2 from the spawned thread! -hi number 3 from the main thread! -hi number 3 from the spawned thread! -hi number 4 from the main thread! -hi number 4 from the spawned thread! -hi number 5 from the spawned thread! -``` - -The calls to `thread::sleep` force a thread to stop its execution for a short -duration, allowing a different thread to run. The threads will probably take -turns, but that isn’t guaranteed: it depends on how your operating system -schedules the threads. In this run, the main thread printed first, even though -the print statement from the spawned thread appears first in the code. And even -though we told the spawned thread to print until `i` is 9, it only got to 5 -before the main thread shut down. - -If you run this code and only see output from the main thread, or don’t see any -overlap, try increasing the numbers in the ranges to create more opportunities -for the operating system to switch between the threads. - -### Waiting for All Threads to Finish Using `join` Handles - -The code in Listing 16-1 not only stops the spawned thread prematurely most of -the time due to the main thread ending, but also can't guarantee that the -spawned thread will get to run at all. The reason is that there is no guarantee -on the order in which threads run! - -We can fix the problem of the spawned thread not getting to run, or not getting -to run completely, by saving the return value of `thread::spawn` in a variable. -The return type of `thread::spawn` is `JoinHandle`. A `JoinHandle` is an owned -value that, when we call the `join` method on it, will wait for its thread to -finish. Listing 16-2 shows how to use the `JoinHandle` of the thread we created -in Listing 16-1 and call `join` to make sure the spawned thread finishes before -`main` exits: - -Filename: src/main.rs - -```rust -use std::thread; -use std::time::Duration; - -fn main() { - let handle = thread::spawn(|| { - for i in 1..10 { - println!("hi number {} from the spawned thread!", i); - thread::sleep(Duration::from_millis(1)); - } - }); - - for i in 1..5 { - println!("hi number {} from the main thread!", i); - thread::sleep(Duration::from_millis(1)); - } - - handle.join().unwrap(); -} -``` - -Listing 16-2: Saving a `JoinHandle` from `thread::spawn` -to guarantee the thread is run to completion - -Calling `join` on the handle blocks the thread currently running until the -thread represented by the handle terminates. *Blocking* a thread means that -thread is prevented from performing work or exiting. Because we’ve put the call -to `join` after the main thread’s `for` loop, running Listing 16-2 should -produce output similar to this: - -```text -hi number 1 from the main thread! -hi number 2 from the main thread! -hi number 1 from the spawned thread! -hi number 3 from the main thread! -hi number 2 from the spawned thread! -hi number 4 from the main thread! -hi number 3 from the spawned thread! -hi number 4 from the spawned thread! -hi number 5 from the spawned thread! -hi number 6 from the spawned thread! -hi number 7 from the spawned thread! -hi number 8 from the spawned thread! -hi number 9 from the spawned thread! -``` - -The two threads continue alternating, but the main thread waits because of the -call to `handle.join()` and does not end until the spawned thread is finished. - -But let’s see what happens when we instead move `handle.join()` before the -`for` loop in `main`, like this: - -Filename: src/main.rs - -```rust -use std::thread; -use std::time::Duration; - -fn main() { - let handle = thread::spawn(|| { - for i in 1..10 { - println!("hi number {} from the spawned thread!", i); - thread::sleep(Duration::from_millis(1)); - } - }); - - handle.join().unwrap(); - - for i in 1..5 { - println!("hi number {} from the main thread!", i); - thread::sleep(Duration::from_millis(1)); - } -} -``` - -The main thread will wait for the spawned thread to finish and then run its -`for` loop, so the output won’t be interleaved anymore, as shown here: - -```text -hi number 1 from the spawned thread! -hi number 2 from the spawned thread! -hi number 3 from the spawned thread! -hi number 4 from the spawned thread! -hi number 5 from the spawned thread! -hi number 6 from the spawned thread! -hi number 7 from the spawned thread! -hi number 8 from the spawned thread! -hi number 9 from the spawned thread! -hi number 1 from the main thread! -hi number 2 from the main thread! -hi number 3 from the main thread! -hi number 4 from the main thread! -``` - -Small details, such as where `join` is called, can affect whether or not your -threads run at the same time. - -### Using `move` Closures with Threads - -The `move` closure is often used alongside `thread::spawn` because it allows -you to use data from one thread in another thread. - -In Chapter 13, we mentioned we can use the `move` keyword before the parameter -list of a closure to force the closure to take ownership of the values it uses -in the environment. This technique is especially useful when creating new -threads in order to transfer ownership of values from one thread to another. - -Notice in Listing 16-1 that the closure we pass to `thread::spawn` takes no -arguments: we’re not using any data from the main thread in the spawned -thread’s code. To use data from the main thread in the spawned thread, the -spawned thread’s closure must capture the values it needs. Listing 16-3 shows -an attempt to create a vector in the main thread and use it in the spawned -thread. However, this won’t yet work, as you’ll see in a moment. - -Filename: src/main.rs - -```rust,ignore -use std::thread; - -fn main() { - let v = vec![1, 2, 3]; - - let handle = thread::spawn(|| { - println!("Here's a vector: {:?}", v); - }); - - handle.join().unwrap(); -} -``` - -Listing 16-3: Attempting to use a vector created by the -main thread in another thread - -The closure uses `v`, so it will capture `v` and make it part of the closure’s -environment. Because `thread::spawn` runs this closure in a new thread, we -should be able to access `v` inside that new thread. But when we compile this -example, we get the following error: - -```text -error[E0373]: closure may outlive the current function, but it borrows `v`, -which is owned by the current function - --> src/main.rs:6:32 - | -6 | let handle = thread::spawn(|| { - | ^^ may outlive borrowed value `v` -7 | println!("Here's a vector: {:?}", v); - | - `v` is borrowed here - | -help: to force the closure to take ownership of `v` (and any other referenced -variables), use the `move` keyword - | -6 | let handle = thread::spawn(move || { - | ^^^^^^^ -``` - -Rust *infers* how to capture `v`, and because `println!` only needs a reference -to `v`, the closure tries to borrow `v`. However, there’s a problem: Rust can’t -tell how long the spawned thread will run, so it doesn’t know if the reference -to `v` will always be valid. - -Listing 16-4 provides a scenario that’s more likely to have a reference to `v` -that won’t be valid: - -Filename: src/main.rs - -```rust,ignore -use std::thread; - -fn main() { - let v = vec![1, 2, 3]; - - let handle = thread::spawn(|| { - println!("Here's a vector: {:?}", v); - }); - - drop(v); // oh no! - - handle.join().unwrap(); -} -``` - -Listing 16-4: A thread with a closure that attempts to -capture a reference to `v` from a main thread that drops `v` - -If we were allowed to run this code, there’s a possibility the spawned thread -would be immediately put in the background without running at all. The spawned -thread has a reference to `v` inside, but the main thread immediately drops -`v`, using the `drop` function we discussed in Chapter 15. Then, when the -spawned thread starts to execute, `v` is no longer valid, so a reference to it -is also invalid. Oh no! - -To fix the compiler error in Listing 16-3, we can use the error message’s -advice: - -```text -help: to force the closure to take ownership of `v` (and any other referenced -variables), use the `move` keyword - | -6 | let handle = thread::spawn(move || { - | ^^^^^^^ -``` - -By adding the `move` keyword before the closure, we force the closure to take -ownership of the values it’s using rather than allowing Rust to infer that it -should borrow the values. The modification to Listing 16-3 shown in Listing -16-5 will compile and run as we intend: - -Filename: src/main.rs - -```rust -use std::thread; - -fn main() { - let v = vec![1, 2, 3]; - - let handle = thread::spawn(move || { - println!("Here's a vector: {:?}", v); - }); - - handle.join().unwrap(); -} -``` - -Listing 16-5: Using the `move` keyword to force a closure -to take ownership of the values it uses - -What would happen to the code in Listing 16-4 where the main thread called -`drop` if we use a `move` closure? Would `move` fix that case? Unfortunately, -no; we would get a different error because what Listing 16-4 is trying to do -isn’t allowed for a different reason. If we added `move` to the closure, we -would move `v` into the closure’s environment, and we could no longer call -`drop` on it in the main thread. We would get this compiler error instead: - -```text -error[E0382]: use of moved value: `v` - --> src/main.rs:10:10 - | -6 | let handle = thread::spawn(move || { - | ------- value moved (into closure) here -... -10 | drop(v); // oh no! - | ^ value used here after move - | - = note: move occurs because `v` has type `std::vec::Vec`, which does - not implement the `Copy` trait -``` - -Rust’s ownership rules have saved us again! We got an error from the code in -Listing 16-3 because Rust was being conservative and only borrowing `v` for the -thread, which meant the main thread could theoretically invalidate the spawned -thread’s reference. By telling Rust to move ownership of `v` to the spawned -thread, we’re guaranteeing Rust that the main thread won’t use `v` anymore. If -we change Listing 16-4 in the same way, we’re then violating the ownership -rules when we try to use `v` in the main thread. The `move` keyword overrides -Rust’s conservative default of borrowing; it doesn’t let us violate the -ownership rules. - -With a basic understanding of threads and the thread API, let’s look at what we -can *do* with threads. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch16-01-threads.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch16-02-message-passing.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch16-02-message-passing.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch16-02-message-passing.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch16-02-message-passing.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,366 +1,10 @@ ## Using Message Passing to Transfer Data Between Threads -One increasingly popular approach to ensuring safe concurrency is *message -passing*, where threads or actors communicate by sending each other messages -containing data. Here’s the idea in a slogan from [the Go language -documentation](http://golang.org/doc/effective_go.html): "Do not communicate by -sharing memory; instead, share memory by communicating." +The 2018 edition of the book is no longer distributed with Rust's documentation. -One major tool Rust has for accomplishing message-sending concurrency is the -*channel*, a programming concept that Rust’s standard library provides an -implementation of. You can imagine a channel in programming as being like a -channel of water, such as a stream or a river. If you put something like a -rubber duck or boat into a stream, it will travel downstream to the end of the -waterway. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -A channel in programming has two halves: a transmitter and a receiver. The -transmitter half is the upstream location where you put rubber ducks into the -river, and the receiver half is where the rubber duck ends up downstream. One -part of your code calls methods on the transmitter with the data you want to -send, and another part checks the receiving end for arriving messages. A -channel is said to be *closed* if either the transmitter or receiver half is -dropped. - -Here, we’ll work up to a program that has one thread to generate values and -send them down a channel, and another thread that will receive the values and -print them out. We’ll be sending simple values between threads using a channel -to illustrate the feature. Once you’re familiar with the technique, you could -use channels to implement a chat system or a system where many threads perform -parts of a calculation and send the parts to one thread that aggregates the -results. - -First, in Listing 16-6, we’ll create a channel but not do anything with it. -Note that this won’t compile yet because Rust can’t tell what type of values we -want to send over the channel. - -Filename: src/main.rs - -```rust -use std::sync::mpsc; - -fn main() { - let (tx, rx) = mpsc::channel(); -# tx.send(()).unwrap(); -} -``` - -Listing 16-6: Creating a channel and assigning the two -halves to `tx` and `rx` - -We create a new channel using the `mpsc::channel` function; `mpsc` stands for -*multiple producer, single consumer*. In short, the way Rust’s standard library -implements channels means a channel can have multiple *sending* ends that -produce values but only one *receiving* end that consumes those values. Imagine -multiple streams flowing together into one big river: everything sent down any -of the streams will end up in one river at the end. We’ll start with a single -producer for now, but we’ll add multiple producers when we get this example -working. - - - -The `mpsc::channel` function returns a tuple, the first element of which is the -sending end and the second element is the receiving end. The abbreviations `tx` -and `rx` are traditionally used in many fields for *transmitter* and *receiver* -respectively, so we name our variables as such to indicate each end. We’re -using a `let` statement with a pattern that destructures the tuples; we’ll -discuss the use of patterns in `let` statements and destructuring in -Chapter 18. Using a `let` statement this way is a convenient approach to -extract the pieces of the tuple returned by `mpsc::channel`. - -Let’s move the transmitting end into a spawned thread and have it send one -string so the spawned thread is communicating with the main thread, as shown in -Listing 16-7. This is like putting a rubber duck in the river upstream or -sending a chat message from one thread to another. - -Filename: src/main.rs - -```rust -use std::thread; -use std::sync::mpsc; - -fn main() { - let (tx, rx) = mpsc::channel(); - - thread::spawn(move || { - let val = String::from("hi"); - tx.send(val).unwrap(); - }); -} -``` - -Listing 16-7: Moving `tx` to a spawned thread and sending -“hi” - -Again, we’re using `thread::spawn` to create a new thread and then using `move` -to move `tx` into the closure so the spawned thread owns `tx`. The spawned -thread needs to own the transmitting end of the channel to be able to send -messages through the channel. - -The transmitting end has a `send` method that takes the value we want to send. -The `send` method returns a `Result` type, so if the receiving end has -already been dropped and there’s nowhere to send a value, the send operation -will return an error. In this example, we’re calling `unwrap` to panic in case -of an error. But in a real application, we would handle it properly: return to -Chapter 9 to review strategies for proper error handling. - -In Listing 16-8, we’ll get the value from the receiving end of the channel in -the main thread. This is like retrieving the rubber duck from the water at the -end of the river or like getting a chat message. - -Filename: src/main.rs - -```rust -use std::thread; -use std::sync::mpsc; - -fn main() { - let (tx, rx) = mpsc::channel(); - - thread::spawn(move || { - let val = String::from("hi"); - tx.send(val).unwrap(); - }); - - let received = rx.recv().unwrap(); - println!("Got: {}", received); -} -``` - -Listing 16-8: Receiving the value “hi” in the main thread -and printing it - -The receiving end of a channel has two useful methods: `recv` and `try_recv`. -We’re using `recv`, short for *receive*, which will block the main thread’s -execution and wait until a value is sent down the channel. Once a value is -sent, `recv` will return it in a `Result`. When the sending end of the -channel closes, `recv` will return an error to signal that no more values will -be coming. - -The `try_recv` method doesn’t block, but will instead return a `Result` -immediately: an `Ok` value holding a message if one is available and an `Err` -value if there aren’t any messages this time. Using `try_recv` is useful if -this thread has other work to do while waiting for messages: we could write a -loop that calls `try_recv` every so often, handles a message if one is -available, and otherwise does other work for a little while until checking -again. - -We’ve used `recv` in this example for simplicity; we don’t have any other work -for the main thread to do other than wait for messages, so blocking the main -thread is appropriate. - -When we run the code in Listing 16-8, we’ll see the value printed from the main -thread: - -```text -Got: hi -``` - -Perfect! - -### Channels and Ownership Transference - -The ownership rules play a vital role in message sending because they help you -write safe, concurrent code. Preventing errors in concurrent programming is the -advantage of thinking about ownership throughout your Rust programs. Let’s do -an experiment to show how channels and ownership work together to prevent -problems: we’ll try to use a `val` value in the spawned thread *after* we’ve -sent it down the channel. Try compiling the code in Listing 16-9 to see why -this code isn't allowed: - -Filename: src/main.rs - -```rust,ignore -use std::thread; -use std::sync::mpsc; - -fn main() { - let (tx, rx) = mpsc::channel(); - - thread::spawn(move || { - let val = String::from("hi"); - tx.send(val).unwrap(); - println!("val is {}", val); - }); - - let received = rx.recv().unwrap(); - println!("Got: {}", received); -} -``` - -Listing 16-9: Attempting to use `val` after we’ve sent it -down the channel - -Here, we try to print `val` after we’ve sent it down the channel via `tx.send`. -Allowing this would be a bad idea: once the value has been sent to another -thread, that thread could modify or drop it before we try to use the value -again. Potentially, the other thread’s modifications could cause errors or -unexpected results due to inconsistent or nonexistent data. However, Rust gives -us an error if we try to compile the code in Listing 16-9: - -```text -error[E0382]: use of moved value: `val` - --> src/main.rs:10:31 - | -9 | tx.send(val).unwrap(); - | --- value moved here -10 | println!("val is {}", val); - | ^^^ value used here after move - | - = note: move occurs because `val` has type `std::string::String`, which does -not implement the `Copy` trait -``` - -Our concurrency mistake has caused a compile time error. The `send` function -takes ownership of its parameter, and when the value is moved, the receiver -takes ownership of it. This stops us from accidentally using the value again -after sending it; the ownership system checks that everything is okay. - -### Sending Multiple Values and Seeing the Receiver Waiting - -The code in Listing 16-8 compiled and ran, but it didn’t clearly show us that -two separate threads were talking to each other over the channel. In Listing -16-10 we’ve made some modifications that will prove the code in Listing 16-8 is -running concurrently: the spawned thread will now send multiple messages and -pause for a second between each message. - -Filename: src/main.rs - -```rust -use std::thread; -use std::sync::mpsc; -use std::time::Duration; - -fn main() { - let (tx, rx) = mpsc::channel(); - - thread::spawn(move || { - let vals = vec![ - String::from("hi"), - String::from("from"), - String::from("the"), - String::from("thread"), - ]; - - for val in vals { - tx.send(val).unwrap(); - thread::sleep(Duration::from_secs(1)); - } - }); - - for received in rx { - println!("Got: {}", received); - } -} -``` - -Listing 16-10: Sending multiple messages and pausing -between each - -This time, the spawned thread has a vector of strings that we want to send to -the main thread. We iterate over them, sending each individually, and pause -between each by calling the `thread::sleep` function with a `Duration` value of -1 second. - -In the main thread, we’re not calling the `recv` function explicitly anymore: -instead, we’re treating `rx` as an iterator. For each value received, we’re -printing it. When the channel is closed, iteration will end. - -When running the code in Listing 16-10, you should see the following output -with a 1-second pause in between each line: - -```text -Got: hi -Got: from -Got: the -Got: thread -``` - -Because we don’t have any code that pauses or delays in the `for` loop in the -main thread, we can tell that the main thread is waiting to receive values from -the spawned thread. - -### Creating Multiple Producers by Cloning the Transmitter - -Earlier we mentioned that `mpsc` was an acronym for *multiple producer, -single consumer*. Let’s put `mpsc` to use and expand the code in Listing 16-10 -to create multiple threads that all send values to the same receiver. We can do -so by cloning the transmitting half of the channel, as shown in Listing 16-11: - -Filename: src/main.rs - -```rust -# use std::thread; -# use std::sync::mpsc; -# use std::time::Duration; -# -# fn main() { -// --snip-- - -let (tx, rx) = mpsc::channel(); - -let tx1 = mpsc::Sender::clone(&tx); -thread::spawn(move || { - let vals = vec![ - String::from("hi"), - String::from("from"), - String::from("the"), - String::from("thread"), - ]; - - for val in vals { - tx1.send(val).unwrap(); - thread::sleep(Duration::from_secs(1)); - } -}); - -thread::spawn(move || { - let vals = vec![ - String::from("more"), - String::from("messages"), - String::from("for"), - String::from("you"), - ]; - - for val in vals { - tx.send(val).unwrap(); - thread::sleep(Duration::from_secs(1)); - } -}); - -for received in rx { - println!("Got: {}", received); -} - -// --snip-- -# } -``` - -Listing 16-11: Sending multiple messages from multiple -producers - -This time, before we create the first spawned thread, we call `clone` on the -sending end of the channel. This will give us a new sending handle we can pass -to the first spawned thread. We pass the original sending end of the channel to -a second spawned thread. This gives us two threads, each sending different -messages to the receiving end of the channel. - -When you run the code, your output should look something like this: - -```text -Got: hi -Got: more -Got: from -Got: messages -Got: for -Got: the -Got: thread -Got: you -``` - -You might see the values in another order; it depends on your system. This is -what makes concurrency interesting as well as difficult. If you experiment with -`thread::sleep`, giving it various values in the different threads, each run -will be more nondeterministic and create different output each time. - -Now that we’ve looked at how channels work, let’s look at a different method of -concurrency. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch16-02-message-passing.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch16-03-shared-state.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch16-03-shared-state.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch16-03-shared-state.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch16-03-shared-state.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,426 +1,10 @@ ## Shared-State Concurrency -Message passing is a fine way of handling concurrency, but it’s not the only -one. Consider this part of the slogan from the Go language documentation again: -“communicate by sharing memory.” +The 2018 edition of the book is no longer distributed with Rust's documentation. -What would communicating by sharing memory look like? In addition, why would -message-passing enthusiasts not use it and do the opposite instead? +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -In a way, channels in any programming language are similar to single ownership, -because once you transfer a value down a channel, you should no longer use that -value. Shared memory concurrency is like multiple ownership: multiple threads -can access the same memory location at the same time. As you saw in Chapter 15, -where smart pointers made multiple ownership possible, multiple ownership can -add complexity because these different owners need managing. Rust’s type system -and ownership rules greatly assist in getting this management correct. For an -example, let’s look at mutexes, one of the more common concurrency primitives -for shared memory. - -### Using Mutexes to Allow Access to Data from One Thread at a Time - -*Mutex* is an abbreviation for *mutual exclusion*, as in, a mutex allows only -one thread to access some data at any given time. To access the data in a -mutex, a thread must first signal that it wants access by asking to acquire the -mutex’s *lock*. The lock is a data structure that is part of the mutex that -keeps track of who currently has exclusive access to the data. Therefore, the -mutex is described as *guarding* the data it holds via the locking system. - -Mutexes have a reputation for being difficult to use because you have to -remember two rules: - -* You must attempt to acquire the lock before using the data. -* When you’re done with the data that the mutex guards, you must unlock the - data so other threads can acquire the lock. - -For a real-world metaphor for a mutex, imagine a panel discussion at a -conference with only one microphone. Before a panelist can speak, they have to -ask or signal that they want to use the microphone. When they get the -microphone, they can talk for as long as they want to and then hand the -microphone to the next panelist who requests to speak. If a panelist forgets to -hand the microphone off when they’re finished with it, no one else is able to -speak. If management of the shared microphone goes wrong, the panel won’t work -as planned! - -Management of mutexes can be incredibly tricky to get right, which is why so -many people are enthusiastic about channels. However, thanks to Rust’s type -system and ownership rules, you can’t get locking and unlocking wrong. - -#### The API of `Mutex` - -As an example of how to use a mutex, let’s start by using a mutex in a -single-threaded context, as shown in Listing 16-12: - -Filename: src/main.rs - -```rust -use std::sync::Mutex; - -fn main() { - let m = Mutex::new(5); - - { - let mut num = m.lock().unwrap(); - *num = 6; - } - - println!("m = {:?}", m); -} -``` - -Listing 16-12: Exploring the API of `Mutex` in a -single-threaded context for simplicity - -As with many types, we create a `Mutex` using the associated function `new`. -To access the data inside the mutex, we use the `lock` method to acquire the -lock. This call will block the current thread so it can’t do any work until -it’s our turn to have the lock. - -The call to `lock` would fail if another thread holding the lock panicked. In -that case, no one would ever be able to get the lock, so we’ve chosen to -`unwrap` and have this thread panic if we’re in that situation. - -After we’ve acquired the lock, we can treat the return value, named `num` in -this case, as a mutable reference to the data inside. The type system ensures -that we acquire a lock before using the value in `m`: `Mutex` is not an -`i32`, so we *must* acquire the lock to be able to use the `i32` value. We -can’t forget; the type system won’t let us access the inner `i32` otherwise. - -As you might suspect, `Mutex` is a smart pointer. More accurately, the call -to `lock` *returns* a smart pointer called `MutexGuard`. This smart pointer -implements `Deref` to point at our inner data; the smart pointer also has a -`Drop` implementation that releases the lock automatically when a `MutexGuard` -goes out of scope, which happens at the end of the inner scope in Listing -16-12. As a result, we don’t risk forgetting to release the lock and blocking -the mutex from being used by other threads because the lock release happens -automatically. - -After dropping the lock, we can print the mutex value and see that we were able -to change the inner `i32` to 6. - -#### Sharing a `Mutex` Between Multiple Threads - -Now, let’s try to share a value between multiple threads using `Mutex`. -We’ll spin up 10 threads and have them each increment a counter value by 1, so -the counter goes from 0 to 10. Note that the next few examples will have -compiler errors, and we’ll use those errors to learn more about using -`Mutex` and how Rust helps us use it correctly. Listing 16-13 has our -starting example: - -Filename: src/main.rs - -```rust,ignore -use std::sync::Mutex; -use std::thread; - -fn main() { - let counter = Mutex::new(0); - let mut handles = vec![]; - - for _ in 0..10 { - let handle = thread::spawn(move || { - let mut num = counter.lock().unwrap(); - - *num += 1; - }); - handles.push(handle); - } - - for handle in handles { - handle.join().unwrap(); - } - - println!("Result: {}", *counter.lock().unwrap()); -} -``` - -Listing 16-13: Ten threads each increment a counter -guarded by a `Mutex` - -We create a `counter` variable to hold an `i32` inside a `Mutex`, as we -did in Listing 16-12. Next, we create 10 threads by iterating over a range -of numbers. We use `thread::spawn` and give all the threads the same closure, -one that moves the counter into the thread, acquires a lock on the `Mutex` -by calling the `lock` method, and then adds 1 to the value in the mutex. When a -thread finishes running its closure, `num` will go out of scope and release the -lock so another thread can acquire it. - -In the main thread, we collect all the join handles. Then, as we did in Listing -16-2, we call `join` on each handle to make sure all the threads finish. At -that point, the main thread will acquire the lock and print the result of this -program. - -We hinted that this example wouldn’t compile. Now let’s find out why! - -```text -error[E0382]: capture of moved value: `counter` - --> src/main.rs:10:27 - | -9 | let handle = thread::spawn(move || { - | ------- value moved (into closure) here -10 | let mut num = counter.lock().unwrap(); - | ^^^^^^^ value captured here after move - | - = note: move occurs because `counter` has type `std::sync::Mutex`, - which does not implement the `Copy` trait - -error[E0382]: use of moved value: `counter` - --> src/main.rs:21:29 - | -9 | let handle = thread::spawn(move || { - | ------- value moved (into closure) here -... -21 | println!("Result: {}", *counter.lock().unwrap()); - | ^^^^^^^ value used here after move - | - = note: move occurs because `counter` has type `std::sync::Mutex`, - which does not implement the `Copy` trait - -error: aborting due to 2 previous errors -``` - -The error message states that the `counter` value is moved into the closure and -then captured when we call `lock`. That description sounds like what we wanted, -but it’s not allowed! - -Let’s figure this out by simplifying the program. Instead of making 10 threads -in a `for` loop, let’s just make two threads without a loop and see what -happens. Replace the first `for` loop in Listing 16-13 with this code instead: - -```rust,ignore -use std::sync::Mutex; -use std::thread; - -fn main() { - let counter = Mutex::new(0); - let mut handles = vec![]; - - let handle = thread::spawn(move || { - let mut num = counter.lock().unwrap(); - - *num += 1; - }); - handles.push(handle); - - let handle2 = thread::spawn(move || { - let mut num2 = counter.lock().unwrap(); - - *num2 += 1; - }); - handles.push(handle2); - - for handle in handles { - handle.join().unwrap(); - } - - println!("Result: {}", *counter.lock().unwrap()); -} -``` - -We make two threads and change the variable names used with the second thread -to `handle2` and `num2`. When we run the code this time, compiling gives us the -following: - -```text -error[E0382]: capture of moved value: `counter` - --> src/main.rs:16:24 - | -8 | let handle = thread::spawn(move || { - | ------- value moved (into closure) here -... -16 | let mut num2 = counter.lock().unwrap(); - | ^^^^^^^ value captured here after move - | - = note: move occurs because `counter` has type `std::sync::Mutex`, - which does not implement the `Copy` trait - -error[E0382]: use of moved value: `counter` - --> src/main.rs:26:29 - | -8 | let handle = thread::spawn(move || { - | ------- value moved (into closure) here -... -26 | println!("Result: {}", *counter.lock().unwrap()); - | ^^^^^^^ value used here after move - | - = note: move occurs because `counter` has type `std::sync::Mutex`, - which does not implement the `Copy` trait - -error: aborting due to 2 previous errors -``` - -Aha! The first error message indicates that `counter` is moved into the closure -for the thread associated with `handle`. That move is preventing us from -capturing `counter` when we try to call `lock` on it and store the result in -`num2` in the second thread! So Rust is telling us that we can’t move ownership -of `counter` into multiple threads. This was hard to see earlier because our -threads were in a loop, and Rust can’t point to different threads in different -iterations of the loop. Let’s fix the compiler error with a multiple-ownership -method we discussed in Chapter 15. - -#### Multiple Ownership with Multiple Threads - -In Chapter 15, we gave a value multiple owners by using the smart pointer -`Rc` to create a reference counted value. Let’s do the same here and see -what happens. We’ll wrap the `Mutex` in `Rc` in Listing 16-14 and clone -the `Rc` before moving ownership to the thread. Now that we’ve seen the -errors, we’ll also switch back to using the `for` loop, and we’ll keep the -`move` keyword with the closure. - -Filename: src/main.rs - -```rust,ignore -use std::rc::Rc; -use std::sync::Mutex; -use std::thread; - -fn main() { - let counter = Rc::new(Mutex::new(0)); - let mut handles = vec![]; - - for _ in 0..10 { - let counter = Rc::clone(&counter); - let handle = thread::spawn(move || { - let mut num = counter.lock().unwrap(); - - *num += 1; - }); - handles.push(handle); - } - - for handle in handles { - handle.join().unwrap(); - } - - println!("Result: {}", *counter.lock().unwrap()); -} -``` - -Listing 16-14: Attempting to use `Rc` to allow -multiple threads to own the `Mutex` - -Once again, we compile and get... different errors! The compiler is teaching us -a lot. - -```text -error[E0277]: the trait bound `std::rc::Rc>: -std::marker::Send` is not satisfied in `[closure@src/main.rs:11:36: -15:10 counter:std::rc::Rc>]` - --> src/main.rs:11:22 - | -11 | let handle = thread::spawn(move || { - | ^^^^^^^^^^^^^ `std::rc::Rc>` -cannot be sent between threads safely - | - = help: within `[closure@src/main.rs:11:36: 15:10 -counter:std::rc::Rc>]`, the trait `std::marker::Send` is -not implemented for `std::rc::Rc>` - = note: required because it appears within the type -`[closure@src/main.rs:11:36: 15:10 counter:std::rc::Rc>]` - = note: required by `std::thread::spawn` -``` - -Wow, that error message is very wordy! Here are some important parts to focus -on: the first inline error says `` `std::rc::Rc>` cannot -be sent between threads safely ``. The reason for this is in the next important -part to focus on, the error message. The distilled error message says `` the -trait bound `Send` is not satisfied ``. We’ll talk about `Send` in the next -section: it’s one of the traits that ensures the types we use with threads are -meant for use in concurrent situations. - -Unfortunately, `Rc` is not safe to share across threads. When `Rc` -manages the reference count, it adds to the count for each call to `clone` and -subtracts from the count when each clone is dropped. But it doesn’t use any -concurrency primitives to make sure that changes to the count can’t be -interrupted by another thread. This could lead to wrong counts—subtle bugs that -could in turn lead to memory leaks or a value being dropped before we’re done -with it. What we need is a type exactly like `Rc` but one that makes changes -to the reference count in a thread-safe way. - -#### Atomic Reference Counting with `Arc` - -Fortunately, `Arc` *is* a type like `Rc` that is safe to use in -concurrent situations. The *a* stands for *atomic*, meaning it’s an *atomically -reference counted* type. Atomics are an additional kind of concurrency -primitive that we won’t cover in detail here: see the standard library -documentation for `std::sync::atomic` for more details. At this point, you just -need to know that atomics work like primitive types but are safe to share -across threads. - -You might then wonder why all primitive types aren’t atomic and why standard -library types aren’t implemented to use `Arc` by default. The reason is that -thread safety comes with a performance penalty that you only want to pay when -you really need to. If you’re just performing operations on values within a -single thread, your code can run faster if it doesn’t have to enforce the -guarantees atomics provide. - -Let’s return to our example: `Arc` and `Rc` have the same API, so we fix -our program by changing the `use` line, the call to `new`, and the call to -`clone`. The code in Listing 16-15 will finally compile and run: - -Filename: src/main.rs - -```rust -use std::sync::{Mutex, Arc}; -use std::thread; - -fn main() { - let counter = Arc::new(Mutex::new(0)); - let mut handles = vec![]; - - for _ in 0..10 { - let counter = Arc::clone(&counter); - let handle = thread::spawn(move || { - let mut num = counter.lock().unwrap(); - - *num += 1; - }); - handles.push(handle); - } - - for handle in handles { - handle.join().unwrap(); - } - - println!("Result: {}", *counter.lock().unwrap()); -} -``` - -Listing 16-15: Using an `Arc` to wrap the `Mutex` -to be able to share ownership across multiple threads - -This code will print the following: - -```text -Result: 10 -``` - -We did it! We counted from 0 to 10, which may not seem very impressive, but it -did teach us a lot about `Mutex` and thread safety. You could also use this -program’s structure to do more complicated operations than just incrementing a -counter. Using this strategy, you can divide a calculation into independent -parts, split those parts across threads, and then use a `Mutex` to have each -thread update the final result with its part. - -### Similarities Between `RefCell`/`Rc` and `Mutex`/`Arc` - -You might have noticed that `counter` is immutable but we could get a mutable -reference to the value inside it; this means `Mutex` provides interior -mutability, as the `Cell` family does. In the same way we used `RefCell` in -Chapter 15 to allow us to mutate contents inside an `Rc`, we use `Mutex` -to mutate contents inside an `Arc`. - -Another detail to note is that Rust can’t protect you from all kinds of logic -errors when you use `Mutex`. Recall in Chapter 15 that using `Rc` came -with the risk of creating reference cycles, where two `Rc` values refer to -each other, causing memory leaks. Similarly, `Mutex` comes with the risk of -creating *deadlocks*. These occur when an operation needs to lock two resources -and two threads have each acquired one of the locks, causing them to wait for -each other forever. If you’re interested in deadlocks, try creating a Rust -program that has a deadlock; then research deadlock mitigation strategies for -mutexes in any language and have a go at implementing them in Rust. The -standard library API documentation for `Mutex` and `MutexGuard` offers -useful information. - -We’ll round out this chapter by talking about the `Send` and `Sync` traits and -how we can use them with custom types. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch16-03-shared-state.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch16-04-extensible-concurrency-sync-and-send.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch16-04-extensible-concurrency-sync-and-send.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch16-04-extensible-concurrency-sync-and-send.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch16-04-extensible-concurrency-sync-and-send.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,87 +1,10 @@ ## Extensible Concurrency with the `Sync` and `Send` Traits -Interestingly, the Rust language has *very* few concurrency features. Almost -every concurrency feature we’ve talked about so far in this chapter has been -part of the standard library, not the language. Your options for handling -concurrency are not limited to the language or the standard library; you can -write your own concurrency features or use those written by others. +The 2018 edition of the book is no longer distributed with Rust's documentation. -However, two concurrency concepts are embedded in the language: the -`std::marker` traits `Sync` and `Send`. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -### Allowing Transference of Ownership Between Threads with `Send` - -The `Send` marker trait indicates that ownership of the type implementing -`Send` can be transferred between threads. Almost every Rust type is `Send`, -but there are some exceptions, including `Rc`: this cannot be `Send` because -if you cloned an `Rc` value and tried to transfer ownership of the clone to -another thread, both threads might update the reference count at the same time. -For this reason, `Rc` is implemented for use in single-threaded situations -where you don’t want to pay the thread-safe performance penalty. - -Therefore, Rust’s type system and trait bounds ensure that you can never -accidentally send an `Rc` value across threads unsafely. When we tried to do -this in Listing 16-14, we got the error `the trait Send is not implemented for -Rc>`. When we switched to `Arc`, which is `Send`, the code -compiled. - -Any type composed entirely of `Send` types is automatically marked as `Send` as -well. Almost all primitive types are `Send`, aside from raw pointers, which -we’ll discuss in Chapter 19. - -### Allowing Access from Multiple Threads with `Sync` - -The `Sync` marker trait indicates that it is safe for the type implementing -`Sync` to be referenced from multiple threads. In other words, any type `T` is -`Sync` if `&T` (a reference to `T`) is `Send`, meaning the reference can be -sent safely to another thread. Similar to `Send`, primitive types are `Sync`, -and types composed entirely of types that are `Sync` are also `Sync`. - -The smart pointer `Rc` is also not `Sync` for the same reasons that it’s not -`Send`. The `RefCell` type (which we talked about in Chapter 15) and the -family of related `Cell` types are not `Sync`. The implementation of borrow -checking that `RefCell` does at runtime is not thread-safe. The smart -pointer `Mutex` is `Sync` and can be used to share access with multiple -threads as you saw in the “Sharing a `Mutex` Between Multiple Threads” -section. - -### Implementing `Send` and `Sync` Manually Is Unsafe - -Because types that are made up of `Send` and `Sync` traits are automatically -also `Send` and `Sync`, we don’t have to implement those traits manually. As -marker traits, they don’t even have any methods to implement. They’re just -useful for enforcing invariants related to concurrency. - -Manually implementing these traits involves implementing unsafe Rust code. -We’ll talk about using unsafe Rust code in Chapter 19; for now, the important -information is that building new concurrent types not made up of `Send` and -`Sync` parts requires careful thought to uphold the safety guarantees. -[The Rustonomicon] has more information about these guarantees and how to -uphold them. - -[The Rustonomicon]: https://doc.rust-lang.org/stable/nomicon/ - -## Summary - -This isn’t the last you’ll see of concurrency in this book: the project in -Chapter 20 will use the concepts in this chapter in a more realistic situation -than the smaller examples discussed here. - -As mentioned earlier, because very little of how Rust handles concurrency is -part of the language, many concurrency solutions are implemented as crates. -These evolve more quickly than the standard library, so be sure to search -online for the current, state-of-the-art crates to use in multithreaded -situations. - -The Rust standard library provides channels for message passing and smart -pointer types, such as `Mutex` and `Arc`, that are safe to use in -concurrent contexts. The type system and the borrow checker ensure that the -code using these solutions won’t end up with data races or invalid references. -Once you get your code to compile, you can rest assured that it will happily -run on multiple threads without the kinds of hard-to-track-down bugs common in -other languages. Concurrent programming is no longer a concept to be afraid of: -go forth and make your programs concurrent, fearlessly! - -Next, we’ll talk about idiomatic ways to model problems and structure solutions -as your Rust programs get bigger. In addition, we’ll discuss how Rust’s idioms -relate to those you might be familiar with from object-oriented programming. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch16-04-extensible-concurrency-sync-and-send.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch17-00-oop.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch17-00-oop.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch17-00-oop.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch17-00-oop.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,13 +1,10 @@ # Object Oriented Programming Features of Rust -Object-oriented programming (OOP) is a way of modeling programs. Objects came -from Simula in the 1960s. Those objects influenced Alan Kay’s programming -architecture in which objects pass messages to each other. He coined the term -*object-oriented programming* in 1967 to describe this architecture. Many -competing definitions describe what OOP is; some definitions would classify -Rust as object oriented, but other definitions would not. In this chapter, -we’ll explore certain characteristics that are commonly considered object -oriented and how those characteristics translate to idiomatic Rust. We’ll then -show you how to implement an object-oriented design pattern in Rust and discuss -the trade-offs of doing so versus implementing a solution using some of Rust’s -strengths instead. +The 2018 edition of the book is no longer distributed with Rust's documentation. + +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. + +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch17-00-oop.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch17-01-what-is-oo.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch17-01-what-is-oo.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch17-01-what-is-oo.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch17-01-what-is-oo.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,181 +1,10 @@ ## Characteristics of Object-Oriented Languages -There is no consensus in the programming community about what features a -language must have to be considered object oriented. Rust is influenced by many -programming paradigms, including OOP; for example, we explored the features -that came from functional programming in Chapter 13. Arguably, OOP languages -share certain common characteristics, namely objects, encapsulation, and -inheritance. Let’s look at what each of those characteristics means and whether -Rust supports it. +The 2018 edition of the book is no longer distributed with Rust's documentation. -### Objects Contain Data and Behavior +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -The book *Design Patterns: Elements of Reusable Object-Oriented Software* by -Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides (Addison-Wesley -Professional, 1994) colloquially referred to as *The Gang of Four* book, is a -catalog of object-oriented design patterns. It defines OOP this way: - -> Object-oriented programs are made up of objects. An *object* packages both -> data and the procedures that operate on that data. The procedures are -> typically called *methods* or *operations*. - -Using this definition, Rust is object oriented: structs and enums have data, -and `impl` blocks provide methods on structs and enums. Even though structs and -enums with methods aren’t *called* objects, they provide the same -functionality, according to the Gang of Four’s definition of objects. - -### Encapsulation that Hides Implementation Details - -Another aspect commonly associated with OOP is the idea of *encapsulation*, -which means that the implementation details of an object aren’t accessible to -code using that object. Therefore, the only way to interact with an object is -through its public API; code using the object shouldn’t be able to reach into -the object’s internals and change data or behavior directly. This enables the -programmer to change and refactor an object’s internals without needing to -change the code that uses the object. - -We discussed how to control encapsulation in Chapter 7: we can use the `pub` -keyword to decide which modules, types, functions, and methods in our code -should be public, and by default everything else is private. For example, we -can define a struct `AveragedCollection` that has a field containing a vector -of `i32` values. The struct can also have a field that contains the average of -the values in the vector, meaning the average doesn’t have to be computed -on demand whenever anyone needs it. In other words, `AveragedCollection` will -cache the calculated average for us. Listing 17-1 has the definition of the -`AveragedCollection` struct: - -Filename: src/lib.rs - -```rust -pub struct AveragedCollection { - list: Vec, - average: f64, -} -``` - -Listing 17-1: An `AveragedCollection` struct that -maintains a list of integers and the average of the items in the -collection - -The struct is marked `pub` so that other code can use it, but the fields within -the struct remain private. This is important in this case because we want to -ensure that whenever a value is added or removed from the list, the average is -also updated. We do this by implementing `add`, `remove`, and `average` methods -on the struct, as shown in Listing 17-2: - -Filename: src/lib.rs - -```rust -# pub struct AveragedCollection { -# list: Vec, -# average: f64, -# } -impl AveragedCollection { - pub fn add(&mut self, value: i32) { - self.list.push(value); - self.update_average(); - } - - pub fn remove(&mut self) -> Option { - let result = self.list.pop(); - match result { - Some(value) => { - self.update_average(); - Some(value) - }, - None => None, - } - } - - pub fn average(&self) -> f64 { - self.average - } - - fn update_average(&mut self) { - let total: i32 = self.list.iter().sum(); - self.average = total as f64 / self.list.len() as f64; - } -} -``` - -Listing 17-2: Implementations of the public methods -`add`, `remove`, and `average` on `AveragedCollection` - -The public methods `add`, `remove`, and `average` are the only ways to modify -an instance of `AveragedCollection`. When an item is added to `list` using the -`add` method or removed using the `remove` method, the implementations of each -call the private `update_average` method that handles updating the `average` -field as well. - -We leave the `list` and `average` fields private so there is no way for -external code to add or remove items to the `list` field directly; otherwise, -the `average` field might become out of sync when the `list` changes. The -`average` method returns the value in the `average` field, allowing external -code to read the `average` but not modify it. - -Because we’ve encapsulated the implementation details of the struct -`AveragedCollection`, we can easily change aspects, such as the data structure, -in the future. For instance, we could use a `HashSet` instead of a `Vec` for -the `list` field. As long as the signatures of the `add`, `remove`, and -`average` public methods stay the same, code using `AveragedCollection` -wouldn’t need to change. If we made `list` public instead, this wouldn’t -necessarily be the case: `HashSet` and `Vec` have different methods for adding -and removing items, so the external code would likely have to change if it were -modifying `list` directly. - -If encapsulation is a required aspect for a language to be considered object -oriented, then Rust meets that requirement. The option to use `pub` or not for -different parts of code enables encapsulation of implementation details. - -### Inheritance as a Type System and as Code Sharing - -*Inheritance* is a mechanism whereby an object can inherit from another -object’s definition, thus gaining the parent object’s data and behavior without -you having to define them again. - -If a language must have inheritance to be an object-oriented language, then -Rust is not one. There is no way to define a struct that inherits the parent -struct’s fields and method implementations. However, if you’re used to having -inheritance in your programming toolbox, you can use other solutions in Rust, -depending on your reason for reaching for inheritance in the first place. - -You choose inheritance for two main reasons. One is for reuse of code: you can -implement particular behavior for one type, and inheritance enables you to -reuse that implementation for a different type. You can share Rust code using -default trait method implementations instead, which you saw in Listing 10-14 -when we added a default implementation of the `summarize` method on the -`Summary` trait. Any type implementing the `Summary` trait would have the -`summarize` method available on it without any further code. This is similar to -a parent class having an implementation of a method and an inheriting child -class also having the implementation of the method. We can also override the -default implementation of the `summarize` method when we implement the -`Summary` trait, which is similar to a child class overriding the -implementation of a method inherited from a parent class. - -The other reason to use inheritance relates to the type system: to enable a -child type to be used in the same places as the parent type. This is also -called *polymorphism*, which means that you can substitute multiple objects for -each other at runtime if they share certain characteristics. - -> ### Polymorphism -> -> To many people, polymorphism is synonymous with inheritance. But it’s -> actually a more general concept that refers to code that can work with data -> of multiple types. For inheritance, those types are generally subclasses. -> -> Rust instead uses generics to abstract over different possible types and -> trait bounds to impose constraints on what those types must provide. This is -> sometimes called *bounded parametric polymorphism*. - -Inheritance has recently fallen out of favor as a programming design solution -in many programming languages because it’s often at risk of sharing more code -than necessary. Subclasses shouldn’t always share all characteristics of their -parent class but will do so with inheritance. This can make a program’s design -less flexible. It also introduces the possibility of calling methods on -subclasses that don’t make sense or that cause errors because the methods don’t -apply to the subclass. In addition, some languages will only allow a subclass -to inherit from one class, further restricting the flexibility of a program’s -design. - -For these reasons, Rust takes a different approach, using trait objects instead -of inheritance. Let’s look at how trait objects enable polymorphism in Rust. +If you have an internet connection, you can [find a copy distributed with +Rust +1.30](https://doc.rust-lang.org/1.30.0/book/2018-edition/ch17-01-what-is-oo.html). \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch17-02-trait-objects.md rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch17-02-trait-objects.md --- rustc-1.30.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch17-02-trait-objects.md 2018-09-07 17:22:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/book/2018-edition/src/ch17-02-trait-objects.md 2018-11-21 02:20:59.000000000 +0000 @@ -1,421 +1,10 @@ ## Using Trait Objects that Allow for Values of Different Types -In Chapter 8, we mentioned that one limitation of vectors is that they can -store elements of only one type. We created a workaround in Listing 8-10 where -we defined a `SpreadsheetCell` enum that had variants to hold integers, floats, -and text. This meant we could store different types of data in each cell and -still have a vector that represented a row of cells. This is a perfectly good -solution when our interchangeable items are a fixed set of types that we know -when our code is compiled. +The 2018 edition of the book is no longer distributed with Rust's documentation. -However, sometimes we want our library user to be able to extend the set of -types that are valid in a particular situation. To show how we might achieve -this, we’ll create an example graphical user interface (GUI) tool that iterates -through a list of items, calling a `draw` method on each one to draw it to the -screen—a common technique for GUI tools. We’ll create a library crate called -`gui` that contains the structure of a GUI library. This crate might include -some types for people to use, such as `Button` or `TextField`. In addition, -`gui` users will want to create their own types that can be drawn: for -instance, one programmer might add an `Image` and another might add a -`SelectBox`. +If you came here via a link or web search, you may want to check out [the current +version of the book](../index.html) instead. -We won’t implement a fully fledged GUI library for this example but will show -how the pieces would fit together. At the time of writing the library, we can’t -know and define all the types other programmers might want to create. But we do -know that `gui` needs to keep track of many values of different types, and it -needs to call a `draw` method on each of these differently typed values. It -doesn’t need to know exactly what will happen when we call the `draw` method, -just that the value will have that method available for us to call. - -To do this in a language with inheritance, we might define a class named -`Component` that has a method named `draw` on it. The other classes, such as -`Button`, `Image`, and `SelectBox`, would inherit from `Component` and thus -inherit the `draw` method. They could each override the `draw` method to define -their custom behavior, but the framework could treat all of the types as if -they were `Component` instances and call `draw` on them. But because Rust -doesn’t have inheritance, we need another way to structure the `gui` library to -allow users to extend it with new types. - -### Defining a Trait for Common Behavior - -To implement the behavior we want `gui` to have, we’ll define a trait named -`Draw` that will have one method named `draw`. Then we can define a vector that -takes a *trait object*. A trait object points to an instance of a type that -implements the trait we specify. We create a trait object by specifying some -sort of pointer, such as a `&` reference or a `Box` smart pointer, and then -specifying the relevant trait, and add a `dyn` keyword. (We’ll talk about the -reason trait objects must use a pointer in Chapter 19 in the section -“Dynamically Sized Types & Sized”.) We can use trait objects in place of a -generic or concrete type. Wherever we use a trait object, Rust’s type system -will ensure at compile time that any value used in that context will -implement the trait object’s trait. Consequently, we don’t need to know all -the possible types at compile time. - -We’ve mentioned that in Rust, we refrain from calling structs and enums -“objects” to distinguish them from other languages’ objects. In a struct or -enum, the data in the struct fields and the behavior in `impl` blocks are -separated, whereas in other languages, the data and behavior combined into one -concept is often labeled an object. However, trait objects *are* more like -objects in other languages in the sense that they combine data and behavior. -But trait objects differ from traditional objects in that we can’t add data to -a trait object. Trait objects aren’t as generally useful as objects in other -languages: their specific purpose is to allow abstraction across common -behavior. - -Listing 17-3 shows how to define a trait named `Draw` with one method named -`draw`: - -Filename: src/lib.rs - -```rust -pub trait Draw { - fn draw(&self); -} -``` - -Listing 17-3: Definition of the `Draw` trait - -This syntax should look familiar from our discussions on how to define traits -in Chapter 10. Next comes some new syntax: Listing 17-4 defines a struct named -`Screen` that holds a vector named `components`. This vector is of type -`Box`, which is a trait object; it’s a stand-in for any type inside -a `Box` that implements the `Draw` trait. - -Filename: src/lib.rs - -```rust -# pub trait Draw { -# fn draw(&self); -# } -# -pub struct Screen { - pub components: Vec>, -} -``` - -Listing 17-4: Definition of the `Screen` struct with a -`components` field holding a vector of trait objects that implement the `Draw` -trait - -On the `Screen` struct, we’ll define a method named `run` that will call the -`draw` method on each of its `components`, as shown in Listing 17-5: - -Filename: src/lib.rs - -```rust -# pub trait Draw { -# fn draw(&self); -# } -# -# pub struct Screen { -# pub components: Vec>, -# } -# -impl Screen { - pub fn run(&self) { - for component in self.components.iter() { - component.draw(); - } - } -} -``` - -Listing 17-5: A `run` method on `Screen` that calls the -`draw` method on each component - -This works differently than defining a struct that uses a generic type -parameter with trait bounds. A generic type parameter can only be substituted -with one concrete type at a time, whereas trait objects allow for multiple -concrete types to fill in for the trait object at runtime. For example, we -could have defined the `Screen` struct using a generic type and a trait bound -as in Listing 17-6: - -Filename: src/lib.rs - -```rust -# pub trait Draw { -# fn draw(&self); -# } -# -pub struct Screen { - pub components: Vec, -} - -impl Screen - where T: Draw { - pub fn run(&self) { - for component in self.components.iter() { - component.draw(); - } - } -} -``` - -Listing 17-6: An alternate implementation of the `Screen` -struct and its `run` method using generics and trait bounds - -This restricts us to a `Screen` instance that has a list of components all of -type `Button` or all of type `TextField`. If you’ll only ever have homogeneous -collections, using generics and trait bounds is preferable because the -definitions will be monomorphized at compile time to use the concrete types. - -On the other hand, with the method using trait objects, one `Screen` instance -can hold a `Vec` that contains a `Box + + diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/aliasing.md rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/aliasing.md --- rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/aliasing.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/aliasing.md 2018-12-04 23:42:54.000000000 +0000 @@ -1,6 +1,6 @@ # Aliasing -First off, let's get some important caveats out of this way: +First off, let's get some important caveats out of the way: * We will be using the broadest possible definition of aliasing for the sake of discussion. Rust's definition will probably be more restricted to factor diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/borrow-splitting.md rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/borrow-splitting.md --- rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/borrow-splitting.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/borrow-splitting.md 2018-12-04 23:42:54.000000000 +0000 @@ -34,21 +34,18 @@ ``` ```text -:4:14: 4:18 error: cannot borrow `x[..]` as mutable more than once at a time -:4 let b = &mut x[1]; - ^~~~ -:3:14: 3:18 note: previous borrow of `x[..]` occurs here; the mutable borrow prevents subsequent moves, borrows, or modification of `x[..]` until the borrow ends -:3 let a = &mut x[0]; - ^~~~ -:6:2: 6:2 note: previous borrow ends here -:1 fn main() { -:2 let mut x = [1, 2, 3]; -:3 let a = &mut x[0]; -:4 let b = &mut x[1]; -:5 println!("{} {}", a, b); -:6 } - ^ -error: aborting due to 2 previous errors +error[E0499]: cannot borrow `x[..]` as mutable more than once at a time + --> src/lib.rs:4:18 + | +3 | let a = &mut x[0]; + | ---- first mutable borrow occurs here +4 | let b = &mut x[1]; + | ^^^^ second mutable borrow occurs here +5 | println!("{} {}", a, b); +6 | } + | - first borrow ends here + +error: aborting due to previous error ``` While it was plausible that borrowck could understand this simple case, it's diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/checked-uninit.md rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/checked-uninit.md --- rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/checked-uninit.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/checked-uninit.md 2018-12-04 23:42:54.000000000 +0000 @@ -12,9 +12,9 @@ ``` ```text -src/main.rs:3:20: 3:21 error: use of possibly uninitialized variable: `x` -src/main.rs:3 println!("{}", x); - ^ + | +3 | println!("{}", x); + | ^ use of possibly uninitialized `x` ``` This is based off of a basic branch analysis: every branch must assign a value @@ -50,8 +50,9 @@ ``` ```text -src/main.rs:6:17: 6:18 error: use of possibly uninitialized variable: `x` -src/main.rs:6 println!("{}", x); + | +6 | println!("{}", x); + | ^ use of possibly uninitialized `x` ``` while this does: diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/coercions.md rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/coercions.md --- rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/coercions.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/coercions.md 2018-12-04 23:42:54.000000000 +0000 @@ -58,7 +58,6 @@ impl<'a> Trait for &'a i32 {} - fn main() { let t: &mut i32 = &mut 0; foo(t); @@ -66,7 +65,19 @@ ``` ```text -:10:5: 10:8 error: the trait bound `&mut i32 : Trait` is not satisfied [E0277] -:10 foo(t); - ^~~ +error[E0277]: the trait bound `&mut i32: Trait` is not satisfied + --> src/main.rs:9:5 + | +9 | foo(t); + | ^^^ the trait `Trait` is not implemented for `&mut i32` + | + = help: the following implementations were found: + <&'a i32 as Trait> +note: required by `foo` + --> src/main.rs:3:1 + | +3 | fn foo(t: X) {} + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error ``` diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/data.md rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/data.md --- rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/data.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/data.md 2018-12-04 23:42:54.000000000 +0000 @@ -3,3 +3,17 @@ Low-level programming cares a lot about data layout. It's a big deal. It also pervasively influences the rest of the language, so we're going to start by digging into how data is represented in Rust. + +This chapter is ideally in agreement with, and rendered redundant by, +the [Type Layout section of the Reference][ref-type-layout]. When this +book was first written, the reference was in complete disrepair, and the +Rustonomicon was attempting to serve as a partial replacement for the reference. +This is no longer the case, so this whole chapter can ideally be deleted. + +We'll keep this chapter around for a bit longer, but ideally you should be +contributing any new facts or improvements to the Reference instead. + + + + +ref-type-layout: ../reference/type-layout.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/dropck.md rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/dropck.md --- rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/dropck.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/dropck.md 2018-12-04 23:42:54.000000000 +0000 @@ -80,14 +80,14 @@ ``` ```text -error: `days` does not live long enough - --> :15:1 +error[E0597]: `days` does not live long enough + --> src/main.rs:12:28 | 12 | inspector = Inspector(&days); - | ---- borrow occurs here + | ^^^^ borrowed value does not live long enough ... 15 | } - | ^ `days` dropped here while still borrowed + | - `days` dropped here while still borrowed | = note: values in a scope are dropped in the opposite order they are created diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/drop-flags.md rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/drop-flags.md --- rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/drop-flags.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/drop-flags.md 2018-12-04 23:42:54.000000000 +0000 @@ -12,7 +12,7 @@ particular, assigning through a dereference unconditionally drops, and assigning in a `let` unconditionally doesn't drop: -``` +```rust let mut x = Box::new(0); // let makes a fresh variable, so never need to drop let y = &mut x; *y = Box::new(1); // Deref assumes the referent is initialized, so always drops diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/exotic-sizes.md rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/exotic-sizes.md --- rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/exotic-sizes.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/exotic-sizes.md 2018-12-04 23:42:54.000000000 +0000 @@ -1,7 +1,7 @@ # Exotically Sized Types -Most of the time, we think in terms of types with a fixed, positive size. This -is not always the case, however. +Most of the time, we expect types to have a statically known and positive size. +This isn't always the case in Rust. @@ -9,47 +9,80 @@ # Dynamically Sized Types (DSTs) -Rust in fact supports Dynamically Sized Types (DSTs): types without a statically +Rust supports Dynamically Sized Types (DSTs): types without a statically known size or alignment. On the surface, this is a bit nonsensical: Rust *must* know the size and alignment of something in order to correctly work with it! In -this regard, DSTs are not normal types. Due to their lack of a statically known -size, these types can only exist behind some kind of pointer. Any pointer to a -DST consequently becomes a *fat* pointer consisting of the pointer and the +this regard, DSTs are not normal types. Because they lack a statically known +size, these types can only exist behind a pointer. Any pointer to a +DST consequently becomes a *wide* pointer consisting of the pointer and the information that "completes" them (more on this below). -There are two major DSTs exposed by the language: trait objects, and slices. +There are two major DSTs exposed by the language: + +* trait objects: `dyn MyTrait` +* slices: `[T]`, `str`, and others A trait object represents some type that implements the traits it specifies. The exact original type is *erased* in favor of runtime reflection with a vtable containing all the information necessary to use the type. -This is the information that completes a trait object: a pointer to its vtable. +The information that completes a trait object pointer is the vtable pointer. +The runtime size of the pointee can be dynamically requested from the vtable. A slice is simply a view into some contiguous storage -- typically an array or -`Vec`. The information that completes a slice is just the number of elements -it points to. +`Vec`. The information that completes a slice pointer is just the number of elements +it points to. The runtime size of the pointee is just the statically known size +of an element multiplied by the number of elements. Structs can actually store a single DST directly as their last field, but this makes them a DST as well: ```rust // Can't be stored on the stack directly -struct Foo { +struct MySuperSlice { info: u32, data: [u8], } ``` +Although such a type is largely useless without a way to construct it. Currently the +only properly supported way to create a custom DST is by making your type generic +and performing an *unsizing coercion*: + +```rust +struct MySuperSliceable { + info: u32, + data: T +} + +fn main() { + let sized: MySuperSliceable<[u8; 8]> = MySuperSliceable { + info: 17, + data: [0; 8], + }; + + let dynamic: &MySuperSliceable<[u8]> = &sized; + + // prints: "17 [0, 0, 0, 0, 0, 0, 0, 0]" + println!("{} {:?}", dynamic.info, &dynamic.data); +} +``` + +(Yes, custom DSTs are a largely half-baked feature for now.) + + + + # Zero Sized Types (ZSTs) -Rust actually allows types to be specified that occupy no space: +Rust also allows types to be specified that occupy no space: ```rust -struct Foo; // No fields = no size +struct Nothing; // No fields = no size // All fields have no size = no size -struct Baz { - foo: Foo, +struct LotsOfNothing { + foo: Nothing, qux: (), // empty tuple has no size baz: [u8; 0], // empty array has no size } @@ -57,13 +90,13 @@ On their own, Zero Sized Types (ZSTs) are, for obvious reasons, pretty useless. However as with many curious layout choices in Rust, their potential is realized -in a generic context: Rust largely understands that any operation that produces -or stores a ZST can be reduced to a no-op. First off, storing it doesn't even -make sense -- it doesn't occupy any space. Also there's only one value of that -type, so anything that loads it can just produce it from the aether -- which is +in a generic context: Rust largely understands that any operation that produces +or stores a ZST can be reduced to a no-op. First off, storing it doesn't even +make sense -- it doesn't occupy any space. Also there's only one value of that +type, so anything that loads it can just produce it from the aether -- which is also a no-op since it doesn't occupy any space. -One of the most extreme example's of this is Sets and Maps. Given a +One of the most extreme examples of this is Sets and Maps. Given a `Map`, it is common to implement a `Set` as just a thin wrapper around `Map`. In many languages, this would necessitate allocating space for UselessJunk and doing work to store and load UselessJunk @@ -78,9 +111,8 @@ Safe code need not worry about ZSTs, but *unsafe* code must be careful about the consequence of types with no size. In particular, pointer offsets are no-ops, -and standard allocators (including jemalloc, the one used by default in Rust) -may return `nullptr` when a zero-sized allocation is requested, which is -indistinguishable from out of memory. +and standard allocators may return `null` when a zero-sized allocation is +requested, which is indistinguishable from the out of memory result. @@ -97,7 +129,7 @@ ``` Empty types are even more marginal than ZSTs. The primary motivating example for -Void types is type-level unreachability. For instance, suppose an API needs to +an empty type is type-level unreachability. For instance, suppose an API needs to return a Result in general, but a specific case actually is infallible. It's actually possible to communicate this at the type level by returning a `Result`. Consumers of the API can confidently unwrap such a Result @@ -105,9 +137,12 @@ this would require providing a value of type `Void`. In principle, Rust can do some interesting analyses and optimizations based -on this fact. For instance, `Result` could be represented as just `T`, -because the `Err` case doesn't actually exist. The following *could* also -compile: +on this fact. For instance, `Result` is represented as just `T`, +because the `Err` case doesn't actually exist (strictly speaking, this is only +an optimization that is not guaranteed, so for example transmuting one into the +other is still UB). + +The following *could* also compile: ```rust,ignore enum Void {} @@ -118,14 +153,39 @@ let Ok(num) = res; ``` -But neither of these tricks work today, so all Void types get you is -the ability to be confident that certain situations are statically impossible. +But this trick doesn't work yet. One final subtle detail about empty types is that raw pointers to them are actually valid to construct, but dereferencing them is Undefined Behavior -because that doesn't actually make sense. That is, you could model C's `void *` -type with `*const Void`, but this doesn't necessarily gain anything over using -e.g. `*const ()`, which *is* safe to randomly dereference. +because that wouldn't make sense. + +We recommend against modelling C's `void*` type with `*const Void`. +A lot of people started doing that but quickly ran into trouble because +Rust doesn't really have any safety guards against trying to instantiate +empty types with unsafe code, and if you do it, it's Undefined Behaviour. +This was especially problematic because developers had a habit of converting +raw pointers to references and `&Void` is *also* Undefined Behaviour to +construct. + +`*const ()` (or equivalent) works reasonably well for `void*`, and can be made +into a reference without any safety problems. It still doesn't prevent you from +trying to read or write values, but at least it compiles to a no-op instead +of UB. + + + + + +# Extern Types + +There is [an accepted RFC][extern-types] to add proper types with an unknown size, +called *extern types*, which would let Rust developers model things like C's `void*` +and other "declared but never defined" types more accurately. However as of +Rust 2018, the feature is stuck in limbo over how `size_of::()` +should behave. + + [dst-issue]: https://github.com/rust-lang/rust/issues/26403 +[extern-types]: https://github.com/rust-lang/rfcs/blob/master/text/1861-extern-types.md diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/leaking.md rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/leaking.md --- rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/leaking.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/leaking.md 2018-12-04 23:42:54.000000000 +0000 @@ -182,7 +182,7 @@ ## thread::scoped::JoinGuard -The thread::scoped API intends to allow threads to be spawned that reference +The thread::scoped API intended to allow threads to be spawned that reference data on their parent's stack without any synchronization over that data by ensuring the parent joins the thread before any of the shared data goes out of scope. diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/lifetime-mismatch.md rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/lifetime-mismatch.md --- rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/lifetime-mismatch.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/lifetime-mismatch.md 2018-12-04 23:42:54.000000000 +0000 @@ -24,19 +24,15 @@ However when we try to compile it: ```text -:11:5: 11:8 error: cannot borrow `foo` as immutable because it is also borrowed as mutable -:11 foo.share(); - ^~~ -:10:16: 10:19 note: previous borrow of `foo` occurs here; the mutable borrow prevents subsequent moves, borrows, or modification of `foo` until the borrow ends -:10 let loan = foo.mutate_and_share(); - ^~~ -:12:2: 12:2 note: previous borrow ends here -:8 fn main() { -:9 let mut foo = Foo; -:10 let loan = foo.mutate_and_share(); -:11 foo.share(); -:12 } - ^ +error[E0502]: cannot borrow `foo` as immutable because it is also borrowed as mutable + --> src/lib.rs:11:5 + | +10 | let loan = foo.mutate_and_share(); + | --- mutable borrow occurs here +11 | foo.share(); + | ^^^ immutable borrow occurs here +12 | } + | - mutable borrow ends here ``` What happened? Well, we got the exact same reasoning as we did for diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/other-reprs.md rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/other-reprs.md --- rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/other-reprs.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/other-reprs.md 2018-12-04 23:42:54.000000000 +0000 @@ -1,6 +1,7 @@ # Alternative representations Rust allows you to specify alternative data layout strategies from the default. +There's also the [reference]. @@ -14,18 +15,26 @@ necessary to soundly do more elaborate tricks with data layout such as reinterpreting values as a different type. -However, the interaction with Rust's more exotic data layout features must be +We strongly recommend using [rust-bindgen][] and/or [cbdingen][] to manage your FFI +boundaries for you. The Rust team works closely with those projects to ensure +that they work robustly and are compatible with current and future guarantees +about type layouts and reprs. + +The interaction of `repr(C)` with Rust's more exotic data layout features must be kept in mind. Due to its dual purpose as "for FFI" and "for layout control", `repr(C)` can be applied to types that will be nonsensical or problematic if passed through the FFI boundary. * ZSTs are still zero-sized, even though this is not a standard behavior in C, and is explicitly contrary to the behavior of an empty type in C++, which -still consumes a byte of space. +says they should still consume a byte of space. -* DST pointers (fat pointers), tuples, and enums with fields are not a concept +* DST pointers (wide pointers) and tuples are not a concept in C, and as such are never FFI-safe. +* Enums with fields also aren't a concept in C or C++, but a valid bridging + of the types [is defined][really-tagged]. + * If `T` is an [FFI-safe non-nullable pointer type](ffi.html#the-nullable-pointer-optimization), `Option` is guaranteed to have the same layout and ABI as `T` and is @@ -35,13 +44,13 @@ * Tuple structs are like structs with regards to `repr(C)`, as the only difference from a struct is that the fields aren’t named. -* This is equivalent to one of `repr(u*)` (see the next section) for enums. The -chosen size is the default enum size for the target platform's C application -binary interface (ABI). Note that enum representation in C is implementation +* `repr(C)` is equivalent to one of `repr(u*)` (see the next section) for +fieldless enums. The chosen size is the default enum size for the target platform's C +application binary interface (ABI). Note that enum representation in C is implementation defined, so this is really a "best guess". In particular, this may be incorrect when the C code of interest is compiled with certain flags. -* Field-less enums with `repr(C)` or `repr(u*)` still may not be set to an +* Fieldless enums with `repr(C)` or `repr(u*)` still may not be set to an integer value without a corresponding variant, even though this is permitted behavior in C or C++. It is undefined behavior to (unsafely) construct an instance of an enum that does not match one of its @@ -50,22 +59,42 @@ +# repr(transparent) + +This can only be used on structs with a single non-zero-sized field (there may +be additional zero-sized fields). The effect is that the layout and ABI of the +whole struct is guaranteed to be the same as that one field. + +The goal is to make it possible to transmute between the single field and the +struct. An example of that is [`UnsafeCell`], which can be transmuted into +the type it wraps. + +Also, passing the struct through FFI where the inner field type is expected on +the other side is guaranteed to work. In particular, this is necessary for `struct +Foo(f32)` to always have the same ABI as `f32`. + +More details are in the [RFC][rfc-transparent]. + + + # repr(u*), repr(i*) -These specify the size to make a field-less enum. If the discriminant overflows +These specify the size to make a fieldless enum. If the discriminant overflows the integer it has to fit in, it will produce a compile-time error. You can manually ask Rust to allow this by setting the overflowing element to explicitly be 0. However Rust will not allow you to create an enum where two variants have the same discriminant. -The term "field-less enum" only means that the enum doesn't have data in any -of its variants. A field-less enum without a `repr(u*)` or `repr(C)` is +The term "fieldless enum" only means that the enum doesn't have data in any +of its variants. A fieldless enum without a `repr(u*)` or `repr(C)` is still a Rust native type, and does not have a stable ABI representation. Adding a `repr` causes it to be treated exactly like the specified integer size for ABI purposes. -Any enum with fields is a Rust type with no guaranteed ABI (even if the -only data is `PhantomData` or something else with zero size). +If the enum has fields, the effect is similar to the effect of `repr(C)` +in that there is a defined layout of the type. This makes it possible to +pass the enum to C code, or access the type's raw representation and directly +manipulate its tag and fields. See [the RFC][really-tagged] for details. Adding an explicit `repr` to an enum suppresses the null-pointer optimization. @@ -88,12 +117,37 @@ However if you take a reference to a packed field, it's unlikely that the compiler will be able to emit code to avoid an unaligned load. -**[As of Rust 1.0 this can cause undefined behavior.][ub loads]** +**[As of Rust 2018, this still can cause undefined behavior.][ub loads]** `repr(packed)` is not to be used lightly. Unless you have extreme requirements, this should not be used. This repr is a modifier on `repr(C)` and `repr(rust)`. + + + +# repr(align(n)) + +`repr(align(n))` (where `n` is a power of two) forces the type to have an +alignment of *at least* n. + +This enables several tricks, like making sure neighboring elements of an array +never share the same cache line with each other (which may speed up certain +kinds of concurrent code). + +This is a modifier on `repr(C)` and `repr(rust)`. It is incompatible with +`repr(packed)`. + + + + + +[reference]: https://github.com/rust-rfcs/unsafe-code-guidelines/tree/master/reference/src/representation [drop flags]: drop-flags.html [ub loads]: https://github.com/rust-lang/rust/issues/27060 +[`UnsafeCell`]: ../std/cell/struct.UnsafeCell.html +[rfc-transparent]: https://github.com/rust-lang/rfcs/blob/master/text/1758-repr-transparent.md +[really-tagged]: https://github.com/rust-lang/rfcs/blob/master/text/2195-really-tagged-unions.md +[rust-bindgen]: https://rust-lang-nursery.github.io/rust-bindgen/ +[cbindgen]: https://github.com/eqrion/cbindgen diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/phantom-data.md rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/phantom-data.md --- rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/phantom-data.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/phantom-data.md 2018-12-04 23:42:54.000000000 +0000 @@ -27,7 +27,7 @@ Iter logically contains a bunch of `&'a T`s, so this is exactly what we tell the PhantomData to simulate: -``` +```rust use std::marker; struct Iter<'a, T: 'a> { @@ -42,7 +42,7 @@ Another important example is Vec, which is (approximately) defined as follows: -``` +```rust struct Vec { data: *const T, // *const for variance! len: usize, @@ -66,7 +66,7 @@ drop some T's when *we* drop, we must add an extra PhantomData saying exactly that: -``` +```rust use std::marker; struct Vec { diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/README.md rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/README.md --- rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/README.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/README.md 2018-12-04 23:42:54.000000000 +0000 @@ -2,20 +2,20 @@ #### The Dark Arts of Advanced and Unsafe Rust Programming -# NOTE: This is a draft document that discusses several unstable aspects of Rust, and may contain serious errors or outdated information. - > Instead of the programs I had hoped for, there came only a shuddering blackness and ineffable loneliness; and I saw at last a fearful truth which no one had ever dared to breathe before — the unwhisperable secret of secrets — The fact that this language of stone and stridor is not a sentient perpetuation of Rust as London is of Old London and Paris of Old Paris, but that it is in fact -quite unsafe, its sprawling body imperfectly embalmed and infested with queer +quite `unsafe`, its sprawling body imperfectly embalmed and infested with queer animate things which have nothing to do with it as it was in compilation. -This book digs into all the awful details that are necessary to understand in -order to write correct Unsafe Rust programs. Due to the nature of this problem, -it may lead to unleashing untold horrors that shatter your psyche into a billion -infinitesimal fragments of despair. +This book digs into all the awful details that you need to understand when +writing Unsafe Rust programs. + +> THE KNOWLEDGE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF UNLEASHING INDESCRIBABLE HORRORS THAT +SHATTER YOUR PSYCHE AND SET YOUR MIND ADRIFT IN THE UNKNOWABLY INFINITE COSMOS. Should you wish a long and happy career of writing Rust programs, you should turn back now and forget you ever saw this book. It is not necessary. However diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/repr-rust.md rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/repr-rust.md --- rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/repr-rust.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/repr-rust.md 2018-12-04 23:42:54.000000000 +0000 @@ -2,12 +2,14 @@ First and foremost, all types have an alignment specified in bytes. The alignment of a type specifies what addresses are valid to store the value at. A -value of alignment `n` must only be stored at an address that is a multiple of +value with alignment `n` must only be stored at an address that is a multiple of `n`. So alignment 2 means you must be stored at an even address, and 1 means that you can be stored anywhere. Alignment is at least 1, and always a power -of 2. Most primitives are generally aligned to their size, although this is -platform-specific behavior. In particular, on x86 `u64` and `f64` may be only -aligned to 32 bits. +of 2. + +Primitives are usually aligned to their size, although this is +platform-specific behavior. For example, on x86 `u64` and `f64` are often +aligned to 4 bytes (32 bits). A type's size must always be a multiple of its alignment. This ensures that an array of that type may always be indexed by offsetting by a multiple of its @@ -20,11 +22,12 @@ * tuples (anonymous product types) * arrays (homogeneous product types) * enums (named sum types -- tagged unions) +* unions (untagged unions) An enum is said to be *field-less* if none of its variants have associated data. -Composite structures will have an alignment equal to the maximum -of their fields' alignment. Rust will consequently insert padding where +By default, composite structures have an alignment equal to the maximum +of their fields' alignments. Rust will consequently insert padding where necessary to ensure that all fields are properly aligned and that the overall type's size is a multiple of its alignment. For instance: @@ -36,9 +39,9 @@ } ``` -will be 32-bit aligned on an architecture that aligns these primitives to their +will be 32-bit aligned on a target that aligns these primitives to their respective sizes. The whole struct will therefore have a size that is a multiple -of 32-bits. It will potentially become: +of 32-bits. It may become: ```rust struct A { @@ -50,10 +53,21 @@ } ``` +or maybe: + +```rust +struct A { + b: u32, + c: u16, + a: u8, + _pad: u8, +} +``` + There is *no indirection* for these types; all data is stored within the struct, as you would expect in C. However with the exception of arrays (which are -densely packed and in-order), the layout of data is not by default specified in -Rust. Given the two following struct definitions: +densely packed and in-order), the layout of data is not specified by default. +Given the two following struct definitions: ```rust struct A { @@ -69,8 +83,7 @@ Rust *does* guarantee that two instances of A have their data laid out in exactly the same way. However Rust *does not* currently guarantee that an -instance of A has the same field ordering or padding as an instance of B, though -in practice there's no reason why they wouldn't. +instance of A has the same field ordering or padding as an instance of B. With A and B as written, this point would seem to be pedantic, but several other features of Rust make it desirable for the language to play with data layout in @@ -107,7 +120,7 @@ } ``` -The latter case quite simply wastes space. An optimal use of space therefore +The latter case quite simply wastes space. An optimal use of space requires different monomorphizations to have *different field orderings*. Enums make this consideration even more complicated. Naively, an enum such as: @@ -120,7 +133,7 @@ } ``` -would be laid out as: +might be laid out as: ```rust struct FooRepr { @@ -129,23 +142,22 @@ } ``` -And indeed this is approximately how it would be laid out in general (modulo the +And indeed this is approximately how it would be laid out (modulo the size and position of `tag`). However there are several cases where such a representation is inefficient. The classic case of this is Rust's "null pointer optimization": an enum consisting of a single outer unit variant (e.g. `None`) and a (potentially nested) non- -nullable pointer variant (e.g. `&T`) makes the tag unnecessary, because a null -pointer value can safely be interpreted to mean that the unit variant is chosen -instead. The net result is that, for example, `size_of::>() == -size_of::<&T>()`. +nullable pointer variant (e.g. `Some(&T)`) makes the tag unnecessary. A null +pointer can safely be interpreted as the unit (`None`) variant. The net +result is that, for example, `size_of::>() == size_of::<&T>()`. There are many types in Rust that are, or contain, non-nullable pointers such as `Box`, `Vec`, `String`, `&T`, and `&mut T`. Similarly, one can imagine nested enums pooling their tags into a single discriminant, as they are by definition known to have a limited range of valid values. In principle enums could -use fairly elaborate algorithms to cache bits throughout nested types with -special constrained representations. As such it is *especially* desirable that +use fairly elaborate algorithms to store bits throughout nested types with +forbidden values. As such it is *especially* desirable that we leave enum layout unspecified today. [dst]: exotic-sizes.html#dynamically-sized-types-dsts diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/safe-unsafe-meaning.md rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/safe-unsafe-meaning.md --- rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/safe-unsafe-meaning.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/safe-unsafe-meaning.md 2018-12-04 23:42:54.000000000 +0000 @@ -41,12 +41,15 @@ * All FFI (Foreign Function Interface) functions are `unsafe` to call because the other language can do arbitrary operations that the Rust compiler can't check. -As of Rust 1.0 there are exactly two unsafe traits: - -* `Send` is a marker trait (a trait with no API) that promises implementors are - safe to send (move) to another thread. -* `Sync` is a marker trait that promises threads can safely share implementors +As of Rust 1.29.2 the standard library defines the following unsafe traits +(there are others, but they are not stabilized yet and some of them may never +be): + +* [`Send`] is a marker trait (a trait with no API) that promises implementors + are safe to send (move) to another thread. +* [`Sync`] is a marker trait that promises threads can safely share implementors through a shared reference. +* [`GlobalAlloc`] allows customizing the memory allocator of the whole program. Much of the Rust standard library also uses Unsafe Rust internally. These implementations have generally been rigorously manually checked, so the Safe Rust @@ -122,24 +125,35 @@ Rust has traditionally avoided doing this because it makes Unsafe Rust pervasive, which isn't desirable. `Send` and `Sync` are marked unsafe because thread safety is a *fundamental property* that unsafe code can't -possibly hope to defend against in the way it could defend against a bad -`Ord` implementation. The decision of whether to mark your own traits `unsafe` -depends on the same sort of consideration. If `unsafe` code can't reasonably -expect to defend against a bad implementation of the trait, then marking the -trait `unsafe` is a reasonable choice. +possibly hope to defend against in the way it could defend against a buggy +`Ord` implementation. Similarly, `GlobalAllocator` is keeping accounts of all +the memory in the program and other things like `Box` or `Vec` build on top of +it. If it does something weird (giving the same chunk of memory to another +request when it is still in use), there's no chance to detect that and do +anything about it. + +The decision of whether to mark your own traits `unsafe` depends on the same +sort of consideration. If `unsafe` code can't reasonably expect to defend +against a broken implementation of the trait, then marking the trait `unsafe` is +a reasonable choice. As an aside, while `Send` and `Sync` are `unsafe` traits, they are *also* automatically implemented for types when such derivations are provably safe to do. `Send` is automatically derived for all types composed only of values whose types also implement `Send`. `Sync` is automatically derived for all types composed only of values whose types also implement `Sync`. This minimizes -the pervasive unsafety of making these two traits `unsafe`. +the pervasive unsafety of making these two traits `unsafe`. And not many people +are going to *implement* memory allocators (or use them directly, for that +matter). This is the balance between Safe and Unsafe Rust. The separation is designed to make using Safe Rust as ergonomic as possible, but requires extra effort and care when writing Unsafe Rust. The rest of this book is largely a discussion of the sort of care that must be taken, and what contracts Unsafe Rust must uphold. +[`Send`]: ../std/marker/trait.Send.html +[`Sync`]: ../std/marker/trait.Sync.html +[`GlobalAlloc`]: ../std/alloc/trait.GlobalAlloc.html [conversions]: conversions.html [ptr_offset]: ../std/primitive.pointer.html#method.offset diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/subtyping.md rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/subtyping.md --- rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/subtyping.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/subtyping.md 2018-12-04 23:42:54.000000000 +0000 @@ -3,53 +3,135 @@ Subtyping is a relationship between types that allows statically typed languages to be a bit more flexible and permissive. -The most common and easy to understand example of this can be found in -languages with inheritance. Consider an Animal type which has an `eat()` -method, and a Cat type which extends Animal, adding a `meow()` method. -Without subtyping, if someone were to write a `feed(Animal)` function, they -wouldn't be able to pass a Cat to this function, because a Cat isn't *exactly* -an Animal. But being able to pass a Cat where an Animal is expected seems -fairly reasonable. After all, a Cat is just an Animal *and more*. Something -having extra features that can be ignored shouldn't be any impediment to -using it! - -This is exactly what subtyping lets us do. Because a Cat is an Animal *and more* -we say that Cat is a *subtype* of Animal. We then say that anywhere a value of -a certain type is expected, a value with a subtype can also be supplied. Ok -actually it's a lot more complicated and subtle than that, but that's the -basic intuition that gets you by in 99% of the cases. We'll cover why it's -*only* 99% later in this section. - -Although Rust doesn't have any notion of structural inheritance, it *does* -include subtyping. In Rust, subtyping derives entirely from lifetimes. Since -lifetimes are regions of code, we can partially order them based on the -*contains* (outlives) relationship. +Subtyping in Rust is a bit different from subtyping in other languages. This +makes it harder to give simple examples, which is a problem since subtyping, +and especially variance, are already hard to understand properly. As in, +even compiler writers mess it up all the time. + +To keep things simple, this section will consider a small extension to the +Rust language that adds a new and simpler subtyping relationship. After +establishing concepts and issues under this simpler system, +we will then relate it back to how subtyping actually occurs in Rust. -Subtyping on lifetimes is in terms of that relationship: if `'big: 'small` -("big contains small" or "big outlives small"), then `'big` is a subtype +So here's our simple extension, *Objective Rust*, featuring three new types: + + +```rust +trait Animal { + fn snuggle(&self); + fn eat(&mut self); +} + +trait Cat: Animal { + fn meow(&self); +} + +trait Dog: Animal { + fn bark(&self); +} +``` + +But unlike normal traits, we can use them as concrete and sized types, just like structs. + +Now, say we have a very simple function that takes an Animal, like this: + +```rust,ignore +fn love(pet: Animal) { + pet.snuggle(); +} +``` + +By default, static types must match *exactly* for a program to compile. As such, +this code won't compile: + +```rust,ignore +let mr_snuggles: Cat = ...; +love(mr_snuggles); // ERROR: expected Animal, found Cat +``` + +Mr. Snuggles is a Cat, and Cats aren't *exactly* Animals, so we can't love him! 😿 + +This is annoying because Cats *are* Animals. They support every operation +an Animal supports, so intuitively `love` shouldn't care if we pass it a `Cat`. +We should be able to just **forget** the non-animal parts of our `Cat`, as they +aren't necessary to love it. + +This is exactly the problem that *subtyping* is intended to fix. Because Cats are just +Animals **and more**, we say Cat is a *subtype* of Animal (because Cats are a *subset* +of all the Animals). Equivalently, we say that Animal is a *supertype* of Cat. +With subtypes, we can tweak our overly strict static type system +with a simple rule: anywhere a value of type `T` is expected, we will also +accept values that are subtypes of `T`. + +Or more concretely: anywhere an Animal is expected, a Cat or Dog will also work. + +As we will see throughout the rest of this section, subtyping is a lot more complicated +and subtle than this, but this simple rule is a very good 99% intuition. And unless you +write unsafe code, the compiler will automatically handle all the corner cases for you. + +But this is the Rustonomicon. We're writing unsafe code, so we need to understand how +this stuff really works, and how we can mess it up. + +The core problem is that this rule, naively applied, will lead to *meowing Dogs*. That is, +we can convince someone that a Dog is actually a Cat. This completely destroys the fabric +of our static type system, making it worse than useless (and leading to Undefined Behaviour). + +Here's a simple example of this happening when we apply subtyping in a completely naive +"find and replace" way. + +```rust,ignore +fn evil_feeder(pet: &mut Animal) { + let spike: Dog = ...; + + // `pet` is an Animal, and Dog is a subtype of Animal, + // so this should be fine, right..? + *pet = spike; +} + +fn main() { + let mut mr_snuggles: Cat = ...; + evil_feeder(&mut mr_snuggles); // Replaces mr_snuggles with a Dog + mr_snuggles.meow(); // OH NO, MEOWING DOG! +} +``` + +Clearly, we need a more robust system than "find and replace". That system is *variance*, +which is a set of rules governing how subtyping should compose. Most importantly, variance +defines situations where subtyping should be disabled. + +But before we get into variance, let's take a quick peek at where subtyping actually occurs in +Rust: *lifetimes*! + +> NOTE: The typed-ness of lifetimes is a fairly arbitrary construct that some +> disagree with. However it simplifies our analysis to treat lifetimes +> and types uniformly. + +Lifetimes are just regions of code, and regions can be partially ordered with the *contains* +(outlives) relationship. Subtyping on lifetimes is in terms of that relationship: +if `'big: 'small` ("big contains small" or "big outlives small"), then `'big` is a subtype of `'small`. This is a large source of confusion, because it seems backwards to many: the bigger region is a *subtype* of the smaller region. But it makes -sense if you consider our Animal example: *Cat* is an Animal *and more*, +sense if you consider our Animal example: Cat is an Animal *and more*, just as `'big` is `'small` *and more*. Put another way, if someone wants a reference that lives for `'small`, usually what they actually mean is that they want a reference that lives for *at least* `'small`. They don't actually care if the lifetimes match -exactly. For this reason `'static`, the forever lifetime, is a subtype -of every lifetime. - -Higher-ranked lifetimes are also subtypes of every concrete lifetime. This is -because taking an arbitrary lifetime is strictly more general than taking a -specific one. - -(The typed-ness of lifetimes is a fairly arbitrary construct that some -disagree with. However it simplifies our analysis to treat lifetimes -and types uniformly.) - -However you can't write a function that takes a value of type `'a`! Lifetimes -are always just part of another type, so we need a way of handling that. -To handle it, we need to talk about *variance*. +exactly. So it should be ok for us to **forget** that something lives for +`'big` and only remember that it lives for `'small`. +The meowing dog problem for lifetimes will result in us being able to +store a short-lived reference in a place that expects a longer-lived one, +creating a dangling reference and letting us use-after-free. + +It will be useful to note that `'static`, the forever lifetime, is a subtype of +every lifetime because by definition it outlives everything. We will be using +this relationship in later examples to keep them as simple as possible. + +With all that said, we still have no idea how to actually *use* subtyping of lifetimes, +because nothing ever has type `'a`. Lifetimes only occur as part of some larger type +like `&'a u32` or `IterMut<'a, u32>`. To apply lifetime subtyping, we need to know +how to compose subtyping. Once again, we need *variance*. @@ -59,200 +141,288 @@ Variance is where things get a bit complicated. Variance is a property that *type constructors* have with respect to their -arguments. A type constructor in Rust is a generic type with unbound arguments. -For instance `Vec` is a type constructor that takes a `T` and returns a +arguments. A type constructor in Rust is any generic type with unbound arguments. +For instance `Vec` is a type constructor that takes a type `T` and returns `Vec`. `&` and `&mut` are type constructors that take two inputs: a lifetime, and a type to point to. +> NOTE: For convenience we will often refer to `F` as a type constructor just so +> that we can easily talk about `T`. Hopefully this is clear in context. + A type constructor F's *variance* is how the subtyping of its inputs affects the -subtyping of its outputs. There are three kinds of variance in Rust: +subtyping of its outputs. There are three kinds of variance in Rust. Given two +types `Sub` and `Super`, where `Sub` is a subtype of `Super`: + +* `F` is *covariant* if `F` is a subtype of `F` (subtyping "passes through") +* `F` is *contravariant* if `F` is a subtype of `F` (subtyping is "inverted") +* `F` is *invariant* otherwise (no subtyping relationship exists) + +If `F` has multiple type parameters, we can talk about the individual variances +by saying that, for example, `F` is covariant over `T` and invariant over `U`. + +It is very useful to keep in mind that covariance is, in practical terms, "the" +variance. Almost all consideration of variance is in terms of whether something +should be covariant or invariant. Actually witnessing contravariance is quite difficult +in Rust, though it does in fact exist. + +Here is a table of important variances which the rest of this section will be devoted +to trying to explain: + +| | | 'a | T | U | +|---|-----------------|:---------:|:-----------------:|:---------:| +| * | `&'a T ` | covariant | covariant | | +| * | `&'a mut T` | covariant | invariant | | +| * | `Box` | | covariant | | +| | `Vec` | | covariant | | +| * | `UnsafeCell` | | invariant | | +| | `Cell` | | invariant | | +| * | `fn(T) -> U` | | **contra**variant | covariant | +| | `*const T` | | covariant | | +| | `*mut T` | | invariant | | + +The types with \*'s are the ones we will be focusing on, as they are in +some sense "fundamental". All the others can be understood by analogy to the others: + +* Vec and all other owning pointers and collections follow the same logic as Box +* Cell and all other interior mutability types follow the same logic as UnsafeCell +* `*const` follows the logic of `&T` +* `*mut` follows the logic of `&mut T` (or `UnsafeCell`) + +> NOTE: the *only* source of contravariance in the language is the arguments to +> a function, which is why it really doesn't come up much in practice. Invoking +> contravariance involves higher-order programming with function pointers that +> take references with specific lifetimes (as opposed to the usual "any lifetime", +> which gets into higher rank lifetimes, which work independently of subtyping). -* F is *covariant* over `T` if `T` being a subtype of `U` implies - `F` is a subtype of `F` (subtyping "passes through") -* F is *contravariant* over `T` if `T` being a subtype of `U` implies - `F` is a subtype of `F` (subtyping is "inverted") -* F is *invariant* over `T` otherwise (no subtyping relation can be derived) - -It should be noted that covariance is *far* more common and important than -contravariance in Rust. The existence of contravariance in Rust can mostly -be ignored. - -Some important variances (which we will explain in detail below): - -* `&'a T` is covariant over `'a` and `T` (as is `*const T` by metaphor) -* `&'a mut T` is covariant over `'a` but invariant over `T` -* `fn(T) -> U` is **contra**variant over `T`, but covariant over `U` -* `Box`, `Vec`, and all other collections are covariant over the types of - their contents -* `UnsafeCell`, `Cell`, `RefCell`, `Mutex` and all other - interior mutability types are invariant over T (as is `*mut T` by metaphor) - -To understand why these variances are correct and desirable, we will consider -several examples. - -We have already covered why `&'a T` should be covariant over `'a` when -introducing subtyping: it's desirable to be able to pass longer-lived things -where shorter-lived things are needed. - -Similar reasoning applies to why it should be covariant over T: it's reasonable -to be able to pass `&&'static str` where an `&&'a str` is expected. The -additional level of indirection doesn't change the desire to be able to pass -longer lived things where shorter lived things are expected. +Ok, that's enough type theory! Let's try to apply the concept of variance to Rust +and look at some examples. -However this logic doesn't apply to `&mut`. To see why `&mut` should -be invariant over T, consider the following code: +First off, let's revisit the meowing dog example: ```rust,ignore -fn overwrite(input: &mut T, new: &mut T) { - *input = *new; +fn evil_feeder(pet: &mut Animal) { + let spike: Dog = ...; + + // `pet` is an Animal, and Dog is a subtype of Animal, + // so this should be fine, right..? + *pet = spike; } fn main() { - let mut forever_str: &'static str = "hello"; - { - let string = String::from("world"); - overwrite(&mut forever_str, &mut &*string); - } - // Oops, printing free'd memory - println!("{}", forever_str); + let mut mr_snuggles: Cat = ...; + evil_feeder(&mut mr_snuggles); // Replaces mr_snuggles with a Dog + mr_snuggles.meow(); // OH NO, MEOWING DOG! } ``` -The signature of `overwrite` is clearly valid: it takes mutable references to -two values of the same type, and overwrites one with the other. +If we look at our table of variances, we see that `&mut T` is *invariant* over `T`. +As it turns out, this completely fixes the issue! With invariance, the fact that +Cat is a subtype of Animal doesn't matter; `&mut Cat` still won't be a subtype of +`&mut Animal`. The static type checker will then correctly stop us from passing +a Cat into `evil_feeder`. + +The soundness of subtyping is based on the idea that it's ok to forget unnecessary +details. But with references, there's always someone that remembers those details: +the value being referenced. That value expects those details to keep being true, +and may behave incorrectly if its expectations are violated. + +The problem with making `&mut T` covariant over `T` is that it gives us the power +to modify the original value *when we don't remember all of its constraints*. +And so, we can make someone have a Dog when they're certain they still have a Cat. + +With that established, we can easily see why `&T` being covariant over `T` *is* +sound: it doesn't let you modify the value, only look at it. Without any way to +mutate, there's no way for us to mess with any details. We can also see why +`UnsafeCell` and all the other interior mutability types must be invariant: they +make `&T` work like `&mut T`! + +Now what about the lifetime on references? Why is it ok for both kinds of references +to be covariant over their lifetimes? Well, here's a two-pronged argument: + +First and foremost, subtyping references based on their lifetimes is *the entire point +of subtyping in Rust*. The only reason we have subtyping is so we can pass +long-lived things where short-lived things are expected. So it better work! + +Second, and more seriously, lifetimes are only a part of the reference itself. The +type of the referent is shared knowledge, which is why adjusting that type in only +one place (the reference) can lead to issues. But if you shrink down a reference's +lifetime when you hand it to someone, that lifetime information isn't shared in +anyway. There are now two independent references with independent lifetimes. +There's no way to mess with original reference's lifetime using the other one. + +Or rather, the only way to mess with someone's lifetime is to build a meowing dog. +But as soon as you try to build a meowing dog, the lifetime should be wrapped up +in an invariant type, preventing the lifetime from being shrunk. To understand this +better, let's port the meowing dog problem over to real Rust. + +In the meowing dog problem we take a subtype (Cat), convert it into a supertype +(Animal), and then use that fact to overwrite the subtype with a value that satisfies +the constraints of the supertype but not the subtype (Dog). + +So with lifetimes, we want to take a long-lived thing, convert it into a +short-lived thing, and then use that to write something that doesn't live long +enough into the place expecting something long-lived. -But, if `&mut T` was covariant over T, then `&mut &'static str` would be a -subtype of `&mut &'a str`, since `&'static str` is a subtype of `&'a str`. -Therefore the lifetime of `forever_str` would successfully be "shrunk" down -to the shorter lifetime of `string`, and `overwrite` would be called successfully. -`string` would subsequently be dropped, and `forever_str` would point to -freed memory when we print it! Therefore `&mut` should be invariant. - -This is the general theme of variance vs invariance: if variance would allow you -to store a short-lived value in a longer-lived slot, then invariance must be used. - -More generally, the soundness of subtyping and variance is based on the idea that its ok to -forget details, but with mutable references there's always someone (the original -value being referenced) that remembers the forgotten details and will assume -that those details haven't changed. If we do something to invalidate those details, -the original location can behave unsoundly. - -However it *is* sound for `&'a mut T` to be covariant over `'a`. The key difference -between `'a` and T is that `'a` is a property of the reference itself, -while T is something the reference is borrowing. If you change T's type, then -the source still remembers the original type. However if you change the -lifetime's type, no one but the reference knows this information, so it's fine. -Put another way: `&'a mut T` owns `'a`, but only *borrows* T. - -`Box` and `Vec` are interesting cases because they're covariant, but you can -definitely store values in them! This is where Rust's typesystem allows it to -be a bit more clever than others. To understand why it's sound for owning -containers to be covariant over their contents, we must consider -the two ways in which a mutation may occur: by-value or by-reference. - -If mutation is by-value, then the old location that remembers extra details is -moved out of, meaning it can't use the value anymore. So we simply don't need to -worry about anyone remembering dangerous details. Put another way, applying -subtyping when passing by-value *destroys details forever*. For example, this -compiles and is fine: +Here it is: -```rust -fn get_box<'a>(str: &'a str) -> Box<&'a str> { - // String literals are `&'static str`s, but it's fine for us to - // "forget" this and let the caller think the string won't live that long. - Box::new("hello") +```rust,ignore +fn evil_feeder(input: &mut T, val: T) { + *input = val; +} + +fn main() { + let mut mr_snuggles: &'static str = "meow! :3"; // mr. snuggles forever!! + { + let spike = String::from("bark! >:V"); + let spike_str: &str = &spike; // Only lives for the block + evil_feeder(&mut mr_snuggles, spike_str); // EVIL! + } + println!("{}", mr_snuggles); // Use after free? } ``` -If mutation is by-reference, then our container is passed as `&mut Vec`. But -`&mut` is invariant over its value, so `&mut Vec` is actually invariant over `T`. -So the fact that `Vec` is covariant over `T` doesn't matter at all when -mutating by-reference. +And what do we get when we run this? -But being covariant still allows `Box` and `Vec` to be weakened when shared -immutably. So you can pass a `&Vec<&'static str>` where a `&Vec<&'a str>` is -expected. +```text +error[E0597]: `spike` does not live long enough + --> src/main.rs:9:32 + | +9 | let spike_str: &str = &spike; + | ^^^^^ borrowed value does not live long enough +10 | evil_feeder(&mut mr_snuggles, spike_str); +11 | } + | - borrowed value only lives until here + | + = note: borrowed value must be valid for the static lifetime... +``` -The invariance of the cell types can be seen as follows: `&` is like an `&mut` -for a cell, because you can still store values in them through an `&`. Therefore -cells must be invariant to avoid lifetime smuggling. +Good, it doesn't compile! Let's break down what's happening here in detail. -`fn` is the most subtle case because they have mixed variance, and in fact are -the only source of **contra**variance. To see why `fn(T) -> U` should be contravariant -over T, consider the following function signature: +First let's look at the new `evil_feeder` function: -```rust,ignore -// 'a is derived from some parent scope -fn foo(&'a str) -> usize; +```rust +fn evil_feeder(input: &mut T, val: T) { + *input = val; +} ``` -This signature claims that it can handle any `&str` that lives at least as -long as `'a`. Now if this signature was **co**variant over `&'a str`, that -would mean +All it does it take a mutable reference and a value and overwrite the referent with it. +What's important about this function is that it creates a type equality constraint. It +clearly says in its signature the referent and the value must be the *exact same* type. + +Meanwhile, in the caller we pass in `&mut &'static str` and `&'spike_str str`. + +Because `&mut T` is invariant over `T`, the compiler concludes it can't apply any subtyping +to the first argument, and so `T` must be exactly `&'static str`. + +The other argument is only an `&'a str`, which *is* covariant over `'a`. So the compiler +adopts a constraint: `&'spike_str str` must be a subtype of `&'static str` (inclusive), +which in turn implies `'spike_str` must be a subtype of `'static` (inclusive). Which is to say, +`'spike_str` must contain `'static`. But only one thing contains `'static` -- `'static` itself! + +This is why we get an error when we try to assign `&spike` to `spike_str`. The +compiler has worked backwards to conclude `spike_str` must live forever, and `&spike` +simply can't live that long. + +So even though references are covariant over their lifetimes, they "inherit" invariance +whenever they're put into a context that could do something bad with that. In this case, +we inherited invariance as soon as we put our reference inside an `&mut T`. + +As it turns out, the argument for why it's ok for Box (and Vec, Hashmap, etc.) to +be covariant is pretty similar to the argument for why it's ok for +lifetimes to be covariant: as soon as you try to stuff them in something like a +mutable reference, they inherit invariance and you're prevented from doing anything +bad. + +However Box makes it easier to focus on by-value aspect of references that we +partially glossed over. + +Unlike a lot of languages which allow values to be freely aliased at all times, +Rust has a very strict rule: if you're allowed to mutate or move a value, you +are guaranteed to be the only one with access to it. + +Consider the following code: ```rust,ignore -fn foo(&'static str) -> usize; +let mr_snuggles: Box = ..; +let spike: Box = ..; + +let mut pet: Box; +pet = mr_snuggles; +pet = spike; ``` -could be provided in its place, as it would be a subtype. However this function -has a stronger requirement: it says that it can only handle `&'static str`s, -and nothing else. Giving `&'a str`s to it would be unsound, as it's free to -assume that what it's given lives forever. Therefore functions definitely shouldn't -be **co**variant over their arguments. - -However if we flip it around and use **contra**variance, it *does* work! If -something expects a function which can handle strings that live forever, -it makes perfect sense to instead provide a function that can handle -strings that live for *less* than forever. So +There is no problem at all with the fact that we have forgotten that `mr_snuggles` was a Cat, +or that we overwrote him with a Dog, because as soon as we moved mr_snuggles to a variable +that only knew he was an Animal, **we destroyed the only thing in the universe that +remembered he was a Cat**! + +In contrast to the argument about immutable references being soundly covariant because they +don't let you change anything, owned values can be covariant because they make you +change *everything*. There is no connection between old locations and new locations. +Applying by-value subtyping is an irreversible act of knowledge destruction, and +without any memory of how things used to be, no one can be tricked into acting on +that old information! + +Only one thing left to explain: function pointers. + +To see why `fn(T) -> U` should be covariant over `U`, consider the following signature: ```rust,ignore -fn foo(&'a str) -> usize; +fn get_animal() -> Animal; ``` -can be passed where +This function claims to produce an Animal. As such, it is perfectly valid to +provide a function with the following signature instead: ```rust,ignore -fn foo(&'static str) -> usize; +fn get_animal() -> Cat; ``` -is expected. +After all, Cats are Animals, so always producing a Cat is a perfectly valid way +to produce Animals. Or to relate it back to real Rust: if we need a function +that is supposed to produce something that lives for `'short`, it's perfectly +fine for it to produce something that lives for `'long`. We don't care, we can +just forget that fact. -To see why `fn(T) -> U` should be **co**variant over U, consider the following -function signature: +However, the same logic does not apply to *arguments*. Consider trying to satisfy: ```rust,ignore -// 'a is derived from some parent scope -fn foo(usize) -> &'a str; +fn handle_animal(Animal); ``` -This signature claims that it will return something that outlives `'a`. It is -therefore completely reasonable to provide +with ```rust,ignore -fn foo(usize) -> &'static str; +fn handle_animal(Cat); ``` -in its place, as it does indeed return things that outlive `'a`. Therefore -functions are covariant over their return type. +The first function can accept Dogs, but the second function absolutely can't. +Covariance doesn't work here. But if we flip it around, it actually *does* +work! If we need a function that can handle Cats, a function that can handle *any* +Animal will surely work fine. Or to relate it back to real Rust: if we need a +function that can handle anything that lives for at least `'long`, it's perfectly +fine for it to be able to handle anything that lives for at least `'short`. -`*const` has the exact same semantics as `&`, so variance follows. `*mut` on the -other hand can dereference to an `&mut` whether shared or not, so it is marked -as invariant just like cells. +And that's why function types, unlike anything else in the language, are +**contra**variant over their arguments. -This is all well and good for the types the standard library provides, but +Now, this is all well and good for the types the standard library provides, but how is variance determined for type that *you* define? A struct, informally -speaking, inherits the variance of its fields. If a struct `Foo` -has a generic argument `A` that is used in a field `a`, then Foo's variance -over `A` is exactly `a`'s variance. However if `A` is used in multiple fields: - -* If all uses of A are covariant, then Foo is covariant over A -* If all uses of A are contravariant, then Foo is contravariant over A -* Otherwise, Foo is invariant over A +speaking, inherits the variance of its fields. If a struct `MyType` +has a generic argument `A` that is used in a field `a`, then MyType's variance +over `A` is exactly `a`'s variance over `A`. + +However if `A` is used in multiple fields: + +* If all uses of `A` are covariant, then MyType is covariant over `A` +* If all uses of `A` are contravariant, then MyType is contravariant over `A` +* Otherwise, MyType is invariant over `A` ```rust use std::cell::Cell; -struct Foo<'a, 'b, A: 'a, B: 'b, C, D, E, F, G, H, In, Out, Mixed> { +struct MyType<'a, 'b, A: 'a, B: 'b, C, D, E, F, G, H, In, Out, Mixed> { a: &'a A, // covariant over 'a and A b: &'b mut B, // covariant over 'b and invariant over B @@ -272,3 +442,4 @@ k2: Mixed, // invariant over Mixed, because invariance wins all conflicts } ``` + diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/vec-final.md rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/vec-final.md --- rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/vec-final.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/vec-final.md 2018-12-04 23:42:54.000000000 +0000 @@ -331,7 +331,7 @@ # assert_eq!(5, x); # assert_eq!(1, v.len()); # } -# +# # pub fn iter_test() { # let mut v = Vec::new(); # for i in 0..10 { @@ -344,7 +344,7 @@ # assert_eq!(0, *first); # assert_eq!(9, *last); # } -# +# # pub fn test_drain() { # let mut v = Vec::new(); # for i in 0..10 { @@ -361,19 +361,19 @@ # v.push(Box::new(1)); # assert_eq!(1, *v.pop().unwrap()); # } -# +# # pub fn test_zst() { # let mut v = Vec::new(); # for _i in 0..10 { # v.push(()) # } -# +# # let mut count = 0; -# +# # for _ in v.into_iter() { # count += 1 # } -# +# # assert_eq!(10, count); # } # } diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/what-unsafe-does.md rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/what-unsafe-does.md --- rustc-1.30.0+dfsg1+llvm/src/doc/nomicon/src/what-unsafe-does.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/nomicon/src/what-unsafe-does.md 2018-12-04 23:42:54.000000000 +0000 @@ -6,6 +6,7 @@ * Call `unsafe` functions (including C functions, compiler intrinsics, and the raw allocator) * Implement `unsafe` traits * Mutate statics +* Access fields of `union`s That's it. The reason these operations are relegated to Unsafe is that misusing any of these things will cause the ever dreaded Undefined Behavior. Invoking diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/not_found.md rustc-1.31.0+dfsg1+llvm/src/doc/not_found.md --- rustc-1.30.0+dfsg1+llvm/src/doc/not_found.md 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/not_found.md 2018-12-04 23:41:40.000000000 +0000 @@ -5,6 +5,28 @@ #TOC { display: none; } .header-section-number { display: none; } li {list-style-type: none; } +#search-input { + width: calc(100% - 100px); +} +#search-but { + cursor: pointer; +} +#search-but, #search-input { + padding: 4px; + border: 1px solid #ccc; + border-radius: 3px; + outline: none; + font-size: 0.7em; + background-color: #fff; +} +#search-but:hover, #search-input:focus { + border-color: #55a9ff; +} +#search-from { + border: none; + padding: 0; + font-size: 0.7em; +} Looks like you've taken a wrong turn. @@ -13,11 +35,20 @@ # Search -
- -
- -Rust doc search: +
+
+ + + + +
+
# Reference @@ -44,26 +75,28 @@ return op; } -function populate_site_search() { - var op = get_url_fragments(); - - var search = document.getElementById('site-search'); - search.value = op.join(' ') + " site:doc.rust-lang.org"; +function on_submit(event) { + var form = event.target; + var q = form['q'].value; + + event.preventDefault(); + + if (form['from'].value === 'duckduckgo') { + document.location.href = form.action + '?q=' + encodeURIComponent(q + ' site:doc.rust-lang.org'); + } else if (form['from'].value === 'library') { + document.location.href = 'std/index.html?search=' + encodeURIComponent(q); + } } -function populate_rust_search() { - var op = get_url_fragments(); - var lt = op.pop(); +function populate_search() { + var form = document.getElementById('search-form'); + form.addEventListener('submit', on_submit); + document.getElementById('search-from').style.display = ''; - // #18540, use a single token + form['from'].value = 'library'; - var a = document.createElement("a"); - a.href = "https://doc.rust-lang.org/core/?search=" + encodeURIComponent(lt); - a.textContent = lt; - var search = document.getElementById('core-search'); - search.innerHTML = ""; - search.appendChild(a); + var op = get_url_fragments(); + document.getElementById('search-input').value = op.join(' '); } -populate_site_search(); -populate_rust_search(); +populate_search(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/README.md rustc-1.31.0+dfsg1+llvm/src/doc/README.md --- rustc-1.30.0+dfsg1+llvm/src/doc/README.md 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/README.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -# Rust documentations - -## Building - -To generate all the docs, follow the "Building Documentation" instructions in -the README in the root of the repository. This will convert the distributed -Markdown docs to HTML and generate HTML doc for the books, 'std' and 'extra' -libraries. - -To generate HTML documentation from one source file/crate, do something like: - -~~~~text -rustdoc --output html-doc/ --output-format html ../src/libstd/path.rs -~~~~ - -(This, of course, requires a working build of the `rustdoc` tool.) - -## Additional notes - -To generate an HTML version of a doc from Markdown manually, you can do -something like: - -~~~~text -rustdoc reference.md -~~~~ - -(`reference.md` being the Rust Reference Manual.) - -An overview of how to use the `rustdoc` command is available [in the docs][1]. -Further details are available from the command line by with `rustdoc --help`. - -[1]: https://github.com/rust-lang/rust/blob/master/src/doc/rustdoc/src/what-is-rustdoc.md diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/attributes.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/attributes.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/attributes.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/attributes.md 2018-12-04 23:42:54.000000000 +0000 @@ -11,15 +11,16 @@ >    `#[` MetaItem `]` > > _MetaItem_ :\ ->       IDENTIFIER\ ->    | IDENTIFIER `=` LITERAL\ ->    | IDENTIFIER `(` _MetaSeq_ `)` +>       [_SimplePath_]\ +>    | [_SimplePath_] `=` [_LiteralExpression_]_without suffix_\ +>    | [_SimplePath_] `(` _MetaSeq_? `)` > > _MetaSeq_ :\ ->       EMPTY\ ->    | _MetaItem_\ ->    | LITERAL\ ->    | _MetaItem_ `,` _MetaSeq_ +>    _MetaItemInner_ ( `,` MetaItemInner )\* `,`? +> +> _MetaItemInner_ :\ +>       _MetaItem_\ +>    | [_LiteralExpression_]_without suffix_ An _attribute_ is a general, free-form metadatum that is interpreted according to name, convention, and language and compiler version. Attributes are modeled @@ -33,6 +34,8 @@ * An identifier followed by a parenthesized list of sub-attribute arguments which include literals +Literal values must not include integer or float type suffixes. + _Inner attributes_, written with a bang ("!") after the hash ("#"), apply to the item that the attribute is declared within. _Outer attributes_, written without the bang after the hash, apply to the thing that follows the attribute. @@ -41,13 +44,16 @@ * All [item declarations] accept outer attributes while [external blocks], [functions], [implementations], and [modules] accept inner attributes. -* [Statements] accept outer attributes. +* Most [statements] accept outer attributes (see [Expression Attributes] for + limitations on expression statements). * [Block expressions] accept outer and inner attributes, but only when they are the outer expression of an [expression statement] or the final expression of another block expression. * [Enum] variants and [struct] and [union] fields accept outer attributes. * [Match expression arms][match expressions] accept outer attributes. * [Generic lifetime or type parameter][generics] accept outer attributes. +* Expressions accept outer attributes in limited situations, see [Expression + Attributes] for details. Some examples of attributes: @@ -74,7 +80,7 @@ // Outer attribute applies to the entire function. fn some_unused_variables() { #![allow(unused_variables)] - + let x = (); let y = (); let z = (); @@ -90,7 +96,7 @@ ## Active and inert attributes An attribute is either active or inert. During attribute processing, *active -attributes* remove themselves from the thing they are on while *inert attriutes* +attributes* remove themselves from the thing they are on while *inert attributes* stay on. The `cfg` and `cfg_attr` attributes are active. The `test` attribute is inert @@ -104,6 +110,9 @@ ## Crate-only attributes +> **Note**: This section is in the process of being removed, with specific +> sections for each attribute. It is not the full list of crate-root attributes. + - `crate_name` - specify the crate's crate name. - `crate_type` - see [linkage](linkage.html). - `no_builtins` - disable optimizing certain code patterns to invocations of @@ -112,7 +121,6 @@ object being linked to defines `main`. - `no_start` - disable linking to the `native` crate, which specifies the "start" language item. -- `no_std` - disable linking to the `std` crate. - `recursion_limit` - Sets the maximum depth for potentially infinitely-recursive compile-time operations like auto-dereference or macro expansion. The default is @@ -127,14 +135,6 @@ [subsystem]: https://msdn.microsoft.com/en-us/library/fcc1zstk.aspx -## Module-only attributes - -- `no_implicit_prelude` - disable injecting `use std::prelude::*` in this - module. -- `path` - specifies the file to load the module from. `#[path="foo.rs"] mod - bar;` is equivalent to `mod bar { /* contents of foo.rs */ }`. The path is - taken relative to the directory that the current module is in. - ## FFI attributes On an `extern` block, the following attributes are interpreted: @@ -173,8 +173,7 @@ - `macro_use` on an `extern crate` — load macros from this crate. An optional list of names `#[macro_use(foo, bar)]` restricts the import to just those macros named. The `extern crate` must appear at the crate root, not inside - `mod`, which ensures proper function of the [`$crate` macro - variable](../book/first-edition/macros.html#the-variable-crate). + `mod`, which ensures proper function of the `$crate` macro variable. - `macro_reexport` on an `extern crate` — re-export the named macros. @@ -183,10 +182,6 @@ - `no_link` on an `extern crate` — even if we load this crate for macros, don't link it into the output. -See the [macros section of the first edition of the -book](../book/first-edition/macros.html#scoping-and-macro-importexport) for more -information on `macro_rules` macro scope. - - `proc_macro` - Defines a [function-like macro]. - `proc_macro_derive` - Defines a [derive mode macro]. @@ -242,6 +237,17 @@ See [The Rustdoc Book] for reference material on this attribute. +### `path` + +The `path` attribute says where a [module]'s source file is. See [modules] for +more information. + +### Preludes + +The [prelude] behavior can be modified with attributes. The [`no_std`] attribute +changes the prelude to the core prelude while the [`no_implicit_prelude`] +prevents the prelude from being added to the module. + ### Testing The compiler comes with a default test framework. It works by attributing @@ -354,6 +360,35 @@ } ``` +#### Tool lint attributes + +Tool lints let you use scoped lints, to `allow`, `warn`, `deny` or `forbid` lints of +certain tools. + +Currently `clippy` is the only available lint tool. + +They only get checked when the associated tool is active, so if you try to use an `allow` attribute for a nonexistent tool lint, the compiler will not warn about the nonexistent lint until you use the tool. + +Otherwise, they work just like regular lint attributes: + + +```rust,ignore +// set the entire `pedantic` clippy lint group to warn +#![warn(clippy::pedantic)] +// silence warnings from the `filter_map` clippy lint +#![allow(clippy::filter_map)] + +fn main() { + // ... +} + +// silence the `cmp_nan` clippy lint just for this function +#[allow(clippy::cmp_nan)] +fn foo() { + // ... +} +``` + #### `must_use` The `must_use` attribute can be used on user-defined composite types @@ -472,7 +507,7 @@ > ***Note***: The compiler automatically inlines functions based on internal > heuristics. Incorrectly inlining functions can actually make the program -> slower, so this attibute should be used with care. +> slower, so this attribute should be used with care. There are three ways of using the inline attribute: @@ -494,7 +529,7 @@ The `derive` attribute allows certain traits to be automatically implemented for data structures. For example, the following will create an `impl` for the -`PartialEq` and `Clone` traits for `Foo`, the type parameter `T` will be given +`PartialEq` and `Clone` traits for `Foo`, and the type parameter `T` will be given the `PartialEq` or `Clone` constraints for the appropriate `impl`: ```rust @@ -522,8 +557,14 @@ You can implement `derive` for your own traits through [procedural macros]. +[_LiteralExpression_]: expressions/literal-expr.html +[_SimplePath_]: paths.html#simple-paths +[`no_implicit_prelude`]: items/modules.html +[`no_std`]: crates-and-source-files.html#preludes-and-no_std [Doc comments]: comments.html#doc-comments [The Rustdoc Book]: ../rustdoc/the-doc-attribute.html +[module]: items/modules.html +[prelude]: crates-and-source-files.html#preludes-and-no_std [procedural macros]: procedural-macros.html [struct]: items/structs.html [enum]: items/enumerations.html @@ -552,7 +593,9 @@ [function-like macro]: procedural-macros.html#function-like-procedural-macros [conditional compilation]: conditional-compilation.html [derive mode macro]: procedural-macros.html#derive-mode-macros -[trait]: items/traits.html[main]: crates-and-source-files.html +[trait]: items/traits.html +[main]: crates-and-source-files.html [`Termination`]: ../std/process/trait.Termination.html [where clause]: items/where-clauses.html [trait or lifetime bounds]: trait-bounds.html +[Expression Attributes]: expressions.html#expression-attributes diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/conditional-compilation.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/conditional-compilation.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/conditional-compilation.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/conditional-compilation.md 2018-12-04 23:42:54.000000000 +0000 @@ -1,18 +1,216 @@ -## Conditional compilation +# Conditional compilation -Sometimes one wants to have different compiler outputs from the same code, -depending on build target, such as targeted operating system, or to enable -release builds. - -Configuration options are boolean (on or off) and are named either with a -single identifier (e.g. `foo`) or an identifier and a string (e.g. `foo = "bar"`; -the quotes are required and spaces around the `=` are unimportant). Note that -similarly-named options, such as `foo`, `foo="bar"` and `foo="baz"` may each be -set or unset independently. - -Configuration options are either provided by the compiler or passed in on the -command line using `--cfg` (e.g. `rustc main.rs --cfg foo --cfg 'bar="baz"'`). -Rust code then checks for their presence using the `#[cfg(...)]` [attribute]: +> **Syntax**\ +> _ConfigurationPredicate_ :\ +>       _ConfigurationOption_\ +>    | _ConfigurationAll_\ +>    | _ConfigurationAny_\ +>    | _ConfigurationNot_ +> +> _ConfigurationOption_ :\ +>    [IDENTIFIER] (`=` ([STRING_LITERAL] | [RAW_STRING_LITERAL]))? +> +> _ConfigurationAll_\ +>    `all` `(` _ConfigurationPredicateList_? `)` +> +> _ConfigurationAny_\ +>    `any` `(` _ConfigurationPredicateList_? `)` +> +> _ConfigurationNot_\ +>    `not` `(` _ConfigurationPredicate_ `)` +> +> _ConfigurationPredicateList_\ +>    _ConfigurationPredicate_ (`,` _ConfigurationPredicate_)\* `,`? + +*Conditionally compiled source code* is source code that may or may not be +considered a part of the source code depending on certain conditions. Source code can be conditionally compiled +using [attributes], [`cfg`] and [`cfg_attr`], and the built-in [`cfg` macro]. +These conditions are based on the target architecture of the compiled crate, +arbitrary values passed to the compiler, and a few other miscellaneous things +further described below in detail. + +Each form of conditional compilation takes a _configuration predicate_ that +evaluates to true or false. The predicate is one of the following: + +* A configuration option. It is true if the option is set and false if it is + unset. +* `all()` with a comma separated list of configuration predicates. It is false + if at least one predicate is false. If there are no predicates, it is true. +* `any()` with a comma separated list of configuration predicates. It is true + if at least one predicate is true. If there are no predicates, it is false. +* `not()` with a configuration predicate. It is true if its predicate is false + and false if its predicate is true. + +_Configuration options_ are names and key-value pairs that are either set or +unset. Names are written as a single identifier such as, for example, `unix`. +Key-value pairs are written as an identifier, `=`, and then a string. For +example, `target_arch = "x86_64"` is a configuration option. + +> **Note**: Whitespace around the `=` is ignored. `foo="bar"` and `foo = "bar"` +> are equivalent configuration options. + +Keys are not unique in the set of key-value configuration options. For example, +both `feature = "std"` and `feature = "serde"` can be set at the same time. + +## Set Configuration Options + +Which configuration options are set is determined statically during the +compilation of the crate. Certain options are _compiler-set_ based on data +about the compilation. Other options are _arbitrarily-set_, set based on input +passed to the compiler outside of the code. It is not possible to set a +configuration option from within the source code of the crate being compiled. + +> **Note**: For `rustc`, arbitrary-set configuration options are set using the +> [`--cfg`] flag. + +
+ +Warning: It is possible for arbitrarily-set configuration options to have the +same value as compiler-set configuration options. For example, it is possible +to do `rustc --cfg "unix" program.rs` while compiling to a Windows target, and +have both `unix` and `windows` configuration options set at the same time. It +is unwise to actually do this. + +
+ +### `target_arch` + +Key-value option set once with the target's CPU architecture. The value is +similar to the first element of the platform's target triple, but not +identical. + +Example values: + +* `"x86"` +* `"x86_64"` +* `"mips"` +* `"powerpc"` +* `"powerpc64"` +* `"arm"` +* `"aarch64"` + +### `target_os` + +Key-value option set once with the target's operating system. This value is +similar to the second and third element of the platform's target triple. + +Example values: + +* `"windows"` +* `"macos"` +* `"ios"` +* `"linux"` +* `"android"` +* `"freebsd"` +* `"dragonfly"` +* `"bitrig"` +* `"openbsd"` +* `"netbsd"` + +### `target_family` + +Key-value option set at most once with the target's operating system value. + +Example values: + +* `"unix"` +* `"windows"` + +### `unix` and `windows` + +`unix` is set if `target_family = "unix"` is set and `windows` is set if +`target_family = "windows"` is set. + +### `target_env` + +Key-value option set with further disambiguating information about the target +platform with information about the ABI or `libc` used. For historical reasons, +this value is only defined as not the empty-string when actually needed for +disambiguation. Thus, for example, on many GNU platforms, this value will be +empty. This value is similar to the fourth element of the platform's target +triple. One difference is that embedded ABIs such as `gnueabihf` will simply +define `target_env` as `"gnu"`. + +Example values: + +* `""` +* `"gnu"` +* `"msvc"` +* `"musl"` + +### `target_endian` + +Key-value option set once with either a value of "little" or "big" depending +on the endianness of the target's CPU. + +### `target_pointer_width` + +Key-value option set once with the target's pointer width in bits. For example, +for targets with 32-bit pointers, this is set to `"32"`. Likewise, it is set +to `"64"` for targets with 64-bit pointers. + + + +### `target_has_atomic` + +Key-value option set for each integer size on which the target can perform +atomic operations. + +Possible values: + +* `"8"` +* `"16"` +* `"32"` +* `"64"` +* `"ptr"` + +### `target_vendor` + +Key-value option set once with the vendor of the target. + +Possible values: + +* `"apple"` +* `"pc"` +* `"unknown"` + +### `test` + +Enabled when compiling the test harness. Done with `rustc` by using the +[`--test`] flag. + +### `debug_assertions` + +Enabled by default when compiling without optimizations. +This can be used to enable extra debugging code in development but not in +production. For example, it controls the behavior of the standard library's +[`debug_assert!`] macro. + +### `proc_macro` + +Set when the crate being compiled is being compiled with the `proc_macro` +[crate type]. + +## Forms of conditional compilation + +### The `cfg` attribute + +> **Syntax**\ +> _CfgAttrAttribute_ :\ +>    `cfg` `(` _ConfigurationPredicate_ `)` + + + +The `cfg` [attribute] conditionally includes the thing it is attached to based +on a configuration predicate. + +It is written as `cfg`, `(`, a configuration predicate, and finally `)`. + +If the predicate is true, the thing is rewritten to not have the `cfg` attribute +on it. If the predicate is false, the thing is removed from the source code. + +Some examples on functions: ```rust // The function is only included in the build when compiling for macOS @@ -41,62 +239,72 @@ } ``` -This illustrates some conditional compilation can be achieved using the -`#[cfg(...)]` [attribute]. `any`, `all` and `not` can be used to assemble -arbitrarily complex configurations through nesting. - -The following configurations must be defined by the implementation: - -* `target_arch = "..."` - Target CPU architecture, such as `"x86"`, - `"x86_64"` `"mips"`, `"powerpc"`, `"powerpc64"`, `"arm"`, or - `"aarch64"`. This value is closely related to the first element of - the platform target triple, though it is not identical. -* `target_os = "..."` - Operating system of the target, examples - include `"windows"`, `"macos"`, `"ios"`, `"linux"`, `"android"`, - `"freebsd"`, `"dragonfly"`, `"bitrig"` , `"openbsd"` or - `"netbsd"`. This value is closely related to the second and third - element of the platform target triple, though it is not identical. -* `target_family = "..."` - Operating system family of the target, e. g. - `"unix"` or `"windows"`. The value of this configuration option is defined - as a configuration itself, like `unix` or `windows`. -* `unix` - See `target_family`. -* `windows` - See `target_family`. -* `target_env = ".."` - Further disambiguates the target platform with - information about the ABI/libc. Presently this value is either - `"gnu"`, `"msvc"`, `"musl"`, or the empty string. For historical - reasons this value has only been defined as non-empty when needed - for disambiguation. Thus on many GNU platforms this value will be - empty. This value is closely related to the fourth element of the - platform target triple, though it is not identical. For example, - embedded ABIs such as `gnueabihf` will simply define `target_env` as - `"gnu"`. -* `target_endian = "..."` - Endianness of the target CPU, either `"little"` or - `"big"`. -* `target_pointer_width = "..."` - Target pointer width in bits. This is set - to `"32"` for targets with 32-bit pointers, and likewise set to `"64"` for - 64-bit pointers. -* `target_has_atomic = "..."` - Set of integer sizes on which the target can perform - atomic operations. Values are `"8"`, `"16"`, `"32"`, `"64"` and `"ptr"`. -* `target_vendor = "..."` - Vendor of the target, for example `apple`, `pc`, or - simply `"unknown"`. -* `test` - Enabled when compiling the test harness (using the `--test` flag). -* `debug_assertions` - Enabled by default when compiling without optimizations. - This can be used to enable extra debugging code in development but not in - production. For example, it controls the behavior of the standard library's - `debug_assert!` macro. -* `proc_macro` - Set when the crate being compiled is being compiled with the - `proc_macro` [crate type]. +The `cfg` attribute is allowed anywhere attributes are allowed except on +generic parameters. + +### The `cfg_attr` attribute + +> **Syntax**\ +> _CfgAttrAttribute_ :\ +>    `cfg_attr` `(` _ConfigurationPredicate_ `,` [_MetaItem_] `,`? `)` + +The `cfg_attr` [attribute] conditionally includes [attributes] based on a +configuration predicate. -You can also set another [attribute] based on a `cfg` variable with `cfg_attr`: +It is written as `cfg_attr` followed by `(`, a configuration predicate, a +[metaitem], an optional `,`, and finally a `)`. + +When the configuration predicate is true, this attribute expands out to be an +attribute of the attribute metaitem. For example, the following module will +either be found at `linux.rs` or `windows.rs` based on the target. ```rust,ignore -#[cfg_attr(a, b)] +#[cfg_attr(linux, path = "linux.rs")] +#[cfg_attr(windows, path = "windows.rs")] +mod os; ``` -This is the same as `#[b]` if `a` is set by `cfg`, and nothing otherwise. +> **Note**: The `cfg_attr` can expand to another `cfg_attr`. For example, +> `#[cfg_attr(linux, cfg_attr(feature = "multithreaded", some_other_attribute))` +> is valid. This example would be equivalent to +> `#[cfg_attr(all(linux, feature ="multithreaded"), some_other_attribute)]`. + +The `cfg_attr` attribute is allowed anywhere attributes are allowed except on +generic parameters. + +### The `cfg` macro + +The built-in `cfg` macro takes in a single configuration predicate and evaluates +to the `true` literal when the predicate is true and the `false` literal when +it is false. -Lastly, configuration options can be used in expressions by invoking the `cfg!` -macro: `cfg!(a)` evaluates to `true` if `a` is set, and `false` otherwise. +For example: + +```rust +let machine_kind = if cfg!(unix) { + "unix" +} else if cfg!(windows) { + "windows" +} else { + "unknown" +}; + +println!("I'm running on a {} machine!", machine_kind); +``` +[IDENTIFIER]: identifiers.html +[RAW_STRING_LITERAL]: tokens.html#raw-string-literals +[STRING_LITERAL]: tokens.html#string-literals +[_MetaItem_]: attributes.html +[`--cfg`]: ../rustc/command-line-arguments.html#a--cfg-configure-the-compilation-environment +[`--test`]: ../rustc/command-line-arguments.html#a--test-build-a-test-harness +[`cfg`]: #the-cfg-attribute +[`cfg` macro]: #the-cfg-macro +[`cfg_attr`]: #the-cfg_attr-attribute +[`debug_assert!`]: ../std/macro.debug_assert.html [attribute]: attributes.html -[crate type]: linkage.html \ No newline at end of file +[attributes]: attributes.html +[crate type]: linkage.html +[expressions]: expressions.html +[items]: items.html +[metaitem]: attributes.html \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/const_eval.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/const_eval.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/const_eval.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/const_eval.md 2018-12-04 23:42:54.000000000 +0000 @@ -0,0 +1,82 @@ +# Constant evaluation + +Constant evaluation is the process of computing the result of +[expressions] during compilation. Only a subset of all expressions +can be evaluated at compile-time. + +## Constant expressions + +Certain types of expressions can be evaluated at compile time. These are called +_constant expressions_ and are required in const contexts. In +other places, such as in [`let` statements](statements.html#let-statements), +constant expressions may be evaluated at compile time. If errors, such as out +of bounds [array indexing] or [overflow] occurs, +then it is a compiler error if the value must be evaluated at compile time, +otherwise it is just a warning, but the code will most likely panic when run. + +The following expressions are constant expressions, so long as any operands are +also constant expressions and do not cause any [`Drop::drop`][destructors] calls +to be ran. + +* [Literals]. +* [Paths] to [functions](items/functions.html) and constants. + Recursively defining constants is not allowed. +* [Tuple expressions]. +* [Array expressions]. +* [Struct] expressions. +* [Enum variant] expressions. +* [Block expressions], including `unsafe` blocks, which only contain items and + possibly a constant tail expression. +* [Field] expressions. +* Index expressions, [array indexing] or [slice] with a `usize`. +* [Range expressions]. +* [Closure expressions] which don't capture variables from the environment. +* Built in [negation], [arithmetic, logical], [comparison] or [lazy boolean] + operators used on integer and floating point types, `bool` and `char`. +* Shared [borrow]s, except if applied to a type with [interior mutability]. +* The [dereference operator]. +* [Grouped] expressions. +* [Cast] expressions, except pointer to address and + function pointer to address casts. +* Calls of const functions and const methods + +## Const context + +A _const context_ is one of the following: + +* [Array type length expressions] +* Repeat expression length expressions +* The initializer of + * [constants] + * [statics] + * [enum discriminants] + +[array type length expressions]: types/array.html +[enum discriminants]: items/enumerations.html#custom-discriminant-values-for-field-less-enumerations +[constants]: items/constant-items.html +[statics]: items/static-items.html +[expressions]: expressions.html +[array indexing]: expressions/array-expr.html#array-and-slice-indexing-expressions +[overflow]: expressions/operator-expr.html#overflow +[destructors]: destructors.html +[literals]: expressions/literal-expr.html +[paths]: expressions/path-expr.html +[tuple expressions]: expressions/tuple-expr.html +[array expressions]: expressions/array-expr.html +[struct]: expressions/struct-expr.html +[enum variant]: expressions/enum-variant-expr.html +[block expressions]: expressions/block-expr.html +[field]: expressions/field-expr.html +[array indexing]: expressions/array-expr.html#array-and-slice-indexing-expressions +[slice]: types/slice.html +[range expressions]: expressions/range-expr.html +[closure expressions]: expressions/closure-expr.html +[negation]: expressions/operator-expr.html#negation-operators +[arithmetic, logical]: expressions/operator-expr.html#arithmetic-and-logical-binary-operators +[comparison]: expressions/operator-expr.html#comparison-operators +[lazy boolean]: expressions/operator-expr.html#lazy-boolean-operators +[borrow]: expressions/operator-expr.html#borrow-operators +[interior mutability]: interior-mutability.html +[dereference operator]: expressions/operator-expr.html#the-dereference-operator +[grouped]: expressions/grouped-expr.html +[cast]: expressions/operator-expr.html#type-cast-expressions diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/crates-and-source-files.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/crates-and-source-files.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/crates-and-source-files.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/crates-and-source-files.md 2018-12-04 23:42:54.000000000 +0000 @@ -14,15 +14,14 @@ > Note: Although Rust, like any other language, can be implemented by an > interpreter as well as a compiler, the only existing implementation is a -> compiler,and the language has always been designed to be compiled. For these +> compiler, and the language has always been designed to be compiled. For these > reasons, this section assumes a compiler. Rust's semantics obey a *phase distinction* between compile-time and run-time.[^phase-distinction] Semantic rules that have a *static interpretation* govern the success or failure of compilation, while -semantic rules -that have a *dynamic interpretation* govern the behavior of the program at -run-time. +semantic rules that have a *dynamic interpretation* govern the behavior of the +program at run-time. The compilation model centers on artifacts called _crates_. Each compilation processes a single crate in source form, and if successful, produces a single @@ -43,10 +42,10 @@ A Rust source file describes a module, the name and location of which — in the module tree of the current crate — are defined from outside the -source file: either by an explicit `mod_item` in a referencing source file, or -by the name of the crate itself. Every source file is a module, but not every -module needs its own source file: [module definitions][module] can be nested -within one file. +source file: either by an explicit [`mod` item][module] in a referencing +source file, or by the name of the crate itself. Every source file is a +module, but not every module needs its own source file: [module +definitions][module] can be nested within one file. Each source file contains a sequence of zero or more `item` definitions, and may optionally begin with any number of [attributes] @@ -66,22 +65,6 @@ #![warn(non_camel_case_types)] ``` -A crate that contains a `main` [function] can be compiled to an executable. If a -`main` function is present, it must take no arguments, must not declare any -[trait or lifetime bounds], must not have any [where clauses], and its return -type must be one of the following: - -* `()` -* `Result<(), E> where E: Error` - - - -> Note: The implementation of which return types are allowed is determined by -> the unstable [`Termination`] trait. - - - The optional [_UTF8 byte order mark_] (UTF8BOM production) indicates that the file is encoded in UTF8. It can only occur at the beginning of the file and is ignored by the compiler. @@ -100,6 +83,48 @@ } ``` +## Preludes and `no_std` + +All crates have a *prelude* that automatically inserts names from a specific +module, the *prelude module*, into scope of each [module] and an [`extern +crate`] into the crate root module. By default, the *standard prelude* is used. +The linked crate is [`std`] and the prelude module is [`std::prelude::v1`]. + +The prelude can be changed to the *core prelude* by using the `no_std` +[attribute] on the root crate module. The linked crate is [`core`] and the +prelude module is [`core::prelude::v1`]. Using the core prelude over the +standard prelude is useful when either the crate is targeting a platform that +does not support the standard library or is purposefully not using the +capabilities of the standard library. Those capabilities are mainly dynamic +memory allocation (e.g. `Box` and `Vec`) and file and network capabilities (e.g. +`std::fs` and `std::io`). + +
+ +Warning: Using `no_std` does not prevent the standard library from being linked +in. It is still valid to put `extern crate std;` into the crate and dependencies +can also link it in. + +
+ +## Main Functions + +A crate that contains a `main` [function] can be compiled to an executable. If a +`main` function is present, it must take no arguments, must not declare any +[trait or lifetime bounds], must not have any [where clauses], and its return +type must be one of the following: + +* `()` +* `Result<(), E> where E: Error` + + + +> Note: The implementation of which return types are allowed is determined by +> the unstable [`Termination`] trait. + + + [^phase-distinction]: This distinction would also exist in an interpreter. Static checks like syntactic analysis, type checking, and lints should happen before the program is executed regardless of when it is executed. @@ -108,15 +133,22 @@ ECMA-335 CLI model, a *library* in the SML/NJ Compilation Manager, a *unit* in the Owens and Flatt module system, or a *configuration* in Mesa. -[module]: items/modules.html -[module path]: paths.html -[attributes]: attributes.html -[unit]: types.html#tuple-types [_InnerAttribute_]: attributes.html [_Item_]: items.html [_shebang_]: https://en.wikipedia.org/wiki/Shebang_(Unix) [_utf8 byte order mark_]: https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8 -[function]: items/functions.html [`Termination`]: ../std/process/trait.Termination.html -[where clauses]: items/generics.html#where-clauses +[`core`]: ../core/index.html +[`core::prelude::v1`]: ../core/prelude/index.html +[`extern crate`]: items/extern-crates.html +[`std`]: ../std/index.html +[`std::prelude::v1`]: ../std/prelude/index.html +[`use` declaration]: items/use-declarations.html +[attribute]: attributes.html +[attributes]: attributes.html +[function]: items/functions.html +[module]: items/modules.html +[module path]: paths.html [trait or lifetime bounds]: trait-bounds.html +[unit]: types.html#tuple-types +[where clauses]: items/generics.html#where-clauses diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/destructors.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/destructors.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/destructors.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/destructors.md 2018-12-04 23:42:54.000000000 +0000 @@ -82,12 +82,12 @@ [Assignment]: expressions/operator-expr.html#assignment-expressions [`std::ops::Drop::drop`]: ../std/ops/trait.Drop.html [RFC 1857]: https://github.com/rust-lang/rfcs/blob/master/text/1857-stabilize-drop-order.md -[struct]: types.html#struct-types -[tuple]: types.html#tuple-types -[enum variant]: types.html#enumerated-types -[array]: types.html#array-and-slice-types -[closure]: types.html#closure-types -[Trait objects]: types.html#trait-objects +[struct]: types/struct.html +[tuple]: types/tuple.html +[enum variant]: types/enum.html +[array]: types/array.html +[closure]: types/closure.html +[Trait objects]: types/trait-object.html [`std::ptr::drop_in_place`]: ../std/ptr/fn.drop_in_place.html [`std::mem::forget`]: ../std/mem/fn.forget.html [`std::mem::ManuallyDrop`]: ../std/mem/struct.ManuallyDrop.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/dynamically-sized-types.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/dynamically-sized-types.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/dynamically-sized-types.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/dynamically-sized-types.md 2018-12-04 23:42:54.000000000 +0000 @@ -24,9 +24,9 @@ `Sized`. [sized]: special-types-and-traits.html#sized -[Slices]: types.html#array-and-slice-types -[trait objects]: types.html#trait-objects -[Pointer types]: types.html#pointer-types +[Slices]: types/slice.html +[trait objects]: types/trait-object.html +[Pointer types]: types/pointer.html [variables]: variables.html [const]: items/constant-items.html [static]: items/static-items.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/array-expr.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/array-expr.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/array-expr.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/array-expr.md 2018-12-04 23:42:54.000000000 +0000 @@ -4,18 +4,20 @@ > **Syntax**\ > _ArrayExpression_ :\ ->       `[` `]`\ ->    | `[` [_Expression_] ( `,` [_Expression_] )\* `,`? `]`\ ->    | `[` [_Expression_] `;` [_Expression_] `]` +>    `[` [_InnerAttribute_]\* _ArrayElements_? `]` +> +> _ArrayElements_ :\ +>       [_Expression_] ( `,` [_Expression_] )\* `,`?\ +>    | [_Expression_] `;` [_Expression_] -An _[array](types.html#array-and-slice-types) expression_ can be written by +An _[array](types/array.html) expression_ can be written by enclosing zero or more comma-separated expressions of uniform type in square brackets. This produces and array containing each of these values in the order they are written. Alternatively there can be exactly two expressions inside the brackets, separated by a semi-colon. The expression after the `;` must be a have type -`usize` and be a [constant expression](expressions.html#constant-expressions), +`usize` and be a [constant expression], such as a [literal](tokens.html#literals) or a [constant item](items/constant-items.html). `[a; b]` creates an array containing `b` copies of the value of `a`. If the expression after the semi-colon has a value @@ -30,13 +32,19 @@ [[1, 0, 0], [0, 1, 0], [0, 0, 1]]; // 2D array ``` +### Array expression attributes + +[Inner attributes] are allowed directly after the opening bracket of an array +expression in the same expression contexts as [attributes on block +expressions]. + ## Array and slice indexing expressions > **Syntax**\ > _IndexExpression_ :\ >    [_Expression_] `[` [_Expression_] `]` -[Array and slice](types.html#array-and-slice-types)-typed expressions can be +[Array](types/array.html) and [slice](types/slice.html)-typed expressions can be indexed by writing a square-bracket-enclosed expression of type `usize` (the index) after them. When the array is mutable, the resulting [memory location] can be assigned to. @@ -73,8 +81,11 @@ The array index expression can be implemented for types other than arrays and slices by implementing the [Index] and [IndexMut] traits. +[IndexMut]: ../std/ops/trait.IndexMut.html +[Index]: ../std/ops/trait.Index.html +[Inner attributes]: attributes.html [_Expression_]: expressions.html +[_InnerAttribute_]: attributes.html +[attributes on block expressions]: expressions/block-expr.html#attributes-on-block-expressions +[constant expression]: const_eval.html#constant-expressions [memory location]: expressions.html#place-expressions-and-value-expressions -[Index]: ../std/ops/trait.Index.html -[IndexMut]: ../std/ops/trait.IndexMut.html -[constant expression]: expressions.html#constant-expressions diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/block-expr.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/block-expr.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/block-expr.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/block-expr.md 2018-12-04 23:42:54.000000000 +0000 @@ -4,19 +4,15 @@ > _BlockExpression_ :\ >    `{`\ >       [_InnerAttribute_]\*\ ->       _Statements_\*\ ->       [_Expression_]?\ +>       _Statements_?\ >    `}` > > _Statements_ :\ ->    ( `;`\ ->    | [_ItemDeclaration_]\ ->    | [_LetStatement_] ;\ ->    | [_NonControlFlowExpressionStatement_][expression statement] ;\ ->    | [_FlowControlExpressionStatement_][expression statement] ;?\ ->    )\* +>       [_Statement_]\+\ +>    | [_Statement_]\+ [_ExpressionWithoutBlock_]\ +>    | [_ExpressionWithoutBlock_] -A *block expression*, or *block*, is a control flow expression and anonymouse +A *block expression*, or *block*, is a control flow expression and anonymous namespace scope for items and variable declarations. As a control flow expression, a block sequentially executes its component non-item declaration statements and then its final optional expression. As an anonymous namespace @@ -60,7 +56,7 @@ > expression of an expression statement, the expected type is `()` unless it > is followed immediately by a semicolon. -Blocks are always [value expressions] and evaluate the last expression in +Blocks are always [value expressions] and evaluate the last expression in value expression context. This can be used to force moving a value if really needed. For example, the following example fails on the call to `consume_self` because the struct was moved out of `s` in the block expression. @@ -76,7 +72,7 @@ fn move_by_block_expression() { let s = Struct; - // Move the value out of `s` in the block expreesion. + // Move the value out of `s` in the block expression. (&{ s }).borrow_self(); // Fails to execute because `s` is moved out of. @@ -109,11 +105,19 @@ ## Attributes on block expressions -Block expressions allow [outer attributes] and [inner attributes] directly after -the opening brace when the block expression is the outer expression of an -[expression statement] or the final expression of another block expression. The -attributes that have meaning on a block expression are [`cfg`] and [the lint -check attributes]. +[Inner attributes] are allowed directly after the opening brace of a block +expression in the following situations: + +* [Function] and [method] bodies. +* Loop bodies ([`loop`], [`while`], [`while let`], and [`for`]). +* Block expressions used as a [statement]. +* Block expressions as elements of [array expressions], [tuple expressions], + [call expressions], tuple-style [struct] and [enum variant] expressions. +* A block expression as the tail expression of another block expression. + + +The attributes that have meaning on a block expression are [`cfg`] and [the +lint check attributes]. For example, this function returns `true` on unix platforms and `false` on other platforms. @@ -125,17 +129,26 @@ } ``` +[_ExpressionWithoutBlock_]: expressions.html [_InnerAttribute_]: attributes.html -[_ItemDeclaration_]: items.html -[_LetStatement_]: statements.html#let-statements -[expression statement]: statements.html#expression-statements -[_Expression_]: expressions.html +[_Statement_]: statements.html +[`cfg`]: conditional-compilation.html +[`for`]: expressions/loop-expr.html#iterator-loops +[`loop`]: expressions/loop-expr.html#infinite-loops +[`while let`]: expressions/loop-expr.html#predicate-pattern-loops +[`while`]: expressions/loop-expr.html#predicate-loops +[array expressions]: expressions/array-expr.html +[call expressions]: expressions/call-expr.html +[enum variant]: expressions/enum-variant-expr.html +[expression attributes]: expressions.html#expression-attributes [expression]: expressions.html -[statements]: statements.html -[value expressions]: expressions.html#place-expressions-and-value-expressions -[outer attributes]: attributes.html +[function]: items/functions.html [inner attributes]: attributes.html -[expression statement]: statements.html#expression-statements -[`cfg`]: conditional-compilation.html +[method]: items/associated-items.html#methods +[statement]: statements.html +[statements]: statements.html +[struct]: expressions/struct-expr.html [the lint check attributes]: attributes.html#lint-check-attributes +[tuple expressions]: expressions/tuple-expr.html [unsafe operations]: unsafety.html +[value expressions]: expressions.html#place-expressions-and-value-expressions diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/call-expr.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/call-expr.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/call-expr.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/call-expr.md 2018-12-04 23:42:54.000000000 +0000 @@ -10,7 +10,7 @@ A _call expression_ consists of an expression followed by a parenthesized expression-list. It invokes a function, providing zero or more input variables. If the function eventually returns, then the expression completes. For -[non-function types](types.html#function-item-types), the expression f(...) uses +[non-function types](types/function-item.html), the expression f(...) uses the method on one of the [`std::ops::Fn`], [`std::ops::FnMut`] or [`std::ops::FnOnce`] traits, which differ in whether they take the type by reference, mutable reference, or take ownership respectively. An automatic diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/closure-expr.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/closure-expr.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/closure-expr.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/closure-expr.md 2018-12-04 23:42:54.000000000 +0000 @@ -8,7 +8,7 @@ A _closure expression_ defines a closure and denotes it as a value, in a single expression. A closure expression is a pipe-symbol-delimited (`|`) list of -patterns followed by an expression. Type annotations may optionally be added +irrefutable [patterns] followed by an expression. Type annotations may optionally be added for the type of the parameters or for the return type. If there is a return type, the expression used for the body of the closure must be a normal [block]. A closure expression also may begin with the @@ -25,7 +25,7 @@ Significantly, closure expressions _capture their environment_, which regular [function definitions] do not. Without the `move` keyword, the closure expression -[infers how it captures each variable from its environment](types.html#capture-modes), +[infers how it captures each variable from its environment](types/closure.html#capture-modes), preferring to capture by shared reference, effectively borrowing all outer variables mentioned inside the closure's body. If needed the compiler will infer that instead mutable references should be taken, or that the values @@ -35,7 +35,7 @@ closure's type is `'static`. The compiler will determine which of the [closure -traits](types.html#call-traits-and-coercions) the closure's type will implement by how it +traits](types/closure.html#call-traits-and-coercions) the closure's type will implement by how it acts on its captured variables. The closure will also implement [`Send`](special-types-and-traits.html#send) and/or [`Sync`](special-types-and-traits.html#sync) if all of its captured types do. @@ -63,8 +63,9 @@ [block]: expressions/block-expr.html [function definitions]: items/functions.html +[patterns]: patterns.html [_Expression_]: expressions.html [_BlockExpression_]: expressions/block-expr.html -[_TypeNoBounds_]: types.html +[_TypeNoBounds_]: types.html#type-expressions [_FunctionParameters_]: items/functions.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/enum-variant-expr.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/enum-variant-expr.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/enum-variant-expr.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/enum-variant-expr.md 2018-12-04 23:42:54.000000000 +0000 @@ -1,7 +1,30 @@ # Enumeration Variant expressions -Enumeration variants can be constructed similarly to structs, using a path to -an enum variant instead of to a struct: +> **Syntax**\ +> _EnumerationVariantExpression_ :\ +>       _EnumExprStruct_\ +>    | _EnumExprTuple_\ +>    | _EnumExprFieldless_ +> +> _EnumExprStruct_ :\ +>    [_PathInExpression_] `{` _EnumExprFields_? `}` +> +> _EnumExprFields_ :\ +>       _EnumExprField_ (`,` _EnumExprField_)\* `,`? +> +> _EnumExprField_ :\ +>       [IDENTIFIER]\ +>    | ([IDENTIFIER] | [TUPLE_INDEX]) `:` [_Expression_] +> +> _EnumExprTuple_ :\ +>    [_PathInExpression_] `(`\ +>       ( [_Expression_] (`,` [_Expression_])\* `,`? )?\ +>    `)` +> +> _EnumExprFieldless_ : [_PathInExpression_] + +Enumeration variants can be constructed similarly to [structs], using a path to an enum +variant instead of to a struct: ```rust # enum Message { @@ -13,3 +36,12 @@ let w = Message::WriteString("Some string".to_string()); let m = Message::Move { x: 50, y: 200 }; ``` + +Enum variant expressions have the same syntax, behavior, and restrictions as [struct +expressions][structs], except they do not support base update with the `..` syntax. + +[IDENTIFIER]: identifiers.html +[TUPLE_INDEX]: tokens.html#integer-literals +[_Expression_]: expressions.html +[_PathInExpression_]: paths.html#paths-in-expressions +[structs]: expressions/struct-expr.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/grouped-expr.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/grouped-expr.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/grouped-expr.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/grouped-expr.md 2018-12-04 23:42:54.000000000 +0000 @@ -2,7 +2,7 @@ > **Syntax**\ > _GroupedExpression_ :\ ->    `(` [_Expression_] `)` +>    `(` [_InnerAttribute_]\* [_Expression_] `)` An expression enclosed in parentheses evaluates to the result of the enclosed expression. Parentheses can be used to explicitly specify evaluation order @@ -35,4 +35,13 @@ assert_eq!((a.f)(), "The field f"); ``` +## Group expression attributes + +[Inner attributes] are allowed directly after the opening parenthesis of a +group expression in the same expression contexts as [attributes on block +expressions]. + +[Inner attributes]: attributes.html [_Expression_]: expressions.html +[_InnerAttribute_]: attributes.html +[attributes on block expressions]: expressions/block-expr.html#attributes-on-block-expressions diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/if-expr.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/if-expr.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/if-expr.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/if-expr.md 2018-12-04 23:42:54.000000000 +0000 @@ -44,7 +44,7 @@ > **Syntax**\ > _IfLetExpression_ :\ ->    `if` `let` _Pattern_ `=` [_Expression_]_except struct expression_ +>    `if` `let` [_Pattern_] `=` [_Expression_]_except struct or lazy boolean operator expression_ > [_BlockExpression_]\ >    (`else` ( > [_BlockExpression_] @@ -92,5 +92,47 @@ assert_eq!(a, 3); ``` +An `if let` expression is equivalent to a `match` expression as follows: + +```rust,ignore +if let PAT = EXPR { + /* body */ +} else { + /*else */ +} +``` + +is equivalent to + +```rust,ignore +match EXPR { + PAT => { /* body */ }, + _ => { /* else */ }, // () if there is no else +} +``` + +The expression cannot be a [lazy boolean operator expression][_LazyBooleanOperatorExpression_]. +Use of a lazy boolean operator is ambiguous with a planned feature change +of the language (the implementation of if-let chains - see [eRFC 2947][_eRFCIfLetChain_]). +When lazy boolean operator expression is desired, this can be achieved +by using parenthesis as below: + +```rust,ignore +// Before... +if let PAT = EXPR && EXPR { .. } + +// After... +if let PAT = ( EXPR && EXPR ) { .. } + +// Before... +if let PAT = EXPR || EXPR { .. } + +// After... +if let PAT = ( EXPR || EXPR ) { .. } +``` + [_Expression_]: expressions.html [_BlockExpression_]: expressions/block-expr.html +[_Pattern_]: patterns.html +[_LazyBooleanOperatorExpression_]: expressions/operator-expr.html#lazy-boolean-operators +[_eRFCIfLetChain_]: https://github.com/rust-lang/rfcs/blob/master/text/2497-if-let-chains.md#rollout-plan-and-transitioning-to-rust-2018 diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/loop-expr.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/loop-expr.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/loop-expr.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/loop-expr.md 2018-12-04 23:42:54.000000000 +0000 @@ -37,7 +37,7 @@ `loop { println!("I live."); }`. A `loop` expression without an associated `break` expression is diverging and -has type [`!`](types.html#never-type). A `loop` expression containing +has type [`!`](types/never.html). A `loop` expression containing associated [`break` expression(s)](#break-expressions) may terminate, and must have type compatible with the value of the `break` expression(s). @@ -67,7 +67,7 @@ > **Syntax**\ > [_PredicatePatternLoopExpression_] :\ ->    `while` `let` _Pattern_ `=` [_Expression_]except struct expression +>    `while` `let` [_Pattern_] `=` [_Expression_]except struct expression > [_BlockExpression_] A `while let` loop is semantically similar to a `while` loop but in place of a @@ -85,11 +85,31 @@ } ``` +A `while let` loop is equivalent to a `loop` expression containing a `match` +expression as follows. + +```rust,ignore +'label: while let PAT = EXPR { + /* loop body */ +} +``` + +is equivalent to + +```rust,ignore +'label: loop { + match EXPR { + PAT => { /* loop body */ }, + _ => break, + } +} +``` + ## Iterator loops > **Syntax**\ > _IteratorLoopExpression_ :\ ->    `for` _Pattern_ `in` [_Expression_]except struct expression +>    `for` [_Pattern_] `in` [_Expression_]except struct expression > [_BlockExpression_] A `for` expression is a syntactic construct for looping over elements provided @@ -118,6 +138,43 @@ assert_eq!(sum, 55); ``` +A for loop is equivalent to the following block expression. + +```rust,ignore +'label: for PATTERN in iter_expr { + /* loop body */ +} +``` + +is equivalent to + +```rust,ignore +{ + let result = match IntoIterator::into_iter(iter_expr) { + mut iter => 'label: loop { + let mut next; + match Iterator::next(&mut iter) { + Option::Some(val) => next = val, + Option::None => break, + }; + let PAT = next; + let () = { /* loop body */ }; + }, + }; + result +} +``` + +`IntoIterator`, `Iterator` and `Option` are always the standard library items +here, not whatever those names resolve to in the current scope. The variable +names `next`, `iter` and `val` are for exposition only, they do not actually +have names the user can type. + +> **Note**: that the outer `match` is used to ensure that any +> [temporary values] in `iter_expr` don't get dropped before the loop is +> finished. `next` is declared before being assigned because it results in +> types being inferred correctly more often. + ## Loop labels > **Syntax**\ @@ -210,8 +267,10 @@ expression `()`. [IDENTIFIER]: identifiers.html +[temporary values]: expressions.html#temporary-lifetimes [_Expression_]: expressions.html [_BlockExpression_]: expressions/block-expr.html +[_Pattern_]: patterns.html [LIFETIME_OR_LABEL]: tokens.html#lifetimes-and-loop-labels diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/match-expr.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/match-expr.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/match-expr.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/match-expr.md 2018-12-04 23:42:54.000000000 +0000 @@ -18,18 +18,15 @@ >    [_OuterAttribute_]\* _MatchArmPatterns_ _MatchArmGuard_? > > _MatchArmPatterns_ :\ ->    `|`? _Pattern_ ( `|` _Pattern_ )\* +>    `|`? [_Pattern_] ( `|` [_Pattern_] )\* > > _MatchArmGuard_ :\ >    `if` [_Expression_] A *`match` expression* branches on a pattern. The exact form of matching that -occurs depends on the pattern. *Patterns* consist of some combination of -literals, destructured arrays or enum constructors, structs and tuples, -variable binding specifications, wildcards (`..`), and placeholders (`_`). A -`match` expression has a *head expression*, which is the value to compare to -the patterns. The type of the patterns must equal the type of the head -expression. +occurs depends on the [pattern]. A `match` +expression has a *head expression*, which is the value to compare to the +patterns. The head expression and the patterns must have the same type. A `match` behaves differently depending on whether or not the head expression is a [place expression or value expression][place expression]. @@ -62,65 +59,10 @@ } ``` -Patterns that bind variables default to binding to a copy or move of the -matched value (depending on the matched value's type). This can be changed to -bind to a reference by using the `ref` keyword, or to a mutable reference using -`ref mut`. - -Patterns can be used to *destructure* structs, enums, and tuples. Destructuring -breaks a value up into its component pieces. The syntax used is the same as -when creating such values. When destructing a data structure with named (but -not numbered) fields, it is allowed to write `fieldname` as a shorthand for -`fieldname: fieldname`. In a pattern whose head expression has a `struct`, -`enum` or `tupl` type, a placeholder (`_`) stands for a *single* data field, -whereas a wildcard `..` stands for *all* the fields of a particular variant. +Variables bound within the pattern are scoped to the match guard and the arm's +expression. The [binding mode] (move, copy, or reference) depends on the pattern. -```rust -# enum Message { -# Quit, -# WriteString(String), -# Move { x: i32, y: i32 }, -# ChangeColor(u8, u8, u8), -# } -# let message = Message::Quit; -match message { - Message::Quit => println!("Quit"), - Message::WriteString(write) => println!("{}", &write), - Message::Move{ x, y: 0 } => println!("move {} horizontally", x), - Message::Move{ .. } => println!("other move"), - Message::ChangeColor { 0: red, 1: green, 2: _ } => { - println!("color change, red: {}, green: {}", red, green); - } -}; -``` - -Patterns can also dereference pointers by using the `&`, `&mut` and `box` -symbols, as appropriate. For example, these two matches on `x: &i32` are -equivalent: - -```rust -let int_reference = &3; - -let a = match *int_reference { 0 => "zero", _ => "some" }; -let b = match int_reference { &0 => "zero", _ => "some" }; - -assert_eq!(a, b); -``` - -Subpatterns can also be bound to variables by the use of the syntax `variable @ -subpattern`. For example: - -```rust -let x = 1; - -match x { - e @ 1 ... 5 => println!("got a range element {}", e), - _ => println!("anything"), -} -``` - -Multiple match patterns may be joined with the `|` operator. An inclusive range -of values may be specified with `..=`. For example: +Multiple match patterns may be joined with the `|` operator: ```rust # let x = 9; @@ -133,34 +75,11 @@ assert_eq!(message, "a few"); ``` -Other forms of [range] \(e.g `..` for an exclusive range, or any range with one or -both endpoints left unspecified) are not supported in matches. The -syntax `...` is also accepted for inclusive ranges in patterns only, for -backwards compatibility. - -Range patterns only work with [`char`] and [numeric types]. A range pattern may -not be a sub-range of another range pattern inside the same `match`. - -Slice patterns can match both arrays of fixed size and slices of dynamic size. -```rust -// Fixed size -let arr = [1, 2, 3]; -match arr { - [1, _, _] => "starts with one", - [a, b, c] => "starts with something else", -}; -``` -```rust -// Dynamic size -let v = vec![1, 2, 3]; -match v[..] { - [a, b] => { /* this arm will not apply because the length doesn't match */ } - [a, b, c] => { /* this arm will apply */ } - _ => { /* this wildcard is required, since we don't know length statically */ } -} -``` +Please notice that the `2..=9` is a [Range Pattern], not a [Range Expression] +and, thus, only those types of ranges supported by range patterns can be used +in match arms. -Finally, match arms can accept *pattern guards* to further refine the +Match arms can accept _match guards_ to further refine the criteria for matching a case. Pattern guards appear after the pattern and consist of a bool-typed expression following the `if` keyword. A pattern guard may refer to the variables bound within the pattern they follow. @@ -201,14 +120,27 @@ Outer attributes are allowed on match arms. The only attributes that have meaning on match arms are [`cfg`], `cold`, and the [lint check attributes]. +[Inner attributes] are allowed directly after the opening brace of the match +expression in the same expression contexts as [attributes on block +expressions]. + [_Expression_]: expressions.html [_BlockExpression_]: expressions/block-expr.html#block-expressions [place expression]: expressions.html#place-expressions-and-value-expressions [value expression]: expressions.html#place-expressions-and-value-expressions -[`char`]: types.html#textual-types -[numeric types]: types.html#numeric-types [_InnerAttribute_]: attributes.html [_OuterAttribute_]: attributes.html [`cfg`]: conditional-compilation.html [lint check attributes]: attributes.html#lint-check-attributes -[range]: expressions/range-expr.html +[Range Expression]: expressions/range-expr.html + +[_Pattern_]: patterns.html +[pattern]: patterns.html +[Identifier Patterns]: patterns.html#identifier-patterns +[Inner attributes]: attributes.html +[Struct Patterns]: patterns.html#struct-patterns +[Tuple Struct Patterns]: patterns.html#tuplestruct-patterns +[Tuple Patterns]: patterns.html#tuple-patterns +[Range Pattern]: patterns.html#range-patterns +[attributes on block expressions]: expressions/block-expr.html#attributes-on-block-expressions +[binding mode]: patterns.html#binding-modes diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/method-call-expr.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/method-call-expr.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/method-call-expr.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/method-call-expr.md 2018-12-04 23:42:54.000000000 +0000 @@ -1,11 +1,15 @@ # Method-call expressions +> **Syntax**\ +> _MethodCallExpression_ :\ +>    [_Expression_] `.` [_PathExprSegment_] `(`[_CallParams_]? `)` + A _method call_ consists of an expression (the *receiver*) followed by a single -dot, an [identifier], and a parenthesized expression-list. Method calls are +dot, an expression path segment, and a parenthesized expression-list. Method calls are resolved to associated [methods] on specific traits, either statically dispatching to a method if the exact `self`-type of the left-hand-side is known, or dynamically dispatching if the left-hand-side expression is an indirect -[trait object](types.html#trait-objects). +[trait object](types/trait-object.html). ```rust let pi: Result = "3.14".parse(); @@ -93,10 +97,12 @@ -[IDENTIFIER]: identifiers.html +[_CallParams_]: expressions/call-expr.html +[_Expression_]: expressions.html +[_PathExprSegment_]: paths.html#paths-in-expressions [visible]: visibility-and-privacy.html -[array]: types.html#array-and-slice-types -[trait objects]: types.html#trait-objects +[array]: types/array.html +[trait objects]: types/trait-object.html [disambiguate call]: expressions/call-expr.html#disambiguating-function-calls [disambiguating function call syntax]: expressions/call-expr.html#disambiguating-function-calls [dereference]: expressions/operator-expr.html#the-dereference-operator diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/operator-expr.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/operator-expr.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/operator-expr.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/operator-expr.md 2018-12-04 23:42:54.000000000 +0000 @@ -85,7 +85,7 @@ >    `*` [_Expression_] The `*` (dereference) operator is also a unary prefix operator. When applied to -a [pointer](types.html#pointer-types) it denotes the pointed-to location. If +a [pointer](types/pointer.html) it denotes the pointed-to location. If the expression is of type `&mut T` and `*mut T`, and is either a local variable, a (nested) field of a local variable or is a mutable [place expression], then the resulting memory location can be assigned to. @@ -312,7 +312,7 @@ > **Syntax**\ > _TypeCastExpression_ :\ ->    [_Expression_] `as` [_PathInExpression_] +>    [_Expression_] `as` [_TypeNoBounds_] A type cast expression is denoted with the binary operator `as`. @@ -345,7 +345,7 @@ | `*T` where `T: Sized` | Numeric type | Pointer to address cast | | Integer type | `*V` where `V: Sized` | Address to pointer cast | | `&[T; n]` | `*const T` | Array to pointer cast | -| [Function pointer](types.html#function-pointer-types) | `*V` where `V: Sized` | Function pointer to pointer cast | +| [Function pointer](types/function-pointer.html) | `*V` where `V: Sized` | Function pointer to pointer cast | | Function pointer | Integer | Function pointer to address cast | | Closure \*\* | Function pointer | Closure to function pointer cast | @@ -446,7 +446,7 @@ [temporary value]: expressions.html#temporary-lifetimes [float-int]: https://github.com/rust-lang/rust/issues/10184 [float-float]: https://github.com/rust-lang/rust/issues/15536 -[`unit` type]: types.html#tuple-types +[`unit` type]: types/tuple.html [_BorrowExpression_]: #borrow-operators [_DereferenceExpression_]: #the-dereference-operator @@ -460,4 +460,4 @@ [_CompoundAssignmentExpression_]: #compound-assignment-expressions [_Expression_]: expressions.html -[_PathInExpression_]: paths.html +[_TypeNoBounds_]: types.html#type-expressions diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/path-expr.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/path-expr.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/path-expr.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/path-expr.md 2018-12-04 23:42:54.000000000 +0000 @@ -1,5 +1,10 @@ # Path expressions +> **Syntax**\ +> _PathExpression_ :\ +>       [_PathInExpression_]\ +>    | [_QualifiedPathInExpression_] + A [path] used as an expression context denotes either a local variable or an item. Path expressions that resolve to local or static variables are [place expressions], other paths are [value expressions]. Using a @@ -19,8 +24,10 @@ let slice_reverse = <[i32]>::reverse; ``` +[_PathInExpression_]: paths.html#paths-in-expressions +[_QualifiedPathInExpression_]: paths.html#qualified-paths [place expressions]: expressions.html#place-expressions-and-value-expressions [value expressions]: expressions.html#place-expressions-and-value-expressions [path]: paths.html [`static mut`]: items/static-items.html#mutable-statics -[`unsafe` block]: expressions/block-expr.html#unsafe-blocks \ No newline at end of file +[`unsafe` block]: expressions/block-expr.html#unsafe-blocks diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/range-expr.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/range-expr.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/range-expr.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/range-expr.md 2018-12-04 23:42:54.000000000 +0000 @@ -21,10 +21,10 @@ > _RangeFullExpr_ :\ >    `..` > -> _RangeExpr_ :\ +> _RangeInclusiveExpr_ :\ >    [_Expression_] `..=` [_Expression_] > -> _RangeToExpr_ :\ +> _RangeToInclusiveExpr_ :\ >    `..=` [_Expression_] The `..` and `..=` operators will construct an object of one of the diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/struct-expr.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/struct-expr.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/struct-expr.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/struct-expr.md 2018-12-04 23:42:54.000000000 +0000 @@ -1,26 +1,35 @@ # Struct expressions -There are several forms of struct expressions. A _struct expression_ consists -of the [path] of a [struct item](items/structs.html), followed by a -brace-enclosed list of zero or more comma-separated name-value pairs, providing -the field values of a new instance of the struct. A field name can be any -[identifier], and is separated from its value expression by a -colon. In the case of a tuple struct the field names are numbers corresponding -to the position of the field. The numbers must be written in decimal, -containing no underscores and with no leading zeros or integer suffix. A value -of a [union](items/unions.html) type can also be created using this syntax, -except that it must specify exactly one field. - -Struct expressions can't be used directly in the head of a [loop] -or an [if], [if let] or [match] expression. But struct expressions can still be -in used inside parentheses, for example. - -A _tuple struct expression_ consists of the path of a struct item, followed by -a parenthesized list of one or more comma-separated expressions (in other -words, the path of a struct item followed by a tuple expression). The struct -item must be a tuple struct item. - -A _unit-like struct expression_ consists only of the path of a struct item. +> **Syntax**\ +> _StructExpression_ :\ +>       _StructExprStruct_\ +>    | _StructExprTuple_\ +>    | _StructExprUnit_ +> +> _StructExprStruct_ :\ +>    [_PathInExpression_] `{` [_InnerAttribute_]\* (_StructExprFields_ | _StructBase_)? `}` +> +> _StructExprFields_ :\ +>    _StructExprField_ (`,` _StructExprField_)\* (`,` _StructBase_ | `,`?) +> +> _StructExprField_ :\ +>       [IDENTIFIER]\ +>    | ([IDENTIFIER] | [TUPLE_INDEX]) `:` [_Expression_] +> +> _StructBase_ :\ +>    `..` [_Expression_] +> +> _StructExprTuple_ :\ +>    [_PathInExpression_] `(`\ +>       [_InnerAttribute_]\*\ +>       ( [_Expression_] (`,` [_Expression_])\* `,`? )?\ +>    `)` +> +> _StructExprUnit_ : [_PathInExpression_] + +A _struct expression_ creates a struct or union value. It consists of a path to a [struct] +or [union] item followed by the values for the fields of the item. There are three forms +of struct expressions: struct, tuple, and unit. The following are examples of struct expressions: @@ -38,8 +47,14 @@ some_fn::(Cookie); ``` -A struct expression forms a new value of the named struct type. Note that for a -given *unit-like* struct type, this will always be the same value. +## Field struct expression + +A struct expression with fields enclosed in curly braces allows you to specify the value +for each individual field in any order. The field name is separated from its value with a +colon. + +A value of a [union] type can also be created using this syntax, except that it must +specify exactly one field. A struct expression can terminate with the syntax `..` followed by an expression to denote a functional update. The expression following `..` (the @@ -48,8 +63,7 @@ same type as the base expression) with the given values for the fields that were explicitly specified and the values in the base expression for all other fields. Just as with all struct expressions, all of the fields of the struct -must be [visible](visibility-and-privacy.html), even those not explicitly -named. +must be [visible], even those not explicitly named. ```rust # struct Point3d { x: i32, y: i32, z: i32 } @@ -57,13 +71,28 @@ Point3d {y: 0, z: 10, .. base}; ``` -## Struct field init shorthand +Struct expressions with curly braces can't be used directly in the head of a [loop] or an +[if], [if let] or [match] expression. However, struct expressions can be in used in these +situations if they are within another expression, for example inside +[parentheses]. + +The field names can be decimal integer values to specify indices for constructing tuple +structs. This can be used with base structs to fill out the remaining indices not +specified: + +```rust +struct Color(u8, u8, u8); +let c1 = Color(0, 0, 0); // Typical way of creating a tuple struct. +let c2 = Color{0: 255, 1: 127, 2: 0}; // Specifying fields by index. +let c3 = Color{1: 0, ..c2}; // Fill out all other fields using a base struct. +``` + +### Struct field init shorthand When initializing a data structure (struct, enum, union) with named (but not numbered) fields, it is allowed to write `fieldname` as a shorthand for `fieldname: fieldname`. This allows a compact syntax with less duplication. - -Example: +For example: ```rust # struct Point3d { x: i32, y: i32, z: i32 } @@ -74,9 +103,51 @@ Point3d { x, y: y_value, z }; ``` +## Tuple struct expression + +A struct expression with fields enclosed in parentheses constructs a tuple struct. Though +it is listed here as a specific expression for completeness, it is equivalent to a [call +expression] to the tuple struct's constructor. For example: + +```rust +struct Position(i32, i32, i32); +Position(0, 0, 0); // Typical way of creating a tuple struct. +let c = Position; // `c` is a function that takes 3 arguments. +let pos = c(8, 6, 7); // Creates a `Position` value. +``` + +## Unit struct expression + +A unit struct expression is just the path to a unit struct item. This refers to the unit +struct's implicit constant of its value. The unit struct value can also be constructed +with a fieldless struct expression. For example: + +```rust +struct Gamma; +let a = Gamma; // Gamma unit value. +let b = Gamma{}; // Exact same value as `a`. +``` + +## Struct expression attributes + +[Inner attributes] are allowed directly after the opening brace or parenthesis +of a struct expression in the same expression contexts as [attributes on block +expressions]. + [IDENTIFIER]: identifiers.html -[path]: paths.html -[loop]: expressions/loop-expr.html -[if]: expressions/if-expr.html#if-expressions +[Inner attributes]: attributes.html +[TUPLE_INDEX]: tokens.html#integer-literals +[_Expression_]: expressions.html +[_InnerAttribute_]: attributes.html +[_PathInExpression_]: paths.html#paths-in-expressions +[attributes on block expressions]: expressions/block-expr.html#attributes-on-block-expressions +[call expression]: expressions/call-expr.html [if let]: expressions/if-expr.html#if-let-expressions +[if]: expressions/if-expr.html#if-expressions +[loop]: expressions/loop-expr.html [match]: expressions/match-expr.html +[parentheses]: http://localhost:3000/expressions/grouped-expr.html +[path]: paths.html +[struct]: items/structs.html +[union]: items/unions.html +[visible]: visibility-and-privacy.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/tuple-expr.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/tuple-expr.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions/tuple-expr.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions/tuple-expr.md 2018-12-04 23:42:54.000000000 +0000 @@ -4,11 +4,13 @@ > **Syntax**\ > _TupleExpression_ :\ ->       `(` `)`\ ->    | `(` ( [_Expression_] `,` )+ [_Expression_]? `)` +>    `(` [_InnerAttribute_]\* _TupleElements_? `)` +> +> _TupleElements_ :\ +>    ( [_Expression_] `,` )+ [_Expression_]? Tuples are written by enclosing zero or more comma-separated expressions in -parentheses. They are used to create [tuple-typed](types.html#tuple-types) +parentheses. They are used to create [tuple-typed](types/tuple.html) values. ```rust @@ -25,13 +27,19 @@ (0); // zero in parentheses ``` +### Tuple expression attributes + +[Inner attributes] are allowed directly after the opening parenthesis of a +tuple expression in the same expression contexts as [attributes on block +expressions]. + ## Tuple indexing expressions > **Syntax**\ > _TupleIndexingExpression_ :\ >    [_Expression_] `.` [TUPLE_INDEX] -[Tuples](types.html#tuple-types) and [struct tuples](items/structs.html) can be +[Tuples](types/tuple.html) and [struct tuples](items/structs.html) can be indexed using the number corresponding to the position of the field. The index must be written as a [decimal literal](tokens.html#integer-literals) with no underscores or suffix. Tuple indexing expressions also differ from field @@ -46,5 +54,8 @@ assert_eq!(unit_x.0, 1.0); ``` +[Inner attributes]: attributes.html [TUPLE_INDEX]: tokens.html#integer-literals [_Expression_]: expressions.html +[_InnerAttribute_]: attributes.html +[attributes on block expressions]: expressions/block-expr.html#attributes-on-block-expressions diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/expressions.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/expressions.md 2018-12-04 23:42:54.000000000 +0000 @@ -2,29 +2,43 @@ > **Syntax**\ > _Expression_ :\ ->       [_LiteralExpression_]\ ->    | [_PathExpression_]\ ->    | [_BlockExpression_]\ ->    | [_OperatorExpression_]\ ->    | [_GroupedExpression_]\ ->    | [_ArrayExpression_]\ ->    | [_IndexExpression_]\ ->    | [_TupleExpression_]\ ->    | [_TupleIndexingExpression_]\ ->    | [_StructExpression_]\ ->    | [_EnumerationVariantExpression_]\ ->    | [_CallExpression_]\ ->    | [_MethodCallExpression_]\ ->    | [_FieldExpression_]\ ->    | [_ClosureExpression_]\ ->    | [_LoopExpression_]\ ->    | [_ContinueExpression_]\ ->    | [_BreakExpression_]\ ->    | [_RangeExpression_]\ ->    | [_IfExpression_]\ ->    | [_IfLetExpression_]\ ->    | [_MatchExpression_]\ ->    | [_ReturnExpression_] +>       _ExpressionWithoutBlock_\ +>    | _ExpressionWithBlock_ +> +> _ExpressionWithoutBlock_ :\ +>    [_OuterAttribute_]\*[†](#expression-attributes)\ +>    (\ +>          [_LiteralExpression_]\ +>       | [_PathExpression_]\ +>       | [_OperatorExpression_]\ +>       | [_GroupedExpression_]\ +>       | [_ArrayExpression_]\ +>       | [_IndexExpression_]\ +>       | [_TupleExpression_]\ +>       | [_TupleIndexingExpression_]\ +>       | [_StructExpression_]\ +>       | [_EnumerationVariantExpression_]\ +>       | [_CallExpression_]\ +>       | [_MethodCallExpression_]\ +>       | [_FieldExpression_]\ +>       | [_ClosureExpression_]\ +>       | [_ContinueExpression_]\ +>       | [_BreakExpression_]\ +>       | [_RangeExpression_]\ +>       | [_ReturnExpression_]\ +>       | [_MacroInvocation_]\ +>    ) +> +> _ExpressionWithBlock_ :\ +>    [_OuterAttribute_]\*[†](#expression-attributes)\ +>    (\ +>          [_BlockExpression_]\ +>       | [_UnsafeBlockExpression_]\ +>       | [_LoopExpression_]\ +>       | [_IfExpression_]\ +>       | [_IfLetExpression_]\ +>       | [_MatchExpression_]\ +>    ) An expression may have two roles: it always produces a *value*, and it may have *effects* (otherwise known as "side effects"). An expression *evaluates to* a @@ -143,12 +157,12 @@ evaluates to that location instead, except if promoted to `'static`. Promotion of a value expression to a `'static` slot occurs when the expression could be written in a constant, borrowed, and dereferencing that borrow where the -expression was the originally written, without changing the runtime behavior. -That is, the promoted expression can be evaluated at compile-time and the -resulting value does not contain [interior mutability] or [destructors] (these -properties are determined based on the value where possible, e.g. `&None` -always has the type `&'static Option<_>`, as it contains nothing disallowed). -Otherwise, the lifetime of temporary values is typically +expression was originally written, without changing the runtime behavior. That +is, the promoted expression can be evaluated at compile-time and the resulting +value does not contain [interior mutability] or [destructors] (these properties +are determined based on the value where possible, e.g. `&None` always has the +type `&'static Option<_>`, as it contains nothing disallowed). Otherwise, the +lifetime of temporary values is typically - the innermost enclosing statement; the tail expression of a block is considered part of the statement that encloses the block, or @@ -229,49 +243,37 @@ * Operands of [comparison]. * Left operands of the [compound assignment]. -## Constant expressions - -Certain types of expressions can be evaluated at compile time. These are called -_constant expressions_. Certain places, such as in -[constants](items/constant-items.html) and [statics](items/static-items.html), -require a constant expression, and are always evaluated at compile time. In -other places, such as in [`let` statements](statements.html#let-statements), -constant expressions may be evaluated at compile time. If errors, such as out -of bounds [array indexing] or [overflow] occurs, -then it is a compiler error if the value must be evaluated at compile time, -otherwise it is just a warning, but the code will most likely panic when run. - -The following expressions are constant expressions, so long as any operands are -also constant expressions and do not cause any [`Drop::drop`][destructors] calls -to be ran. - -* [Literals]. -* [Paths] to [functions](items/functions.html) and constants. - Recursively defining constants is not allowed. -* [Tuple expressions]. -* [Array expressions]. -* [Struct] expressions. -* [Enum variant] expressions. -* [Block expressions], including `unsafe` blocks, which only contain items and - possibly a constant tail expression. -* [Field] expressions. -* Index expressions, [array indexing] or [slice] with a `usize`. -* [Range expressions]. -* [Closure expressions] which don't capture variables from the environment. -* Built in [negation], [arithmetic, logical], [comparison] or [lazy boolean] - operators used on integer and floating point types, `bool` and `char`. -* Shared [borrow]s, except if applied to a type with [interior mutability]. -* The [dereference operator]. -* [Grouped] expressions. -* [Cast] expressions, except pointer to address and - function pointer to address casts. - ## Overloading Traits Many of the following operators and expressions can also be overloaded for other types using traits in `std::ops` or `std::cmp`. These traits also exist in `core::ops` and `core::cmp` with the same names. +## Expression Attributes + +[Outer attributes][_OuterAttribute_] before an expression are allowed only in +a few specific cases: + +* Before an expression used as a [statement]. +* Elements of [array expressions], [tuple expressions], [call expressions], + tuple-style [struct] and [enum variant] expressions. + +* The tail expression of [block expressions]. + + +They are never allowed before: + +* [`if`][_IfExpression_] and [`if let`][_IfLetExpression_] expressions. +* [Range][_RangeExpression_] expressions. +* Binary operator expressions ([_ArithmeticOrLogicalExpression_], + [_ComparisonExpression_], [_LazyBooleanExpression_], [_TypeCastExpression_], + [_AssignmentExpression_], [_CompoundAssignmentExpression_]). + + [block expressions]: expressions/block-expr.html [call expressions]: expressions/call-expr.html [closure expressions]: expressions/closure-expr.html @@ -313,16 +315,23 @@ [let]: statements.html#let-statements [let statement]: statements.html#let-statements [Mutable `static` items]: items/static-items.html#mutable-statics -[slice]: types.html#array-and-slice-types +[const contexts]: const_eval.html +[slice]: types/slice.html +[statement]: statements.html [static variables]: items/static-items.html [Temporary values]: #temporary-lifetimes [Variables]: variables.html + +[_ArithmeticOrLogicalExpression_]: expressions/operator-expr.html#arithmetic-and-logical-binary-operators [_ArrayExpression_]: expressions/array-expr.html +[_AssignmentExpression_]: expressions/operator-expr.html#assignment-expressions [_BlockExpression_]: expressions/block-expr.html [_BreakExpression_]: expressions/loop-expr.html#break-expressions [_CallExpression_]: expressions/call-expr.html [_ClosureExpression_]: expressions/closure-expr.html +[_ComparisonExpression_]: expressions/operator-expr.html#comparison-operators +[_CompoundAssignmentExpression_]: expressions/operator-expr.html#compound-assignment-expressions [_ContinueExpression_]: expressions/loop-expr.html#continue-expressions [_EnumerationVariantExpression_]: expressions/enum-variant-expr.html [_FieldExpression_]: expressions/field-expr.html @@ -330,14 +339,19 @@ [_IfExpression_]: expressions/if-expr.html#if-expressions [_IfLetExpression_]: expressions/if-expr.html#if-let-expressions [_IndexExpression_]: expressions/array-expr.html#array-and-slice-indexing-expressions +[_LazyBooleanExpression_]: expressions/operator-expr.html#lazy-boolean-operators [_LiteralExpression_]: expressions/literal-expr.html [_LoopExpression_]: expressions/loop-expr.html +[_MacroInvocation_]: macros.html#macro-invocation [_MatchExpression_]: expressions/match-expr.html [_MethodCallExpression_]: expressions/method-call-expr.html [_OperatorExpression_]: expressions/operator-expr.html +[_OuterAttribute_]: attributes.html [_PathExpression_]: expressions/path-expr.html [_RangeExpression_]: expressions/range-expr.html [_ReturnExpression_]: expressions/return-expr.html [_StructExpression_]: expressions/struct-expr.html [_TupleExpression_]: expressions/tuple-expr.html [_TupleIndexingExpression_]: expressions/tuple-expr.html#tuple-indexing-expressions +[_TypeCastExpression_]: expressions/operator-expr.html#type-cast-expressions +[_UnsafeBlockExpression_]: expressions/block-expr.html#unsafe-blocks diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/glossary.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/glossary.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/glossary.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/glossary.md 2018-12-04 23:42:54.000000000 +0000 @@ -134,7 +134,7 @@ [enums]: items/enumerations.html [structs]: items/structs.html [unions]: items/unions.html -[trait objects]: types.html#trait-objects +[trait objects]: types/trait-object.html [implementations]: items/implementations.html [traits]: items/traits.html [object safety]: items/traits.html#object-safety diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/interior-mutability.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/interior-mutability.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/interior-mutability.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/interior-mutability.md 2018-12-04 23:42:54.000000000 +0000 @@ -20,7 +20,7 @@ accessed with atomic operations, allowing the value to be shared and mutated across threads. -[shared reference]: types.html#shared-references- +[shared reference]: types/pointer.html#shared-references- [ub]: behavior-considered-undefined.html [`std::mem::transmute`]: ../std/mem/fn.transmute.html [`std::cell::UnsafeCell`]: ../std/cell/struct.UnsafeCell.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/introduction.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/introduction.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/introduction.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/introduction.md 2018-12-04 23:42:54.000000000 +0000 @@ -77,7 +77,13 @@ term is used outside of that chapter, it is usually a link to the section that has this definition. - An *example term* is an example of a term beind defined. + An *example term* is an example of a term being defined. + +* Differences in the language by which edition the crate is compiled under are + in a blockquote that start with the words "Edition Differences:" in **bold**. + + > **Edition Differences**: In the 2015 edition, this syntax is valid that is + > disallowed as of the 2018 edition. * Notes that contain useful information about the state of the book or point out useful, but mostly out of scope, information are in blockquotes that start diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/associated-items.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/associated-items.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/associated-items.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/associated-items.md 2018-12-04 23:42:54.000000000 +0000 @@ -29,7 +29,7 @@ function definition. It is written as a function item, except the function body is replaced with a `;`. -The identifier if the name of the function. The generics, parameter list, +The identifier is the name of the function. The generics, parameter list, return type, and where clause of the associated function must be the same as the associated function declarations's. @@ -79,17 +79,31 @@ ### Methods +> _Method_ :\ +>    [_FunctionQualifiers_] `fn` [IDENTIFIER] [_Generics_]?\ +>       `(` _SelfParam_ (`,` [_FunctionParam_])\* `,`? `)`\ +>       [_FunctionReturnType_]? [_WhereClause_]?\ +>       [_BlockExpression_] +> +> _SelfParam_ :\ +>       (`&` | `&` [_Lifetime_])? `mut`? `self`\ +>    | `mut`? `self` (`:` [_Type_])? + Associated functions whose first parameter is named `self` are called *methods* and may be invoked using the [method call operator], for example, `x.foo()`, as well as the usual function call notation. -The `self` parameter must have one of the following types. As a result, the -following shorthands may be used to declare `self`: - -* `self` -> `self: Self` -* `&'lifetime self` -> `self: &'lifetime Self` -* `&'lifetime mut self` -> `self: &'lifetime mut Self` -* `self : Box` (no shorthand) +If the type of the `self` parameter is specified, it is limited to the type +being implemented (or `Self`), or a reference or mutable reference to the +type, or a boxed value of the type being implemented (such as `Box`). +Shorthand syntax can be used without specifying a type, which have the +following equivalents: + +Shorthand | Equivalent +----------------------|----------- +`self` | `self: Self` +`&'lifetime self` | `self: &'lifetime Self` +`&'lifetime mut self` | `self: &'lifetime mut Self` > Note: Lifetimes can be and usually are elided with this shorthand. @@ -99,7 +113,7 @@ # type Surface = i32; # type BoundingBox = i32; trait Shape { - fn draw(&self, Surface); + fn draw(&self, surface: Surface); fn bounding_box(&self) -> BoundingBox; } ``` @@ -112,7 +126,7 @@ # type Surface = i32; # type BoundingBox = i32; # trait Shape { -# fn draw(&self, Surface); +# fn draw(&self, surface: Surface); # fn bounding_box(&self) -> BoundingBox; # } # @@ -134,6 +148,10 @@ let bounding_box = circle_shape.bounding_box(); ``` +> **Edition Differences**: In the 2015 edition, it is possible to declare trait +> methods with anonymous parameters (e.g. `fn foo(u8)`). This is deprecated and +> an error as of the 2018 edition. All parameters must have an argument name. + ## Associated Types *Associated types* are [type aliases] associated with another type. Associated @@ -191,7 +209,7 @@ trait Container { type E; fn empty() -> Self; - fn insert(&mut self, Self::E); + fn insert(&mut self, elem: Self::E); } ``` @@ -203,7 +221,7 @@ # trait Container { # type E; # fn empty() -> Self; -# fn insert(&mut self, Self::E); +# fn insert(&mut self, elem: Self::E); # } impl Container for Vec { type E = T; @@ -268,18 +286,26 @@ } ``` +[_BlockExpression_]: expressions/block-expr.html +[_FunctionParam_]: items/functions.html +[_FunctionQualifiers_]: items/functions.html +[_FunctionReturnType_]: items/functions.html +[_Generics_]: items/generics.html +[_Lifetime_]: trait-bounds.html +[_Type_]: types.html#type-expressions +[_WhereClause_]: items/generics.html#where-clauses [trait]: items/traits.html [traits]: items/traits.html [type aliases]: items/type-aliases.html [inherent implementations]: items/implementations.html#inherent-implementations [identifier]: identifiers.html -[trait object]: types.html#trait-objects +[trait object]: types/trait-object.html [implementations]: items/implementations.html -[type]: types.html +[type]: types.html#type-expressions [constants]: items/constant-items.html [constant item]: items/constant-items.html [functions]: items/functions.html -[function item]: types.html#function-item-types +[function item]: types/function-item.html [method call operator]: expressions/method-call-expr.html [block]: expressions/block-expr.html [path]: paths.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/constant-items.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/constant-items.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/constant-items.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/constant-items.md 2018-12-04 23:42:54.000000000 +0000 @@ -1,7 +1,7 @@ # Constant items -> **Syntax** -> _ConstantItem_ : +> **Syntax**\ +> _ConstantItem_ :\ >    `const` [IDENTIFIER] `:` [_Type_] `=` [_Expression_] `;` A *constant item* is a named _[constant value]_ which is not associated with a @@ -60,9 +60,9 @@ } ``` -[constant value]: expressions.html#constant-expressions +[constant value]: const_eval.html#constant-expressions [static lifetime elision]: lifetime-elision.html#static-lifetime-elision [`Drop`]: special-types-and-traits.html#drop [IDENTIFIER]: identifiers.html -[_Type_]: types.html +[_Type_]: types.html#type-expressions [_Expression_]: expressions.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/enumerations.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/enumerations.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/enumerations.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/enumerations.md 2018-12-04 23:42:54.000000000 +0000 @@ -68,10 +68,10 @@ These enumerations can be cast to integer types with the `as` operator by a [numeric cast]. The enumeration can optionally specify which integer each -discriminant gets by following the variant name with `=` and then an integer -literal. If the first variant in the declaration is unspecified, then it is set -to zero. For every unspecified discriminant, it is set to one higher than the -previous variant in the declaration. +discriminant gets by following the variant name with `=` followed by a [constant +expression]. If the first variant in the declaration is unspecified, then it is +set to zero. For every other unspecified discriminant, it is set to one higher +than the previous variant in the declaration. ```rust enum Foo { @@ -137,10 +137,11 @@ [_Expression_]: expressions.html [_TupleFields_]: items/structs.html [_StructFields_]: items/structs.html -[enumerated type]: types.html#enumerated-types +[enumerated type]: types/enum.html [`mem::discriminant`]: ../std/mem/fn.discriminant.html [numeric cast]: expressions/operator-expr.html#semantics [`repr` attribute]: attributes.html#ffi-attributes +[constant expression]: const_eval.html#constant-expressions [default representation]: type-layout.html#the-default-representation [primitive representation]: type-layout.html#primitive-representations [`C` representation]: type-layout.html#the-c-representation diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/external-blocks.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/external-blocks.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/external-blocks.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/external-blocks.md 2018-12-04 23:42:54.000000000 +0000 @@ -1,12 +1,42 @@ # External blocks +> **Syntax**\ +> _ExternBlock_ :\ +>    `extern` [_Abi_]? `{`\ +>       [_InnerAttribute_]\*\ +>       _ExternalItem_\*\ +>    `}` +> +> _ExternalItem_ :\ +>    [_OuterAttribute_]\*\ +>    [_Visibility_]?\ +>    ( _ExternalStaticItem_ | _ExternalFunctionItem_ ) +> +> _ExternalStaticItem_ :\ +>    `static` `mut`? [IDENTIFIER] `:` [_Type_] `;` +> +> _ExternalFunctionItem_ :\ +>    `fn` [IDENTIFIER] [_Generics_]?\ +>    `(` _NamedFunctionParameters_? | _NamedFunctionParametersWithVariadics_ ) `)`\ +>    [_FunctionReturnType_]? [_WhereClause_]? `;` +> +> _NamedFunctionParameters_ :\ +>    _NamedFunctionParam_ ( `,` _NamedFunctionParam_ )\* `,`? +> +> _NamedFunctionParam_ :\ +>    ( [IDENTIFIER] | `_` ) `:` [_Type_] +> +> _NamedFunctionParametersWithVariadics_ :\ +>    ( _NamedFunctionParam_ `,` )\* _NamedFunctionParam_ `,` `...` + External blocks form the basis for Rust's foreign function interface. Declarations in an external block describe symbols in external, non-Rust libraries. Functions within external blocks are declared in the same way as other Rust functions, with the exception that they may not have a body and are instead -terminated by a semicolon. +terminated by a semicolon. Patterns are not allowed in parameters, only +[IDENTIFIER] or `_` may be used. Functions within external blocks may be called by Rust code, just like functions defined in Rust. The Rust compiler automatically translates between @@ -23,8 +53,6 @@ A number of [attributes] control the behavior of external blocks. -[attributes]: attributes.html#ffi-attributes - By default external blocks assume that the library they are calling uses the standard C ABI on the specific platform. Other ABIs may be specified using an `abi` string, as shown here: @@ -73,11 +101,29 @@ extern { } ``` -The type of a function declared in an extern block is `extern "abi" fn(A1, ..., -An) -> R`, where `A1...An` are the declared types of its arguments and `R` is -the declared return type. +A function declared in an extern block is implicitly `unsafe`. When coerced to +a function pointer, a function declared in an extern block has type `unsafe +extern "abi" for<'l1, ..., 'lm> fn(A1, ..., An) -> R`, where `'l1`, ... `'lm` +are its lifetime parameters, `A1`, ..., `An` are the declared types of its +parameters and `R` is the declared return type. + +It is `unsafe` to access a static item declared in an extern block, whether or +not it's mutable. It is valid to add the `link` attribute on an empty extern block. You can use this to satisfy the linking requirements of extern blocks elsewhere in your code (including upstream crates) instead of adding the attribute to each extern block. + +[IDENTIFIER]: identifiers.html +[_Abi_]: items/functions.html +[_FunctionParam_]: items/functions.html +[_FunctionParameters_]: items/functions.html +[_FunctionReturnType_]: items/functions.html +[_Generics_]: items/generics.html +[_InnerAttribute_]: attributes.html +[_OuterAttribute_]: attributes.html +[_Type_]: types.html#type-expressions +[_Visibility_]: visibility-and-privacy.html +[_WhereClause_]: items/generics.html#where-clauses +[attributes]: attributes.html#ffi-attributes diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/extern-crates.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/extern-crates.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/extern-crates.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/extern-crates.md 2018-12-04 23:42:54.000000000 +0000 @@ -5,8 +5,8 @@ >    `extern` `crate` [IDENTIFIER] (`as` [IDENTIFIER])? `;` An _`extern crate` declaration_ specifies a dependency on an external crate. -The external crate is then bound into the declaring scope as the `ident` -provided in the `extern_crate_decl`. +The external crate is then bound into the declaring scope as the [identifier] +provided in the `extern crate` declaration. The external crate is resolved to a specific `soname` at compile time, and a runtime linkage requirement to that `soname` is passed to the linker for @@ -14,7 +14,7 @@ compiler's library path and matching the optional `crateid` provided against the `crateid` attributes that were declared on the external crate when it was compiled. If no `crateid` is provided, a default `name` attribute is assumed, -equal to the `ident` given in the `extern_crate_decl`. +equal to the [identifier] given in the `extern crate` declaration. Three examples of `extern crate` declarations: @@ -38,6 +38,51 @@ extern crate hello_world; // hyphen replaced with an underscore ``` -[RFC 940]: https://github.com/rust-lang/rfcs/blob/master/text/0940-hyphens-considered-harmful.md +## Extern Prelude + +External crates provided to the compiler are added to the "extern prelude" +which exposes the crate names into lexical scope of every module without the +need for specifying `extern crate`. + +> **Edition Differences**: In the 2015 edition, crates in the extern prelude +> cannot be referenced via [use declarations], so it is generally standard +> practice to include `extern crate` declarations to bring them into scope. +> +> Beginning in the 2018 edition, [use declarations] can reference crates in +> the extern prelude, so it is considered unidiomatic to use `extern crate`. + +> **Note**: Additional crates that ship with `rustc`, such as [`proc_macro`], +> [`alloc`], and [`test`], currently aren't available in the extern prelude +> and must be brought into scope with an `extern crate` declaration, even in +> the 2018 edition. `use` paths must reference the `extern crate` item (such +> as using [`crate::`] or [`self::`] path prefixes). +> +> ```rust +> extern crate proc_macro; +> // Cannot reference `proc_macro` directly because it is not in the extern prelude. +> // use proc_macro::TokenStream; +> // Instead, you must reference the item in scope from the `extern crate` +> // declaration. +> use self::proc_macro::TokenStream; +> ``` + + [IDENTIFIER]: identifiers.html +[RFC 940]: https://github.com/rust-lang/rfcs/blob/master/text/0940-hyphens-considered-harmful.md +[`alloc`]: https://doc.rust-lang.org/alloc/ +[`crate::`]: paths.html#crate +[`proc_macro`]: https://doc.rust-lang.org/proc_macro/ +[`self::`]: paths.html#self +[`test`]: https://doc.rust-lang.org/test/ +[use declarations]: items/use-declarations.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/functions.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/functions.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/functions.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/functions.md 2018-12-04 23:42:54.000000000 +0000 @@ -1,5 +1,27 @@ # Functions +> **Syntax**\ +> _Function_ :\ +>    _FunctionQualifiers_ `fn` [IDENTIFIER] [_Generics_]?\ +>       `(` _FunctionParameters_? `)`\ +>       _FunctionReturnType_? [_WhereClause_]?\ +>       [_BlockExpression_] +> +> _FunctionQualifiers_ :\ +>    `const`? `unsafe`? (`extern` _Abi_?)? +> +> _Abi_ :\ +>    [STRING_LITERAL] | [RAW_STRING_LITERAL] +> +> _FunctionParameters_ :\ +>    _FunctionParam_ (`,` _FunctionParam_)\* `,`? +> +> _FunctionParam_ :\ +>    [_Pattern_] `:` [_Type_] +> +> _FunctionReturnType_ :\ +>    `->` [_Type_] + A _function_ consists of a [block], along with a name and a set of parameters. Other than a name, all these are optional. Functions are declared with the keyword `fn`. Functions may declare a set of *input* [*variables*][variables] @@ -18,7 +40,7 @@ } ``` -As with `let` bindings, function arguments are irrefutable patterns, so any +As with `let` bindings, function arguments are irrefutable [patterns], so any pattern that is valid in a let binding is also valid as an argument: ```rust @@ -92,7 +114,7 @@ blocks allow Rust code to call foreign code, extern functions with bodies defined in Rust code _can be called by foreign code_. They are defined in the same way as any other Rust function, except that they have the `extern` -modifier. +qualifier. ```rust // Declares an extern fn, the ABI defaults to "C" @@ -115,12 +137,64 @@ of an extern function will cause the process to abort. In LLVM, this is implemented by executing an illegal instruction. +## Const functions + +Functions qualified with the `const` keyword are const functions. _Const +functions_ can be called from within [const contexts]. When called from a const +context, the function is interpreted by the compiler at compile time. The +interpretation happens in the environment of the compilation target and not the +host. So `usize` is `32` bits if you are compiling against a `32` bit system, +irrelevant of whether you are building on a `64` bit or a `32` bit system. + +If a const function is called outside a [const context], it is indistinguishable +from any other function. You can freely do anything with a const function that +you can do with a regular function. + +Const functions have various restrictions to makes sure that they can't be +evaluated at compile-time. It is, for example, not possible to write a random +number generator as a const function. Calling a const function at compile-time +will always yield the same result as calling it at runtime, even when called +multiple times. There's one exception to this rule: if you are doing complex +floating point operations in extreme situations, then you might get (very +slightly) different results. It is advisable to not make array lengths and enum +discriminants depend on floating point computations. + +Exhaustive list of permitted structures in const functions: + +> **Note**: this list is more restrictive than what you can write in +> regular constants + +* Type parameters where the parameters only have any [trait bounds] + of the following kind: + * lifetimes + * `Sized` or [`?Sized`] + + This means that ``, `` and `` + are all permitted. + + This rule also applies to type parameters of impl blocks that + contain const methods + +* Arithmetic and comparison operators on integers +* All boolean operators except for `&&` and `||` which are banned since + they are short-circuiting. +* Any kind of aggregate constructor (array, `struct`, `enum`, tuple, ...) +* Calls to other *safe* const functions (whether by function call or method call) +* Index expressions on arrays and slices +* Field accesses on structs and tuples +* Reading from constants (but not statics, not even taking a reference to a static) +* `&` and `*` (only dereferencing of references, not raw pointers) +* Casts except for raw pointer to integer casts +* `const unsafe fn` is allowed, but the body must consist of safe operations + only and you won't be able to call the `const unsafe fn` from within another + const function even if you use `unsafe` + ## Attributes on functions [Outer attributes][attributes] are allowed on functions. [Inner attributes][attributes] are allowed directly after the `{` inside its [block]. -This example shows an inner attribute on a function. The function will only be +This example shows an inner attribute on a function. The function will only be available while running tests. ``` @@ -135,15 +209,26 @@ The attributes that have meaning on a function are [`cfg`], [`deprecated`], [`doc`], `export_name`, `link_section`, `no_mangle`, [the lint check attributes], [`must_use`], [the procedural macro attributes], [the testing -attributes], and [the optimization hint -attributes]. +attributes], and [the optimization hint attributes]. Functions also accept +attributes macros. +[IDENTIFIER]: identifiers.html +[RAW_STRING_LITERAL]: tokens.html#raw-string-literals +[STRING_LITERAL]: tokens.html#string-literals +[_BlockExpression_]: expressions/block-expr.html +[_Generics_]: items/generics.html +[_InnerAttribute_]: attributes.html +[_Pattern_]: patterns.html +[_Statement_]: statements.html +[_Type_]: types.html#type-expressions +[_WhereClause_]: items/generics.html#where-clauses +[const contexts]: const_eval.html [external blocks]: items/external-blocks.html [path]: paths.html [block]: expressions/block-expr.html [variables]: variables.html -[type]: types.html -[*function item type*]: types.html#function-item-types +[type]: types.html#type-expressions +[*function item type*]: types/function-item.html [Trait]: items/traits.html [attributes]: attributes.html [`cfg`]: conditional-compilation.html @@ -153,4 +238,7 @@ [the optimization hint attributes]: attributes.html#optimization-hints [`deprecated`]: attributes.html#deprecation [`doc`]: attributes.html#documentation -[`must_use`]: attributes.html#must_use \ No newline at end of file +[`must_use`]: attributes.html#must_use +[patterns]: patterns.html +[`?Sized`]: trait-bounds.html#sized +[trait bounds]: trait-bounds.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/generics.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/generics.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/generics.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/generics.md 2018-12-04 23:42:54.000000000 +0000 @@ -12,13 +12,13 @@ >    ( _LifetimeParam_ `,` )\* _LifetimeParam_? > > _LifetimeParam_ :\ ->    [_OuterAttribute_]? [LIFETIME_OR_LABEL] `:` [_LifetimeBounds_]? +>    [_OuterAttribute_]? [LIFETIME_OR_LABEL] ( `:` [_LifetimeBounds_] )? > > _TypeParams_:\ ->    ( _TypeParam_ `,` )\* _TypeParam_ ? +>    ( _TypeParam_ `,` )\* _TypeParam_? > > _TypeParam_ :\ ->    [_OuterAttribute_]? [IDENTIFIER] ( `:` [_TypeParamBounds_] )? ( `=` [_Type_] )? +>    [_OuterAttribute_]? [IDENTIFIER] ( `:` [_TypeParamBounds_]? )? ( `=` [_Type_] )? Functions, type aliases, structs, enumerations, unions, traits and implementations may be *parameterized* by types and lifetimes. These parameters @@ -106,20 +106,16 @@ [_LifetimeBounds_]: trait-bounds.html [_Lifetime_]: trait-bounds.html [_OuterAttribute_]: attributes.html -[_Type_]: types.html +[_Type_]: types.html#type-expressions [_TypeParamBounds_]: trait-bounds.html -[arrays]: types.html#array-and-slice-types -[function pointers]: types.html#function-pointer-types -[references]: types.html#shared-references- -[raw pointers]: types.html#raw-pointers-const-and-mut +[arrays]: types/array.html +[function pointers]: types/function-pointer.html +[references]: types/pointer.html#shared-references- +[raw pointers]: types/pointer.html#raw-pointers-const-and-mut [`Clone`]: special-types-and-traits.html#clone [`Copy`]: special-types-and-traits.html#copy [`Sized`]: special-types-and-traits.html#sized -[tuples]: types.html#tuple-types -[trait object]: types.html#trait-objects +[tuples]: types/tuple.html +[trait object]: types/trait-object.html [attributes]: attributes.html - -[path]: ../paths.html -[Trait]: traits.html#trait-bounds -[_TypePath_]: paths.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/implementations.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/implementations.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/implementations.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/implementations.md 2018-12-04 23:42:54.000000000 +0000 @@ -1,5 +1,36 @@ # Implementations +> **Syntax**\ +> _Implementation_ :\ +>    _InherentImpl_ | _TraitImpl_ +> +> _InherentImpl_ :\ +>    `impl` [_Generics_] [_Type_] [_WhereClause_]? `{`\ +>       [_InnerAttribute_]\*\ +>       _InherentImplItem_\*\ +>    `}` +> +> _InherentImplItem_ :\ +>    [_OuterAttribute_]\* (\ +>          [_MacroInvocationSemi_]\ +>       | ( [_Visibility_]? ( [_ConstantItem_] | [_Function_] | [_Method_] ) )\ +>    ) +> +> _TraitImpl_ :\ +>    `unsafe`? `impl` [_Generics_] `!`? +> [_TypePath_] `for` [_Type_]\ +>    [_WhereClause_]?\ +>    `{`\ +>       [_InnerAttribute_]\*\ +>       _TraitImplItem_\*\ +>    `}` +> +> _TraitImplItem_ :\ +>    [_OuterAttribute_]\* (\ +>          [_MacroInvocationSemi_]\ +>       | ( [_Visibility_]? ( [_TypeAlias_] | [_ConstantItem_] | [_Function_] | [_Method_] ) )\ +>    ) + An _implementation_ is an item that associates items with an _implementing type_. Implementations are defined with the keyword `impl` and contain functions that belong to an instance of the type that is being implemented or to the @@ -59,6 +90,9 @@ type followed by `as` followed by a path to the trait followed by `>` as a path component followed by the associated item's path component. +[Unsafe traits] require the trait implementation to begin with the `unsafe` +keyword. + ```rust # #[derive(Copy, Clone)] # struct Point {x: f64, y: f64}; @@ -143,9 +177,23 @@ meaning here are [`cfg`], [`deprecated`], [`doc`], and [the lint check attributes]. +[IDENTIFIER]: identifiers.html +[_ConstantItem_]: items/constant-items.html +[_Function_]: items/functions.html +[_Generics_]: items/generics.html +[_InnerAttribute_]: attributes.html +[_MacroInvocationSemi_]: macros.html#macro-invocation +[_Method_]: items/associated-items.html#methods +[_OuterAttribute_]: attributes.html +[_TypeAlias_]: items/type-aliases.html +[_TypePath_]: paths.html#paths-in-types +[_Type_]: types.html#type-expressions +[_Visibility_]: visibility-and-privacy.html +[_WhereClause_]: items/generics.html#where-clauses [trait]: items/traits.html [attributes]: attributes.html [`cfg`]: conditional-compilation.html [`deprecated`]: attributes.html#deprecation [`doc`]: attributes.html#documentation [the lint check attributes]: attributes.html#lint-check-attributes +[Unsafe traits]: items/traits.html#unsafe-traits diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/modules.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/modules.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/modules.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/modules.md 2018-12-04 23:42:54.000000000 +0000 @@ -1,6 +1,6 @@ # Modules -> **Syntax:**\ +> **Syntax:**\ > _Module_ :\ >       `mod` [IDENTIFIER] `;`\ >    | `mod` [IDENTIFIER] `{`\ @@ -21,15 +21,15 @@ type Complex = (f64, f64); fn sin(f: f64) -> f64 { /* ... */ -# panic!(); +# unimplemented!(); } fn cos(f: f64) -> f64 { /* ... */ -# panic!(); +# unimplemented!(); } fn tan(f: f64) -> f64 { /* ... */ -# panic!(); +# unimplemented!(); } } ``` @@ -40,38 +40,114 @@ module in scope, or vice versa. Items brought into scope with `use` also have this restriction. -A module without a body is loaded from an external file, by default with the -same name as the module, plus the `.rs` extension. When a nested submodule is -loaded from an external file, it is loaded from a subdirectory path that -mirrors the module hierarchy. +## Module Source Filenames + +A module without a body is loaded from an external file. When the module does +not have a `path` attribute, the path to the file mirrors the logical [module +path]. Ancestor module path components are directories, and the module's +contents are in a file with the name of the module plus the `.rs` extension. +For example, the following module structure can have this corresponding +filesystem structure: + +Module Path | Filesystem Path | File Contents +------------------------- | --------------- | ------------- +`crate` | `lib.rs` | `mod util;` +`crate::util` | `util.rs` | `mod config;` +`crate::util::config` | `util/config.rs` | + +Module filenames may also be the name of the module as a directory with the +contents in a file named `mod.rs` within that directory. The above example can +alternately be expressed with `crate::util`'s contents in a file named +`util/mod.rs`. It is not allowed to have both `util.rs` and `util/mod.rs`. + +> **Note**: Previous to `rustc` 1.30, using `mod.rs` files was the way to load +> a module with nested children. It is encouraged to use the new naming +> convention as it is more consistent, and avoids having many files named +> `mod.rs` within a project. + +### `path` Attribute + +The directories and files used for loading external file modules can be +influenced with the `path` attribute. + +For `path` attributes on modules not inside inline module blocks, the file +path is relative to the directory the source file is located. For example, the +following code snippet would use the paths shown based on where it is located: ```rust,ignore -// Load the `vec` module from `vec.rs` -mod vec; +#[path = "foo.rs"] +mod c; +``` -mod thread { - // Load the `local_data` module from `thread/local_data.rs` - // or `thread/local_data/mod.rs`. - mod local_data; +Source File | `c`'s File Location | `c`'s Module Path +-------------- | ------------------- | ---------------------- +`src/a/b.rs` | `src/a/foo.rs` | `crate::a::b::c` +`src/a/mod.rs` | `src/a/foo.rs` | `crate::a::c` + +For `path` attributes inside inline module blocks, the relative location of +the file path depends on the kind of source file the `path` attribute is +located in. "mod-rs" source files are root modules (such as `lib.rs` or +`main.rs`) and modules with files named `mod.rs`. "non-mod-rs" source files +are all other module files. Paths for `path` attributes inside inline module +blocks in a mod-rs file are relative to the directory of the mod-rs file +including the inline module components as directories. For non-mod-rs files, +it is the same except the path starts with a directory with the name of the +non-mod-rs module. For example, the following code snippet would use the paths +shown based on where it is located: + +```rust,ignore +mod inline { + #[path = "other.rs"] + mod inner; } ``` -The directories and files used for loading external file modules can be -influenced with the `path` attribute. +Source File | `inner`'s File Location | `inner`'s Module Path +-------------- | --------------------------| ---------------------------- +`src/a/b.rs` | `src/a/b/inline/other.rs` | `crate::a::b::inline::inner` +`src/a/mod.rs` | `src/a/inline/other.rs` | `crate::a::inline::inner` + +An example of combining the above rules of `path` attributes on inline modules +and nested modules within (applies to both mod-rs and non-mod-rs files): ```rust,ignore #[path = "thread_files"] mod thread { - // Load the `local_data` module from `thread_files/tls.rs` + // Load the `local_data` module from `thread_files/tls.rs` relative to + // this source file's directory. #[path = "tls.rs"] mod local_data; } ``` -[IDENTIFIER]: identifiers.html +## Prelude Items -[_InnerAttribute_]: attributes.html -[_OuterAttribute_]: attributes.html +Modules implicitly have some names in scope. These name are to built-in types, +macros imported with `#[macro_use]` on an extern crate, and by the crate's +[prelude]. These names are all made of a single identifier. These names are not +part of the module, so for example, any name `name`, `self::name` is not a +valid path. The names added by the [prelude] can be removed by placing the +`no_implicit_prelude` [attribute] onto the module. + +## Attributes on Modules + +Modules, like all items, accept outer attributes. They also accept inner +attributes: either after `{` for a module with a body, or at the beginning of the +source file, after the optional BOM and shebang. + +The built-in attributes that have meaning on a function are [`cfg`], +[`deprecated`], [`doc`], [the lint check attributes], `path`, and +`no_implicit_prelude`. Modules also accept macro attributes. +[_InnerAttribute_]: attributes.html [_Item_]: items.html +[_OuterAttribute_]: attributes.html +[`cfg`]: conditional-compilation.html +[`deprecated`]: attributes.html#deprecation +[`doc`]: attributes.html#documentation +[IDENTIFIER]: identifiers.html +[attribute]: attributes.html [items]: items.html +[module path]: paths.html +[prelude]: crates-and-source-files.html#preludes-and-no_std +[the lint check attributes]: attributes.html#lint-check-attributes diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/static-items.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/static-items.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/static-items.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/static-items.md 2018-12-04 23:42:54.000000000 +0000 @@ -70,8 +70,8 @@ [constant]: items/constant-items.html [`drop`]: destructors.html -[constant expression]: expressions.html#constant-expressions +[constant expression]: const_eval.html#constant-expressions [interior mutable]: interior-mutability.html [IDENTIFIER]: identifiers.html -[_Type_]: types.html +[_Type_]: types.html#type-expressions [_Expression_]: expressions.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/structs.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/structs.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/structs.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/structs.md 2018-12-04 23:42:54.000000000 +0000 @@ -25,7 +25,7 @@ > > _StructField_ :\ >    [_OuterAttribute_]\*\ ->    [_Visibility_] +>    [_Visibility_]?\ >    [IDENTIFIER] `:` [_Type_] > > _TupleFields_ :\ @@ -33,7 +33,7 @@ > > _TupleField_ :\ >    [_OuterAttribute_]\*\ ->    [_Visibility_] +>    [_Visibility_]?\ >    [_Type_] A _struct_ is a nominal [struct type] defined with the keyword `struct`. @@ -49,8 +49,8 @@ A _tuple struct_ is a nominal [tuple type], also defined with the keyword `struct`. For example: -[struct type]: types.html#struct-types -[tuple type]: types.html#tuple-types +[struct type]: types/struct.html +[tuple type]: types/tuple.html ```rust struct Point(i32, i32); @@ -78,11 +78,11 @@ The precise memory layout of a struct is not specified. One can specify a particular layout using the [`repr` attribute]. -[`repr` attribute]: attributes.html#ffi-attributes +[`repr` attribute]: type-layout.html#representations [_OuterAttribute_]: attributes.html [IDENTIFIER]: identifiers.html [_Generics_]: items/generics.html [_WhereClause_]: items/generics.html#where-clauses [_Visibility_]: visibility-and-privacy.html -[_Type_]: types.html +[_Type_]: types.html#type-expressions diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/traits.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/traits.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/traits.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/traits.md 2018-12-04 23:42:54.000000000 +0000 @@ -1,5 +1,51 @@ # Traits +> **Syntax**\ +> _Trait_ :\ +>    `unsafe`? `trait` [IDENTIFIER]  +> [_Generics_]? +> ( `:` [_TypeParamBounds_]? )? +> [_WhereClause_]? `{`\ +>      _TraitItem_\*\ +>    `}` +> +> _TraitItem_ :\ +>    [_OuterAttribute_]\* (\ +>          _TraitFunc_\ +>       | _TraitMethod_\ +>       | _TraitConst_\ +>       | _TraitType_\ +>       | [_MacroInvocationSemi_]\ +>    ) +> +> _TraitFunc_ :\ +>       _TraitFunctionDecl_ ( `;` | [_BlockExpression_] ) +> +> _TraitMethod_ :\ +>       _TraitMethodDecl_ ( `;` | [_BlockExpression_] ) +> +> _TraitFunctionDecl_ :\ +>    [_FunctionQualifiers_] `fn` [IDENTIFIER] [_Generics_]?\ +>       `(` _TraitFunctionParameters_? `)`\ +>       [_FunctionReturnType_]? [_WhereClause_]? +> +> _TraitMethodDecl_ :\ +>    [_FunctionQualifiers_] `fn` [IDENTIFIER] [_Generics_]?\ +>       `(` [_SelfParam_] (`,` _TraitFunctionParam_)\* `,`? `)`\ +>       [_FunctionReturnType_]? [_WhereClause_]? +> +> _TraitFunctionParameters_ :\ +>    _TraitFunctionParam_ (`,` _TraitFunctionParam_)\* `,`? +> +> _TraitFunctionParam_[†](#parameter-patterns) :\ +>    ( [_Pattern_] `:` )? [_Type_] +> +> _TraitConst_ :\ +>    `const` [IDENTIFIER] `:` [_Type_] ( `=` [_Expression_] )? `;` +> +> _TraitType_ :\ +>    `type` [IDENTIFIER] ( `:` [_TypeParamBounds_]? )? `;` + A _trait_ describes an abstract interface that types can implement. This interface consists of [associated items], which come in three varieties: @@ -32,7 +78,7 @@ trait Seq { fn len(&self) -> u32; fn elt_at(&self, n: u32) -> T; - fn iter(&self, F) where F: Fn(T); + fn iter(&self, f: F) where F: Fn(T); } ``` @@ -115,8 +161,66 @@ let nonsense = circle.radius() * circle.area(); ``` +## Unsafe traits + +Traits items that begin with the `unsafe` keyword indicate that *implementing* the +trait may be [unsafe]. It is safe to use a correctly implemented unsafe trait. +The [trait implementation] must also begin with the `unsafe` keyword. + +[`Sync`] and [`Send`] are examples of unsafe traits. + +## Parameter patterns + +Function or method declarations without a body only allow [IDENTIFIER] or +`_` [wild card][WildcardPattern] patterns. `mut` [IDENTIFIER] is currently +allowed, but it is deprecated and will become a hard error in the future. + + +In the 2015 edition, the pattern for a trait function or method parameter is +optional: + +```rust +trait T { + fn f(i32); // Parameter identifiers are not required. +} +``` + +The kinds of patterns for parameters is limited to one of the following: + +* [IDENTIFIER] +* `mut` [IDENTIFIER] +* [`_`][WildcardPattern] +* `&` [IDENTIFIER] +* `&&` [IDENTIFIER] + +Beginning in the 2018 edition, function or method parameter patterns are no +longer optional. Also, all irrefutable patterns are allowed as long as there +is a body. Without a body, the limitations listed above are still in effect. + +```rust,edition2018 +trait T { + fn f1((a, b): (i32, i32)) {} + fn f2(_: (i32, i32)); // Cannot use tuple pattern without a body. +} +``` + +[IDENTIFIER]: identifiers.html +[WildcardPattern]: patterns.html#wildcard-pattern +[_BlockExpression_]: expressions/block-expr.html +[_Expression_]: expressions.html +[_FunctionParam_]: items/functions.html +[_FunctionQualifiers_]: items/functions.html +[_FunctionReturnType_]: items/functions.html +[_Generics_]: items/generics.html +[_MacroInvocationSemi_]: macros.html#macro-invocation +[_OuterAttribute_]: attributes.html +[_Pattern_]: patterns.html +[_SelfParam_]: items/associated-items.html#methods +[_TypeParamBounds_]: trait-bounds.html +[_Type_]: types.html#type-expressions +[_WhereClause_]: items/generics.html#where-clauses [bounds]: trait-bounds.html -[trait object]: types.html#trait-objects +[trait object]: types/trait-object.html [explicit]: expressions/operator-expr.html#type-cast-expressions [RFC 255]: https://github.com/rust-lang/rfcs/blob/master/text/0255-object-safety.md [associated items]: items/associated-items.html @@ -125,3 +229,7 @@ [generics]: items/generics.html [where clauses]: items/generics.html#where-clauses [generic functions]: items/functions.html#generic-functions +[unsafe]: unsafety.html +[trait implementation]: items/implementations.html#trait-implementations +[`Send`]: special-types-and-traits.html#send +[`Sync`]: special-types-and-traits.html#sync diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/type-aliases.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/type-aliases.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/type-aliases.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/type-aliases.md 2018-12-04 23:42:54.000000000 +0000 @@ -32,4 +32,4 @@ [IDENTIFIER]: identifiers.html [_Generics_]: items/generics.html [_WhereClause_]: items/generics.html#where-clauses -[_Type_]: types.html +[_Type_]: types.html#type-expressions diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/use-declarations.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/use-declarations.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items/use-declarations.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items/use-declarations.md 2018-12-04 23:42:54.000000000 +0000 @@ -2,12 +2,12 @@ > **Syntax:**\ > _UseDeclaration_ :\ ->    ([_Visibility_])? `use` _UseTree_ `;` +>    `use` _UseTree_ `;` > > _UseTree_ :\ >       ([_SimplePath_]? `::`)? `*`\ >    | ([_SimplePath_]? `::`)? `{` (_UseTree_ ( `,` _UseTree_ )\* `,`?)? `}`\ ->    | [_SimplePath_] `as` [IDENTIFIER] +>    | [_SimplePath_] ( `as` [IDENTIFIER] )? A _use declaration_ creates one or more local name bindings synonymous with some other [path]. Usually a `use` declaration is used to shorten the path @@ -57,6 +57,8 @@ } ``` +## `use` Visibility + Like items, `use` declarations are private to the containing module, by default. Also like items, a `use` declaration can be public, if qualified by the `pub` keyword. Such a `use` declaration serves to _re-export_ a name. A @@ -82,21 +84,21 @@ In this example, the module `quux` re-exports two public names defined in `foo`. -Also note that the paths contained in `use` items are relative to the crate -root. So, in the previous example, the `use` refers to `quux::foo::{bar, baz}`, -and not simply to `foo::{bar, baz}`. This also means that top-level module -declarations should be at the crate root if direct usage of the declared -modules within `use` items is desired. It is also possible to use `self` and -`super` at the beginning of a `use` item to refer to the current and direct -parent modules respectively. All rules regarding accessing declared modules in -`use` declarations apply to both module declarations and `extern crate` -declarations. +## `use` Paths + +Paths in `use` items must start with a crate name or one of the [path +qualifiers] `crate`, `self`, `super`, or `::`. `crate` refers to the current +crate. `self` refers to the current module. `super` refers to the parent +module. `::` can be used to explicitly refer to a crate, requiring an extern +crate name to follow. An example of what will and will not work for `use` items: + ```rust # #![allow(unused_imports)] -use foo::baz::foobaz; // good: foo is at the root of the crate +use std::path::{self, Path, PathBuf}; // good: std is a crate name +use crate::foo::baz::foobaz; // good: foo is at the root of the crate mod foo { @@ -104,10 +106,10 @@ pub mod iter {} } - use foo::example::iter; // good: foo is at crate root -// use example::iter; // bad: example is not at the crate root + use crate::foo::example::iter; // good: foo is at crate root +// use example::iter; // bad: relative paths are not allowed without `self` use self::baz::foobaz; // good: self refers to module 'foo' - use foo::bar::foobar; // good: foo is at crate root + use crate::foo::bar::foobar; // good: foo is at crate root pub mod bar { pub fn foobar() { } @@ -122,6 +124,32 @@ fn main() {} ``` +> **Edition Differences**: In the 2015 Edition, `use` paths also allow +> accessing items in the crate root. Using the example above, the following +> `use` paths work in 2015 but not 2018: +> +> ```rust,ignore +> use foo::example::iter; +> use ::foo::baz::foobaz; +> ``` +> +> In the 2018 Edition, if an in-scope item has the same name as an external +> crate, then `use` of that crate name requires a leading `::` to +> unambiguously select the crate name. This is to retain compatibility with +> potential future changes. +> +> ```rust,edition2018 +> // use std::fs; // Error, this is ambiguous. +> use ::std::fs; // Imports from the `std` crate, not the module below. +> use self::std::fs as self_fs; // Imports the module below. +> +> mod std { +> pub mod fs {} +> } +> # fn main() {} +> ``` + + [IDENTIFIER]: identifiers.html -[_SimplePath_]: paths.html -[_Visibility_]: visibility-and-privacy.html +[_SimplePath_]: paths.html#simple-paths +[path qualifiers]: paths.html#path-qualifiers diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/items.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/items.md 2018-12-04 23:42:54.000000000 +0000 @@ -1,31 +1,57 @@ # Items +> **Syntax:**\ +> _Item_:\ +>    [_OuterAttribute_]\*\ +>       _VisItem_\ +>    | _MacroItem_ +> +> _VisItem_:\ +>    [_Visibility_]?\ +>    (\ +>          [_Module_]\ +>       | [_ExternCrate_]\ +>       | [_UseDeclaration_]\ +>       | [_Function_]\ +>       | [_TypeAlias_]\ +>       | [_Struct_]\ +>       | [_Enumeration_]\ +>       | [_Union_]\ +>       | [_ConstantItem_]\ +>       | [_StaticItem_]\ +>       | [_Trait_]\ +>       | [_Implementation_]\ +>       | [_ExternBlock_]\ +>    ) +> +> _MacroItem_:\ +>       [_MacroInvocationSemi_]\ +>    | [_MacroRulesDefinition_] + + An _item_ is a component of a crate. Items are organized within a crate by a nested set of [modules]. Every crate has a single "outermost" anonymous module; all further items within the crate have [paths] within the module tree of the crate. -[modules]: items/modules.html -[paths]: paths.html - Items are entirely determined at compile-time, generally remain fixed during execution, and may reside in read-only memory. There are several kinds of items: -* [modules](items/modules.html) -* [`extern crate` declarations](items/extern-crates.html) -* [`use` declarations](items/use-declarations.html) -* [function definitions](items/functions.html) -* [type definitions](items/type-aliases.html) -* [struct definitions](items/structs.html) -* [enumeration definitions](items/enumerations.html) -* [union definitions](items/unions.html) -* [constant items](items/constant-items.html) -* [static items](items/static-items.html) -* [trait definitions](items/traits.html) -* [implementations](items/implementations.html) -* [`extern` blocks](items/external-blocks.html) +* [modules] +* [`extern crate` declarations] +* [`use` declarations] +* [function definitions] +* [type definitions] +* [struct definitions] +* [enumeration definitions] +* [union definitions] +* [constant items] +* [static items] +* [trait definitions] +* [implementations] +* [`extern` blocks] Some items form an implicit scope for the declaration of sub-items. In other words, within a function or module, declarations of items can (in many cases) @@ -36,3 +62,35 @@ qualified by the name of the enclosing item, or is private to the enclosing item (in the case of functions). The grammar specifies the exact locations in which sub-item declarations may appear. + +[_ConstantItem_]: items/constant-items.html +[_Enumeration_]: items/enumerations.html +[_ExternBlock_]: items/external-blocks.html +[_ExternCrate_]: items/extern-crates.html +[_Function_]: items/functions.html +[_Implementation_]: items/implementations.html +[_MacroInvocationSemi_]: macros.html#macro-invocation +[_MacroRulesDefinition_]: macros-by-example.html +[_Module_]: items/modules.html +[_OuterAttribute_]: attributes.html +[_StaticItem_]: items/static-items.html +[_Struct_]: items/structs.html +[_Trait_]: items/traits.html +[_TypeAlias_]: items/type-aliases.html +[_Union_]: items/unions.html +[_UseDeclaration_]: items/use-declarations.html +[_Visibility_]: visibility-and-privacy.html +[`extern crate` declarations]: items/extern-crates.html +[`extern` blocks]: items/external-blocks.html +[`use` declarations]: items/use-declarations.html +[constant items]: items/constant-items.html +[enumeration definitions]: items/enumerations.html +[function definitions]: items/functions.html +[implementations]: items/implementations.html +[modules]: items/modules.html +[paths]: paths.html +[static items]: items/static-items.html +[struct definitions]: items/structs.html +[trait definitions]: items/traits.html +[type definitions]: items/type-aliases.html +[union definitions]: items/unions.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/keywords.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/keywords.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/keywords.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/keywords.md 2018-12-04 23:42:54.000000000 +0000 @@ -57,6 +57,11 @@ > KW_WHERE : `where`\ > KW_WHILE : `while` +The following keywords were added beginning in the 2018 edition. + +> **Lexer 2018+**\ +> KW_DYN : `dyn` + ## Reserved keywords These keywords aren't used yet, but they are reserved for future use. They have @@ -78,6 +83,13 @@ > KW_VIRTUAL : `virtual`\ > KW_YIELD : `yield` +The following keywords are reserved beginning in the 2018 edition. + +> **Lexer 2018+**\ +> KW_ASYNC : `async`\ +> KW_AWAIT : `await`\ +> KW_TRY : `try` + ## Weak keywords These keywords have special meaning only in certain contexts. For example, it @@ -92,17 +104,21 @@ // error[E0262]: invalid lifetime parameter name: `'static` fn invalid_lifetime_parameter<'static>(s: &'static str) -> &'static str { s } ``` -* `dyn` denotes a [trait object] and is a keyword when used in a type position +* In the 2015 edition, [`dyn`] is a keyword when used in a type position followed by a path that does not start with `::`. + Beginning in the 2018 edition, `dyn` has been promoted to a strict keyword. + > **Lexer**\ > KW_UNION : `union`\ -> KW_STATICLIFETIME : `'static`\ +> KW_STATICLIFETIME : `'static` +> +> **Lexer 2015**\ > KW_DYN : `dyn` [items]: items.html [Variables]: variables.html -[Type parameters]: types.html#type-parameters +[Type parameters]: types/parameters.html [loop labels]: expressions/loop-expr.html#loop-labels [Macros]: macros.html [attributes]: attributes.html @@ -110,4 +126,4 @@ [Crates]: crates-and-source-files.html [union]: items/unions.html [variants]: items/enumerations.html -[trait object]: types.html#trait-objects +[`dyn`]: types/trait-object.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/lifetime-elision.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/lifetime-elision.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/lifetime-elision.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/lifetime-elision.md 2018-12-04 23:42:54.000000000 +0000 @@ -169,13 +169,13 @@ const RESOLVED_STATIC: &dyn Fn(&Foo, &Bar) -> &Baz = .. ``` -[closure trait]: types.html#closure-types +[closure trait]: types/closure.html [constant]: items/constant-items.html -[function item]: types.html#function-item-types -[function pointer]: types.html#function-pointer-types +[function item]: types/function-item.html +[function pointer]: types/function-pointer.html [implementation]: items/implementations.html [RFC 599]: https://github.com/rust-lang/rfcs/blob/master/text/0599-default-object-bound.md [RFC 1156]: https://github.com/rust-lang/rfcs/blob/master/text/1156-adjust-default-object-bounds.md [static]: items/static-items.html -[trait object]: types.html#trait-objects +[trait object]: types/trait-object.html [type aliases]: items/type-aliases.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/macros-by-example.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/macros-by-example.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/macros-by-example.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/macros-by-example.md 2018-12-04 23:42:54.000000000 +0000 @@ -1,12 +1,51 @@ # Macros By Example +> **Syntax**\ +> _MacroRulesDefinition_ :\ +>    `macro_rules` `!` [IDENTIFIER] _MacroRulesDef_ +> +> _MacroRulesDef_ :\ +>       `(` _MacroRules_ `)` `;`\ +>    | `[` _MacroRules_ `]` `;`\ +>    | `{` _MacroRules_ `}` +> +> _MacroRules_ :\ +>    _MacroRule_ ( `;` _MacroRule_ )\* `;`? +> +> _MacroRule_ :\ +>    _MacroMatcher_ `=>` _MacroTranscriber_ +> +> _MacroMatcher_ :\ +>       `(` _MacroMatch_\* `)`\ +>    | `[` _MacroMatch_\* `]`\ +>    | `{` _MacroMatch_\* `}` +> +> _MacroMatch_ :\ +>       [_Token_]_except $ and delimiters_\ +>    | _MacroMatcher_\ +>    | `$` [IDENTIFIER] `:` _MacroFragSpec_\ +>    | `$` `(` _MacroMatch_+ `)` _MacroRepSep_? _MacroKleeneOp_ +> +> _MacroFragSpec_ :\ +>       `block` | `expr` | `ident` | `item` | `lifetime`\ +>    | `meta` | `pat` | `path` | `stmt` | `tt` | `ty` | `vis` +> +> _MacroRepSep_ :\ +>    [_Token_]_except delimiters and kleene operators_ +> +> _MacroKleeneOp_2015 :\ +>    `*` | `+` +> +> _MacroKleeneOp_2018+ :\ +>    `*` | `+` | `?` +> +> _MacroTranscriber_ :\ +>    [_DelimTokenTree_] + `macro_rules` allows users to define syntax extension in a declarative way. We call such extensions "macros by example" or simply "macros". -Currently, macros can expand to expressions, statements, items, or patterns. - -(A `sep_token` is any token other than `*` and `+`. A `non_special_token` is -any token other than a delimiter or `$`.) +Macros can expand to expressions, statements, items, types, or patterns. The macro expander looks up macro invocations by name, and tries each macro rule in turn. It transcribes the first successful match. Matching and @@ -20,44 +59,56 @@ In the matcher, `$` _name_ `:` _designator_ matches the nonterminal in the Rust syntax named by _designator_. Valid designators are: -* `item`: an [item] -* `block`: a [block] -* `stmt`: a [statement] -* `pat`: a [pattern] -* `expr`: an [expression] -* `ty`: a [type] -* `ident`: an [identifier] or [keyword] -* `path`: a [path] -* `tt`: a token tree (a single [token] by matching `()`, `[]`, or `{}`) -* `meta`: the contents of an [attribute] -* `lifetime`: a lifetime. Examples: `'static`, `'a`. -* `vis`: a (visibility qualifier)[visibility-and-privacy] - -[item]: items.html -[block]: expressions/block-expr.html -[statement]: statements.html -[pattern]: expressions/match-expr.html -[expression]: expressions.html -[type]: types.html -[identifier]: identifiers.html -[keyword]: keywords.html -[path]: paths.html +* `item`: an [_Item_] +* `block`: a [_BlockExpression_] +* `stmt`: a [_Statement_] without the trailing semicolon +* `pat`: a [_Pattern_] +* `expr`: an [_Expression_] +* `ty`: a [_Type_] +* `ident`: an [IDENTIFIER_OR_KEYWORD] +* `path`: a [_TypePath_] style path +* `tt`: a [_TokenTree_] (a single [token] or tokens in matching delimiters `()`, `[]`, or `{}`) +* `meta`: a [_MetaItem_], the contents of an attribute +* `lifetime`: a [LIFETIME_TOKEN] +* `vis`: a [_Visibility_] qualifier + +[IDENTIFIER]: identifiers.html +[IDENTIFIER_OR_KEYWORD]: identifiers.html +[LIFETIME_TOKEN]: tokens.html#lifetimes-and-loop-labels +[_BlockExpression_]: expressions/block-expr.html +[_Expression_]: expressions.html +[_Item_]: items.html +[_MetaItem_]: attributes.html +[_Pattern_]: patterns.html +[_Statement_]: statements.html +[_TokenTree_]: macros.html#macro-invocation +[_TypePath_]: paths.html#paths-in-types +[_Type_]: types.html#type-expressions +[_Visibility_]: visibility-and-privacy.html [token]: tokens.html -[attribute]: attributes.html -[visibility-and-privacy]: visibility-and-privacy.html In the transcriber, the designator is already known, and so only the name of a matched nonterminal comes after the dollar sign. In both the matcher and transcriber, the Kleene star-like operator indicates -repetition. The Kleene star operator consists of `$` and parentheses, optionally -followed by a separator token, followed by `*` or `+`. `*` means zero or more -repetitions, `+` means at least one repetition. The parentheses are not matched or -transcribed. On the matcher side, a name is bound to _all_ of the names it -matches, in a structure that mimics the structure of the repetition encountered -on a successful match. The job of the transcriber is to sort that structure -out. +repetition. The Kleene star operator consists of `$` and parentheses, +optionally followed by a separator token, followed by `*`, `+`, or `?`. `*` +means zero or more repetitions; `+` means _at least_ one repetition; `?` means +at most one repetition. The parentheses are not matched or transcribed. On the +matcher side, a name is bound to _all_ of the names it matches, in a structure +that mimics the structure of the repetition encountered on a successful match. +The job of the transcriber is to sort that structure out. Also, `?`, unlike `*` +and `+`, does _not_ allow a separator, since one could never match against it +anyway. + +> **Edition Differences**: The `?` Kleene operator did not exist before the +> 2018 edition. + +> **Edition Differences**: Prior to the 2018 Edition, `?` was an allowed +> separator token, rather than a Kleene operator. It is no longer allowed as a +> separator as of the 2018 edition. This avoids ambiguity with the `?` Kleene +> operator. The rules for transcription of these repetitions are called "Macro By Example". Essentially, one "layer" of repetition is discharged at a time, and all of them @@ -84,9 +135,36 @@ a macro definition like `$i:expr [ , ]` is not legal, because `[` could be part of an expression. A macro definition like `$i:expr,` or `$i:expr;` would be legal, however, because `,` and `;` are legal separators. See [RFC 550] for more information. + Specifically: + + * `expr` and `stmt` may only be followed by one of `=>`, `,`, or `;`. + * `pat` may only be followed by one of `=>`, `,`, `=`, `|`, `if`, or `in`. + * `path` and `ty` may only be followed by one of `=>`, `,`, `=`, `|`, `;`, + `:`, `>`, `>>`, `[`, `{`, `as`, `where`, or a macro variable of `block` + fragment type. + * `vis` may only be followed by one of `,`, `priv`, a raw identifier, any + token that can begin a type, or a macro variable of `ident`, `ty`, or + `path` fragment type. + * All other fragment types have no restrictions. + 2. The parser must have eliminated all ambiguity by the time it reaches a `$` _name_ `:` _designator_. This requirement most often affects name-designator pairs when they occur at the beginning of, or immediately after, a `$(...)*`; - requiring a distinctive token in front can solve the problem. + requiring a distinctive token in front can solve the problem. For example: + + ```rust + // The matcher `$($i:ident)* $e:expr` would be ambiguous because the parser + // would be forced to choose between an identifier or an expression. Use some + // token to distinguish them. + macro_rules! example { + ($(I $i:ident)* E $e:expr) => { ($($i)-*) * $e }; + } + let foo = 2; + let bar = 3; + // The following expands to `(foo - bar) * 5` + example!(I foo I bar E 5); + ``` [RFC 550]: https://github.com/rust-lang/rfcs/blob/master/text/0550-macro-future-proofing.md +[_DelimTokenTree_]: macros.html +[_Token_]: tokens.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/macros.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/macros.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/macros.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/macros.md 2018-12-04 23:42:54.000000000 +0000 @@ -9,6 +9,95 @@ * [Macros by Example] define new syntax in a higher-level, declarative way. * [Procedural Macros] can be used to implement custom derive. +## Macro Invocation + +> **Syntax**\ +> _MacroInvocation_ :\ +>    [_SimplePath_] `!` _DelimTokenTree_ +> +> _DelimTokenTree_ :\ +>       `(` _TokenTree_\* `)`\ +>    | `[` _TokenTree_\* `]`\ +>    | `{` _TokenTree_\* `}` +> +> _TokenTree_ :\ +>    [_Token_]_except delimiters_ | _DelimTokenTree_ +> +> _MacroInvocationSemi_ :\ +>       [_SimplePath_] `!` `(` _TokenTree_\* `)` `;`\ +>    | [_SimplePath_] `!` `[` _TokenTree_\* `]` `;`\ +>    | [_SimplePath_] `!` `{` _TokenTree_\* `}` + +A macro invocation executes a macro at compile time and replaces the +invocation with the result of the macro. Macros may be invoked in the +following situations: + +* [Expressions] and [statements] +* [Patterns] +* [Types] +* [Items] including [associated items] +* [`macro_rules`] transcribers + +When used as an item or a statement, the _MacroInvocationSemi_ form is used +where a semicolon is required at the end when not using curly braces. +[Visibility qualifiers] are never allowed before a macro invocation or +[`macro_rules`] definition. + +```rust +// Used as an expression. +let x = vec![1,2,3]; + +// Used as a statement. +println!("Hello!"); + +// Used in a pattern. +macro_rules! pat { + ($i:ident) => (Some($i)) +} + +if let pat!(x) = Some(1) { + assert_eq!(x, 1); +} + +// Used in a type. +macro_rules! Tuple { + { $A:ty, $B:ty } => { ($A, $B) }; +} + +type N2 = Tuple!(i32, i32); + +// Used as an item. +# use std::cell::RefCell; +thread_local!(static FOO: RefCell = RefCell::new(1)); + +// Used as an associated item. +macro_rules! const_maker { + ($t:ty, $v:tt) => { const CONST: $t = $v; }; +} +trait T { + const_maker!{i32, 7} +} + +// Macro calls within macros. +macro_rules! example { + () => { println!("Macro call in a macro!") }; +} +// Outer macro `example` is expanded, then inner macro `println` is expanded. +example!(); +``` + [Macros by Example]: macros-by-example.html [Procedural Macros]: procedural-macros.html +[_SimplePath_]: paths.html#simple-paths +[_Token_]: tokens.html +[associated items]: items/associated-items.html [compiler plugins]: ../unstable-book/language-features/plugin.html +[delimiters]: tokens.html#delimiters +[expressions]: expressions.html +[items]: items.html +[`macro_rules`]: macros-by-example.html +[patterns]: patterns.html +[statements]: statements.html +[tokens]: tokens.html +[types]: types.html +[visibility qualifiers]: visibility-and-privacy.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/paths.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/paths.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/paths.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/paths.md 2018-12-04 23:42:54.000000000 +0000 @@ -1,57 +1,162 @@ # Paths -A *path* is a sequence of one or more path components _logically_ separated by +A *path* is a sequence of one or more path segments _logically_ separated by a namespace qualifier (`::`). If a path -consists of only one component, it refers to either an [item] or a [variable] in -a local control scope. If a path has multiple components, it always refers to an +consists of only one segment, it refers to either an [item] or a [variable] in +a local control scope. If a path has multiple segments, it always refers to an item. -Two examples of simple paths consisting of only identifier components: +Two examples of simple paths consisting of only identifier segments: ```rust,ignore x; x::y::z; ``` -Path components are usually [identifiers], but they may also include -angle-bracket-enclosed lists of type arguments. In [expression] context, the -type argument list is given after a `::` namespace qualifier in order to -disambiguate it from a relational expression involving the less-than -symbol (`<`). In type expression context, the -final namespace qualifier is omitted. - -Two examples of paths with type arguments: - -```rust -# struct HashMap(K,V); -# fn f() { -# fn id(t: T) -> T { t } -type T = HashMap; // Type arguments used in a type expression -let x = id::(10); // Type arguments used in a call expression -# } +## Types of paths + +### Simple Paths + +> **Syntax**\ +> _SimplePath_ :\ +>    `::`? _SimplePathSegment_ (`::` _SimplePathSegment_)\* +> +> _SimplePathSegment_ :\ +>    [IDENTIFIER] | `super` | `self` | `crate` | `$crate` + +Simple paths are used in [visibility] markers, [attributes], [macros], and [`use`] items. +Examples: + +```rust +use std::io::{self, Write}; +mod m { + #[clippy::cyclomatic_complexity = "0"] + pub (in super) fn f1() {} +} ``` -Paths can be denoted with various leading qualifiers to change the meaning of -how it is resolved: +### Paths in expressions + +> **Syntax**\ +> _PathInExpression_ :\ +>    `::`? _PathExprSegment_ (`::` _PathExprSegment_)\* +> +> _PathExprSegment_ :\ +>    _PathIdentSegment_ (`::` _GenericArgs_)? +> +> _PathIdentSegment_ :\ +>    [IDENTIFIER] | `super` | `self` | `Self` | `crate` | `$crate` +> +> _GenericArgs_ :\ +>       `<` `>`\ +>    | `<` _GenericArgsLifetimes_ `,`? `>`\ +>    | `<` _GenericArgsTypes_ `,`? `>`\ +>    | `<` _GenericArgsBindings_ `,`? `>`\ +>    | `<` _GenericArgsTypes_ `,` _GenericArgsBindings_ `,`? `>`\ +>    | `<` _GenericArgsLifetimes_ `,` _GenericArgsTypes_ `,`? `>`\ +>    | `<` _GenericArgsLifetimes_ `,` _GenericArgsBindings_ `,`? `>`\ +>    | `<` _GenericArgsLifetimes_ `,` _GenericArgsTypes_ `,` _GenericArgsBindings_ `,`? `>` +> +> _GenericArgsLifetimes_ :\ +>    [_Lifetime_] (`,` [_Lifetime_])\* +> +> _GenericArgsTypes_ :\ +>    [_Type_] (`,` [_Type_])\* +> +> _GenericArgsBindings_ :\ +>    _GenericArgsBinding_ (`,` _GenericArgsBinding_)\* +> +> _GenericArgsBinding_ :\ +>    [IDENTIFIER] `=` [_Type_] + +Paths in expressions allow for paths with generic arguments to be specified. They are +used in various places in [expressions] and [patterns]. -* Paths starting with `::` are considered to be global paths where the - components of the path start being resolved from the crate root. Each - identifier in the path must resolve to an item. +The `::` token is required before the opening `<` for generic arguments to avoid +ambiguity with the less-than operator. This is colloquially known as "turbofish" syntax. ```rust -mod a { - pub fn foo() {} +(0..10).collect::>(); +Vec::::with_capacity(1024); +``` + +## Qualified paths + +> **Syntax**\ +> _QualifiedPathInExpression_ :\ +>    _QualifiedPathType_ (`::` _PathExprSegment_)+ +> +> _QualifiedPathType_ :\ +>    `<` [_Type_] (`as` _TypePath_)? `>` +> +> _QualifiedPathInType_ :\ +>    _QualifiedPathType_ (`::` _TypePathSegment_)+ + +Fully qualified paths allow for disambiguating the path for [trait implementations] and +for specifying [canonical paths](#canonical-paths). When used in a type specification, it +supports using the type syntax specified below. + +```rust +struct S; +impl S { + fn f() { println!("S"); } } -mod b { - pub fn foo() { - ::a::foo(); // call a's foo function - } +trait T1 { + fn f() { println!("T1 f"); } } -# fn main() {} +impl T1 for S {} +trait T2 { + fn f() { println!("T2 f"); } +} +impl T2 for S {} +S::f(); // Calls the inherent impl. +::f(); // Calls the T1 trait function. +::f(); // Calls the T2 trait function. +``` + +### Paths in types + +> **Syntax**\ +> _TypePath_ :\ +>    `::`? _TypePathSegment_ (`::` _TypePathSegment_)\* +> +> _TypePathSegment_ :\ +>    _PathIdentSegment_ (`::`? ([_GenericArgs_] | _TypePathFn_)? +> +> _TypePathFn_ :\ +> `(` _TypePathFnInputs_? `)` (`->` [_Type_])? +> +> _TypePathFnInputs_ :\ +> [_Type_] (`,` [_Type_])\* `,`? + +Type paths are used within type definitions, trait bounds, type parameter bounds, +and qualified paths. + +Although the `::` token is allowed before the generics arguments, it is not required +because there is no ambiguity like there is in _PathInExpression_. + +```rust,ignore +impl ops::Index> for S { /*...*/ } +fn i() -> impl Iterator> { /*...*/ } +type G = std::boxed::Box isize>; ``` -* Paths starting with the keyword `super` begin resolution relative to the - parent module. Each further identifier must resolve to an item. +## Path qualifiers + +Paths can be denoted with various leading qualifiers to change the meaning of +how it is resolved. + +### `::` + +Paths starting with `::` are considered to be global paths where the segments of the path +start being resolved from the crate root. Each identifier in the path must resolve to an +item. + +> **Edition Differences**: In the 2015 Edition, the crate root contains a variety of +> different items, including external crates, default crates such as `std` and `core`, and +> items in the top level of the crate (including `use` imports). +> +> Beginning with the 2018 Edition, paths starting with `::` can only reference crates. ```rust mod a { @@ -59,14 +164,16 @@ } mod b { pub fn foo() { - super::a::foo(); // call a's foo function + ::a::foo(); // call a's foo function } } # fn main() {} ``` -* Paths starting with the keyword `self` begin resolution relative to the - current module. Each further identifier must resolve to an item. +### `self` + +`self` resolves the path relative to the current module. `self` can only be used as the +first segment, without a preceding `::`. ```rust fn foo() {} @@ -76,8 +183,54 @@ # fn main() {} ``` -Additionally keyword `super` may be repeated several times after the first -`super` or `self` to refer to ancestor modules. +### `Self` + +`Self`, with a capital "S", is used to refer to the implementing type within +[traits] and [implementations]. + +`Self` can only be used as the first segment, without a preceding `::`. + +```rust +trait T { + type Item; + const C: i32; + // `Self` will be whatever type that implements `T`. + fn new() -> Self; + // `Self::Item` will be the type alias in the implementation. + fn f(&self) -> Self::Item; +} +struct S; +impl T for S { + type Item = i32; + const C: i32 = 9; + fn new() -> Self { // `Self` is the type `S`. + S + } + fn f(&self) -> Self::Item { // `Self::Item` is the type `i32`. + Self::C // `Self::C` is the constant value `9`. + } +} +``` + +### `super` + +`super` in a path resolves to the parent module. It may only be used in leading +segments of the path, possibly after an initial `self` segment. + +```rust +mod a { + pub fn foo() {} +} +mod b { + pub fn foo() { + super::a::foo(); // call a's foo function + } +} +# fn main() {} +``` + +`super` may be repeated several times after the first `super` or `self` to refer to +ancestor modules. ```rust mod a { @@ -95,12 +248,46 @@ # fn main() {} ``` +### `crate` + +`crate` resolves the path relative to the current crate. `crate` can only be used as the +first segment, without a preceding `::`. + +```rust +fn foo() {} +mod a { + fn bar() { + crate::foo(); + } +} +# fn main() {} +``` + +### `$crate` + +`$crate` is only used within [macro transcribers], and can only be used as the first +segment, without a preceding `::`. `$crate` will expand to a path to access items from the +top level of the crate where the macro is defined, regardless of which crate the macro is +invoked. + +```rust +pub fn increment(x: u32) -> u32 { + x + 1 +} + +#[macro_export] +macro_rules! inc { + ($x:expr) => ( $crate::increment($x) ) +} +# fn main() { } +``` + ## Canonical paths Items defined in a module or implementation have a *canonical path* that corresponds to where within its crate it is defined. All other paths to these items are aliases. The canonical path is defined as a *path prefix* appended by -the path component the item itself defines. +the path segment the item itself defines. [Implementations] and [use declarations] do not have canonical paths, although the items that implementations define do have them. Items defined in @@ -113,7 +300,7 @@ The path prefix for modules is the canonical path to that module. For bare implementations, it is the canonical path of the item being implemented surrounded by angle (`<>`) brackets. For -trait implementations, it is the canonical path of the item being implemented +[trait implementations], it is the canonical path of the item being implemented followed by `as` followed by the canonical path to the trait all surrounded in angle (`<>`) brackets. @@ -164,10 +351,27 @@ # fn main() {} ``` + +[_GenericArgs_]: #paths-in-expressions +[_Lifetime_]: trait-bounds.html +[_Type_]: types.html#type-expressions [item]: items.html [variable]: variables.html [identifiers]: identifiers.html -[expression]: expressions.html [implementations]: items/implementations.html [modules]: items/modules.html [use declarations]: items/use-declarations.html +[IDENTIFIER]: identifiers.html +[`use`]: items/use-declarations.html +[attributes]: attributes.html +[enum]: items/enumerations.html +[expressions]: expressions.html +[macro transcribers]: macros-by-example.html +[macros]: macros-by-example.html +[patterns]: patterns.html +[struct]: items/structs.html +[trait implementation]: items/implementations.html#trait-implementations +[trait implementations]: items/implementations.html#trait-implementations +[traits]: items/traits.html +[union]: items/unions.html +[visibility]: visibility-and-privacy.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/patterns.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/patterns.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/patterns.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/patterns.md 2018-12-04 23:42:54.000000000 +0000 @@ -0,0 +1,675 @@ +# Patterns + +> **Syntax**\ +> _Pattern_ :\ +>       [_LiteralPattern_]\ +>    | [_IdentifierPattern_]\ +>    | [_WildcardPattern_]\ +>    | [_RangePattern_]\ +>    | [_ReferencePattern_]\ +>    | [_StructPattern_]\ +>    | [_TupleStructPattern_]\ +>    | [_TuplePattern_]\ +>    | [_GroupedPattern_]\ +>    | [_SlicePattern_]\ +>    | [_PathPattern_]\ +>    | [_MacroInvocation_] + +Patterns are used to match values against structures and to, +optionally, bind variables to values inside these structures. They are also +used in variable declarations and parameters for functions and closures. + +The pattern in the following example does four things: + +* Tests if `person` has the `car` field filled with something. +* Tests if the person's `age` field is between 13 and 19, and binds its value to + the `person_age` variable. +* Binds a reference to the `name` field to the variable `person_name`. +* Ignores the rest of the fields of `person`. The remaining fields can have any value and + are not bound to any variables. + +```rust +# struct Car; +# struct Computer; +# struct Person { +# name: String, +# car: Option, +# computer: Option, +# age: u8, +# } +# let person = Person { +# name: String::from("John"), +# car: Some(Car), +# computer: None, +# age: 15, +# }; +if let + Person { + car: Some(_), + age: person_age @ 13..=19, + name: ref person_name, + .. + } = person +{ + println!("{} has a car and is {} years old.", person_name, person_age); +} +``` + +Patterns are used in: + +* [`let` declarations](statements.html#let-statements) +* [Function](items/functions.html) and [closure](expressions/closure-expr.html) + parameters +* [`match` expressions](expressions/match-expr.html) +* [`if let` expressions](expressions/if-expr.html) +* [`while let` expressions](expressions/loop-expr.html#predicate-pattern-loops) +* [`for` expressions](expressions/loop-expr.html#iterator-loops) + +## Destructuring + +Patterns can be used to *destructure* [structs], [enums], and [tuples]. +Destructuring breaks up a value into its component pieces. The syntax used is +almost the same as when creating such values. In a pattern whose head +expression has a `struct`, `enum` or `tuple` type, a placeholder (`_`) stands +in for a *single* data field, whereas a wildcard `..` stands in for *all* the +remaining fields of a particular variant. When destructuring a data structure +with named (but not numbered) fields, it is allowed to write `fieldname` as a +shorthand for `fieldname: fieldname`. + +```rust +# enum Message { +# Quit, +# WriteString(String), +# Move { x: i32, y: i32 }, +# ChangeColor(u8, u8, u8), +# } +# let message = Message::Quit; +match message { + Message::Quit => println!("Quit"), + Message::WriteString(write) => println!("{}", &write), + Message::Move{ x, y: 0 } => println!("move {} horizontally", x), + Message::Move{ .. } => println!("other move"), + Message::ChangeColor { 0: red, 1: green, 2: _ } => { + println!("color change, red: {}, green: {}", red, green); + } +}; +``` + +## Refutability + +A pattern is said to be *refutable* when it has the possibility of not being matched +by the value it is being matched against. *Irrefutable* patterns, on the other hand, +always match the value they are being matched against. Examples: + +```rust +let (x, y) = (1, 2); // "(x, y)" is an irrefutable pattern + +if let (a, 3) = (1, 2) { // "(a, 3)" is refutable, and will not match + panic!("Shouldn't reach here"); +} else if let (a, 4) = (3, 4) { // "(a, 4)" is refutable, and will match + println!("Matched ({}, 4)", a); +} +``` + +## Literal patterns + +> **Syntax**\ +> _LiteralPattern_ :\ +>       [BOOLEAN_LITERAL]\ +>    | [CHAR_LITERAL]\ +>    | [BYTE_LITERAL]\ +>    | [STRING_LITERAL]\ +>    | [RAW_STRING_LITERAL]\ +>    | [BYTE_STRING_LITERAL]\ +>    | [RAW_BYTE_STRING_LITERAL]\ +>    | `-`? [INTEGER_LITERAL]\ +>    | `-`? [FLOAT_LITERAL] + +[BOOLEAN_LITERAL]: tokens.html#boolean-literals +[CHAR_LITERAL]: tokens.html#character-literals +[BYTE_LITERAL]: tokens.html#byte-literals +[STRING_LITERAL]: tokens.html#string-literals +[RAW_STRING_LITERAL]: tokens.html#raw-string-literals +[BYTE_STRING_LITERAL]: tokens.html#byte-string-literals +[RAW_BYTE_STRING_LITERAL]: tokens.html#raw-byte-string-literals +[INTEGER_LITERAL]: tokens.html#integer-literals +[FLOAT_LITERAL]: tokens.html#floating-point-literals + +_Literal patterns_ match exactly the same value as what is created by the +literal. Since negative numbers are not [literals], literal patterns also +accept an optional minus sign before the literal, which acts like the negation +operator. + +
+ +Floating-point literals are currently accepted, but due to the complexity of comparing +them, they are going to be forbidden on literal patterns in a future version of Rust (see +[issue #41620](https://github.com/rust-lang/rust/issues/41620)). + +
+ +Literal patterns are always refutable. + +Examples: + +```rust +for i in -2..5 { + match i { + -1 => println!("It's minus one"), + 1 => println!("It's a one"), + 2|4 => println!("It's either a two or a four"), + _ => println!("Matched none of the arms"), + } +} +``` + +## Identifier patterns + +> **Syntax**\ +> _IdentifierPattern_ :\ +>       `ref`? `mut`? [IDENTIFIER] (`@` [_Pattern_] ) ? + +Identifier patterns bind the value they match to a variable. The identifier +must be unique within the pattern. The variable will shadow any variables of +the same name in scope. The scope of the new binding depends on the context of +where the pattern is used (such as a `let` binding or a `match` arm). + +Patterns that consist of only an identifier, possibly with a `mut`, match any value and +bind it to that identifier. This is the most commonly used pattern in variable +declarations and parameters for functions and closures. + +```rust +let mut variable = 10; +fn sum(x: i32, y: i32) -> i32 { +# x + y +# } +``` + +To bind the matched value of a pattern to a variable, use the syntax `variable @ +subpattern`. For example, the following binds the value 2 to `e` (not the +entire range: the range here is a range subpattern). + +```rust +let x = 2; + +match x { + e @ 1 ..= 5 => println!("got a range element {}", e), + _ => println!("anything"), +} +``` + +By default, identifier patterns bind a variable to a copy of or move from the +matched value depending on whether the matched value implements [`Copy`]. +This can be changed to bind to a reference by using the `ref` keyword, +or to a mutable reference using `ref mut`. For example: + +```rust +# let a = Some(10); +match a { + None => (), + Some(value) => (), +} + +match a { + None => (), + Some(ref value) => (), +} +``` + +In the first match expression, the value is copied (or moved). In the second match, +a reference to the same memory location is bound to the variable value. This syntax is +needed because in destructuring subpatterns the `&` operator can't be applied to +the value's fields. For example, the following is not valid: + +```rust,compile_fail +# struct Person { +# name: String, +# age: u8, +# } +# let value = Person{ name: String::from("John"), age: 23 }; +if let Person{name: &person_name, age: 18..=150} = value { } +``` + +To make it valid, write the following: + +```rust +# struct Person { +# name: String, +# age: u8, +# } +# let value = Person{ name: String::from("John"), age: 23 }; +if let Person{name: ref person_name, age: 18..=150} = value { } +``` + +Thus, `ref` is not something that is being matched against. Its objective is +exclusively to make the matched binding a reference, instead of potentially +copying or moving what was matched. + +[Path patterns](#path-patterns) take precedence over identifier patterns. It is an error +if `ref` or `ref mut` is specified and the identifier shadows a constant. + +### Binding modes + +To service better ergonomics, patterns operate in different *binding modes* in +order to make it easier to bind references to values. When a reference value is matched by +a non-reference pattern, it will be automatically treated as a `ref` or `ref mut` binding. +Example: + +```rust +let x: &Option = &Some(3); +if let Some(y) = x { + // y was converted to `ref y` and its type is &i32 +} +``` + +*Non-reference patterns* include all patterns except bindings, [wildcard +patterns](#wildcard-pattern) (`_`), [`const` patterns](#path-patterns) of reference types, +and [reference patterns](#reference-patterns). + +If a binding pattern does not explicitly have `ref`, `ref mut`, or `mut`, then it uses the +*default binding mode* to determine how the variable is bound. The default binding +mode starts in "move" mode which uses move semantics. When matching a pattern, the +compiler starts from the outside of the pattern and works inwards. Each time a reference +is matched using a non-reference pattern, it will automatically dereference the value and +update the default binding mode. References will set the default binding mode to `ref`. +Mutable references will set the mode to `ref mut` unless the mode is already `ref` in +which case it remains `ref`. If the automatically dereferenced value is still a reference, +it is dereferenced and this process repeats. + +## Wildcard pattern + +> **Syntax**\ +> _WildcardPattern_ :\ +>    `_` + +The _wildcard pattern_ matches any value. It is used to ignore values when they don't +matter. Inside other patterns it matches a single data field (as opposed to the `..` +which matches the remaining fields). Unlike identifier patterns, it does not copy, move +or borrow the value it matches. + +Examples: + +```rust +# let x = 20; +let (a, _) = (10, x); // the x is always matched by _ +# assert_eq!(a, 10); + +// ignore a function/closure param +let real_part = |a: f64, _: f64| { a }; + +// ignore a field from a struct +# struct RGBA { +# r: f32, +# g: f32, +# b: f32, +# a: f32, +# } +# let color = RGBA{r: 0.4, g: 0.1, b: 0.9, a: 0.5}; +let RGBA{r: red, g: green, b: blue, a: _} = color; +# assert_eq!(color.r, red); +# assert_eq!(color.g, green); +# assert_eq!(color.b, blue); + +// accept any Some, with any value +# let x = Some(10); +if let Some(_) = x {} +``` + +The wildcard pattern is always irrefutable. + +## Range patterns + +> **Syntax**\ +> _RangePattern_ :\ +>      _RangePatternBound_ `..=` _RangePatternBound_\ +>    | _RangePatternBound_ `...` _RangePatternBound_ +> +> _RangePatternBound_ :\ +>       [CHAR_LITERAL]\ +>    | [BYTE_LITERAL]\ +>    | `-`? [INTEGER_LITERAL]\ +>    | `-`? [FLOAT_LITERAL]\ +>    | [_PathInExpression_]\ +>    | [_QualifiedPathInExpression_] + +Range patterns match values that are within the closed range defined by its lower and +upper bounds. For example, a pattern `'m'..='p'` will match only the values `'m'`, `'n'`, +`'o'`, and `'p'`. The bounds can be literals or paths that point to constant values. + +A pattern a `..=` b must always have a ≤ b. It is an error to have a range pattern +`10..=0`, for example. + +The `...` syntax is kept for backwards compatibility. + +Range patterns only work on scalar types. The accepted types are: + +* Integer types (u8, i8, u16, i16, usize, isize, etc.). +* Character types (char). +* Floating point types (f32 and f64). This is being deprecated and will not be available + in a future version of Rust (see + [issue #41620](https://github.com/rust-lang/rust/issues/41620)). + +Examples: + +```rust +# let c = 'f'; +let valid_variable = match c { + 'a'..='z' => true, + 'A'..='Z' => true, + 'α'..='ω' => true, + _ => false, +}; + +# let ph = 10; +println!("{}", match ph { + 0..=6 => "acid", + 7 => "neutral", + 8..=14 => "base", + _ => unreachable!(), +}); + +// using paths to constants: +# const TROPOSPHERE_MIN : u8 = 6; +# const TROPOSPHERE_MAX : u8 = 20; +# +# const STRATOSPHERE_MIN : u8 = TROPOSPHERE_MAX + 1; +# const STRATOSPHERE_MAX : u8 = 50; +# +# const MESOSPHERE_MIN : u8 = STRATOSPHERE_MAX + 1; +# const MESOSPHERE_MAX : u8 = 85; +# +# let altitude = 70; +# +println!("{}", match altitude { + TROPOSPHERE_MIN..=TROPOSPHERE_MAX => "troposphere", + STRATOSPHERE_MIN..=STRATOSPHERE_MAX => "stratosphere", + MESOSPHERE_MIN..=MESOSPHERE_MAX => "mesosphere", + _ => "outer space, maybe", +}); + +# pub mod binary { +# pub const MEGA : u64 = 1024*1024; +# pub const GIGA : u64 = 1024*1024*1024; +# } +# let n_items = 20_832_425; +# let bytes_per_item = 12; +if let size @ binary::MEGA..=binary::GIGA = n_items * bytes_per_item { + println!("It fits and occupies {} bytes", size); +} + +# trait MaxValue { +# const MAX: u64; +# } +# impl MaxValue for u8 { +# const MAX: u64 = (1 << 8) - 1; +# } +# impl MaxValue for u16 { +# const MAX: u64 = (1 << 16) - 1; +# } +# impl MaxValue for u32 { +# const MAX: u64 = (1 << 32) - 1; +# } +// using qualified paths: +println!("{}", match 0xfacade { + 0 ..= ::MAX => "fits in a u8", + 0 ..= ::MAX => "fits in a u16", + 0 ..= ::MAX => "fits in a u32", + _ => "too big", +}); +``` + +Range patterns are always refutable, even when they cover the complete set +of possible values of a type. For example, `0u8..=255u8` is refutable even though +it covers all possible values of `u8`. + +## Reference patterns + +> **Syntax**\ +> _ReferencePattern_ :\ +>    (`&`|`&&`) `mut`? _Pattern_ + +Reference patterns dereference the pointers that are being matched +and, thus, borrow them. + +For example, these two matches on `x: &i32` are equivalent: + +```rust +let int_reference = &3; + +let a = match *int_reference { 0 => "zero", _ => "some" }; +let b = match int_reference { &0 => "zero", _ => "some" }; + +assert_eq!(a, b); +``` + +The grammar production for reference patterns has to match the token `&&` to match a +reference to a reference because it is a token by itself, not two `&` tokens. + +Adding the `mut` keyword dereferences a mutable reference. The mutability must match the +mutability of the reference. + +Reference patterns are always irrefutable. + +## Struct patterns + +> **Syntax**\ +> _StructPattern_ :\ +>    [_PathInExpression_] `{`\ +>       _StructPatternElements_ ?\ +>    `}` +> +> _StructPatternElements_ :\ +>       _StructPatternFields_ (`,` | `,` _StructPatternEtCetera_)?\ +>    | _StructPatternEtCetera_ +> +> _StructPatternFields_ :\ +>    _StructPatternField_ (`,` _StructPatternField_) \* +> +> _StructPatternField_ :\ +>    [_OuterAttribute_] \*\ +>    (\ +>          [TUPLE_INDEX] `:` [_Pattern_]\ +>       | [IDENTIFIER] `:` [_Pattern_]\ +>       | `ref`? `mut`? [IDENTIFIER]\ +>    ) +> +> _StructPatternEtCetera_ :\ +>    [_OuterAttribute_] \*\ +>    `..` + +[_OuterAttribute_]: attributes.html +[TUPLE_INDEX]: tokens.html#integer-literals + +Struct patterns match struct values that match all criteria defined by its subpatterns. +They are also used to [destructure](#destructuring) a struct. + +On a struct pattern, the fields are referenced by name, index (in the case of tuple +structs) or ignored by use of `..`: + +```rust +# struct Point { +# x: u32, +# y: u32, +# } +# let s = Point {x: 1, y: 1}; +# +match s { + Point {x: 10, y: 20} => (), + Point {y: 10, x: 20} => (), // order doesn't matter + Point {x: 10, ..} => (), + Point {..} => (), +} + +# struct PointTuple ( +# u32, +# u32, +# ); +# let t = PointTuple(1, 2); +# +match t { + PointTuple {0: 10, 1: 20} => (), + PointTuple {1: 10, 0: 20} => (), // order doesn't matter + PointTuple {0: 10, ..} => (), + PointTuple {..} => (), +} +``` + +If `..` is not used, it is required to match all fields: + +```rust +# struct Struct { +# a: i32, +# b: char, +# c: bool, +# } +# let mut struct_value = Struct{a: 10, b: 'X', c: false}; +# +match struct_value { + Struct{a: 10, b: 'X', c: false} => (), + Struct{a: 10, b: 'X', ref c} => (), + Struct{a: 10, b: 'X', ref mut c} => (), + Struct{a: 10, b: 'X', c: _} => (), + Struct{a: _, b: _, c: _} => (), +} +``` + +The `ref` and/or `mut` _IDENTIFIER_ syntax matches any value and binds it to +a variable with the same name as the given field. + +```rust +# struct Struct { +# a: i32, +# b: char, +# c: bool, +# } +# let struct_value = Struct{a: 10, b: 'X', c: false}; +# +let Struct{a: x, b: y, c: z} = struct_value; // destructure all fields +``` + +A struct pattern is refutable when one of its subpatterns is refutable. + +## Tuple struct patterns + +> **Syntax**\ +> _TupleStructPattern_ :\ +>    [_PathInExpression_] `(` _TupleStructItems_ `)` +> +> _TupleStructItems_ :\ +>       [_Pattern_] ( `,` [_Pattern_] )\* `,`?\ +>    | ([_Pattern_] `,`)\* `..` ( (`,` [_Pattern_])+ `,`? )? + +Tuple struct patterns match tuple struct and enum values that match all criteria defined +by its subpatterns. They are also used to [destructure](#destructuring) a tuple struct or +enum value. + +A tuple struct pattern is refutable when one of its subpatterns is refutable. + +## Tuple patterns + +> **Syntax**\ +> _TuplePattern_ :\ +>    `(` _TuplePatternItems_? `)` +> +> _TuplePatternItems_ :\ +>       [_Pattern_] `,`\ +>    | [_Pattern_] (`,` [_Pattern_])+ `,`?\ +>    | ([_Pattern_] `,`)\* `..` ( (`,` [_Pattern_])+ `,`? )? + +Tuple patterns match tuple values that match all criteria defined by its subpatterns. +They are also used to [destructure](#destructuring) a tuple. + +This pattern is refutable when one of its subpatterns is refutable. + +## Grouped patterns + +> **Syntax**\ +> _GroupedPattern_ :\ +>    `(` [_Pattern_] `)` + +Enclosing a pattern in parentheses can be used to explicitly control the +precedence of compound patterns. For example, a reference pattern next to a +range pattern such as `&0..=5` is ambiguous and is not allowed, but can be +expressed with parentheses. + +```rust +let int_reference = &3; +match int_reference { + &(0..=5) => (), + _ => (), +} +``` + +## Slice patterns + +> **Syntax**\ +> _SlicePattern_ :\ +>    `[` [_Pattern_] \(`,` [_Pattern_])\* `,`? `]` + +Slice patterns can match both arrays of fixed size and slices of dynamic size. +```rust +// Fixed size +let arr = [1, 2, 3]; +match arr { + [1, _, _] => "starts with one", + [a, b, c] => "starts with something else", +}; +``` +```rust +// Dynamic size +let v = vec![1, 2, 3]; +match v[..] { + [a, b] => { /* this arm will not apply because the length doesn't match */ } + [a, b, c] => { /* this arm will apply */ } + _ => { /* this wildcard is required, since the length is not known statically */ } +}; +``` + +## Path patterns + +> **Syntax**\ +> _PathPattern_ :\ +>       [_PathInExpression_]\ +>    | [_QualifiedPathInExpression_] + +_Path patterns_ are patterns that refer either to constant values or +to structs or enum variants that have no fields. + +Unqualified path patterns can refer to: + +* enum variants +* structs +* constants +* associated constants + +Qualified path patterns can only refer to associated constants. + +Constants cannot be a union type. Struct and enum constants must have +`#[derive(PartialEq, Eq)]` (not merely implemented). + +Path patterns are irrefutable when they refer to structs or an enum variant when the enum +has only one variant or a constant whose type is irrefutable. They are refutable when they +refer to refutable constants or enum variants for enums with multiple variants. + +[_GroupedPattern_]: #grouped-patterns +[_IdentifierPattern_]: #identifier-patterns +[_LiteralPattern_]: #literal-patterns +[_MacroInvocation_]: macros.html#macro-invocation +[_PathInExpression_]: paths.html#paths-in-expressions +[_PathPattern_]: #path-patterns +[_Pattern_]: #patterns +[_QualifiedPathInExpression_]: paths.html#qualified-paths +[_RangePattern_]: #range-patterns +[_ReferencePattern_]: #reference-patterns +[_SlicePattern_]: #slice-patterns +[_StructPattern_]: #struct-patterns +[_TuplePattern_]: #tuple-patterns +[_TupleStructPattern_]: #tuple-struct-patterns +[_WildcardPattern_]: #wildcard-pattern + +[`Copy`]: special-types-and-traits.html#copy +[IDENTIFIER]: identifiers.html +[enums]: items/enumerations.html +[literals]: expressions/literal-expr.html +[structs]: items/structs.html +[tuples]: types/tuple.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/procedural-macros.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/procedural-macros.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/procedural-macros.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/procedural-macros.md 2018-12-04 23:42:54.000000000 +0000 @@ -15,7 +15,7 @@ `proc-macro`. > **Note**: When using Cargo, Procedural macro crates are defined with the -> `proc-macro` key in your manfiest: +> `proc-macro` key in your manifest: > > ```toml > [lib] @@ -38,7 +38,7 @@ ### The `proc_macro` crate -Procedural macro crates almost always will link to the compiler-provided +Procedural macro crates almost always will link to the compiler-provided [`proc_macro` crate]. The `proc_macro` crate provides types required for writing procedural macros and facilities to make it easier. @@ -114,7 +114,7 @@ ### Derive mode macros *Derive mode macros* define new modes for the `derive` [attribute]. These macros -define new [items] given the token stream of a [struct], [enum], or [union]. +define new [items] given the token stream of a [struct], [enum], or [union]. They also define [derive mode helper attributes]. Custom deriver modes are defined by a [public] [function] with the @@ -195,7 +195,7 @@ *Attribute macros* define new [attributes] which can be attached to [items]. Attribute macros are defined by a [public] [function] with the -`proc_macro_attribute` [attribute] that a signature of +`proc_macro_attribute` [attribute] that a signature of `(TokenStream, TokenStream) -> TokenStream`. The first [`TokenStream`] is the attribute's metaitems, not including the delimiters. If the attribute is written without a metaitem, the attribute [`TokenStream`] is empty. The second @@ -228,9 +228,9 @@ # use proc_macro::TokenStream; #[proc_macro_attribute] -pub fn show_streams(attr: TokenStream, input: TokenStream) -> TokenStream { +pub fn show_streams(attr: TokenStream, item: TokenStream) -> TokenStream { println!("attr: \"{}\"", attr.to_string()); - println!("item: \"{}\"', input.to_string()); + println!("item: \"{}\"", item.to_string()); item } ``` @@ -259,7 +259,7 @@ // out: attr: "multiple words" // out: item: "fn invoke3() {}" -// Example: +// Example: #[show_streams { delimiters }] fn invoke4() {} // out: "delimiters" @@ -277,6 +277,7 @@ [Function-like macros]: #function-like-procedural-macros [attribute]: attributes.html [attributes]: attributes.html +[block]: expressions/block-expr.html [custom attributes]: attributes.html [crate type]: linkage.html [derive mode helper attributes]: #derive-mode-helper-attributes @@ -292,4 +293,4 @@ [procedural macro tutorial]: ../book/2018-edition/appendix-04-macros.html#procedural-macros-for-custom-derive [public]: visibility-and-privacy.html [struct]: items/structs.html -[unions]: items/unions.html +[union]: items/unions.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/special-types-and-traits.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/special-types-and-traits.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/special-types-and-traits.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/special-types-and-traits.md 2018-12-04 23:42:54.000000000 +0000 @@ -139,29 +139,29 @@ [`UnwindSafe`]: ../std/panic/trait.UnwindSafe.html [`Sync`]: ../std/marker/trait.Sync.html -[Arrays]: types.html#array-and-slice-types +[Arrays]: types/array.html [call expressions]: expressions/call-expr.html [deref coercions]: type-coercions.html#coercion-types [dereference operator]: expressions/operator-expr.html#the-dereference-operator [destructor]: destructors.html [drop check]: ../nomicon/dropck.html [dynamically sized type]: dynamically-sized-types.html -[Function pointers]: types.html#function-pointer-types -[function item types]: types.html#function-item-types +[Function pointers]: types/function-pointer.html +[function item types]: types/function-item.html [implementation items]: items/implementations.html [indexing expressions]: expressions/array-expr.html#array-and-slice-indexing-expressions [interior mutability]: interior-mutability.html -[Numeric types]: types.html#numeric-types +[Numeric types]: types/numeric.html [Methods]: items/associated-items.html#associated-functions-and-methods [method resolution]: expressions/method-call-expr.html [operators]: expressions/operator-expr.html [orphan rules]: items/implementations.html#trait-implementation-coherence -[Raw pointers]: types.html#raw-pointers-const-and-mut +[Raw pointers]: types/pointer.html#raw-pointers-const-and-mut [`static` items]: items/static-items.html -[Shared references]: types.html#shared-references- +[Shared references]: types/pointer.html#shared-references- [the standard library]: ../std/index.html -[trait object]: types.html#trait-objects -[Tuples]: types.html#tuple-types -[Type parameters]: types.html#type-parameters +[trait object]: types/trait-object.html +[Tuples]: types/tuple.html +[Type parameters]: types/parameters.html [variance]: subtyping.html#variance -[`!`]: types.html#never-type +[`!`]: types/never.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/statements.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/statements.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/statements.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/statements.md 2018-12-04 23:42:54.000000000 +0000 @@ -1,5 +1,14 @@ # Statements +> **Syntax**\ +> _Statement_ :\ +>       `;`\ +>    | [_Item_]\ +>    | [_LetStatement_]\ +>    | [_ExpressionStatement_]\ +>    | [_MacroInvocationSemi_] + + A *statement* is a component of a [block], which is in turn a component of an outer [expression] or [function]. @@ -42,7 +51,12 @@ ### `let` statements -A *`let` statement* introduces a new set of [variables], given by a pattern. The +> **Syntax**\ +> _LetStatement_ :\ +>    [_OuterAttribute_]\* `let` [_Pattern_] +> ( `:` [_Type_] )? (`=` [_Expression_] )? `;` + +A *`let` statement* introduces a new set of [variables], given by a [pattern]. The pattern is followed optionally by a type annotation and then optionally by an initializer expression. When no type annotation is given, the compiler will infer the type, or signal an error if insufficient type information is @@ -52,6 +66,11 @@ ## Expression statements +> **Syntax**\ +> _ExpressionStatement_ :\ +>       [_ExpressionWithoutBlock_][expression] `;`\ +>    | [_ExpressionWithBlock_][expression] + An *expression statement* is one that evaluates an [expression] and ignores its result. As a rule, an expression statement's purpose is to trigger the effects of evaluating its expression. @@ -60,7 +79,8 @@ expression, if used in a context where a statement is permitted, can omit the trailing semicolon. This can cause an ambiguity between it being parsed as a standalone statement and as a part of another expression; in this case, it is -parsed as a statement. +parsed as a statement. The type of [_ExpressionWithBlock_][expression] +expressions when used as statements must be the unit type. ```rust # let mut v = vec![1, 2, 3]; @@ -106,3 +126,12 @@ [outer attributes]: attributes.html [`cfg`]: conditional-compilation.html [the lint check attributes]: attributes.html#lint-check-attributes +[pattern]: patterns.html +[_ExpressionStatement_]: #expression-statements +[_Expression_]: expressions.html +[_Item_]: items.html +[_LetStatement_]: #let-statements +[_MacroInvocationSemi_]: macros.html#macro-invocation +[_OuterAttribute_]: attributes.html +[_Pattern_]: patterns.html +[_Type_]: types.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/subtyping.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/subtyping.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/subtyping.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/subtyping.md 2018-12-04 23:42:54.000000000 +0000 @@ -83,7 +83,7 @@ ``` [coercions]: type-coercions.html -[function pointers]: types.html#function-pointer-types +[function pointers]: types/function-pointer.html [Higher-ranked]: ../nomicon/hrtb.html -[lifetime bound]: types.html#trait-object-lifetime-bounds -[trait objects]: types.html#trait-objects +[lifetime bound]: types/trait-object.html#trait-object-lifetime-bounds +[trait objects]: types/trait-object.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/SUMMARY.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/SUMMARY.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/SUMMARY.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/SUMMARY.md 2018-12-04 23:42:54.000000000 +0000 @@ -63,8 +63,28 @@ - [Match expressions](expressions/match-expr.md) - [Return expressions](expressions/return-expr.md) +- [Patterns](patterns.md) + - [Type system](type-system.md) - [Types](types.md) + - [Boolean type](types/boolean.md) + - [Numeric types](types/numeric.md) + - [Textual types](types/textual.md) + - [Never type](types/never.md) + - [Tuple types](types/tuple.md) + - [Array types](types/array.md) + - [Slice types](types/slice.md) + - [Struct types](types/struct.md) + - [Enumerated types](types/enum.md) + - [Union types](types/union.md) + - [Function item types](types/function-item.md) + - [Closure types](types/closure.md) + - [Pointer types](types/pointer.md) + - [Function pointer types](types/function-pointer.md) + - [Trait object types](types/trait-object.md) + - [Impl trait type](types/impl-trait.md) + - [Type parameters](types/parameters.md) + - [Inferred type](types/inferred.md) - [Dynamically Sized Types](dynamically-sized-types.md) - [Type layout](type-layout.md) - [Interior mutability](interior-mutability.md) @@ -89,6 +109,8 @@ - [Behavior considered undefined](behavior-considered-undefined.md) - [Behavior not considered unsafe](behavior-not-considered-unsafe.md) +- [Constant Evaluation](const_eval.md) + [Appendix: Influences](influences.md) [Appendix: As-yet-undocumented Features](undocumented.md) diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/tokens.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/tokens.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/tokens.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/tokens.md 2018-12-04 23:42:54.000000000 +0000 @@ -21,7 +21,7 @@ A literal is an expression consisting of a single token, rather than a sequence of tokens, that immediately and directly denotes the value it evaluates to, rather than referring to it by name or some other evaluation rule. A literal is -a form of [constant expression](expressions.html#constant-expressions), so is +a form of [constant expression](const_eval.html#constant-expressions), so is evaluated (primarily) at compile time. ### Examples @@ -483,7 +483,7 @@ The representation semantics of floating-point numbers are described in ["Machine Types"]. -["Machine Types"]: types.html#machine-types +["Machine Types"]: types/numeric.html ### Boolean literals @@ -524,9 +524,9 @@ | `%` | Percent | [Remainder][arith] | `^` | Caret | [Bitwise and Logical XOR][arith] | `!` | Not | [Bitwise and Logical NOT][negation], [Macro Calls][macros], [Inner Attributes][attributes], [Never Type] -| `&` | And | [Bitwise and Logcal AND][arith], [Borrow], [References] +| `&` | And | [Bitwise and Logical AND][arith], [Borrow], [References], [Reference patterns] | \| | Or | [Bitwise and Logical OR][arith], [Closures], [Match] -| `&&` | AndAnd | [Lazy AND][lazy-bool], [Borrow], [References] +| `&&` | AndAnd | [Lazy AND][lazy-bool], [Borrow], [References], [Reference patterns] | \|\| | OrOr | [Lazy OR][lazy-bool], [Closures] | `<<` | Shl | [Shift Left][arith], [Nested Generics][generics] | `>>` | Shr | [Shift Right][arith], [Nested Generics][generics] @@ -547,12 +547,12 @@ | `<` | Lt | [Less than][comparison], [Generics], [Paths] | `>=` | Ge | [Greater than or equal to][comparison], [Generics] | `<=` | Le | [Less than or equal to][comparison] -| `@` | At | [Subpattern binding][match] -| `_` | Underscore | [Placeholder patterns][match], Inferred types +| `@` | At | [Subpattern binding] +| `_` | Underscore | [Wildcard patterns], [Inferred types] | `.` | Dot | [Field access][field], [Tuple index] -| `..` | DotDot | [Range][range], [Struct expressions], [Wildcard patterns][match] -| `...` | DotDotDot | [Variadic functions][extern] -| `..=` | DotDotEq | [Inclusive Range][range] +| `..` | DotDot | [Range][range], [Struct expressions], [Patterns] +| `...` | DotDotDot | [Variadic functions][extern], [Range patterns] +| `..=` | DotDotEq | [Inclusive Range][range], [Range patterns] | `,` | Comma | Various separators | `;` | Semi | Terminator for various items and statements, [Array types] | `:` | Colon | Various separators @@ -576,38 +576,44 @@ | `(` `)` | Parentheses | +[Inferred types]: types/inferred.html [Operator expressions]: expressions/operator-expr.html -[tokens]: #tokens -[keywords]: keywords.html -[identifier]: identifiers.html -[tuples]: types.html#tuple-types -[tuple structs]: items/structs.html -[tuple variants]: items/enumerations.html +[Range patterns]: patterns.html#range-patterns +[Reference patterns]: patterns.html#reference-patterns +[Subpattern binding]: patterns.html#identifier-patterns +[Wildcard patterns]: patterns.html#wildcard-pattern [arith]: expressions/operator-expr.html#arithmetic-and-logical-binary-operators -[negation]: expressions/operator-expr.html#negation-operators -[lazy-bool]: expressions/operator-expr.html#lazy-boolean-operators -[compound]: expressions/operator-expr.html#compound-assignment-expressions -[comparison]: expressions/operator-expr.html#comparison-operators -[match]: expressions/match-expr.html -[field]: expressions/field-expr.html -[range]: expressions/range-expr.html -[trait bounds]: trait-bounds.html -[dereference]: expressions/operator-expr.html#the-dereference-operator -[raw pointers]: types.html#raw-pointers-const-and-mut -[macros]: macros-by-example.html +[array types]: types/array.html +[assignment]: expressions/operator-expr.html#assignment-expressions [attributes]: attributes.html -[never type]: types.html#never-type [borrow]: expressions/operator-expr.html#borrow-operators -[references]: types.html#pointer-types [closures]: expressions/closure-expr.html -[assignment]: expressions/operator-expr.html#assignment-expressions +[comparison]: expressions/operator-expr.html#comparison-operators +[compound]: expressions/operator-expr.html#compound-assignment-expressions [constant items]: items/constant-items.html +[dereference]: expressions/operator-expr.html#the-dereference-operator +[extern]: items/external-blocks.html +[field]: expressions/field-expr.html +[functions]: items/functions.html [generics]: items/generics.html +[identifier]: identifiers.html +[keywords]: keywords.html +[lazy-bool]: expressions/operator-expr.html#lazy-boolean-operators +[macros]: macros-by-example.html +[match]: expressions/match-expr.html +[negation]: expressions/operator-expr.html#negation-operators +[never type]: types/never.html [paths]: paths.html -[array types]: types.html#array-and-slice-types -[functions]: items/functions.html +[patterns]: patterns.html [question]: expressions/operator-expr.html#the-question-mark-operator +[range]: expressions/range-expr.html +[raw pointers]: types/pointer.html#raw-pointers-const-and-mut +[references]: types/pointer.html [sized]: trait-bounds.html#sized -[extern]: items/external-blocks.html [struct expressions]: expressions/struct-expr.html +[tokens]: #tokens +[trait bounds]: trait-bounds.html [tuple index]: expressions/tuple-expr.html#tuple-indexing-expressions +[tuple structs]: items/structs.html +[tuple variants]: items/enumerations.html +[tuples]: types/tuple.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/trait-bounds.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/trait-bounds.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/trait-bounds.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/trait-bounds.md 2018-12-04 23:42:54.000000000 +0000 @@ -9,9 +9,9 @@ > > _TraitBound_ :\ >       `?`? -> [_ForLifetimes_](#higher-ranked-trait-bounds)? [_TraitPath_]\ +> [_ForLifetimes_](#higher-ranked-trait-bounds)? [_TypePath_]\ >    | `(` `?`? -> [_ForLifetimes_](#higher-ranked-trait-bounds)? [_TraitPath_] `)` +> [_ForLifetimes_](#higher-ranked-trait-bounds)? [_TypePath_] `)` > > _LifetimeBounds_ :\ >    ( _Lifetime_ `+` )\* _Lifetime_? @@ -123,8 +123,8 @@ ``` Higher-ranked lifetimes may also be specified just before the trait, the only -end of the following trait instead of the whole bound. This function is difference is the scope of the lifetime parameter, which extends only to the +end of the following trait instead of the whole bound. This function is equivalent to the last one. ```rust @@ -135,12 +135,12 @@ ``` [LIFETIME_OR_LABEL]: tokens.html#lifetimes-and-loop-labels -[_TraitPath_]: paths.html +[_TypePath_]: paths.html#paths-in-types [`Sized`]: special-types-and-traits.html#sized [associated types]: items/associated-items.html#associated-types [supertraits]: items/traits.html#supertraits [generic]: items/generics.html [Trait]: items/traits.html#trait-bounds -[trait objects]: types.html#trait-objects +[trait objects]: types/trait-object.html [where clause]: items/generics.html#where-clauses diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/type-layout.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/type-layout.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/type-layout.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/type-layout.md 2018-12-04 23:42:54.000000000 +0000 @@ -86,6 +86,9 @@ > Note: This is about the raw `[T]` type, not pointers (`&[T]`, `Box<[T]>`, > etc.) to slices. +## `str` Layout +String slices are a UTF-8 representation of characters that have the same layout as slices of type `[u8]`. + ## Tuple Layout Tuples do not have any guarantees about their layout. @@ -144,7 +147,7 @@ ### The `C` Representation The `C` representation is designed for dual purposes. One purpose is for -creating types that are interoptable with the C Language. The second purpose is +creating types that are interoperable with the C Language. The second purpose is to create types that you can soundly performing operations that rely on data layout such as reinterpreting values as a different type. diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/array.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/array.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/array.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/array.md 2018-12-04 23:42:54.000000000 +0000 @@ -0,0 +1,30 @@ +# Array types + +> **Syntax**\ +> _ArrayType_ :\ +>    `[` [_Type_] `;` [_Expression_] `]` + +An array is a fixed-size sequence of `N` elements of type `T`. The array type +is written as `[T; N]`. The size is an expression that evaluates to a +[`usize`]. + +Examples: + +```rust +// A stack-allocated array +let array: [i32; 3] = [1, 2, 3]; + +// A heap-allocated array, coerced to a slice +let boxed_array: Box<[i32]> = Box::new([1, 2, 3]); +``` + +All elements of arrays are always initialized, and access to an array is +always bounds-checked in safe methods and operators. + +> Note: The [`Vec`] standard library type provides a heap-allocated resizable +> array type. + +[_Expression_]: expressions.html +[_Type_]: types.html#type-expressions +[`Vec`]: ../std/vec/struct.Vec.html +[`usize`]: types/numeric.html#machine-dependent-integer-types diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/boolean.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/boolean.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/boolean.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/boolean.md 2018-12-04 23:42:54.000000000 +0000 @@ -0,0 +1,17 @@ +# Boolean type + +The `bool` type is a datatype which can be either `true` or `false`. The boolean +type uses one byte of memory. It is used in comparisons and bitwise operations +like `&`, `|`, and `!`. + +```rust +fn main() { + let x = true; + let y: bool = false; // with the boolean type annotation + + // Use of booleans in conditional expressions + if x { + println!("x is true"); + } +} +``` diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/closure.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/closure.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/closure.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/closure.md 2018-12-04 23:42:54.000000000 +0000 @@ -0,0 +1,177 @@ +# Closure types + +A [closure expression] produces a closure value with a unique, anonymous type +that cannot be written out. A closure type is approximately equivalent to a +struct which contains the captured variables. For instance, the following +closure: + +```rust +fn f String> (g: F) { + println!("{}", g()); +} + +let mut s = String::from("foo"); +let t = String::from("bar"); + +f(|| { + s += &*t; + s +}); +// Prints "foobar". +``` + +generates a closure type roughly like the following: + +```rust,ignore +struct Closure<'a> { + s : String, + t : &'a String, +} + +impl<'a> (FnOnce() -> String) for Closure<'a> { + fn call_once(self) -> String { + self.s += &*self.t; + self.s + } +} +``` + +so that the call to `f` works as if it were: + +```rust,ignore +f(Closure{s: s, t: &t}); +``` + +## Capture modes + +The compiler prefers to capture a closed-over variable by immutable borrow, +followed by unique immutable borrow (see below), by mutable borrow, and finally +by move. It will pick the first choice of these that allows the closure to +compile. The choice is made only with regards to the contents of the closure +expression; the compiler does not take into account surrounding code, such as +the lifetimes of involved variables. + +If the `move` keyword is used, then all captures are by move or, for `Copy` +types, by copy, regardless of whether a borrow would work. The `move` keyword is +usually used to allow the closure to outlive the captured values, such as if the +closure is being returned or used to spawn a new thread. + +Composite types such as structs, tuples, and enums are always captured entirely, +not by individual fields. It may be necessary to borrow into a local variable in +order to capture a single field: + +```rust +# use std::collections::HashSet; +# +struct SetVec { + set: HashSet, + vec: Vec +} + +impl SetVec { + fn populate(&mut self) { + let vec = &mut self.vec; + self.set.iter().for_each(|&n| { + vec.push(n); + }) + } +} +``` + +If, instead, the closure were to use `self.vec` directly, then it would attempt +to capture `self` by mutable reference. But since `self.set` is already +borrowed to iterate over, the code would not compile. + +## Unique immutable borrows in captures + +Captures can occur by a special kind of borrow called a _unique immutable +borrow_, which cannot be used anywhere else in the language and cannot be +written out explicitly. It occurs when modifying the referent of a mutable +reference, as in the following example: + +```rust +let mut b = false; +let x = &mut b; +{ + let mut c = || { *x = true; }; + // The following line is an error: + // let y = &x; + c(); +} +let z = &x; +``` + +In this case, borrowing `x` mutably is not possible, because `x` is not `mut`. +But at the same time, borrowing `x` immutably would make the assignment illegal, +because a `& &mut` reference may not be unique, so it cannot safely be used to +modify a value. So a unique immutable borrow is used: it borrows `x` immutably, +but like a mutable borrow, it must be unique. In the above example, uncommenting +the declaration of `y` will produce an error because it would violate the +uniqueness of the closure's borrow of `x`; the declaration of z is valid because +the closure's lifetime has expired at the end of the block, releasing the borrow. + +## Call traits and coercions + +Closure types all implement [`FnOnce`], indicating that they can be called once +by consuming ownership of the closure. Additionally, some closures implement +more specific call traits: + +* A closure which does not move out of any captured variables implements + [`FnMut`], indicating that it can be called by mutable reference. + +* A closure which does not mutate or move out of any captured variables + implements [`Fn`], indicating that it can be called by shared reference. + +> Note: `move` closures may still implement [`Fn`] or [`FnMut`], even though +> they capture variables by move. This is because the traits implemented by a +> closure type are determined by what the closure does with captured values, +> not how it captures them. + +*Non-capturing closures* are closures that don't capture anything from their +environment. They can be coerced to function pointers (`fn`) with the matching +signature. + +```rust +let add = |x, y| x + y; + +let mut x = add(5,7); + +type Binop = fn(i32, i32) -> i32; +let bo: Binop = add; +x = bo(5,7); +``` + +## Other traits + +All closure types implement [`Sized`]. Additionally, closure types implement the +following traits if allowed to do so by the types of the captures it stores: + +* [`Clone`] +* [`Copy`] +* [`Sync`] +* [`Send`] + +The rules for [`Send`] and [`Sync`] match those for normal struct types, while +[`Clone`] and [`Copy`] behave as if [derived]. For [`Clone`], the order of +cloning of the captured variables is left unspecified. + +Because captures are often by reference, the following general rules arise: + +* A closure is [`Sync`] if all captured variables are [`Sync`]. +* A closure is [`Send`] if all variables captured by non-unique immutable + reference are [`Sync`], and all values captured by unique immutable or mutable + reference, copy, or move are [`Send`]. +* A closure is [`Clone`] or [`Copy`] if it does not capture any values by + unique immutable or mutable reference, and if all values it captures by copy + or move are [`Clone`] or [`Copy`], respectively. + +[`Clone`]: special-types-and-traits.html#clone +[`Copy`]: special-types-and-traits.html#copy +[`FnMut`]: ../std/ops/trait.FnMut.html +[`FnOnce`]: ../std/ops/trait.FnOnce.html +[`Fn`]: ../std/ops/trait.Fn.html +[`Send`]: special-types-and-traits.html#send +[`Sized`]: special-types-and-traits.html#sized +[`Sync`]: special-types-and-traits.html#sync +[closure expression]: expressions/closure-expr.html +[derived]: attributes.html#derive diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/enum.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/enum.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/enum.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/enum.md 2018-12-04 23:42:54.000000000 +0000 @@ -0,0 +1,23 @@ +# Enumerated types + +An *enumerated type* is a nominal, heterogeneous disjoint union type, denoted +by the name of an [`enum` item]. [^enumtype] + +An [`enum` item] declares both the type and a number of *variants*, each of +which is independently named and has the syntax of a struct, tuple struct or +unit-like struct. + +New instances of an `enum` can be constructed in an [enumeration variant +expression]. + +Any `enum` value consumes as much memory as the largest variant for its +corresponding `enum` type, as well as the size needed to store a discriminant. + +Enum types cannot be denoted *structurally* as types, but must be denoted by +named reference to an [`enum` item]. + +[^enumtype]: The `enum` type is analogous to a `data` constructor declaration in + ML, or a *pick ADT* in Limbo. + +[`enum` item]: items/enumerations.html +[enumeration variant expression]: expressions/enum-variant-expr.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/function-item.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/function-item.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/function-item.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/function-item.md 2018-12-04 23:42:54.000000000 +0000 @@ -0,0 +1,57 @@ +# Function item types + +When referred to, a function item, or the constructor of a tuple-like struct or +enum variant, yields a zero-sized value of its _function item type_. That type +explicitly identifies the function - its name, its type arguments, and its +early-bound lifetime arguments (but not its late-bound lifetime arguments, +which are only assigned when the function is called) - so the value does not +need to contain an actual function pointer, and no indirection is needed when +the function is called. + +There is no syntax that directly refers to a function item type, but the +compiler will display the type as something like `fn(u32) -> i32 {fn_name}` in +error messages. + +Because the function item type explicitly identifies the function, the item +types of different functions - different items, or the same item with different +generics - are distinct, and mixing them will create a type error: + +```rust,compile_fail,E0308 +fn foo() { } +let x = &mut foo::; +*x = foo::; //~ ERROR mismatched types +``` + +However, there is a [coercion] from function items to [function pointers] with +the same signature, which is triggered not only when a function item is used +when a function pointer is directly expected, but also when different function +item types with the same signature meet in different arms of the same `if` or +`match`: + +```rust +# let want_i32 = false; +# fn foo() { } + +// `foo_ptr_1` has function pointer type `fn()` here +let foo_ptr_1: fn() = foo::; + +// ... and so does `foo_ptr_2` - this type-checks. +let foo_ptr_2 = if want_i32 { + foo:: +} else { + foo:: +}; +``` + +All function items implement [`Fn`], [`FnMut`], [`FnOnce`], [`Copy`], +[`Clone`], [`Send`], and [`Sync`]. + +[`Clone`]: special-types-and-traits.html#clone +[`Copy`]: special-types-and-traits.html#copy +[`FnMut`]: ../std/ops/trait.FnMut.html +[`FnOnce`]: ../std/ops/trait.FnOnce.html +[`Fn`]: ../std/ops/trait.Fn.html +[`Send`]: special-types-and-traits.html#send +[`Sync`]: special-types-and-traits.html#sync +[coercion]: type-coercions.html +[function pointers]: types/function-pointer.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/function-pointer.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/function-pointer.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/function-pointer.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/function-pointer.md 2018-12-04 23:42:54.000000000 +0000 @@ -0,0 +1,56 @@ +# Function pointer types + +> **Syntax**\ +> _BareFunctionType_ :\ +>    [_ForLifetimes_]? [_FunctionQualifiers_] `fn`\ +>       `(` _FunctionParametersMaybeNamedVariadic_? `)` _BareFunctionReturnType_? +> +> _BareFunctionReturnType_:\ +>    `->` [_TypeNoBounds_] +> +> _FunctionParametersMaybeNamedVariadic_ :\ +>    _MaybeNamedFunctionParameters_ | _MaybeNamedFunctionParametersVariadic_ +> +> _MaybeNamedFunctionParameters_ :\ +>    _MaybeNamedParam_ ( `,` _MaybeNamedParam_ )\* `,`? +> +> _MaybeNamedParam_ :\ +>    ( ( [IDENTIFIER] | `_` ) `:` )? [_Type_] +> +> _MaybeNamedFunctionParametersVariadic_ :\ +>    ( _MaybeNamedParam_ `,` )\* _MaybeNamedParam_ `,` `...` + +Function pointer types, written using the `fn` keyword, refer to a function +whose identity is not necessarily known at compile-time. They can be created +via a coercion from both [function items] and non-capturing [closures]. + +The `unsafe` qualifier indicates that the type's value is an [unsafe +function], and the `extern` qualifier indicates it is an [extern function]. + +Variadic parameters can only be specified with [`extern`] function types with +the `"C"` or `"cdecl"` calling convention. + +An example where `Binop` is defined as a function pointer type: + +```rust +fn add(x: i32, y: i32) -> i32 { + x + y +} + +let mut x = add(5,7); + +type Binop = fn(i32, i32) -> i32; +let bo: Binop = add; +x = bo(5,7); +``` + +[IDENTIFIER]: identifiers.html +[_ForLifetimes_]: items/generics.html#where-clauses +[_FunctionQualifiers_]: items/functions.html +[_TypeNoBounds_]: types.html#type-expressions +[_Type_]: types.html#type-expressions +[`extern`]: items/external-blocks.html +[closures]: types/closure.html +[extern function]: items/functions.html#extern-functions +[function items]: types/function-item.html +[unsafe function]: unsafe-functions.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/impl-trait.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/impl-trait.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/impl-trait.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/impl-trait.md 2018-12-04 23:42:54.000000000 +0000 @@ -0,0 +1,37 @@ +# Impl trait + +> **Syntax**\ +> _ImplTraitType_ : `impl` [_TypeParamBounds_] +> +> _ImplTraitTypeOneBound_ : `impl` [_TraitBound_] + +## Anonymous type parameters + +> Note: This section is a placeholder for more comprehensive reference +> material. + +> Note: This is often called "impl Trait in argument position". + +Functions can declare an argument to be an anonymous type parameter where the +callee must provide a type that has the bounds declared by the anonymous type +parameter and the function can only use the methods available by the trait +bounds of the anonymous type parameter. + +They are written as `impl` followed by a set of trait bounds. + +## Abstract return types + +> Note: This section is a placeholder for more comprehensive reference +> material. + +> Note: This is often called "impl Trait in return position". + +Functions, except for associated trait functions, can return an abstract +return type. These types stand in for another concrete type where the +use-site may only use the trait methods declared by the trait bounds of the +type. + +They are written as `impl` followed by a set of trait bounds. + +[_TraitBound_]: trait-bounds.html +[_TypeParamBounds_]: trait-bounds.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/inferred.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/inferred.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/inferred.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/inferred.md 2018-12-04 23:42:54.000000000 +0000 @@ -0,0 +1,18 @@ +# Inferred type + +> **Syntax**\ +> _InferredType_ : `_` + +The inferred type asks the compiler to infer the type if possible based on the +surrounding information available. It cannot be used in item signatures. It is +often used in generic arguments: + +```rust +let x: Vec<_> = (0..10).collect(); +``` + + diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/never.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/never.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/never.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/never.md 2018-12-04 23:42:54.000000000 +0000 @@ -0,0 +1,8 @@ +# Never type + +> **Syntax**\ +> _NeverType_ : `!` + +The never type `!` is a type with no values, representing the result of +computations that never complete. Expressions of type `!` can be coerced into +any other type. diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/numeric.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/numeric.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/numeric.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/numeric.md 2018-12-04 23:42:54.000000000 +0000 @@ -0,0 +1,40 @@ +# Numeric types + +## Integer types + +The unsigned integer types consist of: + +Type | Minimum | Maximum +-------|---------|------------------- +`u8` | 0 | 28-1 +`u16` | 0 | 216-1 +`u32` | 0 | 232-1 +`u64` | 0 | 264-1 +`u128` | 0 | 2128-1 + +The signed two's complement integer types consist of: + +Type | Minimum | Maximum +-------|--------------------|------------------- +`i8` | -(27) | 27-1 +`i16` | -(215) | 215-1 +`i32` | -(231) | 231-1 +`i64` | -(263) | 263-1 +`i128` | -(2127) | 2127-1 + + +## Floating-point types + +The IEEE 754-2008 "binary32" and "binary64" floating-point types are `f32` and +`f64`, respectively. + +## Machine-dependent integer types + +The `usize` type is an unsigned integer type with the same number of bits as the +platform's pointer type. It can represent every memory address in the process. + +The `isize` type is a signed integer type with the same number of bits as the +platform's pointer type. The theoretical upper bound on object and array size +is the maximum `isize` value. This ensures that `isize` can be used to calculate +differences between pointers into an object or array and can address every byte +within an object along with one byte past the end. diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/parameters.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/parameters.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/parameters.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/parameters.md 2018-12-04 23:42:54.000000000 +0000 @@ -0,0 +1,19 @@ +# Type parameters + +Within the body of an item that has type parameter declarations, the names of +its type parameters are types: + +```rust +fn to_vec(xs: &[A]) -> Vec
{ + if xs.is_empty() { + return vec![]; + } + let first: A = xs[0].clone(); + let mut rest: Vec = to_vec(&xs[1..]); + rest.insert(0, first); + rest +} +``` + +Here, `first` has type `A`, referring to `to_vec`'s `A` type parameter; and +`rest` has type `Vec`, a vector with element type `A`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/pointer.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/pointer.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/pointer.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/pointer.md 2018-12-04 23:42:54.000000000 +0000 @@ -0,0 +1,57 @@ +# Pointer types + +All pointers in Rust are explicit first-class values. They can be moved or +copied, stored into data structs, and returned from functions. + +## Shared references (`&`) + +> **Syntax**\ +> _ReferenceType_ :\ +>    `&` [_Lifetime_]? `mut`? [_TypeNoBounds_] + +These point to memory _owned by some other value_. When a shared reference to +a value is created it prevents direct mutation of the value. [Interior +mutability] provides an exception for this in certain circumstances. As the +name suggests, any number of shared references to a value may exit. A shared +reference type is written `&type`, or `&'a type` when you need to specify an +explicit lifetime. Copying a reference is a "shallow" operation: it involves +only copying the pointer itself, that is, pointers are `Copy`. Releasing a +reference has no effect on the value it points to, but referencing of a +[temporary value] will keep it alive during the scope of the reference itself. + +## Mutable references (`&mut`) + +These also point to memory owned by some other value. A mutable reference type +is written `&mut type` or `&'a mut type`. A mutable reference (that hasn't been +borrowed) is the only way to access the value it points to, so is not `Copy`. + +## Raw pointers (`*const` and `*mut`) + +> **Syntax**\ +> _RawPointerType_ :\ +>    `*` ( `mut` | `const` ) [_TypeNoBounds_] + +Raw pointers are pointers without safety or liveness guarantees. Raw pointers +are written as `*const T` or `*mut T`, for example `*const i32` means a raw +pointer to a 32-bit integer. Copying or dropping a raw pointer has no effect +on the lifecycle of any other value. Dereferencing a raw pointer is an +[`unsafe` operation], this can also be used to convert a raw pointer to a +reference by reborrowing it (`&*` or `&mut *`). Raw pointers are generally +discouraged in Rust code; they exist to support interoperability with foreign +code, and writing performance-critical or low-level functions. + +When comparing pointers they are compared by their address, rather than by +what they point to. When comparing pointers to [dynamically sized types] they +also have their addition data compared. + +## Smart Pointers + +The standard library contains additional 'smart pointer' types beyond references +and raw pointers. + +[Interior mutability]: interior-mutability.html +[_Lifetime_]: trait-bounds.html +[_TypeNoBounds_]: types.html#type-expressions +[`unsafe` operation]: unsafety.html +[dynamically sized types]: dynamically-sized-types.html +[temporary value]: expressions.html#temporary-lifetimes diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/slice.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/slice.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/slice.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/slice.md 2018-12-04 23:42:54.000000000 +0000 @@ -0,0 +1,32 @@ +# Slice types + +> **Syntax**\ +> _SliceType_ :\ +>    `[` [_Type_] `]` + +A slice is a [dynamically sized type] representing a 'view' into a sequence of +elements of type `T`. The slice type is written as `[T]`. + +To use a slice type it generally has to be used behind a pointer for example +as: + +* `&[T]`, a 'shared slice', often just called a 'slice', it doesn't own the + data it points to, it borrows it. +* `&mut [T]`, a 'mutable slice', mutably borrows the data it points to. +* `Box<[T]>`, a 'boxed slice' + +Examples: + +```rust +// A heap-allocated array, coerced to a slice +let boxed_array: Box<[i32]> = Box::new([1, 2, 3]); + +// A (shared) slice into an array +let slice: &[i32] = &boxed_array[..]; +``` + +All elements of slices are always initialized, and access to a slice is always +bounds-checked in safe methods and operators. + +[_Type_]: types.html#type-expressions +[dynamically sized type]: dynamically-sized-types.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/struct.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/struct.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/struct.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/struct.md 2018-12-04 23:42:54.000000000 +0000 @@ -0,0 +1,28 @@ +# Struct types + +A `struct` *type* is a heterogeneous product of other types, called the +*fields* of the type.[^structtype] + +New instances of a `struct` can be constructed with a [struct expression]. + +The memory layout of a `struct` is undefined by default to allow for compiler +optimizations like field reordering, but it can be fixed with the +`#[repr(...)]` attribute. In either case, fields may be given in any order in a +corresponding struct *expression*; the resulting `struct` value will always +have the same memory layout. + +The fields of a `struct` may be qualified by [visibility modifiers], to allow +access to data in a struct outside a module. + +A _tuple struct_ type is just like a struct type, except that the fields are +anonymous. + +A _unit-like struct_ type is like a struct type, except that it has no fields. +The one value constructed by the associated [struct expression] is the only +value that inhabits such a type. + +[^structtype]: `struct` types are analogous to `struct` types in C, the + *record* types of the ML family, or the *struct* types of the Lisp family. + +[struct expression]: expressions/struct-expr.html +[visibility modifiers]: visibility-and-privacy.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/textual.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/textual.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/textual.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/textual.md 2018-12-04 23:42:54.000000000 +0000 @@ -0,0 +1,16 @@ +# Textual types + +The types `char` and `str` hold textual data. + +A value of type `char` is a [Unicode scalar value] (i.e. a code point that +is not a surrogate), represented as a 32-bit unsigned word in the 0x0000 to +0xD7FF or 0xE000 to 0x10FFFF range. A `[char]` is effectively a UCS-4 / UTF-32 +string. + +A value of type `str` is a Unicode string, represented as an array of 8-bit +unsigned bytes holding a sequence of UTF-8 code points. Since `str` is a +[dynamically sized type], it is not a _first-class_ type, but can only be +instantiated through a pointer type, such as `&str`. + +[Unicode scalar value]: http://www.unicode.org/glossary/#unicode_scalar_value +[dynamically sized type]: dynamically-sized-types.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/trait-object.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/trait-object.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/trait-object.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/trait-object.md 2018-12-04 23:42:54.000000000 +0000 @@ -0,0 +1,114 @@ +# Trait objects + +> **Syntax**\ +> _TraitObjectType_ :\ +>    `dyn`? [_TypeParamBounds_] +> +> _TraitObjectTypeOneBound_ :\ +>    `dyn`? [_TraitBound_] + +A *trait object* is an opaque value of another type that implements a set of +traits. The set of traits is made up of an [object safe] *base trait* plus any +number of [auto traits]. + +Trait objects implement the base trait, its auto traits, and any [supertraits] +of the base trait. + +Trait objects are written as the optional keyword `dyn` followed by a set of +trait bounds, but with the following restrictions on the trait bounds. All +traits except the first trait must be auto traits, there may not be more than +one lifetime, and opt-out bounds (e.g. `?sized`) are not allowed. Furthermore, +paths to traits may be parenthesized. + +For example, given a trait `Trait`, the following are all trait objects: + +* `Trait` +* `dyn Trait` +* `dyn Trait + Send` +* `dyn Trait + Send + Sync` +* `dyn Trait + 'static` +* `dyn Trait + Send + 'static` +* `dyn Trait +` +* `dyn 'static + Trait`. +* `dyn (Trait)` + +> **Edition Differences**: In the 2015 edition, if the first bound of the +> trait object is a path that starts with `::`, then the `dyn` will be treated +> as a part of the path. The first path can be put in parenthesis to get +> around this. As such, if you want a trait object with the trait +> `::your_module::Trait`, you should write it as `dyn (::your_module::Trait)`. +> +> Beginning in the 2018 edition, `dyn` is a true keyword and is not allowed in +> paths, so the parentheses are not necessary. + +> Note: For clarity, it is recommended to always use the `dyn` keyword on your +> trait objects unless your codebase supports compiling with Rust 1.26 or lower. + +Two trait object types alias each other if the base traits alias each other and +if the sets of auto traits are the same and the lifetime bounds are the same. +For example, `dyn Trait + Send + UnwindSafe` is the same as +`dyn Trait + Unwindsafe + Send`. + +
+ +***Warning:*** With two trait object types, even when the complete set of traits +is the same, if the base traits differ, the type is different. For example, +`dyn Send + Sync` is a different type from `dyn Sync + Send`. See [issue 33140]. + +
+ +Due to the opaqueness of which concrete type the value is of, trait objects are +[dynamically sized types]. Like all +DSTs, trait objects are used +behind some type of pointer; for example `&dyn SomeTrait` or +`Box`. Each instance of a pointer to a trait object includes: + + - a pointer to an instance of a type `T` that implements `SomeTrait` + - a _virtual method table_, often just called a _vtable_, which contains, for + each method of `SomeTrait` and its [supertraits] that `T` implements, a + pointer to `T`'s implementation (i.e. a function pointer). + +The purpose of trait objects is to permit "late binding" of methods. Calling a +method on a trait object results in virtual dispatch at runtime: that is, a +function pointer is loaded from the trait object vtable and invoked indirectly. +The actual implementation for each vtable entry can vary on an object-by-object +basis. + +An example of a trait object: + +```rust +trait Printable { + fn stringify(&self) -> String; +} + +impl Printable for i32 { + fn stringify(&self) -> String { self.to_string() } +} + +fn print(a: Box) { + println!("{}", a.stringify()); +} + +fn main() { + print(Box::new(10) as Box); +} +``` + +In this example, the trait `Printable` occurs as a trait object in both the +type signature of `print`, and the cast expression in `main`. + +## Trait Object Lifetime Bounds + +Since a trait object can contain references, the lifetimes of those references +need to be expressed as part of the trait object. This lifetime is written as +`Trait + 'a`. There are [defaults] that allow this lifetime to usually be +inferred with a sensible choice. + +[_TraitBound_]: trait-bounds.html +[_TypeParamBounds_]: types.html#type-expressions +[auto traits]: special-types-and-traits.html#auto-traits +[defaults]: lifetime-elision.html#default-trait-object-lifetimes +[dynamically sized types]: dynamically-sized-types.html +[issue 33140]: https://github.com/rust-lang/rust/issues/33140 +[object safe]: items/traits.html#object-safety +[supertraits]: items/traits.html#supertraits diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/tuple.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/tuple.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/tuple.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/tuple.md 2018-12-04 23:42:54.000000000 +0000 @@ -0,0 +1,34 @@ +# Tuple types + +> **Syntax**\ +> _TupleType_ :\ +>       `(` `)`\ +>    | `(` ( [_Type_] `,` )+ [_Type_]? `)` + +A tuple *type* is a heterogeneous product of other types, called the *elements* +of the tuple. It has no nominal name and is instead structurally typed. + +Tuple types and values are denoted by listing the types or values of their +elements, respectively, in a parenthesized, comma-separated list. + +Because tuple elements don't have a name, they can only be accessed by +pattern-matching or by using `N` directly as a field to access the `N`th +element. + +An example of a tuple type and its use: + +```rust +type Pair<'a> = (i32, &'a str); +let p: Pair<'static> = (10, "ten"); +let (a, b) = p; + +assert_eq!(a, 10); +assert_eq!(b, "ten"); +assert_eq!(p.0, 10); +assert_eq!(p.1, "ten"); +``` + +For historical reasons and convenience, the tuple type with no elements (`()`) +is often called ‘unit’ or ‘the unit type’. + +[_Type_]: types.html#type-expressions diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/union.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/union.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types/union.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types/union.md 2018-12-04 23:42:54.000000000 +0000 @@ -0,0 +1,15 @@ +# Union types + +A *union type* is a nominal, heterogeneous C-like union, denoted by the name of +a [`union` item]. + +A union contains the value of any one of its fields. Since the accessing the +wrong field can cause unexpected or undefined behaviour, `unsafe` is required +to read from a union field or to write to a field that doesn't implement +[`Copy`]. + +The memory layout of a `union` is undefined by default, but the `#[repr(...)]` +attribute can be used to fix a layout. + +[`Copy`]: special-types-and-traits.html#copy +[`union` item]: items/unions.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types.md 2018-12-04 23:42:54.000000000 +0000 @@ -1,259 +1,109 @@ +{{#include types-redirect.html}} # Types Every variable, item and value in a Rust program has a type. The _type_ of a -*value* defines the interpretation of the memory holding it. +*value* defines the interpretation of the memory holding it and the operations +that may be performed on the value. Built-in types are tightly integrated into the language, in nontrivial ways that are not possible to emulate in user-defined types. User-defined types have limited capabilities. -## Primitive types +The list of types is: -Some types are defined by the language, rather than as part of the standard -library, these are called _primitive types_. Some of these are individual -types: - -* The [boolean type] `bool` with values `true` and `false`. -* The [machine types] (integer and floating-point). -* The [machine-dependent integer types]. -* The [textual types] `char` and `str`. -* The [never type] `!` - -There are also some primitive constructs for generic types built in to the -language: - -* [Tuples] -* [Arrays] -* [Slices] -* [Function pointers] -* [References] -* [Pointers] - -[boolean type]: #boolean-type -[machine types]: #machine-types -[machine-dependent integer types]: #machine-dependent-integer-types -[textual types]: #textual-types -[never type]: #never-type -[Tuples]: #tuple-types -[Arrays]: #array-and-slice-types -[Slices]: #array-and-slice-types -[References]: #pointer-types -[Pointers]: #raw-pointers-const-and-mut -[Function pointers]: #function-pointer-types -[function]: #function-types -[closure]: #closure-types - -### Boolean type - -The `bool` type is a datatype which can be either `true` or `false`. The boolean -type uses one byte of memory. It is used in comparisons and bitwise operations -like `&`, `|`, and `!`. +* Primitive types: + * [Boolean] — `true` or `false` + * [Numeric] — integer and float + * [Textual] — `char` and `str` + * [Never] — `!` — a type with no values +* Sequence types: + * [Tuple] + * [Array] + * [Slice] +* User-defined types: + * [Struct] + * [Enum] + * [Union] +* Function types: + * [Functions] + * [Closures] +* Pointer types: + * [References] + * [Raw pointers] + * [Function pointers] +* Trait types: + * [Trait objects] + * [Impl trait] + +## Type expressions + +> **Syntax**\ +> _Type_ :\ +>       _TypeNoBounds_\ +>    | [_ImplTraitType_]\ +>    | [_TraitObjectType_] +> +> _TypeNoBounds_ :\ +>       [_ParenthesizedType_]\ +>    | [_ImplTraitTypeOneBound_]\ +>    | [_TraitObjectTypeOneBound_]\ +>    | [_TypePath_]\ +>    | [_TupleType_]\ +>    | [_NeverType_]\ +>    | [_RawPointerType_]\ +>    | [_ReferenceType_]\ +>    | [_ArrayType_]\ +>    | [_SliceType_]\ +>    | [_InferredType_]\ +>    | [_QualifiedPathInType_]\ +>    | [_BareFunctionType_]\ +>    | [_MacroInvocation_] + +A _type expression_ as defined in the _Type_ grammar rule above is the syntax +for referring to a type. It may refer to: + +* Sequence types ([tuple], [array], [slice]). +* [Type paths] which can reference: + * Primitive types ([boolean], [numeric], [textual]). + * Paths to an [item] ([struct], [enum], [union], [type alias], [trait]). + * [`Self` path] where `Self` is the implementing type. + * Generic [type parameters]. +* Pointer types ([reference], [raw pointer], [function pointer]). +* The [inferred type] which asks the compiler to determine the type. +* [Parentheses] which are used for disambiguation. +* Trait types: [Trait objects] and [impl trait]. +* The [never] type. +* [Macros] which expand to a type expression. + +### Parenthesized types + +> _ParenthesizedType_ :\ +>    `(` [_Type_] `)` + +In some situations the combination of types may be ambiguous. Use parentheses +around a type to avoid ambiguity. For example, the `+` operator for [type +boundaries] within a [reference type] is unclear where the +boundary applies, so the use of parentheses is required. Grammar rules that +require this disambiguation use the [_TypeNoBounds_] rule instead of +[_Type_]. ```rust -fn main() { - let x = true; - let y: bool = false; // with the boolean type annotation - - // Use of booleans in conditional expressions - if x { - println!("x is true"); - } -} +# use std::any::Any; +type T<'a> = &'a (dyn Any + Send); ``` -## Numeric types - -### Machine types - -The machine types are the following: - -* The unsigned word types `u8`, `u16`, `u32`, `u64`, and `u128` with values - drawn from the integer intervals [0, 2^8 - 1], [0, 2^16 - 1], [0, 2^32 - 1], - [0, 2^64 - 1], and [0, 2^128 - 1] respectively. - -* The signed two's complement word types `i8`, `i16`, `i32`, `i64`, and `i128`, - with values drawn from the integer intervals [-(2^7), 2^7 - 1], - [-(2^15), 2^15 - 1], [-(2^31), 2^31 - 1], [-(2^63), 2^63 - 1], and - [-(2^127), 2^127 - 1] respectively. - -* The IEEE 754-2008 "binary32" and "binary64" floating-point types: `f32` and - `f64`, respectively. - -### Machine-dependent integer types - -The `usize` type is an unsigned integer type with the same number of bits as the -platform's pointer type. It can represent every memory address in the process. - -The `isize` type is a signed integer type with the same number of bits as the -platform's pointer type. The theoretical upper bound on object and array size -is the maximum `isize` value. This ensures that `isize` can be used to calculate -differences between pointers into an object or array and can address every byte -within an object along with one byte past the end. - -## Textual types - -The types `char` and `str` hold textual data. - -A value of type `char` is a [Unicode scalar value]( -http://www.unicode.org/glossary/#unicode_scalar_value) (i.e. a code point that -is not a surrogate), represented as a 32-bit unsigned word in the 0x0000 to -0xD7FF or 0xE000 to 0x10FFFF range. A `[char]` is effectively a UCS-4 / UTF-32 -string. - -A value of type `str` is a Unicode string, represented as an array of 8-bit -unsigned bytes holding a sequence of UTF-8 code points. Since `str` is a -[dynamically sized type], it is not a _first-class_ type, but can only be -instantiated through a pointer type, such as `&str`. - -## Never type - -The never type `!` is a type with no values, representing the result of -computations that never complete. Expressions of type `!` can be coerced into -any other type. - -## Tuple types - -A tuple *type* is a heterogeneous product of other types, called the *elements* -of the tuple. It has no nominal name and is instead structurally typed. - -Tuple types and values are denoted by listing the types or values of their -elements, respectively, in a parenthesized, comma-separated list. - -Because tuple elements don't have a name, they can only be accessed by -pattern-matching or by using `N` directly as a field to access the `N`th -element. - -An example of a tuple type and its use: - -```rust -type Pair<'a> = (i32, &'a str); -let p: Pair<'static> = (10, "ten"); -let (a, b) = p; - -assert_eq!(a, 10); -assert_eq!(b, "ten"); -assert_eq!(p.0, 10); -assert_eq!(p.1, "ten"); -``` - -For historical reasons and convenience, the tuple type with no elements (`()`) -is often called ‘unit’ or ‘the unit type’. - -## Array, and Slice types - -Rust has two different types for a list of items: - -* `[T; N]`, an 'array' -* `[T]`, a 'slice' - -An array has a fixed size, and can be allocated on either the stack or the -heap. - -A slice is a [dynamically sized type] representing a 'view' into an array. To -use a slice type it generally has to be used behind a pointer for example as - -* `&[T]`, a 'shared slice', often just called a 'slice', it doesn't own the - data it points to, it borrows it. -* `&mut [T]`, a 'mutable slice', mutably borrows the data it points to. -* `Box<[T]>`, a 'boxed slice' - -Examples: - -```rust -// A stack-allocated array -let array: [i32; 3] = [1, 2, 3]; - -// A heap-allocated array, coerced to a slice -let boxed_array: Box<[i32]> = Box::new([1, 2, 3]); - -// A (shared) slice into an array -let slice: &[i32] = &boxed_array[..]; -``` - -All elements of arrays and slices are always initialized, and access to an -array or slice is always bounds-checked in safe methods and operators. - -> Note: The [`Vec`] standard library type provides a heap-allocated resizable -> array type. - -## Struct types - -A `struct` *type* is a heterogeneous product of other types, called the -*fields* of the type.[^structtype] - -New instances of a `struct` can be constructed with a [struct -expression](expressions/struct-expr.html). - -The memory layout of a `struct` is undefined by default to allow for compiler -optimizations like field reordering, but it can be fixed with the -`#[repr(...)]` attribute. In either case, fields may be given in any order in a -corresponding struct *expression*; the resulting `struct` value will always -have the same memory layout. - -The fields of a `struct` may be qualified by [visibility -modifiers](visibility-and-privacy.html), to allow access to data in a struct -outside a module. - -A _tuple struct_ type is just like a struct type, except that the fields are -anonymous. - -A _unit-like struct_ type is like a struct type, except that it has no fields. -The one value constructed by the associated [struct expression] is the only -value that inhabits such a type. - -[^structtype]: `struct` types are analogous to `struct` types in C, the - *record* types of the ML family, or the *struct* types of the Lisp family. - -## Enumerated types - -An *enumerated type* is a nominal, heterogeneous disjoint union type, denoted -by the name of an [`enum` item](items/enumerations.html). [^enumtype] - -An [`enum` item](items/enumerations.html) declares both the type and a number -of *variants*, each of which is independently named and has the syntax of a -struct, tuple struct or unit-like struct. - -New instances of an `enum` can be constructed in an [enumeration variant -expression](expressions/enum-variant-expr.html). - -Any `enum` value consumes as much memory as the largest variant for its -corresponding `enum` type, as well as the size needed to store a discriminant. - -Enum types cannot be denoted *structurally* as types, but must be denoted by -named reference to an [`enum` item](items/enumerations.html). - -[^enumtype]: The `enum` type is analogous to a `data` constructor declaration in - ML, or a *pick ADT* in Limbo. - -## Union types - -A *union type* is a nominal, heterogeneous C-like union, denoted by the name of -a [`union` item](items/unions.html). - -A union contains the value of any one of its fields. Since the accessing the -wrong field can cause unexpected or undefined behaviour, `unsafe` is required -to read from a union field or to write to a field that doesn't implement -[`Copy`]. - -The memory layout of a `union` is undefined by default, but the `#[repr(...)]` -attribute can be used to fix a layout. - -[`Copy`]: special-types-and-traits.html#copy - ## Recursive types -Nominal types — [structs](#struct-types), -[enumerations](#enumerated-types) and [unions](#union-types) — may be -recursive. That is, each `enum` variant or `struct` or `union` field may refer, -directly or indirectly, to the enclosing `enum` or `struct` type itself. Such -recursion has restrictions: +Nominal types — [structs], [enumerations] and [unions] — may be +recursive. That is, each `enum` variant or `struct` or `union` field may +refer, directly or indirectly, to the enclosing `enum` or `struct` type +itself. Such recursion has restrictions: * Recursive types must include a nominal type in the recursion (not mere [type - definitions](../grammar.html#type-definitions), or other structural types - such as [arrays](#array-and-slice-types) or [tuples](#tuple-types)). So - `type Rec = &'static [Rec]` is not allowed. + aliases], or other structural types such as [arrays] or [tuples]). So `type + Rec = &'static [Rec]` is not allowed. * The size of a recursive type must be finite; in other words the recursive - fields of the type must be [pointer types](#pointer-types). + fields of the type must be [pointer types]. * Recursive type definitions can cross module boundaries, but not module *visibility* boundaries, or crate boundaries (in order to simplify the module system and type checker). @@ -269,495 +119,60 @@ let a: List = List::Cons(7, Box::new(List::Cons(13, Box::new(List::Nil)))); ``` -## Pointer types - -All pointers in Rust are explicit first-class values. They can be moved or -copied, stored into data structs, and returned from functions. - -### Shared references (`&`) - -These point to memory _owned by some other value_. When a shared reference to a -value is created it prevents direct mutation of the value. [Interior -mutability](interior-mutability.html) provides an exception for this in certain -circumstances. As the name suggests, any number of shared references to a value -may exit. A shared reference type is written `&type`, or `&'a type` when you -need to specify an explicit lifetime. Copying a reference is a "shallow" -operation: it involves only copying the pointer itself, that is, pointers are -`Copy`. Releasing a reference has no effect on the value it points to, but -referencing of a [temporary value](expressions.html#temporary-lifetimes) will -keep it alive during the scope of the reference itself. - -### Mutable references (`&mut`) - -These also point to memory owned by some other value. A mutable reference type -is written `&mut type` or `&'a mut type`. A mutable reference (that hasn't been -borrowed) is the only way to access the value it points to, so is not `Copy`. - -### Raw pointers (`*const` and `*mut`) - -Raw pointers are pointers without safety or liveness guarantees. Raw pointers -are written as `*const T` or `*mut T`, for example `*const i32` means a raw -pointer to a 32-bit integer. Copying or dropping a raw pointer has no effect on -the lifecycle of any other value. Dereferencing a raw pointer is an [`unsafe` -operation](unsafe-functions.html), this can also be used to convert a raw -pointer to a reference by reborrowing it (`&*` or `&mut *`). Raw pointers are -generally discouraged in Rust code; they exist to support interoperability with -foreign code, and writing performance-critical or low-level functions. - -When comparing pointers they are compared by their address, rather than by what -they point to. When comparing pointers to [dynamically sized -types](dynamically-sized-types.html) they also have their addition data -compared. - -### Smart Pointers - -The standard library contains additional 'smart pointer' types beyond references -and raw pointers. - -## Function item types - -When referred to, a function item, or the constructor of a tuple-like struct or -enum variant, yields a zero-sized value of its _function item type_. That type -explicitly identifies the function - its name, its type arguments, and its -early-bound lifetime arguments (but not its late-bound lifetime arguments, -which are only assigned when the function is called) - so the value does not -need to contain an actual function pointer, and no indirection is needed when -the function is called. - -There is no syntax that directly refers to a function item type, but the -compiler will display the type as something like `fn(u32) -> i32 {fn_name}` in -error messages. - -Because the function item type explicitly identifies the function, the item -types of different functions - different items, or the same item with different -generics - are distinct, and mixing them will create a type error: - -```rust,compile_fail,E0308 -fn foo() { } -let x = &mut foo::; -*x = foo::; //~ ERROR mismatched types -``` - -However, there is a [coercion] from function items to [function -pointers](#function-pointer-types) with the same signature, which is triggered -not only when a function item is used when a function pointer is directly -expected, but also when different function item types with the same signature -meet in different arms of the same `if` or `match`: - -[coercion]: type-coercions.html - -```rust -# let want_i32 = false; -# fn foo() { } - -// `foo_ptr_1` has function pointer type `fn()` here -let foo_ptr_1: fn() = foo::; - -// ... and so does `foo_ptr_2` - this type-checks. -let foo_ptr_2 = if want_i32 { - foo:: -} else { - foo:: -}; -``` - -All function items implement [`Fn`], [`FnMut`], [`FnOnce`], [`Copy`], -[`Clone`], [`Send`], and [`Sync`]. - -## Function pointer types - -Function pointer types, written using the `fn` keyword, refer to a function -whose identity is not necessarily known at compile-time. They can be created -via a coercion from both [function items](#function-item-types) and -non-capturing [closures](#closure-types). - -A function pointer type consists of a possibly-empty set of function-type -modifiers (such as `unsafe` or `extern`), a sequence of input types and an -output type. - -An example where `Binop` is defined as a function pointer type: - -```rust -fn add(x: i32, y: i32) -> i32 { - x + y -} - -let mut x = add(5,7); - -type Binop = fn(i32, i32) -> i32; -let bo: Binop = add; -x = bo(5,7); -``` - -## Closure types - -A [closure expression] produces a closure value with a unique, anonymous type -that cannot be written out. A closure type is approximately equivalent to a -struct which contains the captured variables. For instance, the following -closure: - -```rust -fn f String> (g: F) { - println!("{}", g()); -} - -let mut s = String::from("foo"); -let t = String::from("bar"); - -f(|| { - s += &*t; - s -}); -// Prints "foobar". -``` - -generates a closure type roughly like the following: - -```rust,ignore -struct Closure<'a> { - s : String, - t : &'a String, -} - -impl<'a> (FnOnce() -> String) for Closure<'a> { - fn call_once(self) -> String { - self.s += &*self.t; - self.s - } -} -``` - -so that the call to `f` works as if it were: - -```rust,ignore -f(Closure{s: s, t: &t}); -``` - -### Capture modes - -The compiler prefers to capture a closed-over variable by immutable borrow, -followed by unique immutable borrow (see below), by mutable borrow, and finally -by move. It will pick the first choice of these that allows the closure to -compile. The choice is made only with regards to the contents of the closure -expression; the compiler does not take into account surrounding code, such as -the lifetimes of involved variables. - -If the `move` keyword is used, then all captures are by move or, for `Copy` -types, by copy, regardless of whether a borrow would work. The `move` keyword is -usually used to allow the closure to outlive the captured values, such as if the -closure is being returned or used to spawn a new thread. - -Composite types such as structs, tuples, and enums are always captured entirely, -not by individual fields. It may be necessary to borrow into a local variable in -order to capture a single field: - -```rust -# use std::collections::HashSet; -# -struct SetVec { - set: HashSet, - vec: Vec -} - -impl SetVec { - fn populate(&mut self) { - let vec = &mut self.vec; - self.set.iter().for_each(|&n| { - vec.push(n); - }) - } -} -``` - -If, instead, the closure were to use `self.vec` directly, then it would attempt -to capture `self` by mutable reference. But since `self.set` is already -borrowed to iterate over, the code would not compile. - -### Unique immutable borrows in captures - -Captures can occur by a special kind of borrow called a _unique immutable -borrow_, which cannot be used anywhere else in the language and cannot be -written out explicitly. It occurs when modifying the referent of a mutable -reference, as in the following example: - -```rust -let mut b = false; -let x = &mut b; -{ - let mut c = || { *x = true; }; - // The following line is an error: - // let y = &x; - c(); -} -let z = &x; -``` - -In this case, borrowing `x` mutably is not possible, because `x` is not `mut`. -But at the same time, borrowing `x` immutably would make the assignment illegal, -because a `& &mut` reference may not be unique, so it cannot safely be used to -modify a value. So a unique immutable borrow is used: it borrows `x` immutably, -but like a mutable borrow, it must be unique. In the above example, uncommenting -the declaration of `y` will produce an error because it would violate the -uniqueness of the closure's borrow of `x`; the declaration of z is valid because -the closure's lifetime has expired at the end of the block, releasing the borrow. - -### Call traits and coercions - -Closure types all implement [`FnOnce`], indicating that they can be called once -by consuming ownership of the closure. Additionally, some closures implement -more specific call traits: - -* A closure which does not move out of any captured variables implements - [`FnMut`], indicating that it can be called by mutable reference. - -* A closure which does not mutate or move out of any captured variables - implements [`Fn`], indicating that it can be called by shared reference. - -> Note: `move` closures may still implement [`Fn`] or [`FnMut`], even though -> they capture variables by move. This is because the traits implemented by a -> closure type are determined by what the closure does with captured values, -> not how it captures them. - -*Non-capturing closures* are closures that don't capture anything from their -environment. They can be coerced to function pointers (`fn`) with the matching -signature. - -```rust -let add = |x, y| x + y; - -let mut x = add(5,7); - -type Binop = fn(i32, i32) -> i32; -let bo: Binop = add; -x = bo(5,7); -``` - -### Other traits - -All closure types implement [`Sized`]. Additionally, closure types implement the -following traits if allowed to do so by the types of the captures it stores: - -* [`Clone`] -* [`Copy`] -* [`Sync`] -* [`Send`] - -The rules for [`Send`] and [`Sync`] match those for normal struct types, while -[`Clone`] and [`Copy`] behave as if [derived][derive]. For [`Clone`], the order -of cloning of the captured variables is left unspecified. - -Because captures are often by reference, the following general rules arise: - -* A closure is [`Sync`] if all captured variables are [`Sync`]. -* A closure is [`Send`] if all variables captured by non-unique immutable - reference are [`Sync`], and all values captured by unique immutable or mutable - reference, copy, or move are [`Send`]. -* A closure is [`Clone`] or [`Copy`] if it does not capture any values by - unique immutable or mutable reference, and if all values it captures by copy - or move are [`Clone`] or [`Copy`], respectively. - -## Trait objects - -> **Syntax** -> _TraitObjectType_ : ->    `dyn`? _TypeParamBounds_ - -A *trait object* is an opaque value of another type that implements a set of -traits. The set of traits is made up of an [object safe] *base trait* plus any -number of [auto traits]. - -Trait objects implement the base trait, its auto traits, and any [supertraits] -of the base trait. - -Trait objects are written as the optional keyword `dyn` followed by a set of -trait bounds, but with the following restrictions on the trait bounds. All -traits except the first trait must be auto traits, there may not be more than -one lifetime, and opt-out bounds (e.g. `?sized`) are not allowed. Furthermore, -paths to traits may be parenthesized. - -For example, given a trait `Trait`, the following are all trait objects: - -* `Trait` -* `dyn Trait` -* `dyn Trait + Send` -* `dyn Trait + Send + Sync` -* `dyn Trait + 'static` -* `dyn Trait + Send + 'static` -* `dyn Trait +` -* `dyn 'static + Trait`. -* `dyn (Trait)` - -If the first bound of the trait object is a path that starts with `::`, then the -`dyn` will be treated as a part of the path. The first path can be put in -parenthesis to get around this. As such, if you want a trait object with the -trait `::your_module::Trait`, you should write it as -`dyn (::your_module::Trait)`. - -> Note: For clarity, it is recommended to always use the `dyn` keyword on your -> trait objects unless your codebase supports compiling with Rust 1.26 or lower. - -Two trait object types alias each other if the base traits alias each other and -if the sets of auto traits are the same and the lifetime bounds are the same. -For example, `dyn Trait + Send + UnwindSafe` is the same as -`dyn Trait + Unwindsafe + Send`. - -
- -***Warning:*** With two trait object types, even when the complete set of traits -is the same, if the base traits differ, the type is different. For example, -`dyn Send + Sync` is a different type from `dyn Sync + Send`. See [issue 33140]. - -
- -Due to the opaqueness of which concrete type the value is of, trait objects are -[dynamically sized types]. Like all -DSTs, trait objects are used -behind some type of pointer; for example `&dyn SomeTrait` or -`Box`. Each instance of a pointer to a trait object includes: - - - a pointer to an instance of a type `T` that implements `SomeTrait` - - a _virtual method table_, often just called a _vtable_, which contains, for - each method of `SomeTrait` and its [supertraits] that `T` implements, a - pointer to `T`'s implementation (i.e. a function pointer). - -The purpose of trait objects is to permit "late binding" of methods. Calling a -method on a trait object results in virtual dispatch at runtime: that is, a -function pointer is loaded from the trait object vtable and invoked indirectly. -The actual implementation for each vtable entry can vary on an object-by-object -basis. - -An example of a trait object: - -```rust -trait Printable { - fn stringify(&self) -> String; -} - -impl Printable for i32 { - fn stringify(&self) -> String { self.to_string() } -} - -fn print(a: Box) { - println!("{}", a.stringify()); -} - -fn main() { - print(Box::new(10) as Box); -} -``` - -In this example, the trait `Printable` occurs as a trait object in both the -type signature of `print`, and the cast expression in `main`. - -### Trait Object Lifetime Bounds - -Since a trait object can contain references, the lifetimes of those references -need to be expressed as part of the trait object. This lifetime is written as -`Trait + 'a`. There are [defaults] that allow this lifetime to usually be -inferred with a sensible choice. - -[defaults]: lifetime-elision.html#default-trait-object-lifetimes - -## Type parameters - -Within the body of an item that has type parameter declarations, the names of -its type parameters are types: - -```rust -fn to_vec(xs: &[A]) -> Vec
{ - if xs.is_empty() { - return vec![]; - } - let first: A = xs[0].clone(); - let mut rest: Vec = to_vec(&xs[1..]); - rest.insert(0, first); - rest -} -``` - -Here, `first` has type `A`, referring to `to_vec`'s `A` type parameter; and -`rest` has type `Vec`, a vector with element type `A`. - -## Anonymous type parameters - -> Note: This section is a placeholder for more comprehensive reference -> material. - -> Note: This is often called "impl Trait in argument position". - -Functions can declare an argument to be an anonymous type parameter where the -callee must provide a type that has the bounds declared by the anonymous type -parameter and the function can only use the methods available by the trait -bounds of the anonymous type parameter. - -They are written as `impl` followed by a set of trait bounds. - -## Abstract return types - -> Note: This section is a placeholder for more comprehensive reference -> material. - -> Note: This is often called "impl Trait in return position". - -Functions, except for associated trait functions, can return an abstract -return type. These types stand in for another concrete type where the -use-site may only use the trait methods declared by the trait bounds of the -type. - -They are written as `impl` followed by a set of trait bounds. - -## Self types - -The special type `Self` has a meaning within traits and implementations: it -refers to the implementing type. For example, in: - -```rust -pub trait From { - fn from(T) -> Self; -} - -impl From for String { - fn from(x: i32) -> Self { - x.to_string() - } -} -``` - -The notation `Self` in the impl refers to the implementing type: `String`. In -another example: - -```rust -trait Printable { - fn make_string(&self) -> String; -} - -impl Printable for String { - fn make_string(&self) -> String { - (*self).clone() - } -} -``` - -> Note: The notation `&self` is a shorthand for `self: &Self`. - -[`Fn`]: ../std/ops/trait.Fn.html -[`FnMut`]: ../std/ops/trait.FnMut.html -[`FnOnce`]: ../std/ops/trait.FnOnce.html -[`Copy`]: special-types-and-traits.html#copy -[`Clone`]: special-types-and-traits.html#clone -[`Send`]: special-types-and-traits.html#send -[`Sync`]: special-types-and-traits.html#sync -[`Sized`]: special-types-and-traits.html#sized -[derive]: attributes.html#derive -[`Vec`]: ../std/vec/struct.Vec.html -[dynamically sized type]: dynamically-sized-types.html -[dynamically sized types]: dynamically-sized-types.html -[struct expression]: expressions/struct-expr.html -[closure expression]: expressions/closure-expr.html -[auto traits]: special-types-and-traits.html#auto-traits -[object safe]: items/traits.html#object-safety -[issue 47010]: https://github.com/rust-lang/rust/issues/47010 -[issue 33140]: https://github.com/rust-lang/rust/issues/33140 -[_PATH_]: paths.html -[_LIFETIME_OR_LABEL_]: tokens.html#lifetimes-and-loop-labels -[supertraits]: items/traits.html#supertraits +[_ArrayType_]: types/array.html +[_BareFunctionType_]: types/function-pointer.html +[_ImplTraitTypeOneBound_]: types/impl-trait.html +[_ImplTraitType_]: types/impl-trait.html +[_InferredType_]: types/inferred.html +[_MacroInvocation_]: macros.html#macro-invocation +[_NeverType_]: types/never.html +[_ParenthesizedType_]: types.html#parenthesized-types +[_QualifiedPathInType_]: paths.html#qualified-paths +[_RawPointerType_]: types/pointer.html#raw-pointers-const-and-mut +[_ReferenceType_]: types/pointer.html#shared-references- +[_SliceType_]: types/slice.html +[_TraitObjectTypeOneBound_]: types/trait-object.html +[_TraitObjectType_]: types/trait-object.html +[_TupleType_]: types/tuple.html#tuple-types +[_TypeNoBounds_]: types.html#type-expressions +[_TypePath_]: paths.html#paths-in-types +[_Type_]: types.html#type-expressions + +[Array]: types/array.html +[Boolean]: types/boolean.html +[Closures]: types/closure.html +[Enum]: types/enum.html +[Function pointers]: types/function-pointer.html +[Functions]: types/function-item.html +[Impl trait]: types/impl-trait.html +[Macros]: macros.html +[Numeric]: types/numeric.html +[Parentheses]: #parenthesized-types +[Raw pointers]: types/pointer.html#raw-pointers-const-and-mut +[References]: types/pointer.html#shared-references- +[Slice]: types/slice.html +[Struct]: types/struct.html +[Textual]: types/textual.html +[Trait objects]: types/trait-object.html +[Tuple]: types/tuple.html +[Type paths]: paths.html#paths-in-types +[Union]: types/union.html +[`Self` path]: paths.html#self-1 +[arrays]: types/array.html +[enumerations]: types/enum.html +[function pointer]: types/function-pointer.html +[inferred type]: types/inferred.html +[item]: items.html +[never]: types/never.html +[pointer types]: types/pointer.html +[raw pointer]: types/pointer.html#raw-pointers-const-and-mut +[reference type]: types/pointer.html#shared-references- +[reference]: types/pointer.html#shared-references- +[structs]: types/struct.html +[trait]: types/trait-object.html +[tuples]: types/tuple.html +[type alias]: items/type-aliases.html +[type aliases]: items/type-aliases.html +[type boundaries]: trait-bounds.html +[type parameters]: types/parameters.html +[unions]: types/union.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types-redirect.html rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types-redirect.html --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/types-redirect.html 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/types-redirect.html 2018-12-04 23:42:54.000000000 +0000 @@ -0,0 +1,43 @@ + diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/unsafety.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/unsafety.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/unsafety.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/unsafety.md 2018-12-04 23:42:54.000000000 +0000 @@ -6,9 +6,15 @@ The following language level features cannot be used in the safe subset of Rust: -- Dereferencing a [raw pointer](types.html#pointer-types). -- Reading or writing a [mutable static variable](items/static-items.html#mutable-statics). -- Reading a field of a [`union`](items/unions.html), or writing to a field of a - union that isn't [`Copy`](special-types-and-traits.html#copy). +- Dereferencing a [raw pointer]. +- Reading or writing a [mutable] or [external] static variable. +- Accessing a field of a [`union`], other than to assign to it. - Calling an unsafe function (including an intrinsic or foreign function). -- Implementing an unsafe trait. \ No newline at end of file +- Implementing an [unsafe trait]. + +[`Copy`]: special-types-and-traits.html#copy +[`union`]: items/unions.html +[mutable static variable]: items/static-items.html#mutable-statics +[external static variable]: items/external-blocks.html +[raw pointer]: types/pointer.html +[unsafe trait]: items/traits.html#unsafe-traits diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/visibility-and-privacy.md rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/visibility-and-privacy.md --- rustc-1.30.0+dfsg1+llvm/src/doc/reference/src/visibility-and-privacy.md 2018-10-24 20:01:21.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/reference/src/visibility-and-privacy.md 2018-12-04 23:42:54.000000000 +0000 @@ -2,12 +2,11 @@ > **Syntax**\ > _Visibility_ :\ ->       EMPTY\ ->    | `pub`\ +>       `pub`\ >    | `pub` `(` `crate` `)`\ ->    | `pub` `(` `in` _ModulePath_ `)`\ ->    | `pub` `(` `in`? `self` `)`\ ->    | `pub` `(` `in`? `super` `)` +>    | `pub` `(` `self` `)`\ +>    | `pub` `(` `super` `)`\ +>    | `pub` `(` `in` [_SimplePath_] `)` These two terms are often used interchangeably, and what they are attempting to convey is the answer to the question "Can this item be used at this location?" @@ -229,3 +228,5 @@ When re-exporting a private item, it can be thought of as allowing the "privacy chain" being short-circuited through the reexport instead of passing through the namespace hierarchy as it normally would. + +[_SimplePath_]: paths.html#simple-paths diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/rust-by-example/README.md rustc-1.31.0+dfsg1+llvm/src/doc/rust-by-example/README.md --- rustc-1.30.0+dfsg1+llvm/src/doc/rust-by-example/README.md 2018-09-06 19:18:23.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/rust-by-example/README.md 2018-11-20 15:10:23.000000000 +0000 @@ -14,7 +14,7 @@ ```bash $ git clone https://github.com/rust-lang/rust-by-example $ cd rust-by-example -$ cargo install mdbook +$ cargo install mdbook --version ^0.2 --force $ mdbook build $ mdbook serve ``` diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/rust-by-example/src/cargo/build_scripts.md rustc-1.31.0+dfsg1+llvm/src/doc/rust-by-example/src/cargo/build_scripts.md --- rustc-1.30.0+dfsg1+llvm/src/doc/rust-by-example/src/cargo/build_scripts.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/rust-by-example/src/cargo/build_scripts.md 2018-11-20 15:10:23.000000000 +0000 @@ -0,0 +1,38 @@ +# Build Scripts + +Sometimes a normal build from cargo is not enough. Perhaps your crate needs some +pre-requisites before cargo will successfully compile, things like code +generation, or some native code that needs to be compiled. To solve this problem +we have build scripts that Cargo can run. + +To add a build script to your package it can either be specified in the +`Cargo.toml` as follows: + +```toml +[package] +... +build = "build.rs" +``` + +Otherwise Cargo will look for a `build.rs` file in the project directory by +default. + +## How to use a build script + +The build script is simply another Rust file that will be compiled and invoked +prior to compiling anything else in the package. Hence it can be used to fulfil +pre-requisites of your crate. + +Cargo provides the script with inputs via environment variables [specified +here] that can be used. + +The script provides output via stdout. All lines printed are written to +`target/debug/build//output`. Further, lines prefixed with `cargo:` will be +interpreted by Cargo directly and hence can be used to define parameters for the +packages compilation. + +For further specification and examples have a read of the [cargo specification]. + +[specified here]: https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts + +[cargo specification]: https://doc.rust-lang.org/cargo/reference/build-scripts.html \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/rust-by-example/src/error/result.md rustc-1.31.0+dfsg1+llvm/src/doc/rust-by-example/src/error/result.md --- rustc-1.30.0+dfsg1+llvm/src/doc/rust-by-example/src/error/result.md 2018-09-06 19:18:23.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/rust-by-example/src/error/result.md 2018-11-20 15:10:23.000000000 +0000 @@ -45,6 +45,39 @@ To improve the quality of our error message, we should be more specific about the return type and consider explicitly handling the error. +## Using `Result` in `main` + +The `Result` type can also be the return type of the `main` function if +specified explicitly. Typically the `main` function will be of the form: + +```rust +fn main() { + println!("Hello World!"); +} +``` + +However `main` is also able to have a return type of `Result`. If an error +occurs within the `main` function it will return an error code and print a debug +representation of the error (using the [`Debug`] trait). The following example +shows such a scenario and touches on aspects covered in [the following section]. + +```rust,editable +use std::num::ParseIntError; + +fn main() -> Result<(), ParseIntError> { + let number_str = "10"; + let number = match number_str.parse::() { + Ok(number) => number, + Err(e) => return Err(e), + }; + println!("{}", number); + Ok(()) +} +``` + + [option]: https://doc.rust-lang.org/std/option/enum.Option.html [result]: https://doc.rust-lang.org/std/result/enum.Result.html [parse]: https://doc.rust-lang.org/std/primitive.str.html#method.parse +[`Debug`]: https://doc.rust-lang.org/std/fmt/trait.Debug.html +[the following section]: error/result/early_returns.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/rust-by-example/src/fn/diverging.md rustc-1.31.0+dfsg1+llvm/src/doc/rust-by-example/src/fn/diverging.md --- rustc-1.30.0+dfsg1+llvm/src/doc/rust-by-example/src/fn/diverging.md 2018-09-06 19:18:23.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/rust-by-example/src/fn/diverging.md 2018-11-20 15:10:23.000000000 +0000 @@ -12,7 +12,7 @@ set of all possible values this type can have is empty. Note, that it is different from the `()` type, which has exactly one possible value. -For example, this functions returns as usual, although there is no information +For example, this function returns as usual, although there is no information in the return value. ```rust @@ -22,7 +22,7 @@ fn main() { let a: () = some_fn(); - println!("This functions returns and you can see this line.") + println!("This function returns and you can see this line.") } ``` diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/rust-by-example/src/scope/lifetime/methods.md rustc-1.31.0+dfsg1+llvm/src/doc/rust-by-example/src/scope/lifetime/methods.md --- rustc-1.30.0+dfsg1+llvm/src/doc/rust-by-example/src/scope/lifetime/methods.md 2018-09-06 19:18:23.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/rust-by-example/src/scope/lifetime/methods.md 2018-11-20 15:10:23.000000000 +0000 @@ -14,7 +14,7 @@ } fn main() { - let mut owner = Owner(18); + let mut owner = Owner(18); owner.add_one(); owner.print(); @@ -25,4 +25,4 @@ [methods] -[methods]: fn/methods.html \ No newline at end of file +[methods]: fn/methods.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/rust-by-example/src/SUMMARY.md rustc-1.31.0+dfsg1+llvm/src/doc/rust-by-example/src/SUMMARY.md --- rustc-1.30.0+dfsg1+llvm/src/doc/rust-by-example/src/SUMMARY.md 2018-09-06 19:18:23.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/rust-by-example/src/SUMMARY.md 2018-11-20 15:10:23.000000000 +0000 @@ -87,6 +87,7 @@ - [Dependencies](cargo/deps.md) - [Conventions](cargo/conventions.md) - [Tests](cargo/test.md) + - [Build Scripts](cargo/build_scripts.md) - [Attributes](attribute.md) - [`dead_code`](attribute/unused.md) diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/rust-by-example/src/trait/derive.md rustc-1.31.0+dfsg1+llvm/src/doc/rust-by-example/src/trait/derive.md --- rustc-1.30.0+dfsg1+llvm/src/doc/rust-by-example/src/trait/derive.md 2018-09-06 19:18:23.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/rust-by-example/src/trait/derive.md 2018-11-20 15:10:23.000000000 +0000 @@ -13,7 +13,7 @@ * [`Default`][default], to create an empty instance of a data type. * [`Debug`][debug], to format a value using the `{:?}` formatter. -```rust,example +```rust,editable // `Centimeters`, a tuple struct that can be compared #[derive(PartialEq, PartialOrd)] struct Centimeters(f64); diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/rust-by-example/src/unsafe.md rustc-1.31.0+dfsg1+llvm/src/doc/rust-by-example/src/unsafe.md --- rustc-1.30.0+dfsg1+llvm/src/doc/rust-by-example/src/unsafe.md 2018-09-06 19:18:23.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/rust-by-example/src/unsafe.md 2018-11-20 15:10:23.000000000 +0000 @@ -2,15 +2,15 @@ As an introduction to this section, to borrow from [the official docs][unsafe], "one should try to minimize the amount of unsafe code in a code base." With that -in mind, let's get started! Unsafe blocks in Rust are used to bypass protections -put in place by the compiler; specifically, there are four primary things that -unsafe blocks are used for: +in mind, let's get started! Unsafe annotations in Rust are used to bypass +protections put in place by the compiler; specifically, there are four primary +things that unsafe is used for: * dereferencing raw pointers -* calling a function over FFI (but this is covered in [a previous - chapter](std_misc/ffi.html) of the book) -* calling functions which are `unsafe` -* inline assembly +* calling functions or methods which are `unsafe` (including calling a function + over FFI, see [a previous chapter](std_misc/ffi.html) of the book) +* accessing or modifying static mutable variables +* implementing unsafe traits ### Raw Pointers Raw pointers `*` and references `&T` function similarly, but references are @@ -45,7 +45,7 @@ unsafe { let my_slice: &[u32] = slice::from_raw_parts(pointer, length); - + assert_eq!(some_vector.as_slice(), my_slice); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/rust-by-example/theme/index.hbs rustc-1.31.0+dfsg1+llvm/src/doc/rust-by-example/theme/index.hbs --- rustc-1.30.0+dfsg1+llvm/src/doc/rust-by-example/theme/index.hbs 2018-09-06 19:18:23.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/rust-by-example/theme/index.hbs 1970-01-01 00:00:00.000000000 +0000 @@ -1,184 +0,0 @@ - - - - - {{ title }} - - - - - - - - - - - - - - - - - - - - - {{#each additional_css}} - - {{/each}} - - {{#if mathjax_support}} - - - {{/if}} - - - - - - - - - - - - - - {{#each additional_js}} - - {{/each}} - - - - - - - - - - - -
- -
- - -
- {{{ content }}} -
- - - {{#previous}} - - {{/previous}} - - {{#next}} - - {{/next}} - -
- - {{#previous}} - - {{/previous}} - - {{#next}} - - {{/next}} - -
- - - - - - - {{{livereload}}} - - {{#if google_analytics}} - - {{/if}} - - {{#if playpens_editable}} - - - - - - {{/if}} - - {{#if is_print}} - - {{/if}} - - - - - diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/rustc/src/command-line-arguments.md rustc-1.31.0+dfsg1+llvm/src/doc/rustc/src/command-line-arguments.md --- rustc-1.30.0+dfsg1+llvm/src/doc/rustc/src/command-line-arguments.md 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/rustc/src/command-line-arguments.md 2018-12-04 23:41:40.000000000 +0000 @@ -10,6 +10,11 @@ This flag can turn on or off various `#[cfg]` settings. +The value can either be a single identifier or two identifiers separated by `=`. + +For examples, `--cfg 'verbose'` or `--cfg 'feature="serde"'`. These correspond +to `#[cfg(verbose)]` and `#[cfg(feature = "serde")]` respectively. + ## `-L`: add a directory to the library search path When looking for external crates, a directory passed to this flag will be searched. diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/rustc/src/lints/listing/warn-by-default.md rustc-1.31.0+dfsg1+llvm/src/doc/rustc/src/lints/listing/warn-by-default.md --- rustc-1.30.0+dfsg1+llvm/src/doc/rustc/src/lints/listing/warn-by-default.md 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/rustc/src/lints/listing/warn-by-default.md 2018-12-04 23:41:40.000000000 +0000 @@ -279,7 +279,7 @@ 1 | #[no_mangle] | ------------ help: remove this attribute 2 | / fn foo(t: T) { -3 | | +3 | | 4 | | } | |_^ | @@ -513,7 +513,7 @@ warning: borrow of packed field requires unsafe function or block (error E0133) --> src/main.rs:11:13 | -11 | let y = &x.data.0; +11 | let y = &x.data.0; | ^^^^^^^^^ | = note: #[warn(safe_packed_borrows)] on by default @@ -874,7 +874,7 @@ This will produce: ```text -warning: unused `std::result::Result` which must be used +warning: unused `std::result::Result` that must be used --> src/main.rs:6:5 | 6 | returns_result(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/rustdoc/src/command-line-arguments.md rustc-1.31.0+dfsg1+llvm/src/doc/rustdoc/src/command-line-arguments.md --- rustc-1.30.0+dfsg1+llvm/src/doc/rustdoc/src/command-line-arguments.md 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/rustdoc/src/command-line-arguments.md 2018-12-04 23:41:40.000000000 +0000 @@ -345,3 +345,17 @@ Similar to `rustc --sysroot`, this lets you change the sysroot `rustdoc` uses when compiling your code. + +### `--edition`: control the edition of docs and doctests + +Using this flag looks like this: + +```bash +$ rustdoc src/lib.rs --edition 2018 +$ rustdoc --test src/lib.rs --edition 2018 +``` + +This flag allows rustdoc to treat your rust code as the given edition. It will compile doctests with +the given edition as well. As with `rustc`, the default edition that `rustdoc` will use is `2015` +(the first edition). + diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/rustdoc/src/documentation-tests.md rustc-1.31.0+dfsg1+llvm/src/doc/rustdoc/src/documentation-tests.md --- rustc-1.30.0+dfsg1+llvm/src/doc/rustdoc/src/documentation-tests.md 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/rustdoc/src/documentation-tests.md 2018-12-04 23:41:40.000000000 +0000 @@ -323,6 +323,22 @@ with the current Rust release may work in a future release, as new features are added. +```text +/// Only runs on the 2018 edition. +/// +/// ```edition2018 +/// let result: Result = try { +/// "1".parse::()? +/// + "2".parse::()? +/// + "3".parse::()? +/// }; +/// ``` +``` + +`edition2018` tells `rustdoc` that the code sample should be compiled the 2018 +edition of Rust. Similarly, you can specify `edition2015` to compile the code +with the 2015 edition. + ## Syntax reference The *exact* syntax for code blocks, including the edge cases, can be found diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/rustdoc/src/the-doc-attribute.md rustc-1.31.0+dfsg1+llvm/src/doc/rustdoc/src/the-doc-attribute.md --- rustc-1.30.0+dfsg1+llvm/src/doc/rustdoc/src/the-doc-attribute.md 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/rustdoc/src/the-doc-attribute.md 2018-12-04 23:41:40.000000000 +0000 @@ -186,6 +186,9 @@ Now we'll have a `Re-exports` line, and `Bar` will not link to anywhere. +One special case: In Rust 2018 and later, if you `pub use` one of your dependencies, `rustdoc` will +not eagerly inline it as a module unless you add `#[doc(inline)}`. + ## `#[doc(hidden)]` Any item annotated with `#[doc(hidden)]` will not appear in the documentation, unless diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/rustdoc/src/unstable-features.md rustc-1.31.0+dfsg1+llvm/src/doc/rustdoc/src/unstable-features.md --- rustc-1.30.0+dfsg1+llvm/src/doc/rustdoc/src/unstable-features.md 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/rustdoc/src/unstable-features.md 2018-12-04 23:41:40.000000000 +0000 @@ -346,19 +346,6 @@ [issue-display-warnings]: https://github.com/rust-lang/rust/issues/41574 -### `--edition`: control the edition of docs and doctests - -Using this flag looks like this: - -```bash -$ rustdoc src/lib.rs -Z unstable-options --edition 2018 -$ rustdoc --test src/lib.rs -Z unstable-options --edition 2018 -``` - -This flag allows rustdoc to treat your rust code as the given edition. It will compile doctests with -the given edition as well. As with `rustc`, the default edition that `rustdoc` will use is `2015` -(the first edition). - ### `--extern-html-root-url`: control how rustdoc links to non-local crates Using this flag looks like this: diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/compiler-flags/emit-stack-sizes.md rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/compiler-flags/emit-stack-sizes.md --- rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/compiler-flags/emit-stack-sizes.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/compiler-flags/emit-stack-sizes.md 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,167 @@ +# `emit-stack-sizes` + +The tracking issue for this feature is: [#54192] + +[#54192]: https://github.com/rust-lang/rust/issues/54192 + +------------------------ + +The rustc flag `-Z emit-stack-sizes` makes LLVM emit stack size metadata. + +> **NOTE**: This LLVM feature only supports the ELF object format as of LLVM +> 8.0. Using this flag with targets that use other object formats (e.g. macOS +> and Windows) will result in it being ignored. + +Consider this crate: + +``` +#![crate_type = "lib"] + +use std::ptr; + +pub fn foo() { + // this function doesn't use the stack +} + +pub fn bar() { + let xs = [0u32; 2]; + + // force LLVM to allocate `xs` on the stack + unsafe { ptr::read_volatile(&xs.as_ptr()); } +} +``` + +Using the `-Z emit-stack-sizes` flag produces extra linker sections in the +output *object file*. + +``` console +$ rustc -C opt-level=3 --emit=obj foo.rs + +$ size -A foo.o +foo.o : +section size addr +.text 0 0 +.text._ZN3foo3foo17he211d7b4a3a0c16eE 1 0 +.text._ZN3foo3bar17h1acb594305f70c2eE 22 0 +.note.GNU-stack 0 0 +.eh_frame 72 0 +Total 95 + +$ rustc -C opt-level=3 --emit=obj -Z emit-stack-sizes foo.rs + +$ size -A foo.o +foo.o : +section size addr +.text 0 0 +.text._ZN3foo3foo17he211d7b4a3a0c16eE 1 0 +.stack_sizes 9 0 +.text._ZN3foo3bar17h1acb594305f70c2eE 22 0 +.stack_sizes 9 0 +.note.GNU-stack 0 0 +.eh_frame 72 0 +Total 113 +``` + +As of LLVM 7.0 the data will be written into a section named `.stack_sizes` and +the format is "an array of pairs of function symbol values (pointer size) and +stack sizes (unsigned LEB128)". + +``` console +$ objdump -d foo.o + +foo.o: file format elf64-x86-64 + +Disassembly of section .text._ZN3foo3foo17he211d7b4a3a0c16eE: + +0000000000000000 <_ZN3foo3foo17he211d7b4a3a0c16eE>: + 0: c3 retq + +Disassembly of section .text._ZN3foo3bar17h1acb594305f70c2eE: + +0000000000000000 <_ZN3foo3bar17h1acb594305f70c2eE>: + 0: 48 83 ec 10 sub $0x10,%rsp + 4: 48 8d 44 24 08 lea 0x8(%rsp),%rax + 9: 48 89 04 24 mov %rax,(%rsp) + d: 48 8b 04 24 mov (%rsp),%rax + 11: 48 83 c4 10 add $0x10,%rsp + 15: c3 retq + +$ objdump -s -j .stack_sizes foo.o + +foo.o: file format elf64-x86-64 + +Contents of section .stack_sizes: + 0000 00000000 00000000 00 ......... +Contents of section .stack_sizes: + 0000 00000000 00000000 10 ......... +``` + +It's important to note that linkers will discard this linker section by default. +To preserve the section you can use a linker script like the one shown below. + +``` text +/* file: keep-stack-sizes.x */ +SECTIONS +{ + /* `INFO` makes the section not allocatable so it won't be loaded into memory */ + .stack_sizes (INFO) : + { + KEEP(*(.stack_sizes)); + } +} +``` + +The linker script must be passed to the linker using a rustc flag like `-C +link-arg`. + +``` +// file: src/main.rs +use std::ptr; + +#[inline(never)] +fn main() { + let xs = [0u32; 2]; + + // force LLVM to allocate `xs` on the stack + unsafe { ptr::read_volatile(&xs.as_ptr()); } +} +``` + +``` console +$ RUSTFLAGS="-Z emit-stack-sizes" cargo build --release + +$ size -A target/release/hello | grep stack_sizes || echo section was not found +section was not found + +$ RUSTFLAGS="-Z emit-stack-sizes" cargo rustc --release -- \ + -C link-arg=-Wl,-Tkeep-stack-sizes.x \ + -C link-arg=-N + +$ size -A target/release/hello | grep stack_sizes +.stack_sizes 90 176272 + +$ # non-allocatable section (flags don't contain the "A" (alloc) flag) +$ readelf -S target/release/hello +Section Headers: + [Nr] Name Type Address Offset + Size EntSize Flags Link Info Align +(..) + [1031] .stack_sizes PROGBITS 000000000002b090 0002b0f0 + 000000000000005a 0000000000000000 L 5 0 1 + +$ objdump -s -j .stack_sizes target/release/hello + +target/release/hello: file format elf64-x86-64 + +Contents of section .stack_sizes: + 2b090 c0040000 00000000 08f00400 00000000 ................ + 2b0a0 00080005 00000000 00000810 05000000 ................ + 2b0b0 00000000 20050000 00000000 10400500 .... ........@.. + 2b0c0 00000000 00087005 00000000 00000080 ......p......... + 2b0d0 05000000 00000000 90050000 00000000 ................ + 2b0e0 00a00500 00000000 0000 .......... +``` + +> Author note: I'm not entirely sure why, in *this* case, `-N` is required in +> addition to `-Tkeep-stack-sizes.x`. For example, it's not required when +> producing statically linked files for the ARM Cortex-M architecture. diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/compiler-flags/profile.md rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/compiler-flags/profile.md --- rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/compiler-flags/profile.md 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/compiler-flags/profile.md 2018-12-04 23:41:40.000000000 +0000 @@ -18,4 +18,4 @@ ``` Once you've built and run your program, files with the `gcno` (after build) and `gcda` (after execution) extensions will be created. -You can parse them with [llvm-cov gcov](http://llvm.org/docs/CommandGuide/llvm-cov.html#llvm-cov-gcov) or [grcov](https://github.com/marco-c/grcov). +You can parse them with [llvm-cov gcov](https://llvm.org/docs/CommandGuide/llvm-cov.html#llvm-cov-gcov) or [grcov](https://github.com/mozilla/grcov). diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/cfg-attr-multi.md rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/cfg-attr-multi.md --- rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/cfg-attr-multi.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/cfg-attr-multi.md 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +# `cfg_attr_multi` + +The tracking issue for this feature is: [#54881] +The RFC for this feature is: [#2539] + +[#54881]: https://github.com/rust-lang/rust/issues/54881 +[#2539]: https://github.com/rust-lang/rfcs/pull/2539 + +------------------------ + +This feature flag lets you put multiple attributes into a `cfg_attr` attribute. + +Example: + +```rust,ignore +#[cfg_attr(all(), must_use, optimize)] +``` + +Because `cfg_attr` resolves before procedural macros, this does not affect +macro resolution at all. \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/extern-in-paths.md rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/extern-in-paths.md --- rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/extern-in-paths.md 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/extern-in-paths.md 2018-12-04 23:41:40.000000000 +0000 @@ -11,8 +11,8 @@ For example, `extern::my_crat::a::b` will resolve to path `a::b` in crate `my_crate`. -`feature(extern_absolute_paths)` mode provides the same effect by resolving absolute paths like -`::my_crate::a::b` to paths from extern crates by default. +Absolute paths on 2018 edition (e.g. `::my_crate::a::b`) provide the same effect +and resolve to extern crates (built-in or passed with `--extern`). ```rust,ignore #![feature(extern_in_paths)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/impl-trait-in-bindings.md rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/impl-trait-in-bindings.md --- rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/impl-trait-in-bindings.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/impl-trait-in-bindings.md 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +# `impl_trait_in_bindings` + +The tracking issue for this feature is: [#34511] + +[#34511]: https://github.com/rust-lang/rust/issues/34511 + +------------------------ + +The `impl_trait_in_bindings` feature gate lets you use `impl Trait` syntax in +`let`, `static`, and `const` bindings. + +A simple example is: + +```rust +#![feature(impl_trait_in_bindings)] + +use std::fmt::Debug; + +fn main() { + let a: impl Debug + Clone = 42; + let b = a.clone(); + println!("{:?}", b); // prints `42` +} +``` + +Note however that because the types of `a` and `b` are opaque in the above +example, calling inherent methods or methods outside of the specified traits +(e.g., `a.abs()` or `b.abs()`) is not allowed, and yields an error. diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/infer-outlives-requirements.md rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/infer-outlives-requirements.md --- rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/infer-outlives-requirements.md 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/infer-outlives-requirements.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -# `infer_outlives_requirements` - -The tracking issue for this feature is: [#44493] - -[#44493]: https://github.com/rust-lang/rust/issues/44493 - ------------------------- -The `infer_outlives_requirements` feature indicates that certain -outlives requirements can be inferred by the compiler rather than -stating them explicitly. - -For example, currently generic struct definitions that contain -references, require where-clauses of the form T: 'a. By using -this feature the outlives predicates will be inferred, although -they may still be written explicitly. - -```rust,ignore (pseudo-Rust) -struct Foo<'a, T> - where T: 'a // <-- currently required - { - bar: &'a T, - } -``` - - -## Examples: - - -```rust,ignore (pseudo-Rust) -#![feature(infer_outlives_requirements)] - -// Implicitly infer T: 'a -struct Foo<'a, T> { - bar: &'a T, -} -``` - -```rust,ignore (pseudo-Rust) -#![feature(infer_outlives_requirements)] - -// Implicitly infer `U: 'b` -struct Foo<'b, U> { - bar: Bar<'b, U> -} - -struct Bar<'a, T> where T: 'a { - x: &'a (), - y: T, -} -``` - -```rust,ignore (pseudo-Rust) -#![feature(infer_outlives_requirements)] - -// Implicitly infer `b': 'a` -struct Foo<'a, 'b, T> { - x: &'a &'b T -} -``` - -```rust,ignore (pseudo-Rust) -#![feature(infer_outlives_requirements)] - -// Implicitly infer `::Item : 'a` -struct Foo<'a, T: Iterator> { - bar: &'a T::Item -``` diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/lang-items.md rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/lang-items.md --- rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/lang-items.md 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/lang-items.md 2018-12-04 23:41:40.000000000 +0000 @@ -311,3 +311,5 @@ - `freeze`: `libcore/marker.rs` - `debug_trait`: `libcore/fmt/mod.rs` - `non_zero`: `libcore/nonzero.rs` + - `arc`: `liballoc/sync.rs` + - `rc`: `liballoc/rc.rs` diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/macro-literal-matcher.md rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/macro-literal-matcher.md --- rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/macro-literal-matcher.md 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/macro-literal-matcher.md 2018-12-04 23:41:40.000000000 +0000 @@ -4,7 +4,7 @@ The RFC is: [rfc#1576]. -With this feature gate enabled, the [list of fragment specifiers][frags] gains one more entry: +With this feature gate enabled, the [list of designators] gains one more entry: * `literal`: a literal. Examples: 2, "string", 'c' @@ -12,6 +12,6 @@ [rfc#1576]: http://rust-lang.github.io/rfcs/1576-macros-literal-matcher.html [#35625]: https://github.com/rust-lang/rust/issues/35625 -[frags]: ../book/first-edition/macros.html#syntactic-requirements +[list of designators]: ../reference/macros-by-example.html ------------------------ diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/marker-trait-attr.md rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/marker-trait-attr.md --- rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/marker-trait-attr.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/marker-trait-attr.md 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +# `marker_trait_attr` + +The tracking issue for this feature is: [#29864] + +[#29864]: https://github.com/rust-lang/rust/issues/29864 + +------------------------ + +Normally, Rust keeps you from adding trait implementations that could +overlap with each other, as it would be ambiguous which to use. This +feature, however, carves out an exception to that rule: a trait can +opt-in to having overlapping implementations, at the cost that those +implementations are not allowed to override anything (and thus the +trait itself cannot have any associated items, as they're pointless +when they'd need to do the same thing for every type anyway). + +```rust +#![feature(marker_trait_attr)] + +use std::fmt::{Debug, Display}; + +#[marker] trait MyMarker {} + +impl MyMarker for T {} +impl MyMarker for T {} + +fn foo(t: T) -> T { + t +} +``` + +This is expected to replace the unstable `overlapping_marker_traits` +feature, which applied to all empty traits (without needing an opt-in). diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/plugin.md rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/plugin.md --- rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/plugin.md 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/plugin.md 2018-12-04 23:41:40.000000000 +0000 @@ -137,8 +137,6 @@ ## Tips and tricks -Some of the [macro debugging tips](../book/first-edition/macros.html#debugging-macro-code) are applicable. - You can use `syntax::parse` to turn token trees into higher-level syntax elements like expressions: diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/tool-lints.md rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/tool-lints.md --- rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/tool-lints.md 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/tool-lints.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -# `tool_lints` - -The tracking issue for this feature is: [#44690] - -[#44690]: https://github.com/rust-lang/rust/issues/44690 - ------------------------- - -Tool lints let you use scoped lints, to `allow`, `warn`, `deny` or `forbid` lints of -certain tools. - -Currently `clippy` is the only available lint tool. - -It is recommended for lint tools to implement the scoped lints like this: - -- `#[_(TOOL_NAME::lintname)]`: for lint names -- `#[_(TOOL_NAME::lintgroup)]`: for groups of lints -- `#[_(TOOL_NAME::all)]`: for (almost[^1]) all lints - -## An example - -```rust -#![feature(tool_lints)] - -#![warn(clippy::pedantic)] - -#[allow(clippy::filter_map)] -fn main() { - let v = vec![0; 10]; - let _ = v.into_iter().filter(|&x| x < 1).map(|x| x + 1).collect::>(); - println!("No filter_map()!"); -} -``` - -[^1]: Some defined lint groups can be excluded here. diff -Nru rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/try-blocks.md rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/try-blocks.md --- rustc-1.30.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/try-blocks.md 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/doc/unstable-book/src/language-features/try-blocks.md 2018-12-04 23:41:40.000000000 +0000 @@ -9,9 +9,7 @@ The `try_blocks` feature adds support for `try` blocks. A `try` block creates a new scope one can use the `?` operator in. -```rust,ignore -// This code needs the 2018 edition - +```rust,edition2018 #![feature(try_blocks)] use std::num::ParseIntError; diff -Nru rustc-1.30.0+dfsg1+llvm/src/etc/gdb_rust_pretty_printing.py rustc-1.31.0+dfsg1+llvm/src/etc/gdb_rust_pretty_printing.py --- rustc-1.30.0+dfsg1+llvm/src/etc/gdb_rust_pretty_printing.py 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/etc/gdb_rust_pretty_printing.py 2018-12-04 23:41:40.000000000 +0000 @@ -322,8 +322,11 @@ def children(self): (length, data_ptr) = \ rustpp.extract_length_and_ptr_from_std_btreeset(self.__val) - val = GdbValue(data_ptr.get_wrapped_value().dereference()).get_child_at_index(3) - gdb_ptr = val.get_wrapped_value() + leaf_node = GdbValue(data_ptr.get_wrapped_value().dereference()) + maybe_uninit_keys = leaf_node.get_child_at_index(3) + manually_drop_keys = maybe_uninit_keys.get_child_at_index(1) + keys = manually_drop_keys.get_child_at_index(0) + gdb_ptr = keys.get_wrapped_value() for index in xrange(length): yield (str(index), gdb_ptr[index]) @@ -345,9 +348,14 @@ def children(self): (length, data_ptr) = \ rustpp.extract_length_and_ptr_from_std_btreemap(self.__val) - keys = GdbValue(data_ptr.get_wrapped_value().dereference()).get_child_at_index(3) + leaf_node = GdbValue(data_ptr.get_wrapped_value().dereference()) + maybe_uninit_keys = leaf_node.get_child_at_index(3) + manually_drop_keys = maybe_uninit_keys.get_child_at_index(1) + keys = manually_drop_keys.get_child_at_index(0) keys_ptr = keys.get_wrapped_value() - vals = GdbValue(data_ptr.get_wrapped_value().dereference()).get_child_at_index(4) + maybe_uninit_vals = leaf_node.get_child_at_index(4) + manually_drop_vals = maybe_uninit_vals.get_child_at_index(1) + vals = manually_drop_vals.get_child_at_index(0) vals_ptr = vals.get_wrapped_value() for index in xrange(length): yield (str(index), keys_ptr[index]) diff -Nru rustc-1.30.0+dfsg1+llvm/src/etc/generate-keyword-tests.py rustc-1.31.0+dfsg1+llvm/src/etc/generate-keyword-tests.py --- rustc-1.30.0+dfsg1+llvm/src/etc/generate-keyword-tests.py 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/etc/generate-keyword-tests.py 2018-12-04 23:41:40.000000000 +0000 @@ -44,7 +44,7 @@ """ test_dir = os.path.abspath( - os.path.join(os.path.dirname(__file__), '../test/parse-fail') + os.path.join(os.path.dirname(__file__), '../test/ui/parser') ) for kw in sys.argv[1:]: diff -Nru rustc-1.30.0+dfsg1+llvm/src/etc/htmldocck.py rustc-1.31.0+dfsg1+llvm/src/etc/htmldocck.py --- rustc-1.30.0+dfsg1+llvm/src/etc/htmldocck.py 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/etc/htmldocck.py 2018-12-04 23:41:40.000000000 +0000 @@ -15,65 +15,66 @@ The principle is simple: This script receives a path to generated HTML documentation and a "template" script, which has a series of check -commands like `@has` or `@matches`. Each command can be used to check if +commands like `@has` or `@matches`. Each command is used to check if some pattern is present or not present in the particular file or in -the particular node of HTML tree. In many cases, the template script -happens to be a source code given to rustdoc. +a particular node of the HTML tree. In many cases, the template script +happens to be the source code given to rustdoc. While it indeed is possible to test in smaller portions, it has been hard to construct tests in this fashion and major rendering errors were -discovered much later. This script is designed for making the black-box -and regression testing of Rustdoc easy. This does not preclude the needs -for unit testing, but can be used to complement related tests by quickly +discovered much later. This script is designed to make black-box and +regression testing of Rustdoc easy. This does not preclude the needs for +unit testing, but can be used to complement related tests by quickly showing the expected renderings. In order to avoid one-off dependencies for this task, this script uses a reasonably working HTML parser and the existing XPath implementation -from Python's standard library. Hopefully we won't render +from Python's standard library. Hopefully, we won't render non-well-formed HTML. # Commands Commands start with an `@` followed by a command name (letters and hyphens), and zero or more arguments separated by one or more whitespace -and optionally delimited with single or double quotes. The `@` mark -cannot be preceded by a non-whitespace character. Other lines (including -every text up to the first `@`) are ignored, but it is recommended to -avoid the use of `@` in the template file. +characters and optionally delimited with single or double quotes. The `@` +mark cannot be preceded by a non-whitespace character. Other lines +(including every text up to the first `@`) are ignored, but it is +recommended to avoid the use of `@` in the template file. There are a number of supported commands: -* `@has PATH` checks for the existence of given file. +* `@has PATH` checks for the existence of the given file. `PATH` is relative to the output directory. It can be given as `-` which repeats the most recently used `PATH`. * `@has PATH PATTERN` and `@matches PATH PATTERN` checks for - the occurrence of given `PATTERN` in the given file. Only one - occurrence of given pattern is enough. + the occurrence of the given pattern `PATTERN` in the specified file. + Only one occurrence of the pattern is enough. For `@has`, `PATTERN` is a whitespace-normalized (every consecutive whitespace being replaced by one single space character) string. The entire file is also whitespace-normalized including newlines. For `@matches`, `PATTERN` is a Python-supported regular expression. - The file remains intact but the regexp is matched with no `MULTILINE` - and `IGNORECASE` option. You can still use a prefix `(?m)` or `(?i)` + The file remains intact but the regexp is matched without the `MULTILINE` + and `IGNORECASE` options. You can still use a prefix `(?m)` or `(?i)` to override them, and `\A` and `\Z` for definitely matching the beginning and end of the file. (The same distinction goes to other variants of these commands.) * `@has PATH XPATH PATTERN` and `@matches PATH XPATH PATTERN` checks for - the presence of given `XPATH` in the given HTML file, and also - the occurrence of given `PATTERN` in the matching node or attribute. - Only one occurrence of given pattern in the match is enough. + the presence of the given XPath `XPATH` in the specified HTML file, + and also the occurrence of the given pattern `PATTERN` in the matching + node or attribute. Only one occurrence of the pattern in the match + is enough. `PATH` should be a valid and well-formed HTML file. It does *not* accept arbitrary HTML5; it should have matching open and close tags and correct entity references at least. - `XPATH` is an XPath expression to match. This is fairly limited: + `XPATH` is an XPath expression to match. The XPath is fairly limited: `tag`, `*`, `.`, `//`, `..`, `[@attr]`, `[@attr='value']`, `[tag]`, `[POS]` (element located in given `POS`), `[last()-POS]`, `text()` and `@attr` (both as the last segment) are supported. Some examples: @@ -85,7 +86,7 @@ - `//h1[@class="fqn"]/span[1]/a[last()]/@class` matches a value of `class` attribute in the last `a` element (can be followed by more elements that are not `a`) inside the first `span` in the `h1` with - a class of `fqn`. Note that there cannot be no additional elements + a class of `fqn`. Note that there cannot be any additional elements between them due to the use of `/` instead of `//`. Do not try to use non-absolute paths, it won't work due to the flawed @@ -93,11 +94,12 @@ For the text matches (i.e. paths not ending with `@attr`), any subelements are flattened into one string; this is handy for ignoring - highlights for example. If you want to simply check the presence of - given node or attribute, use an empty string (`""`) as a `PATTERN`. + highlights for example. If you want to simply check for the presence of + a given node or attribute, use an empty string (`""`) as a `PATTERN`. -* `@count PATH XPATH COUNT' checks for the occurrence of given XPath - in the given file. The number of occurrences must match the given count. +* `@count PATH XPATH COUNT' checks for the occurrence of the given XPath + in the specified file. The number of occurrences must match the given + count. * `@has-dir PATH` checks for the existence of the given directory. diff -Nru rustc-1.30.0+dfsg1+llvm/src/etc/lldb_rust_formatters.py rustc-1.31.0+dfsg1+llvm/src/etc/lldb_rust_formatters.py --- rustc-1.30.0+dfsg1+llvm/src/etc/lldb_rust_formatters.py 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/etc/lldb_rust_formatters.py 2018-12-04 23:41:40.000000000 +0000 @@ -277,7 +277,7 @@ #=-------------------------------------------------------------------------------------------------- def print_array_of_values(array_name, data_ptr_val, length, internal_dict): - """Prints a contigous memory range, interpreting it as values of the + """Prints a contiguous memory range, interpreting it as values of the pointee-type of data_ptr_val.""" data_ptr_type = data_ptr_val.type diff -Nru rustc-1.30.0+dfsg1+llvm/src/liballoc/benches/slice.rs rustc-1.31.0+dfsg1+llvm/src/liballoc/benches/slice.rs --- rustc-1.30.0+dfsg1+llvm/src/liballoc/benches/slice.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/liballoc/benches/slice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,6 +13,7 @@ use std::ptr; use rand::{Rng, SeedableRng, XorShiftRng}; +use rand::distributions::{Standard, Alphanumeric}; use test::{Bencher, black_box}; #[bench] @@ -192,18 +193,20 @@ (0..len as u64).rev().collect() } +const SEED: [u8; 16] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]; + fn gen_random(len: usize) -> Vec { - let mut rng = XorShiftRng::from_seed([0, 1, 2, 3]); - rng.gen_iter::().take(len).collect() + let mut rng = XorShiftRng::from_seed(SEED); + rng.sample_iter(&Standard).take(len).collect() } fn gen_random_bytes(len: usize) -> Vec { - let mut rng = XorShiftRng::from_seed([0, 1, 2, 3]); - rng.gen_iter::().take(len).collect() + let mut rng = XorShiftRng::from_seed(SEED); + rng.sample_iter(&Standard).take(len).collect() } fn gen_mostly_ascending(len: usize) -> Vec { - let mut rng = XorShiftRng::from_seed([0, 1, 2, 3]); + let mut rng = XorShiftRng::from_seed(SEED); let mut v = gen_ascending(len); for _ in (0usize..).take_while(|x| x * x <= len) { let x = rng.gen::() % len; @@ -214,7 +217,7 @@ } fn gen_mostly_descending(len: usize) -> Vec { - let mut rng = XorShiftRng::from_seed([0, 1, 2, 3]); + let mut rng = XorShiftRng::from_seed(SEED); let mut v = gen_descending(len); for _ in (0usize..).take_while(|x| x * x <= len) { let x = rng.gen::() % len; @@ -225,18 +228,18 @@ } fn gen_strings(len: usize) -> Vec { - let mut rng = XorShiftRng::from_seed([0, 1, 2, 3]); + let mut rng = XorShiftRng::from_seed(SEED); let mut v = vec![]; for _ in 0..len { let n = rng.gen::() % 20 + 1; - v.push(rng.gen_ascii_chars().take(n).collect()); + v.push(rng.sample_iter(&Alphanumeric).take(n).collect()); } v } fn gen_big_random(len: usize) -> Vec<[u64; 16]> { - let mut rng = XorShiftRng::from_seed([0, 1, 2, 3]); - rng.gen_iter().map(|x| [x; 16]).take(len).collect() + let mut rng = XorShiftRng::from_seed(SEED); + rng.sample_iter(&Standard).map(|x| [x; 16]).take(len).collect() } macro_rules! sort { diff -Nru rustc-1.30.0+dfsg1+llvm/src/liballoc/boxed.rs rustc-1.31.0+dfsg1+llvm/src/liballoc/boxed.rs --- rustc-1.30.0+dfsg1+llvm/src/liballoc/boxed.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/liballoc/boxed.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,10 +16,18 @@ //! //! # Examples //! -//! Creating a box: +//! Move a value from the stack to the heap by creating a [`Box`]: //! //! ``` -//! let x = Box::new(5); +//! let val: u8 = 5; +//! let boxed: Box = Box::new(val); +//! ``` +//! +//! Move a value from a [`Box`] back to the stack by [dereferencing]: +//! +//! ``` +//! let boxed: Box = Box::new(5); +//! let val: u8 = *boxed; //! ``` //! //! Creating a recursive data structure: @@ -52,6 +60,9 @@ //! elements are in the list, and so we don't know how much memory to allocate //! for a `Cons`. By introducing a `Box`, which has a defined size, we know how //! big `Cons` needs to be. +//! +//! [dereferencing]: ../../std/ops/trait.Deref.html +//! [`Box`]: struct.Box.html #![stable(feature = "rust1", since = "1.0.0")] @@ -60,18 +71,17 @@ use core::cmp::Ordering; use core::convert::From; use core::fmt; -use core::future::{Future, FutureObj, LocalFutureObj, UnsafeFutureObj}; +use core::future::Future; use core::hash::{Hash, Hasher}; use core::iter::FusedIterator; use core::marker::{Unpin, Unsize}; use core::mem; -use core::pin::PinMut; +use core::pin::Pin; use core::ops::{CoerceUnsized, Deref, DerefMut, Generator, GeneratorState}; use core::ptr::{self, NonNull, Unique}; -use core::task::{Context, Poll, Spawn, SpawnErrorKind, SpawnObjError}; +use core::task::{LocalWaker, Poll}; use raw_vec::RawVec; -use pin::PinBox; use str::from_boxed_utf8_unchecked; /// A pointer type for heap allocation. @@ -97,6 +107,12 @@ pub fn new(x: T) -> Box { box x } + + #[unstable(feature = "pin", issue = "49150")] + #[inline(always)] + pub fn pinned(x: T) -> Pin> { + (box x).into() + } } impl Box { @@ -427,6 +443,16 @@ } } +#[unstable(feature = "pin", issue = "49150")] +impl From> for Pin> { + fn from(boxed: Box) -> Self { + // It's not possible to move or replace the insides of a `Pin>` + // when `T: !Unpin`, so it's safe to pin it directly without any + // additional requirements. + unsafe { Pin::new_unchecked(boxed) } + } +} + #[stable(feature = "box_from_slice", since = "1.17.0")] impl<'a, T: Copy> From<&'a [T]> for Box<[T]> { fn from(slice: &'a [T]) -> Box<[T]> { @@ -789,63 +815,7 @@ impl Future for Box { type Output = F::Output; - fn poll(mut self: PinMut, cx: &mut Context) -> Poll { - PinMut::new(&mut **self).poll(cx) - } -} - -#[unstable(feature = "futures_api", issue = "50547")] -unsafe impl<'a, T, F> UnsafeFutureObj<'a, T> for Box - where F: Future + 'a -{ - fn into_raw(self) -> *mut () { - Box::into_raw(self) as *mut () - } - - unsafe fn poll(ptr: *mut (), cx: &mut Context) -> Poll { - let ptr = ptr as *mut F; - let pin: PinMut = PinMut::new_unchecked(&mut *ptr); - pin.poll(cx) - } - - unsafe fn drop(ptr: *mut ()) { - drop(Box::from_raw(ptr as *mut F)) - } -} - -#[unstable(feature = "futures_api", issue = "50547")] -impl Spawn for Box - where Sp: Spawn + ?Sized -{ - fn spawn_obj( - &mut self, - future: FutureObj<'static, ()>, - ) -> Result<(), SpawnObjError> { - (**self).spawn_obj(future) - } - - fn status(&self) -> Result<(), SpawnErrorKind> { - (**self).status() - } -} - -#[unstable(feature = "futures_api", issue = "50547")] -impl<'a, F: Future + Send + 'a> From> for FutureObj<'a, ()> { - fn from(boxed: Box) -> Self { - FutureObj::new(boxed) - } -} - -#[unstable(feature = "futures_api", issue = "50547")] -impl<'a, F: Future + 'a> From> for LocalFutureObj<'a, ()> { - fn from(boxed: Box) -> Self { - LocalFutureObj::new(boxed) - } -} - -#[unstable(feature = "pin", issue = "49150")] -impl From> for Box { - fn from(pinned: PinBox) -> Box { - unsafe { PinBox::unpin(pinned) } + fn poll(mut self: Pin<&mut Self>, lw: &LocalWaker) -> Poll { + F::poll(Pin::new(&mut *self), lw) } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/liballoc/collections/btree/map.rs rustc-1.31.0+dfsg1+llvm/src/liballoc/collections/btree/map.rs --- rustc-1.30.0+dfsg1+llvm/src/liballoc/collections/btree/map.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/liballoc/collections/btree/map.rs 2018-12-04 23:41:40.000000000 +0000 @@ -77,7 +77,7 @@ /// movie_reviews.insert("Office Space", "Deals with real issues in the workplace."); /// movie_reviews.insert("Pulp Fiction", "Masterpiece."); /// movie_reviews.insert("The Godfather", "Very enjoyable."); -/// movie_reviews.insert("The Blues Brothers", "Eye lyked it alot."); +/// movie_reviews.insert("The Blues Brothers", "Eye lyked it a lot."); /// /// // check for a specific one. /// if !movie_reviews.contains_key("Les Misérables") { diff -Nru rustc-1.30.0+dfsg1+llvm/src/liballoc/collections/btree/node.rs rustc-1.31.0+dfsg1+llvm/src/liballoc/collections/btree/node.rs --- rustc-1.30.0+dfsg1+llvm/src/liballoc/collections/btree/node.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/liballoc/collections/btree/node.rs 2018-12-04 23:41:40.000000000 +0000 @@ -42,7 +42,7 @@ // This implies that even an empty internal node has at least one edge. use core::marker::PhantomData; -use core::mem; +use core::mem::{self, MaybeUninit}; use core::ptr::{self, Unique, NonNull}; use core::slice; @@ -58,9 +58,6 @@ /// these should always be put behind pointers, and specifically behind `BoxedNode` in the owned /// case. /// -/// See also rust-lang/rfcs#197, which would make this structure significantly more safe by -/// avoiding accidentally dropping unused and uninitialized keys and values. -/// /// We put the metadata first so that its position is the same for every `K` and `V`, in order /// to statically allocate a single dummy node to avoid allocations. This struct is `repr(C)` to /// prevent them from being reordered. @@ -73,7 +70,7 @@ /// This node's index into the parent node's `edges` array. /// `*node.parent.edges[node.parent_idx]` should be the same thing as `node`. /// This is only guaranteed to be initialized when `parent` is nonnull. - parent_idx: u16, + parent_idx: MaybeUninit, /// The number of keys and values this node stores. /// @@ -83,8 +80,8 @@ /// The arrays storing the actual data of the node. Only the first `len` elements of each /// array are initialized and valid. - keys: [K; CAPACITY], - vals: [V; CAPACITY], + keys: MaybeUninit<[K; CAPACITY]>, + vals: MaybeUninit<[V; CAPACITY]>, } impl LeafNode { @@ -94,10 +91,10 @@ LeafNode { // As a general policy, we leave fields uninitialized if they can be, as this should // be both slightly faster and easier to track in Valgrind. - keys: mem::uninitialized(), - vals: mem::uninitialized(), + keys: MaybeUninit::uninitialized(), + vals: MaybeUninit::uninitialized(), parent: ptr::null(), - parent_idx: mem::uninitialized(), + parent_idx: MaybeUninit::uninitialized(), len: 0 } } @@ -115,10 +112,10 @@ // ever take a pointer past the first key. static EMPTY_ROOT_NODE: LeafNode<(), ()> = LeafNode { parent: ptr::null(), - parent_idx: 0, + parent_idx: MaybeUninit::uninitialized(), len: 0, - keys: [(); CAPACITY], - vals: [(); CAPACITY], + keys: MaybeUninit::uninitialized(), + vals: MaybeUninit::uninitialized(), }; /// The underlying representation of internal nodes. As with `LeafNode`s, these should be hidden @@ -430,7 +427,7 @@ root: self.root, _marker: PhantomData }, - idx: self.as_leaf().parent_idx as usize, + idx: unsafe { usize::from(*self.as_leaf().parent_idx.get_ref()) }, _marker: PhantomData }) } else { @@ -567,7 +564,7 @@ // the node, which is allowed by LLVM. unsafe { slice::from_raw_parts( - self.as_leaf().keys.as_ptr(), + self.as_leaf().keys.as_ptr() as *const K, self.len() ) } @@ -578,7 +575,7 @@ debug_assert!(!self.is_shared_root()); unsafe { slice::from_raw_parts( - self.as_leaf().vals.as_ptr(), + self.as_leaf().vals.as_ptr() as *const V, self.len() ) } @@ -605,7 +602,7 @@ } else { unsafe { slice::from_raw_parts_mut( - &mut self.as_leaf_mut().keys as *mut [K] as *mut K, + self.as_leaf_mut().keys.get_mut() as *mut [K] as *mut K, self.len() ) } @@ -616,7 +613,7 @@ debug_assert!(!self.is_shared_root()); unsafe { slice::from_raw_parts_mut( - &mut self.as_leaf_mut().vals as *mut [V] as *mut V, + self.as_leaf_mut().vals.get_mut() as *mut [V] as *mut V, self.len() ) } @@ -1013,7 +1010,7 @@ let ptr = self.node.as_internal_mut() as *mut _; let mut child = self.descend(); child.as_leaf_mut().parent = ptr; - child.as_leaf_mut().parent_idx = idx; + child.as_leaf_mut().parent_idx.set(idx); } /// Unsafely asserts to the compiler some static information about whether the underlying @@ -1152,12 +1149,12 @@ ptr::copy_nonoverlapping( self.node.keys().as_ptr().add(self.idx + 1), - new_node.keys.as_mut_ptr(), + new_node.keys.as_mut_ptr() as *mut K, new_len ); ptr::copy_nonoverlapping( self.node.vals().as_ptr().add(self.idx + 1), - new_node.vals.as_mut_ptr(), + new_node.vals.as_mut_ptr() as *mut V, new_len ); @@ -1210,12 +1207,12 @@ ptr::copy_nonoverlapping( self.node.keys().as_ptr().add(self.idx + 1), - new_node.data.keys.as_mut_ptr(), + new_node.data.keys.as_mut_ptr() as *mut K, new_len ); ptr::copy_nonoverlapping( self.node.vals().as_ptr().add(self.idx + 1), - new_node.data.vals.as_mut_ptr(), + new_node.data.vals.as_mut_ptr() as *mut V, new_len ); ptr::copy_nonoverlapping( diff -Nru rustc-1.30.0+dfsg1+llvm/src/liballoc/fmt.rs rustc-1.31.0+dfsg1+llvm/src/liballoc/fmt.rs --- rustc-1.30.0+dfsg1+llvm/src/liballoc/fmt.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/liballoc/fmt.rs 2018-12-04 23:41:40.000000000 +0000 @@ -152,7 +152,7 @@ //! Additionally, the return value of this function is [`fmt::Result`] which is a //! type alias of [`Result`]`<(), `[`std::fmt::Error`]`>`. Formatting implementations //! should ensure that they propagate errors from the [`Formatter`][`Formatter`] (e.g., when -//! calling [`write!`]) however, they should never return errors spuriously. That +//! calling [`write!`]). However, they should never return errors spuriously. That //! is, a formatting implementation must and may only return an error if the //! passed-in [`Formatter`] returns an error. This is because, contrary to what //! the function signature might suggest, string formatting is an infallible @@ -335,8 +335,7 @@ //! //! Each argument being formatted can be transformed by a number of formatting //! parameters (corresponding to `format_spec` in the syntax above). These -//! parameters affect the string representation of what's being formatted. This -//! syntax draws heavily from Python's, so it may seem a bit familiar. +//! parameters affect the string representation of what's being formatted. //! //! ## Fill/Alignment //! diff -Nru rustc-1.30.0+dfsg1+llvm/src/liballoc/lib.rs rustc-1.31.0+dfsg1+llvm/src/liballoc/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/liballoc/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/liballoc/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -76,8 +76,6 @@ #![cfg_attr(not(test), feature(fn_traits))] #![cfg_attr(not(test), feature(generator_trait))] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![cfg_attr(test, feature(test))] #![feature(allocator_api)] @@ -88,8 +86,7 @@ #![feature(box_syntax)] #![feature(cfg_target_has_atomic)] #![feature(coerce_unsized)] -#![cfg_attr(stage0, feature(const_fn))] -#![cfg_attr(not(stage0), feature(min_const_fn))] +#![cfg_attr(stage0, feature(min_const_fn))] #![feature(core_intrinsics)] #![feature(custom_attribute)] #![feature(dropck_eyepatch)] @@ -100,6 +97,7 @@ #![feature(lang_items)] #![feature(libc)] #![feature(needs_allocator)] +#![feature(nll)] #![feature(optin_builtin_traits)] #![feature(pattern)] #![feature(pin)] @@ -117,9 +115,10 @@ #![feature(unsize)] #![feature(allocator_internals)] #![feature(on_unimplemented)] -#![feature(exact_chunks)] #![feature(rustc_const_unstable)] #![feature(const_vec_new)] +#![feature(slice_partition_dedup)] +#![feature(maybe_uninit)] // Allow testing this library @@ -161,7 +160,6 @@ pub mod sync; pub mod rc; pub mod raw_vec; -pub mod pin; pub mod prelude; pub mod borrow; pub mod fmt; diff -Nru rustc-1.30.0+dfsg1+llvm/src/liballoc/pin.rs rustc-1.31.0+dfsg1+llvm/src/liballoc/pin.rs --- rustc-1.30.0+dfsg1+llvm/src/liballoc/pin.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/liballoc/pin.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,302 +0,0 @@ -//! Types which pin data to its location in memory -//! -//! It is sometimes useful to have objects that are guaranteed to not move, -//! in the sense that their placement in memory does not change, and can thus be relied upon. -//! -//! A prime example of such a scenario would be building self-referencial structs, -//! since moving an object with pointers to itself will invalidate them, -//! which could cause undefined behavior. -//! -//! In order to prevent objects from moving, they must be *pinned*, -//! by wrapping the data in pinning pointer types, such as [`PinMut`] and [`PinBox`], -//! which are otherwise equivalent to `& mut` and [`Box`], respectively. -//! -//! First of all, these are pointer types because pinned data mustn't be passed around by value -//! (that would change its location in memory). -//! Secondly, since data can be moved out of `&mut` and [`Box`] with functions such as [`swap`], -//! which causes their contents to swap places in memory, -//! we need dedicated types that prohibit such operations. -//! -//! However, these restrictions are usually not necessary, -//! so most types implement the [`Unpin`] auto-trait, -//! which indicates that the type can be moved out safely. -//! Doing so removes the limitations of pinning types, -//! making them the same as their non-pinning counterparts. -//! -//! [`PinMut`]: struct.PinMut.html -//! [`PinBox`]: struct.PinBox.html -//! [`Unpin`]: trait.Unpin.html -//! [`swap`]: ../../std/mem/fn.swap.html -//! [`Box`]: ../boxed/struct.Box.html -//! -//! # Examples -//! -//! ```rust -//! #![feature(pin)] -//! -//! use std::pin::PinBox; -//! use std::marker::Pinned; -//! use std::ptr::NonNull; -//! -//! // This is a self referencial struct since the slice field points to the data field. -//! // We cannot inform the compiler about that with a normal reference, -//! // since this pattern cannot be described with the usual borrowing rules. -//! // Instead we use a raw pointer, though one which is known to not be null, -//! // since we know it's pointing at the string. -//! struct Unmovable { -//! data: String, -//! slice: NonNull, -//! _pin: Pinned, -//! } -//! -//! impl Unmovable { -//! // To ensure the data doesn't move when the function returns, -//! // we place it in the heap where it will stay for the lifetime of the object, -//! // and the only way to access it would be through a pointer to it. -//! fn new(data: String) -> PinBox { -//! let res = Unmovable { -//! data, -//! // we only create the pointer once the data is in place -//! // otherwise it will have already moved before we even started -//! slice: NonNull::dangling(), -//! _pin: Pinned, -//! }; -//! let mut boxed = PinBox::new(res); -//! -//! let slice = NonNull::from(&boxed.data); -//! // we know this is safe because modifying a field doesn't move the whole struct -//! unsafe { PinBox::get_mut(&mut boxed).slice = slice }; -//! boxed -//! } -//! } -//! -//! let unmoved = Unmovable::new("hello".to_string()); -//! // The pointer should point to the correct location, -//! // so long as the struct hasn't moved. -//! // Meanwhile, we are free to move the pointer around. -//! # #[allow(unused_mut)] -//! let mut still_unmoved = unmoved; -//! assert_eq!(still_unmoved.slice, NonNull::from(&still_unmoved.data)); -//! -//! // Since our type doesn't implement Unpin, this will fail to compile: -//! // let new_unmoved = Unmovable::new("world".to_string()); -//! // std::mem::swap(&mut *still_unmoved, &mut *new_unmoved); -//! ``` - -#![unstable(feature = "pin", issue = "49150")] - -pub use core::pin::*; -pub use core::marker::Unpin; - -use core::convert::From; -use core::fmt; -use core::future::{Future, FutureObj, LocalFutureObj, UnsafeFutureObj}; -use core::marker::Unsize; -use core::ops::{CoerceUnsized, Deref, DerefMut}; -use core::task::{Context, Poll}; - -use boxed::Box; - -/// A pinned, heap allocated reference. -/// -/// This type is similar to [`Box`], except that it pins its value, -/// which prevents it from moving out of the reference, unless it implements [`Unpin`]. -/// -/// See the [module documentation] for furthur explaination on pinning. -/// -/// [`Box`]: ../boxed/struct.Box.html -/// [`Unpin`]: ../../std/marker/trait.Unpin.html -/// [module documentation]: index.html -#[unstable(feature = "pin", issue = "49150")] -#[fundamental] -#[repr(transparent)] -pub struct PinBox { - inner: Box, -} - -#[unstable(feature = "pin", issue = "49150")] -impl PinBox { - /// Allocate memory on the heap, move the data into it and pin it. - #[unstable(feature = "pin", issue = "49150")] - pub fn new(data: T) -> PinBox { - PinBox { inner: Box::new(data) } - } -} - -#[unstable(feature = "pin", issue = "49150")] -impl PinBox { - /// Get a pinned reference to the data in this PinBox. - #[inline] - pub fn as_pin_mut<'a>(&'a mut self) -> PinMut<'a, T> { - unsafe { PinMut::new_unchecked(&mut *self.inner) } - } - - /// Constructs a `PinBox` from a raw pointer. - /// - /// After calling this function, the raw pointer is owned by the - /// resulting `PinBox`. Specifically, the `PinBox` destructor will call - /// the destructor of `T` and free the allocated memory. Since the - /// way `PinBox` allocates and releases memory is unspecified, the - /// only valid pointer to pass to this function is the one taken - /// from another `PinBox` via the [`PinBox::into_raw`] function. - /// - /// This function is unsafe because improper use may lead to - /// memory problems. For example, a double-free may occur if the - /// function is called twice on the same raw pointer. - /// - /// [`PinBox::into_raw`]: struct.PinBox.html#method.into_raw - /// - /// # Examples - /// - /// ``` - /// #![feature(pin)] - /// use std::pin::PinBox; - /// let x = PinBox::new(5); - /// let ptr = PinBox::into_raw(x); - /// let x = unsafe { PinBox::from_raw(ptr) }; - /// ``` - #[inline] - pub unsafe fn from_raw(raw: *mut T) -> Self { - PinBox { inner: Box::from_raw(raw) } - } - - /// Consumes the `PinBox`, returning the wrapped raw pointer. - /// - /// After calling this function, the caller is responsible for the - /// memory previously managed by the `PinBox`. In particular, the - /// caller should properly destroy `T` and release the memory. The - /// proper way to do so is to convert the raw pointer back into a - /// `PinBox` with the [`PinBox::from_raw`] function. - /// - /// Note: this is an associated function, which means that you have - /// to call it as `PinBox::into_raw(b)` instead of `b.into_raw()`. This - /// is so that there is no conflict with a method on the inner type. - /// - /// [`PinBox::from_raw`]: struct.PinBox.html#method.from_raw - /// - /// # Examples - /// - /// ``` - /// #![feature(pin)] - /// use std::pin::PinBox; - /// let x = PinBox::new(5); - /// let ptr = PinBox::into_raw(x); - /// ``` - #[inline] - pub fn into_raw(b: PinBox) -> *mut T { - Box::into_raw(b.inner) - } - - /// Get a mutable reference to the data inside this PinBox. - /// - /// This function is unsafe. Users must guarantee that the data is never - /// moved out of this reference. - #[inline] - pub unsafe fn get_mut<'a>(this: &'a mut PinBox) -> &'a mut T { - &mut *this.inner - } - - /// Convert this PinBox into an unpinned Box. - /// - /// This function is unsafe. Users must guarantee that the data is never - /// moved out of the box. - #[inline] - pub unsafe fn unpin(this: PinBox) -> Box { - this.inner - } -} - -#[unstable(feature = "pin", issue = "49150")] -impl From> for PinBox { - fn from(boxed: Box) -> PinBox { - PinBox { inner: boxed } - } -} - -#[unstable(feature = "pin", issue = "49150")] -impl Deref for PinBox { - type Target = T; - - fn deref(&self) -> &T { - &*self.inner - } -} - -#[unstable(feature = "pin", issue = "49150")] -impl DerefMut for PinBox { - fn deref_mut(&mut self) -> &mut T { - &mut *self.inner - } -} - -#[unstable(feature = "pin", issue = "49150")] -impl fmt::Display for PinBox { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Display::fmt(&*self.inner, f) - } -} - -#[unstable(feature = "pin", issue = "49150")] -impl fmt::Debug for PinBox { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Debug::fmt(&*self.inner, f) - } -} - -#[unstable(feature = "pin", issue = "49150")] -impl fmt::Pointer for PinBox { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - // It's not possible to extract the inner Uniq directly from the Box, - // instead we cast it to a *const which aliases the Unique - let ptr: *const T = &*self.inner; - fmt::Pointer::fmt(&ptr, f) - } -} - -#[unstable(feature = "pin", issue = "49150")] -impl, U: ?Sized> CoerceUnsized> for PinBox {} - -#[unstable(feature = "pin", issue = "49150")] -impl Unpin for PinBox {} - -#[unstable(feature = "futures_api", issue = "50547")] -impl Future for PinBox { - type Output = F::Output; - - fn poll(mut self: PinMut, cx: &mut Context) -> Poll { - self.as_pin_mut().poll(cx) - } -} - -#[unstable(feature = "futures_api", issue = "50547")] -unsafe impl<'a, T, F> UnsafeFutureObj<'a, T> for PinBox - where F: Future + 'a -{ - fn into_raw(self) -> *mut () { - PinBox::into_raw(self) as *mut () - } - - unsafe fn poll(ptr: *mut (), cx: &mut Context) -> Poll { - let ptr = ptr as *mut F; - let pin: PinMut = PinMut::new_unchecked(&mut *ptr); - pin.poll(cx) - } - - unsafe fn drop(ptr: *mut ()) { - drop(PinBox::from_raw(ptr as *mut F)) - } -} - -#[unstable(feature = "futures_api", issue = "50547")] -impl<'a, F: Future + Send + 'a> From> for FutureObj<'a, ()> { - fn from(boxed: PinBox) -> Self { - FutureObj::new(boxed) - } -} - -#[unstable(feature = "futures_api", issue = "50547")] -impl<'a, F: Future + 'a> From> for LocalFutureObj<'a, ()> { - fn from(boxed: PinBox) -> Self { - LocalFutureObj::new(boxed) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/liballoc/rc.rs rustc-1.31.0+dfsg1+llvm/src/liballoc/rc.rs --- rustc-1.30.0+dfsg1+llvm/src/liballoc/rc.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/liballoc/rc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -43,8 +43,8 @@ //! //! `Rc` automatically dereferences to `T` (via the [`Deref`] trait), //! so you can call `T`'s methods on a value of type [`Rc`][`Rc`]. To avoid name -//! clashes with `T`'s methods, the methods of [`Rc`][`Rc`] itself are [associated -//! functions][assoc], called using function-like syntax: +//! clashes with `T`'s methods, the methods of [`Rc`][`Rc`] itself are associated +//! functions, called using function-like syntax: //! //! ``` //! use std::rc::Rc; @@ -234,7 +234,6 @@ //! [downgrade]: struct.Rc.html#method.downgrade //! [upgrade]: struct.Weak.html#method.upgrade //! [`None`]: ../../std/option/enum.Option.html#variant.None -//! [assoc]: ../../book/first-edition/method-syntax.html#associated-functions //! [mutability]: ../../std/cell/index.html#introducing-mutability-inside-of-something-immutable #![stable(feature = "rust1", since = "1.0.0")] @@ -256,6 +255,7 @@ use core::mem::{self, align_of_val, forget, size_of_val}; use core::ops::Deref; use core::ops::CoerceUnsized; +use core::pin::Pin; use core::ptr::{self, NonNull}; use core::convert::From; use core::usize; @@ -281,6 +281,7 @@ /// type `T`. /// /// [get_mut]: #method.get_mut +#[cfg_attr(all(not(stage0), not(test)), lang = "rc")] #[stable(feature = "rust1", since = "1.0.0")] pub struct Rc { ptr: NonNull>, @@ -321,6 +322,11 @@ } } + #[unstable(feature = "pin", issue = "49150")] + pub fn pinned(value: T) -> Pin> { + unsafe { Pin::new_unchecked(Rc::new(value)) } + } + /// Returns the contained value, if the `Rc` has exactly one strong reference. /// /// Otherwise, an [`Err`][result] is returned with the same `Rc` that was @@ -860,7 +866,7 @@ /// /// let five = Rc::new(5); /// - /// Rc::clone(&five); + /// let _ = Rc::clone(&five); /// ``` #[inline] fn clone(&self) -> Rc { @@ -1297,7 +1303,7 @@ /// /// let weak_five = Rc::downgrade(&Rc::new(5)); /// - /// Weak::clone(&weak_five); + /// let _ = Weak::clone(&weak_five); /// ``` #[inline] fn clone(&self) -> Weak { diff -Nru rustc-1.30.0+dfsg1+llvm/src/liballoc/slice.rs rustc-1.31.0+dfsg1+llvm/src/liballoc/slice.rs --- rustc-1.30.0+dfsg1+llvm/src/liballoc/slice.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/liballoc/slice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -123,8 +123,10 @@ pub use core::slice::{from_ref, from_mut}; #[stable(feature = "slice_get_slice", since = "1.28.0")] pub use core::slice::SliceIndex; -#[unstable(feature = "exact_chunks", issue = "47115")] -pub use core::slice::{ExactChunks, ExactChunksMut}; +#[stable(feature = "chunks_exact", since = "1.31.0")] +pub use core::slice::{ChunksExact, ChunksExactMut}; +#[stable(feature = "rchunks", since = "1.31.0")] +pub use core::slice::{RChunks, RChunksMut, RChunksExact, RChunksExactMut}; //////////////////////////////////////////////////////////////////////////////// // Basic slice extension methods diff -Nru rustc-1.30.0+dfsg1+llvm/src/liballoc/string.rs rustc-1.31.0+dfsg1+llvm/src/liballoc/string.rs --- rustc-1.30.0+dfsg1+llvm/src/liballoc/string.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/liballoc/string.rs 2018-12-04 23:41:40.000000000 +0000 @@ -2196,6 +2196,7 @@ #[stable(feature = "rust1", since = "1.0.0")] impl<'a> From<&'a str> for String { + #[inline] fn from(s: &'a str) -> String { s.to_owned() } diff -Nru rustc-1.30.0+dfsg1+llvm/src/liballoc/str.rs rustc-1.31.0+dfsg1+llvm/src/liballoc/str.rs --- rustc-1.30.0+dfsg1+llvm/src/liballoc/str.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/liballoc/str.rs 2018-12-04 23:41:40.000000000 +0000 @@ -203,6 +203,7 @@ #[stable(feature = "rust1", since = "1.0.0")] impl ToOwned for str { type Owned = String; + #[inline] fn to_owned(&self) -> String { unsafe { String::from_utf8_unchecked(self.as_bytes().to_owned()) } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/liballoc/sync.rs rustc-1.31.0+dfsg1+llvm/src/liballoc/sync.rs --- rustc-1.30.0+dfsg1+llvm/src/liballoc/sync.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/liballoc/sync.rs 2018-12-04 23:41:40.000000000 +0000 @@ -26,6 +26,7 @@ use core::mem::{self, align_of_val, size_of_val}; use core::ops::Deref; use core::ops::CoerceUnsized; +use core::pin::Pin; use core::ptr::{self, NonNull}; use core::marker::{Unpin, Unsize, PhantomData}; use core::hash::{Hash, Hasher}; @@ -119,8 +120,8 @@ /// /// `Arc` automatically dereferences to `T` (via the [`Deref`][deref] trait), /// so you can call `T`'s methods on a value of type `Arc`. To avoid name -/// clashes with `T`'s methods, the methods of `Arc` itself are [associated -/// functions][assoc], called using function-like syntax: +/// clashes with `T`'s methods, the methods of `Arc` itself are associated +/// functions, called using function-like syntax: /// /// ``` /// use std::sync::Arc; @@ -145,7 +146,6 @@ /// [downgrade]: struct.Arc.html#method.downgrade /// [upgrade]: struct.Weak.html#method.upgrade /// [`None`]: ../../std/option/enum.Option.html#variant.None -/// [assoc]: ../../book/first-edition/method-syntax.html#associated-functions /// [`RefCell`]: ../../std/cell/struct.RefCell.html /// [`std::sync`]: ../../std/sync/index.html /// [`Arc::clone(&from)`]: #method.clone @@ -198,6 +198,7 @@ /// counting in general. /// /// [rc_examples]: ../../std/rc/index.html#examples +#[cfg_attr(all(not(stage0), not(test)), lang = "arc")] #[stable(feature = "rust1", since = "1.0.0")] pub struct Arc { ptr: NonNull>, @@ -297,6 +298,11 @@ Arc { ptr: Box::into_raw_non_null(x), phantom: PhantomData } } + #[unstable(feature = "pin", issue = "49150")] + pub fn pinned(data: T) -> Pin> { + unsafe { Pin::new_unchecked(Arc::new(data)) } + } + /// Returns the contained value, if the `Arc` has exactly one strong reference. /// /// Otherwise, an [`Err`][result] is returned with the same `Arc` that was @@ -706,7 +712,7 @@ /// /// let five = Arc::new(5); /// - /// Arc::clone(&five); + /// let _ = Arc::clone(&five); /// ``` #[inline] fn clone(&self) -> Arc { @@ -1128,7 +1134,7 @@ /// /// let weak_five = Arc::downgrade(&Arc::new(5)); /// - /// Weak::clone(&weak_five); + /// let _ = Weak::clone(&weak_five); /// ``` #[inline] fn clone(&self) -> Weak { diff -Nru rustc-1.30.0+dfsg1+llvm/src/liballoc/tests/lib.rs rustc-1.31.0+dfsg1+llvm/src/liballoc/tests/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/liballoc/tests/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/liballoc/tests/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,8 +11,7 @@ #![feature(allocator_api)] #![feature(alloc_system)] #![feature(box_syntax)] -#![cfg_attr(stage0, feature(const_fn))] -#![cfg_attr(not(stage0), feature(min_const_fn))] +#![cfg_attr(stage0, feature(min_const_fn))] #![feature(drain_filter)] #![feature(exact_size_is_empty)] #![feature(pattern)] @@ -20,7 +19,6 @@ #![feature(str_escape)] #![feature(try_reserve)] #![feature(unboxed_closures)] -#![feature(exact_chunks)] #![feature(repeat_generic_slice)] extern crate alloc_system; diff -Nru rustc-1.30.0+dfsg1+llvm/src/liballoc/tests/slice.rs rustc-1.31.0+dfsg1+llvm/src/liballoc/tests/slice.rs --- rustc-1.30.0+dfsg1+llvm/src/liballoc/tests/slice.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/liballoc/tests/slice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -975,27 +975,75 @@ } #[test] -fn test_exact_chunksator() { +fn test_chunks_exactator() { let v = &[1, 2, 3, 4, 5]; - assert_eq!(v.exact_chunks(2).len(), 2); + assert_eq!(v.chunks_exact(2).len(), 2); let chunks: &[&[_]] = &[&[1, 2], &[3, 4]]; - assert_eq!(v.exact_chunks(2).collect::>(), chunks); + assert_eq!(v.chunks_exact(2).collect::>(), chunks); let chunks: &[&[_]] = &[&[1, 2, 3]]; - assert_eq!(v.exact_chunks(3).collect::>(), chunks); + assert_eq!(v.chunks_exact(3).collect::>(), chunks); let chunks: &[&[_]] = &[]; - assert_eq!(v.exact_chunks(6).collect::>(), chunks); + assert_eq!(v.chunks_exact(6).collect::>(), chunks); let chunks: &[&[_]] = &[&[3, 4], &[1, 2]]; - assert_eq!(v.exact_chunks(2).rev().collect::>(), chunks); + assert_eq!(v.chunks_exact(2).rev().collect::>(), chunks); } #[test] #[should_panic] -fn test_exact_chunksator_0() { +fn test_chunks_exactator_0() { let v = &[1, 2, 3, 4]; - let _it = v.exact_chunks(0); + let _it = v.chunks_exact(0); +} + +#[test] +fn test_rchunksator() { + let v = &[1, 2, 3, 4, 5]; + + assert_eq!(v.rchunks(2).len(), 3); + + let chunks: &[&[_]] = &[&[4, 5], &[2, 3], &[1]]; + assert_eq!(v.rchunks(2).collect::>(), chunks); + let chunks: &[&[_]] = &[&[3, 4, 5], &[1, 2]]; + assert_eq!(v.rchunks(3).collect::>(), chunks); + let chunks: &[&[_]] = &[&[1, 2, 3, 4, 5]]; + assert_eq!(v.rchunks(6).collect::>(), chunks); + + let chunks: &[&[_]] = &[&[1], &[2, 3], &[4, 5]]; + assert_eq!(v.rchunks(2).rev().collect::>(), chunks); +} + +#[test] +#[should_panic] +fn test_rchunksator_0() { + let v = &[1, 2, 3, 4]; + let _it = v.rchunks(0); +} + +#[test] +fn test_rchunks_exactator() { + let v = &[1, 2, 3, 4, 5]; + + assert_eq!(v.rchunks_exact(2).len(), 2); + + let chunks: &[&[_]] = &[&[4, 5], &[2, 3]]; + assert_eq!(v.rchunks_exact(2).collect::>(), chunks); + let chunks: &[&[_]] = &[&[3, 4, 5]]; + assert_eq!(v.rchunks_exact(3).collect::>(), chunks); + let chunks: &[&[_]] = &[]; + assert_eq!(v.rchunks_exact(6).collect::>(), chunks); + + let chunks: &[&[_]] = &[&[2, 3], &[4, 5]]; + assert_eq!(v.rchunks_exact(2).rev().collect::>(), chunks); +} + +#[test] +#[should_panic] +fn test_rchunks_exactator_0() { + let v = &[1, 2, 3, 4]; + let _it = v.rchunks_exact(0); } #[test] @@ -1205,7 +1253,7 @@ #[test] fn test_mut_chunks() { let mut v = [0, 1, 2, 3, 4, 5, 6]; - assert_eq!(v.chunks_mut(2).len(), 4); + assert_eq!(v.chunks_mut(3).len(), 3); for (i, chunk) in v.chunks_mut(3).enumerate() { for x in chunk { *x = i as u8; @@ -1235,10 +1283,10 @@ } #[test] -fn test_mut_exact_chunks() { +fn test_mut_chunks_exact() { let mut v = [0, 1, 2, 3, 4, 5, 6]; - assert_eq!(v.exact_chunks_mut(2).len(), 3); - for (i, chunk) in v.exact_chunks_mut(3).enumerate() { + assert_eq!(v.chunks_exact_mut(3).len(), 2); + for (i, chunk) in v.chunks_exact_mut(3).enumerate() { for x in chunk { *x = i as u8; } @@ -1248,9 +1296,9 @@ } #[test] -fn test_mut_exact_chunks_rev() { +fn test_mut_chunks_exact_rev() { let mut v = [0, 1, 2, 3, 4, 5, 6]; - for (i, chunk) in v.exact_chunks_mut(3).rev().enumerate() { + for (i, chunk) in v.chunks_exact_mut(3).rev().enumerate() { for x in chunk { *x = i as u8; } @@ -1261,9 +1309,73 @@ #[test] #[should_panic] -fn test_mut_exact_chunks_0() { +fn test_mut_chunks_exact_0() { + let mut v = [1, 2, 3, 4]; + let _it = v.chunks_exact_mut(0); +} + +#[test] +fn test_mut_rchunks() { + let mut v = [0, 1, 2, 3, 4, 5, 6]; + assert_eq!(v.rchunks_mut(3).len(), 3); + for (i, chunk) in v.rchunks_mut(3).enumerate() { + for x in chunk { + *x = i as u8; + } + } + let result = [2, 1, 1, 1, 0, 0, 0]; + assert_eq!(v, result); +} + +#[test] +fn test_mut_rchunks_rev() { + let mut v = [0, 1, 2, 3, 4, 5, 6]; + for (i, chunk) in v.rchunks_mut(3).rev().enumerate() { + for x in chunk { + *x = i as u8; + } + } + let result = [0, 1, 1, 1, 2, 2, 2]; + assert_eq!(v, result); +} + +#[test] +#[should_panic] +fn test_mut_rchunks_0() { + let mut v = [1, 2, 3, 4]; + let _it = v.rchunks_mut(0); +} + +#[test] +fn test_mut_rchunks_exact() { + let mut v = [0, 1, 2, 3, 4, 5, 6]; + assert_eq!(v.rchunks_exact_mut(3).len(), 2); + for (i, chunk) in v.rchunks_exact_mut(3).enumerate() { + for x in chunk { + *x = i as u8; + } + } + let result = [0, 1, 1, 1, 0, 0, 0]; + assert_eq!(v, result); +} + +#[test] +fn test_mut_rchunks_exact_rev() { + let mut v = [0, 1, 2, 3, 4, 5, 6]; + for (i, chunk) in v.rchunks_exact_mut(3).rev().enumerate() { + for x in chunk { + *x = i as u8; + } + } + let result = [0, 0, 0, 0, 1, 1, 1]; + assert_eq!(v, result); +} + +#[test] +#[should_panic] +fn test_mut_rchunks_exact_0() { let mut v = [1, 2, 3, 4]; - let _it = v.exact_chunks_mut(0); + let _it = v.rchunks_exact_mut(0); } #[test] diff -Nru rustc-1.30.0+dfsg1+llvm/src/liballoc/vec.rs rustc-1.31.0+dfsg1+llvm/src/liballoc/vec.rs --- rustc-1.30.0+dfsg1+llvm/src/liballoc/vec.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/liballoc/vec.rs 2018-12-04 23:41:40.000000000 +0000 @@ -120,11 +120,17 @@ /// assert_eq!(vec, [1, 2, 3, 4]); /// ``` /// -/// It can also initialize each element of a `Vec` with a given value: +/// It can also initialize each element of a `Vec` with a given value. +/// This may be more efficient than performing allocation and initialization +/// in separate steps, especially when initializing a vector of zeros: /// /// ``` /// let vec = vec![0; 5]; /// assert_eq!(vec, [0, 0, 0, 0, 0]); +/// +/// // The following is equivalent, but potentially slower: +/// let mut vec1 = Vec::with_capacity(5); +/// vec1.resize(5, 0); /// ``` /// /// Use a `Vec` as an efficient stack: @@ -947,10 +953,9 @@ /// Removes all but the first of consecutive elements in the vector satisfying a given equality /// relation. /// - /// The `same_bucket` function is passed references to two elements from the vector, and - /// returns `true` if the elements compare equal, or `false` if they do not. The elements are - /// passed in opposite order from their order in the vector, so if `same_bucket(a, b)` returns - /// `true`, `a` is removed. + /// The `same_bucket` function is passed references to two elements from the vector and + /// must determine if the elements compare equal. The elements are passed in opposite order + /// from their order in the slice, so if `same_bucket(a, b)` returns `true`, `a` is removed. /// /// If the vector is sorted, this removes all duplicates. /// @@ -964,90 +969,12 @@ /// assert_eq!(vec, ["foo", "bar", "baz", "bar"]); /// ``` #[stable(feature = "dedup_by", since = "1.16.0")] - pub fn dedup_by(&mut self, mut same_bucket: F) where F: FnMut(&mut T, &mut T) -> bool { - unsafe { - // Although we have a mutable reference to `self`, we cannot make - // *arbitrary* changes. The `same_bucket` calls could panic, so we - // must ensure that the vector is in a valid state at all time. - // - // The way that we handle this is by using swaps; we iterate - // over all the elements, swapping as we go so that at the end - // the elements we wish to keep are in the front, and those we - // wish to reject are at the back. We can then truncate the - // vector. This operation is still O(n). - // - // Example: We start in this state, where `r` represents "next - // read" and `w` represents "next_write`. - // - // r - // +---+---+---+---+---+---+ - // | 0 | 1 | 1 | 2 | 3 | 3 | - // +---+---+---+---+---+---+ - // w - // - // Comparing self[r] against self[w-1], this is not a duplicate, so - // we swap self[r] and self[w] (no effect as r==w) and then increment both - // r and w, leaving us with: - // - // r - // +---+---+---+---+---+---+ - // | 0 | 1 | 1 | 2 | 3 | 3 | - // +---+---+---+---+---+---+ - // w - // - // Comparing self[r] against self[w-1], this value is a duplicate, - // so we increment `r` but leave everything else unchanged: - // - // r - // +---+---+---+---+---+---+ - // | 0 | 1 | 1 | 2 | 3 | 3 | - // +---+---+---+---+---+---+ - // w - // - // Comparing self[r] against self[w-1], this is not a duplicate, - // so swap self[r] and self[w] and advance r and w: - // - // r - // +---+---+---+---+---+---+ - // | 0 | 1 | 2 | 1 | 3 | 3 | - // +---+---+---+---+---+---+ - // w - // - // Not a duplicate, repeat: - // - // r - // +---+---+---+---+---+---+ - // | 0 | 1 | 2 | 3 | 1 | 3 | - // +---+---+---+---+---+---+ - // w - // - // Duplicate, advance r. End of vec. Truncate to w. - - let ln = self.len(); - if ln <= 1 { - return; - } - - // Avoid bounds checks by using raw pointers. - let p = self.as_mut_ptr(); - let mut r: usize = 1; - let mut w: usize = 1; - - while r < ln { - let p_r = p.add(r); - let p_wm1 = p.add(w - 1); - if !same_bucket(&mut *p_r, &mut *p_wm1) { - if r != w { - let p_w = p_wm1.offset(1); - mem::swap(&mut *p_r, &mut *p_w); - } - w += 1; - } - r += 1; - } - - self.truncate(w); - } + pub fn dedup_by(&mut self, same_bucket: F) where F: FnMut(&mut T, &mut T) -> bool { + let len = { + let (dedup, _) = self.as_mut_slice().partition_dedup_by(same_bucket); + dedup.len() + }; + self.truncate(len); } /// Appends an element to the back of a collection. @@ -1533,7 +1460,8 @@ } impl Vec { - /// Removes consecutive repeated elements in the vector. + /// Removes consecutive repeated elements in the vector according to the + /// [`PartialEq`] trait implementation. /// /// If the vector is sorted, this removes all duplicates. /// @@ -1900,12 +1828,12 @@ unsafe { let mut ptr = self.as_mut_ptr().add(self.len()); let mut local_len = SetLenOnDrop::new(&mut self.len); - for element in iterator { + iterator.for_each(move |element| { ptr::write(ptr, element); ptr = ptr.offset(1); // NB can't overflow since we would have had to alloc the address space local_len.increment_len(1); - } + }); } } else { self.extend_desugared(iterator) diff -Nru rustc-1.30.0+dfsg1+llvm/src/liballoc_jemalloc/lib.rs rustc-1.31.0+dfsg1+llvm/src/liballoc_jemalloc/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/liballoc_jemalloc/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/liballoc_jemalloc/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,8 +16,7 @@ #![feature(core_intrinsics)] #![feature(libc)] #![feature(linkage)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(staged_api)] #![feature(rustc_attrs)] #![cfg_attr(dummy_jemalloc, allow(dead_code, unused_extern_crates))] @@ -91,7 +90,6 @@ // ABI #[rustc_std_internal_symbol] - #[cfg_attr(stage0, no_mangle)] pub unsafe extern fn __rde_alloc(size: usize, align: usize) -> *mut u8 { let flags = align_to_flags(align, size); let ptr = mallocx(size as size_t, flags) as *mut u8; @@ -99,7 +97,6 @@ } #[rustc_std_internal_symbol] - #[cfg_attr(stage0, no_mangle)] pub unsafe extern fn __rde_dealloc(ptr: *mut u8, size: usize, align: usize) { @@ -108,7 +105,6 @@ } #[rustc_std_internal_symbol] - #[cfg_attr(stage0, no_mangle)] pub unsafe extern fn __rde_realloc(ptr: *mut u8, _old_size: usize, align: usize, @@ -119,7 +115,6 @@ } #[rustc_std_internal_symbol] - #[cfg_attr(stage0, no_mangle)] pub unsafe extern fn __rde_alloc_zeroed(size: usize, align: usize) -> *mut u8 { let ptr = if align <= MIN_ALIGN && align <= size { calloc(size as size_t, 1) as *mut u8 diff -Nru rustc-1.30.0+dfsg1+llvm/src/liballoc_system/lib.rs rustc-1.31.0+dfsg1+llvm/src/liballoc_system/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/liballoc_system/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/liballoc_system/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -17,10 +17,13 @@ #![feature(allocator_api)] #![feature(core_intrinsics)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(staged_api)] #![feature(rustc_attrs)] +#![cfg_attr( + all(target_arch = "wasm32", not(target_os = "emscripten")), + feature(integer_atomics, stdsimd) +)] #![cfg_attr(any(unix, target_os = "cloudabi", target_os = "redox"), feature(libc))] #![rustc_alloc_kind = "lib"] @@ -332,29 +335,76 @@ use core::alloc::{GlobalAlloc, Layout}; use System; - // No need for synchronization here as wasm is currently single-threaded static mut DLMALLOC: dlmalloc::Dlmalloc = dlmalloc::DLMALLOC_INIT; #[stable(feature = "alloc_system_type", since = "1.28.0")] unsafe impl GlobalAlloc for System { #[inline] unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + let _lock = lock::lock(); DLMALLOC.malloc(layout.size(), layout.align()) } #[inline] unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { + let _lock = lock::lock(); DLMALLOC.calloc(layout.size(), layout.align()) } #[inline] unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { + let _lock = lock::lock(); DLMALLOC.free(ptr, layout.size(), layout.align()) } #[inline] unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { + let _lock = lock::lock(); DLMALLOC.realloc(ptr, layout.size(), layout.align(), new_size) } } + + #[cfg(target_feature = "atomics")] + mod lock { + use core::arch::wasm32; + use core::sync::atomic::{AtomicI32, Ordering::SeqCst}; + + static LOCKED: AtomicI32 = AtomicI32::new(0); + + pub struct DropLock; + + pub fn lock() -> DropLock { + loop { + if LOCKED.swap(1, SeqCst) == 0 { + return DropLock + } + unsafe { + let r = wasm32::atomic::wait_i32( + &LOCKED as *const AtomicI32 as *mut i32, + 1, // expected value + -1, // timeout + ); + debug_assert!(r == 0 || r == 1); + } + } + } + + impl Drop for DropLock { + fn drop(&mut self) { + let r = LOCKED.swap(0, SeqCst); + debug_assert_eq!(r, 1); + unsafe { + wasm32::atomic::wake( + &LOCKED as *const AtomicI32 as *mut i32, + 1, // only one thread + ); + } + } + } + } + + #[cfg(not(target_feature = "atomics"))] + mod lock { + pub fn lock() {} // no atomics, no threads, that's easy! + } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libarena/lib.rs rustc-1.31.0+dfsg1+llvm/src/libarena/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/libarena/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libarena/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -26,8 +26,7 @@ #![feature(alloc)] #![feature(core_intrinsics)] #![feature(dropck_eyepatch)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(raw_vec_internals)] #![cfg_attr(test, feature(test))] @@ -115,10 +114,9 @@ const PAGE: usize = 4096; -impl TypedArena { +impl Default for TypedArena { /// Creates a new `TypedArena`. - #[inline] - pub fn new() -> TypedArena { + fn default() -> TypedArena { TypedArena { // We set both `ptr` and `end` to 0 so that the first call to // alloc() will trigger a grow(). @@ -128,7 +126,9 @@ _own: PhantomData, } } +} +impl TypedArena { /// Allocates an object in the `TypedArena`, returning a reference to it. #[inline] pub fn alloc(&self, object: T) -> &mut T { @@ -297,15 +297,17 @@ unsafe impl Send for DroplessArena {} -impl DroplessArena { - pub fn new() -> DroplessArena { +impl Default for DroplessArena { + fn default() -> DroplessArena { DroplessArena { ptr: Cell::new(0 as *mut u8), end: Cell::new(0 as *mut u8), - chunks: RefCell::new(vec![]), + chunks: Default::default(), } } +} +impl DroplessArena { pub fn in_arena(&self, ptr: *const T) -> bool { let ptr = ptr as *const u8 as *mut u8; for chunk in &*self.chunks.borrow() { @@ -420,19 +422,14 @@ } } +#[derive(Default)] +// FIXME(@Zoxc): this type is entirely unused in rustc pub struct SyncTypedArena { lock: MTLock>, } impl SyncTypedArena { #[inline(always)] - pub fn new() -> SyncTypedArena { - SyncTypedArena { - lock: MTLock::new(TypedArena::new()) - } - } - - #[inline(always)] pub fn alloc(&self, object: T) -> &mut T { // Extend the lifetime of the result since it's limited to the lock guard unsafe { &mut *(self.lock.lock().alloc(object) as *mut T) } @@ -453,19 +450,13 @@ } } +#[derive(Default)] pub struct SyncDroplessArena { lock: MTLock, } impl SyncDroplessArena { #[inline(always)] - pub fn new() -> SyncDroplessArena { - SyncDroplessArena { - lock: MTLock::new(DroplessArena::new()) - } - } - - #[inline(always)] pub fn in_arena(&self, ptr: *const T) -> bool { self.lock.lock().in_arena(ptr) } @@ -509,7 +500,7 @@ #[test] pub fn test_unused() { - let arena: TypedArena = TypedArena::new(); + let arena: TypedArena = TypedArena::default(); assert!(arena.chunks.borrow().is_empty()); } @@ -547,7 +538,7 @@ } } - let arena = Wrap(TypedArena::new()); + let arena = Wrap(TypedArena::default()); let result = arena.alloc_outer(|| Outer { inner: arena.alloc_inner(|| Inner { value: 10 }), @@ -558,7 +549,7 @@ #[test] pub fn test_copy() { - let arena = TypedArena::new(); + let arena = TypedArena::default(); for _ in 0..100000 { arena.alloc(Point { x: 1, y: 2, z: 3 }); } @@ -566,7 +557,7 @@ #[bench] pub fn bench_copy(b: &mut Bencher) { - let arena = TypedArena::new(); + let arena = TypedArena::default(); b.iter(|| arena.alloc(Point { x: 1, y: 2, z: 3 })) } @@ -585,7 +576,7 @@ #[test] pub fn test_noncopy() { - let arena = TypedArena::new(); + let arena = TypedArena::default(); for _ in 0..100000 { arena.alloc(Noncopy { string: "hello world".to_string(), @@ -596,7 +587,7 @@ #[test] pub fn test_typed_arena_zero_sized() { - let arena = TypedArena::new(); + let arena = TypedArena::default(); for _ in 0..100000 { arena.alloc(()); } @@ -604,7 +595,7 @@ #[test] pub fn test_typed_arena_clear() { - let mut arena = TypedArena::new(); + let mut arena = TypedArena::default(); for _ in 0..10 { arena.clear(); for _ in 0..10000 { @@ -629,7 +620,7 @@ fn test_typed_arena_drop_count() { let counter = Cell::new(0); { - let arena: TypedArena = TypedArena::new(); + let arena: TypedArena = TypedArena::default(); for _ in 0..100 { // Allocate something with drop glue to make sure it doesn't leak. arena.alloc(DropCounter { count: &counter }); @@ -641,7 +632,7 @@ #[test] fn test_typed_arena_drop_on_clear() { let counter = Cell::new(0); - let mut arena: TypedArena = TypedArena::new(); + let mut arena: TypedArena = TypedArena::default(); for i in 0..10 { for _ in 0..100 { // Allocate something with drop glue to make sure it doesn't leak. @@ -668,7 +659,7 @@ fn test_typed_arena_drop_small_count() { DROP_COUNTER.with(|c| c.set(0)); { - let arena: TypedArena = TypedArena::new(); + let arena: TypedArena = TypedArena::default(); for _ in 0..100 { // Allocate something with drop glue to make sure it doesn't leak. arena.alloc(SmallDroppable); @@ -680,7 +671,7 @@ #[bench] pub fn bench_noncopy(b: &mut Bencher) { - let arena = TypedArena::new(); + let arena = TypedArena::default(); b.iter(|| { arena.alloc(Noncopy { string: "hello world".to_string(), diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/alloc.rs rustc-1.31.0+dfsg1+llvm/src/libcore/alloc.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/alloc.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/alloc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -518,7 +518,7 @@ /// The block is described by the given `ptr` pointer and `layout`. /// /// If this returns a non-null pointer, then ownership of the memory block - /// referenced by `ptr` has been transferred to this alloctor. + /// referenced by `ptr` has been transferred to this allocator. /// The memory may or may not have been deallocated, /// and should be considered unusable (unless of course it was /// transferred back to the caller again via the return value of diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/borrow.rs rustc-1.31.0+dfsg1+llvm/src/libcore/borrow.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/borrow.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/borrow.rs 2018-12-04 23:41:40.000000000 +0000 @@ -226,16 +226,16 @@ } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> Borrow for &'a T { +impl Borrow for &T { fn borrow(&self) -> &T { &**self } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> Borrow for &'a mut T { +impl Borrow for &mut T { fn borrow(&self) -> &T { &**self } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> BorrowMut for &'a mut T { +impl BorrowMut for &mut T { fn borrow_mut(&mut self) -> &mut T { &mut **self } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/cell.rs rustc-1.31.0+dfsg1+llvm/src/libcore/cell.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/cell.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/cell.rs 2018-12-04 23:41:40.000000000 +0000 @@ -1092,7 +1092,7 @@ } } -impl<'b> Drop for BorrowRef<'b> { +impl Drop for BorrowRef<'_> { #[inline] fn drop(&mut self) { let borrow = self.borrow.get(); @@ -1101,9 +1101,9 @@ } } -impl<'b> Clone for BorrowRef<'b> { +impl Clone for BorrowRef<'_> { #[inline] - fn clone(&self) -> BorrowRef<'b> { + fn clone(&self) -> Self { // Since this Ref exists, we know the borrow flag // is a reading borrow. let borrow = self.borrow.get(); @@ -1127,7 +1127,7 @@ } #[stable(feature = "rust1", since = "1.0.0")] -impl<'b, T: ?Sized> Deref for Ref<'b, T> { +impl Deref for Ref<'_, T> { type Target = T; #[inline] @@ -1219,7 +1219,7 @@ impl<'b, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized> for Ref<'b, T> {} #[stable(feature = "std_guard_impls", since = "1.20.0")] -impl<'a, T: ?Sized + fmt::Display> fmt::Display for Ref<'a, T> { +impl fmt::Display for Ref<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.value.fmt(f) } @@ -1305,7 +1305,7 @@ borrow: &'b Cell, } -impl<'b> Drop for BorrowRefMut<'b> { +impl Drop for BorrowRefMut<'_> { #[inline] fn drop(&mut self) { let borrow = self.borrow.get(); @@ -1356,7 +1356,7 @@ } #[stable(feature = "rust1", since = "1.0.0")] -impl<'b, T: ?Sized> Deref for RefMut<'b, T> { +impl Deref for RefMut<'_, T> { type Target = T; #[inline] @@ -1366,7 +1366,7 @@ } #[stable(feature = "rust1", since = "1.0.0")] -impl<'b, T: ?Sized> DerefMut for RefMut<'b, T> { +impl DerefMut for RefMut<'_, T> { #[inline] fn deref_mut(&mut self) -> &mut T { self.value @@ -1377,7 +1377,7 @@ impl<'b, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized> for RefMut<'b, T> {} #[stable(feature = "std_guard_impls", since = "1.20.0")] -impl<'a, T: ?Sized + fmt::Display> fmt::Display for RefMut<'a, T> { +impl fmt::Display for RefMut<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.value.fmt(f) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/char/convert.rs rustc-1.31.0+dfsg1+llvm/src/libcore/char/convert.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/char/convert.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/char/convert.rs 2018-12-04 23:41:40.000000000 +0000 @@ -19,7 +19,7 @@ /// Converts a `u32` to a `char`. /// /// Note that all [`char`]s are valid [`u32`]s, and can be cast to one with -/// [`as`]: +/// `as`: /// /// ``` /// let c = '💯'; @@ -34,7 +34,6 @@ /// /// [`char`]: ../../std/primitive.char.html /// [`u32`]: ../../std/primitive.u32.html -/// [`as`]: ../../book/first-edition/casting-between-types.html#as /// /// For an unsafe version of this function which ignores these checks, see /// [`from_u32_unchecked`]. @@ -71,7 +70,7 @@ /// Converts a `u32` to a `char`, ignoring validity. /// /// Note that all [`char`]s are valid [`u32`]s, and can be cast to one with -/// [`as`]: +/// `as`: /// /// ``` /// let c = '💯'; @@ -86,7 +85,6 @@ /// /// [`char`]: ../../std/primitive.char.html /// [`u32`]: ../../std/primitive.u32.html -/// [`as`]: ../../book/first-edition/casting-between-types.html#as /// /// # Safety /// @@ -115,6 +113,19 @@ #[stable(feature = "char_convert", since = "1.13.0")] impl From for u32 { + /// Converts a [`char`] into a [`u32`]. + /// + /// # Examples + /// + /// ``` + /// use std::mem; + /// + /// fn main() { + /// let c = 'c'; + /// let u = u32::from(c); + /// assert!(4 == mem::size_of_val(&u)) + /// } + /// ``` #[inline] fn from(c: char) -> Self { c as u32 @@ -141,6 +152,19 @@ /// C0 and C1 control codes. #[stable(feature = "char_convert", since = "1.13.0")] impl From for char { + /// Converts a [`u8`] into a [`char`]. + /// + /// # Examples + /// + /// ``` + /// use std::mem; + /// + /// fn main() { + /// let u = 32 as u8; + /// let c = char::from(u); + /// assert!(4 == mem::size_of_val(&c)) + /// } + /// ``` #[inline] fn from(i: u8) -> Self { i as char diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/clone.rs rustc-1.31.0+dfsg1+llvm/src/libcore/clone.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/clone.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/clone.rs 2018-12-04 23:41:40.000000000 +0000 @@ -204,7 +204,7 @@ // Shared references can be cloned, but mutable references *cannot*! #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, T: ?Sized> Clone for &'a T { + impl Clone for &T { #[inline] fn clone(&self) -> Self { *self diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/cmp.rs rustc-1.31.0+dfsg1+llvm/src/libcore/cmp.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/cmp.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/cmp.rs 2018-12-04 23:41:40.000000000 +0000 @@ -1033,12 +1033,12 @@ fn gt(&self, other: & &'b B) -> bool { PartialOrd::gt(*self, *other) } } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, A: ?Sized> Ord for &'a A where A: Ord { + impl Ord for &A where A: Ord { #[inline] - fn cmp(&self, other: & &'a A) -> Ordering { Ord::cmp(*self, *other) } + fn cmp(&self, other: &Self) -> Ordering { Ord::cmp(*self, *other) } } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, A: ?Sized> Eq for &'a A where A: Eq {} + impl Eq for &A where A: Eq {} // &mut pointers @@ -1065,12 +1065,12 @@ fn gt(&self, other: &&'b mut B) -> bool { PartialOrd::gt(*self, *other) } } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, A: ?Sized> Ord for &'a mut A where A: Ord { + impl Ord for &mut A where A: Ord { #[inline] - fn cmp(&self, other: &&'a mut A) -> Ordering { Ord::cmp(*self, *other) } + fn cmp(&self, other: &Self) -> Ordering { Ord::cmp(*self, *other) } } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, A: ?Sized> Eq for &'a mut A where A: Eq {} + impl Eq for &mut A where A: Eq {} #[stable(feature = "rust1", since = "1.0.0")] impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b mut B> for &'a A where A: PartialEq { diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/convert.rs rustc-1.31.0+dfsg1+llvm/src/libcore/convert.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/convert.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/convert.rs 2018-12-04 23:41:40.000000000 +0000 @@ -407,7 +407,7 @@ // As lifts over & #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized, U: ?Sized> AsRef for &'a T where T: AsRef +impl AsRef for &T where T: AsRef { fn as_ref(&self) -> &U { >::as_ref(*self) @@ -416,7 +416,7 @@ // As lifts over &mut #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized, U: ?Sized> AsRef for &'a mut T where T: AsRef +impl AsRef for &mut T where T: AsRef { fn as_ref(&self) -> &U { >::as_ref(*self) @@ -433,7 +433,7 @@ // AsMut lifts over &mut #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized, U: ?Sized> AsMut for &'a mut T where T: AsMut +impl AsMut for &mut T where T: AsMut { fn as_mut(&mut self) -> &mut U { (*self).as_mut() diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/fmt/builders.rs rustc-1.31.0+dfsg1+llvm/src/libcore/fmt/builders.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/fmt/builders.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/fmt/builders.rs 2018-12-04 23:41:40.000000000 +0000 @@ -28,7 +28,7 @@ } } -impl<'a> fmt::Write for PadAdapter<'a> { +impl fmt::Write for PadAdapter<'_> { fn write_str(&mut self, mut s: &str) -> fmt::Result { while !s.is_empty() { if self.on_newline { diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/fmt/mod.rs rustc-1.31.0+dfsg1+llvm/src/libcore/fmt/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/fmt/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/fmt/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -96,9 +96,8 @@ /// use std::fmt::{self, write}; /// /// let mut output = String::new(); -/// match write(&mut output, format_args!("Hello {}!", "world")) { -/// Err(fmt::Error) => panic!("An error occurred"), -/// _ => (), +/// if let Err(fmt::Error) = write(&mut output, format_args!("Hello {}!", "world")) { +/// panic!("An error occurred"); /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] @@ -208,7 +207,7 @@ // requiring a `Sized` bound. struct Adapter<'a,T: ?Sized +'a>(&'a mut T); - impl<'a, T: ?Sized> Write for Adapter<'a, T> + impl Write for Adapter<'_, T> where T: Write { fn write_str(&mut self, s: &str) -> Result { @@ -229,7 +228,7 @@ } #[stable(feature = "fmt_write_blanket_impl", since = "1.4.0")] -impl<'a, W: Write + ?Sized> Write for &'a mut W { +impl Write for &mut W { fn write_str(&mut self, s: &str) -> Result { (**self).write_str(s) } @@ -291,8 +290,8 @@ #[unstable(feature = "fmt_internals", reason = "internal to format_args!", issue = "0")] -impl<'a> Clone for ArgumentV1<'a> { - fn clone(&self) -> ArgumentV1<'a> { +impl Clone for ArgumentV1<'_> { + fn clone(&self) -> Self { *self } } @@ -436,14 +435,14 @@ } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> Debug for Arguments<'a> { +impl Debug for Arguments<'_> { fn fmt(&self, fmt: &mut Formatter) -> Result { Display::fmt(self, fmt) } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> Display for Arguments<'a> { +impl Display for Arguments<'_> { fn fmt(&self, fmt: &mut Formatter) -> Result { write(fmt.buf, *self) } @@ -1884,7 +1883,7 @@ } #[stable(since = "1.2.0", feature = "formatter_write")] -impl<'a> Write for Formatter<'a> { +impl Write for Formatter<'_> { fn write_str(&mut self, s: &str) -> Result { self.buf.write_str(s) } @@ -1911,11 +1910,11 @@ ($($tr:ident),*) => { $( #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, T: ?Sized + $tr> $tr for &'a T { + impl $tr for &T { fn fmt(&self, f: &mut Formatter) -> Result { $tr::fmt(&**self, f) } } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, T: ?Sized + $tr> $tr for &'a mut T { + impl $tr for &mut T { fn fmt(&self, f: &mut Formatter) -> Result { $tr::fmt(&**self, f) } } )* @@ -2039,14 +2038,14 @@ } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> Pointer for &'a T { +impl Pointer for &T { fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(&(*self as *const T), f) } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> Pointer for &'a mut T { +impl Pointer for &mut T { fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(&(&**self as *const T), f) } @@ -2153,14 +2152,14 @@ } #[stable(feature = "rust1", since = "1.0.0")] -impl<'b, T: ?Sized + Debug> Debug for Ref<'b, T> { +impl Debug for Ref<'_, T> { fn fmt(&self, f: &mut Formatter) -> Result { Debug::fmt(&**self, f) } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'b, T: ?Sized + Debug> Debug for RefMut<'b, T> { +impl Debug for RefMut<'_, T> { fn fmt(&self, f: &mut Formatter) -> Result { Debug::fmt(&*(self.deref()), f) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/future/future_obj.rs rustc-1.31.0+dfsg1+llvm/src/libcore/future/future_obj.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/future/future_obj.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/future/future_obj.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,182 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![unstable(feature = "futures_api", - reason = "futures in libcore are unstable", - issue = "50547")] - -use fmt; -use future::Future; -use marker::{PhantomData, Unpin}; -use pin::PinMut; -use task::{Context, Poll}; - -/// A custom trait object for polling futures, roughly akin to -/// `Box + 'a>`. -/// -/// This custom trait object was introduced for two reasons: -/// - Currently it is not possible to take `dyn Trait` by value and -/// `Box` is not available in no_std contexts. -/// - The `Future` trait is currently not object safe: The `Future::poll` -/// method makes uses the arbitrary self types feature and traits in which -/// this feature is used are currently not object safe due to current compiler -/// limitations. (See tracking issue for arbitrary self types for more -/// information #44874) -pub struct LocalFutureObj<'a, T> { - ptr: *mut (), - poll_fn: unsafe fn(*mut (), &mut Context) -> Poll, - drop_fn: unsafe fn(*mut ()), - _marker: PhantomData<&'a ()>, -} - -impl<'a, T> Unpin for LocalFutureObj<'a, T> {} - -impl<'a, T> LocalFutureObj<'a, T> { - /// Create a `LocalFutureObj` from a custom trait object representation. - #[inline] - pub fn new + 'a>(f: F) -> LocalFutureObj<'a, T> { - LocalFutureObj { - ptr: f.into_raw(), - poll_fn: F::poll, - drop_fn: F::drop, - _marker: PhantomData, - } - } - - /// Converts the `LocalFutureObj` into a `FutureObj` - /// To make this operation safe one has to ensure that the `UnsafeFutureObj` - /// instance from which this `LocalFutureObj` was created actually - /// implements `Send`. - #[inline] - pub unsafe fn into_future_obj(self) -> FutureObj<'a, T> { - FutureObj(self) - } -} - -impl<'a, T> fmt::Debug for LocalFutureObj<'a, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("LocalFutureObj") - .finish() - } -} - -impl<'a, T> From> for LocalFutureObj<'a, T> { - #[inline] - fn from(f: FutureObj<'a, T>) -> LocalFutureObj<'a, T> { - f.0 - } -} - -impl<'a, T> Future for LocalFutureObj<'a, T> { - type Output = T; - - #[inline] - fn poll(self: PinMut, cx: &mut Context) -> Poll { - unsafe { - (self.poll_fn)(self.ptr, cx) - } - } -} - -impl<'a, T> Drop for LocalFutureObj<'a, T> { - fn drop(&mut self) { - unsafe { - (self.drop_fn)(self.ptr) - } - } -} - -/// A custom trait object for polling futures, roughly akin to -/// `Box + Send + 'a>`. -/// -/// This custom trait object was introduced for two reasons: -/// - Currently it is not possible to take `dyn Trait` by value and -/// `Box` is not available in no_std contexts. -/// - The `Future` trait is currently not object safe: The `Future::poll` -/// method makes uses the arbitrary self types feature and traits in which -/// this feature is used are currently not object safe due to current compiler -/// limitations. (See tracking issue for arbitrary self types for more -/// information #44874) -pub struct FutureObj<'a, T>(LocalFutureObj<'a, T>); - -impl<'a, T> Unpin for FutureObj<'a, T> {} -unsafe impl<'a, T> Send for FutureObj<'a, T> {} - -impl<'a, T> FutureObj<'a, T> { - /// Create a `FutureObj` from a custom trait object representation. - #[inline] - pub fn new + Send>(f: F) -> FutureObj<'a, T> { - FutureObj(LocalFutureObj::new(f)) - } -} - -impl<'a, T> fmt::Debug for FutureObj<'a, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("FutureObj") - .finish() - } -} - -impl<'a, T> Future for FutureObj<'a, T> { - type Output = T; - - #[inline] - fn poll(self: PinMut, cx: &mut Context) -> Poll { - let pinned_field = unsafe { PinMut::map_unchecked(self, |x| &mut x.0) }; - pinned_field.poll(cx) - } -} - -/// A custom implementation of a future trait object for `FutureObj`, providing -/// a hand-rolled vtable. -/// -/// This custom representation is typically used only in `no_std` contexts, -/// where the default `Box`-based implementation is not available. -/// -/// The implementor must guarantee that it is safe to call `poll` repeatedly (in -/// a non-concurrent fashion) with the result of `into_raw` until `drop` is -/// called. -pub unsafe trait UnsafeFutureObj<'a, T>: 'a { - /// Convert an owned instance into a (conceptually owned) void pointer. - fn into_raw(self) -> *mut (); - - /// Poll the future represented by the given void pointer. - /// - /// # Safety - /// - /// The trait implementor must guarantee that it is safe to repeatedly call - /// `poll` with the result of `into_raw` until `drop` is called; such calls - /// are not, however, allowed to race with each other or with calls to - /// `drop`. - unsafe fn poll(ptr: *mut (), cx: &mut Context) -> Poll; - - /// Drops the future represented by the given void pointer. - /// - /// # Safety - /// - /// The trait implementor must guarantee that it is safe to call this - /// function once per `into_raw` invocation; that call cannot race with - /// other calls to `drop` or `poll`. - unsafe fn drop(ptr: *mut ()); -} - -unsafe impl<'a, T, F> UnsafeFutureObj<'a, T> for &'a mut F - where F: Future + Unpin + 'a -{ - fn into_raw(self) -> *mut () { - self as *mut F as *mut () - } - - unsafe fn poll(ptr: *mut (), cx: &mut Context) -> Poll { - PinMut::new_unchecked(&mut *(ptr as *mut F)).poll(cx) - } - - unsafe fn drop(_ptr: *mut ()) {} -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/future/future.rs rustc-1.31.0+dfsg1+llvm/src/libcore/future/future.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/future/future.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/future/future.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,9 +12,10 @@ reason = "futures in libcore are unstable", issue = "50547")] -use pin::PinMut; use marker::Unpin; -use task::{self, Poll}; +use ops; +use pin::Pin; +use task::{Poll, LocalWaker}; /// A future represents an asychronous computation. /// @@ -49,18 +50,18 @@ /// /// Once a future has finished, clients should not `poll` it again. /// - /// When a future is not ready yet, `poll` returns - /// `Poll::Pending`. The future will *also* register the - /// interest of the current task in the value being produced. For example, - /// if the future represents the availability of data on a socket, then the - /// task is recorded so that when data arrives, it is woken up (via - /// [`cx.waker()`]). Once a task has been woken up, - /// it should attempt to `poll` the future again, which may or may not - /// produce a final value. - /// - /// Note that if `Pending` is returned it only means that the *current* task - /// (represented by the argument `cx`) will receive a notification. Tasks - /// from previous calls to `poll` will *not* receive notifications. + /// When a future is not ready yet, `poll` returns `Poll::Pending` and + /// stores a clone of the [`LocalWaker`] to be woken once the future can + /// make progress. For example, a future waiting for a socket to become + /// readable would call `.clone()` on the [`LocalWaker`] and store it. + /// When a signal arrives elsewhere indicating that the socket is readable, + /// `[LocalWaker::wake]` is called and the socket future's task is awoken. + /// Once a task has been woken up, it should attempt to `poll` the future + /// again, which may or may not produce a final value. + /// + /// Note that on multiple calls to `poll`, only the most recent + /// [`LocalWaker`] passed to `poll` should be scheduled to receive a + /// wakeup. /// /// # Runtime characteristics /// @@ -68,9 +69,9 @@ /// progress, meaning that each time the current task is woken up, it should /// actively re-`poll` pending futures that it still has an interest in. /// - /// The `poll` function is not called repeatedly in a tight loop for - /// futures, but only whenever the future itself is ready, as signaled via - /// the `Waker` inside `task::Context`. If you're familiar with the + /// The `poll` function is not called repeatedly in a tight loop-- instead, + /// it should only be called when the future indicates that it is ready to + /// make progress (by calling `wake()`). If you're familiar with the /// `poll(2)` or `select(2)` syscalls on Unix it's worth noting that futures /// typically do *not* suffer the same problems of "all wakeups must poll /// all events"; they are more like `epoll(4)`. @@ -82,6 +83,16 @@ /// thread pool (or something similar) to ensure that `poll` can return /// quickly. /// + /// # [`LocalWaker`], [`Waker`] and thread-safety + /// + /// The `poll` function takes a [`LocalWaker`], an object which knows how to + /// awaken the current task. [`LocalWaker`] is not `Send` nor `Sync`, so in + /// order to make thread-safe futures the [`LocalWaker::into_waker`] method + /// should be used to convert the [`LocalWaker`] into a thread-safe version. + /// [`LocalWaker::wake`] implementations have the ability to be more + /// efficient, however, so when thread safety is not necessary, + /// [`LocalWaker`] should be preferred. + /// /// # Panics /// /// Once a future has completed (returned `Ready` from `poll`), @@ -91,22 +102,29 @@ /// /// [`Poll::Pending`]: ../task/enum.Poll.html#variant.Pending /// [`Poll::Ready(val)`]: ../task/enum.Poll.html#variant.Ready - /// [`cx.waker()`]: ../task/struct.Context.html#method.waker - fn poll(self: PinMut, cx: &mut task::Context) -> Poll; + /// [`LocalWaker`]: ../task/struct.LocalWaker.html + /// [`LocalWaker::into_waker`]: ../task/struct.LocalWaker.html#method.into_waker + /// [`LocalWaker::wake`]: ../task/struct.LocalWaker.html#method.wake + /// [`Waker`]: ../task/struct.Waker.html + fn poll(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll; } impl<'a, F: ?Sized + Future + Unpin> Future for &'a mut F { type Output = F::Output; - fn poll(mut self: PinMut, cx: &mut task::Context) -> Poll { - F::poll(PinMut::new(&mut **self), cx) + fn poll(mut self: Pin<&mut Self>, lw: &LocalWaker) -> Poll { + F::poll(Pin::new(&mut **self), lw) } } -impl<'a, F: ?Sized + Future> Future for PinMut<'a, F> { - type Output = F::Output; +impl

Future for Pin

+where + P: ops::DerefMut, + P::Target: Future, +{ + type Output = <

::Target as Future>::Output; - fn poll(mut self: PinMut, cx: &mut task::Context) -> Poll { - F::poll((*self).reborrow(), cx) + fn poll(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll { + Pin::get_mut(self).as_mut().poll(lw) } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/future/mod.rs rustc-1.31.0+dfsg1+llvm/src/libcore/future/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/future/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/future/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,6 +16,3 @@ mod future; pub use self::future::Future; - -mod future_obj; -pub use self::future_obj::{FutureObj, LocalFutureObj, UnsafeFutureObj}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/hash/mod.rs rustc-1.31.0+dfsg1+llvm/src/libcore/hash/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/hash/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/hash/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -361,7 +361,7 @@ } #[stable(feature = "indirect_hasher_impl", since = "1.22.0")] -impl<'a, H: Hasher + ?Sized> Hasher for &'a mut H { +impl Hasher for &mut H { fn finish(&self) -> u64 { (**self).finish() } @@ -669,14 +669,14 @@ #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, T: ?Sized + Hash> Hash for &'a T { + impl Hash for &T { fn hash(&self, state: &mut H) { (**self).hash(state); } } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, T: ?Sized + Hash> Hash for &'a mut T { + impl Hash for &mut T { fn hash(&self, state: &mut H) { (**self).hash(state); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/intrinsics.rs rustc-1.31.0+dfsg1+llvm/src/libcore/intrinsics.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/intrinsics.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/intrinsics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -962,59 +962,127 @@ /// value is not necessarily valid to be used to actually access memory. pub fn arith_offset(dst: *const T, offset: isize) -> *const T; - /// Copies `count * size_of` bytes from `src` to `dst`. The source - /// and destination may *not* overlap. + /// Copies `count * size_of::()` bytes from `src` to `dst`. The source + /// and destination must *not* overlap. /// - /// `copy_nonoverlapping` is semantically equivalent to C's `memcpy`. + /// For regions of memory which might overlap, use [`copy`] instead. + /// + /// `copy_nonoverlapping` is semantically equivalent to C's [`memcpy`], but + /// with the argument order swapped. + /// + /// [`copy`]: ./fn.copy.html + /// [`memcpy`]: https://en.cppreference.com/w/c/string/byte/memcpy /// /// # Safety /// - /// Beyond requiring that the program must be allowed to access both regions - /// of memory, it is Undefined Behavior for source and destination to - /// overlap. Care must also be taken with the ownership of `src` and - /// `dst`. This method semantically moves the values of `src` into `dst`. - /// However it does not drop the contents of `dst`, or prevent the contents - /// of `src` from being dropped or used. + /// Behavior is undefined if any of the following conditions are violated: + /// + /// * `src` must be [valid] for reads of `count * size_of::()` bytes. + /// + /// * `dst` must be [valid] for writes of `count * size_of::()` bytes. + /// + /// * Both `src` and `dst` must be properly aligned. + /// + /// * The region of memory beginning at `src` with a size of `count * + /// size_of::()` bytes must *not* overlap with the region of memory + /// beginning at `dst` with the same size. + /// + /// Like [`read`], `copy_nonoverlapping` creates a bitwise copy of `T`, regardless of + /// whether `T` is [`Copy`]. If `T` is not [`Copy`], using *both* the values + /// in the region beginning at `*src` and the region beginning at `*dst` can + /// [violate memory safety][read-ownership]. + /// + /// Note that even if the effectively copied size (`count * size_of::()`) is + /// `0`, the pointers must be non-NULL and properly aligned. + /// + /// [`Copy`]: ../marker/trait.Copy.html + /// [`read`]: ../ptr/fn.read.html + /// [read-ownership]: ../ptr/fn.read.html#ownership-of-the-returned-value + /// [valid]: ../ptr/index.html#safety /// /// # Examples /// - /// A safe swap function: + /// Manually implement [`Vec::append`]: /// /// ``` - /// use std::mem; /// use std::ptr; /// - /// # #[allow(dead_code)] - /// fn swap(x: &mut T, y: &mut T) { + /// /// Moves all the elements of `src` into `dst`, leaving `src` empty. + /// fn append(dst: &mut Vec, src: &mut Vec) { + /// let src_len = src.len(); + /// let dst_len = dst.len(); + /// + /// // Ensure that `dst` has enough capacity to hold all of `src`. + /// dst.reserve(src_len); + /// /// unsafe { - /// // Give ourselves some scratch space to work with - /// let mut t: T = mem::uninitialized(); + /// // The call to offset is always safe because `Vec` will never + /// // allocate more than `isize::MAX` bytes. + /// let dst_ptr = dst.as_mut_ptr().offset(dst_len as isize); + /// let src_ptr = src.as_ptr(); + /// + /// // Truncate `src` without dropping its contents. We do this first, + /// // to avoid problems in case something further down panics. + /// src.set_len(0); + /// + /// // The two regions cannot overlap because mutable references do + /// // not alias, and two different vectors cannot own the same + /// // memory. + /// ptr::copy_nonoverlapping(src_ptr, dst_ptr, src_len); /// - /// // Perform the swap, `&mut` pointers never alias - /// ptr::copy_nonoverlapping(x, &mut t, 1); - /// ptr::copy_nonoverlapping(y, x, 1); - /// ptr::copy_nonoverlapping(&t, y, 1); - /// - /// // y and t now point to the same thing, but we need to completely forget `t` - /// // because it's no longer relevant. - /// mem::forget(t); + /// // Notify `dst` that it now holds the contents of `src`. + /// dst.set_len(dst_len + src_len); /// } /// } + /// + /// let mut a = vec!['r']; + /// let mut b = vec!['u', 's', 't']; + /// + /// append(&mut a, &mut b); + /// + /// assert_eq!(a, &['r', 'u', 's', 't']); + /// assert!(b.is_empty()); /// ``` + /// + /// [`Vec::append`]: ../../std/vec/struct.Vec.html#method.append #[stable(feature = "rust1", since = "1.0.0")] pub fn copy_nonoverlapping(src: *const T, dst: *mut T, count: usize); - /// Copies `count * size_of` bytes from `src` to `dst`. The source + /// Copies `count * size_of::()` bytes from `src` to `dst`. The source /// and destination may overlap. /// - /// `copy` is semantically equivalent to C's `memmove`. + /// If the source and destination will *never* overlap, + /// [`copy_nonoverlapping`] can be used instead. + /// + /// `copy` is semantically equivalent to C's [`memmove`], but with the argument + /// order swapped. Copying takes place as if the bytes were copied from `src` + /// to a temporary array and then copied from the array to `dst`. + /// + /// [`copy_nonoverlapping`]: ./fn.copy_nonoverlapping.html + /// [`memmove`]: https://en.cppreference.com/w/c/string/byte/memmove /// /// # Safety /// - /// Care must be taken with the ownership of `src` and `dst`. - /// This method semantically moves the values of `src` into `dst`. - /// However it does not drop the contents of `dst`, or prevent the contents of `src` - /// from being dropped or used. + /// Behavior is undefined if any of the following conditions are violated: + /// + /// * `src` must be [valid] for reads of `count * size_of::()` bytes. + /// + /// * `dst` must be [valid] for writes of `count * size_of::()` bytes. + /// + /// * Both `src` and `dst` must be properly aligned. + /// + /// Like [`read`], `copy` creates a bitwise copy of `T`, regardless of + /// whether `T` is [`Copy`]. If `T` is not [`Copy`], using both the values + /// in the region beginning at `*src` and the region beginning at `*dst` can + /// [violate memory safety][read-ownership]. + /// + /// Note that even if the effectively copied size (`count * size_of::()`) is + /// `0`, the pointers must be non-NULL and properly aligned. + /// + /// [`Copy`]: ../marker/trait.Copy.html + /// [`read`]: ../ptr/fn.read.html + /// [read-ownership]: ../ptr/fn.read.html#ownership-of-the-returned-value + /// [valid]: ../ptr/index.html#safety /// /// # Examples /// @@ -1031,24 +1099,80 @@ /// dst /// } /// ``` - /// #[stable(feature = "rust1", since = "1.0.0")] pub fn copy(src: *const T, dst: *mut T, count: usize); - /// Invokes memset on the specified pointer, setting `count * size_of::()` - /// bytes of memory starting at `dst` to `val`. + /// Sets `count * size_of::()` bytes of memory starting at `dst` to + /// `val`. + /// + /// `write_bytes` is similar to C's [`memset`], but sets `count * + /// size_of::()` bytes to `val`. + /// + /// [`memset`]: https://en.cppreference.com/w/c/string/byte/memset + /// + /// # Safety + /// + /// Behavior is undefined if any of the following conditions are violated: + /// + /// * `dst` must be [valid] for writes of `count * size_of::()` bytes. + /// + /// * `dst` must be properly aligned. + /// + /// Additionally, the caller must ensure that writing `count * + /// size_of::()` bytes to the given region of memory results in a valid + /// value of `T`. Using a region of memory typed as a `T` that contains an + /// invalid value of `T` is undefined behavior. + /// + /// Note that even if the effectively copied size (`count * size_of::()`) is + /// `0`, the pointer must be non-NULL and properly aligned. + /// + /// [valid]: ../ptr/index.html#safety /// /// # Examples /// + /// Basic usage: + /// /// ``` /// use std::ptr; /// - /// let mut vec = vec![0; 4]; + /// let mut vec = vec![0u32; 4]; /// unsafe { /// let vec_ptr = vec.as_mut_ptr(); - /// ptr::write_bytes(vec_ptr, b'a', 2); + /// ptr::write_bytes(vec_ptr, 0xfe, 2); + /// } + /// assert_eq!(vec, [0xfefefefe, 0xfefefefe, 0, 0]); + /// ``` + /// + /// Creating an invalid value: + /// + /// ``` + /// use std::ptr; + /// + /// let mut v = Box::new(0i32); + /// + /// unsafe { + /// // Leaks the previously held value by overwriting the `Box` with + /// // a null pointer. + /// ptr::write_bytes(&mut v as *mut Box, 0, 1); /// } - /// assert_eq!(vec, [b'a', b'a', 0, 0]); + /// + /// // At this point, using or dropping `v` results in undefined behavior. + /// // drop(v); // ERROR + /// + /// // Even leaking `v` "uses" it, and hence is undefined behavior. + /// // mem::forget(v); // ERROR + /// + /// // In fact, `v` is invalid according to basic type layout invariants, so *any* + /// // operation touching it is undefined behavior. + /// // let v2 = v; // ERROR + /// + /// unsafe { + /// // Let us instead put in a valid value + /// ptr::write(&mut v as *mut Box, Box::new(42i32)); + /// } + /// + /// // Now the box is fine + /// assert_eq!(*v, 42); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn write_bytes(dst: *mut T, val: u8, count: usize); @@ -1066,7 +1190,7 @@ /// `min_align_of::()` /// /// The volatile parameter is set to `true`, so it will not be optimized out - /// unless size is equal to zero.. + /// unless size is equal to zero. pub fn volatile_copy_memory(dst: *mut T, src: *const T, count: usize); /// Equivalent to the appropriate `llvm.memset.p0i8.*` intrinsic, with a /// size of `count` * `size_of::()` and an alignment of diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/iter/iterator.rs rustc-1.31.0+dfsg1+llvm/src/libcore/iter/iterator.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/iter/iterator.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/iter/iterator.rs 2018-12-04 23:41:40.000000000 +0000 @@ -31,10 +31,71 @@ #[stable(feature = "rust1", since = "1.0.0")] #[rustc_on_unimplemented( on( + _Self="[std::ops::Range; 1]", + label="if you meant to iterate between two values, remove the square brackets", + note="`[start..end]` is an array of one `Range`; you might have meant to have a `Range` \ + without the brackets: `start..end`" + ), + on( + _Self="[std::ops::RangeFrom; 1]", + label="if you meant to iterate from a value onwards, remove the square brackets", + note="`[start..]` is an array of one `RangeFrom`; you might have meant to have a \ + `RangeFrom` without the brackets: `start..`, keeping in mind that iterating over an \ + unbounded iterator will run forever unless you `break` or `return` from within the \ + loop" + ), + on( + _Self="[std::ops::RangeTo; 1]", + label="if you meant to iterate until a value, remove the square brackets and add a \ + starting value", + note="`[..end]` is an array of one `RangeTo`; you might have meant to have a bounded \ + `Range` without the brackets: `0..end`" + ), + on( + _Self="[std::ops::RangeInclusive; 1]", + label="if you meant to iterate between two values, remove the square brackets", + note="`[start..=end]` is an array of one `RangeInclusive`; you might have meant to have a \ + `RangeInclusive` without the brackets: `start..=end`" + ), + on( + _Self="[std::ops::RangeToInclusive; 1]", + label="if you meant to iterate until a value (including it), remove the square brackets \ + and add a starting value", + note="`[..=end]` is an array of one `RangeToInclusive`; you might have meant to have a \ + bounded `RangeInclusive` without the brackets: `0..=end`" + ), + on( + _Self="std::ops::RangeTo", + label="if you meant to iterate until a value, add a starting value", + note="`..end` is a `RangeTo`, which cannot be iterated on; you might have meant to have a \ + bounded `Range`: `0..end`" + ), + on( + _Self="std::ops::RangeToInclusive", + label="if you meant to iterate until a value (including it), add a starting value", + note="`..=end` is a `RangeToInclusive`, which cannot be iterated on; you might have meant \ + to have a bounded `RangeInclusive`: `0..=end`" + ), + 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" + on( + _Self="std::string::String", + label="`{Self}` is not an iterator; try calling `.chars()` or `.bytes()`" + ), + on( + _Self="[]", + label="borrow the array with `&` or call `.iter()` on it to iterate over it", + note="arrays are not an iterators, but slices like the following are: `&[1, 2, 3]`" + ), + on( + _Self="{integral}", + note="if you want to iterate between `start` until a value `end`, use the exclusive range \ + syntax `start..end` or the inclusive range syntax `start..=end`" + ), + label="`{Self}` is not an iterator", + message="`{Self}` is not an iterator" )] #[doc(spotlight)] pub trait Iterator { @@ -471,7 +532,7 @@ /// If you're doing some sort of looping for a side effect, it's considered /// more idiomatic to use [`for`] than `map()`. /// - /// [`for`]: ../../book/first-edition/loops.html#for + /// [`for`]: ../../book/ch03-05-control-flow.html#looping-through-a-collection-with-for /// /// # Examples /// @@ -519,7 +580,7 @@ /// cases `for_each` may also be faster than a loop, because it will use /// internal iteration on adaptors like `Chain`. /// - /// [`for`]: ../../book/first-edition/loops.html#for + /// [`for`]: ../../book/ch03-05-control-flow.html#looping-through-a-collection-with-for /// /// # Examples /// @@ -1608,7 +1669,7 @@ /// use a `for` loop with a list of things to build up a result. Those /// can be turned into `fold()`s: /// - /// [`for`]: ../../book/first-edition/loops.html#for + /// [`for`]: ../../book/ch03-05-control-flow.html#looping-through-a-collection-with-for /// /// ``` /// let numbers = [1, 2, 3, 4, 5]; @@ -2557,7 +2618,7 @@ } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, I: Iterator + ?Sized> Iterator for &'a mut I { +impl Iterator for &mut I { type Item = I::Item; fn next(&mut self) -> Option { (**self).next() } fn size_hint(&self) -> (usize, Option) { (**self).size_hint() } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/iter/mod.rs rustc-1.31.0+dfsg1+llvm/src/libcore/iter/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/iter/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/iter/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -253,7 +253,7 @@ //! using it. The compiler will warn us about this kind of behavior: //! //! ```text -//! warning: unused result which must be used: iterator adaptors are lazy and +//! warning: unused result that must be used: iterator adaptors are lazy and //! do nothing unless consumed //! ``` //! @@ -319,10 +319,9 @@ use cmp; use fmt; use iter_private::TrustedRandomAccess; -use ops::{self, Try}; +use ops::Try; use usize; use intrinsics; -use mem; #[stable(feature = "rust1", since = "1.0.0")] pub use self::iterator::Iterator; @@ -673,7 +672,12 @@ #[inline] fn next(&mut self) -> Option { - ::spec_next(self) + if self.first_take { + self.first_take = false; + self.iter.next() + } else { + self.iter.nth(self.step) + } } #[inline] @@ -732,78 +736,6 @@ } } } - -// hidden trait for specializing iterator methods -// could be generalized but is currently only used for StepBy -trait StepBySpecIterator { - type Item; - fn spec_next(&mut self) -> Option; -} - -impl StepBySpecIterator for StepBy -where - I: Iterator, -{ - type Item = I::Item; - - #[inline] - default fn spec_next(&mut self) -> Option { - if self.first_take { - self.first_take = false; - self.iter.next() - } else { - self.iter.nth(self.step) - } - } -} - -impl StepBySpecIterator for StepBy> -where - T: Step, -{ - #[inline] - fn spec_next(&mut self) -> Option { - self.first_take = false; - if !(self.iter.start < self.iter.end) { - return None; - } - // add 1 to self.step to get original step size back - // it was decremented for the general case on construction - if let Some(n) = self.iter.start.add_usize(self.step+1) { - let next = mem::replace(&mut self.iter.start, n); - Some(next) - } else { - let last = self.iter.start.clone(); - self.iter.start = self.iter.end.clone(); - Some(last) - } - } -} - -impl StepBySpecIterator for StepBy> -where - T: Step, -{ - #[inline] - fn spec_next(&mut self) -> Option { - self.first_take = false; - self.iter.compute_is_empty(); - if self.iter.is_empty.unwrap_or_default() { - return None; - } - // add 1 to self.step to get original step size back - // it was decremented for the general case on construction - if let Some(n) = self.iter.start.add_usize(self.step+1) { - self.iter.is_empty = Some(!(n <= self.iter.end)); - let next = mem::replace(&mut self.iter.start, n); - Some(next) - } else { - let last = self.iter.start.clone(); - self.iter.is_empty = Some(true); - Some(last) - } - } -} // StepBy can only make the iterator shorter, so the len will still fit. #[stable(feature = "iterator_step_by", since = "1.28.0")] diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/iter/traits.rs rustc-1.31.0+dfsg1+llvm/src/libcore/iter/traits.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/iter/traits.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/iter/traits.rs 2018-12-04 23:41:40.000000000 +0000 @@ -724,7 +724,7 @@ } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, I: ExactSizeIterator + ?Sized> ExactSizeIterator for &'a mut I { +impl ExactSizeIterator for &mut I { fn len(&self) -> usize { (**self).len() } @@ -974,7 +974,7 @@ pub trait FusedIterator: Iterator {} #[stable(feature = "fused", since = "1.26.0")] -impl<'a, I: FusedIterator + ?Sized> FusedIterator for &'a mut I {} +impl FusedIterator for &mut I {} /// An iterator that reports an accurate length using size_hint. /// @@ -999,4 +999,4 @@ pub unsafe trait TrustedLen : Iterator {} #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, I: TrustedLen + ?Sized> TrustedLen for &'a mut I {} +unsafe impl TrustedLen for &mut I {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/lib.rs rustc-1.31.0+dfsg1+llvm/src/libcore/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -87,12 +87,12 @@ #![feature(doc_spotlight)] #![feature(extern_types)] #![feature(fundamental)] +#![cfg_attr(stage0, feature(impl_header_lifetime_elision))] #![feature(intrinsics)] #![feature(lang_items)] #![feature(link_llvm_intrinsics)] #![feature(never_type)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(exhaustive_patterns)] #![feature(macro_at_most_once_rep)] #![feature(no_core)] @@ -117,6 +117,7 @@ #![feature(powerpc_target_feature)] #![feature(mips_target_feature)] #![feature(aarch64_target_feature)] +#![feature(wasm_target_feature)] #![feature(const_slice_len)] #![feature(const_str_as_bytes)] #![feature(const_str_len)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/marker.rs rustc-1.31.0+dfsg1+llvm/src/libcore/marker.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/marker.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/marker.rs 2018-12-04 23:41:40.000000000 +0000 @@ -92,6 +92,7 @@ #[stable(feature = "rust1", since = "1.0.0")] #[lang = "sized"] #[rustc_on_unimplemented( + on(parent_trait="std::path::Path", label="borrow the `Path` instead"), message="the size for values of type `{Self}` cannot be known at compilation time", label="doesn't have a size known at compile-time", note="to learn more, visit Send for &'a T {} + unsafe impl Send for &T {} #[stable(feature = "rust1", since = "1.0.0")] - unsafe impl<'a, T: Send + ?Sized> Send for &'a mut T {} + unsafe impl Send for &mut T {} } /// Compiler-internal trait used to determine whether a type contains @@ -600,8 +601,8 @@ unsafe impl Freeze for PhantomData {} unsafe impl Freeze for *const T {} unsafe impl Freeze for *mut T {} -unsafe impl<'a, T: ?Sized> Freeze for &'a T {} -unsafe impl<'a, T: ?Sized> Freeze for &'a mut T {} +unsafe impl Freeze for &T {} +unsafe impl Freeze for &mut T {} /// Types which can be safely moved after being pinned. /// @@ -609,7 +610,7 @@ /// this trait cannot prevent types from moving by itself. /// /// Instead it can be used to prevent moves through the type system, -/// by controlling the behavior of special pointer types like [`PinMut`], +/// by controlling the behavior of pointers wrapped in the [`Pin`] wrapper, /// which "pin" the type in place by not allowing it to be moved out of them. /// See the [`pin module`] documentation for more information on pinning. /// @@ -621,10 +622,10 @@ /// ```rust /// #![feature(pin)] /// use std::mem::replace; -/// use std::pin::PinMut; +/// use std::pin::Pin; /// /// let mut string = "this".to_string(); -/// let mut pinned_string = PinMut::new(&mut string); +/// let mut pinned_string = Pin::new(&mut string); /// /// // dereferencing the pointer mutably is only possible because String implements Unpin /// replace(&mut *pinned_string, "other".to_string()); @@ -633,7 +634,7 @@ /// This trait is automatically implemented for almost every type. /// /// [`replace`]: ../../std/mem/fn.replace.html -/// [`PinMut`]: ../pin/struct.PinMut.html +/// [`Pin`]: ../pin/struct.Pin.html /// [`pin module`]: ../../std/pin/index.html #[unstable(feature = "pin", issue = "49150")] pub auto trait Unpin {} @@ -689,6 +690,6 @@ // Shared references can be copied, but mutable references *cannot*! #[stable(feature = "rust1", since = "1.0.0")] - impl<'a, T: ?Sized> Copy for &'a T {} + impl Copy for &T {} } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/mem.rs rustc-1.31.0+dfsg1+llvm/src/libcore/mem.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/mem.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/mem.rs 2018-12-04 23:41:40.000000000 +0000 @@ -132,7 +132,6 @@ /// [uninit]: fn.uninitialized.html /// [clone]: ../clone/trait.Clone.html /// [swap]: fn.swap.html -/// [FFI]: ../../book/first-edition/ffi.html /// [box]: ../../std/boxed/struct.Box.html /// [leak]: ../../std/boxed/struct.Box.html#method.leak /// [into_raw]: ../../std/boxed/struct.Box.html#method.into_raw @@ -285,19 +284,11 @@ /// [alignment]: ./fn.align_of.html #[inline] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg(not(stage0))] +#[cfg_attr(not(stage0), rustc_promotable)] pub const fn size_of() -> usize { intrinsics::size_of::() } -#[inline] -#[stable(feature = "rust1", since = "1.0.0")] -#[cfg(stage0)] -/// Ceci n'est pas la documentation -pub const fn size_of() -> usize { - unsafe { intrinsics::size_of::() } -} - /// Returns the size of the pointed-to value in bytes. /// /// This is usually the same as `size_of::()`. However, when `T` *has* no @@ -343,20 +334,10 @@ #[inline] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_deprecated(reason = "use `align_of` instead", since = "1.2.0")] -#[cfg(not(stage0))] pub fn min_align_of() -> usize { intrinsics::min_align_of::() } -#[inline] -#[stable(feature = "rust1", since = "1.0.0")] -#[rustc_deprecated(reason = "use `align_of` instead", since = "1.2.0")] -#[cfg(stage0)] -/// Ceci n'est pas la documentation -pub fn min_align_of() -> usize { - unsafe { intrinsics::min_align_of::() } -} - /// Returns the [ABI]-required minimum alignment of the type of the value that `val` points to. /// /// Every reference to a value of the type `T` must be a multiple of this number. @@ -395,19 +376,11 @@ /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg(not(stage0))] +#[cfg_attr(not(stage0), rustc_promotable)] pub const fn align_of() -> usize { intrinsics::min_align_of::() } -#[inline] -#[stable(feature = "rust1", since = "1.0.0")] -#[cfg(stage0)] -/// Ceci n'est pas la documentation -pub const fn align_of() -> usize { - unsafe { intrinsics::min_align_of::() } -} - /// Returns the [ABI]-required minimum alignment of the type of the value that `val` points to. /// /// Every reference to a value of the type `T` must be a multiple of this number. @@ -483,6 +456,16 @@ /// ``` #[inline] #[stable(feature = "needs_drop", since = "1.21.0")] +#[rustc_const_unstable(feature = "const_needs_drop")] +#[cfg(not(stage0))] +pub const fn needs_drop() -> bool { + intrinsics::needs_drop::() +} + +#[inline] +#[stable(feature = "needs_drop", since = "1.21.0")] +#[cfg(stage0)] +/// Ceci n'est pas la documentation pub fn needs_drop() -> bool { unsafe { intrinsics::needs_drop::() } } @@ -491,7 +474,7 @@ /// /// This has the same effect as allocating space with /// [`mem::uninitialized`][uninit] and then zeroing it out. It is useful for -/// [FFI] sometimes, but should generally be avoided. +/// FFI sometimes, but should generally be avoided. /// /// There is no guarantee that an all-zero byte-pattern represents a valid value of /// some type `T`. If `T` has a destructor and the value is destroyed (due to @@ -502,7 +485,6 @@ /// many of the same caveats. /// /// [uninit]: fn.uninitialized.html -/// [FFI]: ../../book/first-edition/ffi.html /// [ub]: ../../reference/behavior-considered-undefined.html /// /// # Examples @@ -514,6 +496,7 @@ /// assert_eq!(0, x); /// ``` #[inline] +#[rustc_deprecated(since = "2.0.0", reason = "use `mem::MaybeUninit::zeroed` instead")] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn zeroed() -> T { intrinsics::init() @@ -525,11 +508,9 @@ /// **This is incredibly dangerous and should not be done lightly. Deeply /// consider initializing your memory with a default value instead.** /// -/// This is useful for [FFI] functions and initializing arrays sometimes, +/// This is useful for FFI functions and initializing arrays sometimes, /// but should generally be avoided. /// -/// [FFI]: ../../book/first-edition/ffi.html -/// /// # Undefined behavior /// /// It is [undefined behavior][ub] to read uninitialized memory, even just an @@ -608,6 +589,7 @@ /// [copy_no]: ../intrinsics/fn.copy_nonoverlapping.html /// [`Drop`]: ../ops/trait.Drop.html #[inline] +#[rustc_deprecated(since = "2.0.0", reason = "use `mem::MaybeUninit::uninitialized` instead")] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn uninitialized() -> T { intrinsics::uninit() @@ -699,10 +681,9 @@ /// While this does call the argument's implementation of [`Drop`][drop], /// it will not release any borrows, as borrows are based on lexical scope. /// -/// This effectively does nothing for -/// [types which implement `Copy`](../../book/first-edition/ownership.html#copy-types), -/// e.g. integers. Such values are copied and _then_ moved into the function, -/// so the value persists after this function call. +/// This effectively does nothing for types which implement `Copy`, e.g. +/// integers. Such values are copied and _then_ moved into the function, so the +/// value persists after this function call. /// /// This function is not magic; it is literally defined as /// @@ -1024,3 +1005,97 @@ &mut self.value } } + +/// A newtype to construct uninitialized instances of `T` +#[allow(missing_debug_implementations)] +#[unstable(feature = "maybe_uninit", issue = "53491")] +// NOTE after stabilizing `MaybeUninit` proceed to deprecate `mem::{uninitialized,zeroed}` +pub union MaybeUninit { + uninit: (), + value: ManuallyDrop, +} + +impl MaybeUninit { + /// Create a new `MaybeUninit` in an uninitialized state. + /// + /// Note that dropping a `MaybeUninit` will never call `T`'s drop code. + /// It is your responsibility to make sure `T` gets dropped if it got initialized. + #[unstable(feature = "maybe_uninit", issue = "53491")] + pub const fn uninitialized() -> MaybeUninit { + MaybeUninit { uninit: () } + } + + /// Create a new `MaybeUninit` in an uninitialized state, with the memory being + /// filled with `0` bytes. It depends on `T` whether that already makes for + /// proper initialization. For example, `MaybeUninit::zeroed()` is initialized, + /// but `MaybeUninit<&'static i32>::zeroed()` is not because references must not + /// be null. + /// + /// Note that dropping a `MaybeUninit` will never call `T`'s drop code. + /// It is your responsibility to make sure `T` gets dropped if it got initialized. + #[unstable(feature = "maybe_uninit", issue = "53491")] + pub fn zeroed() -> MaybeUninit { + let mut u = MaybeUninit::::uninitialized(); + unsafe { + u.as_mut_ptr().write_bytes(0u8, 1); + } + u + } + + /// Set the value of the `MaybeUninit`. This overwrites any previous value without dropping it. + #[unstable(feature = "maybe_uninit", issue = "53491")] + pub fn set(&mut self, val: T) { + unsafe { + self.value = ManuallyDrop::new(val); + } + } + + /// Extract the value from the `MaybeUninit` container. This is a great way + /// to ensure that the data will get dropped, because the resulting `T` is + /// subject to the usual drop handling. + /// + /// # Unsafety + /// + /// It is up to the caller to guarantee that the the `MaybeUninit` really is in an initialized + /// state, otherwise this will immediately cause undefined behavior. + #[unstable(feature = "maybe_uninit", issue = "53491")] + pub unsafe fn into_inner(self) -> T { + ManuallyDrop::into_inner(self.value) + } + + /// Get a reference to the contained value. + /// + /// # Unsafety + /// + /// It is up to the caller to guarantee that the the `MaybeUninit` really is in an initialized + /// state, otherwise this will immediately cause undefined behavior. + #[unstable(feature = "maybe_uninit", issue = "53491")] + pub unsafe fn get_ref(&self) -> &T { + &*self.value + } + + /// Get a mutable reference to the contained value. + /// + /// # Unsafety + /// + /// It is up to the caller to guarantee that the the `MaybeUninit` really is in an initialized + /// state, otherwise this will immediately cause undefined behavior. + #[unstable(feature = "maybe_uninit", issue = "53491")] + pub unsafe fn get_mut(&mut self) -> &mut T { + &mut *self.value + } + + /// Get a pointer to the contained value. Reading from this pointer will be undefined + /// behavior unless the `MaybeUninit` is initialized. + #[unstable(feature = "maybe_uninit", issue = "53491")] + pub fn as_ptr(&self) -> *const T { + unsafe { &*self.value as *const T } + } + + /// Get a mutable pointer to the contained value. Reading from this pointer will be undefined + /// behavior unless the `MaybeUninit` is initialized. + #[unstable(feature = "maybe_uninit", issue = "53491")] + pub fn as_mut_ptr(&mut self) -> *mut T { + unsafe { &mut *self.value as *mut T } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/nonzero.rs rustc-1.31.0+dfsg1+llvm/src/libcore/nonzero.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/nonzero.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/nonzero.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,8 +14,7 @@ /// A wrapper type for raw pointers and integers that will never be /// NULL or 0 that might allow certain optimizations. -#[cfg_attr(stage0, lang = "non_zero")] -#[cfg_attr(not(stage0), rustc_layout_scalar_valid_range_start(1))] +#[rustc_layout_scalar_valid_range_start(1)] #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] #[repr(transparent)] pub(crate) struct NonZero(pub(crate) T); diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/num/mod.rs rustc-1.31.0+dfsg1+llvm/src/libcore/num/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/num/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/num/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -93,6 +93,13 @@ } + #[stable(feature = "from_nonzero", since = "1.31.0")] + impl From<$Ty> for $Int { + fn from(nonzero: $Ty) -> Self { + nonzero.0 .0 + } + } + impl_nonzero_fmt! { (Debug, Display, Binary, Octal, LowerHex, UpperHex) for $Ty } @@ -209,6 +216,7 @@ ```"), #[stable(feature = "rust1", since = "1.0.0")] #[inline] + #[cfg_attr(not(stage0), rustc_promotable)] pub const fn min_value() -> Self { !0 ^ ((!0 as $UnsignedT) >> 1) as Self } @@ -227,6 +235,7 @@ ```"), #[stable(feature = "rust1", since = "1.0.0")] #[inline] + #[cfg_attr(not(stage0), rustc_promotable)] pub const fn max_value() -> Self { !Self::min_value() } @@ -341,14 +350,6 @@ } } - /// no docs here - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - #[cfg(stage0)] - pub fn rotate_left(self, n: u32) -> Self { - (self as $UnsignedT).rotate_left(n) as Self - } - doc_comment! { concat!("Shifts the bits to the left by a specified amount, `n`, wrapping the truncated bits to the end of the resulting integer. @@ -368,20 +369,11 @@ #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_int_rotate")] #[inline] - #[cfg(not(stage0))] pub const fn rotate_left(self, n: u32) -> Self { (self as $UnsignedT).rotate_left(n) as Self } } - /// no docs here - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - #[cfg(stage0)] - pub fn rotate_right(self, n: u32) -> Self { - (self as $UnsignedT).rotate_right(n) as Self - } - doc_comment! { concat!("Shifts the bits to the right by a specified amount, `n`, wrapping the truncated bits to the beginning of the resulting @@ -402,7 +394,6 @@ #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_int_rotate")] #[inline] - #[cfg(not(stage0))] pub const fn rotate_right(self, n: u32) -> Self { (self as $UnsignedT).rotate_right(n) as Self } @@ -430,14 +421,6 @@ } } - /// no docs here - #[unstable(feature = "reverse_bits", issue = "48763")] - #[inline] - #[cfg(stage0)] - pub fn reverse_bits(self) -> Self { - (self as $UnsignedT).reverse_bits() as Self - } - doc_comment! { concat!("Reverses the bit pattern of the integer. @@ -456,7 +439,6 @@ #[unstable(feature = "reverse_bits", issue = "48763")] #[rustc_const_unstable(feature = "const_int_conversion")] #[inline] - #[cfg(not(stage0))] pub const fn reverse_bits(self) -> Self { (self as $UnsignedT).reverse_bits() as Self } @@ -1007,16 +989,6 @@ } } - /// no docs here - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - #[cfg(stage0)] - pub fn wrapping_add(self, rhs: Self) -> Self { - unsafe { - intrinsics::overflowing_add(self, rhs) - } - } - doc_comment! { concat!("Wrapping (modular) addition. Computes `self + rhs`, wrapping around at the boundary of the type. @@ -1034,7 +1006,6 @@ #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_int_wrapping")] #[inline] - #[cfg(not(stage0))] pub const fn wrapping_add(self, rhs: Self) -> Self { unsafe { intrinsics::overflowing_add(self, rhs) @@ -1042,16 +1013,6 @@ } } - /// no docs here - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - #[cfg(stage0)] - pub fn wrapping_sub(self, rhs: Self) -> Self { - unsafe { - intrinsics::overflowing_sub(self, rhs) - } - } - doc_comment! { concat!("Wrapping (modular) subtraction. Computes `self - rhs`, wrapping around at the boundary of the type. @@ -1069,7 +1030,6 @@ #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_int_wrapping")] #[inline] - #[cfg(not(stage0))] pub const fn wrapping_sub(self, rhs: Self) -> Self { unsafe { intrinsics::overflowing_sub(self, rhs) @@ -1077,16 +1037,6 @@ } } - /// no docs here - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - #[cfg(stage0)] - pub fn wrapping_mul(self, rhs: Self) -> Self { - unsafe { - intrinsics::overflowing_mul(self, rhs) - } - } - doc_comment! { concat!("Wrapping (modular) multiplication. Computes `self * rhs`, wrapping around at the boundary of the type. @@ -1103,7 +1053,6 @@ #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_int_wrapping")] #[inline] - #[cfg(not(stage0))] pub const fn wrapping_mul(self, rhs: Self) -> Self { unsafe { intrinsics::overflowing_mul(self, rhs) @@ -1247,16 +1196,6 @@ } } - /// no docs here - #[stable(feature = "num_wrapping", since = "1.2.0")] - #[inline] - #[cfg(stage0)] - pub fn wrapping_shl(self, rhs: u32) -> Self { - unsafe { - intrinsics::unchecked_shl(self, (rhs & ($BITS - 1)) as $SelfT) - } - } - doc_comment! { concat!("Panic-free bitwise shift-left; yields `self << mask(rhs)`, where `mask` removes any high-order bits of `rhs` that would cause the shift to exceed the bitwidth of the type. @@ -1278,7 +1217,6 @@ #[stable(feature = "num_wrapping", since = "1.2.0")] #[rustc_const_unstable(feature = "const_int_wrapping")] #[inline] - #[cfg(not(stage0))] pub const fn wrapping_shl(self, rhs: u32) -> Self { unsafe { intrinsics::unchecked_shl(self, (rhs & ($BITS - 1)) as $SelfT) @@ -1286,16 +1224,6 @@ } } - /// no docs here - #[stable(feature = "num_wrapping", since = "1.2.0")] - #[inline] - #[cfg(stage0)] - pub fn wrapping_shr(self, rhs: u32) -> Self { - unsafe { - intrinsics::unchecked_shr(self, (rhs & ($BITS - 1)) as $SelfT) - } - } - doc_comment! { concat!("Panic-free bitwise shift-right; yields `self >> mask(rhs)`, where `mask` removes any high-order bits of `rhs` that would cause the shift to exceed the bitwidth of the type. @@ -1317,7 +1245,6 @@ #[stable(feature = "num_wrapping", since = "1.2.0")] #[rustc_const_unstable(feature = "const_int_wrapping")] #[inline] - #[cfg(not(stage0))] pub const fn wrapping_shr(self, rhs: u32) -> Self { unsafe { intrinsics::unchecked_shr(self, (rhs & ($BITS - 1)) as $SelfT) @@ -1396,18 +1323,6 @@ } } - /// no docs here - #[stable(feature = "wrapping", since = "1.7.0")] - #[inline] - #[cfg(stage0)] - pub fn overflowing_add(self, rhs: Self) -> (Self, bool) { - let (a, b) = unsafe { - intrinsics::add_with_overflow(self as $ActualT, - rhs as $ActualT) - }; - (a as Self, b) - } - doc_comment! { concat!("Calculates `self` + `rhs` @@ -1428,7 +1343,6 @@ #[stable(feature = "wrapping", since = "1.7.0")] #[rustc_const_unstable(feature = "const_int_overflowing")] #[inline] - #[cfg(not(stage0))] pub const fn overflowing_add(self, rhs: Self) -> (Self, bool) { let (a, b) = unsafe { intrinsics::add_with_overflow(self as $ActualT, @@ -1438,18 +1352,6 @@ } } - /// no docs here - #[stable(feature = "wrapping", since = "1.7.0")] - #[inline] - #[cfg(stage0)] - pub fn overflowing_sub(self, rhs: Self) -> (Self, bool) { - let (a, b) = unsafe { - intrinsics::sub_with_overflow(self as $ActualT, - rhs as $ActualT) - }; - (a as Self, b) - } - doc_comment! { concat!("Calculates `self` - `rhs` @@ -1470,7 +1372,6 @@ #[stable(feature = "wrapping", since = "1.7.0")] #[rustc_const_unstable(feature = "const_int_overflowing")] #[inline] - #[cfg(not(stage0))] pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool) { let (a, b) = unsafe { intrinsics::sub_with_overflow(self as $ActualT, @@ -1480,18 +1381,6 @@ } } - /// no docs here - #[stable(feature = "wrapping", since = "1.7.0")] - #[inline] - #[cfg(stage0)] - pub fn overflowing_mul(self, rhs: Self) -> (Self, bool) { - let (a, b) = unsafe { - intrinsics::mul_with_overflow(self as $ActualT, - rhs as $ActualT) - }; - (a as Self, b) - } - doc_comment! { concat!("Calculates the multiplication of `self` and `rhs`. @@ -1510,7 +1399,6 @@ #[stable(feature = "wrapping", since = "1.7.0")] #[rustc_const_unstable(feature = "const_int_overflowing")] #[inline] - #[cfg(not(stage0))] pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool) { let (a, b) = unsafe { intrinsics::mul_with_overflow(self as $ActualT, @@ -1681,14 +1569,6 @@ } } - /// no docs here - #[stable(feature = "wrapping", since = "1.7.0")] - #[inline] - #[cfg(stage0)] - pub fn overflowing_shl(self, rhs: u32) -> (Self, bool) { - (self.wrapping_shl(rhs), (rhs > ($BITS - 1))) - } - doc_comment! { concat!("Shifts self left by `rhs` bits. @@ -1708,20 +1588,11 @@ #[stable(feature = "wrapping", since = "1.7.0")] #[rustc_const_unstable(feature = "const_int_overflowing")] #[inline] - #[cfg(not(stage0))] pub const fn overflowing_shl(self, rhs: u32) -> (Self, bool) { (self.wrapping_shl(rhs), (rhs > ($BITS - 1))) } } - /// no docs here - #[stable(feature = "wrapping", since = "1.7.0")] - #[inline] - #[cfg(stage0)] - pub fn overflowing_shr(self, rhs: u32) -> (Self, bool) { - (self.wrapping_shr(rhs), (rhs > ($BITS - 1))) - } - doc_comment! { concat!("Shifts self right by `rhs` bits. @@ -1741,7 +1612,6 @@ #[stable(feature = "wrapping", since = "1.7.0")] #[rustc_const_unstable(feature = "const_int_overflowing")] #[inline] - #[cfg(not(stage0))] pub const fn overflowing_shr(self, rhs: u32) -> (Self, bool) { (self.wrapping_shr(rhs), (rhs > ($BITS - 1))) } @@ -2006,12 +1876,6 @@ } } - /// no docs here - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - #[cfg(stage0)] - pub fn is_positive(self) -> bool { self > 0 } - doc_comment! { concat!("Returns `true` if `self` is positive and `false` if the number is zero or negative. @@ -2028,16 +1892,9 @@ #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_int_sign")] #[inline] - #[cfg(not(stage0))] pub const fn is_positive(self) -> bool { self > 0 } } - /// no docs here - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - #[cfg(stage0)] - pub fn is_negative(self) -> bool { self < 0 } - doc_comment! { concat!("Returns `true` if `self` is negative and `false` if the number is zero or positive. @@ -2054,18 +1911,9 @@ #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_int_sign")] #[inline] - #[cfg(not(stage0))] pub const fn is_negative(self) -> bool { self < 0 } } - /// no docs here - #[unstable(feature = "int_to_from_bytes", issue = "52963")] - #[inline] - #[cfg(stage0)] - pub fn to_be_bytes(self) -> [u8; mem::size_of::()] { - self.to_be().to_ne_bytes() - } - doc_comment! { concat!("Return the memory representation of this integer as a byte array in big-endian (network) byte order. @@ -2081,20 +1929,11 @@ #[unstable(feature = "int_to_from_bytes", issue = "52963")] #[rustc_const_unstable(feature = "const_int_conversion")] #[inline] - #[cfg(not(stage0))] pub const fn to_be_bytes(self) -> [u8; mem::size_of::()] { self.to_be().to_ne_bytes() } } - /// no docs here - #[unstable(feature = "int_to_from_bytes", issue = "52963")] - #[inline] - #[cfg(stage0)] - pub fn to_le_bytes(self) -> [u8; mem::size_of::()] { - self.to_le().to_ne_bytes() - } - doc_comment! { concat!("Return the memory representation of this integer as a byte array in little-endian byte order. @@ -2110,20 +1949,11 @@ #[unstable(feature = "int_to_from_bytes", issue = "52963")] #[rustc_const_unstable(feature = "const_int_conversion")] #[inline] - #[cfg(not(stage0))] pub const fn to_le_bytes(self) -> [u8; mem::size_of::()] { self.to_le().to_ne_bytes() } } - /// no docs here - #[unstable(feature = "int_to_from_bytes", issue = "52963")] - #[inline] - #[cfg(stage0)] - pub fn to_ne_bytes(self) -> [u8; mem::size_of::()] { - unsafe { mem::transmute(self) } - } - doc_comment! { concat!(" Return the memory representation of this integer as a byte array in @@ -2151,20 +1981,11 @@ #[unstable(feature = "int_to_from_bytes", issue = "52963")] #[rustc_const_unstable(feature = "const_int_conversion")] #[inline] - #[cfg(not(stage0))] pub const fn to_ne_bytes(self) -> [u8; mem::size_of::()] { unsafe { mem::transmute(self) } } } - /// no docs here - #[unstable(feature = "int_to_from_bytes", issue = "52963")] - #[inline] - #[cfg(stage0)] - pub fn from_be_bytes(bytes: [u8; mem::size_of::()]) -> Self { - Self::from_be(Self::from_ne_bytes(bytes)) - } - doc_comment! { concat!("Create an integer value from its representation as a byte array in big endian. @@ -2180,20 +2001,11 @@ #[unstable(feature = "int_to_from_bytes", issue = "52963")] #[rustc_const_unstable(feature = "const_int_conversion")] #[inline] - #[cfg(not(stage0))] pub const fn from_be_bytes(bytes: [u8; mem::size_of::()]) -> Self { Self::from_be(Self::from_ne_bytes(bytes)) } } - /// no docs here - #[unstable(feature = "int_to_from_bytes", issue = "52963")] - #[inline] - #[cfg(stage0)] - pub fn from_le_bytes(bytes: [u8; mem::size_of::()]) -> Self { - Self::from_le(Self::from_ne_bytes(bytes)) - } - doc_comment! { concat!(" Create an integer value from its representation as a byte array in @@ -2210,20 +2022,11 @@ #[unstable(feature = "int_to_from_bytes", issue = "52963")] #[rustc_const_unstable(feature = "const_int_conversion")] #[inline] - #[cfg(not(stage0))] pub const fn from_le_bytes(bytes: [u8; mem::size_of::()]) -> Self { Self::from_le(Self::from_ne_bytes(bytes)) } } - /// no docs here - #[unstable(feature = "int_to_from_bytes", issue = "52963")] - #[inline] - #[cfg(stage0)] - pub fn from_ne_bytes(bytes: [u8; mem::size_of::()]) -> Self { - unsafe { mem::transmute(bytes) } - } - doc_comment! { concat!("Create an integer value from its memory representation as a byte array in native endianness. @@ -2250,7 +2053,6 @@ #[unstable(feature = "int_to_from_bytes", issue = "52963")] #[rustc_const_unstable(feature = "const_int_conversion")] #[inline] - #[cfg(not(stage0))] pub const fn from_ne_bytes(bytes: [u8; mem::size_of::()]) -> Self { unsafe { mem::transmute(bytes) } } @@ -2350,6 +2152,7 @@ ", $Feature, "assert_eq!(", stringify!($SelfT), "::min_value(), 0);", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_promotable] #[inline] pub const fn min_value() -> Self { 0 } } @@ -2366,6 +2169,7 @@ stringify!($MaxV), ");", $EndFeature, " ```"), #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_promotable] #[inline] pub const fn max_value() -> Self { !0 } } @@ -2479,16 +2283,6 @@ } } - /// no docs here - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - #[cfg(stage0)] - pub fn rotate_left(self, n: u32) -> Self { - // Protect against undefined behaviour for over-long bit shifts - let n = n % $BITS; - (self << n) | (self >> (($BITS - n) % $BITS)) - } - doc_comment! { concat!("Shifts the bits to the left by a specified amount, `n`, wrapping the truncated bits to the end of the resulting integer. @@ -2508,22 +2302,11 @@ #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_int_rotate")] #[inline] - #[cfg(not(stage0))] pub const fn rotate_left(self, n: u32) -> Self { (self << (n % $BITS)) | (self >> (($BITS - (n % $BITS)) % $BITS)) } } - /// no docs here - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - #[cfg(stage0)] - pub fn rotate_right(self, n: u32) -> Self { - // Protect against undefined behaviour for over-long bit shifts - let n = n % $BITS; - (self >> n) | (self << (($BITS - n) % $BITS)) - } - doc_comment! { concat!("Shifts the bits to the right by a specified amount, `n`, wrapping the truncated bits to the beginning of the resulting @@ -2544,7 +2327,6 @@ #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_int_rotate")] #[inline] - #[cfg(not(stage0))] pub const fn rotate_right(self, n: u32) -> Self { (self >> (n % $BITS)) | (self << (($BITS - (n % $BITS)) % $BITS)) } @@ -2572,14 +2354,6 @@ } } - /// no docs here - #[unstable(feature = "reverse_bits", issue = "48763")] - #[inline] - #[cfg(stage0)] - pub fn reverse_bits(self) -> Self { - unsafe { intrinsics::bitreverse(self as $ActualT) as Self } - } - doc_comment! { concat!("Reverses the bit pattern of the integer. @@ -2598,7 +2372,6 @@ #[unstable(feature = "reverse_bits", issue = "48763")] #[rustc_const_unstable(feature = "const_int_conversion")] #[inline] - #[cfg(not(stage0))] pub const fn reverse_bits(self) -> Self { unsafe { intrinsics::bitreverse(self as $ActualT) as Self } } @@ -3087,16 +2860,6 @@ } } - /// no docs here - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - #[cfg(stage0)] - pub fn wrapping_add(self, rhs: Self) -> Self { - unsafe { - intrinsics::overflowing_add(self, rhs) - } - } - doc_comment! { concat!("Wrapping (modular) addition. Computes `self + rhs`, wrapping around at the boundary of the type. @@ -3113,7 +2876,6 @@ #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_int_wrapping")] #[inline] - #[cfg(not(stage0))] pub const fn wrapping_add(self, rhs: Self) -> Self { unsafe { intrinsics::overflowing_add(self, rhs) @@ -3121,16 +2883,6 @@ } } - /// no docs here - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - #[cfg(stage0)] - pub fn wrapping_sub(self, rhs: Self) -> Self { - unsafe { - intrinsics::overflowing_sub(self, rhs) - } - } - doc_comment! { concat!("Wrapping (modular) subtraction. Computes `self - rhs`, wrapping around at the boundary of the type. @@ -3147,7 +2899,6 @@ #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_int_wrapping")] #[inline] - #[cfg(not(stage0))] pub const fn wrapping_sub(self, rhs: Self) -> Self { unsafe { intrinsics::overflowing_sub(self, rhs) @@ -3155,16 +2906,6 @@ } } - /// no docs here - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - #[cfg(stage0)] - pub fn wrapping_mul(self, rhs: Self) -> Self { - unsafe { - intrinsics::overflowing_mul(self, rhs) - } - } - /// Wrapping (modular) multiplication. Computes `self * /// rhs`, wrapping around at the boundary of the type. /// @@ -3182,7 +2923,6 @@ #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_int_wrapping")] #[inline] - #[cfg(not(stage0))] pub const fn wrapping_mul(self, rhs: Self) -> Self { unsafe { intrinsics::overflowing_mul(self, rhs) @@ -3304,16 +3044,6 @@ self.overflowing_neg().0 } - /// no docs here - #[stable(feature = "num_wrapping", since = "1.2.0")] - #[inline] - #[cfg(stage0)] - pub fn wrapping_shl(self, rhs: u32) -> Self { - unsafe { - intrinsics::unchecked_shl(self, (rhs & ($BITS - 1)) as $SelfT) - } - } - doc_comment! { concat!("Panic-free bitwise shift-left; yields `self << mask(rhs)`, where `mask` removes any high-order bits of `rhs` that @@ -3337,7 +3067,6 @@ #[stable(feature = "num_wrapping", since = "1.2.0")] #[rustc_const_unstable(feature = "const_int_wrapping")] #[inline] - #[cfg(not(stage0))] pub const fn wrapping_shl(self, rhs: u32) -> Self { unsafe { intrinsics::unchecked_shl(self, (rhs & ($BITS - 1)) as $SelfT) @@ -3345,16 +3074,6 @@ } } - /// no docs here - #[stable(feature = "num_wrapping", since = "1.2.0")] - #[inline] - #[cfg(stage0)] - pub fn wrapping_shr(self, rhs: u32) -> Self { - unsafe { - intrinsics::unchecked_shr(self, (rhs & ($BITS - 1)) as $SelfT) - } - } - doc_comment! { concat!("Panic-free bitwise shift-right; yields `self >> mask(rhs)`, where `mask` removes any high-order bits of `rhs` that @@ -3378,7 +3097,6 @@ #[stable(feature = "num_wrapping", since = "1.2.0")] #[rustc_const_unstable(feature = "const_int_wrapping")] #[inline] - #[cfg(not(stage0))] pub const fn wrapping_shr(self, rhs: u32) -> Self { unsafe { intrinsics::unchecked_shr(self, (rhs & ($BITS - 1)) as $SelfT) @@ -3424,18 +3142,6 @@ } } - /// no docs here - #[stable(feature = "wrapping", since = "1.7.0")] - #[inline] - #[cfg(stage0)] - pub fn overflowing_add(self, rhs: Self) -> (Self, bool) { - let (a, b) = unsafe { - intrinsics::add_with_overflow(self as $ActualT, - rhs as $ActualT) - }; - (a as Self, b) - } - doc_comment! { concat!("Calculates `self` + `rhs` @@ -3456,7 +3162,6 @@ #[stable(feature = "wrapping", since = "1.7.0")] #[rustc_const_unstable(feature = "const_int_overflowing")] #[inline] - #[cfg(not(stage0))] pub const fn overflowing_add(self, rhs: Self) -> (Self, bool) { let (a, b) = unsafe { intrinsics::add_with_overflow(self as $ActualT, @@ -3466,18 +3171,6 @@ } } - /// no docs here - #[stable(feature = "wrapping", since = "1.7.0")] - #[inline] - #[cfg(stage0)] - pub fn overflowing_sub(self, rhs: Self) -> (Self, bool) { - let (a, b) = unsafe { - intrinsics::sub_with_overflow(self as $ActualT, - rhs as $ActualT) - }; - (a as Self, b) - } - doc_comment! { concat!("Calculates `self` - `rhs` @@ -3499,7 +3192,6 @@ #[stable(feature = "wrapping", since = "1.7.0")] #[rustc_const_unstable(feature = "const_int_overflowing")] #[inline] - #[cfg(not(stage0))] pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool) { let (a, b) = unsafe { intrinsics::sub_with_overflow(self as $ActualT, @@ -3509,18 +3201,6 @@ } } - /// no docs here - #[stable(feature = "wrapping", since = "1.7.0")] - #[inline] - #[cfg(stage0)] - pub fn overflowing_mul(self, rhs: Self) -> (Self, bool) { - let (a, b) = unsafe { - intrinsics::mul_with_overflow(self as $ActualT, - rhs as $ActualT) - }; - (a as Self, b) - } - /// Calculates the multiplication of `self` and `rhs`. /// /// Returns a tuple of the multiplication along with a boolean @@ -3541,7 +3221,6 @@ #[stable(feature = "wrapping", since = "1.7.0")] #[rustc_const_unstable(feature = "const_int_overflowing")] #[inline] - #[cfg(not(stage0))] pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool) { let (a, b) = unsafe { intrinsics::mul_with_overflow(self as $ActualT, @@ -3680,14 +3359,6 @@ } } - /// no docs here - #[stable(feature = "wrapping", since = "1.7.0")] - #[inline] - #[cfg(stage0)] - pub fn overflowing_shl(self, rhs: u32) -> (Self, bool) { - (self.wrapping_shl(rhs), (rhs > ($BITS - 1))) - } - doc_comment! { concat!("Shifts self left by `rhs` bits. @@ -3708,20 +3379,11 @@ #[stable(feature = "wrapping", since = "1.7.0")] #[rustc_const_unstable(feature = "const_int_overflowing")] #[inline] - #[cfg(not(stage0))] pub const fn overflowing_shl(self, rhs: u32) -> (Self, bool) { (self.wrapping_shl(rhs), (rhs > ($BITS - 1))) } } - /// no docs here - #[stable(feature = "wrapping", since = "1.7.0")] - #[inline] - #[cfg(stage0)] - pub fn overflowing_shr(self, rhs: u32) -> (Self, bool) { - (self.wrapping_shr(rhs), (rhs > ($BITS - 1))) - } - doc_comment! { concat!("Shifts self right by `rhs` bits. @@ -3742,7 +3404,6 @@ #[stable(feature = "wrapping", since = "1.7.0")] #[rustc_const_unstable(feature = "const_int_overflowing")] #[inline] - #[cfg(not(stage0))] pub const fn overflowing_shr(self, rhs: u32) -> (Self, bool) { (self.wrapping_shr(rhs), (rhs > ($BITS - 1))) } @@ -3985,15 +3646,7 @@ } } - /// no docs here - #[unstable(feature = "int_to_from_bytes", issue = "52963")] - #[inline] - #[cfg(stage0)] - pub fn to_be_bytes(self) -> [u8; mem::size_of::()] { - self.to_be().to_ne_bytes() - } - - doc_comment! { + doc_comment! { concat!("Return the memory representation of this integer as a byte array in big-endian (network) byte order. @@ -4008,20 +3661,11 @@ #[unstable(feature = "int_to_from_bytes", issue = "52963")] #[rustc_const_unstable(feature = "const_int_conversion")] #[inline] - #[cfg(not(stage0))] pub const fn to_be_bytes(self) -> [u8; mem::size_of::()] { self.to_be().to_ne_bytes() } } - /// no docs here - #[unstable(feature = "int_to_from_bytes", issue = "52963")] - #[inline] - #[cfg(stage0)] - pub fn to_le_bytes(self) -> [u8; mem::size_of::()] { - self.to_le().to_ne_bytes() - } - doc_comment! { concat!("Return the memory representation of this integer as a byte array in little-endian byte order. @@ -4037,20 +3681,11 @@ #[unstable(feature = "int_to_from_bytes", issue = "52963")] #[rustc_const_unstable(feature = "const_int_conversion")] #[inline] - #[cfg(not(stage0))] pub const fn to_le_bytes(self) -> [u8; mem::size_of::()] { self.to_le().to_ne_bytes() } } - /// no docs here - #[unstable(feature = "int_to_from_bytes", issue = "52963")] - #[inline] - #[cfg(stage0)] - pub fn to_ne_bytes(self) -> [u8; mem::size_of::()] { - unsafe { mem::transmute(self) } - } - doc_comment! { concat!(" Return the memory representation of this integer as a byte array in @@ -4078,20 +3713,11 @@ #[unstable(feature = "int_to_from_bytes", issue = "52963")] #[rustc_const_unstable(feature = "const_int_conversion")] #[inline] - #[cfg(not(stage0))] pub const fn to_ne_bytes(self) -> [u8; mem::size_of::()] { unsafe { mem::transmute(self) } } } - /// no docs here - #[unstable(feature = "int_to_from_bytes", issue = "52963")] - #[inline] - #[cfg(stage0)] - pub fn from_be_bytes(bytes: [u8; mem::size_of::()]) -> Self { - Self::from_be(Self::from_ne_bytes(bytes)) - } - doc_comment! { concat!("Create an integer value from its representation as a byte array in big endian. @@ -4107,20 +3733,11 @@ #[unstable(feature = "int_to_from_bytes", issue = "52963")] #[rustc_const_unstable(feature = "const_int_conversion")] #[inline] - #[cfg(not(stage0))] pub const fn from_be_bytes(bytes: [u8; mem::size_of::()]) -> Self { Self::from_be(Self::from_ne_bytes(bytes)) } } - /// no docs here - #[unstable(feature = "int_to_from_bytes", issue = "52963")] - #[inline] - #[cfg(stage0)] - pub fn from_le_bytes(bytes: [u8; mem::size_of::()]) -> Self { - Self::from_le(Self::from_ne_bytes(bytes)) - } - doc_comment! { concat!(" Create an integer value from its representation as a byte array in @@ -4137,20 +3754,11 @@ #[unstable(feature = "int_to_from_bytes", issue = "52963")] #[rustc_const_unstable(feature = "const_int_conversion")] #[inline] - #[cfg(not(stage0))] pub const fn from_le_bytes(bytes: [u8; mem::size_of::()]) -> Self { Self::from_le(Self::from_ne_bytes(bytes)) } } - /// no docs here - #[unstable(feature = "int_to_from_bytes", issue = "52963")] - #[inline] - #[cfg(stage0)] - pub fn from_ne_bytes(bytes: [u8; mem::size_of::()]) -> Self { - unsafe { mem::transmute(bytes) } - } - doc_comment! { concat!("Create an integer value from its memory representation as a byte array in native endianness. @@ -4177,7 +3785,6 @@ #[unstable(feature = "int_to_from_bytes", issue = "52963")] #[rustc_const_unstable(feature = "const_int_conversion")] #[inline] - #[cfg(not(stage0))] pub const fn from_ne_bytes(bytes: [u8; mem::size_of::()]) -> Self { unsafe { mem::transmute(bytes) } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/ops/deref.rs rustc-1.31.0+dfsg1+llvm/src/libcore/ops/deref.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/ops/deref.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/ops/deref.rs 2018-12-04 23:41:40.000000000 +0000 @@ -83,14 +83,14 @@ } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> Deref for &'a T { +impl Deref for &T { type Target = T; fn deref(&self) -> &T { *self } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> Deref for &'a mut T { +impl Deref for &mut T { type Target = T; fn deref(&self) -> &T { *self } @@ -174,6 +174,6 @@ } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T: ?Sized> DerefMut for &'a mut T { +impl DerefMut for &mut T { fn deref_mut(&mut self) -> &mut T { *self } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/ops/function.rs rustc-1.31.0+dfsg1+llvm/src/libcore/ops/function.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/ops/function.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/ops/function.rs 2018-12-04 23:41:40.000000000 +0000 @@ -240,7 +240,7 @@ mod impls { #[stable(feature = "rust1", since = "1.0.0")] - impl<'a,A,F:?Sized> Fn for &'a F + impl Fn for &F where F : Fn { extern "rust-call" fn call(&self, args: A) -> F::Output { @@ -249,7 +249,7 @@ } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a,A,F:?Sized> FnMut for &'a F + impl FnMut for &F where F : Fn { extern "rust-call" fn call_mut(&mut self, args: A) -> F::Output { @@ -258,7 +258,7 @@ } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a,A,F:?Sized> FnOnce for &'a F + impl FnOnce for &F where F : Fn { type Output = F::Output; @@ -269,7 +269,7 @@ } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a,A,F:?Sized> FnMut for &'a mut F + impl FnMut for &mut F where F : FnMut { extern "rust-call" fn call_mut(&mut self, args: A) -> F::Output { @@ -278,7 +278,7 @@ } #[stable(feature = "rust1", since = "1.0.0")] - impl<'a,A,F:?Sized> FnOnce for &'a mut F + impl FnOnce for &mut F where F : FnMut { type Output = F::Output; diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/ops/generator.rs rustc-1.31.0+dfsg1+llvm/src/libcore/ops/generator.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/ops/generator.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/ops/generator.rs 2018-12-04 23:41:40.000000000 +0000 @@ -124,7 +124,7 @@ } #[unstable(feature = "generator_trait", issue = "43122")] -impl<'a, T> Generator for &'a mut T +impl Generator for &mut T where T: Generator + ?Sized { type Yield = T::Yield; diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/ops/range.rs rustc-1.31.0+dfsg1+llvm/src/libcore/ops/range.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/ops/range.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/ops/range.rs 2018-12-04 23:41:40.000000000 +0000 @@ -304,7 +304,7 @@ } } -/// An range bounded inclusively below and above (`start..=end`). +/// A range bounded inclusively below and above (`start..=end`). /// /// The `RangeInclusive` `start..=end` contains all values with `x >= start` /// and `x <= end`. It is empty unless `start <= end`. @@ -391,6 +391,7 @@ /// ``` #[stable(feature = "inclusive_range_methods", since = "1.27.0")] #[inline] + #[cfg_attr(not(stage0), rustc_promotable)] pub const fn new(start: Idx, end: Idx) -> Self { Self { start, end, is_empty: None } } @@ -851,7 +852,7 @@ } #[stable(feature = "collections_range", since = "1.28.0")] -impl<'a, T> RangeBounds for RangeFrom<&'a T> { +impl RangeBounds for RangeFrom<&T> { fn start_bound(&self) -> Bound<&T> { Included(self.start) } @@ -861,7 +862,7 @@ } #[stable(feature = "collections_range", since = "1.28.0")] -impl<'a, T> RangeBounds for RangeTo<&'a T> { +impl RangeBounds for RangeTo<&T> { fn start_bound(&self) -> Bound<&T> { Unbounded } @@ -871,7 +872,7 @@ } #[stable(feature = "collections_range", since = "1.28.0")] -impl<'a, T> RangeBounds for Range<&'a T> { +impl RangeBounds for Range<&T> { fn start_bound(&self) -> Bound<&T> { Included(self.start) } @@ -881,7 +882,7 @@ } #[stable(feature = "collections_range", since = "1.28.0")] -impl<'a, T> RangeBounds for RangeInclusive<&'a T> { +impl RangeBounds for RangeInclusive<&T> { fn start_bound(&self) -> Bound<&T> { Included(self.start) } @@ -891,7 +892,7 @@ } #[stable(feature = "collections_range", since = "1.28.0")] -impl<'a, T> RangeBounds for RangeToInclusive<&'a T> { +impl RangeBounds for RangeToInclusive<&T> { fn start_bound(&self) -> Bound<&T> { Unbounded } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/option.rs rustc-1.31.0+dfsg1+llvm/src/libcore/option.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/option.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/option.rs 2018-12-04 23:41:40.000000000 +0000 @@ -147,7 +147,7 @@ use iter::{FromIterator, FusedIterator, TrustedLen}; use {hint, mem, ops::{self, Deref}}; -use pin::PinMut; +use pin::Pin; // Note that this is not a lang item per se, but it has a hidden dependency on // `Iterator`, which is one. The compiler assumes that the `next` method of @@ -270,12 +270,22 @@ } } - /// Converts from `Option` to `Option>` + + /// Converts from `Pin<&Option>` to `Option>` + #[inline] + #[unstable(feature = "pin", issue = "49150")] + pub fn as_pin_ref<'a>(self: Pin<&'a Option>) -> Option> { + unsafe { + Pin::get_ref(self).as_ref().map(|x| Pin::new_unchecked(x)) + } + } + + /// Converts from `Pin<&mut Option>` to `Option>` #[inline] #[unstable(feature = "pin", issue = "49150")] - pub fn as_pin_mut<'a>(self: PinMut<'a, Self>) -> Option> { + pub fn as_pin_mut<'a>(self: Pin<&'a mut Option>) -> Option> { unsafe { - PinMut::get_mut_unchecked(self).as_mut().map(|x| PinMut::new_unchecked(x)) + Pin::get_mut_unchecked(self).as_mut().map(|x| Pin::new_unchecked(x)) } } @@ -857,8 +867,6 @@ /// # Examples /// /// ``` - /// #![feature(option_replace)] - /// /// let mut x = Some(2); /// let old = x.replace(5); /// assert_eq!(x, Some(5)); @@ -870,7 +878,7 @@ /// assert_eq!(old, None); /// ``` #[inline] - #[unstable(feature = "option_replace", issue = "51998")] + #[stable(feature = "option_replace", since = "1.31.0")] pub fn replace(&mut self, value: T) -> Option { mem::replace(self, Some(value)) } @@ -1143,18 +1151,18 @@ } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, A> ExactSizeIterator for Iter<'a, A> {} +impl ExactSizeIterator for Iter<'_, A> {} #[stable(feature = "fused", since = "1.26.0")] -impl<'a, A> FusedIterator for Iter<'a, A> {} +impl FusedIterator for Iter<'_, A> {} #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, A> TrustedLen for Iter<'a, A> {} +unsafe impl TrustedLen for Iter<'_, A> {} #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, A> Clone for Iter<'a, A> { +impl Clone for Iter<'_, A> { #[inline] - fn clone(&self) -> Iter<'a, A> { + fn clone(&self) -> Self { Iter { inner: self.inner.clone() } } } @@ -1189,12 +1197,12 @@ } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, A> ExactSizeIterator for IterMut<'a, A> {} +impl ExactSizeIterator for IterMut<'_, A> {} #[stable(feature = "fused", since = "1.26.0")] -impl<'a, A> FusedIterator for IterMut<'a, A> {} +impl FusedIterator for IterMut<'_, A> {} #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, A> TrustedLen for IterMut<'a, A> {} +unsafe impl TrustedLen for IterMut<'_, A> {} /// An iterator over the value in [`Some`] variant of an [`Option`]. /// diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/panic.rs rustc-1.31.0+dfsg1+llvm/src/libcore/panic.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/panic.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/panic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -133,7 +133,7 @@ } #[stable(feature = "panic_hook_display", since = "1.26.0")] -impl<'a> fmt::Display for PanicInfo<'a> { +impl fmt::Display for PanicInfo<'_> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("panicked at ")?; if let Some(message) = self.message { @@ -258,7 +258,7 @@ } #[stable(feature = "panic_hook_display", since = "1.26.0")] -impl<'a> fmt::Display for Location<'a> { +impl fmt::Display for Location<'_> { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { write!(formatter, "{}:{}:{}", self.file, self.line, self.col) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/pin.rs rustc-1.31.0+dfsg1+llvm/src/libcore/pin.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/pin.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/pin.rs 2018-12-04 23:41:40.000000000 +0000 @@ -1,160 +1,328 @@ //! Types which pin data to its location in memory //! -//! See the [standard library module] for more information. +//! It is sometimes useful to have objects that are guaranteed to not move, +//! in the sense that their placement in memory does not change, and can thus be relied upon. //! -//! [standard library module]: ../../std/pin/index.html +//! A prime example of such a scenario would be building self-referencial structs, +//! since moving an object with pointers to itself will invalidate them, +//! which could cause undefined behavior. +//! +//! In order to prevent objects from moving, they must be pinned +//! by wrapping a pointer to the data in the [`Pin`] type. A pointer wrapped +//! in a `Pin` is otherwise equivalent to its normal version, e.g. `Pin>` +//! and `Box` work the same way except that the first is pinning the value +//! of `T` in place. +//! +//! First of all, these are pointer types because pinned data mustn't be passed around by value +//! (that would change its location in memory). +//! Secondly, since data can be moved out of `&mut` and `Box` with functions such as [`swap`], +//! which causes their contents to swap places in memory, +//! we need dedicated types that prohibit such operations. +//! +//! However, these restrictions are usually not necessary, +//! so most types implement the [`Unpin`] auto-trait, +//! which indicates that the type can be moved out safely. +//! Doing so removes the limitations of pinning types, +//! making them the same as their non-pinning counterparts. +//! +//! [`Pin`]: struct.Pin.html +//! [`Unpin`]: trait.Unpin.html +//! [`swap`]: ../../std/mem/fn.swap.html +//! [`Box`]: ../../std/boxed/struct.Box.html +//! +//! # Examples +//! +//! ```rust +//! #![feature(pin)] +//! +//! use std::pin::Pin; +//! use std::marker::Pinned; +//! use std::ptr::NonNull; +//! +//! // This is a self referencial struct since the slice field points to the data field. +//! // We cannot inform the compiler about that with a normal reference, +//! // since this pattern cannot be described with the usual borrowing rules. +//! // Instead we use a raw pointer, though one which is known to not be null, +//! // since we know it's pointing at the string. +//! struct Unmovable { +//! data: String, +//! slice: NonNull, +//! _pin: Pinned, +//! } +//! +//! impl Unmovable { +//! // To ensure the data doesn't move when the function returns, +//! // we place it in the heap where it will stay for the lifetime of the object, +//! // and the only way to access it would be through a pointer to it. +//! fn new(data: String) -> Pin> { +//! let res = Unmovable { +//! data, +//! // we only create the pointer once the data is in place +//! // otherwise it will have already moved before we even started +//! slice: NonNull::dangling(), +//! _pin: Pinned, +//! }; +//! let mut boxed = Box::pinned(res); +//! +//! let slice = NonNull::from(&boxed.data); +//! // we know this is safe because modifying a field doesn't move the whole struct +//! unsafe { +//! let mut_ref: Pin<&mut Self> = Pin::as_mut(&mut boxed); +//! Pin::get_mut_unchecked(mut_ref).slice = slice; +//! } +//! boxed +//! } +//! } +//! +//! let unmoved = Unmovable::new("hello".to_string()); +//! // The pointer should point to the correct location, +//! // so long as the struct hasn't moved. +//! // Meanwhile, we are free to move the pointer around. +//! # #[allow(unused_mut)] +//! let mut still_unmoved = unmoved; +//! assert_eq!(still_unmoved.slice, NonNull::from(&still_unmoved.data)); +//! +//! // Since our type doesn't implement Unpin, this will fail to compile: +//! // let new_unmoved = Unmovable::new("world".to_string()); +//! // std::mem::swap(&mut *still_unmoved, &mut *new_unmoved); +//! ``` #![unstable(feature = "pin", issue = "49150")] use fmt; -use future::{Future, UnsafeFutureObj}; -use marker::{Sized, Unpin, Unsize}; -use task::{Context, Poll}; +use marker::Sized; use ops::{Deref, DerefMut, CoerceUnsized}; -/// A pinned reference. +#[doc(inline)] +pub use marker::Unpin; + +/// A pinned pointer. /// -/// This type is similar to a mutable reference, except that it pins its value, -/// which prevents it from moving out of the reference, unless it implements [`Unpin`]. +/// This is a wrapper around a kind of pointer which makes that pointer "pin" its +/// value in place, preventing the value referenced by that pointer from being moved +/// unless it implements [`Unpin`]. /// -/// See the [`pin` module] documentation for furthur explanation on pinning. +/// See the [`pin` module] documentation for further explanation on pinning. /// /// [`Unpin`]: ../../std/marker/trait.Unpin.html /// [`pin` module]: ../../std/pin/index.html +// +// Note: the derives below are allowed because they all only use `&P`, so they +// cannot move the value behind `pointer`. #[unstable(feature = "pin", issue = "49150")] #[fundamental] -pub struct PinMut<'a, T: ?Sized + 'a> { - inner: &'a mut T, +#[derive(Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)] +pub struct Pin

{ + pointer: P, } -#[unstable(feature = "pin", issue = "49150")] -impl<'a, T: ?Sized + Unpin> PinMut<'a, T> { - /// Construct a new `PinMut` around a reference to some data of a type that +impl Pin

+where + P::Target: Unpin, +{ + /// Construct a new `Pin` around a pointer to some data of a type that /// implements `Unpin`. #[unstable(feature = "pin", issue = "49150")] - pub fn new(reference: &'a mut T) -> PinMut<'a, T> { - PinMut { inner: reference } + #[inline(always)] + pub fn new(pointer: P) -> Pin

{ + // Safety: the value pointed to is `Unpin`, and so has no requirements + // around pinning. + unsafe { Pin::new_unchecked(pointer) } } +} - /// Get a mutable reference to the data inside of this `PinMut`. +impl Pin

{ + /// Construct a new `Pin` around a reference to some data of a type that + /// may or may not implement `Unpin`. + /// + /// # Safety + /// + /// This constructor is unsafe because we cannot guarantee that the data + /// pointed to by `pointer` is pinned. If the constructed `Pin

` does + /// not guarantee that the data `P` points to is pinned, constructing a + /// `Pin

` is undefined behavior. + /// + /// If `pointer` dereferences to an `Unpin` type, `Pin::new` should be used + /// instead. + #[unstable(feature = "pin", issue = "49150")] + #[inline(always)] + pub unsafe fn new_unchecked(pointer: P) -> Pin

{ + Pin { pointer } + } + + /// Get a pinned shared reference from this pinned pointer. #[unstable(feature = "pin", issue = "49150")] - pub fn get_mut(this: PinMut<'a, T>) -> &'a mut T { - this.inner + #[inline(always)] + pub fn as_ref(self: &Pin

) -> Pin<&P::Target> { + unsafe { Pin::new_unchecked(&*self.pointer) } } } +impl Pin

{ + /// Get a pinned mutable reference from this pinned pointer. + #[unstable(feature = "pin", issue = "49150")] + #[inline(always)] + pub fn as_mut(self: &mut Pin

) -> Pin<&mut P::Target> { + unsafe { Pin::new_unchecked(&mut *self.pointer) } + } -#[unstable(feature = "pin", issue = "49150")] -impl<'a, T: ?Sized> PinMut<'a, T> { - /// Construct a new `PinMut` around a reference to some data of a type that - /// may or may not implement `Unpin`. + /// Assign a new value to the memory behind the pinned reference. + #[unstable(feature = "pin", issue = "49150")] + #[inline(always)] + pub fn set(mut self: Pin

, value: P::Target) + where + P::Target: Sized, + { + *self.pointer = value; + } +} + +impl<'a, T: ?Sized> Pin<&'a T> { + /// Construct a new pin by mapping the interior value. /// - /// This constructor is unsafe because we do not know what will happen with - /// that data after the lifetime of the reference ends. If you cannot guarantee that the - /// data will never move again, calling this constructor is invalid. + /// For example, if you wanted to get a `Pin` of a field of something, + /// you could use this to get access to that field in one line of code. + /// + /// # Safety + /// + /// This function is unsafe. You must guarantee that the data you return + /// will not move so long as the argument value does not move (for example, + /// because it is one of the fields of that value), and also that you do + /// not move out of the argument you receive to the interior function. #[unstable(feature = "pin", issue = "49150")] - pub unsafe fn new_unchecked(reference: &'a mut T) -> PinMut<'a, T> { - PinMut { inner: reference } + pub unsafe fn map_unchecked(this: Pin<&'a T>, func: F) -> Pin<&'a U> where + F: FnOnce(&T) -> &U, + { + let pointer = &*this.pointer; + let new_pointer = func(pointer); + Pin::new_unchecked(new_pointer) } - /// Reborrow a `PinMut` for a shorter lifetime. + /// Get a shared reference out of a pin. /// - /// For example, `PinMut::get_mut(x.reborrow())` (unsafely) returns a - /// short-lived mutable reference reborrowing from `x`. + /// Note: `Pin` also implements `Deref` to the target, which can be used + /// to access the inner value. However, `Deref` only provides a reference + /// that lives for as long as the borrow of the `Pin`, not the lifetime of + /// the `Pin` itself. This method allows turning the `Pin` into a reference + /// with the same lifetime as the original `Pin`. #[unstable(feature = "pin", issue = "49150")] - pub fn reborrow<'b>(&'b mut self) -> PinMut<'b, T> { - PinMut { inner: self.inner } + #[inline(always)] + pub fn get_ref(this: Pin<&'a T>) -> &'a T { + this.pointer + } +} + +impl<'a, T: ?Sized> Pin<&'a mut T> { + /// Convert this `Pin<&mut T>` into a `Pin<&T>` with the same lifetime. + #[unstable(feature = "pin", issue = "49150")] + #[inline(always)] + pub fn into_ref(this: Pin<&'a mut T>) -> Pin<&'a T> { + Pin { pointer: this.pointer } + } + + /// Get a mutable reference to the data inside of this `Pin`. + /// + /// This requires that the data inside this `Pin` is `Unpin`. + /// + /// Note: `Pin` also implements `DerefMut` to the data, which can be used + /// to access the inner value. However, `DerefMut` only provides a reference + /// that lives for as long as the borrow of the `Pin`, not the lifetime of + /// the `Pin` itself. This method allows turning the `Pin` into a reference + /// with the same lifetime as the original `Pin`. + #[unstable(feature = "pin", issue = "49150")] + #[inline(always)] + pub fn get_mut(this: Pin<&'a mut T>) -> &'a mut T + where T: Unpin, + { + this.pointer } - /// Get a mutable reference to the data inside of this `PinMut`. + /// Get a mutable reference to the data inside of this `Pin`. + /// + /// # Safety /// /// This function is unsafe. You must guarantee that you will never move /// the data out of the mutable reference you receive when you call this - /// function. + /// function, so that the invariants on the `Pin` type can be upheld. + /// + /// If the underlying data is `Unpin`, `Pin::get_mut` should be used + /// instead. #[unstable(feature = "pin", issue = "49150")] - pub unsafe fn get_mut_unchecked(this: PinMut<'a, T>) -> &'a mut T { - this.inner + #[inline(always)] + pub unsafe fn get_mut_unchecked(this: Pin<&'a mut T>) -> &'a mut T { + this.pointer } /// Construct a new pin by mapping the interior value. /// - /// For example, if you wanted to get a `PinMut` of a field of something, + /// For example, if you wanted to get a `Pin` of a field of something, /// you could use this to get access to that field in one line of code. /// + /// # Safety + /// /// This function is unsafe. You must guarantee that the data you return /// will not move so long as the argument value does not move (for example, /// because it is one of the fields of that value), and also that you do /// not move out of the argument you receive to the interior function. #[unstable(feature = "pin", issue = "49150")] - pub unsafe fn map_unchecked(this: PinMut<'a, T>, f: F) -> PinMut<'a, U> where - F: FnOnce(&mut T) -> &mut U + pub unsafe fn map_unchecked_mut(this: Pin<&'a mut T>, func: F) -> Pin<&'a mut U> where + F: FnOnce(&mut T) -> &mut U, { - PinMut { inner: f(this.inner) } - } - - /// Assign a new value to the memory behind the pinned reference. - #[unstable(feature = "pin", issue = "49150")] - pub fn set(this: PinMut<'a, T>, value: T) - where T: Sized, - { - *this.inner = value; + let pointer = Pin::get_mut_unchecked(this); + let new_pointer = func(pointer); + Pin::new_unchecked(new_pointer) } } #[unstable(feature = "pin", issue = "49150")] -impl<'a, T: ?Sized> Deref for PinMut<'a, T> { - type Target = T; - - fn deref(&self) -> &T { - &*self.inner +impl Deref for Pin

{ + type Target = P::Target; + fn deref(&self) -> &P::Target { + Pin::get_ref(Pin::as_ref(self)) } } #[unstable(feature = "pin", issue = "49150")] -impl<'a, T: ?Sized + Unpin> DerefMut for PinMut<'a, T> { - fn deref_mut(&mut self) -> &mut T { - self.inner +impl DerefMut for Pin

+where + P::Target: Unpin +{ + fn deref_mut(&mut self) -> &mut P::Target { + Pin::get_mut(Pin::as_mut(self)) } } #[unstable(feature = "pin", issue = "49150")] -impl<'a, T: fmt::Debug + ?Sized> fmt::Debug for PinMut<'a, T> { +impl fmt::Debug for Pin

{ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Debug::fmt(&**self, f) + fmt::Debug::fmt(&self.pointer, f) } } #[unstable(feature = "pin", issue = "49150")] -impl<'a, T: fmt::Display + ?Sized> fmt::Display for PinMut<'a, T> { +impl fmt::Display for Pin

{ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Display::fmt(&**self, f) + fmt::Display::fmt(&self.pointer, f) } } #[unstable(feature = "pin", issue = "49150")] -impl<'a, T: ?Sized> fmt::Pointer for PinMut<'a, T> { +impl fmt::Pointer for Pin

{ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Pointer::fmt(&(&*self.inner as *const T), f) + fmt::Pointer::fmt(&self.pointer, f) } } +// Note: this means that any impl of `CoerceUnsized` that allows coercing from +// a type that impls `Deref` to a type that impls +// `Deref` is unsound. Any such impl would probably be unsound +// for other reasons, though, so we just need to take care not to allow such +// impls to land in std. #[unstable(feature = "pin", issue = "49150")] -impl<'a, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized> for PinMut<'a, T> {} +impl CoerceUnsized> for Pin

+where + P: CoerceUnsized, +{} #[unstable(feature = "pin", issue = "49150")] -impl<'a, T: ?Sized> Unpin for PinMut<'a, T> {} - -#[unstable(feature = "futures_api", issue = "50547")] -unsafe impl<'a, T, F> UnsafeFutureObj<'a, T> for PinMut<'a, F> - where F: Future + 'a -{ - fn into_raw(self) -> *mut () { - unsafe { PinMut::get_mut_unchecked(self) as *mut F as *mut () } - } - - unsafe fn poll(ptr: *mut (), cx: &mut Context) -> Poll { - PinMut::new_unchecked(&mut *(ptr as *mut F)).poll(cx) - } - - unsafe fn drop(_ptr: *mut ()) {} -} +impl

Unpin for Pin

{} diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/ptr.rs rustc-1.31.0+dfsg1+llvm/src/libcore/ptr.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/ptr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/ptr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,11 +8,68 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// FIXME: talk about offset, copy_memory, copy_nonoverlapping_memory - -//! Raw, unsafe pointers, `*const T`, and `*mut T`. +//! Manually manage memory through raw pointers. //! //! *[See also the pointer primitive types](../../std/primitive.pointer.html).* +//! +//! # Safety +//! +//! Many functions in this module take raw pointers as arguments and read from +//! or write to them. For this to be safe, these pointers must be *valid*. +//! Whether a pointer is valid depends on the operation it is used for +//! (read or write), and the extent of the memory that is accessed (i.e., +//! how many bytes are read/written). Most functions use `*mut T` and `*const T` +//! to access only a single value, in which case the documentation omits the size +//! and implicitly assumes it to be `size_of::()` bytes. +//! +//! The precise rules for validity are not determined yet. The guarantees that are +//! provided at this point are very minimal: +//! +//! * A [null] pointer is *never* valid, not even for accesses of [size zero][zst]. +//! * All pointers (except for the null pointer) are valid for all operations of +//! [size zero][zst]. +//! * All accesses performed by functions in this module are *non-atomic* in the sense +//! of [atomic operations] used to synchronize between threads. This means it is +//! undefined behavior to perform two concurrent accesses to the same location from different +//! threads unless both accesses only read from memory. Notice that this explicitly +//! includes [`read_volatile`] and [`write_volatile`]: Volatile accesses cannot +//! be used for inter-thread synchronization. +//! * The result of casting a reference to a pointer is valid for as long as the +//! underlying object is live and no reference (just raw pointers) is used to +//! access the same memory. +//! +//! These axioms, along with careful use of [`offset`] for pointer arithmetic, +//! are enough to correctly implement many useful things in unsafe code. Stronger guarantees +//! will be provided eventually, as the [aliasing] rules are being determined. For more +//! information, see the [book] as well as the section in the reference devoted +//! to [undefined behavior][ub]. +//! +//! ## Alignment +//! +//! Valid raw pointers as defined above are not necessarily properly aligned (where +//! "proper" alignment is defined by the pointee type, i.e., `*const T` must be +//! aligned to `mem::align_of::()`). However, most functions require their +//! arguments to be properly aligned, and will explicitly state +//! this requirement in their documentation. Notable exceptions to this are +//! [`read_unaligned`] and [`write_unaligned`]. +//! +//! When a function requires proper alignment, it does so even if the access +//! has size 0, i.e., even if memory is not actually touched. Consider using +//! [`NonNull::dangling`] in such cases. +//! +//! [aliasing]: ../../nomicon/aliasing.html +//! [book]: ../../book/ch19-01-unsafe-rust.html#dereferencing-a-raw-pointer +//! [ub]: ../../reference/behavior-considered-undefined.html +//! [null]: ./fn.null.html +//! [zst]: ../../nomicon/exotic-sizes.html#zero-sized-types-zsts +//! [atomic operations]: ../../std/sync/atomic/index.html +//! [`copy`]: ../../std/ptr/fn.copy.html +//! [`offset`]: ../../std/primitive.pointer.html#method.offset +//! [`read_unaligned`]: ./fn.read_unaligned.html +//! [`write_unaligned`]: ./fn.write_unaligned.html +//! [`read_volatile`]: ./fn.read_volatile.html +//! [`write_volatile`]: ./fn.write_volatile.html +//! [`NonNull::dangling`]: ./struct.NonNull.html#method.dangling #![stable(feature = "rust1", since = "1.0.0")] @@ -38,21 +95,99 @@ /// Executes the destructor (if any) of the pointed-to value. /// -/// This has two use cases: +/// This is semantically equivalent to calling [`ptr::read`] and discarding +/// the result, but has the following advantages: /// /// * It is *required* to use `drop_in_place` to drop unsized types like /// trait objects, because they can't be read out onto the stack and /// dropped normally. /// -/// * It is friendlier to the optimizer to do this over `ptr::read` when +/// * It is friendlier to the optimizer to do this over [`ptr::read`] when /// dropping manually allocated memory (e.g. when writing Box/Rc/Vec), /// as the compiler doesn't need to prove that it's sound to elide the /// copy. /// +/// [`ptr::read`]: ../ptr/fn.read.html +/// /// # Safety /// -/// This has all the same safety problems as `ptr::read` with respect to -/// invalid pointers, types, and double drops. +/// Behavior is undefined if any of the following conditions are violated: +/// +/// * `to_drop` must be [valid] for reads. +/// +/// * `to_drop` must be properly aligned. See the example below for how to drop +/// an unaligned pointer. +/// +/// Additionally, if `T` is not [`Copy`], using the pointed-to value after +/// calling `drop_in_place` can cause undefined behavior. Note that `*to_drop = +/// foo` counts as a use because it will cause the the value to be dropped +/// again. [`write`] can be used to overwrite data without causing it to be +/// dropped. +/// +/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned. +/// +/// [valid]: ../ptr/index.html#safety +/// [`Copy`]: ../marker/trait.Copy.html +/// [`write`]: ../ptr/fn.write.html +/// +/// # Examples +/// +/// Manually remove the last item from a vector: +/// +/// ``` +/// use std::ptr; +/// use std::rc::Rc; +/// +/// let last = Rc::new(1); +/// let weak = Rc::downgrade(&last); +/// +/// let mut v = vec![Rc::new(0), last]; +/// +/// unsafe { +/// // Get a raw pointer to the last element in `v`. +/// let ptr = &mut v[1] as *mut _; +/// // Shorten `v` to prevent the last item from being dropped. We do that first, +/// // to prevent issues if the `drop_in_place` below panics. +/// v.set_len(1); +/// // Without a call `drop_in_place`, the last item would never be dropped, +/// // and the memory it manages would be leaked. +/// ptr::drop_in_place(ptr); +/// } +/// +/// assert_eq!(v, &[0.into()]); +/// +/// // Ensure that the last item was dropped. +/// assert!(weak.upgrade().is_none()); +/// ``` +/// +/// Unaligned values cannot be dropped in place, they must be copied to an aligned +/// location first: +/// ``` +/// use std::ptr; +/// use std::mem; +/// +/// unsafe fn drop_after_copy(to_drop: *mut T) { +/// let mut copy: T = mem::uninitialized(); +/// ptr::copy(to_drop, &mut copy, 1); +/// drop(copy); +/// } +/// +/// #[repr(packed, C)] +/// struct Packed { +/// _padding: u8, +/// unaligned: Vec, +/// } +/// +/// let mut p = Packed { _padding: 0, unaligned: vec![42] }; +/// unsafe { +/// drop_after_copy(&mut p.unaligned as *mut _); +/// mem::forget(p); +/// } +/// ``` +/// +/// Notice that the compiler performs this copy automatically when dropping packed structs, +/// i.e., you do not usually have to worry about such issues unless you call `drop_in_place` +/// manually. #[stable(feature = "drop_in_place", since = "1.8.0")] #[lang = "drop_in_place"] #[allow(unconditional_recursion)] @@ -74,6 +209,7 @@ /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(stage0), rustc_promotable)] pub const fn null() -> *const T { 0 as *const T } /// Creates a null mutable raw pointer. @@ -88,22 +224,35 @@ /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(stage0), rustc_promotable)] pub const fn null_mut() -> *mut T { 0 as *mut T } /// Swaps the values at two mutable locations of the same type, without /// deinitializing either. /// -/// The values pointed at by `x` and `y` may overlap, unlike `mem::swap` which -/// is otherwise equivalent. If the values do overlap, then the overlapping -/// region of memory from `x` will be used. This is demonstrated in the -/// examples section below. +/// But for the following two exceptions, this function is semantically +/// equivalent to [`mem::swap`]: +/// +/// * It operates on raw pointers instead of references. When references are +/// available, [`mem::swap`] should be preferred. +/// +/// * The two pointed-to values may overlap. If the values do overlap, then the +/// overlapping region of memory from `x` will be used. This is demonstrated +/// in the second example below. +/// +/// [`mem::swap`]: ../mem/fn.swap.html /// /// # Safety /// -/// This function copies the memory through the raw pointers passed to it -/// as arguments. +/// Behavior is undefined if any of the following conditions are violated: +/// +/// * Both `x` and `y` must be [valid] for reads and writes. /// -/// Ensure that these pointers are valid before calling `swap`. +/// * Both `x` and `y` must be properly aligned. +/// +/// Note that even if `T` has size `0`, the pointers must be non-NULL and properly aligned. +/// +/// [valid]: ../ptr/index.html#safety /// /// # Examples /// @@ -114,8 +263,8 @@ /// /// let mut array = [0, 1, 2, 3]; /// -/// let x = array[0..].as_mut_ptr() as *mut [u32; 2]; -/// let y = array[2..].as_mut_ptr() as *mut [u32; 2]; +/// let x = array[0..].as_mut_ptr() as *mut [u32; 2]; // this is `array[0..2]` +/// let y = array[2..].as_mut_ptr() as *mut [u32; 2]; // this is `array[2..4]` /// /// unsafe { /// ptr::swap(x, y); @@ -130,11 +279,16 @@ /// /// let mut array = [0, 1, 2, 3]; /// -/// let x = array[0..].as_mut_ptr() as *mut [u32; 3]; -/// let y = array[1..].as_mut_ptr() as *mut [u32; 3]; +/// let x = array[0..].as_mut_ptr() as *mut [u32; 3]; // this is `array[0..3]` +/// let y = array[1..].as_mut_ptr() as *mut [u32; 3]; // this is `array[1..4]` /// /// unsafe { /// ptr::swap(x, y); +/// // The indices `1..3` of the slice overlap between `x` and `y`. +/// // Reasonable results would be for to them be `[2, 3]`, so that indices `0..3` are +/// // `[1, 2, 3]` (matching `y` before the `swap`); or for them to be `[0, 1]` +/// // so that indices `1..4` are `[0, 1, 2]` (matching `x` before the `swap`). +/// // This implementation is defined to make the latter choice. /// assert_eq!([1, 0, 1, 2], array); /// } /// ``` @@ -154,12 +308,26 @@ mem::forget(tmp); } -/// Swaps a sequence of values at two mutable locations of the same type. +/// Swaps `count * size_of::()` bytes between the two regions of memory +/// beginning at `x` and `y`. The two regions must *not* overlap. /// /// # Safety /// -/// The two arguments must each point to the beginning of `count` locations -/// of valid memory, and the two memory ranges must not overlap. +/// Behavior is undefined if any of the following conditions are violated: +/// +/// * Both `x` and `y` must be [valid] for reads and writes of `count * +/// size_of::()` bytes. +/// +/// * Both `x` and `y` must be properly aligned. +/// +/// * The region of memory beginning at `x` with a size of `count * +/// size_of::()` bytes must *not* overlap with the region of memory +/// beginning at `y` with the same size. +/// +/// Note that even if the effectively copied size (`count * size_of::()`) is `0`, +/// the pointers must be non-NULL and properly aligned. +/// +/// [valid]: ../ptr/index.html#safety /// /// # Examples /// @@ -252,18 +420,48 @@ } } -/// Moves `src` into the pointed `dest`, returning the previous `dest` value. +/// Moves `src` into the pointed `dst`, returning the previous `dst` value. /// /// Neither value is dropped. /// +/// This function is semantically equivalent to [`mem::replace`] except that it +/// operates on raw pointers instead of references. When references are +/// available, [`mem::replace`] should be preferred. +/// +/// [`mem::replace`]: ../mem/fn.replace.html +/// /// # Safety /// -/// This is only unsafe because it accepts a raw pointer. -/// Otherwise, this operation is identical to `mem::replace`. +/// Behavior is undefined if any of the following conditions are violated: +/// +/// * `dst` must be [valid] for writes. +/// +/// * `dst` must be properly aligned. +/// +/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned. +/// +/// [valid]: ../ptr/index.html#safety +/// +/// # Examples +/// +/// ``` +/// use std::ptr; +/// +/// let mut rust = vec!['b', 'u', 's', 't']; +/// +/// // `mem::replace` would have the same effect without requiring the unsafe +/// // block. +/// let b = unsafe { +/// ptr::replace(&mut rust[0], 'r') +/// }; +/// +/// assert_eq!(b, 'b'); +/// assert_eq!(rust, &['r', 'u', 's', 't']); +/// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] -pub unsafe fn replace(dest: *mut T, mut src: T) -> T { - mem::swap(&mut *dest, &mut src); // cannot overlap +pub unsafe fn replace(dst: *mut T, mut src: T) -> T { + mem::swap(&mut *dst, &mut src); // cannot overlap src } @@ -272,14 +470,14 @@ /// /// # Safety /// -/// Beyond accepting a raw pointer, this is unsafe because it semantically -/// moves the value out of `src` without preventing further usage of `src`. -/// If `T` is not `Copy`, then care must be taken to ensure that the value at -/// `src` is not used before the data is overwritten again (e.g. with `write`, -/// `write_bytes`, or `copy`). Note that `*src = foo` counts as a use -/// because it will attempt to drop the value previously at `*src`. +/// Behavior is undefined if any of the following conditions are violated: +/// +/// * `src` must be [valid] for reads. /// -/// The pointer must be aligned; use `read_unaligned` if that is not the case. +/// * `src` must be properly aligned. Use [`read_unaligned`] if this is not the +/// case. +/// +/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned. /// /// # Examples /// @@ -293,6 +491,87 @@ /// assert_eq!(std::ptr::read(y), 12); /// } /// ``` +/// +/// Manually implement [`mem::swap`]: +/// +/// ``` +/// use std::ptr; +/// +/// fn swap(a: &mut T, b: &mut T) { +/// unsafe { +/// // Create a bitwise copy of the value at `a` in `tmp`. +/// let tmp = ptr::read(a); +/// +/// // Exiting at this point (either by explicitly returning or by +/// // calling a function which panics) would cause the value in `tmp` to +/// // be dropped while the same value is still referenced by `a`. This +/// // could trigger undefined behavior if `T` is not `Copy`. +/// +/// // Create a bitwise copy of the value at `b` in `a`. +/// // This is safe because mutable references cannot alias. +/// ptr::copy_nonoverlapping(b, a, 1); +/// +/// // As above, exiting here could trigger undefined behavior because +/// // the same value is referenced by `a` and `b`. +/// +/// // Move `tmp` into `b`. +/// ptr::write(b, tmp); +/// +/// // `tmp` has been moved (`write` takes ownership of its second argument), +/// // so nothing is dropped implicitly here. +/// } +/// } +/// +/// let mut foo = "foo".to_owned(); +/// let mut bar = "bar".to_owned(); +/// +/// swap(&mut foo, &mut bar); +/// +/// assert_eq!(foo, "bar"); +/// assert_eq!(bar, "foo"); +/// ``` +/// +/// ## Ownership of the Returned Value +/// +/// `read` creates a bitwise copy of `T`, regardless of whether `T` is [`Copy`]. +/// If `T` is not [`Copy`], using both the returned value and the value at +/// `*src` can violate memory safety. Note that assigning to `*src` counts as a +/// use because it will attempt to drop the value at `*src`. +/// +/// [`write`] can be used to overwrite data without causing it to be dropped. +/// +/// ``` +/// use std::ptr; +/// +/// let mut s = String::from("foo"); +/// unsafe { +/// // `s2` now points to the same underlying memory as `s`. +/// let mut s2: String = ptr::read(&s); +/// +/// assert_eq!(s2, "foo"); +/// +/// // Assigning to `s2` causes its original value to be dropped. Beyond +/// // this point, `s` must no longer be used, as the underlying memory has +/// // been freed. +/// s2 = String::default(); +/// assert_eq!(s2, ""); +/// +/// // Assigning to `s` would cause the old value to be dropped again, +/// // resulting in undefined behavior. +/// // s = String::from("bar"); // ERROR +/// +/// // `ptr::write` can be used to overwrite a value without dropping it. +/// ptr::write(&mut s, String::from("bar")); +/// } +/// +/// assert_eq!(s, "bar"); +/// ``` +/// +/// [`mem::swap`]: ../mem/fn.swap.html +/// [valid]: ../ptr/index.html#safety +/// [`Copy`]: ../marker/trait.Copy.html +/// [`read_unaligned`]: ./fn.read_unaligned.html +/// [`write`]: ./fn.write.html #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn read(src: *const T) -> T { @@ -304,28 +583,61 @@ /// Reads the value from `src` without moving it. This leaves the /// memory in `src` unchanged. /// -/// Unlike `read`, the pointer may be unaligned. +/// Unlike [`read`], `read_unaligned` works with unaligned pointers. /// /// # Safety /// -/// Beyond accepting a raw pointer, this is unsafe because it semantically -/// moves the value out of `src` without preventing further usage of `src`. -/// If `T` is not `Copy`, then care must be taken to ensure that the value at -/// `src` is not used before the data is overwritten again (e.g. with `write`, -/// `write_bytes`, or `copy`). Note that `*src = foo` counts as a use -/// because it will attempt to drop the value previously at `*src`. +/// Behavior is undefined if any of the following conditions are violated: +/// +/// * `src` must be [valid] for reads. +/// +/// Like [`read`], `read_unaligned` creates a bitwise copy of `T`, regardless of +/// whether `T` is [`Copy`]. If `T` is not [`Copy`], using both the returned +/// value and the value at `*src` can [violate memory safety][read-ownership]. +/// +/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned. +/// +/// [`Copy`]: ../marker/trait.Copy.html +/// [`read`]: ./fn.read.html +/// [`write_unaligned`]: ./fn.write_unaligned.html +/// [read-ownership]: ./fn.read.html#ownership-of-the-returned-value +/// [valid]: ../ptr/index.html#safety /// /// # Examples /// -/// Basic usage: +/// Access members of a packed struct by reference: /// /// ``` -/// let x = 12; -/// let y = &x as *const i32; +/// use std::ptr; /// -/// unsafe { -/// assert_eq!(std::ptr::read_unaligned(y), 12); +/// #[repr(packed, C)] +/// struct Packed { +/// _padding: u8, +/// unaligned: u32, /// } +/// +/// let x = Packed { +/// _padding: 0x00, +/// unaligned: 0x01020304, +/// }; +/// +/// let v = unsafe { +/// // Take the address of a 32-bit integer which is not aligned. +/// // This must be done as a raw pointer; unaligned references are invalid. +/// let unaligned = &x.unaligned as *const u32; +/// +/// // Dereferencing normally will emit an aligned load instruction, +/// // causing undefined behavior. +/// // let v = *unaligned; // ERROR +/// +/// // Instead, use `read_unaligned` to read improperly aligned values. +/// let v = ptr::read_unaligned(unaligned); +/// +/// v +/// }; +/// +/// // Accessing unaligned values directly is safe. +/// assert!(x.unaligned == v); /// ``` #[inline] #[stable(feature = "ptr_unaligned", since = "1.17.0")] @@ -340,21 +652,31 @@ /// Overwrites a memory location with the given value without reading or /// dropping the old value. /// -/// # Safety -/// -/// This operation is marked unsafe because it accepts a raw pointer. -/// -/// It does not drop the contents of `dst`. This is safe, but it could leak -/// allocations or resources, so care must be taken not to overwrite an object +/// `write` does not drop the contents of `dst`. This is safe, but it could leak +/// allocations or resources, so care should be taken not to overwrite an object /// that should be dropped. /// /// Additionally, it does not drop `src`. Semantically, `src` is moved into the /// location pointed to by `dst`. /// /// This is appropriate for initializing uninitialized memory, or overwriting -/// memory that has previously been `read` from. +/// memory that has previously been [`read`] from. +/// +/// [`read`]: ./fn.read.html +/// +/// # Safety +/// +/// Behavior is undefined if any of the following conditions are violated: /// -/// The pointer must be aligned; use `write_unaligned` if that is not the case. +/// * `dst` must be [valid] for writes. +/// +/// * `dst` must be properly aligned. Use [`write_unaligned`] if this is not the +/// case. +/// +/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned. +/// +/// [valid]: ../ptr/index.html#safety +/// [`write_unaligned`]: ./fn.write_unaligned.html /// /// # Examples /// @@ -370,6 +692,47 @@ /// assert_eq!(std::ptr::read(y), 12); /// } /// ``` +/// +/// Manually implement [`mem::swap`]: +/// +/// ``` +/// use std::ptr; +/// +/// fn swap(a: &mut T, b: &mut T) { +/// unsafe { +/// // Create a bitwise copy of the value at `a` in `tmp`. +/// let tmp = ptr::read(a); +/// +/// // Exiting at this point (either by explicitly returning or by +/// // calling a function which panics) would cause the value in `tmp` to +/// // be dropped while the same value is still referenced by `a`. This +/// // could trigger undefined behavior if `T` is not `Copy`. +/// +/// // Create a bitwise copy of the value at `b` in `a`. +/// // This is safe because mutable references cannot alias. +/// ptr::copy_nonoverlapping(b, a, 1); +/// +/// // As above, exiting here could trigger undefined behavior because +/// // the same value is referenced by `a` and `b`. +/// +/// // Move `tmp` into `b`. +/// ptr::write(b, tmp); +/// +/// // `tmp` has been moved (`write` takes ownership of its second argument), +/// // so nothing is dropped implicitly here. +/// } +/// } +/// +/// let mut foo = "foo".to_owned(); +/// let mut bar = "bar".to_owned(); +/// +/// swap(&mut foo, &mut bar); +/// +/// assert_eq!(foo, "bar"); +/// assert_eq!(bar, "foo"); +/// ``` +/// +/// [`mem::swap`]: ../mem/fn.swap.html #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn write(dst: *mut T, src: T) { @@ -379,35 +742,62 @@ /// Overwrites a memory location with the given value without reading or /// dropping the old value. /// -/// Unlike `write`, the pointer may be unaligned. -/// -/// # Safety -/// -/// This operation is marked unsafe because it accepts a raw pointer. +/// Unlike [`write`], the pointer may be unaligned. /// -/// It does not drop the contents of `dst`. This is safe, but it could leak -/// allocations or resources, so care must be taken not to overwrite an object -/// that should be dropped. +/// `write_unaligned` does not drop the contents of `dst`. This is safe, but it +/// could leak allocations or resources, so care should be taken not to overwrite +/// an object that should be dropped. /// /// Additionally, it does not drop `src`. Semantically, `src` is moved into the /// location pointed to by `dst`. /// /// This is appropriate for initializing uninitialized memory, or overwriting -/// memory that has previously been `read` from. +/// memory that has previously been read with [`read_unaligned`]. +/// +/// [`write`]: ./fn.write.html +/// [`read_unaligned`]: ./fn.read_unaligned.html +/// +/// # Safety +/// +/// Behavior is undefined if any of the following conditions are violated: +/// +/// * `dst` must be [valid] for writes. +/// +/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned. +/// +/// [valid]: ../ptr/index.html#safety /// /// # Examples /// -/// Basic usage: +/// Access fields in a packed struct: /// /// ``` -/// let mut x = 0; -/// let y = &mut x as *mut i32; -/// let z = 12; +/// use std::{mem, ptr}; +/// +/// #[repr(packed, C)] +/// #[derive(Default)] +/// struct Packed { +/// _padding: u8, +/// unaligned: u32, +/// } +/// +/// let v = 0x01020304; +/// let mut x: Packed = unsafe { mem::zeroed() }; /// /// unsafe { -/// std::ptr::write_unaligned(y, z); -/// assert_eq!(std::ptr::read_unaligned(y), 12); +/// // Take a reference to a 32-bit integer which is not aligned. +/// let unaligned = &mut x.unaligned as *mut u32; +/// +/// // Dereferencing normally will emit an aligned store instruction, +/// // causing undefined behavior because the pointer is not aligned. +/// // *unaligned = v; // ERROR +/// +/// // Instead, use `write_unaligned` to write improperly aligned values. +/// ptr::write_unaligned(unaligned, v); /// } +/// +/// // Accessing unaligned values directly is safe. +/// assert!(x.unaligned == v); /// ``` #[inline] #[stable(feature = "ptr_unaligned", since = "1.17.0")] @@ -425,6 +815,11 @@ /// to not be elided or reordered by the compiler across other volatile /// operations. /// +/// Memory accessed with `read_volatile` or [`write_volatile`] should not be +/// accessed with non-volatile operations. +/// +/// [`write_volatile`]: ./fn.write_volatile.html +/// /// # Notes /// /// Rust does not currently have a rigorously and formally defined memory model, @@ -441,12 +836,23 @@ /// /// # Safety /// -/// Beyond accepting a raw pointer, this is unsafe because it semantically -/// moves the value out of `src` without preventing further usage of `src`. -/// If `T` is not `Copy`, then care must be taken to ensure that the value at -/// `src` is not used before the data is overwritten again (e.g. with `write`, -/// `write_bytes`, or `copy`). Note that `*src = foo` counts as a use -/// because it will attempt to drop the value previously at `*src`. +/// Behavior is undefined if any of the following conditions are violated: +/// +/// * `src` must be [valid] for reads. +/// +/// * `src` must be properly aligned. +/// +/// Like [`read`], `read_unaligned` creates a bitwise copy of `T`, regardless of +/// whether `T` is [`Copy`]. If `T` is not [`Copy`], using both the returned +/// value and the value at `*src` can [violate memory safety][read-ownership]. +/// However, storing non-[`Copy`] types in volatile memory is almost certainly +/// incorrect. +/// +/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned. +/// +/// [valid]: ../ptr/index.html#safety +/// [`Copy`]: ../marker/trait.Copy.html +/// [`read`]: ./fn.read.html /// /// Just like in C, whether an operation is volatile has no bearing whatsoever /// on questions involving concurrent access from multiple threads. Volatile @@ -479,6 +885,18 @@ /// to not be elided or reordered by the compiler across other volatile /// operations. /// +/// Memory accessed with [`read_volatile`] or `write_volatile` should not be +/// accessed with non-volatile operations. +/// +/// `write_volatile` does not drop the contents of `dst`. This is safe, but it +/// could leak allocations or resources, so care should be taken not to overwrite +/// an object that should be dropped. +/// +/// Additionally, it does not drop `src`. Semantically, `src` is moved into the +/// location pointed to by `dst`. +/// +/// [`read_volatile`]: ./fn.read_volatile.html +/// /// # Notes /// /// Rust does not currently have a rigorously and formally defined memory model, @@ -495,14 +913,15 @@ /// /// # Safety /// -/// This operation is marked unsafe because it accepts a raw pointer. +/// Behavior is undefined if any of the following conditions are violated: /// -/// It does not drop the contents of `dst`. This is safe, but it could leak -/// allocations or resources, so care must be taken not to overwrite an object -/// that should be dropped. +/// * `dst` must be [valid] for writes. /// -/// This is appropriate for initializing uninitialized memory, or overwriting -/// memory that has previously been `read` from. +/// * `dst` must be properly aligned. +/// +/// Note that even if `T` has size `0`, the pointer must be non-NULL and properly aligned. +/// +/// [valid]: ../ptr/index.html#safety /// /// Just like in C, whether an operation is volatile has no bearing whatsoever /// on questions involving concurrent access from multiple threads. Volatile @@ -618,7 +1037,7 @@ /// Behavior: /// /// * Both the starting and resulting pointer must be either in bounds or one - /// byte past the end of *the same* allocated object. + /// byte past the end of the same allocated object. /// /// * The computed offset, **in bytes**, cannot overflow an `isize`. /// @@ -836,7 +1255,7 @@ /// Behavior: /// /// * Both the starting and resulting pointer must be either in bounds or one - /// byte past the end of an allocated object. + /// byte past the end of the same allocated object. /// /// * The computed offset, **in bytes**, cannot overflow an `isize`. /// @@ -893,7 +1312,7 @@ /// Behavior: /// /// * Both the starting and resulting pointer must be either in bounds or one - /// byte past the end of an allocated object. + /// byte past the end of the same allocated object. /// /// * The computed offset cannot exceed `isize::MAX` **bytes**. /// @@ -1023,29 +1442,9 @@ /// Reads the value from `self` without moving it. This leaves the /// memory in `self` unchanged. /// - /// # Safety - /// - /// Beyond accepting a raw pointer, this is unsafe because it semantically - /// moves the value out of `self` without preventing further usage of `self`. - /// If `T` is not `Copy`, then care must be taken to ensure that the value at - /// `self` is not used before the data is overwritten again (e.g. with `write`, - /// `write_bytes`, or `copy`). Note that `*self = foo` counts as a use - /// because it will attempt to drop the value previously at `*self`. - /// - /// The pointer must be aligned; use `read_unaligned` if that is not the case. + /// See [`ptr::read`] for safety concerns and examples. /// - /// # Examples - /// - /// Basic usage: - /// - /// ``` - /// let x = 12; - /// let y = &x as *const i32; - /// - /// unsafe { - /// assert_eq!(y.read(), 12); - /// } - /// ``` + /// [`ptr::read`]: ./ptr/fn.read.html #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn read(self) -> T @@ -1061,47 +1460,9 @@ /// to not be elided or reordered by the compiler across other volatile /// operations. /// - /// # Notes - /// - /// Rust does not currently have a rigorously and formally defined memory model, - /// so the precise semantics of what "volatile" means here is subject to change - /// over time. That being said, the semantics will almost always end up pretty - /// similar to [C11's definition of volatile][c11]. - /// - /// The compiler shouldn't change the relative order or number of volatile - /// memory operations. However, volatile memory operations on zero-sized types - /// (e.g. if a zero-sized type is passed to `read_volatile`) are no-ops - /// and may be ignored. - /// - /// [c11]: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf + /// See [`ptr::read_volatile`] for safety concerns and examples. /// - /// # Safety - /// - /// Beyond accepting a raw pointer, this is unsafe because it semantically - /// moves the value out of `self` without preventing further usage of `self`. - /// If `T` is not `Copy`, then care must be taken to ensure that the value at - /// `self` is not used before the data is overwritten again (e.g. with `write`, - /// `write_bytes`, or `copy`). Note that `*self = foo` counts as a use - /// because it will attempt to drop the value previously at `*self`. - /// - /// Just like in C, whether an operation is volatile has no bearing whatsoever - /// on questions involving concurrent access from multiple threads. Volatile - /// accesses behave exactly like non-atomic accesses in that regard. In particular, - /// a race between a `read_volatile` and any write operation to the same location - /// is undefined behavior. - /// - /// # Examples - /// - /// Basic usage: - /// - /// ``` - /// let x = 12; - /// let y = &x as *const i32; - /// - /// unsafe { - /// assert_eq!(y.read_volatile(), 12); - /// } - /// ``` + /// [`ptr::read_volatile`]: ./ptr/fn.read_volatile.html #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn read_volatile(self) -> T @@ -1115,27 +1476,9 @@ /// /// Unlike `read`, the pointer may be unaligned. /// - /// # Safety - /// - /// Beyond accepting a raw pointer, this is unsafe because it semantically - /// moves the value out of `self` without preventing further usage of `self`. - /// If `T` is not `Copy`, then care must be taken to ensure that the value at - /// `self` is not used before the data is overwritten again (e.g. with `write`, - /// `write_bytes`, or `copy`). Note that `*self = foo` counts as a use - /// because it will attempt to drop the value previously at `*self`. + /// See [`ptr::read_unaligned`] for safety concerns and examples. /// - /// # Examples - /// - /// Basic usage: - /// - /// ``` - /// let x = 12; - /// let y = &x as *const i32; - /// - /// unsafe { - /// assert_eq!(y.read_unaligned(), 12); - /// } - /// ``` + /// [`ptr::read_unaligned`]: ./ptr/fn.read_unaligned.html #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn read_unaligned(self) -> T @@ -1147,30 +1490,11 @@ /// Copies `count * size_of` bytes from `self` to `dest`. The source /// and destination may overlap. /// - /// NOTE: this has the *same* argument order as `ptr::copy`. - /// - /// This is semantically equivalent to C's `memmove`. - /// - /// # Safety - /// - /// Care must be taken with the ownership of `self` and `dest`. - /// This method semantically moves the values of `self` into `dest`. - /// However it does not drop the contents of `dest`, or prevent the contents - /// of `self` from being dropped or used. - /// - /// # Examples + /// NOTE: this has the *same* argument order as [`ptr::copy`]. /// - /// Efficiently create a Rust vector from an unsafe buffer: + /// See [`ptr::copy`] for safety concerns and examples. /// - /// ``` - /// # #[allow(dead_code)] - /// unsafe fn from_buf_raw(ptr: *const T, elts: usize) -> Vec { - /// let mut dst = Vec::with_capacity(elts); - /// dst.set_len(elts); - /// ptr.copy_to(dst.as_mut_ptr(), elts); - /// dst - /// } - /// ``` + /// [`ptr::copy`]: ./ptr/fn.copy.html #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn copy_to(self, dest: *mut T, count: usize) @@ -1182,32 +1506,11 @@ /// Copies `count * size_of` bytes from `self` to `dest`. The source /// and destination may *not* overlap. /// - /// NOTE: this has the *same* argument order as `ptr::copy_nonoverlapping`. - /// - /// `copy_nonoverlapping` is semantically equivalent to C's `memcpy`. + /// NOTE: this has the *same* argument order as [`ptr::copy_nonoverlapping`]. /// - /// # Safety + /// See [`ptr::copy_nonoverlapping`] for safety concerns and examples. /// - /// Beyond requiring that the program must be allowed to access both regions - /// of memory, it is Undefined Behavior for source and destination to - /// overlap. Care must also be taken with the ownership of `self` and - /// `self`. This method semantically moves the values of `self` into `dest`. - /// However it does not drop the contents of `dest`, or prevent the contents - /// of `self` from being dropped or used. - /// - /// # Examples - /// - /// Efficiently create a Rust vector from an unsafe buffer: - /// - /// ``` - /// # #[allow(dead_code)] - /// unsafe fn from_buf_raw(ptr: *const T, elts: usize) -> Vec { - /// let mut dst = Vec::with_capacity(elts); - /// dst.set_len(elts); - /// ptr.copy_to_nonoverlapping(dst.as_mut_ptr(), elts); - /// dst - /// } - /// ``` + /// [`ptr::copy_nonoverlapping`]: ./ptr/fn.copy_nonoverlapping.html #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize) @@ -1354,7 +1657,7 @@ /// Behavior: /// /// * Both the starting and resulting pointer must be either in bounds or one - /// byte past the end of *the same* allocated object. + /// byte past the end of the same allocated object. /// /// * The computed offset, **in bytes**, cannot overflow an `isize`. /// @@ -1590,7 +1893,7 @@ /// Behavior: /// /// * Both the starting and resulting pointer must be either in bounds or one - /// byte past the end of an allocated object. + /// byte past the end of the same allocated object. /// /// * The computed offset, **in bytes**, cannot overflow an `isize`. /// @@ -1647,7 +1950,7 @@ /// Behavior: /// /// * Both the starting and resulting pointer must be either in bounds or one - /// byte past the end of an allocated object. + /// byte past the end of the same allocated object. /// /// * The computed offset cannot exceed `isize::MAX` **bytes**. /// @@ -1777,29 +2080,9 @@ /// Reads the value from `self` without moving it. This leaves the /// memory in `self` unchanged. /// - /// # Safety - /// - /// Beyond accepting a raw pointer, this is unsafe because it semantically - /// moves the value out of `self` without preventing further usage of `self`. - /// If `T` is not `Copy`, then care must be taken to ensure that the value at - /// `self` is not used before the data is overwritten again (e.g. with `write`, - /// `write_bytes`, or `copy`). Note that `*self = foo` counts as a use - /// because it will attempt to drop the value previously at `*self`. - /// - /// The pointer must be aligned; use `read_unaligned` if that is not the case. - /// - /// # Examples - /// - /// Basic usage: - /// - /// ``` - /// let x = 12; - /// let y = &x as *const i32; + /// See [`ptr::read`] for safety concerns and examples. /// - /// unsafe { - /// assert_eq!(y.read(), 12); - /// } - /// ``` + /// [`ptr::read`]: ./ptr/fn.read.html #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn read(self) -> T @@ -1815,47 +2098,9 @@ /// to not be elided or reordered by the compiler across other volatile /// operations. /// - /// # Notes - /// - /// Rust does not currently have a rigorously and formally defined memory model, - /// so the precise semantics of what "volatile" means here is subject to change - /// over time. That being said, the semantics will almost always end up pretty - /// similar to [C11's definition of volatile][c11]. - /// - /// The compiler shouldn't change the relative order or number of volatile - /// memory operations. However, volatile memory operations on zero-sized types - /// (e.g. if a zero-sized type is passed to `read_volatile`) are no-ops - /// and may be ignored. - /// - /// [c11]: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf - /// - /// # Safety - /// - /// Beyond accepting a raw pointer, this is unsafe because it semantically - /// moves the value out of `self` without preventing further usage of `self`. - /// If `T` is not `Copy`, then care must be taken to ensure that the value at - /// `self` is not used before the data is overwritten again (e.g. with `write`, - /// `write_bytes`, or `copy`). Note that `*self = foo` counts as a use - /// because it will attempt to drop the value previously at `*self`. - /// - /// Just like in C, whether an operation is volatile has no bearing whatsoever - /// on questions involving concurrent access from multiple threads. Volatile - /// accesses behave exactly like non-atomic accesses in that regard. In particular, - /// a race between a `read_volatile` and any write operation to the same location - /// is undefined behavior. - /// - /// # Examples - /// - /// Basic usage: - /// - /// ``` - /// let x = 12; - /// let y = &x as *const i32; + /// See [`ptr::read_volatile`] for safety concerns and examples. /// - /// unsafe { - /// assert_eq!(y.read_volatile(), 12); - /// } - /// ``` + /// [`ptr::read_volatile`]: ./ptr/fn.read_volatile.html #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn read_volatile(self) -> T @@ -1869,27 +2114,9 @@ /// /// Unlike `read`, the pointer may be unaligned. /// - /// # Safety - /// - /// Beyond accepting a raw pointer, this is unsafe because it semantically - /// moves the value out of `self` without preventing further usage of `self`. - /// If `T` is not `Copy`, then care must be taken to ensure that the value at - /// `self` is not used before the data is overwritten again (e.g. with `write`, - /// `write_bytes`, or `copy`). Note that `*self = foo` counts as a use - /// because it will attempt to drop the value previously at `*self`. - /// - /// # Examples - /// - /// Basic usage: + /// See [`ptr::read_unaligned`] for safety concerns and examples. /// - /// ``` - /// let x = 12; - /// let y = &x as *const i32; - /// - /// unsafe { - /// assert_eq!(y.read_unaligned(), 12); - /// } - /// ``` + /// [`ptr::read_unaligned`]: ./ptr/fn.read_unaligned.html #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn read_unaligned(self) -> T @@ -1901,30 +2128,11 @@ /// Copies `count * size_of` bytes from `self` to `dest`. The source /// and destination may overlap. /// - /// NOTE: this has the *same* argument order as `ptr::copy`. - /// - /// This is semantically equivalent to C's `memmove`. + /// NOTE: this has the *same* argument order as [`ptr::copy`]. /// - /// # Safety - /// - /// Care must be taken with the ownership of `self` and `dest`. - /// This method semantically moves the values of `self` into `dest`. - /// However it does not drop the contents of `self`, or prevent the contents - /// of `dest` from being dropped or used. + /// See [`ptr::copy`] for safety concerns and examples. /// - /// # Examples - /// - /// Efficiently create a Rust vector from an unsafe buffer: - /// - /// ``` - /// # #[allow(dead_code)] - /// unsafe fn from_buf_raw(ptr: *const T, elts: usize) -> Vec { - /// let mut dst = Vec::with_capacity(elts); - /// dst.set_len(elts); - /// ptr.copy_to(dst.as_mut_ptr(), elts); - /// dst - /// } - /// ``` + /// [`ptr::copy`]: ./ptr/fn.copy.html #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn copy_to(self, dest: *mut T, count: usize) @@ -1936,32 +2144,11 @@ /// Copies `count * size_of` bytes from `self` to `dest`. The source /// and destination may *not* overlap. /// - /// NOTE: this has the *same* argument order as `ptr::copy_nonoverlapping`. + /// NOTE: this has the *same* argument order as [`ptr::copy_nonoverlapping`]. /// - /// `copy_nonoverlapping` is semantically equivalent to C's `memcpy`. + /// See [`ptr::copy_nonoverlapping`] for safety concerns and examples. /// - /// # Safety - /// - /// Beyond requiring that the program must be allowed to access both regions - /// of memory, it is Undefined Behavior for source and destination to - /// overlap. Care must also be taken with the ownership of `self` and - /// `self`. This method semantically moves the values of `self` into `dest`. - /// However it does not drop the contents of `dest`, or prevent the contents - /// of `self` from being dropped or used. - /// - /// # Examples - /// - /// Efficiently create a Rust vector from an unsafe buffer: - /// - /// ``` - /// # #[allow(dead_code)] - /// unsafe fn from_buf_raw(ptr: *const T, elts: usize) -> Vec { - /// let mut dst = Vec::with_capacity(elts); - /// dst.set_len(elts); - /// ptr.copy_to_nonoverlapping(dst.as_mut_ptr(), elts); - /// dst - /// } - /// ``` + /// [`ptr::copy_nonoverlapping`]: ./ptr/fn.copy_nonoverlapping.html #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize) @@ -1973,30 +2160,11 @@ /// Copies `count * size_of` bytes from `src` to `self`. The source /// and destination may overlap. /// - /// NOTE: this has the *opposite* argument order of `ptr::copy`. - /// - /// This is semantically equivalent to C's `memmove`. - /// - /// # Safety + /// NOTE: this has the *opposite* argument order of [`ptr::copy`]. /// - /// Care must be taken with the ownership of `src` and `self`. - /// This method semantically moves the values of `src` into `self`. - /// However it does not drop the contents of `self`, or prevent the contents - /// of `src` from being dropped or used. + /// See [`ptr::copy`] for safety concerns and examples. /// - /// # Examples - /// - /// Efficiently create a Rust vector from an unsafe buffer: - /// - /// ``` - /// # #[allow(dead_code)] - /// unsafe fn from_buf_raw(ptr: *const T, elts: usize) -> Vec { - /// let mut dst: Vec = Vec::with_capacity(elts); - /// dst.set_len(elts); - /// dst.as_mut_ptr().copy_from(ptr, elts); - /// dst - /// } - /// ``` + /// [`ptr::copy`]: ./ptr/fn.copy.html #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn copy_from(self, src: *const T, count: usize) @@ -2008,32 +2176,11 @@ /// Copies `count * size_of` bytes from `src` to `self`. The source /// and destination may *not* overlap. /// - /// NOTE: this has the *opposite* argument order of `ptr::copy_nonoverlapping`. - /// - /// `copy_nonoverlapping` is semantically equivalent to C's `memcpy`. - /// - /// # Safety - /// - /// Beyond requiring that the program must be allowed to access both regions - /// of memory, it is Undefined Behavior for source and destination to - /// overlap. Care must also be taken with the ownership of `src` and - /// `self`. This method semantically moves the values of `src` into `self`. - /// However it does not drop the contents of `self`, or prevent the contents - /// of `src` from being dropped or used. - /// - /// # Examples + /// NOTE: this has the *opposite* argument order of [`ptr::copy_nonoverlapping`]. /// - /// Efficiently create a Rust vector from an unsafe buffer: + /// See [`ptr::copy_nonoverlapping`] for safety concerns and examples. /// - /// ``` - /// # #[allow(dead_code)] - /// unsafe fn from_buf_raw(ptr: *const T, elts: usize) -> Vec { - /// let mut dst: Vec = Vec::with_capacity(elts); - /// dst.set_len(elts); - /// dst.as_mut_ptr().copy_from_nonoverlapping(ptr, elts); - /// dst - /// } - /// ``` + /// [`ptr::copy_nonoverlapping`]: ./ptr/fn.copy_nonoverlapping.html #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn copy_from_nonoverlapping(self, src: *const T, count: usize) @@ -2044,21 +2191,9 @@ /// Executes the destructor (if any) of the pointed-to value. /// - /// This has two use cases: - /// - /// * It is *required* to use `drop_in_place` to drop unsized types like - /// trait objects, because they can't be read out onto the stack and - /// dropped normally. - /// - /// * It is friendlier to the optimizer to do this over `ptr::read` when - /// dropping manually allocated memory (e.g. when writing Box/Rc/Vec), - /// as the compiler doesn't need to prove that it's sound to elide the - /// copy. - /// - /// # Safety + /// See [`ptr::drop_in_place`] for safety concerns and examples. /// - /// This has all the same safety problems as `ptr::read` with respect to - /// invalid pointers, types, and double drops. + /// [`ptr::drop_in_place`]: ./ptr/fn.drop_in_place.html #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn drop_in_place(self) { @@ -2068,36 +2203,9 @@ /// Overwrites a memory location with the given value without reading or /// dropping the old value. /// - /// # Safety - /// - /// This operation is marked unsafe because it writes through a raw pointer. - /// - /// It does not drop the contents of `self`. This is safe, but it could leak - /// allocations or resources, so care must be taken not to overwrite an object - /// that should be dropped. - /// - /// Additionally, it does not drop `val`. Semantically, `val` is moved into the - /// location pointed to by `self`. - /// - /// This is appropriate for initializing uninitialized memory, or overwriting - /// memory that has previously been `read` from. + /// See [`ptr::write`] for safety concerns and examples. /// - /// The pointer must be aligned; use `write_unaligned` if that is not the case. - /// - /// # Examples - /// - /// Basic usage: - /// - /// ``` - /// let mut x = 0; - /// let y = &mut x as *mut i32; - /// let z = 12; - /// - /// unsafe { - /// y.write(z); - /// assert_eq!(y.read(), 12); - /// } - /// ``` + /// [`ptr::write`]: ./ptr/fn.write.html #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn write(self, val: T) @@ -2109,16 +2217,9 @@ /// Invokes memset on the specified pointer, setting `count * size_of::()` /// bytes of memory starting at `self` to `val`. /// - /// # Examples + /// See [`ptr::write_bytes`] for safety concerns and examples. /// - /// ``` - /// let mut vec = vec![0; 4]; - /// unsafe { - /// let vec_ptr = vec.as_mut_ptr(); - /// vec_ptr.write_bytes(b'a', 2); - /// } - /// assert_eq!(vec, [b'a', b'a', 0, 0]); - /// ``` + /// [`ptr::write_bytes`]: ./ptr/fn.write_bytes.html #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn write_bytes(self, val: u8, count: usize) @@ -2134,51 +2235,9 @@ /// to not be elided or reordered by the compiler across other volatile /// operations. /// - /// # Notes - /// - /// Rust does not currently have a rigorously and formally defined memory model, - /// so the precise semantics of what "volatile" means here is subject to change - /// over time. That being said, the semantics will almost always end up pretty - /// similar to [C11's definition of volatile][c11]. - /// - /// The compiler shouldn't change the relative order or number of volatile - /// memory operations. However, volatile memory operations on zero-sized types - /// (e.g. if a zero-sized type is passed to `write_volatile`) are no-ops - /// and may be ignored. - /// - /// [c11]: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf - /// - /// # Safety - /// - /// This operation is marked unsafe because it accepts a raw pointer. - /// - /// It does not drop the contents of `self`. This is safe, but it could leak - /// allocations or resources, so care must be taken not to overwrite an object - /// that should be dropped. - /// - /// This is appropriate for initializing uninitialized memory, or overwriting - /// memory that has previously been `read` from. - /// - /// Just like in C, whether an operation is volatile has no bearing whatsoever - /// on questions involving concurrent access from multiple threads. Volatile - /// accesses behave exactly like non-atomic accesses in that regard. In particular, - /// a race between a `write_volatile` and any other operation (reading or writing) - /// on the same location is undefined behavior. + /// See [`ptr::write_volatile`] for safety concerns and examples. /// - /// # Examples - /// - /// Basic usage: - /// - /// ``` - /// let mut x = 0; - /// let y = &mut x as *mut i32; - /// let z = 12; - /// - /// unsafe { - /// y.write_volatile(z); - /// assert_eq!(y.read_volatile(), 12); - /// } - /// ``` + /// [`ptr::write_volatile`]: ./ptr/fn.write_volatile.html #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn write_volatile(self, val: T) @@ -2192,34 +2251,9 @@ /// /// Unlike `write`, the pointer may be unaligned. /// - /// # Safety - /// - /// This operation is marked unsafe because it writes through a raw pointer. + /// See [`ptr::write_unaligned`] for safety concerns and examples. /// - /// It does not drop the contents of `self`. This is safe, but it could leak - /// allocations or resources, so care must be taken not to overwrite an object - /// that should be dropped. - /// - /// Additionally, it does not drop `self`. Semantically, `self` is moved into the - /// location pointed to by `val`. - /// - /// This is appropriate for initializing uninitialized memory, or overwriting - /// memory that has previously been `read` from. - /// - /// # Examples - /// - /// Basic usage: - /// - /// ``` - /// let mut x = 0; - /// let y = &mut x as *mut i32; - /// let z = 12; - /// - /// unsafe { - /// y.write_unaligned(z); - /// assert_eq!(y.read_unaligned(), 12); - /// } - /// ``` + /// [`ptr::write_unaligned`]: ./ptr/fn.write_unaligned.html #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn write_unaligned(self, val: T) @@ -2231,10 +2265,9 @@ /// Replaces the value at `self` with `src`, returning the old /// value, without dropping either. /// - /// # Safety + /// See [`ptr::replace`] for safety concerns and examples. /// - /// This is only unsafe because it accepts a raw pointer. - /// Otherwise, this operation is identical to `mem::replace`. + /// [`ptr::replace`]: ./ptr/fn.replace.html #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn replace(self, src: T) -> T @@ -2247,12 +2280,9 @@ /// deinitializing either. They may overlap, unlike `mem::swap` which is /// otherwise equivalent. /// - /// # Safety - /// - /// This function copies the memory through the raw pointers passed to it - /// as arguments. + /// See [`ptr::swap`] for safety concerns and examples. /// - /// Ensure that these pointers are valid before calling `swap`. + /// [`ptr::swap`]: ./ptr/fn.swap.html #[stable(feature = "pointer_methods", since = "1.26.0")] #[inline] pub unsafe fn swap(self, with: *mut T) @@ -2340,13 +2370,13 @@ /// /// Note, that this table does not contain values where inverse does not exist (i.e. for /// `0⁻¹ mod 16`, `2⁻¹ mod 16`, etc.) - const INV_TABLE_MOD_16: [usize; 8] = [1, 11, 13, 7, 9, 3, 5, 15]; + const INV_TABLE_MOD_16: [u8; 8] = [1, 11, 13, 7, 9, 3, 5, 15]; /// Modulo for which the `INV_TABLE_MOD_16` is intended. const INV_TABLE_MOD: usize = 16; /// INV_TABLE_MOD² const INV_TABLE_MOD_SQUARED: usize = INV_TABLE_MOD * INV_TABLE_MOD; - let table_inverse = INV_TABLE_MOD_16[(x & (INV_TABLE_MOD - 1)) >> 1]; + let table_inverse = INV_TABLE_MOD_16[(x & (INV_TABLE_MOD - 1)) >> 1] as usize; if m <= INV_TABLE_MOD { table_inverse & (m - 1) } else { @@ -2399,36 +2429,23 @@ let gcdpow = intrinsics::cttz_nonzero(stride).min(intrinsics::cttz_nonzero(a)); let gcd = 1usize << gcdpow; - if gcd == 1 { - // This branch solves for the variable $o$ in following linear congruence equation: - // - // ⎰ p + o ≡ 0 (mod a) # $p + o$ must be aligned to specified alignment $a$ - // ⎱ o ≡ 0 (mod s) # offset $o$ must be a multiple of stride $s$ - // - // where + if p as usize & (gcd - 1) == 0 { + // This branch solves for the following linear congruence equation: // - // * a, s are co-prime + // $$ p + so ≡ 0 mod a $$ // - // This gives us the formula below: + // $p$ here is the pointer value, $s$ – stride of `T`, $o$ offset in `T`s, and $a$ – the + // requested alignment. // - // o = (a - (p mod a)) * (s⁻¹ mod a) * s + // g = gcd(a, s) + // o = (a - (p mod a))/g * ((s/g)⁻¹ mod a) // // The first term is “the relative alignment of p to a”, the second term is “how does - // incrementing p by one s change the relative alignment of p”, the third term is - // translating change in units of s to a byte count. + // incrementing p by s bytes change the relative alignment of p”. Division by `g` is + // necessary to make this equation well formed if $a$ and $s$ are not co-prime. // // Furthermore, the result produced by this solution is not “minimal”, so it is necessary - // to take the result $o mod lcm(s, a)$. Since $s$ and $a$ are co-prime (i.e. $gcd(s, a) = - // 1$) and $lcm(s, a) = s * a / gcd(s, a)$, we can replace $lcm(s, a)$ with just a $s * a$. - // - // (Author note: we decided later on to express the offset in "elements" rather than bytes, - // which drops the multiplication by `s` on both sides of the modulo.) - return intrinsics::unchecked_rem(a.wrapping_sub(pmoda).wrapping_mul(mod_inv(smoda, a)), a); - } - - if p as usize & (gcd - 1) == 0 { - // This can be aligned, but `a` and `stride` are not co-prime, so a somewhat adapted - // formula is used. + // to take the result $o mod lcm(s, a)$. We can replace $lcm(s, a)$ with just a $a / g$. let j = a.wrapping_sub(pmoda) >> gcdpow; let k = smoda >> gcdpow; return intrinsics::unchecked_rem(j.wrapping_mul(mod_inv(k, a)), a >> gcdpow); diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/raw.rs rustc-1.31.0+dfsg1+llvm/src/libcore/raw.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/raw.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/raw.rs 2018-12-04 23:41:40.000000000 +0000 @@ -21,11 +21,7 @@ /// The representation of a trait object like `&SomeTrait`. /// /// This struct has the same layout as types like `&SomeTrait` and -/// `Box`. The [Trait Objects chapter of the -/// Book][moreinfo] contains more details about the precise nature of -/// these internals. -/// -/// [moreinfo]: ../../book/first-edition/trait-objects.html#representation +/// `Box`. /// /// `TraitObject` is guaranteed to match layouts, but it is not the /// type of trait objects (e.g. the fields are not directly accessible diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/result.rs rustc-1.31.0+dfsg1+llvm/src/libcore/result.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/result.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/result.rs 2018-12-04 23:41:40.000000000 +0000 @@ -1098,18 +1098,18 @@ } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> ExactSizeIterator for Iter<'a, T> {} +impl ExactSizeIterator for Iter<'_, T> {} #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T> FusedIterator for Iter<'a, T> {} +impl FusedIterator for Iter<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, A> TrustedLen for Iter<'a, A> {} +unsafe impl TrustedLen for Iter<'_, A> {} #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> Clone for Iter<'a, T> { +impl Clone for Iter<'_, T> { #[inline] - fn clone(&self) -> Iter<'a, T> { Iter { inner: self.inner } } + fn clone(&self) -> Self { Iter { inner: self.inner } } } /// An iterator over a mutable reference to the [`Ok`] variant of a [`Result`]. @@ -1143,13 +1143,13 @@ } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> ExactSizeIterator for IterMut<'a, T> {} +impl ExactSizeIterator for IterMut<'_, T> {} #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T> FusedIterator for IterMut<'a, T> {} +impl FusedIterator for IterMut<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, A> TrustedLen for IterMut<'a, A> {} +unsafe impl TrustedLen for IterMut<'_, A> {} /// An iterator over the value in a [`Ok`] variant of a [`Result`]. /// diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/slice/mod.rs rustc-1.31.0+dfsg1+llvm/src/libcore/slice/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/slice/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/slice/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -34,6 +34,7 @@ use cmp; use fmt; use intrinsics::assume; +use isize; use iter::*; use ops::{FnMut, Try, self}; use option::Option; @@ -119,7 +120,7 @@ #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn first(&self) -> Option<&T> { - if self.is_empty() { None } else { Some(&self[0]) } + self.get(0) } /// Returns a mutable pointer to the first element of the slice, or `None` if it is empty. @@ -137,7 +138,7 @@ #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn first_mut(&mut self) -> Option<&mut T> { - if self.is_empty() { None } else { Some(&mut self[0]) } + self.get_mut(0) } /// Returns the first and all the rest of the elements of the slice, or `None` if it is empty. @@ -239,7 +240,8 @@ #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn last(&self) -> Option<&T> { - if self.is_empty() { None } else { Some(&self[self.len() - 1]) } + let last_idx = self.len().checked_sub(1)?; + self.get(last_idx) } /// Returns a mutable pointer to the last item in the slice. @@ -257,9 +259,8 @@ #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn last_mut(&mut self) -> Option<&mut T> { - let len = self.len(); - if len == 0 { return None; } - Some(&mut self[len - 1]) + let last_idx = self.len().checked_sub(1)?; + self.get_mut(last_idx) } /// Returns a reference to an element or subslice depending on the type of @@ -619,13 +620,15 @@ Windows { v: self, size } } - /// Returns an iterator over `chunk_size` elements of the slice at a - /// time. The chunks are slices and do not overlap. If `chunk_size` does - /// not divide the length of the slice, then the last chunk will - /// not have length `chunk_size`. + /// Returns an iterator over `chunk_size` elements of the slice at a time, starting at the + /// beginning of the slice. + /// + /// The chunks are slices and do not overlap. If `chunk_size` does not divide the length of the + /// slice, then the last chunk will not have length `chunk_size`. /// - /// See [`exact_chunks`] for a variant of this iterator that returns chunks - /// of always exactly `chunk_size` elements. + /// See [`chunks_exact`] for a variant of this iterator that returns chunks of always exactly + /// `chunk_size` elements, and [`rchunks`] for the same iterator but starting at the end of the + /// slice of the slice. /// /// # Panics /// @@ -642,7 +645,8 @@ /// assert!(iter.next().is_none()); /// ``` /// - /// [`exact_chunks`]: #method.exact_chunks + /// [`chunks_exact`]: #method.chunks_exact + /// [`rchunks`]: #method.rchunks #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn chunks(&self, chunk_size: usize) -> Chunks { @@ -650,13 +654,15 @@ Chunks { v: self, chunk_size } } - /// Returns an iterator over `chunk_size` elements of the slice at a time. - /// The chunks are mutable slices, and do not overlap. If `chunk_size` does - /// not divide the length of the slice, then the last chunk will not - /// have length `chunk_size`. + /// Returns an iterator over `chunk_size` elements of the slice at a time, starting at the + /// beginning of the slice. /// - /// See [`exact_chunks_mut`] for a variant of this iterator that returns chunks - /// of always exactly `chunk_size` elements. + /// The chunks are mutable slices, and do not overlap. If `chunk_size` does not divide the + /// length of the slice, then the last chunk will not have length `chunk_size`. + /// + /// See [`chunks_exact_mut`] for a variant of this iterator that returns chunks of always + /// exactly `chunk_size` elements, and [`rchunks_mut`] for the same iterator but starting at + /// the end of the slice of the slice. /// /// # Panics /// @@ -677,7 +683,8 @@ /// assert_eq!(v, &[1, 1, 2, 2, 3]); /// ``` /// - /// [`exact_chunks_mut`]: #method.exact_chunks_mut + /// [`chunks_exact_mut`]: #method.chunks_exact_mut + /// [`rchunks_mut`]: #method.rchunks_mut #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut { @@ -685,15 +692,19 @@ ChunksMut { v: self, chunk_size } } - /// Returns an iterator over `chunk_size` elements of the slice at a - /// time. The chunks are slices and do not overlap. If `chunk_size` does - /// not divide the length of the slice, then the last up to `chunk_size-1` - /// elements will be omitted and can be retrieved from the `remainder` - /// function of the iterator. - /// - /// Due to each chunk having exactly `chunk_size` elements, the compiler - /// can often optimize the resulting code better than in the case of - /// [`chunks`]. + /// Returns an iterator over `chunk_size` elements of the slice at a time, starting at the + /// beginning of the slice. + /// + /// The chunks are slices and do not overlap. If `chunk_size` does not divide the length of the + /// slice, then the last up to `chunk_size-1` elements will be omitted and can be retrieved + /// from the `remainder` function of the iterator. + /// + /// Due to each chunk having exactly `chunk_size` elements, the compiler can often optimize the + /// resulting code better than in the case of [`chunks`]. + /// + /// See [`chunks`] for a variant of this iterator that also returns the remainder as a smaller + /// chunk, and [`rchunks_exact`] for the same iterator but starting at the end of the slice of + /// the slice. /// /// # Panics /// @@ -702,35 +713,39 @@ /// # Examples /// /// ``` - /// #![feature(exact_chunks)] - /// /// let slice = ['l', 'o', 'r', 'e', 'm']; - /// let mut iter = slice.exact_chunks(2); + /// let mut iter = slice.chunks_exact(2); /// assert_eq!(iter.next().unwrap(), &['l', 'o']); /// assert_eq!(iter.next().unwrap(), &['r', 'e']); /// assert!(iter.next().is_none()); + /// assert_eq!(iter.remainder(), &['m']); /// ``` /// /// [`chunks`]: #method.chunks - #[unstable(feature = "exact_chunks", issue = "47115")] + /// [`rchunks_exact`]: #method.rchunks_exact + #[stable(feature = "chunks_exact", since = "1.31.0")] #[inline] - pub fn exact_chunks(&self, chunk_size: usize) -> ExactChunks { + pub fn chunks_exact(&self, chunk_size: usize) -> ChunksExact { assert!(chunk_size != 0); let rem = self.len() % chunk_size; let len = self.len() - rem; let (fst, snd) = self.split_at(len); - ExactChunks { v: fst, rem: snd, chunk_size } + ChunksExact { v: fst, rem: snd, chunk_size } } - /// Returns an iterator over `chunk_size` elements of the slice at a time. - /// The chunks are mutable slices, and do not overlap. If `chunk_size` does - /// not divide the length of the slice, then the last up to `chunk_size-1` - /// elements will be omitted and can be retrieved from the `into_remainder` - /// function of the iterator. - /// - /// Due to each chunk having exactly `chunk_size` elements, the compiler - /// can often optimize the resulting code better than in the case of - /// [`chunks_mut`]. + /// Returns an iterator over `chunk_size` elements of the slice at a time, starting at the + /// beginning of the slice. + /// + /// The chunks are mutable slices, and do not overlap. If `chunk_size` does not divide the + /// length of the slice, then the last up to `chunk_size-1` elements will be omitted and can be + /// retrieved from the `into_remainder` function of the iterator. + /// + /// Due to each chunk having exactly `chunk_size` elements, the compiler can often optimize the + /// resulting code better than in the case of [`chunks_mut`]. + /// + /// See [`chunks_mut`] for a variant of this iterator that also returns the remainder as a + /// smaller chunk, and [`rchunks_exact_mut`] for the same iterator but starting at the end of + /// the slice of the slice. /// /// # Panics /// @@ -739,12 +754,10 @@ /// # Examples /// /// ``` - /// #![feature(exact_chunks)] - /// /// let v = &mut [0, 0, 0, 0, 0]; /// let mut count = 1; /// - /// for chunk in v.exact_chunks_mut(2) { + /// for chunk in v.chunks_exact_mut(2) { /// for elem in chunk.iter_mut() { /// *elem += count; /// } @@ -754,14 +767,171 @@ /// ``` /// /// [`chunks_mut`]: #method.chunks_mut - #[unstable(feature = "exact_chunks", issue = "47115")] + /// [`rchunks_exact_mut`]: #method.rchunks_exact_mut + #[stable(feature = "chunks_exact", since = "1.31.0")] #[inline] - pub fn exact_chunks_mut(&mut self, chunk_size: usize) -> ExactChunksMut { + pub fn chunks_exact_mut(&mut self, chunk_size: usize) -> ChunksExactMut { assert!(chunk_size != 0); let rem = self.len() % chunk_size; let len = self.len() - rem; let (fst, snd) = self.split_at_mut(len); - ExactChunksMut { v: fst, rem: snd, chunk_size } + ChunksExactMut { v: fst, rem: snd, chunk_size } + } + + /// Returns an iterator over `chunk_size` elements of the slice at a time, starting at the end + /// of the slice. + /// + /// The chunks are slices and do not overlap. If `chunk_size` does not divide the length of the + /// slice, then the last chunk will not have length `chunk_size`. + /// + /// See [`rchunks_exact`] for a variant of this iterator that returns chunks of always exactly + /// `chunk_size` elements, and [`chunks`] for the same iterator but starting at the beginning + /// of the slice. + /// + /// # Panics + /// + /// Panics if `chunk_size` is 0. + /// + /// # Examples + /// + /// ``` + /// let slice = ['l', 'o', 'r', 'e', 'm']; + /// let mut iter = slice.rchunks(2); + /// assert_eq!(iter.next().unwrap(), &['e', 'm']); + /// assert_eq!(iter.next().unwrap(), &['o', 'r']); + /// assert_eq!(iter.next().unwrap(), &['l']); + /// assert!(iter.next().is_none()); + /// ``` + /// + /// [`rchunks_exact`]: #method.rchunks_exact + /// [`chunks`]: #method.chunks + #[stable(feature = "rchunks", since = "1.31.0")] + #[inline] + pub fn rchunks(&self, chunk_size: usize) -> RChunks { + assert!(chunk_size != 0); + RChunks { v: self, chunk_size } + } + + /// Returns an iterator over `chunk_size` elements of the slice at a time, starting at the end + /// of the slice. + /// + /// The chunks are mutable slices, and do not overlap. If `chunk_size` does not divide the + /// length of the slice, then the last chunk will not have length `chunk_size`. + /// + /// See [`rchunks_exact_mut`] for a variant of this iterator that returns chunks of always + /// exactly `chunk_size` elements, and [`chunks_mut`] for the same iterator but starting at the + /// beginning of the slice. + /// + /// # Panics + /// + /// Panics if `chunk_size` is 0. + /// + /// # Examples + /// + /// ``` + /// let v = &mut [0, 0, 0, 0, 0]; + /// let mut count = 1; + /// + /// for chunk in v.rchunks_mut(2) { + /// for elem in chunk.iter_mut() { + /// *elem += count; + /// } + /// count += 1; + /// } + /// assert_eq!(v, &[3, 2, 2, 1, 1]); + /// ``` + /// + /// [`rchunks_exact_mut`]: #method.rchunks_exact_mut + /// [`chunks_mut`]: #method.chunks_mut + #[stable(feature = "rchunks", since = "1.31.0")] + #[inline] + pub fn rchunks_mut(&mut self, chunk_size: usize) -> RChunksMut { + assert!(chunk_size != 0); + RChunksMut { v: self, chunk_size } + } + + /// Returns an iterator over `chunk_size` elements of the slice at a time, starting at the + /// beginning of the slice. + /// + /// The chunks are slices and do not overlap. If `chunk_size` does not divide the length of the + /// slice, then the last up to `chunk_size-1` elements will be omitted and can be retrieved + /// from the `remainder` function of the iterator. + /// + /// Due to each chunk having exactly `chunk_size` elements, the compiler can often optimize the + /// resulting code better than in the case of [`chunks`]. + /// + /// See [`rchunks`] for a variant of this iterator that also returns the remainder as a smaller + /// chunk, and [`chunks_exact`] for the same iterator but starting at the beginning of the + /// slice of the slice. + /// + /// # Panics + /// + /// Panics if `chunk_size` is 0. + /// + /// # Examples + /// + /// ``` + /// let slice = ['l', 'o', 'r', 'e', 'm']; + /// let mut iter = slice.rchunks_exact(2); + /// assert_eq!(iter.next().unwrap(), &['e', 'm']); + /// assert_eq!(iter.next().unwrap(), &['o', 'r']); + /// assert!(iter.next().is_none()); + /// assert_eq!(iter.remainder(), &['l']); + /// ``` + /// + /// [`rchunks`]: #method.rchunks + /// [`chunks_exact`]: #method.chunks_exact + #[stable(feature = "rchunks", since = "1.31.0")] + #[inline] + pub fn rchunks_exact(&self, chunk_size: usize) -> RChunksExact { + assert!(chunk_size != 0); + let rem = self.len() % chunk_size; + let (fst, snd) = self.split_at(rem); + RChunksExact { v: snd, rem: fst, chunk_size } + } + + /// Returns an iterator over `chunk_size` elements of the slice at a time, starting at the end + /// of the slice. + /// + /// The chunks are mutable slices, and do not overlap. If `chunk_size` does not divide the + /// length of the slice, then the last up to `chunk_size-1` elements will be omitted and can be + /// retrieved from the `into_remainder` function of the iterator. + /// + /// Due to each chunk having exactly `chunk_size` elements, the compiler can often optimize the + /// resulting code better than in the case of [`chunks_mut`]. + /// + /// See [`rchunks_mut`] for a variant of this iterator that also returns the remainder as a + /// smaller chunk, and [`chunks_exact_mut`] for the same iterator but starting at the beginning + /// of the slice of the slice. + /// + /// # Panics + /// + /// Panics if `chunk_size` is 0. + /// + /// # Examples + /// + /// ``` + /// let v = &mut [0, 0, 0, 0, 0]; + /// let mut count = 1; + /// + /// for chunk in v.rchunks_exact_mut(2) { + /// for elem in chunk.iter_mut() { + /// *elem += count; + /// } + /// count += 1; + /// } + /// assert_eq!(v, &[0, 2, 2, 1, 1]); + /// ``` + /// + /// [`rchunks_mut`]: #method.rchunks_mut + /// [`chunks_exact_mut`]: #method.chunks_exact_mut + #[stable(feature = "rchunks", since = "1.31.0")] + #[inline] + pub fn rchunks_exact_mut(&mut self, chunk_size: usize) -> RChunksExactMut { + assert!(chunk_size != 0); + let rem = self.len() % chunk_size; + let (fst, snd) = self.split_at_mut(rem); + RChunksExactMut { v: snd, rem: fst, chunk_size } } /// Divides one slice into two at an index. @@ -1174,9 +1344,10 @@ /// Binary searches this sorted slice for a given element. /// - /// If the value is found then `Ok` is returned, containing the - /// index of the matching element; if the value is not found then - /// `Err` is returned, containing the index where a matching + /// If the value is found then [`Result::Ok`] is returned, containing the + /// index of the matching element. If there are multiple matches, then any + /// one of the matches could be returned. If the value is not found then + /// [`Result::Err`] is returned, containing the index where a matching /// element could be inserted while maintaining sorted order. /// /// # Examples @@ -1208,9 +1379,10 @@ /// order code that indicates whether its argument is `Less`, /// `Equal` or `Greater` the desired target. /// - /// If a matching value is found then returns `Ok`, containing - /// the index for the matched element; if no match is found then - /// `Err` is returned, containing the index where a matching + /// If the value is found then [`Result::Ok`] is returned, containing the + /// index of the matching element. If there are multiple matches, then any + /// one of the matches could be returned. If the value is not found then + /// [`Result::Err`] is returned, containing the index where a matching /// element could be inserted while maintaining sorted order. /// /// # Examples @@ -1264,10 +1436,11 @@ /// Assumes that the slice is sorted by the key, for instance with /// [`sort_by_key`] using the same key extraction function. /// - /// If a matching value is found then returns `Ok`, containing the - /// index for the matched element; if no match is found then `Err` - /// is returned, containing the index where a matching element could - /// be inserted while maintaining sorted order. + /// If the value is found then [`Result::Ok`] is returned, containing the + /// index of the matching element. If there are multiple matches, then any + /// one of the matches could be returned. If the value is not found then + /// [`Result::Err`] is returned, containing the index where a matching + /// element could be inserted while maintaining sorted order. /// /// [`sort_by_key`]: #method.sort_by_key /// @@ -1402,6 +1575,178 @@ sort::quicksort(self, |a, b| f(a).lt(&f(b))); } + /// Moves all consecutive repeated elements to the end of the slice according to the + /// [`PartialEq`] trait implementation. + /// + /// Returns two slices. The first contains no consecutive repeated elements. + /// The second contains all the duplicates in no specified order. + /// + /// If the slice is sorted, the first returned slice contains no duplicates. + /// + /// # Examples + /// + /// ``` + /// #![feature(slice_partition_dedup)] + /// + /// let mut slice = [1, 2, 2, 3, 3, 2, 1, 1]; + /// + /// let (dedup, duplicates) = slice.partition_dedup(); + /// + /// assert_eq!(dedup, [1, 2, 3, 2, 1]); + /// assert_eq!(duplicates, [2, 3, 1]); + /// ``` + #[unstable(feature = "slice_partition_dedup", issue = "54279")] + #[inline] + pub fn partition_dedup(&mut self) -> (&mut [T], &mut [T]) + where T: PartialEq + { + self.partition_dedup_by(|a, b| a == b) + } + + /// Moves all but the first of consecutive elements to the end of the slice satisfying + /// a given equality relation. + /// + /// Returns two slices. The first contains no consecutive repeated elements. + /// The second contains all the duplicates in no specified order. + /// + /// The `same_bucket` function is passed references to two elements from the slice and + /// must determine if the elements compare equal. The elements are passed in opposite order + /// from their order in the slice, so if `same_bucket(a, b)` returns `true`, `a` is moved + /// at the end of the slice. + /// + /// If the slice is sorted, the first returned slice contains no duplicates. + /// + /// # Examples + /// + /// ``` + /// #![feature(slice_partition_dedup)] + /// + /// let mut slice = ["foo", "Foo", "BAZ", "Bar", "bar", "baz", "BAZ"]; + /// + /// let (dedup, duplicates) = slice.partition_dedup_by(|a, b| a.eq_ignore_ascii_case(b)); + /// + /// assert_eq!(dedup, ["foo", "BAZ", "Bar", "baz"]); + /// assert_eq!(duplicates, ["bar", "Foo", "BAZ"]); + /// ``` + #[unstable(feature = "slice_partition_dedup", issue = "54279")] + #[inline] + pub fn partition_dedup_by(&mut self, mut same_bucket: F) -> (&mut [T], &mut [T]) + where F: FnMut(&mut T, &mut T) -> bool + { + // Although we have a mutable reference to `self`, we cannot make + // *arbitrary* changes. The `same_bucket` calls could panic, so we + // must ensure that the slice is in a valid state at all times. + // + // The way that we handle this is by using swaps; we iterate + // over all the elements, swapping as we go so that at the end + // the elements we wish to keep are in the front, and those we + // wish to reject are at the back. We can then split the slice. + // This operation is still O(n). + // + // Example: We start in this state, where `r` represents "next + // read" and `w` represents "next_write`. + // + // r + // +---+---+---+---+---+---+ + // | 0 | 1 | 1 | 2 | 3 | 3 | + // +---+---+---+---+---+---+ + // w + // + // Comparing self[r] against self[w-1], this is not a duplicate, so + // we swap self[r] and self[w] (no effect as r==w) and then increment both + // r and w, leaving us with: + // + // r + // +---+---+---+---+---+---+ + // | 0 | 1 | 1 | 2 | 3 | 3 | + // +---+---+---+---+---+---+ + // w + // + // Comparing self[r] against self[w-1], this value is a duplicate, + // so we increment `r` but leave everything else unchanged: + // + // r + // +---+---+---+---+---+---+ + // | 0 | 1 | 1 | 2 | 3 | 3 | + // +---+---+---+---+---+---+ + // w + // + // Comparing self[r] against self[w-1], this is not a duplicate, + // so swap self[r] and self[w] and advance r and w: + // + // r + // +---+---+---+---+---+---+ + // | 0 | 1 | 2 | 1 | 3 | 3 | + // +---+---+---+---+---+---+ + // w + // + // Not a duplicate, repeat: + // + // r + // +---+---+---+---+---+---+ + // | 0 | 1 | 2 | 3 | 1 | 3 | + // +---+---+---+---+---+---+ + // w + // + // Duplicate, advance r. End of slice. Split at w. + + let len = self.len(); + if len <= 1 { + return (self, &mut []) + } + + let ptr = self.as_mut_ptr(); + let mut next_read: usize = 1; + let mut next_write: usize = 1; + + unsafe { + // Avoid bounds checks by using raw pointers. + while next_read < len { + let ptr_read = ptr.add(next_read); + let prev_ptr_write = ptr.add(next_write - 1); + if !same_bucket(&mut *ptr_read, &mut *prev_ptr_write) { + if next_read != next_write { + let ptr_write = prev_ptr_write.offset(1); + mem::swap(&mut *ptr_read, &mut *ptr_write); + } + next_write += 1; + } + next_read += 1; + } + } + + self.split_at_mut(next_write) + } + + /// Moves all but the first of consecutive elements to the end of the slice that resolve + /// to the same key. + /// + /// Returns two slices. The first contains no consecutive repeated elements. + /// The second contains all the duplicates in no specified order. + /// + /// If the slice is sorted, the first returned slice contains no duplicates. + /// + /// # Examples + /// + /// ``` + /// #![feature(slice_partition_dedup)] + /// + /// let mut slice = [10, 20, 21, 30, 30, 20, 11, 13]; + /// + /// let (dedup, duplicates) = slice.partition_dedup_by_key(|i| *i / 10); + /// + /// assert_eq!(dedup, [10, 20, 30, 20, 11]); + /// assert_eq!(duplicates, [21, 30, 13]); + /// ``` + #[unstable(feature = "slice_partition_dedup", issue = "54279")] + #[inline] + pub fn partition_dedup_by_key(&mut self, mut key: F) -> (&mut [T], &mut [T]) + where F: FnMut(&mut T) -> K, + K: PartialEq, + { + self.partition_dedup_by(|a, b| key(a) == key(b)) + } + /// Rotates the slice in-place such that the first `mid` elements of the /// slice move to the end while the last `self.len() - mid` elements move to /// the front. After calling `rotate_left`, the element previously at index @@ -1618,6 +1963,63 @@ } } + /// Copies elements from one part of the slice to another part of itself, + /// using a memmove. + /// + /// `src` is the range within `self` to copy from. `dest` is the starting + /// index of the range within `self` to copy to, which will have the same + /// length as `src`. The two ranges may overlap. The ends of the two ranges + /// must be less than or equal to `self.len()`. + /// + /// # Panics + /// + /// This function will panic if either range exceeds the end of the slice, + /// or if the end of `src` is before the start. + /// + /// # Examples + /// + /// Copying four bytes within a slice: + /// + /// ``` + /// # #![feature(copy_within)] + /// let mut bytes = *b"Hello, World!"; + /// + /// bytes.copy_within(1..5, 8); + /// + /// assert_eq!(&bytes, b"Hello, Wello!"); + /// ``` + #[unstable(feature = "copy_within", issue = "54236")] + pub fn copy_within>(&mut self, src: R, dest: usize) + where + T: Copy, + { + let src_start = match src.start_bound() { + ops::Bound::Included(&n) => n, + ops::Bound::Excluded(&n) => n + .checked_add(1) + .unwrap_or_else(|| slice_index_overflow_fail()), + ops::Bound::Unbounded => 0, + }; + let src_end = match src.end_bound() { + ops::Bound::Included(&n) => n + .checked_add(1) + .unwrap_or_else(|| slice_index_overflow_fail()), + ops::Bound::Excluded(&n) => n, + ops::Bound::Unbounded => self.len(), + }; + assert!(src_start <= src_end, "src end is before src start"); + assert!(src_end <= self.len(), "src is out of bounds"); + let count = src_end - src_start; + assert!(dest <= self.len() - count, "dest is out of bounds"); + unsafe { + ptr::copy( + self.get_unchecked(src_start), + self.get_unchecked_mut(dest), + count, + ); + } + } + /// Swaps all elements in `self` with those in `other`. /// /// The length of `other` must be the same as `self`. @@ -1699,7 +2101,7 @@ fn gcd(a: usize, b: usize) -> usize { // iterative stein’s algorithm // We should still make this `const fn` (and revert to recursive algorithm if we do) - // because relying on llvm to consteval all this is… well, it makes me + // because relying on llvm to consteval all this is… well, it makes me uncomfortable. let (ctz_a, mut ctz_b) = unsafe { if a == 0 { return b; } if b == 0 { return a; } @@ -2299,15 +2701,15 @@ //////////////////////////////////////////////////////////////////////////////// #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> Default for &'a [T] { +impl Default for &[T] { /// Creates an empty slice. - fn default() -> &'a [T] { &[] } + fn default() -> Self { &[] } } #[stable(feature = "mut_slice_default", since = "1.5.0")] -impl<'a, T> Default for &'a mut [T] { +impl Default for &mut [T] { /// Creates a mutable empty slice. - fn default() -> &'a mut [T] { &mut [] } + fn default() -> Self { &mut [] } } // @@ -2634,7 +3036,7 @@ } #[stable(feature = "core_impl_debug", since = "1.9.0")] -impl<'a, T: 'a + fmt::Debug> fmt::Debug for Iter<'a, T> { +impl fmt::Debug for Iter<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_tuple("Iter") .field(&self.as_slice()) @@ -2643,9 +3045,9 @@ } #[stable(feature = "rust1", since = "1.0.0")] -unsafe impl<'a, T: Sync> Sync for Iter<'a, T> {} +unsafe impl Sync for Iter<'_, T> {} #[stable(feature = "rust1", since = "1.0.0")] -unsafe impl<'a, T: Sync> Send for Iter<'a, T> {} +unsafe impl Send for Iter<'_, T> {} impl<'a, T> Iter<'a, T> { /// View the underlying data as a subslice of the original data. @@ -2681,12 +3083,12 @@ iterator!{struct Iter -> *const T, &'a T, const, /* no mut */} #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> Clone for Iter<'a, T> { - fn clone(&self) -> Iter<'a, T> { Iter { ptr: self.ptr, end: self.end, _marker: self._marker } } +impl Clone for Iter<'_, T> { + fn clone(&self) -> Self { Iter { ptr: self.ptr, end: self.end, _marker: self._marker } } } #[stable(feature = "slice_iter_as_ref", since = "1.13.0")] -impl<'a, T> AsRef<[T]> for Iter<'a, T> { +impl AsRef<[T]> for Iter<'_, T> { fn as_ref(&self) -> &[T] { self.as_slice() } @@ -2726,7 +3128,7 @@ } #[stable(feature = "core_impl_debug", since = "1.9.0")] -impl<'a, T: 'a + fmt::Debug> fmt::Debug for IterMut<'a, T> { +impl fmt::Debug for IterMut<'_, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_tuple("IterMut") .field(&self.make_slice()) @@ -2735,9 +3137,9 @@ } #[stable(feature = "rust1", since = "1.0.0")] -unsafe impl<'a, T: Sync> Sync for IterMut<'a, T> {} +unsafe impl Sync for IterMut<'_, T> {} #[stable(feature = "rust1", since = "1.0.0")] -unsafe impl<'a, T: Send> Send for IterMut<'a, T> {} +unsafe impl Send for IterMut<'_, T> {} impl<'a, T> IterMut<'a, T> { /// View the underlying data as a subslice of the original data. @@ -2805,7 +3207,7 @@ } #[stable(feature = "core_impl_debug", since = "1.9.0")] -impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for Split<'a, T, P> where P: FnMut(&T) -> bool { +impl fmt::Debug for Split<'_, T, P> where P: FnMut(&T) -> bool { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Split") .field("v", &self.v) @@ -2816,8 +3218,8 @@ // FIXME(#26925) Remove in favor of `#[derive(Clone)]` #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T, P> Clone for Split<'a, T, P> where P: Clone + FnMut(&T) -> bool { - fn clone(&self) -> Split<'a, T, P> { +impl Clone for Split<'_, T, P> where P: Clone + FnMut(&T) -> bool { + fn clone(&self) -> Self { Split { v: self.v, pred: self.pred.clone(), @@ -2879,7 +3281,7 @@ } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T, P> FusedIterator for Split<'a, T, P> where P: FnMut(&T) -> bool {} +impl FusedIterator for Split<'_, T, P> where P: FnMut(&T) -> bool {} /// An iterator over the subslices of the vector which are separated /// by elements that match `pred`. @@ -2896,7 +3298,7 @@ } #[stable(feature = "core_impl_debug", since = "1.9.0")] -impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for SplitMut<'a, T, P> where P: FnMut(&T) -> bool { +impl fmt::Debug for SplitMut<'_, T, P> where P: FnMut(&T) -> bool { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("SplitMut") .field("v", &self.v) @@ -2977,7 +3379,7 @@ } #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T, P> FusedIterator for SplitMut<'a, T, P> where P: FnMut(&T) -> bool {} +impl FusedIterator for SplitMut<'_, T, P> where P: FnMut(&T) -> bool {} /// An iterator over subslices separated by elements that match a predicate /// function, starting from the end of the slice. @@ -2993,7 +3395,7 @@ } #[stable(feature = "slice_rsplit", since = "1.27.0")] -impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplit<'a, T, P> where P: FnMut(&T) -> bool { +impl fmt::Debug for RSplit<'_, T, P> where P: FnMut(&T) -> bool { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("RSplit") .field("v", &self.inner.v) @@ -3034,7 +3436,7 @@ } #[stable(feature = "slice_rsplit", since = "1.27.0")] -impl<'a, T, P> FusedIterator for RSplit<'a, T, P> where P: FnMut(&T) -> bool {} +impl FusedIterator for RSplit<'_, T, P> where P: FnMut(&T) -> bool {} /// An iterator over the subslices of the vector which are separated /// by elements that match `pred`, starting from the end of the slice. @@ -3049,7 +3451,7 @@ } #[stable(feature = "slice_rsplit", since = "1.27.0")] -impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool { +impl fmt::Debug for RSplitMut<'_, T, P> where P: FnMut(&T) -> bool { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("RSplitMut") .field("v", &self.inner.v) @@ -3092,7 +3494,7 @@ } #[stable(feature = "slice_rsplit", since = "1.27.0")] -impl<'a, T, P> FusedIterator for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool {} +impl FusedIterator for RSplitMut<'_, T, P> where P: FnMut(&T) -> bool {} /// An private iterator over subslices separated by elements that /// match a predicate function, splitting at most a fixed number of @@ -3135,7 +3537,7 @@ } #[stable(feature = "core_impl_debug", since = "1.9.0")] -impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for SplitN<'a, T, P> where P: FnMut(&T) -> bool { +impl fmt::Debug for SplitN<'_, T, P> where P: FnMut(&T) -> bool { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("SplitN") .field("inner", &self.inner) @@ -3157,7 +3559,7 @@ } #[stable(feature = "core_impl_debug", since = "1.9.0")] -impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplitN<'a, T, P> where P: FnMut(&T) -> bool { +impl fmt::Debug for RSplitN<'_, T, P> where P: FnMut(&T) -> bool { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("RSplitN") .field("inner", &self.inner) @@ -3178,7 +3580,7 @@ } #[stable(feature = "core_impl_debug", since = "1.9.0")] -impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for SplitNMut<'a, T, P> where P: FnMut(&T) -> bool { +impl fmt::Debug for SplitNMut<'_, T, P> where P: FnMut(&T) -> bool { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("SplitNMut") .field("inner", &self.inner) @@ -3200,7 +3602,7 @@ } #[stable(feature = "core_impl_debug", since = "1.9.0")] -impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplitNMut<'a, T, P> where P: FnMut(&T) -> bool { +impl fmt::Debug for RSplitNMut<'_, T, P> where P: FnMut(&T) -> bool { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("RSplitNMut") .field("inner", &self.inner) @@ -3253,8 +3655,8 @@ // FIXME(#26925) Remove in favor of `#[derive(Clone)]` #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> Clone for Windows<'a, T> { - fn clone(&self) -> Windows<'a, T> { +impl Clone for Windows<'_, T> { + fn clone(&self) -> Self { Windows { v: self.v, size: self.size, @@ -3331,13 +3733,13 @@ } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> ExactSizeIterator for Windows<'a, T> {} +impl ExactSizeIterator for Windows<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, T> TrustedLen for Windows<'a, T> {} +unsafe impl TrustedLen for Windows<'_, T> {} #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T> FusedIterator for Windows<'a, T> {} +impl FusedIterator for Windows<'_, T> {} #[doc(hidden)] unsafe impl<'a, T> TrustedRandomAccess for Windows<'a, T> { @@ -3348,7 +3750,7 @@ } /// An iterator over a slice in (non-overlapping) chunks (`chunk_size` elements at a -/// time). +/// time), starting at the beginning of the slice. /// /// When the slice len is not evenly divided by the chunk size, the last slice /// of the iteration will be the remainder. @@ -3366,8 +3768,8 @@ // FIXME(#26925) Remove in favor of `#[derive(Clone)]` #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> Clone for Chunks<'a, T> { - fn clone(&self) -> Chunks<'a, T> { +impl Clone for Chunks<'_, T> { + fn clone(&self) -> Self { Chunks { v: self.v, chunk_size: self.chunk_size, @@ -3453,13 +3855,13 @@ } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> ExactSizeIterator for Chunks<'a, T> {} +impl ExactSizeIterator for Chunks<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, T> TrustedLen for Chunks<'a, T> {} +unsafe impl TrustedLen for Chunks<'_, T> {} #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T> FusedIterator for Chunks<'a, T> {} +impl FusedIterator for Chunks<'_, T> {} #[doc(hidden)] unsafe impl<'a, T> TrustedRandomAccess for Chunks<'a, T> { @@ -3475,8 +3877,10 @@ } /// An iterator over a slice in (non-overlapping) mutable chunks (`chunk_size` -/// elements at a time). When the slice len is not evenly divided by the chunk -/// size, the last slice of the iteration will be the remainder. +/// elements at a time), starting at the beginning of the slice. +/// +/// When the slice len is not evenly divided by the chunk size, the last slice +/// of the iteration will be the remainder. /// /// This struct is created by the [`chunks_mut`] method on [slices]. /// @@ -3572,13 +3976,13 @@ } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a, T> ExactSizeIterator for ChunksMut<'a, T> {} +impl ExactSizeIterator for ChunksMut<'_, T> {} #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, T> TrustedLen for ChunksMut<'a, T> {} +unsafe impl TrustedLen for ChunksMut<'_, T> {} #[stable(feature = "fused", since = "1.26.0")] -impl<'a, T> FusedIterator for ChunksMut<'a, T> {} +impl FusedIterator for ChunksMut<'_, T> {} #[doc(hidden)] unsafe impl<'a, T> TrustedRandomAccess for ChunksMut<'a, T> { @@ -3594,40 +3998,40 @@ } /// An iterator over a slice in (non-overlapping) chunks (`chunk_size` elements at a -/// time). +/// time), starting at the beginning of the slice. /// /// When the slice len is not evenly divided by the chunk size, the last /// up to `chunk_size-1` elements will be omitted but can be retrieved from /// the [`remainder`] function from the iterator. /// -/// This struct is created by the [`exact_chunks`] method on [slices]. +/// This struct is created by the [`chunks_exact`] method on [slices]. /// -/// [`exact_chunks`]: ../../std/primitive.slice.html#method.exact_chunks -/// [`remainder`]: ../../std/slice/struct.ExactChunks.html#method.remainder +/// [`chunks_exact`]: ../../std/primitive.slice.html#method.chunks_exact +/// [`remainder`]: ../../std/slice/struct.ChunksExact.html#method.remainder /// [slices]: ../../std/primitive.slice.html #[derive(Debug)] -#[unstable(feature = "exact_chunks", issue = "47115")] -pub struct ExactChunks<'a, T:'a> { +#[stable(feature = "chunks_exact", since = "1.31.0")] +pub struct ChunksExact<'a, T:'a> { v: &'a [T], rem: &'a [T], chunk_size: usize } -#[unstable(feature = "exact_chunks", issue = "47115")] -impl<'a, T> ExactChunks<'a, T> { +impl<'a, T> ChunksExact<'a, T> { /// Return the remainder of the original slice that is not going to be /// returned by the iterator. The returned slice has at most `chunk_size-1` /// elements. + #[stable(feature = "chunks_exact", since = "1.31.0")] pub fn remainder(&self) -> &'a [T] { self.rem } } // FIXME(#26925) Remove in favor of `#[derive(Clone)]` -#[unstable(feature = "exact_chunks", issue = "47115")] -impl<'a, T> Clone for ExactChunks<'a, T> { - fn clone(&self) -> ExactChunks<'a, T> { - ExactChunks { +#[stable(feature = "chunks_exact", since = "1.31.0")] +impl Clone for ChunksExact<'_, T> { + fn clone(&self) -> Self { + ChunksExact { v: self.v, rem: self.rem, chunk_size: self.chunk_size, @@ -3635,8 +4039,8 @@ } } -#[unstable(feature = "exact_chunks", issue = "47115")] -impl<'a, T> Iterator for ExactChunks<'a, T> { +#[stable(feature = "chunks_exact", since = "1.31.0")] +impl<'a, T> Iterator for ChunksExact<'a, T> { type Item = &'a [T]; #[inline] @@ -3680,8 +4084,8 @@ } } -#[unstable(feature = "exact_chunks", issue = "47115")] -impl<'a, T> DoubleEndedIterator for ExactChunks<'a, T> { +#[stable(feature = "chunks_exact", since = "1.31.0")] +impl<'a, T> DoubleEndedIterator for ChunksExact<'a, T> { #[inline] fn next_back(&mut self) -> Option<&'a [T]> { if self.v.len() < self.chunk_size { @@ -3694,21 +4098,22 @@ } } -#[unstable(feature = "exact_chunks", issue = "47115")] -impl<'a, T> ExactSizeIterator for ExactChunks<'a, T> { +#[stable(feature = "chunks_exact", since = "1.31.0")] +impl ExactSizeIterator for ChunksExact<'_, T> { fn is_empty(&self) -> bool { self.v.is_empty() } } #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, T> TrustedLen for ExactChunks<'a, T> {} +unsafe impl TrustedLen for ChunksExact<'_, T> {} -#[unstable(feature = "exact_chunks", issue = "47115")] -impl<'a, T> FusedIterator for ExactChunks<'a, T> {} +#[stable(feature = "chunks_exact", since = "1.31.0")] +impl FusedIterator for ChunksExact<'_, T> {} #[doc(hidden)] -unsafe impl<'a, T> TrustedRandomAccess for ExactChunks<'a, T> { +#[stable(feature = "chunks_exact", since = "1.31.0")] +unsafe impl<'a, T> TrustedRandomAccess for ChunksExact<'a, T> { unsafe fn get_unchecked(&mut self, i: usize) -> &'a [T] { let start = i * self.chunk_size; from_raw_parts(self.v.as_ptr().add(start), self.chunk_size) @@ -3717,37 +4122,37 @@ } /// An iterator over a slice in (non-overlapping) mutable chunks (`chunk_size` -/// elements at a time). +/// elements at a time), starting at the beginning of the slice. /// /// When the slice len is not evenly divided by the chunk size, the last up to /// `chunk_size-1` elements will be omitted but can be retrieved from the /// [`into_remainder`] function from the iterator. /// -/// This struct is created by the [`exact_chunks_mut`] method on [slices]. +/// This struct is created by the [`chunks_exact_mut`] method on [slices]. /// -/// [`exact_chunks_mut`]: ../../std/primitive.slice.html#method.exact_chunks_mut -/// [`into_remainder`]: ../../std/slice/struct.ExactChunksMut.html#method.into_remainder +/// [`chunks_exact_mut`]: ../../std/primitive.slice.html#method.chunks_exact_mut +/// [`into_remainder`]: ../../std/slice/struct.ChunksExactMut.html#method.into_remainder /// [slices]: ../../std/primitive.slice.html #[derive(Debug)] -#[unstable(feature = "exact_chunks", issue = "47115")] -pub struct ExactChunksMut<'a, T:'a> { +#[stable(feature = "chunks_exact", since = "1.31.0")] +pub struct ChunksExactMut<'a, T:'a> { v: &'a mut [T], rem: &'a mut [T], chunk_size: usize } -#[unstable(feature = "exact_chunks", issue = "47115")] -impl<'a, T> ExactChunksMut<'a, T> { +impl<'a, T> ChunksExactMut<'a, T> { /// Return the remainder of the original slice that is not going to be /// returned by the iterator. The returned slice has at most `chunk_size-1` /// elements. + #[stable(feature = "chunks_exact", since = "1.31.0")] pub fn into_remainder(self) -> &'a mut [T] { self.rem } } -#[unstable(feature = "exact_chunks", issue = "47115")] -impl<'a, T> Iterator for ExactChunksMut<'a, T> { +#[stable(feature = "chunks_exact", since = "1.31.0")] +impl<'a, T> Iterator for ChunksExactMut<'a, T> { type Item = &'a mut [T]; #[inline] @@ -3793,8 +4198,8 @@ } } -#[unstable(feature = "exact_chunks", issue = "47115")] -impl<'a, T> DoubleEndedIterator for ExactChunksMut<'a, T> { +#[stable(feature = "chunks_exact", since = "1.31.0")] +impl<'a, T> DoubleEndedIterator for ChunksExactMut<'a, T> { #[inline] fn next_back(&mut self) -> Option<&'a mut [T]> { if self.v.len() < self.chunk_size { @@ -3809,21 +4214,22 @@ } } -#[unstable(feature = "exact_chunks", issue = "47115")] -impl<'a, T> ExactSizeIterator for ExactChunksMut<'a, T> { +#[stable(feature = "chunks_exact", since = "1.31.0")] +impl ExactSizeIterator for ChunksExactMut<'_, T> { fn is_empty(&self) -> bool { self.v.is_empty() } } #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a, T> TrustedLen for ExactChunksMut<'a, T> {} +unsafe impl TrustedLen for ChunksExactMut<'_, T> {} -#[unstable(feature = "exact_chunks", issue = "47115")] -impl<'a, T> FusedIterator for ExactChunksMut<'a, T> {} +#[stable(feature = "chunks_exact", since = "1.31.0")] +impl FusedIterator for ChunksExactMut<'_, T> {} #[doc(hidden)] -unsafe impl<'a, T> TrustedRandomAccess for ExactChunksMut<'a, T> { +#[stable(feature = "chunks_exact", since = "1.31.0")] +unsafe impl<'a, T> TrustedRandomAccess for ChunksExactMut<'a, T> { unsafe fn get_unchecked(&mut self, i: usize) -> &'a mut [T] { let start = i * self.chunk_size; from_raw_parts_mut(self.v.as_mut_ptr().add(start), self.chunk_size) @@ -3831,69 +4237,578 @@ fn may_have_side_effect() -> bool { false } } -// -// Free functions -// - -/// Forms a slice from a pointer and a length. -/// -/// The `len` argument is the number of **elements**, not the number of bytes. -/// -/// # Safety -/// -/// This function is unsafe as there is no guarantee that the given pointer is -/// valid for `len` elements, nor whether the lifetime inferred is a suitable -/// lifetime for the returned slice. -/// -/// `data` must be non-null and aligned, even for zero-length slices. One -/// reason for this is that enum layout optimizations may rely on references -/// (including slices of any length) being aligned and non-null to distinguish -/// them from other data. You can obtain a pointer that is usable as `data` -/// for zero-length slices using [`NonNull::dangling()`]. -/// -/// # Caveat -/// -/// The lifetime for the returned slice is inferred from its usage. To -/// prevent accidental misuse, it's suggested to tie the lifetime to whichever -/// source lifetime is safe in the context, such as by providing a helper -/// function taking the lifetime of a host value for the slice, or by explicit -/// annotation. -/// -/// # Examples +/// An iterator over a slice in (non-overlapping) chunks (`chunk_size` elements at a +/// time), starting at the end of the slice. /// -/// ``` -/// use std::slice; +/// When the slice len is not evenly divided by the chunk size, the last slice +/// of the iteration will be the remainder. /// -/// // manifest a slice for a single element -/// let x = 42; -/// let ptr = &x as *const _; -/// let slice = unsafe { slice::from_raw_parts(ptr, 1) }; -/// assert_eq!(slice[0], 42); -/// ``` +/// This struct is created by the [`rchunks`] method on [slices]. /// -/// [`NonNull::dangling()`]: ../../std/ptr/struct.NonNull.html#method.dangling -#[inline] -#[stable(feature = "rust1", since = "1.0.0")] -pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] { - debug_assert!(data as usize % mem::align_of::() == 0, "attempt to create unaligned slice"); - Repr { raw: FatPtr { data, len } }.rust +/// [`rchunks`]: ../../std/primitive.slice.html#method.rchunks +/// [slices]: ../../std/primitive.slice.html +#[derive(Debug)] +#[stable(feature = "rchunks", since = "1.31.0")] +pub struct RChunks<'a, T:'a> { + v: &'a [T], + chunk_size: usize } -/// Performs the same functionality as [`from_raw_parts`], except that a -/// mutable slice is returned. -/// -/// This function is unsafe for the same reasons as [`from_raw_parts`], as well -/// as not being able to provide a non-aliasing guarantee of the returned -/// mutable slice. `data` must be non-null and aligned even for zero-length -/// slices as with [`from_raw_parts`]. See the documentation of -/// [`from_raw_parts`] for more details. +// FIXME(#26925) Remove in favor of `#[derive(Clone)]` +#[stable(feature = "rchunks", since = "1.31.0")] +impl<'a, T> Clone for RChunks<'a, T> { + fn clone(&self) -> RChunks<'a, T> { + RChunks { + v: self.v, + chunk_size: self.chunk_size, + } + } +} + +#[stable(feature = "rchunks", since = "1.31.0")] +impl<'a, T> Iterator for RChunks<'a, T> { + type Item = &'a [T]; + + #[inline] + fn next(&mut self) -> Option<&'a [T]> { + if self.v.is_empty() { + None + } else { + let chunksz = cmp::min(self.v.len(), self.chunk_size); + let (fst, snd) = self.v.split_at(self.v.len() - chunksz); + self.v = fst; + Some(snd) + } + } + + #[inline] + fn size_hint(&self) -> (usize, Option) { + if self.v.is_empty() { + (0, Some(0)) + } else { + let n = self.v.len() / self.chunk_size; + let rem = self.v.len() % self.chunk_size; + let n = if rem > 0 { n+1 } else { n }; + (n, Some(n)) + } + } + + #[inline] + fn count(self) -> usize { + self.len() + } + + #[inline] + fn nth(&mut self, n: usize) -> Option { + let (end, overflow) = n.overflowing_mul(self.chunk_size); + if end >= self.v.len() || overflow { + self.v = &[]; + None + } else { + // Can't underflow because of the check above + let end = self.v.len() - end; + let start = match end.checked_sub(self.chunk_size) { + Some(sum) => sum, + None => 0, + }; + let nth = &self.v[start..end]; + self.v = &self.v[0..start]; + Some(nth) + } + } + + #[inline] + fn last(self) -> Option { + if self.v.is_empty() { + None + } else { + let rem = self.v.len() % self.chunk_size; + let end = if rem == 0 { self.chunk_size } else { rem }; + Some(&self.v[0..end]) + } + } +} + +#[stable(feature = "rchunks", since = "1.31.0")] +impl<'a, T> DoubleEndedIterator for RChunks<'a, T> { + #[inline] + fn next_back(&mut self) -> Option<&'a [T]> { + if self.v.is_empty() { + None + } else { + let remainder = self.v.len() % self.chunk_size; + let chunksz = if remainder != 0 { remainder } else { self.chunk_size }; + let (fst, snd) = self.v.split_at(chunksz); + self.v = snd; + Some(fst) + } + } +} + +#[stable(feature = "rchunks", since = "1.31.0")] +impl<'a, T> ExactSizeIterator for RChunks<'a, T> {} + +#[unstable(feature = "trusted_len", issue = "37572")] +unsafe impl<'a, T> TrustedLen for RChunks<'a, T> {} + +#[stable(feature = "rchunks", since = "1.31.0")] +impl<'a, T> FusedIterator for RChunks<'a, T> {} + +#[doc(hidden)] +#[stable(feature = "rchunks", since = "1.31.0")] +unsafe impl<'a, T> TrustedRandomAccess for RChunks<'a, T> { + unsafe fn get_unchecked(&mut self, i: usize) -> &'a [T] { + let end = self.v.len() - i * self.chunk_size; + let start = match end.checked_sub(self.chunk_size) { + None => 0, + Some(start) => start, + }; + from_raw_parts(self.v.as_ptr().add(start), end - start) + } + fn may_have_side_effect() -> bool { false } +} + +/// An iterator over a slice in (non-overlapping) mutable chunks (`chunk_size` +/// elements at a time), starting at the end of the slice. +/// +/// When the slice len is not evenly divided by the chunk size, the last slice +/// of the iteration will be the remainder. +/// +/// This struct is created by the [`rchunks_mut`] method on [slices]. +/// +/// [`rchunks_mut`]: ../../std/primitive.slice.html#method.rchunks_mut +/// [slices]: ../../std/primitive.slice.html +#[derive(Debug)] +#[stable(feature = "rchunks", since = "1.31.0")] +pub struct RChunksMut<'a, T:'a> { + v: &'a mut [T], + chunk_size: usize +} + +#[stable(feature = "rchunks", since = "1.31.0")] +impl<'a, T> Iterator for RChunksMut<'a, T> { + type Item = &'a mut [T]; + + #[inline] + fn next(&mut self) -> Option<&'a mut [T]> { + if self.v.is_empty() { + None + } else { + let sz = cmp::min(self.v.len(), self.chunk_size); + let tmp = mem::replace(&mut self.v, &mut []); + let tmp_len = tmp.len(); + let (head, tail) = tmp.split_at_mut(tmp_len - sz); + self.v = head; + Some(tail) + } + } + + #[inline] + fn size_hint(&self) -> (usize, Option) { + if self.v.is_empty() { + (0, Some(0)) + } else { + let n = self.v.len() / self.chunk_size; + let rem = self.v.len() % self.chunk_size; + let n = if rem > 0 { n + 1 } else { n }; + (n, Some(n)) + } + } + + #[inline] + fn count(self) -> usize { + self.len() + } + + #[inline] + fn nth(&mut self, n: usize) -> Option<&'a mut [T]> { + let (end, overflow) = n.overflowing_mul(self.chunk_size); + if end >= self.v.len() || overflow { + self.v = &mut []; + None + } else { + // Can't underflow because of the check above + let end = self.v.len() - end; + let start = match end.checked_sub(self.chunk_size) { + Some(sum) => sum, + None => 0, + }; + let tmp = mem::replace(&mut self.v, &mut []); + let (head, tail) = tmp.split_at_mut(start); + let (nth, _) = tail.split_at_mut(end - start); + self.v = head; + Some(nth) + } + } + + #[inline] + fn last(self) -> Option { + if self.v.is_empty() { + None + } else { + let rem = self.v.len() % self.chunk_size; + let end = if rem == 0 { self.chunk_size } else { rem }; + Some(&mut self.v[0..end]) + } + } +} + +#[stable(feature = "rchunks", since = "1.31.0")] +impl<'a, T> DoubleEndedIterator for RChunksMut<'a, T> { + #[inline] + fn next_back(&mut self) -> Option<&'a mut [T]> { + if self.v.is_empty() { + None + } else { + let remainder = self.v.len() % self.chunk_size; + let sz = if remainder != 0 { remainder } else { self.chunk_size }; + let tmp = mem::replace(&mut self.v, &mut []); + let (head, tail) = tmp.split_at_mut(sz); + self.v = tail; + Some(head) + } + } +} + +#[stable(feature = "rchunks", since = "1.31.0")] +impl<'a, T> ExactSizeIterator for RChunksMut<'a, T> {} + +#[unstable(feature = "trusted_len", issue = "37572")] +unsafe impl<'a, T> TrustedLen for RChunksMut<'a, T> {} + +#[stable(feature = "rchunks", since = "1.31.0")] +impl<'a, T> FusedIterator for RChunksMut<'a, T> {} + +#[doc(hidden)] +#[stable(feature = "rchunks", since = "1.31.0")] +unsafe impl<'a, T> TrustedRandomAccess for RChunksMut<'a, T> { + unsafe fn get_unchecked(&mut self, i: usize) -> &'a mut [T] { + let end = self.v.len() - i * self.chunk_size; + let start = match end.checked_sub(self.chunk_size) { + None => 0, + Some(start) => start, + }; + from_raw_parts_mut(self.v.as_mut_ptr().add(start), end - start) + } + fn may_have_side_effect() -> bool { false } +} + +/// An iterator over a slice in (non-overlapping) chunks (`chunk_size` elements at a +/// time), starting at the end of the slice. +/// +/// When the slice len is not evenly divided by the chunk size, the last +/// up to `chunk_size-1` elements will be omitted but can be retrieved from +/// the [`remainder`] function from the iterator. +/// +/// This struct is created by the [`rchunks_exact`] method on [slices]. +/// +/// [`rchunks_exact`]: ../../std/primitive.slice.html#method.rchunks_exact +/// [`remainder`]: ../../std/slice/struct.ChunksExact.html#method.remainder +/// [slices]: ../../std/primitive.slice.html +#[derive(Debug)] +#[stable(feature = "rchunks", since = "1.31.0")] +pub struct RChunksExact<'a, T:'a> { + v: &'a [T], + rem: &'a [T], + chunk_size: usize +} + +impl<'a, T> RChunksExact<'a, T> { + /// Return the remainder of the original slice that is not going to be + /// returned by the iterator. The returned slice has at most `chunk_size-1` + /// elements. + #[stable(feature = "rchunks", since = "1.31.0")] + pub fn remainder(&self) -> &'a [T] { + self.rem + } +} + +// FIXME(#26925) Remove in favor of `#[derive(Clone)]` +#[stable(feature = "rchunks", since = "1.31.0")] +impl<'a, T> Clone for RChunksExact<'a, T> { + fn clone(&self) -> RChunksExact<'a, T> { + RChunksExact { + v: self.v, + rem: self.rem, + chunk_size: self.chunk_size, + } + } +} + +#[stable(feature = "rchunks", since = "1.31.0")] +impl<'a, T> Iterator for RChunksExact<'a, T> { + type Item = &'a [T]; + + #[inline] + fn next(&mut self) -> Option<&'a [T]> { + if self.v.len() < self.chunk_size { + None + } else { + let (fst, snd) = self.v.split_at(self.v.len() - self.chunk_size); + self.v = fst; + Some(snd) + } + } + + #[inline] + fn size_hint(&self) -> (usize, Option) { + let n = self.v.len() / self.chunk_size; + (n, Some(n)) + } + + #[inline] + fn count(self) -> usize { + self.len() + } + + #[inline] + fn nth(&mut self, n: usize) -> Option { + let (end, overflow) = n.overflowing_mul(self.chunk_size); + if end >= self.v.len() || overflow { + self.v = &[]; + None + } else { + let (fst, _) = self.v.split_at(self.v.len() - end); + self.v = fst; + self.next() + } + } + + #[inline] + fn last(mut self) -> Option { + self.next_back() + } +} + +#[stable(feature = "rchunks", since = "1.31.0")] +impl<'a, T> DoubleEndedIterator for RChunksExact<'a, T> { + #[inline] + fn next_back(&mut self) -> Option<&'a [T]> { + if self.v.len() < self.chunk_size { + None + } else { + let (fst, snd) = self.v.split_at(self.chunk_size); + self.v = snd; + Some(fst) + } + } +} + +#[stable(feature = "rchunks", since = "1.31.0")] +impl<'a, T> ExactSizeIterator for RChunksExact<'a, T> { + fn is_empty(&self) -> bool { + self.v.is_empty() + } +} + +#[unstable(feature = "trusted_len", issue = "37572")] +unsafe impl<'a, T> TrustedLen for RChunksExact<'a, T> {} + +#[stable(feature = "rchunks", since = "1.31.0")] +impl<'a, T> FusedIterator for RChunksExact<'a, T> {} + +#[doc(hidden)] +#[stable(feature = "rchunks", since = "1.31.0")] +unsafe impl<'a, T> TrustedRandomAccess for RChunksExact<'a, T> { + unsafe fn get_unchecked(&mut self, i: usize) -> &'a [T] { + let end = self.v.len() - i * self.chunk_size; + let start = end - self.chunk_size; + from_raw_parts(self.v.as_ptr().add(start), self.chunk_size) + } + fn may_have_side_effect() -> bool { false } +} + +/// An iterator over a slice in (non-overlapping) mutable chunks (`chunk_size` +/// elements at a time), starting at the end of the slice. +/// +/// When the slice len is not evenly divided by the chunk size, the last up to +/// `chunk_size-1` elements will be omitted but can be retrieved from the +/// [`into_remainder`] function from the iterator. +/// +/// This struct is created by the [`rchunks_exact_mut`] method on [slices]. +/// +/// [`rchunks_exact_mut`]: ../../std/primitive.slice.html#method.rchunks_exact_mut +/// [`into_remainder`]: ../../std/slice/struct.ChunksExactMut.html#method.into_remainder +/// [slices]: ../../std/primitive.slice.html +#[derive(Debug)] +#[stable(feature = "rchunks", since = "1.31.0")] +pub struct RChunksExactMut<'a, T:'a> { + v: &'a mut [T], + rem: &'a mut [T], + chunk_size: usize +} + +impl<'a, T> RChunksExactMut<'a, T> { + /// Return the remainder of the original slice that is not going to be + /// returned by the iterator. The returned slice has at most `chunk_size-1` + /// elements. + #[stable(feature = "rchunks", since = "1.31.0")] + pub fn into_remainder(self) -> &'a mut [T] { + self.rem + } +} + +#[stable(feature = "rchunks", since = "1.31.0")] +impl<'a, T> Iterator for RChunksExactMut<'a, T> { + type Item = &'a mut [T]; + + #[inline] + fn next(&mut self) -> Option<&'a mut [T]> { + if self.v.len() < self.chunk_size { + None + } else { + let tmp = mem::replace(&mut self.v, &mut []); + let tmp_len = tmp.len(); + let (head, tail) = tmp.split_at_mut(tmp_len - self.chunk_size); + self.v = head; + Some(tail) + } + } + + #[inline] + fn size_hint(&self) -> (usize, Option) { + let n = self.v.len() / self.chunk_size; + (n, Some(n)) + } + + #[inline] + fn count(self) -> usize { + self.len() + } + + #[inline] + fn nth(&mut self, n: usize) -> Option<&'a mut [T]> { + let (end, overflow) = n.overflowing_mul(self.chunk_size); + if end >= self.v.len() || overflow { + self.v = &mut []; + None + } else { + let tmp = mem::replace(&mut self.v, &mut []); + let tmp_len = tmp.len(); + let (fst, _) = tmp.split_at_mut(tmp_len - end); + self.v = fst; + self.next() + } + } + + #[inline] + fn last(mut self) -> Option { + self.next_back() + } +} + +#[stable(feature = "rchunks", since = "1.31.0")] +impl<'a, T> DoubleEndedIterator for RChunksExactMut<'a, T> { + #[inline] + fn next_back(&mut self) -> Option<&'a mut [T]> { + if self.v.len() < self.chunk_size { + None + } else { + let tmp = mem::replace(&mut self.v, &mut []); + let (head, tail) = tmp.split_at_mut(self.chunk_size); + self.v = tail; + Some(head) + } + } +} + +#[stable(feature = "rchunks", since = "1.31.0")] +impl<'a, T> ExactSizeIterator for RChunksExactMut<'a, T> { + fn is_empty(&self) -> bool { + self.v.is_empty() + } +} + +#[unstable(feature = "trusted_len", issue = "37572")] +unsafe impl<'a, T> TrustedLen for RChunksExactMut<'a, T> {} + +#[stable(feature = "rchunks", since = "1.31.0")] +impl<'a, T> FusedIterator for RChunksExactMut<'a, T> {} + +#[doc(hidden)] +#[stable(feature = "rchunks", since = "1.31.0")] +unsafe impl<'a, T> TrustedRandomAccess for RChunksExactMut<'a, T> { + unsafe fn get_unchecked(&mut self, i: usize) -> &'a mut [T] { + let end = self.v.len() - i * self.chunk_size; + let start = end - self.chunk_size; + from_raw_parts_mut(self.v.as_mut_ptr().add(start), self.chunk_size) + } + fn may_have_side_effect() -> bool { false } +} + +// +// Free functions +// + +/// Forms a slice from a pointer and a length. +/// +/// The `len` argument is the number of **elements**, not the number of bytes. +/// +/// # Safety +/// +/// This function is unsafe as there is no guarantee that the given pointer is +/// valid for `len` elements, nor whether the lifetime inferred is a suitable +/// lifetime for the returned slice. +/// +/// `data` must be non-null and aligned, even for zero-length slices. One +/// reason for this is that enum layout optimizations may rely on references +/// (including slices of any length) being aligned and non-null to distinguish +/// them from other data. You can obtain a pointer that is usable as `data` +/// for zero-length slices using [`NonNull::dangling()`]. +/// +/// The total size of the slice must be no larger than `isize::MAX` **bytes** +/// in memory. See the safety documentation of [`pointer::offset`]. +/// +/// # Caveat +/// +/// The lifetime for the returned slice is inferred from its usage. To +/// prevent accidental misuse, it's suggested to tie the lifetime to whichever +/// source lifetime is safe in the context, such as by providing a helper +/// function taking the lifetime of a host value for the slice, or by explicit +/// annotation. +/// +/// # Examples +/// +/// ``` +/// use std::slice; +/// +/// // manifest a slice for a single element +/// let x = 42; +/// let ptr = &x as *const _; +/// let slice = unsafe { slice::from_raw_parts(ptr, 1) }; +/// assert_eq!(slice[0], 42); +/// ``` +/// +/// [`NonNull::dangling()`]: ../../std/ptr/struct.NonNull.html#method.dangling +/// [`pointer::offset`]: ../../std/primitive.pointer.html#method.offset +#[inline] +#[stable(feature = "rust1", since = "1.0.0")] +pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] { + debug_assert!(data as usize % mem::align_of::() == 0, "attempt to create unaligned slice"); + debug_assert!(mem::size_of::().saturating_mul(len) <= isize::MAX as usize, + "attempt to create slice covering half the address space"); + Repr { raw: FatPtr { data, len } }.rust +} + +/// Performs the same functionality as [`from_raw_parts`], except that a +/// mutable slice is returned. +/// +/// This function is unsafe for the same reasons as [`from_raw_parts`], as well +/// as not being able to provide a non-aliasing guarantee of the returned +/// mutable slice. `data` must be non-null and aligned even for zero-length +/// slices as with [`from_raw_parts`]. The total size of the slice must be no +/// larger than `isize::MAX` **bytes** in memory. +/// +/// See the documentation of [`from_raw_parts`] for more details. /// /// [`from_raw_parts`]: ../../std/slice/fn.from_raw_parts.html #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn from_raw_parts_mut<'a, T>(data: *mut T, len: usize) -> &'a mut [T] { debug_assert!(data as usize % mem::align_of::() == 0, "attempt to create unaligned slice"); - Repr { raw: FatPtr { data, len} }.rust_mut + debug_assert!(mem::size_of::().saturating_mul(len) <= isize::MAX as usize, + "attempt to create slice covering half the address space"); + Repr { raw: FatPtr { data, len } }.rust_mut } /// Converts a reference to T into a slice of length 1 (without copying). diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/str/mod.rs rustc-1.31.0+dfsg1+llvm/src/libcore/str/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/str/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/str/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -617,7 +617,7 @@ } #[stable(feature = "fused", since = "1.26.0")] -impl<'a> FusedIterator for Chars<'a> {} +impl FusedIterator for Chars<'_> {} impl<'a> Chars<'a> { /// View the underlying data as a subslice of the original data. @@ -707,7 +707,7 @@ } #[stable(feature = "fused", since = "1.26.0")] -impl<'a> FusedIterator for CharIndices<'a> {} +impl FusedIterator for CharIndices<'_> {} impl<'a> CharIndices<'a> { /// View the underlying data as a subslice of the original data. @@ -733,7 +733,7 @@ pub struct Bytes<'a>(Cloned>); #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> Iterator for Bytes<'a> { +impl Iterator for Bytes<'_> { type Item = u8; #[inline] @@ -794,7 +794,7 @@ } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> DoubleEndedIterator for Bytes<'a> { +impl DoubleEndedIterator for Bytes<'_> { #[inline] fn next_back(&mut self) -> Option { self.0.next_back() @@ -809,7 +809,7 @@ } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> ExactSizeIterator for Bytes<'a> { +impl ExactSizeIterator for Bytes<'_> { #[inline] fn len(&self) -> usize { self.0.len() @@ -822,10 +822,10 @@ } #[stable(feature = "fused", since = "1.26.0")] -impl<'a> FusedIterator for Bytes<'a> {} +impl FusedIterator for Bytes<'_> {} #[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl<'a> TrustedLen for Bytes<'a> {} +unsafe impl TrustedLen for Bytes<'_> {} #[doc(hidden)] unsafe impl<'a> TrustedRandomAccess for Bytes<'a> { @@ -1342,7 +1342,7 @@ } #[stable(feature = "fused", since = "1.26.0")] -impl<'a> FusedIterator for Lines<'a> {} +impl FusedIterator for Lines<'_> {} /// Created with the method [`lines_any`]. /// @@ -1409,7 +1409,7 @@ #[stable(feature = "fused", since = "1.26.0")] #[allow(deprecated)] -impl<'a> FusedIterator for LinesAny<'a> {} +impl FusedIterator for LinesAny<'_> {} /* Section: UTF-8 validation @@ -4033,15 +4033,15 @@ } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> Default for &'a str { +impl Default for &str { /// Creates an empty str - fn default() -> &'a str { "" } + fn default() -> Self { "" } } #[stable(feature = "default_mut_str", since = "1.28.0")] -impl<'a> Default for &'a mut str { +impl Default for &mut str { /// Creates an empty mutable str - fn default() -> &'a mut str { unsafe { from_utf8_unchecked_mut(&mut []) } } + fn default() -> Self { unsafe { from_utf8_unchecked_mut(&mut []) } } } /// An iterator over the non-whitespace substrings of a string, @@ -4189,7 +4189,7 @@ } #[stable(feature = "fused", since = "1.26.0")] -impl<'a> FusedIterator for SplitWhitespace<'a> {} +impl FusedIterator for SplitWhitespace<'_> {} #[unstable(feature = "split_ascii_whitespace", issue = "48656")] impl<'a> Iterator for SplitAsciiWhitespace<'a> { @@ -4215,7 +4215,7 @@ } #[unstable(feature = "split_ascii_whitespace", issue = "48656")] -impl<'a> FusedIterator for SplitAsciiWhitespace<'a> {} +impl FusedIterator for SplitAsciiWhitespace<'_> {} /// An iterator of [`u16`] over the string encoded as UTF-16. /// @@ -4234,7 +4234,7 @@ } #[stable(feature = "collection_debug", since = "1.17.0")] -impl<'a> fmt::Debug for EncodeUtf16<'a> { +impl fmt::Debug for EncodeUtf16<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.pad("EncodeUtf16 { .. }") } @@ -4273,4 +4273,4 @@ } #[stable(feature = "fused", since = "1.26.0")] -impl<'a> FusedIterator for EncodeUtf16<'a> {} +impl FusedIterator for EncodeUtf16<'_> {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/str/pattern.rs rustc-1.31.0+dfsg1+llvm/src/libcore/str/pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/str/pattern.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/str/pattern.rs 2018-12-04 23:41:40.000000000 +0000 @@ -491,7 +491,7 @@ fn matches(&mut self, c: char) -> bool { (*self)(c) } } -impl<'a> MultiCharEq for &'a [char] { +impl MultiCharEq for &[char] { #[inline] fn matches(&mut self, c: char) -> bool { self.iter().any(|&m| { m == c }) @@ -666,7 +666,7 @@ pub struct CharPredicateSearcher<'a, F>( as Pattern<'a>>::Searcher) where F: FnMut(char) -> bool; -impl<'a, F> fmt::Debug for CharPredicateSearcher<'a, F> +impl fmt::Debug for CharPredicateSearcher<'_, F> where F: FnMut(char) -> bool { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/sync/atomic.rs rustc-1.31.0+dfsg1+llvm/src/libcore/sync/atomic.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/sync/atomic.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/sync/atomic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -558,6 +558,7 @@ /// ``` #[inline] #[stable(feature = "extended_compare_and_swap", since = "1.10.0")] + #[cfg(target_has_atomic = "cas")] pub fn compare_exchange_weak(&self, current: bool, new: bool, @@ -1041,6 +1042,7 @@ /// ``` #[inline] #[stable(feature = "extended_compare_and_swap", since = "1.10.0")] + #[cfg(target_has_atomic = "cas")] pub fn compare_exchange_weak(&self, current: *mut T, new: *mut T, @@ -1434,6 +1436,7 @@ ```"), #[inline] #[$stable_cxchg] + #[cfg(target_has_atomic = "cas")] pub fn compare_exchange_weak(&self, current: $int_type, new: $int_type, @@ -1471,6 +1474,7 @@ ```"), #[inline] #[$stable] + #[cfg(target_has_atomic = "cas")] pub fn fetch_add(&self, val: $int_type, order: Ordering) -> $int_type { unsafe { atomic_add(self.v.get(), val, order) } } @@ -1502,6 +1506,7 @@ ```"), #[inline] #[$stable] + #[cfg(target_has_atomic = "cas")] pub fn fetch_sub(&self, val: $int_type, order: Ordering) -> $int_type { unsafe { atomic_sub(self.v.get(), val, order) } } @@ -1536,6 +1541,7 @@ ```"), #[inline] #[$stable] + #[cfg(target_has_atomic = "cas")] pub fn fetch_and(&self, val: $int_type, order: Ordering) -> $int_type { unsafe { atomic_and(self.v.get(), val, order) } } @@ -1571,6 +1577,7 @@ ```"), #[inline] #[$stable_nand] + #[cfg(target_has_atomic = "cas")] pub fn fetch_nand(&self, val: $int_type, order: Ordering) -> $int_type { unsafe { atomic_nand(self.v.get(), val, order) } } @@ -1605,6 +1612,7 @@ ```"), #[inline] #[$stable] + #[cfg(target_has_atomic = "cas")] pub fn fetch_or(&self, val: $int_type, order: Ordering) -> $int_type { unsafe { atomic_or(self.v.get(), val, order) } } @@ -1639,6 +1647,7 @@ ```"), #[inline] #[$stable] + #[cfg(target_has_atomic = "cas")] pub fn fetch_xor(&self, val: $int_type, order: Ordering) -> $int_type { unsafe { atomic_xor(self.v.get(), val, order) } } @@ -1688,6 +1697,7 @@ #[unstable(feature = "no_more_cas", reason = "no more CAS loops in user code", issue = "48655")] + #[cfg(target_has_atomic = "cas")] pub fn fetch_update(&self, mut f: F, fetch_order: Ordering, @@ -1748,6 +1758,7 @@ #[unstable(feature = "atomic_min_max", reason = "easier and faster min/max than writing manual CAS loop", issue = "48655")] + #[cfg(target_has_atomic = "cas")] pub fn fetch_max(&self, val: $int_type, order: Ordering) -> $int_type { unsafe { $max_fn(self.v.get(), val, order) } } @@ -1799,6 +1810,7 @@ #[unstable(feature = "atomic_min_max", reason = "easier and faster min/max than writing manual CAS loop", issue = "48655")] + #[cfg(target_has_atomic = "cas")] pub fn fetch_min(&self, val: $int_type, order: Ordering) -> $int_type { unsafe { $min_fn(self.v.get(), val, order) } } @@ -1987,6 +1999,7 @@ /// Returns the previous value (like __sync_fetch_and_add). #[inline] +#[cfg(target_has_atomic = "cas")] unsafe fn atomic_add(dst: *mut T, val: T, order: Ordering) -> T { match order { Acquire => intrinsics::atomic_xadd_acq(dst, val), @@ -1999,6 +2012,7 @@ /// Returns the previous value (like __sync_fetch_and_sub). #[inline] +#[cfg(target_has_atomic = "cas")] unsafe fn atomic_sub(dst: *mut T, val: T, order: Ordering) -> T { match order { Acquire => intrinsics::atomic_xsub_acq(dst, val), @@ -2035,6 +2049,7 @@ } #[inline] +#[cfg(target_has_atomic = "cas")] unsafe fn atomic_compare_exchange_weak(dst: *mut T, old: T, new: T, @@ -2059,6 +2074,7 @@ } #[inline] +#[cfg(target_has_atomic = "cas")] unsafe fn atomic_and(dst: *mut T, val: T, order: Ordering) -> T { match order { Acquire => intrinsics::atomic_and_acq(dst, val), @@ -2070,6 +2086,7 @@ } #[inline] +#[cfg(target_has_atomic = "cas")] unsafe fn atomic_nand(dst: *mut T, val: T, order: Ordering) -> T { match order { Acquire => intrinsics::atomic_nand_acq(dst, val), @@ -2081,6 +2098,7 @@ } #[inline] +#[cfg(target_has_atomic = "cas")] unsafe fn atomic_or(dst: *mut T, val: T, order: Ordering) -> T { match order { Acquire => intrinsics::atomic_or_acq(dst, val), @@ -2092,6 +2110,7 @@ } #[inline] +#[cfg(target_has_atomic = "cas")] unsafe fn atomic_xor(dst: *mut T, val: T, order: Ordering) -> T { match order { Acquire => intrinsics::atomic_xor_acq(dst, val), @@ -2104,6 +2123,7 @@ /// returns the max value (signed comparison) #[inline] +#[cfg(target_has_atomic = "cas")] unsafe fn atomic_max(dst: *mut T, val: T, order: Ordering) -> T { match order { Acquire => intrinsics::atomic_max_acq(dst, val), @@ -2116,6 +2136,7 @@ /// returns the min value (signed comparison) #[inline] +#[cfg(target_has_atomic = "cas")] unsafe fn atomic_min(dst: *mut T, val: T, order: Ordering) -> T { match order { Acquire => intrinsics::atomic_min_acq(dst, val), @@ -2128,6 +2149,7 @@ /// returns the max value (signed comparison) #[inline] +#[cfg(target_has_atomic = "cas")] unsafe fn atomic_umax(dst: *mut T, val: T, order: Ordering) -> T { match order { Acquire => intrinsics::atomic_umax_acq(dst, val), @@ -2140,6 +2162,7 @@ /// returns the min value (signed comparison) #[inline] +#[cfg(target_has_atomic = "cas")] unsafe fn atomic_umin(dst: *mut T, val: T, order: Ordering) -> T { match order { Acquire => intrinsics::atomic_umin_acq(dst, val), @@ -2228,7 +2251,15 @@ /// [`Relaxed`]: enum.Ordering.html#variant.Relaxed #[inline] #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(target_arch = "wasm32", allow(unused_variables))] pub fn fence(order: Ordering) { + // On wasm32 it looks like fences aren't implemented in LLVM yet in that + // they will cause LLVM to abort. The wasm instruction set doesn't have + // fences right now. There's discussion online about the best way for tools + // to conventionally implement fences at + // https://github.com/WebAssembly/tool-conventions/issues/59. We should + // follow that discussion and implement a solution when one comes about! + #[cfg(not(target_arch = "wasm32"))] unsafe { match order { Acquire => intrinsics::atomic_fence_acq(), diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/task/context.rs rustc-1.31.0+dfsg1+llvm/src/libcore/task/context.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/task/context.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/task/context.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![unstable(feature = "futures_api", - reason = "futures in libcore are unstable", - issue = "50547")] - -use fmt; -use super::{Spawn, Waker, LocalWaker}; - -/// Information about the currently-running task. -/// -/// Contexts are always tied to the stack, since they are set up specifically -/// when performing a single `poll` step on a task. -pub struct Context<'a> { - local_waker: &'a LocalWaker, - spawner: &'a mut dyn Spawn, -} - -impl<'a> fmt::Debug for Context<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("Context") - .finish() - } -} - -impl<'a> Context<'a> { - /// Create a new task `Context` with the provided `local_waker`, `waker`, - /// and `spawner`. - #[inline] - pub fn new( - local_waker: &'a LocalWaker, - spawner: &'a mut dyn Spawn, - ) -> Context<'a> { - Context { local_waker, spawner } - } - - /// Get the `LocalWaker` associated with the current task. - #[inline] - pub fn local_waker(&self) -> &'a LocalWaker { - self.local_waker - } - - /// Get the `Waker` associated with the current task. - #[inline] - pub fn waker(&self) -> &'a Waker { - unsafe { &*(self.local_waker as *const LocalWaker as *const Waker) } - } - - /// Get the spawner associated with this task. - /// - /// This method is useful primarily if you want to explicitly handle - /// spawn failures. - #[inline] - pub fn spawner(&mut self) -> &mut dyn Spawn { - self.spawner - } - - /// Produce a context like the current one, but using the given waker - /// instead. - /// - /// This advanced method is primarily used when building "internal - /// schedulers" within a task, where you want to provide some customized - /// wakeup logic. - #[inline] - pub fn with_waker<'b>( - &'b mut self, - local_waker: &'b LocalWaker, - ) -> Context<'b> { - Context { - local_waker, - spawner: self.spawner, - } - } - - /// Produce a context like the current one, but using the given spawner - /// instead. - /// - /// This advanced method is primarily used when building "internal - /// schedulers" within a task. - #[inline] - pub fn with_spawner<'b, Sp: Spawn>( - &'b mut self, - spawner: &'b mut Sp, - ) -> Context<'b> { - Context { - local_waker: self.local_waker, - spawner, - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/task/mod.rs rustc-1.31.0+dfsg1+llvm/src/libcore/task/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/task/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/task/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,12 +14,6 @@ //! Types and Traits for working with asynchronous tasks. -mod context; -pub use self::context::Context; - -mod spawn; -pub use self::spawn::{Spawn, SpawnErrorKind, SpawnObjError, SpawnLocalObjError}; - mod poll; pub use self::poll::Poll; diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/task/spawn.rs rustc-1.31.0+dfsg1+llvm/src/libcore/task/spawn.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/task/spawn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/task/spawn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![unstable(feature = "futures_api", - reason = "futures in libcore are unstable", - issue = "50547")] - -use fmt; -use future::{FutureObj, LocalFutureObj}; - -/// Spawns tasks that poll futures to completion onto its associated task -/// executor. -/// -/// The term "task" refers to a kind of lightweight "thread". Task executors -/// are responsible for scheduling the execution of tasks on operating system -/// threads. -pub trait Spawn { - /// Spawns a new task with the given future. The future will be polled until - /// completion. - /// - /// # Errors - /// - /// The executor may be unable to spawn tasks, either because it has - /// been shut down or is resource-constrained. - fn spawn_obj( - &mut self, - future: FutureObj<'static, ()>, - ) -> Result<(), SpawnObjError>; - - /// Determines whether the executor is able to spawn new tasks. - /// - /// # Returns - /// - /// An `Ok` return means the executor is *likely* (but not guaranteed) - /// to accept a subsequent spawn attempt. Likewise, an `Err` return - /// means that `spawn` is likely, but not guaranteed, to yield an error. - #[inline] - fn status(&self) -> Result<(), SpawnErrorKind> { - Ok(()) - } -} - -/// Provides the reason that an executor was unable to spawn. -pub struct SpawnErrorKind { - _hidden: (), -} - -impl fmt::Debug for SpawnErrorKind { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_tuple("SpawnErrorKind") - .field(&"shutdown") - .finish() - } -} - -impl SpawnErrorKind { - /// Spawning is failing because the executor has been shut down. - pub fn shutdown() -> SpawnErrorKind { - SpawnErrorKind { _hidden: () } - } - - /// Check whether this error is the `shutdown` error. - pub fn is_shutdown(&self) -> bool { - true - } -} - -/// The result of a failed spawn -#[derive(Debug)] -pub struct SpawnObjError { - /// The kind of error - pub kind: SpawnErrorKind, - - /// The future for which spawning inside a task was attempted - pub future: FutureObj<'static, ()>, -} - -/// The result of a failed spawn -#[derive(Debug)] -pub struct SpawnLocalObjError { - /// The kind of error - pub kind: SpawnErrorKind, - - /// The future for which spawning inside a task was attempted - pub future: LocalFutureObj<'static, ()>, -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/task/wake.rs rustc-1.31.0+dfsg1+llvm/src/libcore/task/wake.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/task/wake.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/task/wake.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,7 +12,7 @@ reason = "futures in libcore are unstable", issue = "50547")] -use {fmt, mem}; +use fmt; use marker::Unpin; use ptr::NonNull; @@ -63,6 +63,20 @@ pub fn will_wake(&self, other: &Waker) -> bool { self.inner == other.inner } + + /// Returns whether or not this `Waker` and `other` `LocalWaker` awaken + /// the same task. + /// + /// This function works on a best-effort basis, and may return false even + /// when the `Waker`s would awaken the same task. However, if this function + /// returns true, it is guaranteed that the `Waker`s will awaken the same + /// task. + /// + /// This function is primarily used for optimization purposes. + #[inline] + pub fn will_wake_local(&self, other: &LocalWaker) -> bool { + self.will_wake(&other.0) + } } impl Clone for Waker { @@ -97,9 +111,8 @@ /// Task executors can use this type to implement more optimized singlethreaded wakeup /// behavior. #[repr(transparent)] -pub struct LocalWaker { - inner: NonNull, -} +#[derive(Clone)] +pub struct LocalWaker(Waker); impl Unpin for LocalWaker {} impl !Send for LocalWaker {} @@ -120,13 +133,31 @@ /// on the current thread. #[inline] pub unsafe fn new(inner: NonNull) -> Self { - LocalWaker { inner } + LocalWaker(Waker::new(inner)) + } + + /// Borrows this `LocalWaker` as a `Waker`. + /// + /// `Waker` is nearly identical to `LocalWaker`, but is threadsafe + /// (implements `Send` and `Sync`). + #[inline] + pub fn as_waker(&self) -> &Waker { + &self.0 + } + + /// Converts this `LocalWaker` into a `Waker`. + /// + /// `Waker` is nearly identical to `LocalWaker`, but is threadsafe + /// (implements `Send` and `Sync`). + #[inline] + pub fn into_waker(self) -> Waker { + self.0 } /// Wake up the task associated with this `LocalWaker`. #[inline] pub fn wake(&self) { - unsafe { self.inner.as_ref().wake_local() } + unsafe { self.0.inner.as_ref().wake_local() } } /// Returns whether or not this `LocalWaker` and `other` `LocalWaker` awaken the same task. @@ -139,7 +170,7 @@ /// This function is primarily used for optimization purposes. #[inline] pub fn will_wake(&self, other: &LocalWaker) -> bool { - self.inner == other.inner + self.0.will_wake(&other.0) } /// Returns whether or not this `LocalWaker` and `other` `Waker` awaken the same task. @@ -152,45 +183,29 @@ /// This function is primarily used for optimization purposes. #[inline] pub fn will_wake_nonlocal(&self, other: &Waker) -> bool { - self.inner == other.inner + self.0.will_wake(other) } } impl From for Waker { + /// Converts a `LocalWaker` into a `Waker`. + /// + /// This conversion turns a `!Sync` `LocalWaker` into a `Sync` `Waker`, allowing a wakeup + /// object to be sent to another thread, but giving up its ability to do specialized + /// thread-local wakeup behavior. #[inline] fn from(local_waker: LocalWaker) -> Self { - let inner = local_waker.inner; - mem::forget(local_waker); - Waker { inner } - } -} - -impl Clone for LocalWaker { - #[inline] - fn clone(&self) -> Self { - let waker = unsafe { self.inner.as_ref().clone_raw() }; - let inner = waker.inner; - mem::forget(waker); - LocalWaker { inner } + local_waker.0 } } impl fmt::Debug for LocalWaker { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("Waker") + f.debug_struct("LocalWaker") .finish() } } -impl Drop for LocalWaker { - #[inline] - fn drop(&mut self) { - unsafe { - self.inner.as_ref().drop_raw() - } - } -} - /// An unsafe trait for implementing custom memory management for a `Waker` or `LocalWaker`. /// /// A `Waker` conceptually is a cloneable trait object for `Wake`, and is diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/tests/iter.rs rustc-1.31.0+dfsg1+llvm/src/libcore/tests/iter.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/tests/iter.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/tests/iter.rs 2018-12-04 23:41:40.000000000 +0000 @@ -229,7 +229,7 @@ #[derive(Clone)] struct Test(Bigger); - impl<'a> Iterator for &'a mut Test { + impl Iterator for &mut Test { type Item = i32; fn next(&mut self) -> Option { Some(21) } fn nth(&mut self, n: usize) -> Option { @@ -1619,6 +1619,13 @@ } #[test] +fn test_step_by_skip() { + assert_eq!((0..640).step_by(128).skip(1).collect::>(), [128, 256, 384, 512]); + assert_eq!((0..=50).step_by(10).nth(3), Some(30)); + assert_eq!((200..=255u8).step_by(10).nth(3), Some(230)); +} + +#[test] fn test_range_inclusive_step() { assert_eq!((0..=50).step_by(10).collect::>(), [0, 10, 20, 30, 40, 50]); assert_eq!((0..=5).step_by(1).collect::>(), [0, 1, 2, 3, 4, 5]); diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/tests/lib.rs rustc-1.31.0+dfsg1+llvm/src/libcore/tests/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/tests/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/tests/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -19,6 +19,7 @@ #![feature(flt2dec)] #![feature(fmt_internals)] #![feature(hashmap_internals)] +#![cfg_attr(stage0, feature(impl_header_lifetime_elision))] #![feature(pattern)] #![feature(range_is_empty)] #![feature(raw)] @@ -33,12 +34,12 @@ #![feature(trusted_len)] #![feature(try_from)] #![feature(try_trait)] -#![feature(exact_chunks)] #![feature(align_offset)] #![feature(reverse_bits)] #![feature(inner_deref)] #![feature(slice_internals)] -#![feature(option_replace)] +#![feature(slice_partition_dedup)] +#![feature(copy_within)] extern crate core; extern crate test; diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/tests/nonzero.rs rustc-1.31.0+dfsg1+llvm/src/libcore/tests/nonzero.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/tests/nonzero.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/tests/nonzero.rs 2018-12-04 23:41:40.000000000 +0000 @@ -121,3 +121,10 @@ _ => panic!("Expected the const item as a pattern to match.") } } + +#[test] +fn test_from_nonzero() { + let nz = NonZeroU32::new(1).unwrap(); + let num: u32 = nz.into(); + assert_eq!(num, 1u32); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/tests/slice.rs rustc-1.31.0+dfsg1+llvm/src/libcore/tests/slice.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/tests/slice.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/tests/slice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -221,115 +221,115 @@ } #[test] -fn test_exact_chunks_count() { +fn test_chunks_exact_count() { let v: &[i32] = &[0, 1, 2, 3, 4, 5]; - let c = v.exact_chunks(3); + let c = v.chunks_exact(3); assert_eq!(c.count(), 2); let v2: &[i32] = &[0, 1, 2, 3, 4]; - let c2 = v2.exact_chunks(2); + let c2 = v2.chunks_exact(2); assert_eq!(c2.count(), 2); let v3: &[i32] = &[]; - let c3 = v3.exact_chunks(2); + let c3 = v3.chunks_exact(2); assert_eq!(c3.count(), 0); } #[test] -fn test_exact_chunks_nth() { +fn test_chunks_exact_nth() { let v: &[i32] = &[0, 1, 2, 3, 4, 5]; - let mut c = v.exact_chunks(2); + let mut c = v.chunks_exact(2); assert_eq!(c.nth(1).unwrap(), &[2, 3]); assert_eq!(c.next().unwrap(), &[4, 5]); let v2: &[i32] = &[0, 1, 2, 3, 4, 5, 6]; - let mut c2 = v2.exact_chunks(3); + let mut c2 = v2.chunks_exact(3); assert_eq!(c2.nth(1).unwrap(), &[3, 4, 5]); assert_eq!(c2.next(), None); } #[test] -fn test_exact_chunks_last() { +fn test_chunks_exact_last() { let v: &[i32] = &[0, 1, 2, 3, 4, 5]; - let c = v.exact_chunks(2); + let c = v.chunks_exact(2); assert_eq!(c.last().unwrap(), &[4, 5]); let v2: &[i32] = &[0, 1, 2, 3, 4]; - let c2 = v2.exact_chunks(2); + let c2 = v2.chunks_exact(2); assert_eq!(c2.last().unwrap(), &[2, 3]); } #[test] -fn test_exact_chunks_remainder() { +fn test_chunks_exact_remainder() { let v: &[i32] = &[0, 1, 2, 3, 4]; - let c = v.exact_chunks(2); + let c = v.chunks_exact(2); assert_eq!(c.remainder(), &[4]); } #[test] -fn test_exact_chunks_zip() { +fn test_chunks_exact_zip() { let v1: &[i32] = &[0, 1, 2, 3, 4]; let v2: &[i32] = &[6, 7, 8, 9, 10]; - let res = v1.exact_chunks(2) - .zip(v2.exact_chunks(2)) + let res = v1.chunks_exact(2) + .zip(v2.chunks_exact(2)) .map(|(a, b)| a.iter().sum::() + b.iter().sum::()) .collect::>(); assert_eq!(res, vec![14, 22]); } #[test] -fn test_exact_chunks_mut_count() { +fn test_chunks_exact_mut_count() { let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5]; - let c = v.exact_chunks_mut(3); + let c = v.chunks_exact_mut(3); assert_eq!(c.count(), 2); let v2: &mut [i32] = &mut [0, 1, 2, 3, 4]; - let c2 = v2.exact_chunks_mut(2); + let c2 = v2.chunks_exact_mut(2); assert_eq!(c2.count(), 2); let v3: &mut [i32] = &mut []; - let c3 = v3.exact_chunks_mut(2); + let c3 = v3.chunks_exact_mut(2); assert_eq!(c3.count(), 0); } #[test] -fn test_exact_chunks_mut_nth() { +fn test_chunks_exact_mut_nth() { let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5]; - let mut c = v.exact_chunks_mut(2); + let mut c = v.chunks_exact_mut(2); assert_eq!(c.nth(1).unwrap(), &[2, 3]); assert_eq!(c.next().unwrap(), &[4, 5]); let v2: &mut [i32] = &mut [0, 1, 2, 3, 4, 5, 6]; - let mut c2 = v2.exact_chunks_mut(3); + let mut c2 = v2.chunks_exact_mut(3); assert_eq!(c2.nth(1).unwrap(), &[3, 4, 5]); assert_eq!(c2.next(), None); } #[test] -fn test_exact_chunks_mut_last() { +fn test_chunks_exact_mut_last() { let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5]; - let c = v.exact_chunks_mut(2); + let c = v.chunks_exact_mut(2); assert_eq!(c.last().unwrap(), &[4, 5]); let v2: &mut [i32] = &mut [0, 1, 2, 3, 4]; - let c2 = v2.exact_chunks_mut(2); + let c2 = v2.chunks_exact_mut(2); assert_eq!(c2.last().unwrap(), &[2, 3]); } #[test] -fn test_exact_chunks_mut_remainder() { +fn test_chunks_exact_mut_remainder() { let v: &mut [i32] = &mut [0, 1, 2, 3, 4]; - let c = v.exact_chunks_mut(2); + let c = v.chunks_exact_mut(2); assert_eq!(c.into_remainder(), &[4]); } #[test] -fn test_exact_chunks_mut_zip() { +fn test_chunks_exact_mut_zip() { let v1: &mut [i32] = &mut [0, 1, 2, 3, 4]; let v2: &[i32] = &[6, 7, 8, 9, 10]; - for (a, b) in v1.exact_chunks_mut(2).zip(v2.exact_chunks(2)) { + for (a, b) in v1.chunks_exact_mut(2).zip(v2.chunks_exact(2)) { let sum = b.iter().sum::(); for v in a { *v += sum; @@ -339,6 +339,228 @@ } #[test] +fn test_rchunks_count() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let c = v.rchunks(3); + assert_eq!(c.count(), 2); + + let v2: &[i32] = &[0, 1, 2, 3, 4]; + let c2 = v2.rchunks(2); + assert_eq!(c2.count(), 3); + + let v3: &[i32] = &[]; + let c3 = v3.rchunks(2); + assert_eq!(c3.count(), 0); +} + +#[test] +fn test_rchunks_nth() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let mut c = v.rchunks(2); + assert_eq!(c.nth(1).unwrap(), &[2, 3]); + assert_eq!(c.next().unwrap(), &[0, 1]); + + let v2: &[i32] = &[0, 1, 2, 3, 4]; + let mut c2 = v2.rchunks(3); + assert_eq!(c2.nth(1).unwrap(), &[0, 1]); + assert_eq!(c2.next(), None); +} + +#[test] +fn test_rchunks_last() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let c = v.rchunks(2); + assert_eq!(c.last().unwrap()[1], 1); + + let v2: &[i32] = &[0, 1, 2, 3, 4]; + let c2 = v2.rchunks(2); + assert_eq!(c2.last().unwrap()[0], 0); +} + +#[test] +fn test_rchunks_zip() { + let v1: &[i32] = &[0, 1, 2, 3, 4]; + let v2: &[i32] = &[6, 7, 8, 9, 10]; + + let res = v1.rchunks(2) + .zip(v2.rchunks(2)) + .map(|(a, b)| a.iter().sum::() + b.iter().sum::()) + .collect::>(); + assert_eq!(res, vec![26, 18, 6]); +} + +#[test] +fn test_rchunks_mut_count() { + let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5]; + let c = v.rchunks_mut(3); + assert_eq!(c.count(), 2); + + let v2: &mut [i32] = &mut [0, 1, 2, 3, 4]; + let c2 = v2.rchunks_mut(2); + assert_eq!(c2.count(), 3); + + let v3: &mut [i32] = &mut []; + let c3 = v3.rchunks_mut(2); + assert_eq!(c3.count(), 0); +} + +#[test] +fn test_rchunks_mut_nth() { + let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5]; + let mut c = v.rchunks_mut(2); + assert_eq!(c.nth(1).unwrap(), &[2, 3]); + assert_eq!(c.next().unwrap(), &[0, 1]); + + let v2: &mut [i32] = &mut [0, 1, 2, 3, 4]; + let mut c2 = v2.rchunks_mut(3); + assert_eq!(c2.nth(1).unwrap(), &[0, 1]); + assert_eq!(c2.next(), None); +} + +#[test] +fn test_rchunks_mut_last() { + let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5]; + let c = v.rchunks_mut(2); + assert_eq!(c.last().unwrap(), &[0, 1]); + + let v2: &mut [i32] = &mut [0, 1, 2, 3, 4]; + let c2 = v2.rchunks_mut(2); + assert_eq!(c2.last().unwrap(), &[0]); +} + +#[test] +fn test_rchunks_mut_zip() { + let v1: &mut [i32] = &mut [0, 1, 2, 3, 4]; + let v2: &[i32] = &[6, 7, 8, 9, 10]; + + for (a, b) in v1.rchunks_mut(2).zip(v2.rchunks(2)) { + let sum = b.iter().sum::(); + for v in a { + *v += sum; + } + } + assert_eq!(v1, [6, 16, 17, 22, 23]); +} + +#[test] +fn test_rchunks_exact_count() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let c = v.rchunks_exact(3); + assert_eq!(c.count(), 2); + + let v2: &[i32] = &[0, 1, 2, 3, 4]; + let c2 = v2.rchunks_exact(2); + assert_eq!(c2.count(), 2); + + let v3: &[i32] = &[]; + let c3 = v3.rchunks_exact(2); + assert_eq!(c3.count(), 0); +} + +#[test] +fn test_rchunks_exact_nth() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let mut c = v.rchunks_exact(2); + assert_eq!(c.nth(1).unwrap(), &[2, 3]); + assert_eq!(c.next().unwrap(), &[0, 1]); + + let v2: &[i32] = &[0, 1, 2, 3, 4, 5, 6]; + let mut c2 = v2.rchunks_exact(3); + assert_eq!(c2.nth(1).unwrap(), &[1, 2, 3]); + assert_eq!(c2.next(), None); +} + +#[test] +fn test_rchunks_exact_last() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let c = v.rchunks_exact(2); + assert_eq!(c.last().unwrap(), &[0, 1]); + + let v2: &[i32] = &[0, 1, 2, 3, 4]; + let c2 = v2.rchunks_exact(2); + assert_eq!(c2.last().unwrap(), &[1, 2]); +} + +#[test] +fn test_rchunks_exact_remainder() { + let v: &[i32] = &[0, 1, 2, 3, 4]; + let c = v.rchunks_exact(2); + assert_eq!(c.remainder(), &[0]); +} + +#[test] +fn test_rchunks_exact_zip() { + let v1: &[i32] = &[0, 1, 2, 3, 4]; + let v2: &[i32] = &[6, 7, 8, 9, 10]; + + let res = v1.rchunks_exact(2) + .zip(v2.rchunks_exact(2)) + .map(|(a, b)| a.iter().sum::() + b.iter().sum::()) + .collect::>(); + assert_eq!(res, vec![26, 18]); +} + +#[test] +fn test_rchunks_exact_mut_count() { + let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5]; + let c = v.rchunks_exact_mut(3); + assert_eq!(c.count(), 2); + + let v2: &mut [i32] = &mut [0, 1, 2, 3, 4]; + let c2 = v2.rchunks_exact_mut(2); + assert_eq!(c2.count(), 2); + + let v3: &mut [i32] = &mut []; + let c3 = v3.rchunks_exact_mut(2); + assert_eq!(c3.count(), 0); +} + +#[test] +fn test_rchunks_exact_mut_nth() { + let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5]; + let mut c = v.rchunks_exact_mut(2); + assert_eq!(c.nth(1).unwrap(), &[2, 3]); + assert_eq!(c.next().unwrap(), &[0, 1]); + + let v2: &mut [i32] = &mut [0, 1, 2, 3, 4, 5, 6]; + let mut c2 = v2.rchunks_exact_mut(3); + assert_eq!(c2.nth(1).unwrap(), &[1, 2, 3]); + assert_eq!(c2.next(), None); +} + +#[test] +fn test_rchunks_exact_mut_last() { + let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5]; + let c = v.rchunks_exact_mut(2); + assert_eq!(c.last().unwrap(), &[0, 1]); + + let v2: &mut [i32] = &mut [0, 1, 2, 3, 4]; + let c2 = v2.rchunks_exact_mut(2); + assert_eq!(c2.last().unwrap(), &[1, 2]); +} + +#[test] +fn test_rchunks_exact_mut_remainder() { + let v: &mut [i32] = &mut [0, 1, 2, 3, 4]; + let c = v.rchunks_exact_mut(2); + assert_eq!(c.into_remainder(), &[0]); +} + +#[test] +fn test_rchunks_exact_mut_zip() { + let v1: &mut [i32] = &mut [0, 1, 2, 3, 4]; + let v2: &[i32] = &[6, 7, 8, 9, 10]; + + for (a, b) in v1.rchunks_exact_mut(2).zip(v2.rchunks_exact(2)) { + let sum = b.iter().sum::(); + for v in a { + *v += sum; + } + } + assert_eq!(v1, [0, 16, 17, 22, 23]); +} + +#[test] fn test_windows_count() { let v: &[i32] = &[0, 1, 2, 3, 4, 5]; let c = v.windows(3); @@ -1000,3 +1222,108 @@ assert_eq!(mid.as_ptr() as usize % mem::align_of::(), 0); } } + +#[test] +fn test_slice_partition_dedup_by() { + let mut slice: [i32; 9] = [1, -1, 2, 3, 1, -5, 5, -2, 2]; + + let (dedup, duplicates) = slice.partition_dedup_by(|a, b| a.abs() == b.abs()); + + assert_eq!(dedup, [1, 2, 3, 1, -5, -2]); + assert_eq!(duplicates, [5, -1, 2]); +} + +#[test] +fn test_slice_partition_dedup_empty() { + let mut slice: [i32; 0] = []; + + let (dedup, duplicates) = slice.partition_dedup(); + + assert_eq!(dedup, []); + assert_eq!(duplicates, []); +} + +#[test] +fn test_slice_partition_dedup_one() { + let mut slice = [12]; + + let (dedup, duplicates) = slice.partition_dedup(); + + assert_eq!(dedup, [12]); + assert_eq!(duplicates, []); +} + +#[test] +fn test_slice_partition_dedup_multiple_ident() { + let mut slice = [12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11]; + + let (dedup, duplicates) = slice.partition_dedup(); + + assert_eq!(dedup, [12, 11]); + assert_eq!(duplicates, [12, 12, 12, 12, 11, 11, 11, 11, 11]); +} + +#[test] +fn test_slice_partition_dedup_partialeq() { + #[derive(Debug)] + struct Foo(i32, i32); + + impl PartialEq for Foo { + fn eq(&self, other: &Foo) -> bool { + self.0 == other.0 + } + } + + let mut slice = [Foo(0, 1), Foo(0, 5), Foo(1, 7), Foo(1, 9)]; + + let (dedup, duplicates) = slice.partition_dedup(); + + assert_eq!(dedup, [Foo(0, 1), Foo(1, 7)]); + assert_eq!(duplicates, [Foo(0, 5), Foo(1, 9)]); +} + +#[test] +fn test_copy_within() { + // Start to end, with a RangeTo. + let mut bytes = *b"Hello, World!"; + bytes.copy_within(..3, 10); + assert_eq!(&bytes, b"Hello, WorHel"); + + // End to start, with a RangeFrom. + let mut bytes = *b"Hello, World!"; + bytes.copy_within(10.., 0); + assert_eq!(&bytes, b"ld!lo, World!"); + + // Overlapping, with a RangeInclusive. + let mut bytes = *b"Hello, World!"; + bytes.copy_within(0..=11, 1); + assert_eq!(&bytes, b"HHello, World"); + + // Whole slice, with a RangeFull. + let mut bytes = *b"Hello, World!"; + bytes.copy_within(.., 0); + assert_eq!(&bytes, b"Hello, World!"); +} + +#[test] +#[should_panic(expected = "src is out of bounds")] +fn test_copy_within_panics_src_too_long() { + let mut bytes = *b"Hello, World!"; + // The length is only 13, so 14 is out of bounds. + bytes.copy_within(10..14, 0); +} + +#[test] +#[should_panic(expected = "dest is out of bounds")] +fn test_copy_within_panics_dest_too_long() { + let mut bytes = *b"Hello, World!"; + // The length is only 13, so a slice of length 4 starting at index 10 is out of bounds. + bytes.copy_within(0..4, 10); +} +#[test] +#[should_panic(expected = "src end is before src start")] +fn test_copy_within_panics_src_inverted() { + let mut bytes = *b"Hello, World!"; + // 2 is greater than 1, so this range is invalid. + bytes.copy_within(2..1, 0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/libcore/time.rs rustc-1.31.0+dfsg1+llvm/src/libcore/time.rs --- rustc-1.30.0+dfsg1+llvm/src/libcore/time.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libcore/time.rs 2018-12-04 23:41:40.000000000 +0000 @@ -21,7 +21,7 @@ //! assert_eq!(Duration::new(5, 0), Duration::from_secs(5)); //! ``` -use fmt; +use {fmt, u64}; use iter::Sum; use ops::{Add, Sub, Mul, Div, AddAssign, SubAssign, MulAssign, DivAssign}; @@ -30,6 +30,7 @@ const NANOS_PER_MICRO: u32 = 1_000; const MILLIS_PER_SEC: u64 = 1_000; const MICROS_PER_SEC: u64 = 1_000_000; +const MAX_NANOS_F64: f64 = ((u64::MAX as u128 + 1)*(NANOS_PER_SEC as u128)) as f64; /// A `Duration` type to represent a span of time, typically used for system /// timeouts. @@ -108,6 +109,7 @@ /// ``` #[stable(feature = "duration", since = "1.3.0")] #[inline] + #[cfg_attr(not(stage0), rustc_promotable)] pub const fn from_secs(secs: u64) -> Duration { Duration { secs, nanos: 0 } } @@ -126,6 +128,7 @@ /// ``` #[stable(feature = "duration", since = "1.3.0")] #[inline] + #[cfg_attr(not(stage0), rustc_promotable)] pub const fn from_millis(millis: u64) -> Duration { Duration { secs: millis / MILLIS_PER_SEC, @@ -147,6 +150,7 @@ /// ``` #[stable(feature = "duration_from_micros", since = "1.27.0")] #[inline] + #[cfg_attr(not(stage0), rustc_promotable)] pub const fn from_micros(micros: u64) -> Duration { Duration { secs: micros / MICROS_PER_SEC, @@ -168,6 +172,7 @@ /// ``` #[stable(feature = "duration_extras", since = "1.27.0")] #[inline] + #[cfg_attr(not(stage0), rustc_promotable)] pub const fn from_nanos(nanos: u64) -> Duration { Duration { secs: nanos / (NANOS_PER_SEC as u64), @@ -458,6 +463,115 @@ None } } + + /// Returns the number of seconds contained by this `Duration` as `f64`. + /// + /// The returned value does include the fractional (nanosecond) part of the duration. + /// + /// # Examples + /// ``` + /// #![feature(duration_float)] + /// use std::time::Duration; + /// + /// let dur = Duration::new(2, 700_000_000); + /// assert_eq!(dur.as_float_secs(), 2.7); + /// ``` + #[unstable(feature = "duration_float", issue = "54361")] + #[inline] + pub fn as_float_secs(&self) -> f64 { + (self.secs as f64) + (self.nanos as f64) / (NANOS_PER_SEC as f64) + } + + /// Creates a new `Duration` from the specified number of seconds. + /// + /// # Panics + /// This constructor will panic if `secs` is not finite, negative or overflows `Duration`. + /// + /// # Examples + /// ``` + /// #![feature(duration_float)] + /// use std::time::Duration; + /// + /// let dur = Duration::from_float_secs(2.7); + /// assert_eq!(dur, Duration::new(2, 700_000_000)); + /// ``` + #[unstable(feature = "duration_float", issue = "54361")] + #[inline] + pub fn from_float_secs(secs: f64) -> Duration { + let nanos = secs * (NANOS_PER_SEC as f64); + if !nanos.is_finite() { + panic!("got non-finite value when converting float to duration"); + } + if nanos >= MAX_NANOS_F64 { + panic!("overflow when converting float to duration"); + } + if nanos < 0.0 { + panic!("underflow when converting float to duration"); + } + let nanos = nanos as u128; + Duration { + secs: (nanos / (NANOS_PER_SEC as u128)) as u64, + nanos: (nanos % (NANOS_PER_SEC as u128)) as u32, + } + } + + /// Multiply `Duration` by `f64`. + /// + /// # Panics + /// This method will panic if result is not finite, negative or overflows `Duration`. + /// + /// # Examples + /// ``` + /// #![feature(duration_float)] + /// use std::time::Duration; + /// + /// let dur = Duration::new(2, 700_000_000); + /// assert_eq!(dur.mul_f64(3.14), Duration::new(8, 478_000_000)); + /// assert_eq!(dur.mul_f64(3.14e5), Duration::new(847_800, 0)); + /// ``` + #[unstable(feature = "duration_float", issue = "54361")] + #[inline] + pub fn mul_f64(self, rhs: f64) -> Duration { + Duration::from_float_secs(rhs * self.as_float_secs()) + } + + /// Divide `Duration` by `f64`. + /// + /// # Panics + /// This method will panic if result is not finite, negative or overflows `Duration`. + /// + /// # Examples + /// ``` + /// #![feature(duration_float)] + /// use std::time::Duration; + /// + /// let dur = Duration::new(2, 700_000_000); + /// assert_eq!(dur.div_f64(3.14), Duration::new(0, 859_872_611)); + /// // note that truncation is used, not rounding + /// assert_eq!(dur.div_f64(3.14e5), Duration::new(0, 8_598)); + /// ``` + #[unstable(feature = "duration_float", issue = "54361")] + #[inline] + pub fn div_f64(self, rhs: f64) -> Duration { + Duration::from_float_secs(self.as_float_secs() / rhs) + } + + /// Divide `Duration` by `Duration` and return `f64`. + /// + /// # Examples + /// ``` + /// #![feature(duration_float)] + /// use std::time::Duration; + /// + /// let dur1 = Duration::new(2, 700_000_000); + /// let dur2 = Duration::new(5, 400_000_000); + /// assert_eq!(dur1.div_duration(dur2), 0.5); + /// ``` + #[unstable(feature = "duration_float", issue = "54361")] + #[inline] + pub fn div_duration(self, rhs: Duration) -> f64 { + self.as_float_secs() / rhs.as_float_secs() + } } #[stable(feature = "duration", since = "1.3.0")] @@ -501,6 +615,15 @@ } } +#[stable(feature = "symmetric_u32_duration_mul", since = "1.31.0")] +impl Mul for u32 { + type Output = Duration; + + fn mul(self, rhs: Duration) -> Duration { + rhs * self + } +} + #[stable(feature = "time_augmented_assignment", since = "1.9.0")] impl MulAssign for Duration { fn mul_assign(&mut self, rhs: u32) { diff -Nru rustc-1.30.0+dfsg1+llvm/src/libfmt_macros/lib.rs rustc-1.31.0+dfsg1+llvm/src/libfmt_macros/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/libfmt_macros/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libfmt_macros/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -20,8 +20,7 @@ html_playground_url = "https://play.rust-lang.org/", test(attr(deny(warnings))))] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] pub use self::Piece::*; pub use self::Position::*; @@ -289,7 +288,7 @@ self.cur.next(); Some(pos) } else { - let pos = pos + padding + 1; + let pos = pos + raw + 1; self.err(format!("expected `{:?}`, found `{:?}`", c, maybe), format!("expected `{}`", c), pos, diff -Nru rustc-1.30.0+dfsg1+llvm/src/libgraphviz/lib.rs rustc-1.31.0+dfsg1+llvm/src/libgraphviz/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/libgraphviz/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libgraphviz/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -49,7 +49,6 @@ //! ```rust //! #![feature(rustc_private)] //! -//! use graphviz::IntoCow; //! use std::io::Write; //! use graphviz as dot; //! @@ -84,12 +83,12 @@ //! } //! nodes.sort(); //! nodes.dedup(); -//! nodes.into_cow() +//! nodes.into() //! } //! //! fn edges(&'a self) -> dot::Edges<'a,Ed> { //! let &Edges(ref edges) = self; -//! (&edges[..]).into_cow() +//! (&edges[..]).into() //! } //! //! fn source(&self, e: &Ed) -> Nd { let &(s,_) = e; s } @@ -144,9 +143,8 @@ //! Since both the set of nodes and the set of edges are always //! constructed from scratch via iterators, we use the `collect()` method //! from the `Iterator` trait to collect the nodes and edges into freshly -//! constructed growable `Vec` values (rather use the `into_cow` -//! from the `IntoCow` trait as was used in the first example -//! above). +//! constructed growable `Vec` values (rather than using `Cow` as in the +//! first example above). //! //! The output from this example renders four nodes that make up the //! Hasse-diagram for the subsets of the set `{x, y}`. Each edge is @@ -288,13 +286,12 @@ html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(allow(unused_variables), deny(warnings))))] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(str_escape)] use self::LabelText::*; -use std::borrow::{Cow, ToOwned}; +use std::borrow::Cow; use std::io::prelude::*; use std::io; @@ -412,8 +409,8 @@ /// /// Passing an invalid string (containing spaces, brackets, /// quotes, ...) will return an empty `Err` value. - pub fn new>(name: Name) -> Result, ()> { - let name = name.into_cow(); + pub fn new>>(name: Name) -> Result, ()> { + let name = name.into(); match name.chars().next() { Some(c) if c.is_ascii_alphabetic() || c == '_' => {} _ => return Err(()), @@ -474,7 +471,7 @@ /// The label need not be unique, and may be the empty string; the /// default is in fact the empty string. fn edge_label(&'a self, _e: &Self::Edge) -> LabelText<'a> { - LabelStr("".into_cow()) + LabelStr("".into()) } /// Maps `n` to a style that will be used in the rendered output. @@ -498,16 +495,16 @@ } impl<'a> LabelText<'a> { - pub fn label>(s: S) -> LabelText<'a> { - LabelStr(s.into_cow()) + pub fn label>>(s: S) -> LabelText<'a> { + LabelStr(s.into()) } - pub fn escaped>(s: S) -> LabelText<'a> { - EscStr(s.into_cow()) + pub fn escaped>>(s: S) -> LabelText<'a> { + EscStr(s.into()) } - pub fn html>(s: S) -> LabelText<'a> { - HtmlStr(s.into_cow()) + pub fn html>>(s: S) -> LabelText<'a> { + HtmlStr(s.into()) } fn escape_char(c: char, mut f: F) @@ -551,7 +548,7 @@ EscStr(s) => s, LabelStr(s) => { if s.contains('\\') { - (&*s).escape_default().into_cow() + (&*s).escape_default().into() } else { s } @@ -571,7 +568,7 @@ let suffix = suffix.pre_escaped_content(); prefix.push_str(r"\n\n"); prefix.push_str(&suffix); - EscStr(prefix.into_cow()) + EscStr(prefix.into()) } } @@ -697,40 +694,6 @@ writeln!(w, "}}") } -pub trait IntoCow<'a, B: ?Sized> where B: ToOwned { - fn into_cow(self) -> Cow<'a, B>; -} - -impl<'a> IntoCow<'a, str> for String { - fn into_cow(self) -> Cow<'a, str> { - Cow::Owned(self) - } -} - -impl<'a> IntoCow<'a, str> for &'a str { - fn into_cow(self) -> Cow<'a, str> { - Cow::Borrowed(self) - } -} - -impl<'a> IntoCow<'a, str> for Cow<'a, str> { - fn into_cow(self) -> Cow<'a, str> { - self - } -} - -impl<'a, T: Clone> IntoCow<'a, [T]> for Vec { - fn into_cow(self) -> Cow<'a, [T]> { - Cow::Owned(self) - } -} - -impl<'a, T: Clone> IntoCow<'a, [T]> for &'a [T] { - fn into_cow(self) -> Cow<'a, [T]> { - Cow::Borrowed(self) - } -} - #[cfg(test)] mod tests { use self::NodeLabels::*; @@ -738,7 +701,6 @@ use super::LabelText::{self, LabelStr, EscStr, HtmlStr}; use std::io; use std::io::prelude::*; - use IntoCow; /// each node is an index in a vector in the graph. type Node = usize; @@ -853,12 +815,12 @@ } fn node_label(&'a self, n: &Node) -> LabelText<'a> { match self.node_labels[*n] { - Some(ref l) => LabelStr(l.into_cow()), + Some(l) => LabelStr(l.into()), None => LabelStr(id_name(n).name()), } } fn edge_label(&'a self, e: &&'a Edge) -> LabelText<'a> { - LabelStr(e.label.into_cow()) + LabelStr(e.label.into()) } fn node_style(&'a self, n: &Node) -> Style { self.node_styles[*n] diff -Nru rustc-1.30.0+dfsg1+llvm/src/libpanic_abort/lib.rs rustc-1.31.0+dfsg1+llvm/src/libpanic_abort/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/libpanic_abort/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libpanic_abort/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -24,15 +24,13 @@ #![feature(core_intrinsics)] #![feature(libc)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(panic_runtime)] #![feature(staged_api)] #![feature(rustc_attrs)] // Rust's "try" function, but if we're aborting on panics we just call the // function as there's nothing else we need to do here. -#[cfg_attr(stage0, no_mangle)] #[rustc_std_internal_symbol] pub unsafe extern fn __rust_maybe_catch_panic(f: fn(*mut u8), data: *mut u8, @@ -52,7 +50,6 @@ // which would break compat with XP. For now just use `intrinsics::abort` which // will kill us with an illegal instruction, which will do a good enough job for // now hopefully. -#[cfg_attr(stage0, no_mangle)] #[rustc_std_internal_symbol] pub unsafe extern fn __rust_start_panic(_payload: usize) -> u32 { abort(); @@ -99,9 +96,14 @@ // runtime at all. pub mod personalities { #[no_mangle] - #[cfg(not(all(target_os = "windows", - target_env = "gnu", - target_arch = "x86_64")))] + #[cfg(not(any( + target_arch = "wasm32", + all( + target_os = "windows", + target_env = "gnu", + target_arch = "x86_64", + ), + )))] pub extern fn rust_eh_personality() {} // On x86_64-pc-windows-gnu we use our own personality function that needs diff -Nru rustc-1.30.0+dfsg1+llvm/src/libpanic_unwind/lib.rs rustc-1.31.0+dfsg1+llvm/src/libpanic_unwind/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/libpanic_unwind/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libpanic_unwind/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -34,8 +34,7 @@ #![feature(core_intrinsics)] #![feature(lang_items)] #![feature(libc)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(panic_unwind)] #![feature(raw)] #![feature(staged_api)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/libproc_macro/lib.rs rustc-1.31.0+dfsg1+llvm/src/libproc_macro/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/libproc_macro/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libproc_macro/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -27,8 +27,7 @@ test(no_crate_inject, attr(deny(warnings))), test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(rustc_private)] #![feature(staged_api)] #![feature(lang_items)] @@ -49,7 +48,7 @@ mod diagnostic; #[unstable(feature = "proc_macro_diagnostic", issue = "54140")] -pub use diagnostic::{Diagnostic, Level}; +pub use diagnostic::{Diagnostic, Level, MultiSpan}; use std::{ascii, fmt, iter}; use std::path::PathBuf; @@ -143,7 +142,7 @@ } } -#[unstable(feature = "proc_macro_quote", issue = "38356")] +#[unstable(feature = "proc_macro_quote", issue = "54722")] pub use quote::{quote, quote_span}; /// Creates a token stream containing a single token tree. @@ -253,7 +252,7 @@ /// To quote `$` itself, use `$$`. /// /// This is a dummy macro, the actual implementation is in `quote::quote`.` -#[unstable(feature = "proc_macro_quote", issue = "38356")] +#[unstable(feature = "proc_macro_quote", issue = "54722")] #[macro_export] macro_rules! quote { () => {} } @@ -284,7 +283,7 @@ impl Span { /// A span that resolves at the macro definition site. - #[unstable(feature = "proc_macro_span", issue = "38356")] + #[unstable(feature = "proc_macro_def_site", issue = "54724")] pub fn def_site() -> Span { ::__internal::with_sess(|_, data| data.def_site) } @@ -299,7 +298,7 @@ } /// The original source file into which this span points. - #[unstable(feature = "proc_macro_span", issue = "38356")] + #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn source_file(&self) -> SourceFile { SourceFile { source_file: __internal::lookup_char_pos(self.0.lo()).file, @@ -308,7 +307,7 @@ /// The `Span` for the tokens in the previous macro expansion from which /// `self` was generated from, if any. - #[unstable(feature = "proc_macro_span", issue = "38356")] + #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn parent(&self) -> Option { self.0.parent().map(Span) } @@ -316,13 +315,13 @@ /// The span for the origin source code that `self` was generated from. If /// this `Span` wasn't generated from other macro expansions then the return /// value is the same as `*self`. - #[unstable(feature = "proc_macro_span", issue = "38356")] + #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn source(&self) -> Span { Span(self.0.source_callsite()) } /// Get the starting line/column in the source file for this span. - #[unstable(feature = "proc_macro_span", issue = "38356")] + #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn start(&self) -> LineColumn { let loc = __internal::lookup_char_pos(self.0.lo()); LineColumn { @@ -332,7 +331,7 @@ } /// Get the ending line/column in the source file for this span. - #[unstable(feature = "proc_macro_span", issue = "38356")] + #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn end(&self) -> LineColumn { let loc = __internal::lookup_char_pos(self.0.hi()); LineColumn { @@ -344,7 +343,7 @@ /// Create a new span encompassing `self` and `other`. /// /// Returns `None` if `self` and `other` are from different files. - #[unstable(feature = "proc_macro_span", issue = "38356")] + #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn join(&self, other: Span) -> Option { let self_loc = __internal::lookup_char_pos(self.0.lo()); let other_loc = __internal::lookup_char_pos(other.0.lo()); @@ -356,20 +355,20 @@ /// Creates a new span with the same line/column information as `self` but /// that resolves symbols as though it were at `other`. - #[unstable(feature = "proc_macro_span", issue = "38356")] + #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn resolved_at(&self, other: Span) -> Span { Span(self.0.with_ctxt(other.0.ctxt())) } /// Creates a new span with the same name resolution behavior as `self` but /// with the line/column information of `other`. - #[unstable(feature = "proc_macro_span", issue = "38356")] + #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn located_at(&self, other: Span) -> Span { other.resolved_at(*self) } /// Compares to spans to see if they're equal. - #[unstable(feature = "proc_macro_span", issue = "38356")] + #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn eq(&self, other: &Span) -> bool { self.0 == other.0 } @@ -392,33 +391,33 @@ } /// A line-column pair representing the start or end of a `Span`. -#[unstable(feature = "proc_macro_span", issue = "38356")] +#[unstable(feature = "proc_macro_span", issue = "54725")] #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct LineColumn { /// The 1-indexed line in the source file on which the span starts or ends (inclusive). - #[unstable(feature = "proc_macro_span", issue = "38356")] + #[unstable(feature = "proc_macro_span", issue = "54725")] pub line: usize, /// The 0-indexed column (in UTF-8 characters) in the source file on which /// the span starts or ends (inclusive). - #[unstable(feature = "proc_macro_span", issue = "38356")] + #[unstable(feature = "proc_macro_span", issue = "54725")] pub column: usize } -#[unstable(feature = "proc_macro_span", issue = "38356")] +#[unstable(feature = "proc_macro_span", issue = "54725")] impl !Send for LineColumn {} -#[unstable(feature = "proc_macro_span", issue = "38356")] +#[unstable(feature = "proc_macro_span", issue = "54725")] impl !Sync for LineColumn {} /// The source file of a given `Span`. -#[unstable(feature = "proc_macro_span", issue = "38356")] +#[unstable(feature = "proc_macro_span", issue = "54725")] #[derive(Clone)] pub struct SourceFile { source_file: Lrc, } -#[unstable(feature = "proc_macro_span", issue = "38356")] +#[unstable(feature = "proc_macro_span", issue = "54725")] impl !Send for SourceFile {} -#[unstable(feature = "proc_macro_span", issue = "38356")] +#[unstable(feature = "proc_macro_span", issue = "54725")] impl !Sync for SourceFile {} impl SourceFile { @@ -432,7 +431,7 @@ /// the command line, the path as given may not actually be valid. /// /// [`is_real`]: #method.is_real - #[unstable(feature = "proc_macro_span", issue = "38356")] + #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn path(&self) -> PathBuf { match self.source_file.name { FileName::Real(ref path) => path.clone(), @@ -442,7 +441,7 @@ /// Returns `true` if this source file is a real source file, and not generated by an external /// macro's expansion. - #[unstable(feature = "proc_macro_span", issue = "38356")] + #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn is_real(&self) -> bool { // This is a hack until intercrate spans are implemented and we can have real source files // for spans generated in external macros. @@ -452,7 +451,7 @@ } -#[unstable(feature = "proc_macro_span", issue = "38356")] +#[unstable(feature = "proc_macro_span", issue = "54725")] impl fmt::Debug for SourceFile { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("SourceFile") @@ -462,14 +461,14 @@ } } -#[unstable(feature = "proc_macro_span", issue = "38356")] +#[unstable(feature = "proc_macro_span", issue = "54725")] impl PartialEq for SourceFile { fn eq(&self, other: &Self) -> bool { Lrc::ptr_eq(&self.source_file, &other.source_file) } } -#[unstable(feature = "proc_macro_span", issue = "38356")] +#[unstable(feature = "proc_macro_span", issue = "54725")] impl Eq for SourceFile {} /// A single token or a delimited sequence of token trees (e.g. `[1, (), ..]`). @@ -680,7 +679,7 @@ /// pub fn span_open(&self) -> Span { /// ^ /// ``` - #[unstable(feature = "proc_macro_span", issue = "38356")] + #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn span_open(&self) -> Span { Span(self.span.open) } @@ -691,7 +690,7 @@ /// pub fn span_close(&self) -> Span { /// ^ /// ``` - #[unstable(feature = "proc_macro_span", issue = "38356")] + #[unstable(feature = "proc_macro_span", issue = "54725")] pub fn span_close(&self) -> Span { Span(self.span.close) } @@ -882,7 +881,7 @@ } /// Same as `Ident::new`, but creates a raw identifier (`r#ident`). - #[unstable(feature = "proc_macro_raw_ident", issue = "38356")] + #[unstable(feature = "proc_macro_raw_ident", issue = "54723")] pub fn new_raw(string: &str, span: Span) -> Ident { if !Ident::is_valid(string) { panic!("`{:?}` is not a valid identifier", string) diff -Nru rustc-1.30.0+dfsg1+llvm/src/libproc_macro/quote.rs rustc-1.31.0+dfsg1+llvm/src/libproc_macro/quote.rs --- rustc-1.30.0+dfsg1+llvm/src/libproc_macro/quote.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libproc_macro/quote.rs 2018-12-04 23:41:40.000000000 +0000 @@ -70,7 +70,7 @@ /// This is the actual `quote!()` proc macro. /// /// It is manually loaded in `CStore::load_macro_untracked`. -#[unstable(feature = "proc_macro_quote", issue = "38356")] +#[unstable(feature = "proc_macro_quote", issue = "54722")] pub fn quote(stream: TokenStream) -> TokenStream { if stream.is_empty() { return quote!(::TokenStream::new()); @@ -144,7 +144,7 @@ /// Quote a `Span` into a `TokenStream`. /// This is needed to implement a custom quoter. -#[unstable(feature = "proc_macro_quote", issue = "38356")] +#[unstable(feature = "proc_macro_quote", issue = "54722")] pub fn quote_span(_: Span) -> TokenStream { quote!(::Span::def_site()) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libprofiler_builtins/lib.rs rustc-1.31.0+dfsg1+llvm/src/libprofiler_builtins/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/libprofiler_builtins/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libprofiler_builtins/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,6 +15,5 @@ reason = "internal implementation detail of rustc right now", issue = "0")] #![allow(unused_features)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(staged_api)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/build.rs rustc-1.31.0+dfsg1+llvm/src/librustc/build.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/build.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/build.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::env; + fn main() { println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-env-changed=CFG_LIBDIR_RELATIVE"); println!("cargo:rerun-if-env-changed=CFG_COMPILER_HOST_TRIPLE"); + println!("cargo:rerun-if-env-changed=RUSTC_VERIFY_LLVM_IR"); + + if env::var_os("RUSTC_VERIFY_LLVM_IR").is_some() { + println!("cargo:rustc-cfg=always_verify_llvm_ir"); + } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/librustc/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/librustc/Cargo.toml 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/Cargo.toml 2018-12-04 23:41:40.000000000 +0000 @@ -31,7 +31,7 @@ backtrace = "0.3.3" parking_lot = "0.6" byteorder = { version = "1.1", features = ["i128"]} -chalk-engine = { version = "0.7.0", default-features=false } +chalk-engine = { version = "0.8.0", default-features=false } rustc_fs_util = { path = "../librustc_fs_util" } smallvec = { version = "0.6.5", features = ["union"] } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/cfg/graphviz.rs rustc-1.31.0+dfsg1+llvm/src/librustc/cfg/graphviz.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/cfg/graphviz.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/cfg/graphviz.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,7 +13,6 @@ // For clarity, rename the graphviz crate locally to dot. use graphviz as dot; -use graphviz::IntoCow; use cfg; use hir; @@ -71,21 +70,21 @@ fn node_label(&'a self, &(i, n): &Node<'a>) -> dot::LabelText<'a> { if i == self.cfg.entry { - dot::LabelText::LabelStr("entry".into_cow()) + dot::LabelText::LabelStr("entry".into()) } else if i == self.cfg.exit { - dot::LabelText::LabelStr("exit".into_cow()) + dot::LabelText::LabelStr("exit".into()) } else if n.data.id() == hir::DUMMY_ITEM_LOCAL_ID { - dot::LabelText::LabelStr("(dummy_node)".into_cow()) + dot::LabelText::LabelStr("(dummy_node)".into()) } else { let s = self.local_id_to_string(n.data.id()); - dot::LabelText::EscStr(s.into_cow()) + dot::LabelText::EscStr(s.into()) } } fn edge_label(&self, e: &Edge<'a>) -> dot::LabelText<'a> { let mut label = String::new(); if !self.labelled_edges { - return dot::LabelText::EscStr(label.into_cow()); + return dot::LabelText::EscStr(label.into()); } let mut put_one = false; for (i, &id) in e.data.exiting_scopes.iter().enumerate() { @@ -99,7 +98,7 @@ i, &s[..])); } - dot::LabelText::EscStr(label.into_cow()) + dot::LabelText::EscStr(label.into()) } } @@ -109,7 +108,7 @@ fn nodes(&'a self) -> dot::Nodes<'a, Node<'a>> { let mut v = Vec::new(); self.graph.each_node(|i, nd| { v.push((i, nd)); true }); - v.into_cow() + v.into() } fn edges(&'a self) -> dot::Edges<'a, Edge<'a>> { self.graph.all_edges().iter().collect() diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/dep_graph/cgu_reuse_tracker.rs rustc-1.31.0+dfsg1+llvm/src/librustc/dep_graph/cgu_reuse_tracker.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/dep_graph/cgu_reuse_tracker.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/dep_graph/cgu_reuse_tracker.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,145 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Some facilities for tracking how codegen-units are reused during incremental +//! compilition. This is used for incremental compiliation tests and debug +//! output. + +use session::Session; +use rustc_data_structures::fx::FxHashMap; +use std::sync::{Arc, Mutex}; +use syntax_pos::Span; + +#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)] +pub enum CguReuse { + No, + PreLto, + PostLto, +} + +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum ComparisonKind { + Exact, + AtLeast, +} + +struct TrackerData { + actual_reuse: FxHashMap, + expected_reuse: FxHashMap, +} + +// Span does not implement `Send`, so we can't just store it in the shared +// `TrackerData` object. Instead of splitting up `TrackerData` into shared and +// non-shared parts (which would be complicated), we just mark the `Span` here +// explicitly as `Send`. That's safe because the span data here is only ever +// accessed from the main thread. +struct SendSpan(Span); +unsafe impl Send for SendSpan {} + +#[derive(Clone)] +pub struct CguReuseTracker { + data: Option>>, +} + +impl CguReuseTracker { + pub fn new() -> CguReuseTracker { + let data = TrackerData { + actual_reuse: Default::default(), + expected_reuse: Default::default(), + }; + + CguReuseTracker { + data: Some(Arc::new(Mutex::new(data))), + } + } + + pub fn new_disabled() -> CguReuseTracker { + CguReuseTracker { + data: None, + } + } + + pub fn set_actual_reuse(&self, cgu_name: &str, kind: CguReuse) { + if let Some(ref data) = self.data { + debug!("set_actual_reuse({:?}, {:?})", cgu_name, kind); + + let prev_reuse = data.lock() + .unwrap() + .actual_reuse + .insert(cgu_name.to_string(), kind); + + if let Some(prev_reuse) = prev_reuse { + // The only time it is legal to overwrite reuse state is when + // we discover during ThinLTO that we can actually reuse the + // post-LTO version of a CGU. + assert_eq!(prev_reuse, CguReuse::PreLto); + } + } + } + + pub fn set_expectation(&self, + cgu_name: &str, + cgu_user_name: &str, + error_span: Span, + expected_reuse: CguReuse, + comparison_kind: ComparisonKind) { + if let Some(ref data) = self.data { + debug!("set_expectation({:?}, {:?}, {:?})", cgu_name, + expected_reuse, + comparison_kind); + let mut data = data.lock().unwrap(); + + data.expected_reuse.insert(cgu_name.to_string(), + (cgu_user_name.to_string(), + SendSpan(error_span), + expected_reuse, + comparison_kind)); + } + } + + pub fn check_expected_reuse(&self, sess: &Session) { + if let Some(ref data) = self.data { + let data = data.lock().unwrap(); + + for (cgu_name, &(ref cgu_user_name, + ref error_span, + expected_reuse, + comparison_kind)) in &data.expected_reuse { + if let Some(&actual_reuse) = data.actual_reuse.get(cgu_name) { + let (error, at_least) = match comparison_kind { + ComparisonKind::Exact => { + (expected_reuse != actual_reuse, false) + } + ComparisonKind::AtLeast => { + (actual_reuse < expected_reuse, true) + } + }; + + if error { + let at_least = if at_least { "at least " } else { "" }; + let msg = format!("CGU-reuse for `{}` is `{:?}` but \ + should be {}`{:?}`", + cgu_user_name, + actual_reuse, + at_least, + expected_reuse); + sess.span_err(error_span.0, &msg); + } + } else { + let msg = format!("CGU-reuse for `{}` (mangled: `{}`) was \ + not recorded", + cgu_user_name, + cgu_name); + sess.span_fatal(error_span.0, &msg); + } + } + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/dep_graph/dep_node.rs rustc-1.31.0+dfsg1+llvm/src/librustc/dep_graph/dep_node.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/dep_graph/dep_node.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/dep_graph/dep_node.rs 2018-12-04 23:41:40.000000000 +0000 @@ -70,9 +70,11 @@ use std::fmt; use std::hash::Hash; use syntax_pos::symbol::InternedString; +use traits; use traits::query::{ - CanonicalProjectionGoal, CanonicalTyGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpSubtypeGoal, - CanonicalPredicateGoal, CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpNormalizeGoal, + CanonicalProjectionGoal, CanonicalTyGoal, CanonicalTypeOpAscribeUserTypeGoal, + CanonicalTypeOpEqGoal, CanonicalTypeOpSubtypeGoal, CanonicalPredicateGoal, + CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpNormalizeGoal, }; use ty::{TyCtxt, FnSig, Instance, InstanceDef, ParamEnv, ParamEnvAnd, Predicate, PolyFnSig, PolyTraitRef, Ty}; @@ -331,7 +333,7 @@ /// refers to something from the previous compilation session that /// has been removed. #[inline] - pub fn extract_def_id(&self, tcx: TyCtxt) -> Option { + pub fn extract_def_id(&self, tcx: TyCtxt<'_, '_, '_>) -> Option { if self.kind.can_reconstruct_query_key() { let def_path_hash = DefPathHash(self.hash); tcx.def_path_hash_to_def_id.as_ref()? @@ -386,7 +388,7 @@ } impl fmt::Debug for DepNode { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{:?}", self.kind)?; if !self.kind.has_params() && !self.kind.is_anon() { @@ -424,7 +426,7 @@ impl DefId { #[inline] - pub fn to_dep_node(self, tcx: TyCtxt, kind: DepKind) -> DepNode { + pub fn to_dep_node(self, tcx: TyCtxt<'_, '_, '_>, kind: DepKind) -> DepNode { DepNode::from_def_path_hash(kind, tcx.def_path_hash(self)) } } @@ -515,6 +517,7 @@ [] ItemVarianceConstraints(DefId), [] ItemVariances(DefId), [] IsConstFn(DefId), + [] IsPromotableConstFn(DefId), [] IsForeignItem(DefId), [] TypeParamPredicates { item_id: DefId, param_id: DefId }, [] SizedConstraint(DefId), @@ -549,6 +552,7 @@ [anon] TraitSelect, [] ParamEnv(DefId), + [] Environment(DefId), [] DescribeDef(DefId), // FIXME(mw): DefSpans are not really inputs since they are derived from @@ -651,6 +655,7 @@ [] ImpliedOutlivesBounds(CanonicalTyGoal<'tcx>), [] DropckOutlives(CanonicalTyGoal<'tcx>), [] EvaluateObligation(CanonicalPredicateGoal<'tcx>), + [] TypeOpAscribeUserType(CanonicalTypeOpAscribeUserTypeGoal<'tcx>), [] TypeOpEq(CanonicalTypeOpEqGoal<'tcx>), [] TypeOpSubtype(CanonicalTypeOpSubtypeGoal<'tcx>), [] TypeOpProvePredicate(CanonicalTypeOpProvePredicateGoal<'tcx>), @@ -668,7 +673,7 @@ [input] Features, [] ProgramClausesFor(DefId), - [] ProgramClausesForEnv(ParamEnv<'tcx>), + [] ProgramClausesForEnv(traits::Environment<'tcx>), [] WasmImportModuleMap(CrateNum), [] ForeignModules(CrateNum), @@ -714,7 +719,7 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for DefId { const CAN_RECONSTRUCT_QUERY_KEY: bool = true; - fn to_fingerprint(&self, tcx: TyCtxt) -> Fingerprint { + fn to_fingerprint(&self, tcx: TyCtxt<'_, '_, '_>) -> Fingerprint { tcx.def_path_hash(*self).0 } @@ -726,7 +731,7 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for DefIndex { const CAN_RECONSTRUCT_QUERY_KEY: bool = true; - fn to_fingerprint(&self, tcx: TyCtxt) -> Fingerprint { + fn to_fingerprint(&self, tcx: TyCtxt<'_, '_, '_>) -> Fingerprint { tcx.hir.definitions().def_path_hash(*self).0 } @@ -738,7 +743,7 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for CrateNum { const CAN_RECONSTRUCT_QUERY_KEY: bool = true; - fn to_fingerprint(&self, tcx: TyCtxt) -> Fingerprint { + fn to_fingerprint(&self, tcx: TyCtxt<'_, '_, '_>) -> Fingerprint { let def_id = DefId { krate: *self, index: CRATE_DEF_INDEX, @@ -757,7 +762,7 @@ // We actually would not need to specialize the implementation of this // method but it's faster to combine the hashes than to instantiate a full // hashing context and stable-hashing state. - fn to_fingerprint(&self, tcx: TyCtxt) -> Fingerprint { + fn to_fingerprint(&self, tcx: TyCtxt<'_, '_, '_>) -> Fingerprint { let (def_id_0, def_id_1) = *self; let def_path_hash_0 = tcx.def_path_hash(def_id_0); @@ -781,7 +786,7 @@ // We actually would not need to specialize the implementation of this // method but it's faster to combine the hashes than to instantiate a full // hashing context and stable-hashing state. - fn to_fingerprint(&self, tcx: TyCtxt) -> Fingerprint { + fn to_fingerprint(&self, tcx: TyCtxt<'_, '_, '_>) -> Fingerprint { let HirId { owner, local_id: ItemLocalId(local_id), diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/dep_graph/dep_tracking_map.rs rustc-1.31.0+dfsg1+llvm/src/librustc/dep_graph/dep_tracking_map.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/dep_graph/dep_tracking_map.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/dep_graph/dep_tracking_map.rs 2018-12-04 23:41:40.000000000 +0000 @@ -36,7 +36,7 @@ DepTrackingMap { phantom: PhantomData, graph, - map: FxHashMap(), + map: Default::default(), } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/dep_graph/graph.rs rustc-1.31.0+dfsg1+llvm/src/librustc/dep_graph/graph.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/dep_graph/graph.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/dep_graph/graph.rs 2018-12-04 23:41:40.000000000 +0000 @@ -101,11 +101,11 @@ DepGraph { data: Some(Lrc::new(DepGraphData { previous_work_products: prev_work_products, - dep_node_debug: Lock::new(FxHashMap()), + dep_node_debug: Lock::new(Default::default()), current: Lock::new(CurrentDepGraph::new()), previous: prev_graph, colors: Lock::new(DepNodeColorMap::new(prev_graph_node_count)), - loaded_from_cache: Lock::new(FxHashMap()), + loaded_from_cache: Lock::new(Default::default()), })), fingerprints: Lrc::new(Lock::new(fingerprints)), } @@ -209,7 +209,7 @@ |key| OpenTask::Regular(Lock::new(RegularOpenTask { node: key, reads: SmallVec::new(), - read_set: FxHashSet(), + read_set: Default::default(), })), |data, key, task| data.borrow_mut().complete_task(key, task)) } @@ -353,7 +353,7 @@ let (result, open_task) = ty::tls::with_context(|icx| { let task = OpenTask::Anon(Lock::new(AnonOpenTask { reads: SmallVec::new(), - read_set: FxHashSet(), + read_set: Default::default(), })); let r = { @@ -937,7 +937,7 @@ CurrentDepGraph { nodes: IndexVec::new(), edges: IndexVec::new(), - node_to_node_index: FxHashMap(), + node_to_node_index: Default::default(), anon_id_seed: stable_hasher.finish(), forbidden_edge, total_read_count: 0, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/dep_graph/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/dep_graph/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/dep_graph/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/dep_graph/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,6 +16,7 @@ mod query; mod safe; mod serialized; +pub mod cgu_reuse_tracker; pub use self::dep_tracking_map::{DepTrackingMap, DepTrackingMapConfig}; pub use self::dep_node::{DepNode, DepKind, DepConstructor, WorkProductId, label_strs}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/dep_graph/prev.rs rustc-1.31.0+dfsg1+llvm/src/librustc/dep_graph/prev.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/dep_graph/prev.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/dep_graph/prev.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,7 +13,7 @@ use super::dep_node::DepNode; use super::serialized::{SerializedDepGraph, SerializedDepNodeIndex}; -#[derive(Debug, RustcEncodable, RustcDecodable)] +#[derive(Debug, RustcEncodable, RustcDecodable, Default)] pub struct PreviousDepGraph { data: SerializedDepGraph, index: FxHashMap, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/dep_graph/query.rs rustc-1.31.0+dfsg1+llvm/src/librustc/dep_graph/query.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/dep_graph/query.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/dep_graph/query.rs 2018-12-04 23:41:40.000000000 +0000 @@ -25,7 +25,7 @@ edges: &[(DepNode, DepNode)]) -> DepGraphQuery { let mut graph = Graph::with_capacity(nodes.len(), edges.len()); - let mut indices = FxHashMap(); + let mut indices = FxHashMap::default(); for node in nodes { indices.insert(node.clone(), graph.add_node(node.clone())); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/dep_graph/serialized.rs rustc-1.31.0+dfsg1+llvm/src/librustc/dep_graph/serialized.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/dep_graph/serialized.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/dep_graph/serialized.rs 2018-12-04 23:41:40.000000000 +0000 @@ -19,7 +19,7 @@ } /// Data for use when recompiling the **current crate**. -#[derive(Debug, RustcEncodable, RustcDecodable)] +#[derive(Debug, RustcEncodable, RustcDecodable, Default)] pub struct SerializedDepGraph { /// The set of all DepNodes in the graph pub nodes: IndexVec, @@ -36,16 +36,6 @@ } impl SerializedDepGraph { - - pub fn new() -> SerializedDepGraph { - SerializedDepGraph { - nodes: IndexVec::new(), - fingerprints: IndexVec::new(), - edge_list_indices: IndexVec::new(), - edge_list_data: Vec::new(), - } - } - #[inline] pub fn edge_targets_from(&self, source: SerializedDepNodeIndex) diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/diagnostics.rs rustc-1.31.0+dfsg1+llvm/src/librustc/diagnostics.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/diagnostics.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/diagnostics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -637,8 +637,8 @@ ```compile_fail,E0152 #![feature(lang_items)] -#[lang = "panic_impl"] -struct Foo; // error: duplicate lang item found: `panic_impl` +#[lang = "arc"] +struct Foo; // error: duplicate lang item found: `arc` ``` Lang items are already implemented in the standard library. Unless you are @@ -1232,41 +1232,54 @@ "##, E0309: r##" -Types in type definitions have lifetimes associated with them that represent -how long the data stored within them is guaranteed to be live. This lifetime -must be as long as the data needs to be alive, and missing the constraint that -denotes this will cause this error. +The type definition contains some field whose type +requires an outlives annotation. Outlives annotations +(e.g., `T: 'a`) are used to guarantee that all the data in T is valid +for at least the lifetime `'a`. This scenario most commonly +arises when the type contains an associated type reference +like `>::Output`, as shown in this example: ```compile_fail,E0309 -// This won't compile because T is not constrained, meaning the data -// stored in it is not guaranteed to last as long as the reference +// This won't compile because the applicable impl of +// `SomeTrait` (below) requires that `T: 'a`, but the struct does +// not have a matching where-clause. struct Foo<'a, T> { - foo: &'a T + foo: >::Output, } -``` -This will compile, because it has the constraint on the type parameter: +trait SomeTrait<'a> { + type Output; +} -``` -struct Foo<'a, T: 'a> { - foo: &'a T +impl<'a, T> SomeTrait<'a> for T +where + T: 'a, +{ + type Output = u32; } ``` -To see why this is important, consider the case where `T` is itself a reference -(e.g., `T = &str`). If we don't include the restriction that `T: 'a`, the -following code would be perfectly legal: +Here, the where clause `T: 'a` that appears on the impl is not known to be +satisfied on the struct. To make this example compile, you have to add +a where-clause like `T: 'a` to the struct definition: -```compile_fail,E0309 -struct Foo<'a, T> { - foo: &'a T +``` +struct Foo<'a, T> +where + T: 'a, +{ + foo: >::Output } -fn main() { - let v = "42".to_string(); - let f = Foo{foo: &v}; - drop(v); - println!("{}", f.foo); // but we've already dropped v! +trait SomeTrait<'a> { + type Output; +} + +impl<'a, T> SomeTrait<'a> for T +where + T: 'a, +{ + type Output = u32; } ``` "##, @@ -1465,30 +1478,31 @@ Erroneous code example: ```compile_fail,E0491 -// struct containing a reference requires a lifetime parameter, -// because the data the reference points to must outlive the struct (see E0106) -struct Struct<'a> { - ref_i32: &'a i32, +trait SomeTrait<'a> { + type Output; } -// However, a nested struct like this, the signature itself does not tell -// whether 'a outlives 'b or the other way around. -// So it could be possible that 'b of reference outlives 'a of the data. -struct Nested<'a, 'b> { - ref_struct: &'b Struct<'a>, // compile error E0491 +impl<'a, T> SomeTrait<'a> for T { + type Output = &'a T; // compile error E0491 } ``` -To fix this issue, you can specify a bound to the lifetime like below: +Here, the problem is that a reference type like `&'a T` is only valid +if all the data in T outlives the lifetime `'a`. But this impl as written +is applicable to any lifetime `'a` and any type `T` -- we have no guarantee +that `T` outlives `'a`. To fix this, you can add a where clause like +`where T: 'a`. ``` -struct Struct<'a> { - ref_i32: &'a i32, +trait SomeTrait<'a> { + type Output; } -// 'a: 'b means 'a outlives 'b -struct Nested<'a: 'b, 'b> { - ref_struct: &'b Struct<'a>, +impl<'a, T> SomeTrait<'a> for T +where + T: 'a, +{ + type Output = &'a T; // compile error E0491 } ``` "##, @@ -1725,7 +1739,7 @@ E0562: r##" Abstract return types (written `impl Trait` for some trait `Trait`) are only -allowed as function return types. +allowed as function and inherent impl return types. Erroneous code example: @@ -2102,6 +2116,20 @@ ``` "##, +E0718: r##" +This error indicates that a `#[lang = ".."]` attribute was placed +on the wrong type of item. + +Examples of erroneous code: + +```compile_fail,E0718 +#![feature(lang_items)] + +#[lang = "arc"] +static X: u32 = 42; +``` +"##, + } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/hir/check_attr.rs rustc-1.31.0+dfsg1+llvm/src/librustc/hir/check_attr.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/hir/check_attr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/hir/check_attr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,38 +14,80 @@ //! conflicts between multiple such attributes attached to the same //! item. -use syntax_pos::Span; -use ty::TyCtxt; - use hir; use hir::intravisit::{self, Visitor, NestedVisitorMap}; +use ty::TyCtxt; +use std::fmt::{self, Display}; +use syntax_pos::Span; #[derive(Copy, Clone, PartialEq)] -enum Target { +pub(crate) enum Target { + ExternCrate, + Use, + Static, + Const, Fn, + Closure, + Mod, + ForeignMod, + GlobalAsm, + Ty, + Existential, + Enum, Struct, Union, - Enum, - Const, - ForeignMod, + Trait, + TraitAlias, + Impl, Expression, Statement, - Closure, - Static, - Other, +} + +impl Display for Target { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", match *self { + Target::ExternCrate => "extern crate", + Target::Use => "use", + Target::Static => "static item", + Target::Const => "constant item", + Target::Fn => "function", + Target::Closure => "closure", + Target::Mod => "module", + Target::ForeignMod => "foreign module", + Target::GlobalAsm => "global asm", + Target::Ty => "type alias", + Target::Existential => "existential type", + Target::Enum => "enum", + Target::Struct => "struct", + Target::Union => "union", + Target::Trait => "trait", + Target::TraitAlias => "trait alias", + Target::Impl => "item", + Target::Expression => "expression", + Target::Statement => "statement", + }) + } } impl Target { - fn from_item(item: &hir::Item) -> Target { + pub(crate) fn from_item(item: &hir::Item) -> Target { match item.node { + hir::ItemKind::ExternCrate(..) => Target::ExternCrate, + hir::ItemKind::Use(..) => Target::Use, + hir::ItemKind::Static(..) => Target::Static, + hir::ItemKind::Const(..) => Target::Const, hir::ItemKind::Fn(..) => Target::Fn, + hir::ItemKind::Mod(..) => Target::Mod, + hir::ItemKind::ForeignMod(..) => Target::ForeignMod, + hir::ItemKind::GlobalAsm(..) => Target::GlobalAsm, + hir::ItemKind::Ty(..) => Target::Ty, + hir::ItemKind::Existential(..) => Target::Existential, + hir::ItemKind::Enum(..) => Target::Enum, hir::ItemKind::Struct(..) => Target::Struct, hir::ItemKind::Union(..) => Target::Union, - hir::ItemKind::Enum(..) => Target::Enum, - hir::ItemKind::Const(..) => Target::Const, - hir::ItemKind::ForeignMod(..) => Target::ForeignMod, - hir::ItemKind::Static(..) => Target::Static, - _ => Target::Other, + hir::ItemKind::Trait(..) => Target::Trait, + hir::ItemKind::TraitAlias(..) => Target::TraitAlias, + hir::ItemKind::Impl(..) => Target::Impl, } } } @@ -70,6 +112,8 @@ self.check_inline(attr, &item.span, target) } else if attr.check_name("non_exhaustive") { self.check_non_exhaustive(attr, item, target) + } else if attr.check_name("marker") { + self.check_marker(attr, item, target) } } @@ -113,6 +157,26 @@ .emit(); } } + + /// Check if the `#[marker]` attribute on an `item` is valid. + fn check_marker(&self, attr: &hir::Attribute, item: &hir::Item, target: Target) { + match target { + Target::Trait => { /* Valid */ }, + _ => { + self.tcx.sess + .struct_span_err(attr.span, "attribute can only be applied to a trait") + .span_label(item.span, "not a trait") + .emit(); + return; + } + } + + if !attr.is_word() { + self.tcx.sess + .struct_span_err(attr.span, "attribute should be empty") + .emit(); + } + } /// Check if the `#[repr]` attributes on `item` are valid. fn check_repr(&self, item: &hir::Item, target: Target) { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/hir/def_id.rs rustc-1.31.0+dfsg1+llvm/src/librustc/hir/def_id.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/hir/def_id.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/hir/def_id.rs 2018-12-04 23:41:40.000000000 +0000 @@ -36,11 +36,11 @@ } impl ::std::fmt::Debug for CrateNum { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { match self { CrateNum::Index(id) => write!(fmt, "crate{}", id.private), CrateNum::Invalid => write!(fmt, "invalid crate"), - CrateNum::BuiltinMacros => write!(fmt, "bultin macros crate"), + CrateNum::BuiltinMacros => write!(fmt, "builtin macros crate"), CrateNum::ReservedForIncrCompCache => write!(fmt, "crate for decoding incr comp cache"), } } @@ -97,11 +97,11 @@ } impl fmt::Display for CrateNum { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { CrateNum::Index(id) => fmt::Display::fmt(&id.private, f), CrateNum::Invalid => write!(f, "invalid crate"), - CrateNum::BuiltinMacros => write!(f, "bultin macros crate"), + CrateNum::BuiltinMacros => write!(f, "builtin macros crate"), CrateNum::ReservedForIncrCompCache => write!(f, "crate for decoding incr comp cache"), } } @@ -131,9 +131,8 @@ /// thanks to `NodeCollector::new`. pub const CRATE_DEF_INDEX: DefIndex = DefIndex(0); - impl fmt::Debug for DefIndex { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "DefIndex({}:{})", self.address_space().index(), @@ -216,7 +215,7 @@ } } -/// A DefId identifies a particular *definition*, by combining a crate +/// A `DefId` identifies a particular *definition*, by combining a crate /// index and a def index. #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Copy)] pub struct DefId { @@ -225,9 +224,9 @@ } impl fmt::Debug for DefId { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "DefId({:?}/{}:{}", - self.krate.index(), + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "DefId({}/{}:{}", + self.krate, self.index.address_space().index(), self.index.as_array_index())?; @@ -289,7 +288,7 @@ } impl fmt::Debug for LocalDefId { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.to_def_id().fmt(f) } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/hir/def.rs rustc-1.31.0+dfsg1+llvm/src/librustc/hir/def.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/hir/def.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/hir/def.rs 2018-12-04 23:41:40.000000000 +0000 @@ -36,6 +36,8 @@ Tool, /// Single-segment custom attribute registered by a derive macro (`#[serde(default)]`). DeriveHelper, + /// Single-segment custom attriubte registered by a legacy plugin (`register_attribute`). + LegacyPluginHelper, /// Single-segment custom attribute not registered in any way (`#[my_attr]`). Custom, } @@ -126,14 +128,6 @@ pub fn unresolved_segments(&self) -> usize { self.unresolved_segments } - - pub fn kind_name(&self) -> &'static str { - if self.unresolved_segments != 0 { - "associated item" - } else { - self.base_def.kind_name() - } - } } /// Different kinds of symbols don't influence each other. @@ -259,6 +253,7 @@ NonMacroAttrKind::Builtin => "built-in attribute", NonMacroAttrKind::Tool => "tool attribute", NonMacroAttrKind::DeriveHelper => "derive helper attribute", + NonMacroAttrKind::LegacyPluginHelper => "legacy plugin helper attribute", NonMacroAttrKind::Custom => "custom attribute", } } @@ -266,6 +261,12 @@ impl Def { pub fn def_id(&self) -> DefId { + self.opt_def_id().unwrap_or_else(|| { + bug!("attempted .def_id() on invalid def: {:?}", self) + }) + } + + pub fn opt_def_id(&self) -> Option { match *self { Def::Fn(id) | Def::Mod(id) | Def::Static(id, _) | Def::Variant(id) | Def::VariantCtor(id, ..) | Def::Enum(id) | @@ -273,9 +274,8 @@ Def::AssociatedTy(id) | Def::TyParam(id) | Def::Struct(id) | Def::StructCtor(id, ..) | Def::Union(id) | Def::Trait(id) | Def::Method(id) | Def::Const(id) | Def::AssociatedConst(id) | Def::Macro(id, ..) | - Def::Existential(id) | Def::AssociatedExistential(id) | Def::ForeignTy(id) | - Def::SelfCtor(id) => { - id + Def::Existential(id) | Def::AssociatedExistential(id) | Def::ForeignTy(id) => { + Some(id) } Def::Local(..) | @@ -283,10 +283,11 @@ Def::Label(..) | Def::PrimTy(..) | Def::SelfTy(..) | + Def::SelfCtor(..) | Def::ToolMod | Def::NonMacroAttr(..) | Def::Err => { - bug!("attempted .def_id() on invalid def: {:?}", self) + None } } } @@ -330,4 +331,13 @@ Def::Err => "unresolved item", } } + + pub fn article(&self) -> &'static str { + match *self { + Def::AssociatedTy(..) | Def::AssociatedConst(..) | Def::AssociatedExistential(..) | + Def::Enum(..) | Def::Existential(..) | Def::Err => "an", + Def::Macro(.., macro_kind) => macro_kind.article(), + _ => "a", + } + } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/hir/intravisit.rs rustc-1.31.0+dfsg1+llvm/src/librustc/hir/intravisit.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/hir/intravisit.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/hir/intravisit.rs 2018-12-04 23:41:40.000000000 +0000 @@ -298,6 +298,9 @@ fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl, b: BodyId, s: Span, id: NodeId) { walk_fn(self, fk, fd, b, s, id) } + fn visit_use(&mut self, path: &'v Path, id: NodeId, hir_id: HirId) { + walk_use(self, path, id, hir_id) + } fn visit_trait_item(&mut self, ti: &'v TraitItem) { walk_trait_item(self, ti) } @@ -436,7 +439,9 @@ visitor.visit_ident(ident); } LifetimeName::Param(ParamName::Fresh(_)) | + LifetimeName::Param(ParamName::Error) | LifetimeName::Static | + LifetimeName::Error | LifetimeName::Implicit | LifetimeName::Underscore => {} } @@ -469,8 +474,7 @@ } } ItemKind::Use(ref path, _) => { - visitor.visit_id(item.id); - visitor.visit_path(path, item.hir_id); + visitor.visit_use(path, item.id, item.hir_id); } ItemKind::Static(ref typ, _, body) | ItemKind::Const(ref typ, body) => { @@ -552,6 +556,14 @@ walk_list!(visitor, visit_attribute, &item.attrs); } +pub fn walk_use<'v, V: Visitor<'v>>(visitor: &mut V, + path: &'v Path, + item_id: NodeId, + hir_id: HirId) { + visitor.visit_id(item_id); + visitor.visit_path(path, hir_id); +} + pub fn walk_enum_def<'v, V: Visitor<'v>>(visitor: &mut V, enum_definition: &'v EnumDef, generics: &'v Generics, @@ -603,6 +615,10 @@ TyKind::Path(ref qpath) => { visitor.visit_qpath(qpath, typ.hir_id, typ.span); } + TyKind::Def(item_id, ref lifetimes) => { + visitor.visit_nested_item(item_id); + walk_list!(visitor, visit_generic_arg, lifetimes); + } TyKind::Array(ref ty, ref length) => { visitor.visit_ty(ty); visitor.visit_anon_const(length) @@ -646,6 +662,9 @@ path_span: Span, segment: &'v PathSegment) { visitor.visit_ident(segment.ident); + if let Some(id) = segment.id { + visitor.visit_id(id); + } if let Some(ref args) = segment.args { visitor.visit_generic_args(path_span, args); } @@ -743,7 +762,7 @@ walk_list!(visitor, visit_attribute, ¶m.attrs); match param.name { ParamName::Plain(ident) => visitor.visit_ident(ident), - ParamName::Fresh(_) => {} + ParamName::Error | ParamName::Fresh(_) => {} } match param.kind { GenericParamKind::Lifetime { .. } => {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/hir/lowering.rs rustc-1.31.0+dfsg1+llvm/src/librustc/hir/lowering.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/hir/lowering.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/hir/lowering.rs 2018-12-04 23:41:40.000000000 +0000 @@ -52,16 +52,16 @@ use middle::cstore::CrateStore; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::indexed_vec::IndexVec; -use rustc_data_structures::small_vec::OneVector; use rustc_data_structures::thin_vec::ThinVec; use session::Session; +use session::config::nightly_options; use util::common::FN_OUTPUT_NAME; use util::nodemap::{DefIdMap, NodeMap}; use std::collections::BTreeMap; use std::fmt::Debug; -use std::iter; use std::mem; +use smallvec::SmallVec; use syntax::attr; use syntax::ast; use syntax::ast::*; @@ -125,9 +125,8 @@ // Whether or not in-band lifetimes are being collected. This is used to // indicate whether or not we're in a place where new lifetimes will result - // in in-band lifetime definitions, such a function or an impl header. - // This will always be false unless the `in_band_lifetimes` or - // `impl_header_lifetime_elision` feature is enabled. + // in in-band lifetime definitions, such a function or an impl header, + // including implicit lifetimes from `impl_header_lifetime_elision`. is_collecting_in_band_lifetimes: bool, // Currently in-scope lifetimes defined in impl headers, fn headers, or HRTB. @@ -144,8 +143,12 @@ } pub trait Resolver { - /// Resolve a hir path generated by the lowerer when expanding `for`, `if let`, etc. - fn resolve_hir_path(&mut self, path: &mut hir::Path, is_value: bool); + /// Resolve a path generated by the lowerer when expanding `for`, `if let`, etc. + fn resolve_hir_path( + &mut self, + path: &ast::Path, + is_value: bool, + ) -> hir::Path; /// Obtain the resolution for a node id fn get_resolution(&mut self, id: NodeId) -> Option; @@ -164,7 +167,6 @@ span: Span, crate_root: Option<&str>, components: &[&str], - params: Option>, is_value: bool, ) -> hir::Path; } @@ -175,27 +177,41 @@ /// Example: `fn foo(x: impl Debug)`, where `impl Debug` is conceptually /// equivalent to a fresh universal parameter like `fn foo(x: T)`. /// - /// Newly generated parameters should be inserted into the given `Vec` + /// Newly generated parameters should be inserted into the given `Vec`. Universal(&'a mut Vec), - /// Treat `impl Trait` as shorthand for a new universal existential parameter. + /// Treat `impl Trait` as shorthand for a new existential parameter. /// Example: `fn foo() -> impl Debug`, where `impl Debug` is conceptually - /// equivalent to a fresh existential parameter like `abstract type T; fn foo() -> T`. + /// equivalent to a fresh existential parameter like `existential type T; fn foo() -> T`. /// - /// We store a DefId here so we can look up necessary information later - Existential(DefId), + /// We optionally store a `DefId` for the parent item here so we can look up necessary + /// information later. It is `None` when no information about the context should be stored, + /// e.g. for consts and statics. + Existential(Option), /// `impl Trait` is not accepted in this position. - Disallowed, + Disallowed(ImplTraitPosition), +} + +/// Position in which `impl Trait` is disallowed. Used for error reporting. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +enum ImplTraitPosition { + Binding, + Other, } impl<'a> ImplTraitContext<'a> { + #[inline] + fn disallowed() -> Self { + ImplTraitContext::Disallowed(ImplTraitPosition::Other) + } + fn reborrow(&'b mut self) -> ImplTraitContext<'b> { use self::ImplTraitContext::*; match self { Universal(params) => Universal(params), Existential(did) => Existential(*did), - Disallowed => Disallowed, + Disallowed(pos) => Disallowed(*pos), } } } @@ -301,10 +317,44 @@ /// For **Deprecated** cases, report an error. CreateParameter, + /// Give a hard error when either `&` or `'_` is written. Used to + /// rule out things like `where T: Foo<'_>`. Does not imply an + /// error on default object bounds (e.g., `Box`). + ReportError, + /// Pass responsibility to `resolve_lifetime` code for all cases. PassThrough, } +struct ImplTraitTypeIdVisitor<'a> { ids: &'a mut SmallVec<[hir::ItemId; 1]> } + +impl<'a, 'b> Visitor<'a> for ImplTraitTypeIdVisitor<'b> { + fn visit_ty(&mut self, ty: &'a Ty) { + match ty.node { + | TyKind::Typeof(_) + | TyKind::BareFn(_) + => return, + + TyKind::ImplTrait(id, _) => self.ids.push(hir::ItemId { id }), + _ => {}, + } + visit::walk_ty(self, ty); + } + + fn visit_path_segment( + &mut self, + path_span: Span, + path_segment: &'v PathSegment, + ) { + if let Some(ref p) = path_segment.args { + if let GenericArgs::Parenthesized(_) = **p { + return; + } + } + visit::walk_path_segment(self, path_span, path_segment) + } +} + impl<'a> LoweringContext<'a> { fn lower_crate(mut self, c: &Crate) -> hir::Crate { /// Full-crate AST visitor that inserts into a fresh @@ -396,7 +446,7 @@ self.lctx.with_parent_impl_lifetime_defs(&item_generics, |this| { let this = &mut ItemLowerer { lctx: this }; - if let ItemKind::Impl(_, _, _, _, ref opt_trait_ref, _, _) = item.node { + if let ItemKind::Impl(.., ref opt_trait_ref, _, _) = item.node { this.with_trait_impl_ref(opt_trait_ref, |this| { visit::walk_item(this, item) }); @@ -655,18 +705,14 @@ f: F, ) -> (Vec, T) where - F: FnOnce(&mut LoweringContext) -> (Vec, T), + F: FnOnce(&mut LoweringContext<'_>) -> (Vec, T), { assert!(!self.is_collecting_in_band_lifetimes); assert!(self.lifetimes_to_define.is_empty()); let old_anonymous_lifetime_mode = self.anonymous_lifetime_mode; - if self.sess.features_untracked().impl_header_lifetime_elision { - self.anonymous_lifetime_mode = anonymous_lifetime_mode; - self.is_collecting_in_band_lifetimes = true; - } else if self.sess.features_untracked().in_band_lifetimes { - self.is_collecting_in_band_lifetimes = true; - } + self.anonymous_lifetime_mode = anonymous_lifetime_mode; + self.is_collecting_in_band_lifetimes = true; let (in_band_ty_params, res) = f(self); @@ -683,9 +729,19 @@ // Get the name we'll use to make the def-path. Note // that collisions are ok here and this shouldn't // really show up for end-user. - let str_name = match hir_name { - ParamName::Plain(ident) => ident.as_interned_str(), - ParamName::Fresh(_) => keywords::UnderscoreLifetime.name().as_interned_str(), + let (str_name, kind) = match hir_name { + ParamName::Plain(ident) => ( + ident.as_interned_str(), + hir::LifetimeParamKind::InBand, + ), + ParamName::Fresh(_) => ( + keywords::UnderscoreLifetime.name().as_interned_str(), + hir::LifetimeParamKind::Elided, + ), + ParamName::Error => ( + keywords::UnderscoreLifetime.name().as_interned_str(), + hir::LifetimeParamKind::Error, + ), }; // Add a definition for the in-band lifetime def @@ -705,7 +761,7 @@ bounds: hir_vec![], span, pure_wrt_drop: false, - kind: hir::GenericParamKind::Lifetime { in_band: true } + kind: hir::GenericParamKind::Lifetime { kind } } }) .chain(in_band_ty_params.into_iter()) @@ -742,7 +798,7 @@ } /// When we have either an elided or `'_` lifetime in an impl - /// header, we convert it to + /// header, we convert it to an in-band lifetime. fn collect_fresh_in_band_lifetime(&mut self, span: Span) -> ParamName { assert!(self.is_collecting_in_band_lifetimes); let index = self.lifetimes_to_define.len(); @@ -757,7 +813,7 @@ // for them. fn with_in_scope_lifetime_defs(&mut self, params: &[GenericParam], f: F) -> T where - F: FnOnce(&mut LoweringContext) -> T, + F: FnOnce(&mut LoweringContext<'_>) -> T, { let old_len = self.in_scope_lifetimes.len(); let lt_def_names = params.iter().filter_map(|param| match param.kind { @@ -781,7 +837,7 @@ params: &HirVec, f: F ) -> T where - F: FnOnce(&mut LoweringContext) -> T, + F: FnOnce(&mut LoweringContext<'_>) -> T, { let old_len = self.in_scope_lifetimes.len(); let lt_def_names = params.iter().filter_map(|param| match param.kind { @@ -810,7 +866,7 @@ f: F, ) -> (hir::Generics, T) where - F: FnOnce(&mut LoweringContext, &mut Vec) -> T, + F: FnOnce(&mut LoweringContext<'_>, &mut Vec) -> T, { let (in_band_defs, (mut lowered_generics, res)) = self.with_in_scope_lifetime_defs( &generics.params, @@ -839,7 +895,7 @@ fn with_catch_scope(&mut self, catch_id: NodeId, f: F) -> T where - F: FnOnce(&mut LoweringContext) -> T, + F: FnOnce(&mut LoweringContext<'_>) -> T, { let len = self.catch_scopes.len(); self.catch_scopes.push(catch_id); @@ -861,7 +917,7 @@ capture_clause: CaptureBy, closure_node_id: NodeId, ret_ty: Option<&Ty>, - body: impl FnOnce(&mut LoweringContext) -> hir::Expr, + body: impl FnOnce(&mut LoweringContext<'_>) -> hir::Expr, ) -> hir::ExprKind { let prev_is_generator = mem::replace(&mut self.is_generator, true); let body_expr = body(self); @@ -898,7 +954,7 @@ fn lower_body(&mut self, decl: Option<&FnDecl>, f: F) -> hir::BodyId where - F: FnOnce(&mut LoweringContext) -> hir::Expr, + F: FnOnce(&mut LoweringContext<'_>) -> hir::Expr, { let prev = mem::replace(&mut self.is_generator, false); let result = f(self); @@ -909,7 +965,7 @@ fn with_loop_scope(&mut self, loop_id: NodeId, f: F) -> T where - F: FnOnce(&mut LoweringContext) -> T, + F: FnOnce(&mut LoweringContext<'_>) -> T, { // We're no longer in the base loop's condition; we're in another loop. let was_in_loop_condition = self.is_in_loop_condition; @@ -934,7 +990,7 @@ fn with_loop_condition_scope(&mut self, f: F) -> T where - F: FnOnce(&mut LoweringContext) -> T, + F: FnOnce(&mut LoweringContext<'_>) -> T, { let was_in_loop_condition = self.is_in_loop_condition; self.is_in_loop_condition = true; @@ -948,20 +1004,20 @@ fn with_new_scopes(&mut self, f: F) -> T where - F: FnOnce(&mut LoweringContext) -> T, + F: FnOnce(&mut LoweringContext<'_>) -> T, { let was_in_loop_condition = self.is_in_loop_condition; self.is_in_loop_condition = false; let catch_scopes = mem::replace(&mut self.catch_scopes, Vec::new()); let loop_scopes = mem::replace(&mut self.loop_scopes, Vec::new()); - let result = f(self); + let ret = f(self); self.catch_scopes = catch_scopes; self.loop_scopes = loop_scopes; self.is_in_loop_condition = was_in_loop_condition; - result + ret } fn def_key(&mut self, id: DefId) -> DefKey { @@ -1011,6 +1067,9 @@ } fn lower_attr(&mut self, attr: &Attribute) -> Attribute { + // Note that we explicitly do not walk the path. Since we don't really + // lower attributes (we use the AST version) there is nowhere to keep + // the HirIds. We don't actually need HIR version of attributes anyway. Attribute { id: attr.id, style: attr.style, @@ -1063,7 +1122,8 @@ } } - fn lower_ty_binding(&mut self, b: &TypeBinding, itctx: ImplTraitContext) -> hir::TypeBinding { + fn lower_ty_binding(&mut self, b: &TypeBinding, + itctx: ImplTraitContext<'_>) -> hir::TypeBinding { hir::TypeBinding { id: self.lower_node_id(b.id).node_id, ident: b.ident, @@ -1074,7 +1134,7 @@ fn lower_generic_arg(&mut self, arg: &ast::GenericArg, - itctx: ImplTraitContext) + itctx: ImplTraitContext<'_>) -> hir::GenericArg { match arg { ast::GenericArg::Lifetime(lt) => GenericArg::Lifetime(self.lower_lifetime(<)), @@ -1082,18 +1142,18 @@ } } - fn lower_ty(&mut self, t: &Ty, itctx: ImplTraitContext) -> P { + fn lower_ty(&mut self, t: &Ty, itctx: ImplTraitContext<'_>) -> P { P(self.lower_ty_direct(t, itctx)) } - fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext) -> hir::Ty { + fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext<'_>) -> hir::Ty { let kind = match t.node { TyKind::Infer => hir::TyKind::Infer, TyKind::Err => hir::TyKind::Err, TyKind::Slice(ref ty) => hir::TyKind::Slice(self.lower_ty(ty, itctx)), TyKind::Ptr(ref mt) => hir::TyKind::Ptr(self.lower_mt(mt, itctx)), TyKind::Rptr(ref region, ref mt) => { - let span = t.span.shrink_to_lo(); + let span = self.sess.source_map().next_point(t.span.shrink_to_lo()); let lifetime = match *region { Some(ref lt) => self.lower_lifetime(lt), None => self.elided_ref_lifetime(span), @@ -1110,7 +1170,7 @@ generic_params: this.lower_generic_params( &f.generic_params, &NodeMap(), - ImplTraitContext::Disallowed, + ImplTraitContext::disallowed(), ), unsafety: this.lower_unsafety(f.unsafety), abi: f.abi, @@ -1223,14 +1283,27 @@ }), )) } - ImplTraitContext::Disallowed => { - span_err!( + ImplTraitContext::Disallowed(pos) => { + let allowed_in = if self.sess.features_untracked() + .impl_trait_in_bindings { + "bindings or function and inherent method return types" + } else { + "function and inherent method return types" + }; + let mut err = struct_span_err!( self.sess, t.span, E0562, - "`impl Trait` not allowed outside of function \ - and inherent method return types" + "`impl Trait` not allowed outside of {}", + allowed_in, ); + if pos == ImplTraitPosition::Binding && + nightly_options::is_nightly_build() { + help!(err, + "add #![feature(impl_trait_in_bindings)] to the crate attributes \ + to enable"); + } + err.emit(); hir::TyKind::Err } } @@ -1250,9 +1323,9 @@ fn lower_existential_impl_trait( &mut self, span: Span, - fn_def_id: DefId, + fn_def_id: Option, exist_ty_node_id: NodeId, - lower_bounds: impl FnOnce(&mut LoweringContext) -> hir::GenericBounds, + lower_bounds: impl FnOnce(&mut LoweringContext<'_>) -> hir::GenericBounds, ) -> hir::TyKind { // Make sure we know that some funky desugaring has been going on here. // This is a first: there is code in other places like for loop @@ -1270,7 +1343,6 @@ .opt_def_index(exist_ty_node_id) .unwrap(); - self.allocate_hir_id_counter(exist_ty_node_id, &"existential impl trait"); let hir_bounds = self.with_hir_id_owner(exist_ty_node_id, lower_bounds); @@ -1292,7 +1364,7 @@ span, }, bounds: hir_bounds, - impl_trait_fn: Some(fn_def_id), + impl_trait_fn: fn_def_id, }); let exist_ty_id = lctx.lower_node_id(exist_ty_node_id); // Generate an `existential type Foo: Trait;` declaration @@ -1315,20 +1387,7 @@ lctx.items.insert(exist_ty_id.node_id, exist_ty_item); // `impl Trait` now just becomes `Foo<'a, 'b, ..>` - let path = P(hir::Path { - span: exist_ty_span, - def: Def::Existential(DefId::local(exist_ty_def_index)), - segments: hir_vec![hir::PathSegment { - infer_types: false, - ident: Ident::new(keywords::Invalid.name(), exist_ty_span), - args: Some(P(hir::GenericArgs { - parenthesized: false, - bindings: HirVec::new(), - args: lifetimes, - })) - }], - }); - hir::TyKind::Path(hir::QPath::Resolved(None, path)) + hir::TyKind::Def(hir::ItemId { id: exist_ty_id.node_id }, lifetimes) }) } @@ -1425,7 +1484,7 @@ } } hir::LifetimeName::Param(_) => lifetime.name, - hir::LifetimeName::Static => return, + hir::LifetimeName::Error | hir::LifetimeName::Static => return, }; if !self.currently_bound_lifetimes.contains(&name) @@ -1452,11 +1511,15 @@ lifetime.span, ); - let name = match name { - hir::LifetimeName::Underscore => { - hir::ParamName::Plain(keywords::UnderscoreLifetime.ident()) - } - hir::LifetimeName::Param(param_name) => param_name, + let (name, kind) = match name { + hir::LifetimeName::Underscore => ( + hir::ParamName::Plain(keywords::UnderscoreLifetime.ident()), + hir::LifetimeParamKind::Elided, + ), + hir::LifetimeName::Param(param_name) => ( + param_name, + hir::LifetimeParamKind::Explicit, + ), _ => bug!("expected LifetimeName::Param or ParamName::Plain"), }; @@ -1467,9 +1530,7 @@ pure_wrt_drop: false, attrs: hir_vec![], bounds: hir_vec![], - kind: hir::GenericParamKind::Lifetime { - in_band: false, - } + kind: hir::GenericParamKind::Lifetime { kind } }); } } @@ -1531,14 +1592,14 @@ qself: &Option, p: &Path, param_mode: ParamMode, - mut itctx: ImplTraitContext, + mut itctx: ImplTraitContext<'_>, ) -> hir::QPath { let qself_position = qself.as_ref().map(|q| q.position); let qself = qself.as_ref().map(|q| self.lower_ty(&q.ty, itctx.reborrow())); let resolution = self.resolver .get_resolution(id) - .unwrap_or(PathResolution::new(Def::Err)); + .unwrap_or_else(|| PathResolution::new(Def::Err)); let proj_start = p.segments.len() - resolution.unresolved_segments(); let path = P(hir::Path { @@ -1622,6 +1683,7 @@ num_lifetimes, parenthesized_generic_args, itctx.reborrow(), + None, ) }) .collect(), @@ -1665,6 +1727,7 @@ 0, ParenthesizedGenericArgs::Warn, itctx.reborrow(), + None, )); let qpath = hir::QPath::TypeRelative(ty, segment); @@ -1691,8 +1754,8 @@ &mut self, def: Def, p: &Path, - ident: Option, param_mode: ParamMode, + explicit_owner: Option, ) -> hir::Path { hir::Path { def, @@ -1705,10 +1768,10 @@ param_mode, 0, ParenthesizedGenericArgs::Err, - ImplTraitContext::Disallowed, + ImplTraitContext::disallowed(), + explicit_owner, ) }) - .chain(ident.map(|ident| hir::PathSegment::from_ident(ident))) .collect(), span: p.span, } @@ -1716,7 +1779,7 @@ fn lower_path(&mut self, id: NodeId, p: &Path, param_mode: ParamMode) -> hir::Path { let def = self.expect_full_def(id); - self.lower_path_extra(def, p, None, param_mode) + self.lower_path_extra(def, p, param_mode, None) } fn lower_path_segment( @@ -1726,7 +1789,8 @@ param_mode: ParamMode, expected_lifetimes: usize, parenthesized_generic_args: ParenthesizedGenericArgs, - itctx: ImplTraitContext, + itctx: ImplTraitContext<'_>, + explicit_owner: Option, ) -> hir::PathSegment { let (mut generic_args, infer_types) = if let Some(ref generic_args) = segment.args { let msg = "parenthesized parameters may only be used with a trait"; @@ -1797,8 +1861,21 @@ } } + let def = self.expect_full_def(segment.id); + let id = if let Some(owner) = explicit_owner { + self.lower_node_id_with_owner(segment.id, owner) + } else { + self.lower_node_id(segment.id) + }; + debug!( + "lower_path_segment: ident={:?} original-id={:?} new-id={:?}", + segment.ident, segment.id, id, + ); + hir::PathSegment::new( segment.ident, + Some(id.node_id), + Some(def), generic_args, infer_types, ) @@ -1808,7 +1885,7 @@ &mut self, data: &AngleBracketedArgs, param_mode: ParamMode, - mut itctx: ImplTraitContext, + mut itctx: ImplTraitContext<'_>, ) -> (hir::GenericArgs, bool) { let &AngleBracketedArgs { ref args, ref bindings, .. } = data; let has_types = args.iter().any(|arg| match arg { @@ -1835,9 +1912,11 @@ self.with_anonymous_lifetime_mode( AnonymousLifetimeMode::PassThrough, |this| { - const DISALLOWED: ImplTraitContext = ImplTraitContext::Disallowed; let &ParenthesisedArgs { ref inputs, ref output, span } = data; - let inputs = inputs.iter().map(|ty| this.lower_ty_direct(ty, DISALLOWED)).collect(); + let inputs = inputs + .iter() + .map(|ty| this.lower_ty_direct(ty, ImplTraitContext::disallowed())) + .collect(); let mk_tup = |this: &mut Self, tys, span| { let LoweredNodeId { node_id, hir_id } = this.next_id(); hir::Ty { node: hir::TyKind::Tup(tys), id: node_id, hir_id, span } @@ -1852,7 +1931,7 @@ ident: Ident::from_str(FN_OUTPUT_NAME), ty: output .as_ref() - .map(|ty| this.lower_ty(&ty, DISALLOWED)) + .map(|ty| this.lower_ty(&ty, ImplTraitContext::disallowed())) .unwrap_or_else(|| P(mk_tup(this, hir::HirVec::new(), span))), span: output.as_ref().map_or(span, |ty| ty.span), } @@ -1865,20 +1944,34 @@ ) } - fn lower_local(&mut self, l: &Local) -> P { + fn lower_local(&mut self, l: &Local) -> (P, SmallVec<[hir::ItemId; 1]>) { let LoweredNodeId { node_id, hir_id } = self.lower_node_id(l.id); - P(hir::Local { + let mut ids = SmallVec::<[hir::ItemId; 1]>::new(); + if self.sess.features_untracked().impl_trait_in_bindings { + if let Some(ref ty) = l.ty { + let mut visitor = ImplTraitTypeIdVisitor { ids: &mut ids }; + visitor.visit_ty(ty); + } + } + let parent_def_id = DefId::local(self.current_hir_id_owner.last().unwrap().0); + (P(hir::Local { id: node_id, hir_id, ty: l.ty .as_ref() - .map(|t| self.lower_ty(t, ImplTraitContext::Disallowed)), + .map(|t| self.lower_ty(t, + if self.sess.features_untracked().impl_trait_in_bindings { + ImplTraitContext::Existential(Some(parent_def_id)) + } else { + ImplTraitContext::Disallowed(ImplTraitPosition::Binding) + } + )), pat: self.lower_pat(&l.pat), init: l.init.as_ref().map(|e| P(self.lower_expr(e))), span: l.span, attrs: l.attrs.clone(), source: hir::LocalSource::Normal, - }) + }), ids) } fn lower_mutability(&mut self, m: Mutability) -> hir::Mutability { @@ -1932,7 +2025,7 @@ if let Some((_, ref mut ibty)) = in_band_ty_params { self.lower_ty_direct(&arg.ty, ImplTraitContext::Universal(ibty)) } else { - self.lower_ty_direct(&arg.ty, ImplTraitContext::Disallowed) + self.lower_ty_direct(&arg.ty, ImplTraitContext::disallowed()) } }) .collect::>(); @@ -1948,9 +2041,12 @@ match decl.output { FunctionRetTy::Ty(ref ty) => match in_band_ty_params { Some((def_id, _)) if impl_trait_return_allow => { - hir::Return(self.lower_ty(ty, ImplTraitContext::Existential(def_id))) + hir::Return(self.lower_ty(ty, + ImplTraitContext::Existential(Some(def_id)))) + } + _ => { + hir::Return(self.lower_ty(ty, ImplTraitContext::disallowed())) } - _ => hir::Return(self.lower_ty(ty, ImplTraitContext::Disallowed)), }, FunctionRetTy::Default(span) => hir::DefaultReturn(span), } @@ -1960,11 +2056,31 @@ inputs, output, variadic: decl.variadic, - has_implicit_self: decl.inputs.get(0).map_or(false, |arg| match arg.ty.node { - TyKind::ImplicitSelf => true, - TyKind::Rptr(_, ref mt) => mt.ty.node.is_implicit_self(), - _ => false, - }), + implicit_self: decl.inputs.get(0).map_or( + hir::ImplicitSelfKind::None, + |arg| { + let is_mutable_pat = match arg.pat.node { + PatKind::Ident(BindingMode::ByValue(mt), _, _) | + PatKind::Ident(BindingMode::ByRef(mt), _, _) => + mt == Mutability::Mutable, + _ => false, + }; + + match arg.ty.node { + TyKind::ImplicitSelf if is_mutable_pat => hir::ImplicitSelfKind::Mut, + TyKind::ImplicitSelf => hir::ImplicitSelfKind::Imm, + // Given we are only considering `ImplicitSelf` types, we needn't consider + // the case where we have a mutable pattern to a reference as that would + // no longer be an `ImplicitSelf`. + TyKind::Rptr(_, ref mt) if mt.ty.node.is_implicit_self() && + mt.mutbl == ast::Mutability::Mutable => + hir::ImplicitSelfKind::MutRef, + TyKind::Rptr(_, ref mt) if mt.ty.node.is_implicit_self() => + hir::ImplicitSelfKind::ImmRef, + _ => hir::ImplicitSelfKind::None, + } + }, + ), }) } @@ -2072,7 +2188,7 @@ } } hir::LifetimeName::Param(_) => lifetime.name, - hir::LifetimeName::Static => return, + hir::LifetimeName::Error | hir::LifetimeName::Static => return, }; if !self.currently_bound_lifetimes.contains(&name) { @@ -2131,10 +2247,11 @@ }; let impl_trait_ty = self.lower_existential_impl_trait( - span, fn_def_id, return_impl_trait_id, |this| { + span, Some(fn_def_id), return_impl_trait_id, |this| { let output_ty = match output { - FunctionRetTy::Ty(ty) => - this.lower_ty(ty, ImplTraitContext::Existential(fn_def_id)), + FunctionRetTy::Ty(ty) => { + this.lower_ty(ty, ImplTraitContext::Existential(Some(fn_def_id))) + } FunctionRetTy::Default(span) => { let LoweredNodeId { node_id, hir_id } = this.next_id(); P(hir::Ty { @@ -2199,13 +2316,15 @@ fn lower_param_bound( &mut self, tpb: &GenericBound, - itctx: ImplTraitContext, + itctx: ImplTraitContext<'_>, ) -> hir::GenericBound { match *tpb { - GenericBound::Trait(ref ty, modifier) => hir::GenericBound::Trait( - self.lower_poly_trait_ref(ty, itctx), - self.lower_trait_bound_modifier(modifier), - ), + GenericBound::Trait(ref ty, modifier) => { + hir::GenericBound::Trait( + self.lower_poly_trait_ref(ty, itctx), + self.lower_trait_bound_modifier(modifier), + ) + } GenericBound::Outlives(ref lifetime) => { hir::GenericBound::Outlives(self.lower_lifetime(lifetime)) } @@ -2227,6 +2346,8 @@ AnonymousLifetimeMode::PassThrough => { self.new_named_lifetime(l.id, span, hir::LifetimeName::Underscore) } + + AnonymousLifetimeMode::ReportError => self.new_error_lifetime(Some(l.id), span), }, ident => { self.maybe_collect_in_band_lifetime(ident); @@ -2253,7 +2374,7 @@ &mut self, params: &[GenericParam], add_bounds: &NodeMap>, - mut itctx: ImplTraitContext, + mut itctx: ImplTraitContext<'_>, ) -> hir::HirVec { params.iter().map(|param| { self.lower_generic_param(param, add_bounds, itctx.reborrow()) @@ -2263,18 +2384,28 @@ fn lower_generic_param(&mut self, param: &GenericParam, add_bounds: &NodeMap>, - mut itctx: ImplTraitContext) + mut itctx: ImplTraitContext<'_>) -> hir::GenericParam { - let mut bounds = self.lower_param_bounds(¶m.bounds, itctx.reborrow()); + let mut bounds = self.with_anonymous_lifetime_mode( + AnonymousLifetimeMode::ReportError, + |this| this.lower_param_bounds(¶m.bounds, itctx.reborrow()), + ); + match param.kind { GenericParamKind::Lifetime => { let was_collecting_in_band = self.is_collecting_in_band_lifetimes; self.is_collecting_in_band_lifetimes = false; - let lt = self.lower_lifetime(&Lifetime { id: param.id, ident: param.ident }); + let lt = self.with_anonymous_lifetime_mode( + AnonymousLifetimeMode::ReportError, + |this| this.lower_lifetime(&Lifetime { id: param.id, ident: param.ident }), + ); let param_name = match lt.name { hir::LifetimeName::Param(param_name) => param_name, - _ => hir::ParamName::Plain(lt.name.ident()), + hir::LifetimeName::Implicit + | hir::LifetimeName::Underscore + | hir::LifetimeName::Static => hir::ParamName::Plain(lt.name.ident()), + hir::LifetimeName::Error => ParamName::Error, }; let param = hir::GenericParam { id: lt.id, @@ -2283,7 +2414,9 @@ pure_wrt_drop: attr::contains_name(¶m.attrs, "may_dangle"), attrs: self.lower_attrs(¶m.attrs), bounds, - kind: hir::GenericParamKind::Lifetime { in_band: false } + kind: hir::GenericParamKind::Lifetime { + kind: hir::LifetimeParamKind::Explicit, + } }; self.is_collecting_in_band_lifetimes = was_collecting_in_band; @@ -2317,7 +2450,7 @@ span: ident.span, kind: hir::GenericParamKind::Type { default: default.as_ref().map(|x| { - self.lower_ty(x, ImplTraitContext::Disallowed) + self.lower_ty(x, ImplTraitContext::disallowed()) }), synthetic: param.attrs.iter() .filter(|attr| attr.check_name("rustc_synthetic")) @@ -2332,7 +2465,7 @@ fn lower_generics( &mut self, generics: &Generics, - itctx: ImplTraitContext) + itctx: ImplTraitContext<'_>) -> hir::Generics { // Collect `?Trait` bounds in where clause and move them to parameter definitions. @@ -2396,13 +2529,18 @@ } fn lower_where_clause(&mut self, wc: &WhereClause) -> hir::WhereClause { - hir::WhereClause { - id: self.lower_node_id(wc.id).node_id, - predicates: wc.predicates - .iter() - .map(|predicate| self.lower_where_predicate(predicate)) - .collect(), - } + self.with_anonymous_lifetime_mode( + AnonymousLifetimeMode::ReportError, + |this| { + hir::WhereClause { + id: this.lower_node_id(wc.id).node_id, + predicates: wc.predicates + .iter() + .map(|predicate| this.lower_where_predicate(predicate)) + .collect(), + } + }, + ) } fn lower_where_predicate(&mut self, pred: &WherePredicate) -> hir::WherePredicate { @@ -2420,9 +2558,9 @@ bound_generic_params: this.lower_generic_params( bound_generic_params, &NodeMap(), - ImplTraitContext::Disallowed, + ImplTraitContext::disallowed(), ), - bounded_ty: this.lower_ty(bounded_ty, ImplTraitContext::Disallowed), + bounded_ty: this.lower_ty(bounded_ty, ImplTraitContext::disallowed()), bounds: bounds .iter() .filter_map(|bound| match *bound { @@ -2431,7 +2569,7 @@ GenericBound::Trait(_, TraitBoundModifier::Maybe) => None, _ => Some(this.lower_param_bound( bound, - ImplTraitContext::Disallowed, + ImplTraitContext::disallowed(), )), }) .collect(), @@ -2447,7 +2585,7 @@ }) => hir::WherePredicate::RegionPredicate(hir::WhereRegionPredicate { span, lifetime: self.lower_lifetime(lifetime), - bounds: self.lower_param_bounds(bounds, ImplTraitContext::Disallowed), + bounds: self.lower_param_bounds(bounds, ImplTraitContext::disallowed()), }), WherePredicate::EqPredicate(WhereEqPredicate { id, @@ -2456,8 +2594,8 @@ span, }) => hir::WherePredicate::EqPredicate(hir::WhereEqPredicate { id: self.lower_node_id(id).node_id, - lhs_ty: self.lower_ty(lhs_ty, ImplTraitContext::Disallowed), - rhs_ty: self.lower_ty(rhs_ty, ImplTraitContext::Disallowed), + lhs_ty: self.lower_ty(lhs_ty, ImplTraitContext::disallowed()), + rhs_ty: self.lower_ty(rhs_ty, ImplTraitContext::disallowed()), span, }), } @@ -2485,7 +2623,7 @@ } } - fn lower_trait_ref(&mut self, p: &TraitRef, itctx: ImplTraitContext) -> hir::TraitRef { + fn lower_trait_ref(&mut self, p: &TraitRef, itctx: ImplTraitContext<'_>) -> hir::TraitRef { let path = match self.lower_qpath(p.ref_id, &None, &p.path, ParamMode::Explicit, itctx) { hir::QPath::Resolved(None, path) => path.and_then(|path| path), qpath => bug!("lower_trait_ref: unexpected QPath `{:?}`", qpath), @@ -2501,7 +2639,7 @@ fn lower_poly_trait_ref( &mut self, p: &PolyTraitRef, - mut itctx: ImplTraitContext, + mut itctx: ImplTraitContext<'_>, ) -> hir::PolyTraitRef { let bound_generic_params = self.lower_generic_params(&p.bound_generic_params, &NodeMap(), itctx.reborrow()); @@ -2527,7 +2665,7 @@ None => Ident::new(Symbol::intern(&index.to_string()), f.span), }, vis: self.lower_visibility(&f.vis, None), - ty: self.lower_ty(&f.ty, ImplTraitContext::Disallowed), + ty: self.lower_ty(&f.ty, ImplTraitContext::disallowed()), attrs: self.lower_attrs(&f.attrs), } } @@ -2542,14 +2680,14 @@ } } - fn lower_mt(&mut self, mt: &MutTy, itctx: ImplTraitContext) -> hir::MutTy { + fn lower_mt(&mut self, mt: &MutTy, itctx: ImplTraitContext<'_>) -> hir::MutTy { hir::MutTy { ty: self.lower_ty(&mt.ty, itctx), mutbl: self.lower_mutability(mt.mutbl), } } - fn lower_param_bounds(&mut self, bounds: &[GenericBound], mut itctx: ImplTraitContext) + fn lower_param_bounds(&mut self, bounds: &[GenericBound], mut itctx: ImplTraitContext<'_>) -> hir::GenericBounds { bounds.iter().map(|bound| self.lower_param_bound(bound, itctx.reborrow())).collect() } @@ -2629,18 +2767,34 @@ ItemKind::Static(ref t, m, ref e) => { let value = self.lower_body(None, |this| this.lower_expr(e)); hir::ItemKind::Static( - self.lower_ty(t, ImplTraitContext::Disallowed), + self.lower_ty( + t, + if self.sess.features_untracked().impl_trait_in_bindings { + ImplTraitContext::Existential(None) + } else { + ImplTraitContext::Disallowed(ImplTraitPosition::Binding) + } + ), self.lower_mutability(m), value, ) } ItemKind::Const(ref t, ref e) => { let value = self.lower_body(None, |this| this.lower_expr(e)); - hir::ItemKind::Const(self.lower_ty(t, ImplTraitContext::Disallowed), value) + hir::ItemKind::Const( + self.lower_ty( + t, + if self.sess.features_untracked().impl_trait_in_bindings { + ImplTraitContext::Existential(None) + } else { + ImplTraitContext::Disallowed(ImplTraitPosition::Binding) + } + ), + value + ) } ItemKind::Fn(ref decl, header, ref generics, ref body) => { let fn_def_id = self.resolver.definitions().local_def_id(id); - self.with_new_scopes(|this| { // Note: we don't need to change the return type from `T` to // `impl Future` here because lower_body @@ -2653,7 +2807,11 @@ fn_def_id, AnonymousLifetimeMode::PassThrough, |this, idty| this.lower_fn_decl( - decl, Some((fn_def_id, idty)), true, header.asyncness.opt_return_id()), + decl, + Some((fn_def_id, idty)), + true, + header.asyncness.opt_return_id() + ), ); hir::ItemKind::Fn( @@ -2668,12 +2826,12 @@ ItemKind::ForeignMod(ref nm) => hir::ItemKind::ForeignMod(self.lower_foreign_mod(nm)), ItemKind::GlobalAsm(ref ga) => hir::ItemKind::GlobalAsm(self.lower_global_asm(ga)), ItemKind::Ty(ref t, ref generics) => hir::ItemKind::Ty( - self.lower_ty(t, ImplTraitContext::Disallowed), - self.lower_generics(generics, ImplTraitContext::Disallowed), + self.lower_ty(t, ImplTraitContext::disallowed()), + self.lower_generics(generics, ImplTraitContext::disallowed()), ), ItemKind::Existential(ref b, ref generics) => hir::ItemKind::Existential(hir::ExistTy { - generics: self.lower_generics(generics, ImplTraitContext::Disallowed), - bounds: self.lower_param_bounds(b, ImplTraitContext::Disallowed), + generics: self.lower_generics(generics, ImplTraitContext::disallowed()), + bounds: self.lower_param_bounds(b, ImplTraitContext::disallowed()), impl_trait_fn: None, }), ItemKind::Enum(ref enum_definition, ref generics) => hir::ItemKind::Enum( @@ -2684,20 +2842,20 @@ .map(|x| self.lower_variant(x)) .collect(), }, - self.lower_generics(generics, ImplTraitContext::Disallowed), + self.lower_generics(generics, ImplTraitContext::disallowed()), ), ItemKind::Struct(ref struct_def, ref generics) => { let struct_def = self.lower_variant_data(struct_def); hir::ItemKind::Struct( struct_def, - self.lower_generics(generics, ImplTraitContext::Disallowed), + self.lower_generics(generics, ImplTraitContext::disallowed()), ) } ItemKind::Union(ref vdata, ref generics) => { let vdata = self.lower_variant_data(vdata); hir::ItemKind::Union( vdata, - self.lower_generics(generics, ImplTraitContext::Disallowed), + self.lower_generics(generics, ImplTraitContext::disallowed()), ) } ItemKind::Impl( @@ -2730,7 +2888,7 @@ AnonymousLifetimeMode::CreateParameter, |this, _| { let trait_ref = trait_ref.as_ref().map(|trait_ref| { - this.lower_trait_ref(trait_ref, ImplTraitContext::Disallowed) + this.lower_trait_ref(trait_ref, ImplTraitContext::disallowed()) }); if let Some(ref trait_ref) = trait_ref { @@ -2739,7 +2897,7 @@ } } - let lowered_ty = this.lower_ty(ty, ImplTraitContext::Disallowed); + let lowered_ty = this.lower_ty(ty, ImplTraitContext::disallowed()); (trait_ref, lowered_ty) }, @@ -2766,7 +2924,7 @@ ) } ItemKind::Trait(is_auto, unsafety, ref generics, ref bounds, ref items) => { - let bounds = self.lower_param_bounds(bounds, ImplTraitContext::Disallowed); + let bounds = self.lower_param_bounds(bounds, ImplTraitContext::disallowed()); let items = items .iter() .map(|item| self.lower_trait_item_ref(item)) @@ -2774,14 +2932,14 @@ hir::ItemKind::Trait( self.lower_is_auto(is_auto), self.lower_unsafety(unsafety), - self.lower_generics(generics, ImplTraitContext::Disallowed), + self.lower_generics(generics, ImplTraitContext::disallowed()), bounds, items, ) } ItemKind::TraitAlias(ref generics, ref bounds) => hir::ItemKind::TraitAlias( - self.lower_generics(generics, ImplTraitContext::Disallowed), - self.lower_param_bounds(bounds, ImplTraitContext::Disallowed), + self.lower_generics(generics, ImplTraitContext::disallowed()), + self.lower_param_bounds(bounds, ImplTraitContext::disallowed()), ), ItemKind::MacroDef(..) | ItemKind::Mac(..) => panic!("Shouldn't still be around"), } @@ -2799,7 +2957,16 @@ name: &mut Name, attrs: &hir::HirVec, ) -> hir::ItemKind { + debug!("lower_use_tree(tree={:?})", tree); + debug!("lower_use_tree: vis = {:?}", vis); + let path = &tree.prefix; + let segments = prefix + .segments + .iter() + .chain(path.segments.iter()) + .cloned() + .collect(); match tree.kind { UseTreeKind::Simple(rename, id1, id2) => { @@ -2807,12 +2974,7 @@ // First apply the prefix to the path let mut path = Path { - segments: prefix - .segments - .iter() - .chain(path.segments.iter()) - .cloned() - .collect(), + segments, span: path.span, }; @@ -2832,9 +2994,18 @@ // for later let ret_def = defs.next().unwrap_or(Def::Err); + // Here, we are looping over namespaces, if they exist for the definition + // being imported. We only handle type and value namespaces because we + // won't be dealing with macros in the rest of the compiler. + // Essentially a single `use` which imports two names is desugared into + // two imports. for (def, &new_node_id) in defs.zip([id1, id2].iter()) { let vis = vis.clone(); let name = name.clone(); + let mut path = path.clone(); + for seg in &mut path.segments { + seg.id = self.sess.next_node_id(); + } let span = path.span; self.resolver.definitions().create_def_with_parent( parent_def_index, @@ -2847,7 +3018,8 @@ self.with_hir_id_owner(new_node_id, |this| { let new_id = this.lower_node_id(new_node_id); - let path = this.lower_path_extra(def, &path, None, ParamMode::Explicit); + let path = + this.lower_path_extra(def, &path, ParamMode::Explicit, None); let item = hir::ItemKind::Use(P(path), hir::UseKind::Single); let vis_kind = match vis.node { hir::VisibilityKind::Public => hir::VisibilityKind::Public, @@ -2855,9 +3027,9 @@ hir::VisibilityKind::Inherited => hir::VisibilityKind::Inherited, hir::VisibilityKind::Restricted { ref path, id: _, hir_id: _ } => { let id = this.next_id(); + let path = this.renumber_segment_ids(path); hir::VisibilityKind::Restricted { - path: path.clone(), - // We are allocating a new NodeId here + path, id: id.node_id, hir_id: id.hir_id, } @@ -2880,19 +3052,15 @@ }); } - let path = P(self.lower_path_extra(ret_def, &path, None, ParamMode::Explicit)); + let path = + P(self.lower_path_extra(ret_def, &path, ParamMode::Explicit, None)); hir::ItemKind::Use(path, hir::UseKind::Single) } UseTreeKind::Glob => { let path = P(self.lower_path( id, &Path { - segments: prefix - .segments - .iter() - .chain(path.segments.iter()) - .cloned() - .collect(), + segments, span: path.span, }, ParamMode::Explicit, @@ -2900,19 +3068,39 @@ hir::ItemKind::Use(path, hir::UseKind::Glob) } UseTreeKind::Nested(ref trees) => { + // Nested imports are desugared into simple + // imports. So if we start with + // + // ``` + // pub(x) use foo::{a, b}; + // ``` + // + // we will create three items: + // + // ``` + // pub(x) use foo::a; + // pub(x) use foo::b; + // pub(x) use foo::{}; // <-- this is called the `ListStem` + // ``` + // + // The first two are produced by recursively invoking + // `lower_use_tree` (and indeed there may be things + // like `use foo::{a::{b, c}}` and so forth). They + // wind up being directly added to + // `self.items`. However, the structure of this + // function also requires us to return one item, and + // for that we return the `{}` import (called the + // "`ListStem`"). + let prefix = Path { - segments: prefix - .segments - .iter() - .chain(path.segments.iter()) - .cloned() - .collect(), + segments, span: prefix.span.to(path.span), }; - // Add all the nested PathListItems in the HIR + // Add all the nested PathListItems to the HIR. for &(ref use_tree, id) in trees { self.allocate_hir_id_counter(id, &use_tree); + let LoweredNodeId { node_id: new_id, hir_id: new_hir_id, @@ -2920,19 +3108,35 @@ let mut vis = vis.clone(); let mut name = name.clone(); - let item = - self.lower_use_tree(use_tree, &prefix, new_id, &mut vis, &mut name, &attrs); + let mut prefix = prefix.clone(); + + // Give the segments new ids since they are being cloned. + for seg in &mut prefix.segments { + seg.id = self.sess.next_node_id(); + } + // Each `use` import is an item and thus are owners of the + // names in the path. Up to this point the nested import is + // the current owner, since we want each desugared import to + // own its own names, we have to adjust the owner before + // lowering the rest of the import. self.with_hir_id_owner(new_id, |this| { + let item = this.lower_use_tree(use_tree, + &prefix, + new_id, + &mut vis, + &mut name, + attrs); + let vis_kind = match vis.node { hir::VisibilityKind::Public => hir::VisibilityKind::Public, hir::VisibilityKind::Crate(sugar) => hir::VisibilityKind::Crate(sugar), hir::VisibilityKind::Inherited => hir::VisibilityKind::Inherited, hir::VisibilityKind::Restricted { ref path, id: _, hir_id: _ } => { let id = this.next_id(); + let path = this.renumber_segment_ids(path); hir::VisibilityKind::Restricted { - path: path.clone(), - // We are allocating a new NodeId here + path: path, id: id.node_id, hir_id: id.hir_id, } @@ -2945,7 +3149,7 @@ hir::Item { id: new_id, hir_id: new_hir_id, - name: name, + name, attrs: attrs.clone(), node: item, vis, @@ -2955,25 +3159,57 @@ }); } - // Privatize the degenerate import base, used only to check - // the stability of `use a::{};`, to avoid it showing up as - // a re-export by accident when `pub`, e.g. in documentation. - let path = P(self.lower_path(id, &prefix, ParamMode::Explicit)); - *vis = respan(prefix.span.shrink_to_lo(), hir::VisibilityKind::Inherited); + // Subtle and a bit hacky: we lower the privacy level + // of the list stem to "private" most of the time, but + // not for "restricted" paths. The key thing is that + // we don't want it to stay as `pub` (with no caveats) + // because that affects rustdoc and also the lints + // about `pub` items. But we can't *always* make it + // private -- particularly not for restricted paths -- + // because it contains node-ids that would then be + // unused, failing the check that HirIds are "densely + // assigned". + match vis.node { + hir::VisibilityKind::Public | + hir::VisibilityKind::Crate(_) | + hir::VisibilityKind::Inherited => { + *vis = respan(prefix.span.shrink_to_lo(), hir::VisibilityKind::Inherited); + } + hir::VisibilityKind::Restricted { .. } => { + // do nothing here, as described in the comment on the match + } + } + + let def = self.expect_full_def_from_use(id).next().unwrap_or(Def::Err); + let path = P(self.lower_path_extra(def, &prefix, ParamMode::Explicit, None)); hir::ItemKind::Use(path, hir::UseKind::ListStem) } } } + /// Paths like the visibility path in `pub(super) use foo::{bar, baz}` are repeated + /// many times in the HIR tree; for each occurrence, we need to assign distinct + /// node-ids. (See e.g. #56128.) + fn renumber_segment_ids(&mut self, path: &P) -> P { + debug!("renumber_segment_ids(path = {:?})", path); + let mut path = path.clone(); + for seg in path.segments.iter_mut() { + if seg.id.is_some() { + seg.id = Some(self.next_id().node_id); + } + } + path + } + fn lower_trait_item(&mut self, i: &TraitItem) -> hir::TraitItem { let LoweredNodeId { node_id, hir_id } = self.lower_node_id(i.id); let trait_item_def_id = self.resolver.definitions().local_def_id(node_id); let (generics, node) = match i.node { TraitItemKind::Const(ref ty, ref default) => ( - self.lower_generics(&i.generics, ImplTraitContext::Disallowed), + self.lower_generics(&i.generics, ImplTraitContext::disallowed()), hir::TraitItemKind::Const( - self.lower_ty(ty, ImplTraitContext::Disallowed), + self.lower_ty(ty, ImplTraitContext::disallowed()), default .as_ref() .map(|x| self.lower_body(None, |this| this.lower_expr(x))), @@ -2995,7 +3231,6 @@ let body = this.lower_block(body, false); this.expr_block(body, ThinVec::new()) }); - let (generics, sig) = self.lower_method_sig( &i.generics, sig, @@ -3003,16 +3238,15 @@ false, None, ); - (generics, hir::TraitItemKind::Method(sig, hir::TraitMethod::Provided(body_id))) } TraitItemKind::Type(ref bounds, ref default) => ( - self.lower_generics(&i.generics, ImplTraitContext::Disallowed), + self.lower_generics(&i.generics, ImplTraitContext::disallowed()), hir::TraitItemKind::Type( - self.lower_param_bounds(bounds, ImplTraitContext::Disallowed), + self.lower_param_bounds(bounds, ImplTraitContext::disallowed()), default .as_ref() - .map(|x| self.lower_ty(x, ImplTraitContext::Disallowed)), + .map(|x| self.lower_ty(x, ImplTraitContext::disallowed())), ), ), TraitItemKind::Macro(..) => panic!("Shouldn't exist any more"), @@ -3062,9 +3296,9 @@ ImplItemKind::Const(ref ty, ref expr) => { let body_id = self.lower_body(None, |this| this.lower_expr(expr)); ( - self.lower_generics(&i.generics, ImplTraitContext::Disallowed), + self.lower_generics(&i.generics, ImplTraitContext::disallowed()), hir::ImplItemKind::Const( - self.lower_ty(ty, ImplTraitContext::Disallowed), + self.lower_ty(ty, ImplTraitContext::disallowed()), body_id, ), ) @@ -3082,13 +3316,13 @@ (generics, hir::ImplItemKind::Method(sig, body_id)) } ImplItemKind::Type(ref ty) => ( - self.lower_generics(&i.generics, ImplTraitContext::Disallowed), - hir::ImplItemKind::Type(self.lower_ty(ty, ImplTraitContext::Disallowed)), + self.lower_generics(&i.generics, ImplTraitContext::disallowed()), + hir::ImplItemKind::Type(self.lower_ty(ty, ImplTraitContext::disallowed())), ), ImplItemKind::Existential(ref bounds) => ( - self.lower_generics(&i.generics, ImplTraitContext::Disallowed), + self.lower_generics(&i.generics, ImplTraitContext::disallowed()), hir::ImplItemKind::Existential( - self.lower_param_bounds(bounds, ImplTraitContext::Disallowed), + self.lower_param_bounds(bounds, ImplTraitContext::disallowed()), ), ), ImplItemKind::Macro(..) => panic!("Shouldn't exist any more"), @@ -3137,68 +3371,29 @@ } } - /// Lowers `impl Trait` items and appends them to the list - fn lower_impl_trait_ids( - &mut self, - decl: &FnDecl, - header: &FnHeader, - ids: &mut OneVector, - ) { - if let Some(id) = header.asyncness.opt_return_id() { - ids.push(hir::ItemId { id }); - } - struct IdVisitor<'a> { ids: &'a mut OneVector } - impl<'a, 'b> Visitor<'a> for IdVisitor<'b> { - fn visit_ty(&mut self, ty: &'a Ty) { - match ty.node { - | TyKind::Typeof(_) - | TyKind::BareFn(_) - => return, - - TyKind::ImplTrait(id, _) => self.ids.push(hir::ItemId { id }), - _ => {}, - } - visit::walk_ty(self, ty); - } - fn visit_path_segment( - &mut self, - path_span: Span, - path_segment: &'v PathSegment, - ) { - if let Some(ref p) = path_segment.args { - if let GenericArgs::Parenthesized(_) = **p { - return; - } - } - visit::walk_path_segment(self, path_span, path_segment) - } - } - let mut visitor = IdVisitor { ids }; - match decl.output { - FunctionRetTy::Default(_) => {}, - FunctionRetTy::Ty(ref ty) => visitor.visit_ty(ty), - } - } - - fn lower_item_id(&mut self, i: &Item) -> OneVector { + fn lower_item_id(&mut self, i: &Item) -> SmallVec<[hir::ItemId; 1]> { match i.node { ItemKind::Use(ref use_tree) => { let mut vec = smallvec![hir::ItemId { id: i.id }]; self.lower_item_id_use_tree(use_tree, i.id, &mut vec); vec } - ItemKind::MacroDef(..) => OneVector::new(), - ItemKind::Fn(ref decl, ref header, ..) => { + ItemKind::MacroDef(..) => SmallVec::new(), + ItemKind::Fn(..) | + ItemKind::Impl(.., None, _, _) => smallvec![hir::ItemId { id: i.id }], + ItemKind::Static(ref ty, ..) => { let mut ids = smallvec![hir::ItemId { id: i.id }]; - self.lower_impl_trait_ids(decl, header, &mut ids); + if self.sess.features_untracked().impl_trait_in_bindings { + let mut visitor = ImplTraitTypeIdVisitor { ids: &mut ids }; + visitor.visit_ty(ty); + } ids }, - ItemKind::Impl(.., None, _, ref items) => { + ItemKind::Const(ref ty, ..) => { let mut ids = smallvec![hir::ItemId { id: i.id }]; - for item in items { - if let ImplItemKind::Method(ref sig, _) = item.node { - self.lower_impl_trait_ids(&sig.decl, &sig.header, &mut ids); - } + if self.sess.features_untracked().impl_trait_in_bindings { + let mut visitor = ImplTraitTypeIdVisitor { ids: &mut ids }; + visitor.visit_ty(ty); } ids }, @@ -3209,7 +3404,7 @@ fn lower_item_id_use_tree(&mut self, tree: &UseTree, base_id: NodeId, - vec: &mut OneVector) + vec: &mut SmallVec<[hir::ItemId; 1]>) { match tree.kind { UseTreeKind::Nested(ref nested_vec) => for &(ref nested, id) in nested_vec { @@ -3289,7 +3484,8 @@ hir::ForeignItemKind::Fn(fn_dec, fn_args, generics) } ForeignItemKind::Static(ref t, m) => { - hir::ForeignItemKind::Static(self.lower_ty(t, ImplTraitContext::Disallowed), m) + hir::ForeignItemKind::Static( + self.lower_ty(t, ImplTraitContext::disallowed()), m) } ForeignItemKind::Ty => hir::ForeignItemKind::Type, ForeignItemKind::Macro(_) => panic!("shouldn't exist here"), @@ -3428,7 +3624,7 @@ &None, path, ParamMode::Optional, - ImplTraitContext::Disallowed, + ImplTraitContext::disallowed(), ); self.check_self_struct_ctor_feature(&qpath); hir::PatKind::TupleStruct( @@ -3443,7 +3639,7 @@ qself, path, ParamMode::Optional, - ImplTraitContext::Disallowed, + ImplTraitContext::disallowed(), ); self.check_self_struct_ctor_feature(&qpath); hir::PatKind::Path(qpath) @@ -3454,7 +3650,7 @@ &None, path, ParamMode::Optional, - ImplTraitContext::Disallowed, + ImplTraitContext::disallowed(), ); let fs = fields @@ -3548,7 +3744,8 @@ ParamMode::Optional, 0, ParenthesizedGenericArgs::Err, - ImplTraitContext::Disallowed, + ImplTraitContext::disallowed(), + None, ); let args = args.iter().map(|x| self.lower_expr(x)).collect(); hir::ExprKind::MethodCall(hir_seg, seg.ident.span, args) @@ -3567,11 +3764,11 @@ ExprKind::Lit(ref l) => hir::ExprKind::Lit(P((**l).clone())), ExprKind::Cast(ref expr, ref ty) => { let expr = P(self.lower_expr(expr)); - hir::ExprKind::Cast(expr, self.lower_ty(ty, ImplTraitContext::Disallowed)) + hir::ExprKind::Cast(expr, self.lower_ty(ty, ImplTraitContext::disallowed())) } ExprKind::Type(ref expr, ref ty) => { let expr = P(self.lower_expr(expr)); - hir::ExprKind::Type(expr, self.lower_ty(ty, ImplTraitContext::Disallowed)) + hir::ExprKind::Type(expr, self.lower_ty(ty, ImplTraitContext::disallowed())) } ExprKind::AddrOf(m, ref ohs) => { let m = self.lower_mutability(m); @@ -3761,8 +3958,8 @@ } ExprKind::Block(ref blk, opt_label) => { hir::ExprKind::Block(self.lower_block(blk, - opt_label.is_some()), - self.lower_label(opt_label)) + opt_label.is_some()), + self.lower_label(opt_label)) } ExprKind::Assign(ref el, ref er) => { hir::ExprKind::Assign(P(self.lower_expr(el)), P(self.lower_expr(er))) @@ -3814,9 +4011,7 @@ .collect::>(); let is_unit = fields.is_empty(); - let struct_path = iter::once("ops") - .chain(iter::once(path)) - .collect::>(); + let struct_path = ["ops", path]; let struct_path = self.std_path(e.span, &struct_path, None, is_unit); let struct_path = hir::QPath::Resolved(None, P(struct_path)); @@ -3840,7 +4035,7 @@ qself, path, ParamMode::Optional, - ImplTraitContext::Disallowed, + ImplTraitContext::disallowed(), ); self.check_self_struct_ctor_feature(&qpath); hir::ExprKind::Path(qpath) @@ -3879,6 +4074,7 @@ constraint: out.constraint.clone(), is_rw: out.is_rw, is_indirect: out.is_indirect, + span: out.expr.span, }) .collect(), asm: asm.asm.clone(), @@ -3905,7 +4101,7 @@ &None, path, ParamMode::Optional, - ImplTraitContext::Disallowed, + ImplTraitContext::disallowed(), ), fields.iter().map(|x| self.lower_field(x)).collect(), maybe_expr.as_ref().map(|x| P(self.lower_expr(x))), @@ -4058,16 +4254,16 @@ // expand let head = self.lower_expr(head); let head_sp = head.span; + let desugared_span = self.allow_internal_unstable( + CompilerDesugaringKind::ForLoop, + head_sp, + ); let iter = self.str_to_ident("iter"); let next_ident = self.str_to_ident("__next"); - let next_sp = self.allow_internal_unstable( - CompilerDesugaringKind::ForLoop, - head_sp, - ); let next_pat = self.pat_ident_binding_mode( - next_sp, + desugared_span, next_ident, hir::BindingAnnotation::Mutable, ); @@ -4096,8 +4292,11 @@ }; // `mut iter` - let iter_pat = - self.pat_ident_binding_mode(head_sp, iter, hir::BindingAnnotation::Mutable); + let iter_pat = self.pat_ident_binding_mode( + desugared_span, + iter, + hir::BindingAnnotation::Mutable + ); // `match ::std::iter::Iterator::next(&mut iter) { ... }` let match_expr = { @@ -4126,8 +4325,12 @@ let next_expr = P(self.expr_ident(head_sp, next_ident, next_pat.id)); // `let mut __next` - let next_let = - self.stmt_let_pat(head_sp, None, next_pat, hir::LocalSource::ForLoopDesugar); + let next_let = self.stmt_let_pat( + desugared_span, + None, + next_pat, + hir::LocalSource::ForLoopDesugar, + ); // `let = __next` let pat = self.lower_pat(pat); @@ -4310,17 +4513,34 @@ } } - fn lower_stmt(&mut self, s: &Stmt) -> OneVector { + fn lower_stmt(&mut self, s: &Stmt) -> SmallVec<[hir::Stmt; 1]> { smallvec![match s.node { - StmtKind::Local(ref l) => Spanned { - node: hir::StmtKind::Decl( - P(Spanned { - node: hir::DeclKind::Local(self.lower_local(l)), + StmtKind::Local(ref l) => { + let (l, item_ids) = self.lower_local(l); + let mut ids: SmallVec<[hir::Stmt; 1]> = item_ids + .into_iter() + .map(|item_id| Spanned { + node: hir::StmtKind::Decl( + P(Spanned { + node: hir::DeclKind::Item(item_id), + span: s.span, + }), + self.next_id().node_id, + ), span: s.span, - }), - self.lower_node_id(s.id).node_id, - ), - span: s.span, + }) + .collect(); + ids.push(Spanned { + node: hir::StmtKind::Decl( + P(Spanned { + node: hir::DeclKind::Local(l), + span: s.span, + }), + self.lower_node_id(s.id).node_id, + ), + span: s.span, + }); + return ids; }, StmtKind::Item(ref it) => { // Can only use the ID once. @@ -4334,8 +4554,8 @@ span: s.span, }), id.take() - .map(|id| self.lower_node_id(id).node_id) - .unwrap_or_else(|| self.next_id().node_id), + .map(|id| self.lower_node_id(id).node_id) + .unwrap_or_else(|| self.next_id().node_id), ), span: s.span, }) @@ -4374,13 +4594,20 @@ VisibilityKind::Public => hir::VisibilityKind::Public, VisibilityKind::Crate(sugar) => hir::VisibilityKind::Crate(sugar), VisibilityKind::Restricted { ref path, id } => { + debug!("lower_visibility: restricted path id = {:?}", id); let lowered_id = if let Some(owner) = explicit_owner { self.lower_node_id_with_owner(id, owner) } else { self.lower_node_id(id) }; + let def = self.expect_full_def(id); hir::VisibilityKind::Restricted { - path: P(self.lower_path(id, path, ParamMode::Explicit)), + path: P(self.lower_path_extra( + def, + path, + ParamMode::Explicit, + explicit_owner, + )), id: lowered_id.node_id, hir_id: lowered_id.hir_id, } @@ -4687,8 +4914,17 @@ params: Option>, is_value: bool ) -> hir::Path { - self.resolver - .resolve_str_path(span, self.crate_root, components, params, is_value) + let mut path = self.resolver + .resolve_str_path(span, self.crate_root, components, is_value); + path.segments.last_mut().unwrap().args = params; + + + for seg in path.segments.iter_mut() { + if let Some(id) = seg.id { + seg.id = Some(self.lower_node_id(id).node_id); + } + } + path } fn ty_path(&mut self, id: LoweredNodeId, span: Span, qpath: hir::QPath) -> hir::Ty { @@ -4741,10 +4977,38 @@ } } + AnonymousLifetimeMode::ReportError => self.new_error_lifetime(None, span), + AnonymousLifetimeMode::PassThrough => self.new_implicit_lifetime(span), } } + /// Report an error on illegal use of `'_` or a `&T` with no explicit lifetime; + /// return a "error lifetime". + fn new_error_lifetime(&mut self, id: Option, span: Span) -> hir::Lifetime { + let (id, msg, label) = match id { + Some(id) => (id, "`'_` cannot be used here", "`'_` is a reserved lifetime name"), + + None => ( + self.next_id().node_id, + "`&` without an explicit lifetime name cannot be used here", + "explicit lifetime name needed here", + ), + }; + + let mut err = struct_span_err!( + self.sess, + span, + E0637, + "{}", + msg, + ); + err.span_label(span, label); + err.emit(); + + self.new_named_lifetime(id, span, hir::LifetimeName::Error) + } + /// Invoked to create the lifetime argument(s) for a path like /// `std::cell::Ref`; note that implicit lifetimes in these /// sorts of cases are deprecated. This may therefore report a warning or an @@ -4759,6 +5023,12 @@ // impl Foo for std::cell::Ref // note lack of '_ AnonymousLifetimeMode::CreateParameter => {} + AnonymousLifetimeMode::ReportError => { + return (0..count) + .map(|_| self.new_error_lifetime(None, span)) + .collect(); + } + // This is the normal case. AnonymousLifetimeMode::PassThrough => {} } @@ -4789,6 +5059,10 @@ // `resolve_lifetime` has the code to make that happen. AnonymousLifetimeMode::CreateParameter => {} + AnonymousLifetimeMode::ReportError => { + // ReportError applies to explicit use of `'_`. + } + // This is the normal case. AnonymousLifetimeMode::PassThrough => {} } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/hir/map/blocks.rs rustc-1.31.0+dfsg1+llvm/src/librustc/hir/map/blocks.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/hir/map/blocks.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/hir/map/blocks.rs 2018-12-04 23:41:40.000000000 +0000 @@ -143,7 +143,7 @@ impl<'a> FnLikeNode<'a> { /// Attempts to construct a FnLikeNode from presumed FnLike node input. - pub fn from_node(node: Node) -> Option { + pub fn from_node(node: Node<'_>) -> Option> { let fn_like = match node { map::Node::Item(item) => item.is_fn_like(), map::Node::TraitItem(tm) => tm.is_fn_like(), @@ -173,15 +173,15 @@ } pub fn span(self) -> Span { - self.handle(|i: ItemFnParts| i.span, + self.handle(|i: ItemFnParts<'_>| i.span, |_, _, _: &'a ast::MethodSig, _, _, span, _| span, - |c: ClosureParts| c.span) + |c: ClosureParts<'_>| c.span) } pub fn id(self) -> NodeId { - self.handle(|i: ItemFnParts| i.id, + self.handle(|i: ItemFnParts<'_>| i.id, |id, _, _: &'a ast::MethodSig, _, _, _, _| id, - |c: ClosureParts| c.id) + |c: ClosureParts<'_>| c.id) } pub fn constness(self) -> ast::Constness { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/hir/map/collector.rs rustc-1.31.0+dfsg1+llvm/src/librustc/hir/map/collector.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/hir/map/collector.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/hir/map/collector.rs 2018-12-04 23:41:40.000000000 +0000 @@ -28,6 +28,10 @@ pub(super) struct NodeCollector<'a, 'hir> { /// The crate krate: &'hir Crate, + + /// Source map + source_map: &'a SourceMap, + /// The node map map: Vec>>, /// The parent of this node @@ -54,7 +58,8 @@ pub(super) fn root(krate: &'hir Crate, dep_graph: &'a DepGraph, definitions: &'a definitions::Definitions, - hcx: StableHashingContext<'a>) + hcx: StableHashingContext<'a>, + source_map: &'a SourceMap) -> NodeCollector<'a, 'hir> { let root_mod_def_path_hash = definitions.def_path_hash(CRATE_DEF_INDEX); @@ -102,6 +107,7 @@ let mut collector = NodeCollector { krate, + source_map, map: vec![], parent_node: CRATE_NODE_ID, current_signature_dep_index: root_mod_sig_dep_index, @@ -125,7 +131,6 @@ pub(super) fn finalize_and_compute_crate_hash(mut self, crate_disambiguator: CrateDisambiguator, cstore: &dyn CrateStore, - source_map: &SourceMap, commandline_args_hash: u64) -> (Vec>>, Svh) { @@ -154,7 +159,8 @@ // If we included the full mapping in the SVH, we could only have // reproducible builds by compiling from the same directory. So we just // hash the result of the mapping instead of the mapping itself. - let mut source_file_names: Vec<_> = source_map + let mut source_file_names: Vec<_> = self + .source_map .files() .iter() .filter(|source_file| CrateNum::from_u32(source_file.crate_of_origin) == LOCAL_CRATE) @@ -186,7 +192,7 @@ self.map[id.as_usize()] = Some(entry); } - fn insert(&mut self, id: NodeId, node: Node<'hir>) { + fn insert(&mut self, span: Span, id: NodeId, node: Node<'hir>) { let entry = Entry { parent: self.parent_node, dep_node: if self.currently_in_body { @@ -210,17 +216,26 @@ None => format!("{:?}", node) }; - if hir_id == ::hir::DUMMY_HIR_ID { - debug!("Maybe you forgot to lower the node id {:?}?", id); - } + let forgot_str = if hir_id == ::hir::DUMMY_HIR_ID { + format!("\nMaybe you forgot to lower the node id {:?}?", id) + } else { + String::new() + }; - bug!("inconsistent DepNode for `{}`: \ - current_dep_node_owner={}, hir_id.owner={}", + span_bug!( + span, + "inconsistent DepNode at `{:?}` for `{}`: \ + current_dep_node_owner={} ({:?}), hir_id.owner={} ({:?}){}", + self.source_map.span_to_string(span), node_str, self.definitions .def_path(self.current_dep_node_owner) .to_string_no_crate(), - self.definitions.def_path(hir_id.owner).to_string_no_crate()) + self.current_dep_node_owner, + self.definitions.def_path(hir_id.owner).to_string_no_crate(), + hir_id.owner, + forgot_str, + ) } } @@ -304,12 +319,12 @@ debug_assert_eq!(i.hir_id.owner, self.definitions.opt_def_index(i.id).unwrap()); self.with_dep_node_owner(i.hir_id.owner, i, |this| { - this.insert(i.id, Node::Item(i)); + this.insert(i.span, i.id, Node::Item(i)); this.with_parent(i.id, |this| { if let ItemKind::Struct(ref struct_def, _) = i.node { // If this is a tuple-like struct, register the constructor. if !struct_def.is_struct() { - this.insert(struct_def.id(), Node::StructCtor(struct_def)); + this.insert(i.span, struct_def.id(), Node::StructCtor(struct_def)); } } intravisit::walk_item(this, i); @@ -318,7 +333,7 @@ } fn visit_foreign_item(&mut self, foreign_item: &'hir ForeignItem) { - self.insert(foreign_item.id, Node::ForeignItem(foreign_item)); + self.insert(foreign_item.span, foreign_item.id, Node::ForeignItem(foreign_item)); self.with_parent(foreign_item.id, |this| { intravisit::walk_foreign_item(this, foreign_item); @@ -326,7 +341,7 @@ } fn visit_generic_param(&mut self, param: &'hir GenericParam) { - self.insert(param.id, Node::GenericParam(param)); + self.insert(param.span, param.id, Node::GenericParam(param)); intravisit::walk_generic_param(self, param); } @@ -334,7 +349,7 @@ debug_assert_eq!(ti.hir_id.owner, self.definitions.opt_def_index(ti.id).unwrap()); self.with_dep_node_owner(ti.hir_id.owner, ti, |this| { - this.insert(ti.id, Node::TraitItem(ti)); + this.insert(ti.span, ti.id, Node::TraitItem(ti)); this.with_parent(ti.id, |this| { intravisit::walk_trait_item(this, ti); @@ -346,7 +361,7 @@ debug_assert_eq!(ii.hir_id.owner, self.definitions.opt_def_index(ii.id).unwrap()); self.with_dep_node_owner(ii.hir_id.owner, ii, |this| { - this.insert(ii.id, Node::ImplItem(ii)); + this.insert(ii.span, ii.id, Node::ImplItem(ii)); this.with_parent(ii.id, |this| { intravisit::walk_impl_item(this, ii); @@ -360,7 +375,7 @@ } else { Node::Pat(pat) }; - self.insert(pat.id, node); + self.insert(pat.span, pat.id, node); self.with_parent(pat.id, |this| { intravisit::walk_pat(this, pat); @@ -368,7 +383,7 @@ } fn visit_anon_const(&mut self, constant: &'hir AnonConst) { - self.insert(constant.id, Node::AnonConst(constant)); + self.insert(DUMMY_SP, constant.id, Node::AnonConst(constant)); self.with_parent(constant.id, |this| { intravisit::walk_anon_const(this, constant); @@ -376,7 +391,7 @@ } fn visit_expr(&mut self, expr: &'hir Expr) { - self.insert(expr.id, Node::Expr(expr)); + self.insert(expr.span, expr.id, Node::Expr(expr)); self.with_parent(expr.id, |this| { intravisit::walk_expr(this, expr); @@ -385,15 +400,22 @@ fn visit_stmt(&mut self, stmt: &'hir Stmt) { let id = stmt.node.id(); - self.insert(id, Node::Stmt(stmt)); + self.insert(stmt.span, id, Node::Stmt(stmt)); self.with_parent(id, |this| { intravisit::walk_stmt(this, stmt); }); } + fn visit_path_segment(&mut self, path_span: Span, path_segment: &'hir PathSegment) { + if let Some(id) = path_segment.id { + self.insert(path_span, id, Node::PathSegment(path_segment)); + } + intravisit::walk_path_segment(self, path_span, path_segment); + } + fn visit_ty(&mut self, ty: &'hir Ty) { - self.insert(ty.id, Node::Ty(ty)); + self.insert(ty.span, ty.id, Node::Ty(ty)); self.with_parent(ty.id, |this| { intravisit::walk_ty(this, ty); @@ -401,7 +423,7 @@ } fn visit_trait_ref(&mut self, tr: &'hir TraitRef) { - self.insert(tr.ref_id, Node::TraitRef(tr)); + self.insert(tr.path.span, tr.ref_id, Node::TraitRef(tr)); self.with_parent(tr.ref_id, |this| { intravisit::walk_trait_ref(this, tr); @@ -415,21 +437,21 @@ } fn visit_block(&mut self, block: &'hir Block) { - self.insert(block.id, Node::Block(block)); + self.insert(block.span, block.id, Node::Block(block)); self.with_parent(block.id, |this| { intravisit::walk_block(this, block); }); } fn visit_local(&mut self, l: &'hir Local) { - self.insert(l.id, Node::Local(l)); + self.insert(l.span, l.id, Node::Local(l)); self.with_parent(l.id, |this| { intravisit::walk_local(this, l) }) } fn visit_lifetime(&mut self, lifetime: &'hir Lifetime) { - self.insert(lifetime.id, Node::Lifetime(lifetime)); + self.insert(lifetime.span, lifetime.id, Node::Lifetime(lifetime)); } fn visit_vis(&mut self, visibility: &'hir Visibility) { @@ -438,7 +460,7 @@ VisibilityKind::Crate(_) | VisibilityKind::Inherited => {} VisibilityKind::Restricted { id, .. } => { - self.insert(id, Node::Visibility(visibility)); + self.insert(visibility.span, id, Node::Visibility(visibility)); self.with_parent(id, |this| { intravisit::walk_vis(this, visibility); }); @@ -450,20 +472,20 @@ let def_index = self.definitions.opt_def_index(macro_def.id).unwrap(); self.with_dep_node_owner(def_index, macro_def, |this| { - this.insert(macro_def.id, Node::MacroDef(macro_def)); + this.insert(macro_def.span, macro_def.id, Node::MacroDef(macro_def)); }); } fn visit_variant(&mut self, v: &'hir Variant, g: &'hir Generics, item_id: NodeId) { let id = v.node.data.id(); - self.insert(id, Node::Variant(v)); + self.insert(v.span, id, Node::Variant(v)); self.with_parent(id, |this| { intravisit::walk_variant(this, v, g, item_id); }); } fn visit_struct_field(&mut self, field: &'hir StructField) { - self.insert(field.id, Node::Field(field)); + self.insert(field.span, field.id, Node::Field(field)); self.with_parent(field.id, |this| { intravisit::walk_struct_field(this, field); }); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/hir/map/def_collector.rs rustc-1.31.0+dfsg1+llvm/src/librustc/hir/map/def_collector.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/hir/map/def_collector.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/hir/map/def_collector.rs 2018-12-04 23:41:40.000000000 +0000 @@ -102,9 +102,9 @@ visit::walk_fn_decl(this, decl); let closure_def = this.create_def(closure_id, - DefPathData::ClosureExpr, - REGULAR_SPACE, - span); + DefPathData::ClosureExpr, + REGULAR_SPACE, + span); this.with_parent(closure_def, |this| { visit::walk_block(this, body); }) diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/hir/map/definitions.rs rustc-1.31.0+dfsg1+llvm/src/librustc/hir/map/definitions.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/hir/map/definitions.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/hir/map/definitions.rs 2018-12-04 23:41:40.000000000 +0000 @@ -421,10 +421,10 @@ node_to_def_index: NodeMap(), def_index_to_node: [vec![], vec![]], node_to_hir_id: IndexVec::new(), - parent_modules_of_macro_defs: FxHashMap(), - expansions_that_defined: FxHashMap(), - next_disambiguator: FxHashMap(), - def_index_to_span: FxHashMap(), + parent_modules_of_macro_defs: Default::default(), + expansions_that_defined: Default::default(), + next_disambiguator: Default::default(), + def_index_to_span: Default::default(), } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/hir/map/hir_id_validator.rs rustc-1.31.0+dfsg1+llvm/src/librustc/hir/map/hir_id_validator.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/hir/map/hir_id_validator.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/hir/map/hir_id_validator.rs 2018-12-04 23:41:40.000000000 +0000 @@ -51,7 +51,7 @@ HirIdValidator { hir_map, owner_def_index: None, - hir_ids_seen: FxHashMap(), + hir_ids_seen: Default::default(), errors: Vec::new(), } } @@ -88,7 +88,7 @@ walk(self); if owner_def_index == CRATE_DEF_INDEX { - return + return; } // There's always at least one entry for the owning item itself @@ -129,13 +129,16 @@ local_id, self.hir_map.node_to_string(node_id))); } - self.errors.push(format!( "ItemLocalIds not assigned densely in {}. \ - Max ItemLocalId = {}, missing IDs = {:?}", + Max ItemLocalId = {}, missing IDs = {:?}; seens IDs = {:?}", self.hir_map.def_path(DefId::local(owner_def_index)).to_string_no_crate(), max, - missing_items)); + missing_items, + self.hir_ids_seen + .values() + .map(|n| format!("({:?} {})", n, self.hir_map.node_to_string(*n))) + .collect::>())); } } } @@ -155,6 +158,7 @@ self.errors.push(format!("HirIdValidator: No HirId assigned for NodeId {}: {:?}", node_id, self.hir_map.node_to_string(node_id))); + return; } if owner != stable_id.owner { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/hir/map/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/hir/map/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/hir/map/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/hir/map/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -204,7 +204,7 @@ if let Some(entry) = self.map[id.as_usize()] { self.dep_graph.read_index(entry.dep_node); } else { - bug!("called `HirMap::read()` with invalid `NodeId`") + bug!("called `HirMap::read()` with invalid `NodeId`: {:?}", id) } } @@ -344,6 +344,7 @@ Node::AnonConst(_) | Node::Expr(_) | Node::Stmt(_) | + Node::PathSegment(_) | Node::Ty(_) | Node::TraitRef(_) | Node::Pat(_) | @@ -668,7 +669,7 @@ /// } /// ``` pub fn get_return_block(&self, id: NodeId) -> Option { - let match_fn = |node: &Node| { + let match_fn = |node: &Node<'_>| { match *node { Node::Item(_) | Node::ForeignItem(_) | @@ -677,7 +678,7 @@ _ => false, } }; - let match_non_returning_block = |node: &Node| { + let match_non_returning_block = |node: &Node<'_>| { match *node { Node::Expr(ref expr) => { match expr.node { @@ -709,17 +710,22 @@ } } - /// Returns the NodeId of `id`'s nearest module parent, or `id` itself if no + /// Returns the DefId of `id`'s nearest module parent, or `id` itself if no /// module parent is in this map. pub fn get_module_parent(&self, id: NodeId) -> DefId { - let id = match self.walk_parent_nodes(id, |node| match *node { + self.local_def_id(self.get_module_parent_node(id)) + } + + /// Returns the NodeId of `id`'s nearest module parent, or `id` itself if no + /// module parent is in this map. + pub fn get_module_parent_node(&self, id: NodeId) -> NodeId { + match self.walk_parent_nodes(id, |node| match *node { Node::Item(&Item { node: ItemKind::Mod(_), .. }) => true, _ => false, }, |_| false) { Ok(id) => id, Err(id) => id, - }; - self.local_def_id(id) + } } /// Returns the nearest enclosing scope. A scope is an item or block. @@ -879,6 +885,7 @@ Some(Node::AnonConst(constant)) => self.body(constant.body).value.span, Some(Node::Expr(expr)) => expr.span, Some(Node::Stmt(stmt)) => stmt.span, + Some(Node::PathSegment(seg)) => seg.ident.span, Some(Node::Ty(ty)) => ty.span, Some(Node::TraitRef(tr)) => tr.path.span, Some(Node::Binding(pat)) => pat.span, @@ -949,7 +956,7 @@ // If `id` itself is a mod named `m` with parent `p`, then // returns `Some(id, m, p)`. If `id` has no mod in its parent // chain, then returns `None`. - fn find_first_mod_parent<'a>(map: &'a Map, mut id: NodeId) -> Option<(NodeId, Name)> { + fn find_first_mod_parent<'a>(map: &'a Map<'_>, mut id: NodeId) -> Option<(NodeId, Name)> { loop { if let Node::Item(item) = map.find(id)? { if item_is_mod(&item) { @@ -1027,14 +1034,14 @@ let mut collector = NodeCollector::root(&forest.krate, &forest.dep_graph, &definitions, - hcx); + hcx, + sess.source_map()); intravisit::walk_crate(&mut collector, &forest.krate); let crate_disambiguator = sess.local_crate_disambiguator(); let cmdline_args = sess.opts.dep_tracking_hash(); collector.finalize_and_compute_crate_hash(crate_disambiguator, cstore, - sess.source_map(), cmdline_args) }; @@ -1071,7 +1078,7 @@ /// Identical to the `PpAnn` implementation for `hir::Crate`, /// except it avoids creating a dependency on the whole crate. impl<'hir> print::PpAnn for Map<'hir> { - fn nested(&self, state: &mut print::State, nested: print::Nested) -> io::Result<()> { + fn nested(&self, state: &mut print::State<'_>, nested: print::Nested) -> io::Result<()> { match nested { Nested::Item(id) => state.print_item(self.expect_item(id.id)), Nested::TraitItem(id) => state.print_trait_item(self.trait_item(id)), @@ -1083,7 +1090,7 @@ } impl<'a> print::State<'a> { - pub fn print_node(&mut self, node: Node) -> io::Result<()> { + pub fn print_node(&mut self, node: Node<'_>) -> io::Result<()> { match node { Node::Item(a) => self.print_item(&a), Node::ForeignItem(a) => self.print_foreign_item(&a), @@ -1093,6 +1100,7 @@ Node::AnonConst(a) => self.print_anon_const(&a), Node::Expr(a) => self.print_expr(&a), Node::Stmt(a) => self.print_stmt(&a), + Node::PathSegment(a) => self.print_path_segment(&a), Node::Ty(a) => self.print_type(&a), Node::TraitRef(a) => self.print_trait_ref(&a), Node::Binding(a) | @@ -1121,7 +1129,7 @@ } } -fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String { +fn node_id_to_string(map: &Map<'_>, id: NodeId, include_id: bool) -> String { let id_str = format!(" (id={})", id); let id_str = if include_id { &id_str[..] } else { "" }; @@ -1210,6 +1218,9 @@ Some(Node::Stmt(_)) => { format!("stmt {}{}", map.node_to_pretty_string(id), id_str) } + Some(Node::PathSegment(_)) => { + format!("path segment {}{}", map.node_to_pretty_string(id), id_str) + } Some(Node::Ty(_)) => { format!("type {}{}", map.node_to_pretty_string(id), id_str) } @@ -1248,7 +1259,7 @@ } } -pub fn describe_def(tcx: TyCtxt, def_id: DefId) -> Option { +pub fn describe_def(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Option { if let Some(node_id) = tcx.hir.as_local_node_id(def_id) { tcx.hir.describe_def(node_id) } else { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/hir/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/hir/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/hir/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/hir/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -170,7 +170,7 @@ } impl fmt::Debug for Label { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "label({:?})", self.ident) } } @@ -208,13 +208,18 @@ /// where `'f` is something like `Fresh(0)`. The indices are /// unique per impl, but not necessarily continuous. Fresh(usize), + + /// Indicates an illegal name was given and an error has been + /// repored (so we should squelch other derived errors). Occurs + /// when e.g. `'_` is used in the wrong place. + Error, } impl ParamName { pub fn ident(&self) -> Ident { match *self { ParamName::Plain(ident) => ident, - ParamName::Fresh(_) => keywords::UnderscoreLifetime.ident(), + ParamName::Error | ParamName::Fresh(_) => keywords::UnderscoreLifetime.ident(), } } @@ -234,6 +239,10 @@ /// User typed nothing. e.g. the lifetime in `&u32`. Implicit, + /// Indicates an error during lowering (usually `'_` in wrong place) + /// that was already reported. + Error, + /// User typed `'_`. Underscore, @@ -245,6 +254,7 @@ pub fn ident(&self) -> Ident { match *self { LifetimeName::Implicit => keywords::Invalid.ident(), + LifetimeName::Error => keywords::Invalid.ident(), LifetimeName::Underscore => keywords::UnderscoreLifetime.ident(), LifetimeName::Static => keywords::StaticLifetime.ident(), LifetimeName::Param(param_name) => param_name.ident(), @@ -260,7 +270,7 @@ // in the compiler is concerned -- `Fresh(_)` variants act // equivalently to "some fresh name". They correspond to // early-bound regions on an impl, in other words. - LifetimeName::Param(_) | LifetimeName::Static => false, + LifetimeName::Error | LifetimeName::Param(_) | LifetimeName::Static => false, } } @@ -277,13 +287,13 @@ } impl fmt::Display for Lifetime { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.name.ident().fmt(f) } } impl fmt::Debug for Lifetime { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "lifetime({}: {})", self.id, @@ -320,13 +330,13 @@ } impl fmt::Debug for Path { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "path({})", print::to_string(print::NO_ANN, |s| s.print_path(self, false))) } } impl fmt::Display for Path { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", print::to_string(print::NO_ANN, |s| s.print_path(self, false))) } } @@ -337,6 +347,13 @@ pub struct PathSegment { /// The identifier portion of this path segment. pub ident: Ident, + // `id` and `def` are optional. We currently only use these in save-analysis, + // any path segments without these will not have save-analysis info and + // therefore will not have 'jump to def' in IDEs, but otherwise will not be + // affected. (In general, we don't bother to get the defs for synthesized + // segments, only for segments which have come from the AST). + pub id: Option, + pub def: Option, /// Type/lifetime parameters attached to this path. They come in /// two flavors: `Path` and `Path(A,B) -> C`. Note that @@ -357,14 +374,24 @@ pub fn from_ident(ident: Ident) -> PathSegment { PathSegment { ident, + id: None, + def: None, infer_types: true, args: None, } } - pub fn new(ident: Ident, args: GenericArgs, infer_types: bool) -> Self { + pub fn new( + ident: Ident, + id: Option, + def: Option, + args: GenericArgs, + infer_types: bool, + ) -> Self { PathSegment { ident, + id, + def, infer_types, args: if args.is_empty() { None @@ -499,14 +526,30 @@ pub type GenericBounds = HirVec; +#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Debug)] +pub enum LifetimeParamKind { + // Indicates that the lifetime definition was explicitly declared, like: + // `fn foo<'a>(x: &'a u8) -> &'a u8 { x }` + Explicit, + + // Indicates that the lifetime definition was synthetically added + // as a result of an in-band lifetime usage like: + // `fn foo(x: &'a u8) -> &'a u8 { x }` + InBand, + + // Indication that the lifetime was elided like both cases here: + // `fn foo(x: &u8) -> &'_ u8 { x }` + Elided, + + // Indication that the lifetime name was somehow in error. + Error, +} + #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub enum GenericParamKind { /// A lifetime definition, eg `'a: 'b + 'c + 'd`. Lifetime { - // Indicates that the lifetime definition was synthetically added - // as a result of an in-band lifetime usage like: - // `fn foo(x: &'a u8) -> &'a u8 { x }` - in_band: bool, + kind: LifetimeParamKind, }, Type { default: Option>, @@ -804,7 +847,7 @@ } impl fmt::Debug for Pat { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "pat({}: {})", self.id, print::to_string(print::NO_ANN, |s| s.print_pat(self))) } @@ -1120,7 +1163,7 @@ pub type Stmt = Spanned; impl fmt::Debug for StmtKind { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // Sadness. let spanned = source_map::dummy_spanned(self.clone()); write!(f, @@ -1345,10 +1388,63 @@ ExprKind::Yield(..) => ExprPrecedence::Yield, } } + + pub fn is_place_expr(&self) -> bool { + match self.node { + ExprKind::Path(QPath::Resolved(_, ref path)) => { + match path.def { + Def::Local(..) | Def::Upvar(..) | Def::Static(..) | Def::Err => true, + _ => false, + } + } + + ExprKind::Type(ref e, _) => { + e.is_place_expr() + } + + ExprKind::Unary(UnDeref, _) | + ExprKind::Field(..) | + ExprKind::Index(..) => { + true + } + + // Partially qualified paths in expressions can only legally + // refer to associated items which are always rvalues. + ExprKind::Path(QPath::TypeRelative(..)) | + + ExprKind::Call(..) | + ExprKind::MethodCall(..) | + ExprKind::Struct(..) | + ExprKind::Tup(..) | + ExprKind::If(..) | + ExprKind::Match(..) | + ExprKind::Closure(..) | + ExprKind::Block(..) | + ExprKind::Repeat(..) | + ExprKind::Array(..) | + ExprKind::Break(..) | + ExprKind::Continue(..) | + ExprKind::Ret(..) | + ExprKind::While(..) | + ExprKind::Loop(..) | + ExprKind::Assign(..) | + ExprKind::InlineAsm(..) | + ExprKind::AssignOp(..) | + ExprKind::Lit(_) | + ExprKind::Unary(..) | + ExprKind::Box(..) | + ExprKind::AddrOf(..) | + ExprKind::Binary(..) | + ExprKind::Yield(..) | + ExprKind::Cast(..) => { + false + } + } + } } impl fmt::Debug for Expr { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "expr({}: {})", self.id, print::to_string(print::NO_ANN, |s| s.print_expr(self))) } @@ -1521,7 +1617,7 @@ } impl fmt::Display for LoopIdError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(match *self { LoopIdError::OutsideLoopScope => "not inside loop scope", LoopIdError::UnlabeledCfInWhileCondition => @@ -1668,7 +1764,7 @@ } impl fmt::Debug for Ty { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "type({})", print::to_string(print::NO_ANN, |s| s.print_type(self))) } @@ -1723,6 +1819,12 @@ /// /// Type parameters may be stored in each `PathSegment`. Path(QPath), + /// A type definition itself. This is currently only used for the `existential type` + /// item that `impl Trait` in return position desugars to. + /// + /// The generic arg list are the lifetimes (and in the future possibly parameters) that are + /// actually bound on the `impl Trait`. + Def(ItemId, HirVec), /// A trait object type `Bound1 + Bound2 + Bound3` /// where `Bound` is a trait or a lifetime. TraitObject(HirVec, Lifetime), @@ -1740,6 +1842,7 @@ pub constraint: Symbol, pub is_rw: bool, pub is_indirect: bool, + pub span: Span, } #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] @@ -1769,9 +1872,34 @@ pub inputs: HirVec, pub output: FunctionRetTy, pub variadic: bool, - /// True if this function has an `self`, `&self` or `&mut self` receiver - /// (but not a `self: Xxx` one). - pub has_implicit_self: bool, + /// Does the function have an implicit self? + pub implicit_self: ImplicitSelfKind, +} + +/// Represents what type of implicit self a function has, if any. +#[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug)] +pub enum ImplicitSelfKind { + /// Represents a `fn x(self);`. + Imm, + /// Represents a `fn x(mut self);`. + Mut, + /// Represents a `fn x(&self);`. + ImmRef, + /// Represents a `fn x(&mut self);`. + MutRef, + /// Represents when a function does not have a self argument or + /// when a function has a `self: X` argument. + None +} + +impl ImplicitSelfKind { + /// Does this represent an implicit self? + pub fn has_implicit_self(&self) -> bool { + match *self { + ImplicitSelfKind::None => false, + _ => true, + } + } } /// Is the trait definition an auto trait? @@ -1826,7 +1954,7 @@ } impl fmt::Display for Unsafety { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(match *self { Unsafety::Normal => "normal", Unsafety::Unsafe => "unsafe", @@ -1844,7 +1972,7 @@ } impl fmt::Debug for ImplPolarity { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { ImplPolarity::Positive => "positive".fmt(f), ImplPolarity::Negative => "negative".fmt(f), @@ -2284,7 +2412,8 @@ // imported. pub type GlobMap = NodeMap>; -pub fn provide(providers: &mut Providers) { + +pub fn provide(providers: &mut Providers<'_>) { providers.describe_def = map::describe_def; } @@ -2369,9 +2498,22 @@ } } - /// True if `#[no_mangle]` or `#[export_name(...)]` is present. + /// True if it looks like this symbol needs to be exported, for example: + /// + /// * `#[no_mangle]` is present + /// * `#[export_name(...)]` is present + /// * `#[linkage]` is present pub fn contains_extern_indicator(&self) -> bool { - self.flags.contains(CodegenFnAttrFlags::NO_MANGLE) || self.export_name.is_some() + self.flags.contains(CodegenFnAttrFlags::NO_MANGLE) || + self.export_name.is_some() || + match self.linkage { + // these are private, make sure we don't try to consider + // them external + None | + Some(Linkage::Internal) | + Some(Linkage::Private) => false, + Some(_) => true, + } } } @@ -2386,6 +2528,7 @@ AnonConst(&'hir AnonConst), Expr(&'hir Expr), Stmt(&'hir Stmt), + PathSegment(&'hir PathSegment), Ty(&'hir Ty), TraitRef(&'hir TraitRef), Binding(&'hir Pat), diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/hir/print.rs rustc-1.31.0+dfsg1+llvm/src/librustc/hir/print.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/hir/print.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/hir/print.rs 2018-12-04 23:41:40.000000000 +0000 @@ -48,13 +48,13 @@ } pub trait PpAnn { - fn nested(&self, _state: &mut State, _nested: Nested) -> io::Result<()> { + fn nested(&self, _state: &mut State<'_>, _nested: Nested) -> io::Result<()> { Ok(()) } - fn pre(&self, _state: &mut State, _node: AnnNode) -> io::Result<()> { + fn pre(&self, _state: &mut State<'_>, _node: AnnNode<'_>) -> io::Result<()> { Ok(()) } - fn post(&self, _state: &mut State, _node: AnnNode) -> io::Result<()> { + fn post(&self, _state: &mut State<'_>, _node: AnnNode<'_>) -> io::Result<()> { Ok(()) } fn try_fetch_item(&self, _: ast::NodeId) -> Option<&hir::Item> { @@ -70,7 +70,7 @@ fn try_fetch_item(&self, item: ast::NodeId) -> Option<&hir::Item> { Some(self.item(item)) } - fn nested(&self, state: &mut State, nested: Nested) -> io::Result<()> { + fn nested(&self, state: &mut State<'_>, nested: Nested) -> io::Result<()> { match nested { Nested::Item(id) => state.print_item(self.item(id.id)), Nested::TraitItem(id) => state.print_trait_item(self.trait_item(id)), @@ -180,7 +180,7 @@ State { s: pp::mk_printer(out, default_columns), cm: Some(cm), - comments: comments.clone(), + comments, literals: literals.unwrap_or_default().into_iter().peekable(), cur_cmnt: 0, boxes: Vec::new(), @@ -190,7 +190,7 @@ } pub fn to_string(ann: &dyn PpAnn, f: F) -> String - where F: FnOnce(&mut State) -> io::Result<()> + where F: FnOnce(&mut State<'_>) -> io::Result<()> { let mut wr = Vec::new(); { @@ -314,7 +314,7 @@ mut op: F, mut get_span: G) -> io::Result<()> - where F: FnMut(&mut State, &T) -> io::Result<()>, + where F: FnMut(&mut State<'_>, &T) -> io::Result<()>, G: FnMut(&T) -> syntax_pos::Span { self.rbox(0, b)?; @@ -401,6 +401,7 @@ self.print_ty_fn(f.abi, f.unsafety, &f.decl, None, &f.generic_params, &f.arg_names[..])?; } + hir::TyKind::Def(..) => {}, hir::TyKind::Path(ref qpath) => { self.print_qpath(qpath, false)? } @@ -1632,6 +1633,17 @@ Ok(()) } + pub fn print_path_segment(&mut self, segment: &hir::PathSegment) -> io::Result<()> { + if segment.ident.name != keywords::CrateRoot.name() && + segment.ident.name != keywords::DollarCrate.name() { + self.print_ident(segment.ident)?; + segment.with_generic_args(|generic_args| { + self.print_generic_args(generic_args, segment.infer_types, false) + })?; + } + Ok(()) + } + pub fn print_qpath(&mut self, qpath: &hir::QPath, colons_before_params: bool) diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ich/caching_codemap_view.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ich/caching_codemap_view.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ich/caching_codemap_view.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ich/caching_codemap_view.rs 2018-12-04 23:41:40.000000000 +0000 @@ -44,7 +44,7 @@ CachingSourceMapView { source_map, - line_cache: [entry.clone(), entry.clone(), entry.clone()], + line_cache: [entry.clone(), entry.clone(), entry], time_stamp: 0, } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ich/hcx.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ich/hcx.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ich/hcx.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ich/hcx.rs 2018-12-04 23:41:40.000000000 +0000 @@ -370,7 +370,7 @@ // recursing every time. thread_local! { static CACHE: RefCell> = - RefCell::new(FxHashMap()); + RefCell::new(Default::default()); } let sub_hash: u64 = CACHE.with(|cache| { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ich/impls_hir.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ich/impls_hir.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ich/impls_hir.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ich/impls_hir.rs 2018-12-04 23:41:40.000000000 +0000 @@ -144,7 +144,8 @@ impl_stable_hash_for!(enum hir::ParamName { Plain(name), - Fresh(index) + Fresh(index), + Error, }); impl_stable_hash_for!(enum hir::LifetimeName { @@ -152,6 +153,7 @@ Implicit, Underscore, Static, + Error, }); impl_stable_hash_for!(struct hir::Label { @@ -172,6 +174,8 @@ impl_stable_hash_for!(struct hir::PathSegment { ident -> (ident.name), + id, + def, infer_types, args }); @@ -207,14 +211,21 @@ kind }); +impl_stable_hash_for!(enum hir::LifetimeParamKind { + Explicit, + InBand, + Elided, + Error, +}); + impl<'a> HashStable> for hir::GenericParamKind { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { mem::discriminant(self).hash_stable(hcx, hasher); match self { - hir::GenericParamKind::Lifetime { in_band } => { - in_band.hash_stable(hcx, hasher); + hir::GenericParamKind::Lifetime { kind } => { + kind.hash_stable(hcx, hasher); } hir::GenericParamKind::Type { ref default, synthetic } => { default.hash_stable(hcx, hasher); @@ -339,6 +350,7 @@ Never, Tup(ts), Path(qpath), + Def(it, lt), TraitObject(trait_refs, lifetime), Typeof(body_id), Err, @@ -349,7 +361,7 @@ inputs, output, variadic, - has_implicit_self + implicit_self }); impl_stable_hash_for!(enum hir::FunctionRetTy { @@ -357,6 +369,14 @@ Return(t) }); +impl_stable_hash_for!(enum hir::ImplicitSelfKind { + Imm, + Mut, + ImmRef, + MutRef, + None +}); + impl_stable_hash_for!(struct hir::TraitRef { // Don't hash the ref_id. It is tracked via the thing it is used to access ref_id -> _, @@ -968,7 +988,8 @@ impl_stable_hash_for!(struct hir::InlineAsmOutput { constraint, is_rw, - is_indirect + is_indirect, + span }); impl_stable_hash_for!(struct hir::GlobalAsm { @@ -998,6 +1019,7 @@ Builtin, Tool, DeriveHelper, + LegacyPluginHelper, Custom, }); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ich/impls_mir.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ich/impls_mir.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ich/impls_mir.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ich/impls_mir.rs 2018-12-04 23:41:40.000000000 +0000 @@ -29,6 +29,7 @@ source_info, visibility_scope, internal, + is_block_tail, is_user_variable }); impl_stable_hash_for!(struct mir::UpvarDecl { debug_name, var_hir_id, by_ref, mutability }); @@ -46,6 +47,7 @@ match *self { mir::BorrowKind::Shared | + mir::BorrowKind::Shallow | mir::BorrowKind::Unique => {} mir::BorrowKind::Mut { allow_two_phase_borrow } => { allow_two_phase_borrow.hash_stable(hcx, hasher); @@ -193,11 +195,13 @@ mir::TerminatorKind::Call { ref func, ref args, ref destination, - cleanup } => { + cleanup, + from_hir_call, } => { func.hash_stable(hcx, hasher); args.hash_stable(hcx, hasher); destination.hash_stable(hcx, hasher); cleanup.hash_stable(hcx, hasher); + from_hir_call.hash_stable(hcx, hasher); } mir::TerminatorKind::Assert { ref cond, expected, @@ -238,7 +242,8 @@ place.hash_stable(hcx, hasher); rvalue.hash_stable(hcx, hasher); } - mir::StatementKind::ReadForMatch(ref place) => { + mir::StatementKind::FakeRead(ref cause, ref place) => { + cause.hash_stable(hcx, hasher); place.hash_stable(hcx, hasher); } mir::StatementKind::SetDiscriminant { ref place, variant_index } => { @@ -271,6 +276,8 @@ } } +impl_stable_hash_for!(enum mir::FakeReadCause { ForMatchGuard, ForMatchedPlace, ForLet }); + impl<'a, 'gcx, T> HashStable> for mir::ValidationOperand<'gcx, T> where T: HashStable> @@ -544,7 +551,25 @@ impl_stable_hash_for!(struct mir::ClosureOutlivesRequirement<'tcx> { subject, outlived_free_region, - blame_span + blame_span, + category +}); + +impl_stable_hash_for!(enum mir::ConstraintCategory { + Return, + UseAsConst, + UseAsStatic, + TypeAnnotation, + Cast, + ClosureBounds, + CallArgument, + CopyBound, + SizedBound, + Assignment, + OpaqueType, + Boring, + BoringNoLocation, + Internal, }); impl<'a, 'gcx> HashStable> for mir::ClosureOutlivesSubject<'gcx> { @@ -564,3 +589,23 @@ } impl_stable_hash_for!(struct mir::interpret::GlobalId<'tcx> { instance, promoted }); + +impl<'a, 'gcx> HashStable> for mir::UserTypeAnnotation<'gcx> { + fn hash_stable(&self, + hcx: &mut StableHashingContext<'a>, + hasher: &mut StableHasher) { + mem::discriminant(self).hash_stable(hcx, hasher); + match *self { + mir::UserTypeAnnotation::Ty(ref ty) => { + ty.hash_stable(hcx, hasher); + } + mir::UserTypeAnnotation::TypeOf(ref def_id, ref substs) => { + def_id.hash_stable(hcx, hasher); + substs.hash_stable(hcx, hasher); + } + } + } +} + +impl_stable_hash_for!(struct mir::UserTypeProjection<'tcx> { base, projs }); +impl_stable_hash_for!(struct mir::UserTypeProjections<'tcx> { contents }); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ich/impls_syntax.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ich/impls_syntax.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ich/impls_syntax.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ich/impls_syntax.rs 2018-12-04 23:41:40.000000000 +0000 @@ -130,6 +130,7 @@ level, feature, rustc_depr, + promotable, const_stability }); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ich/impls_ty.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ich/impls_ty.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ich/impls_ty.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ich/impls_ty.rs 2018-12-04 23:41:40.000000000 +0000 @@ -32,7 +32,7 @@ hasher: &mut StableHasher) { thread_local! { static CACHE: RefCell> = - RefCell::new(FxHashMap()); + RefCell::new(Default::default()); } let hash = CACHE.with(|cache| { @@ -131,7 +131,7 @@ } ty::ReLateBound(..) | ty::ReVar(..) | - ty::ReSkolemized(..) => { + ty::RePlaceholder(..) => { bug!("StableHasher: unexpected region {:?}", *self) } } @@ -147,7 +147,7 @@ } } -impl<'gcx> HashStable> for ty::CanonicalVar { +impl<'gcx> HashStable> for ty::BoundTyIndex { #[inline] fn hash_stable(&self, hcx: &mut StableHashingContext<'gcx>, @@ -391,15 +391,39 @@ } } -impl_stable_hash_for!(enum mir::interpret::ScalarMaybeUndef { - Scalar(v), - Undef -}); +impl<'a, Tag> HashStable> +for ::mir::interpret::Pointer +where Tag: HashStable> +{ + fn hash_stable(&self, + hcx: &mut StableHashingContext<'a>, + hasher: &mut StableHasher) { + let ::mir::interpret::Pointer { alloc_id, offset, tag } = self; + alloc_id.hash_stable(hcx, hasher); + offset.hash_stable(hcx, hasher); + tag.hash_stable(hcx, hasher); + } +} -impl_stable_hash_for!(struct mir::interpret::Pointer { - alloc_id, - offset -}); +impl<'a, Tag> HashStable> +for ::mir::interpret::Scalar +where Tag: HashStable> +{ + fn hash_stable(&self, + hcx: &mut StableHashingContext<'a>, + hasher: &mut StableHasher) { + use mir::interpret::Scalar::*; + + mem::discriminant(self).hash_stable(hcx, hasher); + match self { + Bits { bits, size } => { + bits.hash_stable(hcx, hasher); + size.hash_stable(hcx, hasher); + }, + Ptr(ptr) => ptr.hash_stable(hcx, hasher), + } + } +} impl<'a> HashStable> for mir::interpret::AllocId { fn hash_stable( @@ -454,25 +478,6 @@ Mutable }); - -impl<'a> HashStable> -for ::mir::interpret::Scalar { - fn hash_stable(&self, - hcx: &mut StableHashingContext<'a>, - hasher: &mut StableHasher) { - use mir::interpret::Scalar::*; - - mem::discriminant(self).hash_stable(hcx, hasher); - match *self { - Bits { bits, size } => { - bits.hash_stable(hcx, hasher); - size.hash_stable(hcx, hasher); - }, - Ptr(ptr) => ptr.hash_stable(hcx, hasher), - } - } -} - impl_stable_hash_for!(struct ty::Const<'tcx> { ty, val @@ -565,6 +570,10 @@ a.hash_stable(hcx, hasher); b.hash_stable(hcx, hasher) }, + FunctionRetMismatch(a, b) => { + a.hash_stable(hcx, hasher); + b.hash_stable(hcx, hasher) + }, NoMirFor(ref s) => s.hash_stable(hcx, hasher), UnterminatedCString(ptr) => ptr.hash_stable(hcx, hasher), PointerOutOfBounds { @@ -746,8 +755,9 @@ } impl_stable_hash_for!(enum ::middle::resolve_lifetime::LifetimeDefOrigin { - Explicit, - InBand + ExplicitOrElided, + InBand, + Error, }); impl_stable_hash_for!(enum ::middle::resolve_lifetime::Region { @@ -878,8 +888,8 @@ Tuple(inner_tys) => { inner_tys.hash_stable(hcx, hasher); } - Projection(ref projection_ty) => { - projection_ty.hash_stable(hcx, hasher); + Projection(ref data) | UnnormalizedProjection(ref data) => { + data.hash_stable(hcx, hasher); } Opaque(def_id, substs) => { def_id.hash_stable(hcx, hasher); @@ -905,7 +915,7 @@ FreshTy(a), FreshIntTy(a), FreshFloatTy(a), - CanonicalTy(a), + BoundTy(a), }); impl<'a, 'gcx> HashStable> @@ -1033,6 +1043,7 @@ unsafety, paren_sugar, has_auto_impl, + is_marker, def_path_hash, }); @@ -1287,7 +1298,7 @@ }); impl_stable_hash_for!( - impl<'tcx, R> for struct infer::canonical::QueryResult<'tcx, R> { + impl<'tcx, R> for struct infer::canonical::QueryResponse<'tcx, R> { var_values, region_constraints, certainty, value } ); @@ -1360,7 +1371,7 @@ fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - use traits::Goal::*; + use traits::GoalKind::*; mem::discriminant(self).hash_stable(hcx, hasher); match self { @@ -1385,10 +1396,16 @@ impl_stable_hash_for!( impl<'tcx> for struct traits::ProgramClause<'tcx> { - goal, hypotheses + goal, hypotheses, category } ); +impl_stable_hash_for!(enum traits::ProgramClauseCategory { + ImpliedBound, + WellFormed, + Other, +}); + impl<'a, 'tcx> HashStable> for traits::Clause<'tcx> { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, @@ -1407,3 +1424,13 @@ Universal, Existential }); + +impl_stable_hash_for!(struct ty::subst::UserSubsts<'tcx> { substs, user_self_ty }); + +impl_stable_hash_for!(struct ty::subst::UserSelfTy<'tcx> { impl_def_id, self_ty }); + +impl_stable_hash_for!( + impl<'tcx> for struct traits::Environment<'tcx> { + clauses, + } +); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ich/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ich/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ich/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ich/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -30,16 +30,7 @@ pub const ATTR_THEN_THIS_WOULD_NEED: &'static str = "rustc_then_this_would_need"; pub const ATTR_PARTITION_REUSED: &'static str = "rustc_partition_reused"; pub const ATTR_PARTITION_CODEGENED: &'static str = "rustc_partition_codegened"; - - -pub const DEP_GRAPH_ASSERT_ATTRS: &'static [&'static str] = &[ - ATTR_IF_THIS_CHANGED, - ATTR_THEN_THIS_WOULD_NEED, - ATTR_DIRTY, - ATTR_CLEAN, - ATTR_PARTITION_REUSED, - ATTR_PARTITION_CODEGENED, -]; +pub const ATTR_EXPECTED_CGU_REUSE: &'static str = "rustc_expected_cgu_reuse"; pub const IGNORED_ATTRIBUTES: &'static [&'static str] = &[ "cfg", @@ -49,4 +40,5 @@ ATTR_CLEAN, ATTR_PARTITION_REUSED, ATTR_PARTITION_CODEGENED, + ATTR_EXPECTED_CGU_REUSE, ]; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/at.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/at.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/at.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/at.rs 2018-12-04 23:41:40.000000000 +0000 @@ -142,6 +142,28 @@ self.trace(expected, actual).eq(&expected, &actual) } + pub fn relate( + self, + expected: T, + variance: ty::Variance, + actual: T, + ) -> InferResult<'tcx, ()> + where T: ToTrace<'tcx> + { + match variance { + ty::Variance::Covariant => self.sub(expected, actual), + ty::Variance::Invariant => self.eq(expected, actual), + ty::Variance::Contravariant => self.sup(expected, actual), + + // We could make this make sense but it's not readily + // exposed and I don't feel like dealing with it. Note + // that bivariance in general does a bit more than just + // *nothing*, it checks that the types are the same + // "modulo variance" basically. + ty::Variance::Bivariant => panic!("Bivariant given to `relate()`"), + } + } + /// Compute the least-upper-bound, or mutual supertype, of two /// values. The order of the arguments doesn't matter, but since /// this can result in an error (e.g., if asked to compute LUB of diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/canonical/canonicalizer.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/canonical/canonicalizer.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/canonical/canonicalizer.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/canonical/canonicalizer.rs 2018-12-04 23:41:40.000000000 +0000 @@ -17,13 +17,13 @@ use infer::canonical::{ Canonical, CanonicalTyVarKind, CanonicalVarInfo, CanonicalVarKind, Canonicalized, - SmallCanonicalVarValues, + OriginalQueryValues, }; use infer::InferCtxt; use std::sync::atomic::Ordering; use ty::fold::{TypeFoldable, TypeFolder}; use ty::subst::Kind; -use ty::{self, CanonicalVar, Lift, List, Ty, TyCtxt, TypeFlags}; +use ty::{self, BoundTy, BoundTyIndex, Lift, List, Ty, TyCtxt, TypeFlags}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::indexed_vec::Idx; @@ -48,7 +48,7 @@ pub fn canonicalize_query( &self, value: &V, - var_values: &mut SmallCanonicalVarValues<'tcx> + query_state: &mut OriginalQueryValues<'tcx>, ) -> Canonicalized<'gcx, V> where V: TypeFoldable<'tcx> + Lift<'gcx>, @@ -63,11 +63,8 @@ value, Some(self), self.tcx, - CanonicalizeRegionMode { - static_region: true, - other_free_regions: true, - }, - var_values, + &CanonicalizeAllFreeRegions, + query_state, ) } @@ -96,23 +93,17 @@ /// out the [chapter in the rustc guide][c]. /// /// [c]: https://rust-lang-nursery.github.io/rustc-guide/traits/canonicalization.html#canonicalizing-the-query-result - pub fn canonicalize_response( - &self, - value: &V, - ) -> Canonicalized<'gcx, V> + pub fn canonicalize_response(&self, value: &V) -> Canonicalized<'gcx, V> where V: TypeFoldable<'tcx> + Lift<'gcx>, { - let mut var_values = SmallVec::new(); + let mut query_state = OriginalQueryValues::default(); Canonicalizer::canonicalize( value, Some(self), self.tcx, - CanonicalizeRegionMode { - static_region: false, - other_free_regions: false, - }, - &mut var_values + &CanonicalizeQueryResponse, + &mut query_state, ) } @@ -128,7 +119,7 @@ pub fn canonicalize_hr_query_hack( &self, value: &V, - var_values: &mut SmallCanonicalVarValues<'tcx> + query_state: &mut OriginalQueryValues<'tcx>, ) -> Canonicalized<'gcx, V> where V: TypeFoldable<'tcx> + Lift<'gcx>, @@ -143,27 +134,87 @@ value, Some(self), self.tcx, - CanonicalizeRegionMode { - static_region: false, - other_free_regions: true, - }, - var_values + &CanonicalizeFreeRegionsOtherThanStatic, + query_state, ) } } -/// If this flag is true, then all free regions will be replaced with -/// a canonical var. This is used to make queries as generic as -/// possible. For example, the query `F: Foo<'static>` would be -/// canonicalized to `F: Foo<'0>`. -struct CanonicalizeRegionMode { - static_region: bool, - other_free_regions: bool, +/// Controls how we canonicalize "free regions" that are not inference +/// variables. This depends on what we are canonicalizing *for* -- +/// e.g., if we are canonicalizing to create a query, we want to +/// replace those with inference variables, since we want to make a +/// maximally general query. But if we are canonicalizing a *query +/// response*, then we don't typically replace free regions, as they +/// must have been introduced from other parts of the system. +trait CanonicalizeRegionMode { + fn canonicalize_free_region( + &self, + canonicalizer: &mut Canonicalizer<'_, '_, 'tcx>, + r: ty::Region<'tcx>, + ) -> ty::Region<'tcx>; + + fn any(&self) -> bool; } -impl CanonicalizeRegionMode { +struct CanonicalizeQueryResponse; + +impl CanonicalizeRegionMode for CanonicalizeQueryResponse { + fn canonicalize_free_region( + &self, + _canonicalizer: &mut Canonicalizer<'_, '_, 'tcx>, + r: ty::Region<'tcx>, + ) -> ty::Region<'tcx> { + match r { + ty::ReFree(_) | ty::ReEmpty | ty::ReErased | ty::ReStatic | ty::ReEarlyBound(..) => r, + _ => { + // Other than `'static` or `'empty`, the query + // response should be executing in a fully + // canonicalized environment, so there shouldn't be + // any other region names it can come up. + bug!("unexpected region in query response: `{:?}`", r) + } + } + } + fn any(&self) -> bool { - self.static_region || self.other_free_regions + false + } +} + +struct CanonicalizeAllFreeRegions; + +impl CanonicalizeRegionMode for CanonicalizeAllFreeRegions { + fn canonicalize_free_region( + &self, + canonicalizer: &mut Canonicalizer<'_, '_, 'tcx>, + r: ty::Region<'tcx>, + ) -> ty::Region<'tcx> { + canonicalizer.canonical_var_for_region(r) + } + + fn any(&self) -> bool { + true + } +} + +struct CanonicalizeFreeRegionsOtherThanStatic; + +impl CanonicalizeRegionMode for CanonicalizeFreeRegionsOtherThanStatic { + fn canonicalize_free_region( + &self, + canonicalizer: &mut Canonicalizer<'_, '_, 'tcx>, + r: ty::Region<'tcx>, + ) -> ty::Region<'tcx> { + if let ty::ReStatic = r { + r + } else { + canonicalizer.canonical_var_for_region(r) + } + } + + fn any(&self) -> bool { + true } } @@ -171,11 +222,11 @@ infcx: Option<&'cx InferCtxt<'cx, 'gcx, 'tcx>>, tcx: TyCtxt<'cx, 'gcx, 'tcx>, variables: SmallVec<[CanonicalVarInfo; 8]>, - var_values: &'cx mut SmallCanonicalVarValues<'tcx>, + query_state: &'cx mut OriginalQueryValues<'tcx>, // Note that indices is only used once `var_values` is big enough to be // heap-allocated. - indices: FxHashMap, CanonicalVar>, - canonicalize_region_mode: CanonicalizeRegionMode, + indices: FxHashMap, BoundTyIndex>, + canonicalize_region_mode: &'cx dyn CanonicalizeRegionMode, needs_canonical_flags: TypeFlags, } @@ -192,51 +243,25 @@ } ty::ReVar(vid) => { - let r = self - .infcx + let r = self.infcx .unwrap() .borrow_region_constraints() .opportunistic_resolve_var(self.tcx, vid); - let info = CanonicalVarInfo { - kind: CanonicalVarKind::Region, - }; debug!( "canonical: region var found with vid {:?}, \ opportunistically resolved to {:?}", vid, r ); - let cvar = self.canonical_var(info, r.into()); - self.tcx().mk_region(ty::ReCanonical(cvar)) + self.canonical_var_for_region(r) } - ty::ReStatic => { - if self.canonicalize_region_mode.static_region { - let info = CanonicalVarInfo { - kind: CanonicalVarKind::Region, - }; - let cvar = self.canonical_var(info, r.into()); - self.tcx().mk_region(ty::ReCanonical(cvar)) - } else { - r - } - } - - ty::ReEarlyBound(..) + ty::ReStatic + | ty::ReEarlyBound(..) | ty::ReFree(_) | ty::ReScope(_) - | ty::ReSkolemized(..) + | ty::RePlaceholder(..) | ty::ReEmpty - | ty::ReErased => { - if self.canonicalize_region_mode.other_free_regions { - let info = CanonicalVarInfo { - kind: CanonicalVarKind::Region, - }; - let cvar = self.canonical_var(info, r.into()); - self.tcx().mk_region(ty::ReCanonical(cvar)) - } else { - r - } - } + | ty::ReErased => self.canonicalize_region_mode.canonicalize_free_region(self, r), ty::ReClosureBound(..) | ty::ReCanonical(_) => { bug!("canonical region encountered during canonicalization") @@ -258,7 +283,7 @@ bug!("encountered a fresh type during canonicalization") } - ty::Infer(ty::CanonicalTy(_)) => { + ty::Infer(ty::BoundTy(_)) => { bug!("encountered a canonical type during canonicalization") } @@ -283,6 +308,7 @@ | ty::Never | ty::Tuple(..) | ty::Projection(..) + | ty::UnnormalizedProjection(..) | ty::Foreign(..) | ty::Param(..) | ty::Opaque(..) => { @@ -301,10 +327,10 @@ /// `canonicalize_query` and `canonicalize_response`. fn canonicalize( value: &V, - infcx: Option<&'cx InferCtxt<'cx, 'gcx, 'tcx>>, - tcx: TyCtxt<'cx, 'gcx, 'tcx>, - canonicalize_region_mode: CanonicalizeRegionMode, - var_values: &'cx mut SmallCanonicalVarValues<'tcx> + infcx: Option<&InferCtxt<'_, 'gcx, 'tcx>>, + tcx: TyCtxt<'_, 'gcx, 'tcx>, + canonicalize_region_mode: &dyn CanonicalizeRegionMode, + query_state: &mut OriginalQueryValues<'tcx>, ) -> Canonicalized<'gcx, V> where V: TypeFoldable<'tcx> + Lift<'gcx>, @@ -339,7 +365,7 @@ canonicalize_region_mode, needs_canonical_flags, variables: SmallVec::new(), - var_values, + query_state, indices: FxHashMap::default(), }; let out_value = value.fold_with(&mut canonicalizer); @@ -367,25 +393,27 @@ /// or returns an existing variable if `kind` has already been /// seen. `kind` is expected to be an unbound variable (or /// potentially a free region). - fn canonical_var(&mut self, info: CanonicalVarInfo, kind: Kind<'tcx>) -> CanonicalVar { + fn canonical_var(&mut self, info: CanonicalVarInfo, kind: Kind<'tcx>) -> BoundTy { let Canonicalizer { variables, - var_values, + query_state, indices, .. } = self; + let var_values = &mut query_state.var_values; + // This code is hot. `variables` and `var_values` are usually small // (fewer than 8 elements ~95% of the time). They are SmallVec's to // avoid allocations in those cases. We also don't use `indices` to // determine if a kind has been seen before until the limit of 8 has // been exceeded, to also avoid allocations for `indices`. - if !var_values.spilled() { + let var = if !var_values.spilled() { // `var_values` is stack-allocated. `indices` isn't used yet. Do a // direct linear search of `var_values`. if let Some(idx) = var_values.iter().position(|&k| k == kind) { // `kind` is already present in `var_values`. - CanonicalVar::new(idx) + BoundTyIndex::new(idx) } else { // `kind` isn't present in `var_values`. Append it. Likewise // for `info` and `variables`. @@ -397,28 +425,40 @@ // fill up `indices` to facilitate subsequent lookups. if var_values.spilled() { assert!(indices.is_empty()); - *indices = - var_values.iter() - .enumerate() - .map(|(i, &kind)| (kind, CanonicalVar::new(i))) - .collect(); + *indices = var_values + .iter() + .enumerate() + .map(|(i, &kind)| (kind, BoundTyIndex::new(i))) + .collect(); } // The cv is the index of the appended element. - CanonicalVar::new(var_values.len() - 1) + BoundTyIndex::new(var_values.len() - 1) } } else { // `var_values` is large. Do a hashmap search via `indices`. - *indices - .entry(kind) - .or_insert_with(|| { - variables.push(info); - var_values.push(kind); - assert_eq!(variables.len(), var_values.len()); - CanonicalVar::new(variables.len() - 1) - }) + *indices.entry(kind).or_insert_with(|| { + variables.push(info); + var_values.push(kind); + assert_eq!(variables.len(), var_values.len()); + BoundTyIndex::new(variables.len() - 1) + }) + }; + + BoundTy { + level: ty::INNERMOST, + var, } } + fn canonical_var_for_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { + let info = CanonicalVarInfo { + kind: CanonicalVarKind::Region, + }; + let b = self.canonical_var(info, r.into()); + debug_assert_eq!(ty::INNERMOST, b.level); + self.tcx().mk_region(ty::ReCanonical(b.var)) + } + /// Given a type variable `ty_var` of the given kind, first check /// if `ty_var` is bound to anything; if so, canonicalize /// *that*. Otherwise, create a new canonical variable for @@ -432,8 +472,9 @@ let info = CanonicalVarInfo { kind: CanonicalVarKind::Ty(ty_kind), }; - let cvar = self.canonical_var(info, ty_var.into()); - self.tcx().mk_infer(ty::InferTy::CanonicalTy(cvar)) + let b = self.canonical_var(info, ty_var.into()); + debug_assert_eq!(ty::INNERMOST, b.level); + self.tcx().mk_infer(ty::InferTy::BoundTy(b)) } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/canonical/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/canonical/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/canonical/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/canonical/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -40,11 +40,11 @@ use syntax::source_map::Span; use ty::fold::TypeFoldable; use ty::subst::Kind; -use ty::{self, CanonicalVar, Lift, Region, List, TyCtxt}; +use ty::{self, BoundTyIndex, Lift, Region, List, TyCtxt}; mod canonicalizer; -pub mod query_result; +pub mod query_response; mod substitute; @@ -72,12 +72,19 @@ /// canonicalized query response. #[derive(Clone, Debug, PartialEq, Eq, Hash, RustcDecodable, RustcEncodable)] pub struct CanonicalVarValues<'tcx> { - pub var_values: IndexVec>, + pub var_values: IndexVec>, } -/// Like CanonicalVarValues, but for use in places where a SmallVec is -/// appropriate. -pub type SmallCanonicalVarValues<'tcx> = SmallVec<[Kind<'tcx>; 8]>; +/// When we canonicalize a value to form a query, we wind up replacing +/// various parts of it with canonical variables. This struct stores +/// those replaced bits to remember for when we process the query +/// result. +#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, RustcDecodable, RustcEncodable)] +pub struct OriginalQueryValues<'tcx> { + /// This is equivalent to `CanonicalVarValues`, but using a + /// `SmallVec` yields a significant performance win. + pub var_values: SmallVec<[Kind<'tcx>; 8]>, +} /// Information about a canonical variable that is included with the /// canonical value. This is sufficient information for code to create @@ -118,10 +125,10 @@ } /// After we execute a query with a canonicalized key, we get back a -/// `Canonical>`. You can use +/// `Canonical>`. You can use /// `instantiate_query_result` to access the data in this result. #[derive(Clone, Debug)] -pub struct QueryResult<'tcx, R> { +pub struct QueryResponse<'tcx, R> { pub var_values: CanonicalVarValues<'tcx>, pub region_constraints: Vec>, pub certainty: Certainty, @@ -130,8 +137,8 @@ pub type Canonicalized<'gcx, V> = Canonical<'gcx, >::Lifted>; -pub type CanonicalizedQueryResult<'gcx, T> = - Lrc>::Lifted>>>; +pub type CanonicalizedQueryResponse<'gcx, T> = + Lrc>::Lifted>>>; /// Indicates whether or not we were able to prove the query to be /// true. @@ -168,7 +175,7 @@ } } -impl<'tcx, R> QueryResult<'tcx, R> { +impl<'tcx, R> QueryResponse<'tcx, R> { pub fn is_proven(&self) -> bool { self.certainty.is_proven() } @@ -178,7 +185,7 @@ } } -impl<'tcx, R> Canonical<'tcx, QueryResult<'tcx, R>> { +impl<'tcx, R> Canonical<'tcx, QueryResponse<'tcx, R>> { pub fn is_proven(&self) -> bool { self.value.is_proven() } @@ -225,11 +232,15 @@ /// inference variables and applies it to the canonical value. /// Returns both the instantiated result *and* the substitution S. /// - /// This is useful at the start of a query: it basically brings - /// the canonical value "into scope" within your new infcx. At the - /// end of processing, the substitution S (once canonicalized) - /// then represents the values that you computed for each of the - /// canonical inputs to your query. + /// This is only meant to be invoked as part of constructing an + /// inference context at the start of a query (see + /// `InferCtxtBuilder::enter_with_canonical`). It basically + /// brings the canonical value "into scope" within your new infcx. + /// + /// At the end of processing, the substitution S (once + /// canonicalized) then represents the values that you computed + /// for each of the canonical inputs to your query. + pub fn instantiate_canonical_with_fresh_inference_vars( &self, span: Span, @@ -253,7 +264,7 @@ span: Span, variables: &List, ) -> CanonicalVarValues<'tcx> { - let var_values: IndexVec> = variables + let var_values: IndexVec> = variables .iter() .map(|info| self.fresh_inference_var_for_canonical_var(span, *info)) .collect(); @@ -344,22 +355,22 @@ } BraceStructTypeFoldableImpl! { - impl<'tcx, R> TypeFoldable<'tcx> for QueryResult<'tcx, R> { + impl<'tcx, R> TypeFoldable<'tcx> for QueryResponse<'tcx, R> { var_values, region_constraints, certainty, value } where R: TypeFoldable<'tcx>, } BraceStructLiftImpl! { - impl<'a, 'tcx, R> Lift<'tcx> for QueryResult<'a, R> { - type Lifted = QueryResult<'tcx, R::Lifted>; + impl<'a, 'tcx, R> Lift<'tcx> for QueryResponse<'a, R> { + type Lifted = QueryResponse<'tcx, R::Lifted>; var_values, region_constraints, certainty, value } where R: Lift<'tcx> } -impl<'tcx> Index for CanonicalVarValues<'tcx> { +impl<'tcx> Index for CanonicalVarValues<'tcx> { type Output = Kind<'tcx>; - fn index(&self, value: CanonicalVar) -> &Kind<'tcx> { + fn index(&self, value: BoundTyIndex) -> &Kind<'tcx> { &self.var_values[value] } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/canonical/query_response.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/canonical/query_response.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/canonical/query_response.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/canonical/query_response.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,606 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! This module contains the code to instantiate a "query result", and +//! in particular to extract out the resulting region obligations and +//! encode them therein. +//! +//! For an overview of what canonicaliation is and how it fits into +//! rustc, check out the [chapter in the rustc guide][c]. +//! +//! [c]: https://rust-lang-nursery.github.io/rustc-guide/traits/canonicalization.html + +use infer::canonical::substitute::substitute_value; +use infer::canonical::{ + Canonical, CanonicalVarValues, CanonicalizedQueryResponse, Certainty, + OriginalQueryValues, QueryRegionConstraint, QueryResponse, +}; +use infer::region_constraints::{Constraint, RegionConstraintData}; +use infer::InferCtxtBuilder; +use infer::{InferCtxt, InferOk, InferResult}; +use rustc_data_structures::indexed_vec::Idx; +use rustc_data_structures::indexed_vec::IndexVec; +use rustc_data_structures::sync::Lrc; +use std::fmt::Debug; +use syntax_pos::DUMMY_SP; +use traits::query::{Fallible, NoSolution}; +use traits::{FulfillmentContext, TraitEngine}; +use traits::{Obligation, ObligationCause, PredicateObligation}; +use ty::fold::TypeFoldable; +use ty::subst::{Kind, UnpackedKind}; +use ty::{self, BoundTyIndex, Lift, Ty, TyCtxt}; + +impl<'cx, 'gcx, 'tcx> InferCtxtBuilder<'cx, 'gcx, 'tcx> { + /// The "main method" for a canonicalized trait query. Given the + /// canonical key `canonical_key`, this method will create a new + /// inference context, instantiate the key, and run your operation + /// `op`. The operation should yield up a result (of type `R`) as + /// well as a set of trait obligations that must be fully + /// satisfied. These obligations will be processed and the + /// canonical result created. + /// + /// Returns `NoSolution` in the event of any error. + /// + /// (It might be mildly nicer to implement this on `TyCtxt`, and + /// not `InferCtxtBuilder`, but that is a bit tricky right now. + /// In part because we would need a `for<'gcx: 'tcx>` sort of + /// bound for the closure and in part because it is convenient to + /// have `'tcx` be free on this function so that we can talk about + /// `K: TypeFoldable<'tcx>`.) + pub fn enter_canonical_trait_query( + &'tcx mut self, + canonical_key: &Canonical<'tcx, K>, + operation: impl FnOnce(&InferCtxt<'_, 'gcx, 'tcx>, &mut FulfillmentContext<'tcx>, K) + -> Fallible, + ) -> Fallible> + where + K: TypeFoldable<'tcx>, + R: Debug + Lift<'gcx> + TypeFoldable<'tcx>, + { + self.enter_with_canonical( + DUMMY_SP, + canonical_key, + |ref infcx, key, canonical_inference_vars| { + let fulfill_cx = &mut FulfillmentContext::new(); + let value = operation(infcx, fulfill_cx, key)?; + infcx.make_canonicalized_query_response(canonical_inference_vars, value, fulfill_cx) + }, + ) + } +} + +impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { + /// This method is meant to be invoked as the final step of a canonical query + /// implementation. It is given: + /// + /// - the instantiated variables `inference_vars` created from the query key + /// - the result `answer` of the query + /// - a fulfillment context `fulfill_cx` that may contain various obligations which + /// have yet to be proven. + /// + /// Given this, the function will process the obligations pending + /// in `fulfill_cx`: + /// + /// - If all the obligations can be proven successfully, it will + /// package up any resulting region obligations (extracted from + /// `infcx`) along with the fully resolved value `answer` into a + /// query result (which is then itself canonicalized). + /// - If some obligations can be neither proven nor disproven, then + /// the same thing happens, but the resulting query is marked as ambiguous. + /// - Finally, if any of the obligations result in a hard error, + /// then `Err(NoSolution)` is returned. + pub fn make_canonicalized_query_response( + &self, + inference_vars: CanonicalVarValues<'tcx>, + answer: T, + fulfill_cx: &mut FulfillmentContext<'tcx>, + ) -> Fallible> + where + T: Debug + Lift<'gcx> + TypeFoldable<'tcx>, + { + let query_response = self.make_query_response(inference_vars, answer, fulfill_cx)?; + let canonical_result = self.canonicalize_response(&query_response); + + debug!( + "make_canonicalized_query_response: canonical_result = {:#?}", + canonical_result + ); + + Ok(Lrc::new(canonical_result)) + } + + /// Helper for `make_canonicalized_query_response` that does + /// everything up until the final canonicalization. + fn make_query_response( + &self, + inference_vars: CanonicalVarValues<'tcx>, + answer: T, + fulfill_cx: &mut FulfillmentContext<'tcx>, + ) -> Result, NoSolution> + where + T: Debug + TypeFoldable<'tcx> + Lift<'gcx>, + { + let tcx = self.tcx; + + debug!( + "make_query_response(\ + inference_vars={:?}, \ + answer={:?})", + inference_vars, answer, + ); + + // Select everything, returning errors. + let true_errors = fulfill_cx.select_where_possible(self).err().unwrap_or_else(Vec::new); + debug!("true_errors = {:#?}", true_errors); + + if !true_errors.is_empty() { + // FIXME -- we don't indicate *why* we failed to solve + debug!("make_query_response: true_errors={:#?}", true_errors); + return Err(NoSolution); + } + + // Anything left unselected *now* must be an ambiguity. + let ambig_errors = fulfill_cx.select_all_or_error(self).err().unwrap_or_else(Vec::new); + debug!("ambig_errors = {:#?}", ambig_errors); + + let region_obligations = self.take_registered_region_obligations(); + let region_constraints = self.with_region_constraints(|region_constraints| { + make_query_outlives( + tcx, + region_obligations + .iter() + .map(|(_, r_o)| (r_o.sup_type, r_o.sub_region)), + region_constraints, + ) + }); + + let certainty = if ambig_errors.is_empty() { + Certainty::Proven + } else { + Certainty::Ambiguous + }; + + Ok(QueryResponse { + var_values: inference_vars, + region_constraints, + certainty, + value: answer, + }) + } + + /// Given the (canonicalized) result to a canonical query, + /// instantiates the result so it can be used, plugging in the + /// values from the canonical query. (Note that the result may + /// have been ambiguous; you should check the certainty level of + /// the query before applying this function.) + /// + /// To get a good understanding of what is happening here, check + /// out the [chapter in the rustc guide][c]. + /// + /// [c]: https://rust-lang-nursery.github.io/rustc-guide/traits/canonicalization.html#processing-the-canonicalized-query-result + pub fn instantiate_query_response_and_region_obligations( + &self, + cause: &ObligationCause<'tcx>, + param_env: ty::ParamEnv<'tcx>, + original_values: &OriginalQueryValues<'tcx>, + query_response: &Canonical<'tcx, QueryResponse<'tcx, R>>, + ) -> InferResult<'tcx, R> + where + R: Debug + TypeFoldable<'tcx>, + { + let InferOk { + value: result_subst, + mut obligations, + } = self.query_response_substitution(cause, param_env, original_values, query_response)?; + + obligations.extend(self.query_region_constraints_into_obligations( + cause, + param_env, + &query_response.value.region_constraints, + &result_subst, + )); + + let user_result: R = + query_response.substitute_projected(self.tcx, &result_subst, |q_r| &q_r.value); + + Ok(InferOk { + value: user_result, + obligations, + }) + } + + /// An alternative to + /// `instantiate_query_response_and_region_obligations` that is more + /// efficient for NLL. NLL is a bit more advanced in the + /// "transition to chalk" than the rest of the compiler. During + /// the NLL type check, all of the "processing" of types and + /// things happens in queries -- the NLL checker itself is only + /// interested in the region obligations (`'a: 'b` or `T: 'b`) + /// that come out of these queries, which it wants to convert into + /// MIR-based constraints and solve. Therefore, it is most + /// convenient for the NLL Type Checker to **directly consume** + /// the `QueryRegionConstraint` values that arise from doing a + /// query. This is contrast to other parts of the compiler, which + /// would prefer for those `QueryRegionConstraint` to be converted + /// into the older infcx-style constraints (e.g., calls to + /// `sub_regions` or `register_region_obligation`). + /// + /// Therefore, `instantiate_nll_query_response_and_region_obligations` performs the same + /// basic operations as `instantiate_query_response_and_region_obligations` but + /// it returns its result differently: + /// + /// - It creates a substitution `S` that maps from the original + /// query variables to the values computed in the query + /// result. If any errors arise, they are propagated back as an + /// `Err` result. + /// - In the case of a successful substitution, we will append + /// `QueryRegionConstraint` values onto the + /// `output_query_region_constraints` vector for the solver to + /// use (if an error arises, some values may also be pushed, but + /// they should be ignored). + /// - It **can happen** (though it rarely does currently) that + /// equating types and things will give rise to subobligations + /// that must be processed. In this case, those subobligations + /// are propagated back in the return value. + /// - Finally, the query result (of type `R`) is propagated back, + /// after applying the substitution `S`. + pub fn instantiate_nll_query_response_and_region_obligations( + &self, + cause: &ObligationCause<'tcx>, + param_env: ty::ParamEnv<'tcx>, + original_values: &OriginalQueryValues<'tcx>, + query_response: &Canonical<'tcx, QueryResponse<'tcx, R>>, + output_query_region_constraints: &mut Vec>, + ) -> InferResult<'tcx, R> + where + R: Debug + TypeFoldable<'tcx>, + { + let result_subst = + self.query_response_substitution_guess(cause, original_values, query_response); + + // Compute `QueryRegionConstraint` values that unify each of + // the original values `v_o` that was canonicalized into a + // variable... + let mut obligations = vec![]; + + for (index, original_value) in original_values.var_values.iter().enumerate() { + // ...with the value `v_r` of that variable from the query. + let result_value = query_response.substitute_projected(self.tcx, &result_subst, |v| { + &v.var_values[BoundTyIndex::new(index)] + }); + match (original_value.unpack(), result_value.unpack()) { + (UnpackedKind::Lifetime(ty::ReErased), UnpackedKind::Lifetime(ty::ReErased)) => { + // no action needed + } + + (UnpackedKind::Lifetime(v_o), UnpackedKind::Lifetime(v_r)) => { + // To make `v_o = v_r`, we emit `v_o: v_r` and `v_r: v_o`. + if v_o != v_r { + output_query_region_constraints + .push(ty::Binder::dummy(ty::OutlivesPredicate(v_o.into(), v_r))); + output_query_region_constraints + .push(ty::Binder::dummy(ty::OutlivesPredicate(v_r.into(), v_o))); + } + } + + (UnpackedKind::Type(v1), UnpackedKind::Type(v2)) => { + let ok = self.at(cause, param_env).eq(v1, v2)?; + obligations.extend(ok.into_obligations()); + } + + _ => { + bug!( + "kind mismatch, cannot unify {:?} and {:?}", + original_value, + result_value + ); + } + } + } + + // ...also include the other query region constraints from the query. + output_query_region_constraints.extend( + query_response.value.region_constraints.iter().filter_map(|r_c| { + let &ty::OutlivesPredicate(k1, r2) = r_c.skip_binder(); // reconstructed below + let k1 = substitute_value(self.tcx, &result_subst, &k1); + let r2 = substitute_value(self.tcx, &result_subst, &r2); + if k1 != r2.into() { + Some(ty::Binder::bind(ty::OutlivesPredicate(k1, r2))) + } else { + None + } + }) + ); + + let user_result: R = + query_response.substitute_projected(self.tcx, &result_subst, |q_r| &q_r.value); + + Ok(InferOk { + value: user_result, + obligations, + }) + } + + /// Given the original values and the (canonicalized) result from + /// computing a query, returns a substitution that can be applied + /// to the query result to convert the result back into the + /// original namespace. + /// + /// The substitution also comes accompanied with subobligations + /// that arose from unification; these might occur if (for + /// example) we are doing lazy normalization and the value + /// assigned to a type variable is unified with an unnormalized + /// projection. + fn query_response_substitution( + &self, + cause: &ObligationCause<'tcx>, + param_env: ty::ParamEnv<'tcx>, + original_values: &OriginalQueryValues<'tcx>, + query_response: &Canonical<'tcx, QueryResponse<'tcx, R>>, + ) -> InferResult<'tcx, CanonicalVarValues<'tcx>> + where + R: Debug + TypeFoldable<'tcx>, + { + debug!( + "query_response_substitution(original_values={:#?}, query_response={:#?})", + original_values, query_response, + ); + + let result_subst = + self.query_response_substitution_guess(cause, original_values, query_response); + + let obligations = self.unify_query_response_substitution_guess( + cause, + param_env, + original_values, + &result_subst, + query_response, + )? + .into_obligations(); + + Ok(InferOk { + value: result_subst, + obligations, + }) + } + + /// Given the original values and the (canonicalized) result from + /// computing a query, returns a **guess** at a substitution that + /// can be applied to the query result to convert the result back + /// into the original namespace. This is called a **guess** + /// because it uses a quick heuristic to find the values for each + /// canonical variable; if that quick heuristic fails, then we + /// will instantiate fresh inference variables for each canonical + /// variable instead. Therefore, the result of this method must be + /// properly unified + fn query_response_substitution_guess( + &self, + cause: &ObligationCause<'tcx>, + original_values: &OriginalQueryValues<'tcx>, + query_response: &Canonical<'tcx, QueryResponse<'tcx, R>>, + ) -> CanonicalVarValues<'tcx> + where + R: Debug + TypeFoldable<'tcx>, + { + debug!( + "query_response_substitution_guess(original_values={:#?}, query_response={:#?})", + original_values, query_response, + ); + + // Every canonical query result includes values for each of + // the inputs to the query. Therefore, we begin by unifying + // these values with the original inputs that were + // canonicalized. + let result_values = &query_response.value.var_values; + assert_eq!(original_values.var_values.len(), result_values.len()); + + // Quickly try to find initial values for the canonical + // variables in the result in terms of the query. We do this + // by iterating down the values that the query gave to each of + // the canonical inputs. If we find that one of those values + // is directly equal to one of the canonical variables in the + // result, then we can type the corresponding value from the + // input. See the example above. + let mut opt_values: IndexVec>> = + IndexVec::from_elem_n(None, query_response.variables.len()); + + // In terms of our example above, we are iterating over pairs like: + // [(?A, Vec), ('static, '?1), (?B, ?0)] + for (original_value, result_value) in original_values.var_values.iter().zip(result_values) { + match result_value.unpack() { + UnpackedKind::Type(result_value) => { + // e.g., here `result_value` might be `?0` in the example above... + if let ty::Infer(ty::InferTy::BoundTy(b)) = result_value.sty { + // in which case we would set `canonical_vars[0]` to `Some(?U)`. + opt_values[b.var] = Some(*original_value); + } + } + UnpackedKind::Lifetime(result_value) => { + // e.g., here `result_value` might be `'?1` in the example above... + if let &ty::RegionKind::ReCanonical(index) = result_value { + // in which case we would set `canonical_vars[0]` to `Some('static)`. + opt_values[index] = Some(*original_value); + } + } + } + } + + // Create a result substitution: if we found a value for a + // given variable in the loop above, use that. Otherwise, use + // a fresh inference variable. + let result_subst = CanonicalVarValues { + var_values: query_response + .variables + .iter() + .enumerate() + .map(|(index, info)| opt_values[BoundTyIndex::new(index)].unwrap_or_else(|| + self.fresh_inference_var_for_canonical_var(cause.span, *info) + )) + .collect(), + }; + + result_subst + } + + /// Given a "guess" at the values for the canonical variables in + /// the input, try to unify with the *actual* values found in the + /// query result. Often, but not always, this is a no-op, because + /// we already found the mapping in the "guessing" step. + /// + /// See also: `query_response_substitution_guess` + fn unify_query_response_substitution_guess( + &self, + cause: &ObligationCause<'tcx>, + param_env: ty::ParamEnv<'tcx>, + original_values: &OriginalQueryValues<'tcx>, + result_subst: &CanonicalVarValues<'tcx>, + query_response: &Canonical<'tcx, QueryResponse<'tcx, R>>, + ) -> InferResult<'tcx, ()> + where + R: Debug + TypeFoldable<'tcx>, + { + // A closure that yields the result value for the given + // canonical variable; this is taken from + // `query_response.var_values` after applying the substitution + // `result_subst`. + let substituted_query_response = |index: BoundTyIndex| -> Kind<'tcx> { + query_response.substitute_projected(self.tcx, &result_subst, |v| &v.var_values[index]) + }; + + // Unify the original value for each variable with the value + // taken from `query_response` (after applying `result_subst`). + Ok(self.unify_canonical_vars( + cause, + param_env, + original_values, + substituted_query_response, + )?) + } + + /// Converts the region constraints resulting from a query into an + /// iterator of obligations. + fn query_region_constraints_into_obligations<'a>( + &'a self, + cause: &'a ObligationCause<'tcx>, + param_env: ty::ParamEnv<'tcx>, + unsubstituted_region_constraints: &'a [QueryRegionConstraint<'tcx>], + result_subst: &'a CanonicalVarValues<'tcx>, + ) -> impl Iterator> + 'a { + Box::new( + unsubstituted_region_constraints + .iter() + .map(move |constraint| { + let ty::OutlivesPredicate(k1, r2) = constraint.skip_binder(); // restored below + let k1 = substitute_value(self.tcx, result_subst, k1); + let r2 = substitute_value(self.tcx, result_subst, r2); + + Obligation::new( + cause.clone(), + param_env, + match k1.unpack() { + UnpackedKind::Lifetime(r1) => ty::Predicate::RegionOutlives( + ty::Binder::dummy( + ty::OutlivesPredicate(r1, r2) + )), + UnpackedKind::Type(t1) => ty::Predicate::TypeOutlives( + ty::Binder::dummy(ty::OutlivesPredicate( + t1, r2 + ))) + } + ) + }) + ) as Box> + } + + /// Given two sets of values for the same set of canonical variables, unify them. + /// The second set is produced lazilly by supplying indices from the first set. + fn unify_canonical_vars( + &self, + cause: &ObligationCause<'tcx>, + param_env: ty::ParamEnv<'tcx>, + variables1: &OriginalQueryValues<'tcx>, + variables2: impl Fn(BoundTyIndex) -> Kind<'tcx>, + ) -> InferResult<'tcx, ()> { + self.commit_if_ok(|_| { + let mut obligations = vec![]; + for (index, value1) in variables1.var_values.iter().enumerate() { + let value2 = variables2(BoundTyIndex::new(index)); + + match (value1.unpack(), value2.unpack()) { + (UnpackedKind::Type(v1), UnpackedKind::Type(v2)) => { + obligations + .extend(self.at(cause, param_env).eq(v1, v2)?.into_obligations()); + } + ( + UnpackedKind::Lifetime(ty::ReErased), + UnpackedKind::Lifetime(ty::ReErased), + ) => { + // no action needed + } + (UnpackedKind::Lifetime(v1), UnpackedKind::Lifetime(v2)) => { + obligations + .extend(self.at(cause, param_env).eq(v1, v2)?.into_obligations()); + } + _ => { + bug!("kind mismatch, cannot unify {:?} and {:?}", value1, value2,); + } + } + } + Ok(InferOk { + value: (), + obligations, + }) + }) + } +} + +/// Given the region obligations and constraints scraped from the infcx, +/// creates query region constraints. +pub fn make_query_outlives<'tcx>( + tcx: TyCtxt<'_, '_, 'tcx>, + outlives_obligations: impl Iterator, ty::Region<'tcx>)>, + region_constraints: &RegionConstraintData<'tcx>, +) -> Vec> { + let RegionConstraintData { + constraints, + verifys, + givens, + } = region_constraints; + + assert!(verifys.is_empty()); + assert!(givens.is_empty()); + + let outlives: Vec<_> = constraints + .into_iter() + .map(|(k, _)| match *k { + // Swap regions because we are going from sub (<=) to outlives + // (>=). + Constraint::VarSubVar(v1, v2) => ty::OutlivesPredicate( + tcx.mk_region(ty::ReVar(v2)).into(), + tcx.mk_region(ty::ReVar(v1)), + ), + Constraint::VarSubReg(v1, r2) => { + ty::OutlivesPredicate(r2.into(), tcx.mk_region(ty::ReVar(v1))) + } + Constraint::RegSubVar(r1, v2) => { + ty::OutlivesPredicate(tcx.mk_region(ty::ReVar(v2)).into(), r1) + } + Constraint::RegSubReg(r1, r2) => ty::OutlivesPredicate(r2.into(), r1), + }) + .map(ty::Binder::dummy) // no bound regions in the code above + .chain( + outlives_obligations + .map(|(ty, r)| ty::OutlivesPredicate(ty.into(), r)) + .map(ty::Binder::dummy), // no bound regions in the code above + ) + .collect(); + + outlives +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/canonical/query_result.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/canonical/query_result.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/canonical/query_result.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/canonical/query_result.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,613 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! This module contains the code to instantiate a "query result", and -//! in particular to extract out the resulting region obligations and -//! encode them therein. -//! -//! For an overview of what canonicaliation is and how it fits into -//! rustc, check out the [chapter in the rustc guide][c]. -//! -//! [c]: https://rust-lang-nursery.github.io/rustc-guide/traits/canonicalization.html - -use infer::canonical::substitute::substitute_value; -use infer::canonical::{ - Canonical, CanonicalVarKind, CanonicalVarValues, CanonicalizedQueryResult, Certainty, - QueryRegionConstraint, QueryResult, SmallCanonicalVarValues, -}; -use infer::region_constraints::{Constraint, RegionConstraintData}; -use infer::InferCtxtBuilder; -use infer::{InferCtxt, InferOk, InferResult}; -use rustc_data_structures::indexed_vec::Idx; -use rustc_data_structures::indexed_vec::IndexVec; -use rustc_data_structures::sync::Lrc; -use std::fmt::Debug; -use syntax_pos::DUMMY_SP; -use traits::query::{Fallible, NoSolution}; -use traits::{FulfillmentContext, TraitEngine}; -use traits::{Obligation, ObligationCause, PredicateObligation}; -use ty::fold::TypeFoldable; -use ty::subst::{Kind, UnpackedKind}; -use ty::{self, CanonicalVar, Lift, Ty, TyCtxt}; - -impl<'cx, 'gcx, 'tcx> InferCtxtBuilder<'cx, 'gcx, 'tcx> { - /// The "main method" for a canonicalized trait query. Given the - /// canonical key `canonical_key`, this method will create a new - /// inference context, instantiate the key, and run your operation - /// `op`. The operation should yield up a result (of type `R`) as - /// well as a set of trait obligations that must be fully - /// satisfied. These obligations will be processed and the - /// canonical result created. - /// - /// Returns `NoSolution` in the event of any error. - /// - /// (It might be mildly nicer to implement this on `TyCtxt`, and - /// not `InferCtxtBuilder`, but that is a bit tricky right now. - /// In part because we would need a `for<'gcx: 'tcx>` sort of - /// bound for the closure and in part because it is convenient to - /// have `'tcx` be free on this function so that we can talk about - /// `K: TypeFoldable<'tcx>`.) - pub fn enter_canonical_trait_query( - &'tcx mut self, - canonical_key: &Canonical<'tcx, K>, - operation: impl FnOnce(&InferCtxt<'_, 'gcx, 'tcx>, &mut FulfillmentContext<'tcx>, K) - -> Fallible, - ) -> Fallible> - where - K: TypeFoldable<'tcx>, - R: Debug + Lift<'gcx> + TypeFoldable<'tcx>, - { - self.enter(|ref infcx| { - let (key, canonical_inference_vars) = - infcx.instantiate_canonical_with_fresh_inference_vars(DUMMY_SP, &canonical_key); - let fulfill_cx = &mut FulfillmentContext::new(); - let value = operation(infcx, fulfill_cx, key)?; - infcx.make_canonicalized_query_result(canonical_inference_vars, value, fulfill_cx) - }) - } -} - -impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { - /// This method is meant to be invoked as the final step of a canonical query - /// implementation. It is given: - /// - /// - the instantiated variables `inference_vars` created from the query key - /// - the result `answer` of the query - /// - a fulfillment context `fulfill_cx` that may contain various obligations which - /// have yet to be proven. - /// - /// Given this, the function will process the obligations pending - /// in `fulfill_cx`: - /// - /// - If all the obligations can be proven successfully, it will - /// package up any resulting region obligations (extracted from - /// `infcx`) along with the fully resolved value `answer` into a - /// query result (which is then itself canonicalized). - /// - If some obligations can be neither proven nor disproven, then - /// the same thing happens, but the resulting query is marked as ambiguous. - /// - Finally, if any of the obligations result in a hard error, - /// then `Err(NoSolution)` is returned. - pub fn make_canonicalized_query_result( - &self, - inference_vars: CanonicalVarValues<'tcx>, - answer: T, - fulfill_cx: &mut FulfillmentContext<'tcx>, - ) -> Fallible> - where - T: Debug + Lift<'gcx> + TypeFoldable<'tcx>, - { - let query_result = self.make_query_result(inference_vars, answer, fulfill_cx)?; - let canonical_result = self.canonicalize_response(&query_result); - - debug!( - "make_canonicalized_query_result: canonical_result = {:#?}", - canonical_result - ); - - Ok(Lrc::new(canonical_result)) - } - - /// Helper for `make_canonicalized_query_result` that does - /// everything up until the final canonicalization. - fn make_query_result( - &self, - inference_vars: CanonicalVarValues<'tcx>, - answer: T, - fulfill_cx: &mut FulfillmentContext<'tcx>, - ) -> Result, NoSolution> - where - T: Debug + TypeFoldable<'tcx> + Lift<'gcx>, - { - let tcx = self.tcx; - - debug!( - "make_query_result(\ - inference_vars={:?}, \ - answer={:?})", - inference_vars, answer, - ); - - // Select everything, returning errors. - let true_errors = match fulfill_cx.select_where_possible(self) { - Ok(()) => vec![], - Err(errors) => errors, - }; - debug!("true_errors = {:#?}", true_errors); - - if !true_errors.is_empty() { - // FIXME -- we don't indicate *why* we failed to solve - debug!("make_query_result: true_errors={:#?}", true_errors); - return Err(NoSolution); - } - - // Anything left unselected *now* must be an ambiguity. - let ambig_errors = match fulfill_cx.select_all_or_error(self) { - Ok(()) => vec![], - Err(errors) => errors, - }; - debug!("ambig_errors = {:#?}", ambig_errors); - - let region_obligations = self.take_registered_region_obligations(); - let region_constraints = self.with_region_constraints(|region_constraints| { - make_query_outlives( - tcx, - region_obligations - .iter() - .map(|(_, r_o)| (r_o.sup_type, r_o.sub_region)), - region_constraints) - }); - - let certainty = if ambig_errors.is_empty() { - Certainty::Proven - } else { - Certainty::Ambiguous - }; - - Ok(QueryResult { - var_values: inference_vars, - region_constraints, - certainty, - value: answer, - }) - } - - /// Given the (canonicalized) result to a canonical query, - /// instantiates the result so it can be used, plugging in the - /// values from the canonical query. (Note that the result may - /// have been ambiguous; you should check the certainty level of - /// the query before applying this function.) - /// - /// To get a good understanding of what is happening here, check - /// out the [chapter in the rustc guide][c]. - /// - /// [c]: https://rust-lang-nursery.github.io/rustc-guide/traits/canonicalization.html#processing-the-canonicalized-query-result - pub fn instantiate_query_result_and_region_obligations( - &self, - cause: &ObligationCause<'tcx>, - param_env: ty::ParamEnv<'tcx>, - original_values: &SmallCanonicalVarValues<'tcx>, - query_result: &Canonical<'tcx, QueryResult<'tcx, R>>, - ) -> InferResult<'tcx, R> - where - R: Debug + TypeFoldable<'tcx>, - { - let InferOk { - value: result_subst, - mut obligations, - } = self.query_result_substitution(cause, param_env, original_values, query_result)?; - - obligations.extend(self.query_region_constraints_into_obligations( - cause, - param_env, - &query_result.value.region_constraints, - &result_subst, - )); - - let user_result: R = - query_result.substitute_projected(self.tcx, &result_subst, |q_r| &q_r.value); - - Ok(InferOk { - value: user_result, - obligations, - }) - } - - /// An alternative to - /// `instantiate_query_result_and_region_obligations` that is more - /// efficient for NLL. NLL is a bit more advanced in the - /// "transition to chalk" than the rest of the compiler. During - /// the NLL type check, all of the "processing" of types and - /// things happens in queries -- the NLL checker itself is only - /// interested in the region obligations (`'a: 'b` or `T: 'b`) - /// that come out of these queries, which it wants to convert into - /// MIR-based constraints and solve. Therefore, it is most - /// convenient for the NLL Type Checker to **directly consume** - /// the `QueryRegionConstraint` values that arise from doing a - /// query. This is contrast to other parts of the compiler, which - /// would prefer for those `QueryRegionConstraint` to be converted - /// into the older infcx-style constraints (e.g., calls to - /// `sub_regions` or `register_region_obligation`). - /// - /// Therefore, `instantiate_nll_query_result_and_region_obligations` performs the same - /// basic operations as `instantiate_query_result_and_region_obligations` but - /// it returns its result differently: - /// - /// - It creates a substitution `S` that maps from the original - /// query variables to the values computed in the query - /// result. If any errors arise, they are propagated back as an - /// `Err` result. - /// - In the case of a successful substitution, we will append - /// `QueryRegionConstraint` values onto the - /// `output_query_region_constraints` vector for the solver to - /// use (if an error arises, some values may also be pushed, but - /// they should be ignored). - /// - It **can happen** (though it rarely does currently) that - /// equating types and things will give rise to subobligations - /// that must be processed. In this case, those subobligations - /// are propagated back in the return value. - /// - Finally, the query result (of type `R`) is propagated back, - /// after applying the substitution `S`. - pub fn instantiate_nll_query_result_and_region_obligations( - &self, - cause: &ObligationCause<'tcx>, - param_env: ty::ParamEnv<'tcx>, - original_values: &SmallCanonicalVarValues<'tcx>, - query_result: &Canonical<'tcx, QueryResult<'tcx, R>>, - output_query_region_constraints: &mut Vec>, - ) -> InferResult<'tcx, R> - where - R: Debug + TypeFoldable<'tcx>, - { - // In an NLL query, there should be no type variables in the - // query, only region variables. - debug_assert!(query_result.variables.iter().all(|v| match v.kind { - CanonicalVarKind::Ty(_) => false, - CanonicalVarKind::Region => true, - })); - - let result_subst = - self.query_result_substitution_guess(cause, original_values, query_result); - - // Compute `QueryRegionConstraint` values that unify each of - // the original values `v_o` that was canonicalized into a - // variable... - let mut obligations = vec![]; - - for (index, original_value) in original_values.iter().enumerate() { - // ...with the value `v_r` of that variable from the query. - let result_value = query_result.substitute_projected(self.tcx, &result_subst, |v| { - &v.var_values[CanonicalVar::new(index)] - }); - match (original_value.unpack(), result_value.unpack()) { - (UnpackedKind::Lifetime(ty::ReErased), UnpackedKind::Lifetime(ty::ReErased)) => { - // no action needed - } - - (UnpackedKind::Lifetime(v_o), UnpackedKind::Lifetime(v_r)) => { - // To make `v_o = v_r`, we emit `v_o: v_r` and `v_r: v_o`. - if v_o != v_r { - output_query_region_constraints - .push(ty::Binder::dummy(ty::OutlivesPredicate(v_o.into(), v_r))); - output_query_region_constraints - .push(ty::Binder::dummy(ty::OutlivesPredicate(v_r.into(), v_o))); - } - } - - (UnpackedKind::Type(v1), UnpackedKind::Type(v2)) => { - let ok = self.at(cause, param_env).eq(v1, v2)?; - obligations.extend(ok.into_obligations()); - } - - _ => { - bug!( - "kind mismatch, cannot unify {:?} and {:?}", - original_value, - result_value - ); - } - } - } - - // ...also include the other query region constraints from the query. - output_query_region_constraints.reserve(query_result.value.region_constraints.len()); - for r_c in query_result.value.region_constraints.iter() { - let &ty::OutlivesPredicate(k1, r2) = r_c.skip_binder(); // reconstructed below - let k1 = substitute_value(self.tcx, &result_subst, &k1); - let r2 = substitute_value(self.tcx, &result_subst, &r2); - if k1 != r2.into() { - output_query_region_constraints - .push(ty::Binder::bind(ty::OutlivesPredicate(k1, r2))); - } - } - - let user_result: R = - query_result.substitute_projected(self.tcx, &result_subst, |q_r| &q_r.value); - - Ok(InferOk { - value: user_result, - obligations, - }) - } - - /// Given the original values and the (canonicalized) result from - /// computing a query, returns a substitution that can be applied - /// to the query result to convert the result back into the - /// original namespace. - /// - /// The substitution also comes accompanied with subobligations - /// that arose from unification; these might occur if (for - /// example) we are doing lazy normalization and the value - /// assigned to a type variable is unified with an unnormalized - /// projection. - fn query_result_substitution( - &self, - cause: &ObligationCause<'tcx>, - param_env: ty::ParamEnv<'tcx>, - original_values: &SmallCanonicalVarValues<'tcx>, - query_result: &Canonical<'tcx, QueryResult<'tcx, R>>, - ) -> InferResult<'tcx, CanonicalVarValues<'tcx>> - where - R: Debug + TypeFoldable<'tcx>, - { - debug!( - "query_result_substitution(original_values={:#?}, query_result={:#?})", - original_values, query_result, - ); - - let result_subst = - self.query_result_substitution_guess(cause, original_values, query_result); - - let obligations = self.unify_query_result_substitution_guess( - cause, - param_env, - original_values, - &result_subst, - query_result, - )? - .into_obligations(); - - Ok(InferOk { - value: result_subst, - obligations, - }) - } - - /// Given the original values and the (canonicalized) result from - /// computing a query, returns a **guess** at a substitution that - /// can be applied to the query result to convert the result back - /// into the original namespace. This is called a **guess** - /// because it uses a quick heuristic to find the values for each - /// canonical variable; if that quick heuristic fails, then we - /// will instantiate fresh inference variables for each canonical - /// variable instead. Therefore, the result of this method must be - /// properly unified - fn query_result_substitution_guess( - &self, - cause: &ObligationCause<'tcx>, - original_values: &SmallCanonicalVarValues<'tcx>, - query_result: &Canonical<'tcx, QueryResult<'tcx, R>>, - ) -> CanonicalVarValues<'tcx> - where - R: Debug + TypeFoldable<'tcx>, - { - debug!( - "query_result_substitution_guess(original_values={:#?}, query_result={:#?})", - original_values, query_result, - ); - - // Every canonical query result includes values for each of - // the inputs to the query. Therefore, we begin by unifying - // these values with the original inputs that were - // canonicalized. - let result_values = &query_result.value.var_values; - assert_eq!(original_values.len(), result_values.len()); - - // Quickly try to find initial values for the canonical - // variables in the result in terms of the query. We do this - // by iterating down the values that the query gave to each of - // the canonical inputs. If we find that one of those values - // is directly equal to one of the canonical variables in the - // result, then we can type the corresponding value from the - // input. See the example above. - let mut opt_values: IndexVec>> = - IndexVec::from_elem_n(None, query_result.variables.len()); - - // In terms of our example above, we are iterating over pairs like: - // [(?A, Vec), ('static, '?1), (?B, ?0)] - for (original_value, result_value) in original_values.iter().zip(result_values) { - match result_value.unpack() { - UnpackedKind::Type(result_value) => { - // e.g., here `result_value` might be `?0` in the example above... - if let ty::Infer(ty::InferTy::CanonicalTy(index)) = result_value.sty { - // in which case we would set `canonical_vars[0]` to `Some(?U)`. - opt_values[index] = Some(*original_value); - } - } - UnpackedKind::Lifetime(result_value) => { - // e.g., here `result_value` might be `'?1` in the example above... - if let &ty::RegionKind::ReCanonical(index) = result_value { - // in which case we would set `canonical_vars[0]` to `Some('static)`. - opt_values[index] = Some(*original_value); - } - } - } - } - - // Create a result substitution: if we found a value for a - // given variable in the loop above, use that. Otherwise, use - // a fresh inference variable. - let result_subst = CanonicalVarValues { - var_values: query_result - .variables - .iter() - .enumerate() - .map(|(index, info)| match opt_values[CanonicalVar::new(index)] { - Some(k) => k, - None => self.fresh_inference_var_for_canonical_var(cause.span, *info), - }) - .collect(), - }; - - result_subst - } - - /// Given a "guess" at the values for the canonical variables in - /// the input, try to unify with the *actual* values found in the - /// query result. Often, but not always, this is a no-op, because - /// we already found the mapping in the "guessing" step. - /// - /// See also: `query_result_substitution_guess` - fn unify_query_result_substitution_guess( - &self, - cause: &ObligationCause<'tcx>, - param_env: ty::ParamEnv<'tcx>, - original_values: &SmallCanonicalVarValues<'tcx>, - result_subst: &CanonicalVarValues<'tcx>, - query_result: &Canonical<'tcx, QueryResult<'tcx, R>>, - ) -> InferResult<'tcx, ()> - where - R: Debug + TypeFoldable<'tcx>, - { - // A closure that yields the result value for the given - // canonical variable; this is taken from - // `query_result.var_values` after applying the substitution - // `result_subst`. - let substituted_query_result = |index: CanonicalVar| -> Kind<'tcx> { - query_result.substitute_projected(self.tcx, &result_subst, |v| &v.var_values[index]) - }; - - // Unify the original value for each variable with the value - // taken from `query_result` (after applying `result_subst`). - Ok(self.unify_canonical_vars(cause, param_env, original_values, substituted_query_result)?) - } - - /// Converts the region constraints resulting from a query into an - /// iterator of obligations. - fn query_region_constraints_into_obligations<'a>( - &'a self, - cause: &'a ObligationCause<'tcx>, - param_env: ty::ParamEnv<'tcx>, - unsubstituted_region_constraints: &'a [QueryRegionConstraint<'tcx>], - result_subst: &'a CanonicalVarValues<'tcx>, - ) -> impl Iterator> + 'a { - Box::new( - unsubstituted_region_constraints - .iter() - .map(move |constraint| { - let ty::OutlivesPredicate(k1, r2) = constraint.skip_binder(); // restored below - let k1 = substitute_value(self.tcx, result_subst, k1); - let r2 = substitute_value(self.tcx, result_subst, r2); - match k1.unpack() { - UnpackedKind::Lifetime(r1) => Obligation::new( - cause.clone(), - param_env, - ty::Predicate::RegionOutlives(ty::Binder::dummy( - ty::OutlivesPredicate(r1, r2), - )), - ), - - UnpackedKind::Type(t1) => Obligation::new( - cause.clone(), - param_env, - ty::Predicate::TypeOutlives(ty::Binder::dummy(ty::OutlivesPredicate( - t1, r2, - ))), - ), - } - }), - ) as Box> - } - - /// Given two sets of values for the same set of canonical variables, unify them. - /// The second set is produced lazilly by supplying indices from the first set. - fn unify_canonical_vars( - &self, - cause: &ObligationCause<'tcx>, - param_env: ty::ParamEnv<'tcx>, - variables1: &SmallCanonicalVarValues<'tcx>, - variables2: impl Fn(CanonicalVar) -> Kind<'tcx>, - ) -> InferResult<'tcx, ()> { - self.commit_if_ok(|_| { - let mut obligations = vec![]; - for (index, value1) in variables1.iter().enumerate() { - let value2 = variables2(CanonicalVar::new(index)); - - match (value1.unpack(), value2.unpack()) { - (UnpackedKind::Type(v1), UnpackedKind::Type(v2)) => { - obligations - .extend(self.at(cause, param_env).eq(v1, v2)?.into_obligations()); - } - ( - UnpackedKind::Lifetime(ty::ReErased), - UnpackedKind::Lifetime(ty::ReErased), - ) => { - // no action needed - } - (UnpackedKind::Lifetime(v1), UnpackedKind::Lifetime(v2)) => { - obligations - .extend(self.at(cause, param_env).eq(v1, v2)?.into_obligations()); - } - _ => { - bug!("kind mismatch, cannot unify {:?} and {:?}", value1, value2,); - } - } - } - Ok(InferOk { - value: (), - obligations, - }) - }) - } -} - -/// Given the region obligations and constraints scraped from the infcx, -/// creates query region constraints. -pub fn make_query_outlives<'tcx>( - tcx: TyCtxt<'_, '_, 'tcx>, - outlives_obligations: impl Iterator, ty::Region<'tcx>)>, - region_constraints: &RegionConstraintData<'tcx>, -) -> Vec> { - let RegionConstraintData { - constraints, - verifys, - givens, - } = region_constraints; - - assert!(verifys.is_empty()); - assert!(givens.is_empty()); - - let mut outlives: Vec<_> = constraints - .into_iter() - .map(|(k, _)| match *k { - // Swap regions because we are going from sub (<=) to outlives - // (>=). - Constraint::VarSubVar(v1, v2) => ty::OutlivesPredicate( - tcx.mk_region(ty::ReVar(v2)).into(), - tcx.mk_region(ty::ReVar(v1)), - ), - Constraint::VarSubReg(v1, r2) => { - ty::OutlivesPredicate(r2.into(), tcx.mk_region(ty::ReVar(v1))) - } - Constraint::RegSubVar(r1, v2) => { - ty::OutlivesPredicate(tcx.mk_region(ty::ReVar(v2)).into(), r1) - } - Constraint::RegSubReg(r1, r2) => ty::OutlivesPredicate(r2.into(), r1), - }) - .map(ty::Binder::dummy) // no bound regions in the code above - .collect(); - - outlives.extend( - outlives_obligations - .map(|(ty, r)| ty::OutlivesPredicate(ty.into(), r)) - .map(ty::Binder::dummy), // no bound regions in the code above - ); - - outlives -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/canonical/substitute.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/canonical/substitute.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/canonical/substitute.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/canonical/substitute.rs 2018-12-04 23:41:40.000000000 +0000 @@ -85,10 +85,11 @@ fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { match t.sty { - ty::Infer(ty::InferTy::CanonicalTy(c)) => { - match self.var_values.var_values[c].unpack() { + ty::Infer(ty::InferTy::BoundTy(b)) => { + debug_assert_eq!(ty::INNERMOST, b.level); + match self.var_values.var_values[b.var].unpack() { UnpackedKind::Type(ty) => ty, - r => bug!("{:?} is a type but value is {:?}", c, r), + r => bug!("{:?} is a type but value is {:?}", b, r), } } _ => { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/combine.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/combine.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/combine.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/combine.rs 2018-12-04 23:41:40.000000000 +0000 @@ -251,6 +251,7 @@ dir: RelationDir) -> RelateResult<'tcx, Generalization<'tcx>> { + debug!("generalize(ty={:?}, for_vid={:?}, dir={:?}", ty, for_vid, dir); // Determine the ambient variance within which `ty` appears. // The surrounding equation is: // @@ -273,8 +274,15 @@ root_ty: ty, }; - let ty = generalize.relate(&ty, &ty)?; + let ty = match generalize.relate(&ty, &ty) { + Ok(ty) => ty, + Err(e) => { + debug!("generalize: failure {:?}", e); + return Err(e); + } + }; let needs_wf = generalize.needs_wf; + debug!("generalize: success {{ {:?}, {:?} }}", ty, needs_wf); Ok(Generalization { ty, needs_wf }) } } @@ -458,9 +466,10 @@ return Ok(r); } - // Always make a fresh region variable for skolemized regions; - // the higher-ranked decision procedures rely on this. - ty::ReSkolemized(..) => { } + // Always make a fresh region variable for placeholder + // regions; the higher-ranked decision procedures rely on + // this. + ty::RePlaceholder(..) => { } // For anything else, we make a region variable, unless we // are *equating*, in which case it's just wasteful. diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/equate.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/equate.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/equate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/equate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -74,27 +74,28 @@ let infcx = self.fields.infcx; let a = infcx.type_variables.borrow_mut().replace_if_possible(a); let b = infcx.type_variables.borrow_mut().replace_if_possible(b); + + debug!("{}.tys: replacements ({:?}, {:?})", self.tag(), a, b); + match (&a.sty, &b.sty) { (&ty::Infer(TyVar(a_id)), &ty::Infer(TyVar(b_id))) => { infcx.type_variables.borrow_mut().equate(a_id, b_id); - Ok(a) } (&ty::Infer(TyVar(a_id)), _) => { self.fields.instantiate(b, RelationDir::EqTo, a_id, self.a_is_expected)?; - Ok(a) } (_, &ty::Infer(TyVar(b_id))) => { self.fields.instantiate(a, RelationDir::EqTo, b_id, self.a_is_expected)?; - Ok(a) } _ => { self.fields.infcx.super_combine_tys(self, a, b)?; - Ok(a) } } + + Ok(a) } fn regions(&mut self, a: ty::Region<'tcx>, b: ty::Region<'tcx>) diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/error_reporting/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/error_reporting/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/error_reporting/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/error_reporting/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -55,23 +55,22 @@ //! ported to this system, and which relies on string concatenation at the //! time of error detection. -use infer; -use super::{InferCtxt, RegionVariableOrigin, SubregionOrigin, TypeTrace, ValuePairs}; -use super::region_constraints::GenericKind; use super::lexical_region_resolve::RegionResolutionError; +use super::region_constraints::GenericKind; +use super::{InferCtxt, RegionVariableOrigin, SubregionOrigin, TypeTrace, ValuePairs}; +use infer::{self, SuppressRegionErrors}; -use std::{cmp, fmt}; +use errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString}; use hir; -use hir::Node; use hir::def_id::DefId; +use hir::Node; use middle::region; -use traits::{ObligationCause, ObligationCauseCode}; -use ty::{self, subst::Subst, Region, Ty, TyCtxt, TypeFoldable, TyKind}; -use ty::error::TypeError; -use session::config::BorrowckMode; +use std::{cmp, fmt}; use syntax::ast::DUMMY_NODE_ID; use syntax_pos::{Pos, Span}; -use errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString}; +use traits::{ObligationCause, ObligationCauseCode}; +use ty::error::TypeError; +use ty::{self, subst::Subst, Region, Ty, TyCtxt, TyKind, TypeFoldable}; mod note; @@ -83,7 +82,7 @@ pub fn note_and_explain_region( self, region_scope_tree: ®ion::ScopeTree, - err: &mut DiagnosticBuilder, + err: &mut DiagnosticBuilder<'_>, prefix: &str, region: ty::Region<'tcx>, suffix: &str, @@ -143,18 +142,17 @@ ty::ReEmpty => ("the empty lifetime".to_owned(), None), - // FIXME(#13998) ReSkolemized should probably print like + // FIXME(#13998) RePlaceholder should probably print like // ReFree rather than dumping Debug output on the user. // // We shouldn't really be having unification failures with ReVar // and ReLateBound though. - ty::ReSkolemized(..) | ty::ReVar(_) | ty::ReLateBound(..) | ty::ReErased => { + ty::RePlaceholder(..) | ty::ReVar(_) | ty::ReLateBound(..) | ty::ReErased => { (format!("lifetime {:?}", region), None) } // We shouldn't encounter an error message with ReClosureBound. - ty::ReCanonical(..) | - ty::ReClosureBound(..) => { + ty::ReCanonical(..) | ty::ReClosureBound(..) => { bug!("encountered unexpected ReClosureBound: {:?}", region,); } }; @@ -164,7 +162,7 @@ pub fn note_and_explain_free_region( self, - err: &mut DiagnosticBuilder, + err: &mut DiagnosticBuilder<'_>, prefix: &str, region: ty::Region<'tcx>, suffix: &str, @@ -176,9 +174,9 @@ fn msg_span_from_free_region(self, region: ty::Region<'tcx>) -> (String, Option) { match *region { - ty::ReEarlyBound(_) | ty::ReFree(_) => { + ty::ReEarlyBound(_) | ty::ReFree(_) => { self.msg_span_from_early_bound_and_free_regions(region) - }, + } ty::ReStatic => ("the static lifetime".to_owned(), None), _ => bug!("{:?}", region), } @@ -197,25 +195,28 @@ Some(Node::Item(it)) => Self::item_scope_tag(&it), Some(Node::TraitItem(it)) => Self::trait_item_scope_tag(&it), Some(Node::ImplItem(it)) => Self::impl_item_scope_tag(&it), - _ => unreachable!() + _ => unreachable!(), }; let (prefix, span) = match *region { ty::ReEarlyBound(ref br) => { let mut sp = cm.def_span(self.hir.span(node)); - if let Some(param) = self.hir.get_generics(scope).and_then(|generics| { - generics.get_named(&br.name) - }) { + if let Some(param) = self.hir + .get_generics(scope) + .and_then(|generics| generics.get_named(&br.name)) + { sp = param.span; } (format!("the lifetime {} as defined on", br.name), sp) } ty::ReFree(ty::FreeRegion { - bound_region: ty::BoundRegion::BrNamed(_, ref name), .. + bound_region: ty::BoundRegion::BrNamed(_, ref name), + .. }) => { let mut sp = cm.def_span(self.hir.span(node)); - if let Some(param) = self.hir.get_generics(scope).and_then(|generics| { - generics.get_named(&name) - }) { + if let Some(param) = self.hir + .get_generics(scope) + .and_then(|generics| generics.get_named(&name)) + { sp = param.span; } (format!("the lifetime {} as defined on", name), sp) @@ -241,7 +242,7 @@ } fn emit_msg_span( - err: &mut DiagnosticBuilder, + err: &mut DiagnosticBuilder<'_>, prefix: &str, description: String, span: Option, @@ -278,9 +279,9 @@ fn impl_item_scope_tag(item: &hir::ImplItem) -> &'static str { match item.node { hir::ImplItemKind::Method(..) => "method body", - hir::ImplItemKind::Const(..) | - hir::ImplItemKind::Existential(..) | - hir::ImplItemKind::Type(..) => "associated item", + hir::ImplItemKind::Const(..) + | hir::ImplItemKind::Existential(..) + | hir::ImplItemKind::Type(..) => "associated item", } } @@ -298,20 +299,16 @@ &self, region_scope_tree: ®ion::ScopeTree, errors: &Vec>, - will_later_be_reported_by_nll: bool, + suppress: SuppressRegionErrors, ) { - debug!("report_region_errors(): {} errors to start", errors.len()); + debug!( + "report_region_errors(): {} errors to start, suppress = {:?}", + errors.len(), + suppress + ); - // If the errors will later be reported by NLL, choose wether to display them or not based - // on the borrowck mode - if will_later_be_reported_by_nll { - match self.tcx.borrowck_mode() { - // If we're on AST or Migrate mode, report AST region errors - BorrowckMode::Ast | BorrowckMode::Migrate => {}, - // If we're on MIR or Compare mode, don't report AST region errors as they should - // be reported by NLL - BorrowckMode::Compare | BorrowckMode::Mir => return, - } + if suppress.suppressed() { + return; } // try to pre-process the errors, which will group some of them @@ -409,10 +406,10 @@ errors.clone() } else { errors - .iter() - .filter(|&e| !is_bound_failure(e)) - .cloned() - .collect() + .iter() + .filter(|&e| !is_bound_failure(e)) + .cloned() + .collect() }; // sort the errors by span, for better error message stability. @@ -427,11 +424,11 @@ /// Adds a note if the types come from similarly named crates fn check_and_note_conflicting_crates( &self, - err: &mut DiagnosticBuilder, + err: &mut DiagnosticBuilder<'_>, terr: &TypeError<'tcx>, sp: Span, ) { - let report_path_match = |err: &mut DiagnosticBuilder, did1: DefId, did2: DefId| { + let report_path_match = |err: &mut DiagnosticBuilder<'_>, did1: DefId, did2: DefId| { // Only external crates, if either is from a local // module we could have false positives if !(did1.is_local() || did2.is_local()) && did1.krate != did2.krate { @@ -458,11 +455,10 @@ TypeError::Sorts(ref exp_found) => { // if they are both "path types", there's a chance of ambiguity // due to different versions of the same crate - match (&exp_found.expected.sty, &exp_found.found.sty) { - (&ty::Adt(exp_adt, _), &ty::Adt(found_adt, _)) => { - report_path_match(err, exp_adt.did, found_adt.did); - } - _ => (), + if let (&ty::Adt(exp_adt, _), &ty::Adt(found_adt, _)) + = (&exp_found.expected.sty, &exp_found.found.sty) + { + report_path_match(err, exp_adt.did, found_adt.did); } } TypeError::Traits(ref exp_found) => { @@ -482,17 +478,8 @@ } else { err.span_label(arm_span, msg); } - }, - hir::MatchSource::TryDesugar => { // Issue #51632 - if let Ok(try_snippet) = self.tcx.sess.source_map().span_to_snippet(arm_span) { - err.span_suggestion_with_applicability( - arm_span, - "try wrapping with a success variant", - format!("Ok({})", try_snippet), - Applicability::MachineApplicable - ); - } - }, + } + hir::MatchSource::TryDesugar => {} _ => { let msg = "match arm with an incompatible type"; if self.tcx.sess.source_map().is_multiline(arm_span) { @@ -641,16 +628,21 @@ fn strip_generic_default_params( &self, def_id: DefId, - substs: &ty::subst::Substs<'tcx> + substs: &ty::subst::Substs<'tcx>, ) -> &'tcx ty::subst::Substs<'tcx> { let generics = self.tcx.generics_of(def_id); let mut num_supplied_defaults = 0; - let mut type_params = generics.params.iter().rev().filter_map(|param| match param.kind { - ty::GenericParamDefKind::Lifetime => None, - ty::GenericParamDefKind::Type { has_default, .. } => { - Some((param.def_id, has_default)) - } - }).peekable(); + let mut type_params = generics + .params + .iter() + .rev() + .filter_map(|param| match param.kind { + ty::GenericParamDefKind::Lifetime => None, + ty::GenericParamDefKind::Type { has_default, .. } => { + Some((param.def_id, has_default)) + } + }) + .peekable(); let has_default = { let has_default = type_params.peek().map(|(_, has_default)| has_default); *has_default.unwrap_or(&false) @@ -684,10 +676,9 @@ | (&ty::Infer(ty::InferTy::IntVar(_)), &ty::Infer(ty::InferTy::IntVar(_))) | (&ty::Float(_), &ty::Infer(ty::InferTy::FloatVar(_))) | (&ty::Infer(ty::InferTy::FloatVar(_)), &ty::Float(_)) - | ( - &ty::Infer(ty::InferTy::FloatVar(_)), - &ty::Infer(ty::InferTy::FloatVar(_)), - ) => true, + | (&ty::Infer(ty::InferTy::FloatVar(_)), &ty::Infer(ty::InferTy::FloatVar(_))) => { + true + } _ => false, } } @@ -703,11 +694,7 @@ "&{}{}{}", r, if r == "" { "" } else { " " }, - if mutbl == hir::MutMutable { - "mut " - } else { - "" - } + if mutbl == hir::MutMutable { "mut " } else { "" } )); s.push_normal(ty.to_string()); } @@ -738,9 +725,12 @@ let common_len = cmp::min(len1, len2); let remainder1: Vec<_> = sub1.types().skip(common_len).collect(); let remainder2: Vec<_> = sub2.types().skip(common_len).collect(); - let common_default_params = - remainder1.iter().rev().zip(remainder2.iter().rev()) - .filter(|(a, b)| a == b).count(); + let common_default_params = remainder1 + .iter() + .rev() + .zip(remainder2.iter().rev()) + .filter(|(a, b)| a == b) + .count(); let len = sub1.len() - common_default_params; // Only draw `<...>` if there're lifetime/type arguments. @@ -749,7 +739,7 @@ values.1.push_normal("<"); } - fn lifetime_display(lifetime: Region) -> String { + fn lifetime_display(lifetime: Region<'_>) -> String { let s = lifetime.to_string(); if s.is_empty() { "'_".to_string() @@ -866,8 +856,9 @@ } // When encountering &T != &mut T, highlight only the borrow - (&ty::Ref(r1, ref_ty1, mutbl1), - &ty::Ref(r2, ref_ty2, mutbl2)) if equals(&ref_ty1, &ref_ty2) => { + (&ty::Ref(r1, ref_ty1, mutbl1), &ty::Ref(r2, ref_ty2, mutbl2)) + if equals(&ref_ty1, &ref_ty2) => + { let mut values = (DiagnosticStyledString::new(), DiagnosticStyledString::new()); push_ty_ref(&r1, ref_ty1, mutbl1, &mut values.0); push_ty_ref(&r2, ref_ty2, mutbl2, &mut values.1); @@ -1068,11 +1059,7 @@ bound_kind: GenericKind<'tcx>, sub: Region<'tcx>, ) { - self.construct_generic_bound_failure(region_scope_tree, - span, - origin, - bound_kind, - sub) + self.construct_generic_bound_failure(region_scope_tree, span, origin, bound_kind, sub) .emit() } @@ -1083,8 +1070,7 @@ origin: Option>, bound_kind: GenericKind<'tcx>, sub: Region<'tcx>, - ) -> DiagnosticBuilder<'a> - { + ) -> DiagnosticBuilder<'a> { // Attempt to obtain the span of the parameter so we can // suggest adding an explicit lifetime bound to it. let type_param_span = match (self.in_progress_tables, bound_kind) { @@ -1161,8 +1147,10 @@ let tail = if has_lifetimes { " + " } else { "" }; let suggestion = format!("{}: {}{}", bound_kind, sub, tail); err.span_suggestion_short_with_applicability( - sp, consider, suggestion, - Applicability::MaybeIncorrect // Issue #41966 + sp, + consider, + suggestion, + Applicability::MaybeIncorrect, // Issue #41966 ); } else { err.help(consider); @@ -1358,12 +1346,10 @@ match self.code { CompareImplMethodObligation { .. } => Error0308("method not compatible with trait"), MatchExpressionArm { source, .. } => Error0308(match source { - hir::MatchSource::IfLetDesugar { .. } => { - "`if let` arms have incompatible types" - }, + hir::MatchSource::IfLetDesugar { .. } => "`if let` arms have incompatible types", hir::MatchSource::TryDesugar => { "try expression alternatives have incompatible types" - }, + } _ => "match arms have incompatible types", }), IfExpression => Error0308("if and else have incompatible types"), diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/error_reporting/need_type_info.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/error_reporting/need_type_info.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/error_reporting/need_type_info.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/error_reporting/need_type_info.rs 2018-12-04 23:41:40.000000000 +0000 @@ -100,7 +100,7 @@ let mut labels = vec![( span, if &name == "_" { - "cannot infer type".to_string() + "cannot infer type".to_owned() } else { format!("cannot infer type for `{}`", name) }, @@ -138,7 +138,7 @@ // ``` labels.clear(); labels.push( - (pattern.span, "consider giving this closure parameter a type".to_string())); + (pattern.span, "consider giving this closure parameter a type".to_owned())); } else if let Some(pattern) = local_visitor.found_local_pattern { if let Some(simple_ident) = pattern.simple_ident() { match pattern.span.compiler_desugaring_kind() { @@ -146,12 +146,12 @@ format!("consider giving `{}` a type", simple_ident))), Some(CompilerDesugaringKind::ForLoop) => labels.push(( pattern.span, - "the element type for this iterator is not specified".to_string(), + "the element type for this iterator is not specified".to_owned(), )), _ => {} } } else { - labels.push((pattern.span, "consider giving the pattern a type".to_string())); + labels.push((pattern.span, "consider giving the pattern a type".to_owned())); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -56,9 +56,9 @@ let (span, sub, sup) = self.get_regions(); // Determine whether the sub and sup consist of both anonymous (elided) regions. - let anon_reg_sup = self.is_suitable_region(sup)?; + let anon_reg_sup = self.tcx.is_suitable_region(sup)?; - let anon_reg_sub = self.is_suitable_region(sub)?; + let anon_reg_sub = self.tcx.is_suitable_region(sub)?; let scope_def_id_sup = anon_reg_sup.def_id; let bregion_sup = anon_reg_sup.boundregion; let scope_def_id_sub = anon_reg_sub.def_id; @@ -113,12 +113,12 @@ (None, None) => { let (main_label_1, span_label_1) = if ty_sup.id == ty_sub.id { ( - "this type is declared with multiple lifetimes...".to_string(), - "...but data with one lifetime flows into the other here".to_string() + "this type is declared with multiple lifetimes...".to_owned(), + "...but data with one lifetime flows into the other here".to_owned() ) } else { ( - "these two types are declared with different lifetimes...".to_string(), + "these two types are declared with different lifetimes...".to_owned(), format!( "...but data{} flows{} here", span_label_var1, @@ -133,7 +133,7 @@ ty_sub.span, ret_span, "this parameter and the return type are declared \ - with different lifetimes...".to_string() + with different lifetimes...".to_owned() , format!("...but data{} is returned here", span_label_var1), ), @@ -141,7 +141,7 @@ ty_sup.span, ret_span, "this parameter and the return type are declared \ - with different lifetimes...".to_string() + with different lifetimes...".to_owned() , format!("...but data{} is returned here", span_label_var1), ), diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -36,7 +36,7 @@ region: Region<'tcx>, br: &ty::BoundRegion, ) -> Option<(&hir::Ty, &hir::FnDecl)> { - if let Some(anon_reg) = self.is_suitable_region(region) { + if let Some(anon_reg) = self.tcx.is_suitable_region(region) { let def_id = anon_reg.def_id; if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { let fndecl = match self.tcx.hir.get(node_id) { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,6 +13,7 @@ use infer::error_reporting::nice_region_error::NiceRegionError; use ty; use util::common::ErrorReported; +use errors::Applicability; impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { /// When given a `ConcreteFailure` for a function with arguments containing a named region and @@ -33,23 +34,23 @@ // version new_ty of its type where the anonymous region is replaced // with the named one.//scope_def_id let (named, anon, anon_arg_info, region_info) = if self.is_named_region(sub) - && self.is_suitable_region(sup).is_some() + && self.tcx.is_suitable_region(sup).is_some() && self.find_arg_with_region(sup, sub).is_some() { ( sub, sup, self.find_arg_with_region(sup, sub).unwrap(), - self.is_suitable_region(sup).unwrap(), + self.tcx.is_suitable_region(sup).unwrap(), ) - } else if self.is_named_region(sup) && self.is_suitable_region(sub).is_some() + } else if self.is_named_region(sup) && self.tcx.is_suitable_region(sub).is_some() && self.find_arg_with_region(sub, sup).is_some() { ( sup, sub, self.find_arg_with_region(sub, sup).unwrap(), - self.is_suitable_region(sub).unwrap(), + self.tcx.is_suitable_region(sub).unwrap(), ) } else { return None; // inapplicable @@ -111,13 +112,14 @@ E0621, "explicit lifetime required in {}", error_var - ).span_suggestion( + ).span_suggestion_with_applicability( new_ty_span, &format!("add explicit lifetime `{}` to {}", named, span_label_var), - new_ty.to_string() + new_ty.to_string(), + Applicability::Unspecified, ) - .span_label(span, format!("lifetime `{}` required", named)) - .emit(); + .span_label(span, format!("lifetime `{}` required", named)) + .emit(); return Some(ErrorReported); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs 2018-12-04 23:41:40.000000000 +0000 @@ -58,18 +58,17 @@ &RegionKind::ReFree(ref free_region)) = (&sub_origin, sup_region) { let hir = &self.tcx.hir; if let Some(node_id) = hir.as_local_node_id(free_region.scope) { - match hir.get(node_id) { - Node::Expr(Expr { - node: Closure(_, _, _, closure_span, None), - .. - }) => { - let sup_sp = sup_origin.span(); - let origin_sp = origin.span(); - let mut err = self.tcx.sess.struct_span_err( - sup_sp, - "borrowed data cannot be stored outside of its closure"); - err.span_label(sup_sp, "cannot be stored outside of its closure"); - if origin_sp == sup_sp || origin_sp.contains(sup_sp) { + if let Node::Expr(Expr { + node: Closure(_, _, _, closure_span, None), + .. + }) = hir.get(node_id) { + let sup_sp = sup_origin.span(); + let origin_sp = origin.span(); + let mut err = self.tcx.sess.struct_span_err( + sup_sp, + "borrowed data cannot be stored outside of its closure"); + err.span_label(sup_sp, "cannot be stored outside of its closure"); + if origin_sp == sup_sp || origin_sp.contains(sup_sp) { // // sup_sp == origin.span(): // // let mut x = None; @@ -87,11 +86,11 @@ // ------------ ... because it cannot outlive this closure // f = Some(x); // ^ cannot be stored outside of its closure - err.span_label(*external_span, - "borrowed data cannot be stored into here..."); - err.span_label(*closure_span, - "...because it cannot outlive this closure"); - } else { + err.span_label(*external_span, + "borrowed data cannot be stored into here..."); + err.span_label(*closure_span, + "...because it cannot outlive this closure"); + } else { // FIXME: the wording for this case could be much improved // // let mut lines_to_use: Vec<&CrateId> = Vec::new(); @@ -102,18 +101,16 @@ // ...so that variable is valid at time of its declaration // lines_to_use.push(installed_id); // ^^^^^^^^^^^^ cannot be stored outside of its closure - err.span_label(origin_sp, - "cannot infer an appropriate lifetime..."); - err.span_label(*external_span, - "...so that variable is valid at time of its \ - declaration"); - err.span_label(*closure_span, - "borrowed data cannot outlive this closure"); - } - err.emit(); - return Some(ErrorReported); + err.span_label(origin_sp, + "cannot infer an appropriate lifetime..."); + err.span_label(*external_span, + "...so that variable is valid at time of its \ + declaration"); + err.span_label(*closure_span, + "borrowed data cannot outlive this closure"); } - _ => {} + err.emit(); + return Some(ErrorReported); } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/static_impl_trait.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/static_impl_trait.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/static_impl_trait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/static_impl_trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,68 +14,68 @@ use infer::lexical_region_resolve::RegionResolutionError; use ty::{BoundRegion, FreeRegion, RegionKind}; use util::common::ErrorReported; +use errors::Applicability; impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { /// Print the error message for lifetime errors when the return type is a static impl Trait. pub(super) fn try_report_static_impl_trait(&self) -> Option { if let Some(ref error) = self.error { - match error.clone() { - RegionResolutionError::SubSupConflict( + if let RegionResolutionError::SubSupConflict( var_origin, sub_origin, sub_r, sup_origin, sup_r, - ) => { - let anon_reg_sup = self.is_suitable_region(sup_r)?; - if sub_r == &RegionKind::ReStatic && - self.is_return_type_impl_trait(anon_reg_sup.def_id) - { - let sp = var_origin.span(); - let return_sp = sub_origin.span(); - let mut err = self.tcx.sess.struct_span_err( - sp, - "cannot infer an appropriate lifetime", + ) = error.clone() + { + let anon_reg_sup = self.tcx.is_suitable_region(sup_r)?; + if sub_r == &RegionKind::ReStatic && + self.tcx.return_type_impl_trait(anon_reg_sup.def_id).is_some() + { + let sp = var_origin.span(); + let return_sp = sub_origin.span(); + let mut err = self.tcx.sess.struct_span_err( + sp, + "cannot infer an appropriate lifetime", + ); + err.span_label( + return_sp, + "this return type evaluates to the `'static` lifetime...", + ); + err.span_label( + sup_origin.span(), + "...but this borrow...", + ); + + let (lifetime, lt_sp_opt) = self.tcx.msg_span_from_free_region(sup_r); + if let Some(lifetime_sp) = lt_sp_opt { + err.span_note( + lifetime_sp, + &format!("...can't outlive {}", lifetime), ); - err.span_label( + } + + let lifetime_name = match sup_r { + RegionKind::ReFree(FreeRegion { + bound_region: BoundRegion::BrNamed(_, ref name), .. + }) => name.to_string(), + _ => "'_".to_owned(), + }; + if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(return_sp) { + err.span_suggestion_with_applicability( return_sp, - "this return type evaluates to the `'static` lifetime...", + &format!( + "you can add a constraint to the return type to make it last \ + less than `'static` and match {}", + lifetime, + ), + format!("{} + {}", snippet, lifetime_name), + Applicability::Unspecified, ); - err.span_label( - sup_origin.span(), - "...but this borrow...", - ); - - let (lifetime, lt_sp_opt) = self.tcx.msg_span_from_free_region(sup_r); - if let Some(lifetime_sp) = lt_sp_opt { - err.span_note( - lifetime_sp, - &format!("...can't outlive {}", lifetime), - ); - } - - let lifetime_name = match sup_r { - RegionKind::ReFree(FreeRegion { - bound_region: BoundRegion::BrNamed(_, ref name), .. - }) => name.to_string(), - _ => "'_".to_owned(), - }; - if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(return_sp) { - err.span_suggestion( - return_sp, - &format!( - "you can add a constraint to the return type to make it last \ - less than `'static` and match {}", - lifetime, - ), - format!("{} + {}", snippet, lifetime_name), - ); - } - err.emit(); - return Some(ErrorReported); } + err.emit(); + return Some(ErrorReported); } - _ => {} } } None diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/util.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/util.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/util.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/error_reporting/nice_region_error/util.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,7 +15,6 @@ use infer::error_reporting::nice_region_error::NiceRegionError; use ty::{self, Region, Ty}; use hir::def_id::DefId; -use hir::Node; use syntax_pos::Span; // The struct contains the information about the anonymous region @@ -35,18 +34,6 @@ pub is_first: bool, } -// This struct contains information regarding the -// Refree((FreeRegion) corresponding to lifetime conflict -#[derive(Debug)] -pub(super) struct FreeRegionInfo { - // def id corresponding to FreeRegion - pub def_id: DefId, - // the bound region corresponding to FreeRegion - pub boundregion: ty::BoundRegion, - // checks if bound region is in Impl Item - pub is_impl_item: bool, -} - impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { // This method walks the Type of the function body arguments using // `fold_regions()` function and returns the @@ -63,7 +50,7 @@ &self, anon_region: Region<'tcx>, replace_region: Region<'tcx>, - ) -> Option { + ) -> Option> { let (id, bound_region) = match *anon_region { ty::ReFree(ref free_region) => (free_region.scope, free_region.bound_region), ty::ReEarlyBound(ref ebr) => ( @@ -122,36 +109,6 @@ } } - // This method returns the DefId and the BoundRegion corresponding to the given region. - pub(super) fn is_suitable_region(&self, region: Region<'tcx>) -> Option { - let (suitable_region_binding_scope, bound_region) = match *region { - ty::ReFree(ref free_region) => (free_region.scope, free_region.bound_region), - ty::ReEarlyBound(ref ebr) => ( - self.tcx.parent_def_id(ebr.def_id).unwrap(), - ty::BoundRegion::BrNamed(ebr.def_id, ebr.name), - ), - _ => return None, // not a free region - }; - - let node_id = self.tcx - .hir - .as_local_node_id(suitable_region_binding_scope) - .unwrap(); - let is_impl_item = match self.tcx.hir.find(node_id) { - Some(Node::Item(..)) | Some(Node::TraitItem(..)) => false, - Some(Node::ImplItem(..)) => { - self.is_bound_region_in_impl_item(suitable_region_binding_scope) - } - _ => return None, - }; - - return Some(FreeRegionInfo { - def_id: suitable_region_binding_scope, - boundregion: bound_region, - is_impl_item: is_impl_item, - }); - } - // Here, we check for the case where the anonymous region // is in the return type. // FIXME(#42703) - Need to handle certain cases here. @@ -162,36 +119,17 @@ decl: &hir::FnDecl, ) -> Option { let ret_ty = self.tcx.type_of(scope_def_id); - match ret_ty.sty { - ty::FnDef(_, _) => { - let sig = ret_ty.fn_sig(self.tcx); - let late_bound_regions = self.tcx - .collect_referenced_late_bound_regions(&sig.output()); - if late_bound_regions.iter().any(|r| *r == br) { - return Some(decl.output.span()); - } + if let ty::FnDef(_, _) = ret_ty.sty { + let sig = ret_ty.fn_sig(self.tcx); + let late_bound_regions = self.tcx + .collect_referenced_late_bound_regions(&sig.output()); + if late_bound_regions.iter().any(|r| *r == br) { + return Some(decl.output.span()); } - _ => {} } None } - pub(super) fn is_return_type_impl_trait( - &self, - scope_def_id: DefId, - ) -> bool { - let ret_ty = self.tcx.type_of(scope_def_id); - match ret_ty.sty { - ty::FnDef(_, _) => { - let sig = ret_ty.fn_sig(self.tcx); - let output = self.tcx.erase_late_bound_regions(&sig.output()); - return output.is_impl_trait(); - } - _ => {} - } - false - } - // Here we check for the case where anonymous region // corresponds to self and if yes, we display E0312. // FIXME(#42700) - Need to format self properly to @@ -199,28 +137,8 @@ pub(super) fn is_self_anon(&self, is_first: bool, scope_def_id: DefId) -> bool { is_first && self.tcx - .opt_associated_item(scope_def_id) - .map(|i| i.method_has_self_argument) == Some(true) + .opt_associated_item(scope_def_id) + .map(|i| i.method_has_self_argument) == Some(true) } - // Here we check if the bound region is in Impl Item. - pub(super) fn is_bound_region_in_impl_item( - &self, - suitable_region_binding_scope: DefId, - ) -> bool { - let container_id = self.tcx - .associated_item(suitable_region_binding_scope) - .container - .id(); - if self.tcx.impl_trait_ref(container_id).is_some() { - // For now, we do not try to target impls of traits. This is - // because this message is going to suggest that the user - // change the fn signature, but they may not be free to do so, - // since the signature must match the trait. - // - // FIXME(#42706) -- in some cases, we could do better here. - return true; - } - false - } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/error_reporting/note.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/error_reporting/note.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/error_reporting/note.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/error_reporting/note.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,7 +16,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { pub(super) fn note_region_origin(&self, - err: &mut DiagnosticBuilder, + err: &mut DiagnosticBuilder<'_>, origin: &SubregionOrigin<'tcx>) { match *origin { infer::Subtype(ref trace) => { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/freshen.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/freshen.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/freshen.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/freshen.rs 2018-12-04 23:41:40.000000000 +0000 @@ -62,7 +62,7 @@ TypeFreshener { infcx, freshen_count: 0, - freshen_map: FxHashMap(), + freshen_map: Default::default(), } } @@ -107,7 +107,7 @@ ty::ReFree(_) | ty::ReScope(_) | ty::ReVar(_) | - ty::ReSkolemized(..) | + ty::RePlaceholder(..) | ty::ReEmpty | ty::ReErased => { // replace all free regions with 'erased @@ -171,7 +171,7 @@ t } - ty::Infer(ty::CanonicalTy(..)) => + ty::Infer(ty::BoundTy(..)) => bug!("encountered canonical ty during freshening"), ty::Generator(..) | @@ -193,6 +193,7 @@ ty::Never | ty::Tuple(..) | ty::Projection(..) | + ty::UnnormalizedProjection(..) | ty::Foreign(..) | ty::Param(..) | ty::Closure(..) | diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/higher_ranked/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/higher_ranked/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/higher_ranked/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/higher_ranked/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,7 +15,7 @@ InferCtxt, HigherRankedType, SubregionOrigin, - SkolemizationMap}; + PlaceholderMap}; use super::combine::CombineFields; use super::region_constraints::{TaintDirections}; @@ -51,19 +51,21 @@ return self.infcx.commit_if_ok(|snapshot| { let span = self.trace.cause.span; - // First, we instantiate each bound region in the subtype with a fresh - // region variable. + // First, we instantiate each bound region in the supertype with a + // fresh placeholder region. + let (b_prime, placeholder_map) = + self.infcx.replace_late_bound_regions_with_placeholders(b); + + // Next, we instantiate each bound region in the subtype + // with a fresh region variable. These region variables -- + // but no other pre-existing region variables -- can name + // the placeholders. let (a_prime, _) = self.infcx.replace_late_bound_regions_with_fresh_var( span, HigherRankedType, a); - // Second, we instantiate each bound region in the supertype with a - // fresh concrete region. - let (b_prime, skol_map) = - self.infcx.skolemize_late_bound_regions(b); - debug!("a_prime={:?}", a_prime); debug!("b_prime={:?}", b_prime); @@ -71,12 +73,12 @@ let result = self.sub(a_is_expected).relate(&a_prime, &b_prime)?; // Presuming type comparison succeeds, we need to check - // that the skolemized regions do not "leak". - self.infcx.leak_check(!a_is_expected, span, &skol_map, snapshot)?; + // that the placeholder regions do not "leak". + self.infcx.leak_check(!a_is_expected, span, &placeholder_map, snapshot)?; - // We are finished with the skolemized regions now so pop + // We are finished with the placeholder regions now so pop // them off. - self.infcx.pop_skolemized(skol_map, snapshot); + self.infcx.pop_placeholders(placeholder_map, snapshot); debug!("higher_ranked_sub: OK result={:?}", result); @@ -112,68 +114,68 @@ // created as part of this type comparison". return self.infcx.commit_if_ok(|snapshot| { // First, we instantiate each bound region in the matcher - // with a skolemized region. - let ((a_match, a_value), skol_map) = - self.infcx.skolemize_late_bound_regions(a_pair); + // with a placeholder region. + let ((a_match, a_value), placeholder_map) = + self.infcx.replace_late_bound_regions_with_placeholders(a_pair); debug!("higher_ranked_match: a_match={:?}", a_match); - debug!("higher_ranked_match: skol_map={:?}", skol_map); + debug!("higher_ranked_match: placeholder_map={:?}", placeholder_map); // Equate types now that bound regions have been replaced. self.equate(a_is_expected).relate(&a_match, &b_match)?; - // Map each skolemized region to a vector of other regions that it + // Map each placeholder region to a vector of other regions that it // must be equated with. (Note that this vector may include other - // skolemized regions from `skol_map`.) - let skol_resolution_map: FxHashMap<_, _> = - skol_map + // placeholder regions from `placeholder_map`.) + let placeholder_resolution_map: FxHashMap<_, _> = + placeholder_map .iter() - .map(|(&br, &skol)| { + .map(|(&br, &placeholder)| { let tainted_regions = self.infcx.tainted_regions(snapshot, - skol, + placeholder, TaintDirections::incoming()); // [1] - // [1] this routine executes after the skolemized + // [1] this routine executes after the placeholder // regions have been *equated* with something // else, so examining the incoming edges ought to // be enough to collect all constraints - (skol, (br, tainted_regions)) + (placeholder, (br, tainted_regions)) }) .collect(); - // For each skolemized region, pick a representative -- which can + // For each placeholder region, pick a representative -- which can // be any region from the sets above, except for other members of - // `skol_map`. There should always be a representative if things + // `placeholder_map`. There should always be a representative if things // are properly well-formed. - let skol_representatives: FxHashMap<_, _> = - skol_resolution_map + let placeholder_representatives: FxHashMap<_, _> = + placeholder_resolution_map .iter() - .map(|(&skol, &(_, ref regions))| { + .map(|(&placeholder, &(_, ref regions))| { let representative = regions.iter() - .filter(|&&r| !skol_resolution_map.contains_key(r)) + .filter(|&&r| !placeholder_resolution_map.contains_key(r)) .cloned() .next() .unwrap_or_else(|| { bug!("no representative region for `{:?}` in `{:?}`", - skol, regions) + placeholder, regions) }); - (skol, representative) + (placeholder, representative) }) .collect(); - // Equate all the members of each skolemization set with the + // Equate all the members of each placeholder set with the // representative. - for (skol, &(_br, ref regions)) in &skol_resolution_map { - let representative = &skol_representatives[skol]; + for (placeholder, &(_br, ref regions)) in &placeholder_resolution_map { + let representative = &placeholder_representatives[placeholder]; debug!("higher_ranked_match: \ - skol={:?} representative={:?} regions={:?}", - skol, representative, regions); + placeholder={:?} representative={:?} regions={:?}", + placeholder, representative, regions); for region in regions.iter() - .filter(|&r| !skol_resolution_map.contains_key(r)) + .filter(|&r| !placeholder_resolution_map.contains_key(r)) .filter(|&r| r != representative) { let origin = SubregionOrigin::Subtype(self.trace.clone()); @@ -184,18 +186,18 @@ } } - // Replace the skolemized regions appearing in value with + // Replace the placeholder regions appearing in value with // their representatives let a_value = fold_regions_in( self.tcx(), &a_value, - |r, _| skol_representatives.get(&r).cloned().unwrap_or(r)); + |r, _| placeholder_representatives.get(&r).cloned().unwrap_or(r)); debug!("higher_ranked_match: value={:?}", a_value); - // We are now done with these skolemized variables. - self.infcx.pop_skolemized(skol_map, snapshot); + // We are now done with these placeholder variables. + self.infcx.pop_placeholders(placeholder_map, snapshot); Ok(HrMatchResult { value: a_value }) }); @@ -450,7 +452,7 @@ .collect() } -fn is_var_in_set(new_vars: &[ty::RegionVid], r: ty::Region) -> bool { +fn is_var_in_set(new_vars: &[ty::RegionVid], r: ty::Region<'_>) -> bool { match *r { ty::ReVar(ref v) => new_vars.iter().any(|x| x == v), _ => false @@ -500,7 +502,7 @@ * started. This is used in the sub/lub/glb computations. The * idea here is that when we are computing lub/glb of two * regions, we sometimes create intermediate region variables. - * Those region variables may touch some of the skolemized or + * Those region variables may touch some of the placeholder or * other "forbidden" regions we created to replace bound * regions, but they don't really represent an "external" * constraint. @@ -527,10 +529,10 @@ * we're not careful, it will succeed. * * The reason is that when we walk through the subtyping - * algorithm, we begin by replacing `'a` with a skolemized + * algorithm, we begin by replacing `'a` with a placeholder * variable `'1`. We then have `fn(_#0t) <: fn(&'1 int)`. This * can be made true by unifying `_#0t` with `&'1 int`. In the - * process, we create a fresh variable for the skolemized + * process, we create a fresh variable for the placeholder * region, `'$2`, and hence we have that `_#0t == &'$2 * int`. However, because `'$2` was created during the sub * computation, if we're not careful we will erroneously @@ -551,7 +553,7 @@ let escaping_types = self.type_variables.borrow_mut().types_escaping_snapshot(&snapshot.type_snapshot); - let mut escaping_region_vars = FxHashSet(); + let mut escaping_region_vars = FxHashSet::default(); for ty in &escaping_types { self.tcx.collect_regions(ty, &mut escaping_region_vars); } @@ -568,33 +570,39 @@ region_vars } - /// Replace all regions bound by `binder` with skolemized regions and + /// Replace all regions bound by `binder` with placeholder regions and /// return a map indicating which bound-region was replaced with what - /// skolemized region. This is the first step of checking subtyping + /// placeholder region. This is the first step of checking subtyping /// when higher-ranked things are involved. /// /// **Important:** you must call this function from within a snapshot. /// Moreover, before committing the snapshot, you must eventually call - /// either `plug_leaks` or `pop_skolemized` to remove the skolemized + /// either `plug_leaks` or `pop_placeholders` to remove the placeholder /// regions. If you rollback the snapshot (or are using a probe), then /// the pop occurs as part of the rollback, so an explicit call is not /// needed (but is also permitted). /// - /// For more information about how skolemization for HRTBs works, see + /// For more information about how placeholders and HRTBs work, see /// the [rustc guide]. /// /// [rustc guide]: https://rust-lang-nursery.github.io/rustc-guide/traits/hrtb.html - pub fn skolemize_late_bound_regions(&self, - binder: &ty::Binder) - -> (T, SkolemizationMap<'tcx>) - where T : TypeFoldable<'tcx> + pub fn replace_late_bound_regions_with_placeholders( + &self, + binder: &ty::Binder, + ) -> (T, PlaceholderMap<'tcx>) + where + T : TypeFoldable<'tcx>, { + let next_universe = self.create_next_universe(); + let (result, map) = self.tcx.replace_late_bound_regions(binder, |br| { - self.universe.set(self.universe().subuniverse()); - self.tcx.mk_region(ty::ReSkolemized(self.universe(), br)) + self.tcx.mk_region(ty::RePlaceholder(ty::Placeholder { + universe: next_universe, + name: br, + })) }); - debug!("skolemize_bound_regions(binder={:?}, result={:?}, map={:?})", + debug!("replace_late_bound_regions_with_placeholders(binder={:?}, result={:?}, map={:?})", binder, result, map); @@ -603,19 +611,19 @@ } /// Searches the region constraints created since `snapshot` was started - /// and checks to determine whether any of the skolemized regions created - /// in `skol_map` would "escape" -- meaning that they are related to + /// and checks to determine whether any of the placeholder regions created + /// in `placeholder_map` would "escape" -- meaning that they are related to /// other regions in some way. If so, the higher-ranked subtyping doesn't /// hold. See `README.md` for more details. pub fn leak_check(&self, overly_polymorphic: bool, _span: Span, - skol_map: &SkolemizationMap<'tcx>, + placeholder_map: &PlaceholderMap<'tcx>, snapshot: &CombinedSnapshot<'a, 'tcx>) -> RelateResult<'tcx, ()> { - debug!("leak_check: skol_map={:?}", - skol_map); + debug!("leak_check: placeholder_map={:?}", + placeholder_map); // If the user gave `-Zno-leak-check`, then skip the leak // check completely. This is wildly unsound and also not @@ -630,14 +638,14 @@ } let new_vars = self.region_vars_confined_to_snapshot(snapshot); - for (&skol_br, &skol) in skol_map { - // The inputs to a skolemized variable can only + for (&placeholder_br, &placeholder) in placeholder_map { + // The inputs to a placeholder variable can only // be itself or other new variables. let incoming_taints = self.tainted_regions(snapshot, - skol, + placeholder, TaintDirections::both()); for &tainted_region in &incoming_taints { - // Each skolemized should only be relatable to itself + // Each placeholder should only be relatable to itself // or new variables: match *tainted_region { ty::ReVar(vid) => { @@ -646,21 +654,21 @@ } } _ => { - if tainted_region == skol { continue; } + if tainted_region == placeholder { continue; } } }; debug!("{:?} (which replaced {:?}) is tainted by {:?}", - skol, - skol_br, + placeholder, + placeholder_br, tainted_region); return Err(if overly_polymorphic { debug!("Overly polymorphic!"); - TypeError::RegionsOverlyPolymorphic(skol_br, tainted_region) + TypeError::RegionsOverlyPolymorphic(placeholder_br, tainted_region) } else { debug!("Not as polymorphic!"); - TypeError::RegionsInsufficientlyPolymorphic(skol_br, tainted_region) + TypeError::RegionsInsufficientlyPolymorphic(placeholder_br, tainted_region) }) } } @@ -668,9 +676,9 @@ Ok(()) } - /// This code converts from skolemized regions back to late-bound + /// This code converts from placeholder regions back to late-bound /// regions. It works by replacing each region in the taint set of a - /// skolemized region with a bound-region. The bound region will be bound + /// placeholder region with a bound-region. The bound region will be bound /// by the outer-most binder in `value`; the caller must ensure that there is /// such a binder and it is the right place. /// @@ -687,7 +695,7 @@ /// where A : Clone /// { ... } /// - /// Here we will have replaced `'a` with a skolemized region + /// Here we will have replaced `'a` with a placeholder region /// `'0`. This means that our substitution will be `{A=>&'0 /// int, R=>&'0 int}`. /// @@ -697,65 +705,65 @@ /// to the depth of the predicate, in this case 1, so that the final /// predicate is `for<'a> &'a int : Clone`. pub fn plug_leaks(&self, - skol_map: SkolemizationMap<'tcx>, + placeholder_map: PlaceholderMap<'tcx>, snapshot: &CombinedSnapshot<'a, 'tcx>, value: T) -> T where T : TypeFoldable<'tcx> { - debug!("plug_leaks(skol_map={:?}, value={:?})", - skol_map, + debug!("plug_leaks(placeholder_map={:?}, value={:?})", + placeholder_map, value); - if skol_map.is_empty() { + if placeholder_map.is_empty() { return value; } - // Compute a mapping from the "taint set" of each skolemized + // Compute a mapping from the "taint set" of each placeholder // region back to the `ty::BoundRegion` that it originally // represented. Because `leak_check` passed, we know that // these taint sets are mutually disjoint. - let inv_skol_map: FxHashMap, ty::BoundRegion> = - skol_map + let inv_placeholder_map: FxHashMap, ty::BoundRegion> = + placeholder_map .iter() - .flat_map(|(&skol_br, &skol)| { - self.tainted_regions(snapshot, skol, TaintDirections::both()) + .flat_map(|(&placeholder_br, &placeholder)| { + self.tainted_regions(snapshot, placeholder, TaintDirections::both()) .into_iter() - .map(move |tainted_region| (tainted_region, skol_br)) + .map(move |tainted_region| (tainted_region, placeholder_br)) }) .collect(); - debug!("plug_leaks: inv_skol_map={:?}", - inv_skol_map); + debug!("plug_leaks: inv_placeholder_map={:?}", + inv_placeholder_map); // Remove any instantiated type variables from `value`; those can hide // references to regions from the `fold_regions` code below. let value = self.resolve_type_vars_if_possible(&value); - // Map any skolemization byproducts back to a late-bound + // Map any placeholder byproducts back to a late-bound // region. Put that late-bound region at whatever the outermost // binder is that we encountered in `value`. The caller is // responsible for ensuring that (a) `value` contains at least one // binder and (b) that binder is the one we want to use. let result = self.tcx.fold_regions(&value, &mut false, |r, current_depth| { - match inv_skol_map.get(&r) { + match inv_placeholder_map.get(&r) { None => r, Some(br) => { // It is the responsibility of the caller to ensure - // that each skolemized region appears within a + // that each placeholder region appears within a // binder. In practice, this routine is only used by - // trait checking, and all of the skolemized regions + // trait checking, and all of the placeholder regions // appear inside predicates, which always have // binders, so this assert is satisfied. assert!(current_depth > ty::INNERMOST); - // since leak-check passed, this skolemized region + // since leak-check passed, this placeholder region // should only have incoming edges from variables // (which ought not to escape the snapshot, but we // don't check that) or itself assert!( match *r { ty::ReVar(_) => true, - ty::ReSkolemized(_, ref br1) => br == br1, + ty::RePlaceholder(index) => index.name == *br, _ => false, }, "leak-check would have us replace {:?} with {:?}", @@ -769,31 +777,36 @@ } }); - self.pop_skolemized(skol_map, snapshot); + self.pop_placeholders(placeholder_map, snapshot); debug!("plug_leaks: result={:?}", result); result } - /// Pops the skolemized regions found in `skol_map` from the region - /// inference context. Whenever you create skolemized regions via - /// `skolemize_late_bound_regions`, they must be popped before you + /// Pops the placeholder regions found in `placeholder_map` from the region + /// inference context. Whenever you create placeholder regions via + /// `replace_late_bound_regions_with_placeholders`, they must be popped before you /// commit the enclosing snapshot (if you do not commit, e.g. within a /// probe or as a result of an error, then this is not necessary, as /// popping happens as part of the rollback). /// /// Note: popping also occurs implicitly as part of `leak_check`. - pub fn pop_skolemized(&self, - skol_map: SkolemizationMap<'tcx>, - snapshot: &CombinedSnapshot<'a, 'tcx>) { - debug!("pop_skolemized({:?})", skol_map); - let skol_regions: FxHashSet<_> = skol_map.values().cloned().collect(); + pub fn pop_placeholders( + &self, + placeholder_map: PlaceholderMap<'tcx>, + snapshot: &CombinedSnapshot<'a, 'tcx>, + ) { + debug!("pop_placeholders({:?})", placeholder_map); + let placeholder_regions: FxHashSet<_> = placeholder_map.values().cloned().collect(); self.borrow_region_constraints() - .pop_skolemized(self.universe(), &skol_regions, &snapshot.region_constraints_snapshot); + .pop_placeholders( + &placeholder_regions, + &snapshot.region_constraints_snapshot, + ); self.universe.set(snapshot.universe); - if !skol_map.is_empty() { - self.projection_cache.borrow_mut().rollback_skolemized( + if !placeholder_map.is_empty() { + self.projection_cache.borrow_mut().rollback_placeholder( &snapshot.projection_cache_snapshot); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/higher_ranked/README.md rustc-1.31.0+dfsg1+llvm/src/librustc/infer/higher_ranked/README.md --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/higher_ranked/README.md 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/higher_ranked/README.md 2018-12-04 23:41:40.000000000 +0000 @@ -72,11 +72,11 @@ Here is the algorithm we use to perform the subtyping check: 1. Replace all bound regions in the subtype with new variables -2. Replace all bound regions in the supertype with skolemized - equivalents. A "skolemized" region is just a new fresh region +2. Replace all bound regions in the supertype with placeholder + equivalents. A "placeholder" region is just a new fresh region name. 3. Check that the parameter and return types match as normal -4. Ensure that no skolemized regions 'leak' into region variables +4. Ensure that no placeholder regions 'leak' into region variables visible from "the outside" Let's walk through some examples and see how this algorithm plays out. @@ -95,7 +95,7 @@ Here the upper case `&A` indicates a *region variable*, that is, a region whose value is being inferred by the system. I also replaced `&b` with `&x`---I'll use letters late in the alphabet (`x`, `y`, `z`) -to indicate skolemized region names. We can assume they don't appear +to indicate placeholder region names. We can assume they don't appear elsewhere. Note that neither the sub- nor the supertype bind any region names anymore (as indicated by the absence of `<` and `>`). @@ -133,7 +133,7 @@ must hold: but this does not hold. `self` and `x` are both distinct free regions. So the subtype check fails. -#### Checking for skolemization leaks +#### Checking for placeholder leaks You may be wondering about that mysterious last step in the algorithm. So far it has not been relevant. The purpose of that last step is to @@ -159,7 +159,7 @@ fn(&'A T) <: for<'b> fn(&'b T)? -Here we skolemize the bound region in the supertype to yield: +Here we replace the bound region in the supertype with a placeholder to yield: fn(&'A T) <: fn(&'x T)? @@ -175,23 +175,23 @@ is *necessary*, it was key to the first example we walked through. The difference between this example and the first one is that the variable -`A` already existed at the point where the skolemization occurred. In +`A` already existed at the point where the placeholders were added. In the first example, you had two functions: for<'a> fn(&'a T) <: for<'b> fn(&'b T) and hence `&A` and `&x` were created "together". In general, the -intention of the skolemized names is that they are supposed to be +intention of the placeholder names is that they are supposed to be fresh names that could never be equal to anything from the outside. But when inference comes into play, we might not be respecting this rule. So the way we solve this is to add a fourth step that examines the -constraints that refer to skolemized names. Basically, consider a +constraints that refer to placeholder names. Basically, consider a non-directed version of the constraint graph. Let `Tainted(x)` be the -set of all things reachable from a skolemized variable `x`. +set of all things reachable from a placeholder variable `x`. `Tainted(x)` should not contain any regions that existed before the -step at which the skolemization was performed. So this case here +step at which the placeholders were created. So this case here would fail because `&x` was created alone, but is relatable to `&A`. ## Computing the LUB and GLB diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/lexical_region_resolve/graphviz.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/lexical_region_resolve/graphviz.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/lexical_region_resolve/graphviz.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/lexical_region_resolve/graphviz.rs 2018-12-04 23:41:40.000000000 +0000 @@ -112,12 +112,9 @@ } }; - match dump_region_data_to(region_rels, ®ion_data.constraints, &output_path) { - Ok(()) => {} - Err(e) => { - let msg = format!("io error dumping region constraints: {}", e); - tcx.sess.err(&msg) - } + if let Err(e) = dump_region_data_to(region_rels, ®ion_data.constraints, &output_path) { + let msg = format!("io error dumping region constraints: {}", e); + tcx.sess.err(&msg) } } @@ -146,7 +143,7 @@ map: &'a ConstraintMap<'tcx>) -> ConstraintGraph<'a, 'gcx, 'tcx> { let mut i = 0; - let mut node_ids = FxHashMap(); + let mut node_ids = FxHashMap::default(); { let mut add_node = |node| { if let Vacant(e) = node_ids.entry(node) { @@ -178,38 +175,35 @@ impl<'a, 'gcx, 'tcx> dot::Labeller<'a> for ConstraintGraph<'a, 'gcx, 'tcx> { type Node = Node; type Edge = Edge<'tcx>; - fn graph_id(&self) -> dot::Id { + fn graph_id(&self) -> dot::Id<'_> { dot::Id::new(&*self.graph_name).unwrap() } - fn node_id(&self, n: &Node) -> dot::Id { + fn node_id(&self, n: &Node) -> dot::Id<'_> { let node_id = match self.node_ids.get(n) { Some(node_id) => node_id, None => bug!("no node_id found for node: {:?}", n), }; let name = || format!("node_{}", node_id); - match dot::Id::new(name()) { - Ok(id) => id, - Err(_) => { - bug!("failed to create graphviz node identified by {}", name()); - } - } + + dot::Id::new(name()).unwrap_or_else(|_| + bug!("failed to create graphviz node identified by {}", name())) } - fn node_label(&self, n: &Node) -> dot::LabelText { + fn node_label(&self, n: &Node) -> dot::LabelText<'_> { match *n { Node::RegionVid(n_vid) => dot::LabelText::label(format!("{:?}", n_vid)), Node::Region(n_rgn) => dot::LabelText::label(format!("{:?}", n_rgn)), } } - fn edge_label(&self, e: &Edge) -> dot::LabelText { + fn edge_label(&self, e: &Edge<'_>) -> dot::LabelText<'_> { match *e { Edge::Constraint(ref c) => dot::LabelText::label(format!("{:?}", self.map.get(c).unwrap())), - Edge::EnclScope(..) => dot::LabelText::label("(enclosed)".to_string()), + Edge::EnclScope(..) => dot::LabelText::label("(enclosed)".to_owned()), } } } -fn constraint_to_nodes(c: &Constraint) -> (Node, Node) { +fn constraint_to_nodes(c: &Constraint<'_>) -> (Node, Node) { match *c { Constraint::VarSubVar(rv_1, rv_2) => (Node::RegionVid(rv_1), Node::RegionVid(rv_2)), @@ -222,7 +216,7 @@ } } -fn edge_to_nodes(e: &Edge) -> (Node, Node) { +fn edge_to_nodes(e: &Edge<'_>) -> (Node, Node) { match *e { Edge::Constraint(ref c) => constraint_to_nodes(c), Edge::EnclScope(sub, sup) => { @@ -235,15 +229,15 @@ impl<'a, 'gcx, 'tcx> dot::GraphWalk<'a> for ConstraintGraph<'a, 'gcx, 'tcx> { type Node = Node; type Edge = Edge<'tcx>; - fn nodes(&self) -> dot::Nodes { - let mut set = FxHashSet(); + fn nodes(&self) -> dot::Nodes<'_, Node> { + let mut set = FxHashSet::default(); for node in self.node_ids.keys() { set.insert(*node); } debug!("constraint graph has {} nodes", set.len()); set.into_iter().collect() } - fn edges(&self) -> dot::Edges> { + fn edges(&self) -> dot::Edges<'_, Edge<'tcx>> { debug!("constraint graph has {} edges", self.map.len()); let mut v: Vec<_> = self.map.keys().map(|e| Edge::Constraint(*e)).collect(); self.region_rels.region_scope_tree.each_encl_scope(|sub, sup| { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/lexical_region_resolve/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/lexical_region_resolve/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/lexical_region_resolve/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/lexical_region_resolve/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,23 +10,26 @@ //! The code to do lexical region resolution. -use infer::SubregionOrigin; -use infer::RegionVariableOrigin; use infer::region_constraints::Constraint; use infer::region_constraints::GenericKind; use infer::region_constraints::RegionConstraintData; use infer::region_constraints::VarInfos; use infer::region_constraints::VerifyBound; +use infer::RegionVariableOrigin; +use infer::SubregionOrigin; use middle::free_region::RegionRelations; -use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use rustc_data_structures::fx::FxHashSet; -use rustc_data_structures::graph::implementation::{Graph, Direction, NodeIndex, INCOMING, OUTGOING}; +use rustc_data_structures::graph::implementation::{ + Direction, Graph, NodeIndex, INCOMING, OUTGOING, +}; +use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use std::fmt; use std::u32; -use ty::{self, TyCtxt}; -use ty::{Region, RegionVid}; +use ty::fold::TypeFoldable; +use ty::{self, Ty, TyCtxt}; use ty::{ReEarlyBound, ReEmpty, ReErased, ReFree, ReStatic}; -use ty::{ReLateBound, ReScope, ReSkolemized, ReVar}; +use ty::{ReLateBound, ReScope, RePlaceholder, ReVar}; +use ty::{Region, RegionVid}; mod graphviz; @@ -108,11 +111,15 @@ } impl<'cx, 'gcx, 'tcx> LexicalResolver<'cx, 'gcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'cx, 'gcx, 'tcx> { + self.region_rels.tcx + } + fn infer_variable_values( &mut self, errors: &mut Vec>, ) -> LexicalRegionResolutions<'tcx> { - let mut var_data = self.construct_var_data(self.region_rels.tcx); + let mut var_data = self.construct_var_data(self.tcx()); // Dorky hack to cause `dump_constraints` to only get called // if debug mode is enabled: @@ -140,9 +147,7 @@ fn construct_var_data(&self, tcx: TyCtxt<'_, '_, 'tcx>) -> LexicalRegionResolutions<'tcx> { LexicalRegionResolutions { error_region: tcx.types.re_static, - values: (0..self.num_vars()) - .map(|_| VarValue::Value(tcx.types.re_empty)) - .collect(), + values: IndexVec::from_elem_n(VarValue::Value(tcx.types.re_empty), self.num_vars()) } } @@ -156,7 +161,7 @@ } } - fn expand_givens(&mut self, graph: &RegionGraph) { + fn expand_givens(&mut self, graph: &RegionGraph<'_>) { // Givens are a kind of horrible hack to account for // constraints like 'c <= '0 that are known to hold due to // closure signatures (see the comment above on the `givens` @@ -239,9 +244,7 @@ debug!( "Expanding value of {:?} from {:?} to {:?}", - b_vid, - cur_region, - lub + b_vid, cur_region, lub ); *b_data = VarValue::Value(lub); @@ -254,18 +257,17 @@ } } - fn lub_concrete_regions(&self, a: Region<'tcx>, b: Region<'tcx>) -> Region<'tcx> { - let tcx = self.region_rels.tcx; + let tcx = self.tcx(); match (a, b) { - (&ty::ReCanonical(..), _) | - (_, &ty::ReCanonical(..)) | - (&ty::ReClosureBound(..), _) | - (_, &ty::ReClosureBound(..)) | - (&ReLateBound(..), _) | - (_, &ReLateBound(..)) | - (&ReErased, _) | - (_, &ReErased) => { + (&ty::ReCanonical(..), _) + | (_, &ty::ReCanonical(..)) + | (&ty::ReClosureBound(..), _) + | (_, &ty::ReClosureBound(..)) + | (&ReLateBound(..), _) + | (_, &ReLateBound(..)) + | (&ReErased, _) + | (_, &ReErased) => { bug!("cannot relate region: LUB({:?}, {:?})", a, b); } @@ -287,20 +289,20 @@ ); } - (&ReEarlyBound(_), &ReScope(s_id)) | - (&ReScope(s_id), &ReEarlyBound(_)) | - (&ReFree(_), &ReScope(s_id)) | - (&ReScope(s_id), &ReFree(_)) => { + (&ReEarlyBound(_), &ReScope(s_id)) + | (&ReScope(s_id), &ReEarlyBound(_)) + | (&ReFree(_), &ReScope(s_id)) + | (&ReScope(s_id), &ReFree(_)) => { // A "free" region can be interpreted as "some region // at least as big as fr.scope". So, we can // reasonably compare free regions and scopes: let fr_scope = match (a, b) { (&ReEarlyBound(ref br), _) | (_, &ReEarlyBound(ref br)) => self.region_rels .region_scope_tree - .early_free_scope(self.region_rels.tcx, br), + .early_free_scope(self.tcx(), br), (&ReFree(ref fr), _) | (_, &ReFree(ref fr)) => self.region_rels .region_scope_tree - .free_scope(self.region_rels.tcx, fr), + .free_scope(self.tcx(), fr), _ => bug!(), }; let r_id = self.region_rels @@ -332,14 +334,14 @@ tcx.mk_region(ReScope(lub)) } - (&ReEarlyBound(_), &ReEarlyBound(_)) | - (&ReFree(_), &ReEarlyBound(_)) | - (&ReEarlyBound(_), &ReFree(_)) | - (&ReFree(_), &ReFree(_)) => self.region_rels.lub_free_regions(a, b), + (&ReEarlyBound(_), &ReEarlyBound(_)) + | (&ReFree(_), &ReEarlyBound(_)) + | (&ReEarlyBound(_), &ReFree(_)) + | (&ReFree(_), &ReFree(_)) => self.region_rels.lub_free_regions(a, b), // For these types, we cannot define any additional // relationship: - (&ReSkolemized(..), _) | (_, &ReSkolemized(..)) => if a == b { + (&RePlaceholder(..), _) | (_, &RePlaceholder(..)) => if a == b { a } else { tcx.types.re_static @@ -358,8 +360,7 @@ for (constraint, origin) in &self.data.constraints { debug!( "collect_errors: constraint={:?} origin={:?}", - constraint, - origin + constraint, origin ); match *constraint { Constraint::RegSubVar(..) | Constraint::VarSubVar(..) => { @@ -374,9 +375,7 @@ debug!( "collect_errors: region error at {:?}: \ cannot verify that {:?} <= {:?}", - origin, - sub, - sup + origin, sub, sup ); errors.push(RegionResolutionError::ConcreteFailure( @@ -402,10 +401,7 @@ debug!( "collect_errors: region error at {:?}: \ cannot verify that {:?}={:?} <= {:?}", - origin, - a_vid, - a_region, - b_region + origin, a_vid, a_region, b_region ); *a_data = VarValue::ErrorValue; } @@ -415,7 +411,7 @@ for verify in &self.data.verifys { debug!("collect_errors: verify={:?}", verify); - let sub = var_data.normalize(verify.region); + let sub = var_data.normalize(self.tcx(), verify.region); // This was an inference variable which didn't get // constrained, therefore it can be assume to hold. @@ -423,16 +419,15 @@ continue; } - if self.bound_is_met(&verify.bound, var_data, sub) { + let verify_kind_ty = verify.kind.to_ty(self.tcx()); + if self.bound_is_met(&verify.bound, var_data, verify_kind_ty, sub) { continue; } debug!( "collect_errors: region error at {:?}: \ cannot verify that {:?} <= {:?}", - verify.origin, - verify.region, - verify.bound + verify.origin, verify.region, verify.bound ); errors.push(RegionResolutionError::GenericBoundFailure( @@ -561,7 +556,7 @@ // We place free regions first because we are special casing // SubSupConflict(ReFree, ReFree) when reporting error, and so // the user will more likely get a specific suggestion. - fn region_order_key(x: &RegionAndOrigin) -> u8 { + fn region_order_key(x: &RegionAndOrigin<'_>) -> u8 { match *x.region { ReEarlyBound(_) => 0, ReFree(_) => 1, @@ -580,10 +575,7 @@ debug!( "region inference error at {:?} for {:?}: SubSupConflict sub: {:?} \ sup: {:?}", - origin, - node_idx, - lower_bound.region, - upper_bound.region + origin, node_idx, lower_bound.region, upper_bound.region ); errors.push(RegionResolutionError::SubSupConflict( origin, @@ -622,7 +614,7 @@ dup_found: bool, } let mut state = WalkState { - set: FxHashSet(), + set: Default::default(), stack: vec![orig_node_idx], result: Vec::new(), dup_found: false, @@ -645,8 +637,7 @@ debug!( "collect_concrete_regions(orig_node_idx={:?}, node_idx={:?})", - orig_node_idx, - node_idx + orig_node_idx, node_idx ); process_edges(&self.data, &mut state, graph, node_idx, dir); @@ -721,37 +712,45 @@ &self, bound: &VerifyBound<'tcx>, var_values: &LexicalRegionResolutions<'tcx>, + generic_ty: Ty<'tcx>, min: ty::Region<'tcx>, ) -> bool { match bound { - VerifyBound::AnyRegion(rs) => rs.iter() - .map(|&r| var_values.normalize(r)) - .any(|r| self.region_rels.is_subregion_of(min, r)), - - VerifyBound::AllRegions(rs) => rs.iter() - .map(|&r| var_values.normalize(r)) - .all(|r| self.region_rels.is_subregion_of(min, r)), + VerifyBound::IfEq(k, b) => { + (var_values.normalize(self.region_rels.tcx, *k) == generic_ty) + && self.bound_is_met(b, var_values, generic_ty, min) + } + + VerifyBound::OutlivedBy(r) => + self.region_rels.is_subregion_of( + min, + var_values.normalize(self.tcx(), r), + ), - VerifyBound::AnyBound(bs) => bs.iter().any(|b| self.bound_is_met(b, var_values, min)), + VerifyBound::AnyBound(bs) => bs.iter() + .any(|b| self.bound_is_met(b, var_values, generic_ty, min)), - VerifyBound::AllBounds(bs) => bs.iter().all(|b| self.bound_is_met(b, var_values, min)), + VerifyBound::AllBounds(bs) => bs.iter() + .all(|b| self.bound_is_met(b, var_values, generic_ty, min)), } } } impl<'tcx> fmt::Debug for RegionAndOrigin<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "RegionAndOrigin({:?},{:?})", self.region, self.origin) } } - impl<'tcx> LexicalRegionResolutions<'tcx> { - fn normalize(&self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { - match *r { - ty::ReVar(rid) => self.resolve_var(rid), + fn normalize(&self, tcx: TyCtxt<'_, '_, 'tcx>, value: T) -> T + where + T: TypeFoldable<'tcx>, + { + tcx.fold_regions(&value, &mut false, |r, _db| match r { + ty::ReVar(rid) => self.resolve_var(*rid), _ => r, - } + }) } fn value(&self, rid: RegionVid) -> &VarValue<'tcx> { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -20,10 +20,12 @@ use arena::SyncDroplessArena; use errors::DiagnosticBuilder; use hir::def_id::DefId; +use infer::canonical::{Canonical, CanonicalVarValues}; use middle::free_region::RegionRelations; use middle::lang_items; use middle::region; use rustc_data_structures::unify as ut; +use session::config::BorrowckMode; use std::cell::{Cell, Ref, RefCell, RefMut}; use std::collections::BTreeMap; use std::fmt; @@ -48,7 +50,6 @@ use self::type_variable::TypeVariableOrigin; use self::unify_key::ToType; -pub mod opaque_types; pub mod at; pub mod canonical; mod combine; @@ -61,6 +62,8 @@ pub mod lattice; mod lexical_region_resolve; mod lub; +pub mod nll_relate; +pub mod opaque_types; pub mod outlives; pub mod region_constraints; pub mod resolve; @@ -80,6 +83,34 @@ pub type UnitResult<'tcx> = RelateResult<'tcx, ()>; // "unify result" pub type FixupResult = Result; // "fixup result" +/// A flag that is used to suppress region errors. This is normally +/// false, but sometimes -- when we are doing region checks that the +/// NLL borrow checker will also do -- it might be set to true. +#[derive(Copy, Clone, Default, Debug)] +pub struct SuppressRegionErrors { + suppressed: bool, +} + +impl SuppressRegionErrors { + pub fn suppressed(self) -> bool { + self.suppressed + } + + /// Indicates that the MIR borrowck will repeat these region + /// checks, so we should ignore errors if NLL is (unconditionally) + /// enabled. + pub fn when_nll_is_enabled(tcx: TyCtxt<'_, '_, '_>) -> Self { + match tcx.borrowck_mode() { + // If we're on AST or Migrate mode, report AST region errors + BorrowckMode::Ast | BorrowckMode::Migrate => SuppressRegionErrors { suppressed: false }, + + // If we're on MIR or Compare mode, don't report AST region errors as they should + // be reported by NLL + BorrowckMode::Compare | BorrowckMode::Mir => SuppressRegionErrors { suppressed: true }, + } + } +} + pub struct InferCtxt<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { pub tcx: TyCtxt<'a, 'gcx, 'tcx>, @@ -196,9 +227,10 @@ universe: Cell, } -/// A map returned by `skolemize_late_bound_regions()` indicating the skolemized -/// region that each late-bound region was replaced with. -pub type SkolemizationMap<'tcx> = BTreeMap>; +/// A map returned by `replace_late_bound_regions_with_placeholders()` +/// indicating the placeholder region that each late-bound region was +/// replaced with. +pub type PlaceholderMap<'tcx> = BTreeMap>; /// See `error_reporting` module for more details #[derive(Clone, Debug)] @@ -372,12 +404,14 @@ #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] pub enum NLLRegionVariableOrigin { - // During NLL region processing, we create variables for free - // regions that we encounter in the function signature and - // elsewhere. This origin indices we've got one of those. + /// During NLL region processing, we create variables for free + /// regions that we encounter in the function signature and + /// elsewhere. This origin indices we've got one of those. FreeRegion, - BoundRegion(ty::UniverseIndex), + /// "Universal" instantiation of a higher-ranked region (e.g., + /// from a `for<'a> T` binder). Meant to represent "any region". + Placeholder(ty::Placeholder), Existential, } @@ -386,7 +420,7 @@ pub fn is_universal(self) -> bool { match self { NLLRegionVariableOrigin::FreeRegion => true, - NLLRegionVariableOrigin::BoundRegion(..) => true, + NLLRegionVariableOrigin::Placeholder(..) => true, NLLRegionVariableOrigin::Existential => false, } } @@ -408,11 +442,11 @@ pub struct RegionObligation<'tcx> { pub sub_region: ty::Region<'tcx>, pub sup_type: Ty<'tcx>, - pub cause: ObligationCause<'tcx>, + pub origin: SubregionOrigin<'tcx>, } impl fmt::Display for FixupError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use self::FixupError::*; match *self { @@ -444,7 +478,7 @@ pub fn infer_ctxt(self) -> InferCtxtBuilder<'a, 'gcx, 'tcx> { InferCtxtBuilder { global_tcx: self, - arena: SyncDroplessArena::new(), + arena: SyncDroplessArena::default(), fresh_tables: None, } } @@ -458,10 +492,30 @@ self } - pub fn enter(&'tcx mut self, f: F) -> R + /// Given a canonical value `C` as a starting point, create an + /// inference context that contains each of the bound values + /// within instantiated as a fresh variable. The `f` closure is + /// invoked with the new infcx, along with the instantiated value + /// `V` and a substitution `S`. This substitution `S` maps from + /// the bound values in `C` to their instantiated values in `V` + /// (in other words, `S(C) = V`). + pub fn enter_with_canonical( + &'tcx mut self, + span: Span, + canonical: &Canonical<'tcx, T>, + f: impl for<'b> FnOnce(InferCtxt<'b, 'gcx, 'tcx>, T, CanonicalVarValues<'tcx>) -> R, + ) -> R where - F: for<'b> FnOnce(InferCtxt<'b, 'gcx, 'tcx>) -> R, + T: TypeFoldable<'tcx>, { + self.enter(|infcx| { + let (value, subst) = + infcx.instantiate_canonical_with_fresh_inference_vars(span, canonical); + f(infcx, value, subst) + }) + } + + pub fn enter(&'tcx mut self, f: impl for<'b> FnOnce(InferCtxt<'b, 'gcx, 'tcx>) -> R) -> R { let InferCtxtBuilder { global_tcx, ref arena, @@ -472,15 +526,15 @@ f(InferCtxt { tcx, in_progress_tables, - projection_cache: RefCell::new(traits::ProjectionCache::new()), + projection_cache: Default::default(), type_variables: RefCell::new(type_variable::TypeVariableTable::new()), int_unification_table: RefCell::new(ut::UnificationTable::new()), float_unification_table: RefCell::new(ut::UnificationTable::new()), region_constraints: RefCell::new(Some(RegionConstraintCollector::new())), lexical_region_resolutions: RefCell::new(None), - selection_cache: traits::SelectionCache::new(), - evaluation_cache: traits::EvaluationCache::new(), - reported_trait_errors: RefCell::new(FxHashMap()), + selection_cache: Default::default(), + evaluation_cache: Default::default(), + reported_trait_errors: Default::default(), tainted_by_errors_flag: Cell::new(false), err_count_on_creation: tcx.sess.err_count(), in_snapshot: Cell::new(false), @@ -557,7 +611,7 @@ t.fold_with(&mut self.freshener()) } - pub fn type_var_diverges(&'a self, ty: Ty) -> bool { + pub fn type_var_diverges(&'a self, ty: Ty<'_>) -> bool { match ty.sty { ty::Infer(ty::TyVar(vid)) => self.type_variables.borrow().var_diverges(vid), _ => false, @@ -568,7 +622,7 @@ freshen::TypeFreshener::new(self) } - pub fn type_is_unconstrained_numeric(&'a self, ty: Ty) -> UnconstrainedNumeric { + pub fn type_is_unconstrained_numeric(&'a self, ty: Ty<'_>) -> UnconstrainedNumeric { use ty::error::UnconstrainedNumeric::Neither; use ty::error::UnconstrainedNumeric::{UnconstrainedFloat, UnconstrainedInt}; match ty.sty { @@ -880,13 +934,13 @@ a, b, }, - skol_map, - ) = self.skolemize_late_bound_regions(predicate); + placeholder_map, + ) = self.replace_late_bound_regions_with_placeholders(predicate); let cause_span = cause.span; let ok = self.at(cause, param_env).sub_exp(a_is_expected, a, b)?; - self.leak_check(false, cause_span, &skol_map, snapshot)?; - self.pop_skolemized(skol_map, snapshot); + self.leak_check(false, cause_span, &placeholder_map, snapshot)?; + self.pop_placeholders(placeholder_map, snapshot); Ok(ok.unit()) })) } @@ -897,14 +951,14 @@ predicate: &ty::PolyRegionOutlivesPredicate<'tcx>, ) -> UnitResult<'tcx> { self.commit_if_ok(|snapshot| { - let (ty::OutlivesPredicate(r_a, r_b), skol_map) = - self.skolemize_late_bound_regions(predicate); + let (ty::OutlivesPredicate(r_a, r_b), placeholder_map) = + self.replace_late_bound_regions_with_placeholders(predicate); let origin = SubregionOrigin::from_obligation_cause(cause, || { RelateRegionParamBound(cause.span) }); self.sub_regions(origin, r_b, r_a); // `b : a` ==> `a <= b` - self.leak_check(false, cause.span, &skol_map, snapshot)?; - Ok(self.pop_skolemized(skol_map, snapshot)) + self.leak_check(false, cause.span, &placeholder_map, snapshot)?; + Ok(self.pop_placeholders(placeholder_map, snapshot)) }) } @@ -1039,34 +1093,7 @@ region_context: DefId, region_map: ®ion::ScopeTree, outlives_env: &OutlivesEnvironment<'tcx>, - ) { - self.resolve_regions_and_report_errors_inner( - region_context, - region_map, - outlives_env, - false, - ) - } - - /// Like `resolve_regions_and_report_errors`, but skips error - /// reporting if NLL is enabled. This is used for fn bodies where - /// the same error may later be reported by the NLL-based - /// inference. - pub fn resolve_regions_and_report_errors_unless_nll( - &self, - region_context: DefId, - region_map: ®ion::ScopeTree, - outlives_env: &OutlivesEnvironment<'tcx>, - ) { - self.resolve_regions_and_report_errors_inner(region_context, region_map, outlives_env, true) - } - - fn resolve_regions_and_report_errors_inner( - &self, - region_context: DefId, - region_map: ®ion::ScopeTree, - outlives_env: &OutlivesEnvironment<'tcx>, - will_later_be_reported_by_nll: bool, + suppress: SuppressRegionErrors, ) { assert!( self.is_tainted_by_errors() || self.region_obligations.borrow().is_empty(), @@ -1098,7 +1125,7 @@ // this infcx was in use. This is totally hokey but // otherwise we have a hard time separating legit region // errors from silly ones. - self.report_region_errors(region_map, &errors, will_later_be_reported_by_nll); + self.report_region_errors(region_map, &errors, suppress); } } @@ -1450,7 +1477,7 @@ }) } - /// Clears the selection, evaluation, and projection cachesThis is useful when + /// Clears the selection, evaluation, and projection caches. This is useful when /// repeatedly attemping to select an Obligation while changing only /// its ParamEnv, since FulfillmentContext doesn't use 'probe' pub fn clear_caches(&self) { @@ -1463,13 +1490,10 @@ self.universe.get() } - /// Create and return a new subunivese of the current universe; - /// update `self.universe` to that new subuniverse. At present, - /// used only in the NLL subtyping code, which uses the new - /// universe-based scheme instead of the more limited leak-check - /// scheme. - pub fn create_subuniverse(&self) -> ty::UniverseIndex { - let u = self.universe.get().subuniverse(); + /// Create and return a fresh universe that extends all previous + /// universes. Updates `self.universe` to that new universe. + pub fn create_next_universe(&self) -> ty::UniverseIndex { + let u = self.universe.get().next_universe(); self.universe.set(u); u } @@ -1504,7 +1528,7 @@ } impl<'tcx> fmt::Debug for TypeTrace<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "TypeTrace({:?})", self.cause) } } @@ -1592,7 +1616,7 @@ } impl<'tcx> fmt::Debug for RegionObligation<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, "RegionObligation(sub_region={:?}, sup_type={:?})", diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/nll_relate/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/nll_relate/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/nll_relate/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/nll_relate/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,736 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! This code is kind of an alternate way of doing subtyping, +//! supertyping, and type equating, distinct from the `combine.rs` +//! code but very similar in its effect and design. Eventually the two +//! ought to be merged. This code is intended for use in NLL. +//! +//! Here are the key differences: +//! +//! - This code generally assumes that there are no unbound type +//! inferences variables, because at NLL +//! time types are fully inferred up-to regions. +//! - Actually, to support user-given type annotations like +//! `Vec<_>`, we do have some measure of support for type +//! inference variables, but we impose some simplifying +//! assumptions on them that would not be suitable for the infer +//! code more generally. This could be fixed. +//! - This code uses "universes" to handle higher-ranked regions and +//! not the leak-check. This is "more correct" than what rustc does +//! and we are generally migrating in this direction, but NLL had to +//! get there first. + +use crate::infer::InferCtxt; +use crate::ty::fold::{TypeFoldable, TypeVisitor}; +use crate::ty::relate::{self, Relate, RelateResult, TypeRelation}; +use crate::ty::subst::Kind; +use crate::ty::{self, Ty, TyCtxt}; +use rustc_data_structures::fx::FxHashMap; + +pub struct TypeRelating<'me, 'gcx: 'tcx, 'tcx: 'me, D> +where + D: TypeRelatingDelegate<'tcx>, +{ + infcx: &'me InferCtxt<'me, 'gcx, 'tcx>, + + /// Callback to use when we deduce an outlives relationship + delegate: D, + + /// How are we relating `a` and `b`? + /// + /// - covariant means `a <: b` + /// - contravariant means `b <: a` + /// - invariant means `a == b + /// - bivariant means that it doesn't matter + ambient_variance: ty::Variance, + + /// When we pass through a set of binders (e.g., when looking into + /// a `fn` type), we push a new bound region scope onto here. This + /// will contain the instantiated region for each region in those + /// binders. When we then encounter a `ReLateBound(d, br)`, we can + /// use the debruijn index `d` to find the right scope, and then + /// bound region name `br` to find the specific instantiation from + /// within that scope. See `replace_bound_region`. + /// + /// This field stores the instantiations for late-bound regions in + /// the `a` type. + a_scopes: Vec>, + + /// Same as `a_scopes`, but for the `b` type. + b_scopes: Vec>, +} + +pub trait TypeRelatingDelegate<'tcx> { + /// Push a constraint `sup: sub` -- this constraint must be + /// satisfied for the two types to be related. `sub` and `sup` may + /// be regions from the type or new variables created through the + /// delegate. + fn push_outlives(&mut self, sup: ty::Region<'tcx>, sub: ty::Region<'tcx>); + + /// Creates a new universe index. Used when instantiating placeholders. + fn create_next_universe(&mut self) -> ty::UniverseIndex; + + /// Creates a new region variable representing a higher-ranked + /// region that is instantiated existentially. This creates an + /// inference variable, typically. + /// + /// So e.g. if you have `for<'a> fn(..) <: for<'b> fn(..)`, then + /// we will invoke this method to instantiate `'a` with an + /// inference variable (though `'b` would be instantiated first, + /// as a placeholder). + fn next_existential_region_var(&mut self) -> ty::Region<'tcx>; + + /// Creates a new region variable representing a + /// higher-ranked region that is instantiated universally. + /// This creates a new region placeholder, typically. + /// + /// So e.g. if you have `for<'a> fn(..) <: for<'b> fn(..)`, then + /// we will invoke this method to instantiate `'b` with a + /// placeholder region. + fn next_placeholder_region(&mut self, placeholder: ty::Placeholder) -> ty::Region<'tcx>; + + /// Creates a new existential region in the given universe. This + /// is used when handling subtyping and type variables -- if we + /// have that `?X <: Foo<'a>`, for example, we would instantiate + /// `?X` with a type like `Foo<'?0>` where `'?0` is a fresh + /// existential variable created by this function. We would then + /// relate `Foo<'?0>` with `Foo<'a>` (and probably add an outlives + /// relation stating that `'?0: 'a`). + fn generalize_existential(&mut self, universe: ty::UniverseIndex) -> ty::Region<'tcx>; +} + +#[derive(Clone, Debug)] +struct ScopesAndKind<'tcx> { + scopes: Vec>, + kind: Kind<'tcx>, +} + +#[derive(Clone, Debug, Default)] +struct BoundRegionScope<'tcx> { + map: FxHashMap>, +} + +#[derive(Copy, Clone)] +struct UniversallyQuantified(bool); + +impl<'me, 'gcx, 'tcx, D> TypeRelating<'me, 'gcx, 'tcx, D> +where + D: TypeRelatingDelegate<'tcx>, +{ + pub fn new( + infcx: &'me InferCtxt<'me, 'gcx, 'tcx>, + delegate: D, + ambient_variance: ty::Variance, + ) -> Self { + Self { + infcx, + delegate, + ambient_variance, + a_scopes: vec![], + b_scopes: vec![], + } + } + + fn ambient_covariance(&self) -> bool { + match self.ambient_variance { + ty::Variance::Covariant | ty::Variance::Invariant => true, + ty::Variance::Contravariant | ty::Variance::Bivariant => false, + } + } + + fn ambient_contravariance(&self) -> bool { + match self.ambient_variance { + ty::Variance::Contravariant | ty::Variance::Invariant => true, + ty::Variance::Covariant | ty::Variance::Bivariant => false, + } + } + + fn create_scope( + &mut self, + value: &ty::Binder>, + universally_quantified: UniversallyQuantified, + ) -> BoundRegionScope<'tcx> { + let mut scope = BoundRegionScope::default(); + + // Create a callback that creates (via the delegate) either an + // existential or placeholder region as needed. + let mut next_region = { + let delegate = &mut self.delegate; + let mut lazy_universe = None; + move |br: ty::BoundRegion| { + if universally_quantified.0 { + // The first time this closure is called, create a + // new universe for the placeholders we will make + // from here out. + let universe = lazy_universe.unwrap_or_else(|| { + let universe = delegate.create_next_universe(); + lazy_universe = Some(universe); + universe + }); + + let placeholder = ty::Placeholder { universe, name: br }; + delegate.next_placeholder_region(placeholder) + } else { + delegate.next_existential_region_var() + } + } + }; + + value.skip_binder().visit_with(&mut ScopeInstantiator { + next_region: &mut next_region, + target_index: ty::INNERMOST, + bound_region_scope: &mut scope, + }); + + scope + } + + /// When we encounter binders during the type traversal, we record + /// the value to substitute for each of the things contained in + /// that binder. (This will be either a universal placeholder or + /// an existential inference variable.) Given the debruijn index + /// `debruijn` (and name `br`) of some binder we have now + /// encountered, this routine finds the value that we instantiated + /// the region with; to do so, it indexes backwards into the list + /// of ambient scopes `scopes`. + fn lookup_bound_region( + debruijn: ty::DebruijnIndex, + br: &ty::BoundRegion, + first_free_index: ty::DebruijnIndex, + scopes: &[BoundRegionScope<'tcx>], + ) -> ty::Region<'tcx> { + // The debruijn index is a "reverse index" into the + // scopes listing. So when we have INNERMOST (0), we + // want the *last* scope pushed, and so forth. + let debruijn_index = debruijn.index() - first_free_index.index(); + let scope = &scopes[scopes.len() - debruijn_index - 1]; + + // Find this bound region in that scope to map to a + // particular region. + scope.map[br] + } + + /// If `r` is a bound region, find the scope in which it is bound + /// (from `scopes`) and return the value that we instantiated it + /// with. Otherwise just return `r`. + fn replace_bound_region( + &self, + r: ty::Region<'tcx>, + first_free_index: ty::DebruijnIndex, + scopes: &[BoundRegionScope<'tcx>], + ) -> ty::Region<'tcx> { + if let ty::ReLateBound(debruijn, br) = r { + Self::lookup_bound_region(*debruijn, br, first_free_index, scopes) + } else { + r + } + } + + /// Push a new outlives requirement into our output set of + /// constraints. + fn push_outlives(&mut self, sup: ty::Region<'tcx>, sub: ty::Region<'tcx>) { + debug!("push_outlives({:?}: {:?})", sup, sub); + + self.delegate.push_outlives(sup, sub); + } + + /// When we encounter a canonical variable `var` in the output, + /// equate it with `kind`. If the variable has been previously + /// equated, then equate it again. + fn relate_var(&mut self, var_ty: Ty<'tcx>, value_ty: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { + debug!("equate_var(var_ty={:?}, value_ty={:?})", var_ty, value_ty); + + let generalized_ty = self.generalize_value(value_ty); + self.infcx + .force_instantiate_unchecked(var_ty, generalized_ty); + + // The generalized values we extract from `canonical_var_values` have + // been fully instantiated and hence the set of scopes we have + // doesn't matter -- just to be sure, put an empty vector + // in there. + let old_a_scopes = ::std::mem::replace(&mut self.a_scopes, vec![]); + + // Relate the generalized kind to the original one. + let result = self.relate(&generalized_ty, &value_ty); + + // Restore the old scopes now. + self.a_scopes = old_a_scopes; + + debug!("equate_var: complete, result = {:?}", result); + result + } + + fn generalize_value>(&mut self, value: T) -> T { + TypeGeneralizer { + tcx: self.infcx.tcx, + delegate: &mut self.delegate, + first_free_index: ty::INNERMOST, + ambient_variance: self.ambient_variance, + + // These always correspond to an `_` or `'_` written by + // user, and those are always in the root universe. + universe: ty::UniverseIndex::ROOT, + }.relate(&value, &value) + .unwrap() + } +} + +impl TypeRelation<'me, 'gcx, 'tcx> for TypeRelating<'me, 'gcx, 'tcx, D> +where + D: TypeRelatingDelegate<'tcx>, +{ + fn tcx(&self) -> TyCtxt<'me, 'gcx, 'tcx> { + self.infcx.tcx + } + + fn tag(&self) -> &'static str { + "nll::subtype" + } + + fn a_is_expected(&self) -> bool { + true + } + + fn relate_with_variance>( + &mut self, + variance: ty::Variance, + a: &T, + b: &T, + ) -> RelateResult<'tcx, T> { + debug!( + "relate_with_variance(variance={:?}, a={:?}, b={:?})", + variance, a, b + ); + + let old_ambient_variance = self.ambient_variance; + self.ambient_variance = self.ambient_variance.xform(variance); + + debug!( + "relate_with_variance: ambient_variance = {:?}", + self.ambient_variance + ); + + let r = self.relate(a, b)?; + + self.ambient_variance = old_ambient_variance; + + debug!("relate_with_variance: r={:?}", r); + + Ok(r) + } + + fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { + let a = self.infcx.shallow_resolve(a); + match a.sty { + ty::Infer(ty::TyVar(_)) | ty::Infer(ty::IntVar(_)) | ty::Infer(ty::FloatVar(_)) => { + self.relate_var(a.into(), b.into()) + } + + _ => { + debug!( + "tys(a={:?}, b={:?}, variance={:?})", + a, b, self.ambient_variance + ); + + relate::super_relate_tys(self, a, b) + } + } + } + + fn regions( + &mut self, + a: ty::Region<'tcx>, + b: ty::Region<'tcx>, + ) -> RelateResult<'tcx, ty::Region<'tcx>> { + debug!( + "regions(a={:?}, b={:?}, variance={:?})", + a, b, self.ambient_variance + ); + + let v_a = self.replace_bound_region(a, ty::INNERMOST, &self.a_scopes); + let v_b = self.replace_bound_region(b, ty::INNERMOST, &self.b_scopes); + + debug!("regions: v_a = {:?}", v_a); + debug!("regions: v_b = {:?}", v_b); + + if self.ambient_covariance() { + // Covariance: a <= b. Hence, `b: a`. + self.push_outlives(v_b, v_a); + } + + if self.ambient_contravariance() { + // Contravariant: b <= a. Hence, `a: b`. + self.push_outlives(v_a, v_b); + } + + Ok(a) + } + + fn binders( + &mut self, + a: &ty::Binder, + b: &ty::Binder, + ) -> RelateResult<'tcx, ty::Binder> + where + T: Relate<'tcx>, + { + // We want that + // + // ``` + // for<'a> fn(&'a u32) -> &'a u32 <: + // fn(&'b u32) -> &'b u32 + // ``` + // + // but not + // + // ``` + // fn(&'a u32) -> &'a u32 <: + // for<'b> fn(&'b u32) -> &'b u32 + // ``` + // + // We therefore proceed as follows: + // + // - Instantiate binders on `b` universally, yielding a universe U1. + // - Instantiate binders on `a` existentially in U1. + + debug!( + "binders({:?}: {:?}, ambient_variance={:?})", + a, b, self.ambient_variance + ); + + if self.ambient_covariance() { + // Covariance, so we want `for<..> A <: for<..> B` -- + // therefore we compare any instantiation of A (i.e., A + // instantiated with existentials) against every + // instantiation of B (i.e., B instantiated with + // universals). + + let b_scope = self.create_scope(b, UniversallyQuantified(true)); + let a_scope = self.create_scope(a, UniversallyQuantified(false)); + + debug!("binders: a_scope = {:?} (existential)", a_scope); + debug!("binders: b_scope = {:?} (universal)", b_scope); + + self.b_scopes.push(b_scope); + self.a_scopes.push(a_scope); + + // Reset the ambient variance to covariant. This is needed + // to correctly handle cases like + // + // for<'a> fn(&'a u32, &'a u3) == for<'b, 'c> fn(&'b u32, &'c u32) + // + // Somewhat surprisingly, these two types are actually + // **equal**, even though the one on the right looks more + // polymorphic. The reason is due to subtyping. To see it, + // consider that each function can call the other: + // + // - The left function can call the right with `'b` and + // `'c` both equal to `'a` + // + // - The right function can call the left with `'a` set to + // `{P}`, where P is the point in the CFG where the call + // itself occurs. Note that `'b` and `'c` must both + // include P. At the point, the call works because of + // subtyping (i.e., `&'b u32 <: &{P} u32`). + let variance = ::std::mem::replace(&mut self.ambient_variance, ty::Variance::Covariant); + + self.relate(a.skip_binder(), b.skip_binder())?; + + self.ambient_variance = variance; + + self.b_scopes.pop().unwrap(); + self.a_scopes.pop().unwrap(); + } + + if self.ambient_contravariance() { + // Contravariance, so we want `for<..> A :> for<..> B` + // -- therefore we compare every instantiation of A (i.e., + // A instantiated with universals) against any + // instantiation of B (i.e., B instantiated with + // existentials). Opposite of above. + + let a_scope = self.create_scope(a, UniversallyQuantified(true)); + let b_scope = self.create_scope(b, UniversallyQuantified(false)); + + debug!("binders: a_scope = {:?} (universal)", a_scope); + debug!("binders: b_scope = {:?} (existential)", b_scope); + + self.a_scopes.push(a_scope); + self.b_scopes.push(b_scope); + + // Reset ambient variance to contravariance. See the + // covariant case above for an explanation. + let variance = + ::std::mem::replace(&mut self.ambient_variance, ty::Variance::Contravariant); + + self.relate(a.skip_binder(), b.skip_binder())?; + + self.ambient_variance = variance; + + self.b_scopes.pop().unwrap(); + self.a_scopes.pop().unwrap(); + } + + Ok(a.clone()) + } +} + +/// When we encounter a binder like `for<..> fn(..)`, we actually have +/// to walk the `fn` value to find all the values bound by the `for` +/// (these are not explicitly present in the ty representation right +/// now). This visitor handles that: it descends the type, tracking +/// binder depth, and finds late-bound regions targeting the +/// `for<..`>. For each of those, it creates an entry in +/// `bound_region_scope`. +struct ScopeInstantiator<'me, 'tcx: 'me> { + next_region: &'me mut dyn FnMut(ty::BoundRegion) -> ty::Region<'tcx>, + // The debruijn index of the scope we are instantiating. + target_index: ty::DebruijnIndex, + bound_region_scope: &'me mut BoundRegionScope<'tcx>, +} + +impl<'me, 'tcx> TypeVisitor<'tcx> for ScopeInstantiator<'me, 'tcx> { + fn visit_binder>(&mut self, t: &ty::Binder) -> bool { + self.target_index.shift_in(1); + t.super_visit_with(self); + self.target_index.shift_out(1); + + false + } + + fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool { + let ScopeInstantiator { + bound_region_scope, + next_region, + .. + } = self; + + match r { + ty::ReLateBound(debruijn, br) if *debruijn == self.target_index => { + bound_region_scope + .map + .entry(*br) + .or_insert_with(|| next_region(*br)); + } + + _ => {} + } + + false + } +} + +/// The "type generalize" is used when handling inference variables. +/// +/// The basic strategy for handling a constraint like `?A <: B` is to +/// apply a "generalization strategy" to the type `B` -- this replaces +/// all the lifetimes in the type `B` with fresh inference +/// variables. (You can read more about the strategy in this [blog +/// post].) +/// +/// As an example, if we had `?A <: &'x u32`, we would generalize `&'x +/// u32` to `&'0 u32` where `'0` is a fresh variable. This becomes the +/// value of `A`. Finally, we relate `&'0 u32 <: &'x u32`, which +/// establishes `'0: 'x` as a constraint. +/// +/// As a side-effect of this generalization procedure, we also replace +/// all the bound regions that we have traversed with concrete values, +/// so that the resulting generalized type is independent from the +/// scopes. +/// +/// [blog post]: https://is.gd/0hKvIr +struct TypeGeneralizer<'me, 'gcx: 'tcx, 'tcx: 'me, D> +where + D: TypeRelatingDelegate<'tcx> + 'me, +{ + tcx: TyCtxt<'me, 'gcx, 'tcx>, + + delegate: &'me mut D, + + /// After we generalize this type, we are going to relative it to + /// some other type. What will be the variance at this point? + ambient_variance: ty::Variance, + + first_free_index: ty::DebruijnIndex, + + universe: ty::UniverseIndex, +} + +impl TypeRelation<'me, 'gcx, 'tcx> for TypeGeneralizer<'me, 'gcx, 'tcx, D> +where + D: TypeRelatingDelegate<'tcx>, +{ + fn tcx(&self) -> TyCtxt<'me, 'gcx, 'tcx> { + self.tcx + } + + fn tag(&self) -> &'static str { + "nll::generalizer" + } + + fn a_is_expected(&self) -> bool { + true + } + + fn relate_with_variance>( + &mut self, + variance: ty::Variance, + a: &T, + b: &T, + ) -> RelateResult<'tcx, T> { + debug!( + "TypeGeneralizer::relate_with_variance(variance={:?}, a={:?}, b={:?})", + variance, a, b + ); + + let old_ambient_variance = self.ambient_variance; + self.ambient_variance = self.ambient_variance.xform(variance); + + debug!( + "TypeGeneralizer::relate_with_variance: ambient_variance = {:?}", + self.ambient_variance + ); + + let r = self.relate(a, b)?; + + self.ambient_variance = old_ambient_variance; + + debug!("TypeGeneralizer::relate_with_variance: r={:?}", r); + + Ok(r) + } + + fn tys(&mut self, a: Ty<'tcx>, _: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { + debug!("TypeGeneralizer::tys(a={:?})", a,); + + match a.sty { + ty::Infer(ty::TyVar(_)) | ty::Infer(ty::IntVar(_)) | ty::Infer(ty::FloatVar(_)) => { + bug!( + "unexpected inference variable encountered in NLL generalization: {:?}", + a + ); + } + + _ => relate::super_relate_tys(self, a, a), + } + } + + fn regions( + &mut self, + a: ty::Region<'tcx>, + _: ty::Region<'tcx>, + ) -> RelateResult<'tcx, ty::Region<'tcx>> { + debug!("TypeGeneralizer::regions(a={:?})", a,); + + if let ty::ReLateBound(debruijn, _) = a { + if *debruijn < self.first_free_index { + return Ok(a); + } + } + + // For now, we just always create a fresh region variable to + // replace all the regions in the source type. In the main + // type checker, we special case the case where the ambient + // variance is `Invariant` and try to avoid creating a fresh + // region variable, but since this comes up so much less in + // NLL (only when users use `_` etc) it is much less + // important. + // + // As an aside, since these new variables are created in + // `self.universe` universe, this also serves to enforce the + // universe scoping rules. + // + // FIXME(#54105) -- if the ambient variance is bivariant, + // though, we may however need to check well-formedness or + // risk a problem like #41677 again. + + let replacement_region_vid = self.delegate.generalize_existential(self.universe); + + Ok(replacement_region_vid) + } + + fn binders( + &mut self, + a: &ty::Binder, + _: &ty::Binder, + ) -> RelateResult<'tcx, ty::Binder> + where + T: Relate<'tcx>, + { + debug!("TypeGeneralizer::binders(a={:?})", a,); + + self.first_free_index.shift_in(1); + let result = self.relate(a.skip_binder(), a.skip_binder())?; + self.first_free_index.shift_out(1); + Ok(ty::Binder::bind(result)) + } +} + +impl InferCtxt<'_, '_, 'tcx> { + /// A hacky sort of method used by the NLL type-relating code: + /// + /// - `var` must be some unbound type variable. + /// - `value` must be a suitable type to use as its value. + /// + /// `var` will then be equated with `value`. Note that this + /// sidesteps a number of important checks, such as the "occurs + /// check" that prevents cyclic types, so it is important not to + /// use this method during regular type-check. + fn force_instantiate_unchecked(&self, var: Ty<'tcx>, value: Ty<'tcx>) { + match (&var.sty, &value.sty) { + (&ty::Infer(ty::TyVar(vid)), _) => { + let mut type_variables = self.type_variables.borrow_mut(); + + // In NLL, we don't have type inference variables + // floating around, so we can do this rather imprecise + // variant of the occurs-check. + assert!(!value.has_infer_types()); + + type_variables.instantiate(vid, value); + } + + (&ty::Infer(ty::IntVar(vid)), &ty::Int(value)) => { + let mut int_unification_table = self.int_unification_table.borrow_mut(); + int_unification_table + .unify_var_value(vid, Some(ty::IntVarValue::IntType(value))) + .unwrap_or_else(|_| { + bug!("failed to unify int var `{:?}` with `{:?}`", vid, value); + }); + } + + (&ty::Infer(ty::IntVar(vid)), &ty::Uint(value)) => { + let mut int_unification_table = self.int_unification_table.borrow_mut(); + int_unification_table + .unify_var_value(vid, Some(ty::IntVarValue::UintType(value))) + .unwrap_or_else(|_| { + bug!("failed to unify int var `{:?}` with `{:?}`", vid, value); + }); + } + + (&ty::Infer(ty::FloatVar(vid)), &ty::Float(value)) => { + let mut float_unification_table = self.float_unification_table.borrow_mut(); + float_unification_table + .unify_var_value(vid, Some(ty::FloatVarValue(value))) + .unwrap_or_else(|_| { + bug!("failed to unify float var `{:?}` with `{:?}`", vid, value) + }); + } + + _ => { + bug!( + "force_instantiate_unchecked invoked with bad combination: var={:?} value={:?}", + var, + value, + ); + } + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/opaque_types/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/opaque_types/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/opaque_types/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/opaque_types/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -98,9 +98,8 @@ /// /// # Parameters /// - /// - `parent_def_id` -- we will only instantiate opaque types - /// with this parent. This is typically the def-id of the function - /// in whose return type opaque types are being instantiated. + /// - `parent_def_id` -- the def-id of the function in which the opaque type + /// is defined /// - `body_id` -- the body-id with which the resulting obligations should /// be associated /// - `param_env` -- the in-scope parameter environment to be used for @@ -113,11 +112,9 @@ param_env: ty::ParamEnv<'tcx>, value: &T, ) -> InferOk<'tcx, (T, OpaqueTypeMap<'tcx>)> { - debug!( - "instantiate_opaque_types(value={:?}, - parent_def_id={:?}, body_id={:?}, - param_env={:?})", - value, parent_def_id, body_id, param_env, + debug!("instantiate_opaque_types(value={:?}, parent_def_id={:?}, body_id={:?}, \ + param_env={:?})", + value, parent_def_id, body_id, param_env, ); let mut instantiator = Instantiator { infcx: self, @@ -284,7 +281,7 @@ } } - fn constrain_opaque_type>( + pub fn constrain_opaque_type>( &self, def_id: DefId, opaque_defn: &OpaqueTypeDecl<'tcx>, @@ -736,7 +733,7 @@ debug!( "instantiate_opaque_types_in_map: \ - encountered opaque outside it's definition scope \ + encountered opaque outside its definition scope \ def_id={:?}", def_id, ); @@ -806,10 +803,11 @@ ); debug!("instantiate_opaque_types: ty_var={:?}", ty_var); + self.obligations.reserve(bounds.predicates.len()); for predicate in bounds.predicates { // Change the predicate to refer to the type variable, - // which will be the concrete type, instead of the Opaque. - // This also instantiates nested `impl Trait`. + // which will be the concrete type instead of the opaque type. + // This also instantiates nested instances of `impl Trait`. let predicate = self.instantiate_opaque_types_in_map(&predicate); let cause = traits::ObligationCause::new(span, self.body_id, traits::SizedReturnType); @@ -844,7 +842,7 @@ /// We will return true if the reference is within the same module as the existential type /// So true for f1, false for f2. pub fn may_define_existential_type( - tcx: TyCtxt, + tcx: TyCtxt<'_, '_, '_>, def_id: DefId, opaque_node_id: ast::NodeId, ) -> bool { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/outlives/env.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/outlives/env.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/outlives/env.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/outlives/env.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,13 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use infer::{GenericKind, InferCtxt}; use infer::outlives::free_region_map::FreeRegionMap; -use traits::query::outlives_bounds::{self, OutlivesBound}; -use ty::{self, Ty}; - +use infer::{GenericKind, InferCtxt}; +use rustc_data_structures::fx::FxHashMap; use syntax::ast; use syntax_pos::Span; +use traits::query::outlives_bounds::{self, OutlivesBound}; +use ty::{self, Ty}; /// The `OutlivesEnvironment` collects information about what outlives /// what in a given type-checking setting. For example, if we have a @@ -39,15 +39,51 @@ pub struct OutlivesEnvironment<'tcx> { param_env: ty::ParamEnv<'tcx>, free_region_map: FreeRegionMap<'tcx>, - region_bound_pairs: Vec<(ty::Region<'tcx>, GenericKind<'tcx>)>, + + // Contains, for each body B that we are checking (that is, the fn + // item, but also any nested closures), the set of implied region + // bounds that are in scope in that particular body. + // + // Example: + // + // ``` + // fn foo<'a, 'b, T>(x: &'a T, y: &'b ()) { + // bar(x, y, |y: &'b T| { .. } // body B1) + // } // body B0 + // ``` + // + // Here, for body B0, the list would be `[T: 'a]`, because we + // infer that `T` must outlive `'a` from the implied bounds on the + // fn declaration. + // + // For the body B1, the list would be `[T: 'a, T: 'b]`, because we + // also can see that -- within the closure body! -- `T` must + // outlive `'b`. This is not necessarily true outside the closure + // body, since the closure may never be called. + // + // We collect this map as we descend the tree. We then use the + // results when proving outlives obligations like `T: 'x` later + // (e.g., if `T: 'x` must be proven within the body B1, then we + // know it is true if either `'a: 'x` or `'b: 'x`). + region_bound_pairs_map: FxHashMap>, + + // Used to compute `region_bound_pairs_map`: contains the set of + // in-scope region-bound pairs thus far. + region_bound_pairs_accum: RegionBoundPairs<'tcx>, } +/// "Region-bound pairs" tracks outlives relations that are known to +/// be true, either because of explicit where clauses like `T: 'a` or +/// because of implied bounds. +pub type RegionBoundPairs<'tcx> = Vec<(ty::Region<'tcx>, GenericKind<'tcx>)>; + impl<'a, 'gcx: 'tcx, 'tcx: 'a> OutlivesEnvironment<'tcx> { pub fn new(param_env: ty::ParamEnv<'tcx>) -> Self { let mut env = OutlivesEnvironment { param_env, - free_region_map: FreeRegionMap::new(), - region_bound_pairs: vec![], + free_region_map: Default::default(), + region_bound_pairs_map: Default::default(), + region_bound_pairs_accum: vec![], }; env.add_outlives_bounds(None, outlives_bounds::explicit_outlives_bounds(param_env)); @@ -61,8 +97,8 @@ } /// Borrows current value of the `region_bound_pairs`. - pub fn region_bound_pairs(&self) -> &[(ty::Region<'tcx>, GenericKind<'tcx>)] { - &self.region_bound_pairs + pub fn region_bound_pairs_map(&self) -> &FxHashMap> { + &self.region_bound_pairs_map } /// Returns ownership of the `free_region_map`. @@ -108,12 +144,12 @@ /// similar leaks around givens that seem equally suspicious, to /// be honest. --nmatsakis pub fn push_snapshot_pre_closure(&self) -> usize { - self.region_bound_pairs.len() + self.region_bound_pairs_accum.len() } /// See `push_snapshot_pre_closure`. pub fn pop_snapshot_post_closure(&mut self, len: usize) { - self.region_bound_pairs.truncate(len); + self.region_bound_pairs_accum.truncate(len); } /// This method adds "implied bounds" into the outlives environment. @@ -149,6 +185,15 @@ } } + /// Save the current set of region-bound pairs under the given `body_id`. + pub fn save_implied_bounds(&mut self, body_id: ast::NodeId) { + let old = self.region_bound_pairs_map.insert( + body_id, + self.region_bound_pairs_accum.clone(), + ); + assert!(old.is_none()); + } + /// Processes outlives bounds that are known to hold, whether from implied or other sources. /// /// The `infcx` parameter is optional; if the implied bounds may @@ -167,16 +212,18 @@ for outlives_bound in outlives_bounds { debug!("add_outlives_bounds: outlives_bound={:?}", outlives_bound); match outlives_bound { - OutlivesBound::RegionSubRegion(r_a @ &ty::ReEarlyBound(_), &ty::ReVar(vid_b)) | - OutlivesBound::RegionSubRegion(r_a @ &ty::ReFree(_), &ty::ReVar(vid_b)) => { - infcx.expect("no infcx provided but region vars found").add_given(r_a, vid_b); + OutlivesBound::RegionSubRegion(r_a @ &ty::ReEarlyBound(_), &ty::ReVar(vid_b)) + | OutlivesBound::RegionSubRegion(r_a @ &ty::ReFree(_), &ty::ReVar(vid_b)) => { + infcx + .expect("no infcx provided but region vars found") + .add_given(r_a, vid_b); } OutlivesBound::RegionSubParam(r_a, param_b) => { - self.region_bound_pairs + self.region_bound_pairs_accum .push((r_a, GenericKind::Param(param_b))); } OutlivesBound::RegionSubProjection(r_a, projection_b) => { - self.region_bound_pairs + self.region_bound_pairs_accum .push((r_a, GenericKind::Projection(projection_b))); } OutlivesBound::RegionSubRegion(r_a, r_b) => { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/outlives/free_region_map.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/outlives/free_region_map.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/outlives/free_region_map.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/outlives/free_region_map.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ use ty::{self, Lift, TyCtxt, Region}; use rustc_data_structures::transitive_relation::TransitiveRelation; -#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Default)] pub struct FreeRegionMap<'tcx> { // Stores the relation `a < b`, where `a` and `b` are regions. // @@ -21,10 +21,6 @@ } impl<'tcx> FreeRegionMap<'tcx> { - pub fn new() -> Self { - FreeRegionMap { relation: TransitiveRelation::new() } - } - pub fn is_empty(&self) -> bool { self.relation.is_empty() } @@ -84,14 +80,14 @@ } } -fn is_free(r: Region) -> bool { +fn is_free(r: Region<'_>) -> bool { match *r { ty::ReEarlyBound(_) | ty::ReFree(_) => true, _ => false } } -fn is_free_or_static(r: Region) -> bool { +fn is_free_or_static(r: Region<'_>) -> bool { match *r { ty::ReStatic => true, _ => is_free(r), diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/outlives/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/outlives/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/outlives/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/outlives/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,3 +13,4 @@ pub mod env; pub mod free_region_map; pub mod obligations; +pub mod verify; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/outlives/obligations.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/outlives/obligations.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/outlives/obligations.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/outlives/obligations.rs 2018-12-04 23:41:40.000000000 +0000 @@ -69,13 +69,14 @@ //! might later infer `?U` to something like `&'b u32`, which would //! imply that `'b: 'a`. -use hir::def_id::DefId; +use infer::outlives::env::RegionBoundPairs; +use infer::outlives::verify::VerifyBoundCx; use infer::{self, GenericKind, InferCtxt, RegionObligation, SubregionOrigin, VerifyBound}; +use rustc_data_structures::fx::FxHashMap; use syntax::ast; -use traits; +use traits::ObligationCause; use ty::outlives::Component; -use ty::subst::{Subst, Substs}; -use ty::{self, Ty, TyCtxt, TypeFoldable}; +use ty::{self, Region, Ty, TyCtxt, TypeFoldable}; impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { /// Registers that the given region obligation must be resolved @@ -98,6 +99,26 @@ .push((body_id, obligation)); } + pub fn register_region_obligation_with_cause( + &self, + sup_type: Ty<'tcx>, + sub_region: Region<'tcx>, + cause: &ObligationCause<'tcx>, + ) { + let origin = SubregionOrigin::from_obligation_cause(cause, || { + infer::RelateParamBound(cause.span, sup_type) + }); + + self.register_region_obligation( + cause.body_id, + RegionObligation { + sup_type, + sub_region, + origin, + }, + ); + } + /// Trait queries just want to pass back type obligations "as is" pub fn take_registered_region_obligations(&self) -> Vec<(ast::NodeId, RegionObligation<'tcx>)> { ::std::mem::replace(&mut *self.region_obligations.borrow_mut(), vec![]) @@ -138,10 +159,9 @@ /// processed. pub fn process_registered_region_obligations( &self, - region_bound_pairs: &[(ty::Region<'tcx>, GenericKind<'tcx>)], + region_bound_pairs_map: &FxHashMap>, implicit_region_bound: Option>, param_env: ty::ParamEnv<'tcx>, - body_id: ast::NodeId, ) { assert!( !self.in_snapshot.get(), @@ -150,41 +170,39 @@ debug!("process_registered_region_obligations()"); - // pull out the region obligations with the given `body_id` (leaving the rest) - let mut my_region_obligations = Vec::with_capacity(self.region_obligations.borrow().len()); - { - let mut r_o = self.region_obligations.borrow_mut(); - my_region_obligations.extend( - r_o.drain_filter(|(ro_body_id, _)| *ro_body_id == body_id) - .map(|(_, obligation)| obligation) - ); - } + let my_region_obligations = self.take_registered_region_obligations(); - let outlives = &mut TypeOutlives::new( - self, - self.tcx, - region_bound_pairs, - implicit_region_bound, - param_env, - ); - - for RegionObligation { - sup_type, - sub_region, - cause, - } in my_region_obligations + for ( + body_id, + RegionObligation { + sup_type, + sub_region, + origin, + }, + ) in my_region_obligations { debug!( - "process_registered_region_obligations: sup_type={:?} sub_region={:?} cause={:?}", - sup_type, sub_region, cause + "process_registered_region_obligations: sup_type={:?} sub_region={:?} origin={:?}", + sup_type, sub_region, origin ); - let origin = SubregionOrigin::from_obligation_cause(&cause, || { - infer::RelateParamBound(cause.span, sup_type) - }); - let sup_type = self.resolve_type_vars_if_possible(&sup_type); - outlives.type_must_outlive(origin, sup_type, sub_region); + + if let Some(region_bound_pairs) = region_bound_pairs_map.get(&body_id) { + let outlives = &mut TypeOutlives::new( + self, + self.tcx, + ®ion_bound_pairs, + implicit_region_bound, + param_env, + ); + outlives.type_must_outlive(origin, sup_type, sub_region); + } else { + self.tcx.sess.delay_span_bug( + origin.span(), + &format!("no region-bound-pairs for {:?}", body_id), + ) + } } } @@ -192,7 +210,7 @@ /// registered in advance. pub fn type_must_outlive( &self, - region_bound_pairs: &[(ty::Region<'tcx>, GenericKind<'tcx>)], + region_bound_pairs: &RegionBoundPairs<'tcx>, implicit_region_bound: Option>, param_env: ty::ParamEnv<'tcx>, origin: infer::SubregionOrigin<'tcx>, @@ -225,9 +243,7 @@ // of these fields. delegate: D, tcx: TyCtxt<'cx, 'gcx, 'tcx>, - region_bound_pairs: &'cx [(ty::Region<'tcx>, GenericKind<'tcx>)], - implicit_region_bound: Option>, - param_env: ty::ParamEnv<'tcx>, + verify_bound: VerifyBoundCx<'cx, 'gcx, 'tcx>, } pub trait TypeOutlivesDelegate<'tcx> { @@ -254,16 +270,19 @@ pub fn new( delegate: D, tcx: TyCtxt<'cx, 'gcx, 'tcx>, - region_bound_pairs: &'cx [(ty::Region<'tcx>, GenericKind<'tcx>)], + region_bound_pairs: &'cx RegionBoundPairs<'tcx>, implicit_region_bound: Option>, param_env: ty::ParamEnv<'tcx>, ) -> Self { Self { delegate, tcx, - region_bound_pairs, - implicit_region_bound, - param_env, + verify_bound: VerifyBoundCx::new( + tcx, + region_bound_pairs, + implicit_region_bound, + param_env, + ), } } @@ -302,7 +321,8 @@ let origin = origin.clone(); match component { Component::Region(region1) => { - self.delegate.push_sub_region_constraint(origin, region, region1); + self.delegate + .push_sub_region_constraint(origin, region, region1); } Component::Param(param_ty) => { self.param_ty_must_outlive(origin, region, param_ty); @@ -337,8 +357,8 @@ region, param_ty, origin ); - let verify_bound = self.param_bound(param_ty); let generic = GenericKind::Param(param_ty); + let verify_bound = self.verify_bound.generic_bound(generic); self.delegate .push_verify(origin, generic, region, verify_bound); } @@ -368,19 +388,38 @@ // rule might not apply (but another rule might). For now, we err // on the side of adding too few edges into the graph. - // Compute the bounds we can derive from the environment or trait - // definition. We know that the projection outlives all the - // regions in this list. - let env_bounds = self.projection_declared_bounds(projection_ty); - - debug!("projection_must_outlive: env_bounds={:?}", env_bounds); - - // If we know that the projection outlives 'static, then we're - // done here. - if env_bounds.contains(&&ty::ReStatic) { - debug!("projection_must_outlive: 'static as declared bound"); - return; - } + // Compute the bounds we can derive from the trait definition. + // These are guaranteed to apply, no matter the inference + // results. + let trait_bounds: Vec<_> = self.verify_bound + .projection_declared_bounds_from_trait(projection_ty) + .collect(); + + // Compute the bounds we can derive from the environment. This + // is an "approximate" match -- in some cases, these bounds + // may not apply. + let mut approx_env_bounds = self.verify_bound + .projection_approx_declared_bounds_from_env(projection_ty); + debug!( + "projection_must_outlive: approx_env_bounds={:?}", + approx_env_bounds + ); + + // Remove outlives bounds that we get from the environment but + // which are also deducable from the trait. This arises (cc + // #55756) in cases where you have e.g. `>::Item: + // 'a` in the environment but `trait Foo<'b> { type Item: 'b + // }` in the trait definition. + approx_env_bounds.retain(|bound| { + match bound.0.sty { + ty::Projection(projection_ty) => { + self.verify_bound.projection_declared_bounds_from_trait(projection_ty) + .all(|r| r != bound.1) + } + + _ => panic!("expected only projection types from env, not {:?}", bound.0), + } + }); // If declared bounds list is empty, the only applicable rule is // OutlivesProjectionComponent. If there are inference variables, @@ -397,7 +436,7 @@ // inference variables, we use a verify constraint instead of adding // edges, which winds up enforcing the same condition. let needs_infer = projection_ty.needs_infer(); - if env_bounds.is_empty() && needs_infer { + if approx_env_bounds.is_empty() && trait_bounds.is_empty() && needs_infer { debug!("projection_must_outlive: no declared bounds"); for component_ty in projection_ty.substs.types() { @@ -405,36 +444,38 @@ } for r in projection_ty.substs.regions() { - self.delegate.push_sub_region_constraint(origin.clone(), region, r); + self.delegate + .push_sub_region_constraint(origin.clone(), region, r); } return; } - // If we find that there is a unique declared bound `'b`, and this bound - // appears in the trait reference, then the best action is to require that `'b:'r`, - // so do that. This is best no matter what rule we use: + // If we found a unique bound `'b` from the trait, and we + // found nothing else from the environment, then the best + // action is to require that `'b: 'r`, so do that. + // + // This is best no matter what rule we use: // - // - OutlivesProjectionEnv or OutlivesProjectionTraitDef: these would translate to - // the requirement that `'b:'r` - // - OutlivesProjectionComponent: this would require `'b:'r` in addition to - // other conditions - if !env_bounds.is_empty() && env_bounds[1..].iter().all(|b| *b == env_bounds[0]) { - let unique_bound = env_bounds[0]; + // - OutlivesProjectionEnv: these would translate to the requirement that `'b:'r` + // - OutlivesProjectionTraitDef: these would translate to the requirement that `'b:'r` + // - OutlivesProjectionComponent: this would require `'b:'r` + // in addition to other conditions + if !trait_bounds.is_empty() + && trait_bounds[1..] + .iter() + .chain(approx_env_bounds.iter().map(|b| &b.1)) + .all(|b| *b == trait_bounds[0]) + { + let unique_bound = trait_bounds[0]; debug!( - "projection_must_outlive: unique declared bound = {:?}", + "projection_must_outlive: unique trait bound = {:?}", unique_bound ); - if projection_ty - .substs - .regions() - .any(|r| env_bounds.contains(&r)) - { - debug!("projection_must_outlive: unique declared bound appears in trait ref"); - self.delegate - .push_sub_region_constraint(origin.clone(), region, unique_bound); - return; - } + debug!("projection_must_outlive: unique declared bound appears in trait ref"); + self.delegate + .push_sub_region_constraint(origin, region, unique_bound); + return; } // Fallback to verifying after the fact that there exists a @@ -442,216 +483,11 @@ // projection outlive; in some cases, this may add insufficient // edges into the inference graph, leading to inference failures // even though a satisfactory solution exists. - let verify_bound = self.projection_bound(env_bounds, projection_ty); let generic = GenericKind::Projection(projection_ty); + let verify_bound = self.verify_bound.generic_bound(generic); self.delegate .push_verify(origin, generic.clone(), region, verify_bound); } - - fn type_bound(&self, ty: Ty<'tcx>) -> VerifyBound<'tcx> { - match ty.sty { - ty::Param(p) => self.param_bound(p), - ty::Projection(data) => { - let declared_bounds = self.projection_declared_bounds(data); - self.projection_bound(declared_bounds, data) - } - _ => self.recursive_type_bound(ty), - } - } - - fn param_bound(&self, param_ty: ty::ParamTy) -> VerifyBound<'tcx> { - debug!("param_bound(param_ty={:?})", param_ty); - - let mut param_bounds = self.declared_generic_bounds_from_env(GenericKind::Param(param_ty)); - - // Add in the default bound of fn body that applies to all in - // scope type parameters: - param_bounds.extend(self.implicit_region_bound); - - VerifyBound::AnyRegion(param_bounds) - } - - fn projection_declared_bounds( - &self, - projection_ty: ty::ProjectionTy<'tcx>, - ) -> Vec> { - // First assemble bounds from where clauses and traits. - - let mut declared_bounds = - self.declared_generic_bounds_from_env(GenericKind::Projection(projection_ty)); - - declared_bounds - .extend_from_slice(&self.declared_projection_bounds_from_trait(projection_ty)); - - declared_bounds - } - - fn projection_bound( - &self, - declared_bounds: Vec>, - projection_ty: ty::ProjectionTy<'tcx>, - ) -> VerifyBound<'tcx> { - debug!( - "projection_bound(declared_bounds={:?}, projection_ty={:?})", - declared_bounds, projection_ty - ); - - // see the extensive comment in projection_must_outlive - let ty = self - .tcx - .mk_projection(projection_ty.item_def_id, projection_ty.substs); - let recursive_bound = self.recursive_type_bound(ty); - - VerifyBound::AnyRegion(declared_bounds).or(recursive_bound) - } - - fn recursive_type_bound(&self, ty: Ty<'tcx>) -> VerifyBound<'tcx> { - let mut bounds = ty.walk_shallow().map(|subty| self.type_bound(subty)).collect::>(); - - let mut regions = ty.regions(); - regions.retain(|r| !r.is_late_bound()); // ignore late-bound regions - bounds.push(VerifyBound::AllRegions(regions)); - - // remove bounds that must hold, since they are not interesting - bounds.retain(|b| !b.must_hold()); - - if bounds.len() == 1 { - bounds.pop().unwrap() - } else { - VerifyBound::AllBounds(bounds) - } - } - - fn declared_generic_bounds_from_env( - &self, - generic: GenericKind<'tcx>, - ) -> Vec> { - let tcx = self.tcx; - - // To start, collect bounds from user environment. Note that - // parameter environments are already elaborated, so we don't - // have to worry about that. Comparing using `==` is a bit - // dubious for projections, but it will work for simple cases - // like `T` and `T::Item`. It may not work as well for things - // like `>::Item`. - let generic_ty = generic.to_ty(tcx); - let c_b = self.param_env.caller_bounds; - let mut param_bounds = self.collect_outlives_from_predicate_list(generic_ty, c_b); - - // Next, collect regions we scraped from the well-formedness - // constraints in the fn signature. To do that, we walk the list - // of known relations from the fn ctxt. - // - // This is crucial because otherwise code like this fails: - // - // fn foo<'a, A>(x: &'a A) { x.bar() } - // - // The problem is that the type of `x` is `&'a A`. To be - // well-formed, then, A must be lower-generic by `'a`, but we - // don't know that this holds from first principles. - for &(r, p) in self.region_bound_pairs { - debug!("generic={:?} p={:?}", generic, p); - if generic == p { - param_bounds.push(r); - } - } - - param_bounds - } - - /// Given a projection like `>::Bar`, returns any bounds - /// declared in the trait definition. For example, if the trait were - /// - /// ```rust - /// trait Foo<'a> { - /// type Bar: 'a; - /// } - /// ``` - /// - /// then this function would return `'x`. This is subject to the - /// limitations around higher-ranked bounds described in - /// `region_bounds_declared_on_associated_item`. - fn declared_projection_bounds_from_trait( - &self, - projection_ty: ty::ProjectionTy<'tcx>, - ) -> Vec> { - debug!("projection_bounds(projection_ty={:?})", projection_ty); - let mut bounds = self.region_bounds_declared_on_associated_item(projection_ty.item_def_id); - for r in &mut bounds { - *r = r.subst(self.tcx, projection_ty.substs); - } - bounds - } - - /// Given the def-id of an associated item, returns any region - /// bounds attached to that associated item from the trait definition. - /// - /// For example: - /// - /// ```rust - /// trait Foo<'a> { - /// type Bar: 'a; - /// } - /// ``` - /// - /// If we were given the def-id of `Foo::Bar`, we would return - /// `'a`. You could then apply the substitutions from the - /// projection to convert this into your namespace. This also - /// works if the user writes `where >::Bar: 'a` on - /// the trait. In fact, it works by searching for just such a - /// where-clause. - /// - /// It will not, however, work for higher-ranked bounds like: - /// - /// ```rust - /// trait Foo<'a, 'b> - /// where for<'x> >::Bar: 'x - /// { - /// type Bar; - /// } - /// ``` - /// - /// This is for simplicity, and because we are not really smart - /// enough to cope with such bounds anywhere. - fn region_bounds_declared_on_associated_item( - &self, - assoc_item_def_id: DefId, - ) -> Vec> { - let tcx = self.tcx; - let assoc_item = tcx.associated_item(assoc_item_def_id); - let trait_def_id = assoc_item.container.assert_trait(); - let trait_predicates = tcx.predicates_of(trait_def_id); - let identity_substs = Substs::identity_for_item(tcx, assoc_item_def_id); - let identity_proj = tcx.mk_projection(assoc_item_def_id, identity_substs); - self.collect_outlives_from_predicate_list( - identity_proj, - traits::elaborate_predicates(tcx, trait_predicates.predicates), - ) - } - - /// Searches through a predicate list for a predicate `T: 'a`. - /// - /// Careful: does not elaborate predicates, and just uses `==` - /// when comparing `ty` for equality, so `ty` must be something - /// that does not involve inference variables and where you - /// otherwise want a precise match. - fn collect_outlives_from_predicate_list( - &self, - ty: Ty<'tcx>, - predicates: I, - ) -> Vec> - where - I: IntoIterator, - P: AsRef>, - { - predicates - .into_iter() - .filter_map(|p| p.as_ref().to_opt_type_outlives()) - .filter_map(|p| p.no_late_bound_regions()) - .filter(|p| p.0 == ty) - .map(|p| p.1) - .collect() - } } impl<'cx, 'gcx, 'tcx> TypeOutlivesDelegate<'tcx> for &'cx InferCtxt<'cx, 'gcx, 'tcx> { @@ -674,4 +510,3 @@ self.verify_generic_bound(origin, kind, a, bound) } } - diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/outlives/verify.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/outlives/verify.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/outlives/verify.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/outlives/verify.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,329 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use hir::def_id::DefId; +use infer::outlives::env::RegionBoundPairs; +use infer::{GenericKind, VerifyBound}; +use traits; +use ty::subst::{Subst, Substs}; +use ty::{self, Ty, TyCtxt}; +use util::captures::Captures; + +/// The `TypeOutlives` struct has the job of "lowering" a `T: 'a` +/// obligation into a series of `'a: 'b` constraints and "verifys", as +/// described on the module comment. The final constraints are emitted +/// via a "delegate" of type `D` -- this is usually the `infcx`, which +/// accrues them into the `region_obligations` code, but for NLL we +/// use something else. +pub struct VerifyBoundCx<'cx, 'gcx: 'tcx, 'tcx: 'cx> { + tcx: TyCtxt<'cx, 'gcx, 'tcx>, + region_bound_pairs: &'cx RegionBoundPairs<'tcx>, + implicit_region_bound: Option>, + param_env: ty::ParamEnv<'tcx>, +} + +impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> { + pub fn new( + tcx: TyCtxt<'cx, 'gcx, 'tcx>, + region_bound_pairs: &'cx RegionBoundPairs<'tcx>, + implicit_region_bound: Option>, + param_env: ty::ParamEnv<'tcx>, + ) -> Self { + Self { + tcx, + region_bound_pairs, + implicit_region_bound, + param_env, + } + } + + /// Returns a "verify bound" that encodes what we know about + /// `generic` and the regions it outlives. + pub fn generic_bound(&self, generic: GenericKind<'tcx>) -> VerifyBound<'tcx> { + match generic { + GenericKind::Param(param_ty) => self.param_bound(param_ty), + GenericKind::Projection(projection_ty) => self.projection_bound(projection_ty), + } + } + + fn type_bound(&self, ty: Ty<'tcx>) -> VerifyBound<'tcx> { + match ty.sty { + ty::Param(p) => self.param_bound(p), + ty::Projection(data) => self.projection_bound(data), + _ => self.recursive_type_bound(ty), + } + } + + fn param_bound(&self, param_ty: ty::ParamTy) -> VerifyBound<'tcx> { + debug!("param_bound(param_ty={:?})", param_ty); + + // Start with anything like `T: 'a` we can scrape from the + // environment + let param_bounds = self.declared_generic_bounds_from_env(GenericKind::Param(param_ty)) + .into_iter() + .map(|outlives| outlives.1); + + // Add in the default bound of fn body that applies to all in + // scope type parameters: + let param_bounds = param_bounds.chain(self.implicit_region_bound); + + VerifyBound::AnyBound(param_bounds.map(|r| VerifyBound::OutlivedBy(r)).collect()) + } + + /// Given a projection like `T::Item`, searches the environment + /// for where-clauses like `T::Item: 'a`. Returns the set of + /// regions `'a` that it finds. + /// + /// This is an "approximate" check -- it may not find all + /// applicable bounds, and not all the bounds it returns can be + /// relied upon. In particular, this check ignores region + /// identity. So, for example, if we have `>::Item` where `'0` is a region variable, and the + /// user has `>::Item: 'b` in the environment, then + /// the clause from the environment only applies if `'0 = 'a`, + /// which we don't know yet. But we would still include `'b` in + /// this list. + pub fn projection_approx_declared_bounds_from_env( + &self, + projection_ty: ty::ProjectionTy<'tcx>, + ) -> Vec, ty::Region<'tcx>>> { + let projection_ty = GenericKind::Projection(projection_ty).to_ty(self.tcx); + let erased_projection_ty = self.tcx.erase_regions(&projection_ty); + self.declared_generic_bounds_from_env_with_compare_fn(|ty| { + if let ty::Projection(..) = ty.sty { + let erased_ty = self.tcx.erase_regions(&ty); + erased_ty == erased_projection_ty + } else { + false + } + }) + } + + /// Searches the where clauses in scope for regions that + /// `projection_ty` is known to outlive. Currently requires an + /// exact match. + pub fn projection_declared_bounds_from_trait( + &self, + projection_ty: ty::ProjectionTy<'tcx>, + ) -> impl Iterator> + 'cx + Captures<'gcx> { + self.declared_projection_bounds_from_trait(projection_ty) + } + + pub fn projection_bound(&self, projection_ty: ty::ProjectionTy<'tcx>) -> VerifyBound<'tcx> { + debug!("projection_bound(projection_ty={:?})", projection_ty); + + let projection_ty_as_ty = + self.tcx.mk_projection(projection_ty.item_def_id, projection_ty.substs); + + // Search the env for where clauses like `P: 'a`. + let env_bounds = self.projection_approx_declared_bounds_from_env(projection_ty) + .into_iter() + .map(|ty::OutlivesPredicate(ty, r)| { + let vb = VerifyBound::OutlivedBy(r); + if ty == projection_ty_as_ty { + // Micro-optimize if this is an exact match (this + // occurs often when there are no region variables + // involved). + vb + } else { + VerifyBound::IfEq(ty, Box::new(vb)) + } + }); + + // Extend with bounds that we can find from the trait. + let trait_bounds = self.projection_declared_bounds_from_trait(projection_ty) + .into_iter() + .map(|r| VerifyBound::OutlivedBy(r)); + + // see the extensive comment in projection_must_outlive + let ty = self.tcx + .mk_projection(projection_ty.item_def_id, projection_ty.substs); + let recursive_bound = self.recursive_type_bound(ty); + + VerifyBound::AnyBound(env_bounds.chain(trait_bounds).collect()).or(recursive_bound) + } + + fn recursive_type_bound(&self, ty: Ty<'tcx>) -> VerifyBound<'tcx> { + let mut bounds = ty.walk_shallow() + .map(|subty| self.type_bound(subty)) + .collect::>(); + + let mut regions = ty.regions(); + regions.retain(|r| !r.is_late_bound()); // ignore late-bound regions + bounds.push(VerifyBound::AllBounds( + regions + .into_iter() + .map(|r| VerifyBound::OutlivedBy(r)) + .collect(), + )); + + // remove bounds that must hold, since they are not interesting + bounds.retain(|b| !b.must_hold()); + + if bounds.len() == 1 { + bounds.pop().unwrap() + } else { + VerifyBound::AllBounds(bounds) + } + } + + /// Searches the environment for where-clauses like `G: 'a` where + /// `G` is either some type parameter `T` or a projection like + /// `T::Item`. Returns a vector of the `'a` bounds it can find. + /// + /// This is a conservative check -- it may not find all applicable + /// bounds, but all the bounds it returns can be relied upon. + fn declared_generic_bounds_from_env( + &self, + generic: GenericKind<'tcx>, + ) -> Vec, ty::Region<'tcx>>> { + let generic_ty = generic.to_ty(self.tcx); + self.declared_generic_bounds_from_env_with_compare_fn(|ty| ty == generic_ty) + } + + fn declared_generic_bounds_from_env_with_compare_fn( + &self, + compare_ty: impl Fn(Ty<'tcx>) -> bool, + ) -> Vec, ty::Region<'tcx>>> { + let tcx = self.tcx; + + // To start, collect bounds from user environment. Note that + // parameter environments are already elaborated, so we don't + // have to worry about that. Comparing using `==` is a bit + // dubious for projections, but it will work for simple cases + // like `T` and `T::Item`. It may not work as well for things + // like `>::Item`. + let c_b = self.param_env.caller_bounds; + let param_bounds = self.collect_outlives_from_predicate_list(&compare_ty, c_b); + + // Next, collect regions we scraped from the well-formedness + // constraints in the fn signature. To do that, we walk the list + // of known relations from the fn ctxt. + // + // This is crucial because otherwise code like this fails: + // + // fn foo<'a, A>(x: &'a A) { x.bar() } + // + // The problem is that the type of `x` is `&'a A`. To be + // well-formed, then, A must be lower-generic by `'a`, but we + // don't know that this holds from first principles. + let from_region_bound_pairs = self.region_bound_pairs.iter().filter_map(|&(r, p)| { + debug!( + "declared_generic_bounds_from_env_with_compare_fn: region_bound_pair = {:?}", + (r, p) + ); + let p_ty = p.to_ty(tcx); + if compare_ty(p_ty) { + Some(ty::OutlivesPredicate(p_ty, r)) + } else { + None + } + }); + + param_bounds + .chain(from_region_bound_pairs) + .inspect(|bound| { + debug!( + "declared_generic_bounds_from_env_with_compare_fn: result predicate = {:?}", + bound + ) + }) + .collect() + } + + /// Given a projection like `>::Bar`, returns any bounds + /// declared in the trait definition. For example, if the trait were + /// + /// ```rust + /// trait Foo<'a> { + /// type Bar: 'a; + /// } + /// ``` + /// + /// then this function would return `'x`. This is subject to the + /// limitations around higher-ranked bounds described in + /// `region_bounds_declared_on_associated_item`. + fn declared_projection_bounds_from_trait( + &self, + projection_ty: ty::ProjectionTy<'tcx>, + ) -> impl Iterator> + 'cx + Captures<'gcx> { + debug!("projection_bounds(projection_ty={:?})", projection_ty); + let tcx = self.tcx; + self.region_bounds_declared_on_associated_item(projection_ty.item_def_id) + .map(move |r| r.subst(tcx, projection_ty.substs)) + } + + /// Given the def-id of an associated item, returns any region + /// bounds attached to that associated item from the trait definition. + /// + /// For example: + /// + /// ```rust + /// trait Foo<'a> { + /// type Bar: 'a; + /// } + /// ``` + /// + /// If we were given the def-id of `Foo::Bar`, we would return + /// `'a`. You could then apply the substitutions from the + /// projection to convert this into your namespace. This also + /// works if the user writes `where >::Bar: 'a` on + /// the trait. In fact, it works by searching for just such a + /// where-clause. + /// + /// It will not, however, work for higher-ranked bounds like: + /// + /// ```rust + /// trait Foo<'a, 'b> + /// where for<'x> >::Bar: 'x + /// { + /// type Bar; + /// } + /// ``` + /// + /// This is for simplicity, and because we are not really smart + /// enough to cope with such bounds anywhere. + fn region_bounds_declared_on_associated_item( + &self, + assoc_item_def_id: DefId, + ) -> impl Iterator> + 'cx + Captures<'gcx> { + let tcx = self.tcx; + let assoc_item = tcx.associated_item(assoc_item_def_id); + let trait_def_id = assoc_item.container.assert_trait(); + let trait_predicates = tcx.predicates_of(trait_def_id).predicates + .into_iter() + .map(|(p, _)| p) + .collect(); + let identity_substs = Substs::identity_for_item(tcx, assoc_item_def_id); + let identity_proj = tcx.mk_projection(assoc_item_def_id, identity_substs); + self.collect_outlives_from_predicate_list( + move |ty| ty == identity_proj, + traits::elaborate_predicates(tcx, trait_predicates), + ).map(|b| b.1) + } + + /// Searches through a predicate list for a predicate `T: 'a`. + /// + /// Careful: does not elaborate predicates, and just uses `==` + /// when comparing `ty` for equality, so `ty` must be something + /// that does not involve inference variables and where you + /// otherwise want a precise match. + fn collect_outlives_from_predicate_list( + &self, + compare_ty: impl Fn(Ty<'tcx>) -> bool, + predicates: impl IntoIterator>>, + ) -> impl Iterator, ty::Region<'tcx>>> { + predicates + .into_iter() + .filter_map(|p| p.as_ref().to_opt_type_outlives()) + .filter_map(|p| p.no_late_bound_regions()) + .filter(move |p| compare_ty(p.0)) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/region_constraints/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/region_constraints/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/region_constraints/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/region_constraints/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,19 +10,19 @@ //! See README.md -use self::UndoLogEntry::*; use self::CombineMapType::*; +use self::UndoLogEntry::*; -use super::{MiscVariable, RegionVariableOrigin, SubregionOrigin}; use super::unify_key; +use super::{MiscVariable, RegionVariableOrigin, SubregionOrigin}; -use rustc_data_structures::indexed_vec::IndexVec; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_data_structures::indexed_vec::IndexVec; use rustc_data_structures::unify as ut; -use ty::{self, Ty, TyCtxt}; -use ty::{Region, RegionVid}; use ty::ReStatic; +use ty::{self, Ty, TyCtxt}; use ty::{BrFresh, ReLateBound, ReVar}; +use ty::{Region, RegionVid}; use std::collections::BTreeMap; use std::{cmp, fmt, mem, u32}; @@ -149,35 +149,100 @@ pub bound: VerifyBound<'tcx>, } -#[derive(Copy, Clone, PartialEq, Eq)] +#[derive(Copy, Clone, PartialEq, Eq, Hash)] pub enum GenericKind<'tcx> { Param(ty::ParamTy), Projection(ty::ProjectionTy<'tcx>), } -/// When we introduce a verification step, we wish to test that a -/// particular region (let's call it `'min`) meets some bound. -/// The bound is described the by the following grammar: +EnumTypeFoldableImpl! { + impl<'tcx> TypeFoldable<'tcx> for GenericKind<'tcx> { + (GenericKind::Param)(a), + (GenericKind::Projection)(a), + } +} + +/// Describes the things that some `GenericKind` value G is known to +/// outlive. Each variant of `VerifyBound` can be thought of as a +/// function: +/// +/// fn(min: Region) -> bool { .. } +/// +/// where `true` means that the region `min` meets that `G: min`. +/// (False means nothing.) +/// +/// So, for example, if we have the type `T` and we have in scope that +/// `T: 'a` and `T: 'b`, then the verify bound might be: +/// +/// fn(min: Region) -> bool { +/// ('a: min) || ('b: min) +/// } +/// +/// This is described with a `AnyRegion('a, 'b)` node. #[derive(Debug, Clone)] pub enum VerifyBound<'tcx> { - /// B = exists {R} --> some 'r in {R} must outlive 'min + /// Given a kind K and a bound B, expands to a function like the + /// following, where `G` is the generic for which this verify + /// bound was created: + /// + /// fn(min) -> bool { + /// if G == K { + /// B(min) + /// } else { + /// false + /// } + /// } + /// + /// In other words, if the generic `G` that we are checking is + /// equal to `K`, then check the associated verify bound + /// (otherwise, false). + /// + /// This is used when we have something in the environment that + /// may or may not be relevant, depending on the region inference + /// results. For example, we may have `where >::Item: 'b` in our where clauses. If we are + /// generating the verify-bound for `>::Item`, then + /// this where-clause is only relevant if `'0` winds up inferred + /// to `'a`. + /// + /// So we would compile to a verify-bound like + /// + /// IfEq(>::Item, AnyRegion('a)) /// - /// Put another way, the subject value is known to outlive all - /// regions in {R}, so if any of those outlives 'min, then the - /// bound is met. - AnyRegion(Vec>), + /// meaning, if the subject G is equal to `>::Item` + /// (after inference), and `'a: min`, then `G: min`. + IfEq(Ty<'tcx>, Box>), - /// B = forall {R} --> all 'r in {R} must outlive 'min + /// Given a region `R`, expands to the function: /// - /// Put another way, the subject value is known to outlive some - /// region in {R}, so if all of those outlives 'min, then the bound - /// is met. - AllRegions(Vec>), + /// fn(min) -> bool { + /// R: min + /// } + /// + /// This is used when we can establish that `G: R` -- therefore, + /// if `R: min`, then by transitivity `G: min`. + OutlivedBy(Region<'tcx>), - /// B = exists {B} --> 'min must meet some bound b in {B} + /// Given a set of bounds `B`, expands to the function: + /// + /// fn(min) -> bool { + /// exists (b in B) { b(min) } + /// } + /// + /// In other words, if we meet some bound in `B`, that suffices. + /// This is used when all the bounds in `B` are known to apply to + /// G. AnyBound(Vec>), - /// B = forall {B} --> 'min must meet all bounds b in {B} + /// Given a set of bounds `B`, expands to the function: + /// + /// fn(min) -> bool { + /// forall (b in B) { b(min) } + /// } + /// + /// In other words, if we meet *all* bounds in `B`, that suffices. + /// This is used when *some* bound in `B` is known to suffice, but + /// we don't know which. AllBounds(Vec>), } @@ -241,10 +306,10 @@ any_unifications: bool, } -/// When working with skolemized regions, we often wish to find all of -/// the regions that are either reachable from a skolemized region, or -/// which can reach a skolemized region, or both. We call such regions -/// *tained* regions. This struct allows you to decide what set of +/// When working with placeholder regions, we often wish to find all of +/// the regions that are either reachable from a placeholder region, or +/// which can reach a placeholder region, or both. We call such regions +/// *tainted* regions. This struct allows you to decide what set of /// tainted regions you want. #[derive(Debug)] pub struct TaintDirections { @@ -280,8 +345,8 @@ RegionConstraintCollector { var_infos: VarInfos::default(), data: RegionConstraintData::default(), - lubs: FxHashMap(), - glbs: FxHashMap(), + lubs: Default::default(), + glbs: Default::default(), bound_count: 0, undo_log: Vec::new(), unification_table: ut::UnificationTable::new(), @@ -378,7 +443,7 @@ assert!(self.undo_log[snapshot.length] == OpenSnapshot); if snapshot.length == 0 { - self.undo_log.truncate(0); + self.undo_log.clear(); } else { (*self.undo_log)[snapshot.length] = CommitedSnapshot; } @@ -430,13 +495,12 @@ } } - pub fn new_region_var(&mut self, - universe: ty::UniverseIndex, - origin: RegionVariableOrigin) -> RegionVid { - let vid = self.var_infos.push(RegionVariableInfo { - origin, - universe, - }); + pub fn new_region_var( + &mut self, + universe: ty::UniverseIndex, + origin: RegionVariableOrigin, + ) -> RegionVid { + let vid = self.var_infos.push(RegionVariableInfo { origin, universe }); let u_vid = self.unification_table .new_key(unify_key::RegionVidKey { min_vid: vid }); @@ -446,8 +510,7 @@ } debug!( "created new region variable {:?} with origin {:?}", - vid, - origin + vid, origin ); return vid; } @@ -462,51 +525,25 @@ self.var_infos[vid].origin } - /// Removes all the edges to/from the skolemized regions that are + /// Removes all the edges to/from the placeholder regions that are /// in `skols`. This is used after a higher-ranked operation - /// completes to remove all trace of the skolemized regions + /// completes to remove all trace of the placeholder regions /// created in that time. - pub fn pop_skolemized( + pub fn pop_placeholders( &mut self, - skolemization_count: ty::UniverseIndex, - skols: &FxHashSet>, + placeholders: &FxHashSet>, snapshot: &RegionSnapshot, ) { - debug!("pop_skolemized_regions(skols={:?})", skols); + debug!("pop_placeholders(placeholders={:?})", placeholders); assert!(self.in_snapshot()); assert!(self.undo_log[snapshot.length] == OpenSnapshot); - assert!( - skolemization_count.as_usize() >= skols.len(), - "popping more skolemized variables than actually exist, \ - sc now = {:?}, skols.len = {:?}", - skolemization_count, - skols.len() - ); - - let last_to_pop = skolemization_count.subuniverse(); - let first_to_pop = ty::UniverseIndex::from(last_to_pop.as_u32() - skols.len() as u32); - - debug_assert! { - skols.iter() - .all(|&k| match *k { - ty::ReSkolemized(universe, _) => - universe >= first_to_pop && - universe < last_to_pop, - _ => - false - }), - "invalid skolemization keys or keys out of range ({:?}..{:?}): {:?}", - first_to_pop, - last_to_pop, - skols - } let constraints_to_kill: Vec = self.undo_log .iter() .enumerate() .rev() - .filter(|&(_, undo_entry)| kill_constraint(skols, undo_entry)) + .filter(|&(_, undo_entry)| kill_constraint(placeholders, undo_entry)) .map(|(index, _)| index) .collect(); @@ -518,20 +555,20 @@ return; fn kill_constraint<'tcx>( - skols: &FxHashSet>, + placeholders: &FxHashSet>, undo_entry: &UndoLogEntry<'tcx>, ) -> bool { match undo_entry { &AddConstraint(Constraint::VarSubVar(..)) => false, - &AddConstraint(Constraint::RegSubVar(a, _)) => skols.contains(&a), - &AddConstraint(Constraint::VarSubReg(_, b)) => skols.contains(&b), + &AddConstraint(Constraint::RegSubVar(a, _)) => placeholders.contains(&a), + &AddConstraint(Constraint::VarSubReg(_, b)) => placeholders.contains(&b), &AddConstraint(Constraint::RegSubReg(a, b)) => { - skols.contains(&a) || skols.contains(&b) + placeholders.contains(&a) || placeholders.contains(&b) } &AddGiven(..) => false, &AddVerify(_) => false, &AddCombination(_, ref two_regions) => { - skols.contains(&two_regions.a) || skols.contains(&two_regions.b) + placeholders.contains(&two_regions.a) || placeholders.contains(&two_regions.b) } &AddVar(..) | &OpenSnapshot | &Purged | &CommitedSnapshot => false, } @@ -596,11 +633,10 @@ debug!("RegionConstraintCollector: add_verify({:?})", verify); // skip no-op cases known to be satisfied - match verify.bound { - VerifyBound::AllBounds(ref bs) if bs.len() == 0 => { + if let VerifyBound::AllBounds(ref bs) = verify.bound { + if bs.len() == 0 { return; } - _ => {} } let index = self.data.verifys.len(); @@ -649,9 +685,7 @@ // cannot add constraints once regions are resolved debug!( "RegionConstraintCollector: make_subregion({:?}, {:?}) due to {:?}", - sub, - sup, - origin + sub, sup, origin ); match (sub, sup) { @@ -715,7 +749,7 @@ a // LUB(a,a) = a } - _ => self.combine_vars(tcx, Lub, a, b, origin.clone()), + _ => self.combine_vars(tcx, Lub, a, b, origin), } } @@ -737,7 +771,7 @@ a // GLB(a,a) = a } - _ => self.combine_vars(tcx, Glb, a, b, origin.clone()), + _ => self.combine_vars(tcx, Glb, a, b, origin), } } @@ -790,19 +824,19 @@ fn universe(&self, region: Region<'tcx>) -> ty::UniverseIndex { match *region { - ty::ReScope(..) | - ty::ReStatic | - ty::ReEmpty | - ty::ReErased | - ty::ReFree(..) | - ty::ReEarlyBound(..) => ty::UniverseIndex::ROOT, - ty::ReSkolemized(universe, _) => universe, - ty::ReClosureBound(vid) | - ty::ReVar(vid) => self.var_universe(vid), - ty::ReLateBound(..) => - bug!("universe(): encountered bound region {:?}", region), - ty::ReCanonical(..) => - bug!("region_universe(): encountered canonical region {:?}", region), + ty::ReScope(..) + | ty::ReStatic + | ty::ReEmpty + | ty::ReErased + | ty::ReFree(..) + | ty::ReEarlyBound(..) => ty::UniverseIndex::ROOT, + ty::RePlaceholder(placeholder) => placeholder.universe, + ty::ReClosureBound(vid) | ty::ReVar(vid) => self.var_universe(vid), + ty::ReLateBound(..) => bug!("universe(): encountered bound region {:?}", region), + ty::ReCanonical(..) => bug!( + "region_universe(): encountered canonical region {:?}", + region + ), } } @@ -822,7 +856,7 @@ /// relations are considered. For example, one can say that only /// "incoming" edges to `r0` are desired, in which case one will /// get the set of regions `{r|r <= r0}`. This is used when - /// checking whether skolemized regions are being improperly + /// checking whether placeholder regions are being improperly /// related to other regions. pub fn tainted( &self, @@ -833,9 +867,7 @@ ) -> FxHashSet> { debug!( "tainted(mark={:?}, r0={:?}, directions={:?})", - mark, - r0, - directions + mark, r0, directions ); // `result_set` acts as a worklist: we explore all outgoing @@ -849,13 +881,13 @@ } impl fmt::Debug for RegionSnapshot { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "RegionSnapshot(length={})", self.length) } } impl<'tcx> fmt::Debug for GenericKind<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { GenericKind::Param(ref p) => write!(f, "{:?}", p), GenericKind::Projection(ref p) => write!(f, "{:?}", p), @@ -864,7 +896,7 @@ } impl<'tcx> fmt::Display for GenericKind<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { GenericKind::Param(ref p) => write!(f, "{}", p), GenericKind::Projection(ref p) => write!(f, "{}", p), @@ -882,33 +914,23 @@ } impl<'a, 'gcx, 'tcx> VerifyBound<'tcx> { - fn for_each_region(&self, f: &mut dyn FnMut(ty::Region<'tcx>)) { - match self { - &VerifyBound::AnyRegion(ref rs) | &VerifyBound::AllRegions(ref rs) => for &r in rs { - f(r); - }, - - &VerifyBound::AnyBound(ref bs) | &VerifyBound::AllBounds(ref bs) => for b in bs { - b.for_each_region(f); - }, - } - } - pub fn must_hold(&self) -> bool { match self { - &VerifyBound::AnyRegion(ref bs) => bs.contains(&&ty::ReStatic), - &VerifyBound::AllRegions(ref bs) => bs.is_empty(), - &VerifyBound::AnyBound(ref bs) => bs.iter().any(|b| b.must_hold()), - &VerifyBound::AllBounds(ref bs) => bs.iter().all(|b| b.must_hold()), + VerifyBound::IfEq(..) => false, + VerifyBound::OutlivedBy(ty::ReStatic) => true, + VerifyBound::OutlivedBy(_) => false, + VerifyBound::AnyBound(bs) => bs.iter().any(|b| b.must_hold()), + VerifyBound::AllBounds(bs) => bs.iter().all(|b| b.must_hold()), } } pub fn cannot_hold(&self) -> bool { match self { - &VerifyBound::AnyRegion(ref bs) => bs.is_empty(), - &VerifyBound::AllRegions(ref bs) => bs.contains(&&ty::ReEmpty), - &VerifyBound::AnyBound(ref bs) => bs.iter().all(|b| b.cannot_hold()), - &VerifyBound::AllBounds(ref bs) => bs.iter().any(|b| b.cannot_hold()), + VerifyBound::IfEq(_, b) => b.cannot_hold(), + VerifyBound::OutlivedBy(ty::ReEmpty) => true, + VerifyBound::OutlivedBy(_) => false, + VerifyBound::AnyBound(bs) => bs.iter().all(|b| b.cannot_hold()), + VerifyBound::AllBounds(bs) => bs.iter().any(|b| b.cannot_hold()), } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/region_constraints/taint.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/region_constraints/taint.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/region_constraints/taint.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/region_constraints/taint.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,34 +13,39 @@ #[derive(Debug)] pub(super) struct TaintSet<'tcx> { directions: TaintDirections, - regions: FxHashSet> + regions: FxHashSet>, } impl<'tcx> TaintSet<'tcx> { - pub(super) fn new(directions: TaintDirections, - initial_region: ty::Region<'tcx>) - -> Self { - let mut regions = FxHashSet(); + pub(super) fn new(directions: TaintDirections, initial_region: ty::Region<'tcx>) -> Self { + let mut regions = FxHashSet::default(); regions.insert(initial_region); - TaintSet { directions: directions, regions: regions } + TaintSet { + directions: directions, + regions: regions, + } } - pub(super) fn fixed_point(&mut self, - tcx: TyCtxt<'_, '_, 'tcx>, - undo_log: &[UndoLogEntry<'tcx>], - verifys: &[Verify<'tcx>]) { + pub(super) fn fixed_point( + &mut self, + tcx: TyCtxt<'_, '_, 'tcx>, + undo_log: &[UndoLogEntry<'tcx>], + verifys: &[Verify<'tcx>], + ) { let mut prev_len = 0; while prev_len < self.len() { - debug!("tainted: prev_len = {:?} new_len = {:?}", - prev_len, self.len()); + debug!( + "tainted: prev_len = {:?} new_len = {:?}", + prev_len, + self.len() + ); prev_len = self.len(); for undo_entry in undo_log { match undo_entry { &AddConstraint(Constraint::VarSubVar(a, b)) => { - self.add_edge(tcx.mk_region(ReVar(a)), - tcx.mk_region(ReVar(b))); + self.add_edge(tcx.mk_region(ReVar(a)), tcx.mk_region(ReVar(b))); } &AddConstraint(Constraint::RegSubVar(a, b)) => { self.add_edge(a, tcx.mk_region(ReVar(b))); @@ -55,15 +60,13 @@ self.add_edge(a, tcx.mk_region(ReVar(b))); } &AddVerify(i) => { - verifys[i].bound.for_each_region(&mut |b| { - self.add_edge(verifys[i].region, b); - }); - } - &Purged | - &AddCombination(..) | - &AddVar(..) | - &OpenSnapshot | - &CommitedSnapshot => {} + span_bug!( + verifys[i].origin.span(), + "we never add verifications while doing higher-ranked things", + ) + } + &Purged | &AddCombination(..) | &AddVar(..) | &OpenSnapshot + | &CommitedSnapshot => {} } } } @@ -77,9 +80,7 @@ self.regions.len() } - fn add_edge(&mut self, - source: ty::Region<'tcx>, - target: ty::Region<'tcx>) { + fn add_edge(&mut self, source: ty::Region<'tcx>, target: ty::Region<'tcx>) { if self.directions.incoming { if self.regions.contains(&target) { self.regions.insert(source); @@ -93,4 +94,3 @@ } } } - diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/resolve.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/resolve.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/resolve.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/resolve.rs 2018-12-04 23:41:40.000000000 +0000 @@ -153,8 +153,8 @@ fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { if !t.needs_infer() && !ty::keep_local(&t) { t // micro-optimize -- if there is nothing in this type that this fold affects... - // ^ we need to have the `keep_local` check to un-default - // defaulted tuples. + // ^ we need to have the `keep_local` check to un-default + // defaulted tuples. } else { let t = self.infcx.shallow_resolve(t); match t.sty { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/infer/type_variable.rs rustc-1.31.0+dfsg1+llvm/src/librustc/infer/type_variable.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/infer/type_variable.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/infer/type_variable.rs 2018-12-04 23:41:40.000000000 +0000 @@ -273,11 +273,8 @@ pub fn rollback_to(&mut self, s: Snapshot<'tcx>) { debug!("rollback_to{:?}", { for action in self.values.actions_since_snapshot(&s.snapshot) { - match *action { - sv::UndoLog::NewElem(index) => { - debug!("inference variable _#{}t popped", index) - } - _ => { } + if let sv::UndoLog::NewElem(index) = *action { + debug!("inference variable _#{}t popped", index) } } }); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -42,17 +42,14 @@ #![feature(box_patterns)] #![feature(box_syntax)] -#![cfg_attr(stage0, feature(const_fn))] -#![cfg_attr(not(stage0), feature(min_const_fn))] +#![cfg_attr(stage0, feature(min_const_fn))] #![feature(core_intrinsics)] #![feature(drain_filter)] #![cfg_attr(windows, feature(libc))] -#![cfg_attr(stage0, feature(macro_vis_matcher))] #![feature(never_type)] #![feature(exhaustive_patterns)] #![feature(extern_types)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(non_exhaustive)] #![feature(proc_macro_internals)] #![feature(quote)] @@ -60,7 +57,6 @@ #![feature(refcell_replace_swap)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_attrs)] -#![cfg_attr(stage0, feature(attr_literals))] #![feature(slice_patterns)] #![feature(slice_sort_by_cached_key)] #![feature(specialization)] @@ -71,14 +67,16 @@ #![feature(step_trait)] #![feature(integer_atomics)] #![feature(test)] -#![cfg_attr(not(stage0), feature(impl_header_lifetime_elision))] +#![cfg_attr(stage0, feature(impl_header_lifetime_elision))] #![feature(in_band_lifetimes)] #![feature(macro_at_most_once_rep)] -#![cfg_attr(stage0, feature(crate_in_paths))] #![feature(crate_visibility_modifier)] +#![feature(transpose_result)] #![recursion_limit="512"] +#![warn(elided_lifetimes_in_paths)] + extern crate arena; #[macro_use] extern crate bitflags; extern crate core; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/lint/builtin.rs rustc-1.31.0+dfsg1+llvm/src/librustc/lint/builtin.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/lint/builtin.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/lint/builtin.rs 2018-12-04 23:41:40.000000000 +0000 @@ -234,6 +234,12 @@ } declare_lint! { + pub UNCONDITIONAL_RECURSION, + Warn, + "functions that cannot return without calling themselves" +} + +declare_lint! { pub SINGLE_USE_LIFETIMES, Allow, "detects lifetime parameters that are only used once" @@ -313,6 +319,12 @@ } declare_lint! { + pub MISSING_DOC_CODE_EXAMPLES, + Allow, + "warn about missing code example in an item's documentation" +} + +declare_lint! { pub WHERE_CLAUSES_OBJECT_SAFETY, Warn, "checks the object safety of where clauses" @@ -338,6 +350,12 @@ cannot be referred to by absolute paths" } +declare_lint! { + pub EXPLICIT_OUTLIVES_REQUIREMENTS, + Allow, + "outlives requirements can be inferred" +} + /// Some lints that are buffered from `libsyntax`. See `syntax::early_buffered_lints`. pub mod parser { declare_lint! { @@ -390,6 +408,7 @@ DEPRECATED, UNUSED_UNSAFE, UNUSED_MUT, + UNCONDITIONAL_RECURSION, SINGLE_USE_LIFETIMES, UNUSED_LIFETIMES, UNUSED_LABELS, @@ -402,6 +421,7 @@ DUPLICATE_ASSOCIATED_TYPE_BINDINGS, DUPLICATE_MACRO_EXPORTS, INTRA_DOC_LINK_RESOLUTION_FAILURE, + MISSING_DOC_CODE_EXAMPLES, WHERE_CLAUSES_OBJECT_SAFETY, PROC_MACRO_DERIVE_RESOLUTION_FALLBACK, MACRO_USE_EXTERN_CRATE, @@ -426,7 +446,7 @@ } impl BuiltinLintDiagnostics { - pub fn run(self, sess: &Session, db: &mut DiagnosticBuilder) { + pub fn run(self, sess: &Session, db: &mut DiagnosticBuilder<'_>) { match self { BuiltinLintDiagnostics::Normal => (), BuiltinLintDiagnostics::BareTraitObject(span, is_global) => { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/lint/context.rs rustc-1.31.0+dfsg1+llvm/src/librustc/lint/context.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/lint/context.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/lint/context.rs 2018-12-04 23:41:40.000000000 +0000 @@ -67,10 +67,8 @@ /// Lints indexed by name. by_name: FxHashMap, - /// Map of registered lint groups to what lints they expand to. The first - /// bool is true if the lint group was added by a plugin. The optional string - /// is used to store the new names of deprecated lint group names. - lint_groups: FxHashMap<&'static str, (Vec, bool, Option<&'static str>)>, + /// Map of registered lint groups to what lints they expand to. + lint_groups: FxHashMap<&'static str, LintGroup>, /// Extra info for future incompatibility lints, describing the /// issue or RFC that caused the incompatibility. @@ -127,6 +125,18 @@ Removed, } +struct LintAlias { + name: &'static str, + /// Whether deprecation warnings should be suppressed for this alias. + silent: bool, +} + +struct LintGroup { + lint_ids: Vec, + from_plugin: bool, + depr: Option, +} + pub enum CheckLintNameResult<'a> { Ok(&'a [LintId]), /// Lint doesn't exist @@ -149,9 +159,9 @@ pre_expansion_passes: Some(vec![]), early_passes: Some(vec![]), late_passes: Some(vec![]), - by_name: FxHashMap(), - future_incompatible: FxHashMap(), - lint_groups: FxHashMap(), + by_name: Default::default(), + future_incompatible: Default::default(), + lint_groups: Default::default(), } } @@ -160,9 +170,15 @@ } pub fn get_lint_groups<'t>(&'t self) -> Vec<(&'static str, Vec, bool)> { - self.lint_groups.iter().map(|(k, v)| (*k, - v.0.clone(), - v.1)).collect() + self.lint_groups.iter() + .filter(|(_, LintGroup { depr, .. })| { + // Don't display deprecated lint groups. + depr.is_none() + }) + .map(|(k, LintGroup { lint_ids, from_plugin, .. })| { + (*k, lint_ids.clone(), *from_plugin) + }) + .collect() } pub fn register_early_pass(&mut self, @@ -245,6 +261,18 @@ self.future_incompatible.get(&id) } + pub fn register_group_alias( + &mut self, + lint_name: &'static str, + alias: &'static str, + ) { + self.lint_groups.insert(alias, LintGroup { + lint_ids: vec![], + from_plugin: false, + depr: Some(LintAlias { name: lint_name, silent: true }), + }); + } + pub fn register_group( &mut self, sess: Option<&Session>, @@ -255,11 +283,18 @@ ) { let new = self .lint_groups - .insert(name, (to, from_plugin, None)) + .insert(name, LintGroup { + lint_ids: to, + from_plugin, + depr: None, + }) .is_none(); if let Some(deprecated) = deprecated_name { - self.lint_groups - .insert(deprecated, (vec![], from_plugin, Some(name))); + self.lint_groups.insert(deprecated, LintGroup { + lint_ids: vec![], + from_plugin, + depr: Some(LintAlias { name, silent: false }), + }); } if !new { @@ -288,7 +323,7 @@ self.by_name.insert(name.into(), Removed(reason.into())); } - pub fn find_lints(&self, lint_name: &str) -> Result, FindLintError> { + pub fn find_lints(&self, mut lint_name: &str) -> Result, FindLintError> { match self.by_name.get(lint_name) { Some(&Id(lint_id)) => Ok(vec![lint_id]), Some(&Renamed(_, lint_id)) => { @@ -298,9 +333,17 @@ Err(FindLintError::Removed) }, None => { - match self.lint_groups.get(lint_name) { - Some(v) => Ok(v.0.clone()), - None => Err(FindLintError::Removed) + loop { + return match self.lint_groups.get(lint_name) { + Some(LintGroup {lint_ids, depr, .. }) => { + if let Some(LintAlias { name, .. }) = depr { + lint_name = name; + continue; + } + Ok(lint_ids.clone()) + } + None => Err(FindLintError::Removed) + }; } } } @@ -355,7 +398,7 @@ &self, lint_name: &str, tool_name: Option, - ) -> CheckLintNameResult { + ) -> CheckLintNameResult<'_> { let complete_name = if let Some(tool_name) = tool_name { format!("{}::{}", tool_name, lint_name) } else { @@ -366,7 +409,9 @@ match self.by_name.get(&complete_name) { None => match self.lint_groups.get(&*complete_name) { None => return CheckLintNameResult::Tool(Err((None, String::new()))), - Some(ids) => return CheckLintNameResult::Tool(Ok(&ids.0)), + Some(LintGroup { lint_ids, .. }) => { + return CheckLintNameResult::Tool(Ok(&lint_ids)); + } }, Some(&Id(ref id)) => return CheckLintNameResult::Tool(Ok(slice::from_ref(id))), // If the lint was registered as removed or renamed by the lint tool, we don't need @@ -390,16 +435,20 @@ // If neither the lint, nor the lint group exists check if there is a `clippy::` // variant of this lint None => self.check_tool_name_for_backwards_compat(&complete_name, "clippy"), - Some(ids) => { + Some(LintGroup { lint_ids, depr, .. }) => { // Check if the lint group name is deprecated - if let Some(new_name) = ids.2 { - let lint_ids = self.lint_groups.get(new_name).unwrap(); - return CheckLintNameResult::Tool(Err(( - Some(&lint_ids.0), - new_name.to_string(), - ))); + if let Some(LintAlias { name, silent }) = depr { + let LintGroup { lint_ids, .. } = self.lint_groups.get(name).unwrap(); + return if *silent { + CheckLintNameResult::Ok(&lint_ids) + } else { + CheckLintNameResult::Tool(Err(( + Some(&lint_ids), + name.to_string(), + ))) + }; } - CheckLintNameResult::Ok(&ids.0) + CheckLintNameResult::Ok(&lint_ids) } }, Some(&Id(ref id)) => CheckLintNameResult::Ok(slice::from_ref(id)), @@ -410,22 +459,26 @@ &self, lint_name: &str, tool_name: &str, - ) -> CheckLintNameResult { + ) -> CheckLintNameResult<'_> { let complete_name = format!("{}::{}", tool_name, lint_name); match self.by_name.get(&complete_name) { None => match self.lint_groups.get(&*complete_name) { // Now we are sure, that this lint exists nowhere None => CheckLintNameResult::NoLint, - Some(ids) => { - // Reaching this would be weird, but lets cover this case anyway - if let Some(new_name) = ids.2 { - let lint_ids = self.lint_groups.get(new_name).unwrap(); - return CheckLintNameResult::Tool(Err(( - Some(&lint_ids.0), - new_name.to_string(), - ))); + Some(LintGroup { lint_ids, depr, .. }) => { + // Reaching this would be weird, but let's cover this case anyway + if let Some(LintAlias { name, silent }) = depr { + let LintGroup { lint_ids, .. } = self.lint_groups.get(name).unwrap(); + return if *silent { + CheckLintNameResult::Tool(Err((Some(&lint_ids), complete_name))) + } else { + CheckLintNameResult::Tool(Err(( + Some(&lint_ids), + name.to_string(), + ))) + }; } - CheckLintNameResult::Tool(Err((Some(&ids.0), complete_name))) + CheckLintNameResult::Tool(Err((Some(&lint_ids), complete_name))) } }, Some(&Id(ref id)) => { @@ -525,7 +578,7 @@ lint: &'static Lint, span: Option, msg: &str) - -> DiagnosticBuilder; + -> DiagnosticBuilder<'_>; /// Emit a lint at the appropriate level, for a particular span. fn span_lint>(&self, lint: &'static Lint, span: S, msg: &str) { @@ -536,7 +589,7 @@ lint: &'static Lint, span: S, msg: &str) - -> DiagnosticBuilder { + -> DiagnosticBuilder<'_> { self.lookup(lint, Some(span), msg) } @@ -640,7 +693,7 @@ lint: &'static Lint, span: Option, msg: &str) - -> DiagnosticBuilder { + -> DiagnosticBuilder<'_> { let id = self.last_ast_node_with_lint_attrs; match span { Some(s) => self.tcx.struct_span_lint_node(lint, id, s, msg), @@ -697,7 +750,7 @@ lint: &'static Lint, span: Option, msg: &str) - -> DiagnosticBuilder { + -> DiagnosticBuilder<'_> { self.builder.struct_lint(lint, span.map(|s| s.into()), msg) } @@ -967,9 +1020,12 @@ } fn visit_pat(&mut self, p: &'a ast::Pat) { - run_lints!(self, check_pat, p); + let mut visit_subpats = true; + run_lints!(self, check_pat, p, &mut visit_subpats); self.check_id(p.id); - ast_visit::walk_pat(self, p); + if visit_subpats { + ast_visit::walk_pat(self, p); + } } fn visit_expr(&mut self, e: &'a ast::Expr) { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/lint/levels.rs rustc-1.31.0+dfsg1+llvm/src/librustc/lint/levels.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/lint/levels.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/lint/levels.rs 2018-12-04 23:41:40.000000000 +0000 @@ -22,7 +22,6 @@ use syntax::ast; use syntax::attr; use syntax::source_map::MultiSpan; -use syntax::feature_gate; use syntax::symbol::Symbol; use util::nodemap::FxHashMap; @@ -54,13 +53,13 @@ return me } - pub fn builder(sess: &Session) -> LintLevelsBuilder { + pub fn builder(sess: &Session) -> LintLevelsBuilder<'_> { LintLevelsBuilder::new(sess, LintLevelSets::new(sess)) } fn process_command_line(&mut self, sess: &Session) { let store = sess.lint_store.borrow(); - let mut specs = FxHashMap(); + let mut specs = FxHashMap::default(); self.lint_cap = sess.opts.lint_cap.unwrap_or(Level::Forbid); for &(ref lint_name, level) in &sess.opts.lint_opts { @@ -98,7 +97,7 @@ // If `level` is none then we actually assume the default level for this // lint. - let mut level = level.unwrap_or(lint.default_level(sess)); + let mut level = level.unwrap_or_else(|| lint.default_level(sess)); // If we're about to issue a warning, check at the last minute for any // directives against the warnings "lint". If, for example, there's an @@ -176,7 +175,7 @@ sess, sets, cur: 0, - id_to_set: FxHashMap(), + id_to_set: Default::default(), warn_about_weird_lints: sess.buffered_lints.borrow().is_some(), } } @@ -196,7 +195,7 @@ /// /// Don't forget to call `pop`! pub fn push(&mut self, attrs: &[ast::Attribute]) -> BuilderPush { - let mut specs = FxHashMap(); + let mut specs = FxHashMap::default(); let store = self.sess.lint_store.borrow(); let sess = self.sess; let bad_attr = |span| { @@ -228,18 +227,7 @@ } }; let tool_name = if let Some(lint_tool) = word.is_scoped() { - let gate_feature = !self.sess.features_untracked().tool_lints; - let known_tool = attr::is_known_lint_tool(lint_tool); - if gate_feature { - feature_gate::emit_feature_err( - &sess.parse_sess, - "tool_lints", - word.span, - feature_gate::GateIssue::Language, - &format!("scoped lint `{}` is experimental", word.ident), - ); - } - if !known_tool { + if !attr::is_known_lint_tool(lint_tool) { span_err!( sess, lint_tool.span, @@ -247,9 +235,6 @@ "an unknown tool name found in scoped lint: `{}`", word.ident ); - } - - if gate_feature || !known_tool { continue; } @@ -299,7 +284,7 @@ "change it to", new_lint_name.to_string(), Applicability::MachineApplicable, - ).cancel(); + ).emit(); let src = LintSource::Node(Symbol::intern(&new_lint_name), li.span); for id in ids { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/lint/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/lint/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/lint/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/lint/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -327,56 +327,56 @@ } pub trait EarlyLintPass: LintPass { - fn check_ident(&mut self, _: &EarlyContext, _: ast::Ident) { } - fn check_crate(&mut self, _: &EarlyContext, _: &ast::Crate) { } - fn check_crate_post(&mut self, _: &EarlyContext, _: &ast::Crate) { } - fn check_mod(&mut self, _: &EarlyContext, _: &ast::Mod, _: Span, _: ast::NodeId) { } - fn check_mod_post(&mut self, _: &EarlyContext, _: &ast::Mod, _: Span, _: ast::NodeId) { } - fn check_foreign_item(&mut self, _: &EarlyContext, _: &ast::ForeignItem) { } - fn check_foreign_item_post(&mut self, _: &EarlyContext, _: &ast::ForeignItem) { } - fn check_item(&mut self, _: &EarlyContext, _: &ast::Item) { } - fn check_item_post(&mut self, _: &EarlyContext, _: &ast::Item) { } - fn check_local(&mut self, _: &EarlyContext, _: &ast::Local) { } - fn check_block(&mut self, _: &EarlyContext, _: &ast::Block) { } - fn check_block_post(&mut self, _: &EarlyContext, _: &ast::Block) { } - fn check_stmt(&mut self, _: &EarlyContext, _: &ast::Stmt) { } - fn check_arm(&mut self, _: &EarlyContext, _: &ast::Arm) { } - fn check_pat(&mut self, _: &EarlyContext, _: &ast::Pat) { } - fn check_expr(&mut self, _: &EarlyContext, _: &ast::Expr) { } - fn check_expr_post(&mut self, _: &EarlyContext, _: &ast::Expr) { } - fn check_ty(&mut self, _: &EarlyContext, _: &ast::Ty) { } - fn check_generic_param(&mut self, _: &EarlyContext, _: &ast::GenericParam) { } - fn check_generics(&mut self, _: &EarlyContext, _: &ast::Generics) { } - fn check_where_predicate(&mut self, _: &EarlyContext, _: &ast::WherePredicate) { } - fn check_poly_trait_ref(&mut self, _: &EarlyContext, _: &ast::PolyTraitRef, + fn check_ident(&mut self, _: &EarlyContext<'_>, _: ast::Ident) { } + fn check_crate(&mut self, _: &EarlyContext<'_>, _: &ast::Crate) { } + fn check_crate_post(&mut self, _: &EarlyContext<'_>, _: &ast::Crate) { } + fn check_mod(&mut self, _: &EarlyContext<'_>, _: &ast::Mod, _: Span, _: ast::NodeId) { } + fn check_mod_post(&mut self, _: &EarlyContext<'_>, _: &ast::Mod, _: Span, _: ast::NodeId) { } + fn check_foreign_item(&mut self, _: &EarlyContext<'_>, _: &ast::ForeignItem) { } + fn check_foreign_item_post(&mut self, _: &EarlyContext<'_>, _: &ast::ForeignItem) { } + fn check_item(&mut self, _: &EarlyContext<'_>, _: &ast::Item) { } + fn check_item_post(&mut self, _: &EarlyContext<'_>, _: &ast::Item) { } + fn check_local(&mut self, _: &EarlyContext<'_>, _: &ast::Local) { } + fn check_block(&mut self, _: &EarlyContext<'_>, _: &ast::Block) { } + fn check_block_post(&mut self, _: &EarlyContext<'_>, _: &ast::Block) { } + fn check_stmt(&mut self, _: &EarlyContext<'_>, _: &ast::Stmt) { } + fn check_arm(&mut self, _: &EarlyContext<'_>, _: &ast::Arm) { } + fn check_pat(&mut self, _: &EarlyContext<'_>, _: &ast::Pat, _: &mut bool) { } + fn check_expr(&mut self, _: &EarlyContext<'_>, _: &ast::Expr) { } + fn check_expr_post(&mut self, _: &EarlyContext<'_>, _: &ast::Expr) { } + fn check_ty(&mut self, _: &EarlyContext<'_>, _: &ast::Ty) { } + fn check_generic_param(&mut self, _: &EarlyContext<'_>, _: &ast::GenericParam) { } + fn check_generics(&mut self, _: &EarlyContext<'_>, _: &ast::Generics) { } + fn check_where_predicate(&mut self, _: &EarlyContext<'_>, _: &ast::WherePredicate) { } + fn check_poly_trait_ref(&mut self, _: &EarlyContext<'_>, _: &ast::PolyTraitRef, _: &ast::TraitBoundModifier) { } - fn check_fn(&mut self, _: &EarlyContext, - _: ast_visit::FnKind, _: &ast::FnDecl, _: Span, _: ast::NodeId) { } - fn check_fn_post(&mut self, _: &EarlyContext, - _: ast_visit::FnKind, _: &ast::FnDecl, _: Span, _: ast::NodeId) { } - fn check_trait_item(&mut self, _: &EarlyContext, _: &ast::TraitItem) { } - fn check_trait_item_post(&mut self, _: &EarlyContext, _: &ast::TraitItem) { } - fn check_impl_item(&mut self, _: &EarlyContext, _: &ast::ImplItem) { } - fn check_impl_item_post(&mut self, _: &EarlyContext, _: &ast::ImplItem) { } - fn check_struct_def(&mut self, _: &EarlyContext, + fn check_fn(&mut self, _: &EarlyContext<'_>, + _: ast_visit::FnKind<'_>, _: &ast::FnDecl, _: Span, _: ast::NodeId) { } + fn check_fn_post(&mut self, _: &EarlyContext<'_>, + _: ast_visit::FnKind<'_>, _: &ast::FnDecl, _: Span, _: ast::NodeId) { } + fn check_trait_item(&mut self, _: &EarlyContext<'_>, _: &ast::TraitItem) { } + fn check_trait_item_post(&mut self, _: &EarlyContext<'_>, _: &ast::TraitItem) { } + fn check_impl_item(&mut self, _: &EarlyContext<'_>, _: &ast::ImplItem) { } + fn check_impl_item_post(&mut self, _: &EarlyContext<'_>, _: &ast::ImplItem) { } + fn check_struct_def(&mut self, _: &EarlyContext<'_>, _: &ast::VariantData, _: ast::Ident, _: &ast::Generics, _: ast::NodeId) { } - fn check_struct_def_post(&mut self, _: &EarlyContext, + fn check_struct_def_post(&mut self, _: &EarlyContext<'_>, _: &ast::VariantData, _: ast::Ident, _: &ast::Generics, _: ast::NodeId) { } - fn check_struct_field(&mut self, _: &EarlyContext, _: &ast::StructField) { } - fn check_variant(&mut self, _: &EarlyContext, _: &ast::Variant, _: &ast::Generics) { } - fn check_variant_post(&mut self, _: &EarlyContext, _: &ast::Variant, _: &ast::Generics) { } - fn check_lifetime(&mut self, _: &EarlyContext, _: &ast::Lifetime) { } - fn check_path(&mut self, _: &EarlyContext, _: &ast::Path, _: ast::NodeId) { } - fn check_attribute(&mut self, _: &EarlyContext, _: &ast::Attribute) { } - fn check_mac_def(&mut self, _: &EarlyContext, _: &ast::MacroDef, _id: ast::NodeId) { } - fn check_mac(&mut self, _: &EarlyContext, _: &ast::Mac) { } + fn check_struct_field(&mut self, _: &EarlyContext<'_>, _: &ast::StructField) { } + fn check_variant(&mut self, _: &EarlyContext<'_>, _: &ast::Variant, _: &ast::Generics) { } + fn check_variant_post(&mut self, _: &EarlyContext<'_>, _: &ast::Variant, _: &ast::Generics) { } + fn check_lifetime(&mut self, _: &EarlyContext<'_>, _: &ast::Lifetime) { } + fn check_path(&mut self, _: &EarlyContext<'_>, _: &ast::Path, _: ast::NodeId) { } + fn check_attribute(&mut self, _: &EarlyContext<'_>, _: &ast::Attribute) { } + fn check_mac_def(&mut self, _: &EarlyContext<'_>, _: &ast::MacroDef, _id: ast::NodeId) { } + fn check_mac(&mut self, _: &EarlyContext<'_>, _: &ast::Mac) { } /// Called when entering a syntax node that can have lint attributes such /// as `#[allow(...)]`. Called with *all* the attributes of that node. - fn enter_lint_attrs(&mut self, _: &EarlyContext, _: &[ast::Attribute]) { } + fn enter_lint_attrs(&mut self, _: &EarlyContext<'_>, _: &[ast::Attribute]) { } /// Counterpart to `enter_lint_attrs`. - fn exit_lint_attrs(&mut self, _: &EarlyContext, _: &[ast::Attribute]) { } + fn exit_lint_attrs(&mut self, _: &EarlyContext<'_>, _: &[ast::Attribute]) { } } /// A lint pass boxed up as a trait object. @@ -519,7 +519,7 @@ } pub fn take(&mut self, id: ast::NodeId) -> Vec { - self.map.remove(&id).unwrap_or(Vec::new()) + self.map.remove(&id).unwrap_or_default() } pub fn get_any(&self) -> Option<&[BufferedEarlyLint]> { @@ -728,7 +728,7 @@ } } -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers<'_>) { providers.lint_levels = lint_levels; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/macros.rs rustc-1.31.0+dfsg1+llvm/src/librustc/macros.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/macros.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/macros.rs 2018-12-04 23:41:40.000000000 +0000 @@ -63,6 +63,16 @@ } #[macro_export] +macro_rules! static_assert { + ($name:ident: $test:expr) => { + // Use the bool to access an array such that if the bool is false, the access + // is out-of-bounds. + #[allow(dead_code)] + static $name: () = [()][!$test as usize]; + } +} + +#[macro_export] macro_rules! __impl_stable_hash_field { ($field:ident, $ctx:expr, $hasher:expr) => ($field.hash_stable($ctx, $hasher)); ($field:ident, $ctx:expr, $hasher:expr, _) => ({ let _ = $field; }); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/middle/cstore.rs rustc-1.31.0+dfsg1+llvm/src/librustc/middle/cstore.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/middle/cstore.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/middle/cstore.rs 2018-12-04 23:41:40.000000000 +0000 @@ -244,7 +244,7 @@ // In order to get this left-to-right dependency ordering, we perform a // topological sort of all crates putting the leaves at the right-most // positions. -pub fn used_crates(tcx: TyCtxt, prefer: LinkagePreference) +pub fn used_crates(tcx: TyCtxt<'_, '_, '_>, prefer: LinkagePreference) -> Vec<(CrateNum, LibSource)> { let mut libs = tcx.crates() diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/middle/dead.rs rustc-1.31.0+dfsg1+llvm/src/librustc/middle/dead.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/middle/dead.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/middle/dead.rs 2018-12-04 23:41:40.000000000 +0000 @@ -18,6 +18,7 @@ use hir::itemlikevisit::ItemLikeVisitor; use hir::def::Def; +use hir::CodegenFnAttrFlags; use hir::def_id::{DefId, LOCAL_CRATE}; use lint; use middle::privacy; @@ -49,7 +50,7 @@ worklist: Vec, tcx: TyCtxt<'a, 'tcx, 'tcx>, tables: &'a ty::TypeckTables<'tcx>, - live_symbols: Box>, + live_symbols: FxHashSet, repr_has_repr_c: bool, in_pat: bool, inherited_pub_visibility: bool, @@ -79,7 +80,7 @@ self.check_def_id(def.def_id()); } _ if self.in_pat => (), - Def::PrimTy(..) | Def::SelfTy(..) | + Def::PrimTy(..) | Def::SelfTy(..) | Def::SelfCtor(..) | Def::Local(..) | Def::Upvar(..) => {} Def::Variant(variant_id) | Def::VariantCtor(variant_id, ..) => { if let Some(enum_id) = self.tcx.parent_def_id(variant_id) { @@ -130,13 +131,11 @@ } fn mark_live_symbols(&mut self) { - let mut scanned = FxHashSet(); - while !self.worklist.is_empty() { - let id = self.worklist.pop().unwrap(); - if scanned.contains(&id) { + let mut scanned = FxHashSet::default(); + while let Some(id) = self.worklist.pop() { + if !scanned.insert(id) { continue } - scanned.insert(id); if let Some(ref node) = self.tcx.hir.find(id) { self.live_symbols.insert(id); @@ -212,7 +211,7 @@ } fn visit_variant_data(&mut self, def: &'tcx hir::VariantData, _: ast::Name, - _: &hir::Generics, _: ast::NodeId, _: syntax_pos::Span) { + _: &hir::Generics, _: ast::NodeId, _: syntax_pos::Span) { let has_repr_c = self.repr_has_repr_c; let inherited_pub_visibility = self.inherited_pub_visibility; let live_fields = def.fields().iter().filter(|f| { @@ -285,7 +284,7 @@ } } -fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt, +fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt<'_, '_, '_>, id: ast::NodeId, attrs: &[ast::Attribute]) -> bool { if attr::contains_name(attrs, "lang") { @@ -304,14 +303,18 @@ return true; } - // #[used] also keeps the item alive forcefully, - // e.g. for placing it in a specific section. - if attr::contains_name(attrs, "used") { + // Don't lint about global allocators + if attr::contains_name(attrs, "global_allocator") { return true; } - // Don't lint about global allocators - if attr::contains_name(attrs, "global_allocator") { + let def_id = tcx.hir.local_def_id(id); + let cg_attrs = tcx.codegen_fn_attrs(def_id); + + // #[used], #[no_mangle], #[export_name], etc also keeps the item alive + // forcefully, e.g. for placing it in a specific section. + if cg_attrs.contains_extern_indicator() || + cg_attrs.flags.contains(CodegenFnAttrFlags::USED) { return true; } @@ -420,13 +423,13 @@ fn find_live<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, access_levels: &privacy::AccessLevels, krate: &hir::Crate) - -> Box> { + -> FxHashSet { let worklist = create_and_seed_worklist(tcx, access_levels, krate); let mut symbol_visitor = MarkSymbolVisitor { worklist, tcx, tables: &ty::TypeckTables::empty(None), - live_symbols: box FxHashSet(), + live_symbols: Default::default(), repr_has_repr_c: false, in_pat: false, inherited_pub_visibility: false, @@ -447,7 +450,7 @@ struct DeadVisitor<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx>, - live_symbols: Box>, + live_symbols: FxHashSet, } impl<'a, 'tcx> DeadVisitor<'a, 'tcx> { @@ -500,8 +503,8 @@ ctor_id: Option) -> bool { if self.live_symbols.contains(&id) - || ctor_id.map_or(false, - |ctor| self.live_symbols.contains(&ctor)) { + || ctor_id.map_or(false, |ctor| self.live_symbols.contains(&ctor)) + { return true; } // If it's a type whose items are live, then it's live, too. diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/middle/dependency_format.rs rustc-1.31.0+dfsg1+llvm/src/librustc/middle/dependency_format.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/middle/dependency_format.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/middle/dependency_format.rs 2018-12-04 23:41:40.000000000 +0000 @@ -94,7 +94,7 @@ pub fn calculate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let sess = &tcx.sess; - let mut fmts = FxHashMap(); + let mut fmts = FxHashMap::default(); for &ty in sess.crate_types.borrow().iter() { let linkage = calculate_type(tcx, ty); verify_ok(tcx, &linkage); @@ -163,14 +163,14 @@ let src = tcx.used_crate_source(cnum); if src.rlib.is_some() { continue } sess.err(&format!("crate `{}` required to be available in rlib format, \ - but was not found in this form", + but was not found in this form", tcx.crate_name(cnum))); } return Vec::new(); } } - let mut formats = FxHashMap(); + let mut formats = FxHashMap::default(); // Sweep all crates for found dylibs. Add all dylibs, as well as their // dependencies, ensuring there are no conflicts. The only valid case for a @@ -247,16 +247,16 @@ _ => "dylib", }; sess.err(&format!("crate `{}` required to be available in {} format, \ - but was not found in this form", + but was not found in this form", tcx.crate_name(cnum), kind)); } } } - return ret; + ret } -fn add_library(tcx: TyCtxt, +fn add_library(tcx: TyCtxt<'_, '_, '_>, cnum: CrateNum, link: LinkagePreference, m: &mut FxHashMap) { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/middle/entry.rs rustc-1.31.0+dfsg1+llvm/src/librustc/middle/entry.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/middle/entry.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/middle/entry.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - use hir::map as hir_map; use hir::def_id::{CRATE_DEF_INDEX}; use session::{config, Session}; @@ -57,7 +56,7 @@ } pub fn find_entry_point(session: &Session, - hir_map: &hir_map::Map, + hir_map: &hir_map::Map<'_>, crate_name: &str) { let any_exe = session.crate_types.borrow().iter().any(|ty| { *ty == config::CrateType::Executable @@ -113,7 +112,7 @@ } -fn find_item(item: &Item, ctxt: &mut EntryContext, at_root: bool) { +fn find_item(item: &Item, ctxt: &mut EntryContext<'_, '_>, at_root: bool) { match entry_point_type(item, at_root) { EntryPointType::MainNamed => { if ctxt.main_fn.is_none() { @@ -131,7 +130,7 @@ ctxt.attr_main_fn = Some((item.id, item.span)); } else { struct_span_err!(ctxt.session, item.span, E0137, - "multiple functions with a #[main] attribute") + "multiple functions with a #[main] attribute") .span_label(item.span, "additional #[main] function") .span_label(ctxt.attr_main_fn.unwrap().1, "first #[main] function") .emit(); @@ -141,11 +140,8 @@ if ctxt.start_fn.is_none() { ctxt.start_fn = Some((item.id, item.span)); } else { - struct_span_err!( - ctxt.session, item.span, E0138, - "multiple 'start' functions") - .span_label(ctxt.start_fn.unwrap().1, - "previous `start` function here") + struct_span_err!(ctxt.session, item.span, E0138, "multiple 'start' functions") + .span_label(ctxt.start_fn.unwrap().1, "previous `start` function here") .span_label(item.span, "multiple `start` functions") .emit(); } @@ -154,7 +150,7 @@ } } -fn configure_main(this: &mut EntryContext, crate_name: &str) { +fn configure_main(this: &mut EntryContext<'_, '_>, crate_name: &str) { if let Some((node_id, span)) = this.start_fn { this.session.entry_fn.set(Some((node_id, span, EntryFnType::Start))); } else if let Some((node_id, span)) = this.attr_main_fn { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/middle/exported_symbols.rs rustc-1.31.0+dfsg1+llvm/src/librustc/middle/exported_symbols.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/middle/exported_symbols.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/middle/exported_symbols.rs 2018-12-04 23:41:40.000000000 +0000 @@ -35,12 +35,8 @@ impl SymbolExportLevel { pub fn is_below_threshold(self, threshold: SymbolExportLevel) -> bool { - if threshold == SymbolExportLevel::Rust { - // We export everything from Rust dylibs - true - } else { - self == SymbolExportLevel::C - } + threshold == SymbolExportLevel::Rust // export everything from Rust dylibs + || self == SymbolExportLevel::C } } @@ -106,7 +102,7 @@ } } -pub fn metadata_symbol_name(tcx: ty::TyCtxt) -> String { +pub fn metadata_symbol_name(tcx: ty::TyCtxt<'_, '_, '_>) -> String { format!("rust_metadata_{}_{}", tcx.original_crate_name(LOCAL_CRATE), tcx.crate_disambiguator(LOCAL_CRATE).to_fingerprint().to_hex()) diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/middle/expr_use_visitor.rs rustc-1.31.0+dfsg1+llvm/src/librustc/middle/expr_use_visitor.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/middle/expr_use_visitor.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/middle/expr_use_visitor.rs 2018-12-04 23:41:40.000000000 +0000 @@ -211,7 +211,7 @@ } impl OverloadedCallType { - fn from_trait_id(tcx: TyCtxt, trait_id: DefId) -> OverloadedCallType { + fn from_trait_id(tcx: TyCtxt<'_, '_, '_>, trait_id: DefId) -> OverloadedCallType { for &(maybe_function_trait, overloaded_call_type) in &[ (tcx.lang_items().fn_once_trait(), FnOnceOverloadedCall), (tcx.lang_items().fn_mut_trait(), FnMutOverloadedCall), @@ -228,7 +228,7 @@ bug!("overloaded call didn't map to known function trait") } - fn from_method_id(tcx: TyCtxt, method_id: DefId) -> OverloadedCallType { + fn from_method_id(tcx: TyCtxt<'_, '_, '_>, method_id: DefId) -> OverloadedCallType { let method = tcx.associated_item(method_id); OverloadedCallType::from_trait_id(tcx, method.container.id()) } @@ -321,7 +321,7 @@ region::Scope { id: body.value.hir_id.local_id, data: region::ScopeData::Node - })); + })); let arg_cmt = Rc::new(self.mc.cat_rvalue( arg.hir_id, arg.pat.span, @@ -364,11 +364,12 @@ } fn mutate_expr(&mut self, + span: Span, assignment_expr: &hir::Expr, expr: &hir::Expr, mode: MutateMode) { let cmt = return_if_err!(self.mc.cat_expr(expr)); - self.delegate.mutate(assignment_expr.id, assignment_expr.span, &cmt, mode); + self.delegate.mutate(assignment_expr.id, span, &cmt, mode); self.walk_expr(expr); } @@ -402,20 +403,20 @@ self.walk_expr(&subexpr) } - hir::ExprKind::Unary(hir::UnDeref, ref base) => { // *base + hir::ExprKind::Unary(hir::UnDeref, ref base) => { // *base self.select_from_expr(&base); } - hir::ExprKind::Field(ref base, _) => { // base.f + hir::ExprKind::Field(ref base, _) => { // base.f self.select_from_expr(&base); } - hir::ExprKind::Index(ref lhs, ref rhs) => { // lhs[rhs] + hir::ExprKind::Index(ref lhs, ref rhs) => { // lhs[rhs] self.select_from_expr(&lhs); self.consume_expr(&rhs); } - hir::ExprKind::Call(ref callee, ref args) => { // callee(args) + hir::ExprKind::Call(ref callee, ref args) => { // callee(args) self.walk_callee(expr, &callee); self.consume_exprs(args); } @@ -472,12 +473,16 @@ if o.is_indirect { self.consume_expr(output); } else { - self.mutate_expr(expr, output, - if o.is_rw { - MutateMode::WriteAndRead - } else { - MutateMode::JustWrite - }); + self.mutate_expr( + output.span, + expr, + output, + if o.is_rw { + MutateMode::WriteAndRead + } else { + MutateMode::JustWrite + }, + ); } } self.consume_exprs(inputs); @@ -515,7 +520,7 @@ } hir::ExprKind::Assign(ref lhs, ref rhs) => { - self.mutate_expr(expr, &lhs, MutateMode::JustWrite); + self.mutate_expr(expr.span, expr, &lhs, MutateMode::JustWrite); self.consume_expr(&rhs); } @@ -527,7 +532,7 @@ if self.mc.tables.is_method_call(expr) { self.consume_expr(lhs); } else { - self.mutate_expr(expr, &lhs, MutateMode::WriteAndRead); + self.mutate_expr(expr.span, expr, &lhs, MutateMode::WriteAndRead); } self.consume_expr(&rhs); } @@ -801,10 +806,8 @@ self.walk_pat(discr_cmt.clone(), &pat, mode); } - if let Some(ref guard) = arm.guard { - match guard { - hir::Guard::If(ref e) => self.consume_expr(e), - } + if let Some(hir::Guard::If(ref e)) = arm.guard { + self.consume_expr(e) } self.consume_expr(&arm.body); @@ -826,12 +829,13 @@ cmt_discr: mc::cmt<'tcx>, pat: &hir::Pat, mode: &mut TrackMatchMode) { - debug!("determine_pat_move_mode cmt_discr={:?} pat={:?}", cmt_discr, - pat); + debug!("determine_pat_move_mode cmt_discr={:?} pat={:?}", cmt_discr, pat); + return_if_err!(self.mc.cat_pattern(cmt_discr, pat, |cmt_pat, pat| { if let PatKind::Binding(..) = pat.node { - let bm = *self.mc.tables.pat_binding_modes().get(pat.hir_id) - .expect("missing binding mode"); + let bm = *self.mc.tables.pat_binding_modes() + .get(pat.hir_id) + .expect("missing binding mode"); match bm { ty::BindByReference(..) => mode.lub(BorrowingMatch), diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/middle/intrinsicck.rs rustc-1.31.0+dfsg1+llvm/src/librustc/middle/intrinsicck.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/middle/intrinsicck.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/middle/intrinsicck.rs 2018-12-04 23:41:40.000000000 +0000 @@ -107,7 +107,7 @@ } Err(LayoutError::Unknown(bad)) => { if bad == ty { - "this type's size can vary".to_string() + "this type's size can vary".to_owned() } else { format!("size can vary because of {}", bad) } @@ -117,7 +117,7 @@ }; struct_span_err!(self.tcx.sess, span, E0512, - "transmute called with types of different sizes") + "transmute called with types of different sizes") .note(&format!("source type: {} ({})", from, skeleton_string(from, sk_from))) .note(&format!("target type: {} ({})", to, skeleton_string(to, sk_to))) .emit(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/middle/lang_items.rs rustc-1.31.0+dfsg1+llvm/src/librustc/middle/lang_items.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/middle/lang_items.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/middle/lang_items.rs 2018-12-04 23:41:40.000000000 +0000 @@ -22,6 +22,7 @@ pub use self::LangItem::*; use hir::def_id::DefId; +use hir::check_attr::Target; use ty::{self, TyCtxt}; use middle::weak_lang_items; use util::nodemap::FxHashMap; @@ -36,10 +37,9 @@ // So you probably just want to nip down to the end. macro_rules! language_item_table { ( - $( $variant:ident, $name:expr, $method:ident; )* + $( $variant:ident, $name:expr, $method:ident, $target:path; )* ) => { - enum_from_u32! { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] pub enum LangItem { @@ -97,26 +97,49 @@ struct LanguageItemCollector<'a, 'tcx: 'a> { items: LanguageItems, - tcx: TyCtxt<'a, 'tcx, 'tcx>, - - item_refs: FxHashMap<&'static str, usize>, + item_refs: FxHashMap<&'static str, (usize, Target)>, } impl<'a, 'v, 'tcx> ItemLikeVisitor<'v> for LanguageItemCollector<'a, 'tcx> { fn visit_item(&mut self, item: &hir::Item) { if let Some((value, span)) = extract(&item.attrs) { - let item_index = self.item_refs.get(&*value.as_str()).cloned(); - - if let Some(item_index) = item_index { - let def_id = self.tcx.hir.local_def_id(item.id); - self.collect_item(item_index, def_id); - } else { - let mut err = struct_span_err!(self.tcx.sess, span, E0522, - "definition of an unknown language item: `{}`", - value); - err.span_label(span, format!("definition of unknown language item `{}`", value)); - err.emit(); + let actual_target = Target::from_item(item); + match self.item_refs.get(&*value.as_str()).cloned() { + // Known lang item with attribute on correct target. + Some((item_index, expected_target)) if actual_target == expected_target => { + let def_id = self.tcx.hir.local_def_id(item.id); + self.collect_item(item_index, def_id); + }, + // Known lang item with attribute on incorrect target. + Some((_, expected_target)) => { + let mut err = struct_span_err!( + self.tcx.sess, span, E0718, + "`{}` language item must be applied to a {}", + value, expected_target, + ); + err.span_label( + span, + format!( + "attribute should be applied to a {}, not a {}", + expected_target, actual_target, + ), + ); + err.emit(); + }, + // Unknown lang item. + _ => { + let mut err = struct_span_err!( + self.tcx.sess, span, E0522, + "definition of an unknown language item: `{}`", + value + ); + err.span_label( + span, + format!("definition of unknown language item `{}`", value) + ); + err.emit(); + }, } } } @@ -132,9 +155,9 @@ impl<'a, 'tcx> LanguageItemCollector<'a, 'tcx> { fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> LanguageItemCollector<'a, 'tcx> { - let mut item_refs = FxHashMap(); + let mut item_refs = FxHashMap::default(); - $( item_refs.insert($name, $variant as usize); )* + $( item_refs.insert($name, ($variant as usize, $target)); )* LanguageItemCollector { tcx, @@ -145,8 +168,8 @@ fn collect_item(&mut self, item_index: usize, item_def_id: DefId) { // Check for duplicates. - match self.items.items[item_index] { - Some(original_def_id) if original_def_id != item_def_id => { + if let Some(original_def_id) = self.items.items[item_index] { + if original_def_id != item_def_id { let name = LangItem::from_u32(item_index as u32).unwrap().name(); let mut err = match self.tcx.hir.span_if_local(item_def_id) { Some(span) => struct_span_err!( @@ -161,17 +184,13 @@ name)), }; if let Some(span) = self.tcx.hir.span_if_local(original_def_id) { - span_note!(&mut err, span, - "first defined here."); + span_note!(&mut err, span, "first defined here."); } else { err.note(&format!("first defined in crate `{}`.", self.tcx.crate_name(original_def_id.krate))); } err.emit(); } - _ => { - // OK. - } } // Matched. @@ -194,7 +213,7 @@ } } - return None; + None } pub fn collect<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> LanguageItems { @@ -215,84 +234,84 @@ } language_item_table! { -// Variant name, Name, Method name; - CharImplItem, "char", char_impl; - StrImplItem, "str", str_impl; - SliceImplItem, "slice", slice_impl; - SliceU8ImplItem, "slice_u8", slice_u8_impl; - StrAllocImplItem, "str_alloc", str_alloc_impl; - SliceAllocImplItem, "slice_alloc", slice_alloc_impl; - SliceU8AllocImplItem, "slice_u8_alloc", slice_u8_alloc_impl; - ConstPtrImplItem, "const_ptr", const_ptr_impl; - MutPtrImplItem, "mut_ptr", mut_ptr_impl; - I8ImplItem, "i8", i8_impl; - I16ImplItem, "i16", i16_impl; - I32ImplItem, "i32", i32_impl; - I64ImplItem, "i64", i64_impl; - I128ImplItem, "i128", i128_impl; - IsizeImplItem, "isize", isize_impl; - U8ImplItem, "u8", u8_impl; - U16ImplItem, "u16", u16_impl; - U32ImplItem, "u32", u32_impl; - U64ImplItem, "u64", u64_impl; - U128ImplItem, "u128", u128_impl; - UsizeImplItem, "usize", usize_impl; - F32ImplItem, "f32", f32_impl; - F64ImplItem, "f64", f64_impl; - F32RuntimeImplItem, "f32_runtime", f32_runtime_impl; - F64RuntimeImplItem, "f64_runtime", f64_runtime_impl; - - SizedTraitLangItem, "sized", sized_trait; - UnsizeTraitLangItem, "unsize", unsize_trait; - CopyTraitLangItem, "copy", copy_trait; - CloneTraitLangItem, "clone", clone_trait; - SyncTraitLangItem, "sync", sync_trait; - FreezeTraitLangItem, "freeze", freeze_trait; - - DropTraitLangItem, "drop", drop_trait; - - CoerceUnsizedTraitLangItem, "coerce_unsized", coerce_unsized_trait; - - AddTraitLangItem, "add", add_trait; - SubTraitLangItem, "sub", sub_trait; - MulTraitLangItem, "mul", mul_trait; - DivTraitLangItem, "div", div_trait; - RemTraitLangItem, "rem", rem_trait; - NegTraitLangItem, "neg", neg_trait; - NotTraitLangItem, "not", not_trait; - BitXorTraitLangItem, "bitxor", bitxor_trait; - BitAndTraitLangItem, "bitand", bitand_trait; - BitOrTraitLangItem, "bitor", bitor_trait; - ShlTraitLangItem, "shl", shl_trait; - ShrTraitLangItem, "shr", shr_trait; - AddAssignTraitLangItem, "add_assign", add_assign_trait; - SubAssignTraitLangItem, "sub_assign", sub_assign_trait; - MulAssignTraitLangItem, "mul_assign", mul_assign_trait; - DivAssignTraitLangItem, "div_assign", div_assign_trait; - RemAssignTraitLangItem, "rem_assign", rem_assign_trait; - BitXorAssignTraitLangItem, "bitxor_assign", bitxor_assign_trait; - BitAndAssignTraitLangItem, "bitand_assign", bitand_assign_trait; - BitOrAssignTraitLangItem, "bitor_assign", bitor_assign_trait; - ShlAssignTraitLangItem, "shl_assign", shl_assign_trait; - ShrAssignTraitLangItem, "shr_assign", shr_assign_trait; - IndexTraitLangItem, "index", index_trait; - IndexMutTraitLangItem, "index_mut", index_mut_trait; - - UnsafeCellTypeLangItem, "unsafe_cell", unsafe_cell_type; - - DerefTraitLangItem, "deref", deref_trait; - DerefMutTraitLangItem, "deref_mut", deref_mut_trait; - - FnTraitLangItem, "fn", fn_trait; - FnMutTraitLangItem, "fn_mut", fn_mut_trait; - FnOnceTraitLangItem, "fn_once", fn_once_trait; - - GeneratorStateLangItem, "generator_state", gen_state; - GeneratorTraitLangItem, "generator", gen_trait; - - EqTraitLangItem, "eq", eq_trait; - PartialOrdTraitLangItem, "partial_ord", partial_ord_trait; - OrdTraitLangItem, "ord", ord_trait; +// Variant name, Name, Method name, Target; + CharImplItem, "char", char_impl, Target::Impl; + StrImplItem, "str", str_impl, Target::Impl; + SliceImplItem, "slice", slice_impl, Target::Impl; + SliceU8ImplItem, "slice_u8", slice_u8_impl, Target::Impl; + StrAllocImplItem, "str_alloc", str_alloc_impl, Target::Impl; + SliceAllocImplItem, "slice_alloc", slice_alloc_impl, Target::Impl; + SliceU8AllocImplItem, "slice_u8_alloc", slice_u8_alloc_impl, Target::Impl; + ConstPtrImplItem, "const_ptr", const_ptr_impl, Target::Impl; + MutPtrImplItem, "mut_ptr", mut_ptr_impl, Target::Impl; + I8ImplItem, "i8", i8_impl, Target::Impl; + I16ImplItem, "i16", i16_impl, Target::Impl; + I32ImplItem, "i32", i32_impl, Target::Impl; + I64ImplItem, "i64", i64_impl, Target::Impl; + I128ImplItem, "i128", i128_impl, Target::Impl; + IsizeImplItem, "isize", isize_impl, Target::Impl; + U8ImplItem, "u8", u8_impl, Target::Impl; + U16ImplItem, "u16", u16_impl, Target::Impl; + U32ImplItem, "u32", u32_impl, Target::Impl; + U64ImplItem, "u64", u64_impl, Target::Impl; + U128ImplItem, "u128", u128_impl, Target::Impl; + UsizeImplItem, "usize", usize_impl, Target::Impl; + F32ImplItem, "f32", f32_impl, Target::Impl; + F64ImplItem, "f64", f64_impl, Target::Impl; + F32RuntimeImplItem, "f32_runtime", f32_runtime_impl, Target::Impl; + F64RuntimeImplItem, "f64_runtime", f64_runtime_impl, Target::Impl; + + SizedTraitLangItem, "sized", sized_trait, Target::Trait; + UnsizeTraitLangItem, "unsize", unsize_trait, Target::Trait; + CopyTraitLangItem, "copy", copy_trait, Target::Trait; + CloneTraitLangItem, "clone", clone_trait, Target::Trait; + SyncTraitLangItem, "sync", sync_trait, Target::Trait; + FreezeTraitLangItem, "freeze", freeze_trait, Target::Trait; + + DropTraitLangItem, "drop", drop_trait, Target::Trait; + + CoerceUnsizedTraitLangItem, "coerce_unsized", coerce_unsized_trait, Target::Trait; + + AddTraitLangItem, "add", add_trait, Target::Trait; + SubTraitLangItem, "sub", sub_trait, Target::Trait; + MulTraitLangItem, "mul", mul_trait, Target::Trait; + DivTraitLangItem, "div", div_trait, Target::Trait; + RemTraitLangItem, "rem", rem_trait, Target::Trait; + NegTraitLangItem, "neg", neg_trait, Target::Trait; + NotTraitLangItem, "not", not_trait, Target::Trait; + BitXorTraitLangItem, "bitxor", bitxor_trait, Target::Trait; + BitAndTraitLangItem, "bitand", bitand_trait, Target::Trait; + BitOrTraitLangItem, "bitor", bitor_trait, Target::Trait; + ShlTraitLangItem, "shl", shl_trait, Target::Trait; + ShrTraitLangItem, "shr", shr_trait, Target::Trait; + AddAssignTraitLangItem, "add_assign", add_assign_trait, Target::Trait; + SubAssignTraitLangItem, "sub_assign", sub_assign_trait, Target::Trait; + MulAssignTraitLangItem, "mul_assign", mul_assign_trait, Target::Trait; + DivAssignTraitLangItem, "div_assign", div_assign_trait, Target::Trait; + RemAssignTraitLangItem, "rem_assign", rem_assign_trait, Target::Trait; + BitXorAssignTraitLangItem, "bitxor_assign", bitxor_assign_trait, Target::Trait; + BitAndAssignTraitLangItem, "bitand_assign", bitand_assign_trait, Target::Trait; + BitOrAssignTraitLangItem, "bitor_assign", bitor_assign_trait, Target::Trait; + ShlAssignTraitLangItem, "shl_assign", shl_assign_trait, Target::Trait; + ShrAssignTraitLangItem, "shr_assign", shr_assign_trait, Target::Trait; + IndexTraitLangItem, "index", index_trait, Target::Trait; + IndexMutTraitLangItem, "index_mut", index_mut_trait, Target::Trait; + + UnsafeCellTypeLangItem, "unsafe_cell", unsafe_cell_type, Target::Struct; + + DerefTraitLangItem, "deref", deref_trait, Target::Trait; + DerefMutTraitLangItem, "deref_mut", deref_mut_trait, Target::Trait; + + FnTraitLangItem, "fn", fn_trait, Target::Trait; + FnMutTraitLangItem, "fn_mut", fn_mut_trait, Target::Trait; + FnOnceTraitLangItem, "fn_once", fn_once_trait, Target::Trait; + + GeneratorStateLangItem, "generator_state", gen_state, Target::Enum; + GeneratorTraitLangItem, "generator", gen_trait, Target::Trait; + + EqTraitLangItem, "eq", eq_trait, Target::Trait; + PartialOrdTraitLangItem, "partial_ord", partial_ord_trait, Target::Trait; + OrdTraitLangItem, "ord", ord_trait, Target::Trait; // A number of panic-related lang items. The `panic` item corresponds to // divide-by-zero and various panic cases with `match`. The @@ -303,65 +322,68 @@ // defined to use it, but a final product is required to define it // somewhere. Additionally, there are restrictions on crates that use a weak // lang item, but do not have it defined. - PanicFnLangItem, "panic", panic_fn; - PanicBoundsCheckFnLangItem, "panic_bounds_check", panic_bounds_check_fn; - PanicInfoLangItem, "panic_info", panic_info; - PanicImplLangItem, "panic_impl", panic_impl; + PanicFnLangItem, "panic", panic_fn, Target::Fn; + PanicBoundsCheckFnLangItem, "panic_bounds_check", panic_bounds_check_fn, Target::Fn; + PanicInfoLangItem, "panic_info", panic_info, Target::Struct; + PanicImplLangItem, "panic_impl", panic_impl, Target::Fn; // Libstd panic entry point. Necessary for const eval to be able to catch it - BeginPanicFnLangItem, "begin_panic", begin_panic_fn; + BeginPanicFnLangItem, "begin_panic", begin_panic_fn, Target::Fn; - ExchangeMallocFnLangItem, "exchange_malloc", exchange_malloc_fn; - BoxFreeFnLangItem, "box_free", box_free_fn; - DropInPlaceFnLangItem, "drop_in_place", drop_in_place_fn; - OomLangItem, "oom", oom; - AllocLayoutLangItem, "alloc_layout", alloc_layout; + ExchangeMallocFnLangItem, "exchange_malloc", exchange_malloc_fn, Target::Fn; + BoxFreeFnLangItem, "box_free", box_free_fn, Target::Fn; + DropInPlaceFnLangItem, "drop_in_place", drop_in_place_fn, Target::Fn; + OomLangItem, "oom", oom, Target::Fn; + AllocLayoutLangItem, "alloc_layout", alloc_layout, Target::Struct; - StartFnLangItem, "start", start_fn; + StartFnLangItem, "start", start_fn, Target::Fn; - EhPersonalityLangItem, "eh_personality", eh_personality; - EhUnwindResumeLangItem, "eh_unwind_resume", eh_unwind_resume; - MSVCTryFilterLangItem, "msvc_try_filter", msvc_try_filter; + EhPersonalityLangItem, "eh_personality", eh_personality, Target::Fn; + EhUnwindResumeLangItem, "eh_unwind_resume", eh_unwind_resume, Target::Fn; + MSVCTryFilterLangItem, "msvc_try_filter", msvc_try_filter, Target::Static; - OwnedBoxLangItem, "owned_box", owned_box; + OwnedBoxLangItem, "owned_box", owned_box, Target::Struct; - PhantomDataItem, "phantom_data", phantom_data; + PhantomDataItem, "phantom_data", phantom_data, Target::Struct; - ManuallyDropItem, "manually_drop", manually_drop; + ManuallyDropItem, "manually_drop", manually_drop, Target::Struct; - DebugTraitLangItem, "debug_trait", debug_trait; + DebugTraitLangItem, "debug_trait", debug_trait, Target::Trait; // A lang item for each of the 128-bit operators we can optionally lower. - I128AddFnLangItem, "i128_add", i128_add_fn; - U128AddFnLangItem, "u128_add", u128_add_fn; - I128SubFnLangItem, "i128_sub", i128_sub_fn; - U128SubFnLangItem, "u128_sub", u128_sub_fn; - I128MulFnLangItem, "i128_mul", i128_mul_fn; - U128MulFnLangItem, "u128_mul", u128_mul_fn; - I128DivFnLangItem, "i128_div", i128_div_fn; - U128DivFnLangItem, "u128_div", u128_div_fn; - I128RemFnLangItem, "i128_rem", i128_rem_fn; - U128RemFnLangItem, "u128_rem", u128_rem_fn; - I128ShlFnLangItem, "i128_shl", i128_shl_fn; - U128ShlFnLangItem, "u128_shl", u128_shl_fn; - I128ShrFnLangItem, "i128_shr", i128_shr_fn; - U128ShrFnLangItem, "u128_shr", u128_shr_fn; + I128AddFnLangItem, "i128_add", i128_add_fn, Target::Fn; + U128AddFnLangItem, "u128_add", u128_add_fn, Target::Fn; + I128SubFnLangItem, "i128_sub", i128_sub_fn, Target::Fn; + U128SubFnLangItem, "u128_sub", u128_sub_fn, Target::Fn; + I128MulFnLangItem, "i128_mul", i128_mul_fn, Target::Fn; + U128MulFnLangItem, "u128_mul", u128_mul_fn, Target::Fn; + I128DivFnLangItem, "i128_div", i128_div_fn, Target::Fn; + U128DivFnLangItem, "u128_div", u128_div_fn, Target::Fn; + I128RemFnLangItem, "i128_rem", i128_rem_fn, Target::Fn; + U128RemFnLangItem, "u128_rem", u128_rem_fn, Target::Fn; + I128ShlFnLangItem, "i128_shl", i128_shl_fn, Target::Fn; + U128ShlFnLangItem, "u128_shl", u128_shl_fn, Target::Fn; + I128ShrFnLangItem, "i128_shr", i128_shr_fn, Target::Fn; + U128ShrFnLangItem, "u128_shr", u128_shr_fn, Target::Fn; // And overflow versions for the operators that are checkable. // While MIR calls these Checked*, they return (T,bool), not Option. - I128AddoFnLangItem, "i128_addo", i128_addo_fn; - U128AddoFnLangItem, "u128_addo", u128_addo_fn; - I128SuboFnLangItem, "i128_subo", i128_subo_fn; - U128SuboFnLangItem, "u128_subo", u128_subo_fn; - I128MuloFnLangItem, "i128_mulo", i128_mulo_fn; - U128MuloFnLangItem, "u128_mulo", u128_mulo_fn; - I128ShloFnLangItem, "i128_shlo", i128_shlo_fn; - U128ShloFnLangItem, "u128_shlo", u128_shlo_fn; - I128ShroFnLangItem, "i128_shro", i128_shro_fn; - U128ShroFnLangItem, "u128_shro", u128_shro_fn; + I128AddoFnLangItem, "i128_addo", i128_addo_fn, Target::Fn; + U128AddoFnLangItem, "u128_addo", u128_addo_fn, Target::Fn; + I128SuboFnLangItem, "i128_subo", i128_subo_fn, Target::Fn; + U128SuboFnLangItem, "u128_subo", u128_subo_fn, Target::Fn; + I128MuloFnLangItem, "i128_mulo", i128_mulo_fn, Target::Fn; + U128MuloFnLangItem, "u128_mulo", u128_mulo_fn, Target::Fn; + I128ShloFnLangItem, "i128_shlo", i128_shlo_fn, Target::Fn; + U128ShloFnLangItem, "u128_shlo", u128_shlo_fn, Target::Fn; + I128ShroFnLangItem, "i128_shro", i128_shro_fn, Target::Fn; + U128ShroFnLangItem, "u128_shro", u128_shro_fn, Target::Fn; // Align offset for stride != 1, must not panic. - AlignOffsetLangItem, "align_offset", align_offset_fn; + AlignOffsetLangItem, "align_offset", align_offset_fn, Target::Fn; + + TerminationTraitLangItem, "termination", termination, Target::Trait; - TerminationTraitLangItem, "termination", termination; + Arc, "arc", arc, Target::Struct; + Rc, "rc", rc, Target::Struct; } impl<'a, 'tcx, 'gcx> TyCtxt<'a, 'tcx, 'gcx> { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/middle/lib_features.rs rustc-1.31.0+dfsg1+llvm/src/librustc/middle/lib_features.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/middle/lib_features.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/middle/lib_features.rs 2018-12-04 23:41:40.000000000 +0000 @@ -31,8 +31,8 @@ impl LibFeatures { fn new() -> LibFeatures { LibFeatures { - stable: FxHashMap(), - unstable: FxHashSet(), + stable: Default::default(), + unstable: Default::default(), } } @@ -128,8 +128,8 @@ let msg = format!( "feature `{}` is declared {}, but was previously declared {}", feature, - if since.is_some() { "stable"} else { "unstable" }, - if since.is_none() { "stable"} else { "unstable" }, + if since.is_some() { "stable" } else { "unstable" }, + if since.is_none() { "stable" } else { "unstable" }, ); self.tcx.sess.struct_span_err_with_code(span, &msg, DiagnosticId::Error("E0711".into())).emit(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/middle/liveness.rs rustc-1.31.0+dfsg1+llvm/src/librustc/middle/liveness.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/middle/liveness.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/middle/liveness.rs 2018-12-04 23:41:40.000000000 +0000 @@ -64,10 +64,10 @@ //! methods. It effectively does a reverse walk of the AST; whenever we //! reach a loop node, we iterate until a fixed point is reached. //! -//! ## The `Users` struct +//! ## The `RWU` struct //! //! At each live node `N`, we track three pieces of information for each -//! variable `V` (these are encapsulated in the `Users` struct): +//! variable `V` (these are encapsulated in the `RWU` struct): //! //! - `reader`: the `LiveNode` ID of some node which will read the value //! that `V` holds on entry to `N`. Formally: a node `M` such @@ -158,7 +158,7 @@ ExitNode } -fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt) -> String { +fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt<'_, '_, '_>) -> String { let cm = tcx.sess.source_map(); match lnk { FreeVarNode(s) => { @@ -170,7 +170,7 @@ VarDefNode(s) => { format!("Var def node [{}]", cm.span_to_string(s)) } - ExitNode => "Exit node".to_string(), + ExitNode => "Exit node".to_owned(), } } @@ -195,13 +195,13 @@ } impl fmt::Debug for LiveNode { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "ln({})", self.get()) } } impl fmt::Debug for Variable { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "v({})", self.get()) } } @@ -257,7 +257,6 @@ struct IrMaps<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx>, - num_live_nodes: usize, num_vars: usize, live_node_map: HirIdMap, @@ -330,7 +329,7 @@ Local(LocalInfo { name, .. }) | Arg(_, name) => { name.to_string() }, - CleanExit => "".to_string() + CleanExit => "".to_owned() } } @@ -371,7 +370,7 @@ } } - debug!("creating fn_maps: {:?}", &fn_maps as *const IrMaps); + debug!("creating fn_maps: {:?}", &fn_maps as *const IrMaps<'_, '_>); let body = ir.tcx.hir.body(body_id); @@ -474,13 +473,15 @@ // construction site. let mut call_caps = Vec::new(); ir.tcx.with_freevars(expr.id, |freevars| { - for fv in freevars { + call_caps.extend(freevars.iter().filter_map(|fv| { if let Def::Local(rv) = fv.def { let fv_ln = ir.add_live_node(FreeVarNode(fv.span)); let var_hid = ir.tcx.hir.node_to_hir_id(rv); - call_caps.push(CaptureInfo { ln: fv_ln, var_hid }); + Some(CaptureInfo { ln: fv_ln, var_hid }) + } else { + None } - } + })); }); ir.set_captures(expr.id, call_caps); @@ -537,17 +538,108 @@ // the same basic propagation framework in all cases. #[derive(Clone, Copy)] -struct Users { +struct RWU { reader: LiveNode, writer: LiveNode, used: bool } -fn invalid_users() -> Users { - Users { - reader: invalid_node(), - writer: invalid_node(), - used: false +/// Conceptually, this is like a `Vec`. But the number of `RWU`s can get +/// very large, so it uses a more compact representation that takes advantage +/// of the fact that when the number of `RWU`s is large, most of them have an +/// invalid reader and an invalid writer. +struct RWUTable { + /// Each entry in `packed_rwus` is either INV_INV_FALSE, INV_INV_TRUE, or + /// an index into `unpacked_rwus`. In the common cases, this compacts the + /// 65 bits of data into 32; in the uncommon cases, it expands the 65 bits + /// in 96. + /// + /// More compact representations are possible -- e.g. use only 2 bits per + /// packed `RWU` and make the secondary table a HashMap that maps from + /// indices to `RWU`s -- but this one strikes a good balance between size + /// and speed. + packed_rwus: Vec, + unpacked_rwus: Vec, +} + +// A constant representing `RWU { reader: invalid_node(); writer: invalid_node(); used: false }`. +const INV_INV_FALSE: u32 = u32::MAX; + +// A constant representing `RWU { reader: invalid_node(); writer: invalid_node(); used: true }`. +const INV_INV_TRUE: u32 = u32::MAX - 1; + +impl RWUTable { + fn new(num_rwus: usize) -> RWUTable { + Self { + packed_rwus: vec![INV_INV_FALSE; num_rwus], + unpacked_rwus: vec![], + } + } + + fn get(&self, idx: usize) -> RWU { + let packed_rwu = self.packed_rwus[idx]; + match packed_rwu { + INV_INV_FALSE => RWU { reader: invalid_node(), writer: invalid_node(), used: false }, + INV_INV_TRUE => RWU { reader: invalid_node(), writer: invalid_node(), used: true }, + _ => self.unpacked_rwus[packed_rwu as usize], + } + } + + fn get_reader(&self, idx: usize) -> LiveNode { + let packed_rwu = self.packed_rwus[idx]; + match packed_rwu { + INV_INV_FALSE | INV_INV_TRUE => invalid_node(), + _ => self.unpacked_rwus[packed_rwu as usize].reader, + } + } + + fn get_writer(&self, idx: usize) -> LiveNode { + let packed_rwu = self.packed_rwus[idx]; + match packed_rwu { + INV_INV_FALSE | INV_INV_TRUE => invalid_node(), + _ => self.unpacked_rwus[packed_rwu as usize].writer, + } + } + + fn get_used(&self, idx: usize) -> bool { + let packed_rwu = self.packed_rwus[idx]; + match packed_rwu { + INV_INV_FALSE => false, + INV_INV_TRUE => true, + _ => self.unpacked_rwus[packed_rwu as usize].used, + } + } + + #[inline] + fn copy_packed(&mut self, dst_idx: usize, src_idx: usize) { + self.packed_rwus[dst_idx] = self.packed_rwus[src_idx]; + } + + fn assign_unpacked(&mut self, idx: usize, rwu: RWU) { + if rwu.reader == invalid_node() && rwu.writer == invalid_node() { + // When we overwrite an indexing entry in `self.packed_rwus` with + // `INV_INV_{TRUE,FALSE}` we don't remove the corresponding entry + // from `self.unpacked_rwus`; it's not worth the effort, and we + // can't have entries shifting around anyway. + self.packed_rwus[idx] = if rwu.used { + INV_INV_TRUE + } else { + INV_INV_FALSE + } + } else { + // Add a new RWU to `unpacked_rwus` and make `packed_rwus[idx]` + // point to it. + self.packed_rwus[idx] = self.unpacked_rwus.len() as u32; + self.unpacked_rwus.push(rwu); + } + } + + fn assign_inv_inv(&mut self, idx: usize) { + self.packed_rwus[idx] = if self.get_used(idx) { + INV_INV_TRUE + } else { + INV_INV_FALSE + }; } } @@ -567,7 +659,7 @@ tables: &'a ty::TypeckTables<'tcx>, s: Specials, successors: Vec, - users: Vec, + rwu_table: RWUTable, // mappings from loop node ID to LiveNode // ("break" label should map to loop node ID, @@ -598,7 +690,7 @@ tables, s: specials, successors: vec![invalid_node(); num_live_nodes], - users: vec![invalid_users(); num_live_nodes * num_vars], + rwu_table: RWUTable::new(num_live_nodes * num_vars), break_ln: NodeMap(), cont_ln: NodeMap(), } @@ -662,16 +754,13 @@ ln.get() * self.ir.num_vars + var.get() } - fn live_on_entry(&self, ln: LiveNode, var: Variable) - -> Option { + fn live_on_entry(&self, ln: LiveNode, var: Variable) -> Option { assert!(ln.is_valid()); - let reader = self.users[self.idx(ln, var)].reader; - if reader.is_valid() {Some(self.ir.lnk(reader))} else {None} + let reader = self.rwu_table.get_reader(self.idx(ln, var)); + if reader.is_valid() { Some(self.ir.lnk(reader)) } else { None } } - /* - Is this variable live on entry to any of its successor nodes? - */ + // Is this variable live on entry to any of its successor nodes? fn live_on_exit(&self, ln: LiveNode, var: Variable) -> Option { let successor = self.successors[ln.get()]; @@ -680,14 +769,14 @@ fn used_on_entry(&self, ln: LiveNode, var: Variable) -> bool { assert!(ln.is_valid()); - self.users[self.idx(ln, var)].used + self.rwu_table.get_used(self.idx(ln, var)) } fn assigned_on_entry(&self, ln: LiveNode, var: Variable) -> Option { assert!(ln.is_valid()); - let writer = self.users[self.idx(ln, var)].writer; - if writer.is_valid() {Some(self.ir.lnk(writer))} else {None} + let writer = self.rwu_table.get_writer(self.idx(ln, var)); + if writer.is_valid() { Some(self.ir.lnk(writer)) } else { None } } fn assigned_on_exit(&self, ln: LiveNode, var: Variable) @@ -730,9 +819,9 @@ { let wr = &mut wr as &mut dyn Write; write!(wr, "[ln({:?}) of kind {:?} reads", ln.get(), self.ir.lnk(ln)); - self.write_vars(wr, ln, |idx| self.users[idx].reader); + self.write_vars(wr, ln, |idx| self.rwu_table.get_reader(idx)); write!(wr, " writes"); - self.write_vars(wr, ln, |idx| self.users[idx].writer); + self.write_vars(wr, ln, |idx| self.rwu_table.get_writer(idx)); write!(wr, " precedes {:?}]", self.successors[ln.get()]); } String::from_utf8(wr).unwrap() @@ -741,14 +830,9 @@ fn init_empty(&mut self, ln: LiveNode, succ_ln: LiveNode) { self.successors[ln.get()] = succ_ln; - // It is not necessary to initialize the - // values to empty because this is the value - // they have when they are created, and the sets - // only grow during iterations. - // - // self.indices(ln) { |idx| - // self.users[idx] = invalid_users(); - // } + // It is not necessary to initialize the RWUs here because they are all + // set to INV_INV_FALSE when they are created, and the sets only grow + // during iterations. } fn init_from_succ(&mut self, ln: LiveNode, succ_ln: LiveNode) { @@ -756,7 +840,7 @@ self.successors[ln.get()] = succ_ln; self.indices2(ln, succ_ln, |this, idx, succ_idx| { - this.users[idx] = this.users[succ_idx] + this.rwu_table.copy_packed(idx, succ_idx); }); debug!("init_from_succ(ln={}, succ={})", self.ln_str(ln), self.ln_str(succ_ln)); @@ -771,28 +855,31 @@ let mut changed = false; self.indices2(ln, succ_ln, |this, idx, succ_idx| { - changed |= copy_if_invalid(this.users[succ_idx].reader, - &mut this.users[idx].reader); - changed |= copy_if_invalid(this.users[succ_idx].writer, - &mut this.users[idx].writer); - if this.users[succ_idx].used && !this.users[idx].used { - this.users[idx].used = true; + let mut rwu = this.rwu_table.get(idx); + let succ_rwu = this.rwu_table.get(succ_idx); + if succ_rwu.reader.is_valid() && !rwu.reader.is_valid() { + rwu.reader = succ_rwu.reader; + changed = true + } + + if succ_rwu.writer.is_valid() && !rwu.writer.is_valid() { + rwu.writer = succ_rwu.writer; + changed = true + } + + if succ_rwu.used && !rwu.used { + rwu.used = true; changed = true; } + + if changed { + this.rwu_table.assign_unpacked(idx, rwu); + } }); debug!("merge_from_succ(ln={:?}, succ={}, first_merge={}, changed={})", ln, self.ln_str(succ_ln), first_merge, changed); return changed; - - fn copy_if_invalid(src: LiveNode, dst: &mut LiveNode) -> bool { - if src.is_valid() && !dst.is_valid() { - *dst = src; - true - } else { - false - } - } } // Indicates that a local variable was *defined*; we know that no @@ -800,8 +887,7 @@ // this) so we just clear out all the data. fn define(&mut self, writer: LiveNode, var: Variable) { let idx = self.idx(writer, var); - self.users[idx].reader = invalid_node(); - self.users[idx].writer = invalid_node(); + self.rwu_table.assign_inv_inv(idx); debug!("{:?} defines {:?} (idx={}): {}", writer, var, idx, self.ln_str(writer)); @@ -813,25 +899,25 @@ ln, acc, var, self.ln_str(ln)); let idx = self.idx(ln, var); - let user = &mut self.users[idx]; + let mut rwu = self.rwu_table.get(idx); if (acc & ACC_WRITE) != 0 { - user.reader = invalid_node(); - user.writer = ln; + rwu.reader = invalid_node(); + rwu.writer = ln; } // Important: if we both read/write, must do read second // or else the write will override. if (acc & ACC_READ) != 0 { - user.reader = ln; + rwu.reader = ln; } if (acc & ACC_USE) != 0 { - user.used = true; + rwu.used = true; } - } - // _______________________________________________________________________ + self.rwu_table.assign_unpacked(idx, rwu); + } fn compute(&mut self, body: &hir::Expr) -> LiveNode { // if there is a `break` or `again` at the top level, then it's @@ -854,10 +940,9 @@ let entry_ln = self.propagate_through_expr(body, s.fallthrough_ln); // hack to skip the loop unless debug! is enabled: - debug!("^^ liveness computation results for body {} (entry={:?})", - { + debug!("^^ liveness computation results for body {} (entry={:?})", { for ln_idx in 0..self.ir.num_live_nodes { - debug!("{:?}", self.ln_str(LiveNode(ln_idx as u32))); + debug!("{:?}", self.ln_str(LiveNode(ln_idx as u32))); } body.id }, @@ -939,241 +1024,232 @@ debug!("propagate_through_expr: {}", self.ir.tcx.hir.node_to_pretty_string(expr.id)); match expr.node { - // Interesting cases with control flow or which gen/kill - hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { - self.access_path(expr.hir_id, path, succ, ACC_READ | ACC_USE) - } - - hir::ExprKind::Field(ref e, _) => { - self.propagate_through_expr(&e, succ) - } + // Interesting cases with control flow or which gen/kill + hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { + self.access_path(expr.hir_id, path, succ, ACC_READ | ACC_USE) + } - hir::ExprKind::Closure(.., blk_id, _, _) => { - debug!("{} is an ExprKind::Closure", self.ir.tcx.hir.node_to_pretty_string(expr.id)); + hir::ExprKind::Field(ref e, _) => { + self.propagate_through_expr(&e, succ) + } - // The next-node for a break is the successor of the entire - // loop. The next-node for a continue is the top of this loop. - let node = self.live_node(expr.hir_id, expr.span); - - let break_ln = succ; - let cont_ln = node; - self.break_ln.insert(blk_id.node_id, break_ln); - self.cont_ln.insert(blk_id.node_id, cont_ln); - - // the construction of a closure itself is not important, - // but we have to consider the closed over variables. - let caps = match self.ir.capture_info_map.get(&expr.id) { - Some(caps) => caps.clone(), - None => { - span_bug!(expr.span, "no registered caps"); - } - }; - caps.iter().rev().fold(succ, |succ, cap| { - self.init_from_succ(cap.ln, succ); - let var = self.variable(cap.var_hid, expr.span); - self.acc(cap.ln, var, ACC_READ | ACC_USE); - cap.ln - }) - } + hir::ExprKind::Closure(.., blk_id, _, _) => { + debug!("{} is an ExprKind::Closure", + self.ir.tcx.hir.node_to_pretty_string(expr.id)); + + // The next-node for a break is the successor of the entire + // loop. The next-node for a continue is the top of this loop. + let node = self.live_node(expr.hir_id, expr.span); + + let break_ln = succ; + let cont_ln = node; + self.break_ln.insert(blk_id.node_id, break_ln); + self.cont_ln.insert(blk_id.node_id, cont_ln); + + // the construction of a closure itself is not important, + // but we have to consider the closed over variables. + let caps = self.ir.capture_info_map.get(&expr.id).cloned().unwrap_or_else(|| + span_bug!(expr.span, "no registered caps")); + + caps.iter().rev().fold(succ, |succ, cap| { + self.init_from_succ(cap.ln, succ); + let var = self.variable(cap.var_hid, expr.span); + self.acc(cap.ln, var, ACC_READ | ACC_USE); + cap.ln + }) + } - hir::ExprKind::If(ref cond, ref then, ref els) => { - // - // (cond) - // | - // v - // (expr) - // / \ - // | | - // v v - // (then)(els) - // | | - // v v - // ( succ ) - // - let else_ln = self.propagate_through_opt_expr(els.as_ref().map(|e| &**e), succ); - let then_ln = self.propagate_through_expr(&then, succ); - let ln = self.live_node(expr.hir_id, expr.span); - self.init_from_succ(ln, else_ln); - self.merge_from_succ(ln, then_ln, false); - self.propagate_through_expr(&cond, ln) - } + hir::ExprKind::If(ref cond, ref then, ref els) => { + // + // (cond) + // | + // v + // (expr) + // / \ + // | | + // v v + // (then)(els) + // | | + // v v + // ( succ ) + // + let else_ln = self.propagate_through_opt_expr(els.as_ref().map(|e| &**e), succ); + let then_ln = self.propagate_through_expr(&then, succ); + let ln = self.live_node(expr.hir_id, expr.span); + self.init_from_succ(ln, else_ln); + self.merge_from_succ(ln, then_ln, false); + self.propagate_through_expr(&cond, ln) + } - hir::ExprKind::While(ref cond, ref blk, _) => { - self.propagate_through_loop(expr, WhileLoop(&cond), &blk, succ) - } + hir::ExprKind::While(ref cond, ref blk, _) => { + self.propagate_through_loop(expr, WhileLoop(&cond), &blk, succ) + } - // Note that labels have been resolved, so we don't need to look - // at the label ident - hir::ExprKind::Loop(ref blk, _, _) => { - self.propagate_through_loop(expr, LoopLoop, &blk, succ) - } + // Note that labels have been resolved, so we don't need to look + // at the label ident + hir::ExprKind::Loop(ref blk, _, _) => { + self.propagate_through_loop(expr, LoopLoop, &blk, succ) + } - hir::ExprKind::Match(ref e, ref arms, _) => { - // - // (e) - // | - // v - // (expr) - // / | \ - // | | | - // v v v - // (..arms..) - // | | | - // v v v - // ( succ ) - // - // - let ln = self.live_node(expr.hir_id, expr.span); - self.init_empty(ln, succ); - let mut first_merge = true; - for arm in arms { - let body_succ = - self.propagate_through_expr(&arm.body, succ); - let guard_succ = - self.propagate_through_opt_expr( - arm.guard.as_ref().map(|g| - match g { - hir::Guard::If(e) => &**e, - }), - body_succ); - // only consider the first pattern; any later patterns must have - // the same bindings, and we also consider the first pattern to be - // the "authoritative" set of ids - let arm_succ = - self.define_bindings_in_arm_pats(arm.pats.first().map(|p| &**p), - guard_succ); - self.merge_from_succ(ln, arm_succ, first_merge); - first_merge = false; - }; - self.propagate_through_expr(&e, ln) - } + hir::ExprKind::Match(ref e, ref arms, _) => { + // + // (e) + // | + // v + // (expr) + // / | \ + // | | | + // v v v + // (..arms..) + // | | | + // v v v + // ( succ ) + // + // + let ln = self.live_node(expr.hir_id, expr.span); + self.init_empty(ln, succ); + let mut first_merge = true; + for arm in arms { + let body_succ = self.propagate_through_expr(&arm.body, succ); + + let guard_succ = self.propagate_through_opt_expr( + arm.guard.as_ref().map(|hir::Guard::If(e)| &**e), + body_succ + ); + // only consider the first pattern; any later patterns must have + // the same bindings, and we also consider the first pattern to be + // the "authoritative" set of ids + let arm_succ = + self.define_bindings_in_arm_pats(arm.pats.first().map(|p| &**p), + guard_succ); + self.merge_from_succ(ln, arm_succ, first_merge); + first_merge = false; + }; + self.propagate_through_expr(&e, ln) + } - hir::ExprKind::Ret(ref o_e) => { - // ignore succ and subst exit_ln: - let exit_ln = self.s.exit_ln; - self.propagate_through_opt_expr(o_e.as_ref().map(|e| &**e), exit_ln) - } + hir::ExprKind::Ret(ref o_e) => { + // ignore succ and subst exit_ln: + let exit_ln = self.s.exit_ln; + self.propagate_through_opt_expr(o_e.as_ref().map(|e| &**e), exit_ln) + } - hir::ExprKind::Break(label, ref opt_expr) => { - // Find which label this break jumps to - let target = match label.target_id { + hir::ExprKind::Break(label, ref opt_expr) => { + // Find which label this break jumps to + let target = match label.target_id { Ok(node_id) => self.break_ln.get(&node_id), Err(err) => span_bug!(expr.span, "loop scope error: {}", err), - }.map(|x| *x); + }.cloned(); - // Now that we know the label we're going to, - // look it up in the break loop nodes table - - match target { - Some(b) => self.propagate_through_opt_expr(opt_expr.as_ref().map(|e| &**e), b), - None => span_bug!(expr.span, "break to unknown label") - } - } + // Now that we know the label we're going to, + // look it up in the break loop nodes table - hir::ExprKind::Continue(label) => { - // Find which label this expr continues to - let sc = match label.target_id { - Ok(node_id) => node_id, - Err(err) => span_bug!(expr.span, "loop scope error: {}", err), - }; - - // Now that we know the label we're going to, - // look it up in the continue loop nodes table - - match self.cont_ln.get(&sc) { - Some(&b) => b, - None => span_bug!(expr.span, "continue to unknown label") - } - } + match target { + Some(b) => self.propagate_through_opt_expr(opt_expr.as_ref().map(|e| &**e), b), + None => span_bug!(expr.span, "break to unknown label") + } + } - hir::ExprKind::Assign(ref l, ref r) => { - // see comment on places in - // propagate_through_place_components() - let succ = self.write_place(&l, succ, ACC_WRITE); - let succ = self.propagate_through_place_components(&l, succ); - self.propagate_through_expr(&r, succ) - } + hir::ExprKind::Continue(label) => { + // Find which label this expr continues to + let sc = label.target_id.unwrap_or_else(|err| + span_bug!(expr.span, "loop scope error: {}", err)); + + // Now that we know the label we're going to, + // look it up in the continue loop nodes table + self.cont_ln.get(&sc).cloned().unwrap_or_else(|| + span_bug!(expr.span, "continue to unknown label")) + } - hir::ExprKind::AssignOp(_, ref l, ref r) => { - // an overloaded assign op is like a method call - if self.tables.is_method_call(expr) { - let succ = self.propagate_through_expr(&l, succ); - self.propagate_through_expr(&r, succ) - } else { + hir::ExprKind::Assign(ref l, ref r) => { // see comment on places in // propagate_through_place_components() - let succ = self.write_place(&l, succ, ACC_WRITE|ACC_READ); - let succ = self.propagate_through_expr(&r, succ); - self.propagate_through_place_components(&l, succ) + let succ = self.write_place(&l, succ, ACC_WRITE); + let succ = self.propagate_through_place_components(&l, succ); + self.propagate_through_expr(&r, succ) } - } - // Uninteresting cases: just propagate in rev exec order + hir::ExprKind::AssignOp(_, ref l, ref r) => { + // an overloaded assign op is like a method call + if self.tables.is_method_call(expr) { + let succ = self.propagate_through_expr(&l, succ); + self.propagate_through_expr(&r, succ) + } else { + // see comment on places in + // propagate_through_place_components() + let succ = self.write_place(&l, succ, ACC_WRITE|ACC_READ); + let succ = self.propagate_through_expr(&r, succ); + self.propagate_through_place_components(&l, succ) + } + } - hir::ExprKind::Array(ref exprs) => { - self.propagate_through_exprs(exprs, succ) - } + // Uninteresting cases: just propagate in rev exec order - hir::ExprKind::Struct(_, ref fields, ref with_expr) => { - let succ = self.propagate_through_opt_expr(with_expr.as_ref().map(|e| &**e), succ); - fields.iter().rev().fold(succ, |succ, field| { - self.propagate_through_expr(&field.expr, succ) - }) - } + hir::ExprKind::Array(ref exprs) => { + self.propagate_through_exprs(exprs, succ) + } - hir::ExprKind::Call(ref f, ref args) => { - // FIXME(canndrew): This is_never should really be an is_uninhabited - let succ = if self.tables.expr_ty(expr).is_never() { - self.s.exit_ln - } else { - succ - }; - let succ = self.propagate_through_exprs(args, succ); - self.propagate_through_expr(&f, succ) - } + hir::ExprKind::Struct(_, ref fields, ref with_expr) => { + let succ = self.propagate_through_opt_expr(with_expr.as_ref().map(|e| &**e), succ); + fields.iter().rev().fold(succ, |succ, field| { + self.propagate_through_expr(&field.expr, succ) + }) + } - hir::ExprKind::MethodCall(.., ref args) => { - // FIXME(canndrew): This is_never should really be an is_uninhabited - let succ = if self.tables.expr_ty(expr).is_never() { - self.s.exit_ln - } else { - succ - }; - self.propagate_through_exprs(args, succ) - } + hir::ExprKind::Call(ref f, ref args) => { + // FIXME(canndrew): This is_never should really be an is_uninhabited + let succ = if self.tables.expr_ty(expr).is_never() { + self.s.exit_ln + } else { + succ + }; + let succ = self.propagate_through_exprs(args, succ); + self.propagate_through_expr(&f, succ) + } - hir::ExprKind::Tup(ref exprs) => { - self.propagate_through_exprs(exprs, succ) - } + hir::ExprKind::MethodCall(.., ref args) => { + // FIXME(canndrew): This is_never should really be an is_uninhabited + let succ = if self.tables.expr_ty(expr).is_never() { + self.s.exit_ln + } else { + succ + }; - hir::ExprKind::Binary(op, ref l, ref r) if op.node.is_lazy() => { - let r_succ = self.propagate_through_expr(&r, succ); + self.propagate_through_exprs(args, succ) + } - let ln = self.live_node(expr.hir_id, expr.span); - self.init_from_succ(ln, succ); - self.merge_from_succ(ln, r_succ, false); + hir::ExprKind::Tup(ref exprs) => { + self.propagate_through_exprs(exprs, succ) + } - self.propagate_through_expr(&l, ln) - } + hir::ExprKind::Binary(op, ref l, ref r) if op.node.is_lazy() => { + let r_succ = self.propagate_through_expr(&r, succ); - hir::ExprKind::Index(ref l, ref r) | - hir::ExprKind::Binary(_, ref l, ref r) => { - let r_succ = self.propagate_through_expr(&r, succ); - self.propagate_through_expr(&l, r_succ) - } + let ln = self.live_node(expr.hir_id, expr.span); + self.init_from_succ(ln, succ); + self.merge_from_succ(ln, r_succ, false); - hir::ExprKind::Box(ref e) | - hir::ExprKind::AddrOf(_, ref e) | - hir::ExprKind::Cast(ref e, _) | - hir::ExprKind::Type(ref e, _) | - hir::ExprKind::Unary(_, ref e) | - hir::ExprKind::Yield(ref e) | - hir::ExprKind::Repeat(ref e, _) => { - self.propagate_through_expr(&e, succ) - } + self.propagate_through_expr(&l, ln) + } + + hir::ExprKind::Index(ref l, ref r) | + hir::ExprKind::Binary(_, ref l, ref r) => { + let r_succ = self.propagate_through_expr(&r, succ); + self.propagate_through_expr(&l, r_succ) + } + + hir::ExprKind::Box(ref e) | + hir::ExprKind::AddrOf(_, ref e) | + hir::ExprKind::Cast(ref e, _) | + hir::ExprKind::Type(ref e, _) | + hir::ExprKind::Unary(_, ref e) | + hir::ExprKind::Yield(ref e) | + hir::ExprKind::Repeat(ref e, _) => { + self.propagate_through_expr(&e, succ) + } - hir::ExprKind::InlineAsm(ref ia, ref outputs, ref inputs) => { - let succ = ia.outputs.iter().zip(outputs).rev().fold(succ, |succ, (o, output)| { + hir::ExprKind::InlineAsm(ref ia, ref outputs, ref inputs) => { + let succ = ia.outputs.iter().zip(outputs).rev().fold(succ, |succ, (o, output)| { // see comment on places // in propagate_through_place_components() if o.is_indirect { @@ -1182,29 +1258,28 @@ let acc = if o.is_rw { ACC_WRITE|ACC_READ } else { ACC_WRITE }; let succ = self.write_place(output, succ, acc); self.propagate_through_place_components(output, succ) - } - }); + }}); - // Inputs are executed first. Propagate last because of rev order - self.propagate_through_exprs(inputs, succ) - } + // Inputs are executed first. Propagate last because of rev order + self.propagate_through_exprs(inputs, succ) + } - hir::ExprKind::Lit(..) | hir::ExprKind::Path(hir::QPath::TypeRelative(..)) => { - succ - } + hir::ExprKind::Lit(..) | hir::ExprKind::Path(hir::QPath::TypeRelative(..)) => { + succ + } - // Note that labels have been resolved, so we don't need to look - // at the label ident - hir::ExprKind::Block(ref blk, _) => { - self.propagate_through_block(&blk, succ) - } + // Note that labels have been resolved, so we don't need to look + // at the label ident + hir::ExprKind::Block(ref blk, _) => { + self.propagate_through_block(&blk, succ) + } } } fn propagate_through_place_components(&mut self, - expr: &Expr, - succ: LiveNode) - -> LiveNode { + expr: &Expr, + succ: LiveNode) + -> LiveNode { // # Places // // In general, the full flow graph structure for an @@ -1262,18 +1337,17 @@ } // see comment on propagate_through_place() - fn write_place(&mut self, expr: &Expr, succ: LiveNode, acc: u32) - -> LiveNode { + fn write_place(&mut self, expr: &Expr, succ: LiveNode, acc: u32) -> LiveNode { match expr.node { - hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { - self.access_path(expr.hir_id, path, succ, acc) - } + hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { + self.access_path(expr.hir_id, path, succ, acc) + } - // We do not track other places, so just propagate through - // to their subcomponents. Also, it may happen that - // non-places occur here, because those are detected in the - // later pass borrowck. - _ => succ + // We do not track other places, so just propagate through + // to their subcomponents. Also, it may happen that + // non-places occur here, because those are detected in the + // later pass borrowck. + _ => succ } } @@ -1292,20 +1366,19 @@ fn access_path(&mut self, hir_id: HirId, path: &hir::Path, succ: LiveNode, acc: u32) -> LiveNode { match path.def { - Def::Local(nid) => { - self.access_var(hir_id, nid, succ, acc, path.span) - } - _ => succ + Def::Local(nid) => { + self.access_var(hir_id, nid, succ, acc, path.span) + } + _ => succ } } fn propagate_through_loop(&mut self, expr: &Expr, - kind: LoopKind, + kind: LoopKind<'_>, body: &hir::Block, succ: LiveNode) -> LiveNode { - /* We model control flow like this: @@ -1363,8 +1436,8 @@ self.propagate_through_expr(&cond, ln) } }; - assert!(cond_ln == new_cond_ln); - assert!(body_ln == self.propagate_through_block(body, cond_ln)); + assert_eq!(cond_ln, new_cond_ln); + assert_eq!(body_ln, self.propagate_through_block(body, cond_ln)); } cond_ln @@ -1418,49 +1491,49 @@ fn check_expr<'a, 'tcx>(this: &mut Liveness<'a, 'tcx>, expr: &'tcx Expr) { match expr.node { - hir::ExprKind::Assign(ref l, _) => { - this.check_place(&l); - - intravisit::walk_expr(this, expr); - } - - hir::ExprKind::AssignOp(_, ref l, _) => { - if !this.tables.is_method_call(expr) { + hir::ExprKind::Assign(ref l, _) => { this.check_place(&l); + + intravisit::walk_expr(this, expr); } - intravisit::walk_expr(this, expr); - } + hir::ExprKind::AssignOp(_, ref l, _) => { + if !this.tables.is_method_call(expr) { + this.check_place(&l); + } - hir::ExprKind::InlineAsm(ref ia, ref outputs, ref inputs) => { - for input in inputs { - this.visit_expr(input); + intravisit::walk_expr(this, expr); } - // Output operands must be places - for (o, output) in ia.outputs.iter().zip(outputs) { - if !o.is_indirect { - this.check_place(output); - } - this.visit_expr(output); - } + hir::ExprKind::InlineAsm(ref ia, ref outputs, ref inputs) => { + for input in inputs { + this.visit_expr(input); + } - intravisit::walk_expr(this, expr); - } + // Output operands must be places + for (o, output) in ia.outputs.iter().zip(outputs) { + if !o.is_indirect { + this.check_place(output); + } + this.visit_expr(output); + } - // no correctness conditions related to liveness - hir::ExprKind::Call(..) | hir::ExprKind::MethodCall(..) | hir::ExprKind::If(..) | - hir::ExprKind::Match(..) | hir::ExprKind::While(..) | hir::ExprKind::Loop(..) | - hir::ExprKind::Index(..) | hir::ExprKind::Field(..) | - hir::ExprKind::Array(..) | hir::ExprKind::Tup(..) | hir::ExprKind::Binary(..) | - hir::ExprKind::Cast(..) | hir::ExprKind::Unary(..) | hir::ExprKind::Ret(..) | - hir::ExprKind::Break(..) | hir::ExprKind::Continue(..) | hir::ExprKind::Lit(_) | - hir::ExprKind::Block(..) | hir::ExprKind::AddrOf(..) | - hir::ExprKind::Struct(..) | hir::ExprKind::Repeat(..) | - hir::ExprKind::Closure(..) | hir::ExprKind::Path(_) | hir::ExprKind::Yield(..) | - hir::ExprKind::Box(..) | hir::ExprKind::Type(..) => { - intravisit::walk_expr(this, expr); - } + intravisit::walk_expr(this, expr); + } + + // no correctness conditions related to liveness + hir::ExprKind::Call(..) | hir::ExprKind::MethodCall(..) | hir::ExprKind::If(..) | + hir::ExprKind::Match(..) | hir::ExprKind::While(..) | hir::ExprKind::Loop(..) | + hir::ExprKind::Index(..) | hir::ExprKind::Field(..) | + hir::ExprKind::Array(..) | hir::ExprKind::Tup(..) | hir::ExprKind::Binary(..) | + hir::ExprKind::Cast(..) | hir::ExprKind::Unary(..) | hir::ExprKind::Ret(..) | + hir::ExprKind::Break(..) | hir::ExprKind::Continue(..) | hir::ExprKind::Lit(_) | + hir::ExprKind::Block(..) | hir::ExprKind::AddrOf(..) | + hir::ExprKind::Struct(..) | hir::ExprKind::Repeat(..) | + hir::ExprKind::Closure(..) | hir::ExprKind::Path(_) | hir::ExprKind::Yield(..) | + hir::ExprKind::Box(..) | hir::ExprKind::Type(..) => { + intravisit::walk_expr(this, expr); + } } } @@ -1489,7 +1562,7 @@ fn should_warn(&self, var: Variable) -> Option { let name = self.ir.variable_name(var); - if name.is_empty() || name.as_bytes()[0] == ('_' as u8) { + if name.is_empty() || name.as_bytes()[0] == b'_' { None } else { Some(name) @@ -1530,7 +1603,6 @@ if !self.used_on_entry(ln, var) { let r = self.should_warn(var); if let Some(name) = r { - // annoying: for parameters in funcs like `fn(x: i32) // {ret}`, there is only one node, so asking about // assigned_on_exit() is not meaningful. @@ -1540,8 +1612,7 @@ self.assigned_on_exit(ln, var).is_some() }; - let suggest_underscore_msg = format!("consider using `_{}` instead", - name); + let suggest_underscore_msg = format!("consider using `_{}` instead", name); if is_assigned { self.ir.tcx diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/middle/mem_categorization.rs rustc-1.31.0+dfsg1+llvm/src/librustc/middle/mem_categorization.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/middle/mem_categorization.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/middle/mem_categorization.rs 2018-12-04 23:41:40.000000000 +0000 @@ -83,6 +83,7 @@ use syntax::ast::{self, Name}; use syntax_pos::Span; +use std::borrow::Cow; use std::fmt; use std::hash::{Hash, Hasher}; use rustc_data_structures::sync::Lrc; @@ -91,13 +92,13 @@ #[derive(Clone, Debug, PartialEq)] pub enum Categorization<'tcx> { - Rvalue(ty::Region<'tcx>), // temporary val, argument is its scope + Rvalue(ty::Region<'tcx>), // temporary val, argument is its scope StaticItem, - Upvar(Upvar), // upvar referenced by closure env - Local(ast::NodeId), // local variable + Upvar(Upvar), // upvar referenced by closure env + Local(ast::NodeId), // local variable Deref(cmt<'tcx>, PointerKind<'tcx>), // deref of a ptr - Interior(cmt<'tcx>, InteriorKind), // something interior: field, tuple, etc - Downcast(cmt<'tcx>, DefId), // selects a particular enum variant (*1) + Interior(cmt<'tcx>, InteriorKind), // something interior: field, tuple, etc + Downcast(cmt<'tcx>, DefId), // selects a particular enum variant (*1) // (*1) downcast is only required if the enum has more than one variant } @@ -149,8 +150,8 @@ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] pub enum InteriorOffsetKind { - Index, // e.g. `array_expr[index_expr]` - Pattern, // e.g. `fn foo([_, a, _, _]: [A; 4]) { ... }` + Index, // e.g. `array_expr[index_expr]` + Pattern, // e.g. `fn foo([_, a, _, _]: [A; 4]) { ... }` } #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] @@ -324,7 +325,7 @@ } fn from_pointer_kind(base_mutbl: MutabilityCategory, - ptr: PointerKind) -> MutabilityCategory { + ptr: PointerKind<'_>) -> MutabilityCategory { let ret = match ptr { Unique => { base_mutbl.inherit() @@ -341,7 +342,8 @@ ret } - fn from_local(tcx: TyCtxt, tables: &ty::TypeckTables, id: ast::NodeId) -> MutabilityCategory { + fn from_local(tcx: TyCtxt<'_, '_, '_>, tables: &ty::TypeckTables<'_>, + id: ast::NodeId) -> MutabilityCategory { let ret = match tcx.hir.get(id) { Node::Binding(p) => match p.node { PatKind::Binding(..) => { @@ -579,7 +581,7 @@ fn helper<'a, 'gcx, 'tcx>(mc: &MemCategorizationContext<'a, 'gcx, 'tcx>, expr: &hir::Expr, adjustments: &[adjustment::Adjustment<'tcx>]) - -> McResult> { + -> McResult> { match adjustments.split_last() { None => mc.cat_expr_unadjusted(expr), Some((adjustment, previous)) => { @@ -639,61 +641,61 @@ let expr_ty = self.expr_ty(expr)?; match expr.node { - hir::ExprKind::Unary(hir::UnDeref, ref e_base) => { - if self.tables.is_method_call(expr) { - self.cat_overloaded_place(expr, e_base, NoteNone) - } else { - let base_cmt = Rc::new(self.cat_expr(&e_base)?); - self.cat_deref(expr, base_cmt, NoteNone) - } - } - - hir::ExprKind::Field(ref base, f_ident) => { - let base_cmt = Rc::new(self.cat_expr(&base)?); - debug!("cat_expr(cat_field): id={} expr={:?} base={:?}", - expr.id, - expr, - base_cmt); - let f_index = self.tcx.field_index(expr.id, self.tables); - Ok(self.cat_field(expr, base_cmt, f_index, f_ident, expr_ty)) - } - - hir::ExprKind::Index(ref base, _) => { - if self.tables.is_method_call(expr) { - // If this is an index implemented by a method call, then it - // will include an implicit deref of the result. - // The call to index() returns a `&T` value, which - // is an rvalue. That is what we will be - // dereferencing. - self.cat_overloaded_place(expr, base, NoteIndex) - } else { + hir::ExprKind::Unary(hir::UnDeref, ref e_base) => { + if self.tables.is_method_call(expr) { + self.cat_overloaded_place(expr, e_base, NoteNone) + } else { + let base_cmt = Rc::new(self.cat_expr(&e_base)?); + self.cat_deref(expr, base_cmt, NoteNone) + } + } + + hir::ExprKind::Field(ref base, f_ident) => { let base_cmt = Rc::new(self.cat_expr(&base)?); - self.cat_index(expr, base_cmt, expr_ty, InteriorOffsetKind::Index) + debug!("cat_expr(cat_field): id={} expr={:?} base={:?}", + expr.id, + expr, + base_cmt); + let f_index = self.tcx.field_index(expr.id, self.tables); + Ok(self.cat_field(expr, base_cmt, f_index, f_ident, expr_ty)) + } + + hir::ExprKind::Index(ref base, _) => { + if self.tables.is_method_call(expr) { + // If this is an index implemented by a method call, then it + // will include an implicit deref of the result. + // The call to index() returns a `&T` value, which + // is an rvalue. That is what we will be + // dereferencing. + self.cat_overloaded_place(expr, base, NoteIndex) + } else { + let base_cmt = Rc::new(self.cat_expr(&base)?); + self.cat_index(expr, base_cmt, expr_ty, InteriorOffsetKind::Index) + } } - } - hir::ExprKind::Path(ref qpath) => { - let def = self.tables.qpath_def(qpath, expr.hir_id); - self.cat_def(expr.hir_id, expr.span, expr_ty, def) - } - - hir::ExprKind::Type(ref e, _) => { - self.cat_expr(&e) - } - - hir::ExprKind::AddrOf(..) | hir::ExprKind::Call(..) | - hir::ExprKind::Assign(..) | hir::ExprKind::AssignOp(..) | - hir::ExprKind::Closure(..) | hir::ExprKind::Ret(..) | - hir::ExprKind::Unary(..) | hir::ExprKind::Yield(..) | - hir::ExprKind::MethodCall(..) | hir::ExprKind::Cast(..) | - hir::ExprKind::Array(..) | hir::ExprKind::Tup(..) | hir::ExprKind::If(..) | - hir::ExprKind::Binary(..) | hir::ExprKind::While(..) | - hir::ExprKind::Block(..) | hir::ExprKind::Loop(..) | hir::ExprKind::Match(..) | - hir::ExprKind::Lit(..) | hir::ExprKind::Break(..) | - hir::ExprKind::Continue(..) | hir::ExprKind::Struct(..) | hir::ExprKind::Repeat(..) | - hir::ExprKind::InlineAsm(..) | hir::ExprKind::Box(..) => { - Ok(self.cat_rvalue_node(expr.hir_id, expr.span, expr_ty)) - } + hir::ExprKind::Path(ref qpath) => { + let def = self.tables.qpath_def(qpath, expr.hir_id); + self.cat_def(expr.hir_id, expr.span, expr_ty, def) + } + + hir::ExprKind::Type(ref e, _) => { + self.cat_expr(&e) + } + + hir::ExprKind::AddrOf(..) | hir::ExprKind::Call(..) | + hir::ExprKind::Assign(..) | hir::ExprKind::AssignOp(..) | + hir::ExprKind::Closure(..) | hir::ExprKind::Ret(..) | + hir::ExprKind::Unary(..) | hir::ExprKind::Yield(..) | + hir::ExprKind::MethodCall(..) | hir::ExprKind::Cast(..) | + hir::ExprKind::Array(..) | hir::ExprKind::Tup(..) | hir::ExprKind::If(..) | + hir::ExprKind::Binary(..) | hir::ExprKind::While(..) | + hir::ExprKind::Block(..) | hir::ExprKind::Loop(..) | hir::ExprKind::Match(..) | + hir::ExprKind::Lit(..) | hir::ExprKind::Break(..) | + hir::ExprKind::Continue(..) | hir::ExprKind::Struct(..) | hir::ExprKind::Repeat(..) | + hir::ExprKind::InlineAsm(..) | hir::ExprKind::Box(..) => { + Ok(self.cat_rvalue_node(expr.hir_id, expr.span, expr_ty)) + } } } @@ -707,44 +709,45 @@ hir_id, expr_ty, def); match def { - Def::StructCtor(..) | Def::VariantCtor(..) | Def::Const(..) | - Def::AssociatedConst(..) | Def::Fn(..) | Def::Method(..) | Def::SelfCtor(..) => { + Def::StructCtor(..) | Def::VariantCtor(..) | Def::Const(..) | + Def::AssociatedConst(..) | Def::Fn(..) | Def::Method(..) | Def::SelfCtor(..) => { Ok(self.cat_rvalue_node(hir_id, span, expr_ty)) - } + } - Def::Static(def_id, mutbl) => { - // `#[thread_local]` statics may not outlive the current function. - for attr in &self.tcx.get_attrs(def_id)[..] { - if attr.check_name("thread_local") { - return Ok(self.cat_rvalue_node(hir_id, span, expr_ty)); + Def::Static(def_id, mutbl) => { + // `#[thread_local]` statics may not outlive the current function. + for attr in &self.tcx.get_attrs(def_id)[..] { + if attr.check_name("thread_local") { + return Ok(self.cat_rvalue_node(hir_id, span, expr_ty)); + } } + + Ok(cmt_ { + hir_id, + span:span, + cat:Categorization::StaticItem, + mutbl: if mutbl { McDeclared } else { McImmutable}, + ty:expr_ty, + note: NoteNone + }) + } + + Def::Upvar(var_id, _, fn_node_id) => { + self.cat_upvar(hir_id, span, var_id, fn_node_id) } - Ok(cmt_ { - hir_id, - span:span, - cat:Categorization::StaticItem, - mutbl: if mutbl { McDeclared } else { McImmutable}, - ty:expr_ty, - note: NoteNone - }) - } - - Def::Upvar(var_id, _, fn_node_id) => { - self.cat_upvar(hir_id, span, var_id, fn_node_id) - } - - Def::Local(vid) => { - Ok(cmt_ { - hir_id, - span, - cat: Categorization::Local(vid), - mutbl: MutabilityCategory::from_local(self.tcx, self.tables, vid), - ty: expr_ty, - note: NoteNone - }) - } - def => span_bug!(span, "unexpected definition in memory categorization: {:?}", def) + Def::Local(vid) => { + Ok(cmt_ { + hir_id, + span, + cat: Categorization::Local(vid), + mutbl: MutabilityCategory::from_local(self.tcx, self.tables, vid), + ty: expr_ty, + note: NoteNone + }) + } + + def => span_bug!(span, "unexpected definition in memory categorization: {:?}", def) } } @@ -940,19 +943,13 @@ span: Span, expr_ty: Ty<'tcx>) -> cmt_<'tcx> { - debug!( - "cat_rvalue_node(id={:?}, span={:?}, expr_ty={:?})", - hir_id, - span, - expr_ty, - ); + debug!("cat_rvalue_node(id={:?}, span={:?}, expr_ty={:?})", + hir_id, span, expr_ty); + let promotable = self.rvalue_promotable_map.as_ref().map(|m| m.contains(&hir_id.local_id)) .unwrap_or(false); - debug!( - "cat_rvalue_node: promotable = {:?}", - promotable, - ); + debug!("cat_rvalue_node: promotable = {:?}", promotable); // Always promote `[T; 0]` (even when e.g. borrowed mutably). let promotable = match expr_ty.sty { @@ -960,10 +957,7 @@ _ => promotable, }; - debug!( - "cat_rvalue_node: promotable = {:?} (2)", - promotable, - ); + debug!("cat_rvalue_node: promotable = {:?} (2)", promotable); // Compute maximum lifetime of this rvalue. This is 'static if // we can promote to a constant, otherwise equal to enclosing temp @@ -1021,12 +1015,10 @@ base: &hir::Expr, note: Note, ) -> McResult> { - debug!( - "cat_overloaded_place(expr={:?}, base={:?}, note={:?})", - expr, - base, - note, - ); + debug!("cat_overloaded_place(expr={:?}, base={:?}, note={:?})", + expr, + base, + note); // Reconstruct the output assuming it's a reference with the // same region and mutability as the receiver. This holds for @@ -1036,9 +1028,7 @@ let (region, mutbl) = match base_ty.sty { ty::Ref(region, _, mutbl) => (region, mutbl), - _ => { - span_bug!(expr.span, "cat_overloaded_place: base is not a reference") - } + _ => span_bug!(expr.span, "cat_overloaded_place: base is not a reference") }; let ref_ty = self.tcx.mk_ref(region, ty::TypeAndMut { ty: place_ty, @@ -1061,8 +1051,7 @@ let deref_ty = match base_cmt_ty.builtin_deref(true) { Some(mt) => mt.ty, None => { - debug!("Explicit deref of non-derefable type: {:?}", - base_cmt_ty); + debug!("Explicit deref of non-derefable type: {:?}", base_cmt_ty); return Err(()); } }; @@ -1119,11 +1108,11 @@ } pub fn cat_imm_interior(&self, - node: &N, - base_cmt: cmt<'tcx>, - interior_ty: Ty<'tcx>, - interior: InteriorKind) - -> cmt_<'tcx> { + node: &N, + base_cmt: cmt<'tcx>, + interior_ty: Ty<'tcx>, + interior: InteriorKind) + -> cmt_<'tcx> { let ret = cmt_ { hir_id: node.hir_id(), span: node.span(), @@ -1137,10 +1126,10 @@ } pub fn cat_downcast_if_needed(&self, - node: &N, - base_cmt: cmt<'tcx>, - variant_did: DefId) - -> cmt<'tcx> { + node: &N, + base_cmt: cmt<'tcx>, + variant_did: DefId) + -> cmt<'tcx> { // univariant enums do not need downcasts let base_did = self.tcx.parent_def_id(variant_did).unwrap(); if self.tcx.adt_def(base_did).variants.len() != 1 { @@ -1276,117 +1265,120 @@ op(cmt.clone(), pat); match pat.node { - PatKind::TupleStruct(ref qpath, ref subpats, ddpos) => { - let def = self.tables.qpath_def(qpath, pat.hir_id); - let (cmt, expected_len) = match def { - Def::Err => { - debug!("access to unresolvable pattern {:?}", pat); - return Err(()) - } - Def::VariantCtor(def_id, CtorKind::Fn) => { - let enum_def = self.tcx.parent_def_id(def_id).unwrap(); - (self.cat_downcast_if_needed(pat, cmt, def_id), - self.tcx.adt_def(enum_def).variant_with_id(def_id).fields.len()) - } - Def::StructCtor(_, CtorKind::Fn) | Def::SelfCtor(..) => { - match self.pat_ty_unadjusted(&pat)?.sty { - ty::Adt(adt_def, _) => { - (cmt, adt_def.non_enum_variant().fields.len()) - } - ref ty => { - span_bug!(pat.span, "tuple struct pattern unexpected type {:?}", ty); + PatKind::TupleStruct(ref qpath, ref subpats, ddpos) => { + let def = self.tables.qpath_def(qpath, pat.hir_id); + let (cmt, expected_len) = match def { + Def::Err => { + debug!("access to unresolvable pattern {:?}", pat); + return Err(()) + } + Def::VariantCtor(def_id, CtorKind::Fn) => { + let enum_def = self.tcx.parent_def_id(def_id).unwrap(); + (self.cat_downcast_if_needed(pat, cmt, def_id), + self.tcx.adt_def(enum_def).variant_with_id(def_id).fields.len()) + } + Def::StructCtor(_, CtorKind::Fn) | Def::SelfCtor(..) => { + match self.pat_ty_unadjusted(&pat)?.sty { + ty::Adt(adt_def, _) => { + (cmt, adt_def.non_enum_variant().fields.len()) + } + ref ty => { + span_bug!(pat.span, + "tuple struct pattern unexpected type {:?}", ty); + } } } + def => { + span_bug!(pat.span, "tuple struct pattern didn't resolve \ + to variant or struct {:?}", def); + } + }; + + for (i, subpat) in subpats.iter().enumerate_and_adjust(expected_len, ddpos) { + let subpat_ty = self.pat_ty_adjusted(&subpat)?; // see (*2) + let interior = InteriorField(FieldIndex(i, Name::intern(&i.to_string()))); + let subcmt = Rc::new( + self.cat_imm_interior(pat, cmt.clone(), subpat_ty, interior)); + self.cat_pattern_(subcmt, &subpat, op)?; } - def => { - span_bug!(pat.span, "tuple struct pattern didn't resolve \ - to variant or struct {:?}", def); + } + + PatKind::Struct(ref qpath, ref field_pats, _) => { + // {f1: p1, ..., fN: pN} + let def = self.tables.qpath_def(qpath, pat.hir_id); + let cmt = match def { + Def::Err => { + debug!("access to unresolvable pattern {:?}", pat); + return Err(()) + }, + Def::Variant(variant_did) | + Def::VariantCtor(variant_did, ..) => { + self.cat_downcast_if_needed(pat, cmt, variant_did) + }, + _ => cmt + }; + + for fp in field_pats { + let field_ty = self.pat_ty_adjusted(&fp.node.pat)?; // see (*2) + let f_index = self.tcx.field_index(fp.node.id, self.tables); + let cmt_field = Rc::new(self.cat_field(pat, cmt.clone(), f_index, + fp.node.ident, field_ty)); + self.cat_pattern_(cmt_field, &fp.node.pat, op)?; } - }; + } - for (i, subpat) in subpats.iter().enumerate_and_adjust(expected_len, ddpos) { - let subpat_ty = self.pat_ty_adjusted(&subpat)?; // see (*2) - let interior = InteriorField(FieldIndex(i, Name::intern(&i.to_string()))); - let subcmt = Rc::new(self.cat_imm_interior(pat, cmt.clone(), subpat_ty, interior)); - self.cat_pattern_(subcmt, &subpat, op)?; + PatKind::Binding(.., Some(ref subpat)) => { + self.cat_pattern_(cmt, &subpat, op)?; } - } - PatKind::Struct(ref qpath, ref field_pats, _) => { - // {f1: p1, ..., fN: pN} - let def = self.tables.qpath_def(qpath, pat.hir_id); - let cmt = match def { - Def::Err => { - debug!("access to unresolvable pattern {:?}", pat); - return Err(()) - }, - Def::Variant(variant_did) | - Def::VariantCtor(variant_did, ..) => { - self.cat_downcast_if_needed(pat, cmt, variant_did) - }, - _ => cmt - }; - - for fp in field_pats { - let field_ty = self.pat_ty_adjusted(&fp.node.pat)?; // see (*2) - let f_index = self.tcx.field_index(fp.node.id, self.tables); - let cmt_field = Rc::new(self.cat_field(pat, cmt.clone(), f_index, - fp.node.ident, field_ty)); - self.cat_pattern_(cmt_field, &fp.node.pat, op)?; - } - } - - PatKind::Binding(.., Some(ref subpat)) => { - self.cat_pattern_(cmt, &subpat, op)?; - } - - PatKind::Tuple(ref subpats, ddpos) => { - // (p1, ..., pN) - let expected_len = match self.pat_ty_unadjusted(&pat)?.sty { - ty::Tuple(ref tys) => tys.len(), - ref ty => span_bug!(pat.span, "tuple pattern unexpected type {:?}", ty), - }; - for (i, subpat) in subpats.iter().enumerate_and_adjust(expected_len, ddpos) { - let subpat_ty = self.pat_ty_adjusted(&subpat)?; // see (*2) - let interior = InteriorField(FieldIndex(i, Name::intern(&i.to_string()))); - let subcmt = Rc::new(self.cat_imm_interior(pat, cmt.clone(), subpat_ty, interior)); + PatKind::Tuple(ref subpats, ddpos) => { + // (p1, ..., pN) + let expected_len = match self.pat_ty_unadjusted(&pat)?.sty { + ty::Tuple(ref tys) => tys.len(), + ref ty => span_bug!(pat.span, "tuple pattern unexpected type {:?}", ty), + }; + for (i, subpat) in subpats.iter().enumerate_and_adjust(expected_len, ddpos) { + let subpat_ty = self.pat_ty_adjusted(&subpat)?; // see (*2) + let interior = InteriorField(FieldIndex(i, Name::intern(&i.to_string()))); + let subcmt = Rc::new( + self.cat_imm_interior(pat, cmt.clone(), subpat_ty, interior)); + self.cat_pattern_(subcmt, &subpat, op)?; + } + } + + PatKind::Box(ref subpat) | PatKind::Ref(ref subpat, _) => { + // box p1, &p1, &mut p1. we can ignore the mutability of + // PatKind::Ref since that information is already contained + // in the type. + let subcmt = Rc::new(self.cat_deref(pat, cmt, NoteNone)?); self.cat_pattern_(subcmt, &subpat, op)?; } - } - PatKind::Box(ref subpat) | PatKind::Ref(ref subpat, _) => { - // box p1, &p1, &mut p1. we can ignore the mutability of - // PatKind::Ref since that information is already contained - // in the type. - let subcmt = Rc::new(self.cat_deref(pat, cmt, NoteNone)?); - self.cat_pattern_(subcmt, &subpat, op)?; - } - - PatKind::Slice(ref before, ref slice, ref after) => { - let element_ty = match cmt.ty.builtin_index() { - Some(ty) => ty, - None => { - debug!("Explicit index of non-indexable type {:?}", cmt); - return Err(()); + PatKind::Slice(ref before, ref slice, ref after) => { + let element_ty = match cmt.ty.builtin_index() { + Some(ty) => ty, + None => { + debug!("Explicit index of non-indexable type {:?}", cmt); + return Err(()); + } + }; + let context = InteriorOffsetKind::Pattern; + let elt_cmt = Rc::new(self.cat_index(pat, cmt, element_ty, context)?); + for before_pat in before { + self.cat_pattern_(elt_cmt.clone(), &before_pat, op)?; + } + if let Some(ref slice_pat) = *slice { + self.cat_pattern_(elt_cmt.clone(), &slice_pat, op)?; } - }; - let context = InteriorOffsetKind::Pattern; - let elt_cmt = Rc::new(self.cat_index(pat, cmt, element_ty, context)?); - for before_pat in before { - self.cat_pattern_(elt_cmt.clone(), &before_pat, op)?; - } - if let Some(ref slice_pat) = *slice { - self.cat_pattern_(elt_cmt.clone(), &slice_pat, op)?; - } - for after_pat in after { - self.cat_pattern_(elt_cmt.clone(), &after_pat, op)?; - } - } - - PatKind::Path(_) | PatKind::Binding(.., None) | - PatKind::Lit(..) | PatKind::Range(..) | PatKind::Wild => { - // always ok - } + for after_pat in after { + self.cat_pattern_(elt_cmt.clone(), &after_pat, op)?; + } + } + + PatKind::Path(_) | PatKind::Binding(.., None) | + PatKind::Lit(..) | PatKind::Range(..) | PatKind::Wild => { + // always ok + } } Ok(()) @@ -1488,65 +1480,65 @@ } } - pub fn descriptive_string(&self, tcx: TyCtxt) -> String { + pub fn descriptive_string(&self, tcx: TyCtxt<'_, '_, '_>) -> Cow<'static, str> { match self.cat { Categorization::StaticItem => { - "static item".to_string() + "static item".into() } Categorization::Rvalue(..) => { - "non-place".to_string() + "non-place".into() } Categorization::Local(vid) => { if tcx.hir.is_argument(vid) { - "argument".to_string() + "argument" } else { - "local variable".to_string() - } + "local variable" + }.into() } Categorization::Deref(_, pk) => { match self.upvar_cat() { Some(&Categorization::Upvar(ref var)) => { - var.to_string() + var.to_string().into() } Some(_) => bug!(), None => { match pk { Unique => { - "`Box` content".to_string() + "`Box` content" } UnsafePtr(..) => { - "dereference of raw pointer".to_string() + "dereference of raw pointer" } BorrowedPtr(..) => { match self.note { - NoteIndex => "indexed content".to_string(), - _ => "borrowed content".to_string(), + NoteIndex => "indexed content", + _ => "borrowed content" } } - } + }.into() } } } Categorization::Interior(_, InteriorField(..)) => { - "field".to_string() + "field".into() } Categorization::Interior(_, InteriorElement(InteriorOffsetKind::Index)) => { - "indexed content".to_string() + "indexed content".into() } Categorization::Interior(_, InteriorElement(InteriorOffsetKind::Pattern)) => { - "pattern-bound indexed content".to_string() + "pattern-bound indexed content".into() } Categorization::Upvar(ref var) => { - var.to_string() + var.to_string().into() } Categorization::Downcast(ref cmt, _) => { - cmt.descriptive_string(tcx) + cmt.descriptive_string(tcx).into() } } } } -pub fn ptr_sigil(ptr: PointerKind) -> &'static str { +pub fn ptr_sigil(ptr: PointerKind<'_>) -> &'static str { match ptr { Unique => "Box", BorrowedPtr(ty::ImmBorrow, _) => "&", @@ -1557,7 +1549,7 @@ } impl fmt::Debug for InteriorKind { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { InteriorField(FieldIndex(_, info)) => write!(f, "{}", info), InteriorElement(..) => write!(f, "[]"), @@ -1566,13 +1558,13 @@ } impl fmt::Debug for Upvar { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{:?}/{:?}", self.id, self.kind) } } impl fmt::Display for Upvar { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let kind = match self.kind { ty::ClosureKind::Fn => "Fn", ty::ClosureKind::FnMut => "FnMut", diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/middle/privacy.rs rustc-1.31.0+dfsg1+llvm/src/librustc/middle/privacy.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/middle/privacy.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/middle/privacy.rs 2018-12-04 23:41:40.000000000 +0000 @@ -59,7 +59,7 @@ } impl fmt::Debug for AccessLevels { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&self.map, f) } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/middle/reachable.rs rustc-1.31.0+dfsg1+llvm/src/librustc/middle/reachable.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/middle/reachable.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/middle/reachable.rs 2018-12-04 23:41:40.000000000 +0000 @@ -207,7 +207,7 @@ // Step 2: Mark all symbols that the symbols on the worklist touch. fn propagate(&mut self) { - let mut scanned = FxHashSet(); + let mut scanned = FxHashSet::default(); while let Some(search_item) = self.worklist.pop() { if !scanned.insert(search_item) { continue @@ -352,7 +352,7 @@ // which are currently akin to allocator symbols. let def_id = self.tcx.hir.local_def_id(item.id); let codegen_attrs = self.tcx.codegen_fn_attrs(def_id); - if codegen_attrs.linkage.is_some() || + if codegen_attrs.contains_extern_indicator() || codegen_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL) { self.worklist.push(item.id); } @@ -371,7 +371,9 @@ return } - for default_method in self.tcx.provided_trait_methods(trait_def_id) { + let provided_trait_methods = self.tcx.provided_trait_methods(trait_def_id); + self.worklist.reserve(provided_trait_methods.len()); + for default_method in provided_trait_methods { let node_id = self.tcx .hir .as_local_node_id(default_method.def_id) @@ -394,7 +396,6 @@ #[derive(Clone)] pub struct ReachableSet(pub Lrc); - fn reachable_set<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) -> ReachableSet { debug_assert!(crate_num == LOCAL_CRATE); @@ -443,7 +444,7 @@ ReachableSet(Lrc::new(reachable_context.reachable_symbols)) } -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers<'_>) { *providers = Providers { reachable_set, ..*providers diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/middle/region.rs rustc-1.31.0+dfsg1+llvm/src/librustc/middle/region.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/middle/region.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/middle/region.rs 2018-12-04 23:41:40.000000000 +0000 @@ -107,7 +107,7 @@ } impl fmt::Debug for Scope { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { match self.data { ScopeData::Node => write!(fmt, "Node({:?})", self.id), ScopeData::CallSite => write!(fmt, "CallSite({:?})", self.id), @@ -167,10 +167,7 @@ impl_stable_hash_for!(struct ::middle::region::FirstStatementIndex { private }); // compilation error if size of `ScopeData` is not the same as a `u32` -#[allow(dead_code)] -// only works on stage 1 when the rustc_layout_scalar_valid_range attribute actually exists -#[cfg(not(stage0))] -static ASSERT: () = [()][!(mem::size_of::() == 4) as usize]; +static_assert!(ASSERT_SCOPE_DATA: mem::size_of::() == 4); impl Scope { /// Returns a item-local id associated with this scope. @@ -181,7 +178,7 @@ self.id } - pub fn node_id(&self, tcx: TyCtxt, scope_tree: &ScopeTree) -> ast::NodeId { + pub fn node_id(&self, tcx: TyCtxt<'_, '_, '_>, scope_tree: &ScopeTree) -> ast::NodeId { match scope_tree.root_body { Some(hir_id) => { tcx.hir.hir_to_node_id(hir::HirId { @@ -196,7 +193,7 @@ /// Returns the span of this Scope. Note that in general the /// returned span may not correspond to the span of any node id in /// the AST. - pub fn span(&self, tcx: TyCtxt, scope_tree: &ScopeTree) -> Span { + pub fn span(&self, tcx: TyCtxt<'_, '_, '_>, scope_tree: &ScopeTree) -> Span { let node_id = self.node_id(tcx, scope_tree); if node_id == ast::DUMMY_NODE_ID { return DUMMY_SP; @@ -461,13 +458,13 @@ } } - pub fn each_encl_scope(&self, mut e:E) where E: FnMut(Scope, Scope) { + pub fn each_encl_scope(&self, mut e: E) where E: FnMut(Scope, Scope) { for (&child, &parent) in &self.parent_map { e(child, parent.0) } } - pub fn each_var_scope(&self, mut e:E) where E: FnMut(&hir::ItemLocalId, Scope) { + pub fn each_var_scope(&self, mut e: E) where E: FnMut(&hir::ItemLocalId, Scope) { for (child, &parent) in self.var_map.iter() { e(child, parent) } @@ -517,10 +514,8 @@ /// Returns the lifetime of the local variable `var_id` pub fn var_scope(&self, var_id: hir::ItemLocalId) -> Scope { - match self.var_map.get(&var_id) { - Some(&r) => r, - None => { bug!("no enclosing scope for id {:?}", var_id); } - } + self.var_map.get(&var_id).cloned().unwrap_or_else(|| + bug!("no enclosing scope for id {:?}", var_id)) } pub fn temporary_scope(&self, expr_id: hir::ItemLocalId) -> Option { @@ -561,8 +556,7 @@ scope } - pub fn scopes_intersect(&self, scope1: Scope, scope2: Scope) - -> bool { + pub fn scopes_intersect(&self, scope1: Scope, scope2: Scope) -> bool { self.is_subscope_of(scope1, scope2) || self.is_subscope_of(scope2, scope1) } @@ -586,14 +580,13 @@ } } - debug!("is_subscope_of({:?}, {:?})=true", - subscope, superscope); + debug!("is_subscope_of({:?}, {:?})=true", subscope, superscope); return true; } /// Returns the id of the innermost containing body - pub fn containing_body(&self, mut scope: Scope)-> Option { + pub fn containing_body(&self, mut scope: Scope) -> Option { loop { if let ScopeData::CallSite = scope.data { return Some(scope.item_local_id()); @@ -666,8 +659,8 @@ /// Assuming that the provided region was defined within this `ScopeTree`, /// returns the outermost `Scope` that the region outlives. pub fn early_free_scope<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, - br: &ty::EarlyBoundRegion) - -> Scope { + br: &ty::EarlyBoundRegion) + -> Scope { let param_owner = tcx.parent_def_id(br.def_id).unwrap(); let param_owner_id = tcx.hir.as_local_node_id(param_owner).unwrap(); @@ -750,7 +743,7 @@ } /// Records the lifetime of a local variable as `cx.var_parent` -fn record_var_lifetime(visitor: &mut RegionResolutionVisitor, +fn record_var_lifetime(visitor: &mut RegionResolutionVisitor<'_, '_>, var_id: hir::ItemLocalId, _sp: Span) { match visitor.cx.var_parent { @@ -830,10 +823,8 @@ fn resolve_arm<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, arm: &'tcx hir::Arm) { visitor.terminating_scopes.insert(arm.body.hir_id.local_id); - if let Some(ref g) = arm.guard { - match g { - hir::Guard::If(ref expr) => visitor.terminating_scopes.insert(expr.hir_id.local_id), - }; + if let Some(hir::Guard::If(ref expr)) = arm.guard { + visitor.terminating_scopes.insert(expr.hir_id.local_id); } intravisit::walk_arm(visitor, arm); @@ -892,11 +883,9 @@ // This ensures fixed size stacks. hir::ExprKind::Binary( - source_map::Spanned { node: hir::BinOpKind::And, .. }, - _, ref r) | + source_map::Spanned { node: hir::BinOpKind::And, .. }, _, ref r) | hir::ExprKind::Binary( - source_map::Spanned { node: hir::BinOpKind::Or, .. }, - _, ref r) => { + source_map::Spanned { node: hir::BinOpKind::Or, .. }, _, ref r) => { // For shortcircuiting operators, mark the RHS as a terminating // scope since it only executes conditionally. terminating(r.hir_id.local_id); @@ -1268,7 +1257,7 @@ let outer_ec = mem::replace(&mut self.expr_and_pat_count, 0); let outer_cx = self.cx; - let outer_ts = mem::replace(&mut self.terminating_scopes, FxHashSet()); + let outer_ts = mem::replace(&mut self.terminating_scopes, FxHashSet::default()); self.terminating_scopes.insert(body.value.hir_id.local_id); if let Some(root_id) = self.cx.root_id { @@ -1358,7 +1347,7 @@ parent: None, var_parent: None, }, - terminating_scopes: FxHashSet(), + terminating_scopes: Default::default(), }; let body = tcx.hir.body(body_id); @@ -1385,7 +1374,7 @@ Lrc::new(scope_tree) } -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers<'_>) { *providers = Providers { region_scope_tree, ..*providers diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/middle/resolve_lifetime.rs rustc-1.31.0+dfsg1+llvm/src/librustc/middle/resolve_lifetime.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/middle/resolve_lifetime.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/middle/resolve_lifetime.rs 2018-12-04 23:41:40.000000000 +0000 @@ -18,13 +18,14 @@ use hir::def::Def; use hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE}; use hir::map::Map; -use hir::{GenericArg, GenericParam, ItemLocalId, LifetimeName, ParamName, Node}; -use ty::{self, TyCtxt, GenericParamDefKind}; +use hir::{GenericArg, GenericParam, ItemLocalId, LifetimeName, Node, ParamName}; +use ty::{self, DefIdTree, GenericParamDefKind, TyCtxt}; -use errors::DiagnosticBuilder; +use errors::{Applicability, DiagnosticBuilder}; use rustc::lint; use rustc_data_structures::sync::Lrc; use session::Session; +use std::borrow::Cow; use std::cell::Cell; use std::mem::replace; use syntax::ast; @@ -35,29 +36,30 @@ use util::nodemap::{DefIdMap, FxHashMap, FxHashSet, NodeMap, NodeSet}; use hir::intravisit::{self, NestedVisitorMap, Visitor}; -use hir::{self, GenericParamKind}; +use hir::{self, GenericParamKind, LifetimeParamKind}; /// The origin of a named lifetime definition. /// /// This is used to prevent the usage of in-band lifetimes in `Fn`/`fn` syntax. #[derive(Copy, Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Debug)] pub enum LifetimeDefOrigin { - // Explicit binders like `fn foo<'a>(x: &'a u8)` - Explicit, + // Explicit binders like `fn foo<'a>(x: &'a u8)` or elided like `impl Foo<&u32>` + ExplicitOrElided, // In-band declarations like `fn foo(x: &'a u8)` InBand, + // Some kind of erroneous origin + Error, } impl LifetimeDefOrigin { fn from_param(param: &GenericParam) -> Self { match param.kind { - GenericParamKind::Lifetime { in_band } => { - if in_band { - LifetimeDefOrigin::InBand - } else { - LifetimeDefOrigin::Explicit - } - } + GenericParamKind::Lifetime { kind } => match kind { + LifetimeParamKind::InBand => LifetimeDefOrigin::InBand, + LifetimeParamKind::Explicit => LifetimeDefOrigin::ExplicitOrElided, + LifetimeParamKind::Elided => LifetimeDefOrigin::ExplicitOrElided, + LifetimeParamKind::Error => LifetimeDefOrigin::Error, + }, _ => bug!("expected a lifetime param"), } } @@ -88,7 +90,7 @@ } impl Region { - fn early(hir_map: &Map, index: &mut u32, param: &GenericParam) -> (ParamName, Region) { + fn early(hir_map: &Map<'_>, index: &mut u32, param: &GenericParam) -> (ParamName, Region) { let i = *index; *index += 1; let def_id = hir_map.local_def_id(param.id); @@ -97,18 +99,18 @@ (param.name.modern(), Region::EarlyBound(i, def_id, origin)) } - fn late(hir_map: &Map, param: &GenericParam) -> (ParamName, Region) { + fn late(hir_map: &Map<'_>, param: &GenericParam) -> (ParamName, Region) { let depth = ty::INNERMOST; let def_id = hir_map.local_def_id(param.id); let origin = LifetimeDefOrigin::from_param(param); debug!( "Region::late: param={:?} depth={:?} def_id={:?} origin={:?}", - param, - depth, - def_id, - origin, + param, depth, def_id, origin, ); - (param.name.modern(), Region::LateBound(depth, def_id, origin)) + ( + param.name.modern(), + Region::LateBound(depth, def_id, origin), + ) } fn late_anon(index: &Cell) -> Region { @@ -142,23 +144,24 @@ fn shifted_out_to_binder(self, binder: ty::DebruijnIndex) -> Region { match self { - Region::LateBound(debruijn, id, origin) => Region::LateBound( - debruijn.shifted_out_to_binder(binder), - id, - origin, - ), - Region::LateBoundAnon(debruijn, index) => Region::LateBoundAnon( - debruijn.shifted_out_to_binder(binder), - index, - ), + Region::LateBound(debruijn, id, origin) => { + Region::LateBound(debruijn.shifted_out_to_binder(binder), id, origin) + } + Region::LateBoundAnon(debruijn, index) => { + Region::LateBoundAnon(debruijn.shifted_out_to_binder(binder), index) + } _ => self, } } fn subst<'a, L>(self, mut params: L, map: &NamedRegionMap) -> Option - where L: Iterator { + where + L: Iterator, + { if let Region::EarlyBound(index, _, _) = self { - params.nth(index as usize).and_then(|lifetime| map.defs.get(&lifetime.id).cloned()) + params + .nth(index as usize) + .and_then(|lifetime| map.defs.get(&lifetime.id).cloned()) } else { Some(self) } @@ -215,6 +218,7 @@ } /// See `NamedRegionMap`. +#[derive(Default)] pub struct ResolveLifetimes { defs: FxHashMap>>, late_bound: FxHashMap>>, @@ -348,7 +352,7 @@ const ROOT_SCOPE: ScopeRef<'static> = &Scope::Root; -pub fn provide(providers: &mut ty::query::Providers) { +pub fn provide(providers: &mut ty::query::Providers<'_>) { *providers = ty::query::Providers { resolve_lifetimes, @@ -391,11 +395,7 @@ let named_region_map = krate(tcx); - let mut rl = ResolveLifetimes { - defs: FxHashMap(), - late_bound: FxHashMap(), - object_lifetime_defaults: FxHashMap(), - }; + let mut rl = ResolveLifetimes::default(); for (k, v) in named_region_map.defs { let hir_id = tcx.hir.node_to_hir_id(k); @@ -404,7 +404,9 @@ } for k in named_region_map.late_bound { let hir_id = tcx.hir.node_to_hir_id(k); - let map = rl.late_bound.entry(hir_id.owner_local_def_id()).or_default(); + let map = rl.late_bound + .entry(hir_id.owner_local_def_id()) + .or_default(); Lrc::get_mut(map).unwrap().insert(hir_id.local_id); } for (k, v) in named_region_map.object_lifetime_defaults { @@ -494,13 +496,20 @@ }; self.with(scope, |_, this| intravisit::walk_item(this, item)); } - hir::ItemKind::Existential(hir::ExistTy { impl_trait_fn: Some(_), .. }) => { + hir::ItemKind::Existential(hir::ExistTy { + impl_trait_fn: Some(_), + .. + }) => { // currently existential type declarations are just generated from impl Trait // items. doing anything on this node is irrelevant, as we currently don't need // it. } hir::ItemKind::Ty(_, ref generics) - | hir::ItemKind::Existential(hir::ExistTy { impl_trait_fn: None, ref generics, .. }) + | hir::ItemKind::Existential(hir::ExistTy { + impl_trait_fn: None, + ref generics, + .. + }) | hir::ItemKind::Enum(_, ref generics) | hir::ItemKind::Struct(_, ref generics) | hir::ItemKind::Union(_, ref generics) @@ -520,15 +529,19 @@ 0 }; let mut type_count = 0; - let lifetimes = generics.params.iter().filter_map(|param| match param.kind { - GenericParamKind::Lifetime { .. } => { - Some(Region::early(&self.tcx.hir, &mut index, param)) - } - GenericParamKind::Type { .. } => { - type_count += 1; - None - } - }).collect(); + let lifetimes = generics + .params + .iter() + .filter_map(|param| match param.kind { + GenericParamKind::Lifetime { .. } => { + Some(Region::early(&self.tcx.hir, &mut index, param)) + } + GenericParamKind::Type { .. } => { + type_count += 1; + None + } + }) + .collect(); let scope = Scope::Binder { lifetimes, next_early_index: index + type_count, @@ -568,12 +581,15 @@ let was_in_fn_syntax = self.is_in_fn_syntax; self.is_in_fn_syntax = true; let scope = Scope::Binder { - lifetimes: c.generic_params.iter().filter_map(|param| match param.kind { - GenericParamKind::Lifetime { .. } => { - Some(Region::late(&self.tcx.hir, param)) - } - _ => None, - }).collect(), + lifetimes: c.generic_params + .iter() + .filter_map(|param| match param.kind { + GenericParamKind::Lifetime { .. } => { + Some(Region::late(&self.tcx.hir, param)) + } + _ => None, + }) + .collect(), s: self.scope, next_early_index, track_lifetime_uses: true, @@ -611,6 +627,7 @@ // If the user wrote an explicit name, use that. self.visit_lifetime(lifetime); } + LifetimeName::Error => {} } } hir::TyKind::Rptr(ref lifetime_ref, ref mt) => { @@ -621,140 +638,135 @@ }; self.with(scope, |_, this| this.visit_ty(&mt.ty)); } - hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => { - if let Def::Existential(exist_ty_did) = path.def { - let id = self.tcx.hir.as_local_node_id(exist_ty_did).unwrap(); - - // Resolve the lifetimes in the bounds to the lifetime defs in the generics. - // `fn foo<'a>() -> impl MyTrait<'a> { ... }` desugars to - // `abstract type MyAnonTy<'b>: MyTrait<'b>;` - // ^ ^ this gets resolved in the scope of - // the exist_ty generics - let (generics, bounds) = match self.tcx.hir.expect_item(id).node { - // named existential types don't need these hacks - hir::ItemKind::Existential(hir::ExistTy{ impl_trait_fn: None, .. }) => { - intravisit::walk_ty(self, ty); - return; - }, - hir::ItemKind::Existential(hir::ExistTy{ - ref generics, - ref bounds, - .. - }) => ( - generics, - bounds, - ), - ref i => bug!("impl Trait pointed to non-existential type?? {:#?}", i), - }; + hir::TyKind::Def(item_id, ref lifetimes) => { + // Resolve the lifetimes in the bounds to the lifetime defs in the generics. + // `fn foo<'a>() -> impl MyTrait<'a> { ... }` desugars to + // `abstract type MyAnonTy<'b>: MyTrait<'b>;` + // ^ ^ this gets resolved in the scope of + // the exist_ty generics + let (generics, bounds) = match self.tcx.hir.expect_item(item_id.id).node { + // named existential types are reached via TyKind::Path + // this arm is for `impl Trait` in the types of statics, constants and locals + hir::ItemKind::Existential(hir::ExistTy { + impl_trait_fn: None, + .. + }) => { + intravisit::walk_ty(self, ty); + return; + } + // RPIT (return position impl trait) + hir::ItemKind::Existential(hir::ExistTy { + ref generics, + ref bounds, + .. + }) => (generics, bounds), + ref i => bug!("impl Trait pointed to non-existential type?? {:#?}", i), + }; - assert!(exist_ty_did.is_local()); - // Resolve the lifetimes that are applied to the existential type. - // These are resolved in the current scope. - // `fn foo<'a>() -> impl MyTrait<'a> { ... }` desugars to - // `fn foo<'a>() -> MyAnonTy<'a> { ... }` - // ^ ^this gets resolved in the current scope - for lifetime in &path.segments[0].args.as_ref().unwrap().args { - if let hir::GenericArg::Lifetime(lifetime) = lifetime { - self.visit_lifetime(lifetime); - - // Check for predicates like `impl for<'a> Trait>` - // and ban them. Type variables instantiated inside binders aren't - // well-supported at the moment, so this doesn't work. - // In the future, this should be fixed and this error should be removed. - let def = self.map.defs.get(&lifetime.id).cloned(); - if let Some(Region::LateBound(_, def_id, _)) = def { - if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { - // Ensure that the parent of the def is an item, not HRTB - let parent_id = self.tcx.hir.get_parent_node(node_id); - let parent_impl_id = hir::ImplItemId { node_id: parent_id }; - let parent_trait_id = hir::TraitItemId { node_id: parent_id }; - let krate = self.tcx.hir.forest.krate(); - if !(krate.items.contains_key(&parent_id) - || krate.impl_items.contains_key(&parent_impl_id) - || krate.trait_items.contains_key(&parent_trait_id)) - { - span_err!( - self.tcx.sess, - lifetime.span, - E0657, - "`impl Trait` can only capture lifetimes \ - bound at the fn or impl level" - ); - self.uninsert_lifetime_on_error(lifetime, def.unwrap()); - } + // Resolve the lifetimes that are applied to the existential type. + // These are resolved in the current scope. + // `fn foo<'a>() -> impl MyTrait<'a> { ... }` desugars to + // `fn foo<'a>() -> MyAnonTy<'a> { ... }` + // ^ ^this gets resolved in the current scope + for lifetime in lifetimes { + if let hir::GenericArg::Lifetime(lifetime) = lifetime { + self.visit_lifetime(lifetime); + + // Check for predicates like `impl for<'a> Trait>` + // and ban them. Type variables instantiated inside binders aren't + // well-supported at the moment, so this doesn't work. + // In the future, this should be fixed and this error should be removed. + let def = self.map.defs.get(&lifetime.id).cloned(); + if let Some(Region::LateBound(_, def_id, _)) = def { + if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { + // Ensure that the parent of the def is an item, not HRTB + let parent_id = self.tcx.hir.get_parent_node(node_id); + let parent_impl_id = hir::ImplItemId { node_id: parent_id }; + let parent_trait_id = hir::TraitItemId { node_id: parent_id }; + let krate = self.tcx.hir.forest.krate(); + if !(krate.items.contains_key(&parent_id) + || krate.impl_items.contains_key(&parent_impl_id) + || krate.trait_items.contains_key(&parent_trait_id)) + { + span_err!( + self.tcx.sess, + lifetime.span, + E0657, + "`impl Trait` can only capture lifetimes \ + bound at the fn or impl level" + ); + self.uninsert_lifetime_on_error(lifetime, def.unwrap()); } } } } + } - // We want to start our early-bound indices at the end of the parent scope, - // not including any parent `impl Trait`s. - let mut index = self.next_early_index_for_abstract_type(); - debug!("visit_ty: index = {}", index); - - let mut elision = None; - let mut lifetimes = FxHashMap(); - let mut type_count = 0; - for param in &generics.params { - match param.kind { - GenericParamKind::Lifetime { .. } => { - let (name, reg) = Region::early(&self.tcx.hir, &mut index, ¶m); - if let hir::ParamName::Plain(param_name) = name { - if param_name.name == keywords::UnderscoreLifetime.name() { - // Pick the elided lifetime "definition" if one exists - // and use it to make an elision scope. - elision = Some(reg); - } else { - lifetimes.insert(name, reg); - } + // We want to start our early-bound indices at the end of the parent scope, + // not including any parent `impl Trait`s. + let mut index = self.next_early_index_for_abstract_type(); + debug!("visit_ty: index = {}", index); + + let mut elision = None; + let mut lifetimes = FxHashMap::default(); + let mut type_count = 0; + for param in &generics.params { + match param.kind { + GenericParamKind::Lifetime { .. } => { + let (name, reg) = Region::early(&self.tcx.hir, &mut index, ¶m); + if let hir::ParamName::Plain(param_name) = name { + if param_name.name == keywords::UnderscoreLifetime.name() { + // Pick the elided lifetime "definition" if one exists + // and use it to make an elision scope. + elision = Some(reg); } else { lifetimes.insert(name, reg); } - } - GenericParamKind::Type { .. } => { - type_count += 1; + } else { + lifetimes.insert(name, reg); } } + GenericParamKind::Type { .. } => { + type_count += 1; + } } - let next_early_index = index + type_count; + } + let next_early_index = index + type_count; - if let Some(elision_region) = elision { - let scope = Scope::Elision { - elide: Elide::Exact(elision_region), - s: self.scope, - }; - self.with(scope, |_old_scope, this| { - let scope = Scope::Binder { - lifetimes, - next_early_index, - s: this.scope, - track_lifetime_uses: true, - abstract_type_parent: false, - }; - this.with(scope, |_old_scope, this| { - this.visit_generics(generics); - for bound in bounds { - this.visit_param_bound(bound); - } - }); - }); - } else { + if let Some(elision_region) = elision { + let scope = Scope::Elision { + elide: Elide::Exact(elision_region), + s: self.scope, + }; + self.with(scope, |_old_scope, this| { let scope = Scope::Binder { lifetimes, next_early_index, - s: self.scope, + s: this.scope, track_lifetime_uses: true, abstract_type_parent: false, }; - self.with(scope, |_old_scope, this| { + this.with(scope, |_old_scope, this| { this.visit_generics(generics); for bound in bounds { this.visit_param_bound(bound); } }); - } + }); } else { - intravisit::walk_ty(self, ty) + let scope = Scope::Binder { + lifetimes, + next_early_index, + s: self.scope, + track_lifetime_uses: true, + abstract_type_parent: false, + }; + self.with(scope, |_old_scope, this| { + this.visit_generics(generics); + for bound in bounds { + this.visit_param_bound(bound); + } + }); } } _ => intravisit::walk_ty(self, ty), @@ -778,15 +790,19 @@ let mut index = self.next_early_index(); debug!("visit_ty: index = {}", index); let mut type_count = 0; - let lifetimes = generics.params.iter().filter_map(|param| match param.kind { - GenericParamKind::Lifetime { .. } => { - Some(Region::early(&self.tcx.hir, &mut index, param)) - } - GenericParamKind::Type { .. } => { - type_count += 1; - None - } - }).collect(); + let lifetimes = generics + .params + .iter() + .filter_map(|param| match param.kind { + GenericParamKind::Lifetime { .. } => { + Some(Region::early(&self.tcx.hir, &mut index, param)) + } + GenericParamKind::Type { .. } => { + type_count += 1; + None + } + }) + .collect(); let scope = Scope::Binder { lifetimes, next_early_index: index + type_count, @@ -829,15 +845,19 @@ let mut index = self.next_early_index(); let mut next_early_index = index; debug!("visit_ty: index = {}", index); - let lifetimes = generics.params.iter().filter_map(|param| match param.kind { - GenericParamKind::Lifetime { .. } => { - Some(Region::early(&self.tcx.hir, &mut index, param)) - } - GenericParamKind::Type { .. } => { - next_early_index += 1; - None - } - }).collect(); + let lifetimes = generics + .params + .iter() + .filter_map(|param| match param.kind { + GenericParamKind::Lifetime { .. } => { + Some(Region::early(&self.tcx.hir, &mut index, param)) + } + GenericParamKind::Type { .. } => { + next_early_index += 1; + None + } + }) + .collect(); let scope = Scope::Binder { lifetimes, next_early_index, @@ -855,15 +875,19 @@ let mut index = self.next_early_index(); let mut next_early_index = index; debug!("visit_ty: index = {}", index); - let lifetimes = generics.params.iter().filter_map(|param| match param.kind { - GenericParamKind::Lifetime { .. } => { - Some(Region::early(&self.tcx.hir, &mut index, param)) - } - GenericParamKind::Type { .. } => { - next_early_index += 1; - None - } - }).collect(); + let lifetimes = generics + .params + .iter() + .filter_map(|param| match param.kind { + GenericParamKind::Lifetime { .. } => { + Some(Region::early(&self.tcx.hir, &mut index, param)) + } + GenericParamKind::Type { .. } => { + next_early_index += 1; + None + } + }) + .collect(); let scope = Scope::Binder { lifetimes, @@ -937,13 +961,15 @@ ref bound_generic_params, .. }) => { - let lifetimes: FxHashMap<_, _> = bound_generic_params.iter() + let lifetimes: FxHashMap<_, _> = bound_generic_params + .iter() .filter_map(|param| match param.kind { GenericParamKind::Lifetime { .. } => { Some(Region::late(&self.tcx.hir, param)) } _ => None, - }).collect(); + }) + .collect(); if !lifetimes.is_empty() { self.trait_ref_hack = true; let next_early_index = self.next_early_index(); @@ -993,15 +1019,12 @@ ) { debug!("visit_poly_trait_ref trait_ref={:?}", trait_ref); - if !self.trait_ref_hack - || trait_ref - .bound_generic_params - .iter() - .any(|param| match param.kind { - GenericParamKind::Lifetime { .. } => true, - _ => false, - }) - { + if !self.trait_ref_hack || trait_ref.bound_generic_params.iter().any(|param| { + match param.kind { + GenericParamKind::Lifetime { .. } => true, + _ => false, + } + }) { if self.trait_ref_hack { span_err!( self.tcx.sess, @@ -1012,13 +1035,16 @@ } let next_early_index = self.next_early_index(); let scope = Scope::Binder { - lifetimes: trait_ref.bound_generic_params.iter() + lifetimes: trait_ref + .bound_generic_params + .iter() .filter_map(|param| match param.kind { GenericParamKind::Lifetime { .. } => { Some(Region::late(&self.tcx.hir, param)) } _ => None, - }).collect(), + }) + .collect(), s: self.scope, next_early_index, track_lifetime_uses: true, @@ -1083,29 +1109,30 @@ } } -fn check_mixed_explicit_and_in_band_defs( - tcx: TyCtxt<'_, '_, '_>, - params: &P<[hir::GenericParam]>, -) { - let in_bands: Vec<_> = params.iter().filter_map(|param| match param.kind { - GenericParamKind::Lifetime { in_band, .. } => Some((in_band, param.span)), - _ => None, - }).collect(); - let out_of_band = in_bands.iter().find(|(in_band, _)| !in_band); - let in_band = in_bands.iter().find(|(in_band, _)| *in_band); +fn check_mixed_explicit_and_in_band_defs(tcx: TyCtxt<'_, '_, '_>, params: &P<[hir::GenericParam]>) { + let lifetime_params: Vec<_> = params + .iter() + .filter_map(|param| match param.kind { + GenericParamKind::Lifetime { kind, .. } => Some((kind, param.span)), + _ => None, + }) + .collect(); + let explicit = lifetime_params + .iter() + .find(|(kind, _)| *kind == LifetimeParamKind::Explicit); + let in_band = lifetime_params + .iter() + .find(|(kind, _)| *kind == LifetimeParamKind::InBand); - if let (Some((_, out_of_band_span)), Some((_, in_band_span))) - = (out_of_band, in_band) { + if let (Some((_, explicit_span)), Some((_, in_band_span))) = (explicit, in_band) { struct_span_err!( tcx.sess, *in_band_span, E0688, "cannot mix in-band and explicit lifetime definitions" - ).span_label( - *in_band_span, - "in-band lifetime definition here", - ).span_label(*out_of_band_span, "explicit lifetime definition here") - .emit(); + ).span_label(*in_band_span, "in-band lifetime definition here") + .span_label(*explicit_span, "explicit lifetime definition here") + .emit(); } } @@ -1191,8 +1218,9 @@ fn expression_label(ex: &hir::Expr) -> Option { match ex.node { - hir::ExprKind::While(.., Some(label)) | - hir::ExprKind::Loop(_, Some(label), _) => Some(label.ident), + hir::ExprKind::While(.., Some(label)) | hir::ExprKind::Loop(_, Some(label), _) => { + Some(label.ident) + } _ => None, } } @@ -1245,7 +1273,11 @@ hir::ItemKind::Struct(_, ref generics) | hir::ItemKind::Union(_, ref generics) | hir::ItemKind::Enum(_, ref generics) - | hir::ItemKind::Existential(hir::ExistTy { ref generics, impl_trait_fn: None, .. }) + | hir::ItemKind::Existential(hir::ExistTy { + ref generics, + impl_trait_fn: None, + .. + }) | hir::ItemKind::Ty(_, ref generics) | hir::ItemKind::Trait(_, _, ref generics, ..) => { let result = object_lifetime_defaults_for_item(tcx, generics); @@ -1255,24 +1287,26 @@ let object_lifetime_default_reprs: String = result .iter() .map(|set| match *set { - Set1::Empty => "BaseDefault".to_string(), - Set1::One(Region::Static) => "'static".to_string(), - Set1::One(Region::EarlyBound(mut i, _, _)) => { - generics.params.iter().find_map(|param| match param.kind { - GenericParamKind::Lifetime { .. } => { - if i == 0 { - return Some(param.name.ident().to_string()); - } - i -= 1; - None + Set1::Empty => "BaseDefault".into(), + Set1::One(Region::Static) => "'static".into(), + Set1::One(Region::EarlyBound(mut i, _, _)) => generics + .params + .iter() + .find_map(|param| match param.kind { + GenericParamKind::Lifetime { .. } => { + if i == 0 { + return Some(param.name.ident().to_string().into()); } - _ => None, - }).unwrap() - } + i -= 1; + None + } + _ => None, + }) + .unwrap(), Set1::One(_) => bug!(), - Set1::Many => "Ambiguous".to_string(), + Set1::Many => "Ambiguous".into(), }) - .collect::>() + .collect::>>() .join(","); tcx.sess.span_err(item.span, &object_lifetime_default_reprs); } @@ -1300,66 +1334,70 @@ } } - generics.params.iter().filter_map(|param| match param.kind { - GenericParamKind::Lifetime { .. } => None, - GenericParamKind::Type { .. } => { - let mut set = Set1::Empty; - - add_bounds(&mut set, ¶m.bounds); - - let param_def_id = tcx.hir.local_def_id(param.id); - for predicate in &generics.where_clause.predicates { - // Look for `type: ...` where clauses. - let data = match *predicate { - hir::WherePredicate::BoundPredicate(ref data) => data, - _ => continue, - }; + generics + .params + .iter() + .filter_map(|param| match param.kind { + GenericParamKind::Lifetime { .. } => None, + GenericParamKind::Type { .. } => { + let mut set = Set1::Empty; - // Ignore `for<'a> type: ...` as they can change what - // lifetimes mean (although we could "just" handle it). - if !data.bound_generic_params.is_empty() { - continue; - } + add_bounds(&mut set, ¶m.bounds); - let def = match data.bounded_ty.node { - hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => path.def, - _ => continue, - }; + let param_def_id = tcx.hir.local_def_id(param.id); + for predicate in &generics.where_clause.predicates { + // Look for `type: ...` where clauses. + let data = match *predicate { + hir::WherePredicate::BoundPredicate(ref data) => data, + _ => continue, + }; - if def == Def::TyParam(param_def_id) { - add_bounds(&mut set, &data.bounds); - } - } + // Ignore `for<'a> type: ...` as they can change what + // lifetimes mean (although we could "just" handle it). + if !data.bound_generic_params.is_empty() { + continue; + } - Some(match set { - Set1::Empty => Set1::Empty, - Set1::One(name) => { - if name == hir::LifetimeName::Static { - Set1::One(Region::Static) - } else { - generics.params.iter().filter_map(|param| match param.kind { - GenericParamKind::Lifetime { .. } => { - Some(( - param.id, - hir::LifetimeName::Param(param.name), - LifetimeDefOrigin::from_param(param), - )) - } - _ => None, - }) - .enumerate() - .find(|&(_, (_, lt_name, _))| lt_name == name) - .map_or(Set1::Many, |(i, (id, _, origin))| { - let def_id = tcx.hir.local_def_id(id); - Set1::One(Region::EarlyBound(i as u32, def_id, origin)) - }) + let def = match data.bounded_ty.node { + hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => path.def, + _ => continue, + }; + + if def == Def::TyParam(param_def_id) { + add_bounds(&mut set, &data.bounds); } } - Set1::Many => Set1::Many, - }) - } - }) - .collect() + + Some(match set { + Set1::Empty => Set1::Empty, + Set1::One(name) => { + if name == hir::LifetimeName::Static { + Set1::One(Region::Static) + } else { + generics + .params + .iter() + .filter_map(|param| match param.kind { + GenericParamKind::Lifetime { .. } => Some(( + param.id, + hir::LifetimeName::Param(param.name), + LifetimeDefOrigin::from_param(param), + )), + _ => None, + }) + .enumerate() + .find(|&(_, (_, lt_name, _))| lt_name == name) + .map_or(Set1::Many, |(i, (id, _, origin))| { + let def_id = tcx.hir.local_def_id(id); + Set1::One(Region::EarlyBound(i as u32, def_id, origin)) + }) + } + } + Set1::Many => Set1::Many, + }) + } + }) + .collect() } impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { @@ -1371,9 +1409,9 @@ f(self) } - fn with(&mut self, wrap_scope: Scope, f: F) + fn with(&mut self, wrap_scope: Scope<'_>, f: F) where - F: for<'b> FnOnce(ScopeRef, &mut LifetimeContext<'b, 'tcx>), + F: for<'b> FnOnce(ScopeRef<'_>, &mut LifetimeContext<'b, 'tcx>), { let LifetimeContext { tcx, @@ -1402,6 +1440,29 @@ self.xcrate_object_lifetime_defaults = this.xcrate_object_lifetime_defaults; } + /// helper method to determine the span to remove when suggesting the + /// deletion of a lifetime + fn lifetime_deletion_span(&self, name: ast::Ident, generics: &hir::Generics) -> Option { + if generics.params.len() == 1 { + // if sole lifetime, remove the `<>` brackets + Some(generics.span) + } else { + generics.params.iter().enumerate().find_map(|(i, param)| { + if param.name.ident() == name { + // We also want to delete a leading or trailing comma + // as appropriate + if i >= generics.params.len() - 1 { + Some(generics.params[i - 1].span.shrink_to_hi().to(param.span)) + } else { + Some(param.span.to(generics.params[i + 1].span.shrink_to_lo())) + } + } else { + None + } + }) + } + } + fn check_uses_for_lifetimes_defined_by_scope(&mut self) { let defined_by = match self.scope { Scope::Binder { lifetimes, .. } => lifetimes, @@ -1411,7 +1472,8 @@ } }; - let mut def_ids: Vec<_> = defined_by.values() + let mut def_ids: Vec<_> = defined_by + .values() .flat_map(|region| match region { Region::EarlyBound(_, def_id, _) | Region::LateBound(_, def_id, _) @@ -1427,22 +1489,26 @@ for def_id in def_ids { debug!( "check_uses_for_lifetimes_defined_by_scope: def_id = {:?}", - def_id, + def_id ); let lifetimeuseset = self.lifetime_uses.remove(&def_id); + debug!( "check_uses_for_lifetimes_defined_by_scope: lifetimeuseset = {:?}", lifetimeuseset ); + match lifetimeuseset { Some(LifetimeUseSet::One(lifetime)) => { let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap(); debug!("node id first={:?}", node_id); if let Some((id, span, name)) = match self.tcx.hir.get(node_id) { - Node::Lifetime(hir_lifetime) => { - Some((hir_lifetime.id, hir_lifetime.span, hir_lifetime.name.ident())) - } + Node::Lifetime(hir_lifetime) => Some(( + hir_lifetime.id, + hir_lifetime.span, + hir_lifetime.name.ident(), + )), Node::GenericParam(param) => { Some((param.id, param.span, param.name.ident())) } @@ -1466,21 +1532,37 @@ None => { let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap(); if let Some((id, span, name)) = match self.tcx.hir.get(node_id) { - Node::Lifetime(hir_lifetime) => { - Some((hir_lifetime.id, hir_lifetime.span, hir_lifetime.name.ident())) - } + Node::Lifetime(hir_lifetime) => Some(( + hir_lifetime.id, + hir_lifetime.span, + hir_lifetime.name.ident(), + )), Node::GenericParam(param) => { Some((param.id, param.span, param.name.ident())) } _ => None, } { debug!("id ={:?} span = {:?} name = {:?}", node_id, span, name); - self.tcx.struct_span_lint_node( + let mut err = self.tcx.struct_span_lint_node( lint::builtin::UNUSED_LIFETIMES, id, span, - &format!("lifetime parameter `{}` never used", name) - ).emit(); + &format!("lifetime parameter `{}` never used", name), + ); + if let Some(parent_def_id) = self.tcx.parent(def_id) { + if let Some(generics) = self.tcx.hir.get_generics(parent_def_id) { + let unused_lt_span = self.lifetime_deletion_span(name, generics); + if let Some(span) = unused_lt_span { + err.span_suggestion_with_applicability( + span, + "remove it", + String::new(), + Applicability::MachineApplicable, + ); + } + } + } + err.emit(); } } } @@ -1533,19 +1615,23 @@ } let mut type_count = 0; - let lifetimes = generics.params.iter().filter_map(|param| match param.kind { - GenericParamKind::Lifetime { .. } => { - if self.map.late_bound.contains(¶m.id) { - Some(Region::late(&self.tcx.hir, param)) - } else { - Some(Region::early(&self.tcx.hir, &mut index, param)) + let lifetimes = generics + .params + .iter() + .filter_map(|param| match param.kind { + GenericParamKind::Lifetime { .. } => { + if self.map.late_bound.contains(¶m.id) { + Some(Region::late(&self.tcx.hir, param)) + } else { + Some(Region::early(&self.tcx.hir, &mut index, param)) + } } - } - GenericParamKind::Type { .. } => { - type_count += 1; - None - } - }).collect(); + GenericParamKind::Type { .. } => { + type_count += 1; + None + } + }) + .collect(); let next_early_index = index + type_count; let scope = Scope::Binder { @@ -1600,6 +1686,12 @@ fn resolve_lifetime_ref(&mut self, lifetime_ref: &'tcx hir::Lifetime) { debug!("resolve_lifetime_ref(lifetime_ref={:?})", lifetime_ref); + + // If we've already reported an error, just ignore `lifetime_ref`. + if let LifetimeName::Error = lifetime_ref.name { + return; + } + // Walk up the scope chain, tracking the number of fn scopes // that we pass through, until we find a lifetime with the // given name or we run out of scopes. @@ -1618,17 +1710,20 @@ break None; } - Scope::Binder { ref lifetimes, s, .. } => { - let name = match lifetime_ref.name { - LifetimeName::Param(param_name) => param_name, + Scope::Binder { + ref lifetimes, s, .. + } => { + match lifetime_ref.name { + LifetimeName::Param(param_name) => { + if let Some(&def) = lifetimes.get(¶m_name.modern()) { + break Some(def.shifted(late_depth)); + } + } _ => bug!("expected LifetimeName::Param"), - }; - if let Some(&def) = lifetimes.get(&name.modern()) { - break Some(def.shifted(late_depth)); - } else { - late_depth += 1; - scope = s; } + + late_depth += 1; + scope = s; } Scope::Elision { s, .. } | Scope::ObjectLifetimeDefault { s, .. } => { @@ -1678,8 +1773,10 @@ } Region::Static - | Region::EarlyBound(_, _, LifetimeDefOrigin::Explicit) - | Region::LateBound(_, _, LifetimeDefOrigin::Explicit) + | Region::EarlyBound(_, _, LifetimeDefOrigin::ExplicitOrElided) + | Region::LateBound(_, _, LifetimeDefOrigin::ExplicitOrElided) + | Region::EarlyBound(_, _, LifetimeDefOrigin::Error) + | Region::LateBound(_, _, LifetimeDefOrigin::Error) | Region::LateBoundAnon(..) | Region::Free(..) => {} } @@ -1698,31 +1795,29 @@ } } - fn visit_segment_args( - &mut self, - def: Def, - depth: usize, - generic_args: &'tcx hir::GenericArgs, - ) { + fn visit_segment_args(&mut self, def: Def, depth: usize, generic_args: &'tcx hir::GenericArgs) { if generic_args.parenthesized { let was_in_fn_syntax = self.is_in_fn_syntax; self.is_in_fn_syntax = true; - self.visit_fn_like_elision(generic_args.inputs(), - Some(&generic_args.bindings[0].ty)); + self.visit_fn_like_elision(generic_args.inputs(), Some(&generic_args.bindings[0].ty)); self.is_in_fn_syntax = was_in_fn_syntax; return; } let mut elide_lifetimes = true; - let lifetimes = generic_args.args.iter().filter_map(|arg| match arg { - hir::GenericArg::Lifetime(lt) => { - if !lt.is_elided() { - elide_lifetimes = false; + let lifetimes = generic_args + .args + .iter() + .filter_map(|arg| match arg { + hir::GenericArg::Lifetime(lt) => { + if !lt.is_elided() { + elide_lifetimes = false; + } + Some(lt) } - Some(lt) - } - _ => None, - }).collect(); + _ => None, + }) + .collect(); if elide_lifetimes { self.resolve_elided_lifetimes(lifetimes); } else { @@ -1778,33 +1873,37 @@ self.xcrate_object_lifetime_defaults .entry(def_id) .or_insert_with(|| { - tcx.generics_of(def_id).params.iter().filter_map(|param| { - match param.kind { - GenericParamDefKind::Type { object_lifetime_default, .. } => { - Some(object_lifetime_default) - } + tcx.generics_of(def_id) + .params + .iter() + .filter_map(|param| match param.kind { + GenericParamDefKind::Type { + object_lifetime_default, + .. + } => Some(object_lifetime_default), GenericParamDefKind::Lifetime => None, - } - }).collect() + }) + .collect() }) }; - unsubst.iter() - .map(|set| match *set { - Set1::Empty => if in_body { - None - } else { - Some(Region::Static) - }, - Set1::One(r) => { - let lifetimes = generic_args.args.iter().filter_map(|arg| match arg { - GenericArg::Lifetime(lt) => Some(lt), - _ => None, - }); - r.subst(lifetimes, map) - } - Set1::Many => None, - }) - .collect() + unsubst + .iter() + .map(|set| match *set { + Set1::Empty => if in_body { + None + } else { + Some(Region::Static) + }, + Set1::One(r) => { + let lifetimes = generic_args.args.iter().filter_map(|arg| match arg { + GenericArg::Lifetime(lt) => Some(lt), + _ => None, + }); + r.subst(lifetimes, map) + } + Set1::Many => None, + }) + .collect() }); let mut i = 0; @@ -1831,11 +1930,7 @@ } } - fn visit_fn_like_elision( - &mut self, - inputs: &'tcx [hir::Ty], - output: Option<&'tcx P>, - ) { + fn visit_fn_like_elision(&mut self, inputs: &'tcx [hir::Ty], output: Option<&'tcx P>) { debug!("visit_fn_like_elision: enter"); let mut arg_elide = Elide::FreshLateAnon(Cell::new(0)); let arg_scope = Scope::Elision { @@ -1877,18 +1972,15 @@ node: hir::TraitItemKind::Method(_, ref m), .. }) => { - match self.tcx + if let hir::ItemKind::Trait(.., ref trait_items) = self.tcx .hir .expect_item(self.tcx.hir.get_parent(parent)) .node { - hir::ItemKind::Trait(.., ref trait_items) => { - assoc_item_kind = trait_items - .iter() - .find(|ti| ti.id.node_id == parent) - .map(|ti| ti.kind); - } - _ => {} + assoc_item_kind = trait_items + .iter() + .find(|ti| ti.id.node_id == parent) + .map(|ti| ti.kind); } match *m { hir::TraitMethod::Required(_) => None, @@ -1900,19 +1992,16 @@ node: hir::ImplItemKind::Method(_, body), .. }) => { - match self.tcx + if let hir::ItemKind::Impl(.., ref self_ty, ref impl_items) = self.tcx .hir .expect_item(self.tcx.hir.get_parent(parent)) .node { - hir::ItemKind::Impl(.., ref self_ty, ref impl_items) => { - impl_self = Some(self_ty); - assoc_item_kind = impl_items - .iter() - .find(|ii| ii.id.node_id == parent) - .map(|ii| ii.kind); - } - _ => {} + impl_self = Some(self_ty); + assoc_item_kind = impl_items + .iter() + .find(|ii| ii.id.node_id == parent) + .map(|ii| ii.kind); } Some(body) } @@ -1992,7 +2081,7 @@ map: self.map, outer_index: ty::INNERMOST, have_bound_regions: false, - lifetimes: FxHashSet(), + lifetimes: Default::default(), }; gather.visit_ty(input); @@ -2101,8 +2190,7 @@ } } - fn resolve_elided_lifetimes(&mut self, - lifetime_refs: Vec<&'tcx hir::Lifetime>) { + fn resolve_elided_lifetimes(&mut self, lifetime_refs: Vec<&'tcx hir::Lifetime>) { if lifetime_refs.is_empty() { return; } @@ -2147,21 +2235,46 @@ }; let mut err = report_missing_lifetime_specifiers(self.tcx.sess, span, lifetime_refs.len()); + let mut add_label = true; if let Some(params) = error { if lifetime_refs.len() == 1 { - self.report_elision_failure(&mut err, params); + add_label = add_label && self.report_elision_failure(&mut err, params, span); } } + if add_label { + add_missing_lifetime_specifiers_label(&mut err, span, lifetime_refs.len()); + } err.emit(); } + fn suggest_lifetime(&self, db: &mut DiagnosticBuilder<'_>, span: Span, msg: &str) -> bool { + match self.tcx.sess.source_map().span_to_snippet(span) { + Ok(ref snippet) => { + let (sugg, applicability) = if snippet == "&" { + ("&'static ".to_owned(), Applicability::MachineApplicable) + } else if snippet == "'_" { + ("'static".to_owned(), Applicability::MachineApplicable) + } else { + (format!("{} + 'static", snippet), Applicability::MaybeIncorrect) + }; + db.span_suggestion_with_applicability(span, msg, sugg, applicability); + false + } + Err(_) => { + db.help(msg); + true + } + } + } + fn report_elision_failure( &mut self, - db: &mut DiagnosticBuilder, + db: &mut DiagnosticBuilder<'_>, params: &[ElisionFailureInfo], - ) { + span: Span, + ) -> bool { let mut m = String::new(); let len = params.len(); @@ -2216,7 +2329,7 @@ "this function's return type contains a borrowed value, but \ there is no value for it to be borrowed from" ); - help!(db, "consider giving it a 'static lifetime"); + self.suggest_lifetime(db, span, "consider giving it a 'static lifetime") } else if elided_len == 0 { help!( db, @@ -2224,11 +2337,8 @@ an elided lifetime, but the lifetime cannot be derived from \ the arguments" ); - help!( - db, - "consider giving it an explicit bounded or 'static \ - lifetime" - ); + let msg = "consider giving it an explicit bounded or 'static lifetime"; + self.suggest_lifetime(db, span, msg) } else if elided_len == 1 { help!( db, @@ -2236,6 +2346,7 @@ the signature does not say which {} it is borrowed from", m ); + true } else { help!( db, @@ -2243,6 +2354,7 @@ the signature does not say whether it is borrowed from {}", m ); + true } } @@ -2268,16 +2380,24 @@ self.insert_lifetime(lifetime_ref, lifetime.shifted(late_depth)); } - fn check_lifetime_params(&mut self, old_scope: ScopeRef, params: &'tcx [hir::GenericParam]) { - let lifetimes: Vec<_> = params.iter().filter_map(|param| match param.kind { - GenericParamKind::Lifetime { .. } => Some((param, param.name)), - _ => None, - }).collect(); + fn check_lifetime_params( + &mut self, + old_scope: ScopeRef<'_>, + params: &'tcx [hir::GenericParam], + ) { + let lifetimes: Vec<_> = params + .iter() + .filter_map(|param| match param.kind { + GenericParamKind::Lifetime { .. } => Some((param, param.name)), + _ => None, + }) + .collect(); for (i, (lifetime_i, lifetime_i_name)) in lifetimes.iter().enumerate() { if let hir::ParamName::Plain(_) = lifetime_i_name { let name = lifetime_i_name.ident().name; - if name == keywords::UnderscoreLifetime.name() || - name == keywords::StaticLifetime.name() { + if name == keywords::UnderscoreLifetime.name() + || name == keywords::StaticLifetime.name() + { let mut err = struct_span_err!( self.tcx.sess, lifetime_i.span, @@ -2303,8 +2423,8 @@ "lifetime name `{}` declared twice in the same scope", lifetime_j.name.ident() ).span_label(lifetime_j.span, "declared twice") - .span_label(lifetime_i.span, "previous declaration here") - .emit(); + .span_label(lifetime_i.span, "previous declaration here") + .emit(); } } @@ -2314,35 +2434,34 @@ for bound in &lifetime_i.bounds { match bound { hir::GenericBound::Outlives(lt) => match lt.name { - hir::LifetimeName::Underscore => { - let mut err = struct_span_err!( - self.tcx.sess, - lt.span, - E0637, - "invalid lifetime bound name: `'_`" - ); - err.span_label(lt.span, "`'_` is a reserved lifetime name"); - err.emit(); - } + hir::LifetimeName::Underscore => self.tcx.sess.delay_span_bug( + lt.span, + "use of `'_` in illegal place, but not caught by lowering", + ), hir::LifetimeName::Static => { self.insert_lifetime(lt, Region::Static); - self.tcx.sess.struct_span_warn( - lifetime_i.span.to(lt.span), - &format!( - "unnecessary lifetime parameter `{}`", + self.tcx + .sess + .struct_span_warn( + lifetime_i.span.to(lt.span), + &format!( + "unnecessary lifetime parameter `{}`", + lifetime_i.name.ident(), + ), + ) + .help(&format!( + "you can use the `'static` lifetime directly, in place of `{}`", lifetime_i.name.ident(), - ), - ).help(&format!( - "you can use the `'static` lifetime directly, in place \ - of `{}`", - lifetime_i.name.ident(), - )).emit(); + )) + .emit(); } - hir::LifetimeName::Param(_) - | hir::LifetimeName::Implicit => { + hir::LifetimeName::Param(_) | hir::LifetimeName::Implicit => { self.resolve_lifetime_ref(lt); } - } + hir::LifetimeName::Error => { + // No need to do anything, error already reported. + } + }, _ => bug!(), } } @@ -2351,7 +2470,7 @@ fn check_lifetime_param_for_shadowing( &self, - mut old_scope: ScopeRef, + mut old_scope: ScopeRef<'_>, param: &'tcx hir::GenericParam, ) { for label in &self.labels_in_fn { @@ -2496,8 +2615,6 @@ } } -/////////////////////////////////////////////////////////////////////////// - /// Detects late-bound lifetimes and inserts them into /// `map.late_bound`. /// @@ -2518,15 +2635,13 @@ decl, generics ); - let mut constrained_by_input = ConstrainedCollector { - regions: FxHashSet(), - }; + let mut constrained_by_input = ConstrainedCollector::default(); for arg_ty in &decl.inputs { constrained_by_input.visit_ty(arg_ty); } let mut appears_in_output = AllCollector { - regions: FxHashSet(), + regions: Default::default(), }; intravisit::walk_fn_ret_ty(&mut appears_in_output, &decl.output); @@ -2540,20 +2655,18 @@ // Subtle point: because we disallow nested bindings, we can just // ignore binders here and scrape up all names we see. let mut appears_in_where_clause = AllCollector { - regions: FxHashSet(), + regions: Default::default(), }; appears_in_where_clause.visit_generics(generics); for param in &generics.params { - match param.kind { - hir::GenericParamKind::Lifetime { .. } => { - if !param.bounds.is_empty() { - // `'a: 'b` means both `'a` and `'b` are referenced - appears_in_where_clause - .regions.insert(hir::LifetimeName::Param(param.name.modern())); - } + if let hir::GenericParamKind::Lifetime { .. } = param.kind { + if !param.bounds.is_empty() { + // `'a: 'b` means both `'a` and `'b` are referenced + appears_in_where_clause + .regions + .insert(hir::LifetimeName::Param(param.name.modern())); } - hir::GenericParamKind::Type { .. } => {} } } @@ -2587,9 +2700,11 @@ continue; } - debug!("insert_late_bound_lifetimes: lifetime {:?} with id {:?} is late-bound", - param.name.ident(), - param.id); + debug!( + "insert_late_bound_lifetimes: lifetime {:?} with id {:?} is late-bound", + param.name.ident(), + param.id + ); let inserted = map.late_bound.insert(param.id); assert!(inserted, "visited lifetime {:?} twice", param.id); @@ -2597,6 +2712,7 @@ return; + #[derive(Default)] struct ConstrainedCollector { regions: FxHashSet, } @@ -2652,26 +2768,28 @@ } } -pub fn report_missing_lifetime_specifiers( +fn report_missing_lifetime_specifiers( sess: &Session, span: Span, count: usize, ) -> DiagnosticBuilder<'_> { - let mut err = struct_span_err!( + struct_span_err!( sess, span, E0106, "missing lifetime specifier{}", if count > 1 { "s" } else { "" } - ); + ) +} - let msg = if count > 1 { - format!("expected {} lifetime parameters", count) +fn add_missing_lifetime_specifiers_label( + err: &mut DiagnosticBuilder<'_>, + span: Span, + count: usize, +) { + if count > 1 { + err.span_label(span, format!("expected {} lifetime parameters", count)); } else { - "expected lifetime parameter".to_string() + err.span_label(span, "expected lifetime parameter"); }; - - err.span_label(span, msg); - - err } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/middle/stability.rs rustc-1.31.0+dfsg1+llvm/src/librustc/middle/stability.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/middle/stability.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/middle/stability.rs 2018-12-04 23:41:40.000000000 +0000 @@ -164,8 +164,10 @@ if let (&Some(attr::RustcDeprecation {since: dep_since, ..}), &attr::Stable {since: stab_since}) = (&stab.rustc_depr, &stab.level) { // Explicit version of iter::order::lt to handle parse errors properly - for (dep_v, stab_v) in - dep_since.as_str().split('.').zip(stab_since.as_str().split('.')) { + for (dep_v, stab_v) in dep_since.as_str() + .split('.') + .zip(stab_since.as_str().split('.')) + { if let (Ok(dep_v), Ok(stab_v)) = (dep_v.parse::(), stab_v.parse()) { match dep_v.cmp(&stab_v) { Ordering::Less => { @@ -399,13 +401,13 @@ let is_staged_api = tcx.sess.opts.debugging_opts.force_unstable_if_unmarked || tcx.features().staged_api; - let mut staged_api = FxHashMap(); + let mut staged_api = FxHashMap::default(); staged_api.insert(LOCAL_CRATE, is_staged_api); let mut index = Index { staged_api, - stab_map: FxHashMap(), - depr_map: FxHashMap(), - active_features: FxHashSet(), + stab_map: Default::default(), + depr_map: Default::default(), + active_features: Default::default(), }; let ref active_lib_features = tcx.features().declared_lib_features; @@ -441,6 +443,7 @@ feature: Symbol::intern("rustc_private"), rustc_depr: None, const_stability: None, + promotable: false, }); annotator.parent_stab = Some(stability); } @@ -522,15 +525,12 @@ Some(Def::Method(_)) | Some(Def::AssociatedTy(_)) | Some(Def::AssociatedConst(_)) => { - match self.associated_item(def_id).container { - ty::TraitContainer(trait_def_id) => { - // Trait methods do not declare visibility (even - // for visibility info in cstore). Use containing - // trait instead, so methods of pub traits are - // themselves considered pub. - def_id = trait_def_id; - } - _ => {} + if let ty::TraitContainer(trait_def_id) = self.associated_item(def_id).container { + // Trait methods do not declare visibility (even + // for visibility info in cstore). Use containing + // trait instead, so methods of pub traits are + // themselves considered pub. + def_id = trait_def_id; } } _ => {} @@ -560,8 +560,7 @@ /// `id`. pub fn eval_stability(self, def_id: DefId, id: Option, span: Span) -> EvalResult { if span.allows_unstable() { - debug!("stability: \ - skipping span={:?} since it is internal", span); + debug!("stability: skipping span={:?} since it is internal", span); return EvalResult::Allow; } @@ -769,8 +768,8 @@ let param_env = self.tcx.param_env(def_id); if !param_env.can_type_implement_copy(self.tcx, ty).is_ok() { emit_feature_err(&self.tcx.sess.parse_sess, - "untagged_unions", item.span, GateIssue::Language, - "unions with non-`Copy` fields are unstable"); + "untagged_unions", item.span, GateIssue::Language, + "unions with non-`Copy` fields are unstable"); } } } @@ -782,10 +781,8 @@ fn visit_path(&mut self, path: &'tcx hir::Path, id: hir::HirId) { let id = self.tcx.hir.hir_to_node_id(id); - match path.def { - Def::Local(..) | Def::Upvar(..) | Def::SelfCtor(..) | - Def::PrimTy(..) | Def::SelfTy(..) | Def::Err => {} - _ => self.tcx.check_stability(path.def.def_id(), Some(id), path.span) + if let Some(def_id) = path.def.opt_def_id() { + self.tcx.check_stability(def_id, Some(id), path.span) } intravisit::walk_path(self, path) } @@ -815,7 +812,7 @@ } let declared_lang_features = &tcx.features().declared_lang_features; - let mut lang_features = FxHashSet(); + let mut lang_features = FxHashSet::default(); for &(feature, span, since) in declared_lang_features { if let Some(since) = since { // Warn if the user has enabled an already-stable lang feature. @@ -829,7 +826,7 @@ } let declared_lib_features = &tcx.features().declared_lib_features; - let mut remaining_lib_features = FxHashMap(); + let mut remaining_lib_features = FxHashMap::default(); for (feature, span) in declared_lib_features { if remaining_lib_features.contains_key(&feature) { // Warn if the user enables a lib feature multiple times. diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/middle/weak_lang_items.rs rustc-1.31.0+dfsg1+llvm/src/librustc/middle/weak_lang_items.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/middle/weak_lang_items.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/middle/weak_lang_items.rs 2018-12-04 23:41:40.000000000 +0000 @@ -70,7 +70,7 @@ /// Not all lang items are always required for each compilation, particularly in /// the case of panic=abort. In these situations some lang items are injected by /// crates and don't actually need to be defined in libstd. -pub fn whitelisted(tcx: TyCtxt, lang_item: lang_items::LangItem) -> bool { +pub fn whitelisted(tcx: TyCtxt<'_, '_, '_>, lang_item: lang_items::LangItem) -> bool { // If we're not compiling with unwinding, we won't actually need these // symbols. Other panic runtimes ensure that the relevant symbols are // available to link things together, but they're never exercised. @@ -113,13 +113,13 @@ items.$name().is_none() { if lang_items::$item == lang_items::PanicImplLangItem { tcx.sess.err(&format!("`#[panic_handler]` function required, \ - but not found")); + but not found")); } else if lang_items::$item == lang_items::OomLangItem { tcx.sess.err(&format!("`#[alloc_error_handler]` function required, \ - but not found")); + but not found")); } else { tcx.sess.err(&format!("language item required, but not found: `{}`", - stringify!($name))); + stringify!($name))); } } )* diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/mir/cache.rs rustc-1.31.0+dfsg1+llvm/src/librustc/mir/cache.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/mir/cache.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/mir/cache.rs 2018-12-04 23:41:40.000000000 +0000 @@ -57,8 +57,8 @@ pub fn predecessors( &self, - mir: &Mir - ) -> MappedReadGuard>> { + mir: &Mir<'_> + ) -> MappedReadGuard<'_, IndexVec>> { if self.predecessors.borrow().is_none() { *self.predecessors.borrow_mut() = Some(calculate_predecessors(mir)); } @@ -67,7 +67,7 @@ } } -fn calculate_predecessors(mir: &Mir) -> IndexVec> { +fn calculate_predecessors(mir: &Mir<'_>) -> IndexVec> { let mut result = IndexVec::from_elem(vec![], mir.basic_blocks()); for (bb, data) in mir.basic_blocks().iter_enumerated() { if let Some(ref term) = data.terminator { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/mir/interpret/error.rs rustc-1.31.0+dfsg1+llvm/src/librustc/mir/interpret/error.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/mir/interpret/error.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/mir/interpret/error.rs 2018-12-04 23:41:40.000000000 +0000 @@ -186,6 +186,7 @@ FunctionAbiMismatch(Abi, Abi), FunctionArgMismatch(Ty<'tcx>, Ty<'tcx>), + FunctionRetMismatch(Ty<'tcx>, Ty<'tcx>), FunctionArgCountMismatch, NoMirFor(String), UnterminatedCString(Pointer), @@ -294,7 +295,8 @@ use self::EvalErrorKind::*; match *self { MachineError(ref inner) => inner, - FunctionAbiMismatch(..) | FunctionArgMismatch(..) | FunctionArgCountMismatch => + FunctionAbiMismatch(..) | FunctionArgMismatch(..) | FunctionRetMismatch(..) + | FunctionArgCountMismatch => "tried to call a function through a function pointer of incompatible type", InvalidMemoryAccess => "tried to access memory through an invalid pointer", @@ -429,13 +431,13 @@ } impl<'tcx> fmt::Display for EvalError<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{:?}", self.kind) } } impl<'tcx, O: fmt::Debug> fmt::Debug for EvalErrorKind<'tcx, O> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use self::EvalErrorKind::*; match *self { PointerOutOfBounds { ptr, access, allocation_size } => { @@ -470,6 +472,10 @@ write!(f, "tried to call a function with argument of type {:?} \ passing data of type {:?}", callee_ty, caller_ty), + FunctionRetMismatch(caller_ty, callee_ty) => + write!(f, "tried to call a function with return type {:?} \ + passing return place of type {:?}", + callee_ty, caller_ty), FunctionArgCountMismatch => write!(f, "tried to call a function with incorrect number of arguments"), BoundsCheck { ref len, ref index } => diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/mir/interpret/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/mir/interpret/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/mir/interpret/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/mir/interpret/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -23,7 +23,7 @@ FrameInfo, ConstEvalResult, }; -pub use self::value::{Scalar, ConstValue, ScalarMaybeUndef}; +pub use self::value::{Scalar, ConstValue}; use std::fmt; use mir; @@ -138,54 +138,82 @@ /// each context. /// /// Defaults to the index based and loosely coupled AllocId. +/// +/// Pointer is also generic over the `Tag` associated with each pointer, +/// which is used to do provenance tracking during execution. #[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, RustcEncodable, RustcDecodable, Hash)] -pub struct Pointer { +pub struct Pointer { pub alloc_id: Id, pub offset: Size, + pub tag: Tag, } /// Produces a `Pointer` which points to the beginning of the Allocation impl From for Pointer { + #[inline(always)] fn from(alloc_id: AllocId) -> Self { Pointer::new(alloc_id, Size::ZERO) } } -impl<'tcx> Pointer { +impl<'tcx> Pointer<()> { + #[inline(always)] pub fn new(alloc_id: AllocId, offset: Size) -> Self { - Pointer { alloc_id, offset } + Pointer { alloc_id, offset, tag: () } + } + + #[inline(always)] + pub fn with_default_tag(self) -> Pointer + where Tag: Default + { + Pointer::new_with_tag(self.alloc_id, self.offset, Default::default()) + } +} + +impl<'tcx, Tag> Pointer { + #[inline(always)] + pub fn new_with_tag(alloc_id: AllocId, offset: Size, tag: Tag) -> Self { + Pointer { alloc_id, offset, tag } } pub fn wrapping_signed_offset(self, i: i64, cx: C) -> Self { - Pointer::new( + Pointer::new_with_tag( self.alloc_id, Size::from_bytes(cx.data_layout().wrapping_signed_offset(self.offset.bytes(), i)), + self.tag, ) } pub fn overflowing_signed_offset(self, i: i128, cx: C) -> (Self, bool) { let (res, over) = cx.data_layout().overflowing_signed_offset(self.offset.bytes(), i); - (Pointer::new(self.alloc_id, Size::from_bytes(res)), over) + (Pointer::new_with_tag(self.alloc_id, Size::from_bytes(res), self.tag), over) } pub fn signed_offset(self, i: i64, cx: C) -> EvalResult<'tcx, Self> { - Ok(Pointer::new( + Ok(Pointer::new_with_tag( self.alloc_id, Size::from_bytes(cx.data_layout().signed_offset(self.offset.bytes(), i)?), + self.tag, )) } pub fn overflowing_offset(self, i: Size, cx: C) -> (Self, bool) { let (res, over) = cx.data_layout().overflowing_offset(self.offset.bytes(), i.bytes()); - (Pointer::new(self.alloc_id, Size::from_bytes(res)), over) + (Pointer::new_with_tag(self.alloc_id, Size::from_bytes(res), self.tag), over) } pub fn offset(self, i: Size, cx: C) -> EvalResult<'tcx, Self> { - Ok(Pointer::new( + Ok(Pointer::new_with_tag( self.alloc_id, Size::from_bytes(cx.data_layout().offset(self.offset.bytes(), i.bytes())?), + self.tag )) } + + #[inline] + pub fn erase_tag(self) -> Pointer { + Pointer { alloc_id: self.alloc_id, offset: self.offset, tag: () } + } } @@ -253,7 +281,7 @@ impl AllocDecodingState { - pub fn new_decoding_session(&self) -> AllocDecodingSession { + pub fn new_decoding_session(&self) -> AllocDecodingSession<'_> { static DECODER_SESSION_ID: AtomicU32 = AtomicU32::new(0); let counter = DECODER_SESSION_ID.fetch_add(1, Ordering::SeqCst); @@ -394,7 +422,7 @@ } impl fmt::Display for AllocId { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.0) } } @@ -425,8 +453,8 @@ impl<'tcx, M: fmt::Debug + Eq + Hash + Clone> AllocMap<'tcx, M> { pub fn new() -> Self { AllocMap { - id_to_type: FxHashMap(), - type_interner: FxHashMap(), + id_to_type: Default::default(), + type_interner: Default::default(), next_id: AllocId(0), } } @@ -496,15 +524,15 @@ } #[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)] -pub struct Allocation { +pub struct Allocation { /// The actual bytes of the allocation. /// Note that the bytes of a pointer represent the offset of the pointer pub bytes: Vec, - /// Maps from byte addresses to allocations. + /// Maps from byte addresses to extra data for each pointer. /// Only the first byte of a pointer is inserted into the map; i.e., /// every entry in this map applies to `pointer_size` consecutive bytes starting /// at the given offset. - pub relocations: Relocations, + pub relocations: Relocations, /// Denotes undefined memory. Reading from undefined memory is forbidden in miri pub undef_mask: UndefMask, /// The alignment of the allocation to detect unaligned reads. @@ -513,9 +541,11 @@ /// Also used by codegen to determine if a static should be put into mutable memory, /// which happens for `static mut` and `static` with interior mutability. pub mutability: Mutability, + /// Extra state for the machine. + pub extra: Extra, } -impl Allocation { +impl Allocation { /// Creates a read-only allocation initialized by the given bytes pub fn from_bytes(slice: &[u8], align: Align) -> Self { let mut undef_mask = UndefMask::new(Size::ZERO); @@ -526,6 +556,7 @@ undef_mask, align, mutability: Mutability::Immutable, + extra: Extra::default(), } } @@ -541,6 +572,7 @@ undef_mask: UndefMask::new(size), align, mutability: Mutability::Mutable, + extra: Extra::default(), } } } @@ -548,29 +580,29 @@ impl<'tcx> ::serialize::UseSpecializedDecodable for &'tcx Allocation {} #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)] -pub struct Relocations(SortedMap); +pub struct Relocations(SortedMap); -impl Relocations { +impl Relocations { pub fn new() -> Self { Relocations(SortedMap::new()) } // The caller must guarantee that the given relocations are already sorted // by address and contain no duplicates. - pub fn from_presorted(r: Vec<(Size, Id)>) -> Self { + pub fn from_presorted(r: Vec<(Size, (Tag, Id))>) -> Self { Relocations(SortedMap::from_presorted_elements(r)) } } -impl Deref for Relocations { - type Target = SortedMap; +impl Deref for Relocations { + type Target = SortedMap; fn deref(&self) -> &Self::Target { &self.0 } } -impl DerefMut for Relocations { +impl DerefMut for Relocations { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } @@ -600,7 +632,7 @@ } //////////////////////////////////////////////////////////////////////////////// -// Methods to faciliate working with signed integers stored in a u128 +// Methods to facilitate working with signed integers stored in a u128 //////////////////////////////////////////////////////////////////////////////// pub fn sign_extend(value: u128, size: Size) -> u128 { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/mir/interpret/value.rs rustc-1.31.0+dfsg1+llvm/src/librustc/mir/interpret/value.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/mir/interpret/value.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/mir/interpret/value.rs 2018-12-04 23:41:40.000000000 +0000 @@ -24,15 +24,18 @@ /// to allow HIR creation to happen for everything before needing to be able to run constant /// evaluation Unevaluated(DefId, &'tcx Substs<'tcx>), + /// Used only for types with layout::abi::Scalar ABI and ZSTs /// /// Not using the enum `Value` to encode that this must not be `Undef` Scalar(Scalar), - /// Used only for types with layout::abi::ScalarPair + + /// Used only for *fat pointers* with layout::abi::ScalarPair /// - /// The second field may be undef in case of `Option::None` - ScalarPair(Scalar, ScalarMaybeUndef), - /// Used only for the remaining cases. An allocation + offset into the allocation. + /// Needed for pattern matching code related to slices and strings. + ScalarPair(Scalar, Scalar), + + /// An allocation + offset into the allocation. /// Invariant: The AllocId matches the allocation. ByRef(AllocId, &'tcx Allocation, Size), } @@ -67,16 +70,56 @@ ConstValue::ScalarPair(val, Scalar::Bits { bits: len as u128, size: cx.data_layout().pointer_size.bytes() as u8, - }.into()) + }) } #[inline] pub fn new_dyn_trait(val: Scalar, vtable: Pointer) -> Self { - ConstValue::ScalarPair(val, Scalar::Ptr(vtable).into()) + ConstValue::ScalarPair(val, Scalar::Ptr(vtable)) } } -impl<'tcx> Scalar { +/// A `Scalar` represents an immediate, primitive value existing outside of a +/// `memory::Allocation`. It is in many ways like a small chunk of a `Allocation`, up to 8 bytes in +/// size. Like a range of bytes in an `Allocation`, a `Scalar` can either represent the raw bytes +/// of a simple value or a pointer into another `Allocation` +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, RustcEncodable, RustcDecodable, Hash)] +pub enum Scalar { + /// The raw bytes of a simple value. + Bits { + /// The first `size` bytes are the value. + /// Do not try to read less or more bytes that that. The remaining bytes must be 0. + size: u8, + bits: u128, + }, + + /// A pointer into an `Allocation`. An `Allocation` in the `memory` module has a list of + /// relocations, but a `Scalar` is only large enough to contain one, so we just represent the + /// relocation and its associated offset together as a `Pointer` here. + Ptr(Pointer), +} + +impl<'tcx> Scalar<()> { + #[inline] + pub fn with_default_tag(self) -> Scalar + where Tag: Default + { + match self { + Scalar::Ptr(ptr) => Scalar::Ptr(ptr.with_default_tag()), + Scalar::Bits { bits, size } => Scalar::Bits { bits, size }, + } + } +} + +impl<'tcx, Tag> Scalar { + #[inline] + pub fn erase_tag(self) -> Scalar { + match self { + Scalar::Ptr(ptr) => Scalar::Ptr(ptr.erase_tag()), + Scalar::Bits { bits, size } => Scalar::Bits { bits, size }, + } + } + #[inline] pub fn ptr_null(cx: impl HasDataLayout) -> Self { Scalar::Bits { @@ -138,7 +181,7 @@ #[inline] pub fn is_null_ptr(self, cx: impl HasDataLayout) -> bool { match self { - Scalar::Bits { bits, size } => { + Scalar::Bits { bits, size } => { assert_eq!(size as u64, cx.data_layout().pointer_size.bytes()); bits == 0 }, @@ -147,14 +190,6 @@ } #[inline] - pub fn is_null(self) -> bool { - match self { - Scalar::Bits { bits, .. } => bits == 0, - Scalar::Ptr(_) => false - } - } - - #[inline] pub fn from_bool(b: bool) -> Self { Scalar::Bits { bits: b as u128, size: 1 } } @@ -168,7 +203,7 @@ pub fn from_uint(i: impl Into, size: Size) -> Self { let i = i.into(); debug_assert_eq!(truncate(i, size), i, - "Unsigned value {} does not fit in {} bits", i, size.bits()); + "Unsigned value {} does not fit in {} bits", i, size.bits()); Scalar::Bits { bits: i, size: size.bytes() as u8 } } @@ -178,7 +213,7 @@ // `into` performed sign extension, we have to truncate let truncated = truncate(i as u128, size); debug_assert_eq!(sign_extend(truncated, size) as i128, i, - "Signed value {} does not fit in {} bits", i, size.bits()); + "Signed value {} does not fit in {} bits", i, size.bits()); Scalar::Bits { bits: truncated, size: size.bytes() as u8 } } @@ -205,7 +240,7 @@ } #[inline] - pub fn to_ptr(self) -> EvalResult<'tcx, Pointer> { + pub fn to_ptr(self) -> EvalResult<'tcx, Pointer> { match self { Scalar::Bits { bits: 0, .. } => err!(InvalidNullPointerUsage), Scalar::Bits { .. } => err!(ReadBytesAsPointer), @@ -314,122 +349,9 @@ } } -impl From for Scalar { +impl From> for Scalar { #[inline(always)] - fn from(ptr: Pointer) -> Self { + fn from(ptr: Pointer) -> Self { Scalar::Ptr(ptr) } } - -/// A `Scalar` represents an immediate, primitive value existing outside of a -/// `memory::Allocation`. It is in many ways like a small chunk of a `Allocation`, up to 8 bytes in -/// size. Like a range of bytes in an `Allocation`, a `Scalar` can either represent the raw bytes -/// of a simple value or a pointer into another `Allocation` -#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, RustcEncodable, RustcDecodable, Hash)] -pub enum Scalar { - /// The raw bytes of a simple value. - Bits { - /// The first `size` bytes are the value. - /// Do not try to read less or more bytes that that. The remaining bytes must be 0. - size: u8, - bits: u128, - }, - - /// A pointer into an `Allocation`. An `Allocation` in the `memory` module has a list of - /// relocations, but a `Scalar` is only large enough to contain one, so we just represent the - /// relocation and its associated offset together as a `Pointer` here. - Ptr(Pointer), -} - -#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, RustcEncodable, RustcDecodable, Hash)] -pub enum ScalarMaybeUndef { - Scalar(Scalar), - Undef, -} - -impl From for ScalarMaybeUndef { - #[inline(always)] - fn from(s: Scalar) -> Self { - ScalarMaybeUndef::Scalar(s) - } -} - -impl<'tcx> ScalarMaybeUndef { - #[inline] - pub fn not_undef(self) -> EvalResult<'static, Scalar> { - match self { - ScalarMaybeUndef::Scalar(scalar) => Ok(scalar), - ScalarMaybeUndef::Undef => err!(ReadUndefBytes(Size::from_bytes(0))), - } - } - - #[inline(always)] - pub fn to_ptr(self) -> EvalResult<'tcx, Pointer> { - self.not_undef()?.to_ptr() - } - - #[inline(always)] - pub fn to_bits(self, target_size: Size) -> EvalResult<'tcx, u128> { - self.not_undef()?.to_bits(target_size) - } - - #[inline(always)] - pub fn to_bool(self) -> EvalResult<'tcx, bool> { - self.not_undef()?.to_bool() - } - - #[inline(always)] - pub fn to_char(self) -> EvalResult<'tcx, char> { - self.not_undef()?.to_char() - } - - #[inline(always)] - pub fn to_f32(self) -> EvalResult<'tcx, f32> { - self.not_undef()?.to_f32() - } - - #[inline(always)] - pub fn to_f64(self) -> EvalResult<'tcx, f64> { - self.not_undef()?.to_f64() - } - - #[inline(always)] - pub fn to_u8(self) -> EvalResult<'tcx, u8> { - self.not_undef()?.to_u8() - } - - #[inline(always)] - pub fn to_u32(self) -> EvalResult<'tcx, u32> { - self.not_undef()?.to_u32() - } - - #[inline(always)] - pub fn to_u64(self) -> EvalResult<'tcx, u64> { - self.not_undef()?.to_u64() - } - - #[inline(always)] - pub fn to_usize(self, cx: impl HasDataLayout) -> EvalResult<'tcx, u64> { - self.not_undef()?.to_usize(cx) - } - - #[inline(always)] - pub fn to_i8(self) -> EvalResult<'tcx, i8> { - self.not_undef()?.to_i8() - } - - #[inline(always)] - pub fn to_i32(self) -> EvalResult<'tcx, i32> { - self.not_undef()?.to_i32() - } - - #[inline(always)] - pub fn to_i64(self) -> EvalResult<'tcx, i64> { - self.not_undef()?.to_i64() - } - - #[inline(always)] - pub fn to_isize(self, cx: impl HasDataLayout) -> EvalResult<'tcx, i64> { - self.not_undef()?.to_isize(cx) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/mir/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/mir/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/mir/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/mir/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,12 +12,11 @@ //! //! [rustc guide]: https://rust-lang-nursery.github.io/rustc-guide/mir/index.html -use graphviz::IntoCow; use hir::def::CtorKind; use hir::def_id::DefId; use hir::{self, HirId, InlineAsm}; use middle::region; -use mir::interpret::{ConstValue, EvalErrorKind, Scalar, ScalarMaybeUndef}; +use mir::interpret::{ConstValue, EvalErrorKind, Scalar}; use mir::visit::MirVisitable; use rustc_apfloat::ieee::{Double, Single}; use rustc_apfloat::Float; @@ -38,7 +37,7 @@ use syntax::symbol::InternedString; use syntax_pos::{Span, DUMMY_SP}; use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; -use ty::subst::{Subst, Substs}; +use ty::subst::{CanonicalUserSubsts, Subst, Substs}; use ty::{self, AdtDef, CanonicalTy, ClosureSubsts, GeneratorSubsts, Region, Ty, TyCtxt}; use util::ppaux; @@ -327,22 +326,20 @@ if idx < stmts.len() { &stmts[idx].source_info } else { - assert!(idx == stmts.len()); + assert_eq!(idx, stmts.len()); &block.terminator().source_info } } /// Check if `sub` is a sub scope of `sup` pub fn is_sub_scope(&self, mut sub: SourceScope, sup: SourceScope) -> bool { - loop { - if sub == sup { - return true; - } + while sub != sup { match self.source_scopes[sub].parent_scope { None => return false, Some(p) => sub = p, } } + true } /// Return the return type, it always return first element from `local_decls` array @@ -451,11 +448,32 @@ } } -#[derive(Copy, Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, RustcEncodable, RustcDecodable)] pub enum BorrowKind { /// Data must be immutable and is aliasable. Shared, + /// The immediately borrowed place must be immutable, but projections from + /// it don't need to be. For example, a shallow borrow of `a.b` doesn't + /// conflict with a mutable borrow of `a.b.c`. + /// + /// This is used when lowering matches: when matching on a place we want to + /// ensure that place have the same value from the start of the match until + /// an arm is selected. This prevents this code from compiling: + /// + /// let mut x = &Some(0); + /// match *x { + /// None => (), + /// Some(_) if { x = &None; false } => (), + /// Some(_) => (), + /// } + /// + /// This can't be a shared borrow because mutably borrowing (*x as Some).0 + /// should not prevent `if let None = x { ... }`, for example, because the + /// mutating `(*x as Some).0` can't affect the discriminant of `x`. + /// We can also report errors with this kind of borrow differently. + Shallow, + /// Data must be immutable but not aliasable. This kind of borrow /// cannot currently be expressed by the user and is used only in /// implicit closure bindings. It is needed when the closure is @@ -504,10 +522,8 @@ 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, + BorrowKind::Shared | BorrowKind::Shallow | BorrowKind::Unique => false, + BorrowKind::Mut { allow_two_phase_borrow } => allow_two_phase_borrow, } } } @@ -562,11 +578,27 @@ /// This is a binding for a non-`self` binding, or a `self` that has an explicit type. Var(VarBindingForm<'tcx>), /// Binding for a `self`/`&self`/`&mut self` binding where the type is implicit. - ImplicitSelf, + ImplicitSelf(ImplicitSelfKind), /// Reference used in a guard expression to ensure immutability. RefForGuard, } +/// Represents what type of implicit self a function has, if any. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)] +pub enum ImplicitSelfKind { + /// Represents a `fn x(self);`. + Imm, + /// Represents a `fn x(mut self);`. + Mut, + /// Represents a `fn x(&self);`. + ImmRef, + /// Represents a `fn x(&mut self);`. + MutRef, + /// Represents when a function does not have a self argument or + /// when a function has a `self: X` argument. + None +} + CloneTypeFoldableAndLiftImpls! { BindingForm<'tcx>, } impl_stable_hash_for!(struct self::VarBindingForm<'tcx> { @@ -576,6 +608,14 @@ pat_span }); +impl_stable_hash_for!(enum self::ImplicitSelfKind { + Imm, + Mut, + ImmRef, + MutRef, + None +}); + mod binding_form_impl { use ich::StableHashingContext; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult}; @@ -591,13 +631,33 @@ match self { Var(binding) => binding.hash_stable(hcx, hasher), - ImplicitSelf => (), + ImplicitSelf(kind) => kind.hash_stable(hcx, hasher), RefForGuard => (), } } } } +/// `BlockTailInfo` is attached to the `LocalDecl` for temporaries +/// created during evaluation of expressions in a block tail +/// expression; that is, a block like `{ STMT_1; STMT_2; EXPR }`. +/// +/// It is used to improve diagnostics when such temporaries are +/// involved in borrow_check errors, e.g. explanations of where the +/// temporaries come from, when their destructors are run, and/or how +/// one might revise the code to satisfy the borrow checker's rules. +#[derive(Clone, Debug, RustcEncodable, RustcDecodable)] +pub struct BlockTailInfo { + /// If `true`, then the value resulting from evaluating this tail + /// expression is ignored by the block's expression context. + /// + /// Examples include `{ ...; tail };` and `let _ = { ...; tail };` + /// but not e.g. `let _x = { ...; tail };` + pub tail_result_is_ignored: bool, +} + +impl_stable_hash_for!(struct BlockTailInfo { tail_result_is_ignored }); + /// A MIR local. /// /// This can be a binding declared by the user, a temporary inserted by the compiler, a function @@ -637,6 +697,12 @@ /// generator. pub internal: bool, + /// If this local is a temporary and `is_block_tail` is `Some`, + /// then it is a temporary created for evaluation of some + /// subexpression of some block's tail expression (with no + /// intervening statement context). + pub is_block_tail: Option, + /// Type of this local. pub ty: Ty<'tcx>, @@ -644,7 +710,7 @@ /// e.g. via `let x: T`, then we carry that type here. The MIR /// borrow checker needs this information since it can affect /// region inference. - pub user_ty: Option>, + pub user_ty: UserTypeProjections<'tcx>, /// Name of the local, used in debuginfo and pretty-printing. /// @@ -754,10 +820,9 @@ pat_span: _, }))) => true, - // FIXME: might be able to thread the distinction between - // `self`/`mut self`/`&self`/`&mut self` into the - // `BindingForm::ImplicitSelf` variant, (and then return - // true here for solely the first case). + Some(ClearCrossCrate::Set(BindingForm::ImplicitSelf(ImplicitSelfKind::Imm))) + => true, + _ => false, } } @@ -774,7 +839,7 @@ pat_span: _, }))) => true, - Some(ClearCrossCrate::Set(BindingForm::ImplicitSelf)) => true, + Some(ClearCrossCrate::Set(BindingForm::ImplicitSelf(_))) => true, _ => false, } @@ -786,10 +851,19 @@ Self::new_local(ty, Mutability::Mut, false, span) } - /// Create a new immutable `LocalDecl` for a temporary. + /// Converts `self` into same `LocalDecl` except tagged as immutable. + #[inline] + pub fn immutable(mut self) -> Self { + self.mutability = Mutability::Not; + self + } + + /// Converts `self` into same `LocalDecl` except tagged as internal temporary. #[inline] - pub fn new_immutable_temp(ty: Ty<'tcx>, span: Span) -> Self { - Self::new_local(ty, Mutability::Not, false, span) + pub fn block_tail(mut self, info: BlockTailInfo) -> Self { + assert!(self.is_block_tail.is_none()); + self.is_block_tail = Some(info); + self } /// Create a new `LocalDecl` for a internal temporary. @@ -808,7 +882,7 @@ LocalDecl { mutability, ty, - user_ty: None, + user_ty: UserTypeProjections::none(), name: None, source_info: SourceInfo { span, @@ -817,6 +891,7 @@ visibility_scope: OUTERMOST_SOURCE_SCOPE, internal, is_user_variable: None, + is_block_tail: None, } } @@ -824,17 +899,18 @@ /// /// This must be inserted into the `local_decls` list as the first local. #[inline] - pub fn new_return_place(return_ty: Ty, span: Span) -> LocalDecl { + pub fn new_return_place(return_ty: Ty<'_>, span: Span) -> LocalDecl<'_> { LocalDecl { mutability: Mutability::Mut, ty: return_ty, - user_ty: None, + user_ty: UserTypeProjections::none(), source_info: SourceInfo { span, scope: OUTERMOST_SOURCE_SCOPE, }, visibility_scope: OUTERMOST_SOURCE_SCOPE, internal: false, + is_block_tail: None, name: None, // FIXME maybe we do want some name here? is_user_variable: None, } @@ -1005,6 +1081,9 @@ destination: Option<(Place<'tcx>, BasicBlock)>, /// Cleanups to be done if the call unwinds. cleanup: Option, + /// Whether this is from a call in HIR, rather than from an overloaded + /// operator. True for overloaded function call. + from_hir_call: bool, }, /// Jump to the target if the condition has the expected value, @@ -1061,11 +1140,11 @@ iter::Chain, slice::IterMut<'a, BasicBlock>>; impl<'tcx> Terminator<'tcx> { - pub fn successors(&self) -> Successors { + pub fn successors(&self) -> Successors<'_> { self.kind.successors() } - pub fn successors_mut(&mut self) -> SuccessorsMut { + pub fn successors_mut(&mut self) -> SuccessorsMut<'_> { self.kind.successors_mut() } @@ -1094,7 +1173,7 @@ } } - pub fn successors(&self) -> Successors { + pub fn successors(&self) -> Successors<'_> { use self::TerminatorKind::*; match *self { Resume @@ -1179,7 +1258,7 @@ } } - pub fn successors_mut(&mut self) -> SuccessorsMut { + pub fn successors_mut(&mut self) -> SuccessorsMut<'_> { use self::TerminatorKind::*; match *self { Resume @@ -1342,7 +1421,7 @@ pub fn retain_statements(&mut self, mut f: F) where - F: FnMut(&mut Statement) -> bool, + F: FnMut(&mut Statement<'_>) -> bool, { for s in &mut self.statements { if !f(s) { @@ -1416,7 +1495,7 @@ } impl<'tcx> Debug for TerminatorKind<'tcx> { - fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result { self.fmt_head(fmt)?; let successor_count = self.successors().count(); let labels = self.fmt_successor_labels(); @@ -1530,42 +1609,42 @@ }; fmt_const_val(&mut s, &c).unwrap(); s.into() - }).chain(iter::once(String::from("otherwise").into())) + }).chain(iter::once("otherwise".into())) .collect() } Call { destination: Some(_), cleanup: Some(_), .. - } => vec!["return".into_cow(), "unwind".into_cow()], + } => vec!["return".into(), "unwind".into()], Call { destination: Some(_), cleanup: None, .. - } => vec!["return".into_cow()], + } => vec!["return".into()], Call { destination: None, cleanup: Some(_), .. - } => vec!["unwind".into_cow()], + } => vec!["unwind".into()], Call { destination: None, cleanup: None, .. } => vec![], - Yield { drop: Some(_), .. } => vec!["resume".into_cow(), "drop".into_cow()], - Yield { drop: None, .. } => vec!["resume".into_cow()], + Yield { drop: Some(_), .. } => vec!["resume".into(), "drop".into()], + Yield { drop: None, .. } => vec!["resume".into()], DropAndReplace { unwind: None, .. } | Drop { unwind: None, .. } => { - vec!["return".into_cow()] + vec!["return".into()] } DropAndReplace { unwind: Some(_), .. } | Drop { unwind: Some(_), .. - } => vec!["return".into_cow(), "unwind".into_cow()], + } => vec!["return".into(), "unwind".into()], Assert { cleanup: None, .. } => vec!["".into()], - Assert { .. } => vec!["success".into_cow(), "unwind".into_cow()], + Assert { .. } => vec!["success".into(), "unwind".into()], FalseEdges { ref imaginary_targets, .. @@ -1595,6 +1674,10 @@ /// Changes a statement to a nop. This is both faster than deleting instructions and avoids /// invalidating statement indices in `Location`s. pub fn make_nop(&mut self) { + // `Statement` contributes significantly to peak memory usage. Make + // sure it doesn't get bigger. + static_assert!(STATEMENT_IS_AT_MOST_56_BYTES: mem::size_of::>() <= 56); + self.kind = StatementKind::Nop } @@ -1610,11 +1693,13 @@ #[derive(Clone, Debug, RustcEncodable, RustcDecodable)] pub enum StatementKind<'tcx> { /// Write the RHS Rvalue to the LHS Place. - Assign(Place<'tcx>, Rvalue<'tcx>), + Assign(Place<'tcx>, Box>), /// This represents all the reading that a pattern match may do - /// (e.g. inspecting constants and discriminant values). - ReadForMatch(Place<'tcx>), + /// (e.g. inspecting constants and discriminant values), and the + /// kind of pattern it comes from. This is in order to adapt potential + /// error messages to these specific patterns. + FakeRead(FakeReadCause, Place<'tcx>), /// Write the discriminant for a variant to the enum Place. SetDiscriminant { @@ -1631,8 +1716,8 @@ /// Execute a piece of inline Assembly. InlineAsm { asm: Box, - outputs: Vec>, - inputs: Vec>, + outputs: Box<[Place<'tcx>]>, + inputs: Box<[Operand<'tcx>]>, }, /// Assert the given places to be valid inhabitants of their type. These statements are @@ -1656,12 +1741,41 @@ /// - `Contravariant` -- requires that `T_y :> T` /// - `Invariant` -- requires that `T_y == T` /// - `Bivariant` -- no effect - AscribeUserType(Place<'tcx>, ty::Variance, CanonicalTy<'tcx>), + AscribeUserType(Place<'tcx>, ty::Variance, Box>), /// No-op. Useful for deleting instructions without affecting statement indices. Nop, } +/// The `FakeReadCause` describes the type of pattern why a `FakeRead` statement exists. +#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug)] +pub enum FakeReadCause { + /// Inject a fake read of the borrowed input at the start of each arm's + /// pattern testing code. + /// + /// This should ensure that you cannot change the variant for an enum + /// while you are in the midst of matching on it. + ForMatchGuard, + + /// `let x: !; match x {}` doesn't generate any read of x so we need to + /// generate a read of x to check that it is initialized and safe. + ForMatchedPlace, + + /// Officially, the semantics of + /// + /// `let pattern = ;` + /// + /// is that `` is evaluated into a temporary and then this temporary is + /// into the pattern. + /// + /// However, if we see the simple pattern `let var = `, we optimize this to + /// evaluate `` directly into the variable `var`. This is mostly unobservable, + /// but in some cases it can affect the borrow checker, as in #53695. + /// Therefore, we insert a "fake read" here to ensure that we get + /// appropriate errors. + ForLet, +} + /// The `ValidationOp` describes what happens with each of the operands of a /// `Validate` statement. #[derive(Copy, Clone, RustcEncodable, RustcDecodable, PartialEq, Eq)] @@ -1679,7 +1793,7 @@ } impl Debug for ValidationOp { - fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result { use self::ValidationOp::*; match *self { Acquire => write!(fmt, "Acquire"), @@ -1700,7 +1814,7 @@ } impl<'tcx, T: Debug> Debug for ValidationOperand<'tcx, T> { - fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result { write!(fmt, "{:?}: {:?}", self.place, self.ty)?; if let Some(ce) = self.re { // (reuse lifetime rendering policy from ppaux.) @@ -1714,11 +1828,11 @@ } impl<'tcx> Debug for Statement<'tcx> { - fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result { use self::StatementKind::*; match self.kind { Assign(ref place, ref rv) => write!(fmt, "{:?} = {:?}", place, rv), - ReadForMatch(ref place) => write!(fmt, "ReadForMatch({:?})", place), + FakeRead(ref cause, ref place) => write!(fmt, "FakeRead({:?}, {:?})", cause, place), // (reuse lifetime rendering policy from ppaux.) EndRegion(ref ce) => write!(fmt, "EndRegion({})", ty::ReScope(*ce)), Validate(ref op, ref places) => write!(fmt, "Validate({:?}, {:?})", op, places), @@ -1746,7 +1860,7 @@ /// A path to a value; something that can be evaluated without /// changing or disturbing program state. -#[derive(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)] pub enum Place<'tcx> { /// local variable Local(Local), @@ -1763,7 +1877,7 @@ /// The def-id of a static, along with its normalized type (which is /// stored to avoid requiring normalization when reading MIR). -#[derive(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)] pub struct Static<'tcx> { pub def_id: DefId, pub ty: Ty<'tcx>, @@ -1778,13 +1892,13 @@ /// or `*B` or `B[index]`. Note that it is parameterized because it is /// shared between `Constant` and `Place`. See the aliases /// `PlaceProjection` etc below. -#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)] pub struct Projection<'tcx, B, V, T> { pub base: B, pub elem: ProjectionElem<'tcx, V, T>, } -#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)] pub enum ProjectionElem<'tcx, V, T> { Deref, Field(Field, T), @@ -1830,6 +1944,10 @@ /// and the index is a local. pub type PlaceElem<'tcx> = ProjectionElem<'tcx, Local, Ty<'tcx>>; +/// Alias for projections as they appear in `UserTypeProjection`, where we +/// need neither the `V` parameter for `Index` nor the `T` for `Field`. +pub type ProjectionKind<'tcx> = ProjectionElem<'tcx, (), ()>; + newtype_index! { pub struct Field { DEBUG_FORMAT = "field[{}]" @@ -1856,10 +1974,34 @@ pub fn elem(self, elem: PlaceElem<'tcx>) -> Place<'tcx> { Place::Projection(Box::new(PlaceProjection { base: self, elem })) } + + /// Find the innermost `Local` from this `Place`, *if* it is either a local itself or + /// a single deref of a local. + /// + /// FIXME: can we safely swap the semantics of `fn base_local` below in here instead? + pub fn local(&self) -> Option { + match self { + Place::Local(local) | + Place::Projection(box Projection { + base: Place::Local(local), + elem: ProjectionElem::Deref, + }) => Some(*local), + _ => None, + } + } + + /// Find the innermost `Local` from this `Place`. + pub fn base_local(&self) -> Option { + match self { + Place::Local(local) => Some(*local), + Place::Projection(box Projection { base, elem: _ }) => base.base_local(), + Place::Promoted(..) | Place::Static(..) => None, + } + } } impl<'tcx> Debug for Place<'tcx> { - fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result { use self::Place::*; match *self { @@ -1931,9 +2073,8 @@ /////////////////////////////////////////////////////////////////////////// // Operands -/// These are values that can appear inside an rvalue (or an index -/// place). They are intentionally limited to prevent rvalues from -/// being nested in one another. +/// These are values that can appear inside an rvalue. They are intentionally +/// limited to prevent rvalues from being nested in one another. #[derive(Clone, PartialEq, RustcEncodable, RustcDecodable)] pub enum Operand<'tcx> { /// Copy: The value must be available for use afterwards. @@ -1954,7 +2095,7 @@ } impl<'tcx> Debug for Operand<'tcx> { - fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result { use self::Operand::*; match *self { Constant(ref a) => write!(fmt, "{:?}", a), @@ -2066,7 +2207,7 @@ &'tcx AdtDef, usize, &'tcx Substs<'tcx>, - Option>, + Option>, Option, ), @@ -2139,7 +2280,7 @@ } impl<'tcx> Debug for Rvalue<'tcx> { - fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result { use self::Rvalue::*; match *self { @@ -2159,6 +2300,7 @@ Ref(region, borrow_kind, ref place) => { let kind_str = match borrow_kind { BorrowKind::Shared => "", + BorrowKind::Shallow => "shallow ", BorrowKind::Mut { .. } | BorrowKind::Unique => "mut ", }; @@ -2177,7 +2319,7 @@ } Aggregate(ref kind, ref places) => { - fn fmt_tuple(fmt: &mut Formatter, places: &[Operand]) -> fmt::Result { + fn fmt_tuple(fmt: &mut Formatter<'_>, places: &[Operand<'_>]) -> fmt::Result { let mut tuple_fmt = fmt.debug_tuple(""); for place in places { tuple_fmt.field(place); @@ -2269,7 +2411,7 @@ /// this does not necessarily mean that they are "==" in Rust -- in /// particular one must be wary of `NaN`! -#[derive(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] pub struct Constant<'tcx> { pub span: Span, pub ty: Ty<'tcx>, @@ -2279,11 +2421,149 @@ /// indicate that `Vec<_>` was explicitly specified. /// /// Needed for NLL to impose user-given type constraints. - pub user_ty: Option>, + pub user_ty: Option>, pub literal: &'tcx ty::Const<'tcx>, } +/// A user-given type annotation attached to a constant. These arise +/// from constants that are named via paths, like `Foo::::new` and +/// so forth. +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] +pub enum UserTypeAnnotation<'tcx> { + Ty(CanonicalTy<'tcx>), + + /// The canonical type is the result of `type_of(def_id)` with the + /// given substitutions applied. + TypeOf(DefId, CanonicalUserSubsts<'tcx>), +} + +EnumTypeFoldableImpl! { + impl<'tcx> TypeFoldable<'tcx> for UserTypeAnnotation<'tcx> { + (UserTypeAnnotation::Ty)(ty), + (UserTypeAnnotation::TypeOf)(def, substs), + } +} + +EnumLiftImpl! { + impl<'a, 'tcx> Lift<'tcx> for UserTypeAnnotation<'a> { + type Lifted = UserTypeAnnotation<'tcx>; + (UserTypeAnnotation::Ty)(ty), + (UserTypeAnnotation::TypeOf)(def, substs), + } +} + +/// A collection of projections into user types. +/// +/// They are projections because a binding can occur a part of a +/// parent pattern that has been ascribed a type. +/// +/// Its a collection because there can be multiple type ascriptions on +/// the path from the root of the pattern down to the binding itself. +/// +/// An example: +/// +/// ```rust +/// struct S<'a>((i32, &'a str), String); +/// let S((_, w): (i32, &'static str), _): S = ...; +/// // ------ ^^^^^^^^^^^^^^^^^^^ (1) +/// // --------------------------------- ^ (2) +/// ``` +/// +/// The highlights labelled `(1)` show the subpattern `(_, w)` being +/// ascribed the type `(i32, &'static str)`. +/// +/// The highlights labelled `(2)` show the whole pattern being +/// ascribed the type `S`. +/// +/// In this example, when we descend to `w`, we will have built up the +/// following two projected types: +/// +/// * base: `S`, projection: `(base.0).1` +/// * base: `(i32, &'static str)`, projection: `base.1` +/// +/// The first will lead to the constraint `w: &'1 str` (for some +/// inferred region `'1`). The second will lead to the constraint `w: +/// &'static str`. +#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] +pub struct UserTypeProjections<'tcx> { + pub(crate) contents: Vec<(UserTypeProjection<'tcx>, Span)>, +} + +BraceStructTypeFoldableImpl! { + impl<'tcx> TypeFoldable<'tcx> for UserTypeProjections<'tcx> { + contents + } +} + +impl<'tcx> UserTypeProjections<'tcx> { + pub fn none() -> Self { + UserTypeProjections { contents: vec![] } + } + + pub fn from_projections(projs: impl Iterator, Span)>) -> Self { + UserTypeProjections { contents: projs.collect() } + } + + pub fn projections_and_spans(&self) -> impl Iterator, Span)> { + self.contents.iter() + } + + pub fn projections(&self) -> impl Iterator> { + self.contents.iter().map(|&(ref user_type, _span)| user_type) + } +} + +/// Encodes the effect of a user-supplied type annotation on the +/// subcomponents of a pattern. The effect is determined by applying the +/// given list of proejctions to some underlying base type. Often, +/// the projection element list `projs` is empty, in which case this +/// directly encodes a type in `base`. But in the case of complex patterns with +/// subpatterns and bindings, we want to apply only a *part* of the type to a variable, +/// in which case the `projs` vector is used. +/// +/// Examples: +/// +/// * `let x: T = ...` -- here, the `projs` vector is empty. +/// +/// * `let (x, _): T = ...` -- here, the `projs` vector would contain +/// `field[0]` (aka `.0`), indicating that the type of `s` is +/// determined by finding the type of the `.0` field from `T`. +#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] +pub struct UserTypeProjection<'tcx> { + pub base: UserTypeAnnotation<'tcx>, + pub projs: Vec>, +} + +impl<'tcx> Copy for ProjectionKind<'tcx> { } + +CloneTypeFoldableAndLiftImpls! { ProjectionKind<'tcx>, } + +impl<'tcx> TypeFoldable<'tcx> for UserTypeProjection<'tcx> { + fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + use mir::ProjectionElem::*; + + let base = self.base.fold_with(folder); + let projs: Vec<_> = self.projs + .iter() + .map(|elem| { + match elem { + Deref => Deref, + Field(f, ()) => Field(f.clone(), ()), + Index(()) => Index(()), + elem => elem.clone(), + }}) + .collect(); + + UserTypeProjection { base, projs } + } + + fn super_visit_with>(&self, visitor: &mut Vs) -> bool { + self.base.visit_with(visitor) + // Note: there's nothing in `self.proj` to visit. + } +} + newtype_index! { pub struct Promoted { DEBUG_FORMAT = "promoted[{}]" @@ -2291,14 +2571,14 @@ } impl<'tcx> Debug for Constant<'tcx> { - fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result { write!(fmt, "const ")?; fmt_const_val(fmt, self.literal) } } /// Write a `ConstValue` in a way closer to the original source code than the `Debug` output. -pub fn fmt_const_val(f: &mut impl Write, const_val: &ty::Const) -> fmt::Result { +pub fn fmt_const_val(f: &mut impl Write, const_val: &ty::Const<'_>) -> fmt::Result { use ty::TyKind::*; let value = const_val.val; let ty = const_val.ty; @@ -2332,7 +2612,7 @@ // print string literals if let ConstValue::ScalarPair(ptr, len) = value { if let Scalar::Ptr(ptr) = ptr { - if let ScalarMaybeUndef::Scalar(Scalar::Bits { bits: len, .. }) = len { + if let Scalar::Bits { bits: len, .. } = len { if let Ref(_, &ty::TyS { sty: Str, .. }, _) = ty.sty { return ty::tls::with(|tcx| { let alloc = tcx.alloc_map.lock().get(ptr.alloc_id); @@ -2413,7 +2693,7 @@ } impl fmt::Debug for Location { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "{:?}[{}]", self.block, self.statement_index) } } @@ -2553,11 +2833,53 @@ // This region or type ... pub subject: ClosureOutlivesSubject<'tcx>, - // .. must outlive this one. + // ... must outlive this one. pub outlived_free_region: ty::RegionVid, - // If not, report an error here. + // If not, report an error here ... pub blame_span: Span, + + // ... due to this reason. + pub category: ConstraintCategory, +} + +/// Outlives constraints can be categorized to determine whether and why they +/// are interesting (for error reporting). Order of variants indicates sort +/// order of the category, thereby influencing diagnostic output. +/// +/// See also [rustc_mir::borrow_check::nll::constraints] +#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)] +pub enum ConstraintCategory { + Return, + UseAsConst, + UseAsStatic, + TypeAnnotation, + Cast, + + /// A constraint that came from checking the body of a closure. + /// + /// We try to get the category that the closure used when reporting this. + ClosureBounds, + CallArgument, + CopyBound, + SizedBound, + Assignment, + OpaqueType, + + /// A "boring" constraint (caused by the given location) is one that + /// the user probably doesn't want to see described in diagnostics, + /// because it is kind of an artifact of the type system setup. + /// Example: `x = Foo { field: y }` technically creates + /// intermediate regions representing the "type of `Foo { field: y + /// }`", and data flows from `y` into those variables, but they + /// are not very interesting. The assignment into `x` on the other + /// hand might be. + Boring, + // Boring and applicable everywhere. + BoringNoLocation, + + /// A constraint that doesn't correspond to anything the user sees. + Internal, } /// The subject of a ClosureOutlivesRequirement -- that is, the thing @@ -2582,9 +2904,11 @@ */ CloneTypeFoldableAndLiftImpls! { + BlockTailInfo, Mutability, SourceInfo, UpvarDecl, + FakeReadCause, ValidationOp, SourceScope, SourceScopeData, @@ -2624,6 +2948,7 @@ user_ty, name, source_info, + is_block_tail, visibility_scope, } } @@ -2651,7 +2976,7 @@ EnumTypeFoldableImpl! { impl<'tcx> TypeFoldable<'tcx> for StatementKind<'tcx> { (StatementKind::Assign)(a, b), - (StatementKind::ReadForMatch)(place), + (StatementKind::FakeRead)(cause, place), (StatementKind::SetDiscriminant) { place, variant_index }, (StatementKind::StorageLive)(a), (StatementKind::StorageDead)(a), @@ -2721,6 +3046,7 @@ ref args, ref destination, cleanup, + from_hir_call, } => { let dest = destination .as_ref() @@ -2731,6 +3057,7 @@ args: args.fold_with(folder), destination: dest, cleanup, + from_hir_call, } } Assert { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/mir/mono.rs rustc-1.31.0+dfsg1+llvm/src/librustc/mir/mono.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/mir/mono.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/mir/mono.rs 2018-12-04 23:41:40.000000000 +0000 @@ -121,7 +121,7 @@ pub fn new(name: InternedString) -> CodegenUnit<'tcx> { CodegenUnit { name: name, - items: FxHashMap(), + items: Default::default(), size_estimate: None, } } @@ -251,7 +251,7 @@ pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Self { CodegenUnitNameBuilder { tcx, - cache: FxHashMap(), + cache: Default::default(), } } @@ -325,7 +325,7 @@ String::new() }; - let crate_disambiguator = format!("{}", tcx.crate_disambiguator(cnum)); + let crate_disambiguator = tcx.crate_disambiguator(cnum).to_string(); // Using a shortened disambiguator of about 40 bits format!("{}.{}{}", tcx.crate_name(cnum), diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/mir/tcx.rs rustc-1.31.0+dfsg1+llvm/src/librustc/mir/tcx.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/mir/tcx.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/mir/tcx.rs 2018-12-04 23:41:40.000000000 +0000 @@ -44,11 +44,61 @@ } } + /// `place_ty.field_ty(tcx, f)` computes the type at a given field + /// of a record or enum-variant. (Most clients of `PlaceTy` can + /// instead just extract the relevant type directly from their + /// `PlaceElem`, but some instances of `ProjectionElem` do + /// not carry a `Ty` for `T`.) + /// + /// Note that the resulting type has not been normalized. + pub fn field_ty(self, tcx: TyCtxt<'a, 'gcx, 'tcx>, f: &Field) -> Ty<'tcx> + { + // Pass `0` here so it can be used as a "default" variant_index in first arm below + let answer = match (self, 0) { + (PlaceTy::Ty { + ty: &ty::TyS { sty: ty::TyKind::Adt(adt_def, substs), .. } }, variant_index) | + (PlaceTy::Downcast { adt_def, substs, variant_index }, _) => { + let variant_def = &adt_def.variants[variant_index]; + let field_def = &variant_def.fields[f.index()]; + field_def.ty(tcx, substs) + } + (PlaceTy::Ty { ty }, _) => { + match ty.sty { + ty::Tuple(ref tys) => tys[f.index()], + _ => bug!("extracting field of non-tuple non-adt: {:?}", self), + } + } + }; + debug!("field_ty self: {:?} f: {:?} yields: {:?}", self, f, answer); + answer + } + + /// Convenience wrapper around `projection_ty_core` for + /// `PlaceElem`, where we can just use the `Ty` that is already + /// stored inline on field projection elems. pub fn projection_ty(self, tcx: TyCtxt<'a, 'gcx, 'tcx>, elem: &PlaceElem<'tcx>) -> PlaceTy<'tcx> { - match *elem { + self.projection_ty_core(tcx, elem, |_, _, ty| -> Result, ()> { Ok(ty) }) + .unwrap() + } + + /// `place_ty.projection_ty_core(tcx, elem, |...| { ... })` + /// projects `place_ty` onto `elem`, returning the appropriate + /// `Ty` or downcast variant corresponding to that projection. + /// The `handle_field` callback must map a `Field` to its `Ty`, + /// (which should be trivial when `T` = `Ty`). + pub fn projection_ty_core( + self, + tcx: TyCtxt<'a, 'gcx, 'tcx>, + elem: &ProjectionElem<'tcx, V, T>, + mut handle_field: impl FnMut(&Self, &Field, &T) -> Result, E>) + -> Result, E> + where + V: ::std::fmt::Debug, T: ::std::fmt::Debug + { + let answer = match *elem { ProjectionElem::Deref => { let ty = self.to_ty(tcx) .builtin_deref(true) @@ -87,15 +137,18 @@ assert!(index < adt_def.variants.len()); assert_eq!(adt_def, adt_def1); PlaceTy::Downcast { adt_def, - substs, - variant_index: index } + substs, + variant_index: index } } _ => { bug!("cannot downcast non-ADT type: `{:?}`", self) } }, - ProjectionElem::Field(_, fty) => PlaceTy::Ty { ty: fty } - } + ProjectionElem::Field(ref f, ref fty) => + PlaceTy::Ty { ty: handle_field(&self, f, fty)? }, + }; + debug!("projection_ty self: {:?} elem: {:?} yields: {:?}", self, elem, answer); + Ok(answer) } } @@ -151,7 +204,7 @@ } }, _ => None, - } + } _ => None, } } @@ -255,9 +308,9 @@ impl<'tcx> BinOp { pub fn ty<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, - lhs_ty: Ty<'tcx>, - rhs_ty: Ty<'tcx>) - -> Ty<'tcx> { + lhs_ty: Ty<'tcx>, + rhs_ty: Ty<'tcx>) + -> Ty<'tcx> { // FIXME: handle SIMD correctly match self { &BinOp::Add | &BinOp::Sub | &BinOp::Mul | &BinOp::Div | &BinOp::Rem | @@ -287,6 +340,10 @@ // use `&mut`. It gives all the capabilities of an `&uniq` // and hence is a safe "over approximation". BorrowKind::Unique => hir::MutMutable, + + // We have no type corresponding to a shallow borrow, so use + // `&` as an approximation. + BorrowKind::Shallow => hir::MutImmutable, } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/mir/traversal.rs rustc-1.31.0+dfsg1+llvm/src/librustc/mir/traversal.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/mir/traversal.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/mir/traversal.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rustc_data_structures::bitvec::BitArray; +use rustc_data_structures::bit_set::BitSet; use super::*; @@ -32,7 +32,7 @@ #[derive(Clone)] pub struct Preorder<'a, 'tcx: 'a> { mir: &'a Mir<'tcx>, - visited: BitArray, + visited: BitSet, worklist: Vec, } @@ -42,7 +42,7 @@ Preorder { mir, - visited: BitArray::new(mir.basic_blocks().len()), + visited: BitSet::new_empty(mir.basic_blocks().len()), worklist, } } @@ -104,7 +104,7 @@ /// A Postorder traversal of this graph is `D B C A` or `D C B A` pub struct Postorder<'a, 'tcx: 'a> { mir: &'a Mir<'tcx>, - visited: BitArray, + visited: BitSet, visit_stack: Vec<(BasicBlock, Successors<'a>)> } @@ -112,7 +112,7 @@ pub fn new(mir: &'a Mir<'tcx>, root: BasicBlock) -> Postorder<'a, 'tcx> { let mut po = Postorder { mir, - visited: BitArray::new(mir.basic_blocks().len()), + visited: BitSet::new_empty(mir.basic_blocks().len()), visit_stack: Vec::new() }; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/mir/visit.rs rustc-1.31.0+dfsg1+llvm/src/librustc/mir/visit.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/mir/visit.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/mir/visit.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,7 @@ use hir::def_id::DefId; use ty::subst::Substs; -use ty::{CanonicalTy, ClosureSubsts, GeneratorSubsts, Region, Ty}; +use ty::{ClosureSubsts, GeneratorSubsts, Region, Ty}; use mir::*; use syntax_pos::Span; @@ -147,9 +147,9 @@ fn visit_ascribe_user_ty(&mut self, place: & $($mutability)* Place<'tcx>, variance: & $($mutability)* ty::Variance, - c_ty: & $($mutability)* CanonicalTy<'tcx>, + user_ty: & $($mutability)* UserTypeProjection<'tcx>, location: Location) { - self.super_ascribe_user_ty(place, variance, c_ty, location); + self.super_ascribe_user_ty(place, variance, user_ty, location); } fn visit_place(&mut self, @@ -175,9 +175,8 @@ fn visit_projection_elem(&mut self, place: & $($mutability)* PlaceElem<'tcx>, - context: PlaceContext<'tcx>, location: Location) { - self.super_projection_elem(place, context, location); + self.super_projection_elem(place, location); } fn visit_branch(&mut self, @@ -214,8 +213,18 @@ self.super_ty(ty); } - fn visit_canonical_ty(&mut self, ty: & $($mutability)* CanonicalTy<'tcx>) { - self.super_canonical_ty(ty); + fn visit_user_type_projection( + &mut self, + ty: & $($mutability)* UserTypeProjection<'tcx>, + ) { + self.super_user_type_projection(ty); + } + + fn visit_user_type_annotation( + &mut self, + ty: & $($mutability)* UserTypeAnnotation<'tcx>, + ) { + self.super_user_type_annotation(ty); } fn visit_region(&mut self, @@ -354,34 +363,55 @@ ref $($mutability)* rvalue) => { self.visit_assign(block, place, rvalue, location); } - StatementKind::ReadForMatch(ref $($mutability)* place) => { - self.visit_place(place, - PlaceContext::Inspect, - location); + StatementKind::FakeRead(_, ref $($mutability)* place) => { + self.visit_place( + place, + PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect), + location + ); } StatementKind::EndRegion(_) => {} StatementKind::Validate(_, ref $($mutability)* places) => { for operand in places { - self.visit_place(& $($mutability)* operand.place, - PlaceContext::Validate, location); + self.visit_place( + & $($mutability)* operand.place, + PlaceContext::NonUse(NonUseContext::Validate), + location + ); self.visit_ty(& $($mutability)* operand.ty, TyContext::Location(location)); } } StatementKind::SetDiscriminant{ ref $($mutability)* place, .. } => { - self.visit_place(place, PlaceContext::Store, location); + self.visit_place( + place, + PlaceContext::MutatingUse(MutatingUseContext::Store), + location + ); } StatementKind::StorageLive(ref $($mutability)* local) => { - self.visit_local(local, PlaceContext::StorageLive, location); + self.visit_local( + local, + PlaceContext::NonUse(NonUseContext::StorageLive), + location + ); } StatementKind::StorageDead(ref $($mutability)* local) => { - self.visit_local(local, PlaceContext::StorageDead, location); + self.visit_local( + local, + PlaceContext::NonUse(NonUseContext::StorageDead), + location + ); } StatementKind::InlineAsm { ref $($mutability)* outputs, ref $($mutability)* inputs, asm: _ } => { for output in & $($mutability)* outputs[..] { - self.visit_place(output, PlaceContext::AsmOutput, location); + self.visit_place( + output, + PlaceContext::MutatingUse(MutatingUseContext::AsmOutput), + location + ); } for input in & $($mutability)* inputs[..] { self.visit_operand(input, location); @@ -390,9 +420,9 @@ StatementKind::AscribeUserType( ref $($mutability)* place, ref $($mutability)* variance, - ref $($mutability)* c_ty, + ref $($mutability)* user_ty, ) => { - self.visit_ascribe_user_ty(place, variance, c_ty, location); + self.visit_ascribe_user_ty(place, variance, user_ty, location); } StatementKind::Nop => {} } @@ -403,7 +433,11 @@ place: &$($mutability)* Place<'tcx>, rvalue: &$($mutability)* Rvalue<'tcx>, location: Location) { - self.visit_place(place, PlaceContext::Store, location); + self.visit_place( + place, + PlaceContext::MutatingUse(MutatingUseContext::Store), + location + ); self.visit_rvalue(rvalue, location); } @@ -450,7 +484,11 @@ TerminatorKind::Drop { ref $($mutability)* location, target, unwind } => { - self.visit_place(location, PlaceContext::Drop, source_location); + self.visit_place( + location, + PlaceContext::MutatingUse(MutatingUseContext::Drop), + source_location + ); self.visit_branch(block, target); unwind.map(|t| self.visit_branch(block, t)); } @@ -459,7 +497,11 @@ ref $($mutability)* value, target, unwind } => { - self.visit_place(location, PlaceContext::Drop, source_location); + self.visit_place( + location, + PlaceContext::MutatingUse(MutatingUseContext::Drop), + source_location + ); self.visit_operand(value, source_location); self.visit_branch(block, target); unwind.map(|t| self.visit_branch(block, t)); @@ -468,13 +510,18 @@ TerminatorKind::Call { ref $($mutability)* func, ref $($mutability)* args, ref $($mutability)* destination, - cleanup } => { + cleanup, + from_hir_call: _, } => { self.visit_operand(func, source_location); for arg in args { self.visit_operand(arg, source_location); } if let Some((ref $($mutability)* destination, target)) = *destination { - self.visit_place(destination, PlaceContext::Call, source_location); + self.visit_place( + destination, + PlaceContext::MutatingUse(MutatingUseContext::Call), + source_location + ); self.visit_branch(block, target); } cleanup.map(|t| self.visit_branch(block, t)); @@ -542,14 +589,28 @@ Rvalue::Ref(ref $($mutability)* r, bk, ref $($mutability)* path) => { self.visit_region(r, location); - self.visit_place(path, PlaceContext::Borrow { - region: *r, - kind: bk - }, location); + let ctx = match bk { + BorrowKind::Shared => PlaceContext::NonMutatingUse( + NonMutatingUseContext::SharedBorrow(*r) + ), + BorrowKind::Shallow => PlaceContext::NonMutatingUse( + NonMutatingUseContext::ShallowBorrow(*r) + ), + BorrowKind::Unique => PlaceContext::NonMutatingUse( + NonMutatingUseContext::UniqueBorrow(*r) + ), + BorrowKind::Mut { .. } => + PlaceContext::MutatingUse(MutatingUseContext::Borrow(*r)), + }; + self.visit_place(path, ctx, location); } Rvalue::Len(ref $($mutability)* path) => { - self.visit_place(path, PlaceContext::Inspect, location); + self.visit_place( + path, + PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect), + location + ); } Rvalue::Cast(_cast_kind, @@ -574,7 +635,11 @@ } Rvalue::Discriminant(ref $($mutability)* place) => { - self.visit_place(place, PlaceContext::Inspect, location); + self.visit_place( + place, + PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect), + location + ); } Rvalue::NullaryOp(_op, ref $($mutability)* ty) => { @@ -622,10 +687,18 @@ location: Location) { match *operand { Operand::Copy(ref $($mutability)* place) => { - self.visit_place(place, PlaceContext::Copy, location); + self.visit_place( + place, + PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy), + location + ); } Operand::Move(ref $($mutability)* place) => { - self.visit_place(place, PlaceContext::Move, location); + self.visit_place( + place, + PlaceContext::NonMutatingUse(NonMutatingUseContext::Move), + location + ); } Operand::Constant(ref $($mutability)* constant) => { self.visit_constant(constant, location); @@ -636,10 +709,14 @@ fn super_ascribe_user_ty(&mut self, place: & $($mutability)* Place<'tcx>, _variance: & $($mutability)* ty::Variance, - c_ty: & $($mutability)* CanonicalTy<'tcx>, + user_ty: & $($mutability)* UserTypeProjection<'tcx>, location: Location) { - self.visit_place(place, PlaceContext::Validate, location); - self.visit_canonical_ty(c_ty); + self.visit_place( + place, + PlaceContext::NonUse(NonUseContext::AscribeUserTy), + location + ); + self.visit_user_type_projection(user_ty); } fn super_place(&mut self, @@ -683,17 +760,16 @@ ref $($mutability)* elem, } = *proj; let context = if context.is_mutating_use() { - PlaceContext::Projection(Mutability::Mut) + PlaceContext::MutatingUse(MutatingUseContext::Projection) } else { - PlaceContext::Projection(Mutability::Not) + PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection) }; self.visit_place(base, context, location); - self.visit_projection_elem(elem, context, location); + self.visit_projection_elem(elem, location); } fn super_projection_elem(&mut self, proj: & $($mutability)* PlaceElem<'tcx>, - _context: PlaceContext<'tcx>, location: Location) { match *proj { ProjectionElem::Deref => { @@ -704,7 +780,11 @@ self.visit_ty(ty, TyContext::Location(location)); } ProjectionElem::Index(ref $($mutability)* local) => { - self.visit_local(local, PlaceContext::Copy, location); + self.visit_local( + local, + PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy), + location + ); } ProjectionElem::ConstantIndex { offset: _, min_length: _, @@ -727,14 +807,15 @@ ref $($mutability)* visibility_scope, internal: _, is_user_variable: _, + is_block_tail: _, } = *local_decl; self.visit_ty(ty, TyContext::LocalDecl { local, source_info: *source_info, }); - if let Some(user_ty) = user_ty { - self.visit_canonical_ty(user_ty); + for (user_ty, _) in & $($mutability)* user_ty.contents { + self.visit_user_type_projection(user_ty); } self.visit_source_info(source_info); self.visit_source_scope(visibility_scope); @@ -781,7 +862,21 @@ self.visit_source_scope(scope); } - fn super_canonical_ty(&mut self, _ty: & $($mutability)* CanonicalTy<'tcx>) { + fn super_user_type_projection( + &mut self, + ty: & $($mutability)* UserTypeProjection<'tcx>, + ) { + let UserTypeProjection { + ref $($mutability)* base, + projs: _, // Note: Does not visit projection elems! + } = *ty; + self.visit_user_type_annotation(base); + } + + fn super_user_type_annotation( + &mut self, + _ty: & $($mutability)* UserTypeAnnotation<'tcx>, + ) { } fn super_ty(&mut self, _ty: & $($mutability)* Ty<'tcx>) { @@ -872,122 +967,146 @@ } #[derive(Copy, Clone, Debug, PartialEq, Eq)] -pub enum PlaceContext<'tcx> { - // Appears as LHS of an assignment - Store, +pub enum NonMutatingUseContext<'tcx> { + /// Being inspected in some way, like loading a len. + Inspect, + /// Consumed as part of an operand. + Copy, + /// Consumed as part of an operand. + Move, + /// Shared borrow. + SharedBorrow(Region<'tcx>), + /// Shallow borrow. + ShallowBorrow(Region<'tcx>), + /// Unique borrow. + UniqueBorrow(Region<'tcx>), + /// Used as base for another place, e.g. `x` in `x.y`. Will not mutate the place. + /// For example, the projection `x.y` is not marked as a mutation in these cases: + /// + /// z = x.y; + /// f(&x.y); + /// + Projection, +} - // Can often be treated as a Store, but needs to be separate because - // ASM is allowed to read outputs as well, so a Store-AsmOutput sequence - // cannot be simplified the way a Store-Store can be. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum MutatingUseContext<'tcx> { + /// Appears as LHS of an assignment. + Store, + /// Can often be treated as a `Store`, but needs to be separate because + /// ASM is allowed to read outputs as well, so a `Store`-`AsmOutput` sequence + /// cannot be simplified the way a `Store`-`Store` can be. AsmOutput, - - // Dest of a call + /// Destination of a call. Call, - - // Being dropped + /// Being dropped. Drop, + /// Mutable borrow. + Borrow(Region<'tcx>), + /// Used as base for another place, e.g. `x` in `x.y`. Could potentially mutate the place. + /// For example, the projection `x.y` is marked as a mutation in these cases: + /// + /// x.y = ...; + /// f(&mut x.y); + /// + Projection, +} - // Being inspected in some way, like loading a len - Inspect, - - // Being borrowed - Borrow { region: Region<'tcx>, kind: BorrowKind }, - - // Used as base for another place, e.g. `x` in `x.y`. - // - // The `Mutability` argument specifies whether the projection is being performed in order to - // (potentially) mutate the place. For example, the projection `x.y` is marked as a mutation - // in these cases: - // - // x.y = ...; - // f(&mut x.y); - // - // But not in these cases: - // - // z = x.y; - // f(&x.y); - Projection(Mutability), - - // Consumed as part of an operand - Copy, - Move, - - // Starting and ending a storage live range +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum NonUseContext { + /// Starting a storage live range. StorageLive, + /// Ending a storage live range. StorageDead, - - // Validation command + /// User type annotation assertions for NLL. + AscribeUserTy, + /// Validation command. Validate, } +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum PlaceContext<'tcx> { + NonMutatingUse(NonMutatingUseContext<'tcx>), + MutatingUse(MutatingUseContext<'tcx>), + NonUse(NonUseContext), +} + impl<'tcx> PlaceContext<'tcx> { - /// Returns true if this place context represents a drop. + /// Returns `true` if this place context represents a drop. pub fn is_drop(&self) -> bool { match *self { - PlaceContext::Drop => true, + PlaceContext::MutatingUse(MutatingUseContext::Drop) => true, _ => false, } } - /// Returns true if this place context represents a storage live or storage dead marker. + /// Returns `true` if this place context represents a borrow. + pub fn is_borrow(&self) -> bool { + match *self { + PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow(..)) | + PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow(..)) | + PlaceContext::NonMutatingUse(NonMutatingUseContext::UniqueBorrow(..)) | + PlaceContext::MutatingUse(MutatingUseContext::Borrow(..)) => true, + _ => false, + } + } + + /// Returns `true` if this place context represents a storage live or storage dead marker. pub fn is_storage_marker(&self) -> bool { match *self { - PlaceContext::StorageLive | PlaceContext::StorageDead => true, + PlaceContext::NonUse(NonUseContext::StorageLive) | + PlaceContext::NonUse(NonUseContext::StorageDead) => true, _ => false, } } - /// Returns true if this place context represents a storage live marker. + /// Returns `true` if this place context represents a storage live marker. pub fn is_storage_live_marker(&self) -> bool { match *self { - PlaceContext::StorageLive => true, + PlaceContext::NonUse(NonUseContext::StorageLive) => true, _ => false, } } - /// Returns true if this place context represents a storage dead marker. + /// Returns `true` if this place context represents a storage dead marker. pub fn is_storage_dead_marker(&self) -> bool { match *self { - PlaceContext::StorageDead => true, + PlaceContext::NonUse(NonUseContext::StorageDead) => true, _ => false, } } - /// Returns true if this place context represents a use that potentially changes the value. + /// Returns `true` if this place context represents a use that potentially changes the value. pub fn is_mutating_use(&self) -> bool { match *self { - PlaceContext::Store | PlaceContext::AsmOutput | PlaceContext::Call | - 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::Projection(Mutability::Not) | - PlaceContext::Copy | PlaceContext::Move | - PlaceContext::StorageLive | PlaceContext::StorageDead | - PlaceContext::Validate => false, + PlaceContext::MutatingUse(..) => true, + _ => false, } } - /// Returns true if this place context represents a use that does not change the value. + /// Returns `true` if this place context represents a use that does not change the value. pub fn is_nonmutating_use(&self) -> bool { match *self { - PlaceContext::Inspect | PlaceContext::Borrow { kind: BorrowKind::Shared, .. } | - PlaceContext::Borrow { kind: BorrowKind::Unique, .. } | - PlaceContext::Projection(Mutability::Not) | - PlaceContext::Copy | PlaceContext::Move => true, - - PlaceContext::Borrow { kind: BorrowKind::Mut { .. }, .. } | PlaceContext::Store | - PlaceContext::AsmOutput | - PlaceContext::Call | PlaceContext::Projection(Mutability::Mut) | - PlaceContext::Drop | PlaceContext::StorageLive | PlaceContext::StorageDead | - PlaceContext::Validate => false, + PlaceContext::NonMutatingUse(..) => true, + _ => false, } } + /// Returns `true` if this place context represents a use. pub fn is_use(&self) -> bool { - self.is_mutating_use() || self.is_nonmutating_use() + match *self { + PlaceContext::NonUse(..) => false, + _ => true, + } + } + + /// Returns `true` if this place context represents an assignment statement. + pub fn is_place_assignment(&self) -> bool { + match *self { + PlaceContext::MutatingUse(MutatingUseContext::Store) | + PlaceContext::MutatingUse(MutatingUseContext::Call) | + PlaceContext::MutatingUse(MutatingUseContext::AsmOutput) => true, + _ => false, + } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/session/code_stats.rs rustc-1.31.0+dfsg1+llvm/src/librustc/session/code_stats.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/session/code_stats.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/session/code_stats.rs 2018-12-04 23:41:40.000000000 +0000 @@ -54,14 +54,12 @@ pub variants: Vec, } -#[derive(PartialEq, Eq, Debug)] +#[derive(PartialEq, Eq, Debug, Default)] pub struct CodeStats { type_sizes: FxHashSet, } impl CodeStats { - pub fn new() -> Self { CodeStats { type_sizes: FxHashSet() } } - pub fn record_type_size(&mut self, kind: DataTypeKind, type_desc: S, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/session/config.rs rustc-1.31.0+dfsg1+llvm/src/librustc/session/config.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/session/config.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/session/config.rs 2018-12-04 23:41:40.000000000 +0000 @@ -490,10 +490,10 @@ } impl Input { - pub fn filestem(&self) -> String { + pub fn filestem(&self) -> &str { match *self { - Input::File(ref ifile) => ifile.file_stem().unwrap().to_str().unwrap().to_string(), - Input::Str { .. } => "rust_out".to_string(), + Input::File(ref ifile) => ifile.file_stem().unwrap().to_str().unwrap(), + Input::Str { .. } => "rust_out", } } @@ -736,19 +736,19 @@ match (value, opt_type_desc) { (Some(..), None) => { early_error(error_format, &format!("{} option `{}` takes no \ - value", $outputname, key)) + value", $outputname, key)) } (None, Some(type_desc)) => { early_error(error_format, &format!("{0} option `{1}` requires \ - {2} ({3} {1}=)", - $outputname, key, - type_desc, $prefix)) + {2} ({3} {1}=)", + $outputname, key, + type_desc, $prefix)) } (Some(value), Some(type_desc)) => { early_error(error_format, &format!("incorrect value `{}` for {} \ - option `{}` - {} was expected", - value, $outputname, - key, type_desc)) + option `{}` - {} was expected", + value, $outputname, + key, type_desc)) } (None, None) => bug!() } @@ -758,14 +758,13 @@ } if !found { early_error(error_format, &format!("unknown {} option: `{}`", - $outputname, key)); + $outputname, key)); } } return op; } impl<'a> dep_tracking::DepTrackingHash for $struct_name { - fn hash(&self, hasher: &mut DefaultHasher, error_format: ErrorOutputType) { let mut sub_hashes = BTreeMap::new(); $({ @@ -782,7 +781,7 @@ pub type $setter_name = fn(&mut $struct_name, v: Option<&str>) -> bool; pub const $stat: &'static [(&'static str, $setter_name, - Option<&'static str>, &'static str)] = + Option<&'static str>, &'static str)] = &[ $( (stringify!($opt), $mod_set::$opt, $mod_desc::$parse, $desc) ),* ]; #[allow(non_upper_case_globals, dead_code)] @@ -1062,8 +1061,8 @@ ) } options! {CodegenOptions, CodegenSetter, basic_codegen_options, - build_codegen_options, "C", "codegen", - CG_OPTIONS, cg_type_desc, cgsetters, + build_codegen_options, "C", "codegen", + CG_OPTIONS, cg_type_desc, cgsetters, ar: Option = (None, parse_opt_string, [UNTRACKED], "this option is deprecated and does nothing"), linker: Option = (None, parse_opt_pathbuf, [UNTRACKED], @@ -1107,13 +1106,13 @@ no_redzone: Option = (None, parse_opt_bool, [TRACKED], "disable the use of the redzone"), relocation_model: Option = (None, parse_opt_string, [TRACKED], - "choose the relocation model to use (rustc --print relocation-models for details)"), + "choose the relocation model to use (rustc --print relocation-models for details)"), code_model: Option = (None, parse_opt_string, [TRACKED], - "choose the code model to use (rustc --print code-models for details)"), + "choose the code model to use (rustc --print code-models for details)"), metadata: Vec = (Vec::new(), parse_list, [TRACKED], - "metadata to mangle symbol names with"), + "metadata to mangle symbol names with"), extra_filename: String = (String::new(), parse_string, [UNTRACKED], - "extra data to put in each output filename"), + "extra data to put in each output filename"), codegen_units: Option = (None, parse_opt_uint, [UNTRACKED], "divide crate into N units to optimize in parallel"), remark: Passes = (Passes::Some(Vec::new()), parse_passes, [UNTRACKED], @@ -1134,12 +1133,14 @@ panic: Option = (None, parse_panic_strategy, [TRACKED], "panic strategy to compile crate with"), incremental: Option = (None, parse_opt_string, [UNTRACKED], - "enable incremental compilation"), + "enable incremental compilation"), + default_linker_libraries: Option = (None, parse_opt_bool, [UNTRACKED], + "allow the linker to link its default libraries"), } options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, - build_debugging_options, "Z", "debugging", - DB_OPTIONS, db_type_desc, dbsetters, + build_debugging_options, "Z", "debugging", + DB_OPTIONS, db_type_desc, dbsetters, codegen_backend: Option = (None, parse_opt_string, [TRACKED], "the backend to use"), verbose: bool = (false, parse_bool, [UNTRACKED], @@ -1209,26 +1210,26 @@ flowgraph_print_all: bool = (false, parse_bool, [UNTRACKED], "include all dataflow analysis data in -Z unpretty flowgraph output"), print_region_graph: bool = (false, parse_bool, [UNTRACKED], - "prints region inference graph. \ - Use with RUST_REGION_GRAPH=help for more info"), + "prints region inference graph. \ + Use with RUST_REGION_GRAPH=help for more info"), parse_only: bool = (false, parse_bool, [UNTRACKED], - "parse only; do not compile, assemble, or link"), + "parse only; do not compile, assemble, or link"), no_codegen: bool = (false, parse_bool, [TRACKED], - "run all passes except codegen; no output"), + "run all passes except codegen; no output"), treat_err_as_bug: bool = (false, parse_bool, [TRACKED], - "treat all errors that occur as bugs"), + "treat all errors that occur as bugs"), report_delayed_bugs: bool = (false, parse_bool, [TRACKED], - "immediately print bugs registered with `delay_span_bug`"), + "immediately print bugs registered with `delay_span_bug`"), external_macro_backtrace: bool = (false, parse_bool, [UNTRACKED], - "show macro backtraces even for non-local macros"), + "show macro backtraces even for non-local macros"), teach: bool = (false, parse_bool, [TRACKED], - "show extended diagnostic help"), + "show extended diagnostic help"), continue_parse_after_error: bool = (false, parse_bool, [TRACKED], - "attempt to recover from parse errors (experimental)"), + "attempt to recover from parse errors (experimental)"), incremental: Option = (None, parse_opt_string, [UNTRACKED], - "enable incremental compilation (experimental)"), + "enable incremental compilation (experimental)"), incremental_queries: bool = (true, parse_bool, [UNTRACKED], - "enable incremental compilation support for queries (experimental)"), + "enable incremental compilation support for queries (experimental)"), incremental_info: bool = (false, parse_bool, [UNTRACKED], "print high-level information about incremental reuse (or the lack thereof)"), incremental_dump_hash: bool = (false, parse_bool, [UNTRACKED], @@ -1238,64 +1239,64 @@ incremental_ignore_spans: bool = (false, parse_bool, [UNTRACKED], "ignore spans during ICH computation -- used for testing"), dump_dep_graph: bool = (false, parse_bool, [UNTRACKED], - "dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv)"), + "dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv)"), query_dep_graph: bool = (false, parse_bool, [UNTRACKED], - "enable queries of the dependency graph for regression testing"), + "enable queries of the dependency graph for regression testing"), profile_queries: bool = (false, parse_bool, [UNTRACKED], - "trace and profile the queries of the incremental compilation framework"), + "trace and profile the queries of the incremental compilation framework"), profile_queries_and_keys: bool = (false, parse_bool, [UNTRACKED], - "trace and profile the queries and keys of the incremental compilation framework"), + "trace and profile the queries and keys of the incremental compilation framework"), no_analysis: bool = (false, parse_bool, [UNTRACKED], - "parse and expand the source, but run no analysis"), + "parse and expand the source, but run no analysis"), extra_plugins: Vec = (Vec::new(), parse_list, [TRACKED], "load extra plugins"), unstable_options: bool = (false, parse_bool, [UNTRACKED], - "adds unstable command line options to rustc interface"), + "adds unstable command line options to rustc interface"), force_overflow_checks: Option = (None, parse_opt_bool, [TRACKED], - "force overflow checks on or off"), + "force overflow checks on or off"), trace_macros: bool = (false, parse_bool, [UNTRACKED], - "for every macro invocation, print its name and arguments"), + "for every macro invocation, print its name and arguments"), debug_macros: bool = (false, parse_bool, [TRACKED], - "emit line numbers debug info inside macros"), + "emit line numbers debug info inside macros"), keep_hygiene_data: bool = (false, parse_bool, [UNTRACKED], - "don't clear the hygiene data after analysis"), + "don't clear the hygiene data after analysis"), keep_ast: bool = (false, parse_bool, [UNTRACKED], - "keep the AST after lowering it to HIR"), + "keep the AST after lowering it to HIR"), show_span: Option = (None, parse_opt_string, [TRACKED], - "show spans for compiler debugging (expr|pat|ty)"), + "show spans for compiler debugging (expr|pat|ty)"), print_type_sizes: bool = (false, parse_bool, [UNTRACKED], - "print layout information for each type encountered"), + "print layout information for each type encountered"), print_mono_items: Option = (None, parse_opt_string, [UNTRACKED], - "print the result of the monomorphization collection pass"), + "print the result of the monomorphization collection pass"), mir_opt_level: usize = (1, parse_uint, [TRACKED], - "set the MIR optimization level (0-3, default: 1)"), + "set the MIR optimization level (0-3, default: 1)"), mutable_noalias: Option = (None, parse_opt_bool, [TRACKED], - "emit noalias metadata for mutable references (default: yes on LLVM >= 6)"), + "emit noalias metadata for mutable references (default: yes on LLVM >= 6)"), arg_align_attributes: bool = (false, parse_bool, [TRACKED], - "emit align metadata for reference arguments"), + "emit align metadata for reference arguments"), dump_mir: Option = (None, parse_opt_string, [UNTRACKED], - "dump MIR state at various points in transforms"), + "dump MIR state at various points in transforms"), dump_mir_dir: String = (String::from("mir_dump"), parse_string, [UNTRACKED], - "the directory the MIR is dumped into"), + "the directory the MIR is dumped into"), dump_mir_graphviz: bool = (false, parse_bool, [UNTRACKED], - "in addition to `.mir` files, create graphviz `.dot` files"), + "in addition to `.mir` files, create graphviz `.dot` files"), dump_mir_exclude_pass_number: bool = (false, parse_bool, [UNTRACKED], - "if set, exclude the pass number when dumping MIR (used in tests)"), + "if set, exclude the pass number when dumping MIR (used in tests)"), mir_emit_validate: usize = (0, parse_uint, [TRACKED], - "emit Validate MIR statements, interpreted e.g. by miri (0: do not emit; 1: if function \ - contains unsafe block, only validate arguments; 2: always emit full validation)"), + "emit Validate MIR statements, interpreted e.g. by miri (0: do not emit; 1: if function \ + contains unsafe block, only validate arguments; 2: always emit full validation)"), perf_stats: bool = (false, parse_bool, [UNTRACKED], - "print some performance-related statistics"), + "print some performance-related statistics"), hir_stats: bool = (false, parse_bool, [UNTRACKED], - "print some statistics about AST and HIR"), + "print some statistics about AST and HIR"), mir_stats: bool = (false, parse_bool, [UNTRACKED], - "print some statistics about MIR"), + "print some statistics about MIR"), always_encode_mir: bool = (false, parse_bool, [TRACKED], - "encode MIR of all functions into the crate metadata"), + "encode MIR of all functions into the crate metadata"), osx_rpath_install_name: bool = (false, parse_bool, [TRACKED], - "pass `-install_name @rpath/...` to the macOS linker"), + "pass `-install_name @rpath/...` to the macOS linker"), sanitizer: Option = (None, parse_sanitizer, [TRACKED], - "Use a sanitizer"), + "Use a sanitizer"), linker_flavor: Option = (None, parse_linker_flavor, [UNTRACKED], "Linker flavor"), fuel: Option<(String, u64)> = (None, parse_optimization_fuel, [TRACKED], @@ -1311,17 +1312,13 @@ profile: bool = (false, parse_bool, [TRACKED], "insert profiling code"), pgo_gen: Option = (None, parse_opt_string, [TRACKED], - "Generate PGO profile data, to a given file, or to the default \ - location if it's empty."), + "Generate PGO profile data, to a given file, or to the default location if it's empty."), pgo_use: String = (String::new(), parse_string, [TRACKED], "Use PGO profile data from the given profile file."), - disable_instrumentation_preinliner: bool = - (false, parse_bool, [TRACKED], "Disable the instrumentation pre-inliner, \ - useful for profiling / PGO."), + disable_instrumentation_preinliner: bool = (false, parse_bool, [TRACKED], + "Disable the instrumentation pre-inliner, useful for profiling / PGO."), relro_level: Option = (None, parse_relro_level, [TRACKED], "choose which RELRO level to use"), - disable_ast_check_for_mutation_in_guard: bool = (false, parse_bool, [UNTRACKED], - "skip AST-based mutation-in-guard check (mir-borrowck provides more precise check)"), nll_subminimal_causes: bool = (false, parse_bool, [UNTRACKED], "when tracking region error causes, accept subminimal results for faster execution."), nll_facts: bool = (false, parse_bool, [UNTRACKED], @@ -1329,7 +1326,9 @@ disable_nll_user_type_assert: bool = (false, parse_bool, [UNTRACKED], "disable user provided type assertion in NLL"), nll_dont_emit_read_for_match: bool = (false, parse_bool, [UNTRACKED], - "in match codegen, do not include ReadForMatch statements (used by mir-borrowck)"), + "in match codegen, do not include FakeRead statements (used by mir-borrowck)"), + dont_buffer_diagnostics: bool = (false, parse_bool, [UNTRACKED], + "emit diagnostics rather than buffering (breaks NLL error downgrading, sorting)."), polonius: bool = (false, parse_bool, [UNTRACKED], "enable polonius-based borrow-checker"), codegen_time_graph: bool = (false, parse_bool, [UNTRACKED], @@ -1339,7 +1338,7 @@ inline_in_all_cgus: Option = (None, parse_opt_bool, [TRACKED], "control whether #[inline] functions are in all cgus"), tls_model: Option = (None, parse_opt_string, [TRACKED], - "choose the TLS model to use (rustc --print tls-models for details)"), + "choose the TLS model to use (rustc --print tls-models for details)"), saturating_float_casts: bool = (false, parse_bool, [TRACKED], "make float->int casts UB-free: numbers outside the integer type's range are clipped to \ the max/min integer respectively, and NaN is mapped to 0"), @@ -1360,29 +1359,35 @@ `hir` (the HIR), `hir,identified`, or `hir,typed` (HIR with types for each node)."), run_dsymutil: Option = (None, parse_opt_bool, [TRACKED], - "run `dsymutil` and delete intermediate object files"), + "run `dsymutil` and delete intermediate object files"), ui_testing: bool = (false, parse_bool, [UNTRACKED], - "format compiler diagnostics in a way that's better suitable for UI testing"), + "format compiler diagnostics in a way that's better suitable for UI testing"), embed_bitcode: bool = (false, parse_bool, [TRACKED], - "embed LLVM bitcode in object files"), + "embed LLVM bitcode in object files"), strip_debuginfo_if_disabled: Option = (None, parse_opt_bool, [TRACKED], "tell the linker to strip debuginfo when building without debuginfo enabled."), share_generics: Option = (None, parse_opt_bool, [TRACKED], - "make the current crate share its generic instantiations"), + "make the current crate share its generic instantiations"), chalk: bool = (false, parse_bool, [TRACKED], - "enable the experimental Chalk-based trait solving engine"), + "enable the experimental Chalk-based trait solving engine"), cross_lang_lto: CrossLangLto = (CrossLangLto::Disabled, parse_cross_lang_lto, [TRACKED], - "generate build artifacts that are compatible with linker-based LTO."), + "generate build artifacts that are compatible with linker-based LTO."), no_parallel_llvm: bool = (false, parse_bool, [UNTRACKED], - "don't run LLVM in parallel (while keeping codegen-units and ThinLTO)"), + "don't run LLVM in parallel (while keeping codegen-units and ThinLTO)"), no_leak_check: bool = (false, parse_bool, [UNTRACKED], "disables the 'leak check' for subtyping; unsound, but useful for tests"), crate_attr: Vec = (Vec::new(), parse_string_push, [TRACKED], "inject the given attribute in the crate"), self_profile: bool = (false, parse_bool, [UNTRACKED], - "run the self profiler"), + "run the self profiler"), profile_json: bool = (false, parse_bool, [UNTRACKED], - "output a json file with profiler results"), + "output a json file with profiler results"), + emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED], + "emits a section containing stack size metadata"), + plt: Option = (None, parse_opt_bool, [TRACKED], + "whether to use the PLT when calling into shared libraries; + only has effect for PIC code on systems with ELF binaries + (default: PLT is disabled if full relro is enabled)"), } pub fn default_lib_output() -> CrateType { @@ -1401,6 +1406,7 @@ let atomic_cas = sess.target.target.options.atomic_cas; let mut ret = FxHashSet::default(); + ret.reserve(6); // the minimum number of insertions // Target bindings. ret.insert((Symbol::intern("target_os"), Some(Symbol::intern(os)))); if let Some(ref fam) = sess.target.target.options.target_family { @@ -1447,7 +1453,7 @@ if sess.opts.crate_types.contains(&CrateType::ProcMacro) { ret.insert((Symbol::intern("proc_macro"), None)); } - return ret; + ret } pub fn build_configuration(sess: &Session, mut user_cfg: ast::CrateConfig) -> ast::CrateConfig { @@ -1463,15 +1469,12 @@ } pub fn build_target_config(opts: &Options, sp: &Handler) -> Config { - let target = match Target::search(&opts.target_triple) { - Ok(t) => t, - Err(e) => { - sp.struct_fatal(&format!("Error loading target specification: {}", e)) - .help("Use `--print target-list` for a list of built-in targets") - .emit(); - FatalError.raise(); - } - }; + let target = Target::search(&opts.target_triple).unwrap_or_else(|e| { + sp.struct_fatal(&format!("Error loading target specification: {}", e)) + .help("Use `--print target-list` for a list of built-in targets") + .emit(); + FatalError.raise(); + }); let (isize_ty, usize_ty) = match &target.target_pointer_width[..] { "16" => (ast::IntTy::I16, ast::UintTy::U16), @@ -1494,7 +1497,6 @@ #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub enum OptionStability { Stable, - Unstable, } @@ -1837,18 +1839,17 @@ }; let edition = match matches.opt_str("edition") { - Some(arg) => match Edition::from_str(&arg){ - Ok(edition) => edition, - Err(_) => early_error( + Some(arg) => Edition::from_str(&arg).unwrap_or_else(|_| + early_error( ErrorOutputType::default(), &format!( "argument for --edition must be one of: \ - {}. (instead was `{}`)", + {}. (instead was `{}`)", EDITION_NAME_LIST, arg ), ), - } + ), None => DEFAULT_EDITION, }; @@ -1857,7 +1858,7 @@ ErrorOutputType::default(), &format!( "Edition {} is unstable and only \ - available for nightly builds of rustc.", + available for nightly builds of rustc.", edition, ) ) @@ -1917,9 +1918,8 @@ for output_type in list.split(',') { let mut parts = output_type.splitn(2, '='); let shorthand = parts.next().unwrap(); - let output_type = match OutputType::from_shorthand(shorthand) { - Some(output_type) => output_type, - None => early_error( + let output_type = OutputType::from_shorthand(shorthand).unwrap_or_else(|| + early_error( error_format, &format!( "unknown emission type: `{}` - expected one of: {}", @@ -1927,7 +1927,7 @@ OutputType::shorthands_display(), ), ), - }; + ); let path = parts.next().map(PathBuf::from); output_types.insert(output_type, path); } @@ -2055,12 +2055,8 @@ let target_triple = if let Some(target) = matches.opt_str("target") { if target.ends_with(".json") { let path = Path::new(&target); - match TargetTriple::from_path(&path) { - Ok(triple) => triple, - Err(_) => { - early_error(error_format, &format!("target file {:?} does not exist", path)) - } - } + TargetTriple::from_path(&path).unwrap_or_else(|_| + early_error(error_format, &format!("target file {:?} does not exist", path))) } else { TargetTriple::TargetTriple(target) } @@ -2161,7 +2157,7 @@ let mut name_parts = name.splitn(2, ':'); let name = name_parts.next().unwrap(); let new_name = name_parts.next(); - (name.to_string(), new_name.map(|n| n.to_string()), kind) + (name.to_owned(), new_name.map(|n| n.to_owned()), kind) }) .collect(); @@ -2215,10 +2211,8 @@ let mut externs: BTreeMap<_, BTreeSet<_>> = BTreeMap::new(); for arg in &matches.opt_strs("extern") { let mut parts = arg.splitn(2, '='); - let name = match parts.next() { - Some(s) => s, - None => early_error(error_format, "--extern value must not be empty"), - }; + let name = parts.next().unwrap_or_else(|| + early_error(error_format, "--extern value must not be empty")); let location = parts.next().map(|s| s.to_string()); if location.is_none() && !is_unstable_enabled { early_error( @@ -2229,7 +2223,7 @@ }; externs - .entry(name.to_string()) + .entry(name.to_owned()) .or_default() .insert(location); } @@ -2300,9 +2294,7 @@ "cdylib" => CrateType::Cdylib, "bin" => CrateType::Executable, "proc-macro" => CrateType::ProcMacro, - _ => { - return Err(format!("unknown crate type: `{}`", part)); - } + _ => return Err(format!("unknown crate type: `{}`", part)) }; if !crate_types.contains(&new_part) { crate_types.push(new_part) @@ -2375,7 +2367,7 @@ } impl fmt::Display for CrateType { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { CrateType::Executable => "bin".fmt(f), CrateType::Dylib => "dylib".fmt(f), diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/session/filesearch.rs rustc-1.31.0+dfsg1+llvm/src/librustc/session/filesearch.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/session/filesearch.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/session/filesearch.rs 2018-12-04 23:41:40.000000000 +0000 @@ -41,7 +41,7 @@ F: FnMut(&Path, PathKind) { let mut visited_dirs = FxHashSet::default(); - + visited_dirs.reserve(self.search_paths.paths.len() + 1); for (path, kind) in self.search_paths.iter(self.kind) { f(path, kind); visited_dirs.insert(path.to_path_buf()); @@ -160,7 +160,7 @@ match env::current_exe() { Ok(exe) => { match canonicalize(Some(exe)) { - Some(mut p) => { p.pop(); p.pop(); return p; }, + Some(mut p) => { p.pop(); p.pop(); p }, None => bug!("can't determine value for sysroot") } } @@ -175,18 +175,9 @@ // to lib64/lib32. This would be more foolproof by basing the sysroot off // of the directory where librustc is located, rather than where the rustc // binary is. - //If --libdir is set during configuration to the value other than + // If --libdir is set during configuration to the value other than // "lib" (i.e. non-default), this value is used (see issue #16552). - match option_env!("CFG_LIBDIR_RELATIVE") { - Some(libdir) if libdir != "lib" => return libdir.into(), - _ => if sysroot.join(PRIMARY_LIB_DIR).join(RUST_LIB_DIR).exists() { - return PRIMARY_LIB_DIR.into(); - } else { - return SECONDARY_LIB_DIR.into(); - } - } - #[cfg(target_pointer_width = "64")] const PRIMARY_LIB_DIR: &'static str = "lib64"; @@ -194,6 +185,15 @@ const PRIMARY_LIB_DIR: &'static str = "lib32"; const SECONDARY_LIB_DIR: &'static str = "lib"; + + match option_env!("CFG_LIBDIR_RELATIVE") { + Some(libdir) if libdir != "lib" => libdir.into(), + _ => if sysroot.join(PRIMARY_LIB_DIR).join(RUST_LIB_DIR).exists() { + PRIMARY_LIB_DIR.into() + } else { + SECONDARY_LIB_DIR.into() + } + } } // The name of rustc's own place to organize libraries. diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/session/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/session/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/session/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/session/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,6 +11,7 @@ pub use self::code_stats::{DataTypeKind, SizeKind, FieldInfo, VariantInfo}; use self::code_stats::CodeStats; +use dep_graph::cgu_reuse_tracker::CguReuseTracker; use hir::def_id::CrateNum; use rustc_data_structures::fingerprint::Fingerprint; @@ -27,21 +28,18 @@ use rustc_data_structures::base_n; use rustc_data_structures::sync::{self, Lrc, Lock, LockCell, OneThread, Once, RwLock}; -use syntax::ast::NodeId; -use errors::{self, DiagnosticBuilder, DiagnosticId}; +use errors::{self, DiagnosticBuilder, DiagnosticId, Applicability}; use errors::emitter::{Emitter, EmitterWriter}; +use syntax::ast::{self, NodeId}; use syntax::edition::Edition; +use syntax::feature_gate::{self, AttributeType}; use syntax::json::JsonEmitter; -use syntax::feature_gate; -use syntax::parse; -use syntax::parse::ParseSess; -use syntax::{ast, source_map}; -use syntax::feature_gate::AttributeType; +use syntax::source_map; +use syntax::parse::{self, ParseSess}; use syntax_pos::{MultiSpan, Span}; use util::profiling::SelfProfiler; -use rustc_target::spec::PanicStrategy; -use rustc_target::spec::{Target, TargetTriple}; +use rustc_target::spec::{PanicStrategy, RelroLevel, Target, TargetTriple}; use rustc_data_structures::flock; use jobserver::Client; @@ -124,6 +122,9 @@ pub imported_macro_spans: OneThread>>, incr_comp_session: OneThread>, + /// Used for incremental compilation tests. Will only be populated if + /// `-Zquery-dep-graph` is specified. + pub cgu_reuse_tracker: CguReuseTracker, /// Used by -Z profile-queries in util::common pub profile_channel: Lock>>, @@ -431,8 +432,13 @@ diag_builder.span_note(span, message); } DiagnosticBuilderMethod::SpanSuggestion(suggestion) => { - let span = span_maybe.expect("span_suggestion needs a span"); - diag_builder.span_suggestion(span, message, suggestion); + let span = span_maybe.expect("span_suggestion_* needs a span"); + diag_builder.span_suggestion_with_applicability( + span, + message, + suggestion, + Applicability::Unspecified, + ); } } } @@ -519,6 +525,7 @@ } pub fn verify_llvm_ir(&self) -> bool { self.opts.debugging_opts.verify_llvm_ir + || cfg!(always_verify_llvm_ir) } pub fn borrowck_stats(&self) -> bool { self.opts.debugging_opts.borrowck_stats @@ -692,11 +699,11 @@ match self.opts.maybe_sysroot { Some(ref sysroot) => sysroot, None => self.default_sysroot - .as_ref() - .expect("missing sysroot and default_sysroot in Session"), + .as_ref() + .expect("missing sysroot and default_sysroot in Session"), } } - pub fn target_filesearch(&self, kind: PathKind) -> filesearch::FileSearch { + pub fn target_filesearch(&self, kind: PathKind) -> filesearch::FileSearch<'_> { filesearch::FileSearch::new( self.sysroot(), self.opts.target_triple.triple(), @@ -704,7 +711,7 @@ kind, ) } - pub fn host_filesearch(&self, kind: PathKind) -> filesearch::FileSearch { + pub fn host_filesearch(&self, kind: PathKind) -> filesearch::FileSearch<'_> { filesearch::FileSearch::new( self.sysroot(), config::host_triple(), @@ -716,14 +723,8 @@ pub fn set_incr_session_load_dep_graph(&self, load: bool) { let mut incr_comp_session = self.incr_comp_session.borrow_mut(); - match *incr_comp_session { - IncrCompSession::Active { - ref mut load_dep_graph, - .. - } => { - *load_dep_graph = load; - } - _ => {} + if let IncrCompSession::Active { ref mut load_dep_graph, .. } = *incr_comp_session { + *load_dep_graph = load; } } @@ -794,7 +795,7 @@ *incr_comp_session = IncrCompSession::InvalidBecauseOfErrors { session_directory }; } - pub fn incr_comp_session_dir(&self) -> cell::Ref { + pub fn incr_comp_session_dir(&self) -> cell::Ref<'_, PathBuf> { let incr_comp_session = self.incr_comp_session.borrow(); cell::Ref::map( incr_comp_session, @@ -817,7 +818,7 @@ ) } - pub fn incr_comp_session_dir_opt(&self) -> Option> { + pub fn incr_comp_session_dir_opt(&self) -> Option> { if self.opts.incremental.is_some() { Some(self.incr_comp_session_dir()) } else { @@ -861,9 +862,9 @@ /// This expends fuel if applicable, and records fuel if applicable. pub fn consider_optimizing String>(&self, crate_name: &str, msg: T) -> bool { let mut ret = true; - match self.optimization_fuel_crate { - Some(ref c) if c == crate_name => { - assert!(self.query_threads() == 1); + if let Some(ref c) = self.optimization_fuel_crate { + if c == crate_name { + assert_eq!(self.query_threads(), 1); let fuel = self.optimization_fuel_limit.get(); ret = fuel != 0; if fuel == 0 && !self.out_of_fuel.get() { @@ -873,14 +874,12 @@ self.optimization_fuel_limit.set(fuel - 1); } } - _ => {} } - match self.print_fuel_crate { - Some(ref c) if c == crate_name => { - assert!(self.query_threads() == 1); + if let Some(ref c) = self.print_fuel_crate { + if c == crate_name { + assert_eq!(self.query_threads(), 1); self.print_fuel.set(self.print_fuel.get() + 1); } - _ => {} } ret } @@ -964,6 +963,10 @@ self.opts.debugging_opts.teach && self.diagnostic().must_teach(code) } + pub fn rust_2015(&self) -> bool { + self.opts.edition == Edition::Edition2015 + } + /// Are we allowed to use features from the Rust 2018 edition? pub fn rust_2018(&self) -> bool { self.opts.edition >= Edition::Edition2018 @@ -972,6 +975,27 @@ pub fn edition(&self) -> Edition { self.opts.edition } + + /// True if we cannot skip the PLT for shared library calls. + pub fn needs_plt(&self) -> bool { + // Check if the current target usually needs PLT to be enabled. + // The user can use the command line flag to override it. + let needs_plt = self.target.target.options.needs_plt; + + let dbg_opts = &self.opts.debugging_opts; + + let relro_level = dbg_opts.relro_level + .unwrap_or(self.target.target.options.relro_level); + + // Only enable this optimization by default if full relro is also enabled. + // In this case, lazy binding was already unavailable, so nothing is lost. + // This also ensures `-Wl,-z,now` is supported by the linker. + let full_relro = RelroLevel::Full == relro_level; + + // If user didn't explicitly forced us to use / skip the PLT, + // then try to skip it where possible. + dbg_opts.plt.unwrap_or(needs_plt || !full_relro) + } } pub fn build_session( @@ -1012,6 +1036,7 @@ let can_emit_warnings = !(warnings_allow || cap_lints_allow); let treat_err_as_bug = sopts.debugging_opts.treat_err_as_bug; + let dont_buffer_diagnostics = sopts.debugging_opts.dont_buffer_diagnostics; let report_delayed_bugs = sopts.debugging_opts.report_delayed_bugs; let external_macro_backtrace = sopts.debugging_opts.external_macro_backtrace; @@ -1059,6 +1084,7 @@ can_emit_warnings, treat_err_as_bug, report_delayed_bugs, + dont_buffer_diagnostics, external_macro_backtrace, ..Default::default() }, @@ -1074,14 +1100,11 @@ source_map: Lrc, ) -> Session { let host_triple = TargetTriple::from_triple(config::host_triple()); - let host = match Target::search(&host_triple) { - Ok(t) => t, - Err(e) => { - span_diagnostic - .fatal(&format!("Error loading host specification: {}", e)) - .raise(); - } - }; + let host = Target::search(&host_triple).unwrap_or_else(|e| + span_diagnostic + .fatal(&format!("Error loading host specification: {}", e)) + .raise() + ); let target_cfg = config::build_target_config(&sopts, &span_diagnostic); let p_s = parse::ParseSess::with_span_handler(span_diagnostic, source_map); @@ -1101,14 +1124,19 @@ let print_fuel_crate = sopts.debugging_opts.print_fuel.clone(); let print_fuel = LockCell::new(0); - let working_dir = match env::current_dir() { - Ok(dir) => dir, - Err(e) => p_s.span_diagnostic + let working_dir = env::current_dir().unwrap_or_else(|e| + p_s.span_diagnostic .fatal(&format!("Current directory is invalid: {}", e)) - .raise(), - }; + .raise() + ); let working_dir = file_path_mapping.map_prefix(working_dir); + let cgu_reuse_tracker = if sopts.debugging_opts.query_dep_graph { + CguReuseTracker::new() + } else { + CguReuseTracker::new_disabled() + }; + let sess = Session { target: target_cfg, host, @@ -1123,7 +1151,7 @@ working_dir, lint_store: RwLock::new(lint::LintStore::new()), buffered_lints: Lock::new(Some(lint::LintBuffer::new())), - one_time_diagnostics: Lock::new(FxHashSet()), + one_time_diagnostics: Default::default(), plugin_llvm_passes: OneThread::new(RefCell::new(Vec::new())), plugin_attributes: OneThread::new(RefCell::new(Vec::new())), crate_types: Once::new(), @@ -1139,6 +1167,7 @@ injected_panic_runtime: Once::new(), imported_macro_spans: OneThread::new(RefCell::new(FxHashMap::default())), incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)), + cgu_reuse_tracker, self_profiling: Lock::new(SelfProfiler::new()), profile_channel: Lock::new(None), perf_stats: PerfStats { @@ -1148,7 +1177,7 @@ normalize_ty_after_erasing_regions: AtomicUsize::new(0), normalize_projection_ty: AtomicUsize::new(0), }, - code_stats: Lock::new(CodeStats::new()), + code_stats: Default::default(), optimization_fuel_crate, optimization_fuel_limit, print_fuel_crate, @@ -1182,7 +1211,7 @@ }, has_global_allocator: Once::new(), has_panic_handler: Once::new(), - driver_lint_caps: FxHashMap(), + driver_lint_caps: Default::default(), }; validate_commandline_args_with_session_available(&sess); @@ -1235,7 +1264,7 @@ } impl fmt::Display for CrateDisambiguator { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { let (a, b) = self.0.as_value(); let as_u128 = a as u128 | ((b as u128) << 64); f.write_str(&base_n::encode(as_u128, base_n::CASE_INSENSITIVE)) diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/session/search_paths.rs rustc-1.31.0+dfsg1+llvm/src/librustc/session/search_paths.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/session/search_paths.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/session/search_paths.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,7 +14,7 @@ #[derive(Clone, Debug)] pub struct SearchPaths { - paths: Vec<(PathKind, PathBuf)>, + crate paths: Vec<(PathKind, PathBuf)>, } pub struct Iter<'a> { @@ -57,7 +57,7 @@ self.paths.push((kind, PathBuf::from(path))); } - pub fn iter(&self, kind: PathKind) -> Iter { + pub fn iter(&self, kind: PathKind) -> Iter<'_> { Iter { kind: kind, iter: self.paths.iter() } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/auto_trait.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/auto_trait.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/auto_trait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/auto_trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,10 +16,9 @@ use std::collections::hash_map::Entry; use std::collections::VecDeque; -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; - use infer::region_constraints::{Constraint, RegionConstraintData}; -use infer::{InferCtxt, RegionObligation}; +use infer::InferCtxt; +use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use ty::fold::TypeFolder; use ty::{Region, RegionVid}; @@ -74,16 +73,16 @@ /// ``` /// struct Foo { data: Box } /// ``` - + /// /// then this might return that Foo: Send if T: Send (encoded in the AutoTraitResult type). /// The analysis attempts to account for custom impls as well as other complex cases. This /// result is intended for use by rustdoc and other such consumers. - + /// /// (Note that due to the coinductive nature of Send, the full and correct result is actually /// quite simple to generate. That is, when a type has no custom impl, it is Send iff its field /// types are all Send. So, in our example, we might have that Foo: Send if Box: Send. /// But this is often not the best way to present to the user.) - + /// /// Warning: The API should be considered highly unstable, and it may be refactored or removed /// in the future. pub fn find_auto_trait_generics( @@ -112,6 +111,7 @@ orig_params, trait_pred.to_poly_trait_predicate(), )); + match result { Ok(Some(Vtable::VtableImpl(_))) => { debug!( @@ -119,10 +119,10 @@ manual impl found, bailing out", did, trait_did, generics ); - return true; + true } - _ => return false, - }; + _ => false + } }); // If an explicit impl exists, it always takes priority over an auto impl @@ -131,7 +131,7 @@ } return tcx.infer_ctxt().enter(|mut infcx| { - let mut fresh_preds = FxHashSet(); + let mut fresh_preds = FxHashSet::default(); // Due to the way projections are handled by SelectionContext, we need to run // evaluate_predicates twice: once on the original param env, and once on the result of @@ -226,20 +226,18 @@ .iter() .filter_map(|param| match param.kind { ty::GenericParamDefKind::Lifetime => Some(param.name.to_string()), - _ => None + _ => None, }) .collect(); - let body_ids: FxHashSet<_> = infcx + let body_id_map: FxHashMap<_, _> = infcx .region_obligations .borrow() .iter() - .map(|&(id, _)| id) + .map(|&(id, _)| (id, vec![])) .collect(); - for id in body_ids { - infcx.process_registered_region_obligations(&[], None, full_env.clone(), id); - } + infcx.process_registered_region_obligations(&body_id_map, None, full_env.clone()); let region_data = infcx .borrow_region_constraints() @@ -290,7 +288,7 @@ // hold. // // One additional consideration is supertrait bounds. Normally, a ParamEnv is only ever - // consutrcted once for a given type. As part of the construction process, the ParamEnv will + // constructed once for a given type. As part of the construction process, the ParamEnv will // have any supertrait bounds normalized - e.g. if we have a type 'struct Foo', the // ParamEnv will contain 'T: Copy' and 'T: Clone', since 'Copy: Clone'. When we construct our // own ParamEnv, we need to do this ourselves, through traits::elaborate_predicates, or else @@ -313,7 +311,7 @@ let mut select = SelectionContext::new(&infcx); - let mut already_visited = FxHashSet(); + let mut already_visited = FxHashSet::default(); let mut predicates = VecDeque::new(); predicates.push_back(ty::Binder::bind(ty::TraitPredicate { trait_ref: ty::TraitRef { @@ -358,8 +356,10 @@ &Err(SelectionError::Unimplemented) => { if self.is_of_param(pred.skip_binder().trait_ref.substs) { already_visited.remove(&pred); - self.add_user_pred(&mut user_computed_preds, - ty::Predicate::Trait(pred.clone())); + self.add_user_pred( + &mut user_computed_preds, + ty::Predicate::Trait(pred.clone()), + ); predicates.push_back(pred); } else { debug!( @@ -417,8 +417,11 @@ // under which a type implements an auto trait. A trait predicate involving // a HRTB means that the type needs to work with any choice of lifetime, // not just one specific lifetime (e.g. 'static). - fn add_user_pred<'c>(&self, user_computed_preds: &mut FxHashSet>, - new_pred: ty::Predicate<'c>) { + fn add_user_pred<'c>( + &self, + user_computed_preds: &mut FxHashSet>, + new_pred: ty::Predicate<'c>, + ) { let mut should_add_new = true; user_computed_preds.retain(|&old_pred| { match (&new_pred, old_pred) { @@ -426,23 +429,23 @@ if new_trait.def_id() == old_trait.def_id() { let new_substs = new_trait.skip_binder().trait_ref.substs; let old_substs = old_trait.skip_binder().trait_ref.substs; + if !new_substs.types().eq(old_substs.types()) { // We can't compare lifetimes if the types are different, // so skip checking old_pred - return true + return true; } - for (new_region, old_region) in new_substs - .regions() - .zip(old_substs.regions()) { - + for (new_region, old_region) in + new_substs.regions().zip(old_substs.regions()) + { match (new_region, old_region) { // If both predicates have an 'ReLateBound' (a HRTB) in the // same spot, we do nothing ( ty::RegionKind::ReLateBound(_, _), - ty::RegionKind::ReLateBound(_, _) - ) => {}, + ty::RegionKind::ReLateBound(_, _), + ) => {} (ty::RegionKind::ReLateBound(_, _), _) => { // The new predicate has a HRTB in a spot where the old @@ -456,7 +459,7 @@ // so we return 'false' to remove the old predicate from // user_computed_preds return false; - }, + } (_, ty::RegionKind::ReLateBound(_, _)) => { // This is the opposite situation as the previous arm - the // old predicate has a HRTB lifetime in a place where the @@ -469,10 +472,10 @@ } } } - }, + } _ => {} } - return true + return true; }); if should_add_new { @@ -480,22 +483,23 @@ } } - pub fn region_name(&self, region: Region) -> Option { + pub fn region_name(&self, region: Region<'_>) -> Option { match region { &ty::ReEarlyBound(r) => Some(r.name.to_string()), _ => None, } } - pub fn get_lifetime(&self, region: Region, names_map: &FxHashMap) -> String { + pub fn get_lifetime(&self, region: Region<'_>, + names_map: &FxHashMap) -> String { self.region_name(region) - .map(|name| { - names_map.get(&name).unwrap_or_else(|| { + .map(|name| + names_map.get(&name).unwrap_or_else(|| panic!("Missing lifetime with name {:?} for {:?}", name, region) - }) - }) - .unwrap_or(&"'static".to_string()) - .clone() + ) + ) + .cloned() + .unwrap_or_else(|| "'static".to_owned()) } // This is very similar to handle_lifetimes. However, instead of matching ty::Region's @@ -504,35 +508,27 @@ &self, regions: &RegionConstraintData<'cx>, ) -> FxHashMap> { - let mut vid_map: FxHashMap, RegionDeps<'cx>> = FxHashMap(); - let mut finished_map = FxHashMap(); + let mut vid_map: FxHashMap, RegionDeps<'cx>> = FxHashMap::default(); + let mut finished_map = FxHashMap::default(); for constraint in regions.constraints.keys() { match constraint { &Constraint::VarSubVar(r1, r2) => { { - let deps1 = vid_map - .entry(RegionTarget::RegionVid(r1)) - .or_default(); + let deps1 = vid_map.entry(RegionTarget::RegionVid(r1)).or_default(); deps1.larger.insert(RegionTarget::RegionVid(r2)); } - let deps2 = vid_map - .entry(RegionTarget::RegionVid(r2)) - .or_default(); + let deps2 = vid_map.entry(RegionTarget::RegionVid(r2)).or_default(); deps2.smaller.insert(RegionTarget::RegionVid(r1)); } &Constraint::RegSubVar(region, vid) => { { - let deps1 = vid_map - .entry(RegionTarget::Region(region)) - .or_default(); + let deps1 = vid_map.entry(RegionTarget::Region(region)).or_default(); deps1.larger.insert(RegionTarget::RegionVid(vid)); } - let deps2 = vid_map - .entry(RegionTarget::RegionVid(vid)) - .or_default(); + let deps2 = vid_map.entry(RegionTarget::RegionVid(vid)).or_default(); deps2.smaller.insert(RegionTarget::Region(region)); } &Constraint::VarSubReg(vid, region) => { @@ -540,15 +536,11 @@ } &Constraint::RegSubReg(r1, r2) => { { - let deps1 = vid_map - .entry(RegionTarget::Region(r1)) - .or_default(); + let deps1 = vid_map.entry(RegionTarget::Region(r1)).or_default(); deps1.larger.insert(RegionTarget::Region(r2)); } - let deps2 = vid_map - .entry(RegionTarget::Region(r2)) - .or_default(); + let deps2 = vid_map.entry(RegionTarget::Region(r2)).or_default(); deps2.smaller.insert(RegionTarget::Region(r1)); } } @@ -600,7 +592,7 @@ finished_map } - pub fn is_of_param(&self, substs: &Substs) -> bool { + pub fn is_of_param(&self, substs: &Substs<'_>) -> bool { if substs.is_noop() { return false; } @@ -620,7 +612,7 @@ T: Iterator>>, >( &self, - ty: ty::Ty, + ty: ty::Ty<'_>, nested: T, computed_preds: &'b mut FxHashSet>, fresh_preds: &'b mut FxHashSet>, @@ -681,7 +673,11 @@ } } &ty::Predicate::RegionOutlives(ref binder) => { - if select.infcx().region_outlives_predicate(&dummy_cause, binder).is_err() { + if select + .infcx() + .region_outlives_predicate(&dummy_cause, binder) + .is_err() + { return false; } } @@ -691,23 +687,17 @@ binder.map_bound_ref(|pred| pred.0).no_late_bound_regions(), ) { (None, Some(t_a)) => { - select.infcx().register_region_obligation( - ast::DUMMY_NODE_ID, - RegionObligation { - sup_type: t_a, - sub_region: select.infcx().tcx.types.re_static, - cause: dummy_cause.clone(), - }, + select.infcx().register_region_obligation_with_cause( + t_a, + select.infcx().tcx.types.re_static, + &dummy_cause, ); } (Some(ty::OutlivesPredicate(t_a, r_b)), _) => { - select.infcx().register_region_obligation( - ast::DUMMY_NODE_ID, - RegionObligation { - sup_type: t_a, - sub_region: r_b, - cause: dummy_cause.clone(), - }, + select.infcx().register_region_obligation_with_cause( + t_a, + r_b, + &dummy_cause, ); } _ => {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/codegen/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/codegen/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/codegen/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/codegen/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -39,7 +39,7 @@ let trait_ref = ty.erase_regions(&trait_ref); debug!("codegen_fulfill_obligation(trait_ref={:?}, def_id={:?})", - (param_env, trait_ref), trait_ref.def_id()); + (param_env, trait_ref), trait_ref.def_id()); // Do the initial selection for the obligation. This yields the // shallow result we are looking for -- that is, what specific impl. @@ -48,8 +48,8 @@ let obligation_cause = ObligationCause::dummy(); let obligation = Obligation::new(obligation_cause, - param_env, - trait_ref.to_poly_trait_predicate()); + param_env, + trait_ref.to_poly_trait_predicate()); let selection = match selcx.select(&obligation) { Ok(Some(selection)) => selection, @@ -61,12 +61,11 @@ // overflow bug, since I believe this is the only case // where ambiguity can result. bug!("Encountered ambiguity selecting `{:?}` during codegen, \ - presuming due to overflow", - trait_ref) + presuming due to overflow", + trait_ref) } Err(e) => { - bug!("Encountered error `{:?}` selecting `{:?}` during codegen", - e, trait_ref) + bug!("Encountered error `{:?}` selecting `{:?}` during codegen", e, trait_ref) } }; @@ -163,22 +162,16 @@ // In principle, we only need to do this so long as `result` // contains unbound type parameters. It could be a slight // optimization to stop iterating early. - match fulfill_cx.select_all_or_error(self) { - Ok(()) => { } - Err(errors) => { - span_bug!(span, "Encountered errors `{:?}` resolving bounds after type-checking", - errors); - } + if let Err(errors) = fulfill_cx.select_all_or_error(self) { + span_bug!(span, "Encountered errors `{:?}` resolving bounds after type-checking", + errors); } let result = self.resolve_type_vars_if_possible(result); let result = self.tcx.erase_regions(&result); - match self.tcx.lift_to_global(&result) { - Some(result) => result, - None => { - span_bug!(span, "Uninferred types/regions in `{:?}`", result); - } - } + self.tcx.lift_to_global(&result).unwrap_or_else(|| + span_bug!(span, "Uninferred types/regions in `{:?}`", result) + ) } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/coherence.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/coherence.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/coherence.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/coherence.rs 2018-12-04 23:41:40.000000000 +0000 @@ -96,10 +96,10 @@ let header = ty::ImplHeader { impl_def_id, - self_ty: tcx.type_of(impl_def_id), - trait_ref: tcx.impl_trait_ref(impl_def_id), - predicates: tcx.predicates_of(impl_def_id).predicates - }.subst(tcx, impl_substs); + self_ty: tcx.type_of(impl_def_id).subst(tcx, impl_substs), + trait_ref: tcx.impl_trait_ref(impl_def_id).subst(tcx, impl_substs), + predicates: tcx.predicates_of(impl_def_id).instantiate(tcx, impl_substs).predicates, + }; let Normalized { value: mut header, obligations } = traits::normalize(selcx, param_env, ObligationCause::dummy(), &header); @@ -115,11 +115,9 @@ b_def_id: DefId) -> Option> { - debug!("overlap(a_def_id={:?}, b_def_id={:?})", - a_def_id, - b_def_id); + debug!("overlap(a_def_id={:?}, b_def_id={:?})", a_def_id, b_def_id); - // For the purposes of this check, we don't bring any skolemized + // For the purposes of this check, we don't bring any placeholder // types into scope; instead, we replace the generic types with // fresh type variables, and hence we do our evaluations in an // empty environment. @@ -133,10 +131,9 @@ // Do `a` and `b` unify? If not, no overlap. let obligations = match selcx.infcx().at(&ObligationCause::dummy(), param_env) - .eq_impl_headers(&a_impl_header, &b_impl_header) { - Ok(InferOk { obligations, value: () }) => { - obligations - } + .eq_impl_headers(&a_impl_header, &b_impl_header) + { + Ok(InferOk { obligations, value: () }) => obligations, Err(_) => return None }; @@ -164,7 +161,7 @@ return None } - let impl_header = selcx.infcx().resolve_type_vars_if_possible(&a_impl_header); + let impl_header = selcx.infcx().resolve_type_vars_if_possible(&a_impl_header); let intercrate_ambiguity_causes = selcx.take_intercrate_ambiguity_causes(); debug!("overlap: intercrate_ambiguity_causes={:#?}", intercrate_ambiguity_causes); Some(OverlapResult { impl_header, intercrate_ambiguity_causes }) @@ -340,7 +337,7 @@ /// /// Note that this function is never called for types that have both type /// parameters and inference variables. -fn orphan_check_trait_ref<'tcx>(tcx: TyCtxt, +fn orphan_check_trait_ref<'tcx>(tcx: TyCtxt<'_, '_, '_>, trait_ref: ty::TraitRef<'tcx>, in_crate: InCrate) -> Result<(), OrphanCheckErr<'tcx>> @@ -392,7 +389,7 @@ return Err(OrphanCheckErr::NoLocalInputType); } -fn uncovered_tys<'tcx>(tcx: TyCtxt, ty: Ty<'tcx>, in_crate: InCrate) +fn uncovered_tys<'tcx>(tcx: TyCtxt<'_, '_, '_>, ty: Ty<'tcx>, in_crate: InCrate) -> Vec> { if ty_is_local_constructor(ty, in_crate) { vec![] @@ -405,25 +402,23 @@ } } -fn is_possibly_remote_type(ty: Ty, _in_crate: InCrate) -> bool { +fn is_possibly_remote_type(ty: Ty<'_>, _in_crate: InCrate) -> bool { match ty.sty { ty::Projection(..) | ty::Param(..) => true, _ => false, } } -fn ty_is_local(tcx: TyCtxt, ty: Ty, in_crate: InCrate) -> bool { +fn ty_is_local(tcx: TyCtxt<'_, '_, '_>, ty: Ty<'_>, in_crate: InCrate) -> bool { ty_is_local_constructor(ty, in_crate) || fundamental_ty(tcx, ty) && ty.walk_shallow().any(|t| ty_is_local(tcx, t, in_crate)) } -fn fundamental_ty(tcx: TyCtxt, ty: Ty) -> bool { +fn fundamental_ty(tcx: TyCtxt<'_, '_, '_>, ty: Ty<'_>) -> bool { match ty.sty { ty::Ref(..) => true, ty::Adt(def, _) => def.is_fundamental(), - ty::Dynamic(ref data, ..) => { - data.principal().map_or(false, |p| tcx.has_attr(p.def_id(), "fundamental")) - } + ty::Dynamic(ref data, ..) => tcx.has_attr(data.principal().def_id(), "fundamental"), _ => false } } @@ -437,7 +432,7 @@ } } -fn ty_is_local_constructor(ty: Ty, in_crate: InCrate) -> bool { +fn ty_is_local_constructor(ty: Ty<'_>, in_crate: InCrate) -> bool { debug!("ty_is_local_constructor({:?})", ty); match ty.sty { @@ -470,16 +465,11 @@ ty::Adt(def, _) => def_id_is_local(def.did, in_crate), ty::Foreign(did) => def_id_is_local(did, in_crate), - ty::Dynamic(ref tt, ..) => { - tt.principal().map_or(false, |p| { - def_id_is_local(p.def_id(), in_crate) - }) - } + ty::Dynamic(ref tt, ..) => def_id_is_local(tt.principal().def_id(), in_crate), - ty::Error => { - true - } + ty::Error => true, + ty::UnnormalizedProjection(..) | ty::Closure(..) | ty::Generator(..) | ty::GeneratorWitness(..) | diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/error_reporting.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/error_reporting.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/error_reporting.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/error_reporting.rs 2018-12-04 23:41:40.000000000 +0000 @@ -34,6 +34,7 @@ use infer::{self, InferCtxt}; use infer::type_variable::TypeVariableOrigin; use std::fmt; +use std::iter; use syntax::ast; use session::DiagnosticMessageId; use ty::{self, AdtKind, ToPredicate, ToPolyTraitRef, Ty, TyCtxt, TypeFoldable}; @@ -45,7 +46,7 @@ use ty::SubtypePredicate; use util::nodemap::{FxHashMap, FxHashSet}; -use syntax_pos::{DUMMY_SP, Span}; +use syntax_pos::{DUMMY_SP, Span, ExpnInfo, ExpnFormat}; impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { pub fn report_fulfillment_errors(&self, @@ -58,7 +59,7 @@ index: Option, // None if this is an old error } - let mut error_map : FxHashMap<_, Vec<_>> = + let mut error_map: FxHashMap<_, Vec<_>> = self.reported_trait_errors.borrow().iter().map(|(&span, predicates)| { (span, predicates.iter().map(|predicate| ErrorDescriptor { predicate: predicate.clone(), @@ -67,20 +68,32 @@ }).collect(); for (index, error) in errors.iter().enumerate() { - error_map.entry(error.obligation.cause.span).or_default().push( + // We want to ignore desugarings here: spans are equivalent even + // if one is the result of a desugaring and the other is not. + let mut span = error.obligation.cause.span; + if let Some(ExpnInfo { + format: ExpnFormat::CompilerDesugaring(_), + def_site: Some(def_span), + .. + }) = span.ctxt().outer().expn_info() { + span = def_span; + } + + error_map.entry(span).or_default().push( ErrorDescriptor { predicate: error.obligation.predicate.clone(), index: Some(index) - }); + } + ); self.reported_trait_errors.borrow_mut() - .entry(error.obligation.cause.span).or_default() + .entry(span).or_default() .push(error.obligation.predicate.clone()); } - // We do this in 2 passes because we want to display errors in order, tho + // We do this in 2 passes because we want to display errors in order, though // maybe it *is* better to sort errors by span or something. - let mut is_suppressed: Vec = errors.iter().map(|_| false).collect(); + let mut is_suppressed = vec![false; errors.len()]; for (_, error_set) in error_map.iter() { // We want to suppress "duplicate" errors with the same span. for error in error_set { @@ -226,7 +239,7 @@ let msg = format!("type mismatch resolving `{}`", predicate); let error_id = (DiagnosticMessageId::ErrorId(271), - Some(obligation.cause.span), msg.clone()); + Some(obligation.cause.span), msg); let fresh = self.tcx.sess.one_time_diagnostics.borrow_mut().insert(error_id); if fresh { let mut diag = struct_span_err!( @@ -268,7 +281,8 @@ ty::Generator(..) => Some(18), ty::Foreign(..) => Some(19), ty::GeneratorWitness(..) => Some(20), - ty::Infer(..) | ty::Error => None + ty::Infer(..) | ty::Error => None, + ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"), } } @@ -335,11 +349,10 @@ fn on_unimplemented_note( &self, trait_ref: ty::PolyTraitRef<'tcx>, - obligation: &PredicateObligation<'tcx>) -> - OnUnimplementedNote - { + obligation: &PredicateObligation<'tcx>, + ) -> OnUnimplementedNote { let def_id = self.impl_similar_to(trait_ref, obligation) - .unwrap_or(trait_ref.def_id()); + .unwrap_or_else(|| trait_ref.def_id()); let trait_ref = *trait_ref.skip_binder(); let mut flags = vec![]; @@ -349,7 +362,7 @@ _ => { // this is a "direct", user-specified, rather than derived, // obligation. - flags.push(("direct".to_string(), None)); + flags.push(("direct".to_owned(), None)); } } @@ -361,24 +374,27 @@ // Currently I'm leaving it for what I need for `try`. if self.tcx.trait_of_item(item) == Some(trait_ref.def_id) { let method = self.tcx.item_name(item); - flags.push(("from_method".to_string(), None)); - flags.push(("from_method".to_string(), Some(method.to_string()))); + flags.push(("from_method".to_owned(), None)); + flags.push(("from_method".to_owned(), Some(method.to_string()))); } } + if let Some(t) = self.get_parent_trait_ref(&obligation.cause.code) { + flags.push(("parent_trait".to_owned(), Some(t))); + } if let Some(k) = obligation.cause.span.compiler_desugaring_kind() { - flags.push(("from_desugaring".to_string(), None)); - flags.push(("from_desugaring".to_string(), Some(k.name().to_string()))); + flags.push(("from_desugaring".to_owned(), None)); + flags.push(("from_desugaring".to_owned(), Some(k.name().to_string()))); } let generics = self.tcx.generics_of(def_id); let self_ty = trait_ref.self_ty(); // This is also included through the generics list as `Self`, // but the parser won't allow you to use it - flags.push(("_Self".to_string(), Some(self_ty.to_string()))); + flags.push(("_Self".to_owned(), Some(self_ty.to_string()))); if let Some(def) = self_ty.ty_adt_def() { // We also want to be able to select self's original // signature with no type arguments resolved - flags.push(("_Self".to_string(), Some(self.tcx.type_of(def.did).to_string()))); + flags.push(("_Self".to_owned(), Some(self.tcx.type_of(def.did).to_string()))); } for param in generics.params.iter() { @@ -393,7 +409,39 @@ } if let Some(true) = self_ty.ty_adt_def().map(|def| def.did.is_local()) { - flags.push(("crate_local".to_string(), None)); + flags.push(("crate_local".to_owned(), None)); + } + + // Allow targeting all integers using `{integral}`, even if the exact type was resolved + if self_ty.is_integral() { + flags.push(("_Self".to_owned(), Some("{integral}".to_owned()))); + } + + if let ty::Array(aty, len) = self_ty.sty { + flags.push(("_Self".to_owned(), Some("[]".to_owned()))); + flags.push(("_Self".to_owned(), Some(format!("[{}]", aty)))); + if let Some(def) = aty.ty_adt_def() { + // We also want to be able to select the array's type's original + // signature with no type arguments resolved + flags.push(( + "_Self".to_owned(), + Some(format!("[{}]", self.tcx.type_of(def.did).to_string())), + )); + let tcx = self.tcx; + if let Some(len) = len.val.try_to_scalar().and_then(|scalar| { + scalar.to_usize(tcx).ok() + }) { + flags.push(( + "_Self".to_owned(), + Some(format!("[{}; {}]", self.tcx.type_of(def.did).to_string(), len)), + )); + } else { + flags.push(( + "_Self".to_owned(), + Some(format!("[{}; _]", self.tcx.type_of(def.did).to_string())), + )); + } + } } if let Ok(Some(command)) = OnUnimplementedDirective::of_item( @@ -412,32 +460,31 @@ let simp = fast_reject::simplify_type(self.tcx, trait_ref.skip_binder().self_ty(), true); - let mut impl_candidates = Vec::new(); + let all_impls = self.tcx.all_impls(trait_ref.def_id()); match simp { - Some(simp) => self.tcx.for_each_impl(trait_ref.def_id(), |def_id| { + Some(simp) => all_impls.iter().filter_map(|&def_id| { let imp = self.tcx.impl_trait_ref(def_id).unwrap(); let imp_simp = fast_reject::simplify_type(self.tcx, imp.self_ty(), true); if let Some(imp_simp) = imp_simp { if simp != imp_simp { - return; + return None } } - impl_candidates.push(imp); - }), - None => self.tcx.for_each_impl(trait_ref.def_id(), |def_id| { - impl_candidates.push( - self.tcx.impl_trait_ref(def_id).unwrap()); - }) - }; - impl_candidates + + Some(imp) + }).collect(), + None => all_impls.iter().map(|&def_id| + self.tcx.impl_trait_ref(def_id).unwrap() + ).collect() + } } fn report_similar_impl_candidates(&self, mut impl_candidates: Vec>, - err: &mut DiagnosticBuilder) + err: &mut DiagnosticBuilder<'_>) { if impl_candidates.is_empty() { return; @@ -592,7 +639,7 @@ let (post_message, pre_message) = self.get_parent_trait_ref(&obligation.cause.code) .map(|t| (format!(" in `{}`", t), format!("within `{}`, ", t))) - .unwrap_or((String::new(), String::new())); + .unwrap_or_default(); let OnUnimplementedNote { message, label, note } = self.on_unimplemented_note(trait_ref, obligation); @@ -603,10 +650,10 @@ span, E0277, "{}", - message.unwrap_or_else(|| { + message.unwrap_or_else(|| format!("the trait bound `{}` is not satisfied{}", trait_ref.to_predicate(), post_message) - })); + )); let explanation = if obligation.cause.code == ObligationCauseCode::MainFunctionType { @@ -645,7 +692,7 @@ // "the type `T` can't be frobnicated" // which is somewhat confusing. err.help(&format!("consider adding a `where {}` bound", - trait_ref.to_predicate())); + trait_ref.to_predicate())); } else if !have_alt_message { // Can't show anything else useful, try to find similar impls. let impl_candidates = self.find_similar_impl_candidates(trait_ref); @@ -693,7 +740,7 @@ ty::Predicate::RegionOutlives(ref predicate) => { let predicate = self.resolve_type_vars_if_possible(predicate); let err = self.region_outlives_predicate(&obligation.cause, - &predicate).err().unwrap(); + &predicate).err().unwrap(); struct_span_err!(self.tcx.sess, span, E0279, "the requirement `{}` is not satisfied (`{}`)", predicate, err) @@ -722,7 +769,7 @@ let mut err = struct_span_err!( self.tcx.sess, closure_span, E0525, "expected a closure that implements the `{}` trait, \ - but this closure only implements `{}`", + but this closure only implements `{}`", kind, found_kind); @@ -779,40 +826,34 @@ OutputTypeParameterMismatch(ref found_trait_ref, ref expected_trait_ref, _) => { let found_trait_ref = self.resolve_type_vars_if_possible(&*found_trait_ref); let expected_trait_ref = self.resolve_type_vars_if_possible(&*expected_trait_ref); + if expected_trait_ref.self_ty().references_error() { return; } + let found_trait_ty = found_trait_ref.self_ty(); let found_did = match found_trait_ty.sty { - ty::Closure(did, _) | - ty::Foreign(did) | - ty::FnDef(did, _) => Some(did), + ty::Closure(did, _) | ty::Foreign(did) | ty::FnDef(did, _) => Some(did), ty::Adt(def, _) => Some(def.did), _ => None, }; - let found_span = found_did.and_then(|did| { + + let found_span = found_did.and_then(|did| self.tcx.hir.span_if_local(did) - }).map(|sp| self.tcx.sess.source_map().def_span(sp)); // the sp could be an fn def + ).map(|sp| self.tcx.sess.source_map().def_span(sp)); // the sp could be an fn def let found = match found_trait_ref.skip_binder().substs.type_at(1).sty { - ty::Tuple(ref tys) => tys.iter() - .map(|_| ArgKind::empty()).collect::>(), + ty::Tuple(ref tys) => vec![ArgKind::empty(); tys.len()], _ => vec![ArgKind::empty()], }; + let expected = match expected_trait_ref.skip_binder().substs.type_at(1).sty { ty::Tuple(ref tys) => tys.iter() - .map(|t| match t.sty { - ty::Tuple(ref tys) => ArgKind::Tuple( - Some(span), - tys.iter() - .map(|ty| ("_".to_owned(), ty.sty.to_string())) - .collect::>() - ), - _ => ArgKind::Arg("_".to_owned(), t.sty.to_string()), - }).collect(), + .map(|t| ArgKind::from_expected_ty(t, Some(span))).collect(), ref sty => vec![ArgKind::Arg("_".to_owned(), sty.to_string())], }; + if found.len() == expected.len() { self.report_closure_arg_mismatch(span, found_span, @@ -836,8 +877,7 @@ TraitNotObjectSafe(did) => { let violations = self.tcx.object_safety_violations(did); - self.tcx.report_object_safety_error(span, did, - violations) + self.tcx.report_object_safety_error(span, did, violations) } ConstEvalFailure(ref err) => { @@ -846,7 +886,11 @@ "could not evaluate constant expression", ) { Some(err) => err, - None => return, + None => { + self.tcx.sess.delay_span_bug(span, + &format!("constant in type had an ignored error: {:?}", err)); + return; + } } } @@ -933,7 +977,7 @@ /// returns a span and `ArgKind` information that describes the /// arguments it expects. This can be supplied to /// `report_arg_count_mismatch`. - pub fn get_fn_like_arguments(&self, node: Node) -> (Span, Vec) { + pub fn get_fn_like_arguments(&self, node: Node<'_>) -> (Span, Vec) { match node { Node::Expr(&hir::Expr { node: hir::ExprKind::Closure(_, ref _decl, id, span, _), @@ -981,11 +1025,9 @@ .map(|arg| match arg.clone().node { hir::TyKind::Tup(ref tys) => ArgKind::Tuple( Some(arg.span), - tys.iter() - .map(|_| ("_".to_owned(), "_".to_owned())) - .collect::>(), + vec![("_".to_owned(), "_".to_owned()); tys.len()] ), - _ => ArgKind::Arg("_".to_owned(), "_".to_owned()) + _ => ArgKind::empty() }).collect::>()) } Node::Variant(&hir::Variant { @@ -997,15 +1039,13 @@ .. }) => { (self.tcx.sess.source_map().def_span(span), - fields.iter().map(|field| { + fields.iter().map(|field| ArgKind::Arg(field.ident.to_string(), "_".to_string()) - }).collect::>()) + ).collect::>()) } Node::StructCtor(ref variant_data) => { (self.tcx.sess.source_map().def_span(self.tcx.hir.span(variant_data.id())), - variant_data.fields() - .iter().map(|_| ArgKind::Arg("_".to_owned(), "_".to_owned())) - .collect()) + vec![ArgKind::empty(); variant_data.fields().len()]) } _ => panic!("non-FnLike node found: {:?}", node), } @@ -1054,7 +1094,7 @@ found_str, ); - err.span_label(span, format!( "expected {} that takes {}", kind, expected_str)); + err.span_label(span, format!("expected {} that takes {}", kind, expected_str)); if let Some(found_span) = found_span { err.span_label(found_span, format!("takes {}", found_str)); @@ -1063,9 +1103,8 @@ // found arguments is empty (assume the user just wants to ignore args in this case). // For example, if `expected_args_length` is 2, suggest `|_, _|`. if found_args.is_empty() && is_closure { - let underscores = "_".repeat(expected_args.len()) - .split("") - .filter(|s| !s.is_empty()) + let underscores = iter::repeat("_") + .take(expected_args.len()) .collect::>() .join(", "); err.span_suggestion_with_applicability( @@ -1087,7 +1126,8 @@ if fields.len() == expected_args.len() { let sugg = fields.iter() .map(|(name, _)| name.to_owned()) - .collect::>().join(", "); + .collect::>() + .join(", "); err.span_suggestion_with_applicability(found_span, "change the closure to take multiple \ arguments instead of a single tuple", @@ -1146,7 +1186,7 @@ let inputs = trait_ref.substs.type_at(1); let sig = if let ty::Tuple(inputs) = inputs.sty { tcx.mk_fn_sig( - inputs.iter().map(|&x| x), + inputs.iter().cloned(), tcx.mk_infer(ty::TyVar(ty::TyVid { index: 0 })), false, hir::Unsafety::Normal, @@ -1218,12 +1258,11 @@ trait_str); err.span_label(span, format!("the trait `{}` cannot be made into an object", trait_str)); - let mut reported_violations = FxHashSet(); + let mut reported_violations = FxHashSet::default(); for violation in violations { - if !reported_violations.insert(violation.clone()) { - continue; + if reported_violations.insert(violation.clone()) { + err.note(&violation.error_msg()); } - err.note(&violation.error_msg()); } err } @@ -1289,10 +1328,10 @@ self.need_type_info_err(body_id, span, self_ty).emit(); } else { let mut err = struct_span_err!(self.tcx.sess, - span, E0283, - "type annotations required: \ + span, E0283, + "type annotations required: \ cannot resolve `{}`", - predicate); + predicate); self.note_obligation_cause(&mut err, obligation); err.emit(); } @@ -1365,7 +1404,7 @@ let cleaned_pred = pred.fold_with(&mut ParamToVarFolder { infcx: self, - var_map: FxHashMap() + var_map: Default::default() }); let cleaned_pred = super::project::normalize( @@ -1386,7 +1425,7 @@ } fn note_obligation_cause(&self, - err: &mut DiagnosticBuilder, + err: &mut DiagnosticBuilder<'_>, obligation: &Obligation<'tcx, T>) where T: fmt::Display { @@ -1397,7 +1436,7 @@ } fn note_obligation_cause_code(&self, - err: &mut DiagnosticBuilder, + err: &mut DiagnosticBuilder<'_>, predicate: &T, cause_code: &ObligationCauseCode<'tcx>, obligated_types: &mut Vec<&ty::TyS<'tcx>>) @@ -1438,6 +1477,7 @@ ObligationCauseCode::ItemObligation(item_def_id) => { let item_name = tcx.item_path_str(item_def_id); let msg = format!("required by `{}`", item_name); + if let Some(sp) = tcx.hir.span_if_local(item_def_id) { let sp = tcx.sess.source_map().def_span(sp); err.span_note(sp, &msg); @@ -1529,9 +1569,9 @@ parent_trait_ref.skip_binder().self_ty())); let parent_predicate = parent_trait_ref.to_predicate(); self.note_obligation_cause_code(err, - &parent_predicate, - &data.parent_code, - obligated_types); + &parent_predicate, + &data.parent_code, + obligated_types); } ObligationCauseCode::CompareImplMethodObligation { .. } => { err.note( @@ -1552,7 +1592,7 @@ } } - fn suggest_new_overflow_limit(&self, err: &mut DiagnosticBuilder) { + fn suggest_new_overflow_limit(&self, err: &mut DiagnosticBuilder<'_>) { let current_limit = self.tcx.sess.recursion_limit.get(); let suggested_limit = current_limit * 2; err.help(&format!("consider adding a `#![recursion_limit=\"{}\"]` attribute to your crate", @@ -1560,21 +1600,21 @@ } fn is_recursive_obligation(&self, - obligated_types: &mut Vec<&ty::TyS<'tcx>>, - cause_code: &ObligationCauseCode<'tcx>) -> bool { + 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.skip_binder().self_ty() { - return true; - } + + if obligated_types.iter().any(|ot| ot == &parent_trait_ref.skip_binder().self_ty()) { + return true; } } - return false; + false } } /// Summarizes information +#[derive(Clone)] pub enum ArgKind { /// An argument of non-tuple type. Parameters are (name, ty) Arg(String, String), @@ -1592,11 +1632,11 @@ } /// Creates an `ArgKind` from the expected type of an - /// argument. This has no name (`_`) and no source spans.. - pub fn from_expected_ty(t: Ty<'_>) -> ArgKind { + /// argument. It has no name (`_`) and an optional source span. + pub fn from_expected_ty(t: Ty<'_>, span: Option) -> ArgKind { match t.sty { ty::Tuple(ref tys) => ArgKind::Tuple( - None, + span, tys.iter() .map(|ty| ("_".to_owned(), ty.sty.to_string())) .collect::>() diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/fulfill.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/fulfill.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/fulfill.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/fulfill.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use infer::{RegionObligation, InferCtxt}; +use infer::InferCtxt; use mir::interpret::GlobalId; use ty::{self, Ty, TypeFoldable, ToPolyTraitRef, ToPredicate}; use ty::error::ExpectedFound; @@ -45,7 +45,6 @@ /// along. Once all type inference constraints have been generated, the /// method `select_all_or_error` can be used to report any remaining /// ambiguous cases as errors. - pub struct FulfillmentContext<'tcx> { // A list of all obligations that have been registered with this // fulfillment context. @@ -89,7 +88,7 @@ /// Attempts to select obligations using `selcx`. fn select(&mut self, selcx: &mut SelectionContext<'a, 'gcx, 'tcx>) - -> Result<(),Vec>> { + -> Result<(), Vec>> { debug!("select(obligation-forest-size={})", self.predicates.len()); let mut errors = Vec::new(); @@ -293,7 +292,7 @@ ty::Predicate::Trait(ref data) => { let trait_obligation = obligation.with(data.clone()); - if data.is_global() && !data.has_late_bound_regions() { + if data.is_global() { // no type variables present, can use evaluation for better caching. // FIXME: consider caching errors too. if self.selcx.infcx().predicate_must_hold(&obligation) { @@ -363,6 +362,7 @@ match binder.no_late_bound_regions() { // If so, this obligation is an error (for now). Eventually we should be // able to support additional cases here, like `for<'a> &'a str: 'a`. + // NOTE: this is duplicate-implemented between here and fulfillment. None => { ProcessResult::Error(CodeSelectionError(Unimplemented)) } @@ -372,13 +372,11 @@ Some(t_a) => { let r_static = self.selcx.tcx().types.re_static; if self.register_region_obligations { - self.selcx.infcx().register_region_obligation( - obligation.cause.body_id, - RegionObligation { - sup_type: t_a, - sub_region: r_static, - cause: obligation.cause.clone(), - }); + self.selcx.infcx().register_region_obligation_with_cause( + t_a, + r_static, + &obligation.cause, + ); } ProcessResult::Changed(vec![]) } @@ -387,13 +385,11 @@ // If there aren't, register the obligation. Some(ty::OutlivesPredicate(t_a, r_b)) => { if self.register_region_obligations { - self.selcx.infcx().register_region_obligation( - obligation.cause.body_id, - RegionObligation { - sup_type: t_a, - sub_region: r_b, - cause: obligation.cause.clone() - }); + self.selcx.infcx().register_region_obligation_with_cause( + t_a, + r_b, + &obligation.cause, + ); } ProcessResult::Changed(vec![]) } @@ -526,7 +522,7 @@ if self.selcx.coinductive_match(cycle.clone().map(|s| s.obligation.predicate)) { debug!("process_child_obligations: coinductive match"); } else { - let cycle : Vec<_> = cycle.map(|c| c.obligation.clone()).collect(); + let cycle: Vec<_> = cycle.map(|c| c.obligation.clone()).collect(); self.selcx.infcx().report_overflow_error_cycle(&cycle); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -20,6 +20,7 @@ use chalk_engine; use hir; use hir::def_id::DefId; +use infer::SuppressRegionErrors; use infer::outlives::env::OutlivesEnvironment; use middle::region; use mir::interpret::ConstEvalErr; @@ -28,6 +29,7 @@ use ty::error::{ExpectedFound, TypeError}; use ty::fold::{TypeFolder, TypeFoldable, TypeVisitor}; use infer::{InferCtxt}; +use util::common::ErrorReported; use rustc_data_structures::sync::Lrc; use std::fmt::Debug; @@ -46,7 +48,7 @@ pub use self::select::{EvaluationCache, SelectionContext, SelectionCache}; pub use self::select::{EvaluationResult, IntercrateAmbiguityCause, OverflowError}; pub use self::specialize::{OverlapError, specialization_graph, translate_substs}; -pub use self::specialize::{SpecializesCache, find_associated_item}; +pub use self::specialize::find_associated_item; pub use self::engine::{TraitEngine, TraitEngineExt}; pub use self::util::elaborate_predicates; pub use self::util::supertraits; @@ -276,6 +278,8 @@ /// * `DomainGoal` /// * `Goal` /// * `Clause` +/// * `Environment` +/// * `InEnvironment` /// are used for representing the trait system in the form of /// logic programming clauses. They are part of the interface /// for the chalk SLG solver. @@ -316,31 +320,41 @@ } #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] -pub enum Goal<'tcx> { - Implies(Clauses<'tcx>, &'tcx Goal<'tcx>), - And(&'tcx Goal<'tcx>, &'tcx Goal<'tcx>), - Not(&'tcx Goal<'tcx>), +pub enum GoalKind<'tcx> { + Implies(Clauses<'tcx>, Goal<'tcx>), + And(Goal<'tcx>, Goal<'tcx>), + Not(Goal<'tcx>), DomainGoal(DomainGoal<'tcx>), - Quantified(QuantifierKind, ty::Binder<&'tcx Goal<'tcx>>), + Quantified(QuantifierKind, ty::Binder>), CannotProve, } +pub type Goal<'tcx> = &'tcx GoalKind<'tcx>; + pub type Goals<'tcx> = &'tcx List>; impl<'tcx> DomainGoal<'tcx> { - pub fn into_goal(self) -> Goal<'tcx> { - Goal::DomainGoal(self) + pub fn into_goal(self) -> GoalKind<'tcx> { + GoalKind::DomainGoal(self) + } + + pub fn into_program_clause(self) -> ProgramClause<'tcx> { + ProgramClause { + goal: self, + hypotheses: ty::List::empty(), + category: ProgramClauseCategory::Other, + } } } -impl<'tcx> Goal<'tcx> { +impl<'tcx> GoalKind<'tcx> { pub fn from_poly_domain_goal<'a>( domain_goal: PolyDomainGoal<'tcx>, tcx: TyCtxt<'a, 'tcx, 'tcx>, - ) -> Goal<'tcx> { + ) -> GoalKind<'tcx> { match domain_goal.no_late_bound_regions() { Some(p) => p.into_goal(), - None => Goal::Quantified( + None => GoalKind::Quantified( QuantifierKind::Universal, domain_goal.map_bound(|p| tcx.mk_goal(p.into_goal())) ), @@ -356,6 +370,15 @@ ForAll(ty::Binder>), } +impl Clause<'tcx> { + pub fn category(self) -> ProgramClauseCategory { + match self { + Clause::Implies(clause) => clause.category, + Clause::ForAll(clause) => clause.skip_binder().category, + } + } +} + /// Multiple clauses. pub type Clauses<'tcx> = &'tcx List>; @@ -372,6 +395,38 @@ /// ...if we can prove these hypotheses (there may be no hypotheses at all): pub hypotheses: Goals<'tcx>, + + /// Useful for filtering clauses. + pub category: ProgramClauseCategory, +} + +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] +pub enum ProgramClauseCategory { + ImpliedBound, + WellFormed, + Other, +} + +/// A set of clauses that we assume to be true. +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] +pub struct Environment<'tcx> { + pub clauses: Clauses<'tcx>, +} + +impl Environment<'tcx> { + pub fn with(self, goal: G) -> InEnvironment<'tcx, G> { + InEnvironment { + environment: self, + goal, + } + } +} + +/// Something (usually a goal), along with an environment. +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] +pub struct InEnvironment<'tcx, G> { + pub environment: Environment<'tcx>, + pub goal: G, } pub type Selection<'tcx> = Vtable<'tcx, PredicateObligation<'tcx>>; @@ -631,44 +686,20 @@ } } -// FIXME: this is gonna need to be removed ... -/// Normalizes the parameter environment, reporting errors if they occur. -pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - region_context: DefId, - unnormalized_env: ty::ParamEnv<'tcx>, - cause: ObligationCause<'tcx>) - -> ty::ParamEnv<'tcx> +fn do_normalize_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, + region_context: DefId, + cause: ObligationCause<'tcx>, + elaborated_env: ty::ParamEnv<'tcx>, + predicates: Vec>) + -> Result>, ErrorReported> { - // I'm not wild about reporting errors here; I'd prefer to - // have the errors get reported at a defined place (e.g., - // during typeck). Instead I have all parameter - // environments, in effect, going through this function - // and hence potentially reporting errors. This ensurse of - // course that we never forget to normalize (the - // alternative seemed like it would involve a lot of - // manual invocations of this fn -- and then we'd have to - // deal with the errors at each of those sites). - // - // In any case, in practice, typeck constructs all the - // parameter environments once for every fn as it goes, - // and errors will get reported then; so after typeck we - // can be sure that no errors should occur. - + debug!( + "do_normalize_predicates(predicates={:?}, region_context={:?}, cause={:?})", + predicates, + region_context, + cause, + ); let span = cause.span; - - debug!("normalize_param_env_or_error(unnormalized_env={:?})", - unnormalized_env); - - let predicates: Vec<_> = - util::elaborate_predicates(tcx, unnormalized_env.caller_bounds.to_vec()) - .collect(); - - debug!("normalize_param_env_or_error: elaborated-predicates={:?}", - predicates); - - let elaborated_env = ty::ParamEnv::new(tcx.intern_predicates(&predicates), - unnormalized_env.reveal); - tcx.infer_ctxt().enter(|infcx| { // FIXME. We should really... do something with these region // obligations. But this call just continues the older @@ -684,30 +715,21 @@ // them here too, and we will remove this function when // we move over to lazy normalization *anyway*. let fulfill_cx = FulfillmentContext::new_ignoring_regions(); - let predicates = match fully_normalize( &infcx, fulfill_cx, cause, elaborated_env, - // You would really want to pass infcx.param_env.caller_bounds here, - // but that is an interned slice, and fully_normalize takes &T and returns T, so - // without further refactoring, a slice can't be used. Luckily, we still have the - // predicate vector from which we created the ParamEnv in infcx, so we - // can pass that instead. It's roundabout and a bit brittle, but this code path - // ought to be refactored anyway, and until then it saves us from having to copy. &predicates, ) { Ok(predicates) => predicates, Err(errors) => { infcx.report_fulfillment_errors(&errors, None, false); - // An unnormalized env is better than nothing. - return elaborated_env; + return Err(ErrorReported) } }; - debug!("normalize_param_env_or_error: normalized predicates={:?}", - predicates); + debug!("do_normalize_predictes: normalized predicates = {:?}", predicates); let region_scope_tree = region::ScopeTree::default(); @@ -715,7 +737,12 @@ // cares about declarations like `'a: 'b`. let outlives_env = OutlivesEnvironment::new(elaborated_env); - infcx.resolve_regions_and_report_errors(region_context, ®ion_scope_tree, &outlives_env); + infcx.resolve_regions_and_report_errors( + region_context, + ®ion_scope_tree, + &outlives_env, + SuppressRegionErrors::default(), + ); let predicates = match infcx.fully_resolve(&predicates) { Ok(predicates) => predicates, @@ -728,21 +755,119 @@ // unconstrained variable, and it seems better not to ICE, // all things considered. tcx.sess.span_err(span, &fixup_err.to_string()); - // An unnormalized env is better than nothing. - return elaborated_env; + return Err(ErrorReported) } }; - let predicates = match tcx.lift_to_global(&predicates) { - Some(predicates) => predicates, - None => return elaborated_env, + match tcx.lift_to_global(&predicates) { + Some(predicates) => Ok(predicates), + None => { + // FIXME: shouldn't we, you know, actually report an error here? or an ICE? + Err(ErrorReported) + } + } + }) +} + +// FIXME: this is gonna need to be removed ... +/// Normalizes the parameter environment, reporting errors if they occur. +pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, + region_context: DefId, + unnormalized_env: ty::ParamEnv<'tcx>, + cause: ObligationCause<'tcx>) + -> ty::ParamEnv<'tcx> +{ + // I'm not wild about reporting errors here; I'd prefer to + // have the errors get reported at a defined place (e.g., + // during typeck). Instead I have all parameter + // environments, in effect, going through this function + // and hence potentially reporting errors. This ensures of + // course that we never forget to normalize (the + // alternative seemed like it would involve a lot of + // manual invocations of this fn -- and then we'd have to + // deal with the errors at each of those sites). + // + // In any case, in practice, typeck constructs all the + // parameter environments once for every fn as it goes, + // and errors will get reported then; so after typeck we + // can be sure that no errors should occur. + + debug!("normalize_param_env_or_error(region_context={:?}, unnormalized_env={:?}, cause={:?})", + region_context, unnormalized_env, cause); + + let mut predicates: Vec<_> = + util::elaborate_predicates(tcx, unnormalized_env.caller_bounds.to_vec()) + .collect(); + + debug!("normalize_param_env_or_error: elaborated-predicates={:?}", + predicates); + + let elaborated_env = ty::ParamEnv::new(tcx.intern_predicates(&predicates), + unnormalized_env.reveal); + + // HACK: we are trying to normalize the param-env inside *itself*. The problem is that + // normalization expects its param-env to be already normalized, which means we have + // a circularity. + // + // The way we handle this is by normalizing the param-env inside an unnormalized version + // of the param-env, which means that if the param-env contains unnormalized projections, + // we'll have some normalization failures. This is unfortunate. + // + // Lazy normalization would basically handle this by treating just the + // normalizing-a-trait-ref-requires-itself cycles as evaluation failures. + // + // Inferred outlives bounds can create a lot of `TypeOutlives` predicates for associated + // types, so to make the situation less bad, we normalize all the predicates *but* + // the `TypeOutlives` predicates first inside the unnormalized parameter environment, and + // then we normalize the `TypeOutlives` bounds inside the normalized parameter environment. + // + // This works fairly well because trait matching does not actually care about param-env + // TypeOutlives predicates - these are normally used by regionck. + let outlives_predicates: Vec<_> = predicates.drain_filter(|predicate| { + match predicate { + ty::Predicate::TypeOutlives(..) => true, + _ => false + } + }).collect(); + + debug!("normalize_param_env_or_error: predicates=(non-outlives={:?}, outlives={:?})", + predicates, outlives_predicates); + let non_outlives_predicates = + match do_normalize_predicates(tcx, region_context, cause.clone(), + elaborated_env, predicates) { + Ok(predicates) => predicates, + // An unnormalized env is better than nothing. + Err(ErrorReported) => { + debug!("normalize_param_env_or_error: errored resolving non-outlives predicates"); + return elaborated_env + } }; - debug!("normalize_param_env_or_error: resolved predicates={:?}", - predicates); + debug!("normalize_param_env_or_error: non-outlives predicates={:?}", non_outlives_predicates); - ty::ParamEnv::new(tcx.intern_predicates(&predicates), unnormalized_env.reveal) - }) + // Not sure whether it is better to include the unnormalized TypeOutlives predicates + // here. I believe they should not matter, because we are ignoring TypeOutlives param-env + // predicates here anyway. Keeping them here anyway because it seems safer. + let outlives_env: Vec<_> = + non_outlives_predicates.iter().chain(&outlives_predicates).cloned().collect(); + let outlives_env = ty::ParamEnv::new(tcx.intern_predicates(&outlives_env), + unnormalized_env.reveal); + let outlives_predicates = + match do_normalize_predicates(tcx, region_context, cause, + outlives_env, outlives_predicates) { + Ok(predicates) => predicates, + // An unnormalized env is better than nothing. + Err(ErrorReported) => { + debug!("normalize_param_env_or_error: errored resolving outlives predicates"); + return elaborated_env + } + }; + debug!("normalize_param_env_or_error: outlives predicates={:?}", outlives_predicates); + + let mut predicates = non_outlives_predicates; + predicates.extend(outlives_predicates); + debug!("normalize_param_env_or_error: final predicates={:?}", predicates); + ty::ParamEnv::new(tcx.intern_predicates(&predicates), unnormalized_env.reveal) } pub fn fully_normalize<'a, 'gcx, 'tcx, T>( @@ -810,11 +935,10 @@ key: (DefId, &'tcx Substs<'tcx>)) -> bool { - use ty::subst::Subst; debug!("substitute_normalize_and_test_predicates(key={:?})", key); - let predicates = tcx.predicates_of(key.0).predicates.subst(tcx, key.1); + let predicates = tcx.predicates_of(key.0).instantiate(tcx, key.1).predicates; let result = normalize_and_test_predicates(tcx, predicates); debug!("substitute_normalize_and_test_predicates(key={:?}) = {:?}", @@ -851,16 +975,16 @@ // the method may have some early-bound lifetimes, add // regions for those - let substs = trait_ref.map_bound(|trait_ref| { - Substs::for_item(tcx, def_id, |param, _| { + let substs = trait_ref.map_bound(|trait_ref| + Substs::for_item(tcx, def_id, |param, _| match param.kind { GenericParamDefKind::Lifetime => tcx.types.re_erased.into(), GenericParamDefKind::Type {..} => { trait_ref.substs[param.index as usize] } } - }) - }); + ) + ); // the trait type may have higher-ranked lifetimes in it; // so erase them if they appear, so that we get the type @@ -1004,7 +1128,7 @@ } } -pub fn provide(providers: &mut ty::query::Providers) { +pub fn provide(providers: &mut ty::query::Providers<'_>) { *providers = ty::query::Providers { is_object_safe: object_safety::is_object_safe_provider, specialization_graph_of: specialize::specialization_graph_provider, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/object_safety.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/object_safety.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/object_safety.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/object_safety.rs 2018-12-04 23:41:40.000000000 +0000 @@ -124,20 +124,21 @@ // Check methods for violations. let mut violations: Vec<_> = self.associated_items(trait_def_id) .filter(|item| item.kind == ty::AssociatedKind::Method) - .filter_map(|item| { + .filter_map(|item| self.object_safety_violation_for_method(trait_def_id, &item) .map(|code| ObjectSafetyViolation::Method(item.ident.name, code)) - }).filter(|violation| { + ).filter(|violation| { if let ObjectSafetyViolation::Method(_, - MethodViolationCode::WhereClauseReferencesSelf(span)) = violation { - // Using`CRATE_NODE_ID` is wrong, but it's hard to get a more precise id. + MethodViolationCode::WhereClauseReferencesSelf(span)) = violation + { + // Using `CRATE_NODE_ID` is wrong, but it's hard to get a more precise id. // It's also hard to get a use site span, so we use the method definition span. self.lint_node_note( lint::builtin::WHERE_CLAUSES_OBJECT_SAFETY, ast::CRATE_NODE_ID, *span, &format!("the trait `{}` cannot be made into an object", - self.item_path_str(trait_def_id)), + self.item_path_str(trait_def_id)), &violation.error_msg()); false } else { @@ -178,7 +179,7 @@ predicates .predicates .into_iter() - .map(|predicate| predicate.subst_supertrait(self, &trait_ref)) + .map(|(predicate, _)| predicate.subst_supertrait(self, &trait_ref)) .any(|predicate| { match predicate { ty::Predicate::Trait(ref data) => { @@ -213,24 +214,23 @@ let predicates = self.predicates_of(def_id); let predicates = predicates.instantiate_identity(self).predicates; elaborate_predicates(self, predicates) - .any(|predicate| { - match predicate { - ty::Predicate::Trait(ref trait_pred) if trait_pred.def_id() == sized_def_id => { - trait_pred.skip_binder().self_ty().is_self() - } - ty::Predicate::Projection(..) | - ty::Predicate::Trait(..) | - ty::Predicate::Subtype(..) | - ty::Predicate::RegionOutlives(..) | - ty::Predicate::WellFormed(..) | - ty::Predicate::ObjectSafe(..) | - ty::Predicate::ClosureKind(..) | - ty::Predicate::TypeOutlives(..) | - ty::Predicate::ConstEvaluatable(..) => { - false - } + .any(|predicate| match predicate { + ty::Predicate::Trait(ref trait_pred) if trait_pred.def_id() == sized_def_id => { + trait_pred.skip_binder().self_ty().is_self() } - }) + ty::Predicate::Projection(..) | + ty::Predicate::Trait(..) | + ty::Predicate::Subtype(..) | + ty::Predicate::RegionOutlives(..) | + ty::Predicate::WellFormed(..) | + ty::Predicate::ObjectSafe(..) | + ty::Predicate::ClosureKind(..) | + ty::Predicate::TypeOutlives(..) | + ty::Predicate::ConstEvaluatable(..) => { + false + } + } + ) } /// Returns `Some(_)` if this method makes the containing trait not object safe. @@ -311,7 +311,7 @@ if self.predicates_of(method.def_id).predicates.into_iter() // A trait object can't claim to live more than the concrete type, // so outlives predicates will always hold. - .filter(|p| p.to_opt_type_outlives().is_none()) + .filter(|(p, _)| p.to_opt_type_outlives().is_none()) .collect::>() // Do a shallow visit so that `contains_illegal_self_type_reference` // may apply it's custom visiting. diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/on_unimplemented.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/on_unimplemented.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/on_unimplemented.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/on_unimplemented.rs 2018-12-04 23:41:40.000000000 +0000 @@ -44,7 +44,7 @@ } } -fn parse_error(tcx: TyCtxt, span: Span, +fn parse_error(tcx: TyCtxt<'_, '_, '_>, span: Span, message: &str, label: &str, note: Option<&str>) @@ -74,17 +74,17 @@ let condition = if is_root { None } else { - let cond = item_iter.next().ok_or_else(|| { + let cond = item_iter.next().ok_or_else(|| parse_error(tcx, span, "empty `on`-clause in `#[rustc_on_unimplemented]`", "empty on-clause here", None) - })?.meta_item().ok_or_else(|| { + )?.meta_item().ok_or_else(|| parse_error(tcx, span, "invalid `on`-clause in `#[rustc_on_unimplemented]`", "invalid on-clause here", None) - })?; + )?; attr::eval_condition(cond, &tcx.sess.parse_sess, &mut |_| true); Some(cond.clone()) }; @@ -259,9 +259,9 @@ // `{from_desugaring}` is allowed Position::ArgumentNamed(s) if s == "from_desugaring" => (), // So is `{A}` if A is a type parameter - Position::ArgumentNamed(s) => match generics.params.iter().find(|param| { + Position::ArgumentNamed(s) => match generics.params.iter().find(|param| param.name == s - }) { + ) { Some(_) => (), None => { span_err!(tcx.sess, span, E0230, @@ -304,7 +304,7 @@ let empty_string = String::new(); let parser = Parser::new(&self.0, None); - parser.map(|p| { + parser.map(|p| match p { Piece::String(s) => s, Piece::NextArgument(a) => match a.position { @@ -326,11 +326,9 @@ } } }, - _ => { - bug!("broken on_unimplemented {:?} - bad format arg", self.0) - } + _ => bug!("broken on_unimplemented {:?} - bad format arg", self.0) } } - }).collect() + ).collect() } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/project.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/project.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/project.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/project.rs 2018-12-04 23:41:40.000000000 +0000 @@ -171,7 +171,7 @@ match (current, candidate) { (ParamEnv(..), ParamEnv(..)) => convert_to_ambiguous = (), (ParamEnv(..), _) => return false, - (_, ParamEnv(..)) => { unreachable!(); } + (_, ParamEnv(..)) => unreachable!(), (_, _) => convert_to_ambiguous = (), } } @@ -206,15 +206,15 @@ let infcx = selcx.infcx(); infcx.commit_if_ok(|snapshot| { - let (skol_predicate, skol_map) = - infcx.skolemize_late_bound_regions(&obligation.predicate); + let (placeholder_predicate, placeholder_map) = + infcx.replace_late_bound_regions_with_placeholders(&obligation.predicate); - let skol_obligation = obligation.with(skol_predicate); + let skol_obligation = obligation.with(placeholder_predicate); let r = match project_and_unify_type(selcx, &skol_obligation) { Ok(result) => { let span = obligation.cause.span; - match infcx.leak_check(false, span, &skol_map, snapshot) { - Ok(()) => Ok(infcx.plug_leaks(skol_map, snapshot, result)), + match infcx.leak_check(false, span, &placeholder_map, snapshot) { + Ok(()) => Ok(infcx.plug_leaks(placeholder_map, snapshot, result)), Err(e) => { debug!("poly_project_and_unify_type: leak check encountered error {:?}", e); Err(MismatchedProjectionTypes { err: e }) @@ -340,7 +340,7 @@ let value = self.selcx.infcx().resolve_type_vars_if_possible(value); if !value.has_projections() { - value.clone() + value } else { value.fold_with(self) } @@ -419,9 +419,7 @@ normalized_ty } - _ => { - ty - } + _ => ty } } @@ -437,12 +435,9 @@ instance, promoted: None }; - match tcx.const_eval(param_env.and(cid)) { - Ok(evaluated) => { - let evaluated = evaluated.subst(self.tcx(), substs); - return self.fold_const(evaluated); - } - Err(_) => {} + if let Ok(evaluated) = tcx.const_eval(param_env.and(cid)) { + let evaluated = evaluated.subst(self.tcx(), substs); + return self.fold_const(evaluated); } } } else { @@ -453,9 +448,8 @@ instance, promoted: None }; - match tcx.const_eval(param_env.and(cid)) { - Ok(evaluated) => return self.fold_const(evaluated), - Err(_) => {} + if let Ok(evaluated) = tcx.const_eval(param_env.and(cid)) { + return self.fold_const(evaluated) } } } @@ -600,7 +594,7 @@ // But for now, let's classify this as an overflow: let recursion_limit = *selcx.tcx().sess.recursion_limit.get(); - let obligation = Obligation::with_depth(cause.clone(), + let obligation = Obligation::with_depth(cause, recursion_limit, param_env, projection_ty); @@ -894,7 +888,7 @@ let recursion_limit = *selcx.tcx().sess.recursion_limit.get(); if obligation.recursion_depth >= recursion_limit { debug!("project: overflow!"); - selcx.infcx().report_overflow_error(&obligation, true); + return Err(ProjectionTyError::TraitSelectionError(SelectionError::Overflow)); } let obligation_trait_ref = &obligation.predicate.trait_ref(selcx.tcx()); @@ -993,7 +987,7 @@ candidate_set.mark_ambiguous(); return; } - _ => { return; } + _ => return }; // If so, extract what we know from the trait and try to come up with a good answer. @@ -1023,33 +1017,30 @@ for predicate in env_predicates { debug!("assemble_candidates_from_predicates: predicate={:?}", predicate); - match predicate { - ty::Predicate::Projection(data) => { - let same_def_id = data.projection_def_id() == obligation.predicate.item_def_id; - - let is_match = same_def_id && infcx.probe(|_| { - let data_poly_trait_ref = - data.to_poly_trait_ref(infcx.tcx); - let obligation_poly_trait_ref = - obligation_trait_ref.to_poly_trait_ref(); - infcx.at(&obligation.cause, obligation.param_env) - .sup(obligation_poly_trait_ref, data_poly_trait_ref) - .map(|InferOk { obligations: _, value: () }| { - // FIXME(#32730) -- do we need to take obligations - // into account in any way? At the moment, no. - }) - .is_ok() - }); - - debug!("assemble_candidates_from_predicates: candidate={:?} \ - is_match={} same_def_id={}", - data, is_match, same_def_id); + if let ty::Predicate::Projection(data) = predicate { + let same_def_id = data.projection_def_id() == obligation.predicate.item_def_id; - if is_match { - candidate_set.push_candidate(ctor(data)); - } + let is_match = same_def_id && infcx.probe(|_| { + let data_poly_trait_ref = + data.to_poly_trait_ref(infcx.tcx); + let obligation_poly_trait_ref = + obligation_trait_ref.to_poly_trait_ref(); + infcx.at(&obligation.cause, obligation.param_env) + .sup(obligation_poly_trait_ref, data_poly_trait_ref) + .map(|InferOk { obligations: _, value: () }| { + // FIXME(#32730) -- do we need to take obligations + // into account in any way? At the moment, no. + }) + .is_ok() + }); + + debug!("assemble_candidates_from_predicates: candidate={:?} \ + is_match={} same_def_id={}", + data, is_match, same_def_id); + + if is_match { + candidate_set.push_candidate(ctor(data)); } - _ => {} } } } @@ -1072,8 +1063,7 @@ return Err(()); } Err(e) => { - debug!("assemble_candidates_from_impls: selection error {:?}", - e); + debug!("assemble_candidates_from_impls: selection error {:?}", e); candidate_set.mark_error(e); return Err(()); } @@ -1295,11 +1285,11 @@ let mut env_predicates = env_predicates.filter(|data| { let data_poly_trait_ref = data.to_poly_trait_ref(selcx.tcx()); let obligation_poly_trait_ref = obligation_trait_ref.to_poly_trait_ref(); - selcx.infcx().probe(|_| { + selcx.infcx().probe(|_| selcx.infcx().at(&obligation.cause, obligation.param_env) .sup(obligation_poly_trait_ref, data_poly_trait_ref) .is_ok() - }) + ) }); // select the first matching one; there really ought to be one or @@ -1447,7 +1437,7 @@ obligation.predicate.self_ty(), fn_sig, flag) - .map_bound(|(trait_ref, ret_type)| { + .map_bound(|(trait_ref, ret_type)| ty::ProjectionPredicate { projection_ty: ty::ProjectionTy::from_ref_and_name( tcx, @@ -1456,7 +1446,7 @@ ), ty: ret_type } - }); + ); confirm_param_env_candidate(selcx, obligation, predicate) } @@ -1581,11 +1571,11 @@ // # Cache -/// The projection cache. Unlike the standard caches, this can -/// include infcx-dependent type variables - therefore, we have to roll -/// the cache back each time we roll a snapshot back, to avoid assumptions -/// on yet-unresolved inference variables. Types with skolemized regions -/// also have to be removed when the respective snapshot ends. +/// The projection cache. Unlike the standard caches, this can include +/// infcx-dependent type variables - therefore, we have to roll the +/// cache back each time we roll a snapshot back, to avoid assumptions +/// on yet-unresolved inference variables. Types with placeholder +/// regions also have to be removed when the respective snapshot ends. /// /// Because of that, projection cache entries can be "stranded" and left /// inaccessible when type variables inside the key are resolved. We make no @@ -1611,6 +1601,7 @@ /// FIXME: we probably also want some sort of cross-infcx cache here to /// reduce the amount of duplication. Let's see what we get with the Chalk /// reforms. +#[derive(Default)] pub struct ProjectionCache<'tcx> { map: SnapshotMap, ProjectionCacheEntry<'tcx>>, } @@ -1653,12 +1644,6 @@ } impl<'tcx> ProjectionCache<'tcx> { - pub fn new() -> Self { - ProjectionCache { - map: SnapshotMap::new() - } - } - pub fn clear(&mut self) { self.map.clear(); } @@ -1671,7 +1656,7 @@ self.map.rollback_to(&snapshot.snapshot); } - pub fn rollback_skolemized(&mut self, snapshot: &ProjectionCacheSnapshot) { + pub fn rollback_placeholder(&mut self, snapshot: &ProjectionCacheSnapshot) { self.map.partial_rollback(&snapshot.snapshot, &|k| k.ty.has_re_skol()); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/dropck_outlives.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/dropck_outlives.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/dropck_outlives.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/dropck_outlives.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,7 @@ use infer::at::At; use infer::InferOk; -use smallvec::SmallVec; +use infer::canonical::OriginalQueryValues; use std::iter::FromIterator; use syntax::source_map::Span; use ty::subst::Kind; @@ -51,28 +51,25 @@ } let gcx = tcx.global_tcx(); - let mut orig_values = SmallVec::new(); + let mut orig_values = OriginalQueryValues::default(); let c_ty = self.infcx.canonicalize_query(&self.param_env.and(ty), &mut orig_values); let span = self.cause.span; debug!("c_ty = {:?}", c_ty); match &gcx.dropck_outlives(c_ty) { Ok(result) if result.is_proven() => { - match self.infcx.instantiate_query_result_and_region_obligations( + if let Ok(InferOk { value, obligations }) = + self.infcx.instantiate_query_response_and_region_obligations( self.cause, self.param_env, &orig_values, - result, - ) { - Ok(InferOk { value, obligations }) => { - let ty = self.infcx.resolve_type_vars_if_possible(&ty); - let kinds = value.into_kinds_reporting_overflows(tcx, span, ty); - return InferOk { - value: kinds, - obligations, - }; - } - - Err(_) => { /* fallthrough to error-handling code below */ } + result) + { + let ty = self.infcx.resolve_type_vars_if_possible(&ty); + let kinds = value.into_kinds_reporting_overflows(tcx, span, ty); + return InferOk { + value: kinds, + obligations, + }; } } @@ -161,12 +158,7 @@ fn from_iter>>(iter: I) -> Self { let mut result = Self::empty(); - for DtorckConstraint { - outlives, - dtorck_types, - overflows, - } in iter - { + for DtorckConstraint { outlives, dtorck_types, overflows } in iter { result.outlives.extend(outlives); result.dtorck_types.extend(dtorck_types); result.overflows.extend(overflows); @@ -254,12 +246,14 @@ } } - // The following *might* require a destructor: it would deeper inspection to tell. + // The following *might* require a destructor: needs deeper inspection. ty::Dynamic(..) | ty::Projection(..) | ty::Param(_) | ty::Opaque(..) | ty::Infer(_) | ty::Generator(..) => false, + + ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"), } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/evaluate_obligation.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/evaluate_obligation.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/evaluate_obligation.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/evaluate_obligation.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,7 +9,7 @@ // except according to those terms. use infer::InferCtxt; -use smallvec::SmallVec; +use infer::canonical::OriginalQueryValues; use traits::{EvaluationResult, PredicateObligation, SelectionContext, TraitQueryMode, OverflowError}; @@ -20,7 +20,7 @@ &self, obligation: &PredicateObligation<'tcx>, ) -> bool { - self.evaluate_obligation(obligation).may_apply() + self.evaluate_obligation_no_overflow(obligation).may_apply() } /// Evaluates whether the predicate can be satisfied in the given @@ -30,28 +30,44 @@ &self, obligation: &PredicateObligation<'tcx>, ) -> bool { - self.evaluate_obligation(obligation) == EvaluationResult::EvaluatedToOk + self.evaluate_obligation_no_overflow(obligation) == EvaluationResult::EvaluatedToOk } - // Helper function that canonicalizes and runs the query, as well as handles - // overflow. - fn evaluate_obligation( + /// Evaluate a given predicate, capturing overflow and propagating it back. + pub fn evaluate_obligation( &self, obligation: &PredicateObligation<'tcx>, - ) -> EvaluationResult { - let mut _orig_values = SmallVec::new(); + ) -> Result { + let mut _orig_values = OriginalQueryValues::default(); let c_pred = self.canonicalize_query(&obligation.param_env.and(obligation.predicate), &mut _orig_values); // Run canonical query. If overflow occurs, rerun from scratch but this time // in standard trait query mode so that overflow is handled appropriately // within `SelectionContext`. - match self.tcx.global_tcx().evaluate_obligation(c_pred) { + self.tcx.global_tcx().evaluate_obligation(c_pred) + } + + // Helper function that canonicalizes and runs the query. If an + // overflow results, we re-run it in the local context so we can + // report a nice error. + fn evaluate_obligation_no_overflow( + &self, + obligation: &PredicateObligation<'tcx>, + ) -> EvaluationResult { + match self.evaluate_obligation(obligation) { Ok(result) => result, Err(OverflowError) => { let mut selcx = SelectionContext::with_query_mode(&self, TraitQueryMode::Standard); selcx.evaluate_obligation_recursively(obligation) - .expect("Overflow should be caught earlier in standard query mode") + .unwrap_or_else(|r| { + span_bug!( + obligation.cause.span, + "Overflow should be caught earlier in standard query mode: {:?}, {:?}", + obligation, + r, + ) + }) } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -34,6 +34,9 @@ pub type CanonicalPredicateGoal<'tcx> = Canonical<'tcx, ty::ParamEnvAnd<'tcx, ty::Predicate<'tcx>>>; +pub type CanonicalTypeOpAscribeUserTypeGoal<'tcx> = + Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::ascribe_user_type::AscribeUserType<'tcx>>>; + pub type CanonicalTypeOpEqGoal<'tcx> = Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::eq::Eq<'tcx>>>; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/normalize.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/normalize.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/normalize.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/normalize.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,9 +13,9 @@ //! `normalize_projection_ty` query when it encounters projections. use infer::at::At; +use infer::canonical::OriginalQueryValues; use infer::{InferCtxt, InferOk}; use mir::interpret::{ConstValue, GlobalId}; -use smallvec::SmallVec; use traits::project::Normalized; use traits::{Obligation, ObligationCause, PredicateObligation, Reveal}; use ty::fold::{TypeFoldable, TypeFolder}; @@ -48,6 +48,13 @@ value, self.param_env, ); + if !value.has_projections() { + return Ok(Normalized { + value: value.clone(), + obligations: vec![], + }); + } + let mut normalizer = QueryNormalizer { infcx: self.infcx, cause: self.cause, @@ -56,12 +63,6 @@ error: false, anon_depth: 0, }; - if !value.has_projections() { - return Ok(Normalized { - value: value.clone(), - obligations: vec![], - }); - } let value1 = value.fold_with(&mut normalizer); if normalizer.error { @@ -153,9 +154,9 @@ let gcx = self.infcx.tcx.global_tcx(); - let mut orig_values = SmallVec::new(); - let c_data = self.infcx - .canonicalize_query(&self.param_env.and(*data), &mut orig_values); + let mut orig_values = OriginalQueryValues::default(); + let c_data = self.infcx.canonicalize_query( + &self.param_env.and(*data), &mut orig_values); debug!("QueryNormalizer: c_data = {:#?}", c_data); debug!("QueryNormalizer: orig_values = {:#?}", orig_values); match gcx.normalize_projection_ty(c_data) { @@ -166,16 +167,13 @@ return ty; } - match self.infcx.instantiate_query_result_and_region_obligations( + match self.infcx.instantiate_query_response_and_region_obligations( self.cause, self.param_env, &orig_values, - &result, - ) { - Ok(InferOk { - value: result, - obligations, - }) => { + &result) + { + Ok(InferOk { value: result, obligations }) => { debug!("QueryNormalizer: result = {:#?}", result); debug!("QueryNormalizer: obligations = {:#?}", obligations); self.obligations.extend(obligations); @@ -212,12 +210,9 @@ instance, promoted: None, }; - match tcx.const_eval(param_env.and(cid)) { - Ok(evaluated) => { - let evaluated = evaluated.subst(self.tcx(), substs); - return self.fold_const(evaluated); - } - Err(_) => {} + if let Ok(evaluated) = tcx.const_eval(param_env.and(cid)) { + let evaluated = evaluated.subst(self.tcx(), substs); + return self.fold_const(evaluated); } } } else { @@ -228,9 +223,8 @@ instance, promoted: None, }; - match tcx.const_eval(param_env.and(cid)) { - Ok(evaluated) => return self.fold_const(evaluated), - Err(_) => {} + if let Ok(evaluated) = tcx.const_eval(param_env.and(cid)) { + return self.fold_const(evaluated) } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/outlives_bounds.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/outlives_bounds.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/outlives_bounds.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/outlives_bounds.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,9 +9,9 @@ // except according to those terms. use infer::InferCtxt; +use infer::canonical::OriginalQueryValues; use syntax::ast; use syntax::source_map::Span; -use smallvec::SmallVec; use traits::{FulfillmentContext, ObligationCause, TraitEngine, TraitEngineExt}; use traits::query::NoSolution; use ty::{self, Ty, TyCtxt}; @@ -105,7 +105,7 @@ ) -> Vec> { debug!("implied_outlives_bounds(ty = {:?})", ty); - let mut orig_values = SmallVec::new(); + let mut orig_values = OriginalQueryValues::default(); let key = self.canonicalize_query(¶m_env.and(ty), &mut orig_values); let result = match self.tcx.global_tcx().implied_outlives_bounds(key) { Ok(r) => r, @@ -119,7 +119,7 @@ }; assert!(result.value.is_proven()); - let result = self.instantiate_query_result_and_region_obligations( + let result = self.instantiate_query_response_and_region_obligations( &ObligationCause::misc(span, body_id), param_env, &orig_values, &result); debug!("implied_outlives_bounds for {:?}: {:#?}", ty, result); let result = match result { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/type_op/ascribe_user_type.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/type_op/ascribe_user_type.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/type_op/ascribe_user_type.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/type_op/ascribe_user_type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,80 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; +use traits::query::Fallible; +use hir::def_id::DefId; +use mir::ProjectionKind; +use ty::{self, ParamEnvAnd, Ty, TyCtxt}; +use ty::subst::UserSubsts; + +#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] +pub struct AscribeUserType<'tcx> { + pub mir_ty: Ty<'tcx>, + pub variance: ty::Variance, + pub def_id: DefId, + pub user_substs: UserSubsts<'tcx>, + pub projs: &'tcx ty::List>, +} + +impl<'tcx> AscribeUserType<'tcx> { + pub fn new( + mir_ty: Ty<'tcx>, + variance: ty::Variance, + def_id: DefId, + user_substs: UserSubsts<'tcx>, + projs: &'tcx ty::List>, + ) -> Self { + AscribeUserType { mir_ty, variance, def_id, user_substs, projs } + } +} + +impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for AscribeUserType<'tcx> { + type QueryResponse = (); + + fn try_fast_path( + _tcx: TyCtxt<'_, 'gcx, 'tcx>, + _key: &ParamEnvAnd<'tcx, Self>, + ) -> Option { + None + } + + fn perform_query( + tcx: TyCtxt<'_, 'gcx, 'tcx>, + canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, + ) -> Fallible> { + tcx.type_op_ascribe_user_type(canonicalized) + } + + fn shrink_to_tcx_lifetime( + v: &'a CanonicalizedQueryResponse<'gcx, ()>, + ) -> &'a Canonical<'tcx, QueryResponse<'tcx, ()>> { + v + } +} + +BraceStructTypeFoldableImpl! { + impl<'tcx> TypeFoldable<'tcx> for AscribeUserType<'tcx> { + mir_ty, variance, def_id, user_substs, projs + } +} + +BraceStructLiftImpl! { + impl<'a, 'tcx> Lift<'tcx> for AscribeUserType<'a> { + type Lifted = AscribeUserType<'tcx>; + mir_ty, variance, def_id, user_substs, projs + } +} + +impl_stable_hash_for! { + struct AscribeUserType<'tcx> { + mir_ty, variance, def_id, user_substs, projs + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/type_op/custom.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/type_op/custom.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/type_op/custom.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/type_op/custom.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,7 +12,7 @@ use std::fmt; use traits::query::Fallible; -use infer::canonical::query_result; +use infer::canonical::query_response; use infer::canonical::QueryRegionConstraint; use std::rc::Rc; use syntax::source_map::DUMMY_SP; @@ -62,7 +62,7 @@ where G: Fn() -> String, { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", (self.description)()) } } @@ -102,7 +102,7 @@ let region_constraint_data = infcx.take_and_reset_region_constraints(); - let outlives = query_result::make_query_outlives( + let outlives = query_response::make_query_outlives( infcx.tcx, region_obligations .iter() diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/type_op/eq.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/type_op/eq.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/type_op/eq.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/type_op/eq.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResult, QueryResult}; +use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; use traits::query::Fallible; use ty::{ParamEnvAnd, Ty, TyCtxt}; @@ -25,12 +25,12 @@ } impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for Eq<'tcx> { - type QueryResult = (); + type QueryResponse = (); fn try_fast_path( _tcx: TyCtxt<'_, 'gcx, 'tcx>, key: &ParamEnvAnd<'tcx, Eq<'tcx>>, - ) -> Option { + ) -> Option { if key.value.a == key.value.b { Some(()) } else { @@ -41,13 +41,13 @@ fn perform_query( tcx: TyCtxt<'_, 'gcx, 'tcx>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, - ) -> Fallible> { + ) -> Fallible> { tcx.type_op_eq(canonicalized) } fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResult<'gcx, ()>, - ) -> &'a Canonical<'tcx, QueryResult<'tcx, ()>> { + v: &'a CanonicalizedQueryResponse<'gcx, ()>, + ) -> &'a Canonical<'tcx, QueryResponse<'tcx, ()>> { v } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/type_op/implied_outlives_bounds.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/type_op/implied_outlives_bounds.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/type_op/implied_outlives_bounds.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/type_op/implied_outlives_bounds.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResult, QueryResult}; +use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; use traits::query::outlives_bounds::OutlivesBound; use traits::query::Fallible; use ty::{ParamEnvAnd, Ty, TyCtxt}; @@ -25,19 +25,19 @@ } impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for ImpliedOutlivesBounds<'tcx> { - type QueryResult = Vec>; + type QueryResponse = Vec>; fn try_fast_path( _tcx: TyCtxt<'_, 'gcx, 'tcx>, _key: &ParamEnvAnd<'tcx, Self>, - ) -> Option { + ) -> Option { None } fn perform_query( tcx: TyCtxt<'_, 'gcx, 'tcx>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, - ) -> Fallible> { + ) -> Fallible> { // FIXME the query should take a `ImpliedOutlivesBounds` let Canonical { variables, @@ -56,8 +56,8 @@ } fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResult<'gcx, Self::QueryResult>, - ) -> &'a Canonical<'tcx, QueryResult<'tcx, Self::QueryResult>> { + v: &'a CanonicalizedQueryResponse<'gcx, Self::QueryResponse>, + ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self::QueryResponse>> { v } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/type_op/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/type_op/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/type_op/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/type_op/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,10 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResult, QueryRegionConstraint, - QueryResult}; +use infer::canonical::{ + Canonical, Canonicalized, CanonicalizedQueryResponse, OriginalQueryValues, + QueryRegionConstraint, QueryResponse, +}; use infer::{InferCtxt, InferOk}; -use smallvec::SmallVec; use std::fmt; use std::rc::Rc; use traits::query::Fallible; @@ -19,6 +20,7 @@ use ty::fold::TypeFoldable; use ty::{Lift, ParamEnvAnd, TyCtxt}; +pub mod ascribe_user_type; pub mod custom; pub mod eq; pub mod implied_outlives_bounds; @@ -55,7 +57,7 @@ pub trait QueryTypeOp<'gcx: 'tcx, 'tcx>: fmt::Debug + Sized + TypeFoldable<'tcx> + Lift<'gcx> { - type QueryResult: TypeFoldable<'tcx> + Lift<'gcx>; + type QueryResponse: TypeFoldable<'tcx> + Lift<'gcx>; /// Give query the option for a simple fast path that never /// actually hits the tcx cache lookup etc. Return `Some(r)` with @@ -63,7 +65,7 @@ fn try_fast_path( tcx: TyCtxt<'_, 'gcx, 'tcx>, key: &ParamEnvAnd<'tcx, Self>, - ) -> Option; + ) -> Option; /// Performs the actual query with the canonicalized key -- the /// real work happens here. This method is not given an `infcx` @@ -74,29 +76,29 @@ fn perform_query( tcx: TyCtxt<'_, 'gcx, 'tcx>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, - ) -> Fallible>; + ) -> Fallible>; /// Casts a lifted query result (which is in the gcx lifetime) /// into the tcx lifetime. This is always just an identity cast, /// but the generic code doesn't realize it -- put another way, in - /// the generic code, we have a `Lifted<'gcx, Self::QueryResult>` - /// and we want to convert that to a `Self::QueryResult`. This is + /// the generic code, we have a `Lifted<'gcx, Self::QueryResponse>` + /// and we want to convert that to a `Self::QueryResponse`. This is /// not a priori valid, so we can't do it -- but in practice, it /// is always a no-op (e.g., the lifted form of a type, /// `Ty<'gcx>`, is a subtype of `Ty<'tcx>`). So we have to push /// the operation into the impls that know more specifically what - /// `QueryResult` is. This operation would (maybe) be nicer with + /// `QueryResponse` is. This operation would (maybe) be nicer with /// something like HKTs or GATs, since then we could make - /// `QueryResult` parametric and `'gcx` and `'tcx` etc. + /// `QueryResponse` parametric and `'gcx` and `'tcx` etc. fn shrink_to_tcx_lifetime( - lifted_query_result: &'a CanonicalizedQueryResult<'gcx, Self::QueryResult>, - ) -> &'a Canonical<'tcx, QueryResult<'tcx, Self::QueryResult>>; + lifted_query_result: &'a CanonicalizedQueryResponse<'gcx, Self::QueryResponse>, + ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self::QueryResponse>>; fn fully_perform_into( query_key: ParamEnvAnd<'tcx, Self>, infcx: &InferCtxt<'_, 'gcx, 'tcx>, output_query_region_constraints: &mut Vec>, - ) -> Fallible { + ) -> Fallible { if let Some(result) = QueryTypeOp::try_fast_path(infcx.tcx, &query_key) { return Ok(result); } @@ -105,7 +107,7 @@ // `canonicalize_hr_query_hack` here because of things // like the subtype query, which go awry around // `'static` otherwise. - let mut canonical_var_values = SmallVec::new(); + let mut canonical_var_values = OriginalQueryValues::default(); let canonical_self = infcx.canonicalize_hr_query_hack(&query_key, &mut canonical_var_values); let canonical_result = Self::perform_query(infcx.tcx, canonical_self)?; @@ -114,7 +116,7 @@ let param_env = query_key.param_env; let InferOk { value, obligations } = infcx - .instantiate_nll_query_result_and_region_obligations( + .instantiate_nll_query_response_and_region_obligations( &ObligationCause::dummy(), param_env, &canonical_var_values, @@ -145,7 +147,7 @@ where Q: QueryTypeOp<'gcx, 'tcx>, { - type Output = Q::QueryResult; + type Output = Q::QueryResponse; fn fully_perform( self, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/type_op/normalize.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/type_op/normalize.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/type_op/normalize.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/type_op/normalize.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResult, QueryResult}; +use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; use std::fmt; use traits::query::Fallible; use ty::fold::TypeFoldable; @@ -32,7 +32,7 @@ where T: Normalizable<'gcx, 'tcx>, { - type QueryResult = T; + type QueryResponse = T; fn try_fast_path(_tcx: TyCtxt<'_, 'gcx, 'tcx>, key: &ParamEnvAnd<'tcx, Self>) -> Option { if !key.value.value.has_projections() { @@ -45,13 +45,13 @@ fn perform_query( tcx: TyCtxt<'_, 'gcx, 'tcx>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, - ) -> Fallible> { + ) -> Fallible> { T::type_op_method(tcx, canonicalized) } fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResult<'gcx, T>, - ) -> &'a Canonical<'tcx, QueryResult<'tcx, T>> { + v: &'a CanonicalizedQueryResponse<'gcx, T>, + ) -> &'a Canonical<'tcx, QueryResponse<'tcx, T>> { T::shrink_to_tcx_lifetime(v) } } @@ -60,13 +60,13 @@ fn type_op_method( tcx: TyCtxt<'_, 'gcx, 'tcx>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize>>, - ) -> Fallible>; + ) -> Fallible>; /// Convert from the `'gcx` (lifted) form of `Self` into the `tcx` /// form of `Self`. fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResult<'gcx, Self>, - ) -> &'a Canonical<'tcx, QueryResult<'tcx, Self>>; + v: &'a CanonicalizedQueryResponse<'gcx, Self>, + ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>>; } impl Normalizable<'gcx, 'tcx> for Ty<'tcx> @@ -76,13 +76,13 @@ fn type_op_method( tcx: TyCtxt<'_, 'gcx, 'tcx>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize>>, - ) -> Fallible> { + ) -> Fallible> { tcx.type_op_normalize_ty(canonicalized) } fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResult<'gcx, Self>, - ) -> &'a Canonical<'tcx, QueryResult<'tcx, Self>> { + v: &'a CanonicalizedQueryResponse<'gcx, Self>, + ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> { v } } @@ -94,13 +94,13 @@ fn type_op_method( tcx: TyCtxt<'_, 'gcx, 'tcx>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize>>, - ) -> Fallible> { + ) -> Fallible> { tcx.type_op_normalize_predicate(canonicalized) } fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResult<'gcx, Self>, - ) -> &'a Canonical<'tcx, QueryResult<'tcx, Self>> { + v: &'a CanonicalizedQueryResponse<'gcx, Self>, + ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> { v } } @@ -112,13 +112,13 @@ fn type_op_method( tcx: TyCtxt<'_, 'gcx, 'tcx>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize>>, - ) -> Fallible> { + ) -> Fallible> { tcx.type_op_normalize_poly_fn_sig(canonicalized) } fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResult<'gcx, Self>, - ) -> &'a Canonical<'tcx, QueryResult<'tcx, Self>> { + v: &'a CanonicalizedQueryResponse<'gcx, Self>, + ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> { v } } @@ -130,13 +130,13 @@ fn type_op_method( tcx: TyCtxt<'_, 'gcx, 'tcx>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize>>, - ) -> Fallible> { + ) -> Fallible> { tcx.type_op_normalize_fn_sig(canonicalized) } fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResult<'gcx, Self>, - ) -> &'a Canonical<'tcx, QueryResult<'tcx, Self>> { + v: &'a CanonicalizedQueryResponse<'gcx, Self>, + ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> { v } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/type_op/outlives.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/type_op/outlives.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/type_op/outlives.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/type_op/outlives.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResult, QueryResult}; +use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; use traits::query::dropck_outlives::trivial_dropck_outlives; use traits::query::dropck_outlives::DropckOutlivesResult; use traits::query::Fallible; @@ -29,12 +29,12 @@ where 'gcx: 'tcx, { - type QueryResult = DropckOutlivesResult<'tcx>; + type QueryResponse = DropckOutlivesResult<'tcx>; fn try_fast_path( tcx: TyCtxt<'_, 'gcx, 'tcx>, key: &ParamEnvAnd<'tcx, Self>, - ) -> Option { + ) -> Option { if trivial_dropck_outlives(tcx, key.value.dropped_ty) { Some(DropckOutlivesResult::default()) } else { @@ -45,7 +45,7 @@ fn perform_query( tcx: TyCtxt<'_, 'gcx, 'tcx>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, - ) -> Fallible> { + ) -> Fallible> { // Subtle: note that we are not invoking // `infcx.at(...).dropck_outlives(...)` here, but rather the // underlying `dropck_outlives` query. This same underlying @@ -76,8 +76,8 @@ } fn shrink_to_tcx_lifetime( - lifted_query_result: &'a CanonicalizedQueryResult<'gcx, Self::QueryResult>, - ) -> &'a Canonical<'tcx, QueryResult<'tcx, Self::QueryResult>> { + lifted_query_result: &'a CanonicalizedQueryResponse<'gcx, Self::QueryResponse>, + ) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self::QueryResponse>> { lifted_query_result } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/type_op/prove_predicate.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/type_op/prove_predicate.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/type_op/prove_predicate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/type_op/prove_predicate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResult, QueryResult}; +use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; use traits::query::Fallible; use ty::{ParamEnvAnd, Predicate, TyCtxt}; @@ -24,12 +24,12 @@ } impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for ProvePredicate<'tcx> { - type QueryResult = (); + type QueryResponse = (); fn try_fast_path( tcx: TyCtxt<'_, 'gcx, 'tcx>, key: &ParamEnvAnd<'tcx, Self>, - ) -> Option { + ) -> Option { // Proving Sized, very often on "obviously sized" types like // `&T`, accounts for about 60% percentage of the predicates // we have to prove. No need to canonicalize and all that for @@ -50,13 +50,13 @@ fn perform_query( tcx: TyCtxt<'_, 'gcx, 'tcx>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, - ) -> Fallible> { + ) -> Fallible> { tcx.type_op_prove_predicate(canonicalized) } fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResult<'gcx, ()>, - ) -> &'a Canonical<'tcx, QueryResult<'tcx, ()>> { + v: &'a CanonicalizedQueryResponse<'gcx, ()>, + ) -> &'a Canonical<'tcx, QueryResponse<'tcx, ()>> { v } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/type_op/subtype.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/type_op/subtype.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/query/type_op/subtype.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/query/type_op/subtype.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResult, QueryResult}; +use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; use traits::query::Fallible; use ty::{ParamEnvAnd, Ty, TyCtxt}; @@ -28,7 +28,7 @@ } impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for Subtype<'tcx> { - type QueryResult = (); + type QueryResponse = (); fn try_fast_path(_tcx: TyCtxt<'_, 'gcx, 'tcx>, key: &ParamEnvAnd<'tcx, Self>) -> Option<()> { if key.value.sub == key.value.sup { @@ -41,13 +41,13 @@ fn perform_query( tcx: TyCtxt<'_, 'gcx, 'tcx>, canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>, - ) -> Fallible> { + ) -> Fallible> { tcx.type_op_subtype(canonicalized) } fn shrink_to_tcx_lifetime( - v: &'a CanonicalizedQueryResult<'gcx, ()>, - ) -> &'a Canonical<'tcx, QueryResult<'tcx, ()>> { + v: &'a CanonicalizedQueryResponse<'gcx, ()>, + ) -> &'a Canonical<'tcx, QueryResponse<'tcx, ()>> { v } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/select.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/select.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/select.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/select.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,58 +12,61 @@ //! //! [rustc guide]: https://rust-lang-nursery.github.io/rustc-guide/traits/resolution.html#selection -use self::SelectionCandidate::*; use self::EvaluationResult::*; +use self::SelectionCandidate::*; use super::coherence::{self, Conflict}; -use super::DerivedObligationCause; -use super::{IntercrateMode, TraitQueryMode}; use super::project; use super::project::{normalize_with_depth, Normalized, ProjectionCacheKey}; -use super::{PredicateObligation, TraitObligation, ObligationCause}; -use super::{ObligationCauseCode, BuiltinDerivedObligation, ImplDerivedObligation}; -use super::{SelectionError, Unimplemented, OutputTypeParameterMismatch, Overflow}; -use super::{ObjectCastObligation, Obligation}; -use super::TraitNotObjectSafe; +use super::util; +use super::DerivedObligationCause; use super::Selection; use super::SelectionResult; -use super::{VtableBuiltin, VtableImpl, VtableParam, VtableClosure, VtableGenerator, - VtableFnPointer, VtableObject, VtableAutoImpl}; -use super::{VtableImplData, VtableObjectData, VtableBuiltinData, VtableGeneratorData, - VtableClosureData, VtableAutoImplData, VtableFnPointerData}; -use super::util; +use super::TraitNotObjectSafe; +use super::{BuiltinDerivedObligation, ImplDerivedObligation, ObligationCauseCode}; +use super::{IntercrateMode, TraitQueryMode}; +use super::{ObjectCastObligation, Obligation}; +use super::{ObligationCause, PredicateObligation, TraitObligation}; +use super::{OutputTypeParameterMismatch, Overflow, SelectionError, Unimplemented}; +use super::{ + VtableAutoImpl, VtableBuiltin, VtableClosure, VtableFnPointer, VtableGenerator, VtableImpl, + VtableObject, VtableParam, +}; +use super::{ + VtableAutoImplData, VtableBuiltinData, VtableClosureData, VtableFnPointerData, + VtableGeneratorData, VtableImplData, VtableObjectData, +}; -use dep_graph::{DepNodeIndex, DepKind}; +use dep_graph::{DepKind, DepNodeIndex}; use hir::def_id::DefId; use infer; use infer::{InferCtxt, InferOk, TypeFreshener}; -use ty::subst::{Subst, Substs}; -use ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt, TypeFoldable}; +use middle::lang_items; +use mir::interpret::GlobalId; use ty::fast_reject; use ty::relate::TypeRelation; -use middle::lang_items; -use mir::interpret::{GlobalId}; +use ty::subst::{Subst, Substs}; +use ty::{self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable}; +use hir; +use rustc_data_structures::bit_set::GrowableBitSet; use rustc_data_structures::sync::Lock; -use rustc_data_structures::bitvec::BitArray; -use std::iter; +use rustc_target::spec::abi::Abi; use std::cmp; use std::fmt; +use std::iter; use std::mem; use std::rc::Rc; -use rustc_target::spec::abi::Abi; -use hir; use util::nodemap::{FxHashMap, FxHashSet}; - -pub struct SelectionContext<'cx, 'gcx: 'cx+'tcx, 'tcx: 'cx> { +pub struct SelectionContext<'cx, 'gcx: 'cx + 'tcx, 'tcx: 'cx> { infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, - /// Freshener used specifically for skolemizing entries on the - /// obligation stack. This ensures that all entries on the stack - /// at one time will have the same set of skolemized entries, - /// which is important for checking for trait bounds that - /// recursively require themselves. + /// Freshener used specifically for entries on the obligation + /// stack. This ensures that all entries on the stack at one time + /// will have the same set of placeholder entries, which is + /// important for checking for trait bounds that recursively + /// require themselves. freshener: TypeFreshener<'cx, 'gcx, 'tcx>, /// If true, indicates that the evaluation should be conservative @@ -110,26 +113,43 @@ impl IntercrateAmbiguityCause { /// Emits notes when the overlap is caused by complex intercrate ambiguities. /// See #23980 for details. - pub fn add_intercrate_ambiguity_hint<'a, 'tcx>(&self, - err: &mut ::errors::DiagnosticBuilder) { + pub fn add_intercrate_ambiguity_hint<'a, 'tcx>( + &self, + err: &mut ::errors::DiagnosticBuilder<'_>, + ) { err.note(&self.intercrate_ambiguity_hint()); } pub fn intercrate_ambiguity_hint(&self) -> String { match self { - &IntercrateAmbiguityCause::DownstreamCrate { ref trait_desc, ref self_desc } => { + &IntercrateAmbiguityCause::DownstreamCrate { + ref trait_desc, + ref self_desc, + } => { let self_desc = if let &Some(ref ty) = self_desc { format!(" for type `{}`", ty) - } else { String::new() }; - format!("downstream crates may implement trait `{}`{}", trait_desc, self_desc) - } - &IntercrateAmbiguityCause::UpstreamCrateUpdate { ref trait_desc, ref self_desc } => { + } else { + String::new() + }; + format!( + "downstream crates may implement trait `{}`{}", + trait_desc, self_desc + ) + } + &IntercrateAmbiguityCause::UpstreamCrateUpdate { + ref trait_desc, + ref self_desc, + } => { let self_desc = if let &Some(ref ty) = self_desc { format!(" for type `{}`", ty) - } else { String::new() }; - format!("upstream crates may add new impl of trait `{}`{} \ - in future versions", - trait_desc, self_desc) + } else { + String::new() + }; + format!( + "upstream crates may add new impl of trait `{}`{} \ + in future versions", + trait_desc, self_desc + ) } } } @@ -139,17 +159,18 @@ struct TraitObligationStack<'prev, 'tcx: 'prev> { obligation: &'prev TraitObligation<'tcx>, - /// Trait ref from `obligation` but skolemized with the + /// Trait ref from `obligation` but "freshened" with the /// selection-context's freshener. Used to check for recursion. fresh_trait_ref: ty::PolyTraitRef<'tcx>, previous: TraitObligationStackList<'prev, 'tcx>, } -#[derive(Clone)] +#[derive(Clone, Default)] pub struct SelectionCache<'tcx> { - hashmap: Lock, - WithDepNode>>>>, + hashmap: Lock< + FxHashMap, WithDepNode>>>, + >, } /// The selection process begins by considering all impls, where @@ -224,10 +245,12 @@ /// required for associated types to work in default impls, as the bounds /// are visible both as projection bounds and as where-clauses from the /// parameter environment. -#[derive(PartialEq,Eq,Debug,Clone)] +#[derive(PartialEq, Eq, Debug, Clone)] enum SelectionCandidate<'tcx> { /// If has_nested is false, there are no *further* obligations - BuiltinCandidate { has_nested: bool }, + BuiltinCandidate { + has_nested: bool, + }, ParamCandidate(ty::PolyTraitRef<'tcx>), ImplCandidate(DefId), AutoImplCandidate(DefId), @@ -259,11 +282,7 @@ type Lifted = SelectionCandidate<'tcx>; fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option { Some(match *self { - BuiltinCandidate { has_nested } => { - BuiltinCandidate { - has_nested, - } - } + BuiltinCandidate { has_nested } => BuiltinCandidate { has_nested }, ImplCandidate(def_id) => ImplCandidate(def_id), AutoImplCandidate(def_id) => AutoImplCandidate(def_id), ProjectionCandidate => ProjectionCandidate, @@ -293,7 +312,7 @@ ambiguous: bool, } -#[derive(PartialEq,Eq,Debug,Clone)] +#[derive(PartialEq, Eq, Debug, Clone)] struct EvaluatedCandidate<'tcx> { candidate: SelectionCandidate<'tcx>, evaluation: EvaluationResult, @@ -307,7 +326,7 @@ /// candidate (a where-clause or user-defined impl). None, /// It is unknown whether there is an impl. - Ambiguous + Ambiguous, } #[derive(Copy, Clone, Debug, PartialOrd, Ord, PartialEq, Eq)] @@ -390,23 +409,17 @@ impl EvaluationResult { pub fn may_apply(self) -> bool { match self { - EvaluatedToOk | - EvaluatedToAmbig | - EvaluatedToUnknown => true, + EvaluatedToOk | EvaluatedToAmbig | EvaluatedToUnknown => true, - EvaluatedToErr | - EvaluatedToRecur => false + EvaluatedToErr | EvaluatedToRecur => false, } } fn is_stack_dependent(self) -> bool { match self { - EvaluatedToUnknown | - EvaluatedToRecur => true, + EvaluatedToUnknown | EvaluatedToRecur => true, - EvaluatedToOk | - EvaluatedToAmbig | - EvaluatedToErr => false, + EvaluatedToOk | EvaluatedToAmbig | EvaluatedToErr => false, } } } @@ -423,7 +436,7 @@ /// Indicates that trait evaluation caused overflow. pub struct OverflowError; -impl_stable_hash_for!(struct OverflowError { }); +impl_stable_hash_for!(struct OverflowError {}); impl<'tcx> From for SelectionError<'tcx> { fn from(OverflowError: OverflowError) -> SelectionError<'tcx> { @@ -431,9 +444,9 @@ } } -#[derive(Clone)] +#[derive(Clone, Default)] pub struct EvaluationCache<'tcx> { - hashmap: Lock, WithDepNode>> + hashmap: Lock, WithDepNode>>, } impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { @@ -448,8 +461,10 @@ } } - pub fn intercrate(infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, - mode: IntercrateMode) -> SelectionContext<'cx, 'gcx, 'tcx> { + pub fn intercrate( + infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, + mode: IntercrateMode, + ) -> SelectionContext<'cx, 'gcx, 'tcx> { debug!("intercrate({:?})", mode); SelectionContext { infcx, @@ -461,8 +476,10 @@ } } - pub fn with_negative(infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, - allow_negative_impls: bool) -> SelectionContext<'cx, 'gcx, 'tcx> { + pub fn with_negative( + infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, + allow_negative_impls: bool, + ) -> SelectionContext<'cx, 'gcx, 'tcx> { debug!("with_negative({:?})", allow_negative_impls); SelectionContext { infcx, @@ -474,8 +491,10 @@ } } - pub fn with_query_mode(infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, - query_mode: TraitQueryMode) -> SelectionContext<'cx, 'gcx, 'tcx> { + pub fn with_query_mode( + infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, + query_mode: TraitQueryMode, + ) -> SelectionContext<'cx, 'gcx, 'tcx> { debug!("with_query_mode({:?})", query_mode); SelectionContext { infcx, @@ -522,7 +541,8 @@ /// Wraps the inference context's in_snapshot s.t. snapshot handling is only from the selection /// context's self. fn in_snapshot(&mut self, f: F) -> R - where F: FnOnce(&mut Self, &infer::CombinedSnapshot<'cx, 'tcx>) -> R + where + F: FnOnce(&mut Self, &infer::CombinedSnapshot<'cx, 'tcx>) -> R, { self.infcx.in_snapshot(|snapshot| f(self, snapshot)) } @@ -530,20 +550,21 @@ /// Wraps a probe s.t. obligations collected during it are ignored and old obligations are /// retained. fn probe(&mut self, f: F) -> R - where F: FnOnce(&mut Self, &infer::CombinedSnapshot<'cx, 'tcx>) -> R + where + F: FnOnce(&mut Self, &infer::CombinedSnapshot<'cx, 'tcx>) -> R, { self.infcx.probe(|snapshot| f(self, snapshot)) } /// Wraps a commit_if_ok s.t. obligations collected during it are not returned in selection if /// the transaction fails and s.t. old obligations are retained. - fn commit_if_ok(&mut self, f: F) -> Result where - F: FnOnce(&mut Self, &infer::CombinedSnapshot) -> Result + fn commit_if_ok(&mut self, f: F) -> Result + where + F: FnOnce(&mut Self, &infer::CombinedSnapshot<'cx, 'tcx>) -> Result, { self.infcx.commit_if_ok(|snapshot| f(self, snapshot)) } - /////////////////////////////////////////////////////////////////////////// // Selection // @@ -561,8 +582,10 @@ /// Attempts to satisfy the obligation. If successful, this will affect the surrounding /// type environment by performing unification. - pub fn select(&mut self, obligation: &TraitObligation<'tcx>) - -> SelectionResult<'tcx, Selection<'tcx>> { + pub fn select( + &mut self, + obligation: &TraitObligation<'tcx>, + ) -> SelectionResult<'tcx, Selection<'tcx>> { debug!("select({:?})", obligation); debug_assert!(!obligation.predicate.has_escaping_regions()); @@ -574,19 +597,23 @@ // earlier. assert!(self.query_mode == TraitQueryMode::Canonical); return Err(SelectionError::Overflow); - }, - Err(e) => { return Err(e); }, - Ok(None) => { return Ok(None); }, - Ok(Some(candidate)) => candidate + } + Err(e) => { + return Err(e); + } + Ok(None) => { + return Ok(None); + } + Ok(Some(candidate)) => candidate, }; match self.confirm_candidate(obligation, candidate) { Err(SelectionError::Overflow) => { assert!(self.query_mode == TraitQueryMode::Canonical); - return Err(SelectionError::Overflow); - }, + Err(SelectionError::Overflow) + } Err(e) => Err(e), - Ok(candidate) => Ok(Some(candidate)) + Ok(candidate) => Ok(Some(candidate)), } } @@ -601,12 +628,8 @@ // we can be sure it does not. /// Evaluates whether the obligation `obligation` can be satisfied (by any means). - pub fn predicate_may_hold_fatal(&mut self, - obligation: &PredicateObligation<'tcx>) - -> bool - { - debug!("predicate_may_hold_fatal({:?})", - obligation); + pub fn predicate_may_hold_fatal(&mut self, obligation: &PredicateObligation<'tcx>) -> bool { + debug!("predicate_may_hold_fatal({:?})", obligation); // This fatal query is a stopgap that should only be used in standard mode, // where we do not expect overflow to be propagated. @@ -619,10 +642,10 @@ /// Evaluates whether the obligation `obligation` can be satisfied and returns /// an `EvaluationResult`. - pub fn evaluate_obligation_recursively(&mut self, - obligation: &PredicateObligation<'tcx>) - -> Result - { + pub fn evaluate_obligation_recursively( + &mut self, + obligation: &PredicateObligation<'tcx>, + ) -> Result { self.probe(|this, _| { this.evaluate_predicate_recursively(TraitObligationStackList::empty(), obligation) }) @@ -631,17 +654,22 @@ /// Evaluates the predicates in `predicates` recursively. Note that /// this applies projections in the predicates, and therefore /// is run within an inference probe. - fn evaluate_predicates_recursively<'a,'o,I>(&mut self, - stack: TraitObligationStackList<'o, 'tcx>, - predicates: I) - -> Result - where I : IntoIterator>, 'tcx:'a + fn evaluate_predicates_recursively<'a, 'o, I>( + &mut self, + stack: TraitObligationStackList<'o, 'tcx>, + predicates: I, + ) -> Result + where + I: IntoIterator>, + 'tcx: 'a, { let mut result = EvaluatedToOk; for obligation in predicates { let eval = self.evaluate_predicate_recursively(stack, obligation)?; - debug!("evaluate_predicate_recursively({:?}) = {:?}", - obligation, eval); + debug!( + "evaluate_predicate_recursively({:?}) = {:?}", + obligation, eval + ); if let EvaluatedToErr = eval { // fast-path - EvaluatedToErr is the top of the lattice, // so we don't need to look on the other predicates. @@ -653,13 +681,12 @@ Ok(result) } - fn evaluate_predicate_recursively<'o>(&mut self, - previous_stack: TraitObligationStackList<'o, 'tcx>, - obligation: &PredicateObligation<'tcx>) - -> Result - { - debug!("evaluate_predicate_recursively({:?})", - obligation); + fn evaluate_predicate_recursively<'o>( + &mut self, + previous_stack: TraitObligationStackList<'o, 'tcx>, + obligation: &PredicateObligation<'tcx>, + ) -> Result { + debug!("evaluate_predicate_recursively({:?})", obligation); match obligation.predicate { ty::Predicate::Trait(ref t) => { @@ -670,31 +697,116 @@ ty::Predicate::Subtype(ref p) => { // does this code ever run? - match self.infcx.subtype_predicate(&obligation.cause, obligation.param_env, p) { + match self.infcx + .subtype_predicate(&obligation.cause, obligation.param_env, p) + { Some(Ok(InferOk { obligations, .. })) => { self.evaluate_predicates_recursively(previous_stack, &obligations) - }, + } Some(Err(_)) => Ok(EvaluatedToErr), None => Ok(EvaluatedToAmbig), } } - ty::Predicate::WellFormed(ty) => { - match ty::wf::obligations(self.infcx, - obligation.param_env, - obligation.cause.body_id, - ty, obligation.cause.span) { - Some(obligations) => - self.evaluate_predicates_recursively(previous_stack, obligations.iter()), - None => - Ok(EvaluatedToAmbig), + ty::Predicate::WellFormed(ty) => match ty::wf::obligations( + self.infcx, + obligation.param_env, + obligation.cause.body_id, + ty, + obligation.cause.span, + ) { + Some(obligations) => { + self.evaluate_predicates_recursively(previous_stack, obligations.iter()) + } + None => Ok(EvaluatedToAmbig), + }, + + ty::Predicate::TypeOutlives(ref binder) => { + assert!(!binder.has_escaping_regions()); + // Check if the type has higher-ranked regions. + if binder.skip_binder().0.has_escaping_regions() { + // If so, this obligation is an error (for now). Eventually we should be + // able to support additional cases here, like `for<'a> &'a str: 'a`. + + // NOTE: this hack is implemented in both trait fulfillment and + // evaluation. If you fix it in one place, make sure you fix it + // in the other. + + // We don't want to allow this sort of reasoning in intercrate + // mode, for backwards-compatibility reasons. + if self.intercrate.is_some() { + Ok(EvaluatedToAmbig) + } else { + Ok(EvaluatedToErr) + } + } else { + // If the type has no late bound regions, then if we assign all + // the inference variables in it to be 'static, then the type + // will be 'static itself. + // + // Therefore, `staticize(T): 'a` holds for any `'a`, so this + // obligation is fulfilled. Because evaluation works with + // staticized types (yes I know this is involved with #21974), + // we are 100% OK here. + Ok(EvaluatedToOk) } } - ty::Predicate::TypeOutlives(..) | ty::Predicate::RegionOutlives(..) => { - // we do not consider region relationships when - // evaluating trait matches - Ok(EvaluatedToOk) + ty::Predicate::RegionOutlives(ref binder) => { + let ty::OutlivesPredicate(r_a, r_b) = binder.skip_binder(); + + if r_a == r_b { + // for<'a> 'a: 'a. OK + Ok(EvaluatedToOk) + } else if **r_a == ty::ReStatic { + // 'static: 'x always holds. + // + // This special case is handled somewhat inconsistently - if we + // have an inference variable that is supposed to be equal to + // `'static`, then we don't allow it to be equated to an LBR, + // but if we have a literal `'static`, then we *do*. + // + // This is actually consistent with how our region inference works. + // + // It would appear that this sort of inconsistency would + // cause "instability" problems with evaluation caching. However, + // evaluation caching is only for trait predicates, and when + // trait predicates create nested obligations, they contain + // inference variables for all the regions in the trait - the + // only way this codepath can be reached from trait predicate + // evaluation is when the user typed an explicit `where 'static: 'a` + // lifetime bound (in which case we want to return EvaluatedToOk). + // + // If we ever want to handle inference variables that might be + // equatable with ReStatic, we need to make sure we are not confused by + // technically-allowed-by-RFC-447-but-probably-should-not-be + // impls such as + // ```Rust + // impl<'a, 's, T> X<'s> for T where T: Debug + 'a, 'a: 's + // ``` + Ok(EvaluatedToOk) + } else if r_a.is_late_bound() || r_b.is_late_bound() { + // There is no current way to prove `for<'a> 'a: 'x` + // unless `'a = 'x`, because there are no bounds involving + // lifetimes. + + // It might be possible to prove `for<'a> 'x: 'a` by forcing `'x` + // to be `'static`. However, this is not currently done by type + // inference unless `'x` is literally ReStatic. See the comment + // above. + + // We don't want to allow this sort of reasoning in intercrate + // mode, for backwards-compatibility reasons. + if self.intercrate.is_some() { + Ok(EvaluatedToAmbig) + } else { + Ok(EvaluatedToErr) + } + } else { + // Relating 2 inference variable regions. These will + // always hold if our query is "staticized". + Ok(EvaluatedToOk) + } } ty::Predicate::ObjectSafe(trait_def_id) => { @@ -709,8 +821,10 @@ let project_obligation = obligation.with(data.clone()); match project::poly_project_and_unify_type(self, &project_obligation) { Ok(Some(subobligations)) => { - let result = self.evaluate_predicates_recursively(previous_stack, - subobligations.iter()); + let result = self.evaluate_predicates_recursively( + previous_stack, + subobligations.iter(), + ); if let Some(key) = ProjectionCacheKey::from_poly_projection_predicate(self, data) { @@ -718,12 +832,8 @@ } result } - Ok(None) => { - Ok(EvaluatedToAmbig) - } - Err(_) => { - Ok(EvaluatedToErr) - } + Ok(None) => Ok(EvaluatedToAmbig), + Err(_) => Ok(EvaluatedToErr), } } @@ -736,9 +846,7 @@ Ok(EvaluatedToErr) } } - None => { - Ok(EvaluatedToAmbig) - } + None => Ok(EvaluatedToAmbig), } } @@ -746,20 +854,16 @@ let tcx = self.tcx(); match tcx.lift_to_global(&(obligation.param_env, substs)) { Some((param_env, substs)) => { - let instance = ty::Instance::resolve( - tcx.global_tcx(), - param_env, - def_id, - substs, - ); + let instance = + ty::Instance::resolve(tcx.global_tcx(), param_env, def_id, substs); if let Some(instance) = instance { let cid = GlobalId { instance, - promoted: None + promoted: None, }; match self.tcx().const_eval(param_env.and(cid)) { Ok(_) => Ok(EvaluatedToOk), - Err(_) => Ok(EvaluatedToErr) + Err(_) => Ok(EvaluatedToErr), } } else { Ok(EvaluatedToErr) @@ -774,46 +878,50 @@ } } - fn evaluate_trait_predicate_recursively<'o>(&mut self, - previous_stack: TraitObligationStackList<'o, 'tcx>, - mut obligation: TraitObligation<'tcx>) - -> Result - { + fn evaluate_trait_predicate_recursively<'o>( + &mut self, + previous_stack: TraitObligationStackList<'o, 'tcx>, + mut obligation: TraitObligation<'tcx>, + ) -> Result { debug!("evaluate_trait_predicate_recursively({:?})", obligation); if self.intercrate.is_none() && obligation.is_global() - && obligation.param_env.caller_bounds.iter().all(|bound| bound.needs_subst()) { + && obligation + .param_env + .caller_bounds + .iter() + .all(|bound| bound.needs_subst()) + { // If a param env has no global bounds, global obligations do not // depend on its particular value in order to work, so we can clear // out the param env and get better caching. - debug!("evaluate_trait_predicate_recursively({:?}) - in global", obligation); + debug!( + "evaluate_trait_predicate_recursively({:?}) - in global", + obligation + ); obligation.param_env = obligation.param_env.without_caller_bounds(); } let stack = self.push_stack(previous_stack, &obligation); let fresh_trait_ref = stack.fresh_trait_ref; if let Some(result) = self.check_evaluation_cache(obligation.param_env, fresh_trait_ref) { - debug!("CACHE HIT: EVAL({:?})={:?}", - fresh_trait_ref, - result); + debug!("CACHE HIT: EVAL({:?})={:?}", fresh_trait_ref, result); return Ok(result); } let (result, dep_node) = self.in_task(|this| this.evaluate_stack(&stack)); let result = result?; - debug!("CACHE MISS: EVAL({:?})={:?}", - fresh_trait_ref, - result); + debug!("CACHE MISS: EVAL({:?})={:?}", fresh_trait_ref, result); self.insert_evaluation_cache(obligation.param_env, fresh_trait_ref, dep_node, result); Ok(result) } - fn evaluate_stack<'o>(&mut self, - stack: &TraitObligationStack<'o, 'tcx>) - -> Result - { + fn evaluate_stack<'o>( + &mut self, + stack: &TraitObligationStack<'o, 'tcx>, + ) -> Result { // In intercrate mode, whenever any of the types are unbound, // there can always be an impl. Even if there are no impls in // this crate, perhaps the type would be unified with @@ -838,15 +946,18 @@ // This suffices to allow chains like `FnMut` implemented in // terms of `Fn` etc, but we could probably make this more // precise still. - let unbound_input_types = - stack.fresh_trait_ref.skip_binder().input_types().any(|ty| ty.is_fresh()); + let unbound_input_types = stack + .fresh_trait_ref + .skip_binder() + .input_types() + .any(|ty| ty.is_fresh()); // this check was an imperfect workaround for a bug n the old // intercrate mode, it should be removed when that goes away. - if unbound_input_types && - self.intercrate == Some(IntercrateMode::Issue43355) - { - debug!("evaluate_stack({:?}) --> unbound argument, intercrate --> ambiguous", - stack.fresh_trait_ref); + if unbound_input_types && self.intercrate == Some(IntercrateMode::Issue43355) { + debug!( + "evaluate_stack({:?}) --> unbound argument, intercrate --> ambiguous", + stack.fresh_trait_ref + ); // Heuristics: show the diagnostics when there are no candidates in crate. if self.intercrate_ambiguity_causes.is_some() { debug!("evaluate_stack: intercrate_ambiguity_causes is some"); @@ -863,20 +974,23 @@ }, }; debug!("evaluate_stack: pushing cause = {:?}", cause); - self.intercrate_ambiguity_causes.as_mut().unwrap().push(cause); + self.intercrate_ambiguity_causes + .as_mut() + .unwrap() + .push(cause); } } } return Ok(EvaluatedToAmbig); } - if unbound_input_types && - stack.iter().skip(1).any( - |prev| stack.obligation.param_env == prev.obligation.param_env && - self.match_fresh_trait_refs(&stack.fresh_trait_ref, - &prev.fresh_trait_ref)) - { - debug!("evaluate_stack({:?}) --> unbound argument, recursive --> giving up", - stack.fresh_trait_ref); + if unbound_input_types && stack.iter().skip(1).any(|prev| { + stack.obligation.param_env == prev.obligation.param_env + && self.match_fresh_trait_refs(&stack.fresh_trait_ref, &prev.fresh_trait_ref) + }) { + debug!( + "evaluate_stack({:?}) --> unbound argument, recursive --> giving up", + stack.fresh_trait_ref + ); return Ok(EvaluatedToUnknown); } @@ -886,7 +1000,7 @@ // must be met of course). One obvious case this comes up is // marker traits like `Send`. Think of a linked list: // - // struct List { data: T, next: Option>> { + // struct List { data: T, next: Option>> } // // `Box>` will be `Send` if `T` is `Send` and // `Option>>` is `Send`, and in turn @@ -894,28 +1008,31 @@ // `Send`. // // Note that we do this comparison using the `fresh_trait_ref` - // fields. Because these have all been skolemized using + // fields. Because these have all been freshened using // `self.freshener`, we can be sure that (a) this will not // affect the inferencer state and (b) that if we see two - // skolemized types with the same index, they refer to the - // same unbound type variable. - if let Some(rec_index) = - stack.iter() - .skip(1) // skip top-most frame - .position(|prev| stack.obligation.param_env == prev.obligation.param_env && - stack.fresh_trait_ref == prev.fresh_trait_ref) + // fresh regions with the same index, they refer to the same + // unbound type variable. + if let Some(rec_index) = stack.iter() + .skip(1) // skip top-most frame + .position(|prev| stack.obligation.param_env == prev.obligation.param_env && + stack.fresh_trait_ref == prev.fresh_trait_ref) { - debug!("evaluate_stack({:?}) --> recursive", - stack.fresh_trait_ref); - let cycle = stack.iter().skip(1).take(rec_index+1); + debug!("evaluate_stack({:?}) --> recursive", stack.fresh_trait_ref); + + let cycle = stack.iter().skip(1).take(rec_index + 1); let cycle = cycle.map(|stack| ty::Predicate::Trait(stack.obligation.predicate)); if self.coinductive_match(cycle) { - debug!("evaluate_stack({:?}) --> recursive, coinductive", - stack.fresh_trait_ref); + debug!( + "evaluate_stack({:?}) --> recursive, coinductive", + stack.fresh_trait_ref + ); return Ok(EvaluatedToOk); } else { - debug!("evaluate_stack({:?}) --> recursive, inductive", - stack.fresh_trait_ref); + debug!( + "evaluate_stack({:?}) --> recursive, inductive", + stack.fresh_trait_ref + ); return Ok(EvaluatedToRecur); } } @@ -924,7 +1041,7 @@ Ok(Some(c)) => self.evaluate_candidate(stack, &c), Ok(None) => Ok(EvaluatedToAmbig), Err(Overflow) => Err(OverflowError), - Err(..) => Ok(EvaluatedToErr) + Err(..) => Ok(EvaluatedToErr), } } @@ -937,7 +1054,8 @@ /// - all the predicates at positions `X..` between `X` an the top are /// also defaulted traits. pub fn coinductive_match(&mut self, cycle: I) -> bool - where I: Iterator> + where + I: Iterator>, { let mut cycle = cycle; cycle.all(|predicate| self.coinductive_predicate(predicate)) @@ -945,12 +1063,8 @@ fn coinductive_predicate(&self, predicate: ty::Predicate<'tcx>) -> bool { let result = match predicate { - ty::Predicate::Trait(ref data) => { - self.tcx().trait_is_auto(data.def_id()) - } - _ => { - false - } + ty::Predicate::Trait(ref data) => self.tcx().trait_is_auto(data.def_id()), + _ => false, }; debug!("coinductive_predicate({:?}) = {:?}", predicate, result); result @@ -959,34 +1073,37 @@ /// Further evaluate `candidate` to decide whether all type parameters match and whether nested /// obligations are met. Returns true if `candidate` remains viable after this further /// scrutiny. - fn evaluate_candidate<'o>(&mut self, - stack: &TraitObligationStack<'o, 'tcx>, - candidate: &SelectionCandidate<'tcx>) - -> Result - { - debug!("evaluate_candidate: depth={} candidate={:?}", - stack.obligation.recursion_depth, candidate); + fn evaluate_candidate<'o>( + &mut self, + stack: &TraitObligationStack<'o, 'tcx>, + candidate: &SelectionCandidate<'tcx>, + ) -> Result { + debug!( + "evaluate_candidate: depth={} candidate={:?}", + stack.obligation.recursion_depth, candidate + ); let result = self.probe(|this, _| { let candidate = (*candidate).clone(); match this.confirm_candidate(stack.obligation, candidate) { - Ok(selection) => { - this.evaluate_predicates_recursively( - stack.list(), - selection.nested_obligations().iter()) - } - Err(..) => Ok(EvaluatedToErr) + Ok(selection) => this.evaluate_predicates_recursively( + stack.list(), + selection.nested_obligations().iter(), + ), + Err(..) => Ok(EvaluatedToErr), } })?; - debug!("evaluate_candidate: depth={} result={:?}", - stack.obligation.recursion_depth, result); + debug!( + "evaluate_candidate: depth={} result={:?}", + stack.obligation.recursion_depth, result + ); Ok(result) } - fn check_evaluation_cache(&self, - param_env: ty::ParamEnv<'tcx>, - trait_ref: ty::PolyTraitRef<'tcx>) - -> Option - { + fn check_evaluation_cache( + &self, + param_env: ty::ParamEnv<'tcx>, + trait_ref: ty::PolyTraitRef<'tcx>, + ) -> Option { let tcx = self.tcx(); if self.can_use_global_caches(param_env) { let cache = tcx.evaluation_cache.hashmap.borrow(); @@ -994,18 +1111,21 @@ return Some(cached.get(tcx)); } } - self.infcx.evaluation_cache.hashmap - .borrow() - .get(&trait_ref) - .map(|v| v.get(tcx)) + self.infcx + .evaluation_cache + .hashmap + .borrow() + .get(&trait_ref) + .map(|v| v.get(tcx)) } - fn insert_evaluation_cache(&mut self, - param_env: ty::ParamEnv<'tcx>, - trait_ref: ty::PolyTraitRef<'tcx>, - dep_node: DepNodeIndex, - result: EvaluationResult) - { + fn insert_evaluation_cache( + &mut self, + param_env: ty::ParamEnv<'tcx>, + trait_ref: ty::PolyTraitRef<'tcx>, + dep_node: DepNodeIndex, + result: EvaluationResult, + ) { // Avoid caching results that depend on more than just the trait-ref // - the stack can create recursion. if result.is_stack_dependent() { @@ -1016,28 +1136,30 @@ if let Some(trait_ref) = self.tcx().lift_to_global(&trait_ref) { debug!( "insert_evaluation_cache(trait_ref={:?}, candidate={:?}) global", - trait_ref, - result, + trait_ref, result, ); // This may overwrite the cache with the same value // FIXME: Due to #50507 this overwrites the different values // This should be changed to use HashMapExt::insert_same // when that is fixed - self.tcx().evaluation_cache - .hashmap.borrow_mut() - .insert(trait_ref, WithDepNode::new(dep_node, result)); + self.tcx() + .evaluation_cache + .hashmap + .borrow_mut() + .insert(trait_ref, WithDepNode::new(dep_node, result)); return; } } debug!( "insert_evaluation_cache(trait_ref={:?}, candidate={:?})", - trait_ref, - result, + trait_ref, result, ); - self.infcx.evaluation_cache.hashmap - .borrow_mut() - .insert(trait_ref, WithDepNode::new(dep_node, result)); + self.infcx + .evaluation_cache + .hashmap + .borrow_mut() + .insert(trait_ref, WithDepNode::new(dep_node, result)); } /////////////////////////////////////////////////////////////////////////// @@ -1050,10 +1172,10 @@ // [rustc guide]: // https://rust-lang-nursery.github.io/rustc-guide/traits/resolution.html#candidate-assembly - fn candidate_from_obligation<'o>(&mut self, - stack: &TraitObligationStack<'o, 'tcx>) - -> SelectionResult<'tcx, SelectionCandidate<'tcx>> - { + fn candidate_from_obligation<'o>( + &mut self, + stack: &TraitObligationStack<'o, 'tcx>, + ) -> SelectionResult<'tcx, SelectionCandidate<'tcx>> { // Watch out for overflow. This intentionally bypasses (and does // not update) the cache. let recursion_limit = *self.infcx.tcx.sess.recursion_limit.get(); @@ -1061,72 +1183,78 @@ match self.query_mode { TraitQueryMode::Standard => { self.infcx().report_overflow_error(&stack.obligation, true); - }, + } TraitQueryMode::Canonical => { return Err(Overflow); - }, + } } } - // Check the cache. Note that we skolemize the trait-ref - // separately rather than using `stack.fresh_trait_ref` -- this - // is because we want the unbound variables to be replaced - // with fresh skolemized types starting from index 0. - let cache_fresh_trait_pred = - self.infcx.freshen(stack.obligation.predicate.clone()); - debug!("candidate_from_obligation(cache_fresh_trait_pred={:?}, obligation={:?})", - cache_fresh_trait_pred, - stack); + // Check the cache. Note that we freshen the trait-ref + // separately rather than using `stack.fresh_trait_ref` -- + // this is because we want the unbound variables to be + // replaced with fresh types starting from index 0. + let cache_fresh_trait_pred = self.infcx.freshen(stack.obligation.predicate.clone()); + debug!( + "candidate_from_obligation(cache_fresh_trait_pred={:?}, obligation={:?})", + cache_fresh_trait_pred, stack + ); debug_assert!(!stack.obligation.predicate.has_escaping_regions()); - if let Some(c) = self.check_candidate_cache(stack.obligation.param_env, - &cache_fresh_trait_pred) { - debug!("CACHE HIT: SELECT({:?})={:?}", - cache_fresh_trait_pred, - c); + if let Some(c) = + self.check_candidate_cache(stack.obligation.param_env, &cache_fresh_trait_pred) + { + debug!("CACHE HIT: SELECT({:?})={:?}", cache_fresh_trait_pred, c); return c; } // If no match, compute result and insert into cache. - let (candidate, dep_node) = self.in_task(|this| { - this.candidate_from_obligation_no_cache(stack) - }); + let (candidate, dep_node) = + self.in_task(|this| this.candidate_from_obligation_no_cache(stack)); - debug!("CACHE MISS: SELECT({:?})={:?}", - cache_fresh_trait_pred, candidate); - self.insert_candidate_cache(stack.obligation.param_env, - cache_fresh_trait_pred, - dep_node, - candidate.clone()); + debug!( + "CACHE MISS: SELECT({:?})={:?}", + cache_fresh_trait_pred, candidate + ); + self.insert_candidate_cache( + stack.obligation.param_env, + cache_fresh_trait_pred, + dep_node, + candidate.clone(), + ); candidate } fn in_task(&mut self, op: OP) -> (R, DepNodeIndex) - where OP: FnOnce(&mut Self) -> R + where + OP: FnOnce(&mut Self) -> R, { - let (result, dep_node) = self.tcx().dep_graph.with_anon_task(DepKind::TraitSelect, || { - op(self) - }); + let (result, dep_node) = self.tcx() + .dep_graph + .with_anon_task(DepKind::TraitSelect, || op(self)); self.tcx().dep_graph.read_index(dep_node); (result, dep_node) } // Treat negative impls as unimplemented - fn filter_negative_impls(&self, candidate: SelectionCandidate<'tcx>) - -> SelectionResult<'tcx, SelectionCandidate<'tcx>> { + fn filter_negative_impls( + &self, + candidate: SelectionCandidate<'tcx>, + ) -> SelectionResult<'tcx, SelectionCandidate<'tcx>> { if let ImplCandidate(def_id) = candidate { - if !self.allow_negative_impls && - self.tcx().impl_polarity(def_id) == hir::ImplPolarity::Negative { - return Err(Unimplemented) + if !self.allow_negative_impls + && self.tcx().impl_polarity(def_id) == hir::ImplPolarity::Negative + { + return Err(Unimplemented); } } Ok(Some(candidate)) } - fn candidate_from_obligation_no_cache<'o>(&mut self, - stack: &TraitObligationStack<'o, 'tcx>) - -> SelectionResult<'tcx, SelectionCandidate<'tcx>> - { + fn candidate_from_obligation_no_cache<'o>( + &mut self, + stack: &TraitObligationStack<'o, 'tcx>, + ) -> SelectionResult<'tcx, SelectionCandidate<'tcx>> { if stack.obligation.predicate.references_error() { // If we encounter a `Error`, we generally prefer the // most "optimistic" result in response -- that is, the @@ -1138,46 +1266,61 @@ return Ok(None); } - match self.is_knowable(stack) { - None => {} - Some(conflict) => { - debug!("coherence stage: not knowable"); - if self.intercrate_ambiguity_causes.is_some() { - debug!("evaluate_stack: intercrate_ambiguity_causes is some"); - // Heuristics: show the diagnostics when there are no candidates in crate. - if let Ok(candidate_set) = self.assemble_candidates(stack) { - let no_candidates_apply = - candidate_set + if let Some(conflict) = self.is_knowable(stack) { + debug!("coherence stage: not knowable"); + if self.intercrate_ambiguity_causes.is_some() { + debug!("evaluate_stack: intercrate_ambiguity_causes is some"); + // Heuristics: show the diagnostics when there are no candidates in crate. + if let Ok(candidate_set) = self.assemble_candidates(stack) { + let mut no_candidates_apply = true; + { + let evaluated_candidates = candidate_set .vec .iter() - .map(|c| self.evaluate_candidate(stack, &c)) - .collect::, OverflowError>>()? - .iter() - .all(|r| !r.may_apply()); - if !candidate_set.ambiguous && no_candidates_apply { - let trait_ref = stack.obligation.predicate.skip_binder().trait_ref; - let self_ty = trait_ref.self_ty(); - let trait_desc = trait_ref.to_string(); - let self_desc = if self_ty.has_concrete_skeleton() { - Some(self_ty.to_string()) - } else { - None - }; - let cause = if let Conflict::Upstream = conflict { - IntercrateAmbiguityCause::UpstreamCrateUpdate { - trait_desc, - self_desc, + .map(|c| self.evaluate_candidate(stack, &c)); + + for ec in evaluated_candidates { + match ec { + Ok(c) => { + if c.may_apply() { + no_candidates_apply = false; + break; + } } - } else { - IntercrateAmbiguityCause::DownstreamCrate { trait_desc, self_desc } - }; - debug!("evaluate_stack: pushing cause = {:?}", cause); - self.intercrate_ambiguity_causes.as_mut().unwrap().push(cause); + Err(e) => return Err(e.into()), + } } } + + if !candidate_set.ambiguous && no_candidates_apply { + let trait_ref = stack.obligation.predicate.skip_binder().trait_ref; + let self_ty = trait_ref.self_ty(); + let trait_desc = trait_ref.to_string(); + let self_desc = if self_ty.has_concrete_skeleton() { + Some(self_ty.to_string()) + } else { + None + }; + let cause = if let Conflict::Upstream = conflict { + IntercrateAmbiguityCause::UpstreamCrateUpdate { + trait_desc, + self_desc, + } + } else { + IntercrateAmbiguityCause::DownstreamCrate { + trait_desc, + self_desc, + } + }; + debug!("evaluate_stack: pushing cause = {:?}", cause); + self.intercrate_ambiguity_causes + .as_mut() + .unwrap() + .push(cause); + } } - return Ok(None); } + return Ok(None); } let candidate_set = self.assemble_candidates(stack)?; @@ -1189,10 +1332,12 @@ let mut candidates = candidate_set.vec; - debug!("assembled {} candidates for {:?}: {:?}", - candidates.len(), - stack, - candidates); + debug!( + "assembled {} candidates for {:?}: {:?}", + candidates.len(), + stack, + candidates + ); // At this point, we know that each of the entries in the // candidate set is *individually* applicable. Now we have to @@ -1223,8 +1368,7 @@ // Winnow, but record the exact outcome of evaluation, which // is needed for specialization. Propagate overflow if it occurs. - let candidates: Result>, _> = candidates - .into_iter() + let mut candidates = candidates.into_iter() .map(|c| match self.evaluate_candidate(stack, &c) { Ok(eval) if eval.may_apply() => Ok(Some(EvaluatedCandidate { candidate: c, @@ -1233,34 +1377,40 @@ Ok(_) => Ok(None), Err(OverflowError) => Err(Overflow), }) - .collect(); + .flat_map(Result::transpose) + .collect::, _>>()?; - let mut candidates: Vec = - candidates?.into_iter().filter_map(|c| c).collect(); - - debug!("winnowed to {} candidates for {:?}: {:?}", - candidates.len(), - stack, - candidates); + debug!( + "winnowed to {} candidates for {:?}: {:?}", + candidates.len(), + stack, + candidates + ); - // If there are STILL multiple candidate, we can further + // If there are STILL multiple candidates, we can further // reduce the list by dropping duplicates -- including // resolving specializations. if candidates.len() > 1 { let mut i = 0; while i < candidates.len() { - let is_dup = - (0..candidates.len()) - .filter(|&j| i != j) - .any(|j| self.candidate_should_be_dropped_in_favor_of(&candidates[i], - &candidates[j])); + let is_dup = (0..candidates.len()).filter(|&j| i != j).any(|j| { + self.candidate_should_be_dropped_in_favor_of(&candidates[i], &candidates[j]) + }); if is_dup { - debug!("Dropping candidate #{}/{}: {:?}", - i, candidates.len(), candidates[i]); + debug!( + "Dropping candidate #{}/{}: {:?}", + i, + candidates.len(), + candidates[i] + ); candidates.swap_remove(i); } else { - debug!("Retaining candidate #{}/{}: {:?}", - i, candidates.len(), candidates[i]); + debug!( + "Retaining candidate #{}/{}: {:?}", + i, + candidates.len(), + candidates[i] + ); i += 1; // If there are *STILL* multiple candidates, give up @@ -1290,10 +1440,7 @@ self.filter_negative_impls(candidates.pop().unwrap().candidate) } - fn is_knowable<'o>(&mut self, - stack: &TraitObligationStack<'o, 'tcx>) - -> Option - { + fn is_knowable<'o>(&mut self, stack: &TraitObligationStack<'o, 'tcx>) -> Option { debug!("is_knowable(intercrate={:?})", self.intercrate); if !self.intercrate.is_some() { @@ -1301,7 +1448,8 @@ } let obligation = &stack.obligation; - let predicate = self.infcx().resolve_type_vars_if_possible(&obligation.predicate); + let predicate = self.infcx() + .resolve_type_vars_if_possible(&obligation.predicate); // ok to skip binder because of the nature of the // trait-ref-is-knowable check, which does not care about @@ -1309,8 +1457,13 @@ let trait_ref = predicate.skip_binder().trait_ref; let result = coherence::trait_ref_is_knowable(self.tcx(), trait_ref); - if let (Some(Conflict::Downstream { used_to_be_broken: true }), - Some(IntercrateMode::Issue43355)) = (result, self.intercrate) { + if let ( + Some(Conflict::Downstream { + used_to_be_broken: true, + }), + Some(IntercrateMode::Issue43355), + ) = (result, self.intercrate) + { debug!("is_knowable: IGNORING conflict to be bug-compatible with #43355"); None } else { @@ -1348,11 +1501,11 @@ true } - fn check_candidate_cache(&mut self, - param_env: ty::ParamEnv<'tcx>, - cache_fresh_trait_pred: &ty::PolyTraitPredicate<'tcx>) - -> Option>> - { + fn check_candidate_cache( + &mut self, + param_env: ty::ParamEnv<'tcx>, + cache_fresh_trait_pred: &ty::PolyTraitPredicate<'tcx>, + ) -> Option>> { let tcx = self.tcx(); let trait_ref = &cache_fresh_trait_pred.skip_binder().trait_ref; if self.can_use_global_caches(param_env) { @@ -1361,32 +1514,73 @@ return Some(cached.get(tcx)); } } - self.infcx.selection_cache.hashmap - .borrow() - .get(trait_ref) - .map(|v| v.get(tcx)) + self.infcx + .selection_cache + .hashmap + .borrow() + .get(trait_ref) + .map(|v| v.get(tcx)) + } + + /// Determines whether can we safely cache the result + /// of selecting an obligation. This is almost always 'true', + /// except when dealing with certain ParamCandidates. + /// + /// Ordinarily, a ParamCandidate will contain no inference variables, + /// since it was usually produced directly from a DefId. However, + /// certain cases (currently only librustdoc's blanket impl finder), + /// a ParamEnv may be explicitly constructed with inference types. + /// When this is the case, we do *not* want to cache the resulting selection + /// candidate. This is due to the fact that it might not always be possible + /// to equate the obligation's trait ref and the candidate's trait ref, + /// if more constraints end up getting added to an inference variable. + /// + /// Because of this, we always want to re-run the full selection + /// process for our obligation the next time we see it, since + /// we might end up picking a different SelectionCandidate (or none at all) + fn can_cache_candidate(&self, + result: &SelectionResult<'tcx, SelectionCandidate<'tcx>> + ) -> bool { + match result { + Ok(Some(SelectionCandidate::ParamCandidate(trait_ref))) => { + !trait_ref.skip_binder().input_types().any(|t| t.walk().any(|t_| t_.is_ty_infer())) + }, + _ => true + } } - fn insert_candidate_cache(&mut self, - param_env: ty::ParamEnv<'tcx>, - cache_fresh_trait_pred: ty::PolyTraitPredicate<'tcx>, - dep_node: DepNodeIndex, - candidate: SelectionResult<'tcx, SelectionCandidate<'tcx>>) - { + fn insert_candidate_cache( + &mut self, + param_env: ty::ParamEnv<'tcx>, + cache_fresh_trait_pred: ty::PolyTraitPredicate<'tcx>, + dep_node: DepNodeIndex, + candidate: SelectionResult<'tcx, SelectionCandidate<'tcx>>, + ) { let tcx = self.tcx(); let trait_ref = cache_fresh_trait_pred.skip_binder().trait_ref; + + if !self.can_cache_candidate(&candidate) { + debug!("insert_candidate_cache(trait_ref={:?}, candidate={:?} -\ + candidate is not cacheable", trait_ref, candidate); + return; + + } + if self.can_use_global_caches(param_env) { - if let Some(trait_ref) = tcx.lift_to_global(&trait_ref) { + if let Err(Overflow) = candidate { + // Don't cache overflow globally; we only produce this + // in certain modes. + } else if let Some(trait_ref) = tcx.lift_to_global(&trait_ref) { if let Some(candidate) = tcx.lift_to_global(&candidate) { debug!( "insert_candidate_cache(trait_ref={:?}, candidate={:?}) global", - trait_ref, - candidate, + trait_ref, candidate, ); // This may overwrite the cache with the same value tcx.selection_cache - .hashmap.borrow_mut() - .insert(trait_ref, WithDepNode::new(dep_node, candidate)); + .hashmap + .borrow_mut() + .insert(trait_ref, WithDepNode::new(dep_node, candidate)); return; } } @@ -1394,24 +1588,26 @@ debug!( "insert_candidate_cache(trait_ref={:?}, candidate={:?}) local", - trait_ref, - candidate, + trait_ref, candidate, ); - self.infcx.selection_cache.hashmap - .borrow_mut() - .insert(trait_ref, WithDepNode::new(dep_node, candidate)); + self.infcx + .selection_cache + .hashmap + .borrow_mut() + .insert(trait_ref, WithDepNode::new(dep_node, candidate)); } - fn assemble_candidates<'o>(&mut self, - stack: &TraitObligationStack<'o, 'tcx>) - -> Result, SelectionError<'tcx>> - { + fn assemble_candidates<'o>( + &mut self, + stack: &TraitObligationStack<'o, 'tcx>, + ) -> Result, SelectionError<'tcx>> { let TraitObligationStack { obligation, .. } = *stack; let ref obligation = Obligation { param_env: obligation.param_env, cause: obligation.cause.clone(), recursion_depth: obligation.recursion_depth, - predicate: self.infcx().resolve_type_vars_if_possible(&obligation.predicate) + predicate: self.infcx() + .resolve_type_vars_if_possible(&obligation.predicate), }; if obligation.predicate.skip_binder().self_ty().is_ty_var() { @@ -1424,22 +1620,27 @@ // Take the fast path out - this also improves // performance by preventing assemble_candidates_from_impls from // matching every impl for this trait. - return Ok(SelectionCandidateSet { vec: vec![], ambiguous: true }); + return Ok(SelectionCandidateSet { + vec: vec![], + ambiguous: true, + }); } let mut candidates = SelectionCandidateSet { vec: Vec::new(), - ambiguous: false + ambiguous: false, }; // Other bounds. Consider both in-scope bounds from fn decl // and applicable impls. There is a certain set of precedence rules here. - let def_id = obligation.predicate.def_id(); let lang_items = self.tcx().lang_items(); + if lang_items.copy_trait() == Some(def_id) { - debug!("obligation self ty is {:?}", - obligation.predicate.skip_binder().self_ty()); + debug!( + "obligation self ty is {:?}", + obligation.predicate.skip_binder().self_ty() + ); // User-defined copy impls are permitted, but only for // structs and enums. @@ -1452,8 +1653,7 @@ // Sized is never implementable by end-users, it is // always automatically computed. let sized_conditions = self.sized_conditions(obligation); - self.assemble_builtin_bound_candidates(sized_conditions, - &mut candidates)?; + self.assemble_builtin_bound_candidates(sized_conditions, &mut candidates)?; } else if lang_items.unsize_trait() == Some(def_id) { self.assemble_candidates_for_unsizing(obligation, &mut candidates); } else { @@ -1483,26 +1683,28 @@ Ok(candidates) } - fn assemble_candidates_from_projected_tys(&mut self, - obligation: &TraitObligation<'tcx>, - candidates: &mut SelectionCandidateSet<'tcx>) - { + fn assemble_candidates_from_projected_tys( + &mut self, + obligation: &TraitObligation<'tcx>, + candidates: &mut SelectionCandidateSet<'tcx>, + ) { debug!("assemble_candidates_for_projected_tys({:?})", obligation); - // before we go into the whole skolemization thing, just + // before we go into the whole placeholder thing, just // quickly check if the self-type is a projection at all. match obligation.predicate.skip_binder().trait_ref.self_ty().sty { ty::Projection(_) | ty::Opaque(..) => {} ty::Infer(ty::TyVar(_)) => { - span_bug!(obligation.cause.span, - "Self=_ should have been handled by assemble_candidates"); + span_bug!( + obligation.cause.span, + "Self=_ should have been handled by assemble_candidates" + ); } - _ => return + _ => return, } let result = self.probe(|this, snapshot| { - this.match_projection_obligation_against_definition_bounds(obligation, - snapshot) + this.match_projection_obligation_against_definition_bounds(obligation, snapshot) }); if result { @@ -1513,65 +1715,76 @@ fn match_projection_obligation_against_definition_bounds( &mut self, obligation: &TraitObligation<'tcx>, - snapshot: &infer::CombinedSnapshot<'cx, 'tcx>) - -> bool - { - let poly_trait_predicate = - self.infcx().resolve_type_vars_if_possible(&obligation.predicate); - let (skol_trait_predicate, skol_map) = - self.infcx().skolemize_late_bound_regions(&poly_trait_predicate); - debug!("match_projection_obligation_against_definition_bounds: \ - skol_trait_predicate={:?} skol_map={:?}", - skol_trait_predicate, - skol_map); + snapshot: &infer::CombinedSnapshot<'cx, 'tcx>, + ) -> bool { + let poly_trait_predicate = self.infcx() + .resolve_type_vars_if_possible(&obligation.predicate); + let (skol_trait_predicate, placeholder_map) = self.infcx() + .replace_late_bound_regions_with_placeholders(&poly_trait_predicate); + debug!( + "match_projection_obligation_against_definition_bounds: \ + skol_trait_predicate={:?} placeholder_map={:?}", + skol_trait_predicate, placeholder_map + ); let (def_id, substs) = match skol_trait_predicate.trait_ref.self_ty().sty { - ty::Projection(ref data) => - (data.trait_ref(self.tcx()).def_id, data.substs), + ty::Projection(ref data) => (data.trait_ref(self.tcx()).def_id, data.substs), ty::Opaque(def_id, substs) => (def_id, substs), _ => { span_bug!( obligation.cause.span, "match_projection_obligation_against_definition_bounds() called \ - but self-ty not a projection: {:?}", - skol_trait_predicate.trait_ref.self_ty()); + but self-ty is not a projection: {:?}", + skol_trait_predicate.trait_ref.self_ty() + ); } }; - debug!("match_projection_obligation_against_definition_bounds: \ - def_id={:?}, substs={:?}", - def_id, substs); + debug!( + "match_projection_obligation_against_definition_bounds: \ + def_id={:?}, substs={:?}", + def_id, substs + ); let predicates_of = self.tcx().predicates_of(def_id); let bounds = predicates_of.instantiate(self.tcx(), substs); - debug!("match_projection_obligation_against_definition_bounds: \ - bounds={:?}", - bounds); + debug!( + "match_projection_obligation_against_definition_bounds: \ + bounds={:?}", + bounds + ); - let matching_bound = - util::elaborate_predicates(self.tcx(), bounds.predicates) + let matching_bound = util::elaborate_predicates(self.tcx(), bounds.predicates) .filter_to_traits() - .find( - |bound| self.probe( - |this, _| this.match_projection(obligation, - bound.clone(), - skol_trait_predicate.trait_ref.clone(), - &skol_map, - snapshot))); - - debug!("match_projection_obligation_against_definition_bounds: \ - matching_bound={:?}", - matching_bound); + .find(|bound| { + self.probe(|this, _| { + this.match_projection( + obligation, + bound.clone(), + skol_trait_predicate.trait_ref.clone(), + &placeholder_map, + snapshot, + ) + }) + }); + + debug!( + "match_projection_obligation_against_definition_bounds: \ + matching_bound={:?}", + matching_bound + ); match matching_bound { None => false, Some(bound) => { // Repeat the successful match, if any, this time outside of a probe. - let result = self.match_projection(obligation, - bound, - skol_trait_predicate.trait_ref.clone(), - &skol_map, - snapshot); + let result = self.match_projection( + obligation, + bound, + skol_trait_predicate.trait_ref.clone(), + &placeholder_map, + snapshot, + ); - self.infcx.pop_skolemized(skol_map, snapshot); + self.infcx.pop_placeholders(placeholder_map, snapshot); assert!(result); true @@ -1579,39 +1792,48 @@ } } - fn match_projection(&mut self, - obligation: &TraitObligation<'tcx>, - trait_bound: ty::PolyTraitRef<'tcx>, - skol_trait_ref: ty::TraitRef<'tcx>, - skol_map: &infer::SkolemizationMap<'tcx>, - snapshot: &infer::CombinedSnapshot<'cx, 'tcx>) - -> bool - { + fn match_projection( + &mut self, + obligation: &TraitObligation<'tcx>, + trait_bound: ty::PolyTraitRef<'tcx>, + skol_trait_ref: ty::TraitRef<'tcx>, + placeholder_map: &infer::PlaceholderMap<'tcx>, + snapshot: &infer::CombinedSnapshot<'cx, 'tcx>, + ) -> bool { debug_assert!(!skol_trait_ref.has_escaping_regions()); - if self.infcx.at(&obligation.cause, obligation.param_env) - .sup(ty::Binder::dummy(skol_trait_ref), trait_bound).is_err() { + if self.infcx + .at(&obligation.cause, obligation.param_env) + .sup(ty::Binder::dummy(skol_trait_ref), trait_bound) + .is_err() + { return false; } - self.infcx.leak_check(false, obligation.cause.span, skol_map, snapshot).is_ok() + self.infcx + .leak_check(false, obligation.cause.span, placeholder_map, snapshot) + .is_ok() } /// Given an obligation like ``, search the obligations that the caller /// supplied to find out whether it is listed among them. /// /// Never affects inference environment. - fn assemble_candidates_from_caller_bounds<'o>(&mut self, - stack: &TraitObligationStack<'o, 'tcx>, - candidates: &mut SelectionCandidateSet<'tcx>) - -> Result<(),SelectionError<'tcx>> - { - debug!("assemble_candidates_from_caller_bounds({:?})", - stack.obligation); + fn assemble_candidates_from_caller_bounds<'o>( + &mut self, + stack: &TraitObligationStack<'o, 'tcx>, + candidates: &mut SelectionCandidateSet<'tcx>, + ) -> Result<(), SelectionError<'tcx>> { + debug!( + "assemble_candidates_from_caller_bounds({:?})", + stack.obligation + ); - let all_bounds = - stack.obligation.param_env.caller_bounds - .iter() - .filter_map(|o| o.to_opt_poly_trait_ref()); + let all_bounds = stack + .obligation + .param_env + .caller_bounds + .iter() + .filter_map(|o| o.to_opt_poly_trait_ref()); // micro-optimization: filter out predicates relating to different // traits. @@ -1632,26 +1854,26 @@ Ok(()) } - fn evaluate_where_clause<'o>(&mut self, - stack: &TraitObligationStack<'o, 'tcx>, - where_clause_trait_ref: ty::PolyTraitRef<'tcx>) - -> Result - { + fn evaluate_where_clause<'o>( + &mut self, + stack: &TraitObligationStack<'o, 'tcx>, + where_clause_trait_ref: ty::PolyTraitRef<'tcx>, + ) -> Result { self.probe(move |this, _| { match this.match_where_clause_trait_ref(stack.obligation, where_clause_trait_ref) { Ok(obligations) => { this.evaluate_predicates_recursively(stack.list(), obligations.iter()) } - Err(()) => Ok(EvaluatedToErr) + Err(()) => Ok(EvaluatedToErr), } }) } - fn assemble_generator_candidates(&mut self, - obligation: &TraitObligation<'tcx>, - candidates: &mut SelectionCandidateSet<'tcx>) - -> Result<(),SelectionError<'tcx>> - { + fn assemble_generator_candidates( + &mut self, + obligation: &TraitObligation<'tcx>, + candidates: &mut SelectionCandidateSet<'tcx>, + ) -> Result<(), SelectionError<'tcx>> { if self.tcx().lang_items().gen_trait() != Some(obligation.predicate.def_id()) { return Ok(()); } @@ -1662,20 +1884,21 @@ let self_ty = *obligation.self_ty().skip_binder(); match self_ty.sty { ty::Generator(..) => { - debug!("assemble_generator_candidates: self_ty={:?} obligation={:?}", - self_ty, - obligation); + debug!( + "assemble_generator_candidates: self_ty={:?} obligation={:?}", + self_ty, obligation + ); candidates.vec.push(GeneratorCandidate); - Ok(()) } ty::Infer(ty::TyVar(_)) => { debug!("assemble_generator_candidates: ambiguous self-type"); candidates.ambiguous = true; - return Ok(()); } - _ => { return Ok(()); } + _ => {} } + + Ok(()) } /// Check for the artificial impl that the compiler will create for an obligation like `X : @@ -1684,14 +1907,19 @@ /// Note: the type parameters on a closure candidate are modeled as *output* type /// parameters and hence do not affect whether this trait is a match or not. They will be /// unified during the confirmation step. - fn assemble_closure_candidates(&mut self, - obligation: &TraitObligation<'tcx>, - candidates: &mut SelectionCandidateSet<'tcx>) - -> Result<(),SelectionError<'tcx>> - { - let kind = match self.tcx().lang_items().fn_trait_kind(obligation.predicate.def_id()) { + fn assemble_closure_candidates( + &mut self, + obligation: &TraitObligation<'tcx>, + candidates: &mut SelectionCandidateSet<'tcx>, + ) -> Result<(), SelectionError<'tcx>> { + let kind = match self.tcx() + .lang_items() + .fn_trait_kind(obligation.predicate.def_id()) + { Some(k) => k, - None => { return Ok(()); } + None => { + return Ok(()); + } }; // ok to skip binder because the substs on closure types never @@ -1699,11 +1927,16 @@ // type/region parameters match obligation.self_ty().skip_binder().sty { ty::Closure(closure_def_id, closure_substs) => { - debug!("assemble_unboxed_candidates: kind={:?} obligation={:?}", - kind, obligation); + debug!( + "assemble_unboxed_candidates: kind={:?} obligation={:?}", + kind, obligation + ); match self.infcx.closure_kind(closure_def_id, closure_substs) { Some(closure_kind) => { - debug!("assemble_unboxed_candidates: closure_kind = {:?}", closure_kind); + debug!( + "assemble_unboxed_candidates: closure_kind = {:?}", + closure_kind + ); if closure_kind.extends(kind) { candidates.vec.push(ClosureCandidate); } @@ -1712,26 +1945,30 @@ debug!("assemble_unboxed_candidates: closure_kind not yet known"); candidates.vec.push(ClosureCandidate); } - }; - Ok(()) + } } ty::Infer(ty::TyVar(_)) => { debug!("assemble_unboxed_closure_candidates: ambiguous self-type"); candidates.ambiguous = true; - return Ok(()); } - _ => { return Ok(()); } + _ => {} } + + Ok(()) } /// Implement one of the `Fn()` family for a fn pointer. - fn assemble_fn_pointer_candidates(&mut self, - obligation: &TraitObligation<'tcx>, - candidates: &mut SelectionCandidateSet<'tcx>) - -> Result<(),SelectionError<'tcx>> - { + fn assemble_fn_pointer_candidates( + &mut self, + obligation: &TraitObligation<'tcx>, + candidates: &mut SelectionCandidateSet<'tcx>, + ) -> Result<(), SelectionError<'tcx>> { // We provide impl of all fn traits for fn pointers. - if self.tcx().lang_items().fn_trait_kind(obligation.predicate.def_id()).is_none() { + if self.tcx() + .lang_items() + .fn_trait_kind(obligation.predicate.def_id()) + .is_none() + { return Ok(()); } @@ -1742,7 +1979,6 @@ debug!("assemble_fn_pointer_candidates: ambiguous self-type"); candidates.ambiguous = true; // could wind up being a fn() type } - // provide an impl, but only for suitable `fn` pointers ty::FnDef(..) | ty::FnPtr(_) => { if let ty::FnSig { @@ -1750,52 +1986,53 @@ abi: Abi::Rust, variadic: false, .. - } = self_ty.fn_sig(self.tcx()).skip_binder() { + } = self_ty.fn_sig(self.tcx()).skip_binder() + { candidates.vec.push(FnPointerCandidate); } } - - _ => { } + _ => {} } Ok(()) } /// Search for impls that might apply to `obligation`. - fn assemble_candidates_from_impls(&mut self, - obligation: &TraitObligation<'tcx>, - candidates: &mut SelectionCandidateSet<'tcx>) - -> Result<(), SelectionError<'tcx>> - { - debug!("assemble_candidates_from_impls(obligation={:?})", obligation); + fn assemble_candidates_from_impls( + &mut self, + obligation: &TraitObligation<'tcx>, + candidates: &mut SelectionCandidateSet<'tcx>, + ) -> Result<(), SelectionError<'tcx>> { + debug!( + "assemble_candidates_from_impls(obligation={:?})", + obligation + ); self.tcx().for_each_relevant_impl( obligation.predicate.def_id(), obligation.predicate.skip_binder().trait_ref.self_ty(), |impl_def_id| { - self.probe(|this, snapshot| { /* [1] */ - match this.match_impl(impl_def_id, obligation, snapshot) { - Ok(skol_map) => { - candidates.vec.push(ImplCandidate(impl_def_id)); - - // NB: we can safely drop the skol map - // since we are in a probe [1] - mem::drop(skol_map); - } - Err(_) => { } + self.probe(|this, snapshot| { + if let Ok(placeholder_map) = this.match_impl(impl_def_id, obligation, snapshot) + { + candidates.vec.push(ImplCandidate(impl_def_id)); + + // NB: we can safely drop the placeholder map + // since we are in a probe. + mem::drop(placeholder_map); } }); - } + }, ); Ok(()) } - fn assemble_candidates_from_auto_impls(&mut self, - obligation: &TraitObligation<'tcx>, - candidates: &mut SelectionCandidateSet<'tcx>) - -> Result<(), SelectionError<'tcx>> - { + fn assemble_candidates_from_auto_impls( + &mut self, + obligation: &TraitObligation<'tcx>, + candidates: &mut SelectionCandidateSet<'tcx>, + ) -> Result<(), SelectionError<'tcx>> { // OK to skip binder here because the tests we do below do not involve bound regions let self_ty = *obligation.self_ty().skip_binder(); debug!("assemble_candidates_from_auto_impls(self_ty={:?})", self_ty); @@ -1816,8 +2053,7 @@ // still be provided by a manual implementation for // this trait and type. } - ty::Param(..) | - ty::Projection(..) => { + ty::Param(..) | ty::Projection(..) => { // In these cases, we don't know what the actual // type is. Therefore, we cannot break it down // into its constituent types. So we don't @@ -1836,9 +2072,7 @@ // the auto impl might apply, we don't know candidates.ambiguous = true; } - _ => { - candidates.vec.push(AutoImplCandidate(def_id.clone())) - } + _ => candidates.vec.push(AutoImplCandidate(def_id.clone())), } } @@ -1846,12 +2080,15 @@ } /// Search for impls that might apply to `obligation`. - fn assemble_candidates_from_object_ty(&mut self, - obligation: &TraitObligation<'tcx>, - candidates: &mut SelectionCandidateSet<'tcx>) - { - debug!("assemble_candidates_from_object_ty(self_ty={:?})", - obligation.self_ty().skip_binder()); + fn assemble_candidates_from_object_ty( + &mut self, + obligation: &TraitObligation<'tcx>, + candidates: &mut SelectionCandidateSet<'tcx>, + ) { + debug!( + "assemble_candidates_from_object_ty(self_ty={:?})", + obligation.self_ty().skip_binder() + ); // Object-safety candidates are only applicable to object-safe // traits. Including this check is useful because it helps @@ -1872,42 +2109,43 @@ let self_ty = this.tcx().erase_late_bound_regions(&obligation.self_ty()); let poly_trait_ref = match self_ty.sty { ty::Dynamic(ref data, ..) => { - if data.auto_traits().any(|did| did == obligation.predicate.def_id()) { - debug!("assemble_candidates_from_object_ty: matched builtin bound, \ - pushing candidate"); + if data.auto_traits() + .any(|did| did == obligation.predicate.def_id()) + { + debug!( + "assemble_candidates_from_object_ty: matched builtin bound, \ + pushing candidate" + ); candidates.vec.push(BuiltinObjectCandidate); return; } - match data.principal() { - Some(p) => p.with_self_ty(this.tcx(), self_ty), - None => return, - } + data.principal().with_self_ty(this.tcx(), self_ty) } ty::Infer(ty::TyVar(_)) => { debug!("assemble_candidates_from_object_ty: ambiguous"); candidates.ambiguous = true; // could wind up being an object type return; } - _ => { - return; - } + _ => return, }; - debug!("assemble_candidates_from_object_ty: poly_trait_ref={:?}", - poly_trait_ref); + debug!( + "assemble_candidates_from_object_ty: poly_trait_ref={:?}", + poly_trait_ref + ); // Count only those upcast versions that match the trait-ref // we are looking for. Specifically, do not only check for the // correct trait, but also the correct type parameters. // For example, we may be trying to upcast `Foo` to `Bar`, // but `Foo` is declared as `trait Foo : Bar`. - let upcast_trait_refs = - util::supertraits(this.tcx(), poly_trait_ref) + let upcast_trait_refs = util::supertraits(this.tcx(), poly_trait_ref) .filter(|upcast_trait_ref| { this.probe(|this, _| { let upcast_trait_ref = upcast_trait_ref.clone(); - this.match_poly_trait_ref(obligation, upcast_trait_ref).is_ok() + this.match_poly_trait_ref(obligation, upcast_trait_ref) + .is_ok() }) }) .count(); @@ -1922,9 +2160,11 @@ } /// Search for unsizing that might apply to `obligation`. - fn assemble_candidates_for_unsizing(&mut self, - obligation: &TraitObligation<'tcx>, - candidates: &mut SelectionCandidateSet<'tcx>) { + fn assemble_candidates_for_unsizing( + &mut self, + obligation: &TraitObligation<'tcx>, + candidates: &mut SelectionCandidateSet<'tcx>, + ) { // We currently never consider higher-ranked obligations e.g. // `for<'a> &'a T: Unsize` to be implemented. This is not // because they are a priori invalid, and we could potentially add support @@ -1946,10 +2186,17 @@ return; } }; - let target = obligation.predicate.skip_binder().trait_ref.substs.type_at(1); + let target = obligation + .predicate + .skip_binder() + .trait_ref + .substs + .type_at(1); - debug!("assemble_candidates_for_unsizing(source={:?}, target={:?})", - source, target); + debug!( + "assemble_candidates_for_unsizing(source={:?}, target={:?})", + source, target + ); let may_apply = match (&source.sty, &target.sty) { // Trait+Kx+'a -> Trait+Ky+'b (upcasts). @@ -1965,13 +2212,10 @@ // // We always upcast when we can because of reason // #2 (region bounds). - match (data_a.principal(), data_b.principal()) { - (Some(a), Some(b)) => a.def_id() == b.def_id() && - data_b.auto_traits() - // All of a's auto traits need to be in b's auto traits. - .all(|b| data_a.auto_traits().any(|a| a == b)), - _ => false - } + data_a.principal().def_id() == data_b.principal().def_id() + && data_b.auto_traits() + // All of a's auto traits need to be in b's auto traits. + .all(|b| data_a.auto_traits().any(|a| a == b)) } // T -> Trait. @@ -1980,8 +2224,7 @@ // Ambiguous handling is below T -> Trait, because inference // variables can still implement Unsize and nested // obligations will have the final say (likely deferred). - (&ty::Infer(ty::TyVar(_)), _) | - (_, &ty::Infer(ty::TyVar(_))) => { + (&ty::Infer(ty::TyVar(_)), _) | (_, &ty::Infer(ty::TyVar(_))) => { debug!("assemble_candidates_for_unsizing: ambiguous"); candidates.ambiguous = true; false @@ -1996,11 +2239,9 @@ } // (.., T) -> (.., U). - (&ty::Tuple(tys_a), &ty::Tuple(tys_b)) => { - tys_a.len() == tys_b.len() - } + (&ty::Tuple(tys_a), &ty::Tuple(tys_b)) => tys_a.len() == tys_b.len(), - _ => false + _ => false, }; if may_apply { @@ -2013,9 +2254,8 @@ // // Winnowing is the process of attempting to resolve ambiguity by // probing further. During the winnowing process, we unify all - // type variables (ignoring skolemization) and then we also - // attempt to evaluate recursive bounds to see if they are - // satisfied. + // type variables and then we also attempt to evaluate recursive + // bounds to see if they are satisfied. /// Returns true if `victim` should be dropped in favor of /// `other`. Generally speaking we will drop duplicate @@ -2025,20 +2265,18 @@ fn candidate_should_be_dropped_in_favor_of<'o>( &mut self, victim: &EvaluatedCandidate<'tcx>, - other: &EvaluatedCandidate<'tcx>) - -> bool - { - // Check if a bound would previously have been removed when normalizing - // the param_env so that it can be given the lowest priority. See - // #50825 for the motivation for this. - let is_global = |cand: &ty::PolyTraitRef<'_>| { - cand.is_global() && !cand.has_late_bound_regions() - }; - + other: &EvaluatedCandidate<'tcx>, + ) -> bool { if victim.candidate == other.candidate { return true; } + // Check if a bound would previously have been removed when normalizing + // the param_env so that it can be given the lowest priority. See + // #50825 for the motivation for this. + let is_global = + |cand: &ty::PolyTraitRef<'_>| cand.is_global() && !cand.has_late_bound_regions(); + match other.candidate { // Prefer BuiltinCandidate { has_nested: false } to anything else. // This is a fix for #53123 and prevents winnowing from accidentally extending the @@ -2048,58 +2286,55 @@ AutoImplCandidate(..) => { bug!( "default implementations shouldn't be recorded \ - when there are other valid candidates"); + when there are other valid candidates" + ); } // Prefer BuiltinCandidate { has_nested: false } to anything else. // This is a fix for #53123 and prevents winnowing from accidentally extending the // lifetime of a variable. BuiltinCandidate { has_nested: false } => false, - ImplCandidate(..) | - ClosureCandidate | - GeneratorCandidate | - FnPointerCandidate | - BuiltinObjectCandidate | - BuiltinUnsizeCandidate | - BuiltinCandidate { .. } => { + ImplCandidate(..) + | ClosureCandidate + | GeneratorCandidate + | FnPointerCandidate + | BuiltinObjectCandidate + | BuiltinUnsizeCandidate + | BuiltinCandidate { .. } => { // Global bounds from the where clause should be ignored // here (see issue #50825). Otherwise, we have a where // clause so don't go around looking for impls. !is_global(cand) } - ObjectCandidate | - ProjectionCandidate => { + ObjectCandidate | ProjectionCandidate => { // Arbitrarily give param candidates priority // over projection and object candidates. !is_global(cand) - }, + } ParamCandidate(..) => false, }, - ObjectCandidate | - ProjectionCandidate => match victim.candidate { + ObjectCandidate | ProjectionCandidate => match victim.candidate { AutoImplCandidate(..) => { bug!( "default implementations shouldn't be recorded \ - when there are other valid candidates"); + when there are other valid candidates" + ); } // Prefer BuiltinCandidate { has_nested: false } to anything else. // This is a fix for #53123 and prevents winnowing from accidentally extending the // lifetime of a variable. BuiltinCandidate { has_nested: false } => false, - ImplCandidate(..) | - ClosureCandidate | - GeneratorCandidate | - FnPointerCandidate | - BuiltinObjectCandidate | - BuiltinUnsizeCandidate | - BuiltinCandidate { .. } => { - true - } - ObjectCandidate | - ProjectionCandidate => { + ImplCandidate(..) + | ClosureCandidate + | GeneratorCandidate + | FnPointerCandidate + | BuiltinObjectCandidate + | BuiltinUnsizeCandidate + | BuiltinCandidate { .. } => true, + ObjectCandidate | ProjectionCandidate => { // Arbitrarily give param candidates priority // over projection and object candidates. true - }, + } ParamCandidate(ref cand) => is_global(cand), }, ImplCandidate(other_def) => { @@ -2110,25 +2345,25 @@ match victim.candidate { ImplCandidate(victim_def) => { let tcx = self.tcx().global_tcx(); - return tcx.specializes((other_def, victim_def)) || - tcx.impls_are_allowed_to_overlap(other_def, victim_def); + return tcx.specializes((other_def, victim_def)) + || tcx.impls_are_allowed_to_overlap(other_def, victim_def); } ParamCandidate(ref cand) => { // Prefer the impl to a global where clause candidate. return is_global(cand); } - _ => () + _ => (), } } false - }, - ClosureCandidate | - GeneratorCandidate | - FnPointerCandidate | - BuiltinObjectCandidate | - BuiltinUnsizeCandidate | - BuiltinCandidate { has_nested: true } => { + } + ClosureCandidate + | GeneratorCandidate + | FnPointerCandidate + | BuiltinObjectCandidate + | BuiltinUnsizeCandidate + | BuiltinCandidate { has_nested: true } => { match victim.candidate { ParamCandidate(ref cand) => { // Prefer these to a global where-clause bound @@ -2138,7 +2373,7 @@ _ => false, } } - _ => false + _ => false, } } @@ -2148,101 +2383,127 @@ // These cover the traits that are built-in to the language // itself: `Copy`, `Clone` and `Sized`. - fn assemble_builtin_bound_candidates<'o>(&mut self, - conditions: BuiltinImplConditions<'tcx>, - candidates: &mut SelectionCandidateSet<'tcx>) - -> Result<(),SelectionError<'tcx>> - { + fn assemble_builtin_bound_candidates<'o>( + &mut self, + conditions: BuiltinImplConditions<'tcx>, + candidates: &mut SelectionCandidateSet<'tcx>, + ) -> Result<(), SelectionError<'tcx>> { match conditions { BuiltinImplConditions::Where(nested) => { debug!("builtin_bound: nested={:?}", nested); candidates.vec.push(BuiltinCandidate { - has_nested: nested.skip_binder().len() > 0 + has_nested: nested.skip_binder().len() > 0, }); - Ok(()) } - BuiltinImplConditions::None => { Ok(()) } + BuiltinImplConditions::None => {} BuiltinImplConditions::Ambiguous => { debug!("assemble_builtin_bound_candidates: ambiguous builtin"); - Ok(candidates.ambiguous = true) + candidates.ambiguous = true; } } + + Ok(()) } - fn sized_conditions(&mut self, obligation: &TraitObligation<'tcx>) - -> BuiltinImplConditions<'tcx> - { + fn sized_conditions( + &mut self, + obligation: &TraitObligation<'tcx>, + ) -> BuiltinImplConditions<'tcx> { use self::BuiltinImplConditions::{Ambiguous, None, Where}; // NOTE: binder moved to (*) - let self_ty = self.infcx.shallow_resolve( - obligation.predicate.skip_binder().self_ty()); + let self_ty = self.infcx + .shallow_resolve(obligation.predicate.skip_binder().self_ty()); match self_ty.sty { - ty::Infer(ty::IntVar(_)) | ty::Infer(ty::FloatVar(_)) | - ty::Uint(_) | ty::Int(_) | ty::Bool | ty::Float(_) | - ty::FnDef(..) | ty::FnPtr(_) | ty::RawPtr(..) | - ty::Char | ty::Ref(..) | ty::Generator(..) | - ty::GeneratorWitness(..) | ty::Array(..) | ty::Closure(..) | - ty::Never | ty::Error => { + ty::Infer(ty::IntVar(_)) + | ty::Infer(ty::FloatVar(_)) + | ty::Uint(_) + | ty::Int(_) + | ty::Bool + | ty::Float(_) + | ty::FnDef(..) + | ty::FnPtr(_) + | ty::RawPtr(..) + | ty::Char + | ty::Ref(..) + | ty::Generator(..) + | ty::GeneratorWitness(..) + | ty::Array(..) + | ty::Closure(..) + | ty::Never + | ty::Error => { // safe for everything Where(ty::Binder::dummy(Vec::new())) } ty::Str | ty::Slice(_) | ty::Dynamic(..) | ty::Foreign(..) => None, - ty::Tuple(tys) => { - Where(ty::Binder::bind(tys.last().into_iter().cloned().collect())) - } + ty::Tuple(tys) => Where(ty::Binder::bind(tys.last().into_iter().cloned().collect())), ty::Adt(def, substs) => { let sized_crit = def.sized_constraint(self.tcx()); // (*) binder moved here Where(ty::Binder::bind( - sized_crit.iter().map(|ty| ty.subst(self.tcx(), substs)).collect() + sized_crit + .iter() + .map(|ty| ty.subst(self.tcx(), substs)) + .collect(), )) } ty::Projection(_) | ty::Param(_) | ty::Opaque(..) => None, ty::Infer(ty::TyVar(_)) => Ambiguous, - ty::Infer(ty::CanonicalTy(_)) | - ty::Infer(ty::FreshTy(_)) | - ty::Infer(ty::FreshIntTy(_)) | - ty::Infer(ty::FreshFloatTy(_)) => { - bug!("asked to assemble builtin bounds of unexpected type: {:?}", - self_ty); + ty::UnnormalizedProjection(..) + | ty::Infer(ty::BoundTy(_)) + | ty::Infer(ty::FreshTy(_)) + | ty::Infer(ty::FreshIntTy(_)) + | ty::Infer(ty::FreshFloatTy(_)) => { + bug!( + "asked to assemble builtin bounds of unexpected type: {:?}", + self_ty + ); } } } - fn copy_clone_conditions(&mut self, obligation: &TraitObligation<'tcx>) - -> BuiltinImplConditions<'tcx> - { + fn copy_clone_conditions( + &mut self, + obligation: &TraitObligation<'tcx>, + ) -> BuiltinImplConditions<'tcx> { // NOTE: binder moved to (*) - let self_ty = self.infcx.shallow_resolve( - obligation.predicate.skip_binder().self_ty()); + let self_ty = self.infcx + .shallow_resolve(obligation.predicate.skip_binder().self_ty()); use self::BuiltinImplConditions::{Ambiguous, None, Where}; match self_ty.sty { - ty::Infer(ty::IntVar(_)) | ty::Infer(ty::FloatVar(_)) | - ty::FnDef(..) | ty::FnPtr(_) | ty::Error => { - Where(ty::Binder::dummy(Vec::new())) - } - - ty::Uint(_) | ty::Int(_) | ty::Bool | ty::Float(_) | - ty::Char | ty::RawPtr(..) | ty::Never | - ty::Ref(_, _, hir::MutImmutable) => { + ty::Infer(ty::IntVar(_)) + | ty::Infer(ty::FloatVar(_)) + | ty::FnDef(..) + | ty::FnPtr(_) + | ty::Error => Where(ty::Binder::dummy(Vec::new())), + + ty::Uint(_) + | ty::Int(_) + | ty::Bool + | ty::Float(_) + | ty::Char + | ty::RawPtr(..) + | ty::Never + | ty::Ref(_, _, hir::MutImmutable) => { // Implementations provided in libcore None } - ty::Dynamic(..) | ty::Str | ty::Slice(..) | - ty::Generator(..) | ty::GeneratorWitness(..) | ty::Foreign(..) | - ty::Ref(_, _, hir::MutMutable) => { - None - } + ty::Dynamic(..) + | ty::Str + | ty::Slice(..) + | ty::Generator(..) + | ty::GeneratorWitness(..) + | ty::Foreign(..) + | ty::Ref(_, _, hir::MutMutable) => None, ty::Array(element_ty, _) => { // (*) binder moved here @@ -2259,7 +2520,9 @@ let is_copy_trait = Some(trait_id) == self.tcx().lang_items().copy_trait(); let is_clone_trait = Some(trait_id) == self.tcx().lang_items().clone_trait(); if is_copy_trait || is_clone_trait { - Where(ty::Binder::bind(substs.upvar_tys(def_id, self.tcx()).collect())) + Where(ty::Binder::bind( + substs.upvar_tys(def_id, self.tcx()).collect(), + )) } else { None } @@ -2277,12 +2540,15 @@ Ambiguous } - ty::Infer(ty::CanonicalTy(_)) | - ty::Infer(ty::FreshTy(_)) | - ty::Infer(ty::FreshIntTy(_)) | - ty::Infer(ty::FreshFloatTy(_)) => { - bug!("asked to assemble builtin bounds of unexpected type: {:?}", - self_ty); + ty::UnnormalizedProjection(..) + | ty::Infer(ty::BoundTy(_)) + | ty::Infer(ty::FreshTy(_)) + | ty::Infer(ty::FreshIntTy(_)) + | ty::Infer(ty::FreshFloatTy(_)) => { + bug!( + "asked to assemble builtin bounds of unexpected type: {:?}", + self_ty + ); } } } @@ -2300,55 +2566,54 @@ /// ``` fn constituent_types_for_ty(&self, t: Ty<'tcx>) -> Vec> { match t.sty { - ty::Uint(_) | - ty::Int(_) | - ty::Bool | - ty::Float(_) | - ty::FnDef(..) | - ty::FnPtr(_) | - ty::Str | - ty::Error | - ty::Infer(ty::IntVar(_)) | - ty::Infer(ty::FloatVar(_)) | - ty::Never | - ty::Char => { - Vec::new() - } - - ty::Dynamic(..) | - ty::Param(..) | - ty::Foreign(..) | - ty::Projection(..) | - ty::Infer(ty::CanonicalTy(_)) | - ty::Infer(ty::TyVar(_)) | - ty::Infer(ty::FreshTy(_)) | - ty::Infer(ty::FreshIntTy(_)) | - ty::Infer(ty::FreshFloatTy(_)) => { - bug!("asked to assemble constituent types of unexpected type: {:?}", - t); + ty::Uint(_) + | ty::Int(_) + | ty::Bool + | ty::Float(_) + | ty::FnDef(..) + | ty::FnPtr(_) + | ty::Str + | ty::Error + | ty::Infer(ty::IntVar(_)) + | ty::Infer(ty::FloatVar(_)) + | ty::Never + | ty::Char => Vec::new(), + + ty::UnnormalizedProjection(..) + | ty::Dynamic(..) + | ty::Param(..) + | ty::Foreign(..) + | ty::Projection(..) + | ty::Infer(ty::BoundTy(_)) + | ty::Infer(ty::TyVar(_)) + | ty::Infer(ty::FreshTy(_)) + | ty::Infer(ty::FreshIntTy(_)) + | ty::Infer(ty::FreshFloatTy(_)) => { + bug!( + "asked to assemble constituent types of unexpected type: {:?}", + t + ); } - ty::RawPtr(ty::TypeAndMut { ty: element_ty, ..}) | - ty::Ref(_, element_ty, _) => { - vec![element_ty] - }, - - ty::Array(element_ty, _) | ty::Slice(element_ty) => { + ty::RawPtr(ty::TypeAndMut { ty: element_ty, .. }) | ty::Ref(_, element_ty, _) => { vec![element_ty] } + ty::Array(element_ty, _) | ty::Slice(element_ty) => vec![element_ty], + ty::Tuple(ref tys) => { // (T1, ..., Tn) -- meets any bound that all of T1...Tn meet tys.to_vec() } - ty::Closure(def_id, ref substs) => { - substs.upvar_tys(def_id, self.tcx()).collect() - } + ty::Closure(def_id, ref substs) => substs.upvar_tys(def_id, self.tcx()).collect(), ty::Generator(def_id, ref substs, _) => { let witness = substs.witness(def_id, self.tcx()); - substs.upvar_tys(def_id, self.tcx()).chain(iter::once(witness)).collect() + substs + .upvar_tys(def_id, self.tcx()) + .chain(iter::once(witness)) + .collect() } ty::GeneratorWitness(types) => { @@ -2359,15 +2624,9 @@ } // for `PhantomData`, we pass `T` - ty::Adt(def, substs) if def.is_phantom_data() => { - substs.types().collect() - } + ty::Adt(def, substs) if def.is_phantom_data() => substs.types().collect(), - ty::Adt(def, substs) => { - def.all_fields() - .map(|f| f.ty(self.tcx(), substs)) - .collect() - } + ty::Adt(def, substs) => def.all_fields().map(|f| f.ty(self.tcx(), substs)).collect(), ty::Opaque(def_id, substs) => { // We can resolve the `impl Trait` to its concrete type, @@ -2378,14 +2637,14 @@ } } - fn collect_predicates_for_types(&mut self, - param_env: ty::ParamEnv<'tcx>, - cause: ObligationCause<'tcx>, - recursion_depth: usize, - trait_def_id: DefId, - types: ty::Binder>>) - -> Vec> - { + fn collect_predicates_for_types( + &mut self, + param_env: ty::ParamEnv<'tcx>, + cause: ObligationCause<'tcx>, + recursion_depth: usize, + trait_def_id: DefId, + types: ty::Binder>>, + ) -> Vec> { // Because the types were potentially derived from // higher-ranked obligations they may reference late-bound // regions. For example, `for<'a> Foo<&'a int> : Copy` would @@ -2395,34 +2654,45 @@ // // The strategy is to: // - // 1. Instantiate those regions to skolemized regions (e.g., + // 1. Instantiate those regions to placeholder regions (e.g., // `for<'a> &'a int` becomes `&0 int`. // 2. Produce something like `&'0 int : Copy` // 3. Re-bind the regions back to `for<'a> &'a int : Copy` - types.skip_binder().into_iter().flat_map(|ty| { // binder moved -\ - let ty: ty::Binder> = ty::Binder::bind(ty); // <----/ - - self.in_snapshot(|this, snapshot| { - let (skol_ty, skol_map) = - this.infcx().skolemize_late_bound_regions(&ty); - let Normalized { value: normalized_ty, mut obligations } = - project::normalize_with_depth(this, - param_env, - cause.clone(), - recursion_depth, - &skol_ty); - let skol_obligation = - this.tcx().predicate_for_trait_def(param_env, - cause.clone(), - trait_def_id, - recursion_depth, - normalized_ty, - &[]); - obligations.push(skol_obligation); - this.infcx().plug_leaks(skol_map, snapshot, obligations) + types + .skip_binder() + .into_iter() + .flat_map(|ty| { + // binder moved -\ + let ty: ty::Binder> = ty::Binder::bind(ty); // <----/ + + self.in_snapshot(|this, snapshot| { + let (skol_ty, placeholder_map) = this.infcx() + .replace_late_bound_regions_with_placeholders(&ty); + let Normalized { + value: normalized_ty, + mut obligations, + } = project::normalize_with_depth( + this, + param_env, + cause.clone(), + recursion_depth, + &skol_ty, + ); + let skol_obligation = this.tcx().predicate_for_trait_def( + param_env, + cause.clone(), + trait_def_id, + recursion_depth, + normalized_ty, + &[], + ); + obligations.push(skol_obligation); + this.infcx() + .plug_leaks(placeholder_map, snapshot, obligations) + }) }) - }).collect() + .collect() } /////////////////////////////////////////////////////////////////////////// @@ -2435,14 +2705,12 @@ // [rustc guide]: // https://rust-lang-nursery.github.io/rustc-guide/traits/resolution.html#confirmation - fn confirm_candidate(&mut self, - obligation: &TraitObligation<'tcx>, - candidate: SelectionCandidate<'tcx>) - -> Result,SelectionError<'tcx>> - { - debug!("confirm_candidate({:?}, {:?})", - obligation, - candidate); + fn confirm_candidate( + &mut self, + obligation: &TraitObligation<'tcx>, + candidate: SelectionCandidate<'tcx>, + ) -> Result, SelectionError<'tcx>> { + debug!("confirm_candidate({:?}, {:?})", obligation, candidate); match candidate { BuiltinCandidate { has_nested } => { @@ -2460,9 +2728,10 @@ Ok(VtableAutoImpl(data)) } - ImplCandidate(impl_def_id) => { - Ok(VtableImpl(self.confirm_impl_candidate(obligation, impl_def_id))) - } + ImplCandidate(impl_def_id) => Ok(VtableImpl(self.confirm_impl_candidate( + obligation, + impl_def_id, + ))), ClosureCandidate => { let vtable_closure = self.confirm_closure_candidate(obligation)?; @@ -2489,8 +2758,7 @@ } FnPointerCandidate => { - let data = - self.confirm_fn_pointer_candidate(obligation)?; + let data = self.confirm_fn_pointer_candidate(obligation)?; Ok(VtableFnPointer(data)) } @@ -2506,25 +2774,20 @@ } } - fn confirm_projection_candidate(&mut self, - obligation: &TraitObligation<'tcx>) - { + fn confirm_projection_candidate(&mut self, obligation: &TraitObligation<'tcx>) { self.in_snapshot(|this, snapshot| { let result = - this.match_projection_obligation_against_definition_bounds(obligation, - snapshot); + this.match_projection_obligation_against_definition_bounds(obligation, snapshot); assert!(result); }) } - fn confirm_param_candidate(&mut self, - obligation: &TraitObligation<'tcx>, - param: ty::PolyTraitRef<'tcx>) - -> Vec> - { - debug!("confirm_param_candidate({:?},{:?})", - obligation, - param); + fn confirm_param_candidate( + &mut self, + obligation: &TraitObligation<'tcx>, + param: ty::PolyTraitRef<'tcx>, + ) -> Vec> { + debug!("confirm_param_candidate({:?},{:?})", obligation, param); // During evaluation, we already checked that this // where-clause trait-ref could be unified with the obligation @@ -2533,56 +2796,62 @@ match self.match_where_clause_trait_ref(obligation, param.clone()) { Ok(obligations) => obligations, Err(()) => { - bug!("Where clause `{:?}` was applicable to `{:?}` but now is not", - param, - obligation); + bug!( + "Where clause `{:?}` was applicable to `{:?}` but now is not", + param, + obligation + ); } } } - fn confirm_builtin_candidate(&mut self, - obligation: &TraitObligation<'tcx>, - has_nested: bool) - -> VtableBuiltinData> - { - debug!("confirm_builtin_candidate({:?}, {:?})", - obligation, has_nested); + fn confirm_builtin_candidate( + &mut self, + obligation: &TraitObligation<'tcx>, + has_nested: bool, + ) -> VtableBuiltinData> { + debug!( + "confirm_builtin_candidate({:?}, {:?})", + obligation, has_nested + ); let lang_items = self.tcx().lang_items(); let obligations = if has_nested { let trait_def = obligation.predicate.def_id(); - let conditions = match trait_def { - _ if Some(trait_def) == lang_items.sized_trait() => { - self.sized_conditions(obligation) - } - _ if Some(trait_def) == lang_items.copy_trait() => { - self.copy_clone_conditions(obligation) - } - _ if Some(trait_def) == lang_items.clone_trait() => { - self.copy_clone_conditions(obligation) - } - _ => bug!("unexpected builtin trait {:?}", trait_def) + let conditions = if Some(trait_def) == lang_items.sized_trait() { + self.sized_conditions(obligation) + } else if Some(trait_def) == lang_items.copy_trait() { + self.copy_clone_conditions(obligation) + } else if Some(trait_def) == lang_items.clone_trait() { + self.copy_clone_conditions(obligation) + } else { + bug!("unexpected builtin trait {:?}", trait_def) }; let nested = match conditions { BuiltinImplConditions::Where(nested) => nested, - _ => bug!("obligation {:?} had matched a builtin impl but now doesn't", - obligation) + _ => bug!( + "obligation {:?} had matched a builtin impl but now doesn't", + obligation + ), }; let cause = obligation.derived_cause(BuiltinDerivedObligation); - self.collect_predicates_for_types(obligation.param_env, - cause, - obligation.recursion_depth+1, - trait_def, - nested) + self.collect_predicates_for_types( + obligation.param_env, + cause, + obligation.recursion_depth + 1, + trait_def, + nested, + ) } else { vec![] }; - debug!("confirm_builtin_candidate: obligations={:?}", - obligations); + debug!("confirm_builtin_candidate: obligations={:?}", obligations); - VtableBuiltinData { nested: obligations } + VtableBuiltinData { + nested: obligations, + } } /// This handles the case where a `auto trait Foo` impl is being used. @@ -2590,14 +2859,15 @@ /// /// 1. For each constituent type `Y` in `X`, `Y : Foo` holds /// 2. For each where-clause `C` declared on `Foo`, `[Self => X] C` holds. - fn confirm_auto_impl_candidate(&mut self, - obligation: &TraitObligation<'tcx>, - trait_def_id: DefId) - -> VtableAutoImplData> - { - debug!("confirm_auto_impl_candidate({:?}, {:?})", - obligation, - trait_def_id); + fn confirm_auto_impl_candidate( + &mut self, + obligation: &TraitObligation<'tcx>, + trait_def_id: DefId, + ) -> VtableAutoImplData> { + debug!( + "confirm_auto_impl_candidate({:?}, {:?})", + obligation, trait_def_id + ); let types = obligation.predicate.map_bound(|inner| { let self_ty = self.infcx.shallow_resolve(inner.self_ty()); @@ -2607,101 +2877,105 @@ } /// See `confirm_auto_impl_candidate` - fn vtable_auto_impl(&mut self, - obligation: &TraitObligation<'tcx>, - trait_def_id: DefId, - nested: ty::Binder>>) - -> VtableAutoImplData> - { + fn vtable_auto_impl( + &mut self, + obligation: &TraitObligation<'tcx>, + trait_def_id: DefId, + nested: ty::Binder>>, + ) -> VtableAutoImplData> { debug!("vtable_auto_impl: nested={:?}", nested); let cause = obligation.derived_cause(BuiltinDerivedObligation); let mut obligations = self.collect_predicates_for_types( obligation.param_env, cause, - obligation.recursion_depth+1, + obligation.recursion_depth + 1, trait_def_id, - nested); + nested, + ); - let trait_obligations = self.in_snapshot(|this, snapshot| { + let trait_obligations: Vec> = self.in_snapshot(|this, snapshot| { let poly_trait_ref = obligation.predicate.to_poly_trait_ref(); - let (trait_ref, skol_map) = - this.infcx().skolemize_late_bound_regions(&poly_trait_ref); + let (trait_ref, placeholder_map) = this.infcx() + .replace_late_bound_regions_with_placeholders(&poly_trait_ref); let cause = obligation.derived_cause(ImplDerivedObligation); - this.impl_or_trait_obligations(cause, - obligation.recursion_depth + 1, - obligation.param_env, - trait_def_id, - &trait_ref.substs, - skol_map, - snapshot) + this.impl_or_trait_obligations( + cause, + obligation.recursion_depth + 1, + obligation.param_env, + trait_def_id, + &trait_ref.substs, + placeholder_map, + snapshot, + ) }); + // Adds the predicates from the trait. Note that this contains a `Self: Trait` + // predicate as usual. It won't have any effect since auto traits are coinductive. obligations.extend(trait_obligations); debug!("vtable_auto_impl: obligations={:?}", obligations); VtableAutoImplData { trait_def_id, - nested: obligations + nested: obligations, } } - fn confirm_impl_candidate(&mut self, - obligation: &TraitObligation<'tcx>, - impl_def_id: DefId) - -> VtableImplData<'tcx, PredicateObligation<'tcx>> - { - debug!("confirm_impl_candidate({:?},{:?})", - obligation, - impl_def_id); + fn confirm_impl_candidate( + &mut self, + obligation: &TraitObligation<'tcx>, + impl_def_id: DefId, + ) -> VtableImplData<'tcx, PredicateObligation<'tcx>> { + debug!("confirm_impl_candidate({:?},{:?})", obligation, impl_def_id); // First, create the substitutions by matching the impl again, // this time not in a probe. self.in_snapshot(|this, snapshot| { - let (substs, skol_map) = - this.rematch_impl(impl_def_id, obligation, - snapshot); + let (substs, placeholder_map) = this.rematch_impl(impl_def_id, obligation, snapshot); debug!("confirm_impl_candidate substs={:?}", substs); let cause = obligation.derived_cause(ImplDerivedObligation); - this.vtable_impl(impl_def_id, - substs, - cause, - obligation.recursion_depth + 1, - obligation.param_env, - skol_map, - snapshot) + this.vtable_impl( + impl_def_id, + substs, + cause, + obligation.recursion_depth + 1, + obligation.param_env, + placeholder_map, + snapshot, + ) }) } - fn vtable_impl(&mut self, - impl_def_id: DefId, - mut substs: Normalized<'tcx, &'tcx Substs<'tcx>>, - cause: ObligationCause<'tcx>, - recursion_depth: usize, - param_env: ty::ParamEnv<'tcx>, - skol_map: infer::SkolemizationMap<'tcx>, - snapshot: &infer::CombinedSnapshot<'cx, 'tcx>) - -> VtableImplData<'tcx, PredicateObligation<'tcx>> - { - debug!("vtable_impl(impl_def_id={:?}, substs={:?}, recursion_depth={}, skol_map={:?})", - impl_def_id, - substs, - recursion_depth, - skol_map); - - let mut impl_obligations = - self.impl_or_trait_obligations(cause, - recursion_depth, - param_env, - impl_def_id, - &substs.value, - skol_map, - snapshot); - - debug!("vtable_impl: impl_def_id={:?} impl_obligations={:?}", - impl_def_id, - impl_obligations); + fn vtable_impl( + &mut self, + impl_def_id: DefId, + mut substs: Normalized<'tcx, &'tcx Substs<'tcx>>, + cause: ObligationCause<'tcx>, + recursion_depth: usize, + param_env: ty::ParamEnv<'tcx>, + placeholder_map: infer::PlaceholderMap<'tcx>, + snapshot: &infer::CombinedSnapshot<'cx, 'tcx>, + ) -> VtableImplData<'tcx, PredicateObligation<'tcx>> { + debug!( + "vtable_impl(impl_def_id={:?}, substs={:?}, recursion_depth={}, placeholder_map={:?})", + impl_def_id, substs, recursion_depth, placeholder_map + ); + + let mut impl_obligations = self.impl_or_trait_obligations( + cause, + recursion_depth, + param_env, + impl_def_id, + &substs.value, + placeholder_map, + snapshot, + ); + + debug!( + "vtable_impl: impl_def_id={:?} impl_obligations={:?}", + impl_def_id, impl_obligations + ); // Because of RFC447, the impl-trait-ref and obligations // are sufficient to determine the impl substs, without @@ -2710,31 +2984,30 @@ // e.g. `impl> Foo<::T> for V` impl_obligations.append(&mut substs.obligations); - VtableImplData { impl_def_id, - substs: substs.value, - nested: impl_obligations } + VtableImplData { + impl_def_id, + substs: substs.value, + nested: impl_obligations, + } } - fn confirm_object_candidate(&mut self, - obligation: &TraitObligation<'tcx>) - -> VtableObjectData<'tcx, PredicateObligation<'tcx>> - { - debug!("confirm_object_candidate({:?})", - obligation); + fn confirm_object_candidate( + &mut self, + obligation: &TraitObligation<'tcx>, + ) -> VtableObjectData<'tcx, PredicateObligation<'tcx>> { + debug!("confirm_object_candidate({:?})", obligation); // FIXME skipping binder here seems wrong -- we should // probably flatten the binder from the obligation and the // binder from the object. Have to try to make a broken test // case that results. -nmatsakis - let self_ty = self.infcx.shallow_resolve(*obligation.self_ty().skip_binder()); + let self_ty = self.infcx + .shallow_resolve(*obligation.self_ty().skip_binder()); let poly_trait_ref = match self_ty.sty { ty::Dynamic(ref data, ..) => { - data.principal().unwrap().with_self_ty(self.tcx(), self_ty) - } - _ => { - span_bug!(obligation.cause.span, - "object candidate with non-object"); + data.principal().with_self_ty(self.tcx(), self_ty) } + _ => span_bug!(obligation.cause.span, "object candidate with non-object"), }; let mut upcast_trait_ref = None; @@ -2750,30 +3023,22 @@ // where we can unify because otherwise select would have // reported an ambiguity. (When we do find a match, also // record it for later.) - let nonmatching = - util::supertraits(tcx, poly_trait_ref) - .take_while(|&t| { - match - self.commit_if_ok( - |this, _| this.match_poly_trait_ref(obligation, t)) - { - Ok(obligations) => { - upcast_trait_ref = Some(t); - nested.extend(obligations); - false - } - Err(_) => { true } + let nonmatching = util::supertraits(tcx, poly_trait_ref).take_while( + |&t| match self.commit_if_ok(|this, _| this.match_poly_trait_ref(obligation, t)) { + Ok(obligations) => { + upcast_trait_ref = Some(t); + nested.extend(obligations); + false } - }); + Err(_) => true, + }, + ); // Additionally, for each of the nonmatching predicates that // we pass over, we sum up the set of number of vtable // entries, so that we can compute the offset for the selected // trait. - vtable_base = - nonmatching.map(|t| tcx.count_own_vtable_entries(t)) - .sum(); - + vtable_base = nonmatching.map(|t| tcx.count_own_vtable_entries(t)).sum(); } VtableObjectData { @@ -2783,137 +3048,154 @@ } } - fn confirm_fn_pointer_candidate(&mut self, obligation: &TraitObligation<'tcx>) - -> Result>, SelectionError<'tcx>> - { - debug!("confirm_fn_pointer_candidate({:?})", - obligation); + fn confirm_fn_pointer_candidate( + &mut self, + obligation: &TraitObligation<'tcx>, + ) -> Result>, SelectionError<'tcx>> { + debug!("confirm_fn_pointer_candidate({:?})", obligation); // ok to skip binder; it is reintroduced below - let self_ty = self.infcx.shallow_resolve(*obligation.self_ty().skip_binder()); + let self_ty = self.infcx + .shallow_resolve(*obligation.self_ty().skip_binder()); let sig = self_ty.fn_sig(self.tcx()); - let trait_ref = - self.tcx().closure_trait_ref_and_return_type(obligation.predicate.def_id(), - self_ty, - sig, - util::TupleArgumentsFlag::Yes) + let trait_ref = self.tcx() + .closure_trait_ref_and_return_type( + obligation.predicate.def_id(), + self_ty, + sig, + util::TupleArgumentsFlag::Yes, + ) .map_bound(|(trait_ref, _)| trait_ref); - let Normalized { value: trait_ref, obligations } = - project::normalize_with_depth(self, - obligation.param_env, - obligation.cause.clone(), - obligation.recursion_depth + 1, - &trait_ref); - - self.confirm_poly_trait_refs(obligation.cause.clone(), - obligation.param_env, - obligation.predicate.to_poly_trait_ref(), - trait_ref)?; - Ok(VtableFnPointerData { fn_ty: self_ty, nested: obligations }) - } - - fn confirm_generator_candidate(&mut self, - obligation: &TraitObligation<'tcx>) - -> Result>, - SelectionError<'tcx>> - { + let Normalized { + value: trait_ref, + obligations, + } = project::normalize_with_depth( + self, + obligation.param_env, + obligation.cause.clone(), + obligation.recursion_depth + 1, + &trait_ref, + ); + + self.confirm_poly_trait_refs( + obligation.cause.clone(), + obligation.param_env, + obligation.predicate.to_poly_trait_ref(), + trait_ref, + )?; + Ok(VtableFnPointerData { + fn_ty: self_ty, + nested: obligations, + }) + } + + fn confirm_generator_candidate( + &mut self, + obligation: &TraitObligation<'tcx>, + ) -> Result>, SelectionError<'tcx>> { // ok to skip binder because the substs on generator types never // touch bound regions, they just capture the in-scope // type/region parameters - let self_ty = self.infcx.shallow_resolve(obligation.self_ty().skip_binder()); + let self_ty = self.infcx + .shallow_resolve(obligation.self_ty().skip_binder()); let (generator_def_id, substs) = match self_ty.sty { ty::Generator(id, substs, _) => (id, substs), - _ => bug!("closure candidate for non-closure {:?}", obligation) + _ => bug!("closure candidate for non-closure {:?}", obligation), }; - debug!("confirm_generator_candidate({:?},{:?},{:?})", - obligation, - generator_def_id, - substs); + debug!( + "confirm_generator_candidate({:?},{:?},{:?})", + obligation, generator_def_id, substs + ); - let trait_ref = - self.generator_trait_ref_unnormalized(obligation, generator_def_id, substs); + let trait_ref = self.generator_trait_ref_unnormalized(obligation, generator_def_id, substs); let Normalized { value: trait_ref, - mut obligations - } = normalize_with_depth(self, - obligation.param_env, - obligation.cause.clone(), - obligation.recursion_depth+1, - &trait_ref); - - debug!("confirm_generator_candidate(generator_def_id={:?}, \ - trait_ref={:?}, obligations={:?})", - generator_def_id, - trait_ref, - obligations); - - obligations.extend( - self.confirm_poly_trait_refs(obligation.cause.clone(), - obligation.param_env, - obligation.predicate.to_poly_trait_ref(), - trait_ref)?); + mut obligations, + } = normalize_with_depth( + self, + obligation.param_env, + obligation.cause.clone(), + obligation.recursion_depth + 1, + &trait_ref, + ); + + debug!( + "confirm_generator_candidate(generator_def_id={:?}, \ + trait_ref={:?}, obligations={:?})", + generator_def_id, trait_ref, obligations + ); + + obligations.extend(self.confirm_poly_trait_refs( + obligation.cause.clone(), + obligation.param_env, + obligation.predicate.to_poly_trait_ref(), + trait_ref, + )?); Ok(VtableGeneratorData { generator_def_id: generator_def_id, substs: substs.clone(), - nested: obligations + nested: obligations, }) } - fn confirm_closure_candidate(&mut self, - obligation: &TraitObligation<'tcx>) - -> Result>, - SelectionError<'tcx>> - { + fn confirm_closure_candidate( + &mut self, + obligation: &TraitObligation<'tcx>, + ) -> Result>, SelectionError<'tcx>> { debug!("confirm_closure_candidate({:?})", obligation); - let kind = match self.tcx().lang_items().fn_trait_kind(obligation.predicate.def_id()) { - Some(k) => k, - None => bug!("closure candidate for non-fn trait {:?}", obligation) - }; + let kind = self.tcx() + .lang_items() + .fn_trait_kind(obligation.predicate.def_id()) + .unwrap_or_else(|| bug!("closure candidate for non-fn trait {:?}", obligation)); // ok to skip binder because the substs on closure types never // touch bound regions, they just capture the in-scope // type/region parameters - let self_ty = self.infcx.shallow_resolve(obligation.self_ty().skip_binder()); + let self_ty = self.infcx + .shallow_resolve(obligation.self_ty().skip_binder()); let (closure_def_id, substs) = match self_ty.sty { ty::Closure(id, substs) => (id, substs), - _ => bug!("closure candidate for non-closure {:?}", obligation) + _ => bug!("closure candidate for non-closure {:?}", obligation), }; - let trait_ref = - self.closure_trait_ref_unnormalized(obligation, closure_def_id, substs); + let trait_ref = self.closure_trait_ref_unnormalized(obligation, closure_def_id, substs); let Normalized { value: trait_ref, - mut obligations - } = normalize_with_depth(self, - obligation.param_env, - obligation.cause.clone(), - obligation.recursion_depth+1, - &trait_ref); - - debug!("confirm_closure_candidate(closure_def_id={:?}, trait_ref={:?}, obligations={:?})", - closure_def_id, - trait_ref, - obligations); - - obligations.extend( - self.confirm_poly_trait_refs(obligation.cause.clone(), - obligation.param_env, - obligation.predicate.to_poly_trait_ref(), - trait_ref)?); + mut obligations, + } = normalize_with_depth( + self, + obligation.param_env, + obligation.cause.clone(), + obligation.recursion_depth + 1, + &trait_ref, + ); + + debug!( + "confirm_closure_candidate(closure_def_id={:?}, trait_ref={:?}, obligations={:?})", + closure_def_id, trait_ref, obligations + ); + + obligations.extend(self.confirm_poly_trait_refs( + obligation.cause.clone(), + obligation.param_env, + obligation.predicate.to_poly_trait_ref(), + trait_ref, + )?); obligations.push(Obligation::new( obligation.cause.clone(), obligation.param_env, - ty::Predicate::ClosureKind(closure_def_id, substs, kind))); + ty::Predicate::ClosureKind(closure_def_id, substs, kind), + )); Ok(VtableClosureData { closure_def_id, substs: substs.clone(), - nested: obligations + nested: obligations, }) } @@ -2942,13 +3224,13 @@ /// because these output type parameters should not affect the /// selection of the impl. Therefore, if there is a mismatch, we /// report an error to the user. - fn confirm_poly_trait_refs(&mut self, - obligation_cause: ObligationCause<'tcx>, - obligation_param_env: ty::ParamEnv<'tcx>, - obligation_trait_ref: ty::PolyTraitRef<'tcx>, - expected_trait_ref: ty::PolyTraitRef<'tcx>) - -> Result>, SelectionError<'tcx>> - { + fn confirm_poly_trait_refs( + &mut self, + obligation_cause: ObligationCause<'tcx>, + obligation_param_env: ty::ParamEnv<'tcx>, + obligation_trait_ref: ty::PolyTraitRef<'tcx>, + expected_trait_ref: ty::PolyTraitRef<'tcx>, + ) -> Result>, SelectionError<'tcx>> { let obligation_trait_ref = obligation_trait_ref.clone(); self.infcx .at(&obligation_cause, obligation_param_env) @@ -2957,21 +3239,28 @@ .map_err(|e| OutputTypeParameterMismatch(expected_trait_ref, obligation_trait_ref, e)) } - fn confirm_builtin_unsize_candidate(&mut self, - obligation: &TraitObligation<'tcx>,) - -> Result>, SelectionError<'tcx>> - { + fn confirm_builtin_unsize_candidate( + &mut self, + obligation: &TraitObligation<'tcx>, + ) -> Result>, SelectionError<'tcx>> { let tcx = self.tcx(); // assemble_candidates_for_unsizing should ensure there are no late bound // regions here. See the comment there for more details. - let source = self.infcx.shallow_resolve( - obligation.self_ty().no_late_bound_regions().unwrap()); - let target = obligation.predicate.skip_binder().trait_ref.substs.type_at(1); + let source = self.infcx + .shallow_resolve(obligation.self_ty().no_late_bound_regions().unwrap()); + let target = obligation + .predicate + .skip_binder() + .trait_ref + .substs + .type_at(1); let target = self.infcx.shallow_resolve(target); - debug!("confirm_builtin_unsize_candidate(source={:?}, target={:?})", - source, target); + debug!( + "confirm_builtin_unsize_candidate(source={:?}, target={:?})", + source, target + ); let mut nested = vec![]; match (&source.sty, &target.sty) { @@ -2979,49 +3268,62 @@ (&ty::Dynamic(ref data_a, r_a), &ty::Dynamic(ref data_b, r_b)) => { // See assemble_candidates_for_unsizing for more info. let existential_predicates = data_a.map_bound(|data_a| { - let principal = data_a.principal(); - let iter = principal.into_iter().map(ty::ExistentialPredicate::Trait) - .chain(data_a.projection_bounds() - .map(|x| ty::ExistentialPredicate::Projection(x))) - .chain(data_b.auto_traits().map(ty::ExistentialPredicate::AutoTrait)); + let iter = iter::once(ty::ExistentialPredicate::Trait(data_a.principal())) + .chain( + data_a + .projection_bounds() + .map(|x| ty::ExistentialPredicate::Projection(x)), + ) + .chain( + data_b + .auto_traits() + .map(ty::ExistentialPredicate::AutoTrait), + ); tcx.mk_existential_predicates(iter) }); let new_trait = tcx.mk_dynamic(existential_predicates, r_b); - let InferOk { obligations, .. } = - self.infcx.at(&obligation.cause, obligation.param_env) - .eq(target, new_trait) - .map_err(|_| Unimplemented)?; + let InferOk { obligations, .. } = self.infcx + .at(&obligation.cause, obligation.param_env) + .eq(target, new_trait) + .map_err(|_| Unimplemented)?; nested.extend(obligations); // Register one obligation for 'a: 'b. - let cause = ObligationCause::new(obligation.cause.span, - obligation.cause.body_id, - ObjectCastObligation(target)); + let cause = ObligationCause::new( + obligation.cause.span, + obligation.cause.body_id, + ObjectCastObligation(target), + ); let outlives = ty::OutlivesPredicate(r_a, r_b); - nested.push(Obligation::with_depth(cause, - obligation.recursion_depth + 1, - obligation.param_env, - ty::Binder::bind(outlives).to_predicate())); + nested.push(Obligation::with_depth( + cause, + obligation.recursion_depth + 1, + obligation.param_env, + ty::Binder::bind(outlives).to_predicate(), + )); } // T -> Trait. (_, &ty::Dynamic(ref data, r)) => { - let mut object_dids = - data.auto_traits().chain(data.principal().map(|p| p.def_id())); - if let Some(did) = object_dids.find(|did| { - !tcx.is_object_safe(*did) - }) { - return Err(TraitNotObjectSafe(did)) - } - - let cause = ObligationCause::new(obligation.cause.span, - obligation.cause.body_id, - ObjectCastObligation(target)); - let mut push = |predicate| { - nested.push(Obligation::with_depth(cause.clone(), - obligation.recursion_depth + 1, - obligation.param_env, - predicate)); + let mut object_dids = data.auto_traits() + .chain(iter::once(data.principal().def_id())); + if let Some(did) = object_dids.find(|did| !tcx.is_object_safe(*did)) { + return Err(TraitNotObjectSafe(did)); + } + + let cause = ObligationCause::new( + obligation.cause.span, + obligation.cause.body_id, + ObjectCastObligation(target), + ); + + let predicate_to_obligation = |predicate| { + Obligation::with_depth( + cause.clone(), + obligation.recursion_depth + 1, + obligation.param_env, + predicate, + ) }; // Create obligations: @@ -3030,36 +3332,38 @@ // words, if the object type is Foo+Send, this would create an obligation for the // Send check.) // - Projection predicates - for predicate in data.iter() { - push(predicate.with_self_ty(tcx, source)); - } + nested.extend( + data.iter() + .map(|d| predicate_to_obligation(d.with_self_ty(tcx, source))), + ); // We can only make objects from sized types. let tr = ty::TraitRef { def_id: tcx.require_lang_item(lang_items::SizedTraitLangItem), substs: tcx.mk_substs_trait(source, &[]), }; - push(tr.to_predicate()); + nested.push(predicate_to_obligation(tr.to_predicate())); // If the type is `Foo+'a`, ensures that the type // being cast to `Foo+'a` outlives `'a`: let outlives = ty::OutlivesPredicate(source, r); - push(ty::Binder::dummy(outlives).to_predicate()); + nested.push(predicate_to_obligation( + ty::Binder::dummy(outlives).to_predicate(), + )); } // [T; n] -> [T]. (&ty::Array(a, _), &ty::Slice(b)) => { - let InferOk { obligations, .. } = - self.infcx.at(&obligation.cause, obligation.param_env) - .eq(b, a) - .map_err(|_| Unimplemented)?; + let InferOk { obligations, .. } = self.infcx + .at(&obligation.cause, obligation.param_env) + .eq(b, a) + .map_err(|_| Unimplemented)?; nested.extend(obligations); } // Struct -> Struct. (&ty::Adt(def, substs_a), &ty::Adt(_, substs_b)) => { - let fields = def - .all_fields() + let fields = def.all_fields() .map(|f| tcx.type_of(f.did)) .collect::>(); @@ -3069,7 +3373,7 @@ } else { return Err(Unimplemented); }; - let mut ty_params = BitArray::new(substs_a.types().count()); + let mut ty_params = GrowableBitSet::new_empty(); let mut found = false; for ty in field.walk() { if let ty::Param(p) = ty.sty { @@ -3113,10 +3417,10 @@ } }); let new_struct = tcx.mk_adt(def, tcx.mk_substs(params)); - let InferOk { obligations, .. } = - self.infcx.at(&obligation.cause, obligation.param_env) - .eq(target, new_struct) - .map_err(|_| Unimplemented)?; + let InferOk { obligations, .. } = self.infcx + .at(&obligation.cause, obligation.param_env) + .eq(target, new_struct) + .map_err(|_| Unimplemented)?; nested.extend(obligations); // Construct the nested Field: Unsize> predicate. @@ -3126,7 +3430,8 @@ obligation.predicate.def_id(), obligation.recursion_depth + 1, inner_source, - &[inner_target.into()])); + &[inner_target.into()], + )); } // (.., T) -> (.., U). @@ -3144,10 +3449,10 @@ // Check that the source tuple with the target's // last element is equal to the target. let new_tuple = tcx.mk_tup(a_mid.iter().cloned().chain(iter::once(b_last))); - let InferOk { obligations, .. } = - self.infcx.at(&obligation.cause, obligation.param_env) - .eq(target, new_tuple) - .map_err(|_| Unimplemented)?; + let InferOk { obligations, .. } = self.infcx + .at(&obligation.cause, obligation.param_env) + .eq(target, new_tuple) + .map_err(|_| Unimplemented)?; nested.extend(obligations); // Construct the nested T: Unsize predicate. @@ -3157,10 +3462,11 @@ obligation.predicate.def_id(), obligation.recursion_depth + 1, a_last, - &[b_last.into()])); + &[b_last.into()], + )); } - _ => bug!() + _ => bug!(), }; Ok(VtableBuiltinData { nested: nested }) @@ -3176,30 +3482,39 @@ // run inside of a `probe()` so that their side-effects are // contained. - fn rematch_impl(&mut self, - impl_def_id: DefId, - obligation: &TraitObligation<'tcx>, - snapshot: &infer::CombinedSnapshot<'cx, 'tcx>) - -> (Normalized<'tcx, &'tcx Substs<'tcx>>, - infer::SkolemizationMap<'tcx>) - { + fn rematch_impl( + &mut self, + impl_def_id: DefId, + obligation: &TraitObligation<'tcx>, + snapshot: &infer::CombinedSnapshot<'cx, 'tcx>, + ) -> ( + Normalized<'tcx, &'tcx Substs<'tcx>>, + infer::PlaceholderMap<'tcx>, + ) { match self.match_impl(impl_def_id, obligation, snapshot) { - Ok((substs, skol_map)) => (substs, skol_map), + Ok((substs, placeholder_map)) => (substs, placeholder_map), Err(()) => { - bug!("Impl {:?} was matchable against {:?} but now is not", - impl_def_id, - obligation); + bug!( + "Impl {:?} was matchable against {:?} but now is not", + impl_def_id, + obligation + ); } } } - fn match_impl(&mut self, - impl_def_id: DefId, - obligation: &TraitObligation<'tcx>, - snapshot: &infer::CombinedSnapshot<'cx, 'tcx>) - -> Result<(Normalized<'tcx, &'tcx Substs<'tcx>>, - infer::SkolemizationMap<'tcx>), ()> - { + fn match_impl( + &mut self, + impl_def_id: DefId, + obligation: &TraitObligation<'tcx>, + snapshot: &infer::CombinedSnapshot<'cx, 'tcx>, + ) -> Result< + ( + Normalized<'tcx, &'tcx Substs<'tcx>>, + infer::PlaceholderMap<'tcx>, + ), + (), + > { let impl_trait_ref = self.tcx().impl_trait_ref(impl_def_id).unwrap(); // Before we create the substitutions and everything, first @@ -3209,74 +3524,78 @@ return Err(()); } - let (skol_obligation, skol_map) = self.infcx().skolemize_late_bound_regions( - &obligation.predicate); + let (skol_obligation, placeholder_map) = self.infcx() + .replace_late_bound_regions_with_placeholders(&obligation.predicate); let skol_obligation_trait_ref = skol_obligation.trait_ref; - let impl_substs = self.infcx.fresh_substs_for_item(obligation.cause.span, - impl_def_id); + let impl_substs = self.infcx + .fresh_substs_for_item(obligation.cause.span, impl_def_id); - let impl_trait_ref = impl_trait_ref.subst(self.tcx(), - impl_substs); + let impl_trait_ref = impl_trait_ref.subst(self.tcx(), impl_substs); - let Normalized { value: impl_trait_ref, obligations: mut nested_obligations } = - project::normalize_with_depth(self, - obligation.param_env, - obligation.cause.clone(), - obligation.recursion_depth + 1, - &impl_trait_ref); - - debug!("match_impl(impl_def_id={:?}, obligation={:?}, \ - impl_trait_ref={:?}, skol_obligation_trait_ref={:?})", - impl_def_id, - obligation, - impl_trait_ref, - skol_obligation_trait_ref); - - let InferOk { obligations, .. } = - self.infcx.at(&obligation.cause, obligation.param_env) - .eq(skol_obligation_trait_ref, impl_trait_ref) - .map_err(|e| { - debug!("match_impl: failed eq_trait_refs due to `{}`", e); - () - })?; + let Normalized { + value: impl_trait_ref, + obligations: mut nested_obligations, + } = project::normalize_with_depth( + self, + obligation.param_env, + obligation.cause.clone(), + obligation.recursion_depth + 1, + &impl_trait_ref, + ); + + debug!( + "match_impl(impl_def_id={:?}, obligation={:?}, \ + impl_trait_ref={:?}, skol_obligation_trait_ref={:?})", + impl_def_id, obligation, impl_trait_ref, skol_obligation_trait_ref + ); + + let InferOk { obligations, .. } = self.infcx + .at(&obligation.cause, obligation.param_env) + .eq(skol_obligation_trait_ref, impl_trait_ref) + .map_err(|e| debug!("match_impl: failed eq_trait_refs due to `{}`", e))?; nested_obligations.extend(obligations); - if let Err(e) = self.infcx.leak_check(false, - obligation.cause.span, - &skol_map, - snapshot) { + if let Err(e) = + self.infcx + .leak_check(false, obligation.cause.span, &placeholder_map, snapshot) + { debug!("match_impl: failed leak check due to `{}`", e); return Err(()); } debug!("match_impl: success impl_substs={:?}", impl_substs); - Ok((Normalized { - value: impl_substs, - obligations: nested_obligations - }, skol_map)) + Ok(( + Normalized { + value: impl_substs, + obligations: nested_obligations, + }, + placeholder_map, + )) } - fn fast_reject_trait_refs(&mut self, - obligation: &TraitObligation, - impl_trait_ref: &ty::TraitRef) - -> bool - { + fn fast_reject_trait_refs( + &mut self, + obligation: &TraitObligation<'_>, + impl_trait_ref: &ty::TraitRef<'_>, + ) -> bool { // We can avoid creating type variables and doing the full // substitution if we find that any of the input types, when // simplified, do not match. - obligation.predicate.skip_binder().input_types() + obligation + .predicate + .skip_binder() + .input_types() .zip(impl_trait_ref.input_types()) .any(|(obligation_ty, impl_ty)| { let simplified_obligation_ty = fast_reject::simplify_type(self.tcx(), obligation_ty, true); - let simplified_impl_ty = - fast_reject::simplify_type(self.tcx(), impl_ty, false); + let simplified_impl_ty = fast_reject::simplify_type(self.tcx(), impl_ty, false); - simplified_obligation_ty.is_some() && - simplified_impl_ty.is_some() && - simplified_obligation_ty != simplified_impl_ty + simplified_obligation_ty.is_some() + && simplified_impl_ty.is_some() + && simplified_obligation_ty != simplified_impl_ty }) } @@ -3285,50 +3604,54 @@ /// result from the normalization. Normalization is necessary /// because where-clauses are stored in the parameter environment /// unnormalized. - fn match_where_clause_trait_ref(&mut self, - obligation: &TraitObligation<'tcx>, - where_clause_trait_ref: ty::PolyTraitRef<'tcx>) - -> Result>,()> - { + fn match_where_clause_trait_ref( + &mut self, + obligation: &TraitObligation<'tcx>, + where_clause_trait_ref: ty::PolyTraitRef<'tcx>, + ) -> Result>, ()> { self.match_poly_trait_ref(obligation, where_clause_trait_ref) } /// Returns `Ok` if `poly_trait_ref` being true implies that the /// obligation is satisfied. - fn match_poly_trait_ref(&mut self, - obligation: &TraitObligation<'tcx>, - poly_trait_ref: ty::PolyTraitRef<'tcx>) - -> Result>,()> - { - debug!("match_poly_trait_ref: obligation={:?} poly_trait_ref={:?}", - obligation, - poly_trait_ref); - - self.infcx.at(&obligation.cause, obligation.param_env) - .sup(obligation.predicate.to_poly_trait_ref(), poly_trait_ref) - .map(|InferOk { obligations, .. }| obligations) - .map_err(|_| ()) + fn match_poly_trait_ref( + &mut self, + obligation: &TraitObligation<'tcx>, + poly_trait_ref: ty::PolyTraitRef<'tcx>, + ) -> Result>, ()> { + debug!( + "match_poly_trait_ref: obligation={:?} poly_trait_ref={:?}", + obligation, poly_trait_ref + ); + + self.infcx + .at(&obligation.cause, obligation.param_env) + .sup(obligation.predicate.to_poly_trait_ref(), poly_trait_ref) + .map(|InferOk { obligations, .. }| obligations) + .map_err(|_| ()) } /////////////////////////////////////////////////////////////////////////// // Miscellany - fn match_fresh_trait_refs(&self, - previous: &ty::PolyTraitRef<'tcx>, - current: &ty::PolyTraitRef<'tcx>) - -> bool - { + fn match_fresh_trait_refs( + &self, + previous: &ty::PolyTraitRef<'tcx>, + current: &ty::PolyTraitRef<'tcx>, + ) -> bool { let mut matcher = ty::_match::Match::new(self.tcx()); matcher.relate(previous, current).is_ok() } - fn push_stack<'o,'s:'o>(&mut self, - previous_stack: TraitObligationStackList<'s, 'tcx>, - obligation: &'o TraitObligation<'tcx>) - -> TraitObligationStack<'o, 'tcx> - { - let fresh_trait_ref = - obligation.predicate.to_poly_trait_ref().fold_with(&mut self.freshener); + fn push_stack<'o, 's: 'o>( + &mut self, + previous_stack: TraitObligationStackList<'s, 'tcx>, + obligation: &'o TraitObligation<'tcx>, + ) -> TraitObligationStack<'o, 'tcx> { + let fresh_trait_ref = obligation + .predicate + .to_poly_trait_ref() + .fold_with(&mut self.freshener); TraitObligationStack { obligation, @@ -3337,12 +3660,12 @@ } } - fn closure_trait_ref_unnormalized(&mut self, - obligation: &TraitObligation<'tcx>, - closure_def_id: DefId, - substs: ty::ClosureSubsts<'tcx>) - -> ty::PolyTraitRef<'tcx> - { + fn closure_trait_ref_unnormalized( + &mut self, + obligation: &TraitObligation<'tcx>, + closure_def_id: DefId, + substs: ty::ClosureSubsts<'tcx>, + ) -> ty::PolyTraitRef<'tcx> { let closure_type = self.infcx.closure_sig(closure_def_id, substs); // (1) Feels icky to skip the binder here, but OTOH we know @@ -3350,21 +3673,22 @@ // in fact unparameterized (or at least does not reference any // regions bound in the obligation). Still probably some // refactoring could make this nicer. - - self.tcx().closure_trait_ref_and_return_type(obligation.predicate.def_id(), - obligation.predicate - .skip_binder().self_ty(), // (1) - closure_type, - util::TupleArgumentsFlag::No) + self.tcx() + .closure_trait_ref_and_return_type( + obligation.predicate.def_id(), + obligation.predicate.skip_binder().self_ty(), // (1) + closure_type, + util::TupleArgumentsFlag::No, + ) .map_bound(|(trait_ref, _)| trait_ref) } - fn generator_trait_ref_unnormalized(&mut self, - obligation: &TraitObligation<'tcx>, - closure_def_id: DefId, - substs: ty::GeneratorSubsts<'tcx>) - -> ty::PolyTraitRef<'tcx> - { + fn generator_trait_ref_unnormalized( + &mut self, + obligation: &TraitObligation<'tcx>, + closure_def_id: DefId, + substs: ty::GeneratorSubsts<'tcx>, + ) -> ty::PolyTraitRef<'tcx> { let gen_sig = substs.poly_sig(closure_def_id, self.tcx()); // (1) Feels icky to skip the binder here, but OTOH we know @@ -3373,10 +3697,12 @@ // regions bound in the obligation). Still probably some // refactoring could make this nicer. - self.tcx().generator_trait_ref_and_outputs(obligation.predicate.def_id(), - obligation.predicate - .skip_binder().self_ty(), // (1) - gen_sig) + self.tcx() + .generator_trait_ref_and_outputs( + obligation.predicate.def_id(), + obligation.predicate.skip_binder().self_ty(), // (1) + gen_sig, + ) .map_bound(|(trait_ref, ..)| trait_ref) } @@ -3384,16 +3710,16 @@ /// impl or trait. The obligations are substituted and fully /// normalized. This is used when confirming an impl or default /// impl. - fn impl_or_trait_obligations(&mut self, - cause: ObligationCause<'tcx>, - recursion_depth: usize, - param_env: ty::ParamEnv<'tcx>, - def_id: DefId, // of impl or trait - substs: &Substs<'tcx>, // for impl or trait - skol_map: infer::SkolemizationMap<'tcx>, - snapshot: &infer::CombinedSnapshot<'cx, 'tcx>) - -> Vec> - { + fn impl_or_trait_obligations( + &mut self, + cause: ObligationCause<'tcx>, + recursion_depth: usize, + param_env: ty::ParamEnv<'tcx>, + def_id: DefId, // of impl or trait + substs: &Substs<'tcx>, // for impl or trait + placeholder_map: infer::PlaceholderMap<'tcx>, + snapshot: &infer::CombinedSnapshot<'cx, 'tcx>, + ) -> Vec> { debug!("impl_or_trait_obligations(def_id={:?})", def_id); let tcx = self.tcx(); @@ -3413,17 +3739,25 @@ // that order. let predicates = tcx.predicates_of(def_id); assert_eq!(predicates.parent, None); - let mut predicates: Vec<_> = predicates.predicates.iter().flat_map(|predicate| { - let predicate = normalize_with_depth(self, param_env, cause.clone(), recursion_depth, - &predicate.subst(tcx, substs)); - predicate.obligations.into_iter().chain( - Some(Obligation { + let mut predicates: Vec<_> = predicates + .predicates + .iter() + .flat_map(|(predicate, _)| { + let predicate = normalize_with_depth( + self, + param_env, + cause.clone(), + recursion_depth, + &predicate.subst(tcx, substs), + ); + predicate.obligations.into_iter().chain(Some(Obligation { cause: cause.clone(), recursion_depth, param_env, - predicate: predicate.value + predicate: predicate.value, })) - }).collect(); + }) + .collect(); // We are performing deduplication here to avoid exponential blowups // (#38528) from happening, but the real cause of the duplication is @@ -3443,19 +3777,20 @@ } } else { // Three or more elements. Use a general deduplication process. - let mut seen = FxHashSet(); + let mut seen = FxHashSet::default(); predicates.retain(|i| seen.insert(i.clone())); } - self.infcx().plug_leaks(skol_map, snapshot, predicates) + self.infcx() + .plug_leaks(placeholder_map, snapshot, predicates) } } impl<'tcx> TraitObligation<'tcx> { #[allow(unused_comparisons)] - pub fn derived_cause(&self, - variant: fn(DerivedObligationCause<'tcx>) -> ObligationCauseCode<'tcx>) - -> ObligationCause<'tcx> - { + pub fn derived_cause( + &self, + variant: fn(DerivedObligationCause<'tcx>) -> ObligationCauseCode<'tcx>, + ) -> ObligationCause<'tcx> { /*! * Creates a cause for obligations that are derived from * `obligation` by a recursive search (e.g., for a builtin @@ -3474,10 +3809,14 @@ if obligation.recursion_depth >= 0 { let derived_cause = DerivedObligationCause { parent_trait_ref: obligation.predicate.to_poly_trait_ref(), - parent_code: Rc::new(obligation.cause.code.clone()) + parent_code: Rc::new(obligation.cause.code.clone()), }; let derived_code = variant(derived_cause); - ObligationCause::new(obligation.cause.span, obligation.cause.body_id, derived_code) + ObligationCause::new( + obligation.cause.span, + obligation.cause.body_id, + derived_code, + ) } else { obligation.cause.clone() } @@ -3485,70 +3824,60 @@ } impl<'tcx> SelectionCache<'tcx> { - pub fn new() -> SelectionCache<'tcx> { - SelectionCache { - hashmap: Lock::new(FxHashMap()) - } - } - + /// Actually frees the underlying memory in contrast to what stdlib containers do on `clear` pub fn clear(&self) { - *self.hashmap.borrow_mut() = FxHashMap() + *self.hashmap.borrow_mut() = Default::default(); } } impl<'tcx> EvaluationCache<'tcx> { - pub fn new() -> EvaluationCache<'tcx> { - EvaluationCache { - hashmap: Lock::new(FxHashMap()) - } - } - + /// Actually frees the underlying memory in contrast to what stdlib containers do on `clear` pub fn clear(&self) { - *self.hashmap.borrow_mut() = FxHashMap() + *self.hashmap.borrow_mut() = Default::default(); } } -impl<'o,'tcx> TraitObligationStack<'o,'tcx> { - fn list(&'o self) -> TraitObligationStackList<'o,'tcx> { +impl<'o, 'tcx> TraitObligationStack<'o, 'tcx> { + fn list(&'o self) -> TraitObligationStackList<'o, 'tcx> { TraitObligationStackList::with(self) } - fn iter(&'o self) -> TraitObligationStackList<'o,'tcx> { + fn iter(&'o self) -> TraitObligationStackList<'o, 'tcx> { self.list() } } #[derive(Copy, Clone)] -struct TraitObligationStackList<'o,'tcx:'o> { - head: Option<&'o TraitObligationStack<'o,'tcx>> +struct TraitObligationStackList<'o, 'tcx: 'o> { + head: Option<&'o TraitObligationStack<'o, 'tcx>>, } -impl<'o,'tcx> TraitObligationStackList<'o,'tcx> { - fn empty() -> TraitObligationStackList<'o,'tcx> { +impl<'o, 'tcx> TraitObligationStackList<'o, 'tcx> { + fn empty() -> TraitObligationStackList<'o, 'tcx> { TraitObligationStackList { head: None } } - fn with(r: &'o TraitObligationStack<'o,'tcx>) -> TraitObligationStackList<'o,'tcx> { + fn with(r: &'o TraitObligationStack<'o, 'tcx>) -> TraitObligationStackList<'o, 'tcx> { TraitObligationStackList { head: Some(r) } } } -impl<'o,'tcx> Iterator for TraitObligationStackList<'o,'tcx>{ - type Item = &'o TraitObligationStack<'o,'tcx>; +impl<'o, 'tcx> Iterator for TraitObligationStackList<'o, 'tcx> { + type Item = &'o TraitObligationStack<'o, 'tcx>; - fn next(&mut self) -> Option<&'o TraitObligationStack<'o,'tcx>> { + fn next(&mut self) -> Option<&'o TraitObligationStack<'o, 'tcx>> { match self.head { Some(o) => { *self = o.previous; Some(o) } - None => None + None => None, } } } -impl<'o,'tcx> fmt::Debug for TraitObligationStack<'o,'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +impl<'o, 'tcx> fmt::Debug for TraitObligationStack<'o, 'tcx> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "TraitObligationStack({:?})", self.obligation) } } @@ -3556,15 +3885,18 @@ #[derive(Clone, Eq, PartialEq)] pub struct WithDepNode { dep_node: DepNodeIndex, - cached_value: T + cached_value: T, } impl WithDepNode { pub fn new(dep_node: DepNodeIndex, cached_value: T) -> Self { - WithDepNode { dep_node, cached_value } + WithDepNode { + dep_node, + cached_value, + } } - pub fn get(&self, tcx: TyCtxt) -> T { + pub fn get(&self, tcx: TyCtxt<'_, '_, '_>) -> T { tcx.dep_graph.read_index(self.dep_node); self.cached_value.clone() } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/specialize/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/specialize/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/specialize/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/specialize/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -22,7 +22,7 @@ use super::{SelectionContext, FulfillmentContext}; use super::util::impl_trait_ref_and_oblig; -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_data_structures::fx::FxHashSet; use hir::def_id::DefId; use infer::{InferCtxt, InferOk}; use ty::subst::{Subst, Substs}; @@ -100,10 +100,10 @@ } fulfill_implication(infcx, param_env, source_trait_ref, target_impl) - .unwrap_or_else(|_| { + .unwrap_or_else(|_| bug!("When translating substitutions for specialization, the expected \ specialization failed to hold") - }) + ) } specialization_graph::Node::Trait(..) => source_trait_ref.substs, }; @@ -137,17 +137,15 @@ let substs = translate_substs(&infcx, param_env, impl_data.impl_def_id, substs, node_item.node); let substs = infcx.tcx.erase_regions(&substs); - tcx.lift(&substs).unwrap_or_else(|| { + tcx.lift(&substs).unwrap_or_else(|| bug!("find_method: translate_substs \ returned {:?} which contains inference types/regions", - substs); - }) + substs) + ) }); (node_item.item.def_id, substs) } - None => { - bug!("{:?} not found in {:?}", item, impl_data.impl_def_id) - } + None => bug!("{:?} not found in {:?}", item, impl_data.impl_def_id) } } @@ -186,7 +184,7 @@ return false; } - // create a parameter environment corresponding to a (skolemized) instantiation of impl1 + // create a parameter environment corresponding to a (placeholder) instantiation of impl1 let penv = tcx.param_env(impl1_def_id); let impl1_trait_ref = tcx.impl_trait_ref(impl1_def_id).unwrap(); @@ -286,34 +284,13 @@ }) } -pub struct SpecializesCache { - map: FxHashMap<(DefId, DefId), bool>, -} - -impl SpecializesCache { - pub fn new() -> Self { - SpecializesCache { - map: FxHashMap() - } - } - - pub fn check(&self, a: DefId, b: DefId) -> Option { - self.map.get(&(a, b)).cloned() - } - - pub fn insert(&mut self, a: DefId, b: DefId, result: bool) { - self.map.insert((a, b), result); - } -} - // Query provider for `specialization_graph_of`. pub(super) fn specialization_graph_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_id: DefId) -> Lrc { let mut sg = specialization_graph::Graph::new(); - let mut trait_impls = Vec::new(); - tcx.for_each_impl(trait_id, |impl_did| trait_impls.push(impl_did)); + let mut trait_impls = tcx.all_impls(trait_id); // The coherence checking implementation seems to rely on impls being // iterated over (roughly) in definition order, so we are sorting by @@ -367,9 +344,9 @@ "first implementation here".to_string()); err.span_label(impl_span, format!("conflicting implementation{}", - overlap.self_desc - .map_or(String::new(), - |ty| format!(" for `{}`", ty)))); + overlap.self_desc + .map_or(String::new(), + |ty| format!(" for `{}`", ty)))); } Err(cname) => { let msg = match to_pretty_impl_header(tcx, overlap.with_impl) { @@ -398,7 +375,7 @@ /// Recovers the "impl X for Y" signature from `impl_def_id` and returns it as a /// string. -fn to_pretty_impl_header(tcx: TyCtxt, impl_def_id: DefId) -> Option { +fn to_pretty_impl_header(tcx: TyCtxt<'_, '_, '_>, impl_def_id: DefId) -> Option { use std::fmt::Write; let trait_ref = if let Some(tr) = tcx.impl_trait_ref(impl_def_id) { @@ -428,8 +405,10 @@ // The predicates will contain default bounds like `T: Sized`. We need to // remove these bounds, and add `T: ?Sized` to any untouched type parameters. let predicates = tcx.predicates_of(impl_def_id).predicates; - let mut pretty_predicates = Vec::with_capacity(predicates.len()); - for p in predicates { + let mut pretty_predicates = Vec::with_capacity( + predicates.len() + types_without_default_bounds.len()); + + for (p, _) in predicates { if let Some(poly_trait_ref) = p.to_opt_poly_trait_ref() { if Some(poly_trait_ref.def_id()) == sized_trait { types_without_default_bounds.remove(poly_trait_ref.self_ty()); @@ -438,9 +417,11 @@ } pretty_predicates.push(p.to_string()); } + pretty_predicates.extend( types_without_default_bounds.iter().map(|ty| format!("{}: ?Sized", ty)) ); + if !pretty_predicates.is_empty() { write!(w, "\n where {}", pretty_predicates.join(", ")).unwrap(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/specialize/specialization_graph.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/specialize/specialization_graph.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/specialize/specialization_graph.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/specialize/specialization_graph.rs 2018-12-04 23:41:40.000000000 +0000 @@ -142,7 +142,7 @@ possible_sibling, ); - let overlap_error = |overlap: traits::coherence::OverlapResult| { + let overlap_error = |overlap: traits::coherence::OverlapResult<'_>| { // overlap, but no specialization; error out let trait_ref = overlap.impl_header.trait_ref.unwrap(); let self_ty = trait_ref.self_ty(); @@ -390,11 +390,12 @@ let cur = self.current_source.take(); if let Some(Node::Impl(cur_impl)) = cur { let parent = self.specialization_graph.parent(cur_impl); - if parent == self.trait_def_id { - self.current_source = Some(Node::Trait(parent)); + + self.current_source = if parent == self.trait_def_id { + Some(Node::Trait(parent)) } else { - self.current_source = Some(Node::Impl(parent)); - } + Some(Node::Impl(parent)) + }; } cur } @@ -446,7 +447,7 @@ /// Walk up the specialization ancestors of a given impl, starting with that /// impl itself. -pub fn ancestors(tcx: TyCtxt, +pub fn ancestors(tcx: TyCtxt<'_, '_, '_>, trait_def_id: DefId, start_from_impl: DefId) -> Ancestors { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/structural_impls.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/structural_impls.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/structural_impls.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/structural_impls.rs 2018-12-04 23:41:40.000000000 +0000 @@ -21,13 +21,13 @@ // structural impls for the structs in traits impl<'tcx, T: fmt::Debug> fmt::Debug for Normalized<'tcx, T> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "Normalized({:?},{:?})", self.value, self.obligations) } } impl<'tcx, O: fmt::Debug> fmt::Debug for traits::Obligation<'tcx, O> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if ty::tls::with(|tcx| tcx.sess.verbose()) { write!( f, @@ -45,7 +45,7 @@ } impl<'tcx, N: fmt::Debug> fmt::Debug for traits::Vtable<'tcx, N> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { super::VtableImpl(ref v) => write!(f, "{:?}", v), @@ -67,7 +67,7 @@ } impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableImplData<'tcx, N> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, "VtableImpl(impl_def_id={:?}, substs={:?}, nested={:?})", @@ -77,7 +77,7 @@ } impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableGeneratorData<'tcx, N> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, "VtableGenerator(generator_def_id={:?}, substs={:?}, nested={:?})", @@ -87,7 +87,7 @@ } impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableClosureData<'tcx, N> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, "VtableClosure(closure_def_id={:?}, substs={:?}, nested={:?})", @@ -97,13 +97,13 @@ } impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableBuiltinData { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "VtableBuiltin(nested={:?})", self.nested) } } impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableAutoImplData { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, "VtableAutoImplData(trait_def_id={:?}, nested={:?})", @@ -113,7 +113,7 @@ } impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableObjectData<'tcx, N> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, "VtableObject(upcast={:?}, vtable_base={}, nested={:?})", @@ -123,7 +123,7 @@ } impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableFnPointerData<'tcx, N> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, "VtableFnPointer(fn_ty={:?}, nested={:?})", @@ -133,13 +133,13 @@ } impl<'tcx> fmt::Debug for traits::FulfillmentError<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "FulfillmentError({:?},{:?})", self.obligation, self.code) } } impl<'tcx> fmt::Debug for traits::FulfillmentErrorCode<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { super::CodeSelectionError(ref e) => write!(f, "{:?}", e), super::CodeProjectionError(ref e) => write!(f, "{:?}", e), @@ -152,7 +152,7 @@ } impl<'tcx> fmt::Debug for traits::MismatchedProjectionTypes<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "MismatchedProjectionTypes({:?})", self.err) } } @@ -166,16 +166,16 @@ match *self { super::Unimplemented => Some(super::Unimplemented), super::OutputTypeParameterMismatch(a, b, ref err) => { - tcx.lift(&(a, b)).and_then(|(a, b)| { + tcx.lift(&(a, b)).and_then(|(a, b)| tcx.lift(err) .map(|err| super::OutputTypeParameterMismatch(a, b, err)) - }) + ) } super::TraitNotObjectSafe(def_id) => Some(super::TraitNotObjectSafe(def_id)), super::ConstEvalFailure(ref err) => tcx.lift(&**err).map(|err| super::ConstEvalFailure( err.into(), )), - super::Overflow => bug!(), // FIXME: ape ConstEvalFailure? + super::Overflow => Some(super::Overflow), } } } @@ -193,10 +193,10 @@ super::ReferenceOutlivesReferent(ty) => { tcx.lift(&ty).map(super::ReferenceOutlivesReferent) } - super::ObjectTypeBound(ty, r) => tcx.lift(&ty).and_then(|ty| { + super::ObjectTypeBound(ty, r) => tcx.lift(&ty).and_then(|ty| tcx.lift(&r) - .and_then(|r| Some(super::ObjectTypeBound(ty, r))) - }), + .and_then(|r| Some(super::ObjectTypeBound(ty, r))) + ), super::ObjectCastObligation(ty) => tcx.lift(&ty).map(super::ObjectCastObligation), super::AssignmentLhsSized => Some(super::AssignmentLhsSized), super::TupleInitializerSized => Some(super::TupleInitializerSized), @@ -245,13 +245,13 @@ impl<'a, 'tcx> Lift<'tcx> for traits::DerivedObligationCause<'a> { type Lifted = traits::DerivedObligationCause<'tcx>; fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option { - tcx.lift(&self.parent_trait_ref).and_then(|trait_ref| { + tcx.lift(&self.parent_trait_ref).and_then(|trait_ref| tcx.lift(&*self.parent_code) - .map(|code| traits::DerivedObligationCause { - parent_trait_ref: trait_ref, - parent_code: Rc::new(code), - }) - }) + .map(|code| traits::DerivedObligationCause { + parent_trait_ref: trait_ref, + parent_code: Rc::new(code), + }) + ) } } @@ -275,40 +275,40 @@ impl_def_id, substs, nested, - }) => tcx.lift(&substs).map(|substs| { + }) => tcx.lift(&substs).map(|substs| traits::VtableImpl(traits::VtableImplData { impl_def_id, substs, nested, }) - }), + ), traits::VtableAutoImpl(t) => Some(traits::VtableAutoImpl(t)), traits::VtableGenerator(traits::VtableGeneratorData { generator_def_id, substs, nested, - }) => tcx.lift(&substs).map(|substs| { + }) => tcx.lift(&substs).map(|substs| traits::VtableGenerator(traits::VtableGeneratorData { generator_def_id: generator_def_id, substs: substs, nested: nested, }) - }), + ), traits::VtableClosure(traits::VtableClosureData { closure_def_id, substs, nested, - }) => tcx.lift(&substs).map(|substs| { + }) => tcx.lift(&substs).map(|substs| traits::VtableClosure(traits::VtableClosureData { closure_def_id, substs, nested, }) - }), + ), traits::VtableFnPointer(traits::VtableFnPointerData { fn_ty, nested }) => { - tcx.lift(&fn_ty).map(|fn_ty| { + tcx.lift(&fn_ty).map(|fn_ty| traits::VtableFnPointer(traits::VtableFnPointerData { fn_ty, nested }) - }) + ) } traits::VtableParam(n) => Some(traits::VtableParam(n)), traits::VtableBuiltin(n) => Some(traits::VtableBuiltin(n)), @@ -316,13 +316,13 @@ upcast_trait_ref, vtable_base, nested, - }) => tcx.lift(&upcast_trait_ref).map(|trait_ref| { + }) => tcx.lift(&upcast_trait_ref).map(|trait_ref| traits::VtableObject(traits::VtableObjectData { upcast_trait_ref: trait_ref, vtable_base, nested, }) - }), + ), } } } @@ -409,7 +409,7 @@ } impl<'tcx> fmt::Display for traits::WhereClause<'tcx> { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { use traits::WhereClause::*; match self { @@ -422,7 +422,7 @@ } impl<'tcx> fmt::Display for traits::WellFormed<'tcx> { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { use traits::WellFormed::*; match self { @@ -433,7 +433,7 @@ } impl<'tcx> fmt::Display for traits::FromEnv<'tcx> { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { use traits::FromEnv::*; match self { @@ -444,7 +444,7 @@ } impl<'tcx> fmt::Display for traits::DomainGoal<'tcx> { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { use traits::DomainGoal::*; match self { @@ -457,7 +457,7 @@ } impl fmt::Display for traits::QuantifierKind { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { use traits::QuantifierKind::*; match self { @@ -468,8 +468,8 @@ } impl<'tcx> fmt::Display for traits::Goal<'tcx> { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - use traits::Goal::*; + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { + use traits::GoalKind::*; match self { Implies(hypotheses, goal) => { @@ -495,8 +495,8 @@ } impl<'tcx> fmt::Display for traits::ProgramClause<'tcx> { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - let traits::ProgramClause { goal, hypotheses } = self; + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { + let traits::ProgramClause { goal, hypotheses, .. } = self; write!(fmt, "{}", goal)?; if !hypotheses.is_empty() { write!(fmt, " :- ")?; @@ -512,7 +512,7 @@ } impl<'tcx> fmt::Display for traits::Clause<'tcx> { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { use traits::Clause::*; match self { @@ -598,25 +598,25 @@ } EnumTypeFoldableImpl! { - impl<'tcx> TypeFoldable<'tcx> for traits::Goal<'tcx> { - (traits::Goal::Implies)(hypotheses, goal), - (traits::Goal::And)(goal1, goal2), - (traits::Goal::Not)(goal), - (traits::Goal::DomainGoal)(domain_goal), - (traits::Goal::Quantified)(qkind, goal), - (traits::Goal::CannotProve), + impl<'tcx> TypeFoldable<'tcx> for traits::GoalKind<'tcx> { + (traits::GoalKind::Implies)(hypotheses, goal), + (traits::GoalKind::And)(goal1, goal2), + (traits::GoalKind::Not)(goal), + (traits::GoalKind::DomainGoal)(domain_goal), + (traits::GoalKind::Quantified)(qkind, goal), + (traits::GoalKind::CannotProve), } } EnumLiftImpl! { - impl<'a, 'tcx> Lift<'tcx> for traits::Goal<'a> { - type Lifted = traits::Goal<'tcx>; - (traits::Goal::Implies)(hypotheses, goal), - (traits::Goal::And)(goal1, goal2), - (traits::Goal::Not)(goal), - (traits::Goal::DomainGoal)(domain_goal), - (traits::Goal::Quantified)(kind, goal), - (traits::Goal::CannotProve), + impl<'a, 'tcx> Lift<'tcx> for traits::GoalKind<'a> { + type Lifted = traits::GoalKind<'tcx>; + (traits::GoalKind::Implies)(hypotheses, goal), + (traits::GoalKind::And)(goal1, goal2), + (traits::GoalKind::Not)(goal), + (traits::GoalKind::DomainGoal)(domain_goal), + (traits::GoalKind::Quantified)(kind, goal), + (traits::GoalKind::CannotProve), } } @@ -633,7 +633,7 @@ } } -impl<'tcx> TypeFoldable<'tcx> for &'tcx traits::Goal<'tcx> { +impl<'tcx> TypeFoldable<'tcx> for traits::Goal<'tcx> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { let v = (**self).fold_with(folder); folder.tcx().mk_goal(v) @@ -647,10 +647,15 @@ BraceStructTypeFoldableImpl! { impl<'tcx> TypeFoldable<'tcx> for traits::ProgramClause<'tcx> { goal, - hypotheses + hypotheses, + category, } } +CloneTypeFoldableAndLiftImpls! { + traits::ProgramClauseCategory, +} + EnumTypeFoldableImpl! { impl<'tcx> TypeFoldable<'tcx> for traits::Clause<'tcx> { (traits::Clause::Implies)(clause), @@ -658,7 +663,43 @@ } } -impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { +BraceStructTypeFoldableImpl! { + impl<'tcx> TypeFoldable<'tcx> for traits::Environment<'tcx> { clauses } +} + +BraceStructTypeFoldableImpl! { + impl<'tcx, G> TypeFoldable<'tcx> for traits::InEnvironment<'tcx, G> { + environment, + goal + } where G: TypeFoldable<'tcx> +} + +impl<'a, 'tcx> Lift<'tcx> for traits::Environment<'a> { + type Lifted = traits::Environment<'tcx>; + fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option { + tcx.lift(&self.clauses).map(|clauses| { + traits::Environment { + clauses, + } + }) + } +} + +impl<'a, 'tcx, G: Lift<'tcx>> Lift<'tcx> for traits::InEnvironment<'a, G> { + type Lifted = traits::InEnvironment<'tcx, G::Lifted>; + fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option { + tcx.lift(&self.environment).and_then(|environment| { + tcx.lift(&self.goal).map(|goal| { + traits::InEnvironment { + environment, + goal, + } + }) + }) + } +} + +impl<'tcx> TypeFoldable<'tcx> for traits::Clauses<'tcx> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { let v = self.iter() .map(|t| t.fold_with(folder)) diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/traits/util.rs rustc-1.31.0+dfsg1+llvm/src/librustc/traits/util.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/traits/util.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/traits/util.rs 2018-12-04 23:41:40.000000000 +0000 @@ -59,7 +59,7 @@ impl<'a, 'gcx, 'tcx> PredicateSet<'a, 'gcx, 'tcx> { fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> PredicateSet<'a, 'gcx, 'tcx> { - PredicateSet { tcx: tcx, set: FxHashSet() } + PredicateSet { tcx: tcx, set: Default::default() } } fn insert(&mut self, pred: &ty::Predicate<'tcx>) -> bool { @@ -137,7 +137,7 @@ let mut predicates: Vec<_> = predicates.predicates .iter() - .map(|p| p.subst_supertrait(tcx, &data.to_poly_trait_ref())) + .map(|(p, _)| p.subst_supertrait(tcx, &data.to_poly_trait_ref())) .collect(); debug!("super_predicates: data={:?} predicates={:?}", @@ -311,7 +311,7 @@ self.stack.extend( predicates.predicates .iter() - .filter_map(|p| p.to_opt_poly_trait_ref()) + .filter_map(|(p, _)| p.to_opt_poly_trait_ref()) .map(|t| t.def_id()) .filter(|&super_def_id| visited.insert(super_def_id))); Some(def_id) @@ -346,8 +346,7 @@ Some(ty::Predicate::Trait(data)) => { return Some(data.to_poly_trait_ref()); } - Some(_) => { - } + Some(_) => {} } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/cast.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/cast.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/cast.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/cast.rs 2018-12-04 23:41:40.000000000 +0000 @@ -58,6 +58,8 @@ } impl<'tcx> CastTy<'tcx> { + /// Returns `Some` for integral/pointer casts. + /// casts like unsizing casts will return `None` pub fn from_ty(t: Ty<'tcx>) -> Option> { match t.sty { ty::Bool => Some(CastTy::Int(IntTy::Bool)), diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/codec.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/codec.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/codec.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/codec.rs 2018-12-04 23:41:40.000000000 +0000 @@ -109,8 +109,9 @@ { predicates.parent.encode(encoder)?; predicates.predicates.len().encode(encoder)?; - for predicate in &predicates.predicates { - encode_with_shorthand(encoder, predicate, &cache)? + for (predicate, span) in &predicates.predicates { + encode_with_shorthand(encoder, predicate, &cache)?; + span.encode(encoder)?; } Ok(()) } @@ -177,18 +178,19 @@ Ok(ty::GenericPredicates { parent: Decodable::decode(decoder)?, predicates: (0..decoder.read_usize()?).map(|_| { - // Handle shorthands first, if we have an usize > 0x80. - if decoder.positioned_at_shorthand() { - let pos = decoder.read_usize()?; - assert!(pos >= SHORTHAND_OFFSET); - let shorthand = pos - SHORTHAND_OFFSET; - - decoder.with_position(shorthand, ty::Predicate::decode) - } else { - ty::Predicate::decode(decoder) - } - }) - .collect::, _>>()?, + // Handle shorthands first, if we have an usize > 0x80. + let predicate = if decoder.positioned_at_shorthand() { + let pos = decoder.read_usize()?; + assert!(pos >= SHORTHAND_OFFSET); + let shorthand = pos - SHORTHAND_OFFSET; + + decoder.with_position(shorthand, ty::Predicate::decode) + } else { + ty::Predicate::decode(decoder) + }?; + Ok((predicate, Decodable::decode(decoder)?)) + }) + .collect::, _>>()?, }) } @@ -265,7 +267,7 @@ #[inline] pub fn decode_allocation<'a, 'tcx, D>(decoder: &mut D) - -> Result<&'tcx Allocation, D::Error> + -> Result<&'tcx Allocation, D::Error> where D: TyDecoder<'a, 'tcx>, 'tcx: 'a, { @@ -318,7 +320,7 @@ read_f64 -> f64; read_f32 -> f32; read_char -> char; - read_str -> Cow; + read_str -> Cow<'_, str>; } fn error(&mut self, err: &str) -> Self::Error { @@ -415,4 +417,3 @@ } } } - diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/constness.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/constness.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/constness.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/constness.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,111 @@ +use ty::query::Providers; +use hir::def_id::DefId; +use hir; +use ty::TyCtxt; +use syntax_pos::symbol::Symbol; +use hir::map::blocks::FnLikeNode; +use syntax::attr; +use rustc_target::spec::abi; + +impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { + /// Whether the `def_id` counts as const fn in your current crate, considering all active + /// feature gates + pub fn is_const_fn(self, def_id: DefId) -> bool { + self.is_const_fn_raw(def_id) && match self.lookup_stability(def_id) { + Some(stab) => match stab.const_stability { + // has a `rustc_const_unstable` attribute, check whether the user enabled the + // corresponding feature gate + Some(feature_name) => self.features() + .declared_lib_features + .iter() + .any(|&(sym, _)| sym == feature_name), + // the function has no stability attribute, it is stable as const fn or the user + // needs to use feature gates to use the function at all + None => true, + }, + // functions without stability are either stable user written const fn or the user is + // using feature gates and we thus don't care what they do + None => true, + } + } + + /// Whether the `def_id` is an unstable const fn and what feature gate is necessary to enable it + pub fn is_unstable_const_fn(self, def_id: DefId) -> Option { + if self.is_const_fn_raw(def_id) { + self.lookup_stability(def_id)?.const_stability + } else { + None + } + } + + /// Returns true if this function must conform to `min_const_fn` + pub fn is_min_const_fn(self, def_id: DefId) -> bool { + if self.features().staged_api { + // some intrinsics are waved through if called inside the + // standard library. Users never need to call them directly + if let abi::Abi::RustIntrinsic = self.fn_sig(def_id).abi() { + assert!(!self.is_const_fn(def_id)); + match &self.item_name(def_id).as_str()[..] { + | "size_of" + | "min_align_of" + | "needs_drop" + => return true, + _ => {}, + } + } + // in order for a libstd function to be considered min_const_fn + // it needs to be stable and have no `rustc_const_unstable` attribute + match self.lookup_stability(def_id) { + // stable functions with unstable const fn aren't `min_const_fn` + Some(&attr::Stability { const_stability: Some(_), .. }) => false, + // unstable functions don't need to conform + Some(&attr::Stability { ref level, .. }) if level.is_unstable() => false, + // everything else needs to conform, because it would be callable from + // other `min_const_fn` functions + _ => true, + } + } else { + // users enabling the `const_fn` feature gate can do what they want + !self.sess.features_untracked().const_fn + } + } +} + + +pub fn provide<'tcx>(providers: &mut Providers<'tcx>) { + /// only checks whether the function has a `const` modifier + fn is_const_fn_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool { + let node_id = tcx.hir.as_local_node_id(def_id) + .expect("Non-local call to local provider is_const_fn"); + + if let Some(fn_like) = FnLikeNode::from_node(tcx.hir.get(node_id)) { + fn_like.constness() == hir::Constness::Const + } else { + false + } + } + + fn is_promotable_const_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool { + tcx.is_const_fn(def_id) && match tcx.lookup_stability(def_id) { + Some(stab) => { + if cfg!(debug_assertions) && stab.promotable { + let sig = tcx.fn_sig(def_id); + assert_eq!( + sig.unsafety(), + hir::Unsafety::Normal, + "don't mark const unsafe fns as promotable", + // https://github.com/rust-lang/rust/pull/53851#issuecomment-418760682 + ); + } + stab.promotable + }, + None => false, + } + } + + *providers = Providers { + is_const_fn_raw, + is_promotable_const_fn, + ..*providers + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/context.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/context.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/context.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/context.rs 2018-12-04 23:41:40.000000000 +0000 @@ -17,7 +17,7 @@ use session::config::{BorrowckMode, OutputFilenames}; use session::config::CrateType; use middle; -use hir::{TraitCandidate, HirId, ItemLocalId}; +use hir::{TraitCandidate, HirId, ItemKind, ItemLocalId, Node}; use hir::def::{Def, Export}; use hir::def_id::{CrateNum, DefId, DefIndex, LOCAL_CRATE}; use hir::map as hir_map; @@ -31,12 +31,12 @@ use middle::lang_items; use middle::resolve_lifetime::{self, ObjectLifetimeDefault}; use middle::stability; -use mir::{self, Mir, interpret}; +use mir::{self, Mir, interpret, ProjectionKind}; use mir::interpret::Allocation; -use ty::subst::{CanonicalSubsts, Kind, Substs, Subst}; +use ty::subst::{CanonicalUserSubsts, Kind, Substs, Subst}; use ty::ReprOptions; use traits; -use traits::{Clause, Clauses, Goal, Goals}; +use traits::{Clause, Clauses, GoalKind, Goal, Goals}; use ty::{self, Ty, TypeAndMut}; use ty::{TyS, TyKind, List}; use ty::{AdtKind, AdtDef, ClosureSubsts, GeneratorSubsts, Region, Const}; @@ -50,7 +50,8 @@ use ty::steal::Steal; use ty::BindingMode; use ty::CanonicalTy; -use util::nodemap::{DefIdSet, ItemLocalMap}; +use ty::CanonicalPolyFnSig; +use util::nodemap::{DefIdMap, DefIdSet, ItemLocalMap}; use util::nodemap::{FxHashMap, FxHashSet}; use smallvec::SmallVec; use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap, @@ -89,13 +90,14 @@ impl<'tcx> AllArenas<'tcx> { pub fn new() -> Self { AllArenas { - global: WorkerLocal::new(|_| GlobalArenas::new()), - interner: SyncDroplessArena::new(), + global: WorkerLocal::new(|_| GlobalArenas::default()), + interner: SyncDroplessArena::default(), } } } /// Internal storage +#[derive(Default)] pub struct GlobalArenas<'tcx> { // internings layout: TypedArena, @@ -111,21 +113,6 @@ const_allocs: TypedArena, } -impl<'tcx> GlobalArenas<'tcx> { - pub fn new() -> GlobalArenas<'tcx> { - GlobalArenas { - layout: TypedArena::new(), - generics: TypedArena::new(), - trait_def: TypedArena::new(), - adt_def: TypedArena::new(), - steal_mir: TypedArena::new(), - mir: TypedArena::new(), - tables: TypedArena::new(), - const_allocs: TypedArena::new(), - } - } -} - type InternedSet<'tcx, T> = Lock>>; pub struct CtxtInterners<'tcx> { @@ -143,7 +130,9 @@ predicates: InternedSet<'tcx, List>>, const_: InternedSet<'tcx, Const<'tcx>>, clauses: InternedSet<'tcx, List>>, - goals: InternedSet<'tcx, List>>, + goal: InternedSet<'tcx, GoalKind<'tcx>>, + goal_list: InternedSet<'tcx, List>>, + projs: InternedSet<'tcx, List>>, } impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> { @@ -159,7 +148,9 @@ predicates: Default::default(), const_: Default::default(), clauses: Default::default(), - goals: Default::default(), + goal: Default::default(), + goal_list: Default::default(), + projs: Default::default(), } } @@ -190,8 +181,8 @@ // types/regions in the global interner if local as *const _ as usize == global as *const _ as usize { bug!("Attempted to intern `{:?}` which contains \ - inference types/regions in the global type context", - &ty_struct); + inference types/regions in the global type context", + &ty_struct); } // Don't be &mut TyS. @@ -272,9 +263,9 @@ bug!("node {} with HirId::owner {:?} cannot be placed in \ TypeckTables with local_id_root {:?}", - tcx.hir.node_to_string(node_id), - DefId::local(hir_id.owner), - local_id_root) + tcx.hir.node_to_string(node_id), + DefId::local(hir_id.owner), + local_id_root) }); } } else { @@ -301,7 +292,7 @@ self.data.get(&id.local_id) } - pub fn iter(&self) -> hash_map::Iter { + pub fn iter(&self) -> hash_map::Iter<'_, hir::ItemLocalId, V> { self.data.iter() } } @@ -325,7 +316,7 @@ self.data.get_mut(&id.local_id) } - pub fn entry(&mut self, id: hir::HirId) -> Entry { + pub fn entry(&mut self, id: hir::HirId) -> Entry<'_, hir::ItemLocalId, V> { validate_hir_id_for_typeck_tables(self.local_id_root, id, true); self.data.entry(id.local_id) } @@ -356,10 +347,6 @@ /// belongs, but it may not exist if it's a tuple field (`tuple.0`). field_indices: ItemLocalMap, - /// Stores the canonicalized types provided by the user. See also - /// `AscribeUserType` statement in MIR. - user_provided_tys: ItemLocalMap>, - /// Stores the types for various nodes in the AST. Note that this table /// is not guaranteed to be populated until after typeck. See /// typeck::check::fn_ctxt for details. @@ -371,6 +358,14 @@ /// other items. node_substs: ItemLocalMap<&'tcx Substs<'tcx>>, + /// Stores the canonicalized types provided by the user. See also + /// `AscribeUserType` statement in MIR. + user_provided_tys: ItemLocalMap>, + + /// Stores the canonicalized types provided by the user. See also + /// `AscribeUserType` statement in MIR. + pub user_provided_sigs: DefIdMap>, + /// Stores the substitutions that the user explicitly gave (if any) /// attached to `id`. These will not include any inferred /// values. The canonical form is used to capture things like `_` @@ -381,7 +376,7 @@ /// If the user wrote `foo.collect::>()`, then the /// canonical substitutions would include only `for { Vec /// }`. - user_substs: ItemLocalMap>, + user_substs: ItemLocalMap>, adjustments: ItemLocalMap>>, @@ -454,21 +449,22 @@ type_dependent_defs: ItemLocalMap(), field_indices: ItemLocalMap(), user_provided_tys: ItemLocalMap(), + user_provided_sigs: Default::default(), node_types: ItemLocalMap(), node_substs: ItemLocalMap(), user_substs: ItemLocalMap(), adjustments: ItemLocalMap(), pat_binding_modes: ItemLocalMap(), pat_adjustments: ItemLocalMap(), - upvar_capture_map: FxHashMap(), + upvar_capture_map: Default::default(), closure_kind_origins: ItemLocalMap(), liberated_fn_sigs: ItemLocalMap(), fru_field_types: ItemLocalMap(), cast_kinds: ItemLocalMap(), used_trait_imports: Lrc::new(DefIdSet()), tainted_by_errors: false, - free_region_map: FreeRegionMap::new(), - concrete_existential_types: FxHashMap(), + free_region_map: Default::default(), + concrete_existential_types: Default::default(), } } @@ -483,56 +479,56 @@ } } - pub fn type_dependent_defs(&self) -> LocalTableInContext { + pub fn type_dependent_defs(&self) -> LocalTableInContext<'_, Def> { LocalTableInContext { local_id_root: self.local_id_root, data: &self.type_dependent_defs } } - pub fn type_dependent_defs_mut(&mut self) -> LocalTableInContextMut { + pub fn type_dependent_defs_mut(&mut self) -> LocalTableInContextMut<'_, Def> { LocalTableInContextMut { local_id_root: self.local_id_root, data: &mut self.type_dependent_defs } } - pub fn field_indices(&self) -> LocalTableInContext { + pub fn field_indices(&self) -> LocalTableInContext<'_, usize> { LocalTableInContext { local_id_root: self.local_id_root, data: &self.field_indices } } - pub fn field_indices_mut(&mut self) -> LocalTableInContextMut { + pub fn field_indices_mut(&mut self) -> LocalTableInContextMut<'_, usize> { LocalTableInContextMut { local_id_root: self.local_id_root, data: &mut self.field_indices } } - pub fn user_provided_tys(&self) -> LocalTableInContext> { + pub fn user_provided_tys(&self) -> LocalTableInContext<'_, CanonicalTy<'tcx>> { LocalTableInContext { local_id_root: self.local_id_root, data: &self.user_provided_tys } } - pub fn user_provided_tys_mut(&mut self) -> LocalTableInContextMut> { + pub fn user_provided_tys_mut(&mut self) -> LocalTableInContextMut<'_, CanonicalTy<'tcx>> { LocalTableInContextMut { local_id_root: self.local_id_root, data: &mut self.user_provided_tys } } - pub fn node_types(&self) -> LocalTableInContext> { + pub fn node_types(&self) -> LocalTableInContext<'_, Ty<'tcx>> { LocalTableInContext { local_id_root: self.local_id_root, data: &self.node_types } } - pub fn node_types_mut(&mut self) -> LocalTableInContextMut> { + pub fn node_types_mut(&mut self) -> LocalTableInContextMut<'_, Ty<'tcx>> { LocalTableInContextMut { local_id_root: self.local_id_root, data: &mut self.node_types @@ -540,16 +536,13 @@ } pub fn node_id_to_type(&self, id: hir::HirId) -> Ty<'tcx> { - match self.node_id_to_type_opt(id) { - Some(ty) => ty, - None => { - bug!("node_id_to_type: no type for node `{}`", - tls::with(|tcx| { - let id = tcx.hir.hir_to_node_id(id); - tcx.hir.node_to_string(id) - })) - } - } + self.node_id_to_type_opt(id).unwrap_or_else(|| + bug!("node_id_to_type: no type for node `{}`", + tls::with(|tcx| { + let id = tcx.hir.hir_to_node_id(id); + tcx.hir.node_to_string(id) + })) + ) } pub fn node_id_to_type_opt(&self, id: hir::HirId) -> Option> { @@ -557,7 +550,7 @@ self.node_types.get(&id.local_id).cloned() } - pub fn node_substs_mut(&mut self) -> LocalTableInContextMut<&'tcx Substs<'tcx>> { + pub fn node_substs_mut(&mut self) -> LocalTableInContextMut<'_, &'tcx Substs<'tcx>> { LocalTableInContextMut { local_id_root: self.local_id_root, data: &mut self.node_substs @@ -566,7 +559,7 @@ pub fn node_substs(&self, id: hir::HirId) -> &'tcx Substs<'tcx> { validate_hir_id_for_typeck_tables(self.local_id_root, id, false); - self.node_substs.get(&id.local_id).cloned().unwrap_or(Substs::empty()) + self.node_substs.get(&id.local_id).cloned().unwrap_or_else(|| Substs::empty()) } pub fn node_substs_opt(&self, id: hir::HirId) -> Option<&'tcx Substs<'tcx>> { @@ -574,14 +567,14 @@ self.node_substs.get(&id.local_id).cloned() } - pub fn user_substs_mut(&mut self) -> LocalTableInContextMut> { + pub fn user_substs_mut(&mut self) -> LocalTableInContextMut<'_, CanonicalUserSubsts<'tcx>> { LocalTableInContextMut { local_id_root: self.local_id_root, data: &mut self.user_substs } } - pub fn user_substs(&self, id: hir::HirId) -> Option> { + pub fn user_substs(&self, id: hir::HirId) -> Option> { validate_hir_id_for_typeck_tables(self.local_id_root, id, false); self.user_substs.get(&id.local_id).cloned() } @@ -614,7 +607,7 @@ self.node_id_to_type_opt(expr.hir_id) } - pub fn adjustments(&self) -> LocalTableInContext>> { + pub fn adjustments(&self) -> LocalTableInContext<'_, Vec>> { LocalTableInContext { local_id_root: self.local_id_root, data: &self.adjustments @@ -622,7 +615,7 @@ } pub fn adjustments_mut(&mut self) - -> LocalTableInContextMut>> { + -> LocalTableInContextMut<'_, Vec>> { LocalTableInContextMut { local_id_root: self.local_id_root, data: &mut self.adjustments @@ -663,7 +656,7 @@ } } - pub fn pat_binding_modes(&self) -> LocalTableInContext { + pub fn pat_binding_modes(&self) -> LocalTableInContext<'_, BindingMode> { LocalTableInContext { local_id_root: self.local_id_root, data: &self.pat_binding_modes @@ -671,14 +664,14 @@ } pub fn pat_binding_modes_mut(&mut self) - -> LocalTableInContextMut { + -> LocalTableInContextMut<'_, BindingMode> { LocalTableInContextMut { local_id_root: self.local_id_root, data: &mut self.pat_binding_modes } } - pub fn pat_adjustments(&self) -> LocalTableInContext>> { + pub fn pat_adjustments(&self) -> LocalTableInContext<'_, Vec>> { LocalTableInContext { local_id_root: self.local_id_root, data: &self.pat_adjustments, @@ -686,7 +679,7 @@ } pub fn pat_adjustments_mut(&mut self) - -> LocalTableInContextMut>> { + -> LocalTableInContextMut<'_, Vec>> { LocalTableInContextMut { local_id_root: self.local_id_root, data: &mut self.pat_adjustments, @@ -697,56 +690,56 @@ self.upvar_capture_map[&upvar_id] } - pub fn closure_kind_origins(&self) -> LocalTableInContext<(Span, ast::Name)> { + pub fn closure_kind_origins(&self) -> LocalTableInContext<'_, (Span, ast::Name)> { LocalTableInContext { local_id_root: self.local_id_root, data: &self.closure_kind_origins } } - pub fn closure_kind_origins_mut(&mut self) -> LocalTableInContextMut<(Span, ast::Name)> { + pub fn closure_kind_origins_mut(&mut self) -> LocalTableInContextMut<'_, (Span, ast::Name)> { LocalTableInContextMut { local_id_root: self.local_id_root, data: &mut self.closure_kind_origins } } - pub fn liberated_fn_sigs(&self) -> LocalTableInContext> { + pub fn liberated_fn_sigs(&self) -> LocalTableInContext<'_, ty::FnSig<'tcx>> { LocalTableInContext { local_id_root: self.local_id_root, data: &self.liberated_fn_sigs } } - pub fn liberated_fn_sigs_mut(&mut self) -> LocalTableInContextMut> { + pub fn liberated_fn_sigs_mut(&mut self) -> LocalTableInContextMut<'_, ty::FnSig<'tcx>> { LocalTableInContextMut { local_id_root: self.local_id_root, data: &mut self.liberated_fn_sigs } } - pub fn fru_field_types(&self) -> LocalTableInContext>> { + pub fn fru_field_types(&self) -> LocalTableInContext<'_, Vec>> { LocalTableInContext { local_id_root: self.local_id_root, data: &self.fru_field_types } } - pub fn fru_field_types_mut(&mut self) -> LocalTableInContextMut>> { + pub fn fru_field_types_mut(&mut self) -> LocalTableInContextMut<'_, Vec>> { LocalTableInContextMut { local_id_root: self.local_id_root, data: &mut self.fru_field_types } } - pub fn cast_kinds(&self) -> LocalTableInContext { + pub fn cast_kinds(&self) -> LocalTableInContext<'_, ty::cast::CastKind> { LocalTableInContext { local_id_root: self.local_id_root, data: &self.cast_kinds } } - pub fn cast_kinds_mut(&mut self) -> LocalTableInContextMut { + pub fn cast_kinds_mut(&mut self) -> LocalTableInContextMut<'_, ty::cast::CastKind> { LocalTableInContextMut { local_id_root: self.local_id_root, data: &mut self.cast_kinds @@ -763,6 +756,7 @@ ref type_dependent_defs, ref field_indices, ref user_provided_tys, + ref user_provided_sigs, ref node_types, ref node_substs, ref user_substs, @@ -786,6 +780,7 @@ type_dependent_defs.hash_stable(hcx, hasher); field_indices.hash_stable(hcx, hasher); user_provided_tys.hash_stable(hcx, hasher); + user_provided_sigs.hash_stable(hcx, hasher); node_types.hash_stable(hcx, hasher); node_substs.hash_stable(hcx, hasher); user_substs.hash_stable(hcx, hasher); @@ -829,12 +824,10 @@ impl<'tcx> CommonTypes<'tcx> { fn new(interners: &CtxtInterners<'tcx>) -> CommonTypes<'tcx> { // Ensure our type representation does not grow - #[cfg(all(not(stage0), target_pointer_width = "64"))] - #[allow(dead_code)] - static ASSERT_TY_KIND: () = [()][!(::std::mem::size_of::() <= 24) as usize]; - #[cfg(all(not(stage0), target_pointer_width = "64"))] - #[allow(dead_code)] - static ASSERT_TYS: () = [()][!(::std::mem::size_of::() <= 32) as usize]; + #[cfg(target_pointer_width = "64")] + static_assert!(ASSERT_TY_KIND: ::std::mem::size_of::>() <= 24); + #[cfg(target_pointer_width = "64")] + static_assert!(ASSERT_TYS: ::std::mem::size_of::>() <= 32); let mk = |sty| CtxtInterners::intern_ty(interners, interners, sty); let mk_region = |r| { @@ -872,6 +865,18 @@ } } +// This struct contains information regarding the `ReFree(FreeRegion)` corresponding to a lifetime +// conflict. +#[derive(Debug)] +pub struct FreeRegionInfo { + // def id corresponding to FreeRegion + pub def_id: DefId, + // the bound region corresponding to FreeRegion + pub boundregion: ty::BoundRegion, + // checks if bound region is in Impl Item + pub is_impl_item: bool, +} + /// The central data structure of the compiler. It stores references /// to the various **arenas** and also houses the results of the /// various **compiler queries** that have been performed. See the @@ -928,7 +933,9 @@ maybe_unused_trait_imports: FxHashSet, maybe_unused_extern_crates: Vec<(DefId, Span)>, - pub extern_prelude: FxHashSet, + /// Extern prelude entries. The value is `true` if the entry was introduced + /// via `extern crate` item and not `--extern` option or compiler built-in. + pub extern_prelude: FxHashMap, // Internal cache for metadata decoding. No need to track deps on this. pub rcache: Lock>>, @@ -1121,37 +1128,6 @@ local as usize == global as usize } - /// Returns true if this function must conform to `min_const_fn` - pub fn is_min_const_fn(self, def_id: DefId) -> bool { - if self.features().staged_api { - // some intrinsics are waved through if called inside the - // standard library. Users never need to call them directly - if let abi::Abi::RustIntrinsic = self.fn_sig(def_id).abi() { - assert!(!self.is_const_fn(def_id)); - match &self.item_name(def_id).as_str()[..] { - | "size_of" - | "min_align_of" - => return true, - _ => {}, - } - } - // in order for a libstd function to be considered min_const_fn - // it needs to be stable and have no `rustc_const_unstable` attribute - match self.lookup_stability(def_id) { - // stable functions with unstable const fn aren't `min_const_fn` - Some(&attr::Stability { const_stability: Some(_), .. }) => false, - // unstable functions don't need to conform - Some(&attr::Stability { ref level, .. }) if level.is_unstable() => false, - // everything else needs to conform, because it would be callable from - // other `min_const_fn` functions - _ => true, - } - } else { - // users enabling the `const_fn` can do what they want - !self.sess.features_untracked().const_fn - } - } - /// Create a type context and call the closure with a `TyCtxt` reference /// to the context. The closure enforces that the type context and any interned /// value (types, substs, etc.) can only be used while `ty::tls` has a valid @@ -1212,13 +1188,13 @@ None }; - let mut trait_map: FxHashMap<_, Lrc>> = FxHashMap(); + let mut trait_map: FxHashMap<_, Lrc>> = FxHashMap::default(); for (k, v) in resolutions.trait_map { let hir_id = hir.node_to_hir_id(k); let map = trait_map.entry(hir_id.owner).or_default(); Lrc::get_mut(map).unwrap() - .insert(hir_id.local_id, - Lrc::new(StableVec::new(v))); + .insert(hir_id.local_id, + Lrc::new(StableVec::new(v))); } let gcx = &GlobalCtxt { @@ -1226,7 +1202,7 @@ cstore, global_arenas: &arenas.global, global_interners: interners, - dep_graph: dep_graph.clone(), + dep_graph, types: common_types, trait_map, export_map: resolutions.export_map.into_iter().map(|(k, v)| { @@ -1253,14 +1229,14 @@ extern_providers, on_disk_query_result_cache, ), - rcache: Lock::new(FxHashMap()), - selection_cache: traits::SelectionCache::new(), - evaluation_cache: traits::EvaluationCache::new(), + rcache: Default::default(), + selection_cache: Default::default(), + evaluation_cache: Default::default(), crate_name: Symbol::intern(crate_name), data_layout, - layout_interner: Lock::new(FxHashSet()), - stability_interner: Lock::new(FxHashSet()), - allocation_interner: Lock::new(FxHashSet()), + layout_interner: Default::default(), + stability_interner: Default::default(), + allocation_interner: Default::default(), alloc_map: Lock::new(interpret::AllocMap::new()), tx_to_llvm_workers: Lock::new(tx), output_filenames: Arc::new(output_filenames.clone()), @@ -1437,10 +1413,32 @@ self.queries.on_disk_cache.serialize(self.global_tcx(), encoder) } + /// This checks whether one is allowed to have pattern bindings + /// that bind-by-move on a match arm that has a guard, e.g.: + /// + /// ```rust + /// match foo { A(inner) if { /* something */ } => ..., ... } + /// ``` + /// + /// It is separate from check_for_mutation_in_guard_via_ast_walk, + /// because that method has a narrower effect that can be toggled + /// off via a separate `-Z` flag, at least for the short term. + pub fn allow_bind_by_move_patterns_with_guards(self) -> bool { + self.features().bind_by_move_pattern_guards && self.use_mir_borrowck() + } + /// If true, we should use a naive AST walk to determine if match /// guard could perform bad mutations (or mutable-borrows). pub fn check_for_mutation_in_guard_via_ast_walk(self) -> bool { - !self.sess.opts.debugging_opts.disable_ast_check_for_mutation_in_guard + // If someone requests the feature, then be a little more + // careful and ensure that MIR-borrowck is enabled (which can + // happen via edition selection, via `feature(nll)`, or via an + // appropriate `-Z` flag) before disabling the mutation check. + if self.allow_bind_by_move_patterns_with_guards() { + return false; + } + + return true; } /// If true, we should use the AST-based borrowck (we may *also* use @@ -1467,7 +1465,7 @@ self.emit_read_for_match() } - /// If true, make MIR codegen for `match` emit ReadForMatch + /// If true, make MIR codegen for `match` emit FakeRead /// statements (which simulate the maximal effect of executing the /// patterns in a match arm). pub fn emit_read_for_match(&self) -> bool { @@ -1486,15 +1484,8 @@ /// done with either: `-Ztwo-phase-borrows`, `#![feature(nll)]`, /// or by opting into an edition after 2015. pub fn two_phase_borrows(self) -> bool { - if self.features().nll || self.sess.opts.debugging_opts.two_phase_borrows { - return true; - } - - match self.sess.edition() { - Edition::Edition2015 => false, - Edition::Edition2018 => true, - _ => true, - } + self.sess.rust_2018() || self.features().nll || + self.sess.opts.debugging_opts.two_phase_borrows } /// What mode(s) of borrowck should we run? AST? MIR? both? @@ -1572,6 +1563,88 @@ } }) } + + // This method returns the DefId and the BoundRegion corresponding to the given region. + pub fn is_suitable_region(&self, region: Region<'tcx>) -> Option { + let (suitable_region_binding_scope, bound_region) = match *region { + ty::ReFree(ref free_region) => (free_region.scope, free_region.bound_region), + ty::ReEarlyBound(ref ebr) => ( + self.parent_def_id(ebr.def_id).unwrap(), + ty::BoundRegion::BrNamed(ebr.def_id, ebr.name), + ), + _ => return None, // not a free region + }; + + let node_id = self.hir + .as_local_node_id(suitable_region_binding_scope) + .unwrap(); + let is_impl_item = match self.hir.find(node_id) { + Some(Node::Item(..)) | Some(Node::TraitItem(..)) => false, + Some(Node::ImplItem(..)) => { + self.is_bound_region_in_impl_item(suitable_region_binding_scope) + } + _ => return None, + }; + + return Some(FreeRegionInfo { + def_id: suitable_region_binding_scope, + boundregion: bound_region, + is_impl_item: is_impl_item, + }); + } + + pub fn return_type_impl_trait( + &self, + scope_def_id: DefId, + ) -> Option> { + // HACK: `type_of_def_id()` will fail on these (#55796), so return None + let node_id = self.hir.as_local_node_id(scope_def_id).unwrap(); + match self.hir.get(node_id) { + Node::Item(item) => { + match item.node { + ItemKind::Fn(..) => { /* type_of_def_id() will work */ } + _ => { + return None; + } + } + } + _ => { /* type_of_def_id() will work or panic */ } + } + + let ret_ty = self.type_of(scope_def_id); + match ret_ty.sty { + ty::FnDef(_, _) => { + let sig = ret_ty.fn_sig(*self); + let output = self.erase_late_bound_regions(&sig.output()); + if output.is_impl_trait() { + Some(output) + } else { + None + } + } + _ => None + } + } + + // Here we check if the bound region is in Impl Item. + pub fn is_bound_region_in_impl_item( + &self, + suitable_region_binding_scope: DefId, + ) -> bool { + let container_id = self.associated_item(suitable_region_binding_scope) + .container + .id(); + if self.impl_trait_ref(container_id).is_some() { + // For now, we do not try to target impls of traits. This is + // because this message is going to suggest that the user + // change the fn signature, but they may not be free to do so, + // since the signature must match the trait. + // + // FIXME(#42706) -- in some cases, we could do better here. + return true; + } + false + } } impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { @@ -1663,9 +1736,9 @@ } } -impl<'a, 'tcx> Lift<'tcx> for &'a Goal<'a> { - type Lifted = &'tcx Goal<'tcx>; - fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<&'tcx Goal<'tcx>> { +impl<'a, 'tcx> Lift<'tcx> for Goal<'a> { + type Lifted = Goal<'tcx>; + fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option> { if tcx.interners.arena.in_arena(*self as *const _) { return Some(unsafe { mem::transmute(*self) }); } @@ -1822,6 +1895,24 @@ } } +impl<'a, 'tcx> Lift<'tcx> for &'a List> { + type Lifted = &'tcx List>; + fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option { + if self.len() == 0 { + return Some(List::empty()); + } + if tcx.interners.arena.in_arena(*self as *const _) { + return Some(unsafe { mem::transmute(*self) }); + } + // Also try in the global tcx if we're not that. + if !tcx.is_global() { + self.lift_to_tcx(tcx.global_tcx()) + } else { + None + } + } +} + pub mod tls { use super::{GlobalCtxt, TyCtxt}; @@ -1901,7 +1992,7 @@ /// This is a callback from libsyntax as it cannot access the implicit state /// in librustc otherwise - fn span_debug(span: syntax_pos::Span, f: &mut fmt::Formatter) -> fmt::Result { + fn span_debug(span: syntax_pos::Span, f: &mut fmt::Formatter<'_>) -> fmt::Result { with(|tcx| { write!(f, "{}", tcx.sess.source_map().span_to_string(span)) }) @@ -2024,9 +2115,9 @@ } else { // We could get a ImplicitCtxt pointer from another thread. // Ensure that ImplicitCtxt is Sync - sync::assert_sync::(); + sync::assert_sync::>(); - unsafe { f(Some(&*(context as *const ImplicitCtxt))) } + unsafe { f(Some(&*(context as *const ImplicitCtxt<'_, '_, '_>))) } } } @@ -2050,7 +2141,7 @@ unsafe { let gcx = tcx.gcx as *const _ as usize; assert!(context.tcx.gcx as *const _ as usize == gcx); - let context: &ImplicitCtxt = mem::transmute(context); + let context: &ImplicitCtxt<'_, '_, '_> = mem::transmute(context); f(context) } }) @@ -2070,7 +2161,7 @@ let interners = tcx.interners as *const _ as usize; assert!(context.tcx.gcx as *const _ as usize == gcx); assert!(context.tcx.interners as *const _ as usize == interners); - let context: &ImplicitCtxt = mem::transmute(context); + let context: &ImplicitCtxt<'_, '_, '_> = mem::transmute(context); f(context) } }) @@ -2110,14 +2201,13 @@ both_infer: usize, } - pub fn go(tcx: TyCtxt) { + pub fn go(tcx: TyCtxt<'_, '_, '_>) { let mut total = DebugStat { total: 0, region_infer: 0, ty_infer: 0, both_infer: 0, }; $(let mut $variant = total;)* - for &Interned(t) in tcx.interners.type_.borrow().iter() { let variant = match t.sty { ty::Bool | ty::Char | ty::Int(..) | ty::Uint(..) | @@ -2136,7 +2226,7 @@ } println!("Ty interner total ty region both"); $(println!(" {:18}: {uses:6} {usespc:4.1}%, \ -{ty:4.1}% {region:5.1}% {both:4.1}%", + {ty:4.1}% {region:5.1}% {both:4.1}%", stringify!($variant), uses = $variant.total, usespc = $variant.total as f64 * 100.0 / total.total as f64, @@ -2145,7 +2235,7 @@ both = $variant.both_infer as f64 * 100.0 / total.total as f64); )* println!(" total {uses:6} \ -{ty:4.1}% {region:5.1}% {both:4.1}%", + {ty:4.1}% {region:5.1}% {both:4.1}%", uses = total.total, ty = total.ty_infer as f64 * 100.0 / total.total as f64, region = total.region_infer as f64 * 100.0 / total.total as f64, @@ -2163,7 +2253,7 @@ self, Adt, Array, Slice, RawPtr, Ref, FnDef, FnPtr, Generator, GeneratorWitness, Dynamic, Closure, Tuple, - Param, Infer, Projection, Opaque, Foreign); + Param, Infer, UnnormalizedProjection, Projection, Opaque, Foreign); println!("Substs interner: #{}", self.interners.substs.borrow().len()); println!("Region interner: #{}", self.interners.region.borrow().len()); @@ -2231,12 +2321,25 @@ } } +impl<'tcx: 'lcx, 'lcx> Borrow<[ProjectionKind<'lcx>]> + for Interned<'tcx, List>> { + fn borrow<'a>(&'a self) -> &'a [ProjectionKind<'lcx>] { + &self.0[..] + } +} + impl<'tcx> Borrow for Interned<'tcx, RegionKind> { fn borrow<'a>(&'a self) -> &'a RegionKind { &self.0 } } +impl<'tcx: 'lcx, 'lcx> Borrow> for Interned<'tcx, GoalKind<'tcx>> { + fn borrow<'a>(&'a self) -> &'a GoalKind<'lcx> { + &self.0 + } +} + impl<'tcx: 'lcx, 'lcx> Borrow<[ExistentialPredicate<'lcx>]> for Interned<'tcx, List>> { fn borrow<'a>(&'a self) -> &'a [ExistentialPredicate<'lcx>] { @@ -2352,7 +2455,8 @@ direct_interners!('tcx, region: mk_region(|r: &RegionKind| r.keep_in_local_tcx()) -> RegionKind, - const_: mk_const(|c: &Const| keep_local(&c.ty) || keep_local(&c.val)) -> Const<'tcx> + const_: mk_const(|c: &Const<'_>| keep_local(&c.ty) || keep_local(&c.val)) -> Const<'tcx>, + goal: mk_goal(|c: &GoalKind<'_>| keep_local(c)) -> GoalKind<'tcx> ); macro_rules! slice_interners { @@ -2361,7 +2465,7 @@ &[$ty<'tcx>], |a, v| List::from_arena(a, v), Deref::deref, - |xs: &[$ty]| xs.iter().any(keep_local)) -> List<$ty<'tcx>>);)+ + |xs: &[$ty<'_>]| xs.iter().any(keep_local)) -> List<$ty<'tcx>>);)+ ) } @@ -2371,7 +2475,8 @@ type_list: _intern_type_list(Ty), substs: _intern_substs(Kind), clauses: _intern_clauses(Clause), - goals: _intern_goals(Goal) + goal_list: _intern_goals(Goal), + projs: _intern_projs(ProjectionKind) ); // This isn't a perfect fit: CanonicalVarInfo slices are always @@ -2582,7 +2687,7 @@ } pub fn mk_closure(self, closure_id: DefId, closure_substs: ClosureSubsts<'tcx>) - -> Ty<'tcx> { + -> Ty<'tcx> { self.mk_ty(Closure(closure_id, closure_substs)) } @@ -2615,8 +2720,8 @@ } pub fn mk_ty_param(self, - index: u32, - name: InternedString) -> Ty<'tcx> { + index: u32, + name: InternedString) -> Ty<'tcx> { self.mk_ty(Param(ParamTy { idx: index, name: name })) } @@ -2673,6 +2778,14 @@ } } + pub fn intern_projs(self, ps: &[ProjectionKind<'tcx>]) -> &'tcx List> { + if ps.len() == 0 { + List::empty() + } else { + self._intern_projs(ps) + } + } + pub fn intern_canonical_var_infos(self, ts: &[CanonicalVarInfo]) -> CanonicalVarInfos<'gcx> { if ts.len() == 0 { List::empty() @@ -2751,10 +2864,6 @@ iter.intern_with(|xs| self.intern_goals(xs)) } - pub fn mk_goal(self, goal: Goal<'tcx>) -> &'tcx Goal { - &self.intern_goals(&[goal])[0] - } - pub fn lint_hir>(self, lint: &'static Lint, hir_id: HirId, @@ -2918,7 +3027,7 @@ } } -pub fn provide(providers: &mut ty::query::Providers) { +pub fn provide(providers: &mut ty::query::Providers<'_>) { // FIXME(#44234) - almost all of these queries have no sub-queries and // therefore no actual inputs, they're just reading tables calculated in // resolve! Does this work? Unsure! That's what the issue is about diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/erase_regions.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/erase_regions.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/erase_regions.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/erase_regions.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ use ty::{self, Ty, TyCtxt}; use ty::fold::{TypeFolder, TypeFoldable}; -pub(super) fn provide(providers: &mut ty::query::Providers) { +pub(super) fn provide(providers: &mut ty::query::Providers<'_>) { *providers = ty::query::Providers { erase_regions_ty, ..*providers diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/error.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/error.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/error.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/error.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,6 +10,7 @@ use hir::def_id::DefId; use ty::{self, BoundRegion, Region, Ty, TyCtxt}; +use std::borrow::Cow; use std::fmt; use rustc_target::spec::abi; use syntax::ast; @@ -68,10 +69,10 @@ /// afterwards to present additional details, particularly when it comes to lifetime-related /// errors. impl<'tcx> fmt::Display for TypeError<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use self::TypeError::*; - fn report_maybe_different(f: &mut fmt::Formatter, - expected: String, found: String) -> fmt::Result { + fn report_maybe_different(f: &mut fmt::Formatter<'_>, + expected: &str, found: &str) -> fmt::Result { // A naive approach to making sure that we're not reporting silly errors such as: // (expected closure, found closure). if expected == found { @@ -126,15 +127,15 @@ br) } Sorts(values) => ty::tls::with(|tcx| { - report_maybe_different(f, values.expected.sort_string(tcx), - values.found.sort_string(tcx)) + report_maybe_different(f, &values.expected.sort_string(tcx), + &values.found.sort_string(tcx)) }), Traits(values) => ty::tls::with(|tcx| { report_maybe_different(f, - format!("trait `{}`", - tcx.item_path_str(values.expected)), - format!("trait `{}`", - tcx.item_path_str(values.found))) + &format!("trait `{}`", + tcx.item_path_str(values.expected)), + &format!("trait `{}`", + tcx.item_path_str(values.found))) }), IntMismatch(ref values) => { write!(f, "expected `{:?}`, found `{:?}`", @@ -162,8 +163,8 @@ values.found) }, ExistentialMismatch(ref values) => { - report_maybe_different(f, format!("trait `{}`", values.expected), - format!("trait `{}`", values.found)) + report_maybe_different(f, &format!("trait `{}`", values.expected), + &format!("trait `{}`", values.found)) } OldStyleLUB(ref err) => { write!(f, "{}", err) @@ -173,22 +174,22 @@ } impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> { - pub fn sort_string(&self, tcx: TyCtxt<'a, 'gcx, 'lcx>) -> String { + pub fn sort_string(&self, tcx: TyCtxt<'a, 'gcx, 'lcx>) -> Cow<'static, str> { match self.sty { ty::Bool | ty::Char | ty::Int(_) | - ty::Uint(_) | ty::Float(_) | ty::Str | ty::Never => self.to_string(), - ty::Tuple(ref tys) if tys.is_empty() => self.to_string(), + ty::Uint(_) | ty::Float(_) | ty::Str | ty::Never => self.to_string().into(), + ty::Tuple(ref tys) if tys.is_empty() => self.to_string().into(), - ty::Adt(def, _) => format!("{} `{}`", def.descr(), tcx.item_path_str(def.did)), - ty::Foreign(def_id) => format!("extern type `{}`", tcx.item_path_str(def_id)), + ty::Adt(def, _) => format!("{} `{}`", def.descr(), tcx.item_path_str(def.did)).into(), + ty::Foreign(def_id) => format!("extern type `{}`", tcx.item_path_str(def_id)).into(), ty::Array(_, n) => { match n.assert_usize(tcx) { - Some(n) => format!("array of {} elements", n), - None => "array".to_string(), + Some(n) => format!("array of {} elements", n).into(), + None => "array".into(), } } - ty::Slice(_) => "slice".to_string(), - ty::RawPtr(_) => "*-ptr".to_string(), + ty::Slice(_) => "slice".into(), + ty::RawPtr(_) => "*-ptr".into(), ty::Ref(region, ty, mutbl) => { let tymut = ty::TypeAndMut { ty, mutbl }; let tymut_string = tymut.to_string(); @@ -199,45 +200,45 @@ format!("{}reference", match mutbl { hir::Mutability::MutMutable => "mutable ", _ => "" - }) + }).into() } else { - format!("&{}", tymut_string) + format!("&{}", tymut_string).into() } } - ty::FnDef(..) => "fn item".to_string(), - ty::FnPtr(_) => "fn pointer".to_string(), + ty::FnDef(..) => "fn item".into(), + ty::FnPtr(_) => "fn pointer".into(), ty::Dynamic(ref inner, ..) => { - inner.principal().map_or_else(|| "trait".to_string(), - |p| format!("trait {}", tcx.item_path_str(p.def_id()))) + format!("trait {}", tcx.item_path_str(inner.principal().def_id())).into() } - ty::Closure(..) => "closure".to_string(), - ty::Generator(..) => "generator".to_string(), - ty::GeneratorWitness(..) => "generator witness".to_string(), - ty::Tuple(..) => "tuple".to_string(), - ty::Infer(ty::TyVar(_)) => "inferred type".to_string(), - ty::Infer(ty::IntVar(_)) => "integral variable".to_string(), - ty::Infer(ty::FloatVar(_)) => "floating-point variable".to_string(), - ty::Infer(ty::CanonicalTy(_)) | - ty::Infer(ty::FreshTy(_)) => "skolemized type".to_string(), - ty::Infer(ty::FreshIntTy(_)) => "skolemized integral type".to_string(), - ty::Infer(ty::FreshFloatTy(_)) => "skolemized floating-point type".to_string(), - ty::Projection(_) => "associated type".to_string(), + ty::Closure(..) => "closure".into(), + ty::Generator(..) => "generator".into(), + ty::GeneratorWitness(..) => "generator witness".into(), + ty::Tuple(..) => "tuple".into(), + ty::Infer(ty::TyVar(_)) => "inferred type".into(), + ty::Infer(ty::IntVar(_)) => "integral variable".into(), + ty::Infer(ty::FloatVar(_)) => "floating-point variable".into(), + ty::Infer(ty::BoundTy(_)) | + ty::Infer(ty::FreshTy(_)) => "fresh type".into(), + ty::Infer(ty::FreshIntTy(_)) => "fresh integral type".into(), + ty::Infer(ty::FreshFloatTy(_)) => "fresh floating-point type".into(), + ty::Projection(_) => "associated type".into(), + ty::UnnormalizedProjection(_) => "non-normalized associated type".into(), ty::Param(ref p) => { if p.is_self() { - "Self".to_string() + "Self".into() } else { - "type parameter".to_string() + "type parameter".into() } } - ty::Opaque(..) => "opaque type".to_string(), - ty::Error => "type error".to_string(), + ty::Opaque(..) => "opaque type".into(), + ty::Error => "type error".into(), } } } impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn note_and_explain_type_err(self, - db: &mut DiagnosticBuilder, + db: &mut DiagnosticBuilder<'_>, err: &TypeError<'tcx>, sp: Span) { use self::TypeError::*; @@ -250,20 +251,19 @@ db.note("no two closures, even if identical, have the same type"); db.help("consider boxing your closure and/or using it as a trait object"); } - match (&values.found.sty, &values.expected.sty) { // Issue #53280 - (ty::Infer(ty::IntVar(_)), ty::Float(_)) => { - if let Ok(snippet) = self.sess.source_map().span_to_snippet(sp) { - if snippet.chars().all(|c| c.is_digit(10) || c == '-' || c == '_') { - db.span_suggestion_with_applicability( - sp, - "use a float literal", - format!("{}.0", snippet), - Applicability::MachineApplicable - ); - } + if let (ty::Infer(ty::IntVar(_)), ty::Float(_)) = + (&values.found.sty, &values.expected.sty) // Issue #53280 + { + if let Ok(snippet) = self.sess.source_map().span_to_snippet(sp) { + if snippet.chars().all(|c| c.is_digit(10) || c == '-' || c == '_') { + db.span_suggestion_with_applicability( + sp, + "use a float literal", + format!("{}.0", snippet), + Applicability::MachineApplicable + ); } - }, - _ => {} + } } }, OldStyleLUB(err) => { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/fast_reject.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/fast_reject.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/fast_reject.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/fast_reject.rs 2018-12-04 23:41:40.000000000 +0000 @@ -63,7 +63,7 @@ /// `can_simplify_params` should be true if type parameters appear free in `ty` and `false` if they /// are to be considered bound. pub fn simplify_type<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, - ty: Ty, + ty: Ty<'_>, can_simplify_params: bool) -> Option { @@ -78,7 +78,7 @@ ty::Array(..) | ty::Slice(_) => Some(ArraySimplifiedType), ty::RawPtr(_) => Some(PtrSimplifiedType), ty::Dynamic(ref trait_info, ..) => { - trait_info.principal().map(|p| TraitSimplifiedType(p.def_id())) + Some(TraitSimplifiedType(trait_info.principal().def_id())) } ty::Ref(_, ty, _) => { // since we introduce auto-refs during method lookup, we @@ -103,6 +103,7 @@ ty::FnPtr(ref f) => { Some(FunctionSimplifiedType(f.skip_binder().inputs().len())) } + ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"), ty::Projection(_) | ty::Param(_) => { if can_simplify_params { // In normalized types, projections don't unify with diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/flags.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/flags.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/flags.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/flags.rs 2018-12-04 23:41:40.000000000 +0000 @@ -28,7 +28,7 @@ } } - pub fn for_sty(st: &ty::TyKind) -> FlagComputation { + pub fn for_sty(st: &ty::TyKind<'_>) -> FlagComputation { let mut result = FlagComputation::new(); result.add_sty(st); result @@ -62,12 +62,10 @@ let outer_exclusive_binder = computation.outer_exclusive_binder; if outer_exclusive_binder > ty::INNERMOST { self.add_exclusive_binder(outer_exclusive_binder.shifted_out(1)); - } else { - // otherwise, this binder captures nothing - } + } // otherwise, this binder captures nothing } - fn add_sty(&mut self, st: &ty::TyKind) { + fn add_sty(&mut self, st: &ty::TyKind<'_>) { match st { &ty::Bool | &ty::Char | @@ -124,7 +122,7 @@ ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_) | - ty::CanonicalTy(_) => { + ty::BoundTy(_) => { self.add_flags(TypeFlags::HAS_CANONICAL_VARS); } @@ -150,6 +148,11 @@ self.add_projection_ty(data); } + &ty::UnnormalizedProjection(ref data) => { + self.add_flags(TypeFlags::HAS_PROJECTION); + self.add_projection_ty(data); + }, + &ty::Opaque(_, substs) => { self.add_flags(TypeFlags::HAS_PROJECTION); self.add_substs(substs); @@ -204,18 +207,18 @@ } } - fn add_ty(&mut self, ty: Ty) { + fn add_ty(&mut self, ty: Ty<'_>) { self.add_flags(ty.flags); self.add_exclusive_binder(ty.outer_exclusive_binder); } - fn add_tys(&mut self, tys: &[Ty]) { + fn add_tys(&mut self, tys: &[Ty<'_>]) { for &ty in tys { self.add_ty(ty); } } - fn add_fn_sig(&mut self, fn_sig: ty::PolyFnSig) { + fn add_fn_sig(&mut self, fn_sig: ty::PolyFnSig<'_>) { let mut computation = FlagComputation::new(); computation.add_tys(fn_sig.skip_binder().inputs()); @@ -224,14 +227,14 @@ self.add_bound_computation(&computation); } - fn add_region(&mut self, r: ty::Region) { + fn add_region(&mut self, r: ty::Region<'_>) { self.add_flags(r.type_flags()); if let ty::ReLateBound(debruijn, _) = *r { self.add_binder(debruijn); } } - fn add_const(&mut self, constant: &ty::Const) { + fn add_const(&mut self, constant: &ty::Const<'_>) { self.add_ty(constant.ty); if let ConstValue::Unevaluated(_, substs) = constant.val { self.add_flags(TypeFlags::HAS_PROJECTION); @@ -239,16 +242,16 @@ } } - fn add_existential_projection(&mut self, projection: &ty::ExistentialProjection) { + fn add_existential_projection(&mut self, projection: &ty::ExistentialProjection<'_>) { self.add_substs(projection.substs); self.add_ty(projection.ty); } - fn add_projection_ty(&mut self, projection_ty: &ty::ProjectionTy) { + fn add_projection_ty(&mut self, projection_ty: &ty::ProjectionTy<'_>) { self.add_substs(projection_ty.substs); } - fn add_substs(&mut self, substs: &Substs) { + fn add_substs(&mut self, substs: &Substs<'_>) { for ty in substs.types() { self.add_ty(ty); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/fold.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/fold.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/fold.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/fold.rs 2018-12-04 23:41:40.000000000 +0000 @@ -667,12 +667,14 @@ /// we already use the term "free region". It refers to the regions that we use to represent bound /// regions on a fn definition while we are typechecking its body. /// -/// To clarify, conceptually there is no particular difference between an "escaping" region and a -/// "free" region. However, there is a big difference in practice. Basically, when "entering" a -/// binding level, one is generally required to do some sort of processing to a bound region, such -/// as replacing it with a fresh/skolemized region, or making an entry in the environment to -/// represent the scope to which it is attached, etc. An escaping region represents a bound region -/// for which this processing has not yet been done. +/// To clarify, conceptually there is no particular difference between +/// an "escaping" region and a "free" region. However, there is a big +/// difference in practice. Basically, when "entering" a binding +/// level, one is generally required to do some sort of processing to +/// a bound region, such as replacing it with a fresh/placeholder +/// region, or making an entry in the environment to represent the +/// scope to which it is attached, etc. An escaping region represents +/// a bound region for which this processing has not yet been done. struct HasEscapingRegionsVisitor { /// Anything bound by `outer_index` or "above" is escaping outer_index: ty::DebruijnIndex, @@ -708,7 +710,7 @@ } impl<'tcx> TypeVisitor<'tcx> for HasTypeFlagsVisitor { - fn visit_ty(&mut self, t: Ty) -> bool { + fn visit_ty(&mut self, t: Ty<'_>) -> bool { debug!("HasTypeFlagsVisitor: t={:?} t.flags={:?} self.flags={:?}", t, t.flags, self.flags); t.flags.intersects(self.flags) } @@ -751,7 +753,7 @@ fn new(just_constrained: bool) -> Self { LateBoundRegionsCollector { current_index: ty::INNERMOST, - regions: FxHashSet(), + regions: Default::default(), just_constrained, } } @@ -780,11 +782,10 @@ } fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool { - match *r { - ty::ReLateBound(debruijn, br) if debruijn == self.current_index => { + if let ty::ReLateBound(debruijn, br) = *r { + if debruijn == self.current_index { self.regions.insert(br); } - _ => { } } false } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/inhabitedness/def_id_forest.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/inhabitedness/def_id_forest.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/inhabitedness/def_id_forest.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/inhabitedness/def_id_forest.rs 2018-12-04 23:41:40.000000000 +0000 @@ -66,12 +66,7 @@ tcx: TyCtxt<'a, 'gcx, 'tcx>, id: DefId) -> bool { - for root_id in self.root_ids.iter() { - if tcx.is_descendant_of(id, *root_id) { - return true; - } - } - false + self.root_ids.iter().any(|root_id| tcx.is_descendant_of(id, *root_id)) } /// Calculate the intersection of a collection of forests. @@ -92,11 +87,7 @@ } ret.root_ids.extend(old_ret.drain()); - for id in next_forest.root_ids { - if ret.contains(tcx, id) { - next_ret.push(id); - } - } + next_ret.extend(next_forest.root_ids.into_iter().filter(|&id| ret.contains(tcx, id))); mem::swap(&mut next_ret, &mut ret.root_ids); next_ret.drain(); @@ -112,11 +103,7 @@ let mut ret = DefIdForest::empty(); let mut next_ret = SmallVec::new(); for next_forest in iter { - for id in ret.root_ids.drain() { - if !next_forest.contains(tcx, id) { - next_ret.push(id); - } - } + next_ret.extend(ret.root_ids.drain().filter(|&id| !next_forest.contains(tcx, id))); for id in next_forest.root_ids { if !next_ret.contains(&id) { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/inhabitedness/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/inhabitedness/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/inhabitedness/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/inhabitedness/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -113,7 +113,7 @@ } fn ty_inhabitedness_forest(self, ty: Ty<'tcx>) -> DefIdForest { - ty.uninhabited_from(&mut FxHashMap(), self) + ty.uninhabited_from(&mut FxHashMap::default(), self) } pub fn is_enum_variant_uninhabited_from(self, @@ -140,7 +140,7 @@ let adt_kind = self.adt_def(adt_def_id).adt_kind(); // Compute inhabitedness forest: - variant.uninhabited_from(&mut FxHashMap(), self, substs, adt_kind) + variant.uninhabited_from(&mut FxHashMap::default(), self, substs, adt_kind) } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/instance.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/instance.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/instance.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/instance.rs 2018-12-04 23:41:40.000000000 +0000 @@ -109,12 +109,14 @@ return true } let codegen_fn_attrs = tcx.codegen_fn_attrs(self.def_id()); - codegen_fn_attrs.requests_inline() || tcx.is_const_fn(self.def_id()) + // need to use `is_const_fn_raw` since we don't really care if the user can use it as a + // const fn, just whether the function should be inlined + codegen_fn_attrs.requests_inline() || tcx.is_const_fn_raw(self.def_id()) } } impl<'tcx> fmt::Display for Instance<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ppaux::parameterized(f, self.substs, self.def_id(), &[])?; match self.def { InstanceDef::Item(_) => Ok(()), @@ -229,11 +231,11 @@ } pub fn resolve_closure( - tcx: TyCtxt<'a, 'tcx, 'tcx>, - def_id: DefId, - substs: ty::ClosureSubsts<'tcx>, - requested_kind: ty::ClosureKind) - -> Instance<'tcx> + tcx: TyCtxt<'a, 'tcx, 'tcx>, + def_id: DefId, + substs: ty::ClosureSubsts<'tcx>, + requested_kind: ty::ClosureKind) + -> Instance<'tcx> { let actual_kind = substs.closure_kind(def_id, tcx); @@ -253,8 +255,8 @@ ) -> Option> { let def_id = trait_item.def_id; debug!("resolve_associated_item(trait_item={:?}, \ - trait_id={:?}, \ - rcvr_substs={:?})", + trait_id={:?}, \ + rcvr_substs={:?})", def_id, trait_id, rcvr_substs); let trait_ref = ty::TraitRef::from_method(tcx, trait_id, rcvr_substs); @@ -278,7 +280,7 @@ traits::VtableClosure(closure_data) => { let trait_closure_kind = tcx.lang_items().fn_trait_kind(trait_id).unwrap(); Some(Instance::resolve_closure(tcx, closure_data.closure_def_id, closure_data.substs, - trait_closure_kind)) + trait_closure_kind)) } traits::VtableFnPointer(ref data) => { Some(Instance { @@ -308,7 +310,7 @@ } fn needs_fn_once_adapter_shim<'a, 'tcx>(actual_closure_kind: ty::ClosureKind, - trait_closure_kind: ty::ClosureKind) + trait_closure_kind: ty::ClosureKind) -> Result { match (actual_closure_kind, trait_closure_kind) { @@ -342,13 +344,14 @@ } fn fn_once_adapter_instance<'a, 'tcx>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, - closure_did: DefId, - substs: ty::ClosureSubsts<'tcx>, - ) -> Instance<'tcx> { + tcx: TyCtxt<'a, 'tcx, 'tcx>, + closure_did: DefId, + substs: ty::ClosureSubsts<'tcx>) + -> Instance<'tcx> +{ debug!("fn_once_adapter_shim({:?}, {:?})", - closure_did, - substs); + closure_did, + substs); let fn_once = tcx.lang_items().fn_once_trait().unwrap(); let call_once = tcx.associated_items(fn_once) .find(|it| it.kind == ty::AssociatedKind::Method) diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/item_path.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/item_path.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/item_path.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/item_path.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,17 +10,18 @@ use hir::map::DefPathData; use hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; -use ty::{self, Ty, TyCtxt}; +use ty::{self, DefIdTree, Ty, TyCtxt}; use middle::cstore::{ExternCrate, ExternCrateSource}; use syntax::ast; -use syntax::symbol::Symbol; -use syntax::symbol::LocalInternedString; +use syntax::symbol::{keywords, LocalInternedString, Symbol}; use std::cell::Cell; +use std::fmt::Debug; thread_local! { static FORCE_ABSOLUTE: Cell = Cell::new(false); static FORCE_IMPL_FILENAME_LINE: Cell = Cell::new(false); + static SHOULD_PREFIX_WITH_CRATE: Cell = Cell::new(false); } /// Enforces that item_path_str always returns an absolute path and @@ -51,6 +52,17 @@ }) } +/// Add the `crate::` prefix to paths where appropriate. +pub fn with_crate_prefix R, R>(f: F) -> R { + SHOULD_PREFIX_WITH_CRATE.with(|flag| { + let old = flag.get(); + flag.set(true); + let result = f(); + flag.set(old); + result + }) +} + impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { /// Returns a string identifying this def-id. This string is /// suitable for user output. It is relative to the current crate @@ -64,7 +76,8 @@ } }); let mut buffer = LocalPathBuffer::new(mode); - self.push_item_path(&mut buffer, def_id); + debug!("item_path_str: buffer={:?} def_id={:?}", buffer, def_id); + self.push_item_path(&mut buffer, def_id, false); buffer.into_string() } @@ -77,16 +90,26 @@ /// suitable for user output. It always begins with a crate identifier. pub fn absolute_item_path_str(self, def_id: DefId) -> String { let mut buffer = LocalPathBuffer::new(RootMode::Absolute); - self.push_item_path(&mut buffer, def_id); + debug!("absolute_item_path_str: buffer={:?} def_id={:?}", buffer, def_id); + self.push_item_path(&mut buffer, def_id, false); buffer.into_string() } /// Returns the "path" to a particular crate. This can proceed in /// various ways, depending on the `root_mode` of the `buffer`. /// (See `RootMode` enum for more details.) - pub fn push_krate_path(self, buffer: &mut T, cnum: CrateNum) - where T: ItemPathBuffer + /// + /// `pushed_prelude_crate` argument should be `true` when the buffer + /// has had a prelude crate pushed to it. If this is the case, then + /// we do not want to prepend `crate::` (as that would not be a valid + /// path). + pub fn push_krate_path(self, buffer: &mut T, cnum: CrateNum, pushed_prelude_crate: bool) + where T: ItemPathBuffer + Debug { + debug!( + "push_krate_path: buffer={:?} cnum={:?} LOCAL_CRATE={:?}", + buffer, cnum, LOCAL_CRATE + ); match *buffer.root_mode() { RootMode::Local => { // In local mode, when we encounter a crate other than @@ -109,16 +132,29 @@ .. }) = *opt_extern_crate { - self.push_item_path(buffer, def_id); + debug!("push_krate_path: def_id={:?}", def_id); + self.push_item_path(buffer, def_id, pushed_prelude_crate); } else { - buffer.push(&self.crate_name(cnum).as_str()); + let name = self.crate_name(cnum).as_str(); + debug!("push_krate_path: name={:?}", name); + buffer.push(&name); } + } else if self.sess.rust_2018() && !pushed_prelude_crate { + SHOULD_PREFIX_WITH_CRATE.with(|flag| { + // We only add the `crate::` keyword where appropriate. In particular, + // when we've not previously pushed a prelude crate to this path. + if flag.get() { + buffer.push(&keywords::Crate.name().as_str()) + } + }) } } RootMode::Absolute => { // In absolute mode, just write the crate name // unconditionally. - buffer.push(&self.original_crate_name(cnum).as_str()); + let name = self.original_crate_name(cnum).as_str(); + debug!("push_krate_path: original_name={:?}", name); + buffer.push(&name); } } } @@ -126,13 +162,26 @@ /// If possible, this pushes a global path resolving to `external_def_id` that is visible /// from at least one local module and returns true. If the crate defining `external_def_id` is /// declared with an `extern crate`, the path is guaranteed to use the `extern crate`. - pub fn try_push_visible_item_path(self, buffer: &mut T, external_def_id: DefId) -> bool - where T: ItemPathBuffer + pub fn try_push_visible_item_path( + self, + buffer: &mut T, + external_def_id: DefId, + pushed_prelude_crate: bool, + ) -> bool + where T: ItemPathBuffer + Debug { + debug!( + "try_push_visible_item_path: buffer={:?} external_def_id={:?}", + buffer, external_def_id + ); let visible_parent_map = self.visible_parent_map(LOCAL_CRATE); let (mut cur_def, mut cur_path) = (external_def_id, Vec::::new()); loop { + debug!( + "try_push_visible_item_path: cur_def={:?} cur_path={:?} CRATE_DEF_INDEX={:?}", + cur_def, cur_path, CRATE_DEF_INDEX, + ); // If `cur_def` is a direct or injected extern crate, push the path to the crate // followed by the path to the item within the crate and return. if cur_def.index == CRATE_DEF_INDEX { @@ -142,7 +191,8 @@ direct: true, .. }) => { - self.push_item_path(buffer, def_id); + debug!("try_push_visible_item_path: def_id={:?}", def_id); + self.push_item_path(buffer, def_id, pushed_prelude_crate); cur_path.iter().rev().for_each(|segment| buffer.push(&segment)); return true; } @@ -156,6 +206,7 @@ } let mut cur_def_key = self.def_key(cur_def); + debug!("try_push_visible_item_path: cur_def_key={:?}", cur_def_key); // For a UnitStruct or TupleStruct we want the name of its parent rather than . if let DefPathData::StructCtor = cur_def_key.disambiguated_data.data { @@ -167,41 +218,101 @@ cur_def_key = self.def_key(parent); } + let visible_parent = visible_parent_map.get(&cur_def).cloned(); + let actual_parent = self.parent(cur_def); + debug!( + "try_push_visible_item_path: visible_parent={:?} actual_parent={:?}", + visible_parent, actual_parent, + ); + let data = cur_def_key.disambiguated_data.data; - let symbol = data.get_opt_name().map(|n| n.as_str()).unwrap_or_else(|| { - if let DefPathData::CrateRoot = data { // reexported `extern crate` (#43189) - self.original_crate_name(cur_def.krate).as_str() - } else { - Symbol::intern("").as_str() - } - }); + let symbol = match data { + // In order to output a path that could actually be imported (valid and visible), + // we need to handle re-exports correctly. + // + // For example, take `std::os::unix::process::CommandExt`, this trait is actually + // defined at `std::sys::unix::ext::process::CommandExt` (at time of writing). + // + // `std::os::unix` rexports the contents of `std::sys::unix::ext`. `std::sys` is + // private so the "true" path to `CommandExt` isn't accessible. + // + // In this case, the `visible_parent_map` will look something like this: + // + // (child) -> (parent) + // `std::sys::unix::ext::process::CommandExt` -> `std::sys::unix::ext::process` + // `std::sys::unix::ext::process` -> `std::sys::unix::ext` + // `std::sys::unix::ext` -> `std::os` + // + // This is correct, as the visible parent of `std::sys::unix::ext` is in fact + // `std::os`. + // + // When printing the path to `CommandExt` and looking at the `cur_def_key` that + // corresponds to `std::sys::unix::ext`, we would normally print `ext` and then go + // to the parent - resulting in a mangled path like + // `std::os::ext::process::CommandExt`. + // + // Instead, we must detect that there was a re-export and instead print `unix` + // (which is the name `std::sys::unix::ext` was re-exported as in `std::os`). To + // do this, we compare the parent of `std::sys::unix::ext` (`std::sys::unix`) with + // the visible parent (`std::os`). If these do not match, then we iterate over + // the children of the visible parent (as was done when computing + // `visible_parent_map`), looking for the specific child we currently have and then + // have access to the re-exported name. + DefPathData::Module(module_name) if visible_parent != actual_parent => { + let mut name: Option = None; + if let Some(visible_parent) = visible_parent { + for child in self.item_children(visible_parent).iter() { + if child.def.def_id() == cur_def { + name = Some(child.ident); + } + } + } + name.map(|n| n.as_str()).unwrap_or(module_name.as_str()) + }, + _ => { + data.get_opt_name().map(|n| n.as_str()).unwrap_or_else(|| { + // Re-exported `extern crate` (#43189). + if let DefPathData::CrateRoot = data { + self.original_crate_name(cur_def.krate).as_str() + } else { + Symbol::intern("").as_str() + } + }) + }, + }; + debug!("try_push_visible_item_path: symbol={:?}", symbol); cur_path.push(symbol); - match visible_parent_map.get(&cur_def) { - Some(&def) => cur_def = def, + match visible_parent { + Some(def) => cur_def = def, None => return false, }; } } - pub fn push_item_path(self, buffer: &mut T, def_id: DefId) - where T: ItemPathBuffer + pub fn push_item_path(self, buffer: &mut T, def_id: DefId, pushed_prelude_crate: bool) + where T: ItemPathBuffer + Debug { + debug!( + "push_item_path: buffer={:?} def_id={:?} pushed_prelude_crate={:?}", + buffer, def_id, pushed_prelude_crate + ); match *buffer.root_mode() { RootMode::Local if !def_id.is_local() => - if self.try_push_visible_item_path(buffer, def_id) { return }, + if self.try_push_visible_item_path(buffer, def_id, pushed_prelude_crate) { return }, _ => {} } let key = self.def_key(def_id); + debug!("push_item_path: key={:?}", key); match key.disambiguated_data.data { DefPathData::CrateRoot => { assert!(key.parent.is_none()); - self.push_krate_path(buffer, def_id.krate); + self.push_krate_path(buffer, def_id.krate, pushed_prelude_crate); } DefPathData::Impl => { - self.push_impl_path(buffer, def_id); + self.push_impl_path(buffer, def_id, pushed_prelude_crate); } // Unclear if there is any value in distinguishing these. @@ -224,22 +335,40 @@ data @ DefPathData::ClosureExpr | data @ DefPathData::ImplTrait | data @ DefPathData::GlobalMetaData(..) => { - let parent_def_id = self.parent_def_id(def_id).unwrap(); - self.push_item_path(buffer, parent_def_id); + let parent_did = self.parent_def_id(def_id).unwrap(); + + // Keep track of whether we are one recursion away from the `CrateRoot` and + // pushing the name of a prelude crate. If we are, we'll want to know this when + // printing the `CrateRoot` so we don't prepend a `crate::` to paths. + let mut is_prelude_crate = false; + if let DefPathData::CrateRoot = self.def_key(parent_did).disambiguated_data.data { + if self.extern_prelude.contains_key(&data.as_interned_str().as_symbol()) { + is_prelude_crate = true; + } + } + + self.push_item_path( + buffer, parent_did, pushed_prelude_crate || is_prelude_crate + ); buffer.push(&data.as_interned_str().as_symbol().as_str()); - } + }, + DefPathData::StructCtor => { // present `X` instead of `X::{{constructor}}` let parent_def_id = self.parent_def_id(def_id).unwrap(); - self.push_item_path(buffer, parent_def_id); + self.push_item_path(buffer, parent_def_id, pushed_prelude_crate); } } } - fn push_impl_path(self, - buffer: &mut T, - impl_def_id: DefId) - where T: ItemPathBuffer + fn push_impl_path( + self, + buffer: &mut T, + impl_def_id: DefId, + pushed_prelude_crate: bool, + ) + where T: ItemPathBuffer + Debug { + debug!("push_impl_path: buffer={:?} impl_def_id={:?}", buffer, impl_def_id); let parent_def_id = self.parent_def_id(impl_def_id).unwrap(); // Always use types for non-local impls, where types are always @@ -251,7 +380,7 @@ }; if !use_types { - return self.push_impl_path_fallback(buffer, impl_def_id); + return self.push_impl_path_fallback(buffer, impl_def_id, pushed_prelude_crate); } // Decide whether to print the parent path for the impl. @@ -275,7 +404,7 @@ // If the impl is not co-located with either self-type or // trait-type, then fallback to a format that identifies // the module more clearly. - self.push_item_path(buffer, parent_def_id); + self.push_item_path(buffer, parent_def_id, pushed_prelude_crate); if let Some(trait_ref) = impl_trait_ref { buffer.push(&format!("", trait_ref, self_ty)); } else { @@ -289,9 +418,7 @@ if let Some(trait_ref) = impl_trait_ref { // Trait impls. - buffer.push(&format!("<{} as {}>", - self_ty, - trait_ref)); + buffer.push(&format!("<{} as {}>", self_ty, trait_ref)); return; } @@ -301,13 +428,13 @@ match self_ty.sty { ty::Adt(adt_def, substs) => { if substs.types().next().is_none() { // ignore regions - self.push_item_path(buffer, adt_def.did); + self.push_item_path(buffer, adt_def.did, pushed_prelude_crate); } else { buffer.push(&format!("<{}>", self_ty)); } } - ty::Foreign(did) => self.push_item_path(buffer, did), + ty::Foreign(did) => self.push_item_path(buffer, did, pushed_prelude_crate), ty::Bool | ty::Char | @@ -324,16 +451,19 @@ } } - fn push_impl_path_fallback(self, - buffer: &mut T, - impl_def_id: DefId) - where T: ItemPathBuffer + fn push_impl_path_fallback( + self, + buffer: &mut T, + impl_def_id: DefId, + pushed_prelude_crate: bool, + ) + where T: ItemPathBuffer + Debug { // If no type info is available, fall back to // pretty printing some span information. This should // only occur very early in the compiler pipeline. let parent_def_id = self.parent_def_id(impl_def_id).unwrap(); - self.push_item_path(buffer, parent_def_id); + self.push_item_path(buffer, parent_def_id, pushed_prelude_crate); let node_id = self.hir.as_local_node_id(impl_def_id).unwrap(); let item = self.hir.expect_item(node_id); let span_str = self.sess.source_map().span_to_string(item.span); @@ -355,11 +485,11 @@ /// function tries to find a "characteristic def-id" for a /// type. It's just a heuristic so it makes some questionable /// decisions and we may want to adjust it later. -pub fn characteristic_def_id_of_type(ty: Ty) -> Option { +pub fn characteristic_def_id_of_type(ty: Ty<'_>) -> Option { match ty.sty { ty::Adt(adt_def, _) => Some(adt_def.did), - ty::Dynamic(data, ..) => data.principal().map(|p| p.def_id()), + ty::Dynamic(data, ..) => Some(data.principal().def_id()), ty::Array(subty, _) | ty::Slice(subty) => characteristic_def_id_of_type(subty), @@ -384,6 +514,7 @@ ty::Str | ty::FnPtr(_) | ty::Projection(_) | + ty::UnnormalizedProjection(..) | ty::Param(_) | ty::Opaque(..) | ty::Infer(_) | diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/layout.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/layout.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/layout.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/layout.rs 2018-12-04 23:41:40.000000000 +0000 @@ -32,11 +32,11 @@ fn to_ty<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, signed: bool) -> Ty<'tcx>; fn from_attr(cx: C, ity: attr::IntType) -> Integer; fn repr_discr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - ty: Ty<'tcx>, - repr: &ReprOptions, - min: i128, - max: i128) - -> (Integer, bool); + ty: Ty<'tcx>, + repr: &ReprOptions, + min: i128, + max: i128) + -> (Integer, bool); } impl IntegerExt for Integer { @@ -76,11 +76,11 @@ /// N.B.: u128 values above i128::MAX will be treated as signed, but /// that shouldn't affect anything, other than maybe debuginfo. fn repr_discr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - ty: Ty<'tcx>, - repr: &ReprOptions, - min: i128, - max: i128) - -> (Integer, bool) { + ty: Ty<'tcx>, + repr: &ReprOptions, + min: i128, + max: i128) + -> (Integer, bool) { // Theoretically, negative values could be larger in unsigned representation // than the unsigned representation of the signed minimum. However, if there // are any negative values, the only valid unsigned representation is u128 @@ -96,7 +96,7 @@ let fit = if ity.is_signed() { signed_fit } else { unsigned_fit }; if discr < fit { bug!("Integer::repr_discr: `#[repr]` hint too small for \ - discriminant range of enum `{}", ty) + discriminant range of enum `{}", ty) } return (discr, ity.is_signed()); } @@ -106,7 +106,7 @@ // WARNING: the ARM EABI has two variants; the one corresponding // to `at_least == I32` appears to be used on Linux and NetBSD, // but some systems may use the variant corresponding to no - // lower bound. However, we don't run on those yet...? + // lower bound. However, we don't run on those yet...? "arm" => min_from_extern = Some(I32), _ => min_from_extern = Some(I32), } @@ -157,7 +157,7 @@ } impl<'tcx> fmt::Display for LayoutError<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { LayoutError::Unknown(ty) => { write!(f, "the type `{:?}` has an unknown layout", ty) @@ -195,7 +195,7 @@ }) } -pub fn provide(providers: &mut ty::query::Providers) { +pub fn provide(providers: &mut ty::query::Providers<'_>) { *providers = ty::query::Providers { layout_raw, ..*providers @@ -250,7 +250,8 @@ /// A univariant, but with a prefix of an arbitrary size & alignment (e.g. enum tag). Prefixed(Size, Align), } - let univariant_uninterned = |fields: &[TyLayout], repr: &ReprOptions, kind| { + + let univariant_uninterned = |fields: &[TyLayout<'_>], repr: &ReprOptions, kind| { let packed = repr.packed(); if packed && repr.align > 0 { bug!("struct cannot be packed and aligned"); @@ -283,7 +284,7 @@ fields.len() }; let optimizing = &mut inverse_memory_index[..end]; - let field_align = |f: &TyLayout| { + let field_align = |f: &TyLayout<'_>| { if packed { f.align.min(pack).abi() } else { f.align.abi() } }; match kind { @@ -324,7 +325,7 @@ let field = fields[i as usize]; if !sized { bug!("univariant: field #{} of `{}` comes after unsized field", - offsets.len(), ty); + offsets.len(), ty); } if field.is_unsized() { @@ -449,7 +450,7 @@ } } - if sized && fields.iter().any(|f| f.abi == Abi::Uninhabited) { + if sized && fields.iter().any(|f| f.abi.is_uninhabited()) { abi = Abi::Uninhabited; } @@ -464,7 +465,7 @@ size }) }; - let univariant = |fields: &[TyLayout], repr: &ReprOptions, kind| { + let univariant = |fields: &[TyLayout<'_>], repr: &ReprOptions, kind| { Ok(tcx.intern_layout(univariant_uninterned(fields, repr, kind)?)) }; debug_assert!(!ty.has_infer_types()); @@ -628,7 +629,7 @@ }; univariant(&tys.iter().map(|ty| self.layout_of(ty)).collect::, _>>()?, - &ReprOptions::default(), kind)? + &ReprOptions::default(), kind)? } // SIMD vector types. @@ -640,7 +641,7 @@ Abi::Scalar(ref scalar) => scalar.clone(), _ => { tcx.sess.fatal(&format!("monomorphising SIMD type `{}` with \ - a non-machine element type `{}`", + a non-machine element type `{}`", ty, element.ty)); } }; @@ -723,8 +724,8 @@ // but *not* an encoding of the discriminant (e.g. a tag value). // See issue #49298 for more details on the need to leave space // for non-ZST uninhabited data (mostly partial initialization). - let absent = |fields: &[TyLayout]| { - let uninhabited = fields.iter().any(|f| f.abi == Abi::Uninhabited); + let absent = |fields: &[TyLayout<'_>]| { + let uninhabited = fields.iter().any(|f| f.abi.is_uninhabited()); let is_zst = fields.iter().all(|f| f.is_zst()); uninhabited && is_zst }; @@ -743,7 +744,7 @@ // Only one variant is present. (present_second.is_none() && // Representation optimizations are allowed. - !def.repr.inhibit_enum_layout_opt()); + !def.repr.inhibit_enum_layout_opt()); if is_struct { // Struct, or univariant enum equivalent to a struct. // (Typechecking will reject discriminant-sizing attrs.) @@ -755,7 +756,7 @@ let param_env = tcx.param_env(def.did); let last_field = def.variants[v].fields.last().unwrap(); let always_sized = tcx.type_of(last_field.did) - .is_sized(tcx.at(DUMMY_SP), param_env); + .is_sized(tcx.at(DUMMY_SP), param_env); if !always_sized { StructKind::MaybeUnsized } else { StructKind::AlwaysSized } }; @@ -872,7 +873,7 @@ _ => Abi::Aggregate { sized: true }, }; - if st.iter().all(|v| v.abi == Abi::Uninhabited) { + if st.iter().all(|v| v.abi.is_uninhabited()) { abi = Abi::Uninhabited; } @@ -900,7 +901,7 @@ let discr_type = def.repr.discr_type(); let bits = Integer::from_attr(tcx, discr_type).size().bits(); for (i, discr) in def.discriminants(tcx).enumerate() { - if variants[i].iter().any(|f| f.abi == Abi::Uninhabited) { + if variants[i].iter().any(|f| f.abi.is_uninhabited()) { continue; } let mut x = discr.val as i128; @@ -1096,7 +1097,7 @@ } } - if layout_variants.iter().all(|v| v.abi == Abi::Uninhabited) { + if layout_variants.iter().all(|v| v.abi.is_uninhabited()) { abi = Abi::Uninhabited; } @@ -1123,7 +1124,7 @@ } tcx.layout_raw(param_env.and(normalized))? } - ty::GeneratorWitness(..) | ty::Infer(_) => { + ty::UnnormalizedProjection(..) | ty::GeneratorWitness(..) | ty::Infer(_) => { bug!("LayoutDetails::compute: unexpected type `{}`", ty) } ty::Param(_) | ty::Error => { @@ -1258,8 +1259,8 @@ let fields: Vec<_> = variant_def.fields.iter().map(|f| f.ident.name).collect(); build_variant_info(Some(variant_def.name), - &fields, - layout.for_variant(self, i)) + &fields, + layout.for_variant(self, i)) }) .collect(); record(adt_kind.into(), adt_packed, match layout.variants { @@ -1403,7 +1404,7 @@ } } - pub fn same_size(self, other: SizeSkeleton) -> bool { + pub fn same_size(self, other: SizeSkeleton<'_>) -> bool { match (self, other) { (SizeSkeleton::Known(a), SizeSkeleton::Known(b)) => a == b, (SizeSkeleton::Pointer { tail: a, .. }, @@ -1702,8 +1703,8 @@ } } - ty::Projection(_) | ty::Opaque(..) | ty::Param(_) | - ty::Infer(_) | ty::Error => { + ty::Projection(_) | ty::UnnormalizedProjection(..) | + ty::Opaque(..) | ty::Param(_) | ty::Infer(_) | ty::Error => { bug!("TyLayout::field_type: unexpected type `{}`", this.ty) } }) diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -36,7 +36,7 @@ use ty::util::{IntTypeExt, Discr}; use ty::walk::TypeWalker; use util::captures::Captures; -use util::nodemap::{NodeSet, DefIdMap, FxHashMap, FxHashSet}; +use util::nodemap::{NodeSet, DefIdMap, FxHashMap}; use arena::SyncDroplessArena; use session::DataTypeKind; @@ -57,13 +57,14 @@ use syntax_pos::{DUMMY_SP, Span}; use smallvec; +use rustc_data_structures::indexed_vec::Idx; use rustc_data_structures::stable_hasher::{StableHasher, StableHasherResult, HashStable}; use hir; -pub use self::sty::{Binder, CanonicalVar, DebruijnIndex, INNERMOST}; -pub use self::sty::{FnSig, GenSig, PolyFnSig, PolyGenSig}; +pub use self::sty::{Binder, BoundTy, BoundTyIndex, DebruijnIndex, INNERMOST}; +pub use self::sty::{FnSig, GenSig, CanonicalPolyFnSig, PolyFnSig, PolyGenSig}; pub use self::sty::{InferTy, ParamTy, ProjectionTy, ExistentialPredicate}; pub use self::sty::{ClosureSubsts, GeneratorSubsts, UpvarSubsts, TypeAndMut}; pub use self::sty::{TraitRef, TyKind, PolyTraitRef}; @@ -80,7 +81,7 @@ pub use self::binding::BindingMode; pub use self::binding::BindingMode::*; -pub use self::context::{TyCtxt, GlobalArenas, AllArenas, tls, keep_local}; +pub use self::context::{TyCtxt, FreeRegionInfo, GlobalArenas, AllArenas, tls, keep_local}; pub use self::context::{Lift, TypeckTables}; pub use self::instance::{Instance, InstanceDef}; @@ -94,6 +95,7 @@ pub mod cast; #[macro_use] pub mod codec; +mod constness; pub mod error; mod erase_regions; pub mod fast_reject; @@ -139,7 +141,9 @@ pub maybe_unused_trait_imports: NodeSet, pub maybe_unused_extern_crates: Vec<(NodeId, Span)>, pub export_map: ExportMap, - pub extern_prelude: FxHashSet, + /// Extern prelude entries. The value is `true` if the entry was introduced + /// via `extern crate` item and not `--extern` option or compiler built-in. + pub extern_prelude: FxHashMap, } #[derive(Clone, Copy, PartialEq, Eq, Debug)] @@ -274,7 +278,7 @@ } impl Visibility { - pub fn from_hir(visibility: &hir::Visibility, id: NodeId, tcx: TyCtxt) -> Self { + pub fn from_hir(visibility: &hir::Visibility, id: NodeId, tcx: TyCtxt<'_, '_, '_>) -> Self { match visibility.node { hir::VisibilityKind::Public => Visibility::Public, hir::VisibilityKind::Crate(_) => Visibility::Restricted(DefId::local(CRATE_DEF_INDEX)), @@ -326,7 +330,7 @@ } } -#[derive(Clone, PartialEq, RustcDecodable, RustcEncodable, Copy)] +#[derive(Copy, Clone, PartialEq, Eq, RustcDecodable, RustcEncodable, Hash)] pub enum Variance { Covariant, // T <: T iff A <: B -- e.g., function return type Invariant, // T <: T iff B == A -- e.g., type of mutable cell @@ -537,7 +541,7 @@ impl<'tcx> Hash for TyS<'tcx> { fn hash(&self, s: &mut H) { - (self as *const TyS).hash(s) + (self as *const TyS<'_>).hash(s) } } @@ -650,7 +654,7 @@ } impl fmt::Debug for List { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { (**self).fmt(f) } } @@ -862,24 +866,22 @@ impl GenericParamDef { pub fn to_early_bound_region_data(&self) -> ty::EarlyBoundRegion { - match self.kind { - GenericParamDefKind::Lifetime => { - ty::EarlyBoundRegion { - def_id: self.def_id, - index: self.index, - name: self.name, - } + if let GenericParamDefKind::Lifetime = self.kind { + ty::EarlyBoundRegion { + def_id: self.def_id, + index: self.index, + name: self.name, } - _ => bug!("cannot convert a non-lifetime parameter def to an early bound region") + } else { + bug!("cannot convert a non-lifetime parameter def to an early bound region") } } pub fn to_bound_region(&self) -> ty::BoundRegion { - match self.kind { - GenericParamDefKind::Lifetime => { - self.to_early_bound_region_data().to_bound_region() - } - _ => bug!("cannot convert a non-lifetime parameter def to an early bound region") + if let GenericParamDefKind::Lifetime = self.kind { + self.to_early_bound_region_data().to_bound_region() + } else { + bug!("cannot convert a non-lifetime parameter def to an early bound region") } } } @@ -957,7 +959,7 @@ } } else { tcx.generics_of(self.parent.expect("parent_count>0 but no parent?")) - .region_param(param, tcx) + .region_param(param, tcx) } } @@ -974,7 +976,7 @@ } } else { tcx.generics_of(self.parent.expect("parent_count>0 but no parent?")) - .type_param(param, tcx) + .type_param(param, tcx) } } } @@ -983,7 +985,7 @@ #[derive(Clone, Default)] pub struct GenericPredicates<'tcx> { pub parent: Option, - pub predicates: Vec>, + pub predicates: Vec<(Predicate<'tcx>, Span)>, } impl<'tcx> serialize::UseSpecializedEncodable for GenericPredicates<'tcx> {} @@ -999,7 +1001,7 @@ pub fn instantiate_own(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, substs: &Substs<'tcx>) -> InstantiatedPredicates<'tcx> { InstantiatedPredicates { - predicates: self.predicates.subst(tcx, substs) + predicates: self.predicates.iter().map(|(p, _)| p.subst(tcx, substs)).collect(), } } @@ -1009,7 +1011,9 @@ if let Some(def_id) = self.parent { tcx.predicates_of(def_id).instantiate_into(tcx, instantiated, substs); } - instantiated.predicates.extend(self.predicates.iter().map(|p| p.subst(tcx, substs))) + instantiated.predicates.extend( + self.predicates.iter().map(|(p, _)| p.subst(tcx, substs)), + ); } pub fn instantiate_identity(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) @@ -1024,7 +1028,7 @@ if let Some(def_id) = self.parent { tcx.predicates_of(def_id).instantiate_identity_into(tcx, instantiated); } - instantiated.predicates.extend(&self.predicates) + instantiated.predicates.extend(self.predicates.iter().map(|&(p, _)| p)) } pub fn instantiate_supertrait(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, @@ -1033,7 +1037,7 @@ { assert_eq!(self.parent, None); InstantiatedPredicates { - predicates: self.predicates.iter().map(|pred| { + predicates: self.predicates.iter().map(|(pred, _)| { pred.subst_supertrait(tcx, poly_trait_ref) }).collect() } @@ -1262,7 +1266,7 @@ self.skip_binder().projection_ty.item_def_id } - pub fn to_poly_trait_ref(&self, tcx: TyCtxt) -> PolyTraitRef<'tcx> { + pub fn to_poly_trait_ref(&self, tcx: TyCtxt<'_, '_, '_>) -> PolyTraitRef<'tcx> { // Note: unlike with TraitRef::to_poly_trait_ref(), // self.0.trait_ref is permitted to have escaping regions. // This is because here `self` has a `Binder` and so does our @@ -1374,7 +1378,7 @@ } }; - // The only reason to collect into a vector here is that I was + // FIXME: The only reason to collect into a vector here is that I was // too lazy to make the full (somewhat complicated) iterator // type that would be needed here. But I wanted this fn to // return an iterator conceptually, rather than a `Vec`, so as @@ -1456,10 +1460,10 @@ /// "Universes" are used during type- and trait-checking in the /// presence of `for<..>` binders to control what sets of names are /// visible. Universes are arranged into a tree: the root universe -/// contains names that are always visible. But when you enter into -/// some subuniverse, then it may add names that are only visible -/// within that subtree (but it can still name the names of its -/// ancestor universes). +/// contains names that are always visible. Each child then adds a new +/// set of names that are visible, in addition to those of its parent. +/// We say that the child universe "extends" the parent universe with +/// new names. /// /// To make this more concrete, consider this program: /// @@ -1471,84 +1475,69 @@ /// ``` /// /// The struct name `Foo` is in the root universe U0. But the type -/// parameter `T`, introduced on `bar`, is in a subuniverse U1 -- -/// i.e., within `bar`, we can name both `T` and `Foo`, but outside of -/// `bar`, we cannot name `T`. Then, within the type of `y`, the -/// region `'a` is in a subuniverse U2 of U1, because we can name it -/// inside the fn type but not outside. +/// parameter `T`, introduced on `bar`, is in an extended universe U1 +/// -- i.e., within `bar`, we can name both `T` and `Foo`, but outside +/// of `bar`, we cannot name `T`. Then, within the type of `y`, the +/// region `'a` is in a universe U2 that extends U1, because we can +/// name it inside the fn type but not outside. /// -/// Universes are related to **skolemization** -- which is a way of -/// doing type- and trait-checking around these "forall" binders (also -/// called **universal quantification**). The idea is that when, in -/// the body of `bar`, we refer to `T` as a type, we aren't referring -/// to any type in particular, but rather a kind of "fresh" type that -/// is distinct from all other types we have actually declared. This -/// is called a **skolemized** type, and we use universes to talk -/// about this. In other words, a type name in universe 0 always -/// corresponds to some "ground" type that the user declared, but a -/// type name in a non-zero universe is a skolemized type -- an -/// idealized representative of "types in general" that we use for -/// checking generic functions. -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)] -pub struct UniverseIndex(u32); +/// Universes are used to do type- and trait-checking around these +/// "forall" binders (also called **universal quantification**). The +/// idea is that when, in the body of `bar`, we refer to `T` as a +/// type, we aren't referring to any type in particular, but rather a +/// kind of "fresh" type that is distinct from all other types we have +/// actually declared. This is called a **placeholder** type, and we +/// use universes to talk about this. In other words, a type name in +/// universe 0 always corresponds to some "ground" type that the user +/// declared, but a type name in a non-zero universe is a placeholder +/// type -- an idealized representative of "types in general" that we +/// use for checking generic functions. +newtype_index! { + pub struct UniverseIndex { + DEBUG_FORMAT = "U{}", + } +} + +impl_stable_hash_for!(struct UniverseIndex { private }); impl UniverseIndex { - /// The root universe, where things that the user defined are - /// visible. - pub const ROOT: Self = UniverseIndex(0); - - /// The "max universe" -- this isn't really a valid universe, but - /// it's useful sometimes as a "starting value" when you are - /// taking the minimum of a (non-empty!) set of universes. - pub const MAX: Self = UniverseIndex(::std::u32::MAX); - - /// Creates a universe index from the given integer. Not to be - /// used lightly lest you pick a bad value. But sometimes we - /// convert universe indices into integers and back for various - /// reasons. - pub fn from_u32(index: u32) -> Self { - UniverseIndex(index) - } + pub const ROOT: UniverseIndex = UniverseIndex::from_u32_const(0); - /// A "subuniverse" corresponds to being inside a `forall` quantifier. - /// So, for example, suppose we have this type in universe `U`: + /// Returns the "next" universe index in order -- this new index + /// is considered to extend all previous universes. This + /// corresponds to entering a `forall` quantifier. So, for + /// example, suppose we have this type in universe `U`: /// /// ``` /// for<'a> fn(&'a u32) /// ``` /// /// Once we "enter" into this `for<'a>` quantifier, we are in a - /// subuniverse of `U` -- in this new universe, we can name the - /// region `'a`, but that region was not nameable from `U` because - /// it was not in scope there. - pub fn subuniverse(self) -> UniverseIndex { - UniverseIndex(self.0.checked_add(1).unwrap()) - } - - /// True if the names in this universe are a subset of the names in `other`. - pub fn is_subset_of(self, other: UniverseIndex) -> bool { - self.0 <= other.0 - } - - pub fn as_u32(&self) -> u32 { - self.0 - } - - pub fn as_usize(&self) -> usize { - self.0 as usize + /// new universe that extends `U` -- in this new universe, we can + /// name the region `'a`, but that region was not nameable from + /// `U` because it was not in scope there. + pub fn next_universe(self) -> UniverseIndex { + UniverseIndex::from_u32(self.private.checked_add(1).unwrap()) + } + + /// True if `self` can name a name from `other` -- in other words, + /// if the set of names in `self` is a superset of those in + /// `other`. + pub fn can_name(self, other: UniverseIndex) -> bool { + self.private >= other.private } } -impl fmt::Debug for UniverseIndex { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - write!(fmt, "U{}", self.as_u32()) - } -} - -impl From for UniverseIndex { - fn from(index: u32) -> Self { - UniverseIndex(index) - } +/// The "placeholder index" fully defines a placeholder region. +/// Placeholder regions are identified by both a **universe** as well +/// as a "bound-region" within that universe. The `bound_region` is +/// basically a name -- distinct bound regions within the same +/// universe are just two regions with an unknown relationship to one +/// another. +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, PartialOrd, Ord)] +pub struct Placeholder { + pub universe: UniverseIndex, + pub name: BoundRegion, } /// When type checking, we use the `ParamEnv` to track @@ -1693,9 +1682,13 @@ const IS_FUNDAMENTAL = 1 << 2; const IS_UNION = 1 << 3; const IS_BOX = 1 << 4; + /// Indicates whether the type is an `Arc`. + const IS_ARC = 1 << 5; + /// Indicates whether the type is an `Rc`. + const IS_RC = 1 << 6; /// Indicates whether the variant list of this ADT is `#[non_exhaustive]`. /// (i.e., this flag is never set unless this ADT is an enum). - const IS_VARIANT_LIST_NON_EXHAUSTIVE = 1 << 5; + const IS_VARIANT_LIST_NON_EXHAUSTIVE = 1 << 7; } } @@ -1725,19 +1718,29 @@ /// - `did` is the DefId used for the variant - for tuple-structs, it is the constructor DefId, /// and for everything else, it is the variant DefId. /// - `attribute_def_id` is the DefId that has the variant's attributes. + /// this is the struct DefId for structs, and the variant DefId for variants. + /// + /// Note that we *could* use the constructor DefId, because the constructor attributes + /// redirect to the base attributes, but compiling a small crate requires + /// loading the AdtDefs for all the structs in the universe (e.g. coherence for any + /// built-in trait), and we do not want to load attributes twice. + /// + /// If someone speeds up attribute loading to not be a performance concern, they can + /// remove this hack and use the constructor DefId everywhere. pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>, did: DefId, name: Name, discr: VariantDiscr, fields: Vec, adt_kind: AdtKind, - ctor_kind: CtorKind) + ctor_kind: CtorKind, + attribute_def_id: DefId) -> Self { - debug!("VariantDef::new({:?}, {:?}, {:?}, {:?}, {:?}, {:?})", did, name, discr, fields, - adt_kind, ctor_kind); + debug!("VariantDef::new({:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?})", did, name, discr, + fields, adt_kind, ctor_kind, attribute_def_id); let mut flags = VariantFlags::NO_VARIANT_FLAGS; - if adt_kind == AdtKind::Struct && tcx.has_attr(did, "non_exhaustive") { + if adt_kind == AdtKind::Struct && tcx.has_attr(attribute_def_id, "non_exhaustive") { debug!("found non-exhaustive field list for {:?}", did); flags = flags | VariantFlags::IS_FIELD_LIST_NON_EXHAUSTIVE; } @@ -1840,8 +1843,7 @@ hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { thread_local! { - static CACHE: RefCell> = - RefCell::new(FxHashMap()); + static CACHE: RefCell> = Default::default(); } let hash: Fingerprint = CACHE.with(|cache| { @@ -1920,7 +1922,7 @@ }); impl ReprOptions { - pub fn new(tcx: TyCtxt, did: DefId) -> ReprOptions { + pub fn new(tcx: TyCtxt<'_, '_, '_>, did: DefId) -> ReprOptions { let mut flags = ReprFlags::empty(); let mut size = None; let mut max_align = 0; @@ -1988,7 +1990,7 @@ } impl<'a, 'gcx, 'tcx> AdtDef { - fn new(tcx: TyCtxt, + fn new(tcx: TyCtxt<'_, '_, '_>, did: DefId, kind: AdtKind, variants: Vec, @@ -2005,6 +2007,12 @@ if Some(did) == tcx.lang_items().owned_box() { flags = flags | AdtFlags::IS_BOX; } + if Some(did) == tcx.lang_items().arc() { + flags = flags | AdtFlags::IS_ARC; + } + if Some(did) == tcx.lang_items().rc() { + flags = flags | AdtFlags::IS_RC; + } if kind == AdtKind::Enum && tcx.has_attr(did, "non_exhaustive") { debug!("found non-exhaustive variant list for {:?}", did); flags = flags | AdtFlags::IS_VARIANT_LIST_NON_EXHAUSTIVE; @@ -2083,6 +2091,16 @@ self.flags.intersects(AdtFlags::IS_PHANTOM_DATA) } + /// Returns `true` if this is `Arc`. + pub fn is_arc(&self) -> bool { + self.flags.intersects(AdtFlags::IS_ARC) + } + + /// Returns `true` if this is `Rc`. + pub fn is_rc(&self) -> bool { + self.flags.intersects(AdtFlags::IS_RC) + } + /// Returns true if this is Box. #[inline] pub fn is_box(&self) -> bool { @@ -2181,7 +2199,7 @@ if !expr_did.is_local() { span_bug!(tcx.def_span(expr_did), "variant discriminant evaluation succeeded \ - in its crate but failed locally"); + in its crate but failed locally"); } None } @@ -2317,9 +2335,9 @@ debug!("sized_constraint_for_ty({:?}) intermediate = {:?}", ty, adt_tys); adt_tys.iter() - .map(|ty| ty.subst(tcx, substs)) - .flat_map(|ty| self.sized_constraint_for_ty(tcx, ty)) - .collect() + .map(|ty| ty.subst(tcx, substs)) + .flat_map(|ty| self.sized_constraint_for_ty(tcx, ty)) + .collect() } Projection(..) | Opaque(..) => { @@ -2328,6 +2346,8 @@ vec![ty] } + UnnormalizedProjection(..) => bug!("only used with chalk-engine"), + Param(..) => { // perf hack: if there is a `T: Sized` bound, then // we know that `T` is Sized and do not need to check @@ -2342,7 +2362,7 @@ substs: tcx.mk_substs_trait(ty, &[]) }).to_predicate(); let predicates = tcx.predicates_of(self.did).predicates; - if predicates.into_iter().any(|p| p == sized_predicate) { + if predicates.into_iter().any(|(p, _)| p == sized_predicate) { vec![] } else { vec![ty] @@ -2633,7 +2653,7 @@ } } - pub fn field_index(self, node_id: NodeId, tables: &TypeckTables) -> usize { + pub fn field_index(self, node_id: NodeId, tables: &TypeckTables<'_>) -> usize { let hir_id = self.hir.node_to_hir_id(node_id); tables.field_indices().get(hir_id).cloned().expect("no index for a field") } @@ -2653,23 +2673,32 @@ as Box + 'a> } - /// Returns true if the impls are the same polarity and are implementing - /// a trait which contains no items + /// Returns true if the impls are the same polarity and the trait either + /// has no items or is annotated #[marker] and prevents item overrides. pub fn impls_are_allowed_to_overlap(self, def_id1: DefId, def_id2: DefId) -> bool { - if !self.features().overlapping_marker_traits { - return false; + if self.features().overlapping_marker_traits { + let trait1_is_empty = self.impl_trait_ref(def_id1) + .map_or(false, |trait_ref| { + self.associated_item_def_ids(trait_ref.def_id).is_empty() + }); + let trait2_is_empty = self.impl_trait_ref(def_id2) + .map_or(false, |trait_ref| { + self.associated_item_def_ids(trait_ref.def_id).is_empty() + }); + self.impl_polarity(def_id1) == self.impl_polarity(def_id2) + && trait1_is_empty + && trait2_is_empty + } else if self.features().marker_trait_attr { + let is_marker_impl = |def_id: DefId| -> bool { + let trait_ref = self.impl_trait_ref(def_id); + trait_ref.map_or(false, |tr| self.trait_def(tr.def_id).is_marker) + }; + self.impl_polarity(def_id1) == self.impl_polarity(def_id2) + && is_marker_impl(def_id1) + && is_marker_impl(def_id2) + } else { + false } - let trait1_is_empty = self.impl_trait_ref(def_id1) - .map_or(false, |trait_ref| { - self.associated_item_def_ids(trait_ref.def_id).is_empty() - }); - let trait2_is_empty = self.impl_trait_ref(def_id2) - .map_or(false, |trait_ref| { - self.associated_item_def_ids(trait_ref.def_id).is_empty() - }); - self.impl_polarity(def_id1) == self.impl_polarity(def_id2) - && trait1_is_empty - && trait2_is_empty } // Returns `ty::VariantDef` if `def` refers to a struct, @@ -2849,9 +2878,7 @@ } } -fn associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) - -> AssociatedItem -{ +fn associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> AssociatedItem { let id = tcx.hir.as_local_node_id(def_id).unwrap(); let parent_id = tcx.hir.get_parent(id); let parent_def_id = tcx.hir.local_def_id(parent_id); @@ -2951,7 +2978,7 @@ } /// Yields the parent function's `DefId` if `def_id` is an `impl Trait` definition -pub fn is_impl_trait_defn(tcx: TyCtxt, def_id: DefId) -> Option { +pub fn is_impl_trait_defn(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Option { if let Some(node_id) = tcx.hir.as_local_node_id(def_id) { if let Node::Item(item) = tcx.hir.get(node_id) { if let hir::ItemKind::Existential(ref exist_ty) = item.node { @@ -2965,8 +2992,8 @@ /// See `ParamEnv` struct def'n for details. fn param_env<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) - -> ParamEnv<'tcx> { - + -> ParamEnv<'tcx> +{ // The param_env of an impl Trait type is its defining function's param_env if let Some(parent) = is_impl_trait_defn(tcx, def_id) { return param_env(tcx, parent); @@ -3031,11 +3058,12 @@ } } -pub fn provide(providers: &mut ty::query::Providers) { +pub fn provide(providers: &mut ty::query::Providers<'_>) { context::provide(providers); erase_regions::provide(providers); layout::provide(providers); util::provide(providers); + constness::provide(providers); *providers = ty::query::Providers { associated_item, associated_item_def_ids, @@ -3086,13 +3114,13 @@ } impl fmt::Display for SymbolName { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&self.name, fmt) } } impl fmt::Debug for SymbolName { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&self.name, fmt) } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/outlives.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/outlives.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/outlives.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/outlives.rs 2018-12-04 23:41:40.000000000 +0000 @@ -73,7 +73,6 @@ // projection). match ty.sty { ty::Closure(def_id, ref substs) => { - for upvar_ty in substs.upvar_tys(def_id, *self) { self.compute_components(upvar_ty, out); } @@ -124,6 +123,8 @@ } } + ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"), + // We assume that inference variables are fully resolved. // So, if we encounter an inference variable, just record // the unresolved variable as a component. @@ -181,9 +182,5 @@ } fn push_region_constraints<'tcx>(out: &mut Vec>, regions: Vec>) { - for r in regions { - if !r.is_late_bound() { - out.push(Component::Region(r)); - } - } + out.extend(regions.iter().filter(|&r| !r.is_late_bound()).map(|r| Component::Region(r))); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/query/config.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/query/config.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/query/config.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/query/config.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,9 +12,11 @@ use dep_graph::DepNode; use hir::def_id::{CrateNum, DefId, DefIndex}; use mir::interpret::GlobalId; +use traits; use traits::query::{ - CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal, CanonicalTypeOpEqGoal, - CanonicalTypeOpNormalizeGoal, CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpSubtypeGoal, + CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal, + CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpNormalizeGoal, + CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpSubtypeGoal, }; use ty::{self, ParamEnvAnd, Ty, TyCtxt}; use ty::subst::Substs; @@ -23,6 +25,7 @@ use ty::query::QueryCache; use util::profiling::ProfileCategory; +use std::borrow::Cow; use std::hash::Hash; use std::fmt::Debug; use syntax_pos::symbol::InternedString; @@ -55,7 +58,7 @@ } pub(super) trait QueryDescription<'tcx>: QueryAccessors<'tcx> { - fn describe(tcx: TyCtxt, key: Self::Key) -> String; + fn describe(tcx: TyCtxt<'_, '_, '_>, key: Self::Key) -> Cow<'static, str>; #[inline] fn cache_on_disk(_: Self::Key) -> bool { @@ -70,213 +73,233 @@ } impl<'tcx, M: QueryAccessors<'tcx, Key=DefId>> QueryDescription<'tcx> for M { - default fn describe(tcx: TyCtxt, def_id: DefId) -> String { + default fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { if !tcx.sess.verbose() { - format!("processing `{}`", tcx.item_path_str(def_id)) + format!("processing `{}`", tcx.item_path_str(def_id)).into() } else { let name = unsafe { ::std::intrinsics::type_name::() }; - format!("processing `{}` applied to `{:?}`", name, def_id) + format!("processing `{}` applied to `{:?}`", name, def_id).into() } } } impl<'tcx> QueryDescription<'tcx> for queries::normalize_projection_ty<'tcx> { fn describe( - _tcx: TyCtxt, + _tcx: TyCtxt<'_, '_, '_>, goal: CanonicalProjectionGoal<'tcx>, - ) -> String { - format!("normalizing `{:?}`", goal) + ) -> Cow<'static, str> { + format!("normalizing `{:?}`", goal).into() } } impl<'tcx> QueryDescription<'tcx> for queries::implied_outlives_bounds<'tcx> { - fn describe(_tcx: TyCtxt, goal: CanonicalTyGoal<'tcx>) -> String { - format!("computing implied outlives bounds for `{:?}`", goal) + fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTyGoal<'tcx>) -> Cow<'static, str> { + format!("computing implied outlives bounds for `{:?}`", goal).into() } } impl<'tcx> QueryDescription<'tcx> for queries::dropck_outlives<'tcx> { - fn describe(_tcx: TyCtxt, goal: CanonicalTyGoal<'tcx>) -> String { - format!("computing dropck types for `{:?}`", goal) + fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTyGoal<'tcx>) -> Cow<'static, str> { + format!("computing dropck types for `{:?}`", goal).into() } } impl<'tcx> QueryDescription<'tcx> for queries::normalize_ty_after_erasing_regions<'tcx> { - fn describe(_tcx: TyCtxt, goal: ParamEnvAnd<'tcx, Ty<'tcx>>) -> String { - format!("normalizing `{:?}`", goal) + fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: ParamEnvAnd<'tcx, Ty<'tcx>>) -> Cow<'static, str> { + format!("normalizing `{:?}`", goal).into() } } impl<'tcx> QueryDescription<'tcx> for queries::evaluate_obligation<'tcx> { - fn describe(_tcx: TyCtxt, goal: CanonicalPredicateGoal<'tcx>) -> String { - format!("evaluating trait selection obligation `{}`", goal.value.value) + fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalPredicateGoal<'tcx>) -> Cow<'static, str> { + format!("evaluating trait selection obligation `{}`", goal.value.value).into() + } +} + +impl<'tcx> QueryDescription<'tcx> for queries::type_op_ascribe_user_type<'tcx> { + fn describe( + _tcx: TyCtxt<'_, '_, '_>, + goal: CanonicalTypeOpAscribeUserTypeGoal<'tcx>, + ) -> Cow<'static, str> { + format!("evaluating `type_op_ascribe_user_type` `{:?}`", goal).into() } } impl<'tcx> QueryDescription<'tcx> for queries::type_op_eq<'tcx> { - fn describe(_tcx: TyCtxt, goal: CanonicalTypeOpEqGoal<'tcx>) -> String { - format!("evaluating `type_op_eq` `{:?}`", goal) + fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTypeOpEqGoal<'tcx>) -> Cow<'static, str> { + format!("evaluating `type_op_eq` `{:?}`", goal).into() } } impl<'tcx> QueryDescription<'tcx> for queries::type_op_subtype<'tcx> { - fn describe(_tcx: TyCtxt, goal: CanonicalTypeOpSubtypeGoal<'tcx>) -> String { - format!("evaluating `type_op_subtype` `{:?}`", goal) + fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTypeOpSubtypeGoal<'tcx>) + -> Cow<'static, str> { + format!("evaluating `type_op_subtype` `{:?}`", goal).into() } } impl<'tcx> QueryDescription<'tcx> for queries::type_op_prove_predicate<'tcx> { - fn describe(_tcx: TyCtxt, goal: CanonicalTypeOpProvePredicateGoal<'tcx>) -> String { - format!("evaluating `type_op_prove_predicate` `{:?}`", goal) + fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTypeOpProvePredicateGoal<'tcx>) + -> Cow<'static, str> { + format!("evaluating `type_op_prove_predicate` `{:?}`", goal).into() } } impl<'tcx> QueryDescription<'tcx> for queries::type_op_normalize_ty<'tcx> { - fn describe(_tcx: TyCtxt, goal: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>) -> String { - format!("normalizing `{:?}`", goal) + fn describe(_tcx: TyCtxt<'_, '_, '_>, + goal: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>) -> Cow<'static, str> { + format!("normalizing `{:?}`", goal).into() } } impl<'tcx> QueryDescription<'tcx> for queries::type_op_normalize_predicate<'tcx> { fn describe( - _tcx: TyCtxt, + _tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::Predicate<'tcx>>, - ) -> String { - format!("normalizing `{:?}`", goal) + ) -> Cow<'static, str> { + format!("normalizing `{:?}`", goal).into() } } impl<'tcx> QueryDescription<'tcx> for queries::type_op_normalize_poly_fn_sig<'tcx> { fn describe( - _tcx: TyCtxt, + _tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>>, - ) -> String { - format!("normalizing `{:?}`", goal) + ) -> Cow<'static, str> { + format!("normalizing `{:?}`", goal).into() } } impl<'tcx> QueryDescription<'tcx> for queries::type_op_normalize_fn_sig<'tcx> { - fn describe(_tcx: TyCtxt, goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>>) -> String { - format!("normalizing `{:?}`", goal) + fn describe(_tcx: TyCtxt<'_, '_, '_>, + goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>>) -> Cow<'static, str> { + format!("normalizing `{:?}`", goal).into() } } impl<'tcx> QueryDescription<'tcx> for queries::is_copy_raw<'tcx> { - fn describe(_tcx: TyCtxt, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> String { - format!("computing whether `{}` is `Copy`", env.value) + fn describe(_tcx: TyCtxt<'_, '_, '_>, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) + -> Cow<'static, str> { + format!("computing whether `{}` is `Copy`", env.value).into() } } impl<'tcx> QueryDescription<'tcx> for queries::is_sized_raw<'tcx> { - fn describe(_tcx: TyCtxt, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> String { - format!("computing whether `{}` is `Sized`", env.value) + fn describe(_tcx: TyCtxt<'_, '_, '_>, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) + -> Cow<'static, str> { + format!("computing whether `{}` is `Sized`", env.value).into() } } impl<'tcx> QueryDescription<'tcx> for queries::is_freeze_raw<'tcx> { - fn describe(_tcx: TyCtxt, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> String { - format!("computing whether `{}` is freeze", env.value) + fn describe(_tcx: TyCtxt<'_, '_, '_>, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) + -> Cow<'static, str> { + format!("computing whether `{}` is freeze", env.value).into() } } impl<'tcx> QueryDescription<'tcx> for queries::needs_drop_raw<'tcx> { - fn describe(_tcx: TyCtxt, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> String { - format!("computing whether `{}` needs drop", env.value) + fn describe(_tcx: TyCtxt<'_, '_, '_>, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) + -> Cow<'static, str> { + format!("computing whether `{}` needs drop", env.value).into() } } impl<'tcx> QueryDescription<'tcx> for queries::layout_raw<'tcx> { - fn describe(_tcx: TyCtxt, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> String { - format!("computing layout of `{}`", env.value) + fn describe(_tcx: TyCtxt<'_, '_, '_>, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) + -> Cow<'static, str> { + format!("computing layout of `{}`", env.value).into() } } impl<'tcx> QueryDescription<'tcx> for queries::super_predicates_of<'tcx> { - fn describe(tcx: TyCtxt, def_id: DefId) -> String { + fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { format!("computing the supertraits of `{}`", - tcx.item_path_str(def_id)) + tcx.item_path_str(def_id)).into() } } impl<'tcx> QueryDescription<'tcx> for queries::erase_regions_ty<'tcx> { - fn describe(_tcx: TyCtxt, ty: Ty<'tcx>) -> String { - format!("erasing regions from `{:?}`", ty) + fn describe(_tcx: TyCtxt<'_, '_, '_>, ty: Ty<'tcx>) -> Cow<'static, str> { + format!("erasing regions from `{:?}`", ty).into() } } impl<'tcx> QueryDescription<'tcx> for queries::type_param_predicates<'tcx> { - fn describe(tcx: TyCtxt, (_, def_id): (DefId, DefId)) -> String { + fn describe(tcx: TyCtxt<'_, '_, '_>, (_, def_id): (DefId, DefId)) -> Cow<'static, str> { let id = tcx.hir.as_local_node_id(def_id).unwrap(); format!("computing the bounds for type parameter `{}`", - tcx.hir.ty_param_name(id)) + tcx.hir.ty_param_name(id)).into() } } impl<'tcx> QueryDescription<'tcx> for queries::coherent_trait<'tcx> { - fn describe(tcx: TyCtxt, def_id: DefId) -> String { + fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { format!("coherence checking all impls of trait `{}`", - tcx.item_path_str(def_id)) + tcx.item_path_str(def_id)).into() } } impl<'tcx> QueryDescription<'tcx> for queries::upstream_monomorphizations<'tcx> { - fn describe(_: TyCtxt, k: CrateNum) -> String { - format!("collecting available upstream monomorphizations `{:?}`", k) + fn describe(_: TyCtxt<'_, '_, '_>, k: CrateNum) -> Cow<'static, str> { + format!("collecting available upstream monomorphizations `{:?}`", k).into() } } impl<'tcx> QueryDescription<'tcx> for queries::crate_inherent_impls<'tcx> { - fn describe(_: TyCtxt, k: CrateNum) -> String { - format!("all inherent impls defined in crate `{:?}`", k) + fn describe(_: TyCtxt<'_, '_, '_>, k: CrateNum) -> Cow<'static, str> { + format!("all inherent impls defined in crate `{:?}`", k).into() } } impl<'tcx> QueryDescription<'tcx> for queries::crate_inherent_impls_overlap_check<'tcx> { - fn describe(_: TyCtxt, _: CrateNum) -> String { - "check for overlap between inherent impls defined in this crate".to_string() + fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "check for overlap between inherent impls defined in this crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::crate_variances<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "computing the variances for items in this crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "computing the variances for items in this crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::inferred_outlives_crate<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "computing the inferred outlives predicates for items in this crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "computing the inferred outlives predicates for items in this crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::mir_shims<'tcx> { - fn describe(tcx: TyCtxt, def: ty::InstanceDef<'tcx>) -> String { + fn describe(tcx: TyCtxt<'_, '_, '_>, def: ty::InstanceDef<'tcx>) -> Cow<'static, str> { format!("generating MIR shim for `{}`", - tcx.item_path_str(def.def_id())) + tcx.item_path_str(def.def_id())).into() } } impl<'tcx> QueryDescription<'tcx> for queries::privacy_access_levels<'tcx> { - fn describe(_: TyCtxt, _: CrateNum) -> String { - "privacy access levels".to_string() + fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "privacy access levels".into() } } impl<'tcx> QueryDescription<'tcx> for queries::typeck_item_bodies<'tcx> { - fn describe(_: TyCtxt, _: CrateNum) -> String { - "type-checking all item bodies".to_string() + fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "type-checking all item bodies".into() } } impl<'tcx> QueryDescription<'tcx> for queries::reachable_set<'tcx> { - fn describe(_: TyCtxt, _: CrateNum) -> String { - "reachability".to_string() + fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "reachability".into() } } impl<'tcx> QueryDescription<'tcx> for queries::const_eval<'tcx> { - fn describe(tcx: TyCtxt, key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>) -> String { - format!("const-evaluating `{}`", tcx.item_path_str(key.value.instance.def.def_id())) + fn describe(tcx: TyCtxt<'_, '_, '_>, key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>) + -> Cow<'static, str> + { + format!("const-evaluating `{}`", tcx.item_path_str(key.value.instance.def.def_id())).into() } #[inline] @@ -293,14 +316,14 @@ } impl<'tcx> QueryDescription<'tcx> for queries::mir_keys<'tcx> { - fn describe(_: TyCtxt, _: CrateNum) -> String { - "getting a list of all mir_keys".to_string() + fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "getting a list of all mir_keys".into() } } impl<'tcx> QueryDescription<'tcx> for queries::symbol_name<'tcx> { - fn describe(_tcx: TyCtxt, instance: ty::Instance<'tcx>) -> String { - format!("computing the symbol for `{}`", instance) + fn describe(_tcx: TyCtxt<'_, '_, '_>, instance: ty::Instance<'tcx>) -> Cow<'static, str> { + format!("computing the symbol for `{}`", instance).into() } #[inline] @@ -317,64 +340,64 @@ } impl<'tcx> QueryDescription<'tcx> for queries::describe_def<'tcx> { - fn describe(_: TyCtxt, _: DefId) -> String { + fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { bug!("describe_def") } } impl<'tcx> QueryDescription<'tcx> for queries::def_span<'tcx> { - fn describe(_: TyCtxt, _: DefId) -> String { + fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { bug!("def_span") } } impl<'tcx> QueryDescription<'tcx> for queries::lookup_stability<'tcx> { - fn describe(_: TyCtxt, _: DefId) -> String { + fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { bug!("stability") } } impl<'tcx> QueryDescription<'tcx> for queries::lookup_deprecation_entry<'tcx> { - fn describe(_: TyCtxt, _: DefId) -> String { + fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { bug!("deprecation") } } impl<'tcx> QueryDescription<'tcx> for queries::item_attrs<'tcx> { - fn describe(_: TyCtxt, _: DefId) -> String { + fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { bug!("item_attrs") } } impl<'tcx> QueryDescription<'tcx> for queries::is_reachable_non_generic<'tcx> { - fn describe(_: TyCtxt, _: DefId) -> String { + fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { bug!("is_reachable_non_generic") } } impl<'tcx> QueryDescription<'tcx> for queries::fn_arg_names<'tcx> { - fn describe(_: TyCtxt, _: DefId) -> String { + fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { bug!("fn_arg_names") } } impl<'tcx> QueryDescription<'tcx> for queries::impl_parent<'tcx> { - fn describe(_: TyCtxt, _: DefId) -> String { + fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { bug!("impl_parent") } } impl<'tcx> QueryDescription<'tcx> for queries::trait_of_item<'tcx> { - fn describe(_: TyCtxt, _: DefId) -> String { + fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { bug!("trait_of_item") } } impl<'tcx> QueryDescription<'tcx> for queries::const_is_rvalue_promotable_to_static<'tcx> { - fn describe(tcx: TyCtxt, def_id: DefId) -> String { + fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { format!("const checking if rvalue is promotable to static `{}`", - tcx.item_path_str(def_id)) + tcx.item_path_str(def_id)).into() } #[inline] @@ -384,29 +407,31 @@ #[inline] fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - id: SerializedDepNodeIndex) - -> Option { + id: SerializedDepNodeIndex) + -> Option { tcx.queries.on_disk_cache.try_load_query_result(tcx, id) } } impl<'tcx> QueryDescription<'tcx> for queries::rvalue_promotable_map<'tcx> { - fn describe(tcx: TyCtxt, def_id: DefId) -> String { + fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { format!("checking which parts of `{}` are promotable to static", - tcx.item_path_str(def_id)) + tcx.item_path_str(def_id)).into() } } impl<'tcx> QueryDescription<'tcx> for queries::is_mir_available<'tcx> { - fn describe(tcx: TyCtxt, def_id: DefId) -> String { + fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { format!("checking if item is mir available: `{}`", - tcx.item_path_str(def_id)) + tcx.item_path_str(def_id)).into() } } impl<'tcx> QueryDescription<'tcx> for queries::codegen_fulfill_obligation<'tcx> { - fn describe(tcx: TyCtxt, key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)) -> String { + fn describe(tcx: TyCtxt<'_, '_, '_>, + key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)) -> Cow<'static, str> { format!("checking if `{}` fulfills its obligations", tcx.item_path_str(key.1.def_id())) + .into() } #[inline] @@ -423,320 +448,320 @@ } impl<'tcx> QueryDescription<'tcx> for queries::trait_impls_of<'tcx> { - fn describe(tcx: TyCtxt, def_id: DefId) -> String { - format!("trait impls of `{}`", tcx.item_path_str(def_id)) + fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { + format!("trait impls of `{}`", tcx.item_path_str(def_id)).into() } } impl<'tcx> QueryDescription<'tcx> for queries::is_object_safe<'tcx> { - fn describe(tcx: TyCtxt, def_id: DefId) -> String { - format!("determine object safety of trait `{}`", tcx.item_path_str(def_id)) + fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { + format!("determine object safety of trait `{}`", tcx.item_path_str(def_id)).into() } } -impl<'tcx> QueryDescription<'tcx> for queries::is_const_fn<'tcx> { - fn describe(tcx: TyCtxt, def_id: DefId) -> String { - format!("checking if item is const fn: `{}`", tcx.item_path_str(def_id)) +impl<'tcx> QueryDescription<'tcx> for queries::is_const_fn_raw<'tcx> { + fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { + format!("checking if item is const fn: `{}`", tcx.item_path_str(def_id)).into() } } impl<'tcx> QueryDescription<'tcx> for queries::dylib_dependency_formats<'tcx> { - fn describe(_: TyCtxt, _: CrateNum) -> String { - "dylib dependency formats of crate".to_string() + fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "dylib dependency formats of crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::is_panic_runtime<'tcx> { - fn describe(_: TyCtxt, _: CrateNum) -> String { - "checking if the crate is_panic_runtime".to_string() + fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "checking if the crate is_panic_runtime".into() } } impl<'tcx> QueryDescription<'tcx> for queries::is_compiler_builtins<'tcx> { - fn describe(_: TyCtxt, _: CrateNum) -> String { - "checking if the crate is_compiler_builtins".to_string() + fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "checking if the crate is_compiler_builtins".into() } } impl<'tcx> QueryDescription<'tcx> for queries::has_global_allocator<'tcx> { - fn describe(_: TyCtxt, _: CrateNum) -> String { - "checking if the crate has_global_allocator".to_string() + fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "checking if the crate has_global_allocator".into() } } impl<'tcx> QueryDescription<'tcx> for queries::has_panic_handler<'tcx> { - fn describe(_: TyCtxt, _: CrateNum) -> String { - "checking if the crate has_panic_handler".to_string() + fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "checking if the crate has_panic_handler".into() } } impl<'tcx> QueryDescription<'tcx> for queries::extern_crate<'tcx> { - fn describe(_: TyCtxt, _: DefId) -> String { - "getting crate's ExternCrateData".to_string() + fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { + "getting crate's ExternCrateData".into() } } impl<'tcx> QueryDescription<'tcx> for queries::lint_levels<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "computing the lint levels for items in this crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "computing the lint levels for items in this crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::specializes<'tcx> { - fn describe(_tcx: TyCtxt, _: (DefId, DefId)) -> String { - "computing whether impls specialize one another".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: (DefId, DefId)) -> Cow<'static, str> { + "computing whether impls specialize one another".into() } } impl<'tcx> QueryDescription<'tcx> for queries::in_scope_traits_map<'tcx> { - fn describe(_tcx: TyCtxt, _: DefIndex) -> String { - "traits in scope at a block".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: DefIndex) -> Cow<'static, str> { + "traits in scope at a block".into() } } impl<'tcx> QueryDescription<'tcx> for queries::is_no_builtins<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "test whether a crate has #![no_builtins]".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "test whether a crate has #![no_builtins]".into() } } impl<'tcx> QueryDescription<'tcx> for queries::panic_strategy<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "query a crate's configured panic strategy".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "query a crate's configured panic strategy".into() } } impl<'tcx> QueryDescription<'tcx> for queries::is_profiler_runtime<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "query a crate is #![profiler_runtime]".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "query a crate is #![profiler_runtime]".into() } } impl<'tcx> QueryDescription<'tcx> for queries::is_sanitizer_runtime<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "query a crate is #![sanitizer_runtime]".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "query a crate is #![sanitizer_runtime]".into() } } impl<'tcx> QueryDescription<'tcx> for queries::reachable_non_generics<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "looking up the exported symbols of a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up the exported symbols of a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::native_libraries<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "looking up the native libraries of a linked crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up the native libraries of a linked crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::foreign_modules<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "looking up the foreign modules of a linked crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up the foreign modules of a linked crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::plugin_registrar_fn<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "looking up the plugin registrar for a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up the plugin registrar for a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::derive_registrar_fn<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "looking up the derive registrar for a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up the derive registrar for a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::crate_disambiguator<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "looking up the disambiguator a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up the disambiguator a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::crate_hash<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "looking up the hash a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up the hash a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::original_crate_name<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "looking up the original name a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up the original name a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::extra_filename<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "looking up the extra filename for a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up the extra filename for a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::implementations_of_trait<'tcx> { - fn describe(_tcx: TyCtxt, _: (CrateNum, DefId)) -> String { - "looking up implementations of a trait in a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: (CrateNum, DefId)) -> Cow<'static, str> { + "looking up implementations of a trait in a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::all_trait_implementations<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "looking up all (?) trait implementations".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up all (?) trait implementations".into() } } impl<'tcx> QueryDescription<'tcx> for queries::link_args<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "looking up link arguments for a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up link arguments for a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::resolve_lifetimes<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "resolving lifetimes".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "resolving lifetimes".into() } } impl<'tcx> QueryDescription<'tcx> for queries::named_region_map<'tcx> { - fn describe(_tcx: TyCtxt, _: DefIndex) -> String { - "looking up a named region".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: DefIndex) -> Cow<'static, str> { + "looking up a named region".into() } } impl<'tcx> QueryDescription<'tcx> for queries::is_late_bound_map<'tcx> { - fn describe(_tcx: TyCtxt, _: DefIndex) -> String { - "testing if a region is late bound".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: DefIndex) -> Cow<'static, str> { + "testing if a region is late bound".into() } } impl<'tcx> QueryDescription<'tcx> for queries::object_lifetime_defaults_map<'tcx> { - fn describe(_tcx: TyCtxt, _: DefIndex) -> String { - "looking up lifetime defaults for a region".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: DefIndex) -> Cow<'static, str> { + "looking up lifetime defaults for a region".into() } } impl<'tcx> QueryDescription<'tcx> for queries::dep_kind<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "fetching what a dependency looks like".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "fetching what a dependency looks like".into() } } impl<'tcx> QueryDescription<'tcx> for queries::crate_name<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "fetching what a crate is named".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "fetching what a crate is named".into() } } impl<'tcx> QueryDescription<'tcx> for queries::get_lib_features<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - format!("calculating the lib features map") + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "calculating the lib features map".into() } } impl<'tcx> QueryDescription<'tcx> for queries::defined_lib_features<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - format!("calculating the lib features defined in a crate") + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "calculating the lib features defined in a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::get_lang_items<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "calculating the lang items map".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "calculating the lang items map".into() } } impl<'tcx> QueryDescription<'tcx> for queries::defined_lang_items<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "calculating the lang items defined in a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "calculating the lang items defined in a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::missing_lang_items<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "calculating the missing lang items in a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "calculating the missing lang items in a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::visible_parent_map<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "calculating the visible parent map".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "calculating the visible parent map".into() } } impl<'tcx> QueryDescription<'tcx> for queries::missing_extern_crate_item<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "seeing if we're missing an `extern crate` item for this crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "seeing if we're missing an `extern crate` item for this crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::used_crate_source<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "looking at the source for a crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking at the source for a crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::postorder_cnums<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "generating a postorder list of CrateNums".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "generating a postorder list of CrateNums".into() } } impl<'tcx> QueryDescription<'tcx> for queries::maybe_unused_extern_crates<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "looking up all possibly unused extern crates".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up all possibly unused extern crates".into() } } impl<'tcx> QueryDescription<'tcx> for queries::stability_index<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "calculating the stability index for the local crate".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "calculating the stability index for the local crate".into() } } impl<'tcx> QueryDescription<'tcx> for queries::all_traits<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "fetching all foreign and local traits".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "fetching all foreign and local traits".into() } } impl<'tcx> QueryDescription<'tcx> for queries::all_crate_nums<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "fetching all foreign CrateNum instances".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "fetching all foreign CrateNum instances".into() } } impl<'tcx> QueryDescription<'tcx> for queries::exported_symbols<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "exported_symbols".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "exported_symbols".into() } } impl<'tcx> QueryDescription<'tcx> for queries::collect_and_partition_mono_items<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "collect_and_partition_mono_items".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "collect_and_partition_mono_items".into() } } impl<'tcx> QueryDescription<'tcx> for queries::codegen_unit<'tcx> { - fn describe(_tcx: TyCtxt, _: InternedString) -> String { - "codegen_unit".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: InternedString) -> Cow<'static, str> { + "codegen_unit".into() } } impl<'tcx> QueryDescription<'tcx> for queries::output_filenames<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "output_filenames".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "output_filenames".into() } } impl<'tcx> QueryDescription<'tcx> for queries::vtable_methods<'tcx> { - fn describe(tcx: TyCtxt, key: ty::PolyTraitRef<'tcx> ) -> String { - format!("finding all methods for trait {}", tcx.item_path_str(key.def_id())) + fn describe(tcx: TyCtxt<'_, '_, '_>, key: ty::PolyTraitRef<'tcx> ) -> Cow<'static, str> { + format!("finding all methods for trait {}", tcx.item_path_str(key.def_id())).into() } } impl<'tcx> QueryDescription<'tcx> for queries::features_query<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "looking up enabled feature gates".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up enabled feature gates".into() } } @@ -773,20 +798,20 @@ } impl<'tcx> QueryDescription<'tcx> for queries::substitute_normalize_and_test_predicates<'tcx> { - fn describe(tcx: TyCtxt, key: (DefId, &'tcx Substs<'tcx>)) -> String { - format!("testing substituted normalized predicates:`{}`", tcx.item_path_str(key.0)) + fn describe(tcx: TyCtxt<'_, '_, '_>, key: (DefId, &'tcx Substs<'tcx>)) -> Cow<'static, str> { + format!("testing substituted normalized predicates:`{}`", tcx.item_path_str(key.0)).into() } } impl<'tcx> QueryDescription<'tcx> for queries::target_features_whitelist<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "looking up the whitelist of target features".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "looking up the whitelist of target features".into() } } impl<'tcx> QueryDescription<'tcx> for queries::instance_def_size_estimate<'tcx> { - fn describe(tcx: TyCtxt, def: ty::InstanceDef<'tcx>) -> String { - format!("estimating size for `{}`", tcx.item_path_str(def.def_id())) + fn describe(tcx: TyCtxt<'_, '_, '_>, def: ty::InstanceDef<'tcx>) -> Cow<'static, str> { + format!("estimating size for `{}`", tcx.item_path_str(def.def_id())).into() } } @@ -806,26 +831,32 @@ } impl<'tcx> QueryDescription<'tcx> for queries::program_clauses_for<'tcx> { - fn describe(_tcx: TyCtxt, _: DefId) -> String { - "generating chalk-style clauses".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { + "generating chalk-style clauses".into() } } impl<'tcx> QueryDescription<'tcx> for queries::program_clauses_for_env<'tcx> { - fn describe(_tcx: TyCtxt, _: ty::ParamEnv<'tcx>) -> String { - "generating chalk-style clauses for param env".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: traits::Environment<'tcx>) -> Cow<'static, str> { + "generating chalk-style clauses for environment".into() + } +} + +impl<'tcx> QueryDescription<'tcx> for queries::environment<'tcx> { + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { + "return a chalk-style environment".into() } } impl<'tcx> QueryDescription<'tcx> for queries::wasm_import_module_map<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "wasm import module map".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "wasm import module map".into() } } impl<'tcx> QueryDescription<'tcx> for queries::dllimport_foreign_items<'tcx> { - fn describe(_tcx: TyCtxt, _: CrateNum) -> String { - "wasm import module map".to_string() + fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { + "wasm import module map".into() } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/query/job.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/query/job.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/query/job.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/query/job.rs 2018-12-04 23:41:40.000000000 +0000 @@ -123,9 +123,11 @@ let mut cycle = Vec::new(); while let Some(job) = current_job { - cycle.insert(0, job.info.clone()); + cycle.push(job.info.clone()); if ptr::eq(&*job, self) { + cycle.reverse(); + // This is the end of the cycle // The span entry we included was for the usage // of the cycle itself, and not part of the cycle @@ -324,16 +326,16 @@ query: Lrc>, visited: &mut FxHashSet<*const QueryJob<'tcx>> ) -> bool { - // We already visited this or we're deliberately ignoring it - if visited.contains(&query.as_ptr()) { - return false; - } - // This query is connected to the root (it has no query parent), return true if query.parent.is_none() { return true; } + // We already visited this or we're deliberately ignoring it + if visited.contains(&query.as_ptr()) { + return false; + } + visited.insert(query.as_ptr()); let mut connected = false; @@ -368,13 +370,11 @@ // Reverse the stack so earlier entries require later entries stack.reverse(); - // Extract the spans and queries into separate arrays - let mut spans: Vec<_> = stack.iter().map(|e| e.0).collect(); - let queries = stack.into_iter().map(|e| e.1); + // The stack is a vector of pairs of spans and queries + let (mut spans, queries): (Vec<_>, Vec<_>) = stack.into_iter().unzip(); // Shift the spans so that queries are matched with the span for their waitee - let last = spans.pop().unwrap(); - spans.insert(0, last); + spans.rotate_right(1); // Zip them back together let mut stack: Vec<_> = spans.into_iter().zip(queries).collect(); @@ -388,7 +388,7 @@ // Find the queries in the cycle which are // connected to queries outside the cycle - let entry_points: Vec>> = stack.iter().filter_map(|query| { + let entry_points = stack.iter().filter_map(|query| { // Mark all the other queries in the cycle as already visited let mut visited = FxHashSet::from_iter(stack.iter().filter_map(|q| { if q.1.as_ptr() != query.1.as_ptr() { @@ -403,21 +403,21 @@ } else { None } - }).collect(); + }); // Deterministically pick an entry point // FIXME: Sort this instead let mut hcx = tcx.create_stable_hashing_context(); - let entry_point = entry_points.iter().min_by_key(|q| { + let entry_point = entry_points.min_by_key(|q| { let mut stable_hasher = StableHasher::::new(); q.info.query.hash_stable(&mut hcx, &mut stable_hasher); stable_hasher.finish() }).unwrap().as_ptr(); - // Shift the stack until our entry point is first - while stack[0].1.as_ptr() != entry_point { - let last = stack.pop().unwrap(); - stack.insert(0, last); + // Shift the stack so that our entry point is first + let entry_point_pos = stack.iter().position(|(_, query)| query.as_ptr() == entry_point); + if let Some(pos) = entry_point_pos { + stack.rotate_right(pos); } // Create the cycle error diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/query/keys.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/query/keys.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/query/keys.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/query/keys.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,6 +12,7 @@ use infer::canonical::Canonical; use hir::def_id::{CrateNum, DefId, LOCAL_CRATE, DefIndex}; +use traits; use ty::{self, Ty, TyCtxt}; use ty::subst::Substs; use ty::fast_reject::SimplifiedType; @@ -31,7 +32,7 @@ /// In the event that a cycle occurs, if no explicit span has been /// given for a query with key `self`, what span should we use? - fn default_span(&self, tcx: TyCtxt) -> Span; + fn default_span(&self, tcx: TyCtxt<'_, '_, '_>) -> Span; } impl<'tcx> Key for ty::InstanceDef<'tcx> { @@ -39,7 +40,7 @@ LOCAL_CRATE } - fn default_span(&self, tcx: TyCtxt) -> Span { + fn default_span(&self, tcx: TyCtxt<'_, '_, '_>) -> Span { tcx.def_span(self.def_id()) } } @@ -49,7 +50,7 @@ LOCAL_CRATE } - fn default_span(&self, tcx: TyCtxt) -> Span { + fn default_span(&self, tcx: TyCtxt<'_, '_, '_>) -> Span { tcx.def_span(self.def_id()) } } @@ -59,7 +60,7 @@ self.instance.query_crate() } - fn default_span(&self, tcx: TyCtxt) -> Span { + fn default_span(&self, tcx: TyCtxt<'_, '_, '_>) -> Span { self.instance.default_span(tcx) } } @@ -68,7 +69,7 @@ fn query_crate(&self) -> CrateNum { *self } - fn default_span(&self, _: TyCtxt) -> Span { + fn default_span(&self, _: TyCtxt<'_, '_, '_>) -> Span { DUMMY_SP } } @@ -77,7 +78,7 @@ fn query_crate(&self) -> CrateNum { LOCAL_CRATE } - fn default_span(&self, _tcx: TyCtxt) -> Span { + fn default_span(&self, _tcx: TyCtxt<'_, '_, '_>) -> Span { DUMMY_SP } } @@ -86,7 +87,7 @@ fn query_crate(&self) -> CrateNum { self.krate } - fn default_span(&self, tcx: TyCtxt) -> Span { + fn default_span(&self, tcx: TyCtxt<'_, '_, '_>) -> Span { tcx.def_span(*self) } } @@ -95,7 +96,7 @@ fn query_crate(&self) -> CrateNum { self.0.krate } - fn default_span(&self, tcx: TyCtxt) -> Span { + fn default_span(&self, tcx: TyCtxt<'_, '_, '_>) -> Span { self.1.default_span(tcx) } } @@ -104,7 +105,7 @@ fn query_crate(&self) -> CrateNum { self.0 } - fn default_span(&self, tcx: TyCtxt) -> Span { + fn default_span(&self, tcx: TyCtxt<'_, '_, '_>) -> Span { self.1.default_span(tcx) } } @@ -113,7 +114,7 @@ fn query_crate(&self) -> CrateNum { self.0.krate } - fn default_span(&self, tcx: TyCtxt) -> Span { + fn default_span(&self, tcx: TyCtxt<'_, '_, '_>) -> Span { self.0.default_span(tcx) } } @@ -122,7 +123,7 @@ fn query_crate(&self) -> CrateNum { self.0.krate } - fn default_span(&self, tcx: TyCtxt) -> Span { + fn default_span(&self, tcx: TyCtxt<'_, '_, '_>) -> Span { self.0.default_span(tcx) } } @@ -131,7 +132,7 @@ fn query_crate(&self) -> CrateNum { self.1.def_id().krate } - fn default_span(&self, tcx: TyCtxt) -> Span { + fn default_span(&self, tcx: TyCtxt<'_, '_, '_>) -> Span { tcx.def_span(self.1.def_id()) } } @@ -140,7 +141,7 @@ fn query_crate(&self) -> CrateNum { self.def_id().krate } - fn default_span(&self, tcx: TyCtxt) -> Span { + fn default_span(&self, tcx: TyCtxt<'_, '_, '_>) -> Span { tcx.def_span(self.def_id()) } } @@ -149,7 +150,7 @@ fn query_crate(&self) -> CrateNum { LOCAL_CRATE } - fn default_span(&self, _: TyCtxt) -> Span { + fn default_span(&self, _: TyCtxt<'_, '_, '_>) -> Span { DUMMY_SP } } @@ -158,7 +159,7 @@ fn query_crate(&self) -> CrateNum { LOCAL_CRATE } - fn default_span(&self, _: TyCtxt) -> Span { + fn default_span(&self, _: TyCtxt<'_, '_, '_>) -> Span { DUMMY_SP } } @@ -167,7 +168,7 @@ fn query_crate(&self) -> CrateNum { LOCAL_CRATE } - fn default_span(&self, _: TyCtxt) -> Span { + fn default_span(&self, _: TyCtxt<'_, '_, '_>) -> Span { DUMMY_SP } } @@ -176,16 +177,25 @@ fn query_crate(&self) -> CrateNum { self.value.query_crate() } - fn default_span(&self, tcx: TyCtxt) -> Span { + fn default_span(&self, tcx: TyCtxt<'_, '_, '_>) -> Span { self.value.default_span(tcx) } } +impl<'tcx> Key for traits::Environment<'tcx> { + fn query_crate(&self) -> CrateNum { + LOCAL_CRATE + } + fn default_span(&self, _: TyCtxt<'_, '_, '_>) -> Span { + DUMMY_SP + } +} + impl Key for InternedString { fn query_crate(&self) -> CrateNum { LOCAL_CRATE } - fn default_span(&self, _tcx: TyCtxt) -> Span { + fn default_span(&self, _tcx: TyCtxt<'_, '_, '_>) -> Span { DUMMY_SP } } @@ -200,7 +210,7 @@ LOCAL_CRATE } - fn default_span(&self, _tcx: TyCtxt) -> Span { + fn default_span(&self, _tcx: TyCtxt<'_, '_, '_>) -> Span { DUMMY_SP } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/query/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/query/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/query/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/query/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -34,9 +34,12 @@ use session::{CompileResult, CrateDisambiguator}; use session::config::OutputFilenames; use traits::{self, Vtable}; -use traits::query::{CanonicalPredicateGoal, CanonicalProjectionGoal, - CanonicalTyGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpSubtypeGoal, - CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpNormalizeGoal, NoSolution}; +use traits::query::{ + CanonicalPredicateGoal, CanonicalProjectionGoal, + CanonicalTyGoal, CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, + CanonicalTypeOpSubtypeGoal, CanonicalTypeOpProvePredicateGoal, + CanonicalTypeOpNormalizeGoal, NoSolution, +}; use traits::query::dropck_outlives::{DtorckConstraint, DropckOutlivesResult}; use traits::query::normalize::NormalizationResult; use traits::query::outlives_bounds::OutlivesBound; @@ -49,14 +52,15 @@ use util::common::{ErrorReported}; use util::profiling::ProfileCategory::*; -use rustc_data_structures::indexed_set::IdxSet; -use rustc_target::spec::PanicStrategy; +use rustc_data_structures::bit_set::BitSet; use rustc_data_structures::indexed_vec::IndexVec; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::stable_hasher::StableVec; +use rustc_data_structures::sync::Lrc; +use rustc_target::spec::PanicStrategy; +use std::borrow::Cow; use std::ops::Deref; -use rustc_data_structures::sync::Lrc; use std::sync::Arc; use syntax_pos::{Span, DUMMY_SP}; use syntax_pos::symbol::InternedString; @@ -160,8 +164,23 @@ DefId ) -> Result, NoSolution>, - /// True if this is a const fn - [] fn is_const_fn: IsConstFn(DefId) -> bool, + /// True if this is a const fn, use the `is_const_fn` to know whether your crate actually + /// sees it as const fn (e.g. the const-fn-ness might be unstable and you might not have + /// the feature gate active) + /// + /// DO NOT CALL MANUALLY, it is only meant to cache the base data for the `is_const_fn` + /// function + [] fn is_const_fn_raw: IsConstFn(DefId) -> bool, + + + /// Returns true if calls to the function may be promoted + /// + /// This is either because the function is e.g. a tuple-struct or tuple-variant constructor, + /// or because it has the `#[rustc_promotable]` attribute. The attribute should be removed + /// in the future in favour of some form of check which figures out whether the function + /// does not inspect the bits of any of its arguments (so is essentially just a constructor + /// function) + [] fn is_promotable_const_fn: IsPromotableConstFn(DefId) -> bool, /// True if this is a foreign item (i.e., linked via `extern { ... }`). [] fn is_foreign_item: IsForeignItem(DefId) -> bool, @@ -208,7 +227,7 @@ /// Maps DefId's that have an associated Mir to the result /// of the MIR qualify_consts pass. The actual meaning of /// the value isn't known except to the pass itself. - [] fn mir_const_qualif: MirConstQualif(DefId) -> (u8, Lrc>), + [] fn mir_const_qualif: MirConstQualif(DefId) -> (u8, Lrc>), /// Fetch the MIR for a given def-id right after it's built - this includes /// unreachable code. @@ -353,16 +372,16 @@ -> Lrc, [] fn is_object_safe: ObjectSafety(DefId) -> bool, - // Get the ParameterEnvironment for a given item; this environment - // will be in "user-facing" mode, meaning that it is suitabe for - // type-checking etc, and it does not normalize specializable - // associated types. This is almost always what you want, - // unless you are doing MIR optimizations, in which case you - // might want to use `reveal_all()` method to change modes. + /// Get the ParameterEnvironment for a given item; this environment + /// will be in "user-facing" mode, meaning that it is suitabe for + /// type-checking etc, and it does not normalize specializable + /// associated types. This is almost always what you want, + /// unless you are doing MIR optimizations, in which case you + /// might want to use `reveal_all()` method to change modes. [] fn param_env: ParamEnv(DefId) -> ty::ParamEnv<'tcx>, - // Trait selection queries. These are best used by invoking `ty.moves_by_default()`, - // `ty.is_copy()`, etc, since that will prune the environment where possible. + /// Trait selection queries. These are best used by invoking `ty.moves_by_default()`, + /// `ty.is_copy()`, etc, since that will prune the environment where possible. [] fn is_copy_raw: is_copy_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool, [] fn is_sized_raw: is_sized_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool, [] fn is_freeze_raw: is_freeze_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool, @@ -543,7 +562,7 @@ [] fn normalize_projection_ty: NormalizeProjectionTy( CanonicalProjectionGoal<'tcx> ) -> Result< - Lrc>>>, + Lrc>>>, NoSolution, >, @@ -555,7 +574,7 @@ [] fn implied_outlives_bounds: ImpliedOutlivesBounds( CanonicalTyGoal<'tcx> ) -> Result< - Lrc>>>>, + Lrc>>>>, NoSolution, >, @@ -563,7 +582,7 @@ [] fn dropck_outlives: DropckOutlives( CanonicalTyGoal<'tcx> ) -> Result< - Lrc>>>, + Lrc>>>, NoSolution, >, @@ -574,10 +593,18 @@ ) -> Result, /// Do not call this query directly: part of the `Eq` type-op + [] fn type_op_ascribe_user_type: TypeOpAscribeUserType( + CanonicalTypeOpAscribeUserTypeGoal<'tcx> + ) -> Result< + Lrc>>, + NoSolution, + >, + + /// Do not call this query directly: part of the `Eq` type-op [] fn type_op_eq: TypeOpEq( CanonicalTypeOpEqGoal<'tcx> ) -> Result< - Lrc>>, + Lrc>>, NoSolution, >, @@ -585,7 +612,7 @@ [] fn type_op_subtype: TypeOpSubtype( CanonicalTypeOpSubtypeGoal<'tcx> ) -> Result< - Lrc>>, + Lrc>>, NoSolution, >, @@ -593,7 +620,7 @@ [] fn type_op_prove_predicate: TypeOpProvePredicate( CanonicalTypeOpProvePredicateGoal<'tcx> ) -> Result< - Lrc>>, + Lrc>>, NoSolution, >, @@ -601,7 +628,7 @@ [] fn type_op_normalize_ty: TypeOpNormalizeTy( CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>> ) -> Result< - Lrc>>>, + Lrc>>>, NoSolution, >, @@ -609,7 +636,7 @@ [] fn type_op_normalize_predicate: TypeOpNormalizePredicate( CanonicalTypeOpNormalizeGoal<'tcx, ty::Predicate<'tcx>> ) -> Result< - Lrc>>>, + Lrc>>>, NoSolution, >, @@ -617,7 +644,7 @@ [] fn type_op_normalize_poly_fn_sig: TypeOpNormalizePolyFnSig( CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>> ) -> Result< - Lrc>>>, + Lrc>>>, NoSolution, >, @@ -625,7 +652,7 @@ [] fn type_op_normalize_fn_sig: TypeOpNormalizeFnSig( CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>> ) -> Result< - Lrc>>>, + Lrc>>>, NoSolution, >, @@ -648,8 +675,11 @@ [] fn program_clauses_for: ProgramClausesFor(DefId) -> Clauses<'tcx>, [] fn program_clauses_for_env: ProgramClausesForEnv( - ty::ParamEnv<'tcx> + traits::Environment<'tcx> ) -> Clauses<'tcx>, + + // Get the chalk-style environment of the given item. + [] fn environment: Environment(DefId) -> traits::Environment<'tcx>, }, Linking { @@ -666,21 +696,21 @@ span: Span, key: DefId, ) -> Result<&'tcx [Ty<'tcx>], DiagnosticBuilder<'a>> { - self.try_get_query::(span, key) + self.try_get_query::>(span, key) } pub fn try_needs_drop_raw( self, span: Span, key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>, ) -> Result> { - self.try_get_query::(span, key) + self.try_get_query::>(span, key) } pub fn try_optimized_mir( self, span: Span, key: DefId, ) -> Result<&'tcx mir::Mir<'tcx>, DiagnosticBuilder<'a>> { - self.try_get_query::(span, key) + self.try_get_query::>(span, key) } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/query/on_disk_cache.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/query/on_disk_cache.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/query/on_disk_cache.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/query/on_disk_cache.rs 2018-12-04 23:41:40.000000000 +0000 @@ -136,14 +136,14 @@ OnDiskCache { serialized_data: data, file_index_to_stable_id: footer.file_index_to_stable_id, - file_index_to_file: Lock::new(FxHashMap()), + file_index_to_file: Default::default(), prev_cnums: footer.prev_cnums, cnum_map: Once::new(), source_map: sess.source_map(), - current_diagnostics: Lock::new(FxHashMap()), + current_diagnostics: Default::default(), query_result_index: footer.query_result_index.into_iter().collect(), prev_diagnostics_index: footer.diagnostics_index.into_iter().collect(), - synthetic_expansion_infos: Lock::new(FxHashMap()), + synthetic_expansion_infos: Default::default(), alloc_decoding_state: AllocDecodingState::new(footer.interpret_alloc_index), } } @@ -151,15 +151,15 @@ pub fn new_empty(source_map: &'sess SourceMap) -> OnDiskCache<'sess> { OnDiskCache { serialized_data: Vec::new(), - file_index_to_stable_id: FxHashMap(), - file_index_to_file: Lock::new(FxHashMap()), + file_index_to_stable_id: Default::default(), + file_index_to_file: Default::default(), prev_cnums: vec![], cnum_map: Once::new(), source_map, - current_diagnostics: Lock::new(FxHashMap()), - query_result_index: FxHashMap(), - prev_diagnostics_index: FxHashMap(), - synthetic_expansion_infos: Lock::new(FxHashMap()), + current_diagnostics: Default::default(), + query_result_index: Default::default(), + prev_diagnostics_index: Default::default(), + synthetic_expansion_infos: Default::default(), alloc_decoding_state: AllocDecodingState::new(Vec::new()), } } @@ -174,8 +174,8 @@ tcx.dep_graph.with_ignore(|| { // Allocate SourceFileIndices let (file_to_file_index, file_index_to_stable_id) = { - let mut file_to_file_index = FxHashMap(); - let mut file_index_to_stable_id = FxHashMap(); + let mut file_to_file_index = FxHashMap::default(); + let mut file_index_to_stable_id = FxHashMap::default(); for (index, file) in tcx.sess.source_map().files().iter().enumerate() { let index = SourceFileIndex(index as u32); @@ -190,10 +190,10 @@ let mut encoder = CacheEncoder { tcx, encoder, - type_shorthands: FxHashMap(), - predicate_shorthands: FxHashMap(), - expn_info_shorthands: FxHashMap(), - interpret_allocs: FxHashMap(), + type_shorthands: Default::default(), + predicate_shorthands: Default::default(), + expn_info_shorthands: Default::default(), + interpret_allocs: Default::default(), interpret_allocs_inverse: Vec::new(), source_map: CachingSourceMapView::new(tcx.sess.source_map()), file_to_file_index, @@ -212,23 +212,23 @@ let enc = &mut encoder; let qri = &mut query_result_index; - encode_query_results::(tcx, enc, qri)?; - encode_query_results::(tcx, enc, qri)?; - encode_query_results::(tcx, enc, qri)?; - encode_query_results::(tcx, enc, qri)?; - encode_query_results::(tcx, enc, qri)?; - encode_query_results::(tcx, enc, qri)?; - encode_query_results::(tcx, enc, qri)?; - encode_query_results::(tcx, enc, qri)?; - encode_query_results::(tcx, enc, qri)?; - encode_query_results::(tcx, enc, qri)?; - encode_query_results::(tcx, enc, qri)?; - encode_query_results::(tcx, enc, qri)?; - encode_query_results::(tcx, enc, qri)?; - encode_query_results::(tcx, enc, qri)?; - encode_query_results::(tcx, enc, qri)?; - encode_query_results::(tcx, enc, qri)?; - encode_query_results::(tcx, enc, qri)?; + encode_query_results::, _>(tcx, enc, qri)?; + encode_query_results::, _>(tcx, enc, qri)?; + encode_query_results::, _>(tcx, enc, qri)?; + encode_query_results::, _>(tcx, enc, qri)?; + encode_query_results::, _>(tcx, enc, qri)?; + encode_query_results::, _>(tcx, enc, qri)?; + encode_query_results::, _>(tcx, enc, qri)?; + encode_query_results::, _>(tcx, enc, qri)?; + encode_query_results::, _>(tcx, enc, qri)?; + encode_query_results::, _>(tcx, enc, qri)?; + encode_query_results::, _>(tcx, enc, qri)?; + encode_query_results::, _>(tcx, enc, qri)?; + encode_query_results::, _>(tcx, enc, qri)?; + encode_query_results::, _>(tcx, enc, qri)?; + encode_query_results::, _>(tcx, enc, qri)?; + encode_query_results::, _>(tcx, enc, qri)?; + encode_query_results::, _>(tcx, enc, qri)?; // const eval is special, it only encodes successfully evaluated constants use ty::query::QueryAccessors; @@ -254,23 +254,19 @@ })?; // Encode diagnostics - let diagnostics_index = { - let mut diagnostics_index = EncodedDiagnosticsIndex::new(); - - for (dep_node_index, diagnostics) in self.current_diagnostics - .borrow() - .iter() { - let pos = AbsoluteBytePos::new(encoder.position()); - // Let's make sure we get the expected type here: - let diagnostics: &EncodedDiagnostics = diagnostics; - let dep_node_index = - SerializedDepNodeIndex::new(dep_node_index.index()); - encoder.encode_tagged(dep_node_index, diagnostics)?; - diagnostics_index.push((dep_node_index, pos)); - } - - diagnostics_index - }; + let diagnostics_index: EncodedDiagnosticsIndex = self.current_diagnostics.borrow() + .iter() + .map(|(dep_node_index, diagnostics)| + { + let pos = AbsoluteBytePos::new(encoder.position()); + // Let's make sure we get the expected type here: + let diagnostics: &EncodedDiagnostics = diagnostics; + let dep_node_index = SerializedDepNodeIndex::new(dep_node_index.index()); + encoder.encode_tagged(dep_node_index, diagnostics)?; + + Ok((dep_node_index, pos)) + }) + .collect::>()?; let interpret_alloc_index = { let mut interpret_alloc_index = Vec::new(); @@ -282,6 +278,7 @@ // otherwise, abort break; } + interpret_alloc_index.reserve(new_n); for idx in n..new_n { let id = encoder.interpret_allocs_inverse[idx]; let pos = encoder.position() as u32; @@ -323,7 +320,7 @@ return Ok(()); - fn sorted_cnums_including_local_crate(tcx: TyCtxt) -> Vec { + fn sorted_cnums_including_local_crate(tcx: TyCtxt<'_, '_, '_>) -> Vec { let mut cnums = vec![LOCAL_CRATE]; cnums.extend_from_slice(&tcx.crates()[..]); cnums.sort_unstable(); @@ -345,7 +342,7 @@ &self.prev_diagnostics_index, "diagnostics"); - diagnostics.unwrap_or(Vec::new()) + diagnostics.unwrap_or_default() } /// Store a diagnostic emitted during the current compilation session. @@ -434,23 +431,22 @@ // current-session-CrateNum. There might be CrateNums from the previous // Session that don't occur in the current one. For these, the mapping // maps to None. - fn compute_cnum_map(tcx: TyCtxt, + fn compute_cnum_map(tcx: TyCtxt<'_, '_, '_>, prev_cnums: &[(u32, String, CrateDisambiguator)]) -> IndexVec> { tcx.dep_graph.with_ignore(|| { let current_cnums = tcx.all_crate_nums(LOCAL_CRATE).iter().map(|&cnum| { let crate_name = tcx.original_crate_name(cnum) - .as_str() .to_string(); let crate_disambiguator = tcx.crate_disambiguator(cnum); ((crate_name, crate_disambiguator), cnum) }).collect::>(); let map_size = prev_cnums.iter() - .map(|&(cnum, ..)| cnum) - .max() - .unwrap_or(0) + 1; + .map(|&(cnum, ..)| cnum) + .max() + .unwrap_or(0) + 1; let mut map = IndexVec::new(); map.resize(map_size as usize, None); @@ -465,7 +461,6 @@ } } - //- DECODING ------------------------------------------------------------------- /// A decoder that can read the incr. comp. cache. It is similar to the one @@ -494,7 +489,7 @@ file_index_to_file.borrow_mut().entry(index).or_insert_with(|| { let stable_id = file_index_to_stable_id[&index]; source_map.source_file_by_stable_id(stable_id) - .expect("Failed to lookup SourceFile in new context.") + .expect("Failed to lookup SourceFile in new context.") }).clone() } } @@ -761,7 +756,7 @@ struct CacheEncoder<'enc, 'a, 'tcx, E> where E: 'enc + ty_codec::TyEncoder, - 'tcx: 'a, + 'tcx: 'a, { tcx: TyCtxt<'a, 'tcx, 'tcx>, encoder: &'enc mut E, @@ -839,9 +834,7 @@ let (file_lo, line_lo, col_lo) = match self.source_map .byte_pos_to_line_and_col(span_data.lo) { Some(pos) => pos, - None => { - return TAG_INVALID_SPAN.encode(self); - } + None => return TAG_INVALID_SPAN.encode(self) }; if !file_lo.contains(span_data.hi) { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/query/plumbing.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/query/plumbing.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/query/plumbing.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/query/plumbing.rs 2018-12-04 23:41:40.000000000 +0000 @@ -55,11 +55,11 @@ } } -impl<'tcx, M: QueryConfig<'tcx>> QueryCache<'tcx, M> { - pub(super) fn new() -> QueryCache<'tcx, M> { +impl<'tcx, M: QueryConfig<'tcx>> Default for QueryCache<'tcx, M> { + fn default() -> QueryCache<'tcx, M> { QueryCache { - results: FxHashMap(), - active: FxHashMap(), + results: FxHashMap::default(), + active: FxHashMap::default(), } } } @@ -449,14 +449,14 @@ let prev_dep_node_index = self.dep_graph.prev_dep_node_index_of(dep_node); let result = Q::try_load_from_disk(self.global_tcx(), - prev_dep_node_index); + prev_dep_node_index); // We always expect to find a cached result for things that // can be forced from DepNode. debug_assert!(!dep_node.kind.can_reconstruct_query_key() || - result.is_some(), - "Missing on-disk cache entry for {:?}", - dep_node); + result.is_some(), + "Missing on-disk cache entry for {:?}", + dep_node); result } else { // Some things are never cached on disk. @@ -491,7 +491,7 @@ assert!(Some(self.dep_graph.fingerprint_of(dep_node_index)) == self.dep_graph.prev_fingerprint_of(dep_node), "Fingerprint for green query instance not loaded \ - from cache: {:?}", dep_node); + from cache: {:?}", dep_node); debug!("BEGIN verify_ich({:?})", dep_node); let mut hcx = self.create_stable_hashing_context(); @@ -530,8 +530,8 @@ // (see for example #48923) assert!(!self.dep_graph.dep_node_exists(&dep_node), "Forcing query with already existing DepNode.\n\ - - query-key: {:?}\n\ - - dep-node: {:?}", + - query-key: {:?}\n\ + - dep-node: {:?}", key, dep_node); profq_msg!(self, ProfileQueriesMsg::ProviderBegin); @@ -699,7 +699,7 @@ providers, fallback_extern_providers: Box::new(fallback_extern_providers), on_disk_cache, - $($name: Lock::new(QueryCache::new())),* + $($name: Default::default()),* } } @@ -709,14 +709,19 @@ // We use try_lock here since we are only called from the // deadlock handler, and this shouldn't be locked - $(for v in self.$name.try_lock().unwrap().active.values() { - match *v { - QueryResult::Started(ref job) => jobs.push(job.clone()), - _ => (), - } - })* + $( + jobs.extend( + self.$name.try_lock().unwrap().active.values().filter_map(|v| + if let QueryResult::Started(ref job) = *v { + Some(job.clone()) + } else { + None + } + ) + ); + )* - return jobs; + jobs } } @@ -733,14 +738,14 @@ } } - pub fn describe(&self, tcx: TyCtxt) -> String { + pub fn describe(&self, tcx: TyCtxt<'_, '_, '_>) -> Cow<'static, str> { let (r, name) = match *self { $(Query::$name(key) => { (queries::$name::describe(tcx, key), stringify!($name)) })* }; if tcx.sess.verbose() { - format!("{} [{}]", r, name) + format!("{} [{}]", r, name).into() } else { r } @@ -753,9 +758,8 @@ } // The def_span query is used to calculate default_span, // so exit to avoid infinite recursion - match *self { - Query::def_span(..) => return span, - _ => () + if let Query::def_span(..) = *self { + return span } match *self { $(Query::$name(key) => key.default_span(tcx),)* @@ -845,7 +849,7 @@ /// /// Note: The optimization is only available during incr. comp. pub fn ensure(tcx: TyCtxt<'a, $tcx, 'lcx>, key: $K) -> () { - tcx.ensure_query::(key); + tcx.ensure_query::>(key); } })* @@ -881,7 +885,7 @@ impl<'a, $tcx, 'lcx> TyCtxtAt<'a, $tcx, 'lcx> { $($(#[$attr])* pub fn $name(self, key: $K) -> $V { - self.tcx.get_query::(self.span, key) + self.tcx.get_query::>(self.span, key) })* } @@ -1028,11 +1032,10 @@ ) ); - match tcx.force_query::<::ty::query::queries::$query>($key, DUMMY_SP, *dep_node) { - Ok(_) => {}, - Err(e) => { - tcx.report_cycle(e).emit(); - } + if let Err(e) = tcx.force_query::<::ty::query::queries::$query<'_>>( + $key, DUMMY_SP, *dep_node + ) { + tcx.report_cycle(e).emit(); } } } @@ -1076,6 +1079,7 @@ DepKind::ImpliedOutlivesBounds | DepKind::DropckOutlives | DepKind::EvaluateObligation | + DepKind::TypeOpAscribeUserType | DepKind::TypeOpEq | DepKind::TypeOpSubtype | DepKind::TypeOpProvePredicate | @@ -1134,7 +1138,8 @@ DepKind::FnSignature => { force!(fn_sig, def_id!()); } DepKind::CoerceUnsizedInfo => { force!(coerce_unsized_info, def_id!()); } DepKind::ItemVariances => { force!(variances_of, def_id!()); } - DepKind::IsConstFn => { force!(is_const_fn, def_id!()); } + DepKind::IsConstFn => { force!(is_const_fn_raw, def_id!()); } + DepKind::IsPromotableConstFn => { force!(is_promotable_const_fn, def_id!()); } DepKind::IsForeignItem => { force!(is_foreign_item, def_id!()); } DepKind::SizedConstraint => { force!(adt_sized_constraint, def_id!()); } DepKind::DtorckConstraint => { force!(adt_dtorck_constraint, def_id!()); } @@ -1152,6 +1157,7 @@ DepKind::CheckMatch => { force!(check_match, def_id!()); } DepKind::ParamEnv => { force!(param_env, def_id!()); } + DepKind::Environment => { force!(environment, def_id!()); } DepKind::DescribeDef => { force!(describe_def, def_id!()); } DepKind::DefSpan => { force!(def_span, def_id!()); } DepKind::LookupStability => { force!(lookup_stability, def_id!()); } @@ -1281,7 +1287,7 @@ impl DepNode { // Check whether the query invocation corresponding to the given // DepNode is eligible for on-disk-caching. - pub fn cache_on_disk(&self, tcx: TyCtxt) -> bool { + pub fn cache_on_disk(&self, tcx: TyCtxt<'_, '_, '_>) -> bool { use ty::query::queries; use ty::query::QueryDescription; @@ -1299,7 +1305,7 @@ // above `cache_on_disk` methods returns true. // Also, as a sanity check, it expects that the corresponding query // invocation has been marked as green already. - pub fn load_from_on_disk_cache(&self, tcx: TyCtxt) { + pub fn load_from_on_disk_cache(&self, tcx: TyCtxt<'_, '_, '_>) { match self.kind { $(DepKind::$dep_kind => { debug_assert!(tcx.dep_graph diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/query/README.md rustc-1.31.0+dfsg1+llvm/src/librustc/ty/query/README.md --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/query/README.md 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/query/README.md 2018-12-04 23:41:40.000000000 +0000 @@ -294,7 +294,7 @@ ```rust impl<'tcx> QueryDescription for queries::type_of<'tcx> { - fn describe(tcx: TyCtxt, key: DefId) -> String { + fn describe(tcx: TyCtxt<'_, '_, '_>, key: DefId) -> String { format!("computing the type of `{}`", tcx.item_path_str(key)) } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/relate.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/relate.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/relate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/relate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -274,9 +274,10 @@ if a.len() != b.len() { Err(TypeError::ProjectionBoundsLength(expected_found(relation, &a.len(), &b.len()))) } else { - a.iter().zip(b) - .map(|(a, b)| relation.relate(a, b)) - .collect() + a.iter() + .zip(b) + .map(|(a, b)| relation.relate(a, b)) + .collect() } } } @@ -331,7 +332,7 @@ -> RelateResult<'tcx, GeneratorWitness<'tcx>> where R: TypeRelation<'a, 'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a { - assert!(a.0.len() == b.0.len()); + assert_eq!(a.0.len(), b.0.len()); let tcx = relation.tcx(); let types = tcx.mk_type_list(a.0.iter().zip(b.0).map(|(a, b)| relation.relate(a, b)))?; Ok(GeneratorWitness(types)) @@ -361,7 +362,7 @@ let tcx = relation.tcx(); let a_sty = &a.sty; let b_sty = &b.sty; - debug!("super_tys: a_sty={:?} b_sty={:?}", a_sty, b_sty); + debug!("super_relate_tys: a_sty={:?} b_sty={:?}", a_sty, b_sty); match (a_sty, b_sty) { (&ty::Infer(_), _) | (_, &ty::Infer(_)) => @@ -478,27 +479,24 @@ ConstValue::Unevaluated(def_id, substs) => { // FIXME(eddyb) get the right param_env. let param_env = ty::ParamEnv::empty(); - match tcx.lift_to_global(&substs) { - Some(substs) => { - let instance = ty::Instance::resolve( - tcx.global_tcx(), - param_env, - def_id, - substs, - ); - if let Some(instance) = instance { - let cid = GlobalId { - instance, - promoted: None - }; - if let Some(s) = tcx.const_eval(param_env.and(cid)) - .ok() - .map(|c| c.unwrap_usize(tcx)) { - return Ok(s) - } + if let Some(substs) = tcx.lift_to_global(&substs) { + let instance = ty::Instance::resolve( + tcx.global_tcx(), + param_env, + def_id, + substs, + ); + if let Some(instance) = instance { + let cid = GlobalId { + instance, + promoted: None + }; + if let Some(s) = tcx.const_eval(param_env.and(cid)) + .ok() + .map(|c| c.unwrap_usize(tcx)) { + return Ok(s) } - }, - None => {} + } } tcx.sess.delay_span_bug(tcx.def_span(def_id), "array length could not be evaluated"); @@ -702,7 +700,12 @@ (UnpackedKind::Type(a_ty), UnpackedKind::Type(b_ty)) => { Ok(relation.relate(&a_ty, &b_ty)?.into()) } - (UnpackedKind::Lifetime(_), _) | (UnpackedKind::Type(_), _) => bug!() + (UnpackedKind::Lifetime(unpacked), x) => { + bug!("impossible case reached: can't relate: {:?} with {:?}", unpacked, x) + } + (UnpackedKind::Type(unpacked), x) => { + bug!("impossible case reached: can't relate: {:?} with {:?}", unpacked, x) + } } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/steal.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/steal.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/steal.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/steal.rs 2018-12-04 23:41:40.000000000 +0000 @@ -42,7 +42,7 @@ } } - pub fn borrow(&self) -> MappedReadGuard { + pub fn borrow(&self) -> MappedReadGuard<'_, T> { ReadGuard::map(self.value.borrow(), |opt| match *opt { None => bug!("attempted to read from stolen value"), Some(ref v) => v diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/structural_impls.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/structural_impls.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/structural_impls.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/structural_impls.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,6 +13,7 @@ //! hand, though we've recently added some macros (e.g., //! `BraceStructLiftImpl!`) to help with the tedium. +use mir::ProjectionKind; use mir::interpret::{ConstValue, ConstEvalErr}; use ty::{self, Lift, Ty, TyCtxt}; use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; @@ -57,6 +58,7 @@ ::ty::ClosureKind, ::ty::IntVarValue, ::ty::ParamTy, + ::ty::UniverseIndex, ::ty::Variance, ::syntax_pos::Span, } @@ -386,12 +388,12 @@ type Lifted = ty::GenSig<'tcx>; fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option { tcx.lift(&(self.yield_ty, self.return_ty)) - .map(|(yield_ty, return_ty)| { - ty::GenSig { - yield_ty, - return_ty, - } - }) + .map(|(yield_ty, return_ty)| { + ty::GenSig { + yield_ty, + return_ty, + } + }) } } @@ -452,7 +454,6 @@ CyclicTy(t) => return tcx.lift(&t).map(|t| CyclicTy(t)), ProjectionMismatched(x) => ProjectionMismatched(x), ProjectionBoundsLength(x) => ProjectionBoundsLength(x), - Sorts(ref x) => return tcx.lift(x).map(Sorts), OldStyleLUB(ref x) => return tcx.lift(x).map(OldStyleLUB), ExistentialMismatch(ref x) => return tcx.lift(x).map(ExistentialMismatch) @@ -493,6 +494,10 @@ tcx.lift(&a)?, tcx.lift(&b)?, ), + FunctionRetMismatch(a, b) => FunctionRetMismatch( + tcx.lift(&a)?, + tcx.lift(&b)?, + ), FunctionArgCountMismatch => FunctionArgCountMismatch, NoMirFor(ref s) => NoMirFor(s.clone()), UnterminatedCString(ptr) => UnterminatedCString(ptr), @@ -720,6 +725,16 @@ } } +impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Box<[T]> { + fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + self.iter().map(|t| t.fold_with(folder)).collect::>().into_boxed_slice() + } + + fn super_visit_with>(&self, visitor: &mut V) -> bool { + self.iter().any(|t| t.visit_with(visitor)) + } +} + impl<'tcx, T:TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { self.map_bound_ref(|ty| ty.fold_with(folder)) @@ -772,6 +787,17 @@ } } +impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { + fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + let v = self.iter().map(|t| t.fold_with(folder)).collect::>(); + folder.tcx().intern_projs(&v) + } + + fn super_visit_with>(&self, visitor: &mut V) -> bool { + self.iter().any(|t| t.visit_with(visitor)) + } +} + impl<'tcx> TypeFoldable<'tcx> for ty::instance::Instance<'tcx> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { use ty::InstanceDef::*; @@ -807,22 +833,16 @@ use ty::InstanceDef::*; self.substs.visit_with(visitor) || match self.def { - Item(did) => did.visit_with(visitor), - Intrinsic(did) => did.visit_with(visitor), - FnPtrShim(did, ty) => { - did.visit_with(visitor) || - ty.visit_with(visitor) + Item(did) | Intrinsic(did) | Virtual(did, _) => { + did.visit_with(visitor) }, - Virtual(did, _) => did.visit_with(visitor), - ClosureOnceShim { call_once } => call_once.visit_with(visitor), - DropGlue(did, ty) => { - did.visit_with(visitor) || - ty.visit_with(visitor) + FnPtrShim(did, ty) | CloneShim(did, ty) => { + did.visit_with(visitor) || ty.visit_with(visitor) }, - CloneShim(did, ty) => { - did.visit_with(visitor) || - ty.visit_with(visitor) + DropGlue(did, ty) => { + did.visit_with(visitor) || ty.visit_with(visitor) }, + ClosureOnceShim { call_once } => call_once.visit_with(visitor), } } } @@ -866,6 +886,9 @@ ty::GeneratorWitness(types) => ty::GeneratorWitness(types.fold_with(folder)), ty::Closure(did, substs) => ty::Closure(did, substs.fold_with(folder)), ty::Projection(ref data) => ty::Projection(data.fold_with(folder)), + ty::UnnormalizedProjection(ref data) => { + ty::UnnormalizedProjection(data.fold_with(folder)) + } ty::Opaque(did, substs) => ty::Opaque(did, substs.fold_with(folder)), ty::Bool | ty::Char | ty::Str | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Error | ty::Infer(_) | @@ -900,7 +923,9 @@ } ty::GeneratorWitness(ref types) => types.visit_with(visitor), ty::Closure(_did, ref substs) => substs.visit_with(visitor), - ty::Projection(ref data) => data.visit_with(visitor), + ty::Projection(ref data) | ty::UnnormalizedProjection(ref data) => { + data.visit_with(visitor) + } ty::Opaque(_, ref substs) => substs.visit_with(visitor), ty::Bool | ty::Char | ty::Str | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Error | ty::Infer(_) | diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/sty.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/sty.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/sty.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/sty.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ //! This module contains TyKind and its major components use hir::def_id::DefId; - +use infer::canonical::Canonical; use mir::interpret::ConstValue; use middle::region; use polonius_engine::Atom; @@ -79,8 +79,8 @@ } } -/// NB: If you change this, you'll probably want to change the corresponding -/// AST structure in libsyntax/ast.rs as well. +/// N.B., If you change this, you'll probably want to change the corresponding +/// AST structure in `libsyntax/ast.rs` as well. #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)] pub enum TyKind<'tcx> { /// The primitive boolean type. Written as `bool`. @@ -126,10 +126,25 @@ Ref(Region<'tcx>, Ty<'tcx>, hir::Mutability), /// The anonymous type of a function declaration/definition. Each - /// function has a unique type. + /// function has a unique type, which is output (for a function + /// named `foo` returning an `i32`) as `fn() -> i32 {foo}`. + /// + /// For example the type of `bar` here: + /// + /// ```rust + /// fn foo() -> i32 { 1 } + /// let bar = foo; // bar: fn() -> i32 {foo} + /// ``` FnDef(DefId, &'tcx Substs<'tcx>), /// A pointer to a function. Written as `fn() -> i32`. + /// + /// For example the type of `bar` here: + /// + /// ```rust + /// fn foo() -> i32 { 1 } + /// let bar: fn() -> i32 = foo; + /// ``` FnPtr(PolyFnSig<'tcx>), /// A trait, defined with `trait`. @@ -157,8 +172,13 @@ /// `>::N`. Projection(ProjectionTy<'tcx>), + /// A placeholder type used when we do not have enough information + /// to normalize the projection of an associated type to an + /// existing concrete type. Currently only used with chalk-engine. + UnnormalizedProjection(ProjectionTy<'tcx>), + /// Opaque (`impl Trait`) type found in a return type. - /// The DefId comes either from + /// The `DefId` comes either from /// * the `impl Trait` ast::Ty node, /// * or the `existential type` declaration /// The substitutions are for the generics of the function in question. @@ -168,7 +188,7 @@ /// A type parameter; for example, `T` in `fn f(x: T) {} Param(ParamTy), - /// A type variable used during type-checking. + /// A type variable used during type checking. Infer(InferTy), /// A placeholder for a type which could not be computed; this is @@ -539,10 +559,10 @@ impl<'tcx> serialize::UseSpecializedDecodable for &'tcx List> {} impl<'tcx> List> { - pub fn principal(&self) -> Option> { - match self.get(0) { - Some(&ExistentialPredicate::Trait(tr)) => Some(tr), - _ => None, + pub fn principal(&self) -> ExistentialTraitRef<'tcx> { + match self[0] { + ExistentialPredicate::Trait(tr) => tr, + other => bug!("first predicate is {:?}", other), } } @@ -569,8 +589,8 @@ } impl<'tcx> Binder<&'tcx List>> { - pub fn principal(&self) -> Option> { - self.skip_binder().principal().map(Binder::bind) + pub fn principal(&self) -> PolyExistentialTraitRef<'tcx> { + Binder::bind(self.skip_binder().principal()) } #[inline] @@ -704,11 +724,11 @@ /// Object types don't have a self-type specified. Therefore, when /// we convert the principal trait-ref into a normal trait-ref, /// you must give *some* self-type. A common choice is `mk_err()` - /// or some skolemized type. + /// or some placeholder type. pub fn with_self_ty(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, self_ty: Ty<'tcx>) -> ty::TraitRef<'tcx> { // otherwise the escaping regions would be captured by the binder - debug_assert!(!self_ty.has_escaping_regions()); + // debug_assert!(!self_ty.has_escaping_regions()); ty::TraitRef { def_id: self.def_id, @@ -727,7 +747,7 @@ /// Object types don't have a self-type specified. Therefore, when /// we convert the principal trait-ref into a normal trait-ref, /// you must give *some* self-type. A common choice is `mk_err()` - /// or some skolemized type. + /// or some placeholder type. pub fn with_self_ty(&self, tcx: TyCtxt<'_, '_, 'tcx>, self_ty: Ty<'tcx>) -> ty::PolyTraitRef<'tcx> { @@ -738,7 +758,7 @@ /// Binder is a binder for higher-ranked lifetimes. It is part of the /// compiler's representation for things like `for<'a> Fn(&'a isize)` /// (which would be represented by the type `PolyTraitRef == -/// Binder`). Note that when we skolemize, instantiate, +/// Binder`). Note that when we instantiate, /// erase, or otherwise "discharge" these bound regions, we change the /// type from `Binder` to just `T` (see /// e.g. `liberate_late_bound_regions`). @@ -864,7 +884,7 @@ /// Construct a ProjectionTy by searching the trait from trait_ref for the /// associated item named item_name. pub fn from_ref_and_name( - tcx: TyCtxt, trait_ref: ty::TraitRef<'tcx>, item_name: Ident + tcx: TyCtxt<'_, '_, '_>, trait_ref: ty::TraitRef<'tcx>, item_name: Ident ) -> ProjectionTy<'tcx> { let item_def_id = tcx.associated_items(trait_ref.def_id).find(|item| { item.kind == ty::AssociatedKind::Type && @@ -880,7 +900,7 @@ /// Extracts the underlying trait reference from this projection. /// For example, if this is a projection of `::Item`, /// then this function would return a `T: Iterator` trait reference. - pub fn trait_ref(&self, tcx: TyCtxt) -> ty::TraitRef<'tcx> { + pub fn trait_ref(&self, tcx: TyCtxt<'_, '_, '_>) -> ty::TraitRef<'tcx> { let def_id = tcx.associated_item(self.item_def_id).container.id(); ty::TraitRef { def_id, @@ -947,7 +967,7 @@ self.map_bound_ref(|fn_sig| fn_sig.inputs_and_output) } pub fn output(&self) -> ty::Binder> { - self.map_bound_ref(|fn_sig| fn_sig.output().clone()) + self.map_bound_ref(|fn_sig| fn_sig.output()) } pub fn variadic(&self) -> bool { self.skip_binder().variadic @@ -960,6 +980,9 @@ } } +pub type CanonicalPolyFnSig<'tcx> = Canonical<'tcx, Binder>>; + + #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)] pub struct ParamTy { pub idx: u32, @@ -987,11 +1010,7 @@ // FIXME(#50125): Ignoring `Self` with `idx != 0` might lead to weird behavior elsewhere, // but this should only be possible when using `-Z continue-parse-after-error` like // `compile-fail/issue-36638.rs`. - if self.name == keywords::SelfType.name().as_str() && self.idx == 0 { - true - } else { - false - } + self.name == keywords::SelfType.name().as_str() && self.idx == 0 } } @@ -1061,10 +1080,10 @@ /// /// Unlike Param-s, bound regions are not supposed to exist "in the wild" /// outside their binder, e.g. in types passed to type inference, and -/// should first be substituted (by skolemized regions, free regions, +/// should first be substituted (by placeholder regions, free regions, /// or region variables). /// -/// ## Skolemized and Free Regions +/// ## Placeholder and Free Regions /// /// One often wants to work with bound regions without knowing their precise /// identity. For example, when checking a function, the lifetime of a borrow @@ -1072,12 +1091,11 @@ /// it must be ensured that bounds on the region can't be accidentally /// assumed without being checked. /// -/// The process of doing that is called "skolemization". The bound regions -/// are replaced by skolemized markers, which don't satisfy any relation -/// not explicitly provided. +/// To do this, we replace the bound regions with placeholder markers, +/// which don't satisfy any relation not explicitly provided. /// -/// There are 2 kinds of skolemized regions in rustc: `ReFree` and -/// `ReSkolemized`. When checking an item's body, `ReFree` is supposed +/// There are 2 kinds of placeholder regions in rustc: `ReFree` and +/// `RePlaceholder`. When checking an item's body, `ReFree` is supposed /// to be used. These also support explicit bounds: both the internally-stored /// *scope*, which the region is assumed to outlive, as well as other /// relations stored in the `FreeRegionMap`. Note that these relations @@ -1086,14 +1104,14 @@ /// /// When working with higher-ranked types, some region relations aren't /// yet known, so you can't just call `resolve_regions_and_report_errors`. -/// `ReSkolemized` is designed for this purpose. In these contexts, +/// `RePlaceholder` is designed for this purpose. In these contexts, /// there's also the risk that some inference variable laying around will -/// get unified with your skolemized region: if you want to check whether +/// get unified with your placeholder region: if you want to check whether /// `for<'a> Foo<'_>: 'a`, and you substitute your bound region `'a` -/// with a skolemized region `'%a`, the variable `'_` would just be -/// instantiated to the skolemized region `'%a`, which is wrong because +/// with a placeholder region `'%a`, the variable `'_` would just be +/// instantiated to the placeholder region `'%a`, which is wrong because /// the inference variable is supposed to satisfy the relation -/// *for every value of the skolemized region*. To ensure that doesn't +/// *for every value of the placeholder region*. To ensure that doesn't /// happen, you can use `leak_check`. This is more clearly explained /// by the [rustc guide]. /// @@ -1127,9 +1145,9 @@ /// A region variable. Should not exist after typeck. ReVar(RegionVid), - /// A skolemized region - basically the higher-ranked version of ReFree. + /// A placeholder region - basically the higher-ranked version of ReFree. /// Should not exist after typeck. - ReSkolemized(ty::UniverseIndex, BoundRegion), + RePlaceholder(ty::Placeholder), /// Empty lifetime is for data that is never accessed. /// Bottom in the region lattice. We treat ReEmpty somewhat @@ -1150,7 +1168,7 @@ ReClosureBound(RegionVid), /// Canonicalized region, used only when preparing a trait query. - ReCanonical(CanonicalVar), + ReCanonical(BoundTyIndex), } impl<'tcx> serialize::UseSpecializedDecodable for Region<'tcx> {} @@ -1202,14 +1220,22 @@ FreshIntTy(u32), FreshFloatTy(u32), - /// Canonicalized type variable, used only when preparing a trait query. - CanonicalTy(CanonicalVar), + /// Bound type variable, used only when preparing a trait query. + BoundTy(BoundTy), } newtype_index! { - pub struct CanonicalVar { .. } + pub struct BoundTyIndex { .. } +} + +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)] +pub struct BoundTy { + pub level: DebruijnIndex, + pub var: BoundTyIndex, } +impl_stable_hash_for!(struct BoundTy { level, var }); + /// A `ProjectionPredicate` for an `ExistentialTraitRef`. #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)] pub struct ExistentialProjection<'tcx> { @@ -1225,7 +1251,7 @@ /// For example, if this is a projection of `exists T. ::Item == X`, /// then this function would return a `exists T. T: Iterator` existential trait /// reference. - pub fn trait_ref(&self, tcx: TyCtxt) -> ty::ExistentialTraitRef<'tcx> { + pub fn trait_ref(&self, tcx: TyCtxt<'_, '_, '_>) -> ty::ExistentialTraitRef<'tcx> { let def_id = tcx.associated_item(self.item_def_id).container.id(); ty::ExistentialTraitRef{ def_id, @@ -1324,6 +1350,23 @@ /// Region utilities impl RegionKind { + /// Is this region named by the user? + pub fn has_name(&self) -> bool { + match *self { + RegionKind::ReEarlyBound(ebr) => ebr.has_name(), + RegionKind::ReLateBound(_, br) => br.is_named(), + RegionKind::ReFree(fr) => fr.bound_region.is_named(), + RegionKind::ReScope(..) => false, + RegionKind::ReStatic => true, + RegionKind::ReVar(..) => false, + RegionKind::RePlaceholder(placeholder) => placeholder.name.is_named(), + RegionKind::ReEmpty => false, + RegionKind::ReErased => false, + RegionKind::ReClosureBound(..) => false, + RegionKind::ReCanonical(..) => false, + } + } + pub fn is_late_bound(&self) -> bool { match *self { ty::ReLateBound(..) => true, @@ -1388,7 +1431,7 @@ flags = flags | TypeFlags::HAS_FREE_REGIONS; flags = flags | TypeFlags::HAS_RE_INFER; } - ty::ReSkolemized(..) => { + ty::RePlaceholder(..) => { flags = flags | TypeFlags::HAS_FREE_REGIONS; flags = flags | TypeFlags::HAS_RE_SKOL; } @@ -1552,7 +1595,7 @@ } } - pub fn simd_size(&self, _cx: TyCtxt) -> usize { + pub fn simd_size(&self, _cx: TyCtxt<'_, '_, '_>) -> usize { match self.sty { Adt(def, _) => def.non_enum_variant().fields.len(), _ => bug!("simd_size called on invalid type") @@ -1581,6 +1624,22 @@ } } + /// Returns `true` if this type is an `Arc`. + pub fn is_arc(&self) -> bool { + match self.sty { + Adt(def, _) => def.is_arc(), + _ => false, + } + } + + /// Returns `true` if this type is an `Rc`. + pub fn is_rc(&self) -> bool { + match self.sty { + Adt(def, _) => def.is_rc(), + _ => false, + } + } + pub fn is_box(&self) -> bool { match self.sty { Adt(def, _) => def.is_box(), @@ -1777,9 +1836,7 @@ } Dynamic(ref obj, region) => { let mut v = vec![region]; - if let Some(p) = obj.principal() { - v.extend(p.skip_binder().substs.regions()); - } + v.extend(obj.principal().skip_binder().substs.regions()); v } Adt(_, substs) | Opaque(_, substs) => { @@ -1789,7 +1846,7 @@ Generator(_, GeneratorSubsts { ref substs }, _) => { substs.regions().collect() } - Projection(ref data) => { + Projection(ref data) | UnnormalizedProjection(ref data) => { data.substs.regions().collect() } FnDef(..) | @@ -1869,9 +1926,11 @@ ty::Projection(_) | ty::Param(_) | ty::Opaque(..) => false, + ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"), + ty::Infer(ty::TyVar(_)) => false, - ty::Infer(ty::CanonicalTy(_)) | + ty::Infer(ty::BoundTy(_)) | ty::Infer(ty::FreshTy(_)) | ty::Infer(ty::FreshIntTy(_)) | ty::Infer(ty::FreshFloatTy(_)) => @@ -2004,18 +2063,14 @@ tcx: TyCtxt<'_, '_, '_>, ty: ParamEnvAnd<'tcx, Ty<'tcx>>, ) -> u128 { - match self.assert_bits(tcx, ty) { - Some(val) => val, - None => bug!("expected bits of {}, got {:#?}", ty.value, self), - } + self.assert_bits(tcx, ty).unwrap_or_else(|| + bug!("expected bits of {}, got {:#?}", ty.value, self)) } #[inline] pub fn unwrap_usize(&self, tcx: TyCtxt<'_, '_, '_>) -> u64 { - match self.assert_usize(tcx) { - Some(val) => val, - None => bug!("expected constant usize, got {:#?}", self), - } + self.assert_usize(tcx).unwrap_or_else(|| + bug!("expected constant usize, got {:#?}", self)) } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/subst.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/subst.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/subst.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/subst.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,7 +12,7 @@ use hir::def_id::DefId; use infer::canonical::Canonical; -use ty::{self, CanonicalVar, Lift, List, Ty, TyCtxt}; +use ty::{self, BoundTyIndex, Lift, List, Ty, TyCtxt}; use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; use serialize::{self, Encodable, Encoder, Decodable, Decoder}; @@ -73,13 +73,13 @@ } impl<'tcx> Ord for Kind<'tcx> { - fn cmp(&self, other: &Kind) -> Ordering { + fn cmp(&self, other: &Kind<'_>) -> Ordering { self.unpack().cmp(&other.unpack()) } } impl<'tcx> PartialOrd for Kind<'tcx> { - fn partial_cmp(&self, other: &Kind) -> Option { + fn partial_cmp(&self, other: &Kind<'_>) -> Option { Some(self.cmp(&other)) } } @@ -111,7 +111,7 @@ } impl<'tcx> fmt::Debug for Kind<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.unpack() { UnpackedKind::Lifetime(lt) => write!(f, "{:?}", lt), UnpackedKind::Type(ty) => write!(f, "{:?}", ty), @@ -120,7 +120,7 @@ } impl<'tcx> fmt::Display for Kind<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.unpack() { UnpackedKind::Lifetime(lt) => write!(f, "{}", lt), UnpackedKind::Type(ty) => write!(f, "{}", ty), @@ -205,10 +205,9 @@ where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx> { Substs::for_item(tcx, def_id, |param, substs| { - match self.get(param.index as usize) { - Some(&kind) => kind, - None => mk_kind(param, substs), - } + self.get(param.index as usize) + .cloned() + .unwrap_or_else(|| mk_kind(param, substs)) }) } @@ -230,6 +229,7 @@ mk_kind: &mut F) where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx> { + substs.reserve(defs.params.len()); for param in &defs.params { let kind = mk_kind(param, substs); assert_eq!(param.index as usize, substs.len()); @@ -323,33 +323,6 @@ } } -pub type CanonicalSubsts<'gcx> = Canonical<'gcx, &'gcx Substs<'gcx>>; - -impl<'gcx> CanonicalSubsts<'gcx> { - /// True if this represents a substitution like - /// - /// ```text - /// [?0, ?1, ?2] - /// ``` - /// - /// i.e., each thing is mapped to a canonical variable with the same index. - pub fn is_identity(&self) -> bool { - self.value.iter().zip(CanonicalVar::new(0)..).all(|(kind, cvar)| { - match kind.unpack() { - UnpackedKind::Type(ty) => match ty.sty { - ty::Infer(ty::CanonicalTy(cvar1)) => cvar == cvar1, - _ => false, - }, - - UnpackedKind::Lifetime(r) => match r { - ty::ReCanonical(cvar1) => cvar == *cvar1, - _ => false, - }, - } - }) - } -} - impl<'tcx> serialize::UseSpecializedDecodable for &'tcx Substs<'tcx> {} /////////////////////////////////////////////////////////////////////////// @@ -361,7 +334,7 @@ pub trait Subst<'tcx> : Sized { fn subst<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, - substs: &[Kind<'tcx>]) -> Self { + substs: &[Kind<'tcx>]) -> Self { self.subst_spanned(tcx, substs, None) } @@ -489,7 +462,7 @@ span_bug!( span, "Type parameter `{:?}` ({:?}/{}) out of range \ - when substituting (root type={:?}) substs={:?}", + when substituting (root type={:?}) substs={:?}", p, source_ty, p.idx, @@ -564,3 +537,98 @@ self.tcx().mk_region(ty::fold::shift_region(*region, self.region_binders_passed)) } } + +pub type CanonicalUserSubsts<'tcx> = Canonical<'tcx, UserSubsts<'tcx>>; + +impl CanonicalUserSubsts<'tcx> { + /// True if this represents a substitution like + /// + /// ```text + /// [?0, ?1, ?2] + /// ``` + /// + /// i.e., each thing is mapped to a canonical variable with the same index. + pub fn is_identity(&self) -> bool { + if self.value.user_self_ty.is_some() { + return false; + } + + self.value.substs.iter().zip(BoundTyIndex::new(0)..).all(|(kind, cvar)| { + match kind.unpack() { + UnpackedKind::Type(ty) => match ty.sty { + ty::Infer(ty::BoundTy(ref b)) => cvar == b.var, + _ => false, + }, + + UnpackedKind::Lifetime(r) => match r { + ty::ReCanonical(cvar1) => cvar == *cvar1, + _ => false, + }, + } + }) + } +} + +/// Stores the user-given substs to reach some fully qualified path +/// (e.g., `::Item` or `::Item`). +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] +pub struct UserSubsts<'tcx> { + /// The substitutions for the item as given by the user. + pub substs: &'tcx Substs<'tcx>, + + /// The self-type, in the case of a `::Item` path (when applied + /// to an inherent impl). See `UserSelfTy` below. + pub user_self_ty: Option>, +} + +BraceStructTypeFoldableImpl! { + impl<'tcx> TypeFoldable<'tcx> for UserSubsts<'tcx> { + substs, + user_self_ty, + } +} + +BraceStructLiftImpl! { + impl<'a, 'tcx> Lift<'tcx> for UserSubsts<'a> { + type Lifted = UserSubsts<'tcx>; + substs, + user_self_ty, + } +} + +/// Specifies the user-given self-type. In the case of a path that +/// refers to a member in an inherent impl, this self-type is +/// sometimes needed to constrain the type parameters on the impl. For +/// example, in this code: +/// +/// ``` +/// struct Foo { } +/// impl Foo { fn method() { } } +/// ``` +/// +/// when you then have a path like `>::method`, +/// this struct would carry the def-id of the impl along with the +/// self-type `Foo`. Then we can instantiate the parameters of +/// the impl (with the substs from `UserSubsts`) and apply those to +/// the self-type, giving `Foo`. Finally, we unify that with +/// the self-type here, which contains `?A` to be `&'static u32` +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] +pub struct UserSelfTy<'tcx> { + pub impl_def_id: DefId, + pub self_ty: Ty<'tcx>, +} + +BraceStructTypeFoldableImpl! { + impl<'tcx> TypeFoldable<'tcx> for UserSelfTy<'tcx> { + impl_def_id, + self_ty, + } +} + +BraceStructLiftImpl! { + impl<'a, 'tcx> Lift<'tcx> for UserSelfTy<'a> { + type Lifted = UserSelfTy<'tcx>; + impl_def_id, + self_ty, + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/trait_def.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/trait_def.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/trait_def.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/trait_def.rs 2018-12-04 23:41:40.000000000 +0000 @@ -36,6 +36,11 @@ pub has_auto_impl: bool, + /// If `true`, then this trait has the `#[marker]` attribute, indicating + /// that all its associated items have defaults that cannot be overridden, + /// and thus `impl`s of it are allowed to overlap. + pub is_marker: bool, + /// The ICH of this trait's DefPath, cached here so it doesn't have to be /// recomputed all the time. pub def_path_hash: DefPathHash, @@ -53,13 +58,15 @@ unsafety: hir::Unsafety, paren_sugar: bool, has_auto_impl: bool, + is_marker: bool, def_path_hash: DefPathHash) -> TraitDef { TraitDef { def_id, - paren_sugar, unsafety, + paren_sugar, has_auto_impl, + is_marker, def_path_hash, } } @@ -131,13 +138,20 @@ } } } else { - for v in impls.non_blanket_impls.values() { - for &impl_def_id in v { - f(impl_def_id); - } + for &impl_def_id in impls.non_blanket_impls.values().flatten() { + f(impl_def_id); } } } + + /// Return a vector containing all impls + pub fn all_impls(self, def_id: DefId) -> Vec { + let impls = self.trait_impls_of(def_id); + + impls.blanket_impls.iter().chain( + impls.non_blanket_impls.values().flatten() + ).cloned().collect() + } } // Query provider for `trait_impls_of`. @@ -157,9 +171,9 @@ fast_reject::simplify_type(tcx, impl_self_ty, false) { impls.non_blanket_impls - .entry(simplified_self_ty) - .or_default() - .push(impl_def_id); + .entry(simplified_self_ty) + .or_default() + .push(impl_def_id); } else { impls.blanket_impls.push(impl_def_id); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/util.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/util.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/util.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/util.rs 2018-12-04 23:41:40.000000000 +0000 @@ -39,7 +39,7 @@ } impl<'tcx> fmt::Display for Discr<'tcx> { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { match self.ty.sty { ty::Int(ity) => { let bits = ty::tls::with(|tcx| { @@ -119,17 +119,17 @@ impl IntTypeExt for attr::IntType { fn to_ty<'a, 'gcx, 'tcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> { match *self { - SignedInt(ast::IntTy::I8) => tcx.types.i8, - SignedInt(ast::IntTy::I16) => tcx.types.i16, - SignedInt(ast::IntTy::I32) => tcx.types.i32, - SignedInt(ast::IntTy::I64) => tcx.types.i64, + SignedInt(ast::IntTy::I8) => tcx.types.i8, + SignedInt(ast::IntTy::I16) => tcx.types.i16, + SignedInt(ast::IntTy::I32) => tcx.types.i32, + SignedInt(ast::IntTy::I64) => tcx.types.i64, SignedInt(ast::IntTy::I128) => tcx.types.i128, - SignedInt(ast::IntTy::Isize) => tcx.types.isize, + SignedInt(ast::IntTy::Isize) => tcx.types.isize, UnsignedInt(ast::UintTy::U8) => tcx.types.u8, UnsignedInt(ast::UintTy::U16) => tcx.types.u16, UnsignedInt(ast::UintTy::U32) => tcx.types.u32, UnsignedInt(ast::UintTy::U64) => tcx.types.u64, - UnsignedInt(ast::UintTy::U128) => tcx.types.u128, + UnsignedInt(ast::UintTy::U128) => tcx.types.u128, UnsignedInt(ast::UintTy::Usize) => tcx.types.usize, } } @@ -205,11 +205,11 @@ let mut infringing = Vec::new(); for variant in &adt.variants { for field in &variant.fields { - let span = tcx.def_span(field.did); let ty = field.ty(tcx, substs); if ty.references_error() { continue; } + let span = tcx.def_span(field.did); let cause = ObligationCause { span, ..ObligationCause::dummy() }; let ctx = traits::FulfillmentContext::new(); match traits::fully_normalize(&infcx, ctx, cause, self, &ty) { @@ -257,16 +257,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn has_error_field(self, ty: Ty<'tcx>) -> bool { - match ty.sty { - ty::Adt(def, substs) => { - for field in def.all_fields() { - let field_ty = field.ty(self, substs); - if let Error = field_ty.sty { - return true; - } + if let ty::Adt(def, substs) = ty.sty { + for field in def.all_fields() { + let field_ty = field.ty(self, substs); + if let Error = field_ty.sty { + return true; } } - _ => (), } false } @@ -421,7 +418,7 @@ let ty = self.type_of(adt_did); self.for_each_relevant_impl(drop_trait, ty, |impl_did| { if let Some(item) = self.associated_items(impl_did).next() { - if let Ok(()) = validate(self, impl_did) { + if validate(self, impl_did).is_ok() { dtor_did = Some(item.def_id); } } @@ -513,7 +510,9 @@ false } } - }).map(|(&item_param, _)| item_param).collect(); + }) + .map(|(&item_param, _)| item_param) + .collect(); debug!("destructor_constraint({:?}) = {:?}", def.did, result); result } @@ -674,15 +673,15 @@ pub fn is_representable(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>, sp: Span) - -> Representability { - + -> Representability + { // Iterate until something non-representable is found fn fold_repr>(iter: It) -> Representability { iter.fold(Representability::Representable, |r1, r2| { match (r1, r2) { (Representability::SelfRecursive(v1), Representability::SelfRecursive(v2)) => { - Representability::SelfRecursive(v1.iter().map(|s| *s).chain(v2).collect()) + Representability::SelfRecursive(v1.into_iter().chain(v2).collect()) } (r1, r2) => cmp::max(r1, r2) } @@ -846,8 +845,8 @@ // To avoid a stack overflow when checking an enum variant or struct that // contains a different, structurally recursive type, maintain a stack // of seen types and check recursion for each of them (issues #3008, #3779). - let mut seen: Vec = Vec::new(); - let mut representable_cache = FxHashMap(); + let mut seen: Vec> = Vec::new(); + let mut representable_cache = FxHashMap::default(); let r = is_type_structurally_recursive( tcx, sp, &mut seen, &mut representable_cache, self); debug!("is_type_representable: {:?} is {:?}", self, r); @@ -904,20 +903,17 @@ let (param_env, ty) = query.into_parts(); let needs_drop = |ty: Ty<'tcx>| -> bool { - match tcx.try_needs_drop_raw(DUMMY_SP, param_env.and(ty)) { - Ok(v) => v, - Err(mut bug) => { - // Cycles should be reported as an error by `check_representable`. - // - // Consider the type as not needing drop in the meanwhile to - // avoid further errors. - // - // In case we forgot to emit a bug elsewhere, delay our - // diagnostic to get emitted as a compiler bug. - bug.delay_as_bug(); - false - } - } + tcx.try_needs_drop_raw(DUMMY_SP, param_env.and(ty)).unwrap_or_else(|mut bug| { + // Cycles should be reported as an error by `check_representable`. + // + // Consider the type as not needing drop in the meanwhile to + // avoid further errors. + // + // In case we forgot to emit a bug elsewhere, delay our + // diagnostic to get emitted as a compiler bug. + bug.delay_as_bug(); + false + }) }; assert!(!ty.needs_infer()); @@ -958,6 +954,8 @@ ty::Dynamic(..) | ty::Projection(..) | ty::Param(_) | ty::Opaque(..) | ty::Infer(_) | ty::Error => true, + ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"), + // Structural recursion. ty::Array(ty, _) | ty::Slice(ty) => needs_drop(ty), @@ -1039,7 +1037,7 @@ } } -pub fn provide(providers: &mut ty::query::Providers) { +pub fn provide(providers: &mut ty::query::Providers<'_>) { *providers = ty::query::Providers { is_copy_raw, is_sized_raw, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/walk.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/walk.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/walk.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/walk.rs 2018-12-04 23:41:40.000000000 +0000 @@ -54,7 +54,7 @@ debug!("next(): stack={:?}", self.stack); match self.stack.pop() { None => { - return None; + None } Some(ty) => { self.last_subtree = self.stack.len(); @@ -97,7 +97,7 @@ ty::Ref(_, ty, _) => { stack.push(ty); } - ty::Projection(ref data) => { + ty::Projection(ref data) | ty::UnnormalizedProjection(ref data) => { stack.extend(data.substs.types().rev()); } ty::Dynamic(ref obj, ..) => { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/ty/wf.rs rustc-1.31.0+dfsg1+llvm/src/librustc/ty/wf.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/ty/wf.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/ty/wf.rs 2018-12-04 23:41:40.000000000 +0000 @@ -223,8 +223,8 @@ let predicate = ty::Predicate::ConstEvaluatable(def_id, substs); let cause = self.cause(traits::MiscObligation); self.out.push(traits::Obligation::new(cause, - self.param_env, - predicate)); + self.param_env, + predicate)); } } @@ -289,6 +289,8 @@ self.compute_projection(data); } + ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"), + ty::Adt(def, substs) => { // WfNominalType let obligations = self.nominal_obligations(def.did, substs); @@ -385,7 +387,7 @@ let cause = self.cause(traits::MiscObligation); let component_traits = - data.auto_traits().chain(data.principal().map(|p| p.def_id())); + data.auto_traits().chain(once(data.principal().def_id())); self.out.extend( component_traits.map(|did| traits::Obligation::new( cause.clone(), @@ -493,6 +495,7 @@ let explicit_bound = region; + self.out.reserve(implicit_bounds.len()); for implicit_bound in implicit_bounds { let cause = self.cause(traits::ObjectTypeBound(ty, explicit_bound)); let outlives = ty::Binder::dummy( @@ -518,7 +521,7 @@ { // Since we don't actually *know* the self type for an object, // this "open(err)" serves as a kind of dummy standin -- basically - // a skolemized type. + // a placeholder type. let open_ty = tcx.mk_infer(ty::FreshTy(0)); let predicates = existential_predicates.iter().filter_map(|predicate| { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/util/bug.rs rustc-1.31.0+dfsg1+llvm/src/librustc/util/bug.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/util/bug.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/util/bug.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,7 +16,7 @@ #[cold] #[inline(never)] -pub fn bug_fmt(file: &'static str, line: u32, args: fmt::Arguments) -> ! { +pub fn bug_fmt(file: &'static str, line: u32, args: fmt::Arguments<'_>) -> ! { // this wrapper mostly exists so I don't have to write a fully // qualified path of None:: inside the bug!() macro definition opt_span_bug_fmt(file, line, None::, args); @@ -28,7 +28,7 @@ file: &'static str, line: u32, span: S, - args: fmt::Arguments, + args: fmt::Arguments<'_>, ) -> ! { opt_span_bug_fmt(file, line, Some(span), args); } @@ -37,7 +37,7 @@ file: &'static str, line: u32, span: Option, - args: fmt::Arguments, + args: fmt::Arguments<'_>, ) -> ! { tls::with_opt(move |tcx| { let msg = format!("{}:{}: {}", file, line, args); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/util/common.rs rustc-1.31.0+dfsg1+llvm/src/librustc/util/common.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/util/common.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/util/common.rs 2018-12-04 23:41:40.000000000 +0000 @@ -39,14 +39,14 @@ thread_local!(static TIME_DEPTH: Cell = Cell::new(0)); lazy_static! { - static ref DEFAULT_HOOK: Box = { + static ref DEFAULT_HOOK: Box) + Sync + Send + 'static> = { let hook = panic::take_hook(); panic::set_hook(Box::new(panic_hook)); hook }; } -fn panic_hook(info: &panic::PanicInfo) { +fn panic_hook(info: &panic::PanicInfo<'_>) { if !proc_macro::__internal::in_sess() { (*DEFAULT_HOOK)(info); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/util/nodemap.rs rustc-1.31.0+dfsg1+llvm/src/librustc/util/nodemap.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/util/nodemap.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/util/nodemap.rs 2018-12-04 23:41:40.000000000 +0000 @@ -22,9 +22,9 @@ macro_rules! define_id_collections { ($map_name:ident, $set_name:ident, $key:ty) => { pub type $map_name = FxHashMap<$key, T>; - pub fn $map_name() -> $map_name { FxHashMap() } + pub fn $map_name() -> $map_name { Default::default() } pub type $set_name = FxHashSet<$key>; - pub fn $set_name() -> $set_name { FxHashSet() } + pub fn $set_name() -> $set_name { Default::default() } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/util/ppaux.rs rustc-1.31.0+dfsg1+llvm/src/librustc/util/ppaux.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/util/ppaux.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/util/ppaux.rs 2018-12-04 23:41:40.000000000 +0000 @@ -18,7 +18,7 @@ use ty::{Error, Str, Array, Slice, Float, FnDef, FnPtr}; use ty::{Param, RawPtr, Ref, Never, Tuple}; use ty::{Closure, Generator, GeneratorWitness, Foreign, Projection, Opaque}; -use ty::{Dynamic, Int, Uint, Infer}; +use ty::{UnnormalizedProjection, Dynamic, Int, Uint, Infer}; use ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable, GenericParamCount, GenericParamDefKind}; use util::nodemap::FxHashSet; @@ -34,12 +34,19 @@ thread_local! { /// Mechanism for highlighting of specific regions for display in NLL region inference errors. /// Contains region to highlight and counter for number to use when highlighting. - static HIGHLIGHT_REGION: Cell> = Cell::new(None) + static HIGHLIGHT_REGION_FOR_REGIONVID: Cell> = Cell::new(None) +} + +thread_local! { + /// Mechanism for highlighting of specific regions for display in NLL's 'borrow does not live + /// long enough' errors. Contains a region to highlight and a counter to use. + static HIGHLIGHT_REGION_FOR_BOUND_REGION: Cell> = + Cell::new(None) } macro_rules! gen_display_debug_body { ( $with:path ) => { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut cx = PrintContext::new(); $with(self, f, &mut cx) } @@ -175,7 +182,7 @@ fn prepare_late_bound_region_info<'tcx, T>(&mut self, value: &ty::Binder) where T: TypeFoldable<'tcx> { - let mut collector = LateBoundRegionNameCollector(FxHashSet()); + let mut collector = LateBoundRegionNameCollector(Default::default()); value.visit_with(&mut collector); self.used_region_names = Some(collector.0); self.region_index = 0; @@ -218,9 +225,9 @@ impl PrintContext { fn fn_sig(&mut self, f: &mut F, - inputs: &[Ty], + inputs: &[Ty<'_>], variadic: bool, - output: Ty) + output: Ty<'_>) -> fmt::Result { write!(f, "(")?; let mut inputs = inputs.iter(); @@ -243,9 +250,9 @@ fn parameterized(&mut self, f: &mut F, - substs: &subst::Substs, + substs: &subst::Substs<'_>, mut did: DefId, - projections: &[ty::ProjectionPredicate]) + projections: &[ty::ProjectionPredicate<'_>]) -> fmt::Result { let key = ty::tls::with(|tcx| tcx.def_key(did)); let mut item_name = if let Some(name) = key.disambiguated_data.data.get_opt_name() { @@ -388,12 +395,12 @@ let print_regions = |f: &mut F, start: &str, skip, count| { // Don't print any regions if they're all erased. let regions = || substs.regions().skip(skip).take(count); - if regions().all(|r: ty::Region| *r == ty::ReErased) { + if regions().all(|r: ty::Region<'_>| *r == ty::ReErased) { return Ok(()); } for region in regions() { - let region: ty::Region = region; + let region: ty::Region<'_> = region; start_or_continue(f, start, ", ")?; if verbose { write!(f, "{:?}", region)?; @@ -557,19 +564,41 @@ } pub fn parameterized(f: &mut F, - substs: &subst::Substs, + substs: &subst::Substs<'_>, did: DefId, - projections: &[ty::ProjectionPredicate]) + projections: &[ty::ProjectionPredicate<'_>]) -> fmt::Result { PrintContext::new().parameterized(f, substs, did, projections) } -fn get_highlight_region() -> Option<(RegionVid, usize)> { - HIGHLIGHT_REGION.with(|hr| hr.get()) +fn get_highlight_region_for_regionvid() -> Option<(RegionVid, usize)> { + HIGHLIGHT_REGION_FOR_REGIONVID.with(|hr| hr.get()) } -pub fn with_highlight_region(r: RegionVid, counter: usize, op: impl FnOnce() -> R) -> R { - HIGHLIGHT_REGION.with(|hr| { +pub fn with_highlight_region_for_regionvid( + r: RegionVid, + counter: usize, + op: impl FnOnce() -> R +) -> R { + HIGHLIGHT_REGION_FOR_REGIONVID.with(|hr| { + assert_eq!(hr.get(), None); + hr.set(Some((r, counter))); + let r = op(); + hr.set(None); + r + }) +} + +fn get_highlight_region_for_bound_region() -> Option<(ty::BoundRegion, usize)> { + HIGHLIGHT_REGION_FOR_BOUND_REGION.with(|hr| hr.get()) +} + +pub fn with_highlight_region_for_bound_region( + r: ty::BoundRegion, + counter: usize, + op: impl Fn() -> R +) -> R { + HIGHLIGHT_REGION_FOR_BOUND_REGION.with(|hr| { assert_eq!(hr.get(), None); hr.set(Some((r, counter))); let r = op(); @@ -592,16 +621,16 @@ // Use a type that can't appear in defaults of type parameters. let dummy_self = tcx.mk_infer(ty::FreshTy(0)); - if let Some(p) = self.principal() { - let principal = tcx.lift(&p).expect("could not lift TraitRef for printing") - .with_self_ty(tcx, dummy_self); - let projections = self.projection_bounds().map(|p| { - tcx.lift(&p) - .expect("could not lift projection for printing") - .with_self_ty(tcx, dummy_self) - }).collect::>(); - cx.parameterized(f, principal.substs, principal.def_id, &projections)?; - } + let principal = tcx + .lift(&self.principal()) + .expect("could not lift TraitRef for printing") + .with_self_ty(tcx, dummy_self); + let projections = self.projection_bounds().map(|p| { + tcx.lift(&p) + .expect("could not lift projection for printing") + .with_self_ty(tcx, dummy_self) + }).collect::>(); + cx.parameterized(f, principal.substs, principal.def_id, &projections)?; // Builtin bounds. for did in self.auto_traits() { @@ -617,7 +646,7 @@ } impl fmt::Debug for ty::GenericParamDef { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let type_name = match self.kind { ty::GenericParamDefKind::Lifetime => "Lifetime", ty::GenericParamDefKind::Type {..} => "Type", @@ -631,7 +660,7 @@ } impl fmt::Debug for ty::TraitDef { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ty::tls::with(|tcx| { write!(f, "{}", tcx.item_path_str(self.def_id)) }) @@ -639,7 +668,7 @@ } impl fmt::Debug for ty::AdtDef { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ty::tls::with(|tcx| { write!(f, "{}", tcx.item_path_str(self.did)) }) @@ -647,7 +676,7 @@ } impl<'tcx> fmt::Debug for ty::ClosureUpvar<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "ClosureUpvar({:?},{:?})", self.def, self.ty) @@ -655,7 +684,7 @@ } impl fmt::Debug for ty::UpvarId { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "UpvarId({:?};`{}`;{:?})", self.var_id, ty::tls::with(|tcx| tcx.hir.name(tcx.hir.hir_to_node_id(self.var_id))), @@ -664,7 +693,7 @@ } impl<'tcx> fmt::Debug for ty::UpvarBorrow<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "UpvarBorrow({:?}, {:?})", self.kind, self.region) } @@ -726,6 +755,15 @@ return self.print_debug(f, cx); } + if let Some((region, counter)) = get_highlight_region_for_bound_region() { + if *self == region { + return match *self { + BrNamed(_, name) => write!(f, "{}", name), + BrAnon(_) | BrFresh(_) | BrEnv => write!(f, "'{}", counter) + }; + } + } + match *self { BrNamed(_, name) => write!(f, "{}", name), BrAnon(_) | BrFresh(_) | BrEnv => Ok(()) @@ -748,7 +786,7 @@ define_print! { () ty::RegionKind, (self, f, cx) { display { - if cx.is_verbose || get_highlight_region().is_some() { + if cx.is_verbose || get_highlight_region_for_regionvid().is_some() { return self.print_debug(f, cx); } @@ -765,7 +803,7 @@ } ty::ReLateBound(_, br) | ty::ReFree(ty::FreeRegion { bound_region: br, .. }) | - ty::ReSkolemized(_, br) => { + ty::RePlaceholder(ty::Placeholder { name: br, .. }) => { write!(f, "{}", br) } ty::ReScope(scope) if cx.identify_regions => { @@ -834,8 +872,8 @@ write!(f, "'?{}", c.index()) } - ty::ReSkolemized(universe, ref bound_region) => { - write!(f, "ReSkolemized({:?}, {:?})", universe, bound_region) + ty::RePlaceholder(placeholder) => { + write!(f, "RePlaceholder({:?})", placeholder) } ty::ReEmpty => write!(f, "ReEmpty"), @@ -904,26 +942,26 @@ } impl fmt::Debug for ty::TyVid { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "_#{}t", self.index) } } impl fmt::Debug for ty::IntVid { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "_#{}i", self.index) } } impl fmt::Debug for ty::FloatVid { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "_#{}f", self.index) } } impl fmt::Debug for ty::RegionVid { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - if let Some((region, counter)) = get_highlight_region() { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + if let Some((region, counter)) = get_highlight_region_for_regionvid() { debug!("RegionVid.fmt: region={:?} self={:?} counter={:?}", region, self, counter); return if *self == region { write!(f, "'{:?}", counter) @@ -946,7 +984,7 @@ ty::TyVar(_) => write!(f, "_"), ty::IntVar(_) => write!(f, "{}", "{integer}"), ty::FloatVar(_) => write!(f, "{}", "{float}"), - ty::CanonicalTy(_) => write!(f, "_"), + ty::BoundTy(_) => write!(f, "_"), ty::FreshTy(v) => write!(f, "FreshTy({})", v), ty::FreshIntTy(v) => write!(f, "FreshIntTy({})", v), ty::FreshFloatTy(v) => write!(f, "FreshFloatTy({})", v) @@ -958,7 +996,7 @@ ty::TyVar(ref v) => write!(f, "{:?}", v), ty::IntVar(ref v) => write!(f, "{:?}", v), ty::FloatVar(ref v) => write!(f, "{:?}", v), - ty::CanonicalTy(v) => write!(f, "?{:?}", v.index()), + ty::BoundTy(v) => write!(f, "?{:?}", v.var.index()), ty::FreshTy(v) => write!(f, "FreshTy({:?})", v), ty::FreshIntTy(v) => write!(f, "FreshIntTy({:?})", v), ty::FreshFloatTy(v) => write!(f, "FreshFloatTy({:?})", v) @@ -968,7 +1006,7 @@ } impl fmt::Debug for ty::IntVarValue { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { ty::IntType(ref v) => v.fmt(f), ty::UintType(ref v) => v.fmt(f), @@ -977,7 +1015,7 @@ } impl fmt::Debug for ty::FloatVarValue { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } @@ -988,7 +1026,7 @@ where T: fmt::Display + for<'a> ty::Lift<'a>, for<'a> >::Lifted: fmt::Display + TypeFoldable<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ty::tls::with(|tcx| in_binder(f, tcx, self, tcx.lift(self))) } }*/ @@ -1105,6 +1143,11 @@ } Foreign(def_id) => parameterized(f, subst::Substs::empty(), def_id, &[]), Projection(ref data) => data.print(f, cx), + UnnormalizedProjection(ref data) => { + write!(f, "Unnormalized(")?; + data.print(f, cx)?; + write!(f, ")") + } Opaque(def_id, substs) => { if cx.is_verbose { return write!(f, "Opaque({:?}, {:?})", def_id, substs); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc/util/profiling.rs rustc-1.31.0+dfsg1+llvm/src/librustc/util/profiling.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc/util/profiling.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc/util/profiling.rs 2018-12-04 23:41:40.000000000 +0000 @@ -61,7 +61,7 @@ } } - fn print(&self, lock: &mut StdoutLock) { + fn print(&self, lock: &mut StdoutLock<'_>) { writeln!(lock, "| Phase | Time (ms) | Queries | Hits (%) |") .unwrap(); writeln!(lock, "| ---------------- | -------------- | -------------- | -------- |") diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_allocator/expand.rs rustc-1.31.0+dfsg1+llvm/src/librustc_allocator/expand.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_allocator/expand.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_allocator/expand.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,8 +9,8 @@ // except according to those terms. use rustc::middle::allocator::AllocatorKind; -use rustc_data_structures::small_vec::OneVector; use rustc_errors; +use smallvec::SmallVec; use syntax::{ ast::{ self, Arg, Attribute, Crate, Expr, FnHeader, Generics, Ident, Item, ItemKind, @@ -65,7 +65,7 @@ } impl<'a> Folder for ExpandAllocatorDirectives<'a> { - fn fold_item(&mut self, item: P) -> OneVector> { + fn fold_item(&mut self, item: P) -> SmallVec<[P; 1]> { debug!("in submodule {}", self.in_submod); let name = if attr::contains_name(&item.attrs, "global_allocator") { @@ -152,11 +152,7 @@ let module = f.cx.monotonic_expander().fold_item(module).pop().unwrap(); // Return the item and new submodule - let mut ret = OneVector::with_capacity(2); - ret.push(item); - ret.push(module); - - return ret; + smallvec![item, module] } // If we enter a submodule, take note. diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_allocator/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_allocator/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_allocator/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_allocator/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(rustc_private)] #[macro_use] extern crate log; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_apfloat/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_apfloat/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_apfloat/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_apfloat/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -45,8 +45,7 @@ html_root_url = "https://doc.rust-lang.org/nightly/")] #![forbid(unsafe_code)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(try_from)] // See librustc_cratesio_shim/Cargo.toml for a comment explaining this. #[allow(unused_extern_crates)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_asan/build.rs rustc-1.31.0+dfsg1+llvm/src/librustc_asan/build.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_asan/build.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_asan/build.rs 2018-12-04 23:41:40.000000000 +0000 @@ -31,6 +31,7 @@ .out_dir(&native.out_dir) .build_target(&target) .build(); + native.fixup_sanitizer_lib_name("asan"); } println!("cargo:rerun-if-env-changed=LLVM_CONFIG"); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_asan/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_asan/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_asan/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_asan/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,8 +10,7 @@ #![sanitizer_runtime] #![feature(alloc_system)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(sanitizer_runtime)] #![feature(staged_api)] #![no_std] diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_borrowck/borrowck/check_loans.rs rustc-1.31.0+dfsg1+llvm/src/librustc_borrowck/borrowck/check_loans.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_borrowck/borrowck/check_loans.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_borrowck/borrowck/check_loans.rs 2018-12-04 23:41:40.000000000 +0000 @@ -426,7 +426,7 @@ // These cannot exist in borrowck RegionKind::ReVar(..) | RegionKind::ReCanonical(..) | - RegionKind::ReSkolemized(..) | + RegionKind::RePlaceholder(..) | RegionKind::ReClosureBound(..) | RegionKind::ReErased => span_bug!(borrow_span, "unexpected region in borrowck {:?}", @@ -609,12 +609,12 @@ new_loan.span, &nl, old_loan.span, previous_end_span, Origin::Ast), (ty::UniqueImmBorrow, _) => self.bccx.cannot_uniquely_borrow_by_one_closure( - new_loan.span, &nl, &new_loan_msg, + new_loan.span, "closure", &nl, &new_loan_msg, old_loan.span, &ol_pronoun, &old_loan_msg, previous_end_span, Origin::Ast), (_, ty::UniqueImmBorrow) => { let new_loan_str = &new_loan.kind.to_user_str(); self.bccx.cannot_reborrow_already_uniquely_borrowed( - new_loan.span, &nl, &new_loan_msg, new_loan_str, + new_loan.span, "closure", &nl, &new_loan_msg, new_loan_str, old_loan.span, &old_loan_msg, previous_end_span, Origin::Ast) } (..) => diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_borrowck/borrowck/gather_loans/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_borrowck/borrowck/gather_loans/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_borrowck/borrowck/gather_loans/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_borrowck/borrowck/gather_loans/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -368,7 +368,7 @@ ty::ReClosureBound(..) | ty::ReLateBound(..) | ty::ReVar(..) | - ty::ReSkolemized(..) | + ty::RePlaceholder(..) | ty::ReErased => { span_bug!( cmt.span, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_borrowck/borrowck/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_borrowck/borrowck/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_borrowck/borrowck/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_borrowck/borrowck/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -38,6 +38,7 @@ use rustc_mir::util::suggest_ref_mut; use rustc::util::nodemap::FxHashSet; +use std::borrow::Cow; use std::cell::{Cell, RefCell}; use std::fmt; use std::rc::Rc; @@ -102,7 +103,7 @@ // tuple structs/variants) do not have an associated body // and do not need borrowchecking. return Lrc::new(BorrowCheckResult { - used_mut_nodes: FxHashSet(), + used_mut_nodes: Default::default(), signalled_any_error: SignalledError::NoErrorsSeen, }) } @@ -119,7 +120,7 @@ region_scope_tree, owner_def_id, body, - used_mut_nodes: RefCell::new(FxHashSet()), + used_mut_nodes: Default::default(), signalled_any_error: Cell::new(SignalledError::NoErrorsSeen), }; @@ -234,7 +235,7 @@ region_scope_tree, owner_def_id, body, - used_mut_nodes: RefCell::new(FxHashSet()), + used_mut_nodes: Default::default(), signalled_any_error: Cell::new(SignalledError::NoErrorsSeen), }; @@ -694,7 +695,7 @@ let mut err = self.cannot_act_on_moved_value(use_span, verb, msg, - Some(nl.to_string()), + Some(nl), Origin::Ast); let need_note = match lp.ty.sty { ty::Closure(id, _) => { @@ -808,34 +809,34 @@ match err.code { err_mutbl => { - let descr = match err.cmt.note { + let descr: Cow<'static, str> = match err.cmt.note { mc::NoteClosureEnv(_) | mc::NoteUpvarRef(_) => { - self.cmt_to_string(&err.cmt) + self.cmt_to_cow_str(&err.cmt) } _ => match opt_loan_path_is_field(&err.cmt) { (None, true) => { format!("{} of {} binding", - self.cmt_to_string(&err.cmt), - err.cmt.mutbl.to_user_str()) + self.cmt_to_cow_str(&err.cmt), + err.cmt.mutbl.to_user_str()).into() } (None, false) => { format!("{} {}", err.cmt.mutbl.to_user_str(), - self.cmt_to_string(&err.cmt)) + self.cmt_to_cow_str(&err.cmt)).into() } (Some(lp), true) => { format!("{} `{}` of {} binding", - self.cmt_to_string(&err.cmt), + self.cmt_to_cow_str(&err.cmt), self.loan_path_to_string(&lp), - err.cmt.mutbl.to_user_str()) + err.cmt.mutbl.to_user_str()).into() } (Some(lp), false) => { format!("{} {} `{}`", err.cmt.mutbl.to_user_str(), - self.cmt_to_string(&err.cmt), - self.loan_path_to_string(&lp)) + self.cmt_to_cow_str(&err.cmt), + self.loan_path_to_string(&lp)).into() } } }; @@ -867,10 +868,20 @@ }) = cmt.cat { db.note(fn_closure_msg); } else { - db.span_suggestion(sp, msg, suggestion); + db.span_suggestion_with_applicability( + sp, + msg, + suggestion, + Applicability::Unspecified, + ); } } else { - db.span_suggestion(sp, msg, suggestion); + db.span_suggestion_with_applicability( + sp, + msg, + suggestion, + Applicability::Unspecified, + ); } } _ => { @@ -1048,11 +1059,11 @@ err_borrowed_pointer_too_short(loan_scope, ptr_scope) => { let descr = self.cmt_to_path_or_string(err.cmt); let mut db = self.lifetime_too_short_for_reborrow(error_span, &descr, Origin::Ast); - let descr = match opt_loan_path(&err.cmt) { + let descr: Cow<'static, str> = match opt_loan_path(&err.cmt) { Some(lp) => { - format!("`{}`", self.loan_path_to_string(&lp)) + format!("`{}`", self.loan_path_to_string(&lp)).into() } - None => self.cmt_to_string(&err.cmt), + None => self.cmt_to_cow_str(&err.cmt) }; self.tcx.note_and_explain_region( &self.region_scope_tree, @@ -1211,7 +1222,7 @@ if let Some(i) = arg_pos { // The argument's `Ty` (Some(&fn_like.decl().inputs[i]), - i == 0 && fn_like.decl().has_implicit_self) + i == 0 && fn_like.decl().implicit_self.has_implicit_self()) } else { (None, false) } @@ -1236,10 +1247,16 @@ let let_span = self.tcx.hir.span(node_id); let suggestion = suggest_ref_mut(self.tcx, let_span); if let Some(replace_str) = suggestion { - db.span_suggestion( + db.span_suggestion_with_applicability( let_span, "use a mutable reference instead", replace_str, + // I believe this can be machine applicable, + // but if there are multiple attempted uses of an immutable + // reference, I don't know how rustfix handles it, it might + // attempt fixing them multiple times. + // @estebank + Applicability::Unspecified, ); } } @@ -1292,11 +1309,12 @@ )) = ty.map(|t| &t.node) { let borrow_expr_id = self.tcx.hir.get_parent_node(borrowed_node_id); - db.span_suggestion( + db.span_suggestion_with_applicability( self.tcx.hir.span(borrow_expr_id), "consider removing the `&mut`, as it is an \ immutable binding to a mutable reference", - snippet + snippet, + Applicability::MachineApplicable, ); } else { db.span_suggestion_with_applicability( @@ -1326,12 +1344,15 @@ &cmt_path_or_string, capture_span, Origin::Ast) - .span_suggestion(err.span, - &format!("to force the closure to take ownership of {} \ - (and any other referenced variables), \ - use the `move` keyword", - cmt_path_or_string), - suggestion) + .span_suggestion_with_applicability( + err.span, + &format!("to force the closure to take ownership of {} \ + (and any other referenced variables), \ + use the `move` keyword", + cmt_path_or_string), + suggestion, + Applicability::MachineApplicable, + ) .emit(); self.signal_error(); } @@ -1457,14 +1478,14 @@ result } - pub fn cmt_to_string(&self, cmt: &mc::cmt_<'tcx>) -> String { + pub fn cmt_to_cow_str(&self, cmt: &mc::cmt_<'tcx>) -> Cow<'static, str> { cmt.descriptive_string(self.tcx) } pub fn cmt_to_path_or_string(&self, cmt: &mc::cmt_<'tcx>) -> String { match opt_loan_path(cmt) { Some(lp) => format!("`{}`", self.loan_path_to_string(&lp)), - None => self.cmt_to_string(cmt), + None => self.cmt_to_cow_str(cmt).into_owned(), } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_borrowck/borrowck/move_data.rs rustc-1.31.0+dfsg1+llvm/src/librustc_borrowck/borrowck/move_data.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_borrowck/borrowck/move_data.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_borrowck/borrowck/move_data.rs 2018-12-04 23:41:40.000000000 +0000 @@ -347,7 +347,7 @@ lp = base_lp.clone(); } - self.add_move_helper(tcx, orig_lp.clone(), id, kind); + self.add_move_helper(tcx, orig_lp, id, kind); } fn add_move_helper(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, @@ -359,7 +359,7 @@ id, kind); - let path_index = self.move_path(tcx, lp.clone()); + let path_index = self.move_path(tcx, lp); let move_index = MoveIndex(self.moves.borrow().len()); let next_move = self.path_first_move(path_index); @@ -402,7 +402,7 @@ } } - self.add_assignment_helper(tcx, lp.clone(), assign_id, span); + self.add_assignment_helper(tcx, lp, assign_id, span); } fn add_assignment_helper(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_borrowck/borrowck/unused.rs rustc-1.31.0+dfsg1+llvm/src/librustc_borrowck/borrowck/unused.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_borrowck/borrowck/unused.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_borrowck/borrowck/unused.rs 2018-12-04 23:41:40.000000000 +0000 @@ -45,7 +45,7 @@ impl<'a, 'tcx> UnusedMutCx<'a, 'tcx> { fn check_unused_mut_pat(&self, pats: &[P]) { let tcx = self.bccx.tcx; - let mut mutables: FxHashMap<_, Vec<_>> = FxHashMap(); + let mut mutables: FxHashMap<_, Vec<_>> = Default::default(); for p in pats { p.each_binding(|_, hir_id, span, ident| { // Skip anything that looks like `_foo` @@ -76,10 +76,14 @@ } let (hir_id, span) = ids[0]; - let mut_span = tcx.sess.source_map().span_until_non_whitespace(span); + if span.compiler_desugaring_kind().is_some() { + // If the `mut` arises as part of a desugaring, we should ignore it. + continue; + } // Ok, every name wasn't used mutably, so issue a warning that this // didn't need to be mutable. + let mut_span = tcx.sess.source_map().span_until_non_whitespace(span); tcx.struct_span_lint_hir(UNUSED_MUT, hir_id, span, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_borrowck/dataflow.rs rustc-1.31.0+dfsg1+llvm/src/librustc_borrowck/dataflow.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_borrowck/dataflow.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_borrowck/dataflow.rs 2018-12-04 23:41:40.000000000 +0000 @@ -169,7 +169,7 @@ fn build_local_id_to_index(body: Option<&hir::Body>, cfg: &cfg::CFG) -> FxHashMap> { - let mut index = FxHashMap(); + let mut index = FxHashMap::default(); // FIXME(#15020) Would it be better to fold formals from decl // into cfg itself? i.e. introduce a fn-based flow-graph in diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_borrowck/graphviz.rs rustc-1.31.0+dfsg1+llvm/src/librustc_borrowck/graphviz.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_borrowck/graphviz.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_borrowck/graphviz.rs 2018-12-04 23:41:40.000000000 +0000 @@ -23,7 +23,6 @@ use rustc::cfg::CFGIndex; use dataflow::{DataFlowOperator, DataFlowContext, EntryOrExit}; use std::rc::Rc; -use dot::IntoCow; #[derive(Debug, Copy, Clone)] pub enum Variant { @@ -139,8 +138,8 @@ let suffix = self.dataflow_for(EntryOrExit::Exit, n); let inner_label = self.inner.node_label(n); inner_label - .prefix_line(dot::LabelText::LabelStr(prefix.into_cow())) - .suffix_line(dot::LabelText::LabelStr(suffix.into_cow())) + .prefix_line(dot::LabelText::LabelStr(prefix.into())) + .suffix_line(dot::LabelText::LabelStr(suffix.into())) } fn edge_label(&'a self, e: &Edge<'a>) -> dot::LabelText<'a> { self.inner.edge_label(e) } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_borrowck/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_borrowck/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_borrowck/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_borrowck/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,8 +14,7 @@ #![allow(non_camel_case_types)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(quote)] #![recursion_limit="256"] diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/abi.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/abi.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/abi.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/abi.rs 2018-12-04 23:41:40.000000000 +0000 @@ -150,7 +150,7 @@ // Create list of fields in the main structure let mut args: Vec<_> = self.prefix.iter().flat_map(|option_kind| option_kind.map( - |kind| Reg { kind: kind, size: self.prefix_chunk }.llvm_type(cx))) + |kind| Reg { kind: kind, size: self.prefix_chunk }.llvm_type(cx))) .chain((0..rest_count).map(|_| rest_ll_unit)) .collect(); @@ -259,8 +259,7 @@ } pub trait FnTypeExt<'tcx> { - fn of_instance(cx: &CodegenCx<'ll, 'tcx>, instance: &ty::Instance<'tcx>) - -> Self; + fn of_instance(cx: &CodegenCx<'ll, 'tcx>, instance: &ty::Instance<'tcx>) -> Self; fn new(cx: &CodegenCx<'ll, 'tcx>, sig: ty::FnSig<'tcx>, extra_args: &[Ty<'tcx>]) -> Self; @@ -283,8 +282,7 @@ } impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> { - fn of_instance(cx: &CodegenCx<'ll, 'tcx>, instance: &ty::Instance<'tcx>) - -> Self { + fn of_instance(cx: &CodegenCx<'ll, 'tcx>, instance: &ty::Instance<'tcx>) -> Self { let fn_ty = instance.ty(cx.tcx); let sig = ty_fn_sig(cx, fn_ty); let sig = cx.tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig); @@ -292,16 +290,16 @@ } fn new(cx: &CodegenCx<'ll, 'tcx>, - sig: ty::FnSig<'tcx>, - extra_args: &[Ty<'tcx>]) -> Self { + sig: ty::FnSig<'tcx>, + extra_args: &[Ty<'tcx>]) -> Self { FnType::new_internal(cx, sig, extra_args, |ty, _| { ArgType::new(cx.layout_of(ty)) }) } fn new_vtable(cx: &CodegenCx<'ll, 'tcx>, - sig: ty::FnSig<'tcx>, - extra_args: &[Ty<'tcx>]) -> Self { + sig: ty::FnSig<'tcx>, + extra_args: &[Ty<'tcx>]) -> Self { FnType::new_internal(cx, sig, extra_args, |ty, arg_idx| { let mut layout = cx.layout_of(ty); // Don't pass the vtable, it's not an argument of the virtual fn. @@ -338,7 +336,7 @@ RustIntrinsic | PlatformIntrinsic | Rust | RustCall => Conv::C, - // It's the ABI's job to select this, not us. + // It's the ABI's job to select this, not ours. System => bug!("system abi should be selected elsewhere"), Stdcall => Conv::X86Stdcall, @@ -538,7 +536,10 @@ // Note that the platform intrinsic ABI is exempt here as // that's how we connect up to LLVM and it's unstable // anyway, we control all calls to it in libstd. - layout::Abi::Vector { .. } if abi != Abi::PlatformIntrinsic => { + layout::Abi::Vector { .. } + if abi != Abi::PlatformIntrinsic && + cx.sess().target.target.options.simd_types_indirect => + { arg.make_indirect(); return } @@ -697,14 +698,13 @@ // If the value is a boolean, the range is 0..2 and that ultimately // become 0..0 when the type becomes i1, which would be rejected // by the LLVM verifier. - match scalar.value { - layout::Int(..) if !scalar.is_bool() => { + if let layout::Int(..) = scalar.value { + if !scalar.is_bool() { let range = scalar.valid_range_exclusive(bx.cx); if range.start != range.end { bx.range_metadata(callsite, range); } } - _ => {} } } for arg in &self.args { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/allocator.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/allocator.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/allocator.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/allocator.rs 2018-12-04 23:41:40.000000000 +0000 @@ -33,7 +33,7 @@ let void = llvm::LLVMVoidTypeInContext(llcx); for method in ALLOCATOR_METHODS { - let mut args = Vec::new(); + let mut args = Vec::with_capacity(method.inputs.len()); for ty in method.inputs.iter() { match *ty { AllocatorTy::Layout => { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/asm.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/asm.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/asm.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/asm.rs 2018-12-04 23:41:40.000000000 +0000 @@ -30,7 +30,7 @@ ia: &hir::InlineAsm, outputs: Vec>, mut inputs: Vec<&'ll Value> -) { +) -> bool { let mut ext_constraints = vec![]; let mut output_types = vec![]; @@ -97,6 +97,10 @@ ia.alignstack, dialect ); + if r.is_none() { + return false; + } + let r = r.unwrap(); // Again, based on how many outputs we have let outputs = ia.outputs.iter().zip(&outputs).filter(|&(ref o, _)| !o.is_indirect); @@ -117,6 +121,8 @@ llvm::LLVMSetMetadata(r, kind, llvm::LLVMMDNodeInContext(bx.cx.llcx, &val, 1)); } + + return true; } pub fn codegen_global_asm<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/attributes.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/attributes.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/attributes.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/attributes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -94,9 +94,8 @@ // Currently stack probes seem somewhat incompatible with the address // sanitizer. With asan we're already protected from stack overflow anyway // so we don't really need stack probes regardless. - match cx.sess().opts.debugging_opts.sanitizer { - Some(Sanitizer::Address) => return, - _ => {} + if let Some(Sanitizer::Address) = cx.sess().opts.debugging_opts.sanitizer { + return } // probestack doesn't play nice either with pgo-gen. @@ -138,6 +137,15 @@ target_cpu.as_c_str()); } +/// Sets the `NonLazyBind` LLVM attribute on a given function, +/// assuming the codegen options allow skipping the PLT. +pub fn non_lazy_bind(sess: &Session, llfn: &'ll Value) { + // Don't generate calls through PLT if it's not necessary + if !sess.needs_plt() { + Attribute::NonLazyBind.apply_llfn(Function, llfn); + } +} + /// Composite function which sets LLVM attributes for function depending on its AST (#[attribute]) /// attributes. pub fn from_fn_attrs( @@ -146,7 +154,7 @@ id: Option, ) { let codegen_fn_attrs = id.map(|id| cx.tcx.codegen_fn_attrs(id)) - .unwrap_or(CodegenFnAttrs::new()); + .unwrap_or_else(|| CodegenFnAttrs::new()); inline(cx, llfn, codegen_fn_attrs.inline); @@ -280,14 +288,16 @@ // `NativeLibrary` internally contains information about // `#[link(wasm_import_module = "...")]` for example. let native_libs = tcx.native_libraries(cnum); - let mut def_id_to_native_lib = FxHashMap(); - for lib in native_libs.iter() { + + let def_id_to_native_lib = native_libs.iter().filter_map(|lib| if let Some(id) = lib.foreign_module { - def_id_to_native_lib.insert(id, lib); + Some((id, lib)) + } else { + None } - } + ).collect::>(); - let mut ret = FxHashMap(); + let mut ret = FxHashMap::default(); for lib in tcx.foreign_modules(cnum).iter() { let module = def_id_to_native_lib .get(&lib.def_id) @@ -296,10 +306,10 @@ Some(s) => s, None => continue, }; - for id in lib.foreign_items.iter() { + ret.extend(lib.foreign_items.iter().map(|id| { assert_eq!(id.krate, cnum); - ret.insert(*id, module.to_string()); - } + (*id, module.to_string()) + })); } Lrc::new(ret) diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/back/linker.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/back/linker.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/back/linker.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/back/linker.rs 2018-12-04 23:41:40.000000000 +0000 @@ -89,6 +89,7 @@ Box::new(WasmLd { cmd, sess, + info: self }) as Box } } @@ -204,17 +205,6 @@ self.linker_arg(&format!("-plugin-opt={}", opt_level)); self.linker_arg(&format!("-plugin-opt=mcpu={}", llvm_util::target_cpu(self.sess))); - - match self.sess.lto() { - config::Lto::Thin | - config::Lto::ThinLocal => { - self.linker_arg("-plugin-opt=thin"); - } - config::Lto::Fat | - config::Lto::No => { - // default to regular LTO - } - } } } @@ -926,6 +916,7 @@ pub struct WasmLd<'a> { cmd: Command, sess: &'a Session, + info: &'a LinkerInfo, } impl<'a> Linker for WasmLd<'a> { @@ -1021,7 +1012,10 @@ fn build_dylib(&mut self, _out_filename: &Path) { } - fn export_symbols(&mut self, _tmpdir: &Path, _crate_type: CrateType) { + fn export_symbols(&mut self, _tmpdir: &Path, crate_type: CrateType) { + for sym in self.info.exports[&crate_type].iter() { + self.cmd.arg("--export").arg(&sym); + } } fn subsystem(&mut self, _subsystem: &str) { @@ -1071,6 +1065,10 @@ // Make the default table accessible self.cmd.arg("--export-table"); + // Rust code should never have warnings, and warnings are often + // indicative of bugs, let's prevent them. + self.cmd.arg("--fatal-warnings"); + let mut cmd = Command::new(""); ::std::mem::swap(&mut cmd, &mut self.cmd); cmd diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/back/link.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/back/link.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/back/link.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/back/link.rs 2018-12-04 23:41:40.000000000 +0000 @@ -47,7 +47,8 @@ use syntax::attr; pub use rustc_codegen_utils::link::{find_crate_name, filename_for_input, default_output_for_target, - invalid_output_for_target, out_filename, check_file_is_writeable}; + invalid_output_for_target, out_filename, check_file_is_writeable, + filename_for_metadata}; // The third parameter is for env vars, used on windows to set up the // path for MSVC to find its DLLs, and gcc to find its bundled @@ -218,15 +219,6 @@ false } -fn filename_for_metadata(sess: &Session, crate_name: &str, outputs: &OutputFilenames) -> PathBuf { - let out_filename = outputs.single_output_file.clone() - .unwrap_or(outputs - .out_directory - .join(&format!("lib{}{}.rmeta", crate_name, sess.opts.cg.extra_filename))); - check_file_is_writeable(&out_filename, sess); - out_filename -} - pub(crate) fn each_linked_rlib(sess: &Session, info: &CrateInfo, f: &mut dyn FnMut(CrateNum, &Path)) -> Result<(), String> { @@ -1146,12 +1138,16 @@ // Pass debuginfo flags down to the linker. cmd.debuginfo(); - // We want to prevent the compiler from accidentally leaking in any system - // libraries, so we explicitly ask gcc to not link to any libraries by - // default. Note that this does not happen for windows because windows pulls - // in some large number of libraries and I couldn't quite figure out which - // subset we wanted. - if t.options.no_default_libraries { + // We want to, by default, prevent the compiler from accidentally leaking in + // any system libraries, so we may explicitly ask linkers to not link to any + // libraries by default. Note that this does not happen for windows because + // windows pulls in some large number of libraries and I couldn't quite + // figure out which subset we wanted. + // + // This is all naturally configurable via the standard methods as well. + if !sess.opts.cg.default_linker_libraries.unwrap_or(false) && + t.options.no_default_libraries + { cmd.no_default_libraries(); } @@ -1317,7 +1313,7 @@ // for the current implementation of the standard library. let mut group_end = None; let mut group_start = None; - let mut end_with = FxHashSet(); + let mut end_with = FxHashSet::default(); let info = &codegen_results.crate_info; for &(cnum, _) in deps.iter().rev() { if let Some(missing) = info.missing_lang_items.get(&cnum) { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/back/lto.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/back/lto.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/back/lto.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/back/lto.rs 2018-12-04 23:41:40.000000000 +0000 @@ -18,6 +18,7 @@ use llvm; use memmap; use rustc::dep_graph::WorkProduct; +use rustc::dep_graph::cgu_reuse_tracker::CguReuse; use rustc::hir::def_id::LOCAL_CRATE; use rustc::middle::exported_symbols::SymbolExportLevel; use rustc::session::config::{self, Lto}; @@ -501,7 +502,7 @@ // If we don't compile incrementally, we don't need to load the // import data from LLVM. assert!(green_modules.is_empty()); - ThinLTOImports::new() + ThinLTOImports::default() }; info!("thin LTO import map loaded"); timeline.record("import-map-loaded"); @@ -538,6 +539,8 @@ let work_product = green_modules[module_name].clone(); copy_jobs.push(work_product); info!(" - {}: re-used", module_name); + cgcx.cgu_reuse_tracker.set_actual_reuse(module_name, + CguReuse::PostLto); continue } } @@ -870,19 +873,13 @@ } } -#[derive(Debug)] +#[derive(Debug, Default)] pub struct ThinLTOImports { // key = llvm name of importing module, value = list of modules it imports from imports: FxHashMap>, } impl ThinLTOImports { - fn new() -> ThinLTOImports { - ThinLTOImports { - imports: FxHashMap(), - } - } - fn modules_imported_by(&self, llvm_module_name: &str) -> &[String] { self.imports.get(llvm_module_name).map(|v| &v[..]).unwrap_or(&[]) } @@ -907,9 +904,7 @@ .unwrap() .push(imported_module_name.to_owned()); } - let mut map = ThinLTOImports { - imports: FxHashMap(), - }; + let mut map = ThinLTOImports::default(); llvm::LLVMRustGetThinLTOModuleImports(data, imported_module_callback, &mut map as *mut _ as *mut libc::c_void); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/back/rpath.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/back/rpath.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/back/rpath.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/back/rpath.rs 2018-12-04 23:41:40.000000000 +0000 @@ -109,7 +109,7 @@ }; let cwd = env::current_dir().unwrap(); - let mut lib = fs::canonicalize(&cwd.join(lib)).unwrap_or(cwd.join(lib)); + let mut lib = fs::canonicalize(&cwd.join(lib)).unwrap_or_else(|_| cwd.join(lib)); lib.pop(); let mut output = cwd.join(&config.out_filename); output.pop(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/back/write.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/back/write.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/back/write.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/back/write.rs 2018-12-04 23:41:40.000000000 +0000 @@ -21,6 +21,7 @@ use rustc_incremental::{copy_cgu_workproducts_to_incr_comp_cache_dir, in_incr_comp_dir, in_incr_comp_dir_sess}; use rustc::dep_graph::{WorkProduct, WorkProductId, WorkProductFileKind}; +use rustc::dep_graph::cgu_reuse_tracker::CguReuseTracker; use rustc::middle::cstore::EncodedMetadata; use rustc::session::config::{self, OutputFilenames, OutputType, Passes, Sanitizer, Lto}; use rustc::session::Session; @@ -195,6 +196,7 @@ let features = CString::new(features).unwrap(); let is_pie_binary = !find_features && is_pie_binary(sess); let trap_unreachable = sess.target.target.options.trap_unreachable; + let emit_stack_size_section = sess.opts.debugging_opts.emit_stack_sizes; let asm_comments = sess.asm_comments(); @@ -212,6 +214,7 @@ trap_unreachable, singlethread, asm_comments, + emit_stack_size_section, ) }; @@ -377,6 +380,8 @@ // The incremental compilation session directory, or None if we are not // compiling incrementally pub incr_comp_session_dir: Option, + // Used to update CGU re-use information during the thinlto phase. + pub cgu_reuse_tracker: CguReuseTracker, // Channel back to the main control thread to send messages to coordinator_send: Sender>, // A reference to the TimeGraph so we can register timings. None means that @@ -1535,7 +1540,7 @@ // Compute the set of symbols we need to retain when doing LTO (if we need to) let exported_symbols = { - let mut exported_symbols = FxHashMap(); + let mut exported_symbols = FxHashMap::default(); let copy_symbols = |cnum| { let symbols = tcx.exported_symbols(cnum) @@ -1607,6 +1612,7 @@ remark: sess.opts.cg.remark.clone(), worker: 0, incr_comp_session_dir: sess.incr_comp_session_dir_opt().map(|r| r.clone()), + cgu_reuse_tracker: sess.cgu_reuse_tracker.clone(), coordinator_send, diag_emitter: shared_emitter.clone(), time_graph, @@ -2025,9 +2031,7 @@ main_thread_worker_state = MainThreadWorkerState::Idle; } Message::Done { result: Err(()), worker_id: _ } => { - shared_emitter.fatal("aborting due to worker thread failure"); - // Exit the coordinator thread - return Err(()) + bug!("worker thread panicked"); } Message::CodegenItem => { bug!("the coordinator should not receive codegen requests") @@ -2386,10 +2390,12 @@ panic!("expected abort due to worker thread errors") }, Err(_) => { - sess.fatal("Error during codegen/LLVM phase."); + bug!("panic during codegen/LLVM phase"); } }; + sess.cgu_reuse_tracker.check_expected_reuse(sess); + sess.abort_if_errors(); if let Some(time_graph) = self.time_graph { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/base.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/base.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/base.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/base.rs 2018-12-04 23:41:40.000000000 +0000 @@ -32,6 +32,7 @@ use back::write::{self, OngoingCodegen}; use llvm::{self, TypeKind, get_param}; use metadata; +use rustc::dep_graph::cgu_reuse_tracker::CguReuse; use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; use rustc::middle::lang_items::StartFnLangItem; use rustc::middle::weak_lang_items; @@ -69,7 +70,7 @@ use mono_item::{MonoItem, BaseMonoItemExt, MonoItemExt}; use type_::Type; use type_of::LayoutLlvmExt; -use rustc::util::nodemap::{FxHashMap, FxHashSet, DefIdSet}; +use rustc::util::nodemap::{FxHashMap, DefIdSet}; use CrateInfo; use rustc_data_structures::small_c_str::SmallCStr; use rustc_data_structures::sync::Lrc; @@ -212,8 +213,8 @@ vtable_ptr.llvm_type(cx)) } _ => bug!("unsized_info: invalid unsizing {:?} -> {:?}", - source, - target), + source, + target), } } @@ -339,11 +340,11 @@ } fn cast_shift_rhs<'ll, F, G>(op: hir::BinOpKind, - lhs: &'ll Value, - rhs: &'ll Value, - trunc: F, - zext: G) - -> &'ll Value + lhs: &'ll Value, + rhs: &'ll Value, + trunc: F, + zext: G) + -> &'ll Value where F: FnOnce(&'ll Value, &'ll Type) -> &'ll Value, G: FnOnce(&'ll Value, &'ll Type) -> &'ll Value { @@ -362,8 +363,8 @@ if lhs_sz < rhs_sz { trunc(rhs, lhs_llty) } else if lhs_sz > rhs_sz { - // FIXME (#1877: If shifting by negative - // values becomes not undefined then this is wrong. + // FIXME (#1877: If in the future shifting by negative + // values is no longer undefined then this is wrong. zext(rhs, lhs_llty) } else { rhs @@ -494,10 +495,8 @@ let sig = common::ty_fn_sig(cx, fn_ty); let sig = cx.tcx.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), &sig); - let lldecl = match cx.instances.borrow().get(&instance) { - Some(&val) => val, - None => bug!("Instance `{:?}` not already declared", instance) - }; + let lldecl = cx.instances.borrow().get(&instance).cloned().unwrap_or_else(|| + bug!("Instance `{:?}` not already declared", instance)); cx.stats.borrow_mut().n_closures += 1; @@ -565,8 +564,8 @@ if declare::get_defined_value(cx, "main").is_some() { // FIXME: We should be smart and show a better diagnostic here. cx.sess().struct_span_err(sp, "entry symbol `main` defined multiple times") - .help("did you use #[no_mangle] on `fn main`? Use #[start] instead") - .emit(); + .help("did you use #[no_mangle] on `fn main`? Use #[start] instead") + .emit(); cx.sess().abort_if_errors(); bug!(); } @@ -697,25 +696,18 @@ } } -#[derive(Debug)] -enum CguReUsable { - PreLto, - PostLto, - No -} - fn determine_cgu_reuse<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, cgu: &CodegenUnit<'tcx>) - -> CguReUsable { + -> CguReuse { if !tcx.dep_graph.is_fully_enabled() { - return CguReUsable::No + return CguReuse::No } let work_product_id = &cgu.work_product_id(); if tcx.dep_graph.previous_work_product(work_product_id).is_none() { // We don't have anything cached for this CGU. This can happen // if the CGU did not exist in the previous session. - return CguReUsable::No + return CguReuse::No } // Try to mark the CGU as green. If it we can do so, it means that nothing @@ -732,19 +724,19 @@ if tcx.dep_graph.try_mark_green(tcx, &dep_node).is_some() { // We can re-use either the pre- or the post-thinlto state if tcx.sess.lto() != Lto::No { - CguReUsable::PreLto + CguReuse::PreLto } else { - CguReUsable::PostLto + CguReuse::PostLto } } else { - CguReUsable::No + CguReuse::No } } pub fn codegen_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - rx: mpsc::Receiver>) - -> OngoingCodegen { - + rx: mpsc::Receiver>) + -> OngoingCodegen +{ check_for_rustc_errors_attr(tcx); if let Some(true) = tcx.sess.opts.debugging_opts.thinlto { @@ -792,7 +784,7 @@ !tcx.sess.opts.output_types.should_codegen() { let ongoing_codegen = write::start_async_codegen( tcx, - time_graph.clone(), + time_graph, metadata, rx, 1); @@ -809,8 +801,7 @@ // Run the monomorphization collector and partition the collected items into // codegen units. - let codegen_units = - tcx.collect_and_partition_mono_items(LOCAL_CRATE).1; + let codegen_units = tcx.collect_and_partition_mono_items(LOCAL_CRATE).1; let codegen_units = (*codegen_units).clone(); // Force all codegen_unit queries so they are already either red or green @@ -843,12 +834,7 @@ .iter() .any(|(_, list)| { use rustc::middle::dependency_format::Linkage; - list.iter().any(|linkage| { - match linkage { - Linkage::Dynamic => true, - _ => false, - } - }) + list.iter().any(|&linkage| linkage == Linkage::Dynamic) }); let allocator_module = if any_dynamic_crate { None @@ -894,8 +880,11 @@ ongoing_codegen.wait_for_signal_to_codegen_item(); ongoing_codegen.check_for_errors(tcx.sess); - let loaded_from_cache = match determine_cgu_reuse(tcx, &cgu) { - CguReUsable::No => { + let cgu_reuse = determine_cgu_reuse(tcx, &cgu); + tcx.sess.cgu_reuse_tracker.set_actual_reuse(&cgu.name().as_str(), cgu_reuse); + + match cgu_reuse { + CguReuse::No => { let _timing_guard = time_graph.as_ref().map(|time_graph| { time_graph.start(write::CODEGEN_WORKER_TIMELINE, write::CODEGEN_WORK_PACKAGE_KIND, @@ -907,14 +896,14 @@ total_codegen_time += start_time.elapsed(); false } - CguReUsable::PreLto => { + CguReuse::PreLto => { write::submit_pre_lto_module_to_llvm(tcx, CachedModuleCodegen { name: cgu.name().to_string(), source: cgu.work_product(tcx), }); true } - CguReUsable::PostLto => { + CguReuse::PostLto => { write::submit_post_lto_module_to_llvm(tcx, CachedModuleCodegen { name: cgu.name().to_string(), source: cgu.work_product(tcx), @@ -922,12 +911,6 @@ true } }; - - if tcx.dep_graph.is_fully_enabled() { - let dep_node = cgu.codegen_dep_node(tcx); - let dep_node_index = tcx.dep_graph.dep_node_index_of(&dep_node); - tcx.dep_graph.mark_loaded_from_cache(dep_node_index, loaded_from_cache); - } } ongoing_codegen.codegen_finished(tcx); @@ -938,9 +921,7 @@ "codegen to LLVM IR", total_codegen_time); - if tcx.sess.opts.incremental.is_some() { - ::rustc_incremental::assert_module_sources::assert_module_sources(tcx); - } + rustc_incremental::assert_module_sources::assert_module_sources(tcx); symbol_names_test::report_symbol_names(tcx); @@ -999,7 +980,7 @@ if mode_string != "lazy" { let message = format!("Unknown codegen-item collection mode '{}'. \ Falling back to 'lazy' mode.", - mode_string); + mode_string); tcx.sess.warn(&message); } @@ -1049,7 +1030,7 @@ }).collect(); if tcx.sess.opts.debugging_opts.print_mono_items.is_some() { - let mut item_to_cgus: FxHashMap<_, Vec<_>> = FxHashMap(); + let mut item_to_cgus: FxHashMap<_, Vec<_>> = Default::default(); for cgu in &codegen_units { for (&mono_item, &linkage) in cgu.items() { @@ -1111,17 +1092,17 @@ compiler_builtins: None, profiler_runtime: None, sanitizer_runtime: None, - is_no_builtins: FxHashSet(), - native_libraries: FxHashMap(), + is_no_builtins: Default::default(), + native_libraries: Default::default(), used_libraries: tcx.native_libraries(LOCAL_CRATE), link_args: tcx.link_args(LOCAL_CRATE), - crate_name: FxHashMap(), + crate_name: Default::default(), used_crates_dynamic: cstore::used_crates(tcx, LinkagePreference::RequireDynamic), used_crates_static: cstore::used_crates(tcx, LinkagePreference::RequireStatic), - used_crate_source: FxHashMap(), - wasm_imports: FxHashMap(), - lang_item_to_crate: FxHashMap(), - missing_lang_items: FxHashMap(), + used_crate_source: Default::default(), + wasm_imports: Default::default(), + lang_item_to_crate: Default::default(), + missing_lang_items: Default::default(), }; let lang_items = tcx.lang_items(); @@ -1134,7 +1115,15 @@ info.load_wasm_imports(tcx, LOCAL_CRATE); } - for &cnum in tcx.crates().iter() { + let crates = tcx.crates(); + + let n_crates = crates.len(); + info.native_libraries.reserve(n_crates); + info.crate_name.reserve(n_crates); + info.used_crate_source.reserve(n_crates); + info.missing_lang_items.reserve(n_crates); + + for &cnum in crates.iter() { info.native_libraries.insert(cnum, tcx.native_libraries(cnum)); info.crate_name.insert(cnum, tcx.crate_name(cnum).to_string()); info.used_crate_source.insert(cnum, tcx.used_crate_source(cnum)); @@ -1176,11 +1165,12 @@ } fn load_wasm_imports(&mut self, tcx: TyCtxt, cnum: CrateNum) { - for (&id, module) in tcx.wasm_import_module_map(cnum).iter() { + self.wasm_imports.extend(tcx.wasm_import_module_map(cnum).iter().map(|(&id, module)| { let instance = Instance::mono(tcx, id); let import_name = tcx.symbol_name(instance); - self.wasm_imports.insert(import_name.to_string(), module.clone()); - } + + (import_name.to_string(), module.clone()) + })); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/builder.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/builder.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/builder.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/builder.rs 2018-12-04 23:41:40.000000000 +0000 @@ -110,10 +110,10 @@ } if self.cx.sess().count_llvm_insns() { *self.cx.stats - .borrow_mut() - .llvm_insns - .entry(category.to_string()) - .or_insert(0) += 1; + .borrow_mut() + .llvm_insns + .entry(category.to_string()) + .or_insert(0) += 1; } } @@ -735,9 +735,9 @@ } pub fn inline_asm_call(&self, asm: *const c_char, cons: *const c_char, - inputs: &[&'ll Value], output: &'ll Type, - volatile: bool, alignstack: bool, - dia: AsmDialect) -> &'ll Value { + inputs: &[&'ll Value], output: &'ll Type, + volatile: bool, alignstack: bool, + dia: AsmDialect) -> Option<&'ll Value> { self.count_insn("inlineasm"); let volatile = if volatile { llvm::True } @@ -753,9 +753,17 @@ debug!("Asm Output Type: {:?}", output); let fty = Type::func(&argtys[..], output); unsafe { - let v = llvm::LLVMRustInlineAsm( - fty, asm, cons, volatile, alignstack, dia); - self.call(v, inputs, None) + // Ask LLVM to verify that the constraints are well-formed. + let constraints_ok = llvm::LLVMRustInlineAsmVerify(fty, cons); + debug!("Constraint verification result: {:?}", constraints_ok); + if constraints_ok { + let v = llvm::LLVMRustInlineAsm( + fty, asm, cons, volatile, alignstack, dia); + Some(self.call(v, inputs, None)) + } else { + // LLVM has detected an issue with our constraints, bail out + None + } } } @@ -1085,7 +1093,7 @@ ) -> &'ll Value { unsafe { llvm::LLVMRustBuildAtomicCmpXchg(self.llbuilder, dst, cmp, src, - order, failure_order, weak) + order, failure_order, weak) } } pub fn atomic_rmw( @@ -1186,7 +1194,7 @@ }) .collect(); - return Cow::Owned(casted_args); + Cow::Owned(casted_args) } pub fn lifetime_start(&self, ptr: &'ll Value, size: Size) { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/common.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/common.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/common.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/common.rs 2018-12-04 23:41:40.000000000 +0000 @@ -336,16 +336,13 @@ msg: &str, li: LangItem) -> DefId { - match tcx.lang_items().require(li) { - Ok(id) => id, - Err(s) => { - let msg = format!("{} {}", msg, s); - match span { - Some(span) => tcx.sess.span_fatal(span, &msg[..]), - None => tcx.sess.fatal(&msg[..]), - } + tcx.lang_items().require(li).unwrap_or_else(|s| { + let msg = format!("{} {}", msg, s); + match span { + Some(span) => tcx.sess.span_fatal(span, &msg[..]), + None => tcx.sess.fatal(&msg[..]), } - } + }) } // To avoid UB from LLVM, these two functions mask RHS with an diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/consts.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/consts.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/consts.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/consts.rs 2018-12-04 23:41:40.000000000 +0000 @@ -124,7 +124,7 @@ assert!(!defined_in_current_codegen_unit, "consts::get_static() should always hit the cache for \ statics defined in the same CGU, but did not for `{:?}`", - def_id); + def_id); let ty = instance.ty(cx.tcx); let sym = cx.tcx.symbol_name(instance).as_str(); @@ -249,14 +249,13 @@ // extern "C" fn() from being non-null, so we can't just declare a // static and call it a day. Some linkages (like weak) will make it such // that the static actually has a null value. - let llty2 = match ty.sty { - ty::RawPtr(ref mt) => cx.layout_of(mt.ty).llvm_type(cx), - _ => { - if span.is_some() { - cx.sess().span_fatal(span.unwrap(), "must have type `*const T` or `*mut T`") - } else { - bug!("must have type `*const T` or `*mut T`") - } + let llty2 = if let ty::RawPtr(ref mt) = ty.sty { + cx.layout_of(mt.ty).llvm_type(cx) + } else { + if let Some(span) = span { + cx.sess().span_fatal(span, "must have type `*const T` or `*mut T`") + } else { + bug!("must have type `*const T` or `*mut T`") } }; unsafe { @@ -273,9 +272,9 @@ let mut real_name = "_rust_extern_with_linkage_".to_string(); real_name.push_str(&sym); let g2 = declare::define_global(cx, &real_name, llty).unwrap_or_else(||{ - if span.is_some() { + if let Some(span) = span { cx.sess().span_fatal( - span.unwrap(), + span, &format!("symbol `{}` is already defined", &sym) ) } else { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/context.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/context.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/context.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/context.rs 2018-12-04 23:41:40.000000000 +0000 @@ -59,8 +59,8 @@ /// Cache instances of monomorphic and polymorphic items pub instances: RefCell, &'a Value>>, /// Cache generated vtables - pub vtables: RefCell, - Option>), &'a Value>>, + pub vtables: RefCell, ty::PolyExistentialTraitRef<'tcx>), + &'a Value>>, /// Cache of constant strings, pub const_cstr_cache: RefCell>, @@ -208,14 +208,21 @@ llvm::LLVMRustSetModulePIELevel(llmod); } + // If skipping the PLT is enabled, we need to add some module metadata + // to ensure intrinsic calls don't use it. + if !sess.needs_plt() { + let avoid_plt = "RtLibUseGOT\0".as_ptr() as *const _; + llvm::LLVMRustAddModuleFlag(llmod, avoid_plt, 1); + } + llmod } impl<'a, 'tcx> CodegenCx<'a, 'tcx> { crate fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, - codegen_unit: Arc>, - llvm_module: &'a ::ModuleLlvm) - -> CodegenCx<'a, 'tcx> { + codegen_unit: Arc>, + llvm_module: &'a ::ModuleLlvm) + -> CodegenCx<'a, 'tcx> { // An interesting part of Windows which MSVC forces our hand on (and // apparently MinGW didn't) is the usage of `dllimport` and `dllexport` // attributes in LLVM IR as well as native dependencies (in C these @@ -270,8 +277,8 @@ let dbg_cx = if tcx.sess.opts.debuginfo != DebugInfo::None { let dctx = debuginfo::CrateDebugContext::new(llmod); debuginfo::metadata::compile_unit_metadata(tcx, - &codegen_unit.name().as_str(), - &dctx); + &codegen_unit.name().as_str(), + &dctx); Some(dctx) } else { None @@ -288,22 +295,22 @@ llcx, stats: RefCell::new(Stats::default()), codegen_unit, - instances: RefCell::new(FxHashMap()), - vtables: RefCell::new(FxHashMap()), - const_cstr_cache: RefCell::new(FxHashMap()), - const_unsized: RefCell::new(FxHashMap()), - const_globals: RefCell::new(FxHashMap()), + instances: Default::default(), + vtables: Default::default(), + const_cstr_cache: Default::default(), + const_unsized: Default::default(), + const_globals: Default::default(), statics_to_rauw: RefCell::new(Vec::new()), used_statics: RefCell::new(Vec::new()), - lltypes: RefCell::new(FxHashMap()), - scalar_lltypes: RefCell::new(FxHashMap()), - pointee_infos: RefCell::new(FxHashMap()), + lltypes: Default::default(), + scalar_lltypes: Default::default(), + pointee_infos: Default::default(), isize_ty, dbg_cx, eh_personality: Cell::new(None), eh_unwind_resume: Cell::new(None), rust_try_fn: Cell::new(None), - intrinsics: RefCell::new(FxHashMap()), + intrinsics: Default::default(), local_gen_sym_counter: Cell::new(0), } } @@ -318,10 +325,8 @@ if let Some(v) = self.intrinsics.borrow().get(key).cloned() { return v; } - match declare_intrinsic(self, key) { - Some(v) => return v, - None => bug!("unknown intrinsic '{}'", key) - } + + declare_intrinsic(self, key).unwrap_or_else(|| bug!("unknown intrinsic '{}'", key)) } /// Generate a new symbol name with the given prefix. This symbol name must @@ -465,9 +470,10 @@ fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout { self.tcx.layout_of(ty::ParamEnv::reveal_all().and(ty)) - .unwrap_or_else(|e| match e { - LayoutError::SizeOverflow(_) => self.sess().fatal(&e.to_string()), - _ => bug!("failed to get layout for `{}`: {}", ty, e) + .unwrap_or_else(|e| if let LayoutError::SizeOverflow(_) = e { + self.sess().fatal(&e.to_string()) + } else { + bug!("failed to get layout for `{}`: {}", ty, e) }) } } @@ -772,5 +778,6 @@ ifn!("llvm.dbg.declare", fn(Type::metadata(cx), Type::metadata(cx)) -> void); ifn!("llvm.dbg.value", fn(Type::metadata(cx), t_i64, Type::metadata(cx)) -> void); } - return None; + + None } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs 2018-12-04 23:41:40.000000000 +0000 @@ -21,7 +21,7 @@ use syntax_pos::Pos; -use rustc_data_structures::bitvec::BitArray; +use rustc_data_structures::bit_set::BitSet; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use syntax_pos::BytePos; @@ -37,7 +37,7 @@ impl MirDebugScope<'ll> { pub fn is_valid(&self) -> bool { - !self.scope_metadata.is_none() + self.scope_metadata.is_some() } } @@ -64,7 +64,7 @@ }; // Find all the scopes with variables defined in them. - let mut has_variables = BitArray::new(mir.source_scopes.len()); + let mut has_variables = BitSet::new_empty(mir.source_scopes.len()); for var in mir.vars_iter() { let decl = &mir.local_decls[var]; has_variables.insert(decl.visibility_scope); @@ -81,7 +81,7 @@ fn make_mir_scope(cx: &CodegenCx<'ll, '_>, mir: &Mir, - has_variables: &BitArray, + has_variables: &BitSet, debug_context: &FunctionDebugContextData<'ll>, scope: SourceScope, scopes: &mut IndexVec>) { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/debuginfo/metadata.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/debuginfo/metadata.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/debuginfo/metadata.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/debuginfo/metadata.rs 2018-12-04 23:41:40.000000000 +0000 @@ -96,6 +96,7 @@ // created so far. The metadata nodes are indexed by UniqueTypeId, and, for // faster lookup, also by Ty. The TypeMap is responsible for creating // UniqueTypeIds. +#[derive(Default)] pub struct TypeMap<'ll, 'tcx> { // The UniqueTypeIds created so far unique_id_interner: Interner, @@ -108,15 +109,6 @@ } impl TypeMap<'ll, 'tcx> { - pub fn new() -> Self { - TypeMap { - unique_id_interner: Interner::new(), - type_to_metadata: FxHashMap(), - unique_id_to_metadata: FxHashMap(), - type_to_unique_id: FxHashMap(), - } - } - // Adds a Ty to metadata mapping to the TypeMap. The method will fail if // the mapping already exists. fn register_type_with_metadata( @@ -163,10 +155,10 @@ fn get_unique_type_id_of_type<'a>(&mut self, cx: &CodegenCx<'a, 'tcx>, type_: Ty<'tcx>) -> UniqueTypeId { // Let's see if we already have something in the cache - match self.type_to_unique_id.get(&type_).cloned() { - Some(unique_type_id) => return unique_type_id, - None => { /* generate one */} - }; + if let Some(unique_type_id) = self.type_to_unique_id.get(&type_).cloned() { + return unique_type_id; + } + // if not, generate one // The hasher we are using to generate the UniqueTypeId. We want // something that provides more than the 64 bits of the DefaultHasher. @@ -286,11 +278,11 @@ // unique id can be found in the type map macro_rules! return_if_metadata_created_in_meantime { ($cx: expr, $unique_type_id: expr) => ( - match debug_context($cx).type_map - .borrow() - .find_metadata_for_unique_id($unique_type_id) { - Some(metadata) => return MetadataCreationResult::new(metadata, true), - None => { /* proceed normally */ } + if let Some(metadata) = debug_context($cx).type_map + .borrow() + .find_metadata_for_unique_id($unique_type_id) + { + return MetadataCreationResult::new(metadata, true); } ) } @@ -352,7 +344,7 @@ let member_descriptions = vec![ MemberDescription { - name: "data_ptr".to_string(), + name: "data_ptr".to_owned(), type_metadata: data_ptr_metadata, offset: Size::ZERO, size: pointer_size, @@ -360,7 +352,7 @@ flags: DIFlags::FlagZero, }, MemberDescription { - name: "length".to_string(), + name: "length".to_owned(), type_metadata: type_metadata(cx, cx.tcx.types.usize, span), offset: pointer_size, size: usize_size, @@ -435,12 +427,7 @@ // But it does not describe the trait's methods. let containing_scope = match trait_type.sty { - ty::Dynamic(ref data, ..) => if let Some(principal) = data.principal() { - let def_id = principal.def_id(); - Some(get_namespace_for_item(cx, def_id)) - } else { - NO_SCOPE_METADATA - }, + ty::Dynamic(ref data, ..) => Some(get_namespace_for_item(cx, data.principal().def_id())), _ => { bug!("debuginfo: Unexpected trait-object type in \ trait_pointer_metadata(): {:?}", @@ -463,7 +450,7 @@ let vtable_field = layout.field(cx, 1); let member_descriptions = vec![ MemberDescription { - name: "pointer".to_string(), + name: "pointer".to_owned(), type_metadata: type_metadata(cx, cx.tcx.mk_mut_ptr(cx.tcx.types.u8), syntax_pos::DUMMY_SP), @@ -473,7 +460,7 @@ flags: DIFlags::FlagArtificial, }, MemberDescription { - name: "vtable".to_string(), + name: "vtable".to_owned(), type_metadata: type_metadata(cx, vtable_field.ty, syntax_pos::DUMMY_SP), offset: layout.fields.offset(1), size: vtable_field.size, @@ -548,12 +535,12 @@ _ => { let pointee_metadata = type_metadata(cx, ty, usage_site_span); - match debug_context(cx).type_map - .borrow() - .find_metadata_for_unique_id(unique_type_id) { - Some(metadata) => return Err(metadata), - None => { /* proceed normally */ } - }; + if let Some(metadata) = debug_context(cx).type_map + .borrow() + .find_metadata_for_unique_id(unique_type_id) + { + return Err(metadata); + } Ok(MetadataCreationResult::new(pointer_type_metadata(cx, t, pointee_metadata), false)) @@ -582,12 +569,12 @@ } ty::Dynamic(..) => { MetadataCreationResult::new( - trait_pointer_metadata(cx, t, None, unique_type_id), - false) + trait_pointer_metadata(cx, t, None, unique_type_id), + false) } ty::Foreign(..) => { MetadataCreationResult::new( - foreign_type_metadata(cx, t, unique_type_id), + foreign_type_metadata(cx, t, unique_type_id), false) } ty::RawPtr(ty::TypeAndMut{ty, ..}) | @@ -608,12 +595,12 @@ unique_type_id, t.fn_sig(cx.tcx), usage_site_span).metadata; - match debug_context(cx).type_map - .borrow() - .find_metadata_for_unique_id(unique_type_id) { - Some(metadata) => return metadata, - None => { /* proceed normally */ } - }; + if let Some(metadata) = debug_context(cx).type_map + .borrow() + .find_metadata_for_unique_id(unique_type_id) + { + return metadata; + } // This is actually a function pointer, so wrap it in pointer DI MetadataCreationResult::new(pointer_type_metadata(cx, t, fn_metadata), false) @@ -646,16 +633,16 @@ } AdtKind::Union => { prepare_union_metadata(cx, - t, - unique_type_id, - usage_site_span).finalize(cx) + t, + unique_type_id, + usage_site_span).finalize(cx) } AdtKind::Enum => { prepare_enum_metadata(cx, - t, - def.did, - unique_type_id, - usage_site_span).finalize(cx) + t, + def.did, + unique_type_id, + usage_site_span).finalize(cx) } }, ty::Tuple(ref elements) => { @@ -943,7 +930,7 @@ impl MemberDescriptionFactory<'ll, 'tcx> { fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>) - -> Vec> { + -> Vec> { match *self { StructMDF(ref this) => { this.create_member_descriptions(cx) @@ -977,7 +964,7 @@ impl<'tcx> StructMemberDescriptionFactory<'tcx> { fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>) - -> Vec> { + -> Vec> { let layout = cx.layout_of(self.ty); self.variant.fields.iter().enumerate().map(|(i, f)| { let name = if self.variant.ctor_kind == CtorKind::Fn { @@ -1047,7 +1034,7 @@ impl<'tcx> TupleMemberDescriptionFactory<'tcx> { fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>) - -> Vec> { + -> Vec> { let layout = cx.layout_of(self.ty); self.component_types.iter().enumerate().map(|(i, &component_type)| { let (size, align) = cx.size_and_align_of(component_type); @@ -1101,7 +1088,7 @@ impl<'tcx> UnionMemberDescriptionFactory<'tcx> { fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>) - -> Vec> { + -> Vec> { self.variant.fields.iter().enumerate().map(|(i, f)| { let field = self.layout.field(cx, i); let (size, align) = field.size_and_align(); @@ -1170,7 +1157,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>) - -> Vec> { + -> Vec> { let adt = &self.enum_type.ty_adt_def().unwrap(); match self.layout.variants { layout::Variants::Single { .. } if adt.variants.is_empty() => vec![], @@ -1362,7 +1349,7 @@ // We have the layout of an enum variant, we need the layout of the outer enum let enum_layout = cx.layout_of(layout.ty); (Some(enum_layout.fields.offset(0)), - Some(("RUST$ENUM$DISR".to_string(), enum_layout.field(cx, 0).ty))) + Some(("RUST$ENUM$DISR".to_owned(), enum_layout.field(cx, 0).ty))) } _ => (None, None), }; @@ -1476,9 +1463,8 @@ } }; - match (&layout.abi, discriminant_type_metadata) { - (&layout::Abi::Scalar(_), Some(discr)) => return FinalMetadata(discr), - _ => {} + if let (&layout::Abi::Scalar(_), Some(discr)) = (&layout.abi, discriminant_type_metadata) { + return FinalMetadata(discr); } let (enum_type_size, enum_type_align) = layout.size_and_align(); @@ -1551,7 +1537,7 @@ composite_type_metadata, member_descriptions); - return composite_type_metadata; + composite_type_metadata } fn set_members_of_composite_type(cx: &CodegenCx<'ll, '_>, @@ -1639,7 +1625,7 @@ unique_type_id.as_ptr()) }; - return metadata_stub; + metadata_stub } fn create_union_stub( @@ -1675,7 +1661,7 @@ unique_type_id.as_ptr()) }; - return metadata_stub; + metadata_stub } /// Creates debug information for the given global variable. @@ -1803,13 +1789,7 @@ llvm::LLVMRustDIBuilderCreateStaticVariable(DIB(cx), NO_SCOPE_METADATA, name.as_ptr(), - // LLVM 3.9 - // doesn't accept - // null here, so - // pass the name - // as the linkage - // name. - name.as_ptr(), + ptr::null(), unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER, vtable_type, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/debuginfo/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/debuginfo/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/debuginfo/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/debuginfo/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -100,11 +100,11 @@ llcontext, llmod, builder, - created_files: RefCell::new(FxHashMap()), - created_enum_disr_types: RefCell::new(FxHashMap()), - type_map: RefCell::new(TypeMap::new()), + created_files: Default::default(), + created_enum_disr_types: Default::default(), + type_map: Default::default(), namespace_map: RefCell::new(DefIdMap()), - composite_types_completed: RefCell::new(FxHashSet()), + composite_types_completed: Default::default(), } } } @@ -271,16 +271,14 @@ let mut flags = DIFlags::FlagPrototyped; let local_id = cx.tcx.hir.as_local_node_id(def_id); - match *cx.sess().entry_fn.borrow() { - Some((id, _, _)) => { - if local_id == Some(id) { - flags = flags | DIFlags::FlagMainSubprogram; - } + if let Some((id, _, _)) = *cx.sess().entry_fn.borrow() { + if local_id == Some(id) { + flags |= DIFlags::FlagMainSubprogram; } - None => {} - }; - if cx.layout_of(sig.output()).abi == ty::layout::Abi::Uninhabited { - flags = flags | DIFlags::FlagNoReturn; + } + + if cx.layout_of(sig.output()).abi.is_uninhabited() { + flags |= DIFlags::FlagNoReturn; } let fn_metadata = unsafe { @@ -371,7 +369,7 @@ } } - return create_DIArray(DIB(cx), &signature[..]); + create_DIArray(DIB(cx), &signature[..]) } fn get_template_parameters( @@ -428,7 +426,7 @@ vec![] }; - return create_DIArray(DIB(cx), &template_params[..]); + create_DIArray(DIB(cx), &template_params[..]) } fn get_parameter_names(cx: &CodegenCx, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/debuginfo/source_loc.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/debuginfo/source_loc.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/debuginfo/source_loc.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/debuginfo/source_loc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -56,11 +56,8 @@ /// switches source location emitting on and must therefore be called before the /// first real statement/expression of the function is codegened. pub fn start_emitting_source_locations(dbg_context: &FunctionDebugContext<'ll>) { - match *dbg_context { - FunctionDebugContext::RegularContext(ref data) => { - data.source_locations_enabled.set(true) - }, - _ => { /* safe to ignore */ } + if let FunctionDebugContext::RegularContext(ref data) = *dbg_context { + data.source_locations_enabled.set(true); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/debuginfo/type_names.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/debuginfo/type_names.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/debuginfo/type_names.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/debuginfo/type_names.rs 2018-12-04 23:41:40.000000000 +0000 @@ -116,14 +116,12 @@ } }, ty::Dynamic(ref trait_data, ..) => { - if let Some(principal) = trait_data.principal() { - let principal = cx.tcx.normalize_erasing_late_bound_regions( - ty::ParamEnv::reveal_all(), - &principal, - ); - push_item_name(cx, principal.def_id, false, output); - push_type_params(cx, principal.substs, output); - } + let principal = cx.tcx.normalize_erasing_late_bound_regions( + ty::ParamEnv::reveal_all(), + &trait_data.principal(), + ); + push_item_name(cx, principal.def_id, false, output); + push_type_params(cx, principal.substs, output); }, ty::FnDef(..) | ty::FnPtr(_) => { let sig = t.fn_sig(cx.tcx); @@ -173,12 +171,13 @@ } ty::Error | ty::Infer(_) | + ty::UnnormalizedProjection(..) | ty::Projection(..) | ty::Opaque(..) | ty::GeneratorWitness(..) | ty::Param(_) => { bug!("debuginfo: Trying to create type name for \ - unexpected type: {:?}", t); + unexpected type: {:?}", t); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/declare.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/declare.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/declare.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/declare.rs 2018-12-04 23:41:40.000000000 +0000 @@ -23,7 +23,7 @@ use llvm; use llvm::AttributePlace::Function; use rustc::ty::{self, Ty}; -use rustc::ty::layout::{self, LayoutOf}; +use rustc::ty::layout::LayoutOf; use rustc::session::config::Sanitizer; use rustc_data_structures::small_c_str::SmallCStr; use rustc_target::spec::PanicStrategy; @@ -104,6 +104,8 @@ attributes::unwind(llfn, false); } + attributes::non_lazy_bind(cx.sess(), llfn); + llfn } @@ -137,7 +139,7 @@ let fty = FnType::new(cx, sig, &[]); let llfn = declare_raw_fn(cx, name, fty.llvm_cconv(), fty.llvm_type(cx)); - if cx.layout_of(sig.output()).abi == layout::Abi::Uninhabited { + if cx.layout_of(sig.output()).abi.is_uninhabited() { llvm::Attribute::NoReturn.apply_llfn(Function, llfn); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/diagnostics.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/diagnostics.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/diagnostics.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/diagnostics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -47,4 +47,37 @@ ``` "##, +E0668: r##" +Malformed inline assembly rejected by LLVM. + +LLVM checks the validity of the constraints and the assembly string passed to +it. This error implies that LLVM seems something wrong with the inline +assembly call. + +In particular, it can happen if you forgot the closing bracket of a register +constraint (see issue #51430): +```ignore (error-emitted-at-codegen-which-cannot-be-handled-by-compile_fail) +#![feature(asm)] + +fn main() { + let rax: u64; + unsafe { + asm!("" :"={rax"(rax)); + println!("Accumulator is: {}", rax); + } +} +``` +"##, + +E0669: r##" +Cannot convert inline assembly operand to a single LLVM value. + +This error usually happens when trying to pass in a value to an input inline +assembly operand that is actually a pair of values. In particular, this can +happen when trying to pass in a slice, for instance a `&str`. In Rust, these +values are represented internally as a pair of values, the pointer and its +length. When passed as an input operand, this pair of values can not be +coerced into a register and thus we must fail with an error. +"##, + } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/glue.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/glue.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/glue.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/glue.rs 2018-12-04 23:41:40.000000000 +0000 @@ -97,8 +97,8 @@ C_usize(cx, std::cmp::max(sized_align, unsized_align) as u64) } _ => bx.select(bx.icmp(llvm::IntUGT, sized_align, unsized_align), - sized_align, - unsized_align) + sized_align, + unsized_align) }; // Issue #27023: must add any necessary padding to `size` diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/intrinsic.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/intrinsic.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/intrinsic.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/intrinsic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -115,8 +115,8 @@ let llval = match name { _ if simple.is_some() => { bx.call(simple.unwrap(), - &args.iter().map(|arg| arg.immediate()).collect::>(), - None) + &args.iter().map(|arg| arg.immediate()).collect::>(), + None) } "unreachable" => { return; @@ -373,7 +373,6 @@ return; } } - }, "fadd_fast" | "fsub_fast" | "fmul_fast" | "fdiv_fast" | "frem_fast" => { let sty = &arg_tys[0].sty; @@ -540,10 +539,9 @@ } _ => { - let intr = match Intrinsic::find(&name) { - Some(intr) => intr, - None => bug!("unknown intrinsic '{}'", name), - }; + let intr = Intrinsic::find(&name).unwrap_or_else(|| + bug!("unknown intrinsic '{}'", name)); + fn one(x: Vec) -> T { assert_eq!(x.len(), 1); x.into_iter().next().unwrap() @@ -822,8 +820,7 @@ let i64p = Type::i64(cx).ptr_to(); let ptr_align = bx.tcx().data_layout.pointer_align; let slot = bx.alloca(i64p, "slot", ptr_align); - bx.invoke(func, &[data], normal.llbb(), catchswitch.llbb(), - None); + bx.invoke(func, &[data], normal.llbb(), catchswitch.llbb(), None); normal.ret(C_i32(cx, 0)); @@ -911,8 +908,7 @@ // being thrown. The second value is a "selector" indicating which of // the landing pad clauses the exception's type had been matched to. // rust_try ignores the selector. - let lpad_ty = Type::struct_(cx, &[Type::i8p(cx), Type::i32(cx)], - false); + let lpad_ty = Type::struct_(cx, &[Type::i8p(cx), Type::i32(cx)], false); let vals = catch.landing_pad(lpad_ty, bx.cx.eh_personality(), 1); catch.add_clause(vals, C_null(Type::i8p(cx))); let ptr = catch.extract_value(vals, 0); @@ -976,7 +972,7 @@ let output = tcx.types.i32; let rust_try = gen_fn(cx, "__rust_try", vec![fn_ty, i8p, i8p], output, codegen); cx.rust_try_fn.set(Some(rust_try)); - return rust_try + rust_try } fn span_invalid_monomorphization_error(a: &Session, b: Span, c: &str) { @@ -1000,11 +996,11 @@ ($msg: tt, $($fmt: tt)*) => { span_invalid_monomorphization_error( bx.sess(), span, - &format!(concat!("invalid monomorphization of `{}` intrinsic: ", - $msg), + &format!(concat!("invalid monomorphization of `{}` intrinsic: ", $msg), name, $($fmt)*)); } } + macro_rules! return_error { ($($fmt: tt)*) => { { @@ -1021,14 +1017,13 @@ } }; } + macro_rules! require_simd { ($ty: expr, $position: expr) => { require!($ty.is_simd(), "expected SIMD {} type, found non-SIMD `{}`", $position, $ty) } } - - let tcx = bx.tcx(); let sig = tcx.normalize_erasing_late_bound_regions( ty::ParamEnv::reveal_all(), @@ -1075,11 +1070,8 @@ } if name.starts_with("simd_shuffle") { - let n: usize = match name["simd_shuffle".len()..].parse() { - Ok(n) => n, - Err(_) => span_bug!(span, - "bad `simd_shuffle` instruction only caught in codegen?") - }; + let n: usize = name["simd_shuffle".len()..].parse().unwrap_or_else(|_| + span_bug!(span, "bad `simd_shuffle` instruction only caught in codegen?")); require_simd!(ret_ty, "return"); @@ -1121,8 +1113,8 @@ }; return Ok(bx.shuffle_vector(args[0].immediate(), - args[1].immediate(), - C_vector(&indices))) + args[1].immediate(), + C_vector(&indices))) } if name == "simd_insert" { @@ -1130,8 +1122,8 @@ "expected inserted type `{}` (element of input `{}`), found `{}`", in_elem, in_ty, arg_tys[2]); return Ok(bx.insert_element(args[0].immediate(), - args[2].immediate(), - args[1].immediate())) + args[2].immediate(), + args[1].immediate())) } if name == "simd_extract" { require!(ret_ty == in_elem, @@ -1150,9 +1142,7 @@ ); match m_elem_ty.sty { ty::Int(_) => {}, - _ => { - return_error!("mask element type is `{}`, expected `i_`", m_elem_ty); - } + _ => return_error!("mask element type is `{}`, expected `i_`", m_elem_ty) } // truncate the mask to a vector of i1s let i1 = Type::i1(bx.cx); @@ -1177,8 +1167,7 @@ ($msg: tt, $($fmt: tt)*) => { span_invalid_monomorphization_error( bx.sess(), span, - &format!(concat!("invalid monomorphization of `{}` intrinsic: ", - $msg), + &format!(concat!("invalid monomorphization of `{}` intrinsic: ", $msg), name, $($fmt)*)); } } @@ -1223,63 +1212,53 @@ &args.iter().map(|arg| arg.immediate()).collect::>(), None); unsafe { llvm::LLVMRustSetHasUnsafeAlgebra(c) }; - return Ok(c); - } - - if name == "simd_fsqrt" { - return simd_simple_float_intrinsic("sqrt", in_elem, in_ty, in_len, bx, span, args); - } - - if name == "simd_fsin" { - return simd_simple_float_intrinsic("sin", in_elem, in_ty, in_len, bx, span, args); - } - - if name == "simd_fcos" { - return simd_simple_float_intrinsic("cos", in_elem, in_ty, in_len, bx, span, args); - } - - if name == "simd_fabs" { - return simd_simple_float_intrinsic("fabs", in_elem, in_ty, in_len, bx, span, args); - } - - if name == "simd_floor" { - return simd_simple_float_intrinsic("floor", in_elem, in_ty, in_len, bx, span, args); - } - - if name == "simd_ceil" { - return simd_simple_float_intrinsic("ceil", in_elem, in_ty, in_len, bx, span, args); - } - - if name == "simd_fexp" { - return simd_simple_float_intrinsic("exp", in_elem, in_ty, in_len, bx, span, args); - } - - if name == "simd_fexp2" { - return simd_simple_float_intrinsic("exp2", in_elem, in_ty, in_len, bx, span, args); - } - - if name == "simd_flog10" { - return simd_simple_float_intrinsic("log10", in_elem, in_ty, in_len, bx, span, args); - } - - if name == "simd_flog2" { - return simd_simple_float_intrinsic("log2", in_elem, in_ty, in_len, bx, span, args); - } - - if name == "simd_flog" { - return simd_simple_float_intrinsic("log", in_elem, in_ty, in_len, bx, span, args); + Ok(c) } - if name == "simd_fpowi" { - return simd_simple_float_intrinsic("powi", in_elem, in_ty, in_len, bx, span, args); - } - - if name == "simd_fpow" { - return simd_simple_float_intrinsic("pow", in_elem, in_ty, in_len, bx, span, args); - } - - if name == "simd_fma" { - return simd_simple_float_intrinsic("fma", in_elem, in_ty, in_len, bx, span, args); + match name { + "simd_fsqrt" => { + return simd_simple_float_intrinsic("sqrt", in_elem, in_ty, in_len, bx, span, args); + } + "simd_fsin" => { + return simd_simple_float_intrinsic("sin", in_elem, in_ty, in_len, bx, span, args); + } + "simd_fcos" => { + return simd_simple_float_intrinsic("cos", in_elem, in_ty, in_len, bx, span, args); + } + "simd_fabs" => { + return simd_simple_float_intrinsic("fabs", in_elem, in_ty, in_len, bx, span, args); + } + "simd_floor" => { + return simd_simple_float_intrinsic("floor", in_elem, in_ty, in_len, bx, span, args); + } + "simd_ceil" => { + return simd_simple_float_intrinsic("ceil", in_elem, in_ty, in_len, bx, span, args); + } + "simd_fexp" => { + return simd_simple_float_intrinsic("exp", in_elem, in_ty, in_len, bx, span, args); + } + "simd_fexp2" => { + return simd_simple_float_intrinsic("exp2", in_elem, in_ty, in_len, bx, span, args); + } + "simd_flog10" => { + return simd_simple_float_intrinsic("log10", in_elem, in_ty, in_len, bx, span, args); + } + "simd_flog2" => { + return simd_simple_float_intrinsic("log2", in_elem, in_ty, in_len, bx, span, args); + } + "simd_flog" => { + return simd_simple_float_intrinsic("log", in_elem, in_ty, in_len, bx, span, args); + } + "simd_fpowi" => { + return simd_simple_float_intrinsic("powi", in_elem, in_ty, in_len, bx, span, args); + } + "simd_fpow" => { + return simd_simple_float_intrinsic("pow", in_elem, in_ty, in_len, bx, span, args); + } + "simd_fma" => { + return simd_simple_float_intrinsic("fma", in_elem, in_ty, in_len, bx, span, args); + } + _ => { /* fallthrough */ } } // FIXME: use: @@ -1312,7 +1291,7 @@ } - if name == "simd_gather" { + if name == "simd_gather" { // simd_gather(values: , pointers: , // mask: ) -> // * N: number of elements in the input vectors @@ -1360,7 +1339,7 @@ // to the element type of the first argument let (pointer_count, underlying_ty) = match arg_tys[1].simd_type(tcx).sty { ty::RawPtr(p) if p.ty == in_elem => (ptr_count(arg_tys[1].simd_type(tcx)), - non_ptr(arg_tys[1].simd_type(tcx))), + non_ptr(arg_tys[1].simd_type(tcx))), _ => { require!(false, "expected element type `{}` of second argument `{}` \ to be a pointer to the element type `{}` of the first \ @@ -1371,7 +1350,7 @@ } }; assert!(pointer_count > 0); - assert!(pointer_count - 1 == ptr_count(arg_tys[0].simd_type(tcx))); + assert_eq!(pointer_count - 1, ptr_count(arg_tys[0].simd_type(tcx))); assert_eq!(underlying_ty, non_ptr(arg_tys[0].simd_type(tcx))); // The element type of the third argument must be a signed integer type of any width: @@ -1414,7 +1393,7 @@ return Ok(v); } - if name == "simd_scatter" { + if name == "simd_scatter" { // simd_scatter(values: , pointers: , // mask: ) -> () // * N: number of elements in the input vectors @@ -1468,7 +1447,7 @@ } }; assert!(pointer_count > 0); - assert!(pointer_count - 1 == ptr_count(arg_tys[0].simd_type(tcx))); + assert_eq!(pointer_count - 1, ptr_count(arg_tys[0].simd_type(tcx))); assert_eq!(underlying_ty, non_ptr(arg_tys[0].simd_type(tcx))); // The element type of the third argument must be a signed integer type of any width: @@ -1570,7 +1549,6 @@ ) } } - }; Ok(bx.$float_reduce(acc, args[0].immediate())) } @@ -1750,9 +1728,9 @@ _ => {}, } require!(false, - "unsupported operation on `{}` with element `{}`", - in_ty, - in_elem) + "unsupported operation on `{}` with element `{}`", + in_ty, + in_elem) })* } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -26,8 +26,7 @@ #![feature(in_band_lifetimes)] #![allow(unused_attributes)] #![feature(libc)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(quote)] #![feature(range_contains)] #![feature(rustc_diagnostic_macros)] @@ -307,7 +306,7 @@ }; let bytecode_compressed = if emit_bc_compressed { Some(outputs.temp_path(OutputType::Bitcode, Some(&self.name)) - .with_extension(RLIB_BYTECODE_EXTENSION)) + .with_extension(RLIB_BYTECODE_EXTENSION)) } else { None }; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/llvm/archive_ro.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/llvm/archive_ro.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/llvm/archive_ro.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/llvm/archive_ro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -40,7 +40,7 @@ return unsafe { let s = path2cstr(dst); let ar = super::LLVMRustOpenArchive(s.as_ptr()).ok_or_else(|| { - super::last_error().unwrap_or("failed to open archive".to_string()) + super::last_error().unwrap_or_else(|| "failed to open archive".to_owned()) })?; Ok(ArchiveRO { raw: ar }) }; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/llvm/diagnostic.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/llvm/diagnostic.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/llvm/diagnostic.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/llvm/diagnostic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -77,7 +77,7 @@ ).ok() ).ok(); - let mut filename = filename.unwrap_or(String::new()); + let mut filename = filename.unwrap_or_default(); if filename.is_empty() { filename.push_str(""); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/llvm/ffi.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/llvm/ffi.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/llvm/ffi.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/llvm/ffi.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,16 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// FIXME: Rename 'DIGlobalVariable' to 'DIGlobalVariableExpression' -// once support for LLVM 3.9 is dropped. -// -// This method was changed in this LLVM patch: -// https://reviews.llvm.org/D26769 - use super::debuginfo::{ DIBuilder, DIDescriptor, DIFile, DILexicalBlock, DISubprogram, DIType, DIBasicType, DIDerivedType, DICompositeType, DIScope, DIVariable, - DIGlobalVariable, DIArray, DISubrange, DITemplateTypeParameter, DIEnumerator, + DIGlobalVariableExpression, DIArray, DISubrange, DITemplateTypeParameter, DIEnumerator, DINameSpace, DIFlags, }; @@ -128,6 +122,7 @@ SanitizeThread = 20, SanitizeAddress = 21, SanitizeMemory = 22, + NonLazyBind = 23, } /// LLVMIntPredicate @@ -447,7 +442,7 @@ pub type DIDerivedType = DIType; pub type DICompositeType = DIDerivedType; pub type DIVariable = DIDescriptor; - pub type DIGlobalVariable = DIDescriptor; + pub type DIGlobalVariableExpression = DIDescriptor; pub type DIArray = DIDescriptor; pub type DISubrange = DIDescriptor; pub type DIEnumerator = DIDescriptor; @@ -487,6 +482,8 @@ extern { pub type ModuleBuffer; } extern "C" { + pub fn LLVMRustInstallFatalErrorHandler(); + // Create and destroy contexts. pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context; pub fn LLVMContextDispose(C: &'static mut Context); @@ -1214,6 +1211,9 @@ AlignStack: Bool, Dialect: AsmDialect) -> &Value; + pub fn LLVMRustInlineAsmVerify(Ty: &Type, + Constraints: *const c_char) + -> bool; pub fn LLVMRustDebugMetadataVersion() -> u32; pub fn LLVMRustVersionMajor() -> u32; @@ -1330,7 +1330,7 @@ Val: &'a Value, Decl: Option<&'a DIDescriptor>, AlignInBits: u32) - -> &'a DIGlobalVariable; + -> &'a DIGlobalVariableExpression; pub fn LLVMRustDIBuilderCreateVariable(Builder: &DIBuilder<'a>, Tag: c_uint, @@ -1466,7 +1466,8 @@ DataSections: bool, TrapUnreachable: bool, Singlethread: bool, - AsmComments: bool) + AsmComments: bool, + EmitStackSizeSection: bool) -> Option<&'static mut TargetMachine>; pub fn LLVMRustDisposeTargetMachine(T: &'static mut TargetMachine); pub fn LLVMRustAddAnalysisPasses(T: &'a TargetMachine, PM: &PassManager<'a>, M: &'a Module); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/llvm_util.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/llvm_util.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/llvm_util.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/llvm_util.rs 2018-12-04 23:41:40.000000000 +0000 @@ -52,8 +52,11 @@ } unsafe fn configure_llvm(sess: &Session) { - let mut llvm_c_strs = Vec::new(); - let mut llvm_args = Vec::new(); + let n_args = sess.opts.cg.llvm_args.len(); + let mut llvm_c_strs = Vec::with_capacity(n_args + 1); + let mut llvm_args = Vec::with_capacity(n_args + 1); + + llvm::LLVMRustInstallFatalErrorHandler(); { let mut add = |arg: &str| { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/metadata.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/metadata.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/metadata.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/metadata.rs 2018-12-04 23:41:40.000000000 +0000 @@ -63,7 +63,7 @@ let of = ObjectFile::new(mb) .map(|of| OwningRef::new(box of)) .ok_or_else(|| format!("provided path not an object file: '{}'", - filename.display()))?; + filename.display()))?; let buf = of.try_map(|of| search_meta_section(of, target, filename))?; Ok(rustc_erase_owner!(buf)) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/meth.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/meth.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/meth.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/meth.rs 2018-12-04 23:41:40.000000000 +0000 @@ -72,7 +72,7 @@ pub fn get_vtable( cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>, - trait_ref: Option>, + trait_ref: ty::PolyExistentialTraitRef<'tcx>, ) -> &'ll Value { let tcx = cx.tcx; @@ -86,23 +86,23 @@ // Not in the cache. Build it. let nullptr = C_null(Type::i8p(cx)); + let methods = tcx.vtable_methods(trait_ref.with_self_ty(tcx, ty)); + let methods = methods.iter().cloned().map(|opt_mth| { + opt_mth.map_or(nullptr, |(def_id, substs)| { + callee::resolve_and_get_fn(cx, def_id, substs) + }) + }); + let (size, align) = cx.size_and_align_of(ty); - let mut components: Vec<_> = [ + // ///////////////////////////////////////////////////////////////////////////////////////////// + // If you touch this code, be sure to also make the corresponding changes to + // `get_vtable` in rust_mir/interpret/traits.rs + // ///////////////////////////////////////////////////////////////////////////////////////////// + let components: Vec<_> = [ callee::get_fn(cx, monomorphize::resolve_drop_in_place(cx.tcx, ty)), C_usize(cx, size.bytes()), C_usize(cx, align.abi()) - ].iter().cloned().collect(); - - if let Some(trait_ref) = trait_ref { - let trait_ref = trait_ref.with_self_ty(tcx, ty); - let methods = tcx.vtable_methods(trait_ref); - let methods = methods.iter().cloned().map(|opt_mth| { - opt_mth.map_or(nullptr, |(def_id, substs)| { - callee::resolve_and_get_fn(cx, def_id, substs) - }) - }); - components.extend(methods); - } + ].iter().cloned().chain(methods).collect(); let vtable_const = C_struct(cx, &components, false); let align = cx.data_layout().pointer_align; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/analyze.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/analyze.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/analyze.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/analyze.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,18 +11,18 @@ //! An analysis to determine which locals require allocas and //! which do not. -use rustc_data_structures::bitvec::BitArray; +use rustc_data_structures::bit_set::BitSet; use rustc_data_structures::graph::dominators::Dominators; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use rustc::mir::{self, Location, TerminatorKind}; -use rustc::mir::visit::{Visitor, PlaceContext}; +use rustc::mir::visit::{Visitor, PlaceContext, MutatingUseContext, NonMutatingUseContext}; use rustc::mir::traversal; use rustc::ty; use rustc::ty::layout::LayoutOf; use type_of::LayoutLlvmExt; use super::FunctionCx; -pub fn non_ssa_locals(fx: &FunctionCx<'a, 'll, 'tcx>) -> BitArray { +pub fn non_ssa_locals(fx: &FunctionCx<'a, 'll, 'tcx>) -> BitSet { let mir = fx.mir; let mut analyzer = LocalAnalyzer::new(fx); @@ -54,7 +54,7 @@ struct LocalAnalyzer<'mir, 'a: 'mir, 'll: 'a, 'tcx: 'll> { fx: &'mir FunctionCx<'a, 'll, 'tcx>, dominators: Dominators, - non_ssa_locals: BitArray, + non_ssa_locals: BitSet, // The location of the first visited direct assignment to each // local, or an invalid location (out of bounds `block` index). first_assignment: IndexVec @@ -67,7 +67,7 @@ let mut analyzer = LocalAnalyzer { fx, dominators: fx.mir.dominators(), - non_ssa_locals: BitArray::new(fx.mir.local_decls.len()), + non_ssa_locals: BitSet::new_empty(fx.mir.local_decls.len()), first_assignment: IndexVec::from_elem(invalid_location, &fx.mir.local_decls) }; @@ -116,7 +116,11 @@ self.not_ssa(index); } } else { - self.visit_place(place, PlaceContext::Store, location); + self.visit_place( + place, + PlaceContext::MutatingUse(MutatingUseContext::Store), + location + ); } self.visit_rvalue(rvalue, location); @@ -142,7 +146,11 @@ // is not guaranteed to be statically dominated by the // definition of x, so x must always be in an alloca. if let mir::Operand::Move(ref place) = args[0] { - self.visit_place(place, PlaceContext::Drop, location); + self.visit_place( + place, + PlaceContext::MutatingUse(MutatingUseContext::Drop), + location + ); } } } @@ -151,16 +159,17 @@ } fn visit_place(&mut self, - place: &mir::Place<'tcx>, - context: PlaceContext<'tcx>, - location: Location) { + place: &mir::Place<'tcx>, + context: PlaceContext<'tcx>, + location: Location) { debug!("visit_place(place={:?}, context={:?})", place, context); let cx = self.fx.cx; if let mir::Place::Projection(ref proj) = *place { // Allow uses of projections that are ZSTs or from scalar fields. let is_consume = match context { - PlaceContext::Copy | PlaceContext::Move => true, + PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) | + PlaceContext::NonMutatingUse(NonMutatingUseContext::Move) => true, _ => false }; if is_consume { @@ -168,7 +177,9 @@ let base_ty = self.fx.monomorphize(&base_ty); // ZSTs don't require any actual memory access. - let elem_ty = base_ty.projection_ty(cx.tcx, &proj.elem).to_ty(cx.tcx); + let elem_ty = base_ty + .projection_ty(cx.tcx, &proj.elem) + .to_ty(cx.tcx); let elem_ty = self.fx.monomorphize(&elem_ty); if cx.layout_of(elem_ty).is_zst() { return; @@ -188,7 +199,11 @@ // A deref projection only reads the pointer, never needs the place. if let mir::ProjectionElem::Deref = proj.elem { - return self.visit_place(&proj.base, PlaceContext::Copy, location); + return self.visit_place( + &proj.base, + PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy), + location + ); } } @@ -200,16 +215,14 @@ context: PlaceContext<'tcx>, location: Location) { match context { - PlaceContext::Call => { + PlaceContext::MutatingUse(MutatingUseContext::Call) => { self.assign(local, location); } - PlaceContext::StorageLive | - PlaceContext::StorageDead | - PlaceContext::Validate => {} + PlaceContext::NonUse(_) => {} - PlaceContext::Copy | - PlaceContext::Move => { + PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) | + PlaceContext::NonMutatingUse(NonMutatingUseContext::Move) => { // Reads from uninitialized variables (e.g. in dead code, after // optimizations) require locals to be in (uninitialized) memory. // NB: there can be uninitialized reads of a local visited after @@ -225,15 +238,19 @@ } } - PlaceContext::Inspect | - PlaceContext::Store | - PlaceContext::AsmOutput | - PlaceContext::Borrow { .. } | - PlaceContext::Projection(..) => { + PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect) | + PlaceContext::MutatingUse(MutatingUseContext::Store) | + PlaceContext::MutatingUse(MutatingUseContext::AsmOutput) | + PlaceContext::MutatingUse(MutatingUseContext::Borrow(..)) | + PlaceContext::MutatingUse(MutatingUseContext::Projection) | + PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow(..)) | + PlaceContext::NonMutatingUse(NonMutatingUseContext::UniqueBorrow(..)) | + PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow(..)) | + PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection) => { self.not_ssa(local); } - PlaceContext::Drop => { + PlaceContext::MutatingUse(MutatingUseContext::Drop) => { let ty = mir::Place::Local(local).ty(self.fx.mir, self.fx.cx.tcx); let ty = self.fx.monomorphize(&ty.to_ty(self.fx.cx.tcx)); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/block.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/block.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/block.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/block.rs 2018-12-04 23:41:40.000000000 +0000 @@ -49,9 +49,9 @@ } fn codegen_terminator(&mut self, - mut bx: Builder<'a, 'll, 'tcx>, - bb: mir::BasicBlock, - terminator: &mir::Terminator<'tcx>) + mut bx: Builder<'a, 'll, 'tcx>, + bb: mir::BasicBlock, + terminator: &mir::Terminator<'tcx>) { debug!("codegen_terminator: {:?}", terminator); @@ -125,10 +125,10 @@ this.unreachable_block() }; let invokeret = bx.invoke(fn_ptr, - &llargs, - ret_bx, - llblock(this, cleanup), - cleanup_bundle); + &llargs, + ret_bx, + llblock(this, cleanup), + cleanup_bundle); fn_ty.apply_attrs_callsite(&bx, invokeret); if let Some((ret_dest, target)) = destination { @@ -213,7 +213,8 @@ } else { let (otherwise, targets) = targets.split_last().unwrap(); let switch = bx.switch(discr.immediate(), - llblock(self, *otherwise), values.len()); + llblock(self, *otherwise), + values.len()); let switch_llty = bx.cx.layout_of(switch_ty).immediate_llvm_type(bx.cx); for (&value, target) in values.iter().zip(targets) { let llval = C_uint_big(switch_llty, value); @@ -387,8 +388,8 @@ let msg_str = Symbol::intern(str).as_str(); let msg_str = C_str_slice(bx.cx, msg_str); let msg_file_line_col = C_struct(bx.cx, - &[msg_str, filename, line, col], - false); + &[msg_str, filename, line, col], + false); let msg_file_line_col = consts::addr_of(bx.cx, msg_file_line_col, align, @@ -412,7 +413,13 @@ bug!("undesugared DropAndReplace in codegen: {:?}", terminator); } - mir::TerminatorKind::Call { ref func, ref args, ref destination, cleanup } => { + mir::TerminatorKind::Call { + ref func, + ref args, + ref destination, + cleanup, + from_hir_call: _ + } => { // Create the callee. This is a fn ptr or zero-sized and hence a kind of scalar. let callee = self.codegen_operand(&bx, func); @@ -482,6 +489,54 @@ _ => FnType::new(bx.cx, sig, &extra_args) }; + // emit a panic instead of instantiating an uninhabited type + if (intrinsic == Some("init") || intrinsic == Some("uninit")) && + fn_ty.ret.layout.abi.is_uninhabited() + { + let loc = bx.sess().source_map().lookup_char_pos(span.lo()); + let filename = Symbol::intern(&loc.file.name.to_string()).as_str(); + let filename = C_str_slice(bx.cx, filename); + let line = C_u32(bx.cx, loc.line as u32); + let col = C_u32(bx.cx, loc.col.to_usize() as u32 + 1); + let align = tcx.data_layout.aggregate_align + .max(tcx.data_layout.i32_align) + .max(tcx.data_layout.pointer_align); + + let str = format!( + "Attempted to instantiate uninhabited type {} using mem::{}", + sig.output(), + if intrinsic == Some("init") { "zeroed" } else { "uninitialized" } + ); + let msg_str = Symbol::intern(&str).as_str(); + let msg_str = C_str_slice(bx.cx, msg_str); + let msg_file_line_col = C_struct(bx.cx, + &[msg_str, filename, line, col], + false); + let msg_file_line_col = consts::addr_of(bx.cx, + msg_file_line_col, + align, + Some("panic_loc")); + + // Obtain the panic entry point. + let def_id = + common::langcall(bx.tcx(), Some(span), "", lang_items::PanicFnLangItem); + let instance = ty::Instance::mono(bx.tcx(), def_id); + let fn_ty = FnType::of_instance(bx.cx, &instance); + let llfn = callee::get_fn(bx.cx, instance); + + // Codegen the actual panic invoke/call. + do_call( + self, + bx, + fn_ty, + llfn, + &[msg_file_line_col], + destination.as_ref().map(|(_, bb)| (ReturnDest::Nothing, *bb)), + cleanup, + ); + return; + } + // The arguments we'll be passing. Plus one to account for outptr, if used. let arg_count = fn_ty.args.len() + fn_ty.ret.is_indirect() as usize; let mut llargs = Vec::with_capacity(arg_count); @@ -565,7 +620,7 @@ let callee_ty = instance.as_ref().unwrap().ty(bx.cx.tcx); codegen_intrinsic_call(&bx, callee_ty, &fn_ty, &args, dest, - terminator.source_info.span); + terminator.source_info.span); if let ReturnDest::IndirectOperand(dst, _) = ret_dest { self.store_return(&bx, ret_dest, &fn_ty.ret, dst.llval); @@ -702,7 +757,7 @@ // Have to load the argument, maybe while casting it. if let PassMode::Cast(ty) = arg.mode { llval = bx.load(bx.pointercast(llval, ty.llvm_type(bx.cx).ptr_to()), - align.min(arg.layout.align)); + align.min(arg.layout.align)); } else { // We can't use `PlaceRef::load` here because the argument // may have a type we don't treat as immediate, but the ABI @@ -724,10 +779,10 @@ } fn codegen_arguments_untupled(&mut self, - bx: &Builder<'a, 'll, 'tcx>, - operand: &mir::Operand<'tcx>, - llargs: &mut Vec<&'ll Value>, - args: &[ArgType<'tcx, Ty<'tcx>>]) { + bx: &Builder<'a, 'll, 'tcx>, + operand: &mir::Operand<'tcx>, + llargs: &mut Vec<&'ll Value>, + args: &[ArgType<'tcx, Ty<'tcx>>]) { let tuple = self.codegen_operand(bx, operand); // Handle both by-ref and immediate tuples. @@ -879,8 +934,8 @@ } fn codegen_transmute(&mut self, bx: &Builder<'a, 'll, 'tcx>, - src: &mir::Operand<'tcx>, - dst: &mir::Place<'tcx>) { + src: &mir::Operand<'tcx>, + dst: &mir::Place<'tcx>) { if let mir::Place::Local(index) = *dst { match self.locals[index] { LocalRef::Place(place) => self.codegen_transmute_into(bx, src, place), @@ -907,8 +962,8 @@ } fn codegen_transmute_into(&mut self, bx: &Builder<'a, 'll, 'tcx>, - src: &mir::Operand<'tcx>, - dst: PlaceRef<'ll, 'tcx>) { + src: &mir::Operand<'tcx>, + dst: PlaceRef<'ll, 'tcx>) { let src = self.codegen_operand(bx, src); let llty = src.layout.llvm_type(bx.cx); let cast_ptr = bx.pointercast(dst.llval, llty.ptr_to()); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/constant.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/constant.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/constant.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/constant.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,7 @@ use llvm; use rustc::mir::interpret::{ConstEvalErr, read_target_uint}; -use rustc_mir::interpret::{const_field}; +use rustc_mir::const_eval::const_field; use rustc::hir::def_id::DefId; use rustc::mir; use rustc_data_structures::indexed_vec::Idx; @@ -92,7 +92,7 @@ let pointer_size = layout.pointer_size.bytes() as usize; let mut next_offset = 0; - for &(offset, alloc_id) in alloc.relocations.iter() { + for &(offset, ((), alloc_id)) in alloc.relocations.iter() { let offset = offset.bytes(); assert_eq!(offset as usize as u64, offset); let offset = offset as usize; @@ -105,7 +105,7 @@ ).expect("const_alloc_to_llvm: could not read relocation pointer") as u64; llvals.push(scalar_to_llvm( cx, - Pointer { alloc_id, offset: Size::from_bytes(ptr_offset) }.into(), + Pointer::new(alloc_id, Size::from_bytes(ptr_offset)).into(), &layout::Scalar { value: layout::Primitive::Pointer, valid_range: 0..=!0 diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -31,7 +31,7 @@ use std::iter; -use rustc_data_structures::bitvec::BitArray; +use rustc_data_structures::bit_set::BitSet; use rustc_data_structures::indexed_vec::IndexVec; pub use self::constant::codegen_static_initializer; @@ -162,16 +162,16 @@ // corresponding to span's containing source scope. If so, we need to create a DIScope // "extension" into that file. fn scope_metadata_for_loc(&self, scope_id: mir::SourceScope, pos: BytePos) - -> Option<&'ll DIScope> { + -> Option<&'ll DIScope> { let scope_metadata = self.scopes[scope_id].scope_metadata; if pos < self.scopes[scope_id].file_start_pos || pos >= self.scopes[scope_id].file_end_pos { let cm = self.cx.sess().source_map(); let defining_crate = self.debug_context.get_ref(DUMMY_SP).defining_crate; Some(debuginfo::extend_scope_to_file(self.cx, - scope_metadata.unwrap(), - &cm.lookup_char_pos(pos).file, - defining_crate)) + scope_metadata.unwrap(), + &cm.lookup_char_pos(pos).file, + defining_crate)) } else { scope_metadata } @@ -341,7 +341,7 @@ debuginfo::start_emitting_source_locations(&fx.debug_context); let rpo = traversal::reverse_postorder(&mir); - let mut visited = BitArray::new(mir.basic_blocks().len()); + let mut visited = BitSet::new_empty(mir.basic_blocks().len()); // Codegen the body of each block using reverse postorder for (bb, _) in rpo { @@ -435,7 +435,7 @@ bx: &Builder<'a, 'll, 'tcx>, fx: &FunctionCx<'a, 'll, 'tcx>, scopes: &IndexVec>, - memory_locals: &BitArray, + memory_locals: &BitSet, ) -> Vec> { let mir = fx.mir; let tcx = bx.tcx(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/operand.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/operand.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/operand.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/operand.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,9 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rustc::mir::interpret::ConstEvalErr; +use rustc::mir::interpret::{ConstValue, ConstEvalErr}; use rustc::mir; -use rustc::mir::interpret::{ConstValue, ScalarMaybeUndef}; use rustc::ty; use rustc::ty::layout::{self, Align, LayoutOf, TyLayout}; use rustc_data_structures::sync::Lrc; @@ -114,15 +113,12 @@ layout.scalar_pair_element_llvm_type(bx.cx, 0, true), ); let b_layout = layout.scalar_pair_element_llvm_type(bx.cx, 1, true); - let b_llval = match b { - ScalarMaybeUndef::Scalar(b) => scalar_to_llvm( - bx.cx, - b, - b_scalar, - b_layout, - ), - ScalarMaybeUndef::Undef => C_undef(b_layout), - }; + let b_llval = scalar_to_llvm( + bx.cx, + b, + b_scalar, + b_layout, + ); OperandValue::Pair(a_llval, b_llval) }, ConstValue::ByRef(_, alloc, offset) => { @@ -298,11 +294,21 @@ bx.store_with_flags(val, dest.llval, dest.align, flags); } OperandValue::Pair(a, b) => { - for (i, &x) in [a, b].iter().enumerate() { - let llptr = bx.struct_gep(dest.llval, i as u64); - let val = base::from_immediate(bx, x); - bx.store_with_flags(val, llptr, dest.align, flags); - } + let (a_scalar, b_scalar) = match dest.layout.abi { + layout::Abi::ScalarPair(ref a, ref b) => (a, b), + _ => bug!("store_with_flags: invalid ScalarPair layout: {:#?}", dest.layout) + }; + let b_offset = a_scalar.value.size(bx.cx).abi_align(b_scalar.value.align(bx.cx)); + + let llptr = bx.struct_gep(dest.llval, 0); + let val = base::from_immediate(bx, a); + let align = dest.align; + bx.store_with_flags(val, llptr, align, flags); + + let llptr = bx.struct_gep(dest.llval, 1); + let val = base::from_immediate(bx, b); + let align = dest.align.restrict_for_offset(b_offset); + bx.store_with_flags(val, llptr, align, flags); } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/place.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/place.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/place.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/place.rs 2018-12-04 23:41:40.000000000 +0000 @@ -150,9 +150,10 @@ }); OperandValue::Immediate(base::to_immediate(bx, llval, self.layout)) } else if let layout::Abi::ScalarPair(ref a, ref b) = self.layout.abi { - let load = |i, scalar: &layout::Scalar| { + let b_offset = a.value.size(bx.cx).abi_align(b.value.align(bx.cx)); + let load = |i, scalar: &layout::Scalar, align| { let llptr = bx.struct_gep(self.llval, i as u64); - let load = bx.load(llptr, self.align); + let load = bx.load(llptr, align); scalar_load_metadata(load, scalar); if scalar.is_bool() { bx.trunc(load, Type::i1(bx.cx)) @@ -160,7 +161,10 @@ load } }; - OperandValue::Pair(load(0, a), load(1, b)) + OperandValue::Pair( + load(0, a, self.align), + load(1, b, self.align.restrict_for_offset(b_offset)), + ) } else { OperandValue::Ref(self.llval, None, self.align) }; @@ -173,10 +177,7 @@ let cx = bx.cx; let field = self.layout.field(cx, ix); let offset = self.layout.fields.offset(ix); - let effective_field_align = self.align - .min(self.layout.align) - .min(field.align) - .restrict_for_offset(offset); + let effective_field_align = self.align.restrict_for_offset(offset); let simple = || { // Unions and newtypes only use an offset of 0. @@ -278,7 +279,7 @@ /// Obtain the actual discriminant of a value. pub fn codegen_get_discr(self, bx: &Builder<'a, 'll, 'tcx>, cast_to: Ty<'tcx>) -> &'ll Value { let cast_to = bx.cx.layout_of(cast_to).immediate_llvm_type(bx.cx); - if self.layout.abi == layout::Abi::Uninhabited { + if self.layout.abi.is_uninhabited() { return C_undef(cast_to); } match self.layout.variants { @@ -341,7 +342,7 @@ /// Set the discriminant for a new value of the given case of the given /// representation. pub fn codegen_set_discr(&self, bx: &Builder<'a, 'll, 'tcx>, variant_index: usize) { - if self.layout.for_variant(bx.cx, variant_index).abi == layout::Abi::Uninhabited { + if self.layout.for_variant(bx.cx, variant_index).abi.is_uninhabited() { return; } match self.layout.variants { @@ -520,7 +521,8 @@ let mut subslice = cg_base.project_index(bx, C_usize(bx.cx, from as u64)); let projected_ty = PlaceTy::Ty { ty: cg_base.layout.ty } - .projection_ty(tcx, &projection.elem).to_ty(bx.tcx()); + .projection_ty(tcx, &projection.elem) + .to_ty(bx.tcx()); subslice.layout = bx.cx.layout_of(self.monomorphize(&projected_ty)); if subslice.layout.is_unsized() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/rvalue.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/rvalue.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/rvalue.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/rvalue.rs 2018-12-04 23:41:40.000000000 +0000 @@ -290,7 +290,7 @@ mir::CastKind::Misc => { assert!(cast.is_llvm_immediate()); let ll_t_out = cast.immediate_llvm_type(bx.cx); - if operand.layout.abi == layout::Abi::Uninhabited { + if operand.layout.abi.is_uninhabited() { return (bx, OperandRef { val: OperandValue::Immediate(C_undef(ll_t_out)), layout: cast, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/statement.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/statement.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/statement.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/mir/statement.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,6 +15,7 @@ use super::FunctionCx; use super::LocalRef; +use super::OperandValue; impl FunctionCx<'a, 'll, 'tcx> { pub fn codegen_statement(&mut self, @@ -82,14 +83,31 @@ self.codegen_place(&bx, output) }).collect(); - let input_vals = inputs.iter().map(|input| { - self.codegen_operand(&bx, input).immediate() - }).collect(); + let input_vals = inputs.iter() + .try_fold(Vec::with_capacity(inputs.len()), |mut acc, input| { + let op = self.codegen_operand(&bx, input); + if let OperandValue::Immediate(_) = op.val { + acc.push(op.immediate()); + Ok(acc) + } else { + Err(op) + } + }); - asm::codegen_inline_asm(&bx, asm, outputs, input_vals); + if input_vals.is_err() { + span_err!(bx.sess(), statement.source_info.span, E0669, + "invalid value for constraint in inline assembly"); + } else { + let input_vals = input_vals.unwrap(); + let res = asm::codegen_inline_asm(&bx, asm, outputs, input_vals); + if !res { + span_err!(bx.sess(), statement.source_info.span, E0668, + "malformed inline assembly"); + } + } bx } - mir::StatementKind::ReadForMatch(_) | + mir::StatementKind::FakeRead(..) | mir::StatementKind::EndRegion(_) | mir::StatementKind::Validate(..) | mir::StatementKind::AscribeUserType(..) | diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/mono_item.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/mono_item.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/mono_item.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/mono_item.rs 2018-12-04 23:41:40.000000000 +0000 @@ -108,8 +108,8 @@ match *self.as_mono_item() { MonoItem::Fn(instance) => { format!("Fn({:?}, {})", - instance.def, - instance.substs.as_ptr() as usize) + instance.def, + instance.substs.as_ptr() as usize) } MonoItem::Static(id) => { format!("Static({:?})", id) diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/type_of.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/type_of.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/type_of.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/type_of.rs 2018-12-04 23:41:40.000000000 +0000 @@ -65,13 +65,12 @@ let mut name = String::with_capacity(32); let printer = DefPathBasedNames::new(cx.tcx, true, true); printer.push_type_name(layout.ty, &mut name); - match (&layout.ty.sty, &layout.variants) { - (&ty::Adt(def, _), &layout::Variants::Single { index }) => { - if def.is_enum() && !def.variants.is_empty() { - write!(&mut name, "::{}", def.variants[index].name).unwrap(); - } + if let (&ty::Adt(def, _), &layout::Variants::Single { index }) + = (&layout.ty.sty, &layout.variants) + { + if def.is_enum() && !def.variants.is_empty() { + write!(&mut name, "::{}", def.variants[index].name).unwrap(); } - _ => {} } Some(name) } @@ -132,7 +131,7 @@ debug!("struct_llfields: {}: {:?} offset: {:?} target_offset: {:?} \ effective_field_align: {}", - i, field, offset, target_offset, effective_field_align.abi()); + i, field, offset, target_offset, effective_field_align.abi()); assert!(target_offset >= offset); let padding = target_offset - offset; let padding_align = prev_effective_align.min(effective_field_align); @@ -155,7 +154,7 @@ debug!("struct_llfields: pad_bytes: {:?} offset: {:?} stride: {:?}", padding, offset, layout.size); result.push(Type::padding_filler(cx, padding, padding_align)); - assert!(result.len() == 1 + field_count * 2); + assert_eq!(result.len(), 1 + field_count * 2); } else { debug!("struct_llfields: offset: {:?} stride: {:?}", offset, layout.size); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/value.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/value.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_llvm/value.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_llvm/value.rs 2018-12-04 23:41:40.000000000 +0000 @@ -34,6 +34,6 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(&llvm::build_string(|s| unsafe { llvm::LLVMRustWriteValueToString(self, s); - }).expect("nun-UTF8 value description from LLVM")) + }).expect("non-UTF8 value description from LLVM")) } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_utils/codegen_backend.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_utils/codegen_backend.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_utils/codegen_backend.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_utils/codegen_backend.rs 2018-12-04 23:41:40.000000000 +0000 @@ -28,7 +28,6 @@ use std::sync::{mpsc, Arc}; use rustc_data_structures::owning_ref::OwningRef; -use rustc_data_structures::sync::Lrc; use flate2::Compression; use flate2::write::DeflateEncoder; @@ -42,7 +41,6 @@ use rustc::middle::cstore::MetadataLoader; use rustc::dep_graph::DepGraph; use rustc_target::spec::Target; -use rustc_data_structures::fx::FxHashMap; use rustc_mir::monomorphize::collector; use link::out_filename; @@ -132,7 +130,7 @@ ::symbol_names::provide(providers); providers.target_features_whitelist = |_tcx, _cnum| { - Lrc::new(FxHashMap()) // Just a dummy + Default::default() // Just a dummy }; providers.is_reachable_non_generic = |_tcx, _defid| true; providers.exported_symbols = |_tcx, _crate| Arc::new(Vec::new()); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_utils/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_utils/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_utils/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_utils/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -19,8 +19,7 @@ #![feature(box_patterns)] #![feature(box_syntax)] #![feature(custom_attribute)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![allow(unused_attributes)] #![feature(quote)] #![feature(rustc_diagnostic_macros)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_utils/link.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_utils/link.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_utils/link.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_utils/link.rs 2018-12-04 23:41:40.000000000 +0000 @@ -97,6 +97,19 @@ "rust_out".to_string() } +pub fn filename_for_metadata(sess: &Session, + crate_name: &str, + outputs: &OutputFilenames) -> PathBuf { + let libname = format!("{}{}", crate_name, sess.opts.cg.extra_filename); + + let out_filename = outputs.single_output_file.clone() + .unwrap_or_else(|| outputs.out_directory.join(&format!("lib{}.rmeta", libname))); + + check_file_is_writeable(&out_filename, sess); + + out_filename +} + pub fn filename_for_input(sess: &Session, crate_type: config::CrateType, crate_name: &str, @@ -125,7 +138,7 @@ let suffix = &sess.target.target.options.exe_suffix; let out_filename = outputs.path(OutputType::Exe); if suffix.is_empty() { - out_filename.to_path_buf() + out_filename } else { out_filename.with_extension(&suffix[1..]) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_utils/symbol_names.rs rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_utils/symbol_names.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_codegen_utils/symbol_names.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_codegen_utils/symbol_names.rs 2018-12-04 23:41:40.000000000 +0000 @@ -228,7 +228,7 @@ fn def_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ty::SymbolName { let mut buffer = SymbolPathBuffer::new(); item_path::with_forced_absolute_paths(|| { - tcx.push_item_path(&mut buffer, def_id); + tcx.push_item_path(&mut buffer, def_id, false); }); buffer.into_interned() } @@ -338,6 +338,7 @@ // // To be able to work on all platforms and get *some* reasonable output, we // use C++ name-mangling. +#[derive(Debug)] struct SymbolPathBuffer { result: String, temp_buf: String, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_cratesio_shim/src/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_cratesio_shim/src/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_cratesio_shim/src/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_cratesio_shim/src/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,8 +11,7 @@ // See Cargo.toml for a comment explaining this crate. #![allow(unused_extern_crates)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] extern crate bitflags; extern crate log; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/array_vec.rs rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/array_vec.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/array_vec.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/array_vec.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,305 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! A stack-allocated vector, allowing storage of N elements on the stack. - -use std::marker::Unsize; -use std::iter::Extend; -use std::ptr::{self, drop_in_place, NonNull}; -use std::ops::{Deref, DerefMut, Range}; -use std::hash::{Hash, Hasher}; -use std::slice; -use std::fmt; -use std::mem; -use std::mem::ManuallyDrop; -use std::ops::Bound::{Excluded, Included, Unbounded}; -use std::ops::RangeBounds; - -pub unsafe trait Array { - type Element; - type PartialStorage: Unsize<[ManuallyDrop]>; - const LEN: usize; -} - -unsafe impl Array for [T; 1] { - type Element = T; - type PartialStorage = [ManuallyDrop; 1]; - const LEN: usize = 1; -} - -unsafe impl Array for [T; 8] { - type Element = T; - type PartialStorage = [ManuallyDrop; 8]; - const LEN: usize = 8; -} - -unsafe impl Array for [T; 32] { - type Element = T; - type PartialStorage = [ManuallyDrop; 32]; - const LEN: usize = 32; -} - -pub struct ArrayVec { - count: usize, - values: A::PartialStorage -} - -impl Hash for ArrayVec - where A: Array, - A::Element: Hash { - fn hash(&self, state: &mut H) where H: Hasher { - (&self[..]).hash(state); - } -} - -impl Clone for ArrayVec - where A: Array, - A::Element: Clone { - fn clone(&self) -> Self { - let mut v = ArrayVec::new(); - v.extend(self.iter().cloned()); - v - } -} - -impl ArrayVec { - pub fn new() -> Self { - ArrayVec { - count: 0, - values: unsafe { ::std::mem::uninitialized() }, - } - } - - pub fn len(&self) -> usize { - self.count - } - - pub unsafe fn set_len(&mut self, len: usize) { - self.count = len; - } - - /// Panics when the stack vector is full. - pub fn push(&mut self, el: A::Element) { - let arr = &mut self.values as &mut [ManuallyDrop<_>]; - arr[self.count] = ManuallyDrop::new(el); - self.count += 1; - } - - pub fn pop(&mut self) -> Option { - if self.count > 0 { - let arr = &mut self.values as &mut [ManuallyDrop<_>]; - self.count -= 1; - unsafe { - let value = ptr::read(&*arr[self.count]); - Some(value) - } - } else { - None - } - } - - pub fn drain(&mut self, range: R) -> Drain - where R: RangeBounds - { - // Memory safety - // - // When the Drain is first created, it shortens the length of - // the source vector to make sure no uninitialized or moved-from elements - // are accessible at all if the Drain's destructor never gets to run. - // - // Drain will ptr::read out the values to remove. - // When finished, remaining tail of the vec is copied back to cover - // the hole, and the vector length is restored to the new length. - // - let len = self.len(); - let start = match range.start_bound() { - Included(&n) => n, - Excluded(&n) => n + 1, - Unbounded => 0, - }; - let end = match range.end_bound() { - Included(&n) => n + 1, - Excluded(&n) => n, - Unbounded => len, - }; - assert!(start <= end); - assert!(end <= len); - - unsafe { - // set self.vec length's to start, to be safe in case Drain is leaked - self.set_len(start); - // Use the borrow in the IterMut to indicate borrowing behavior of the - // whole Drain iterator (like &mut T). - let range_slice = { - let arr = &mut self.values as &mut [ManuallyDrop<::Element>]; - slice::from_raw_parts_mut(arr.as_mut_ptr().add(start), - end - start) - }; - Drain { - tail_start: end, - tail_len: len - end, - iter: range_slice.iter(), - array_vec: NonNull::from(self), - } - } - } -} - -impl Default for ArrayVec - where A: Array { - fn default() -> Self { - ArrayVec::new() - } -} - -impl fmt::Debug for ArrayVec - where A: Array, - A::Element: fmt::Debug { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self[..].fmt(f) - } -} - -impl Deref for ArrayVec { - type Target = [A::Element]; - fn deref(&self) -> &Self::Target { - unsafe { - slice::from_raw_parts(&self.values as *const _ as *const A::Element, self.count) - } - } -} - -impl DerefMut for ArrayVec { - fn deref_mut(&mut self) -> &mut [A::Element] { - unsafe { - slice::from_raw_parts_mut(&mut self.values as *mut _ as *mut A::Element, self.count) - } - } -} - -impl Drop for ArrayVec { - fn drop(&mut self) { - unsafe { - drop_in_place(&mut self[..]) - } - } -} - -impl Extend for ArrayVec { - fn extend(&mut self, iter: I) where I: IntoIterator { - for el in iter { - self.push(el); - } - } -} - -pub struct Iter { - indices: Range, - store: A::PartialStorage, -} - -impl Drop for Iter { - fn drop(&mut self) { - self.for_each(drop); - } -} - -impl Iterator for Iter { - type Item = A::Element; - - fn next(&mut self) -> Option { - let arr = &self.store as &[ManuallyDrop<_>]; - unsafe { - self.indices.next().map(|i| ptr::read(&*arr[i])) - } - } - - fn size_hint(&self) -> (usize, Option) { - self.indices.size_hint() - } -} - -pub struct Drain<'a, A: Array> - where A::Element: 'a -{ - tail_start: usize, - tail_len: usize, - iter: slice::Iter<'a, ManuallyDrop>, - array_vec: NonNull>, -} - -impl<'a, A: Array> Iterator for Drain<'a, A> { - type Item = A::Element; - - #[inline] - fn next(&mut self) -> Option { - self.iter.next().map(|elt| unsafe { ptr::read(&**elt) }) - } - - fn size_hint(&self) -> (usize, Option) { - self.iter.size_hint() - } -} - -impl<'a, A: Array> Drop for Drain<'a, A> { - fn drop(&mut self) { - // exhaust self first - self.for_each(drop); - - if self.tail_len > 0 { - unsafe { - let source_array_vec: &mut ArrayVec = self.array_vec.as_mut(); - // memmove back untouched tail, update to new length - let start = source_array_vec.len(); - let tail = self.tail_start; - { - let arr = - &mut source_array_vec.values as &mut [ManuallyDrop<::Element>]; - let src = arr.as_ptr().add(tail); - let dst = arr.as_mut_ptr().add(start); - ptr::copy(src, dst, self.tail_len); - }; - source_array_vec.set_len(start + self.tail_len); - } - } - } -} - -impl IntoIterator for ArrayVec { - type Item = A::Element; - type IntoIter = Iter; - fn into_iter(self) -> Self::IntoIter { - let store = unsafe { - ptr::read(&self.values) - }; - let indices = 0..self.count; - mem::forget(self); - Iter { - indices, - store, - } - } -} - -impl<'a, A: Array> IntoIterator for &'a ArrayVec { - type Item = &'a A::Element; - type IntoIter = slice::Iter<'a, A::Element>; - fn into_iter(self) -> Self::IntoIter { - self.iter() - } -} - -impl<'a, A: Array> IntoIterator for &'a mut ArrayVec { - type Item = &'a mut A::Element; - type IntoIter = slice::IterMut<'a, A::Element>; - fn into_iter(self) -> Self::IntoIter { - self.iter_mut() - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/bit_set.rs rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/bit_set.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/bit_set.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/bit_set.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,1144 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use indexed_vec::{Idx, IndexVec}; +use smallvec::SmallVec; +use std::fmt; +use std::iter; +use std::marker::PhantomData; +use std::mem; +use std::slice; + +pub type Word = u64; +pub const WORD_BYTES: usize = mem::size_of::(); +pub const WORD_BITS: usize = WORD_BYTES * 8; + +/// A fixed-size bitset type with a dense representation. It does not support +/// resizing after creation; use `GrowableBitSet` for that. +/// +/// `T` is an index type, typically a newtyped `usize` wrapper, but it can also +/// just be `usize`. +/// +/// All operations that involve an element will panic if the element is equal +/// to or greater than the domain size. All operations that involve two bitsets +/// will panic if the bitsets have differing domain sizes. +#[derive(Clone, Eq, PartialEq, RustcDecodable, RustcEncodable)] +pub struct BitSet { + domain_size: usize, + words: Vec, + marker: PhantomData, +} + +impl BitSet { + /// Create a new, empty bitset with a given `domain_size`. + #[inline] + pub fn new_empty(domain_size: usize) -> BitSet { + let num_words = num_words(domain_size); + BitSet { + domain_size, + words: vec![0; num_words], + marker: PhantomData, + } + } + + /// Create a new, filled bitset with a given `domain_size`. + #[inline] + pub fn new_filled(domain_size: usize) -> BitSet { + let num_words = num_words(domain_size); + let mut result = BitSet { + domain_size, + words: vec![!0; num_words], + marker: PhantomData, + }; + result.clear_excess_bits(); + result + } + + /// Get the domain size. + pub fn domain_size(&self) -> usize { + self.domain_size + } + + /// Clear all elements. + #[inline] + pub fn clear(&mut self) { + for word in &mut self.words { + *word = 0; + } + } + + /// Clear excess bits in the final word. + fn clear_excess_bits(&mut self) { + let num_bits_in_final_word = self.domain_size % WORD_BITS; + if num_bits_in_final_word > 0 { + let mask = (1 << num_bits_in_final_word) - 1; + let final_word_idx = self.words.len() - 1; + self.words[final_word_idx] &= mask; + } + } + + /// Efficiently overwrite `self` with `other`. + pub fn overwrite(&mut self, other: &BitSet) { + assert!(self.domain_size == other.domain_size); + self.words.clone_from_slice(&other.words); + } + + /// Count the number of set bits in the set. + pub fn count(&self) -> usize { + self.words.iter().map(|e| e.count_ones() as usize).sum() + } + + /// True if `self` contains `elem`. + #[inline] + pub fn contains(&self, elem: T) -> bool { + assert!(elem.index() < self.domain_size); + let (word_index, mask) = word_index_and_mask(elem); + (self.words[word_index] & mask) != 0 + } + + /// Is `self` is a (non-strict) superset of `other`? + #[inline] + pub fn superset(&self, other: &BitSet) -> bool { + assert_eq!(self.domain_size, other.domain_size); + self.words.iter().zip(&other.words).all(|(a, b)| (a & b) == *b) + } + + /// Is the set empty? + #[inline] + pub fn is_empty(&self) -> bool { + self.words.iter().all(|a| *a == 0) + } + + /// Insert `elem`. Returns true if the set has changed. + #[inline] + pub fn insert(&mut self, elem: T) -> bool { + assert!(elem.index() < self.domain_size); + let (word_index, mask) = word_index_and_mask(elem); + let word_ref = &mut self.words[word_index]; + let word = *word_ref; + let new_word = word | mask; + *word_ref = new_word; + new_word != word + } + + /// Sets all bits to true. + pub fn insert_all(&mut self) { + for word in &mut self.words { + *word = !0; + } + self.clear_excess_bits(); + } + + /// Returns true if the set has changed. + #[inline] + pub fn remove(&mut self, elem: T) -> bool { + assert!(elem.index() < self.domain_size); + let (word_index, mask) = word_index_and_mask(elem); + let word_ref = &mut self.words[word_index]; + let word = *word_ref; + let new_word = word & !mask; + *word_ref = new_word; + new_word != word + } + + /// Set `self = self | other` and return true if `self` changed + /// (i.e., if new bits were added). + pub fn union(&mut self, other: &impl UnionIntoBitSet) -> bool { + other.union_into(self) + } + + /// Set `self = self - other` and return true if `self` changed. + /// (i.e., if any bits were removed). + pub fn subtract(&mut self, other: &impl SubtractFromBitSet) -> bool { + other.subtract_from(self) + } + + /// Set `self = self & other` and return true if `self` changed. + /// (i.e., if any bits were removed). + pub fn intersect(&mut self, other: &BitSet) -> bool { + assert_eq!(self.domain_size, other.domain_size); + bitwise(&mut self.words, &other.words, |a, b| { a & b }) + } + + /// Get a slice of the underlying words. + pub fn words(&self) -> &[Word] { + &self.words + } + + /// Iterates over the indices of set bits in a sorted order. + #[inline] + pub fn iter<'a>(&'a self) -> BitIter<'a, T> { + BitIter { + cur: None, + iter: self.words.iter().enumerate(), + marker: PhantomData, + } + } + + /// Duplicates the set as a hybrid set. + pub fn to_hybrid(&self) -> HybridBitSet { + // Note: we currently don't bother trying to make a Sparse set. + HybridBitSet::Dense(self.to_owned()) + } +} + +/// This is implemented by all the bitsets so that BitSet::union() can be +/// passed any type of bitset. +pub trait UnionIntoBitSet { + // Performs `other = other | self`. + fn union_into(&self, other: &mut BitSet) -> bool; +} + +/// This is implemented by all the bitsets so that BitSet::subtract() can be +/// passed any type of bitset. +pub trait SubtractFromBitSet { + // Performs `other = other - self`. + fn subtract_from(&self, other: &mut BitSet) -> bool; +} + +impl UnionIntoBitSet for BitSet { + fn union_into(&self, other: &mut BitSet) -> bool { + assert_eq!(self.domain_size, other.domain_size); + bitwise(&mut other.words, &self.words, |a, b| { a | b }) + } +} + +impl SubtractFromBitSet for BitSet { + fn subtract_from(&self, other: &mut BitSet) -> bool { + assert_eq!(self.domain_size, other.domain_size); + bitwise(&mut other.words, &self.words, |a, b| { a & !b }) + } +} + +impl fmt::Debug for BitSet { + fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { + w.debug_list() + .entries(self.iter()) + .finish() + } +} + +impl ToString for BitSet { + fn to_string(&self) -> String { + let mut result = String::new(); + let mut sep = '['; + + // Note: this is a little endian printout of bytes. + + // i tracks how many bits we have printed so far. + let mut i = 0; + for word in &self.words { + let mut word = *word; + for _ in 0..WORD_BYTES { // for each byte in `word`: + let remain = self.domain_size - i; + // If less than a byte remains, then mask just that many bits. + let mask = if remain <= 8 { (1 << remain) - 1 } else { 0xFF }; + assert!(mask <= 0xFF); + let byte = word & mask; + + result.push_str(&format!("{}{:02x}", sep, byte)); + + if remain <= 8 { break; } + word >>= 8; + i += 8; + sep = '-'; + } + sep = '|'; + } + result.push(']'); + + result + } +} + +pub struct BitIter<'a, T: Idx> { + cur: Option<(Word, usize)>, + iter: iter::Enumerate>, + marker: PhantomData +} + +impl<'a, T: Idx> Iterator for BitIter<'a, T> { + type Item = T; + fn next(&mut self) -> Option { + loop { + if let Some((ref mut word, offset)) = self.cur { + let bit_pos = word.trailing_zeros() as usize; + if bit_pos != WORD_BITS { + let bit = 1 << bit_pos; + *word ^= bit; + return Some(T::new(bit_pos + offset)) + } + } + + let (i, word) = self.iter.next()?; + self.cur = Some((*word, WORD_BITS * i)); + } + } +} + +pub trait BitSetOperator { + /// Combine one bitset into another. + fn join(&self, inout_set: &mut BitSet, in_set: &BitSet) -> bool; +} + +#[inline] +fn bitwise(out_vec: &mut [Word], in_vec: &[Word], op: Op) -> bool + where Op: Fn(Word, Word) -> Word +{ + assert_eq!(out_vec.len(), in_vec.len()); + let mut changed = false; + for (out_elem, in_elem) in out_vec.iter_mut().zip(in_vec.iter()) { + let old_val = *out_elem; + let new_val = op(old_val, *in_elem); + *out_elem = new_val; + changed |= old_val != new_val; + } + changed +} + +const SPARSE_MAX: usize = 8; + +/// A fixed-size bitset type with a sparse representation and a maximum of +/// `SPARSE_MAX` elements. The elements are stored as a sorted `SmallVec` with +/// no duplicates; although `SmallVec` can spill its elements to the heap, that +/// never happens within this type because of the `SPARSE_MAX` limit. +/// +/// This type is used by `HybridBitSet`; do not use directly. +#[derive(Clone, Debug)] +pub struct SparseBitSet { + domain_size: usize, + elems: SmallVec<[T; SPARSE_MAX]>, +} + +impl SparseBitSet { + fn new_empty(domain_size: usize) -> Self { + SparseBitSet { + domain_size, + elems: SmallVec::new() + } + } + + fn len(&self) -> usize { + self.elems.len() + } + + fn is_empty(&self) -> bool { + self.elems.len() == 0 + } + + fn contains(&self, elem: T) -> bool { + assert!(elem.index() < self.domain_size); + self.elems.contains(&elem) + } + + fn insert(&mut self, elem: T) -> bool { + assert!(elem.index() < self.domain_size); + let changed = if let Some(i) = self.elems.iter().position(|&e| e >= elem) { + if self.elems[i] == elem { + // `elem` is already in the set. + false + } else { + // `elem` is smaller than one or more existing elements. + self.elems.insert(i, elem); + true + } + } else { + // `elem` is larger than all existing elements. + self.elems.push(elem); + true + }; + assert!(self.len() <= SPARSE_MAX); + changed + } + + fn remove(&mut self, elem: T) -> bool { + assert!(elem.index() < self.domain_size); + if let Some(i) = self.elems.iter().position(|&e| e == elem) { + self.elems.remove(i); + true + } else { + false + } + } + + fn to_dense(&self) -> BitSet { + let mut dense = BitSet::new_empty(self.domain_size); + for elem in self.elems.iter() { + dense.insert(*elem); + } + dense + } + + fn iter(&self) -> slice::Iter { + self.elems.iter() + } +} + +impl UnionIntoBitSet for SparseBitSet { + fn union_into(&self, other: &mut BitSet) -> bool { + assert_eq!(self.domain_size, other.domain_size); + let mut changed = false; + for elem in self.iter() { + changed |= other.insert(*elem); + } + changed + } +} + +impl SubtractFromBitSet for SparseBitSet { + fn subtract_from(&self, other: &mut BitSet) -> bool { + assert_eq!(self.domain_size, other.domain_size); + let mut changed = false; + for elem in self.iter() { + changed |= other.remove(*elem); + } + changed + } +} + +/// A fixed-size bitset type with a hybrid representation: sparse when there +/// are up to a `SPARSE_MAX` elements in the set, but dense when there are more +/// than `SPARSE_MAX`. +/// +/// This type is especially efficient for sets that typically have a small +/// number of elements, but a large `domain_size`, and are cleared frequently. +/// +/// `T` is an index type, typically a newtyped `usize` wrapper, but it can also +/// just be `usize`. +/// +/// All operations that involve an element will panic if the element is equal +/// to or greater than the domain size. All operations that involve two bitsets +/// will panic if the bitsets have differing domain sizes. +#[derive(Clone, Debug)] +pub enum HybridBitSet { + Sparse(SparseBitSet), + Dense(BitSet), +} + +impl HybridBitSet { + pub fn new_empty(domain_size: usize) -> Self { + HybridBitSet::Sparse(SparseBitSet::new_empty(domain_size)) + } + + fn domain_size(&self) -> usize { + match self { + HybridBitSet::Sparse(sparse) => sparse.domain_size, + HybridBitSet::Dense(dense) => dense.domain_size, + } + } + + pub fn clear(&mut self) { + let domain_size = self.domain_size(); + *self = HybridBitSet::new_empty(domain_size); + } + + pub fn contains(&self, elem: T) -> bool { + match self { + HybridBitSet::Sparse(sparse) => sparse.contains(elem), + HybridBitSet::Dense(dense) => dense.contains(elem), + } + } + + pub fn superset(&self, other: &HybridBitSet) -> bool { + match (self, other) { + (HybridBitSet::Dense(self_dense), HybridBitSet::Dense(other_dense)) => { + self_dense.superset(other_dense) + } + _ => { + assert!(self.domain_size() == other.domain_size()); + other.iter().all(|elem| self.contains(elem)) + } + } + } + + pub fn is_empty(&self) -> bool { + match self { + HybridBitSet::Sparse(sparse) => sparse.is_empty(), + HybridBitSet::Dense(dense) => dense.is_empty(), + } + } + + pub fn insert(&mut self, elem: T) -> bool { + // No need to check `elem` against `self.domain_size` here because all + // the match cases check it, one way or another. + match self { + HybridBitSet::Sparse(sparse) if sparse.len() < SPARSE_MAX => { + // The set is sparse and has space for `elem`. + sparse.insert(elem) + } + HybridBitSet::Sparse(sparse) if sparse.contains(elem) => { + // The set is sparse and does not have space for `elem`, but + // that doesn't matter because `elem` is already present. + false + } + HybridBitSet::Sparse(sparse) => { + // The set is sparse and full. Convert to a dense set. + let mut dense = sparse.to_dense(); + let changed = dense.insert(elem); + assert!(changed); + *self = HybridBitSet::Dense(dense); + changed + } + HybridBitSet::Dense(dense) => dense.insert(elem), + } + } + + pub fn insert_all(&mut self) { + let domain_size = self.domain_size(); + match self { + HybridBitSet::Sparse(_) => { + *self = HybridBitSet::Dense(BitSet::new_filled(domain_size)); + } + HybridBitSet::Dense(dense) => dense.insert_all(), + } + } + + pub fn remove(&mut self, elem: T) -> bool { + // Note: we currently don't bother going from Dense back to Sparse. + match self { + HybridBitSet::Sparse(sparse) => sparse.remove(elem), + HybridBitSet::Dense(dense) => dense.remove(elem), + } + } + + pub fn union(&mut self, other: &HybridBitSet) -> bool { + match self { + HybridBitSet::Sparse(self_sparse) => { + match other { + HybridBitSet::Sparse(other_sparse) => { + // Both sets are sparse. Add the elements in + // `other_sparse` to `self` one at a time. This + // may or may not cause `self` to be densified. + assert_eq!(self.domain_size(), other.domain_size()); + let mut changed = false; + for elem in other_sparse.iter() { + changed |= self.insert(*elem); + } + changed + } + HybridBitSet::Dense(other_dense) => { + // `self` is sparse and `other` is dense. Densify + // `self` and then do the bitwise union. + let mut new_dense = self_sparse.to_dense(); + let changed = new_dense.union(other_dense); + *self = HybridBitSet::Dense(new_dense); + changed + } + } + } + + HybridBitSet::Dense(self_dense) => self_dense.union(other), + } + } + + /// Converts to a dense set, consuming itself in the process. + pub fn to_dense(self) -> BitSet { + match self { + HybridBitSet::Sparse(sparse) => sparse.to_dense(), + HybridBitSet::Dense(dense) => dense, + } + } + + pub fn iter(&self) -> HybridIter { + match self { + HybridBitSet::Sparse(sparse) => HybridIter::Sparse(sparse.iter()), + HybridBitSet::Dense(dense) => HybridIter::Dense(dense.iter()), + } + } +} + +impl UnionIntoBitSet for HybridBitSet { + fn union_into(&self, other: &mut BitSet) -> bool { + match self { + HybridBitSet::Sparse(sparse) => sparse.union_into(other), + HybridBitSet::Dense(dense) => dense.union_into(other), + } + } +} + +impl SubtractFromBitSet for HybridBitSet { + fn subtract_from(&self, other: &mut BitSet) -> bool { + match self { + HybridBitSet::Sparse(sparse) => sparse.subtract_from(other), + HybridBitSet::Dense(dense) => dense.subtract_from(other), + } + } +} + +pub enum HybridIter<'a, T: Idx> { + Sparse(slice::Iter<'a, T>), + Dense(BitIter<'a, T>), +} + +impl<'a, T: Idx> Iterator for HybridIter<'a, T> { + type Item = T; + + fn next(&mut self) -> Option { + match self { + HybridIter::Sparse(sparse) => sparse.next().map(|e| *e), + HybridIter::Dense(dense) => dense.next(), + } + } +} + +/// A resizable bitset type with a dense representation. +/// +/// `T` is an index type, typically a newtyped `usize` wrapper, but it can also +/// just be `usize`. +/// +/// All operations that involve an element will panic if the element is equal +/// to or greater than the domain size. +#[derive(Clone, Debug, PartialEq)] +pub struct GrowableBitSet { + bit_set: BitSet, +} + +impl GrowableBitSet { + /// Ensure that the set can hold at least `min_domain_size` elements. + pub fn ensure(&mut self, min_domain_size: usize) { + if self.bit_set.domain_size < min_domain_size { + self.bit_set.domain_size = min_domain_size; + } + + let min_num_words = num_words(min_domain_size); + if self.bit_set.words.len() < min_num_words { + self.bit_set.words.resize(min_num_words, 0) + } + } + + pub fn new_empty() -> GrowableBitSet { + GrowableBitSet { bit_set: BitSet::new_empty(0) } + } + + pub fn with_capacity(bits: usize) -> GrowableBitSet { + GrowableBitSet { bit_set: BitSet::new_empty(bits) } + } + + /// Returns true if the set has changed. + #[inline] + pub fn insert(&mut self, elem: T) -> bool { + self.ensure(elem.index() + 1); + self.bit_set.insert(elem) + } + + #[inline] + pub fn contains(&self, elem: T) -> bool { + let (word_index, mask) = word_index_and_mask(elem); + if let Some(word) = self.bit_set.words.get(word_index) { + (word & mask) != 0 + } else { + false + } + } +} + +/// A fixed-size 2D bit matrix type with a dense representation. +/// +/// `R` and `C` are index types used to identify rows and columns respectively; +/// typically newtyped `usize` wrappers, but they can also just be `usize`. +/// +/// All operations that involve a row and/or column index will panic if the +/// index exceeds the relevant bound. +#[derive(Clone, Debug)] +pub struct BitMatrix { + num_rows: usize, + num_columns: usize, + words: Vec, + marker: PhantomData<(R, C)>, +} + +impl BitMatrix { + /// Create a new `rows x columns` matrix, initially empty. + pub fn new(num_rows: usize, num_columns: usize) -> BitMatrix { + // For every element, we need one bit for every other + // element. Round up to an even number of words. + let words_per_row = num_words(num_columns); + BitMatrix { + num_rows, + num_columns, + words: vec![0; num_rows * words_per_row], + marker: PhantomData, + } + } + + /// The range of bits for a given row. + fn range(&self, row: R) -> (usize, usize) { + let words_per_row = num_words(self.num_columns); + let start = row.index() * words_per_row; + (start, start + words_per_row) + } + + /// Sets the cell at `(row, column)` to true. Put another way, insert + /// `column` to the bitset for `row`. + /// + /// Returns true if this changed the matrix, and false otherwise. + pub fn insert(&mut self, row: R, column: C) -> bool { + assert!(row.index() < self.num_rows && column.index() < self.num_columns); + let (start, _) = self.range(row); + let (word_index, mask) = word_index_and_mask(column); + let words = &mut self.words[..]; + let word = words[start + word_index]; + let new_word = word | mask; + words[start + word_index] = new_word; + word != new_word + } + + /// Do the bits from `row` contain `column`? Put another way, is + /// the matrix cell at `(row, column)` true? Put yet another way, + /// if the matrix represents (transitive) reachability, can + /// `row` reach `column`? + pub fn contains(&self, row: R, column: C) -> bool { + assert!(row.index() < self.num_rows && column.index() < self.num_columns); + let (start, _) = self.range(row); + let (word_index, mask) = word_index_and_mask(column); + (self.words[start + word_index] & mask) != 0 + } + + /// Returns those indices that are true in rows `a` and `b`. This + /// is an O(n) operation where `n` is the number of elements + /// (somewhat independent from the actual size of the + /// intersection, in particular). + pub fn intersect_rows(&self, row1: R, row2: R) -> Vec { + assert!(row1.index() < self.num_rows && row2.index() < self.num_rows); + let (row1_start, row1_end) = self.range(row1); + let (row2_start, row2_end) = self.range(row2); + let mut result = Vec::with_capacity(self.num_columns); + for (base, (i, j)) in (row1_start..row1_end).zip(row2_start..row2_end).enumerate() { + let mut v = self.words[i] & self.words[j]; + for bit in 0..WORD_BITS { + if v == 0 { + break; + } + if v & 0x1 != 0 { + result.push(C::new(base * WORD_BITS + bit)); + } + v >>= 1; + } + } + result + } + + /// Add the bits from row `read` to the bits from row `write`, + /// return true if anything changed. + /// + /// This is used when computing transitive reachability because if + /// you have an edge `write -> read`, because in that case + /// `write` can reach everything that `read` can (and + /// potentially more). + pub fn union_rows(&mut self, read: R, write: R) -> bool { + assert!(read.index() < self.num_rows && write.index() < self.num_rows); + let (read_start, read_end) = self.range(read); + let (write_start, write_end) = self.range(write); + let words = &mut self.words[..]; + let mut changed = false; + for (read_index, write_index) in (read_start..read_end).zip(write_start..write_end) { + let word = words[write_index]; + let new_word = word | words[read_index]; + words[write_index] = new_word; + changed |= word != new_word; + } + changed + } + + /// Iterates through all the columns set to true in a given row of + /// the matrix. + pub fn iter<'a>(&'a self, row: R) -> BitIter<'a, C> { + assert!(row.index() < self.num_rows); + let (start, end) = self.range(row); + BitIter { + cur: None, + iter: self.words[start..end].iter().enumerate(), + marker: PhantomData, + } + } +} + +/// A fixed-column-size, variable-row-size 2D bit matrix with a moderately +/// sparse representation. +/// +/// Initially, every row has no explicit representation. If any bit within a +/// row is set, the entire row is instantiated as `Some()`. +/// Furthermore, any previously uninstantiated rows prior to it will be +/// instantiated as `None`. Those prior rows may themselves become fully +/// instantiated later on if any of their bits are set. +/// +/// `R` and `C` are index types used to identify rows and columns respectively; +/// typically newtyped `usize` wrappers, but they can also just be `usize`. +#[derive(Clone, Debug)] +pub struct SparseBitMatrix +where + R: Idx, + C: Idx, +{ + num_columns: usize, + rows: IndexVec>>, +} + +impl SparseBitMatrix { + /// Create a new empty sparse bit matrix with no rows or columns. + pub fn new(num_columns: usize) -> Self { + Self { + num_columns, + rows: IndexVec::new(), + } + } + + fn ensure_row(&mut self, row: R) -> &mut HybridBitSet { + // Instantiate any missing rows up to and including row `row` with an + // empty HybridBitSet. + self.rows.ensure_contains_elem(row, || None); + + // Then replace row `row` with a full HybridBitSet if necessary. + let num_columns = self.num_columns; + self.rows[row].get_or_insert_with(|| HybridBitSet::new_empty(num_columns)) + } + + /// Sets the cell at `(row, column)` to true. Put another way, insert + /// `column` to the bitset for `row`. + /// + /// Returns true if this changed the matrix, and false otherwise. + pub fn insert(&mut self, row: R, column: C) -> bool { + self.ensure_row(row).insert(column) + } + + /// Do the bits from `row` contain `column`? Put another way, is + /// the matrix cell at `(row, column)` true? Put yet another way, + /// if the matrix represents (transitive) reachability, can + /// `row` reach `column`? + pub fn contains(&self, row: R, column: C) -> bool { + self.row(row).map_or(false, |r| r.contains(column)) + } + + /// Add the bits from row `read` to the bits from row `write`, + /// return true if anything changed. + /// + /// This is used when computing transitive reachability because if + /// you have an edge `write -> read`, because in that case + /// `write` can reach everything that `read` can (and + /// potentially more). + pub fn union_rows(&mut self, read: R, write: R) -> bool { + if read == write || self.row(read).is_none() { + return false; + } + + self.ensure_row(write); + if let (Some(read_row), Some(write_row)) = self.rows.pick2_mut(read, write) { + write_row.union(read_row) + } else { + unreachable!() + } + } + + /// Union a row, `from`, into the `into` row. + pub fn union_into_row(&mut self, into: R, from: &HybridBitSet) -> bool { + self.ensure_row(into).union(from) + } + + /// Insert all bits in the given row. + pub fn insert_all_into_row(&mut self, row: R) { + self.ensure_row(row).insert_all(); + } + + pub fn rows(&self) -> impl Iterator { + self.rows.indices() + } + + /// Iterates through all the columns set to true in a given row of + /// the matrix. + pub fn iter<'a>(&'a self, row: R) -> impl Iterator + 'a { + self.row(row).into_iter().flat_map(|r| r.iter()) + } + + pub fn row(&self, row: R) -> Option<&HybridBitSet> { + if let Some(Some(row)) = self.rows.get(row) { + Some(row) + } else { + None + } + } +} + +#[inline] +fn num_words(domain_size: T) -> usize { + (domain_size.index() + WORD_BITS - 1) / WORD_BITS +} + +#[inline] +fn word_index_and_mask(elem: T) -> (usize, Word) { + let elem = elem.index(); + let word_index = elem / WORD_BITS; + let mask = 1 << (elem % WORD_BITS); + (word_index, mask) +} + +#[test] +fn test_new_filled() { + for i in 0..128 { + let idx_buf = BitSet::new_filled(i); + let elems: Vec = idx_buf.iter().collect(); + let expected: Vec = (0..i).collect(); + assert_eq!(elems, expected); + } +} + +#[test] +fn bitset_iter_works() { + let mut bitset: BitSet = BitSet::new_empty(100); + bitset.insert(1); + bitset.insert(10); + bitset.insert(19); + bitset.insert(62); + bitset.insert(63); + bitset.insert(64); + bitset.insert(65); + bitset.insert(66); + bitset.insert(99); + assert_eq!( + bitset.iter().collect::>(), + [1, 10, 19, 62, 63, 64, 65, 66, 99] + ); +} + +#[test] +fn bitset_iter_works_2() { + let mut bitset: BitSet = BitSet::new_empty(320); + bitset.insert(0); + bitset.insert(127); + bitset.insert(191); + bitset.insert(255); + bitset.insert(319); + assert_eq!(bitset.iter().collect::>(), [0, 127, 191, 255, 319]); +} + +#[test] +fn union_two_sets() { + let mut set1: BitSet = BitSet::new_empty(65); + let mut set2: BitSet = BitSet::new_empty(65); + assert!(set1.insert(3)); + assert!(!set1.insert(3)); + assert!(set2.insert(5)); + assert!(set2.insert(64)); + assert!(set1.union(&set2)); + assert!(!set1.union(&set2)); + assert!(set1.contains(3)); + assert!(!set1.contains(4)); + assert!(set1.contains(5)); + assert!(!set1.contains(63)); + assert!(set1.contains(64)); +} + +#[test] +fn hybrid_bitset() { + let mut sparse038: HybridBitSet = HybridBitSet::new_empty(256); + assert!(sparse038.is_empty()); + assert!(sparse038.insert(0)); + assert!(sparse038.insert(1)); + assert!(sparse038.insert(8)); + assert!(sparse038.insert(3)); + assert!(!sparse038.insert(3)); + assert!(sparse038.remove(1)); + assert!(!sparse038.is_empty()); + assert_eq!(sparse038.iter().collect::>(), [0, 3, 8]); + + for i in 0..256 { + if i == 0 || i == 3 || i == 8 { + assert!(sparse038.contains(i)); + } else { + assert!(!sparse038.contains(i)); + } + } + + let mut sparse01358 = sparse038.clone(); + assert!(sparse01358.insert(1)); + assert!(sparse01358.insert(5)); + assert_eq!(sparse01358.iter().collect::>(), [0, 1, 3, 5, 8]); + + let mut dense10 = HybridBitSet::new_empty(256); + for i in 0..10 { + assert!(dense10.insert(i)); + } + assert!(!dense10.is_empty()); + assert_eq!(dense10.iter().collect::>(), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + + let mut dense256 = HybridBitSet::new_empty(256); + assert!(dense256.is_empty()); + dense256.insert_all(); + assert!(!dense256.is_empty()); + for i in 0..256 { + assert!(dense256.contains(i)); + } + + assert!(sparse038.superset(&sparse038)); // sparse + sparse (self) + assert!(sparse01358.superset(&sparse038)); // sparse + sparse + assert!(dense10.superset(&sparse038)); // dense + sparse + assert!(dense10.superset(&dense10)); // dense + dense (self) + assert!(dense256.superset(&dense10)); // dense + dense + + let mut hybrid = sparse038; + assert!(!sparse01358.union(&hybrid)); // no change + assert!(hybrid.union(&sparse01358)); + assert!(hybrid.superset(&sparse01358) && sparse01358.superset(&hybrid)); + assert!(!dense10.union(&sparse01358)); + assert!(!dense256.union(&dense10)); + let mut dense = dense10; + assert!(dense.union(&dense256)); + assert!(dense.superset(&dense256) && dense256.superset(&dense)); + assert!(hybrid.union(&dense256)); + assert!(hybrid.superset(&dense256) && dense256.superset(&hybrid)); + + assert_eq!(dense256.iter().count(), 256); + let mut dense0 = dense256; + for i in 0..256 { + assert!(dense0.remove(i)); + } + assert!(!dense0.remove(0)); + assert!(dense0.is_empty()); +} + +#[test] +fn grow() { + let mut set: GrowableBitSet = GrowableBitSet::with_capacity(65); + for index in 0..65 { + assert!(set.insert(index)); + assert!(!set.insert(index)); + } + set.ensure(128); + + // Check if the bits set before growing are still set + for index in 0..65 { + assert!(set.contains(index)); + } + + // Check if the new bits are all un-set + for index in 65..128 { + assert!(!set.contains(index)); + } + + // Check that we can set all new bits without running out of bounds + for index in 65..128 { + assert!(set.insert(index)); + assert!(!set.insert(index)); + } +} + +#[test] +fn matrix_intersection() { + let mut matrix: BitMatrix = BitMatrix::new(200, 200); + + // (*) Elements reachable from both 2 and 65. + + matrix.insert(2, 3); + matrix.insert(2, 6); + matrix.insert(2, 10); // (*) + matrix.insert(2, 64); // (*) + matrix.insert(2, 65); + matrix.insert(2, 130); + matrix.insert(2, 160); // (*) + + matrix.insert(64, 133); + + matrix.insert(65, 2); + matrix.insert(65, 8); + matrix.insert(65, 10); // (*) + matrix.insert(65, 64); // (*) + matrix.insert(65, 68); + matrix.insert(65, 133); + matrix.insert(65, 160); // (*) + + let intersection = matrix.intersect_rows(2, 64); + assert!(intersection.is_empty()); + + let intersection = matrix.intersect_rows(2, 65); + assert_eq!(intersection, &[10, 64, 160]); +} + +#[test] +fn matrix_iter() { + let mut matrix: BitMatrix = BitMatrix::new(64, 100); + matrix.insert(3, 22); + matrix.insert(3, 75); + matrix.insert(2, 99); + matrix.insert(4, 0); + matrix.union_rows(3, 5); + + let expected = [99]; + let mut iter = expected.iter(); + for i in matrix.iter(2) { + let j = *iter.next().unwrap(); + assert_eq!(i, j); + } + assert!(iter.next().is_none()); + + let expected = [22, 75]; + let mut iter = expected.iter(); + for i in matrix.iter(3) { + let j = *iter.next().unwrap(); + assert_eq!(i, j); + } + assert!(iter.next().is_none()); + + let expected = [0]; + let mut iter = expected.iter(); + for i in matrix.iter(4) { + let j = *iter.next().unwrap(); + assert_eq!(i, j); + } + assert!(iter.next().is_none()); + + let expected = [22, 75]; + let mut iter = expected.iter(); + for i in matrix.iter(5) { + let j = *iter.next().unwrap(); + assert_eq!(i, j); + } + assert!(iter.next().is_none()); +} + +#[test] +fn sparse_matrix_iter() { + let mut matrix: SparseBitMatrix = SparseBitMatrix::new(100); + matrix.insert(3, 22); + matrix.insert(3, 75); + matrix.insert(2, 99); + matrix.insert(4, 0); + matrix.union_rows(3, 5); + + let expected = [99]; + let mut iter = expected.iter(); + for i in matrix.iter(2) { + let j = *iter.next().unwrap(); + assert_eq!(i, j); + } + assert!(iter.next().is_none()); + + let expected = [22, 75]; + let mut iter = expected.iter(); + for i in matrix.iter(3) { + let j = *iter.next().unwrap(); + assert_eq!(i, j); + } + assert!(iter.next().is_none()); + + let expected = [0]; + let mut iter = expected.iter(); + for i in matrix.iter(4) { + let j = *iter.next().unwrap(); + assert_eq!(i, j); + } + assert!(iter.next().is_none()); + + let expected = [22, 75]; + let mut iter = expected.iter(); + for i in matrix.iter(5) { + let j = *iter.next().unwrap(); + assert_eq!(i, j); + } + assert!(iter.next().is_none()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/bitvec.rs rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/bitvec.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/bitvec.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/bitvec.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,781 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use indexed_vec::{Idx, IndexVec}; -use rustc_serialize; -use std::iter; -use std::marker::PhantomData; -use std::slice; - -pub type Word = u64; -pub const WORD_BYTES: usize = ::std::mem::size_of::(); -pub const WORD_BITS: usize = WORD_BYTES * 8; - -/// A very simple BitArray type. -/// -/// It does not support resizing after creation; use `BitVector` for that. -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct BitArray { - data: Vec, - marker: PhantomData, -} - -impl BitArray { - // Do not make this method public, instead switch your use case to BitVector. - #[inline] - fn grow(&mut self, num_bits: C) { - let num_words = num_words(num_bits); - if self.data.len() <= num_words { - self.data.resize(num_words + 1, 0) - } - } - - #[inline] - pub fn new(num_bits: usize) -> BitArray { - BitArray::new_empty(num_bits) - } - - #[inline] - pub fn new_empty(num_bits: usize) -> BitArray { - let num_words = num_words(num_bits); - BitArray { - data: vec![0; num_words], - marker: PhantomData, - } - } - - #[inline] - pub fn new_filled(num_bits: usize) -> BitArray { - let num_words = num_words(num_bits); - let mut result = BitArray { - data: vec![!0; num_words], - marker: PhantomData, - }; - result.clear_above(num_bits); - result - } - - #[inline] - pub fn clear(&mut self) { - for p in &mut self.data { - *p = 0; - } - } - - /// Sets all elements up to `num_bits`. - pub fn set_up_to(&mut self, num_bits: usize) { - for p in &mut self.data { - *p = !0; - } - self.clear_above(num_bits); - } - - /// Clear all elements above `num_bits`. - fn clear_above(&mut self, num_bits: usize) { - let first_clear_block = num_bits / WORD_BITS; - - if first_clear_block < self.data.len() { - // Within `first_clear_block`, the `num_bits % WORD_BITS` LSBs - // should remain. - let mask = (1 << (num_bits % WORD_BITS)) - 1; - self.data[first_clear_block] &= mask; - - // All the blocks above `first_clear_block` are fully cleared. - for b in &mut self.data[first_clear_block + 1..] { - *b = 0; - } - } - } - - pub fn count(&self) -> usize { - self.data.iter().map(|e| e.count_ones() as usize).sum() - } - - /// True if `self` contains the bit `bit`. - #[inline] - pub fn contains(&self, bit: C) -> bool { - let (word, mask) = word_mask(bit); - (self.data[word] & mask) != 0 - } - - /// True if `self` contains all the bits in `other`. - /// - /// The two vectors must have the same length. - #[inline] - pub fn contains_all(&self, other: &BitArray) -> bool { - assert_eq!(self.data.len(), other.data.len()); - self.data.iter().zip(&other.data).all(|(a, b)| (a & b) == *b) - } - - #[inline] - pub fn is_empty(&self) -> bool { - self.data.iter().all(|a| *a == 0) - } - - /// Returns true if the bit has changed. - #[inline] - pub fn insert(&mut self, bit: C) -> bool { - let (word, mask) = word_mask(bit); - let data = &mut self.data[word]; - let value = *data; - let new_value = value | mask; - *data = new_value; - new_value != value - } - - /// Sets all bits to true. - pub fn insert_all(&mut self) { - for data in &mut self.data { - *data = !0; - } - } - - /// Returns true if the bit has changed. - #[inline] - pub fn remove(&mut self, bit: C) -> bool { - let (word, mask) = word_mask(bit); - let data = &mut self.data[word]; - let value = *data; - let new_value = value & !mask; - *data = new_value; - new_value != value - } - - #[inline] - pub fn merge(&mut self, all: &BitArray) -> bool { - assert!(self.data.len() == all.data.len()); - let mut changed = false; - for (i, j) in self.data.iter_mut().zip(&all.data) { - let value = *i; - *i = value | *j; - if value != *i { - changed = true; - } - } - changed - } - - pub fn words(&self) -> &[Word] { - &self.data - } - - pub fn words_mut(&mut self) -> &mut [Word] { - &mut self.data - } - - /// Iterates over indexes of set bits in a sorted order - #[inline] - pub fn iter<'a>(&'a self) -> BitIter<'a, C> { - BitIter { - cur: None, - iter: self.data.iter().enumerate(), - marker: PhantomData, - } - } -} - -impl rustc_serialize::Encodable for BitArray { - fn encode(&self, encoder: &mut E) -> Result<(), E::Error> { - self.data.encode(encoder) - } -} - -impl rustc_serialize::Decodable for BitArray { - fn decode(d: &mut D) -> Result, D::Error> { - let words: Vec = rustc_serialize::Decodable::decode(d)?; - Ok(BitArray { - data: words, - marker: PhantomData, - }) - } -} - -pub struct BitIter<'a, C: Idx> { - cur: Option<(Word, usize)>, - iter: iter::Enumerate>, - marker: PhantomData -} - -impl<'a, C: Idx> Iterator for BitIter<'a, C> { - type Item = C; - fn next(&mut self) -> Option { - loop { - if let Some((ref mut word, offset)) = self.cur { - let bit_pos = word.trailing_zeros() as usize; - if bit_pos != WORD_BITS { - let bit = 1 << bit_pos; - *word ^= bit; - return Some(C::new(bit_pos + offset)) - } - } - - let (i, word) = self.iter.next()?; - self.cur = Some((*word, WORD_BITS * i)); - } - } -} - -pub trait BitwiseOperator { - /// Applies some bit-operation pointwise to each of the bits in the two inputs. - fn join(&self, pred1: Word, pred2: Word) -> Word; -} - -#[inline] -pub fn bitwise(out_vec: &mut [Word], in_vec: &[Word], op: &Op) -> bool -{ - assert_eq!(out_vec.len(), in_vec.len()); - let mut changed = false; - for (out_elem, in_elem) in out_vec.iter_mut().zip(in_vec.iter()) { - let old_val = *out_elem; - let new_val = op.join(old_val, *in_elem); - *out_elem = new_val; - changed |= old_val != new_val; - } - changed -} - -pub struct Intersect; -impl BitwiseOperator for Intersect { - #[inline] - fn join(&self, a: Word, b: Word) -> Word { a & b } -} - -pub struct Union; -impl BitwiseOperator for Union { - #[inline] - fn join(&self, a: Word, b: Word) -> Word { a | b } -} - -pub struct Subtract; -impl BitwiseOperator for Subtract { - #[inline] - fn join(&self, a: Word, b: Word) -> Word { a & !b } -} - -pub fn bits_to_string(words: &[Word], bits: usize) -> String { - let mut result = String::new(); - let mut sep = '['; - - // Note: this is a little endian printout of bytes. - - // i tracks how many bits we have printed so far. - let mut i = 0; - for &word in words.iter() { - let mut v = word; - for _ in 0..WORD_BYTES { // for each byte in `v`: - let remain = bits - i; - // If less than a byte remains, then mask just that many bits. - let mask = if remain <= 8 { (1 << remain) - 1 } else { 0xFF }; - assert!(mask <= 0xFF); - let byte = v & mask; - - result.push_str(&format!("{}{:02x}", sep, byte)); - - if remain <= 8 { break; } - v >>= 8; - i += 8; - sep = '-'; - } - sep = '|'; - } - result.push(']'); - - result -} - -/// A resizable BitVector type. -#[derive(Clone, Debug, PartialEq)] -pub struct BitVector { - data: BitArray, -} - -impl BitVector { - pub fn grow(&mut self, num_bits: C) { - self.data.grow(num_bits) - } - - pub fn new() -> BitVector { - BitVector { data: BitArray::new(0) } - } - - pub fn with_capacity(bits: usize) -> BitVector { - BitVector { data: BitArray::new(bits) } - } - - /// Returns true if the bit has changed. - #[inline] - pub fn insert(&mut self, bit: C) -> bool { - self.grow(bit); - self.data.insert(bit) - } - - #[inline] - pub fn contains(&self, bit: C) -> bool { - let (word, mask) = word_mask(bit); - if let Some(word) = self.data.data.get(word) { - (word & mask) != 0 - } else { - false - } - } -} - -/// A "bit matrix" is basically a matrix of booleans represented as -/// one gigantic bitvector. In other words, it is as if you have -/// `rows` bitvectors, each of length `columns`. -#[derive(Clone, Debug)] -pub struct BitMatrix { - columns: usize, - vector: Vec, - phantom: PhantomData<(R, C)>, -} - -impl BitMatrix { - /// Create a new `rows x columns` matrix, initially empty. - pub fn new(rows: usize, columns: usize) -> BitMatrix { - // For every element, we need one bit for every other - // element. Round up to an even number of words. - let words_per_row = num_words(columns); - BitMatrix { - columns, - vector: vec![0; rows * words_per_row], - phantom: PhantomData, - } - } - - /// The range of bits for a given row. - fn range(&self, row: R) -> (usize, usize) { - let row = row.index(); - let words_per_row = num_words(self.columns); - let start = row * words_per_row; - (start, start + words_per_row) - } - - /// Sets the cell at `(row, column)` to true. Put another way, add - /// `column` to the bitset for `row`. - /// - /// Returns true if this changed the matrix, and false otherwise. - pub fn add(&mut self, row: R, column: R) -> bool { - let (start, _) = self.range(row); - let (word, mask) = word_mask(column); - let vector = &mut self.vector[..]; - let v1 = vector[start + word]; - let v2 = v1 | mask; - vector[start + word] = v2; - v1 != v2 - } - - /// Do the bits from `row` contain `column`? Put another way, is - /// the matrix cell at `(row, column)` true? Put yet another way, - /// if the matrix represents (transitive) reachability, can - /// `row` reach `column`? - pub fn contains(&self, row: R, column: R) -> bool { - let (start, _) = self.range(row); - let (word, mask) = word_mask(column); - (self.vector[start + word] & mask) != 0 - } - - /// Returns those indices that are true in rows `a` and `b`. This - /// is an O(n) operation where `n` is the number of elements - /// (somewhat independent from the actual size of the - /// intersection, in particular). - pub fn intersection(&self, a: R, b: R) -> Vec { - let (a_start, a_end) = self.range(a); - let (b_start, b_end) = self.range(b); - let mut result = Vec::with_capacity(self.columns); - for (base, (i, j)) in (a_start..a_end).zip(b_start..b_end).enumerate() { - let mut v = self.vector[i] & self.vector[j]; - for bit in 0..WORD_BITS { - if v == 0 { - break; - } - if v & 0x1 != 0 { - result.push(C::new(base * WORD_BITS + bit)); - } - v >>= 1; - } - } - result - } - - /// Add the bits from row `read` to the bits from row `write`, - /// return true if anything changed. - /// - /// This is used when computing transitive reachability because if - /// you have an edge `write -> read`, because in that case - /// `write` can reach everything that `read` can (and - /// potentially more). - pub fn merge(&mut self, read: R, write: R) -> bool { - let (read_start, read_end) = self.range(read); - let (write_start, write_end) = self.range(write); - let vector = &mut self.vector[..]; - let mut changed = false; - for (read_index, write_index) in (read_start..read_end).zip(write_start..write_end) { - let v1 = vector[write_index]; - let v2 = v1 | vector[read_index]; - vector[write_index] = v2; - changed |= v1 != v2; - } - changed - } - - /// Iterates through all the columns set to true in a given row of - /// the matrix. - pub fn iter<'a>(&'a self, row: R) -> BitIter<'a, C> { - let (start, end) = self.range(row); - BitIter { - cur: None, - iter: self.vector[start..end].iter().enumerate(), - marker: PhantomData, - } - } -} - -/// A moderately sparse bit matrix, in which rows are instantiated lazily. -/// -/// Initially, every row has no explicit representation. If any bit within a -/// row is set, the entire row is instantiated as -/// `Some()`. Furthermore, any previously -/// uninstantiated rows prior to it will be instantiated as `None`. Those prior -/// rows may themselves become fully instantiated later on if any of their bits -/// are set. -#[derive(Clone, Debug)] -pub struct SparseBitMatrix -where - R: Idx, - C: Idx, -{ - num_columns: usize, - rows: IndexVec>>, -} - -impl SparseBitMatrix { - /// Create a new empty sparse bit matrix with no rows or columns. - pub fn new(num_columns: usize) -> Self { - Self { - num_columns, - rows: IndexVec::new(), - } - } - - fn ensure_row(&mut self, row: R) -> &mut BitArray { - // Instantiate any missing rows up to and including row `row` with an - // empty BitArray. - self.rows.ensure_contains_elem(row, || None); - - // Then replace row `row` with a full BitArray if necessary. - let num_columns = self.num_columns; - self.rows[row].get_or_insert_with(|| BitArray::new(num_columns)) - } - - /// Sets the cell at `(row, column)` to true. Put another way, insert - /// `column` to the bitset for `row`. - /// - /// Returns true if this changed the matrix, and false otherwise. - pub fn add(&mut self, row: R, column: C) -> bool { - self.ensure_row(row).insert(column) - } - - /// Do the bits from `row` contain `column`? Put another way, is - /// the matrix cell at `(row, column)` true? Put yet another way, - /// if the matrix represents (transitive) reachability, can - /// `row` reach `column`? - pub fn contains(&self, row: R, column: C) -> bool { - self.row(row).map_or(false, |r| r.contains(column)) - } - - /// Add the bits from row `read` to the bits from row `write`, - /// return true if anything changed. - /// - /// This is used when computing transitive reachability because if - /// you have an edge `write -> read`, because in that case - /// `write` can reach everything that `read` can (and - /// potentially more). - pub fn merge(&mut self, read: R, write: R) -> bool { - if read == write || self.row(read).is_none() { - return false; - } - - self.ensure_row(write); - if let (Some(bitvec_read), Some(bitvec_write)) = self.rows.pick2_mut(read, write) { - bitvec_write.merge(bitvec_read) - } else { - unreachable!() - } - } - - /// Merge a row, `from`, into the `into` row. - pub fn merge_into(&mut self, into: R, from: &BitArray) -> bool { - self.ensure_row(into).merge(from) - } - - /// Add all bits to the given row. - pub fn add_all(&mut self, row: R) { - self.ensure_row(row).insert_all(); - } - - pub fn rows(&self) -> impl Iterator { - self.rows.indices() - } - - /// Iterates through all the columns set to true in a given row of - /// the matrix. - pub fn iter<'a>(&'a self, row: R) -> impl Iterator + 'a { - self.row(row).into_iter().flat_map(|r| r.iter()) - } - - pub fn row(&self, row: R) -> Option<&BitArray> { - if let Some(Some(row)) = self.rows.get(row) { - Some(row) - } else { - None - } - } -} - -#[inline] -fn num_words(elements: C) -> usize { - (elements.index() + WORD_BITS - 1) / WORD_BITS -} - -#[inline] -fn word_mask(index: C) -> (usize, Word) { - let index = index.index(); - let word = index / WORD_BITS; - let mask = 1 << (index % WORD_BITS); - (word, mask) -} - -#[test] -fn test_clear_above() { - use std::cmp; - - for i in 0..256 { - let mut idx_buf: BitArray = BitArray::new_filled(128); - idx_buf.clear_above(i); - - let elems: Vec = idx_buf.iter().collect(); - let expected: Vec = (0..cmp::min(i, 128)).collect(); - assert_eq!(elems, expected); - } -} - -#[test] -fn test_set_up_to() { - for i in 0..128 { - for mut idx_buf in - vec![BitArray::new_empty(128), BitArray::new_filled(128)] - .into_iter() - { - idx_buf.set_up_to(i); - - let elems: Vec = idx_buf.iter().collect(); - let expected: Vec = (0..i).collect(); - assert_eq!(elems, expected); - } - } -} - -#[test] -fn test_new_filled() { - for i in 0..128 { - let idx_buf = BitArray::new_filled(i); - let elems: Vec = idx_buf.iter().collect(); - let expected: Vec = (0..i).collect(); - assert_eq!(elems, expected); - } -} - -#[test] -fn bitvec_iter_works() { - let mut bitvec: BitArray = BitArray::new(100); - bitvec.insert(1); - bitvec.insert(10); - bitvec.insert(19); - bitvec.insert(62); - bitvec.insert(63); - bitvec.insert(64); - bitvec.insert(65); - bitvec.insert(66); - bitvec.insert(99); - assert_eq!( - bitvec.iter().collect::>(), - [1, 10, 19, 62, 63, 64, 65, 66, 99] - ); -} - -#[test] -fn bitvec_iter_works_2() { - let mut bitvec: BitArray = BitArray::new(319); - bitvec.insert(0); - bitvec.insert(127); - bitvec.insert(191); - bitvec.insert(255); - bitvec.insert(319); - assert_eq!(bitvec.iter().collect::>(), [0, 127, 191, 255, 319]); -} - -#[test] -fn union_two_vecs() { - let mut vec1: BitArray = BitArray::new(65); - let mut vec2: BitArray = BitArray::new(65); - assert!(vec1.insert(3)); - assert!(!vec1.insert(3)); - assert!(vec2.insert(5)); - assert!(vec2.insert(64)); - assert!(vec1.merge(&vec2)); - assert!(!vec1.merge(&vec2)); - assert!(vec1.contains(3)); - assert!(!vec1.contains(4)); - assert!(vec1.contains(5)); - assert!(!vec1.contains(63)); - assert!(vec1.contains(64)); -} - -#[test] -fn grow() { - let mut vec1: BitVector = BitVector::with_capacity(65); - for index in 0..65 { - assert!(vec1.insert(index)); - assert!(!vec1.insert(index)); - } - vec1.grow(128); - - // Check if the bits set before growing are still set - for index in 0..65 { - assert!(vec1.contains(index)); - } - - // Check if the new bits are all un-set - for index in 65..128 { - assert!(!vec1.contains(index)); - } - - // Check that we can set all new bits without running out of bounds - for index in 65..128 { - assert!(vec1.insert(index)); - assert!(!vec1.insert(index)); - } -} - -#[test] -fn matrix_intersection() { - let mut vec1: BitMatrix = BitMatrix::new(200, 200); - - // (*) Elements reachable from both 2 and 65. - - vec1.add(2, 3); - vec1.add(2, 6); - vec1.add(2, 10); // (*) - vec1.add(2, 64); // (*) - vec1.add(2, 65); - vec1.add(2, 130); - vec1.add(2, 160); // (*) - - vec1.add(64, 133); - - vec1.add(65, 2); - vec1.add(65, 8); - vec1.add(65, 10); // (*) - vec1.add(65, 64); // (*) - vec1.add(65, 68); - vec1.add(65, 133); - vec1.add(65, 160); // (*) - - let intersection = vec1.intersection(2, 64); - assert!(intersection.is_empty()); - - let intersection = vec1.intersection(2, 65); - assert_eq!(intersection, &[10, 64, 160]); -} - -#[test] -fn matrix_iter() { - let mut matrix: BitMatrix = BitMatrix::new(64, 100); - matrix.add(3, 22); - matrix.add(3, 75); - matrix.add(2, 99); - matrix.add(4, 0); - matrix.merge(3, 5); - - let expected = [99]; - let mut iter = expected.iter(); - for i in matrix.iter(2) { - let j = *iter.next().unwrap(); - assert_eq!(i, j); - } - assert!(iter.next().is_none()); - - let expected = [22, 75]; - let mut iter = expected.iter(); - for i in matrix.iter(3) { - let j = *iter.next().unwrap(); - assert_eq!(i, j); - } - assert!(iter.next().is_none()); - - let expected = [0]; - let mut iter = expected.iter(); - for i in matrix.iter(4) { - let j = *iter.next().unwrap(); - assert_eq!(i, j); - } - assert!(iter.next().is_none()); - - let expected = [22, 75]; - let mut iter = expected.iter(); - for i in matrix.iter(5) { - let j = *iter.next().unwrap(); - assert_eq!(i, j); - } - assert!(iter.next().is_none()); -} - -#[test] -fn sparse_matrix_iter() { - let mut matrix: SparseBitMatrix = SparseBitMatrix::new(100); - matrix.add(3, 22); - matrix.add(3, 75); - matrix.add(2, 99); - matrix.add(4, 0); - matrix.merge(3, 5); - - let expected = [99]; - let mut iter = expected.iter(); - for i in matrix.iter(2) { - let j = *iter.next().unwrap(); - assert_eq!(i, j); - } - assert!(iter.next().is_none()); - - let expected = [22, 75]; - let mut iter = expected.iter(); - for i in matrix.iter(3) { - let j = *iter.next().unwrap(); - assert_eq!(i, j); - } - assert!(iter.next().is_none()); - - let expected = [0]; - let mut iter = expected.iter(); - for i in matrix.iter(4) { - let j = *iter.next().unwrap(); - assert_eq!(i, j); - } - assert!(iter.next().is_none()); - - let expected = [22, 75]; - let mut iter = expected.iter(); - for i in matrix.iter(5) { - let j = *iter.next().unwrap(); - assert_eq!(i, j); - } - assert!(iter.next().is_none()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/Cargo.toml 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/Cargo.toml 2018-12-04 23:41:40.000000000 +0000 @@ -13,6 +13,7 @@ log = "0.4" rustc_cratesio_shim = { path = "../librustc_cratesio_shim" } serialize = { path = "../libserialize" } +graphviz = { path = "../libgraphviz" } cfg-if = "0.1.2" stable_deref_trait = "1.0.0" parking_lot_core = "0.2.8" diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/fx.rs rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/fx.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/fx.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/fx.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,21 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::collections::{HashMap, HashSet}; -use std::default::Default; -use std::hash::Hash; - pub use rustc_hash::FxHashMap; pub use rustc_hash::FxHashSet; pub use rustc_hash::FxHasher; - -#[allow(non_snake_case)] -pub fn FxHashMap() -> FxHashMap { - HashMap::default() -} - -#[allow(non_snake_case)] -pub fn FxHashSet() -> FxHashSet { - HashSet::default() -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/graph/implementation/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/graph/implementation/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/graph/implementation/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/graph/implementation/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -30,7 +30,7 @@ //! the field `next_edge`). Each of those fields is an array that should //! be indexed by the direction (see the type `Direction`). -use bitvec::BitArray; +use bit_set::BitSet; use std::fmt::Debug; use std::usize; use snapshot_vec::{SnapshotVec, SnapshotVecDelegate}; @@ -266,7 +266,7 @@ direction: Direction, entry_node: NodeIndex, ) -> Vec { - let mut visited = BitArray::new(self.len_nodes()); + let mut visited = BitSet::new_empty(self.len_nodes()); let mut stack = vec![]; let mut result = Vec::with_capacity(self.len_nodes()); let mut push_node = |stack: &mut Vec<_>, node: NodeIndex| { @@ -348,7 +348,7 @@ { graph: &'g Graph, stack: Vec, - visited: BitArray, + visited: BitSet, direction: Direction, } @@ -358,7 +358,7 @@ start_node: NodeIndex, direction: Direction, ) -> Self { - let mut visited = BitArray::new(graph.len_nodes()); + let mut visited = BitSet::new_empty(graph.len_nodes()); visited.insert(start_node.node_id()); DepthFirstTraversal { graph, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/indexed_set.rs rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/indexed_set.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/indexed_set.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/indexed_set.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,358 +0,0 @@ -// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use array_vec::ArrayVec; -use std::fmt; -use std::mem; -use std::slice; -use bitvec::{bitwise, BitArray, BitIter, Intersect, Subtract, Union, Word, WORD_BITS}; -use indexed_vec::Idx; -use rustc_serialize; - -/// This is implemented by all the index sets so that IdxSet::union() can be -/// passed any type of index set. -pub trait UnionIntoIdxSet { - // Performs `other = other | self`. - fn union_into(&self, other: &mut IdxSet) -> bool; -} - -/// This is implemented by all the index sets so that IdxSet::subtract() can be -/// passed any type of index set. -pub trait SubtractFromIdxSet { - // Performs `other = other - self`. - fn subtract_from(&self, other: &mut IdxSet) -> bool; -} - -/// Represents a set of some element type E, where each E is identified by some -/// unique index type `T`. -/// -/// In other words, `T` is the type used to index into the bitvector -/// this type uses to represent the set of object it holds. -/// -/// The representation is dense, using one bit per possible element. -#[derive(Clone, Eq, PartialEq)] -pub struct IdxSet(BitArray); - -impl rustc_serialize::Encodable for IdxSet { - fn encode(&self, encoder: &mut E) -> Result<(), E::Error> { - self.0.encode(encoder) - } -} - -impl rustc_serialize::Decodable for IdxSet { - fn decode(d: &mut D) -> Result, D::Error> { - Ok(IdxSet(rustc_serialize::Decodable::decode(d)?)) - } -} - -impl fmt::Debug for IdxSet { - fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { - w.debug_list() - .entries(self.iter()) - .finish() - } -} - -impl IdxSet { - /// Creates set holding no elements. - pub fn new_empty(domain_size: usize) -> Self { - IdxSet(BitArray::new_empty(domain_size)) - } - - /// Creates set holding every element whose index falls in range 0..domain_size. - pub fn new_filled(domain_size: usize) -> Self { - IdxSet(BitArray::new_filled(domain_size)) - } - - /// Duplicates as a hybrid set. - pub fn to_hybrid(&self) -> HybridIdxSet { - // This domain_size may be slightly larger than the one specified - // upon creation, due to rounding up to a whole word. That's ok. - let domain_size = self.words().len() * WORD_BITS; - - // Note: we currently don't bother trying to make a Sparse set. - HybridIdxSet::Dense(self.to_owned(), domain_size) - } - - /// Removes all elements - pub fn clear(&mut self) { - self.0.clear(); - } - - /// Sets all elements up to `domain_size` - pub fn set_up_to(&mut self, domain_size: usize) { - self.0.set_up_to(domain_size); - } - - /// Removes `elem` from the set `self`; returns true iff this changed `self`. - pub fn remove(&mut self, elem: &T) -> bool { - self.0.remove(*elem) - } - - /// Adds `elem` to the set `self`; returns true iff this changed `self`. - pub fn add(&mut self, elem: &T) -> bool { - self.0.insert(*elem) - } - - /// Returns true iff set `self` contains `elem`. - pub fn contains(&self, elem: &T) -> bool { - self.0.contains(*elem) - } - - pub fn words(&self) -> &[Word] { - self.0.words() - } - - pub fn words_mut(&mut self) -> &mut [Word] { - self.0.words_mut() - } - - /// Efficiently overwrite `self` with `other`. Panics if `self` and `other` - /// don't have the same length. - pub fn overwrite(&mut self, other: &IdxSet) { - self.words_mut().clone_from_slice(other.words()); - } - - /// Set `self = self | other` and return true if `self` changed - /// (i.e., if new bits were added). - pub fn union(&mut self, other: &impl UnionIntoIdxSet) -> bool { - other.union_into(self) - } - - /// Set `self = self - other` and return true if `self` changed. - /// (i.e., if any bits were removed). - pub fn subtract(&mut self, other: &impl SubtractFromIdxSet) -> bool { - other.subtract_from(self) - } - - /// Set `self = self & other` and return true if `self` changed. - /// (i.e., if any bits were removed). - pub fn intersect(&mut self, other: &IdxSet) -> bool { - bitwise(self.words_mut(), other.words(), &Intersect) - } - - pub fn iter(&self) -> BitIter { - self.0.iter() - } -} - -impl UnionIntoIdxSet for IdxSet { - fn union_into(&self, other: &mut IdxSet) -> bool { - bitwise(other.words_mut(), self.words(), &Union) - } -} - -impl SubtractFromIdxSet for IdxSet { - fn subtract_from(&self, other: &mut IdxSet) -> bool { - bitwise(other.words_mut(), self.words(), &Subtract) - } -} - -const SPARSE_MAX: usize = 8; - -/// A sparse index set with a maximum of SPARSE_MAX elements. Used by -/// HybridIdxSet; do not use directly. -/// -/// The elements are stored as an unsorted vector with no duplicates. -#[derive(Clone, Debug)] -pub struct SparseIdxSet(ArrayVec<[T; SPARSE_MAX]>); - -impl SparseIdxSet { - fn new() -> Self { - SparseIdxSet(ArrayVec::new()) - } - - fn len(&self) -> usize { - self.0.len() - } - - fn contains(&self, elem: &T) -> bool { - self.0.contains(elem) - } - - fn add(&mut self, elem: &T) -> bool { - // Ensure there are no duplicates. - if self.0.contains(elem) { - false - } else { - self.0.push(*elem); - true - } - } - - fn remove(&mut self, elem: &T) -> bool { - if let Some(i) = self.0.iter().position(|e| e == elem) { - // Swap the found element to the end, then pop it. - let len = self.0.len(); - self.0.swap(i, len - 1); - self.0.pop(); - true - } else { - false - } - } - - fn to_dense(&self, domain_size: usize) -> IdxSet { - let mut dense = IdxSet::new_empty(domain_size); - for elem in self.0.iter() { - dense.add(elem); - } - dense - } - - fn iter(&self) -> slice::Iter { - self.0.iter() - } -} - -impl UnionIntoIdxSet for SparseIdxSet { - fn union_into(&self, other: &mut IdxSet) -> bool { - let mut changed = false; - for elem in self.iter() { - changed |= other.add(&elem); - } - changed - } -} - -impl SubtractFromIdxSet for SparseIdxSet { - fn subtract_from(&self, other: &mut IdxSet) -> bool { - let mut changed = false; - for elem in self.iter() { - changed |= other.remove(&elem); - } - changed - } -} - -/// Like IdxSet, but with a hybrid representation: sparse when there are few -/// elements in the set, but dense when there are many. It's especially -/// efficient for sets that typically have a small number of elements, but a -/// large `domain_size`, and are cleared frequently. -#[derive(Clone, Debug)] -pub enum HybridIdxSet { - Sparse(SparseIdxSet, usize), - Dense(IdxSet, usize), -} - -impl HybridIdxSet { - pub fn new_empty(domain_size: usize) -> Self { - HybridIdxSet::Sparse(SparseIdxSet::new(), domain_size) - } - - pub fn clear(&mut self) { - let domain_size = match *self { - HybridIdxSet::Sparse(_, size) => size, - HybridIdxSet::Dense(_, size) => size, - }; - *self = HybridIdxSet::new_empty(domain_size); - } - - /// Returns true iff set `self` contains `elem`. - pub fn contains(&self, elem: &T) -> bool { - match self { - HybridIdxSet::Sparse(sparse, _) => sparse.contains(elem), - HybridIdxSet::Dense(dense, _) => dense.contains(elem), - } - } - - /// Adds `elem` to the set `self`. - pub fn add(&mut self, elem: &T) -> bool { - match self { - HybridIdxSet::Sparse(sparse, _) if sparse.len() < SPARSE_MAX => { - // The set is sparse and has space for `elem`. - sparse.add(elem) - } - HybridIdxSet::Sparse(sparse, _) if sparse.contains(elem) => { - // The set is sparse and does not have space for `elem`, but - // that doesn't matter because `elem` is already present. - false - } - HybridIdxSet::Sparse(_, _) => { - // The set is sparse and full. Convert to a dense set. - // - // FIXME: This code is awful, but I can't work out how else to - // appease the borrow checker. - let dummy = HybridIdxSet::Sparse(SparseIdxSet::new(), 0); - match mem::replace(self, dummy) { - HybridIdxSet::Sparse(sparse, domain_size) => { - let mut dense = sparse.to_dense(domain_size); - let changed = dense.add(elem); - assert!(changed); - mem::replace(self, HybridIdxSet::Dense(dense, domain_size)); - changed - } - _ => panic!("impossible"), - } - } - - HybridIdxSet::Dense(dense, _) => dense.add(elem), - } - } - - /// Removes `elem` from the set `self`. - pub fn remove(&mut self, elem: &T) -> bool { - // Note: we currently don't bother going from Dense back to Sparse. - match self { - HybridIdxSet::Sparse(sparse, _) => sparse.remove(elem), - HybridIdxSet::Dense(dense, _) => dense.remove(elem), - } - } - - /// Converts to a dense set, consuming itself in the process. - pub fn to_dense(self) -> IdxSet { - match self { - HybridIdxSet::Sparse(sparse, domain_size) => sparse.to_dense(domain_size), - HybridIdxSet::Dense(dense, _) => dense, - } - } - - /// Iteration order is unspecified. - pub fn iter(&self) -> HybridIter { - match self { - HybridIdxSet::Sparse(sparse, _) => HybridIter::Sparse(sparse.iter()), - HybridIdxSet::Dense(dense, _) => HybridIter::Dense(dense.iter()), - } - } -} - -impl UnionIntoIdxSet for HybridIdxSet { - fn union_into(&self, other: &mut IdxSet) -> bool { - match self { - HybridIdxSet::Sparse(sparse, _) => sparse.union_into(other), - HybridIdxSet::Dense(dense, _) => dense.union_into(other), - } - } -} - -impl SubtractFromIdxSet for HybridIdxSet { - fn subtract_from(&self, other: &mut IdxSet) -> bool { - match self { - HybridIdxSet::Sparse(sparse, _) => sparse.subtract_from(other), - HybridIdxSet::Dense(dense, _) => dense.subtract_from(other), - } - } -} - -pub enum HybridIter<'a, T: Idx> { - Sparse(slice::Iter<'a, T>), - Dense(BitIter<'a, T>), -} - -impl<'a, T: Idx> Iterator for HybridIter<'a, T> { - type Item = T; - - fn next(&mut self) -> Option { - match self { - HybridIter::Sparse(sparse) => sparse.next().map(|e| *e), - HybridIter::Dense(dense) => dense.next(), - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/indexed_vec.rs rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/indexed_vec.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/indexed_vec.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/indexed_vec.rs 2018-12-04 23:41:40.000000000 +0000 @@ -535,6 +535,13 @@ self.raw.len() } + /// Gives the next index that will be assigned when `push` is + /// called. + #[inline] + pub fn next_index(&self) -> I { + I::new(self.len()) + } + #[inline] pub fn is_empty(&self) -> bool { self.raw.is_empty() diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -21,15 +21,13 @@ html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(in_band_lifetimes)] -#![feature(impl_header_lifetime_elision)] +#![cfg_attr(stage0, feature(impl_header_lifetime_elision))] #![feature(unboxed_closures)] #![feature(fn_traits)] #![feature(unsize)] #![feature(specialization)] #![feature(optin_builtin_traits)] -#![cfg_attr(stage0, feature(macro_vis_matcher))] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(allow_internal_unstable)] #![feature(vec_resize_with)] @@ -51,7 +49,7 @@ extern crate rustc_rayon_core as rayon_core; extern crate rustc_hash; extern crate serialize; -#[cfg_attr(test, macro_use)] +extern crate graphviz; extern crate smallvec; // See librustc_cratesio_shim/Cargo.toml for a comment explaining this. @@ -61,21 +59,18 @@ pub use rustc_serialize::hex::ToHex; pub mod svh; -pub mod array_vec; pub mod base_n; -pub mod bitvec; +pub mod bit_set; pub mod const_cstr; pub mod flock; pub mod fx; pub mod graph; -pub mod indexed_set; pub mod indexed_vec; pub mod obligation_forest; pub mod owning_ref; pub mod ptr_key; pub mod sip128; pub mod small_c_str; -pub mod small_vec; pub mod snapshot_map; pub use ena::snapshot_vec; pub mod sorted_map; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/obligation_forest/graphviz.rs rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/obligation_forest/graphviz.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/obligation_forest/graphviz.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/obligation_forest/graphviz.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,101 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use graphviz as dot; +use obligation_forest::{ForestObligation, ObligationForest}; +use std::env::var_os; +use std::fs::File; +use std::path::Path; +use std::sync::atomic::AtomicUsize; +use std::sync::atomic::Ordering; + +impl ObligationForest { + /// Create a graphviz representation of the obligation forest. Given a directory this will + /// create files with name of the format `_.gv`. The counter is + /// global and is maintained internally. + /// + /// Calling this will do nothing unless the environment variable + /// `DUMP_OBLIGATION_FOREST_GRAPHVIZ` is defined. + /// + /// A few post-processing that you might want to do make the forest easier to visualize: + /// + /// * `sed 's,std::[a-z]*::,,g'` — Deletes the `std::::` prefix of paths. + /// * `sed 's,"Binder(TraitPredicate(<\(.*\)>)) (\([^)]*\))","\1 (\2)",'` — Transforms + /// `Binder(TraitPredicate())` into just ``. + #[allow(dead_code)] + pub fn dump_graphviz>(&self, dir: P, description: &str) { + static COUNTER: AtomicUsize = AtomicUsize::new(0); + + if var_os("DUMP_OBLIGATION_FOREST_GRAPHVIZ").is_none() { + return; + } + + let counter = COUNTER.fetch_add(1, Ordering::AcqRel); + + let file_path = dir.as_ref().join(format!("{:010}_{}.gv", counter, description)); + + let mut gv_file = File::create(file_path).unwrap(); + + dot::render(&self, &mut gv_file).unwrap(); + } +} + +impl<'a, O: ForestObligation + 'a> dot::Labeller<'a> for &'a ObligationForest { + type Node = usize; + type Edge = (usize, usize); + + fn graph_id(&self) -> dot::Id { + dot::Id::new("trait_obligation_forest").unwrap() + } + + fn node_id(&self, index: &Self::Node) -> dot::Id { + dot::Id::new(format!("obligation_{}", index)).unwrap() + } + + fn node_label(&self, index: &Self::Node) -> dot::LabelText { + let node = &self.nodes[*index]; + let label = format!("{:?} ({:?})", node.obligation.as_predicate(), node.state.get()); + + dot::LabelText::LabelStr(label.into()) + } + + fn edge_label(&self, (_index_source, _index_target): &Self::Edge) -> dot::LabelText { + dot::LabelText::LabelStr("".into()) + } +} + +impl<'a, O: ForestObligation + 'a> dot::GraphWalk<'a> for &'a ObligationForest { + type Node = usize; + type Edge = (usize, usize); + + fn nodes(&self) -> dot::Nodes { + (0..self.nodes.len()).collect() + } + + fn edges(&self) -> dot::Edges { + (0..self.nodes.len()) + .flat_map(|i| { + let node = &self.nodes[i]; + + node.parent.iter().map(|p| p.get()) + .chain(node.dependents.iter().map(|p| p.get())) + .map(move |p| (p, i)) + }) + .collect() + } + + fn source(&self, (s, _): &Self::Edge) -> Self::Node { + *s + } + + fn target(&self, (_, t): &Self::Edge) -> Self::Node { + *t + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/obligation_forest/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/obligation_forest/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/obligation_forest/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/obligation_forest/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -26,6 +26,8 @@ mod node_index; use self::node_index::NodeIndex; +mod graphviz; + #[cfg(test)] mod test; @@ -65,6 +67,12 @@ Error(E), } +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +struct ObligationTreeId(usize); + +type ObligationTreeIdGenerator = + ::std::iter::Map<::std::ops::RangeFrom, fn(usize) -> ObligationTreeId>; + pub struct ObligationForest { /// The list of obligations. In between calls to /// `process_obligations`, this list only contains nodes in the @@ -79,11 +87,25 @@ /// at a higher index than its parent. This is needed by the /// backtrace iterator (which uses `split_at`). nodes: Vec>, + /// A cache of predicates that have been successfully completed. done_cache: FxHashSet, + /// An cache of the nodes in `nodes`, indexed by predicate. waiting_cache: FxHashMap, + scratch: Option>, + + obligation_tree_id_generator: ObligationTreeIdGenerator, + + /// Per tree error cache. This is used to deduplicate errors, + /// which is necessary to avoid trait resolution overflow in + /// some cases. + /// + /// See [this][details] for details. + /// + /// [details]: https://github.com/rust-lang/rust/pull/53255#issuecomment-421184780 + error_cache: FxHashMap>, } #[derive(Debug)] @@ -99,6 +121,9 @@ /// Obligations that depend on this obligation for their /// completion. They must all be in a non-pending state. dependents: Vec, + + /// Identifier of the obligation tree to which this node belongs. + obligation_tree_id: ObligationTreeId, } /// The state of one node in some tree within the forest. This @@ -162,9 +187,11 @@ pub fn new() -> ObligationForest { ObligationForest { nodes: vec![], - done_cache: FxHashSet(), - waiting_cache: FxHashMap(), + done_cache: Default::default(), + waiting_cache: Default::default(), scratch: Some(vec![]), + obligation_tree_id_generator: (0..).map(|i| ObligationTreeId(i)), + error_cache: Default::default(), } } @@ -187,7 +214,7 @@ -> Result<(), ()> { if self.done_cache.contains(obligation.as_predicate()) { - return Ok(()) + return Ok(()); } match self.waiting_cache.entry(obligation.as_predicate().clone()) { @@ -214,9 +241,29 @@ Entry::Vacant(v) => { debug!("register_obligation_at({:?}, {:?}) - ok, new index is {}", obligation, parent, self.nodes.len()); - v.insert(NodeIndex::new(self.nodes.len())); - self.nodes.push(Node::new(parent, obligation)); - Ok(()) + + let obligation_tree_id = match parent { + Some(p) => { + let parent_node = &self.nodes[p.get()]; + parent_node.obligation_tree_id + } + None => self.obligation_tree_id_generator.next().unwrap() + }; + + let already_failed = + parent.is_some() + && self.error_cache + .get(&obligation_tree_id) + .map(|errors| errors.contains(obligation.as_predicate())) + .unwrap_or(false); + + if already_failed { + Err(()) + } else { + v.insert(NodeIndex::new(self.nodes.len())); + self.nodes.push(Node::new(parent, obligation, obligation_tree_id)); + Ok(()) + } } } } @@ -251,6 +298,15 @@ .collect() } + fn insert_into_error_cache(&mut self, node_index: usize) { + let node = &self.nodes[node_index]; + + self.error_cache + .entry(node.obligation_tree_id) + .or_default() + .insert(node.obligation.as_predicate().clone()); + } + /// Perform a pass through the obligation list. This must /// be called in a loop until `outcome.stalled` is false. /// @@ -264,22 +320,15 @@ let mut stalled = true; for index in 0..self.nodes.len() { - debug!("process_obligations: node {} == {:?}", - index, - self.nodes[index]); + debug!("process_obligations: node {} == {:?}", index, self.nodes[index]); let result = match self.nodes[index] { - Node { state: ref _state, ref mut obligation, .. } - if _state.get() == NodeState::Pending => - { - processor.process_obligation(obligation) - } + Node { ref state, ref mut obligation, .. } if state.get() == NodeState::Pending => + processor.process_obligation(obligation), _ => continue }; - debug!("process_obligations: node {} got result {:?}", - index, - result); + debug!("process_obligations: node {} got result {:?}", index, result); match result { ProcessResult::Unchanged => { @@ -420,13 +469,13 @@ } while let Some(i) = error_stack.pop() { - let node = &self.nodes[i]; - - match node.state.get() { + match self.nodes[i].state.get() { NodeState::Error => continue, - _ => node.state.set(NodeState::Error) + _ => self.nodes[i].state.set(NodeState::Error), } + let node = &self.nodes[i]; + error_stack.extend( node.parent.iter().chain(node.dependents.iter()).map(|x| x.get()) ); @@ -514,6 +563,7 @@ self.waiting_cache.remove(self.nodes[i].obligation.as_predicate()); node_rewrites[i] = nodes_len; dead_nodes += 1; + self.insert_into_error_cache(i); } NodeState::OnDfsStack | NodeState::Success => unreachable!() } @@ -587,12 +637,17 @@ } impl Node { - fn new(parent: Option, obligation: O) -> Node { + fn new( + parent: Option, + obligation: O, + obligation_tree_id: ObligationTreeId + ) -> Node { Node { obligation, state: Cell::new(NodeState::Pending), parent, dependents: vec![], + obligation_tree_id, } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/obligation_forest/test.rs rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/obligation_forest/test.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/obligation_forest/test.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/obligation_forest/test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -59,8 +59,9 @@ fn process_backedge<'c, I>(&mut self, _cycle: I, _marker: PhantomData<&'c Self::Obligation>) - where I: Clone + Iterator { - } + where I: Clone + Iterator + { + } } @@ -350,11 +351,8 @@ }, |_|{})); assert_eq!(ok, vec!["(A,B,C): Sized"]); assert_eq!(err.len(), 0); - - } - #[test] fn orphan() { // check that orphaned nodes are handled correctly diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/small_vec.rs rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/small_vec.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/small_vec.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/small_vec.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! A vector type intended to be used for small vectors. -//! -//! Space for up to N elements is provided on the stack. If more elements are collected, Vec is -//! used to store the values on the heap. -//! -//! The N above is determined by Array's implementor, by way of an associated constant. - -use smallvec::{Array, SmallVec}; - -pub type OneVector = SmallVec<[T; 1]>; - -pub trait ExpectOne { - fn expect_one(self, err: &'static str) -> A::Item; -} - -impl ExpectOne for SmallVec { - fn expect_one(self, err: &'static str) -> A::Item { - assert!(self.len() == 1, err); - self.into_iter().next().unwrap() - } -} - -#[cfg(test)] -mod tests { - extern crate test; - use super::*; - - #[test] - #[should_panic] - fn test_expect_one_zero() { - let _: isize = OneVector::new().expect_one(""); - } - - #[test] - #[should_panic] - fn test_expect_one_many() { - OneVector::from_vec(vec![1, 2]).expect_one(""); - } - - #[test] - fn test_expect_one_one() { - assert_eq!(1, (smallvec![1] as OneVector<_>).expect_one("")); - assert_eq!(1, OneVector::from_vec(vec![1]).expect_one("")); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/snapshot_map/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/snapshot_map/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/snapshot_map/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/snapshot_map/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -35,16 +35,20 @@ Noop, } -impl SnapshotMap +impl Default for SnapshotMap where K: Hash + Clone + Eq { - pub fn new() -> Self { + fn default() -> Self { SnapshotMap { - map: FxHashMap(), + map: FxHashMap::default(), undo_log: vec![], } } +} +impl SnapshotMap + where K: Hash + Clone + Eq +{ pub fn clear(&mut self) { self.map.clear(); self.undo_log.clear(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/snapshot_map/test.rs rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/snapshot_map/test.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/snapshot_map/test.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/snapshot_map/test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,7 +12,7 @@ #[test] fn basic() { - let mut map = SnapshotMap::new(); + let mut map = SnapshotMap::default(); map.insert(22, "twenty-two"); let snapshot = map.snapshot(); map.insert(22, "thirty-three"); @@ -29,7 +29,7 @@ #[test] #[should_panic] fn out_of_order() { - let mut map = SnapshotMap::new(); + let mut map = SnapshotMap::default(); map.insert(22, "twenty-two"); let snapshot1 = map.snapshot(); let _snapshot2 = map.snapshot(); @@ -38,7 +38,7 @@ #[test] fn nested_commit_then_rollback() { - let mut map = SnapshotMap::new(); + let mut map = SnapshotMap::default(); map.insert(22, "twenty-two"); let snapshot1 = map.snapshot(); let snapshot2 = map.snapshot(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/stable_hasher.rs rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/stable_hasher.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/stable_hasher.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/stable_hasher.rs 2018-12-04 23:41:40.000000000 +0000 @@ -457,7 +457,7 @@ } -impl HashStable for ::indexed_set::IdxSet +impl HashStable for ::bit_set::BitSet { fn hash_stable(&self, ctx: &mut CTX, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/sync.rs rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/sync.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/sync.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/sync.rs 2018-12-04 23:41:40.000000000 +0000 @@ -133,7 +133,7 @@ pub type MTRef<'a, T> = &'a mut T; - #[derive(Debug)] + #[derive(Debug, Default)] pub struct MTLock(T); impl MTLock { @@ -228,7 +228,7 @@ pub type MTRef<'a, T> = &'a T; - #[derive(Debug)] + #[derive(Debug, Default)] pub struct MTLock(Lock); impl MTLock { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/transitive_relation.rs rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/transitive_relation.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/transitive_relation.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/transitive_relation.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use bitvec::BitMatrix; +use bit_set::BitMatrix; use fx::FxHashMap; use sync::Lock; use rustc_serialize::{Encodable, Encoder, Decodable, Decoder}; @@ -51,16 +51,18 @@ target: Index, } -impl TransitiveRelation { - pub fn new() -> TransitiveRelation { +impl Default for TransitiveRelation { + fn default() -> TransitiveRelation { TransitiveRelation { elements: vec![], - map: FxHashMap(), + map: FxHashMap::default(), edges: vec![], closure: Lock::new(None), } } +} +impl TransitiveRelation { pub fn is_empty(&self) -> bool { self.edges.is_empty() } @@ -95,7 +97,7 @@ where F: FnMut(&T) -> Option, U: Clone + Debug + Eq + Hash + Clone, { - let mut result = TransitiveRelation::new(); + let mut result = TransitiveRelation::default(); for edge in &self.edges { result.add(f(&self.elements[edge.source.0])?, f(&self.elements[edge.target.0])?); } @@ -279,7 +281,7 @@ // // This same algorithm is used in `parents` below. - let mut candidates = closure.intersection(a.0, b.0); // (1) + let mut candidates = closure.intersect_rows(a.0, b.0); // (1) pare_down(&mut candidates, closure); // (2) candidates.reverse(); // (3a) pare_down(&mut candidates, closure); // (3b) @@ -321,7 +323,7 @@ // with a slight tweak. In the case where `a R a`, we remove // that from the set of candidates. let ancestors = self.with_closure(|closure| { - let mut ancestors = closure.intersection(a.0, a.0); + let mut ancestors = closure.intersect_rows(a.0, a.0); // Remove anything that can reach `a`. If this is a // reflexive relation, this will include `a` itself. @@ -366,10 +368,10 @@ changed = false; for edge in &self.edges { // add an edge from S -> T - changed |= matrix.add(edge.source.0, edge.target.0); + changed |= matrix.insert(edge.source.0, edge.target.0); // add all outgoing edges from T into S - changed |= matrix.merge(edge.target.0, edge.source.0); + changed |= matrix.union_rows(edge.target.0, edge.source.0); } } matrix @@ -487,7 +489,7 @@ #[test] fn test_one_step() { - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("a", "b"); relation.add("a", "c"); assert!(relation.contains(&"a", &"c")); @@ -498,7 +500,7 @@ #[test] fn test_many_steps() { - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("a", "b"); relation.add("a", "c"); relation.add("a", "f"); @@ -528,7 +530,7 @@ // ^ // | // b - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("a", "tcx"); relation.add("b", "tcx"); assert_eq!(relation.minimal_upper_bounds(&"a", &"b"), vec![&"tcx"]); @@ -549,7 +551,7 @@ // need the second pare down call to get the right result (after // intersection, we have [1, 2], but 2 -> 1). - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("0", "1"); relation.add("0", "2"); @@ -576,7 +578,7 @@ // Like the precedecing test, but in this case intersection is [2, // 1], and hence we rely on the first pare down call. - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("0", "1"); relation.add("0", "2"); @@ -595,7 +597,7 @@ fn mubs_no_best_choice() { // in this case, the intersection yields [1, 2], and the "pare // down" calls find nothing to remove. - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("0", "1"); relation.add("0", "2"); @@ -612,7 +614,7 @@ // in this case, 1 and 2 form a cycle; we pick arbitrarily (but // consistently). - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("0", "1"); relation.add("0", "2"); @@ -634,7 +636,7 @@ // /\ | // b -> b1 ---+ - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("a", "a1"); relation.add("a", "b1"); relation.add("b", "a1"); @@ -657,7 +659,7 @@ // /\ /\ | // b -> b1 -> b2 ---------+ - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("a", "a1"); relation.add("a", "b1"); relation.add("b", "a1"); @@ -690,7 +692,7 @@ // | // b -> b1 ---+ - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("a", "a1"); relation.add("b", "b1"); relation.add("a1", "x"); @@ -713,7 +715,7 @@ // b // "digraph { a -> c -> d; b -> d; }", - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("a", "c"); relation.add("c", "d"); relation.add("b", "d"); @@ -732,7 +734,7 @@ // b // "digraph { a -> c -> d; d -> c; a -> d; b -> d; }", - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("a", "c"); relation.add("c", "d"); relation.add("d", "c"); @@ -752,7 +754,7 @@ // +--- b // "digraph { a -> c -> d; d -> c; b -> d; b -> c; }", - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("a", "c"); relation.add("c", "d"); relation.add("d", "c"); @@ -772,7 +774,7 @@ // b ---+ // "digraph { a -> c -> d -> e -> c; b -> d; b -> e; }", - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("a", "c"); relation.add("c", "d"); relation.add("d", "e"); @@ -794,7 +796,7 @@ // b ---+ // "digraph { a -> c -> d -> e -> c; a -> d; b -> e; }" - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); relation.add("a", "c"); relation.add("c", "d"); relation.add("d", "e"); @@ -832,7 +834,7 @@ (1, /*->*/ 3), ]; - let mut relation = TransitiveRelation::new(); + let mut relation = TransitiveRelation::default(); for (a, b) in pairs { relation.add(a, b); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/work_queue.rs rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/work_queue.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_data_structures/work_queue.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_data_structures/work_queue.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use indexed_set::IdxSet; +use bit_set::BitSet; use indexed_vec::Idx; use std::collections::VecDeque; @@ -20,7 +20,7 @@ /// and also use a bit set to track occupancy. pub struct WorkQueue { deque: VecDeque, - set: IdxSet, + set: BitSet, } impl WorkQueue { @@ -29,7 +29,7 @@ pub fn with_all(len: usize) -> Self { WorkQueue { deque: (0..len).map(T::new).collect(), - set: IdxSet::new_filled(len), + set: BitSet::new_filled(len), } } @@ -38,14 +38,14 @@ pub fn with_none(len: usize) -> Self { WorkQueue { deque: VecDeque::with_capacity(len), - set: IdxSet::new_empty(len), + set: BitSet::new_empty(len), } } /// Attempt to enqueue `element` in the work queue. Returns false if it was already present. #[inline] pub fn insert(&mut self, element: T) -> bool { - if self.set.add(&element) { + if self.set.insert(element) { self.deque.push_back(element); true } else { @@ -53,11 +53,11 @@ } } - /// Attempt to enqueue `element` in the work queue. Returns false if it was already present. + /// Attempt to pop an element from the work queue. #[inline] pub fn pop(&mut self) -> Option { if let Some(element) = self.deque.pop_front() { - self.set.remove(&element); + self.set.remove(element); Some(element) } else { None diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_driver/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/librustc_driver/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/librustc_driver/Cargo.toml 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_driver/Cargo.toml 2018-12-04 23:41:40.000000000 +0000 @@ -35,5 +35,6 @@ rustc_typeck = { path = "../librustc_typeck" } serialize = { path = "../libserialize" } syntax = { path = "../libsyntax" } +smallvec = { version = "0.6.5", features = ["union"] } syntax_ext = { path = "../libsyntax_ext" } syntax_pos = { path = "../libsyntax_pos" } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_driver/driver.rs rustc-1.31.0+dfsg1+llvm/src/librustc_driver/driver.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_driver/driver.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_driver/driver.rs 2018-12-04 23:41:40.000000000 +0000 @@ -44,7 +44,7 @@ use std::any::Any; use std::env; -use std::ffi::{OsStr, OsString}; +use std::ffi::OsString; use std::fs; use std::io::{self, Write}; use std::iter; @@ -91,7 +91,7 @@ let config = ThreadPoolBuilder::new() .num_threads(Session::query_threads_from_opts(&opts)) .deadlock_handler(|| unsafe { ty::query::handle_deadlock() }) - .stack_size(16 * 1024 * 1024); + .stack_size(::STACK_SIZE); let with_pool = move |pool: &ThreadPool| { pool.install(move || f(opts)) @@ -790,7 +790,9 @@ trait_map: resolver.trait_map, maybe_unused_trait_imports: resolver.maybe_unused_trait_imports, maybe_unused_extern_crates: resolver.maybe_unused_extern_crates, - extern_prelude: resolver.extern_prelude, + extern_prelude: resolver.extern_prelude.iter().map(|(ident, entry)| { + (ident.name, entry.introduced_by_item) + }).collect(), }, analysis: ty::CrateAnalysis { @@ -882,7 +884,7 @@ ) }); - let mut registry = registry.unwrap_or(Registry::new(sess, krate.span)); + let mut registry = registry.unwrap_or_else(|| Registry::new(sess, krate.span)); time(sess, "plugin registration", || { if sess.features_untracked().rustc_diagnostic_macros { @@ -1022,6 +1024,7 @@ .cloned() .collect(); missing_fragment_specifiers.sort(); + for span in missing_fragment_specifiers { let lint = lint::builtin::MISSING_FRAGMENT_SPECIFIER; let msg = "missing fragment specifier"; @@ -1473,7 +1476,7 @@ .collect(); let mut file = fs::File::create(&deps_filename)?; for path in out_filenames { - write!(file, "{}: {}\n\n", path.display(), files.join(" "))?; + writeln!(file, "{}: {}\n", path.display(), files.join(" "))?; } // Emit a fake target for each input file to the compilation. This @@ -1485,15 +1488,12 @@ Ok(()) })(); - match result { - Ok(()) => {} - Err(e) => { - sess.fatal(&format!( - "error writing dependencies to `{}`: {}", - deps_filename.display(), - e - )); - } + if let Err(e) = result { + sess.fatal(&format!( + "error writing dependencies to `{}`: {}", + deps_filename.display(), + e + )); } } @@ -1521,6 +1521,7 @@ Symbol::intern("proc-macro"), Symbol::intern("bin") ]; + if let ast::MetaItemKind::NameValue(spanned) = a.meta().unwrap().node { let span = spanned.span; let lev_candidate = find_best_match_for_name( @@ -1552,7 +1553,7 @@ } None } - _ => { + None => { session .struct_span_err(a.span, "`crate_type` requires a value") .note("for example: `#![crate_type=\"lib\"]`") @@ -1582,25 +1583,26 @@ base.push(::rustc_codegen_utils::link::default_output_for_target( session, )); + } else { + base.sort(); + base.dedup(); } - base.sort(); - base.dedup(); } - base.into_iter() - .filter(|crate_type| { - let res = !::rustc_codegen_utils::link::invalid_output_for_target(session, *crate_type); - - if !res { - session.warn(&format!( - "dropping unsupported crate type `{}` for target `{}`", - *crate_type, session.opts.target_triple - )); - } + base.retain(|crate_type| { + let res = !::rustc_codegen_utils::link::invalid_output_for_target(session, *crate_type); - res - }) - .collect() + if !res { + session.warn(&format!( + "dropping unsupported crate type `{}` for target `{}`", + *crate_type, session.opts.target_triple + )); + } + + res + }); + + base } pub fn compute_crate_disambiguator(session: &Session) -> CrateDisambiguator { @@ -1651,17 +1653,14 @@ // "-" as input file will cause the parser to read from stdin so we // have to make up a name // We want to toss everything after the final '.' - let dirpath = match *odir { - Some(ref d) => d.clone(), - None => PathBuf::new(), - }; + let dirpath = (*odir).as_ref().cloned().unwrap_or_default(); // If a crate name is present, we use it as the link name let stem = sess.opts .crate_name .clone() .or_else(|| attr::find_crate_name(attrs).map(|n| n.to_string())) - .unwrap_or(input.filestem()); + .unwrap_or_else(|| input.filestem().to_owned()); OutputFilenames { out_directory: dirpath, @@ -1694,13 +1693,11 @@ sess.warn("ignoring -C extra-filename flag due to -o flag"); } - let cur_dir = Path::new(""); - OutputFilenames { - out_directory: out_file.parent().unwrap_or(cur_dir).to_path_buf(), + out_directory: out_file.parent().unwrap_or_else(|| Path::new("")).to_path_buf(), out_filestem: out_file .file_stem() - .unwrap_or(OsStr::new("")) + .unwrap_or_default() .to_str() .unwrap() .to_string(), diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_driver/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_driver/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_driver/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_driver/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -20,9 +20,7 @@ #![feature(box_syntax)] #![cfg_attr(unix, feature(libc))] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] -#![feature(option_replace)] +#![feature(nll)] #![feature(quote)] #![feature(rustc_diagnostic_macros)] #![feature(slice_sort_by_cached_key)] @@ -33,7 +31,7 @@ #![recursion_limit="256"] extern crate arena; -extern crate getopts; +pub extern crate getopts; extern crate graphviz; extern crate env_logger; #[cfg(unix)] @@ -59,6 +57,7 @@ extern crate rustc_typeck; extern crate scoped_tls; extern crate serialize; +extern crate smallvec; #[macro_use] extern crate log; extern crate syntax; @@ -90,6 +89,7 @@ use serialize::json::ToJson; use std::any::Any; +use std::borrow::Cow; use std::cmp::max; use std::default::Default; use std::env::consts::{DLL_PREFIX, DLL_SUFFIX}; @@ -137,9 +137,7 @@ codegen_backend: &dyn CodegenBackend) { let tf = Symbol::intern("target_feature"); - for feat in codegen_backend.target_features(sess) { - cfg.insert((tf, Some(feat))); - } + cfg.extend(codegen_backend.target_features(sess).into_iter().map(|feat| (tf, Some(feat)))); if sess.crt_static_feature() { cfg.insert((tf, Some(Symbol::intern("crt-static")))); @@ -153,21 +151,14 @@ /// Exit status code used for compilation failures and invalid flags. pub const EXIT_FAILURE: isize = 1; -const BUG_REPORT_URL: &'static str = "https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.\ - md#bug-reports"; +const BUG_REPORT_URL: &str = "https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.\ + md#bug-reports"; + +const ICE_REPORT_COMPILER_FLAGS: &[&str] = &["Z", "C", "crate-type"]; -const ICE_REPORT_COMPILER_FLAGS: &'static [&'static str] = &[ - "Z", - "C", - "crate-type", -]; -const ICE_REPORT_COMPILER_FLAGS_EXCLUDE: &'static [&'static str] = &[ - "metadata", - "extra-filename", -]; -const ICE_REPORT_COMPILER_FLAGS_STRIP_VALUE: &'static [&'static str] = &[ - "incremental", -]; +const ICE_REPORT_COMPILER_FLAGS_EXCLUDE: &[&str] = &["metadata", "extra-filename"]; + +const ICE_REPORT_COMPILER_FLAGS_STRIP_VALUE: &[&str] = &["incremental"]; pub fn abort_on_err(result: Result, sess: &Session) -> T { match result { @@ -196,14 +187,16 @@ } None => { let emitter = - errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto, - None, - true, - false); + errors::emitter::EmitterWriter::stderr( + errors::ColorConfig::Auto, + None, + true, + false + ); let handler = errors::Handler::with_emitter(true, false, Box::new(emitter)); handler.emit(&MultiSpan::new(), - "aborting due to previous error(s)", - errors::Level::Fatal); + "aborting due to previous error(s)", + errors::Level::Fatal); panic::resume_unwind(Box::new(errors::FatalErrorMarker)); } } @@ -225,15 +218,10 @@ // available for future dynamic libraries opened. This is currently used by // loading LLVM and then making its symbols available for other dynamic // libraries. - let lib = match DynamicLibrary::open_global_now(path) { - Ok(lib) => lib, - Err(err) => { - let err = format!("couldn't load codegen backend {:?}: {:?}", - path, - err); - early_error(ErrorOutputType::default(), &err); - } - }; + let lib = DynamicLibrary::open_global_now(path).unwrap_or_else(|err| { + let err = format!("couldn't load codegen backend {:?}: {:?}", path, err); + early_error(ErrorOutputType::default(), &err); + }); unsafe { match lib.symbol("__rustc_codegen_backend") { Ok(f) => { @@ -329,37 +317,30 @@ let sysroot = sysroot_candidates.iter() .map(|sysroot| { let libdir = filesearch::relative_target_lib_path(&sysroot, &target); - sysroot.join(libdir) - .with_file_name(option_env!("CFG_CODEGEN_BACKENDS_DIR") - .unwrap_or("codegen-backends")) + sysroot.join(libdir).with_file_name( + option_env!("CFG_CODEGEN_BACKENDS_DIR").unwrap_or("codegen-backends")) }) .filter(|f| { info!("codegen backend candidate: {}", f.display()); f.exists() }) .next(); - let sysroot = match sysroot { - Some(path) => path, - None => { - let candidates = sysroot_candidates.iter() - .map(|p| p.display().to_string()) - .collect::>() - .join("\n* "); - let err = format!("failed to find a `codegen-backends` folder \ - in the sysroot candidates:\n* {}", candidates); - early_error(ErrorOutputType::default(), &err); - } - }; + let sysroot = sysroot.unwrap_or_else(|| { + let candidates = sysroot_candidates.iter() + .map(|p| p.display().to_string()) + .collect::>() + .join("\n* "); + let err = format!("failed to find a `codegen-backends` folder \ + in the sysroot candidates:\n* {}", candidates); + early_error(ErrorOutputType::default(), &err); + }); info!("probing {} for a codegen backend", sysroot.display()); - let d = match sysroot.read_dir() { - Ok(d) => d, - Err(e) => { - let err = format!("failed to load default codegen backend, couldn't \ - read `{}`: {}", sysroot.display(), e); - early_error(ErrorOutputType::default(), &err); - } - }; + let d = sysroot.read_dir().unwrap_or_else(|e| { + let err = format!("failed to load default codegen backend, couldn't \ + read `{}`: {}", sysroot.display(), e); + early_error(ErrorOutputType::default(), &err); + }); let mut file: Option = None; @@ -379,8 +360,8 @@ } if let Some(ref prev) = file { let err = format!("duplicate codegen backends found\n\ - first: {}\n\ - second: {}\n\ + first: {}\n\ + second: {}\n\ ", prev.display(), path.display()); early_error(ErrorOutputType::default(), &err); } @@ -392,7 +373,7 @@ None => { let err = format!("failed to load default codegen backend for `{}`, \ no appropriate codegen dylib found in `{}`", - backend_name, sysroot.display()); + backend_name, sysroot.display()); early_error(ErrorOutputType::default(), &err); } } @@ -579,7 +560,7 @@ unsafe { // Set the SIGPIPE signal handler, so that an EPIPE // will cause rustc to terminate, as expected. - assert!(libc::signal(libc::SIGPIPE, libc::SIG_DFL) != libc::SIG_ERR); + assert_ne!(libc::signal(libc::SIGPIPE, libc::SIG_DFL), libc::SIG_ERR); } } @@ -980,6 +961,7 @@ state.expanded_crate.unwrap(), state.analysis.unwrap(), state.crate_name.unwrap(), + state.input, None, DumpHandler::new(state.out_dir, state.crate_name.unwrap())) @@ -996,7 +978,7 @@ input: &Input) -> Compilation { let r = matches.opt_strs("Z"); - if r.contains(&("ls".to_string())) { + if r.iter().any(|s| *s == "ls") { match input { &Input::File(ref ifile) => { let path = &(*ifile); @@ -1015,7 +997,7 @@ return Compilation::Stop; } - return Compilation::Continue; + Compilation::Continue } @@ -1028,7 +1010,7 @@ use rustc::session::config::PrintRequest::*; // PrintRequest::NativeStaticLibs is special - printed during linking // (empty iterator returns true) - if sess.opts.prints.iter().all(|&p| p==PrintRequest::NativeStaticLibs) { + if sess.opts.prints.iter().all(|&p| p == PrintRequest::NativeStaticLibs) { return Compilation::Continue; } @@ -1055,10 +1037,8 @@ Sysroot => println!("{}", sess.sysroot().display()), TargetSpec => println!("{}", sess.target.target.to_json().pretty()), FileNames | CrateName => { - let input = match input { - Some(input) => input, - None => early_error(ErrorOutputType::default(), "no input file provided"), - }; + let input = input.unwrap_or_else(|| + early_error(ErrorOutputType::default(), "no input file provided")); let attrs = attrs.as_ref().unwrap(); let t_outputs = driver::build_output_filenames(input, odir, ofile, attrs, sess); let id = rustc_codegen_utils::link::find_crate_name(Some(sess), attrs, input); @@ -1074,18 +1054,14 @@ &id, &t_outputs ); - println!("{}", - fname.file_name() - .unwrap() - .to_string_lossy()); + println!("{}", fname.file_name().unwrap().to_string_lossy()); } } Cfg => { let allow_unstable_cfg = UnstableFeatures::from_environment() .is_nightly_build(); - let mut cfgs = Vec::new(); - for &(name, ref value) in sess.parse_sess.config.iter() { + let mut cfgs = sess.parse_sess.config.iter().filter_map(|&(name, ref value)| { let gated_cfg = GatedCfg::gate(&ast::MetaItem { ident: ast::Path::from_ident(ast::Ident::with_empty_ctxt(name)), node: ast::MetaItemKind::Word, @@ -1104,16 +1080,16 @@ let value = value.as_ref().map(|s| s.as_ref()); if name != "target_feature" || value != Some("crt-static") { if !allow_unstable_cfg && gated_cfg.is_some() { - continue; + return None } } - cfgs.push(if let Some(value) = value { - format!("{}=\"{}\"", name, value) + if let Some(value) = value { + Some(format!("{}=\"{}\"", name, value)) } else { - name.to_string() - }); - } + Some(name.to_string()) + } + }).collect::>(); cfgs.sort(); for cfg in cfgs { @@ -1150,9 +1126,8 @@ pub fn version(binary: &str, matches: &getopts::Matches) { let verbose = matches.opt_present("verbose"); - println!("{} {}", - binary, - option_env!("CFG_VERSION").unwrap_or("unknown version")); + println!("{} {}", binary, option_env!("CFG_VERSION").unwrap_or("unknown version")); + if verbose { fn unw(x: Option<&str>) -> &str { x.unwrap_or("unknown") @@ -1176,7 +1151,7 @@ for option in groups.iter().filter(|x| include_unstable_options || x.is_stable()) { (option.apply)(&mut options); } - let message = "Usage: rustc [OPTIONS] INPUT".to_string(); + let message = "Usage: rustc [OPTIONS] INPUT"; let nightly_help = if nightly_options::is_nightly_build() { "\n -Z help Print internal options for debugging rustc" } else { @@ -1191,7 +1166,7 @@ -C help Print codegen options -W help \ Print 'lint' options and default settings{}{}\n", - options.usage(&message), + options.usage(message), nightly_help, verbose_help); } @@ -1273,8 +1248,6 @@ print_lints(builtin); - - let max_name_len = max("warnings".len(), plugin_groups.iter() .chain(&builtin_groups) @@ -1407,10 +1380,8 @@ for option in config::rustc_optgroups() { (option.apply)(&mut options); } - let matches = match options.parse(args) { - Ok(m) => m, - Err(f) => early_error(ErrorOutputType::default(), &f.to_string()), - }; + let matches = options.parse(args).unwrap_or_else(|f| + early_error(ErrorOutputType::default(), &f.to_string())); // For all options we just parsed, we check a few aspects: // @@ -1452,6 +1423,7 @@ } let cg_flags = matches.opt_strs("C"); + if cg_flags.iter().any(|x| *x == "help") { describe_codegen_flags(); return None; @@ -1462,7 +1434,7 @@ "the --no-stack-check flag is deprecated and does nothing"); } - if cg_flags.contains(&"passes=list".to_string()) { + if cg_flags.iter().any(|x| *x == "passes=list") { get_codegen_sysroot("llvm")().print_passes(); return None; } @@ -1488,6 +1460,11 @@ } } +// Temporarily have stack size set to 32MB to deal with various crates with long method +// chains or deep syntax trees. +// FIXME(oli-obk): get https://github.com/rust-lang/rust/pull/55617 the finish line +const STACK_SIZE: usize = 32 * 1024 * 1024; // 32MB + /// Runs `f` in a suitable thread for running `rustc`; returns a `Result` with either the return /// value of `f` or -- if a panic occurs -- the panic value. /// @@ -1497,10 +1474,7 @@ where F: FnOnce() -> R + Send + 'static, R: Send + 'static, { - // Temporarily have stack size set to 16MB to deal with nom-using crates failing - const STACK_SIZE: usize = 16 * 1024 * 1024; // 16MB - - #[cfg(all(unix,not(target_os = "haiku")))] + #[cfg(all(unix, not(target_os = "haiku")))] let spawn_thread = unsafe { // Fetch the current resource limits let mut rlim = libc::rlimit { @@ -1554,7 +1528,7 @@ } }; - #[cfg(not(any(windows,unix)))] + #[cfg(not(any(windows, unix)))] let spawn_thread = true; // The or condition is added from backward compatibility. @@ -1632,7 +1606,7 @@ } } - if result.len() > 0 { + if !result.is_empty() { Some((result, excluded_cargo_defaults)) } else { None @@ -1680,25 +1654,25 @@ errors::Level::Bug); } - let mut xs = vec![ - "the compiler unexpectedly panicked. this is a bug.".to_string(), - format!("we would appreciate a bug report: {}", BUG_REPORT_URL), + let mut xs: Vec> = vec![ + "the compiler unexpectedly panicked. this is a bug.".into(), + format!("we would appreciate a bug report: {}", BUG_REPORT_URL).into(), format!("rustc {} running on {}", option_env!("CFG_VERSION").unwrap_or("unknown_version"), - config::host_triple()), + config::host_triple()).into(), ]; if let Some((flags, excluded_cargo_defaults)) = extra_compiler_flags() { - xs.push(format!("compiler flags: {}", flags.join(" "))); + xs.push(format!("compiler flags: {}", flags.join(" ")).into()); if excluded_cargo_defaults { - xs.push("some of the compiler flags provided by cargo are hidden".to_string()); + xs.push("some of the compiler flags provided by cargo are hidden".into()); } } for note in &xs { handler.emit(&MultiSpan::new(), - ¬e, + note, errors::Level::Note); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_driver/pretty.rs rustc-1.31.0+dfsg1+llvm/src/librustc_driver/pretty.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_driver/pretty.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_driver/pretty.rs 2018-12-04 23:41:40.000000000 +0000 @@ -24,7 +24,6 @@ use rustc::session::config::{Input, OutputFilenames}; use rustc_borrowck as borrowck; use rustc_borrowck::graphviz as borrowck_dot; -use rustc_data_structures::small_vec::OneVector; use rustc_data_structures::thin_vec::ThinVec; use rustc_metadata::cstore::CStore; @@ -38,6 +37,7 @@ use syntax_pos::{self, FileName}; use graphviz as dot; +use smallvec::SmallVec; use std::cell::Cell; use std::fs::File; @@ -167,10 +167,10 @@ impl PpSourceMode { /// Constructs a `PrinterSupport` object and passes it to `f`. fn call_with_pp_support<'tcx, A, F>(&self, - sess: &'tcx Session, - hir_map: Option<&hir_map::Map<'tcx>>, - f: F) - -> A + sess: &'tcx Session, + hir_map: Option<&hir_map::Map<'tcx>>, + f: F) + -> A where F: FnOnce(&dyn PrinterSupport) -> A { match *self { @@ -198,17 +198,18 @@ _ => panic!("Should use call_with_pp_support_hir"), } } - fn call_with_pp_support_hir<'tcx, A, F>(&self, - sess: &'tcx Session, - cstore: &'tcx CStore, - hir_map: &hir_map::Map<'tcx>, - analysis: &ty::CrateAnalysis, - resolutions: &Resolutions, - arenas: &'tcx AllArenas<'tcx>, - output_filenames: &OutputFilenames, - id: &str, - f: F) - -> A + fn call_with_pp_support_hir<'tcx, A, F>( + &self, + sess: &'tcx Session, + cstore: &'tcx CStore, + hir_map: &hir_map::Map<'tcx>, + analysis: &ty::CrateAnalysis, + resolutions: &Resolutions, + arenas: &'tcx AllArenas<'tcx>, + output_filenames: &OutputFilenames, + id: &str, + f: F + ) -> A where F: FnOnce(&dyn HirPrinterSupport, &hir::Crate) -> A { match *self { @@ -727,7 +728,7 @@ self.run(is_const, |s| fold::noop_fold_item_kind(i, s)) } - fn fold_trait_item(&mut self, i: ast::TraitItem) -> OneVector { + fn fold_trait_item(&mut self, i: ast::TraitItem) -> SmallVec<[ast::TraitItem; 1]> { let is_const = match i.node { ast::TraitItemKind::Const(..) => true, ast::TraitItemKind::Method(ast::MethodSig { ref decl, ref header, .. }, _) => @@ -737,7 +738,7 @@ self.run(is_const, |s| fold::noop_fold_trait_item(i, s)) } - fn fold_impl_item(&mut self, i: ast::ImplItem) -> OneVector { + fn fold_impl_item(&mut self, i: ast::ImplItem) -> SmallVec<[ast::ImplItem; 1]> { let is_const = match i.node { ast::ImplItemKind::Const(..) => true, ast::ImplItemKind::Method(ast::MethodSig { ref decl, ref header, .. }, _) => @@ -855,7 +856,7 @@ break n.body(); } let parent = tcx.hir.get_parent_node(node_id); - assert!(node_id != parent); + assert_ne!(node_id, parent); node_id = parent; } } @@ -952,18 +953,17 @@ // Silently ignores an identified node. let out: &mut dyn Write = &mut out; s.call_with_pp_support(sess, None, move |annotation| { - debug!("pretty printing source code {:?}", s); - let sess = annotation.sess(); - pprust::print_crate(sess.source_map(), - &sess.parse_sess, - krate, - src_name, - &mut rdr, - box out, - annotation.pp_ann(), - false) - }) - .unwrap() + debug!("pretty printing source code {:?}", s); + let sess = annotation.sess(); + pprust::print_crate(sess.source_map(), + &sess.parse_sess, + krate, + src_name, + &mut rdr, + box out, + annotation.pp_ann(), + false) + }).unwrap() } else { unreachable!(); }; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_driver/profile/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_driver/profile/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_driver/profile/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_driver/profile/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -23,7 +23,7 @@ use std::sync::mpsc::{channel}; let (tx, rx) = channel(); if profq_set_chan(sess, tx) { - thread::spawn(move||profile_queries_thread(rx)); + thread::spawn(move || profile_queries_thread(rx)); } } @@ -34,11 +34,12 @@ pub fn dump(sess: &Session, path: String) { use std::sync::mpsc::{channel}; let (tx, rx) = channel(); - let params = ProfQDumpParams{ - path, ack:tx, + let params = ProfQDumpParams { + path, + ack: tx, // FIXME: Add another compiler flag to toggle whether this log // is written; false for now - dump_profq_msg_log:true, + dump_profq_msg_log: true, }; profq_msg(sess, ProfileQueriesMsg::Dump(params)); let _ = rx.recv().unwrap(); @@ -63,20 +64,20 @@ } fn total_duration(traces: &[trace::Rec]) -> Duration { - let mut sum : Duration = Duration::new(0,0); + let mut sum : Duration = Duration::new(0, 0); for t in traces.iter() { sum += t.dur_total; } return sum } // profiling thread; retains state (in local variables) and dump traces, upon request. -fn profile_queries_thread(r:Receiver) { +fn profile_queries_thread(r: Receiver) { use self::trace::*; use std::fs::File; use std::time::{Instant}; - let mut profq_msgs : Vec = vec![]; - let mut frame : StackFrame = StackFrame{ parse_st:ParseState::Clear, traces:vec![] }; - let mut stack : Vec = vec![]; + let mut profq_msgs: Vec = vec![]; + let mut frame: StackFrame = StackFrame { parse_st: ParseState::Clear, traces: vec![] }; + let mut stack: Vec = vec![]; loop { let msg = r.recv(); if let Err(_recv_err) = msg { @@ -90,7 +91,7 @@ match msg { ProfileQueriesMsg::Halt => return, ProfileQueriesMsg::Dump(params) => { - assert!(stack.len() == 0); + assert!(stack.is_empty()); assert!(frame.parse_st == ParseState::Clear); { // write log of all messages @@ -109,17 +110,14 @@ let counts_path = format!("{}.counts.txt", params.path); let mut counts_file = File::create(&counts_path).unwrap(); - write!(html_file, "\n").unwrap(); - write!(html_file, - "\n\n", - "profile_queries.css").unwrap(); - write!(html_file, "\n").unwrap(); - write!(html_file, "\n").unwrap(); - write!(html_file, "\n").unwrap(); + writeln!(html_file, "\n\n").unwrap(); trace::write_traces(&mut html_file, &mut counts_file, &frame.traces); - write!(html_file, "\n\n").unwrap(); + writeln!(html_file, "\n").unwrap(); let ack_path = format!("{}.ack", params.path); let ack_file = File::create(&ack_path).unwrap(); @@ -141,10 +139,10 @@ // Parse State: Clear (ParseState::Clear, - ProfileQueriesMsg::QueryBegin(span,querymsg)) => { + ProfileQueriesMsg::QueryBegin(span, querymsg)) => { let start = Instant::now(); frame.parse_st = ParseState::HaveQuery - (Query{span:span, msg:querymsg}, start) + (Query { span, msg: querymsg }, start) }, (ParseState::Clear, ProfileQueriesMsg::CacheHit) => { @@ -287,8 +285,6 @@ frame = StackFrame{parse_st:ParseState::Clear, traces:vec![]}; }, - // - // // Parse errors: (ParseState::HaveQuery(q,_), @@ -310,7 +306,6 @@ unreachable!() }, } - } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_driver/profile/trace.rs rustc-1.31.0+dfsg1+llvm/src/librustc_driver/profile/trace.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_driver/profile/trace.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_driver/profile/trace.rs 2018-12-04 23:41:40.000000000 +0000 @@ -43,18 +43,18 @@ pub dur_total: Duration, } +fn cons(s: &str) -> String { + let first = s.split(|d| d == '(' || d == '{').next(); + assert!(first.is_some() && first != Some("")); + first.unwrap().to_owned() +} + pub fn cons_of_query_msg(q: &trace::Query) -> String { - let s = format!("{:?}", q.msg); - let cons: Vec<&str> = s.split(|d| d == '(' || d == '{').collect(); - assert!(cons.len() > 0 && cons[0] != ""); - cons[0].to_string() + cons(&format!("{:?}", q.msg)) } pub fn cons_of_key(k: &DepNode) -> String { - let s = format!("{:?}", k); - let cons: Vec<&str> = s.split(|d| d == '(' || d == '{').collect(); - assert!(cons.len() > 0 && cons[0] != ""); - cons[0].to_string() + cons(&format!("{:?}", k)) } // First return value is text; second return value is a CSS class @@ -84,35 +84,33 @@ // First return value is text; second return value is a CSS class fn html_of_duration(_start: &Instant, dur: &Duration) -> (String, String) { use rustc::util::common::duration_to_secs_str; - (duration_to_secs_str(dur.clone()), - String::new() - ) + (duration_to_secs_str(dur.clone()), String::new()) } -fn html_of_fraction(frac: f64) -> (String, String) { +fn html_of_fraction(frac: f64) -> (String, &'static str) { let css = { - if frac > 0.50 { "frac-50".to_string() } - else if frac > 0.40 { "frac-40".to_string() } - else if frac > 0.30 { "frac-30".to_string() } - else if frac > 0.20 { "frac-20".to_string() } - else if frac > 0.10 { "frac-10".to_string() } - else if frac > 0.05 { "frac-05".to_string() } - else if frac > 0.02 { "frac-02".to_string() } - else if frac > 0.01 { "frac-01".to_string() } - else if frac > 0.001 { "frac-001".to_string() } - else { "frac-0".to_string() } + if frac > 0.50 { "frac-50" } + else if frac > 0.40 { "frac-40" } + else if frac > 0.30 { "frac-30" } + else if frac > 0.20 { "frac-20" } + else if frac > 0.10 { "frac-10" } + else if frac > 0.05 { "frac-05" } + else if frac > 0.02 { "frac-02" } + else if frac > 0.01 { "frac-01" } + else if frac > 0.001 { "frac-001" } + else { "frac-0" } }; let percent = frac * 100.0; - if percent > 0.1 { (format!("{:.1}%", percent), css) } - else { ("< 0.1%".to_string(), css) } + + if percent > 0.1 { + (format!("{:.1}%", percent), css) + } else { + ("< 0.1%".to_string(), css) + } } fn total_duration(traces: &[Rec]) -> Duration { - let mut sum : Duration = Duration::new(0,0); - for t in traces.iter() { - sum += t.dur_total; - } - return sum + Duration::new(0, 0) + traces.iter().map(|t| t.dur_total).sum() } fn duration_div(nom: Duration, den: Duration) -> f64 { @@ -130,64 +128,65 @@ let fraction = duration_div(t.dur_total, total); let percent = fraction * 100.0; let (frc_text, frc_css_classes) = html_of_fraction(fraction); - write!(file, "

").unwrap(); } } fn compute_counts_rec(counts: &mut FxHashMap, traces: &[Rec]) { + counts.reserve(traces.len()); for t in traces.iter() { match t.effect { Effect::TimeBegin(ref msg) => { let qm = match counts.get(msg) { - Some(_qm) => { panic!("TimeBegin with non-unique, repeat message") } - None => QueryMetric{ + Some(_qm) => panic!("TimeBegin with non-unique, repeat message"), + None => QueryMetric { count: 1, dur_self: t.dur_self, dur_total: t.dur_total, - }}; + } + }; counts.insert(msg.clone(), qm); }, Effect::TaskBegin(ref key) => { let cons = cons_of_key(key); let qm = match counts.get(&cons) { Some(qm) => - QueryMetric{ + QueryMetric { count: qm.count + 1, dur_self: qm.dur_self + t.dur_self, dur_total: qm.dur_total + t.dur_total, }, - None => QueryMetric{ + None => QueryMetric { count: 1, dur_self: t.dur_self, dur_total: t.dur_total, - }}; + } + }; counts.insert(cons, qm); }, Effect::QueryBegin(ref qmsg, ref _cc) => { let qcons = cons_of_query_msg(qmsg); let qm = match counts.get(&qcons) { Some(qm) => - QueryMetric{ + QueryMetric { count: qm.count + 1, dur_total: qm.dur_total + t.dur_total, dur_self: qm.dur_self + t.dur_self }, - None => QueryMetric{ + None => QueryMetric { count: 1, dur_total: t.dur_total, dur_self: t.dur_self, @@ -200,19 +199,20 @@ } } -pub fn write_counts(count_file: &mut File, counts: &mut FxHashMap) { +pub fn write_counts(count_file: &mut File, counts: &mut FxHashMap) { use rustc::util::common::duration_to_secs_str; use std::cmp::Reverse; let mut data = counts.iter().map(|(ref cons, ref qm)| (cons.clone(), qm.count.clone(), qm.dur_total.clone(), qm.dur_self.clone()) ).collect::>(); + data.sort_by_key(|k| Reverse(k.3)); for (cons, count, dur_total, dur_self) in data { - write!(count_file, "{}, {}, {}, {}\n", - cons, count, - duration_to_secs_str(dur_total), - duration_to_secs_str(dur_self) + writeln!(count_file, "{}, {}, {}, {}", + cons, count, + duration_to_secs_str(dur_total), + duration_to_secs_str(dur_self) ).unwrap(); } } @@ -223,12 +223,12 @@ compute_counts_rec(&mut counts, traces); write_counts(counts_file, &mut counts); - let total : Duration = total_duration(traces); + let total: Duration = total_duration(traces); write_traces_rec(html_file, traces, total, 0) } pub fn write_style(html_file: &mut File) { - write!(html_file,"{}", " + write!(html_file, "{}", " body { font-family: sans-serif; background: black; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_driver/test.rs rustc-1.31.0+dfsg1+llvm/src/librustc_driver/test.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_driver/test.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_driver/test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,29 +14,29 @@ use std::sync::mpsc; use driver; -use rustc_lint; -use rustc_resolve::MakeGlobMap; -use rustc::middle::region; -use rustc::ty::subst::Subst; -use rustc::traits::ObligationCause; -use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; -use rustc::ty::query::OnDiskCache; -use rustc::infer::{self, InferOk, InferResult}; +use errors; +use errors::emitter::Emitter; +use errors::{DiagnosticBuilder, Level}; +use rustc::hir::map as hir_map; use rustc::infer::outlives::env::OutlivesEnvironment; use rustc::infer::type_variable::TypeVariableOrigin; -use rustc_metadata::cstore::CStore; -use rustc::hir::map as hir_map; -use rustc::session::{self, config}; +use rustc::infer::{self, InferOk, InferResult, SuppressRegionErrors}; +use rustc::middle::region; use rustc::session::config::{OutputFilenames, OutputTypes}; +use rustc::session::{self, config}; +use rustc::traits::ObligationCause; +use rustc::ty::query::OnDiskCache; +use rustc::ty::subst::Subst; +use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; use rustc_data_structures::sync::{self, Lrc}; +use rustc_lint; +use rustc_metadata::cstore::CStore; +use rustc_resolve::MakeGlobMap; +use rustc_target::spec::abi::Abi; use syntax; use syntax::ast; -use rustc_target::spec::abi::Abi; -use syntax::source_map::{SourceMap, FilePathMapping, FileName}; -use errors; -use errors::emitter::Emitter; -use errors::{Level, DiagnosticBuilder}; use syntax::feature_gate::UnstableFeatures; +use syntax::source_map::{FileName, FilePathMapping, SourceMap}; use syntax::symbol::Symbol; use syntax_pos::DUMMY_SP; @@ -90,13 +90,15 @@ fn errors(msgs: &[&str]) -> (Box, usize) { let v = msgs.iter().map(|m| m.to_string()).collect(); - (box ExpectErrorEmitter { messages: v } as Box, msgs.len()) + ( + box ExpectErrorEmitter { messages: v } as Box, + msgs.len(), + ) } -fn test_env(source_string: &str, - args: (Box, usize), - body: F) - where F: FnOnce(Env) +fn test_env(source_string: &str, args: (Box, usize), body: F) +where + F: FnOnce(Env), { syntax::with_globals(|| { let mut options = config::Options::default(); @@ -113,34 +115,41 @@ options: config::Options, source_string: &str, (emitter, expected_err_count): (Box, usize), - body: F -) - where F: FnOnce(Env) + body: F, +) where + F: FnOnce(Env), { let diagnostic_handler = errors::Handler::with_emitter(true, false, emitter); - let sess = session::build_session_(options, - None, - diagnostic_handler, - Lrc::new(SourceMap::new(FilePathMapping::empty()))); + let sess = session::build_session_( + options, + None, + diagnostic_handler, + Lrc::new(SourceMap::new(FilePathMapping::empty())), + ); let cstore = CStore::new(::get_codegen_backend(&sess).metadata_loader()); rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess)); let input = config::Input::Str { name: FileName::Anon, input: source_string.to_string(), }; - let krate = driver::phase_1_parse_input(&driver::CompileController::basic(), - &sess, - &input).unwrap(); - let driver::ExpansionResult { defs, resolutions, mut hir_forest, .. } = { - driver::phase_2_configure_and_expand(&sess, - &cstore, - krate, - None, - "test", - None, - MakeGlobMap::No, - |_| Ok(())) - .expect("phase 2 aborted") + let krate = + driver::phase_1_parse_input(&driver::CompileController::basic(), &sess, &input).unwrap(); + let driver::ExpansionResult { + defs, + resolutions, + mut hir_forest, + .. + } = { + driver::phase_2_configure_and_expand( + &sess, + &cstore, + krate, + None, + "test", + None, + MakeGlobMap::No, + |_| Ok(()), + ).expect("phase 2 aborted") }; let arenas = ty::AllArenas::new(); @@ -155,32 +164,39 @@ extra: String::new(), outputs: OutputTypes::new(&[]), }; - TyCtxt::create_and_enter(&sess, - &cstore, - ty::query::Providers::default(), - ty::query::Providers::default(), - &arenas, - resolutions, - hir_map, - OnDiskCache::new_empty(sess.source_map()), - "test_crate", - tx, - &outputs, - |tcx| { - tcx.infer_ctxt().enter(|infcx| { - let mut region_scope_tree = region::ScopeTree::default(); - let param_env = ty::ParamEnv::empty(); - body(Env { - infcx: &infcx, - region_scope_tree: &mut region_scope_tree, - param_env: param_env, + TyCtxt::create_and_enter( + &sess, + &cstore, + ty::query::Providers::default(), + ty::query::Providers::default(), + &arenas, + resolutions, + hir_map, + OnDiskCache::new_empty(sess.source_map()), + "test_crate", + tx, + &outputs, + |tcx| { + tcx.infer_ctxt().enter(|infcx| { + let mut region_scope_tree = region::ScopeTree::default(); + let param_env = ty::ParamEnv::empty(); + body(Env { + infcx: &infcx, + region_scope_tree: &mut region_scope_tree, + param_env: param_env, + }); + let outlives_env = OutlivesEnvironment::new(param_env); + let def_id = tcx.hir.local_def_id(ast::CRATE_NODE_ID); + infcx.resolve_regions_and_report_errors( + def_id, + ®ion_scope_tree, + &outlives_env, + SuppressRegionErrors::default(), + ); + assert_eq!(tcx.sess.err_count(), expected_err_count); }); - let outlives_env = OutlivesEnvironment::new(param_env); - let def_id = tcx.hir.local_def_id(ast::CRATE_NODE_ID); - infcx.resolve_regions_and_report_errors(def_id, ®ion_scope_tree, &outlives_env); - assert_eq!(tcx.sess.err_count(), expected_err_count); - }); - }); + }, + ); } fn d1() -> ty::DebruijnIndex { @@ -196,9 +212,15 @@ self.infcx.tcx } - pub fn create_region_hierarchy(&mut self, rh: &RH, - parent: (region::Scope, region::ScopeDepth)) { - let me = region::Scope { id: rh.id, data: region::ScopeData::Node }; + pub fn create_region_hierarchy( + &mut self, + rh: &RH, + parent: (region::Scope, region::ScopeDepth), + ) { + let me = region::Scope { + id: rh.id, + data: region::ScopeData::Node, + }; self.region_scope_tree.record_scope_parent(me, Some(parent)); for child_rh in rh.sub { self.create_region_hierarchy(child_rh, (me, parent.1 + 1)); @@ -211,20 +233,25 @@ let dscope = region::Scope { id: hir::ItemLocalId(1), - data: region::ScopeData::Destruction + data: region::ScopeData::Destruction, }; self.region_scope_tree.record_scope_parent(dscope, None); - self.create_region_hierarchy(&RH { - id: hir::ItemLocalId(1), - sub: &[RH { - id: hir::ItemLocalId(10), - sub: &[], + self.create_region_hierarchy( + &RH { + id: hir::ItemLocalId(1), + sub: &[ + RH { + id: hir::ItemLocalId(10), + sub: &[], + }, + RH { + id: hir::ItemLocalId(11), + sub: &[], + }, + ], }, - RH { - id: hir::ItemLocalId(11), - sub: &[], - }], - }, (dscope, 1)); + (dscope, 1), + ); } #[allow(dead_code)] // this seems like it could be useful, even if we don't use it now @@ -236,11 +263,12 @@ } }; - fn search_mod(this: &Env, - m: &hir::Mod, - idx: usize, - names: &[String]) - -> Option { + fn search_mod( + this: &Env, + m: &hir::Mod, + idx: usize, + names: &[String], + ) -> Option { assert!(idx < names.len()); for item in &m.item_ids { let item = this.infcx.tcx.hir.expect_item(item.id); @@ -257,22 +285,22 @@ } return match it.node { - hir::ItemKind::Use(..) | - hir::ItemKind::ExternCrate(..) | - hir::ItemKind::Const(..) | - hir::ItemKind::Static(..) | - hir::ItemKind::Fn(..) | - hir::ItemKind::ForeignMod(..) | - hir::ItemKind::GlobalAsm(..) | - hir::ItemKind::Existential(..) | - hir::ItemKind::Ty(..) => None, - - hir::ItemKind::Enum(..) | - hir::ItemKind::Struct(..) | - hir::ItemKind::Union(..) | - hir::ItemKind::Trait(..) | - hir::ItemKind::TraitAlias(..) | - hir::ItemKind::Impl(..) => None, + hir::ItemKind::Use(..) + | hir::ItemKind::ExternCrate(..) + | hir::ItemKind::Const(..) + | hir::ItemKind::Static(..) + | hir::ItemKind::Fn(..) + | hir::ItemKind::ForeignMod(..) + | hir::ItemKind::GlobalAsm(..) + | hir::ItemKind::Existential(..) + | hir::ItemKind::Ty(..) => None, + + hir::ItemKind::Enum(..) + | hir::ItemKind::Struct(..) + | hir::ItemKind::Union(..) + | hir::ItemKind::Trait(..) + | hir::ItemKind::TraitAlias(..) + | hir::ItemKind::Impl(..) => None, hir::ItemKind::Mod(ref m) => search_mod(this, m, idx, names), }; @@ -280,7 +308,10 @@ } pub fn make_subtype(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> bool { - match self.infcx.at(&ObligationCause::dummy(), self.param_env).sub(a, b) { + match self.infcx + .at(&ObligationCause::dummy(), self.param_env) + .sub(a, b) + { Ok(_) => true, Err(ref e) => panic!("Encountered error: {}", e), } @@ -302,13 +333,15 @@ } pub fn t_fn(&self, input_tys: &[Ty<'tcx>], output_ty: Ty<'tcx>) -> Ty<'tcx> { - self.infcx.tcx.mk_fn_ptr(ty::Binder::bind(self.infcx.tcx.mk_fn_sig( - input_tys.iter().cloned(), - output_ty, - false, - hir::Unsafety::Normal, - Abi::Rust - ))) + self.infcx + .tcx + .mk_fn_ptr(ty::Binder::bind(self.infcx.tcx.mk_fn_sig( + input_tys.iter().cloned(), + output_ty, + false, + hir::Unsafety::Normal, + Abi::Rust, + ))) } pub fn t_nil(&self) -> Ty<'tcx> { @@ -321,23 +354,30 @@ pub fn t_param(&self, index: u32) -> Ty<'tcx> { let name = format!("T{}", index); - self.infcx.tcx.mk_ty_param(index, Symbol::intern(&name).as_interned_str()) + self.infcx + .tcx + .mk_ty_param(index, Symbol::intern(&name).as_interned_str()) } pub fn re_early_bound(&self, index: u32, name: &'static str) -> ty::Region<'tcx> { let name = Symbol::intern(name).as_interned_str(); - self.infcx.tcx.mk_region(ty::ReEarlyBound(ty::EarlyBoundRegion { - def_id: self.infcx.tcx.hir.local_def_id(ast::CRATE_NODE_ID), - index, - name, - })) - } - - pub fn re_late_bound_with_debruijn(&self, - id: u32, - debruijn: ty::DebruijnIndex) - -> ty::Region<'tcx> { - self.infcx.tcx.mk_region(ty::ReLateBound(debruijn, ty::BrAnon(id))) + self.infcx + .tcx + .mk_region(ty::ReEarlyBound(ty::EarlyBoundRegion { + def_id: self.infcx.tcx.hir.local_def_id(ast::CRATE_NODE_ID), + index, + name, + })) + } + + pub fn re_late_bound_with_debruijn( + &self, + id: u32, + debruijn: ty::DebruijnIndex, + ) -> ty::Region<'tcx> { + self.infcx + .tcx + .mk_region(ty::ReLateBound(debruijn, ty::BrAnon(id))) } pub fn t_rptr(&self, r: ty::Region<'tcx>) -> Ty<'tcx> { @@ -349,10 +389,11 @@ self.infcx.tcx.mk_imm_ref(r, self.tcx().types.isize) } - pub fn t_rptr_late_bound_with_debruijn(&self, - id: u32, - debruijn: ty::DebruijnIndex) - -> Ty<'tcx> { + pub fn t_rptr_late_bound_with_debruijn( + &self, + id: u32, + debruijn: ty::DebruijnIndex, + ) -> Ty<'tcx> { let r = self.re_late_bound_with_debruijn(id, debruijn); self.infcx.tcx.mk_imm_ref(r, self.tcx().types.isize) } @@ -360,9 +401,11 @@ pub fn t_rptr_scope(&self, id: u32) -> Ty<'tcx> { let r = ty::ReScope(region::Scope { id: hir::ItemLocalId(id), - data: region::ScopeData::Node + data: region::ScopeData::Node, }); - self.infcx.tcx.mk_imm_ref(self.infcx.tcx.mk_region(r), self.tcx().types.isize) + self.infcx + .tcx + .mk_imm_ref(self.infcx.tcx.mk_region(r), self.tcx().types.isize) } pub fn re_free(&self, id: u32) -> ty::Region<'tcx> { @@ -378,14 +421,19 @@ } pub fn sub(&self, t1: Ty<'tcx>, t2: Ty<'tcx>) -> InferResult<'tcx, ()> { - self.infcx.at(&ObligationCause::dummy(), self.param_env).sub(t1, t2) + self.infcx + .at(&ObligationCause::dummy(), self.param_env) + .sub(t1, t2) } /// Checks that `t1 <: t2` is true (this may register additional /// region checks). pub fn check_sub(&self, t1: Ty<'tcx>, t2: Ty<'tcx>) { match self.sub(t1, t2) { - Ok(InferOk { obligations, value: () }) => { + Ok(InferOk { + obligations, + value: (), + }) => { // None of these tests should require nested obligations: assert!(obligations.is_empty()); } @@ -445,8 +493,10 @@ env.create_simple_region_hierarchy(); let t_rptr_free1 = env.t_rptr_free(1); let t_rptr_bound1 = env.t_rptr_late_bound(1); - env.check_not_sub(env.t_fn(&[t_rptr_free1], env.tcx().types.isize), - env.t_fn(&[t_rptr_bound1], env.tcx().types.isize)); + env.check_not_sub( + env.t_fn(&[t_rptr_free1], env.tcx().types.isize), + env.t_fn(&[t_rptr_bound1], env.tcx().types.isize), + ); }) } @@ -462,8 +512,10 @@ env.create_simple_region_hierarchy(); let t_rptr_bound1 = env.t_rptr_late_bound(1); let t_rptr_free1 = env.t_rptr_free(1); - env.check_sub(env.t_fn(&[t_rptr_bound1], env.tcx().types.isize), - env.t_fn(&[t_rptr_free1], env.tcx().types.isize)); + env.check_sub( + env.t_fn(&[t_rptr_bound1], env.tcx().types.isize), + env.t_fn(&[t_rptr_free1], env.tcx().types.isize), + ); }) } @@ -476,10 +528,13 @@ //! does NOT hold for any instantiation of `_#1`. test_env(EMPTY_SOURCE_STR, errors(&[]), |env| { - let t_infer1 = env.infcx.next_ty_var(TypeVariableOrigin::MiscVariable(DUMMY_SP)); + let t_infer1 = env.infcx + .next_ty_var(TypeVariableOrigin::MiscVariable(DUMMY_SP)); let t_rptr_bound1 = env.t_rptr_late_bound(1); - env.check_not_sub(env.t_fn(&[t_infer1], env.tcx().types.isize), - env.t_fn(&[t_rptr_bound1], env.tcx().types.isize)); + env.check_not_sub( + env.t_fn(&[t_infer1], env.tcx().types.isize), + env.t_fn(&[t_rptr_bound1], env.tcx().types.isize), + ); }) } @@ -487,7 +542,6 @@ /// This requires adjusting the Debruijn index. #[test] fn subst_ty_renumber_bound() { - test_env(EMPTY_SOURCE_STR, errors(&[]), |env| { // Situation: // Theta = [A -> &'a foo] @@ -509,11 +563,10 @@ env.t_fn(&[t_ptr_bound2], env.t_nil()) }; - debug!("subst_bound: t_source={:?} substs={:?} t_substituted={:?} t_expected={:?}", - t_source, - substs, - t_substituted, - t_expected); + debug!( + "subst_bound: t_source={:?} substs={:?} t_substituted={:?} t_expected={:?}", + t_source, substs, t_substituted, t_expected + ); assert_eq!(t_substituted, t_expected); }) @@ -546,11 +599,10 @@ env.t_pair(t_rptr_bound1, env.t_fn(&[t_rptr_bound2], env.t_nil())) }; - debug!("subst_bound: t_source={:?} substs={:?} t_substituted={:?} t_expected={:?}", - t_source, - substs, - t_substituted, - t_expected); + debug!( + "subst_bound: t_source={:?} substs={:?} t_substituted={:?} t_expected={:?}", + t_source, substs, t_substituted, t_expected + ); assert_eq!(t_substituted, t_expected); }) @@ -559,7 +611,6 @@ /// Test that we correctly compute whether a type has escaping regions or not. #[test] fn escaping() { - test_env(EMPTY_SOURCE_STR, errors(&[]), |mut env| { // Situation: // Theta = [A -> &'a foo] @@ -608,11 +659,10 @@ env.t_fn(&[t_rptr_bound2], env.t_nil()) }; - debug!("subst_bound: t_source={:?} substs={:?} t_substituted={:?} t_expected={:?}", - t_source, - substs, - t_substituted, - t_expected); + debug!( + "subst_bound: t_source={:?} substs={:?} t_substituted={:?} t_expected={:?}", + t_source, substs, t_substituted, t_expected + ); assert_eq!(t_substituted, t_expected); }) @@ -627,9 +677,13 @@ let tup1_ty = tcx.intern_tup(&[int_ty, usize_ty, int_ty, usize_ty]); let tup2_ty = tcx.intern_tup(&[tup1_ty, tup1_ty, usize_ty]); let walked: Vec<_> = tup2_ty.walk().collect(); - assert_eq!(walked, - [tup2_ty, tup1_ty, int_ty, usize_ty, int_ty, usize_ty, tup1_ty, int_ty, - usize_ty, int_ty, usize_ty, usize_ty]); + assert_eq!( + walked, + [ + tup2_ty, tup1_ty, int_ty, usize_ty, int_ty, usize_ty, tup1_ty, int_ty, usize_ty, + int_ty, usize_ty, usize_ty + ] + ); }) } @@ -644,14 +698,16 @@ // types we expect to see (in order), plus a boolean saying // whether to skip the subtree. - let mut expected = vec![(tup2_ty, false), - (tup1_ty, false), - (int_ty, false), - (usize_ty, false), - (int_ty, false), - (usize_ty, false), - (tup1_ty, true), // skip the isize/usize/isize/usize - (usize_ty, false)]; + let mut expected = vec![ + (tup2_ty, false), + (tup1_ty, false), + (int_ty, false), + (usize_ty, false), + (int_ty, false), + (usize_ty, false), + (tup1_ty, true), // skip the isize/usize/isize/usize + (usize_ty, false), + ]; expected.reverse(); let mut walker = tup2_ty.walk(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_errors/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/librustc_errors/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/librustc_errors/Cargo.toml 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_errors/Cargo.toml 2018-12-04 23:41:40.000000000 +0000 @@ -9,6 +9,7 @@ crate-type = ["dylib"] [dependencies] +log = "0.4" serialize = { path = "../libserialize" } syntax_pos = { path = "../libsyntax_pos" } rustc_data_structures = { path = "../librustc_data_structures" } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_errors/diagnostic_builder.rs rustc-1.31.0+dfsg1+llvm/src/librustc_errors/diagnostic_builder.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_errors/diagnostic_builder.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_errors/diagnostic_builder.rs 2018-12-04 23:41:40.000000000 +0000 @@ -21,6 +21,10 @@ use syntax_pos::{MultiSpan, Span}; /// Used for emitting structured error messages and other diagnostic information. +/// +/// If there is some state in a downstream crate you would like to +/// access in the methods of `DiagnosticBuilder` here, consider +/// extending `HandlerFlags`, accessed via `self.handler.flags`. #[must_use] #[derive(Clone)] pub struct DiagnosticBuilder<'a> { @@ -39,16 +43,18 @@ /// it easy to declare such methods on the builder. macro_rules! forward { // Forward pattern for &self -> &Self - (pub fn $n:ident(&self, $($name:ident: $ty:ty),*) -> &Self) => { + (pub fn $n:ident(&self, $($name:ident: $ty:ty),* $(,)*) -> &Self) => { pub fn $n(&self, $($name: $ty),*) -> &Self { + #[allow(deprecated)] self.diagnostic.$n($($name),*); self } }; // Forward pattern for &mut self -> &mut Self - (pub fn $n:ident(&mut self, $($name:ident: $ty:ty),*) -> &mut Self) => { + (pub fn $n:ident(&mut self, $($name:ident: $ty:ty),* $(,)*) -> &mut Self) => { pub fn $n(&mut self, $($name: $ty),*) -> &mut Self { + #[allow(deprecated)] self.diagnostic.$n($($name),*); self } @@ -56,8 +62,12 @@ // Forward pattern for &mut self -> &mut Self, with S: Into // type parameter. No obvious way to make this more generic. - (pub fn $n:ident>(&mut self, $($name:ident: $ty:ty),*) -> &mut Self) => { + (pub fn $n:ident>( + &mut self, + $($name:ident: $ty:ty),* + $(,)*) -> &mut Self) => { pub fn $n>(&mut self, $($name: $ty),*) -> &mut Self { + #[allow(deprecated)] self.diagnostic.$n($($name),*); self } @@ -89,8 +99,14 @@ self.cancel(); } - /// Buffers the diagnostic for later emission. - pub fn buffer(self, buffered_diagnostics: &mut Vec) { + /// Buffers the diagnostic for later emission, unless handler + /// has disabled such buffering. + pub fn buffer(mut self, buffered_diagnostics: &mut Vec) { + if self.handler.flags.dont_buffer_diagnostics || self.handler.flags.treat_err_as_bug { + self.emit(); + return; + } + // We need to use `ptr::read` because `DiagnosticBuilder` // implements `Drop`. let diagnostic; @@ -98,6 +114,9 @@ diagnostic = ::std::ptr::read(&self.diagnostic); ::std::mem::forget(self); }; + // Logging here is useful to help track down where in logs an error was + // actually emitted. + debug!("buffer: diagnostic={:?}", diagnostic); buffered_diagnostics.push(diagnostic); } @@ -109,7 +128,7 @@ message: &str, span: Option, ) -> &mut Self { - let span = span.map(|s| s.into()).unwrap_or(MultiSpan::new()); + let span = span.map(|s| s.into()).unwrap_or_else(|| MultiSpan::new()); self.diagnostic.sub(level, message, span, None); self } @@ -144,49 +163,75 @@ forward!(pub fn note_expected_found(&mut self, label: &dyn fmt::Display, expected: DiagnosticStyledString, - found: DiagnosticStyledString) - -> &mut Self); + found: DiagnosticStyledString, + ) -> &mut Self); forward!(pub fn note_expected_found_extra(&mut self, label: &dyn fmt::Display, expected: DiagnosticStyledString, found: DiagnosticStyledString, expected_extra: &dyn fmt::Display, - found_extra: &dyn fmt::Display) - -> &mut Self); + found_extra: &dyn fmt::Display, + ) -> &mut Self); forward!(pub fn note(&mut self, msg: &str) -> &mut Self); forward!(pub fn span_note>(&mut self, sp: S, - msg: &str) - -> &mut Self); + msg: &str, + ) -> &mut Self); forward!(pub fn warn(&mut self, msg: &str) -> &mut Self); forward!(pub fn span_warn>(&mut self, sp: S, msg: &str) -> &mut Self); forward!(pub fn help(&mut self , msg: &str) -> &mut Self); forward!(pub fn span_help>(&mut self, sp: S, - msg: &str) - -> &mut Self); - forward!(pub fn span_suggestion_short(&mut self, - sp: Span, - msg: &str, - suggestion: String) - -> &mut Self); + msg: &str, + ) -> &mut Self); + + #[deprecated(note = "Use `span_suggestion_short_with_applicability`")] + forward!(pub fn span_suggestion_short( + &mut self, + sp: Span, + msg: &str, + suggestion: String, + ) -> &mut Self); + + #[deprecated(note = "Use `multipart_suggestion_with_applicability`")] forward!(pub fn multipart_suggestion( &mut self, msg: &str, - suggestion: Vec<(Span, String)> + suggestion: Vec<(Span, String)>, ) -> &mut Self); + + #[deprecated(note = "Use `span_suggestion_with_applicability`")] forward!(pub fn span_suggestion(&mut self, sp: Span, msg: &str, - suggestion: String) - -> &mut Self); + suggestion: String, + ) -> &mut Self); + + #[deprecated(note = "Use `span_suggestions_with_applicability`")] forward!(pub fn span_suggestions(&mut self, sp: Span, msg: &str, - suggestions: Vec) - -> &mut Self); + suggestions: Vec, + ) -> &mut Self); + + pub fn multipart_suggestion_with_applicability(&mut self, + msg: &str, + suggestion: Vec<(Span, String)>, + applicability: Applicability, + ) -> &mut Self { + if !self.allow_suggestions { + return self + } + self.diagnostic.multipart_suggestion_with_applicability( + msg, + suggestion, + applicability, + ); + self + } + pub fn span_suggestion_with_applicability(&mut self, sp: Span, msg: &str, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_errors/diagnostic.rs rustc-1.31.0+dfsg1+llvm/src/librustc_errors/diagnostic.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_errors/diagnostic.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_errors/diagnostic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -76,9 +76,9 @@ } impl StringPart { - pub fn content(&self) -> String { + pub fn content(&self) -> &str { match self { - &StringPart::Normal(ref s) | & StringPart::Highlighted(ref s) => s.to_owned() + &StringPart::Normal(ref s) | & StringPart::Highlighted(ref s) => s } } } @@ -232,6 +232,7 @@ /// inline it will only show the text message and not the text. /// /// See `CodeSuggestion` for more information. + #[deprecated(note = "Use `span_suggestion_short_with_applicability`")] pub fn span_suggestion_short(&mut self, sp: Span, msg: &str, suggestion: String) -> &mut Self { self.suggestions.push(CodeSuggestion { substitutions: vec![Substitution { @@ -263,6 +264,7 @@ /// * may contain a name of a function, variable or type, but not whole expressions /// /// See `CodeSuggestion` for more information. + #[deprecated(note = "Use `span_suggestion_with_applicability`")] pub fn span_suggestion(&mut self, sp: Span, msg: &str, suggestion: String) -> &mut Self { self.suggestions.push(CodeSuggestion { substitutions: vec![Substitution { @@ -278,10 +280,11 @@ self } - pub fn multipart_suggestion( + pub fn multipart_suggestion_with_applicability( &mut self, msg: &str, suggestion: Vec<(Span, String)>, + applicability: Applicability, ) -> &mut Self { self.suggestions.push(CodeSuggestion { substitutions: vec![Substitution { @@ -292,12 +295,26 @@ }], msg: msg.to_owned(), show_code_when_inline: true, - applicability: Applicability::Unspecified, + applicability, }); self } + #[deprecated(note = "Use `multipart_suggestion_with_applicability`")] + pub fn multipart_suggestion( + &mut self, + msg: &str, + suggestion: Vec<(Span, String)>, + ) -> &mut Self { + self.multipart_suggestion_with_applicability( + msg, + suggestion, + Applicability::Unspecified, + ) + } + /// Prints out a message with multiple suggested edits of the code. + #[deprecated(note = "Use `span_suggestions_with_applicability`")] pub fn span_suggestions(&mut self, sp: Span, msg: &str, suggestions: Vec) -> &mut Self { self.suggestions.push(CodeSuggestion { substitutions: suggestions.into_iter().map(|snippet| Substitution { @@ -381,7 +398,7 @@ } pub fn message(&self) -> String { - self.message.iter().map(|i| i.0.to_owned()).collect::() + self.message.iter().map(|i| i.0.as_str()).collect::() } pub fn styled_message(&self) -> &Vec<(String, Style)> { @@ -431,7 +448,7 @@ impl SubDiagnostic { pub fn message(&self) -> String { - self.message.iter().map(|i| i.0.to_owned()).collect::() + self.message.iter().map(|i| i.0.as_str()).collect::() } pub fn styled_message(&self) -> &Vec<(String, Style)> { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_errors/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_errors/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_errors/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_errors/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,14 +16,15 @@ #![allow(unused_attributes)] #![feature(range_contains)] #![cfg_attr(unix, feature(libc))] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(optin_builtin_traits)] extern crate atty; extern crate termcolor; #[cfg(unix)] extern crate libc; +#[macro_use] +extern crate log; extern crate rustc_data_structures; extern crate serialize as rustc_serialize; extern crate syntax_pos; @@ -304,9 +305,20 @@ #[derive(Default)] pub struct HandlerFlags { + /// If false, warning-level lints are suppressed. + /// (rustc: see `--allow warnings` and `--cap-lints`) pub can_emit_warnings: bool, + /// If true, error-level diagnostics are upgraded to bug-level. + /// (rustc: see `-Z treat-err-as-bug`) pub treat_err_as_bug: bool, + /// If true, immediately emit diagnostics that would otherwise be buffered. + /// (rustc: see `-Z dont-buffer-diagnostics` and `-Z treat-err-as-bug`) + pub dont_buffer_diagnostics: bool, + /// If true, immediately print bugs registered with `delay_span_bug`. + /// (rustc: see `-Z report-delayed-bugs`) pub report_delayed_bugs: bool, + /// show macro backtraces even for non-local macros. + /// (rustc: see `-Z external-macro-backtrace`) pub external_macro_backtrace: bool, } @@ -370,9 +382,9 @@ emitter: Lock::new(e), continue_after_error: LockCell::new(true), delayed_span_bugs: Lock::new(Vec::new()), - taught_diagnostics: Lock::new(FxHashSet()), - emitted_diagnostic_codes: Lock::new(FxHashSet()), - emitted_diagnostics: Lock::new(FxHashSet()), + taught_diagnostics: Default::default(), + emitted_diagnostic_codes: Default::default(), + emitted_diagnostics: Default::default(), } } @@ -386,7 +398,8 @@ /// tools that want to reuse a `Parser` cleaning the previously emitted diagnostics as well as /// the overall count of emitted error diagnostics. pub fn reset_err_count(&self) { - *self.emitted_diagnostics.borrow_mut() = FxHashSet(); + // actually frees the underlying memory (which `clear` would not do) + *self.emitted_diagnostics.borrow_mut() = Default::default(); self.err_count.store(0, SeqCst); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_incremental/assert_dep_graph.rs rustc-1.31.0+dfsg1+llvm/src/librustc_incremental/assert_dep_graph.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_incremental/assert_dep_graph.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_incremental/assert_dep_graph.rs 2018-12-04 23:41:40.000000000 +0000 @@ -55,7 +55,6 @@ use rustc::hir; use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc::ich::{ATTR_IF_THIS_CHANGED, ATTR_THEN_THIS_WOULD_NEED}; -use graphviz::IntoCow; use std::env; use std::fs::{self, File}; use std::io::Write; @@ -274,10 +273,10 @@ type Edge = (&'q DepNode, &'q DepNode); fn nodes(&self) -> dot::Nodes<&'q DepNode> { let nodes: Vec<_> = self.0.iter().cloned().collect(); - nodes.into_cow() + nodes.into() } fn edges(&self) -> dot::Edges<(&'q DepNode, &'q DepNode)> { - self.1[..].into_cow() + self.1[..].into() } fn source(&self, edge: &(&'q DepNode, &'q DepNode)) -> &'q DepNode { edge.0 @@ -344,7 +343,7 @@ direction: Direction) -> FxHashSet<&'q DepNode> { - let mut set = FxHashSet(); + let mut set = FxHashSet::default(); for &start in starts { debug!("walk_nodes: start={:?} outgoing?={:?}", start, direction == OUTGOING); if set.insert(start) { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_incremental/assert_module_sources.rs rustc-1.31.0+dfsg1+llvm/src/librustc_incremental/assert_module_sources.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_incremental/assert_module_sources.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_incremental/assert_module_sources.rs 2018-12-04 23:41:40.000000000 +0000 @@ -26,19 +26,23 @@ //! The reason that we use `cfg=...` and not `#[cfg_attr]` is so that //! the HIR doesn't change as a result of the annotations, which might //! perturb the reuse results. +//! +//! `#![rustc_expected_cgu_reuse(module="spike", cfg="rpass2", kind="post-lto")] +//! allows for doing a more fine-grained check to see if pre- or post-lto data +//! was re-used. use rustc::hir::def_id::LOCAL_CRATE; -use rustc::dep_graph::{DepNode, DepConstructor}; +use rustc::dep_graph::cgu_reuse_tracker::*; use rustc::mir::mono::CodegenUnitNameBuilder; use rustc::ty::TyCtxt; +use std::collections::BTreeSet; use syntax::ast; -use rustc::ich::{ATTR_PARTITION_REUSED, ATTR_PARTITION_CODEGENED}; +use rustc::ich::{ATTR_PARTITION_REUSED, ATTR_PARTITION_CODEGENED, + ATTR_EXPECTED_CGU_REUSE}; const MODULE: &'static str = "module"; const CFG: &'static str = "cfg"; - -#[derive(Debug, PartialEq, Clone, Copy)] -enum Disposition { Reused, Codegened } +const KIND: &'static str = "kind"; pub fn assert_module_sources<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { tcx.dep_graph.with_ignore(|| { @@ -46,7 +50,18 @@ return; } - let ams = AssertModuleSource { tcx }; + let available_cgus = tcx + .collect_and_partition_mono_items(LOCAL_CRATE) + .1 + .iter() + .map(|cgu| format!("{}", cgu.name())) + .collect::>(); + + let ams = AssertModuleSource { + tcx, + available_cgus + }; + for attr in &tcx.hir.krate().attrs { ams.check_attr(attr); } @@ -54,19 +69,39 @@ } struct AssertModuleSource<'a, 'tcx: 'a> { - tcx: TyCtxt<'a, 'tcx, 'tcx> + tcx: TyCtxt<'a, 'tcx, 'tcx>, + available_cgus: BTreeSet, } impl<'a, 'tcx> AssertModuleSource<'a, 'tcx> { fn check_attr(&self, attr: &ast::Attribute) { - let disposition = if attr.check_name(ATTR_PARTITION_REUSED) { - Disposition::Reused + let (expected_reuse, comp_kind) = if attr.check_name(ATTR_PARTITION_REUSED) { + (CguReuse::PreLto, ComparisonKind::AtLeast) } else if attr.check_name(ATTR_PARTITION_CODEGENED) { - Disposition::Codegened + (CguReuse::No, ComparisonKind::Exact) + } else if attr.check_name(ATTR_EXPECTED_CGU_REUSE) { + match &self.field(attr, KIND).as_str()[..] { + "no" => (CguReuse::No, ComparisonKind::Exact), + "pre-lto" => (CguReuse::PreLto, ComparisonKind::Exact), + "post-lto" => (CguReuse::PostLto, ComparisonKind::Exact), + "any" => (CguReuse::PreLto, ComparisonKind::AtLeast), + other => { + self.tcx.sess.span_fatal( + attr.span, + &format!("unknown cgu-reuse-kind `{}` specified", other)); + } + } } else { return; }; + if !self.tcx.sess.opts.debugging_opts.query_dep_graph { + self.tcx.sess.span_fatal( + attr.span, + &format!("found CGU-reuse attribute but `-Zquery-dep-graph` \ + was not specified")); + } + if !self.check_config(attr) { debug!("check_attr: config does not match, ignoring attr"); return; @@ -101,43 +136,24 @@ debug!("mapping '{}' to cgu name '{}'", self.field(attr, MODULE), cgu_name); - let dep_node = DepNode::new(self.tcx, - DepConstructor::CompileCodegenUnit(cgu_name)); - - if let Some(loaded_from_cache) = self.tcx.dep_graph.was_loaded_from_cache(&dep_node) { - match (disposition, loaded_from_cache) { - (Disposition::Reused, false) => { - self.tcx.sess.span_err( - attr.span, - &format!("expected module named `{}` to be Reused but is Codegened", - user_path)); - } - (Disposition::Codegened, true) => { - self.tcx.sess.span_err( - attr.span, - &format!("expected module named `{}` to be Codegened but is Reused", - user_path)); - } - (Disposition::Reused, true) | - (Disposition::Codegened, false) => { - // These are what we would expect. - } - } - } else { - let available_cgus = self.tcx - .collect_and_partition_mono_items(LOCAL_CRATE) - .1 - .iter() - .map(|cgu| format!("{}", cgu.name())) - .collect::>() - .join(", "); - + if !self.available_cgus.contains(&cgu_name.as_str()[..]) { self.tcx.sess.span_err(attr.span, - &format!("no module named `{}` (mangled: {}).\nAvailable modules: {}", + &format!("no module named `{}` (mangled: {}). \ + Available modules: {}", user_path, cgu_name, - available_cgus)); + self.available_cgus + .iter() + .cloned() + .collect::>() + .join(", "))); } + + self.tcx.sess.cgu_reuse_tracker.set_expectation(&cgu_name.as_str(), + &user_path, + attr.span, + expected_reuse, + comp_kind); } fn field(&self, attr: &ast::Attribute, name: &str) -> ast::Name { @@ -171,5 +187,4 @@ debug!("check_config: no match found"); return false; } - } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_incremental/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_incremental/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_incremental/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_incremental/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,8 +14,7 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(specialization)] #![recursion_limit="256"] diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_incremental/persist/dirty_clean.rs rustc-1.31.0+dfsg1+llvm/src/librustc_incremental/persist/dirty_clean.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_incremental/persist/dirty_clean.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_incremental/persist/dirty_clean.rs 2018-12-04 23:41:40.000000000 +0000 @@ -226,7 +226,7 @@ let krate = tcx.hir.krate(); let mut dirty_clean_visitor = DirtyCleanVisitor { tcx, - checked_attrs: FxHashSet(), + checked_attrs: Default::default(), }; krate.visit_all_item_likes(&mut dirty_clean_visitor); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_incremental/persist/fs.rs rustc-1.31.0+dfsg1+llvm/src/librustc_incremental/persist/fs.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_incremental/persist/fs.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_incremental/persist/fs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -219,7 +219,7 @@ } }; - let mut source_directories_already_tried = FxHashSet(); + let mut source_directories_already_tried = FxHashSet::default(); loop { // Generate a session directory of the form: @@ -656,8 +656,8 @@ // First do a pass over the crate directory, collecting lock files and // session directories - let mut session_directories = FxHashSet(); - let mut lock_files = FxHashSet(); + let mut session_directories = FxHashSet::default(); + let mut lock_files = FxHashSet::default(); for dir_entry in try!(crate_directory.read_dir()) { let dir_entry = match dir_entry { @@ -875,7 +875,7 @@ .map(|(_, path, lock)| (path, lock)) .collect() } else { - FxHashMap() + FxHashMap::default() } } @@ -924,7 +924,7 @@ assert_eq!(all_except_most_recent( vec![ ]).keys().cloned().collect::>(), - FxHashSet() + FxHashSet::default() ); } @@ -939,7 +939,7 @@ #[test] fn test_find_source_directory_in_iter() { - let already_visited = FxHashSet(); + let already_visited = FxHashSet::default(); // Find newest assert_eq!(find_source_directory_in_iter( diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_incremental/persist/load.rs rustc-1.31.0+dfsg1+llvm/src/librustc_incremental/persist/load.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_incremental/persist/load.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_incremental/persist/load.rs 2018-12-04 23:41:40.000000000 +0000 @@ -48,7 +48,7 @@ match self { LoadResult::Error { message } => { sess.warn(&message); - (PreviousDepGraph::new(SerializedDepGraph::new()), FxHashMap()) + Default::default() }, LoadResult::DataOutOfDate => { if let Err(err) = delete_all_session_dir_contents(sess) { @@ -56,7 +56,7 @@ incremental compilation session directory contents `{}`: {}.", dep_graph_path(sess).display(), err)); } - (PreviousDepGraph::new(SerializedDepGraph::new()), FxHashMap()) + Default::default() } LoadResult::Ok { data } => data } @@ -117,7 +117,7 @@ if sess.opts.incremental.is_none() { // No incremental compilation. return MaybeAsync::Sync(LoadResult::Ok { - data: (PreviousDepGraph::new(SerializedDepGraph::new()), FxHashMap()) + data: Default::default(), }); } @@ -127,7 +127,7 @@ let report_incremental_info = sess.opts.debugging_opts.incremental_info; let expected_hash = sess.opts.dep_tracking_hash(); - let mut prev_work_products = FxHashMap(); + let mut prev_work_products = FxHashMap::default(); // If we are only building with -Zquery-dep-graph but without an actual // incr. comp. session directory, we skip this. Otherwise we'd fail diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_incremental/persist/save.rs rustc-1.31.0+dfsg1+llvm/src/librustc_incremental/persist/save.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_incremental/persist/save.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_incremental/persist/save.rs 2018-12-04 23:41:40.000000000 +0000 @@ -162,7 +162,7 @@ let (total_edge_reads, total_duplicate_edge_reads) = tcx.dep_graph.edge_deduplication_data(); - let mut counts: FxHashMap<_, Stat> = FxHashMap(); + let mut counts: FxHashMap<_, Stat> = FxHashMap::default(); for (i, &node) in serialized_graph.nodes.iter_enumerated() { let stat = counts.entry(node.kind).or_insert(Stat { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_lint/builtin.rs rustc-1.31.0+dfsg1+llvm/src/librustc_lint/builtin.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_lint/builtin.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_lint/builtin.rs 2018-12-04 23:41:40.000000000 +0000 @@ -30,10 +30,7 @@ use rustc::hir::def::Def; use rustc::hir::def_id::DefId; -use rustc::cfg; -use rustc::ty::subst::Substs; use rustc::ty::{self, Ty}; -use rustc::traits; use hir::Node; use util::nodemap::NodeSet; use lint::{LateContext, LintContext, LintArray}; @@ -43,6 +40,8 @@ use syntax::tokenstream::{TokenTree, TokenStream}; use syntax::ast; +use syntax::ptr::P; +use syntax::ast::Expr; use syntax::attr; use syntax::source_map::Spanned; use syntax::edition::Edition; @@ -50,6 +49,7 @@ use syntax_pos::{BytePos, Span, SyntaxContext}; use syntax::symbol::keywords; use syntax::errors::{Applicability, DiagnosticBuilder}; +use syntax::print::pprust::expr_to_string; use rustc::hir::{self, GenericParamKind, PatKind}; use rustc::hir::intravisit::FnKind; @@ -783,7 +783,7 @@ fn check_attribute(&mut self, cx: &EarlyContext, attr: &ast::Attribute) { for &&(n, _, ref g) in &self.depr_attrs { if attr.name() == n { - if let &AttributeGate::Gated(Stability::Deprecated(link), + if let &AttributeGate::Gated(Stability::Deprecated(link, suggestion), ref name, ref reason, _) = g { @@ -792,7 +792,7 @@ let mut err = cx.struct_span_lint(DEPRECATED, attr.span, &msg); err.span_suggestion_short_with_applicability( attr.span, - "remove this attribute", + suggestion.unwrap_or("remove this attribute"), String::new(), Applicability::MachineApplicable ); @@ -845,279 +845,6 @@ } declare_lint! { - pub UNCONDITIONAL_RECURSION, - Warn, - "functions that cannot return without calling themselves" -} - -#[derive(Copy, Clone)] -pub struct UnconditionalRecursion; - - -impl LintPass for UnconditionalRecursion { - fn get_lints(&self) -> LintArray { - lint_array![UNCONDITIONAL_RECURSION] - } -} - -impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnconditionalRecursion { - fn check_fn(&mut self, - cx: &LateContext, - fn_kind: FnKind, - _: &hir::FnDecl, - body: &hir::Body, - sp: Span, - id: ast::NodeId) { - let method = match fn_kind { - FnKind::ItemFn(..) => None, - FnKind::Method(..) => { - Some(cx.tcx.associated_item(cx.tcx.hir.local_def_id(id))) - } - // closures can't recur, so they don't matter. - FnKind::Closure(_) => return, - }; - - // Walk through this function (say `f`) looking to see if - // every possible path references itself, i.e. the function is - // called recursively unconditionally. This is done by trying - // to find a path from the entry node to the exit node that - // *doesn't* call `f` by traversing from the entry while - // pretending that calls of `f` are sinks (i.e. ignoring any - // exit edges from them). - // - // NB. this has an edge case with non-returning statements, - // like `loop {}` or `panic!()`: control flow never reaches - // the exit node through these, so one can have a function - // that never actually calls itself but is still picked up by - // this lint: - // - // fn f(cond: bool) { - // if !cond { panic!() } // could come from `assert!(cond)` - // f(false) - // } - // - // In general, functions of that form may be able to call - // itself a finite number of times and then diverge. The lint - // considers this to be an error for two reasons, (a) it is - // easier to implement, and (b) it seems rare to actually want - // to have behaviour like the above, rather than - // e.g. accidentally recursing after an assert. - - let cfg = cfg::CFG::new(cx.tcx, &body); - - let mut work_queue = vec![cfg.entry]; - let mut reached_exit_without_self_call = false; - let mut self_call_spans = vec![]; - let mut visited = FxHashSet::default(); - - while let Some(idx) = work_queue.pop() { - if idx == cfg.exit { - // found a path! - reached_exit_without_self_call = true; - break; - } - - let cfg_id = idx.node_id(); - if visited.contains(&cfg_id) { - // already done - continue; - } - visited.insert(cfg_id); - - // is this a recursive call? - let local_id = cfg.graph.node_data(idx).id(); - if local_id != hir::DUMMY_ITEM_LOCAL_ID { - let node_id = cx.tcx.hir.hir_to_node_id(hir::HirId { - owner: body.value.hir_id.owner, - local_id - }); - let self_recursive = match method { - Some(ref method) => expr_refers_to_this_method(cx, method, node_id), - None => expr_refers_to_this_fn(cx, id, node_id), - }; - if self_recursive { - self_call_spans.push(cx.tcx.hir.span(node_id)); - // this is a self call, so we shouldn't explore past - // this node in the CFG. - continue; - } - } - - // add the successors of this node to explore the graph further. - for (_, edge) in cfg.graph.outgoing_edges(idx) { - let target_idx = edge.target(); - let target_cfg_id = target_idx.node_id(); - if !visited.contains(&target_cfg_id) { - work_queue.push(target_idx) - } - } - } - - // Check the number of self calls because a function that - // doesn't return (e.g. calls a `-> !` function or `loop { /* - // no break */ }`) shouldn't be linted unless it actually - // recurs. - if !reached_exit_without_self_call && !self_call_spans.is_empty() { - let sp = cx.tcx.sess.source_map().def_span(sp); - let mut db = cx.struct_span_lint(UNCONDITIONAL_RECURSION, - sp, - "function cannot return without recursing"); - db.span_label(sp, "cannot return without recursing"); - // offer some help to the programmer. - for call in &self_call_spans { - db.span_label(*call, "recursive call site"); - } - db.help("a `loop` may express intention better if this is on purpose"); - db.emit(); - } - - // all done - return; - - // Functions for identifying if the given Expr NodeId `id` - // represents a call to the function `fn_id`/method `method`. - - fn expr_refers_to_this_fn(cx: &LateContext, fn_id: ast::NodeId, id: ast::NodeId) -> bool { - match cx.tcx.hir.get(id) { - Node::Expr(&hir::Expr { node: hir::ExprKind::Call(ref callee, _), .. }) => { - let def = if let hir::ExprKind::Path(ref qpath) = callee.node { - cx.tables.qpath_def(qpath, callee.hir_id) - } else { - return false; - }; - match def { - Def::Local(..) | Def::Upvar(..) => false, - _ => def.def_id() == cx.tcx.hir.local_def_id(fn_id) - } - } - _ => false, - } - } - - // Check if the expression `id` performs a call to `method`. - fn expr_refers_to_this_method(cx: &LateContext, - method: &ty::AssociatedItem, - id: ast::NodeId) - -> bool { - use rustc::ty::adjustment::*; - - // Ignore non-expressions. - let expr = if let Node::Expr(e) = cx.tcx.hir.get(id) { - e - } else { - return false; - }; - - // Check for overloaded autoderef method calls. - let mut source = cx.tables.expr_ty(expr); - for adjustment in cx.tables.expr_adjustments(expr) { - if let Adjust::Deref(Some(deref)) = adjustment.kind { - let (def_id, substs) = deref.method_call(cx.tcx, source); - if method_call_refers_to_method(cx, method, def_id, substs, id) { - return true; - } - } - source = adjustment.target; - } - - // Check for method calls and overloaded operators. - if cx.tables.is_method_call(expr) { - let hir_id = cx.tcx.hir.definitions().node_to_hir_id(id); - if let Some(def) = cx.tables.type_dependent_defs().get(hir_id) { - let def_id = def.def_id(); - let substs = cx.tables.node_substs(hir_id); - if method_call_refers_to_method(cx, method, def_id, substs, id) { - return true; - } - } else { - cx.tcx.sess.delay_span_bug(expr.span, - "no type-dependent def for method call"); - } - } - - // Check for calls to methods via explicit paths (e.g. `T::method()`). - match expr.node { - hir::ExprKind::Call(ref callee, _) => { - let def = if let hir::ExprKind::Path(ref qpath) = callee.node { - cx.tables.qpath_def(qpath, callee.hir_id) - } else { - return false; - }; - match def { - Def::Method(def_id) => { - let substs = cx.tables.node_substs(callee.hir_id); - method_call_refers_to_method(cx, method, def_id, substs, id) - } - _ => false, - } - } - _ => false, - } - } - - // Check if the method call to the method with the ID `callee_id` - // and instantiated with `callee_substs` refers to method `method`. - fn method_call_refers_to_method<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, - method: &ty::AssociatedItem, - callee_id: DefId, - callee_substs: &Substs<'tcx>, - expr_id: ast::NodeId) - -> bool { - let tcx = cx.tcx; - let callee_item = tcx.associated_item(callee_id); - - match callee_item.container { - // This is an inherent method, so the `def_id` refers - // directly to the method definition. - ty::ImplContainer(_) => callee_id == method.def_id, - - // A trait method, from any number of possible sources. - // Attempt to select a concrete impl before checking. - ty::TraitContainer(trait_def_id) => { - let trait_ref = ty::TraitRef::from_method(tcx, trait_def_id, callee_substs); - let trait_ref = ty::Binder::bind(trait_ref); - let span = tcx.hir.span(expr_id); - let obligation = - traits::Obligation::new(traits::ObligationCause::misc(span, expr_id), - cx.param_env, - trait_ref.to_poly_trait_predicate()); - - tcx.infer_ctxt().enter(|infcx| { - let mut selcx = traits::SelectionContext::new(&infcx); - match selcx.select(&obligation) { - // The method comes from a `T: Trait` bound. - // If `T` is `Self`, then this call is inside - // a default method definition. - Ok(Some(traits::VtableParam(_))) => { - let on_self = trait_ref.self_ty().is_self(); - // We can only be recursing in a default - // method if we're being called literally - // on the `Self` type. - on_self && callee_id == method.def_id - } - - // The `impl` is known, so we check that with a - // special case: - Ok(Some(traits::VtableImpl(vtable_impl))) => { - let container = ty::ImplContainer(vtable_impl.impl_def_id); - // It matches if it comes from the same impl, - // and has the same method name. - container == method.container && - callee_item.ident.name == method.ident.name - } - - // There's no way to know if this call is - // recursive, so we assume it's not. - _ => false, - } - }) - } - } - } - } -} - -declare_lint! { PLUGIN_AS_LIBRARY, Warn, "compiler plugin used as ordinary library in non-plugin crate" @@ -1164,18 +891,6 @@ } declare_lint! { - PRIVATE_NO_MANGLE_FNS, - Warn, - "functions marked #[no_mangle] should be exported" -} - -declare_lint! { - PRIVATE_NO_MANGLE_STATICS, - Warn, - "statics marked #[no_mangle] should be exported" -} - -declare_lint! { NO_MANGLE_CONST_ITEMS, Deny, "const items will not have their symbols exported" @@ -1192,52 +907,16 @@ impl LintPass for InvalidNoMangleItems { fn get_lints(&self) -> LintArray { - lint_array!(PRIVATE_NO_MANGLE_FNS, - PRIVATE_NO_MANGLE_STATICS, - NO_MANGLE_CONST_ITEMS, + lint_array!(NO_MANGLE_CONST_ITEMS, NO_MANGLE_GENERIC_ITEMS) } } impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems { fn check_item(&mut self, cx: &LateContext, it: &hir::Item) { - let suggest_export = |vis: &hir::Visibility, err: &mut DiagnosticBuilder| { - let suggestion = match vis.node { - hir::VisibilityKind::Inherited => { - // inherited visibility is empty span at item start; need an extra space - Some("pub ".to_owned()) - }, - hir::VisibilityKind::Restricted { .. } | - hir::VisibilityKind::Crate(_) => { - Some("pub".to_owned()) - }, - hir::VisibilityKind::Public => { - err.help("try exporting the item with a `pub use` statement"); - None - } - }; - if let Some(replacement) = suggestion { - err.span_suggestion_with_applicability( - vis.span, - "try making it public", - replacement, - Applicability::MachineApplicable - ); - } - }; - match it.node { hir::ItemKind::Fn(.., ref generics, _) => { if let Some(no_mangle_attr) = attr::find_by_name(&it.attrs, "no_mangle") { - if attr::contains_name(&it.attrs, "linkage") { - return; - } - if !cx.access_levels.is_reachable(it.id) { - let msg = "function is marked #[no_mangle], but not exported"; - let mut err = cx.struct_span_lint(PRIVATE_NO_MANGLE_FNS, it.span, msg); - suggest_export(&it.vis, &mut err); - err.emit(); - } for param in &generics.params { match param.kind { GenericParamKind::Lifetime { .. } => {} @@ -1261,15 +940,6 @@ } } } - hir::ItemKind::Static(..) => { - if attr::contains_name(&it.attrs, "no_mangle") && - !cx.access_levels.is_reachable(it.id) { - let msg = "static is marked #[no_mangle], but not exported"; - let mut err = cx.struct_span_lint(PRIVATE_NO_MANGLE_STATICS, it.span, msg); - suggest_export(&it.vis, &mut err); - err.emit(); - } - } hir::ItemKind::Const(..) => { if attr::contains_name(&it.attrs, "no_mangle") { // Const items do not refer to a particular location in memory, and therefore @@ -1612,18 +1282,16 @@ gid: ::rustc::mir::interpret::GlobalId<'tcx>, what: &str, ) { - let ecx = ::rustc_mir::interpret::mk_eval_cx(tcx, gid.instance, param_env).unwrap(); + let ecx = ::rustc_mir::const_eval::mk_eval_cx(tcx, gid.instance, param_env).unwrap(); let result = (|| { let op = ecx.const_to_op(constant)?; - let mut todo = vec![(op, Vec::new())]; - let mut seen = FxHashSet(); - seen.insert(op); - while let Some((op, mut path)) = todo.pop() { + let mut ref_tracking = ::rustc_mir::interpret::RefTracking::new(op); + while let Some((op, mut path)) = ref_tracking.todo.pop() { ecx.validate_operand( op, &mut path, - &mut seen, - &mut todo, + Some(&mut ref_tracking), + /* const_mode */ true, )?; } Ok(()) @@ -1736,8 +1404,8 @@ if cx.tcx.features().trivial_bounds { let def_id = cx.tcx.hir.local_def_id(item.id); let predicates = cx.tcx.predicates_of(def_id); - for predicate in &predicates.predicates { - let predicate_kind_name = match *predicate { + for &(predicate, span) in &predicates.predicates { + let predicate_kind_name = match predicate { Trait(..) => "Trait", TypeOutlives(..) | RegionOutlives(..) => "Lifetime", @@ -1755,7 +1423,7 @@ if predicate.is_global() { cx.span_lint( TRIVIAL_BOUNDS, - item.span, + span, &format!("{} bound {} does not depend on any type \ or lifetime parameters", predicate_kind_name, predicate), ); @@ -1783,10 +1451,7 @@ MISSING_DEBUG_IMPLEMENTATIONS, ANONYMOUS_PARAMETERS, UNUSED_DOC_COMMENTS, - UNCONDITIONAL_RECURSION, PLUGIN_AS_LIBRARY, - PRIVATE_NO_MANGLE_FNS, - PRIVATE_NO_MANGLE_STATICS, NO_MANGLE_CONST_ITEMS, NO_MANGLE_GENERIC_ITEMS, MUTABLE_TRANSMUTES, @@ -1815,21 +1480,48 @@ } impl EarlyLintPass for EllipsisInclusiveRangePatterns { - fn check_pat(&mut self, cx: &EarlyContext, pat: &ast::Pat) { - use self::ast::{PatKind, RangeEnd, RangeSyntax}; + fn check_pat(&mut self, cx: &EarlyContext, pat: &ast::Pat, visit_subpats: &mut bool) { + use self::ast::{PatKind, RangeEnd, RangeSyntax::DotDotDot}; + + /// If `pat` is a `...` pattern, return the start and end of the range, as well as the span + /// corresponding to the ellipsis. + fn matches_ellipsis_pat(pat: &ast::Pat) -> Option<(&P, &P, Span)> { + match &pat.node { + PatKind::Range(a, b, Spanned { span, node: RangeEnd::Included(DotDotDot), .. }) => { + Some((a, b, *span)) + } + _ => None, + } + } + + let (parenthesise, endpoints) = match &pat.node { + PatKind::Ref(subpat, _) => (true, matches_ellipsis_pat(&subpat)), + _ => (false, matches_ellipsis_pat(pat)), + }; - if let PatKind::Range( - _, _, Spanned { span, node: RangeEnd::Included(RangeSyntax::DotDotDot) } - ) = pat.node { + if let Some((start, end, join)) = endpoints { let msg = "`...` range patterns are deprecated"; - let mut err = cx.struct_span_lint(ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, span, msg); - err.span_suggestion_short_with_applicability( - span, "use `..=` for an inclusive range", "..=".to_owned(), - // FIXME: outstanding problem with precedence in ref patterns: - // https://github.com/rust-lang/rust/issues/51043#issuecomment-392252285 - Applicability::MaybeIncorrect - ); - err.emit() + let suggestion = "use `..=` for an inclusive range"; + if parenthesise { + *visit_subpats = false; + let mut err = cx.struct_span_lint(ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, pat.span, msg); + err.span_suggestion_with_applicability( + pat.span, + suggestion, + format!("&({}..={})", expr_to_string(&start), expr_to_string(&end)), + Applicability::MachineApplicable, + ); + err.emit(); + } else { + let mut err = cx.struct_span_lint(ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, join, msg); + err.span_suggestion_short_with_applicability( + join, + suggestion, + "..=".to_owned(), + Applicability::MachineApplicable, + ); + err.emit(); + }; } } } @@ -1934,21 +1626,52 @@ self.check_tokens(cx, mac.node.tts.clone().into()); } fn check_ident(&mut self, cx: &EarlyContext, ident: ast::Ident) { - let next_edition = match cx.sess.edition() { + let ident_str = &ident.as_str()[..]; + let cur_edition = cx.sess.edition(); + let is_raw_ident = |ident: ast::Ident| { + cx.sess.parse_sess.raw_identifier_spans.borrow().contains(&ident.span) + }; + let next_edition = match cur_edition { Edition::Edition2015 => { - match &ident.as_str()[..] { - "async" | - "try" => Edition::Edition2018, + match ident_str { + "async" | "try" | "dyn" => Edition::Edition2018, + // Only issue warnings for `await` if the `async_await` + // feature isn't being used. Otherwise, users need + // to keep using `await` for the macro exposed by std. + "await" if !cx.sess.features_untracked().async_await => Edition::Edition2018, _ => return, } } // no new keywords yet for 2018 edition and beyond - _ => return, + // However, `await` is a "false" keyword in the 2018 edition, + // and can only be used if the `async_await` feature is enabled. + // Otherwise, we emit an error. + _ => { + if "await" == ident_str + && !cx.sess.features_untracked().async_await + && !is_raw_ident(ident) + { + let mut err = struct_span_err!( + cx.sess, + ident.span, + E0721, + "`await` is a keyword in the {} edition", cur_edition, + ); + err.span_suggestion_with_applicability( + ident.span, + "you can use a raw identifier to stay compatible", + "r#await".to_string(), + Applicability::MachineApplicable, + ); + err.emit(); + } + return + }, }; // don't lint `r#foo` - if cx.sess.parse_sess.raw_identifier_spans.borrow().contains(&ident.span) { + if is_raw_ident(ident) { return; } @@ -1968,3 +1691,234 @@ lint.emit() } } + + +pub struct ExplicitOutlivesRequirements; + +impl LintPass for ExplicitOutlivesRequirements { + fn get_lints(&self) -> LintArray { + lint_array![EXPLICIT_OUTLIVES_REQUIREMENTS] + } +} + +impl ExplicitOutlivesRequirements { + fn collect_outlives_bound_spans( + &self, + cx: &LateContext, + item_def_id: DefId, + param_name: &str, + bounds: &hir::GenericBounds, + infer_static: bool + ) -> Vec<(usize, Span)> { + // For lack of a more elegant strategy for comparing the `ty::Predicate`s + // returned by this query with the params/bounds grabbed from the HIR—and + // with some regrets—we're going to covert the param/lifetime names to + // strings + let inferred_outlives = cx.tcx.inferred_outlives_of(item_def_id); + + let ty_lt_names = inferred_outlives.iter().filter_map(|pred| { + let binder = match pred { + ty::Predicate::TypeOutlives(binder) => binder, + _ => { return None; } + }; + let ty_outlives_pred = binder.skip_binder(); + let ty_name = match ty_outlives_pred.0.sty { + ty::Param(param) => param.name.to_string(), + _ => { return None; } + }; + let lt_name = match ty_outlives_pred.1 { + ty::RegionKind::ReEarlyBound(region) => { + region.name.to_string() + }, + _ => { return None; } + }; + Some((ty_name, lt_name)) + }).collect::>(); + + let mut bound_spans = Vec::new(); + for (i, bound) in bounds.iter().enumerate() { + if let hir::GenericBound::Outlives(lifetime) = bound { + let is_static = match lifetime.name { + hir::LifetimeName::Static => true, + _ => false + }; + if is_static && !infer_static { + // infer-outlives for 'static is still feature-gated (tracking issue #44493) + continue; + } + + let lt_name = &lifetime.name.ident().to_string(); + if ty_lt_names.contains(&(param_name.to_owned(), lt_name.to_owned())) { + bound_spans.push((i, bound.span())); + } + } + } + bound_spans + } + + fn consolidate_outlives_bound_spans( + &self, + lo: Span, + bounds: &hir::GenericBounds, + bound_spans: Vec<(usize, Span)> + ) -> Vec { + if bounds.is_empty() { + return Vec::new(); + } + if bound_spans.len() == bounds.len() { + let (_, last_bound_span) = bound_spans[bound_spans.len()-1]; + // If all bounds are inferable, we want to delete the colon, so + // start from just after the parameter (span passed as argument) + vec![lo.to(last_bound_span)] + } else { + let mut merged = Vec::new(); + let mut last_merged_i = None; + + let mut from_start = true; + for (i, bound_span) in bound_spans { + match last_merged_i { + // If the first bound is inferable, our span should also eat the trailing `+` + None if i == 0 => { + merged.push(bound_span.to(bounds[1].span().shrink_to_lo())); + last_merged_i = Some(0); + }, + // If consecutive bounds are inferable, merge their spans + Some(h) if i == h+1 => { + if let Some(tail) = merged.last_mut() { + // Also eat the trailing `+` if the first + // more-than-one bound is inferable + let to_span = if from_start && i < bounds.len() { + bounds[i+1].span().shrink_to_lo() + } else { + bound_span + }; + *tail = tail.to(to_span); + last_merged_i = Some(i); + } else { + bug!("another bound-span visited earlier"); + } + }, + _ => { + // When we find a non-inferable bound, subsequent inferable bounds + // won't be consecutive from the start (and we'll eat the leading + // `+` rather than the trailing one) + from_start = false; + merged.push(bounds[i-1].span().shrink_to_hi().to(bound_span)); + last_merged_i = Some(i); + } + } + } + merged + } + } +} + +impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitOutlivesRequirements { + fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) { + let infer_static = cx.tcx.features().infer_static_outlives_requirements; + let def_id = cx.tcx.hir.local_def_id(item.id); + if let hir::ItemKind::Struct(_, ref generics) = item.node { + let mut bound_count = 0; + let mut lint_spans = Vec::new(); + + for param in &generics.params { + let param_name = match param.kind { + hir::GenericParamKind::Lifetime { .. } => { continue; }, + hir::GenericParamKind::Type { .. } => { + match param.name { + hir::ParamName::Fresh(_) => { continue; }, + hir::ParamName::Error => { continue; }, + hir::ParamName::Plain(name) => name.to_string() + } + } + }; + let bound_spans = self.collect_outlives_bound_spans( + cx, def_id, ¶m_name, ¶m.bounds, infer_static + ); + bound_count += bound_spans.len(); + lint_spans.extend( + self.consolidate_outlives_bound_spans( + param.span.shrink_to_hi(), ¶m.bounds, bound_spans + ) + ); + } + + let mut where_lint_spans = Vec::new(); + let mut dropped_predicate_count = 0; + let num_predicates = generics.where_clause.predicates.len(); + for (i, where_predicate) in generics.where_clause.predicates.iter().enumerate() { + if let hir::WherePredicate::BoundPredicate(predicate) = where_predicate { + let param_name = match predicate.bounded_ty.node { + hir::TyKind::Path(ref qpath) => { + if let hir::QPath::Resolved(None, ty_param_path) = qpath { + ty_param_path.segments[0].ident.to_string() + } else { + continue; + } + }, + _ => { continue; } + }; + let bound_spans = self.collect_outlives_bound_spans( + cx, def_id, ¶m_name, &predicate.bounds, infer_static + ); + bound_count += bound_spans.len(); + + let drop_predicate = bound_spans.len() == predicate.bounds.len(); + if drop_predicate { + dropped_predicate_count += 1; + } + + // If all the bounds on a predicate were inferable and there are + // further predicates, we want to eat the trailing comma + if drop_predicate && i + 1 < num_predicates { + let next_predicate_span = generics.where_clause.predicates[i+1].span(); + where_lint_spans.push( + predicate.span.to(next_predicate_span.shrink_to_lo()) + ); + } else { + where_lint_spans.extend( + self.consolidate_outlives_bound_spans( + predicate.span.shrink_to_lo(), + &predicate.bounds, + bound_spans + ) + ); + } + } + } + + // If all predicates are inferable, drop the entire clause + // (including the `where`) + if num_predicates > 0 && dropped_predicate_count == num_predicates { + let full_where_span = generics.span.shrink_to_hi() + .to(generics.where_clause.span() + .expect("span of (nonempty) where clause should exist")); + lint_spans.push( + full_where_span + ); + } else { + lint_spans.extend(where_lint_spans); + } + + if !lint_spans.is_empty() { + let mut err = cx.struct_span_lint( + EXPLICIT_OUTLIVES_REQUIREMENTS, + lint_spans.clone(), + "outlives requirements can be inferred" + ); + err.multipart_suggestion_with_applicability( + if bound_count == 1 { + "remove this bound" + } else { + "remove these bounds" + }, + lint_spans.into_iter().map(|span| (span, "".to_owned())).collect::>(), + Applicability::MachineApplicable + ); + err.emit(); + } + + } + } + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_lint/diagnostics.rs rustc-1.31.0+dfsg1+llvm/src/librustc_lint/diagnostics.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_lint/diagnostics.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_lint/diagnostics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +register_diagnostics! { + E0721, // `await` keyword +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_lint/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_lint/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_lint/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_lint/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -26,13 +26,12 @@ #![cfg_attr(test, feature(test))] #![feature(box_patterns)] #![feature(box_syntax)] -#![cfg_attr(stage0, feature(macro_vis_matcher))] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(quote)] #![feature(rustc_diagnostic_macros)] #![feature(macro_at_most_once_rep)] +#[macro_use] extern crate syntax; #[macro_use] extern crate rustc; @@ -48,6 +47,7 @@ BARE_TRAIT_OBJECTS, ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE, ELIDED_LIFETIMES_IN_PATHS, + EXPLICIT_OUTLIVES_REQUIREMENTS, parser::QUESTION_MARK_MACRO_SEP }; use rustc::session; @@ -62,6 +62,7 @@ use lint::LintId; use lint::FutureIncompatibleInfo; +mod diagnostics; mod nonstandard_style; pub mod builtin; mod types; @@ -83,30 +84,30 @@ ($sess:ident, $($name:ident),*,) => ( {$( store.register_early_pass($sess, false, box $name); - )*} - ) + )*} + ) } macro_rules! add_pre_expansion_builtin { ($sess:ident, $($name:ident),*,) => ( {$( store.register_pre_expansion_pass($sess, box $name); - )*} - ) + )*} + ) } macro_rules! add_early_builtin_with_new { ($sess:ident, $($name:ident),*,) => ( {$( store.register_early_pass($sess, false, box $name::new()); - )*} - ) + )*} + ) } macro_rules! add_lint_group { ($sess:ident, $name:expr, $($lint:ident),*) => ( store.register_group($sess, false, $name, None, vec![$(LintId::of($lint)),*]); - ) + ) } add_pre_expansion_builtin!(sess, @@ -143,7 +144,6 @@ UnusedAllocation: UnusedAllocation, MissingCopyImplementations: MissingCopyImplementations, UnstableFeatures: UnstableFeatures, - UnconditionalRecursion: UnconditionalRecursion, InvalidNoMangleItems: InvalidNoMangleItems, PluginAsLibrary: PluginAsLibrary, MutableTransmutes: MutableTransmutes, @@ -156,17 +156,12 @@ TypeLimits: TypeLimits::new(), MissingDoc: MissingDoc::new(), MissingDebugImplementations: MissingDebugImplementations::new(), + ExplicitOutlivesRequirements: ExplicitOutlivesRequirements, ]], ['tcx]); store.register_late_pass(sess, false, box BuiltinCombinedLateLintPass::new()); add_lint_group!(sess, - "bad_style", - NON_CAMEL_CASE_TYPES, - NON_SNAKE_CASE, - NON_UPPER_CASE_GLOBALS); - - add_lint_group!(sess, "nonstandard_style", NON_CAMEL_CASE_TYPES, NON_SNAKE_CASE, @@ -198,7 +193,8 @@ BARE_TRAIT_OBJECTS, UNUSED_EXTERN_CRATES, ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, - ELIDED_LIFETIMES_IN_PATHS + ELIDED_LIFETIMES_IN_PATHS, + EXPLICIT_OUTLIVES_REQUIREMENTS // FIXME(#52665, #47816) not always applicable and not all // macros are ready for this yet. @@ -354,6 +350,8 @@ store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate"); store.register_removed("negate_unsigned", "cast a signed value instead"); store.register_removed("raw_pointer_derive", "using derive with raw pointers is ok"); + // Register lint group aliases + store.register_group_alias("nonstandard_style", "bad_style"); // This was renamed to raw_pointer_derive, which was then removed, // so it is also considered removed store.register_removed("raw_pointer_deriving", "using derive with raw pointers is ok"); @@ -384,4 +382,8 @@ "converted into hard error, see https://github.com/rust-lang/rust/issues/48950"); store.register_removed("resolve_trait_on_defaulted_unit", "converted into hard error, see https://github.com/rust-lang/rust/issues/48950"); + store.register_removed("private_no_mangle_fns", + "no longer an warning, #[no_mangle] functions always exported"); + store.register_removed("private_no_mangle_statics", + "no longer an warning, #[no_mangle] statics always exported"); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_lint/nonstandard_style.rs rustc-1.31.0+dfsg1+llvm/src/librustc_lint/nonstandard_style.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_lint/nonstandard_style.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_lint/nonstandard_style.rs 2018-12-04 23:41:40.000000000 +0000 @@ -59,10 +59,10 @@ fn is_camel_case(name: ast::Name) -> bool { let name = name.as_str(); + let name = name.trim_matches('_'); if name.is_empty() { return true; } - let name = name.trim_matches('_'); // start with a non-lowercase letter rather than non-uppercase // ones (some scripts don't have a concept of upper/lowercase) diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_lint/types.rs rustc-1.31.0+dfsg1+llvm/src/librustc_lint/types.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_lint/types.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_lint/types.rs 2018-12-04 23:41:40.000000000 +0000 @@ -24,6 +24,7 @@ use syntax::{ast, attr}; use syntax::errors::Applicability; use rustc_target::spec::abi::Abi; +use syntax::edition::Edition; use syntax_pos::Span; use syntax::source_map; @@ -38,7 +39,8 @@ declare_lint! { OVERFLOWING_LITERALS, Warn, - "literal out of range for its type" + "literal out of range for its type", + Edition::Edition2018 => Deny } declare_lint! { @@ -720,6 +722,7 @@ ty::Closure(..) | ty::Generator(..) | ty::GeneratorWitness(..) | + ty::UnnormalizedProjection(..) | ty::Projection(..) | ty::Opaque(..) | ty::FnDef(..) => bug!("Unexpected type in foreign function"), @@ -731,7 +734,7 @@ // any generic types right now: let ty = self.cx.tcx.normalize_erasing_regions(ParamEnv::reveal_all(), ty); - match self.check_type_for_ffi(&mut FxHashSet(), ty) { + match self.check_type_for_ffi(&mut FxHashSet::default(), ty) { FfiResult::FfiSafe => {} FfiResult::FfiPhantom(ty) => { self.cx.span_lint(IMPROPER_CTYPES, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_lint/unused.rs rustc-1.31.0+dfsg1+llvm/src/librustc_lint/unused.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_lint/unused.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_lint/unused.rs 2018-12-04 23:41:40.000000000 +0000 @@ -29,7 +29,8 @@ declare_lint! { pub UNUSED_MUST_USE, Warn, - "unused result of a type flagged as #[must_use]" + "unused result of a type flagged as #[must_use]", + report_in_external_macro: true } declare_lint! { @@ -59,16 +60,17 @@ } let t = cx.tables.expr_ty(&expr); - let ty_warned = match t.sty { - ty::Tuple(ref tys) if tys.is_empty() => return, - ty::Never => return, + // FIXME(varkor): replace with `t.is_unit() || t.conservative_is_uninhabited()`. + let type_permits_no_use = match t.sty { + ty::Tuple(ref tys) if tys.is_empty() => true, + ty::Never => true, ty::Adt(def, _) => { if def.variants.is_empty() { - return; + true } else { check_must_use(cx, def.did, s.span, "") } - }, + } _ => false, }; @@ -79,10 +81,11 @@ match callee.node { hir::ExprKind::Path(ref qpath) => { let def = cx.tables.qpath_def(qpath, callee.hir_id); - if let Def::Fn(_) = def { - Some(def) - } else { // `Def::Local` if it was a closure, for which we - None // do not currently support must-use linting + match def { + Def::Fn(_) | Def::Method(_) => Some(def), + // `Def::Local` if it was a closure, for which we + // do not currently support must-use linting + _ => None } }, _ => None @@ -96,7 +99,12 @@ if let Some(def) = maybe_def { let def_id = def.def_id(); fn_warned = check_must_use(cx, def_id, s.span, "return value of "); + } else if type_permits_no_use { + // We don't warn about unused unit or uninhabited types. + // (See https://github.com/rust-lang/rust/issues/43806 for details.) + return; } + let must_use_op = match expr.node { // Hardcoding operators here seemed more expedient than the // refactoring that would be needed to look up the `#[must_use]` @@ -136,18 +144,18 @@ if let Some(must_use_op) = must_use_op { cx.span_lint(UNUSED_MUST_USE, expr.span, - &format!("unused {} which must be used", must_use_op)); + &format!("unused {} that must be used", must_use_op)); op_warned = true; } - if !(ty_warned || fn_warned || op_warned) { + if !(type_permits_no_use || fn_warned || op_warned) { cx.span_lint(UNUSED_RESULTS, s.span, "unused result"); } fn check_must_use(cx: &LateContext, def_id: DefId, sp: Span, describe_path: &str) -> bool { for attr in cx.tcx.get_attrs(def_id).iter() { if attr.check_name("must_use") { - let msg = format!("unused {}`{}` which must be used", + let msg = format!("unused {}`{}` that must be used", describe_path, cx.tcx.item_path_str(def_id)); let mut err = cx.struct_span_lint(UNUSED_MUST_USE, sp, &msg); // check for #[must_use = "..."] @@ -234,7 +242,7 @@ .find(|&&(builtin, ty, _)| name == builtin && ty == AttributeType::CrateLevel) .is_some(); - // Has a plugin registered this attribute as one which must be used at + // Has a plugin registered this attribute as one that must be used at // the crate level? let plugin_crate = plugin_attributes.iter() .find(|&&(ref x, t)| name == &**x && AttributeType::CrateLevel == t) @@ -265,55 +273,79 @@ pub struct UnusedParens; impl UnusedParens { - fn check_unused_parens_core(&self, + fn check_unused_parens_expr(&self, cx: &EarlyContext, value: &ast::Expr, msg: &str, - struct_lit_needs_parens: bool) { + followed_by_block: bool) { if let ast::ExprKind::Paren(ref inner) = value.node { - let necessary = struct_lit_needs_parens && - parser::contains_exterior_struct_lit(&inner); + let necessary = followed_by_block && if let ast::ExprKind::Ret(_) = inner.node { + true + } else { + parser::contains_exterior_struct_lit(&inner) + }; if !necessary { - let span_msg = format!("unnecessary parentheses around {}", msg); - let mut err = cx.struct_span_lint(UNUSED_PARENS, - value.span, - &span_msg); - // Remove exactly one pair of parentheses (rather than naïvely - // stripping all paren characters) - let mut ate_left_paren = false; - let mut ate_right_paren = false; - let parens_removed = pprust::expr_to_string(value) - .trim_matches(|c| { - match c { - '(' => { - if ate_left_paren { - false - } else { - ate_left_paren = true; - true - } - }, - ')' => { - if ate_right_paren { - false - } else { - ate_right_paren = true; - true - } - }, - _ => false, - } - }).to_owned(); - err.span_suggestion_short_with_applicability( - value.span, - "remove these parentheses", - parens_removed, - Applicability::MachineApplicable - ); - err.emit(); + let expr_text = if let Ok(snippet) = cx.sess().source_map() + .span_to_snippet(value.span) { + snippet + } else { + pprust::expr_to_string(value) + }; + Self::remove_outer_parens(cx, value.span, &expr_text, msg); } } } + + fn check_unused_parens_pat(&self, + cx: &EarlyContext, + value: &ast::Pat, + msg: &str) { + if let ast::PatKind::Paren(_) = value.node { + let pattern_text = if let Ok(snippet) = cx.sess().source_map() + .span_to_snippet(value.span) { + snippet + } else { + pprust::pat_to_string(value) + }; + Self::remove_outer_parens(cx, value.span, &pattern_text, msg); + } + } + + fn remove_outer_parens(cx: &EarlyContext, span: Span, pattern: &str, msg: &str) { + let span_msg = format!("unnecessary parentheses around {}", msg); + let mut err = cx.struct_span_lint(UNUSED_PARENS, span, &span_msg); + let mut ate_left_paren = false; + let mut ate_right_paren = false; + let parens_removed = pattern + .trim_matches(|c| { + match c { + '(' => { + if ate_left_paren { + false + } else { + ate_left_paren = true; + true + } + }, + ')' => { + if ate_right_paren { + false + } else { + ate_right_paren = true; + true + } + }, + _ => false, + } + }).to_owned(); + err.span_suggestion_short_with_applicability( + span, + "remove these parentheses", + parens_removed, + Applicability::MachineApplicable + ); + err.emit(); + } } impl LintPass for UnusedParens { @@ -325,7 +357,7 @@ impl EarlyLintPass for UnusedParens { fn check_expr(&mut self, cx: &EarlyContext, e: &ast::Expr) { use syntax::ast::ExprKind::*; - let (value, msg, struct_lit_needs_parens) = match e.node { + let (value, msg, followed_by_block) = match e.node { If(ref cond, ..) => (cond, "`if` condition", true), While(ref cond, ..) => (cond, "`while` condition", true), IfLet(_, ref cond, ..) => (cond, "`if let` head expression", true), @@ -337,21 +369,15 @@ AssignOp(.., ref value) => (value, "assigned value", 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..]; - } + let (args_to_check, call_kind) = match *call_or_other { + Call(_, ref args) => (&args[..], "function"), + // first "argument" is self (which sometimes needs parens) + MethodCall(_, ref args) => (&args[1..], "method"), // actual catch-all arm - _ => { return; } - } + _ => { + return; + } + }; // 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 @@ -363,25 +389,34 @@ } let msg = format!("{} argument", call_kind); for arg in args_to_check { - self.check_unused_parens_core(cx, arg, &msg, false); + self.check_unused_parens_expr(cx, arg, &msg, false); } return; } }; - self.check_unused_parens_core(cx, &value, msg, struct_lit_needs_parens); + self.check_unused_parens_expr(cx, &value, msg, followed_by_block); + } + + fn check_pat(&mut self, cx: &EarlyContext, p: &ast::Pat, _: &mut bool) { + use ast::PatKind::{Paren, Range}; + // The lint visitor will visit each subpattern of `p`. We do not want to lint any range + // pattern no matter where it occurs in the pattern. For something like `&(a..=b)`, there + // is a recursive `check_pat` on `a` and `b`, but we will assume that if there are + // unnecessary parens they serve a purpose of readability. + if let Paren(ref pat) = p.node { + match pat.node { + Range(..) => {} + _ => self.check_unused_parens_pat(cx, &p, "pattern") + } + } } fn check_stmt(&mut self, cx: &EarlyContext, s: &ast::Stmt) { - let (value, msg) = match s.node { - ast::StmtKind::Local(ref local) => { - match local.init { - Some(ref value) => (value, "assigned value"), - None => return, - } + if let ast::StmtKind::Local(ref local) = s.node { + if let Some(ref value) = local.init { + self.check_unused_parens_expr(cx, &value, "assigned value", false); } - _ => return, - }; - self.check_unused_parens_core(cx, &value, msg, false); + } } } @@ -414,9 +449,8 @@ let orig_ident = items[0].0.prefix.segments.last().unwrap().ident; if orig_ident.name == keywords::SelfValue.name() { return; - } else { - node_ident = rename.unwrap_or(orig_ident); } + node_ident = rename.unwrap_or(orig_ident); } ast::UseTreeKind::Glob => { node_ident = ast::Ident::from_str("*"); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_llvm/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_llvm/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_llvm/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_llvm/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(static_nobundle)] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_lsan/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_lsan/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_lsan/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_lsan/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,8 +10,7 @@ #![sanitizer_runtime] #![feature(alloc_system)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(sanitizer_runtime)] #![feature(staged_api)] #![no_std] diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_metadata/creader.rs rustc-1.31.0+dfsg1+llvm/src/librustc_metadata/creader.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_metadata/creader.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_metadata/creader.rs 2018-12-04 23:41:40.000000000 +0000 @@ -1133,7 +1133,7 @@ path_len, direct: true, }, - &mut FxHashSet(), + &mut FxHashSet::default(), ); self.cstore.add_extern_mod_stmt_cnum(item.id, cnum); cnum @@ -1160,7 +1160,7 @@ path_len: usize::max_value(), direct: true, }, - &mut FxHashSet(), + &mut FxHashSet::default(), ); cnum @@ -1184,7 +1184,7 @@ path_len: usize::max_value(), direct: true, }, - &mut FxHashSet(), + &mut FxHashSet::default(), ); Some(cnum) diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_metadata/cstore_impl.rs rustc-1.31.0+dfsg1+llvm/src/librustc_metadata/cstore_impl.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_metadata/cstore_impl.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_metadata/cstore_impl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -26,7 +26,6 @@ use rustc::ty::query::Providers; use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE, CRATE_DEF_INDEX}; use rustc::hir::map::{DefKey, DefPath, DefPathHash}; -use rustc::hir::map::blocks::FnLikeNode; use rustc::hir::map::definitions::DefPathTable; use rustc::util::nodemap::DefIdMap; use rustc_data_structures::svh::Svh; @@ -42,8 +41,7 @@ use syntax::parse::source_file_to_stream; use syntax::symbol::Symbol; use syntax_pos::{Span, NO_EXPANSION, FileName}; -use rustc_data_structures::indexed_set::IdxSet; -use rustc::hir; +use rustc_data_structures::bit_set::BitSet; macro_rules! provide { (<$lt:tt> $tcx:ident, $def_id:ident, $other:ident, $cdata:ident, @@ -70,7 +68,7 @@ let $cdata = $tcx.crate_data_as_rc_any($def_id.krate); let $cdata = $cdata.downcast_ref::() - .expect("CrateStore crated ata is not a CrateMetadata"); + .expect("CrateStore created data is not a CrateMetadata"); $compute })* @@ -141,11 +139,11 @@ mir } mir_const_qualif => { - (cdata.mir_const_qualif(def_id.index), Lrc::new(IdxSet::new_empty(0))) + (cdata.mir_const_qualif(def_id.index), Lrc::new(BitSet::new_empty(0))) } fn_sig => { cdata.fn_sig(def_id.index, tcx) } inherent_impls => { Lrc::new(cdata.get_inherent_implementations_for_type(def_id.index)) } - is_const_fn => { cdata.is_const_fn(def_id.index) } + is_const_fn_raw => { cdata.is_const_fn_raw(def_id.index) } is_foreign_item => { cdata.is_foreign_item(def_id.index) } describe_def => { cdata.get_def(def_id.index) } def_span => { cdata.get_span(def_id.index, &tcx.sess) } @@ -264,22 +262,10 @@ } pub fn provide<'tcx>(providers: &mut Providers<'tcx>) { - fn is_const_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool { - let node_id = tcx.hir.as_local_node_id(def_id) - .expect("Non-local call to local provider is_const_fn"); - - if let Some(fn_like) = FnLikeNode::from_node(tcx.hir.get(node_id)) { - fn_like.constness() == hir::Constness::Const - } else { - false - } - } - // FIXME(#44234) - almost all of these queries have no sub-queries and // therefore no actual inputs, they're just reading tables calculated in // resolve! Does this work? Unsure! That's what the issue is about *providers = Providers { - is_const_fn, is_dllimport_foreign_item: |tcx, id| { tcx.native_library_kind(id) == Some(NativeLibraryKind::NativeUnknown) }, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_metadata/cstore.rs rustc-1.31.0+dfsg1+llvm/src/librustc_metadata/cstore.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_metadata/cstore.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_metadata/cstore.rs 2018-12-04 23:41:40.000000000 +0000 @@ -111,7 +111,7 @@ // corresponding `CrateNum`. This first entry will always remain // `None`. metas: RwLock::new(IndexVec::from_elem_n(None, 1)), - extern_mod_crate_map: Lock::new(FxHashMap()), + extern_mod_crate_map: Default::default(), metadata_loader, } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_metadata/decoder.rs rustc-1.31.0+dfsg1+llvm/src/librustc_metadata/decoder.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_metadata/decoder.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_metadata/decoder.rs 2018-12-04 23:41:40.000000000 +0000 @@ -539,6 +539,7 @@ data.unsafety, data.paren_sugar, data.has_auto_impl, + data.is_marker, self.def_path_table.def_path_hash(item_id)) } @@ -556,9 +557,12 @@ _ => bug!(), }; + let def_id = self.local_def_id(data.struct_ctor.unwrap_or(index)); + let attribute_def_id = self.local_def_id(index); + ty::VariantDef::new( tcx, - self.local_def_id(data.struct_ctor.unwrap_or(index)), + def_id, self.item_name(index).as_symbol(), data.discr, item.children.decode(self).map(|index| { @@ -570,7 +574,8 @@ } }).collect(), adt_kind, - data.ctor_kind + data.ctor_kind, + attribute_def_id ) } @@ -1109,7 +1114,7 @@ } } - pub fn is_const_fn(&self, id: DefIndex) -> bool { + crate fn is_const_fn_raw(&self, id: DefIndex) -> bool { let constness = match self.entry(id).kind { EntryKind::Method(data) => data.decode(self).fn_data.constness, EntryKind::Fn(data) => data.decode(self).constness, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_metadata/encoder.rs rustc-1.31.0+dfsg1+llvm/src/librustc_metadata/encoder.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_metadata/encoder.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_metadata/encoder.rs 2018-12-04 23:41:40.000000000 +0000 @@ -1152,6 +1152,7 @@ unsafety: trait_def.unsafety, paren_sugar: trait_def.paren_sugar, has_auto_impl: tcx.trait_is_auto(def_id), + is_marker: trait_def.is_marker, super_predicates: self.lazy(&tcx.super_predicates_of(def_id)), }; @@ -1493,7 +1494,7 @@ let tcx = self.tcx; let mut visitor = ImplVisitor { tcx, - impls: FxHashMap(), + impls: FxHashMap::default(), }; tcx.hir.krate().visit_all_item_likes(&mut visitor); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_metadata/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_metadata/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_metadata/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_metadata/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,8 +15,7 @@ #![feature(box_patterns)] #![feature(libc)] #![feature(macro_at_most_once_rep)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(proc_macro_internals)] #![feature(proc_macro_quote)] #![feature(quote)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_metadata/locator.rs rustc-1.31.0+dfsg1+llvm/src/librustc_metadata/locator.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_metadata/locator.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_metadata/locator.rs 2018-12-04 23:41:40.000000000 +0000 @@ -459,7 +459,7 @@ let mut candidates: FxHashMap< _, (FxHashMap<_, _>, FxHashMap<_, _>, FxHashMap<_, _>), - > = FxHashMap(); + > = Default::default(); let mut staticlibs = vec![]; // First, find all possible candidate rlibs and dylibs purely based on @@ -528,7 +528,7 @@ // A Library candidate is created if the metadata for the set of // libraries corresponds to the crate id and hash criteria that this // search is being performed for. - let mut libraries = FxHashMap(); + let mut libraries = FxHashMap::default(); for (_hash, (rlibs, rmetas, dylibs)) in candidates { let mut slot = None; let rlib = self.extract_one(rlibs, CrateFlavor::Rlib, &mut slot); @@ -622,7 +622,7 @@ } } Err(err) => { - info!("no metadata found: {}", err); + warn!("no metadata found: {}", err); continue; } }; @@ -678,7 +678,7 @@ if let Some((ref prev, _)) = ret { let sysroot = self.sess.sysroot(); let sysroot = sysroot.canonicalize() - .unwrap_or(sysroot.to_path_buf()); + .unwrap_or_else(|_| sysroot.to_path_buf()); if prev.starts_with(&sysroot) { continue } @@ -771,9 +771,9 @@ // rlibs/dylibs. let sess = self.sess; let dylibname = self.dylibname(); - let mut rlibs = FxHashMap(); - let mut rmetas = FxHashMap(); - let mut dylibs = FxHashMap(); + let mut rlibs = FxHashMap::default(); + let mut rmetas = FxHashMap::default(); + let mut dylibs = FxHashMap::default(); { let locs = locs.map(|l| PathBuf::from(l)).filter(|loc| { if !loc.exists() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_metadata/native_libs.rs rustc-1.31.0+dfsg1+llvm/src/librustc_metadata/native_libs.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_metadata/native_libs.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_metadata/native_libs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -183,7 +183,7 @@ // Process libs passed on the command line fn process_command_line(&mut self) { // First, check for errors - let mut renames = FxHashSet(); + let mut renames = FxHashSet::default(); for &(ref name, ref new_name, _) in &self.tcx.sess.opts.libs { if let &Some(ref new_name) = new_name { let any_duplicate = self.libs diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_metadata/schema.rs rustc-1.31.0+dfsg1+llvm/src/librustc_metadata/schema.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_metadata/schema.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_metadata/schema.rs 2018-12-04 23:41:40.000000000 +0000 @@ -472,6 +472,7 @@ pub unsafety: hir::Unsafety, pub paren_sugar: bool, pub has_auto_impl: bool, + pub is_marker: bool, pub super_predicates: Lazy>, } @@ -479,6 +480,7 @@ unsafety, paren_sugar, has_auto_impl, + is_marker, super_predicates }); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/borrow_set.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/borrow_set.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/borrow_set.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/borrow_set.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,12 +12,14 @@ use dataflow::indexes::BorrowIndex; use dataflow::move_paths::MoveData; use rustc::mir::traversal; -use rustc::mir::visit::{PlaceContext, Visitor}; +use rustc::mir::visit::{ + PlaceContext, Visitor, NonUseContext, MutatingUseContext, NonMutatingUseContext +}; use rustc::mir::{self, Location, Mir, Place, Local}; use rustc::ty::{Region, TyCtxt}; use rustc::util::nodemap::{FxHashMap, FxHashSet}; use rustc_data_structures::indexed_vec::IndexVec; -use rustc_data_structures::bitvec::BitArray; +use rustc_data_structures::bit_set::BitSet; use std::fmt; use std::hash::Hash; use std::ops::Index; @@ -87,22 +89,23 @@ fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { let kind = match self.kind { mir::BorrowKind::Shared => "", + mir::BorrowKind::Shallow => "shallow ", mir::BorrowKind::Unique => "uniq ", mir::BorrowKind::Mut { .. } => "mut ", }; let region = self.region.to_string(); - let region = if region.len() > 0 { - format!("{} ", region) + let separator = if !region.is_empty() { + " " } else { - region + "" }; - write!(w, "&{}{}{:?}", region, kind, self.borrowed_place) + write!(w, "&{}{}{}{:?}", region, separator, kind, self.borrowed_place) } } crate enum LocalsStateAtExit { AllAreInvalidated, - SomeAreInvalidated { has_storage_dead_or_moved: BitArray } + SomeAreInvalidated { has_storage_dead_or_moved: BitSet } } impl LocalsStateAtExit { @@ -111,11 +114,11 @@ mir: &Mir<'tcx>, move_data: &MoveData<'tcx> ) -> Self { - struct HasStorageDead(BitArray); + struct HasStorageDead(BitSet); impl<'tcx> Visitor<'tcx> for HasStorageDead { fn visit_local(&mut self, local: &Local, ctx: PlaceContext<'tcx>, _: Location) { - if ctx == PlaceContext::StorageDead { + if ctx == PlaceContext::NonUse(NonUseContext::StorageDead) { self.0.insert(*local); } } @@ -124,7 +127,7 @@ if locals_are_invalidated_at_exit { LocalsStateAtExit::AllAreInvalidated } else { - let mut has_storage_dead = HasStorageDead(BitArray::new(mir.local_decls.len())); + let mut has_storage_dead = HasStorageDead(BitSet::new_empty(mir.local_decls.len())); has_storage_dead.visit_mir(mir); let mut has_storage_dead_or_moved = has_storage_dead.0; for move_out in &move_data.moves { @@ -150,11 +153,11 @@ tcx, mir, idx_vec: IndexVec::new(), - location_map: FxHashMap(), - activation_map: FxHashMap(), - region_map: FxHashMap(), - local_map: FxHashMap(), - pending_activations: FxHashMap(), + location_map: Default::default(), + activation_map: Default::default(), + region_map: Default::default(), + local_map: Default::default(), + pending_activations: Default::default(), locals_state_at_exit: LocalsStateAtExit::build(locals_are_invalidated_at_exit, mir, move_data), }; @@ -243,7 +246,7 @@ K: Clone + Eq + Hash, V: Eq + Hash, { - map.entry(k.clone()).or_insert(FxHashSet()).insert(v); + map.entry(k.clone()).or_default().insert(v); } } @@ -260,56 +263,54 @@ // ... check whether we (earlier) saw a 2-phase borrow like // // TMP = &mut place - match self.pending_activations.get(temp) { - Some(&borrow_index) => { - let borrow_data = &mut self.idx_vec[borrow_index]; - - // Watch out: the use of TMP in the borrow itself - // doesn't count as an activation. =) - if borrow_data.reserve_location == location && context == PlaceContext::Store { - return; - } + if let Some(&borrow_index) = self.pending_activations.get(temp) { + let borrow_data = &mut self.idx_vec[borrow_index]; - if let TwoPhaseActivation::ActivatedAt(other_location) = - borrow_data.activation_location { - span_bug!( - self.mir.source_info(location).span, - "found two uses for 2-phase borrow temporary {:?}: \ - {:?} and {:?}", - temp, - location, - other_location, - ); - } + // Watch out: the use of TMP in the borrow itself + // doesn't count as an activation. =) + if borrow_data.reserve_location == location && + context == PlaceContext::MutatingUse(MutatingUseContext::Store) + { + return; + } - // Otherwise, this is the unique later use - // that we expect. - borrow_data.activation_location = match context { - // The use of TMP in a shared borrow does not - // count as an actual activation. - PlaceContext::Borrow { kind: mir::BorrowKind::Shared, .. } => { - TwoPhaseActivation::NotActivated - } - _ => { - // Double check: This borrow is indeed a two-phase borrow (that is, - // we are 'transitioning' from `NotActivated` to `ActivatedAt`) and - // we've not found any other activations (checked above). - assert_eq!( - borrow_data.activation_location, - TwoPhaseActivation::NotActivated, - "never found an activation for this borrow!", - ); - - self.activation_map - .entry(location) - .or_default() - .push(borrow_index); - TwoPhaseActivation::ActivatedAt(location) - } - }; + if let TwoPhaseActivation::ActivatedAt(other_location) = + borrow_data.activation_location { + span_bug!( + self.mir.source_info(location).span, + "found two uses for 2-phase borrow temporary {:?}: \ + {:?} and {:?}", + temp, + location, + other_location, + ); } - None => {} + // Otherwise, this is the unique later use + // that we expect. + borrow_data.activation_location = match context { + // The use of TMP in a shared borrow does not + // count as an actual activation. + PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow(..)) | + PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow(..)) => + TwoPhaseActivation::NotActivated, + _ => { + // Double check: This borrow is indeed a two-phase borrow (that is, + // we are 'transitioning' from `NotActivated` to `ActivatedAt`) and + // we've not found any other activations (checked above). + assert_eq!( + borrow_data.activation_location, + TwoPhaseActivation::NotActivated, + "never found an activation for this borrow!", + ); + + self.activation_map + .entry(location) + .or_default() + .push(borrow_index); + TwoPhaseActivation::ActivatedAt(location) + } + }; } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/error_reporting.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/error_reporting.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/error_reporting.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/error_reporting.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,14 +8,23 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use borrow_check::nll::explain_borrow::BorrowExplanation; +use borrow_check::nll::region_infer::{RegionName, RegionNameSource}; +use borrow_check::prefixes::IsPrefixOf; use borrow_check::WriteKind; +use rustc::hir; +use rustc::hir::def_id::DefId; use rustc::middle::region::ScopeTree; -use rustc::mir::VarBindingForm; -use rustc::mir::{BindingForm, BorrowKind, ClearCrossCrate, Field, Local}; -use rustc::mir::{LocalDecl, LocalKind, Location, Operand, Place}; -use rustc::mir::{ProjectionElem, Rvalue, Statement, StatementKind}; -use rustc::ty; +use rustc::mir::{ + self, AggregateKind, BindingForm, BorrowKind, ClearCrossCrate, Constant, + ConstraintCategory, Field, Local, LocalDecl, LocalKind, Location, Operand, + Place, PlaceProjection, ProjectionElem, Rvalue, Statement, StatementKind, + TerminatorKind, VarBindingForm, +}; +use rustc::ty::{self, DefIdTree}; +use rustc::util::ppaux::with_highlight_region_for_bound_region; use rustc_data_structures::fx::FxHashSet; +use rustc_data_structures::indexed_vec::Idx; use rustc_data_structures::sync::Lrc; use rustc_errors::{Applicability, DiagnosticBuilder}; use syntax_pos::Span; @@ -23,33 +32,54 @@ use super::borrow_set::BorrowData; use super::{Context, MirBorrowckCtxt}; use super::{InitializationRequiringAction, PrefixSet}; - -use borrow_check::nll::explain_borrow::BorrowContainsPointReason; use dataflow::drop_flag_effects; use dataflow::move_paths::indexes::MoveOutIndex; use dataflow::move_paths::MovePathIndex; use util::borrowck_errors::{BorrowckErrors, Origin}; +#[derive(Debug)] +struct MoveSite { + /// Index of the "move out" that we found. The `MoveData` can + /// then tell us where the move occurred. + moi: MoveOutIndex, + + /// True if we traversed a back edge while walking from the point + /// of error to the move site. + traversed_back_edge: bool +} + impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { pub(super) fn report_use_of_moved_or_uninitialized( &mut self, context: Context, desired_action: InitializationRequiringAction, - (place, span): (&Place<'tcx>, Span), + (moved_place, used_place, span): (&Place<'tcx>, &Place<'tcx>, Span), mpi: MovePathIndex, ) { - let use_spans = self - .move_spans(place, context.loc) + debug!( + "report_use_of_moved_or_uninitialized: context={:?} desired_action={:?} \ + moved_place={:?} used_place={:?} span={:?} mpi={:?}", + context, desired_action, moved_place, used_place, span, mpi + ); + + let use_spans = self.move_spans(moved_place, context.loc) .or_else(|| self.borrow_spans(span, context.loc)); let span = use_spans.args_or_use(); - let mois = self.get_moved_indexes(context, mpi); - debug!("report_use_of_moved_or_uninitialized: mois={:?}", mois); + let move_site_vec = self.get_moved_indexes(context, mpi); + debug!( + "report_use_of_moved_or_uninitialized: move_site_vec={:?}", + move_site_vec + ); + let move_out_indices: Vec<_> = move_site_vec + .iter() + .map(|move_site| move_site.moi) + .collect(); - if mois.is_empty() { - let root_place = self.prefixes(&place, PrefixSet::All).last().unwrap(); + if move_out_indices.is_empty() { + let root_place = self.prefixes(&used_place, PrefixSet::All).last().unwrap(); - if self.moved_error_reported.contains(&root_place.clone()) { + if self.uninitialized_error_reported.contains(root_place) { debug!( "report_use_of_moved_or_uninitialized place: error about {:?} suppressed", root_place @@ -57,42 +87,61 @@ return; } - self.moved_error_reported.insert(root_place.clone()); + self.uninitialized_error_reported.insert(root_place.clone()); - let item_msg = match self.describe_place_with_options(place, IncludingDowncast(true)) { + let item_msg = match self.describe_place_with_options(used_place, + IncludingDowncast(true)) { Some(name) => format!("`{}`", name), None => "value".to_owned(), }; - let mut err = self.tcx.cannot_act_on_uninitialized_variable( + let mut err = self.infcx.tcx.cannot_act_on_uninitialized_variable( span, desired_action.as_noun(), - &self - .describe_place_with_options(place, IncludingDowncast(true)) - .unwrap_or("_".to_owned()), + &self.describe_place_with_options(moved_place, IncludingDowncast(true)) + .unwrap_or_else(|| "_".to_owned()), Origin::Mir, ); err.span_label(span, format!("use of possibly uninitialized {}", item_msg)); use_spans.var_span_label( &mut err, - format!("{} occurs due to use in closure", desired_action.as_noun()), + format!("{} occurs due to use{}", desired_action.as_noun(), use_spans.describe()), ); err.buffer(&mut self.errors_buffer); } else { + if let Some((reported_place, _)) = self.move_error_reported.get(&move_out_indices) { + if self.prefixes(&reported_place, PrefixSet::All) + .any(|p| p == used_place) + { + debug!( + "report_use_of_moved_or_uninitialized place: error suppressed \ + mois={:?}", + move_out_indices + ); + return; + } + } + let msg = ""; //FIXME: add "partially " or "collaterally " - let mut err = self.tcx.cannot_act_on_moved_value( + let mut err = self.infcx.tcx.cannot_act_on_moved_value( span, desired_action.as_noun(), msg, - self.describe_place_with_options(&place, IncludingDowncast(true)), + self.describe_place_with_options(&moved_place, IncludingDowncast(true)), Origin::Mir, ); + self.add_closure_invoked_twice_with_moved_variable_suggestion( + context.loc, + used_place, + &mut err, + ); + let mut is_loop_move = false; - for moi in &mois { - let move_out = self.move_data.moves[*moi]; + for move_site in &move_site_vec { + let move_out = self.move_data.moves[(*move_site).moi]; let moved_place = &self.move_data.move_paths[move_out.path].place; let move_spans = self.move_spans(moved_place, move_out.source); @@ -107,18 +156,29 @@ if span == move_span { err.span_label( span, - format!("value moved{} here in previous iteration of loop", move_msg), + format!("value moved{} here, in previous iteration of loop", move_msg), ); is_loop_move = true; + } else if move_site.traversed_back_edge { + err.span_label( + move_span, + format!( + "value moved{} here, in previous iteration of loop", + move_msg + ), + ); } else { err.span_label(move_span, format!("value moved{} here", move_msg)); - move_spans.var_span_label(&mut err, "variable moved due to use in closure"); + move_spans.var_span_label( + &mut err, + format!("variable moved due to use{}", move_spans.describe()), + ); }; } use_spans.var_span_label( &mut err, - format!("{} occurs due to use in closure", desired_action.as_noun()), + format!("{} occurs due to use{}", desired_action.as_noun(), use_spans.describe()), ); if !is_loop_move { @@ -131,29 +191,27 @@ ); } - if let Some(ty) = self.retrieve_type_for_place(place) { + if let Some(ty) = self.retrieve_type_for_place(used_place) { let needs_note = match ty.sty { ty::Closure(id, _) => { - let tables = self.tcx.typeck_tables_of(id); - let node_id = self.tcx.hir.as_local_node_id(id).unwrap(); - let hir_id = self.tcx.hir.node_to_hir_id(node_id); - if tables.closure_kind_origins().get(hir_id).is_some() { - false - } else { - true - } + let tables = self.infcx.tcx.typeck_tables_of(id); + let node_id = self.infcx.tcx.hir.as_local_node_id(id).unwrap(); + let hir_id = self.infcx.tcx.hir.node_to_hir_id(node_id); + + tables.closure_kind_origins().get(hir_id).is_none() } _ => true, }; if needs_note { - let mpi = self.move_data.moves[mois[0]].path; + let mpi = self.move_data.moves[move_out_indices[0]].path; let place = &self.move_data.move_paths[mpi].place; if let Some(ty) = self.retrieve_type_for_place(place) { - let note_msg = match self - .describe_place_with_options(place, IncludingDowncast(true)) - { + let note_msg = match self.describe_place_with_options( + place, + IncludingDowncast(true), + ) { Some(name) => format!("`{}`", name), None => "value".to_owned(), }; @@ -167,17 +225,26 @@ } } - err.buffer(&mut self.errors_buffer); + if let Some((_, mut old_err)) = self.move_error_reported + .insert(move_out_indices, (used_place.clone(), err)) + { + // Cancel the old error so it doesn't ICE. + old_err.cancel(); + } } } pub(super) fn report_move_out_while_borrowed( &mut self, context: Context, - (place, _span): (&Place<'tcx>, Span), + (place, span): (&Place<'tcx>, Span), borrow: &BorrowData<'tcx>, ) { - let tcx = self.tcx; + debug!( + "report_move_out_while_borrowed: context={:?} place={:?} span={:?} borrow={:?}", + context, place, span, borrow + ); + let tcx = self.infcx.tcx; let value_msg = match self.describe_place(place) { Some(name) => format!("`{}`", name), None => "value".to_owned(), @@ -195,17 +262,24 @@ let mut err = tcx.cannot_move_when_borrowed( span, - &self.describe_place(place).unwrap_or("_".to_owned()), + &self.describe_place(place).unwrap_or_else(|| "_".to_owned()), Origin::Mir, ); err.span_label(borrow_span, format!("borrow of {} occurs here", borrow_msg)); err.span_label(span, format!("move out of {} occurs here", value_msg)); - borrow_spans.var_span_label(&mut err, "borrow occurs due to use in closure"); + borrow_spans.var_span_label( + &mut err, + format!("borrow occurs due to use{}", borrow_spans.describe()) + ); - move_spans.var_span_label(&mut err, "move occurs due to use in closure"); + move_spans.var_span_label( + &mut err, + format!("move occurs due to use{}", move_spans.describe()) + ); - self.explain_why_borrow_contains_point(context, borrow, None, &mut err); + self.explain_why_borrow_contains_point(context, borrow, None) + .add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, ""); err.buffer(&mut self.errors_buffer); } @@ -215,7 +289,7 @@ (place, _span): (&Place<'tcx>, Span), borrow: &BorrowData<'tcx>, ) { - let tcx = self.tcx; + let tcx = self.infcx.tcx; let borrow_spans = self.retrieve_borrow_spans(borrow); let borrow_span = borrow_spans.args_or_use(); @@ -227,22 +301,22 @@ let mut err = tcx.cannot_use_when_mutably_borrowed( span, - &self.describe_place(place).unwrap_or("_".to_owned()), + &self.describe_place(place).unwrap_or_else(|| "_".to_owned()), borrow_span, - &self - .describe_place(&borrow.borrowed_place) - .unwrap_or("_".to_owned()), + &self.describe_place(&borrow.borrowed_place) + .unwrap_or_else(|| "_".to_owned()), Origin::Mir, ); borrow_spans.var_span_label(&mut err, { let place = &borrow.borrowed_place; - let desc_place = self.describe_place(place).unwrap_or("_".to_owned()); + let desc_place = self.describe_place(place).unwrap_or_else(|| "_".to_owned()); - format!("borrow occurs due to use of `{}` in closure", desc_place) + format!("borrow occurs due to use of `{}`{}", desc_place, borrow_spans.describe()) }); - self.explain_why_borrow_contains_point(context, borrow, None, &mut err); + self.explain_why_borrow_contains_point(context, borrow, None) + .add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, ""); err.buffer(&mut self.errors_buffer); } @@ -259,8 +333,16 @@ let borrow_spans = self.borrow_spans(span, context.loc); let span = borrow_spans.args_or_use(); - let desc_place = self.describe_place(place).unwrap_or("_".to_owned()); - let tcx = self.tcx; + let container_name = if issued_spans.for_generator() || borrow_spans.for_generator() { + "generator" + } else { + "closure" + }; + + let desc_place = self.describe_place(place).unwrap_or_else(|| "_".to_owned()); + let tcx = self.infcx.tcx; + + let first_borrow_desc; // FIXME: supply non-"" `opt_via` when appropriate let mut err = match ( @@ -271,9 +353,9 @@ "immutable", "mutable", ) { - (BorrowKind::Shared, lft, _, BorrowKind::Mut { .. }, _, rgt) - | (BorrowKind::Mut { .. }, _, lft, BorrowKind::Shared, rgt, _) => tcx - .cannot_reborrow_already_borrowed( + (BorrowKind::Shared, lft, _, BorrowKind::Mut { .. }, _, rgt) => { + first_borrow_desc = "mutable "; + tcx.cannot_reborrow_already_borrowed( span, &desc_place, "", @@ -284,10 +366,27 @@ "", None, Origin::Mir, - ), + ) + } + (BorrowKind::Mut { .. }, _, lft, BorrowKind::Shared, rgt, _) => { + first_borrow_desc = "immutable "; + tcx.cannot_reborrow_already_borrowed( + span, + &desc_place, + "", + lft, + issued_span, + "it", + rgt, + "", + None, + Origin::Mir, + ) + } - (BorrowKind::Mut { .. }, _, _, BorrowKind::Mut { .. }, _, _) => tcx - .cannot_mutably_borrow_multiply( + (BorrowKind::Mut { .. }, _, _, BorrowKind::Mut { .. }, _, _) => { + first_borrow_desc = "first "; + tcx.cannot_mutably_borrow_multiply( span, &desc_place, "", @@ -295,31 +394,60 @@ "", None, Origin::Mir, - ), + ) + } - (BorrowKind::Unique, _, _, BorrowKind::Unique, _, _) => tcx - .cannot_uniquely_borrow_by_two_closures( + (BorrowKind::Unique, _, _, BorrowKind::Unique, _, _) => { + first_borrow_desc = "first "; + tcx.cannot_uniquely_borrow_by_two_closures( span, &desc_place, issued_span, None, Origin::Mir, - ), + ) + } - (BorrowKind::Unique, _, _, _, _, _) => tcx.cannot_uniquely_borrow_by_one_closure( - span, - &desc_place, - "", - issued_span, - "it", - "", - None, - Origin::Mir, - ), + (BorrowKind::Mut { .. }, _, _, BorrowKind::Shallow, _, _) + | (BorrowKind::Unique, _, _, BorrowKind::Shallow, _, _) => { + let mut err = tcx.cannot_mutate_in_match_guard( + span, + issued_span, + &desc_place, + "mutably borrow", + Origin::Mir, + ); + borrow_spans.var_span_label( + &mut err, + format!( + "borrow occurs due to use of `{}`{}", desc_place, borrow_spans.describe() + ), + ); + err.buffer(&mut self.errors_buffer); + + return; + } + + (BorrowKind::Unique, _, _, _, _, _) => { + first_borrow_desc = "first "; + tcx.cannot_uniquely_borrow_by_one_closure( + span, + container_name, + &desc_place, + "", + issued_span, + "it", + "", + None, + Origin::Mir, + ) + }, - (BorrowKind::Shared, lft, _, BorrowKind::Unique, _, _) => tcx - .cannot_reborrow_already_uniquely_borrowed( + (BorrowKind::Shared, lft, _, BorrowKind::Unique, _, _) => { + first_borrow_desc = "first "; + tcx.cannot_reborrow_already_uniquely_borrowed( span, + container_name, &desc_place, "", lft, @@ -327,11 +455,14 @@ "", None, Origin::Mir, - ), + ) + } - (BorrowKind::Mut { .. }, _, lft, BorrowKind::Unique, _, _) => tcx - .cannot_reborrow_already_uniquely_borrowed( + (BorrowKind::Mut { .. }, _, lft, BorrowKind::Unique, _, _) => { + first_borrow_desc = "first "; + tcx.cannot_reborrow_already_uniquely_borrowed( span, + container_name, &desc_place, "", lft, @@ -339,41 +470,63 @@ "", None, Origin::Mir, - ), + ) + } - (BorrowKind::Shared, _, _, BorrowKind::Shared, _, _) => unreachable!(), + (BorrowKind::Shallow, _, _, BorrowKind::Unique, _, _) + | (BorrowKind::Shallow, _, _, BorrowKind::Mut { .. }, _, _) => { + // Shallow borrows are uses from the user's point of view. + self.report_use_while_mutably_borrowed(context, (place, span), issued_borrow); + return; + } + (BorrowKind::Shared, _, _, BorrowKind::Shared, _, _) + | (BorrowKind::Shared, _, _, BorrowKind::Shallow, _, _) + | (BorrowKind::Shallow, _, _, BorrowKind::Shared, _, _) + | (BorrowKind::Shallow, _, _, BorrowKind::Shallow, _, _) => unreachable!(), }; if issued_spans == borrow_spans { borrow_spans.var_span_label( &mut err, - format!("borrows occur due to use of `{}` in closure", desc_place), + format!("borrows occur due to use of `{}`{}", desc_place, borrow_spans.describe()), ); } else { let borrow_place = &issued_borrow.borrowed_place; - let borrow_place_desc = self.describe_place(borrow_place).unwrap_or("_".to_owned()); + let borrow_place_desc = self.describe_place(borrow_place) + .unwrap_or_else(|| "_".to_owned()); issued_spans.var_span_label( &mut err, format!( - "first borrow occurs due to use of `{}` in closure", - borrow_place_desc + "first borrow occurs due to use of `{}`{}", + borrow_place_desc, + issued_spans.describe(), ), ); borrow_spans.var_span_label( &mut err, format!( - "second borrow occurs due to use of `{}` in closure", - desc_place + "second borrow occurs due to use of `{}`{}", + desc_place, + borrow_spans.describe(), ), ); } - self.explain_why_borrow_contains_point(context, issued_borrow, None, &mut err); + self.explain_why_borrow_contains_point(context, issued_borrow, None) + .add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, first_borrow_desc); err.buffer(&mut self.errors_buffer); } + /// Reports StorageDeadOrDrop of `place` conflicts with `borrow`. + /// + /// This means that some data referenced by `borrow` needs to live + /// past the point where the StorageDeadOrDrop of `place` occurs. + /// This is usually interpreted as meaning that `place` has too + /// short a lifetime. (But sometimes it is more useful to report + /// it as a more direct conflict between the execution of a + /// `Drop::drop` with an aliasing borrow.) pub(super) fn report_borrowed_value_does_not_live_long_enough( &mut self, context: Context, @@ -381,10 +534,16 @@ place_span: (&Place<'tcx>, Span), kind: Option, ) { + debug!( + "report_borrowed_value_does_not_live_long_enough(\ + {:?}, {:?}, {:?}, {:?}\ + )", + context, borrow, place_span, kind + ); + let drop_span = place_span.1; - let scope_tree = self.tcx.region_scope_tree(self.mir_def_id); - let root_place = self - .prefixes(&borrow.borrowed_place, PrefixSet::All) + let scope_tree = self.infcx.tcx.region_scope_tree(self.mir_def_id); + let root_place = self.prefixes(&borrow.borrowed_place, PrefixSet::All) .last() .unwrap(); @@ -396,8 +555,7 @@ _ => drop_span, }; - if self - .access_place_error_reported + if self.access_place_error_reported .contains(&(root_place.clone(), borrow_span)) { debug!( @@ -410,71 +568,261 @@ self.access_place_error_reported .insert((root_place.clone(), borrow_span)); - let borrow_reason = self.find_why_borrow_contains_point(context, borrow); + if let StorageDeadOrDrop::Destructor(dropped_ty) = + self.classify_drop_access_kind(&borrow.borrowed_place) + { + // If a borrow of path `B` conflicts with drop of `D` (and + // we're not in the uninteresting case where `B` is a + // prefix of `D`), then report this as a more interesting + // destructor conflict. + if !borrow.borrowed_place.is_prefix_of(place_span.0) { + self.report_borrow_conflicts_with_destructor( + context, borrow, place_span, kind, dropped_ty, + ); + return; + } + } + + let place_desc = self.describe_place(&borrow.borrowed_place); + + let kind_place = kind.filter(|_| place_desc.is_some()).map(|k| (k, place_span.0)); + let explanation = self.explain_why_borrow_contains_point(context, &borrow, kind_place); - let mut err = match &self.describe_place(&borrow.borrowed_place) { - Some(_) if self.is_place_thread_local(root_place) => { + let err = match (place_desc, explanation) { + (Some(_), _) if self.is_place_thread_local(root_place) => { self.report_thread_local_value_does_not_live_long_enough(drop_span, borrow_span) } - Some(name) => self.report_local_value_does_not_live_long_enough( + // If the outlives constraint comes from inside the closure, + // for example: + // + // let x = 0; + // let y = &x; + // Box::new(|| y) as Box &'static i32> + // + // then just use the normal error. The closure isn't escaping + // and `move` will not help here. + ( + Some(ref name), + BorrowExplanation::MustBeValidFor { + category: category @ ConstraintCategory::Return, + from_closure: false, + ref region_name, + span, + .. + }, + ) + | ( + Some(ref name), + BorrowExplanation::MustBeValidFor { + category: category @ ConstraintCategory::CallArgument, + from_closure: false, + ref region_name, + span, + .. + }, + ) if borrow_spans.for_closure() => self.report_escaping_closure_capture( + borrow_spans.args_or_use(), + borrow_span, + region_name, + category, + span, + &format!("`{}`", name), + ), + ( + ref name, + BorrowExplanation::MustBeValidFor { + category: ConstraintCategory::Assignment, + from_closure: false, + region_name: RegionName { + source: RegionNameSource::AnonRegionFromUpvar(upvar_span, ref upvar_name), + .. + }, + span, + .. + }, + ) => self.report_escaping_data(borrow_span, name, upvar_span, upvar_name, span), + (Some(name), explanation) => self.report_local_value_does_not_live_long_enough( context, - name, + &name, &scope_tree, &borrow, - borrow_reason, drop_span, - borrow_span, - kind.map(|k| (k, place_span.0)), + borrow_spans, + explanation, ), - None => self.report_temporary_value_does_not_live_long_enough( + (None, explanation) => self.report_temporary_value_does_not_live_long_enough( context, &scope_tree, &borrow, - borrow_reason, drop_span, + borrow_spans, proper_span, + explanation, ), }; - borrow_spans.args_span_label(&mut err, "value captured here"); - err.buffer(&mut self.errors_buffer); } fn report_local_value_does_not_live_long_enough( &mut self, context: Context, - name: &String, + name: &str, scope_tree: &Lrc, borrow: &BorrowData<'tcx>, - reason: BorrowContainsPointReason<'tcx>, drop_span: Span, - borrow_span: Span, - kind_place: Option<(WriteKind, &Place<'tcx>)>, + borrow_spans: UseSpans, + explanation: BorrowExplanation, ) -> DiagnosticBuilder<'cx> { debug!( "report_local_value_does_not_live_long_enough(\ - {:?}, {:?}, {:?}, {:?}, {:?}, {:?}, {:?}\ + {:?}, {:?}, {:?}, {:?}, {:?}, {:?}\ )", - context, name, scope_tree, borrow, reason, drop_span, borrow_span + context, name, scope_tree, borrow, drop_span, borrow_spans ); - let mut err = self.tcx.path_does_not_live_long_enough( + let borrow_span = borrow_spans.var_or_use(); + if let BorrowExplanation::MustBeValidFor { + category: ConstraintCategory::Return, + span, + ref opt_place_desc, + from_closure: false, + .. + } = explanation { + return self.report_cannot_return_reference_to_local( + borrow, + borrow_span, + span, + opt_place_desc.as_ref(), + ); + } + + let mut err = self.infcx.tcx.path_does_not_live_long_enough( borrow_span, &format!("`{}`", name), Origin::Mir, ); - err.span_label(borrow_span, "borrowed value does not live long enough"); - err.span_label( - drop_span, - format!("`{}` dropped here while still borrowed", name), - ); + if let Some(annotation) = self.annotate_argument_and_return_for_borrow(borrow) { + let region_name = annotation.emit(&mut err); + + err.span_label( + borrow_span, + format!("`{}` would have to be valid for `{}`...", name, region_name), + ); + + if let Some(fn_node_id) = self.infcx.tcx.hir.as_local_node_id(self.mir_def_id) { + err.span_label( + drop_span, + format!( + "...but `{}` will be dropped here, when the function `{}` returns", + name, + self.infcx.tcx.hir.name(fn_node_id), + ), + ); + + err.note( + "functions cannot return a borrow to data owned within the function's scope, \ + functions can only return borrows to data passed as arguments", + ); + err.note( + "to learn more, visit ", + ); + } else { + err.span_label( + drop_span, + format!("...but `{}` dropped here while still borrowed", name), + ); + } + + if let BorrowExplanation::MustBeValidFor { .. } = explanation { + } else { + explanation.add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, ""); + } + } else { + err.span_label(borrow_span, "borrowed value does not live long enough"); + err.span_label( + drop_span, + format!("`{}` dropped here while still borrowed", name), + ); + + let within = if borrow_spans.for_generator() { + " by generator" + } else { + "" + }; + + borrow_spans.args_span_label( + &mut err, + format!("value captured here{}", within), + ); + + explanation.add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, ""); + } - self.report_why_borrow_contains_point(&mut err, reason, kind_place); err } + fn report_borrow_conflicts_with_destructor( + &mut self, + context: Context, + borrow: &BorrowData<'tcx>, + (place, drop_span): (&Place<'tcx>, Span), + kind: Option, + dropped_ty: ty::Ty<'tcx>, + ) { + debug!( + "report_borrow_conflicts_with_destructor(\ + {:?}, {:?}, ({:?}, {:?}), {:?}\ + )", + context, borrow, place, drop_span, kind, + ); + + let borrow_spans = self.retrieve_borrow_spans(borrow); + let borrow_span = borrow_spans.var_or_use(); + + let mut err = self.infcx + .tcx + .cannot_borrow_across_destructor(borrow_span, Origin::Mir); + + let what_was_dropped = match self.describe_place(place) { + Some(name) => format!("`{}`", name.as_str()), + None => format!("temporary value"), + }; + + let label = match self.describe_place(&borrow.borrowed_place) { + Some(borrowed) => format!( + "here, drop of {D} needs exclusive access to `{B}`, \ + because the type `{T}` implements the `Drop` trait", + D = what_was_dropped, + T = dropped_ty, + B = borrowed + ), + None => format!( + "here is drop of {D}; whose type `{T}` implements the `Drop` trait", + D = what_was_dropped, + T = dropped_ty + ), + }; + err.span_label(drop_span, label); + + // Only give this note and suggestion if they could be relevant. + let explanation = + self.explain_why_borrow_contains_point(context, borrow, kind.map(|k| (k, place))); + match explanation { + BorrowExplanation::UsedLater { .. } + | BorrowExplanation::UsedLaterWhenDropped { .. } => { + err.note("consider using a `let` binding to create a longer lived value"); + } + _ => {} + } + + explanation.add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, ""); + + err.buffer(&mut self.errors_buffer); + } + fn report_thread_local_value_does_not_live_long_enough( &mut self, drop_span: Span, @@ -487,7 +835,7 @@ drop_span, borrow_span ); - let mut err = self + let mut err = self.infcx .tcx .thread_local_value_does_not_live_long_enough(borrow_span, Origin::Mir); @@ -496,6 +844,7 @@ "thread-local variables cannot be borrowed beyond the end of the function", ); err.span_label(drop_span, "end of enclosing function is here"); + err } @@ -504,59 +853,277 @@ context: Context, scope_tree: &Lrc, borrow: &BorrowData<'tcx>, - reason: BorrowContainsPointReason<'tcx>, drop_span: Span, + borrow_spans: UseSpans, proper_span: Span, + explanation: BorrowExplanation, ) -> DiagnosticBuilder<'cx> { debug!( "report_temporary_value_does_not_live_long_enough(\ - {:?}, {:?}, {:?}, {:?}, {:?}, {:?}\ + {:?}, {:?}, {:?}, {:?}, {:?}\ )", - context, scope_tree, borrow, reason, drop_span, proper_span + context, scope_tree, borrow, drop_span, proper_span ); - let tcx = self.tcx; - let mut err = - tcx.path_does_not_live_long_enough(proper_span, "borrowed value", Origin::Mir); - err.span_label(proper_span, "temporary value does not live long enough"); - err.span_label(drop_span, "temporary value only lives until here"); - - // Only give this note and suggestion if they could be relevant - match reason { - BorrowContainsPointReason::Liveness {..} - | BorrowContainsPointReason::DropLiveness {..} => { + if let BorrowExplanation::MustBeValidFor { + category: ConstraintCategory::Return, + span, + from_closure: false, + .. + } = explanation { + return self.report_cannot_return_reference_to_local( + borrow, + proper_span, + span, + None, + ); + } + + let tcx = self.infcx.tcx; + let mut err = tcx.temporary_value_borrowed_for_too_long(proper_span, Origin::Mir); + err.span_label( + proper_span, + "creates a temporary which is freed while still in use", + ); + err.span_label( + drop_span, + "temporary value is freed at the end of this statement", + ); + + match explanation { + BorrowExplanation::UsedLater(..) + | BorrowExplanation::UsedLaterInLoop(..) + | BorrowExplanation::UsedLaterWhenDropped { .. } => { + // Only give this note and suggestion if it could be relevant. err.note("consider using a `let` binding to create a longer lived value"); } - BorrowContainsPointReason::OutlivesFreeRegion {..} => (), + _ => {} } + explanation.add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, ""); + + let within = if borrow_spans.for_generator() { + " by generator" + } else { + "" + }; + + borrow_spans.args_span_label( + &mut err, + format!("value captured here{}", within), + ); - self.report_why_borrow_contains_point(&mut err, reason, None); err } - fn get_moved_indexes(&mut self, context: Context, mpi: MovePathIndex) -> Vec { + fn report_cannot_return_reference_to_local( + &self, + borrow: &BorrowData<'tcx>, + borrow_span: Span, + return_span: Span, + opt_place_desc: Option<&String>, + ) -> DiagnosticBuilder<'cx> { + let tcx = self.infcx.tcx; + + // FIXME use a better heuristic than Spans + let reference_desc = if return_span == self.mir.source_info(borrow.reserve_location).span { + "reference to" + } else { + "value referencing" + }; + + let (place_desc, note) = if let Some(place_desc) = opt_place_desc { + let local_kind = match borrow.borrowed_place { + Place::Local(local) => { + match self.mir.local_kind(local) { + LocalKind::ReturnPointer + | LocalKind::Temp => bug!("temporary or return pointer with a name"), + LocalKind::Var => "local variable ", + LocalKind::Arg + if !self.mir.upvar_decls.is_empty() + && local == Local::new(1) => { + "variable captured by `move` " + } + LocalKind::Arg => { + "function parameter " + } + } + } + _ => "local data ", + }; + ( + format!("{}`{}`", local_kind, place_desc), + format!("`{}` is borrowed here", place_desc), + ) + } else { + let root_place = self.prefixes(&borrow.borrowed_place, PrefixSet::All) + .last() + .unwrap(); + let local = if let Place::Local(local) = *root_place { + local + } else { + bug!("report_cannot_return_reference_to_local: not a local") + }; + match self.mir.local_kind(local) { + LocalKind::ReturnPointer | LocalKind::Temp => { + ( + "temporary value".to_string(), + "temporary value created here".to_string(), + ) + } + LocalKind::Arg => { + ( + "function parameter".to_string(), + "function parameter borrowed here".to_string(), + ) + }, + LocalKind::Var => bug!("local variable without a name"), + } + }; + + let mut err = tcx.cannot_return_reference_to_local( + return_span, + reference_desc, + &place_desc, + Origin::Mir, + ); + + if return_span != borrow_span { + err.span_label(borrow_span, note); + } + + err + } + + fn report_escaping_closure_capture( + &mut self, + args_span: Span, + var_span: Span, + fr_name: &RegionName, + category: ConstraintCategory, + constraint_span: Span, + captured_var: &str, + ) -> DiagnosticBuilder<'cx> { + let tcx = self.infcx.tcx; + + let mut err = tcx.cannot_capture_in_long_lived_closure( + args_span, + captured_var, + var_span, + Origin::Mir, + ); + + let suggestion = match tcx.sess.source_map().span_to_snippet(args_span) { + Ok(string) => format!("move {}", string), + Err(_) => "move || ".to_string() + }; + + err.span_suggestion_with_applicability( + args_span, + &format!("to force the closure to take ownership of {} (and any \ + other referenced variables), use the `move` keyword", + captured_var), + suggestion, + Applicability::MachineApplicable, + ); + + match category { + ConstraintCategory::Return => { + err.span_note(constraint_span, &format!("closure is returned here")); + } + ConstraintCategory::CallArgument => { + fr_name.highlight_region_name(&mut err); + err.span_note( + constraint_span, + &format!("function requires argument type to outlive `{}`", fr_name), + ); + } + _ => bug!("report_escaping_closure_capture called with unexpected constraint \ + category: `{:?}`", category), + } + err + } + + fn report_escaping_data( + &mut self, + borrow_span: Span, + name: &Option, + upvar_span: Span, + upvar_name: &str, + escape_span: Span, + ) -> DiagnosticBuilder<'cx> { + let tcx = self.infcx.tcx; + + let escapes_from = if tcx.is_closure(self.mir_def_id) { + let tables = tcx.typeck_tables_of(self.mir_def_id); + let mir_hir_id = tcx.hir.def_index_to_hir_id(self.mir_def_id.index); + match tables.node_id_to_type(mir_hir_id).sty { + ty::Closure(..) => "closure", + ty::Generator(..) => "generator", + _ => bug!("Closure body doesn't have a closure or generator type"), + } + } else { + "function" + }; + + let mut err = tcx.borrowed_data_escapes_closure(escape_span, escapes_from, Origin::Mir); + + err.span_label( + upvar_span, + format!( + "`{}` is declared here, outside of the {} body", + upvar_name, escapes_from + ), + ); + + err.span_label( + borrow_span, + format!( + "borrow is only valid in the {} body", + escapes_from + ), + ); + + if let Some(name) = name { + err.span_label( + escape_span, + format!("reference to `{}` escapes the {} body here", name, escapes_from), + ); + } else { + err.span_label( + escape_span, + format!("reference escapes the {} body here", escapes_from), + ); + } + + err + } + + fn get_moved_indexes(&mut self, context: Context, mpi: MovePathIndex) -> Vec { let mir = self.mir; let mut stack = Vec::new(); - stack.extend(mir.predecessor_locations(context.loc)); + stack.extend(mir.predecessor_locations(context.loc).map(|predecessor| { + let is_back_edge = context.loc.dominates(predecessor, &self.dominators); + (predecessor, is_back_edge) + })); - let mut visited = FxHashSet(); + let mut visited = FxHashSet::default(); let mut result = vec![]; - 'dfs: while let Some(l) = stack.pop() { + 'dfs: while let Some((location, is_back_edge)) = stack.pop() { debug!( - "report_use_of_moved_or_uninitialized: current_location={:?}", - l + "report_use_of_moved_or_uninitialized: (current_location={:?}, back_edge={})", + location, is_back_edge ); - if !visited.insert(l) { + if !visited.insert(location) { continue; } // check for moves - let stmt_kind = mir[l.block] + let stmt_kind = mir[location.block] .statements - .get(l.statement_index) + .get(location.statement_index) .map(|s| &s.kind); if let Some(StatementKind::StorageDead(..)) = stmt_kind { // this analysis only tries to find moves explicitly @@ -564,11 +1131,25 @@ // created by `StorageDead` and at the beginning // of a function. } else { - for moi in &self.move_data.loc_map[l] { + // If we are found a use of a.b.c which was in error, then we want to look for + // moves not only of a.b.c but also a.b and a. + // + // Note that the moves data already includes "parent" paths, so we don't have to + // worry about the other case: that is, if there is a move of a.b.c, it is already + // marked as a move of a.b and a as well, so we will generate the correct errors + // there. + let mut mpis = vec![mpi]; + let move_paths = &self.move_data.move_paths; + mpis.extend(move_paths[mpi].parents(move_paths)); + + for moi in &self.move_data.loc_map[location] { debug!("report_use_of_moved_or_uninitialized: moi={:?}", moi); - if self.move_data.moves[*moi].path == mpi { + if mpis.contains(&self.move_data.moves[*moi].path) { debug!("report_use_of_moved_or_uninitialized: found"); - result.push(*moi); + result.push(MoveSite { + moi: *moi, + traversed_back_edge: is_back_edge, + }); // Strictly speaking, we could continue our DFS here. There may be // other moves that can reach the point of error. But it is kind of @@ -593,16 +1174,25 @@ // check for inits let mut any_match = false; - drop_flag_effects::for_location_inits(self.tcx, self.mir, self.move_data, l, |m| { - if m == mpi { - any_match = true; - } - }); + drop_flag_effects::for_location_inits( + self.infcx.tcx, + self.mir, + self.move_data, + location, + |m| { + if m == mpi { + any_match = true; + } + }, + ); if any_match { continue 'dfs; } - stack.extend(mir.predecessor_locations(l)); + stack.extend(mir.predecessor_locations(location).map(|predecessor| { + let back_edge = location.dominates(predecessor, &self.dominators); + (predecessor, is_back_edge || back_edge) + })); } result @@ -617,17 +1207,31 @@ let loan_spans = self.retrieve_borrow_spans(loan); let loan_span = loan_spans.args_or_use(); - let tcx = self.tcx; - let mut err = tcx.cannot_assign_to_borrowed( - span, - loan_span, - &self.describe_place(place).unwrap_or("_".to_owned()), - Origin::Mir, - ); + let tcx = self.infcx.tcx; + let mut err = if loan.kind == BorrowKind::Shallow { + tcx.cannot_mutate_in_match_guard( + span, + loan_span, + &self.describe_place(place).unwrap_or_else(|| "_".to_owned()), + "assign", + Origin::Mir, + ) + } else { + tcx.cannot_assign_to_borrowed( + span, + loan_span, + &self.describe_place(place).unwrap_or_else(|| "_".to_owned()), + Origin::Mir, + ) + }; - loan_spans.var_span_label(&mut err, "borrow occurs due to use in closure"); + loan_spans.var_span_label( + &mut err, + format!("borrow occurs due to use{}", loan_spans.describe()), + ); - self.explain_why_borrow_contains_point(context, loan, None, &mut err); + self.explain_why_borrow_contains_point(context, loan, None) + .add_explanation_to_diagnostic(self.infcx.tcx, self.mir, &mut err, ""); err.buffer(&mut self.errors_buffer); } @@ -679,7 +1283,7 @@ Some(decl) => (self.describe_place(err_place), decl.source_info.span), }; - let mut err = self.tcx.cannot_reassign_immutable( + let mut err = self.infcx.tcx.cannot_reassign_immutable( span, place_description.as_ref().map(AsRef::as_ref).unwrap_or("_"), from_arg, @@ -718,17 +1322,120 @@ pub(super) struct IncludingDowncast(bool); +/// Which case a StorageDeadOrDrop is for. +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +enum StorageDeadOrDrop<'tcx> { + LocalStorageDead, + BoxedStorageDead, + Destructor(ty::Ty<'tcx>), +} + impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { - // End-user visible description of `place` if one can be found. If the - // place is a temporary for instance, None will be returned. + + /// Adds a suggestion when a closure is invoked twice with a moved variable. + /// + /// ```text + /// note: closure cannot be invoked more than once because it moves the variable `dict` out of + /// its environment + /// --> $DIR/issue-42065.rs:16:29 + /// | + /// LL | for (key, value) in dict { + /// | ^^^^ + /// ``` + pub(super) fn add_closure_invoked_twice_with_moved_variable_suggestion( + &self, + location: Location, + place: &Place<'tcx>, + diag: &mut DiagnosticBuilder<'_>, + ) { + let mut target = place.local(); + debug!( + "add_closure_invoked_twice_with_moved_variable_suggestion: location={:?} place={:?} \ + target={:?}", + location, place, target, + ); + for stmt in &self.mir[location.block].statements[location.statement_index..] { + debug!( + "add_closure_invoked_twice_with_moved_variable_suggestion: stmt={:?} \ + target={:?}", + stmt, target, + ); + if let StatementKind::Assign(into, box Rvalue::Use(from)) = &stmt.kind { + debug!( + "add_closure_invoked_twice_with_moved_variable_suggestion: into={:?} \ + from={:?}", + into, from, + ); + match from { + Operand::Copy(ref place) | + Operand::Move(ref place) if target == place.local() => + target = into.local(), + _ => {}, + } + } + } + + + let terminator = self.mir[location.block].terminator(); + debug!( + "add_closure_invoked_twice_with_moved_variable_suggestion: terminator={:?}", + terminator, + ); + if let TerminatorKind::Call { + func: Operand::Constant(box Constant { + literal: ty::Const { ty: &ty::TyS { sty: ty::TyKind::FnDef(id, _), .. }, .. }, + .. + }), + args, + .. + } = &terminator.kind { + debug!("add_closure_invoked_twice_with_moved_variable_suggestion: id={:?}", id); + if self.infcx.tcx.parent(id) == self.infcx.tcx.lang_items().fn_once_trait() { + let closure = match args.first() { + Some(Operand::Copy(ref place)) | + Some(Operand::Move(ref place)) if target == place.local() => + place.local().unwrap(), + _ => return, + }; + debug!( + "add_closure_invoked_twice_with_moved_variable_suggestion: closure={:?}", + closure, + ); + + if let ty::TyKind::Closure(did, _substs) = self.mir.local_decls[closure].ty.sty { + let node_id = match self.infcx.tcx.hir.as_local_node_id(did) { + Some(node_id) => node_id, + _ => return, + }; + let hir_id = self.infcx.tcx.hir.node_to_hir_id(node_id); + + if let Some(( + span, name + )) = self.infcx.tcx.typeck_tables_of(did).closure_kind_origins().get(hir_id) { + diag.span_note( + *span, + &format!( + "closure cannot be invoked more than once because it \ + moves the variable `{}` out of its environment", + name, + ), + ); + } + } + } + } + } + + /// End-user visible description of `place` if one can be found. If the + /// place is a temporary for instance, None will be returned. pub(super) fn describe_place(&self, place: &Place<'tcx>) -> Option { self.describe_place_with_options(place, IncludingDowncast(false)) } - // End-user visible description of `place` if one can be found. If the - // place is a temporary for instance, None will be returned. - // `IncludingDowncast` parameter makes the function return `Err` if `ProjectionElem` is - // `Downcast` and `IncludingDowncast` is true + /// End-user visible description of `place` if one can be found. If the + /// place is a temporary for instance, None will be returned. + /// `IncludingDowncast` parameter makes the function return `Err` if `ProjectionElem` is + /// `Downcast` and `IncludingDowncast` is true pub(super) fn describe_place_with_options( &self, place: &Place<'tcx>, @@ -741,7 +1448,7 @@ } } - // Appends end-user visible description of `place` to `buf`. + /// Appends end-user visible description of `place` to `buf`. fn append_place_to_string( &self, place: &Place<'tcx>, @@ -757,13 +1464,13 @@ self.append_local_to_string(local, buf)?; } Place::Static(ref static_) => { - buf.push_str(&self.tcx.item_name(static_.def_id).to_string()); + buf.push_str(&self.infcx.tcx.item_name(static_.def_id).to_string()); } Place::Projection(ref proj) => { match proj.elem { ProjectionElem::Deref => { let upvar_field_projection = - place.is_upvar_field_projection(self.mir, &self.tcx); + place.is_upvar_field_projection(self.mir, &self.infcx.tcx); if let Some(field) = upvar_field_projection { let var_index = field.index(); let name = self.mir.upvar_decls[var_index].debug_name.to_string(); @@ -825,7 +1532,7 @@ autoderef = true; let upvar_field_projection = - place.is_upvar_field_projection(self.mir, &self.tcx); + place.is_upvar_field_projection(self.mir, &self.infcx.tcx); if let Some(field) = upvar_field_projection { let var_index = field.index(); let name = self.mir.upvar_decls[var_index].debug_name.to_string(); @@ -876,8 +1583,8 @@ Ok(()) } - // Appends end-user visible description of the `local` place to `buf`. If `local` doesn't have - // a name, then `Err` is returned + /// Appends end-user visible description of the `local` place to `buf`. If `local` doesn't have + /// a name, then `Err` is returned fn append_local_to_string(&self, local_index: Local, buf: &mut String) -> Result<(), ()> { let local = &self.mir.local_decls[local_index]; match local.name { @@ -889,7 +1596,7 @@ } } - // End-user visible description of the `field`nth field of `base` + /// End-user visible description of the `field`nth field of `base` fn describe_field(&self, base: &Place, field: Field) -> String { match *base { Place::Local(local) => { @@ -900,23 +1607,21 @@ Place::Static(ref static_) => self.describe_field_from_ty(&static_.ty, field), Place::Projection(ref proj) => match proj.elem { ProjectionElem::Deref => self.describe_field(&proj.base, field), - ProjectionElem::Downcast(def, variant_index) => format!( - "{}", - def.variants[variant_index].fields[field.index()].ident - ), + ProjectionElem::Downcast(def, variant_index) => + def.variants[variant_index].fields[field.index()].ident.to_string(), ProjectionElem::Field(_, field_type) => { self.describe_field_from_ty(&field_type, field) } ProjectionElem::Index(..) | ProjectionElem::ConstantIndex { .. } | ProjectionElem::Subslice { .. } => { - self.describe_field(&proj.base, field).to_string() + self.describe_field(&proj.base, field) } }, } } - // End-user visible description of the `field_index`nth field of `ty` + /// End-user visible description of the `field_index`nth field of `ty` fn describe_field_from_ty(&self, ty: &ty::Ty, field: Field) -> String { if ty.is_box() { // If the type is a box, the field is described from the boxed type @@ -940,10 +1645,12 @@ // the local code in the current crate, so this returns an `Option` in case // the closure comes from another crate. But in that case we wouldn't // be borrowck'ing it, so we can just unwrap: - let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap(); - let freevar = self.tcx.with_freevars(node_id, |fv| fv[field.index()]); + let node_id = self.infcx.tcx.hir.as_local_node_id(def_id).unwrap(); + let freevar = self.infcx + .tcx + .with_freevars(node_id, |fv| fv[field.index()]); - self.tcx.hir.name(freevar.var_id()).to_string() + self.infcx.tcx.hir.name(freevar.var_id()).to_string() } _ => { // Might need a revision when the fields in trait RFC is implemented @@ -957,7 +1664,7 @@ } } - // Retrieve type of a place for the current MIR representation + /// Retrieve type of a place for the current MIR representation fn retrieve_type_for_place(&self, place: &Place<'tcx>) -> Option { match place { Place::Local(local) => { @@ -976,7 +1683,7 @@ /// Check if a place is a thread-local static. pub fn is_place_thread_local(&self, place: &Place<'tcx>) -> bool { if let Place::Static(statik) = place { - let attrs = self.tcx.get_attrs(statik.def_id); + let attrs = self.infcx.tcx.get_attrs(statik.def_id); let is_thread_local = attrs.iter().any(|attr| attr.check_name("thread_local")); debug!( @@ -989,6 +1696,525 @@ false } } + + fn classify_drop_access_kind(&self, place: &Place<'tcx>) -> StorageDeadOrDrop<'tcx> { + let tcx = self.infcx.tcx; + match place { + Place::Local(_) | Place::Static(_) | Place::Promoted(_) => { + StorageDeadOrDrop::LocalStorageDead + } + Place::Projection(box PlaceProjection { base, elem }) => { + let base_access = self.classify_drop_access_kind(base); + match elem { + ProjectionElem::Deref => match base_access { + StorageDeadOrDrop::LocalStorageDead + | StorageDeadOrDrop::BoxedStorageDead => { + assert!( + base.ty(self.mir, tcx).to_ty(tcx).is_box(), + "Drop of value behind a reference or raw pointer" + ); + StorageDeadOrDrop::BoxedStorageDead + } + StorageDeadOrDrop::Destructor(_) => base_access, + }, + ProjectionElem::Field(..) | ProjectionElem::Downcast(..) => { + let base_ty = base.ty(self.mir, tcx).to_ty(tcx); + match base_ty.sty { + ty::Adt(def, _) if def.has_dtor(tcx) => { + // Report the outermost adt with a destructor + match base_access { + StorageDeadOrDrop::Destructor(_) => base_access, + StorageDeadOrDrop::LocalStorageDead + | StorageDeadOrDrop::BoxedStorageDead => { + StorageDeadOrDrop::Destructor(base_ty) + } + } + } + _ => base_access, + } + } + + ProjectionElem::ConstantIndex { .. } + | ProjectionElem::Subslice { .. } + | ProjectionElem::Index(_) => base_access, + } + } + } + } + + /// Annotate argument and return type of function and closure with (synthesized) lifetime for + /// borrow of local value that does not live long enough. + fn annotate_argument_and_return_for_borrow( + &self, + borrow: &BorrowData<'tcx>, + ) -> Option { + // Define a fallback for when we can't match a closure. + let fallback = || { + let is_closure = self.infcx.tcx.is_closure(self.mir_def_id); + if is_closure { + None + } else { + let ty = self.infcx.tcx.type_of(self.mir_def_id); + match ty.sty { + ty::TyKind::FnDef(_, _) | ty::TyKind::FnPtr(_) => self.annotate_fn_sig( + self.mir_def_id, + self.infcx.tcx.fn_sig(self.mir_def_id), + ), + _ => None, + } + } + }; + + // In order to determine whether we need to annotate, we need to check whether the reserve + // place was an assignment into a temporary. + // + // If it was, we check whether or not that temporary is eventually assigned into the return + // place. If it was, we can add annotations about the function's return type and arguments + // and it'll make sense. + let location = borrow.reserve_location; + debug!( + "annotate_argument_and_return_for_borrow: location={:?}", + location + ); + if let Some(&Statement { kind: StatementKind::Assign(ref reservation, _), ..}) + = &self.mir[location.block].statements.get(location.statement_index) + { + debug!( + "annotate_argument_and_return_for_borrow: reservation={:?}", + reservation + ); + // Check that the initial assignment of the reserve location is into a temporary. + let mut target = *match reservation { + Place::Local(local) if self.mir.local_kind(*local) == LocalKind::Temp => local, + _ => return None, + }; + + // Next, look through the rest of the block, checking if we are assigning the + // `target` (that is, the place that contains our borrow) to anything. + let mut annotated_closure = None; + for stmt in &self.mir[location.block].statements[location.statement_index + 1..] { + debug!( + "annotate_argument_and_return_for_borrow: target={:?} stmt={:?}", + target, stmt + ); + if let StatementKind::Assign(Place::Local(assigned_to), box rvalue) = &stmt.kind + { + debug!( + "annotate_argument_and_return_for_borrow: assigned_to={:?} \ + rvalue={:?}", + assigned_to, rvalue + ); + // Check if our `target` was captured by a closure. + if let Rvalue::Aggregate( + box AggregateKind::Closure(def_id, substs), + operands, + ) = rvalue + { + for operand in operands { + let assigned_from = match operand { + Operand::Copy(assigned_from) | Operand::Move(assigned_from) => { + assigned_from + } + _ => continue, + }; + debug!( + "annotate_argument_and_return_for_borrow: assigned_from={:?}", + assigned_from + ); + + // Find the local from the operand. + let assigned_from_local = match assigned_from.local() { + Some(local) => local, + None => continue, + }; + + if assigned_from_local != target { + continue; + } + + // If a closure captured our `target` and then assigned + // into a place then we should annotate the closure in + // case it ends up being assigned into the return place. + annotated_closure = self.annotate_fn_sig( + *def_id, + self.infcx.closure_sig(*def_id, *substs), + ); + debug!( + "annotate_argument_and_return_for_borrow: \ + annotated_closure={:?} assigned_from_local={:?} \ + assigned_to={:?}", + annotated_closure, assigned_from_local, assigned_to + ); + + if *assigned_to == mir::RETURN_PLACE { + // If it was assigned directly into the return place, then + // return now. + return annotated_closure; + } else { + // Otherwise, update the target. + target = *assigned_to; + } + } + + // If none of our closure's operands matched, then skip to the next + // statement. + continue; + } + + // Otherwise, look at other types of assignment. + let assigned_from = match rvalue { + Rvalue::Ref(_, _, assigned_from) => assigned_from, + Rvalue::Use(operand) => match operand { + Operand::Copy(assigned_from) | Operand::Move(assigned_from) => { + assigned_from + } + _ => continue, + }, + _ => continue, + }; + debug!( + "annotate_argument_and_return_for_borrow: \ + assigned_from={:?}", + assigned_from, + ); + + // Find the local from the rvalue. + let assigned_from_local = match assigned_from.local() { + Some(local) => local, + None => continue, + }; + debug!( + "annotate_argument_and_return_for_borrow: \ + assigned_from_local={:?}", + assigned_from_local, + ); + + // Check if our local matches the target - if so, we've assigned our + // borrow to a new place. + if assigned_from_local != target { + continue; + } + + // If we assigned our `target` into a new place, then we should + // check if it was the return place. + debug!( + "annotate_argument_and_return_for_borrow: \ + assigned_from_local={:?} assigned_to={:?}", + assigned_from_local, assigned_to + ); + if *assigned_to == mir::RETURN_PLACE { + // If it was then return the annotated closure if there was one, + // else, annotate this function. + return annotated_closure.or_else(fallback); + } + + // If we didn't assign into the return place, then we just update + // the target. + target = *assigned_to; + } + } + + // Check the terminator if we didn't find anything in the statements. + let terminator = &self.mir[location.block].terminator(); + debug!( + "annotate_argument_and_return_for_borrow: target={:?} terminator={:?}", + target, terminator + ); + if let TerminatorKind::Call { + destination: Some((Place::Local(assigned_to), _)), + args, + .. + } = &terminator.kind + { + debug!( + "annotate_argument_and_return_for_borrow: assigned_to={:?} args={:?}", + assigned_to, args + ); + for operand in args { + let assigned_from = match operand { + Operand::Copy(assigned_from) | Operand::Move(assigned_from) => { + assigned_from + } + _ => continue, + }; + debug!( + "annotate_argument_and_return_for_borrow: assigned_from={:?}", + assigned_from, + ); + + if let Some(assigned_from_local) = assigned_from.local() { + debug!( + "annotate_argument_and_return_for_borrow: assigned_from_local={:?}", + assigned_from_local, + ); + + if *assigned_to == mir::RETURN_PLACE && assigned_from_local == target { + return annotated_closure.or_else(fallback); + } + } + } + } + } + + // If we haven't found an assignment into the return place, then we need not add + // any annotations. + debug!("annotate_argument_and_return_for_borrow: none found"); + None + } + + /// Annotate the first argument and return type of a function signature if they are + /// references. + fn annotate_fn_sig( + &self, + did: DefId, + sig: ty::PolyFnSig<'tcx>, + ) -> Option { + debug!("annotate_fn_sig: did={:?} sig={:?}", did, sig); + let is_closure = self.infcx.tcx.is_closure(did); + let fn_node_id = self.infcx.tcx.hir.as_local_node_id(did)?; + let fn_decl = self.infcx.tcx.hir.fn_decl(fn_node_id)?; + + // We need to work out which arguments to highlight. We do this by looking + // at the return type, where there are three cases: + // + // 1. If there are named arguments, then we should highlight the return type and + // highlight any of the arguments that are also references with that lifetime. + // If there are no arguments that have the same lifetime as the return type, + // then don't highlight anything. + // 2. The return type is a reference with an anonymous lifetime. If this is + // the case, then we can take advantage of (and teach) the lifetime elision + // rules. + // + // We know that an error is being reported. So the arguments and return type + // must satisfy the elision rules. Therefore, if there is a single argument + // then that means the return type and first (and only) argument have the same + // lifetime and the borrow isn't meeting that, we can highlight the argument + // and return type. + // + // If there are multiple arguments then the first argument must be self (else + // it would not satisfy the elision rules), so we can highlight self and the + // return type. + // 3. The return type is not a reference. In this case, we don't highlight + // anything. + let return_ty = sig.output(); + match return_ty.skip_binder().sty { + ty::TyKind::Ref(return_region, _, _) if return_region.has_name() && !is_closure => { + // This is case 1 from above, return type is a named reference so we need to + // search for relevant arguments. + let mut arguments = Vec::new(); + for (index, argument) in sig.inputs().skip_binder().iter().enumerate() { + if let ty::TyKind::Ref(argument_region, _, _) = argument.sty { + if argument_region == return_region { + // Need to use the `rustc::ty` types to compare against the + // `return_region`. Then use the `rustc::hir` type to get only + // the lifetime span. + if let hir::TyKind::Rptr(lifetime, _) = &fn_decl.inputs[index].node { + // With access to the lifetime, we can get + // the span of it. + arguments.push((*argument, lifetime.span)); + } else { + bug!("ty type is a ref but hir type is not"); + } + } + } + } + + // We need to have arguments. This shouldn't happen, but it's worth checking. + if arguments.is_empty() { + return None; + } + + // We use a mix of the HIR and the Ty types to get information + // as the HIR doesn't have full types for closure arguments. + let return_ty = *sig.output().skip_binder(); + let mut return_span = fn_decl.output.span(); + if let hir::FunctionRetTy::Return(ty) = fn_decl.output { + if let hir::TyKind::Rptr(lifetime, _) = ty.into_inner().node { + return_span = lifetime.span; + } + } + + Some(AnnotatedBorrowFnSignature::NamedFunction { + arguments, + return_ty, + return_span, + }) + } + ty::TyKind::Ref(_, _, _) if is_closure => { + // This is case 2 from above but only for closures, return type is anonymous + // reference so we select + // the first argument. + let argument_span = fn_decl.inputs.first()?.span; + let argument_ty = sig.inputs().skip_binder().first()?; + + // Closure arguments are wrapped in a tuple, so we need to get the first + // from that. + if let ty::TyKind::Tuple(elems) = argument_ty.sty { + let argument_ty = elems.first()?; + if let ty::TyKind::Ref(_, _, _) = argument_ty.sty { + return Some(AnnotatedBorrowFnSignature::Closure { + argument_ty, + argument_span, + }); + } + } + + None + } + ty::TyKind::Ref(_, _, _) => { + // This is also case 2 from above but for functions, return type is still an + // anonymous reference so we select the first argument. + let argument_span = fn_decl.inputs.first()?.span; + let argument_ty = sig.inputs().skip_binder().first()?; + + let return_span = fn_decl.output.span(); + let return_ty = *sig.output().skip_binder(); + + // We expect the first argument to be a reference. + match argument_ty.sty { + ty::TyKind::Ref(_, _, _) => {} + _ => return None, + } + + Some(AnnotatedBorrowFnSignature::AnonymousFunction { + argument_ty, + argument_span, + return_ty, + return_span, + }) + } + _ => { + // This is case 3 from above, return type is not a reference so don't highlight + // anything. + None + } + } + } +} + +#[derive(Debug)] +enum AnnotatedBorrowFnSignature<'tcx> { + NamedFunction { + arguments: Vec<(ty::Ty<'tcx>, Span)>, + return_ty: ty::Ty<'tcx>, + return_span: Span, + }, + AnonymousFunction { + argument_ty: ty::Ty<'tcx>, + argument_span: Span, + return_ty: ty::Ty<'tcx>, + return_span: Span, + }, + Closure { + argument_ty: ty::Ty<'tcx>, + argument_span: Span, + }, +} + +impl<'tcx> AnnotatedBorrowFnSignature<'tcx> { + /// Annotate the provided diagnostic with information about borrow from the fn signature that + /// helps explain. + fn emit(&self, diag: &mut DiagnosticBuilder<'_>) -> String { + match self { + AnnotatedBorrowFnSignature::Closure { + argument_ty, + argument_span, + } => { + diag.span_label( + *argument_span, + format!("has type `{}`", self.get_name_for_ty(argument_ty, 0)), + ); + + self.get_region_name_for_ty(argument_ty, 0) + } + AnnotatedBorrowFnSignature::AnonymousFunction { + argument_ty, + argument_span, + return_ty, + return_span, + } => { + let argument_ty_name = self.get_name_for_ty(argument_ty, 0); + diag.span_label(*argument_span, format!("has type `{}`", argument_ty_name)); + + let return_ty_name = self.get_name_for_ty(return_ty, 0); + let types_equal = return_ty_name == argument_ty_name; + diag.span_label( + *return_span, + format!( + "{}has type `{}`", + if types_equal { "also " } else { "" }, + return_ty_name, + ), + ); + + diag.note( + "argument and return type have the same lifetime due to lifetime elision rules", + ); + diag.note( + "to learn more, visit ", + ); + + self.get_region_name_for_ty(return_ty, 0) + } + AnnotatedBorrowFnSignature::NamedFunction { + arguments, + return_ty, + return_span, + } => { + // Region of return type and arguments checked to be the same earlier. + let region_name = self.get_region_name_for_ty(return_ty, 0); + for (_, argument_span) in arguments { + diag.span_label(*argument_span, format!("has lifetime `{}`", region_name)); + } + + diag.span_label( + *return_span, + format!("also has lifetime `{}`", region_name,), + ); + + diag.help(&format!( + "use data from the highlighted arguments which match the `{}` lifetime of \ + the return type", + region_name, + )); + + region_name + } + } + } + + /// Return the name of the provided `Ty` (that must be a reference) with a synthesized lifetime + /// name where required. + fn get_name_for_ty(&self, ty: ty::Ty<'tcx>, counter: usize) -> String { + // We need to add synthesized lifetimes where appropriate. We do + // this by hooking into the pretty printer and telling it to label the + // lifetimes without names with the value `'0`. + match ty.sty { + ty::TyKind::Ref(ty::RegionKind::ReLateBound(_, br), _, _) + | ty::TyKind::Ref( + ty::RegionKind::RePlaceholder(ty::Placeholder { name: br, .. }), + _, + _, + ) => with_highlight_region_for_bound_region(*br, counter, || ty.to_string()), + _ => ty.to_string(), + } + } + + /// Return the name of the provided `Ty` (that must be a reference)'s region with a + /// synthesized lifetime name where required. + fn get_region_name_for_ty(&self, ty: ty::Ty<'tcx>, counter: usize) -> String { + match ty.sty { + ty::TyKind::Ref(region, _, _) => match region { + ty::RegionKind::ReLateBound(_, br) + | ty::RegionKind::RePlaceholder(ty::Placeholder { name: br, .. }) => { + with_highlight_region_for_bound_region(*br, counter, || region.to_string()) + } + _ => region.to_string(), + }, + _ => bug!("ty for annotation of borrow region is not a reference"), + } + } } // The span(s) associated to a use of a place. @@ -996,6 +2222,8 @@ pub(super) enum UseSpans { // The access is caused by capturing a variable for a closure. ClosureUse { + // This is true if the captured variable was from a generator. + is_generator: bool, // The span of the args of the closure, including the `move` keyword if // it's present. args_span: Span, @@ -1036,10 +2264,31 @@ } } - pub(super) fn for_closure(self) -> bool { - match self { - UseSpans::ClosureUse { .. } => true, - UseSpans::OtherUse(_) => false, + /// Return `false` if this place is not used in a closure. + fn for_closure(&self) -> bool { + match *self { + UseSpans::ClosureUse { is_generator, .. } => !is_generator, + _ => false, + } + } + + /// Return `false` if this place is not used in a generator. + fn for_generator(&self) -> bool { + match *self { + UseSpans::ClosureUse { is_generator, .. } => is_generator, + _ => false, + } + } + + /// Describe the span associated with a use of a place. + fn describe(&self) -> String { + match *self { + UseSpans::ClosureUse { is_generator, .. } => if is_generator { + " in generator".to_string() + } else { + " in closure".to_string() + }, + _ => "".to_string(), } } @@ -1062,51 +2311,37 @@ location: Location, ) -> UseSpans { use self::UseSpans::*; - use rustc::hir::ExprKind::Closure; - use rustc::mir::AggregateKind; - let stmt = match self.mir[location.block] - .statements - .get(location.statement_index) - { + let stmt = match self.mir[location.block].statements.get(location.statement_index) { Some(stmt) => stmt, None => return OtherUse(self.mir.source_info(location).span), }; - if let StatementKind::Assign(_, Rvalue::Aggregate(ref kind, ref places)) = stmt.kind { - if let AggregateKind::Closure(def_id, _) = **kind { - debug!("find_closure_move_span: found closure {:?}", places); - - if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { - if let Closure(_, _, _, args_span, _) = self.tcx.hir.expect_expr(node_id).node { - if let Some(var_span) = self.tcx.with_freevars(node_id, |freevars| { - for (v, place) in freevars.iter().zip(places) { - match place { - Operand::Copy(place) | Operand::Move(place) - if moved_place == place => - { - debug!( - "find_closure_move_span: found captured local {:?}", - place - ); - return Some(v.span); - } - _ => {} - } - } - None - }) { - return ClosureUse { - args_span, - var_span, - }; - } - } - } + debug!("move_spans: moved_place={:?} location={:?} stmt={:?}", moved_place, location, stmt); + if let StatementKind::Assign( + _, + box Rvalue::Aggregate(ref kind, ref places) + ) = stmt.kind { + let (def_id, is_generator) = match kind { + box AggregateKind::Closure(def_id, _) => (def_id, false), + box AggregateKind::Generator(def_id, _, _) => (def_id, true), + _ => return OtherUse(stmt.source_info.span), + }; + + debug!( + "move_spans: def_id={:?} is_generator={:?} places={:?}", + def_id, is_generator, places + ); + if let Some((args_span, var_span)) = self.closure_span(*def_id, moved_place, places) { + return ClosureUse { + is_generator, + args_span, + var_span, + }; } } - return OtherUse(stmt.source_info.span); + OtherUse(stmt.source_info.span) } /// Finds the span of arguments of a closure (within `maybe_closure_span`) @@ -1115,10 +2350,9 @@ /// and originating from `maybe_closure_span`. pub(super) fn borrow_spans(&self, use_span: Span, location: Location) -> UseSpans { use self::UseSpans::*; - use rustc::hir::ExprKind::Closure; - use rustc::mir::AggregateKind; + debug!("borrow_spans: use_span={:?} location={:?}", use_span, location); - let local = match self.mir[location.block] + let target = match self.mir[location.block] .statements .get(location.statement_index) { @@ -1129,51 +2363,35 @@ _ => return OtherUse(use_span), }; - if self.mir.local_kind(local) != LocalKind::Temp { + if self.mir.local_kind(target) != LocalKind::Temp { // operands are always temporaries. return OtherUse(use_span); } for stmt in &self.mir[location.block].statements[location.statement_index + 1..] { - if let StatementKind::Assign(_, Rvalue::Aggregate(ref kind, ref places)) = stmt.kind { - if let AggregateKind::Closure(def_id, _) = **kind { - debug!("find_closure_borrow_span: found closure {:?}", places); - - return if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { - let args_span = if let Closure(_, _, _, span, _) = - self.tcx.hir.expect_expr(node_id).node - { - span - } else { - return OtherUse(use_span); - }; + if let StatementKind::Assign( + _, box Rvalue::Aggregate(ref kind, ref places) + ) = stmt.kind { + let (def_id, is_generator) = match kind { + box AggregateKind::Closure(def_id, _) => (def_id, false), + box AggregateKind::Generator(def_id, _, _) => (def_id, true), + _ => continue, + }; - self.tcx - .with_freevars(node_id, |freevars| { - for (v, place) in freevars.iter().zip(places) { - match *place { - Operand::Copy(Place::Local(l)) - | Operand::Move(Place::Local(l)) - if local == l => - { - debug!( - "find_closure_borrow_span: found captured local \ - {:?}", - l - ); - return Some(v.span); - } - _ => {} - } - } - None - }).map(|var_span| ClosureUse { - args_span, - var_span, - }).unwrap_or(OtherUse(use_span)) - } else { - OtherUse(use_span) + debug!( + "borrow_spans: def_id={:?} is_generator={:?} places={:?}", + def_id, is_generator, places + ); + if let Some((args_span, var_span)) = self.closure_span( + *def_id, &Place::Local(target), places + ) { + return ClosureUse { + is_generator, + args_span, + var_span, }; + } else { + return OtherUse(use_span); } } @@ -1185,6 +2403,47 @@ OtherUse(use_span) } + /// Finds the span of a captured variable within a closure or generator. + fn closure_span( + &self, + def_id: DefId, + target_place: &Place<'tcx>, + places: &Vec>, + ) -> Option<(Span, Span)> { + debug!( + "closure_span: def_id={:?} target_place={:?} places={:?}", + def_id, target_place, places + ); + let node_id = self.infcx.tcx.hir.as_local_node_id(def_id)?; + let expr = &self.infcx.tcx.hir.expect_expr(node_id).node; + debug!("closure_span: node_id={:?} expr={:?}", node_id, expr); + if let hir::ExprKind::Closure( + .., args_span, _ + ) = expr { + let var_span = self.infcx.tcx.with_freevars( + node_id, + |freevars| { + for (v, place) in freevars.iter().zip(places) { + match place { + Operand::Copy(place) | + Operand::Move(place) if target_place == place => { + debug!("closure_span: found captured local {:?}", place); + return Some(v.span); + }, + _ => {} + } + } + + None + }, + )?; + + Some((*args_span, var_span)) + } else { + None + } + } + /// Helper to retrieve span(s) of given borrow from the current MIR /// representation pub(super) fn retrieve_borrow_spans(&self, borrow: &BorrowData) -> UseSpans { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/flows.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/flows.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/flows.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/flows.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,7 +15,7 @@ use rustc::mir::{BasicBlock, Location}; use rustc::ty::RegionVid; -use rustc_data_structures::bitvec::BitIter; +use rustc_data_structures::bit_set::BitIter; use borrow_check::location::LocationIndex; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -23,21 +23,21 @@ use rustc::mir::{Field, Projection, ProjectionElem, Rvalue, Statement, StatementKind}; use rustc::mir::{Terminator, TerminatorKind}; use rustc::ty::query::Providers; -use rustc::ty::{self, ParamEnv, TyCtxt, Ty}; +use rustc::ty::{self, TyCtxt}; use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, Level}; -use rustc_data_structures::graph::dominators::Dominators; +use rustc_data_structures::bit_set::BitSet; use rustc_data_structures::fx::FxHashSet; -use rustc_data_structures::indexed_set::IdxSet; -use rustc_data_structures::indexed_vec::Idx; +use rustc_data_structures::graph::dominators::Dominators; use smallvec::SmallVec; use std::rc::Rc; +use std::collections::BTreeMap; use syntax_pos::Span; -use dataflow::indexes::BorrowIndex; -use dataflow::move_paths::{HasMoveData, LookupResult, MoveData, MoveError, MovePathIndex}; +use dataflow::indexes::{BorrowIndex, InitIndex, MoveOutIndex, MovePathIndex}; +use dataflow::move_paths::{HasMoveData, LookupResult, MoveData, MoveError}; use dataflow::Borrows; use dataflow::DataflowResultsConsumer; use dataflow::FlowAtLocation; @@ -167,7 +167,7 @@ _ => Some(tcx.hir.body_owned_by(id)), }; - let dead_unwinds = IdxSet::new_empty(mir.basic_blocks().len()); + let dead_unwinds = BitSet::new_empty(mir.basic_blocks().len()); let mut flow_inits = FlowAtLocation::new(do_dataflow( tcx, mir, @@ -245,20 +245,20 @@ let dominators = mir.dominators(); let mut mbcx = MirBorrowckCtxt { - tcx: tcx, - mir: mir, + infcx, + mir, mir_def_id: def_id, move_data: &mdpe.move_data, - param_env: param_env, location_table, movable_generator, locals_are_invalidated_at_exit, - access_place_error_reported: FxHashSet(), - reservation_error_reported: FxHashSet(), - moved_error_reported: FxHashSet(), + access_place_error_reported: Default::default(), + reservation_error_reported: Default::default(), + move_error_reported: BTreeMap::new(), + uninitialized_error_reported: Default::default(), errors_buffer, nonlexical_regioncx: regioncx, - used_mut: FxHashSet(), + used_mut: Default::default(), used_mut_upvars: SmallVec::new(), borrow_set, dominators, @@ -284,7 +284,7 @@ let temporary_used_locals: FxHashSet = mbcx .used_mut .iter() - .filter(|&local| !mbcx.mir.local_decls[*local].is_user_variable.is_some()) + .filter(|&local| mbcx.mir.local_decls[*local].is_user_variable.is_none()) .cloned() .collect(); mbcx.gather_used_muts(temporary_used_locals); @@ -315,29 +315,64 @@ } let span = local_decl.source_info.span; - let mut_span = tcx.sess.source_map().span_until_non_whitespace(span); + if span.compiler_desugaring_kind().is_some() { + // If the `mut` arises as part of a desugaring, we should ignore it. + continue; + } - let mut err = tcx.struct_span_lint_node( + let mut_span = tcx.sess.source_map().span_until_non_whitespace(span); + tcx.struct_span_lint_node( UNUSED_MUT, vsi[local_decl.source_info.scope].lint_root, span, "variable does not need to be mutable", - ); - err.span_suggestion_short_with_applicability( + ) + .span_suggestion_short_with_applicability( mut_span, "remove this `mut`", String::new(), - Applicability::MachineApplicable); - - err.buffer(&mut mbcx.errors_buffer); + Applicability::MachineApplicable, + ) + .emit(); } } - if mbcx.errors_buffer.len() > 0 { + // Buffer any move errors that we collected and de-duplicated. + for (_, (_, diag)) in mbcx.move_error_reported { + diag.buffer(&mut mbcx.errors_buffer); + } + + if !mbcx.errors_buffer.is_empty() { mbcx.errors_buffer.sort_by_key(|diag| diag.span.primary_span()); if tcx.migrate_borrowck() { - match tcx.borrowck(def_id).signalled_any_error { + // When borrowck=migrate, check if AST-borrowck would + // error on the given code. + + // rust-lang/rust#55492: loop over parents to ensure that + // errors that AST-borrowck only detects in some parent of + // a closure still allows NLL to signal an error. + let mut curr_def_id = def_id; + let signalled_any_error = loop { + match tcx.borrowck(curr_def_id).signalled_any_error { + SignalledError::NoErrorsSeen => { + // keep traversing (and borrow-checking) parents + } + SignalledError::SawSomeError => { + // stop search here + break SignalledError::SawSomeError; + } + } + + if tcx.is_closure(curr_def_id) { + curr_def_id = tcx.parent_def_id(curr_def_id) + .expect("a closure must have a parent_def_id"); + } else { + break SignalledError::NoErrorsSeen; + } + }; + + match signalled_any_error { SignalledError::NoErrorsSeen => { // if AST-borrowck signalled no errors, then // downgrade all the buffered MIR-borrowck errors @@ -361,7 +396,7 @@ } for diag in mbcx.errors_buffer.drain(..) { - DiagnosticBuilder::new_diagnostic(mbcx.tcx.sess.diagnostic(), diag).emit(); + DiagnosticBuilder::new_diagnostic(mbcx.infcx.tcx.sess.diagnostic(), diag).emit(); } } @@ -376,7 +411,7 @@ } pub struct MirBorrowckCtxt<'cx, 'gcx: 'tcx, 'tcx: 'cx> { - tcx: TyCtxt<'cx, 'gcx, 'tcx>, + infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, mir: &'cx Mir<'tcx>, mir_def_id: DefId, move_data: &'cx MoveData<'tcx>, @@ -385,7 +420,6 @@ /// when MIR borrowck begins. location_table: &'cx LocationTable, - param_env: ParamEnv<'gcx>, movable_generator: bool, /// This keeps track of whether local variables are free-ed when the function /// exits even without a `StorageDead`, which appears to be the case for @@ -408,9 +442,24 @@ /// but it is currently inconvenient to track down the BorrowIndex /// at the time we detect and report a reservation error. reservation_error_reported: FxHashSet>, - /// This field keeps track of errors reported in the checking of moved variables, + /// This field keeps track of move errors that are to be reported for given move indicies. + /// + /// There are situations where many errors can be reported for a single move out (see #53807) + /// and we want only the best of those errors. + /// + /// The `report_use_of_moved_or_uninitialized` function checks this map and replaces the + /// diagnostic (if there is one) if the `Place` of the error being reported is a prefix of the + /// `Place` of the previous most diagnostic. This happens instead of buffering the error. Once + /// all move errors have been reported, any diagnostics in this map are added to the buffer + /// to be emitted. + /// + /// `BTreeMap` is used to preserve the order of insertions when iterating. This is necessary + /// when errors in the map are being re-added to the error buffer so that errors with the + /// same primary span come out in a consistent order. + move_error_reported: BTreeMap, (Place<'tcx>, DiagnosticBuilder<'cx>)>, + /// This field keeps track of errors reported in the checking of uninitialized variables, /// so that we don't report seemingly duplicate errors. - moved_error_reported: FxHashSet>, + uninitialized_error_reported: FxHashSet>, /// Errors to be reported buffer errors_buffer: Vec, /// This field keeps track of all the local variables that are declared mut and are mutated. @@ -478,12 +527,21 @@ flow_state, ); } - StatementKind::ReadForMatch(ref place) => { - self.access_place( - ContextKind::ReadForMatch.new(location), + StatementKind::FakeRead(_, ref place) => { + // Read for match doesn't access any memory and is used to + // assert that a place is safe and live. So we don't have to + // do any checks here. + // + // FIXME: Remove check that the place is initialized. This is + // needed for now because matches don't have never patterns yet. + // So this is the only place we prevent + // let x: !; + // match x {}; + // from compiling. + self.check_if_path_or_subpath_is_moved( + ContextKind::FakeRead.new(location), + InitializationRequiringAction::Use, (place, span), - (Deep, Read(ReadKind::Borrow(BorrowKind::Shared))), - LocalMutationIsAllowed::No, flow_state, ); } @@ -505,13 +563,13 @@ ref inputs, } => { let context = ContextKind::InlineAsm.new(location); - for (o, output) in asm.outputs.iter().zip(outputs) { + for (o, output) in asm.outputs.iter().zip(outputs.iter()) { if o.is_indirect { // FIXME(eddyb) indirect inline asm outputs should // be encoeded through MIR place derefs instead. self.access_place( context, - (output, span), + (output, o.span), (Deep, Read(ReadKind::Copy)), LocalMutationIsAllowed::No, flow_state, @@ -519,20 +577,20 @@ self.check_if_path_or_subpath_is_moved( context, InitializationRequiringAction::Use, - (output, span), + (output, o.span), flow_state, ); } else { self.mutate_place( context, - (output, span), + (output, o.span), if o.is_rw { Deep } else { Shallow(None) }, if o.is_rw { WriteAndRead } else { JustWrite }, flow_state, ); } } - for input in inputs { + for input in inputs.iter() { self.consume_operand(context, (input, span), flow_state); } } @@ -588,13 +646,14 @@ target: _, unwind: _, } => { - let gcx = self.tcx.global_tcx(); + let gcx = self.infcx.tcx.global_tcx(); // Compute the type with accurate region information. - let drop_place_ty = drop_place.ty(self.mir, self.tcx); + let drop_place_ty = drop_place.ty(self.mir, self.infcx.tcx); // Erase the regions. - let drop_place_ty = self.tcx.erase_regions(&drop_place_ty).to_ty(self.tcx); + let drop_place_ty = self.infcx.tcx.erase_regions(&drop_place_ty) + .to_ty(self.infcx.tcx); // "Lift" into the gcx -- once regions are erased, this type should be in the // global arenas; this "lift" operation basically just asserts that is true, but @@ -605,8 +664,13 @@ loc: {:?} term: {:?} drop_place: {:?} drop_place_ty: {:?} span: {:?}", loc, term, drop_place, drop_place_ty, span); - self.visit_terminator_drop( - loc, term, flow_state, drop_place, drop_place_ty, span, SeenTy(None)); + self.access_place( + ContextKind::Drop.new(loc), + (drop_place, span), + (AccessDepth::Drop, Write(WriteKind::StorageDeadOrDrop)), + LocalMutationIsAllowed::Yes, + flow_state, + ); } TerminatorKind::DropAndReplace { location: ref drop_place, @@ -632,6 +696,7 @@ ref args, ref destination, cleanup: _, + from_hir_call: _, } => { self.consume_operand(ContextKind::CallOperator.new(loc), (func, span), flow_state); for arg in args { @@ -723,16 +788,17 @@ } use self::ReadOrWrite::{Activation, Read, Reservation, Write}; -use self::ShallowOrDeep::{Deep, Shallow}; +use self::AccessDepth::{Deep, Shallow}; #[derive(Copy, Clone, PartialEq, Eq, Debug)] enum ArtificialField { Discriminant, ArrayLength, + ShallowBorrow, } #[derive(Copy, Clone, PartialEq, Eq, Debug)] -enum ShallowOrDeep { +enum AccessDepth { /// From the RFC: "A *shallow* access means that the immediate /// fields reached at P are accessed, but references or pointers /// found within are not dereferenced. Right now, the only access @@ -744,6 +810,10 @@ /// through the given place may be invalidated or accesses by /// this action." Deep, + + /// Access is Deep only when there is a Drop implementation that + /// can reach the data behind the reference. + Drop, } /// Kind of access to a value: read or write @@ -801,12 +871,14 @@ No, } -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug)] enum InitializationRequiringAction { Update, Borrow, + MatchOn, Use, Assignment, + PartialAssignment, } struct RootPlace<'d, 'tcx: 'd> { @@ -819,8 +891,10 @@ match self { InitializationRequiringAction::Update => "update", InitializationRequiringAction::Borrow => "borrow", + InitializationRequiringAction::MatchOn => "use", // no good noun InitializationRequiringAction::Use => "use", InitializationRequiringAction::Assignment => "assign", + InitializationRequiringAction::PartialAssignment => "assign to part", } } @@ -828,234 +902,15 @@ match self { InitializationRequiringAction::Update => "updated", InitializationRequiringAction::Borrow => "borrowed", + InitializationRequiringAction::MatchOn => "matched on", InitializationRequiringAction::Use => "used", InitializationRequiringAction::Assignment => "assigned", - } - } -} - -/// A simple linked-list threaded up the stack of recursive calls in `visit_terminator_drop`. -#[derive(Copy, Clone, Debug)] -struct SeenTy<'a, 'gcx: 'a>(Option<(Ty<'gcx>, &'a SeenTy<'a, 'gcx>)>); - -impl<'a, 'gcx> SeenTy<'a, 'gcx> { - /// Return a new list with `ty` prepended to the front of `self`. - fn cons(&'a self, ty: Ty<'gcx>) -> Self { - SeenTy(Some((ty, self))) - } - - /// True if and only if `ty` occurs on the linked list `self`. - fn have_seen(self, ty: Ty) -> bool { - let mut this = self.0; - loop { - match this { - None => return false, - Some((seen_ty, recur)) => { - if seen_ty == ty { - return true; - } else { - this = recur.0; - continue; - } - } - } + InitializationRequiringAction::PartialAssignment => "partially assigned", } } } impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { - /// Invokes `access_place` as appropriate for dropping the value - /// at `drop_place`. Note that the *actual* `Drop` in the MIR is - /// always for a variable (e.g., `Drop(x)`) -- but we recursively - /// break this variable down into subpaths (e.g., `Drop(x.foo)`) - /// to indicate more precisely which fields might actually be - /// accessed by a destructor. - fn visit_terminator_drop( - &mut self, - loc: Location, - term: &Terminator<'tcx>, - flow_state: &Flows<'cx, 'gcx, 'tcx>, - drop_place: &Place<'tcx>, - erased_drop_place_ty: ty::Ty<'gcx>, - span: Span, - prev_seen: SeenTy<'_, 'gcx>, - ) { - if prev_seen.have_seen(erased_drop_place_ty) { - // if we have directly seen the input ty `T`, then we must - // have had some *direct* ownership loop between `T` and - // some directly-owned (as in, actually traversed by - // recursive calls below) part that is also of type `T`. - // - // Note: in *all* such cases, the data in question cannot - // be constructed (nor destructed) in finite time/space. - // - // Proper examples, some of which are statically rejected: - // - // * `struct A { field: A, ... }`: - // statically rejected as infinite size - // - // * `type B = (B, ...);`: - // statically rejected as cyclic - // - // * `struct C { field: Box, ... }` - // * `struct D { field: Box<(D, D)>, ... }`: - // *accepted*, though impossible to construct - // - // Here is *NOT* an example: - // * `struct Z { field: Option>, ... }`: - // Here, the type is both representable in finite space (due to the boxed indirection) - // and constructable in finite time (since the recursion can bottom out with `None`). - // This is an obvious instance of something the compiler must accept. - // - // Since some of the above impossible cases like `C` and - // `D` are accepted by the compiler, we must take care not - // to infinite-loop while processing them. But since such - // cases cannot actually arise, it is sound for us to just - // skip them during drop. If the developer uses unsafe - // code to construct them, they should not be surprised by - // weird drop behavior in their resulting code. - debug!("visit_terminator_drop previously seen \ - erased_drop_place_ty: {:?} on prev_seen: {:?}; returning early.", - erased_drop_place_ty, prev_seen); - return; - } - - let gcx = self.tcx.global_tcx(); - let drop_field = |mir: &mut MirBorrowckCtxt<'cx, 'gcx, 'tcx>, - (index, field): (usize, ty::Ty<'gcx>)| { - let field_ty = gcx.normalize_erasing_regions(mir.param_env, field); - let place = drop_place.clone().field(Field::new(index), field_ty); - - debug!("visit_terminator_drop drop_field place: {:?} field_ty: {:?}", place, field_ty); - let seen = prev_seen.cons(erased_drop_place_ty); - mir.visit_terminator_drop(loc, term, flow_state, &place, field_ty, span, seen); - }; - - match erased_drop_place_ty.sty { - // When a struct is being dropped, we need to check - // whether it has a destructor, if it does, then we can - // call it, if it does not then we need to check the - // individual fields instead. This way if `foo` has a - // destructor but `bar` does not, we will only check for - // borrows of `x.foo` and not `x.bar`. See #47703. - ty::Adt(def, substs) if def.is_struct() && !def.has_dtor(self.tcx) => { - def.all_fields() - .map(|field| field.ty(gcx, substs)) - .enumerate() - .for_each(|field| drop_field(self, field)); - } - // Same as above, but for tuples. - ty::Tuple(tys) => { - tys.iter() - .cloned() - .enumerate() - .for_each(|field| drop_field(self, field)); - } - // Closures also have disjoint fields, but they are only - // directly accessed in the body of the closure. - ty::Closure(def, substs) - if *drop_place == Place::Local(Local::new(1)) - && !self.mir.upvar_decls.is_empty() => - { - substs - .upvar_tys(def, self.tcx) - .enumerate() - .for_each(|field| drop_field(self, field)); - } - // Generators also have disjoint fields, but they are only - // directly accessed in the body of the generator. - ty::Generator(def, substs, _) - if *drop_place == Place::Local(Local::new(1)) - && !self.mir.upvar_decls.is_empty() => - { - substs - .upvar_tys(def, self.tcx) - .enumerate() - .for_each(|field| drop_field(self, field)); - } - - // #45696: special-case Box by treating its dtor as - // only deep *across owned content*. Namely, we know - // dropping a box does not touch data behind any - // references it holds; if we were to instead fall into - // the base case below, we would have a Deep Write due to - // the box being `needs_drop`, and that Deep Write would - // touch `&mut` data in the box. - ty::Adt(def, _) if def.is_box() => { - // When/if we add a `&own T` type, this action would - // be like running the destructor of the `&own T`. - // (And the owner of backing storage referenced by the - // `&own T` would be responsible for deallocating that - // backing storage.) - - // we model dropping any content owned by the box by - // recurring on box contents. This catches cases like - // `Box>>`, while - // still restricting Write to *owned* content. - let ty = erased_drop_place_ty.boxed_ty(); - let deref_place = drop_place.clone().deref(); - debug!("visit_terminator_drop drop-box-content deref_place: {:?} ty: {:?}", - deref_place, ty); - let seen = prev_seen.cons(erased_drop_place_ty); - self.visit_terminator_drop( - loc, term, flow_state, &deref_place, ty, span, seen); - } - - _ => { - // We have now refined the type of the value being - // dropped (potentially) to just the type of a - // subfield; so check whether that field's type still - // "needs drop". - if erased_drop_place_ty.needs_drop(gcx, self.param_env) { - // If so, we assume that the destructor may access - // any data it likes (i.e., a Deep Write). - self.access_place( - ContextKind::Drop.new(loc), - (drop_place, span), - (Deep, Write(WriteKind::StorageDeadOrDrop)), - LocalMutationIsAllowed::Yes, - flow_state, - ); - } else { - // If there is no destructor, we still include a - // *shallow* write. This essentially ensures that - // borrows of the memory directly at `drop_place` - // cannot continue to be borrowed across the drop. - // - // If we were to use a Deep Write here, then any - // `&mut T` that is reachable from `drop_place` - // would get invalidated; fixing that is the - // essence of resolving issue #45696. - // - // * Note: In the compiler today, doing a Deep - // Write here would not actually break - // anything beyond #45696; for example it does not - // break this example: - // - // ```rust - // fn reborrow(x: &mut i32) -> &mut i32 { &mut *x } - // ``` - // - // Why? Because we do not schedule/emit - // `Drop(x)` in the MIR unless `x` needs drop in - // the first place. - // - // FIXME: Its possible this logic actually should - // be attached to the `StorageDead` statement - // rather than the `Drop`. See discussion on PR - // #52782. - self.access_place( - ContextKind::Drop.new(loc), - (drop_place, span), - (Shallow(None), Write(WriteKind::StorageDeadOrDrop)), - LocalMutationIsAllowed::Yes, - flow_state, - ); - } - } - } - } - /// 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 @@ -1066,7 +921,7 @@ &mut self, context: Context, place_span: (&Place<'tcx>, Span), - kind: (ShallowOrDeep, ReadOrWrite), + kind: (AccessDepth, ReadOrWrite), is_local_mutation_allowed: LocalMutationIsAllowed, flow_state: &Flows<'cx, 'gcx, 'tcx>, ) { @@ -1122,7 +977,7 @@ &mut self, context: Context, place_span: (&Place<'tcx>, Span), - sd: ShallowOrDeep, + sd: AccessDepth, rw: ReadOrWrite, flow_state: &Flows<'cx, 'gcx, 'tcx>, ) -> bool { @@ -1132,7 +987,7 @@ ); let mut error_reported = false; - let tcx = self.tcx; + let tcx = self.infcx.tcx; let mir = self.mir; let location = self.location_table.start_index(context.loc); let borrow_set = self.borrow_set.clone(); @@ -1163,24 +1018,29 @@ Control::Continue } - (Read(_), BorrowKind::Shared) | (Reservation(..), BorrowKind::Shared) => { + (Read(_), BorrowKind::Shared) | (Reservation(..), BorrowKind::Shared) + | (Read(_), BorrowKind::Shallow) | (Reservation(..), BorrowKind::Shallow) => { + Control::Continue + } + + (Write(WriteKind::Move), BorrowKind::Shallow) => { + // Handled by initialization checks. Control::Continue } (Read(kind), BorrowKind::Unique) | (Read(kind), BorrowKind::Mut { .. }) => { // Reading from mere reservations of mutable-borrows is OK. if !is_active(&this.dominators, borrow, context.loc) { - assert!(allow_two_phase_borrow(&this.tcx, borrow.kind)); + assert!(allow_two_phase_borrow(&this.infcx.tcx, borrow.kind)); return Control::Continue; } + error_reported = true; match kind { - ReadKind::Copy => { - error_reported = true; + ReadKind::Copy => { this.report_use_while_mutably_borrowed(context, place_span, borrow) } ReadKind::Borrow(bk) => { - error_reported = true; this.report_conflicting_borrow(context, place_span, bk, &borrow) } } @@ -1210,26 +1070,22 @@ Read(..) | Write(..) => {} } + error_reported = true; match kind { WriteKind::MutableBorrow(bk) => { - error_reported = true; this.report_conflicting_borrow(context, place_span, bk, &borrow) } WriteKind::StorageDeadOrDrop => { - error_reported = true; this.report_borrowed_value_does_not_live_long_enough( context, borrow, place_span, - Some(kind), - ); + Some(kind)) } WriteKind::Mutate => { - error_reported = true; this.report_illegal_mutation_of_borrowed(context, place_span, borrow) } WriteKind::Move => { - error_reported = true; this.report_move_out_while_borrowed(context, place_span, &borrow) } } @@ -1245,7 +1101,7 @@ &mut self, context: Context, place_span: (&Place<'tcx>, Span), - kind: ShallowOrDeep, + kind: AccessDepth, mode: MutateMode, flow_state: &Flows<'cx, 'gcx, 'tcx>, ) { @@ -1300,10 +1156,13 @@ match *rvalue { Rvalue::Ref(_ /*rgn*/, bk, ref place) => { let access_kind = match bk { + BorrowKind::Shallow => { + (Shallow(Some(ArtificialField::ShallowBorrow)), Read(ReadKind::Borrow(bk))) + }, BorrowKind::Shared => (Deep, Read(ReadKind::Borrow(bk))), BorrowKind::Unique | BorrowKind::Mut { .. } => { let wk = WriteKind::MutableBorrow(bk); - if allow_two_phase_borrow(&self.tcx, bk) { + if allow_two_phase_borrow(&self.infcx.tcx, bk) { (Deep, Reservation(wk)) } else { (Deep, Write(wk)) @@ -1319,9 +1178,15 @@ flow_state, ); + let action = if bk == BorrowKind::Shallow { + InitializationRequiringAction::MatchOn + } else { + InitializationRequiringAction::Borrow + }; + self.check_if_path_or_subpath_is_moved( context, - InitializationRequiringAction::Borrow, + action, (place, span), flow_state, ); @@ -1378,7 +1243,7 @@ | AggregateKind::Generator(def_id, _, _) => { let BorrowCheckResult { used_mut_upvars, .. - } = self.tcx.mir_borrowck(def_id); + } = self.infcx.tcx.mir_borrowck(def_id); debug!("{:?} used_mut_upvars={:?}", def_id, used_mut_upvars); for field in used_mut_upvars { // This relies on the current way that by-value @@ -1392,7 +1257,7 @@ Operand::Move(ref place @ Place::Projection(_)) | Operand::Copy(ref place @ Place::Projection(_)) => { if let Some(field) = place.is_upvar_field_projection( - self.mir, &self.tcx) { + self.mir, &self.infcx.tcx) { self.used_mut_upvars.push(field); } } @@ -1464,7 +1329,7 @@ } } - /// Returns whether a borrow of this place is invalidated when the function + /// Checks whether a borrow of this place is invalidated when the function /// exits fn check_for_invalidation_at_exit( &mut self, @@ -1507,15 +1372,20 @@ return; } - // FIXME: replace this with a proper borrow_conflicts_with_place when - // that is merged. let sd = if might_be_alive { Deep } else { Shallow(None) }; - if places_conflict::places_conflict(self.tcx, self.mir, place, root_place, sd) { + if places_conflict::borrow_conflicts_with_place( + self.infcx.tcx, + self.mir, + place, + borrow.kind, + root_place, + sd + ) { debug!("check_for_invalidation_at_exit({:?}): INVALID", place); // FIXME: should be talking about the region lifetime instead // of just a span here. - let span = self.tcx.sess.source_map().end_point(span); + let span = self.infcx.tcx.sess.source_map().end_point(span); self.report_borrowed_value_does_not_live_long_enough( context, borrow, @@ -1531,7 +1401,7 @@ debug!("check_for_local_borrow({:?})", borrow); if borrow_of_local_data(&borrow.borrowed_place) { - let err = self.tcx + let err = self.infcx.tcx .cannot_borrow_across_generator_yield( self.retrieve_borrow_spans(borrow).var_or_use(), yield_span, @@ -1548,7 +1418,7 @@ span: Span, flow_state: &Flows<'cx, 'gcx, 'tcx>, ) { - if !self.tcx.two_phase_borrows() { + if !self.infcx.tcx.two_phase_borrows() { return; } @@ -1561,7 +1431,7 @@ // only mutable borrows should be 2-phase assert!(match borrow.kind { - BorrowKind::Shared => false, + BorrowKind::Shared | BorrowKind::Shallow => false, BorrowKind::Unique | BorrowKind::Mut { .. } => true, }); @@ -1593,10 +1463,7 @@ debug!("check_if_reassignment_to_immutable_state({:?})", local); // Check if any of the initializiations of `local` have happened yet: - let mpi = self.move_data.rev_lookup.find_local(local); - let init_indices = &self.move_data.init_path_map[mpi]; - let first_init_index = init_indices.iter().find(|ii| flow_state.ever_inits.contains(ii)); - if let Some(&init_index) = first_init_index { + if let Some(init_index) = self.is_local_ever_initialized(local, flow_state) { // And, if so, report an error. let init = &self.move_data.inits[init_index]; let span = init.span(&self.mir); @@ -1652,12 +1519,12 @@ debug!("check_if_full_path_is_moved place: {:?}", place_span.0); match self.move_path_closest_to(place_span.0) { - Ok(mpi) => { - if maybe_uninits.contains(&mpi) { + Ok((prefix, mpi)) => { + if maybe_uninits.contains(mpi) { self.report_use_of_moved_or_uninitialized( context, desired_action, - place_span, + (prefix, place_span.0, place_span.1), mpi, ); return; // don't bother finding other problems. @@ -1715,7 +1582,7 @@ self.report_use_of_moved_or_uninitialized( context, desired_action, - place_span, + (place_span.0, place_span.0, place_span.1), child_mpi, ); return; // don't bother finding other problems. @@ -1733,14 +1600,14 @@ /// An Err result includes a tag indicated why the search failed. /// Currently this can only occur if the place is built off of a /// static variable, as we do not track those in the MoveData. - fn move_path_closest_to( + fn move_path_closest_to<'a>( &mut self, - place: &Place<'tcx>, - ) -> Result { + place: &'a Place<'tcx>, + ) -> Result<(&'a Place<'tcx>, MovePathIndex), NoMovePathFound> where 'cx: 'a { let mut last_prefix = place; for prefix in self.prefixes(place, PrefixSet::All) { if let Some(mpi) = self.move_path_for_place(prefix) { - return Ok(mpi); + return Ok((prefix, mpi)); } last_prefix = prefix; } @@ -1748,7 +1615,7 @@ Place::Local(_) => panic!("should have move path for every Local"), Place::Projection(_) => panic!("PrefixSet::All meant don't stop for Projection"), Place::Promoted(_) | - Place::Static(_) => return Err(NoMovePathFound::ReachedStatic), + Place::Static(_) => Err(NoMovePathFound::ReachedStatic), } } @@ -1810,7 +1677,7 @@ // if type of `P` has a dtor, then // assigning to `P.f` requires `P` itself // be already initialized - let tcx = self.tcx; + let tcx = self.infcx.tcx; match base.ty(self.mir, tcx).to_ty(tcx).sty { ty::Adt(def, _) if def.has_dtor(tcx) => { self.check_if_path_or_subpath_is_moved( @@ -1821,6 +1688,26 @@ // recur further) break; } + + + // Once `let s; s.x = V; read(s.x);`, + // is allowed, remove this match arm. + ty::Adt(..) | ty::Tuple(..) => { + check_parent_of_field(self, context, base, span, flow_state); + + if let Some(local) = place.base_local() { + // rust-lang/rust#21232, + // #54499, #54986: during + // period where we reject + // partial initialization, do + // not complain about + // unnecessary `mut` on an + // attempt to do a partial + // initialization. + self.used_mut.insert(local); + } + } + _ => {} } } @@ -1831,8 +1718,73 @@ } } } - } + fn check_parent_of_field<'cx, 'gcx, 'tcx>(this: &mut MirBorrowckCtxt<'cx, 'gcx, 'tcx>, + context: Context, + base: &Place<'tcx>, + span: Span, + flow_state: &Flows<'cx, 'gcx, 'tcx>) + { + // rust-lang/rust#21232: Until Rust allows reads from the + // initialized parts of partially initialized structs, we + // will, starting with the 2018 edition, reject attempts + // to write to structs that are not fully initialized. + // + // In other words, *until* we allow this: + // + // 1. `let mut s; s.x = Val; read(s.x);` + // + // we will for now disallow this: + // + // 2. `let mut s; s.x = Val;` + // + // and also this: + // + // 3. `let mut s = ...; drop(s); s.x=Val;` + // + // This does not use check_if_path_or_subpath_is_moved, + // because we want to *allow* reinitializations of fields: + // e.g. want to allow + // + // `let mut s = ...; drop(s.x); s.x=Val;` + // + // This does not use check_if_full_path_is_moved on + // `base`, because that would report an error about the + // `base` as a whole, but in this scenario we *really* + // want to report an error about the actual thing that was + // moved, which may be some prefix of `base`. + + // Shallow so that we'll stop at any dereference; we'll + // report errors about issues with such bases elsewhere. + let maybe_uninits = &flow_state.uninits; + + // Find the shortest uninitialized prefix you can reach + // without going over a Deref. + let mut shortest_uninit_seen = None; + for prefix in this.prefixes(base, PrefixSet::Shallow) { + let mpi = match this.move_path_for_place(prefix) { + Some(mpi) => mpi, None => continue, + }; + + if maybe_uninits.contains(mpi) { + debug!("check_parent_of_field updating shortest_uninit_seen from {:?} to {:?}", + shortest_uninit_seen, Some((prefix, mpi))); + shortest_uninit_seen = Some((prefix, mpi)); + } else { + debug!("check_parent_of_field {:?} is definitely initialized", (prefix, mpi)); + } + } + + if let Some((prefix, mpi)) = shortest_uninit_seen { + this.report_use_of_moved_or_uninitialized( + context, + InitializationRequiringAction::PartialAssignment, + (prefix, base, span), + mpi, + ); + } + } + } /// Check the permissions for the given place and read or write kind /// @@ -1846,13 +1798,23 @@ location: Location, ) -> bool { debug!( - "check_access_permissions({:?}, {:?}, {:?})", + "check_access_permissions({:?}, {:?}, is_local_mutation_allowed: {:?})", place, kind, is_local_mutation_allowed ); let error_access; let the_place_err; + // rust-lang/rust#21232, #54986: during period where we reject + // partial initialization, do not complain about mutability + // errors except for actual mutation (as opposed to an attempt + // to do a partial initialization). + let previously_initialized = if let Some(local) = place.base_local() { + self.is_local_ever_initialized(local, flow_state).is_some() + } else { + true + }; + match kind { Reservation(WriteKind::MutableBorrow(borrow_kind @ BorrowKind::Unique)) | Reservation(WriteKind::MutableBorrow(borrow_kind @ BorrowKind::Mut { .. })) @@ -1861,7 +1823,7 @@ let is_local_mutation_allowed = match borrow_kind { BorrowKind::Unique => LocalMutationIsAllowed::Yes, BorrowKind::Mut { .. } => is_local_mutation_allowed, - BorrowKind::Shared => unreachable!(), + BorrowKind::Shared | BorrowKind::Shallow => unreachable!(), }; match self.is_mutable(place, is_local_mutation_allowed) { Ok(root_place) => { @@ -1891,10 +1853,12 @@ | Write(wk @ WriteKind::Move) | Reservation(wk @ WriteKind::StorageDeadOrDrop) | Reservation(wk @ WriteKind::MutableBorrow(BorrowKind::Shared)) + | Reservation(wk @ WriteKind::MutableBorrow(BorrowKind::Shallow)) | Write(wk @ WriteKind::StorageDeadOrDrop) - | Write(wk @ WriteKind::MutableBorrow(BorrowKind::Shared)) => { + | Write(wk @ WriteKind::MutableBorrow(BorrowKind::Shared)) + | Write(wk @ WriteKind::MutableBorrow(BorrowKind::Shallow)) => { if let Err(_place_err) = self.is_mutable(place, is_local_mutation_allowed) { - if self.tcx.migrate_borrowck() { + if self.infcx.tcx.migrate_borrowck() { // rust-lang/rust#46908: In pure NLL mode this // code path should be unreachable (and thus // we signal an ICE in the else branch @@ -1917,7 +1881,7 @@ location, ); } else { - self.tcx.sess.delay_span_bug( + self.infcx.tcx.sess.delay_span_bug( span, &format!( "Accessing `{:?}` with the kind `{:?}` shouldn't be possible", @@ -1935,6 +1899,7 @@ Read(ReadKind::Borrow(BorrowKind::Unique)) | Read(ReadKind::Borrow(BorrowKind::Mut { .. })) | Read(ReadKind::Borrow(BorrowKind::Shared)) + | Read(ReadKind::Borrow(BorrowKind::Shallow)) | Read(ReadKind::Copy) => { // Access authorized return false; @@ -1942,14 +1907,33 @@ } // at this point, we have set up the error reporting state. - self.report_mutability_error( - place, - span, - the_place_err, - error_access, - location, - ); - return true; + return if previously_initialized { + self.report_mutability_error( + place, + span, + the_place_err, + error_access, + location, + ); + true + } else { + false + }; + } + + fn is_local_ever_initialized(&self, + local: Local, + flow_state: &Flows<'cx, 'gcx, 'tcx>) + -> Option + { + let mpi = self.move_data.rev_lookup.find_local(local); + let ii = &self.move_data.init_path_map[mpi]; + for &index in ii { + if flow_state.ever_inits.contains(index) { + return Some(index); + } + } + None } /// Adds the place into the used mutable variables set @@ -1963,18 +1947,13 @@ place: Place::Local(local), is_local_mutation_allowed, } => { - if is_local_mutation_allowed != LocalMutationIsAllowed::Yes { - // If the local may be initialized, and it is now currently being - // mutated, then it is justified to be annotated with the `mut` - // keyword, since the mutation may be a possible reassignment. - let mpi = self.move_data.rev_lookup.find_local(*local); - let ii = &self.move_data.init_path_map[mpi]; - for index in ii { - if flow_state.ever_inits.contains(index) { - self.used_mut.insert(*local); - break; - } - } + // If the local may have been initialized, and it is now currently being + // mutated, then it is justified to be annotated with the `mut` + // keyword, since the mutation may be a possible reassignment. + if is_local_mutation_allowed != LocalMutationIsAllowed::Yes && + self.is_local_ever_initialized(*local, flow_state).is_some() + { + self.used_mut.insert(*local); } } RootPlace { @@ -1985,7 +1964,7 @@ place: place @ Place::Projection(_), is_local_mutation_allowed: _, } => { - if let Some(field) = place.is_upvar_field_projection(self.mir, &self.tcx) { + if let Some(field) = place.is_upvar_field_projection(self.mir, &self.infcx.tcx) { self.used_mut_upvars.push(field); } } @@ -2000,7 +1979,7 @@ } } - /// Whether this value be written or borrowed mutably. + /// Whether this value can be written or borrowed mutably. /// Returns the root place if the place passed in is a projection. fn is_mutable<'d>( &self, @@ -2035,7 +2014,7 @@ is_local_mutation_allowed, }), Place::Static(ref static_) => { - if self.tcx.is_static(static_.def_id) != Some(hir::Mutability::MutMutable) { + if self.infcx.tcx.is_static(static_.def_id) != Some(hir::Mutability::MutMutable) { Err(place) } else { Ok(RootPlace { @@ -2047,7 +2026,7 @@ Place::Projection(ref proj) => { match proj.elem { ProjectionElem::Deref => { - let base_ty = proj.base.ty(self.mir, self.tcx).to_ty(self.tcx); + let base_ty = proj.base.ty(self.mir, self.infcx.tcx).to_ty(self.infcx.tcx); // Check the kind of deref to decide match base_ty.sty { @@ -2059,7 +2038,7 @@ // unique path to the `&mut` hir::MutMutable => { let mode = match place.is_upvar_field_projection( - self.mir, &self.tcx) + self.mir, &self.infcx.tcx) { Some(field) if { @@ -2078,14 +2057,14 @@ ty::RawPtr(tnm) => { match tnm.mutbl { // `*const` raw pointers are not mutable - hir::MutImmutable => return Err(place), + hir::MutImmutable => Err(place), // `*mut` raw pointers are always mutable, regardless of // context. The users have to check by themselves. hir::MutMutable => { - return Ok(RootPlace { + Ok(RootPlace { place, is_local_mutation_allowed, - }); + }) } } } @@ -2105,7 +2084,7 @@ | ProjectionElem::Subslice { .. } | ProjectionElem::Downcast(..) => { let upvar_field_projection = place.is_upvar_field_projection( - self.mir, &self.tcx); + self.mir, &self.infcx.tcx); if let Some(field) = upvar_field_projection { let decl = &self.mir.upvar_decls[field.index()]; debug!( @@ -2206,7 +2185,7 @@ CallDest, Assert, Yield, - ReadForMatch, + FakeRead, StorageDead, } @@ -2214,7 +2193,7 @@ fn new(self, loc: Location) -> Context { Context { kind: self, - loc: loc, + loc, } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/move_errors.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/move_errors.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/move_errors.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/move_errors.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,15 +9,19 @@ // except according to those terms. use core::unicode::property::Pattern_White_Space; +use std::fmt::{self, Display}; + use rustc::mir::*; use rustc::ty; -use rustc_errors::DiagnosticBuilder; +use rustc_errors::{DiagnosticBuilder,Applicability}; use syntax_pos::Span; use borrow_check::MirBorrowckCtxt; use borrow_check::prefixes::PrefixSet; -use dataflow::move_paths::{IllegalMoveOrigin, IllegalMoveOriginKind}; -use dataflow::move_paths::{LookupResult, MoveError, MovePathIndex}; +use dataflow::move_paths::{ + IllegalMoveOrigin, IllegalMoveOriginKind, InitLocation, + LookupResult, MoveError, MovePathIndex, +}; use util::borrowck_errors::{BorrowckErrors, Origin}; // Often when desugaring a pattern match we may have many individual moves in @@ -61,6 +65,24 @@ }, } +enum BorrowedContentSource { + Arc, + Rc, + DerefRawPointer, + Other, +} + +impl Display for BorrowedContentSource { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + BorrowedContentSource::Arc => write!(f, "an `Arc`"), + BorrowedContentSource::Rc => write!(f, "an `Rc`"), + BorrowedContentSource::DerefRawPointer => write!(f, "dereference of raw pointer"), + BorrowedContentSource::Other => write!(f, "borrowed content"), + } + } +} + impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> { pub(crate) fn report_move_errors(&mut self, move_errors: Vec<(Place<'tcx>, MoveError<'tcx>)>) { let grouped_errors = self.group_move_errors(move_errors); @@ -100,7 +122,7 @@ // flow could be used. if let Some(StatementKind::Assign( Place::Local(local), - Rvalue::Use(Operand::Move(move_from)), + box Rvalue::Use(Operand::Move(move_from)), )) = self.mir.basic_blocks()[location.block] .statements .get(location.statement_index) @@ -244,30 +266,32 @@ let origin = Origin::Mir; debug!("report: original_path={:?} span={:?}, kind={:?} \ original_path.is_upvar_field_projection={:?}", original_path, span, kind, - original_path.is_upvar_field_projection(self.mir, &self.tcx)); + original_path.is_upvar_field_projection(self.mir, &self.infcx.tcx)); ( match kind { IllegalMoveOriginKind::Static => { - self.tcx.cannot_move_out_of(span, "static item", origin) + self.infcx.tcx.cannot_move_out_of(span, "static item", origin) } IllegalMoveOriginKind::BorrowedContent { target_place: place } => { // Inspect the type of the content behind the // borrow to provide feedback about why this // was a move rather than a copy. - let ty = place.ty(self.mir, self.tcx).to_ty(self.tcx); + let ty = place.ty(self.mir, self.infcx.tcx).to_ty(self.infcx.tcx); let is_upvar_field_projection = self.prefixes(&original_path, PrefixSet::All) - .any(|p| p.is_upvar_field_projection(self.mir, &self.tcx) + .any(|p| p.is_upvar_field_projection(self.mir, &self.infcx.tcx) .is_some()); + debug!("report: ty={:?}", ty); match ty.sty { - ty::Array(..) | ty::Slice(..) => self - .tcx - .cannot_move_out_of_interior_noncopy(span, ty, None, origin), + ty::Array(..) | ty::Slice(..) => + self.infcx.tcx.cannot_move_out_of_interior_noncopy( + span, ty, None, origin + ), ty::Closure(def_id, closure_substs) if !self.mir.upvar_decls.is_empty() && is_upvar_field_projection => { let closure_kind_ty = - closure_substs.closure_kind_ty(def_id, self.tcx); + closure_substs.closure_kind_ty(def_id, self.infcx.tcx); let closure_kind = closure_kind_ty.to_opt_closure_kind(); let place_description = match closure_kind { Some(ty::ClosureKind::Fn) => { @@ -285,18 +309,18 @@ place_description={:?}", closure_kind_ty, closure_kind, place_description); - let mut diag = self.tcx.cannot_move_out_of( + let mut diag = self.infcx.tcx.cannot_move_out_of( span, place_description, origin); for prefix in self.prefixes(&original_path, PrefixSet::All) { if let Some(field) = prefix.is_upvar_field_projection( - self.mir, &self.tcx) { + self.mir, &self.infcx.tcx) { let upvar_decl = &self.mir.upvar_decls[field.index()]; let upvar_hir_id = upvar_decl.var_hir_id.assert_crate_local(); let upvar_node_id = - self.tcx.hir.hir_to_node_id(upvar_hir_id); - let upvar_span = self.tcx.hir.span(upvar_node_id); + self.infcx.tcx.hir.hir_to_node_id(upvar_hir_id); + let upvar_span = self.infcx.tcx.hir.span(upvar_node_id); diag.span_label(upvar_span, "captured outer variable"); break; } @@ -304,18 +328,22 @@ diag } - _ => self - .tcx - .cannot_move_out_of(span, "borrowed content", origin), + _ => { + let source = self.borrowed_content_source(place); + self.infcx.tcx.cannot_move_out_of( + span, &source.to_string(), origin + ) + }, } } IllegalMoveOriginKind::InteriorOfTypeWithDestructor { container_ty: ty } => { - self.tcx + self.infcx.tcx .cannot_move_out_of_interior_of_drop(span, ty, origin) } - IllegalMoveOriginKind::InteriorOfSliceOrArray { ty, is_index } => self - .tcx - .cannot_move_out_of_interior_noncopy(span, ty, Some(*is_index), origin), + IllegalMoveOriginKind::InteriorOfSliceOrArray { ty, is_index } => + self.infcx.tcx.cannot_move_out_of_interior_noncopy( + span, ty, Some(*is_index), origin + ), }, span, ) @@ -331,7 +359,7 @@ err: &mut DiagnosticBuilder<'a>, span: Span, ) { - let snippet = self.tcx.sess.source_map().span_to_snippet(span).unwrap(); + let snippet = self.infcx.tcx.sess.source_map().span_to_snippet(span).unwrap(); match error { GroupedMoveError::MovesFromPlace { mut binds_to, @@ -350,16 +378,18 @@ // expressions `a[b]`, which roughly desugar to // `*Index::index(&a, b)` or // `*IndexMut::index_mut(&mut a, b)`. - err.span_suggestion( + err.span_suggestion_with_applicability( span, "consider removing the `*`", snippet[1..].to_owned(), + Applicability::Unspecified, ); } else { - err.span_suggestion( + err.span_suggestion_with_applicability( span, "consider borrowing here", format!("&{}", snippet), + Applicability::Unspecified, ); } @@ -392,8 +422,7 @@ .. })) ) = bind_to.is_user_variable { - let pat_snippet = self - .tcx.sess.source_map() + let pat_snippet = self.infcx.tcx.sess.source_map() .span_to_snippet(pat_span) .unwrap(); if pat_snippet.starts_with('&') { @@ -420,10 +449,11 @@ suggestions.sort_unstable_by_key(|&(span, _, _)| span); suggestions.dedup_by_key(|&mut (span, _, _)| span); for (span, to_remove, suggestion) in suggestions { - err.span_suggestion( + err.span_suggestion_with_applicability( span, &format!("consider removing the `{}`", to_remove), - suggestion + suggestion, + Applicability::MachineApplicable, ); } } @@ -439,9 +469,9 @@ let binding_span = bind_to.source_info.span; if j == 0 { - err.span_label(binding_span, format!("data moved here")); + err.span_label(binding_span, "data moved here"); } else { - err.span_label(binding_span, format!("...and here")); + err.span_label(binding_span, "...and here"); } if binds_to.len() == 1 { @@ -467,4 +497,106 @@ ); } } + + fn borrowed_content_source(&self, place: &Place<'tcx>) -> BorrowedContentSource { + // Look up the provided place and work out the move path index for it, + // we'll use this to work back through where this value came from and check whether it + // was originally part of an `Rc` or `Arc`. + let initial_mpi = match self.move_data.rev_lookup.find(place) { + LookupResult::Exact(mpi) | LookupResult::Parent(Some(mpi)) => mpi, + _ => return BorrowedContentSource::Other, + }; + + let mut queue = vec![initial_mpi]; + let mut visited = Vec::new(); + debug!("borrowed_content_source: queue={:?}", queue); + while let Some(mpi) = queue.pop() { + debug!( + "borrowed_content_source: mpi={:?} queue={:?} visited={:?}", + mpi, queue, visited + ); + + // Don't visit the same path twice. + if visited.contains(&mpi) { + continue; + } + visited.push(mpi); + + for i in &self.move_data.init_path_map[mpi] { + let init = &self.move_data.inits[*i]; + debug!("borrowed_content_source: init={:?}", init); + // We're only interested in statements that initialized a value, not the + // initializations from arguments. + let loc = match init.location { + InitLocation::Statement(stmt) => stmt, + _ => continue, + }; + + let bbd = &self.mir[loc.block]; + let is_terminator = bbd.statements.len() == loc.statement_index; + debug!("borrowed_content_source: loc={:?} is_terminator={:?}", loc, is_terminator); + if !is_terminator { + let stmt = &bbd.statements[loc.statement_index]; + debug!("borrowed_content_source: stmt={:?}", stmt); + // We're only interested in assignments (in particular, where the + // assignment came from - was it an `Rc` or `Arc`?). + if let StatementKind::Assign(_, box Rvalue::Ref(_, _, source)) = &stmt.kind { + let ty = source.ty(self.mir, self.infcx.tcx).to_ty(self.infcx.tcx); + let ty = match ty.sty { + ty::TyKind::Ref(_, ty, _) => ty, + _ => ty, + }; + debug!("borrowed_content_source: ty={:?}", ty); + + if ty.is_arc() { + return BorrowedContentSource::Arc; + } else if ty.is_rc() { + return BorrowedContentSource::Rc; + } else { + queue.push(init.path); + } + } + } else if let Some(Terminator { + kind: TerminatorKind::Call { args, .. }, + .. + }) = &bbd.terminator { + for arg in args { + let source = match arg { + Operand::Copy(place) | Operand::Move(place) => place, + _ => continue, + }; + + let ty = source.ty(self.mir, self.infcx.tcx).to_ty(self.infcx.tcx); + let ty = match ty.sty { + ty::TyKind::Ref(_, ty, _) => ty, + _ => ty, + }; + debug!("borrowed_content_source: ty={:?}", ty); + + if ty.is_arc() { + return BorrowedContentSource::Arc; + } else if ty.is_rc() { + return BorrowedContentSource::Rc; + } else { + queue.push(init.path); + } + } + } + } + } + + // If we didn't find an `Arc` or an `Rc`, then check specifically for + // a dereference of a place that has the type of a raw pointer. + // We can't use `place.ty(..).to_ty(..)` here as that strips away the raw pointer. + if let Place::Projection(box Projection { + base, + elem: ProjectionElem::Deref, + }) = place { + if base.ty(self.mir, self.infcx.tcx).to_ty(self.infcx.tcx).is_unsafe_ptr() { + return BorrowedContentSource::DerefRawPointer; + } + } + + BorrowedContentSource::Other + } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/mutability_errors.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/mutability_errors.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/mutability_errors.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/mutability_errors.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,12 +16,14 @@ use rustc::ty::{self, Const, DefIdTree, TyS, TyKind, TyCtxt}; use rustc_data_structures::indexed_vec::Idx; use syntax_pos::Span; +use syntax_pos::symbol::keywords; use dataflow::move_paths::InitLocation; use borrow_check::MirBorrowckCtxt; use util::borrowck_errors::{BorrowckErrors, Origin}; use util::collect_writes::FindAssignments; use util::suggest_ref_mut; +use rustc_errors::Applicability; #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub(super) enum AccessKind { @@ -70,11 +72,11 @@ elem: ProjectionElem::Field(upvar_index, _), }) => { debug_assert!(is_closure_or_generator( - base.ty(self.mir, self.tcx).to_ty(self.tcx) + base.ty(self.mir, self.infcx.tcx).to_ty(self.infcx.tcx) )); item_msg = format!("`{}`", access_place_desc.unwrap()); - if access_place.is_upvar_field_projection(self.mir, &self.tcx).is_some() { + if access_place.is_upvar_field_projection(self.mir, &self.infcx.tcx).is_some() { reason = ", as it is not declared as mutable".to_string(); } else { let name = self.mir.upvar_decls[upvar_index.index()].debug_name; @@ -90,11 +92,11 @@ item_msg = format!("`{}`", access_place_desc.unwrap()); debug_assert!(self.mir.local_decls[Local::new(1)].ty.is_region_ptr()); debug_assert!(is_closure_or_generator( - the_place_err.ty(self.mir, self.tcx).to_ty(self.tcx) + the_place_err.ty(self.mir, self.infcx.tcx).to_ty(self.infcx.tcx) )); reason = if access_place.is_upvar_field_projection(self.mir, - &self.tcx).is_some() { + &self.infcx.tcx).is_some() { ", as it is a captured variable in a `Fn` closure".to_string() } else { ", as `Fn` closures cannot mutate their captured variables".to_string() @@ -115,7 +117,7 @@ reason = ", as it is immutable for the pattern guard".to_string(); } else { let pointer_type = - if base.ty(self.mir, self.tcx).to_ty(self.tcx).is_region_ptr() { + if base.ty(self.mir, self.infcx.tcx).to_ty(self.infcx.tcx).is_region_ptr() { "`&` reference" } else { "`*const` pointer" @@ -144,7 +146,7 @@ reason = String::new(); } else { item_msg = format!("`{}`", access_place_desc.unwrap()); - let static_name = &self.tcx.item_name(*def_id); + let static_name = &self.infcx.tcx.item_name(*def_id); reason = format!(", as `{}` is an immutable static item", static_name); } } @@ -176,14 +178,14 @@ let span = match error_access { AccessKind::Move => { - err = self.tcx + err = self.infcx.tcx .cannot_move_out_of(span, &(item_msg + &reason), Origin::Mir); act = "move"; acted_on = "moved"; span } AccessKind::Mutate => { - err = self.tcx + err = self.infcx.tcx .cannot_assign(span, &(item_msg + &reason), Origin::Mir); act = "assign"; acted_on = "written"; @@ -195,7 +197,7 @@ let borrow_spans = self.borrow_spans(span, location); let borrow_span = borrow_spans.args_or_use(); - err = self.tcx.cannot_borrow_path_as_mutable_because( + err = self.infcx.tcx.cannot_borrow_path_as_mutable_because( borrow_span, &item_msg, &reason, @@ -206,7 +208,7 @@ format!( "mutable borrow occurs due to use of `{}` in closure", // always Some() if the message is printed. - self.describe_place(access_place).unwrap_or(String::new()), + self.describe_place(access_place).unwrap_or_default(), ) ); borrow_span @@ -216,6 +218,72 @@ debug!("report_mutability_error: act={:?}, acted_on={:?}", act, acted_on); match the_place_err { + // Suggest making an existing shared borrow in a struct definition a mutable borrow. + // + // This is applicable when we have a deref of a field access to a deref of a local - + // something like `*((*_1).0`. The local that we get will be a reference to the + // struct we've got a field access of (it must be a reference since there's a deref + // after the field access). + Place::Projection(box Projection { + base: Place::Projection(box Projection { + base: Place::Projection(box Projection { + base, + elem: ProjectionElem::Deref, + }), + elem: ProjectionElem::Field(field, _), + }), + elem: ProjectionElem::Deref, + }) => { + err.span_label(span, format!("cannot {ACT}", ACT = act)); + + if let Some((span, message)) = annotate_struct_field( + self.infcx.tcx, + base.ty(self.mir, self.infcx.tcx).to_ty(self.infcx.tcx), + field, + ) { + err.span_suggestion_with_applicability( + span, + "consider changing this to be mutable", + message, + Applicability::MaybeIncorrect, + ); + } + }, + + // Suggest removing a `&mut` from the use of a mutable reference. + Place::Local(local) + if { + self.mir.local_decls.get(*local).map(|local_decl| { + if let ClearCrossCrate::Set( + mir::BindingForm::ImplicitSelf(kind) + ) = local_decl.is_user_variable.as_ref().unwrap() { + // Check if the user variable is a `&mut self` and we can therefore + // suggest removing the `&mut`. + // + // Deliberately fall into this case for all implicit self types, + // so that we don't fall in to the next case with them. + *kind == mir::ImplicitSelfKind::MutRef + } else if Some(keywords::SelfValue.name()) == local_decl.name { + // Otherwise, check if the name is the self kewyord - in which case + // we have an explicit self. Do the same thing in this case and check + // for a `self: &mut Self` to suggest removing the `&mut`. + if let ty::TyKind::Ref( + _, _, hir::Mutability::MutMutable + ) = local_decl.ty.sty { + true + } else { + false + } + } else { + false + } + }).unwrap_or(false) + } => + { + err.span_label(span, format!("cannot {ACT}", ACT = act)); + err.span_label(span, "try removing `&mut` here"); + }, + // We want to suggest users use `let mut` for local (user // variable) mutations... Place::Local(local) if self.mir.local_decls[*local].can_be_made_mutable() => { @@ -227,10 +295,11 @@ assert_eq!(local_decl.mutability, Mutability::Not); err.span_label(span, format!("cannot {ACT}", ACT = act)); - err.span_suggestion( + err.span_suggestion_with_applicability( local_decl.source_info.span, "consider changing this to be mutable", format!("mut {}", local_decl.name.unwrap()), + Applicability::MachineApplicable, ); } @@ -240,7 +309,7 @@ elem: ProjectionElem::Field(upvar_index, _), }) => { debug_assert!(is_closure_or_generator( - base.ty(self.mir, self.tcx).to_ty(self.tcx) + base.ty(self.mir, self.infcx.tcx).to_ty(self.infcx.tcx) )); err.span_label(span, format!("cannot {ACT}", ACT = act)); @@ -248,8 +317,8 @@ let upvar_hir_id = self.mir.upvar_decls[upvar_index.index()] .var_hir_id .assert_crate_local(); - let upvar_node_id = self.tcx.hir.hir_to_node_id(upvar_hir_id); - if let Some(Node::Binding(pat)) = self.tcx.hir.find(upvar_node_id) { + let upvar_node_id = self.infcx.tcx.hir.hir_to_node_id(upvar_hir_id); + if let Some(Node::Binding(pat)) = self.infcx.tcx.hir.find(upvar_node_id) { if let hir::PatKind::Binding( hir::BindingAnnotation::Unannotated, _, @@ -257,10 +326,11 @@ _, ) = pat.node { - err.span_suggestion( + err.span_suggestion_with_applicability( upvar_ident.span, "consider changing this to be mutable", format!("mut {}", upvar_ident.name), + Applicability::MachineApplicable, ); } } @@ -271,7 +341,7 @@ // a local variable, then just suggest the user remove it. Place::Local(_) if { - if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) { + if let Ok(snippet) = self.infcx.tcx.sess.source_map().span_to_snippet(span) { snippet.starts_with("&mut ") } else { false @@ -313,8 +383,8 @@ { let local_decl = &self.mir.local_decls[*local]; let suggestion = match local_decl.is_user_variable.as_ref().unwrap() { - ClearCrossCrate::Set(mir::BindingForm::ImplicitSelf) => { - Some(suggest_ampmut_self(self.tcx, local_decl)) + ClearCrossCrate::Set(mir::BindingForm::ImplicitSelf(_)) => { + Some(suggest_ampmut_self(self.infcx.tcx, local_decl)) } ClearCrossCrate::Set(mir::BindingForm::Var(mir::VarBindingForm { @@ -322,7 +392,7 @@ opt_ty_info, .. })) => Some(suggest_ampmut( - self.tcx, + self.infcx.tcx, self.mir, *local, local_decl, @@ -334,11 +404,10 @@ .. })) => { let pattern_span = local_decl.source_info.span; - suggest_ref_mut(self.tcx, pattern_span) + suggest_ref_mut(self.infcx.tcx, pattern_span) .map(|replacement| (pattern_span, replacement)) } - // ClearCrossCrate::Set(mir::BindingForm::RefForGuard) => unreachable!(), ClearCrossCrate::Clear => bug!("saw cleared local state"), @@ -351,10 +420,11 @@ }; if let Some((err_help_span, suggested_code)) = suggestion { - err.span_suggestion( + err.span_suggestion_with_applicability( err_help_span, &format!("consider changing this to be a mutable {}", pointer_desc), suggested_code, + Applicability::MachineApplicable, ); } @@ -422,11 +492,11 @@ .. } ) = &self.mir.basic_blocks()[location.block].terminator { - if self.tcx.parent(id) == self.tcx.lang_items().index_trait() { - + let index_trait = self.infcx.tcx.lang_items().index_trait(); + if self.infcx.tcx.parent(id) == index_trait { let mut found = false; - self.tcx.for_each_relevant_impl( - self.tcx.lang_items().index_mut_trait().unwrap(), + self.infcx.tcx.for_each_relevant_impl( + self.infcx.tcx.lang_items().index_mut_trait().unwrap(), substs.type_at(0), |_relevant_impl| { found = true; @@ -434,7 +504,7 @@ ); let extra = if found { - String::from("") + String::new() } else { format!(", but it is not implemented for `{}`", substs.type_at(0)) @@ -502,7 +572,7 @@ opt_ty_info: Option, ) -> (Span, String) { let locations = mir.find_assignments(local); - if locations.len() > 0 { + if !locations.is_empty() { let assignment_rhs_span = mir.source_info(locations[0]).span; if let Ok(src) = tcx.sess.source_map().span_to_snippet(assignment_rhs_span) { if let (true, Some(ws_pos)) = ( @@ -513,7 +583,7 @@ let ty = &src[ws_pos..]; return (assignment_rhs_span, format!("&{} mut {}", lt_name, ty)); } else if src.starts_with('&') { - let borrowed_expr = src[1..].to_string(); + let borrowed_expr = &src[1..]; return (assignment_rhs_span, format!("&mut {}", borrowed_expr)); } } @@ -553,3 +623,54 @@ fn is_closure_or_generator(ty: ty::Ty) -> bool { ty.is_closure() || ty.is_generator() } + +/// Add a suggestion to a struct definition given a field access to a local. +/// This function expects the local to be a reference to a struct in order to produce a suggestion. +/// +/// ```text +/// LL | s: &'a String +/// | ---------- use `&'a mut String` here to make mutable +/// ``` +fn annotate_struct_field( + tcx: TyCtxt<'cx, 'gcx, 'tcx>, + ty: ty::Ty<'tcx>, + field: &mir::Field, +) -> Option<(Span, String)> { + // Expect our local to be a reference to a struct of some kind. + if let ty::TyKind::Ref(_, ty, _) = ty.sty { + if let ty::TyKind::Adt(def, _) = ty.sty { + let field = def.all_fields().nth(field.index())?; + // Use the HIR types to construct the diagnostic message. + let node_id = tcx.hir.as_local_node_id(field.did)?; + let node = tcx.hir.find(node_id)?; + // Now we're dealing with the actual struct that we're going to suggest a change to, + // we can expect a field that is an immutable reference to a type. + if let hir::Node::Field(field) = node { + if let hir::TyKind::Rptr(lifetime, hir::MutTy { + mutbl: hir::Mutability::MutImmutable, + ref ty + }) = field.ty.node { + // Get the snippets in two parts - the named lifetime (if there is one) and + // type being referenced, that way we can reconstruct the snippet without loss + // of detail. + let type_snippet = tcx.sess.source_map().span_to_snippet(ty.span).ok()?; + let lifetime_snippet = if !lifetime.is_elided() { + format!("{} ", tcx.sess.source_map().span_to_snippet(lifetime.span).ok()?) + } else { + String::new() + }; + + return Some(( + field.ty.span, + format!( + "&{}mut {}", + lifetime_snippet, &*type_snippet, + ), + )); + } + } + } + } + + None +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/constraint_generation.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/constraint_generation.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/constraint_generation.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/constraint_generation.rs 2018-12-04 23:41:40.000000000 +0000 @@ -18,9 +18,10 @@ use rustc::mir::visit::Visitor; use rustc::mir::{BasicBlock, BasicBlockData, Location, Mir, Place, Rvalue}; use rustc::mir::{Statement, Terminator}; +use rustc::mir::UserTypeProjection; use rustc::ty::fold::TypeFoldable; use rustc::ty::subst::Substs; -use rustc::ty::{self, CanonicalTy, ClosureSubsts, GeneratorSubsts, RegionVid}; +use rustc::ty::{self, ClosureSubsts, GeneratorSubsts, RegionVid}; pub(super) fn generate_constraints<'cx, 'gcx, 'tcx>( infcx: &InferCtxt<'cx, 'gcx, 'tcx>, @@ -140,6 +141,7 @@ if let Some(all_facts) = self.all_facts { if let Place::Local(temp) = place { if let Some(borrow_indices) = self.borrow_set.local_map.get(temp) { + all_facts.killed.reserve(borrow_indices.len()); for &borrow_index in borrow_indices { let location_index = self.location_table.mid_index(location); all_facts.killed.push((borrow_index, location_index)); @@ -163,7 +165,9 @@ self.location_table.mid_index(location), )); - for successor_block in terminator.successors() { + let successor_blocks = terminator.successors(); + all_facts.cfg_edge.reserve(successor_blocks.size_hint().0); + for successor_block in successor_blocks { all_facts.cfg_edge.push(( self.location_table.mid_index(location), self.location_table @@ -179,7 +183,7 @@ &mut self, _place: &Place<'tcx>, _variance: &ty::Variance, - _c_ty: &CanonicalTy<'tcx>, + _user_ty: &UserTypeProjection<'tcx>, _location: Location, ) { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/constraints/graph.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/constraints/graph.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/constraints/graph.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/constraints/graph.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,10 +9,13 @@ // except according to those terms. use borrow_check::nll::type_check::Locations; -use borrow_check::nll::constraints::{ConstraintIndex, ConstraintSet, OutlivesConstraint}; +use borrow_check::nll::constraints::ConstraintIndex; +use borrow_check::nll::constraints::{ConstraintSet, OutlivesConstraint}; +use rustc::mir::ConstraintCategory; use rustc::ty::RegionVid; use rustc_data_structures::graph; use rustc_data_structures::indexed_vec::IndexVec; +use syntax_pos::DUMMY_SP; /// The construct graph organizes the constraints by their end-points. /// It can be used to view a `R1: R2` constraint as either an edge `R1 @@ -174,7 +177,8 @@ Some(OutlivesConstraint { sup: self.static_region, sub: next_static_idx.into(), - locations: Locations::All, + locations: Locations::All(DUMMY_SP), + category: ConstraintCategory::Internal, }) } else { None diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/constraints/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/constraints/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/constraints/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/constraints/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use rustc::mir::ConstraintCategory; use rustc::ty::RegionVid; use rustc_data_structures::graph::scc::Sccs; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; @@ -87,6 +88,9 @@ /// Where did this constraint arise? pub locations: Locations, + + /// What caused this constraint? + pub category: ConstraintCategory, } impl fmt::Debug for OutlivesConstraint { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs 2018-12-04 23:41:40.000000000 +0000 @@ -48,7 +48,7 @@ impl<'cx, 'gcx, 'tcx> UseFinder<'cx, 'gcx, 'tcx> { fn find(&mut self) -> Option { let mut queue = VecDeque::new(); - let mut visited = FxHashSet(); + let mut visited = FxHashSet::default(); queue.push_back(self.start_point); while let Some(p) = queue.pop_front() { @@ -121,9 +121,7 @@ enum DefUseResult { Def, - UseLive { local: Local }, - UseDrop { local: Local }, } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,32 +9,176 @@ // except according to those terms. use borrow_check::borrow_set::BorrowData; -use borrow_check::nll::region_infer::Cause; +use borrow_check::error_reporting::UseSpans; +use borrow_check::nll::ConstraintDescription; +use borrow_check::nll::region_infer::{Cause, RegionName}; use borrow_check::{Context, MirBorrowckCtxt, WriteKind}; -use rustc::mir::{Local, Location, Place, TerminatorKind}; +use rustc::ty::{self, TyCtxt}; +use rustc::mir::{ + CastKind, ConstraintCategory, FakeReadCause, Local, Location, Mir, Operand, + Place, Projection, ProjectionElem, Rvalue, Statement, StatementKind, + TerminatorKind +}; use rustc_errors::DiagnosticBuilder; -use rustc::ty::Region; +use syntax_pos::Span; mod find_use; -#[derive(Copy, Clone, Debug)] -pub enum BorrowContainsPointReason<'tcx> { - Liveness { - local: Local, - location: Location, - in_loop: bool, +pub(in borrow_check) enum BorrowExplanation { + UsedLater(LaterUseKind, Span), + UsedLaterInLoop(LaterUseKind, Span), + UsedLaterWhenDropped { + drop_loc: Location, + dropped_local: Local, + should_note_order: bool, }, - DropLiveness { - local: Local, - location: Location, - }, - OutlivesFreeRegion { - outlived_region: Option>, + MustBeValidFor { + category: ConstraintCategory, + from_closure: bool, + span: Span, + region_name: RegionName, + opt_place_desc: Option, }, + Unexplained, +} + +#[derive(Clone, Copy)] +pub(in borrow_check) enum LaterUseKind { + TraitCapture, + ClosureCapture, + Call, + FakeLetRead, + Other, +} + +impl BorrowExplanation { + pub(in borrow_check) fn add_explanation_to_diagnostic<'cx, 'gcx, 'tcx>( + &self, + tcx: TyCtxt<'cx, 'gcx, 'tcx>, + mir: &Mir<'tcx>, + err: &mut DiagnosticBuilder<'_>, + borrow_desc: &str, + ) { + match *self { + BorrowExplanation::UsedLater(later_use_kind, var_or_use_span) => { + let message = match later_use_kind { + LaterUseKind::TraitCapture => "borrow later captured here by trait object", + LaterUseKind::ClosureCapture => "borrow later captured here by closure", + LaterUseKind::Call => "borrow later used by call", + LaterUseKind::FakeLetRead => "borrow later stored here", + LaterUseKind::Other => "borrow later used here", + }; + err.span_label(var_or_use_span, format!("{}{}", borrow_desc, message)); + }, + BorrowExplanation::UsedLaterInLoop(later_use_kind, var_or_use_span) => { + let message = match later_use_kind { + LaterUseKind::TraitCapture => + "borrow captured here by trait object, in later iteration of loop", + LaterUseKind::ClosureCapture => + "borrow captured here by closure, in later iteration of loop", + LaterUseKind::Call => "borrow used by call, in later iteration of loop", + LaterUseKind::FakeLetRead => "borrow later stored here", + LaterUseKind::Other => "borrow used here, in later iteration of loop", + }; + err.span_label(var_or_use_span, format!("{}{}", borrow_desc, message)); + }, + BorrowExplanation::UsedLaterWhenDropped { drop_loc, dropped_local, + should_note_order } => + { + let local_decl = &mir.local_decls[dropped_local]; + let (dtor_desc, type_desc) = match local_decl.ty.sty { + // If type is an ADT that implements Drop, then + // simplify output by reporting just the ADT name. + ty::Adt(adt, _substs) if adt.has_dtor(tcx) && !adt.is_box() => + ("`Drop` code", format!("type `{}`", tcx.item_path_str(adt.did))), + + // Otherwise, just report the whole type (and use + // the intentionally fuzzy phrase "destructor") + ty::Closure(..) => + ("destructor", "closure".to_owned()), + ty::Generator(..) => + ("destructor", "generator".to_owned()), + + _ => ("destructor", format!("type `{}`", local_decl.ty)), + }; + + match local_decl.name { + Some(local_name) => { + let message = + format!("{B}borrow might be used here, when `{LOC}` is dropped \ + and runs the {DTOR} for {TYPE}", + B=borrow_desc, LOC=local_name, TYPE=type_desc, DTOR=dtor_desc); + err.span_label(mir.source_info(drop_loc).span, message); + + if should_note_order { + err.note( + "values in a scope are dropped \ + in the opposite order they are defined", + ); + } + } + None => { + err.span_label(local_decl.source_info.span, + format!("a temporary with access to the {B}borrow \ + is created here ...", + B=borrow_desc)); + let message = + format!("... and the {B}borrow might be used here, \ + when that temporary is dropped \ + and runs the {DTOR} for {TYPE}", + B=borrow_desc, TYPE=type_desc, DTOR=dtor_desc); + err.span_label(mir.source_info(drop_loc).span, message); + + if let Some(info) = &local_decl.is_block_tail { + // FIXME: use span_suggestion instead, highlighting the + // whole block tail expression. + let msg = if info.tail_result_is_ignored { + "The temporary is part of an expression at the end of a block. \ + Consider adding semicolon after the expression so its temporaries \ + are dropped sooner, before the local variables declared by the \ + block are dropped." + } else { + "The temporary is part of an expression at the end of a block. \ + Consider forcing this temporary to be dropped sooner, before \ + the block's local variables are dropped. \ + For example, you could save the expression's value in a new \ + local variable `x` and then make `x` be the expression \ + at the end of the block." + }; + + err.note(msg); + } + } + } + }, + BorrowExplanation::MustBeValidFor { + category, + span, + ref region_name, + ref opt_place_desc, + from_closure: _, + } => { + region_name.highlight_region_name(err); + + if let Some(desc) = opt_place_desc { + err.span_label(span, format!( + "{}requires that `{}` is borrowed for `{}`", + category.description(), desc, region_name, + )); + } else { + err.span_label(span, format!( + "{}requires that {}borrow lasts for `{}`", + category.description(), borrow_desc, region_name, + )); + }; + }, + _ => {}, + } + } } impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { - /// Adds annotations to `err` explaining *why* the borrow contains the + /// Returns structured explanation for *why* the borrow contains the /// point from `context`. This is key for the "3-point errors" /// [described in the NLL RFC][d]. /// @@ -45,7 +189,6 @@ /// - `kind_place`: if Some, this describes the statement that triggered the error. /// - first half is the kind of write, if any, being performed /// - second half is the place being accessed - /// - `err`: where the error annotations are going to be added /// /// [d]: https://rust-lang.github.io/rfcs/2094-nll.html#leveraging-intuition-framing-errors-in-terms-of-points pub(in borrow_check) fn explain_why_borrow_contains_point( @@ -53,134 +196,92 @@ context: Context, borrow: &BorrowData<'tcx>, kind_place: Option<(WriteKind, &Place<'tcx>)>, - err: &mut DiagnosticBuilder<'_>, - ) { - let reason = self.find_why_borrow_contains_point(context, borrow); - self.report_why_borrow_contains_point(err, reason, kind_place); - } - - /// Finds the reason that [explain_why_borrow_contains_point] will report - /// but doesn't add it to any message. This is a separate function in case - /// the caller wants to change the error they report based on the reason - /// that will be reported. - pub(in borrow_check) fn find_why_borrow_contains_point( - &self, - context: Context, - borrow: &BorrowData<'tcx> - ) -> BorrowContainsPointReason<'tcx> { - use self::BorrowContainsPointReason::*; - + ) -> BorrowExplanation { debug!( - "find_why_borrow_contains_point(context={:?}, borrow={:?})", - context, borrow, + "explain_why_borrow_contains_point(context={:?}, borrow={:?}, kind_place={:?})", + context, borrow, kind_place ); let regioncx = &self.nonlexical_regioncx; let mir = self.mir; - let tcx = self.tcx; + let tcx = self.infcx.tcx; let borrow_region_vid = regioncx.to_region_vid(borrow.region); - debug!( "explain_why_borrow_contains_point: borrow_region_vid={:?}", borrow_region_vid ); let region_sub = regioncx.find_sub_region_live_at(borrow_region_vid, context.loc); - debug!( "explain_why_borrow_contains_point: region_sub={:?}", region_sub ); - match find_use::find(mir, regioncx, tcx, region_sub, context.loc) { - Some(Cause::LiveVar(local, location)) => Liveness { - local, - location, - in_loop: self.is_borrow_location_in_loop(context.loc), - }, - Some(Cause::DropVar(local, location)) => DropLiveness { - local, - location, - }, - None => OutlivesFreeRegion { - outlived_region: regioncx.to_error_region(region_sub), - }, - } - } - - /// Adds annotations to `err` for the explanation `reason`. This is a - /// separate method so that the caller can change their error message based - /// on the reason that is going to be reported. - pub (in borrow_check) fn report_why_borrow_contains_point( - &self, - err: &mut DiagnosticBuilder, - reason: BorrowContainsPointReason<'tcx>, - kind_place: Option<(WriteKind, &Place<'tcx>)>, - ) { - use self::BorrowContainsPointReason::*; - - debug!( - "find_why_borrow_contains_point(reason={:?}, kind_place={:?})", - reason, kind_place, - ); - - let mir = self.mir; - - match reason { - Liveness { local, location, in_loop } => { + match find_use::find(mir, regioncx, tcx, region_sub, context.loc) { + Some(Cause::LiveVar(local, location)) => { let span = mir.source_info(location).span; let spans = self.move_spans(&Place::Local(local), location) .or_else(|| self.borrow_spans(span, location)); - let message = if in_loop { - if spans.for_closure() { - "borrow captured here by closure in later iteration of loop" - } else { - "borrow used here in later iteration of loop" - } + + if self.is_borrow_location_in_loop(context.loc) { + let later_use = self.later_use_kind(borrow, spans, location); + BorrowExplanation::UsedLaterInLoop(later_use.0, later_use.1) } else { - if spans.for_closure() { - "borrow later captured here by closure" - } else { - "borrow later used here" - } - }; - err.span_label(spans.var_or_use(), message); + // Check if the location represents a `FakeRead`, and adapt the error + // message to the `FakeReadCause` it is from: in particular, + // the ones inserted in optimized `let var = ` patterns. + let later_use = self.later_use_kind(borrow, spans, location); + BorrowExplanation::UsedLater(later_use.0, later_use.1) + } } - DropLiveness { local, location } => match &mir.local_decls[local].name { - Some(local_name) => { - err.span_label( - mir.source_info(location).span, - format!("borrow later used here, when `{}` is dropped", local_name), - ); - if let Some((WriteKind::StorageDeadOrDrop, place)) = kind_place { - if let Place::Local(borrowed_local) = place { - let dropped_local_scope = mir.local_decls[local].visibility_scope; - let borrowed_local_scope = - mir.local_decls[*borrowed_local].visibility_scope; + Some(Cause::DropVar(local, location)) => { + let mut should_note_order = false; + if mir.local_decls[local].name.is_some() { + if let Some((WriteKind::StorageDeadOrDrop, place)) = kind_place { + if let Place::Local(borrowed_local) = place { + let dropped_local_scope = mir.local_decls[local].visibility_scope; + let borrowed_local_scope = + mir.local_decls[*borrowed_local].visibility_scope; + + if mir.is_sub_scope(borrowed_local_scope, dropped_local_scope) + && local != *borrowed_local + { + should_note_order = true; + } + } + } + } + + BorrowExplanation::UsedLaterWhenDropped { + drop_loc: location, + dropped_local: local, + should_note_order, + } + } - if mir.is_sub_scope(borrowed_local_scope, dropped_local_scope) { - err.note( - "values in a scope are dropped \ - in the opposite order they are defined", - ); - } - } - } + None => if let Some(region) = regioncx.to_error_region_vid(borrow_region_vid) { + let (category, from_closure, span, region_name) = self + .nonlexical_regioncx + .free_region_constraint_info( + self.mir, + self.mir_def_id, + self.infcx, + borrow_region_vid, + region, + ); + let opt_place_desc = self.describe_place(&borrow.borrowed_place); + BorrowExplanation::MustBeValidFor { + category, + from_closure, + span, + region_name, + opt_place_desc, } - - None => {} - } - OutlivesFreeRegion { outlived_region: Some(region) } => { - self.tcx.note_and_explain_free_region( - err, - "borrowed value must be valid for ", - region, - "...", - ); + } else { + BorrowExplanation::Unexplained } - OutlivesFreeRegion { outlived_region: None } => (), } } @@ -214,9 +315,8 @@ pending_locations.push(target.start_location()); }, TerminatorKind::SwitchInt { ref targets, .. } => { - for target in targets { - pending_locations.push(target.start_location()); - } + pending_locations.extend( + targets.into_iter().map(|target| target.start_location())); }, TerminatorKind::Drop { target, unwind, .. } | TerminatorKind::DropAndReplace { target, unwind, .. } | @@ -238,9 +338,8 @@ }, TerminatorKind::FalseEdges { real_target, ref imaginary_targets, .. } => { pending_locations.push(real_target.start_location()); - for target in imaginary_targets { - pending_locations.push(target.start_location()); - } + pending_locations.extend( + imaginary_targets.into_iter().map(|target| target.start_location())); }, _ => {}, } @@ -255,5 +354,182 @@ false } -} + /// Determine how the borrow was later used. + fn later_use_kind( + &self, + borrow: &BorrowData<'tcx>, + use_spans: UseSpans, + location: Location + ) -> (LaterUseKind, Span) { + match use_spans { + UseSpans::ClosureUse { var_span, .. } => { + // Used in a closure. + (LaterUseKind::ClosureCapture, var_span) + }, + UseSpans::OtherUse(span) => { + let block = &self.mir.basic_blocks()[location.block]; + + let kind = if let Some(&Statement { + kind: StatementKind::FakeRead(FakeReadCause::ForLet, _), + .. + }) = block.statements.get(location.statement_index) { + LaterUseKind::FakeLetRead + } else if self.was_captured_by_trait_object(borrow) { + LaterUseKind::TraitCapture + } else if location.statement_index == block.statements.len() { + if let TerminatorKind::Call { + ref func, from_hir_call: true, .. + } = block.terminator().kind { + // Just point to the function, to reduce the chance of overlapping spans. + let function_span = match func { + Operand::Constant(c) => c.span, + Operand::Copy(Place::Local(l)) | Operand::Move(Place::Local(l)) => { + let local_decl = &self.mir.local_decls[*l]; + if local_decl.name.is_none() { + local_decl.source_info.span + } else { + span + } + }, + _ => span, + }; + return (LaterUseKind::Call, function_span); + } else { + LaterUseKind::Other + } + } else { + LaterUseKind::Other + }; + + (kind, span) + } + } + } + + /// Check if a borrowed value was captured by a trait object. We do this by + /// looking forward in the MIR from the reserve location and checking if we see + /// a unsized cast to a trait object on our data. + fn was_captured_by_trait_object(&self, borrow: &BorrowData<'tcx>) -> bool { + // Start at the reserve location, find the place that we want to see cast to a trait object. + let location = borrow.reserve_location; + let block = &self.mir[location.block]; + let stmt = block.statements.get(location.statement_index); + debug!("was_captured_by_trait_object: location={:?} stmt={:?}", location, stmt); + + // We make a `queue` vector that has the locations we want to visit. As of writing, this + // will only ever have one item at any given time, but by using a vector, we can pop from + // it which simplifies the termination logic. + let mut queue = vec![location]; + let mut target = if let Some(&Statement { + kind: StatementKind::Assign(Place::Local(local), _), + .. + }) = stmt { + local + } else { + return false; + }; + + debug!("was_captured_by_trait: target={:?} queue={:?}", target, queue); + while let Some(current_location) = queue.pop() { + debug!("was_captured_by_trait: target={:?}", target); + let block = &self.mir[current_location.block]; + // We need to check the current location to find out if it is a terminator. + let is_terminator = current_location.statement_index == block.statements.len(); + if !is_terminator { + let stmt = &block.statements[current_location.statement_index]; + debug!("was_captured_by_trait_object: stmt={:?}", stmt); + + // The only kind of statement that we care about is assignments... + if let StatementKind::Assign( + place, + box rvalue, + ) = &stmt.kind { + let into = match place { + Place::Local(into) => into, + Place::Projection(box Projection { + base: Place::Local(into), + elem: ProjectionElem::Deref, + }) => into, + _ => { + // Continue at the next location. + queue.push(current_location.successor_within_block()); + continue; + }, + }; + + match rvalue { + // If we see a use, we should check whether it is our data, and if so + // update the place that we're looking for to that new place. + Rvalue::Use(operand) => match operand { + Operand::Copy(Place::Local(from)) | + Operand::Move(Place::Local(from)) if *from == target => { + target = *into; + }, + _ => {}, + }, + // If we see a unsized cast, then if it is our data we should check + // whether it is being cast to a trait object. + Rvalue::Cast(CastKind::Unsize, operand, ty) => match operand { + Operand::Copy(Place::Local(from)) | + Operand::Move(Place::Local(from)) if *from == target => { + debug!("was_captured_by_trait_object: ty={:?}", ty); + // Check the type for a trait object. + return match ty.sty { + // `&dyn Trait` + ty::TyKind::Ref(_, ty, _) if ty.is_trait() => true, + // `Box` + _ if ty.is_box() && ty.boxed_ty().is_trait() => + true, + // `dyn Trait` + _ if ty.is_trait() => true, + // Anything else. + _ => false, + }; + }, + _ => return false, + }, + _ => {}, + } + } + + // Continue at the next location. + queue.push(current_location.successor_within_block()); + } else { + // The only thing we need to do for terminators is progress to the next block. + let terminator = block.terminator(); + debug!("was_captured_by_trait_object: terminator={:?}", terminator); + + if let TerminatorKind::Call { + destination: Some((Place::Local(dest), block)), + args, + .. + } = &terminator.kind { + debug!( + "was_captured_by_trait_object: target={:?} dest={:?} args={:?}", + target, dest, args + ); + // Check if one of the arguments to this function is the target place. + let found_target = args.iter().any(|arg| { + if let Operand::Move(Place::Local(potential)) = arg { + *potential == target + } else { + false + } + }); + + // If it is, follow this to the next block and update the target. + if found_target { + target = *dest; + queue.push(block.start_location()); + } + } + } + + debug!("was_captured_by_trait: queue={:?}", queue); + } + + // We didn't find anything and ran out of locations to check. + false + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/invalidation.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/invalidation.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/invalidation.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/invalidation.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ use borrow_check::borrow_set::BorrowSet; use borrow_check::location::LocationTable; use borrow_check::{JustWrite, WriteAndRead}; -use borrow_check::{ShallowOrDeep, Deep, Shallow}; +use borrow_check::{AccessDepth, Deep, Shallow}; use borrow_check::{ReadOrWrite, Activation, Read, Reservation, Write}; use borrow_check::{Context, ContextKind}; use borrow_check::{LocalMutationIsAllowed, MutateMode}; @@ -20,61 +20,52 @@ use borrow_check::nll::facts::AllFacts; use borrow_check::path_utils::*; use dataflow::move_paths::indexes::BorrowIndex; -use rustc::hir::def_id::DefId; -use rustc::infer::InferCtxt; +use rustc::ty::TyCtxt; use rustc::mir::visit::Visitor; -use rustc::mir::{BasicBlock, Location, Mir, Place, Rvalue, Local}; +use rustc::mir::{BasicBlock, Location, Mir, Place, Rvalue}; use rustc::mir::{Statement, StatementKind}; use rustc::mir::{Terminator, TerminatorKind}; -use rustc::mir::{Field, Operand, BorrowKind}; -use rustc::ty::{self, ParamEnv}; -use rustc_data_structures::indexed_vec::Idx; +use rustc::mir::{Operand, BorrowKind}; use rustc_data_structures::graph::dominators::Dominators; pub(super) fn generate_invalidates<'cx, 'gcx, 'tcx>( - infcx: &InferCtxt<'cx, 'gcx, 'tcx>, + tcx: TyCtxt<'cx, 'gcx, 'tcx>, all_facts: &mut Option, location_table: &LocationTable, mir: &Mir<'tcx>, - mir_def_id: DefId, borrow_set: &BorrowSet<'tcx>, ) { - if !all_facts.is_some() { + if all_facts.is_none() { // Nothing to do if we don't have any facts return; } - let param_env = infcx.tcx.param_env(mir_def_id); - if let Some(all_facts) = all_facts { let dominators = mir.dominators(); let mut ig = InvalidationGenerator { all_facts, borrow_set, - infcx, + tcx, location_table, mir, dominators, - param_env, }; ig.visit_mir(mir); } } -/// 'cg = the duration of the constraint generation process itself. -struct InvalidationGenerator<'cg, 'cx: 'cg, 'tcx: 'cx, 'gcx: 'tcx> { - infcx: &'cg InferCtxt<'cx, 'gcx, 'tcx>, - all_facts: &'cg mut AllFacts, - location_table: &'cg LocationTable, - mir: &'cg Mir<'tcx>, +struct InvalidationGenerator<'cx, 'tcx: 'cx, 'gcx: 'tcx> { + tcx: TyCtxt<'cx, 'gcx, 'tcx>, + all_facts: &'cx mut AllFacts, + location_table: &'cx LocationTable, + mir: &'cx Mir<'tcx>, dominators: Dominators, - borrow_set: &'cg BorrowSet<'tcx>, - param_env: ParamEnv<'gcx>, + borrow_set: &'cx BorrowSet<'tcx>, } /// Visits the whole MIR and generates invalidates() facts /// Most of the code implementing this was stolen from borrow_check/mod.rs -impl<'cg, 'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cg, 'cx, 'tcx, 'gcx> { +impl<'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx, 'gcx> { fn visit_statement(&mut self, block: BasicBlock, statement: &Statement<'tcx>, @@ -93,9 +84,9 @@ JustWrite ); } - StatementKind::ReadForMatch(ref place) => { + StatementKind::FakeRead(_, ref place) => { self.access_place( - ContextKind::ReadForMatch.new(location), + ContextKind::FakeRead.new(location), place, (Deep, Read(ReadKind::Borrow(BorrowKind::Shared))), LocalMutationIsAllowed::No, @@ -118,7 +109,7 @@ ref inputs, } => { let context = ContextKind::InlineAsm.new(location); - for (o, output) in asm.outputs.iter().zip(outputs) { + for (o, output) in asm.outputs.iter().zip(outputs.iter()) { if o.is_indirect { // FIXME(eddyb) indirect inline asm outputs should // be encoeded through MIR place derefs instead. @@ -137,7 +128,7 @@ ); } } - for input in inputs { + for input in inputs.iter() { self.consume_operand(context, input); } } @@ -183,12 +174,12 @@ target: _, unwind: _, } => { - let tcx = self.infcx.tcx; - let gcx = tcx.global_tcx(); - let drop_place_ty = drop_place.ty(self.mir, tcx); - let drop_place_ty = tcx.erase_regions(&drop_place_ty).to_ty(tcx); - let drop_place_ty = gcx.lift(&drop_place_ty).unwrap(); - self.visit_terminator_drop(location, terminator, drop_place, drop_place_ty); + self.access_place( + ContextKind::Drop.new(location), + drop_place, + (AccessDepth::Drop, Write(WriteKind::StorageDeadOrDrop)), + LocalMutationIsAllowed::Yes, + ); } TerminatorKind::DropAndReplace { location: ref drop_place, @@ -212,6 +203,7 @@ ref args, ref destination, cleanup: _, + from_hir_call: _, } => { self.consume_operand(ContextKind::CallOperator.new(location), func); for arg in args { @@ -285,82 +277,13 @@ } } -impl<'cg, 'cx, 'tcx, 'gcx> InvalidationGenerator<'cg, 'cx, 'tcx, 'gcx> { - /// Simulates dropping of a variable - fn visit_terminator_drop( - &mut self, - loc: Location, - term: &Terminator<'tcx>, - drop_place: &Place<'tcx>, - erased_drop_place_ty: ty::Ty<'gcx>, - ) { - let gcx = self.infcx.tcx.global_tcx(); - let drop_field = | - ig: &mut InvalidationGenerator<'cg, 'cx, 'gcx, 'tcx>, - (index, field): (usize, ty::Ty<'gcx>), - | { - let field_ty = gcx.normalize_erasing_regions(ig.param_env, field); - let place = drop_place.clone().field(Field::new(index), field_ty); - - ig.visit_terminator_drop(loc, term, &place, field_ty); - }; - - match erased_drop_place_ty.sty { - // When a struct is being dropped, we need to check - // whether it has a destructor, if it does, then we can - // call it, if it does not then we need to check the - // individual fields instead. This way if `foo` has a - // destructor but `bar` does not, we will only check for - // borrows of `x.foo` and not `x.bar`. See #47703. - ty::Adt(def, substs) if def.is_struct() && !def.has_dtor(self.infcx.tcx) => { - def.all_fields() - .map(|field| field.ty(gcx, substs)) - .enumerate() - .for_each(|field| drop_field(self, field)); - } - // Same as above, but for tuples. - ty::Tuple(tys) => { - tys.iter().cloned().enumerate() - .for_each(|field| drop_field(self, field)); - } - // Closures and generators also have disjoint fields, but they are only - // directly accessed in the body of the closure/generator. - ty::Generator(def, substs, ..) - if *drop_place == Place::Local(Local::new(1)) && !self.mir.upvar_decls.is_empty() - => { - substs.upvar_tys(def, self.infcx.tcx).enumerate() - .for_each(|field| drop_field(self, field)); - } - ty::Closure(def, substs) - if *drop_place == Place::Local(Local::new(1)) && !self.mir.upvar_decls.is_empty() - => { - substs.upvar_tys(def, self.infcx.tcx).enumerate() - .for_each(|field| drop_field(self, field)); - } - _ => { - // We have now refined the type of the value being - // dropped (potentially) to just the type of a - // subfield; so check whether that field's type still - // "needs drop". If so, we assume that the destructor - // may access any data it likes (i.e., a Deep Write). - if erased_drop_place_ty.needs_drop(gcx, self.param_env) { - self.access_place( - ContextKind::Drop.new(loc), - drop_place, - (Deep, Write(WriteKind::StorageDeadOrDrop)), - LocalMutationIsAllowed::Yes, - ); - } - } - } - } - +impl<'cg, 'cx, 'tcx, 'gcx> InvalidationGenerator<'cx, 'tcx, 'gcx> { /// Simulates mutation of a place fn mutate_place( &mut self, context: Context, place: &Place<'tcx>, - kind: ShallowOrDeep, + kind: AccessDepth, _mode: MutateMode, ) { self.access_place( @@ -407,10 +330,13 @@ match *rvalue { Rvalue::Ref(_ /*rgn*/, bk, ref place) => { let access_kind = match bk { + BorrowKind::Shallow => { + (Shallow(Some(ArtificialField::ShallowBorrow)), Read(ReadKind::Borrow(bk))) + }, BorrowKind::Shared => (Deep, Read(ReadKind::Borrow(bk))), BorrowKind::Unique | BorrowKind::Mut { .. } => { let wk = WriteKind::MutableBorrow(bk); - if allow_two_phase_borrow(&self.infcx.tcx, bk) { + if allow_two_phase_borrow(&self.tcx, bk) { (Deep, Reservation(wk)) } else { (Deep, Write(wk)) @@ -469,7 +395,7 @@ &mut self, context: Context, place: &Place<'tcx>, - kind: (ShallowOrDeep, ReadOrWrite), + kind: (AccessDepth, ReadOrWrite), _is_local_mutation_allowed: LocalMutationIsAllowed, ) { let (sd, rw) = kind; @@ -481,7 +407,7 @@ &mut self, context: Context, place: &Place<'tcx>, - sd: ShallowOrDeep, + sd: AccessDepth, rw: ReadOrWrite, ) { debug!( @@ -492,7 +418,7 @@ sd, rw, ); - let tcx = self.infcx.tcx; + let tcx = self.tcx; let mir = self.mir; let borrow_set = self.borrow_set.clone(); let indices = self.borrow_set.borrows.indices(); @@ -517,15 +443,16 @@ // have already taken the reservation } - (Read(_), BorrowKind::Shared) | (Reservation(..), BorrowKind::Shared) => { - // Reads/reservations don't invalidate shared borrows + (Read(_), BorrowKind::Shallow) | (Reservation(..), BorrowKind::Shallow) + | (Read(_), BorrowKind::Shared) | (Reservation(..), BorrowKind::Shared) => { + // Reads/reservations don't invalidate shared or shallow borrows } (Read(_), BorrowKind::Unique) | (Read(_), BorrowKind::Mut { .. }) => { // Reading from mere reservations of mutable-borrows is OK. if !is_active(&this.dominators, borrow, context.loc) { // If the borrow isn't active yet, reads don't invalidate it - assert!(allow_two_phase_borrow(&this.infcx.tcx, borrow.kind)); + assert!(allow_two_phase_borrow(&this.tcx, borrow.kind)); return Control::Continue; } @@ -553,7 +480,7 @@ /// Generate a new invalidates(L, B) fact fn generate_invalidates(&mut self, b: BorrowIndex, l: Location) { - let lidx = self.location_table.mid_index(l); + let lidx = self.location_table.start_index(l); self.all_facts.invalidates.push((lidx, b)); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -107,6 +107,7 @@ // Run the MIR type-checker. let MirTypeckResults { constraints, + placeholder_indices, universal_region_relations, } = type_check::type_check( infcx, @@ -122,6 +123,8 @@ elements, ); + let placeholder_indices = Rc::new(placeholder_indices); + if let Some(all_facts) = &mut all_facts { all_facts .universal_region @@ -135,6 +138,7 @@ let MirTypeckRegionConstraints { mut liveness_constraints, outlives_constraints, + closure_bounds_mapping, type_tests, } = constraints; @@ -150,9 +154,11 @@ let mut regioncx = RegionInferenceContext::new( var_origins, universal_regions, + placeholder_indices, universal_region_relations, mir, outlives_constraints, + closure_bounds_mapping, type_tests, liveness_constraints, elements, @@ -160,11 +166,10 @@ // Generate various additional constraints. invalidation::generate_invalidates( - infcx, + infcx.tcx, &mut all_facts, location_table, &mir, - def_id, borrow_set, ); @@ -179,7 +184,7 @@ if infcx.tcx.sess.opts.debugging_opts.polonius { let algorithm = env::var("POLONIUS_ALGORITHM") - .unwrap_or(String::from("DatafrogOpt")); + .unwrap_or_else(|_| String::from("DatafrogOpt")); let algorithm = Algorithm::from_str(&algorithm).unwrap(); debug!("compute_regions: using polonius algorithm {:?}", algorithm); Some(Rc::new(Output::compute( @@ -366,3 +371,7 @@ self } } + +crate trait ConstraintDescription { + fn description(&self) -> &'static str; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/dump_mir.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/dump_mir.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/dump_mir.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/dump_mir.rs 2018-12-04 23:41:40.000000000 +0000 @@ -36,12 +36,12 @@ let outlived_by = self.universal_region_relations.regions_outlived_by(region); writeln!( out, - "| {r:rw$} | {c:cw$} | {ob}", - r = format!("{:?}", region), + "| {r:rw$?} | {c:cw$?} | {ob:?}", + r = region, rw = REGION_WIDTH, - c = format!("{:?}", classification), + c = classification, cw = 8, // "External" at most - ob = format!("{:?}", outlived_by) + ob = outlived_by )?; } } @@ -51,8 +51,8 @@ for region in self.regions() { writeln!( out, - "| {r:rw$} | {ui:4?} | {v}", - r = format!("{:?}", region), + "| {r:rw$?} | {ui:4?} | {v}", + r = region, rw = REGION_WIDTH, ui = self.region_universe(region), v = self.region_value_str(region), @@ -88,11 +88,13 @@ sup, sub, locations, + category, } = constraint; with_msg(&format!( - "{:?}: {:?} due to {:?}", + "{:?}: {:?} due to {:?} at {:?}", sup, sub, + category, locations, ))?; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,45 +8,47 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use borrow_check::nll::constraints::OutlivesConstraint; +use borrow_check::nll::ConstraintDescription; +use borrow_check::nll::constraints::{OutlivesConstraint}; use borrow_check::nll::region_infer::RegionInferenceContext; use borrow_check::nll::type_check::Locations; +use borrow_check::nll::universal_regions::DefiningTy; +use util::borrowck_errors::{BorrowckErrors, Origin}; use rustc::hir::def_id::DefId; use rustc::infer::error_reporting::nice_region_error::NiceRegionError; use rustc::infer::InferCtxt; -use rustc::mir::{self, Location, Mir, Place, Rvalue, StatementKind, TerminatorKind}; -use rustc::ty::{TyCtxt, RegionVid}; +use rustc::mir::{ConstraintCategory, Location, Mir}; +use rustc::ty::{self, RegionVid}; use rustc_data_structures::indexed_vec::IndexVec; -use rustc_errors::Diagnostic; +use rustc_errors::{Diagnostic, DiagnosticBuilder}; use std::collections::VecDeque; -use std::fmt; +use syntax::symbol::keywords; use syntax_pos::Span; +use syntax::errors::Applicability; mod region_name; mod var_name; -/// Constraints that are considered interesting can be categorized to -/// determine why they are interesting. Order of variants indicates -/// sort order of the category, thereby influencing diagnostic output. -#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -enum ConstraintCategory { - Cast, - Assignment, - Return, - CallArgument, - Other, - Boring, -} +crate use self::region_name::{RegionName, RegionNameSource}; -impl fmt::Display for ConstraintCategory { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { +impl ConstraintDescription for ConstraintCategory { + fn description(&self) -> &'static str { // Must end with a space. Allows for empty names to be provided. match self { - ConstraintCategory::Assignment => write!(f, "assignment "), - ConstraintCategory::Return => write!(f, "returning this value "), - ConstraintCategory::Cast => write!(f, "cast "), - ConstraintCategory::CallArgument => write!(f, "argument "), - _ => write!(f, ""), + ConstraintCategory::Assignment => "assignment ", + ConstraintCategory::Return => "returning this value ", + ConstraintCategory::UseAsConst => "using this value as a constant ", + ConstraintCategory::UseAsStatic => "using this value as a static ", + ConstraintCategory::Cast => "cast ", + ConstraintCategory::CallArgument => "argument ", + ConstraintCategory::TypeAnnotation => "type annotation ", + ConstraintCategory::ClosureBounds => "closure body ", + ConstraintCategory::SizedBound => "proving this value is `Sized` ", + ConstraintCategory::CopyBound => "copying this value ", + ConstraintCategory::OpaqueType => "opaque type ", + ConstraintCategory::Boring + | ConstraintCategory::BoringNoLocation + | ConstraintCategory::Internal => "", } } } @@ -68,10 +70,9 @@ fn best_blame_constraint( &self, mir: &Mir<'tcx>, - tcx: TyCtxt<'_, '_, 'tcx>, from_region: RegionVid, target_test: impl Fn(RegionVid) -> bool, - ) -> (ConstraintCategory, Span, RegionVid) { + ) -> (ConstraintCategory, bool, Span) { debug!("best_blame_constraint(from_region={:?})", from_region); // Find all paths @@ -91,9 +92,15 @@ ); // Classify each of the constraints along the path. - let mut categorized_path: Vec<(ConstraintCategory, Span)> = path + let mut categorized_path: Vec<(ConstraintCategory, bool, Span)> = path .iter() - .map(|&index| self.classify_constraint(index, mir, tcx)) + .map(|constraint| { + if constraint.category == ConstraintCategory::ClosureBounds { + self.retrieve_closure_constraint_info(mir, &constraint) + } else { + (constraint.category, false, constraint.locations.span(mir)) + } + }) .collect(); debug!( "best_blame_constraint: categorized_path={:#?}", @@ -126,18 +133,17 @@ let constraint_sup_scc = self.constraint_sccs.scc(constraint.sup); match categorized_path[i].0 { - ConstraintCategory::Boring => false, - ConstraintCategory::Other => { - // other isn't interesting when the two lifetimes - // are unified. - constraint_sup_scc != self.constraint_sccs.scc(constraint.sub) - } + ConstraintCategory::OpaqueType + | ConstraintCategory::Boring + | ConstraintCategory::BoringNoLocation + | ConstraintCategory::Internal => false, + ConstraintCategory::TypeAnnotation + | ConstraintCategory::Return => true, _ => constraint_sup_scc != target_scc, } }); if let Some(i) = best_choice { - let (category, span) = categorized_path[i]; - return (category, span, target_region); + return categorized_path[i] } // If that search fails, that is.. unusual. Maybe everything @@ -145,11 +151,9 @@ // appears to be the most interesting point to report to the // user via an even more ad-hoc guess. categorized_path.sort_by(|p0, p1| p0.0.cmp(&p1.0)); - debug!("best_blame_constraint: sorted_path={:#?}", categorized_path); - - let &(category, span) = categorized_path.first().unwrap(); + debug!("`: sorted_path={:#?}", categorized_path); - (category, span, target_region) + *categorized_path.first().unwrap() } /// Walks the graph of constraints (where `'a: 'b` is considered @@ -217,106 +221,6 @@ None } - /// This function will return true if a constraint is interesting and false if a constraint - /// is not. It is useful in filtering constraint paths to only interesting points. - fn constraint_is_interesting(&self, constraint: OutlivesConstraint) -> bool { - debug!( - "constraint_is_interesting: locations={:?} constraint={:?}", - constraint.locations, constraint - ); - - match constraint.locations { - Locations::Interesting(_) | Locations::All => true, - _ => false, - } - } - - /// This function classifies a constraint from a location. - fn classify_constraint( - &self, - constraint: OutlivesConstraint, - mir: &Mir<'tcx>, - tcx: TyCtxt<'_, '_, 'tcx>, - ) -> (ConstraintCategory, Span) { - debug!("classify_constraint: constraint={:?}", constraint); - let span = constraint.locations.span(mir); - let location = constraint - .locations - .from_location() - .unwrap_or(Location::START); - - if !self.constraint_is_interesting(constraint) { - return (ConstraintCategory::Boring, span); - } - - let data = &mir[location.block]; - debug!( - "classify_constraint: location={:?} data={:?}", - location, data - ); - let category = if location.statement_index == data.statements.len() { - if let Some(ref terminator) = data.terminator { - debug!("classify_constraint: terminator.kind={:?}", terminator.kind); - match terminator.kind { - TerminatorKind::DropAndReplace { .. } => ConstraintCategory::Assignment, - // Classify calls differently depending on whether or not - // the sub region appears in the destination type (so the - // sup region is in the return type). If the return type - // contains the sub-region, then this is either an - // assignment or a return, depending on whether we are - // writing to the RETURN_PLACE or not. - // - // The idea here is that the region is being propagated - // from an input into the output place, so it's a kind of - // assignment. Otherwise, if the sub-region only appears in - // the argument types, then use the CallArgument - // classification. - TerminatorKind::Call { destination: Some((ref place, _)), .. } => { - if tcx.any_free_region_meets( - &place.ty(mir, tcx).to_ty(tcx), - |region| self.to_region_vid(region) == constraint.sub, - ) { - match place { - Place::Local(mir::RETURN_PLACE) => ConstraintCategory::Return, - _ => ConstraintCategory::Assignment, - } - } else { - ConstraintCategory::CallArgument - } - } - TerminatorKind::Call { destination: None, .. } => { - ConstraintCategory::CallArgument - } - _ => ConstraintCategory::Other, - } - } else { - ConstraintCategory::Other - } - } else { - let statement = &data.statements[location.statement_index]; - debug!("classify_constraint: statement.kind={:?}", statement.kind); - match statement.kind { - StatementKind::Assign(ref place, ref rvalue) => { - debug!("classify_constraint: place={:?} rvalue={:?}", place, rvalue); - if *place == Place::Local(mir::RETURN_PLACE) { - ConstraintCategory::Return - } else { - match rvalue { - Rvalue::Cast(..) => ConstraintCategory::Cast, - Rvalue::Use(..) | Rvalue::Aggregate(..) => { - ConstraintCategory::Assignment - } - _ => ConstraintCategory::Other, - } - } - } - _ => ConstraintCategory::Other, - } - }; - - (category, span) - } - /// Report an error because the universal region `fr` was required to outlive /// `outlived_fr` but it is not known to do so. For example: /// @@ -336,9 +240,8 @@ ) { debug!("report_error(fr={:?}, outlived_fr={:?})", fr, outlived_fr); - let (category, span, _) = self.best_blame_constraint( + let (category, _, span) = self.best_blame_constraint( mir, - infcx.tcx, fr, |r| r == outlived_fr ); @@ -356,10 +259,13 @@ self.universal_regions.is_local_free_region(fr), self.universal_regions.is_local_free_region(outlived_fr), ); + debug!("report_error: fr_is_local={:?} outlived_fr_is_local={:?} category={:?}", fr_is_local, outlived_fr_is_local, category); - match (category, fr_is_local, outlived_fr_is_local) { + (ConstraintCategory::Return, true, false) if self.is_closure_fn_mut(infcx, fr) => + self.report_fnmut_error(mir, infcx, mir_def_id, fr, outlived_fr, span, + errors_buffer), (ConstraintCategory::Assignment, true, false) | (ConstraintCategory::CallArgument, true, false) => self.report_escaping_data_error(mir, infcx, mir_def_id, fr, outlived_fr, @@ -371,6 +277,85 @@ }; } + /// Report a specialized error when `FnMut` closures return a reference to a captured variable. + /// This function expects `fr` to be local and `outlived_fr` to not be local. + /// + /// ```text + /// error: captured variable cannot escape `FnMut` closure body + /// --> $DIR/issue-53040.rs:15:8 + /// | + /// LL | || &mut v; + /// | -- ^^^^^^ creates a reference to a captured variable which escapes the closure body + /// | | + /// | inferred to be a `FnMut` closure + /// | + /// = note: `FnMut` closures only have access to their captured variables while they are + /// executing... + /// = note: ...therefore, returned references to captured variables will escape the closure + /// ``` + fn report_fnmut_error( + &self, + mir: &Mir<'tcx>, + infcx: &InferCtxt<'_, '_, 'tcx>, + mir_def_id: DefId, + _fr: RegionVid, + outlived_fr: RegionVid, + span: Span, + errors_buffer: &mut Vec, + ) { + let mut diag = infcx.tcx.sess.struct_span_err( + span, + "captured variable cannot escape `FnMut` closure body", + ); + + // We should check if the return type of this closure is in fact a closure - in that + // case, we can special case the error further. + let return_type_is_closure = self.universal_regions.unnormalized_output_ty.is_closure(); + let message = if return_type_is_closure { + "returns a closure that contains a reference to a captured variable, which then \ + escapes the closure body" + } else { + "returns a reference to a captured variable which escapes the closure body" + }; + + diag.span_label( + span, + message, + ); + + match self.give_region_a_name(infcx, mir, mir_def_id, outlived_fr, &mut 1).source { + RegionNameSource::NamedEarlyBoundRegion(fr_span) | + RegionNameSource::NamedFreeRegion(fr_span) | + RegionNameSource::SynthesizedFreeEnvRegion(fr_span, _) | + RegionNameSource::CannotMatchHirTy(fr_span, _) | + RegionNameSource::MatchedHirTy(fr_span) | + RegionNameSource::MatchedAdtAndSegment(fr_span) | + RegionNameSource::AnonRegionFromUpvar(fr_span, _) | + RegionNameSource::AnonRegionFromOutput(fr_span, _, _) => { + diag.span_label(fr_span, "inferred to be a `FnMut` closure"); + }, + _ => {}, + } + + diag.note("`FnMut` closures only have access to their captured variables while they are \ + executing..."); + diag.note("...therefore, they cannot allow references to captured variables to escape"); + + diag.buffer(errors_buffer); + } + + /// Reports a error specifically for when data is escaping a closure. + /// + /// ```text + /// error: borrowed data escapes outside of function + /// --> $DIR/lifetime-bound-will-change-warning.rs:44:5 + /// | + /// LL | fn test2<'a>(x: &'a Box) { + /// | - `x` is a reference that is only valid in the function body + /// LL | // but ref_obj will not, so warn. + /// LL | ref_obj(x) + /// | ^^^^^^^^^^ `x` escapes the function body here + /// ``` fn report_escaping_data_error( &self, mir: &Mir<'tcx>, @@ -386,43 +371,66 @@ let outlived_fr_name_and_span = self.get_var_name_and_span_for_region(infcx.tcx, mir, outlived_fr); - let escapes_from = if infcx.tcx.is_closure(mir_def_id) { "closure" } else { "function" }; + let escapes_from = match self.universal_regions.defining_ty { + DefiningTy::Closure(..) => "closure", + DefiningTy::Generator(..) => "generator", + DefiningTy::FnDef(..) => "function", + DefiningTy::Const(..) => "const" + }; - if fr_name_and_span.is_none() && outlived_fr_name_and_span.is_none() { + // Revert to the normal error in these cases. + // Assignments aren't "escapes" in function items. + if (fr_name_and_span.is_none() && outlived_fr_name_and_span.is_none()) + || (category == ConstraintCategory::Assignment && escapes_from == "function") + || escapes_from == "const" + { return self.report_general_error(mir, infcx, mir_def_id, fr, true, outlived_fr, false, category, span, errors_buffer); } - let mut diag = infcx.tcx.sess.struct_span_err( - span, &format!("borrowed data escapes outside of {}", escapes_from), - ); + let mut diag = infcx.tcx.borrowed_data_escapes_closure(span, escapes_from, Origin::Mir); - if let Some((outlived_fr_name, outlived_fr_span)) = outlived_fr_name_and_span { - if let Some(name) = outlived_fr_name { - diag.span_label( - outlived_fr_span, - format!("`{}` is declared here, outside of the {} body", name, escapes_from), - ); - } + if let Some((Some(outlived_fr_name), outlived_fr_span)) = outlived_fr_name_and_span { + diag.span_label( + outlived_fr_span, + format!( + "`{}` is declared here, outside of the {} body", + outlived_fr_name, escapes_from + ), + ); } - if let Some((fr_name, fr_span)) = fr_name_and_span { - if let Some(name) = fr_name { - diag.span_label( - fr_span, - format!("`{}` is a reference that is only valid in the {} body", - name, escapes_from), - ); + if let Some((Some(fr_name), fr_span)) = fr_name_and_span { + diag.span_label( + fr_span, + format!( + "`{}` is a reference that is only valid in the {} body", + fr_name, escapes_from + ), + ); - diag.span_label(span, format!("`{}` escapes the {} body here", - name, escapes_from)); - } + diag.span_label(span, format!("`{}` escapes the {} body here", fr_name, escapes_from)); } diag.buffer(errors_buffer); } + /// Reports a region inference error for the general case with named/synthesized lifetimes to + /// explain what is happening. + /// + /// ```text + /// error: unsatisfied lifetime constraints + /// --> $DIR/regions-creating-enums3.rs:17:5 + /// | + /// LL | fn mk_add_bad1<'a,'b>(x: &'a ast<'a>, y: &'b ast<'b>) -> ast<'a> { + /// | -- -- lifetime `'b` defined here + /// | | + /// | lifetime `'a` defined here + /// LL | ast::add(x, y) + /// | ^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'a` but it + /// | is returning data with lifetime `'b` + /// ``` fn report_general_error( &self, mir: &Mir<'tcx>, @@ -442,10 +450,11 @@ ); let counter = &mut 1; - let fr_name = self.give_region_a_name( - infcx, mir, mir_def_id, fr, counter, &mut diag); + let fr_name = self.give_region_a_name(infcx, mir, mir_def_id, fr, counter); + fr_name.highlight_region_name(&mut diag); let outlived_fr_name = self.give_region_a_name( - infcx, mir, mir_def_id, outlived_fr, counter, &mut diag); + infcx, mir, mir_def_id, outlived_fr, counter); + outlived_fr_name.highlight_region_name(&mut diag); let mir_def_name = if infcx.tcx.is_closure(mir_def_id) { "closure" } else { "function" }; @@ -460,14 +469,128 @@ _ => { diag.span_label(span, format!( "{}requires that `{}` must outlive `{}`", - category, fr_name, outlived_fr_name, + category.description(), fr_name, outlived_fr_name, )); }, } + self.add_static_impl_trait_suggestion( + infcx, &mut diag, fr, fr_name, outlived_fr, + ); + diag.buffer(errors_buffer); } + /// Adds a suggestion to errors where a `impl Trait` is returned. + /// + /// ```text + /// help: to allow this impl Trait to capture borrowed data with lifetime `'1`, add `'_` as + /// a constraint + /// | + /// LL | fn iter_values_anon(&self) -> impl Iterator + 'a { + /// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + /// ``` + fn add_static_impl_trait_suggestion( + &self, + infcx: &InferCtxt<'_, '_, 'tcx>, + diag: &mut DiagnosticBuilder<'_>, + fr: RegionVid, + // We need to pass `fr_name` - computing it again will label it twice. + fr_name: RegionName, + outlived_fr: RegionVid, + ) { + if let ( + Some(f), + Some(ty::RegionKind::ReStatic) + ) = (self.to_error_region(fr), self.to_error_region(outlived_fr)) { + if let Some(ty::TyS { + sty: ty::TyKind::Opaque(did, substs), + .. + }) = infcx.tcx.is_suitable_region(f) + .map(|r| r.def_id) + .map(|id| infcx.tcx.return_type_impl_trait(id)) + .unwrap_or(None) + { + // Check whether or not the impl trait return type is intended to capture + // data with the static lifetime. + // + // eg. check for `impl Trait + 'static` instead of `impl Trait`. + let has_static_predicate = { + let predicates_of = infcx.tcx.predicates_of(*did); + let bounds = predicates_of.instantiate(infcx.tcx, substs); + + let mut found = false; + for predicate in bounds.predicates { + if let ty::Predicate::TypeOutlives(binder) = predicate { + if let ty::OutlivesPredicate( + _, + ty::RegionKind::ReStatic + ) = binder.skip_binder() { + found = true; + break; + } + } + } + + found + }; + + debug!("add_static_impl_trait_suggestion: has_static_predicate={:?}", + has_static_predicate); + let static_str = keywords::StaticLifetime.name(); + // If there is a static predicate, then the only sensible suggestion is to replace + // fr with `'static`. + if has_static_predicate { + diag.help( + &format!( + "consider replacing `{}` with `{}`", + fr_name, static_str, + ), + ); + } else { + // Otherwise, we should suggest adding a constraint on the return type. + let span = infcx.tcx.def_span(*did); + if let Ok(snippet) = infcx.tcx.sess.source_map().span_to_snippet(span) { + let suggestable_fr_name = if fr_name.was_named() { + fr_name.to_string() + } else { + "'_".to_string() + }; + + diag.span_suggestion_with_applicability( + span, + &format!( + "to allow this impl Trait to capture borrowed data with lifetime \ + `{}`, add `{}` as a constraint", + fr_name, suggestable_fr_name, + ), + format!("{} + {}", snippet, suggestable_fr_name), + Applicability::MachineApplicable, + ); + } + } + } + } + } + + crate fn free_region_constraint_info( + &self, + mir: &Mir<'tcx>, + mir_def_id: DefId, + infcx: &InferCtxt<'_, '_, 'tcx>, + borrow_region: RegionVid, + outlived_region: RegionVid, + ) -> (ConstraintCategory, bool, Span, RegionName) { + let (category, from_closure, span) = self.best_blame_constraint( + mir, + borrow_region, + |r| r == outlived_region + ); + let outlived_fr_name = self.give_region_a_name( + infcx, mir, mir_def_id, outlived_region, &mut 1); + (category, from_closure, span, outlived_fr_name) + } + // Finds some region R such that `fr1: R` and `R` is live at // `elem`. crate fn find_sub_region_live_at(&self, fr1: RegionVid, elem: Location) -> RegionVid { @@ -483,11 +606,46 @@ crate fn find_outlives_blame_span( &self, mir: &Mir<'tcx>, - tcx: TyCtxt<'_, '_, 'tcx>, fr1: RegionVid, fr2: RegionVid, - ) -> Span { - let (_, span, _) = self.best_blame_constraint(mir, tcx, fr1, |r| r == fr2); - span + ) -> (ConstraintCategory, Span) { + let (category, _, span) = self.best_blame_constraint(mir, fr1, |r| r == fr2); + (category, span) + } + + fn retrieve_closure_constraint_info( + &self, + mir: &Mir<'tcx>, + constraint: &OutlivesConstraint + ) -> (ConstraintCategory, bool, Span) { + let loc = match constraint.locations { + Locations::All(span) => return (constraint.category, false, span), + Locations::Single(loc) => loc, + }; + + let opt_span_category = self + .closure_bounds_mapping[&loc] + .get(&(constraint.sup, constraint.sub)); + opt_span_category + .map(|&(category, span)| (category, true, span)) + .unwrap_or((constraint.category, false, mir.source_info(loc).span)) + } + + /// Returns `true` if a closure is inferred to be an `FnMut` closure. + crate fn is_closure_fn_mut( + &self, + infcx: &InferCtxt<'_, '_, 'tcx>, + fr: RegionVid, + ) -> bool { + if let Some(ty::ReFree(free_region)) = self.to_error_region(fr) { + if let ty::BoundRegion::BrEnv = free_region.bound_region { + if let DefiningTy::Closure(def_id, substs) = self.universal_regions.defining_ty { + let closure_kind_ty = substs.closure_kind_ty(def_id, infcx.tcx); + return Some(ty::ClosureKind::FnMut) == closure_kind_ty.to_opt_closure_kind(); + } + } + } + + false } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::fmt::{self, Display}; use borrow_check::nll::region_infer::RegionInferenceContext; use borrow_check::nll::universal_regions::DefiningTy; use borrow_check::nll::ToRegionVid; @@ -17,12 +18,112 @@ use rustc::mir::Mir; use rustc::ty::subst::{Substs, UnpackedKind}; use rustc::ty::{self, RegionKind, RegionVid, Ty, TyCtxt}; -use rustc::util::ppaux::with_highlight_region; +use rustc::util::ppaux::with_highlight_region_for_regionvid; use rustc_errors::DiagnosticBuilder; use syntax::ast::{Name, DUMMY_NODE_ID}; use syntax::symbol::keywords; +use syntax_pos::Span; use syntax_pos::symbol::InternedString; +#[derive(Debug)] +crate struct RegionName { + crate name: InternedString, + crate source: RegionNameSource, +} + +#[derive(Debug)] +crate enum RegionNameSource { + NamedEarlyBoundRegion(Span), + NamedFreeRegion(Span), + Static, + SynthesizedFreeEnvRegion(Span, String), + CannotMatchHirTy(Span, String), + MatchedHirTy(Span), + MatchedAdtAndSegment(Span), + AnonRegionFromUpvar(Span, String), + AnonRegionFromOutput(Span, String, String), +} + +impl RegionName { + #[allow(dead_code)] + crate fn was_named(&self) -> bool { + match self.source { + RegionNameSource::NamedEarlyBoundRegion(..) | + RegionNameSource::NamedFreeRegion(..) | + RegionNameSource::Static => true, + RegionNameSource::SynthesizedFreeEnvRegion(..) | + RegionNameSource::CannotMatchHirTy(..) | + RegionNameSource::MatchedHirTy(..) | + RegionNameSource::MatchedAdtAndSegment(..) | + RegionNameSource::AnonRegionFromUpvar(..) | + RegionNameSource::AnonRegionFromOutput(..) => false, + } + } + + #[allow(dead_code)] + crate fn was_synthesized(&self) -> bool { + !self.was_named() + } + + #[allow(dead_code)] + crate fn name(&self) -> &InternedString { + &self.name + } + + crate fn highlight_region_name( + &self, + diag: &mut DiagnosticBuilder<'_> + ) { + match &self.source { + RegionNameSource::NamedFreeRegion(span) | + RegionNameSource::NamedEarlyBoundRegion(span) => { + diag.span_label( + *span, + format!("lifetime `{}` defined here", self), + ); + }, + RegionNameSource::SynthesizedFreeEnvRegion(span, note) => { + diag.span_label( + *span, + format!("lifetime `{}` represents this closure's body", self), + ); + diag.note(¬e); + }, + RegionNameSource::CannotMatchHirTy(span, type_name) => { + diag.span_label(*span, format!("has type `{}`", type_name)); + }, + RegionNameSource::MatchedHirTy(span) => { + diag.span_label( + *span, + format!("let's call the lifetime of this reference `{}`", self), + ); + }, + RegionNameSource::MatchedAdtAndSegment(span) => { + diag.span_label(*span, format!("let's call this `{}`", self)); + }, + RegionNameSource::AnonRegionFromUpvar(span, upvar_name) => { + diag.span_label( + *span, + format!("lifetime `{}` appears in the type of `{}`", self, upvar_name), + ); + }, + RegionNameSource::AnonRegionFromOutput(span, mir_description, type_name) => { + diag.span_label( + *span, + format!("return type{} is {}", mir_description, type_name), + ); + }, + RegionNameSource::Static => {}, + } + } +} + +impl Display for RegionName { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.name) + } +} + impl<'tcx> RegionInferenceContext<'tcx> { /// Maps from an internal MIR region vid to something that we can /// report to the user. In some cases, the region vids will map @@ -56,26 +157,25 @@ mir_def_id: DefId, fr: RegionVid, counter: &mut usize, - diag: &mut DiagnosticBuilder, - ) -> InternedString { + ) -> RegionName { debug!("give_region_a_name(fr={:?}, counter={})", fr, counter); assert!(self.universal_regions.is_universal_region(fr)); - let value = self.give_name_from_error_region(infcx.tcx, mir_def_id, fr, counter, diag) + let value = self.give_name_from_error_region(infcx.tcx, mir_def_id, fr, counter) .or_else(|| { self.give_name_if_anonymous_region_appears_in_arguments( - infcx, mir, mir_def_id, fr, counter, diag, + infcx, mir, mir_def_id, fr, counter, ) }) .or_else(|| { self.give_name_if_anonymous_region_appears_in_upvars( - infcx.tcx, mir, fr, counter, diag, + infcx.tcx, mir, fr, counter, ) }) .or_else(|| { self.give_name_if_anonymous_region_appears_in_output( - infcx, mir, mir_def_id, fr, counter, diag, + infcx, mir, mir_def_id, fr, counter, ) }) .unwrap_or_else(|| span_bug!(mir.span, "can't make a name for free region {:?}", fr)); @@ -94,28 +194,36 @@ mir_def_id: DefId, fr: RegionVid, counter: &mut usize, - diag: &mut DiagnosticBuilder<'_>, - ) -> Option { + ) -> Option { let error_region = self.to_error_region(fr)?; debug!("give_region_a_name: error_region = {:?}", error_region); match error_region { ty::ReEarlyBound(ebr) => { if ebr.has_name() { - self.highlight_named_span(tcx, error_region, &ebr.name, diag); - Some(ebr.name) + let span = self.get_named_span(tcx, error_region, &ebr.name); + Some(RegionName { + name: ebr.name, + source: RegionNameSource::NamedEarlyBoundRegion(span) + }) } else { None } } - ty::ReStatic => Some(keywords::StaticLifetime.name().as_interned_str()), + ty::ReStatic => Some(RegionName { + name: keywords::StaticLifetime.name().as_interned_str(), + source: RegionNameSource::Static + }), ty::ReFree(free_region) => match free_region.bound_region { ty::BoundRegion::BrNamed(_, name) => { - self.highlight_named_span(tcx, error_region, &name, diag); - Some(name) - } + let span = self.get_named_span(tcx, error_region, &name); + Some(RegionName { + name, + source: RegionNameSource::NamedFreeRegion(span), + }) + }, ty::BoundRegion::BrEnv => { let mir_node_id = tcx.hir.as_local_node_id(mir_def_id).expect("non-local mir"); @@ -130,10 +238,6 @@ bug!("Closure is not defined by a closure expr"); }; let region_name = self.synthesize_region_name(counter); - diag.span_label( - args_span, - format!("lifetime `{}` represents this closure's body", region_name), - ); let closure_kind_ty = substs.closure_kind_ty(def_id, tcx); let note = match closure_kind_ty.to_opt_closure_kind() { @@ -151,9 +255,13 @@ None => bug!("Closure kind not inferred in borrow check"), }; - diag.note(note); - - Some(region_name) + Some(RegionName { + name: region_name, + source: RegionNameSource::SynthesizedFreeEnvRegion( + args_span, + note.to_string() + ), + }) } else { // Can't have BrEnv in functions, constants or generators. bug!("BrEnv outside of closure."); @@ -166,7 +274,7 @@ ty::ReLateBound(..) | ty::ReScope(..) | ty::ReVar(..) - | ty::ReSkolemized(..) + | ty::RePlaceholder(..) | ty::ReEmpty | ty::ReErased | ty::ReClosureBound(..) @@ -174,7 +282,7 @@ } } - /// Highlight a named span to provide context for error messages that + /// Get a span of a named region to provide context for error messages that /// mention that span, for example: /// /// ``` @@ -188,27 +296,24 @@ /// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'b` must /// | outlive `'a` /// ``` - fn highlight_named_span( + fn get_named_span( &self, tcx: TyCtxt<'_, '_, 'tcx>, error_region: &RegionKind, name: &InternedString, - diag: &mut DiagnosticBuilder<'_>, - ) { - let cm = tcx.sess.source_map(); - + ) -> Span { let scope = error_region.free_region_binding_scope(tcx); let node = tcx.hir.as_local_node_id(scope).unwrap_or(DUMMY_NODE_ID); - let mut sp = cm.def_span(tcx.hir.span(node)); + let span = tcx.sess.source_map().def_span(tcx.hir.span(node)); if let Some(param) = tcx.hir .get_generics(scope) .and_then(|generics| generics.get_named(name)) { - sp = param.span; + param.span + } else { + span } - - diag.span_label(sp, format!("lifetime `{}` defined here", name)); } /// Find an argument that contains `fr` and label it with a fully @@ -226,8 +331,7 @@ mir_def_id: DefId, fr: RegionVid, counter: &mut usize, - diag: &mut DiagnosticBuilder<'_>, - ) -> Option { + ) -> Option { let implicit_inputs = self.universal_regions.defining_ty.implicit_inputs(); let argument_index = self.get_argument_index_for_region(infcx.tcx, fr)?; @@ -241,12 +345,11 @@ arg_ty, argument_index, counter, - diag, ) { return Some(region_name); } - self.give_name_if_we_cannot_match_hir_ty(infcx, mir, fr, arg_ty, counter, diag) + self.give_name_if_we_cannot_match_hir_ty(infcx, mir, fr, arg_ty, counter) } fn give_name_if_we_can_match_hir_ty_from_argument( @@ -258,8 +361,7 @@ argument_ty: Ty<'tcx>, argument_index: usize, counter: &mut usize, - diag: &mut DiagnosticBuilder<'_>, - ) -> Option { + ) -> Option { let mir_node_id = infcx.tcx.hir.as_local_node_id(mir_def_id)?; let fn_decl = infcx.tcx.hir.fn_decl(mir_node_id)?; let argument_hir_ty: &hir::Ty = &fn_decl.inputs[argument_index]; @@ -273,7 +375,6 @@ needle_fr, argument_ty, counter, - diag, ), _ => self.give_name_if_we_can_match_hir_ty( @@ -282,7 +383,6 @@ argument_ty, argument_hir_ty, counter, - diag, ), } } @@ -305,9 +405,8 @@ needle_fr: RegionVid, argument_ty: Ty<'tcx>, counter: &mut usize, - diag: &mut DiagnosticBuilder<'_>, - ) -> Option { - let type_name = with_highlight_region(needle_fr, *counter, || { + ) -> Option { + let type_name = with_highlight_region_for_regionvid(needle_fr, *counter, || { infcx.extract_type_name(&argument_ty) }); @@ -319,12 +418,14 @@ // Only add a label if we can confirm that a region was labelled. let argument_index = self.get_argument_index_for_region(infcx.tcx, needle_fr)?; let (_, span) = self.get_argument_name_and_span_for_region(mir, argument_index); - diag.span_label(span, format!("has type `{}`", type_name)); - // This counter value will already have been used, so this function will increment it - // so the next value will be used next and return the region name that would have been - // used. - Some(self.synthesize_region_name(counter)) + Some(RegionName { + // This counter value will already have been used, so this function will increment + // it so the next value will be used next and return the region name that would + // have been used. + name: self.synthesize_region_name(counter), + source: RegionNameSource::CannotMatchHirTy(span, type_name), + }) } else { None }; @@ -360,11 +461,9 @@ argument_ty: Ty<'tcx>, argument_hir_ty: &hir::Ty, counter: &mut usize, - diag: &mut DiagnosticBuilder<'_>, - ) -> Option { - let search_stack: &mut Vec<(Ty<'tcx>, &hir::Ty)> = &mut Vec::new(); - - search_stack.push((argument_ty, argument_hir_ty)); + ) -> Option { + let search_stack: &mut Vec<(Ty<'tcx>, &hir::Ty)> = + &mut vec![(argument_ty, argument_hir_ty)]; while let Some((ty, hir_ty)) = search_stack.pop() { match (&ty.sty, &hir_ty.node) { @@ -385,15 +484,10 @@ let source_map = tcx.sess.source_map(); let ampersand_span = source_map.start_point(hir_ty.span); - diag.span_label( - ampersand_span, - format!( - "let's call the lifetime of this reference `{}`", - region_name - ), - ); - - return Some(region_name); + return Some(RegionName { + name: region_name, + source: RegionNameSource::MatchedHirTy(ampersand_span), + }); } // Otherwise, let's descend into the referent types. @@ -405,16 +499,22 @@ ty::Adt(_adt_def, substs), hir::TyKind::Path(hir::QPath::Resolved(None, path)), ) => { - if let Some(last_segment) = path.segments.last() { - if let Some(name) = self.match_adt_and_segment( - substs, - needle_fr, - last_segment, - counter, - diag, - search_stack, - ) { - return Some(name); + match path.def { + // Type parameters of the type alias have no reason to + // be the same as those of the ADT. + // FIXME: We should be able to do something similar to + // match_adt_and_segment in this case. + hir::def::Def::TyAlias(_) => (), + _ => if let Some(last_segment) = path.segments.last() { + if let Some(name) = self.match_adt_and_segment( + substs, + needle_fr, + last_segment, + counter, + search_stack, + ) { + return Some(name); + } } } } @@ -455,20 +555,22 @@ needle_fr: RegionVid, last_segment: &'hir hir::PathSegment, counter: &mut usize, - diag: &mut DiagnosticBuilder<'_>, search_stack: &mut Vec<(Ty<'tcx>, &'hir hir::Ty)>, - ) -> Option { + ) -> Option { // Did the user give explicit arguments? (e.g., `Foo<..>`) let args = last_segment.args.as_ref()?; let lifetime = self.try_match_adt_and_generic_args(substs, needle_fr, args, search_stack)?; match lifetime.name { hir::LifetimeName::Param(_) + | hir::LifetimeName::Error | hir::LifetimeName::Static | hir::LifetimeName::Underscore => { let region_name = self.synthesize_region_name(counter); let ampersand_span = lifetime.span; - diag.span_label(ampersand_span, format!("let's call this `{}`", region_name)); - return Some(region_name); + Some(RegionName { + name: region_name, + source: RegionNameSource::MatchedAdtAndSegment(ampersand_span), + }) } hir::LifetimeName::Implicit => { @@ -483,7 +585,7 @@ // T>`. We don't consider this a match; instead we let // the "fully elaborated" type fallback above handle // it. - return None; + None } } } @@ -543,22 +645,16 @@ mir: &Mir<'tcx>, fr: RegionVid, counter: &mut usize, - diag: &mut DiagnosticBuilder<'_>, - ) -> Option { + ) -> Option { let upvar_index = self.get_upvar_index_for_region(tcx, fr)?; let (upvar_name, upvar_span) = self.get_upvar_name_and_span_for_region(tcx, mir, upvar_index); let region_name = self.synthesize_region_name(counter); - diag.span_label( - upvar_span, - format!( - "lifetime `{}` appears in the type of `{}`", - region_name, upvar_name - ), - ); - - Some(region_name) + Some(RegionName { + name: region_name, + source: RegionNameSource::AnonRegionFromUpvar(upvar_span, upvar_name.to_string()), + }) } /// Check for arguments appearing in the (closure) return type. It @@ -572,8 +668,7 @@ mir_def_id: DefId, fr: RegionVid, counter: &mut usize, - diag: &mut DiagnosticBuilder<'_>, - ) -> Option { + ) -> Option { let tcx = infcx.tcx; let return_ty = self.universal_regions.unnormalized_output_ty; @@ -588,7 +683,8 @@ return None; } - let type_name = with_highlight_region(fr, *counter, || infcx.extract_type_name(&return_ty)); + let type_name = with_highlight_region_for_regionvid( + fr, *counter, || infcx.extract_type_name(&return_ty)); let mir_node_id = tcx.hir.as_local_node_id(mir_def_id).expect("non-local mir"); @@ -609,15 +705,17 @@ (mir.span, "") }; - diag.span_label( - return_span, - format!("return type{} is {}", mir_description, type_name), - ); - - // This counter value will already have been used, so this function will increment it - // so the next value will be used next and return the region name that would have been - // used. - Some(self.synthesize_region_name(counter)) + Some(RegionName { + // This counter value will already have been used, so this function will increment it + // so the next value will be used next and return the region name that would have been + // used. + name: self.synthesize_region_name(counter), + source: RegionNameSource::AnonRegionFromOutput( + return_span, + mir_description.to_string(), + type_name + ), + }) } /// Create a synthetic region named `'1`, incrementing the diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs 2018-12-04 23:41:40.000000000 +0000 @@ -50,11 +50,12 @@ .defining_ty .upvar_tys(tcx) .position(|upvar_ty| { - debug!( - "get_upvar_index_for_region: upvar_ty = {:?}", - upvar_ty, - ); - tcx.any_free_region_meets(&upvar_ty, |r| r.to_region_vid() == fr) + debug!("get_upvar_index_for_region: upvar_ty={:?}", upvar_ty); + tcx.any_free_region_meets(&upvar_ty, |r| { + let r = r.to_region_vid(); + debug!("get_upvar_index_for_region: r={:?} fr={:?}", r, fr); + r == fr + }) })?; let upvar_ty = self diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,7 +14,7 @@ use super::*; use borrow_check::nll::constraints::OutlivesConstraint; -use dot::{self, IntoCow}; +use dot; use std::borrow::Cow; use std::io::{self, Write}; @@ -49,7 +49,7 @@ type Edge = OutlivesConstraint; fn graph_id(&'this self) -> dot::Id<'this> { - dot::Id::new("RegionInferenceContext".to_string()).unwrap() + dot::Id::new("RegionInferenceContext").unwrap() } fn node_id(&'this self, n: &RegionVid) -> dot::Id<'this> { dot::Id::new(format!("r{}", n.index())).unwrap() @@ -58,10 +58,10 @@ Some(dot::LabelText::LabelStr(Cow::Borrowed("box"))) } fn node_label(&'this self, n: &RegionVid) -> dot::LabelText<'this> { - dot::LabelText::LabelStr(format!("{:?}", n).into_cow()) + dot::LabelText::LabelStr(format!("{:?}", n).into()) } fn edge_label(&'this self, e: &OutlivesConstraint) -> dot::LabelText<'this> { - dot::LabelText::LabelStr(format!("{:?}", e.locations).into_cow()) + dot::LabelText::LabelStr(format!("{:?}", e.locations).into()) } } @@ -71,10 +71,10 @@ fn nodes(&'this self) -> dot::Nodes<'this, RegionVid> { let vids: Vec = self.regioncx.definitions.indices().collect(); - vids.into_cow() + vids.into() } fn edges(&'this self) -> dot::Edges<'this, OutlivesConstraint> { - (&self.regioncx.constraints.raw[..]).into_cow() + (&self.regioncx.constraints.raw[..]).into() } // Render `a: b` as `a -> b`, indicating the flow @@ -109,7 +109,7 @@ } fn node_label(&'this self, n: &ConstraintSccIndex) -> dot::LabelText<'this> { let nodes = &self.nodes_per_scc[*n]; - dot::LabelText::LabelStr(format!("{:?} = {:?}", n, nodes).into_cow()) + dot::LabelText::LabelStr(format!("{:?} = {:?}", n, nodes).into()) } } @@ -119,7 +119,7 @@ fn nodes(&'this self) -> dot::Nodes<'this, ConstraintSccIndex> { let vids: Vec = self.regioncx.constraint_sccs.all_sccs().collect(); - vids.into_cow() + vids.into() } fn edges(&'this self) -> dot::Edges<'this, (ConstraintSccIndex, ConstraintSccIndex)> { let edges: Vec<_> = self.regioncx @@ -134,7 +134,7 @@ }) .collect(); - edges.into_cow() + edges.into() } // Render `a: b` as `a -> b`, indicating the flow diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,31 +10,32 @@ use super::universal_regions::UniversalRegions; use borrow_check::nll::constraints::graph::NormalConstraintGraph; -use borrow_check::nll::constraints::{ - ConstraintSccIndex, ConstraintSet, OutlivesConstraint, -}; -use borrow_check::nll::region_infer::values::{RegionElement, ToElementIndex}; +use borrow_check::nll::constraints::{ConstraintSccIndex, ConstraintSet, OutlivesConstraint}; +use borrow_check::nll::region_infer::values::{PlaceholderIndices, RegionElement, ToElementIndex}; use borrow_check::nll::type_check::free_region_relations::UniversalRegionRelations; use borrow_check::nll::type_check::Locations; use rustc::hir::def_id::DefId; use rustc::infer::canonical::QueryRegionConstraint; -use rustc::infer::region_constraints::{GenericKind, VarInfos}; +use rustc::infer::region_constraints::{GenericKind, VarInfos, VerifyBound}; use rustc::infer::{InferCtxt, NLLRegionVariableOrigin, RegionVariableOrigin}; use rustc::mir::{ - ClosureOutlivesRequirement, ClosureOutlivesSubject, ClosureRegionRequirements, Local, Location, - Mir, + ClosureOutlivesRequirement, ClosureOutlivesSubject, ClosureRegionRequirements, + ConstraintCategory, Local, Location, Mir, }; use rustc::ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable}; use rustc::util::common; +use rustc_data_structures::bit_set::BitSet; +use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::graph::scc::Sccs; -use rustc_data_structures::indexed_set::IdxSet; use rustc_data_structures::indexed_vec::IndexVec; -use rustc_errors::{DiagnosticBuilder, Diagnostic}; +use rustc_errors::{Diagnostic, DiagnosticBuilder}; +use syntax_pos::Span; use std::rc::Rc; mod dump_mir; mod error_reporting; +crate use self::error_reporting::{RegionName, RegionNameSource}; mod graphviz; pub mod values; use self::values::{LivenessValues, RegionValueElements, RegionValues}; @@ -62,15 +63,28 @@ /// the SCC (see `constraint_sccs`) and for error reporting. constraint_graph: Rc, - /// The SCC computed from `constraints` and the constraint graph. Used to compute the values - /// of each region. + /// The SCC computed from `constraints` and the constraint graph. Used to + /// compute the values of each region. constraint_sccs: Rc>, + /// Map closure bounds to a `Span` that should be used for error reporting. + closure_bounds_mapping: + FxHashMap>, + /// Contains the minimum universe of any variable within the same /// SCC. We will ensure that no SCC contains values that are not /// visible from this index. scc_universes: IndexVec, + /// Contains a "representative" from each SCC. This will be the + /// minimal RegionVid belonging to that universe. It is used as a + /// kind of hacky way to manage checking outlives relationships, + /// since we can 'canonicalize' each region to the representative + /// of its SCC and be sure that -- if they have the same repr -- + /// they *must* be equal (though not having the same repr does not + /// mean they are unequal). + scc_representatives: IndexVec, + /// The final inferred values of the region variables; we compute /// one value per SCC. To get the value for any given *region*, /// you first find which scc it is a part of. @@ -97,7 +111,7 @@ /// Which universe is this region variable defined in? This is /// most often `ty::UniverseIndex::ROOT`, but when we encounter /// forall-quantifiers like `for<'a> { 'a = 'b }`, we would create - /// the variable for `'a` in a subuniverse. + /// the variable for `'a` in a fresh universe that extends ROOT. universe: ty::UniverseIndex, /// If this is 'static or an early-bound region, then this is @@ -162,42 +176,7 @@ /// A test which, if met by the region `'x`, proves that this type /// constraint is satisfied. - pub test: RegionTest, -} - -/// A "test" that can be applied to some "subject region" `'x`. These are used to -/// describe type constraints. Tests do not presently affect the -/// region values that get inferred for each variable; they only -/// examine the results *after* inference. This means they can -/// conveniently include disjuction ("a or b must be true"). -#[derive(Clone, Debug)] -pub enum RegionTest { - /// The subject region `'x` must by outlived by *some* region in - /// the given set of regions. - /// - /// This test comes from e.g. a where clause like `T: 'a + 'b`, - /// which implies that we know that `T: 'a` and that `T: - /// 'b`. Therefore, if we are trying to prove that `T: 'x`, we can - /// do so by showing that `'a: 'x` *or* `'b: 'x`. - IsOutlivedByAnyRegionIn(Vec), - - /// The subject region `'x` must by outlived by *all* regions in - /// the given set of regions. - /// - /// This test comes from e.g. a projection type like `T = >::Foo`, which must outlive `'a` or `'b`, and - /// maybe both. Therefore we can prove that `T: 'x` if we know - /// that `'a: 'x` *and* `'b: 'x`. - IsOutlivedByAllRegionsIn(Vec), - - /// Any of the given tests are true. - /// - /// This arises from projections, for which there are multiple - /// ways to prove an outlives relationship. - Any(Vec), - - /// All of the given tests are true. - All(Vec), + pub verify_bound: VerifyBound<'tcx>, } impl<'tcx> RegionInferenceContext<'tcx> { @@ -211,9 +190,14 @@ pub(crate) fn new( var_infos: VarInfos, universal_regions: Rc>, + placeholder_indices: Rc, universal_region_relations: Rc>, _mir: &Mir<'tcx>, outlives_constraints: ConstraintSet, + closure_bounds_mapping: FxHashMap< + Location, + FxHashMap<(RegionVid, RegionVid), (ConstraintCategory, Span)>, + >, type_tests: Vec>, liveness_constraints: LivenessValues, elements: &Rc, @@ -224,19 +208,13 @@ .map(|info| RegionDefinition::new(info.universe, info.origin)) .collect(); - // Compute the max universe used anywhere amongst the regions. - let max_universe = definitions - .iter() - .map(|d| d.universe) - .max() - .unwrap_or(ty::UniverseIndex::ROOT); - let constraints = Rc::new(outlives_constraints); // freeze constraints let constraint_graph = Rc::new(constraints.graph(definitions.len())); let fr_static = universal_regions.fr_static; let constraint_sccs = Rc::new(constraints.compute_sccs(&constraint_graph, fr_static)); - let mut scc_values = RegionValues::new(elements, universal_regions.len(), max_universe); + let mut scc_values = + RegionValues::new(elements, universal_regions.len(), &placeholder_indices); for region in liveness_constraints.rows() { let scc = constraint_sccs.scc(region); @@ -245,13 +223,17 @@ let scc_universes = Self::compute_scc_universes(&constraint_sccs, &definitions); + let scc_representatives = Self::compute_scc_representatives(&constraint_sccs, &definitions); + let mut result = Self { definitions, liveness_constraints, constraints, constraint_graph, constraint_sccs, + closure_bounds_mapping, scc_universes, + scc_representatives, scc_values, type_tests, universal_regions, @@ -288,6 +270,27 @@ scc_universes } + /// For each SCC, we compute a unique `RegionVid` (in fact, the + /// minimal one that belongs to the SCC). See + /// `scc_representatives` field of `RegionInferenceContext` for + /// more details. + fn compute_scc_representatives( + constraints_scc: &Sccs, + definitions: &IndexVec>, + ) -> IndexVec { + let num_sccs = constraints_scc.num_sccs(); + let next_region_vid = definitions.next_index(); + let mut scc_representatives = IndexVec::from_elem_n(next_region_vid, num_sccs); + + for region_vid in definitions.indices() { + let scc = constraints_scc.scc(region_vid); + let prev_min = scc_representatives[scc]; + scc_representatives[scc] = region_vid.min(prev_min); + } + + scc_representatives + } + /// Initializes the region variables for each universally /// quantified region (lifetime parameter). The first N variables /// always correspond to the regions appearing in the function @@ -333,17 +336,14 @@ self.scc_values.add_element(scc, variable); } - NLLRegionVariableOrigin::BoundRegion(ui) => { - // Each placeholder region X outlives its - // associated universe but nothing else. Every - // placeholder region is always in a universe that - // contains `ui` -- but when placeholder regions - // are placed into an SCC, that SCC may include - // things from other universes that do not include - // `ui`. + NLLRegionVariableOrigin::Placeholder(placeholder) => { + // Each placeholder region is only visible from + // its universe `ui` and its extensions. So we + // can't just add it into `scc` unless the + // universe of the scc can name this region. let scc_universe = self.scc_universes[scc]; - if ui.is_subset_of(scc_universe) { - self.scc_values.add_element(scc, ui); + if scc_universe.can_name(placeholder.universe) { + self.scc_values.add_element(scc, placeholder); } else { self.add_incompatible_universe(scc); } @@ -477,7 +477,7 @@ // SCC. For each SCC, we visit its successors and compute // their values, then we union all those values to get our // own. - let visited = &mut IdxSet::new_empty(self.constraint_sccs.num_sccs()); + let visited = &mut BitSet::new_empty(self.constraint_sccs.num_sccs()); for scc_index in self.constraint_sccs.all_sccs() { self.propagate_constraint_sccs_if_new(scc_index, visited); } @@ -487,9 +487,9 @@ fn propagate_constraint_sccs_if_new( &mut self, scc_a: ConstraintSccIndex, - visited: &mut IdxSet, + visited: &mut BitSet, ) { - if visited.add(&scc_a) { + if visited.insert(scc_a) { self.propagate_constraint_sccs_new(scc_a, visited); } } @@ -497,7 +497,7 @@ fn propagate_constraint_sccs_new( &mut self, scc_a: ConstraintSccIndex, - visited: &mut IdxSet, + visited: &mut BitSet, ) { let constraint_sccs = self.constraint_sccs.clone(); @@ -540,7 +540,7 @@ // Quick check: if scc_b's declared universe is a subset of // scc_a's declared univese (typically, both are ROOT), then // it cannot contain any problematic universe elements. - if self.scc_universes[scc_b].is_subset_of(universe_a) { + if universe_a.can_name(self.scc_universes[scc_b]) { return true; } @@ -548,8 +548,8 @@ // B's value, and check whether all of them are nameable // from universe_a self.scc_values - .subuniverses_contained_in(scc_b) - .all(|u| u.is_subset_of(universe_a)) + .placeholders_contained_in(scc_b) + .all(|p| universe_a.can_name(p.universe)) } /// Extend `scc` so that it can outlive some placeholder region @@ -579,10 +579,22 @@ ) { let tcx = infcx.tcx; + // Sometimes we register equivalent type-tests that would + // result in basically the exact same error being reported to + // the user. Avoid that. + let mut deduplicate_errors = FxHashSet::default(); + for type_test in &self.type_tests { debug!("check_type_test: {:?}", type_test); - if self.eval_region_test(mir, type_test.lower_bound, &type_test.test) { + let generic_ty = type_test.generic_kind.to_ty(tcx); + if self.eval_verify_bound( + tcx, + mir, + generic_ty, + type_test.lower_bound, + &type_test.verify_bound, + ) { continue; } @@ -597,11 +609,31 @@ } } - // Oh the humanity. Obviously we will do better than this error eventually. + // Type-test failed. Report the error. + + // Try to convert the lower-bound region into something named we can print for the user. let lower_bound_region = self.to_error_region(type_test.lower_bound); + + // Skip duplicate-ish errors. + let type_test_span = type_test.locations.span(mir); + let erased_generic_kind = tcx.erase_regions(&type_test.generic_kind); + if !deduplicate_errors.insert(( + erased_generic_kind, + lower_bound_region, + type_test.locations, + )) { + continue; + } else { + debug!( + "check_type_test: reporting error for erased_generic_kind={:?}, \ + lower_bound_region={:?}, \ + type_test.locations={:?}", + erased_generic_kind, lower_bound_region, type_test.locations, + ); + } + if let Some(lower_bound_region) = lower_bound_region { let region_scope_tree = &tcx.region_scope_tree(mir_def_id); - let type_test_span = type_test.locations.span(mir); infcx .construct_generic_bound_failure( region_scope_tree, @@ -621,7 +653,6 @@ // to report it; we could probably handle it by // iterating over the universal regions and reporting // an error that multiple bounds are required. - let type_test_span = type_test.locations.span(mir); tcx.sess .struct_span_err( type_test_span, @@ -639,13 +670,19 @@ /// to find a good name from that. Returns `None` if we can't find /// one (e.g., this is just some random part of the CFG). pub fn to_error_region(&self, r: RegionVid) -> Option> { + self.to_error_region_vid(r).and_then(|r| self.definitions[r].external_name) + } + + /// Returns the [RegionVid] corresponding to the region returned by + /// `to_error_region`. + pub fn to_error_region_vid(&self, r: RegionVid) -> Option { if self.universal_regions.is_universal_region(r) { - return self.definitions[r].external_name; + Some(r) } else { let r_scc = self.constraint_sccs.scc(r); let upper_bound = self.universal_upper_bound(r); if self.scc_values.contains(r_scc, upper_bound) { - self.to_error_region(upper_bound) + self.to_error_region_vid(upper_bound) } else { None } @@ -689,7 +726,7 @@ generic_kind, lower_bound, locations, - test: _, + verify_bound: _, } = type_test; let generic_ty = generic_kind.to_ty(tcx); @@ -716,7 +753,7 @@ // where `ur` is a local bound -- we are sometimes in a // position to prove things that our caller cannot. See // #53570 for an example. - if self.eval_region_test(mir, ur, &type_test.test) { + if self.eval_verify_bound(tcx, mir, generic_ty, ur, &type_test.verify_bound) { continue; } @@ -732,6 +769,7 @@ subject, outlived_free_region: non_local_ub, blame_span: locations.span(mir), + category: ConstraintCategory::Boring, }; debug!("try_promote_type_test: pushing {:#?}", requirement); propagated_outlives_requirements.push(requirement); @@ -888,31 +926,99 @@ /// Test if `test` is true when applied to `lower_bound` at /// `point`, and returns true or false. - fn eval_region_test(&self, mir: &Mir<'tcx>, lower_bound: RegionVid, test: &RegionTest) -> bool { + fn eval_verify_bound( + &self, + tcx: TyCtxt<'_, '_, 'tcx>, + mir: &Mir<'tcx>, + generic_ty: Ty<'tcx>, + lower_bound: RegionVid, + verify_bound: &VerifyBound<'tcx>, + ) -> bool { debug!( - "eval_region_test(lower_bound={:?}, test={:?})", - lower_bound, test + "eval_verify_bound(lower_bound={:?}, verify_bound={:?})", + lower_bound, verify_bound ); - match test { - RegionTest::IsOutlivedByAllRegionsIn(regions) => regions - .iter() - .all(|&r| self.eval_outlives(mir, r, lower_bound)), - - RegionTest::IsOutlivedByAnyRegionIn(regions) => regions - .iter() - .any(|&r| self.eval_outlives(mir, r, lower_bound)), - - RegionTest::Any(tests) => tests - .iter() - .any(|test| self.eval_region_test(mir, lower_bound, test)), - - RegionTest::All(tests) => tests - .iter() - .all(|test| self.eval_region_test(mir, lower_bound, test)), + match verify_bound { + VerifyBound::IfEq(test_ty, verify_bound1) => { + self.eval_if_eq(tcx, mir, generic_ty, lower_bound, test_ty, verify_bound1) + } + + VerifyBound::OutlivedBy(r) => { + let r_vid = self.to_region_vid(r); + self.eval_outlives(mir, r_vid, lower_bound) + } + + VerifyBound::AnyBound(verify_bounds) => verify_bounds.iter().any(|verify_bound| { + self.eval_verify_bound(tcx, mir, generic_ty, lower_bound, verify_bound) + }), + + VerifyBound::AllBounds(verify_bounds) => verify_bounds.iter().all(|verify_bound| { + self.eval_verify_bound(tcx, mir, generic_ty, lower_bound, verify_bound) + }), + } + } + + fn eval_if_eq( + &self, + tcx: TyCtxt<'_, '_, 'tcx>, + mir: &Mir<'tcx>, + generic_ty: Ty<'tcx>, + lower_bound: RegionVid, + test_ty: Ty<'tcx>, + verify_bound: &VerifyBound<'tcx>, + ) -> bool { + let generic_ty_normalized = self.normalize_to_scc_representatives(tcx, generic_ty); + let test_ty_normalized = self.normalize_to_scc_representatives(tcx, test_ty); + if generic_ty_normalized == test_ty_normalized { + self.eval_verify_bound(tcx, mir, generic_ty, lower_bound, verify_bound) + } else { + false } } + /// This is a conservative normalization procedure. It takes every + /// free region in `value` and replaces it with the + /// "representative" of its SCC (see `scc_representatives` field). + /// We are guaranteed that if two values normalize to the same + /// thing, then they are equal; this is a conservative check in + /// that they could still be equal even if they normalize to + /// different results. (For example, there might be two regions + /// with the same value that are not in the same SCC). + /// + /// NB. This is not an ideal approach and I would like to revisit + /// it. However, it works pretty well in practice. In particular, + /// this is needed to deal with projection outlives bounds like + /// + /// >::Item: '1 + /// + /// In particular, this routine winds up being important when + /// there are bounds like `where >::Item: 'b` in the + /// environment. In this case, if we can show that `'0 == 'a`, + /// and that `'b: '1`, then we know that the clause is + /// satisfied. In such cases, particularly due to limitations of + /// the trait solver =), we usually wind up with a where-clause like + /// `T: Foo<'a>` in scope, which thus forces `'0 == 'a` to be added as + /// a constraint, and thus ensures that they are in the same SCC. + /// + /// So why can't we do a more correct routine? Well, we could + /// *almost* use the `relate_tys` code, but the way it is + /// currently setup it creates inference variables to deal with + /// higher-ranked things and so forth, and right now the inference + /// context is not permitted to make more inference variables. So + /// we use this kind of hacky solution. + fn normalize_to_scc_representatives(&self, tcx: TyCtxt<'_, '_, 'tcx>, value: T) -> T + where + T: TypeFoldable<'tcx>, + { + tcx.fold_regions(&value, &mut false, |r, _db| { + let vid = self.to_region_vid(r); + let scc = self.constraint_sccs.scc(vid); + let repr = self.scc_representatives[scc]; + tcx.mk_region(ty::ReVar(repr)) + }) + } + // Evaluate whether `sup_region: sub_region @ point`. fn eval_outlives( &self, @@ -1005,8 +1111,8 @@ ); } - NLLRegionVariableOrigin::BoundRegion(universe) => { - self.check_bound_universal_region(infcx, mir, mir_def_id, fr, universe); + NLLRegionVariableOrigin::Placeholder(placeholder) => { + self.check_bound_universal_region(infcx, mir, mir_def_id, fr, placeholder); } NLLRegionVariableOrigin::Existential => { @@ -1042,7 +1148,7 @@ assert!(self.scc_universes[longer_fr_scc] == ty::UniverseIndex::ROOT); debug_assert!( self.scc_values - .subuniverses_contained_in(longer_fr_scc) + .placeholders_contained_in(longer_fr_scc) .next() .is_none() ); @@ -1062,7 +1168,7 @@ longer_fr, shorter_fr, ); - let blame_span = self.find_outlives_blame_span(mir, infcx.tcx, longer_fr, shorter_fr); + let blame_span_category = self.find_outlives_blame_span(mir, longer_fr, shorter_fr); if let Some(propagated_outlives_requirements) = propagated_outlives_requirements { // Shrink `fr` until we find a non-local region (if we do). @@ -1087,9 +1193,10 @@ propagated_outlives_requirements.push(ClosureOutlivesRequirement { subject: ClosureOutlivesSubject::Region(fr_minus), outlived_free_region: shorter_fr_plus, - blame_span: blame_span, + blame_span: blame_span_category.1, + category: blame_span_category.0, }); - return; + continue; } } @@ -1101,6 +1208,7 @@ // to report the error. This gives better error messages // in some cases. self.report_error(mir, infcx, mir_def_id, longer_fr, shorter_fr, errors_buffer); + return; // continuing to iterate just reports more errors than necessary } } @@ -1110,9 +1218,12 @@ mir: &Mir<'tcx>, _mir_def_id: DefId, longer_fr: RegionVid, - universe: ty::UniverseIndex, + placeholder: ty::Placeholder, ) { - debug!("check_bound_universal_region(fr={:?})", longer_fr); + debug!( + "check_bound_universal_region(fr={:?}, placeholder={:?})", + longer_fr, placeholder, + ); let longer_fr_scc = self.constraint_sccs.scc(longer_fr); @@ -1125,7 +1236,7 @@ .find(|element| match element { RegionElement::Location(_) => true, RegionElement::RootUniversalRegion(_) => true, - RegionElement::SubUniversalRegion(ui) => *ui != universe, + RegionElement::PlaceholderRegion(placeholder1) => placeholder != *placeholder1, }) } { Some(v) => v, @@ -1136,10 +1247,10 @@ let error_region = match error_element { RegionElement::Location(l) => self.find_sub_region_live_at(longer_fr, l), RegionElement::RootUniversalRegion(r) => r, - RegionElement::SubUniversalRegion(error_ui) => self.definitions + RegionElement::PlaceholderRegion(error_placeholder) => self.definitions .iter_enumerated() .filter_map(|(r, definition)| match definition.origin { - NLLRegionVariableOrigin::BoundRegion(ui) if error_ui == ui => Some(r), + NLLRegionVariableOrigin::Placeholder(p) if p == error_placeholder => Some(r), _ => None, }) .next() @@ -1147,7 +1258,7 @@ }; // Find the code to blame for the fact that `longer_fr` outlives `error_fr`. - let span = self.find_outlives_blame_span(mir, infcx.tcx, longer_fr, error_region); + let (_, span) = self.find_outlives_blame_span(mir, longer_fr, error_region); // Obviously, this error message is far from satisfactory. // At present, though, it only appears in unit tests -- @@ -1187,7 +1298,7 @@ tcx: TyCtxt<'_, 'gcx, 'tcx>, location: Location, closure_def_id: DefId, - closure_substs: ty::ClosureSubsts<'tcx>, + closure_substs: &'tcx ty::subst::Substs<'tcx>, ) -> Vec>; fn subst_closure_mapping( @@ -1218,23 +1329,19 @@ tcx: TyCtxt<'_, 'gcx, 'tcx>, location: Location, closure_def_id: DefId, - closure_substs: ty::ClosureSubsts<'tcx>, + closure_substs: &'tcx ty::subst::Substs<'tcx>, ) -> Vec> { debug!( "apply_requirements(location={:?}, closure_def_id={:?}, closure_substs={:?})", location, closure_def_id, closure_substs ); - // Get Tu. - let user_closure_ty = tcx.mk_closure(closure_def_id, closure_substs); - debug!("apply_requirements: user_closure_ty={:?}", user_closure_ty); - - // Extract the values of the free regions in `user_closure_ty` + // Extract the values of the free regions in `closure_substs` // into a vector. These are the regions that we will be // relating to one another. let closure_mapping = &UniversalRegions::closure_mapping( tcx, - user_closure_ty, + closure_substs, self.num_external_vids, tcx.closure_base_def_id(closure_def_id), ); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/values.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/values.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/values.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/region_infer/values.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,8 @@ use rustc::mir::{BasicBlock, Location, Mir}; use rustc::ty::{self, RegionVid}; -use rustc_data_structures::bitvec::{BitArray, SparseBitMatrix}; +use rustc_data_structures::bit_set::{HybridBitSet, SparseBitMatrix}; +use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::indexed_vec::Idx; use rustc_data_structures::indexed_vec::IndexVec; use std::fmt::Debug; @@ -31,8 +32,7 @@ impl RegionValueElements { crate fn new(mir: &Mir<'_>) -> Self { let mut num_points = 0; - let statements_before_block: IndexVec = mir - .basic_blocks() + let statements_before_block: IndexVec = mir.basic_blocks() .iter() .map(|block_data| { let v = num_points; @@ -48,7 +48,7 @@ let mut basic_blocks = IndexVec::with_capacity(num_points); for (bb, bb_data) in mir.basic_blocks().iter_enumerated() { - basic_blocks.extend((0 .. bb_data.statements.len() + 1).map(|_| bb)); + basic_blocks.extend((0..bb_data.statements.len() + 1).map(|_| bb)); } Self { @@ -85,7 +85,10 @@ let block = self.basic_blocks[index]; let start_index = self.statements_before_block[block]; let statement_index = index.index() - start_index; - Location { block, statement_index } + Location { + block, + statement_index, + } } /// Sometimes we get point-indices back from bitsets that may be @@ -103,13 +106,15 @@ index: PointIndex, stack: &mut Vec, ) { - let Location { block, statement_index } = self.to_location(index); + let Location { + block, + statement_index, + } = self.to_location(index); if statement_index == 0 { // If this is a basic block head, then the predecessors are // the the terminators of other basic blocks stack.extend( - mir - .predecessors_for(block) + mir.predecessors_for(block) .iter() .map(|&pred_bb| mir.terminator_loc(pred_bb)) .map(|pred_loc| self.point_from_location(pred_loc)), @@ -127,10 +132,7 @@ pub struct PointIndex { DEBUG_FORMAT = "PointIndex({})" } } -/// A single integer representing a (non-zero) `UniverseIndex`. -/// Computed just by subtracting one from `UniverseIndex`; this is -/// because the `0` value for `UniverseIndex` represents the root -/// universe, and we don't need/want a bit for that one. +/// A single integer representing a `ty::Placeholder`. newtype_index! { pub struct PlaceholderIndex { DEBUG_FORMAT = "PlaceholderIndex({})" } } @@ -146,9 +148,9 @@ /// a lifetime parameter). RootUniversalRegion(RegionVid), - /// A subuniverse from a subuniverse (e.g., instantiated from a - /// `for<'a> fn(&'a u32)` type). - SubUniversalRegion(ty::UniverseIndex), + /// A placeholder (e.g., instantiated from a `for<'a> fn(&'a u32)` + /// type). + PlaceholderRegion(ty::Placeholder), } /// When we initially compute liveness, we use a bit matrix storing @@ -179,19 +181,22 @@ crate fn add_element(&mut self, row: N, location: Location) -> bool { debug!("LivenessValues::add(r={:?}, location={:?})", row, location); let index = self.elements.point_from_location(location); - self.points.add(row, index) + self.points.insert(row, index) } /// Adds all the elements in the given bit array into the given /// region. Returns true if any of them are newly added. - crate fn add_elements(&mut self, row: N, locations: &BitArray) -> bool { - debug!("LivenessValues::add_elements(row={:?}, locations={:?})", row, locations); - self.points.merge_into(row, locations) + crate fn add_elements(&mut self, row: N, locations: &HybridBitSet) -> bool { + debug!( + "LivenessValues::add_elements(row={:?}, locations={:?})", + row, locations + ); + self.points.union_into_row(row, locations) } /// Adds all the control-flow points to the values for `r`. crate fn add_all_points(&mut self, row: N) { - self.points.add_all(row); + self.points.insert_all_into_row(row); } /// True if the region `r` contains the given element. @@ -214,6 +219,39 @@ } } +/// Maps from `ty::Placeholder` values that are used in the rest of +/// rustc to the internal `PlaceholderIndex` values that are used in +/// NLL. +#[derive(Default)] +crate struct PlaceholderIndices { + to_index: FxHashMap, + from_index: IndexVec, +} + +impl PlaceholderIndices { + crate fn insert(&mut self, placeholder: ty::Placeholder) -> PlaceholderIndex { + let PlaceholderIndices { + to_index, + from_index, + } = self; + *to_index + .entry(placeholder) + .or_insert_with(|| from_index.push(placeholder)) + } + + crate fn lookup_index(&self, placeholder: ty::Placeholder) -> PlaceholderIndex { + self.to_index[&placeholder] + } + + crate fn lookup_placeholder(&self, placeholder: PlaceholderIndex) -> ty::Placeholder { + self.from_index[placeholder] + } + + crate fn len(&self) -> usize { + self.from_index.len() + } +} + /// Stores the full values for a set of regions (in contrast to /// `LivenessValues`, which only stores those points in the where a /// region is live). The full value for a region may contain points in @@ -235,6 +273,7 @@ #[derive(Clone)] crate struct RegionValues { elements: Rc, + placeholder_indices: Rc, points: SparseBitMatrix, free_regions: SparseBitMatrix, @@ -250,12 +289,13 @@ crate fn new( elements: &Rc, num_universal_regions: usize, - max_universe: ty::UniverseIndex, + placeholder_indices: &Rc, ) -> Self { - let num_placeholders = max_universe.as_usize(); + let num_placeholders = placeholder_indices.len(); Self { elements: elements.clone(), points: SparseBitMatrix::new(elements.num_points), + placeholder_indices: placeholder_indices.clone(), free_regions: SparseBitMatrix::new(num_universal_regions), placeholders: SparseBitMatrix::new(num_placeholders), } @@ -270,15 +310,15 @@ /// Adds all the control-flow points to the values for `r`. crate fn add_all_points(&mut self, r: N) { - self.points.add_all(r); + self.points.insert_all_into_row(r); } /// Add all elements in `r_from` to `r_to` (because e.g. `r_to: /// r_from`). crate fn add_region(&mut self, r_to: N, r_from: N) -> bool { - self.points.merge(r_from, r_to) - | self.free_regions.merge(r_from, r_to) - | self.placeholders.merge(r_from, r_to) + self.points.union_rows(r_from, r_to) + | self.free_regions.union_rows(r_from, r_to) + | self.placeholders.union_rows(r_from, r_to) } /// True if the region `r` contains the given element. @@ -291,7 +331,7 @@ /// the region `to` in `self`. crate fn merge_liveness(&mut self, to: N, from: M, values: &LivenessValues) { if let Some(set) = values.points.row(from) { - self.points.merge_into(to, set); + self.points.union_into_row(to, set); } } @@ -300,7 +340,7 @@ crate fn contains_points(&self, sup_region: N, sub_region: N) -> bool { if let Some(sub_row) = self.points.row(sub_region) { if let Some(sup_row) = self.points.row(sup_region) { - sup_row.contains_all(sub_row) + sup_row.superset(sub_row) } else { // sup row is empty, so sub row must be empty sub_row.is_empty() @@ -313,14 +353,11 @@ /// Returns the locations contained within a given region `r`. crate fn locations_outlived_by<'a>(&'a self, r: N) -> impl Iterator + 'a { - self.points - .row(r) - .into_iter() - .flat_map(move |set| { - set.iter() - .take_while(move |&p| self.elements.point_in_range(p)) - .map(move |p| self.elements.to_location(p)) - }) + self.points.row(r).into_iter().flat_map(move |set| { + set.iter() + .take_while(move |&p| self.elements.point_in_range(p)) + .map(move |p| self.elements.to_location(p)) + }) } /// Returns just the universal regions that are contained in a given region's value. @@ -335,32 +372,30 @@ } /// Returns all the elements contained in a given region's value. - crate fn subuniverses_contained_in<'a>( + crate fn placeholders_contained_in<'a>( &'a self, r: N, - ) -> impl Iterator + 'a { + ) -> impl Iterator + 'a { self.placeholders .row(r) .into_iter() .flat_map(|set| set.iter()) - .map(|p| ty::UniverseIndex::from_u32((p.index() + 1) as u32)) + .map(move |p| self.placeholder_indices.lookup_placeholder(p)) } /// Returns all the elements contained in a given region's value. crate fn elements_contained_in<'a>(&'a self, r: N) -> impl Iterator + 'a { let points_iter = self.locations_outlived_by(r).map(RegionElement::Location); - let free_regions_iter = self - .universal_regions_outlived_by(r) + let free_regions_iter = self.universal_regions_outlived_by(r) .map(RegionElement::RootUniversalRegion); - let subuniverses_iter = self - .subuniverses_contained_in(r) - .map(RegionElement::SubUniversalRegion); + let placeholder_universes_iter = self.placeholders_contained_in(r) + .map(RegionElement::PlaceholderRegion); points_iter .chain(free_regions_iter) - .chain(subuniverses_iter) + .chain(placeholder_universes_iter) } /// Returns a "pretty" string value of the region. Meant for debugging. @@ -378,7 +413,7 @@ impl ToElementIndex for Location { fn add_to_row(self, values: &mut RegionValues, row: N) -> bool { let index = values.elements.point_from_location(self); - values.points.add(row, index) + values.points.insert(row, index) } fn contained_in_row(self, values: &RegionValues, row: N) -> bool { @@ -389,7 +424,7 @@ impl ToElementIndex for RegionVid { fn add_to_row(self, values: &mut RegionValues, row: N) -> bool { - values.free_regions.add(row, self) + values.free_regions.insert(row, self) } fn contained_in_row(self, values: &RegionValues, row: N) -> bool { @@ -397,14 +432,14 @@ } } -impl ToElementIndex for ty::UniverseIndex { +impl ToElementIndex for ty::Placeholder { fn add_to_row(self, values: &mut RegionValues, row: N) -> bool { - let index = PlaceholderIndex::new(self.as_usize() - 1); - values.placeholders.add(row, index) + let index = values.placeholder_indices.lookup_index(self); + values.placeholders.insert(row, index) } fn contained_in_row(self, values: &RegionValues, row: N) -> bool { - let index = PlaceholderIndex::new(self.as_usize() - 1); + let index = values.placeholder_indices.lookup_index(self); values.placeholders.contains(row, index) } } @@ -467,7 +502,7 @@ result.push_str(&format!("{:?}", fr)); } - RegionElement::SubUniversalRegion(ur) => { + RegionElement::PlaceholderRegion(placeholder) => { if let Some((location1, location2)) = open_location { push_sep(&mut result); push_location_range(&mut result, location1, location2); @@ -475,7 +510,7 @@ } push_sep(&mut result); - result.push_str(&format!("{:?}", ur)); + result.push_str(&format!("{:?}", placeholder)); } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/renumber.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/renumber.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/renumber.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/renumber.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,8 +9,8 @@ // except according to those terms. use rustc::ty::subst::Substs; -use rustc::ty::{self, CanonicalTy, ClosureSubsts, GeneratorSubsts, Ty, TypeFoldable}; -use rustc::mir::{BasicBlock, Location, Mir, Place, Statement, StatementKind}; +use rustc::ty::{self, ClosureSubsts, GeneratorSubsts, Ty, TypeFoldable}; +use rustc::mir::{BasicBlock, Location, Mir, Statement, StatementKind, UserTypeAnnotation}; use rustc::mir::visit::{MutVisitor, TyContext}; use rustc::infer::{InferCtxt, NLLRegionVariableOrigin}; @@ -65,6 +65,14 @@ debug!("visit_ty: ty={:?}", ty); } + fn visit_user_type_annotation(&mut self, _ty: &mut UserTypeAnnotation<'tcx>) { + // User type annotations represent the types that the user + // wrote in the progarm. We don't want to erase the regions + // from these types: rather, we want to add them as + // constraints at type-check time. + debug!("visit_user_type_annotation: skipping renumber"); + } + fn visit_substs(&mut self, substs: &mut &'tcx Substs<'tcx>, location: Location) { debug!("visit_substs(substs={:?}, location={:?})", substs, location); @@ -112,19 +120,6 @@ debug!("visit_closure_substs: substs={:?}", substs); } - fn visit_ascribe_user_ty( - &mut self, - _place: &mut Place<'tcx>, - _variance: &mut ty::Variance, - _c_ty: &mut CanonicalTy<'tcx>, - _location: Location, - ) { - // User-assert-ty statements represent types that the user added explicitly. - // We don't want to erase the regions from these types: rather, we want to - // add them as constraints at type-check time. - debug!("visit_user_assert_ty: skipping renumber"); - } - fn visit_statement( &mut self, block: BasicBlock, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,16 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use borrow_check::location::LocationTable; use borrow_check::nll::constraints::{ConstraintSet, OutlivesConstraint}; -use borrow_check::nll::facts::AllFacts; -use borrow_check::nll::region_infer::{RegionTest, TypeTest}; +use borrow_check::nll::region_infer::TypeTest; use borrow_check::nll::type_check::Locations; use borrow_check::nll::universal_regions::UniversalRegions; use rustc::infer::canonical::QueryRegionConstraint; +use rustc::infer::outlives::env::RegionBoundPairs; use rustc::infer::outlives::obligations::{TypeOutlives, TypeOutlivesDelegate}; use rustc::infer::region_constraints::{GenericKind, VerifyBound}; use rustc::infer::{self, SubregionOrigin}; +use rustc::mir::ConstraintCategory; use rustc::ty::subst::UnpackedKind; use rustc::ty::{self, TyCtxt}; use syntax_pos::DUMMY_SP; @@ -25,40 +25,37 @@ crate struct ConstraintConversion<'a, 'gcx: 'tcx, 'tcx: 'a> { tcx: TyCtxt<'a, 'gcx, 'tcx>, universal_regions: &'a UniversalRegions<'tcx>, - location_table: &'a LocationTable, - region_bound_pairs: &'a [(ty::Region<'tcx>, GenericKind<'tcx>)], + region_bound_pairs: &'a RegionBoundPairs<'tcx>, implicit_region_bound: Option>, param_env: ty::ParamEnv<'tcx>, locations: Locations, + category: ConstraintCategory, outlives_constraints: &'a mut ConstraintSet, type_tests: &'a mut Vec>, - all_facts: &'a mut Option, } impl<'a, 'gcx, 'tcx> ConstraintConversion<'a, 'gcx, 'tcx> { crate fn new( tcx: TyCtxt<'a, 'gcx, 'tcx>, universal_regions: &'a UniversalRegions<'tcx>, - location_table: &'a LocationTable, - region_bound_pairs: &'a [(ty::Region<'tcx>, GenericKind<'tcx>)], + region_bound_pairs: &'a RegionBoundPairs<'tcx>, implicit_region_bound: Option>, param_env: ty::ParamEnv<'tcx>, locations: Locations, + category: ConstraintCategory, outlives_constraints: &'a mut ConstraintSet, type_tests: &'a mut Vec>, - all_facts: &'a mut Option, ) -> Self { Self { tcx, universal_regions, - location_table, region_bound_pairs, implicit_region_bound, param_env, locations, + category, outlives_constraints, type_tests, - all_facts, } } @@ -97,23 +94,6 @@ let r1_vid = self.to_region_vid(r1); let r2_vid = self.to_region_vid(r2); self.add_outlives(r1_vid, r2_vid); - - // In the new analysis, all outlives relations etc - // "take effect" at the mid point of the statement - // that requires them, so ignore the `at_location`. - if let Some(all_facts) = &mut self.all_facts { - if let Some(from_location) = self.locations.from_location() { - all_facts.outlives.push(( - r1_vid, - r2_vid, - self.location_table.mid_index(from_location), - )); - } else { - for location in self.location_table.all_points() { - all_facts.outlives.push((r1_vid, r2_vid, location)); - } - } - } } UnpackedKind::Type(t1) => { @@ -136,43 +116,15 @@ &self, generic_kind: GenericKind<'tcx>, region: ty::Region<'tcx>, - bound: VerifyBound<'tcx>, + verify_bound: VerifyBound<'tcx>, ) -> TypeTest<'tcx> { let lower_bound = self.to_region_vid(region); - let test = self.verify_bound_to_region_test(&bound); - TypeTest { generic_kind, lower_bound, locations: self.locations, - test, - } - } - - fn verify_bound_to_region_test(&self, verify_bound: &VerifyBound<'tcx>) -> RegionTest { - match verify_bound { - VerifyBound::AnyRegion(regions) => RegionTest::IsOutlivedByAnyRegionIn( - regions.iter().map(|r| self.to_region_vid(r)).collect(), - ), - - VerifyBound::AllRegions(regions) => RegionTest::IsOutlivedByAllRegionsIn( - regions.iter().map(|r| self.to_region_vid(r)).collect(), - ), - - VerifyBound::AnyBound(bounds) => RegionTest::Any( - bounds - .iter() - .map(|b| self.verify_bound_to_region_test(b)) - .collect(), - ), - - VerifyBound::AllBounds(bounds) => RegionTest::All( - bounds - .iter() - .map(|b| self.verify_bound_to_region_test(b)) - .collect(), - ), + verify_bound, } } @@ -183,12 +135,14 @@ fn add_outlives(&mut self, sup: ty::RegionVid, sub: ty::RegionVid) { self.outlives_constraints.push(OutlivesConstraint { locations: self.locations, + category: self.category, sub, sup, }); } fn add_type_test(&mut self, type_test: TypeTest<'tcx>) { + debug!("add_type_test(type_test={:?})", type_test); self.type_tests.push(type_test); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use borrow_check::location::LocationTable; -use borrow_check::nll::facts::AllFacts; use borrow_check::nll::type_check::constraint_conversion; use borrow_check::nll::type_check::{Locations, MirTypeckRegionConstraints}; use borrow_check::nll::universal_regions::UniversalRegions; @@ -18,11 +16,13 @@ use rustc::infer::outlives::free_region_map::FreeRegionRelations; use rustc::infer::region_constraints::GenericKind; use rustc::infer::InferCtxt; +use rustc::mir::ConstraintCategory; use rustc::traits::query::outlives_bounds::{self, OutlivesBound}; use rustc::traits::query::type_op::{self, TypeOp}; use rustc::ty::{self, RegionVid, Ty}; use rustc_data_structures::transitive_relation::TransitiveRelation; use std::rc::Rc; +use syntax_pos::DUMMY_SP; #[derive(Debug)] crate struct UniversalRegionRelations<'tcx> { @@ -67,25 +67,21 @@ crate fn create( infcx: &InferCtxt<'_, '_, 'tcx>, param_env: ty::ParamEnv<'tcx>, - location_table: &LocationTable, implicit_region_bound: Option>, universal_regions: &Rc>, constraints: &mut MirTypeckRegionConstraints<'tcx>, - all_facts: &mut Option, ) -> CreateResult<'tcx> { UniversalRegionRelationsBuilder { infcx, param_env, implicit_region_bound, constraints, - location_table, - all_facts, universal_regions: universal_regions.clone(), region_bound_pairs: Vec::new(), relations: UniversalRegionRelations { universal_regions: universal_regions.clone(), - outlives: TransitiveRelation::new(), - inverse_outlives: TransitiveRelation::new(), + outlives: Default::default(), + inverse_outlives: Default::default(), }, }.create() } @@ -208,11 +204,9 @@ struct UniversalRegionRelationsBuilder<'this, 'gcx: 'tcx, 'tcx: 'this> { infcx: &'this InferCtxt<'this, 'gcx, 'tcx>, param_env: ty::ParamEnv<'tcx>, - location_table: &'this LocationTable, universal_regions: Rc>, implicit_region_bound: Option>, constraints: &'this mut MirTypeckRegionConstraints<'tcx>, - all_facts: &'this mut Option, // outputs: relations: UniversalRegionRelations<'tcx>, @@ -279,14 +273,13 @@ constraint_conversion::ConstraintConversion::new( self.infcx.tcx, &self.universal_regions, - &self.location_table, &self.region_bound_pairs, self.implicit_region_bound, self.param_env, - Locations::All, + Locations::All(DUMMY_SP), + ConstraintCategory::Internal, &mut self.constraints.outlives_constraints, &mut self.constraints.type_tests, - &mut self.all_facts, ).convert_all(&data); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/input_output.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/input_output.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/input_output.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/input_output.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,21 +14,16 @@ //! are supplied to us before normalization and may contain existential //! `impl Trait` instances. In contrast, the input/output types found in //! the MIR (specifically, in the special local variables for the -//! `RETURN_PLACE` the MIR arguments) are always fully normalize (and +//! `RETURN_PLACE` the MIR arguments) are always fully normalized (and //! contain revealed `impl Trait` values). -use borrow_check::nll::renumber; -use borrow_check::nll::type_check::free_region_relations::UniversalRegionRelations; use borrow_check::nll::universal_regions::UniversalRegions; -use rustc::hir::def_id::DefId; -use rustc::infer::InferOk; +use rustc::infer::LateBoundRegionConversionTime; use rustc::mir::*; -use rustc::traits::query::type_op::custom::CustomTypeOp; -use rustc::traits::{ObligationCause, PredicateObligations}; -use rustc::ty::subst::Subst; use rustc::ty::Ty; use rustc_data_structures::indexed_vec::Idx; +use syntax_pos::Span; use super::{Locations, TypeChecker}; @@ -36,27 +31,86 @@ pub(super) fn equate_inputs_and_outputs( &mut self, mir: &Mir<'tcx>, - mir_def_id: DefId, universal_regions: &UniversalRegions<'tcx>, - universal_region_relations: &UniversalRegionRelations<'tcx>, normalized_inputs_and_output: &[Ty<'tcx>], ) { - let tcx = self.infcx.tcx; - let (&normalized_output_ty, normalized_input_tys) = normalized_inputs_and_output.split_last().unwrap(); - let infcx = self.infcx; + + // If the user explicitly annotated the input types, extract + // those. + // + // e.g. `|x: FxHashMap<_, &'static u32>| ...` + let user_provided_sig; + if !self.tcx().is_closure(self.mir_def_id) { + user_provided_sig = None; + } else { + let typeck_tables = self.tcx().typeck_tables_of(self.mir_def_id); + user_provided_sig = match typeck_tables.user_provided_sigs.get(&self.mir_def_id) { + None => None, + Some(user_provided_poly_sig) => { + // Instantiate the canonicalized variables from + // user-provided signature (e.g. the `_` in the code + // above) with fresh variables. + let (poly_sig, _) = self.infcx.instantiate_canonical_with_fresh_inference_vars( + mir.span, + &user_provided_poly_sig, + ); + + // Replace the bound items in the fn sig with fresh + // variables, so that they represent the view from + // "inside" the closure. + Some( + self.infcx + .replace_late_bound_regions_with_fresh_var( + mir.span, + LateBoundRegionConversionTime::FnCall, + &poly_sig, + ) + .0, + ) + } + } + }; // Equate expected input tys with those in the MIR. - let argument_locals = (1..).map(Local::new); - for (&normalized_input_ty, local) in normalized_input_tys.iter().zip(argument_locals) { + for (&normalized_input_ty, argument_index) in normalized_input_tys.iter().zip(0..) { + // In MIR, argument N is stored in local N+1. + let local = Local::new(argument_index + 1); + debug!( "equate_inputs_and_outputs: normalized_input_ty = {:?}", normalized_input_ty ); let mir_input_ty = mir.local_decls[local].ty; - self.equate_normalized_input_or_output(normalized_input_ty, mir_input_ty); + let mir_input_span = mir.local_decls[local].source_info.span; + self.equate_normalized_input_or_output( + normalized_input_ty, + mir_input_ty, + mir_input_span, + ); + } + + if let Some(user_provided_sig) = user_provided_sig { + for (&user_provided_input_ty, argument_index) in + user_provided_sig.inputs().iter().zip(0..) + { + // In MIR, closures begin an implicit `self`, so + // argument N is stored in local N+2. + let local = Local::new(argument_index + 2); + let mir_input_ty = mir.local_decls[local].ty; + let mir_input_span = mir.local_decls[local].source_info.span; + + // If the user explicitly annotated the input types, enforce those. + let user_provided_input_ty = + self.normalize(user_provided_input_ty, Locations::All(mir_input_span)); + self.equate_normalized_input_or_output( + user_provided_input_ty, + mir_input_ty, + mir_input_span, + ); + } } assert!( @@ -65,113 +119,53 @@ ); if let Some(mir_yield_ty) = mir.yield_ty { let ur_yield_ty = universal_regions.yield_ty.unwrap(); - self.equate_normalized_input_or_output(ur_yield_ty, mir_yield_ty); + let yield_span = mir.local_decls[RETURN_PLACE].source_info.span; + self.equate_normalized_input_or_output(ur_yield_ty, mir_yield_ty, yield_span); } // Return types are a bit more complex. They may contain existential `impl Trait` // types. - let param_env = self.param_env; let mir_output_ty = mir.local_decls[RETURN_PLACE].ty; - let opaque_type_map = - self.fully_perform_op( - Locations::All, - CustomTypeOp::new( - |infcx| { - let mut obligations = ObligationAccumulator::default(); - - let dummy_body_id = ObligationCause::dummy().body_id; - let (output_ty, opaque_type_map) = - obligations.add(infcx.instantiate_opaque_types( - mir_def_id, - dummy_body_id, - param_env, - &normalized_output_ty, - )); - debug!( - "equate_inputs_and_outputs: instantiated output_ty={:?}", - output_ty - ); - debug!( - "equate_inputs_and_outputs: opaque_type_map={:#?}", - opaque_type_map - ); - - debug!( - "equate_inputs_and_outputs: mir_output_ty={:?}", - mir_output_ty - ); - obligations.add( - infcx - .at(&ObligationCause::dummy(), param_env) - .eq(output_ty, mir_output_ty)?, - ); - - for (&opaque_def_id, opaque_decl) in &opaque_type_map { - let opaque_defn_ty = tcx.type_of(opaque_def_id); - let opaque_defn_ty = opaque_defn_ty.subst(tcx, opaque_decl.substs); - let opaque_defn_ty = renumber::renumber_regions( - infcx, - &opaque_defn_ty, - ); - debug!( - "equate_inputs_and_outputs: concrete_ty={:?}", - opaque_decl.concrete_ty - ); - debug!("equate_inputs_and_outputs: opaque_defn_ty={:?}", - opaque_defn_ty); - obligations.add( - infcx - .at(&ObligationCause::dummy(), param_env) - .eq(opaque_decl.concrete_ty, opaque_defn_ty)?, - ); - } - - debug!("equate_inputs_and_outputs: equated"); - - Ok(InferOk { - value: Some(opaque_type_map), - obligations: obligations.into_vec(), - }) - }, - || "input_output".to_string(), - ), - ).unwrap_or_else(|terr| { - span_mirbug!( - self, - Location::START, - "equate_inputs_and_outputs: `{:?}=={:?}` failed with `{:?}`", - normalized_output_ty, - mir_output_ty, - terr - ); - None - }); + let output_span = mir.local_decls[RETURN_PLACE].source_info.span; + if let Err(terr) = self.eq_opaque_type_and_type( + mir_output_ty, + normalized_output_ty, + self.mir_def_id, + Locations::All(output_span), + ConstraintCategory::BoringNoLocation, + ) { + span_mirbug!( + self, + Location::START, + "equate_inputs_and_outputs: `{:?}=={:?}` failed with `{:?}`", + normalized_output_ty, + mir_output_ty, + terr + ); + }; - // Finally, if we instantiated the opaque types successfully, we - // have to solve any bounds (e.g., `-> impl Iterator` needs to - // prove that `T: Iterator` where `T` is the type we - // instantiated it with). - if let Some(opaque_type_map) = opaque_type_map { - self.fully_perform_op( - Locations::All, - CustomTypeOp::new( - |_cx| { - infcx.constrain_opaque_types(&opaque_type_map, universal_region_relations); - Ok(InferOk { - value: (), - obligations: vec![], - }) - }, - || "opaque_type_map".to_string(), - ), - ).unwrap(); + // If the user explicitly annotated the output types, enforce those. + if let Some(user_provided_sig) = user_provided_sig { + let user_provided_output_ty = user_provided_sig.output(); + let user_provided_output_ty = + self.normalize(user_provided_output_ty, Locations::All(output_span)); + self.equate_normalized_input_or_output( + user_provided_output_ty, + mir_output_ty, + output_span, + ); } } - fn equate_normalized_input_or_output(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) { + fn equate_normalized_input_or_output(&mut self, a: Ty<'tcx>, b: Ty<'tcx>, span: Span) { debug!("equate_normalized_input_or_output(a={:?}, b={:?})", a, b); - if let Err(terr) = self.eq_types(a, b, Locations::All) { + if let Err(terr) = self.eq_types( + a, + b, + Locations::All(span), + ConstraintCategory::BoringNoLocation, + ) { span_mirbug!( self, Location::START, @@ -183,20 +177,3 @@ } } } - -#[derive(Debug, Default)] -struct ObligationAccumulator<'tcx> { - obligations: PredicateObligations<'tcx>, -} - -impl<'tcx> ObligationAccumulator<'tcx> { - fn add(&mut self, value: InferOk<'tcx, T>) -> T { - let InferOk { value, obligations } = value; - self.obligations.extend(obligations); - value - } - - fn into_vec(self) -> PredicateObligations<'tcx> { - self.obligations - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs 2018-12-04 23:41:40.000000000 +0000 @@ -17,6 +17,7 @@ //! types, instead of all variables. use borrow_check::nll::ToRegionVid; +use borrow_check::nll::facts::{AllFacts, AllFactsExt}; use rustc::mir::{Local, Mir}; use rustc::ty::{RegionVid, TyCtxt}; use rustc_data_structures::fx::FxHashSet; @@ -61,12 +62,13 @@ mir: &Mir<'tcx>, ) -> Self { let mut to_local = IndexVec::default(); + let facts_enabled = AllFacts::enabled(tcx); let from_local: IndexVec> = mir.local_decls .iter_enumerated() .map(|(local, local_decl)| { if tcx.all_free_regions_meet(&local_decl.ty, |r| { free_regions.contains(&r.to_region_vid()) - }) { + }) && !facts_enabled { // If all the regions in the type are free regions // (or there are no regions), then we don't need // to track liveness for this variable. diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use borrow_check::location::LocationTable; use borrow_check::nll::region_infer::values::RegionValueElements; use borrow_check::nll::constraints::ConstraintSet; use borrow_check::nll::NllLivenessMap; @@ -40,6 +41,7 @@ elements: &Rc, flow_inits: &mut FlowAtLocation>, move_data: &MoveData<'tcx>, + location_table: &LocationTable, ) { debug!("liveness::generate"); let free_regions = { @@ -51,7 +53,7 @@ ) }; let liveness_map = NllLivenessMap::compute(typeck.tcx(), &free_regions, mir); - trace::trace(typeck, mir, elements, flow_inits, move_data, &liveness_map); + trace::trace(typeck, mir, elements, flow_inits, move_data, &liveness_map, location_table); } /// Compute all regions that are (currently) known to outlive free diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,21 +8,22 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use borrow_check::location::LocationTable; use borrow_check::nll::region_infer::values::{self, PointIndex, RegionValueElements}; use borrow_check::nll::type_check::liveness::liveness_map::{LiveVar, NllLivenessMap}; use borrow_check::nll::type_check::liveness::local_use_map::LocalUseMap; -use borrow_check::nll::type_check::AtLocation; +use borrow_check::nll::type_check::NormalizeLocation; use borrow_check::nll::type_check::TypeChecker; use dataflow::move_paths::indexes::MovePathIndex; use dataflow::move_paths::MoveData; use dataflow::{FlowAtLocation, FlowsAtLocation, MaybeInitializedPlaces}; use rustc::infer::canonical::QueryRegionConstraint; -use rustc::mir::{BasicBlock, Local, Location, Mir}; +use rustc::mir::{BasicBlock, ConstraintCategory, Local, Location, Mir}; use rustc::traits::query::dropck_outlives::DropckOutlivesResult; use rustc::traits::query::type_op::outlives::DropckOutlives; use rustc::traits::query::type_op::TypeOp; use rustc::ty::{Ty, TypeFoldable}; -use rustc_data_structures::bitvec::BitArray; +use rustc_data_structures::bit_set::HybridBitSet; use rustc_data_structures::fx::FxHashMap; use std::rc::Rc; use util::liveness::LiveVariableMap; @@ -48,6 +49,7 @@ flow_inits: &mut FlowAtLocation>, move_data: &MoveData<'tcx>, liveness_map: &NllLivenessMap, + location_table: &LocationTable, ) { debug!("trace()"); @@ -66,6 +68,7 @@ move_data, liveness_map, drop_data: FxHashMap::default(), + location_table, }; LivenessResults::new(cx).compute_for_all_locals(); @@ -104,6 +107,9 @@ /// Map tracking which variables need liveness computation. liveness_map: &'me NllLivenessMap, + + /// Maps between a MIR Location and a LocationIndex + location_table: &'me LocationTable, } struct DropData<'tcx> { @@ -121,16 +127,16 @@ cx: LivenessContext<'me, 'typeck, 'flow, 'gcx, 'tcx>, /// Set of points that define the current local. - defs: BitArray, + defs: HybridBitSet, /// Points where the current variable is "use live" -- meaning /// that there is a future "full use" that may use its value. - use_live_at: BitArray, + use_live_at: HybridBitSet, /// Points where the current variable is "drop live" -- meaning /// that there is no future "full use" that may use its value, but /// there is a future drop. - drop_live_at: BitArray, + drop_live_at: HybridBitSet, /// Locations where drops may occur. drop_locations: Vec, @@ -144,9 +150,9 @@ let num_points = cx.elements.num_points(); LivenessResults { cx, - defs: BitArray::new(num_points), - use_live_at: BitArray::new(num_points), - drop_live_at: BitArray::new(num_points), + defs: HybridBitSet::new_empty(num_points), + use_live_at: HybridBitSet::new_empty(num_points), + drop_live_at: HybridBitSet::new_empty(num_points), drop_locations: vec![], stack: vec![], } @@ -448,11 +454,17 @@ fn add_use_live_facts_for( &mut self, value: impl TypeFoldable<'tcx>, - live_at: &BitArray, + live_at: &HybridBitSet, ) { debug!("add_use_live_facts_for(value={:?})", value); - Self::make_all_regions_live(self.elements, &mut self.typeck, value, live_at) + Self::make_all_regions_live( + self.elements, + &mut self.typeck, + value, + live_at, + self.location_table, + ) } /// Some variable with type `live_ty` is "drop live" at `location` @@ -465,7 +477,7 @@ dropped_local: Local, dropped_ty: Ty<'tcx>, drop_locations: &[Location], - live_at: &BitArray, + live_at: &HybridBitSet, ) { debug!( "add_drop_live_constraint(\ @@ -487,7 +499,11 @@ if let Some(data) = &drop_data.region_constraint_data { for &drop_location in drop_locations { self.typeck - .push_region_constraints(drop_location.boring(), data); + .push_region_constraints( + drop_location.to_locations(), + ConstraintCategory::Boring, + data, + ); } } @@ -500,7 +516,13 @@ // All things in the `outlives` array may be touched by // the destructor and must be live at this point. for &kind in &drop_data.dropck_result.kinds { - Self::make_all_regions_live(self.elements, &mut self.typeck, kind, live_at); + Self::make_all_regions_live( + self.elements, + &mut self.typeck, + kind, + live_at, + self.location_table, + ); } } @@ -508,7 +530,8 @@ elements: &RegionValueElements, typeck: &mut TypeChecker<'_, '_, 'tcx>, value: impl TypeFoldable<'tcx>, - live_at: &BitArray, + live_at: &HybridBitSet, + location_table: &LocationTable, ) { debug!("make_all_regions_live(value={:?})", value); debug!( @@ -527,8 +550,12 @@ .liveness_constraints .add_elements(live_region_vid, live_at); - if let Some(_) = borrowck_context.all_facts { - bug!("polonius liveness facts not implemented yet") + if let Some(facts) = borrowck_context.all_facts { + for point in live_at.iter() { + let loc = elements.to_location(point); + facts.region_live_at.push((live_region_vid, location_table.start_index(loc))); + facts.region_live_at.push((live_region_vid, location_table.mid_index(loc))); + } } }); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,12 +15,15 @@ use borrow_check::location::LocationTable; use borrow_check::nll::constraints::{ConstraintSet, OutlivesConstraint}; use borrow_check::nll::facts::AllFacts; -use borrow_check::nll::region_infer::values::{LivenessValues, RegionValueElements}; +use borrow_check::nll::region_infer::values::LivenessValues; +use borrow_check::nll::region_infer::values::PlaceholderIndices; +use borrow_check::nll::region_infer::values::RegionValueElements; use borrow_check::nll::region_infer::{ClosureRegionRequirementsExt, TypeTest}; +use borrow_check::nll::renumber; use borrow_check::nll::type_check::free_region_relations::{ CreateResult, UniversalRegionRelations, }; -use borrow_check::nll::universal_regions::UniversalRegions; +use borrow_check::nll::universal_regions::{DefiningTy, UniversalRegions}; use borrow_check::nll::ToRegionVid; use dataflow::move_paths::MoveData; use dataflow::FlowAtLocation; @@ -28,22 +31,26 @@ use rustc::hir; use rustc::hir::def_id::DefId; use rustc::infer::canonical::QueryRegionConstraint; -use rustc::infer::region_constraints::GenericKind; -use rustc::infer::{InferCtxt, LateBoundRegionConversionTime}; +use rustc::infer::outlives::env::RegionBoundPairs; +use rustc::infer::{InferCtxt, InferOk, LateBoundRegionConversionTime}; use rustc::mir::interpret::EvalErrorKind::BoundsCheck; use rustc::mir::tcx::PlaceTy; -use rustc::mir::visit::{PlaceContext, Visitor}; +use rustc::mir::visit::{PlaceContext, Visitor, MutatingUseContext, NonMutatingUseContext}; use rustc::mir::*; use rustc::traits::query::type_op; +use rustc::traits::query::type_op::custom::CustomTypeOp; use rustc::traits::query::{Fallible, NoSolution}; +use rustc::traits::{ObligationCause, PredicateObligations}; use rustc::ty::fold::TypeFoldable; -use rustc::ty::{self, CanonicalTy, RegionVid, ToPolyTraitRef, Ty, TyCtxt, TyKind}; -use std::fmt; +use rustc::ty::subst::{Subst, Substs, UnpackedKind}; +use rustc::ty::{self, RegionVid, ToPolyTraitRef, Ty, TyCtxt, TyKind}; use std::rc::Rc; +use std::{fmt, iter}; use syntax_pos::{Span, DUMMY_SP}; use transform::{MirPass, MirSource}; -use rustc_data_structures::fx::FxHashSet; +use either::Either; +use rustc_data_structures::fx::{FxHashMap, FxHashSet}; macro_rules! span_mirbug { ($context:expr, $elem:expr, $($message:tt)*) => ({ @@ -98,7 +105,7 @@ /// to outlive; should represent the fn body /// - `input_tys` -- fully liberated, but **not** normalized, expected types of the arguments; /// the types of the input parameters found in the MIR itself will be equated with these -/// - `output_ty` -- fully liberaetd, but **not** normalized, expected return type; +/// - `output_ty` -- fully liberated, but **not** normalized, expected return type; /// the type for the RETURN_PLACE will be equated with this /// - `liveness` -- results of a liveness computation on the MIR; used to create liveness /// constraints for the regions in the types of variables @@ -121,8 +128,10 @@ let mut constraints = MirTypeckRegionConstraints { liveness_constraints: LivenessValues::new(elements), outlives_constraints: ConstraintSet::default(), + closure_bounds_mapping: Default::default(), type_tests: Vec::default(), }; + let mut placeholder_indices = PlaceholderIndices::default(); let CreateResult { universal_region_relations, @@ -131,45 +140,42 @@ } = free_region_relations::create( infcx, param_env, - location_table, Some(implicit_region_bound), universal_regions, &mut constraints, - all_facts, ); - { - let mut borrowck_context = BorrowCheckContext { - universal_regions, - location_table, - borrow_set, - all_facts, - constraints: &mut constraints, - }; + let mut borrowck_context = BorrowCheckContext { + universal_regions, + location_table, + borrow_set, + all_facts, + constraints: &mut constraints, + placeholder_indices: &mut placeholder_indices, + }; - type_check_internal( - infcx, - mir_def_id, - param_env, - mir, - ®ion_bound_pairs, - Some(implicit_region_bound), - Some(&mut borrowck_context), - |cx| { - cx.equate_inputs_and_outputs( - mir, - mir_def_id, - universal_regions, - &universal_region_relations, - &normalized_inputs_and_output, - ); - liveness::generate(cx, mir, elements, flow_inits, move_data); - }, - ); - } + type_check_internal( + infcx, + mir_def_id, + param_env, + mir, + ®ion_bound_pairs, + Some(implicit_region_bound), + Some(&mut borrowck_context), + Some(&universal_region_relations), + |cx| { + cx.equate_inputs_and_outputs(mir, universal_regions, &normalized_inputs_and_output); + liveness::generate(cx, mir, elements, flow_inits, move_data, location_table); + + cx.borrowck_context + .as_mut() + .map(|bcx| translate_outlives_facts(bcx)); + }, + ); MirTypeckResults { constraints, + placeholder_indices, universal_region_relations, } } @@ -179,9 +185,10 @@ mir_def_id: DefId, param_env: ty::ParamEnv<'gcx>, mir: &'a Mir<'tcx>, - region_bound_pairs: &'a [(ty::Region<'tcx>, GenericKind<'tcx>)], + region_bound_pairs: &'a RegionBoundPairs<'tcx>, implicit_region_bound: Option>, borrowck_context: Option<&'a mut BorrowCheckContext<'a, 'tcx>>, + universal_region_relations: Option<&'a UniversalRegionRelations<'tcx>>, mut extra: impl FnMut(&mut TypeChecker<'a, 'gcx, 'tcx>) -> R, ) -> R where { let mut checker = TypeChecker::new( @@ -192,6 +199,7 @@ region_bound_pairs, implicit_region_bound, borrowck_context, + universal_region_relations, ); let errors_reported = { let mut verifier = TypeVerifier::new(&mut checker, mir); @@ -207,6 +215,31 @@ extra(&mut checker) } +fn translate_outlives_facts(cx: &mut BorrowCheckContext) { + if let Some(facts) = cx.all_facts { + let location_table = cx.location_table; + facts + .outlives + .extend(cx.constraints.outlives_constraints.iter().flat_map( + |constraint: &OutlivesConstraint| { + if let Some(from_location) = constraint.locations.from_location() { + Either::Left(iter::once(( + constraint.sup, + constraint.sub, + location_table.mid_index(from_location), + ))) + } else { + Either::Right( + location_table + .all_points() + .map(move |location| (constraint.sup, constraint.sub, location)), + ) + } + }, + )); + } +} + fn mirbug(tcx: TyCtxt, span: Span, msg: &str) { // We sometimes see MIR failures (notably predicate failures) due to // the fact that we check rvalue sized predicates here. So use `delay_span_bug` @@ -251,8 +284,9 @@ if let Err(terr) = self.cx.relate_type_and_user_type( constant.ty, ty::Variance::Invariant, - user_ty, - location.boring(), + &UserTypeProjection { base: user_ty, projs: vec![], }, + location.to_locations(), + ConstraintCategory::Boring, ) { span_mirbug!( self, @@ -276,12 +310,13 @@ self.super_local_decl(local, local_decl); self.sanitize_type(local_decl, local_decl.ty); - if let Some(user_ty) = local_decl.user_ty { + for (user_ty, span) in local_decl.user_ty.projections_and_spans() { if let Err(terr) = self.cx.relate_type_and_user_type( local_decl.ty, ty::Variance::Invariant, user_ty, - Locations::All, + Locations::All(*span), + ConstraintCategory::TypeAnnotation, ) { span_mirbug!( self, @@ -364,15 +399,18 @@ let instantiated_predicates = tcx.predicates_of(def_id).instantiate(tcx, substs); type_checker.normalize_and_prove_instantiated_predicates( instantiated_predicates, - location.boring(), + location.to_locations(), ); } debug!("sanitize_constant: expected_ty={:?}", constant.literal.ty); - if let Err(terr) = self.cx - .eq_types(constant.literal.ty, constant.ty, location.boring()) - { + if let Err(terr) = self.cx.eq_types( + constant.literal.ty, + constant.ty, + location.to_locations(), + ConstraintCategory::Boring, + ) { span_mirbug!( self, constant, @@ -417,7 +455,10 @@ let sty = self.sanitize_type(place, sty); let ty = self.tcx().type_of(def_id); let ty = self.cx.normalize(ty, location); - if let Err(terr) = self.cx.eq_types(ty, sty, location.boring()) { + if let Err(terr) = + self.cx + .eq_types(ty, sty, location.to_locations(), ConstraintCategory::Boring) + { span_mirbug!( self, place, @@ -431,9 +472,9 @@ } Place::Projection(ref proj) => { let base_context = if context.is_mutating_use() { - PlaceContext::Projection(Mutability::Mut) + PlaceContext::MutatingUse(MutatingUseContext::Projection) } else { - PlaceContext::Projection(Mutability::Not) + PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection) }; let base_ty = self.sanitize_place(&proj.base, location, base_context); if let PlaceTy::Ty { ty } = base_ty { @@ -447,7 +488,7 @@ self.sanitize_projection(base_ty, &proj.elem, place, location) } }; - if let PlaceContext::Copy = context { + if let PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) = context { let tcx = self.tcx(); let trait_ref = ty::TraitRef { def_id: tcx.lang_items().copy_trait().unwrap(), @@ -461,7 +502,11 @@ // (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.interesting()); + self.cx.prove_trait_ref( + trait_ref, + location.to_locations(), + ConstraintCategory::CopyBound, + ); } place_ty } @@ -560,7 +605,12 @@ ProjectionElem::Field(field, fty) => { let fty = self.sanitize_type(place, fty); match self.field_ty(place, base, field, location) { - Ok(ty) => if let Err(terr) = self.cx.eq_types(ty, fty, location.boring()) { + Ok(ty) => if let Err(terr) = self.cx.eq_types( + ty, + fty, + location.to_locations(), + ConstraintCategory::Boring, + ) { span_mirbug!( self, place, @@ -667,10 +717,11 @@ last_span: Span, mir: &'a Mir<'tcx>, mir_def_id: DefId, - region_bound_pairs: &'a [(ty::Region<'tcx>, GenericKind<'tcx>)], + region_bound_pairs: &'a RegionBoundPairs<'tcx>, implicit_region_bound: Option>, reported_errors: FxHashSet<(Ty<'tcx>, Span)>, borrowck_context: Option<&'a mut BorrowCheckContext<'a, 'tcx>>, + universal_region_relations: Option<&'a UniversalRegionRelations<'tcx>>, } struct BorrowCheckContext<'a, 'tcx: 'a> { @@ -679,10 +730,12 @@ all_facts: &'a mut Option, borrow_set: &'a BorrowSet<'tcx>, constraints: &'a mut MirTypeckRegionConstraints<'tcx>, + placeholder_indices: &'a mut PlaceholderIndices, } crate struct MirTypeckResults<'tcx> { crate constraints: MirTypeckRegionConstraints<'tcx>, + crate placeholder_indices: PlaceholderIndices, crate universal_region_relations: Rc>, } @@ -700,6 +753,9 @@ crate outlives_constraints: ConstraintSet, + crate closure_bounds_mapping: + FxHashMap>, + crate type_tests: Vec>, } @@ -740,43 +796,32 @@ /// user-given type annotations; e.g., if the user wrote `let mut /// x: &'static u32 = ...`, we would ensure that all values /// assigned to `x` are of `'static` lifetime. - All, - - /// A "boring" constraint (caused by the given location) is one that - /// the user probably doesn't want to see described in diagnostics, - /// because it is kind of an artifact of the type system setup. /// - /// Example: `x = Foo { field: y }` technically creates - /// intermediate regions representing the "type of `Foo { field: y - /// }`", and data flows from `y` into those variables, but they - /// are not very interesting. The assignment into `x` on the other - /// hand might be. - Boring(Location), - - /// An *important* outlives constraint (caused by the given - /// location) is one that would be useful to highlight in - /// diagnostics, because it represents a point where references - /// flow from one spot to another (e.g., `x = y`) - Interesting(Location), + /// The span points to the place the constraint arose. For example, + /// it points to the type in a user-given type annotation. If + /// there's no sensible span then it's DUMMY_SP. + All(Span), + + /// An outlives constraint that only has to hold at a single location, + /// usually it represents a point where references flow from one spot to + /// another (e.g., `x = y`) + Single(Location), } impl Locations { pub fn from_location(&self) -> Option { match self { - Locations::All => None, - Locations::Boring(from_location) | Locations::Interesting(from_location) => { - Some(*from_location) - } + Locations::All(_) => None, + Locations::Single(from_location) => Some(*from_location), } } /// Gets a span representing the location. pub fn span(&self, mir: &Mir<'_>) -> Span { - let span_location = match self { - Locations::All => Location::START, - Locations::Boring(l) | Locations::Interesting(l) => *l, - }; - mir.source_info(span_location).span + match self { + Locations::All(span) => *span, + Locations::Single(l) => mir.source_info(*l).span, + } } } @@ -786,9 +831,10 @@ mir: &'a Mir<'tcx>, mir_def_id: DefId, param_env: ty::ParamEnv<'gcx>, - region_bound_pairs: &'a [(ty::Region<'tcx>, GenericKind<'tcx>)], + region_bound_pairs: &'a RegionBoundPairs<'tcx>, implicit_region_bound: Option>, borrowck_context: Option<&'a mut BorrowCheckContext<'a, 'tcx>>, + universal_region_relations: Option<&'a UniversalRegionRelations<'tcx>>, ) -> Self { TypeChecker { infcx, @@ -799,7 +845,8 @@ region_bound_pairs, implicit_region_bound, borrowck_context, - reported_errors: FxHashSet(), + reported_errors: Default::default(), + universal_region_relations, } } @@ -816,12 +863,13 @@ fn fully_perform_op( &mut self, locations: Locations, + category: ConstraintCategory, op: impl type_op::TypeOp<'gcx, 'tcx, Output = R>, ) -> Fallible { let (r, opt_data) = op.fully_perform(self.infcx)?; if let Some(data) = &opt_data { - self.push_region_constraints(locations, data); + self.push_region_constraints(locations, category, data); } Ok(r) @@ -830,6 +878,7 @@ fn push_region_constraints( &mut self, locations: Locations, + category: ConstraintCategory, data: &[QueryRegionConstraint<'tcx>], ) { debug!( @@ -841,53 +890,264 @@ constraint_conversion::ConstraintConversion::new( self.infcx.tcx, borrowck_context.universal_regions, - borrowck_context.location_table, self.region_bound_pairs, self.implicit_region_bound, self.param_env, locations, + category, &mut borrowck_context.constraints.outlives_constraints, &mut borrowck_context.constraints.type_tests, - &mut borrowck_context.all_facts, ).convert_all(&data); } } - fn sub_types(&mut self, sub: Ty<'tcx>, sup: Ty<'tcx>, locations: Locations) -> Fallible<()> { - relate_tys::sub_types( - self.infcx, - sub, - sup, - locations, - self.borrowck_context.as_mut().map(|x| &mut **x), - ) - } - - fn eq_types(&mut self, a: Ty<'tcx>, b: Ty<'tcx>, locations: Locations) -> Fallible<()> { - relate_tys::eq_types( + /// Convenient wrapper around `relate_tys::relate_types` -- see + /// that fn for docs. + fn relate_types( + &mut self, + a: Ty<'tcx>, + v: ty::Variance, + b: Ty<'tcx>, + locations: Locations, + category: ConstraintCategory, + ) -> Fallible<()> { + relate_tys::relate_types( self.infcx, a, + v, b, locations, + category, self.borrowck_context.as_mut().map(|x| &mut **x), ) } + fn sub_types( + &mut self, + sub: Ty<'tcx>, + sup: Ty<'tcx>, + locations: Locations, + category: ConstraintCategory, + ) -> Fallible<()> { + self.relate_types(sub, ty::Variance::Covariant, sup, locations, category) + } + + /// Try to relate `sub <: sup`; if this fails, instantiate opaque + /// variables in `sub` with their inferred definitions and try + /// again. This is used for opaque types in places (e.g., `let x: + /// impl Foo = ..`). + fn sub_types_or_anon( + &mut self, + sub: Ty<'tcx>, + sup: Ty<'tcx>, + locations: Locations, + category: ConstraintCategory, + ) -> Fallible<()> { + if let Err(terr) = self.sub_types(sub, sup, locations, category) { + if let TyKind::Opaque(..) = sup.sty { + // When you have `let x: impl Foo = ...` in a closure, + // the resulting inferend values are stored with the + // def-id of the base function. + let parent_def_id = self.tcx().closure_base_def_id(self.mir_def_id); + return self.eq_opaque_type_and_type(sub, sup, parent_def_id, locations, category); + } else { + return Err(terr); + } + } + Ok(()) + } + + fn eq_types( + &mut self, + a: Ty<'tcx>, + b: Ty<'tcx>, + locations: Locations, + category: ConstraintCategory, + ) -> Fallible<()> { + self.relate_types(a, ty::Variance::Invariant, b, locations, category) + } + fn relate_type_and_user_type( &mut self, a: Ty<'tcx>, v: ty::Variance, - b: CanonicalTy<'tcx>, + user_ty: &UserTypeProjection<'tcx>, locations: Locations, + category: ConstraintCategory, ) -> Fallible<()> { - relate_tys::relate_type_and_user_type( - self.infcx, - a, - v, - b, + debug!( + "relate_type_and_user_type(a={:?}, v={:?}, user_ty={:?}, locations={:?})", + a, v, user_ty, locations, + ); + + match user_ty.base { + UserTypeAnnotation::Ty(canonical_ty) => { + let (ty, _) = self.infcx + .instantiate_canonical_with_fresh_inference_vars(DUMMY_SP, &canonical_ty); + + // The `TypeRelating` code assumes that "unresolved inference + // variables" appear in the "a" side, so flip `Contravariant` + // ambient variance to get the right relationship. + let v1 = ty::Contravariant.xform(v); + + let tcx = self.infcx.tcx; + let ty = self.normalize(ty, locations); + + // We need to follow any provided projetions into the type. + // + // if we hit a ty var as we descend, then just skip the + // attempt to relate the mir local with any type. + #[derive(Debug)] struct HitTyVar; + let mut curr_projected_ty: Result; + + curr_projected_ty = Ok(PlaceTy::from_ty(ty)); + for proj in &user_ty.projs { + let projected_ty = if let Ok(projected_ty) = curr_projected_ty { + projected_ty + } else { + break; + }; + curr_projected_ty = projected_ty.projection_ty_core( + tcx, proj, |this, field, &()| { + if this.to_ty(tcx).is_ty_var() { + Err(HitTyVar) + } else { + let ty = this.field_ty(tcx, field); + Ok(self.normalize(ty, locations)) + } + }); + } + debug!("user_ty base: {:?} freshened: {:?} projs: {:?} yields: {:?}", + user_ty.base, ty, user_ty.projs, curr_projected_ty); + + if let Ok(projected_ty) = curr_projected_ty { + let ty = projected_ty.to_ty(tcx); + self.relate_types(ty, v1, a, locations, category)?; + } + } + UserTypeAnnotation::TypeOf(def_id, canonical_substs) => { + let ( + user_substs, + _, + ) = self.infcx + .instantiate_canonical_with_fresh_inference_vars(DUMMY_SP, &canonical_substs); + + let projs = self.infcx.tcx.intern_projs(&user_ty.projs); + self.fully_perform_op( + locations, + category, + self.param_env.and(type_op::ascribe_user_type::AscribeUserType::new( + a, v, def_id, user_substs, projs, + )), + )?; + } + } + + Ok(()) + } + + fn eq_opaque_type_and_type( + &mut self, + revealed_ty: Ty<'tcx>, + anon_ty: Ty<'tcx>, + anon_owner_def_id: DefId, + locations: Locations, + category: ConstraintCategory, + ) -> Fallible<()> { + debug!( + "eq_opaque_type_and_type( \ + revealed_ty={:?}, \ + anon_ty={:?})", + revealed_ty, anon_ty + ); + let infcx = self.infcx; + let tcx = infcx.tcx; + let param_env = self.param_env; + debug!("eq_opaque_type_and_type: mir_def_id={:?}", self.mir_def_id); + let opaque_type_map = self.fully_perform_op( locations, - self.borrowck_context.as_mut().map(|x| &mut **x), - ) + category, + CustomTypeOp::new( + |infcx| { + let mut obligations = ObligationAccumulator::default(); + + let dummy_body_id = ObligationCause::dummy().body_id; + let (output_ty, opaque_type_map) = + obligations.add(infcx.instantiate_opaque_types( + anon_owner_def_id, + dummy_body_id, + param_env, + &anon_ty, + )); + debug!( + "eq_opaque_type_and_type: \ + instantiated output_ty={:?} \ + opaque_type_map={:#?} \ + revealed_ty={:?}", + output_ty, opaque_type_map, revealed_ty + ); + obligations.add(infcx + .at(&ObligationCause::dummy(), param_env) + .eq(output_ty, revealed_ty)?); + + for (&opaque_def_id, opaque_decl) in &opaque_type_map { + let opaque_defn_ty = tcx.type_of(opaque_def_id); + let opaque_defn_ty = opaque_defn_ty.subst(tcx, opaque_decl.substs); + let opaque_defn_ty = renumber::renumber_regions(infcx, &opaque_defn_ty); + debug!( + "eq_opaque_type_and_type: concrete_ty={:?}={:?} opaque_defn_ty={:?}", + opaque_decl.concrete_ty, + infcx.resolve_type_vars_if_possible(&opaque_decl.concrete_ty), + opaque_defn_ty + ); + obligations.add(infcx + .at(&ObligationCause::dummy(), param_env) + .eq(opaque_decl.concrete_ty, opaque_defn_ty)?); + } + + debug!("eq_opaque_type_and_type: equated"); + + Ok(InferOk { + value: Some(opaque_type_map), + obligations: obligations.into_vec(), + }) + }, + || "input_output".to_string(), + ), + )?; + + let universal_region_relations = match self.universal_region_relations { + Some(rel) => rel, + None => return Ok(()), + }; + + // Finally, if we instantiated the anon types successfully, we + // have to solve any bounds (e.g., `-> impl Iterator` needs to + // prove that `T: Iterator` where `T` is the type we + // instantiated it with). + if let Some(opaque_type_map) = opaque_type_map { + for (opaque_def_id, opaque_decl) in opaque_type_map { + self.fully_perform_op( + locations, + ConstraintCategory::OpaqueType, + CustomTypeOp::new( + |_cx| { + infcx.constrain_opaque_type( + opaque_def_id, + &opaque_decl, + universal_region_relations, + ); + Ok(InferOk { + value: (), + obligations: vec![], + }) + }, + || "opaque_type_map".to_string(), + ), + )?; + } + } + Ok(()) } fn tcx(&self) -> TyCtxt<'a, 'gcx, 'tcx> { @@ -903,21 +1163,35 @@ // they are not caused by the user, but rather artifacts // of lowering. Assignments to other sorts of places *are* interesting // though. - let is_temp = if let Place::Local(l) = *place { - l != RETURN_PLACE && !mir.local_decls[l].is_user_variable.is_some() - } else { - false - }; - - let locations = if is_temp { - location.boring() - } else { - location.interesting() + let category = match *place { + Place::Local(RETURN_PLACE) => if let Some(BorrowCheckContext { + universal_regions: + UniversalRegions { + defining_ty: DefiningTy::Const(def_id, _), + .. + }, + .. + }) = self.borrowck_context + { + if tcx.is_static(*def_id).is_some() { + ConstraintCategory::UseAsStatic + } else { + ConstraintCategory::UseAsConst + } + } else { + ConstraintCategory::Return + }, + Place::Local(l) if !mir.local_decls[l].is_user_variable.is_some() => { + ConstraintCategory::Boring + } + _ => ConstraintCategory::Assignment, }; let place_ty = place.ty(mir, tcx).to_ty(tcx); let rv_ty = rv.ty(mir, tcx); - if let Err(terr) = self.sub_types(rv_ty, place_ty, locations) { + if let Err(terr) = + self.sub_types_or_anon(rv_ty, place_ty, location.to_locations(), category) + { span_mirbug!( self, stmt, @@ -932,8 +1206,9 @@ if let Err(terr) = self.relate_type_and_user_type( rv_ty, ty::Variance::Invariant, - user_ty, - location.boring(), + &UserTypeProjection { base: user_ty, projs: vec![], }, + location.to_locations(), + ConstraintCategory::Boring, ) { span_mirbug!( self, @@ -952,7 +1227,11 @@ def_id: tcx.lang_items().sized_trait().unwrap(), substs: tcx.mk_substs_trait(place_ty, &[]), }; - self.prove_trait_ref(trait_ref, location.interesting()); + self.prove_trait_ref( + trait_ref, + location.to_locations(), + ConstraintCategory::SizedBound, + ); } } StatementKind::SetDiscriminant { @@ -980,11 +1259,15 @@ ); }; } - StatementKind::AscribeUserType(ref place, variance, c_ty) => { + StatementKind::AscribeUserType(ref place, variance, box ref c_ty) => { let place_ty = place.ty(mir, tcx).to_ty(tcx); - if let Err(terr) = - self.relate_type_and_user_type(place_ty, variance, c_ty, Locations::All) - { + if let Err(terr) = self.relate_type_and_user_type( + place_ty, + variance, + c_ty, + Locations::All(stmt.source_info.span), + ConstraintCategory::TypeAnnotation, + ) { span_mirbug!( self, stmt, @@ -995,7 +1278,7 @@ ); } } - StatementKind::ReadForMatch(_) + StatementKind::FakeRead(..) | StatementKind::StorageLive(_) | StatementKind::StorageDead(_) | StatementKind::InlineAsm { .. } @@ -1035,8 +1318,10 @@ let place_ty = location.ty(mir, tcx).to_ty(tcx); let rv_ty = value.ty(mir, tcx); - let locations = term_location.interesting(); - if let Err(terr) = self.sub_types(rv_ty, place_ty, locations) { + let locations = term_location.to_locations(); + if let Err(terr) = + self.sub_types(rv_ty, place_ty, locations, ConstraintCategory::Assignment) + { span_mirbug!( self, term, @@ -1053,7 +1338,12 @@ .. } => { let discr_ty = discr.ty(mir, tcx); - if let Err(terr) = self.sub_types(discr_ty, switch_ty, term_location.boring()) { + if let Err(terr) = self.sub_types( + discr_ty, + switch_ty, + term_location.to_locations(), + ConstraintCategory::Assignment, + ) { span_mirbug!( self, term, @@ -1072,6 +1362,7 @@ ref func, ref args, ref destination, + from_hir_call, .. } => { let func_ty = func.ty(mir, tcx); @@ -1093,7 +1384,8 @@ self.prove_predicates( sig.inputs().iter().map(|ty| ty::Predicate::WellFormed(ty)), - term_location.boring(), + term_location.to_locations(), + ConstraintCategory::Boring, ); // The ordinary liveness rules will ensure that all @@ -1115,7 +1407,7 @@ } } - self.check_call_inputs(mir, term, &sig, args, term_location); + self.check_call_inputs(mir, term, &sig, args, term_location, from_hir_call); } TerminatorKind::Assert { ref cond, ref msg, .. @@ -1139,8 +1431,12 @@ match mir.yield_ty { None => span_mirbug!(self, term, "yield in non-generator"), Some(ty) => { - if let Err(terr) = self.sub_types(value_ty, ty, term_location.interesting()) - { + if let Err(terr) = self.sub_types( + value_ty, + ty, + term_location.to_locations(), + ConstraintCategory::Return, + ) { span_mirbug!( self, term, @@ -1168,19 +1464,37 @@ match *destination { Some((ref dest, _target_block)) => { let dest_ty = dest.ty(mir, tcx).to_ty(tcx); - let is_temp = if let Place::Local(l) = *dest { - l != RETURN_PLACE && !mir.local_decls[l].is_user_variable.is_some() - } else { - false + let category = match *dest { + Place::Local(RETURN_PLACE) => { + if let Some(BorrowCheckContext { + universal_regions: + UniversalRegions { + defining_ty: DefiningTy::Const(def_id, _), + .. + }, + .. + }) = self.borrowck_context + { + if tcx.is_static(*def_id).is_some() { + ConstraintCategory::UseAsStatic + } else { + ConstraintCategory::UseAsConst + } + } else { + ConstraintCategory::Return + } + } + Place::Local(l) if !mir.local_decls[l].is_user_variable.is_some() => { + ConstraintCategory::Boring + } + _ => ConstraintCategory::Assignment, }; - let locations = if is_temp { - term_location.boring() - } else { - term_location.interesting() - }; + let locations = term_location.to_locations(); - if let Err(terr) = self.sub_types(sig.output(), dest_ty, locations) { + if let Err(terr) = + self.sub_types_or_anon(sig.output(), dest_ty, locations, category) + { span_mirbug!( self, term, @@ -1214,6 +1528,7 @@ sig: &ty::FnSig<'tcx>, args: &[Operand<'tcx>], term_location: Location, + from_hir_call: bool, ) { debug!("check_call_inputs({:?}, {:?})", sig, args); if args.len() < sig.inputs().len() || (args.len() > sig.inputs().len() && !sig.variadic) { @@ -1221,7 +1536,14 @@ } for (n, (fn_arg, op_arg)) in sig.inputs().iter().zip(args).enumerate() { let op_arg_ty = op_arg.ty(mir, self.tcx()); - if let Err(terr) = self.sub_types(op_arg_ty, fn_arg, term_location.interesting()) { + let category = if from_hir_call { + ConstraintCategory::CallArgument + } else { + ConstraintCategory::Boring + }; + if let Err(terr) = + self.sub_types(op_arg_ty, fn_arg, term_location.to_locations(), category) + { span_mirbug!( self, term, @@ -1343,12 +1665,7 @@ } } - fn check_local( - &mut self, - mir: &Mir<'tcx>, - local: Local, - local_decl: &LocalDecl<'tcx>, - ) { + fn check_local(&mut self, mir: &Mir<'tcx>, local: Local, local_decl: &LocalDecl<'tcx>) { match mir.local_kind(local) { LocalKind::ReturnPointer | LocalKind::Arg => { // return values of normal functions are required to be @@ -1470,7 +1787,11 @@ substs: tcx.mk_substs_trait(operand_ty, &[]), }; - self.prove_trait_ref(trait_ref, location.interesting()); + self.prove_trait_ref( + trait_ref, + location.to_locations(), + ConstraintCategory::CopyBound, + ); }, Rvalue::NullaryOp(_, ty) => { @@ -1485,91 +1806,116 @@ substs: tcx.mk_substs_trait(ty, &[]), }; - self.prove_trait_ref(trait_ref, location.interesting()); + self.prove_trait_ref( + trait_ref, + location.to_locations(), + ConstraintCategory::SizedBound, + ); } - Rvalue::Cast(cast_kind, op, ty) => match cast_kind { - CastKind::ReifyFnPointer => { - let fn_sig = op.ty(mir, tcx).fn_sig(tcx); - - // The type that we see in the fcx is like - // `foo::<'a, 'b>`, where `foo` is the path to a - // function definition. When we extract the - // signature, it comes from the `fn_sig` query, - // and hence may contain unnormalized results. - let fn_sig = self.normalize(fn_sig, location); + Rvalue::Cast(cast_kind, op, ty) => { + match cast_kind { + CastKind::ReifyFnPointer => { + let fn_sig = op.ty(mir, tcx).fn_sig(tcx); + + // The type that we see in the fcx is like + // `foo::<'a, 'b>`, where `foo` is the path to a + // function definition. When we extract the + // signature, it comes from the `fn_sig` query, + // and hence may contain unnormalized results. + let fn_sig = self.normalize(fn_sig, location); - let ty_fn_ptr_from = tcx.mk_fn_ptr(fn_sig); + let ty_fn_ptr_from = tcx.mk_fn_ptr(fn_sig); - if let Err(terr) = self.eq_types(ty_fn_ptr_from, ty, location.interesting()) { - span_mirbug!( - self, - rvalue, - "equating {:?} with {:?} yields {:?}", + if let Err(terr) = self.eq_types( ty_fn_ptr_from, ty, - terr - ); + location.to_locations(), + ConstraintCategory::Cast, + ) { + span_mirbug!( + self, + rvalue, + "equating {:?} with {:?} yields {:?}", + ty_fn_ptr_from, + ty, + terr + ); + } } - } - CastKind::ClosureFnPointer => { - let sig = match op.ty(mir, tcx).sty { - ty::Closure(def_id, substs) => { - substs.closure_sig_ty(def_id, tcx).fn_sig(tcx) - } - _ => bug!(), - }; - let ty_fn_ptr_from = tcx.coerce_closure_fn_ty(sig); + CastKind::ClosureFnPointer => { + let sig = match op.ty(mir, tcx).sty { + ty::Closure(def_id, substs) => { + substs.closure_sig_ty(def_id, tcx).fn_sig(tcx) + } + _ => bug!(), + }; + let ty_fn_ptr_from = tcx.coerce_closure_fn_ty(sig); - if let Err(terr) = self.eq_types(ty_fn_ptr_from, ty, location.interesting()) { - span_mirbug!( - self, - rvalue, - "equating {:?} with {:?} yields {:?}", + if let Err(terr) = self.eq_types( ty_fn_ptr_from, ty, - terr - ); + location.to_locations(), + ConstraintCategory::Cast, + ) { + span_mirbug!( + self, + rvalue, + "equating {:?} with {:?} yields {:?}", + ty_fn_ptr_from, + ty, + terr + ); + } } - } - CastKind::UnsafeFnPointer => { - let fn_sig = op.ty(mir, tcx).fn_sig(tcx); + CastKind::UnsafeFnPointer => { + let fn_sig = op.ty(mir, tcx).fn_sig(tcx); - // The type that we see in the fcx is like - // `foo::<'a, 'b>`, where `foo` is the path to a - // function definition. When we extract the - // signature, it comes from the `fn_sig` query, - // and hence may contain unnormalized results. - let fn_sig = self.normalize(fn_sig, location); + // The type that we see in the fcx is like + // `foo::<'a, 'b>`, where `foo` is the path to a + // function definition. When we extract the + // signature, it comes from the `fn_sig` query, + // and hence may contain unnormalized results. + let fn_sig = self.normalize(fn_sig, location); - let ty_fn_ptr_from = tcx.safe_to_unsafe_fn_ty(fn_sig); + let ty_fn_ptr_from = tcx.safe_to_unsafe_fn_ty(fn_sig); - if let Err(terr) = self.eq_types(ty_fn_ptr_from, ty, location.interesting()) { - span_mirbug!( - self, - rvalue, - "equating {:?} with {:?} yields {:?}", + if let Err(terr) = self.eq_types( ty_fn_ptr_from, ty, - terr - ); + location.to_locations(), + ConstraintCategory::Cast, + ) { + span_mirbug!( + self, + rvalue, + "equating {:?} with {:?} yields {:?}", + ty_fn_ptr_from, + ty, + terr + ); + } } - } - CastKind::Unsize => { - let &ty = ty; - let trait_ref = ty::TraitRef { - def_id: tcx.lang_items().coerce_unsized_trait().unwrap(), - substs: tcx.mk_substs_trait(op.ty(mir, tcx), &[ty.into()]), - }; + CastKind::Unsize => { + let &ty = ty; + let trait_ref = ty::TraitRef { + def_id: tcx.lang_items().coerce_unsized_trait().unwrap(), + substs: tcx.mk_substs_trait(op.ty(mir, tcx), &[ty.into()]), + }; - self.prove_trait_ref(trait_ref, location.interesting()); - } + self.prove_trait_ref( + trait_ref, + location.to_locations(), + ConstraintCategory::Cast, + ); + } - CastKind::Misc => {} - }, + CastKind::Misc => {} + } + } Rvalue::Ref(region, _borrow_kind, borrowed_place) => { self.add_reborrow_constraint(location, region, borrowed_place); @@ -1588,7 +1934,7 @@ /// If this rvalue supports a user-given type annotation, then /// extract and return it. This represents the final type of the /// rvalue and will be unified with the inferred type. - fn rvalue_user_ty(&self, rvalue: &Rvalue<'tcx>) -> Option> { + fn rvalue_user_ty(&self, rvalue: &Rvalue<'tcx>) -> Option> { match rvalue { Rvalue::Use(_) | Rvalue::Repeat(..) @@ -1644,7 +1990,12 @@ }; let operand_ty = operand.ty(mir, tcx); - if let Err(terr) = self.sub_types(operand_ty, field_ty, location.boring()) { + if let Err(terr) = self.sub_types( + operand_ty, + field_ty, + location.to_locations(), + ConstraintCategory::Boring, + ) { span_mirbug!( self, rvalue, @@ -1723,17 +2074,10 @@ constraints.outlives_constraints.push(OutlivesConstraint { sup: ref_region.to_region_vid(), sub: borrow_region.to_region_vid(), - locations: location.boring(), + locations: location.to_locations(), + category: ConstraintCategory::Boring, }); - if let Some(all_facts) = all_facts { - all_facts.outlives.push(( - ref_region.to_region_vid(), - borrow_region.to_region_vid(), - location_table.mid_index(location), - )); - } - match mutbl { hir::Mutability::MutImmutable => { // Immutable reference. We don't need the base @@ -1828,26 +2172,9 @@ // desugaring. A closure gets desugared to a struct, and // these extra requirements are basically like where // clauses on the struct. - AggregateKind::Closure(def_id, substs) => { - if let Some(closure_region_requirements) = - tcx.mir_borrowck(*def_id).closure_requirements - { - let closure_constraints = closure_region_requirements.apply_requirements( - self.infcx.tcx, - location, - *def_id, - *substs, - ); - - // Hmm, are these constraints *really* boring? - self.push_region_constraints(location.boring(), &closure_constraints); - } - - tcx.predicates_of(*def_id).instantiate(tcx, substs.substs) - } - - AggregateKind::Generator(def_id, substs, _) => { - tcx.predicates_of(*def_id).instantiate(tcx, substs.substs) + AggregateKind::Closure(def_id, ty::ClosureSubsts { substs }) + | AggregateKind::Generator(def_id, ty::GeneratorSubsts { substs }, _) => { + self.prove_closure_bounds(tcx, *def_id, substs, location) } AggregateKind::Array(_) | AggregateKind::Tuple => ty::InstantiatedPredicates::empty(), @@ -1855,16 +2182,83 @@ self.normalize_and_prove_instantiated_predicates( instantiated_predicates, - location.boring(), + location.to_locations(), ); } - fn prove_trait_ref(&mut self, trait_ref: ty::TraitRef<'tcx>, locations: Locations) { + fn prove_closure_bounds( + &mut self, + tcx: TyCtxt<'a, 'gcx, 'tcx>, + def_id: DefId, + substs: &'tcx Substs<'tcx>, + location: Location, + ) -> ty::InstantiatedPredicates<'tcx> { + if let Some(closure_region_requirements) = tcx.mir_borrowck(def_id).closure_requirements { + let closure_constraints = + closure_region_requirements.apply_requirements(tcx, location, def_id, substs); + + if let Some(ref mut borrowck_context) = self.borrowck_context { + let bounds_mapping = closure_constraints + .iter() + .enumerate() + .filter_map(|(idx, constraint)| { + let ty::OutlivesPredicate(k1, r2) = + constraint.no_late_bound_regions().unwrap_or_else(|| { + bug!("query_constraint {:?} contained bound regions", constraint,); + }); + + match k1.unpack() { + UnpackedKind::Lifetime(r1) => { + // constraint is r1: r2 + let r1_vid = borrowck_context.universal_regions.to_region_vid(r1); + let r2_vid = borrowck_context.universal_regions.to_region_vid(r2); + let outlives_requirements = + &closure_region_requirements.outlives_requirements[idx]; + Some(( + (r1_vid, r2_vid), + ( + outlives_requirements.category, + outlives_requirements.blame_span, + ), + )) + } + UnpackedKind::Type(_) => None, + } + }) + .collect(); + + let existing = borrowck_context + .constraints + .closure_bounds_mapping + .insert(location, bounds_mapping); + assert!( + existing.is_none(), + "Multiple closures at the same location." + ); + } + + self.push_region_constraints( + location.to_locations(), + ConstraintCategory::ClosureBounds, + &closure_constraints, + ); + } + + tcx.predicates_of(def_id).instantiate(tcx, substs) + } + + fn prove_trait_ref( + &mut self, + trait_ref: ty::TraitRef<'tcx>, + locations: Locations, + category: ConstraintCategory, + ) { self.prove_predicates( Some(ty::Predicate::Trait( trait_ref.to_poly_trait_ref().to_poly_trait_predicate(), )), locations, + category, ); } @@ -1875,7 +2269,7 @@ ) { for predicate in instantiated_predicates.predicates { let predicate = self.normalize(predicate, locations); - self.prove_predicate(predicate, locations); + self.prove_predicate(predicate, locations, ConstraintCategory::Boring); } } @@ -1883,6 +2277,7 @@ &mut self, predicates: impl IntoIterator>, locations: Locations, + category: ConstraintCategory, ) { for predicate in predicates { debug!( @@ -1890,11 +2285,16 @@ predicate, locations, ); - self.prove_predicate(predicate, locations); + self.prove_predicate(predicate, locations, category); } } - fn prove_predicate(&mut self, predicate: ty::Predicate<'tcx>, locations: Locations) { + fn prove_predicate( + &mut self, + predicate: ty::Predicate<'tcx>, + locations: Locations, + category: ConstraintCategory, + ) { debug!( "prove_predicate(predicate={:?}, location={:?})", predicate, locations, @@ -1903,6 +2303,7 @@ let param_env = self.param_env; self.fully_perform_op( locations, + category, param_env.and(type_op::prove_predicate::ProvePredicate::new(predicate)), ).unwrap_or_else(|NoSolution| { span_mirbug!(self, NoSolution, "could not prove {:?}", predicate); @@ -1943,6 +2344,7 @@ let param_env = self.param_env; self.fully_perform_op( location.to_locations(), + ConstraintCategory::Boring, param_env.and(type_op::normalize::Normalize::new(value)), ).unwrap_or_else(|NoSolution| { span_mirbug!(self, NoSolution, "failed to normalize `{:?}`", value); @@ -1984,7 +2386,8 @@ def_id, param_env, mir, - &[], + &vec![], + None, None, None, |_| (), @@ -1996,26 +2399,6 @@ } } -pub trait AtLocation { - /// Indicates a "boring" constraint that the user probably - /// woudln't want to see highlights. - fn boring(self) -> Locations; - - /// Indicates an "interesting" edge, which is of significance only - /// for diagnostics. - fn interesting(self) -> Locations; -} - -impl AtLocation for Location { - fn boring(self) -> Locations { - Locations::Boring(self) - } - - fn interesting(self) -> Locations { - Locations::Interesting(self) - } -} - trait NormalizeLocation: fmt::Debug + Copy { fn to_locations(self) -> Locations; } @@ -2028,6 +2411,23 @@ impl NormalizeLocation for Location { fn to_locations(self) -> Locations { - self.boring() + Locations::Single(self) + } +} + +#[derive(Debug, Default)] +struct ObligationAccumulator<'tcx> { + obligations: PredicateObligations<'tcx>, +} + +impl<'tcx> ObligationAccumulator<'tcx> { + fn add(&mut self, value: InferOk<'tcx, T>) -> T { + let InferOk { value, obligations } = value; + self.obligations.extend(obligations); + value + } + + fn into_vec(self) -> PredicateObligations<'tcx> { + self.obligations } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,253 +10,93 @@ use borrow_check::nll::constraints::OutlivesConstraint; use borrow_check::nll::type_check::{BorrowCheckContext, Locations}; -use borrow_check::nll::universal_regions::UniversalRegions; -use borrow_check::nll::ToRegionVid; -use rustc::infer::canonical::{Canonical, CanonicalVarInfos}; +use rustc::infer::nll_relate::{TypeRelating, TypeRelatingDelegate}; use rustc::infer::{InferCtxt, NLLRegionVariableOrigin}; +use rustc::mir::ConstraintCategory; use rustc::traits::query::Fallible; -use rustc::ty::fold::{TypeFoldable, TypeVisitor}; -use rustc::ty::relate::{self, Relate, RelateResult, TypeRelation}; -use rustc::ty::subst::Kind; -use rustc::ty::{self, CanonicalTy, CanonicalVar, RegionVid, Ty, TyCtxt}; -use rustc_data_structures::fx::FxHashMap; -use rustc_data_structures::indexed_vec::IndexVec; +use rustc::ty::relate::TypeRelation; +use rustc::ty::{self, Ty}; -/// Adds sufficient constraints to ensure that `a <: b`. -pub(super) fn sub_types<'tcx>( - infcx: &InferCtxt<'_, '_, 'tcx>, - a: Ty<'tcx>, - b: Ty<'tcx>, - locations: Locations, - borrowck_context: Option<&mut BorrowCheckContext<'_, 'tcx>>, -) -> Fallible<()> { - debug!("sub_types(a={:?}, b={:?}, locations={:?})", a, b, locations); - TypeRelating::new( - infcx, - ty::Variance::Covariant, - locations, - borrowck_context, - ty::List::empty(), - ).relate(&a, &b)?; - Ok(()) -} - -/// Adds sufficient constraints to ensure that `a == b`. -pub(super) fn eq_types<'tcx>( +/// Adds sufficient constraints to ensure that `a R b` where `R` depends on `v`: +/// +/// - "Covariant" `a <: b` +/// - "Invariant" `a == b` +/// - "Contravariant" `a :> b` +/// +/// NB. The type `a` is permitted to have unresolved inference +/// variables, but not the type `b`. +pub(super) fn relate_types<'tcx>( infcx: &InferCtxt<'_, '_, 'tcx>, a: Ty<'tcx>, + v: ty::Variance, b: Ty<'tcx>, locations: Locations, + category: ConstraintCategory, borrowck_context: Option<&mut BorrowCheckContext<'_, 'tcx>>, ) -> Fallible<()> { debug!("eq_types(a={:?}, b={:?}, locations={:?})", a, b, locations); TypeRelating::new( infcx, - ty::Variance::Invariant, - locations, - borrowck_context, - ty::List::empty(), + NllTypeRelatingDelegate::new(infcx, borrowck_context, locations, category), + v, ).relate(&a, &b)?; Ok(()) } -/// Adds sufficient constraints to ensure that `a <: b`, where `b` is -/// a user-given type (which means it may have canonical variables -/// encoding things like `_`). -pub(super) fn relate_type_and_user_type<'tcx>( - infcx: &InferCtxt<'_, '_, 'tcx>, - a: Ty<'tcx>, - v: ty::Variance, - b: CanonicalTy<'tcx>, - locations: Locations, - borrowck_context: Option<&mut BorrowCheckContext<'_, 'tcx>>, -) -> Fallible<()> { - debug!( - "sub_type_and_user_type(a={:?}, b={:?}, locations={:?})", - a, b, locations - ); - let Canonical { - variables: b_variables, - value: b_value, - } = b; - - // The `TypeRelating` code assumes that the "canonical variables" - // appear in the "a" side, so flip `Contravariant` ambient - // variance to get the right relationship. - let v1 = ty::Contravariant.xform(v); - - TypeRelating::new( - infcx, - v1, - locations, - borrowck_context, - b_variables, - ).relate(&b_value, &a)?; - Ok(()) -} - -struct TypeRelating<'cx, 'bccx: 'cx, 'gcx: 'tcx, 'tcx: 'bccx> { - infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, - - /// How are we relating `a` and `b`? - /// - /// - covariant means `a <: b` - /// - contravariant means `b <: a` - /// - invariant means `a == b - /// - bivariant means that it doesn't matter - ambient_variance: ty::Variance, - - /// When we pass through a set of binders (e.g., when looking into - /// a `fn` type), we push a new bound region scope onto here. This - /// will contain the instantiated region for each region in those - /// binders. When we then encounter a `ReLateBound(d, br)`, we can - /// use the debruijn index `d` to find the right scope, and then - /// bound region name `br` to find the specific instantiation from - /// within that scope. See `replace_bound_region`. - /// - /// This field stores the instantiations for late-bound regions in - /// the `a` type. - a_scopes: Vec, - - /// Same as `a_scopes`, but for the `b` type. - b_scopes: Vec, +struct NllTypeRelatingDelegate<'me, 'bccx: 'me, 'gcx: 'tcx, 'tcx: 'bccx> { + infcx: &'me InferCtxt<'me, 'gcx, 'tcx>, + borrowck_context: Option<&'me mut BorrowCheckContext<'bccx, 'tcx>>, /// Where (and why) is this relation taking place? locations: Locations, - /// This will be `Some` when we are running the type check as part - /// of NLL, and `None` if we are running a "sanity check". - borrowck_context: Option<&'cx mut BorrowCheckContext<'bccx, 'tcx>>, - - /// As we execute, the type on the LHS *may* come from a canonical - /// source. In that case, we will sometimes find a constraint like - /// `?0 = B`, where `B` is a type from the RHS. The first time we - /// find that, we simply record `B` (and the list of scopes that - /// tells us how to *interpret* `B`). The next time we encounter - /// `?0`, then, we can read this value out and use it. - /// - /// One problem: these variables may be in some other universe, - /// how can we enforce that? I guess I could add some kind of - /// "minimum universe constraint" that we can feed to the NLL checker. - /// --> also, we know this doesn't happen - canonical_var_values: IndexVec>>, -} - -#[derive(Clone, Debug)] -struct ScopesAndKind<'tcx> { - scopes: Vec, - kind: Kind<'tcx>, -} - -#[derive(Clone, Debug, Default)] -struct BoundRegionScope { - map: FxHashMap, + /// What category do we assign the resulting `'a: 'b` relationships? + category: ConstraintCategory, } -#[derive(Copy, Clone)] -struct UniversallyQuantified(bool); - -impl<'cx, 'bccx, 'gcx, 'tcx> TypeRelating<'cx, 'bccx, 'gcx, 'tcx> { +impl NllTypeRelatingDelegate<'me, 'bccx, 'gcx, 'tcx> { fn new( - infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, - ambient_variance: ty::Variance, + infcx: &'me InferCtxt<'me, 'gcx, 'tcx>, + borrowck_context: Option<&'me mut BorrowCheckContext<'bccx, 'tcx>>, locations: Locations, - borrowck_context: Option<&'cx mut BorrowCheckContext<'bccx, 'tcx>>, - canonical_var_infos: CanonicalVarInfos<'tcx>, + category: ConstraintCategory, ) -> Self { - let canonical_var_values = IndexVec::from_elem_n(None, canonical_var_infos.len()); Self { infcx, - ambient_variance, borrowck_context, locations, - canonical_var_values, - a_scopes: vec![], - b_scopes: vec![], - } - } - - fn ambient_covariance(&self) -> bool { - match self.ambient_variance { - ty::Variance::Covariant | ty::Variance::Invariant => true, - ty::Variance::Contravariant | ty::Variance::Bivariant => false, - } - } - - fn ambient_contravariance(&self) -> bool { - match self.ambient_variance { - ty::Variance::Contravariant | ty::Variance::Invariant => true, - ty::Variance::Covariant | ty::Variance::Bivariant => false, + category, } } +} - fn create_scope( - &mut self, - value: &ty::Binder>, - universally_quantified: UniversallyQuantified, - ) -> BoundRegionScope { - let mut scope = BoundRegionScope::default(); - value.skip_binder().visit_with(&mut ScopeInstantiator { - infcx: self.infcx, - target_index: ty::INNERMOST, - universally_quantified, - bound_region_scope: &mut scope, - }); - scope +impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, '_, 'tcx> { + fn create_next_universe(&mut self) -> ty::UniverseIndex { + self.infcx.create_next_universe() } - /// When we encounter binders during the type traversal, we record - /// the value to substitute for each of the things contained in - /// that binder. (This will be either a universal placeholder or - /// an existential inference variable.) Given the debruijn index - /// `debruijn` (and name `br`) of some binder we have now - /// encountered, this routine finds the value that we instantiated - /// the region with; to do so, it indexes backwards into the list - /// of ambient scopes `scopes`. - fn lookup_bound_region( - debruijn: ty::DebruijnIndex, - br: &ty::BoundRegion, - first_free_index: ty::DebruijnIndex, - scopes: &[BoundRegionScope], - ) -> RegionVid { - // The debruijn index is a "reverse index" into the - // scopes listing. So when we have INNERMOST (0), we - // want the *last* scope pushed, and so forth. - let debruijn_index = debruijn.index() - first_free_index.index(); - let scope = &scopes[scopes.len() - debruijn_index - 1]; - - // Find this bound region in that scope to map to a - // particular region. - scope.map[br] + fn next_existential_region_var(&mut self) -> ty::Region<'tcx> { + let origin = NLLRegionVariableOrigin::Existential; + self.infcx.next_nll_region_var(origin) } - /// If `r` is a bound region, find the scope in which it is bound - /// (from `scopes`) and return the value that we instantiated it - /// with. Otherwise just return `r`. - fn replace_bound_region( - &self, - universal_regions: &UniversalRegions<'tcx>, - r: ty::Region<'tcx>, - first_free_index: ty::DebruijnIndex, - scopes: &[BoundRegionScope], - ) -> RegionVid { - match r { - ty::ReLateBound(debruijn, br) => { - Self::lookup_bound_region(*debruijn, br, first_free_index, scopes) - } - - ty::ReVar(v) => *v, - - _ => universal_regions.to_region_vid(r), + fn next_placeholder_region(&mut self, placeholder: ty::Placeholder) -> ty::Region<'tcx> { + let origin = NLLRegionVariableOrigin::Placeholder(placeholder); + if let Some(borrowck_context) = &mut self.borrowck_context { + borrowck_context.placeholder_indices.insert(placeholder); } + self.infcx.next_nll_region_var(origin) } - /// Push a new outlives requirement into our output set of - /// constraints. - fn push_outlives(&mut self, sup: RegionVid, sub: RegionVid) { - debug!("push_outlives({:?}: {:?})", sup, sub); + fn generalize_existential(&mut self, universe: ty::UniverseIndex) -> ty::Region<'tcx> { + self.infcx + .next_nll_region_var_in_universe(NLLRegionVariableOrigin::Existential, universe) + } + fn push_outlives(&mut self, sup: ty::Region<'tcx>, sub: ty::Region<'tcx>) { if let Some(borrowck_context) = &mut self.borrowck_context { + let sub = borrowck_context.universal_regions.to_region_vid(sub); + let sup = borrowck_context.universal_regions.to_region_vid(sup); borrowck_context .constraints .outlives_constraints @@ -264,461 +104,8 @@ sup, sub, locations: self.locations, + category: self.category, }); - - // FIXME all facts! } } - - /// When we encounter a canonical variable `var` in the output, - /// equate it with `kind`. If the variable has been previously - /// equated, then equate it again. - fn relate_var( - &mut self, - var: CanonicalVar, - b_kind: Kind<'tcx>, - ) -> RelateResult<'tcx, Kind<'tcx>> { - debug!("equate_var(var={:?}, b_kind={:?})", var, b_kind); - - let generalized_kind = match self.canonical_var_values[var] { - Some(v) => v, - None => { - let generalized_kind = self.generalize_value(b_kind); - self.canonical_var_values[var] = Some(generalized_kind); - generalized_kind - } - }; - - // The generalized values we extract from `canonical_var_values` have - // been fully instantiated and hence the set of scopes we have - // doesn't matter -- just to be sure, put an empty vector - // in there. - let old_a_scopes = ::std::mem::replace(&mut self.a_scopes, vec![]); - - // Relate the generalized kind to the original one. - let result = self.relate(&generalized_kind, &b_kind); - - // Restore the old scopes now. - self.a_scopes = old_a_scopes; - - debug!("equate_var: complete, result = {:?}", result); - return result; - } - - fn generalize_value( - &self, - kind: Kind<'tcx>, - ) -> Kind<'tcx> { - TypeGeneralizer { - type_rel: self, - first_free_index: ty::INNERMOST, - ambient_variance: self.ambient_variance, - - // These always correspond to an `_` or `'_` written by - // user, and those are always in the root universe. - universe: ty::UniverseIndex::ROOT, - }.relate(&kind, &kind) - .unwrap() - } -} - -impl<'cx, 'bccx, 'gcx, 'tcx> TypeRelation<'cx, 'gcx, 'tcx> - for TypeRelating<'cx, 'bccx, 'gcx, 'tcx> -{ - fn tcx(&self) -> TyCtxt<'cx, 'gcx, 'tcx> { - self.infcx.tcx - } - - fn tag(&self) -> &'static str { - "nll::subtype" - } - - fn a_is_expected(&self) -> bool { - true - } - - fn relate_with_variance>( - &mut self, - variance: ty::Variance, - a: &T, - b: &T, - ) -> RelateResult<'tcx, T> { - debug!( - "relate_with_variance(variance={:?}, a={:?}, b={:?})", - variance, a, b - ); - - let old_ambient_variance = self.ambient_variance; - self.ambient_variance = self.ambient_variance.xform(variance); - - debug!( - "relate_with_variance: ambient_variance = {:?}", - self.ambient_variance - ); - - let r = self.relate(a, b)?; - - self.ambient_variance = old_ambient_variance; - - debug!("relate_with_variance: r={:?}", r); - - Ok(r) - } - - fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { - // Watch out for the case that we are matching a `?T` against the - // right-hand side. - if let ty::Infer(ty::CanonicalTy(var)) = a.sty { - self.relate_var(var, b.into())?; - Ok(a) - } else { - debug!( - "tys(a={:?}, b={:?}, variance={:?})", - a, b, self.ambient_variance - ); - - relate::super_relate_tys(self, a, b) - } - } - - fn regions( - &mut self, - a: ty::Region<'tcx>, - b: ty::Region<'tcx>, - ) -> RelateResult<'tcx, ty::Region<'tcx>> { - if let Some(&mut BorrowCheckContext { - universal_regions, .. - }) = self.borrowck_context - { - if let ty::ReCanonical(var) = a { - self.relate_var(*var, b.into())?; - return Ok(a); - } - - debug!( - "regions(a={:?}, b={:?}, variance={:?})", - a, b, self.ambient_variance - ); - - let v_a = - self.replace_bound_region(universal_regions, a, ty::INNERMOST, &self.a_scopes); - let v_b = - self.replace_bound_region(universal_regions, b, ty::INNERMOST, &self.b_scopes); - - debug!("regions: v_a = {:?}", v_a); - debug!("regions: v_b = {:?}", v_b); - - if self.ambient_covariance() { - // Covariance: a <= b. Hence, `b: a`. - self.push_outlives(v_b, v_a); - } - - if self.ambient_contravariance() { - // Contravariant: b <= a. Hence, `a: b`. - self.push_outlives(v_a, v_b); - } - } - - Ok(a) - } - - fn binders( - &mut self, - a: &ty::Binder, - b: &ty::Binder, - ) -> RelateResult<'tcx, ty::Binder> - where - T: Relate<'tcx>, - { - // We want that - // - // ``` - // for<'a> fn(&'a u32) -> &'a u32 <: - // fn(&'b u32) -> &'b u32 - // ``` - // - // but not - // - // ``` - // fn(&'a u32) -> &'a u32 <: - // for<'b> fn(&'b u32) -> &'b u32 - // ``` - // - // We therefore proceed as follows: - // - // - Instantiate binders on `b` universally, yielding a universe U1. - // - Instantiate binders on `a` existentially in U1. - - debug!( - "binders({:?}: {:?}, ambient_variance={:?})", - a, b, self.ambient_variance - ); - - if self.ambient_covariance() { - // Covariance, so we want `for<..> A <: for<..> B` -- - // therefore we compare any instantiation of A (i.e., A - // instantiated with existentials) against every - // instantiation of B (i.e., B instantiated with - // universals). - - let b_scope = self.create_scope(b, UniversallyQuantified(true)); - let a_scope = self.create_scope(a, UniversallyQuantified(false)); - - debug!("binders: a_scope = {:?} (existential)", a_scope); - debug!("binders: b_scope = {:?} (universal)", b_scope); - - self.b_scopes.push(b_scope); - self.a_scopes.push(a_scope); - - // Reset the ambient variance to covariant. This is needed - // to correctly handle cases like - // - // for<'a> fn(&'a u32, &'a u3) == for<'b, 'c> fn(&'b u32, &'c u32) - // - // Somewhat surprisingly, these two types are actually - // **equal**, even though the one on the right looks more - // polymorphic. The reason is due to subtyping. To see it, - // consider that each function can call the other: - // - // - The left function can call the right with `'b` and - // `'c` both equal to `'a` - // - // - The right function can call the left with `'a` set to - // `{P}`, where P is the point in the CFG where the call - // itself occurs. Note that `'b` and `'c` must both - // include P. At the point, the call works because of - // subtyping (i.e., `&'b u32 <: &{P} u32`). - let variance = ::std::mem::replace(&mut self.ambient_variance, ty::Variance::Covariant); - - self.relate(a.skip_binder(), b.skip_binder())?; - - self.ambient_variance = variance; - - self.b_scopes.pop().unwrap(); - self.a_scopes.pop().unwrap(); - } - - if self.ambient_contravariance() { - // Contravariance, so we want `for<..> A :> for<..> B` - // -- therefore we compare every instantiation of A (i.e., - // A instantiated with universals) against any - // instantiation of B (i.e., B instantiated with - // existentials). Opposite of above. - - let a_scope = self.create_scope(a, UniversallyQuantified(true)); - let b_scope = self.create_scope(b, UniversallyQuantified(false)); - - debug!("binders: a_scope = {:?} (universal)", a_scope); - debug!("binders: b_scope = {:?} (existential)", b_scope); - - self.a_scopes.push(a_scope); - self.b_scopes.push(b_scope); - - // Reset ambient variance to contravariance. See the - // covariant case above for an explanation. - let variance = ::std::mem::replace( - &mut self.ambient_variance, - ty::Variance::Contravariant, - ); - - self.relate(a.skip_binder(), b.skip_binder())?; - - self.ambient_variance = variance; - - self.b_scopes.pop().unwrap(); - self.a_scopes.pop().unwrap(); - } - - Ok(a.clone()) - } -} - -/// When we encounter a binder like `for<..> fn(..)`, we actually have -/// to walk the `fn` value to find all the values bound by the `for` -/// (these are not explicitly present in the ty representation right -/// now). This visitor handles that: it descends the type, tracking -/// binder depth, and finds late-bound regions targeting the -/// `for<..`>. For each of those, it creates an entry in -/// `bound_region_scope`. -struct ScopeInstantiator<'cx, 'gcx: 'tcx, 'tcx: 'cx> { - infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, - // The debruijn index of the scope we are instantiating. - target_index: ty::DebruijnIndex, - universally_quantified: UniversallyQuantified, - bound_region_scope: &'cx mut BoundRegionScope, -} - -impl<'cx, 'gcx, 'tcx> TypeVisitor<'tcx> for ScopeInstantiator<'cx, 'gcx, 'tcx> { - fn visit_binder>(&mut self, t: &ty::Binder) -> bool { - self.target_index.shift_in(1); - t.super_visit_with(self); - self.target_index.shift_out(1); - - false - } - - fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool { - let ScopeInstantiator { - infcx, - universally_quantified, - .. - } = *self; - - match r { - ty::ReLateBound(debruijn, br) if *debruijn == self.target_index => { - self.bound_region_scope.map.entry(*br).or_insert_with(|| { - let origin = if universally_quantified.0 { - NLLRegionVariableOrigin::BoundRegion(infcx.create_subuniverse()) - } else { - NLLRegionVariableOrigin::Existential - }; - infcx.next_nll_region_var(origin).to_region_vid() - }); - } - - _ => {} - } - - false - } -} - -/// The "type generalize" is used when handling inference variables. -/// -/// The basic strategy for handling a constraint like `?A <: B` is to -/// apply a "generalization strategy" to the type `B` -- this replaces -/// all the lifetimes in the type `B` with fresh inference -/// variables. (You can read more about the strategy in this [blog -/// post].) -/// -/// As an example, if we had `?A <: &'x u32`, we would generalize `&'x -/// u32` to `&'0 u32` where `'0` is a fresh variable. This becomes the -/// value of `A`. Finally, we relate `&'0 u32 <: &'x u32`, which -/// establishes `'0: 'x` as a constraint. -/// -/// As a side-effect of this generalization procedure, we also replace -/// all the bound regions that we have traversed with concrete values, -/// so that the resulting generalized type is independent from the -/// scopes. -/// -/// [blog post]: https://is.gd/0hKvIr -struct TypeGeneralizer<'me, 'bccx: 'me, 'gcx: 'tcx, 'tcx: 'bccx> { - type_rel: &'me TypeRelating<'me, 'bccx, 'gcx, 'tcx>, - - /// After we generalize this type, we are going to relative it to - /// some other type. What will be the variance at this point? - ambient_variance: ty::Variance, - - first_free_index: ty::DebruijnIndex, - - universe: ty::UniverseIndex, -} - -impl TypeRelation<'me, 'gcx, 'tcx> for TypeGeneralizer<'me, 'bbcx, 'gcx, 'tcx> { - fn tcx(&self) -> TyCtxt<'me, 'gcx, 'tcx> { - self.type_rel.infcx.tcx - } - - fn tag(&self) -> &'static str { - "nll::generalizer" - } - - fn a_is_expected(&self) -> bool { - true - } - - fn relate_with_variance>( - &mut self, - variance: ty::Variance, - a: &T, - b: &T, - ) -> RelateResult<'tcx, T> { - debug!( - "TypeGeneralizer::relate_with_variance(variance={:?}, a={:?}, b={:?})", - variance, a, b - ); - - let old_ambient_variance = self.ambient_variance; - self.ambient_variance = self.ambient_variance.xform(variance); - - debug!( - "TypeGeneralizer::relate_with_variance: ambient_variance = {:?}", - self.ambient_variance - ); - - let r = self.relate(a, b)?; - - self.ambient_variance = old_ambient_variance; - - debug!("TypeGeneralizer::relate_with_variance: r={:?}", r); - - Ok(r) - } - - fn tys(&mut self, a: Ty<'tcx>, _: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { - debug!("TypeGeneralizer::tys(a={:?})", a,); - - match a.sty { - ty::Infer(ty::TyVar(_)) | ty::Infer(ty::IntVar(_)) | ty::Infer(ty::FloatVar(_)) => { - bug!( - "unexpected inference variable encountered in NLL generalization: {:?}", - a - ); - } - - _ => relate::super_relate_tys(self, a, a), - } - } - - fn regions( - &mut self, - a: ty::Region<'tcx>, - _: ty::Region<'tcx>, - ) -> RelateResult<'tcx, ty::Region<'tcx>> { - debug!("TypeGeneralizer::regions(a={:?})", a,); - - if let ty::ReLateBound(debruijn, _) = a { - if *debruijn < self.first_free_index { - return Ok(a); - } - } - - // For now, we just always create a fresh region variable to - // replace all the regions in the source type. In the main - // type checker, we special case the case where the ambient - // variance is `Invariant` and try to avoid creating a fresh - // region variable, but since this comes up so much less in - // NLL (only when users use `_` etc) it is much less - // important. - // - // As an aside, since these new variables are created in - // `self.universe` universe, this also serves to enforce the - // universe scoping rules. - // - // FIXME(#54105) -- if the ambient variance is bivariant, - // though, we may however need to check well-formedness or - // risk a problem like #41677 again. - - let replacement_region_vid = self.type_rel - .infcx - .next_nll_region_var_in_universe(NLLRegionVariableOrigin::Existential, self.universe); - - Ok(replacement_region_vid) - } - - fn binders( - &mut self, - a: &ty::Binder, - _: &ty::Binder, - ) -> RelateResult<'tcx, ty::Binder> - where - T: Relate<'tcx>, - { - debug!("TypeGeneralizer::binders(a={:?})", a,); - - self.first_free_index.shift_in(1); - let result = self.relate(a.skip_binder(), a.skip_binder())?; - self.first_free_index.shift_out(1); - Ok(ty::Binder::bind(result)) - } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/universal_regions.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/universal_regions.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/universal_regions.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/nll/universal_regions.rs 2018-12-04 23:41:40.000000000 +0000 @@ -232,13 +232,13 @@ /// `V[1]: V[2]`. pub fn closure_mapping( tcx: TyCtxt<'_, '_, 'tcx>, - closure_ty: Ty<'tcx>, + closure_substs: &'tcx Substs<'tcx>, expected_num_vars: usize, closure_base_def_id: DefId, ) -> IndexVec> { let mut region_mapping = IndexVec::with_capacity(expected_num_vars); region_mapping.push(tcx.types.re_static); - tcx.for_each_free_region(&closure_ty, |fr| { + tcx.for_each_free_region(&closure_substs, |fr| { region_mapping.push(fr); }); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/path_utils.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/path_utils.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/path_utils.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/path_utils.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ use borrow_check::borrow_set::{BorrowSet, BorrowData, TwoPhaseActivation}; use borrow_check::places_conflict; use borrow_check::Context; -use borrow_check::ShallowOrDeep; +use borrow_check::AccessDepth; use dataflow::indexes::BorrowIndex; use rustc::mir::{BasicBlock, Location, Mir, Place}; use rustc::mir::{ProjectionElem, BorrowKind}; @@ -43,7 +43,7 @@ tcx: TyCtxt<'a, 'gcx, 'tcx>, mir: &Mir<'tcx>, _context: Context, - access_place: (ShallowOrDeep, &Place<'tcx>), + access_place: (AccessDepth, &Place<'tcx>), borrow_set: &BorrowSet<'tcx>, candidates: I, mut op: F, @@ -61,7 +61,14 @@ for i in candidates { let borrowed = &borrow_set[i]; - if places_conflict::places_conflict(tcx, mir, &borrowed.borrowed_place, place, access) { + if places_conflict::borrow_conflicts_with_place( + tcx, + mir, + &borrowed.borrowed_place, + borrowed.kind, + place, + access, + ) { debug!( "each_borrow_involving_path: {:?} @ {:?} vs. {:?}/{:?}", i, borrowed, place, access diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/places_conflict.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/places_conflict.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/places_conflict.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/places_conflict.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,22 +10,23 @@ use borrow_check::ArtificialField; use borrow_check::Overlap; -use borrow_check::{Deep, Shallow, ShallowOrDeep}; +use borrow_check::{Deep, Shallow, AccessDepth}; use rustc::hir; -use rustc::mir::{Mir, Place}; +use rustc::mir::{BorrowKind, Mir, Place}; use rustc::mir::{Projection, ProjectionElem}; use rustc::ty::{self, TyCtxt}; use std::cmp::max; -pub(super) fn places_conflict<'gcx, 'tcx>( +pub(super) fn borrow_conflicts_with_place<'gcx, 'tcx>( tcx: TyCtxt<'_, 'gcx, 'tcx>, mir: &Mir<'tcx>, borrow_place: &Place<'tcx>, + borrow_kind: BorrowKind, access_place: &Place<'tcx>, - access: ShallowOrDeep, + access: AccessDepth, ) -> bool { debug!( - "places_conflict({:?},{:?},{:?})", + "borrow_conflicts_with_place({:?},{:?},{:?})", borrow_place, access_place, access ); @@ -39,7 +40,14 @@ unroll_place(borrow_place, None, |borrow_components| { unroll_place(access_place, None, |access_components| { - place_components_conflict(tcx, mir, borrow_components, access_components, access) + place_components_conflict( + tcx, + mir, + borrow_components, + borrow_kind, + access_components, + access + ) }) }) } @@ -48,8 +56,9 @@ tcx: TyCtxt<'_, 'gcx, 'tcx>, mir: &Mir<'tcx>, mut borrow_components: PlaceComponentsIter<'_, 'tcx>, + borrow_kind: BorrowKind, mut access_components: PlaceComponentsIter<'_, 'tcx>, - access: ShallowOrDeep, + access: AccessDepth, ) -> bool { // The borrowck rules for proving disjointness are applied from the "root" of the // borrow forwards, iterating over "similar" projections in lockstep until @@ -95,10 +104,10 @@ loop { // loop invariant: borrow_c is always either equal to access_c or disjoint from it. if let Some(borrow_c) = borrow_components.next() { - debug!("places_conflict: borrow_c = {:?}", borrow_c); + debug!("borrow_conflicts_with_place: borrow_c = {:?}", borrow_c); if let Some(access_c) = access_components.next() { - debug!("places_conflict: access_c = {:?}", access_c); + debug!("borrow_conflicts_with_place: access_c = {:?}", access_c); // Borrow and access path both have more components. // @@ -127,7 +136,7 @@ // idea, at least for now, so just give up and // report a conflict. This is unsafe code anyway so // the user could always use raw pointers. - debug!("places_conflict: arbitrary -> conflict"); + debug!("borrow_conflicts_with_place: arbitrary -> conflict"); return true; } Overlap::EqualOrDisjoint => { @@ -136,7 +145,7 @@ Overlap::Disjoint => { // We have proven the borrow disjoint - further // projections will remain disjoint. - debug!("places_conflict: disjoint"); + debug!("borrow_conflicts_with_place: disjoint"); return false; } } @@ -157,7 +166,8 @@ match (elem, &base_ty.sty, access) { (_, _, Shallow(Some(ArtificialField::Discriminant))) - | (_, _, Shallow(Some(ArtificialField::ArrayLength))) => { + | (_, _, Shallow(Some(ArtificialField::ArrayLength))) + | (_, _, Shallow(Some(ArtificialField::ShallowBorrow))) => { // The discriminant and array length are like // additional fields on the type; they do not // overlap any existing data there. Furthermore, @@ -167,7 +177,7 @@ // // e.g. a (mutable) borrow of `a[5]` while we read the // array length of `a`. - debug!("places_conflict: implicit field"); + debug!("borrow_conflicts_with_place: implicit field"); return false; } @@ -175,20 +185,30 @@ // e.g. a borrow of `*x.y` while we shallowly access `x.y` or some // prefix thereof - the shallow access can't touch anything behind // the pointer. - debug!("places_conflict: shallow access behind ptr"); + debug!("borrow_conflicts_with_place: shallow access behind ptr"); return false; } (ProjectionElem::Deref, ty::Ref(_, _, hir::MutImmutable), _) => { - // the borrow goes through a dereference of a shared reference. - // - // I'm not sure why we are tracking these borrows - shared - // references can *always* be aliased, which means the - // permission check already account for this borrow. - debug!("places_conflict: behind a shared ref"); + // Shouldn't be tracked + bug!("Tracking borrow behind shared reference."); + } + (ProjectionElem::Deref, ty::Ref(_, _, hir::MutMutable), AccessDepth::Drop) => { + // Values behind a mutatble reference are not access either by Dropping a + // value, or by StorageDead + debug!("borrow_conflicts_with_place: drop access behind ptr"); return false; } + (ProjectionElem::Field { .. }, ty::Adt(def, _), AccessDepth::Drop) => { + // Drop can read/write arbitrary projections, so places + // conflict regardless of further projections. + if def.has_dtor(tcx) { + return true; + } + } + (ProjectionElem::Deref, _, Deep) + | (ProjectionElem::Deref, _, AccessDepth::Drop) | (ProjectionElem::Field { .. }, _, _) | (ProjectionElem::Index { .. }, _, _) | (ProjectionElem::ConstantIndex { .. }, _, _) @@ -215,11 +235,13 @@ // If the second example, where we did, then we still know // that the borrow can access a *part* of our place that // our access cares about, so we still have a conflict. - // - // FIXME: Differs from AST-borrowck; includes drive-by fix - // to #38899. Will probably need back-compat mode flag. - debug!("places_conflict: full borrow, CONFLICT"); - return true; + if borrow_kind == BorrowKind::Shallow && access_components.next().is_some() { + debug!("borrow_conflicts_with_place: shallow borrow"); + return false; + } else { + debug!("borrow_conflicts_with_place: full borrow, CONFLICT"); + return true; + } } } } @@ -231,7 +253,7 @@ /// /// NB: This particular impl strategy is not the most obvious. It was /// chosen because it makes a measurable difference to NLL -/// performance, as this code (`places_conflict`) is somewhat hot. +/// performance, as this code (`borrow_conflicts_with_place`) is somewhat hot. struct PlaceComponents<'p, 'tcx: 'p> { component: &'p Place<'tcx>, next: Option<&'p PlaceComponents<'p, 'tcx>>, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/prefixes.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/prefixes.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/prefixes.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/prefixes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -79,7 +79,7 @@ next: Some(place), kind, mir: self.mir, - tcx: self.tcx, + tcx: self.infcx.tcx, } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/used_muts.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/used_muts.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/borrow_check/used_muts.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/borrow_check/used_muts.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,7 +14,6 @@ use rustc_data_structures::fx::FxHashSet; use borrow_check::MirBorrowckCtxt; -use util::collect_writes::is_place_assignment; impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { /// Walks the MIR looking for assignments to a set of locals, as part of the unused mutable @@ -46,7 +45,7 @@ return; } - if is_place_assignment(&place_context) { + if place_context.is_place_assignment() { // Propagate the Local assigned at this Location as a used mutable local variable for moi in &self.mbcx.move_data.loc_map[location] { let mpi = &self.mbcx.move_data.moves[*moi].path; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/block.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/block.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/block.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/block.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use build::{BlockAnd, BlockAndExtension, Builder}; +use build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; use build::ForGuard::OutsideGuard; use build::matches::ArmHasGuard; use hair::*; @@ -93,6 +93,7 @@ let Stmt { kind, opt_destruction_scope } = this.hir.mirror(stmt); match kind { StmtKind::Expr { scope, expr } => { + this.block_context.push(BlockFrame::Statement { ignores_expr_result: true }); unpack!(block = this.in_opt_scope( opt_destruction_scope.map(|de|(de, source_info)), block, |this| { let si = (scope, source_info); @@ -109,6 +110,13 @@ initializer, lint_level } => { + let ignores_expr_result = if let PatternKind::Wild = *pattern.kind { + true + } else { + false + }; + this.block_context.push(BlockFrame::Statement { ignores_expr_result }); + // Enter the remainder scope, i.e. the bindings' destruction scope. this.push_scope((remainder_scope, source_info)); let_scope_stack.push(remainder_scope); @@ -143,10 +151,13 @@ None, remainder_span, lint_level, slice::from_ref(&pattern), ArmHasGuard(false), None); - this.visit_bindings(&pattern, None, &mut |this, _, _, _, node, span, _, _| { - this.storage_live_binding(block, node, span, OutsideGuard); - this.schedule_drop_for_binding(node, span, OutsideGuard); - }) + this.visit_bindings( + &pattern, + &PatternTypeProjections::none(), + &mut |this, _, _, _, node, span, _, _| { + this.storage_live_binding(block, node, span, OutsideGuard); + this.schedule_drop_for_binding(node, span, OutsideGuard); + }) } // Enter the source scope, after evaluating the initializer. @@ -155,19 +166,40 @@ } } } + + let popped = this.block_context.pop(); + assert!(popped.map_or(false, |bf|bf.is_statement())); } + // Then, the block may have an optional trailing expression which is a “return” value - // of the block. + // of the block, which is stored into `destination`. + let tcx = this.hir.tcx(); + let destination_ty = destination.ty(&this.local_decls, tcx).to_ty(tcx); if let Some(expr) = expr { + let tail_result_is_ignored = destination_ty.is_unit() || + match this.block_context.last() { + // no context: conservatively assume result is read + None => false, + + // sub-expression: block result feeds into some computation + Some(BlockFrame::SubExpr) => false, + + // otherwise: use accumualated is_ignored state. + Some(BlockFrame::TailExpr { tail_result_is_ignored: ignored }) | + Some(BlockFrame::Statement { ignores_expr_result: ignored }) => *ignored, + }; + this.block_context.push(BlockFrame::TailExpr { tail_result_is_ignored }); + unpack!(block = this.into(destination, block, expr)); + let popped = this.block_context.pop(); + + assert!(popped.map_or(false, |bf|bf.is_tail_expr())); } else { // If a block has no trailing expression, then it is given an implicit return type. // This return type is usually `()`, unless the block is diverging, in which case the // return type is `!`. For the unit type, we need to actually return the unit, but in // the case of `!`, no return value is required, as the block will never return. - let tcx = this.hir.tcx(); - let ty = destination.ty(&this.local_decls, tcx).to_ty(tcx); - if ty.is_unit() { + if destination_ty.is_unit() { // We only want to assign an implicit `()` as the return value of the block if the // block does not diverge. (Otherwise, we may try to assign a unit to a `!`-type.) this.cfg.push_assign_unit(block, source_info, destination); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/cfg.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/cfg.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/cfg.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/cfg.rs 2018-12-04 23:41:40.000000000 +0000 @@ -76,7 +76,7 @@ rvalue: Rvalue<'tcx>) { self.push(block, Statement { source_info, - kind: StatementKind::Assign(place.clone(), rvalue) + kind: StatementKind::Assign(place.clone(), box rvalue) }); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/expr/as_place.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/expr/as_place.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/expr/as_place.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/expr/as_place.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,6 +16,7 @@ use hair::*; use rustc::mir::interpret::EvalErrorKind::BoundsCheck; use rustc::mir::*; +use rustc::ty::Variance; use rustc_data_structures::indexed_vec::Idx; @@ -136,6 +137,44 @@ ty: expr.ty, }))), + ExprKind::PlaceTypeAscription { source, user_ty } => { + let place = unpack!(block = this.as_place(block, source)); + if let Some(user_ty) = user_ty { + this.cfg.push( + block, + Statement { + source_info, + kind: StatementKind::AscribeUserType( + place.clone(), + Variance::Invariant, + box UserTypeProjection { base: user_ty, projs: vec![], }, + ), + }, + ); + } + block.and(place) + } + ExprKind::ValueTypeAscription { source, user_ty } => { + let source = this.hir.mirror(source); + let temp = unpack!( + block = this.as_temp(block, source.temp_lifetime, source, mutability) + ); + if let Some(user_ty) = user_ty { + this.cfg.push( + block, + Statement { + source_info, + kind: StatementKind::AscribeUserType( + Place::Local(temp.clone()), + Variance::Invariant, + box UserTypeProjection { base: user_ty, projs: vec![], }, + ), + }, + ); + } + block.and(Place::Local(temp)) + } + ExprKind::Array { .. } | ExprKind::Tuple { .. } | ExprKind::Adt { .. } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/expr/as_rvalue.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/expr/as_rvalue.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/expr/as_rvalue.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/expr/as_rvalue.rs 2018-12-04 23:41:40.000000000 +0000 @@ -386,7 +386,9 @@ | ExprKind::Continue { .. } | ExprKind::Return { .. } | ExprKind::InlineAsm { .. } - | ExprKind::StaticRef { .. } => { + | ExprKind::StaticRef { .. } + | ExprKind::PlaceTypeAscription { .. } + | ExprKind::ValueTypeAscription { .. } => { // these do not have corresponding `Rvalue` variants, // so make an operand and then return that debug_assert!(match Category::of(&expr.kind) { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/expr/as_temp.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/expr/as_temp.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/expr/as_temp.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/expr/as_temp.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,7 @@ //! See docs in build/expr/mod.rs -use build::{BlockAnd, BlockAndExtension, Builder}; +use build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; use hair::*; use rustc::middle::region; use rustc::mir::*; @@ -59,14 +59,30 @@ } let expr_ty = expr.ty; - let temp = if mutability == Mutability::Not { - this.local_decls - .push(LocalDecl::new_immutable_temp(expr_ty, expr_span)) - } else { - this.local_decls - .push(LocalDecl::new_temp(expr_ty, expr_span)) - }; + let temp = { + let mut local_decl = LocalDecl::new_temp(expr_ty, expr_span); + if mutability == Mutability::Not { + local_decl = local_decl.immutable(); + } + + debug!("creating temp {:?} with block_context: {:?}", local_decl, this.block_context); + // Find out whether this temp is being created within the + // tail expression of a block whose result is ignored. + for bf in this.block_context.iter().rev() { + match bf { + BlockFrame::SubExpr => continue, + BlockFrame::Statement { .. } => break, + &BlockFrame::TailExpr { tail_result_is_ignored } => { + local_decl = local_decl.block_tail(BlockTailInfo { + tail_result_is_ignored + }); + break; + } + } + } + this.local_decls.push(local_decl) + }; if !expr_ty.is_never() { this.cfg.push( block, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/expr/category.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/expr/category.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/expr/category.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/expr/category.rs 2018-12-04 23:41:40.000000000 +0000 @@ -50,7 +50,9 @@ | ExprKind::Index { .. } | ExprKind::SelfRef | ExprKind::VarRef { .. } - | ExprKind::StaticRef { .. } => Some(Category::Place), + | ExprKind::StaticRef { .. } + | ExprKind::PlaceTypeAscription { .. } + | ExprKind::ValueTypeAscription { .. } => Some(Category::Place), ExprKind::LogicalOp { .. } | ExprKind::If { .. } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/expr/into.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/expr/into.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/expr/into.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/expr/into.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ //! See docs in build/expr/mod.rs use build::expr::category::{Category, RvalueFunc}; -use build::{BlockAnd, BlockAndExtension, Builder}; +use build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; use hair::*; use rustc::mir::*; use rustc::ty; @@ -39,7 +39,17 @@ let expr_span = expr.span; let source_info = this.source_info(expr_span); - match expr.kind { + let expr_is_block_or_scope = match expr.kind { + ExprKind::Block { .. } => true, + ExprKind::Scope { .. } => true, + _ => false, + }; + + if !expr_is_block_or_scope { + this.block_context.push(BlockFrame::SubExpr); + } + + let block_and = match expr.kind { ExprKind::Scope { region_scope, lint_level, @@ -264,7 +274,7 @@ ); exit_block.unit() } - ExprKind::Call { ty, fun, args } => { + ExprKind::Call { ty, fun, args, from_hir_call } => { // FIXME(canndrew): This is_never should probably be an is_uninhabited let diverges = expr.ty.is_never(); let intrinsic = match ty.sty { @@ -296,12 +306,13 @@ let ptr_temp = this.local_decls.push(LocalDecl { mutability: Mutability::Mut, ty: ptr_ty, - user_ty: None, + user_ty: UserTypeProjections::none(), name: None, source_info, visibility_scope: source_info.scope, internal: true, is_user_variable: None, + is_block_tail: None, }); let ptr_temp = Place::Local(ptr_temp); let block = unpack!(this.into(&ptr_temp, block, ptr)); @@ -326,6 +337,7 @@ } else { Some((destination.clone(), success)) }, + from_hir_call, }, ); success.unit() @@ -345,7 +357,11 @@ } // Avoid creating a temporary - ExprKind::VarRef { .. } | ExprKind::SelfRef | ExprKind::StaticRef { .. } => { + ExprKind::VarRef { .. } | + ExprKind::SelfRef | + ExprKind::StaticRef { .. } | + ExprKind::PlaceTypeAscription { .. } | + ExprKind::ValueTypeAscription { .. } => { debug_assert!(Category::of(&expr.kind) == Some(Category::Place)); let place = unpack!(block = this.as_place(block, expr)); @@ -393,7 +409,14 @@ | ExprKind::Literal { .. } | ExprKind::Yield { .. } => { debug_assert!(match Category::of(&expr.kind).unwrap() { + // should be handled above Category::Rvalue(RvalueFunc::Into) => false, + + // must be handled above or else we get an + // infinite loop in the builder; see + // e.g. `ExprKind::VarRef` above + Category::Place => false, + _ => true, }); @@ -402,6 +425,13 @@ .push_assign(block, source_info, destination, rvalue); block.unit() } + }; + + if !expr_is_block_or_scope { + let popped = this.block_context.pop(); + assert!(popped.is_some()); } + + block_and } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/expr/stmt.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/expr/stmt.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/expr/stmt.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/expr/stmt.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,7 +9,7 @@ // except according to those terms. use build::scope::BreakableScope; -use build::{BlockAnd, BlockAndExtension, Builder}; +use build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; use hair::*; use rustc::mir::*; @@ -20,6 +20,7 @@ let source_info = this.source_info(expr.span); // Handle a number of expressions that don't need a destination at all. This // avoids needing a mountain of temporary `()` variables. + let expr2 = expr.clone(); match expr.kind { ExprKind::Scope { region_scope, @@ -40,19 +41,23 @@ // is better for borrowck interaction with overloaded // operators like x[j] = x[i]. + debug!("stmt_expr Assign block_context.push(SubExpr) : {:?}", expr2); + this.block_context.push(BlockFrame::SubExpr); + // Generate better code for things that don't need to be // dropped. if this.hir.needs_drop(lhs.ty) { let rhs = unpack!(block = this.as_local_operand(block, rhs)); let lhs = unpack!(block = this.as_place(block, lhs)); unpack!(block = this.build_drop_and_replace(block, lhs_span, lhs, rhs)); - block.unit() } else { let rhs = unpack!(block = this.as_local_rvalue(block, rhs)); let lhs = unpack!(block = this.as_place(block, lhs)); this.cfg.push_assign(block, source_info, &lhs, rhs); - block.unit() } + + this.block_context.pop(); + block.unit() } ExprKind::AssignOp { op, lhs, rhs } => { // FIXME(#28160) there is an interesting semantics @@ -66,6 +71,9 @@ let lhs = this.hir.mirror(lhs); let lhs_ty = lhs.ty; + debug!("stmt_expr AssignOp block_context.push(SubExpr) : {:?}", expr2); + this.block_context.push(BlockFrame::SubExpr); + // As above, RTL. let rhs = unpack!(block = this.as_local_operand(block, rhs)); let lhs = unpack!(block = this.as_place(block, lhs)); @@ -85,6 +93,7 @@ ); this.cfg.push_assign(block, source_info, &lhs, result); + this.block_context.pop(); block.unit() } ExprKind::Continue { label } => { @@ -114,7 +123,10 @@ (break_block, region_scope, break_destination.clone()) }; if let Some(value) = value { - unpack!(block = this.into(&destination, block, value)) + debug!("stmt_expr Break val block_context.push(SubExpr) : {:?}", expr2); + this.block_context.push(BlockFrame::SubExpr); + unpack!(block = this.into(&destination, block, value)); + this.block_context.pop(); } else { this.cfg.push_assign_unit(block, source_info, &destination) } @@ -123,7 +135,13 @@ } ExprKind::Return { value } => { block = match value { - Some(value) => unpack!(this.into(&Place::Local(RETURN_PLACE), block, value)), + Some(value) => { + debug!("stmt_expr Return val block_context.push(SubExpr) : {:?}", expr2); + this.block_context.push(BlockFrame::SubExpr); + let result = unpack!(this.into(&Place::Local(RETURN_PLACE), block, value)); + this.block_context.pop(); + result + } None => { this.cfg .push_assign_unit(block, source_info, &Place::Local(RETURN_PLACE)); @@ -140,14 +158,18 @@ outputs, inputs, } => { + debug!("stmt_expr InlineAsm block_context.push(SubExpr) : {:?}", expr2); + this.block_context.push(BlockFrame::SubExpr); let outputs = outputs .into_iter() .map(|output| unpack!(block = this.as_place(block, output))) - .collect(); + .collect::>() + .into_boxed_slice(); let inputs = inputs .into_iter() .map(|input| unpack!(block = this.as_local_operand(block, input))) - .collect(); + .collect::>() + .into_boxed_slice(); this.cfg.push( block, Statement { @@ -159,6 +181,7 @@ }, }, ); + this.block_context.pop(); block.unit() } _ => { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/matches/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/matches/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/matches/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/matches/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -18,10 +18,11 @@ use build::{BlockAnd, BlockAndExtension, Builder}; use build::{GuardFrame, GuardFrameLocal, LocalsForNode}; use hair::*; +use hair::pattern::PatternTypeProjections; use rustc::hir; use rustc::mir::*; -use rustc::ty::{self, CanonicalTy, Ty}; -use rustc_data_structures::bitvec::BitArray; +use rustc::ty::{self, Ty}; +use rustc_data_structures::bit_set::BitSet; use rustc_data_structures::fx::FxHashMap; use syntax::ast::{Name, NodeId}; use syntax_pos::Span; @@ -31,6 +32,8 @@ mod test; mod util; +use std::convert::TryFrom; + /// ArmHasGuard is isomorphic to a boolean flag. It indicates whether /// a match arm has a guard expression attached to it. #[derive(Copy, Clone, Debug)] @@ -57,39 +60,22 @@ // 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. + // of `discriminant_place`, specifically by applying `ReadForMatch`. // - // NOTE: Under NLL, the above issue should no longer occur because it - // injects a borrow of the matched input, which should have the same effect - // as eddyb's hack. Once NLL is the default, we can remove the hack. - - let dummy_source_info = self.source_info(discriminant_span); - let dummy_access = Rvalue::Discriminant(discriminant_place.clone()); - let dummy_ty = dummy_access.ty(&self.local_decls, tcx); - let dummy_temp = self.temp(dummy_ty, dummy_source_info.span); - self.cfg - .push_assign(block, dummy_source_info, &dummy_temp, dummy_access); + // NOTE: ReadForMatch also checks that the discriminant is initialized. + // This is currently needed to not allow matching on an uninitialized, + // uninhabited value. If we get never patterns, those will check that + // the place is initialized, and so this read would only be used to + // check safety. let source_info = self.source_info(discriminant_span); - let borrowed_input_temp = if tcx.generate_borrow_of_any_match_input() { - // The region is unknown at this point; we rely on NLL - // inference to find an appropriate one. Therefore you can - // only use this when NLL is turned on. - assert!(tcx.use_mir_borrowck()); - let borrowed_input = Rvalue::Ref( - tcx.types.re_empty, - BorrowKind::Shared, + self.cfg.push(block, Statement { + source_info, + kind: StatementKind::FakeRead( + FakeReadCause::ForMatchedPlace, discriminant_place.clone(), - ); - let borrowed_input_ty = borrowed_input.ty(&self.local_decls, tcx); - let borrowed_input_temp = self.temp(borrowed_input_ty, span); - self.cfg - .push_assign(block, source_info, &borrowed_input_temp, borrowed_input); - Some(borrowed_input_temp) - } else { - None - }; + ), + }); let mut arm_blocks = ArmBlocks { blocks: arms.iter().map(|_| self.cfg.start_new_block()).collect(), @@ -118,6 +104,8 @@ .map(|_| self.cfg.start_new_block()) .collect(); + let mut has_guard = false; + // assemble a list of candidates: there is one candidate per // pattern, which means there may be more than one candidate // *per arm*. These candidates are kept sorted such that the @@ -140,27 +128,9 @@ .map( |( (arm_index, pat_index, pattern, guard), - (pre_binding_block, next_candidate_pre_binding_block), + (pre_binding_block, next_candidate_pre_binding_block) )| { - if let (true, Some(borrow_temp)) = - (tcx.emit_read_for_match(), borrowed_input_temp.clone()) - { - // inject a fake read of the borrowed input at - // the start of each arm's pattern testing - // code. - // - // This should ensure that you cannot change - // the variant for an enum while you are in - // the midst of matching on it. - let pattern_source_info = self.source_info(pattern.span); - self.cfg.push( - *pre_binding_block, - Statement { - source_info: pattern_source_info, - kind: StatementKind::ReadForMatch(borrow_temp.clone()), - }, - ); - } + has_guard |= guard.is_some(); // One might ask: why not build up the match pair such that it // matches via `borrowed_input_temp.deref()` instead of @@ -205,9 +175,31 @@ TerminatorKind::Unreachable, ); + // Maps a place to the kind of Fake borrow that we want to perform on + // it: either Shallow or Shared, depending on whether the place is + // bound in the match, or just switched on. + // If there are no match guards then we don't need any fake borrows, + // so don't track them. + let mut fake_borrows = if has_guard && tcx.generate_borrow_of_any_match_input() { + Some(FxHashMap::default()) + } else { + None + }; + + let pre_binding_blocks: Vec<_> = candidates + .iter() + .map(|cand| (cand.pre_binding_block, cand.span)) + .collect(); + // this will generate code to test discriminant_place and // branch to the appropriate arm block - let otherwise = self.match_candidates(span, &mut arm_blocks, candidates, block); + let otherwise = self.match_candidates( + discriminant_span, + &mut arm_blocks, + candidates, + block, + &mut fake_borrows, + ); if !otherwise.is_empty() { // All matches are exhaustive. However, because some matches @@ -227,6 +219,10 @@ } } + if let Some(fake_borrows) = fake_borrows { + self.add_fake_borrows(&pre_binding_blocks, fake_borrows, source_info, block); + } + // all the arm blocks will rejoin here let end_block = self.cfg.start_new_block(); @@ -247,7 +243,7 @@ end_block.unit() } - pub fn expr_into_pattern( + pub(super) fn expr_into_pattern( &mut self, mut block: BasicBlock, irrefutable_pat: Pattern<'tcx>, @@ -264,6 +260,18 @@ let place = self.storage_live_binding(block, var, irrefutable_pat.span, OutsideGuard); unpack!(block = self.into(&place, block, initializer)); + + + // Inject a fake read, see comments on `FakeReadCause::ForLet`. + let source_info = self.source_info(irrefutable_pat.span); + self.cfg.push( + block, + Statement { + source_info, + kind: StatementKind::FakeRead(FakeReadCause::ForLet, place), + }, + ); + self.schedule_drop_for_binding(var, irrefutable_pat.span, OutsideGuard); block.unit() } @@ -286,21 +294,32 @@ }, .. }, - user_ty: ascription_user_ty, + user_ty: pat_ascription_ty, + user_ty_span, } => { let place = self.storage_live_binding(block, var, irrefutable_pat.span, OutsideGuard); unpack!(block = self.into(&place, block, initializer)); - let source_info = self.source_info(irrefutable_pat.span); + // Inject a fake read, see comments on `FakeReadCause::ForLet`. + let pattern_source_info = self.source_info(irrefutable_pat.span); self.cfg.push( block, Statement { - source_info, + source_info: pattern_source_info, + kind: StatementKind::FakeRead(FakeReadCause::ForLet, place.clone()), + }, + ); + + let ty_source_info = self.source_info(user_ty_span); + self.cfg.push( + block, + Statement { + source_info: ty_source_info, kind: StatementKind::AscribeUserType( - place.clone(), + place, ty::Variance::Invariant, - ascription_user_ty, + box pat_ascription_ty.user_ty(), ), }, ); @@ -399,7 +418,7 @@ let num_patterns = patterns.len(); self.visit_bindings( &patterns[0], - None, + &PatternTypeProjections::none(), &mut |this, mutability, name, mode, var, span, ty, user_ty| { if visibility_scope.is_none() { visibility_scope = @@ -472,10 +491,10 @@ ); } - pub fn visit_bindings( + pub(super) fn visit_bindings( &mut self, pattern: &Pattern<'tcx>, - mut pattern_user_ty: Option>, + pattern_user_ty: &PatternTypeProjections<'tcx>, f: &mut impl FnMut( &mut Self, Mutability, @@ -484,7 +503,7 @@ NodeId, Span, Ty<'tcx>, - Option>, + &PatternTypeProjections<'tcx>, ), ) { match *pattern.kind { @@ -497,20 +516,19 @@ ref subpattern, .. } => { - match mode { - BindingMode::ByValue => { } + let pattern_ref_binding; // sidestep temp lifetime limitations. + let binding_user_ty = match mode { + BindingMode::ByValue => { pattern_user_ty } BindingMode::ByRef(..) => { // If this is a `ref` binding (e.g., `let ref // x: T = ..`), then the type of `x` is not - // `T` but rather `&T`, so ignore - // `pattern_user_ty` for now. - // - // FIXME(#47184): extract or handle `pattern_user_ty` somehow - pattern_user_ty = None; + // `T` but rather `&T`. + pattern_ref_binding = pattern_user_ty.ref_binding(); + &pattern_ref_binding } - } + }; - f(self, mutability, name, mode, var, pattern.span, ty, pattern_user_ty); + f(self, mutability, name, mode, var, pattern.span, ty, binding_user_ty); if let Some(subpattern) = subpattern.as_ref() { self.visit_bindings(subpattern, pattern_user_ty, f); } @@ -525,34 +543,44 @@ ref slice, ref suffix, } => { - // FIXME(#47184): extract or handle `pattern_user_ty` somehow - for subpattern in prefix.iter().chain(slice).chain(suffix) { - self.visit_bindings(subpattern, None, f); + let from = u32::try_from(prefix.len()).unwrap(); + let to = u32::try_from(suffix.len()).unwrap(); + for subpattern in prefix { + self.visit_bindings(subpattern, &pattern_user_ty.index(), f); + } + for subpattern in slice { + self.visit_bindings(subpattern, &pattern_user_ty.subslice(from, to), f); + } + for subpattern in suffix { + self.visit_bindings(subpattern, &pattern_user_ty.index(), f); } } PatternKind::Constant { .. } | PatternKind::Range { .. } | PatternKind::Wild => {} PatternKind::Deref { ref subpattern } => { - // FIXME(#47184): extract or handle `pattern_user_ty` somehow - self.visit_bindings(subpattern, None, f); + self.visit_bindings(subpattern, &pattern_user_ty.deref(), f); } - PatternKind::AscribeUserType { ref subpattern, user_ty } => { + PatternKind::AscribeUserType { ref subpattern, ref user_ty, user_ty_span } => { // This corresponds to something like // // ``` - // let (p1: T1): T2 = ...; + // let A::<'a>(_): A<'static> = ...; // ``` - // - // Not presently possible, though maybe someday. - assert!(pattern_user_ty.is_none()); - self.visit_bindings(subpattern, Some(user_ty), f) - } - PatternKind::Leaf { ref subpatterns } - | PatternKind::Variant { - ref subpatterns, .. - } => { - // FIXME(#47184): extract or handle `pattern_user_ty` somehow + let subpattern_user_ty = pattern_user_ty.add_user_type(user_ty, user_ty_span); + self.visit_bindings(subpattern, &subpattern_user_ty, f) + } + + PatternKind::Leaf { ref subpatterns } => { for subpattern in subpatterns { - self.visit_bindings(&subpattern.pattern, None, f); + let subpattern_user_ty = pattern_user_ty.leaf(subpattern.field); + self.visit_bindings(&subpattern.pattern, &subpattern_user_ty, f); + } + } + + PatternKind::Variant { adt_def, substs: _, variant_index, ref subpatterns } => { + for subpattern in subpatterns { + let subpattern_user_ty = pattern_user_ty.variant( + adt_def, variant_index, subpattern.field); + self.visit_bindings(&subpattern.pattern, &subpattern_user_ty, f); } } } @@ -611,7 +639,7 @@ struct Ascription<'tcx> { span: Span, source: Place<'tcx>, - user_ty: CanonicalTy<'tcx>, + user_ty: PatternTypeProjection<'tcx>, } #[derive(Clone, Debug)] @@ -635,7 +663,7 @@ // test the branches of enum Switch { adt_def: &'tcx ty::AdtDef, - variants: BitArray, + variants: BitSet, }, // test the branches of enum @@ -696,12 +724,16 @@ /// up the list of candidates and recurse with a non-exhaustive /// list. This is important to keep the size of the generated code /// under control. See `test_candidates` for more details. + /// + /// If `add_fake_borrows` is true, then places which need fake borrows + /// will be added to it. fn match_candidates<'pat>( &mut self, span: Span, arm_blocks: &mut ArmBlocks, mut candidates: Vec>, mut block: BasicBlock, + fake_borrows: &mut Option, BorrowKind>>, ) -> Vec { debug!( "matched_candidate(span={:?}, block={:?}, candidates={:?})", @@ -729,6 +761,15 @@ ); let mut unmatched_candidates = candidates.split_off(fully_matched); + // Insert a *Shared* borrow of any places that are bound. + if let Some(fake_borrows) = fake_borrows { + for Binding { source, .. } + in candidates.iter().flat_map(|candidate| &candidate.bindings) + { + fake_borrows.insert(source.clone(), BorrowKind::Shared); + } + } + let fully_matched_with_guard = candidates.iter().take_while(|c| c.guard.is_some()).count(); let unreachable_candidates = if fully_matched_with_guard + 1 < candidates.len() { @@ -765,7 +806,13 @@ return vec![]; } else { let target = self.cfg.start_new_block(); - return self.match_candidates(span, arm_blocks, unmatched_candidates, target); + return self.match_candidates( + span, + arm_blocks, + unmatched_candidates, + target, + &mut None, + ); } } } @@ -778,7 +825,7 @@ // Test candidates where possible. let (otherwise, tested_candidates) = - self.test_candidates(span, arm_blocks, &unmatched_candidates, block); + self.test_candidates(span, arm_blocks, &unmatched_candidates, block, fake_borrows); // If the target candidates were exhaustive, then we are done. // But for borrowck continue build decision tree. @@ -792,7 +839,7 @@ // Otherwise, let's process those remaining candidates. let join_block = self.join_otherwise_blocks(span, otherwise); - self.match_candidates(span, arm_blocks, untested_candidates, join_block) + self.match_candidates(span, arm_blocks, untested_candidates, join_block, &mut None) } fn join_otherwise_blocks(&mut self, span: Span, mut otherwise: Vec) -> BasicBlock { @@ -932,6 +979,7 @@ arm_blocks: &mut ArmBlocks, candidates: &[Candidate<'pat, 'tcx>], block: BasicBlock, + fake_borrows: &mut Option, BorrowKind>>, ) -> (Vec, usize) { // extract the match-pair from the highest priority candidate let match_pair = &candidates.first().unwrap().match_pairs[0]; @@ -972,6 +1020,11 @@ _ => {} } + // Insert a Shallow borrow of any places that is switched on. + fake_borrows.as_mut().map(|fb| { + fb.entry(match_pair.place.clone()).or_insert(BorrowKind::Shallow) + }); + // perform the test, branching to one of N blocks. For each of // those N possible outcomes, create a (initially empty) // vector of candidates. Those are the candidates that still @@ -1008,7 +1061,13 @@ .into_iter() .zip(target_candidates) .flat_map(|(target_block, target_candidates)| { - self.match_candidates(span, arm_blocks, target_candidates, target_block) + self.match_candidates( + span, + arm_blocks, + target_candidates, + target_block, + fake_borrows, + ) }) .collect(); @@ -1262,6 +1321,14 @@ ) { for ascription in ascriptions { let source_info = self.source_info(ascription.span); + + debug!( + "adding user ascription at span {:?} of place {:?} and {:?}", + source_info.span, + ascription.source, + ascription.user_ty, + ); + self.cfg.push( block, Statement { @@ -1269,7 +1336,7 @@ kind: StatementKind::AscribeUserType( ascription.source.clone(), ty::Variance::Covariant, - ascription.user_ty, + box ascription.user_ty.clone().user_ty(), ), }, ); @@ -1345,7 +1412,9 @@ // borrow of the whole match input. See additional // discussion on rust-lang/rust#49870. let borrow_kind = match borrow_kind { - BorrowKind::Shared | BorrowKind::Unique => borrow_kind, + BorrowKind::Shared + | BorrowKind::Shallow + | BorrowKind::Unique => borrow_kind, BorrowKind::Mut { .. } => BorrowKind::Mut { allow_two_phase_borrow: true, }, @@ -1414,7 +1483,7 @@ num_patterns: usize, var_id: NodeId, var_ty: Ty<'tcx>, - user_var_ty: Option>, + user_var_ty: &PatternTypeProjections<'tcx>, has_guard: ArmHasGuard, opt_match_place: Option<(Option>, Span)>, pat_span: Span, @@ -1433,11 +1502,12 @@ let local = LocalDecl::<'tcx> { mutability, ty: var_ty, - user_ty: user_var_ty, + user_ty: user_var_ty.clone().user_ty(), name: Some(name), source_info, visibility_scope, internal: false, + is_block_tail: None, is_user_variable: Some(ClearCrossCrate::Set(BindingForm::Var(VarBindingForm { binding_mode, // hypothetically, `visit_bindings` could try to unzip @@ -1465,12 +1535,13 @@ // See previous comment. mutability: Mutability::Not, ty: tcx.mk_imm_ref(tcx.types.re_empty, var_ty), - user_ty: None, + user_ty: UserTypeProjections::none(), name: Some(name), source_info, visibility_scope, // FIXME: should these secretly injected ref_for_guard's be marked as `internal`? internal: false, + is_block_tail: None, is_user_variable: Some(ClearCrossCrate::Set(BindingForm::RefForGuard)), }); LocalsForNode::ForGuard { @@ -1484,4 +1555,86 @@ debug!("declare_binding: vars={:?}", locals); self.var_indices.insert(var_id, locals); } + + // Determine the fake borrows that are needed to ensure that the place + // will evaluate to the same thing until an arm has been chosen. + fn add_fake_borrows<'pat>( + &mut self, + pre_binding_blocks: &[(BasicBlock, Span)], + fake_borrows: FxHashMap, BorrowKind>, + source_info: SourceInfo, + start_block: BasicBlock, + ) { + let tcx = self.hir.tcx(); + + debug!("add_fake_borrows pre_binding_blocks = {:?}, fake_borrows = {:?}", + pre_binding_blocks, fake_borrows); + + let mut all_fake_borrows = Vec::with_capacity(fake_borrows.len()); + + // Insert a Shallow borrow of the prefixes of any fake borrows. + for (place, borrow_kind) in fake_borrows + { + { + let mut prefix_cursor = &place; + while let Place::Projection(box Projection { base, elem }) = prefix_cursor { + if let ProjectionElem::Deref = elem { + // Insert a shallow borrow after a deref. For other + // projections the borrow of prefix_cursor will + // conflict with any mutation of base. + all_fake_borrows.push((base.clone(), BorrowKind::Shallow)); + } + prefix_cursor = base; + } + } + + all_fake_borrows.push((place, borrow_kind)); + } + + // Deduplicate and ensure a deterministic order. + all_fake_borrows.sort(); + all_fake_borrows.dedup(); + + debug!("add_fake_borrows all_fake_borrows = {:?}", all_fake_borrows); + + // Add fake borrows to the start of the match and reads of them before + // the start of each arm. + let mut borrowed_input_temps = Vec::with_capacity(all_fake_borrows.len()); + + for (matched_place, borrow_kind) in all_fake_borrows { + let borrowed_input = + Rvalue::Ref(tcx.types.re_empty, borrow_kind, matched_place.clone()); + let borrowed_input_ty = borrowed_input.ty(&self.local_decls, tcx); + let borrowed_input_temp = self.temp(borrowed_input_ty, source_info.span); + self.cfg.push_assign( + start_block, + source_info, + &borrowed_input_temp, + borrowed_input + ); + borrowed_input_temps.push(borrowed_input_temp); + } + + // FIXME: This could be a lot of reads (#fake borrows * #patterns). + // The false edges that we currently generate would allow us to only do + // this on the last Candidate, but it's possible that there might not be + // so many false edges in the future, so we read for all Candidates for + // now. + // Another option would be to make our own block and add our own false + // edges to it. + if tcx.emit_read_for_match() { + for &(pre_binding_block, span) in pre_binding_blocks { + let pattern_source_info = self.source_info(span); + for temp in &borrowed_input_temps { + self.cfg.push(pre_binding_block, Statement { + source_info: pattern_source_info, + kind: StatementKind::FakeRead( + FakeReadCause::ForMatchGuard, + temp.clone(), + ), + }); + } + } + } + } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/matches/simplify.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/matches/simplify.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/matches/simplify.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/matches/simplify.rs 2018-12-04 23:41:40.000000000 +0000 @@ -63,10 +63,10 @@ candidate: &mut Candidate<'pat, 'tcx>) -> Result<(), MatchPair<'pat, 'tcx>> { match *match_pair.pattern.kind { - PatternKind::AscribeUserType { ref subpattern, user_ty } => { + PatternKind::AscribeUserType { ref subpattern, ref user_ty, user_ty_span } => { candidate.ascriptions.push(Ascription { - span: match_pair.pattern.span, - user_ty, + span: user_ty_span, + user_ty: user_ty.clone(), source: match_pair.place.clone(), }); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/matches/test.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/matches/test.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/matches/test.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/matches/test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -18,8 +18,8 @@ use build::Builder; use build::matches::{Candidate, MatchPair, Test, TestKind}; use hair::*; +use rustc_data_structures::bit_set::BitSet; use rustc_data_structures::fx::FxHashMap; -use rustc_data_structures::bitvec::BitArray; use rustc::ty::{self, Ty}; use rustc::ty::util::IntTypeExt; use rustc::mir::*; @@ -38,7 +38,7 @@ span: match_pair.pattern.span, kind: TestKind::Switch { adt_def: adt_def.clone(), - variants: BitArray::new(adt_def.variants.len()), + variants: BitSet::new_empty(adt_def.variants.len()), }, } } @@ -55,7 +55,7 @@ // these maps are empty to start; cases are // added below in add_cases_to_switch options: vec![], - indices: FxHashMap(), + indices: Default::default(), } } } @@ -152,7 +152,7 @@ pub fn add_variants_to_switch<'pat>(&mut self, test_place: &Place<'tcx>, candidate: &Candidate<'pat, 'tcx>, - variants: &mut BitArray) + variants: &mut BitSet) -> bool { let match_pair = match candidate.match_pairs.iter().find(|mp| mp.place == *test_place) { @@ -324,7 +324,7 @@ let ref_ty = self.hir.tcx().mk_ref(region, tam); // let lhs_ref_place = &lhs; - let ref_rvalue = Rvalue::Ref(region, BorrowKind::Shared, place.clone()); + let ref_rvalue = Rvalue::Ref(region, BorrowKind::Shared, place); let lhs_ref_place = self.temp(ref_ty, test.span); self.cfg.push_assign(block, source_info, &lhs_ref_place, ref_rvalue); let val = Operand::Move(lhs_ref_place); @@ -361,6 +361,7 @@ args: vec![val, expect], destination: Some((eq_result.clone(), eq_block)), cleanup: Some(cleanup), + from_hir_call: false, }); // check the result diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -35,21 +35,51 @@ use transform::MirSource; use util as mir_util; +use super::lints; + /// Construct the MIR for a given def-id. pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'tcx> { let id = tcx.hir.as_local_node_id(def_id).unwrap(); // Figure out what primary body this item has. - let body_id = match tcx.hir.get(id) { + let (body_id, return_ty_span) = match tcx.hir.get(id) { Node::Variant(variant) => return create_constructor_shim(tcx, id, &variant.node.data), Node::StructCtor(ctor) => return create_constructor_shim(tcx, id, ctor), - _ => match tcx.hir.maybe_body_owned_by(id) { - Some(body) => body, - None => span_bug!(tcx.hir.span(id), "can't build MIR for {:?}", def_id), - }, + Node::Expr(hir::Expr { node: hir::ExprKind::Closure(_, decl, body_id, _, _), .. }) + | Node::Item(hir::Item { node: hir::ItemKind::Fn(decl, _, _, body_id), .. }) + | Node::ImplItem( + hir::ImplItem { + node: hir::ImplItemKind::Method(hir::MethodSig { decl, .. }, body_id), + .. + } + ) + | Node::TraitItem( + hir::TraitItem { + node: hir::TraitItemKind::Method( + hir::MethodSig { decl, .. }, + hir::TraitMethod::Provided(body_id), + ), + .. + } + ) => { + (*body_id, decl.output.span()) + } + Node::Item(hir::Item { node: hir::ItemKind::Static(ty, _, body_id), .. }) + | Node::Item(hir::Item { node: hir::ItemKind::Const(ty, body_id), .. }) + | Node::ImplItem(hir::ImplItem { node: hir::ImplItemKind::Const(ty, body_id), .. }) + | Node::TraitItem( + hir::TraitItem { node: hir::TraitItemKind::Const(ty, Some(body_id)), .. } + ) => { + (*body_id, ty.span) + } + Node::AnonConst(hir::AnonConst { body, id, .. }) => { + (*body, tcx.hir.span(*id)) + } + + _ => span_bug!(tcx.hir.span(id), "can't build MIR for {:?}", def_id), }; tcx.infer_ctxt().enter(|infcx| { @@ -97,8 +127,14 @@ let ty_hir_id = fn_decl.inputs[index].hir_id; let ty_span = tcx.hir.span(tcx.hir.hir_to_node_id(ty_hir_id)); opt_ty_info = Some(ty_span); - self_arg = if index == 0 && fn_decl.has_implicit_self { - Some(ImplicitSelfBinding) + self_arg = if index == 0 && fn_decl.implicit_self.has_implicit_self() { + match fn_decl.implicit_self { + hir::ImplicitSelfKind::Imm => Some(ImplicitSelfKind::Imm), + hir::ImplicitSelfKind::Mut => Some(ImplicitSelfKind::Mut), + hir::ImplicitSelfKind::ImmRef => Some(ImplicitSelfKind::ImmRef), + hir::ImplicitSelfKind::MutRef => Some(ImplicitSelfKind::MutRef), + _ => None, + } } else { None }; @@ -124,9 +160,9 @@ }; build::construct_fn(cx, id, arguments, safety, abi, - return_ty, yield_ty, body) + return_ty, yield_ty, return_ty_span, body) } else { - build::construct_const(cx, body_id) + build::construct_const(cx, body_id, return_ty_span) }; // Convert the Mir to global types. @@ -142,6 +178,8 @@ mir_util::dump_mir(tcx, None, "mir_map", &0, MirSource::item(def_id), &mir, |_, _| Ok(()) ); + lints::check(tcx, &mir, def_id); + mir }) } @@ -247,6 +285,57 @@ tcx.liberate_late_bound_regions(closure_def_id, &closure_env_ty) } +#[derive(Debug, PartialEq, Eq)] +pub enum BlockFrame { + /// Evaluation is currently within a statement. + /// + /// Examples include: + /// 1. `EXPR;` + /// 2. `let _ = EXPR;` + /// 3. `let x = EXPR;` + Statement { + /// If true, then statement discards result from evaluating + /// the expression (such as examples 1 and 2 above). + ignores_expr_result: bool + }, + + /// Evaluation is currently within the tail expression of a block. + /// + /// Example: `{ STMT_1; STMT_2; EXPR }` + TailExpr { + /// If true, then the surrounding context of the block ignores + /// the result of evaluating the block's tail expression. + /// + /// Example: `let _ = { STMT_1; EXPR };` + tail_result_is_ignored: bool + }, + + /// Generic mark meaning that the block occurred as a subexpression + /// where the result might be used. + /// + /// Examples: `foo(EXPR)`, `match EXPR { ... }` + SubExpr, +} + +impl BlockFrame { + fn is_tail_expr(&self) -> bool { + match *self { + BlockFrame::TailExpr { .. } => true, + + BlockFrame::Statement { .. } | + BlockFrame::SubExpr => false, + } + } + fn is_statement(&self) -> bool { + match *self { + BlockFrame::Statement { .. } => true, + + BlockFrame::TailExpr { .. } | + BlockFrame::SubExpr => false, + } + } + } + struct Builder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { hir: Cx<'a, 'gcx, 'tcx>, cfg: CFG<'tcx>, @@ -258,6 +347,20 @@ /// see the `scope` module for more details scopes: Vec>, + /// the block-context: each time we build the code within an hair::Block, + /// we push a frame here tracking whether we are building a statement or + /// if we are pushing the tail expression of the block. This is used to + /// embed information in generated temps about whether they were created + /// for a block tail expression or not. + /// + /// It would be great if we could fold this into `self.scopes` + /// somehow; but right now I think that is very tightly tied to + /// the code generation in ways that we cannot (or should not) + /// start just throwing new entries onto that vector in order to + /// distinguish the context of EXPR1 from the context of EXPR2 in + /// `{ STMTS; EXPR1 } + EXPR2` + block_context: Vec, + /// The current unsafe block in scope, even if it is hidden by /// a PushUnsafeBlock unpushed_unsafe: Safety, @@ -480,12 +583,10 @@ /////////////////////////////////////////////////////////////////////////// /// the main entry point for building MIR for a function -struct ImplicitSelfBinding; - struct ArgInfo<'gcx>(Ty<'gcx>, Option, Option<&'gcx hir::Pat>, - Option); + Option); fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>, fn_id: ast::NodeId, @@ -494,6 +595,7 @@ abi: Abi, return_ty: Ty<'gcx>, yield_ty: Option>, + return_ty_span: Span, body: &'gcx hir::Body) -> Mir<'tcx> where A: Iterator> @@ -542,11 +644,12 @@ }).collect() }); - let mut builder = Builder::new(hir.clone(), + let mut builder = Builder::new(hir, span, arguments.len(), safety, return_ty, + return_ty_span, upvar_decls); let fn_def_id = tcx.hir.local_def_id(fn_id); @@ -601,15 +704,17 @@ mir } -fn construct_const<'a, 'gcx, 'tcx>(hir: Cx<'a, 'gcx, 'tcx>, - body_id: hir::BodyId) - -> Mir<'tcx> { +fn construct_const<'a, 'gcx, 'tcx>( + hir: Cx<'a, 'gcx, 'tcx>, + body_id: hir::BodyId, + ty_span: Span, +) -> Mir<'tcx> { let tcx = hir.tcx(); let ast_expr = &tcx.hir.body(body_id).value; let ty = hir.tables().expr_ty_adjusted(ast_expr); let owner_id = tcx.hir.body_owner(body_id); let span = tcx.hir.span(owner_id); - let mut builder = Builder::new(hir.clone(), span, 0, Safety::Safe, ty, vec![]); + let mut builder = Builder::new(hir, span, 0, Safety::Safe, ty, ty_span,vec![]); let mut block = START_BLOCK; let expr = builder.hir.mirror(ast_expr); @@ -637,7 +742,7 @@ let owner_id = hir.tcx().hir.body_owner(body_id); let span = hir.tcx().hir.span(owner_id); let ty = hir.tcx().types.err; - let mut builder = Builder::new(hir, span, 0, Safety::Safe, ty, vec![]); + let mut builder = Builder::new(hir, span, 0, Safety::Safe, ty, span, vec![]); let source_info = builder.source_info(span); builder.cfg.terminate(START_BLOCK, source_info, TerminatorKind::Unreachable); builder.finish(None) @@ -649,6 +754,7 @@ arg_count: usize, safety: Safety, return_ty: Ty<'tcx>, + return_span: Span, upvar_decls: Vec) -> Builder<'a, 'gcx, 'tcx> { let lint_level = LintLevel::Explicit(hir.root_lint_level); @@ -658,6 +764,7 @@ fn_span: span, arg_count, scopes: vec![], + block_context: vec![], source_scopes: IndexVec::new(), source_scope: OUTERMOST_SOURCE_SCOPE, source_scope_local_data: IndexVec::new(), @@ -665,8 +772,10 @@ push_unsafe_count: 0, unpushed_unsafe: safety, breakable_scopes: vec![], - local_decls: IndexVec::from_elem_n(LocalDecl::new_return_place(return_ty, - span), 1), + local_decls: IndexVec::from_elem_n( + LocalDecl::new_return_place(return_ty, return_span), + 1, + ), upvar_decls, var_indices: NodeMap(), unit_temp: None, @@ -736,12 +845,13 @@ self.local_decls.push(LocalDecl { mutability: Mutability::Mut, ty, - user_ty: None, + user_ty: UserTypeProjections::none(), source_info, visibility_scope: source_info.scope, name, internal: false, is_user_variable: None, + is_block_tail: None, }); } @@ -762,8 +872,8 @@ PatternKind::Binding { mutability, var, mode: BindingMode::ByValue, .. } => { self.local_decls[local].mutability = mutability; self.local_decls[local].is_user_variable = - if let Some(ImplicitSelfBinding) = self_binding { - Some(ClearCrossCrate::Set(BindingForm::ImplicitSelf)) + if let Some(kind) = self_binding { + Some(ClearCrossCrate::Set(BindingForm::ImplicitSelf(*kind))) } else { let binding_mode = ty::BindingMode::BindByValue(mutability.into()); Some(ClearCrossCrate::Set(BindingForm::Var(VarBindingForm { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/scope.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/scope.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/build/scope.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/build/scope.rs 2018-12-04 23:41:40.000000000 +0000 @@ -358,7 +358,7 @@ needs_cleanup: false, drops: vec![], cached_generator_drop: None, - cached_exits: FxHashMap(), + cached_exits: Default::default(), cached_unwind: CachedBlock::default(), }); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/const_eval.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/const_eval.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/const_eval.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/const_eval.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,44 +12,54 @@ use std::fmt; use std::error::Error; +use std::borrow::{Borrow, Cow}; +use std::hash::Hash; +use std::collections::hash_map::Entry; use rustc::hir::{self, def_id::DefId}; use rustc::mir::interpret::ConstEvalErr; use rustc::mir; -use rustc::ty::{self, TyCtxt, Instance, query::TyCtxtAt}; -use rustc::ty::layout::{self, LayoutOf, TyLayout}; +use rustc::ty::{self, Ty, TyCtxt, Instance, query::TyCtxtAt}; +use rustc::ty::layout::{self, Size, LayoutOf, TyLayout}; use rustc::ty::subst::Subst; use rustc_data_structures::indexed_vec::IndexVec; +use rustc_data_structures::fx::FxHashMap; use syntax::ast::Mutability; -use syntax::source_map::Span; +use syntax::source_map::{Span, DUMMY_SP}; -use rustc::mir::interpret::{ - EvalResult, EvalError, EvalErrorKind, GlobalId, - Scalar, Allocation, ConstValue, -}; use interpret::{self, - Place, PlaceTy, MemPlace, OpTy, Operand, Value, - EvalContext, StackPopCleanup, MemoryKind, + PlaceTy, MemPlace, OpTy, Operand, Value, Pointer, Scalar, ConstValue, + EvalResult, EvalError, EvalErrorKind, GlobalId, EvalContext, StackPopCleanup, + Allocation, AllocId, MemoryKind, + snapshot, }; +/// Number of steps until the detector even starts doing anything. +/// Also, a warning is shown to the user when this number is reached. +const STEPS_UNTIL_DETECTOR_ENABLED: isize = 1_000_000; +/// The number of steps between loop detector snapshots. +/// Should be a power of two for performance reasons. +const DETECTOR_SNAPSHOT_PERIOD: isize = 256; + pub fn mk_borrowck_eval_cx<'a, 'mir, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance<'tcx>, mir: &'mir mir::Mir<'tcx>, span: Span, -) -> EvalResult<'tcx, EvalContext<'a, 'mir, 'tcx, CompileTimeEvaluator>> { +) -> EvalResult<'tcx, CompileTimeEvalContext<'a, 'mir, 'tcx>> { debug!("mk_borrowck_eval_cx: {:?}", instance); let param_env = tcx.param_env(instance.def_id()); - let mut ecx = EvalContext::new(tcx.at(span), param_env, CompileTimeEvaluator, ()); + let mut ecx = EvalContext::new(tcx.at(span), param_env, CompileTimeInterpreter::new()); // insert a stack frame so any queries have the correct substs + // cannot use `push_stack_frame`; if we do `const_prop` explodes ecx.stack.push(interpret::Frame { block: mir::START_BLOCK, locals: IndexVec::new(), instance, span, mir, - return_place: Place::null(tcx), + return_place: None, return_to_block: StackPopCleanup::Goto(None), // never pop stmt: 0, }); @@ -60,35 +70,34 @@ tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance<'tcx>, param_env: ty::ParamEnv<'tcx>, -) -> EvalResult<'tcx, EvalContext<'a, 'tcx, 'tcx, CompileTimeEvaluator>> { +) -> EvalResult<'tcx, CompileTimeEvalContext<'a, 'tcx, 'tcx>> { debug!("mk_eval_cx: {:?}, {:?}", instance, param_env); let span = tcx.def_span(instance.def_id()); - let mut ecx = EvalContext::new(tcx.at(span), param_env, CompileTimeEvaluator, ()); + let mut ecx = EvalContext::new(tcx.at(span), param_env, CompileTimeInterpreter::new()); let mir = ecx.load_mir(instance.def)?; // insert a stack frame so any queries have the correct substs ecx.push_stack_frame( instance, mir.span, mir, - Place::null(tcx), + None, StackPopCleanup::Goto(None), // never pop )?; Ok(ecx) } -pub fn eval_promoted<'a, 'mir, 'tcx>( - ecx: &mut EvalContext<'a, 'mir, 'tcx, CompileTimeEvaluator>, +pub(crate) fn eval_promoted<'a, 'mir, 'tcx>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, cid: GlobalId<'tcx>, mir: &'mir mir::Mir<'tcx>, param_env: ty::ParamEnv<'tcx>, ) -> EvalResult<'tcx, OpTy<'tcx>> { - ecx.with_fresh_body(|ecx| { - eval_body_using_ecx(ecx, cid, Some(mir), param_env) - }) + let mut ecx = mk_borrowck_eval_cx(tcx, cid.instance, mir, DUMMY_SP).unwrap(); + eval_body_using_ecx(&mut ecx, cid, Some(mir), param_env) } pub fn op_to_const<'tcx>( - ecx: &EvalContext<'_, '_, 'tcx, CompileTimeEvaluator>, + ecx: &CompileTimeEvalContext<'_, '_, 'tcx>, op: OpTy<'tcx>, may_normalize: bool, ) -> EvalResult<'tcx, &'tcx ty::Const<'tcx>> { @@ -111,16 +120,16 @@ } }; let val = match normalized_op { - Err(MemPlace { ptr, align, extra }) => { + Err(MemPlace { ptr, align, meta }) => { // extract alloc-offset pair - assert!(extra.is_none()); + assert!(meta.is_none()); let ptr = ptr.to_ptr()?; let alloc = ecx.memory.get(ptr.alloc_id)?; assert!(alloc.align.abi() >= align.abi()); assert!(alloc.bytes.len() as u64 - ptr.offset.bytes() >= op.layout.size.bytes()); let mut alloc = alloc.clone(); alloc.align = align; - // FIXME shouldnt it be the case that `mark_static_initialized` has already + // FIXME shouldn't it be the case that `mark_static_initialized` has already // interned this? I thought that is the entire point of that `FinishStatic` stuff? let alloc = ecx.tcx.intern_const_alloc(alloc); ConstValue::ByRef(ptr.alloc_id, alloc, ptr.offset) @@ -128,7 +137,7 @@ Ok(Value::Scalar(x)) => ConstValue::Scalar(x.not_undef()?), Ok(Value::ScalarPair(a, b)) => - ConstValue::ScalarPair(a.not_undef()?, b), + ConstValue::ScalarPair(a.not_undef()?, b.not_undef()?), }; Ok(ty::Const::from_const_value(ecx.tcx.tcx, val, op.layout.ty)) } @@ -138,19 +147,19 @@ cid: GlobalId<'tcx>, mir: Option<&'mir mir::Mir<'tcx>>, param_env: ty::ParamEnv<'tcx>, -) -> (EvalResult<'tcx, OpTy<'tcx>>, EvalContext<'a, 'mir, 'tcx, CompileTimeEvaluator>) { +) -> (EvalResult<'tcx, OpTy<'tcx>>, CompileTimeEvalContext<'a, 'mir, 'tcx>) { // we start out with the best span we have // and try improving it down the road when more information is available let span = tcx.def_span(cid.instance.def_id()); let span = mir.map(|mir| mir.span).unwrap_or(span); - let mut ecx = EvalContext::new(tcx.at(span), param_env, CompileTimeEvaluator, ()); + let mut ecx = EvalContext::new(tcx.at(span), param_env, CompileTimeInterpreter::new()); let r = eval_body_using_ecx(&mut ecx, cid, mir, param_env); (r, ecx) } // Returns a pointer to where the result lives -fn eval_body_using_ecx<'a, 'mir, 'tcx>( - ecx: &mut EvalContext<'a, 'mir, 'tcx, CompileTimeEvaluator>, +fn eval_body_using_ecx<'mir, 'tcx>( + ecx: &mut CompileTimeEvalContext<'_, 'mir, 'tcx>, cid: GlobalId<'tcx>, mir: Option<&'mir mir::Mir<'tcx>>, param_env: ty::ParamEnv<'tcx>, @@ -176,7 +185,7 @@ cid.instance, mir.span, mir, - Place::Ptr(*ret), + Some(ret.into()), StackPopCleanup::None { cleanup: false }, )?; @@ -197,21 +206,15 @@ Ok(ret.into()) } -#[derive(Debug, Clone, Eq, PartialEq, Hash)] -pub struct CompileTimeEvaluator; - impl<'tcx> Into> for ConstEvalError { fn into(self) -> EvalError<'tcx> { EvalErrorKind::MachineError(self.to_string()).into() } } -impl_stable_hash_for!(struct CompileTimeEvaluator {}); - #[derive(Clone, Debug)] enum ConstEvalError { NeedsRfc(String), - NotConst(String), } impl fmt::Display for ConstEvalError { @@ -225,7 +228,6 @@ msg ) } - NotConst(ref msg) => write!(f, "{}", msg), } } } @@ -235,7 +237,6 @@ use self::ConstEvalError::*; match *self { NeedsRfc(_) => "this feature needs an rfc before being allowed inside constants", - NotConst(_) => "this feature is not compatible with constant evaluation", } } @@ -244,14 +245,117 @@ } } -impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeEvaluator { - type MemoryData = (); +// Extra machine state for CTFE, and the Machine instance +pub struct CompileTimeInterpreter<'a, 'mir, 'tcx: 'a+'mir> { + /// When this value is negative, it indicates the number of interpreter + /// steps *until* the loop detector is enabled. When it is positive, it is + /// the number of steps after the detector has been enabled modulo the loop + /// detector period. + pub(super) steps_since_detector_enabled: isize, + + /// Extra state to detect loops. + pub(super) loop_detector: snapshot::InfiniteLoopDetector<'a, 'mir, 'tcx>, +} + +impl<'a, 'mir, 'tcx> CompileTimeInterpreter<'a, 'mir, 'tcx> { + fn new() -> Self { + CompileTimeInterpreter { + loop_detector: Default::default(), + steps_since_detector_enabled: -STEPS_UNTIL_DETECTOR_ENABLED, + } + } +} + +impl interpret::AllocMap for FxHashMap { + #[inline(always)] + fn contains_key(&mut self, k: &Q) -> bool + where K: Borrow + { + FxHashMap::contains_key(self, k) + } + + #[inline(always)] + fn insert(&mut self, k: K, v: V) -> Option + { + FxHashMap::insert(self, k, v) + } + + #[inline(always)] + fn remove(&mut self, k: &Q) -> Option + where K: Borrow + { + FxHashMap::remove(self, k) + } + + #[inline(always)] + fn filter_map_collect(&self, mut f: impl FnMut(&K, &V) -> Option) -> Vec { + self.iter() + .filter_map(move |(k, v)| f(k, &*v)) + .collect() + } + + #[inline(always)] + fn get_or( + &self, + k: K, + vacant: impl FnOnce() -> Result + ) -> Result<&V, E> + { + match self.get(&k) { + Some(v) => Ok(v), + None => { + vacant()?; + bug!("The CTFE machine shouldn't ever need to extend the alloc_map when reading") + } + } + } + + #[inline(always)] + fn get_mut_or( + &mut self, + k: K, + vacant: impl FnOnce() -> Result + ) -> Result<&mut V, E> + { + match self.entry(k) { + Entry::Occupied(e) => Ok(e.into_mut()), + Entry::Vacant(e) => { + let v = vacant()?; + Ok(e.insert(v)) + } + } + } +} + +type CompileTimeEvalContext<'a, 'mir, 'tcx> = + EvalContext<'a, 'mir, 'tcx, CompileTimeInterpreter<'a, 'mir, 'tcx>>; + +impl interpret::MayLeak for ! { + #[inline(always)] + fn may_leak(self) -> bool { + // `self` is uninhabited + self + } +} + +impl<'a, 'mir, 'tcx> interpret::Machine<'a, 'mir, 'tcx> + for CompileTimeInterpreter<'a, 'mir, 'tcx> +{ type MemoryKinds = !; + type AllocExtra = (); + type PointerTag = (); + + type MemoryMap = FxHashMap, Allocation)>; - const MUT_STATIC_KIND: Option = None; // no mutating of statics allowed - const DETECT_LOOPS: bool = true; + const STATIC_KIND: Option = None; // no copying of statics allowed + const ENABLE_PTR_TRACKING_HOOKS: bool = false; // we don't have no provenance - fn find_fn<'a>( + #[inline(always)] + fn enforce_validity(_ecx: &EvalContext<'a, 'mir, 'tcx, Self>) -> bool { + false // for now, we don't enforce validity + } + + fn find_fn( ecx: &mut EvalContext<'a, 'mir, 'tcx, Self>, instance: ty::Instance<'tcx>, args: &[OpTy<'tcx>], @@ -266,9 +370,6 @@ ecx.goto_block(ret)?; // fully evaluated and done return Ok(None); } - return Err( - ConstEvalError::NotConst(format!("calling non-const fn `{}`", instance)).into(), - ); } // This is a const fn. Call it. Ok(Some(match ecx.load_mir(instance.def) { @@ -285,7 +386,7 @@ })) } - fn call_intrinsic<'a>( + fn call_intrinsic( ecx: &mut EvalContext<'a, 'mir, 'tcx, Self>, instance: ty::Instance<'tcx>, args: &[OpTy<'tcx>], @@ -301,7 +402,7 @@ ) } - fn ptr_op<'a>( + fn ptr_op( _ecx: &EvalContext<'a, 'mir, 'tcx, Self>, _bin_op: mir::BinOp, _left: Scalar, @@ -314,14 +415,22 @@ ) } - fn find_foreign_static<'a>( + fn find_foreign_static( _tcx: TyCtxtAt<'a, 'tcx, 'tcx>, _def_id: DefId, - ) -> EvalResult<'tcx, &'tcx Allocation> { + ) -> EvalResult<'tcx, Cow<'tcx, Allocation>> { err!(ReadForeignStatic) } - fn box_alloc<'a>( + #[inline(always)] + fn static_with_default_tag( + alloc: &'_ Allocation + ) -> Cow<'_, Allocation> { + // We do not use a tag so we can just cheaply forward the reference + Cow::Borrowed(alloc) + } + + fn box_alloc( _ecx: &mut EvalContext<'a, 'mir, 'tcx, Self>, _dest: PlaceTy<'tcx>, ) -> EvalResult<'tcx> { @@ -329,6 +438,50 @@ ConstEvalError::NeedsRfc("heap allocations via `box` keyword".to_string()).into(), ) } + + fn before_terminator(ecx: &mut EvalContext<'a, 'mir, 'tcx, Self>) -> EvalResult<'tcx> { + { + let steps = &mut ecx.machine.steps_since_detector_enabled; + + *steps += 1; + if *steps < 0 { + return Ok(()); + } + + *steps %= DETECTOR_SNAPSHOT_PERIOD; + if *steps != 0 { + return Ok(()); + } + } + + let span = ecx.frame().span; + ecx.machine.loop_detector.observe_and_analyze( + &ecx.tcx, + span, + &ecx.memory, + &ecx.stack[..], + ) + } + + #[inline(always)] + fn tag_reference( + _ecx: &mut EvalContext<'a, 'mir, 'tcx, Self>, + _ptr: Pointer, + _pointee_ty: Ty<'tcx>, + _pointee_size: Size, + _borrow_kind: Option, + ) -> EvalResult<'tcx, Self::PointerTag> { + Ok(()) + } + + #[inline(always)] + fn tag_dereference( + _ecx: &EvalContext<'a, 'mir, 'tcx, Self>, + _ptr: Pointer, + _ptr_ty: Ty<'tcx>, + ) -> EvalResult<'tcx, Self::PointerTag> { + Ok(()) + } } /// Project to a field of a (variant of a) const diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/dataflow/at_location.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/dataflow/at_location.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/dataflow/at_location.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/dataflow/at_location.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,8 +12,7 @@ //! locations. use rustc::mir::{BasicBlock, Location}; -use rustc_data_structures::bitvec::BitIter; -use rustc_data_structures::indexed_set::{HybridIdxSet, IdxSet}; +use rustc_data_structures::bit_set::{BitIter, BitSet, HybridBitSet}; use dataflow::{BitDenotation, BlockSets, DataflowResults}; use dataflow::move_paths::{HasMoveData, MovePathIndex}; @@ -76,9 +75,9 @@ BD: BitDenotation, { base_results: DataflowResults, - curr_state: IdxSet, - stmt_gen: HybridIdxSet, - stmt_kill: HybridIdxSet, + curr_state: BitSet, + stmt_gen: HybridBitSet, + stmt_kill: HybridBitSet, } impl FlowAtLocation @@ -105,9 +104,9 @@ pub fn new(results: DataflowResults) -> Self { let bits_per_block = results.sets().bits_per_block(); - let curr_state = IdxSet::new_empty(bits_per_block); - let stmt_gen = HybridIdxSet::new_empty(bits_per_block); - let stmt_kill = HybridIdxSet::new_empty(bits_per_block); + let curr_state = BitSet::new_empty(bits_per_block); + let stmt_gen = HybridBitSet::new_empty(bits_per_block); + let stmt_kill = HybridBitSet::new_empty(bits_per_block); FlowAtLocation { base_results: results, curr_state: curr_state, @@ -121,7 +120,7 @@ self.base_results.operator() } - pub fn contains(&self, x: &BD::Idx) -> bool { + pub fn contains(&self, x: BD::Idx) -> bool { self.curr_state.contains(x) } @@ -224,7 +223,7 @@ // siblings); // - ~99% of the time the loop isn't reached, and this code is hot, so // we don't want to allocate `todo` unnecessarily. - if self.contains(&mpi) { + if self.contains(mpi) { return Some(mpi); } let move_data = self.operator().move_data(); @@ -236,7 +235,7 @@ }; while let Some(mpi) = todo.pop() { - if self.contains(&mpi) { + if self.contains(mpi) { return Some(mpi); } let move_path = &move_data.move_paths[mpi]; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/dataflow/graphviz.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/dataflow/graphviz.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/dataflow/graphviz.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/dataflow/graphviz.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,10 +12,8 @@ use syntax::ast::NodeId; use rustc::mir::{BasicBlock, Mir}; -use rustc_data_structures::bitvec::bits_to_string; use dot; -use dot::IntoCow; use std::fs; use std::io; @@ -217,13 +215,12 @@ let i = n.index(); let flow = self.mbcx.flow_state(); - let bits_per_block = flow.sets.bits_per_block(); write!(w, "")?; // Entry let set = flow.sets.on_entry_set_for(i); - write!(w, "{:?}", dot::escape_html(&bits_to_string(set.words(), bits_per_block)))?; + write!(w, "{:?}", dot::escape_html(&set.to_string()))?; // Terminator write!(w, "")?; @@ -259,7 +256,7 @@ .basic_blocks() .indices() .collect::>() - .into_cow() + .into() } fn edges(&self) -> dot::Edges { @@ -269,7 +266,7 @@ .indices() .flat_map(|bb| outgoing(mir, bb)) .collect::>() - .into_cow() + .into() } fn source(&self, edge: &Edge) -> Node { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/dataflow/impls/borrowed_locals.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/dataflow/impls/borrowed_locals.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/dataflow/impls/borrowed_locals.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/dataflow/impls/borrowed_locals.rs 2018-12-04 23:41:40.000000000 +0000 @@ -43,7 +43,7 @@ self.mir.local_decls.len() } - fn start_block_effect(&self, _sets: &mut IdxSet) { + fn start_block_effect(&self, _sets: &mut BitSet) { // Nothing is borrowed on function entry } @@ -58,7 +58,7 @@ // StorageDead invalidates all borrows and raw pointers to a local match stmt.kind { - StatementKind::StorageDead(l) => sets.kill(&l), + StatementKind::StorageDead(l) => sets.kill(l), _ => (), } } @@ -72,7 +72,7 @@ } fn propagate_call_return(&self, - _in_out: &mut IdxSet, + _in_out: &mut BitSet, _call_bb: mir::BasicBlock, _dest_bb: mir::BasicBlock, _dest_place: &mir::Place) { @@ -80,10 +80,10 @@ } } -impl<'a, 'tcx> BitwiseOperator for HaveBeenBorrowedLocals<'a, 'tcx> { +impl<'a, 'tcx> BitSetOperator for HaveBeenBorrowedLocals<'a, 'tcx> { #[inline] - fn join(&self, pred1: Word, pred2: Word) -> Word { - pred1 | pred2 // "maybe" means we union effects of both preds + fn join(&self, inout_set: &mut BitSet, in_set: &BitSet) -> bool { + inout_set.union(in_set) // "maybe" means we union effects of both preds } } @@ -118,7 +118,7 @@ location: Location) { if let Rvalue::Ref(_, _, ref place) = *rvalue { if let Some(local) = find_local(place) { - self.sets.gen(&local); + self.sets.gen(local); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/dataflow/impls/borrows.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/dataflow/impls/borrows.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/dataflow/impls/borrows.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/dataflow/impls/borrows.rs 2018-12-04 23:41:40.000000000 +0000 @@ -20,10 +20,9 @@ use rustc::ty::{RegionKind, RegionVid}; use rustc::ty::RegionKind::ReScope; -use rustc_data_structures::bitvec::{BitwiseOperator, Word}; +use rustc_data_structures::bit_set::{BitSet, BitSetOperator}; use rustc_data_structures::fx::FxHashMap; -use rustc_data_structures::indexed_set::IdxSet; -use rustc_data_structures::indexed_vec::IndexVec; +use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use rustc_data_structures::sync::Lrc; use dataflow::{BitDenotation, BlockSets, InitialFlow}; @@ -78,7 +77,7 @@ // `visited` once they are added to `stack`, before they are actually // processed, because this avoids the need to look them up again on // completion. - let mut visited = FxHashMap(); + let mut visited = FxHashMap::default(); visited.insert(location.block, location.statement_index); let mut stack = vec![]; @@ -163,7 +162,7 @@ } }); - let mut borrows_out_of_scope_at_location = FxHashMap(); + let mut borrows_out_of_scope_at_location = FxHashMap::default(); for (borrow_index, borrow_data) in borrow_set.borrows.iter_enumerated() { let borrow_region = borrow_data.region.to_region_vid(); let location = borrow_set.borrows[borrow_index].reserve_location; @@ -230,7 +229,7 @@ self.borrow_set.borrows.len() * 2 } - fn start_block_effect(&self, _entry_set: &mut IdxSet) { + fn start_block_effect(&self, _entry_set: &mut BitSet) { // no borrows of code region_scopes have been taken prior to // function execution, so this method has no effect on // `_sets`. @@ -271,7 +270,7 @@ // re-consider the current implementations of the // propagate_call_return method. - if let mir::Rvalue::Ref(region, _, ref place) = *rhs { + if let mir::Rvalue::Ref(region, _, ref place) = **rhs { if place.ignore_borrow( self.tcx, self.mir, @@ -289,7 +288,7 @@ debug!("Borrows::statement_effect_on_borrows \ location: {:?} stmt: {:?} has empty region, killing {:?}", location, stmt.kind, index); - sets.kill(&index); + sets.kill(*index); return } else { debug!("Borrows::statement_effect_on_borrows location: {:?} stmt: {:?}", @@ -299,7 +298,7 @@ assert!(self.borrow_set.region_map.get(region).unwrap_or_else(|| { panic!("could not find BorrowIndexs for region {:?}", region); }).contains(&index)); - sets.gen(&index); + sets.gen(*index); // Issue #46746: Two-phase borrows handles // stmts of form `Tmp = &mut Borrow` ... @@ -311,7 +310,7 @@ // e.g. `box (&mut _)`. Current // conservative solution: force // immediate activation here. - sets.gen(&index); + sets.gen(*index); } } } @@ -337,7 +336,7 @@ } } - mir::StatementKind::ReadForMatch(..) | + mir::StatementKind::FakeRead(..) | mir::StatementKind::SetDiscriminant { .. } | mir::StatementKind::StorageLive(..) | mir::StatementKind::Validate(..) | @@ -381,7 +380,7 @@ if *scope != root_scope && self.scope_tree.is_subscope_of(*scope, root_scope) { - sets.kill(&borrow_index); + sets.kill(borrow_index); } } } @@ -402,7 +401,7 @@ } fn propagate_call_return(&self, - _in_out: &mut IdxSet, + _in_out: &mut BitSet, _call_bb: mir::BasicBlock, _dest_bb: mir::BasicBlock, _dest_place: &mir::Place) { @@ -414,10 +413,10 @@ } } -impl<'a, 'gcx, 'tcx> BitwiseOperator for Borrows<'a, 'gcx, 'tcx> { +impl<'a, 'gcx, 'tcx> BitSetOperator for Borrows<'a, 'gcx, 'tcx> { #[inline] - fn join(&self, pred1: Word, pred2: Word) -> Word { - pred1 | pred2 // union effects of preds when computing reservations + fn join(&self, inout_set: &mut BitSet, in_set: &BitSet) -> bool { + inout_set.union(in_set) // "maybe" means we union effects of both preds } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/dataflow/impls/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/dataflow/impls/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/dataflow/impls/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/dataflow/impls/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,8 +14,7 @@ use rustc::ty::TyCtxt; use rustc::mir::{self, Mir, Location}; -use rustc_data_structures::bitvec::{BitwiseOperator, Word}; -use rustc_data_structures::indexed_set::{IdxSet}; +use rustc_data_structures::bit_set::{BitSet, BitSetOperator}; use rustc_data_structures::indexed_vec::Idx; use super::MoveDataParamEnv; @@ -266,8 +265,8 @@ state: DropFlagState) { match state { - DropFlagState::Absent => sets.kill(&path), - DropFlagState::Present => sets.gen(&path), + DropFlagState::Absent => sets.kill(path), + DropFlagState::Present => sets.gen(path), } } } @@ -277,8 +276,8 @@ state: DropFlagState) { match state { - DropFlagState::Absent => sets.gen(&path), - DropFlagState::Present => sets.kill(&path), + DropFlagState::Absent => sets.gen(path), + DropFlagState::Present => sets.kill(path), } } } @@ -288,8 +287,8 @@ state: DropFlagState) { match state { - DropFlagState::Absent => sets.kill(&path), - DropFlagState::Present => sets.gen(&path), + DropFlagState::Absent => sets.kill(path), + DropFlagState::Present => sets.gen(path), } } } @@ -301,12 +300,12 @@ self.move_data().move_paths.len() } - fn start_block_effect(&self, entry_set: &mut IdxSet) { + fn start_block_effect(&self, entry_set: &mut BitSet) { drop_flag_effects_for_function_entry( self.tcx, self.mir, self.mdpe, |path, s| { assert!(s == DropFlagState::Present); - entry_set.add(&path); + entry_set.insert(path); }); } @@ -333,7 +332,7 @@ } fn propagate_call_return(&self, - in_out: &mut IdxSet, + in_out: &mut BitSet, _call_bb: mir::BasicBlock, _dest_bb: mir::BasicBlock, dest_place: &mir::Place) { @@ -341,7 +340,7 @@ // the bits for that dest_place to 1 (initialized). on_lookup_result_bits(self.tcx, self.mir, self.move_data(), self.move_data().rev_lookup.find(dest_place), - |mpi| { in_out.add(&mpi); }); + |mpi| { in_out.insert(mpi); }); } } @@ -353,15 +352,16 @@ } // sets on_entry bits for Arg places - fn start_block_effect(&self, entry_set: &mut IdxSet) { + fn start_block_effect(&self, entry_set: &mut BitSet) { // set all bits to 1 (uninit) before gathering counterevidence - entry_set.set_up_to(self.bits_per_block()); + assert!(self.bits_per_block() == entry_set.domain_size()); + entry_set.insert_all(); drop_flag_effects_for_function_entry( self.tcx, self.mir, self.mdpe, |path, s| { assert!(s == DropFlagState::Present); - entry_set.remove(&path); + entry_set.remove(path); }); } @@ -388,7 +388,7 @@ } fn propagate_call_return(&self, - in_out: &mut IdxSet, + in_out: &mut BitSet, _call_bb: mir::BasicBlock, _dest_bb: mir::BasicBlock, dest_place: &mir::Place) { @@ -396,7 +396,7 @@ // the bits for that dest_place to 0 (initialized). on_lookup_result_bits(self.tcx, self.mir, self.move_data(), self.move_data().rev_lookup.find(dest_place), - |mpi| { in_out.remove(&mpi); }); + |mpi| { in_out.remove(mpi); }); } } @@ -408,14 +408,14 @@ } // sets on_entry bits for Arg places - fn start_block_effect(&self, entry_set: &mut IdxSet) { + fn start_block_effect(&self, entry_set: &mut BitSet) { entry_set.clear(); drop_flag_effects_for_function_entry( self.tcx, self.mir, self.mdpe, |path, s| { assert!(s == DropFlagState::Present); - entry_set.add(&path); + entry_set.insert(path); }); } @@ -442,7 +442,7 @@ } fn propagate_call_return(&self, - in_out: &mut IdxSet, + in_out: &mut BitSet, _call_bb: mir::BasicBlock, _dest_bb: mir::BasicBlock, dest_place: &mir::Place) { @@ -450,7 +450,7 @@ // the bits for that dest_place to 1 (initialized). on_lookup_result_bits(self.tcx, self.mir, self.move_data(), self.move_data().rev_lookup.find(dest_place), - |mpi| { in_out.add(&mpi); }); + |mpi| { in_out.insert(mpi); }); } } @@ -461,9 +461,9 @@ self.move_data().inits.len() } - fn start_block_effect(&self, entry_set: &mut IdxSet) { + fn start_block_effect(&self, entry_set: &mut BitSet) { for arg_init in 0..self.mir.arg_count { - entry_set.add(&InitIndex::new(arg_init)); + entry_set.insert(InitIndex::new(arg_init)); } } @@ -531,7 +531,7 @@ } fn propagate_call_return(&self, - in_out: &mut IdxSet, + in_out: &mut BitSet, call_bb: mir::BasicBlock, _dest_bb: mir::BasicBlock, _dest_place: &mir::Place) { @@ -545,36 +545,36 @@ }; for init_index in &init_loc_map[call_loc] { assert!(init_index.index() < bits_per_block); - in_out.add(init_index); + in_out.insert(*init_index); } } } -impl<'a, 'gcx, 'tcx> BitwiseOperator for MaybeInitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'gcx, 'tcx> BitSetOperator for MaybeInitializedPlaces<'a, 'gcx, 'tcx> { #[inline] - fn join(&self, pred1: Word, pred2: Word) -> Word { - pred1 | pred2 // "maybe" means we union effects of both preds + fn join(&self, inout_set: &mut BitSet, in_set: &BitSet) -> bool { + inout_set.union(in_set) // "maybe" means we union effects of both preds } } -impl<'a, 'gcx, 'tcx> BitwiseOperator for MaybeUninitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'gcx, 'tcx> BitSetOperator for MaybeUninitializedPlaces<'a, 'gcx, 'tcx> { #[inline] - fn join(&self, pred1: Word, pred2: Word) -> Word { - pred1 | pred2 // "maybe" means we union effects of both preds + fn join(&self, inout_set: &mut BitSet, in_set: &BitSet) -> bool { + inout_set.union(in_set) // "maybe" means we union effects of both preds } } -impl<'a, 'gcx, 'tcx> BitwiseOperator for DefinitelyInitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'gcx, 'tcx> BitSetOperator for DefinitelyInitializedPlaces<'a, 'gcx, 'tcx> { #[inline] - fn join(&self, pred1: Word, pred2: Word) -> Word { - pred1 & pred2 // "definitely" means we intersect effects of both preds + fn join(&self, inout_set: &mut BitSet, in_set: &BitSet) -> bool { + inout_set.intersect(in_set) // "definitely" means we intersect effects of both preds } } -impl<'a, 'gcx, 'tcx> BitwiseOperator for EverInitializedPlaces<'a, 'gcx, 'tcx> { +impl<'a, 'gcx, 'tcx> BitSetOperator for EverInitializedPlaces<'a, 'gcx, 'tcx> { #[inline] - fn join(&self, pred1: Word, pred2: Word) -> Word { - pred1 | pred2 // inits from both preds are in scope + fn join(&self, inout_set: &mut BitSet, in_set: &BitSet) -> bool { + inout_set.union(in_set) // inits from both preds are in scope } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/dataflow/impls/storage_liveness.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/dataflow/impls/storage_liveness.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/dataflow/impls/storage_liveness.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/dataflow/impls/storage_liveness.rs 2018-12-04 23:41:40.000000000 +0000 @@ -36,7 +36,7 @@ self.mir.local_decls.len() } - fn start_block_effect(&self, _sets: &mut IdxSet) { + fn start_block_effect(&self, _sets: &mut BitSet) { // Nothing is live on function entry } @@ -46,8 +46,8 @@ let stmt = &self.mir[loc.block].statements[loc.statement_index]; match stmt.kind { - StatementKind::StorageLive(l) => sets.gen(&l), - StatementKind::StorageDead(l) => sets.kill(&l), + StatementKind::StorageLive(l) => sets.gen(l), + StatementKind::StorageDead(l) => sets.kill(l), _ => (), } } @@ -59,7 +59,7 @@ } fn propagate_call_return(&self, - _in_out: &mut IdxSet, + _in_out: &mut BitSet, _call_bb: mir::BasicBlock, _dest_bb: mir::BasicBlock, _dest_place: &mir::Place) { @@ -67,10 +67,10 @@ } } -impl<'a, 'tcx> BitwiseOperator for MaybeStorageLive<'a, 'tcx> { +impl<'a, 'tcx> BitSetOperator for MaybeStorageLive<'a, 'tcx> { #[inline] - fn join(&self, pred1: Word, pred2: Word) -> Word { - pred1 | pred2 // "maybe" means we union effects of both preds + fn join(&self, inout_set: &mut BitSet, in_set: &BitSet) -> bool { + inout_set.union(in_set) // "maybe" means we union effects of both preds } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/dataflow/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/dataflow/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/dataflow/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/dataflow/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,8 +10,7 @@ use syntax::ast::{self, MetaItem}; -use rustc_data_structures::bitvec::{bitwise, BitwiseOperator}; -use rustc_data_structures::indexed_set::{HybridIdxSet, IdxSet}; +use rustc_data_structures::bit_set::{BitSet, BitSetOperator, HybridBitSet}; use rustc_data_structures::indexed_vec::Idx; use rustc_data_structures::work_queue::WorkQueue; @@ -125,7 +124,7 @@ mir: &'a Mir<'tcx>, node_id: ast::NodeId, attributes: &[ast::Attribute], - dead_unwinds: &IdxSet, + dead_unwinds: &BitSet, bd: BD, p: P) -> DataflowResults @@ -182,7 +181,7 @@ impl<'a, 'tcx: 'a, BD> DataflowAnalysis<'a, 'tcx, BD> where BD: BitDenotation { fn propagate(&mut self) { - let mut temp = IdxSet::new_empty(self.flow_state.sets.bits_per_block); + let mut temp = BitSet::new_empty(self.flow_state.sets.bits_per_block); let mut propcx = PropagationContext { builder: self, }; @@ -231,7 +230,7 @@ impl<'b, 'a: 'b, 'tcx: 'a, BD> PropagationContext<'b, 'a, 'tcx, BD> where BD: BitDenotation { - fn walk_cfg(&mut self, in_out: &mut IdxSet) { + fn walk_cfg(&mut self, in_out: &mut BitSet) { let mut dirty_queue: WorkQueue = WorkQueue::with_all(self.builder.mir.basic_blocks().len()); let mir = self.builder.mir; @@ -352,7 +351,7 @@ analysis: &T, result: &DataflowResults, mir: &Mir<'tcx>) - -> IdxSet { + -> BitSet { let mut on_entry = result.sets().on_entry_set_for(loc.block.index()).to_owned(); let mut kill_set = on_entry.to_hybrid(); let mut gen_set = kill_set.clone(); @@ -385,7 +384,7 @@ pub struct DataflowAnalysis<'a, 'tcx: 'a, O> where O: BitDenotation { flow_state: DataflowState, - dead_unwinds: &'a IdxSet, + dead_unwinds: &'a BitSet, mir: &'a Mir<'tcx>, } @@ -426,7 +425,7 @@ impl DataflowState { pub(crate) fn interpret_set<'c, P>(&self, o: &'c O, - set: &IdxSet, + set: &BitSet, render_idx: &P) -> Vec where P: Fn(&O, O::Idx) -> DebugFormatted @@ -436,7 +435,7 @@ pub(crate) fn interpret_hybrid_set<'c, P>(&self, o: &'c O, - set: &HybridIdxSet, + set: &HybridBitSet, render_idx: &P) -> Vec where P: Fn(&O, O::Idx) -> DebugFormatted @@ -451,21 +450,21 @@ bits_per_block: usize, /// For each block, bits valid on entry to the block. - on_entry_sets: Vec>, + on_entry_sets: Vec>, /// For each block, bits generated by executing the statements + /// terminator in the block -- with one caveat. In particular, for /// *call terminators*, the effect of storing the destination is /// not included, since that only takes effect on the **success** /// edge (and not the unwind edge). - gen_sets: Vec>, + gen_sets: Vec>, /// For each block, bits killed by executing the statements + /// terminator in the block -- with one caveat. In particular, for /// *call terminators*, the effect of storing the destination is /// not included, since that only takes effect on the **success** /// edge (and not the unwind edge). - kill_sets: Vec>, + kill_sets: Vec>, } /// Triple of sets associated with a given block. @@ -485,20 +484,20 @@ #[derive(Debug)] pub struct BlockSets<'a, E: Idx> { /// Dataflow state immediately before control flow enters the given block. - pub(crate) on_entry: &'a mut IdxSet, + pub(crate) on_entry: &'a mut BitSet, /// Bits that are set to 1 by the time we exit the given block. Hybrid /// because it usually contains only 0 or 1 elements. - pub(crate) gen_set: &'a mut HybridIdxSet, + pub(crate) gen_set: &'a mut HybridBitSet, /// Bits that are set to 0 by the time we exit the given block. Hybrid /// because it usually contains only 0 or 1 elements. - pub(crate) kill_set: &'a mut HybridIdxSet, + pub(crate) kill_set: &'a mut HybridBitSet, } impl<'a, E:Idx> BlockSets<'a, E> { - fn gen(&mut self, e: &E) { - self.gen_set.add(e); + fn gen(&mut self, e: E) { + self.gen_set.insert(e); self.kill_set.remove(e); } fn gen_all(&mut self, i: I) @@ -506,13 +505,13 @@ I::Item: Borrow { for j in i { - self.gen(j.borrow()); + self.gen(*j.borrow()); } } - fn kill(&mut self, e: &E) { + fn kill(&mut self, e: E) { self.gen_set.remove(e); - self.kill_set.add(e); + self.kill_set.insert(e); } fn kill_all(&mut self, i: I) @@ -520,7 +519,7 @@ I::Item: Borrow { for j in i { - self.kill(j.borrow()); + self.kill(*j.borrow()); } } @@ -540,13 +539,13 @@ } } - pub fn on_entry_set_for(&self, block_idx: usize) -> &IdxSet { + pub fn on_entry_set_for(&self, block_idx: usize) -> &BitSet { &self.on_entry_sets[block_idx] } - pub fn gen_set_for(&self, block_idx: usize) -> &HybridIdxSet { + pub fn gen_set_for(&self, block_idx: usize) -> &HybridBitSet { &self.gen_sets[block_idx] } - pub fn kill_set_for(&self, block_idx: usize) -> &HybridIdxSet { + pub fn kill_set_for(&self, block_idx: usize) -> &HybridBitSet { &self.kill_sets[block_idx] } } @@ -562,7 +561,7 @@ fn bottom_value() -> bool; } -pub trait BitDenotation: BitwiseOperator { +pub trait BitDenotation: BitSetOperator { /// Specifies what index type is used to access the bitvector. type Idx: Idx; @@ -609,7 +608,7 @@ /// these won't be accounted for correctly. /// /// (For example, establishing the call arguments.) - fn start_block_effect(&self, entry_set: &mut IdxSet); + fn start_block_effect(&self, entry_set: &mut BitSet); /// Similar to `statement_effect`, except it applies /// *just before* the statement rather than *just after* it. @@ -689,7 +688,7 @@ /// kill-sets associated with each edge coming out of the basic /// block. fn propagate_call_return(&self, - in_out: &mut IdxSet, + in_out: &mut BitSet, call_bb: mir::BasicBlock, dest_bb: mir::BasicBlock, dest_place: &mir::Place); @@ -698,17 +697,17 @@ impl<'a, 'tcx, D> DataflowAnalysis<'a, 'tcx, D> where D: BitDenotation { pub fn new(mir: &'a Mir<'tcx>, - dead_unwinds: &'a IdxSet, + dead_unwinds: &'a BitSet, denotation: D) -> Self where D: InitialFlow { let bits_per_block = denotation.bits_per_block(); let num_blocks = mir.basic_blocks().len(); let on_entry_sets = if D::bottom_value() { - vec![IdxSet::new_filled(bits_per_block); num_blocks] + vec![BitSet::new_filled(bits_per_block); num_blocks] } else { - vec![IdxSet::new_empty(bits_per_block); num_blocks] + vec![BitSet::new_empty(bits_per_block); num_blocks] }; - let gen_sets = vec![HybridIdxSet::new_empty(bits_per_block); num_blocks]; + let gen_sets = vec![HybridBitSet::new_empty(bits_per_block); num_blocks]; let kill_sets = gen_sets.clone(); DataflowAnalysis { @@ -727,7 +726,7 @@ } pub fn new_from_sets(mir: &'a Mir<'tcx>, - dead_unwinds: &'a IdxSet, + dead_unwinds: &'a BitSet, sets: AllSets, denotation: D) -> Self { DataflowAnalysis { @@ -758,7 +757,7 @@ /// unwind target). fn propagate_bits_into_graph_successors_of( &mut self, - in_out: &mut IdxSet, + in_out: &mut BitSet, (bb, bb_data): (mir::BasicBlock, &mir::BasicBlockData), dirty_list: &mut WorkQueue) { @@ -787,7 +786,7 @@ target, value: _, location: _, unwind: Some(unwind) } => { self.propagate_bits_into_entry_set_for(in_out, target, dirty_list); - if !self.dead_unwinds.contains(&bb) { + if !self.dead_unwinds.contains(bb) { self.propagate_bits_into_entry_set_for(in_out, unwind, dirty_list); } } @@ -796,9 +795,9 @@ self.propagate_bits_into_entry_set_for(in_out, *target, dirty_list); } } - mir::TerminatorKind::Call { cleanup, ref destination, func: _, args: _ } => { + mir::TerminatorKind::Call { cleanup, ref destination, .. } => { if let Some(unwind) = cleanup { - if !self.dead_unwinds.contains(&bb) { + if !self.dead_unwinds.contains(bb) { self.propagate_bits_into_entry_set_for(in_out, unwind, dirty_list); } } @@ -819,7 +818,7 @@ mir::TerminatorKind::FalseUnwind { real_target, unwind } => { self.propagate_bits_into_entry_set_for(in_out, real_target, dirty_list); if let Some(unwind) = unwind { - if !self.dead_unwinds.contains(&bb) { + if !self.dead_unwinds.contains(bb) { self.propagate_bits_into_entry_set_for(in_out, unwind, dirty_list); } } @@ -828,13 +827,11 @@ } fn propagate_bits_into_entry_set_for(&mut self, - in_out: &IdxSet, + in_out: &BitSet, bb: mir::BasicBlock, dirty_queue: &mut WorkQueue) { - let entry_set = self.flow_state.sets.for_block(bb.index()).on_entry; - let set_changed = bitwise(entry_set.words_mut(), - in_out.words(), - &self.flow_state.operator); + let entry_set = &mut self.flow_state.sets.for_block(bb.index()).on_entry; + let set_changed = self.flow_state.operator.join(entry_set, &in_out); if set_changed { dirty_queue.insert(bb); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/dataflow/move_paths/builder.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/dataflow/move_paths/builder.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/dataflow/move_paths/builder.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/dataflow/move_paths/builder.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,6 @@ use rustc::ty::{self, TyCtxt}; use rustc::mir::*; use rustc::mir::tcx::RvalueInitializationState; -use rustc::util::nodemap::FxHashMap; use rustc_data_structures::indexed_vec::{IndexVec}; use std::collections::hash_map::Entry; @@ -53,7 +52,7 @@ v, ) }).collect(), - projections: FxHashMap(), + projections: Default::default(), }, move_paths, path_map, @@ -281,7 +280,7 @@ } self.gather_rvalue(rval); } - StatementKind::ReadForMatch(ref place) => { + StatementKind::FakeRead(_, ref place) => { self.create_move_path(place); } StatementKind::InlineAsm { ref outputs, ref inputs, ref asm } => { @@ -290,7 +289,7 @@ self.gather_init(output, InitKind::Deep); } } - for input in inputs { + for input in inputs.iter() { self.gather_operand(input); } } @@ -380,7 +379,13 @@ self.gather_operand(value); self.gather_init(location, InitKind::Deep); } - TerminatorKind::Call { ref func, ref args, ref destination, cleanup: _ } => { + TerminatorKind::Call { + ref func, + ref args, + ref destination, + cleanup: _, + from_hir_call: _, + } => { self.gather_operand(func); for arg in args { self.gather_operand(arg); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/dataflow/move_paths/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/dataflow/move_paths/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/dataflow/move_paths/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/dataflow/move_paths/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -97,6 +97,20 @@ pub place: Place<'tcx>, } +impl<'tcx> MovePath<'tcx> { + pub fn parents(&self, move_paths: &IndexVec) -> Vec { + let mut parents = Vec::new(); + + let mut curr_parent = self.parent; + while let Some(parent_mpi) = curr_parent { + parents.push(parent_mpi); + curr_parent = move_paths[parent_mpi].parent; + } + + parents + } +} + impl<'tcx> fmt::Debug for MovePath<'tcx> { fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { write!(w, "MovePath {{")?; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/diagnostics.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/diagnostics.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/diagnostics.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/diagnostics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -665,24 +665,6 @@ ``` "##, -E0022: r##" -Constant functions are not allowed to mutate anything. Thus, binding to an -argument with a mutable pattern is not allowed. For example, - -```compile_fail -const fn foo(mut x: u8) { - // do stuff -} -``` - -Is incorrect because the function body may not mutate `x`. - -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. -"##, - E0133: r##" Unsafe code was used outside of an unsafe function or block. @@ -1991,6 +1973,26 @@ ``` "##, +E0510: r##" +Cannot mutate place in this match guard. + +When matching on a variable it cannot be mutated in the match guards, as this +could cause the match to be non-exhaustive: + +```compile_fail,E0510 +#![feature(nll, bind_by_move_pattern_guards)] +let mut x = Some(0); +match x { + None => (), + Some(v) if { x = None; false } => (), + Some(_) => (), // No longer matches +} +``` + +Here executing `x = None` would modify the value being matched and require us +to go "back in time" to the `None` arm. +"##, + E0579: r##" When matching against an exclusive range, the compiler verifies that the range is non-empty. Exclusive range patterns include the start point but not the end @@ -2009,6 +2011,46 @@ ``` "##, +E0515: r##" +Cannot return value that references local variable + +Local variables, function parameters and temporaries are all dropped before the +end of the function body. So a reference to them cannot be returned. + +```compile_fail,E0515 +#![feature(nll)] +fn get_dangling_reference() -> &'static i32 { + let x = 0; + &x +} +``` + +```compile_fail,E0515 +#![feature(nll)] +use std::slice::Iter; +fn get_dangling_iterator<'a>() -> Iter<'a, i32> { + let v = vec![1, 2, 3]; + v.iter() +} +``` + +Consider returning an owned value instead: + +``` +use std::vec::IntoIter; + +fn get_integer() -> i32 { + let x = 0; + x +} + +fn get_owned_iterator() -> IntoIter { + let v = vec![1, 2, 3]; + v.into_iter() +} +``` +"##, + E0595: r##" Closures cannot mutate immutable captured variables. @@ -2187,6 +2229,148 @@ ``` "##, +E0713: r##" +This error occurs when an attempt is made to borrow state past the end of the +lifetime of a type that implements the `Drop` trait. + +Example of erroneous code: + +```compile_fail,E0713 +#![feature(nll)] + +pub struct S<'a> { data: &'a mut String } + +impl<'a> Drop for S<'a> { + fn drop(&mut self) { self.data.push_str("being dropped"); } +} + +fn demo<'a>(s: S<'a>) -> &'a mut String { let p = &mut *s.data; p } +``` + +Here, `demo` tries to borrow the string data held within its +argument `s` and then return that borrow. However, `S` is +declared as implementing `Drop`. + +Structs implementing the `Drop` trait have an implicit destructor that +gets called when they go out of scope. This destructor gets exclusive +access to the fields of the struct when it runs. + +This means that when `s` reaches the end of `demo`, its destructor +gets exclusive access to its `&mut`-borrowed string data. allowing +another borrow of that string data (`p`), to exist across the drop of +`s` would be a violation of the principle that `&mut`-borrows have +exclusive, unaliased access to their referenced data. + +This error can be fixed by changing `demo` so that the destructor does +not run while the string-data is borrowed; for example by taking `S` +by reference: + +``` +#![feature(nll)] + +pub struct S<'a> { data: &'a mut String } + +impl<'a> Drop for S<'a> { + fn drop(&mut self) { self.data.push_str("being dropped"); } +} + +fn demo<'a>(s: &'a mut S<'a>) -> &'a mut String { let p = &mut *(*s).data; p } +``` + +Note that this approach needs a reference to S with lifetime `'a`. +Nothing shorter than `'a` will suffice: a shorter lifetime would imply +that after `demo` finishes executing, something else (such as the +destructor!) could access `s.data` after the end of that shorter +lifetime, which would again violate the `&mut`-borrow's exclusive +access. +"##, + +E0716: r##" +This error indicates that a temporary value is being dropped +while a borrow is still in active use. + +Erroneous code example: + +```compile_fail,E0716 +# #![feature(nll)] +fn foo() -> i32 { 22 } +fn bar(x: &i32) -> &i32 { x } +let p = bar(&foo()); + // ------ creates a temporary +let q = *p; +``` + +Here, the expression `&foo()` is borrowing the expression +`foo()`. As `foo()` is call to a function, and not the name of +a variable, this creates a **temporary** -- that temporary stores +the return value from `foo()` so that it can be borrowed. +So you might imagine that `let p = bar(&foo())` is equivalent +to this: + +```compile_fail,E0597 +# fn foo() -> i32 { 22 } +# fn bar(x: &i32) -> &i32 { x } +let p = { + let tmp = foo(); // the temporary + bar(&tmp) +}; // <-- tmp is freed as we exit this block +let q = p; +``` + +Whenever a temporary is created, it is automatically dropped (freed) +according to fixed rules. Ordinarily, the temporary is dropped +at the end of the enclosing statement -- in this case, after the `let`. +This is illustrated in the example above by showing that `tmp` would +be freed as we exit the block. + +To fix this problem, you need to create a local variable +to store the value in rather than relying on a temporary. +For example, you might change the original program to +the following: + +``` +fn foo() -> i32 { 22 } +fn bar(x: &i32) -> &i32 { x } +let value = foo(); // dropped at the end of the enclosing block +let p = bar(&value); +let q = *p; +``` + +By introducing the explicit `let value`, we allocate storage +that will last until the end of the enclosing block (when `value` +goes out of scope). When we borrow `&value`, we are borrowing a +local variable that already exists, and hence no temporary is created. + +Temporaries are not always dropped at the end of the enclosing +statement. In simple cases where the `&` expression is immediately +stored into a variable, the compiler will automatically extend +the lifetime of the temporary until the end of the enclosinb +block. Therefore, an alternative way to fix the original +program is to write `let tmp = &foo()` and not `let tmp = foo()`: + +``` +fn foo() -> i32 { 22 } +fn bar(x: &i32) -> &i32 { x } +let value = &foo(); +let p = bar(value); +let q = *p; +``` + +Here, we are still borrowing `foo()`, but as the borrow is assigned +directly into a variable, the temporary will not be dropped until +the end of the enclosing block. Similar rules apply when temporaries +are stored into aggregate structures like a tuple or struct: + +``` +// Here, two temporaries are created, but +// as they are stored directly into `value`, +// they are not dropped until the end of the +// enclosing block. +fn foo() -> i32 { 22 } +let value = (&foo(), &foo()); +``` +"##, + } register_diagnostics! { @@ -2195,6 +2379,7 @@ // E0471, // constant evaluation error (in pattern) // E0385, // {} in an aliasable location E0493, // destructors cannot be evaluated at compile-time + E0521, // borrowed data escapes outside of closure E0524, // two closures require unique access to `..` at the same time E0526, // shuffle indices are not constant E0594, // cannot assign to {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/hair/cx/block.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/hair/cx/block.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/hair/cx/block.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/hair/cx/block.rs 2018-12-04 23:41:40.000000000 +0000 @@ -86,12 +86,13 @@ let mut pattern = cx.pattern_from_hir(&local.pat); if let Some(ty) = &local.ty { - if let Some(user_ty) = cx.tables.user_provided_tys().get(ty.hir_id) { + if let Some(&user_ty) = cx.tables.user_provided_tys().get(ty.hir_id) { pattern = Pattern { ty: pattern.ty, span: pattern.span, kind: Box::new(PatternKind::AscribeUserType { - user_ty: *user_ty, + user_ty: PatternTypeProjection::from_canonical_ty(user_ty), + user_ty_span: ty.span, subpattern: pattern }) }; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/hair/cx/expr.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/hair/cx/expr.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/hair/cx/expr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/hair/cx/expr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,6 +13,7 @@ use hair::cx::Cx; use hair::cx::block; use hair::cx::to_ref::ToRef; +use hair::util::UserAnnotatedTyHelpers; use rustc::hir::def::{Def, CtorKind}; use rustc::mir::interpret::GlobalId; use rustc::ty::{self, AdtKind, Ty}; @@ -21,6 +22,7 @@ use rustc::hir; use rustc::hir::def_id::LocalDefId; use rustc::mir::{BorrowKind}; +use syntax_pos::Span; impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr { type Output = Expr<'tcx>; @@ -232,9 +234,9 @@ let kind = match expr.node { // Here comes the interesting stuff: - hir::ExprKind::MethodCall(.., ref args) => { + hir::ExprKind::MethodCall(_, method_span, ref args) => { // Rewrite a.b(c) into UFCS form like Trait::b(a, c) - let expr = method_callee(cx, expr, None); + let expr = method_callee(cx, expr, method_span,None); let args = args.iter() .map(|e| e.to_ref()) .collect(); @@ -242,6 +244,7 @@ ty: expr.ty, fun: expr.to_ref(), args, + from_hir_call: true, } } @@ -254,7 +257,7 @@ // rewrite f(u, v) into FnOnce::call_once(f, (u, v)) - let method = method_callee(cx, expr, None); + let method = method_callee(cx, expr, fun.span,None); let arg_tys = args.iter().map(|e| cx.tables().expr_ty_adjusted(e)); let tupled_args = Expr { @@ -268,6 +271,7 @@ ty: method.ty, fun: method.to_ref(), args: vec![fun.to_ref(), tupled_args.to_ref()], + from_hir_call: true, } } else { let adt_data = if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = @@ -291,13 +295,7 @@ let substs = cx.tables().node_substs(fun.hir_id); let user_ty = cx.tables().user_substs(fun.hir_id) - .map(|user_substs| { - user_substs.unchecked_map(|user_substs| { - // Here, we just pair an `AdtDef` with the - // `user_substs`, so no new types etc are introduced. - cx.tcx().mk_adt(adt_def, user_substs) - }) - }); + .map(|user_substs| UserTypeAnnotation::TypeOf(adt_def.did, user_substs)); let field_refs = args.iter() .enumerate() @@ -321,6 +319,7 @@ ty: cx.tables().node_id_to_type(fun.hir_id), fun: fun.to_ref(), args: args.to_ref(), + from_hir_call: true, } } } @@ -471,7 +470,7 @@ adt_def: adt, variant_index: 0, substs, - user_ty: user_annotated_ty_for_adt(cx, expr.hir_id, adt), + user_ty: cx.user_substs_applied_to_adt(expr.hir_id, adt), fields: field_refs(cx, fields), base: base.as_ref().map(|base| { FruInfo { @@ -497,7 +496,7 @@ adt_def: adt, variant_index: index, substs, - user_ty: user_annotated_ty_for_adt(cx, expr.hir_id, adt), + user_ty: cx.user_substs_applied_to_adt(expr.hir_id, adt), fields: field_refs(cx, fields), base: None, } @@ -638,12 +637,25 @@ name: Field::new(cx.tcx.field_index(expr.id, cx.tables)), } } - hir::ExprKind::Cast(ref source, _) => { + hir::ExprKind::Cast(ref source, ref cast_ty) => { + // Check for a user-given type annotation on this `cast` + let user_ty = cx.tables.user_provided_tys().get(cast_ty.hir_id) + .map(|&t| UserTypeAnnotation::Ty(t)); + + debug!( + "cast({:?}) has ty w/ hir_id {:?} and user provided ty {:?}", + expr, + cast_ty.hir_id, + user_ty, + ); + // Check to see if this cast is a "coercion cast", where the cast is actually done // using a coercion (or is a no-op). - if let Some(&TyCastKind::CoercionCast) = cx.tables() - .cast_kinds() - .get(source.hir_id) { + let cast = if let Some(&TyCastKind::CoercionCast) = + cx.tables() + .cast_kinds() + .get(source.hir_id) + { // Convert the lexpr to a vexpr. ExprKind::Use { source: source.to_ref() } } else { @@ -680,24 +692,30 @@ } else { None }; - let source = if let Some((did, offset, ty)) = var { + + let source = if let Some((did, offset, var_ty)) = var { let mk_const = |literal| Expr { temp_lifetime, - ty, + ty: var_ty, span: expr.span, kind: ExprKind::Literal { literal, user_ty: None }, }.to_ref(); let offset = mk_const(ty::Const::from_bits( cx.tcx, offset as u128, - cx.param_env.and(ty), + cx.param_env.and(var_ty), )); match did { Some(did) => { // in case we are offsetting from a computed discriminant // and not the beginning of discriminants (which is always `0`) let substs = Substs::identity_for_item(cx.tcx(), did); - let lhs = mk_const(ty::Const::unevaluated(cx.tcx(), did, substs, ty)); + let lhs = mk_const(ty::Const::unevaluated( + cx.tcx(), + did, + substs, + var_ty, + )); let bin = ExprKind::Binary { op: BinOp::Add, lhs, @@ -705,7 +723,7 @@ }; Expr { temp_lifetime, - ty, + ty: var_ty, span: expr.span, kind: bin, }.to_ref() @@ -715,10 +733,45 @@ } else { source.to_ref() }; + ExprKind::Cast { source } + }; + + if let Some(user_ty) = user_ty { + // NOTE: Creating a new Expr and wrapping a Cast inside of it may be + // inefficient, revisit this when performance becomes an issue. + let cast_expr = Expr { + temp_lifetime, + ty: expr_ty, + span: expr.span, + kind: cast, + }; + + ExprKind::ValueTypeAscription { + source: cast_expr.to_ref(), + user_ty: Some(user_ty), + } + } else { + cast + } + } + hir::ExprKind::Type(ref source, ref ty) => { + let user_provided_tys = cx.tables.user_provided_tys(); + let user_ty = user_provided_tys + .get(ty.hir_id) + .map(|&c_ty| UserTypeAnnotation::Ty(c_ty)); + if source.is_place_expr() { + ExprKind::PlaceTypeAscription { + source: source.to_ref(), + user_ty, + } + } else { + ExprKind::ValueTypeAscription { + source: source.to_ref(), + user_ty, + } } } - hir::ExprKind::Type(ref source, _) => return source.make_mirror(cx), hir::ExprKind::Box(ref value) => { ExprKind::Box { value: value.to_ref(), @@ -738,11 +791,11 @@ } } -fn user_annotated_ty_for_def( +fn user_substs_applied_to_def( cx: &mut Cx<'a, 'gcx, 'tcx>, hir_id: hir::HirId, def: &Def, -) -> Option> { +) -> Option> { match def { // A reference to something callable -- e.g., a fn, method, or // a tuple-struct or tuple-variant. This has the type of a @@ -750,16 +803,10 @@ Def::Fn(_) | Def::Method(_) | Def::StructCtor(_, CtorKind::Fn) | - Def::VariantCtor(_, CtorKind::Fn) => - Some(cx.tables().user_substs(hir_id)?.unchecked_map(|user_substs| { - // Here, we just pair a `DefId` with the - // `user_substs`, so no new types etc are introduced. - cx.tcx().mk_fn_def(def.def_id(), user_substs) - })), - - Def::Const(_def_id) | - Def::AssociatedConst(_def_id) => - bug!("unimplemented"), + Def::VariantCtor(_, CtorKind::Fn) | + Def::Const(_) | + Def::AssociatedConst(_) => + Some(UserTypeAnnotation::TypeOf(def.def_id(), cx.tables().user_substs(hir_id)?)), // A unit struct/variant which is used as a value (e.g., // `None`). This has the type of the enum/struct that defines @@ -767,51 +814,21 @@ // user. Def::StructCtor(_def_id, CtorKind::Const) | Def::VariantCtor(_def_id, CtorKind::Const) => - match &cx.tables().node_id_to_type(hir_id).sty { - ty::Adt(adt_def, _) => user_annotated_ty_for_adt(cx, hir_id, adt_def), - sty => bug!("unexpected sty: {:?}", sty), - }, + cx.user_substs_applied_to_ty_of_hir_id(hir_id), // `Self` is used in expression as a tuple struct constructor or an unit struct constructor - Def::SelfCtor(_) => { - let sty = &cx.tables().node_id_to_type(hir_id).sty; - match sty { - ty::FnDef(ref def_id, _) => { - Some(cx.tables().user_substs(hir_id)?.unchecked_map(|user_substs| { - // Here, we just pair a `DefId` with the - // `user_substs`, so no new types etc are introduced. - cx.tcx().mk_fn_def(*def_id, user_substs) - })) - } - ty::Adt(ref adt_def, _) => { - user_annotated_ty_for_adt(cx, hir_id, adt_def) - } - _ => { - bug!("unexpected sty: {:?}", sty) - } - } - } + Def::SelfCtor(_) => + cx.user_substs_applied_to_ty_of_hir_id(hir_id), + _ => - bug!("user_annotated_ty_for_def: unexpected def {:?} at {:?}", def, hir_id) + bug!("user_substs_applied_to_def: unexpected def {:?} at {:?}", def, hir_id) } } -fn user_annotated_ty_for_adt( - cx: &mut Cx<'a, 'gcx, 'tcx>, - hir_id: hir::HirId, - adt_def: &'tcx AdtDef, -) -> Option> { - let user_substs = cx.tables().user_substs(hir_id)?; - Some(user_substs.unchecked_map(|user_substs| { - // Here, we just pair an `AdtDef` with the - // `user_substs`, so no new types etc are introduced. - cx.tcx().mk_adt(adt_def, user_substs) - })) -} - fn method_callee<'a, 'gcx, 'tcx>( cx: &mut Cx<'a, 'gcx, 'tcx>, expr: &hir::Expr, + span: Span, overloaded_callee: Option<(DefId, &'tcx Substs<'tcx>)>, ) -> Expr<'tcx> { let temp_lifetime = cx.region_scope_tree.temporary_scope(expr.hir_id.local_id); @@ -824,7 +841,7 @@ .unwrap_or_else(|| { span_bug!(expr.span, "no type-dependent def for method callee") }); - let user_ty = user_annotated_ty_for_def(cx, expr.hir_id, def); + let user_ty = user_substs_applied_to_def(cx, expr.hir_id, def); (def.def_id(), cx.tables().node_substs(expr.hir_id), user_ty) } }; @@ -832,7 +849,7 @@ Expr { temp_lifetime, ty, - span: expr.span, + span, kind: ExprKind::Literal { literal: ty::Const::zero_sized(cx.tcx(), ty), user_ty, @@ -891,7 +908,7 @@ Def::StructCtor(_, CtorKind::Fn) | Def::VariantCtor(_, CtorKind::Fn) | Def::SelfCtor(..) => { - let user_ty = user_annotated_ty_for_def(cx, expr.hir_id, &def); + let user_ty = user_substs_applied_to_def(cx, expr.hir_id, &def); ExprKind::Literal { literal: ty::Const::zero_sized( cx.tcx, @@ -902,14 +919,17 @@ }, Def::Const(def_id) | - Def::AssociatedConst(def_id) => ExprKind::Literal { - literal: ty::Const::unevaluated( - cx.tcx, - def_id, - substs, - cx.tables().node_id_to_type(expr.hir_id), - ), - user_ty: None, // FIXME(#47184) -- user given type annot on constants + Def::AssociatedConst(def_id) => { + let user_ty = user_substs_applied_to_def(cx, expr.hir_id, &def); + ExprKind::Literal { + literal: ty::Const::unevaluated( + cx.tcx, + def_id, + substs, + cx.tables().node_id_to_type(expr.hir_id), + ), + user_ty, + } }, Def::StructCtor(def_id, CtorKind::Const) | @@ -922,7 +942,7 @@ adt_def, variant_index: adt_def.variant_index_with_id(def_id), substs, - user_ty: user_annotated_ty_for_adt(cx, expr.hir_id, adt_def), + user_ty: cx.user_substs_applied_to_adt(expr.hir_id, adt_def), fields: vec![], base: None, } @@ -1093,11 +1113,12 @@ expr: &'tcx hir::Expr, args: Vec>) -> ExprKind<'tcx> { - let fun = method_callee(cx, expr, None); + let fun = method_callee(cx, expr, expr.span, None); ExprKind::Call { ty: fun.ty, fun: fun.to_ref(), args, + from_hir_call: false, } } @@ -1132,7 +1153,7 @@ // construct the complete expression `foo()` for the overloaded call, // which will yield the &T type let temp_lifetime = cx.region_scope_tree.temporary_scope(expr.hir_id.local_id); - let fun = method_callee(cx, expr, overloaded_callee); + let fun = method_callee(cx, expr, expr.span, overloaded_callee); let ref_expr = Expr { temp_lifetime, ty: ref_ty, @@ -1141,6 +1162,7 @@ ty: fun.ty, fun: fun.to_ref(), args, + from_hir_call: false, }, }; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/hair/cx/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/hair/cx/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/hair/cx/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/hair/cx/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,6 +15,7 @@ //! use hair::*; +use hair::util::UserAnnotatedTyHelpers; use rustc_data_structures::indexed_vec::Idx; use rustc::hir::def_id::{DefId, LOCAL_CRATE}; @@ -272,6 +273,16 @@ } } +impl UserAnnotatedTyHelpers<'gcx, 'tcx> for Cx<'_, 'gcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'_, 'gcx, 'tcx> { + self.tcx() + } + + fn tables(&self) -> &ty::TypeckTables<'tcx> { + self.tables() + } +} + fn lint_level_for_hir_id(tcx: TyCtxt, mut id: ast::NodeId) -> ast::NodeId { // Right now we insert a `with_ignore` node in the dep graph here to // ignore the fact that `lint_levels` below depends on the entire crate. diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/hair/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/hair/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/hair/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/hair/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,11 +14,11 @@ //! unit-tested and separated from the Rust source and compiler data //! structures. -use rustc::mir::{BinOp, BorrowKind, Field, UnOp}; +use rustc::mir::{BinOp, BorrowKind, UserTypeAnnotation, Field, UnOp}; use rustc::hir::def_id::DefId; use rustc::middle::region; use rustc::ty::subst::Substs; -use rustc::ty::{AdtDef, CanonicalTy, UpvarSubsts, Region, Ty, Const}; +use rustc::ty::{AdtDef, UpvarSubsts, Region, Ty, Const}; use rustc::hir; use syntax::ast; use syntax_pos::Span; @@ -28,6 +28,9 @@ pub mod pattern; pub use self::pattern::{BindingMode, Pattern, PatternKind, FieldPattern}; +pub(crate) use self::pattern::{PatternTypeProjection, PatternTypeProjections}; + +mod util; #[derive(Copy, Clone, Debug)] pub enum LintLevel { @@ -150,6 +153,9 @@ ty: Ty<'tcx>, fun: ExprRef<'tcx>, args: Vec>, + // Whether this is from a call in HIR, rather than from an overloaded + // operator. True for overloaded function call. + from_hir_call: bool, }, Deref { arg: ExprRef<'tcx>, @@ -263,11 +269,21 @@ /// Optional user-given substs: for something like `let x = /// Bar:: { ... }`. - user_ty: Option>, + user_ty: Option>, fields: Vec>, base: Option> }, + PlaceTypeAscription { + source: ExprRef<'tcx>, + /// Type that the user gave to this expression + user_ty: Option>, + }, + ValueTypeAscription { + source: ExprRef<'tcx>, + /// Type that the user gave to this expression + user_ty: Option>, + }, Closure { closure_id: DefId, substs: UpvarSubsts<'tcx>, @@ -276,13 +292,7 @@ }, Literal { literal: &'tcx Const<'tcx>, - - /// Optional user-given type: for something like - /// `collect::>`, this would be present and would - /// indicate that `Vec<_>` was explicitly specified. - /// - /// Needed for NLL to impose user-given type constraints. - user_ty: Option>, + user_ty: Option>, }, InlineAsm { asm: &'tcx hir::InlineAsm, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/hair/pattern/check_match.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/hair/pattern/check_match.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/hair/pattern/check_match.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/hair/pattern/check_match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -35,7 +35,7 @@ use syntax::ast; use syntax::ptr::P; -use syntax_pos::{Span, DUMMY_SP}; +use syntax_pos::{Span, DUMMY_SP, MultiSpan}; struct OuterVisitor<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx> } @@ -298,7 +298,8 @@ let label_msg = match pat.node { PatKind::Path(hir::QPath::Resolved(None, ref path)) if path.segments.len() == 1 && path.segments[0].args.is_none() => { - format!("interpreted as a {} pattern, not new variable", path.def.kind_name()) + format!("interpreted as {} {} pattern, not new variable", + path.def.article(), path.def.kind_name()) } _ => format!("pattern `{}` not covered", pattern_string), }; @@ -527,8 +528,8 @@ } }) } - - let check_move = |p: &Pat, sub: Option<&Pat>| { + let span_vec = &mut Vec::new(); + let check_move = |p: &Pat, sub: Option<&Pat>, span_vec: &mut Vec| { // check legality of moving out of the enum // x @ Foo(..) is legal, but x @ Foo(y) isn't. @@ -537,21 +538,17 @@ "cannot bind by-move with sub-bindings") .span_label(p.span, "binds an already bound by-move value by moving it") .emit(); - } else if has_guard { - struct_span_err!(cx.tcx.sess, p.span, E0008, - "cannot bind by-move into a pattern guard") - .span_label(p.span, "moves value into pattern guard") - .emit(); - } else if let Some(by_ref_span) = by_ref_span { - struct_span_err!( - cx.tcx.sess, - p.span, - E0009, - "cannot bind by-move and by-ref in the same pattern", - ) - .span_label(p.span, "by-move pattern here") - .span_label(by_ref_span, "both by-ref and by-move used") - .emit(); + } else if has_guard && !cx.tcx.allow_bind_by_move_patterns_with_guards() { + let mut err = struct_span_err!(cx.tcx.sess, p.span, E0008, + "cannot bind by-move into a pattern guard"); + err.span_label(p.span, "moves value into pattern guard"); + if cx.tcx.sess.opts.unstable_features.is_nightly_build() && cx.tcx.use_mir_borrowck() { + err.help("add #![feature(bind_by_move_pattern_guards)] to the \ + crate attributes to enable"); + } + err.emit(); + } else if let Some(_by_ref_span) = by_ref_span { + span_vec.push(p.span); } }; @@ -563,7 +560,7 @@ ty::BindByValue(..) => { let pat_ty = cx.tables.node_id_to_type(p.hir_id); if pat_ty.moves_by_default(cx.tcx, cx.param_env, pat.span) { - check_move(p, sub.as_ref().map(|p| &**p)); + check_move(p, sub.as_ref().map(|p| &**p), span_vec); } } _ => {} @@ -575,6 +572,20 @@ true }); } + if !span_vec.is_empty(){ + let span = MultiSpan::from_spans(span_vec.clone()); + let mut err = struct_span_err!( + cx.tcx.sess, + span, + E0009, + "cannot bind by-move and by-ref in the same pattern", + ); + err.span_label(by_ref_span.unwrap(), "both by-ref and by-move used"); + for span in span_vec.iter(){ + err.span_label(*span, "by-move pattern here"); + } + err.emit(); + } } /// Ensures that a pattern guard doesn't borrow by mutable reference or @@ -613,10 +624,16 @@ _: LoanCause) { match kind { ty::MutBorrow => { - struct_span_err!(self.cx.tcx.sess, span, E0301, - "cannot mutably borrow in a pattern guard") - .span_label(span, "borrowed mutably in pattern guard") - .emit(); + let mut err = struct_span_err!(self.cx.tcx.sess, span, E0301, + "cannot mutably borrow in a pattern guard"); + err.span_label(span, "borrowed mutably in pattern guard"); + if self.cx.tcx.sess.opts.unstable_features.is_nightly_build() && + self.cx.tcx.use_mir_borrowck() + { + err.help("add #![feature(bind_by_move_pattern_guards)] to the \ + crate attributes to enable"); + } + err.emit(); } ty::ImmBorrow | ty::UniqueImmBorrow => {} } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/hair/pattern/_match.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/hair/pattern/_match.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/hair/pattern/_match.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/hair/pattern/_match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -320,7 +320,7 @@ f: F) -> R where F: for<'b> FnOnce(MatchCheckCtxt<'b, 'tcx>) -> R { - let pattern_arena = TypedArena::new(); + let pattern_arena = TypedArena::default(); f(MatchCheckCtxt { tcx, @@ -1048,7 +1048,7 @@ if let Some(constructors) = pat_constructors(cx, v[0], pcx) { debug!("is_useful - expanding constructors: {:#?}", constructors); split_grouped_constructors(cx.tcx, constructors, matrix, pcx.ty).into_iter().map(|c| - is_useful_specialized(cx, matrix, v, c.clone(), pcx.ty, witness) + is_useful_specialized(cx, matrix, v, c, pcx.ty, witness) ).find(|result| result.is_useful()).unwrap_or(NotUseful) } else { debug!("is_useful - expanding wildcard"); @@ -1096,7 +1096,7 @@ if missing_ctors.is_empty() && !is_non_exhaustive { split_grouped_constructors(cx.tcx, all_ctors, matrix, pcx.ty).into_iter().map(|c| { - is_useful_specialized(cx, matrix, v, c.clone(), pcx.ty, witness) + is_useful_specialized(cx, matrix, v, c, pcx.ty, witness) }).find(|result| result.is_useful()).unwrap_or(NotUseful) } else { let matrix = rows.iter().filter_map(|r| { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/hair/pattern/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/hair/pattern/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/hair/pattern/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/hair/pattern/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,11 +16,14 @@ pub use self::check_match::check_crate; pub(crate) use self::check_match::check_match; -use interpret::{const_field, const_variant_index}; +use const_eval::{const_field, const_variant_index}; + +use hair::util::UserAnnotatedTyHelpers; use rustc::mir::{fmt_const_val, Field, BorrowKind, Mutability}; +use rustc::mir::{ProjectionElem, UserTypeAnnotation, UserTypeProjection, UserTypeProjections}; use rustc::mir::interpret::{Scalar, GlobalId, ConstValue, sign_extend}; -use rustc::ty::{self, CanonicalTy, TyCtxt, AdtDef, Ty, Region}; +use rustc::ty::{self, Region, TyCtxt, AdtDef, Ty}; use rustc::ty::subst::{Substs, Kind}; use rustc::hir::{self, PatKind, RangeEnd}; use rustc::hir::def::{Def, CtorKind}; @@ -62,13 +65,125 @@ pub kind: Box>, } + +#[derive(Clone, Debug)] +pub(crate) struct PatternTypeProjections<'tcx> { + contents: Vec<(PatternTypeProjection<'tcx>, Span)>, +} + +impl<'tcx> PatternTypeProjections<'tcx> { + pub(crate) fn user_ty(self) -> UserTypeProjections<'tcx> { + UserTypeProjections::from_projections( + self.contents.into_iter().map(|(pat_ty_proj, span)| (pat_ty_proj.user_ty(), span))) + } + + pub(crate) fn none() -> Self { + PatternTypeProjections { contents: vec![] } + } + + pub(crate) fn ref_binding(&self) -> Self { + // FIXME(#47184): ignore for now + PatternTypeProjections { contents: vec![] } + } + + fn map_projs(&self, + mut f: impl FnMut(&PatternTypeProjection<'tcx>) -> PatternTypeProjection<'tcx>) + -> Self + { + PatternTypeProjections { + contents: self.contents + .iter() + .map(|(proj, span)| (f(proj), *span)) + .collect(), } + } + + pub(crate) fn index(&self) -> Self { self.map_projs(|pat_ty_proj| pat_ty_proj.index()) } + + pub(crate) fn subslice(&self, from: u32, to: u32) -> Self { + self.map_projs(|pat_ty_proj| pat_ty_proj.subslice(from, to)) + } + + pub(crate) fn deref(&self) -> Self { self.map_projs(|pat_ty_proj| pat_ty_proj.deref()) } + + pub(crate) fn leaf(&self, field: Field) -> Self { + self.map_projs(|pat_ty_proj| pat_ty_proj.leaf(field)) + } + + pub(crate) fn variant(&self, + adt_def: &'tcx AdtDef, + variant_index: usize, + field: Field) -> Self { + self.map_projs(|pat_ty_proj| pat_ty_proj.variant(adt_def, variant_index, field)) + } + + pub(crate) fn add_user_type(&self, user_ty: &PatternTypeProjection<'tcx>, sp: Span) -> Self { + let mut new = self.clone(); + new.contents.push((user_ty.clone(), sp)); + new + } +} + +#[derive(Clone, Debug)] +pub struct PatternTypeProjection<'tcx>(UserTypeProjection<'tcx>); + +impl<'tcx> PatternTypeProjection<'tcx> { + pub(crate) fn index(&self) -> Self { + let mut new = self.clone(); + new.0.projs.push(ProjectionElem::Index(())); + new + } + + pub(crate) fn subslice(&self, from: u32, to: u32) -> Self { + let mut new = self.clone(); + new.0.projs.push(ProjectionElem::Subslice { from, to }); + new + } + + pub(crate) fn deref(&self) -> Self { + let mut new = self.clone(); + new.0.projs.push(ProjectionElem::Deref); + new + } + + pub(crate) fn leaf(&self, field: Field) -> Self { + let mut new = self.clone(); + new.0.projs.push(ProjectionElem::Field(field, ())); + new + } + + pub(crate) fn variant(&self, + adt_def: &'tcx AdtDef, + variant_index: usize, + field: Field) -> Self { + let mut new = self.clone(); + new.0.projs.push(ProjectionElem::Downcast(adt_def, variant_index)); + new.0.projs.push(ProjectionElem::Field(field, ())); + new + } + + pub(crate) fn from_canonical_ty(c_ty: ty::CanonicalTy<'tcx>) -> Self { + Self::from_user_type(UserTypeAnnotation::Ty(c_ty)) + } + + pub(crate) fn from_user_type(u_ty: UserTypeAnnotation<'tcx>) -> Self { + Self::from_user_type_proj(UserTypeProjection { base: u_ty, projs: vec![], }) + } + + pub(crate) fn from_user_type_proj(u_ty: UserTypeProjection<'tcx>) -> Self { + PatternTypeProjection(u_ty) + } + + pub(crate) fn user_ty(self) -> UserTypeProjection<'tcx> { self.0 } +} + #[derive(Clone, Debug)] pub enum PatternKind<'tcx> { Wild, AscribeUserType { - user_ty: CanonicalTy<'tcx>, + user_ty: PatternTypeProjection<'tcx>, subpattern: Pattern<'tcx>, + user_ty_span: Span, }, /// x, ref x, x @ P, etc @@ -529,8 +644,9 @@ field: Field::new(i), pattern: self.lower_pattern(field), }) - .collect(); - self.lower_variant_or_leaf(def, pat.span, ty, subpatterns) + .collect(); + + self.lower_variant_or_leaf(def, pat.hir_id, pat.span, ty, subpatterns) } PatKind::Struct(ref qpath, ref fields, _) => { @@ -546,7 +662,7 @@ }) .collect(); - self.lower_variant_or_leaf(def, pat.span, ty, subpatterns) + self.lower_variant_or_leaf(def, pat.hir_id, pat.span, ty, subpatterns) } }; @@ -637,12 +753,12 @@ fn lower_variant_or_leaf( &mut self, def: Def, + hir_id: hir::HirId, span: Span, ty: Ty<'tcx>, - subpatterns: Vec>) - -> PatternKind<'tcx> - { - match def { + subpatterns: Vec>, + ) -> PatternKind<'tcx> { + let mut kind = match def { Def::Variant(variant_id) | Def::VariantCtor(variant_id, ..) => { let enum_id = self.tcx.parent_def_id(variant_id).unwrap(); let adt_def = self.tcx.adt_def(enum_id); @@ -675,7 +791,26 @@ self.errors.push(PatternError::NonConstPath(span)); PatternKind::Wild } + }; + + if let Some(user_ty) = self.user_substs_applied_to_ty_of_hir_id(hir_id) { + let subpattern = Pattern { + span, + ty, + kind: Box::new(kind), + }; + + debug!("pattern user_ty = {:?} for pattern at {:?}", user_ty, span); + + let pat_ty = PatternTypeProjection::from_user_type(user_ty); + kind = PatternKind::AscribeUserType { + subpattern, + user_ty: pat_ty, + user_ty_span: span, + }; } + + kind } /// Takes a HIR Path. If the path is a constant, evaluates it and feeds @@ -729,7 +864,7 @@ }, } } - _ => self.lower_variant_or_leaf(def, span, ty, vec![]), + _ => self.lower_variant_or_leaf(def, id, span, ty, vec![]), }; Pattern { @@ -894,6 +1029,17 @@ } } +impl UserAnnotatedTyHelpers<'tcx, 'tcx> for PatternContext<'_, 'tcx> { + fn tcx(&self) -> TyCtxt<'_, 'tcx, 'tcx> { + self.tcx + } + + fn tables(&self) -> &ty::TypeckTables<'tcx> { + self.tables + } +} + + pub trait PatternFoldable<'tcx> : Sized { fn fold_with>(&self, folder: &mut F) -> Self { self.super_fold_with(folder) @@ -947,7 +1093,8 @@ CloneImpls!{ <'tcx> Span, Field, Mutability, ast::Name, ast::NodeId, usize, &'tcx ty::Const<'tcx>, Region<'tcx>, Ty<'tcx>, BindingMode<'tcx>, &'tcx AdtDef, - &'tcx Substs<'tcx>, &'tcx Kind<'tcx>, CanonicalTy<'tcx> + &'tcx Substs<'tcx>, &'tcx Kind<'tcx>, UserTypeAnnotation<'tcx>, + UserTypeProjection<'tcx>, PatternTypeProjection<'tcx> } impl<'tcx> PatternFoldable<'tcx> for FieldPattern<'tcx> { @@ -983,10 +1130,12 @@ PatternKind::Wild => PatternKind::Wild, PatternKind::AscribeUserType { ref subpattern, - user_ty, + ref user_ty, + user_ty_span, } => PatternKind::AscribeUserType { subpattern: subpattern.fold_with(folder), user_ty: user_ty.fold_with(folder), + user_ty_span, }, PatternKind::Binding { mutability, @@ -1124,13 +1273,6 @@ len_b, ), ) if ptr_a.offset.bytes() == 0 && ptr_b.offset.bytes() == 0 => { - let len_a = len_a.not_undef().ok(); - let len_b = len_b.not_undef().ok(); - if len_a.is_none() || len_b.is_none() { - tcx.sess.struct_err("str slice len is undef").delay_as_bug(); - } - let len_a = len_a?; - let len_b = len_b?; if let Ok(len_a) = len_a.to_bits(tcx.data_layout.pointer_size) { if let Ok(len_b) = len_b.to_bits(tcx.data_layout.pointer_size) { if len_a == len_b { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/hair/util.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/hair/util.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/hair/util.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/hair/util.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use rustc::hir; +use rustc::mir::UserTypeAnnotation; +use rustc::ty::{self, AdtDef, TyCtxt}; + +crate trait UserAnnotatedTyHelpers<'gcx: 'tcx, 'tcx> { + fn tcx(&self) -> TyCtxt<'_, 'gcx, 'tcx>; + + fn tables(&self) -> &ty::TypeckTables<'tcx>; + + fn user_substs_applied_to_adt( + &self, + hir_id: hir::HirId, + adt_def: &'tcx AdtDef, + ) -> Option> { + let user_substs = self.tables().user_substs(hir_id)?; + Some(UserTypeAnnotation::TypeOf(adt_def.did, user_substs)) + } + + /// Looks up the type associated with this hir-id and applies the + /// user-given substitutions; the hir-id must map to a suitable + /// type. + fn user_substs_applied_to_ty_of_hir_id( + &self, + hir_id: hir::HirId, + ) -> Option> { + let user_substs = self.tables().user_substs(hir_id)?; + match &self.tables().node_id_to_type(hir_id).sty { + ty::Adt(adt_def, _) => Some(UserTypeAnnotation::TypeOf(adt_def.did, user_substs)), + ty::FnDef(def_id, _) => Some(UserTypeAnnotation::TypeOf(*def_id, user_substs)), + sty => bug!( + "sty: {:?} should not have user-substs {:?} recorded ", + sty, + user_substs + ), + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/cast.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/cast.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/cast.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/cast.rs 2018-12-04 23:41:40.000000000 +0000 @@ -21,7 +21,7 @@ use super::{EvalContext, Machine, PlaceTy, OpTy, Value}; -impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { +impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { fn type_is_fat_ptr(&self, ty: Ty<'tcx>) -> bool { match ty.sty { ty::RawPtr(ty::TypeAndMut { ty, .. }) | @@ -33,12 +33,10 @@ pub fn cast( &mut self, - src: OpTy<'tcx>, + src: OpTy<'tcx, M::PointerTag>, kind: CastKind, - dest: PlaceTy<'tcx>, + dest: PlaceTy<'tcx, M::PointerTag>, ) -> EvalResult<'tcx> { - let src_layout = src.layout; - let dst_layout = dest.layout; use rustc::mir::CastKind::*; match kind { Unsize => { @@ -46,15 +44,28 @@ } Misc => { + let src_layout = src.layout; let src = self.read_value(src)?; + + let src = if M::ENABLE_PTR_TRACKING_HOOKS && src_layout.ty.is_region_ptr() { + // The only `Misc` casts on references are those creating raw pointers. + assert!(dest.layout.ty.is_unsafe_ptr()); + // For the purpose of the "ptr tag hooks", treat this as creating + // a new, raw reference. + let place = self.ref_to_mplace(src)?; + self.create_ref(place, None)? + } else { + *src + }; + if self.type_is_fat_ptr(src_layout.ty) { - match (*src, self.type_is_fat_ptr(dest.layout.ty)) { + match (src, self.type_is_fat_ptr(dest.layout.ty)) { // pointers to extern types (Value::Scalar(_),_) | // slices and trait objects to other slices/trait objects (Value::ScalarPair(..), true) => { // No change to value - self.write_value(*src, dest)?; + self.write_value(src, dest)?; } // slices and trait objects to thin pointers (dropping the metadata) (Value::ScalarPair(data, _), false) => { @@ -65,11 +76,13 @@ match src_layout.variants { layout::Variants::Single { index } => { if let Some(def) = src_layout.ty.ty_adt_def() { + // Cast from a univariant enum + assert!(src_layout.is_zst()); let discr_val = def .discriminant_for_variant(*self.tcx, index) .val; return self.write_scalar( - Scalar::from_uint(discr_val, dst_layout.size), + Scalar::from_uint(discr_val, dest.layout.size), dest); } } @@ -85,7 +98,7 @@ ReifyFnPointer => { // The src operand does not matter, just its type - match src_layout.ty.sty { + match src.layout.ty.sty { ty::FnDef(def_id, substs) => { if self.tcx.has_attr(def_id, "rustc_args_required_const") { bug!("reifying a fn ptr that requires \ @@ -117,7 +130,7 @@ ClosureFnPointer => { // The src operand does not matter, just its type - match src_layout.ty.sty { + match src.layout.ty.sty { ty::Closure(def_id, substs) => { let substs = self.tcx.subst_and_normalize_erasing_regions( self.substs(), @@ -143,10 +156,10 @@ pub(super) fn cast_scalar( &self, - val: Scalar, + val: Scalar, src_layout: TyLayout<'tcx>, dest_layout: TyLayout<'tcx>, - ) -> EvalResult<'tcx, Scalar> { + ) -> EvalResult<'tcx, Scalar> { use rustc::ty::TyKind::*; trace!("Casting {:?}: {:?} to {:?}", val, src_layout.ty, dest_layout.ty); @@ -182,7 +195,7 @@ v: u128, src_layout: TyLayout<'tcx>, dest_layout: TyLayout<'tcx>, - ) -> EvalResult<'tcx, Scalar> { + ) -> EvalResult<'tcx, Scalar> { let signed = src_layout.abi.is_signed(); let v = if signed { self.sign_extend(v, src_layout) @@ -239,13 +252,13 @@ bits: u128, fty: FloatTy, dest_ty: Ty<'tcx> - ) -> EvalResult<'tcx, Scalar> { + ) -> EvalResult<'tcx, Scalar> { use rustc::ty::TyKind::*; use rustc_apfloat::FloatConvert; match dest_ty.sty { // float -> uint Uint(t) => { - let width = t.bit_width().unwrap_or(self.pointer_size().bits() as usize); + let width = t.bit_width().unwrap_or_else(|| self.pointer_size().bits() as usize); let v = match fty { FloatTy::F32 => Single::from_bits(bits).to_u128(width).value, FloatTy::F64 => Double::from_bits(bits).to_u128(width).value, @@ -255,7 +268,7 @@ }, // float -> int Int(t) => { - let width = t.bit_width().unwrap_or(self.pointer_size().bits() as usize); + let width = t.bit_width().unwrap_or_else(|| self.pointer_size().bits() as usize); let v = match fty { FloatTy::F32 => Single::from_bits(bits).to_i128(width).value, FloatTy::F64 => Double::from_bits(bits).to_i128(width).value, @@ -283,7 +296,11 @@ } } - fn cast_from_ptr(&self, ptr: Pointer, ty: Ty<'tcx>) -> EvalResult<'tcx, Scalar> { + fn cast_from_ptr( + &self, + ptr: Pointer, + ty: Ty<'tcx> + ) -> EvalResult<'tcx, Scalar> { use rustc::ty::TyKind::*; match ty.sty { // Casting to a reference or fn pointer is not permitted by rustc, @@ -298,8 +315,8 @@ fn unsize_into_ptr( &mut self, - src: OpTy<'tcx>, - dest: PlaceTy<'tcx>, + src: OpTy<'tcx, M::PointerTag>, + dest: PlaceTy<'tcx, M::PointerTag>, // The pointee types sty: Ty<'tcx>, dty: Ty<'tcx>, @@ -318,16 +335,12 @@ // For now, upcasts are limited to changes in marker // traits, and hence never actually require an actual // change to the vtable. - self.copy_op(src, dest) + let val = self.read_value(src)?; + self.write_value(*val, dest) } (_, &ty::Dynamic(ref data, _)) => { // Initial cast from sized to dyn trait - let trait_ref = data.principal().unwrap().with_self_ty( - *self.tcx, - src_pointee_ty, - ); - let trait_ref = self.tcx.erase_regions(&trait_ref); - let vtable = self.get_vtable(src_pointee_ty, trait_ref)?; + let vtable = self.get_vtable(src_pointee_ty, data.principal())?; let ptr = self.read_value(src)?.to_scalar_ptr()?; let val = Value::new_dyn_trait(ptr, vtable); self.write_value(val, dest) @@ -339,8 +352,8 @@ fn unsize_into( &mut self, - src: OpTy<'tcx>, - dest: PlaceTy<'tcx>, + src: OpTy<'tcx, M::PointerTag>, + dest: PlaceTy<'tcx, M::PointerTag>, ) -> EvalResult<'tcx> { match (&src.layout.ty.sty, &dest.layout.ty.sty) { (&ty::Ref(_, s, _), &ty::Ref(_, d, _)) | diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/eval_context.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/eval_context.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/eval_context.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/eval_context.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,10 +11,10 @@ use std::fmt::Write; use std::mem; +use syntax::source_map::{self, Span, DUMMY_SP}; use rustc::hir::def_id::DefId; use rustc::hir::def::Def; use rustc::hir::map::definitions::DefPathData; -use rustc::ich::StableHashingContext; use rustc::mir; use rustc::ty::layout::{ self, Size, Align, HasDataLayout, LayoutOf, TyLayout @@ -23,24 +23,19 @@ use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; use rustc::ty::query::TyCtxtAt; use rustc_data_structures::indexed_vec::IndexVec; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult}; use rustc::mir::interpret::{ GlobalId, Scalar, FrameInfo, AllocId, EvalResult, EvalErrorKind, - ScalarMaybeUndef, truncate, sign_extend, }; - -use syntax::source_map::{self, Span}; +use rustc_data_structures::fx::FxHashMap; use super::{ - Value, Operand, MemPlace, MPlaceTy, Place, + Value, Operand, MemPlace, MPlaceTy, Place, PlaceTy, ScalarMaybeUndef, Memory, Machine }; -use super::snapshot::InfiniteLoopDetector; - -pub struct EvalContext<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'mir, 'tcx>> { +pub struct EvalContext<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'a, 'mir, 'tcx>> { /// Stores the `Machine` instance. pub machine: M, @@ -48,31 +43,21 @@ pub tcx: TyCtxtAt<'a, 'tcx, 'tcx>, /// Bounds in scope for polymorphic evaluations. - pub param_env: ty::ParamEnv<'tcx>, + pub(crate) param_env: ty::ParamEnv<'tcx>, /// The virtual memory system. pub memory: Memory<'a, 'mir, 'tcx, M>, /// The virtual call stack. - pub(crate) stack: Vec>, + pub(crate) stack: Vec>, - /// The maximum number of stack frames allowed - pub(super) stack_limit: usize, - - /// When this value is negative, it indicates the number of interpreter - /// steps *until* the loop detector is enabled. When it is positive, it is - /// the number of steps after the detector has been enabled modulo the loop - /// detector period. - pub(super) steps_since_detector_enabled: isize, - - /// Extra state to detect loops. - /// FIXME: Move this to the CTFE machine's state, out of the general miri engine. - pub(super) loop_detector: InfiniteLoopDetector<'a, 'mir, 'tcx, M>, + /// A cache for deduplicating vtables + pub(super) vtables: FxHashMap<(Ty<'tcx>, ty::PolyExistentialTraitRef<'tcx>), AllocId>, } /// A stack frame. #[derive(Clone)] -pub struct Frame<'mir, 'tcx: 'mir> { +pub struct Frame<'mir, 'tcx: 'mir, Tag=()> { //////////////////////////////////////////////////////////////////////////////// // Function and callsite information //////////////////////////////////////////////////////////////////////////////// @@ -91,15 +76,16 @@ /// Work to perform when returning from this function pub return_to_block: StackPopCleanup, - /// The location where the result of the current stack frame should be written to. - pub return_place: Place, + /// The location where the result of the current stack frame should be written to, + /// and its layout in the caller. + pub return_place: Option>, /// The list of locals for this stack frame, stored in order as /// `[return_ptr, arguments..., variables..., temporaries...]`. /// The locals are stored as `Option`s. /// `None` represents a local that is currently dead, while a live local /// can either directly contain `Scalar` or refer to some part of an `Allocation`. - pub locals: IndexVec>, + pub locals: IndexVec>, //////////////////////////////////////////////////////////////////////////////// // Current position within the function @@ -112,33 +98,11 @@ pub stmt: usize, } -// Not using the macro because that does not support types depending on 'tcx -impl<'a, 'mir, 'tcx: 'mir> HashStable> for Frame<'mir, 'tcx> { - fn hash_stable( - &self, - hcx: &mut StableHashingContext<'a>, - hasher: &mut StableHasher) { - - let Frame { - mir, - instance, - span, - return_to_block, - return_place, - locals, - block, - stmt, - } = self; - - (mir, instance, span, return_to_block).hash_stable(hcx, hasher); - (return_place, locals, block, stmt).hash_stable(hcx, hasher); - } -} - #[derive(Clone, Debug, Eq, PartialEq, Hash)] pub enum StackPopCleanup { /// Jump to the next block in the caller, or cause UB if None (that's a function - /// that may never return). + /// that may never return). Also store layout of return place so + /// we can validate it at that layout. Goto(Option), /// Just do nohing: Used by Main and for the box_alloc hook in miri. /// `cleanup` says whether locals are deallocated. Static computation @@ -147,41 +111,26 @@ None { cleanup: bool }, } -// Can't use the macro here because that does not support named enum fields. -impl<'a> HashStable> for StackPopCleanup { - fn hash_stable( - &self, - hcx: &mut StableHashingContext<'a>, - hasher: &mut StableHasher) - { - mem::discriminant(self).hash_stable(hcx, hasher); - match self { - StackPopCleanup::Goto(ref block) => block.hash_stable(hcx, hasher), - StackPopCleanup::None { cleanup } => cleanup.hash_stable(hcx, hasher), - } - } -} - // State of a local variable #[derive(Copy, Clone, PartialEq, Eq, Hash)] -pub enum LocalValue { +pub enum LocalValue { Dead, // Mostly for convenience, we re-use the `Operand` type here. // This is an optimization over just always having a pointer here; // we can thus avoid doing an allocation when the local just stores // immediate values *and* never has its address taken. - Live(Operand), + Live(Operand), } -impl<'tcx> LocalValue { - pub fn access(&self) -> EvalResult<'tcx, &Operand> { +impl<'tcx, Tag> LocalValue { + pub fn access(&self) -> EvalResult<'tcx, &Operand> { match self { LocalValue::Dead => err!(DeadLocal), LocalValue::Live(ref val) => Ok(val), } } - pub fn access_mut(&mut self) -> EvalResult<'tcx, &mut Operand> { + pub fn access_mut(&mut self) -> EvalResult<'tcx, &mut Operand> { match self { LocalValue::Dead => err!(DeadLocal), LocalValue::Live(ref mut val) => Ok(val), @@ -189,19 +138,16 @@ } } -impl_stable_hash_for!(enum self::LocalValue { - Dead, - Live(x), -}); - -impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> HasDataLayout for &'a EvalContext<'a, 'mir, 'tcx, M> { +impl<'b, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> HasDataLayout + for &'b EvalContext<'a, 'mir, 'tcx, M> +{ #[inline] fn data_layout(&self) -> &layout::TargetDataLayout { &self.tcx.data_layout } } -impl<'c, 'b, 'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> HasDataLayout +impl<'c, 'b, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> HasDataLayout for &'c &'b mut EvalContext<'a, 'mir, 'tcx, M> { #[inline] @@ -210,24 +156,27 @@ } } -impl<'a, 'mir, 'tcx, M> layout::HasTyCtxt<'tcx> for &'a EvalContext<'a, 'mir, 'tcx, M> - where M: Machine<'mir, 'tcx> +impl<'b, 'a, 'mir, 'tcx, M> layout::HasTyCtxt<'tcx> for &'b EvalContext<'a, 'mir, 'tcx, M> + where M: Machine<'a, 'mir, 'tcx> { #[inline] - fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx, 'tcx> { + fn tcx<'d>(&'d self) -> TyCtxt<'d, 'tcx, 'tcx> { *self.tcx } } -impl<'c, 'b, 'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> layout::HasTyCtxt<'tcx> - for &'c &'b mut EvalContext<'a, 'mir, 'tcx, M> { +impl<'c, 'b, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> layout::HasTyCtxt<'tcx> + for &'c &'b mut EvalContext<'a, 'mir, 'tcx, M> +{ #[inline] fn tcx<'d>(&'d self) -> TyCtxt<'d, 'tcx, 'tcx> { *self.tcx } } -impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> LayoutOf for &'a EvalContext<'a, 'mir, 'tcx, M> { +impl<'b, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> LayoutOf + for &'b EvalContext<'a, 'mir, 'tcx, M> +{ type Ty = Ty<'tcx>; type TyLayout = EvalResult<'tcx, TyLayout<'tcx>>; @@ -238,8 +187,9 @@ } } -impl<'c, 'b, 'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> LayoutOf - for &'c &'b mut EvalContext<'a, 'mir, 'tcx, M> { +impl<'c, 'b, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> LayoutOf + for &'c &'b mut EvalContext<'a, 'mir, 'tcx, M> +{ type Ty = Ty<'tcx>; type TyLayout = EvalResult<'tcx, TyLayout<'tcx>>; @@ -249,77 +199,64 @@ } } -const STEPS_UNTIL_DETECTOR_ENABLED: isize = 1_000_000; - -impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { +impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { pub fn new( tcx: TyCtxtAt<'a, 'tcx, 'tcx>, param_env: ty::ParamEnv<'tcx>, machine: M, - memory_data: M::MemoryData, ) -> Self { EvalContext { machine, tcx, param_env, - memory: Memory::new(tcx, memory_data), + memory: Memory::new(tcx), stack: Vec::new(), - stack_limit: tcx.sess.const_eval_stack_frame_limit, - loop_detector: Default::default(), - steps_since_detector_enabled: -STEPS_UNTIL_DETECTOR_ENABLED, + vtables: FxHashMap::default(), } } - pub(crate) fn with_fresh_body R, R>(&mut self, f: F) -> R { - let stack = mem::replace(&mut self.stack, Vec::new()); - let steps = mem::replace(&mut self.steps_since_detector_enabled, - -STEPS_UNTIL_DETECTOR_ENABLED); - let r = f(self); - self.stack = stack; - self.steps_since_detector_enabled = steps; - r - } - + #[inline(always)] pub fn memory(&self) -> &Memory<'a, 'mir, 'tcx, M> { &self.memory } + #[inline(always)] pub fn memory_mut(&mut self) -> &mut Memory<'a, 'mir, 'tcx, M> { &mut self.memory } - pub fn stack(&self) -> &[Frame<'mir, 'tcx>] { + #[inline(always)] + pub fn stack(&self) -> &[Frame<'mir, 'tcx, M::PointerTag>] { &self.stack } - #[inline] + #[inline(always)] pub fn cur_frame(&self) -> usize { assert!(self.stack.len() > 0); self.stack.len() - 1 } - /// Mark a storage as live, killing the previous content and returning it. - /// Remember to deallocate that! - pub fn storage_live(&mut self, local: mir::Local) -> EvalResult<'tcx, LocalValue> { - trace!("{:?} is now live", local); - - let layout = self.layout_of_local(self.cur_frame(), local)?; - let init = LocalValue::Live(self.uninit_operand(layout)?); - // StorageLive *always* kills the value that's currently stored - Ok(mem::replace(&mut self.frame_mut().locals[local], init)) + #[inline(always)] + pub fn frame(&self) -> &Frame<'mir, 'tcx, M::PointerTag> { + self.stack.last().expect("no call frames exist") } - /// Returns the old value of the local. - /// Remember to deallocate that! - pub fn storage_dead(&mut self, local: mir::Local) -> LocalValue { - trace!("{:?} is now dead", local); + #[inline(always)] + pub fn frame_mut(&mut self) -> &mut Frame<'mir, 'tcx, M::PointerTag> { + self.stack.last_mut().expect("no call frames exist") + } - mem::replace(&mut self.frame_mut().locals[local], LocalValue::Dead) + #[inline(always)] + pub(super) fn mir(&self) -> &'mir mir::Mir<'tcx> { + self.frame().mir } - pub fn str_to_value(&mut self, s: &str) -> EvalResult<'tcx, Value> { - let ptr = self.memory.allocate_static_bytes(s.as_bytes()); - Ok(Value::new_slice(Scalar::Ptr(ptr), s.len() as u64, self.tcx.tcx)) + pub fn substs(&self) -> &'tcx Substs<'tcx> { + if let Some(frame) = self.stack.last() { + frame.instance.substs + } else { + Substs::empty() + } } pub(super) fn resolve( @@ -343,10 +280,14 @@ ).ok_or_else(|| EvalErrorKind::TooGeneric.into()) } - pub(super) fn type_is_sized(&self, ty: Ty<'tcx>) -> bool { + pub fn type_is_sized(&self, ty: Ty<'tcx>) -> bool { ty.is_sized(self.tcx, self.param_env) } + pub fn type_is_freeze(&self, ty: Ty<'tcx>) -> bool { + ty.is_freeze(*self.tcx, self.param_env, DUMMY_SP) + } + pub fn load_mir( &self, instance: ty::InstanceDef<'tcx>, @@ -383,34 +324,30 @@ pub fn layout_of_local( &self, - frame: usize, + frame: &Frame<'mir, 'tcx, M::PointerTag>, local: mir::Local ) -> EvalResult<'tcx, TyLayout<'tcx>> { - let local_ty = self.stack[frame].mir.local_decls[local].ty; - let local_ty = self.monomorphize( - local_ty, - self.stack[frame].instance.substs - ); + let local_ty = frame.mir.local_decls[local].ty; + let local_ty = self.monomorphize(local_ty, frame.instance.substs); self.layout_of(local_ty) } + pub fn str_to_value(&mut self, s: &str) -> EvalResult<'tcx, Value> { + let ptr = self.memory.allocate_static_bytes(s.as_bytes()); + Ok(Value::new_slice(Scalar::Ptr(ptr), s.len() as u64, self.tcx.tcx)) + } + /// Return the actual dynamic size and alignment of the place at the given type. - /// Only the "extra" (metadata) part of the place matters. + /// Only the "meta" (metadata) part of the place matters. + /// This can fail to provide an answer for extern types. pub(super) fn size_and_align_of( &self, - metadata: Option, + metadata: Option>, layout: TyLayout<'tcx>, - ) -> EvalResult<'tcx, (Size, Align)> { - let metadata = match metadata { - None => { - assert!(!layout.is_unsized()); - return Ok(layout.size_and_align()) - } - Some(metadata) => { - assert!(layout.is_unsized()); - metadata - } - }; + ) -> EvalResult<'tcx, Option<(Size, Align)>> { + if !layout.is_unsized() { + return Ok(Some(layout.size_and_align())); + } match layout.ty.sty { ty::Adt(..) | ty::Tuple(..) => { // First get the size of all statically known fields. @@ -418,11 +355,11 @@ // and it also rounds up to alignment, which we want to avoid, // as the unsized field's alignment could be smaller. assert!(!layout.ty.is_simd()); - debug!("DST layout: {:?}", layout); + trace!("DST layout: {:?}", layout); let sized_size = layout.fields.offset(layout.fields.count() - 1); let sized_align = layout.align; - debug!( + trace!( "DST {} statically sized prefix size: {:?} align: {:?}", layout.ty, sized_size, @@ -430,9 +367,11 @@ ); // Recurse to get the size of the dynamically sized field (must be - // the last field). + // the last field). Can't have foreign types here, how would we + // adjust alignment and size for them? let field = layout.field(self, layout.fields.count() - 1)?; - let (unsized_size, unsized_align) = self.size_and_align_of(Some(metadata), field)?; + let (unsized_size, unsized_align) = self.size_and_align_of(metadata, field)? + .expect("Fields cannot be extern types"); // FIXME (#26403, #27023): We should be adding padding // to `sized_size` (to accommodate the `unsized_align` @@ -459,18 +398,22 @@ // // `(size + (align-1)) & -align` - Ok((size.abi_align(align), align)) + Ok(Some((size.abi_align(align), align))) } ty::Dynamic(..) => { - let vtable = metadata.to_ptr()?; + let vtable = metadata.expect("dyn trait fat ptr must have vtable").to_ptr()?; // the second entry in the vtable is the dynamic size of the object. - self.read_size_and_align_from_vtable(vtable) + Ok(Some(self.read_size_and_align_from_vtable(vtable)?)) } ty::Slice(_) | ty::Str => { - let len = metadata.to_usize(self)?; + let len = metadata.expect("slice fat ptr must have vtable").to_usize(self)?; let (elem_size, align) = layout.field(self, 0)?.size_and_align(); - Ok((elem_size * len, align)) + Ok(Some((elem_size * len, align))) + } + + ty::Foreign(_) => { + Ok(None) } _ => bug!("size_and_align_of::<{:?}> not supported", layout.ty), @@ -479,9 +422,9 @@ #[inline] pub fn size_and_align_of_mplace( &self, - mplace: MPlaceTy<'tcx> - ) -> EvalResult<'tcx, (Size, Align)> { - self.size_and_align_of(mplace.extra, mplace.layout) + mplace: MPlaceTy<'tcx, M::PointerTag> + ) -> EvalResult<'tcx, Option<(Size, Align)>> { + self.size_and_align_of(mplace.meta, mplace.layout) } pub fn push_stack_frame( @@ -489,9 +432,12 @@ instance: ty::Instance<'tcx>, span: source_map::Span, mir: &'mir mir::Mir<'tcx>, - return_place: Place, + return_place: Option>, return_to_block: StackPopCleanup, ) -> EvalResult<'tcx> { + if self.stack.len() > 1 { // FIXME should be "> 0", printing topmost frame crashes rustc... + debug!("PAUSING({}) {}", self.cur_frame(), self.frame().instance); + } ::log_settings::settings().indentation += 1; // first push a stack frame so we have access to the local substs @@ -516,6 +462,9 @@ let dummy = LocalValue::Live(Operand::Immediate(Value::Scalar(ScalarMaybeUndef::Undef))); let mut locals = IndexVec::from_elem(dummy, &mir.local_decls); + // Return place is handled specially by the `eval_place` functions, and the + // entry in `locals` should never be used. Make it dead, to be sure. + locals[mir::RETURN_PLACE] = LocalValue::Dead; // Now mark those locals as dead that we do not want to initialize match self.tcx.describe_def(instance.def_id()) { // statics and constants don't have `Storage*` statements, no need to look for them @@ -553,7 +502,11 @@ self.frame_mut().locals = locals; } - if self.stack.len() > self.stack_limit { + if self.stack.len() > 1 { // FIXME no check should be needed, but some instances ICE + debug!("ENTERING({}) {}", self.cur_frame(), self.frame().instance); + } + + if self.stack.len() > self.tcx.sess.const_eval_stack_frame_limit { err!(StackFrameLimitReached) } else { Ok(()) @@ -561,6 +514,9 @@ } pub(super) fn pop_stack_frame(&mut self) -> EvalResult<'tcx> { + if self.stack.len() > 1 { // FIXME no check should be needed, but some instances ICE + debug!("LEAVING({}) {}", self.cur_frame(), self.frame().instance); + } ::log_settings::settings().indentation -= 1; let frame = self.stack.pop().expect( "tried to pop a stack frame, but there were none", @@ -571,20 +527,74 @@ } StackPopCleanup::None { cleanup } => { if !cleanup { - // Leak the locals + // Leak the locals. Also skip validation, this is only used by + // static/const computation which does its own (stronger) final + // validation. return Ok(()); } } } - // deallocate all locals that are backed by an allocation + // Deallocate all locals that are backed by an allocation. for local in frame.locals { self.deallocate_local(local)?; } + // Validate the return value. + if let Some(return_place) = frame.return_place { + if M::enforce_validity(self) { + // Data got changed, better make sure it matches the type! + // It is still possible that the return place held invalid data while + // the function is running, but that's okay because nobody could have + // accessed that same data from the "outside" to observe any broken + // invariant -- that is, unless a function somehow has a ptr to + // its return place... but the way MIR is currently generated, the + // return place is always a local and then this cannot happen. + self.validate_operand( + self.place_to_op(return_place)?, + &mut vec![], + None, + /*const_mode*/false, + )?; + } + } else { + // Uh, that shouldn't happen... the function did not intend to return + return err!(Unreachable); + } + + if self.stack.len() > 1 { // FIXME should be "> 0", printing topmost frame crashes rustc... + debug!("CONTINUING({}) {}", self.cur_frame(), self.frame().instance); + } Ok(()) } - pub(super) fn deallocate_local(&mut self, local: LocalValue) -> EvalResult<'tcx> { + /// Mark a storage as live, killing the previous content and returning it. + /// Remember to deallocate that! + pub fn storage_live( + &mut self, + local: mir::Local + ) -> EvalResult<'tcx, LocalValue> { + assert!(local != mir::RETURN_PLACE, "Cannot make return place live"); + trace!("{:?} is now live", local); + + let layout = self.layout_of_local(self.frame(), local)?; + let init = LocalValue::Live(self.uninit_operand(layout)?); + // StorageLive *always* kills the value that's currently stored + Ok(mem::replace(&mut self.frame_mut().locals[local], init)) + } + + /// Returns the old value of the local. + /// Remember to deallocate that! + pub fn storage_dead(&mut self, local: mir::Local) -> LocalValue { + assert!(local != mir::RETURN_PLACE, "Cannot make return place dead"); + trace!("{:?} is now dead", local); + + mem::replace(&mut self.frame_mut().locals[local], LocalValue::Dead) + } + + pub(super) fn deallocate_local( + &mut self, + local: LocalValue, + ) -> EvalResult<'tcx> { // FIXME: should we tell the user that there was a local which was never written to? if let LocalValue::Live(Operand::Indirect(MemPlace { ptr, .. })) = local { trace!("deallocating local"); @@ -605,29 +615,7 @@ .map_err(|err| EvalErrorKind::ReferencedConstant(err).into()) } - #[inline(always)] - pub fn frame(&self) -> &Frame<'mir, 'tcx> { - self.stack.last().expect("no call frames exist") - } - - #[inline(always)] - pub fn frame_mut(&mut self) -> &mut Frame<'mir, 'tcx> { - self.stack.last_mut().expect("no call frames exist") - } - - pub(super) fn mir(&self) -> &'mir mir::Mir<'tcx> { - self.frame().mir - } - - pub fn substs(&self) -> &'tcx Substs<'tcx> { - if let Some(frame) = self.stack.last() { - frame.instance.substs - } else { - Substs::empty() - } - } - - pub fn dump_place(&self, place: Place) { + pub fn dump_place(&self, place: Place) { // Debug output if !log_enabled!(::log::Level::Trace) { return; @@ -742,4 +730,3 @@ truncate(value, ty.size) } } - diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/intrinsics.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/intrinsics.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/intrinsics.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/intrinsics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -25,11 +25,11 @@ }; -fn numeric_intrinsic<'tcx>( +fn numeric_intrinsic<'tcx, Tag>( name: &str, bits: u128, kind: Primitive, -) -> EvalResult<'tcx, Scalar> { +) -> EvalResult<'tcx, Scalar> { let size = match kind { Primitive::Int(integer, _) => integer.size(), _ => bug!("invalid `{}` argument: {:?}", name, bits), @@ -46,13 +46,13 @@ Ok(Scalar::from_uint(bits_out, size)) } -impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { +impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { /// Returns whether emulation happened. pub fn emulate_intrinsic( &mut self, instance: ty::Instance<'tcx>, - args: &[OpTy<'tcx>], - dest: PlaceTy<'tcx>, + args: &[OpTy<'tcx, M::PointerTag>], + dest: PlaceTy<'tcx, M::PointerTag>, ) -> EvalResult<'tcx, bool> { let substs = instance.substs; @@ -65,6 +65,13 @@ self.write_scalar(align_val, dest)?; } + "needs_drop" => { + let ty = substs.type_at(0); + let ty_needs_drop = ty.needs_drop(self.tcx.tcx, self.param_env); + let val = Scalar::from_bool(ty_needs_drop); + self.write_scalar(val, dest)?; + } + "size_of" => { let ty = substs.type_at(0); let size = self.layout_of(ty)?.size.bytes() as u128; @@ -144,11 +151,7 @@ self.write_scalar(val, dest)?; } "transmute" => { - // Go through an allocation, to make sure the completely different layouts - // do not pose a problem. (When the user transmutes through a union, - // there will not be a layout mismatch.) - let dest = self.force_allocation(dest)?; - self.copy_op(args[0], dest.into())?; + self.copy_op_transmute(args[0], dest)?; } _ => return Ok(false), @@ -162,8 +165,8 @@ pub fn hook_fn( &mut self, instance: ty::Instance<'tcx>, - args: &[OpTy<'tcx>], - dest: Option>, + args: &[OpTy<'tcx, M::PointerTag>], + dest: Option>, ) -> EvalResult<'tcx, bool> { let def_id = instance.def_id(); // Some fn calls are actually BinOp intrinsics diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/machine.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/machine.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/machine.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/machine.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,28 +12,106 @@ //! This separation exists to ensure that no fancy miri features like //! interpreting common C functions leak into CTFE. +use std::borrow::{Borrow, Cow}; +use std::hash::Hash; + use rustc::hir::def_id::DefId; -use rustc::mir::interpret::{Allocation, EvalResult, Scalar}; use rustc::mir; -use rustc::ty::{self, layout::TyLayout, query::TyCtxtAt}; +use rustc::ty::{self, Ty, layout::{Size, TyLayout}, query::TyCtxtAt}; -use super::{EvalContext, PlaceTy, OpTy}; +use super::{ + Allocation, AllocId, EvalResult, Scalar, + EvalContext, PlaceTy, OpTy, Pointer, MemoryKind, +}; + +/// Classifying memory accesses +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum MemoryAccess { + Read, + Write, +} + +/// Whether this kind of memory is allowed to leak +pub trait MayLeak: Copy { + fn may_leak(self) -> bool; +} + +/// The functionality needed by memory to manage its allocations +pub trait AllocMap { + /// Test if the map contains the given key. + /// Deliberately takes `&mut` because that is sufficient, and some implementations + /// can be more efficient then (using `RefCell::get_mut`). + fn contains_key(&mut self, k: &Q) -> bool + where K: Borrow; + + /// Insert new entry into the map. + fn insert(&mut self, k: K, v: V) -> Option; + + /// Remove entry from the map. + fn remove(&mut self, k: &Q) -> Option + where K: Borrow; + + /// Return data based the keys and values in the map. + fn filter_map_collect(&self, f: impl FnMut(&K, &V) -> Option) -> Vec; + + /// Return a reference to entry `k`. If no such entry exists, call + /// `vacant` and either forward its error, or add its result to the map + /// and return a reference to *that*. + fn get_or( + &self, + k: K, + vacant: impl FnOnce() -> Result + ) -> Result<&V, E>; + + /// Return a mutable reference to entry `k`. If no such entry exists, call + /// `vacant` and either forward its error, or add its result to the map + /// and return a reference to *that*. + fn get_mut_or( + &mut self, + k: K, + vacant: impl FnOnce() -> Result + ) -> Result<&mut V, E>; +} /// Methods of this trait signifies a point where CTFE evaluation would fail -/// and some use case dependent behaviour can instead be applied -pub trait Machine<'mir, 'tcx>: Clone + Eq { - /// Additional data that can be accessed via the Memory - type MemoryData: Clone + Eq; - +/// and some use case dependent behaviour can instead be applied. +pub trait Machine<'a, 'mir, 'tcx>: Sized { /// Additional memory kinds a machine wishes to distinguish from the builtin ones - type MemoryKinds: ::std::fmt::Debug + Copy + Clone + Eq; - - /// The memory kind to use for mutated statics -- or None if those are not supported. - const MUT_STATIC_KIND: Option; + type MemoryKinds: ::std::fmt::Debug + MayLeak + Eq + 'static; - /// Whether to attempt to detect infinite loops (any kind of infinite - /// execution, really). - const DETECT_LOOPS: bool; + /// Tag tracked alongside every pointer. This is used to implement "Stacked Borrows" + /// . + type PointerTag: ::std::fmt::Debug + Default + Copy + Eq + Hash + 'static; + + /// Extra data stored in every allocation. + type AllocExtra: ::std::fmt::Debug + Default + Clone; + + /// Memory's allocation map + type MemoryMap: + AllocMap< + AllocId, + (MemoryKind, Allocation) + > + + Default + + Clone; + + /// The memory kind to use for copied statics -- or None if those are not supported. + /// Statics are copied under two circumstances: When they are mutated, and when + /// `static_with_default_tag` or `find_foreign_static` (see below) returns an owned allocation + /// that is added to the memory so that the work is not done twice. + const STATIC_KIND: Option; + + /// As an optimization, you can prevent the pointer tracking hooks from ever being + /// called. You should only do this if you do not care about provenance tracking. + /// This controls the `tag_reference` and `tag_dereference` hooks. + const ENABLE_PTR_TRACKING_HOOKS: bool; + + /// Whether to enforce the validity invariant + fn enforce_validity(ecx: &EvalContext<'a, 'mir, 'tcx, Self>) -> bool; + + /// Called before a basic block terminator is executed. + /// You can use this to detect endlessly running programs. + fn before_terminator(ecx: &mut EvalContext<'a, 'mir, 'tcx, Self>) -> EvalResult<'tcx>; /// Entry point to all function calls. /// @@ -45,55 +123,109 @@ /// nor just jump to `ret`, but instead push their own stack frame.) /// Passing `dest`and `ret` in the same `Option` proved very annoying when only one of them /// was used. - fn find_fn<'a>( + fn find_fn( ecx: &mut EvalContext<'a, 'mir, 'tcx, Self>, instance: ty::Instance<'tcx>, - args: &[OpTy<'tcx>], - dest: Option>, + args: &[OpTy<'tcx, Self::PointerTag>], + dest: Option>, ret: Option, ) -> EvalResult<'tcx, Option<&'mir mir::Mir<'tcx>>>; /// Directly process an intrinsic without pushing a stack frame. /// If this returns successfully, the engine will take care of jumping to the next block. - fn call_intrinsic<'a>( + fn call_intrinsic( ecx: &mut EvalContext<'a, 'mir, 'tcx, Self>, instance: ty::Instance<'tcx>, - args: &[OpTy<'tcx>], - dest: PlaceTy<'tcx>, + args: &[OpTy<'tcx, Self::PointerTag>], + dest: PlaceTy<'tcx, Self::PointerTag>, ) -> EvalResult<'tcx>; /// Called for read access to a foreign static item. - /// This can be called multiple times for the same static item and should return consistent - /// results. Once the item is *written* the first time, as usual for statics a copy is - /// made and this function is not called again. - fn find_foreign_static<'a>( + /// + /// This will only be called once per static and machine; the result is cached in + /// the machine memory. (This relies on `AllocMap::get_or` being able to add the + /// owned allocation to the map even when the map is shared.) + fn find_foreign_static( tcx: TyCtxtAt<'a, 'tcx, 'tcx>, def_id: DefId, - ) -> EvalResult<'tcx, &'tcx Allocation>; + ) -> EvalResult<'tcx, Cow<'tcx, Allocation>>; + + /// Called to turn an allocation obtained from the `tcx` into one that has + /// the appropriate tags on each pointer. + /// + /// This should avoid copying if no work has to be done! If this returns an owned + /// allocation (because a copy had to be done to add the tags), machine memory will + /// cache the result. (This relies on `AllocMap::get_or` being able to add the + /// owned allocation to the map even when the map is shared.) + fn static_with_default_tag( + alloc: &'_ Allocation + ) -> Cow<'_, Allocation>; /// Called for all binary operations on integer(-like) types when one operand is a pointer /// value, and for the `Offset` operation that is inherently about pointers. /// /// Returns a (value, overflowed) pair if the operation succeeded - fn ptr_op<'a>( + fn ptr_op( ecx: &EvalContext<'a, 'mir, 'tcx, Self>, bin_op: mir::BinOp, - left: Scalar, + left: Scalar, left_layout: TyLayout<'tcx>, - right: Scalar, + right: Scalar, right_layout: TyLayout<'tcx>, - ) -> EvalResult<'tcx, (Scalar, bool)>; + ) -> EvalResult<'tcx, (Scalar, bool)>; - /// Heap allocations via the `box` keyword - /// - /// Returns a pointer to the allocated memory - fn box_alloc<'a>( + /// Heap allocations via the `box` keyword. + fn box_alloc( ecx: &mut EvalContext<'a, 'mir, 'tcx, Self>, - dest: PlaceTy<'tcx>, + dest: PlaceTy<'tcx, Self::PointerTag>, ) -> EvalResult<'tcx>; + /// Hook for performing extra checks on a memory access. + /// + /// Takes read-only access to the allocation so we can keep all the memory read + /// operations take `&self`. Use a `RefCell` in `AllocExtra` if you + /// need to mutate. + #[inline] + fn memory_accessed( + _alloc: &Allocation, + _ptr: Pointer, + _size: Size, + _access: MemoryAccess, + ) -> EvalResult<'tcx> { + Ok(()) + } + + /// Hook for performing extra checks when memory gets deallocated. + #[inline] + fn memory_deallocated( + _alloc: &mut Allocation, + _ptr: Pointer, + ) -> EvalResult<'tcx> { + Ok(()) + } + + /// Executed when evaluating the `&` operator: Creating a new reference. + /// This has the chance to adjust the tag. + /// `borrow_kind` can be `None` in case a raw ptr is being created. + fn tag_reference( + ecx: &mut EvalContext<'a, 'mir, 'tcx, Self>, + ptr: Pointer, + pointee_ty: Ty<'tcx>, + pointee_size: Size, + borrow_kind: Option, + ) -> EvalResult<'tcx, Self::PointerTag>; + + /// Executed when evaluating the `*` operator: Following a reference. + /// This has the change to adjust the tag. + fn tag_dereference( + ecx: &EvalContext<'a, 'mir, 'tcx, Self>, + ptr: Pointer, + ptr_ty: Ty<'tcx>, + ) -> EvalResult<'tcx, Self::PointerTag>; + /// Execute a validation operation - fn validation_op<'a>( + #[inline] + fn validation_op( _ecx: &mut EvalContext<'a, 'mir, 'tcx, Self>, _op: ::rustc::mir::ValidationOp, _operand: &::rustc::mir::ValidationOperand<'tcx, ::rustc::mir::Place<'tcx>>, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/memory.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/memory.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/memory.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/memory.rs 2018-12-04 23:41:40.000000000 +0000 @@ -18,54 +18,74 @@ use std::collections::VecDeque; use std::ptr; +use std::borrow::Cow; -use rustc::ty::{self, Instance, query::TyCtxtAt}; +use rustc::ty::{self, Instance, ParamEnv, query::TyCtxtAt}; use rustc::ty::layout::{self, Align, TargetDataLayout, Size, HasDataLayout}; -use rustc::mir::interpret::{Pointer, AllocId, Allocation, ConstValue, ScalarMaybeUndef, GlobalId, - EvalResult, Scalar, EvalErrorKind, AllocType, PointerArithmetic, - truncate}; -pub use rustc::mir::interpret::{write_target_uint, read_target_uint}; +pub use rustc::mir::interpret::{truncate, write_target_uint, read_target_uint}; use rustc_data_structures::fx::{FxHashSet, FxHashMap}; use syntax::ast::Mutability; -use super::Machine; +use super::{ + Pointer, AllocId, Allocation, ConstValue, GlobalId, + EvalResult, Scalar, EvalErrorKind, AllocType, PointerArithmetic, + Machine, MemoryAccess, AllocMap, MayLeak, ScalarMaybeUndef, +}; #[derive(Debug, PartialEq, Eq, Copy, Clone, Hash)] pub enum MemoryKind { /// Error if deallocated except during a stack pop Stack, + /// Error if ever deallocated + Vtable, /// Additional memory kinds a machine wishes to distinguish from the builtin ones Machine(T), } -#[derive(Clone)] -pub struct Memory<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'mir, 'tcx>> { - /// Additional data required by the Machine - pub data: M::MemoryData, +impl MayLeak for MemoryKind { + #[inline] + fn may_leak(self) -> bool { + match self { + MemoryKind::Stack => false, + MemoryKind::Vtable => true, + MemoryKind::Machine(k) => k.may_leak() + } + } +} +// `Memory` has to depend on the `Machine` because some of its operations +// (e.g. `get`) call a `Machine` hook. +pub struct Memory<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'a, 'mir, 'tcx>> { /// Allocations local to this instance of the miri engine. The kind /// helps ensure that the same mechanism is used for allocation and /// deallocation. When an allocation is not found here, it is a - /// static and looked up in the `tcx` for read access. Writing to - /// a static creates a copy here, in the machine. - alloc_map: FxHashMap, Allocation)>, + /// static and looked up in the `tcx` for read access. Some machines may + /// have to mutate this map even on a read-only access to a static (because + /// they do pointer provenance tracking and the allocations in `tcx` have + /// the wrong type), so we let the machine override this type. + /// Either way, if the machine allows writing to a static, doing so will + /// create a copy of the static allocation here. + alloc_map: M::MemoryMap, /// To be able to compare pointers with NULL, and to check alignment for accesses /// to ZSTs (where pointers may dangle), we keep track of the size even for allocations /// that do not exist any more. dead_alloc_map: FxHashMap, - pub tcx: TyCtxtAt<'a, 'tcx, 'tcx>, + /// Lets us implement `HasDataLayout`, which is awfully convenient. + pub(super) tcx: TyCtxtAt<'a, 'tcx, 'tcx>, } -impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> HasDataLayout for &'a Memory<'a, 'mir, 'tcx, M> { +impl<'b, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> HasDataLayout + for &'b Memory<'a, 'mir, 'tcx, M> +{ #[inline] fn data_layout(&self) -> &TargetDataLayout { &self.tcx.data_layout } } -impl<'a, 'b, 'c, 'mir, 'tcx, M: Machine<'mir, 'tcx>> HasDataLayout +impl<'a, 'b, 'c, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> HasDataLayout for &'b &'c mut Memory<'a, 'mir, 'tcx, M> { #[inline] @@ -74,27 +94,40 @@ } } -impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { - pub fn new(tcx: TyCtxtAt<'a, 'tcx, 'tcx>, data: M::MemoryData) -> Self { +// FIXME: Really we shouldn't clone memory, ever. Snapshot machinery should instead +// carefully copy only the reachable parts. +impl<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'a, 'mir, 'tcx>> + Clone for Memory<'a, 'mir, 'tcx, M> +{ + fn clone(&self) -> Self { Memory { - data, - alloc_map: FxHashMap::default(), + alloc_map: self.alloc_map.clone(), + dead_alloc_map: self.dead_alloc_map.clone(), + tcx: self.tcx, + } + } +} + +impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { + pub fn new(tcx: TyCtxtAt<'a, 'tcx, 'tcx>) -> Self { + Memory { + alloc_map: Default::default(), dead_alloc_map: FxHashMap::default(), tcx, } } - pub fn create_fn_alloc(&mut self, instance: Instance<'tcx>) -> Pointer { - self.tcx.alloc_map.lock().create_fn_alloc(instance).into() + pub fn create_fn_alloc(&mut self, instance: Instance<'tcx>) -> Pointer { + Pointer::from(self.tcx.alloc_map.lock().create_fn_alloc(instance)).with_default_tag() } - pub fn allocate_static_bytes(&mut self, bytes: &[u8]) -> Pointer { - self.tcx.allocate_bytes(bytes).into() + pub fn allocate_static_bytes(&mut self, bytes: &[u8]) -> Pointer { + Pointer::from(self.tcx.allocate_bytes(bytes)).with_default_tag() } pub fn allocate_with( &mut self, - alloc: Allocation, + alloc: Allocation, kind: MemoryKind, ) -> EvalResult<'tcx, AllocId> { let id = self.tcx.alloc_map.lock().reserve(); @@ -107,19 +140,20 @@ size: Size, align: Align, kind: MemoryKind, - ) -> EvalResult<'tcx, Pointer> { - self.allocate_with(Allocation::undef(size, align), kind).map(Pointer::from) + ) -> EvalResult<'tcx, Pointer> { + let ptr = Pointer::from(self.allocate_with(Allocation::undef(size, align), kind)?); + Ok(ptr.with_default_tag()) } pub fn reallocate( &mut self, - ptr: Pointer, + ptr: Pointer, old_size: Size, old_align: Align, new_size: Size, new_align: Align, kind: MemoryKind, - ) -> EvalResult<'tcx, Pointer> { + ) -> EvalResult<'tcx, Pointer> { if ptr.offset.bytes() != 0 { return err!(ReallocateNonBasePtr); } @@ -140,7 +174,7 @@ } /// Deallocate a local, or do nothing if that local has been made into a static - pub fn deallocate_local(&mut self, ptr: Pointer) -> EvalResult<'tcx> { + pub fn deallocate_local(&mut self, ptr: Pointer) -> EvalResult<'tcx> { // The allocation might be already removed by static interning. // This can only really happen in the CTFE instance, not in miri. if self.alloc_map.contains_key(&ptr.alloc_id) { @@ -152,17 +186,17 @@ pub fn deallocate( &mut self, - ptr: Pointer, + ptr: Pointer, size_and_align: Option<(Size, Align)>, kind: MemoryKind, ) -> EvalResult<'tcx> { - debug!("deallocating: {}", ptr.alloc_id); + trace!("deallocating: {}", ptr.alloc_id); if ptr.offset.bytes() != 0 { return err!(DeallocateNonBasePtr); } - let (alloc_kind, alloc) = match self.alloc_map.remove(&ptr.alloc_id) { + let (alloc_kind, mut alloc) = match self.alloc_map.remove(&ptr.alloc_id) { Some(alloc) => alloc, None => { // Deallocating static memory -- always an error @@ -197,6 +231,9 @@ } } + // Let the machine take some extra action + M::memory_deallocated(&mut alloc, ptr)?; + // Don't forget to remember size and align of this now-dead allocation let old = self.dead_alloc_map.insert( ptr.alloc_id, @@ -211,16 +248,20 @@ /// Check that the pointer is aligned AND non-NULL. This supports ZSTs in two ways: /// You can pass a scalar, and a `Pointer` does not have to actually still be allocated. - pub fn check_align(&self, ptr: Scalar, required_align: Align) -> EvalResult<'tcx> { + pub fn check_align( + &self, + ptr: Scalar, + required_align: Align + ) -> EvalResult<'tcx> { // Check non-NULL/Undef, extract offset let (offset, alloc_align) = match ptr { Scalar::Ptr(ptr) => { - let (size, align) = self.get_size_and_align(ptr.alloc_id)?; + let (size, align) = self.get_size_and_align(ptr.alloc_id); // check this is not NULL -- which we can ensure only if this is in-bounds // of some (potentially dead) allocation. if ptr.offset > size { return err!(PointerOutOfBounds { - ptr, + ptr: ptr.erase_tag(), access: true, allocation_size: size, }); @@ -264,31 +305,49 @@ /// If you want to check bounds before doing a memory access, be sure to /// check the pointer one past the end of your access, then everything will /// work out exactly. - pub fn check_bounds(&self, ptr: Pointer, access: bool) -> EvalResult<'tcx> { + pub fn check_bounds_ptr(&self, ptr: Pointer, access: bool) -> EvalResult<'tcx> { let alloc = self.get(ptr.alloc_id)?; let allocation_size = alloc.bytes.len() as u64; if ptr.offset.bytes() > allocation_size { return err!(PointerOutOfBounds { - ptr, + ptr: ptr.erase_tag(), access, allocation_size: Size::from_bytes(allocation_size), }); } Ok(()) } + + /// Check if the memory range beginning at `ptr` and of size `Size` is "in-bounds". + #[inline(always)] + pub fn check_bounds( + &self, + ptr: Pointer, + size: Size, + access: bool + ) -> EvalResult<'tcx> { + // if ptr.offset is in bounds, then so is ptr (because offset checks for overflow) + self.check_bounds_ptr(ptr.offset(size, &*self)?, access) + } } /// Allocation accessors -impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { - /// Helper function to obtain the global (tcx) allocation for a static +impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { + /// Helper function to obtain the global (tcx) allocation for a static. + /// This attempts to return a reference to an existing allocation if + /// one can be found in `tcx`. That, however, is only possible if `tcx` and + /// this machine use the same pointer tag, so it is indirected through + /// `M::static_with_default_tag`. fn get_static_alloc( tcx: TyCtxtAt<'a, 'tcx, 'tcx>, id: AllocId, - ) -> EvalResult<'tcx, &'tcx Allocation> { + ) -> EvalResult<'tcx, Cow<'tcx, Allocation>> { let alloc = tcx.alloc_map.lock().get(id); let def_id = match alloc { Some(AllocType::Memory(mem)) => { - return Ok(mem) + // We got tcx memory. Let the machine figure out whether and how to + // turn that into memory with the right pointer tag. + return Ok(M::static_with_default_tag(mem)) } Some(AllocType::Function(..)) => { return err!(DerefFunctionPointer) @@ -315,63 +374,101 @@ EvalErrorKind::ReferencedConstant(err).into() }).map(|const_val| { if let ConstValue::ByRef(_, allocation, _) = const_val.val { - allocation + // We got tcx memory. Let the machine figure out whether and how to + // turn that into memory with the right pointer tag. + M::static_with_default_tag(allocation) } else { bug!("Matching on non-ByRef static") } }) } - pub fn get(&self, id: AllocId) -> EvalResult<'tcx, &Allocation> { - match self.alloc_map.get(&id) { - // Normal alloc? - Some(alloc) => Ok(&alloc.1), - // Static. No need to make any copies, just provide read access to the global static - // memory in tcx. - None => Self::get_static_alloc(self.tcx, id), - } - } - - pub fn get_size_and_align(&self, id: AllocId) -> EvalResult<'tcx, (Size, Align)> { - Ok(match self.get(id) { - Ok(alloc) => (Size::from_bytes(alloc.bytes.len() as u64), alloc.align), - Err(err) => match err.kind { - EvalErrorKind::DanglingPointerDeref => - // This should be in the dead allocation map - *self.dead_alloc_map.get(&id).expect( - "allocation missing in dead_alloc_map" - ), - // E.g. a function ptr allocation - _ => return Err(err) + pub fn get(&self, id: AllocId) -> EvalResult<'tcx, &Allocation> { + // The error type of the inner closure here is somewhat funny. We have two + // ways of "erroring": An actual error, or because we got a reference from + // `get_static_alloc` that we can actually use directly without inserting anything anywhere. + // So the error type is `EvalResult<'tcx, &Allocation>`. + let a = self.alloc_map.get_or(id, || { + let alloc = Self::get_static_alloc(self.tcx, id).map_err(Err)?; + match alloc { + Cow::Borrowed(alloc) => { + // We got a ref, cheaply return that as an "error" so that the + // map does not get mutated. + Err(Ok(alloc)) + } + Cow::Owned(alloc) => { + // Need to put it into the map and return a ref to that + let kind = M::STATIC_KIND.expect( + "I got an owned allocation that I have to copy but the machine does \ + not expect that to happen" + ); + Ok((MemoryKind::Machine(kind), alloc)) + } } - }) + }); + // Now unpack that funny error type + match a { + Ok(a) => Ok(&a.1), + Err(a) => a + } } pub fn get_mut( &mut self, id: AllocId, - ) -> EvalResult<'tcx, &mut Allocation> { - // Static? - if !self.alloc_map.contains_key(&id) { - // Ask the machine for what to do - if let Some(kind) = M::MUT_STATIC_KIND { - // The machine supports mutating statics. Make a copy, use that. - self.deep_copy_static(id, MemoryKind::Machine(kind))?; - } else { - return err!(ModifiedConstantMemory) + ) -> EvalResult<'tcx, &mut Allocation> { + let tcx = self.tcx; + let a = self.alloc_map.get_mut_or(id, || { + // Need to make a copy, even if `get_static_alloc` is able + // to give us a cheap reference. + let alloc = Self::get_static_alloc(tcx, id)?; + if alloc.mutability == Mutability::Immutable { + return err!(ModifiedConstantMemory); + } + let kind = M::STATIC_KIND.expect( + "An allocation is being mutated but the machine does not expect that to happen" + ); + Ok((MemoryKind::Machine(kind), alloc.into_owned())) + }); + // Unpack the error type manually because type inference doesn't + // work otherwise (and we cannot help it because `impl Trait`) + match a { + Err(e) => Err(e), + Ok(a) => { + let a = &mut a.1; + if a.mutability == Mutability::Immutable { + return err!(ModifiedConstantMemory); + } + Ok(a) } } - // If we come here, we know the allocation is in our map - let alloc = &mut self.alloc_map.get_mut(&id).unwrap().1; - // See if we are allowed to mutate this - if alloc.mutability == Mutability::Immutable { - err!(ModifiedConstantMemory) - } else { - Ok(alloc) + } + + pub fn get_size_and_align(&self, id: AllocId) -> (Size, Align) { + if let Ok(alloc) = self.get(id) { + return (Size::from_bytes(alloc.bytes.len() as u64), alloc.align); + } + // Could also be a fn ptr or extern static + match self.tcx.alloc_map.lock().get(id) { + Some(AllocType::Function(..)) => (Size::ZERO, Align::from_bytes(1, 1).unwrap()), + Some(AllocType::Static(did)) => { + // The only way `get` couldn't have worked here is if this is an extern static + assert!(self.tcx.is_foreign_item(did)); + // Use size and align of the type + let ty = self.tcx.type_of(did); + let layout = self.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap(); + (layout.size, layout.align) + } + _ => { + // Must be a deallocated pointer + *self.dead_alloc_map.get(&id).expect( + "allocation missing in dead_alloc_map" + ) + } } } - pub fn get_fn(&self, ptr: Pointer) -> EvalResult<'tcx, Instance<'tcx>> { + pub fn get_fn(&self, ptr: Pointer) -> EvalResult<'tcx, Instance<'tcx>> { if ptr.offset.bytes() != 0 { return err!(InvalidFunctionPointer); } @@ -382,130 +479,156 @@ } } + pub fn mark_immutable(&mut self, id: AllocId) -> EvalResult<'tcx> { + self.get_mut(id)?.mutability = Mutability::Immutable; + Ok(()) + } + /// For debugging, print an allocation and all allocations it points to, recursively. pub fn dump_alloc(&self, id: AllocId) { - if !log_enabled!(::log::Level::Trace) { - return; - } self.dump_allocs(vec![id]); } + fn dump_alloc_helper( + &self, + allocs_seen: &mut FxHashSet, + allocs_to_print: &mut VecDeque, + mut msg: String, + alloc: &Allocation, + extra: String, + ) { + use std::fmt::Write; + + let prefix_len = msg.len(); + let mut relocations = vec![]; + + for i in 0..(alloc.bytes.len() as u64) { + let i = Size::from_bytes(i); + if let Some(&(_, target_id)) = alloc.relocations.get(&i) { + if allocs_seen.insert(target_id) { + allocs_to_print.push_back(target_id); + } + relocations.push((i, target_id)); + } + if alloc.undef_mask.is_range_defined(i, i + Size::from_bytes(1)).is_ok() { + // this `as usize` is fine, since `i` came from a `usize` + write!(msg, "{:02x} ", alloc.bytes[i.bytes() as usize]).unwrap(); + } else { + msg.push_str("__ "); + } + } + + trace!( + "{}({} bytes, alignment {}){}", + msg, + alloc.bytes.len(), + alloc.align.abi(), + extra + ); + + if !relocations.is_empty() { + msg.clear(); + write!(msg, "{:1$}", "", prefix_len).unwrap(); // Print spaces. + let mut pos = Size::ZERO; + let relocation_width = (self.pointer_size().bytes() - 1) * 3; + for (i, target_id) in relocations { + // this `as usize` is fine, since we can't print more chars than `usize::MAX` + write!(msg, "{:1$}", "", ((i - pos) * 3).bytes() as usize).unwrap(); + let target = format!("({})", target_id); + // this `as usize` is fine, since we can't print more chars than `usize::MAX` + write!(msg, "└{0:─^1$}┘ ", target, relocation_width as usize).unwrap(); + pos = i + self.pointer_size(); + } + trace!("{}", msg); + } + } + /// For debugging, print a list of allocations and all allocations they point to, recursively. pub fn dump_allocs(&self, mut allocs: Vec) { if !log_enabled!(::log::Level::Trace) { return; } - use std::fmt::Write; allocs.sort(); allocs.dedup(); let mut allocs_to_print = VecDeque::from(allocs); let mut allocs_seen = FxHashSet::default(); while let Some(id) = allocs_to_print.pop_front() { - let mut msg = format!("Alloc {:<5} ", format!("{}:", id)); - let prefix_len = msg.len(); - let mut relocations = vec![]; - - let (alloc, immutable) = - // normal alloc? - match self.alloc_map.get(&id) { - Some((kind, alloc)) => (alloc, match kind { + let msg = format!("Alloc {:<5} ", format!("{}:", id)); + + // normal alloc? + match self.alloc_map.get_or(id, || Err(())) { + Ok((kind, alloc)) => { + let extra = match kind { MemoryKind::Stack => " (stack)".to_owned(), + MemoryKind::Vtable => " (vtable)".to_owned(), MemoryKind::Machine(m) => format!(" ({:?})", m), - }), - None => { - // static alloc? - match self.tcx.alloc_map.lock().get(id) { - Some(AllocType::Memory(a)) => (a, " (immutable)".to_owned()), - Some(AllocType::Function(func)) => { - trace!("{} {}", msg, func); - continue; - } - Some(AllocType::Static(did)) => { - trace!("{} {:?}", msg, did); - continue; - } - None => { - trace!("{} (deallocated)", msg); - continue; - } + }; + self.dump_alloc_helper( + &mut allocs_seen, &mut allocs_to_print, + msg, alloc, extra + ); + }, + Err(()) => { + // static alloc? + match self.tcx.alloc_map.lock().get(id) { + Some(AllocType::Memory(alloc)) => { + self.dump_alloc_helper( + &mut allocs_seen, &mut allocs_to_print, + msg, alloc, " (immutable)".to_owned() + ); + } + Some(AllocType::Function(func)) => { + trace!("{} {}", msg, func); + } + Some(AllocType::Static(did)) => { + trace!("{} {:?}", msg, did); + } + None => { + trace!("{} (deallocated)", msg); } - }, - }; - - for i in 0..(alloc.bytes.len() as u64) { - let i = Size::from_bytes(i); - if let Some(&target_id) = alloc.relocations.get(&i) { - if allocs_seen.insert(target_id) { - allocs_to_print.push_back(target_id); } - relocations.push((i, target_id)); - } - if alloc.undef_mask.is_range_defined(i, i + Size::from_bytes(1)).is_ok() { - // this `as usize` is fine, since `i` came from a `usize` - write!(msg, "{:02x} ", alloc.bytes[i.bytes() as usize]).unwrap(); - } else { - msg.push_str("__ "); - } - } + }, + }; - trace!( - "{}({} bytes, alignment {}){}", - msg, - alloc.bytes.len(), - alloc.align.abi(), - immutable - ); - - if !relocations.is_empty() { - msg.clear(); - write!(msg, "{:1$}", "", prefix_len).unwrap(); // Print spaces. - let mut pos = Size::ZERO; - let relocation_width = (self.pointer_size().bytes() - 1) * 3; - for (i, target_id) in relocations { - // this `as usize` is fine, since we can't print more chars than `usize::MAX` - write!(msg, "{:1$}", "", ((i - pos) * 3).bytes() as usize).unwrap(); - let target = format!("({})", target_id); - // this `as usize` is fine, since we can't print more chars than `usize::MAX` - write!(msg, "└{0:─^1$}┘ ", target, relocation_width as usize).unwrap(); - pos = i + self.pointer_size(); - } - trace!("{}", msg); - } } } pub fn leak_report(&self) -> usize { trace!("### LEAK REPORT ###"); - let mut_static_kind = M::MUT_STATIC_KIND.map(|k| MemoryKind::Machine(k)); - let leaks: Vec<_> = self.alloc_map - .iter() - .filter_map(|(&id, &(kind, _))| - // exclude mutable statics - if Some(kind) == mut_static_kind { None } else { Some(id) } ) - .collect(); + let leaks: Vec<_> = self.alloc_map.filter_map_collect(|&id, &(kind, _)| { + if kind.may_leak() { None } else { Some(id) } + }); let n = leaks.len(); self.dump_allocs(leaks); n } + + /// This is used by [priroda](https://github.com/oli-obk/priroda) + pub fn alloc_map(&self) -> &M::MemoryMap { + &self.alloc_map + } } /// Byte accessors -impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { +impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { /// The last argument controls whether we error out when there are undefined /// or pointer bytes. You should never call this, call `get_bytes` or /// `get_bytes_with_undef_and_ptr` instead, + /// + /// This function also guarantees that the resulting pointer will remain stable + /// even when new allocations are pushed to the `HashMap`. `copy_repeatedly` relies + /// on that. fn get_bytes_internal( &self, - ptr: Pointer, + ptr: Pointer, size: Size, align: Align, check_defined_and_ptr: bool, ) -> EvalResult<'tcx, &[u8]> { assert_ne!(size.bytes(), 0, "0-sized accesses should never even get a `Pointer`"); self.check_align(ptr.into(), align)?; - // if ptr.offset is in bounds, then so is ptr (because offset checks for overflow) - self.check_bounds(ptr.offset(size, &*self)?, true)?; + self.check_bounds(ptr, size, true)?; if check_defined_and_ptr { self.check_defined(ptr, size)?; @@ -516,6 +639,8 @@ } let alloc = self.get(ptr.alloc_id)?; + M::memory_accessed(alloc, ptr, size, MemoryAccess::Read)?; + assert_eq!(ptr.offset.bytes() as usize as u64, ptr.offset.bytes()); assert_eq!(size.bytes() as usize as u64, size.bytes()); let offset = ptr.offset.bytes() as usize; @@ -523,16 +648,21 @@ } #[inline] - fn get_bytes(&self, ptr: Pointer, size: Size, align: Align) -> EvalResult<'tcx, &[u8]> { + fn get_bytes( + &self, + ptr: Pointer, + size: Size, + align: Align + ) -> EvalResult<'tcx, &[u8]> { self.get_bytes_internal(ptr, size, align, true) } /// It is the caller's responsibility to handle undefined and pointer bytes. - /// However, this still checks that there are no relocations on the egdes. + /// However, this still checks that there are no relocations on the *edges*. #[inline] fn get_bytes_with_undef_and_ptr( &self, - ptr: Pointer, + ptr: Pointer, size: Size, align: Align ) -> EvalResult<'tcx, &[u8]> { @@ -543,19 +673,20 @@ /// so be sure to actually put data there! fn get_bytes_mut( &mut self, - ptr: Pointer, + ptr: Pointer, size: Size, align: Align, ) -> EvalResult<'tcx, &mut [u8]> { assert_ne!(size.bytes(), 0, "0-sized accesses should never even get a `Pointer`"); self.check_align(ptr.into(), align)?; - // if ptr.offset is in bounds, then so is ptr (because offset checks for overflow) - self.check_bounds(ptr.offset(size, &self)?, true)?; + self.check_bounds(ptr, size, true)?; self.mark_definedness(ptr, size, true)?; self.clear_relocations(ptr, size)?; let alloc = self.get_mut(ptr.alloc_id)?; + M::memory_accessed(alloc, ptr, size, MemoryAccess::Write)?; + assert_eq!(ptr.offset.bytes() as usize as u64, ptr.offset.bytes()); assert_eq!(size.bytes() as usize as u64, size.bytes()); let offset = ptr.offset.bytes() as usize; @@ -563,8 +694,12 @@ } } -/// Reading and writing -impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { +/// Interning (for CTFE) +impl<'a, 'mir, 'tcx, M> Memory<'a, 'mir, 'tcx, M> +where + M: Machine<'a, 'mir, 'tcx, PointerTag=(), AllocExtra=()>, + M::MemoryMap: AllocMap, Allocation)>, +{ /// mark an allocation as static and initialized, either mutable or not pub fn intern_static( &mut self, @@ -580,14 +715,14 @@ let (kind, mut alloc) = self.alloc_map.remove(&alloc_id).unwrap(); match kind { MemoryKind::Machine(_) => bug!("Static cannot refer to machine memory"), - MemoryKind::Stack => {}, + MemoryKind::Stack | MemoryKind::Vtable => {}, } // ensure llvm knows not to put this into immutable memory alloc.mutability = mutability; let alloc = self.tcx.intern_const_alloc(alloc); self.tcx.alloc_map.lock().set_id_memory(alloc_id, alloc); // recurse into inner allocations - for &alloc in alloc.relocations.values() { + for &(_, alloc) in alloc.relocations.values() { // FIXME: Reusing the mutability here is likely incorrect. It is originally // determined via `is_freeze`, and data is considered frozen if there is no // `UnsafeCell` *immediately* in that data -- however, this search stops @@ -601,28 +736,15 @@ } Ok(()) } +} - /// The alloc_id must refer to a (mutable) static; a deep copy of that - /// static is made into this memory. - fn deep_copy_static( - &mut self, - id: AllocId, - kind: MemoryKind, - ) -> EvalResult<'tcx> { - let alloc = Self::get_static_alloc(self.tcx, id)?; - if alloc.mutability == Mutability::Immutable { - return err!(ModifiedConstantMemory); - } - let old = self.alloc_map.insert(id, (kind, alloc.clone())); - assert!(old.is_none(), "deep_copy_static: must not overwrite existing memory"); - Ok(()) - } - +/// Reading and writing +impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { pub fn copy( &mut self, - src: Scalar, + src: Scalar, src_align: Align, - dest: Scalar, + dest: Scalar, dest_align: Align, size: Size, nonoverlapping: bool, @@ -632,9 +754,9 @@ pub fn copy_repeatedly( &mut self, - src: Scalar, + src: Scalar, src_align: Align, - dest: Scalar, + dest: Scalar, dest_align: Align, size: Size, length: u64, @@ -661,9 +783,9 @@ new_relocations.extend( relocations .iter() - .map(|&(offset, alloc_id)| { + .map(|&(offset, reloc)| { (offset + dest.offset - src.offset + (i * size * relocations.len() as u64), - alloc_id) + reloc) }) ); } @@ -678,6 +800,8 @@ // SAFE: The above indexing would have panicked if there weren't at least `size` bytes // behind `src` and `dest`. Also, we use the overlapping-safe `ptr::copy` if `src` and // `dest` could possibly overlap. + // The pointers above remain valid even if the `HashMap` table is moved around because they + // point into the `Vec` storing the bytes. unsafe { assert_eq!(size.bytes() as usize as u64, size.bytes()); if src.alloc_id == dest.alloc_id { @@ -713,7 +837,7 @@ Ok(()) } - pub fn read_c_str(&self, ptr: Pointer) -> EvalResult<'tcx, &[u8]> { + pub fn read_c_str(&self, ptr: Pointer) -> EvalResult<'tcx, &[u8]> { let alloc = self.get(ptr.alloc_id)?; assert_eq!(ptr.offset.bytes() as usize as u64, ptr.offset.bytes()); let offset = ptr.offset.bytes() as usize; @@ -724,11 +848,34 @@ self.check_defined(ptr, p1)?; Ok(&alloc.bytes[offset..offset + size]) } - None => err!(UnterminatedCString(ptr)), + None => err!(UnterminatedCString(ptr.erase_tag())), } } - pub fn read_bytes(&self, ptr: Scalar, size: Size) -> EvalResult<'tcx, &[u8]> { + pub fn check_bytes( + &self, + ptr: Scalar, + size: Size, + allow_ptr_and_undef: bool, + ) -> EvalResult<'tcx> { + // Empty accesses don't need to be valid pointers, but they should still be non-NULL + let align = Align::from_bytes(1, 1).unwrap(); + if size.bytes() == 0 { + self.check_align(ptr, align)?; + return Ok(()); + } + let ptr = ptr.to_ptr()?; + // Check bounds, align and relocations on the edges + self.get_bytes_with_undef_and_ptr(ptr, size, align)?; + // Check undef and ptr + if !allow_ptr_and_undef { + self.check_defined(ptr, size)?; + self.check_relocations(ptr, size)?; + } + Ok(()) + } + + pub fn read_bytes(&self, ptr: Scalar, size: Size) -> EvalResult<'tcx, &[u8]> { // Empty accesses don't need to be valid pointers, but they should still be non-NULL let align = Align::from_bytes(1, 1).unwrap(); if size.bytes() == 0 { @@ -738,7 +885,7 @@ self.get_bytes(ptr.to_ptr()?, size, align) } - pub fn write_bytes(&mut self, ptr: Scalar, src: &[u8]) -> EvalResult<'tcx> { + pub fn write_bytes(&mut self, ptr: Scalar, src: &[u8]) -> EvalResult<'tcx> { // Empty accesses don't need to be valid pointers, but they should still be non-NULL let align = Align::from_bytes(1, 1).unwrap(); if src.is_empty() { @@ -750,7 +897,12 @@ Ok(()) } - pub fn write_repeat(&mut self, ptr: Scalar, val: u8, count: Size) -> EvalResult<'tcx> { + pub fn write_repeat( + &mut self, + ptr: Scalar, + val: u8, + count: Size + ) -> EvalResult<'tcx> { // Empty accesses don't need to be valid pointers, but they should still be non-NULL let align = Align::from_bytes(1, 1).unwrap(); if count.bytes() == 0 { @@ -767,10 +919,10 @@ /// Read a *non-ZST* scalar pub fn read_scalar( &self, - ptr: Pointer, + ptr: Pointer, ptr_align: Align, size: Size - ) -> EvalResult<'tcx, ScalarMaybeUndef> { + ) -> EvalResult<'tcx, ScalarMaybeUndef> { // get_bytes_unchecked tests alignment and relocation edges let bytes = self.get_bytes_with_undef_and_ptr( ptr, size, ptr_align.min(self.int_align(size)) @@ -791,8 +943,8 @@ } else { let alloc = self.get(ptr.alloc_id)?; match alloc.relocations.get(&ptr.offset) { - Some(&alloc_id) => { - let ptr = Pointer::new(alloc_id, Size::from_bytes(bits as u64)); + Some(&(tag, alloc_id)) => { + let ptr = Pointer::new_with_tag(alloc_id, Size::from_bytes(bits as u64), tag); return Ok(ScalarMaybeUndef::Scalar(ptr.into())) } None => {}, @@ -802,17 +954,20 @@ Ok(ScalarMaybeUndef::Scalar(Scalar::from_uint(bits, size))) } - pub fn read_ptr_sized(&self, ptr: Pointer, ptr_align: Align) - -> EvalResult<'tcx, ScalarMaybeUndef> { + pub fn read_ptr_sized( + &self, + ptr: Pointer, + ptr_align: Align + ) -> EvalResult<'tcx, ScalarMaybeUndef> { self.read_scalar(ptr, ptr_align, self.pointer_size()) } /// Write a *non-ZST* scalar pub fn write_scalar( &mut self, - ptr: Pointer, + ptr: Pointer, ptr_align: Align, - val: ScalarMaybeUndef, + val: ScalarMaybeUndef, type_size: Size, ) -> EvalResult<'tcx> { let val = match val { @@ -846,7 +1001,7 @@ Scalar::Ptr(val) => { self.get_mut(ptr.alloc_id)?.relocations.insert( ptr.offset, - val.alloc_id, + (val.tag, val.alloc_id), ); } _ => {} @@ -855,8 +1010,12 @@ Ok(()) } - pub fn write_ptr_sized(&mut self, ptr: Pointer, ptr_align: Align, val: ScalarMaybeUndef) - -> EvalResult<'tcx> { + pub fn write_ptr_sized( + &mut self, + ptr: Pointer, + ptr_align: Align, + val: ScalarMaybeUndef + ) -> EvalResult<'tcx> { let ptr_size = self.pointer_size(); self.write_scalar(ptr.into(), ptr_align, val, ptr_size) } @@ -877,13 +1036,13 @@ } /// Relocations -impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { +impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { /// Return all relocations overlapping with the given ptr-offset pair. fn relocations( &self, - ptr: Pointer, + ptr: Pointer, size: Size, - ) -> EvalResult<'tcx, &[(Size, AllocId)]> { + ) -> EvalResult<'tcx, &[(Size, (M::PointerTag, AllocId))]> { // We have to go back `pointer_size - 1` bytes, as that one would still overlap with // the beginning of this range. let start = ptr.offset.bytes().saturating_sub(self.pointer_size().bytes() - 1); @@ -893,7 +1052,7 @@ /// Check that there ar eno relocations overlapping with the given range. #[inline(always)] - fn check_relocations(&self, ptr: Pointer, size: Size) -> EvalResult<'tcx> { + fn check_relocations(&self, ptr: Pointer, size: Size) -> EvalResult<'tcx> { if self.relocations(ptr, size)?.len() != 0 { err!(ReadPointerAsBytes) } else { @@ -907,7 +1066,7 @@ /// uninitialized. This is a somewhat odd "spooky action at a distance", /// but it allows strictly more code to run than if we would just error /// immediately in that case. - fn clear_relocations(&mut self, ptr: Pointer, size: Size) -> EvalResult<'tcx> { + fn clear_relocations(&mut self, ptr: Pointer, size: Size) -> EvalResult<'tcx> { // Find the start and end of the given range and its outermost relocations. let (first, last) = { // Find all relocations overlapping the given range. @@ -939,10 +1098,10 @@ Ok(()) } - /// Error if there are relocations overlapping with the egdes of the + /// Error if there are relocations overlapping with the edges of the /// given memory range. #[inline] - fn check_relocation_edges(&self, ptr: Pointer, size: Size) -> EvalResult<'tcx> { + fn check_relocation_edges(&self, ptr: Pointer, size: Size) -> EvalResult<'tcx> { self.check_relocations(ptr, Size::ZERO)?; self.check_relocations(ptr.offset(size, self)?, Size::ZERO)?; Ok(()) @@ -950,12 +1109,12 @@ } /// Undefined bytes -impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { - // FIXME(solson): This is a very naive, slow version. +impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { + // FIXME: Add a fast version for the common, nonoverlapping case fn copy_undef_mask( &mut self, - src: Pointer, - dest: Pointer, + src: Pointer, + dest: Pointer, size: Size, repeat: u64, ) -> EvalResult<'tcx> { @@ -982,7 +1141,7 @@ /// Checks that a range of bytes is defined. If not, returns the `ReadUndefBytes` /// error which will report the first byte which is undefined. #[inline] - fn check_defined(&self, ptr: Pointer, size: Size) -> EvalResult<'tcx> { + fn check_defined(&self, ptr: Pointer, size: Size) -> EvalResult<'tcx> { let alloc = self.get(ptr.alloc_id)?; alloc.undef_mask.is_range_defined( ptr.offset, @@ -992,7 +1151,7 @@ pub fn mark_definedness( &mut self, - ptr: Pointer, + ptr: Pointer, size: Size, new_state: bool, ) -> EvalResult<'tcx> { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -17,13 +17,15 @@ mod machine; mod memory; mod operator; -mod snapshot; +pub(crate) mod snapshot; // for const_eval mod step; mod terminator; mod traits; mod validity; mod intrinsics; +pub use rustc::mir::interpret::*; // have all the `interpret` symbols in one place: here + pub use self::eval_context::{ EvalContext, Frame, StackPopCleanup, LocalValue, }; @@ -32,19 +34,8 @@ pub use self::memory::{Memory, MemoryKind}; -pub use self::machine::Machine; +pub use self::machine::{Machine, AllocMap, MemoryAccess, MayLeak}; -pub use self::operand::{Value, ValTy, Operand, OpTy}; +pub use self::operand::{ScalarMaybeUndef, Value, ValTy, Operand, OpTy}; -// reexports for compatibility -pub use const_eval::{ - eval_promoted, - mk_borrowck_eval_cx, - mk_eval_cx, - CompileTimeEvaluator, - const_to_allocation_provider, - const_eval_provider, - const_field, - const_variant_index, - op_to_const, -}; +pub use self::validity::RefTracking; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/operand.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/operand.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/operand.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/operand.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,6 @@ //! Functions concerning immediate values and operands, and reading from operands. //! All high-level functions to read from memory work on operands as sources. -use std::hash::{Hash, Hasher}; use std::convert::TryInto; use rustc::{mir, ty}; @@ -19,11 +18,126 @@ use rustc::mir::interpret::{ GlobalId, AllocId, - ConstValue, Pointer, Scalar, ScalarMaybeUndef, + ConstValue, Pointer, Scalar, EvalResult, EvalErrorKind }; use super::{EvalContext, Machine, MemPlace, MPlaceTy, MemoryKind}; +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, RustcEncodable, RustcDecodable, Hash)] +pub enum ScalarMaybeUndef { + Scalar(Scalar), + Undef, +} + +impl From> for ScalarMaybeUndef { + #[inline(always)] + fn from(s: Scalar) -> Self { + ScalarMaybeUndef::Scalar(s) + } +} + +impl<'tcx> ScalarMaybeUndef<()> { + #[inline] + pub fn with_default_tag(self) -> ScalarMaybeUndef + where Tag: Default + { + match self { + ScalarMaybeUndef::Scalar(s) => ScalarMaybeUndef::Scalar(s.with_default_tag()), + ScalarMaybeUndef::Undef => ScalarMaybeUndef::Undef, + } + } +} + +impl<'tcx, Tag> ScalarMaybeUndef { + #[inline] + pub fn erase_tag(self) -> ScalarMaybeUndef + { + match self { + ScalarMaybeUndef::Scalar(s) => ScalarMaybeUndef::Scalar(s.erase_tag()), + ScalarMaybeUndef::Undef => ScalarMaybeUndef::Undef, + } + } + + #[inline] + pub fn not_undef(self) -> EvalResult<'static, Scalar> { + match self { + ScalarMaybeUndef::Scalar(scalar) => Ok(scalar), + ScalarMaybeUndef::Undef => err!(ReadUndefBytes(Size::from_bytes(0))), + } + } + + #[inline(always)] + pub fn to_ptr(self) -> EvalResult<'tcx, Pointer> { + self.not_undef()?.to_ptr() + } + + #[inline(always)] + pub fn to_bits(self, target_size: Size) -> EvalResult<'tcx, u128> { + self.not_undef()?.to_bits(target_size) + } + + #[inline(always)] + pub fn to_bool(self) -> EvalResult<'tcx, bool> { + self.not_undef()?.to_bool() + } + + #[inline(always)] + pub fn to_char(self) -> EvalResult<'tcx, char> { + self.not_undef()?.to_char() + } + + #[inline(always)] + pub fn to_f32(self) -> EvalResult<'tcx, f32> { + self.not_undef()?.to_f32() + } + + #[inline(always)] + pub fn to_f64(self) -> EvalResult<'tcx, f64> { + self.not_undef()?.to_f64() + } + + #[inline(always)] + pub fn to_u8(self) -> EvalResult<'tcx, u8> { + self.not_undef()?.to_u8() + } + + #[inline(always)] + pub fn to_u32(self) -> EvalResult<'tcx, u32> { + self.not_undef()?.to_u32() + } + + #[inline(always)] + pub fn to_u64(self) -> EvalResult<'tcx, u64> { + self.not_undef()?.to_u64() + } + + #[inline(always)] + pub fn to_usize(self, cx: impl HasDataLayout) -> EvalResult<'tcx, u64> { + self.not_undef()?.to_usize(cx) + } + + #[inline(always)] + pub fn to_i8(self) -> EvalResult<'tcx, i8> { + self.not_undef()?.to_i8() + } + + #[inline(always)] + pub fn to_i32(self) -> EvalResult<'tcx, i32> { + self.not_undef()?.to_i32() + } + + #[inline(always)] + pub fn to_i64(self) -> EvalResult<'tcx, i64> { + self.not_undef()?.to_i64() + } + + #[inline(always)] + pub fn to_isize(self, cx: impl HasDataLayout) -> EvalResult<'tcx, i64> { + self.not_undef()?.to_isize(cx) + } +} + + /// A `Value` represents a single immediate self-contained Rust value. /// /// For optimization of a few very common cases, there is also a representation for a pair of @@ -32,26 +146,49 @@ /// In particular, thanks to `ScalarPair`, arithmetic operations and casts can be entirely /// defined on `Value`, and do not have to work with a `Place`. #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] -pub enum Value { - Scalar(ScalarMaybeUndef), - ScalarPair(ScalarMaybeUndef, ScalarMaybeUndef), +pub enum Value { + Scalar(ScalarMaybeUndef), + ScalarPair(ScalarMaybeUndef, ScalarMaybeUndef), } -impl<'tcx> Value { +impl Value { + #[inline] + pub fn with_default_tag(self) -> Value + where Tag: Default + { + match self { + Value::Scalar(x) => Value::Scalar(x.with_default_tag()), + Value::ScalarPair(x, y) => + Value::ScalarPair(x.with_default_tag(), y.with_default_tag()), + } + } +} + +impl<'tcx, Tag> Value { + #[inline] + pub fn erase_tag(self) -> Value + { + match self { + Value::Scalar(x) => Value::Scalar(x.erase_tag()), + Value::ScalarPair(x, y) => + Value::ScalarPair(x.erase_tag(), y.erase_tag()), + } + } + pub fn new_slice( - val: Scalar, + val: Scalar, len: u64, cx: impl HasDataLayout ) -> Self { Value::ScalarPair(val.into(), Scalar::from_uint(len, cx.data_layout().pointer_size).into()) } - pub fn new_dyn_trait(val: Scalar, vtable: Pointer) -> Self { + pub fn new_dyn_trait(val: Scalar, vtable: Pointer) -> Self { Value::ScalarPair(val.into(), Scalar::Ptr(vtable).into()) } #[inline] - pub fn to_scalar_or_undef(self) -> ScalarMaybeUndef { + pub fn to_scalar_or_undef(self) -> ScalarMaybeUndef { match self { Value::Scalar(val) => val, Value::ScalarPair(..) => bug!("Got a fat pointer where a scalar was expected"), @@ -59,12 +196,12 @@ } #[inline] - pub fn to_scalar(self) -> EvalResult<'tcx, Scalar> { + pub fn to_scalar(self) -> EvalResult<'tcx, Scalar> { self.to_scalar_or_undef().not_undef() } #[inline] - pub fn to_scalar_pair(self) -> EvalResult<'tcx, (Scalar, Scalar)> { + pub fn to_scalar_pair(self) -> EvalResult<'tcx, (Scalar, Scalar)> { match self { Value::Scalar(..) => bug!("Got a thin pointer where a scalar pair was expected"), Value::ScalarPair(a, b) => Ok((a.not_undef()?, b.not_undef()?)) @@ -74,7 +211,7 @@ /// Convert the value into a pointer (or a pointer-sized integer). /// Throws away the second half of a ScalarPair! #[inline] - pub fn to_scalar_ptr(self) -> EvalResult<'tcx, Scalar> { + pub fn to_scalar_ptr(self) -> EvalResult<'tcx, Scalar> { match self { Value::Scalar(ptr) | Value::ScalarPair(ptr, _) => ptr.not_undef(), @@ -82,23 +219,18 @@ } } -impl_stable_hash_for!(enum ::interpret::Value { - Scalar(x), - ScalarPair(x, y), -}); - // ScalarPair needs a type to interpret, so we often have a value and a type together // as input for binary and cast operations. #[derive(Copy, Clone, Debug)] -pub struct ValTy<'tcx> { - value: Value, +pub struct ValTy<'tcx, Tag=()> { + value: Value, pub layout: TyLayout<'tcx>, } -impl<'tcx> ::std::ops::Deref for ValTy<'tcx> { - type Target = Value; +impl<'tcx, Tag> ::std::ops::Deref for ValTy<'tcx, Tag> { + type Target = Value; #[inline(always)] - fn deref(&self) -> &Value { + fn deref(&self) -> &Value { &self.value } } @@ -107,14 +239,37 @@ /// or still in memory. The latter is an optimization, to delay reading that chunk of /// memory and to avoid having to store arbitrary-sized data here. #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] -pub enum Operand { - Immediate(Value), - Indirect(MemPlace), +pub enum Operand { + Immediate(Value), + Indirect(MemPlace), } impl Operand { #[inline] - pub fn to_mem_place(self) -> MemPlace { + pub fn with_default_tag(self) -> Operand + where Tag: Default + { + match self { + Operand::Immediate(x) => Operand::Immediate(x.with_default_tag()), + Operand::Indirect(x) => Operand::Indirect(x.with_default_tag()), + } + } +} + +impl Operand { + #[inline] + pub fn erase_tag(self) -> Operand + { + match self { + Operand::Immediate(x) => Operand::Immediate(x.erase_tag()), + Operand::Indirect(x) => Operand::Indirect(x.erase_tag()), + } + } + + #[inline] + pub fn to_mem_place(self) -> MemPlace + where Tag: ::std::fmt::Debug + { match self { Operand::Indirect(mplace) => mplace, _ => bug!("to_mem_place: expected Operand::Indirect, got {:?}", self), @@ -123,7 +278,9 @@ } #[inline] - pub fn to_immediate(self) -> Value { + pub fn to_immediate(self) -> Value + where Tag: ::std::fmt::Debug + { match self { Operand::Immediate(val) => val, _ => bug!("to_immediate: expected Operand::Immediate, got {:?}", self), @@ -132,28 +289,23 @@ } } -impl_stable_hash_for!(enum ::interpret::Operand { - Immediate(x), - Indirect(x), -}); - -#[derive(Copy, Clone, Debug)] -pub struct OpTy<'tcx> { - crate op: Operand, // ideally we'd make this private, but const_prop needs this +#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] +pub struct OpTy<'tcx, Tag=()> { + crate op: Operand, // ideally we'd make this private, but const_prop needs this pub layout: TyLayout<'tcx>, } -impl<'tcx> ::std::ops::Deref for OpTy<'tcx> { - type Target = Operand; +impl<'tcx, Tag> ::std::ops::Deref for OpTy<'tcx, Tag> { + type Target = Operand; #[inline(always)] - fn deref(&self) -> &Operand { + fn deref(&self) -> &Operand { &self.op } } -impl<'tcx> From> for OpTy<'tcx> { +impl<'tcx, Tag: Copy> From> for OpTy<'tcx, Tag> { #[inline(always)] - fn from(mplace: MPlaceTy<'tcx>) -> Self { + fn from(mplace: MPlaceTy<'tcx, Tag>) -> Self { OpTy { op: Operand::Indirect(*mplace), layout: mplace.layout @@ -161,9 +313,9 @@ } } -impl<'tcx> From> for OpTy<'tcx> { +impl<'tcx, Tag> From> for OpTy<'tcx, Tag> { #[inline(always)] - fn from(val: ValTy<'tcx>) -> Self { + fn from(val: ValTy<'tcx, Tag>) -> Self { OpTy { op: Operand::Immediate(val.value), layout: val.layout @@ -171,19 +323,17 @@ } } -// Validation needs to hash OpTy, but we cannot hash Layout -- so we just hash the type -impl<'tcx> Hash for OpTy<'tcx> { - fn hash(&self, state: &mut H) { - self.op.hash(state); - self.layout.ty.hash(state); - } -} -impl<'tcx> PartialEq for OpTy<'tcx> { - fn eq(&self, other: &Self) -> bool { - self.op == other.op && self.layout.ty == other.layout.ty +impl<'tcx, Tag> OpTy<'tcx, Tag> +{ + #[inline] + pub fn erase_tag(self) -> OpTy<'tcx> + { + OpTy { + op: self.op.erase_tag(), + layout: self.layout, + } } } -impl<'tcx> Eq for OpTy<'tcx> {} // Use the existing layout if given (but sanity check in debug mode), // or compute the layout. @@ -206,15 +356,15 @@ } } -impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { - /// Try reading a value in memory; this is interesting particularily for ScalarPair. +impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { + /// Try reading a value in memory; this is interesting particularly for ScalarPair. /// Return None if the layout does not permit loading this as a value. pub(super) fn try_read_value_from_mplace( &self, - mplace: MPlaceTy<'tcx>, - ) -> EvalResult<'tcx, Option> { + mplace: MPlaceTy<'tcx, M::PointerTag>, + ) -> EvalResult<'tcx, Option>> { if mplace.layout.is_unsized() { - // Dont touch unsized + // Don't touch unsized return Ok(None); } let (ptr, ptr_align) = mplace.to_scalar_ptr_align(); @@ -255,8 +405,8 @@ /// in a `Value`, not on which data is stored there currently. pub(crate) fn try_read_value( &self, - src: OpTy<'tcx>, - ) -> EvalResult<'tcx, Result> { + src: OpTy<'tcx, M::PointerTag>, + ) -> EvalResult<'tcx, Result, MemPlace>> { Ok(match src.try_as_mplace() { Ok(mplace) => { if let Some(val) = self.try_read_value_from_mplace(mplace)? { @@ -271,7 +421,10 @@ /// Read a value from a place, asserting that that is possible with the given layout. #[inline(always)] - pub fn read_value(&self, op: OpTy<'tcx>) -> EvalResult<'tcx, ValTy<'tcx>> { + pub fn read_value( + &self, + op: OpTy<'tcx, M::PointerTag> + ) -> EvalResult<'tcx, ValTy<'tcx, M::PointerTag>> { if let Ok(value) = self.try_read_value(op)? { Ok(ValTy { value, layout: op.layout }) } else { @@ -280,7 +433,10 @@ } /// Read a scalar from a place - pub fn read_scalar(&self, op: OpTy<'tcx>) -> EvalResult<'tcx, ScalarMaybeUndef> { + pub fn read_scalar( + &self, + op: OpTy<'tcx, M::PointerTag> + ) -> EvalResult<'tcx, ScalarMaybeUndef> { match *self.read_value(op)? { Value::ScalarPair(..) => bug!("got ScalarPair for type: {:?}", op.layout.ty), Value::Scalar(val) => Ok(val), @@ -290,7 +446,7 @@ // Turn the MPlace into a string (must already be dereferenced!) pub fn read_str( &self, - mplace: MPlaceTy<'tcx>, + mplace: MPlaceTy<'tcx, M::PointerTag>, ) -> EvalResult<'tcx, &str> { let len = mplace.len(self)?; let bytes = self.memory.read_bytes(mplace.ptr, Size::from_bytes(len as u64))?; @@ -299,7 +455,10 @@ Ok(str) } - pub fn uninit_operand(&mut self, layout: TyLayout<'tcx>) -> EvalResult<'tcx, Operand> { + pub fn uninit_operand( + &mut self, + layout: TyLayout<'tcx> + ) -> EvalResult<'tcx, Operand> { // This decides which types we will use the Immediate optimization for, and hence should // match what `try_read_value` and `eval_place_to_op` support. if layout.is_zst() { @@ -326,9 +485,9 @@ /// Projection functions pub fn operand_field( &self, - op: OpTy<'tcx>, + op: OpTy<'tcx, M::PointerTag>, field: u64, - ) -> EvalResult<'tcx, OpTy<'tcx>> { + ) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>> { let base = match op.try_as_mplace() { Ok(mplace) => { // The easy case @@ -361,9 +520,9 @@ pub fn operand_downcast( &self, - op: OpTy<'tcx>, + op: OpTy<'tcx, M::PointerTag>, variant: usize, - ) -> EvalResult<'tcx, OpTy<'tcx>> { + ) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>> { // Downcasts only change the layout Ok(match op.try_as_mplace() { Ok(mplace) => { @@ -380,8 +539,8 @@ // will always be a MemPlace. pub(super) fn deref_operand( &self, - src: OpTy<'tcx>, - ) -> EvalResult<'tcx, MPlaceTy<'tcx>> { + src: OpTy<'tcx, M::PointerTag>, + ) -> EvalResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> { let val = self.read_value(src)?; trace!("deref to {} on {:?}", val.layout.ty, *val); Ok(self.ref_to_mplace(val)?) @@ -389,9 +548,9 @@ pub fn operand_projection( &self, - base: OpTy<'tcx>, + base: OpTy<'tcx, M::PointerTag>, proj_elem: &mir::PlaceElem<'tcx>, - ) -> EvalResult<'tcx, OpTy<'tcx>> { + ) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>> { use rustc::mir::ProjectionElem::*; Ok(match *proj_elem { Field(field, _) => self.operand_field(base, field.index() as u64)?, @@ -412,6 +571,22 @@ }) } + /// This is used by [priroda](https://github.com/oli-obk/priroda) to get an OpTy from a local + /// + /// When you know the layout of the local in advance, you can pass it as last argument + pub fn access_local( + &self, + frame: &super::Frame<'mir, 'tcx, M::PointerTag>, + local: mir::Local, + layout: Option>, + ) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>> { + assert_ne!(local, mir::RETURN_PLACE); + let op = *frame.locals[local].access()?; + let layout = from_known_layout(layout, + || self.layout_of_local(frame, local))?; + Ok(OpTy { op, layout }) + } + // Evaluate a place with the goal of reading from it. This lets us sometimes // avoid allocations. If you already know the layout, you can pass it in // to avoid looking it up again. @@ -419,16 +594,11 @@ &self, mir_place: &mir::Place<'tcx>, layout: Option>, - ) -> EvalResult<'tcx, OpTy<'tcx>> { + ) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>> { use rustc::mir::Place::*; let op = match *mir_place { Local(mir::RETURN_PLACE) => return err!(ReadFromReturnPointer), - Local(local) => { - let op = *self.frame().locals[local].access()?; - let layout = from_known_layout(layout, - || self.layout_of_local(self.cur_frame(), local))?; - OpTy { op, layout } - }, + Local(local) => self.access_local(self.frame(), local, layout)?, Projection(ref proj) => { let op = self.eval_place_to_op(&proj.base, None)?; @@ -449,7 +619,7 @@ &self, mir_op: &mir::Operand<'tcx>, layout: Option>, - ) -> EvalResult<'tcx, OpTy<'tcx>> { + ) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>> { use rustc::mir::Operand::*; let op = match *mir_op { // FIXME: do some more logic on `move` to invalidate the old location @@ -474,7 +644,7 @@ pub(super) fn eval_operands( &self, ops: &[mir::Operand<'tcx>], - ) -> EvalResult<'tcx, Vec>> { + ) -> EvalResult<'tcx, Vec>> { ops.into_iter() .map(|op| self.eval_operand(op, None)) .collect() @@ -484,7 +654,7 @@ pub(super) fn const_value_to_op( &self, val: ConstValue<'tcx>, - ) -> EvalResult<'tcx, Operand> { + ) -> EvalResult<'tcx, Operand> { trace!("const_value_to_op: {:?}", val); match val { ConstValue::Unevaluated(def_id, substs) => { @@ -497,23 +667,28 @@ ConstValue::ByRef(id, alloc, offset) => { // We rely on mutability being set correctly in that allocation to prevent writes // where none should happen -- and for `static mut`, we copy on demand anyway. - Ok(Operand::Indirect(MemPlace::from_ptr(Pointer::new(id, offset), alloc.align))) + Ok(Operand::Indirect( + MemPlace::from_ptr(Pointer::new(id, offset), alloc.align) + ).with_default_tag()) }, ConstValue::ScalarPair(a, b) => - Ok(Operand::Immediate(Value::ScalarPair(a.into(), b))), + Ok(Operand::Immediate(Value::ScalarPair(a.into(), b.into())).with_default_tag()), ConstValue::Scalar(x) => - Ok(Operand::Immediate(Value::Scalar(x.into()))), + Ok(Operand::Immediate(Value::Scalar(x.into())).with_default_tag()), } } pub fn const_to_op( &self, cnst: &ty::Const<'tcx>, - ) -> EvalResult<'tcx, OpTy<'tcx>> { + ) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>> { let op = self.const_value_to_op(cnst.val)?; Ok(OpTy { op, layout: self.layout_of(cnst.ty)? }) } - pub(super) fn global_to_op(&self, gid: GlobalId<'tcx>) -> EvalResult<'tcx, Operand> { + pub(super) fn global_to_op( + &self, + gid: GlobalId<'tcx> + ) -> EvalResult<'tcx, Operand> { let cv = self.const_eval(gid)?; self.const_value_to_op(cv.val) } @@ -521,12 +696,9 @@ /// Read discriminant, return the runtime value as well as the variant index. pub fn read_discriminant( &self, - rval: OpTy<'tcx>, + rval: OpTy<'tcx, M::PointerTag>, ) -> EvalResult<'tcx, (u128, usize)> { trace!("read_discriminant_value {:#?}", rval.layout); - if rval.layout.abi == layout::Abi::Uninhabited { - return err!(Unreachable); - } match rval.layout.variants { layout::Variants::Single { index } => { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/operator.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/operator.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/operator.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/operator.rs 2018-12-04 23:41:40.000000000 +0000 @@ -18,15 +18,15 @@ use super::{EvalContext, PlaceTy, Value, Machine, ValTy}; -impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { +impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { /// Applies the binary operation `op` to the two operands and writes a tuple of the result /// and a boolean signifying the potential overflow to the destination. pub fn binop_with_overflow( &mut self, op: mir::BinOp, - left: ValTy<'tcx>, - right: ValTy<'tcx>, - dest: PlaceTy<'tcx>, + left: ValTy<'tcx, M::PointerTag>, + right: ValTy<'tcx, M::PointerTag>, + dest: PlaceTy<'tcx, M::PointerTag>, ) -> EvalResult<'tcx> { let (val, overflowed) = self.binary_op_val(op, left, right)?; let val = Value::ScalarPair(val.into(), Scalar::from_bool(overflowed).into()); @@ -38,22 +38,22 @@ pub fn binop_ignore_overflow( &mut self, op: mir::BinOp, - left: ValTy<'tcx>, - right: ValTy<'tcx>, - dest: PlaceTy<'tcx>, + left: ValTy<'tcx, M::PointerTag>, + right: ValTy<'tcx, M::PointerTag>, + dest: PlaceTy<'tcx, M::PointerTag>, ) -> EvalResult<'tcx> { let (val, _overflowed) = self.binary_op_val(op, left, right)?; self.write_scalar(val, dest) } } -impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { +impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { fn binary_char_op( &self, bin_op: mir::BinOp, l: char, r: char, - ) -> EvalResult<'tcx, (Scalar, bool)> { + ) -> EvalResult<'tcx, (Scalar, bool)> { use rustc::mir::BinOp::*; let res = match bin_op { @@ -73,7 +73,7 @@ bin_op: mir::BinOp, l: bool, r: bool, - ) -> EvalResult<'tcx, (Scalar, bool)> { + ) -> EvalResult<'tcx, (Scalar, bool)> { use rustc::mir::BinOp::*; let res = match bin_op { @@ -98,7 +98,7 @@ // passing in raw bits l: u128, r: u128, - ) -> EvalResult<'tcx, (Scalar, bool)> { + ) -> EvalResult<'tcx, (Scalar, bool)> { use rustc::mir::BinOp::*; macro_rules! float_math { @@ -138,7 +138,7 @@ left_layout: TyLayout<'tcx>, r: u128, right_layout: TyLayout<'tcx>, - ) -> EvalResult<'tcx, (Scalar, bool)> { + ) -> EvalResult<'tcx, (Scalar, bool)> { use rustc::mir::BinOp::*; // Shift ops can have an RHS with a different numeric type. @@ -288,9 +288,9 @@ pub fn binary_op_val( &self, bin_op: mir::BinOp, - left: ValTy<'tcx>, - right: ValTy<'tcx>, - ) -> EvalResult<'tcx, (Scalar, bool)> { + left: ValTy<'tcx, M::PointerTag>, + right: ValTy<'tcx, M::PointerTag>, + ) -> EvalResult<'tcx, (Scalar, bool)> { self.binary_op( bin_op, left.to_scalar()?, left.layout, @@ -302,11 +302,11 @@ pub fn binary_op( &self, bin_op: mir::BinOp, - left: Scalar, + left: Scalar, left_layout: TyLayout<'tcx>, - right: Scalar, + right: Scalar, right_layout: TyLayout<'tcx>, - ) -> EvalResult<'tcx, (Scalar, bool)> { + ) -> EvalResult<'tcx, (Scalar, bool)> { trace!("Running binary op {:?}: {:?} ({:?}), {:?} ({:?})", bin_op, left, left_layout.ty, right, right_layout.ty); @@ -352,9 +352,9 @@ pub fn unary_op( &self, un_op: mir::UnOp, - val: Scalar, + val: Scalar, layout: TyLayout<'tcx>, - ) -> EvalResult<'tcx, Scalar> { + ) -> EvalResult<'tcx, Scalar> { use rustc::mir::UnOp::*; use rustc_apfloat::ieee::{Single, Double}; use rustc_apfloat::Float; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/place.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/place.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/place.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/place.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,42 +13,37 @@ //! All high-level functions to write to memory work on places as destinations. use std::convert::TryFrom; -use std::mem; +use std::hash::Hash; -use rustc::ich::StableHashingContext; use rustc::mir; use rustc::ty::{self, Ty}; use rustc::ty::layout::{self, Size, Align, LayoutOf, TyLayout, HasDataLayout}; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult}; use rustc::mir::interpret::{ - GlobalId, AllocId, Scalar, EvalResult, Pointer, ScalarMaybeUndef, PointerArithmetic + GlobalId, AllocId, Allocation, Scalar, EvalResult, Pointer, PointerArithmetic +}; +use super::{ + EvalContext, Machine, AllocMap, + Value, ValTy, ScalarMaybeUndef, Operand, OpTy, MemoryKind }; -use super::{EvalContext, Machine, Value, ValTy, Operand, OpTy, MemoryKind}; #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] -pub struct MemPlace { +pub struct MemPlace { /// A place may have an integral pointer for ZSTs, and since it might /// be turned back into a reference before ever being dereferenced. /// However, it may never be undef. - pub ptr: Scalar, + pub ptr: Scalar, pub align: Align, /// Metadata for unsized places. Interpretation is up to the type. /// Must not be present for sized types, but can be missing for unsized types /// (e.g. `extern type`). - pub extra: Option>, + pub meta: Option>, } -impl_stable_hash_for!(struct ::interpret::MemPlace { - ptr, - align, - extra, -}); - #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] -pub enum Place { +pub enum Place { /// A place referring to a value allocated in the `Memory` system. - Ptr(MemPlace), + Ptr(MemPlace), /// To support alloc-free locals, we are able to write directly to a local. /// (Without that optimization, we'd just always be a `MemPlace`.) @@ -58,55 +53,38 @@ }, } -// Can't use the macro here because that does not support named enum fields. -impl<'a> HashStable> for Place { - fn hash_stable( - &self, hcx: &mut StableHashingContext<'a>, - hasher: &mut StableHasher) - { - mem::discriminant(self).hash_stable(hcx, hasher); - match self { - Place::Ptr(mem_place) => mem_place.hash_stable(hcx, hasher), - - Place::Local { frame, local } => { - frame.hash_stable(hcx, hasher); - local.hash_stable(hcx, hasher); - }, - } - } -} #[derive(Copy, Clone, Debug)] -pub struct PlaceTy<'tcx> { - place: Place, +pub struct PlaceTy<'tcx, Tag=()> { + place: Place, pub layout: TyLayout<'tcx>, } -impl<'tcx> ::std::ops::Deref for PlaceTy<'tcx> { - type Target = Place; +impl<'tcx, Tag> ::std::ops::Deref for PlaceTy<'tcx, Tag> { + type Target = Place; #[inline(always)] - fn deref(&self) -> &Place { + fn deref(&self) -> &Place { &self.place } } /// A MemPlace with its layout. Constructing it is only possible in this module. #[derive(Copy, Clone, Debug)] -pub struct MPlaceTy<'tcx> { - mplace: MemPlace, +pub struct MPlaceTy<'tcx, Tag=()> { + mplace: MemPlace, pub layout: TyLayout<'tcx>, } -impl<'tcx> ::std::ops::Deref for MPlaceTy<'tcx> { - type Target = MemPlace; +impl<'tcx, Tag> ::std::ops::Deref for MPlaceTy<'tcx, Tag> { + type Target = MemPlace; #[inline(always)] - fn deref(&self) -> &MemPlace { + fn deref(&self) -> &MemPlace { &self.mplace } } -impl<'tcx> From> for PlaceTy<'tcx> { +impl<'tcx, Tag> From> for PlaceTy<'tcx, Tag> { #[inline(always)] - fn from(mplace: MPlaceTy<'tcx>) -> Self { + fn from(mplace: MPlaceTy<'tcx, Tag>) -> Self { PlaceTy { place: Place::Ptr(mplace.mplace), layout: mplace.layout @@ -115,60 +93,84 @@ } impl MemPlace { + #[inline] + pub fn with_default_tag(self) -> MemPlace + where Tag: Default + { + MemPlace { + ptr: self.ptr.with_default_tag(), + align: self.align, + meta: self.meta.map(Scalar::with_default_tag), + } + } +} + +impl MemPlace { + #[inline] + pub fn erase_tag(self) -> MemPlace + { + MemPlace { + ptr: self.ptr.erase_tag(), + align: self.align, + meta: self.meta.map(Scalar::erase_tag), + } + } + #[inline(always)] - pub fn from_scalar_ptr(ptr: Scalar, align: Align) -> Self { + pub fn from_scalar_ptr(ptr: Scalar, align: Align) -> Self { MemPlace { ptr, align, - extra: None, + meta: None, } } #[inline(always)] - pub fn from_ptr(ptr: Pointer, align: Align) -> Self { + pub fn from_ptr(ptr: Pointer, align: Align) -> Self { Self::from_scalar_ptr(ptr.into(), align) } #[inline(always)] - pub fn to_scalar_ptr_align(self) -> (Scalar, Align) { - assert_eq!(self.extra, None); + pub fn to_scalar_ptr_align(self) -> (Scalar, Align) { + assert!(self.meta.is_none()); (self.ptr, self.align) } - /// Extract the ptr part of the mplace + /// metact the ptr part of the mplace #[inline(always)] - pub fn to_ptr(self) -> EvalResult<'tcx, Pointer> { + pub fn to_ptr(self) -> EvalResult<'tcx, Pointer> { // At this point, we forget about the alignment information -- // the place has been turned into a reference, and no matter where it came from, // it now must be aligned. self.to_scalar_ptr_align().0.to_ptr() } +} - /// Turn a mplace into a (thin or fat) pointer, as a reference, pointing to the same space. - /// This is the inverse of `ref_to_mplace`. - pub fn to_ref(self) -> Value { - // We ignore the alignment of the place here -- special handling for packed structs ends - // at the `&` operator. - match self.extra { - None => Value::Scalar(self.ptr.into()), - Some(extra) => Value::ScalarPair(self.ptr.into(), extra.into()), +impl<'tcx, Tag> MPlaceTy<'tcx, Tag> { + /// Produces a MemPlace that works for ZST but nothing else + #[inline] + pub fn dangling(layout: TyLayout<'tcx>, cx: impl HasDataLayout) -> Self { + MPlaceTy { + mplace: MemPlace::from_scalar_ptr( + Scalar::from_uint(layout.align.abi(), cx.pointer_size()), + layout.align + ), + layout } } -} -impl<'tcx> MPlaceTy<'tcx> { #[inline] - fn from_aligned_ptr(ptr: Pointer, layout: TyLayout<'tcx>) -> Self { + fn from_aligned_ptr(ptr: Pointer, layout: TyLayout<'tcx>) -> Self { MPlaceTy { mplace: MemPlace::from_ptr(ptr, layout.align), layout } } #[inline] pub(super) fn len(self, cx: impl HasDataLayout) -> EvalResult<'tcx, u64> { if self.layout.is_unsized() { - // We need to consult `extra` metadata + // We need to consult `meta` metadata match self.layout.ty.sty { ty::Slice(..) | ty::Str => - return self.extra.unwrap().to_usize(cx), + return self.mplace.meta.unwrap().to_usize(cx), _ => bug!("len not supported on unsized type {:?}", self.layout.ty), } } else { @@ -182,30 +184,30 @@ } #[inline] - pub(super) fn vtable(self) -> EvalResult<'tcx, Pointer> { + pub(super) fn vtable(self) -> EvalResult<'tcx, Pointer> { match self.layout.ty.sty { - ty::Dynamic(..) => self.extra.unwrap().to_ptr(), + ty::Dynamic(..) => self.mplace.meta.unwrap().to_ptr(), _ => bug!("vtable not supported on type {:?}", self.layout.ty), } } } -impl<'tcx> OpTy<'tcx> { +impl<'tcx, Tag: ::std::fmt::Debug> OpTy<'tcx, Tag> { #[inline(always)] - pub fn try_as_mplace(self) -> Result, Value> { - match *self { + pub fn try_as_mplace(self) -> Result, Value> { + match self.op { Operand::Indirect(mplace) => Ok(MPlaceTy { mplace, layout: self.layout }), Operand::Immediate(value) => Err(value), } } #[inline(always)] - pub fn to_mem_place(self) -> MPlaceTy<'tcx> { + pub fn to_mem_place(self) -> MPlaceTy<'tcx, Tag> { self.try_as_mplace().unwrap() } } -impl<'tcx> Place { +impl<'tcx, Tag: ::std::fmt::Debug> Place { /// Produces a Place that will error if attempted to be read from or written to #[inline] pub fn null(cx: impl HasDataLayout) -> Self { @@ -213,17 +215,17 @@ } #[inline] - pub fn from_scalar_ptr(ptr: Scalar, align: Align) -> Self { + pub fn from_scalar_ptr(ptr: Scalar, align: Align) -> Self { Place::Ptr(MemPlace::from_scalar_ptr(ptr, align)) } #[inline] - pub fn from_ptr(ptr: Pointer, align: Align) -> Self { + pub fn from_ptr(ptr: Pointer, align: Align) -> Self { Place::Ptr(MemPlace::from_ptr(ptr, align)) } #[inline] - pub fn to_mem_place(self) -> MemPlace { + pub fn to_mem_place(self) -> MemPlace { match self { Place::Ptr(mplace) => mplace, _ => bug!("to_mem_place: expected Place::Ptr, got {:?}", self), @@ -232,56 +234,90 @@ } #[inline] - pub fn to_scalar_ptr_align(self) -> (Scalar, Align) { + pub fn to_scalar_ptr_align(self) -> (Scalar, Align) { self.to_mem_place().to_scalar_ptr_align() } #[inline] - pub fn to_ptr(self) -> EvalResult<'tcx, Pointer> { + pub fn to_ptr(self) -> EvalResult<'tcx, Pointer> { self.to_mem_place().to_ptr() } } -impl<'tcx> PlaceTy<'tcx> { - /// Produces a Place that will error if attempted to be read from or written to - #[inline] - pub fn null(cx: impl HasDataLayout, layout: TyLayout<'tcx>) -> Self { - PlaceTy { place: Place::from_scalar_ptr(Scalar::ptr_null(cx), layout.align), layout } - } - +impl<'tcx, Tag: ::std::fmt::Debug> PlaceTy<'tcx, Tag> { #[inline] - pub fn to_mem_place(self) -> MPlaceTy<'tcx> { + pub fn to_mem_place(self) -> MPlaceTy<'tcx, Tag> { MPlaceTy { mplace: self.place.to_mem_place(), layout: self.layout } } } -impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { +// separating the pointer tag for `impl Trait`, see https://github.com/rust-lang/rust/issues/54385 +impl<'a, 'mir, 'tcx, Tag, M> EvalContext<'a, 'mir, 'tcx, M> +where + Tag: ::std::fmt::Debug+Default+Copy+Eq+Hash+'static, + M: Machine<'a, 'mir, 'tcx, PointerTag=Tag>, + M::MemoryMap: AllocMap, Allocation)>, +{ /// Take a value, which represents a (thin or fat) reference, and make it a place. - /// Alignment is just based on the type. This is the inverse of `MemPlace::to_ref`. + /// Alignment is just based on the type. This is the inverse of `create_ref`. pub fn ref_to_mplace( - &self, val: ValTy<'tcx> - ) -> EvalResult<'tcx, MPlaceTy<'tcx>> { + &self, + val: ValTy<'tcx, M::PointerTag>, + ) -> EvalResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> { + let ptr = match val.to_scalar_ptr()? { + Scalar::Ptr(ptr) if M::ENABLE_PTR_TRACKING_HOOKS => { + // Machine might want to track the `*` operator + let tag = M::tag_dereference(self, ptr, val.layout.ty)?; + Scalar::Ptr(Pointer::new_with_tag(ptr.alloc_id, ptr.offset, tag)) + } + other => other, + }; + let pointee_type = val.layout.ty.builtin_deref(true).unwrap().ty; let layout = self.layout_of(pointee_type)?; let align = layout.align; + let mplace = match *val { - Value::Scalar(ptr) => - MemPlace { ptr: ptr.not_undef()?, align, extra: None }, - Value::ScalarPair(ptr, extra) => - MemPlace { ptr: ptr.not_undef()?, align, extra: Some(extra.not_undef()?) }, + Value::Scalar(_) => + MemPlace { ptr, align, meta: None }, + Value::ScalarPair(_, meta) => + MemPlace { ptr, align, meta: Some(meta.not_undef()?) }, }; Ok(MPlaceTy { mplace, layout }) } + /// Turn a mplace into a (thin or fat) pointer, as a reference, pointing to the same space. + /// This is the inverse of `ref_to_mplace`. + pub fn create_ref( + &mut self, + place: MPlaceTy<'tcx, M::PointerTag>, + borrow_kind: Option, + ) -> EvalResult<'tcx, Value> { + let ptr = match place.ptr { + Scalar::Ptr(ptr) if M::ENABLE_PTR_TRACKING_HOOKS => { + // Machine might want to track the `&` operator + let (size, _) = self.size_and_align_of_mplace(place)? + .expect("create_ref cannot determine size"); + let tag = M::tag_reference(self, ptr, place.layout.ty, size, borrow_kind)?; + Scalar::Ptr(Pointer::new_with_tag(ptr.alloc_id, ptr.offset, tag)) + }, + other => other, + }; + Ok(match place.meta { + None => Value::Scalar(ptr.into()), + Some(meta) => Value::ScalarPair(ptr.into(), meta.into()), + }) + } + /// Offset a pointer to project to a field. Unlike place_field, this is always /// possible without allocating, so it can take &self. Also return the field's layout. /// This supports both struct and array fields. #[inline(always)] pub fn mplace_field( &self, - base: MPlaceTy<'tcx>, + base: MPlaceTy<'tcx, M::PointerTag>, field: u64, - ) -> EvalResult<'tcx, MPlaceTy<'tcx>> { + ) -> EvalResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> { // Not using the layout method because we want to compute on u64 let offset = match base.layout.fields { layout::FieldPlacement::Arbitrary { ref offsets, .. } => @@ -304,29 +340,34 @@ let field_layout = base.layout.field(self, usize::try_from(field).unwrap_or(0))?; // Offset may need adjustment for unsized fields - let (extra, offset) = if field_layout.is_unsized() { + let (meta, offset) = if field_layout.is_unsized() { // re-use parent metadata to determine dynamic field layout - let (_, align) = self.size_and_align_of(base.extra, field_layout)?; - (base.extra, offset.abi_align(align)) - + let (_, align) = self.size_and_align_of(base.meta, field_layout)? + .expect("Fields cannot be extern types"); + (base.meta, offset.abi_align(align)) } else { - // base.extra could be present; we might be accessing a sized field of an unsized + // base.meta could be present; we might be accessing a sized field of an unsized // struct. (None, offset) }; let ptr = base.ptr.ptr_offset(offset, self)?; - let align = base.align.min(field_layout.align); // only use static information + let align = base.align + // We do not look at `base.layout.align` nor `field_layout.align`, unlike + // codegen -- mostly to see if we can get away with that + .restrict_for_offset(offset); // must be last thing that happens - Ok(MPlaceTy { mplace: MemPlace { ptr, align, extra }, layout: field_layout }) + Ok(MPlaceTy { mplace: MemPlace { ptr, align, meta }, layout: field_layout }) } // Iterates over all fields of an array. Much more efficient than doing the // same by repeatedly calling `mplace_array`. pub fn mplace_array_fields( &self, - base: MPlaceTy<'tcx>, - ) -> EvalResult<'tcx, impl Iterator>> + 'a> { + base: MPlaceTy<'tcx, Tag>, + ) -> + EvalResult<'tcx, impl Iterator>> + 'a> + { let len = base.len(self)?; // also asserts that we have a type where this makes sense let stride = match base.layout.fields { layout::FieldPlacement::Array { stride, .. } => stride, @@ -337,7 +378,7 @@ Ok((0..len).map(move |i| { let ptr = base.ptr.ptr_offset(i * stride, dl)?; Ok(MPlaceTy { - mplace: MemPlace { ptr, align: base.align, extra: None }, + mplace: MemPlace { ptr, align: base.align, meta: None }, layout }) })) @@ -345,10 +386,10 @@ pub fn mplace_subslice( &self, - base: MPlaceTy<'tcx>, + base: MPlaceTy<'tcx, M::PointerTag>, from: u64, to: u64, - ) -> EvalResult<'tcx, MPlaceTy<'tcx>> { + ) -> EvalResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> { let len = base.len(self)?; // also asserts that we have a type where this makes sense assert!(from <= len - to); @@ -361,9 +402,9 @@ }; let ptr = base.ptr.ptr_offset(from_offset, self)?; - // Compute extra and new layout + // Compute meta and new layout let inner_len = len - to - from; - let (extra, ty) = match base.layout.ty.sty { + let (meta, ty) = match base.layout.ty.sty { // It is not nice to match on the type, but that seems to be the only way to // implement this. ty::Array(inner, _) => @@ -378,27 +419,27 @@ let layout = self.layout_of(ty)?; Ok(MPlaceTy { - mplace: MemPlace { ptr, align: base.align, extra }, + mplace: MemPlace { ptr, align: base.align, meta }, layout }) } pub fn mplace_downcast( &self, - base: MPlaceTy<'tcx>, + base: MPlaceTy<'tcx, M::PointerTag>, variant: usize, - ) -> EvalResult<'tcx, MPlaceTy<'tcx>> { + ) -> EvalResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> { // Downcasts only change the layout - assert_eq!(base.extra, None); + assert!(base.meta.is_none()); Ok(MPlaceTy { layout: base.layout.for_variant(self, variant), ..base }) } /// Project into an mplace pub fn mplace_projection( &self, - base: MPlaceTy<'tcx>, + base: MPlaceTy<'tcx, M::PointerTag>, proj_elem: &mir::PlaceElem<'tcx>, - ) -> EvalResult<'tcx, MPlaceTy<'tcx>> { + ) -> EvalResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> { use rustc::mir::ProjectionElem::*; Ok(match *proj_elem { Field(field, _) => self.mplace_field(base, field.index() as u64)?, @@ -439,9 +480,9 @@ /// Just a convenience function, but used quite a bit. pub fn place_field( &mut self, - base: PlaceTy<'tcx>, + base: PlaceTy<'tcx, M::PointerTag>, field: u64, - ) -> EvalResult<'tcx, PlaceTy<'tcx>> { + ) -> EvalResult<'tcx, PlaceTy<'tcx, M::PointerTag>> { // FIXME: We could try to be smarter and avoid allocation for fields that span the // entire place. let mplace = self.force_allocation(base)?; @@ -450,9 +491,9 @@ pub fn place_downcast( &mut self, - base: PlaceTy<'tcx>, + base: PlaceTy<'tcx, M::PointerTag>, variant: usize, - ) -> EvalResult<'tcx, PlaceTy<'tcx>> { + ) -> EvalResult<'tcx, PlaceTy<'tcx, M::PointerTag>> { // Downcast just changes the layout Ok(match base.place { Place::Ptr(mplace) => @@ -467,9 +508,9 @@ /// Project into a place pub fn place_projection( &mut self, - base: PlaceTy<'tcx>, + base: PlaceTy<'tcx, M::PointerTag>, proj_elem: &mir::ProjectionElem<'tcx, mir::Local, Ty<'tcx>>, - ) -> EvalResult<'tcx, PlaceTy<'tcx>> { + ) -> EvalResult<'tcx, PlaceTy<'tcx, M::PointerTag>> { use rustc::mir::ProjectionElem::*; Ok(match *proj_elem { Field(field, _) => self.place_field(base, field.index() as u64)?, @@ -489,7 +530,7 @@ pub(super) fn eval_place_to_mplace( &self, mir_place: &mir::Place<'tcx> - ) -> EvalResult<'tcx, MPlaceTy<'tcx>> { + ) -> EvalResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> { use rustc::mir::Place::*; Ok(match *mir_place { Promoted(ref promoted) => { @@ -526,7 +567,7 @@ // and miri: They use the same query to eventually obtain a `ty::Const` // and use that for further computation. let alloc = self.tcx.alloc_map.lock().intern_static(cid.instance.def_id()); - MPlaceTy::from_aligned_ptr(alloc.into(), layout) + MPlaceTy::from_aligned_ptr(Pointer::from(alloc).with_default_tag(), layout) } _ => bug!("eval_place_to_mplace called on {:?}", mir_place), @@ -535,19 +576,28 @@ /// Compute a place. You should only use this if you intend to write into this /// place; for reading, a more efficient alternative is `eval_place_for_read`. - pub fn eval_place(&mut self, mir_place: &mir::Place<'tcx>) -> EvalResult<'tcx, PlaceTy<'tcx>> { + pub fn eval_place( + &mut self, + mir_place: &mir::Place<'tcx> + ) -> EvalResult<'tcx, PlaceTy<'tcx, M::PointerTag>> { use rustc::mir::Place::*; let place = match *mir_place { - Local(mir::RETURN_PLACE) => PlaceTy { - place: self.frame().return_place, - layout: self.layout_of_local(self.cur_frame(), mir::RETURN_PLACE)?, + Local(mir::RETURN_PLACE) => match self.frame().return_place { + Some(return_place) => + // We use our layout to verify our assumption; caller will validate + // their layout on return. + PlaceTy { + place: *return_place, + layout: self.layout_of_local(self.frame(), mir::RETURN_PLACE)?, + }, + None => return err!(InvalidNullPointerUsage), }, Local(local) => PlaceTy { place: Place::Local { frame: self.cur_frame(), local, }, - layout: self.layout_of_local(self.cur_frame(), local)?, + layout: self.layout_of_local(self.frame(), local)?, }, Projection(ref proj) => { @@ -565,19 +615,55 @@ /// Write a scalar to a place pub fn write_scalar( &mut self, - val: impl Into, - dest: PlaceTy<'tcx>, + val: impl Into>, + dest: PlaceTy<'tcx, M::PointerTag>, ) -> EvalResult<'tcx> { self.write_value(Value::Scalar(val.into()), dest) } /// Write a value to a place + #[inline(always)] pub fn write_value( &mut self, - src_val: Value, - dest: PlaceTy<'tcx>, + src_val: Value, + dest: PlaceTy<'tcx, M::PointerTag>, + ) -> EvalResult<'tcx> { + self.write_value_no_validate(src_val, dest)?; + + if M::enforce_validity(self) { + // Data got changed, better make sure it matches the type! + self.validate_operand(self.place_to_op(dest)?, &mut vec![], None, /*const_mode*/false)?; + } + + Ok(()) + } + + /// Write a value to a place. + /// If you use this you are responsible for validating that things got copied at the + /// right type. + fn write_value_no_validate( + &mut self, + src_val: Value, + dest: PlaceTy<'tcx, M::PointerTag>, ) -> EvalResult<'tcx> { - trace!("write_value: {:?} <- {:?}", *dest, src_val); + if cfg!(debug_assertions) { + // This is a very common path, avoid some checks in release mode + assert!(!dest.layout.is_unsized(), "Cannot write unsized data"); + match src_val { + Value::Scalar(ScalarMaybeUndef::Scalar(Scalar::Ptr(_))) => + assert_eq!(self.pointer_size(), dest.layout.size, + "Size mismatch when writing pointer"), + Value::Scalar(ScalarMaybeUndef::Scalar(Scalar::Bits { size, .. })) => + assert_eq!(Size::from_bytes(size.into()), dest.layout.size, + "Size mismatch when writing bits"), + Value::Scalar(ScalarMaybeUndef::Undef) => {}, // undef can have any size + Value::ScalarPair(_, _) => { + // FIXME: Can we check anything here? + } + } + } + trace!("write_value: {:?} <- {:?}: {}", *dest, src_val, dest.layout.ty); + // See if we can avoid an allocation. This is the counterpart to `try_read_value`, // but not factored as a separate function. let mplace = match dest.place { @@ -593,17 +679,19 @@ }, Place::Ptr(mplace) => mplace, // already in memory }; + let dest = MPlaceTy { mplace, layout: dest.layout }; // This is already in memory, write there. - let dest = MPlaceTy { mplace, layout: dest.layout }; - self.write_value_to_mplace(src_val, dest) + self.write_value_to_mplace_no_validate(src_val, dest) } - /// Write a value to memory - fn write_value_to_mplace( + /// Write a value to memory. + /// If you use this you are responsible for validating that things git copied at the + /// right type. + fn write_value_to_mplace_no_validate( &mut self, - value: Value, - dest: MPlaceTy<'tcx>, + value: Value, + dest: MPlaceTy<'tcx, M::PointerTag>, ) -> EvalResult<'tcx> { let (ptr, ptr_align) = dest.to_scalar_ptr_align(); // Note that it is really important that the type here is the right one, and matches the @@ -618,8 +706,17 @@ } let ptr = ptr.to_ptr()?; + // FIXME: We should check that there are dest.layout.size many bytes available in + // memory. The code below is not sufficient, with enough padding it might not + // cover all the bytes! match value { Value::Scalar(scalar) => { + match dest.layout.abi { + layout::Abi::Scalar(_) => {}, // fine + _ => bug!("write_value_to_mplace: invalid Scalar layout: {:#?}", + dest.layout) + } + self.memory.write_scalar( ptr, ptr_align.min(dest.layout.align), scalar, dest.layout.size ) @@ -635,48 +732,118 @@ let b_offset = a_size.abi_align(b_align); let b_ptr = ptr.offset(b_offset, &self)?.into(); + // It is tempting to verify `b_offset` against `layout.fields.offset(1)`, + // but that does not work: We could be a newtype around a pair, then the + // fields do not match the `ScalarPair` components. + self.memory.write_scalar(ptr, ptr_align.min(a_align), a_val, a_size)?; self.memory.write_scalar(b_ptr, ptr_align.min(b_align), b_val, b_size) } } } - /// Copy the data from an operand to a place + /// Copy the data from an operand to a place. This does not support transmuting! + /// Use `copy_op_transmute` if the layouts could disagree. + #[inline(always)] pub fn copy_op( &mut self, - src: OpTy<'tcx>, - dest: PlaceTy<'tcx>, + src: OpTy<'tcx, M::PointerTag>, + dest: PlaceTy<'tcx, M::PointerTag>, ) -> EvalResult<'tcx> { - assert!(!src.layout.is_unsized() && !dest.layout.is_unsized(), + self.copy_op_no_validate(src, dest)?; + + if M::enforce_validity(self) { + // Data got changed, better make sure it matches the type! + self.validate_operand(self.place_to_op(dest)?, &mut vec![], None, /*const_mode*/false)?; + } + + Ok(()) + } + + /// Copy the data from an operand to a place. This does not support transmuting! + /// Use `copy_op_transmute` if the layouts could disagree. + /// Also, if you use this you are responsible for validating that things git copied at the + /// right type. + fn copy_op_no_validate( + &mut self, + src: OpTy<'tcx, M::PointerTag>, + dest: PlaceTy<'tcx, M::PointerTag>, + ) -> EvalResult<'tcx> { + debug_assert!(!src.layout.is_unsized() && !dest.layout.is_unsized(), "Cannot copy unsized data"); - assert_eq!(src.layout.size, dest.layout.size, - "Size mismatch when copying!\nsrc: {:#?}\ndest: {:#?}", src, dest); + // We do NOT compare the types for equality, because well-typed code can + // actually "transmute" `&mut T` to `&T` in an assignment without a cast. + assert!(src.layout.details == dest.layout.details, + "Layout mismatch when copying!\nsrc: {:#?}\ndest: {:#?}", src, dest); // Let us see if the layout is simple so we take a shortcut, avoid force_allocation. - let (src_ptr, src_align) = match self.try_read_value(src)? { - Ok(src_val) => - // Yay, we got a value that we can write directly. We write with the - // *source layout*, because that was used to load, and if they do not match - // this is a transmute we want to support. - return self.write_value(src_val, PlaceTy { place: *dest, layout: src.layout }), - Err(mplace) => mplace.to_scalar_ptr_align(), + let src = match self.try_read_value(src)? { + Ok(src_val) => { + // Yay, we got a value that we can write directly. + return self.write_value_no_validate(src_val, dest); + } + Err(mplace) => mplace, }; // Slow path, this does not fit into an immediate. Just memcpy. - trace!("copy_op: {:?} <- {:?}", *dest, *src); - let (dest_ptr, dest_align) = self.force_allocation(dest)?.to_scalar_ptr_align(); + trace!("copy_op: {:?} <- {:?}: {}", *dest, src, dest.layout.ty); + + let dest = self.force_allocation(dest)?; + let (src_ptr, src_align) = src.to_scalar_ptr_align(); + let (dest_ptr, dest_align) = dest.to_scalar_ptr_align(); self.memory.copy( src_ptr, src_align, dest_ptr, dest_align, - src.layout.size, false - ) + dest.layout.size, false + )?; + + Ok(()) + } + + /// Copy the data from an operand to a place. The layouts may disagree, but they must + /// have the same size. + pub fn copy_op_transmute( + &mut self, + src: OpTy<'tcx, M::PointerTag>, + dest: PlaceTy<'tcx, M::PointerTag>, + ) -> EvalResult<'tcx> { + if src.layout.details == dest.layout.details { + // Fast path: Just use normal `copy_op` + return self.copy_op(src, dest); + } + // We still require the sizes to match + debug_assert!(!src.layout.is_unsized() && !dest.layout.is_unsized(), + "Cannot copy unsized data"); + assert!(src.layout.size == dest.layout.size, + "Size mismatch when transmuting!\nsrc: {:#?}\ndest: {:#?}", src, dest); + + // The hard case is `ScalarPair`. `src` is already read from memory in this case, + // using `src.layout` to figure out which bytes to use for the 1st and 2nd field. + // We have to write them to `dest` at the offsets they were *read at*, which is + // not necessarily the same as the offsets in `dest.layout`! + // Hence we do the copy with the source layout on both sides. We also make sure to write + // into memory, because if `dest` is a local we would not even have a way to write + // at the `src` offsets; the fact that we came from a different layout would + // just be lost. + let dest = self.force_allocation(dest)?; + self.copy_op_no_validate( + src, + PlaceTy::from(MPlaceTy { mplace: *dest, layout: src.layout }), + )?; + + if M::enforce_validity(self) { + // Data got changed, better make sure it matches the type! + self.validate_operand(dest.into(), &mut vec![], None, /*const_mode*/false)?; + } + + Ok(()) } /// Make sure that a place is in memory, and return where it is. /// This is essentially `force_to_memplace`. pub fn force_allocation( &mut self, - place: PlaceTy<'tcx>, - ) -> EvalResult<'tcx, MPlaceTy<'tcx>> { + place: PlaceTy<'tcx, M::PointerTag>, + ) -> EvalResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> { let mplace = match place.place { Place::Local { frame, local } => { match *self.stack[frame].locals[local].access()? { @@ -689,9 +856,11 @@ // We need the layout of the local. We can NOT use the layout we got, // that might e.g. be an inner field of a struct with `Scalar` layout, // that has different alignment than the outer field. - let local_layout = self.layout_of_local(frame, local)?; + let local_layout = self.layout_of_local(&self.stack[frame], local)?; let ptr = self.allocate(local_layout, MemoryKind::Stack)?; - self.write_value_to_mplace(value, ptr)?; + // We don't have to validate as we can assume the local + // was already valid for its type. + self.write_value_to_mplace_no_validate(value, ptr)?; let mplace = ptr.mplace; // Update the local *self.stack[frame].locals[local].access_mut()? = @@ -710,7 +879,7 @@ &mut self, layout: TyLayout<'tcx>, kind: MemoryKind, - ) -> EvalResult<'tcx, MPlaceTy<'tcx>> { + ) -> EvalResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> { assert!(!layout.is_unsized(), "cannot alloc memory for unsized type"); let ptr = self.memory.allocate(layout.size, layout.align, kind)?; Ok(MPlaceTy::from_aligned_ptr(ptr, layout)) @@ -719,7 +888,7 @@ pub fn write_discriminant_index( &mut self, variant_index: usize, - dest: PlaceTy<'tcx>, + dest: PlaceTy<'tcx, M::PointerTag>, ) -> EvalResult<'tcx> { match dest.layout.variants { layout::Variants::Single { index } => { @@ -767,7 +936,10 @@ /// Every place can be read from, so we can turm them into an operand #[inline(always)] - pub fn place_to_op(&self, place: PlaceTy<'tcx>) -> EvalResult<'tcx, OpTy<'tcx>> { + pub fn place_to_op( + &self, + place: PlaceTy<'tcx, M::PointerTag> + ) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>> { let op = match place.place { Place::Ptr(mplace) => { Operand::Indirect(mplace) @@ -780,8 +952,8 @@ /// Turn a place with a `dyn Trait` type into a place with the actual dynamic type. /// Also return some more information so drop doesn't have to run the same code twice. - pub(super) fn unpack_dyn_trait(&self, mplace: MPlaceTy<'tcx>) - -> EvalResult<'tcx, (ty::Instance<'tcx>, MPlaceTy<'tcx>)> { + pub(super) fn unpack_dyn_trait(&self, mplace: MPlaceTy<'tcx, M::PointerTag>) + -> EvalResult<'tcx, (ty::Instance<'tcx>, MPlaceTy<'tcx, M::PointerTag>)> { let vtable = mplace.vtable()?; // also sanity checks the type let (instance, ty) = self.read_drop_type_from_vtable(vtable)?; let layout = self.layout_of(ty)?; @@ -794,7 +966,7 @@ } let mplace = MPlaceTy { - mplace: MemPlace { extra: None, ..*mplace }, + mplace: MemPlace { meta: None, ..*mplace }, layout }; Ok((instance, mplace)) diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/snapshot.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/snapshot.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/snapshot.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/snapshot.rs 2018-12-04 23:41:40.000000000 +0000 @@ -2,12 +2,16 @@ //! during const-evaluation by taking snapshots of the state of the interpreter //! at regular intervals. +// This lives in `interpret` because it needs access to all sots of private state. However, +// it is not used by the general miri engine, just by CTFE. + use std::hash::{Hash, Hasher}; +use std::mem; use rustc::ich::{StableHashingContext, StableHashingContextProvider}; use rustc::mir; use rustc::mir::interpret::{ - AllocId, Pointer, Scalar, ScalarMaybeUndef, + AllocId, Pointer, Scalar, Relocations, Allocation, UndefMask, EvalResult, EvalErrorKind, }; @@ -21,9 +25,11 @@ use syntax::source_map::Span; use super::eval_context::{LocalValue, StackPopCleanup}; -use super::{Frame, Memory, Machine, Operand, MemPlace, Place, Value}; +use super::{Frame, Memory, Operand, MemPlace, Place, Value, ScalarMaybeUndef}; +use const_eval::CompileTimeInterpreter; -pub(super) struct InfiniteLoopDetector<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'mir, 'tcx>> { +#[derive(Default)] +pub(crate) struct InfiniteLoopDetector<'a, 'mir, 'tcx: 'a + 'mir> { /// The set of all `EvalSnapshot` *hashes* observed by this detector. /// /// When a collision occurs in this table, we store the full snapshot in @@ -35,47 +41,36 @@ /// An `EvalSnapshot` will only be fully cloned once it has caused a /// collision in `hashes`. As a result, the detector must observe at least /// *two* full cycles of an infinite loop before it triggers. - snapshots: FxHashSet>, -} - -impl<'a, 'mir, 'tcx, M> Default for InfiniteLoopDetector<'a, 'mir, 'tcx, M> - where M: Machine<'mir, 'tcx>, - 'tcx: 'a + 'mir, -{ - fn default() -> Self { - InfiniteLoopDetector { - hashes: FxHashSet::default(), - snapshots: FxHashSet::default(), - } - } + snapshots: FxHashSet>, } -impl<'a, 'mir, 'tcx, M> InfiniteLoopDetector<'a, 'mir, 'tcx, M> - where M: Machine<'mir, 'tcx>, - 'tcx: 'a + 'mir, +impl<'a, 'mir, 'tcx> InfiniteLoopDetector<'a, 'mir, 'tcx> { - /// Returns `true` if the loop detector has not yet observed a snapshot. - pub fn is_empty(&self) -> bool { - self.hashes.is_empty() - } - - pub fn observe_and_analyze( + pub fn observe_and_analyze<'b>( &mut self, tcx: &TyCtxt<'b, 'tcx, 'tcx>, - memory: &Memory<'a, 'mir, 'tcx, M>, + span: Span, + memory: &Memory<'a, 'mir, 'tcx, CompileTimeInterpreter<'a, 'mir, 'tcx>>, stack: &[Frame<'mir, 'tcx>], ) -> EvalResult<'tcx, ()> { - + // Compute stack's hash before copying anything let mut hcx = tcx.get_stable_hashing_context(); let mut hasher = StableHasher::::new(); stack.hash_stable(&mut hcx, &mut hasher); let hash = hasher.finish(); + // Check if we know that hash already + if self.hashes.is_empty() { + // FIXME(#49980): make this warning a lint + tcx.sess.span_warn(span, + "Constant evaluating a complex constant, this might take some time"); + } if self.hashes.insert(hash) { // No collision return Ok(()) } + // We need to make a full copy. NOW things that to get really expensive. info!("snapshotting the state of the interpreter"); if self.snapshots.insert(EvalSnapshot::new(memory, stack)) { @@ -104,6 +99,8 @@ ($field:ident, $ctx:expr, $delegate:expr) => ($delegate); } +// This assumes the type has two type parameters, first for the tag (set to `()`), +// then for the id macro_rules! impl_snapshot_for { // FIXME(mark-i-m): Some of these should be `?` rather than `*`. (enum $enum_name:ident { @@ -113,7 +110,7 @@ impl<'a, Ctx> self::Snapshot<'a, Ctx> for $enum_name where Ctx: self::SnapshotContext<'a>, { - type Item = $enum_name>; + type Item = $enum_name<(), AllocIdSnapshot<'a>>; #[inline] fn snapshot(&self, __ctx: &'a Ctx) -> Self::Item { @@ -134,7 +131,7 @@ impl<'a, Ctx> self::Snapshot<'a, Ctx> for $struct_name where Ctx: self::SnapshotContext<'a>, { - type Item = $struct_name>; + type Item = $struct_name<(), AllocIdSnapshot<'a>>; #[inline] fn snapshot(&self, __ctx: &'a Ctx) -> Self::Item { @@ -179,13 +176,14 @@ impl_snapshot_for!(struct Pointer { alloc_id, - offset -> *offset, + offset -> *offset, // just copy offset verbatim + tag -> *tag, // just copy tag }); impl<'a, Ctx> Snapshot<'a, Ctx> for Scalar where Ctx: SnapshotContext<'a>, { - type Item = Scalar>; + type Item = Scalar<(), AllocIdSnapshot<'a>>; fn snapshot(&self, ctx: &'a Ctx) -> Self::Item { match self { @@ -198,21 +196,48 @@ } } +impl_stable_hash_for!(enum ::interpret::ScalarMaybeUndef { + Scalar(v), + Undef +}); + impl_snapshot_for!(enum ScalarMaybeUndef { Scalar(s), Undef, }); +impl_stable_hash_for!(struct ::interpret::MemPlace { + ptr, + align, + meta, +}); impl_snapshot_for!(struct MemPlace { ptr, - extra, - align -> *align, + meta, + align -> *align, // just copy alignment verbatim }); +// Can't use the macro here because that does not support named enum fields. +impl<'a> HashStable> for Place { + fn hash_stable( + &self, hcx: &mut StableHashingContext<'a>, + hasher: &mut StableHasher) + { + mem::discriminant(self).hash_stable(hcx, hasher); + match self { + Place::Ptr(mem_place) => mem_place.hash_stable(hcx, hasher), + + Place::Local { frame, local } => { + frame.hash_stable(hcx, hasher); + local.hash_stable(hcx, hasher); + }, + } + } +} impl<'a, Ctx> Snapshot<'a, Ctx> for Place where Ctx: SnapshotContext<'a>, { - type Item = Place>; + type Item = Place<(), AllocIdSnapshot<'a>>; fn snapshot(&self, ctx: &'a Ctx) -> Self::Item { match self { @@ -226,16 +251,28 @@ } } +impl_stable_hash_for!(enum ::interpret::Value { + Scalar(x), + ScalarPair(x, y), +}); impl_snapshot_for!(enum Value { Scalar(s), ScalarPair(s, t), }); +impl_stable_hash_for!(enum ::interpret::Operand { + Immediate(x), + Indirect(x), +}); impl_snapshot_for!(enum Operand { Immediate(v), Indirect(m), }); +impl_stable_hash_for!(enum ::interpret::LocalValue { + Dead, + Live(x), +}); impl_snapshot_for!(enum LocalValue { Live(v), Dead, @@ -244,11 +281,11 @@ impl<'a, Ctx> Snapshot<'a, Ctx> for Relocations where Ctx: SnapshotContext<'a>, { - type Item = Relocations>; + type Item = Relocations<(), AllocIdSnapshot<'a>>; fn snapshot(&self, ctx: &'a Ctx) -> Self::Item { Relocations::from_presorted(self.iter() - .map(|(size, id)| (*size, id.snapshot(ctx))) + .map(|(size, ((), id))| (*size, ((), id.snapshot(ctx)))) .collect()) } } @@ -256,7 +293,7 @@ #[derive(Eq, PartialEq)] struct AllocationSnapshot<'a> { bytes: &'a [u8], - relocations: Relocations>, + relocations: Relocations<(), AllocIdSnapshot<'a>>, undef_mask: &'a UndefMask, align: &'a Align, mutability: &'a Mutability, @@ -268,7 +305,7 @@ type Item = AllocationSnapshot<'a>; fn snapshot(&self, ctx: &'a Ctx) -> Self::Item { - let Allocation { bytes, relocations, undef_mask, align, mutability } = self; + let Allocation { bytes, relocations, undef_mask, align, mutability, extra: () } = self; AllocationSnapshot { bytes, @@ -280,17 +317,54 @@ } } +// Can't use the macro here because that does not support named enum fields. +impl<'a> HashStable> for StackPopCleanup { + fn hash_stable( + &self, + hcx: &mut StableHashingContext<'a>, + hasher: &mut StableHasher) + { + mem::discriminant(self).hash_stable(hcx, hasher); + match self { + StackPopCleanup::Goto(ref block) => block.hash_stable(hcx, hasher), + StackPopCleanup::None { cleanup } => cleanup.hash_stable(hcx, hasher), + } + } +} + #[derive(Eq, PartialEq)] struct FrameSnapshot<'a, 'tcx: 'a> { instance: &'a ty::Instance<'tcx>, span: &'a Span, return_to_block: &'a StackPopCleanup, - return_place: Place>, - locals: IndexVec>>, + return_place: Option>>, + locals: IndexVec>>, block: &'a mir::BasicBlock, stmt: usize, } +// Not using the macro because that does not support types depending on two lifetimes +impl<'a, 'mir, 'tcx: 'mir> HashStable> for Frame<'mir, 'tcx> { + fn hash_stable( + &self, + hcx: &mut StableHashingContext<'a>, + hasher: &mut StableHasher) { + + let Frame { + mir, + instance, + span, + return_to_block, + return_place, + locals, + block, + stmt, + } = self; + + (mir, instance, span, return_to_block).hash_stable(hcx, hasher); + (return_place.as_ref().map(|r| &**r), locals, block, stmt).hash_stable(hcx, hasher); + } +} impl<'a, 'mir, 'tcx, Ctx> Snapshot<'a, Ctx> for &'a Frame<'mir, 'tcx> where Ctx: SnapshotContext<'a>, { @@ -314,28 +388,14 @@ return_to_block, block, stmt: *stmt, - return_place: return_place.snapshot(ctx), + return_place: return_place.map(|r| r.snapshot(ctx)), locals: locals.iter().map(|local| local.snapshot(ctx)).collect(), } } } -#[derive(Eq, PartialEq)] -struct MemorySnapshot<'a, 'mir: 'a, 'tcx: 'a + 'mir, M: Machine<'mir, 'tcx> + 'a> { - data: &'a M::MemoryData, -} - -impl<'a, 'mir, 'tcx, M> Memory<'a, 'mir, 'tcx, M> - where M: Machine<'mir, 'tcx>, -{ - fn snapshot<'b: 'a>(&'b self) -> MemorySnapshot<'b, 'mir, 'tcx, M> { - let Memory { data, .. } = self; - MemorySnapshot { data } - } -} - -impl<'a, 'b, 'mir, 'tcx, M> SnapshotContext<'b> for Memory<'a, 'mir, 'tcx, M> - where M: Machine<'mir, 'tcx>, +impl<'a, 'b, 'mir, 'tcx: 'a+'mir> SnapshotContext<'b> + for Memory<'a, 'mir, 'tcx, CompileTimeInterpreter<'a, 'mir, 'tcx>> { fn resolve(&'b self, id: &AllocId) -> Option<&'b Allocation> { self.get(*id).ok() @@ -343,16 +403,17 @@ } /// The virtual machine state during const-evaluation at a given point in time. -struct EvalSnapshot<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'mir, 'tcx>> { - memory: Memory<'a, 'mir, 'tcx, M>, +/// We assume the `CompileTimeInterpreter` has no interesting extra state that +/// is worth considering here. +struct EvalSnapshot<'a, 'mir, 'tcx: 'a + 'mir> { + memory: Memory<'a, 'mir, 'tcx, CompileTimeInterpreter<'a, 'mir, 'tcx>>, stack: Vec>, } -impl<'a, 'mir, 'tcx, M> EvalSnapshot<'a, 'mir, 'tcx, M> - where M: Machine<'mir, 'tcx>, +impl<'a, 'mir, 'tcx: 'a + 'mir> EvalSnapshot<'a, 'mir, 'tcx> { fn new( - memory: &Memory<'a, 'mir, 'tcx, M>, + memory: &Memory<'a, 'mir, 'tcx, CompileTimeInterpreter<'a, 'mir, 'tcx>>, stack: &[Frame<'mir, 'tcx>] ) -> Self { EvalSnapshot { @@ -361,16 +422,17 @@ } } - fn snapshot<'b: 'a>(&'b self) - -> (MemorySnapshot<'b, 'mir, 'tcx, M>, Vec>) + // Used to compare two snapshots + fn snapshot(&'b self) + -> Vec> { - let EvalSnapshot{ memory, stack } = self; - (memory.snapshot(), stack.iter().map(|frame| frame.snapshot(memory)).collect()) + // Start with the stack, iterate and recursively snapshot + self.stack.iter().map(|frame| frame.snapshot(&self.memory)).collect() } + } -impl<'a, 'mir, 'tcx, M> Hash for EvalSnapshot<'a, 'mir, 'tcx, M> - where M: Machine<'mir, 'tcx>, +impl<'a, 'mir, 'tcx> Hash for EvalSnapshot<'a, 'mir, 'tcx> { fn hash(&self, state: &mut H) { // Implement in terms of hash stable, so that k1 == k2 -> hash(k1) == hash(k2) @@ -383,28 +445,29 @@ // Not using the macro because we need special handling for `memory`, which the macro // does not support at the same time as the extra bounds on the type. -impl<'a, 'b, 'mir, 'tcx, M> HashStable> - for EvalSnapshot<'a, 'mir, 'tcx, M> - where M: Machine<'mir, 'tcx>, +impl<'a, 'b, 'mir, 'tcx> HashStable> + for EvalSnapshot<'a, 'mir, 'tcx> { fn hash_stable( &self, hcx: &mut StableHashingContext<'b>, hasher: &mut StableHasher) { + // Not hashing memory: Avoid hashing memory all the time during execution let EvalSnapshot{ memory: _, stack } = self; stack.hash_stable(hcx, hasher); } } -impl<'a, 'mir, 'tcx, M> Eq for EvalSnapshot<'a, 'mir, 'tcx, M> - where M: Machine<'mir, 'tcx>, +impl<'a, 'mir, 'tcx> Eq for EvalSnapshot<'a, 'mir, 'tcx> {} -impl<'a, 'mir, 'tcx, M> PartialEq for EvalSnapshot<'a, 'mir, 'tcx, M> - where M: Machine<'mir, 'tcx>, +impl<'a, 'mir, 'tcx> PartialEq for EvalSnapshot<'a, 'mir, 'tcx> { fn eq(&self, other: &Self) -> bool { + // FIXME: This looks to be a *ridicolously expensive* comparison operation. + // Doesn't this make tons of copies? Either `snapshot` is very badly named, + // or it does! self.snapshot() == other.snapshot() } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/step.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/step.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/step.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/step.rs 2018-12-04 23:41:40.000000000 +0000 @@ -45,52 +45,16 @@ } } -impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { - pub fn inc_step_counter_and_detect_loops(&mut self) -> EvalResult<'tcx, ()> { - /// The number of steps between loop detector snapshots. - /// Should be a power of two for performance reasons. - const DETECTOR_SNAPSHOT_PERIOD: isize = 256; - - { - let steps = &mut self.steps_since_detector_enabled; - - *steps += 1; - if *steps < 0 { - return Ok(()); - } - - *steps %= DETECTOR_SNAPSHOT_PERIOD; - if *steps != 0 { - return Ok(()); - } - } - - if !M::DETECT_LOOPS { - return Ok(()); - } - - if self.loop_detector.is_empty() { - // First run of the loop detector - - // FIXME(#49980): make this warning a lint - self.tcx.sess.span_warn(self.frame().span, - "Constant evaluating a complex constant, this might take some time"); - } - - self.loop_detector.observe_and_analyze( - &self.tcx, - &self.memory, - &self.stack[..], - ) - } - +impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { pub fn run(&mut self) -> EvalResult<'tcx> { while self.step()? {} Ok(()) } /// Returns true as long as there are more things to do. - fn step(&mut self) -> EvalResult<'tcx, bool> { + /// + /// This is used by [priroda](https://github.com/oli-obk/priroda) + pub fn step(&mut self) -> EvalResult<'tcx, bool> { if self.stack.is_empty() { return Ok(false); } @@ -108,7 +72,7 @@ return Ok(true); } - self.inc_step_counter_and_detect_loops()?; + M::before_terminator(self)?; let terminator = basic_block.terminator(); assert_eq!(old_frames, self.cur_frame()); @@ -150,9 +114,9 @@ self.deallocate_local(old_val)?; } - // No dynamic semantics attached to `ReadForMatch`; MIR + // No dynamic semantics attached to `FakeRead`; MIR // interpreter is solely intended for borrowck'ed code. - ReadForMatch(..) => {} + FakeRead(..) => {} // Validity checks. Validate(op, ref places) => { @@ -284,9 +248,10 @@ )?; } - Ref(_, _, ref place) => { + Ref(_, borrow_kind, ref place) => { let src = self.eval_place(place)?; - let val = self.force_allocation(src)?.to_ref(); + let val = self.force_allocation(src)?; + let val = self.create_ref(val, Some(borrow_kind))?; self.write_value(val, dest)?; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/terminator.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/terminator.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/terminator.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/terminator.rs 2018-12-04 23:41:40.000000000 +0000 @@ -17,10 +17,10 @@ use rustc::mir::interpret::{EvalResult, PointerArithmetic, EvalErrorKind, Scalar}; use super::{ - EvalContext, Machine, Value, OpTy, Place, PlaceTy, Operand, StackPopCleanup + EvalContext, Machine, Value, OpTy, PlaceTy, MPlaceTy, Operand, StackPopCleanup }; -impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { +impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { #[inline] pub fn goto_block(&mut self, target: Option) -> EvalResult<'tcx> { if let Some(target) = target { @@ -39,7 +39,7 @@ use rustc::mir::TerminatorKind::*; match terminator.kind { Return => { - self.dump_place(self.frame().return_place); + self.frame().return_place.map(|r| self.dump_place(*r)); self.pop_stack_frame()? } @@ -205,8 +205,8 @@ fn pass_argument( &mut self, skip_zst: bool, - caller_arg: &mut impl Iterator>, - callee_arg: PlaceTy<'tcx>, + caller_arg: &mut impl Iterator>, + callee_arg: PlaceTy<'tcx, M::PointerTag>, ) -> EvalResult<'tcx> { if skip_zst && callee_arg.layout.is_zst() { // Nothing to do. @@ -222,7 +222,8 @@ if !Self::check_argument_compat(caller_arg.layout, callee_arg.layout) { return err!(FunctionArgMismatch(caller_arg.layout.ty, callee_arg.layout.ty)); } - self.copy_op(caller_arg, callee_arg) + // We allow some transmutes here + self.copy_op_transmute(caller_arg, callee_arg) } /// Call this function -- pushing the stack frame and initializing the arguments. @@ -231,8 +232,8 @@ instance: ty::Instance<'tcx>, span: Span, caller_abi: Abi, - args: &[OpTy<'tcx>], - dest: Option>, + args: &[OpTy<'tcx, M::PointerTag>], + dest: Option>, ret: Option, ) -> EvalResult<'tcx> { trace!("eval_fn_call: {:#?}", instance); @@ -285,15 +286,11 @@ None => return Ok(()), }; - let return_place = match dest { - Some(place) => *place, - None => Place::null(&self), - }; self.push_stack_frame( instance, span, mir, - return_place, + dest, StackPopCleanup::Goto(ret), )?; @@ -313,7 +310,7 @@ mir.spread_arg, mir.args_iter() .map(|local| - (local, self.layout_of_local(self.cur_frame(), local).unwrap().ty) + (local, self.layout_of_local(self.frame(), local).unwrap().ty) ) .collect::>() ); @@ -330,7 +327,7 @@ // last incoming argument. These two iterators do not have the same type, // so to keep the code paths uniform we accept an allocation // (for RustCall ABI only). - let caller_args : Cow<[OpTy<'tcx>]> = + let caller_args : Cow<[OpTy<'tcx, M::PointerTag>]> = if caller_abi == Abi::RustCall && !args.is_empty() { // Untuple let (&untuple_arg, args) = args.split_last().unwrap(); @@ -339,7 +336,7 @@ .chain((0..untuple_arg.layout.fields.count()).into_iter() .map(|i| self.operand_field(untuple_arg, i as u64)) ) - .collect::>>>()?) + .collect::>>>()?) } else { // Plain arg passing Cow::from(args) @@ -373,6 +370,23 @@ trace!("Caller has too many args over"); return err!(FunctionArgCountMismatch); } + // Don't forget to check the return type! + if let Some(caller_ret) = dest { + let callee_ret = self.eval_place(&mir::Place::Local(mir::RETURN_PLACE))?; + if !Self::check_argument_compat(caller_ret.layout, callee_ret.layout) { + return err!(FunctionRetMismatch( + caller_ret.layout.ty, callee_ret.layout.ty + )); + } + } else { + let callee_layout = + self.layout_of_local(self.frame(), mir::RETURN_PLACE)?; + if !callee_layout.abi.is_uninhabited() { + return err!(FunctionRetMismatch( + self.tcx.types.never, callee_layout.ty + )); + } + } Ok(()) })(); match res { @@ -412,7 +426,7 @@ fn drop_in_place( &mut self, - place: PlaceTy<'tcx>, + place: PlaceTy<'tcx, M::PointerTag>, instance: ty::Instance<'tcx>, span: Span, target: mir::BasicBlock, @@ -432,19 +446,22 @@ }; let arg = OpTy { - op: Operand::Immediate(place.to_ref()), + op: Operand::Immediate(self.create_ref( + place, + None // this is a "raw reference" + )?), layout: self.layout_of(self.tcx.mk_mut_ptr(place.layout.ty))?, }; let ty = self.tcx.mk_unit(); // return type is () - let dest = PlaceTy::null(&self, self.layout_of(ty)?); + let dest = MPlaceTy::dangling(self.layout_of(ty)?, &self); self.eval_fn_call( instance, span, Abi::Rust, &[arg], - Some(dest), + Some(dest.into()), Some(target), ) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/traits.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/traits.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/traits.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/traits.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,11 +12,9 @@ use rustc::ty::layout::{Size, Align, LayoutOf}; use rustc::mir::interpret::{Scalar, Pointer, EvalResult, PointerArithmetic}; -use syntax::ast::Mutability; - use super::{EvalContext, Machine, MemoryKind}; -impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { +impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { /// Creates a dynamic vtable for the given type and vtable origin. This is used only for /// objects. /// @@ -26,22 +24,36 @@ pub fn get_vtable( &mut self, ty: Ty<'tcx>, - trait_ref: ty::PolyTraitRef<'tcx>, - ) -> EvalResult<'tcx, Pointer> { - debug!("get_vtable(trait_ref={:?})", trait_ref); + poly_trait_ref: ty::PolyExistentialTraitRef<'tcx>, + ) -> EvalResult<'tcx, Pointer> { + trace!("get_vtable(trait_ref={:?})", poly_trait_ref); + + let (ty, poly_trait_ref) = self.tcx.erase_regions(&(ty, poly_trait_ref)); + + if let Some(&vtable) = self.vtables.get(&(ty, poly_trait_ref)) { + return Ok(Pointer::from(vtable).with_default_tag()); + } + + let trait_ref = poly_trait_ref.with_self_ty(*self.tcx, ty); + let trait_ref = self.tcx.erase_regions(&trait_ref); - let layout = self.layout_of(trait_ref.self_ty())?; + let methods = self.tcx.vtable_methods(trait_ref); + + let layout = self.layout_of(ty)?; assert!(!layout.is_unsized(), "can't create a vtable for an unsized type"); let size = layout.size.bytes(); let align = layout.align.abi(); let ptr_size = self.pointer_size(); let ptr_align = self.tcx.data_layout.pointer_align; - let methods = self.tcx.vtable_methods(trait_ref); + // ///////////////////////////////////////////////////////////////////////////////////////// + // If you touch this code, be sure to also make the corresponding changes to + // `get_vtable` in rust_codegen_llvm/meth.rs + // ///////////////////////////////////////////////////////////////////////////////////////// let vtable = self.memory.allocate( ptr_size * (3 + methods.len() as u64), ptr_align, - MemoryKind::Stack, + MemoryKind::Vtable, )?; let drop = ::monomorphize::resolve_drop_in_place(*self.tcx, ty); @@ -63,10 +75,8 @@ } } - self.memory.intern_static( - vtable.alloc_id, - Mutability::Immutable, - )?; + self.memory.mark_immutable(vtable.alloc_id)?; + assert!(self.vtables.insert((ty, poly_trait_ref), vtable.alloc_id).is_none()); Ok(vtable) } @@ -74,7 +84,7 @@ /// Return the drop fn instance as well as the actual dynamic type pub fn read_drop_type_from_vtable( &self, - vtable: Pointer, + vtable: Pointer, ) -> EvalResult<'tcx, (ty::Instance<'tcx>, ty::Ty<'tcx>)> { // we don't care about the pointee type, we just want a pointer let pointer_align = self.tcx.data_layout.pointer_align; @@ -90,7 +100,7 @@ pub fn read_size_and_align_from_vtable( &self, - vtable: Pointer, + vtable: Pointer, ) -> EvalResult<'tcx, (Size, Align)> { let pointer_size = self.pointer_size(); let pointer_align = self.tcx.data_layout.pointer_align; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/validity.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/validity.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/interpret/validity.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/interpret/validity.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,20 +9,21 @@ // except according to those terms. use std::fmt::Write; +use std::hash::Hash; use syntax_pos::symbol::Symbol; -use rustc::ty::layout::{self, Size, Primitive}; -use rustc::ty::{self, Ty}; +use rustc::ty::layout::{self, Size, Align, TyLayout}; +use rustc::ty; use rustc_data_structures::fx::FxHashSet; use rustc::mir::interpret::{ - Scalar, AllocType, EvalResult, ScalarMaybeUndef, EvalErrorKind, PointerArithmetic + Scalar, AllocType, EvalResult, EvalErrorKind }; use super::{ - OpTy, Machine, EvalContext + ValTy, OpTy, MPlaceTy, Machine, EvalContext, ScalarMaybeUndef }; -macro_rules! validation_failure{ +macro_rules! validation_failure { ($what:expr, $where:expr, $details:expr) => {{ let where_ = path_format($where); let where_ = if where_.is_empty() { @@ -49,6 +50,22 @@ }}; } +macro_rules! try_validation { + ($e:expr, $what:expr, $where:expr, $details:expr) => {{ + match $e { + Ok(x) => x, + Err(_) => return validation_failure!($what, $where, $details), + } + }}; + + ($e:expr, $what:expr, $where:expr) => {{ + match $e { + Ok(x) => x, + Err(_) => return validation_failure!($what, $where), + } + }} +} + /// We want to show a nice path to the invalid field for diagnotsics, /// but avoid string operations in the happy case where no error happens. /// So we track a `Vec` where `PathElem` contains all the data we @@ -63,6 +80,23 @@ Tag, } +/// State for tracking recursive validation of references +pub struct RefTracking<'tcx, Tag> { + pub seen: FxHashSet<(OpTy<'tcx, Tag>)>, + pub todo: Vec<(OpTy<'tcx, Tag>, Vec)>, +} + +impl<'tcx, Tag: Copy+Eq+Hash> RefTracking<'tcx, Tag> { + pub fn new(op: OpTy<'tcx, Tag>) -> Self { + let mut ref_tracking = RefTracking { + seen: FxHashSet::default(), + todo: vec![(op, Vec::new())], + }; + ref_tracking.seen.insert(op); + ref_tracking + } +} + // Adding a Deref and making a copy of the path to be put into the queue // always go together. This one does it with only new allocation. fn path_clone_and_deref(path: &Vec) -> Vec { @@ -95,133 +129,259 @@ out } -impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { - fn validate_scalar( +fn scalar_format(value: ScalarMaybeUndef) -> String { + match value { + ScalarMaybeUndef::Undef => + "uninitialized bytes".to_owned(), + ScalarMaybeUndef::Scalar(Scalar::Ptr(_)) => + "a pointer".to_owned(), + ScalarMaybeUndef::Scalar(Scalar::Bits { bits, .. }) => + bits.to_string(), + } +} + +impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { + /// Make sure that `value` is valid for `ty`, *assuming* `ty` is a primitive type. + fn validate_primitive_type( &self, - value: ScalarMaybeUndef, - size: Size, - scalar: &layout::Scalar, + value: ValTy<'tcx, M::PointerTag>, path: &Vec, - ty: Ty, + ref_tracking: Option<&mut RefTracking<'tcx, M::PointerTag>>, + const_mode: bool, ) -> EvalResult<'tcx> { - trace!("validate scalar: {:#?}, {:#?}, {:#?}, {}", value, size, scalar, ty); - let (lo, hi) = scalar.valid_range.clone().into_inner(); - - let value = match value { - ScalarMaybeUndef::Scalar(scalar) => scalar, - ScalarMaybeUndef::Undef => return validation_failure!("undefined bytes", path), - }; - - let bits = match value { - Scalar::Bits { bits, size: value_size } => { - assert_eq!(value_size as u64, size.bytes()); - bits + // Go over all the primitive types + let ty = value.layout.ty; + match ty.sty { + ty::Bool => { + let value = value.to_scalar_or_undef(); + try_validation!(value.to_bool(), + scalar_format(value), path, "a boolean"); }, - Scalar::Ptr(_) => { - match ty.sty { - ty::Bool | - ty::Char | - ty::Float(_) | - ty::Int(_) | - ty::Uint(_) => { - return validation_failure!( - "a pointer", - path, - format!("the type {}", ty.sty) - ); + ty::Char => { + let value = value.to_scalar_or_undef(); + try_validation!(value.to_char(), + scalar_format(value), path, "a valid unicode codepoint"); + }, + ty::Float(_) | ty::Int(_) | ty::Uint(_) => { + // NOTE: Keep this in sync with the array optimization for int/float + // types below! + let size = value.layout.size; + let value = value.to_scalar_or_undef(); + if const_mode { + // Integers/floats in CTFE: Must be scalar bits, pointers are dangerous + try_validation!(value.to_bits(size), + scalar_format(value), path, "initialized plain bits"); + } else { + // At run-time, for now, we accept *anything* for these types, including + // undef. We should fix that, but let's start low. + } + } + _ if ty.is_box() || ty.is_region_ptr() || ty.is_unsafe_ptr() => { + // Handle fat pointers. We also check fat raw pointers, + // their metadata must be valid! + // This also checks that the ptr itself is initialized, which + // seems reasonable even for raw pointers. + let place = try_validation!(self.ref_to_mplace(value), + "undefined data in pointer", path); + // Check metadata early, for better diagnostics + if place.layout.is_unsized() { + let tail = self.tcx.struct_tail(place.layout.ty); + match tail.sty { + ty::Dynamic(..) => { + let vtable = try_validation!(place.meta.unwrap().to_ptr(), + "non-pointer vtable in fat pointer", path); + try_validation!(self.read_drop_type_from_vtable(vtable), + "invalid drop fn in vtable", path); + try_validation!(self.read_size_and_align_from_vtable(vtable), + "invalid size or align in vtable", path); + // FIXME: More checks for the vtable. + } + ty::Slice(..) | ty::Str => { + try_validation!(place.meta.unwrap().to_usize(self), + "non-integer slice length in fat pointer", path); + } + ty::Foreign(..) => { + // Unsized, but not fat. + } + _ => + bug!("Unexpected unsized type tail: {:?}", tail), } - ty::RawPtr(_) | - ty::Ref(_, _, _) | - ty::FnPtr(_) => {} - _ => { unreachable!(); } } + // for safe ptrs, also check the ptr values itself + if !ty.is_unsafe_ptr() { + // Make sure this is non-NULL and aligned + let (size, align) = self.size_and_align_of(place.meta, place.layout)? + // for the purpose of validity, consider foreign types to have + // alignment and size determined by the layout (size will be 0, + // alignment should take attributes into account). + .unwrap_or_else(|| place.layout.size_and_align()); + match self.memory.check_align(place.ptr, align) { + Ok(_) => {}, + Err(err) => match err.kind { + EvalErrorKind::InvalidNullPointerUsage => + return validation_failure!("NULL reference", path), + EvalErrorKind::AlignmentCheckFailed { .. } => + return validation_failure!("unaligned reference", path), + _ => + return validation_failure!( + "dangling (out-of-bounds) reference (might be NULL at \ + run-time)", + path + ), + } + } + // non-ZST also have to be dereferenceable + if size != Size::ZERO { + let ptr = try_validation!(place.ptr.to_ptr(), + "integer pointer in non-ZST reference", path); + if const_mode { + // Skip validation entirely for some external statics + let alloc_kind = self.tcx.alloc_map.lock().get(ptr.alloc_id); + if let Some(AllocType::Static(did)) = alloc_kind { + // `extern static` cannot be validated as they have no body. + // FIXME: Statics from other crates are also skipped. + // They might be checked at a different type, but for now we + // want to avoid recursing too deeply. This is not sound! + if !did.is_local() || self.tcx.is_foreign_item(did) { + return Ok(()); + } + } + } + try_validation!(self.memory.check_bounds(ptr, size, false), + "dangling (not entirely in bounds) reference", path); + } + if let Some(ref_tracking) = ref_tracking { + // Check if we have encountered this pointer+layout combination + // before. Proceed recursively even for integer pointers, no + // reason to skip them! They are (recursively) valid for some ZST, + // but not for others (e.g. `!` is a ZST). + let op = place.into(); + if ref_tracking.seen.insert(op) { + trace!("Recursing below ptr {:#?}", *op); + ref_tracking.todo.push((op, path_clone_and_deref(path))); + } + } + } + } + ty::FnPtr(_sig) => { + let value = value.to_scalar_or_undef(); + let ptr = try_validation!(value.to_ptr(), + scalar_format(value), path, "a pointer"); + let _fn = try_validation!(self.memory.get_fn(ptr), + scalar_format(value), path, "a function pointer"); + // FIXME: Check if the signature matches + } + // This should be all the primitive types + ty::Never => bug!("Uninhabited type should have been caught earlier"), + _ => bug!("Unexpected primitive type {}", value.layout.ty) + } + Ok(()) + } - let ptr_size = self.pointer_size(); - let ptr_max = u128::max_value() >> (128 - ptr_size.bits()); - return if lo > hi { - if lo - hi == 1 { - // no gap, all values are ok - Ok(()) - } else if hi < ptr_max || lo > 1 { - let max = u128::max_value() >> (128 - size.bits()); - validation_failure!( - "pointer", - path, - format!("something in the range {:?} or {:?}", 0..=lo, hi..=max) - ) - } else { - Ok(()) + /// Make sure that `value` matches the + fn validate_scalar_layout( + &self, + value: ScalarMaybeUndef, + size: Size, + path: &Vec, + layout: &layout::Scalar, + ) -> EvalResult<'tcx> { + let (lo, hi) = layout.valid_range.clone().into_inner(); + let max_hi = u128::max_value() >> (128 - size.bits()); // as big as the size fits + assert!(hi <= max_hi); + if (lo == 0 && hi == max_hi) || (hi + 1 == lo) { + // Nothing to check + return Ok(()); + } + // At least one value is excluded. Get the bits. + let value = try_validation!(value.not_undef(), + scalar_format(value), path, format!("something in the range {:?}", layout.valid_range)); + let bits = match value { + Scalar::Ptr(ptr) => { + if lo == 1 && hi == max_hi { + // only NULL is not allowed. + // We can call `check_align` to check non-NULL-ness, but have to also look + // for function pointers. + let non_null = + self.memory.check_align( + Scalar::Ptr(ptr), Align::from_bytes(1, 1).unwrap() + ).is_ok() || + self.memory.get_fn(ptr).is_ok(); + if !non_null { + // could be NULL + return validation_failure!("a potentially NULL pointer", path); } - } else if hi < ptr_max || lo > 1 { - validation_failure!( - "pointer", - path, - format!("something in the range {:?}", scalar.valid_range) - ) + return Ok(()); } else { - Ok(()) - }; - }, - }; - - // char gets a special treatment, because its number space is not contiguous so `TyLayout` - // has no special checks for chars - match ty.sty { - ty::Char => { - debug_assert_eq!(size.bytes(), 4); - if ::std::char::from_u32(bits as u32).is_none() { + // Conservatively, we reject, because the pointer *could* have this + // value. return validation_failure!( - "character", + "a pointer", path, - "a valid unicode codepoint" + format!( + "something that cannot possibly be outside the (wrapping) range {:?}", + layout.valid_range + ) ); } } - _ => {}, - } - + Scalar::Bits { bits, size: value_size } => { + assert_eq!(value_size as u64, size.bytes()); + bits + } + }; + // Now compare. This is slightly subtle because this is a special "wrap-around" range. use std::ops::RangeInclusive; let in_range = |bound: RangeInclusive| bound.contains(&bits); if lo > hi { - if in_range(0..=hi) || in_range(lo..=u128::max_value()) { + // wrapping around + if in_range(0..=hi) || in_range(lo..=max_hi) { Ok(()) } else { validation_failure!( bits, path, - format!("something in the range {:?} or {:?}", ..=hi, lo..) + format!("something in the range {:?} or {:?}", 0..=hi, lo..=max_hi) ) } } else { - if in_range(scalar.valid_range.clone()) { + if in_range(layout.valid_range.clone()) { Ok(()) } else { validation_failure!( bits, path, - format!("something in the range {:?}", scalar.valid_range) + if hi == max_hi { + format!("something greater or equal to {}", lo) + } else { + format!("something in the range {:?}", layout.valid_range) + } ) } } } - /// This function checks the data at `op`. + /// This function checks the data at `op`. `op` is assumed to cover valid memory if it + /// is an indirect operand. /// It will error if the bits at the destination do not match the ones described by the layout. /// The `path` may be pushed to, but the part that is present when the function /// starts must not be changed! + /// + /// `ref_tracking` can be None to avoid recursive checking below references. + /// This also toggles between "run-time" (no recursion) and "compile-time" (with recursion) + /// validation (e.g., pointer values are fine in integers at runtime). pub fn validate_operand( &self, - dest: OpTy<'tcx>, + dest: OpTy<'tcx, M::PointerTag>, path: &mut Vec, - seen: &mut FxHashSet<(OpTy<'tcx>)>, - todo: &mut Vec<(OpTy<'tcx>, Vec)>, + mut ref_tracking: Option<&mut RefTracking<'tcx, M::PointerTag>>, + const_mode: bool, ) -> EvalResult<'tcx> { - trace!("validate_operand: {:?}, {:#?}", *dest, dest.layout); + trace!("validate_operand: {:?}, {:?}", *dest, dest.layout.ty); - // Find the right variant. We have to handle this as a prelude, not via - // proper recursion with the new inner layout, to be able to later nicely - // print the field names of the enum field that is being accessed. - let (variant, dest) = match dest.layout.variants { + // If this is a multi-variant layout, we have find the right one and proceed with that. + // (No good reasoning to make this recursion, but it is equivalent to that.) + let dest = match dest.layout.variants { layout::Variants::NicheFilling { .. } | layout::Variants::Tagged { .. } => { let variant = match self.read_discriminant(dest) { @@ -237,130 +397,111 @@ ), } }; - let inner_dest = self.operand_downcast(dest, variant)?; // Put the variant projection onto the path, as a field path.push(PathElem::Field(dest.layout.ty .ty_adt_def() .unwrap() .variants[variant].name)); + // Proceed with this variant + let dest = self.operand_downcast(dest, variant)?; trace!("variant layout: {:#?}", dest.layout); - (variant, inner_dest) + dest }, - layout::Variants::Single { index } => { - // Pre-processing for trait objects: Treat them at their real type. - // (We do not do this for slices and strings: For slices it is not needed, - // `mplace_array_fields` does the right thing, and for strings there is no - // real type that would show the actual length.) - let dest = match dest.layout.ty.sty { - ty::Dynamic(..) => { - let dest = dest.to_mem_place(); // immediate trait objects are not a thing - match self.unpack_dyn_trait(dest) { - Ok(res) => res.1.into(), - Err(_) => - return validation_failure!( - "invalid vtable in fat pointer", path - ), - } - } - _ => dest - }; - (index, dest) - } + layout::Variants::Single { .. } => dest, + }; + + // First thing, find the real type: + // If it is a trait object, switch to the actual type that was used to create it. + let dest = match dest.layout.ty.sty { + ty::Dynamic(..) => { + let dest = dest.to_mem_place(); // immediate trait objects are not a thing + self.unpack_dyn_trait(dest)?.1.into() + }, + _ => dest }; - // Remember the length, in case we need to truncate - let path_len = path.len(); + // If this is a scalar, validate the scalar layout. + // Things can be aggregates and have scalar layout at the same time, and that + // is very relevant for `NonNull` and similar structs: We need to validate them + // at their scalar layout *before* descending into their fields. + // FIXME: We could avoid some redundant checks here. For newtypes wrapping + // scalars, we do the same check on every "level" (e.g. first we check + // MyNewtype and then the scalar in there). + match dest.layout.abi { + layout::Abi::Uninhabited => + return validation_failure!("a value of an uninhabited type", path), + layout::Abi::Scalar(ref layout) => { + let value = try_validation!(self.read_scalar(dest), + "uninitialized or unrepresentable data", path); + self.validate_scalar_layout(value, dest.layout.size, &path, layout)?; + } + // FIXME: Should we do something for ScalarPair? Vector? + _ => {} + } - // Validate all fields + // Check primitive types. We do this after checking the scalar layout, + // just to have that done as well. Primitives can have varying layout, + // so we check them separately and before aggregate handling. + // It is CRITICAL that we get this check right, or we might be + // validating the wrong thing! + let primitive = match dest.layout.fields { + // Primitives appear as Union with 0 fields -- except for fat pointers. + layout::FieldPlacement::Union(0) => true, + _ => dest.layout.ty.builtin_deref(true).is_some(), + }; + if primitive { + let value = try_validation!(self.read_value(dest), + "uninitialized or unrepresentable data", path); + return self.validate_primitive_type( + value, + &path, + ref_tracking, + const_mode, + ); + } + + // Validate all fields of compound data structures + let path_len = path.len(); // Remember the length, in case we need to truncate match dest.layout.fields { - // primitives are unions with zero fields - // We still check `layout.fields`, not `layout.abi`, because `layout.abi` - // is `Scalar` for newtypes around scalars, but we want to descend through the - // fields to get a proper `path`. - layout::FieldPlacement::Union(0) => { - match dest.layout.abi { - // nothing to do, whatever the pointer points to, it is never going to be read - layout::Abi::Uninhabited => - return validation_failure!("a value of an uninhabited type", path), - // check that the scalar is a valid pointer or that its bit range matches the - // expectation. - layout::Abi::Scalar(ref scalar_layout) => { - let size = scalar_layout.value.size(self); - let value = match self.read_value(dest) { - Ok(val) => val, - Err(err) => match err.kind { - EvalErrorKind::PointerOutOfBounds { .. } | - EvalErrorKind::ReadUndefBytes(_) => - return validation_failure!( - "uninitialized or out-of-bounds memory", path - ), - _ => - return validation_failure!( - "unrepresentable data", path - ), - } - }; - let scalar = value.to_scalar_or_undef(); - self.validate_scalar(scalar, size, scalar_layout, &path, dest.layout.ty)?; - if scalar_layout.value == Primitive::Pointer { - // ignore integer pointers, we can't reason about the final hardware - if let Scalar::Ptr(ptr) = scalar.not_undef()? { - let alloc_kind = self.tcx.alloc_map.lock().get(ptr.alloc_id); - if let Some(AllocType::Static(did)) = alloc_kind { - // statics from other crates are already checked. - // extern statics cannot be validated as they have no body. - if !did.is_local() || self.tcx.is_foreign_item(did) { - return Ok(()); - } - } - if value.layout.ty.builtin_deref(false).is_some() { - let ptr_op = self.ref_to_mplace(value)?.into(); - // we have not encountered this pointer+layout combination - // before. - if seen.insert(ptr_op) { - trace!("Recursing below ptr {:#?}", *value); - todo.push((ptr_op, path_clone_and_deref(path))); - } - } - } - } - }, - _ => bug!("bad abi for FieldPlacement::Union(0): {:#?}", dest.layout.abi), - } - } - layout::FieldPlacement::Union(_) => { + layout::FieldPlacement::Union(..) => { // We can't check unions, their bits are allowed to be anything. // The fields don't need to correspond to any bit pattern of the union's fields. // See https://github.com/rust-lang/rust/issues/32836#issuecomment-406875389 }, - layout::FieldPlacement::Array { stride, .. } if !dest.layout.is_zst() => { - let dest = dest.to_mem_place(); // non-ZST array/slice/str cannot be immediate + layout::FieldPlacement::Arbitrary { ref offsets, .. } => { + // Go look at all the fields + for i in 0..offsets.len() { + let field = self.operand_field(dest, i as u64)?; + path.push(self.aggregate_field_path_elem(dest.layout, i)); + self.validate_operand( + field, + path, + ref_tracking.as_mut().map(|r| &mut **r), + const_mode, + )?; + path.truncate(path_len); + } + } + layout::FieldPlacement::Array { stride, .. } => { + let dest = if dest.layout.is_zst() { + // it's a ZST, the memory content cannot matter + MPlaceTy::dangling(dest.layout, self) + } else { + // non-ZST array/slice/str cannot be immediate + dest.to_mem_place() + }; match dest.layout.ty.sty { // Special handling for strings to verify UTF-8 ty::Str => { - match self.read_str(dest) { - Ok(_) => {}, - Err(err) => match err.kind { - EvalErrorKind::PointerOutOfBounds { .. } | - EvalErrorKind::ReadUndefBytes(_) => - // The error here looks slightly different than it does - // for slices, because we do not report the index into the - // str at which we are OOB. - return validation_failure!( - "uninitialized or out-of-bounds memory", path - ), - _ => - return validation_failure!( - "non-UTF-8 data in str", path - ), - } - } + try_validation!(self.read_str(dest), + "uninitialized or non-UTF-8 data in str", path); } // Special handling for arrays/slices of builtin integer types ty::Array(tys, ..) | ty::Slice(tys) if { - // This optimization applies only for integer types + // This optimization applies only for integer and floating point types + // (i.e., types that can hold arbitrary bytes). match tys.sty { - ty::Int(..) | ty::Uint(..) => true, + ty::Int(..) | ty::Uint(..) | ty::Float(..) => true, _ => false, } } => { @@ -372,9 +513,22 @@ // This is the size in bytes of the whole array. let size = Size::from_bytes(ty_size * len); - match self.memory.read_bytes(dest.ptr, size) { + // NOTE: Keep this in sync with the handling of integer and float + // types above, in `validate_primitive_type`. + // In run-time mode, we accept pointers in here. This is actually more + // permissive than a per-element check would be, e.g. we accept + // an &[u8] that contains a pointer even though bytewise checking would + // reject it. However, that's good: We don't inherently want + // to reject those pointers, we just do not have the machinery to + // talk about parts of a pointer. + // We also accept undef, for consistency with the type-based checks. + match self.memory.check_bytes( + dest.ptr, + size, + /*allow_ptr_and_undef*/!const_mode, + ) { // In the happy case, we needn't check anything else. - Ok(_) => {}, + Ok(()) => {}, // Some error happened, try to provide a more detailed description. Err(err) => { // For some errors we might be able to provide extra information @@ -390,18 +544,9 @@ "undefined bytes", path ) }, - EvalErrorKind::PointerOutOfBounds { allocation_size, .. } => { - // If the array access is out-of-bounds, the first - // undefined access is the after the end of the array. - let i = (allocation_size.bytes() * ty_size) as usize; - path.push(PathElem::ArrayElem(i)); - }, - _ => (), + // Other errors shouldn't be possible + _ => return Err(err), } - - return validation_failure!( - "uninitialized or out-of-bounds memory", path - ) } } }, @@ -411,83 +556,32 @@ for (i, field) in self.mplace_array_fields(dest)?.enumerate() { let field = field?; path.push(PathElem::ArrayElem(i)); - self.validate_operand(field.into(), path, seen, todo)?; + self.validate_operand( + field.into(), + path, + ref_tracking.as_mut().map(|r| &mut **r), + const_mode, + )?; path.truncate(path_len); } } } }, - layout::FieldPlacement::Array { .. } => { - // An empty array. Nothing to do. - } - layout::FieldPlacement::Arbitrary { ref offsets, .. } => { - // Fat pointers are treated like pointers, not aggregates. - if dest.layout.ty.builtin_deref(true).is_some() { - // This is a fat pointer. - let ptr = match self.read_value(dest.into()) - .and_then(|val| self.ref_to_mplace(val)) - { - Ok(ptr) => ptr, - Err(_) => - return validation_failure!( - "undefined location or metadata in fat pointer", path - ), - }; - // check metadata early, for better diagnostics - match self.tcx.struct_tail(ptr.layout.ty).sty { - ty::Dynamic(..) => { - match ptr.extra.unwrap().to_ptr() { - Ok(_) => {}, - Err(_) => - return validation_failure!( - "non-pointer vtable in fat pointer", path - ), - } - // FIXME: More checks for the vtable. - } - ty::Slice(..) | ty::Str => { - match ptr.extra.unwrap().to_usize(self) { - Ok(_) => {}, - Err(_) => - return validation_failure!( - "non-integer slice length in fat pointer", path - ), - } - } - _ => - bug!("Unexpected unsized type tail: {:?}", - self.tcx.struct_tail(ptr.layout.ty) - ), - } - // for safe ptrs, recursively check it - if !dest.layout.ty.is_unsafe_ptr() { - let ptr = ptr.into(); - if seen.insert(ptr) { - trace!("Recursing below fat ptr {:?}", ptr); - todo.push((ptr, path_clone_and_deref(path))); - } - } - } else { - // Not a pointer, perform regular aggregate handling below - for i in 0..offsets.len() { - let field = self.operand_field(dest, i as u64)?; - path.push(self.aggregate_field_path_elem(dest.layout.ty, variant, i)); - self.validate_operand(field, path, seen, todo)?; - path.truncate(path_len); - } - } - } } Ok(()) } - fn aggregate_field_path_elem(&self, ty: Ty<'tcx>, variant: usize, field: usize) -> PathElem { - match ty.sty { + fn aggregate_field_path_elem(&self, layout: TyLayout<'tcx>, field: usize) -> PathElem { + match layout.ty.sty { // generators and closures. ty::Closure(def_id, _) | ty::Generator(def_id, _, _) => { - let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap(); - let freevar = self.tcx.with_freevars(node_id, |fv| fv[field]); - PathElem::ClosureVar(self.tcx.hir.name(freevar.var_id())) + if let Some(upvar) = self.tcx.optimized_mir(def_id).upvar_decls.get(field) { + PathElem::ClosureVar(upvar.debug_name) + } else { + // Sometimes the index is beyond the number of freevars (seen + // for a generator). + PathElem::ClosureVar(Symbol::intern(&field.to_string())) + } } // tuples @@ -495,7 +589,10 @@ // enums ty::Adt(def, ..) if def.is_enum() => { - let variant = &def.variants[variant]; + let variant = match layout.variants { + layout::Variants::Single { index } => &def.variants[index], + _ => bug!("aggregate_field_path_elem: got enum but not in a specific variant"), + }; PathElem::Field(variant.fields[field].ident.name) } @@ -503,7 +600,7 @@ ty::Adt(def, _) => PathElem::Field(def.non_enum_variant().fields[field].ident.name), // nothing else has an aggregate layout - _ => bug!("aggregate_field_path_elem: got non-aggregate type {:?}", ty), + _ => bug!("aggregate_field_path_elem: got non-aggregate type {:?}", layout.ty), } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,10 +14,9 @@ */ -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(in_band_lifetimes)] -#![feature(impl_header_lifetime_elision)] +#![cfg_attr(stage0, feature(impl_header_lifetime_elision))] #![feature(slice_patterns)] #![feature(slice_sort_by_cached_key)] #![feature(box_patterns)] @@ -26,12 +25,10 @@ #![feature(core_intrinsics)] #![feature(const_fn)] #![feature(decl_macro)] -#![cfg_attr(stage0, feature(macro_vis_matcher))] #![feature(exhaustive_patterns)] #![feature(range_contains)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_attrs)] -#![cfg_attr(stage0, feature(attr_literals))] #![feature(never_type)] #![feature(specialization)] #![feature(try_trait)] @@ -82,6 +79,7 @@ mod build; mod dataflow; mod hair; +mod lints; mod shim; pub mod transform; pub mod util; @@ -96,7 +94,7 @@ borrow_check::provide(providers); shim::provide(providers); transform::provide(providers); - providers.const_eval = interpret::const_eval_provider; + providers.const_eval = const_eval::const_eval_provider; providers.check_match = hair::pattern::check_match; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/lints.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/lints.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/lints.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/lints.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,156 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use rustc_data_structures::bit_set::BitSet; +use rustc::hir::def_id::DefId; +use rustc::hir::intravisit::FnKind; +use rustc::hir::map::blocks::FnLikeNode; +use rustc::lint::builtin::UNCONDITIONAL_RECURSION; +use rustc::mir::{self, Mir, TerminatorKind}; +use rustc::ty::{AssociatedItem, AssociatedItemContainer, Instance, TyCtxt, TyKind}; +use rustc::ty::subst::Substs; + +pub fn check(tcx: TyCtxt<'a, 'tcx, 'tcx>, + mir: &Mir<'tcx>, + def_id: DefId) { + let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); + + if let Some(fn_like_node) = FnLikeNode::from_node(tcx.hir.get(node_id)) { + check_fn_for_unconditional_recursion(tcx, fn_like_node.kind(), mir, def_id); + } +} + +fn check_fn_for_unconditional_recursion(tcx: TyCtxt<'a, 'tcx, 'tcx>, + fn_kind: FnKind, + mir: &Mir<'tcx>, + def_id: DefId) { + if let FnKind::Closure(_) = fn_kind { + // closures can't recur, so they don't matter. + return; + } + + //FIXME(#54444) rewrite this lint to use the dataflow framework + + // Walk through this function (say `f`) looking to see if + // every possible path references itself, i.e. the function is + // called recursively unconditionally. This is done by trying + // to find a path from the entry node to the exit node that + // *doesn't* call `f` by traversing from the entry while + // pretending that calls of `f` are sinks (i.e. ignoring any + // exit edges from them). + // + // NB. this has an edge case with non-returning statements, + // like `loop {}` or `panic!()`: control flow never reaches + // the exit node through these, so one can have a function + // that never actually calls itself but is still picked up by + // this lint: + // + // fn f(cond: bool) { + // if !cond { panic!() } // could come from `assert!(cond)` + // f(false) + // } + // + // In general, functions of that form may be able to call + // itself a finite number of times and then diverge. The lint + // considers this to be an error for two reasons, (a) it is + // easier to implement, and (b) it seems rare to actually want + // to have behaviour like the above, rather than + // e.g. accidentally recursing after an assert. + + let basic_blocks = mir.basic_blocks(); + let mut reachable_without_self_call_queue = vec![mir::START_BLOCK]; + let mut reached_exit_without_self_call = false; + let mut self_call_locations = vec![]; + let mut visited = BitSet::new_empty(basic_blocks.len()); + + let param_env = tcx.param_env(def_id); + let trait_substs_count = + match tcx.opt_associated_item(def_id) { + Some(AssociatedItem { + container: AssociatedItemContainer::TraitContainer(trait_def_id), + .. + }) => tcx.generics_of(trait_def_id).count(), + _ => 0 + }; + let caller_substs = &Substs::identity_for_item(tcx, def_id)[..trait_substs_count]; + + while let Some(bb) = reachable_without_self_call_queue.pop() { + if visited.contains(bb) { + //already done + continue; + } + + visited.insert(bb); + + let block = &basic_blocks[bb]; + + if let Some(ref terminator) = block.terminator { + match terminator.kind { + TerminatorKind::Call { ref func, .. } => { + let func_ty = func.ty(mir, tcx); + + if let TyKind::FnDef(fn_def_id, substs) = func_ty.sty { + let (call_fn_id, call_substs) = + if let Some(instance) = Instance::resolve(tcx, + param_env, + fn_def_id, + substs) { + (instance.def_id(), instance.substs) + } else { + (fn_def_id, substs) + }; + + let is_self_call = + call_fn_id == def_id && + &call_substs[..caller_substs.len()] == caller_substs; + + if is_self_call { + self_call_locations.push(terminator.source_info); + + //this is a self call so we shouldn't explore + //further down this path + continue; + } + } + }, + TerminatorKind::Abort | TerminatorKind::Return => { + //found a path! + reached_exit_without_self_call = true; + break; + } + _ => {} + } + + for successor in terminator.successors() { + reachable_without_self_call_queue.push(*successor); + } + } + } + + // Check the number of self calls because a function that + // doesn't return (e.g. calls a `-> !` function or `loop { /* + // no break */ }`) shouldn't be linted unless it actually + // recurs. + if !reached_exit_without_self_call && !self_call_locations.is_empty() { + let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); + let sp = tcx.sess.source_map().def_span(tcx.hir.span(node_id)); + let mut db = tcx.struct_span_lint_node(UNCONDITIONAL_RECURSION, + node_id, + sp, + "function cannot return without recursing"); + db.span_label(sp, "cannot return without recursing"); + // offer some help to the programmer. + for location in &self_call_locations { + db.span_label(location.span, "recursive call site"); + } + db.help("a `loop` may express intention better if this is on purpose"); + db.emit(); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/monomorphize/collector.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/monomorphize/collector.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/monomorphize/collector.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/monomorphize/collector.rs 2018-12-04 23:41:40.000000000 +0000 @@ -193,7 +193,7 @@ use rustc::hir::Node; use rustc::hir::def_id::DefId; -use rustc::mir::interpret::{AllocId, ConstValue, ScalarMaybeUndef}; +use rustc::mir::interpret::{AllocId, ConstValue}; use rustc::middle::lang_items::{ExchangeMallocFnLangItem, StartFnLangItem}; use rustc::ty::subst::Substs; use rustc::ty::{self, TypeFoldable, Ty, TyCtxt, GenericParamDefKind}; @@ -210,7 +210,7 @@ use monomorphize::item::{MonoItemExt, DefPathBasedNames, InstantiationMode}; -use rustc_data_structures::bitvec::BitVector; +use rustc_data_structures::bit_set::GrowableBitSet; use rustc_data_structures::sync::{MTRef, MTLock, ParallelIterator, par_iter}; #[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)] @@ -231,16 +231,16 @@ // Contains one bit per mono item in the `targets` field. That bit // is true if that mono item needs to be inlined into every CGU. - inlines: BitVector, + inlines: GrowableBitSet, } impl<'tcx> InliningMap<'tcx> { fn new() -> InliningMap<'tcx> { InliningMap { - index: FxHashMap(), + index: FxHashMap::default(), targets: Vec::new(), - inlines: BitVector::with_capacity(1024), + inlines: GrowableBitSet::with_capacity(1024), } } @@ -256,7 +256,7 @@ let new_items_count_total = new_items_count + self.targets.len(); self.targets.reserve(new_items_count); - self.inlines.grow(new_items_count_total); + self.inlines.ensure(new_items_count_total); for (i, (target, inline)) in new_targets.enumerate() { self.targets.push(target); @@ -305,7 +305,7 @@ debug!("Building mono item graph, beginning at roots"); - let mut visited = MTLock::new(FxHashSet()); + let mut visited = MTLock::new(FxHashSet::default()); let mut inlining_map = MTLock::new(InliningMap::new()); { @@ -907,22 +907,20 @@ !impl_ty.needs_subst() && !impl_ty.has_escaping_regions()); if let ty::Dynamic(ref trait_ty, ..) = trait_ty.sty { - if let Some(principal) = trait_ty.principal() { - let poly_trait_ref = principal.with_self_ty(tcx, impl_ty); - assert!(!poly_trait_ref.has_escaping_regions()); - - // Walk all methods of the trait, including those of its supertraits - let methods = tcx.vtable_methods(poly_trait_ref); - let methods = methods.iter().cloned().filter_map(|method| method) - .map(|(def_id, substs)| ty::Instance::resolve( - tcx, - ty::ParamEnv::reveal_all(), - def_id, - substs).unwrap()) - .filter(|&instance| should_monomorphize_locally(tcx, &instance)) - .map(|instance| create_fn_mono_item(instance)); - output.extend(methods); - } + let poly_trait_ref = trait_ty.principal().with_self_ty(tcx, impl_ty); + assert!(!poly_trait_ref.has_escaping_regions()); + + // Walk all methods of the trait, including those of its supertraits + let methods = tcx.vtable_methods(poly_trait_ref); + let methods = methods.iter().cloned().filter_map(|method| method) + .map(|(def_id, substs)| ty::Instance::resolve( + tcx, + ty::ParamEnv::reveal_all(), + def_id, + substs).unwrap()) + .filter(|&instance| should_monomorphize_locally(tcx, &instance)) + .map(|instance| create_fn_mono_item(instance)); + output.extend(methods); // Also add the destructor visit_drop_use(tcx, impl_ty, false, output); } @@ -1163,7 +1161,7 @@ } Some(AllocType::Memory(alloc)) => { trace!("collecting {:?} with {:#?}", alloc_id, alloc); - for &inner in alloc.relocations.values() { + for &((), inner) in alloc.relocations.values() { collect_miri(tcx, inner, output); } }, @@ -1263,16 +1261,16 @@ }; match val { ConstValue::Unevaluated(..) => bug!("const eval yielded unevaluated const"), - ConstValue::ScalarPair(Scalar::Ptr(a), ScalarMaybeUndef::Scalar(Scalar::Ptr(b))) => { + ConstValue::ScalarPair(Scalar::Ptr(a), Scalar::Ptr(b)) => { collect_miri(tcx, a.alloc_id, output); collect_miri(tcx, b.alloc_id, output); } - ConstValue::ScalarPair(_, ScalarMaybeUndef::Scalar(Scalar::Ptr(ptr))) | + ConstValue::ScalarPair(_, Scalar::Ptr(ptr)) | ConstValue::ScalarPair(Scalar::Ptr(ptr), _) | ConstValue::Scalar(Scalar::Ptr(ptr)) => collect_miri(tcx, ptr.alloc_id, output), ConstValue::ByRef(_id, alloc, _offset) => { - for &id in alloc.relocations.values() { + for &((), id) in alloc.relocations.values() { collect_miri(tcx, id, output); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/monomorphize/item.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/monomorphize/item.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/monomorphize/item.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/monomorphize/item.rs 2018-12-04 23:41:40.000000000 +0000 @@ -320,12 +320,13 @@ output.push(']'); }, ty::Dynamic(ref trait_data, ..) => { - if let Some(principal) = trait_data.principal() { - self.push_def_path(principal.def_id(), output); - self.push_type_params(principal.skip_binder().substs, - trait_data.projection_bounds(), - output); - } + let principal = trait_data.principal(); + self.push_def_path(principal.def_id(), output); + self.push_type_params( + principal.skip_binder().substs, + trait_data.projection_bounds(), + output, + ); }, ty::Foreign(did) => self.push_def_path(did, output), ty::FnDef(..) | @@ -382,6 +383,7 @@ } ty::Error | ty::Infer(_) | + ty::UnnormalizedProjection(..) | ty::Projection(..) | ty::Param(_) | ty::GeneratorWitness(_) | diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/monomorphize/partitioning.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/monomorphize/partitioning.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/monomorphize/partitioning.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/monomorphize/partitioning.rs 2018-12-04 23:41:40.000000000 +0000 @@ -301,10 +301,10 @@ -> PreInliningPartitioning<'tcx> where I: Iterator> { - let mut roots = FxHashSet(); - let mut codegen_units = FxHashMap(); + let mut roots = FxHashSet::default(); + let mut codegen_units = FxHashMap::default(); let is_incremental_build = tcx.sess.opts.incremental.is_some(); - let mut internalization_candidates = FxHashSet(); + let mut internalization_candidates = FxHashSet::default(); // Determine if monomorphizations instantiated in this crate will be made // available to downstream crates. This depends on whether we are in @@ -314,7 +314,7 @@ tcx.local_crate_exports_generics(); let cgu_name_builder = &mut CodegenUnitNameBuilder::new(tcx); - let cgu_name_cache = &mut FxHashMap(); + let cgu_name_cache = &mut FxHashMap::default(); for mono_item in mono_items { match mono_item.instantiation_mode(tcx) { @@ -602,7 +602,7 @@ inlining_map: &InliningMap<'tcx>) -> PostInliningPartitioning<'tcx> { let mut new_partitioning = Vec::new(); - let mut mono_item_placements = FxHashMap(); + let mut mono_item_placements = FxHashMap::default(); let PreInliningPartitioning { codegen_units: initial_cgus, @@ -614,7 +614,7 @@ for old_codegen_unit in initial_cgus { // Collect all items that need to be available in this codegen unit - let mut reachable = FxHashSet(); + let mut reachable = FxHashSet::default(); for root in old_codegen_unit.items().keys() { follow_inlining(*root, inlining_map, &mut reachable); } @@ -703,7 +703,7 @@ // Build a map from every monomorphization to all the monomorphizations that // reference it. - let mut accessor_map: FxHashMap, Vec>> = FxHashMap(); + let mut accessor_map: FxHashMap, Vec>> = Default::default(); inlining_map.iter_accesses(|accessor, accessees| { for accessee in accessees { accessor_map.entry(*accessee) diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/shim.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/shim.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/shim.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/shim.rs 2018-12-04 23:41:40.000000000 +0000 @@ -140,13 +140,15 @@ fn temp_decl(mutability: Mutability, ty: Ty, span: Span) -> LocalDecl { let source_info = SourceInfo { scope: OUTERMOST_SOURCE_SCOPE, span }; LocalDecl { - mutability, ty, - user_ty: None, + mutability, + ty, + user_ty: UserTypeProjections::none(), name: None, source_info, visibility_scope: source_info.scope, internal: false, is_user_variable: None, + is_block_tail: None, } } @@ -407,7 +409,7 @@ let ret_statement = self.make_statement( StatementKind::Assign( Place::Local(RETURN_PLACE), - Rvalue::Use(Operand::Copy(rcvr)) + box Rvalue::Use(Operand::Copy(rcvr)) ) ); self.block(vec![ret_statement], TerminatorKind::Return, false); @@ -458,7 +460,7 @@ let statement = self.make_statement( StatementKind::Assign( ref_loc.clone(), - Rvalue::Ref(tcx.types.re_erased, BorrowKind::Shared, src) + box Rvalue::Ref(tcx.types.re_erased, BorrowKind::Shared, src) ) ); @@ -468,6 +470,7 @@ args: vec![Operand::Move(ref_loc)], destination: Some((dest, next)), cleanup: Some(cleanup), + from_hir_call: true, }, false); } @@ -485,7 +488,7 @@ let compute_cond = self.make_statement( StatementKind::Assign( cond.clone(), - Rvalue::BinaryOp(BinOp::Ne, Operand::Copy(end), Operand::Copy(beg)) + box Rvalue::BinaryOp(BinOp::Ne, Operand::Copy(end), Operand::Copy(beg)) ) ); @@ -521,13 +524,13 @@ self.make_statement( StatementKind::Assign( Place::Local(beg), - Rvalue::Use(Operand::Constant(self.make_usize(0))) + box Rvalue::Use(Operand::Constant(self.make_usize(0))) ) ), self.make_statement( StatementKind::Assign( end.clone(), - Rvalue::Use(Operand::Constant(self.make_usize(len))) + box Rvalue::Use(Operand::Constant(self.make_usize(len))) ) ) ]; @@ -544,7 +547,7 @@ // `dest[i] = Clone::clone(src[beg])`; // Goto #3 if ok, #5 if unwinding happens. let dest_field = dest.clone().index(beg); - let src_field = src.clone().index(beg); + let src_field = src.index(beg); self.make_clone_call(dest_field, src_field, ty, BasicBlock::new(3), BasicBlock::new(5)); @@ -555,7 +558,7 @@ self.make_statement( StatementKind::Assign( Place::Local(beg), - Rvalue::BinaryOp( + box Rvalue::BinaryOp( BinOp::Add, Operand::Copy(Place::Local(beg)), Operand::Constant(self.make_usize(1)) @@ -578,7 +581,7 @@ let init = self.make_statement( StatementKind::Assign( Place::Local(beg), - Rvalue::Use(Operand::Constant(self.make_usize(0))) + box Rvalue::Use(Operand::Constant(self.make_usize(0))) ) ); self.block(vec![init], TerminatorKind::Goto { target: BasicBlock::new(6) }, true); @@ -605,7 +608,7 @@ let statement = self.make_statement( StatementKind::Assign( Place::Local(beg), - Rvalue::BinaryOp( + box Rvalue::BinaryOp( BinOp::Add, Operand::Copy(Place::Local(beg)), Operand::Constant(self.make_usize(1)) @@ -715,7 +718,7 @@ source_info, kind: StatementKind::Assign( Place::Local(ref_rcvr), - Rvalue::Ref(tcx.types.re_erased, borrow_kind, rcvr_l) + box Rvalue::Ref(tcx.types.re_erased, borrow_kind, rcvr_l) ) }); Operand::Move(Place::Local(ref_rcvr)) @@ -766,7 +769,8 @@ Some(BasicBlock::new(3)) } else { None - } + }, + from_hir_call: true, }, false); if let Adjustment::RefMut = rcvr_adjustment { @@ -851,7 +855,7 @@ source_info, kind: StatementKind::Assign( Place::Local(RETURN_PLACE), - Rvalue::Aggregate( + box Rvalue::Aggregate( box AggregateKind::Adt(adt_def, variant_no, substs, None, None), (1..sig.inputs().len()+1).map(|i| { Operand::Move(Place::Local(Local::new(i))) diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/add_validation.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/add_validation.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/add_validation.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/add_validation.rs 2018-12-04 23:41:40.000000000 +0000 @@ -320,12 +320,12 @@ for i in (0..block_data.statements.len()).rev() { match block_data.statements[i].kind { // When the borrow of this ref expires, we need to recover validation. - StatementKind::Assign(_, Rvalue::Ref(_, _, _)) => { + StatementKind::Assign(_, box Rvalue::Ref(_, _, _)) => { // Due to a lack of NLL; we can't capture anything directly here. // Instead, we have to re-match and clone there. let (dest_place, re, src_place) = match block_data.statements[i].kind { StatementKind::Assign(ref dest_place, - Rvalue::Ref(re, _, ref src_place)) => { + box Rvalue::Ref(re, _, ref src_place)) => { (dest_place.clone(), re, src_place.clone()) }, _ => bug!("We already matched this."), @@ -354,17 +354,17 @@ block_data.statements.insert(i, release_stmt); } // Casts can change what validation does (e.g. unsizing) - StatementKind::Assign(_, Rvalue::Cast(kind, Operand::Copy(_), _)) | - StatementKind::Assign(_, Rvalue::Cast(kind, Operand::Move(_), _)) + StatementKind::Assign(_, box Rvalue::Cast(kind, Operand::Copy(_), _)) | + StatementKind::Assign(_, box Rvalue::Cast(kind, Operand::Move(_), _)) if kind != CastKind::Misc => { // Due to a lack of NLL; we can't capture anything directly here. // Instead, we have to re-match and clone there. let (dest_place, src_place) = match block_data.statements[i].kind { StatementKind::Assign(ref dest_place, - Rvalue::Cast(_, Operand::Copy(ref src_place), _)) | + box Rvalue::Cast(_, Operand::Copy(ref src_place), _)) | StatementKind::Assign(ref dest_place, - Rvalue::Cast(_, Operand::Move(ref src_place), _)) => + box Rvalue::Cast(_, Operand::Move(ref src_place), _)) => { (dest_place.clone(), src_place.clone()) }, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/check_unsafety.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/check_unsafety.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/check_unsafety.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/check_unsafety.rs 2018-12-04 23:41:40.000000000 +0000 @@ -19,7 +19,7 @@ use rustc::hir::def_id::DefId; use rustc::lint::builtin::{SAFE_EXTERN_STATICS, SAFE_PACKED_BORROWS, UNUSED_UNSAFE}; use rustc::mir::*; -use rustc::mir::visit::{PlaceContext, Visitor}; +use rustc::mir::visit::{PlaceContext, Visitor, MutatingUseContext}; use syntax::ast; use syntax::symbol::Symbol; @@ -57,7 +57,7 @@ }, tcx, param_env, - used_unsafe: FxHashSet(), + used_unsafe: Default::default(), inherited_blocks: vec![], } } @@ -108,7 +108,7 @@ self.source_info = statement.source_info; match statement.kind { StatementKind::Assign(..) | - StatementKind::ReadForMatch(..) | + StatementKind::FakeRead(..) | StatementKind::SetDiscriminant { .. } | StatementKind::StorageLive(..) | StatementKind::StorageDead(..) | @@ -152,7 +152,7 @@ place: &Place<'tcx>, context: PlaceContext<'tcx>, location: Location) { - if let PlaceContext::Borrow { .. } = context { + if context.is_borrow() { if util::is_disaligned(self.tcx, self.mir, self.param_env, place) { let source_info = self.source_info; let lint_root = @@ -193,9 +193,11 @@ } ty::Adt(adt, _) => { if adt.is_union() { - if context == PlaceContext::Store || - context == PlaceContext::AsmOutput || - context == PlaceContext::Drop + if context == PlaceContext::MutatingUse(MutatingUseContext::Store) || + context == PlaceContext::MutatingUse(MutatingUseContext::Drop) || + context == PlaceContext::MutatingUse( + MutatingUseContext::AsmOutput + ) { let elem_ty = match elem { &ProjectionElem::Field(_, ty) => ty, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/cleanup_post_borrowck.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/cleanup_post_borrowck.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/cleanup_post_borrowck.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/cleanup_post_borrowck.rs 2018-12-04 23:41:40.000000000 +0000 @@ -33,13 +33,15 @@ use rustc_data_structures::fx::FxHashSet; use rustc::middle::region; -use rustc::mir::{BasicBlock, Location, Mir, Rvalue, Statement, StatementKind}; +use rustc::mir::{BasicBlock, FakeReadCause, Local, Location, Mir, Place}; +use rustc::mir::{Rvalue, Statement, StatementKind}; use rustc::mir::visit::{MutVisitor, Visitor, TyContext}; use rustc::ty::{Ty, RegionKind, TyCtxt}; use transform::{MirPass, MirSource}; pub struct CleanEndRegions; +#[derive(Default)] struct GatherBorrowedRegions { seen_regions: FxHashSet, } @@ -55,9 +57,7 @@ mir: &mut Mir<'tcx>) { if !tcx.emit_end_regions() { return; } - let mut gather = GatherBorrowedRegions { - seen_regions: FxHashSet() - }; + let mut gather = GatherBorrowedRegions::default(); gather.visit_mir(mir); let mut delete = DeleteTrivialEndRegions { seen_regions: &mut gather.seen_regions }; @@ -134,4 +134,62 @@ } self.super_statement(block, statement, location); } +} + +pub struct CleanFakeReadsAndBorrows; + +#[derive(Default)] +pub struct DeleteAndRecordFakeReads { + fake_borrow_temporaries: FxHashSet, +} + +pub struct DeleteFakeBorrows { + fake_borrow_temporaries: FxHashSet, +} + +// Removes any FakeReads from the MIR +impl MirPass for CleanFakeReadsAndBorrows { + fn run_pass<'a, 'tcx>(&self, + _tcx: TyCtxt<'a, 'tcx, 'tcx>, + _source: MirSource, + mir: &mut Mir<'tcx>) { + let mut delete_reads = DeleteAndRecordFakeReads::default(); + delete_reads.visit_mir(mir); + let mut delete_borrows = DeleteFakeBorrows { + fake_borrow_temporaries: delete_reads.fake_borrow_temporaries, + }; + delete_borrows.visit_mir(mir); + } +} + +impl<'tcx> MutVisitor<'tcx> for DeleteAndRecordFakeReads { + fn visit_statement(&mut self, + block: BasicBlock, + statement: &mut Statement<'tcx>, + location: Location) { + if let StatementKind::FakeRead(cause, ref place) = statement.kind { + if let FakeReadCause::ForMatchGuard = cause { + match *place { + Place::Local(local) => self.fake_borrow_temporaries.insert(local), + _ => bug!("Fake match guard read of non-local: {:?}", place), + }; + } + statement.make_nop(); + } + self.super_statement(block, statement, location); + } +} + +impl<'tcx> MutVisitor<'tcx> for DeleteFakeBorrows { + fn visit_statement(&mut self, + block: BasicBlock, + statement: &mut Statement<'tcx>, + location: Location) { + if let StatementKind::Assign(Place::Local(local), _) = statement.kind { + if self.fake_borrow_temporaries.contains(&local) { + statement.make_nop(); + } + } + self.super_statement(block, statement, location); + } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/const_prop.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/const_prop.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/const_prop.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/const_prop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,13 +16,13 @@ use rustc::mir::{Constant, Location, Place, Mir, Operand, Rvalue, Local}; use rustc::mir::{NullOp, UnOp, StatementKind, Statement, BasicBlock, LocalKind}; use rustc::mir::{TerminatorKind, ClearCrossCrate, SourceInfo, BinOp, ProjectionElem}; -use rustc::mir::visit::{Visitor, PlaceContext}; +use rustc::mir::visit::{Visitor, PlaceContext, MutatingUseContext, NonMutatingUseContext}; use rustc::mir::interpret::{ - ConstEvalErr, EvalErrorKind, ScalarMaybeUndef, Scalar, GlobalId, EvalResult + ConstEvalErr, EvalErrorKind, Scalar, GlobalId, EvalResult }; use rustc::ty::{TyCtxt, self, Instance}; -use interpret::{EvalContext, CompileTimeEvaluator, eval_promoted, mk_borrowck_eval_cx}; -use interpret::{self, Value, OpTy, MemoryKind}; +use interpret::{self, EvalContext, Value, OpTy, MemoryKind, ScalarMaybeUndef}; +use const_eval::{CompileTimeInterpreter, eval_promoted, mk_borrowck_eval_cx}; use transform::{MirPass, MirSource}; use syntax::source_map::{Span, DUMMY_SP}; use rustc::ty::subst::Substs; @@ -68,9 +68,9 @@ type Const<'tcx> = (OpTy<'tcx>, Span); /// Finds optimization opportunities on the MIR. -struct ConstPropagator<'b, 'a, 'tcx:'a+'b> { - ecx: EvalContext<'a, 'b, 'tcx, CompileTimeEvaluator>, - mir: &'b Mir<'tcx>, +struct ConstPropagator<'a, 'mir, 'tcx:'a+'mir> { + ecx: EvalContext<'a, 'mir, 'tcx, CompileTimeInterpreter<'a, 'mir, 'tcx>>, + mir: &'mir Mir<'tcx>, tcx: TyCtxt<'a, 'tcx, 'tcx>, source: MirSource, places: IndexVec>>, @@ -101,12 +101,12 @@ } } -impl<'b, 'a, 'tcx:'b> ConstPropagator<'b, 'a, 'tcx> { +impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> { fn new( - mir: &'b Mir<'tcx>, + mir: &'mir Mir<'tcx>, tcx: TyCtxt<'a, 'tcx, 'tcx>, source: MirSource, - ) -> ConstPropagator<'b, 'a, 'tcx> { + ) -> ConstPropagator<'a, 'mir, 'tcx> { let param_env = tcx.param_env(source.def_id); let substs = Substs::identity_for_item(tcx, source.def_id); let instance = Instance::new(source.def_id, substs); @@ -154,6 +154,7 @@ // FIXME: figure out the rules and start linting | FunctionAbiMismatch(..) | FunctionArgMismatch(..) + | FunctionRetMismatch(..) | FunctionArgCountMismatch // fine at runtime, might be a register address or sth | ReadBytesAsPointer @@ -310,7 +311,7 @@ // cannot use `const_eval` here, because that would require having the MIR // for the current function available, but we're producing said MIR right now let res = self.use_ecx(source_info, |this| { - eval_promoted(&mut this.ecx, cid, this.mir, this.param_env) + eval_promoted(this.tcx, cid, this.mir, this.param_env) })?; trace!("evaluated promoted {:?} to {:?}", promoted, res); Some((res, source_info.span)) @@ -528,17 +529,18 @@ // Constants must have at most one write // FIXME(oli-obk): we could be more powerful here, if the multiple writes // only occur in independent execution paths - Store => if self.found_assignment[local] { + MutatingUse(MutatingUseContext::Store) => if self.found_assignment[local] { self.can_const_prop[local] = false; } else { self.found_assignment[local] = true }, // Reading constants is allowed an arbitrary number of times - Copy | Move | - StorageDead | StorageLive | - Validate | - Projection(_) | - Inspect => {}, + NonMutatingUse(NonMutatingUseContext::Copy) | + NonMutatingUse(NonMutatingUseContext::Move) | + NonMutatingUse(NonMutatingUseContext::Inspect) | + NonMutatingUse(NonMutatingUseContext::Projection) | + MutatingUse(MutatingUseContext::Projection) | + NonUse(_) => {}, _ => self.can_const_prop[local] = false, } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/copy_prop.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/copy_prop.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/copy_prop.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/copy_prop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -104,7 +104,7 @@ // That use of the source must be an assignment. match statement.kind { - StatementKind::Assign(Place::Local(local), Rvalue::Use(ref operand)) if + StatementKind::Assign(Place::Local(local), box Rvalue::Use(ref operand)) if local == dest_local => { let maybe_action = match *operand { Operand::Copy(ref src_place) | @@ -155,11 +155,11 @@ match stmt.kind { StatementKind::Assign( Place::Local(local), - Rvalue::Use(Operand::Copy(Place::Local(src_local))), + box Rvalue::Use(Operand::Copy(Place::Local(src_local))), ) | StatementKind::Assign( Place::Local(local), - Rvalue::Use(Operand::Move(Place::Local(src_local))), + box Rvalue::Use(Operand::Move(Place::Local(src_local))), ) if local == dest_local && dest_local == src_local => {} _ => { continue; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/deaggregator.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/deaggregator.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/deaggregator.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/deaggregator.rs 2018-12-04 23:41:40.000000000 +0000 @@ -26,7 +26,7 @@ bb.expand_statements(|stmt| { // FIXME(eddyb) don't match twice on `stmt.kind` (post-NLL). if let StatementKind::Assign(_, ref rhs) = stmt.kind { - if let Rvalue::Aggregate(ref kind, _) = *rhs { + if let Rvalue::Aggregate(ref kind, _) = **rhs { // FIXME(#48193) Deaggregate arrays when it's cheaper to do so. if let AggregateKind::Array(_) = **kind { return None; @@ -41,8 +41,12 @@ let stmt = stmt.replace_nop(); let source_info = stmt.source_info; let (mut lhs, kind, operands) = match stmt.kind { - StatementKind::Assign(lhs, Rvalue::Aggregate(kind, operands)) - => (lhs, kind, operands), + StatementKind::Assign(lhs, box rvalue) => { + match rvalue { + Rvalue::Aggregate(kind, operands) => (lhs, kind, operands), + _ => bug!() + } + } _ => bug!() }; @@ -82,7 +86,7 @@ }; Statement { source_info, - kind: StatementKind::Assign(lhs_field, Rvalue::Use(op)), + kind: StatementKind::Assign(lhs_field, box Rvalue::Use(op)), } }).chain(set_discriminant)) }); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/elaborate_drops.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/elaborate_drops.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/elaborate_drops.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/elaborate_drops.rs 2018-12-04 23:41:40.000000000 +0000 @@ -18,15 +18,14 @@ use rustc::ty::{self, TyCtxt}; use rustc::mir::*; use rustc::util::nodemap::FxHashMap; -use rustc_data_structures::indexed_set::IdxSet; +use rustc_data_structures::bit_set::BitSet; +use std::fmt; +use syntax::ast; +use syntax_pos::Span; use transform::{MirPass, MirSource}; use util::patch::MirPatch; use util::elaborate_drops::{DropFlagState, Unwind, elaborate_drop}; use util::elaborate_drops::{DropElaborator, DropStyle, DropFlagMode}; -use syntax::ast; -use syntax_pos::Span; - -use std::fmt; pub struct ElaborateDrops; @@ -76,7 +75,7 @@ env: &env, flow_inits, flow_uninits, - drop_flags: FxHashMap(), + drop_flags: Default::default(), patch: MirPatch::new(mir), }.elaborate() }; @@ -92,12 +91,12 @@ mir: &Mir<'tcx>, id: ast::NodeId, env: &MoveDataParamEnv<'tcx, 'tcx>) - -> IdxSet + -> BitSet { debug!("find_dead_unwinds({:?})", mir.span); // We only need to do this pass once, because unwind edges can only // reach cleanup blocks, which can't have unwind edges themselves. - let mut dead_unwinds = IdxSet::new_empty(mir.basic_blocks().len()); + let mut dead_unwinds = BitSet::new_empty(mir.basic_blocks().len()); let flow_inits = do_dataflow(tcx, mir, id, &[], &dead_unwinds, MaybeInitializedPlaces::new(tcx, mir, &env), @@ -111,7 +110,7 @@ let mut init_data = InitializationData { live: flow_inits.sets().on_entry_set_for(bb.index()).to_owned(), - dead: IdxSet::new_empty(env.move_data.move_paths.len()), + dead: BitSet::new_empty(env.move_data.move_paths.len()), }; debug!("find_dead_unwinds @ {:?}: {:?}; init_data={:?}", bb, bb_data, init_data.live); @@ -138,7 +137,7 @@ debug!("find_dead_unwinds @ {:?}: maybe_live={}", bb, maybe_live); if !maybe_live { - dead_unwinds.add(&bb); + dead_unwinds.insert(bb); } } @@ -146,8 +145,8 @@ } struct InitializationData { - live: IdxSet, - dead: IdxSet + live: BitSet, + dead: BitSet } impl InitializationData { @@ -162,19 +161,19 @@ loc, path, df); match df { DropFlagState::Present => { - self.live.add(&path); - self.dead.remove(&path); + self.live.insert(path); + self.dead.remove(path); } DropFlagState::Absent => { - self.dead.add(&path); - self.live.remove(&path); + self.dead.insert(path); + self.live.remove(path); } } }); } fn state(&self, path: MovePathIndex) -> (bool, bool) { - (self.live.contains(&path), self.dead.contains(&path)) + (self.live.contains(path), self.dead.contains(path)) } } @@ -479,11 +478,11 @@ assert!(!data.is_cleanup, "DropAndReplace in unwind path not supported"); let assign = Statement { - kind: StatementKind::Assign(location.clone(), Rvalue::Use(value.clone())), + kind: StatementKind::Assign(location.clone(), box Rvalue::Use(value.clone())), source_info: terminator.source_info }; - let unwind = unwind.unwrap_or(self.patch.resume_block()); + let unwind = unwind.unwrap_or_else(|| self.patch.resume_block()); let unwind = self.patch.new_block(BasicBlockData { statements: vec![assign.clone()], terminator: Some(Terminator { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/generator.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/generator.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/generator.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/generator.rs 2018-12-04 23:41:40.000000000 +0000 @@ -69,7 +69,7 @@ use util::liveness::{self, IdentityMap}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::indexed_vec::Idx; -use rustc_data_structures::indexed_set::IdxSet; +use rustc_data_structures::bit_set::BitSet; use std::borrow::Cow; use std::iter::once; use std::mem; @@ -188,7 +188,7 @@ }); Statement { source_info, - kind: StatementKind::Assign(state, Rvalue::Use(val)), + kind: StatementKind::Assign(state, box Rvalue::Use(val)), } } } @@ -246,7 +246,7 @@ data.statements.push(Statement { source_info, kind: StatementKind::Assign(Place::Local(RETURN_PLACE), - self.make_state(state_idx, v)), + box self.make_state(state_idx, v)), }); let state = if let Some(resume) = resume { // Yield let state = 3 + self.suspension_points.len() as u32; @@ -303,11 +303,12 @@ let new_ret = LocalDecl { mutability: Mutability::Mut, ty: ret_ty, - user_ty: None, + user_ty: UserTypeProjections::none(), name: None, source_info, visibility_scope: source_info.scope, internal: false, + is_block_tail: None, is_user_variable: None, }; let new_ret_local = Local::new(mir.local_decls.len()); @@ -331,7 +332,7 @@ _location: Location) { match statement.kind { StatementKind::StorageLive(l) | - StatementKind::StorageDead(l) => { self.0.remove(&l); } + StatementKind::StorageDead(l) => { self.0.remove(l); } _ => (), } } @@ -341,7 +342,7 @@ fn mark_as_borrowed<'tcx>(place: &Place<'tcx>, locals: &mut BorrowedLocals) { match *place { - Place::Local(l) => { locals.0.add(&l); }, + Place::Local(l) => { locals.0.insert(l); }, Place::Promoted(_) | Place::Static(..) => (), Place::Projection(ref proj) => { @@ -376,7 +377,7 @@ liveness::LiveVarSet, FxHashMap>, ) { - let dead_unwinds = IdxSet::new_empty(mir.basic_blocks().len()); + let dead_unwinds = BitSet::new_empty(mir.basic_blocks().len()); let node_id = tcx.hir.as_local_node_id(source.def_id).unwrap(); // Calculate when MIR locals have live storage. This gives us an upper bound of their @@ -388,7 +389,7 @@ // Find the MIR locals which do not use StorageLive/StorageDead statements. // The storage of these locals are always live. - let mut ignored = StorageIgnored(IdxSet::new_filled(mir.local_decls.len())); + let mut ignored = StorageIgnored(BitSet::new_filled(mir.local_decls.len())); ignored.visit_mir(mir); // Calculate the MIR locals which have been previously @@ -472,7 +473,7 @@ } // The generator argument is ignored - set.remove(&self_arg()); + set.remove(self_arg()); (set, storage_liveness_map) } @@ -502,7 +503,7 @@ for (local, decl) in mir.local_decls.iter_enumerated() { // Ignore locals which are internal or not live - if !live_locals.contains(&local) || decl.internal { + if !live_locals.contains(local) || decl.internal { continue; } @@ -657,11 +658,12 @@ mir.local_decls[RETURN_PLACE] = LocalDecl { mutability: Mutability::Mut, ty: tcx.mk_unit(), - user_ty: None, + user_ty: UserTypeProjections::none(), name: None, source_info, visibility_scope: source_info.scope, internal: false, + is_block_tail: None, is_user_variable: None, }; @@ -674,11 +676,12 @@ ty: gen_ty, mutbl: hir::Mutability::MutMutable, }), - user_ty: None, + user_ty: UserTypeProjections::none(), name: None, source_info, visibility_scope: source_info.scope, internal: false, + is_block_tail: None, is_user_variable: None, }; @@ -823,7 +826,7 @@ // Create StorageLive instructions for locals with live storage for i in 0..(mir.local_decls.len()) { let l = Local::new(i); - if point.storage_liveness.contains(&l) && !transform.remap.contains_key(&l) { + if point.storage_liveness.contains(l) && !transform.remap.contains_key(&l) { statements.push(Statement { source_info, kind: StatementKind::StorageLive(l), diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/inline.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/inline.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/inline.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/inline.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,12 +14,12 @@ use rustc::hir::CodegenFnAttrFlags; use rustc::hir::def_id::DefId; -use rustc_data_structures::bitvec::BitArray; +use rustc_data_structures::bit_set::BitSet; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use rustc::mir::*; use rustc::mir::visit::*; -use rustc::ty::{self, Instance, Ty, TyCtxt}; +use rustc::ty::{self, Instance, InstanceDef, Ty, TyCtxt}; use rustc::ty::subst::{Subst,Substs}; use std::collections::VecDeque; @@ -94,18 +94,27 @@ // Only consider direct calls to functions let terminator = bb_data.terminator(); if let TerminatorKind::Call { - func: Operand::Constant(ref f), .. } = terminator.kind { - if let ty::FnDef(callee_def_id, substs) = f.ty.sty { + func: ref op, .. } = terminator.kind { + if let ty::FnDef(callee_def_id, substs) = op.ty(caller_mir, self.tcx).sty { if let Some(instance) = Instance::resolve(self.tcx, param_env, callee_def_id, substs) { - callsites.push_back(CallSite { - callee: instance.def_id(), - substs: instance.substs, - bb, - location: terminator.source_info - }); + let is_virtual = + if let InstanceDef::Virtual(..) = instance.def { + true + } else { + false + }; + + if !is_virtual { + callsites.push_back(CallSite { + callee: instance.def_id(), + substs: instance.substs, + bb, + location: terminator.source_info + }); + } } } } @@ -271,7 +280,7 @@ // Traverse the MIR manually so we can account for the effects of // inlining on the CFG. let mut work_list = vec![START_BLOCK]; - let mut visited = BitArray::new(callee_mir.basic_blocks().len()); + let mut visited = BitSet::new_empty(callee_mir.basic_blocks().len()); while let Some(bb) = work_list.pop() { if !visited.insert(bb.index()) { continue; } let blk = &callee_mir.basic_blocks()[bb]; @@ -447,7 +456,7 @@ let stmt = Statement { source_info: callsite.location, - kind: StatementKind::Assign(tmp.clone(), dest) + kind: StatementKind::Assign(tmp.clone(), box dest) }; caller_mir[callsite.bb] .statements.push(stmt); @@ -594,7 +603,7 @@ let stmt = Statement { source_info: callsite.location, - kind: StatementKind::Assign(Place::Local(arg_tmp), arg), + kind: StatementKind::Assign(Place::Local(arg_tmp), box arg), }; caller_mir[callsite.bb].statements.push(stmt); arg_tmp diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/lower_128bit.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/lower_128bit.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/lower_128bit.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/lower_128bit.rs 2018-12-04 23:41:40.000000000 +0000 @@ -79,11 +79,14 @@ let bin_statement = block.statements.pop().unwrap(); let source_info = bin_statement.source_info; let (place, lhs, mut rhs) = match bin_statement.kind { - StatementKind::Assign(place, Rvalue::BinaryOp(_, lhs, rhs)) - | StatementKind::Assign(place, Rvalue::CheckedBinaryOp(_, lhs, rhs)) => { - (place, lhs, rhs) + StatementKind::Assign(place, box rvalue) => { + match rvalue { + Rvalue::BinaryOp(_, lhs, rhs) + | Rvalue::CheckedBinaryOp(_, lhs, rhs) => (place, lhs, rhs), + _ => bug!(), + } } - _ => bug!("Statement doesn't match pattern any more?"), + _ => bug!() }; if let Some(local) = cast_local { @@ -95,7 +98,7 @@ source_info: source_info, kind: StatementKind::Assign( Place::Local(local), - Rvalue::Cast( + box Rvalue::Cast( CastKind::Misc, rhs, rhs_override_ty.unwrap())), @@ -118,6 +121,7 @@ args: vec![lhs, rhs], destination: Some((place, bb)), cleanup: None, + from_hir_call: false, }, }); } @@ -154,13 +158,13 @@ where D: HasLocalDecls<'tcx> { match statement.kind { - StatementKind::Assign(_, Rvalue::BinaryOp(bin_op, ref lhs, _)) => { + StatementKind::Assign(_, box Rvalue::BinaryOp(bin_op, ref lhs, _)) => { let ty = lhs.ty(local_decls, tcx); if let Some(is_signed) = sign_of_128bit(ty) { return item_for_op(bin_op, is_signed); } }, - StatementKind::Assign(_, Rvalue::CheckedBinaryOp(bin_op, ref lhs, _)) => { + StatementKind::Assign(_, box Rvalue::CheckedBinaryOp(bin_op, ref lhs, _)) => { let ty = lhs.ty(local_decls, tcx); if let Some(is_signed) = sign_of_128bit(ty) { return item_for_checked_op(bin_op, is_signed); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -237,9 +237,12 @@ no_landing_pads::NoLandingPads, simplify_branches::SimplifyBranches::new("initial"), remove_noop_landing_pads::RemoveNoopLandingPads, - simplify::SimplifyCfg::new("early-opt"), // Remove all `AscribeUserType` statements. cleanup_post_borrowck::CleanAscribeUserType, + // Remove all `FakeRead` statements and the borrows that are only + // used for checking matches + cleanup_post_borrowck::CleanFakeReadsAndBorrows, + simplify::SimplifyCfg::new("early-opt"), // These next passes must be executed together add_call_guards::CriticalCallEdges, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/promote_consts.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/promote_consts.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/promote_consts.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/promote_consts.rs 2018-12-04 23:41:40.000000000 +0000 @@ -23,7 +23,7 @@ //! move analysis runs after promotion on broken MIR. use rustc::mir::*; -use rustc::mir::visit::{PlaceContext, MutVisitor, Visitor}; +use rustc::mir::visit::{PlaceContext, MutatingUseContext, MutVisitor, Visitor}; use rustc::mir::traversal::ReversePostorder; use rustc::ty::TyCtxt; use syntax_pos::Span; @@ -53,6 +53,7 @@ impl TempState { pub fn is_promotable(&self) -> bool { + debug!("is_promotable: self={:?}", self); if let TempState::Defined { uses, .. } = *self { uses > 0 } else { @@ -88,6 +89,7 @@ &index: &Local, context: PlaceContext<'tcx>, location: Location) { + debug!("visit_local: index={:?} context={:?} location={:?}", index, context, location); // We're only interested in temporaries if self.mir.local_kind(index) != LocalKind::Temp { return; @@ -95,17 +97,22 @@ // Ignore drops, if the temp gets promoted, // then it's constant and thus drop is noop. - // Storage live ranges are also irrelevant. - if context.is_drop() || context.is_storage_marker() { + // Non-uses are also irrelevent. + if context.is_drop() || !context.is_use() { + debug!( + "visit_local: context.is_drop={:?} context.is_use={:?}", + context.is_drop(), context.is_use(), + ); return; } let temp = &mut self.temps[index]; + debug!("visit_local: temp={:?}", temp); if *temp == TempState::Undefined { match context { - PlaceContext::Store | - PlaceContext::AsmOutput | - PlaceContext::Call => { + PlaceContext::MutatingUse(MutatingUseContext::Store) | + PlaceContext::MutatingUse(MutatingUseContext::AsmOutput) | + PlaceContext::MutatingUse(MutatingUseContext::Call) => { *temp = TempState::Defined { location, uses: 0 @@ -117,10 +124,8 @@ } else if let TempState::Defined { ref mut uses, .. } = *temp { // We always allow borrows, even mutable ones, as we need // to promote mutable borrows of some ZSTs e.g. `&mut []`. - let allowed_use = match context { - PlaceContext::Borrow {..} => true, - _ => context.is_nonmutating_use() - }; + let allowed_use = context.is_borrow() || context.is_nonmutating_use(); + debug!("visit_local: allowed_use={:?}", allowed_use); if allowed_use { *uses += 1; return; @@ -182,7 +187,7 @@ span, scope: OUTERMOST_SOURCE_SCOPE }, - kind: StatementKind::Assign(Place::Local(dest), rvalue) + kind: StatementKind::Assign(Place::Local(dest), box rvalue) }); } @@ -217,7 +222,7 @@ // First, take the Rvalue or Call out of the source MIR, // or duplicate it, depending on keep_original. if loc.statement_index < no_stmts { - let (mut rvalue, source_info) = { + let (rvalue, source_info) = { let statement = &mut self.source[loc.block].statements[loc.statement_index]; let rhs = match statement.kind { StatementKind::Assign(_, ref mut rhs) => rhs, @@ -230,11 +235,12 @@ (if self.keep_original { rhs.clone() } else { - let unit = Rvalue::Aggregate(box AggregateKind::Tuple, vec![]); + let unit = box Rvalue::Aggregate(box AggregateKind::Tuple, vec![]); mem::replace(rhs, unit) }, statement.source_info) }; + let mut rvalue = *rvalue; self.visit_rvalue(&mut rvalue, loc); self.assign(new_temp, rvalue, source_info.span); } else { @@ -257,7 +263,7 @@ }; match terminator.kind { - TerminatorKind::Call { mut func, mut args, .. } => { + TerminatorKind::Call { mut func, mut args, from_hir_call, .. } => { self.visit_operand(&mut func, loc); for arg in &mut args { self.visit_operand(arg, loc); @@ -271,7 +277,8 @@ func, args, cleanup: None, - destination: Some((Place::Local(new_temp), new_target)) + destination: Some((Place::Local(new_temp), new_target)), + from_hir_call, }, ..terminator }; @@ -301,7 +308,7 @@ Candidate::Ref(loc) => { let ref mut statement = blocks[loc.block].statements[loc.statement_index]; match statement.kind { - StatementKind::Assign(_, Rvalue::Ref(_, _, ref mut place)) => { + StatementKind::Assign(_, box Rvalue::Ref(_, _, ref mut place)) => { // Find the underlying local for this (necessarily interior) borrow. // HACK(eddyb) using a recursive function because of mutable borrows. fn interior_base<'a, 'tcx>(place: &'a mut Place<'tcx>) diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/qualify_consts.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/qualify_consts.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/qualify_consts.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/qualify_consts.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,8 +14,7 @@ //! The Qualif flags below can be used to also provide better //! diagnostics as to why a constant rvalue wasn't promoted. -use rustc_data_structures::bitvec::BitArray; -use rustc_data_structures::indexed_set::IdxSet; +use rustc_data_structures::bit_set::BitSet; use rustc_data_structures::indexed_vec::IndexVec; use rustc_data_structures::fx::FxHashSet; use rustc::hir; @@ -27,10 +26,9 @@ use rustc::ty::query::Providers; use rustc::mir::*; use rustc::mir::traversal::ReversePostorder; -use rustc::mir::visit::{PlaceContext, Visitor}; +use rustc::mir::visit::{PlaceContext, Visitor, MutatingUseContext, NonMutatingUseContext}; use rustc::middle::lang_items; use rustc_target::spec::abi::Abi; -use syntax::attr; use syntax::ast::LitKind; use syntax::feature_gate::{UnstableFeatures, feature_err, emit_feature_err, GateIssue}; use syntax_pos::{Span, DUMMY_SP}; @@ -86,7 +84,7 @@ } /// What kind of item we are in. -#[derive(Copy, Clone, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq)] enum Mode { Const, Static, @@ -116,7 +114,7 @@ param_env: ty::ParamEnv<'tcx>, local_qualif: IndexVec>, qualif: Qualif, - const_fn_arg_vars: BitArray, + const_fn_arg_vars: BitSet, temp_promotion_state: IndexVec, promotion_candidates: Vec } @@ -151,7 +149,7 @@ param_env, local_qualif, qualif: Qualif::empty(), - const_fn_arg_vars: BitArray::new(mir.local_decls.len()), + const_fn_arg_vars: BitSet::new_empty(mir.local_decls.len()), temp_promotion_state: temps, promotion_candidates: vec![] } @@ -273,19 +271,23 @@ // This must be an explicit assignment. _ => { // Catch more errors in the destination. - self.visit_place(dest, PlaceContext::Store, location); + self.visit_place( + dest, + PlaceContext::MutatingUse(MutatingUseContext::Store), + location + ); self.statement_like(); } } } /// Qualify a whole const, static initializer or const fn. - fn qualify_const(&mut self) -> (Qualif, Lrc>) { + fn qualify_const(&mut self) -> (Qualif, Lrc>) { debug!("qualifying {} {:?}", self.mode, self.def_id); let mir = self.mir; - let mut seen_blocks = BitArray::new(mir.basic_blocks().len()); + let mut seen_blocks = BitSet::new_empty(mir.basic_blocks().len()); let mut bb = START_BLOCK; loop { seen_blocks.insert(bb.index()); @@ -383,14 +385,15 @@ // Collect all the temps we need to promote. - let mut promoted_temps = IdxSet::new_empty(self.temp_promotion_state.len()); + let mut promoted_temps = BitSet::new_empty(self.temp_promotion_state.len()); + debug!("qualify_const: promotion_candidates={:?}", self.promotion_candidates); for candidate in &self.promotion_candidates { match *candidate { Candidate::Ref(Location { block: bb, statement_index: stmt_idx }) => { match self.mir[bb].statements[stmt_idx].kind { - StatementKind::Assign(_, Rvalue::Ref(_, _, Place::Local(index))) => { - promoted_temps.add(&index); + StatementKind::Assign(_, box Rvalue::Ref(_, _, Place::Local(index))) => { + promoted_temps.insert(index); } _ => {} } @@ -416,6 +419,7 @@ &local: &Local, _: PlaceContext<'tcx>, _: Location) { + debug!("visit_local: local={:?}", local); let kind = self.mir.local_kind(local); match kind { LocalKind::ReturnPointer => { @@ -437,6 +441,7 @@ } if !self.temp_promotion_state[local].is_promotable() { + debug!("visit_local: (not promotable) local={:?}", local); self.add(Qualif::NOT_PROMOTABLE); } @@ -453,6 +458,7 @@ place: &Place<'tcx>, context: PlaceContext<'tcx>, location: Location) { + debug!("visit_place: place={:?} context={:?} location={:?}", place, context, location); match *place { Place::Local(ref local) => self.visit_local(local, context, location), Place::Promoted(_) => bug!("promoting already promoted MIR"), @@ -497,20 +503,22 @@ this.super_place(place, context, location); match proj.elem { ProjectionElem::Deref => { - if let Mode::Fn = this.mode { - this.add(Qualif::NOT_CONST); - } else { - let base_ty = proj.base.ty(this.mir, this.tcx).to_ty(this.tcx); - if let ty::RawPtr(_) = base_ty.sty { - if !this.tcx.sess.features_untracked().const_raw_ptr_deref { - emit_feature_err( - &this.tcx.sess.parse_sess, "const_raw_ptr_deref", - this.span, GateIssue::Language, - &format!( - "dereferencing raw pointers in {}s is unstable", - this.mode, - ), - ); + this.add(Qualif::NOT_CONST); + let base_ty = proj.base.ty(this.mir, this.tcx).to_ty(this.tcx); + match this.mode { + Mode::Fn => {}, + _ => { + if let ty::RawPtr(_) = base_ty.sty { + if !this.tcx.sess.features_untracked().const_raw_ptr_deref { + emit_feature_err( + &this.tcx.sess.parse_sess, "const_raw_ptr_deref", + this.span, GateIssue::Language, + &format!( + "dereferencing raw pointers in {}s is unstable", + this.mode, + ), + ); + } } } } @@ -557,6 +565,7 @@ } fn visit_operand(&mut self, operand: &Operand<'tcx>, location: Location) { + debug!("visit_operand: operand={:?} location={:?}", operand, location); self.super_operand(operand, location); match *operand { @@ -591,6 +600,7 @@ } fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) { + debug!("visit_rvalue: rvalue={:?} location={:?}", rvalue, location); // Recurse through operands and places. if let Rvalue::Ref(region, kind, ref place) = *rvalue { let mut is_reborrow = false; @@ -604,10 +614,17 @@ } if is_reborrow { - self.super_place(place, PlaceContext::Borrow { - region, - kind - }, location); + let ctx = match kind { + BorrowKind::Shared => + PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow(region)), + BorrowKind::Shallow => + PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow(region)), + BorrowKind::Unique => + PlaceContext::NonMutatingUse(NonMutatingUseContext::UniqueBorrow(region)), + BorrowKind::Mut { .. } => + PlaceContext::MutatingUse(MutatingUseContext::Borrow(region)), + }; + self.super_place(place, ctx, location); } else { self.super_rvalue(rvalue, location); } @@ -696,6 +713,7 @@ } } + debug!("visit_rvalue: forbidden_mut={:?}", forbidden_mut); if forbidden_mut { self.add(Qualif::NOT_CONST); } else { @@ -709,15 +727,19 @@ } place = &proj.base; } + debug!("visit_rvalue: place={:?}", place); if let Place::Local(local) = *place { if self.mir.local_kind(local) == LocalKind::Temp { + debug!("visit_rvalue: local={:?}", local); if let Some(qualif) = self.local_qualif[local] { // `forbidden_mut` is false, so we can safely ignore // `MUTABLE_INTERIOR` from the local's qualifications. // This allows borrowing fields which don't have // `MUTABLE_INTERIOR`, from a type that does, e.g.: // `let _: &'static _ = &(Cell::new(1), 2).1;` + debug!("visit_rvalue: qualif={:?}", qualif); if (qualif - Qualif::MUTABLE_INTERIOR).is_empty() { + debug!("visit_rvalue: candidate={:?}", candidate); self.promotion_candidates.push(candidate); } } @@ -734,8 +756,11 @@ (CastTy::Ptr(_), CastTy::Int(_)) | (CastTy::FnPtr, CastTy::Int(_)) => { if let Mode::Fn = self.mode { + // in normal functions, mark such casts as not promotable self.add(Qualif::NOT_CONST); } else if !self.tcx.sess.features_untracked().const_raw_ptr_to_usize_cast { + // in const fn and constants require the feature gate + // FIXME: make it unsafe inside const fn and constants emit_feature_err( &self.tcx.sess.parse_sess, "const_raw_ptr_to_usize_cast", self.span, GateIssue::Language, @@ -751,15 +776,18 @@ } Rvalue::BinaryOp(op, ref lhs, _) => { - if let ty::RawPtr(_) = lhs.ty(self.mir, self.tcx).sty { + if let ty::RawPtr(_) | ty::FnPtr(..) = lhs.ty(self.mir, self.tcx).sty { assert!(op == BinOp::Eq || op == BinOp::Ne || op == BinOp::Le || op == BinOp::Lt || op == BinOp::Ge || op == BinOp::Gt || op == BinOp::Offset); if let Mode::Fn = self.mode { + // raw pointer operations are not allowed inside promoteds self.add(Qualif::NOT_CONST); } else if !self.tcx.sess.features_untracked().const_compare_raw_pointers { + // require the feature gate inside constants and const fn + // FIXME: make it unsafe to use these operations emit_feature_err( &self.tcx.sess.parse_sess, "const_compare_raw_pointers", @@ -809,12 +837,13 @@ bb: BasicBlock, kind: &TerminatorKind<'tcx>, location: Location) { + debug!("visit_terminator_kind: bb={:?} kind={:?} location={:?}", bb, kind, location); if let TerminatorKind::Call { ref func, ref args, ref destination, .. } = *kind { 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); + let (mut is_shuffle, mut is_const_fn) = (false, false); if let ty::FnDef(def_id, _) = fn_ty.sty { callee_def_id = Some(def_id); match self.tcx.fn_sig(def_id).abi() { @@ -824,6 +853,7 @@ match &self.tcx.item_name(def_id).as_str()[..] { | "size_of" | "min_align_of" + | "needs_drop" | "type_id" | "bswap" | "bitreverse" @@ -839,10 +869,17 @@ | "unchecked_shr" | "add_with_overflow" | "sub_with_overflow" - | "mul_with_overflow" => is_const_fn = Some(def_id), + | "mul_with_overflow" + // no need to check feature gates, intrinsics are only callable from the + // libstd or with forever unstable feature gates + => is_const_fn = true, + // special intrinsic that can be called diretly without an intrinsic + // feature gate needs a language feature gate "transmute" => { + // never promote transmute calls if self.mode != Mode::Fn { - is_const_fn = Some(def_id); + is_const_fn = true; + // const eval transmute calls only with the feature gate if !self.tcx.sess.features_untracked().const_transmute { emit_feature_err( &self.tcx.sess.parse_sess, "const_transmute", @@ -861,8 +898,81 @@ } } _ => { - if self.tcx.is_const_fn(def_id) || self.is_const_panic_fn(def_id) { - is_const_fn = Some(def_id); + // in normal functions we only care about promotion + if self.mode == Mode::Fn { + // never promote const fn calls of + // functions without #[rustc_promotable] + if self.tcx.is_promotable_const_fn(def_id) { + is_const_fn = true; + } + } else { + // stable const fn or unstable const fns with their feature gate + // active + if self.tcx.is_const_fn(def_id) { + is_const_fn = true; + } else if self.is_const_panic_fn(def_id) { + // check the const_panic feature gate + // FIXME: cannot allow this inside `allow_internal_unstable` because + // that would make `panic!` insta stable in constants, since the + // macro is marked with the attr + if self.tcx.sess.features_untracked().const_panic { + is_const_fn = true; + } else { + // don't allow panics in constants without the feature gate + emit_feature_err( + &self.tcx.sess.parse_sess, + "const_panic", + self.span, + GateIssue::Language, + &format!("panicking in {}s is unstable", self.mode), + ); + } + } else if let Some(feature) = self.tcx.is_unstable_const_fn(def_id) { + // check `#[unstable]` const fns or `#[rustc_const_unstable]` + // functions without the feature gate active in this crate to report + // a better error message than the one below + if self.span.allows_unstable() { + // `allow_internal_unstable` can make such calls stable + is_const_fn = true; + } else { + let mut err = self.tcx.sess.struct_span_err(self.span, + &format!("`{}` is not yet stable as a const fn", + self.tcx.item_path_str(def_id))); + help!(&mut err, + "in Nightly builds, add `#![feature({})]` \ + to the crate attributes to enable", + feature); + err.emit(); + } + } else { + // FIXME(#24111) Remove this check when const fn stabilizes + let (msg, note) = if let UnstableFeatures::Disallow = + self.tcx.sess.opts.unstable_features { + (format!("calls in {}s are limited to \ + tuple structs and tuple variants", + self.mode), + Some("a limited form of compile-time function \ + evaluation is available on a nightly \ + compiler via `const fn`")) + } else { + (format!("calls in {}s are limited \ + to constant functions, \ + tuple structs and tuple variants", + self.mode), + None) + }; + let mut err = struct_span_err!( + self.tcx.sess, + self.span, + E0015, + "{}", + msg, + ); + if let Some(note) = note { + err.span_note(self.span, note); + } + err.emit(); + } } } } @@ -880,6 +990,7 @@ let candidate = Candidate::Argument { bb, index: i }; if is_shuffle && i == 2 { if this.qualif.is_empty() { + debug!("visit_terminator_kind: candidate={:?}", candidate); this.promotion_candidates.push(candidate); } else { span_err!(this.tcx.sess, this.span, E0526, @@ -896,6 +1007,7 @@ return } if this.qualif.is_empty() { + debug!("visit_terminator_kind: candidate={:?}", candidate); this.promotion_candidates.push(candidate); } else { this.tcx.sess.span_err(this.span, @@ -905,78 +1017,14 @@ }); } - // Const fn calls. - if let Some(def_id) = is_const_fn { - // check the const_panic feature gate or - // find corresponding rustc_const_unstable feature - // FIXME: cannot allow this inside `allow_internal_unstable` because that would make - // `panic!` insta stable in constants, since the macro is marked with the attr - if self.is_const_panic_fn(def_id) { - if self.mode == Mode::Fn { - // never promote panics - self.qualif = Qualif::NOT_CONST; - } else if !self.tcx.sess.features_untracked().const_panic { - // don't allow panics in constants without the feature gate - emit_feature_err( - &self.tcx.sess.parse_sess, - "const_panic", - self.span, - GateIssue::Language, - &format!("panicking in {}s is unstable", self.mode), - ); - } - } else if let Some(&attr::Stability { - const_stability: Some(ref feature_name), - .. }) = self.tcx.lookup_stability(def_id) { - if - // feature-gate is not enabled, - !self.tcx.features() - .declared_lib_features - .iter() - .any(|&(ref sym, _)| sym == feature_name) && - - // this doesn't come from a macro that has #[allow_internal_unstable] - !self.span.allows_unstable() - { - self.qualif = Qualif::NOT_CONST; - if self.mode != Mode::Fn { - // inside a constant environment, not having the feature gate is - // an error - let mut err = self.tcx.sess.struct_span_err(self.span, - &format!("`{}` is not yet stable as a const fn", - self.tcx.item_path_str(def_id))); - help!(&mut err, - "in Nightly builds, add `#![feature({})]` \ - to the crate attributes to enable", - feature_name); - err.emit(); - } - } - } - } else { + // non-const fn calls. + if !is_const_fn { self.qualif = Qualif::NOT_CONST; if self.mode != Mode::Fn { - // FIXME(#24111) Remove this check when const fn stabilizes - let (msg, note) = if let UnstableFeatures::Disallow = - self.tcx.sess.opts.unstable_features { - (format!("calls in {}s are limited to \ - tuple structs and tuple variants", - self.mode), - Some("a limited form of compile-time function \ - evaluation is available on a nightly \ - compiler via `const fn`")) - } else { - (format!("calls in {}s are limited \ - to constant functions, \ - tuple structs and tuple variants", - self.mode), - None) - }; - let mut err = struct_span_err!(self.tcx.sess, self.span, E0015, "{}", msg); - if let Some(note) = note { - err.span_note(self.span, note); - } - err.emit(); + self.tcx.sess.delay_span_bug( + self.span, + "should have reported an error about non-const fn calls in constants", + ) } } @@ -1033,6 +1081,7 @@ dest: &Place<'tcx>, rvalue: &Rvalue<'tcx>, location: Location) { + debug!("visit_assign: dest={:?} rvalue={:?} location={:?}", dest, rvalue, location); self.visit_rvalue(rvalue, location); // Check the allowed const fn argument forms. @@ -1081,17 +1130,19 @@ } fn visit_source_info(&mut self, source_info: &SourceInfo) { + debug!("visit_source_info: source_info={:?}", source_info); self.span = source_info.span; } fn visit_statement(&mut self, bb: BasicBlock, statement: &Statement<'tcx>, location: Location) { + debug!("visit_statement: bb={:?} statement={:?} location={:?}", bb, statement, location); self.nest(|this| { this.visit_source_info(&statement.source_info); match statement.kind { StatementKind::Assign(ref place, ref rvalue) => { this.visit_assign(bb, place, rvalue, location); } - StatementKind::ReadForMatch(..) | + StatementKind::FakeRead(..) | StatementKind::SetDiscriminant { .. } | StatementKind::StorageLive(_) | StatementKind::StorageDead(_) | @@ -1108,6 +1159,7 @@ bb: BasicBlock, terminator: &Terminator<'tcx>, location: Location) { + debug!("visit_terminator: bb={:?} terminator={:?} location={:?}", bb, terminator, location); self.nest(|this| this.super_terminator(bb, terminator, location)); } } @@ -1121,7 +1173,7 @@ fn mir_const_qualif<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) - -> (u8, Lrc>) { + -> (u8, Lrc>) { // NB: This `borrow()` is guaranteed to be valid (i.e., the value // cannot yet be stolen), because `mir_validated()`, which steals // from `mir_const(), forces this query to execute before @@ -1130,7 +1182,7 @@ if mir.return_ty().references_error() { tcx.sess.delay_span_bug(mir.span, "mir_const_qualif: Mir had errors"); - return (Qualif::NOT_CONST.bits(), Lrc::new(IdxSet::new_empty(0))); + return (Qualif::NOT_CONST.bits(), Lrc::new(BitSet::new_empty(0))); } let mut qualifier = Qualifier::new(tcx, def_id, mir, Mode::Const); @@ -1174,6 +1226,7 @@ hir::BodyOwnerKind::Static(hir::MutMutable) => Mode::StaticMut, }; + debug!("run_pass: mode={:?}", mode); if mode == Mode::Fn || mode == Mode::ConstFn { // This is ugly because Qualifier holds onto mir, // which can't be mutated until its scope ends. @@ -1216,11 +1269,12 @@ // In `const` and `static` everything without `StorageDead` // is `'static`, we don't have to create promoted MIR fragments, // just remove `Drop` and `StorageDead` on "promoted" locals. + debug!("run_pass: promoted_temps={:?}", promoted_temps); for block in mir.basic_blocks_mut() { block.statements.retain(|statement| { match statement.kind { StatementKind::StorageDead(index) => { - !promoted_temps.contains(&index) + !promoted_temps.contains(index) } _ => true } @@ -1228,7 +1282,7 @@ let terminator = block.terminator_mut(); match terminator.kind { TerminatorKind::Drop { location: Place::Local(index), target, .. } => { - if promoted_temps.contains(&index) { + if promoted_temps.contains(index) { terminator.kind = TerminatorKind::Goto { target, }; @@ -1268,7 +1322,7 @@ fn args_required_const(tcx: TyCtxt, def_id: DefId) -> Option> { let attrs = tcx.get_attrs(def_id); let attr = attrs.iter().find(|a| a.check_name("rustc_args_required_const"))?; - let mut ret = FxHashSet(); + let mut ret = FxHashSet::default(); for meta in attr.meta_item_list()? { match meta.literal()?.node { LitKind::Int(a, _) => { ret.insert(a as usize); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/qualify_min_const_fn.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/qualify_min_const_fn.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/qualify_min_const_fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/qualify_min_const_fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,7 +15,7 @@ let mut current = def_id; loop { let predicates = tcx.predicates_of(current); - for predicate in &predicates.predicates { + for (predicate, _) in &predicates.predicates { match predicate { | Predicate::RegionOutlives(_) | Predicate::TypeOutlives(_) @@ -148,7 +148,7 @@ Rvalue::Len(place) | Rvalue::Discriminant(place) | Rvalue::Ref(_, _, place) => { check_place(tcx, mir, place, span, PlaceMode::Read) } - Rvalue::Cast(_, operand, cast_ty) => { + Rvalue::Cast(CastKind::Misc, operand, cast_ty) => { use rustc::ty::cast::CastTy; let cast_in = CastTy::from_ty(operand.ty(mir, tcx)).expect("bad input type for cast"); let cast_out = CastTy::from_ty(cast_ty).expect("bad output type for cast"); @@ -163,6 +163,16 @@ _ => check_operand(tcx, mir, operand, span), } } + Rvalue::Cast(CastKind::UnsafeFnPointer, _, _) | + Rvalue::Cast(CastKind::ClosureFnPointer, _, _) | + Rvalue::Cast(CastKind::ReifyFnPointer, _, _) => Err(( + span, + "function pointer casts are not allowed in const fn".into(), + )), + Rvalue::Cast(CastKind::Unsize, _, _) => Err(( + span, + "unsizing casts are not allowed in const fn".into(), + )), // binops are fine on integers Rvalue::BinaryOp(_, lhs, rhs) | Rvalue::CheckedBinaryOp(_, lhs, rhs) => { check_operand(tcx, mir, lhs, span)?; @@ -177,8 +187,11 @@ )) } } - // checked by regular const fn checks - Rvalue::NullaryOp(..) => Ok(()), + Rvalue::NullaryOp(NullOp::SizeOf, _) => Ok(()), + Rvalue::NullaryOp(NullOp::Box, _) => Err(( + span, + "heap allocations are not allowed in const fn".into(), + )), Rvalue::UnaryOp(_, operand) => { let ty = operand.ty(mir, tcx); if ty.is_integral() || ty.is_bool() { @@ -216,7 +229,7 @@ check_rvalue(tcx, mir, rval, span) } - StatementKind::ReadForMatch(_) => Err((span, "match in const fn is unstable".into())), + StatementKind::FakeRead(..) => Err((span, "match in const fn is unstable".into())), // just an assignment StatementKind::SetDiscriminant { .. } => Ok(()), @@ -304,7 +317,8 @@ check_place(tcx, mir, location, span, PlaceMode::Read)?; check_operand(tcx, mir, value, span) }, - TerminatorKind::SwitchInt { .. } => Err(( + + TerminatorKind::FalseEdges { .. } | TerminatorKind::SwitchInt { .. } => Err(( span, "`if`, `match`, `&&` and `||` are not stable in const fn".into(), )), @@ -318,6 +332,7 @@ TerminatorKind::Call { func, args, + from_hir_call: _, destination: _, cleanup: _, } => { @@ -349,10 +364,8 @@ cleanup: _, } => check_operand(tcx, mir, cond, span), - | TerminatorKind::FalseEdges { .. } | TerminatorKind::FalseUnwind { .. } => span_bug!( - terminator.source_info.span, - "min_const_fn encountered `{:#?}`", - terminator - ), + TerminatorKind::FalseUnwind { .. } => { + Err((span, "loops are not allowed in const fn".into())) + }, } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/remove_noop_landing_pads.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/remove_noop_landing_pads.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/remove_noop_landing_pads.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/remove_noop_landing_pads.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,7 @@ use rustc::ty::TyCtxt; use rustc::mir::*; -use rustc_data_structures::bitvec::BitArray; +use rustc_data_structures::bit_set::BitSet; use transform::{MirPass, MirSource}; use util::patch::MirPatch; @@ -45,11 +45,11 @@ &self, bb: BasicBlock, mir: &Mir, - nop_landing_pads: &BitArray, + nop_landing_pads: &BitSet, ) -> bool { for stmt in &mir[bb].statements { match stmt.kind { - StatementKind::ReadForMatch(_) | + StatementKind::FakeRead(..) | StatementKind::StorageLive(_) | StatementKind::StorageDead(_) | StatementKind::EndRegion(_) | @@ -60,7 +60,7 @@ // instructions, but this should all run after borrowck). } - StatementKind::Assign(Place::Local(_), Rvalue::Use(_)) => { + StatementKind::Assign(Place::Local(_), box Rvalue::Use(_)) => { // Writing to a local (e.g. a drop flag) does not // turn a landing pad to a non-nop } @@ -111,7 +111,7 @@ let mut jumps_folded = 0; let mut landing_pads_removed = 0; - let mut nop_landing_pads = BitArray::new(mir.basic_blocks().len()); + let mut nop_landing_pads = BitSet::new_empty(mir.basic_blocks().len()); // This is a post-order traversal, so that if A post-dominates B // then A will be visited before B. diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/rustc_peek.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/rustc_peek.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/rustc_peek.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/rustc_peek.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,7 +14,7 @@ use rustc::ty::{self, TyCtxt}; use rustc::mir::{self, Mir, Location}; -use rustc_data_structures::indexed_set::IdxSet; +use rustc_data_structures::bit_set::BitSet; use transform::{MirPass, MirSource}; use dataflow::{do_dataflow, DebugFormatted}; @@ -46,7 +46,7 @@ let param_env = tcx.param_env(def_id); let move_data = MoveData::gather_moves(mir, tcx).unwrap(); let mdpe = MoveDataParamEnv { move_data: move_data, param_env: param_env }; - let dead_unwinds = IdxSet::new_empty(mir.basic_blocks().len()); + let dead_unwinds = BitSet::new_empty(mir.basic_blocks().len()); let flow_inits = do_dataflow(tcx, mir, id, &attributes, &dead_unwinds, MaybeInitializedPlaces::new(tcx, mir, &mdpe), @@ -157,7 +157,7 @@ mir::StatementKind::Assign(ref place, ref rvalue) => { (place, rvalue) } - mir::StatementKind::ReadForMatch(_) | + mir::StatementKind::FakeRead(..) | mir::StatementKind::StorageLive(_) | mir::StatementKind::StorageDead(_) | mir::StatementKind::InlineAsm { .. } | @@ -171,11 +171,11 @@ }; if place == peek_arg_place { - if let mir::Rvalue::Ref(_, mir::BorrowKind::Shared, ref peeking_at_place) = *rvalue { + if let mir::Rvalue::Ref(_, mir::BorrowKind::Shared, ref peeking_at_place) = **rvalue { // Okay, our search is over. match move_data.rev_lookup.find(peeking_at_place) { LookupResult::Exact(peek_mpi) => { - let bit_state = sets.on_entry.contains(&peek_mpi); + let bit_state = sets.on_entry.contains(peek_mpi); debug!("rustc_peek({:?} = &{:?}) bit_state: {}", place, peeking_at_place, bit_state); if !bit_state { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/simplify.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/simplify.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/simplify.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/simplify.rs 2018-12-04 23:41:40.000000000 +0000 @@ -37,7 +37,7 @@ //! naively generate still contains the `_a = ()` write in the unreachable block "after" the //! return. -use rustc_data_structures::bitvec::BitArray; +use rustc_data_structures::bit_set::BitSet; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use rustc::ty::TyCtxt; use rustc::mir::*; @@ -249,7 +249,7 @@ } pub fn remove_dead_blocks(mir: &mut Mir) { - let mut seen = BitArray::new(mir.basic_blocks().len()); + let mut seen = BitSet::new_empty(mir.basic_blocks().len()); for (bb, _) in traversal::preorder(mir) { seen.insert(bb.index()); } @@ -285,7 +285,7 @@ tcx: TyCtxt<'a, 'tcx, 'tcx>, _: MirSource, mir: &mut Mir<'tcx>) { - let mut marker = DeclMarker { locals: BitArray::new(mir.local_decls.len()) }; + let mut marker = DeclMarker { locals: BitSet::new_empty(mir.local_decls.len()) }; marker.visit_mir(mir); // Return pointer and arguments are always live marker.locals.insert(RETURN_PLACE); @@ -310,7 +310,7 @@ /// Construct the mapping while swapping out unused stuff out from the `vec`. fn make_local_map<'tcx, V>( vec: &mut IndexVec, - mask: BitArray, + mask: BitSet, ) -> IndexVec> { let mut map: IndexVec> = IndexVec::from_elem(None, &*vec); let mut used = Local::new(0); @@ -326,13 +326,15 @@ } struct DeclMarker { - pub locals: BitArray, + pub locals: BitSet, } impl<'tcx> Visitor<'tcx> for DeclMarker { fn visit_local(&mut self, local: &Local, ctx: PlaceContext<'tcx>, _: Location) { - // ignore these altogether, they get removed along with their otherwise unused decls. - if ctx != PlaceContext::StorageLive && ctx != PlaceContext::StorageDead { + // Ignore storage markers altogether, they get removed along with their otherwise unused + // decls. + // FIXME: Extend this to all non-uses. + if !ctx.is_storage_marker() { self.locals.insert(*local); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/uniform_array_move_out.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/uniform_array_move_out.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/transform/uniform_array_move_out.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/transform/uniform_array_move_out.rs 2018-12-04 23:41:40.000000000 +0000 @@ -39,7 +39,7 @@ use rustc::ty; use rustc::ty::TyCtxt; use rustc::mir::*; -use rustc::mir::visit::{Visitor, PlaceContext}; +use rustc::mir::visit::{Visitor, PlaceContext, NonUseContext}; use transform::{MirPass, MirSource}; use util::patch::MirPatch; use rustc_data_structures::indexed_vec::{IndexVec}; @@ -184,7 +184,7 @@ for candidate in &visitor.candidates { let statement = &mir[candidate.block].statements[candidate.statement_index]; if let StatementKind::Assign(ref dst_place, ref rval) = statement.kind { - if let Rvalue::Aggregate(box AggregateKind::Array(_), ref items) = *rval { + if let Rvalue::Aggregate(box AggregateKind::Array(_), ref items) = **rval { let items : Vec<_> = items.iter().map(|item| { if let Operand::Move(Place::Local(local)) = item { let local_use = &visitor.locals_use[*local]; @@ -268,7 +268,7 @@ let statement = &block.statements[location.statement_index]; if let StatementKind::Assign( Place::Local(_), - Rvalue::Use(Operand::Move(Place::Projection(box PlaceProjection{ + box Rvalue::Use(Operand::Move(Place::Projection(box PlaceProjection{ ref base, elem: ProjectionElem::ConstantIndex{ offset, min_length: _, from_end: false}})))) = statement.kind { return Some((offset, base)) @@ -316,8 +316,8 @@ location: Location) { let local_use = &mut self.locals_use[*local]; match context { - PlaceContext::StorageLive => local_use.alive = Some(location), - PlaceContext::StorageDead => local_use.dead = Some(location), + PlaceContext::NonUse(NonUseContext::StorageLive) => local_use.alive = Some(location), + PlaceContext::NonUse(NonUseContext::StorageDead) => local_use.dead = Some(location), _ => { local_use.use_count += 1; if local_use.first_use.is_none() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/util/borrowck_errors.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/util/borrowck_errors.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/util/borrowck_errors.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/util/borrowck_errors.rs 2018-12-04 23:41:40.000000000 +0000 @@ -221,6 +221,7 @@ fn cannot_uniquely_borrow_by_one_closure( self, new_loan_span: Span, + container_name: &str, desc_new: &str, opt_via: &str, old_loan_span: Span, @@ -241,7 +242,7 @@ ); err.span_label( new_loan_span, - format!("closure construction occurs here{}", opt_via), + format!("{} construction occurs here{}", container_name, opt_via), ); err.span_label(old_loan_span, format!("borrow occurs here{}", old_opt_via)); if let Some(previous_end_span) = previous_end_span { @@ -253,6 +254,7 @@ fn cannot_reborrow_already_uniquely_borrowed( self, new_loan_span: Span, + container_name: &str, desc_new: &str, opt_via: &str, kind_new: &str, @@ -275,7 +277,7 @@ err.span_label(new_loan_span, format!("borrow occurs here{}", opt_via)); err.span_label( old_loan_span, - format!("closure construction occurs here{}", old_opt_via), + format!("{} construction occurs here{}", container_name, old_opt_via), ); if let Some(previous_end_span) = previous_end_span { err.span_label(previous_end_span, "borrow from closure ends here"); @@ -474,7 +476,7 @@ ) -> DiagnosticBuilder<'cx> { let moved_path = moved_path .map(|mp| format!(": `{}`", mp)) - .unwrap_or(String::new()); + .unwrap_or_default(); let err = struct_span_err!( self, @@ -555,6 +557,29 @@ self.cannot_borrow_path_as_mutable_because(span, path, "", o) } + fn cannot_mutate_in_match_guard( + self, + mutate_span: Span, + match_span: Span, + match_place: &str, + action: &str, + o: Origin, + ) -> DiagnosticBuilder<'cx> { + let mut err = struct_span_err!( + self, + mutate_span, + E0510, + "cannot {} `{}` in match guard{OGN}", + action, + match_place, + OGN = o + ); + err.span_label(mutate_span, format!("cannot {}", action)); + err.span_label(match_span, format!("value is immutable in match guard")); + + self.cancel_if_wrong_origin(err, o) + } + fn cannot_borrow_across_generator_yield( self, span: Span, @@ -573,6 +598,22 @@ self.cancel_if_wrong_origin(err, o) } + fn cannot_borrow_across_destructor( + self, + borrow_span: Span, + o: Origin, + ) -> DiagnosticBuilder<'cx> { + let err = struct_span_err!( + self, + borrow_span, + E0713, + "borrow may still be in use when destructor runs{OGN}", + OGN = o + ); + + self.cancel_if_wrong_origin(err, o) + } + fn path_does_not_live_long_enough( self, span: Span, @@ -591,6 +632,31 @@ self.cancel_if_wrong_origin(err, o) } + fn cannot_return_reference_to_local( + self, + span: Span, + reference_desc: &str, + path_desc: &str, + o: Origin, + ) -> DiagnosticBuilder<'cx> { + let mut err = struct_span_err!( + self, + span, + E0515, + "cannot return {REFERENCE} {LOCAL}{OGN}", + REFERENCE=reference_desc, + LOCAL=path_desc, + OGN = o + ); + + err.span_label( + span, + format!("returns a {} data owned by the current function", reference_desc), + ); + + self.cancel_if_wrong_origin(err, o) + } + fn lifetime_too_short_for_reborrow( self, span: Span, @@ -676,6 +742,24 @@ self.cancel_if_wrong_origin(err, o) } + fn borrowed_data_escapes_closure( + self, + escape_span: Span, + escapes_from: &str, + o: Origin, + ) -> DiagnosticBuilder<'cx> { + let err = struct_span_err!( + self, + escape_span, + E0521, + "borrowed data escapes outside of {}{OGN}", + escapes_from, + OGN = o + ); + + self.cancel_if_wrong_origin(err, o) + } + fn thread_local_value_does_not_live_long_enough( self, span: Span, @@ -689,6 +773,22 @@ OGN = o ); + self.cancel_if_wrong_origin(err, o) + } + + fn temporary_value_borrowed_for_too_long( + self, + span: Span, + o: Origin, + ) -> DiagnosticBuilder<'cx> { + let err = struct_span_err!( + self, + span, + E0716, + "temporary value dropped while borrowed{OGN}", + OGN = o + ); + self.cancel_if_wrong_origin(err, o) } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/util/collect_writes.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/util/collect_writes.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/util/collect_writes.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/util/collect_writes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -43,24 +43,8 @@ return; } - if is_place_assignment(&place_context) { + if place_context.is_place_assignment() { self.locations.push(location); } } } - -/// Returns true if this place context represents an assignment statement -crate fn is_place_assignment(place_context: &PlaceContext) -> bool { - match *place_context { - PlaceContext::Store | PlaceContext::Call | PlaceContext::AsmOutput => true, - PlaceContext::Drop - | PlaceContext::Inspect - | PlaceContext::Borrow { .. } - | PlaceContext::Projection(..) - | PlaceContext::Copy - | PlaceContext::Move - | PlaceContext::StorageLive - | PlaceContext::StorageDead - | PlaceContext::Validate => false, - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/util/elaborate_drops.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/util/elaborate_drops.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/util/elaborate_drops.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/util/elaborate_drops.rs 2018-12-04 23:41:40.000000000 +0000 @@ -545,8 +545,9 @@ args: vec![Operand::Move(Place::Local(ref_place))], destination: Some((unit_temp, succ)), cleanup: unwind.into_option(), + from_hir_call: true, }, - source_info: self.source_info + source_info: self.source_info, }), is_cleanup: unwind.is_cleanup(), }; @@ -752,11 +753,11 @@ self.place.clone() ))); drop_block_stmts.push(self.assign(&cur, Rvalue::Cast( - CastKind::Misc, Operand::Move(tmp.clone()), iter_ty + CastKind::Misc, Operand::Move(tmp), iter_ty ))); drop_block_stmts.push(self.assign(&length_or_end, Rvalue::BinaryOp(BinOp::Offset, - Operand::Copy(cur.clone()), Operand::Move(length.clone()) + Operand::Copy(cur), Operand::Move(length) ))); } else { // index = 0 (length already pushed) @@ -903,7 +904,8 @@ func: Operand::function_handle(tcx, free_func, substs, self.source_info.span), args: args, destination: Some((unit_temp, target)), - cleanup: None + cleanup: None, + from_hir_call: false, }; // FIXME(#43234) let free_block = self.new_block(unwind, call); @@ -977,7 +979,7 @@ fn assign(&self, lhs: &Place<'tcx>, rhs: Rvalue<'tcx>) -> Statement<'tcx> { Statement { source_info: self.source_info, - kind: StatementKind::Assign(lhs.clone(), rhs) + kind: StatementKind::Assign(lhs.clone(), box rhs) } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/util/liveness.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/util/liveness.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/util/liveness.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/util/liveness.rs 2018-12-04 23:41:40.000000000 +0000 @@ -33,11 +33,13 @@ //! generator yield points, all pre-existing references are invalidated, so this //! doesn't matter). -use rustc::mir::visit::{PlaceContext, Visitor}; +use rustc::mir::visit::{ + PlaceContext, Visitor, MutatingUseContext, NonMutatingUseContext, NonUseContext, +}; use rustc::mir::Local; use rustc::mir::*; use rustc::ty::{item_path, TyCtxt}; -use rustc_data_structures::indexed_set::IdxSet; +use rustc_data_structures::bit_set::BitSet; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use rustc_data_structures::work_queue::WorkQueue; use std::fs; @@ -46,7 +48,7 @@ use transform::MirSource; use util::pretty::{dump_enabled, write_basic_block, write_mir_intro}; -pub type LiveVarSet = IdxSet; +pub type LiveVarSet = BitSet; /// This gives the result of the liveness analysis at the boundary of /// basic blocks. @@ -161,10 +163,10 @@ /////////////////////////////////////////////////////////////////////////// // DEFS - PlaceContext::Store | + PlaceContext::MutatingUse(MutatingUseContext::Store) | // This is potentially both a def and a use... - PlaceContext::AsmOutput | + PlaceContext::MutatingUse(MutatingUseContext::AsmOutput) | // We let Call define the result in both the success and // unwind cases. This is not really correct, however it @@ -172,12 +174,12 @@ // generate MIR. To do things properly, we would apply // the def in call only to the input from the success // path and not the unwind path. -nmatsakis - PlaceContext::Call | + PlaceContext::MutatingUse(MutatingUseContext::Call) | // Storage live and storage dead aren't proper defines, but we can ignore // values that come before them. - PlaceContext::StorageLive | - PlaceContext::StorageDead => Some(DefUse::Def), + PlaceContext::NonUse(NonUseContext::StorageLive) | + PlaceContext::NonUse(NonUseContext::StorageDead) => Some(DefUse::Def), /////////////////////////////////////////////////////////////////////////// // REGULAR USES @@ -186,18 +188,23 @@ // purposes of NLL, these are special in that **all** the // lifetimes appearing in the variable must be live for each regular use. - PlaceContext::Projection(..) | + PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection) | + PlaceContext::MutatingUse(MutatingUseContext::Projection) | // Borrows only consider their local used at the point of the borrow. // This won't affect the results since we use this analysis for generators // and we only care about the result at suspension points. Borrows cannot // cross suspension points so this behavior is unproblematic. - PlaceContext::Borrow { .. } | - - PlaceContext::Inspect | - PlaceContext::Copy | - PlaceContext::Move | - PlaceContext::Validate => + PlaceContext::MutatingUse(MutatingUseContext::Borrow(..)) | + PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow(..)) | + PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow(..)) | + PlaceContext::NonMutatingUse(NonMutatingUseContext::UniqueBorrow(..)) | + + PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect) | + PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) | + PlaceContext::NonMutatingUse(NonMutatingUseContext::Move) | + PlaceContext::NonUse(NonUseContext::AscribeUserTy) | + PlaceContext::NonUse(NonUseContext::Validate) => Some(DefUse::Use), /////////////////////////////////////////////////////////////////////////// @@ -208,7 +215,7 @@ // uses in drop are special because `#[may_dangle]` // attributes can affect whether lifetimes must be live. - PlaceContext::Drop => + PlaceContext::MutatingUse(MutatingUseContext::Drop) => Some(DefUse::Drop), } } @@ -243,8 +250,8 @@ // X = 5 // // Defs = {}, Uses = {X} // use(X) - self.uses.remove(&index); - self.defs.add(&index); + self.uses.remove(index); + self.defs.insert(index); } fn add_use(&mut self, index: V) { @@ -258,8 +265,8 @@ // X = 5 // // Defs = {}, Uses = {X} // use(X) - self.defs.remove(&index); - self.uses.add(&index); + self.defs.remove(index); + self.uses.insert(index); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/util/patch.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/util/patch.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/util/patch.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/util/patch.rs 2018-12-04 23:41:40.000000000 +0000 @@ -130,7 +130,7 @@ } pub fn add_assign(&mut self, loc: Location, place: Place<'tcx>, rv: Rvalue<'tcx>) { - self.add_statement(loc, StatementKind::Assign(place, rv)); + self.add_statement(loc, StatementKind::Assign(place, box rv)); } pub fn make_nop(&mut self, loc: Location) { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_mir/util/pretty.rs rustc-1.31.0+dfsg1+llvm/src/librustc_mir/util/pretty.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_mir/util/pretty.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_mir/util/pretty.rs 2018-12-04 23:41:40.000000000 +0000 @@ -502,7 +502,7 @@ local, var.ty ); - if let Some(user_ty) = var.user_ty { + for user_ty in var.user_ty.projections() { write!(indented_var, " as {:?}", user_ty).unwrap(); } indented_var.push_str(";"); @@ -536,7 +536,7 @@ writeln!(w, "{{")?; // construct a scope tree and write it out - let mut scope_tree: FxHashMap> = FxHashMap(); + let mut scope_tree: FxHashMap> = Default::default(); for (index, scope_data) in mir.source_scopes.iter().enumerate() { if let Some(parent) = scope_data.parent_scope { scope_tree diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_msan/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_msan/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_msan/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_msan/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,8 +10,7 @@ #![sanitizer_runtime] #![feature(alloc_system)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(sanitizer_runtime)] #![feature(staged_api)] #![no_std] diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_passes/ast_validation.rs rustc-1.31.0+dfsg1+llvm/src/librustc_passes/ast_validation.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_passes/ast_validation.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_passes/ast_validation.rs 2018-12-04 23:41:40.000000000 +0000 @@ -166,12 +166,12 @@ } } - /// With eRFC 2497, we need to check whether an expression is ambigious and warn or error + /// With eRFC 2497, we need to check whether an expression is ambiguous and warn or error /// depending on the edition, this function handles that. fn while_if_let_ambiguity(&self, expr: &P) { if let Some((span, op_kind)) = self.while_if_let_expr_ambiguity(&expr) { let mut err = self.err_handler().struct_span_err( - span, &format!("ambigious use of `{}`", op_kind.to_string()) + span, &format!("ambiguous use of `{}`", op_kind.to_string()) ); err.note( @@ -182,8 +182,9 @@ ); if let Ok(snippet) = self.session.source_map().span_to_snippet(span) { - err.span_suggestion( + err.span_suggestion_with_applicability( span, "consider adding parentheses", format!("({})", snippet), + Applicability::MachineApplicable, ); } @@ -192,9 +193,9 @@ } /// With eRFC 2497 adding if-let chains, there is a requirement that the parsing of - /// `&&` and `||` in a if-let statement be unambigious. This function returns a span and - /// a `BinOpKind` (either `&&` or `||` depending on what was ambigious) if it is determined - /// that the current expression parsed is ambigious and will break in future. + /// `&&` and `||` in a if-let statement be unambiguous. This function returns a span and + /// a `BinOpKind` (either `&&` or `||` depending on what was ambiguous) if it is determined + /// that the current expression parsed is ambiguous and will break in future. fn while_if_let_expr_ambiguity(&self, expr: &P) -> Option<(Span, BinOpKind)> { debug!("while_if_let_expr_ambiguity: expr.node: {:?}", expr.node); match &expr.node { @@ -202,12 +203,12 @@ Some((expr.span, op.node)) }, ExprKind::Range(ref lhs, ref rhs, _) => { - let lhs_ambigious = lhs.as_ref() + let lhs_ambiguous = lhs.as_ref() .and_then(|lhs| self.while_if_let_expr_ambiguity(lhs)); - let rhs_ambigious = rhs.as_ref() + let rhs_ambiguous = rhs.as_ref() .and_then(|rhs| self.while_if_let_expr_ambiguity(rhs)); - lhs_ambigious.or(rhs_ambigious) + lhs_ambiguous.or(rhs_ambiguous) } _ => None, } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_passes/hir_stats.rs rustc-1.31.0+dfsg1+llvm/src/librustc_passes/hir_stats.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_passes/hir_stats.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_passes/hir_stats.rs 2018-12-04 23:41:40.000000000 +0000 @@ -41,8 +41,8 @@ pub fn print_hir_stats(krate: &hir::Crate) { let mut collector = StatCollector { krate: Some(krate), - data: FxHashMap(), - seen: FxHashSet(), + data: FxHashMap::default(), + seen: FxHashSet::default(), }; hir_visit::walk_crate(&mut collector, krate); collector.print("HIR STATS"); @@ -51,8 +51,8 @@ pub fn print_ast_stats<'v>(krate: &'v ast::Crate, title: &str) { let mut collector = StatCollector { krate: None, - data: FxHashMap(), - seen: FxHashSet(), + data: FxHashMap::default(), + seen: FxHashSet::default(), }; ast_visit::walk_crate(&mut collector, krate); collector.print(title); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_passes/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_passes/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_passes/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_passes/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -18,8 +18,7 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(rustc_diagnostic_macros)] #[macro_use] diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_passes/loops.rs rustc-1.31.0+dfsg1+llvm/src/librustc_passes/loops.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_passes/loops.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_passes/loops.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,6 +16,7 @@ use rustc::hir::{self, Node, Destination}; use syntax::ast; use syntax_pos::Span; +use errors::Applicability; #[derive(Clone, Copy, Debug, PartialEq)] enum LoopKind { @@ -140,11 +141,16 @@ .span_label(e.span, "can only break with a value inside \ `loop` or breakable block") - .span_suggestion(e.span, - &format!("instead, use `break` on its own \ - without a value inside this `{}` loop", - kind.name()), - "break".to_string()) + .span_suggestion_with_applicability( + e.span, + &format!( + "instead, use `break` on its own \ + without a value inside this `{}` loop", + kind.name() + ), + "break".to_string(), + Applicability::MaybeIncorrect, + ) .emit(); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_passes/mir_stats.rs rustc-1.31.0+dfsg1+llvm/src/librustc_passes/mir_stats.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_passes/mir_stats.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_passes/mir_stats.rs 2018-12-04 23:41:40.000000000 +0000 @@ -82,7 +82,7 @@ self.record("Statement", statement); self.record(match statement.kind { StatementKind::Assign(..) => "StatementKind::Assign", - StatementKind::ReadForMatch(..) => "StatementKind::ReadForMatch", + StatementKind::FakeRead(..) => "StatementKind::FakeRead", StatementKind::EndRegion(..) => "StatementKind::EndRegion", StatementKind::Validate(..) => "StatementKind::Validate", StatementKind::SetDiscriminant { .. } => "StatementKind::SetDiscriminant", @@ -211,7 +211,6 @@ fn visit_projection_elem(&mut self, place: &PlaceElem<'tcx>, - context: mir_visit::PlaceContext<'tcx>, location: Location) { self.record("PlaceElem", place); self.record(match *place { @@ -222,7 +221,7 @@ ProjectionElem::ConstantIndex { .. } => "PlaceElem::ConstantIndex", ProjectionElem::Downcast(..) => "PlaceElem::Downcast", }, place); - self.super_projection_elem(place, context, location); + self.super_projection_elem(place, location); } fn visit_constant(&mut self, constant: &Constant<'tcx>, location: Location) { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_passes/rvalue_promotion.rs rustc-1.31.0+dfsg1+llvm/src/librustc_passes/rvalue_promotion.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_passes/rvalue_promotion.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_passes/rvalue_promotion.rs 2018-12-04 23:41:40.000000000 +0000 @@ -27,7 +27,6 @@ use rustc::ty::cast::CastKind; use rustc::hir::def::{Def, CtorKind}; use rustc::hir::def_id::DefId; -use rustc::hir::map::blocks::FnLikeNode; use rustc::middle::expr_use_visitor as euv; use rustc::middle::mem_categorization as mc; use rustc::middle::mem_categorization::Categorization; @@ -38,7 +37,6 @@ use rustc::hir; use rustc_data_structures::sync::Lrc; use syntax::ast; -use syntax::attr; use syntax_pos::{Span, DUMMY_SP}; use self::Promotability::*; use std::ops::{BitAnd, BitAndAssign, BitOr}; @@ -160,41 +158,15 @@ } } - fn handle_const_fn_call(&mut self, def_id: DefId, - ret_ty: Ty<'gcx>, span: Span) -> Promotability { - if self.type_promotability(ret_ty) == NotPromotable { - return NotPromotable; - } - - let node_check = if let Some(fn_id) = self.tcx.hir.as_local_node_id(def_id) { - FnLikeNode::from_node(self.tcx.hir.get(fn_id)).map_or(false, |fn_like| { - fn_like.constness() == hir::Constness::Const - }) + fn handle_const_fn_call( + &mut self, + def_id: DefId, + ) -> Promotability { + if self.tcx.is_promotable_const_fn(def_id) { + Promotable } else { - self.tcx.is_const_fn(def_id) - }; - - if !node_check { - return NotPromotable + NotPromotable } - - if let Some(&attr::Stability { - const_stability: Some(ref feature_name), - .. }) = self.tcx.lookup_stability(def_id) { - let stable_check = - // feature-gate is enabled, - self.tcx.features() - .declared_lib_features - .iter() - .any(|&(ref sym, _)| sym == feature_name) || - - // this comes from a macro that has #[allow_internal_unstable] - span.allows_unstable(); - if !stable_check { - return NotPromotable - } - }; - Promotable } /// While the `ExprUseVisitor` walks, we will identify which @@ -348,7 +320,7 @@ return NotPromotable; } match v.tables.node_id_to_type(lhs.hir_id).sty { - ty::RawPtr(_) => { + ty::RawPtr(_) | ty::FnPtr(..) => { assert!(op.node == hir::BinOpKind::Eq || op.node == hir::BinOpKind::Ne || op.node == hir::BinOpKind::Le || op.node == hir::BinOpKind::Lt || op.node == hir::BinOpKind::Ge || op.node == hir::BinOpKind::Gt); @@ -443,14 +415,10 @@ Def::StructCtor(_, CtorKind::Fn) | Def::VariantCtor(_, CtorKind::Fn) | Def::SelfCtor(..) => Promotable, - Def::Fn(did) => { - v.handle_const_fn_call(did, node_ty, e.span) - } + Def::Fn(did) => v.handle_const_fn_call(did), Def::Method(did) => { match v.tcx.associated_item(did).container { - ty::ImplContainer(_) => { - v.handle_const_fn_call(did, node_ty, e.span) - } + ty::ImplContainer(_) => v.handle_const_fn_call(did), ty::TraitContainer(_) => NotPromotable, } } @@ -466,16 +434,13 @@ if let Some(def) = v.tables.type_dependent_defs().get(e.hir_id) { let def_id = def.def_id(); match v.tcx.associated_item(def_id).container { - ty::ImplContainer(_) => { - method_call_result = method_call_result - & v.handle_const_fn_call(def_id, node_ty, e.span); - } - ty::TraitContainer(_) => return NotPromotable, - }; + ty::ImplContainer(_) => method_call_result & v.handle_const_fn_call(def_id), + ty::TraitContainer(_) => NotPromotable, + } } else { v.tcx.sess.delay_span_bug(e.span, "no type-dependent def for method call"); + NotPromotable } - method_call_result } hir::ExprKind::Struct(ref _qpath, ref hirvec, ref option_expr) => { let mut struct_result = Promotable; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_platform_intrinsics/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_platform_intrinsics/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_platform_intrinsics/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_platform_intrinsics/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,8 +10,7 @@ #![allow(nonstandard_style)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] pub struct Intrinsic { pub inputs: &'static [&'static Type], diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_plugin/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_plugin/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_plugin/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_plugin/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -64,8 +64,7 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(rustc_diagnostic_macros)] #[macro_use] extern crate syntax; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_privacy/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_privacy/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_privacy/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_privacy/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,8 +12,7 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(rustc_diagnostic_macros)] #![recursion_limit="256"] @@ -94,8 +93,7 @@ let ty_def_id = match self.tcx.type_of(item_def_id).sty { ty::Adt(adt, _) => adt.did, ty::Foreign(did) => did, - ty::Dynamic(ref obj, ..) if obj.principal().is_some() => - obj.principal().unwrap().def_id(), + ty::Dynamic(ref obj, ..) => obj.principal().def_id(), ty::Projection(ref proj) => proj.trait_ref(self.tcx).def_id, _ => return Some(AccessLevel::Public) }; @@ -363,9 +361,11 @@ let def_id = self.tcx.hir.local_def_id(id); if let Some(exports) = self.tcx.module_exports(def_id) { for export in exports.iter() { - if let Some(node_id) = self.tcx.hir.as_local_node_id(export.def.def_id()) { - if export.vis == ty::Visibility::Public { - self.update(node_id, Some(AccessLevel::Exported)); + if export.vis == ty::Visibility::Public { + if let Some(def_id) = export.def.opt_def_id() { + if let Some(node_id) = self.tcx.hir.as_local_node_id(def_id) { + self.update(node_id, Some(AccessLevel::Exported)); + } } } } @@ -435,7 +435,7 @@ fn predicates(&mut self) -> &mut Self { let predicates = self.ev.tcx.predicates_of(self.item_def_id); - for predicate in &predicates.predicates { + for (predicate, _) in &predicates.predicates { predicate.visit_with(self); match predicate { &ty::Predicate::Trait(poly_predicate) => { @@ -485,7 +485,7 @@ let ty_def_id = match ty.sty { ty::Adt(adt, _) => Some(adt.did), ty::Foreign(did) => Some(did), - ty::Dynamic(ref obj, ..) => obj.principal().map(|p| p.def_id()), + ty::Dynamic(ref obj, ..) => Some(obj.principal().def_id()), ty::Projection(ref proj) => Some(proj.item_def_id), ty::FnDef(def_id, ..) | ty::Closure(def_id, ..) | @@ -782,7 +782,7 @@ if self.check_trait_ref(*principal.skip_binder()) { return; } - for poly_predicate in projections { + for (poly_predicate, _) in projections { let tcx = self.tcx; if self.check_trait_ref(poly_predicate.skip_binder().projection_ty.trait_ref(tcx)) { return; @@ -957,7 +957,7 @@ } } ty::Opaque(def_id, ..) => { - for predicate in &self.tcx.predicates_of(def_id).predicates { + for (predicate, _) in &self.tcx.predicates_of(def_id).predicates { let trait_ref = match *predicate { ty::Predicate::Trait(ref poly_trait_predicate) => { Some(poly_trait_predicate.skip_binder().trait_ref) @@ -1381,8 +1381,14 @@ } fn predicates(&mut self) -> &mut Self { - let predicates = self.tcx.predicates_of(self.item_def_id); - for predicate in &predicates.predicates { + // NB: We use `explicit_predicates_of` and not `predicates_of` + // because we don't want to report privacy errors due to where + // clauses that the compiler inferred. We only want to + // consider the ones that the user wrote. This is important + // for the inferred outlives rules; see + // `src/test/ui/rfc-2093-infer-outlives/privacy.rs`. + let predicates = self.tcx.explicit_predicates_of(self.item_def_id); + for (predicate, _) in &predicates.predicates { predicate.visit_with(self); match predicate { &ty::Predicate::Trait(poly_predicate) => { @@ -1451,7 +1457,7 @@ let ty_def_id = match ty.sty { ty::Adt(adt, _) => Some(adt.did), ty::Foreign(did) => Some(did), - ty::Dynamic(ref obj, ..) => obj.principal().map(|p| p.def_id()), + ty::Dynamic(ref obj, ..) => Some(obj.principal().def_id()), ty::Projection(ref proj) => { if self.required_visibility == ty::Visibility::Invisible { // Conservatively approximate the whole type alias as public without @@ -1728,7 +1734,7 @@ in_body: false, span: krate.span, empty_tables: &empty_tables, - visited_opaque_tys: FxHashSet() + visited_opaque_tys: FxHashSet::default() }; intravisit::walk_crate(&mut visitor, krate); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_resolve/build_reduced_graph.rs rustc-1.31.0+dfsg1+llvm/src/librustc_resolve/build_reduced_graph.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_resolve/build_reduced_graph.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_resolve/build_reduced_graph.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,8 +16,8 @@ use macros::{InvocationData, ParentScope, LegacyScope}; use resolve_imports::ImportDirective; use resolve_imports::ImportDirectiveSubclass::{self, GlobImport, SingleImport}; -use {Module, ModuleData, ModuleKind, NameBinding, NameBindingKind, ToNameBinding}; -use {ModuleOrUniformRoot, PerNS, Resolver, ResolverArenas}; +use {Module, ModuleData, ModuleKind, NameBinding, NameBindingKind, Segment, ToNameBinding}; +use {ModuleOrUniformRoot, PerNS, Resolver, ResolverArenas, ExternPreludeEntry}; use Namespace::{self, TypeNS, ValueNS, MacroNS}; use {resolve_error, resolve_struct_error, ResolutionError}; @@ -28,13 +28,14 @@ use rustc_metadata::cstore::LoadedMacro; use std::cell::Cell; +use std::ptr; use rustc_data_structures::sync::Lrc; use syntax::ast::{Name, Ident}; use syntax::attr; use syntax::ast::{self, Block, ForeignItem, ForeignItemKind, Item, ItemKind, NodeId}; -use syntax::ast::{Mutability, StmtKind, TraitItem, TraitItemKind, Variant}; +use syntax::ast::{MetaItemKind, Mutability, StmtKind, TraitItem, TraitItemKind, Variant}; use syntax::ext::base::{MacroKind, SyntaxExtension}; use syntax::ext::base::Determinacy::Undetermined; use syntax::ext::hygiene::Mark; @@ -82,12 +83,6 @@ } } -#[derive(Default, PartialEq, Eq)] -struct LegacyMacroImports { - import_all: Option, - imports: Vec<(Name, Span)>, -} - impl<'a, 'cl> Resolver<'a, 'cl> { /// Defines `name` in namespace `ns` of module `parent` to be `def` if it is not yet defined; /// otherwise, reports an error. @@ -116,145 +111,50 @@ fn build_reduced_graph_for_use_tree( &mut self, - root_use_tree: &ast::UseTree, - root_id: NodeId, + // This particular use tree use_tree: &ast::UseTree, id: NodeId, - vis: ty::Visibility, - parent_prefix: &[Ident], - mut uniform_paths_canary_emitted: bool, + parent_prefix: &[Segment], nested: bool, + // The whole `use` item + parent_scope: ParentScope<'a>, item: &Item, - expansion: Mark, + vis: ty::Visibility, + root_span: Span, ) { - debug!("build_reduced_graph_for_use_tree(parent_prefix={:?}, \ - uniform_paths_canary_emitted={}, \ - use_tree={:?}, nested={})", - parent_prefix, uniform_paths_canary_emitted, use_tree, nested); - - let is_prelude = attr::contains_name(&item.attrs, "prelude_import"); - let uniform_paths = - self.session.rust_2018() && - self.session.features_untracked().uniform_paths; - - let prefix_iter = || parent_prefix.iter().cloned() - .chain(use_tree.prefix.segments.iter().map(|seg| seg.ident)); - let prefix_start = prefix_iter().nth(0); - let starts_with_non_keyword = prefix_start.map_or(false, |ident| { - !ident.is_path_segment_keyword() - }); + debug!("build_reduced_graph_for_use_tree(parent_prefix={:?}, use_tree={:?}, nested={})", + parent_prefix, use_tree, nested); - // Imports are resolved as global by default, prepend `CrateRoot`, - // unless `#![feature(uniform_paths)]` is enabled. - let inject_crate_root = - !uniform_paths && - match use_tree.kind { - // HACK(eddyb) special-case `use *` to mean `use ::*`. - ast::UseTreeKind::Glob if prefix_start.is_none() => true, - _ => starts_with_non_keyword, - }; - let root = if inject_crate_root { - let span = use_tree.prefix.span.shrink_to_lo(); - Some(Ident::new(keywords::CrateRoot.name(), span)) - } else { - None - }; + let mut prefix_iter = parent_prefix.iter().cloned() + .chain(use_tree.prefix.segments.iter().map(|seg| seg.into())).peekable(); - let prefix: Vec<_> = root.into_iter().chain(prefix_iter()).collect(); + // On 2015 edition imports are resolved as crate-relative by default, + // so prefixes are prepended with crate root segment if necessary. + // The root is prepended lazily, when the first non-empty prefix or terminating glob + // appears, so imports in braced groups can have roots prepended independently. + // 2015 identifiers used on global 2018 edition enter special "virtual 2015 mode", don't + // get crate root prepended, but get special treatment during in-scope resolution instead. + let is_glob = if let ast::UseTreeKind::Glob = use_tree.kind { true } else { false }; + let crate_root = match prefix_iter.peek() { + Some(seg) if !seg.ident.is_path_segment_keyword() && + seg.ident.span.rust_2015() && self.session.rust_2015() => { + Some(seg.ident.span.ctxt()) + } + None if is_glob && use_tree.span.rust_2015() => { + Some(use_tree.span.ctxt()) + } + _ => None, + }.map(|ctxt| Segment::from_ident(Ident::new( + keywords::CrateRoot.name(), use_tree.prefix.span.shrink_to_lo().with_ctxt(ctxt) + ))); + let prefix = crate_root.into_iter().chain(prefix_iter).collect::>(); debug!("build_reduced_graph_for_use_tree: prefix={:?}", prefix); - // `#[feature(uniform_paths)]` allows an unqualified import path, - // e.g. `use x::...;` to resolve not just globally (`use ::x::...;`) - // but also relatively (`use self::x::...;`). To catch ambiguities - // that might arise from both of these being available and resolution - // silently picking one of them, an artificial `use self::x as _;` - // import is injected as a "canary", and an error is emitted if it - // successfully resolves while an `x` external crate exists. - // - // For each block scope around the `use` item, one special canary - // import of the form `use x as _;` is also injected, having its - // parent set to that scope; `resolve_imports` will only resolve - // it within its appropriate scope; if any of them successfully - // resolve, an ambiguity error is emitted, since the original - // import can't see the item in the block scope (`self::x` only - // looks in the enclosing module), but a non-`use` path could. - // - // Additionally, the canary might be able to catch limitations of the - // current implementation, where `::x` may be chosen due to `self::x` - // not existing, but `self::x` could appear later, from macro expansion. - // - // NB. The canary currently only errors if the `x::...` path *could* - // resolve as a relative path through the extern crate, i.e. `x` is - // in `extern_prelude`, *even though* `::x` might still forcefully - // load a non-`extern_prelude` crate. - // While always producing an ambiguity errors if `self::x` exists and - // a crate *could* be loaded, would be more conservative, imports for - // local modules named `test` (or less commonly, `syntax` or `log`), - // would need to be qualified (e.g. `self::test`), which is considered - // ergonomically unacceptable. - let emit_uniform_paths_canary = - !uniform_paths_canary_emitted && - self.session.rust_2018() && - starts_with_non_keyword; - if emit_uniform_paths_canary { - let source = prefix_start.unwrap(); - - // Helper closure to emit a canary with the given base path. - let emit = |this: &mut Self, base: Option| { - let subclass = SingleImport { - target: Ident { - name: keywords::Underscore.name().gensymed(), - span: source.span, - }, - source, - result: PerNS { - type_ns: Cell::new(Err(Undetermined)), - value_ns: Cell::new(Err(Undetermined)), - macro_ns: Cell::new(Err(Undetermined)), - }, - type_ns_only: false, - }; - this.add_import_directive( - base.into_iter().collect(), - subclass.clone(), - source.span, - id, - root_use_tree.span, - root_id, - ty::Visibility::Invisible, - expansion, - true, // is_uniform_paths_canary - ); - }; - - // A single simple `self::x` canary. - emit(self, Some(Ident { - name: keywords::SelfValue.name(), - span: source.span, - })); - - // One special unprefixed canary per block scope around - // the import, to detect items unreachable by `self::x`. - let orig_current_module = self.current_module; - let mut span = source.span.modern(); - loop { - match self.current_module.kind { - ModuleKind::Block(..) => emit(self, None), - ModuleKind::Def(..) => break, - } - match self.hygienic_lexical_parent(self.current_module, &mut span) { - Some(module) => { - self.current_module = module; - } - None => break, - } - } - self.current_module = orig_current_module; - - uniform_paths_canary_emitted = true; - } - + let empty_for_self = |prefix: &[Segment]| { + prefix.is_empty() || + prefix.len() == 1 && prefix[0].ident.name == keywords::CrateRoot.name() + }; match use_tree.kind { ast::UseTreeKind::Simple(rename, ..) => { let mut ident = use_tree.ident(); @@ -264,13 +164,10 @@ if nested { // Correctly handle `self` - if source.name == keywords::SelfValue.name() { + if source.ident.name == keywords::SelfValue.name() { type_ns_only = true; - let empty_prefix = module_path.last().map_or(true, |ident| { - ident.name == keywords::CrateRoot.name() - }); - if empty_prefix { + if empty_for_self(&module_path) { resolve_error( self, use_tree.span, @@ -283,20 +180,20 @@ // Replace `use foo::self;` with `use foo;` source = module_path.pop().unwrap(); if rename.is_none() { - ident = source; + ident = source.ident; } } } else { // Disallow `self` - if source.name == keywords::SelfValue.name() { + if source.ident.name == keywords::SelfValue.name() { resolve_error(self, use_tree.span, ResolutionError::SelfImportsOnlyAllowedWithin); } // Disallow `use $crate;` - if source.name == keywords::DollarCrate.name() && module_path.is_empty() { - let crate_root = self.resolve_crate_root(source); + if source.ident.name == keywords::DollarCrate.name() && module_path.is_empty() { + let crate_root = self.resolve_crate_root(source.ident); let crate_name = match crate_root.kind { ModuleKind::Def(_, name) => name, ModuleKind::Block(..) => unreachable!(), @@ -306,11 +203,14 @@ // while the current crate doesn't have a valid `crate_name`. if crate_name != keywords::Invalid.name() { // `crate_name` should not be interpreted as relative. - module_path.push(Ident { - name: keywords::CrateRoot.name(), - span: source.span, + module_path.push(Segment { + ident: Ident { + name: keywords::CrateRoot.name(), + span: source.ident.span, + }, + id: Some(self.session.next_node_id()), }); - source.name = crate_name; + source.ident.name = crate_name; } if rename.is_none() { ident.name = crate_name; @@ -331,7 +231,7 @@ let subclass = SingleImport { target: ident, - source, + source: source.ident, result: PerNS { type_ns: Cell::new(Err(Undetermined)), value_ns: Cell::new(Err(Undetermined)), @@ -344,16 +244,15 @@ subclass, use_tree.span, id, - root_use_tree.span, - root_id, + root_span, + item.id, vis, - expansion, - false, // is_uniform_paths_canary + parent_scope, ); } ast::UseTreeKind::Glob => { let subclass = GlobImport { - is_prelude, + is_prelude: attr::contains_name(&item.attrs, "prelude_import"), max_vis: Cell::new(ty::Visibility::Invisible), }; self.add_import_directive( @@ -361,11 +260,10 @@ subclass, use_tree.span, id, - root_use_tree.span, - root_id, + root_span, + item.id, vis, - expansion, - false, // is_uniform_paths_canary + parent_scope, ); } ast::UseTreeKind::Nested(ref items) => { @@ -393,16 +291,34 @@ for &(ref tree, id) in items { self.build_reduced_graph_for_use_tree( - root_use_tree, - root_id, - tree, - id, - vis, - &prefix, - uniform_paths_canary_emitted, - true, - item, - expansion, + // This particular use tree + tree, id, &prefix, true, + // The whole `use` item + parent_scope.clone(), item, vis, root_span, + ); + } + + // Empty groups `a::b::{}` are turned into synthetic `self` imports + // `a::b::c::{self as _}`, so that their prefixes are correctly + // resolved and checked for privacy/stability/etc. + if items.is_empty() && !empty_for_self(&prefix) { + let new_span = prefix[prefix.len() - 1].ident.span; + let tree = ast::UseTree { + prefix: ast::Path::from_ident( + Ident::new(keywords::SelfValue.name(), new_span) + ), + kind: ast::UseTreeKind::Simple( + Some(Ident::new(keywords::Underscore.name().gensymed(), new_span)), + ast::DUMMY_NODE_ID, + ast::DUMMY_NODE_ID, + ), + span: use_tree.span, + }; + self.build_reduced_graph_for_use_tree( + // This particular use tree + &tree, id, &prefix, true, + // The whole `use` item + parent_scope.clone(), item, ty::Visibility::Invisible, root_span, ); } } @@ -410,8 +326,9 @@ } /// Constructs the reduced graph for one item. - fn build_reduced_graph_for_item(&mut self, item: &Item, expansion: Mark) { - let parent = self.current_module; + fn build_reduced_graph_for_item(&mut self, item: &Item, parent_scope: ParentScope<'a>) { + let parent = parent_scope.module; + let expansion = parent_scope.expansion; let ident = item.ident; let sp = item.span; let vis = self.resolve_visibility(&item.vis); @@ -419,16 +336,10 @@ match item.node { ItemKind::Use(ref use_tree) => { self.build_reduced_graph_for_use_tree( - use_tree, - item.id, - use_tree, - item.id, - vis, - &[], - false, // uniform_paths_canary_emitted - false, - item, - expansion, + // This particular use tree + use_tree, item.id, &[], false, + // The whole `use` item + parent_scope, item, vis, use_tree.span, ); } @@ -437,35 +348,55 @@ let module = self.get_module(DefId { krate: crate_id, index: CRATE_DEF_INDEX }); self.populate_module_if_necessary(module); - if injected_crate_name().map_or(false, |name| item.ident.name == name) { + if injected_crate_name().map_or(false, |name| ident.name == name) { self.injected_crate = Some(module); } - let used = self.process_legacy_macro_imports(item, module, expansion); + let used = self.process_legacy_macro_imports(item, module, &parent_scope); let binding = (module, ty::Visibility::Public, sp, expansion).to_name_binding(self.arenas); let directive = self.arenas.alloc_import_directive(ImportDirective { root_id: item.id, id: item.id, - parent, + parent_scope, imported_module: Cell::new(Some(ModuleOrUniformRoot::Module(module))), - subclass: ImportDirectiveSubclass::ExternCrate(orig_name), + subclass: ImportDirectiveSubclass::ExternCrate { + source: orig_name, + target: ident, + }, root_span: item.span, span: item.span, module_path: Vec::new(), vis: Cell::new(vis), - expansion, used: Cell::new(used), - is_uniform_paths_canary: false, }); self.potentially_unused_imports.push(directive); let imported_binding = self.import(binding, directive); + if ptr::eq(self.current_module, self.graph_root) { + if let Some(entry) = self.extern_prelude.get(&ident.modern()) { + if expansion != Mark::root() && orig_name.is_some() && + entry.extern_crate_item.is_none() { + self.session.span_err(item.span, "macro-expanded `extern crate` items \ + cannot shadow names passed with \ + `--extern`"); + } + } + let entry = self.extern_prelude.entry(ident.modern()) + .or_insert(ExternPreludeEntry { + extern_crate_item: None, + introduced_by_item: true, + }); + entry.extern_crate_item = Some(imported_binding); + if orig_name.is_some() { + entry.introduced_by_item = true; + } + } self.define(parent, ident, TypeNS, imported_binding); } ItemKind::GlobalAsm(..) => {} - ItemKind::Mod(..) if item.ident == keywords::Invalid.ident() => {} // Crate root + ItemKind::Mod(..) if ident == keywords::Invalid.ident() => {} // Crate root ItemKind::Mod(..) => { let def_id = self.definitions.local_def_id(item.id); @@ -827,35 +758,52 @@ } // This returns true if we should consider the underlying `extern crate` to be used. - fn process_legacy_macro_imports(&mut self, item: &Item, module: Module<'a>, expansion: Mark) - -> bool { - let allow_shadowing = expansion == Mark::root(); - let legacy_imports = self.legacy_macro_imports(&item.attrs); - let used = legacy_imports != LegacyMacroImports::default(); - - // `#[macro_use]` is only allowed at the crate root. - if self.current_module.parent.is_some() && used { - span_err!(self.session, item.span, E0468, - "an `extern crate` loading macros must be at the crate root"); + fn process_legacy_macro_imports(&mut self, item: &Item, module: Module<'a>, + parent_scope: &ParentScope<'a>) -> bool { + let mut import_all = None; + let mut single_imports = Vec::new(); + for attr in &item.attrs { + if attr.check_name("macro_use") { + if self.current_module.parent.is_some() { + span_err!(self.session, item.span, E0468, + "an `extern crate` loading macros must be at the crate root"); + } + let ill_formed = |span| span_err!(self.session, span, E0466, "bad macro import"); + match attr.meta() { + Some(meta) => match meta.node { + MetaItemKind::Word => { + import_all = Some(meta.span); + break; + } + MetaItemKind::List(nested_metas) => for nested_meta in nested_metas { + match nested_meta.word() { + Some(word) => single_imports.push((word.name(), word.span)), + None => ill_formed(nested_meta.span), + } + } + MetaItemKind::NameValue(..) => ill_formed(meta.span), + } + None => ill_formed(attr.span()), + } + } } - let (graph_root, arenas) = (self.graph_root, self.arenas); + let arenas = self.arenas; let macro_use_directive = |span| arenas.alloc_import_directive(ImportDirective { root_id: item.id, id: item.id, - parent: graph_root, + parent_scope: parent_scope.clone(), imported_module: Cell::new(Some(ModuleOrUniformRoot::Module(module))), subclass: ImportDirectiveSubclass::MacroUse, root_span: span, span, module_path: Vec::new(), vis: Cell::new(ty::Visibility::Restricted(DefId::local(CRATE_DEF_INDEX))), - expansion, used: Cell::new(false), - is_uniform_paths_canary: false, }); - if let Some(span) = legacy_imports.import_all { + let allow_shadowing = parent_scope.expansion == Mark::root(); + if let Some(span) = import_all { let directive = macro_use_directive(span); self.potentially_unused_imports.push(directive); module.for_each_child(|ident, ns, binding| if ns == MacroNS { @@ -863,12 +811,13 @@ self.legacy_import_macro(ident.name, imported_binding, span, allow_shadowing); }); } else { - for (name, span) in legacy_imports.imports { + for (name, span) in single_imports.iter().cloned() { let ident = Ident::with_empty_ctxt(name); let result = self.resolve_ident_in_module( ModuleOrUniformRoot::Module(module), ident, MacroNS, + None, false, span, ); @@ -882,7 +831,7 @@ } } } - used + import_all.is_some() || !single_imports.is_empty() } // does this attribute list contain "macro_use"? @@ -908,25 +857,6 @@ false } - - fn legacy_macro_imports(&mut self, attrs: &[ast::Attribute]) -> LegacyMacroImports { - let mut imports = LegacyMacroImports::default(); - for attr in attrs { - if attr.check_name("macro_use") { - match attr.meta_item_list() { - Some(names) => for attr in names { - if let Some(word) = attr.word() { - imports.imports.push((word.name(), attr.span())); - } else { - span_err!(self.session, attr.span(), E0466, "bad macro import"); - } - }, - None => imports.import_all = Some(attr.span), - } - } - } - imports - } } pub struct BuildReducedGraphVisitor<'a, 'b: 'a, 'c: 'b> { @@ -942,7 +872,6 @@ let invocation = self.resolver.invocations[&mark]; invocation.module.set(self.resolver.current_module); invocation.parent_legacy_scope.set(self.current_legacy_scope); - invocation.output_legacy_scope.set(self.current_legacy_scope); invocation } } @@ -981,7 +910,13 @@ let orig_current_module = self.resolver.current_module; let orig_current_legacy_scope = self.current_legacy_scope; - self.resolver.build_reduced_graph_for_item(item, self.expansion); + let parent_scope = ParentScope { + module: self.resolver.current_module, + expansion: self.expansion, + legacy: self.current_legacy_scope, + derives: Vec::new(), + }; + self.resolver.build_reduced_graph_for_item(item, parent_scope); visit::walk_item(self, item); self.resolver.current_module = orig_current_module; if !macro_use { @@ -1048,13 +983,10 @@ fn visit_token(&mut self, t: Token) { if let Token::Interpolated(nt) = t { - match nt.0 { - token::NtExpr(ref expr) => { - if let ast::ExprKind::Mac(..) = expr.node { - self.visit_invoc(expr.id); - } + if let token::NtExpr(ref expr) = nt.0 { + if let ast::ExprKind::Mac(..) = expr.node { + self.visit_invoc(expr.id); } - _ => {} } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_resolve/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/librustc_resolve/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/librustc_resolve/Cargo.toml 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_resolve/Cargo.toml 2018-12-04 23:41:40.000000000 +0000 @@ -10,6 +10,7 @@ test = false [dependencies] +bitflags = "1.0" log = "0.4" syntax = { path = "../libsyntax" } rustc = { path = "../librustc" } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_resolve/check_unused.rs rustc-1.31.0+dfsg1+llvm/src/librustc_resolve/check_unused.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_resolve/check_unused.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_resolve/check_unused.rs 2018-12-04 23:41:40.000000000 +0000 @@ -109,7 +109,7 @@ self.item_span }; - if items.len() == 0 { + if items.is_empty() { self.unused_imports .entry(self.base_id) .or_default() @@ -144,7 +144,7 @@ } } } - ImportDirectiveSubclass::ExternCrate(_) => { + ImportDirectiveSubclass::ExternCrate { .. } => { resolver.maybe_unused_extern_crates.push((directive.id, directive.span)); } ImportDirectiveSubclass::MacroUse => { @@ -170,7 +170,7 @@ for (id, spans) in &visitor.unused_imports { let len = spans.len(); - let mut spans = spans.values().map(|s| *s).collect::>(); + let mut spans = spans.values().cloned().collect::>(); spans.sort(); let ms = MultiSpan::from_spans(spans.clone()); let mut span_snippets = spans.iter() @@ -183,7 +183,7 @@ span_snippets.sort(); let msg = format!("unused import{}{}", if len > 1 { "s" } else { "" }, - if span_snippets.len() > 0 { + if !span_snippets.is_empty() { format!(": {}", span_snippets.join(", ")) } else { String::new() diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_resolve/diagnostics.rs rustc-1.31.0+dfsg1+llvm/src/librustc_resolve/diagnostics.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_resolve/diagnostics.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_resolve/diagnostics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -1253,7 +1253,7 @@ ```compile_fail,E0433 let map = HashMap::new(); -// error: failed to resolve. Use of undeclared type or module `HashMap` +// error: failed to resolve: use of undeclared type or module `HashMap` ``` Please verify you didn't misspell the type/module's name or that you didn't diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_resolve/error_reporting.rs rustc-1.31.0+dfsg1+llvm/src/librustc_resolve/error_reporting.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_resolve/error_reporting.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_resolve/error_reporting.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,169 @@ +// Copyright 2012-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use {CrateLint, PathResult, Segment}; +use macros::ParentScope; + +use syntax::symbol::keywords; +use syntax_pos::Span; + +use resolve_imports::ImportResolver; +use std::cmp::Reverse; + +impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> { + /// Add suggestions for a path that cannot be resolved. + pub(crate) fn make_path_suggestion( + &mut self, + span: Span, + mut path: Vec, + parent_scope: &ParentScope<'b>, + ) -> Option<(Vec, Option)> { + debug!("make_path_suggestion: span={:?} path={:?}", span, path); + + match (path.get(0), path.get(1)) { + // `{{root}}::ident::...` on both editions. + // On 2015 `{{root}}` is usually added implicitly. + (Some(fst), Some(snd)) if fst.ident.name == keywords::CrateRoot.name() && + !snd.ident.is_path_segment_keyword() => {} + // `ident::...` on 2018 + (Some(fst), _) if fst.ident.span.rust_2018() && + !fst.ident.is_path_segment_keyword() => { + // Insert a placeholder that's later replaced by `self`/`super`/etc. + path.insert(0, Segment::from_ident(keywords::Invalid.ident())); + } + _ => return None, + } + + self.make_missing_self_suggestion(span, path.clone(), parent_scope) + .or_else(|| self.make_missing_crate_suggestion(span, path.clone(), parent_scope)) + .or_else(|| self.make_missing_super_suggestion(span, path.clone(), parent_scope)) + .or_else(|| self.make_external_crate_suggestion(span, path, parent_scope)) + } + + /// Suggest a missing `self::` if that resolves to an correct module. + /// + /// ``` + /// | + /// LL | use foo::Bar; + /// | ^^^ did you mean `self::foo`? + /// ``` + fn make_missing_self_suggestion( + &mut self, + span: Span, + mut path: Vec, + parent_scope: &ParentScope<'b>, + ) -> Option<(Vec, Option)> { + // Replace first ident with `self` and check if that is valid. + path[0].ident.name = keywords::SelfValue.name(); + let result = self.resolve_path(&path, None, parent_scope, false, span, CrateLint::No); + debug!("make_missing_self_suggestion: path={:?} result={:?}", path, result); + if let PathResult::Module(..) = result { + Some((path, None)) + } else { + None + } + } + + /// Suggest a missing `crate::` if that resolves to an correct module. + /// + /// ``` + /// | + /// LL | use foo::Bar; + /// | ^^^ did you mean `crate::foo`? + /// ``` + fn make_missing_crate_suggestion( + &mut self, + span: Span, + mut path: Vec, + parent_scope: &ParentScope<'b>, + ) -> Option<(Vec, Option)> { + // Replace first ident with `crate` and check if that is valid. + path[0].ident.name = keywords::Crate.name(); + let result = self.resolve_path(&path, None, parent_scope, false, span, CrateLint::No); + debug!("make_missing_crate_suggestion: path={:?} result={:?}", path, result); + if let PathResult::Module(..) = result { + Some(( + path, + Some( + "`use` statements changed in Rust 2018; read more at \ + ".to_string() + ), + )) + } else { + None + } + } + + /// Suggest a missing `super::` if that resolves to an correct module. + /// + /// ``` + /// | + /// LL | use foo::Bar; + /// | ^^^ did you mean `super::foo`? + /// ``` + fn make_missing_super_suggestion( + &mut self, + span: Span, + mut path: Vec, + parent_scope: &ParentScope<'b>, + ) -> Option<(Vec, Option)> { + // Replace first ident with `crate` and check if that is valid. + path[0].ident.name = keywords::Super.name(); + let result = self.resolve_path(&path, None, parent_scope, false, span, CrateLint::No); + debug!("make_missing_super_suggestion: path={:?} result={:?}", path, result); + if let PathResult::Module(..) = result { + Some((path, None)) + } else { + None + } + } + + /// Suggest a missing external crate name if that resolves to an correct module. + /// + /// ``` + /// | + /// LL | use foobar::Baz; + /// | ^^^^^^ did you mean `baz::foobar`? + /// ``` + /// + /// Used when importing a submodule of an external crate but missing that crate's + /// name as the first part of path. + fn make_external_crate_suggestion( + &mut self, + span: Span, + mut path: Vec, + parent_scope: &ParentScope<'b>, + ) -> Option<(Vec, Option)> { + if path[1].ident.span.rust_2015() { + return None; + } + + // Sort extern crate names in reverse order to get + // 1) some consistent ordering for emitted dignostics and + // 2) `std` suggestions before `core` suggestions. + let mut extern_crate_names = + self.resolver.extern_prelude.iter().map(|(ident, _)| ident.name).collect::>(); + extern_crate_names.sort_by_key(|name| Reverse(name.as_str())); + + for name in extern_crate_names.into_iter() { + // Replace first ident with a crate name and check if that is valid. + path[0].ident.name = name; + let result = self.resolve_path(&path, None, parent_scope, false, span, CrateLint::No); + debug!("make_external_crate_suggestion: name={:?} path={:?} result={:?}", + name, path, result); + if let PathResult::Module(..) = result { + return Some((path, None)); + } + } + + None + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_resolve/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_resolve/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_resolve/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_resolve/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,12 +13,14 @@ html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(crate_visibility_modifier)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(label_break_value)] +#![feature(nll)] #![feature(rustc_diagnostic_macros)] #![feature(slice_sort_by_cached_key)] #[macro_use] +extern crate bitflags; +#[macro_use] extern crate log; #[macro_use] extern crate syntax; @@ -43,8 +45,9 @@ use rustc::hir::def::*; use rustc::hir::def::Namespace::*; use rustc::hir::def_id::{CRATE_DEF_INDEX, LOCAL_CRATE, DefId}; -use rustc::ty; use rustc::hir::{Freevar, FreevarMap, TraitCandidate, TraitMap, GlobMap}; +use rustc::session::config::nightly_options; +use rustc::ty; use rustc::util::nodemap::{NodeMap, NodeSet, FxHashMap, FxHashSet, DefIdMap}; use rustc_metadata::creader::CrateLoader; @@ -84,7 +87,7 @@ // NB: This module needs to be declared first so diagnostics are // registered before they are used. mod diagnostics; - +mod error_reporting; mod macros; mod check_unused; mod build_reduced_graph; @@ -94,6 +97,18 @@ ["clippy", "rustfmt"].contains(&&*name.as_str()) } +enum Weak { + Yes, + No, +} + +enum ScopeSet { + Import(Namespace), + AbsolutePath(Namespace), + Macro(MacroKind), + Module, +} + /// A free importable items suggested in case of resolution failure. struct ImportSuggestion { path: Path, @@ -368,7 +383,7 @@ } ResolutionError::FailedToResolve(msg) => { let mut err = struct_span_err!(resolver.session, span, E0433, - "failed to resolve. {}", msg); + "failed to resolve: {}", msg); err.span_label(span, msg); err } @@ -388,14 +403,13 @@ err } ResolutionError::BindingShadowsSomethingUnacceptable(what_binding, name, binding) => { - let shadows_what = PathResolution::new(binding.def()).kind_name(); - let mut err = struct_span_err!(resolver.session, - span, - E0530, - "{}s cannot shadow {}s", what_binding, shadows_what); - err.span_label(span, format!("cannot be named the same as a {}", shadows_what)); + let shadows_what = binding.descr(); + let mut err = struct_span_err!(resolver.session, span, E0530, "{}s cannot shadow {}s", + what_binding, shadows_what); + err.span_label(span, format!("cannot be named the same as {} {}", + binding.article(), shadows_what)); let participle = if binding.is_import() { "imported" } else { "defined" }; - let msg = format!("a {} `{}` is {} here", shadows_what, name, participle); + let msg = format!("the {} `{}` is {} here", shadows_what, name, participle); err.span_label(binding.span, msg); err } @@ -479,15 +493,13 @@ TraitItem(Namespace), // Path in `pub(path)` Visibility, - // Path in `use a::b::{...};` - ImportPrefix, } impl<'a> PathSource<'a> { fn namespace(self) -> Namespace { match self { PathSource::Type | PathSource::Trait(_) | PathSource::Struct | - PathSource::Visibility | PathSource::ImportPrefix => TypeNS, + PathSource::Visibility => TypeNS, PathSource::Expr(..) | PathSource::Pat | PathSource::TupleStruct => ValueNS, PathSource::TraitItem(ns) => ns, } @@ -495,7 +507,7 @@ fn global_by_default(self) -> bool { match self { - PathSource::Visibility | PathSource::ImportPrefix => true, + PathSource::Visibility => true, PathSource::Type | PathSource::Expr(..) | PathSource::Pat | PathSource::Struct | PathSource::TupleStruct | PathSource::Trait(_) | PathSource::TraitItem(..) => false, @@ -507,7 +519,7 @@ PathSource::Type | PathSource::Expr(..) | PathSource::Pat | PathSource::Struct | PathSource::TupleStruct => true, PathSource::Trait(_) | PathSource::TraitItem(..) | - PathSource::Visibility | PathSource::ImportPrefix => false, + PathSource::Visibility => false, } } @@ -519,7 +531,6 @@ PathSource::Struct => "struct, variant or union type", PathSource::TupleStruct => "tuple struct/variant", PathSource::Visibility => "module", - PathSource::ImportPrefix => "module or enum", PathSource::TraitItem(ns) => match ns { TypeNS => "associated type", ValueNS => "method or associated constant", @@ -584,10 +595,6 @@ Def::AssociatedTy(..) if ns == TypeNS => true, _ => false, }, - PathSource::ImportPrefix => match def { - Def::Mod(..) | Def::Enum(..) => true, - _ => false, - }, PathSource::Visibility => match def { Def::Mod(..) => true, _ => false, @@ -623,8 +630,45 @@ (PathSource::Pat, false) | (PathSource::TupleStruct, false) => "E0531", (PathSource::TraitItem(..), true) => "E0575", (PathSource::TraitItem(..), false) => "E0576", - (PathSource::Visibility, true) | (PathSource::ImportPrefix, true) => "E0577", - (PathSource::Visibility, false) | (PathSource::ImportPrefix, false) => "E0578", + (PathSource::Visibility, true) => "E0577", + (PathSource::Visibility, false) => "E0578", + } + } +} + +// A minimal representation of a path segment. We use this in resolve because +// we synthesize 'path segments' which don't have the rest of an AST or HIR +// PathSegment. +#[derive(Clone, Copy, Debug)] +pub struct Segment { + ident: Ident, + id: Option, +} + +impl Segment { + fn from_path(path: &Path) -> Vec { + path.segments.iter().map(|s| s.into()).collect() + } + + fn from_ident(ident: Ident) -> Segment { + Segment { + ident, + id: None, + } + } + + fn names_to_string(segments: &[Segment]) -> String { + names_to_string(&segments.iter() + .map(|seg| seg.ident) + .collect::>()) + } +} + +impl<'a> From<&'a ast::PathSegment> for Segment { + fn from(seg: &'a ast::PathSegment) -> Segment { + Segment { + ident: seg.ident, + id: Some(seg.id), } } } @@ -778,7 +822,7 @@ self.label_ribs.push(Rib::new(rib_kind)); // Add each argument to the rib. - let mut bindings_list = FxHashMap(); + let mut bindings_list = FxHashMap::default(); for argument in &declaration.inputs { self.resolve_pattern(&argument.pat, PatternSource::FnParam, &mut bindings_list); @@ -928,7 +972,7 @@ impl<'a> Rib<'a> { fn new(kind: RibKind<'a>) -> Rib<'a> { Rib { - bindings: FxHashMap(), + bindings: Default::default(), kind, } } @@ -961,14 +1005,35 @@ } #[derive(Copy, Clone, Debug)] -pub enum ModuleOrUniformRoot<'a> { +enum ModuleOrUniformRoot<'a> { /// Regular module. Module(Module<'a>), - /// The `{{root}}` (`CrateRoot` aka "global") / `extern` initial segment - /// in which external crates resolve, and also `crate` (only in `{{root}}`, - /// but *not* `extern`), in the Rust 2018 edition. - UniformRoot(Name), + /// Virtual module that denotes resolution in crate root with fallback to extern prelude. + CrateRootAndExternPrelude, + + /// Virtual module that denotes resolution in extern prelude. + /// Used for paths starting with `::` on 2018 edition or `extern::`. + ExternPrelude, + + /// Virtual module that denotes resolution in current scope. + /// Used only for resolving single-segment imports. The reason it exists is that import paths + /// are always split into two parts, the first of which should be some kind of module. + CurrentScope, +} + +impl<'a> PartialEq for ModuleOrUniformRoot<'a> { + fn eq(&self, other: &Self) -> bool { + match (*self, *other) { + (ModuleOrUniformRoot::Module(lhs), + ModuleOrUniformRoot::Module(rhs)) => ptr::eq(lhs, rhs), + (ModuleOrUniformRoot::CrateRootAndExternPrelude, + ModuleOrUniformRoot::CrateRootAndExternPrelude) | + (ModuleOrUniformRoot::ExternPrelude, ModuleOrUniformRoot::ExternPrelude) | + (ModuleOrUniformRoot::CurrentScope, ModuleOrUniformRoot::CurrentScope) => true, + _ => false, + } + } } #[derive(Clone, Debug)] @@ -1012,8 +1077,10 @@ normal_ancestor_id: DefId, resolutions: RefCell>>>, - legacy_macro_resolutions: RefCell, Option)>>, - macro_resolutions: RefCell, Span)>>, + single_segment_macro_resolutions: RefCell, + Option<&'a NameBinding<'a>>)>>, + multi_segment_macro_resolutions: RefCell, Span, MacroKind, ParentScope<'a>, + Option)>>, builtin_attrs: RefCell)>>, // Macro invocations that can expand into items in this module. @@ -1050,11 +1117,11 @@ parent, kind, normal_ancestor_id, - resolutions: RefCell::new(FxHashMap()), - legacy_macro_resolutions: RefCell::new(Vec::new()), - macro_resolutions: RefCell::new(Vec::new()), + resolutions: Default::default(), + single_segment_macro_resolutions: RefCell::new(Vec::new()), + multi_segment_macro_resolutions: RefCell::new(Vec::new()), builtin_attrs: RefCell::new(Vec::new()), - unresolved_invocations: RefCell::new(FxHashSet()), + unresolved_invocations: Default::default(), no_implicit_prelude: false, glob_importers: RefCell::new(Vec::new()), globs: RefCell::new(Vec::new()), @@ -1161,12 +1228,13 @@ used: Cell, }, Ambiguity { + kind: AmbiguityKind, b1: &'a NameBinding<'a>, b2: &'a NameBinding<'a>, } } -struct PrivacyError<'a>(Span, Name, &'a NameBinding<'a>); +struct PrivacyError<'a>(Span, Ident, &'a NameBinding<'a>); struct UseError<'a> { err: DiagnosticBuilder<'a>, @@ -1178,10 +1246,65 @@ better: bool, } +#[derive(Clone, Copy, PartialEq, Debug)] +enum AmbiguityKind { + Import, + AbsolutePath, + BuiltinAttr, + DeriveHelper, + LegacyHelperVsPrelude, + LegacyVsModern, + GlobVsOuter, + GlobVsGlob, + GlobVsExpanded, + MoreExpandedVsOuter, +} + +impl AmbiguityKind { + fn descr(self) -> &'static str { + match self { + AmbiguityKind::Import => + "name vs any other name during import resolution", + AmbiguityKind::AbsolutePath => + "name in the crate root vs extern crate during absolute path resolution", + AmbiguityKind::BuiltinAttr => + "built-in attribute vs any other name", + AmbiguityKind::DeriveHelper => + "derive helper attribute vs any other name", + AmbiguityKind::LegacyHelperVsPrelude => + "legacy plugin helper attribute vs name from prelude", + AmbiguityKind::LegacyVsModern => + "`macro_rules` vs non-`macro_rules` from other module", + AmbiguityKind::GlobVsOuter => + "glob import vs any other name from outer scope during import/macro resolution", + AmbiguityKind::GlobVsGlob => + "glob import vs glob import in the same module", + AmbiguityKind::GlobVsExpanded => + "glob import vs macro-expanded name in the same \ + module during import/macro resolution", + AmbiguityKind::MoreExpandedVsOuter => + "macro-expanded name vs less macro-expanded name \ + from outer scope during import/macro resolution", + } + } +} + +/// Miscellaneous bits of metadata for better ambiguity error reporting. +#[derive(Clone, Copy, PartialEq)] +enum AmbiguityErrorMisc { + SuggestCrate, + SuggestSelf, + FromPrelude, + None, +} + struct AmbiguityError<'a> { + kind: AmbiguityKind, ident: Ident, b1: &'a NameBinding<'a>, b2: &'a NameBinding<'a>, + misc1: AmbiguityErrorMisc, + misc2: AmbiguityErrorMisc, } impl<'a> NameBinding<'a> { @@ -1210,10 +1333,6 @@ } } - fn get_macro<'b: 'a>(&self, resolver: &mut Resolver<'a, 'b>) -> Lrc { - resolver.get_macro(self.def_ignoring_ambiguity()) - } - // We sometimes need to treat variants as `pub` for backwards compatibility fn pseudo_vis(&self) -> ty::Visibility { if self.is_variant() && self.def().def_id().is_local() { @@ -1235,9 +1354,12 @@ match self.kind { NameBindingKind::Import { directive: &ImportDirective { - subclass: ImportDirectiveSubclass::ExternCrate(_), .. + subclass: ImportDirectiveSubclass::ExternCrate { .. }, .. }, .. } => true, + NameBindingKind::Module( + &ModuleData { kind: ModuleKind::Def(Def::Mod(def_id), _), .. } + ) => def_id.index == CRATE_DEF_INDEX, _ => false, } } @@ -1249,15 +1371,6 @@ } } - fn is_renamed_extern_crate(&self) -> bool { - if let NameBindingKind::Import { directive, ..} = self.kind { - if let ImportDirectiveSubclass::ExternCrate(Some(_)) = directive.subclass { - return true; - } - } - false - } - fn is_glob_import(&self) -> bool { match self.kind { NameBindingKind::Import { directive, .. } => directive.is_glob(), @@ -1292,6 +1405,10 @@ if self.is_extern_crate() { "extern crate" } else { self.def().kind_name() } } + fn article(&self) -> &'static str { + if self.is_extern_crate() { "an" } else { self.def().article() } + } + // Suppose that we resolved macro invocation with `invoc_parent_expansion` to binding `binding` // at some expansion round `max(invoc, binding)` when they both emerged from macros. // Then this function returns `true` if `self` may emerge from a macro *after* that @@ -1316,13 +1433,14 @@ /// /// All other types are defined somewhere and possibly imported, but the primitive ones need /// special handling, since they have no place of origin. +#[derive(Default)] struct PrimitiveTypeTable { primitive_types: FxHashMap, } impl PrimitiveTypeTable { fn new() -> PrimitiveTypeTable { - let mut table = PrimitiveTypeTable { primitive_types: FxHashMap() }; + let mut table = PrimitiveTypeTable::default(); table.intern("bool", Bool); table.intern("char", Char); @@ -1349,6 +1467,12 @@ } } +#[derive(Default, Clone)] +pub struct ExternPreludeEntry<'a> { + extern_crate_item: Option<&'a NameBinding<'a>>, + pub introduced_by_item: bool, +} + /// The main resolver class. /// /// This is the visitor that walks the whole crate. @@ -1361,7 +1485,7 @@ graph_root: Module<'a>, prelude: Option>, - pub extern_prelude: FxHashSet, + pub extern_prelude: FxHashMap>, /// n.b. This is used only for better diagnostics, not name resolution itself. has_self: FxHashSet, @@ -1392,6 +1516,12 @@ /// The current self type if inside an impl (used for better errors). current_self_type: Option, + /// The current self item if inside an ADT (used for better errors). + current_self_item: Option, + + /// FIXME: Refactor things so that this is passed through arguments and not resolver. + last_import_segment: bool, + /// The idents for the primitive types. primitive_type_table: PrimitiveTypeTable, @@ -1480,6 +1610,7 @@ } /// Nothing really interesting here, it just provides memory for the rest of the crate. +#[derive(Default)] pub struct ResolverArenas<'a> { modules: arena::TypedArena>, local_modules: RefCell>>, @@ -1532,7 +1663,11 @@ /// This interface is used through the AST→HIR step, to embed full paths into the HIR. After that /// the resolver is no longer needed as all the relevant information is inline. impl<'a, 'cl> hir::lowering::Resolver for Resolver<'a, 'cl> { - fn resolve_hir_path(&mut self, path: &mut hir::Path, is_value: bool) { + fn resolve_hir_path( + &mut self, + path: &ast::Path, + is_value: bool, + ) -> hir::Path { self.resolve_hir_path_cb(path, is_value, |resolver, span, error| resolve_error(resolver, span, error)) } @@ -1542,33 +1677,22 @@ span: Span, crate_root: Option<&str>, components: &[&str], - args: Option>, is_value: bool ) -> hir::Path { - let mut segments = iter::once(keywords::CrateRoot.ident()) + let segments = iter::once(keywords::CrateRoot.ident()) .chain( crate_root.into_iter() .chain(components.iter().cloned()) .map(Ident::from_str) - ).map(hir::PathSegment::from_ident).collect::>(); + ).map(|i| self.new_ast_path_segment(i)).collect::>(); - if let Some(args) = args { - let ident = segments.last().unwrap().ident; - *segments.last_mut().unwrap() = hir::PathSegment { - ident, - args: Some(args), - infer_types: true, - }; - } - let mut path = hir::Path { + let path = ast::Path { span, - def: Def::Err, - segments: segments.into(), + segments, }; - self.resolve_hir_path(&mut path, is_value); - path + self.resolve_hir_path(&path, is_value) } fn get_resolution(&mut self, id: NodeId) -> Option { @@ -1594,23 +1718,27 @@ use std::iter; let mut errored = false; - let mut path = if path_str.starts_with("::") { - hir::Path { + let path = if path_str.starts_with("::") { + ast::Path { span, - def: Def::Err, - segments: iter::once(keywords::CrateRoot.ident()).chain({ - path_str.split("::").skip(1).map(Ident::from_str) - }).map(hir::PathSegment::from_ident).collect(), + segments: iter::once(keywords::CrateRoot.ident()) + .chain({ + path_str.split("::").skip(1).map(Ident::from_str) + }) + .map(|i| self.new_ast_path_segment(i)) + .collect(), } } else { - hir::Path { + ast::Path { span, - def: Def::Err, - segments: path_str.split("::").map(Ident::from_str) - .map(hir::PathSegment::from_ident).collect(), + segments: path_str + .split("::") + .map(Ident::from_str) + .map(|i| self.new_ast_path_segment(i)) + .collect(), } }; - self.resolve_hir_path_cb(&mut path, is_value, |_, _, _| errored = true); + let path = self.resolve_hir_path_cb(&path, is_value, |_, _, _| errored = true); if errored || path.def == Def::Err { Err(()) } else { @@ -1619,38 +1747,59 @@ } /// resolve_hir_path, but takes a callback in case there was an error - fn resolve_hir_path_cb(&mut self, path: &mut hir::Path, is_value: bool, error_callback: F) + fn resolve_hir_path_cb( + &mut self, + path: &ast::Path, + is_value: bool, + error_callback: F, + ) -> hir::Path where F: for<'c, 'b> FnOnce(&'c mut Resolver, Span, ResolutionError<'b>) { let namespace = if is_value { ValueNS } else { TypeNS }; - let hir::Path { ref segments, span, ref mut def } = *path; - let path: Vec<_> = segments.iter().map(|seg| seg.ident).collect(); + let span = path.span; + let segments = &path.segments; + let path = Segment::from_path(&path); // FIXME (Manishearth): Intra doc links won't get warned of epoch changes - match self.resolve_path(None, &path, Some(namespace), true, span, CrateLint::No) { + let def = match self.resolve_path_without_parent_scope( + &path, + Some(namespace), + true, + span, + CrateLint::No, + ) { PathResult::Module(ModuleOrUniformRoot::Module(module)) => - *def = module.def().unwrap(), + module.def().unwrap(), PathResult::NonModule(path_res) if path_res.unresolved_segments() == 0 => - *def = path_res.base_def(), - PathResult::NonModule(..) => match self.resolve_path( - None, - &path, - None, - true, - span, - CrateLint::No, - ) { - PathResult::Failed(span, msg, _) => { - error_callback(self, span, ResolutionError::FailedToResolve(&msg)); - } - _ => {} - }, - PathResult::Module(ModuleOrUniformRoot::UniformRoot(_)) | - PathResult::Indeterminate => unreachable!(), + path_res.base_def(), + PathResult::NonModule(..) => { + let msg = "type-relative paths are not supported in this context"; + error_callback(self, span, ResolutionError::FailedToResolve(msg)); + Def::Err + } + PathResult::Module(..) | PathResult::Indeterminate => unreachable!(), PathResult::Failed(span, msg, _) => { error_callback(self, span, ResolutionError::FailedToResolve(&msg)); + Def::Err } + }; + + let segments: Vec<_> = segments.iter().map(|seg| { + let mut hir_seg = hir::PathSegment::from_ident(seg.ident); + hir_seg.def = Some(self.def_map.get(&seg.id).map_or(Def::Err, |p| p.base_def())); + hir_seg + }).collect(); + hir::Path { + span, + def, + segments: segments.into(), } } + + fn new_ast_path_segment(&self, ident: Ident) -> ast::PathSegment { + let mut seg = ast::PathSegment::from_ident(ident); + seg.id = self.session.next_node_id(); + seg + } } impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { @@ -1668,31 +1817,32 @@ no_implicit_prelude: attr::contains_name(&krate.attrs, "no_implicit_prelude"), ..ModuleData::new(None, root_module_kind, root_def_id, Mark::root(), krate.span) }); - let mut module_map = FxHashMap(); + let mut module_map = FxHashMap::default(); module_map.insert(DefId::local(CRATE_DEF_INDEX), graph_root); let mut definitions = Definitions::new(); DefCollector::new(&mut definitions, Mark::root()) .collect_root(crate_name, session.local_crate_disambiguator()); - let mut extern_prelude: FxHashSet = - session.opts.externs.iter().map(|kv| Symbol::intern(kv.0)).collect(); + let mut extern_prelude: FxHashMap = + session.opts.externs.iter().map(|kv| (Ident::from_str(kv.0), Default::default())) + .collect(); if !attr::contains_name(&krate.attrs, "no_core") { - extern_prelude.insert(Symbol::intern("core")); + extern_prelude.insert(Ident::from_str("core"), Default::default()); if !attr::contains_name(&krate.attrs, "no_std") { - extern_prelude.insert(Symbol::intern("std")); + extern_prelude.insert(Ident::from_str("std"), Default::default()); if session.rust_2018() { - extern_prelude.insert(Symbol::intern("meta")); + extern_prelude.insert(Ident::from_str("meta"), Default::default()); } } } - let mut invocations = FxHashMap(); + let mut invocations = FxHashMap::default(); invocations.insert(Mark::root(), arenas.alloc_invocation_data(InvocationData::root(graph_root))); - let mut macro_defs = FxHashMap(); + let mut macro_defs = FxHashMap::default(); macro_defs.insert(Mark::root(), root_def_id); Resolver { @@ -1708,8 +1858,8 @@ prelude: None, extern_prelude, - has_self: FxHashSet(), - field_names: FxHashMap(), + has_self: FxHashSet::default(), + field_names: FxHashMap::default(), determined_imports: Vec::new(), indeterminate_imports: Vec::new(), @@ -1724,6 +1874,8 @@ current_trait_ref: None, current_self_type: None, + current_self_item: None, + last_import_segment: false, primitive_type_table: PrimitiveTypeTable::new(), @@ -1731,21 +1883,21 @@ import_map: NodeMap(), freevars: NodeMap(), freevars_seen: NodeMap(), - export_map: FxHashMap(), + export_map: FxHashMap::default(), trait_map: NodeMap(), module_map, block_map: NodeMap(), - extern_module_map: FxHashMap(), - binding_parent_modules: FxHashMap(), + extern_module_map: FxHashMap::default(), + binding_parent_modules: FxHashMap::default(), make_glob_map: make_glob_map == MakeGlobMap::Yes, glob_map: NodeMap(), - used_imports: FxHashSet(), + used_imports: FxHashSet::default(), maybe_unused_trait_imports: NodeSet(), maybe_unused_extern_crates: Vec::new(), - unused_labels: FxHashMap(), + unused_labels: FxHashMap::default(), privacy_errors: Vec::new(), ambiguity_errors: Vec::new(), @@ -1761,35 +1913,27 @@ }), crate_loader, - macro_names: FxHashSet(), - builtin_macros: FxHashMap(), - macro_use_prelude: FxHashMap(), - all_macros: FxHashMap(), - macro_map: FxHashMap(), + macro_names: FxHashSet::default(), + builtin_macros: FxHashMap::default(), + macro_use_prelude: FxHashMap::default(), + all_macros: FxHashMap::default(), + macro_map: FxHashMap::default(), invocations, macro_defs, - local_macro_def_scopes: FxHashMap(), - name_already_seen: FxHashMap(), + local_macro_def_scopes: FxHashMap::default(), + name_already_seen: FxHashMap::default(), whitelisted_legacy_custom_derives: Vec::new(), potentially_unused_imports: Vec::new(), struct_constructors: DefIdMap(), found_unresolved_macro: false, - unused_macros: FxHashSet(), + unused_macros: FxHashSet::default(), current_type_ascription: Vec::new(), injected_crate: None, } } pub fn arenas() -> ResolverArenas<'a> { - ResolverArenas { - modules: arena::TypedArena::new(), - local_modules: RefCell::new(Vec::new()), - name_bindings: arena::TypedArena::new(), - import_directives: arena::TypedArena::new(), - name_resolutions: arena::TypedArena::new(), - invocation_data: arena::TypedArena::new(), - legacy_bindings: arena::TypedArena::new(), - } + Default::default() } /// Runs the function on each namespace. @@ -1833,23 +1977,35 @@ self.arenas.alloc_module(module) } - fn record_use(&mut self, ident: Ident, ns: Namespace, binding: &'a NameBinding<'a>) - -> bool /* true if an error was reported */ { - match binding.kind { - NameBindingKind::Import { directive, binding, ref used } - if !used.get() => { + fn record_use(&mut self, ident: Ident, ns: Namespace, + used_binding: &'a NameBinding<'a>, is_lexical_scope: bool) { + match used_binding.kind { + NameBindingKind::Import { directive, binding, ref used } if !used.get() => { + // Avoid marking `extern crate` items that refer to a name from extern prelude, + // but not introduce it, as used if they are accessed from lexical scope. + if is_lexical_scope { + if let Some(entry) = self.extern_prelude.get(&ident.modern()) { + if let Some(crate_item) = entry.extern_crate_item { + if ptr::eq(used_binding, crate_item) && !entry.introduced_by_item { + return; + } + } + } + } used.set(true); directive.used.set(true); self.used_imports.insert((directive.id, ns)); self.add_to_glob_map(directive.id, ident); - self.record_use(ident, ns, binding) + self.record_use(ident, ns, binding, false); } - NameBindingKind::Import { .. } => false, - NameBindingKind::Ambiguity { b1, b2 } => { - self.ambiguity_errors.push(AmbiguityError { ident, b1, b2 }); - true + NameBindingKind::Ambiguity { kind, b1, b2 } => { + self.ambiguity_errors.push(AmbiguityError { + kind, ident, b1, b2, + misc1: AmbiguityErrorMisc::None, + misc2: AmbiguityErrorMisc::None, + }); } - _ => false + _ => {} } } @@ -1920,7 +2076,6 @@ ModuleOrUniformRoot::Module(module), ident, ns, - false, record_used, path_span, ); @@ -1951,7 +2106,6 @@ ModuleOrUniformRoot::Module(module), ident, ns, - false, record_used, path_span, ); @@ -1977,25 +2131,14 @@ } if !module.no_implicit_prelude { - if ns == TypeNS && self.extern_prelude.contains(&ident.name) { - let crate_id = if record_used { - self.crate_loader.process_path_extern(ident.name, ident.span) - } else if let Some(crate_id) = - self.crate_loader.maybe_process_path_extern(ident.name, ident.span) { - crate_id - } else { - return None; - }; - let crate_root = self.get_module(DefId { krate: crate_id, index: CRATE_DEF_INDEX }); - self.populate_module_if_necessary(&crate_root); - - let binding = (crate_root, ty::Visibility::Public, - ident.span, Mark::root()).to_name_binding(self.arenas); - return Some(LexicalScopeBinding::Item(binding)); + if ns == TypeNS { + if let Some(binding) = self.extern_prelude_get(ident, !record_used) { + return Some(LexicalScopeBinding::Item(binding)); + } } if ns == TypeNS && is_known_tool(ident.name) { let binding = (Def::ToolMod, ty::Visibility::Public, - ident.span, Mark::root()).to_name_binding(self.arenas); + DUMMY_SP, Mark::root()).to_name_binding(self.arenas); return Some(LexicalScopeBinding::Item(binding)); } if let Some(prelude) = self.prelude { @@ -2004,7 +2147,6 @@ ident, ns, false, - false, path_span, ) { return Some(LexicalScopeBinding::Item(binding)); @@ -2064,22 +2206,48 @@ None } - fn resolve_ident_in_module(&mut self, - module: ModuleOrUniformRoot<'a>, - mut ident: Ident, - ns: Namespace, - record_used: bool, - span: Span) - -> Result<&'a NameBinding<'a>, Determinacy> { - ident.span = ident.span.modern(); + fn resolve_ident_in_module( + &mut self, + module: ModuleOrUniformRoot<'a>, + ident: Ident, + ns: Namespace, + parent_scope: Option<&ParentScope<'a>>, + record_used: bool, + path_span: Span + ) -> Result<&'a NameBinding<'a>, Determinacy> { + self.resolve_ident_in_module_ext( + module, ident, ns, parent_scope, record_used, path_span + ).map_err(|(determinacy, _)| determinacy) + } + + fn resolve_ident_in_module_ext( + &mut self, + module: ModuleOrUniformRoot<'a>, + mut ident: Ident, + ns: Namespace, + parent_scope: Option<&ParentScope<'a>>, + record_used: bool, + path_span: Span + ) -> Result<&'a NameBinding<'a>, (Determinacy, Weak)> { let orig_current_module = self.current_module; - if let ModuleOrUniformRoot::Module(module) = module { - if let Some(def) = ident.span.adjust(module.expansion) { - self.current_module = self.macro_def_scope(def); + match module { + ModuleOrUniformRoot::Module(module) => { + ident.span = ident.span.modern(); + if let Some(def) = ident.span.adjust(module.expansion) { + self.current_module = self.macro_def_scope(def); + } + } + ModuleOrUniformRoot::ExternPrelude => { + ident.span = ident.span.modern(); + ident.span.adjust(Mark::root()); + } + ModuleOrUniformRoot::CrateRootAndExternPrelude | + ModuleOrUniformRoot::CurrentScope => { + // No adjustments } } - let result = self.resolve_ident_in_module_unadjusted( - module, ident, ns, false, record_used, span, + let result = self.resolve_ident_in_module_unadjusted_ext( + module, ident, ns, parent_scope, false, record_used, path_span, ); self.current_module = orig_current_module; result @@ -2207,18 +2375,46 @@ } fn resolve_adt(&mut self, item: &Item, generics: &Generics) { - self.with_type_parameter_rib(HasTypeParameters(generics, ItemRibKind), |this| { - let item_def_id = this.definitions.local_def_id(item.id); - if this.session.features_untracked().self_in_typedefs { - this.with_self_rib(Def::SelfTy(None, Some(item_def_id)), |this| { + self.with_current_self_item(item, |this| { + this.with_type_parameter_rib(HasTypeParameters(generics, ItemRibKind), |this| { + let item_def_id = this.definitions.local_def_id(item.id); + if this.session.features_untracked().self_in_typedefs { + this.with_self_rib(Def::SelfTy(None, Some(item_def_id)), |this| { + visit::walk_item(this, item); + }); + } else { visit::walk_item(this, item); - }); - } else { - visit::walk_item(this, item); - } + } + }); }); } + fn future_proof_import(&mut self, use_tree: &ast::UseTree) { + let segments = &use_tree.prefix.segments; + if !segments.is_empty() { + let ident = segments[0].ident; + if ident.is_path_segment_keyword() || ident.span.rust_2015() { + return; + } + + let nss = match use_tree.kind { + ast::UseTreeKind::Simple(..) if segments.len() == 1 => &[TypeNS, ValueNS][..], + _ => &[TypeNS], + }; + for &ns in nss { + if let Some(LexicalScopeBinding::Def(..)) = + self.resolve_ident_in_lexical_scope(ident, ns, None, use_tree.prefix.span) { + let what = if ns == TypeNS { "type parameters" } else { "local variables" }; + self.session.span_err(ident.span, &format!("imports cannot refer to {}", what)); + } + } + } else if let ast::UseTreeKind::Nested(use_trees) = &use_tree.kind { + for (use_tree, _) in use_trees { + self.future_proof_import(use_tree); + } + } + } + fn resolve_item(&mut self, item: &Item) { let name = item.ident.name; debug!("(resolving item) resolving {}", name); @@ -2313,15 +2509,11 @@ } ItemKind::Use(ref use_tree) => { - // Imports are resolved as global by default, add starting root segment. - let path = Path { - segments: use_tree.prefix.make_root().into_iter().collect(), - span: use_tree.span, - }; - self.resolve_use_tree(item.id, use_tree.span, item.id, use_tree, &path); + self.future_proof_import(use_tree); } - ItemKind::ExternCrate(_) | ItemKind::MacroDef(..) | ItemKind::GlobalAsm(_) => { + ItemKind::ExternCrate(..) | + ItemKind::MacroDef(..) | ItemKind::GlobalAsm(..) => { // do nothing, these are just around to be encoded } @@ -2329,56 +2521,13 @@ } } - /// For the most part, use trees are desugared into `ImportDirective` instances - /// when building the reduced graph (see `build_reduced_graph_for_use_tree`). But - /// there is one special case we handle here: an empty nested import like - /// `a::{b::{}}`, which desugares into...no import directives. - fn resolve_use_tree( - &mut self, - root_id: NodeId, - root_span: Span, - id: NodeId, - use_tree: &ast::UseTree, - prefix: &Path, - ) { - match use_tree.kind { - ast::UseTreeKind::Nested(ref items) => { - let path = Path { - segments: prefix.segments - .iter() - .chain(use_tree.prefix.segments.iter()) - .cloned() - .collect(), - span: prefix.span.to(use_tree.prefix.span), - }; - - if items.len() == 0 { - // Resolve prefix of an import with empty braces (issue #28388). - self.smart_resolve_path_with_crate_lint( - id, - None, - &path, - PathSource::ImportPrefix, - CrateLint::UsePath { root_id, root_span }, - ); - } else { - for &(ref tree, nested_id) in items { - self.resolve_use_tree(root_id, root_span, nested_id, tree, &path); - } - } - } - ast::UseTreeKind::Simple(..) => {}, - ast::UseTreeKind::Glob => {}, - } - } - fn with_type_parameter_rib<'b, F>(&'b mut self, type_parameters: TypeParameters<'a, 'b>, f: F) where F: FnOnce(&mut Resolver) { match type_parameters { HasTypeParameters(generics, rib_kind) => { let mut function_type_rib = Rib::new(rib_kind); - let mut seen_bindings = FxHashMap(); + let mut seen_bindings = FxHashMap::default(); for param in &generics.params { match param.kind { GenericParamKind::Lifetime { .. } => {} @@ -2456,6 +2605,15 @@ result } + fn with_current_self_item(&mut self, self_item: &Item, f: F) -> T + where F: FnOnce(&mut Resolver) -> T + { + let previous_value = replace(&mut self.current_self_item, Some(self_item.id)); + let result = f(self); + self.current_self_item = previous_value; + result + } + /// This is called to resolve a trait reference from an `impl` (i.e. `impl Trait for Foo`) fn with_optional_trait_ref(&mut self, opt_trait_ref: Option<&TraitRef>, f: F) -> T where F: FnOnce(&mut Resolver, Option) -> T @@ -2463,9 +2621,7 @@ let mut new_val = None; let mut new_id = None; if let Some(trait_ref) = opt_trait_ref { - let path: Vec<_> = trait_ref.path.segments.iter() - .map(|seg| seg.ident) - .collect(); + let path: Vec<_> = Segment::from_path(&trait_ref.path); let def = self.smart_resolve_path_fragment( trait_ref.ref_id, None, @@ -2478,10 +2634,9 @@ new_id = Some(def.def_id()); let span = trait_ref.path.span; if let PathResult::Module(ModuleOrUniformRoot::Module(module)) = - self.resolve_path( - None, + self.resolve_path_without_parent_scope( &path, - None, + Some(TypeNS), false, span, CrateLint::SimplePath(trait_ref.ref_id), @@ -2620,6 +2775,7 @@ ModuleOrUniformRoot::Module(module), ident, ns, + None, false, span, ).is_err() { @@ -2637,7 +2793,7 @@ walk_list!(self, visit_expr, &local.init); // Resolve the pattern. - self.resolve_pattern(&local.pat, PatternSource::Let, &mut FxHashMap()); + self.resolve_pattern(&local.pat, PatternSource::Let, &mut FxHashMap::default()); } // build a map from pattern identifiers to binding-info's. @@ -2645,7 +2801,7 @@ // that expands into an or-pattern where one 'x' was from the // user and one 'x' came from the macro. fn binding_mode_map(&mut self, pat: &Pat) -> BindingMap { - let mut binding_map = FxHashMap(); + let mut binding_map = FxHashMap::default(); pat.walk(&mut |pat| { if let PatKind::Ident(binding_mode, ident, ref sub_pat) = pat.node { @@ -2670,8 +2826,8 @@ return; } - let mut missing_vars = FxHashMap(); - let mut inconsistent_vars = FxHashMap(); + let mut missing_vars = FxHashMap::default(); + let mut inconsistent_vars = FxHashMap::default(); for (i, p) in pats.iter().enumerate() { let map_i = self.binding_mode_map(&p); @@ -2682,7 +2838,7 @@ let map_j = self.binding_mode_map(&q); for (&key, &binding_i) in &map_i { - if map_j.len() == 0 { // Account for missing bindings when + if map_j.is_empty() { // Account for missing bindings when let binding_error = missing_vars // map_j has none. .entry(key.name) .or_insert(BindingError { @@ -2735,7 +2891,7 @@ fn resolve_arm(&mut self, arm: &Arm) { self.ribs[ValueNS].push(Rib::new(NormalRibKind)); - let mut bindings_list = FxHashMap(); + let mut bindings_list = FxHashMap::default(); for pattern in &arm.pats { self.resolve_pattern(&pattern, PatternSource::Match, &mut bindings_list); } @@ -2743,9 +2899,8 @@ // This has to happen *after* we determine which pat_idents are variants self.check_consistent_bindings(&arm.pats); - match arm.guard { - Some(ast::Guard::If(ref expr)) => self.visit_expr(expr), - _ => {} + if let Some(ast::Guard::If(ref expr)) = arm.guard { + self.visit_expr(expr) } self.visit_expr(&arm.body); @@ -2877,7 +3032,7 @@ Def::Const(..) if is_syntactic_ambiguity => { // Disambiguate in favor of a unit struct/variant // or constant pattern. - self.record_use(ident, ValueNS, binding.unwrap()); + self.record_use(ident, ValueNS, binding.unwrap(), false); Some(PathResolution::new(def)) } Def::StructCtor(..) | Def::VariantCtor(..) | @@ -2962,21 +3117,25 @@ source: PathSource, crate_lint: CrateLint ) -> PathResolution { - let segments = &path.segments.iter() - .map(|seg| seg.ident) - .collect::>(); - self.smart_resolve_path_fragment(id, qself, segments, path.span, source, crate_lint) + self.smart_resolve_path_fragment( + id, + qself, + &Segment::from_path(path), + path.span, + source, + crate_lint, + ) } fn smart_resolve_path_fragment(&mut self, id: NodeId, qself: Option<&QSelf>, - path: &[Ident], + path: &[Segment], span: Span, source: PathSource, crate_lint: CrateLint) -> PathResolution { - let ident_span = path.last().map_or(span, |ident| ident.span); + let ident_span = path.last().map_or(span, |ident| ident.ident.span); let ns = source.namespace(); let is_expected = &|def| source.is_expected(def); let is_enum_variant = &|def| if let Def::Variant(..) = def { true } else { false }; @@ -2985,28 +3144,29 @@ let report_errors = |this: &mut Self, def: Option| { // Make the base error. let expected = source.descr_expected(); - let path_str = names_to_string(path); + let path_str = Segment::names_to_string(path); + let item_str = path.last().unwrap().ident; let code = source.error_code(def.is_some()); let (base_msg, fallback_label, base_span) = if let Some(def) = def { (format!("expected {}, found {} `{}`", expected, def.kind_name(), path_str), format!("not a {}", expected), span) } else { - let item_str = path[path.len() - 1]; - let item_span = path[path.len() - 1].span; + let item_span = path.last().unwrap().ident.span; let (mod_prefix, mod_str) = if path.len() == 1 { (String::new(), "this scope".to_string()) - } else if path.len() == 2 && path[0].name == keywords::CrateRoot.name() { + } else if path.len() == 2 && path[0].ident.name == keywords::CrateRoot.name() { (String::new(), "the crate root".to_string()) } else { let mod_path = &path[..path.len() - 1]; - let mod_prefix = match this.resolve_path(None, mod_path, Some(TypeNS), - false, span, CrateLint::No) { + let mod_prefix = match this.resolve_path_without_parent_scope( + mod_path, Some(TypeNS), false, span, CrateLint::No + ) { PathResult::Module(ModuleOrUniformRoot::Module(module)) => module.def(), _ => None, }.map_or(String::new(), |def| format!("{} ", def.kind_name())); - (mod_prefix, format!("`{}`", names_to_string(mod_path))) + (mod_prefix, format!("`{}`", Segment::names_to_string(mod_path))) }; (format!("cannot find {} `{}` in {}{}", expected, item_str, mod_prefix, mod_str), format!("not found in {}", mod_str), @@ -3015,6 +3175,17 @@ let code = DiagnosticId::Error(code.into()); let mut err = this.session.struct_span_err_with_code(base_span, &base_msg, code); + // Emit help message for fake-self from other languages like `this`(javascript) + if ["this", "my"].contains(&&*item_str.as_str()) + && this.self_value_is_available(path[0].ident.span, span) { + err.span_suggestion_with_applicability( + span, + "did you mean", + "self".to_string(), + Applicability::MaybeIncorrect, + ); + } + // Emit special messages for unresolved `Self` and `self`. if is_self_type(path, ns) { __diagnostic_used!(E0411); @@ -3025,22 +3196,27 @@ "traits and impls" }; err.span_label(span, format!("`Self` is only available in {}", available_in)); + if this.current_self_item.is_some() && nightly_options::is_nightly_build() { + err.help("add #![feature(self_in_typedefs)] to the crate attributes \ + to enable"); + } return (err, Vec::new()); } if is_self_value(path, ns) { __diagnostic_used!(E0424); err.code(DiagnosticId::Error("E0424".into())); - err.span_label(span, format!("`self` value is only available in \ + err.span_label(span, format!("`self` value is a keyword \ + only available in \ methods with `self` parameter")); return (err, Vec::new()); } // Try to lookup the name in more relaxed fashion for better error reporting. - let ident = *path.last().unwrap(); - let candidates = this.lookup_import_candidates(ident.name, ns, is_expected); + let ident = path.last().unwrap().ident; + let candidates = this.lookup_import_candidates(ident, ns, is_expected); if candidates.is_empty() && is_expected(Def::Enum(DefId::local(CRATE_DEF_INDEX))) { let enum_candidates = - this.lookup_import_candidates(ident.name, ns, is_enum_variant); + this.lookup_import_candidates(ident, ns, is_enum_variant); let mut enum_candidates = enum_candidates.iter() .map(|suggestion| import_candidate_to_paths(&suggestion)).collect::>(); enum_candidates.sort(); @@ -3063,7 +3239,7 @@ } if path.len() == 1 && this.self_type_is_available(span) { if let Some(candidate) = this.lookup_assoc_candidate(ident, ns, is_expected) { - let self_is_available = this.self_value_is_available(path[0].span, span); + let self_is_available = this.self_value_is_available(path[0].ident.span, span); match candidate { AssocSuggestion::Field => { err.span_suggestion_with_applicability( @@ -3073,7 +3249,8 @@ Applicability::MachineApplicable, ); if !self_is_available { - err.span_label(span, format!("`self` value is only available in \ + err.span_label(span, format!("`self` value is a keyword \ + only available in \ methods with `self` parameter")); } } @@ -3159,11 +3336,11 @@ // parser issue where a struct literal is being used on an expression // where a brace being opened means a block is being started. Look // ahead for the next text to see if `span` is followed by a `{`. - let cm = this.session.source_map(); + let sm = this.session.source_map(); let mut sp = span; loop { - sp = cm.next_point(sp); - match cm.span_to_snippet(sp) { + sp = sm.next_point(sp); + match sm.span_to_snippet(sp) { Ok(ref snippet) => { if snippet.chars().any(|c| { !c.is_whitespace() }) { break; @@ -3172,20 +3349,51 @@ _ => break, } } - let followed_by_brace = match cm.span_to_snippet(sp) { + let followed_by_brace = match sm.span_to_snippet(sp) { Ok(ref snippet) if snippet == "{" => true, _ => false, }; - if let (PathSource::Expr(None), true) = (source, followed_by_brace) { - err.span_label( - span, - format!("did you mean `({} {{ /* fields */ }})`?", path_str), - ); - } else { - err.span_label( - span, - format!("did you mean `{} {{ /* fields */ }}`?", path_str), - ); + match source { + PathSource::Expr(Some(parent)) => { + match parent.node { + ExprKind::MethodCall(ref path_assignment, _) => { + err.span_suggestion_with_applicability( + sm.start_point(parent.span) + .to(path_assignment.ident.span), + "use `::` to access an associated function", + format!("{}::{}", + path_str, + path_assignment.ident), + Applicability::MaybeIncorrect + ); + return (err, candidates); + }, + _ => { + err.span_label( + span, + format!("did you mean `{} {{ /* fields */ }}`?", + path_str), + ); + return (err, candidates); + }, + } + }, + PathSource::Expr(None) if followed_by_brace == true => { + err.span_label( + span, + format!("did you mean `({} {{ /* fields */ }})`?", + path_str), + ); + return (err, candidates); + }, + _ => { + err.span_label( + span, + format!("did you mean `{} {{ /* fields */ }}`?", + path_str), + ); + return (err, candidates); + }, } } return (err, candidates); @@ -3266,7 +3474,7 @@ // or `::A::B`. If `B` should be resolved in value namespace then // it needs to be added to the trait map. if ns == ValueNS { - let item_name = *path.last().unwrap(); + let item_name = path.last().unwrap().ident; let traits = self.get_traits_containing_item(item_name, ns); self.trait_map.insert(id, traits); } @@ -3301,12 +3509,15 @@ err.span_label(base_span, "expecting a type here because of type ascription"); if line_sp != line_base_sp { - err.span_suggestion_short(sp, - "did you mean to use `;` here instead?", - ";".to_string()); + err.span_suggestion_short_with_applicability( + sp, + "did you mean to use `;` here instead?", + ";".to_string(), + Applicability::MaybeIncorrect, + ); } break; - } else if snippet.trim().len() != 0 { + } else if !snippet.trim().is_empty() { debug!("tried to find type ascription `:` token, couldn't find it"); break; } @@ -3333,7 +3544,7 @@ fn resolve_qpath_anywhere(&mut self, id: NodeId, qself: Option<&QSelf>, - path: &[Ident], + path: &[Segment], primary_ns: Namespace, span: Span, defer_to_typeck: bool, @@ -3355,10 +3566,10 @@ } } if primary_ns != MacroNS && - (self.macro_names.contains(&path[0].modern()) || - self.builtin_macros.get(&path[0].name).cloned() + (self.macro_names.contains(&path[0].ident.modern()) || + self.builtin_macros.get(&path[0].ident.name).cloned() .and_then(NameBinding::macro_kind) == Some(MacroKind::Bang) || - self.macro_use_prelude.get(&path[0].name).cloned() + self.macro_use_prelude.get(&path[0].ident.name).cloned() .and_then(NameBinding::macro_kind) == Some(MacroKind::Bang)) { // Return some dummy definition, it's enough for error reporting. return Some( @@ -3372,7 +3583,7 @@ fn resolve_qpath(&mut self, id: NodeId, qself: Option<&QSelf>, - path: &[Ident], + path: &[Segment], ns: Namespace, span: Span, global_by_default: bool, @@ -3434,8 +3645,7 @@ )); } - let result = match self.resolve_path( - None, + let result = match self.resolve_path_without_parent_scope( &path, Some(ns), true, @@ -3462,8 +3672,8 @@ PathResult::Failed(..) if (ns == TypeNS || path.len() > 1) && self.primitive_type_table.primitive_types - .contains_key(&path[0].name) => { - let prim = self.primitive_type_table.primitive_types[&path[0].name]; + .contains_key(&path[0].ident.name) => { + let prim = self.primitive_type_table.primitive_types[&path[0].ident.name]; PathResolution::with_unresolved_segments(Def::PrimTy(prim), path.len() - 1) } PathResult::Module(ModuleOrUniformRoot::Module(module)) => @@ -3472,17 +3682,15 @@ resolve_error(self, span, ResolutionError::FailedToResolve(&msg)); err_path_resolution() } - PathResult::Module(ModuleOrUniformRoot::UniformRoot(_)) | - PathResult::Failed(..) => return None, + PathResult::Module(..) | PathResult::Failed(..) => return None, PathResult::Indeterminate => bug!("indetermined path result in resolve_qpath"), }; if path.len() > 1 && !global_by_default && result.base_def() != Def::Err && - path[0].name != keywords::CrateRoot.name() && - path[0].name != keywords::DollarCrate.name() { + path[0].ident.name != keywords::CrateRoot.name() && + path[0].ident.name != keywords::DollarCrate.name() { let unqualified_result = { - match self.resolve_path( - None, + match self.resolve_path_without_parent_scope( &[*path.last().unwrap()], Some(ns), false, @@ -3504,31 +3712,31 @@ Some(result) } - fn resolve_path( + fn resolve_path_without_parent_scope( &mut self, - base_module: Option>, - path: &[Ident], - opt_ns: Option, // `None` indicates a module path + path: &[Segment], + opt_ns: Option, // `None` indicates a module path in import record_used: bool, path_span: Span, crate_lint: CrateLint, ) -> PathResult<'a> { + // Macro and import paths must have full parent scope available during resolution, + // other paths will do okay with parent module alone. + assert!(opt_ns != None && opt_ns != Some(MacroNS)); let parent_scope = ParentScope { module: self.current_module, ..self.dummy_parent_scope() }; - self.resolve_path_with_parent_scope(base_module, path, opt_ns, &parent_scope, - record_used, path_span, crate_lint) + self.resolve_path(path, opt_ns, &parent_scope, record_used, path_span, crate_lint) } - fn resolve_path_with_parent_scope( + fn resolve_path( &mut self, - base_module: Option>, - path: &[Ident], - opt_ns: Option, // `None` indicates a module path + path: &[Segment], + opt_ns: Option, // `None` indicates a module path in import parent_scope: &ParentScope<'a>, record_used: bool, path_span: Span, crate_lint: CrateLint, ) -> PathResult<'a> { - let mut module = base_module; + let mut module = None; let mut allow_super = true; let mut second_binding = None; self.current_module = parent_scope.module; @@ -3543,8 +3751,19 @@ crate_lint, ); - for (i, &ident) in path.iter().enumerate() { - debug!("resolve_path ident {} {:?}", i, ident); + for (i, &Segment { ident, id }) in path.iter().enumerate() { + debug!("resolve_path ident {} {:?} {:?}", i, ident, id); + let record_segment_def = |this: &mut Self, def| { + if record_used { + if let Some(id) = id { + if !this.def_map.contains_key(&id) { + assert!(id != ast::DUMMY_NODE_ID, "Trying to resolve dummy id"); + this.record_def(id, PathResolution::new(def)); + } + } + } + }; + let is_last = i == path.len() - 1; let ns = if is_last { opt_ns.unwrap_or(TypeNS) } else { TypeNS }; let name = ident.name; @@ -3570,7 +3789,7 @@ continue; } } - let msg = "There are too many initial `super`s.".to_string(); + let msg = "there are too many initial `super`s.".to_string(); return PathResult::Failed(ident.span, msg, false); } if i == 0 { @@ -3581,9 +3800,14 @@ continue; } if name == keywords::Extern.name() || - name == keywords::CrateRoot.name() && - self.session.rust_2018() { - module = Some(ModuleOrUniformRoot::UniformRoot(name)); + name == keywords::CrateRoot.name() && ident.span.rust_2018() { + module = Some(ModuleOrUniformRoot::ExternPrelude); + continue; + } + if name == keywords::CrateRoot.name() && + ident.span.rust_2015() && self.session.rust_2018() { + // `::a::b` from 2015 macro on 2018 global edition + module = Some(ModuleOrUniformRoot::CrateRootAndExternPrelude); continue; } if name == keywords::CrateRoot.name() || @@ -3604,7 +3828,7 @@ } else { format!("`{}`", name) }; - let msg = if i == 1 && path[0].name == keywords::CrateRoot.name() { + let msg = if i == 1 && path[0].ident.name == keywords::CrateRoot.name() { format!("global paths cannot start with {}", name_str) } else { format!("{} in paths can only be used in start position", name_str) @@ -3613,11 +3837,12 @@ } let binding = if let Some(module) = module { - self.resolve_ident_in_module(module, ident, ns, record_used, path_span) - } else if opt_ns == Some(MacroNS) { + self.resolve_ident_in_module(module, ident, ns, None, record_used, path_span) + } else if opt_ns.is_none() || opt_ns == Some(MacroNS) { assert!(ns == TypeNS); - self.resolve_lexical_macro_path_segment(ident, ns, None, parent_scope, record_used, - record_used, path_span).map(|(b, _)| b) + let scopes = if opt_ns.is_none() { ScopeSet::Import(ns) } else { ScopeSet::Module }; + self.early_resolve_ident_in_lexical_scope(ident, scopes, parent_scope, record_used, + record_used, path_span) } else { let record_used_id = if record_used { crate_lint.node_id().or(Some(CRATE_NODE_ID)) } else { None }; @@ -3627,11 +3852,12 @@ // we found a local variable or type param Some(LexicalScopeBinding::Def(def)) if opt_ns == Some(TypeNS) || opt_ns == Some(ValueNS) => { + record_segment_def(self, def); return PathResult::NonModule(PathResolution::with_unresolved_segments( def, path.len() - 1 )); } - _ => Err(if record_used { Determined } else { Undetermined }), + _ => Err(Determinacy::determined(record_used)), } }; @@ -3644,6 +3870,7 @@ let maybe_assoc = opt_ns != Some(MacroNS) && PathSource::Type.is_expected(def); if let Some(next_module) = binding.module() { module = Some(ModuleOrUniformRoot::Module(next_module)); + record_segment_def(self, def); } else if def == Def::ToolMod && i + 1 != path.len() { let def = Def::NonMacroAttr(NonMacroAttrKind::Tool); return PathResult::NonModule(PathResolution::new(def)); @@ -3661,7 +3888,7 @@ )); } else { return PathResult::Failed(ident.span, - format!("Not a module `{}`", ident), + format!("not a module `{}`", ident), is_last); } } @@ -3681,19 +3908,19 @@ let msg = if module_def == self.graph_root.def() { let is_mod = |def| match def { Def::Mod(..) => true, _ => false }; let mut candidates = - self.lookup_import_candidates(name, TypeNS, is_mod); + self.lookup_import_candidates(ident, TypeNS, is_mod); candidates.sort_by_cached_key(|c| { (c.path.segments.len(), c.path.to_string()) }); if let Some(candidate) = candidates.get(0) { - format!("Did you mean `{}`?", candidate.path) + format!("did you mean `{}`?", candidate.path) } else { - format!("Maybe a missing `extern crate {};`?", ident) + format!("maybe a missing `extern crate {};`?", ident) } } else if i == 0 { - format!("Use of undeclared type or module `{}`", ident) + format!("use of undeclared type or module `{}`", ident) } else { - format!("Could not find `{}` in `{}`", ident, path[i - 1]) + format!("could not find `{}` in `{}`", ident, path[i - 1].ident) }; return PathResult::Failed(ident.span, msg, is_last); } @@ -3702,24 +3929,20 @@ self.lint_if_path_starts_with_module(crate_lint, path, path_span, second_binding); - PathResult::Module(module.unwrap_or_else(|| { - span_bug!(path_span, "resolve_path: empty(?) path {:?} has no module", path); - })) - + PathResult::Module(match module { + Some(module) => module, + None if path.is_empty() => ModuleOrUniformRoot::CurrentScope, + _ => span_bug!(path_span, "resolve_path: non-empty path `{:?}` has no module", path), + }) } fn lint_if_path_starts_with_module( &self, crate_lint: CrateLint, - path: &[Ident], + path: &[Segment], path_span: Span, second_binding: Option<&NameBinding>, ) { - // In the 2018 edition this lint is a hard error, so nothing to do - if self.session.rust_2018() { - return - } - let (diag_id, diag_span) = match crate_lint { CrateLint::No => return, CrateLint::SimplePath(id) => (id, path_span), @@ -3728,8 +3951,9 @@ }; let first_name = match path.get(0) { - Some(ident) => ident.name, - None => return, + // In the 2018 edition this lint is a hard error, so nothing to do + Some(seg) if seg.ident.span.rust_2015() && self.session.rust_2015() => seg.ident.name, + _ => return, }; // We're only interested in `use` paths which should start with @@ -3740,7 +3964,7 @@ match path.get(1) { // If this import looks like `crate::...` it's already good - Some(ident) if ident.name == keywords::Crate.name() => return, + Some(Segment { ident, .. }) if ident.name == keywords::Crate.name() => return, // Otherwise go below to see if it's an extern crate Some(_) => {} // If the path has length one (and it's `CrateRoot` most likely) @@ -3756,7 +3980,7 @@ if let NameBindingKind::Import { directive: d, .. } = binding.kind { // Careful: we still want to rewrite paths from // renamed extern crates. - if let ImportDirectiveSubclass::ExternCrate(None) = d.subclass { + if let ImportDirectiveSubclass::ExternCrate { source: None, .. } = d.subclass { return } } @@ -3868,7 +4092,7 @@ } _ => {} } - return def; + def } fn lookup_assoc_candidate(&mut self, @@ -3915,6 +4139,7 @@ ModuleOrUniformRoot::Module(module), ident, ns, + None, false, module.span, ) { @@ -3933,7 +4158,7 @@ } fn lookup_typo_candidate(&mut self, - path: &[Ident], + path: &[Segment], ns: Namespace, filter_fn: FilterFn, span: Span) @@ -3971,7 +4196,7 @@ } else { // Items from the prelude if !module.no_implicit_prelude { - names.extend(self.extern_prelude.iter().cloned()); + names.extend(self.extern_prelude.iter().map(|(ident, _)| ident.name)); if let Some(prelude) = self.prelude { add_module_candidates(prelude, &mut names); } @@ -3989,15 +4214,16 @@ } else { // Search in module. let mod_path = &path[..path.len() - 1]; - if let PathResult::Module(module) = self.resolve_path(None, mod_path, Some(TypeNS), - false, span, CrateLint::No) { + if let PathResult::Module(module) = self.resolve_path_without_parent_scope( + mod_path, Some(TypeNS), false, span, CrateLint::No + ) { if let ModuleOrUniformRoot::Module(module) = module { add_module_candidates(module, &mut names); } } } - let name = path[path.len() - 1].name; + let name = path[path.len() - 1].ident.name; // Make sure error reporting is deterministic. names.sort_by_cached_key(|name| name.as_str()); match find_best_match_for_name(names.iter(), &name.as_str(), None) { @@ -4081,7 +4307,7 @@ self.visit_expr(subexpression); self.ribs[ValueNS].push(Rib::new(NormalRibKind)); - let mut bindings_list = FxHashMap(); + let mut bindings_list = FxHashMap::default(); for pat in pats { self.resolve_pattern(pat, PatternSource::IfLet, &mut bindings_list); } @@ -4106,7 +4332,7 @@ self.with_resolved_label(label, expr.id, |this| { this.visit_expr(subexpression); this.ribs[ValueNS].push(Rib::new(NormalRibKind)); - let mut bindings_list = FxHashMap(); + let mut bindings_list = FxHashMap::default(); for pat in pats { this.resolve_pattern(pat, PatternSource::WhileLet, &mut bindings_list); } @@ -4120,7 +4346,7 @@ ExprKind::ForLoop(ref pattern, ref subexpression, ref block, label) => { self.visit_expr(subexpression); self.ribs[ValueNS].push(Rib::new(NormalRibKind)); - self.resolve_pattern(pattern, PatternSource::For, &mut FxHashMap()); + self.resolve_pattern(pattern, PatternSource::For, &mut FxHashMap::default()); self.resolve_labeled_block(label, expr.id, block); @@ -4173,7 +4399,7 @@ self.ribs[ValueNS].push(Rib::new(rib_kind)); self.label_ribs.push(Rib::new(rib_kind)); // Resolve arguments: - let mut bindings_list = FxHashMap(); + let mut bindings_list = FxHashMap::default(); for argument in &fn_decl.inputs { self.resolve_pattern(&argument.pat, PatternSource::FnParam, &mut bindings_list); self.visit_ty(&argument.ty); @@ -4236,6 +4462,7 @@ ModuleOrUniformRoot::Module(module), ident, ns, + None, false, module.span, ).is_ok() { @@ -4291,7 +4518,6 @@ ident, ns, false, - false, module.span, ).is_ok() { let import_id = match binding.kind { @@ -4309,7 +4535,7 @@ } fn lookup_import_candidates_from_module(&mut self, - lookup_name: Name, + lookup_ident: Ident, namespace: Namespace, start_module: &'a ModuleData<'a>, crate_name: Ident, @@ -4318,10 +4544,9 @@ where FilterFn: Fn(Def) -> bool { let mut candidates = Vec::new(); - let mut worklist = Vec::new(); - let mut seen_modules = FxHashSet(); + let mut seen_modules = FxHashSet::default(); let not_local_module = crate_name != keywords::Crate.ident(); - worklist.push((start_module, Vec::::new(), not_local_module)); + let mut worklist = vec![(start_module, Vec::::new(), not_local_module)]; while let Some((in_module, path_segments, @@ -4337,11 +4562,11 @@ if !name_binding.is_importable() { return; } // collect results based on the filter function - if ident.name == lookup_name && ns == namespace { + if ident.name == lookup_ident.name && ns == namespace { if filter_fn(name_binding.def()) { // create the path let mut segms = path_segments.clone(); - if self.session.rust_2018() { + if lookup_ident.span.rust_2018() { // crate-local absolute paths start with `crate::` in edition 2018 // FIXME: may also be stabilized for Rust 2015 (Issues #45477, #44660) segms.insert( @@ -4375,7 +4600,7 @@ let is_extern_crate_that_also_appears_in_prelude = name_binding.is_extern_crate() && - self.session.rust_2018(); + lookup_ident.span.rust_2018(); let is_visible_to_user = !in_module_is_extern || name_binding.vis == ty::Visibility::Public; @@ -4402,39 +4627,28 @@ /// NOTE: The method does not look into imports, but this is not a problem, /// since we report the definitions (thus, the de-aliased imports). fn lookup_import_candidates(&mut self, - lookup_name: Name, + lookup_ident: Ident, namespace: Namespace, filter_fn: FilterFn) -> Vec where FilterFn: Fn(Def) -> bool { - let mut suggestions = vec![]; + let mut suggestions = self.lookup_import_candidates_from_module( + lookup_ident, namespace, self.graph_root, keywords::Crate.ident(), &filter_fn); - suggestions.extend( - self.lookup_import_candidates_from_module( - lookup_name, namespace, self.graph_root, keywords::Crate.ident(), &filter_fn - ) - ); - - if self.session.rust_2018() { + if lookup_ident.span.rust_2018() { let extern_prelude_names = self.extern_prelude.clone(); - for &name in extern_prelude_names.iter() { - let ident = Ident::with_empty_ctxt(name); - match self.crate_loader.maybe_process_path_extern(name, ident.span) { - Some(crate_id) => { - let crate_root = self.get_module(DefId { - krate: crate_id, - index: CRATE_DEF_INDEX, - }); - self.populate_module_if_necessary(&crate_root); + for (ident, _) in extern_prelude_names.into_iter() { + if let Some(crate_id) = self.crate_loader.maybe_process_path_extern(ident.name, + ident.span) { + let crate_root = self.get_module(DefId { + krate: crate_id, + index: CRATE_DEF_INDEX, + }); + self.populate_module_if_necessary(&crate_root); - suggestions.extend( - self.lookup_import_candidates_from_module( - lookup_name, namespace, crate_root, ident, &filter_fn - ) - ); - } - None => {} + suggestions.extend(self.lookup_import_candidates_from_module( + lookup_ident, namespace, crate_root, ident, &filter_fn)); } } } @@ -4447,9 +4661,8 @@ -> Option<(Module<'a>, ImportSuggestion)> { let mut result = None; - let mut worklist = Vec::new(); - let mut seen_modules = FxHashSet(); - worklist.push((self.graph_root, Vec::new())); + let mut seen_modules = FxHashSet::default(); + let mut worklist = vec![(self.graph_root, Vec::new())]; while let Some((in_module, path_segments)) = worklist.pop() { // abort if the module is already found @@ -4525,10 +4738,28 @@ ty::Visibility::Restricted(self.current_module.normal_ancestor_id) } ast::VisibilityKind::Restricted { ref path, id, .. } => { - // Visibilities are resolved as global by default, add starting root segment. - let segments = path.make_root().iter().chain(path.segments.iter()) - .map(|seg| seg.ident) - .collect::>(); + // For visibilities we are not ready to provide correct implementation of "uniform + // paths" right now, so on 2018 edition we only allow module-relative paths for now. + // On 2015 edition visibilities are resolved as crate-relative by default, + // so we are prepending a root segment if necessary. + let ident = path.segments.get(0).expect("empty path in visibility").ident; + let crate_root = if ident.is_path_segment_keyword() { + None + } else if ident.span.rust_2018() { + let msg = "relative paths are not supported in visibilities on 2018 edition"; + self.session.struct_span_err(ident.span, msg) + .span_suggestion(path.span, "try", format!("crate::{}", path)) + .emit(); + return ty::Visibility::Public; + } else { + let ctxt = ident.span.ctxt(); + Some(Segment::from_ident(Ident::new( + keywords::CrateRoot.name(), path.span.shrink_to_lo().with_ctxt(ctxt) + ))) + }; + + let segments = crate_root.into_iter() + .chain(path.segments.iter().map(|seg| seg.into())).collect::>(); let def = self.smart_resolve_path_fragment( id, None, @@ -4586,43 +4817,97 @@ } } - fn report_ambiguity_error(&self, ident: Ident, b1: &NameBinding, b2: &NameBinding) { - let participle = |is_import: bool| if is_import { "imported" } else { "defined" }; - let msg1 = - format!("`{}` could refer to the name {} here", ident, participle(b1.is_import())); - let msg2 = - format!("`{}` could also refer to the name {} here", ident, participle(b2.is_import())); - let note = if b1.expansion != Mark::root() { - Some(if let Def::Macro(..) = b1.def() { - format!("macro-expanded {} do not shadow", - if b1.is_import() { "macro imports" } else { "macros" }) + fn binding_description(&self, b: &NameBinding, ident: Ident, from_prelude: bool) -> String { + if b.span.is_dummy() { + let add_built_in = match b.def() { + // These already contain the "built-in" prefix or look bad with it. + Def::NonMacroAttr(..) | Def::PrimTy(..) | Def::ToolMod => false, + _ => true, + }; + let (built_in, from) = if from_prelude { + ("", " from prelude") + } else if b.is_extern_crate() && !b.is_import() && + self.session.opts.externs.get(&ident.as_str()).is_some() { + ("", " passed with `--extern`") + } else if add_built_in { + (" built-in", "") } else { - format!("macro-expanded {} do not shadow when used in a macro invocation path", - if b1.is_import() { "imports" } else { "items" }) - }) - } else if b1.is_glob_import() { - Some(format!("consider adding an explicit import of `{}` to disambiguate", ident)) + ("", "") + }; + + let article = if built_in.is_empty() { b.article() } else { "a" }; + format!("{a}{built_in} {thing}{from}", + a = article, thing = b.descr(), built_in = built_in, from = from) } else { - None + let introduced = if b.is_import() { "imported" } else { "defined" }; + format!("the {thing} {introduced} here", + thing = b.descr(), introduced = introduced) + } + } + + fn report_ambiguity_error(&self, ambiguity_error: &AmbiguityError) { + let AmbiguityError { kind, ident, b1, b2, misc1, misc2 } = *ambiguity_error; + let (b1, b2, misc1, misc2, swapped) = if b2.span.is_dummy() && !b1.span.is_dummy() { + // We have to print the span-less alternative first, otherwise formatting looks bad. + (b2, b1, misc2, misc1, true) + } else { + (b1, b2, misc1, misc2, false) }; - let mut err = struct_span_err!(self.session, ident.span, E0659, "`{}` is ambiguous", ident); + let mut err = struct_span_err!(self.session, ident.span, E0659, + "`{ident}` is ambiguous ({why})", + ident = ident, why = kind.descr()); err.span_label(ident.span, "ambiguous name"); - err.span_note(b1.span, &msg1); - match b2.def() { - Def::Macro(..) if b2.span.is_dummy() => - err.note(&format!("`{}` is also a builtin macro", ident)), - _ => err.span_note(b2.span, &msg2), + + let mut could_refer_to = |b: &NameBinding, misc: AmbiguityErrorMisc, also: &str| { + let what = self.binding_description(b, ident, misc == AmbiguityErrorMisc::FromPrelude); + let note_msg = format!("`{ident}` could{also} refer to {what}", + ident = ident, also = also, what = what); + + let mut help_msgs = Vec::new(); + if b.is_glob_import() && (kind == AmbiguityKind::GlobVsGlob || + kind == AmbiguityKind::GlobVsExpanded || + kind == AmbiguityKind::GlobVsOuter && + swapped != also.is_empty()) { + help_msgs.push(format!("consider adding an explicit import of \ + `{ident}` to disambiguate", ident = ident)) + } + if b.is_extern_crate() && ident.span.rust_2018() { + help_msgs.push(format!( + "use `::{ident}` to refer to this {thing} unambiguously", + ident = ident, thing = b.descr(), + )) + } + if misc == AmbiguityErrorMisc::SuggestCrate { + help_msgs.push(format!( + "use `crate::{ident}` to refer to this {thing} unambiguously", + ident = ident, thing = b.descr(), + )) + } else if misc == AmbiguityErrorMisc::SuggestSelf { + help_msgs.push(format!( + "use `self::{ident}` to refer to this {thing} unambiguously", + ident = ident, thing = b.descr(), + )) + } + + if b.span.is_dummy() { + err.note(¬e_msg); + } else { + err.span_note(b.span, ¬e_msg); + } + for (i, help_msg) in help_msgs.iter().enumerate() { + let or = if i == 0 { "" } else { "or " }; + err.help(&format!("{}{}", or, help_msg)); + } }; - if let Some(note) = note { - err.note(¬e); - } + + could_refer_to(b1, misc1, ""); + could_refer_to(b2, misc2, " also"); err.emit(); } fn report_errors(&mut self, krate: &Crate) { self.report_with_use_injections(krate); - let mut reported_spans = FxHashSet(); for &(span_use, span_def) in &self.macro_expanded_macro_export_errors { let msg = "macro-expanded `macro_export` macros from the current crate \ @@ -4635,15 +4920,16 @@ ); } - for &AmbiguityError { ident, b1, b2 } in &self.ambiguity_errors { - if reported_spans.insert(ident.span) { - self.report_ambiguity_error(ident, b1, b2); - } + for ambiguity_error in &self.ambiguity_errors { + self.report_ambiguity_error(ambiguity_error); } - for &PrivacyError(span, name, binding) in &self.privacy_errors { - if !reported_spans.insert(span) { continue } - span_err!(self.session, span, E0603, "{} `{}` is private", binding.descr(), name); + let mut reported_spans = FxHashSet::default(); + for &PrivacyError(dedup_span, ident, binding) in &self.privacy_errors { + if reported_spans.insert(dedup_span) { + span_err!(self.session, ident.span, E0603, "{} `{}` is private", + binding.descr(), ident.name); + } } } @@ -4737,10 +5023,17 @@ }; let cm = self.session.source_map(); - let rename_msg = "You can use `as` to change the binding name of the import"; + let rename_msg = "you can use `as` to change the binding name of the import"; - if let (Ok(snippet), false) = (cm.span_to_snippet(binding.span), - binding.is_renamed_extern_crate()) { + if let ( + Ok(snippet), + NameBindingKind::Import { directive, ..}, + _dummy @ false, + ) = ( + cm.span_to_snippet(binding.span), + binding.kind.clone(), + binding.span.is_dummy(), + ) { let suggested_name = if name.as_str().chars().next().unwrap().is_uppercase() { format!("Other{}", name) } else { @@ -4749,13 +5042,30 @@ err.span_suggestion_with_applicability( binding.span, - rename_msg, - if snippet.ends_with(';') { - format!("{} as {};", &snippet[..snippet.len() - 1], suggested_name) - } else { - format!("{} as {}", snippet, suggested_name) + &rename_msg, + match directive.subclass { + ImportDirectiveSubclass::SingleImport { type_ns_only: true, .. } => + format!("self as {}", suggested_name), + ImportDirectiveSubclass::SingleImport { source, .. } => + format!( + "{} as {}{}", + &snippet[..((source.span.hi().0 - binding.span.lo().0) as usize)], + suggested_name, + if snippet.ends_with(";") { + ";" + } else { + "" + } + ), + ImportDirectiveSubclass::ExternCrate { source, target, .. } => + format!( + "extern crate {} as {};", + source.unwrap_or(target.name), + suggested_name, + ), + _ => unreachable!(), }, - Applicability::MachineApplicable, + Applicability::MaybeIncorrect, ); } else { err.span_label(binding.span, rename_msg); @@ -4765,14 +5075,40 @@ err.emit(); self.name_already_seen.insert(name, span); } + + fn extern_prelude_get(&mut self, ident: Ident, speculative: bool) + -> Option<&'a NameBinding<'a>> { + if ident.is_path_segment_keyword() { + // Make sure `self`, `super` etc produce an error when passed to here. + return None; + } + self.extern_prelude.get(&ident.modern()).cloned().and_then(|entry| { + if let Some(binding) = entry.extern_crate_item { + Some(binding) + } else { + let crate_id = if !speculative { + self.crate_loader.process_path_extern(ident.name, ident.span) + } else if let Some(crate_id) = + self.crate_loader.maybe_process_path_extern(ident.name, ident.span) { + crate_id + } else { + return None; + }; + let crate_root = self.get_module(DefId { krate: crate_id, index: CRATE_DEF_INDEX }); + self.populate_module_if_necessary(&crate_root); + Some((crate_root, ty::Visibility::Public, DUMMY_SP, Mark::root()) + .to_name_binding(self.arenas)) + } + }) + } } -fn is_self_type(path: &[Ident], namespace: Namespace) -> bool { - namespace == TypeNS && path.len() == 1 && path[0].name == keywords::SelfType.name() +fn is_self_type(path: &[Segment], namespace: Namespace) -> bool { + namespace == TypeNS && path.len() == 1 && path[0].ident.name == keywords::SelfType.name() } -fn is_self_value(path: &[Ident], namespace: Namespace) -> bool { - namespace == ValueNS && path.len() == 1 && path[0].name == keywords::SelfValue.name() +fn is_self_value(path: &[Segment], namespace: Namespace) -> bool { + namespace == ValueNS && path.len() == 1 && path[0].ident.name == keywords::SelfValue.name() } fn names_to_string(idents: &[Ident]) -> String { @@ -4845,7 +5181,12 @@ *candidate = format!("use {};\n{}", candidate, additional_newline); } - err.span_suggestions(span, &msg, path_strings); + err.span_suggestions_with_applicability( + span, + &msg, + path_strings, + Applicability::Unspecified, + ); } else { let mut msg = msg; msg.push(':'); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_resolve/macros.rs rustc-1.31.0+dfsg1+llvm/src/librustc_resolve/macros.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_resolve/macros.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_resolve/macros.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,10 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use {AmbiguityError, CrateLint, Resolver, ResolutionError, is_known_tool, resolve_error}; -use {Module, ModuleKind, NameBinding, NameBindingKind, PathResult, ToNameBinding}; +use {AmbiguityError, AmbiguityKind, AmbiguityErrorMisc}; +use {CrateLint, Resolver, ResolutionError, ScopeSet, Weak}; +use {Module, ModuleKind, NameBinding, NameBindingKind, PathResult, Segment, ToNameBinding}; +use {is_known_tool, resolve_error}; use ModuleOrUniformRoot; -use Namespace::{self, TypeNS, MacroNS}; +use Namespace::*; use build_reduced_graph::{BuildReducedGraphVisitor, IsMacroExport}; use resolve_imports::ImportResolver; use rustc::hir::def_id::{DefId, CRATE_DEF_INDEX, DefIndex, @@ -22,9 +24,9 @@ use syntax::ast::{self, Name, Ident}; use syntax::attr; use syntax::errors::DiagnosticBuilder; -use syntax::ext::base::{self, Determinacy, MultiModifier, MultiDecorator}; +use syntax::ext::base::{self, Determinacy}; use syntax::ext::base::{MacroKind, SyntaxExtension, Resolver as SyntaxResolver}; -use syntax::ext::expand::{AstFragment, Invocation, InvocationKind, TogetherWith}; +use syntax::ext::expand::{AstFragment, Invocation, InvocationKind}; use syntax::ext::hygiene::{self, Mark}; use syntax::ext::tt::macro_rules; use syntax::feature_gate::{self, feature_err, emit_feature_err, is_builtin_attr_name, GateIssue}; @@ -40,14 +42,10 @@ use errors::Applicability; use std::cell::Cell; -use std::mem; +use std::{mem, ptr}; use rustc_data_structures::sync::Lrc; -use rustc_data_structures::small_vec::ExpectOne; -#[derive(Clone, Copy)] -crate struct FromPrelude(bool); - -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct InvocationData<'a> { def_index: DefIndex, /// Module in which the macro was invoked. @@ -57,8 +55,8 @@ crate parent_legacy_scope: Cell>, /// Legacy scope *produced* by expanding this macro invocation, /// includes all the macro_rules items, other invocations, etc generated by it. - /// Set to the parent scope if the macro is not expanded yet (as if the macro produced nothing). - crate output_legacy_scope: Cell>, + /// `None` if the macro is not expanded yet. + crate output_legacy_scope: Cell>>, } impl<'a> InvocationData<'a> { @@ -67,13 +65,14 @@ module: Cell::new(graph_root), def_index: CRATE_DEF_INDEX, parent_legacy_scope: Cell::new(LegacyScope::Empty), - output_legacy_scope: Cell::new(LegacyScope::Empty), + output_legacy_scope: Cell::new(Some(LegacyScope::Empty)), } } } /// Binding produced by a `macro_rules` item. /// Not modularized, can shadow previous legacy bindings, etc. +#[derive(Debug)] pub struct LegacyBinding<'a> { binding: &'a NameBinding<'a>, /// Legacy scope into which the `macro_rules` item was planted. @@ -86,7 +85,7 @@ /// (named or unnamed), or even further if it escapes with `#[macro_use]`. /// Some macro invocations need to introduce legacy scopes too because they /// potentially can expand into macro definitions. -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug)] pub enum LegacyScope<'a> { /// Created when invocation data is allocated in the arena, /// must be replaced with a proper scope later. @@ -100,8 +99,8 @@ Invocation(&'a InvocationData<'a>), } -/// Everything you need to resolve a macro path. -#[derive(Clone)] +/// Everything you need to resolve a macro or import path. +#[derive(Clone, Debug)] pub struct ParentScope<'a> { crate module: Module<'a>, crate expansion: Mark, @@ -112,7 +111,7 @@ // Macro namespace is separated into two sub-namespaces, one for bang macros and // one for attribute-like macros (attributes, derives). // We ignore resolutions from one sub-namespace when searching names in scope for another. -fn sub_namespace_mismatch(requirement: Option, candidate: Option) -> bool { +fn sub_namespace_match(candidate: Option, requirement: Option) -> bool { #[derive(PartialEq)] enum SubNS { Bang, AttrLike } let sub_ns = |kind| match kind { @@ -123,7 +122,7 @@ let requirement = requirement.and_then(|kind| sub_ns(kind)); let candidate = candidate.and_then(|kind| sub_ns(kind)); // "No specific sub-namespace" means "matches anything" for both requirements and candidates. - candidate.is_some() && requirement.is_some() && candidate != requirement + candidate.is_none() || requirement.is_none() || candidate == requirement } impl<'a, 'crateloader: 'a> base::Resolver for Resolver<'a, 'crateloader> { @@ -138,7 +137,7 @@ module: Cell::new(module), def_index: module.def_id().unwrap().index, parent_legacy_scope: Cell::new(LegacyScope::Empty), - output_legacy_scope: Cell::new(LegacyScope::Empty), + output_legacy_scope: Cell::new(Some(LegacyScope::Empty)), })); mark } @@ -190,7 +189,9 @@ } } - EliminateCrateVar(self, item.span).fold_item(item).expect_one("") + let ret = EliminateCrateVar(self, item.span).fold_item(item); + assert!(ret.len() == 1); + ret.into_iter().next().unwrap() } fn is_whitelisted_legacy_custom_derive(&self, name: Name) -> bool { @@ -205,16 +206,14 @@ self.current_module = invocation.module.get(); self.current_module.unresolved_invocations.borrow_mut().remove(&mark); self.current_module.unresolved_invocations.borrow_mut().extend(derives); - for &derive in derives { - self.invocations.insert(derive, invocation); - } + self.invocations.extend(derives.iter().map(|&derive| (derive, invocation))); let mut visitor = BuildReducedGraphVisitor { resolver: self, current_legacy_scope: invocation.parent_legacy_scope.get(), expansion: mark, }; fragment.visit_with(&mut visitor); - invocation.output_legacy_scope.set(visitor.current_legacy_scope); + invocation.output_legacy_scope.set(Some(visitor.current_legacy_scope)); } fn add_builtin(&mut self, ident: ast::Ident, ext: Lrc) { @@ -228,7 +227,7 @@ let binding = self.arenas.alloc_name_binding(NameBinding { kind: NameBindingKind::Def(Def::Macro(def_id, kind), false), span: DUMMY_SP, - vis: ty::Visibility::Invisible, + vis: ty::Visibility::Public, expansion: Mark::root(), }); if self.builtin_macros.insert(ident.name, binding).is_some() { @@ -244,27 +243,10 @@ // Resolves attribute and derive legacy macros from `#![plugin(..)]`. fn find_legacy_attr_invoc(&mut self, attrs: &mut Vec, allow_derive: bool) -> Option { - for i in 0..attrs.len() { - let name = attrs[i].name(); - - if self.session.plugin_attributes.borrow().iter() - .any(|&(ref attr_nm, _)| name == &**attr_nm) { - attr::mark_known(&attrs[i]); - } - - match self.builtin_macros.get(&name).cloned() { - Some(binding) => match *binding.get_macro(self) { - MultiModifier(..) | MultiDecorator(..) | SyntaxExtension::AttrProcMacro(..) => { - return Some(attrs.remove(i)) - } - _ => {} - }, - None => {} - } + if !allow_derive { + return None; } - if !allow_derive { return None } - // Check for legacy derives for i in 0..attrs.len() { let name = attrs[i].name(); @@ -296,11 +278,12 @@ if traits.is_empty() { attrs.remove(i); } else { - let mut tokens = Vec::new(); + let mut tokens = Vec::with_capacity(traits.len() - 1); for (j, path) in traits.iter().enumerate() { if j > 0 { tokens.push(TokenTree::Token(attrs[i].span, Token::Comma).into()); } + tokens.reserve((path.segments.len() * 2).saturating_sub(1)); for (k, segment) in path.segments.iter().enumerate() { if k > 0 { tokens.push(TokenTree::Token(path.span, Token::ModSep).into()); @@ -332,29 +315,24 @@ fn resolve_macro_invocation(&mut self, invoc: &Invocation, invoc_id: Mark, force: bool) -> Result>, Determinacy> { - let (path, kind, derives_in_scope, together_with) = match invoc.kind { + let (path, kind, derives_in_scope, after_derive) = match invoc.kind { InvocationKind::Attr { attr: None, .. } => return Ok(None), - InvocationKind::Attr { attr: Some(ref attr), ref traits, together_with, .. } => - (&attr.path, MacroKind::Attr, traits.clone(), together_with), + InvocationKind::Attr { attr: Some(ref attr), ref traits, after_derive, .. } => + (&attr.path, MacroKind::Attr, traits.clone(), after_derive), InvocationKind::Bang { ref mac, .. } => - (&mac.node.path, MacroKind::Bang, Vec::new(), TogetherWith::None), + (&mac.node.path, MacroKind::Bang, Vec::new(), false), InvocationKind::Derive { ref path, .. } => - (path, MacroKind::Derive, Vec::new(), TogetherWith::None), + (path, MacroKind::Derive, Vec::new(), false), }; let parent_scope = self.invoc_parent_scope(invoc_id, derives_in_scope); - let (def, ext) = self.resolve_macro_to_def(path, kind, &parent_scope, force)?; + let (def, ext) = self.resolve_macro_to_def(path, kind, &parent_scope, true, force)?; if let Def::Macro(def_id, _) = def { - match together_with { - TogetherWith::Derive => - self.session.span_err(invoc.span(), - "macro attributes must be placed before `#[derive]`"), - TogetherWith::TestBench if !self.session.features_untracked().plugin => - self.session.span_err(invoc.span(), - "macro attributes cannot be used together with `#[test]` or `#[bench]`"), - _ => {} + if after_derive { + self.session.span_err(invoc.span(), + "macro attributes must be placed before `#[derive]`"); } self.macro_defs.insert(invoc.expansion_data.mark, def_id); let normal_module_def_id = @@ -372,7 +350,7 @@ derives_in_scope: Vec, force: bool) -> Result, Determinacy> { let parent_scope = self.invoc_parent_scope(invoc_id, derives_in_scope); - Ok(self.resolve_macro_to_def(path, kind, &parent_scope, force)?.1) + Ok(self.resolve_macro_to_def(path, kind, &parent_scope, false, force)?.1) } fn check_unused_macros(&self) { @@ -394,11 +372,11 @@ } impl<'a, 'cl> Resolver<'a, 'cl> { - pub fn dummy_parent_scope(&mut self) -> ParentScope<'a> { + pub fn dummy_parent_scope(&self) -> ParentScope<'a> { self.invoc_parent_scope(Mark::root(), Vec::new()) } - fn invoc_parent_scope(&mut self, invoc_id: Mark, derives: Vec) -> ParentScope<'a> { + fn invoc_parent_scope(&self, invoc_id: Mark, derives: Vec) -> ParentScope<'a> { let invoc = self.invocations[&invoc_id]; ParentScope { module: invoc.module.get().nearest_item_scope(), @@ -413,9 +391,10 @@ path: &ast::Path, kind: MacroKind, parent_scope: &ParentScope<'a>, + trace: bool, force: bool, ) -> Result<(Def, Lrc), Determinacy> { - let def = self.resolve_macro_to_def_inner(path, kind, parent_scope, force); + let def = self.resolve_macro_to_def_inner(path, kind, parent_scope, trace, force); // Report errors and enforce feature gates for the resolved macro. if def != Err(Determinacy::Undetermined) { @@ -473,6 +452,9 @@ return Err(Determinacy::Determined); } } + Def::Err => { + return Err(Determinacy::Determined); + } _ => panic!("expected `Def::Macro` or `Def::NonMacroAttr`"), } @@ -484,86 +466,78 @@ path: &ast::Path, kind: MacroKind, parent_scope: &ParentScope<'a>, + trace: bool, force: bool, ) -> Result { - let ast::Path { ref segments, span } = *path; - let mut path: Vec<_> = segments.iter().map(|seg| seg.ident).collect(); + let path_span = path.span; + let mut path = Segment::from_path(path); // Possibly apply the macro helper hack if kind == MacroKind::Bang && path.len() == 1 && - path[0].span.ctxt().outer().expn_info().map_or(false, |info| info.local_inner_macros) { - let root = Ident::new(keywords::DollarCrate.name(), path[0].span); - path.insert(0, root); + path[0].ident.span.ctxt().outer().expn_info() + .map_or(false, |info| info.local_inner_macros) { + let root = Ident::new(keywords::DollarCrate.name(), path[0].ident.span); + path.insert(0, Segment::from_ident(root)); } if path.len() > 1 { - let def = match self.resolve_path_with_parent_scope(None, &path, Some(MacroNS), - parent_scope, false, span, - CrateLint::No) { - PathResult::NonModule(path_res) => match path_res.base_def() { - Def::Err => Err(Determinacy::Determined), - def @ _ => { - if path_res.unresolved_segments() > 0 { - self.found_unresolved_macro = true; - self.session.span_err(span, "fail to resolve non-ident macro path"); - Err(Determinacy::Determined) - } else { - Ok(def) - } - } - }, - PathResult::Module(..) => unreachable!(), + let def = match self.resolve_path(&path, Some(MacroNS), parent_scope, + false, path_span, CrateLint::No) { + PathResult::NonModule(path_res) if path_res.unresolved_segments() == 0 => { + Ok(path_res.base_def()) + } PathResult::Indeterminate if !force => return Err(Determinacy::Undetermined), - _ => { + PathResult::NonModule(..) | PathResult::Indeterminate | PathResult::Failed(..) => { self.found_unresolved_macro = true; Err(Determinacy::Determined) - }, + } + PathResult::Module(..) => unreachable!(), }; - parent_scope.module.macro_resolutions.borrow_mut() - .push((path.into_boxed_slice(), span)); - return def; - } - let result = if let Some(legacy_binding) = self.resolve_legacy_scope(path[0], Some(kind), - parent_scope, false) { - Ok(legacy_binding.def()) + if trace { + parent_scope.module.multi_segment_macro_resolutions.borrow_mut() + .push((path, path_span, kind, parent_scope.clone(), def.ok())); + } + + def } else { - match self.resolve_lexical_macro_path_segment(path[0], MacroNS, Some(kind), - parent_scope, false, force, span) { - Ok((binding, _)) => Ok(binding.def_ignoring_ambiguity()), + let binding = self.early_resolve_ident_in_lexical_scope( + path[0].ident, ScopeSet::Macro(kind), parent_scope, false, force, path_span + ); + match binding { + Ok(..) => {} + Err(Determinacy::Determined) => self.found_unresolved_macro = true, Err(Determinacy::Undetermined) => return Err(Determinacy::Undetermined), - Err(Determinacy::Determined) => { - self.found_unresolved_macro = true; - Err(Determinacy::Determined) - } } - }; - parent_scope.module.legacy_macro_resolutions.borrow_mut() - .push((path[0], kind, parent_scope.clone(), result.ok())); + if trace { + parent_scope.module.single_segment_macro_resolutions.borrow_mut() + .push((path[0].ident, kind, parent_scope.clone(), binding.ok())); + } - result + binding.map(|binding| binding.def_ignoring_ambiguity()) + } } - // Resolve the initial segment of a non-global macro path - // (e.g. `foo` in `foo::bar!(); or `foo!();`). + // Resolve an identifier in lexical scope. // This is a variation of `fn resolve_ident_in_lexical_scope` that can be run during // expansion and import resolution (perhaps they can be merged in the future). - crate fn resolve_lexical_macro_path_segment( + // The function is used for resolving initial segments of macro paths (e.g. `foo` in + // `foo::bar!(); or `foo!();`) and also for import paths on 2018 edition. + crate fn early_resolve_ident_in_lexical_scope( &mut self, - mut ident: Ident, - ns: Namespace, - kind: Option, + orig_ident: Ident, + scope_set: ScopeSet, parent_scope: &ParentScope<'a>, record_used: bool, force: bool, path_span: Span, - ) -> Result<(&'a NameBinding<'a>, FromPrelude), Determinacy> { + ) -> Result<&'a NameBinding<'a>, Determinacy> { // General principles: // 1. Not controlled (user-defined) names should have higher priority than controlled names // built into the language or standard library. This way we can add new names into the // language or standard library without breaking user code. - // 2. "Closed set" below means new names can appear after the current resolution attempt. + // 2. "Closed set" below means new names cannot appear after the current resolution attempt. // Places to search (in order of decreasing priority): // (Type NS) // 1. FIXME: Ribs (type parameters), there's no necessary infrastructure yet @@ -574,26 +548,68 @@ // 4. Tool modules (closed, controlled right now, but not in the future). // 5. Standard library prelude (de-facto closed, controlled). // 6. Language prelude (closed, controlled). + // (Value NS) + // 1. FIXME: Ribs (local variables), there's no necessary infrastructure yet + // (open set, not controlled). + // 2. Names in modules (both normal `mod`ules and blocks), loop through hygienic parents + // (open, not controlled). + // 3. Standard library prelude (de-facto closed, controlled). // (Macro NS) - // 0. Derive helpers (open, not controlled). All ambiguities with other names + // 1-3. Derive helpers (open, not controlled). All ambiguities with other names // are currently reported as errors. They should be higher in priority than preludes // and probably even names in modules according to the "general principles" above. They // also should be subject to restricted shadowing because are effectively produced by // derives (you need to resolve the derive first to add helpers into scope), but they // should be available before the derive is expanded for compatibility. // It's mess in general, so we are being conservative for now. - // 1. Names in modules (both normal `mod`ules and blocks), loop through hygienic parents - // (open, not controlled). - // 2. `macro_use` prelude (open, the open part is from macro expansions, not controlled). - // 2a. User-defined prelude from macro-use + // 1-3. `macro_rules` (open, not controlled), loop through legacy scopes. Have higher + // priority than prelude macros, but create ambiguities with macros in modules. + // 1-3. Names in modules (both normal `mod`ules and blocks), loop through hygienic parents + // (open, not controlled). Have higher priority than prelude macros, but create + // ambiguities with `macro_rules`. + // 4. `macro_use` prelude (open, the open part is from macro expansions, not controlled). + // 4a. User-defined prelude from macro-use // (open, the open part is from macro expansions, not controlled). - // 2b. Standard library prelude is currently implemented as `macro-use` (closed, controlled) - // 3. Language prelude: builtin macros (closed, controlled, except for legacy plugins). - // 4. Language prelude: builtin attributes (closed, controlled). + // 4b. Standard library prelude is currently implemented as `macro-use` (closed, controlled) + // 5. Language prelude: builtin macros (closed, controlled, except for legacy plugins). + // 6. Language prelude: builtin attributes (closed, controlled). + // 4-6. Legacy plugin helpers (open, not controlled). Similar to derive helpers, + // but introduced by legacy plugins using `register_attribute`. Priority is somewhere + // in prelude, not sure where exactly (creates ambiguities with any other prelude names). + + enum WhereToResolve<'a> { + DeriveHelpers, + MacroRules(LegacyScope<'a>), + CrateRoot, + Module(Module<'a>), + MacroUsePrelude, + BuiltinMacros, + BuiltinAttrs, + LegacyPluginHelpers, + ExternPrelude, + ToolPrelude, + StdLibPrelude, + BuiltinTypes, + } + + bitflags! { + struct Flags: u8 { + const MACRO_RULES = 1 << 0; + const MODULE = 1 << 1; + const PRELUDE = 1 << 2; + const MISC_SUGGEST_CRATE = 1 << 3; + const MISC_SUGGEST_SELF = 1 << 4; + const MISC_FROM_PRELUDE = 1 << 5; + } + } - assert!(ns == TypeNS || ns == MacroNS); assert!(force || !record_used); // `record_used` implies `force` - ident = ident.modern(); + let mut ident = orig_ident.modern(); + + // Make sure `self`, `super` etc produce an error when passed to here. + if ident.is_path_segment_keyword() { + return Err(Determinacy::Determined); + } // This is *the* result, resolution from the scope closest to the resolved identifier. // However, sometimes this result is "weak" because it comes from a glob import or @@ -606,91 +622,156 @@ // } // So we have to save the innermost solution and continue searching in outer scopes // to detect potential ambiguities. - let mut innermost_result: Option<(&NameBinding, FromPrelude)> = None; - - enum WhereToResolve<'a> { - Module(Module<'a>), - MacroUsePrelude, - BuiltinMacros, - BuiltinAttrs, - DeriveHelpers, - ExternPrelude, - ToolPrelude, - StdLibPrelude, - BuiltinTypes, - } + let mut innermost_result: Option<(&NameBinding, Flags)> = None; // Go through all the scopes and try to resolve the name. - let mut where_to_resolve = WhereToResolve::DeriveHelpers; + let rust_2015 = orig_ident.span.rust_2015(); + let (ns, macro_kind, is_import, is_absolute_path) = match scope_set { + ScopeSet::Import(ns) => (ns, None, true, false), + ScopeSet::AbsolutePath(ns) => (ns, None, false, true), + ScopeSet::Macro(macro_kind) => (MacroNS, Some(macro_kind), false, false), + ScopeSet::Module => (TypeNS, None, false, false), + }; + let mut where_to_resolve = match ns { + _ if is_absolute_path || is_import && rust_2015 => WhereToResolve::CrateRoot, + TypeNS | ValueNS => WhereToResolve::Module(parent_scope.module), + MacroNS => WhereToResolve::DeriveHelpers, + }; let mut use_prelude = !parent_scope.module.no_implicit_prelude; + let mut determinacy = Determinacy::Determined; loop { let result = match where_to_resolve { + WhereToResolve::DeriveHelpers => { + let mut result = Err(Determinacy::Determined); + for derive in &parent_scope.derives { + let parent_scope = ParentScope { derives: Vec::new(), ..*parent_scope }; + match self.resolve_macro_to_def(derive, MacroKind::Derive, + &parent_scope, true, force) { + Ok((_, ext)) => { + if let SyntaxExtension::ProcMacroDerive(_, helpers, _) = &*ext { + if helpers.contains(&ident.name) { + let binding = + (Def::NonMacroAttr(NonMacroAttrKind::DeriveHelper), + ty::Visibility::Public, derive.span, Mark::root()) + .to_name_binding(self.arenas); + result = Ok((binding, Flags::empty())); + break; + } + } + } + Err(Determinacy::Determined) => {} + Err(Determinacy::Undetermined) => + result = Err(Determinacy::Undetermined), + } + } + result + } + WhereToResolve::MacroRules(legacy_scope) => match legacy_scope { + LegacyScope::Binding(legacy_binding) if ident == legacy_binding.ident => + Ok((legacy_binding.binding, Flags::MACRO_RULES)), + LegacyScope::Invocation(invoc) if invoc.output_legacy_scope.get().is_none() => + Err(Determinacy::Undetermined), + _ => Err(Determinacy::Determined), + } + WhereToResolve::CrateRoot => { + let root_ident = Ident::new(keywords::CrateRoot.name(), orig_ident.span); + let root_module = self.resolve_crate_root(root_ident); + let binding = self.resolve_ident_in_module_ext( + ModuleOrUniformRoot::Module(root_module), + orig_ident, + ns, + None, + record_used, + path_span, + ); + match binding { + Ok(binding) => Ok((binding, Flags::MODULE | Flags::MISC_SUGGEST_CRATE)), + Err((Determinacy::Undetermined, Weak::No)) => + return Err(Determinacy::determined(force)), + Err((Determinacy::Undetermined, Weak::Yes)) => + Err(Determinacy::Undetermined), + Err((Determinacy::Determined, _)) => Err(Determinacy::Determined), + } + } WhereToResolve::Module(module) => { let orig_current_module = mem::replace(&mut self.current_module, module); - let binding = self.resolve_ident_in_module_unadjusted( + let binding = self.resolve_ident_in_module_unadjusted_ext( ModuleOrUniformRoot::Module(module), ident, ns, + None, true, record_used, path_span, ); self.current_module = orig_current_module; - binding.map(|binding| (binding, FromPrelude(false))) + match binding { + Ok(binding) => { + let misc_flags = if ptr::eq(module, self.graph_root) { + Flags::MISC_SUGGEST_CRATE + } else if module.is_normal() { + Flags::MISC_SUGGEST_SELF + } else { + Flags::empty() + }; + Ok((binding, Flags::MODULE | misc_flags)) + } + Err((Determinacy::Undetermined, Weak::No)) => + return Err(Determinacy::determined(force)), + Err((Determinacy::Undetermined, Weak::Yes)) => + Err(Determinacy::Undetermined), + Err((Determinacy::Determined, _)) => Err(Determinacy::Determined), + } } WhereToResolve::MacroUsePrelude => { - match self.macro_use_prelude.get(&ident.name).cloned() { - Some(binding) => Ok((binding, FromPrelude(true))), - None => Err(Determinacy::Determined), + if use_prelude || rust_2015 { + match self.macro_use_prelude.get(&ident.name).cloned() { + Some(binding) => + Ok((binding, Flags::PRELUDE | Flags::MISC_FROM_PRELUDE)), + None => Err(Determinacy::determined( + self.graph_root.unresolved_invocations.borrow().is_empty() + )) + } + } else { + Err(Determinacy::Determined) } } WhereToResolve::BuiltinMacros => { match self.builtin_macros.get(&ident.name).cloned() { - Some(binding) => Ok((binding, FromPrelude(true))), + Some(binding) => Ok((binding, Flags::PRELUDE)), None => Err(Determinacy::Determined), } } WhereToResolve::BuiltinAttrs => { if is_builtin_attr_name(ident.name) { let binding = (Def::NonMacroAttr(NonMacroAttrKind::Builtin), - ty::Visibility::Public, ident.span, Mark::root()) + ty::Visibility::Public, DUMMY_SP, Mark::root()) .to_name_binding(self.arenas); - Ok((binding, FromPrelude(true))) + Ok((binding, Flags::PRELUDE)) } else { Err(Determinacy::Determined) } } - WhereToResolve::DeriveHelpers => { - let mut result = Err(Determinacy::Determined); - for derive in &parent_scope.derives { - let parent_scope = ParentScope { derives: Vec::new(), ..*parent_scope }; - if let Ok((_, ext)) = self.resolve_macro_to_def(derive, MacroKind::Derive, - &parent_scope, force) { - if let SyntaxExtension::ProcMacroDerive(_, helper_attrs, _) = &*ext { - if helper_attrs.contains(&ident.name) { - let binding = - (Def::NonMacroAttr(NonMacroAttrKind::DeriveHelper), - ty::Visibility::Public, derive.span, Mark::root()) - .to_name_binding(self.arenas); - result = Ok((binding, FromPrelude(false))); - break; - } - } - } + WhereToResolve::LegacyPluginHelpers => { + if (use_prelude || rust_2015) && + self.session.plugin_attributes.borrow().iter() + .any(|(name, _)| ident.name == &**name) { + let binding = (Def::NonMacroAttr(NonMacroAttrKind::LegacyPluginHelper), + ty::Visibility::Public, DUMMY_SP, Mark::root()) + .to_name_binding(self.arenas); + Ok((binding, Flags::PRELUDE)) + } else { + Err(Determinacy::Determined) } - result } WhereToResolve::ExternPrelude => { - if use_prelude && self.extern_prelude.contains(&ident.name) { - let crate_id = - self.crate_loader.process_path_extern(ident.name, ident.span); - let crate_root = - self.get_module(DefId { krate: crate_id, index: CRATE_DEF_INDEX }); - self.populate_module_if_necessary(crate_root); - - let binding = (crate_root, ty::Visibility::Public, - ident.span, Mark::root()).to_name_binding(self.arenas); - Ok((binding, FromPrelude(true))) + if use_prelude || is_absolute_path { + match self.extern_prelude_get(ident, !record_used) { + Some(binding) => Ok((binding, Flags::PRELUDE)), + None => Err(Determinacy::determined( + self.graph_root.unresolved_invocations.borrow().is_empty() + )), + } } else { Err(Determinacy::Determined) } @@ -698,8 +779,8 @@ WhereToResolve::ToolPrelude => { if use_prelude && is_known_tool(ident.name) { let binding = (Def::ToolMod, ty::Visibility::Public, - ident.span, Mark::root()).to_name_binding(self.arenas); - Ok((binding, FromPrelude(true))) + DUMMY_SP, Mark::root()).to_name_binding(self.arenas); + Ok((binding, Flags::PRELUDE)) } else { Err(Determinacy::Determined) } @@ -713,101 +794,203 @@ ident, ns, false, - false, path_span, ) { - result = Ok((binding, FromPrelude(true))); + result = Ok((binding, Flags::PRELUDE | Flags::MISC_FROM_PRELUDE)); } } } result } WhereToResolve::BuiltinTypes => { - if let Some(prim_ty) = - self.primitive_type_table.primitive_types.get(&ident.name).cloned() { - let binding = (Def::PrimTy(prim_ty), ty::Visibility::Public, - ident.span, Mark::root()).to_name_binding(self.arenas); - Ok((binding, FromPrelude(true))) - } else { - Err(Determinacy::Determined) + match self.primitive_type_table.primitive_types.get(&ident.name).cloned() { + Some(prim_ty) => { + let binding = (Def::PrimTy(prim_ty), ty::Visibility::Public, + DUMMY_SP, Mark::root()).to_name_binding(self.arenas); + Ok((binding, Flags::PRELUDE)) + } + None => Err(Determinacy::Determined) } } }; - macro_rules! continue_search { () => { - where_to_resolve = match where_to_resolve { - WhereToResolve::Module(module) => { - match self.hygienic_lexical_parent(module, &mut ident.span) { - Some(parent_module) => WhereToResolve::Module(parent_module), - None => { - use_prelude = !module.no_implicit_prelude; - if ns == MacroNS { - WhereToResolve::MacroUsePrelude - } else { - WhereToResolve::ExternPrelude - } - } - } - } - WhereToResolve::MacroUsePrelude => WhereToResolve::BuiltinMacros, - WhereToResolve::BuiltinMacros => WhereToResolve::BuiltinAttrs, - WhereToResolve::BuiltinAttrs => break, // nowhere else to search - WhereToResolve::DeriveHelpers => WhereToResolve::Module(parent_scope.module), - WhereToResolve::ExternPrelude => WhereToResolve::ToolPrelude, - WhereToResolve::ToolPrelude => WhereToResolve::StdLibPrelude, - WhereToResolve::StdLibPrelude => WhereToResolve::BuiltinTypes, - WhereToResolve::BuiltinTypes => break, // nowhere else to search - }; - - continue; - }} - match result { - Ok(result) => { - if sub_namespace_mismatch(kind, result.0.macro_kind()) { - continue_search!(); - } - + Ok((binding, flags)) if sub_namespace_match(binding.macro_kind(), macro_kind) => { if !record_used { - return Ok(result); + return Ok(binding); } - if let Some(innermost_result) = innermost_result { + if let Some((innermost_binding, innermost_flags)) = innermost_result { // Found another solution, if the first one was "weak", report an error. - let (def, innermost_def) = (result.0.def(), innermost_result.0.def()); - if def != innermost_def && - (innermost_result.0.is_glob_import() || - innermost_result.0.may_appear_after(parent_scope.expansion, result.0) || - innermost_def == Def::NonMacroAttr(NonMacroAttrKind::DeriveHelper) || - def == Def::NonMacroAttr(NonMacroAttrKind::DeriveHelper)) { - self.ambiguity_errors.push(AmbiguityError { - ident, - b1: innermost_result.0, - b2: result.0, - }); - return Ok(innermost_result); + let (def, innermost_def) = (binding.def(), innermost_binding.def()); + if def != innermost_def { + let builtin = Def::NonMacroAttr(NonMacroAttrKind::Builtin); + let derive_helper = Def::NonMacroAttr(NonMacroAttrKind::DeriveHelper); + let legacy_helper = + Def::NonMacroAttr(NonMacroAttrKind::LegacyPluginHelper); + + let ambiguity_error_kind = if is_import { + Some(AmbiguityKind::Import) + } else if is_absolute_path { + Some(AmbiguityKind::AbsolutePath) + } else if innermost_def == builtin || def == builtin { + Some(AmbiguityKind::BuiltinAttr) + } else if innermost_def == derive_helper || def == derive_helper { + Some(AmbiguityKind::DeriveHelper) + } else if innermost_def == legacy_helper && + flags.contains(Flags::PRELUDE) || + def == legacy_helper && + innermost_flags.contains(Flags::PRELUDE) { + Some(AmbiguityKind::LegacyHelperVsPrelude) + } else if innermost_flags.contains(Flags::MACRO_RULES) && + flags.contains(Flags::MODULE) && + !self.disambiguate_legacy_vs_modern(innermost_binding, + binding) || + flags.contains(Flags::MACRO_RULES) && + innermost_flags.contains(Flags::MODULE) && + !self.disambiguate_legacy_vs_modern(binding, + innermost_binding) { + Some(AmbiguityKind::LegacyVsModern) + } else if innermost_binding.is_glob_import() { + Some(AmbiguityKind::GlobVsOuter) + } else if innermost_binding.may_appear_after(parent_scope.expansion, + binding) { + Some(AmbiguityKind::MoreExpandedVsOuter) + } else { + None + }; + if let Some(kind) = ambiguity_error_kind { + let misc = |f: Flags| if f.contains(Flags::MISC_SUGGEST_CRATE) { + AmbiguityErrorMisc::SuggestCrate + } else if f.contains(Flags::MISC_SUGGEST_SELF) { + AmbiguityErrorMisc::SuggestSelf + } else if f.contains(Flags::MISC_FROM_PRELUDE) { + AmbiguityErrorMisc::FromPrelude + } else { + AmbiguityErrorMisc::None + }; + self.ambiguity_errors.push(AmbiguityError { + kind, + ident: orig_ident, + b1: innermost_binding, + b2: binding, + misc1: misc(innermost_flags), + misc2: misc(flags), + }); + return Ok(innermost_binding); + } } } else { // Found the first solution. - innermost_result = Some(result); + innermost_result = Some((binding, flags)); } - - continue_search!(); - }, - Err(Determinacy::Determined) => { - continue_search!(); } - Err(Determinacy::Undetermined) => return Err(Determinacy::determined(force)), + Ok(..) | Err(Determinacy::Determined) => {} + Err(Determinacy::Undetermined) => determinacy = Determinacy::Undetermined } + + where_to_resolve = match where_to_resolve { + WhereToResolve::DeriveHelpers => + WhereToResolve::MacroRules(parent_scope.legacy), + WhereToResolve::MacroRules(legacy_scope) => match legacy_scope { + LegacyScope::Binding(binding) => WhereToResolve::MacroRules( + binding.parent_legacy_scope + ), + LegacyScope::Invocation(invoc) => WhereToResolve::MacroRules( + invoc.output_legacy_scope.get().unwrap_or(invoc.parent_legacy_scope.get()) + ), + LegacyScope::Empty => WhereToResolve::Module(parent_scope.module), + LegacyScope::Uninitialized => unreachable!(), + } + WhereToResolve::CrateRoot if is_import => match ns { + TypeNS | ValueNS => WhereToResolve::Module(parent_scope.module), + MacroNS => WhereToResolve::DeriveHelpers, + } + WhereToResolve::CrateRoot if is_absolute_path => match ns { + TypeNS => { + ident.span.adjust(Mark::root()); + WhereToResolve::ExternPrelude + } + ValueNS | MacroNS => break, + } + WhereToResolve::CrateRoot => unreachable!(), + WhereToResolve::Module(module) => { + match self.hygienic_lexical_parent(module, &mut ident.span) { + Some(parent_module) => WhereToResolve::Module(parent_module), + None => { + use_prelude = !module.no_implicit_prelude; + match ns { + TypeNS => WhereToResolve::ExternPrelude, + ValueNS => WhereToResolve::StdLibPrelude, + MacroNS => WhereToResolve::MacroUsePrelude, + } + } + } + } + WhereToResolve::MacroUsePrelude => WhereToResolve::BuiltinMacros, + WhereToResolve::BuiltinMacros => WhereToResolve::BuiltinAttrs, + WhereToResolve::BuiltinAttrs => WhereToResolve::LegacyPluginHelpers, + WhereToResolve::LegacyPluginHelpers => break, // nowhere else to search + WhereToResolve::ExternPrelude if is_absolute_path => break, + WhereToResolve::ExternPrelude => WhereToResolve::ToolPrelude, + WhereToResolve::ToolPrelude => WhereToResolve::StdLibPrelude, + WhereToResolve::StdLibPrelude => match ns { + TypeNS => WhereToResolve::BuiltinTypes, + ValueNS => break, // nowhere else to search + MacroNS => unreachable!(), + } + WhereToResolve::BuiltinTypes => break, // nowhere else to search + }; + + continue; } // The first found solution was the only one, return it. - if let Some(innermost_result) = innermost_result { - return Ok(innermost_result); + if let Some((binding, flags)) = innermost_result { + // We get to here only if there's no ambiguity, in ambiguous cases an error will + // be reported anyway, so there's no reason to report an additional feature error. + // The `binding` can actually be introduced by something other than `--extern`, + // but its `Def` should coincide with a crate passed with `--extern` + // (otherwise there would be ambiguity) and we can skip feature error in this case. + 'ok: { + if !is_import || self.session.features_untracked().uniform_paths { + break 'ok; + } + if ns == TypeNS && use_prelude && self.extern_prelude_get(ident, true).is_some() { + break 'ok; + } + if rust_2015 { + let root_ident = Ident::new(keywords::CrateRoot.name(), orig_ident.span); + let root_module = self.resolve_crate_root(root_ident); + if self.resolve_ident_in_module_ext(ModuleOrUniformRoot::Module(root_module), + orig_ident, ns, None, false, path_span) + .is_ok() { + break 'ok; + } + } + + let msg = "imports can only refer to extern crate names \ + passed with `--extern` on stable channel"; + let mut err = feature_err(&self.session.parse_sess, "uniform_paths", + ident.span, GateIssue::Language, msg); + + let what = self.binding_description(binding, ident, + flags.contains(Flags::MISC_FROM_PRELUDE)); + let note_msg = format!("this import refers to {what}", what = what); + if binding.span.is_dummy() { + err.note(¬e_msg); + } else { + err.span_note(binding.span, ¬e_msg); + err.span_label(binding.span, "not an extern crate passed with `--extern`"); + } + err.emit(); + } + + return Ok(binding); } - let determinacy = Determinacy::determined(force); - if determinacy == Determinacy::Determined && kind == Some(MacroKind::Attr) { + let determinacy = Determinacy::determined(determinacy == Determinacy::Determined || force); + if determinacy == Determinacy::Determined && macro_kind == Some(MacroKind::Attr) { // For single-segment attributes interpret determinate "no resolution" as a custom // attribute. (Lexical resolution implies the first segment and attr kind should imply // the last segment, so we are certainly working with a single-segment attribute here.) @@ -815,188 +998,96 @@ let binding = (Def::NonMacroAttr(NonMacroAttrKind::Custom), ty::Visibility::Public, ident.span, Mark::root()) .to_name_binding(self.arenas); - Ok((binding, FromPrelude(true))) + Ok(binding) } else { Err(determinacy) } } - fn resolve_legacy_scope( - &mut self, - ident: Ident, - kind: Option, - parent_scope: &ParentScope<'a>, - record_used: bool, - ) -> Option<&'a NameBinding<'a>> { - if sub_namespace_mismatch(kind, Some(MacroKind::Bang)) { - return None; - } - - let ident = ident.modern(); - - // This is *the* result, resolution from the scope closest to the resolved identifier. - // However, sometimes this result is "weak" because it comes from a macro expansion, - // and in this case it cannot shadow names from outer scopes, e.g. - // macro_rules! m { ... } // solution in outer scope - // { - // define_m!(); // generates another `macro_rules! m` - innermost solution - // // weak, cannot shadow the outer `m`, need to report ambiguity error - // m!(); - // } - // So we have to save the innermost solution and continue searching in outer scopes - // to detect potential ambiguities. - let mut innermost_result: Option<&NameBinding> = None; - - // Go through all the scopes and try to resolve the name. - let mut where_to_resolve = parent_scope.legacy; - loop { - let result = match where_to_resolve { - LegacyScope::Binding(legacy_binding) if ident == legacy_binding.ident => - Some(legacy_binding.binding), - _ => None, - }; - - macro_rules! continue_search { () => { - where_to_resolve = match where_to_resolve { - LegacyScope::Empty => break, // nowhere else to search - LegacyScope::Binding(binding) => binding.parent_legacy_scope, - LegacyScope::Invocation(invocation) => invocation.output_legacy_scope.get(), - LegacyScope::Uninitialized => unreachable!(), - }; - - continue; - }} - - match result { - Some(result) => { - if !record_used { - return Some(result); - } - - if let Some(innermost_result) = innermost_result { - // Found another solution, if the first one was "weak", report an error. - if result.def() != innermost_result.def() && - innermost_result.may_appear_after(parent_scope.expansion, result) { - self.ambiguity_errors.push(AmbiguityError { - ident, - b1: innermost_result, - b2: result, - }); - return Some(innermost_result); - } - } else { - // Found the first solution. - innermost_result = Some(result); - } + pub fn finalize_current_module_macro_resolutions(&mut self) { + let module = self.current_module; - continue_search!(); + let check_consistency = |this: &mut Self, path: &[Segment], span, + kind: MacroKind, initial_def, def| { + if let Some(initial_def) = initial_def { + if def != initial_def && def != Def::Err && this.ambiguity_errors.is_empty() { + // Make sure compilation does not succeed if preferred macro resolution + // has changed after the macro had been expanded. In theory all such + // situations should be reported as ambiguity errors, so this is a bug. + span_bug!(span, "inconsistent resolution for a macro"); } - None => { - continue_search!(); + } else { + // It's possible that the macro was unresolved (indeterminate) and silently + // expanded into a dummy fragment for recovery during expansion. + // Now, post-expansion, the resolution may succeed, but we can't change the + // past and need to report an error. + // However, non-speculative `resolve_path` can successfully return private items + // even if speculative `resolve_path` returned nothing previously, so we skip this + // less informative error if the privacy error is reported elsewhere. + if this.privacy_errors.is_empty() { + let msg = format!("cannot determine resolution for the {} `{}`", + kind.descr(), Segment::names_to_string(path)); + let msg_note = "import resolution is stuck, try simplifying macro imports"; + this.session.struct_span_err(span, &msg).note(msg_note).emit(); } } - } - - // The first found solution was the only one (or there was no solution at all), return it. - innermost_result - } + }; - pub fn finalize_current_module_macro_resolutions(&mut self) { - let module = self.current_module; - for &(ref path, span) in module.macro_resolutions.borrow().iter() { - match self.resolve_path(None, &path, Some(MacroNS), true, span, CrateLint::No) { - PathResult::NonModule(_) => {}, - PathResult::Failed(span, msg, _) => { + let macro_resolutions = + mem::replace(&mut *module.multi_segment_macro_resolutions.borrow_mut(), Vec::new()); + for (mut path, path_span, kind, parent_scope, initial_def) in macro_resolutions { + // FIXME: Path resolution will ICE if segment IDs present. + for seg in &mut path { seg.id = None; } + match self.resolve_path(&path, Some(MacroNS), &parent_scope, + true, path_span, CrateLint::No) { + PathResult::NonModule(path_res) if path_res.unresolved_segments() == 0 => { + let def = path_res.base_def(); + check_consistency(self, &path, path_span, kind, initial_def, def); + } + path_res @ PathResult::NonModule(..) | path_res @ PathResult::Failed(..) => { + let (span, msg) = if let PathResult::Failed(span, msg, ..) = path_res { + (span, msg) + } else { + (path_span, format!("partially resolved path in {} {}", + kind.article(), kind.descr())) + }; resolve_error(self, span, ResolutionError::FailedToResolve(&msg)); } - _ => unreachable!(), + PathResult::Module(..) | PathResult::Indeterminate => unreachable!(), } } - let legacy_macro_resolutions = - mem::replace(&mut *module.legacy_macro_resolutions.borrow_mut(), Vec::new()); - for (ident, kind, parent_scope, def) in legacy_macro_resolutions { - let span = ident.span; - let legacy_resolution = self.resolve_legacy_scope( - ident, Some(kind), &parent_scope, true - ); - let resolution = self.resolve_lexical_macro_path_segment( - ident, MacroNS, Some(kind), &parent_scope, true, true, span - ); - - let check_consistency = |this: &Self, new_def: Def| { - if let Some(def) = def { - if this.ambiguity_errors.is_empty() && new_def != def && new_def != Def::Err { - // Make sure compilation does not succeed if preferred macro resolution - // has changed after the macro had been expanded. In theory all such - // situations should be reported as ambiguity errors, so this is span-bug. - span_bug!(span, "inconsistent resolution for a macro"); - } - } else { - // It's possible that the macro was unresolved (indeterminate) and silently - // expanded into a dummy fragment for recovery during expansion. - // Now, post-expansion, the resolution may succeed, but we can't change the - // past and need to report an error. - let msg = - format!("cannot determine resolution for the {} `{}`", kind.descr(), ident); - let msg_note = "import resolution is stuck, try simplifying macro imports"; - this.session.struct_span_err(span, &msg).note(msg_note).emit(); + let macro_resolutions = + mem::replace(&mut *module.single_segment_macro_resolutions.borrow_mut(), Vec::new()); + for (ident, kind, parent_scope, initial_binding) in macro_resolutions { + match self.early_resolve_ident_in_lexical_scope(ident, ScopeSet::Macro(kind), + &parent_scope, true, true, ident.span) { + Ok(binding) => { + let initial_def = initial_binding.map(|initial_binding| { + self.record_use(ident, MacroNS, initial_binding, false); + initial_binding.def_ignoring_ambiguity() + }); + let def = binding.def_ignoring_ambiguity(); + let seg = Segment::from_ident(ident); + check_consistency(self, &[seg], ident.span, kind, initial_def, def); } - }; - - match (legacy_resolution, resolution) { - (None, Err(_)) => { - assert!(def.is_none()); + Err(..) => { + assert!(initial_binding.is_none()); let bang = if kind == MacroKind::Bang { "!" } else { "" }; let msg = format!("cannot find {} `{}{}` in this scope", kind.descr(), ident, bang); - let mut err = self.session.struct_span_err(span, &msg); - self.suggest_macro_name(&ident.as_str(), kind, &mut err, span); + let mut err = self.session.struct_span_err(ident.span, &msg); + self.suggest_macro_name(&ident.as_str(), kind, &mut err, ident.span); err.emit(); - }, - (Some(legacy_binding), Ok((binding, FromPrelude(from_prelude)))) - if legacy_binding.def() != binding.def_ignoring_ambiguity() && - (!from_prelude && - !self.disambiguate_legacy_vs_modern(legacy_binding, binding) || - legacy_binding.may_appear_after(parent_scope.expansion, binding)) => { - self.report_ambiguity_error(ident, legacy_binding, binding); - }, - // OK, non-macro-expanded legacy wins over prelude even if defs are different - // Also, non-macro-expanded legacy wins over modern from the same module - // Also, legacy and modern can co-exist if their defs are same - (Some(legacy_binding), Ok(_)) | - // OK, unambiguous resolution - (Some(legacy_binding), Err(_)) => { - check_consistency(self, legacy_binding.def()); - } - // OK, unambiguous resolution - (None, Ok((binding, FromPrelude(from_prelude)))) => { - check_consistency(self, binding.def_ignoring_ambiguity()); - if from_prelude { - self.record_use(ident, MacroNS, binding); - } } - }; + } } let builtin_attrs = mem::replace(&mut *module.builtin_attrs.borrow_mut(), Vec::new()); for (ident, parent_scope) in builtin_attrs { - let resolve_legacy = |this: &mut Self| this.resolve_legacy_scope( - ident, Some(MacroKind::Attr), &parent_scope, true + let _ = self.early_resolve_ident_in_lexical_scope( + ident, ScopeSet::Macro(MacroKind::Attr), &parent_scope, true, true, ident.span ); - let resolve_modern = |this: &mut Self| this.resolve_lexical_macro_path_segment( - ident, MacroNS, Some(MacroKind::Attr), &parent_scope, true, true, ident.span - ).map(|(binding, _)| binding).ok(); - - if let Some(binding) = resolve_legacy(self).or_else(|| resolve_modern(self)) { - if binding.def_ignoring_ambiguity() != - Def::NonMacroAttr(NonMacroAttrKind::Builtin) { - let builtin_binding = (Def::NonMacroAttr(NonMacroAttrKind::Builtin), - ty::Visibility::Public, ident.span, Mark::root()) - .to_name_binding(self.arenas); - self.report_ambiguity_error(ident, binding, builtin_binding); - } - } } } @@ -1024,7 +1115,7 @@ } }; let ident = Ident::new(Symbol::intern(name), span); - self.lookup_typo_candidate(&[ident], MacroNS, is_macro, span) + self.lookup_typo_candidate(&[Segment::from_ident(ident)], MacroNS, is_macro, span) }); if let Some(suggestion) = suggestion { @@ -1063,7 +1154,7 @@ def_index: invoc.def_index, module: Cell::new(graph_root), parent_legacy_scope: Cell::new(LegacyScope::Uninitialized), - output_legacy_scope: Cell::new(LegacyScope::Uninitialized), + output_legacy_scope: Cell::new(None), }) }); }; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_resolve/resolve_imports.rs rustc-1.31.0+dfsg1+llvm/src/librustc_resolve/resolve_imports.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_resolve/resolve_imports.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_resolve/resolve_imports.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,18 +10,20 @@ use self::ImportDirectiveSubclass::*; -use {AmbiguityError, CrateLint, Module, ModuleOrUniformRoot, PerNS}; +use {AmbiguityError, AmbiguityKind, AmbiguityErrorMisc}; +use {CrateLint, Module, ModuleOrUniformRoot, PerNS, ScopeSet, Weak}; use Namespace::{self, TypeNS, MacroNS}; use {NameBinding, NameBindingKind, ToNameBinding, PathResult, PrivacyError}; -use Resolver; +use {Resolver, Segment}; use {names_to_string, module_to_string}; use {resolve_error, ResolutionError}; +use macros::ParentScope; use rustc_data_structures::ptr_key::PtrKey; use rustc::ty; use rustc::lint::builtin::BuiltinLintDiagnostics; use rustc::lint::builtin::{DUPLICATE_MACRO_EXPORTS, PUB_USE_OF_PRIVATE_EXTERN_CRATE}; -use rustc::hir::def_id::{CRATE_DEF_INDEX, DefId}; +use rustc::hir::def_id::{CrateNum, DefId}; use rustc::hir::def::*; use rustc::session::DiagnosticMessageId; use rustc::util::nodemap::FxHashSet; @@ -34,8 +36,6 @@ use syntax_pos::{MultiSpan, Span}; use std::cell::{Cell, RefCell}; -use std::collections::BTreeMap; -use std::fmt::Write; use std::{mem, ptr}; /// Contains data for specific types of import directives. @@ -52,13 +52,16 @@ max_vis: Cell, // The visibility of the greatest re-export. // n.b. `max_vis` is only used in `finalize_import` to check for re-export errors. }, - ExternCrate(Option), + ExternCrate { + source: Option, + target: Ident, + }, MacroUse, } /// One import directive. #[derive(Debug,Clone)] -pub struct ImportDirective<'a> { +crate struct ImportDirective<'a> { /// The id of the `extern crate`, `UseTree` etc that imported this `ImportDirective`. /// /// In the case where the `ImportDirective` was expanded from a "nested" use tree, @@ -85,21 +88,13 @@ /// Span of the *root* use tree (see `root_id`). pub root_span: Span, - pub parent: Module<'a>, - pub module_path: Vec, + pub parent_scope: ParentScope<'a>, + pub module_path: Vec, /// The resolution of `module_path`. pub imported_module: Cell>>, pub subclass: ImportDirectiveSubclass<'a>, pub vis: Cell, - pub expansion: Mark, pub used: Cell, - - /// Whether this import is a "canary" for the `uniform_paths` feature, - /// i.e. `use x::...;` results in an `use self::x as _;` canary. - /// This flag affects diagnostics: an error is reported if and only if - /// the import resolves successfully and an external crate with the same - /// name (`x` above) also exists; any resolution failures are ignored. - pub is_uniform_paths_canary: bool, } impl<'a> ImportDirective<'a> { @@ -140,96 +135,80 @@ .or_insert_with(|| self.arenas.alloc_name_resolution()) } + crate fn resolve_ident_in_module_unadjusted( + &mut self, + module: ModuleOrUniformRoot<'a>, + ident: Ident, + ns: Namespace, + record_used: bool, + path_span: Span, + ) -> Result<&'a NameBinding<'a>, Determinacy> { + self.resolve_ident_in_module_unadjusted_ext( + module, ident, ns, None, false, record_used, path_span + ).map_err(|(determinacy, _)| determinacy) + } + /// Attempts to resolve `ident` in namespaces `ns` of `module`. /// Invariant: if `record_used` is `Some`, expansion and import resolution must be complete. - pub fn resolve_ident_in_module_unadjusted(&mut self, - module: ModuleOrUniformRoot<'a>, - ident: Ident, - ns: Namespace, - restricted_shadowing: bool, - record_used: bool, - path_span: Span) - -> Result<&'a NameBinding<'a>, Determinacy> { + crate fn resolve_ident_in_module_unadjusted_ext( + &mut self, + module: ModuleOrUniformRoot<'a>, + ident: Ident, + ns: Namespace, + parent_scope: Option<&ParentScope<'a>>, + restricted_shadowing: bool, + record_used: bool, + path_span: Span, + ) -> Result<&'a NameBinding<'a>, (Determinacy, Weak)> { let module = match module { ModuleOrUniformRoot::Module(module) => module, - ModuleOrUniformRoot::UniformRoot(root) => { - // HACK(eddyb): `resolve_path` uses `keywords::Invalid` to indicate - // paths of length 0, and currently these are relative `use` paths. - let can_be_relative = !ident.is_path_segment_keyword() && - root == keywords::Invalid.name(); - if can_be_relative { - // Relative paths should only get here if the feature-gate is on. - assert!(self.session.rust_2018() && - self.session.features_untracked().uniform_paths); - - // Try first to resolve relatively. - let mut ctxt = ident.span.ctxt().modern(); - let self_module = self.resolve_self(&mut ctxt, self.current_module); - - let binding = self.resolve_ident_in_module_unadjusted( - ModuleOrUniformRoot::Module(self_module), - ident, - ns, - restricted_shadowing, - record_used, - path_span, - ); - - // FIXME(eddyb) This may give false negatives, specifically - // if a crate with the same name is found in `extern_prelude`, - // preventing the check below this one from returning `binding` - // in all cases. - // - // That is, if there's no crate with the same name, `binding` - // is always returned, which is the result of doing the exact - // same lookup of `ident`, in the `self` module. - // But when a crate does exist, it will get chosen even when - // macro expansion could result in a success from the lookup - // in the `self` module, later on. - // - // NB. This is currently alleviated by the "ambiguity canaries" - // (see `is_uniform_paths_canary`) that get introduced for the - // maybe-relative imports handled here: if the false negative - // case were to arise, it would *also* cause an ambiguity error. - if binding.is_ok() { - return binding; - } - - // Fall back to resolving to an external crate. - if !( - ns == TypeNS && - !ident.is_path_segment_keyword() && - self.extern_prelude.contains(&ident.name) - ) { - // ... unless the crate name is not in the `extern_prelude`. - return binding; + ModuleOrUniformRoot::CrateRootAndExternPrelude => { + assert!(!restricted_shadowing); + let parent_scope = self.dummy_parent_scope(); + let binding = self.early_resolve_ident_in_lexical_scope( + ident, ScopeSet::AbsolutePath(ns), &parent_scope, + record_used, record_used, path_span, + ); + return binding.map_err(|determinacy| (determinacy, Weak::No)); + } + ModuleOrUniformRoot::ExternPrelude => { + assert!(!restricted_shadowing); + return if ns != TypeNS { + Err((Determined, Weak::No)) + } else if let Some(binding) = self.extern_prelude_get(ident, !record_used) { + Ok(binding) + } else if !self.graph_root.unresolved_invocations.borrow().is_empty() { + // Macro-expanded `extern crate` items can add names to extern prelude. + Err((Undetermined, Weak::No)) + } else { + Err((Determined, Weak::No)) + } + } + ModuleOrUniformRoot::CurrentScope => { + assert!(!restricted_shadowing); + let parent_scope = + parent_scope.expect("no parent scope for a single-segment import"); + + if ns == TypeNS { + if ident.name == keywords::Crate.name() || + ident.name == keywords::DollarCrate.name() { + let module = self.resolve_crate_root(ident); + let binding = (module, ty::Visibility::Public, + module.span, Mark::root()) + .to_name_binding(self.arenas); + return Ok(binding); + } else if ident.name == keywords::Super.name() || + ident.name == keywords::SelfValue.name() { + // FIXME: Implement these with renaming requirements so that e.g. + // `use super;` doesn't work, but `use super as name;` does. + // Fall through here to get an error from `early_resolve_...`. } } - let crate_root = if - ns == TypeNS && - root != keywords::Extern.name() && - ( - ident.name == keywords::Crate.name() || - ident.name == keywords::DollarCrate.name() - ) - { - self.resolve_crate_root(ident) - } else if - ns == TypeNS && - !ident.is_path_segment_keyword() && - self.extern_prelude.contains(&ident.name) - { - let crate_id = - self.crate_loader.process_path_extern(ident.name, ident.span); - self.get_module(DefId { krate: crate_id, index: CRATE_DEF_INDEX }) - } else { - return Err(Determined); - }; - self.populate_module_if_necessary(crate_root); - let binding = (crate_root, ty::Visibility::Public, - ident.span, Mark::root()).to_name_binding(self.arenas); - return Ok(binding); + let binding = self.early_resolve_ident_in_lexical_scope( + ident, ScopeSet::Import(ns), parent_scope, record_used, record_used, path_span + ); + return binding.map_err(|determinacy| (determinacy, Weak::No)); } }; @@ -237,7 +216,7 @@ let resolution = self.resolution(module, ident, ns) .try_borrow_mut() - .map_err(|_| Determined)?; // This happens when there is a cycle of imports + .map_err(|_| (Determined, Weak::No))?; // This happens when there is a cycle of imports. if let Some(binding) = resolution.binding { if !restricted_shadowing && binding.expansion != Mark::root() { @@ -247,37 +226,46 @@ } } + let check_usable = |this: &mut Self, binding: &'a NameBinding<'a>| { + // `extern crate` are always usable for backwards compatibility, see issue #37020, + // remove this together with `PUB_USE_OF_PRIVATE_EXTERN_CRATE`. + let usable = this.is_accessible(binding.vis) || binding.is_extern_crate(); + if usable { Ok(binding) } else { Err((Determined, Weak::No)) } + }; + if record_used { - if let Some(binding) = resolution.binding { - if let Some(shadowed_glob) = resolution.shadowed_glob { - // Forbid expanded shadowing to avoid time travel. - if restricted_shadowing && - binding.expansion != Mark::root() && - ns != MacroNS && // In MacroNS, `try_define` always forbids this shadowing - binding.def() != shadowed_glob.def() { - self.ambiguity_errors.push(AmbiguityError { - ident, - b1: binding, - b2: shadowed_glob, - }); + return resolution.binding.ok_or((Determined, Weak::No)).and_then(|binding| { + if self.last_import_segment && check_usable(self, binding).is_err() { + Err((Determined, Weak::No)) + } else { + self.record_use(ident, ns, binding, restricted_shadowing); + + if let Some(shadowed_glob) = resolution.shadowed_glob { + // Forbid expanded shadowing to avoid time travel. + if restricted_shadowing && + binding.expansion != Mark::root() && + binding.def() != shadowed_glob.def() { + self.ambiguity_errors.push(AmbiguityError { + kind: AmbiguityKind::GlobVsExpanded, + ident, + b1: binding, + b2: shadowed_glob, + misc1: AmbiguityErrorMisc::None, + misc2: AmbiguityErrorMisc::None, + }); + } } - } - if self.record_use(ident, ns, binding) { - return Ok(self.dummy_binding); - } - if !self.is_accessible(binding.vis) { - self.privacy_errors.push(PrivacyError(path_span, ident.name, binding)); - } - } - return resolution.binding.ok_or(Determined); - } + if !self.is_accessible(binding.vis) && + // Remove this together with `PUB_USE_OF_PRIVATE_EXTERN_CRATE` + !(self.last_import_segment && binding.is_extern_crate()) { + self.privacy_errors.push(PrivacyError(path_span, ident, binding)); + } - let check_usable = |this: &mut Self, binding: &'a NameBinding<'a>| { - // `extern crate` are always usable for backwards compatibility, see issue #37020. - let usable = this.is_accessible(binding.vis) || binding.is_extern_crate(); - if usable { Ok(binding) } else { Err(Determined) } - }; + Ok(binding) + } + }) + } // Items and single imports are not shadowable, if we have one, then it's determined. if let Some(binding) = resolution.binding { @@ -294,16 +282,19 @@ if !self.is_accessible(single_import.vis.get()) { continue; } - let module = unwrap_or!(single_import.imported_module.get(), return Err(Undetermined)); + let module = unwrap_or!(single_import.imported_module.get(), + return Err((Undetermined, Weak::No))); let ident = match single_import.subclass { SingleImport { source, .. } => source, _ => unreachable!(), }; - match self.resolve_ident_in_module(module, ident, ns, false, path_span) { + match self.resolve_ident_in_module(module, ident, ns, Some(&single_import.parent_scope), + false, path_span) { Err(Determined) => continue, - Ok(binding) - if !self.is_accessible_from(binding.vis, single_import.parent) => continue, - Ok(_) | Err(Undetermined) => return Err(Undetermined), + Ok(binding) if !self.is_accessible_from( + binding.vis, single_import.parent_scope.module + ) => continue, + Ok(_) | Err(Undetermined) => return Err((Undetermined, Weak::No)), } } @@ -324,7 +315,7 @@ if !unexpanded_macros || ns == MacroNS || restricted_shadowing { return check_usable(self, binding); } else { - return Err(Undetermined); + return Err((Undetermined, Weak::No)); } } @@ -333,17 +324,13 @@ // Now we are in situation when new item/import can appear only from a glob or a macro // expansion. With restricted shadowing names from globs and macro expansions cannot // shadow names from outer scopes, so we can freely fallback from module search to search - // in outer scopes. To continue search in outer scopes we have to lie a bit and return - // `Determined` to `resolve_lexical_macro_path_segment` even if the correct answer - // for in-module resolution could be `Undetermined`. - if restricted_shadowing { - return Err(Determined); - } + // in outer scopes. For `early_resolve_ident_in_lexical_scope` to continue search in outer + // scopes we return `Undetermined` with `Weak::Yes`. // Check if one of unexpanded macros can still define the name, // if it can then our "no resolution" result is not determined and can be invalidated. if unexpanded_macros { - return Err(Undetermined); + return Err((Undetermined, Weak::Yes)); } // Check if one of glob imports can still define the name, @@ -354,8 +341,8 @@ } let module = match glob_import.imported_module.get() { Some(ModuleOrUniformRoot::Module(module)) => module, - Some(ModuleOrUniformRoot::UniformRoot(_)) => continue, - None => return Err(Undetermined), + Some(_) => continue, + None => return Err((Undetermined, Weak::Yes)), }; let (orig_current_module, mut ident) = (self.current_module, ident.modern()); match ident.span.glob_adjust(module.expansion, glob_import.span.ctxt().modern()) { @@ -368,37 +355,36 @@ ident, ns, false, - false, path_span, ); self.current_module = orig_current_module; match result { Err(Determined) => continue, - Ok(binding) - if !self.is_accessible_from(binding.vis, glob_import.parent) => continue, - Ok(_) | Err(Undetermined) => return Err(Undetermined), + Ok(binding) if !self.is_accessible_from( + binding.vis, glob_import.parent_scope.module + ) => continue, + Ok(_) | Err(Undetermined) => return Err((Undetermined, Weak::Yes)), } } // No resolution and no one else can define the name - determinate error. - Err(Determined) + Err((Determined, Weak::No)) } // Add an import directive to the current module. pub fn add_import_directive(&mut self, - module_path: Vec, + module_path: Vec, subclass: ImportDirectiveSubclass<'a>, span: Span, id: NodeId, root_span: Span, root_id: NodeId, vis: ty::Visibility, - expansion: Mark, - is_uniform_paths_canary: bool) { - let current_module = self.current_module; + parent_scope: ParentScope<'a>) { + let current_module = parent_scope.module; let directive = self.arenas.alloc_import_directive(ImportDirective { - parent: current_module, + parent_scope, module_path, imported_module: Cell::new(None), subclass, @@ -407,9 +393,7 @@ root_span, root_id, vis: Cell::new(vis), - expansion, used: Cell::new(false), - is_uniform_paths_canary, }); debug!("add_import_directive({:?})", directive); @@ -425,15 +409,15 @@ // We don't add prelude imports to the globs since they only affect lexical scopes, // which are not relevant to import resolution. GlobImport { is_prelude: true, .. } => {} - GlobImport { .. } => self.current_module.globs.borrow_mut().push(directive), + GlobImport { .. } => current_module.globs.borrow_mut().push(directive), _ => unreachable!(), } } // Given a binding and an import directive that resolves to it, // return the corresponding binding defined by the import directive. - pub fn import(&self, binding: &'a NameBinding<'a>, directive: &'a ImportDirective<'a>) - -> &'a NameBinding<'a> { + crate fn import(&self, binding: &'a NameBinding<'a>, directive: &'a ImportDirective<'a>) + -> &'a NameBinding<'a> { let vis = if binding.pseudo_vis().is_at_least(directive.vis.get(), self) || // c.f. `PUB_USE_OF_PRIVATE_EXTERN_CRATE` !directive.is_glob() && binding.is_extern_crate() { @@ -456,7 +440,7 @@ }, span: directive.span, vis, - expansion: directive.expansion, + expansion: directive.parent_scope.expansion, }) } @@ -481,38 +465,48 @@ self.set_binding_parent_module(binding, module); self.update_resolution(module, ident, ns, |this, resolution| { if let Some(old_binding) = resolution.binding { - if binding.is_glob_import() { - if !old_binding.is_glob_import() && - !(ns == MacroNS && old_binding.expansion != Mark::root()) { - resolution.shadowed_glob = Some(binding); - } else if binding.def() != old_binding.def() { - resolution.binding = Some(this.ambiguity(old_binding, binding)); - } else if !old_binding.vis.is_at_least(binding.vis, &*this) { - // We are glob-importing the same item but with greater visibility. - resolution.binding = Some(binding); + match (old_binding.is_glob_import(), binding.is_glob_import()) { + (true, true) => { + if binding.def() != old_binding.def() { + resolution.binding = Some(this.ambiguity(AmbiguityKind::GlobVsGlob, + old_binding, binding)); + } else if !old_binding.vis.is_at_least(binding.vis, &*this) { + // We are glob-importing the same item but with greater visibility. + resolution.binding = Some(binding); + } } - } else if old_binding.is_glob_import() { - if ns == MacroNS && binding.expansion != Mark::root() && - binding.def() != old_binding.def() { - resolution.binding = Some(this.ambiguity(binding, old_binding)); - } else { - resolution.binding = Some(binding); - resolution.shadowed_glob = Some(old_binding); + (old_glob @ true, false) | (old_glob @ false, true) => { + let (glob_binding, nonglob_binding) = if old_glob { + (old_binding, binding) + } else { + (binding, old_binding) + }; + if glob_binding.def() != nonglob_binding.def() && + ns == MacroNS && nonglob_binding.expansion != Mark::root() { + resolution.binding = Some(this.ambiguity(AmbiguityKind::GlobVsExpanded, + nonglob_binding, glob_binding)); + } else { + resolution.binding = Some(nonglob_binding); + resolution.shadowed_glob = Some(glob_binding); + } } - } else if let (&NameBindingKind::Def(_, true), &NameBindingKind::Def(_, true)) = - (&old_binding.kind, &binding.kind) { + (false, false) => { + if let (&NameBindingKind::Def(_, true), &NameBindingKind::Def(_, true)) = + (&old_binding.kind, &binding.kind) { + + this.session.buffer_lint_with_diagnostic( + DUPLICATE_MACRO_EXPORTS, + CRATE_NODE_ID, + binding.span, + &format!("a macro named `{}` has already been exported", ident), + BuiltinLintDiagnostics::DuplicatedMacroExports( + ident, old_binding.span, binding.span)); - this.session.buffer_lint_with_diagnostic( - DUPLICATE_MACRO_EXPORTS, - CRATE_NODE_ID, - binding.span, - &format!("a macro named `{}` has already been exported", ident), - BuiltinLintDiagnostics::DuplicatedMacroExports( - ident, old_binding.span, binding.span)); - - resolution.binding = Some(binding); - } else { - return Err(old_binding); + resolution.binding = Some(binding); + } else { + return Err(old_binding); + } + } } } else { resolution.binding = Some(binding); @@ -522,10 +516,10 @@ }) } - pub fn ambiguity(&self, b1: &'a NameBinding<'a>, b2: &'a NameBinding<'a>) + fn ambiguity(&self, kind: AmbiguityKind, b1: &'a NameBinding<'a>, b2: &'a NameBinding<'a>) -> &'a NameBinding<'a> { self.arenas.alloc_name_binding(NameBinding { - kind: NameBindingKind::Ambiguity { b1, b2 }, + kind: NameBindingKind::Ambiguity { kind, b1, b2 }, vis: if b1.vis.is_at_least(b2.vis, self) { b1.vis } else { b2.vis }, span: b1.span, expansion: Mark::root(), @@ -562,12 +556,12 @@ let scope = match ident.span.reverse_glob_adjust(module.expansion, directive.span.ctxt().modern()) { Some(Some(def)) => self.macro_def_scope(def), - Some(None) => directive.parent, + Some(None) => directive.parent_scope.module, None => continue, }; if self.is_accessible_from(binding.vis, scope) { let imported_binding = self.import(binding, directive); - let _ = self.try_define(directive.parent, ident, ns, imported_binding); + let _ = self.try_define(directive.parent_scope.module, ident, ns, imported_binding); } } @@ -581,7 +575,7 @@ let dummy_binding = self.dummy_binding; let dummy_binding = self.import(dummy_binding, directive); self.per_ns(|this, ns| { - let _ = this.try_define(directive.parent, target, ns, dummy_binding); + let _ = this.try_define(directive.parent_scope.module, target, ns, dummy_binding); }); } } @@ -639,73 +633,20 @@ self.finalize_resolutions_in(module); } - struct UniformPathsCanaryResults<'a> { - name: Name, - module_scope: Option<&'a NameBinding<'a>>, - block_scopes: Vec<&'a NameBinding<'a>>, - } - - // Collect all tripped `uniform_paths` canaries separately. - let mut uniform_paths_canaries: BTreeMap< - (Span, NodeId, Namespace), - UniformPathsCanaryResults, - > = BTreeMap::new(); - let mut errors = false; - let mut seen_spans = FxHashSet(); + let mut seen_spans = FxHashSet::default(); let mut error_vec = Vec::new(); let mut prev_root_id: NodeId = NodeId::new(0); for i in 0 .. self.determined_imports.len() { let import = self.determined_imports[i]; - let error = self.finalize_import(import); - - // For a `#![feature(uniform_paths)]` `use self::x as _` canary, - // failure is ignored, while success may cause an ambiguity error. - if import.is_uniform_paths_canary { - if error.is_some() { - continue; - } - - let (name, result) = match import.subclass { - SingleImport { source, ref result, .. } => (source.name, result), - _ => bug!(), - }; - - let has_explicit_self = - import.module_path.len() > 0 && - import.module_path[0].name == keywords::SelfValue.name(); - - self.per_ns(|_, ns| { - if let Some(result) = result[ns].get().ok() { - let canary_results = - uniform_paths_canaries.entry((import.span, import.id, ns)) - .or_insert(UniformPathsCanaryResults { - name, - module_scope: None, - block_scopes: vec![], - }); - - // All the canaries with the same `id` should have the same `name`. - assert_eq!(canary_results.name, name); - - if has_explicit_self { - // There should only be one `self::x` (module-scoped) canary. - assert!(canary_results.module_scope.is_none()); - canary_results.module_scope = Some(result); - } else { - canary_results.block_scopes.push(result); - } - } - }); - } else if let Some((span, err)) = error { + if let Some((span, err, note)) = self.finalize_import(import) { errors = true; if let SingleImport { source, ref result, .. } = import.subclass { if source.name == "self" { // Silence `unresolved import` error if E0429 is already emitted - match result.value_ns.get() { - Err(Determined) => continue, - _ => {}, + if let Err(Determined) = result.value_ns.get() { + continue; } } } @@ -723,85 +664,18 @@ self.throw_unresolved_import_error(empty_vec, None); } if !seen_spans.contains(&span) { - let path = import_path_to_string(&import.module_path[..], - &import.subclass, - span); - error_vec.push((span, path, err)); + let path = import_path_to_string( + &import.module_path.iter().map(|seg| seg.ident).collect::>(), + &import.subclass, + span, + ); + error_vec.push((span, path, err, note)); seen_spans.insert(span); prev_root_id = import.root_id; } } } - let uniform_paths_feature = self.session.features_untracked().uniform_paths; - for ((span, _, ns), results) in uniform_paths_canaries { - let name = results.name; - let external_crate = if ns == TypeNS && self.extern_prelude.contains(&name) { - let crate_id = - self.crate_loader.process_path_extern(name, span); - Some(Def::Mod(DefId { krate: crate_id, index: CRATE_DEF_INDEX })) - } else { - None - }; - - // Currently imports can't resolve in non-module scopes, - // we only have canaries in them for future-proofing. - if external_crate.is_none() && results.module_scope.is_none() { - continue; - } - - { - let mut all_results = external_crate.into_iter().chain( - results.module_scope.iter() - .chain(&results.block_scopes) - .map(|binding| binding.def()) - ); - let first = all_results.next().unwrap(); - - // An ambiguity requires more than one *distinct* possible resolution. - let possible_resultions = - 1 + all_results.filter(|&def| def != first).count(); - if possible_resultions <= 1 { - continue; - } - } - - errors = true; - - let msg = format!("`{}` import is ambiguous", name); - let mut err = self.session.struct_span_err(span, &msg); - let mut suggestion_choices = String::new(); - if external_crate.is_some() { - write!(suggestion_choices, "`::{}`", name); - err.span_label(span, - format!("can refer to external crate `::{}`", name)); - } - if let Some(result) = results.module_scope { - if !suggestion_choices.is_empty() { - suggestion_choices.push_str(" or "); - } - write!(suggestion_choices, "`self::{}`", name); - if uniform_paths_feature { - err.span_label(result.span, - format!("can refer to `self::{}`", name)); - } else { - err.span_label(result.span, - format!("may refer to `self::{}` in the future", name)); - } - } - for result in results.block_scopes { - err.span_label(result.span, - format!("shadowed by block-scoped `{}`", name)); - } - err.help(&format!("write {} explicitly instead", suggestion_choices)); - if uniform_paths_feature { - err.note("relative `use` paths enabled by `#![feature(uniform_paths)]`"); - } else { - err.note("in the future, `#![feature(uniform_paths)]` may become the default"); - } - err.emit(); - } - if !error_vec.is_empty() { self.throw_unresolved_import_error(error_vec.clone(), None); } @@ -810,37 +684,51 @@ // to avoid generating multiple errors on the same import. if !errors { for import in &self.indeterminate_imports { - if import.is_uniform_paths_canary { - continue; - } self.throw_unresolved_import_error(error_vec, Some(MultiSpan::from(import.span))); break; } } } - fn throw_unresolved_import_error(&self, error_vec: Vec<(Span, String, String)>, - span: Option) { + fn throw_unresolved_import_error( + &self, + error_vec: Vec<(Span, String, String, Option)>, + span: Option, + ) { let max_span_label_msg_count = 10; // upper limit on number of span_label message. - let (span,msg) = match error_vec.is_empty() { - true => (span.unwrap(), "unresolved import".to_string()), - false => { - let span = MultiSpan::from_spans(error_vec.clone().into_iter() - .map(|elem: (Span, String, String)| { elem.0 } - ).collect()); - let path_vec: Vec = error_vec.clone().into_iter() - .map(|elem: (Span, String, String)| { format!("`{}`", elem.1) } - ).collect(); - let path = path_vec.join(", "); - let msg = format!("unresolved import{} {}", - if path_vec.len() > 1 { "s" } else { "" }, path); - (span, msg) - } + let (span, msg, note) = if error_vec.is_empty() { + (span.unwrap(), "unresolved import".to_string(), None) + } else { + let span = MultiSpan::from_spans( + error_vec.clone().into_iter() + .map(|elem: (Span, String, String, Option)| elem.0) + .collect() + ); + + let note: Option = error_vec.clone().into_iter() + .filter_map(|elem: (Span, String, String, Option)| elem.3) + .last(); + + let path_vec: Vec = error_vec.clone().into_iter() + .map(|elem: (Span, String, String, Option)| format!("`{}`", elem.1)) + .collect(); + let path = path_vec.join(", "); + let msg = format!( + "unresolved import{} {}", + if path_vec.len() > 1 { "s" } else { "" }, + path + ); + + (span, msg, note) }; + let mut err = struct_span_err!(self.resolver.session, span, E0432, "{}", &msg); for span_error in error_vec.into_iter().take(max_span_label_msg_count) { err.span_label(span_error.0, span_error.2); } + if let Some(note) = note { + err.note(¬e); + } err.emit(); } @@ -848,36 +736,31 @@ /// If successful, the resolved bindings are written into the module. fn resolve_import(&mut self, directive: &'b ImportDirective<'b>) -> bool { debug!("(resolving import for module) resolving import `{}::...` in `{}`", - names_to_string(&directive.module_path[..]), - module_to_string(self.current_module).unwrap_or("???".to_string())); + Segment::names_to_string(&directive.module_path), + module_to_string(self.current_module).unwrap_or_else(|| "???".to_string())); - self.current_module = directive.parent; + self.current_module = directive.parent_scope.module; let module = if let Some(module) = directive.imported_module.get() { module } else { - let vis = directive.vis.get(); - // For better failure detection, pretend that the import will not define any names - // while resolving its module path. - directive.vis.set(ty::Visibility::Invisible); - let result = self.resolve_path( - Some(if directive.is_uniform_paths_canary { - ModuleOrUniformRoot::Module(directive.parent) - } else { - ModuleOrUniformRoot::UniformRoot(keywords::Invalid.name()) - }), - &directive.module_path[..], + // For better failure detection, pretend that the import will + // not define any names while resolving its module path. + let orig_vis = directive.vis.replace(ty::Visibility::Invisible); + let path_res = self.resolve_path( + &directive.module_path, None, + &directive.parent_scope, false, directive.span, directive.crate_lint(), ); - directive.vis.set(vis); + directive.vis.set(orig_vis); - match result { + match path_res { PathResult::Module(module) => module, PathResult::Indeterminate => return false, - _ => return true, + PathResult::NonModule(..) | PathResult::Failed(..) => return true, } }; @@ -895,16 +778,20 @@ let mut indeterminate = false; self.per_ns(|this, ns| if !type_ns_only || ns == TypeNS { if let Err(Undetermined) = result[ns].get() { - result[ns].set(this.resolve_ident_in_module(module, - source, - ns, - false, - directive.span)); + // For better failure detection, pretend that the import will + // not define any names while resolving its module path. + let orig_vis = directive.vis.replace(ty::Visibility::Invisible); + let binding = this.resolve_ident_in_module( + module, source, ns, Some(&directive.parent_scope), false, directive.span + ); + directive.vis.set(orig_vis); + + result[ns].set(binding); } else { return }; - let parent = directive.parent; + let parent = directive.parent_scope.module; match result[ns].get() { Err(Undetermined) => indeterminate = true, Err(Determined) => { @@ -935,55 +822,71 @@ } // If appropriate, returns an error to report. - fn finalize_import(&mut self, directive: &'b ImportDirective<'b>) -> Option<(Span, String)> { - self.current_module = directive.parent; - let ImportDirective { ref module_path, span, .. } = *directive; - - let module_result = self.resolve_path( - Some(if directive.is_uniform_paths_canary { - ModuleOrUniformRoot::Module(directive.parent) - } else { - ModuleOrUniformRoot::UniformRoot(keywords::Invalid.name()) - }), - &module_path, - None, - true, - span, - directive.crate_lint(), - ); - let module = match module_result { - PathResult::Module(module) => module, + fn finalize_import( + &mut self, + directive: &'b ImportDirective<'b> + ) -> Option<(Span, String, Option)> { + self.current_module = directive.parent_scope.module; + + let orig_vis = directive.vis.replace(ty::Visibility::Invisible); + let path_res = self.resolve_path(&directive.module_path, None, &directive.parent_scope, + true, directive.span, directive.crate_lint()); + directive.vis.set(orig_vis); + let module = match path_res { + PathResult::Module(module) => { + // Consistency checks, analogous to `finalize_current_module_macro_resolutions`. + if let Some(initial_module) = directive.imported_module.get() { + if module != initial_module && self.ambiguity_errors.is_empty() { + span_bug!(directive.span, "inconsistent resolution for an import"); + } + } else { + if self.privacy_errors.is_empty() { + let msg = "cannot determine resolution for the import"; + let msg_note = "import resolution is stuck, try simplifying other imports"; + self.session.struct_span_err(directive.span, msg).note(msg_note).emit(); + } + } + + module + } PathResult::Failed(span, msg, false) => { + assert!(!self.ambiguity_errors.is_empty() || + directive.imported_module.get().is_none()); resolve_error(self, span, ResolutionError::FailedToResolve(&msg)); return None; } PathResult::Failed(span, msg, true) => { - let (mut self_path, mut self_result) = (module_path.clone(), None); - let is_special = |ident: Ident| ident.is_path_segment_keyword() && - ident.name != keywords::CrateRoot.name(); - if !self_path.is_empty() && !is_special(self_path[0]) && - !(self_path.len() > 1 && is_special(self_path[1])) { - self_path[0].name = keywords::SelfValue.name(); - self_result = Some(self.resolve_path(None, &self_path, None, false, - span, CrateLint::No)); - } - return if let Some(PathResult::Module(..)) = self_result { - Some((span, format!("Did you mean `{}`?", names_to_string(&self_path[..])))) + assert!(!self.ambiguity_errors.is_empty() || + directive.imported_module.get().is_none()); + return if let Some((suggested_path, note)) = self.make_path_suggestion( + span, directive.module_path.clone(), &directive.parent_scope + ) { + Some(( + span, + format!("did you mean `{}`?", Segment::names_to_string(&suggested_path)), + note, + )) } else { - Some((span, msg)) + Some((span, msg, None)) }; - }, - _ => return None, + } + PathResult::NonModule(path_res) if path_res.base_def() == Def::Err => { + // The error was already reported earlier. + assert!(!self.ambiguity_errors.is_empty() || + directive.imported_module.get().is_none()); + return None; + } + PathResult::Indeterminate | PathResult::NonModule(..) => unreachable!(), }; let (ident, result, type_ns_only) = match directive.subclass { SingleImport { source, ref result, type_ns_only, .. } => (source, result, type_ns_only), GlobImport { is_prelude, ref max_vis } => { - if module_path.len() <= 1 { + if directive.module_path.len() <= 1 { // HACK(eddyb) `lint_if_path_starts_with_module` needs at least // 2 segments, so the `resolve_path` above won't trigger it. - let mut full_path = module_path.clone(); - full_path.push(keywords::Invalid.ident()); + let mut full_path = directive.module_path.clone(); + full_path.push(Segment::from_ident(keywords::Invalid.ident())); self.lint_if_path_starts_with_module( directive.crate_lint(), &full_path, @@ -993,10 +896,13 @@ } if let ModuleOrUniformRoot::Module(module) = module { - if module.def_id() == directive.parent.def_id() { + if module.def_id() == directive.parent_scope.module.def_id() { // Importing a module into itself is not allowed. - return Some((directive.span, - "Cannot glob-import a module into itself.".to_string())); + return Some(( + directive.span, + "Cannot glob-import a module into itself.".to_string(), + None, + )); } } if !is_prelude && @@ -1010,37 +916,66 @@ _ => unreachable!(), }; - // Do not record uses from canaries, to avoid interfering with other - // diagnostics or suggestions that rely on some items not being used. - let record_used = !directive.is_uniform_paths_canary; - let mut all_ns_err = true; self.per_ns(|this, ns| if !type_ns_only || ns == TypeNS { - if let Ok(binding) = result[ns].get() { - all_ns_err = false; - if record_used && this.record_use(ident, ns, binding) { - if let ModuleOrUniformRoot::Module(module) = module { - this.resolution(module, ident, ns).borrow_mut().binding = - Some(this.dummy_binding); + let orig_vis = directive.vis.replace(ty::Visibility::Invisible); + let orig_last_import_segment = mem::replace(&mut this.last_import_segment, true); + let binding = this.resolve_ident_in_module( + module, ident, ns, Some(&directive.parent_scope), true, directive.span + ); + this.last_import_segment = orig_last_import_segment; + directive.vis.set(orig_vis); + + match binding { + Ok(binding) => { + // Consistency checks, analogous to `finalize_current_module_macro_resolutions`. + let initial_def = result[ns].get().map(|initial_binding| { + all_ns_err = false; + this.record_use(ident, ns, initial_binding, + directive.module_path.is_empty()); + initial_binding.def_ignoring_ambiguity() + }); + let def = binding.def_ignoring_ambiguity(); + if let Ok(initial_def) = initial_def { + if def != initial_def && this.ambiguity_errors.is_empty() { + span_bug!(directive.span, "inconsistent resolution for an import"); + } + } else { + if def != Def::Err && + this.ambiguity_errors.is_empty() && this.privacy_errors.is_empty() { + let msg = "cannot determine resolution for the import"; + let msg_note = + "import resolution is stuck, try simplifying other imports"; + this.session.struct_span_err(directive.span, msg).note(msg_note).emit(); + } } } + Err(..) => { + // FIXME: This assert may fire if public glob is later shadowed by a private + // single import (see test `issue-55884-2.rs`). In theory single imports should + // always block globs, even if they are not yet resolved, so that this kind of + // self-inconsistent resolution never happens. + // Reenable the assert when the issue is fixed. + // assert!(result[ns].get().is_err()); + } } }); if all_ns_err { let mut all_ns_failed = true; self.per_ns(|this, ns| if !type_ns_only || ns == TypeNS { - match this.resolve_ident_in_module(module, ident, ns, record_used, span) { - Ok(_) => all_ns_failed = false, - _ => {} + let binding = this.resolve_ident_in_module( + module, ident, ns, Some(&directive.parent_scope), true, directive.span + ); + if binding.is_ok() { + all_ns_failed = false; } }); return if all_ns_failed { let resolutions = match module { - ModuleOrUniformRoot::Module(module) => - Some(module.resolutions.borrow()), - ModuleOrUniformRoot::UniformRoot(_) => None, + ModuleOrUniformRoot::Module(module) => Some(module.resolutions.borrow()), + _ => None, }; let resolutions = resolutions.as_ref().into_iter().flat_map(|r| r.iter()); let names = resolutions.filter_map(|(&(ref i, _), resolution)| { @@ -1078,7 +1013,7 @@ format!("no `{}` in the root{}", ident, lev_suggestion) } } - ModuleOrUniformRoot::UniformRoot(_) => { + _ => { if !ident.is_path_segment_keyword() { format!("no `{}` external crate{}", ident, lev_suggestion) } else { @@ -1088,7 +1023,7 @@ } } }; - Some((span, msg)) + Some((directive.span, msg, None)) } else { // `resolve_ident_in_module` reported a privacy error. self.import_dummy_binding(directive); @@ -1137,11 +1072,11 @@ } } - if module_path.len() <= 1 { + if directive.module_path.len() <= 1 { // HACK(eddyb) `lint_if_path_starts_with_module` needs at least // 2 segments, so the `resolve_path` above won't trigger it. - let mut full_path = module_path.clone(); - full_path.push(ident); + let mut full_path = directive.module_path.clone(); + full_path.push(Segment::from_ident(ident)); self.per_ns(|this, ns| { if let Ok(binding) = result[ns].get() { this.lint_if_path_starts_with_module( @@ -1158,8 +1093,18 @@ // this may resolve to either a value or a type, but for documentation // purposes it's good enough to just favor one over the other. self.per_ns(|this, ns| if let Some(binding) = result[ns].get().ok() { + let mut def = binding.def(); + if let Def::Macro(def_id, _) = def { + // `DefId`s from the "built-in macro crate" should not leak from resolve because + // later stages are not ready to deal with them and produce lots of ICEs. Replace + // them with `Def::Err` until some saner scheme is implemented for built-in macros. + if def_id.krate == CrateNum::BuiltinMacros { + this.session.span_err(directive.span, "cannot import a built-in macro"); + def = Def::Err; + } + } let import = this.import_map.entry(directive.id).or_default(); - import[ns] = Some(PathResolution::new(binding.def())); + import[ns] = Some(PathResolution::new(def)); }); debug!("(resolving single import) successfully resolved import"); @@ -1169,9 +1114,8 @@ fn resolve_glob_import(&mut self, directive: &'b ImportDirective<'b>) { let module = match directive.imported_module.get().unwrap() { ModuleOrUniformRoot::Module(module) => module, - ModuleOrUniformRoot::UniformRoot(_) => { - self.session.span_err(directive.span, - "cannot glob-import all possible crates"); + _ => { + self.session.span_err(directive.span, "cannot glob-import all possible crates"); return; } }; @@ -1181,7 +1125,7 @@ if let Some(Def::Trait(_)) = module.def() { self.session.span_err(directive.span, "items in traits are not importable."); return; - } else if module.def_id() == directive.parent.def_id() { + } else if module.def_id() == directive.parent_scope.module.def_id() { return; } else if let GlobImport { is_prelude: true, .. } = directive.subclass { self.prelude = Some(module); @@ -1205,7 +1149,7 @@ }; if self.is_accessible_from(binding.pseudo_vis(), scope) { let imported_binding = self.import(binding, directive); - let _ = self.try_define(directive.parent, ident, ns, imported_binding); + let _ = self.try_define(directive.parent_scope.module, ident, ns, imported_binding); } } @@ -1228,19 +1172,16 @@ None => continue, }; - // Don't reexport `uniform_path` canaries. - let non_canary_import = match binding.kind { - NameBindingKind::Import { directive, .. } => { - !directive.is_uniform_paths_canary - } - _ => false, - }; - - if non_canary_import || binding.is_macro_def() { + // Filter away "empty import canaries". + let is_non_canary_import = + binding.is_import() && binding.vis != ty::Visibility::Invisible; + if is_non_canary_import || binding.is_macro_def() { let def = binding.def(); if def != Def::Err { - if !def.def_id().is_local() { - self.cstore.export_macros_untracked(def.def_id().krate); + if let Some(def_id) = def.opt_def_id() { + if !def_id.is_local() && def_id.krate != CrateNum::BuiltinMacros { + self.cstore.export_macros_untracked(def_id.krate); + } } reexports.push(Export { ident: ident.modern(), @@ -1251,65 +1192,62 @@ } } - match binding.kind { - NameBindingKind::Import { binding: orig_binding, directive, .. } => { - if ns == TypeNS && orig_binding.is_variant() && - !orig_binding.vis.is_at_least(binding.vis, &*self) { - let msg = match directive.subclass { - ImportDirectiveSubclass::SingleImport { .. } => { - format!("variant `{}` is private and cannot be re-exported", - ident) - }, - ImportDirectiveSubclass::GlobImport { .. } => { - let msg = "enum is private and its variants \ - cannot be re-exported".to_owned(); - let error_id = (DiagnosticMessageId::ErrorId(0), // no code?! - Some(binding.span), - msg.clone()); - let fresh = self.session.one_time_diagnostics - .borrow_mut().insert(error_id); - if !fresh { - continue; - } - msg - }, - ref s @ _ => bug!("unexpected import subclass {:?}", s) - }; - let mut err = self.session.struct_span_err(binding.span, &msg); - - let imported_module = match directive.imported_module.get() { - Some(ModuleOrUniformRoot::Module(module)) => module, - _ => bug!("module should exist"), - }; - let resolutions = imported_module.parent.expect("parent should exist") - .resolutions.borrow(); - let enum_path_segment_index = directive.module_path.len() - 1; - let enum_ident = directive.module_path[enum_path_segment_index]; - - let enum_resolution = resolutions.get(&(enum_ident, TypeNS)) - .expect("resolution should exist"); - let enum_span = enum_resolution.borrow() - .binding.expect("binding should exist") - .span; - let enum_def_span = self.session.source_map().def_span(enum_span); - let enum_def_snippet = self.session.source_map() - .span_to_snippet(enum_def_span).expect("snippet should exist"); - // potentially need to strip extant `crate`/`pub(path)` for suggestion - let after_vis_index = enum_def_snippet.find("enum") - .expect("`enum` keyword should exist in snippet"); - let suggestion = format!("pub {}", - &enum_def_snippet[after_vis_index..]); - - self.session - .diag_span_suggestion_once(&mut err, - DiagnosticMessageId::ErrorId(0), - enum_def_span, - "consider making the enum public", - suggestion); - err.emit(); - } + if let NameBindingKind::Import { binding: orig_binding, directive, .. } = binding.kind { + if ns == TypeNS && orig_binding.is_variant() && + !orig_binding.vis.is_at_least(binding.vis, &*self) { + let msg = match directive.subclass { + ImportDirectiveSubclass::SingleImport { .. } => { + format!("variant `{}` is private and cannot be re-exported", + ident) + }, + ImportDirectiveSubclass::GlobImport { .. } => { + let msg = "enum is private and its variants \ + cannot be re-exported".to_owned(); + let error_id = (DiagnosticMessageId::ErrorId(0), // no code?! + Some(binding.span), + msg.clone()); + let fresh = self.session.one_time_diagnostics + .borrow_mut().insert(error_id); + if !fresh { + continue; + } + msg + }, + ref s @ _ => bug!("unexpected import subclass {:?}", s) + }; + let mut err = self.session.struct_span_err(binding.span, &msg); + + let imported_module = match directive.imported_module.get() { + Some(ModuleOrUniformRoot::Module(module)) => module, + _ => bug!("module should exist"), + }; + let resolutions = imported_module.parent.expect("parent should exist") + .resolutions.borrow(); + let enum_path_segment_index = directive.module_path.len() - 1; + let enum_ident = directive.module_path[enum_path_segment_index].ident; + + let enum_resolution = resolutions.get(&(enum_ident, TypeNS)) + .expect("resolution should exist"); + let enum_span = enum_resolution.borrow() + .binding.expect("binding should exist") + .span; + let enum_def_span = self.session.source_map().def_span(enum_span); + let enum_def_snippet = self.session.source_map() + .span_to_snippet(enum_def_span).expect("snippet should exist"); + // potentially need to strip extant `crate`/`pub(path)` for suggestion + let after_vis_index = enum_def_snippet.find("enum") + .expect("`enum` keyword should exist in snippet"); + let suggestion = format!("pub {}", + &enum_def_snippet[after_vis_index..]); + + self.session + .diag_span_suggestion_once(&mut err, + DiagnosticMessageId::ErrorId(0), + enum_def_span, + "consider making the enum public", + suggestion); + err.emit(); } - _ => {} } } @@ -1346,7 +1284,7 @@ match *subclass { SingleImport { source, .. } => source.to_string(), GlobImport { .. } => "*".to_string(), - ExternCrate(_) => "".to_string(), + ExternCrate { .. } => "".to_string(), MacroUse => "#[macro_use]".to_string(), } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_save_analysis/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/librustc_save_analysis/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/librustc_save_analysis/Cargo.toml 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_save_analysis/Cargo.toml 2018-12-04 23:41:40.000000000 +0000 @@ -12,11 +12,12 @@ log = "0.4" rustc = { path = "../librustc" } rustc_data_structures = { path = "../librustc_data_structures" } +rustc_codegen_utils = { path = "../librustc_codegen_utils" } rustc_target = { path = "../librustc_target" } rustc_typeck = { path = "../librustc_typeck" } syntax = { path = "../libsyntax" } syntax_pos = { path = "../libsyntax_pos" } -rls-data = "0.18" +rls-data = "0.18.1" rls-span = "0.4" # FIXME(#40527) should move rustc serialize out of tree rustc-serialize = "0.3" diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_save_analysis/dump_visitor.rs rustc-1.31.0+dfsg1+llvm/src/librustc_save_analysis/dump_visitor.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_save_analysis/dump_visitor.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_save_analysis/dump_visitor.rs 2018-12-04 23:41:40.000000000 +0000 @@ -25,19 +25,19 @@ use rustc::hir::def::Def as HirDef; use rustc::hir::def_id::DefId; +use rustc::session::config::Input; use rustc::ty::{self, TyCtxt}; use rustc_data_structures::fx::FxHashSet; use std::path::Path; +use std::env; use syntax::ast::{self, Attribute, NodeId, PatKind, CRATE_NODE_ID}; use syntax::parse::token; -use syntax::symbol::keywords; use syntax::visit::{self, Visitor}; use syntax::print::pprust::{ bounds_to_string, generic_params_to_string, - path_to_string, ty_to_string }; use syntax::ptr::P; @@ -49,8 +49,8 @@ use span_utils::SpanUtils; use sig; -use rls_data::{CratePreludeData, Def, DefKind, GlobalCrateId, Import, ImportKind, Ref, RefKind, - Relation, RelationKind, SpanData}; +use rls_data::{CompilationOptions, CratePreludeData, Def, DefKind, GlobalCrateId, Import, + ImportKind, Ref, RefKind, Relation, RelationKind, SpanData}; macro_rules! down_cast_data { ($id:ident, $kind:ident, $sp:expr) => { @@ -92,7 +92,7 @@ // we only write one macro def per unique macro definition, and // one macro use per unique callsite span. // mac_defs: FxHashSet, - macro_calls: FxHashSet, + // macro_calls: FxHashSet, } impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { @@ -105,10 +105,10 @@ tcx: save_ctxt.tcx, save_ctxt, dumper, - span: span_utils.clone(), + span: span_utils, cur_scope: CRATE_NODE_ID, // mac_defs: FxHashSet::default(), - macro_calls: FxHashSet(), + // macro_calls: FxHashSet::default(), } } @@ -161,7 +161,7 @@ .to_fingerprint() .as_value(), }, - crate_root: crate_root.unwrap_or("".to_owned()), + crate_root: crate_root.unwrap_or_else(|| "".to_owned()), external_crates: self.save_ctxt.get_external_crates(), span: self.span_from_span(krate.span), }; @@ -169,95 +169,69 @@ self.dumper.crate_prelude(data); } - // Return all non-empty prefixes of a path. - // For each prefix, we return the span for the last segment in the prefix and - // a str representation of the entire prefix. - fn process_path_prefixes(&self, path: &ast::Path) -> Vec<(Span, String)> { - let segments = &path.segments[if path.is_global() { 1 } else { 0 }..]; - - let mut result = Vec::with_capacity(segments.len()); - let mut segs = Vec::with_capacity(segments.len()); - - for (i, seg) in segments.iter().enumerate() { - segs.push(seg.clone()); - let sub_path = ast::Path { - span: seg.ident.span, // span for the last segment - segments: segs, - }; - let qualname = if i == 0 && path.is_global() { - format!("::{}", path_to_string(&sub_path)) - } else { - path_to_string(&sub_path) + pub fn dump_compilation_options(&mut self, input: &Input, crate_name: &str) { + // Apply possible `remap-path-prefix` remapping to the input source file + // (and don't include remapping args anymore) + let (program, arguments) = { + let remap_arg_indices = { + let mut indices = FxHashSet::default(); + // Args are guaranteed to be valid UTF-8 (checked early) + for (i, e) in env::args().enumerate() { + if e.starts_with("--remap-path-prefix=") { + indices.insert(i); + } else if e == "--remap-path-prefix" { + indices.insert(i); + indices.insert(i + 1); + } + } + indices }; - result.push((seg.ident.span, qualname)); - segs = sub_path.segments; - } - result + let mut args = env::args() + .enumerate() + .filter(|(i, _)| !remap_arg_indices.contains(i)) + .map(|(_, arg)| { + match input { + Input::File(ref path) if path == Path::new(&arg) => { + let mapped = &self.tcx.sess.local_crate_source_file; + mapped + .as_ref() + .unwrap() + .to_string_lossy() + .into() + }, + _ => arg, + } + }); + + (args.next().unwrap(), args.collect()) + }; + + let data = CompilationOptions { + directory: self.tcx.sess.working_dir.0.clone(), + program, + arguments, + output: self.save_ctxt.compilation_output(crate_name), + }; + + self.dumper.compilation_opts(data); } fn write_sub_paths(&mut self, path: &ast::Path) { - let sub_paths = self.process_path_prefixes(path); - for (span, _) in sub_paths { - let span = self.span_from_span(span); - self.dumper.dump_ref(Ref { - kind: RefKind::Mod, - span, - ref_id: ::null_id(), - }); + for seg in &path.segments { + if let Some(data) = self.save_ctxt.get_path_segment_data(seg) { + self.dumper.dump_ref(data); + } } } // As write_sub_paths, but does not process the last ident in the path (assuming it // will be processed elsewhere). See note on write_sub_paths about global. fn write_sub_paths_truncated(&mut self, path: &ast::Path) { - let sub_paths = self.process_path_prefixes(path); - let len = sub_paths.len(); - if len <= 1 { - return; - } - - for (span, _) in sub_paths.into_iter().take(len - 1) { - let span = self.span_from_span(span); - self.dumper.dump_ref(Ref { - kind: RefKind::Mod, - span, - ref_id: ::null_id(), - }); - } - } - - // As write_sub_paths, but expects a path of the form module_path::trait::method - // Where trait could actually be a struct too. - fn write_sub_path_trait_truncated(&mut self, path: &ast::Path) { - let sub_paths = self.process_path_prefixes(path); - let len = sub_paths.len(); - if len <= 1 { - return; - } - let sub_paths = &sub_paths[..(len - 1)]; - - // write the trait part of the sub-path - let (ref span, _) = sub_paths[len - 2]; - let span = self.span_from_span(*span); - self.dumper.dump_ref(Ref { - kind: RefKind::Type, - ref_id: ::null_id(), - span, - }); - - // write the other sub-paths - if len <= 2 { - return; - } - let sub_paths = &sub_paths[..len - 2]; - for &(ref span, _) in sub_paths { - let span = self.span_from_span(*span); - self.dumper.dump_ref(Ref { - kind: RefKind::Mod, - span, - ref_id: ::null_id(), - }); + for seg in &path.segments[..path.segments.len() - 1] { + if let Some(data) = self.save_ctxt.get_path_segment_data(seg) { + self.dumper.dump_ref(data); + } } } @@ -273,7 +247,6 @@ self.visit_pat(&arg.pat); let mut collector = PathCollector::new(); collector.visit_pat(&arg.pat); - let span_utils = self.span.clone(); for (id, ident, ..) in collector.collected_idents { let hir_id = self.tcx.hir.node_to_hir_id(id); @@ -281,10 +254,9 @@ Some(s) => s.to_string(), None => continue, }; - let sub_span = span_utils.span_for_last_ident(ident.span); - if !self.span.filter_generated(sub_span, ident.span) { + if !self.span.filter_generated(ident.span) { let id = ::id_from_node_id(id, &self.save_ctxt); - let span = self.span_from_span(sub_span.expect("No span found for variable")); + let span = self.span_from_span(ident.span); self.dumper.dump_def( &Access { @@ -323,7 +295,7 @@ ) { debug!("process_method: {}:{}", id, ident); - if let Some(mut method_data) = self.save_ctxt.get_method_data(id, ident.name, span) { + if let Some(mut method_data) = self.save_ctxt.get_method_data(id, ident, span) { let sig_str = ::make_signature(&sig.decl, &generics); if body.is_some() { self.nest_tables( @@ -332,7 +304,7 @@ ); } - self.process_generic_params(&generics, span, &method_data.qualname, id); + self.process_generic_params(&generics, &method_data.qualname, id); method_data.value = sig_str; method_data.sig = sig::method_signature(id, ident, generics, sig, &self.save_ctxt); @@ -365,7 +337,6 @@ fn process_generic_params( &mut self, generics: &'l ast::Generics, - full_span: Span, prefix: &str, id: NodeId, ) { @@ -377,7 +348,7 @@ let name = escape(self.span.snippet(param_ss)); // Append $id to name to make sure each one is unique. let qualname = format!("{}::{}${}", prefix, name, id); - if !self.span.filter_generated(Some(param_ss), full_span) { + if !self.span.filter_generated(param_ss) { let id = ::id_from_node_id(param.id, &self.save_ctxt); let span = self.span_from_span(param_ss); @@ -421,7 +392,7 @@ item.id, |v| v.process_formals(&decl.inputs, &fn_data.qualname), ); - self.process_generic_params(ty_params, item.span, &fn_data.qualname, item.id); + self.process_generic_params(ty_params, &fn_data.qualname, item.id); self.dumper.dump_def(&access_from!(self.save_ctxt, item), fn_data); } @@ -455,8 +426,7 @@ fn process_assoc_const( &mut self, id: ast::NodeId, - name: ast::Name, - span: Span, + ident: ast::Ident, typ: &'l ast::Ty, expr: Option<&'l ast::Expr>, parent_id: DefId, @@ -465,11 +435,9 @@ ) { let qualname = format!("::{}", self.tcx.node_path_str(id)); - let sub_span = self.span.sub_span_after_keyword(span, keywords::Const); - - if !self.span.filter_generated(sub_span, span) { - let sig = sig::assoc_const_signature(id, name, typ, expr, &self.save_ctxt); - let span = self.span_from_span(sub_span.expect("No span found for variable")); + if !self.span.filter_generated(ident.span) { + let sig = sig::assoc_const_signature(id, ident.name, typ, expr, &self.save_ctxt); + let span = self.span_from_span(ident.span); self.dumper.dump_def( &access_from!(self.save_ctxt, vis, id), @@ -477,7 +445,7 @@ kind: DefKind::Const, id: ::id_from_node_id(id, &self.save_ctxt), span, - name: name.to_string(), + name: ident.name.to_string(), qualname, value: ty_to_string(&typ), parent: Some(::id_from_def_id(parent_id)), @@ -508,13 +476,12 @@ let name = item.ident.to_string(); let qualname = format!("::{}", self.tcx.node_path_str(item.id)); - let (kind, keyword) = match item.node { - ast::ItemKind::Struct(_, _) => (DefKind::Struct, keywords::Struct), - ast::ItemKind::Union(_, _) => (DefKind::Union, keywords::Union), + let kind = match item.node { + ast::ItemKind::Struct(_, _) => DefKind::Struct, + ast::ItemKind::Union(_, _) => DefKind::Union, _ => unreachable!(), }; - let sub_span = self.span.sub_span_after_keyword(item.span, keyword); let (value, fields) = match item.node { ast::ItemKind::Struct(ast::VariantData::Struct(ref fields, _), _) | ast::ItemKind::Union(ast::VariantData::Struct(ref fields, _), _) => { @@ -545,8 +512,8 @@ _ => (String::new(), vec![]), }; - if !self.span.filter_generated(sub_span, item.span) { - let span = self.span_from_span(sub_span.expect("No span found for struct")); + if !self.span.filter_generated(item.ident.span) { + let span = self.span_from_span(item.ident.span); self.dumper.dump_def( &access_from!(self.save_ctxt, item), Def { @@ -571,7 +538,7 @@ self.visit_ty(&field.ty); } - self.process_generic_params(ty_params, item.span, &qualname, item.id); + self.process_generic_params(ty_params, &qualname, item.id); } fn process_enum( @@ -592,22 +559,21 @@ for variant in &enum_definition.variants { let name = variant.node.ident.name.to_string(); let qualname = format!("{}::{}", enum_data.qualname, name); + let name_span = variant.node.ident.span; match variant.node.data { ast::VariantData::Struct(ref fields, _) => { - let sub_span = self.span.span_for_first_ident(variant.span); let fields_str = fields .iter() .enumerate() .map(|(i, f)| { - f.ident.map(|i| i.to_string()).unwrap_or(i.to_string()) + f.ident.map(|i| i.to_string()).unwrap_or_else(|| i.to_string()) }) .collect::>() .join(", "); let value = format!("{}::{} {{ {} }}", enum_data.name, name, fields_str); - if !self.span.filter_generated(sub_span, variant.span) { - let span = self - .span_from_span(sub_span.expect("No span found for struct variant")); + if !self.span.filter_generated(name_span) { + let span = self.span_from_span(name_span); let id = ::id_from_node_id(variant.node.data.id(), &self.save_ctxt); let parent = Some(::id_from_node_id(item.id, &self.save_ctxt)); @@ -634,7 +600,6 @@ } } ref v => { - let sub_span = self.span.span_for_first_ident(variant.span); let mut value = format!("{}::{}", enum_data.name, name); if let &ast::VariantData::Tuple(ref fields, _) = v { value.push('('); @@ -645,9 +610,8 @@ .join(", ")); value.push(')'); } - if !self.span.filter_generated(sub_span, variant.span) { - let span = - self.span_from_span(sub_span.expect("No span found for tuple variant")); + if !self.span.filter_generated(name_span) { + let span = self.span_from_span(name_span); let id = ::id_from_node_id(variant.node.data.id(), &self.save_ctxt); let parent = Some(::id_from_node_id(item.id, &self.save_ctxt)); @@ -681,7 +645,7 @@ self.visit_ty(&field.ty); } } - self.process_generic_params(ty_params, item.span, &enum_data.qualname, item.id); + self.process_generic_params(ty_params, &enum_data.qualname, item.id); self.dumper.dump_def(&access, enum_data); } @@ -694,18 +658,20 @@ impl_items: &'l [ast::ImplItem], ) { if let Some(impl_data) = self.save_ctxt.get_item_data(item) { - 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); + if !self.span.filter_generated(item.span) { + 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 { self.process_path(trait_ref.ref_id, &trait_ref.path); } - self.process_generic_params(type_parameters, item.span, "", item.id); + self.process_generic_params(type_parameters, "", item.id); for impl_item in impl_items { let map = &self.tcx.hir; self.process_impl_item(impl_item, map.local_def_id(item.id)); @@ -729,10 +695,9 @@ val.push_str(": "); val.push_str(&bounds_to_string(trait_refs)); } - let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Trait); - if !self.span.filter_generated(sub_span, item.span) { + if !self.span.filter_generated(item.ident.span) { let id = ::id_from_node_id(item.id, &self.save_ctxt); - let span = self.span_from_span(sub_span.expect("No span found for trait")); + let span = self.span_from_span(item.ident.span); let children = methods .iter() .map(|i| ::id_from_node_id(i.id, &self.save_ctxt)) @@ -765,21 +730,18 @@ let trait_ref = &trait_ref.trait_ref; if let Some(id) = self.lookup_def_id(trait_ref.ref_id) { - let sub_span = self.span.sub_span_for_type_name(trait_ref.path.span); - if !self.span.filter_generated(sub_span, trait_ref.path.span) { - let span = self.span_from_span(sub_span.expect("No span found for trait ref")); + let sub_span = trait_ref.path.segments.last().unwrap().ident.span; + if !self.span.filter_generated(sub_span) { + let span = self.span_from_span(sub_span); self.dumper.dump_ref(Ref { kind: RefKind::Type, - span, + span: span.clone(), ref_id: ::id_from_def_id(id), }); - } - if !self.span.filter_generated(sub_span, trait_ref.path.span) { - let sub_span = self.span_from_span(sub_span.expect("No span for inheritance")); self.dumper.dump_relation(Relation { kind: RelationKind::SuperTrait, - span: sub_span, + span, from: ::id_from_def_id(id), to: ::id_from_node_id(item.id, &self.save_ctxt), }); @@ -788,7 +750,7 @@ } // walk generics and methods - self.process_generic_params(generics, item.span, &qualname, item.id); + self.process_generic_params(generics, &qualname, item.id); for method in methods { let map = &self.tcx.hir; self.process_trait_item(method, map.local_def_id(item.id)) @@ -811,8 +773,7 @@ } fn process_path(&mut self, id: NodeId, path: &'l ast::Path) { - debug!("process_path {:?}", path); - if generated_code(path.span) { + if self.span.filter_generated(path.span) { return; } self.dump_path_ref(id, path); @@ -841,29 +802,7 @@ } } - // Modules or types in the path prefix. - match self.save_ctxt.get_path_def(id) { - HirDef::Method(did) => { - let ti = self.tcx.associated_item(did); - if ti.kind == ty::AssociatedKind::Method && ti.method_has_self_argument { - self.write_sub_path_trait_truncated(path); - } - } - HirDef::Fn(..) | - HirDef::Const(..) | - HirDef::Static(..) | - HirDef::StructCtor(..) | - HirDef::VariantCtor(..) | - HirDef::AssociatedConst(..) | - HirDef::Local(..) | - HirDef::Upvar(..) | - HirDef::Struct(..) | - HirDef::Union(..) | - HirDef::Variant(..) | - HirDef::TyAlias(..) | - HirDef::AssociatedTy(..) => self.write_sub_paths_truncated(path), - _ => {} - } + self.write_sub_paths_truncated(path); } fn process_struct_lit( @@ -874,9 +813,8 @@ variant: &'l ty::VariantDef, base: &'l Option>, ) { - self.write_sub_paths_truncated(path); - if let Some(struct_lit_data) = self.save_ctxt.get_expr_data(ex) { + self.write_sub_paths_truncated(path); down_cast_data!(struct_lit_data, RefData, ex.span); if !generated_code(ex.span) { self.dumper.dump_ref(struct_lit_data); @@ -938,12 +876,10 @@ }; let variant = adt.variant_of_def(self.save_ctxt.get_path_def(p.id)); - for &Spanned { node: ref field, span } in fields { - let sub_span = self.span.span_for_first_ident(span); + for &Spanned { node: ref field, .. } in fields { if let Some(index) = self.tcx.find_field_index(field.ident, variant) { - if !self.span.filter_generated(sub_span, span) { - let span = - self.span_from_span(sub_span.expect("No span fund for var ref")); + if !self.span.filter_generated(field.ident.span) { + let span = self.span_from_span(field.ident.span); self.dumper.dump_ref(Ref { kind: RefKind::Variable, span, @@ -980,11 +916,11 @@ .tables .node_id_to_type_opt(hir_id) .map(|t| t.to_string()) - .unwrap_or(String::new()); + .unwrap_or_default(); value.push_str(": "); value.push_str(&typ); - if !self.span.filter_generated(Some(ident.span), ident.span) { + if !self.span.filter_generated(ident.span) { let qualname = format!("{}${}", ident.to_string(), id); let id = ::id_from_node_id(id, &self.save_ctxt); let span = self.span_from_span(ident.span); @@ -1059,14 +995,11 @@ None => String::new(), }; - // Get the span only for the name of the variable (I hope the path - // is only ever a variable name, but who knows?). - let sub_span = self.span.span_for_last_ident(ident.span); // Rust uses the id of the pattern for var lookups, so we'll use it too. - if !self.span.filter_generated(sub_span, ident.span) { + if !self.span.filter_generated(ident.span) { let qualname = format!("{}${}", ident.to_string(), id); let id = ::id_from_node_id(id, &self.save_ctxt); - let span = self.span_from_span(sub_span.expect("No span found for variable")); + let span = self.span_from_span(ident.span); self.dumper.dump_def( &Access { @@ -1099,18 +1032,20 @@ /// If the span is not macro-generated, do nothing, else use callee and /// callsite spans to record macro definition and use data, using the /// mac_uses and mac_defs sets to prevent multiples. - fn process_macro_use(&mut self, span: Span) { - let source_span = span.source_callsite(); - if !self.macro_calls.insert(source_span) { - return; - } + fn process_macro_use(&mut self, _span: Span) { + // FIXME if we're not dumping the defs (see below), there is no point + // dumping refs either. + // let source_span = span.source_callsite(); + // if !self.macro_calls.insert(source_span) { + // return; + // } - let data = match self.save_ctxt.get_macro_use_data(span) { - None => return, - Some(data) => data, - }; + // let data = match self.save_ctxt.get_macro_use_data(span) { + // None => return, + // Some(data) => data, + // }; - self.dumper.macro_use(data); + // self.dumper.macro_use(data); // FIXME write the macro def // let mut hasher = DefaultHasher::new(); @@ -1140,8 +1075,7 @@ ast::TraitItemKind::Const(ref ty, ref expr) => { self.process_assoc_const( trait_item.id, - trait_item.ident.name, - trait_item.span, + trait_item.ident, &ty, expr.as_ref().map(|e| &**e), trait_id, @@ -1164,11 +1098,9 @@ // FIXME do something with _bounds (for type refs) let name = trait_item.ident.name.to_string(); let qualname = format!("::{}", self.tcx.node_path_str(trait_item.id)); - let sub_span = self.span - .sub_span_after_keyword(trait_item.span, keywords::Type); - if !self.span.filter_generated(sub_span, trait_item.span) { - let span = self.span_from_span(sub_span.expect("No span found for assoc type")); + if !self.span.filter_generated(trait_item.ident.span) { + let span = self.span_from_span(trait_item.ident.span); let id = ::id_from_node_id(trait_item.id, &self.save_ctxt); self.dumper.dump_def( @@ -1213,8 +1145,7 @@ ast::ImplItemKind::Const(ref ty, ref expr) => { self.process_assoc_const( impl_item.id, - impl_item.ident.name, - impl_item.span, + impl_item.ident, &ty, Some(expr), impl_id, @@ -1278,7 +1209,7 @@ .map(::id_from_def_id); match use_tree.kind { - ast::UseTreeKind::Simple(..) => { + ast::UseTreeKind::Simple(alias, ..) => { let ident = use_tree.ident(); let path = ast::Path { segments: prefix.segments @@ -1289,24 +1220,22 @@ span: path.span, }; - let sub_span = self.span.span_for_last_ident(path.span); - let alias_span = self.span.sub_span_after_keyword(use_tree.span, keywords::As); - let ref_id = self.lookup_def_id(id); - - if !self.span.filter_generated(sub_span, path.span) { - let span = self.span_from_span(sub_span.expect("No span found for use")); - let alias_span = alias_span.map(|sp| self.span_from_span(sp)); + let sub_span = path.segments.last().unwrap().ident.span; + if !self.span.filter_generated(sub_span) { + let ref_id = self.lookup_def_id(id).map(|id| ::id_from_def_id(id)); + let alias_span = alias.map(|i| self.span_from_span(i.span)); + let span = self.span_from_span(sub_span); self.dumper.import(&access, Import { kind: ImportKind::Use, - ref_id: ref_id.map(|id| ::id_from_def_id(id)), + ref_id, span, alias_span, name: ident.to_string(), value: String::new(), parent, }); + self.write_sub_paths_truncated(&path); } - self.write_sub_paths_truncated(&path); } ast::UseTreeKind::Glob => { let path = ast::Path { @@ -1327,22 +1256,26 @@ Vec::new() }; - let sub_span = self.span.sub_span_of_token(use_tree.span, - token::BinOp(token::Star)); - if !self.span.filter_generated(sub_span, use_tree.span) { - let span = - self.span_from_span(sub_span.expect("No span found for use glob")); - self.dumper.import(&access, Import { - kind: ImportKind::GlobUse, - ref_id: None, - span, - alias_span: None, - name: "*".to_owned(), - value: names.join(", "), - parent, - }); + // Otherwise it's a span with wrong macro expansion info, which + // we don't want to track anyway, since it's probably macro-internal `use` + if let Some(sub_span) = + self.span.sub_span_of_token(use_tree.span, token::BinOp(token::Star)) + { + if !self.span.filter_generated(use_tree.span) { + let span = self.span_from_span(sub_span); + + self.dumper.import(&access, Import { + kind: ImportKind::GlobUse, + ref_id: None, + span, + alias_span: None, + name: "*".to_owned(), + value: names.join(", "), + parent, + }); + self.write_sub_paths(&path); + } } - self.write_sub_paths(&path); } ast::UseTreeKind::Nested(ref nested_items) => { let prefix = ast::Path { @@ -1421,11 +1354,9 @@ self.process_use_tree(use_tree, item.id, item, &prefix); } ExternCrate(_) => { - let alias_span = self.span.span_for_last_ident(item.span); - - if !self.span.filter_generated(alias_span, item.span) { - let span = - self.span_from_span(alias_span.expect("No span found for extern crate")); + let name_span = item.ident.span; + if !self.span.filter_generated(name_span) { + let span = self.span_from_span(name_span); let parent = self.save_ctxt.tcx.hir.opt_local_def_id(item.id) .and_then(|id| self.save_ctxt.tcx.parent_def_id(id)) .map(::id_from_def_id); @@ -1468,9 +1399,8 @@ Ty(ref ty, ref ty_params) => { let qualname = format!("::{}", self.tcx.node_path_str(item.id)); let value = ty_to_string(&ty); - let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Type); - if !self.span.filter_generated(sub_span, item.span) { - let span = self.span_from_span(sub_span.expect("No span found for typedef")); + if !self.span.filter_generated(item.ident.span) { + let span = self.span_from_span(item.ident.span); let id = ::id_from_node_id(item.id, &self.save_ctxt); self.dumper.dump_def( @@ -1493,15 +1423,14 @@ } self.visit_ty(&ty); - self.process_generic_params(ty_params, item.span, &qualname, item.id); + self.process_generic_params(ty_params, &qualname, item.id); } Existential(ref _bounds, ref ty_params) => { let qualname = format!("::{}", self.tcx.node_path_str(item.id)); // FIXME do something with _bounds let value = String::new(); - let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Type); - if !self.span.filter_generated(sub_span, item.span) { - let span = self.span_from_span(sub_span.expect("No span found for typedef")); + if !self.span.filter_generated(item.ident.span) { + let span = self.span_from_span(item.ident.span); let id = ::id_from_node_id(item.id, &self.save_ctxt); self.dumper.dump_def( @@ -1523,7 +1452,7 @@ ); } - self.process_generic_params(ty_params, item.span, &qualname, item.id); + self.process_generic_params(ty_params, &qualname, item.id); } Mac(_) => (), _ => visit::walk_item(self, item), @@ -1556,14 +1485,13 @@ } if let Some(id) = self.lookup_def_id(t.id) { - if let Some(sub_span) = self.span.sub_span_for_type_name(t.span) { - let span = self.span_from_span(sub_span); - self.dumper.dump_ref(Ref { - kind: RefKind::Type, - span, - ref_id: ::id_from_def_id(id), - }); - } + let sub_span = path.segments.last().unwrap().ident.span; + let span = self.span_from_span(sub_span); + self.dumper.dump_ref(Ref { + kind: RefKind::Type, + span, + ref_id: ::id_from_def_id(id), + }); } self.write_sub_paths_truncated(path); @@ -1687,7 +1615,7 @@ let value = l.init .as_ref() .map(|i| self.span.snippet(i.span)) - .unwrap_or(String::new()); + .unwrap_or_default(); self.process_var_decl(&l.pat, value); // Just walk the initialiser and type (don't want to walk the pattern again). @@ -1703,11 +1631,7 @@ if let Some(fn_data) = self.save_ctxt.get_extern_item_data(item) { down_cast_data!(fn_data, DefData, item.span); - self.nest_tables( - item.id, - |v| v.process_formals(&decl.inputs, &fn_data.qualname), - ); - self.process_generic_params(generics, item.span, &fn_data.qualname, item.id); + self.process_generic_params(generics, &fn_data.qualname, item.id); self.dumper.dump_def(&access, fn_data); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_save_analysis/json_dumper.rs rustc-1.31.0+dfsg1+llvm/src/librustc_save_analysis/json_dumper.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_save_analysis/json_dumper.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_save_analysis/json_dumper.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,9 +12,9 @@ use rustc_serialize::json::as_json; -use rls_data::{self, Analysis, CratePreludeData, Def, DefKind, Import, MacroRef, Ref, RefKind, - Relation, Impl}; use rls_data::config::Config; +use rls_data::{self, Analysis, CompilationOptions, CratePreludeData, Def, DefKind, Impl, Import, + MacroRef, Ref, RefKind, Relation}; use rls_span::{Column, Row}; #[derive(Debug)] @@ -89,7 +89,11 @@ self.result.prelude = Some(data) } - pub fn macro_use(&mut self, data: MacroRef) { + pub fn compilation_opts(&mut self, data: CompilationOptions) { + self.result.compilation = Some(data); + } + + pub fn _macro_use(&mut self, data: MacroRef) { if self.config.pub_only || self.config.reachable_only { return; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_save_analysis/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_save_analysis/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_save_analysis/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_save_analysis/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,8 +12,7 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(custom_attribute)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![allow(unused_attributes)] #![recursion_limit="256"] @@ -24,6 +23,7 @@ #[macro_use] extern crate log; extern crate rustc_data_structures; +extern crate rustc_codegen_utils; extern crate rustc_serialize; extern crate rustc_target; extern crate rustc_typeck; @@ -46,9 +46,10 @@ use rustc::hir::Node; use rustc::hir::def_id::{DefId, LOCAL_CRATE}; use rustc::middle::cstore::ExternCrate; -use rustc::session::config::CrateType; +use rustc::session::config::{CrateType, Input, OutputType}; use rustc::ty::{self, TyCtxt}; use rustc_typeck::hir_ty_to_ty; +use rustc_codegen_utils::link::{filename_for_metadata, out_filename}; use std::cell::Cell; use std::default::Default; @@ -56,12 +57,10 @@ use std::fs::File; use std::path::{Path, PathBuf}; -use syntax::ast::{self, Attribute, NodeId, PatKind}; +use syntax::ast::{self, Attribute, DUMMY_NODE_ID, NodeId, PatKind}; use syntax::source_map::Spanned; use syntax::parse::lexer::comments::strip_doc_comment_decoration; -use syntax::parse::token; use syntax::print::pprust; -use syntax::symbol::keywords; use syntax::visit::{self, Visitor}; use syntax::print::pprust::{arg_to_string, ty_to_string}; use syntax::source_map::MacroAttribute; @@ -111,6 +110,24 @@ } } + // Returns path to the compilation output (e.g. libfoo-12345678.rmeta) + pub fn compilation_output(&self, crate_name: &str) -> PathBuf { + let sess = &self.tcx.sess; + // Save-analysis is emitted per whole session, not per each crate type + let crate_type = sess.crate_types.borrow()[0]; + let outputs = &*self.tcx.output_filenames(LOCAL_CRATE); + + if outputs.outputs.contains_key(&OutputType::Metadata) { + filename_for_metadata(sess, crate_name, outputs) + } else if outputs.outputs.should_codegen() { + out_filename(sess, crate_type, outputs, crate_name) + } else { + // Otherwise it's only a DepInfo, in which case we return early and + // not even reach the analysis stage. + unreachable!() + } + } + // List external crates used by the current crate. pub fn get_external_crates(&self) -> Vec { let mut result = Vec::with_capacity(self.tcx.crates().len()); @@ -127,7 +144,7 @@ result.push(ExternalCrateData { // FIXME: change file_name field to PathBuf in rls-data // https://github.com/nrc/rls-data/issues/7 - file_name: self.span_utils.make_path_string(&lo_loc.file.name), + file_name: self.span_utils.make_filename_string(&lo_loc.file), num: n.as_u32(), id: GlobalCrateId { name: self.tcx.crate_name(n).to_string(), @@ -143,14 +160,12 @@ let qualname = format!("::{}", self.tcx.node_path_str(item.id)); match item.node { ast::ForeignItemKind::Fn(ref decl, ref generics) => { - let sub_span = self.span_utils - .sub_span_after_keyword(item.span, keywords::Fn); - filter!(self.span_utils, sub_span, item.span, None); + filter!(self.span_utils, item.ident.span); Some(Data::DefData(Def { kind: DefKind::ForeignFunction, id: id_from_node_id(item.id, self), - span: self.span_from_span(sub_span.unwrap()), + span: self.span_from_span(item.ident.span), name: item.ident.to_string(), qualname, value: make_signature(decl, generics), @@ -162,13 +177,11 @@ attributes: lower_attributes(item.attrs.clone(), self), })) } - ast::ForeignItemKind::Static(ref ty, m) => { - let keyword = if m { keywords::Mut } else { keywords::Static }; - let sub_span = self.span_utils.sub_span_after_keyword(item.span, keyword); - filter!(self.span_utils, sub_span, item.span, None); + ast::ForeignItemKind::Static(ref ty, _) => { + filter!(self.span_utils, item.ident.span); let id = ::id_from_node_id(item.id, self); - let span = self.span_from_span(sub_span.unwrap()); + let span = self.span_from_span(item.ident.span); Some(Data::DefData(Def { kind: DefKind::ForeignStatic, @@ -195,13 +208,11 @@ match item.node { ast::ItemKind::Fn(ref decl, .., ref generics, _) => { let qualname = format!("::{}", self.tcx.node_path_str(item.id)); - let sub_span = self.span_utils - .sub_span_after_keyword(item.span, keywords::Fn); - filter!(self.span_utils, sub_span, item.span, None); + filter!(self.span_utils, item.ident.span); Some(Data::DefData(Def { kind: DefKind::Function, id: id_from_node_id(item.id, self), - span: self.span_from_span(sub_span.unwrap()), + span: self.span_from_span(item.ident.span), name: item.ident.to_string(), qualname, value: make_signature(decl, generics), @@ -213,19 +224,13 @@ attributes: lower_attributes(item.attrs.clone(), self), })) } - ast::ItemKind::Static(ref typ, mt, _) => { + ast::ItemKind::Static(ref typ, ..) => { let qualname = format!("::{}", self.tcx.node_path_str(item.id)); - let keyword = match mt { - ast::Mutability::Mutable => keywords::Mut, - ast::Mutability::Immutable => keywords::Static, - }; - - let sub_span = self.span_utils.sub_span_after_keyword(item.span, keyword); - filter!(self.span_utils, sub_span, item.span, None); + filter!(self.span_utils, item.ident.span); let id = id_from_node_id(item.id, self); - let span = self.span_from_span(sub_span.unwrap()); + let span = self.span_from_span(item.ident.span); Some(Data::DefData(Def { kind: DefKind::Static, @@ -244,12 +249,10 @@ } ast::ItemKind::Const(ref typ, _) => { let qualname = format!("::{}", self.tcx.node_path_str(item.id)); - let sub_span = self.span_utils - .sub_span_after_keyword(item.span, keywords::Const); - filter!(self.span_utils, sub_span, item.span, None); + filter!(self.span_utils, item.ident.span); let id = id_from_node_id(item.id, self); - let span = self.span_from_span(sub_span.unwrap()); + let span = self.span_from_span(item.ident.span); Some(Data::DefData(Def { kind: DefKind::Const, @@ -272,16 +275,14 @@ let cm = self.tcx.sess.source_map(); let filename = cm.span_to_filename(m.inner); - let sub_span = self.span_utils - .sub_span_after_keyword(item.span, keywords::Mod); - filter!(self.span_utils, sub_span, item.span, None); + filter!(self.span_utils, item.ident.span); Some(Data::DefData(Def { kind: DefKind::Mod, id: id_from_node_id(item.id, self), name: item.ident.to_string(), qualname, - span: self.span_from_span(sub_span.unwrap()), + span: self.span_from_span(item.ident.span), value: filename.to_string(), parent: None, children: m.items @@ -297,9 +298,7 @@ ast::ItemKind::Enum(ref def, _) => { let name = item.ident.to_string(); let qualname = format!("::{}", self.tcx.node_path_str(item.id)); - let sub_span = self.span_utils - .sub_span_after_keyword(item.span, keywords::Enum); - filter!(self.span_utils, sub_span, item.span, None); + filter!(self.span_utils, item.ident.span); let variants_str = def.variants .iter() .map(|v| v.node.ident.to_string()) @@ -309,7 +308,7 @@ Some(Data::DefData(Def { kind: DefKind::Enum, id: id_from_node_id(item.id, self), - span: self.span_from_span(sub_span.unwrap()), + span: self.span_from_span(item.ident.span), name, qualname, value, @@ -330,11 +329,11 @@ if generated_code(path.span) { return None; } - let sub_span = self.span_utils.sub_span_for_type_name(path.span); - filter!(self.span_utils, sub_span, typ.span, None); + let sub_span = path.segments.last().unwrap().ident.span; + filter!(self.span_utils, sub_span); let impl_id = self.next_impl_id(); - let span = self.span_from_span(sub_span.unwrap()); + let span = self.span_from_span(sub_span); let type_data = self.lookup_ref_id(typ.id); type_data.map(|type_data| { @@ -348,7 +347,7 @@ .as_ref() .and_then(|t| self.lookup_ref_id(t.ref_id)) .map(id_from_def_id) - .unwrap_or(null_id()), + .unwrap_or_else(|| null_id()), }, Impl { id: impl_id, @@ -383,15 +382,13 @@ if let Some(ident) = field.ident { let name = ident.to_string(); let qualname = format!("::{}::{}", self.tcx.node_path_str(scope), ident); - let sub_span = self.span_utils - .sub_span_before_token(field.span, token::Colon); - filter!(self.span_utils, sub_span, field.span, None); + filter!(self.span_utils, ident.span); let def_id = self.tcx.hir.local_def_id(field.id); let typ = self.tcx.type_of(def_id).to_string(); let id = id_from_node_id(field.id, self); - let span = self.span_from_span(sub_span.unwrap()); + let span = self.span_from_span(ident.span); Some(Def { kind: DefKind::Field, @@ -414,7 +411,7 @@ // FIXME would be nice to take a MethodItem here, but the ast provides both // trait and impl flavours, so the caller must do the disassembly. - pub fn get_method_data(&self, id: ast::NodeId, name: ast::Name, span: Span) -> Option { + pub fn get_method_data(&self, id: ast::NodeId, ident: ast::Ident, span: Span) -> Option { // The qualname for a method is the trait name or name of the struct in an impl in // which the method is declared in, followed by the method's name. let (qualname, parent_scope, decl_id, docs, attributes) = @@ -440,7 +437,7 @@ qualname.push_str(&self.tcx.item_path_str(def_id)); self.tcx .associated_items(def_id) - .find(|item| item.ident.name == name) + .find(|item| item.ident.name == ident.name) .map(|item| decl_id = Some(item.def_id)); } qualname.push_str(">"); @@ -493,16 +490,15 @@ }, }; - let qualname = format!("{}::{}", qualname, name); + let qualname = format!("{}::{}", qualname, ident.name); - let sub_span = self.span_utils.sub_span_after_keyword(span, keywords::Fn); - filter!(self.span_utils, sub_span, span, None); + filter!(self.span_utils, ident.span); Some(Def { kind: DefKind::Method, id: id_from_node_id(id, self), - span: self.span_from_span(sub_span.unwrap()), - name: name.to_string(), + span: self.span_from_span(ident.span), + name: ident.name.to_string(), qualname, // FIXME you get better data here by using the visitor. value: String::new(), @@ -521,9 +517,9 @@ if generated_code(span) { return None; } - let sub_span = self.span_utils.sub_span_for_type_name(span).or(Some(span)); - filter!(self.span_utils, sub_span, span, None); - let span = self.span_from_span(sub_span.unwrap()); + let sub_span = trait_ref.path.segments.last().unwrap().ident.span; + filter!(self.span_utils, sub_span); + let span = self.span_from_span(sub_span); Some(Ref { kind: RefKind::Type, span, @@ -555,9 +551,8 @@ ty::Adt(def, _) if !def.is_enum() => { let variant = &def.non_enum_variant(); let index = self.tcx.find_field_index(ident, variant).unwrap(); - let sub_span = self.span_utils.span_for_last_ident(expr.span); - filter!(self.span_utils, sub_span, expr.span, None); - let span = self.span_from_span(sub_span.unwrap()); + filter!(self.span_utils, ident.span); + let span = self.span_from_span(ident.span); return Some(Data::RefData(Ref { kind: RefKind::Variable, span, @@ -574,9 +569,9 @@ ast::ExprKind::Struct(ref path, ..) => { match self.tables.expr_ty_adjusted(&hir_node).sty { ty::Adt(def, _) if !def.is_enum() => { - let sub_span = self.span_utils.span_for_last_ident(path.span); - filter!(self.span_utils, sub_span, path.span, None); - let span = self.span_from_span(sub_span.unwrap()); + let sub_span = path.segments.last().unwrap().ident.span; + filter!(self.span_utils, sub_span); + let span = self.span_from_span(sub_span); Some(Data::RefData(Ref { kind: RefKind::Type, span, @@ -605,7 +600,7 @@ ty::TraitContainer(_) => (None, Some(method_id)), }; let sub_span = seg.ident.span; - filter!(self.span_utils, Some(sub_span), expr.span, None); + filter!(self.span_utils, sub_span); let span = self.span_from_span(sub_span); Some(Data::RefData(Ref { kind: RefKind::Function, @@ -613,7 +608,7 @@ ref_id: def_id .or(decl_id) .map(|id| id_from_def_id(id)) - .unwrap_or(null_id()), + .unwrap_or_else(|| null_id()), })) } ast::ExprKind::Path(_, ref path) => { @@ -637,6 +632,10 @@ Node::Visibility(&Spanned { node: hir::VisibilityKind::Restricted { ref path, .. }, .. }) => path.def, + Node::PathSegment(seg) => match seg.def { + Some(def) => def, + None => HirDef::Err, + }, Node::Expr(&hir::Expr { node: hir::ExprKind::Struct(ref qpath, ..), .. @@ -690,12 +689,26 @@ } pub fn get_path_data(&self, id: NodeId, path: &ast::Path) -> Option { + path.segments + .last() + .and_then(|seg| { + self.get_path_segment_data(seg) + .or_else(|| self.get_path_segment_data_with_id(seg, id)) + }) + } + + pub fn get_path_segment_data(&self, path_seg: &ast::PathSegment) -> Option { + self.get_path_segment_data_with_id(path_seg, path_seg.id) + } + + fn get_path_segment_data_with_id( + &self, + path_seg: &ast::PathSegment, + id: NodeId, + ) -> Option { // Returns true if the path is function type sugar, e.g., `Fn(A) -> B`. - fn fn_type(path: &ast::Path) -> bool { - if path.segments.len() != 1 { - return false; - } - if let Some(ref generic_args) = path.segments[0].args { + fn fn_type(seg: &ast::PathSegment) -> bool { + if let Some(ref generic_args) = seg.args { if let ast::GenericArgs::Parenthesized(_) = **generic_args { return true; } @@ -703,17 +716,17 @@ false } - if path.segments.is_empty() { + if id == DUMMY_NODE_ID { return None; } let def = self.get_path_def(id); - let last_seg = &path.segments[path.segments.len() - 1]; - let sub_span = last_seg.ident.span; - filter!(self.span_utils, Some(sub_span), path.span, None); + let span = path_seg.ident.span; + filter!(self.span_utils, span); + let span = self.span_from_span(span); + match def { HirDef::Upvar(id, ..) | HirDef::Local(id) => { - let span = self.span_from_span(sub_span); Some(Ref { kind: RefKind::Variable, span, @@ -724,23 +737,17 @@ HirDef::Const(..) | HirDef::AssociatedConst(..) | HirDef::VariantCtor(..) => { - let span = self.span_from_span(sub_span); Some(Ref { kind: RefKind::Variable, span, ref_id: id_from_def_id(def.def_id()), }) } - HirDef::Trait(def_id) if fn_type(path) => { - // Function type bounds are desugared in the parser, so we have to - // special case them here. - let fn_span = self.span_utils.span_for_first_ident(path.span); - fn_span.map(|span| { - Ref { - kind: RefKind::Type, - span: self.span_from_span(span), - ref_id: id_from_def_id(def_id), - } + HirDef::Trait(def_id) if fn_type(path_seg) => { + Some(Ref { + kind: RefKind::Type, + span, + ref_id: id_from_def_id(def_id), }) } HirDef::Struct(def_id) | @@ -755,7 +762,6 @@ HirDef::Trait(def_id) | HirDef::Existential(def_id) | HirDef::TyParam(def_id) => { - let span = self.span_from_span(sub_span); Some(Ref { kind: RefKind::Type, span, @@ -766,7 +772,6 @@ // This is a reference to a tuple struct where the def_id points // to an invisible constructor function. That is not a very useful // def, so adjust to point to the tuple struct itself. - let span = self.span_from_span(sub_span); let parent_def_id = self.tcx.parent_def_id(def_id).unwrap(); Some(Ref { kind: RefKind::Type, @@ -785,7 +790,6 @@ } else { None }; - let span = self.span_from_span(sub_span); Some(Ref { kind: RefKind::Function, span, @@ -793,7 +797,6 @@ }) } HirDef::Fn(def_id) => { - let span = self.span_from_span(sub_span); Some(Ref { kind: RefKind::Function, span, @@ -801,7 +804,6 @@ }) } HirDef::Mod(def_id) => { - let span = self.span_from_span(sub_span); Some(Ref { kind: RefKind::Mod, span, @@ -824,15 +826,14 @@ field_ref: &ast::Field, variant: &ty::VariantDef, ) -> Option { - let index = self.tcx.find_field_index(field_ref.ident, variant).unwrap(); - // 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); - let span = self.span_from_span(sub_span.unwrap()); - Some(Ref { - kind: RefKind::Variable, - span, - ref_id: id_from_def_id(variant.fields[index].did), + filter!(self.span_utils, field_ref.ident.span); + self.tcx.find_field_index(field_ref.ident, variant).map(|index| { + let span = self.span_from_span(field_ref.ident.span); + Ref { + kind: RefKind::Variable, + span, + ref_id: id_from_def_id(variant.fields[index].did), + } }) } @@ -1016,6 +1017,7 @@ save_ctxt: SaveContext<'l, 'tcx>, krate: &ast::Crate, cratename: &str, + input: &'l Input, ); } @@ -1081,12 +1083,14 @@ save_ctxt: SaveContext<'l, 'tcx>, krate: &ast::Crate, cratename: &str, + input: &'l Input, ) { let output = &mut self.output_file(&save_ctxt); let mut dumper = JsonDumper::new(output, save_ctxt.config.clone()); let mut visitor = DumpVisitor::new(save_ctxt, &mut dumper); visitor.dump_crate_info(cratename, krate); + visitor.dump_compilation_options(input, cratename); visit::walk_crate(&mut visitor, krate); } } @@ -1102,6 +1106,7 @@ save_ctxt: SaveContext<'l, 'tcx>, krate: &ast::Crate, cratename: &str, + input: &'l Input, ) { // We're using the JsonDumper here because it has the format of the // save-analysis results that we will pass to the callback. IOW, we are @@ -1112,6 +1117,7 @@ let mut visitor = DumpVisitor::new(save_ctxt, &mut dumper); visitor.dump_crate_info(cratename, krate); + visitor.dump_compilation_options(input, cratename); visit::walk_crate(&mut visitor, krate); } } @@ -1121,6 +1127,7 @@ krate: &ast::Crate, analysis: &'l ty::CrateAnalysis, cratename: &str, + input: &'l Input, config: Option, mut handler: H, ) { @@ -1138,7 +1145,7 @@ impl_counter: Cell::new(0), }; - handler.save(save_ctxt, krate, cratename) + handler.save(save_ctxt, krate, cratename, input) }) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_save_analysis/span_utils.rs rustc-1.31.0+dfsg1+llvm/src/librustc_save_analysis/span_utils.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_save_analysis/span_utils.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_save_analysis/span_utils.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,7 +16,6 @@ use syntax::parse::lexer::{self, StringReader}; use syntax::parse::token::{self, Token}; -use syntax::symbol::keywords; use syntax_pos::*; #[derive(Clone)] @@ -35,14 +34,24 @@ } } - pub fn make_path_string(&self, path: &FileName) -> String { - match *path { - FileName::Real(ref path) if !path.is_absolute() => - self.sess.working_dir.0 - .join(&path) - .display() - .to_string(), - _ => path.to_string(), + pub fn make_filename_string(&self, file: &SourceFile) -> String { + match &file.name { + FileName::Real(path) if !file.name_was_remapped => { + if path.is_absolute() { + self.sess.source_map().path_mapping() + .map_prefix(path.clone()).0 + .display() + .to_string() + } else { + self.sess.working_dir.0 + .join(&path) + .display() + .to_string() + } + }, + // If the file name is already remapped, we assume the user + // configured it the way they wanted to, so use that directly + filename => filename.to_string() } } @@ -57,131 +66,6 @@ lexer::StringReader::retokenize(&self.sess.parse_sess, span) } - // Re-parses a path and returns the span for the last identifier in the path - pub fn span_for_last_ident(&self, span: Span) -> Option { - let mut result = None; - - let mut toks = self.retokenise_span(span); - let mut bracket_count = 0; - loop { - let ts = toks.real_token(); - if ts.tok == token::Eof { - return result; - } - if bracket_count == 0 && (ts.tok.is_ident() || ts.tok.is_keyword(keywords::SelfValue)) { - result = Some(ts.sp); - } - - bracket_count += match ts.tok { - token::Lt => 1, - token::Gt => -1, - token::BinOp(token::Shr) => -2, - _ => 0, - } - } - } - - // Return the span for the first identifier in the path. - pub fn span_for_first_ident(&self, span: Span) -> Option { - let mut toks = self.retokenise_span(span); - let mut bracket_count = 0; - loop { - let ts = toks.real_token(); - if ts.tok == token::Eof { - return None; - } - if bracket_count == 0 && (ts.tok.is_ident() || ts.tok.is_keyword(keywords::SelfValue)) { - return Some(ts.sp); - } - - bracket_count += match ts.tok { - token::Lt => 1, - token::Gt => -1, - token::BinOp(token::Shr) => -2, - _ => 0, - } - } - } - - // Return the span for the last ident before a `<` and outside any - // angle brackets, or the last span. - pub fn sub_span_for_type_name(&self, span: Span) -> Option { - let mut toks = self.retokenise_span(span); - let mut prev = toks.real_token(); - let mut result = None; - - // We keep track of the following two counts - the depth of nesting of - // angle brackets, and the depth of nesting of square brackets. For the - // angle bracket count, we only count tokens which occur outside of any - // square brackets (i.e. bracket_count == 0). The intuition here is - // that we want to count angle brackets in the type, but not any which - // could be in expression context (because these could mean 'less than', - // etc.). - let mut angle_count = 0; - let mut bracket_count = 0; - loop { - let next = toks.real_token(); - - if (next.tok == token::Lt || next.tok == token::Colon) && angle_count == 0 - && bracket_count == 0 && prev.tok.is_ident() - { - result = Some(prev.sp); - } - - if bracket_count == 0 { - angle_count += match prev.tok { - token::Lt => 1, - token::Gt => -1, - token::BinOp(token::Shl) => 2, - token::BinOp(token::Shr) => -2, - _ => 0, - }; - } - - bracket_count += match prev.tok { - token::OpenDelim(token::Bracket) => 1, - token::CloseDelim(token::Bracket) => -1, - _ => 0, - }; - - if next.tok == token::Eof { - break; - } - prev = next; - } - #[cfg(debug_assertions)] { - if angle_count != 0 || bracket_count != 0 { - let loc = self.sess.source_map().lookup_char_pos(span.lo()); - span_bug!( - span, - "Mis-counted brackets when breaking path? Parsing '{}' in {}, line {}", - self.snippet(span), - loc.file.name, - loc.line - ); - } - } - if result.is_none() && prev.tok.is_ident() { - return Some(prev.sp); - } - result - } - - pub fn sub_span_before_token(&self, span: Span, tok: Token) -> Option { - let mut toks = self.retokenise_span(span); - let mut prev = toks.real_token(); - loop { - if prev.tok == token::Eof { - return None; - } - let next = toks.real_token(); - if next.tok == tok { - return Some(prev.sp); - } - prev = next; - } - } - pub fn sub_span_of_token(&self, span: Span, tok: Token) -> Option { let mut toks = self.retokenise_span(span); loop { @@ -195,28 +79,6 @@ } } - pub fn sub_span_after_keyword(&self, span: Span, keyword: keywords::Keyword) -> Option { - self.sub_span_after(span, |t| t.is_keyword(keyword)) - } - - fn sub_span_after bool>(&self, span: Span, f: F) -> Option { - let mut toks = self.retokenise_span(span); - loop { - let ts = toks.real_token(); - if ts.tok == token::Eof { - return None; - } - if f(ts.tok) { - let ts = toks.real_token(); - if ts.tok == token::Eof { - return None; - } else { - return Some(ts.sp); - } - } - } - } - // // Return the name for a macro definition (identifier after first `!`) // pub fn span_for_macro_def_name(&self, span: Span) -> Option { // let mut toks = self.retokenise_span(span); @@ -261,42 +123,24 @@ /// /// Used to filter out spans of minimal value, /// such as references to macro internal variables. - pub fn filter_generated(&self, sub_span: Option, parent: Span) -> bool { - if !generated_code(parent) { - // Edge case - this occurs on generated code with incorrect expansion info. - return sub_span.is_none() + pub fn filter_generated(&self, span: Span) -> bool { + if generated_code(span) { + return true; } - // If sub_span is none, filter out generated code. - let sub_span = match sub_span { - Some(ss) => ss, - None => return true, - }; //If the span comes from a fake source_file, filter it. - if !self.sess + !self.sess .source_map() - .lookup_char_pos(parent.lo()) + .lookup_char_pos(span.lo()) .file .is_real_file() - { - return true; - } - - // Otherwise, a generated span is deemed invalid if it is not a sub-span of the root - // callsite. This filters out macro internal variables and most malformed spans. - !parent.source_callsite().contains(sub_span) } } macro_rules! filter { - ($util: expr, $span: expr, $parent: expr, None) => { - if $util.filter_generated($span, $parent) { + ($util: expr, $parent: expr) => { + if $util.filter_generated($parent) { return None; } }; - ($util: expr, $span: ident, $parent: expr) => { - if $util.filter_generated($span, $parent) { - return; - } - }; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_target/abi/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_target/abi/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_target/abi/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_target/abi/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -430,7 +430,7 @@ } /// Lower the alignment, if necessary, such that the given offset - /// is aligned to it (the offset is a multiple of the aligment). + /// is aligned to it (the offset is a multiple of the alignment). pub fn restrict_for_offset(self, offset: Size) -> Align { self.min(Align::max_for_offset(offset)) } @@ -802,6 +802,14 @@ _ => false, } } + + /// Returns true if this is an uninhabited type + pub fn is_uninhabited(&self) -> bool { + match *self { + Abi::Uninhabited => true, + _ => false, + } + } } #[derive(PartialEq, Eq, Hash, Debug)] @@ -866,7 +874,7 @@ /// to those obtained from `layout_of(ty)`, as we need to produce /// layouts for which Rust types do not exist, such as enum variants /// or synthetic fields of enums (i.e. discriminants) and fat pointers. -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] pub struct TyLayout<'a, Ty> { pub ty: Ty, pub details: &'a LayoutDetails diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_target/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_target/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_target/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_target/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -22,10 +22,8 @@ html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(box_syntax)] -#![cfg_attr(stage0, feature(const_fn))] -#![cfg_attr(not(stage0), feature(min_const_fn))] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![cfg_attr(stage0, feature(min_const_fn))] +#![feature(nll)] #![feature(slice_patterns)] #[macro_use] diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_target/spec/aarch64_pc_windows_msvc.rs rustc-1.31.0+dfsg1+llvm/src/librustc_target/spec/aarch64_pc_windows_msvc.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_target/spec/aarch64_pc_windows_msvc.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_target/spec/aarch64_pc_windows_msvc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use spec::{LinkerFlavor, Target, TargetResult, PanicStrategy, LldFlavor}; +use spec::{LinkerFlavor, Target, TargetResult, PanicStrategy}; pub fn target() -> TargetResult { let mut base = super::windows_msvc_base::opts(); @@ -17,7 +17,6 @@ // FIXME: this shouldn't be panic=abort, it should be panic=unwind base.panic_strategy = PanicStrategy::Abort; - base.linker = Some("rust-lld".to_owned()); Ok(Target { llvm_target: "aarch64-pc-windows-msvc".to_string(), @@ -29,7 +28,7 @@ target_os: "windows".to_string(), target_env: "msvc".to_string(), target_vendor: "pc".to_string(), - linker_flavor: LinkerFlavor::Lld(LldFlavor::Link), + linker_flavor: LinkerFlavor::Msvc, options: base, }) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_target/spec/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_target/spec/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_target/spec/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_target/spec/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -576,6 +576,9 @@ /// the functions in the executable are not randomized and can be used /// during an exploit of a vulnerability in any code. pub position_independent_executables: bool, + /// Determines if the target always requires using the PLT for indirect + /// library calls or not. This controls the default value of the `-Z plt` flag. + pub needs_plt: bool, /// Either partial, full, or off. Full RELRO makes the dynamic linker /// resolve all symbols at startup and marks the GOT read-only before /// starting the program, preventing overwriting the GOT. @@ -677,6 +680,12 @@ /// typically because the platform needs to unwind for things like stack /// unwinders. pub requires_uwtable: bool, + + /// Whether or not SIMD types are passed by reference in the Rust ABI, + /// typically required if a target can be compiled with a mixed set of + /// target features. This is `true` by default, and `false` for targets like + /// wasm32 where the whole program either has simd or not. + pub simd_types_indirect: bool, } impl Default for TargetOptions { @@ -720,6 +729,7 @@ has_rpath: false, no_default_libraries: true, position_independent_executables: false, + needs_plt: false, relro_level: RelroLevel::None, pre_link_objects_exe: Vec::new(), pre_link_objects_exe_crt: Vec::new(), @@ -756,12 +766,13 @@ embed_bitcode: false, emit_debug_gdb_scripts: true, requires_uwtable: false, + simd_types_indirect: true, } } } impl Target { - /// Given a function ABI, turn "System" into the correct ABI for this target. + /// Given a function ABI, turn it into the correct ABI for this target. pub fn adjust_abi(&self, abi: Abi) -> Abi { match abi { Abi::System => { @@ -771,6 +782,16 @@ Abi::C } }, + // These ABI kinds are ignored on non-x86 Windows targets. + // See https://docs.microsoft.com/en-us/cpp/cpp/argument-passing-and-naming-conventions + // and the individual pages for __stdcall et al. + Abi::Stdcall | Abi::Fastcall | Abi::Vectorcall | Abi::Thiscall => { + if self.options.is_like_windows && self.arch != "x86" { + Abi::C + } else { + abi + } + }, abi => abi } } @@ -999,6 +1020,7 @@ key!(has_rpath, bool); key!(no_default_libraries, bool); key!(position_independent_executables, bool); + key!(needs_plt, bool); try!(key!(relro_level, RelroLevel)); key!(archive_format); key!(allow_asm, bool); @@ -1026,6 +1048,7 @@ key!(embed_bitcode, bool); key!(emit_debug_gdb_scripts, bool); key!(requires_uwtable, bool); + key!(simd_types_indirect, bool); if let Some(array) = obj.find("abi-blacklist").and_then(Json::as_array) { for name in array.iter().filter_map(|abi| abi.as_string()) { @@ -1109,7 +1132,7 @@ macro_rules! target_val { ($attr:ident) => ( { let name = (stringify!($attr)).replace("_", "-"); - d.insert(name.to_string(), self.$attr.to_json()); + d.insert(name, self.$attr.to_json()); } ); ($attr:ident, $key_name:expr) => ( { let name = $key_name; @@ -1121,7 +1144,7 @@ ($attr:ident) => ( { let name = (stringify!($attr)).replace("_", "-"); if default.$attr != self.options.$attr { - d.insert(name.to_string(), self.options.$attr.to_json()); + d.insert(name, self.options.$attr.to_json()); } } ); ($attr:ident, $key_name:expr) => ( { @@ -1137,7 +1160,7 @@ .iter() .map(|(k, v)| (k.desc().to_owned(), v.clone())) .collect::>(); - d.insert(name.to_string(), obj.to_json()); + d.insert(name, obj.to_json()); } } ); (env - $attr:ident) => ( { @@ -1147,7 +1170,7 @@ .iter() .map(|&(ref k, ref v)| k.clone() + "=" + &v) .collect::>(); - d.insert(name.to_string(), obj.to_json()); + d.insert(name, obj.to_json()); } } ); @@ -1207,6 +1230,7 @@ target_option_val!(has_rpath); target_option_val!(no_default_libraries); target_option_val!(position_independent_executables); + target_option_val!(needs_plt); target_option_val!(relro_level); target_option_val!(archive_format); target_option_val!(allow_asm); @@ -1234,6 +1258,7 @@ target_option_val!(embed_bitcode); target_option_val!(emit_debug_gdb_scripts); target_option_val!(requires_uwtable); + target_option_val!(simd_types_indirect); if default.abi_blacklist != self.options.abi_blacklist { d.insert("abi-blacklist".to_string(), self.options.abi_blacklist.iter() diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_target/spec/netbsd_base.rs rustc-1.31.0+dfsg1+llvm/src/librustc_target/spec/netbsd_base.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_target/spec/netbsd_base.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_target/spec/netbsd_base.rs 2018-12-04 23:41:40.000000000 +0000 @@ -29,6 +29,7 @@ executables: true, target_family: Some("unix".to_string()), linker_is_gnu: true, + no_default_libraries: false, has_rpath: true, pre_link_args: args, position_independent_executables: true, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_target/spec/wasm32_unknown_unknown.rs rustc-1.31.0+dfsg1+llvm/src/librustc_target/spec/wasm32_unknown_unknown.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_target/spec/wasm32_unknown_unknown.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_target/spec/wasm32_unknown_unknown.rs 2018-12-04 23:41:40.000000000 +0000 @@ -54,6 +54,12 @@ linker: Some("rust-lld".to_owned()), lld_flavor: LldFlavor::Wasm, + // No need for indirection here, simd types can always be passed by + // value as the whole module either has simd or not, which is different + // from x86 (for example) where programs can have functions that don't + // enable simd features. + simd_types_indirect: false, + .. Default::default() }; Ok(Target { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_target/spec/x86_64_rumprun_netbsd.rs rustc-1.31.0+dfsg1+llvm/src/librustc_target/spec/x86_64_rumprun_netbsd.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_target/spec/x86_64_rumprun_netbsd.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_target/spec/x86_64_rumprun_netbsd.rs 2018-12-04 23:41:40.000000000 +0000 @@ -21,7 +21,6 @@ base.has_rpath = false; base.position_independent_executables = false; base.disable_redzone = true; - base.no_default_libraries = false; base.exe_allocation_crate = None; base.stack_probes = true; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_target/spec/x86_64_unknown_linux_gnux32.rs rustc-1.31.0+dfsg1+llvm/src/librustc_target/spec/x86_64_unknown_linux_gnux32.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_target/spec/x86_64_unknown_linux_gnux32.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_target/spec/x86_64_unknown_linux_gnux32.rs 2018-12-04 23:41:40.000000000 +0000 @@ -17,6 +17,9 @@ base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-mx32".to_string()); base.stack_probes = true; base.has_elf_tls = false; + // BUG(GabrielMajeri): disabling the PLT on x86_64 Linux with x32 ABI + // breaks code gen. See LLVM bug 36743 + base.needs_plt = true; Ok(Target { llvm_target: "x86_64-unknown-linux-gnux32".to_string(), diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_traits/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/librustc_traits/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/librustc_traits/Cargo.toml 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_traits/Cargo.toml 2018-12-04 23:41:40.000000000 +0000 @@ -16,5 +16,5 @@ rustc_data_structures = { path = "../librustc_data_structures" } syntax = { path = "../libsyntax" } syntax_pos = { path = "../libsyntax_pos" } -chalk-engine = { version = "0.7.0", default-features=false } +chalk-engine = { version = "0.8.0", default-features=false } smallvec = { version = "0.6.5", features = ["union"] } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_traits/chalk_context.rs rustc-1.31.0+dfsg1+llvm/src/librustc_traits/chalk_context.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_traits/chalk_context.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_traits/chalk_context.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,9 @@ use chalk_engine::fallible::Fallible as ChalkEngineFallible; use chalk_engine::{context, hh::HhGoal, DelayedLiteral, ExClause}; -use rustc::infer::canonical::{Canonical, CanonicalVarValues, QueryRegionConstraint, QueryResult}; +use rustc::infer::canonical::{ + Canonical, CanonicalVarValues, OriginalQueryValues, QueryRegionConstraint, QueryResponse, +}; use rustc::infer::{InferCtxt, InferOk, LateBoundRegionConversionTime}; use rustc::traits::{ WellFormed, @@ -19,13 +21,17 @@ ExClauseFold, ExClauseLift, Goal, - ProgramClause, - QuantifierKind + GoalKind, + Clause, + ProgramClauseCategory, + QuantifierKind, + Environment, + InEnvironment, }; use rustc::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; use rustc::ty::subst::Kind; use rustc::ty::{self, TyCtxt}; -use smallvec::SmallVec; +use rustc::hir::def_id::DefId; use std::fmt::{self, Debug}; use std::marker::PhantomData; @@ -66,71 +72,66 @@ impl context::Context for ChalkArenas<'tcx> { type CanonicalExClause = Canonical<'tcx, ExClause>; - type CanonicalGoalInEnvironment = Canonical<'tcx, ty::ParamEnvAnd<'tcx, Goal<'tcx>>>; + type CanonicalGoalInEnvironment = Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>; // u-canonicalization not yet implemented - type UCanonicalGoalInEnvironment = Canonical<'tcx, ty::ParamEnvAnd<'tcx, Goal<'tcx>>>; + type UCanonicalGoalInEnvironment = Canonical<'tcx, InEnvironment<'tcx, Goal<'tcx>>>; type CanonicalConstrainedSubst = Canonical<'tcx, ConstrainedSubst<'tcx>>; // u-canonicalization not yet implemented type UniverseMap = UniverseMap; - type Solution = Canonical<'tcx, QueryResult<'tcx, ()>>; + type Solution = Canonical<'tcx, QueryResponse<'tcx, ()>>; type InferenceNormalizedSubst = CanonicalVarValues<'tcx>; - type GoalInEnvironment = ty::ParamEnvAnd<'tcx, Goal<'tcx>>; + type GoalInEnvironment = InEnvironment<'tcx, Goal<'tcx>>; type RegionConstraint = QueryRegionConstraint<'tcx>; type Substitution = CanonicalVarValues<'tcx>; - type Environment = ty::ParamEnv<'tcx>; + type Environment = Environment<'tcx>; type Goal = Goal<'tcx>; type DomainGoal = DomainGoal<'tcx>; - type BindersGoal = ty::Binder<&'tcx Goal<'tcx>>; + type BindersGoal = ty::Binder>; type Parameter = Kind<'tcx>; - type ProgramClause = ProgramClause<'tcx>; + type ProgramClause = Clause<'tcx>; - type ProgramClauses = Vec>; + type ProgramClauses = Vec>; type UnificationResult = InferOk<'tcx, ()>; - fn into_goal(domain_goal: DomainGoal<'tcx>) -> Goal<'tcx> { - Goal::DomainGoal(domain_goal) - } - - fn cannot_prove() -> Goal<'tcx> { - Goal::CannotProve - } - fn goal_in_environment( - env: &ty::ParamEnv<'tcx>, + env: &Environment<'tcx>, goal: Goal<'tcx>, - ) -> ty::ParamEnvAnd<'tcx, Goal<'tcx>> { - env.and(goal) + ) -> InEnvironment<'tcx, Goal<'tcx>> { + env.with(goal) } } impl context::AggregateOps> for ChalkContext<'cx, 'gcx> { fn make_solution( &self, - _root_goal: &Canonical<'gcx, ty::ParamEnvAnd<'gcx, Goal<'gcx>>>, + _root_goal: &Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>>, _simplified_answers: impl context::AnswerStream>, - ) -> Option>> { + ) -> Option>> { unimplemented!() } } impl context::ContextOps> for ChalkContext<'cx, 'gcx> { /// True if this is a coinductive goal -- e.g., proving an auto trait. - fn is_coinductive(&self, _goal: &Canonical<'gcx, ty::ParamEnvAnd<'gcx, Goal<'gcx>>>) -> bool { + fn is_coinductive( + &self, + _goal: &Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>> + ) -> bool { unimplemented!() } @@ -148,7 +149,7 @@ /// - the environment and goal found by substitution `S` into `arg` fn instantiate_ucanonical_goal( &self, - _arg: &Canonical<'gcx, ty::ParamEnvAnd<'gcx, Goal<'gcx>>>, + _arg: &Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>>, _op: impl context::WithInstantiatedUCanonicalGoal, Output = R>, ) -> R { unimplemented!() @@ -181,19 +182,19 @@ } fn canonical( - u_canon: &'a Canonical<'gcx, ty::ParamEnvAnd<'gcx, Goal<'gcx>>>, - ) -> &'a Canonical<'gcx, ty::ParamEnvAnd<'gcx, Goal<'gcx>>> { + u_canon: &'a Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>>, + ) -> &'a Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>> { u_canon } fn is_trivial_substitution( - _u_canon: &Canonical<'gcx, ty::ParamEnvAnd<'gcx, Goal<'gcx>>>, + _u_canon: &Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>>, _canonical_subst: &Canonical<'gcx, ConstrainedSubst<'gcx>>, ) -> bool { unimplemented!() } - fn num_universes(_: &Canonical<'gcx, ty::ParamEnvAnd<'gcx, Goal<'gcx>>>) -> usize { + fn num_universes(_: &Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>>) -> usize { 0 // FIXME } @@ -202,8 +203,8 @@ /// but for the universes of universally quantified names. fn map_goal_from_canonical( _map: &UniverseMap, - value: &Canonical<'gcx, ty::ParamEnvAnd<'gcx, Goal<'gcx>>>, - ) -> Canonical<'gcx, ty::ParamEnvAnd<'gcx, Goal<'gcx>>> { + value: &Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>>, + ) -> Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>> { *value // FIXME universe maps not implemented yet } @@ -251,24 +252,36 @@ impl context::InferenceTable, ChalkArenas<'tcx>> for ChalkInferenceContext<'cx, 'gcx, 'tcx> { + fn into_goal(&self, domain_goal: DomainGoal<'tcx>) -> Goal<'tcx> { + self.infcx.tcx.mk_goal(GoalKind::DomainGoal(domain_goal)) + } + + fn cannot_prove(&self) -> Goal<'tcx> { + self.infcx.tcx.mk_goal(GoalKind::CannotProve) + } + fn into_hh_goal(&mut self, goal: Goal<'tcx>) -> ChalkHhGoal<'tcx> { - match goal { - Goal::Implies(..) => panic!("FIXME rust-lang-nursery/chalk#94"), - Goal::And(left, right) => HhGoal::And(*left, *right), - Goal::Not(subgoal) => HhGoal::Not(*subgoal), - Goal::DomainGoal(d) => HhGoal::DomainGoal(d), - Goal::Quantified(QuantifierKind::Universal, binder) => HhGoal::ForAll(binder), - Goal::Quantified(QuantifierKind::Existential, binder) => HhGoal::Exists(binder), - Goal::CannotProve => HhGoal::CannotProve, + match *goal { + GoalKind::Implies(..) => panic!("FIXME rust-lang-nursery/chalk#94"), + GoalKind::And(left, right) => HhGoal::And(left, right), + GoalKind::Not(subgoal) => HhGoal::Not(subgoal), + GoalKind::DomainGoal(d) => HhGoal::DomainGoal(d), + GoalKind::Quantified(QuantifierKind::Universal, binder) => HhGoal::ForAll(binder), + GoalKind::Quantified(QuantifierKind::Existential, binder) => HhGoal::Exists(binder), + GoalKind::CannotProve => HhGoal::CannotProve, } } fn add_clauses( &mut self, - _env: &ty::ParamEnv<'tcx>, - _clauses: Vec>, - ) -> ty::ParamEnv<'tcx> { - panic!("FIXME no method to add clauses to ParamEnv yet") + env: &Environment<'tcx>, + clauses: Vec>, + ) -> Environment<'tcx> { + Environment { + clauses: self.infcx.tcx.mk_clauses( + env.clauses.iter().cloned().chain(clauses.into_iter()) + ) + } } } @@ -277,10 +290,10 @@ { fn resolvent_clause( &mut self, - _environment: &ty::ParamEnv<'tcx>, + _environment: &Environment<'tcx>, _goal: &DomainGoal<'tcx>, _subst: &CanonicalVarValues<'tcx>, - _clause: &ProgramClause<'tcx>, + _clause: &Clause<'tcx>, ) -> chalk_engine::fallible::Fallible>> { panic!() } @@ -288,8 +301,8 @@ fn apply_answer_subst( &mut self, _ex_clause: ChalkExClause<'tcx>, - _selected_goal: &ty::ParamEnvAnd<'tcx, Goal<'tcx>>, - _answer_table_goal: &Canonical<'gcx, ty::ParamEnvAnd<'gcx, Goal<'gcx>>>, + _selected_goal: &InEnvironment<'tcx, Goal<'tcx>>, + _answer_table_goal: &Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>>, _canonical_answer_subst: &Canonical<'gcx, ConstrainedSubst<'gcx>>, ) -> chalk_engine::fallible::Fallible> { panic!() @@ -301,8 +314,8 @@ { fn truncate_goal( &mut self, - subgoal: &ty::ParamEnvAnd<'tcx, Goal<'tcx>>, - ) -> Option>> { + subgoal: &InEnvironment<'tcx, Goal<'tcx>>, + ) -> Option>> { Some(*subgoal) // FIXME we should truncate at some point! } @@ -319,65 +332,249 @@ { fn program_clauses( &self, - _environment: &ty::ParamEnv<'tcx>, + environment: &Environment<'tcx>, goal: &DomainGoal<'tcx>, - ) -> Vec> { + ) -> Vec> { use rustc::traits::WhereClause::*; - match goal { - DomainGoal::Holds(Implemented(_trait_predicate)) => { + fn assemble_clauses_from_impls<'tcx>( + tcx: ty::TyCtxt<'_, '_, 'tcx>, + trait_def_id: DefId, + clauses: &mut Vec> + ) { + tcx.for_each_impl(trait_def_id, |impl_def_id| { + clauses.extend( + tcx.program_clauses_for(impl_def_id) + .into_iter() + .cloned() + ); + }); + } + + fn assemble_clauses_from_assoc_ty_values<'tcx>( + tcx: ty::TyCtxt<'_, '_, 'tcx>, + trait_def_id: DefId, + clauses: &mut Vec> + ) { + tcx.for_each_impl(trait_def_id, |impl_def_id| { + for def_id in tcx.associated_item_def_ids(impl_def_id).iter() { + clauses.extend( + tcx.program_clauses_for(*def_id) + .into_iter() + .cloned() + ); + } + }); + } + + let mut clauses = match goal { + DomainGoal::Holds(Implemented(trait_predicate)) => { // These come from: - // - // - Trait definitions (implied bounds) - // - Implementations of the trait itself - panic!() + // * implementations of the trait itself (rule `Implemented-From-Impl`) + // * the trait decl (rule `Implemented-From-Env`) + + let mut clauses = vec![]; + assemble_clauses_from_impls( + self.infcx.tcx, + trait_predicate.def_id(), + &mut clauses + ); + + // FIXME: we need to add special rules for builtin impls: + // * `Copy` / `Clone` + // * `Sized` + // * `Unsize` + // * `Generator` + // * `FnOnce` / `FnMut` / `Fn` + // * trait objects + // * auto traits + + // Rule `Implemented-From-Env` will be computed from the environment. + clauses } - DomainGoal::Holds(ProjectionEq(_projection_predicate)) => { + DomainGoal::Holds(ProjectionEq(projection_predicate)) => { // These come from: - panic!() + // * the assoc type definition (rule `ProjectionEq-Placeholder`) + // * normalization of the assoc ty values (rule `ProjectionEq-Normalize`) + // * implied bounds from trait definitions (rule `Implied-Bound-From-Trait`) + // * implied bounds from type definitions (rule `Implied-Bound-From-Type`) + + let clauses = self.infcx.tcx.program_clauses_for( + projection_predicate.projection_ty.item_def_id + ).into_iter() + + // only select `ProjectionEq-Placeholder` and `ProjectionEq-Normalize` + .filter(|clause| clause.category() == ProgramClauseCategory::Other) + + .cloned() + .collect::>(); + + // Rules `Implied-Bound-From-Trait` and `Implied-Bound-From-Type` will be computed + // from the environment. + clauses } - DomainGoal::Holds(RegionOutlives(_region_outlives)) => { - panic!() + DomainGoal::Holds(RegionOutlives(..)) => { + // These come from: + // * implied bounds from trait definitions (rule `Implied-Bound-From-Trait`) + // * implied bounds from type definitions (rule `Implied-Bound-From-Type`) + + // All of these rules are computed in the environment. + vec![] } - DomainGoal::Holds(TypeOutlives(_type_outlives)) => { - panic!() + DomainGoal::Holds(TypeOutlives(..)) => { + // These come from: + // * implied bounds from trait definitions (rule `Implied-Bound-From-Trait`) + // * implied bounds from type definitions (rule `Implied-Bound-From-Type`) + + // All of these rules are computed in the environment. + vec![] } - DomainGoal::WellFormed(WellFormed::Trait(_trait_predicate)) => { - // These come from -- the trait decl. - panic!() + DomainGoal::WellFormed(WellFormed::Trait(trait_predicate)) => { + // These come from -- the trait decl (rule `WellFormed-TraitRef`). + self.infcx.tcx.program_clauses_for(trait_predicate.def_id()) + .into_iter() + + // only select `WellFormed-TraitRef` + .filter(|clause| clause.category() == ProgramClauseCategory::WellFormed) + + .cloned() + .collect() } - DomainGoal::WellFormed(WellFormed::Ty(_ty)) => panic!(), + DomainGoal::WellFormed(WellFormed::Ty(ty)) => { + // These come from: + // * the associated type definition if `ty` refers to an unnormalized + // associated type (rule `WellFormed-AssocTy`) + // * custom rules for built-in types + // * the type definition otherwise (rule `WellFormed-Type`) + let clauses = match ty.sty { + ty::Projection(data) => { + self.infcx.tcx.program_clauses_for(data.item_def_id) + } + + // These types are always WF (recall that we do not check + // for parameters to be WF) + ty::Bool | + ty::Char | + ty::Int(..) | + ty::Uint(..) | + ty::Float(..) | + ty::Str | + ty::RawPtr(..) | + ty::FnPtr(..) | + ty::Param(..) | + ty::Never => { + ty::List::empty() + } + + // WF if inner type is `Sized` + ty::Slice(..) | + ty::Array(..) => { + ty::List::empty() + } + + ty::Tuple(..) => { + ty::List::empty() + } + + // WF if `sub_ty` outlives `region` + ty::Ref(..) => { + ty::List::empty() + } + + ty::Dynamic(..) => { + // FIXME: no rules yet for trait objects + ty::List::empty() + } + + ty::Adt(def, ..) => { + self.infcx.tcx.program_clauses_for(def.did) + } + + ty::Foreign(def_id) | + ty::FnDef(def_id, ..) | + ty::Closure(def_id, ..) | + ty::Generator(def_id, ..) | + ty::Opaque(def_id, ..) => { + self.infcx.tcx.program_clauses_for(def_id) + } + + ty::GeneratorWitness(..) | + ty::UnnormalizedProjection(..) | + ty::Infer(..) | + ty::Error => { + bug!("unexpected type {:?}", ty) + } + }; + + clauses.into_iter() + .filter(|clause| clause.category() == ProgramClauseCategory::WellFormed) + .cloned() + .collect() + } - DomainGoal::FromEnv(FromEnv::Trait(_trait_predicate)) => panic!(), + DomainGoal::FromEnv(FromEnv::Trait(..)) => { + // These come from: + // * implied bounds from trait definitions (rule `Implied-Bound-From-Trait`) + // * implied bounds from type definitions (rule `Implied-Bound-From-Type`) + // * implied bounds from assoc type defs (rules `Implied-Trait-From-AssocTy`, + // `Implied-Bound-From-AssocTy` and `Implied-WC-From-AssocTy`) - DomainGoal::FromEnv(FromEnv::Ty(_ty)) => panic!(), + // All of these rules are computed in the environment. + vec![] + } - DomainGoal::Normalize(_) => panic!(), - } + DomainGoal::FromEnv(FromEnv::Ty(..)) => { + // There are no `FromEnv::Ty(..) :- ...` rules (this predicate only + // comes from the environment). + vec![] + } + + DomainGoal::Normalize(projection_predicate) => { + // These come from -- assoc ty values (rule `Normalize-From-Impl`). + let mut clauses = vec![]; + + assemble_clauses_from_assoc_ty_values( + self.infcx.tcx, + projection_predicate.projection_ty.trait_ref(self.infcx.tcx).def_id, + &mut clauses + ); + + clauses + } + }; + + let environment = self.infcx.tcx.lift_to_global(environment) + .expect("environment is not global"); + clauses.extend( + self.infcx.tcx.program_clauses_for_env(environment) + .into_iter() + .cloned() + ); + clauses } fn instantiate_binders_universally( &mut self, - _arg: &ty::Binder<&'tcx Goal<'tcx>>, + _arg: &ty::Binder>, ) -> Goal<'tcx> { panic!("FIXME -- universal instantiation needs sgrif's branch") } fn instantiate_binders_existentially( &mut self, - arg: &ty::Binder<&'tcx Goal<'tcx>>, + arg: &ty::Binder>, ) -> Goal<'tcx> { let (value, _map) = self.infcx.replace_late_bound_regions_with_fresh_var( DUMMY_SP, LateBoundRegionConversionTime::HigherRankedType, arg, ); - *value + value } fn debug_ex_clause(&mut self, value: &'v ChalkExClause<'tcx>) -> Box { @@ -387,9 +584,9 @@ fn canonicalize_goal( &mut self, - value: &ty::ParamEnvAnd<'tcx, Goal<'tcx>>, - ) -> Canonical<'gcx, ty::ParamEnvAnd<'gcx, Goal<'gcx>>> { - let mut _orig_values = SmallVec::new(); + value: &InEnvironment<'tcx, Goal<'tcx>>, + ) -> Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>> { + let mut _orig_values = OriginalQueryValues::default(); self.infcx.canonicalize_query(value, &mut _orig_values) } @@ -410,9 +607,9 @@ fn u_canonicalize_goal( &mut self, - value: &Canonical<'gcx, ty::ParamEnvAnd<'gcx, Goal<'gcx>>>, + value: &Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>>, ) -> ( - Canonical<'gcx, ty::ParamEnvAnd<'gcx, Goal<'gcx>>>, + Canonical<'gcx, InEnvironment<'gcx, Goal<'gcx>>>, UniverseMap, ) { (value.clone(), UniverseMap) @@ -420,14 +617,14 @@ fn invert_goal( &mut self, - _value: &ty::ParamEnvAnd<'tcx, Goal<'tcx>>, - ) -> Option>> { + _value: &InEnvironment<'tcx, Goal<'tcx>>, + ) -> Option>> { panic!("goal inversion not yet implemented") } fn unify_parameters( &mut self, - _environment: &ty::ParamEnv<'tcx>, + _environment: &Environment<'tcx>, _a: &Kind<'tcx>, _b: &Kind<'tcx>, ) -> ChalkEngineFallible> { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_traits/dropck_outlives.rs rustc-1.31.0+dfsg1+llvm/src/librustc_traits/dropck_outlives.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_traits/dropck_outlives.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_traits/dropck_outlives.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,7 +9,7 @@ // except according to those terms. use rustc::hir::def_id::DefId; -use rustc::infer::canonical::{Canonical, QueryResult}; +use rustc::infer::canonical::{Canonical, QueryResponse}; use rustc::traits::query::dropck_outlives::{DropckOutlivesResult, DtorckConstraint}; use rustc::traits::query::{CanonicalTyGoal, NoSolution}; use rustc::traits::{FulfillmentContext, Normalized, ObligationCause, TraitEngineExt}; @@ -30,124 +30,125 @@ fn dropck_outlives<'tcx>( tcx: TyCtxt<'_, 'tcx, 'tcx>, - goal: CanonicalTyGoal<'tcx>, -) -> Result>>>, NoSolution> { - debug!("dropck_outlives(goal={:#?})", goal); - - tcx.infer_ctxt().enter(|ref infcx| { - let tcx = infcx.tcx; - let ( - ParamEnvAnd { + canonical_goal: CanonicalTyGoal<'tcx>, +) -> Result>>>, NoSolution> { + debug!("dropck_outlives(goal={:#?})", canonical_goal); + + tcx.infer_ctxt().enter_with_canonical( + DUMMY_SP, + &canonical_goal, + |ref infcx, goal, canonical_inference_vars| { + let tcx = infcx.tcx; + let ParamEnvAnd { param_env, value: for_ty, - }, - canonical_inference_vars, - ) = infcx.instantiate_canonical_with_fresh_inference_vars(DUMMY_SP, &goal); + } = goal; - let mut result = DropckOutlivesResult { - kinds: vec![], - overflows: vec![], - }; - - // A stack of types left to process. Each round, we pop - // something from the stack and invoke - // `dtorck_constraint_for_ty`. This may produce new types that - // have to be pushed on the stack. This continues until we have explored - // all the reachable types from the type `for_ty`. - // - // Example: Imagine that we have the following code: - // - // ```rust - // struct A { - // value: B, - // children: Vec, - // } - // - // struct B { - // value: u32 - // } - // - // fn f() { - // let a: A = ...; - // .. - // } // here, `a` is dropped - // ``` - // - // at the point where `a` is dropped, we need to figure out - // which types inside of `a` contain region data that may be - // accessed by any destructors in `a`. We begin by pushing `A` - // onto the stack, as that is the type of `a`. We will then - // invoke `dtorck_constraint_for_ty` which will expand `A` - // into the types of its fields `(B, Vec)`. These will get - // pushed onto the stack. Eventually, expanding `Vec` will - // lead to us trying to push `A` a second time -- to prevent - // infinite recursion, we notice that `A` was already pushed - // once and stop. - let mut ty_stack = vec![(for_ty, 0)]; - - // Set used to detect infinite recursion. - let mut ty_set = FxHashSet(); - - let fulfill_cx = &mut FulfillmentContext::new(); - - let cause = ObligationCause::dummy(); - while let Some((ty, depth)) = ty_stack.pop() { - let DtorckConstraint { - dtorck_types, - outlives, - overflows, - } = dtorck_constraint_for_ty(tcx, DUMMY_SP, for_ty, depth, ty)?; + let mut result = DropckOutlivesResult { + kinds: vec![], + overflows: vec![], + }; - // "outlives" represent types/regions that may be touched - // by a destructor. - result.kinds.extend(outlives); - result.overflows.extend(overflows); - - // dtorck types are "types that will get dropped but which - // do not themselves define a destructor", more or less. We have - // to push them onto the stack to be expanded. - for ty in dtorck_types { - match infcx.at(&cause, param_env).normalize(&ty) { - Ok(Normalized { - value: ty, - obligations, - }) => { - fulfill_cx.register_predicate_obligations(infcx, obligations); - - debug!("dropck_outlives: ty from dtorck_types = {:?}", ty); - - match ty.sty { - // All parameters live for the duration of the - // function. - ty::Param(..) => {} - - // A projection that we couldn't resolve - it - // might have a destructor. - ty::Projection(..) | ty::Opaque(..) => { - result.kinds.push(ty.into()); - } + // A stack of types left to process. Each round, we pop + // something from the stack and invoke + // `dtorck_constraint_for_ty`. This may produce new types that + // have to be pushed on the stack. This continues until we have explored + // all the reachable types from the type `for_ty`. + // + // Example: Imagine that we have the following code: + // + // ```rust + // struct A { + // value: B, + // children: Vec, + // } + // + // struct B { + // value: u32 + // } + // + // fn f() { + // let a: A = ...; + // .. + // } // here, `a` is dropped + // ``` + // + // at the point where `a` is dropped, we need to figure out + // which types inside of `a` contain region data that may be + // accessed by any destructors in `a`. We begin by pushing `A` + // onto the stack, as that is the type of `a`. We will then + // invoke `dtorck_constraint_for_ty` which will expand `A` + // into the types of its fields `(B, Vec)`. These will get + // pushed onto the stack. Eventually, expanding `Vec` will + // lead to us trying to push `A` a second time -- to prevent + // infinite recursion, we notice that `A` was already pushed + // once and stop. + let mut ty_stack = vec![(for_ty, 0)]; + + // Set used to detect infinite recursion. + let mut ty_set = FxHashSet::default(); + + let fulfill_cx = &mut FulfillmentContext::new(); + + let cause = ObligationCause::dummy(); + while let Some((ty, depth)) = ty_stack.pop() { + let DtorckConstraint { + dtorck_types, + outlives, + overflows, + } = dtorck_constraint_for_ty(tcx, DUMMY_SP, for_ty, depth, ty)?; + + // "outlives" represent types/regions that may be touched + // by a destructor. + result.kinds.extend(outlives); + result.overflows.extend(overflows); + + // dtorck types are "types that will get dropped but which + // do not themselves define a destructor", more or less. We have + // to push them onto the stack to be expanded. + for ty in dtorck_types { + match infcx.at(&cause, param_env).normalize(&ty) { + Ok(Normalized { + value: ty, + obligations, + }) => { + fulfill_cx.register_predicate_obligations(infcx, obligations); + + debug!("dropck_outlives: ty from dtorck_types = {:?}", ty); + + match ty.sty { + // All parameters live for the duration of the + // function. + ty::Param(..) => {} + + // A projection that we couldn't resolve - it + // might have a destructor. + ty::Projection(..) | ty::Opaque(..) => { + result.kinds.push(ty.into()); + } - _ => { - if ty_set.insert(ty) { - ty_stack.push((ty, depth + 1)); + _ => { + if ty_set.insert(ty) { + ty_stack.push((ty, depth + 1)); + } } } } - } - // We don't actually expect to fail to normalize. - // That implies a WF error somewhere else. - Err(NoSolution) => { - return Err(NoSolution); + // We don't actually expect to fail to normalize. + // That implies a WF error somewhere else. + Err(NoSolution) => { + return Err(NoSolution); + } } } } - } - debug!("dropck_outlives: result = {:#?}", result); + debug!("dropck_outlives: result = {:#?}", result); - infcx.make_canonicalized_query_result(canonical_inference_vars, result, fulfill_cx) - }) + infcx.make_canonicalized_query_response(canonical_inference_vars, result, fulfill_cx) + }, + ) } /// Return a set of constraints that needs to be satisfied in @@ -195,8 +196,7 @@ dtorck_constraint_for_ty(tcx, span, for_ty, depth + 1, ety) } - ty::Tuple(tys) => tys - .iter() + ty::Tuple(tys) => tys.iter() .map(|ty| dtorck_constraint_for_ty(tcx, span, for_ty, depth + 1, ty)) .collect(), @@ -272,6 +272,8 @@ overflows: vec![], }), + ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"), + ty::Infer(..) | ty::Error => { // By the time this code runs, all type variables ought to // be fully resolved. @@ -306,8 +308,7 @@ return Ok(result); } - let mut result = def - .all_fields() + let mut result = def.all_fields() .map(|field| tcx.type_of(field.did)) .map(|fty| dtorck_constraint_for_ty(tcx, span, fty, 0, fty)) .collect::>()?; @@ -320,8 +321,8 @@ } fn dedup_dtorck_constraint<'tcx>(c: &mut DtorckConstraint<'tcx>) { - let mut outlives = FxHashSet(); - let mut dtorck_types = FxHashSet(); + let mut outlives = FxHashSet::default(); + let mut dtorck_types = FxHashSet::default(); c.outlives.retain(|&val| outlives.replace(val).is_none()); c.dtorck_types diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_traits/evaluate_obligation.rs rustc-1.31.0+dfsg1+llvm/src/librustc_traits/evaluate_obligation.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_traits/evaluate_obligation.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_traits/evaluate_obligation.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,9 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rustc::traits::{EvaluationResult, Obligation, ObligationCause, - OverflowError, SelectionContext, TraitQueryMode}; use rustc::traits::query::CanonicalPredicateGoal; +use rustc::traits::{ + EvaluationResult, Obligation, ObligationCause, OverflowError, SelectionContext, TraitQueryMode, +}; use rustc::ty::query::Providers; use rustc::ty::{ParamEnvAnd, TyCtxt}; use syntax::source_map::DUMMY_SP; @@ -24,20 +25,21 @@ fn evaluate_obligation<'tcx>( tcx: TyCtxt<'_, 'tcx, 'tcx>, - goal: CanonicalPredicateGoal<'tcx>, + canonical_goal: CanonicalPredicateGoal<'tcx>, ) -> Result { - tcx.infer_ctxt().enter(|ref infcx| { - let ( - ParamEnvAnd { + tcx.infer_ctxt().enter_with_canonical( + DUMMY_SP, + &canonical_goal, + |ref infcx, goal, _canonical_inference_vars| { + let ParamEnvAnd { param_env, value: predicate, - }, - _canonical_inference_vars, - ) = infcx.instantiate_canonical_with_fresh_inference_vars(DUMMY_SP, &goal); + } = goal; - let mut selcx = SelectionContext::with_query_mode(&infcx, TraitQueryMode::Canonical); - let obligation = Obligation::new(ObligationCause::dummy(), param_env, predicate); + let mut selcx = SelectionContext::with_query_mode(&infcx, TraitQueryMode::Canonical); + let obligation = Obligation::new(ObligationCause::dummy(), param_env, predicate); - selcx.evaluate_obligation_recursively(&obligation) - }) + selcx.evaluate_obligation_recursively(&obligation) + }, + ) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_traits/implied_outlives_bounds.rs rustc-1.31.0+dfsg1+llvm/src/librustc_traits/implied_outlives_bounds.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_traits/implied_outlives_bounds.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_traits/implied_outlives_bounds.rs 2018-12-04 23:41:40.000000000 +0000 @@ -37,7 +37,7 @@ tcx: TyCtxt<'_, 'tcx, 'tcx>, goal: CanonicalTyGoal<'tcx>, ) -> Result< - Lrc>>>>, + Lrc>>>>, NoSolution, > { tcx.infer_ctxt() diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_traits/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_traits/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_traits/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_traits/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,12 +11,9 @@ //! New recursive solver modeled on Chalk's recursive solver. Most of //! the guts are broken up into modules; see the comments in those modules. -#![cfg_attr(stage0, feature(crate_in_paths))] #![feature(crate_visibility_modifier)] -#![cfg_attr(stage0, feature(extern_prelude))] #![feature(in_band_lifetimes)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![recursion_limit="256"] diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_traits/lowering/environment.rs rustc-1.31.0+dfsg1+llvm/src/librustc_traits/lowering/environment.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_traits/lowering/environment.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_traits/lowering/environment.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,259 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use rustc::traits::{ + Clause, + Clauses, + DomainGoal, + FromEnv, + ProgramClause, + ProgramClauseCategory, + Environment, +}; +use rustc::ty::{self, TyCtxt, Ty}; +use rustc::hir::def_id::DefId; +use rustc_data_structures::fx::FxHashSet; + +struct ClauseVisitor<'set, 'a, 'tcx: 'a + 'set> { + tcx: TyCtxt<'a, 'tcx, 'tcx>, + round: &'set mut FxHashSet>, +} + +impl ClauseVisitor<'set, 'a, 'tcx> { + fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, round: &'set mut FxHashSet>) -> Self { + ClauseVisitor { + tcx, + round, + } + } + + fn visit_ty(&mut self, ty: Ty<'tcx>) { + match ty.sty { + ty::Projection(data) => { + self.round.extend( + self.tcx.program_clauses_for(data.item_def_id) + .iter() + .filter(|c| c.category() == ProgramClauseCategory::ImpliedBound) + .cloned() + ); + } + + // forall<'a, T> { `Outlives(T, 'a) :- FromEnv(&'a T)` } + ty::Ref(_region, _sub_ty, ..) => { + // FIXME: we'd need bound tys in order to properly write the above rule + } + + ty::Dynamic(..) => { + // FIXME: trait object rules are not yet implemented + } + + ty::Adt(def, ..) => { + self.round.extend( + self.tcx.program_clauses_for(def.did) + .iter() + .filter(|c| c.category() == ProgramClauseCategory::ImpliedBound) + .cloned() + ); + } + + ty::Foreign(def_id) | + ty::FnDef(def_id, ..) | + ty::Closure(def_id, ..) | + ty::Generator(def_id, ..) | + ty::Opaque(def_id, ..) => { + self.round.extend( + self.tcx.program_clauses_for(def_id) + .iter() + .filter(|c| c.category() == ProgramClauseCategory::ImpliedBound) + .cloned() + ); + } + + ty::Bool | + ty::Char | + ty::Int(..) | + ty::Uint(..) | + ty::Float(..) | + ty::Str | + ty::Array(..) | + ty::Slice(..) | + ty::RawPtr(..) | + ty::FnPtr(..) | + ty::Tuple(..) | + ty::Never | + ty::Param(..) => (), + + ty::GeneratorWitness(..) | + ty::UnnormalizedProjection(..) | + ty::Infer(..) | + ty::Error => { + bug!("unexpected type {:?}", ty); + } + } + } + + fn visit_from_env(&mut self, from_env: FromEnv<'tcx>) { + match from_env { + FromEnv::Trait(predicate) => { + self.round.extend( + self.tcx.program_clauses_for(predicate.def_id()) + .iter() + .filter(|c| c.category() == ProgramClauseCategory::ImpliedBound) + .cloned() + ); + } + + FromEnv::Ty(ty) => self.visit_ty(ty), + } + } + + fn visit_domain_goal(&mut self, domain_goal: DomainGoal<'tcx>) { + // The only domain goals we can find in an environment are: + // * `DomainGoal::Holds(..)` + // * `DomainGoal::FromEnv(..)` + // The former do not lead to any implied bounds. So we only need + // to visit the latter. + if let DomainGoal::FromEnv(from_env) = domain_goal { + self.visit_from_env(from_env); + } + } + + fn visit_program_clause(&mut self, clause: ProgramClause<'tcx>) { + self.visit_domain_goal(clause.goal); + // No need to visit `clause.hypotheses`: they are always of the form + // `FromEnv(...)` and were visited at a previous round. + } + + fn visit_clause(&mut self, clause: Clause<'tcx>) { + match clause { + Clause::Implies(clause) => self.visit_program_clause(clause), + Clause::ForAll(clause) => self.visit_program_clause(*clause.skip_binder()), + } + } +} + +crate fn program_clauses_for_env<'a, 'tcx>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + environment: Environment<'tcx>, +) -> Clauses<'tcx> { + debug!("program_clauses_for_env(environment={:?})", environment); + + let mut last_round = FxHashSet::default(); + { + let mut visitor = ClauseVisitor::new(tcx, &mut last_round); + for &clause in environment.clauses { + visitor.visit_clause(clause); + } + } + + let mut closure = last_round.clone(); + let mut next_round = FxHashSet::default(); + while !last_round.is_empty() { + let mut visitor = ClauseVisitor::new(tcx, &mut next_round); + for clause in last_round.drain() { + visitor.visit_clause(clause); + } + last_round.extend( + next_round.drain().filter(|&clause| closure.insert(clause)) + ); + } + + debug!("program_clauses_for_env: closure = {:#?}", closure); + + return tcx.mk_clauses( + closure.into_iter() + ); +} + +crate fn environment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Environment<'tcx> { + use super::{Lower, IntoFromEnvGoal}; + use rustc::hir::{Node, TraitItemKind, ImplItemKind, ItemKind, ForeignItemKind}; + + // The environment of an impl Trait type is its defining function's environment. + if let Some(parent) = ty::is_impl_trait_defn(tcx, def_id) { + return environment(tcx, parent); + } + + // Compute the bounds on `Self` and the type parameters. + let ty::InstantiatedPredicates { predicates } = + tcx.predicates_of(def_id).instantiate_identity(tcx); + + let clauses = predicates.into_iter() + .map(|predicate| predicate.lower()) + .map(|domain_goal| domain_goal.map_bound(|bound| bound.into_from_env_goal())) + .map(|domain_goal| domain_goal.map_bound(|bound| bound.into_program_clause())) + + // `ForAll` because each `domain_goal` is a `PolyDomainGoal` and + // could bound lifetimes. + .map(Clause::ForAll); + + let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); + let node = tcx.hir.get(node_id); + + let mut is_fn = false; + let mut is_impl = false; + match node { + Node::TraitItem(item) => match item.node { + TraitItemKind::Method(..) => is_fn = true, + _ => (), + } + + Node::ImplItem(item) => match item.node { + ImplItemKind::Method(..) => is_fn = true, + _ => (), + } + + Node::Item(item) => match item.node { + ItemKind::Impl(..) => is_impl = true, + ItemKind::Fn(..) => is_fn = true, + _ => (), + } + + Node::ForeignItem(item) => match item.node { + ForeignItemKind::Fn(..) => is_fn = true, + _ => (), + } + + // FIXME: closures? + _ => (), + } + + let mut input_tys = FxHashSet::default(); + + // In an impl, we assume that the receiver type and all its constituents + // are well-formed. + if is_impl { + let trait_ref = tcx.impl_trait_ref(def_id).expect("not an impl"); + input_tys.extend(trait_ref.self_ty().walk()); + } + + // In an fn, we assume that the arguments and all their constituents are + // well-formed. + if is_fn { + let fn_sig = tcx.fn_sig(def_id); + input_tys.extend( + // FIXME: `skip_binder` seems ok for now? In a real setting, + // the late bound regions would next be instantiated with things + // in the inference table. + fn_sig.skip_binder().inputs().iter().flat_map(|ty| ty.walk()) + ); + } + + let clauses = clauses.chain( + input_tys.into_iter() + .map(|ty| DomainGoal::FromEnv(FromEnv::Ty(ty))) + .map(|domain_goal| domain_goal.into_program_clause()) + .map(Clause::Implies) + ); + + Environment { + clauses: tcx.mk_clauses(clauses), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_traits/lowering/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_traits/lowering/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_traits/lowering/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_traits/lowering/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,608 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod environment; + +use rustc::hir::def_id::DefId; +use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; +use rustc::hir::map::definitions::DefPathData; +use rustc::hir::{self, ImplPolarity}; +use rustc::traits::{ + Clause, + Clauses, + DomainGoal, + FromEnv, + GoalKind, + PolyDomainGoal, + ProgramClause, + ProgramClauseCategory, + WellFormed, + WhereClause, +}; +use rustc::ty::query::Providers; +use rustc::ty::{self, List, TyCtxt}; +use syntax::ast; + +use std::iter; + +crate fn provide(p: &mut Providers) { + *p = Providers { + program_clauses_for, + program_clauses_for_env: environment::program_clauses_for_env, + environment: environment::environment, + ..*p + }; +} + +crate trait Lower { + /// Lower a rustc construct (e.g. `ty::TraitPredicate`) to a chalk-like type. + fn lower(&self) -> T; +} + +impl Lower> for Vec +where + T: Lower, +{ + fn lower(&self) -> Vec { + self.iter().map(|item| item.lower()).collect() + } +} + +impl<'tcx> Lower> for ty::TraitPredicate<'tcx> { + fn lower(&self) -> WhereClause<'tcx> { + WhereClause::Implemented(*self) + } +} + +impl<'tcx> Lower> for ty::ProjectionPredicate<'tcx> { + fn lower(&self) -> WhereClause<'tcx> { + WhereClause::ProjectionEq(*self) + } +} + +impl<'tcx> Lower> for ty::RegionOutlivesPredicate<'tcx> { + fn lower(&self) -> WhereClause<'tcx> { + WhereClause::RegionOutlives(*self) + } +} + +impl<'tcx> Lower> for ty::TypeOutlivesPredicate<'tcx> { + fn lower(&self) -> WhereClause<'tcx> { + WhereClause::TypeOutlives(*self) + } +} + +impl<'tcx, T> Lower> for T +where + T: Lower>, +{ + fn lower(&self) -> DomainGoal<'tcx> { + DomainGoal::Holds(self.lower()) + } +} + +/// `ty::Binder` is used for wrapping a rustc construction possibly containing generic +/// lifetimes, e.g. `for<'a> T: Fn(&'a i32)`. Instead of representing higher-ranked things +/// in that leaf-form (i.e. `Holds(Implemented(Binder))` in the previous +/// example), we model them with quantified domain goals, e.g. as for the previous example: +/// `forall<'a> { T: Fn(&'a i32) }` which corresponds to something like +/// `Binder`. +impl<'tcx, T> Lower> for ty::Binder +where + T: Lower> + ty::fold::TypeFoldable<'tcx>, +{ + fn lower(&self) -> PolyDomainGoal<'tcx> { + self.map_bound_ref(|p| p.lower()) + } +} + +impl<'tcx> Lower> for ty::Predicate<'tcx> { + fn lower(&self) -> PolyDomainGoal<'tcx> { + use rustc::ty::Predicate; + + match self { + Predicate::Trait(predicate) => predicate.lower(), + Predicate::RegionOutlives(predicate) => predicate.lower(), + Predicate::TypeOutlives(predicate) => predicate.lower(), + Predicate::Projection(predicate) => predicate.lower(), + Predicate::WellFormed(ty) => { + ty::Binder::dummy(DomainGoal::WellFormed(WellFormed::Ty(*ty))) + } + Predicate::ObjectSafe(..) + | Predicate::ClosureKind(..) + | Predicate::Subtype(..) + | Predicate::ConstEvaluatable(..) => unimplemented!(), + } + } +} + +/// Used for implied bounds related rules (see rustc guide). +trait IntoFromEnvGoal { + /// Transforms an existing goal into a `FromEnv` goal. + fn into_from_env_goal(self) -> Self; +} + +/// Used for well-formedness related rules (see rustc guide). +trait IntoWellFormedGoal { + /// Transforms an existing goal into a `WellFormed` goal. + fn into_well_formed_goal(self) -> Self; +} + +impl<'tcx> IntoFromEnvGoal for DomainGoal<'tcx> { + fn into_from_env_goal(self) -> DomainGoal<'tcx> { + use self::WhereClause::*; + + match self { + DomainGoal::Holds(Implemented(trait_ref)) => { + DomainGoal::FromEnv(FromEnv::Trait(trait_ref)) + } + other => other, + } + } +} + +impl<'tcx> IntoWellFormedGoal for DomainGoal<'tcx> { + fn into_well_formed_goal(self) -> DomainGoal<'tcx> { + use self::WhereClause::*; + + match self { + DomainGoal::Holds(Implemented(trait_ref)) => { + DomainGoal::WellFormed(WellFormed::Trait(trait_ref)) + } + other => other, + } + } +} + +crate fn program_clauses_for<'a, 'tcx>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + def_id: DefId, +) -> Clauses<'tcx> { + match tcx.def_key(def_id).disambiguated_data.data { + DefPathData::Trait(_) => program_clauses_for_trait(tcx, def_id), + DefPathData::Impl => program_clauses_for_impl(tcx, def_id), + DefPathData::AssocTypeInImpl(..) => program_clauses_for_associated_type_value(tcx, def_id), + DefPathData::AssocTypeInTrait(..) => program_clauses_for_associated_type_def(tcx, def_id), + DefPathData::TypeNs(..) => program_clauses_for_type_def(tcx, def_id), + _ => List::empty(), + } +} + +fn program_clauses_for_trait<'a, 'tcx>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + def_id: DefId, +) -> Clauses<'tcx> { + // `trait Trait where WC { .. } // P0 == Self` + + // Rule Implemented-From-Env (see rustc guide) + // + // ``` + // forall { + // Implemented(Self: Trait) :- FromEnv(Self: Trait) + // } + // ``` + + // `Self: Trait` + let trait_pred = ty::TraitPredicate { + trait_ref: ty::TraitRef::identity(tcx, def_id), + }; + + // `Implemented(Self: Trait)` + let impl_trait: DomainGoal = trait_pred.lower(); + + // `FromEnv(Self: Trait)` + let from_env_goal = tcx.mk_goal(impl_trait.into_from_env_goal().into_goal()); + let hypotheses = tcx.intern_goals(&[from_env_goal]); + + // `Implemented(Self: Trait) :- FromEnv(Self: Trait)` + let implemented_from_env = ProgramClause { + goal: impl_trait, + hypotheses, + category: ProgramClauseCategory::ImpliedBound, + }; + + let clauses = iter::once(Clause::ForAll(ty::Binder::dummy(implemented_from_env))); + + let where_clauses = &tcx.predicates_defined_on(def_id).predicates + .into_iter() + .map(|(wc, _)| wc.lower()) + .collect::>(); + + // Rule Implied-Bound-From-Trait + // + // For each where clause WC: + // ``` + // forall { + // FromEnv(WC) :- FromEnv(Self: Trait)`, for each where clause WC + let implied_bound_clauses = where_clauses + .iter() + .cloned() + + // `FromEnv(WC) :- FromEnv(Self: Trait)` + .map(|wc| wc.map_bound(|goal| ProgramClause { + goal: goal.into_from_env_goal(), + hypotheses, + category: ProgramClauseCategory::ImpliedBound, + })) + .map(Clause::ForAll); + + // Rule WellFormed-TraitRef + // + // Here `WC` denotes the set of all where clauses: + // ``` + // forall { + // WellFormed(Self: Trait) :- Implemented(Self: Trait) && WellFormed(WC) + // } + // ``` + + // `Implemented(Self: Trait) && WellFormed(WC)` + let wf_conditions = iter::once(ty::Binder::dummy(trait_pred.lower())) + .chain( + where_clauses + .into_iter() + .map(|wc| wc.map_bound(|goal| goal.into_well_formed_goal())) + ); + + // `WellFormed(Self: Trait) :- Implemented(Self: Trait) && WellFormed(WC)` + let wf_clause = ProgramClause { + goal: DomainGoal::WellFormed(WellFormed::Trait(trait_pred)), + hypotheses: tcx.mk_goals( + wf_conditions.map(|wc| tcx.mk_goal(GoalKind::from_poly_domain_goal(wc, tcx))), + ), + category: ProgramClauseCategory::WellFormed, + }; + let wf_clause = iter::once(Clause::ForAll(ty::Binder::dummy(wf_clause))); + + tcx.mk_clauses( + clauses + .chain(implied_bound_clauses) + .chain(wf_clause) + ) +} + +fn program_clauses_for_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Clauses<'tcx> { + if let ImplPolarity::Negative = tcx.impl_polarity(def_id) { + return List::empty(); + } + + // Rule Implemented-From-Impl (see rustc guide) + // + // `impl Trait for A0 where WC { .. }` + // + // ``` + // forall { + // Implemented(A0: Trait) :- WC + // } + // ``` + + let trait_ref = tcx.impl_trait_ref(def_id).expect("not an impl"); + + // `Implemented(A0: Trait)` + let trait_pred = ty::TraitPredicate { trait_ref }.lower(); + + // `WC` + let where_clauses = tcx.predicates_of(def_id).predicates + .into_iter() + .map(|(wc, _)| wc.lower()); + + // `Implemented(A0: Trait) :- WC` + let clause = ProgramClause { + goal: trait_pred, + hypotheses: tcx.mk_goals( + where_clauses + .map(|wc| tcx.mk_goal(GoalKind::from_poly_domain_goal(wc, tcx))), + ), + category: ProgramClauseCategory::Other, + }; + tcx.mk_clauses(iter::once(Clause::ForAll(ty::Binder::dummy(clause)))) +} + +pub fn program_clauses_for_type_def<'a, 'tcx>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + def_id: DefId, +) -> Clauses<'tcx> { + // Rule WellFormed-Type + // + // `struct Ty where WC1, ..., WCm` + // + // ``` + // forall { + // WellFormed(Ty<...>) :- WC1, ..., WCm` + // } + // ``` + + // `Ty<...>` + let ty = tcx.type_of(def_id); + + // `WC` + let where_clauses = tcx.predicates_of(def_id).predicates + .into_iter() + .map(|(wc, _)| wc.lower()) + .collect::>(); + + // `WellFormed(Ty<...>) :- WC1, ..., WCm` + let well_formed = ProgramClause { + goal: DomainGoal::WellFormed(WellFormed::Ty(ty)), + hypotheses: tcx.mk_goals( + where_clauses + .iter() + .cloned() + .map(|wc| tcx.mk_goal(GoalKind::from_poly_domain_goal(wc, tcx))), + ), + category: ProgramClauseCategory::WellFormed, + }; + + let well_formed_clause = iter::once(Clause::ForAll(ty::Binder::dummy(well_formed))); + + // Rule FromEnv-Type + // + // For each where clause `WC`: + // ``` + // forall { + // FromEnv(WC) :- FromEnv(Ty<...>) + // } + // ``` + + // `FromEnv(Ty<...>)` + let from_env_goal = tcx.mk_goal(DomainGoal::FromEnv(FromEnv::Ty(ty)).into_goal()); + let hypotheses = tcx.intern_goals(&[from_env_goal]); + + // For each where clause `WC`: + let from_env_clauses = where_clauses + .into_iter() + + // `FromEnv(WC) :- FromEnv(Ty<...>)` + .map(|wc| wc.map_bound(|goal| ProgramClause { + goal: goal.into_from_env_goal(), + hypotheses, + category: ProgramClauseCategory::ImpliedBound, + })) + + .map(Clause::ForAll); + + tcx.mk_clauses(well_formed_clause.chain(from_env_clauses)) +} + +pub fn program_clauses_for_associated_type_def<'a, 'tcx>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + item_id: DefId, +) -> Clauses<'tcx> { + // Rule ProjectionEq-Skolemize + // + // ``` + // trait Trait { + // type AssocType; + // } + // ``` + // + // `ProjectionEq` can succeed by skolemizing, see "associated type" + // chapter for more: + // ``` + // forall { + // ProjectionEq( + // >::AssocType = + // (Trait::AssocType) + // ) + // } + // ``` + + let item = tcx.associated_item(item_id); + debug_assert_eq!(item.kind, ty::AssociatedKind::Type); + let trait_id = match item.container { + ty::AssociatedItemContainer::TraitContainer(trait_id) => trait_id, + _ => bug!("not an trait container"), + }; + let trait_ref = ty::TraitRef::identity(tcx, trait_id); + + let projection_ty = ty::ProjectionTy::from_ref_and_name(tcx, trait_ref, item.ident); + let placeholder_ty = tcx.mk_ty(ty::UnnormalizedProjection(projection_ty)); + let projection_eq = WhereClause::ProjectionEq(ty::ProjectionPredicate { + projection_ty, + ty: placeholder_ty, + }); + + let projection_eq_clause = ProgramClause { + goal: DomainGoal::Holds(projection_eq), + hypotheses: ty::List::empty(), + category: ProgramClauseCategory::Other, + }; + + // Rule WellFormed-AssocTy + // ``` + // forall { + // WellFormed((Trait::AssocType)) + // :- Implemented(Self: Trait) + // } + // ``` + + let trait_predicate = ty::TraitPredicate { trait_ref }; + let hypothesis = tcx.mk_goal( + DomainGoal::Holds(WhereClause::Implemented(trait_predicate)).into_goal() + ); + let wf_clause = ProgramClause { + goal: DomainGoal::WellFormed(WellFormed::Ty(placeholder_ty)), + hypotheses: tcx.mk_goals(iter::once(hypothesis)), + category: ProgramClauseCategory::WellFormed, + }; + + // Rule Implied-Trait-From-AssocTy + // ``` + // forall { + // FromEnv(Self: Trait) + // :- FromEnv((Trait::AssocType)) + // } + // ``` + + let hypothesis = tcx.mk_goal( + DomainGoal::FromEnv(FromEnv::Ty(placeholder_ty)).into_goal() + ); + let from_env_clause = ProgramClause { + goal: DomainGoal::FromEnv(FromEnv::Trait(trait_predicate)), + hypotheses: tcx.mk_goals(iter::once(hypothesis)), + category: ProgramClauseCategory::ImpliedBound, + }; + + let clauses = iter::once(projection_eq_clause) + .chain(iter::once(wf_clause)) + .chain(iter::once(from_env_clause)); + let clauses = clauses.map(|clause| Clause::ForAll(ty::Binder::dummy(clause))); + tcx.mk_clauses(clauses) +} + +pub fn program_clauses_for_associated_type_value<'a, 'tcx>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + item_id: DefId, +) -> Clauses<'tcx> { + // Rule Normalize-From-Impl (see rustc guide) + // + // ``` + // impl Trait for A0 { + // type AssocType = T; + // } + // ``` + // + // FIXME: For the moment, we don't account for where clauses written on the associated + // ty definition (i.e. in the trait def, as in `type AssocType where T: Sized`). + // ``` + // forall { + // forall { + // Normalize(>::AssocType -> T) :- + // Implemented(A0: Trait) + // } + // } + // ``` + + let item = tcx.associated_item(item_id); + debug_assert_eq!(item.kind, ty::AssociatedKind::Type); + let impl_id = match item.container { + ty::AssociatedItemContainer::ImplContainer(impl_id) => impl_id, + _ => bug!("not an impl container"), + }; + + // `A0 as Trait` + let trait_ref = tcx.impl_trait_ref(impl_id).unwrap(); + + // `T` + let ty = tcx.type_of(item_id); + + // `Implemented(A0: Trait)` + let trait_implemented = ty::Binder::dummy(ty::TraitPredicate { trait_ref }.lower()); + + // `Implemented(A0: Trait)` + let hypotheses = vec![trait_implemented]; + + // `>::AssocType` + let projection_ty = ty::ProjectionTy::from_ref_and_name(tcx, trait_ref, item.ident); + + // `Normalize(>::AssocType -> T)` + let normalize_goal = DomainGoal::Normalize(ty::ProjectionPredicate { projection_ty, ty }); + + // `Normalize(... -> T) :- ...` + let clause = ProgramClause { + goal: normalize_goal, + hypotheses: tcx.mk_goals( + hypotheses + .into_iter() + .map(|wc| tcx.mk_goal(GoalKind::from_poly_domain_goal(wc, tcx))), + ), + category: ProgramClauseCategory::Other, + }; + tcx.mk_clauses(iter::once(Clause::ForAll(ty::Binder::dummy(clause)))) +} + +pub fn dump_program_clauses<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { + if !tcx.features().rustc_attrs { + return; + } + + let mut visitor = ClauseDumper { tcx }; + tcx.hir + .krate() + .visit_all_item_likes(&mut visitor.as_deep_visitor()); +} + +struct ClauseDumper<'a, 'tcx: 'a> { + tcx: TyCtxt<'a, 'tcx, 'tcx>, +} + +impl<'a, 'tcx> ClauseDumper<'a, 'tcx> { + fn process_attrs(&mut self, node_id: ast::NodeId, attrs: &[ast::Attribute]) { + let def_id = self.tcx.hir.local_def_id(node_id); + for attr in attrs { + let mut clauses = None; + + if attr.check_name("rustc_dump_program_clauses") { + clauses = Some(self.tcx.program_clauses_for(def_id)); + } + + if attr.check_name("rustc_dump_env_program_clauses") { + let environment = self.tcx.environment(def_id); + clauses = Some(self.tcx.program_clauses_for_env(environment)); + } + + if let Some(clauses) = clauses { + let mut err = self + .tcx + .sess + .struct_span_err(attr.span, "program clause dump"); + + let mut strings: Vec<_> = clauses + .iter() + .map(|clause| { + // Skip the top-level binder for a less verbose output + let program_clause = match clause { + Clause::Implies(program_clause) => program_clause, + Clause::ForAll(program_clause) => program_clause.skip_binder(), + }; + program_clause.to_string() + }) + .collect(); + + strings.sort(); + + for string in strings { + err.note(&string); + } + + err.emit(); + } + } + } +} + +impl<'a, 'tcx> Visitor<'tcx> for ClauseDumper<'a, 'tcx> { + fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { + NestedVisitorMap::OnlyBodies(&self.tcx.hir) + } + + fn visit_item(&mut self, item: &'tcx hir::Item) { + self.process_attrs(item.id, &item.attrs); + intravisit::walk_item(self, item); + } + + fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) { + self.process_attrs(trait_item.id, &trait_item.attrs); + intravisit::walk_trait_item(self, trait_item); + } + + fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) { + self.process_attrs(impl_item.id, &impl_item.attrs); + intravisit::walk_impl_item(self, impl_item); + } + + fn visit_struct_field(&mut self, s: &'tcx hir::StructField) { + self.process_attrs(s.id, &s.attrs); + intravisit::walk_struct_field(self, s); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_traits/lowering.rs rustc-1.31.0+dfsg1+llvm/src/librustc_traits/lowering.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_traits/lowering.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_traits/lowering.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,566 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use rustc::hir::def_id::DefId; -use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; -use rustc::hir::map::definitions::DefPathData; -use rustc::hir::{self, ImplPolarity}; -use rustc::traits::{ - Clause, Clauses, DomainGoal, FromEnv, Goal, PolyDomainGoal, ProgramClause, WellFormed, - WhereClause, -}; -use rustc::ty::query::Providers; -use rustc::ty::{self, List, TyCtxt}; -use rustc_data_structures::fx::FxHashSet; -use std::mem; -use syntax::ast; - -use std::iter; - -crate fn provide(p: &mut Providers) { - *p = Providers { - program_clauses_for, - program_clauses_for_env, - ..*p - }; -} - -crate trait Lower { - /// Lower a rustc construct (e.g. `ty::TraitPredicate`) to a chalk-like type. - fn lower(&self) -> T; -} - -impl Lower> for Vec -where - T: Lower, -{ - fn lower(&self) -> Vec { - self.iter().map(|item| item.lower()).collect() - } -} - -impl<'tcx> Lower> for ty::TraitPredicate<'tcx> { - fn lower(&self) -> WhereClause<'tcx> { - WhereClause::Implemented(*self) - } -} - -impl<'tcx> Lower> for ty::ProjectionPredicate<'tcx> { - fn lower(&self) -> WhereClause<'tcx> { - WhereClause::ProjectionEq(*self) - } -} - -impl<'tcx> Lower> for ty::RegionOutlivesPredicate<'tcx> { - fn lower(&self) -> WhereClause<'tcx> { - WhereClause::RegionOutlives(*self) - } -} - -impl<'tcx> Lower> for ty::TypeOutlivesPredicate<'tcx> { - fn lower(&self) -> WhereClause<'tcx> { - WhereClause::TypeOutlives(*self) - } -} - -impl<'tcx, T> Lower> for T -where - T: Lower>, -{ - fn lower(&self) -> DomainGoal<'tcx> { - DomainGoal::Holds(self.lower()) - } -} - -/// `ty::Binder` is used for wrapping a rustc construction possibly containing generic -/// lifetimes, e.g. `for<'a> T: Fn(&'a i32)`. Instead of representing higher-ranked things -/// in that leaf-form (i.e. `Holds(Implemented(Binder))` in the previous -/// example), we model them with quantified domain goals, e.g. as for the previous example: -/// `forall<'a> { T: Fn(&'a i32) }` which corresponds to something like -/// `Binder`. -impl<'tcx, T> Lower> for ty::Binder -where - T: Lower> + ty::fold::TypeFoldable<'tcx>, -{ - fn lower(&self) -> PolyDomainGoal<'tcx> { - self.map_bound_ref(|p| p.lower()) - } -} - -impl<'tcx> Lower> for ty::Predicate<'tcx> { - fn lower(&self) -> PolyDomainGoal<'tcx> { - use rustc::ty::Predicate; - - match self { - Predicate::Trait(predicate) => predicate.lower(), - Predicate::RegionOutlives(predicate) => predicate.lower(), - Predicate::TypeOutlives(predicate) => predicate.lower(), - Predicate::Projection(predicate) => predicate.lower(), - Predicate::WellFormed(ty) => { - ty::Binder::dummy(DomainGoal::WellFormed(WellFormed::Ty(*ty))) - } - Predicate::ObjectSafe(..) - | Predicate::ClosureKind(..) - | Predicate::Subtype(..) - | Predicate::ConstEvaluatable(..) => unimplemented!(), - } - } -} - -/// Used for implied bounds related rules (see rustc guide). -trait IntoFromEnvGoal { - /// Transforms an existing goal into a `FromEnv` goal. - fn into_from_env_goal(self) -> Self; -} - -/// Used for well-formedness related rules (see rustc guide). -trait IntoWellFormedGoal { - /// Transforms an existing goal into a `WellFormed` goal. - fn into_well_formed_goal(self) -> Self; -} - -impl<'tcx> IntoFromEnvGoal for DomainGoal<'tcx> { - fn into_from_env_goal(self) -> DomainGoal<'tcx> { - use self::WhereClause::*; - - match self { - DomainGoal::Holds(Implemented(trait_ref)) => { - DomainGoal::FromEnv(FromEnv::Trait(trait_ref)) - } - other => other, - } - } -} - -impl<'tcx> IntoWellFormedGoal for DomainGoal<'tcx> { - fn into_well_formed_goal(self) -> DomainGoal<'tcx> { - use self::WhereClause::*; - - match self { - DomainGoal::Holds(Implemented(trait_ref)) => { - DomainGoal::WellFormed(WellFormed::Trait(trait_ref)) - } - other => other, - } - } -} - -crate fn program_clauses_for<'a, 'tcx>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, - def_id: DefId, -) -> Clauses<'tcx> { - match tcx.def_key(def_id).disambiguated_data.data { - DefPathData::Trait(_) => program_clauses_for_trait(tcx, def_id), - DefPathData::Impl => program_clauses_for_impl(tcx, def_id), - DefPathData::AssocTypeInImpl(..) => program_clauses_for_associated_type_value(tcx, def_id), - DefPathData::AssocTypeInTrait(..) => program_clauses_for_associated_type_def(tcx, def_id), - DefPathData::TypeNs(..) => program_clauses_for_type_def(tcx, def_id), - _ => List::empty(), - } -} - -crate fn program_clauses_for_env<'a, 'tcx>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, - param_env: ty::ParamEnv<'tcx>, -) -> Clauses<'tcx> { - debug!("program_clauses_for_env(param_env={:?})", param_env); - - let mut last_round = FxHashSet(); - last_round.extend( - param_env - .caller_bounds - .iter() - .flat_map(|&p| predicate_def_id(p)), - ); - - let mut closure = last_round.clone(); - let mut next_round = FxHashSet(); - while !last_round.is_empty() { - next_round.extend( - last_round - .drain() - .flat_map(|def_id| { - tcx.predicates_of(def_id) - .instantiate_identity(tcx) - .predicates - }) - .flat_map(|p| predicate_def_id(p)) - .filter(|&def_id| closure.insert(def_id)), - ); - mem::swap(&mut next_round, &mut last_round); - } - - debug!("program_clauses_for_env: closure = {:#?}", closure); - - return tcx.mk_clauses( - closure - .into_iter() - .flat_map(|def_id| tcx.program_clauses_for(def_id).iter().cloned()), - ); - - /// Given that `predicate` is in the environment, returns the - /// def-id of something (e.g., a trait, associated item, etc) - /// whose predicates can also be assumed to be true. We will - /// compute the transitive closure of such things. - fn predicate_def_id<'tcx>(predicate: ty::Predicate<'tcx>) -> Option { - match predicate { - ty::Predicate::Trait(predicate) => Some(predicate.def_id()), - - ty::Predicate::Projection(projection) => Some(projection.item_def_id()), - - ty::Predicate::WellFormed(..) - | ty::Predicate::RegionOutlives(..) - | ty::Predicate::TypeOutlives(..) - | ty::Predicate::ObjectSafe(..) - | ty::Predicate::ClosureKind(..) - | ty::Predicate::Subtype(..) - | ty::Predicate::ConstEvaluatable(..) => None, - } - } -} - -fn program_clauses_for_trait<'a, 'tcx>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, - def_id: DefId, -) -> Clauses<'tcx> { - // `trait Trait where WC { .. } // P0 == Self` - - // Rule Implemented-From-Env (see rustc guide) - // - // ``` - // forall { - // Implemented(Self: Trait) :- FromEnv(Self: Trait) - // } - // ``` - - // `Self: Trait` - let trait_pred = ty::TraitPredicate { - trait_ref: ty::TraitRef::identity(tcx, def_id), - }; - - // `Implemented(Self: Trait)` - let impl_trait: DomainGoal = trait_pred.lower(); - - // `FromEnv(Self: Trait)` - let from_env_goal = impl_trait.into_from_env_goal().into_goal(); - let hypotheses = tcx.intern_goals(&[from_env_goal]); - - // `Implemented(Self: Trait) :- FromEnv(Self: Trait)` - let implemented_from_env = ProgramClause { - goal: impl_trait, - hypotheses, - }; - - let clauses = iter::once(Clause::ForAll(ty::Binder::dummy(implemented_from_env))); - - let where_clauses = &tcx.predicates_defined_on(def_id).predicates; - - // Rule Implied-Bound-From-Trait - // - // For each where clause WC: - // ``` - // forall { - // FromEnv(WC) :- FromEnv(Self: Trait)`, for each where clause WC - let implied_bound_clauses = where_clauses - .into_iter() - .map(|wc| wc.lower()) - - // `FromEnv(WC) :- FromEnv(Self: Trait)` - .map(|wc| wc.map_bound(|goal| ProgramClause { - goal: goal.into_from_env_goal(), - hypotheses, - })) - .map(Clause::ForAll); - - // Rule WellFormed-TraitRef - // - // Here `WC` denotes the set of all where clauses: - // ``` - // forall { - // WellFormed(Self: Trait) :- Implemented(Self: Trait) && WellFormed(WC) - // } - // ``` - - // `Implemented(Self: Trait) && WellFormed(WC)` - let wf_conditions = iter::once(ty::Binder::dummy(trait_pred.lower())) - .chain( - where_clauses - .into_iter() - .map(|wc| wc.lower()) - .map(|wc| wc.map_bound(|goal| goal.into_well_formed_goal())) - ); - - // `WellFormed(Self: Trait) :- Implemented(Self: Trait) && WellFormed(WC)` - let wf_clause = ProgramClause { - goal: DomainGoal::WellFormed(WellFormed::Trait(trait_pred)), - hypotheses: tcx.mk_goals( - wf_conditions.map(|wc| Goal::from_poly_domain_goal(wc, tcx)), - ), - }; - let wf_clause = iter::once(Clause::ForAll(ty::Binder::dummy(wf_clause))); - - tcx.mk_clauses( - clauses - .chain(implied_bound_clauses) - .chain(wf_clause) - ) -} - -fn program_clauses_for_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Clauses<'tcx> { - if let ImplPolarity::Negative = tcx.impl_polarity(def_id) { - return List::empty(); - } - - // Rule Implemented-From-Impl (see rustc guide) - // - // `impl Trait for A0 where WC { .. }` - // - // ``` - // forall { - // Implemented(A0: Trait) :- WC - // } - // ``` - - let trait_ref = tcx.impl_trait_ref(def_id).expect("not an impl"); - - // `Implemented(A0: Trait)` - let trait_pred = ty::TraitPredicate { trait_ref }.lower(); - - // `WC` - let where_clauses = tcx.predicates_of(def_id).predicates.lower(); - - // `Implemented(A0: Trait) :- WC` - let clause = ProgramClause { - goal: trait_pred, - hypotheses: tcx.mk_goals( - where_clauses - .into_iter() - .map(|wc| Goal::from_poly_domain_goal(wc, tcx)), - ), - }; - tcx.intern_clauses(&[Clause::ForAll(ty::Binder::dummy(clause))]) -} - -pub fn program_clauses_for_type_def<'a, 'tcx>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, - def_id: DefId, -) -> Clauses<'tcx> { - // Rule WellFormed-Type - // - // `struct Ty where WC1, ..., WCm` - // - // ``` - // forall { - // WellFormed(Ty<...>) :- WC1, ..., WCm` - // } - // ``` - - // `Ty<...>` - let ty = tcx.type_of(def_id); - - // `WC` - let where_clauses = tcx.predicates_of(def_id).predicates.lower(); - - // `WellFormed(Ty<...>) :- WC1, ..., WCm` - let well_formed = ProgramClause { - goal: DomainGoal::WellFormed(WellFormed::Ty(ty)), - hypotheses: tcx.mk_goals( - where_clauses - .iter() - .cloned() - .map(|wc| Goal::from_poly_domain_goal(wc, tcx)), - ), - }; - - let well_formed_clause = iter::once(Clause::ForAll(ty::Binder::dummy(well_formed))); - - // Rule FromEnv-Type - // - // For each where clause `WC`: - // ``` - // forall { - // FromEnv(WC) :- FromEnv(Ty<...>) - // } - // ``` - - // `FromEnv(Ty<...>)` - let from_env_goal = DomainGoal::FromEnv(FromEnv::Ty(ty)).into_goal(); - let hypotheses = tcx.intern_goals(&[from_env_goal]); - - // For each where clause `WC`: - let from_env_clauses = where_clauses - .into_iter() - - // `FromEnv(WC) :- FromEnv(Ty<...>)` - .map(|wc| wc.map_bound(|goal| ProgramClause { - goal: goal.into_from_env_goal(), - hypotheses, - })) - - .map(Clause::ForAll); - - tcx.mk_clauses(well_formed_clause.chain(from_env_clauses)) -} - -pub fn program_clauses_for_associated_type_def<'a, 'tcx>( - _tcx: TyCtxt<'a, 'tcx, 'tcx>, - _item_id: DefId, -) -> Clauses<'tcx> { - unimplemented!() -} - -pub fn program_clauses_for_associated_type_value<'a, 'tcx>( - tcx: TyCtxt<'a, 'tcx, 'tcx>, - item_id: DefId, -) -> Clauses<'tcx> { - // Rule Normalize-From-Impl (see rustc guide) - // - // ```impl Trait for A0 - // { - // type AssocType = T; - // }``` - // - // FIXME: For the moment, we don't account for where clauses written on the associated - // ty definition (i.e. in the trait def, as in `type AssocType where T: Sized`). - // ``` - // forall { - // forall { - // Normalize(>::AssocType -> T) :- - // Implemented(A0: Trait) - // } - // } - // ``` - - let item = tcx.associated_item(item_id); - debug_assert_eq!(item.kind, ty::AssociatedKind::Type); - let impl_id = match item.container { - ty::AssociatedItemContainer::ImplContainer(impl_id) => impl_id, - _ => bug!("not an impl container"), - }; - - // `A0 as Trait` - let trait_ref = tcx.impl_trait_ref(impl_id).unwrap(); - - // `T` - let ty = tcx.type_of(item_id); - - // `Implemented(A0: Trait)` - let trait_implemented = ty::Binder::dummy(ty::TraitPredicate { trait_ref }.lower()); - - // `Implemented(A0: Trait)` - let hypotheses = vec![trait_implemented]; - - // `>::AssocType` - let projection_ty = ty::ProjectionTy::from_ref_and_name(tcx, trait_ref, item.ident); - - // `Normalize(>::AssocType -> T)` - let normalize_goal = DomainGoal::Normalize(ty::ProjectionPredicate { projection_ty, ty }); - - // `Normalize(... -> T) :- ...` - let clause = ProgramClause { - goal: normalize_goal, - hypotheses: tcx.mk_goals( - hypotheses - .into_iter() - .map(|wc| Goal::from_poly_domain_goal(wc, tcx)), - ), - }; - tcx.intern_clauses(&[Clause::ForAll(ty::Binder::dummy(clause))]) -} - -pub fn dump_program_clauses<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { - if !tcx.features().rustc_attrs { - return; - } - - let mut visitor = ClauseDumper { tcx }; - tcx.hir - .krate() - .visit_all_item_likes(&mut visitor.as_deep_visitor()); -} - -struct ClauseDumper<'a, 'tcx: 'a> { - tcx: TyCtxt<'a, 'tcx, 'tcx>, -} - -impl<'a, 'tcx> ClauseDumper<'a, 'tcx> { - fn process_attrs(&mut self, node_id: ast::NodeId, attrs: &[ast::Attribute]) { - let def_id = self.tcx.hir.local_def_id(node_id); - for attr in attrs { - let mut clauses = None; - - if attr.check_name("rustc_dump_program_clauses") { - clauses = Some(self.tcx.program_clauses_for(def_id)); - } - - if attr.check_name("rustc_dump_env_program_clauses") { - let param_env = self.tcx.param_env(def_id); - clauses = Some(self.tcx.program_clauses_for_env(param_env)); - } - - if let Some(clauses) = clauses { - let mut err = self - .tcx - .sess - .struct_span_err(attr.span, "program clause dump"); - - let mut strings: Vec<_> = clauses - .iter() - .map(|clause| { - // Skip the top-level binder for a less verbose output - let program_clause = match clause { - Clause::Implies(program_clause) => program_clause, - Clause::ForAll(program_clause) => program_clause.skip_binder(), - }; - program_clause.to_string() - }) - .collect(); - - strings.sort(); - - for string in strings { - err.note(&string); - } - - err.emit(); - } - } - } -} - -impl<'a, 'tcx> Visitor<'tcx> for ClauseDumper<'a, 'tcx> { - fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { - NestedVisitorMap::OnlyBodies(&self.tcx.hir) - } - - fn visit_item(&mut self, item: &'tcx hir::Item) { - self.process_attrs(item.id, &item.attrs); - intravisit::walk_item(self, item); - } - - fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) { - self.process_attrs(trait_item.id, &trait_item.attrs); - intravisit::walk_trait_item(self, trait_item); - } - - fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) { - self.process_attrs(impl_item.id, &impl_item.attrs); - intravisit::walk_impl_item(self, impl_item); - } - - fn visit_struct_field(&mut self, s: &'tcx hir::StructField) { - self.process_attrs(s.id, &s.attrs); - intravisit::walk_struct_field(self, s); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_traits/normalize_projection_ty.rs rustc-1.31.0+dfsg1+llvm/src/librustc_traits/normalize_projection_ty.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_traits/normalize_projection_ty.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_traits/normalize_projection_ty.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rustc::infer::canonical::{Canonical, QueryResult}; +use rustc::infer::canonical::{Canonical, QueryResponse}; use rustc::traits::query::{normalize::NormalizationResult, CanonicalProjectionGoal, NoSolution}; use rustc::traits::{self, ObligationCause, SelectionContext, TraitEngineExt}; use rustc::ty::query::Providers; @@ -28,7 +28,7 @@ fn normalize_projection_ty<'tcx>( tcx: TyCtxt<'_, 'tcx, 'tcx>, goal: CanonicalProjectionGoal<'tcx>, -) -> Result>>>, NoSolution> { +) -> Result>>>, NoSolution> { debug!("normalize_provider(goal={:#?})", goal); tcx.sess diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_traits/type_op.rs rustc-1.31.0+dfsg1+llvm/src/librustc_traits/type_op.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_traits/type_op.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_traits/type_op.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,22 +8,34 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rustc::infer::canonical::{Canonical, QueryResult}; +use rustc::infer::at::ToTrace; +use rustc::infer::canonical::{Canonical, QueryResponse}; use rustc::infer::InferCtxt; +use rustc::hir::def_id::DefId; +use rustc::mir::ProjectionKind; +use rustc::mir::tcx::PlaceTy; +use rustc::traits::query::type_op::ascribe_user_type::AscribeUserType; use rustc::traits::query::type_op::eq::Eq; use rustc::traits::query::type_op::normalize::Normalize; use rustc::traits::query::type_op::prove_predicate::ProvePredicate; use rustc::traits::query::type_op::subtype::Subtype; use rustc::traits::query::{Fallible, NoSolution}; -use rustc::traits::{FulfillmentContext, Normalized, Obligation, ObligationCause, TraitEngine, - TraitEngineExt}; +use rustc::traits::{ + FulfillmentContext, Normalized, Obligation, ObligationCause, TraitEngine, TraitEngineExt, +}; use rustc::ty::query::Providers; -use rustc::ty::{FnSig, Lift, ParamEnvAnd, PolyFnSig, Predicate, Ty, TyCtxt, TypeFoldable}; +use rustc::ty::subst::{Kind, Subst, UserSelfTy, UserSubsts}; +use rustc::ty::{ + FnSig, Lift, ParamEnv, ParamEnvAnd, PolyFnSig, Predicate, Ty, TyCtxt, TypeFoldable, Variance, +}; use rustc_data_structures::sync::Lrc; use std::fmt; +use syntax::ast; +use syntax_pos::DUMMY_SP; crate fn provide(p: &mut Providers) { *p = Providers { + type_op_ascribe_user_type, type_op_eq, type_op_prove_predicate, type_op_subtype, @@ -35,10 +47,188 @@ }; } +fn type_op_ascribe_user_type<'tcx>( + tcx: TyCtxt<'_, 'tcx, 'tcx>, + canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, AscribeUserType<'tcx>>>, +) -> Result>>, NoSolution> { + tcx.infer_ctxt() + .enter_canonical_trait_query(&canonicalized, |infcx, fulfill_cx, key| { + let ( + param_env, + AscribeUserType { + mir_ty, + variance, + def_id, + user_substs, + projs, + }, + ) = key.into_parts(); + + debug!( + "type_op_ascribe_user_type(\ + mir_ty={:?}, variance={:?}, def_id={:?}, user_substs={:?}, projs={:?}\ + )", + mir_ty, variance, def_id, user_substs, projs, + ); + + let mut cx = AscribeUserTypeCx { + infcx, + param_env, + fulfill_cx, + }; + cx.relate_mir_and_user_ty(mir_ty, variance, def_id, user_substs, projs)?; + + Ok(()) + }) +} + +struct AscribeUserTypeCx<'me, 'gcx: 'tcx, 'tcx: 'me> { + infcx: &'me InferCtxt<'me, 'gcx, 'tcx>, + param_env: ParamEnv<'tcx>, + fulfill_cx: &'me mut FulfillmentContext<'tcx>, +} + +impl AscribeUserTypeCx<'me, 'gcx, 'tcx> { + fn normalize(&mut self, value: T) -> T + where + T: TypeFoldable<'tcx>, + { + self.infcx + .partially_normalize_associated_types_in( + DUMMY_SP, + ast::CRATE_NODE_ID, + self.param_env, + &value, + ) + .into_value_registering_obligations(self.infcx, self.fulfill_cx) + } + + fn relate(&mut self, a: T, variance: Variance, b: T) -> Result<(), NoSolution> + where + T: ToTrace<'tcx>, + { + Ok(self.infcx + .at(&ObligationCause::dummy(), self.param_env) + .relate(a, variance, b)? + .into_value_registering_obligations(self.infcx, self.fulfill_cx)) + } + + fn prove_predicate(&mut self, predicate: Predicate<'tcx>) { + self.fulfill_cx.register_predicate_obligation( + self.infcx, + Obligation::new(ObligationCause::dummy(), self.param_env, predicate), + ); + } + + fn tcx(&self) -> TyCtxt<'me, 'gcx, 'tcx> { + self.infcx.tcx + } + + fn subst(&self, value: T, substs: &[Kind<'tcx>]) -> T + where + T: TypeFoldable<'tcx>, + { + value.subst(self.tcx(), substs) + } + + fn relate_mir_and_user_ty( + &mut self, + mir_ty: Ty<'tcx>, + variance: Variance, + def_id: DefId, + user_substs: UserSubsts<'tcx>, + projs: &[ProjectionKind<'tcx>], + ) -> Result<(), NoSolution> { + let UserSubsts { + substs, + user_self_ty, + } = user_substs; + + let tcx = self.tcx(); + + let ty = tcx.type_of(def_id); + let ty = self.subst(ty, substs); + debug!("relate_type_and_user_type: ty of def-id is {:?}", ty); + let ty = self.normalize(ty); + + // We need to follow any provided projetions into the type. + // + // if we hit a ty var as we descend, then just skip the + // attempt to relate the mir local with any type. + + struct HitTyVar; + let mut curr_projected_ty: Result; + curr_projected_ty = Ok(PlaceTy::from_ty(ty)); + for proj in projs { + let projected_ty = if let Ok(projected_ty) = curr_projected_ty { + projected_ty + } else { + break; + }; + curr_projected_ty = projected_ty.projection_ty_core( + tcx, proj, |this, field, &()| { + if this.to_ty(tcx).is_ty_var() { + Err(HitTyVar) + } else { + let ty = this.field_ty(tcx, field); + Ok(self.normalize(ty)) + } + }); + } + + if let Ok(projected_ty) = curr_projected_ty { + let ty = projected_ty.to_ty(tcx); + self.relate(mir_ty, variance, ty)?; + } + + if let Some(UserSelfTy { + impl_def_id, + self_ty, + }) = user_self_ty + { + let impl_self_ty = self.tcx().type_of(impl_def_id); + let impl_self_ty = self.subst(impl_self_ty, &substs); + let impl_self_ty = self.normalize(impl_self_ty); + + self.relate(self_ty, Variance::Invariant, impl_self_ty)?; + + self.prove_predicate(Predicate::WellFormed(impl_self_ty)); + } + + // Prove the predicates coming along with `def_id`. + // + // Also, normalize the `instantiated_predicates` + // because otherwise we wind up with duplicate "type + // outlives" error messages. + let instantiated_predicates = self.tcx() + .predicates_of(def_id) + .instantiate(self.tcx(), substs); + for instantiated_predicate in instantiated_predicates.predicates { + let instantiated_predicate = self.normalize(instantiated_predicate); + self.prove_predicate(instantiated_predicate); + } + + // In addition to proving the predicates, we have to + // prove that `ty` is well-formed -- this is because + // the WF of `ty` is predicated on the substs being + // well-formed, and we haven't proven *that*. We don't + // want to prove the WF of types from `substs` directly because they + // haven't been normalized. + // + // FIXME(nmatsakis): Well, perhaps we should normalize + // them? This would only be relevant if some input + // type were ill-formed but did not appear in `ty`, + // which...could happen with normalization... + self.prove_predicate(Predicate::WellFormed(ty)); + + Ok(()) + } +} + fn type_op_eq<'tcx>( tcx: TyCtxt<'_, 'tcx, 'tcx>, canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Eq<'tcx>>>, -) -> Result>>, NoSolution> { +) -> Result>>, NoSolution> { tcx.infer_ctxt() .enter_canonical_trait_query(&canonicalized, |infcx, fulfill_cx, key| { let (param_env, Eq { a, b }) = key.into_parts(); @@ -68,7 +258,7 @@ fn type_op_normalize_ty( tcx: TyCtxt<'_, 'tcx, 'tcx>, canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize>>>, -) -> Result>>>, NoSolution> { +) -> Result>>>, NoSolution> { tcx.infer_ctxt() .enter_canonical_trait_query(&canonicalized, type_op_normalize) } @@ -76,7 +266,7 @@ fn type_op_normalize_predicate( tcx: TyCtxt<'_, 'tcx, 'tcx>, canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize>>>, -) -> Result>>>, NoSolution> { +) -> Result>>>, NoSolution> { tcx.infer_ctxt() .enter_canonical_trait_query(&canonicalized, type_op_normalize) } @@ -84,7 +274,7 @@ fn type_op_normalize_fn_sig( tcx: TyCtxt<'_, 'tcx, 'tcx>, canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize>>>, -) -> Result>>>, NoSolution> { +) -> Result>>>, NoSolution> { tcx.infer_ctxt() .enter_canonical_trait_query(&canonicalized, type_op_normalize) } @@ -92,7 +282,7 @@ fn type_op_normalize_poly_fn_sig( tcx: TyCtxt<'_, 'tcx, 'tcx>, canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize>>>, -) -> Result>>>, NoSolution> { +) -> Result>>>, NoSolution> { tcx.infer_ctxt() .enter_canonical_trait_query(&canonicalized, type_op_normalize) } @@ -100,7 +290,7 @@ fn type_op_subtype<'tcx>( tcx: TyCtxt<'_, 'tcx, 'tcx>, canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Subtype<'tcx>>>, -) -> Result>>, NoSolution> { +) -> Result>>, NoSolution> { tcx.infer_ctxt() .enter_canonical_trait_query(&canonicalized, |infcx, fulfill_cx, key| { let (param_env, Subtype { sub, sup }) = key.into_parts(); @@ -114,7 +304,7 @@ fn type_op_prove_predicate<'tcx>( tcx: TyCtxt<'_, 'tcx, 'tcx>, canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, ProvePredicate<'tcx>>>, -) -> Result>>, NoSolution> { +) -> Result>>, NoSolution> { tcx.infer_ctxt() .enter_canonical_trait_query(&canonicalized, |infcx, fulfill_cx, key| { let (param_env, ProvePredicate { predicate }) = key.into_parts(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_tsan/build.rs rustc-1.31.0+dfsg1+llvm/src/librustc_tsan/build.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_tsan/build.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_tsan/build.rs 2018-12-04 23:41:40.000000000 +0000 @@ -31,6 +31,7 @@ .out_dir(&native.out_dir) .build_target(&target) .build(); + native.fixup_sanitizer_lib_name("tsan"); } println!("cargo:rerun-if-env-changed=LLVM_CONFIG"); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_tsan/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_tsan/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_tsan/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_tsan/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,8 +10,7 @@ #![sanitizer_runtime] #![feature(alloc_system)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(sanitizer_runtime)] #![feature(staged_api)] #![no_std] diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/astconv.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/astconv.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/astconv.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/astconv.rs 2018-12-04 23:41:40.000000000 +0000 @@ -30,7 +30,7 @@ use require_c_abi_if_variadic; use util::common::ErrorReported; use util::nodemap::FxHashMap; -use errors::{FatalError, DiagnosticId}; +use errors::{Applicability, FatalError, DiagnosticId}; use lint; use std::iter; @@ -147,7 +147,7 @@ bound_region: ty::BrNamed(id, name) })) - // (*) -- not late-bound, won't change + // (*) -- not late-bound, won't change } None => { @@ -167,8 +167,8 @@ }; debug!("ast_region_to_region(lifetime={:?}) yields {:?}", - lifetime, - r); + lifetime, + r); r } @@ -218,7 +218,7 @@ span, E0632, "cannot provide explicit type parameters when `impl Trait` is \ - used in argument position." + used in argument position." }; err.emit(); @@ -402,21 +402,44 @@ } /// Creates the relevant generic argument substitutions - /// corresponding to a set of generic parameters. - pub fn create_substs_for_generic_args<'a, 'b, A, P, I>( + /// corresponding to a set of generic parameters. This is a + /// rather complex little function. Let me try to explain the + /// role of each of its parameters: + /// + /// To start, we are given the `def_id` of the thing we are + /// creating the substitutions for, and a partial set of + /// substitutions `parent_substs`. In general, the substitutions + /// for an item begin with substitutions for all the "parents" of + /// that item -- so e.g. for a method it might include the + /// parameters from the impl. + /// + /// Therefore, the method begins by walking down these parents, + /// starting with the outermost parent and proceed inwards until + /// it reaches `def_id`. For each parent P, it will check `parent_substs` + /// first to see if the parent's substitutions are listed in there. If so, + /// we can append those and move on. Otherwise, it invokes the + /// three callback functions: + /// + /// - `args_for_def_id`: given the def-id P, supplies back the + /// generic arguments that were given to that parent from within + /// the path; so e.g. if you have `::Bar`, the def-id + /// might refer to the trait `Foo`, and the arguments might be + /// `[T]`. The boolean value indicates whether to infer values + /// for arguments whose values were not explicitly provided. + /// - `provided_kind`: given the generic parameter and the value from `args_for_def_id`, + /// instantiate a `Kind` + /// - `inferred_kind`: if no parameter was provided, and inference is enabled, then + /// creates a suitable inference variable. + pub fn create_substs_for_generic_args<'a, 'b>( tcx: TyCtxt<'a, 'gcx, 'tcx>, def_id: DefId, parent_substs: &[Kind<'tcx>], has_self: bool, self_ty: Option>, - args_for_def_id: A, - provided_kind: P, - inferred_kind: I, - ) -> &'tcx Substs<'tcx> where - A: Fn(DefId) -> (Option<&'b GenericArgs>, bool), - P: Fn(&GenericParamDef, &GenericArg) -> Kind<'tcx>, - I: Fn(Option<&[Kind<'tcx>]>, &GenericParamDef, bool) -> Kind<'tcx> - { + args_for_def_id: impl Fn(DefId) -> (Option<&'b GenericArgs>, bool), + provided_kind: impl Fn(&GenericParamDef, &GenericArg) -> Kind<'tcx>, + inferred_kind: impl Fn(Option<&[Kind<'tcx>]>, &GenericParamDef, bool) -> Kind<'tcx>, + ) -> &'tcx Substs<'tcx> { // Collect the segments of the path: we need to substitute arguments // for parameters throughout the entire path (wherever there are // generic parameters). @@ -538,7 +561,7 @@ // region with the current anon region binding (in other words, // whatever & would get replaced with). debug!("create_substs_for_ast_path(def_id={:?}, self_ty={:?}, \ - generic_args={:?})", + generic_args={:?})", def_id, self_ty, generic_args); let tcx = self.tcx(); @@ -609,7 +632,7 @@ if default_needs_object_self(param) { struct_span_err!(tcx.sess, span, E0393, "the type parameter `{}` must be explicitly \ - specified", + specified", param.name) .span_label(span, format!("missing reference to `{}`", param.name)) @@ -623,7 +646,7 @@ self.normalize_ty( span, tcx.at(span).type_of(param.def_id) - .subst_spanned(tcx, substs.unwrap(), Some(span)) + .subst_spanned(tcx, substs.unwrap(), Some(span)) ).into() } } else if infer_types { @@ -693,7 +716,7 @@ pub(super) fn instantiate_poly_trait_ref_inner(&self, trait_ref: &hir::TraitRef, self_ty: Ty<'tcx>, - poly_projections: &mut Vec>, + poly_projections: &mut Vec<(ty::PolyProjectionPredicate<'tcx>, Span)>, speculative: bool) -> ty::PolyTraitRef<'tcx> { @@ -716,7 +739,8 @@ let predicate: Result<_, ErrorReported> = self.ast_type_binding_to_poly_projection_predicate( trait_ref.ref_id, poly_trait_ref, binding, speculative, &mut dup_bindings); - predicate.ok() // ok to ignore Err() because ErrorReported (see above) + // ok to ignore Err() because ErrorReported (see above) + Some((predicate.ok()?, binding.span)) })); debug!("ast_path_to_poly_trait_ref({:?}, projections={:?}) -> {:?}", @@ -727,7 +751,7 @@ pub fn instantiate_poly_trait_ref(&self, poly_trait_ref: &hir::PolyTraitRef, self_ty: Ty<'tcx>, - poly_projections: &mut Vec>) + poly_projections: &mut Vec<(ty::PolyProjectionPredicate<'tcx>, Span)>) -> ty::PolyTraitRef<'tcx> { self.instantiate_poly_trait_ref_inner(&poly_trait_ref.trait_ref, self_ty, @@ -850,7 +874,7 @@ binding.span, E0582, "binding for associated type `{}` references lifetime `{}`, \ - which does not appear in the trait input types", + which does not appear in the trait input types", binding.item_name, br_name) .emit(); } @@ -890,7 +914,7 @@ ref_id, binding.span, &format!("associated type binding `{}` specified more than once", - binding.item_name) + binding.item_name) ); err.span_label(binding.span, "used more than once"); err.span_label(*prev_span, format!("first use of `{}`", binding.item_name)); @@ -974,7 +998,7 @@ let existential_principal = principal.map_bound(|trait_ref| { self.trait_ref_to_existential(trait_ref) }); - let existential_projections = projection_bounds.iter().map(|bound| { + let existential_projections = projection_bounds.iter().map(|(bound, _)| { bound.map_bound(|b| { let trait_ref = self.trait_ref_to_existential(b.projection_ty.trait_ref(tcx)); ty::ExistentialProjection { @@ -993,7 +1017,7 @@ if !object_safety_violations.is_empty() { tcx.report_object_safety_error( span, principal.def_id(), object_safety_violations) - .emit(); + .emit(); return tcx.types.err; } @@ -1006,20 +1030,20 @@ .map(|item| item.def_id)); } - for projection_bound in &projection_bounds { + for (projection_bound, _) in &projection_bounds { associated_types.remove(&projection_bound.projection_def_id()); } for item_def_id in associated_types { let assoc_item = tcx.associated_item(item_def_id); let trait_def_id = assoc_item.container.id(); - struct_span_err!(tcx.sess, span, E0191, - "the value of the associated type `{}` (from the trait `{}`) must be specified", - assoc_item.ident, - tcx.item_path_str(trait_def_id)) - .span_label(span, format!( - "missing associated type `{}` value", assoc_item.ident)) - .emit(); + struct_span_err!(tcx.sess, span, E0191, "the value of the associated type `{}` \ + (from the trait `{}`) must be specified", + assoc_item.ident, + tcx.item_path_str(trait_def_id)) + .span_label(span, format!("missing associated type `{}` value", + assoc_item.ident)) + .emit(); } // Dedup auto traits so that `dyn Trait + Send + Send` is the same as `dyn Trait + Send`. @@ -1031,12 +1055,11 @@ iter::once(ty::ExistentialPredicate::Trait(*existential_principal.skip_binder())) .chain(auto_traits.into_iter().map(ty::ExistentialPredicate::AutoTrait)) .chain(existential_projections - .map(|x| ty::ExistentialPredicate::Projection(*x.skip_binder()))) + .map(|x| ty::ExistentialPredicate::Projection(*x.skip_binder()))) .collect::>(); v.sort_by(|a, b| a.stable_cmp(tcx, b)); let existential_predicates = ty::Binder::bind(tcx.mk_existential_predicates(v.into_iter())); - // Explicitly specified region bound. Use that. let region_bound = if !lifetime.is_elided() { self.ast_region_to_region(lifetime, None) @@ -1069,11 +1092,12 @@ trait_str: &str, name: &str) { struct_span_err!(self.tcx().sess, span, E0223, "ambiguous associated type") - .span_label(span, "ambiguous associated type") - .note(&format!("specify the type using the syntax `<{} as {}>::{}`", - type_str, trait_str, name)) - .emit(); - + .span_suggestion_with_applicability( + span, + "use fully-qualified syntax", + format!("<{} as {}>::{}", type_str, trait_str, name), + Applicability::HasPlaceholders + ).emit(); } // Search for a bound on a type parameter which includes the associated item @@ -1089,12 +1113,11 @@ let tcx = self.tcx(); let bounds: Vec<_> = self.get_type_parameter_bounds(span, ty_param_def_id) - .predicates.into_iter().filter_map(|p| p.to_opt_poly_trait_ref()).collect(); + .predicates.into_iter().filter_map(|(p, _)| p.to_opt_poly_trait_ref()).collect(); // Check that there is exactly one way to find an associated type with the // correct name. - let suitable_bounds = - traits::transitive_bounds(tcx, &bounds) + let suitable_bounds = traits::transitive_bounds(tcx, &bounds) .filter(|b| self.trait_defines_associated_type_named(b.def_id(), assoc_name)); let param_node_id = tcx.hir.as_local_node_id(ty_param_def_id).unwrap(); @@ -1109,10 +1132,10 @@ // Checks that bounds contains exactly one element and reports appropriate // errors otherwise. fn one_bound_for_assoc_type(&self, - mut bounds: I, - ty_param_name: &str, - assoc_name: ast::Ident, - span: Span) + mut bounds: I, + ty_param_name: &str, + assoc_name: ast::Ident, + span: Span) -> Result, ErrorReported> where I: Iterator> { @@ -1120,9 +1143,9 @@ Some(bound) => bound, None => { struct_span_err!(self.tcx().sess, span, E0220, - "associated type `{}` not found for `{}`", - assoc_name, - ty_param_name) + "associated type `{}` not found for `{}`", + assoc_name, + ty_param_name) .span_label(span, format!("associated type `{}` not found", assoc_name)) .emit(); return Err(ErrorReported); @@ -1141,14 +1164,14 @@ for bound in bounds { let bound_span = self.tcx().associated_items(bound.def_id()).find(|item| { item.kind == ty::AssociatedKind::Type && - self.tcx().hygienic_eq(assoc_name, item.ident, bound.def_id()) + self.tcx().hygienic_eq(assoc_name, item.ident, bound.def_id()) }) .and_then(|item| self.tcx().hir.span_if_local(item.def_id)); if let Some(span) = bound_span { err.span_label(span, format!("ambiguous `{}` from `{}`", - assoc_name, - bound)); + assoc_name, + bound)); } else { span_note!(&mut err, span, "associated type `{}` could derive from `{}`", @@ -1197,8 +1220,7 @@ } }; - let candidates = - traits::supertraits(tcx, ty::Binder::bind(trait_ref)) + let candidates = traits::supertraits(tcx, ty::Binder::bind(trait_ref)) .filter(|r| self.trait_defines_associated_type_named(r.def_id(), assoc_name)); match self.one_bound_for_assoc_type(candidates, "Self", assoc_name, span) { @@ -1229,7 +1251,7 @@ let (assoc_ident, def_scope) = tcx.adjust_ident(assoc_name, trait_did, ref_id); let item = tcx.associated_items(trait_did).find(|i| { Namespace::from(i.kind) == Namespace::Type && - i.ident.modern() == assoc_ident + i.ident.modern() == assoc_ident }) .expect("missing associated type"); @@ -1292,8 +1314,7 @@ if err_for_lt { continue } err_for_lt = true; (struct_span_err!(self.tcx().sess, lt.span, E0110, - "lifetime parameters are not allowed on \ - this type"), + "lifetime parameters are not allowed on this type"), lt.span, "lifetime") } @@ -1301,7 +1322,7 @@ if err_for_ty { continue } err_for_ty = true; (struct_span_err!(self.tcx().sess, ty.span, E0109, - "type parameters are not allowed on this type"), + "type parameters are not allowed on this type"), ty.span, "type") } @@ -1341,10 +1362,7 @@ match path.def { Def::Existential(did) => { // check for desugared impl trait - if ty::is_impl_trait_defn(tcx, did).is_some() { - let lifetimes = &path.segments[0].args.as_ref().unwrap().args; - return self.impl_trait_ty_to_ty(did, lifetimes); - } + assert!(ty::is_impl_trait_defn(tcx, did).is_none()); let item_segment = path.segments.split_last().unwrap(); self.prohibit_generics(item_segment.1); let substs = self.ast_path_substs_for_ty(span, did, item_segment.0); @@ -1465,6 +1483,10 @@ }); self.def_to_ty(opt_self_ty, path, false) } + hir::TyKind::Def(item_id, ref lifetimes) => { + let did = tcx.hir.local_def_id(item_id.id); + self.impl_trait_ty_to_ty(did, lifetimes) + }, hir::TyKind::Path(hir::QPath::TypeRelative(ref qself, ref segment)) => { debug!("ast_ty_to_ty: qself={:?} segment={:?}", qself, segment); let ty = self.ast_ty_to_ty(qself); @@ -1570,8 +1592,8 @@ debug!("ty_of_fn"); let tcx = self.tcx(); - let input_tys: Vec = - decl.inputs.iter().map(|a| self.ty_of_arg(a, None)).collect(); + let input_tys = + decl.inputs.iter().map(|a| self.ty_of_arg(a, None)); let output_ty = match decl.output { hir::Return(ref output) => self.ast_ty_to_ty(output), @@ -1581,7 +1603,7 @@ debug!("ty_of_fn: output_ty={:?}", output_ty); let bare_fn_ty = ty::Binder::bind(tcx.mk_fn_sig( - input_tys.into_iter(), + input_tys, output_ty, decl.variadic, unsafety, @@ -1589,7 +1611,7 @@ )); // Find any late-bound regions declared in return type that do - // not appear in the arguments. These are not wellformed. + // not appear in the arguments. These are not well-formed. // // Example: // for<'a> fn() -> &'a str <-- 'a is bad @@ -1701,42 +1723,41 @@ // and return from functions in multiple places. #[derive(PartialEq, Eq, Clone, Debug)] pub struct Bounds<'tcx> { - pub region_bounds: Vec>, - pub implicitly_sized: bool, - pub trait_bounds: Vec>, - pub projection_bounds: Vec>, + pub region_bounds: Vec<(ty::Region<'tcx>, Span)>, + pub implicitly_sized: Option, + pub trait_bounds: Vec<(ty::PolyTraitRef<'tcx>, Span)>, + pub projection_bounds: Vec<(ty::PolyProjectionPredicate<'tcx>, Span)>, } impl<'a, 'gcx, 'tcx> Bounds<'tcx> { pub fn predicates(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, param_ty: Ty<'tcx>) - -> Vec> + -> Vec<(ty::Predicate<'tcx>, Span)> { // If it could be sized, and is, add the sized predicate - let sized_predicate = if self.implicitly_sized { + let sized_predicate = self.implicitly_sized.and_then(|span| { tcx.lang_items().sized_trait().map(|sized| { let trait_ref = ty::TraitRef { def_id: sized, substs: tcx.mk_substs_trait(param_ty, &[]) }; - trait_ref.to_predicate() + (trait_ref.to_predicate(), span) }) - } else { - None - }; + }); sized_predicate.into_iter().chain( - self.region_bounds.iter().map(|®ion_bound| { + self.region_bounds.iter().map(|&(region_bound, span)| { // account for the binder being introduced below; no need to shift `param_ty` // because, at present at least, it can only refer to early-bound regions let region_bound = tcx.mk_region(ty::fold::shift_region(*region_bound, 1)); - ty::Binder::dummy(ty::OutlivesPredicate(param_ty, region_bound)).to_predicate() + let outlives = ty::OutlivesPredicate(param_ty, region_bound); + (ty::Binder::dummy(outlives).to_predicate(), span) }).chain( - self.trait_bounds.iter().map(|bound_trait_ref| { - bound_trait_ref.to_predicate() + self.trait_bounds.iter().map(|&(bound_trait_ref, span)| { + (bound_trait_ref.to_predicate(), span) }) ).chain( - self.projection_bounds.iter().map(|projection| { - projection.to_predicate() + self.projection_bounds.iter().map(|&(projection, span)| { + (projection.to_predicate(), span) }) ) ).collect() diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/autoderef.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/autoderef.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/autoderef.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/autoderef.rs 2018-12-04 23:41:40.000000000 +0000 @@ -61,7 +61,7 @@ let suggested_limit = *tcx.sess.recursion_limit.get() * 2; let msg = format!("reached the recursion limit while auto-dereferencing {:?}", self.cur_ty); - let error_id = (DiagnosticMessageId::ErrorId(55), Some(self.span), msg.clone()); + let error_id = (DiagnosticMessageId::ErrorId(55), Some(self.span), msg); let fresh = tcx.sess.one_time_diagnostics.borrow_mut().insert(error_id); if fresh { struct_span_err!(tcx.sess, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/callee.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/callee.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/callee.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/callee.rs 2018-12-04 23:41:40.000000000 +0000 @@ -166,34 +166,31 @@ None => continue, }; - match self.lookup_method_in_trait(call_expr.span, - method_name, - trait_def_id, - adjusted_ty, - None) { - None => continue, - Some(ok) => { - let method = self.register_infer_ok_obligations(ok); - let mut autoref = None; - if borrow { - if let ty::Ref(region, _, mutbl) = method.sig.inputs()[0].sty { - let mutbl = match 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: AllowTwoPhase::No, - } - }; - autoref = Some(Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)), - target: method.sig.inputs()[0] - }); - } + if let Some(ok) = self.lookup_method_in_trait(call_expr.span, + method_name, + trait_def_id, + adjusted_ty, + None) { + let method = self.register_infer_ok_obligations(ok); + let mut autoref = None; + if borrow { + if let ty::Ref(region, _, mutbl) = method.sig.inputs()[0].sty { + let mutbl = match 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: AllowTwoPhase::No, + } + }; + autoref = Some(Adjustment { + kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)), + target: method.sig.inputs()[0] + }); } - return Some((autoref, method)); } + return Some((autoref, method)); } } @@ -238,7 +235,7 @@ err.span_suggestion_with_applicability( call_expr.span, &format!("`{}` is a unit variant, you need to write it \ - without the parenthesis", path), + without the parenthesis", path), path.to_string(), Applicability::MachineApplicable ); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/cast.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/cast.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/cast.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/cast.rs 2018-12-04 23:41:40.000000000 +0000 @@ -40,7 +40,7 @@ use super::FnCtxt; -use errors::DiagnosticBuilder; +use errors::{DiagnosticBuilder,Applicability}; use hir::def_id::DefId; use lint; use rustc::hir; @@ -73,7 +73,7 @@ /// No metadata attached, ie pointer to sized type or foreign type Thin, /// A trait object - Vtable(Option), + Vtable(DefId), /// Slice Length, /// The unsize info of this projection @@ -105,7 +105,7 @@ Ok(match t.sty { ty::Slice(_) | ty::Str => Some(PointerKind::Length), ty::Dynamic(ref tty, ..) => - Some(PointerKind::Vtable(tty.principal().map(|p| p.def_id()))), + Some(PointerKind::Vtable(tty.principal().def_id())), ty::Adt(def, substs) if def.is_struct() => { match def.non_enum_variant().fields.last() { None => Some(PointerKind::Thin), @@ -124,6 +124,7 @@ ty::Foreign(..) => Some(PointerKind::Thin), // We should really try to normalize here. ty::Projection(ref pi) => Some(PointerKind::OfProjection(pi)), + ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"), ty::Opaque(def_id, substs) => Some(PointerKind::OfOpaque(def_id, substs)), ty::Param(ref p) => Some(PointerKind::OfParam(p)), // Insufficient type information. @@ -219,11 +220,11 @@ let cast_ty = fcx.ty_to_string(self.cast_ty); err.span_label(error_span, format!("cannot cast `{}` as `{}`", - fcx.ty_to_string(self.expr_ty), - cast_ty)); + fcx.ty_to_string(self.expr_ty), + cast_ty)); if let Ok(snippet) = fcx.sess().source_map().span_to_snippet(self.expr.span) { err.span_help(self.expr.span, - &format!("did you mean `*{}`?", snippet)); + &format!("did you mean `*{}`?", snippet)); } err.emit(); } @@ -267,16 +268,16 @@ } CastError::CastToChar => { type_error_struct!(fcx.tcx.sess, self.span, self.expr_ty, E0604, - "only `u8` can be cast as `char`, not `{}`", self.expr_ty).emit(); + "only `u8` can be cast as `char`, not `{}`", self.expr_ty).emit(); } CastError::NonScalar => { type_error_struct!(fcx.tcx.sess, self.span, self.expr_ty, E0605, - "non-primitive cast: `{}` as `{}`", - self.expr_ty, - fcx.ty_to_string(self.cast_ty)) - .note("an `as` expression can only be used to convert between \ - primitive types. Consider using the `From` trait") - .emit(); + "non-primitive cast: `{}` as `{}`", + self.expr_ty, + fcx.ty_to_string(self.cast_ty)) + .note("an `as` expression can only be used to convert between \ + primitive types. Consider using the `From` trait") + .emit(); } CastError::SizedUnsizedCast => { use structured_errors::{SizedUnsizedCastError, StructuredDiagnostic}; @@ -299,9 +300,12 @@ err.note("The type information given here is insufficient to check whether \ the pointer cast is valid"); if unknown_cast_to { - err.span_suggestion_short(self.cast_span, - "consider giving more type information", - String::new()); + err.span_suggestion_short_with_applicability( + self.cast_span, + "consider giving more type information", + String::new(), + Applicability::Unspecified, + ); } err.emit(); } @@ -327,9 +331,12 @@ if self.cast_ty.is_trait() { match fcx.tcx.sess.source_map().span_to_snippet(self.cast_span) { Ok(s) => { - err.span_suggestion(self.cast_span, - "try casting to a reference instead", - format!("&{}{}", mtstr, s)); + err.span_suggestion_with_applicability( + self.cast_span, + "try casting to a reference instead", + format!("&{}{}", mtstr, s), + Applicability::MachineApplicable, + ); } Err(_) => { span_help!(err, self.cast_span, "did you mean `&{}{}`?", mtstr, tstr) @@ -346,9 +353,12 @@ ty::Adt(def, ..) if def.is_box() => { match fcx.tcx.sess.source_map().span_to_snippet(self.cast_span) { Ok(s) => { - err.span_suggestion(self.cast_span, - "try casting to a `Box` instead", - format!("Box<{}>", s)); + err.span_suggestion_with_applicability( + self.cast_span, + "try casting to a `Box` instead", + format!("Box<{}>", s), + Applicability::MachineApplicable, + ); } Err(_) => span_help!(err, self.cast_span, "did you mean `Box<{}>`?", tstr), } @@ -436,7 +446,7 @@ self.expr_ty, fcx.tcx.mk_fn_ptr(f), AllowTwoPhase::No); - if !res.is_ok() { + if res.is_err() { return Err(CastError::NonScalar); } (FnPtr, t_cast) diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/closure.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/closure.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/closure.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/closure.rs 2018-12-04 23:41:40.000000000 +0000 @@ -198,9 +198,7 @@ self.deduce_sig_from_projection(None, &pb) }) .next(); - let kind = object_type - .principal() - .and_then(|p| self.tcx.lang_items().fn_trait_kind(p.def_id())); + let kind = self.tcx.lang_items().fn_trait_kind(object_type.principal().def_id()); (sig, kind) } ty::Infer(ty::TyVar(vid)) => self.deduce_expectations_from_obligations(vid), @@ -231,20 +229,19 @@ obligation.predicate ); - match obligation.predicate { + if let ty::Predicate::Projection(ref proj_predicate) = obligation.predicate { // Given a Projection predicate, we can potentially infer // the complete signature. - ty::Predicate::Projection(ref proj_predicate) => { - let trait_ref = proj_predicate.to_poly_trait_ref(self.tcx); - self.self_type_matches_expected_vid(trait_ref, expected_vid) - .and_then(|_| { - self.deduce_sig_from_projection( - Some(obligation.cause.span), - proj_predicate, - ) - }) - } - _ => None, + let trait_ref = proj_predicate.to_poly_trait_ref(self.tcx); + self.self_type_matches_expected_vid(trait_ref, expected_vid) + .and_then(|_| { + self.deduce_sig_from_projection( + Some(obligation.cause.span), + proj_predicate + ) + }) + } else { + None } }) .next(); @@ -318,9 +315,7 @@ let input_tys = match arg_param_ty.sty { ty::Tuple(tys) => tys.into_iter(), - _ => { - return None; - } + _ => return None }; let ret_param_ty = projection.skip_binder().ty; @@ -382,7 +377,7 @@ ) -> ClosureSignatures<'tcx> { debug!("sig_of_closure_no_expectation()"); - let bound_sig = self.supplied_sig_of_closure(decl); + let bound_sig = self.supplied_sig_of_closure(expr_def_id, decl); self.closure_sigs(expr_def_id, body, bound_sig) } @@ -484,7 +479,7 @@ // Along the way, it also writes out entries for types that the user // wrote into our tables, which are then later used by the privacy // check. - match self.check_supplied_sig_against_expectation(decl, &closure_sigs) { + match self.check_supplied_sig_against_expectation(expr_def_id, decl, &closure_sigs) { Ok(infer_ok) => self.register_infer_ok_obligations(infer_ok), Err(_) => return self.sig_of_closure_no_expectation(expr_def_id, decl, body), } @@ -504,7 +499,7 @@ .sig .inputs() .iter() - .map(|ty| ArgKind::from_expected_ty(ty)) + .map(|ty| ArgKind::from_expected_ty(ty, None)) .collect(); let (closure_span, found_args) = self.get_fn_like_arguments(expr_map_node); let expected_span = expected_sig.cause_span.unwrap_or(closure_span); @@ -526,6 +521,7 @@ /// strategy. fn check_supplied_sig_against_expectation( &self, + expr_def_id: DefId, decl: &hir::FnDecl, expected_sigs: &ClosureSignatures<'tcx>, ) -> InferResult<'tcx, ()> { @@ -533,7 +529,7 @@ // // (See comment on `sig_of_closure_with_expectation` for the // meaning of these letters.) - let supplied_sig = self.supplied_sig_of_closure(decl); + let supplied_sig = self.supplied_sig_of_closure(expr_def_id, decl); debug!( "check_supplied_sig_against_expectation: supplied_sig={:?}", @@ -560,8 +556,8 @@ // The liberated version of this signature should be be a subtype // of the liberated form of the expectation. for ((hir_ty, &supplied_ty), expected_ty) in decl.inputs.iter() - .zip(*supplied_sig.inputs().skip_binder()) // binder moved to (*) below - .zip(expected_sigs.liberated_sig.inputs()) + .zip(*supplied_sig.inputs().skip_binder()) // binder moved to (*) below + .zip(expected_sigs.liberated_sig.inputs()) // `liberated_sig` is E'. { // Instantiate (this part of..) S to S', i.e., with fresh variables. @@ -603,7 +599,13 @@ /// If there is no expected signature, then we will convert the /// types that the user gave into a signature. - fn supplied_sig_of_closure(&self, decl: &hir::FnDecl) -> ty::PolyFnSig<'tcx> { + /// + /// Also, record this closure signature for later. + fn supplied_sig_of_closure( + &self, + expr_def_id: DefId, + decl: &hir::FnDecl, + ) -> ty::PolyFnSig<'tcx> { let astconv: &dyn AstConv = self; // First, convert the types that the user supplied (if any). @@ -623,6 +625,12 @@ debug!("supplied_sig_of_closure: result={:?}", result); + let c_result = self.inh.infcx.canonicalize_response(&result); + self.tables.borrow_mut().user_provided_sigs.insert( + expr_def_id, + c_result, + ); + result } @@ -638,11 +646,8 @@ self.tcx.types.err }); - match decl.output { - hir::Return(ref output) => { - astconv.ast_ty_to_ty(&output); - } - hir::DefaultReturn(_) => {} + if let hir::Return(ref output) = decl.output { + astconv.ast_ty_to_ty(&output); } let result = ty::Binder::bind(self.tcx.mk_fn_sig( diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/coercion.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/coercion.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/coercion.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/coercion.rs 2018-12-04 23:41:40.000000000 +0000 @@ -144,8 +144,7 @@ fn unify(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> InferResult<'tcx, Ty<'tcx>> { self.commit_if_ok(|_| { if self.use_lub { - self.at(&self.cause, self.fcx.param_env) - .lub(b, a) + self.at(&self.cause, self.fcx.param_env).lub(b, a) } else { self.at(&self.cause, self.fcx.param_env) .sup(b, a) @@ -256,8 +255,8 @@ b: Ty<'tcx>, r_b: ty::Region<'tcx>, mt_b: TypeAndMut<'tcx>) - -> CoerceResult<'tcx> { - + -> CoerceResult<'tcx> + { debug!("coerce_borrowed_pointer(a={:?}, b={:?})", a, b); // If we have a parameter of type `&M T_a` and the value @@ -591,9 +590,7 @@ } Ok(Some(vtable)) => { - for obligation in vtable.nested_obligations() { - queue.push_back(obligation); - } + queue.extend(vtable.nested_obligations()) } } } @@ -620,12 +617,11 @@ G: FnOnce(Ty<'tcx>) -> Vec> { if let ty::FnPtr(fn_ty_b) = b.sty { - match (fn_ty_a.unsafety(), fn_ty_b.unsafety()) { - (hir::Unsafety::Normal, hir::Unsafety::Unsafe) => { - let unsafe_a = self.tcx.safe_to_unsafe_fn_ty(fn_ty_a); - return self.unify_and(unsafe_a, b, to_unsafe); - } - _ => {} + if let (hir::Unsafety::Normal, hir::Unsafety::Unsafe) + = (fn_ty_a.unsafety(), fn_ty_b.unsafety()) + { + let unsafe_a = self.tcx.safe_to_unsafe_fn_ty(fn_ty_a); + return self.unify_and(unsafe_a, b, to_unsafe); } } self.unify_and(a, b, normal) @@ -653,7 +649,6 @@ -> CoerceResult<'tcx> { //! Attempts to coerce from the type of a Rust function item //! into a closure or a `proc`. - //! let b = self.shallow_resolve(b); debug!("coerce_from_fn_item(a={:?}, b={:?})", a, b); @@ -724,9 +719,7 @@ let (is_ref, mt_a) = match a.sty { ty::Ref(_, ty, mutbl) => (true, ty::TypeAndMut { ty, mutbl }), ty::RawPtr(mt) => (false, mt), - _ => { - return self.unify_and(a, b, identity); - } + _ => return self.unify_and(a, b, identity) }; // Check that the types which they point at are compatible. @@ -896,10 +889,10 @@ }; if !noop { - return self.commit_if_ok(|_| { + return self.commit_if_ok(|_| self.at(cause, self.param_env) .lub(prev_ty, new_ty) - }).map(|ok| self.register_infer_ok_obligations(ok)); + ).map(|ok| self.register_infer_ok_obligations(ok)); } } @@ -909,10 +902,10 @@ if let Some(e) = first_error { Err(e) } else { - self.commit_if_ok(|_| { + self.commit_if_ok(|_| self.at(cause, self.param_env) .lub(prev_ty, new_ty) - }).map(|ok| self.register_infer_ok_obligations(ok)) + ).map(|ok| self.register_infer_ok_obligations(ok)) } } Ok(ok) => { @@ -1005,7 +998,7 @@ /// needlessly cloning the slice. pub fn with_coercion_sites(expected_ty: Ty<'tcx>, coercion_sites: &'exprs [E]) - -> Self { + -> Self { Self::make(expected_ty, Expressions::UpFront(coercion_sites)) } @@ -1039,8 +1032,8 @@ } /// Indicates that the value generated by `expression`, which is - /// of type `expression_ty`, is one of the possibility that we - /// could coerce from. This will record `expression` and later + /// of type `expression_ty`, is one of the possibilities that we + /// could coerce from. This will record `expression`, and later /// calls to `coerce` may come back and add adjustments and things /// if necessary. pub fn coerce<'a>(&mut self, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/compare_method.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/compare_method.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/compare_method.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/compare_method.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,10 +16,11 @@ use rustc::ty::error::{ExpectedFound, TypeError}; use rustc::ty::subst::{Subst, Substs}; use rustc::util::common::ErrorReported; +use errors::Applicability; use syntax_pos::Span; -use super::{Inherited, FnCtxt}; +use super::{Inherited, FnCtxt, potentially_plural_count}; /// Checks that a method from an impl conforms to the signature of /// the same method as declared in the trait. @@ -127,14 +128,14 @@ // We create a mapping `dummy_substs` that maps from the impl type // parameters to fresh types and regions. For type parameters, // this is the identity transform, but we could as well use any - // skolemized types. For regions, we convert from bound to free + // placeholder types. For regions, we convert from bound to free // regions (Note: but only early-bound regions, i.e., those // declared on the impl or used in type parameter bounds). // // impl_to_skol_substs = {'i => 'i0, U => U0, N => N0 } // // Now we can apply skol_substs to the type of the impl method - // to yield a new function type in terms of our fresh, skolemized + // to yield a new function type in terms of our fresh, placeholder // types: // // <'b> fn(t: &'i0 U0, m: &'b) -> Foo @@ -162,15 +163,15 @@ // We do this by creating a parameter environment which contains a // substitution corresponding to impl_to_skol_substs. We then build // trait_to_skol_substs and use it to convert the predicates contained - // in the trait_m.generics to the skolemized form. + // in the trait_m.generics to the placeholder form. // // Finally we register each of these predicates as an obligation in // a fresh FulfillmentCtxt, and invoke select_all_or_error. - // Create mapping from impl to skolemized. + // Create mapping from impl to placeholder. let impl_to_skol_substs = Substs::identity_for_item(tcx, impl_m.def_id); - // Create mapping from trait to skolemized. + // Create mapping from trait to placeholder. let trait_to_skol_substs = impl_to_skol_substs.rebase_onto(tcx, impl_m.container.id(), trait_to_impl_substs); @@ -208,10 +209,10 @@ // // We then register the obligations from the impl_m and check to see // if all constraints hold. - hybrid_preds.predicates - .extend(trait_m_predicates.instantiate_own(tcx, trait_to_skol_substs).predicates); + hybrid_preds.predicates.extend( + trait_m_predicates.instantiate_own(tcx, trait_to_skol_substs).predicates); - // Construct trait parameter environment and then shift it into the skolemized viewpoint. + // Construct trait parameter environment and then shift it into the placeholder viewpoint. // The key step here is to update the caller_bounds's predicates to be // the new hybrid bounds we computed. let normalize_cause = traits::ObligationCause::misc(impl_m_span, impl_m_node_id); @@ -258,7 +259,7 @@ // any associated types appearing in the fn arguments or return // type. - // Compute skolemized form of impl and trait method tys. + // Compute placeholder form of impl and trait method tys. let tcx = infcx.tcx; let (impl_sig, _) = @@ -319,12 +320,13 @@ trait_m.ident); if let TypeError::Mutability = terr { if let Some(trait_err_span) = trait_err_span { - if let Ok(trait_err_str) = tcx.sess.source_map(). - span_to_snippet(trait_err_span) { - diag.span_suggestion( + if let Ok(trait_err_str) = tcx.sess.source_map() + .span_to_snippet(trait_err_span) { + diag.span_suggestion_with_applicability( impl_err_span, "consider change the type to match the mutability in trait", - format!("{}", trait_err_str), + trait_err_str, + Applicability::MachineApplicable, ); } } @@ -332,7 +334,7 @@ infcx.note_type_err(&mut diag, &cause, - trait_err_span.map(|sp| (sp, "type in trait".to_string())), + trait_err_span.map(|sp| (sp, "type in trait".to_owned())), Some(infer::ValuePairs::Types(ExpectedFound { expected: trait_fty, found: impl_fty, @@ -406,7 +408,7 @@ return Err(ErrorReported); } - return Ok(()); + Ok(()) } fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a, 'gcx, 'tcx>, @@ -468,14 +470,14 @@ impl_iter.zip(trait_iter) .zip(impl_m_iter) .zip(trait_m_iter) - .filter_map(|(((&impl_arg_ty, &trait_arg_ty), impl_arg), trait_arg)| { + .filter_map(|(((&impl_arg_ty, &trait_arg_ty), impl_arg), trait_arg)| match infcx.at(&cause, param_env).sub(trait_arg_ty, impl_arg_ty) { Ok(_) => None, Err(_) => Some((impl_arg.span, Some(trait_arg.span))), } - }) + ) .next() - .unwrap_or_else(|| { + .unwrap_or_else(|| if infcx.at(&cause, param_env) .sup(trait_sig.output(), impl_sig.output()) @@ -485,7 +487,7 @@ } else { (cause.span(&tcx), tcx.hir.span_if_local(trait_m.def_id)) } - }) + ) } else { (cause.span(&tcx), tcx.hir.span_if_local(trait_m.def_id)) } @@ -524,9 +526,9 @@ ); let can_eq_self = |ty| infcx.can_eq(param_env, untransformed_self_ty, ty).is_ok(); match ExplicitSelf::determine(self_arg_ty, can_eq_self) { - ExplicitSelf::ByValue => "self".to_string(), - ExplicitSelf::ByReference(_, hir::MutImmutable) => "&self".to_string(), - ExplicitSelf::ByReference(_, hir::MutMutable) => "&mut self".to_string(), + ExplicitSelf::ByValue => "self".to_owned(), + ExplicitSelf::ByReference(_, hir::MutImmutable) => "&self".to_owned(), + ExplicitSelf::ByReference(_, hir::MutMutable) => "&mut self".to_owned(), _ => format!("self: {}", self_arg_ty) } }) @@ -589,6 +591,7 @@ let trait_m_generics = tcx.generics_of(trait_m.def_id); let num_impl_m_type_params = impl_m_generics.own_counts().types; let num_trait_m_type_params = trait_m_generics.own_counts().types; + if num_impl_m_type_params != num_trait_m_type_params { let impl_m_node_id = tcx.hir.as_local_node_id(impl_m.def_id).unwrap(); let impl_m_item = tcx.hir.expect_impl_item(impl_m_node_id); @@ -598,43 +601,26 @@ impl_m_item.generics.span }; - let mut err = struct_span_err!(tcx.sess, - span, - E0049, - "method `{}` has {} type parameter{} but its trait \ - declaration has {} type parameter{}", - trait_m.ident, - num_impl_m_type_params, - if num_impl_m_type_params == 1 { "" } else { "s" }, - num_trait_m_type_params, - if num_trait_m_type_params == 1 { - "" - } else { - "s" - }); + let mut err = struct_span_err!(tcx.sess, span, E0049, + "method `{}` has {} but its trait declaration has {}", + trait_m.ident, + potentially_plural_count(num_impl_m_type_params, "type parameter"), + potentially_plural_count(num_trait_m_type_params, "type parameter") + ); let mut suffix = None; if let Some(span) = trait_item_span { - err.span_label(span, - format!("expected {}", - &if num_trait_m_type_params != 1 { - format!("{} type parameters", num_trait_m_type_params) - } else { - format!("{} type parameter", num_trait_m_type_params) - })); + err.span_label(span, format!("expected {}", + potentially_plural_count(num_trait_m_type_params, "type parameter"))); } else { suffix = Some(format!(", expected {}", num_trait_m_type_params)); } err.span_label(span, format!("found {}{}", - &if num_impl_m_type_params != 1 { - format!("{} type parameters", num_impl_m_type_params) - } else { - "1 type parameter".to_string() - }, - suffix.as_ref().map(|s| &s[..]).unwrap_or(""))); + potentially_plural_count(num_impl_m_type_params, "type parameter"), + suffix.as_ref().map(|s| &s[..]).unwrap_or(""))); err.emit(); @@ -692,33 +678,21 @@ let mut err = struct_span_err!(tcx.sess, impl_span, E0050, - "method `{}` has {} parameter{} but the declaration in \ + "method `{}` has {} but the declaration in \ trait `{}` has {}", trait_m.ident, - impl_number_args, - if impl_number_args == 1 { "" } else { "s" }, + potentially_plural_count(impl_number_args, "parameter"), tcx.item_path_str(trait_m.def_id), trait_number_args); if let Some(trait_span) = trait_span { - err.span_label(trait_span, - format!("trait requires {}", - &if trait_number_args != 1 { - format!("{} parameters", trait_number_args) - } else { - format!("{} parameter", trait_number_args) - })); + err.span_label(trait_span, format!("trait requires {}", + potentially_plural_count(trait_number_args, "parameter"))); } else { err.note_trait_signature(trait_m.ident.to_string(), trait_m.signature(&tcx)); } - err.span_label(impl_span, - format!("expected {}, found {}", - &if trait_number_args != 1 { - format!("{} parameters", trait_number_args) - } else { - format!("{} parameter", trait_number_args) - }, - impl_number_args)); + err.span_label(impl_span, format!("expected {}, found {}", + potentially_plural_count(trait_number_args, "parameter"), impl_number_args)); err.emit(); return Err(ErrorReported); } @@ -748,8 +722,9 @@ GenericParamDefKind::Lifetime => None, } }); - for ((impl_def_id, impl_synthetic), - (trait_def_id, trait_synthetic)) in impl_m_type_params.zip(trait_m_type_params) { + for ((impl_def_id, impl_synthetic), (trait_def_id, trait_synthetic)) + in impl_m_type_params.zip(trait_m_type_params) + { if impl_synthetic != trait_synthetic { let impl_node_id = tcx.hir.as_local_node_id(impl_def_id).unwrap(); let impl_span = tcx.hir.span(impl_node_id); @@ -799,7 +774,7 @@ .span_to_snippet(trait_m.generics.span) .ok()?; - err.multipart_suggestion( + err.multipart_suggestion_with_applicability( "try changing the `impl Trait` argument to a generic parameter", vec![ // replace `impl Trait` with `T` @@ -809,6 +784,7 @@ // of the generics, but it works for the common case (generics_span, new_generics), ], + Applicability::MaybeIncorrect, ); Some(()) })(); @@ -828,15 +804,14 @@ impl<'v> hir::intravisit::Visitor<'v> for Visitor { fn visit_ty(&mut self, ty: &'v hir::Ty) { hir::intravisit::walk_ty(self, ty); - match ty.node { - hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => { - if let hir::def::Def::TyParam(def_id) = path.def { - if def_id == self.1 { - self.0 = Some(ty.span); - } + if let hir::TyKind::Path( + hir::QPath::Resolved(None, ref path)) = ty.node + { + if let hir::def::Def::TyParam(def_id) = path.def { + if def_id == self.1 { + self.0 = Some(ty.span); } - }, - _ => {} + } } } fn nested_visit_map<'this>( @@ -870,7 +845,7 @@ .span_to_snippet(bounds) .ok()?; - err.multipart_suggestion( + err.multipart_suggestion_with_applicability( "try removing the generic parameter and using `impl Trait` instead", vec![ // delete generic parameters @@ -878,6 +853,7 @@ // replace param usage with `impl Trait` (span, format!("impl {}", bounds)), ], + Applicability::MaybeIncorrect, ); Some(()) })(); @@ -918,7 +894,7 @@ // method. let impl_c_node_id = tcx.hir.as_local_node_id(impl_c.def_id).unwrap(); - // Compute skolemized form of impl and trait const tys. + // Compute placeholder form of impl and trait const tys. let impl_ty = tcx.type_of(impl_c.def_id); let trait_ty = tcx.type_of(trait_c.def_id).subst(tcx, trait_to_impl_substs); let mut cause = ObligationCause::misc(impl_c_span, impl_c_node_id); @@ -971,7 +947,7 @@ infcx.note_type_err(&mut diag, &cause, - trait_c_span.map(|span| (span, "type in trait".to_string())), + trait_c_span.map(|span| (span, "type in trait".to_owned())), Some(infer::ValuePairs::Types(ExpectedFound { expected: trait_ty, found: impl_ty, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/demand.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/demand.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/demand.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/demand.rs 2018-12-04 23:41:40.000000000 +0000 @@ -111,31 +111,36 @@ let expr_ty = self.resolve_type_vars_with_obligations(checked_ty); let mut err = self.report_mismatched_types(&cause, expected, expr_ty, e); - // If the expected type is an enum with any variants whose sole - // field is of the found type, suggest such variants. See Issue - // #42764. + // If the expected type is an enum (Issue #55250) with any variants whose + // sole field is of the found type, suggest such variants. (Issue #42764) if let ty::Adt(expected_adt, substs) = expected.sty { - let mut compatible_variants = vec![]; - for variant in &expected_adt.variants { - if variant.fields.len() == 1 { - let sole_field = &variant.fields[0]; - let sole_field_ty = sole_field.ty(self.tcx, substs); - if self.can_coerce(expr_ty, sole_field_ty) { - let mut variant_path = self.tcx.item_path_str(variant.did); - variant_path = variant_path.trim_left_matches("std::prelude::v1::") - .to_string(); - compatible_variants.push(variant_path); - } + if expected_adt.is_enum() { + let mut compatible_variants = expected_adt.variants + .iter() + .filter(|variant| variant.fields.len() == 1) + .filter_map(|variant| { + let sole_field = &variant.fields[0]; + let sole_field_ty = sole_field.ty(self.tcx, substs); + if self.can_coerce(expr_ty, sole_field_ty) { + let variant_path = self.tcx.item_path_str(variant.did); + Some(variant_path.trim_left_matches("std::prelude::v1::").to_string()) + } else { + None + } + }).peekable(); + + if compatible_variants.peek().is_some() { + let expr_text = print::to_string(print::NO_ANN, |s| s.print_expr(expr)); + let suggestions = compatible_variants + .map(|v| format!("{}({})", v, expr_text)).collect::>(); + err.span_suggestions_with_applicability( + expr.span, + "try using a variant of the expected type", + suggestions, + Applicability::MaybeIncorrect, + ); } } - if !compatible_variants.is_empty() { - let expr_text = print::to_string(print::NO_ANN, |s| s.print_expr(expr)); - let suggestions = compatible_variants.iter() - .map(|v| format!("{}({})", v, expr_text)).collect::>(); - err.span_suggestions(expr.span, - "try using a variant of the expected type", - suggestions); - } } self.suggest_ref_or_into(&mut err, expr, expected, expr_ty); @@ -305,11 +310,20 @@ }; if self.can_coerce(ref_ty, expected) { if let Ok(src) = cm.span_to_snippet(sp) { - let sugg_expr = match expr.node { // parenthesize if needed (Issue #46756) + let needs_parens = match expr.node { + // parenthesize if needed (Issue #46756) hir::ExprKind::Cast(_, _) | - hir::ExprKind::Binary(_, _, _) => format!("({})", src), - _ => src, + hir::ExprKind::Binary(_, _, _) => true, + // parenthesize borrows of range literals (Issue #54505) + _ if self.is_range_literal(expr) => true, + _ => false, + }; + let sugg_expr = if needs_parens { + format!("({})", src) + } else { + src }; + if let Some(sugg) = self.can_use_as_ref(expr) { return Some(sugg); } @@ -370,6 +384,66 @@ None } + /// This function checks if the specified expression is a built-in range literal. + /// (See: `LoweringContext::lower_expr()` in `src/librustc/hir/lowering.rs`). + fn is_range_literal(&self, expr: &hir::Expr) -> bool { + use hir::{Path, QPath, ExprKind, TyKind}; + + // We support `::std::ops::Range` and `::core::ops::Range` prefixes + let is_range_path = |path: &Path| { + let mut segs = path.segments.iter() + .map(|seg| seg.ident.as_str()); + + if let (Some(root), Some(std_core), Some(ops), Some(range), None) = + (segs.next(), segs.next(), segs.next(), segs.next(), segs.next()) + { + // "{{root}}" is the equivalent of `::` prefix in Path + root == "{{root}}" && (std_core == "std" || std_core == "core") + && ops == "ops" && range.starts_with("Range") + } else { + false + } + }; + + let span_is_range_literal = |span: &Span| { + // Check whether a span corresponding to a range expression + // is a range literal, rather than an explicit struct or `new()` call. + let source_map = self.tcx.sess.source_map(); + let end_point = source_map.end_point(*span); + + if let Ok(end_string) = source_map.span_to_snippet(end_point) { + !(end_string.ends_with("}") || end_string.ends_with(")")) + } else { + false + } + }; + + match expr.node { + // All built-in range literals but `..=` and `..` desugar to Structs + ExprKind::Struct(QPath::Resolved(None, ref path), _, _) | + // `..` desugars to its struct path + ExprKind::Path(QPath::Resolved(None, ref path)) => { + return is_range_path(&path) && span_is_range_literal(&expr.span); + } + + // `..=` desugars into `::std::ops::RangeInclusive::new(...)` + ExprKind::Call(ref func, _) => { + if let ExprKind::Path(QPath::TypeRelative(ref ty, ref segment)) = func.node { + if let TyKind::Path(QPath::Resolved(None, ref path)) = ty.node { + let call_to_new = segment.ident.as_str() == "new"; + + return is_range_path(&path) && span_is_range_literal(&expr.span) + && call_to_new; + } + } + } + + _ => {} + } + + false + } + pub fn check_for_cast(&self, err: &mut DiagnosticBuilder<'tcx>, expr: &hir::Expr, @@ -377,15 +451,12 @@ expected_ty: Ty<'tcx>) -> bool { let parent_id = self.tcx.hir.get_parent_node(expr.id); - match self.tcx.hir.find(parent_id) { - Some(parent) => { - // Shouldn't suggest `.into()` on `const`s. - if let Node::Item(Item { node: ItemKind::Const(_, _), .. }) = parent { - // FIXME(estebank): modify once we decide to suggest `as` casts - return false; - } + if let Some(parent) = self.tcx.hir.find(parent_id) { + // Shouldn't suggest `.into()` on `const`s. + if let Node::Item(Item { node: ItemKind::Const(_, _), .. }) = parent { + // FIXME(estebank): modify once we decide to suggest `as` casts + return false; } - None => {} }; let will_truncate = "will truncate the source value"; @@ -415,10 +486,55 @@ src, if needs_paren { ")" } else { "" }, expected_ty); - let into_suggestion = format!("{}{}{}.into()", - if needs_paren { "(" } else { "" }, - src, - if needs_paren { ")" } else { "" }); + let into_suggestion = format!( + "{}{}{}.into()", + if needs_paren { "(" } else { "" }, + src, + if needs_paren { ")" } else { "" }, + ); + let literal_is_ty_suffixed = |expr: &hir::Expr| { + if let hir::ExprKind::Lit(lit) = &expr.node { + lit.node.is_suffixed() + } else { + false + } + }; + + let into_sugg = into_suggestion.clone(); + let suggest_to_change_suffix_or_into = |err: &mut DiagnosticBuilder, + note: Option<&str>| { + let suggest_msg = if literal_is_ty_suffixed(expr) { + format!( + "change the type of the numeric literal from `{}` to `{}`", + checked_ty, + expected_ty, + ) + } else { + match note { + Some(note) => format!("{}, which {}", msg, note), + _ => format!("{} in a lossless way", msg), + } + }; + + let suffix_suggestion = format!( + "{}{}{}{}", + if needs_paren { "(" } else { "" }, + src.trim_right_matches(&checked_ty.to_string()), + expected_ty, + if needs_paren { ")" } else { "" }, + ); + + err.span_suggestion_with_applicability( + expr.span, + &suggest_msg, + if literal_is_ty_suffixed(expr) { + suffix_suggestion + } else { + into_sugg + }, + Applicability::MachineApplicable, + ); + }; match (&expected_ty.sty, &checked_ty.sty) { (&ty::Int(ref exp), &ty::Int(ref found)) => { @@ -444,11 +560,9 @@ } } _ => { - err.span_suggestion_with_applicability( - expr.span, - &format!("{}, which {}", msg, will_sign_extend), - into_suggestion, - Applicability::MachineApplicable + suggest_to_change_suffix_or_into( + err, + Some(will_sign_extend), ); } } @@ -477,12 +591,10 @@ } } _ => { - err.span_suggestion_with_applicability( - expr.span, - &format!("{}, which {}", msg, will_zero_extend), - into_suggestion, - Applicability::MachineApplicable - ); + suggest_to_change_suffix_or_into( + err, + Some(will_zero_extend), + ); } } true @@ -583,12 +695,10 @@ } (&ty::Float(ref exp), &ty::Float(ref found)) => { if found.bit_width() < exp.bit_width() { - err.span_suggestion_with_applicability( - expr.span, - &format!("{} in a lossless way", msg), - into_suggestion, - Applicability::MachineApplicable - ); + suggest_to_change_suffix_or_into( + err, + None, + ); } else if can_cast { err.span_suggestion_with_applicability( expr.span, @@ -620,7 +730,7 @@ expr.span, &format!("{}, producing the floating point representation of the \ integer", - msg), + msg), into_suggestion, Applicability::MachineApplicable ); @@ -628,7 +738,7 @@ err.span_suggestion_with_applicability(expr.span, &format!("{}, producing the floating point representation of the \ integer, rounded if necessary", - msg), + msg), cast_suggestion, Applicability::MaybeIncorrect // lossy conversion ); @@ -642,7 +752,7 @@ expr.span, &format!("{}, producing the floating point representation of the \ integer", - msg), + msg), into_suggestion, Applicability::MachineApplicable ); @@ -651,7 +761,7 @@ expr.span, &format!("{}, producing the floating point representation of the \ integer, rounded if necessary", - msg), + msg), cast_suggestion, Applicability::MaybeIncorrect // lossy conversion ); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/dropck.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/dropck.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/dropck.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/dropck.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,12 +11,12 @@ use check::regionck::RegionCtxt; use hir::def_id::DefId; -use rustc::infer::{self, InferOk}; use rustc::infer::outlives::env::OutlivesEnvironment; +use rustc::infer::{self, InferOk, SuppressRegionErrors}; use rustc::middle::region; +use rustc::traits::{ObligationCause, TraitEngine, TraitEngineExt}; use rustc::ty::subst::{Subst, Substs, UnpackedKind}; use rustc::ty::{self, Ty, TyCtxt}; -use rustc::traits::{ObligationCause, TraitEngine, TraitEngineExt}; use util::common::ErrorReported; use syntax::ast; @@ -39,23 +39,28 @@ /// struct/enum definition for the nominal type itself (i.e. /// cannot do `struct S; impl Drop for S { ... }`). /// -pub fn check_drop_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - drop_impl_did: DefId) - -> Result<(), ErrorReported> { +pub fn check_drop_impl<'a, 'tcx>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + drop_impl_did: DefId, +) -> Result<(), ErrorReported> { let dtor_self_type = tcx.type_of(drop_impl_did); let dtor_predicates = tcx.predicates_of(drop_impl_did); match dtor_self_type.sty { ty::Adt(adt_def, self_to_impl_substs) => { - ensure_drop_params_and_item_params_correspond(tcx, - drop_impl_did, - dtor_self_type, - adt_def.did)?; - - ensure_drop_predicates_are_implied_by_item_defn(tcx, - drop_impl_did, - &dtor_predicates, - adt_def.did, - self_to_impl_substs) + ensure_drop_params_and_item_params_correspond( + tcx, + drop_impl_did, + dtor_self_type, + adt_def.did, + )?; + + ensure_drop_predicates_are_implied_by_item_defn( + tcx, + drop_impl_did, + &dtor_predicates, + adt_def.did, + self_to_impl_substs, + ) } _ => { // Destructors only work on nominal types. This was @@ -63,8 +68,7 @@ // not have been terminated. let span = tcx.def_span(drop_impl_did); tcx.sess.delay_span_bug(span, - &format!("should have been rejected by coherence check: {}", - dtor_self_type)); + &format!("should have been rejected by coherence check: {}", dtor_self_type)); Err(ErrorReported) } } @@ -74,9 +78,8 @@ tcx: TyCtxt<'a, 'tcx, 'tcx>, drop_impl_did: DefId, drop_impl_ty: Ty<'tcx>, - self_type_did: DefId) - -> Result<(), ErrorReported> -{ + self_type_did: DefId, +) -> Result<(), ErrorReported> { let drop_impl_node_id = tcx.hir.as_local_node_id(drop_impl_did).unwrap(); // check that the impl type can be made to match the trait type. @@ -89,22 +92,29 @@ let named_type = tcx.type_of(self_type_did); let drop_impl_span = tcx.def_span(drop_impl_did); - let fresh_impl_substs = - infcx.fresh_substs_for_item(drop_impl_span, drop_impl_did); + let fresh_impl_substs = infcx.fresh_substs_for_item(drop_impl_span, drop_impl_did); let fresh_impl_self_ty = drop_impl_ty.subst(tcx, fresh_impl_substs); let cause = &ObligationCause::misc(drop_impl_span, drop_impl_node_id); - match infcx.at(cause, impl_param_env).eq(named_type, fresh_impl_self_ty) { + match infcx + .at(cause, impl_param_env) + .eq(named_type, fresh_impl_self_ty) + { Ok(InferOk { obligations, .. }) => { fulfillment_cx.register_predicate_obligations(infcx, obligations); } Err(_) => { let item_span = tcx.def_span(self_type_did); - struct_span_err!(tcx.sess, drop_impl_span, E0366, - "Implementations of Drop cannot be specialized") - .span_note(item_span, - "Use same sequence of generic type and region \ - parameters that is on the struct/enum definition") + struct_span_err!( + tcx.sess, + drop_impl_span, + E0366, + "Implementations of Drop cannot be specialized" + ).span_note( + item_span, + "Use same sequence of generic type and region \ + parameters that is on the struct/enum definition", + ) .emit(); return Err(ErrorReported); } @@ -128,7 +138,12 @@ // conservative. -nmatsakis let outlives_env = OutlivesEnvironment::new(ty::ParamEnv::empty()); - infcx.resolve_regions_and_report_errors(drop_impl_did, ®ion_scope_tree, &outlives_env); + infcx.resolve_regions_and_report_errors( + drop_impl_did, + ®ion_scope_tree, + &outlives_env, + SuppressRegionErrors::default(), + ); Ok(()) }) } @@ -140,9 +155,8 @@ drop_impl_did: DefId, dtor_predicates: &ty::GenericPredicates<'tcx>, self_type_did: DefId, - self_to_impl_substs: &Substs<'tcx>) - -> Result<(), ErrorReported> -{ + self_to_impl_substs: &Substs<'tcx>, +) -> Result<(), ErrorReported> { let mut result = Ok(()); // Here is an example, analogous to that from @@ -198,7 +212,7 @@ // just to look for all the predicates directly. assert_eq!(dtor_predicates.parent, None); - for predicate in &dtor_predicates.predicates { + for (predicate, _) in &dtor_predicates.predicates { // (We do not need to worry about deep analysis of type // expressions etc because the Drop impls are already forced // to take on a structure that is roughly an alpha-renaming of @@ -213,11 +227,17 @@ if !assumptions_in_impl_context.contains(&predicate) { let item_span = tcx.hir.span(self_type_node_id); - struct_span_err!(tcx.sess, drop_impl_span, E0367, - "The requirement `{}` is added only by the Drop impl.", predicate) - .span_note(item_span, - "The same requirement must be part of \ - the struct/enum definition") + struct_span_err!( + tcx.sess, + drop_impl_span, + E0367, + "The requirement `{}` is added only by the Drop impl.", + predicate + ).span_note( + item_span, + "The same requirement must be part of \ + the struct/enum definition", + ) .emit(); result = Err(ErrorReported); } @@ -283,18 +303,16 @@ ty: Ty<'tcx>, span: Span, body_id: ast::NodeId, - scope: region::Scope) - -> Result<(), ErrorReported> -{ + scope: region::Scope, +) -> Result<(), ErrorReported> { debug!("check_safety_of_destructor_if_necessary typ: {:?} scope: {:?}", ty, scope); - let parent_scope = match rcx.region_scope_tree.opt_encl_scope(scope) { Some(parent_scope) => parent_scope, // If no enclosing scope, then it must be the root scope // which cannot be outlived. - None => return Ok(()) + None => return Ok(()), }; let parent_scope = rcx.tcx.mk_region(ty::ReScope(parent_scope)); let origin = || infer::SubregionOrigin::SafeDestructor(span); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/generator_interior.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/generator_interior.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/generator_interior.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/generator_interior.rs 2018-12-04 23:41:40.000000000 +0000 @@ -48,7 +48,7 @@ // See the mega-comment at `yield_in_scope` for a proof. debug!("comparing counts yield: {} self: {}, source_span = {:?}", - expr_count, self.expr_count, source_span); + expr_count, self.expr_count, source_span); if expr_count >= self.expr_count { Some(yield_span) @@ -89,7 +89,7 @@ let body = fcx.tcx.hir.body(body_id); let mut visitor = InteriorVisitor { fcx, - types: FxHashMap(), + types: FxHashMap::default(), region_scope_tree: fcx.tcx.region_scope_tree(def_id), expr_count: 0, }; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/intrinsic.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/intrinsic.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/intrinsic.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/intrinsic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -57,7 +57,7 @@ struct_span_err!(tcx.sess, span, E0094, "intrinsic has wrong number of type \ - parameters: found {}, expected {}", + parameters: found {}, expected {}", i_n_tps, n_tps) .span_label(span, format!("expected {} type parameter", n_tps)) .emit(); @@ -83,7 +83,7 @@ let name = it.name.as_str(); let (n_tps, inputs, output, unsafety) = if name.starts_with("atomic_") { let split : Vec<&str> = name.split('_').collect(); - assert!(split.len() >= 2, "Atomic intrinsic not correct format"); + assert!(split.len() >= 2, "Atomic intrinsic in an incorrect format"); //We only care about the operation here let (n_tps, inputs, output) = match split[1] { @@ -117,7 +117,7 @@ (0, Vec::new(), tcx.types.never, hir::Unsafety::Unsafe) } else { let unsafety = match &name[..] { - "size_of" | "min_align_of" => hir::Unsafety::Normal, + "size_of" | "min_align_of" | "needs_drop" => hir::Unsafety::Normal, _ => hir::Unsafety::Unsafe, }; let (n_tps, inputs, output) = match &name[..] { @@ -127,8 +127,8 @@ "size_of_val" | "min_align_of_val" => { (1, vec![ tcx.mk_imm_ref(tcx.mk_region(ty::ReLateBound(ty::INNERMOST, - ty::BrAnon(0))), - param(0)) + ty::BrAnon(0))), + param(0)) ], tcx.types.usize) } "rustc_peek" => (1, vec![param(0)], param(0)), @@ -306,7 +306,7 @@ "discriminant_value" => (1, vec![ tcx.mk_imm_ref(tcx.mk_region(ty::ReLateBound(ty::INNERMOST, - ty::BrAnon(0))), + ty::BrAnon(0))), param(0))], tcx.types.u64), "try" => { @@ -327,10 +327,10 @@ ref other => { struct_span_err!(tcx.sess, it.span, E0093, - "unrecognized intrinsic function: `{}`", - *other) - .span_label(it.span, "unrecognized intrinsic") - .emit(); + "unrecognized intrinsic function: `{}`", + *other) + .span_label(it.span, "unrecognized intrinsic") + .emit(); return; } }; @@ -416,7 +416,7 @@ return } - let mut structural_to_nomimal = FxHashMap(); + let mut structural_to_nomimal = FxHashMap::default(); let sig = tcx.fn_sig(def_id); let sig = sig.no_late_bound_regions().unwrap(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/_match.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/_match.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/_match.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/_match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -24,6 +24,7 @@ use syntax::ast; use syntax::source_map::Spanned; use syntax::ptr::P; +use syntax::util::lev_distance::find_best_match_for_name; use syntax_pos::Span; impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { @@ -81,35 +82,33 @@ // // See the examples in `run-pass/match-defbm*.rs`. let mut pat_adjustments = vec![]; - expected = loop { + while let ty::Ref(_, inner_ty, inner_mutability) = exp_ty.sty { debug!("inspecting {:?} with type {:?}", exp_ty, exp_ty.sty); - match exp_ty.sty { - ty::Ref(_, inner_ty, inner_mutability) => { - debug!("current discriminant is Ref, inserting implicit deref"); - // Preserve the reference type. We'll need it later during HAIR lowering. - pat_adjustments.push(exp_ty); - - exp_ty = inner_ty; - def_bm = match def_bm { - // If default binding mode is by value, make it `ref` or `ref mut` - // (depending on whether we observe `&` or `&mut`). - ty::BindByValue(_) => - ty::BindByReference(inner_mutability), - - // Once a `ref`, always a `ref`. This is because a `& &mut` can't mutate - // the underlying value. - ty::BindByReference(hir::Mutability::MutImmutable) => - ty::BindByReference(hir::Mutability::MutImmutable), - - // When `ref mut`, stay a `ref mut` (on `&mut`) or downgrade to `ref` - // (on `&`). - ty::BindByReference(hir::Mutability::MutMutable) => - ty::BindByReference(inner_mutability), - }; - }, - _ => break exp_ty, - } - }; + + debug!("current discriminant is Ref, inserting implicit deref"); + // Preserve the reference type. We'll need it later during HAIR lowering. + pat_adjustments.push(exp_ty); + + exp_ty = inner_ty; + def_bm = match def_bm { + // If default binding mode is by value, make it `ref` or `ref mut` + // (depending on whether we observe `&` or `&mut`). + ty::BindByValue(_) => + ty::BindByReference(inner_mutability), + + // Once a `ref`, always a `ref`. This is because a `& &mut` can't mutate + // the underlying value. + ty::BindByReference(hir::Mutability::MutImmutable) => + ty::BindByReference(hir::Mutability::MutImmutable), + + // When `ref mut`, stay a `ref mut` (on `&mut`) or downgrade to `ref` + // (on `&`). + ty::BindByReference(hir::Mutability::MutMutable) => + ty::BindByReference(inner_mutability), + }; + } + expected = exp_ty; + if pat_adjustments.len() > 0 { debug!("default binding mode is now {:?}", def_bm); self.inh.tables.borrow_mut() @@ -153,7 +152,7 @@ if let ty::Ref(_, r_ty, _) = expected_ty.sty { if let ty::Slice(_) = r_ty.sty { pat_ty = tcx.mk_imm_ref(tcx.types.re_static, - tcx.mk_slice(tcx.types.u8)) + tcx.mk_slice(tcx.types.u8)) } } } @@ -235,7 +234,7 @@ .pat_binding_modes_mut() .insert(pat.hir_id, bm); debug!("check_pat_walk: pat.hir_id={:?} bm={:?}", pat.hir_id, bm); - let typ = self.local_ty(pat.span, pat.id); + let local_ty = self.local_ty(pat.span, pat.id).decl_ty; match bm { ty::BindByReference(mutbl) => { // if the binding is like @@ -249,28 +248,28 @@ // `x` is assigned a value of type `&M T`, hence `&M T <: typeof(x)` is // required. However, we use equality, which is stronger. See (*) for // an explanation. - self.demand_eqtype(pat.span, region_ty, typ); + self.demand_eqtype(pat.span, region_ty, local_ty); } // otherwise the type of x is the expected type T ty::BindByValue(_) => { // As above, `T <: typeof(x)` is required but we // use equality, see (*) below. - self.demand_eqtype(pat.span, expected, typ); + self.demand_eqtype(pat.span, expected, local_ty); } } // if there are multiple arms, make sure they all agree on // what the type of the binding `x` ought to be if var_id != pat.id { - let vt = self.local_ty(pat.span, var_id); - self.demand_eqtype(pat.span, vt, typ); + let vt = self.local_ty(pat.span, var_id).decl_ty; + self.demand_eqtype(pat.span, vt, local_ty); } if let Some(ref p) = *sub { self.check_pat_walk(&p, expected, def_bm, true); } - typ + local_ty } PatKind::TupleStruct(ref qpath, ref subpats, ddpos) => { self.check_pat_tuple_struct(pat, qpath, &subpats, ddpos, expected, def_bm) @@ -294,7 +293,7 @@ let element_tys_iter = (0..max_len).map(|_| self.next_ty_var( // FIXME: MiscVariable for now, obtaining the span and name information - // from all tuple elements isn't trivial. + // from all tuple elements isn't trivial. TypeVariableOrigin::TypeInference(pat.span))); let element_tys = tcx.mk_type_list(element_tys_iter); let pat_ty = tcx.mk_ty(ty::Tuple(element_tys)); @@ -394,7 +393,7 @@ tcx.sess, pat.span, E0527, "pattern requires {} elements but array has {}", min_len, size) - .span_label(pat.span, format!("expected {} elements",size)) + .span_label(pat.span, format!("expected {} elements", size)) .emit(); } (inner_ty, tcx.types.err) @@ -610,24 +609,25 @@ self.check_expr_has_type_or_error(discrim, discrim_ty); }; - // If the discriminant diverges, the match is pointless (e.g., - // `match (return) { }`). - self.warn_if_unreachable(expr.id, expr.span, "expression"); - // If there are no arms, that is a diverging match; a special case. if arms.is_empty() { self.diverges.set(self.diverges.get() | Diverges::Always); return tcx.types.never; } + if self.diverges.get().always() { + for arm in arms { + self.warn_if_unreachable(arm.body.id, arm.body.span, "arm"); + } + } + // Otherwise, we have to union together the types that the // arms produce and so forth. - let discrim_diverges = self.diverges.get(); self.diverges.set(Diverges::Maybe); - // Typecheck the patterns first, so that we get types for all the - // bindings. + // rust-lang/rust#55810: Typecheck patterns first (via eager + // collection into `Vec`), so we get types for all bindings. let all_arm_pats_diverge: Vec<_> = arms.iter().map(|arm| { let mut all_pats_diverge = Diverges::WarnedAlways; for p in &arm.pats { @@ -814,11 +814,6 @@ report_unexpected_def(def); return self.tcx.types.err; } - // Replace constructor type with constructed type for tuple struct patterns. - let pat_ty = pat_ty.fn_sig(tcx).output(); - let pat_ty = pat_ty.no_late_bound_regions().expect("expected fn type"); - - self.demand_eqtype(pat.span, expected, pat_ty); let variant = match def { Def::Err => { @@ -836,6 +831,13 @@ } _ => bug!("unexpected pattern definition: {:?}", def) }; + + // Replace constructor type with constructed type for tuple struct patterns. + let pat_ty = pat_ty.fn_sig(tcx).output(); + let pat_ty = pat_ty.no_late_bound_regions().expect("expected fn type"); + + self.demand_eqtype(pat.span, expected, pat_ty); + // Type check subpatterns. if subpats.len() == variant.fields.len() || subpats.len() < variant.fields.len() && ddpos.is_some() { @@ -857,7 +859,7 @@ subpats.len(), subpats_ending, def.kind_name(), variant.fields.len(), fields_ending) .span_label(pat.span, format!("expected {} field{}, found {}", - variant.fields.len(), fields_ending, subpats.len())) + variant.fields.len(), fields_ending, subpats.len())) .emit(); on_error(); return tcx.types.err; @@ -889,7 +891,7 @@ .collect::>(); // Keep track of which fields have already appeared in the pattern. - let mut used_fields = FxHashMap(); + let mut used_fields = FxHashMap::default(); let mut no_field_errors = true; let mut inexistent_fields = vec![]; @@ -927,7 +929,11 @@ self.check_pat_walk(&field.pat, field_ty, def_bm, true); } - + let mut unmentioned_fields = variant.fields + .iter() + .map(|field| field.ident.modern()) + .filter(|ident| !used_fields.contains_key(&ident)) + .collect::>(); if inexistent_fields.len() > 0 { let (field_names, t, plural) = if inexistent_fields.len() == 1 { (format!("a field named `{}`", inexistent_fields[0].1), "this", "") @@ -946,13 +952,23 @@ kind_name, tcx.item_path_str(variant.did), field_names); - if let Some((span, _)) = inexistent_fields.last() { + if let Some((span, ident)) = inexistent_fields.last() { err.span_label(*span, format!("{} `{}` does not have {} field{}", kind_name, tcx.item_path_str(variant.did), t, plural)); + if plural == "" { + let input = unmentioned_fields.iter().map(|field| &field.name); + let suggested_name = + find_best_match_for_name(input, &ident.name.as_str(), None); + if let Some(suggested_name) = suggested_name { + err.span_suggestion(*span, "did you mean", suggested_name.to_string()); + // we don't want to throw `E0027` in case we have thrown `E0026` for them + unmentioned_fields.retain(|&x| x.as_str() != suggested_name.as_str()); + } + } } if tcx.sess.teach(&err.get_code().unwrap()) { err.note( @@ -985,11 +1001,6 @@ tcx.sess.span_err(span, "`..` cannot be used in union patterns"); } } else if !etc { - let unmentioned_fields = variant.fields - .iter() - .map(|field| field.ident.modern()) - .filter(|ident| !used_fields.contains_key(&ident)) - .collect::>(); if unmentioned_fields.len() > 0 { let field_names = if unmentioned_fields.len() == 1 { format!("field `{}`", unmentioned_fields[0]) diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/method/confirm.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/method/confirm.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/method/confirm.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/method/confirm.rs 2018-12-04 23:41:40.000000000 +0000 @@ -210,9 +210,6 @@ target } - /////////////////////////////////////////////////////////////////////////// - // - /// Returns a set of substitutions for the method *receiver* where all type and region /// parameters are instantiated with fresh variables. This substitution does not include any /// parameters declared on the method itself. @@ -291,18 +288,18 @@ self.fcx .autoderef(self.span, self_ty) .include_raw_pointers() - .filter_map(|(ty, _)| { + .filter_map(|(ty, _)| match ty.sty { - ty::Dynamic(ref data, ..) => data.principal().map(|p| closure(self, ty, p)), + ty::Dynamic(ref data, ..) => Some(closure(self, ty, data.principal())), _ => None, } - }) + ) .next() - .unwrap_or_else(|| { + .unwrap_or_else(|| span_bug!(self.span, "self-type `{}` for ObjectPick never dereferenced to an object", self_ty) - }) + ) } fn instantiate_method_substs( @@ -373,9 +370,6 @@ } } - /////////////////////////////////////////////////////////////////////////// - // - // NOTE: this returns the *unnormalized* predicates and method sig. Because of // inference guessing, the predicates and method signature can't be normalized // until we unify the `Self` type. @@ -444,11 +438,10 @@ /// respectively. fn convert_place_derefs_to_mutable(&self) { // Gather up expressions we want to munge. - let mut exprs = Vec::new(); - exprs.push(self.self_expr); + let mut exprs = vec![self.self_expr]; + loop { - let last = exprs[exprs.len() - 1]; - match last.node { + match exprs.last().unwrap().node { hir::ExprKind::Field(ref expr, _) | hir::ExprKind::Index(ref expr, _) | hir::ExprKind::Unary(hir::UnDeref, ref expr) => exprs.push(&expr), diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/method/probe.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/method/probe.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/method/probe.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/method/probe.rs 2018-12-04 23:41:40.000000000 +0000 @@ -17,6 +17,9 @@ use hir::def_id::DefId; use hir::def::Def; use namespace::Namespace; +use rustc::hir; +use rustc::lint; +use rustc::session::config::nightly_options; use rustc::ty::subst::{Subst, Substs}; use rustc::traits::{self, ObligationCause}; use rustc::ty::{self, Ty, ToPolyTraitRef, ToPredicate, TraitRef, TypeFoldable}; @@ -28,8 +31,6 @@ use syntax::ast; use syntax::util::lev_distance::{lev_distance, find_best_match_for_name}; use syntax_pos::{Span, symbol::Symbol}; -use rustc::hir; -use rustc::lint; use std::mem; use std::ops::Deref; use std::rc::Rc; @@ -395,7 +396,7 @@ return_type, inherent_candidates: Vec::new(), extension_candidates: Vec::new(), - impl_dups: FxHashSet(), + impl_dups: FxHashSet::default(), steps: steps, static_candidates: Vec::new(), allow_similar_names: false, @@ -451,10 +452,9 @@ match self_ty.sty { ty::Dynamic(ref data, ..) => { - if let Some(p) = data.principal() { - self.assemble_inherent_candidates_from_object(self_ty, p); - self.assemble_inherent_impl_candidates_for_type(p.def_id()); - } + let p = data.principal(); + self.assemble_inherent_candidates_from_object(self_ty, p); + self.assemble_inherent_impl_candidates_for_type(p.def_id()); } ty::Adt(def, _) => { self.assemble_inherent_impl_candidates_for_type(def.did); @@ -718,7 +718,7 @@ if expr_id == ast::DUMMY_NODE_ID { return Ok(()) } - let mut duplicates = FxHashSet(); + let mut duplicates = FxHashSet::default(); let expr_hir_id = self.tcx.hir.node_to_hir_id(expr_id); let opt_applicable_traits = self.tcx.in_scope_traits(expr_hir_id); if let Some(applicable_traits) = opt_applicable_traits { @@ -735,7 +735,7 @@ } fn assemble_extension_candidates_for_all_traits(&mut self) -> Result<(), MethodError<'tcx>> { - let mut duplicates = FxHashSet(); + let mut duplicates = FxHashSet::default(); for trait_info in suggest::all_traits(self.tcx) { if duplicates.insert(trait_info.def_id) { self.assemble_extension_candidates_for_trait(None, trait_info.def_id)?; @@ -800,7 +800,7 @@ } fn candidate_method_names(&self) -> Vec { - let mut set = FxHashSet(); + let mut set = FxHashSet::default(); let mut names: Vec<_> = self.inherent_candidates .iter() .chain(&self.extension_candidates) @@ -1064,7 +1064,8 @@ "a method with this name may be added to the standard library in the future", ); - // FIXME: This should be a `span_suggestion` instead of `help`. However `self.span` only + // FIXME: This should be a `span_suggestion_with_applicability` instead of `help` + // However `self.span` only // highlights the method name, so we can't use it. Also consider reusing the code from // `report_method_error()`. diag.help(&format!( @@ -1072,9 +1073,9 @@ self.tcx.item_path_str(stable_pick.item.def_id), )); - if ::rustc::session::config::nightly_options::is_nightly_build() { + if nightly_options::is_nightly_build() { for (candidate, feature) in unstable_candidates { - diag.note(&format!( + diag.help(&format!( "add #![feature({})] to the crate attributes to enable `{}`", feature, self.tcx.item_path_str(candidate.item.def_id), @@ -1156,7 +1157,7 @@ // Convert the bounds into obligations. let impl_obligations = traits::predicates_for_generics( - cause.clone(), self.param_env, &impl_bounds); + cause, self.param_env, &impl_bounds); debug!("impl_obligations={:?}", impl_obligations); impl_obligations.into_iter() @@ -1174,7 +1175,7 @@ TraitCandidate(trait_ref) => { let predicate = trait_ref.to_predicate(); let obligation = - traits::Obligation::new(cause.clone(), self.param_env, predicate); + traits::Obligation::new(cause, self.param_env, predicate); if !self.predicate_may_hold(&obligation) { if self.probe(|_| self.select_trait_candidate(trait_ref).is_err()) { // This candidate's primary obligation doesn't even @@ -1254,9 +1255,8 @@ { // Do all probes correspond to the same trait? let container = probes[0].0.item.container; - match container { - ty::TraitContainer(_) => {} - ty::ImplContainer(_) => return None, + if let ty::ImplContainer(_) = container { + return None } if probes[1..].iter().any(|&(p, _)| p.item.container != container) { return None; @@ -1460,7 +1460,7 @@ .filter(|x| { let dist = lev_distance(&*name.as_str(), &x.ident.as_str()); Namespace::from(x.kind) == Namespace::Value && dist > 0 - && dist <= max_dist + && dist <= max_dist }) .collect() } else { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/method/suggest.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/method/suggest.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/method/suggest.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/method/suggest.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,6 +16,7 @@ use hir::Node; use rustc_data_structures::sync::Lrc; use rustc::ty::{self, Ty, TyCtxt, ToPolyTraitRef, ToPredicate, TypeFoldable}; +use rustc::ty::item_path::with_crate_prefix; use hir::def::Def; use hir::def_id::{CRATE_DEF_INDEX, DefId}; use middle::lang_items::FnOnceTraitLangItem; @@ -88,7 +89,6 @@ } let report_candidates = |err: &mut DiagnosticBuilder, mut sources: Vec| { - sources.sort(); sources.dedup(); // Dynamic limit to avoid hiding just one candidate, which is silly. @@ -174,7 +174,7 @@ .map(|arg| print::to_string(print::NO_ANN, |s| s.print_expr(arg))) .collect::>() - .join(", ")).unwrap_or("...".to_owned()))); + .join(", ")).unwrap_or_else(|| "...".to_owned()))); } } } @@ -225,9 +225,9 @@ // ({integer}/{float}). let mut candidates = all_traits(self.tcx) .into_iter() - .filter(|info| { - self.associated_item(info.def_id, item_name, Namespace::Value).is_some() - }); + .filter_map(|info| + self.associated_item(info.def_id, item_name, Namespace::Value) + ); if let (true, false, Some(expr), Some(_)) = (actual.is_numeric(), actual.has_concrete_skeleton(), rcvr_expr, @@ -247,17 +247,20 @@ "f32" }; match expr.node { - hir::ExprKind::Lit(ref lit) => { // numeric literal + hir::ExprKind::Lit(ref lit) => { // numeric literal let snippet = tcx.sess.source_map().span_to_snippet(lit.span) - .unwrap_or("".to_string()); + .unwrap_or_else(|_| "".to_owned()); - err.span_suggestion(lit.span, + err.span_suggestion_with_applicability( + lit.span, &format!("you must specify a concrete type for \ this numeric value, like `{}`", concrete_type), format!("{}_{}", snippet, - concrete_type)); + concrete_type), + Applicability::MaybeIncorrect, + ); } hir::ExprKind::Path(ref qpath) => { // local binding if let &hir::QPath::Resolved(_, ref path) = &qpath { @@ -281,13 +284,14 @@ ty, .. })) => { - err.span_suggestion( + err.span_suggestion_with_applicability( // account for `let x: _ = 42;` // ^^^^ span.to(ty.as_ref().map(|ty| ty.span) .unwrap_or(span)), &msg, format!("{}: {}", snippet, concrete_type), + Applicability::MaybeIncorrect, ); } _ => { @@ -338,8 +342,8 @@ // give a helping note that it has to be called as (x.f)(...). if let Some(expr) = rcvr_expr { for (ty, _) in self.autoderef(span, rcvr_ty) { - match ty.sty { - ty::Adt(def, substs) if !def.is_enum() => { + if let ty::Adt(def, substs) = ty.sty { + if !def.is_enum() { let variant = &def.non_enum_variant(); if let Some(index) = self.tcx.find_field_index(item_name, variant) { let field = &variant.fields[index]; @@ -373,7 +377,6 @@ break; } } - _ => {} } } } else { @@ -513,20 +516,37 @@ } else { "\n" }; - format!("use {};\n{}", self.tcx.item_path_str(*did), additional_newline) + format!( + "use {};\n{}", + with_crate_prefix(|| self.tcx.item_path_str(*did)), + additional_newline + ) }).collect(); - err.span_suggestions(span, &msg, path_strings); + err.span_suggestions_with_applicability( + span, + &msg, + path_strings, + Applicability::MaybeIncorrect, + ); } else { let limit = if candidates.len() == 5 { 5 } else { 4 }; for (i, trait_did) in candidates.iter().take(limit).enumerate() { if candidates.len() > 1 { - msg.push_str(&format!("\ncandidate #{}: `use {};`", - i + 1, - self.tcx.item_path_str(*trait_did))); + msg.push_str( + &format!( + "\ncandidate #{}: `use {};`", + i + 1, + with_crate_prefix(|| self.tcx.item_path_str(*trait_did)) + ) + ); } else { - msg.push_str(&format!("\n`use {};`", - self.tcx.item_path_str(*trait_did))); + msg.push_str( + &format!( + "\n`use {};`", + with_crate_prefix(|| self.tcx.item_path_str(*trait_did)) + ) + ); } } if candidates.len() > limit { @@ -643,8 +663,7 @@ ty::Adt(def, _) => def.did.is_local(), ty::Foreign(did) => did.is_local(), - ty::Dynamic(ref tr, ..) => tr.principal() - .map_or(false, |p| p.def_id().is_local()), + ty::Dynamic(ref tr, ..) => tr.principal().def_id().is_local(), ty::Param(_) => true, @@ -713,12 +732,9 @@ } impl<'v, 'a, 'tcx> itemlikevisit::ItemLikeVisitor<'v> for Visitor<'a, 'tcx> { fn visit_item(&mut self, i: &'v hir::Item) { - match i.node { - hir::ItemKind::Trait(..) => { - let def_id = self.map.local_def_id(i.id); - self.traits.push(def_id); - } - _ => {} + if let hir::ItemKind::Trait(..) = i.node { + let def_id = self.map.local_def_id(i.id); + self.traits.push(def_id); } } @@ -734,7 +750,7 @@ }); // Cross-crate: - let mut external_mods = FxHashSet(); + let mut external_mods = FxHashSet::default(); fn handle_external_def(tcx: TyCtxt, traits: &mut Vec, external_mods: &mut FxHashSet, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -65,7 +65,7 @@ The types of top-level items, which never contain unbound type variables, are stored directly into the `tcx` tables. -n.b.: A type variable is not the same thing as a type parameter. A +N.B.: A type variable is not the same thing as a type parameter. A type variable is rather an "instance" of a type parameter: that is, given a generic function `fn foo(t: T)`: while checking the function `foo`, the type `ty_param(0)` refers to the type `T`, which @@ -95,7 +95,8 @@ use rustc::infer::type_variable::{TypeVariableOrigin}; use rustc::middle::region; use rustc::mir::interpret::{ConstValue, GlobalId}; -use rustc::ty::subst::{CanonicalSubsts, UnpackedKind, Subst, Substs}; +use rustc::ty::subst::{CanonicalUserSubsts, UnpackedKind, Subst, Substs, + UserSelfTy, UserSubsts}; use rustc::traits::{self, ObligationCause, ObligationCauseCode, TraitEngine}; use rustc::ty::{self, Ty, TyCtxt, GenericParamDefKind, Visibility, ToPredicate, RegionKind}; use rustc::ty::adjustment::{Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability}; @@ -154,6 +155,13 @@ mod intrinsic; mod op; +/// The type of a local binding, including the revealed type for anon types. +#[derive(Copy, Clone)] +pub struct LocalTy<'tcx> { + decl_ty: Ty<'tcx>, + revealed_ty: Ty<'tcx> +} + /// A wrapper for InferCtxt's `in_progress_tables` field. #[derive(Copy, Clone)] struct MaybeInProgressTables<'a, 'tcx: 'a> { @@ -180,7 +188,6 @@ } } - /// closures defined within the function. For example: /// /// fn foo() { @@ -195,7 +202,7 @@ tables: MaybeInProgressTables<'a, 'tcx>, - locals: RefCell>>, + locals: RefCell>>, fulfillment_cx: RefCell>>, @@ -656,7 +663,8 @@ } fn register_predicates(&self, obligations: I) - where I: IntoIterator> { + where I: IntoIterator> + { for obligation in obligations { self.register_predicate(obligation); } @@ -815,8 +823,8 @@ } fn used_trait_imports<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - def_id: DefId) - -> Lrc { + def_id: DefId) + -> Lrc { tcx.typeck_tables_of(def_id).used_trait_imports.clone() } @@ -846,7 +854,7 @@ check_abi(tcx, span, fn_sig.abi()); - // Compute the fty from point of view of inside fn. + // Compute the fty from point of view of inside the fn. let fn_sig = tcx.liberate_late_bound_regions(def_id, &fn_sig); let fn_sig = @@ -863,10 +871,19 @@ let expected_type = fcx.normalize_associated_types_in(body.value.span, &expected_type); fcx.require_type_is_sized(expected_type, body.value.span, traits::ConstSized); + let revealed_ty = if tcx.features().impl_trait_in_bindings { + fcx.instantiate_opaque_types_from_value( + id, + &expected_type + ) + } else { + expected_type + }; + // Gather locals in statics (because of block expressions). - GatherLocalsVisitor { fcx: &fcx }.visit_body(body); + GatherLocalsVisitor { fcx: &fcx, parent_id: id, }.visit_body(body); - fcx.check_expr_coercable_to_type(&body.value, expected_type); + fcx.check_expr_coercable_to_type(&body.value, revealed_ty); fcx }; @@ -914,22 +931,26 @@ } struct GatherLocalsVisitor<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { - fcx: &'a FnCtxt<'a, 'gcx, 'tcx> + fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, + parent_id: ast::NodeId, } impl<'a, 'gcx, 'tcx> GatherLocalsVisitor<'a, 'gcx, 'tcx> { - fn assign(&mut self, span: Span, nid: ast::NodeId, ty_opt: Option>) -> Ty<'tcx> { + fn assign(&mut self, span: Span, nid: ast::NodeId, ty_opt: Option>) -> Ty<'tcx> { match ty_opt { None => { // infer the variable's type let var_ty = self.fcx.next_ty_var(TypeVariableOrigin::TypeInference(span)); - self.fcx.locals.borrow_mut().insert(nid, var_ty); + self.fcx.locals.borrow_mut().insert(nid, LocalTy { + decl_ty: var_ty, + revealed_ty: var_ty + }); var_ty } Some(typ) => { // take type that the user specified self.fcx.locals.borrow_mut().insert(nid, typ); - typ + typ.revealed_ty } } } @@ -942,24 +963,34 @@ // Add explicitly-declared locals. fn visit_local(&mut self, local: &'gcx hir::Local) { - let o_ty = match local.ty { + let local_ty = match local.ty { Some(ref ty) => { let o_ty = self.fcx.to_ty(&ty); - let c_ty = self.fcx.inh.infcx.canonicalize_response(&o_ty); - debug!("visit_local: ty.hir_id={:?} o_ty={:?} c_ty={:?}", ty.hir_id, o_ty, c_ty); + let revealed_ty = if self.fcx.tcx.features().impl_trait_in_bindings { + self.fcx.instantiate_opaque_types_from_value( + self.parent_id, + &o_ty + ) + } else { + o_ty + }; + + let c_ty = self.fcx.inh.infcx.canonicalize_response(&revealed_ty); + debug!("visit_local: ty.hir_id={:?} o_ty={:?} revealed_ty={:?} c_ty={:?}", + ty.hir_id, o_ty, revealed_ty, c_ty); self.fcx.tables.borrow_mut().user_provided_tys_mut().insert(ty.hir_id, c_ty); - Some(o_ty) + Some(LocalTy { decl_ty: o_ty, revealed_ty }) }, None => None, }; - self.assign(local.span, local.id, o_ty); + self.assign(local.span, local.id, local_ty); debug!("Local variable {:?} is assigned type {}", local.pat, self.fcx.ty_to_string( - self.fcx.locals.borrow().get(&local.id).unwrap().clone())); + self.fcx.locals.borrow().get(&local.id).unwrap().clone().decl_ty)); intravisit::walk_local(self, local); } @@ -976,7 +1007,7 @@ debug!("Pattern binding {} is assigned to {} with type {:?}", ident, self.fcx.ty_to_string( - self.fcx.locals.borrow().get(&p.id).unwrap().clone()), + self.fcx.locals.borrow().get(&p.id).unwrap().clone().decl_ty), var_ty); } intravisit::walk_pat(self, p); @@ -1027,7 +1058,7 @@ let declared_ret_ty = fn_sig.output(); fcx.require_type_is_sized(declared_ret_ty, decl.output.span(), traits::SizedReturnType); - let revealed_ret_ty = fcx.instantiate_opaque_types_from_return_value(fn_id, &declared_ret_ty); + let revealed_ret_ty = fcx.instantiate_opaque_types_from_value(fn_id, &declared_ret_ty); fcx.ret_coercion = Some(RefCell::new(CoerceMany::new(revealed_ret_ty))); fn_sig = fcx.tcx.mk_fn_sig( fn_sig.inputs().iter().cloned(), @@ -1045,7 +1076,9 @@ fcx.yield_ty = Some(yield_ty); } - GatherLocalsVisitor { fcx: &fcx, }.visit_body(body); + let outer_def_id = fcx.tcx.closure_base_def_id(fcx.tcx.hir.local_def_id(fn_id)); + let outer_node_id = fcx.tcx.hir.as_local_node_id(outer_def_id).unwrap(); + GatherLocalsVisitor { fcx: &fcx, parent_id: outer_node_id, }.visit_body(body); // Add formal parameters. for (arg_ty, arg) in fn_sig.inputs().iter().zip(&body.arguments) { @@ -1119,19 +1152,16 @@ if let Some(term_id) = fcx.tcx.lang_items().termination() { if let Some((id, _, entry_type)) = *fcx.tcx.sess.entry_fn.borrow() { if id == fn_id { - match entry_type { - config::EntryFnType::Main => { - let substs = fcx.tcx.mk_substs_trait(declared_ret_ty, &[]); - let trait_ref = ty::TraitRef::new(term_id, substs); - let return_ty_span = decl.output.span(); - let cause = traits::ObligationCause::new( - return_ty_span, fn_id, ObligationCauseCode::MainFunctionType); - - inherited.register_predicate( - traits::Obligation::new( - cause, param_env, trait_ref.to_predicate())); - }, - config::EntryFnType::Start => {}, + if let config::EntryFnType::Main = entry_type { + let substs = fcx.tcx.mk_substs_trait(declared_ret_ty, &[]); + let trait_ref = ty::TraitRef::new(term_id, substs); + let return_ty_span = decl.output.span(); + let cause = traits::ObligationCause::new( + return_ty_span, fn_id, ObligationCauseCode::MainFunctionType); + + inherited.register_predicate( + traits::Obligation::new( + cause, param_env, trait_ref.to_predicate())); } } } @@ -1274,90 +1304,96 @@ check_packed(tcx, span, def_id); } -pub fn check_item_type<'a,'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item) { - debug!("check_item_type(it.id={}, it.name={})", - it.id, - tcx.item_path_str(tcx.hir.local_def_id(it.id))); +pub fn check_item_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item) { + debug!( + "check_item_type(it.id={}, it.name={})", + it.id, + tcx.item_path_str(tcx.hir.local_def_id(it.id)) + ); let _indenter = indenter(); match it.node { - // Consts can play a role in type-checking, so they are included here. - hir::ItemKind::Static(..) => { - let def_id = tcx.hir.local_def_id(it.id); - tcx.typeck_tables_of(def_id); - maybe_check_static_with_link_section(tcx, def_id, it.span); - } - hir::ItemKind::Const(..) => { - tcx.typeck_tables_of(tcx.hir.local_def_id(it.id)); - } - hir::ItemKind::Enum(ref enum_definition, _) => { - check_enum(tcx, - it.span, - &enum_definition.variants, - it.id); - } - hir::ItemKind::Fn(..) => {} // entirely within check_item_body - hir::ItemKind::Impl(.., ref impl_item_refs) => { - debug!("ItemKind::Impl {} with id {}", it.name, it.id); - let impl_def_id = tcx.hir.local_def_id(it.id); - if let Some(impl_trait_ref) = tcx.impl_trait_ref(impl_def_id) { - check_impl_items_against_trait(tcx, - it.span, - impl_def_id, - impl_trait_ref, - impl_item_refs); - let trait_def_id = impl_trait_ref.def_id; - check_on_unimplemented(tcx, trait_def_id, it); - } - } - hir::ItemKind::Trait(..) => { - let def_id = tcx.hir.local_def_id(it.id); - check_on_unimplemented(tcx, def_id, it); - } - hir::ItemKind::Struct(..) => { - check_struct(tcx, it.id, it.span); - } - hir::ItemKind::Union(..) => { - check_union(tcx, it.id, it.span); - } - hir::ItemKind::Existential(..) | - hir::ItemKind::Ty(..) => { - let def_id = tcx.hir.local_def_id(it.id); - let pty_ty = tcx.type_of(def_id); - let generics = tcx.generics_of(def_id); - check_bounds_are_used(tcx, &generics, pty_ty); - } - hir::ItemKind::ForeignMod(ref m) => { - check_abi(tcx, it.span, m.abi); - - if m.abi == Abi::RustIntrinsic { - for item in &m.items { - intrinsic::check_intrinsic_type(tcx, item); - } - } else if m.abi == Abi::PlatformIntrinsic { - for item in &m.items { - intrinsic::check_platform_intrinsic_type(tcx, item); - } - } else { - for item in &m.items { - let generics = tcx.generics_of(tcx.hir.local_def_id(item.id)); - if generics.params.len() - generics.own_counts().lifetimes != 0 { - let mut err = struct_span_err!(tcx.sess, item.span, E0044, - "foreign items may not have type parameters"); - err.span_label(item.span, "can't have type parameters"); - // FIXME: once we start storing spans for type arguments, turn this into a - // suggestion. - err.help("use specialization instead of type parameters by replacing them \ - with concrete types like `u32`"); - err.emit(); + // Consts can play a role in type-checking, so they are included here. + hir::ItemKind::Static(..) => { + let def_id = tcx.hir.local_def_id(it.id); + tcx.typeck_tables_of(def_id); + maybe_check_static_with_link_section(tcx, def_id, it.span); + } + hir::ItemKind::Const(..) => { + tcx.typeck_tables_of(tcx.hir.local_def_id(it.id)); + } + hir::ItemKind::Enum(ref enum_definition, _) => { + check_enum(tcx, it.span, &enum_definition.variants, it.id); + } + hir::ItemKind::Fn(..) => {} // entirely within check_item_body + hir::ItemKind::Impl(.., ref impl_item_refs) => { + debug!("ItemKind::Impl {} with id {}", it.name, it.id); + let impl_def_id = tcx.hir.local_def_id(it.id); + if let Some(impl_trait_ref) = tcx.impl_trait_ref(impl_def_id) { + check_impl_items_against_trait( + tcx, + it.span, + impl_def_id, + impl_trait_ref, + impl_item_refs, + ); + let trait_def_id = impl_trait_ref.def_id; + check_on_unimplemented(tcx, trait_def_id, it); + } + } + hir::ItemKind::Trait(..) => { + let def_id = tcx.hir.local_def_id(it.id); + check_on_unimplemented(tcx, def_id, it); + } + hir::ItemKind::Struct(..) => { + check_struct(tcx, it.id, it.span); + } + hir::ItemKind::Union(..) => { + check_union(tcx, it.id, it.span); + } + hir::ItemKind::Existential(..) | hir::ItemKind::Ty(..) => { + let def_id = tcx.hir.local_def_id(it.id); + let pty_ty = tcx.type_of(def_id); + let generics = tcx.generics_of(def_id); + check_bounds_are_used(tcx, &generics, pty_ty); + } + hir::ItemKind::ForeignMod(ref m) => { + check_abi(tcx, it.span, m.abi); + + if m.abi == Abi::RustIntrinsic { + for item in &m.items { + intrinsic::check_intrinsic_type(tcx, item); + } + } else if m.abi == Abi::PlatformIntrinsic { + for item in &m.items { + intrinsic::check_platform_intrinsic_type(tcx, item); } + } else { + for item in &m.items { + let generics = tcx.generics_of(tcx.hir.local_def_id(item.id)); + if generics.params.len() - generics.own_counts().lifetimes != 0 { + let mut err = struct_span_err!( + tcx.sess, + item.span, + E0044, + "foreign items may not have type parameters" + ); + err.span_label(item.span, "can't have type parameters"); + // FIXME: once we start storing spans for type arguments, turn this into a + // suggestion. + err.help( + "use specialization instead of type parameters by replacing them \ + with concrete types like `u32`", + ); + err.emit(); + } - if let hir::ForeignItemKind::Fn(ref fn_decl, _, _) = item.node { - require_c_abi_if_variadic(tcx, fn_decl, m.abi, item.span); + if let hir::ForeignItemKind::Fn(ref fn_decl, _, _) = item.node { + require_c_abi_if_variadic(tcx, fn_decl, m.abi, item.span); + } } } } - } - _ => {/* nothing to do */ } + _ => { /* nothing to do */ } } } @@ -1503,10 +1539,10 @@ impl_trait_ref); } else { let mut err = struct_span_err!(tcx.sess, impl_item.span, E0323, - "item `{}` is an associated const, \ - which doesn't match its trait `{}`", - ty_impl_item.ident, - impl_trait_ref); + "item `{}` is an associated const, \ + which doesn't match its trait `{}`", + ty_impl_item.ident, + impl_trait_ref); err.span_label(impl_item.span, "does not match trait"); // We can only get the spans from local trait definition // Same for E0324 and E0325 @@ -1527,10 +1563,10 @@ trait_span); } else { let mut err = struct_span_err!(tcx.sess, impl_item.span, E0324, - "item `{}` is an associated method, \ - which doesn't match its trait `{}`", - ty_impl_item.ident, - impl_trait_ref); + "item `{}` is an associated method, \ + which doesn't match its trait `{}`", + ty_impl_item.ident, + impl_trait_ref); err.span_label(impl_item.span, "does not match trait"); if let Some(trait_span) = tcx.hir.span_if_local(ty_trait_item.def_id) { err.span_label(trait_span, "item in trait"); @@ -1546,10 +1582,10 @@ } } else { let mut err = struct_span_err!(tcx.sess, impl_item.span, E0325, - "item `{}` is an associated type, \ - which doesn't match its trait `{}`", - ty_impl_item.ident, - impl_trait_ref); + "item `{}` is an associated type, \ + which doesn't match its trait `{}`", + ty_impl_item.ident, + impl_trait_ref); err.span_label(impl_item.span, "does not match trait"); if let Some(trait_span) = tcx.hir.span_if_local(ty_trait_item.def_id) { err.span_label(trait_span, "item in trait"); @@ -1587,8 +1623,8 @@ let mut err = struct_span_err!(tcx.sess, impl_span, E0046, "not all trait items implemented, missing: `{}`", missing_items.iter() - .map(|trait_item| trait_item.ident.to_string()) - .collect::>().join("`, `")); + .map(|trait_item| trait_item.ident.to_string()) + .collect::>().join("`, `")); err.span_label(impl_span, format!("missing `{}` in implementation", missing_items.iter() .map(|trait_item| trait_item.ident.to_string()) @@ -1646,8 +1682,8 @@ pub fn check_simd<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sp: Span, def_id: DefId) { let t = tcx.type_of(def_id); - match t.sty { - ty::Adt(def, substs) if def.is_struct() => { + if let ty::Adt(def, substs) = t.sty { + if def.is_struct() { let fields = &def.non_enum_variant().fields; if fields.is_empty() { span_err!(tcx.sess, sp, E0075, "SIMD vector cannot be empty"); @@ -1662,7 +1698,7 @@ } match e.sty { ty::Param(_) => { /* struct(T, T, T, T) is ok */ } - _ if e.is_machine() => { /* struct(u8, u8, u8, u8) is ok */ } + _ if e.is_machine() => { /* struct(u8, u8, u8, u8) is ok */ } _ => { span_err!(tcx.sess, sp, E0077, "SIMD vector element type should be machine type"); @@ -1670,7 +1706,6 @@ } } } - _ => () } } @@ -1706,8 +1741,8 @@ debug!("check_packed_inner: {:?} is recursive", t); return false; } - match t.sty { - ty::Adt(def, substs) if def.is_struct() || def.is_union() => { + if let ty::Adt(def, substs) = t.sty { + if def.is_struct() || def.is_union() { if tcx.adt_def(def.did).repr.align > 0 { return true; } @@ -1715,19 +1750,15 @@ stack.push(def_id); for field in &def.non_enum_variant().fields { let f = field.ty(tcx, substs); - match f.sty { - ty::Adt(def, _) => { - if check_packed_inner(tcx, def.did, stack) { - return true; - } + if let ty::Adt(def, _) = f.sty { + if check_packed_inner(tcx, def.did, stack) { + return true; } - _ => () } } // only need to pop if not early out stack.pop(); } - _ => () } false } @@ -1739,7 +1770,7 @@ } // For each field, figure out if it's known to be a ZST and align(1) - let field_infos: Vec<_> = adt.non_enum_variant().fields.iter().map(|field| { + let field_infos = adt.non_enum_variant().fields.iter().map(|field| { let ty = field.ty(tcx, Substs::identity_for_item(tcx, field.did)); let param_env = tcx.param_env(field.did); let layout = tcx.layout_of(param_env.and(ty)); @@ -1748,19 +1779,19 @@ let zst = layout.map(|layout| layout.is_zst()).unwrap_or(false); let align1 = layout.map(|layout| layout.align.abi() == 1).unwrap_or(false); (span, zst, align1) - }).collect(); + }); - let non_zst_fields = field_infos.iter().filter(|(_span, zst, _align1)| !*zst); + let non_zst_fields = field_infos.clone().filter(|(_span, zst, _align1)| !*zst); let non_zst_count = non_zst_fields.clone().count(); if non_zst_count != 1 { - let field_spans: Vec<_> = non_zst_fields.map(|(span, _zst, _align1)| *span).collect(); + let field_spans: Vec<_> = non_zst_fields.map(|(span, _zst, _align1)| span).collect(); struct_span_err!(tcx.sess, sp, E0690, "transparent struct needs exactly one non-zero-sized field, but has {}", - non_zst_count) + non_zst_count) .span_note(field_spans, "non-zero-sized field") .emit(); } - for &(span, zst, align1) in &field_infos { + for (span, zst, align1) in field_infos { if zst && !align1 { span_err!(tcx.sess, span, E0691, "zero-sized field in transparent struct has alignment larger than 1"); @@ -1805,7 +1836,7 @@ } } - let mut disr_vals: Vec> = Vec::new(); + let mut disr_vals: Vec> = Vec::with_capacity(vs.len()); for (discr, v) in def.discriminants(tcx).zip(vs) { // Check for duplicate discriminant values if let Some(i) = disr_vals.iter().position(|&x| x.val == discr.val) { @@ -1845,14 +1876,17 @@ let index = generics.param_def_id_to_index[&def_id]; ty::GenericPredicates { parent: None, - predicates: self.param_env.caller_bounds.iter().filter(|predicate| { - match **predicate { - ty::Predicate::Trait(ref data) => { - data.skip_binder().self_ty().is_param(index) + predicates: self.param_env.caller_bounds.iter().filter_map(|&predicate| { + match predicate { + ty::Predicate::Trait(ref data) + if data.skip_binder().self_ty().is_param(index) => { + // HACK(eddyb) should get the original `Span`. + let span = tcx.def_span(def_id); + Some((predicate, span)) } - _ => false + _ => None } - }).cloned().collect() + }).collect() } } @@ -2040,14 +2074,11 @@ format!("{:?}", self_ptr) } - pub fn local_ty(&self, span: Span, nid: ast::NodeId) -> Ty<'tcx> { - match self.locals.borrow().get(&nid) { - Some(&t) => t, - None => { - span_bug!(span, "no type for local variable {}", - self.tcx.hir.node_to_string(nid)); - } - } + pub fn local_ty(&self, span: Span, nid: ast::NodeId) -> LocalTy<'tcx> { + self.locals.borrow().get(&nid).cloned().unwrap_or_else(|| + span_bug!(span, "no type for local variable {}", + self.tcx.hir.node_to_string(nid)) + ) } #[inline] @@ -2106,7 +2137,10 @@ method.substs[i] } }); - self.infcx.canonicalize_response(&just_method_substs) + self.infcx.canonicalize_response(&UserSubsts { + substs: just_method_substs, + user_self_ty: None, // not relevant here + }) }); debug!("write_method_call: user_substs = {:?}", user_substs); @@ -2133,15 +2167,30 @@ /// This should be invoked **before any unifications have /// occurred**, so that annotations like `Vec<_>` are preserved /// properly. - pub fn write_user_substs_from_substs(&self, hir_id: hir::HirId, substs: &'tcx Substs<'tcx>) { + pub fn write_user_substs_from_substs( + &self, + hir_id: hir::HirId, + substs: &'tcx Substs<'tcx>, + user_self_ty: Option>, + ) { + debug!( + "write_user_substs_from_substs({:?}, {:?}) in fcx {}", + hir_id, + substs, + self.tag(), + ); + if !substs.is_noop() { - let user_substs = self.infcx.canonicalize_response(&substs); + let user_substs = self.infcx.canonicalize_response(&UserSubsts { + substs, + user_self_ty, + }); debug!("instantiate_value_path: user_substs = {:?}", user_substs); self.write_user_substs(hir_id, user_substs); } } - pub fn write_user_substs(&self, hir_id: hir::HirId, substs: CanonicalSubsts<'tcx>) { + pub fn write_user_substs(&self, hir_id: hir::HirId, substs: CanonicalUserSubsts<'tcx>) { debug!( "write_user_substs({:?}, {:?}) in fcx {}", hir_id, @@ -2225,25 +2274,22 @@ result } - /// Replace the opaque types from the return value of the - /// function with type variables and records the `OpaqueTypeMap` for - /// later use during writeback. See + /// Replace the opaque types from the given value with type variables, + /// and records the `OpaqueTypeMap` for later use during writeback. See /// `InferCtxt::instantiate_opaque_types` for more details. - fn instantiate_opaque_types_from_return_value>( + fn instantiate_opaque_types_from_value>( &self, - fn_id: ast::NodeId, + parent_id: ast::NodeId, value: &T, ) -> T { - let fn_def_id = self.tcx.hir.local_def_id(fn_id); - debug!( - "instantiate_opaque_types_from_return_value(fn_def_id={:?}, value={:?})", - fn_def_id, - value - ); + let parent_def_id = self.tcx.hir.local_def_id(parent_id); + debug!("instantiate_opaque_types_from_value(parent_def_id={:?}, value={:?})", + parent_def_id, + value); let (value, opaque_type_map) = self.register_infer_ok_obligations( self.instantiate_opaque_types( - fn_def_id, + parent_def_id, self.body_id, self.param_env, value, @@ -2311,6 +2357,24 @@ t } + pub fn to_ty_saving_user_provided_ty(&self, ast_ty: &hir::Ty) -> Ty<'tcx> { + let ty = self.to_ty(ast_ty); + + // If the type given by the user has free regions, save it for + // later, since NLL would like to enforce those. Also pass in + // types that involve projections, since those can resolve to + // `'static` bounds (modulo #54940, which hopefully will be + // fixed by the time you see this comment, dear reader, + // although I have my doubts). Other sorts of things are + // already sufficiently enforced with erased regions. =) + if ty.has_free_regions() || ty.has_projections() { + let c_ty = self.infcx.canonicalize_response(&ty); + self.tables.borrow_mut().user_provided_tys_mut().insert(ast_ty.hir_id, c_ty); + } + + ty + } + pub fn node_ty(&self, id: hir::HirId) -> Ty<'tcx> { match self.tables.borrow().node_types().get(id) { Some(&t) => t, @@ -2339,8 +2403,7 @@ } /// Registers obligations that all types appearing in `substs` are well-formed. - pub fn add_wf_bounds(&self, substs: &Substs<'tcx>, expr: &hir::Expr) - { + pub fn add_wf_bounds(&self, substs: &Substs<'tcx>, expr: &hir::Expr) { for ty in substs.types() { self.register_wf_obligation(ty, expr.span, traits::MiscObligation); } @@ -2387,8 +2450,7 @@ substs: &Substs<'tcx>) -> Ty<'tcx> { - self.normalize_associated_types_in(span, - &field.ty(self.tcx, substs)) + self.normalize_associated_types_in(span, &field.ty(self.tcx, substs)) } fn check_casts(&self) { @@ -2439,64 +2501,8 @@ /// Select as many obligations as we can at present. fn select_obligations_where_possible(&self, fallback_has_occurred: bool) { - match self.fulfillment_cx.borrow_mut().select_where_possible(self) { - Ok(()) => { } - Err(errors) => { - self.report_fulfillment_errors(&errors, self.inh.body_id, fallback_has_occurred); - }, - } - } - - fn is_place_expr(&self, expr: &hir::Expr) -> bool { - match expr.node { - hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) => { - match path.def { - Def::Local(..) | Def::Upvar(..) | Def::Static(..) | Def::Err => true, - _ => false, - } - } - - hir::ExprKind::Type(ref e, _) => { - self.is_place_expr(e) - } - - hir::ExprKind::Unary(hir::UnDeref, _) | - hir::ExprKind::Field(..) | - hir::ExprKind::Index(..) => { - true - } - - // Partially qualified paths in expressions can only legally - // refer to associated items which are always rvalues. - hir::ExprKind::Path(hir::QPath::TypeRelative(..)) | - - hir::ExprKind::Call(..) | - hir::ExprKind::MethodCall(..) | - hir::ExprKind::Struct(..) | - hir::ExprKind::Tup(..) | - hir::ExprKind::If(..) | - hir::ExprKind::Match(..) | - hir::ExprKind::Closure(..) | - hir::ExprKind::Block(..) | - hir::ExprKind::Repeat(..) | - hir::ExprKind::Array(..) | - hir::ExprKind::Break(..) | - hir::ExprKind::Continue(..) | - hir::ExprKind::Ret(..) | - hir::ExprKind::While(..) | - hir::ExprKind::Loop(..) | - hir::ExprKind::Assign(..) | - hir::ExprKind::InlineAsm(..) | - hir::ExprKind::AssignOp(..) | - hir::ExprKind::Lit(_) | - hir::ExprKind::Unary(..) | - hir::ExprKind::Box(..) | - hir::ExprKind::AddrOf(..) | - hir::ExprKind::Binary(..) | - hir::ExprKind::Yield(..) | - hir::ExprKind::Cast(..) => { - false - } + if let Err(errors) = self.fulfillment_cx.borrow_mut().select_where_possible(self) { + self.report_fulfillment_errors(&errors, self.inh.body_id, fallback_has_occurred); } } @@ -2738,17 +2744,16 @@ let expected_arg_count = fn_inputs.len(); let param_count_error = |expected_count: usize, - arg_count: usize, - error_code: &str, - variadic: bool, - sugg_unit: bool| { + arg_count: usize, + error_code: &str, + variadic: bool, + sugg_unit: bool| { let mut err = tcx.sess.struct_span_err_with_code(sp, - &format!("this function takes {}{} parameter{} but {} parameter{} supplied", + &format!("this function takes {}{} but {} {} supplied", if variadic {"at least "} else {""}, - expected_count, - if expected_count == 1 {""} else {"s"}, - arg_count, - if arg_count == 1 {" was"} else {"s were"}), + potentially_plural_count(expected_count, "parameter"), + potentially_plural_count(arg_count, "parameter"), + if arg_count == 1 {"was"} else {"were"}), DiagnosticId::Error(error_code.to_owned())); if let Some(def_s) = def_span.map(|sp| tcx.sess.source_map().def_span(sp)) { @@ -2764,10 +2769,9 @@ String::from("()"), Applicability::MachineApplicable); } else { - err.span_label(sp, format!("expected {}{} parameter{}", - if variadic {"at least "} else {""}, - expected_count, - if expected_count == 1 {""} else {"s"})); + err.span_label(sp, format!("expected {}{}", + if variadic {"at least "} else {""}, + potentially_plural_count(expected_count, "parameter"))); } err.emit(); }; @@ -2889,7 +2893,7 @@ let coerce_ty = expected.only_has_type(self).unwrap_or(formal_ty); // We're processing function arguments so we definitely want to use // two-phase borrows. - self.demand_coerce(&arg, checked_ty, coerce_ty, AllowTwoPhase::Yes); + self.demand_coerce(&arg, checked_ty, coerce_ty, AllowTwoPhase::Yes); // 3. Relate the expected type and the formal one, // if the expected type was used for the coercion. @@ -2933,7 +2937,7 @@ } fn err_args(&self, len: usize) -> Vec> { - (0..len).map(|_| self.tcx.types.err).collect() + vec![self.tcx.types.err; len] } // AST fragment checking @@ -2948,7 +2952,7 @@ ast::LitKind::Str(..) => tcx.mk_static_str(), ast::LitKind::ByteStr(ref v) => { tcx.mk_imm_ref(tcx.types.re_static, - tcx.mk_array(tcx.types.u8, v.len() as u64)) + tcx.mk_array(tcx.types.u8, v.len() as u64)) } ast::LitKind::Byte(_) => tcx.types.u8, ast::LitKind::Char(_) => tcx.types.char, @@ -3017,23 +3021,22 @@ if let Some(mut err) = self.demand_suptype_diag(expr.span, expected_ty, ty) { // Add help to type error if this is an `if` condition with an assignment - match (expected, &expr.node) { - (ExpectIfCondition, &hir::ExprKind::Assign(ref lhs, ref rhs)) => { - let msg = "try comparing for equality"; - if let (Ok(left), Ok(right)) = ( - self.tcx.sess.source_map().span_to_snippet(lhs.span), - self.tcx.sess.source_map().span_to_snippet(rhs.span)) - { - err.span_suggestion_with_applicability( - expr.span, - msg, - format!("{} == {}", left, right), - Applicability::MaybeIncorrect); - } else { - err.help(msg); - } + if let (ExpectIfCondition, &hir::ExprKind::Assign(ref lhs, ref rhs)) + = (expected, &expr.node) + { + let msg = "try comparing for equality"; + if let (Ok(left), Ok(right)) = ( + self.tcx.sess.source_map().span_to_snippet(lhs.span), + self.tcx.sess.source_map().span_to_snippet(rhs.span)) + { + err.span_suggestion_with_applicability( + expr.span, + msg, + format!("{} == {}", left, right), + Applicability::MaybeIncorrect); + } else { + err.help(msg); } - _ => (), } err.emit(); } @@ -3048,7 +3051,8 @@ self.demand_coerce(expr, ty, expected, AllowTwoPhase::No) } - fn check_expr_with_hint(&self, expr: &'gcx hir::Expr, + fn check_expr_with_hint(&self, + expr: &'gcx hir::Expr, expected: Ty<'tcx>) -> Ty<'tcx> { self.check_expr_with_expectation(expr, ExpectHasType(expected)) } @@ -3129,7 +3133,7 @@ Ok(formal_args.iter().map(|ty| { self.resolve_type_vars_if_possible(ty) }).collect()) - }).unwrap_or(Vec::new()); + }).unwrap_or_default(); debug!("expected_inputs_for_expected_output(formal={:?} -> {:?}, expected={:?} -> {:?})", formal_args, formal_ret, expect_args, expected_ret); @@ -3197,7 +3201,6 @@ return_expr_ty); } - // A generic function for checking the then and else in an if // or if-else. fn check_then_else(&self, @@ -3321,8 +3324,8 @@ self.tcx().types.err } else if self.method_exists(field, expr_t, expr.id, true) { type_error_struct!(self.tcx().sess, field.span, expr_t, E0615, - "attempted to take value of method `{}` on type `{}`", - field, expr_t) + "attempted to take value of method `{}` on type `{}`", + field, expr_t) .help("maybe a `()` to call it is missing?") .emit(); self.tcx().types.err @@ -3347,11 +3350,34 @@ } }; } + ty::Array(_, len) => { + if let (Some(len), Ok(user_index)) = ( + len.assert_usize(self.tcx), + field.as_str().parse::() + ) { + let base = self.tcx.hir.node_to_pretty_string(base.id); + let help = "instead of using tuple indexing, use array indexing"; + let suggestion = format!("{}[{}]", base, field); + let applicability = if len < user_index { + Applicability::MachineApplicable + } else { + Applicability::MaybeIncorrect + }; + err.span_suggestion_with_applicability( + expr.span, help, suggestion, applicability + ); + } + } ty::RawPtr(..) => { let base = self.tcx.hir.node_to_pretty_string(base.id); let msg = format!("`{}` is a native pointer; try dereferencing it", base); let suggestion = format!("(*{}).{}", base, field); - err.span_suggestion(field.span, &msg, suggestion); + err.span_suggestion_with_applicability( + field.span, + &msg, + suggestion, + Applicability::MaybeIncorrect, + ); } _ => {} } @@ -3384,14 +3410,12 @@ } fn available_field_names(&self, variant: &'tcx ty::VariantDef) -> Vec { - let mut available = Vec::new(); - for field in variant.fields.iter() { + variant.fields.iter().filter(|field| { let def_scope = self.tcx.adjust_ident(field.ident, variant.did, self.body_id).1; - if field.vis.is_accessible_from(def_scope, self.tcx) { - available.push(field.ident.name); - } - } - available + field.vis.is_accessible_from(def_scope, self.tcx) + }) + .map(|field| field.ident.name) + .collect() } fn name_series_display(&self, names: Vec) -> String { @@ -3423,13 +3447,13 @@ |actual| match ty.sty { ty::Adt(adt, ..) if adt.is_enum() => { struct_span_err!(self.tcx.sess, field.ident.span, E0559, - "{} `{}::{}` has no field named `{}`", - kind_name, actual, variant.name, field.ident) + "{} `{}::{}` has no field named `{}`", + kind_name, actual, variant.name, field.ident) } _ => { struct_span_err!(self.tcx.sess, field.ident.span, E0560, - "{} `{}` has no field named `{}`", - kind_name, actual, field.ident) + "{} `{}` has no field named `{}`", + kind_name, actual, field.ident) } }, ty); @@ -3486,12 +3510,12 @@ _ => span_bug!(span, "non-ADT passed to check_expr_struct_fields") }; - let mut remaining_fields = FxHashMap(); + let mut remaining_fields = FxHashMap::default(); for (i, field) in variant.fields.iter().enumerate() { remaining_fields.insert(field.ident.modern(), (i, field)); } - let mut seen_fields = FxHashMap(); + let mut seen_fields = FxHashMap::default(); let mut error_happened = false; @@ -3514,10 +3538,10 @@ error_happened = true; if let Some(prev_span) = seen_fields.get(&ident) { let mut err = struct_span_err!(self.tcx.sess, - field.ident.span, - E0062, - "field `{}` specified more than once", - ident); + field.ident.span, + E0062, + "field `{}` specified more than once", + ident); err.span_label(field.ident.span, "used more than once"); err.span_label(*prev_span, format!("first use of `{}`", ident)); @@ -3581,11 +3605,8 @@ for field in fields { self.check_expr(&field.expr); } - match *base_expr { - Some(ref base) => { - self.check_expr(&base); - }, - None => {} + if let Some(ref base) = *base_expr { + self.check_expr(&base); } } @@ -3626,7 +3647,7 @@ if let Some((variant, did, substs)) = variant { debug!("check_struct_path: did={:?} substs={:?}", did, substs); let hir_id = self.tcx.hir.node_to_hir_id(node_id); - self.write_user_substs_from_substs(hir_id, substs); + self.write_user_substs_from_substs(hir_id, substs, None); // Check bounds on type arguments used in the path. let bounds = self.instantiate_bounds(path_span, did, substs); @@ -3716,9 +3737,9 @@ /// that there are actually multiple representations for `Error`, so avoid /// that when err needs to be handled differently. fn check_expr_with_expectation_and_needs(&self, - expr: &'gcx hir::Expr, - expected: Expectation<'tcx>, - needs: Needs) -> Ty<'tcx> { + expr: &'gcx hir::Expr, + expected: Expectation<'tcx>, + needs: Needs) -> Ty<'tcx> { debug!(">> typechecking: expr={:?} expected={:?}", expr, expected); @@ -3762,10 +3783,19 @@ ty } - fn check_expr_kind(&self, - expr: &'gcx hir::Expr, - expected: Expectation<'tcx>, - needs: Needs) -> Ty<'tcx> { + fn check_expr_kind( + &self, + expr: &'gcx hir::Expr, + expected: Expectation<'tcx>, + needs: Needs + ) -> Ty<'tcx> { + debug!( + "check_expr_kind(expr={:?}, expected={:?}, needs={:?})", + expr, + expected, + needs, + ); + let tcx = self.tcx; let id = expr.id; match expr.node { @@ -3804,8 +3834,8 @@ _ => Needs::None }; let mut oprnd_t = self.check_expr_with_expectation_and_needs(&oprnd, - expected_inner, - needs); + expected_inner, + needs); if !oprnd_t.references_error() { oprnd_t = self.structurally_resolved_type(expr.span, oprnd_t); @@ -3835,8 +3865,8 @@ self.write_method_call(expr.hir_id, method); } else { type_error_struct!(tcx.sess, expr.span, oprnd_t, E0614, - "type `{}` cannot be dereferenced", - oprnd_t).emit(); + "type `{}` cannot be dereferenced", + oprnd_t).emit(); oprnd_t = tcx.types.err; } } @@ -3862,7 +3892,7 @@ let hint = expected.only_has_type(self).map_or(NoExpectation, |ty| { match ty.sty { ty::Ref(_, ty, _) | ty::RawPtr(ty::TypeAndMut { ty, .. }) => { - if self.is_place_expr(&oprnd) { + if oprnd.is_place_expr() { // Places may legitimately have unsized types. // For example, dereferences of a fat pointer and // the last field of a struct can be unsized. @@ -3915,11 +3945,8 @@ ty } hir::ExprKind::InlineAsm(_, ref outputs, ref inputs) => { - for output in outputs { - self.check_expr(output); - } - for input in inputs { - self.check_expr(input); + for expr in outputs.iter().chain(inputs.iter()) { + self.check_expr(expr); } tcx.mk_unit() } @@ -4018,7 +4045,7 @@ hir::ExprKind::Ret(ref expr_opt) => { if self.ret_coercion.is_none() { struct_span_err!(self.tcx.sess, expr.span, E0572, - "return statement outside of function body").emit(); + "return statement outside of function body").emit(); } else if let Some(ref e) = *expr_opt { self.check_return_expr(e); } else { @@ -4041,7 +4068,7 @@ _ => { // Only check this if not in an `if` condition, as the // mistyped comparison help is more appropriate. - if !self.is_place_expr(&lhs) { + if !lhs.is_place_expr() { struct_span_err!(self.tcx.sess, expr.span, E0070, "invalid left-hand side expression") .span_label(expr.span, "left-hand of expression not valid") @@ -4060,7 +4087,7 @@ } hir::ExprKind::If(ref cond, ref then_expr, ref opt_else_expr) => { self.check_then_else(&cond, then_expr, opt_else_expr.as_ref().map(|e| &**e), - expr.span, expected) + expr.span, expected) } hir::ExprKind::While(ref cond, ref body, _) => { let ctxt = BreakableCtxt { @@ -4124,7 +4151,7 @@ // [1] self.tcx.sess.delay_span_bug(body.span, "no coercion, but loop may not break"); } - ctxt.coerce.map(|c| c.complete(self)).unwrap_or(self.tcx.mk_unit()) + ctxt.coerce.map(|c| c.complete(self)).unwrap_or_else(|| self.tcx.mk_unit()) } hir::ExprKind::Match(ref discrim, ref arms, match_src) => { self.check_match(expr, &discrim, arms, expected, match_src) @@ -4144,7 +4171,7 @@ hir::ExprKind::Cast(ref e, ref t) => { // Find the type of `e`. Supply hints based on the type we are casting to, // if appropriate. - let t_cast = self.to_ty(t); + let t_cast = self.to_ty_saving_user_provided_ty(t); let t_cast = self.resolve_type_vars_if_possible(&t_cast); let t_expr = self.check_expr_with_expectation(e, ExpectCastableToType(t_cast)); let t_cast = self.resolve_type_vars_if_possible(&t_cast); @@ -4167,7 +4194,7 @@ } } hir::ExprKind::Type(ref e, ref t) => { - let ty = self.to_ty(&t); + let ty = self.to_ty_saving_user_provided_ty(&t); self.check_expr_eq_type(&e, ty); ty } @@ -4336,7 +4363,7 @@ } if needs_note { err.help("to access tuple elements, use tuple indexing \ - syntax (e.g. `tuple.0`)"); + syntax (e.g. `tuple.0`)"); } } err.emit(); @@ -4352,7 +4379,7 @@ } None => { struct_span_err!(self.tcx.sess, expr.span, E0627, - "yield statement outside of generator literal").emit(); + "yield statement outside of generator literal").emit(); } } tcx.mk_unit() @@ -4448,7 +4475,7 @@ // See #44848. let ref_bindings = local.pat.contains_explicit_ref_binding(); - let local_ty = self.local_ty(init.span, local.id); + let local_ty = self.local_ty(init.span, local.id).revealed_ty; if let Some(m) = ref_bindings { // Somewhat subtle: if we have a `ref` binding in the pattern, // we want to avoid introducing coercions for the RHS. This is @@ -4466,8 +4493,8 @@ } } - pub fn check_decl_local(&self, local: &'gcx hir::Local) { - let t = self.local_ty(local.span, local.id); + pub fn check_decl_local(&self, local: &'gcx hir::Local) { + let t = self.local_ty(local.span, local.id).decl_ty; self.write_ty(local.hir_id, t); if let Some(ref init) = local.init { @@ -4490,11 +4517,8 @@ // Don't do all the complex logic below for DeclItem. match stmt.node { hir::StmtKind::Decl(ref decl, _) => { - match decl.node { - hir::DeclKind::Local(_) => {} - hir::DeclKind::Item(_) => { - return; - } + if let hir::DeclKind::Item(_) = decl.node { + return } } hir::StmtKind::Expr(..) | hir::StmtKind::Semi(..) => {} @@ -4719,37 +4743,39 @@ found: Ty<'tcx>, ) { if let Some((sp, msg, suggestion)) = self.check_ref(expr, found, expected) { - err.span_suggestion(sp, msg, suggestion); + err.span_suggestion_with_applicability( + sp, + msg, + suggestion, + Applicability::MachineApplicable, + ); } else if !self.check_for_cast(err, expr, found, expected) { let methods = self.get_conversion_methods(expr.span, expected, found); if let Ok(expr_text) = self.sess().source_map().span_to_snippet(expr.span) { - let suggestions = iter::repeat(expr_text).zip(methods.iter()) + let suggestions = iter::repeat(&expr_text).zip(methods.iter()) .filter_map(|(receiver, method)| { let method_call = format!(".{}()", method.ident); if receiver.ends_with(&method_call) { None // do not suggest code that is already there (#53348) } else { - /* - methods defined in `method_call_list` will overwrite - `.clone()` in copy of `receiver` - */ let method_call_list = [".to_vec()", ".to_string()"]; if receiver.ends_with(".clone()") - && method_call_list.contains(&method_call.as_str()){ - // created copy of `receiver` because we don't want other - // suggestion to get affected - let mut new_receiver = receiver.clone(); - let max_len = new_receiver.rfind(".").unwrap(); - new_receiver.truncate(max_len); - Some(format!("{}{}", new_receiver, method_call)) + && method_call_list.contains(&method_call.as_str()) { + let max_len = receiver.rfind(".").unwrap(); + Some(format!("{}{}", &receiver[..max_len], method_call)) } else { Some(format!("{}{}", receiver, method_call)) } } - }) .collect::>(); + }).collect::>(); if !suggestions.is_empty() { - err.span_suggestions(expr.span, "try using a conversion method", suggestions); + err.span_suggestions_with_applicability( + expr.span, + "try using a conversion method", + suggestions, + Applicability::MaybeIncorrect, + ); } } } @@ -4794,7 +4820,6 @@ } } - /// A possible error is to forget to add a return type that is needed: /// /// ``` @@ -4990,14 +5015,17 @@ span: Span, node_id: ast::NodeId) -> (Ty<'tcx>, Def) { - debug!("instantiate_value_path(path={:?}, def={:?}, node_id={})", - segments, - def, - node_id); + debug!( + "instantiate_value_path(segments={:?}, self_ty={:?}, def={:?}, node_id={})", + segments, + self_ty, + def, + node_id, + ); let path_segs = self.def_ids_for_path_segments(segments, def); - let mut ufcs_associated = None; + let mut user_self_ty = None; match def { Def::Method(def_id) | Def::AssociatedConst(def_id) => { @@ -5006,12 +5034,20 @@ ty::TraitContainer(trait_did) => { callee::check_legal_trait_for_method_call(self.tcx, span, trait_did) } - ty::ImplContainer(_) => {} - } - if segments.len() == 1 { - // `::assoc` will end up here, and so can `T::assoc`. - let self_ty = self_ty.expect("UFCS sugared assoc missing Self"); - ufcs_associated = Some((container, self_ty)); + ty::ImplContainer(impl_def_id) => { + if segments.len() == 1 { + // `::assoc` will end up here, and so + // can `T::assoc`. It this came from an + // inherent impl, we need to record the + // `T` for posterity (see `UserSelfTy` for + // details). + let self_ty = self_ty.expect("UFCS sugared assoc missing Self"); + user_self_ty = Some(UserSelfTy { + impl_def_id, + self_ty, + }); + } + } } } _ => {} @@ -5036,7 +5072,7 @@ match def { Def::Local(nid) | Def::Upvar(nid, ..) => { - let ty = self.local_ty(span, nid); + let ty = self.local_ty(span, nid).decl_ty; let ty = self.normalize_associated_types_in(span, &ty); self.write_ty(self.tcx.hir.node_to_hir_id(node_id), ty); return (ty, def); @@ -5154,7 +5190,7 @@ } else { // If no type arguments were provided, we have to infer them. // This case also occurs as a result of some malformed input, e.g. - // a lifetime argument being given instead of a type paramter. + // a lifetime argument being given instead of a type parameter. // Using inference instead of `Error` gives better error messages. self.var_for_def(span, param) } @@ -5165,6 +5201,10 @@ assert!(!substs.has_escaping_regions()); assert!(!ty.has_escaping_regions()); + // Write the "user substs" down first thing for later. + let hir_id = self.tcx.hir.node_to_hir_id(node_id); + self.write_user_substs_from_substs(hir_id, substs, user_self_ty); + // Add all the obligations that are required, substituting and // normalized appropriately. let bounds = self.instantiate_bounds(span, def_id, &substs); @@ -5176,7 +5216,7 @@ // the referenced item. let ty_substituted = self.instantiate_type_scheme(span, &substs, &ty); - if let Some((ty::ImplContainer(impl_def_id), self_ty)) = ufcs_associated { + if let Some(UserSelfTy { impl_def_id, self_ty }) = user_self_ty { // In the case of `Foo::method` and `>::method`, if `method` // is inherent, there is no `Self` parameter, instead, the impl needs // type parameters, which we can infer by unifying the provided `Self` @@ -5200,11 +5240,8 @@ debug!("instantiate_value_path: type of {:?} is {:?}", node_id, ty_substituted); - let hir_id = self.tcx.hir.node_to_hir_id(node_id); self.write_substs(hir_id, substs); - self.write_user_substs_from_substs(hir_id, substs); - (ty_substituted, new_def) } @@ -5220,18 +5257,12 @@ // 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::Expr(expr) => { - match expr.node { - hir::ExprKind::Call(ref callee, ..) => { - if callee.id == node_id { - return - } - } - _ => {} + if let Node::Expr(expr) = self.tcx.hir.get(self.tcx.hir.get_parent_node(node_id)) { + if let hir::ExprKind::Call(ref callee, ..) = expr.node { + if callee.id == node_id { + return } } - _ => {} } self.tcx.sess.span_err(span, "this function can only be invoked \ @@ -5257,8 +5288,8 @@ } fn with_breakable_ctxt R, R>(&self, id: ast::NodeId, - ctxt: BreakableCtxt<'gcx, 'tcx>, f: F) - -> (BreakableCtxt<'gcx, 'tcx>, R) { + ctxt: BreakableCtxt<'gcx, 'tcx>, f: F) + -> (BreakableCtxt<'gcx, 'tcx>, R) { let index; { let mut enclosing_breakables = self.enclosing_breakables.borrow_mut(); @@ -5332,3 +5363,7 @@ ::session::config::host_triple(), )); } + +fn potentially_plural_count(count: usize, word: &str) -> String { + format!("{} {}{}", count, word, if count == 1 { "" } else { "s" }) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/op.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/op.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/op.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/op.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,7 +16,7 @@ use rustc::ty::TyKind::{Ref, Adt, Str, Uint, Never, Tuple, Char, Array}; use rustc::ty::adjustment::{Adjustment, Adjust, AllowTwoPhase, AutoBorrow, AutoBorrowMutability}; use rustc::infer::type_variable::TypeVariableOrigin; -use errors; +use errors::{self,Applicability}; use syntax_pos::Span; use syntax::ast::Ident; use rustc::hir; @@ -40,7 +40,7 @@ return_ty }; - if !self.is_place_expr(lhs_expr) { + if !lhs_expr.is_place_expr() { struct_span_err!( self.tcx.sess, lhs_expr.span, E0067, "invalid left-hand side expression") @@ -311,7 +311,7 @@ hir::BinOpKind::BitOr => Some("std::ops::BitOrAssign"), hir::BinOpKind::Shl => Some("std::ops::ShlAssign"), hir::BinOpKind::Shr => Some("std::ops::ShrAssign"), - _ => None + _ => None }; if let Some(missing_trait) = missing_trait { if op.node == hir::BinOpKind::Add && @@ -338,15 +338,15 @@ } IsAssign::No => { let mut err = struct_span_err!(self.tcx.sess, expr.span, E0369, - "binary operation `{}` cannot be applied to type `{}`", - op.node.as_str(), - lhs_ty); + "binary operation `{}` cannot be applied to type `{}`", + op.node.as_str(), + lhs_ty); let mut suggested_deref = false; if let Ref(_, mut rty, _) = lhs_ty.sty { if { !self.infcx.type_moves_by_default(self.param_env, - rty, - lhs_expr.span) && + rty, + lhs_expr.span) && self.lookup_op_method(rty, &[rhs_ty], Op::Binary(op, is_assign)) @@ -444,9 +444,12 @@ err.span_label(expr.span, "`+` can't be used to concatenate two `&str` strings"); match source_map.span_to_snippet(lhs_expr.span) { - Ok(lstring) => err.span_suggestion(lhs_expr.span, - msg, - format!("{}.to_owned()", lstring)), + Ok(lstring) => err.span_suggestion_with_applicability( + lhs_expr.span, + msg, + format!("{}.to_owned()", lstring), + Applicability::MachineApplicable, + ), _ => err.help(msg), }; } @@ -462,10 +465,14 @@ is_assign, ) { (Ok(l), Ok(r), false) => { - err.multipart_suggestion(msg, vec![ - (lhs_expr.span, format!("{}.to_owned()", l)), - (rhs_expr.span, format!("&{}", r)), - ]); + err.multipart_suggestion_with_applicability( + msg, + vec![ + (lhs_expr.span, format!("{}.to_owned()", l)), + (rhs_expr.span, format!("&{}", r)), + ], + Applicability::MachineApplicable, + ); } _ => { err.help(msg); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/regionck.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/regionck.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/regionck.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/regionck.rs 2018-12-04 23:41:40.000000000 +0000 @@ -88,27 +88,32 @@ use middle::mem_categorization::Categorization; use middle::region; use rustc::hir::def_id::DefId; -use rustc::ty::subst::Substs; -use rustc::ty::{self, Ty}; -use rustc::infer; use rustc::infer::outlives::env::OutlivesEnvironment; +use rustc::infer::{self, RegionObligation, SuppressRegionErrors}; use rustc::ty::adjustment; +use rustc::ty::subst::Substs; +use rustc::ty::{self, Ty}; +use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor}; +use rustc::hir::{self, PatKind}; +use rustc_data_structures::sync::Lrc; use std::mem; use std::ops::Deref; use std::rc::Rc; -use rustc_data_structures::sync::Lrc; use syntax::ast; use syntax_pos::Span; -use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap}; -use rustc::hir::{self, PatKind}; // a variation on try that just returns unit macro_rules! ignore_err { - ($e:expr) => (match $e { Ok(e) => e, Err(_) => { - debug!("ignoring mem-categorization error!"); - return () - }}) + ($e:expr) => { + match $e { + Ok(e) => e, + Err(_) => { + debug!("ignoring mem-categorization error!"); + return (); + } + } + }; } /////////////////////////////////////////////////////////////////////////// @@ -118,17 +123,24 @@ pub fn regionck_expr(&self, body: &'gcx hir::Body) { let subject = self.tcx.hir.body_owner_def_id(body.id()); let id = body.value.id; - let mut rcx = RegionCtxt::new(self, - RepeatingScope(id), - id, - Subject(subject), - self.param_env); + let mut rcx = RegionCtxt::new( + self, + RepeatingScope(id), + id, + Subject(subject), + self.param_env, + ); + + // There are no add'l implied bounds when checking a + // standalone expr (e.g., the `E` in a type like `[u32; E]`). + rcx.outlives_environment.save_implied_bounds(id); + if self.err_count_since_creation() == 0 { // regionck assumes typeck succeeded rcx.visit_body(body); rcx.visit_region_obligations(id); } - rcx.resolve_regions_and_report_errors_unless_nll(); + rcx.resolve_regions_and_report_errors(SuppressRegionErrors::when_nll_is_enabled(self.tcx)); assert!(self.tables.borrow().free_region_map.is_empty()); self.tables.borrow_mut().free_region_map = rcx.outlives_environment.into_free_region_map(); @@ -136,20 +148,21 @@ /// Region checking during the WF phase for items. `wf_tys` are the /// types from which we should derive implied bounds, if any. - pub fn regionck_item(&self, - item_id: ast::NodeId, - span: Span, - wf_tys: &[Ty<'tcx>]) { + pub fn regionck_item(&self, item_id: ast::NodeId, span: Span, wf_tys: &[Ty<'tcx>]) { debug!("regionck_item(item.id={:?}, wf_tys={:?})", item_id, wf_tys); let subject = self.tcx.hir.local_def_id(item_id); - let mut rcx = RegionCtxt::new(self, - RepeatingScope(item_id), - item_id, - Subject(subject), - self.param_env); - rcx.outlives_environment.add_implied_bounds(self, wf_tys, item_id, span); + let mut rcx = RegionCtxt::new( + self, + RepeatingScope(item_id), + item_id, + Subject(subject), + self.param_env, + ); + rcx.outlives_environment + .add_implied_bounds(self, wf_tys, item_id, span); + rcx.outlives_environment.save_implied_bounds(item_id); rcx.visit_region_obligations(item_id); - rcx.resolve_regions_and_report_errors(); + rcx.resolve_regions_and_report_errors(SuppressRegionErrors::default()); } /// Region check a function body. Not invoked on closures, but @@ -160,24 +173,24 @@ /// rest of type check and because sometimes we need type /// inference to have completed before we can determine which /// constraints to add. - pub fn regionck_fn(&self, - fn_id: ast::NodeId, - body: &'gcx hir::Body) { + pub fn regionck_fn(&self, fn_id: ast::NodeId, body: &'gcx hir::Body) { debug!("regionck_fn(id={})", fn_id); let subject = self.tcx.hir.body_owner_def_id(body.id()); let node_id = body.value.id; - let mut rcx = RegionCtxt::new(self, - RepeatingScope(node_id), - node_id, - Subject(subject), - self.param_env); + let mut rcx = RegionCtxt::new( + self, + RepeatingScope(node_id), + node_id, + Subject(subject), + self.param_env, + ); if self.err_count_since_creation() == 0 { // regionck assumes typeck succeeded rcx.visit_fn_body(fn_id, body, self.tcx.hir.span(fn_id)); } - rcx.resolve_regions_and_report_errors_unless_nll(); + rcx.resolve_regions_and_report_errors(SuppressRegionErrors::when_nll_is_enabled(self.tcx)); // In this mode, we also copy the free-region-map into the // tables of the enclosing fcx. In the other regionck modes @@ -190,7 +203,7 @@ /////////////////////////////////////////////////////////////////////////// // INTERNALS -pub struct RegionCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { +pub struct RegionCtxt<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { pub fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, pub region_scope_tree: Lrc, @@ -208,7 +221,6 @@ // id of AST node being analyzed (the subject of the analysis). subject_def_id: DefId, - } impl<'a, 'gcx, 'tcx> Deref for RegionCtxt<'a, 'gcx, 'tcx> { @@ -222,12 +234,13 @@ pub struct Subject(DefId); impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { - pub fn new(fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, - RepeatingScope(initial_repeating_scope): RepeatingScope, - initial_body_id: ast::NodeId, - Subject(subject): Subject, - param_env: ty::ParamEnv<'tcx>) - -> RegionCtxt<'a, 'gcx, 'tcx> { + pub fn new( + fcx: &'a FnCtxt<'a, 'gcx, 'tcx>, + RepeatingScope(initial_repeating_scope): RepeatingScope, + initial_body_id: ast::NodeId, + Subject(subject): Subject, + param_env: ty::ParamEnv<'tcx>, + ) -> RegionCtxt<'a, 'gcx, 'tcx> { let region_scope_tree = fcx.tcx.region_scope_tree(subject); let outlives_environment = OutlivesEnvironment::new(param_env); RegionCtxt { @@ -296,11 +309,12 @@ /// closures, however, we save and restore any "scoped state" /// before we invoke this function. (See `visit_fn` in the /// `intravisit::Visitor` impl below.) - fn visit_fn_body(&mut self, - id: ast::NodeId, // the id of the fn itself - body: &'gcx hir::Body, - span: Span) - { + fn visit_fn_body( + &mut self, + id: ast::NodeId, // the id of the fn itself + body: &'gcx hir::Body, + span: Span, + ) { // When we enter a function, we can derive debug!("visit_fn_body(id={})", id); @@ -309,7 +323,7 @@ let call_site = region::Scope { id: body.value.hir_id.local_id, - data: region::ScopeData::CallSite + data: region::ScopeData::CallSite, }; self.call_site_scope = Some(call_site); @@ -328,32 +342,41 @@ // because it will have no effect. // // FIXME(#27579) return types should not be implied bounds - let fn_sig_tys: Vec<_> = - fn_sig.inputs().iter().cloned().chain(Some(fn_sig.output())).collect(); + let fn_sig_tys: Vec<_> = fn_sig + .inputs() + .iter() + .cloned() + .chain(Some(fn_sig.output())) + .collect(); self.outlives_environment.add_implied_bounds( self.fcx, &fn_sig_tys[..], body_id.node_id, - span); + span, + ); + self.outlives_environment + .save_implied_bounds(body_id.node_id); self.link_fn_args( region::Scope { id: body.value.hir_id.local_id, - data: region::ScopeData::Node + data: region::ScopeData::Node, }, - &body.arguments); + &body.arguments, + ); self.visit_body(body); self.visit_region_obligations(body_id.node_id); let call_site_scope = self.call_site_scope.unwrap(); - debug!("visit_fn_body body.id {:?} call_site_scope: {:?}", - body.id(), call_site_scope); + debug!( + "visit_fn_body body.id {:?} call_site_scope: {:?}", + body.id(), + call_site_scope + ); let call_site_region = self.tcx.mk_region(ty::ReScope(call_site_scope)); let body_hir_id = self.tcx.hir.node_to_hir_id(body_id.node_id); - self.type_of_node_must_outlive(infer::CallReturn(span), - body_hir_id, - call_site_region); + self.type_of_node_must_outlive(infer::CallReturn(span), body_hir_id, call_site_region); self.constrain_opaque_types( &self.fcx.opaque_types.borrow(), @@ -361,32 +384,28 @@ ); } - fn visit_region_obligations(&mut self, node_id: ast::NodeId) - { + fn visit_region_obligations(&mut self, node_id: ast::NodeId) { debug!("visit_region_obligations: node_id={}", node_id); // region checking can introduce new pending obligations // which, when processed, might generate new region // obligations. So make sure we process those. self.select_all_obligations_or_error(); + } + fn resolve_regions_and_report_errors(&self, suppress: SuppressRegionErrors) { self.infcx.process_registered_region_obligations( - self.outlives_environment.region_bound_pairs(), + self.outlives_environment.region_bound_pairs_map(), self.implicit_region_bound, self.param_env, - self.body_id); - } - - fn resolve_regions_and_report_errors(&self) { - self.fcx.resolve_regions_and_report_errors(self.subject_def_id, - &self.region_scope_tree, - &self.outlives_environment); - } + ); - fn resolve_regions_and_report_errors_unless_nll(&self) { - self.fcx.resolve_regions_and_report_errors_unless_nll(self.subject_def_id, - &self.region_scope_tree, - &self.outlives_environment); + self.fcx.resolve_regions_and_report_errors( + self.subject_def_id, + &self.region_scope_tree, + &self.outlives_environment, + suppress, + ); } fn constrain_bindings_in_pat(&mut self, pat: &hir::Pat) { @@ -423,7 +442,8 @@ let typ = self.resolve_node_type(hir_id); let body_id = self.body_id; let _ = dropck::check_safety_of_destructor_if_necessary( - self, typ, span, body_id, var_scope); + self, typ, span, body_id, var_scope, + ); }) } } @@ -441,14 +461,21 @@ NestedVisitorMap::None } - fn visit_fn(&mut self, - fk: intravisit::FnKind<'gcx>, - _: &'gcx hir::FnDecl, - body_id: hir::BodyId, - span: Span, - id: ast::NodeId) { - assert!(match fk { intravisit::FnKind::Closure(..) => true, _ => false }, - "visit_fn invoked for something other than a closure"); + fn visit_fn( + &mut self, + fk: intravisit::FnKind<'gcx>, + _: &'gcx hir::FnDecl, + body_id: hir::BodyId, + span: Span, + id: ast::NodeId, + ) { + assert!( + match fk { + intravisit::FnKind::Closure(..) => true, + _ => false, + }, + "visit_fn invoked for something other than a closure" + ); // Save state of current function before invoking // `visit_fn_body`. We will restore afterwards. @@ -460,7 +487,8 @@ self.visit_fn_body(id, body, span); // Restore state from previous function. - self.outlives_environment.pop_snapshot_post_closure(env_snapshot); + self.outlives_environment + .pop_snapshot_post_closure(env_snapshot); self.call_site_scope = old_call_site_scope; self.body_id = old_body_id; } @@ -483,20 +511,24 @@ } fn visit_expr(&mut self, expr: &'gcx hir::Expr) { - debug!("regionck::visit_expr(e={:?}, repeating_scope={})", - expr, self.repeating_scope); + debug!( + "regionck::visit_expr(e={:?}, repeating_scope={})", + expr, self.repeating_scope + ); // No matter what, the type of each expression must outlive the // scope of that expression. This also guarantees basic WF. let expr_ty = self.resolve_node_type(expr.hir_id); // the region corresponding to this expression - let expr_region = self.tcx.mk_region(ty::ReScope( - region::Scope { - id: expr.hir_id.local_id, - data: region::ScopeData::Node - })); - self.type_must_outlive(infer::ExprTypeIsNotInScope(expr_ty, expr.span), - expr_ty, expr_region); + let expr_region = self.tcx.mk_region(ty::ReScope(region::Scope { + id: expr.hir_id.local_id, + data: region::ScopeData::Node, + })); + self.type_must_outlive( + infer::ExprTypeIsNotInScope(expr_ty, expr.span), + expr_ty, + expr_region, + ); let is_method_call = self.tables.borrow().is_method_call(expr); @@ -506,12 +538,11 @@ // provided as arguments outlive the call. if is_method_call { let origin = match expr.node { - hir::ExprKind::MethodCall(..) => - infer::ParameterOrigin::MethodCall, - hir::ExprKind::Unary(op, _) if op == hir::UnDeref => - infer::ParameterOrigin::OverloadedDeref, - _ => - infer::ParameterOrigin::OverloadedOperator + hir::ExprKind::MethodCall(..) => infer::ParameterOrigin::MethodCall, + hir::ExprKind::Unary(op, _) if op == hir::UnDeref => { + infer::ParameterOrigin::OverloadedDeref + } + _ => infer::ParameterOrigin::OverloadedOperator, }; let substs = self.tables.borrow().node_substs(expr.hir_id); @@ -533,8 +564,10 @@ } } - debug!("regionck::visit_expr(e={:?}, repeating_scope={}) - visiting subexprs", - expr, self.repeating_scope); + debug!( + "regionck::visit_expr(e={:?}, repeating_scope={}) - visiting subexprs", + expr, self.repeating_scope + ); match expr.node { hir::ExprKind::Path(_) => { let substs = self.tables.borrow().node_substs(expr.hir_id); @@ -571,7 +604,7 @@ self.constrain_call(expr, Some(&lhs), Some(&**rhs).into_iter()); intravisit::walk_expr(self, expr); - }, + } hir::ExprKind::Binary(_, ref lhs, ref rhs) if is_method_call => { // As `ExprKind::MethodCall`, but the call is via an overloaded op. @@ -586,8 +619,7 @@ let lhs_ty = self.resolve_expr_type_adjusted(&lhs); let rhs_ty = self.resolve_expr_type_adjusted(&rhs); for &ty in &[lhs_ty, rhs_ty] { - self.type_must_outlive(infer::Operand(expr.span), - ty, expr_region); + self.type_must_outlive(infer::Operand(expr.span), ty, expr_region); } intravisit::walk_expr(self, expr); } @@ -674,12 +706,16 @@ hir::ExprKind::Ret(Some(ref ret_expr)) => { let call_site_scope = self.call_site_scope; - debug!("visit_expr ExprKind::Ret ret_expr.id {} call_site_scope: {:?}", - ret_expr.id, call_site_scope); + debug!( + "visit_expr ExprKind::Ret ret_expr.id {} call_site_scope: {:?}", + ret_expr.id, call_site_scope + ); let call_site_region = self.tcx.mk_region(ty::ReScope(call_site_scope.unwrap())); - self.type_of_node_must_outlive(infer::CallReturn(ret_expr.span), - ret_expr.hir_id, - call_site_region); + self.type_of_node_must_outlive( + infer::CallReturn(ret_expr.span), + ret_expr.hir_id, + call_site_region, + ); intravisit::walk_expr(self, expr); } @@ -691,13 +727,11 @@ } impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { - fn constrain_cast(&mut self, - cast_expr: &hir::Expr, - source_expr: &hir::Expr) - { - debug!("constrain_cast(cast_expr={:?}, source_expr={:?})", - cast_expr, - source_expr); + fn constrain_cast(&mut self, cast_expr: &hir::Expr, source_expr: &hir::Expr) { + debug!( + "constrain_cast(cast_expr={:?}, source_expr={:?})", + cast_expr, source_expr + ); let source_ty = self.resolve_node_type(source_expr.hir_id); let target_ty = self.resolve_node_type(cast_expr.hir_id); @@ -705,40 +739,35 @@ self.walk_cast(cast_expr, source_ty, target_ty); } - fn walk_cast(&mut self, - cast_expr: &hir::Expr, - from_ty: Ty<'tcx>, - to_ty: Ty<'tcx>) { - debug!("walk_cast(from_ty={:?}, to_ty={:?})", - from_ty, - to_ty); + fn walk_cast(&mut self, cast_expr: &hir::Expr, from_ty: Ty<'tcx>, to_ty: Ty<'tcx>) { + debug!("walk_cast(from_ty={:?}, to_ty={:?})", from_ty, to_ty); match (&from_ty.sty, &to_ty.sty) { - /*From:*/ (&ty::Ref(from_r, from_ty, _), - /*To: */ &ty::Ref(to_r, to_ty, _)) => { + /*From:*/ + (&ty::Ref(from_r, from_ty, _), /*To: */ &ty::Ref(to_r, to_ty, _)) => { // Target cannot outlive source, naturally. self.sub_regions(infer::Reborrow(cast_expr.span), to_r, from_r); self.walk_cast(cast_expr, from_ty, to_ty); } - /*From:*/ (_, - /*To: */ &ty::Dynamic(.., r)) => { + /*From:*/ + (_, /*To: */ &ty::Dynamic(.., r)) => { // When T is existentially quantified as a trait // `Foo+'to`, it must outlive the region bound `'to`. self.type_must_outlive(infer::RelateObjectBound(cast_expr.span), from_ty, r); } - /*From:*/ (&ty::Adt(from_def, _), - /*To: */ &ty::Adt(to_def, _)) if from_def.is_box() && to_def.is_box() => { + /*From:*/ + (&ty::Adt(from_def, _), /*To: */ &ty::Adt(to_def, _)) + if from_def.is_box() && to_def.is_box() => + { self.walk_cast(cast_expr, from_ty.boxed_ty(), to_ty.boxed_ty()); } - _ => { } + _ => {} } } - fn check_expr_fn_block(&mut self, - expr: &'gcx hir::Expr, - body_id: hir::BodyId) { + fn check_expr_fn_block(&mut self, expr: &'gcx hir::Expr, body_id: hir::BodyId) { let repeating_scope = self.set_repeating_scope(body_id.node_id); intravisit::walk_expr(self, expr); self.set_repeating_scope(repeating_scope); @@ -747,7 +776,7 @@ fn constrain_callee(&mut self, callee_expr: &hir::Expr) { let callee_ty = self.resolve_node_type(callee_expr.hir_id); match callee_ty.sty { - ty::FnDef(..) | ty::FnPtr(_) => { } + ty::FnDef(..) | ty::FnPtr(_) => {} _ => { // this should not happen, but it does if the program is // erroneous @@ -760,18 +789,21 @@ } } - fn constrain_call<'b, I: Iterator>(&mut self, - call_expr: &hir::Expr, - receiver: Option<&hir::Expr>, - arg_exprs: I) { + fn constrain_call<'b, I: Iterator>( + &mut self, + call_expr: &hir::Expr, + receiver: Option<&hir::Expr>, + arg_exprs: I, + ) { //! Invoked on every call site (i.e., normal calls, method calls, //! and overloaded operators). Constrains the regions which appear //! in the type of the function. Also constrains the regions that //! appear in the arguments appropriately. - debug!("constrain_call(call_expr={:?}, receiver={:?})", - call_expr, - receiver); + debug!( + "constrain_call(call_expr={:?}, receiver={:?})", + call_expr, receiver + ); // `callee_region` is the scope representing the time in which the // call occurs. @@ -779,7 +811,7 @@ // FIXME(#6268) to support nested method calls, should be callee_id let callee_scope = region::Scope { id: call_expr.hir_id.local_id, - data: region::ScopeData::Node + data: region::ScopeData::Node, }; let callee_region = self.tcx.mk_region(ty::ReScope(callee_scope)); @@ -790,27 +822,30 @@ // ensure that any regions appearing in the argument type are // valid for at least the lifetime of the function: - self.type_of_node_must_outlive(infer::CallArg(arg_expr.span), - arg_expr.hir_id, - callee_region); + self.type_of_node_must_outlive( + infer::CallArg(arg_expr.span), + arg_expr.hir_id, + callee_region, + ); } // as loop above, but for receiver if let Some(r) = receiver { debug!("receiver: {:?}", r); - self.type_of_node_must_outlive(infer::CallRcvr(r.span), - r.hir_id, - callee_region); + self.type_of_node_must_outlive(infer::CallRcvr(r.span), r.hir_id, callee_region); } } /// Create a temporary `MemCategorizationContext` and pass it to the closure. fn with_mc(&self, f: F) -> R - where F: for<'b> FnOnce(mc::MemCategorizationContext<'b, 'gcx, 'tcx>) -> R + where + F: for<'b> FnOnce(mc::MemCategorizationContext<'b, 'gcx, 'tcx>) -> R, { - f(mc::MemCategorizationContext::with_infer(&self.infcx, - &self.region_scope_tree, - &self.tables.borrow())) + f(mc::MemCategorizationContext::with_infer( + &self.infcx, + &self.region_scope_tree, + &self.tables.borrow(), + )) } /// Invoked on any adjustments that occur. Checks that if this is a region pointer being @@ -832,37 +867,46 @@ // expression. self.check_safety_of_rvalue_destructor_if_necessary(&cmt, expr.span); - let expr_region = self.tcx.mk_region(ty::ReScope( - region::Scope { - id: expr.hir_id.local_id, - data: region::ScopeData::Node - })); + let expr_region = self.tcx.mk_region(ty::ReScope(region::Scope { + id: expr.hir_id.local_id, + data: region::ScopeData::Node, + })); for adjustment in adjustments { - debug!("constrain_adjustments: adjustment={:?}, cmt={:?}", - adjustment, cmt); + debug!( + "constrain_adjustments: adjustment={:?}, cmt={:?}", + adjustment, cmt + ); if let adjustment::Adjust::Deref(Some(deref)) = adjustment.kind { debug!("constrain_adjustments: overloaded deref: {:?}", deref); // Treat overloaded autoderefs as if an AutoBorrow adjustment // was applied on the base type, as that is always the case. - let input = self.tcx.mk_ref(deref.region, ty::TypeAndMut { - ty: cmt.ty, - mutbl: deref.mutbl, - }); - let output = self.tcx.mk_ref(deref.region, ty::TypeAndMut { - ty: adjustment.target, - mutbl: deref.mutbl, - }); - - self.link_region(expr.span, deref.region, - ty::BorrowKind::from_mutbl(deref.mutbl), &cmt); + let input = self.tcx.mk_ref( + deref.region, + ty::TypeAndMut { + ty: cmt.ty, + mutbl: deref.mutbl, + }, + ); + let output = self.tcx.mk_ref( + deref.region, + ty::TypeAndMut { + ty: adjustment.target, + mutbl: deref.mutbl, + }, + ); + + self.link_region( + expr.span, + deref.region, + ty::BorrowKind::from_mutbl(deref.mutbl), + &cmt, + ); // Specialized version of constrain_call. - self.type_must_outlive(infer::CallRcvr(expr.span), - input, expr_region); - self.type_must_outlive(infer::CallReturn(expr.span), - output, expr_region); + self.type_must_outlive(infer::CallRcvr(expr.span), input, expr_region); + self.type_must_outlive(infer::CallReturn(expr.span), output, expr_region); } if let adjustment::Adjust::Borrow(ref autoref) = adjustment.kind { @@ -872,73 +916,83 @@ // the current node. // // FIXME(#6268) remove to support nested method calls - self.type_of_node_must_outlive(infer::AutoBorrow(expr.span), - expr.hir_id, - expr_region); + self.type_of_node_must_outlive( + infer::AutoBorrow(expr.span), + expr.hir_id, + expr_region, + ); } cmt = self.with_mc(|mc| mc.cat_expr_adjusted(expr, cmt, &adjustment))?; if let Categorization::Deref(_, mc::BorrowedPtr(_, r_ptr)) = cmt.cat { - self.mk_subregion_due_to_dereference(expr.span, - expr_region, r_ptr); + self.mk_subregion_due_to_dereference(expr.span, expr_region, r_ptr); } } Ok(cmt) } - pub fn mk_subregion_due_to_dereference(&mut self, - deref_span: Span, - minimum_lifetime: ty::Region<'tcx>, - maximum_lifetime: ty::Region<'tcx>) { - self.sub_regions(infer::DerefPointer(deref_span), - minimum_lifetime, maximum_lifetime) - } - - fn check_safety_of_rvalue_destructor_if_necessary(&mut self, - cmt: &mc::cmt_<'tcx>, - span: Span) { - match cmt.cat { - Categorization::Rvalue(region) => { - match *region { - ty::ReScope(rvalue_scope) => { - let typ = self.resolve_type(cmt.ty); - let body_id = self.body_id; - let _ = dropck::check_safety_of_destructor_if_necessary( - self, typ, span, body_id, rvalue_scope); - } - ty::ReStatic => {} - _ => { - span_bug!(span, - "unexpected rvalue region in rvalue \ - destructor safety checking: `{:?}`", - region); - } + pub fn mk_subregion_due_to_dereference( + &mut self, + deref_span: Span, + minimum_lifetime: ty::Region<'tcx>, + maximum_lifetime: ty::Region<'tcx>, + ) { + self.sub_regions( + infer::DerefPointer(deref_span), + minimum_lifetime, + maximum_lifetime, + ) + } + + fn check_safety_of_rvalue_destructor_if_necessary(&mut self, cmt: &mc::cmt_<'tcx>, span: Span) { + if let Categorization::Rvalue(region) = cmt.cat { + match *region { + ty::ReScope(rvalue_scope) => { + let typ = self.resolve_type(cmt.ty); + let body_id = self.body_id; + let _ = dropck::check_safety_of_destructor_if_necessary( + self, + typ, + span, + body_id, + rvalue_scope, + ); + } + ty::ReStatic => {} + _ => { + span_bug!( + span, + "unexpected rvalue region in rvalue \ + destructor safety checking: `{:?}`", + region + ); } } - _ => {} } } /// Invoked on any index expression that occurs. Checks that if this is a slice /// being indexed, the lifetime of the pointer includes the deref expr. - fn constrain_index(&mut self, - index_expr: &hir::Expr, - indexed_ty: Ty<'tcx>) - { - debug!("constrain_index(index_expr=?, indexed_ty={}", - self.ty_to_string(indexed_ty)); + fn constrain_index(&mut self, index_expr: &hir::Expr, indexed_ty: Ty<'tcx>) { + debug!( + "constrain_index(index_expr=?, indexed_ty={}", + self.ty_to_string(indexed_ty) + ); let r_index_expr = ty::ReScope(region::Scope { id: index_expr.hir_id.local_id, - data: region::ScopeData::Node + data: region::ScopeData::Node, }); if let ty::Ref(r_ptr, r_ty, _) = indexed_ty.sty { match r_ty.sty { ty::Slice(_) | ty::Str => { - self.sub_regions(infer::IndexSlice(index_expr.span), - self.tcx.mk_region(r_index_expr), r_ptr); + self.sub_regions( + infer::IndexSlice(index_expr.span), + self.tcx.mk_region(r_index_expr), + r_ptr, + ); } _ => {} } @@ -947,27 +1001,29 @@ /// Guarantees that any lifetimes which appear in the type of the node `id` (after applying /// adjustments) are valid for at least `minimum_lifetime` - fn type_of_node_must_outlive(&mut self, + fn type_of_node_must_outlive( + &mut self, origin: infer::SubregionOrigin<'tcx>, hir_id: hir::HirId, - minimum_lifetime: ty::Region<'tcx>) - { + minimum_lifetime: ty::Region<'tcx>, + ) { // Try to resolve the type. If we encounter an error, then typeck // is going to fail anyway, so just stop here and let typeck // report errors later on in the writeback phase. let ty0 = self.resolve_node_type(hir_id); let ty = self.tables - .borrow() - .adjustments() - .get(hir_id) - .and_then(|adj| adj.last()) - .map_or(ty0, |adj| adj.target); + .borrow() + .adjustments() + .get(hir_id) + .and_then(|adj| adj.last()) + .map_or(ty0, |adj| adj.target); let ty = self.resolve_type(ty); - debug!("constrain_regions_in_type_of_node(\ - ty={}, ty0={}, id={:?}, minimum_lifetime={:?})", - ty, ty0, - hir_id, minimum_lifetime); + debug!( + "constrain_regions_in_type_of_node(\ + ty={}, ty0={}, id={:?}, minimum_lifetime={:?})", + ty, ty0, hir_id, minimum_lifetime + ); self.type_must_outlive(origin, ty, minimum_lifetime); } @@ -979,23 +1035,25 @@ /// - `origin`, the reason we need this constraint /// - `ty`, the type `T` /// - `region`, the region `'a` - pub fn type_must_outlive(&self, - origin: infer::SubregionOrigin<'tcx>, - ty: Ty<'tcx>, - region: ty::Region<'tcx>) - { - self.infcx.type_must_outlive(self.outlives_environment.region_bound_pairs(), - self.implicit_region_bound, - self.param_env, - origin, - ty, - region); + pub fn type_must_outlive( + &self, + origin: infer::SubregionOrigin<'tcx>, + ty: Ty<'tcx>, + region: ty::Region<'tcx>, + ) { + self.infcx.register_region_obligation( + self.body_id, + RegionObligation { + sub_region: region, + sup_type: ty, + origin, + }, + ); } /// Computes the guarantor for an expression `&base` and then ensures that the lifetime of the /// resulting pointer is linked to the lifetime of its guarantor (if any). - fn link_addr_of(&mut self, expr: &hir::Expr, - mutability: hir::Mutability, base: &hir::Expr) { + fn link_addr_of(&mut self, expr: &hir::Expr, mutability: hir::Mutability, base: &hir::Expr) { debug!("link_addr_of(expr={:?}, base={:?})", expr, base); let cmt = ignore_err!(self.with_mc(|mc| mc.cat_expr(base))); @@ -1011,7 +1069,9 @@ fn link_local(&self, local: &hir::Local) { debug!("regionck::for_local()"); let init_expr = match local.init { - None => { return; } + None => { + return; + } Some(ref expr) => &**expr, }; let discr_cmt = Rc::new(ignore_err!(self.with_mc(|mc| mc.cat_expr(init_expr)))); @@ -1043,10 +1103,7 @@ let arg_cmt = self.with_mc(|mc| { Rc::new(mc.cat_rvalue(arg.hir_id, arg.pat.span, re_scope, arg_ty)) }); - debug!("arg_ty={:?} arg_cmt={:?} arg={:?}", - arg_ty, - arg_cmt, - arg); + debug!("arg_ty={:?} arg_cmt={:?} arg={:?}", arg_ty, arg_cmt, arg); self.link_pattern(arg_cmt, &arg.pat); } } @@ -1054,24 +1111,28 @@ /// Link lifetimes of any ref bindings in `root_pat` to the pointers found /// in the discriminant, if needed. fn link_pattern(&self, discr_cmt: mc::cmt<'tcx>, root_pat: &hir::Pat) { - debug!("link_pattern(discr_cmt={:?}, root_pat={:?})", - discr_cmt, - root_pat); + debug!( + "link_pattern(discr_cmt={:?}, root_pat={:?})", + discr_cmt, root_pat + ); ignore_err!(self.with_mc(|mc| { mc.cat_pattern(discr_cmt, root_pat, |sub_cmt, sub_pat| { - match sub_pat.node { - // `ref x` pattern - PatKind::Binding(..) => { - if let Some(&bm) = mc.tables.pat_binding_modes().get(sub_pat.hir_id) { - if let ty::BindByReference(mutbl) = bm { - self.link_region_from_node_type(sub_pat.span, sub_pat.hir_id, - mutbl, &sub_cmt); - } - } else { - self.tcx.sess.delay_span_bug(sub_pat.span, "missing binding mode"); + // `ref x` pattern + if let PatKind::Binding(..) = sub_pat.node { + if let Some(&bm) = mc.tables.pat_binding_modes().get(sub_pat.hir_id) { + if let ty::BindByReference(mutbl) = bm { + self.link_region_from_node_type( + sub_pat.span, + sub_pat.hir_id, + mutbl, + &sub_cmt, + ); } + } else { + self.tcx + .sess + .delay_span_bug(sub_pat.span, "missing binding mode"); } - _ => {} } }) })); @@ -1079,12 +1140,16 @@ /// Link lifetime of borrowed pointer resulting from autoref to lifetimes in the value being /// autoref'd. - fn link_autoref(&self, - expr: &hir::Expr, - expr_cmt: &mc::cmt_<'tcx>, - autoref: &adjustment::AutoBorrow<'tcx>) - { - debug!("link_autoref(autoref={:?}, expr_cmt={:?})", autoref, expr_cmt); + fn link_autoref( + &self, + expr: &hir::Expr, + expr_cmt: &mc::cmt_<'tcx>, + autoref: &adjustment::AutoBorrow<'tcx>, + ) { + debug!( + "link_autoref(autoref={:?}, expr_cmt={:?})", + autoref, expr_cmt + ); match *autoref { adjustment::AutoBorrow::Ref(r, m) => { @@ -1094,7 +1159,7 @@ adjustment::AutoBorrow::RawPtr(m) => { let r = self.tcx.mk_region(ty::ReScope(region::Scope { id: expr.hir_id.local_id, - data: region::ScopeData::Node + data: region::ScopeData::Node, })); self.link_region(expr.span, r, ty::BorrowKind::from_mutbl(m), expr_cmt); } @@ -1103,17 +1168,21 @@ /// Like `link_region()`, except that the region is extracted from the type of `id`, /// which must be some reference (`&T`, `&str`, etc). - fn link_region_from_node_type(&self, - span: Span, - id: hir::HirId, - mutbl: hir::Mutability, - cmt_borrowed: &mc::cmt_<'tcx>) { - debug!("link_region_from_node_type(id={:?}, mutbl={:?}, cmt_borrowed={:?})", - id, mutbl, cmt_borrowed); + fn link_region_from_node_type( + &self, + span: Span, + id: hir::HirId, + mutbl: hir::Mutability, + cmt_borrowed: &mc::cmt_<'tcx>, + ) { + debug!( + "link_region_from_node_type(id={:?}, mutbl={:?}, cmt_borrowed={:?})", + id, mutbl, cmt_borrowed + ); let rptr_ty = self.resolve_node_type(id); if let ty::Ref(r, _, _) = rptr_ty.sty { - debug!("rptr_ty={}", rptr_ty); + debug!("rptr_ty={}", rptr_ty); self.link_region(span, r, ty::BorrowKind::from_mutbl(mutbl), cmt_borrowed); } } @@ -1122,11 +1191,13 @@ /// kind `borrow_kind` and lifetime `borrow_region`. /// In order to ensure borrowck is satisfied, this may create constraints /// between regions, as explained in `link_reborrowed_region()`. - fn link_region(&self, - span: Span, - borrow_region: ty::Region<'tcx>, - borrow_kind: ty::BorrowKind, - borrow_cmt: &mc::cmt_<'tcx>) { + fn link_region( + &self, + span: Span, + borrow_region: ty::Region<'tcx>, + borrow_kind: ty::BorrowKind, + borrow_cmt: &mc::cmt_<'tcx>, + ) { let origin = infer::DataBorrowed(borrow_cmt.ty, span); self.type_must_outlive(origin, borrow_cmt.ty, borrow_region); @@ -1134,16 +1205,21 @@ let mut borrow_cmt_cat = borrow_cmt.cat.clone(); loop { - debug!("link_region(borrow_region={:?}, borrow_kind={:?}, borrow_cmt={:?})", - borrow_region, - borrow_kind, - borrow_cmt); + debug!( + "link_region(borrow_region={:?}, borrow_kind={:?}, borrow_cmt={:?})", + borrow_region, borrow_kind, borrow_cmt + ); match borrow_cmt_cat { Categorization::Deref(ref_cmt, mc::BorrowedPtr(ref_kind, ref_region)) => { - match self.link_reborrowed_region(span, - borrow_region, borrow_kind, - ref_cmt, ref_region, ref_kind, - borrow_cmt.note) { + match self.link_reborrowed_region( + span, + borrow_region, + borrow_kind, + ref_cmt, + ref_region, + ref_kind, + borrow_cmt.note, + ) { Some((c, k)) => { borrow_cmt_cat = c.cat.clone(); borrow_kind = k; @@ -1154,20 +1230,20 @@ } } - Categorization::Downcast(cmt_base, _) | - Categorization::Deref(cmt_base, mc::Unique) | - Categorization::Interior(cmt_base, _) => { + Categorization::Downcast(cmt_base, _) + | Categorization::Deref(cmt_base, mc::Unique) + | Categorization::Interior(cmt_base, _) => { // Borrowing interior or owned data requires the base // to be valid and borrowable in the same fashion. borrow_cmt_cat = cmt_base.cat.clone(); borrow_kind = borrow_kind; } - Categorization::Deref(_, mc::UnsafePtr(..)) | - Categorization::StaticItem | - Categorization::Upvar(..) | - Categorization::Local(..) | - Categorization::Rvalue(..) => { + Categorization::Deref(_, mc::UnsafePtr(..)) + | Categorization::StaticItem + | Categorization::Upvar(..) + | Categorization::Local(..) + | Categorization::Rvalue(..) => { // These are all "base cases" with independent lifetimes // that are not subject to inference return; @@ -1218,16 +1294,16 @@ /// /// The return value of this function indicates whether we need to /// recurse and process `ref_cmt` (see case 2 above). - fn link_reborrowed_region(&self, - span: Span, - borrow_region: ty::Region<'tcx>, - borrow_kind: ty::BorrowKind, - ref_cmt: mc::cmt<'tcx>, - ref_region: ty::Region<'tcx>, - mut ref_kind: ty::BorrowKind, - note: mc::Note) - -> Option<(mc::cmt<'tcx>, ty::BorrowKind)> - { + fn link_reborrowed_region( + &self, + span: Span, + borrow_region: ty::Region<'tcx>, + borrow_kind: ty::BorrowKind, + ref_cmt: mc::cmt<'tcx>, + ref_region: ty::Region<'tcx>, + mut ref_kind: ty::BorrowKind, + note: mc::Note, + ) -> Option<(mc::cmt<'tcx>, ty::BorrowKind)> { // Possible upvar ID we may need later to create an entry in the // maybe link map. @@ -1243,7 +1319,7 @@ infer::ReborrowUpvar(span, *upvar_id) } _ => { - span_bug!( span, "Illegal upvar id: {:?}", upvar_id); + span_bug!(span, "Illegal upvar id: {:?}", upvar_id); } } } @@ -1253,14 +1329,13 @@ // link infer::ReborrowUpvar(span, *upvar_id) } - _ => { - infer::Reborrow(span) - } + _ => infer::Reborrow(span), }; - debug!("link_reborrowed_region: {:?} <= {:?}", - borrow_region, - ref_region); + debug!( + "link_reborrowed_region: {:?} <= {:?}", + borrow_region, ref_region + ); self.sub_regions(cause, borrow_region, ref_region); // If we end up needing to recurse and establish a region link @@ -1272,10 +1347,8 @@ // borrowck requires a unique path to the `&mut` reference but not // necessarily a *mutable* path. let new_borrow_kind = match borrow_kind { - ty::ImmBorrow => - ty::ImmBorrow, - ty::MutBorrow | ty::UniqueImmBorrow => - ty::UniqueImmBorrow + ty::ImmBorrow => ty::ImmBorrow, + ty::MutBorrow | ty::UniqueImmBorrow => ty::UniqueImmBorrow, }; // Decide whether we need to recurse and link any regions within @@ -1329,16 +1402,20 @@ /// Checks that the values provided for type/region arguments in a given /// expression are well-formed and in-scope. - fn substs_wf_in_scope(&mut self, - origin: infer::ParameterOrigin, - substs: &Substs<'tcx>, - expr_span: Span, - expr_region: ty::Region<'tcx>) { - debug!("substs_wf_in_scope(substs={:?}, \ - expr_region={:?}, \ - origin={:?}, \ - expr_span={:?})", - substs, expr_region, origin, expr_span); + fn substs_wf_in_scope( + &mut self, + origin: infer::ParameterOrigin, + substs: &Substs<'tcx>, + expr_span: Span, + expr_region: ty::Region<'tcx>, + ) { + debug!( + "substs_wf_in_scope(substs={:?}, \ + expr_region={:?}, \ + origin={:?}, \ + expr_span={:?})", + substs, expr_region, origin, expr_span + ); let origin = infer::ParameterInScope(origin, expr_span); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/upvar.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/upvar.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/upvar.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/upvar.rs 2018-12-04 23:41:40.000000000 +0000 @@ -73,15 +73,11 @@ } fn visit_expr(&mut self, expr: &'gcx hir::Expr) { - match expr.node { - hir::ExprKind::Closure(cc, _, body_id, _, _) => { - let body = self.fcx.tcx.hir.body(body_id); - self.visit_body(body); - self.fcx - .analyze_closure(expr.id, expr.hir_id, expr.span, body, cc); - } - - _ => {} + if let hir::ExprKind::Closure(cc, _, body_id, _, _) = expr.node { + let body = self.fcx.tcx.hir.body(body_id); + self.visit_body(body); + self.fcx + .analyze_closure(expr.id, expr.hir_id, expr.span, body, cc); } intravisit::walk_expr(self, expr); @@ -335,49 +331,46 @@ "adjust_upvar_borrow_kind_for_consume: guarantor.cat={:?}", guarantor.cat ); - match guarantor.cat { - Categorization::Deref(_, mc::BorrowedPtr(..)) => { - debug!( - "adjust_upvar_borrow_kind_for_consume: found deref with note {:?}", - cmt.note - ); - match guarantor.note { - mc::NoteUpvarRef(upvar_id) => { - debug!( - "adjust_upvar_borrow_kind_for_consume: \ - setting upvar_id={:?} to by value", - upvar_id - ); - - // to move out of an upvar, this must be a FnOnce closure - self.adjust_closure_kind( - upvar_id.closure_expr_id, - ty::ClosureKind::FnOnce, - guarantor.span, - var_name(tcx, upvar_id.var_id), - ); + if let Categorization::Deref(_, mc::BorrowedPtr(..)) = guarantor.cat { + debug!( + "adjust_upvar_borrow_kind_for_consume: found deref with note {:?}", + cmt.note + ); + match guarantor.note { + mc::NoteUpvarRef(upvar_id) => { + debug!( + "adjust_upvar_borrow_kind_for_consume: \ + setting upvar_id={:?} to by value", + upvar_id + ); - self.adjust_upvar_captures - .insert(upvar_id, ty::UpvarCapture::ByValue); - } - mc::NoteClosureEnv(upvar_id) => { - // we get just a closureenv ref if this is a - // `move` closure, or if the upvar has already - // been inferred to by-value. In any case, we - // must still adjust the kind of the closure - // to be a FnOnce closure to permit moves out - // of the environment. - self.adjust_closure_kind( - upvar_id.closure_expr_id, - ty::ClosureKind::FnOnce, - guarantor.span, - var_name(tcx, upvar_id.var_id), - ); - } - mc::NoteIndex | mc::NoteNone => {} + // to move out of an upvar, this must be a FnOnce closure + self.adjust_closure_kind( + upvar_id.closure_expr_id, + ty::ClosureKind::FnOnce, + guarantor.span, + var_name(tcx, upvar_id.var_id), + ); + + self.adjust_upvar_captures + .insert(upvar_id, ty::UpvarCapture::ByValue); + } + mc::NoteClosureEnv(upvar_id) => { + // we get just a closureenv ref if this is a + // `move` closure, or if the upvar has already + // been inferred to by-value. In any case, we + // must still adjust the kind of the closure + // to be a FnOnce closure to permit moves out + // of the environment. + self.adjust_closure_kind( + upvar_id.closure_expr_id, + ty::ClosureKind::FnOnce, + guarantor.span, + var_name(tcx, upvar_id.var_id), + ); } + mc::NoteIndex | mc::NoteNone => {} } - _ => {} } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/wfcheck.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/wfcheck.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/wfcheck.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/wfcheck.rs 2018-12-04 23:41:40.000000000 +0000 @@ -77,8 +77,8 @@ let item = tcx.hir.expect_item(node_id); debug!("check_item_well_formed(it.id={}, it.name={})", - item.id, - tcx.item_path_str(def_id)); + item.id, + tcx.item_path_str(def_id)); match item.node { // Right now we check that every default trait implementation @@ -110,20 +110,25 @@ // FIXME(#27579) what amount of WF checking do we need for neg impls? if trait_ref.is_some() && !is_auto { span_err!(tcx.sess, item.span, E0192, - "negative impls are only allowed for \ - auto traits (e.g., `Send` and `Sync`)") + "negative impls are only allowed for \ + auto traits (e.g., `Send` and `Sync`)") } } } hir::ItemKind::Fn(..) => { check_item_fn(tcx, item); } - hir::ItemKind::Static(..) => { - check_item_type(tcx, item); + hir::ItemKind::Static(ref ty, ..) => { + check_item_type(tcx, item.id, ty.span); } - hir::ItemKind::Const(..) => { - check_item_type(tcx, item); + hir::ItemKind::Const(ref ty, ..) => { + check_item_type(tcx, item.id, ty.span); } + hir::ItemKind::ForeignMod(ref module) => for it in module.items.iter() { + if let hir::ForeignItemKind::Static(ref ty, ..) = it.node { + check_item_type(tcx, it.id, ty.span); + } + }, hir::ItemKind::Struct(ref struct_def, ref ast_generics) => { check_type_defn(tcx, item, false, |fcx| { vec![fcx.non_enum_variant(struct_def)] @@ -175,9 +180,9 @@ } fn check_associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - item_id: ast::NodeId, - span: Span, - sig_if_method: Option<&hir::MethodSig>) { + item_id: ast::NodeId, + span: Span, + sig_if_method: Option<&hir::MethodSig>) { let code = ObligationCauseCode::MiscObligation; for_id(tcx, item_id, span).with_fcx(|fcx, tcx| { let item = fcx.tcx.associated_item(fcx.tcx.hir.local_def_id(item_id)); @@ -185,7 +190,7 @@ let (mut implied_bounds, self_ty) = match item.container { ty::TraitContainer(_) => (vec![], fcx.tcx.mk_self_type()), ty::ImplContainer(def_id) => (fcx.impl_implied_bounds(def_id, span), - fcx.tcx.type_of(def_id)) + fcx.tcx.type_of(def_id)) }; match item.kind { @@ -199,7 +204,7 @@ let sig = fcx.tcx.fn_sig(item.def_id); let sig = fcx.normalize_associated_types_in(span, &sig); check_fn_or_method(tcx, fcx, span, sig, - item.def_id, &mut implied_bounds); + item.def_id, &mut implied_bounds); let sig_if_method = sig_if_method.expect("bad signature for method"); check_method_receiver(fcx, sig_if_method, &item, self_ty); } @@ -220,12 +225,12 @@ } fn for_item<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>, item: &hir::Item) - -> CheckWfFcxBuilder<'a, 'gcx, 'tcx> { + -> CheckWfFcxBuilder<'a, 'gcx, 'tcx> { for_id(tcx, item.id, item.span) } fn for_id<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>, id: ast::NodeId, span: Span) - -> CheckWfFcxBuilder<'a, 'gcx, 'tcx> { + -> CheckWfFcxBuilder<'a, 'gcx, 'tcx> { let def_id = tcx.hir.local_def_id(id); CheckWfFcxBuilder { inherited: Inherited::build(tcx, def_id), @@ -304,6 +309,19 @@ fn check_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item: &hir::Item) { let trait_def_id = tcx.hir.local_def_id(item.id); + + let trait_def = tcx.trait_def(trait_def_id); + if trait_def.is_marker { + for associated_def_id in &*tcx.associated_item_def_ids(trait_def_id) { + struct_span_err!( + tcx.sess, + tcx.def_span(*associated_def_id), + E0714, + "marker traits cannot have associated items", + ).emit(); + } + } + for_item(tcx, item).with_fcx(|fcx, _| { check_where_clauses(tcx, fcx, item.span, trait_def_id, None); vec![] @@ -317,30 +335,37 @@ let sig = fcx.normalize_associated_types_in(item.span, &sig); let mut implied_bounds = vec![]; check_fn_or_method(tcx, fcx, item.span, sig, - def_id, &mut implied_bounds); + def_id, &mut implied_bounds); implied_bounds }) } -fn check_item_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - item: &hir::Item) -{ - debug!("check_item_type: {:?}", item); - - for_item(tcx, item).with_fcx(|fcx, _this| { - let ty = fcx.tcx.type_of(fcx.tcx.hir.local_def_id(item.id)); - let item_ty = fcx.normalize_associated_types_in(item.span, &ty); +fn check_item_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId, ty_span: Span) { + debug!("check_item_type: {:?}", item_id); - fcx.register_wf_obligation(item_ty, item.span, ObligationCauseCode::MiscObligation); + for_id(tcx, item_id, ty_span).with_fcx(|fcx, gcx| { + let ty = gcx.type_of(gcx.hir.local_def_id(item_id)); + let item_ty = fcx.normalize_associated_types_in(ty_span, &ty); + + fcx.register_wf_obligation(item_ty, ty_span, ObligationCauseCode::MiscObligation); + fcx.register_bound( + item_ty, + fcx.tcx.require_lang_item(lang_items::SizedTraitLangItem), + traits::ObligationCause::new( + ty_span, + fcx.body_id, + traits::MiscObligation, + ), + ); vec![] // no implied bounds in a const etc }); } fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - item: &hir::Item, - ast_self_ty: &hir::Ty, - ast_trait_ref: &Option) + item: &hir::Item, + ast_self_ty: &hir::Ty, + ast_trait_ref: &Option) { debug!("check_impl: {:?}", item); @@ -449,7 +474,8 @@ } }); // Now we build the substituted predicates. - let default_obligations = predicates.predicates.iter().flat_map(|&pred| { + let default_obligations = predicates.predicates.iter().flat_map(|&(pred, _)| { + #[derive(Default)] struct CountParams { params: FxHashSet } impl<'tcx> ty::fold::TypeVisitor<'tcx> for CountParams { fn visit_ty(&mut self, t: Ty<'tcx>) -> bool { @@ -466,17 +492,14 @@ true } } - let mut param_count = CountParams { params: FxHashSet() }; + let mut param_count = CountParams::default(); let has_region = pred.visit_with(&mut param_count); let substituted_pred = pred.subst(fcx.tcx, substs); // Don't check non-defaulted params, dependent defaults (including lifetimes) // or preds with multiple params. - if { - substituted_pred.references_error() || param_count.params.len() > 1 - || has_region - } { - None - } else if predicates.predicates.contains(&substituted_pred) { + if substituted_pred.references_error() || param_count.params.len() > 1 || has_region { + None + } else if predicates.predicates.iter().any(|&(p, _)| p == substituted_pred) { // Avoid duplication of predicates that contain no parameters, for example. None } else { @@ -522,11 +545,11 @@ } fn check_fn_or_method<'a, 'fcx, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>, - fcx: &FnCtxt<'fcx, 'gcx, 'tcx>, - span: Span, - sig: ty::PolyFnSig<'tcx>, - def_id: DefId, - implied_bounds: &mut Vec>) + fcx: &FnCtxt<'fcx, 'gcx, 'tcx>, + span: Span, + sig: ty::PolyFnSig<'tcx>, + def_id: DefId, + implied_bounds: &mut Vec>) { let sig = fcx.normalize_associated_types_in(span, &sig); let sig = fcx.tcx.liberate_late_bound_regions(def_id, &sig); @@ -584,7 +607,7 @@ let opaque_node_id = tcx.hir.as_local_node_id(def_id).unwrap(); if may_define_existential_type(tcx, fn_def_id, opaque_node_id) { trace!("check_existential_types may define. Generics: {:#?}", generics); - let mut seen: FxHashMap<_, Vec<_>> = FxHashMap(); + let mut seen: FxHashMap<_, Vec<_>> = FxHashMap::default(); for (subst, param) in substs.iter().zip(&generics.params) { match subst.unpack() { ty::subst::UnpackedKind::Type(ty) => match ty.sty { @@ -651,7 +674,7 @@ } // if may_define_existential_type // now register the bounds on the parameters of the existential type - // so the parameters given by the function need to fulfil them + // so the parameters given by the function need to fulfill them // ```rust // existential type Foo: 'static; // fn foo() -> Foo { .. *} @@ -666,10 +689,10 @@ "check_existential_types may define. adding predicates: {:#?}", predicates, ); - for &pred in predicates.predicates.iter() { + for &(pred, _) in predicates.predicates.iter() { let substituted_pred = pred.subst(fcx.tcx, substs); // Avoid duplication of predicates that contain no parameters, for example. - if !predicates.predicates.contains(&substituted_pred) { + if !predicates.predicates.iter().any(|&(p, _)| p == substituted_pred) { substituted_predicates.push(substituted_pred); } } @@ -689,7 +712,7 @@ { // check that the method has a valid receiver type, given the type `Self` debug!("check_method_receiver({:?}, self_ty={:?})", - method, self_ty); + method, self_ty); if !method.method_has_self_argument { return; @@ -793,14 +816,14 @@ let mut constrained_parameters: FxHashSet<_> = variances.iter().enumerate() - .filter(|&(_, &variance)| variance != ty::Bivariant) - .map(|(index, _)| Parameter(index as u32)) - .collect(); + .filter(|&(_, &variance)| variance != ty::Bivariant) + .map(|(index, _)| Parameter(index as u32)) + .collect(); identify_constrained_type_params(tcx, - ty_predicates.predicates.as_slice(), - None, - &mut constrained_parameters); + &ty_predicates, + None, + &mut constrained_parameters); for (index, _) in variances.iter().enumerate() { if constrained_parameters.contains(&Parameter(index as u32)) { @@ -808,27 +831,25 @@ } let param = &hir_generics.params[index]; - report_bivariance(tcx, param.span, param.name.ident().name); + match param.name { + hir::ParamName::Error => { } + _ => report_bivariance(tcx, param.span, param.name.ident().name), + } } } fn report_bivariance<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - span: Span, - param_name: ast::Name) + span: Span, + param_name: ast::Name) { let mut err = error_392(tcx, span, param_name); let suggested_marker_id = tcx.lang_items().phantom_data(); - match suggested_marker_id { - Some(def_id) => { - err.help( - &format!("consider removing `{}` or using a marker such as `{}`", - param_name, - tcx.item_path_str(def_id))); - } - None => { - // no lang items, no help! - } + // help is available only in presence of lang items + if let Some(def_id) = suggested_marker_id { + err.help(&format!("consider removing `{}` or using a marker such as `{}`", + param_name, + tcx.item_path_str(def_id))); } err.emit(); } @@ -842,11 +863,10 @@ }).collect(); for method_param in &generics.params { - match method_param.kind { - // Shadowing is checked in resolve_lifetime. - GenericParamDefKind::Lifetime => continue, - _ => {}, - }; + // Shadowing is checked in resolve_lifetime. + if let GenericParamDefKind::Lifetime = method_param.kind { + continue + } if impl_params.contains_key(&method_param.name) { // Tighten up the span to focus on only the shadowing type let type_span = tcx.def_span(method_param.def_id); @@ -863,16 +883,19 @@ /// Feature gates RFC 2056 - trivial bounds, checking for global bounds that /// aren't true. fn check_false_global_bounds<'a, 'gcx, 'tcx>( - fcx: &FnCtxt<'a, 'gcx, 'tcx>, - span: Span, - id: ast::NodeId, -) { + fcx: &FnCtxt<'a, 'gcx, 'tcx>, + span: Span, + id: ast::NodeId) +{ use rustc::ty::TypeFoldable; let empty_env = ty::ParamEnv::empty(); let def_id = fcx.tcx.hir.local_def_id(id); - let predicates = fcx.tcx.predicates_of(def_id).predicates; + let predicates = fcx.tcx.predicates_of(def_id).predicates + .into_iter() + .map(|(p, _)| p) + .collect(); // Check elaborated bounds let implied_obligations = traits::elaborate_predicates(fcx.tcx, predicates); @@ -950,15 +973,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { fn non_enum_variant(&self, struct_def: &hir::VariantData) -> AdtVariant<'tcx> { - let fields = - struct_def.fields().iter() - .map(|field| { - let field_ty = self.tcx.type_of(self.tcx.hir.local_def_id(field.id)); - let field_ty = self.normalize_associated_types_in(field.span, - &field_ty); - AdtField { ty: field_ty, span: field.span } - }) - .collect(); + let fields = struct_def.fields().iter().map(|field| { + let field_ty = self.tcx.type_of(self.tcx.hir.local_def_id(field.id)); + let field_ty = self.normalize_associated_types_in(field.span, + &field_ty); + AdtField { ty: field_ty, span: field.span } + }) + .collect(); AdtVariant { fields: fields } } @@ -997,8 +1018,8 @@ fn error_194(tcx: TyCtxt, span: Span, trait_decl_span: Span, name: &str) { struct_span_err!(tcx.sess, span, E0194, - "type parameter `{}` shadows another type parameter of the same name", - name) + "type parameter `{}` shadows another type parameter of the same name", + name) .span_label(span, "shadows another type parameter") .span_label(trait_decl_span, format!("first `{}` declared here", name)) .emit(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/writeback.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/writeback.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check/writeback.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check/writeback.rs 2018-12-04 23:41:40.000000000 +0000 @@ -52,6 +52,7 @@ wbcx.visit_cast_types(); wbcx.visit_free_region_map(); wbcx.visit_user_provided_tys(); + wbcx.visit_user_provided_sigs(); let used_trait_imports = mem::replace( &mut self.tables.borrow_mut().used_trait_imports, @@ -75,7 +76,7 @@ } /////////////////////////////////////////////////////////////////////////// -// The Writerback context. This visitor walks the AST, checking the +// The Writeback context. This visitor walks the AST, checking the // fn-specific tables to find references to types or regions. It // resolves those regions to remove inference variables and writes the // final result back into the master tables in the tcx. Here and @@ -178,39 +179,34 @@ if let hir::ExprKind::Index(ref base, ref index) = e.node { let mut tables = self.fcx.tables.borrow_mut(); - match tables.expr_ty_adjusted(&base).sty { - // All valid indexing looks like this - ty::Ref(_, base_ty, _) => { - let index_ty = tables.expr_ty_adjusted(&index); - let index_ty = self.fcx.resolve_type_vars_if_possible(&index_ty); - - if base_ty.builtin_index().is_some() && index_ty == self.fcx.tcx.types.usize { - // Remove the method call record - tables.type_dependent_defs_mut().remove(e.hir_id); - tables.node_substs_mut().remove(e.hir_id); - - tables.adjustments_mut().get_mut(base.hir_id).map(|a| { - // Discard the need for a mutable borrow - match a.pop() { - // Extra adjustment made when indexing causes a drop - // of size information - we need to get rid of it - // Since this is "after" the other adjustment to be - // discarded, we do an extra `pop()` - Some(Adjustment { - kind: Adjust::Unsize, - .. - }) => { - // So the borrow discard actually happens here - a.pop(); - } - _ => {} + // All valid indexing looks like this; might encounter non-valid indexes at this point + if let ty::Ref(_, base_ty, _) = tables.expr_ty_adjusted(&base).sty { + let index_ty = tables.expr_ty_adjusted(&index); + let index_ty = self.fcx.resolve_type_vars_if_possible(&index_ty); + + if base_ty.builtin_index().is_some() && index_ty == self.fcx.tcx.types.usize { + // Remove the method call record + tables.type_dependent_defs_mut().remove(e.hir_id); + tables.node_substs_mut().remove(e.hir_id); + + tables.adjustments_mut().get_mut(base.hir_id).map(|a| { + // Discard the need for a mutable borrow + match a.pop() { + // Extra adjustment made when indexing causes a drop + // of size information - we need to get rid of it + // Since this is "after" the other adjustment to be + // discarded, we do an extra `pop()` + Some(Adjustment { + kind: Adjust::Unsize, + .. + }) => { + // So the borrow discard actually happens here + a.pop(); } - }); - } + _ => {} + } + }); } - // Might encounter non-valid indexes at this point, so there - // has to be a fall-through - _ => {} } } } @@ -290,7 +286,7 @@ fn visit_local(&mut self, l: &'gcx hir::Local) { intravisit::walk_local(self, l); - let var_ty = self.fcx.local_ty(l.span, l.id); + let var_ty = self.fcx.local_ty(l.span, l.id).decl_ty; let var_ty = self.resolve(&var_ty, &l.span); self.write_ty_to_tables(l.hir_id, var_ty); } @@ -393,6 +389,27 @@ } } + fn visit_user_provided_sigs(&mut self) { + let fcx_tables = self.fcx.tables.borrow(); + debug_assert_eq!(fcx_tables.local_id_root, self.tables.local_id_root); + + for (&def_id, c_sig) in fcx_tables.user_provided_sigs.iter() { + let c_sig = if let Some(c_sig) = self.tcx().lift_to_global(c_sig) { + c_sig + } else { + span_bug!( + self.fcx.tcx.hir.span_if_local(def_id).unwrap(), + "writeback: `{:?}` missing from the global type context", + c_sig + ); + }; + + self.tables + .user_provided_sigs + .insert(def_id, c_sig.clone()); + } + } + fn visit_opaque_types(&mut self, span: Span) { for (&def_id, opaque_defn) in self.fcx.opaque_types.borrow().iter() { let node_id = self.tcx().hir.as_local_node_id(def_id).unwrap(); @@ -445,7 +462,7 @@ span, &format!( "type parameter `{}` is part of concrete type but not used \ - in parameter list for existential type", + in parameter list for existential type", ty, ), ) @@ -767,10 +784,7 @@ // FIXME This should be carefully checked // We could use `self.report_error` but it doesn't accept a ty::Region, right now. fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { - match self.infcx.fully_resolve(&r) { - Ok(r) => r, - Err(_) => self.tcx.types.re_static, - } + self.infcx.fully_resolve(&r).unwrap_or(self.tcx.types.re_static) } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check_unused.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check_unused.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/check_unused.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/check_unused.rs 2018-12-04 23:41:40.000000000 +0000 @@ -75,7 +75,7 @@ let msg = if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span) { format!("unused import: `{}`", snippet) } else { - "unused import".to_string() + "unused import".to_owned() }; self.tcx.lint_node(lint::builtin::UNUSED_IMPORTS, id, span, &msg); } @@ -138,9 +138,15 @@ if extern_crate.warn_if_unused { if let Some(&span) = unused_extern_crates.get(&extern_crate.def_id) { let msg = "unused extern crate"; + + // Removal suggestion span needs to include attributes (Issue #54400) + let span_with_attrs = tcx.get_attrs(extern_crate.def_id).iter() + .map(|attr| attr.span) + .fold(span, |acc, attr_span| acc.to(attr_span)); + tcx.struct_span_lint_node(lint, id, span, msg) .span_suggestion_short_with_applicability( - span, + span_with_attrs, "remove it", String::new(), Applicability::MachineApplicable) @@ -158,7 +164,7 @@ // If the extern crate isn't in the extern prelude, // there is no way it can be written as an `use`. let orig_name = extern_crate.orig_name.unwrap_or(item.name); - if !tcx.extern_prelude.contains(&orig_name) { + if !tcx.extern_prelude.get(&orig_name).map_or(false, |from_item| !from_item) { continue; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/coherence/builtin.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/coherence/builtin.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/coherence/builtin.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/coherence/builtin.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,6 +11,7 @@ //! Check properties that are required by built-in traits and set //! up data structures required by type-checking/codegen. +use rustc::infer::SuppressRegionErrors; use rustc::infer::outlives::env::OutlivesEnvironment; use rustc::middle::region; use rustc::middle::lang_items::UnsizeTraitLangItem; @@ -54,33 +55,29 @@ } fn visit_implementation_of_drop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_did: DefId) { - match tcx.type_of(impl_did).sty { - ty::Adt(..) => {} - _ => { - // Destructors only work on nominal types. - if let Some(impl_node_id) = tcx.hir.as_local_node_id(impl_did) { - match tcx.hir.find(impl_node_id) { - Some(Node::Item(item)) => { - let span = match item.node { - ItemKind::Impl(.., ref ty, _) => ty.span, - _ => item.span, - }; - struct_span_err!(tcx.sess, - span, - E0120, - "the Drop trait may only be implemented on \ - structures") - .span_label(span, "implementing Drop requires a struct") - .emit(); - } - _ => { - bug!("didn't find impl in ast map"); - } - } + if let ty::Adt(..) = tcx.type_of(impl_did).sty { + /* do nothing */ + } else { + // Destructors only work on nominal types. + if let Some(impl_node_id) = tcx.hir.as_local_node_id(impl_did) { + if let Some(Node::Item(item)) = tcx.hir.find(impl_node_id) { + let span = match item.node { + ItemKind::Impl(.., ref ty, _) => ty.span, + _ => item.span, + }; + struct_span_err!(tcx.sess, + span, + E0120, + "the Drop trait may only be implemented on \ + structures") + .span_label(span, "implementing Drop requires a struct") + .emit(); } else { - bug!("found external impl of Drop trait on \ - something other than a struct"); + bug!("didn't find impl in ast map"); } + } else { + bug!("found external impl of Drop trait on \ + something other than a struct"); } } } @@ -91,8 +88,7 @@ let impl_node_id = if let Some(n) = tcx.hir.as_local_node_id(impl_did) { n } else { - debug!("visit_implementation_of_copy(): impl not in this \ - crate"); + debug!("visit_implementation_of_copy(): impl not in this crate"); return; }; @@ -118,11 +114,11 @@ }; let mut err = struct_span_err!(tcx.sess, - span, - E0204, - "the trait `Copy` may not be implemented for this type"); + span, + E0204, + "the trait `Copy` may not be implemented for this type"); for span in fields.iter().map(|f| tcx.def_span(f.did)) { - err.span_label(span, "this field does not implement `Copy`"); + err.span_label(span, "this field does not implement `Copy`"); } err.emit() } @@ -172,12 +168,9 @@ debug!("compute_coerce_unsized_info(impl_did={:?})", impl_did); let coerce_unsized_trait = gcx.lang_items().coerce_unsized_trait().unwrap(); - let unsize_trait = match gcx.lang_items().require(UnsizeTraitLangItem) { - Ok(id) => id, - Err(err) => { - gcx.sess.fatal(&format!("`CoerceUnsized` implementation {}", err)); - } - }; + let unsize_trait = gcx.lang_items().require(UnsizeTraitLangItem).unwrap_or_else(|err| { + gcx.sess.fatal(&format!("`CoerceUnsized` implementation {}", err)); + }); // this provider should only get invoked for local def-ids let impl_node_id = gcx.hir.as_local_node_id(impl_did).unwrap_or_else(|| { @@ -209,9 +202,9 @@ mk_ptr: &dyn Fn(Ty<'gcx>) -> Ty<'gcx>| { if (mt_a.mutbl, mt_b.mutbl) == (hir::MutImmutable, hir::MutMutable) { infcx.report_mismatched_types(&cause, - mk_ptr(mt_b.ty), - target, - ty::error::TypeError::Mutability) + mk_ptr(mt_b.ty), + target, + ty::error::TypeError::Mutability) .emit(); } (mt_a.ty, mt_b.ty, unsize_trait, None) @@ -234,7 +227,7 @@ } (&ty::Adt(def_a, substs_a), &ty::Adt(def_b, substs_b)) if def_a.is_struct() && - def_b.is_struct() => { + def_b.is_struct() => { if def_a != def_b { let source_path = gcx.item_path_str(def_a.did); let target_path = gcx.item_path_str(def_b.did); @@ -276,7 +269,7 @@ // exactly one (non-phantom) field has changed its // type, which we will expect to be the pointer that // is becoming fat (we could probably generalize this - // to mutiple thin pointers of the same type becoming + // to multiple thin pointers of the same type becoming // fat, but we don't). In this case: // // - `extra` has type `T` before and type `T` after @@ -396,6 +389,7 @@ impl_did, ®ion_scope_tree, &outlives_env, + SuppressRegionErrors::default(), ); CoerceUnsizedInfo { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/coherence/inherent_impls.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/coherence/inherent_impls.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/coherence/inherent_impls.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/coherence/inherent_impls.rs 2018-12-04 23:41:40.000000000 +0000 @@ -108,8 +108,8 @@ ty::Foreign(did) => { self.check_def_id(item, did); } - ty::Dynamic(ref data, ..) if data.principal().is_some() => { - self.check_def_id(item, data.principal().unwrap().def_id()); + ty::Dynamic(ref data, ..) => { + self.check_def_id(item, data.principal().def_id()); } ty::Char => { self.check_primitive_impl(def_id, @@ -315,8 +315,7 @@ E0116, "cannot define inherent `impl` for a type outside of the crate \ where the type is defined") - .span_label(item.span, - "impl for type defined outside of crate.") + .span_label(item.span, "impl for type defined outside of crate.") .note("define and implement a trait or new type instead") .emit(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/coherence/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/coherence/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/coherence/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/coherence/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -36,8 +36,8 @@ if let Some(trait_ref) = tcx.impl_trait_ref(impl_def_id) { debug!("(checking implementation) adding impl for trait '{:?}', item '{}'", - trait_ref, - tcx.item_path_str(impl_def_id)); + trait_ref, + tcx.item_path_str(impl_def_id)); // Skip impls where one of the self type is an error type. // This occurs with e.g. resolve failures (#30589). @@ -46,6 +46,7 @@ } enforce_trait_manually_implementable(tcx, impl_def_id, trait_ref.def_id); + enforce_empty_impls_for_marker_traits(tcx, impl_def_id, trait_ref.def_id); } } @@ -99,6 +100,25 @@ .emit(); } +/// We allow impls of marker traits to overlap, so they can't override impls +/// as that could make it ambiguous which associated item to use. +fn enforce_empty_impls_for_marker_traits(tcx: TyCtxt, impl_def_id: DefId, trait_def_id: DefId) { + if !tcx.trait_def(trait_def_id).is_marker { + return; + } + + if tcx.associated_item_def_ids(trait_def_id).is_empty() { + return; + } + + let span = tcx.sess.source_map().def_span(tcx.span_of_impl(impl_def_id).unwrap()); + struct_span_err!(tcx.sess, + span, + E0715, + "impls for marker traits cannot contain items") + .emit(); +} + pub fn provide(providers: &mut Providers) { use self::builtin::coerce_unsized_info; use self::inherent_impls::{crate_inherent_impls, inherent_impls}; @@ -161,13 +181,12 @@ // This is something like impl Trait1 for Trait2. Illegal // if Trait1 is a supertrait of Trait2 or Trait2 is not object safe. - if data.principal().map_or(true, |p| !tcx.is_object_safe(p.def_id())) { + if !tcx.is_object_safe(data.principal().def_id()) { // This is an error, but it will be reported by wfcheck. Ignore it here. // This is tested by `coherence-impl-trait-for-trait-object-safe.rs`. } else { let mut supertrait_def_ids = - traits::supertrait_def_ids(tcx, - data.principal().unwrap().def_id()); + traits::supertrait_def_ids(tcx, data.principal().def_id()); if supertrait_def_ids.any(|d| d == trait_def_id) { let sp = tcx.sess.source_map().def_span(tcx.span_of_impl(impl_def_id).unwrap()); struct_span_err!(tcx.sess, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/coherence/orphan.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/coherence/orphan.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/coherence/orphan.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/coherence/orphan.rs 2018-12-04 23:41:40.000000000 +0000 @@ -33,131 +33,126 @@ /// reports. fn visit_item(&mut self, item: &hir::Item) { let def_id = self.tcx.hir.local_def_id(item.id); - match item.node { - hir::ItemKind::Impl(.., Some(_), _, _) => { - // "Trait" impl - debug!("coherence2::orphan check: trait impl {}", - self.tcx.hir.node_to_string(item.id)); - let trait_ref = self.tcx.impl_trait_ref(def_id).unwrap(); - let trait_def_id = trait_ref.def_id; - let cm = self.tcx.sess.source_map(); - let sp = cm.def_span(item.span); - match traits::orphan_check(self.tcx, def_id) { - Ok(()) => {} - Err(traits::OrphanCheckErr::NoLocalInputType) => { - struct_span_err!(self.tcx.sess, - sp, - E0117, - "only traits defined in the current crate can be \ - implemented for arbitrary types") - .span_label(sp, "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") - .emit(); - return; - } - Err(traits::OrphanCheckErr::UncoveredTy(param_ty)) => { - struct_span_err!(self.tcx.sess, - sp, - E0210, - "type parameter `{}` must be used as the type parameter \ - for some local type (e.g. `MyStruct<{}>`)", - param_ty, - param_ty) - .span_label(sp, - format!("type parameter `{}` must be used as the type \ - parameter for some local type", param_ty)) - .note("only traits defined in the current crate can be implemented \ - for a type parameter") - .emit(); - return; - } + // "Trait" impl + if let hir::ItemKind::Impl(.., Some(_), _, _) = item.node { + debug!("coherence2::orphan check: trait impl {}", + self.tcx.hir.node_to_string(item.id)); + let trait_ref = self.tcx.impl_trait_ref(def_id).unwrap(); + let trait_def_id = trait_ref.def_id; + let cm = self.tcx.sess.source_map(); + let sp = cm.def_span(item.span); + match traits::orphan_check(self.tcx, def_id) { + Ok(()) => {} + Err(traits::OrphanCheckErr::NoLocalInputType) => { + struct_span_err!(self.tcx.sess, + sp, + E0117, + "only traits defined in the current crate can be \ + implemented for arbitrary types") + .span_label(sp, "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") + .emit(); + return; + } + Err(traits::OrphanCheckErr::UncoveredTy(param_ty)) => { + struct_span_err!(self.tcx.sess, + sp, + E0210, + "type parameter `{}` must be used as the type parameter \ + for some local type (e.g. `MyStruct<{}>`)", + param_ty, + param_ty) + .span_label(sp, + format!("type parameter `{}` must be used as the type \ + parameter for some local type", param_ty)) + .note("only traits defined in the current crate can be implemented \ + for a type parameter") + .emit(); + return; } + } - // In addition to the above rules, we restrict impls of auto traits - // so that they can only be implemented on nominal types, such as structs, - // enums or foreign types. To see why this restriction exists, consider the - // following example (#22978). Imagine that crate A defines an auto trait - // `Foo` and a fn that operates on pairs of types: - // - // ``` - // // Crate A - // auto trait Foo { } - // fn two_foos(..) { - // one_foo::<(A,B)>(..) - // } - // fn one_foo(..) { .. } - // ``` - // - // This type-checks fine; in particular the fn - // `two_foos` is able to conclude that `(A,B):Foo` - // because `A:Foo` and `B:Foo`. - // - // Now imagine that crate B comes along and does the following: - // - // ``` - // struct A { } - // struct B { } - // impl Foo for A { } - // impl Foo for B { } - // impl !Send for (A, B) { } - // ``` - // - // This final impl is legal according to the orpan - // rules, but it invalidates the reasoning from - // `two_foos` above. - debug!("trait_ref={:?} trait_def_id={:?} trait_is_auto={}", - trait_ref, - trait_def_id, - self.tcx.trait_is_auto(trait_def_id)); - if self.tcx.trait_is_auto(trait_def_id) && - !trait_def_id.is_local() { - let self_ty = trait_ref.self_ty(); - let opt_self_def_id = match self_ty.sty { - ty::Adt(self_def, _) => Some(self_def.did), - ty::Foreign(did) => Some(did), - _ => None, - }; + // In addition to the above rules, we restrict impls of auto traits + // so that they can only be implemented on nominal types, such as structs, + // enums or foreign types. To see why this restriction exists, consider the + // following example (#22978). Imagine that crate A defines an auto trait + // `Foo` and a fn that operates on pairs of types: + // + // ``` + // // Crate A + // auto trait Foo { } + // fn two_foos(..) { + // one_foo::<(A,B)>(..) + // } + // fn one_foo(..) { .. } + // ``` + // + // This type-checks fine; in particular the fn + // `two_foos` is able to conclude that `(A,B):Foo` + // because `A:Foo` and `B:Foo`. + // + // Now imagine that crate B comes along and does the following: + // + // ``` + // struct A { } + // struct B { } + // impl Foo for A { } + // impl Foo for B { } + // impl !Send for (A, B) { } + // ``` + // + // This final impl is legal according to the orpan + // rules, but it invalidates the reasoning from + // `two_foos` above. + debug!("trait_ref={:?} trait_def_id={:?} trait_is_auto={}", + trait_ref, + trait_def_id, + self.tcx.trait_is_auto(trait_def_id)); + if self.tcx.trait_is_auto(trait_def_id) && + !trait_def_id.is_local() { + let self_ty = trait_ref.self_ty(); + let opt_self_def_id = match self_ty.sty { + ty::Adt(self_def, _) => Some(self_def.did), + ty::Foreign(did) => Some(did), + _ => None, + }; - let msg = match opt_self_def_id { - // We only want to permit nominal types, but not *all* nominal types. - // They must be local to the current crate, so that people - // can't do `unsafe impl Send for Rc` or - // `impl !Send for Box`. - Some(self_def_id) => { - if self_def_id.is_local() { - None - } else { - Some(( - format!("cross-crate traits with a default impl, like `{}`, \ - can only be implemented for a struct/enum type \ - defined in the current crate", - self.tcx.item_path_str(trait_def_id)), - "can't implement cross-crate trait for type in another crate" - )) - } - } - _ => { - Some((format!("cross-crate traits with a default impl, like `{}`, can \ - only be implemented for a struct/enum type, not `{}`", - self.tcx.item_path_str(trait_def_id), - self_ty), - "can't implement cross-crate trait with a default impl for \ - non-struct/enum type")) + let msg = match opt_self_def_id { + // We only want to permit nominal types, but not *all* nominal types. + // They must be local to the current crate, so that people + // can't do `unsafe impl Send for Rc` or + // `impl !Send for Box`. + Some(self_def_id) => { + if self_def_id.is_local() { + None + } else { + Some(( + format!("cross-crate traits with a default impl, like `{}`, \ + can only be implemented for a struct/enum type \ + defined in the current crate", + self.tcx.item_path_str(trait_def_id)), + "can't implement cross-crate trait for type in another crate" + )) } - }; - - if let Some((msg, label)) = msg { - struct_span_err!(self.tcx.sess, sp, E0321, "{}", msg) - .span_label(sp, label) - .emit(); - return; } + _ => { + Some((format!("cross-crate traits with a default impl, like `{}`, can \ + only be implemented for a struct/enum type, not `{}`", + self.tcx.item_path_str(trait_def_id), + self_ty), + "can't implement cross-crate trait with a default impl for \ + non-struct/enum type")) + } + }; + + if let Some((msg, label)) = msg { + struct_span_err!(self.tcx.sess, sp, E0321, "{}", msg) + .span_label(sp, label) + .emit(); + return; } } - _ => { - // Not an impl - } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/coherence/unsafety.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/coherence/unsafety.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/coherence/unsafety.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/coherence/unsafety.rs 2018-12-04 23:41:40.000000000 +0000 @@ -29,52 +29,49 @@ item: &'v hir::Item, impl_generics: Option<&hir::Generics>, unsafety: hir::Unsafety, - polarity: hir::ImplPolarity) { - match self.tcx.impl_trait_ref(self.tcx.hir.local_def_id(item.id)) { - None => {} - - Some(trait_ref) => { - let trait_def = self.tcx.trait_def(trait_ref.def_id); - let unsafe_attr = impl_generics.and_then(|generics| { - generics.params.iter().find(|p| p.pure_wrt_drop).map(|_| "may_dangle") - }); - match (trait_def.unsafety, unsafe_attr, unsafety, polarity) { - (Unsafety::Normal, None, Unsafety::Unsafe, hir::ImplPolarity::Positive) => { - span_err!(self.tcx.sess, - item.span, - E0199, - "implementing the trait `{}` is not unsafe", - trait_ref); - } + polarity: hir::ImplPolarity) + { + if let Some(trait_ref) = self.tcx.impl_trait_ref(self.tcx.hir.local_def_id(item.id)) { + let trait_def = self.tcx.trait_def(trait_ref.def_id); + let unsafe_attr = impl_generics.and_then(|generics| { + generics.params.iter().find(|p| p.pure_wrt_drop).map(|_| "may_dangle") + }); + match (trait_def.unsafety, unsafe_attr, unsafety, polarity) { + (Unsafety::Normal, None, Unsafety::Unsafe, hir::ImplPolarity::Positive) => { + span_err!(self.tcx.sess, + item.span, + E0199, + "implementing the trait `{}` is not unsafe", + trait_ref); + } - (Unsafety::Unsafe, _, Unsafety::Normal, hir::ImplPolarity::Positive) => { - span_err!(self.tcx.sess, - item.span, - E0200, - "the trait `{}` requires an `unsafe impl` declaration", - trait_ref); - } + (Unsafety::Unsafe, _, Unsafety::Normal, hir::ImplPolarity::Positive) => { + span_err!(self.tcx.sess, + item.span, + E0200, + "the trait `{}` requires an `unsafe impl` declaration", + trait_ref); + } - (Unsafety::Normal, Some(attr_name), Unsafety::Normal, - hir::ImplPolarity::Positive) => - { - span_err!(self.tcx.sess, - item.span, - E0569, - "requires an `unsafe impl` declaration due to `#[{}]` attribute", - attr_name); - } + (Unsafety::Normal, Some(attr_name), Unsafety::Normal, + hir::ImplPolarity::Positive) => + { + span_err!(self.tcx.sess, + item.span, + E0569, + "requires an `unsafe impl` declaration due to `#[{}]` attribute", + attr_name); + } - (_, _, Unsafety::Unsafe, hir::ImplPolarity::Negative) => { - // Reported in AST validation - self.tcx.sess.delay_span_bug(item.span, "unsafe negative impl"); - } - (_, _, Unsafety::Normal, hir::ImplPolarity::Negative) | - (Unsafety::Unsafe, _, Unsafety::Unsafe, hir::ImplPolarity::Positive) | - (Unsafety::Normal, Some(_), Unsafety::Unsafe, hir::ImplPolarity::Positive) | - (Unsafety::Normal, None, Unsafety::Normal, _) => { - // OK - } + (_, _, Unsafety::Unsafe, hir::ImplPolarity::Negative) => { + // Reported in AST validation + self.tcx.sess.delay_span_bug(item.span, "unsafe negative impl"); + } + (_, _, Unsafety::Normal, hir::ImplPolarity::Negative) | + (Unsafety::Unsafe, _, Unsafety::Unsafe, hir::ImplPolarity::Positive) | + (Unsafety::Normal, Some(_), Unsafety::Unsafe, hir::ImplPolarity::Positive) | + (Unsafety::Normal, None, Unsafety::Normal, _) => { + // OK } } } @@ -83,11 +80,8 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for UnsafetyChecker<'cx, 'tcx> { fn visit_item(&mut self, item: &'v hir::Item) { - match item.node { - hir::ItemKind::Impl(unsafety, polarity, _, ref generics, ..) => { - self.check_unsafety_coherence(item, Some(generics), unsafety, polarity); - } - _ => {} + if let hir::ItemKind::Impl(unsafety, polarity, _, ref generics, ..) = item.node { + self.check_unsafety_coherence(item, Some(generics), unsafety, polarity); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/collect.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/collect.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/collect.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/collect.rs 2018-12-04 23:41:40.000000000 +0000 @@ -56,14 +56,16 @@ use rustc::hir::GenericParamKind; use rustc::hir::{self, CodegenFnAttrFlags, CodegenFnAttrs, Unsafety}; +use std::iter; + /////////////////////////////////////////////////////////////////////////// // Main entry point pub fn collect_item_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let mut visitor = CollectItemTypesVisitor { tcx: tcx }; tcx.hir - .krate() - .visit_all_item_likes(&mut visitor.as_deep_visitor()); + .krate() + .visit_all_item_likes(&mut visitor.as_deep_visitor()); } pub fn provide(providers: &mut Providers) { @@ -195,7 +197,8 @@ E0121, "the type placeholder `_` is not allowed within types on item signatures" ).span_label(span, "not allowed in type signatures") - .emit(); + .emit(); + self.tcx().types.err } @@ -292,9 +295,10 @@ ItemKind::Trait(_, _, ref generics, ..) => { // Implied `Self: Trait` and supertrait bounds. if param_id == item_node_id { + let identity_trait_ref = ty::TraitRef::identity(tcx, item_def_id); result .predicates - .push(ty::TraitRef::identity(tcx, item_def_id).to_predicate()); + .push((identity_trait_ref.to_predicate(), item.span)); } generics } @@ -327,7 +331,7 @@ ast_generics: &hir::Generics, param_id: ast::NodeId, ty: Ty<'tcx>, - ) -> Vec> { + ) -> Vec<(ty::Predicate<'tcx>, Span)> { let from_ty_params = ast_generics .params .iter() @@ -526,12 +530,11 @@ ).span_label( variant.span, format!("overflowed on value after {}", prev_discr.unwrap()), - ) - .note(&format!( - "explicitly set `{} = {}` if that is desired outcome", - variant.node.name, wrapped_discr - )) - .emit(); + ).note(&format!( + "explicitly set `{} = {}` if that is desired outcome", + variant.node.name, wrapped_discr + )) + .emit(); None }.unwrap_or(wrapped_discr), ); @@ -555,9 +558,10 @@ name: ast::Name, discr: ty::VariantDiscr, def: &hir::VariantData, - adt_kind: ty::AdtKind + adt_kind: ty::AdtKind, + attribute_def_id: DefId ) -> ty::VariantDef { - let mut seen_fields: FxHashMap = FxHashMap(); + let mut seen_fields: FxHashMap = Default::default(); let node_id = tcx.hir.as_local_node_id(did).unwrap(); let fields = def .fields() @@ -573,8 +577,8 @@ "field `{}` is already declared", f.ident ).span_label(f.span, "field already declared") - .span_label(prev_span, format!("`{}` first declared here", f.ident)) - .emit(); + .span_label(prev_span, format!("`{}` first declared here", f.ident)) + .emit(); } else { seen_fields.insert(f.ident.modern(), f.span); } @@ -592,7 +596,8 @@ discr, fields, adt_kind, - CtorKind::from_hir(def)) + CtorKind::from_hir(def), + attribute_def_id) } fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::AdtDef { @@ -622,7 +627,8 @@ }; distance_from_explicit += 1; - convert_variant(tcx, did, v.node.name, discr, &v.node.data, AdtKind::Enum) + convert_variant(tcx, did, v.node.name, discr, &v.node.data, AdtKind::Enum, + did) }) .collect(), ) @@ -642,7 +648,8 @@ item.name, ty::VariantDiscr::Relative(0), def, - AdtKind::Struct + AdtKind::Struct, + def_id )], ) } @@ -654,7 +661,8 @@ item.name, ty::VariantDiscr::Relative(0), def, - AdtKind::Union + AdtKind::Union, + def_id )], ), _ => bug!(), @@ -700,8 +708,10 @@ // Now require that immediate supertraits are converted, // which will, in turn, reach indirect supertraits. - for bound in superbounds.iter().filter_map(|p| p.to_opt_poly_trait_ref()) { - tcx.at(item.span).super_predicates_of(bound.def_id()); + for &(pred, span) in &superbounds { + if let ty::Predicate::Trait(bound) = pred { + tcx.at(span).super_predicates_of(bound.def_id()); + } } ty::GenericPredicates { @@ -735,8 +745,9 @@ err.emit(); } + let is_marker = tcx.has_attr(def_id, "marker"); let def_path_hash = tcx.def_path_hash(def_id); - let def = ty::TraitDef::new(def_id, unsafety, paren_sugar, is_auto, def_path_hash); + let def = ty::TraitDef::new(def_id, unsafety, paren_sugar, is_auto, is_marker, def_path_hash); tcx.alloc_trait_def(def) } @@ -813,14 +824,11 @@ has_late_bound_regions: None, }; for param in &generics.params { - match param.kind { - GenericParamKind::Lifetime { .. } => { - let hir_id = tcx.hir.node_to_hir_id(param.id); - if tcx.is_late_bound(hir_id) { - return Some(param.span); - } + if let GenericParamKind::Lifetime { .. } = param.kind { + let hir_id = tcx.hir.node_to_hir_id(param.id); + if tcx.is_late_bound(hir_id) { + return Some(param.span); } - _ => {} } } visitor.visit_fn_decl(decl); @@ -1303,6 +1311,7 @@ def_id: DefId, found: Option<(Span, ty::Ty<'tcx>)>, } + impl<'a, 'tcx> ConstraintLocator<'a, 'tcx> { fn check(&mut self, def_id: DefId) { trace!("checking {:?}", def_id); @@ -1336,6 +1345,7 @@ } } } + impl<'a, 'tcx> intravisit::Visitor<'tcx> for ConstraintLocator<'a, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> { intravisit::NestedVisitorMap::All(&self.tcx.hir) @@ -1362,6 +1372,7 @@ intravisit::walk_trait_item(self, it); } } + let mut locator = ConstraintLocator { def_id, tcx, @@ -1369,7 +1380,9 @@ }; let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); let parent = tcx.hir.get_parent(node_id); + trace!("parent_id: {:?}", parent); + if parent == ast::CRATE_NODE_ID { intravisit::walk_crate(&mut locator, tcx.hir.krate()); } else { @@ -1384,6 +1397,7 @@ ), } } + match locator.found { Some((_, ty)) => ty, None => { @@ -1577,15 +1591,12 @@ tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId, ) -> ty::GenericPredicates<'tcx> { + debug!("predicates_defined_on({:?})", def_id); let explicit = tcx.explicit_predicates_of(def_id); - let predicates = if tcx.sess.features_untracked().infer_outlives_requirements { - [ - &explicit.predicates[..], - &tcx.inferred_outlives_of(def_id)[..], - ].concat() - } else { - explicit.predicates - }; + let span = tcx.def_span(def_id); + let predicates = explicit.predicates.into_iter().chain( + tcx.inferred_outlives_of(def_id).iter().map(|&p| (p, span)) + ).collect(); ty::GenericPredicates { parent: explicit.parent, @@ -1615,7 +1626,8 @@ // prove that the trait applies to the types that were // used, and adding the predicate into this list ensures // that this is done. - predicates.push(ty::TraitRef::identity(tcx, def_id).to_predicate()); + let span = tcx.def_span(def_id); + predicates.push((ty::TraitRef::identity(tcx, def_id).to_predicate(), span)); } ty::GenericPredicates { parent, predicates } @@ -1626,9 +1638,39 @@ def_id: DefId, ) -> ty::GenericPredicates<'tcx> { use rustc::hir::*; + use rustc_data_structures::fx::FxHashSet; debug!("explicit_predicates_of(def_id={:?})", def_id); + /// A data structure with unique elements, which preserves order of insertion. + /// Preserving the order of insertion is important here so as not to break + /// compile-fail UI tests. + struct UniquePredicates<'tcx> { + predicates: Vec<(ty::Predicate<'tcx>, Span)>, + uniques: FxHashSet<(ty::Predicate<'tcx>, Span)>, + } + + impl<'tcx> UniquePredicates<'tcx> { + fn new() -> Self { + UniquePredicates { + predicates: vec![], + uniques: FxHashSet::default(), + } + } + + fn push(&mut self, value: (ty::Predicate<'tcx>, Span)) { + if self.uniques.insert(value) { + self.predicates.push(value); + } + } + + fn extend, Span)>>(&mut self, iter: I) { + for value in iter { + self.push(value); + } + } + } + let node_id = tcx.hir.as_local_node_id(def_id).unwrap(); let node = tcx.hir.get(node_id); @@ -1638,7 +1680,7 @@ let icx = ItemCtxt::new(tcx, def_id); let no_generics = hir::Generics::empty(); - let mut predicates = vec![]; + let mut predicates = UniquePredicates::new(); let ast_generics = match node { Node::TraitItem(item) => &item.generics, @@ -1733,7 +1775,7 @@ // on a trait we need to add in the supertrait bounds and bounds found on // associated types. if let Some((_trait_ref, _)) = is_trait { - predicates = tcx.super_predicates_of(def_id).predicates; + predicates.extend(tcx.super_predicates_of(def_id).predicates); } // In default impls, we can assume that the self type implements @@ -1745,7 +1787,7 @@ // (see below). Recall that a default impl is not itself an impl, but rather a // set of defaults that can be incorporated into another impl. if let Some(trait_ref) = is_default_impl_trait { - predicates.push(trait_ref.to_poly_trait_ref().to_predicate()); + predicates.push((trait_ref.to_poly_trait_ref().to_predicate(), tcx.def_span(def_id))); } // Collect the region predicates that were declared inline as @@ -1766,7 +1808,7 @@ hir::GenericBound::Outlives(lt) => { let bound = AstConv::ast_region_to_region(&icx, <, None); let outlives = ty::Binder::bind(ty::OutlivesPredicate(region, bound)); - predicates.push(outlives.to_predicate()); + predicates.push((outlives.to_predicate(), lt.span)); } _ => bug!(), }); @@ -1778,17 +1820,14 @@ // Collect the predicates that were written inline by the user on each // type parameter (e.g., ``). for param in &ast_generics.params { - match param.kind { - GenericParamKind::Type { .. } => { - let name = param.name.ident().as_interned_str(); - let param_ty = ty::ParamTy::new(index, name).to_ty(tcx); - index += 1; - - let sized = SizedByDefault::Yes; - let bounds = compute_bounds(&icx, param_ty, ¶m.bounds, sized, param.span); - predicates.extend(bounds.predicates(tcx, param_ty)); - } - _ => {} + if let GenericParamKind::Type { .. } = param.kind { + let name = param.name.ident().as_interned_str(); + let param_ty = ty::ParamTy::new(index, name).to_ty(tcx); + index += 1; + + let sized = SizedByDefault::Yes; + let bounds = compute_bounds(&icx, param_ty, ¶m.bounds, sized, param.span); + predicates.extend(bounds.predicates(tcx, param_ty)); } } @@ -1810,7 +1849,8 @@ // users who never wrote `where Type:,` themselves, to // compiler/tooling bugs from not handling WF predicates. } else { - predicates.push(ty::Predicate::WellFormed(ty)); + let span = bound_pred.bounded_ty.span; + predicates.push((ty::Predicate::WellFormed(ty), span)); } } @@ -1826,14 +1866,16 @@ &mut projections, ); - predicates.push(trait_ref.to_predicate()); - predicates.extend(projections.iter().map(|p| p.to_predicate())); + predicates.extend( + iter::once((trait_ref.to_predicate(), poly_trait_ref.span)).chain( + projections.iter().map(|&(p, span)| (p.to_predicate(), span) + ))); } &hir::GenericBound::Outlives(ref lifetime) => { let region = AstConv::ast_region_to_region(&icx, lifetime, None); let pred = ty::Binder::bind(ty::OutlivesPredicate(ty, region)); - predicates.push(ty::Predicate::TypeOutlives(pred)) + predicates.push((ty::Predicate::TypeOutlives(pred), lifetime.span)) } } } @@ -1841,16 +1883,17 @@ &hir::WherePredicate::RegionPredicate(ref region_pred) => { let r1 = AstConv::ast_region_to_region(&icx, ®ion_pred.lifetime, None); - for bound in ®ion_pred.bounds { - let r2 = match bound { + predicates.extend(region_pred.bounds.iter().map(|bound| { + let (r2, span) = match bound { hir::GenericBound::Outlives(lt) => { - AstConv::ast_region_to_region(&icx, lt, None) + (AstConv::ast_region_to_region(&icx, lt, None), lt.span) } _ => bug!(), }; let pred = ty::Binder::bind(ty::OutlivesPredicate(r1, r2)); - predicates.push(ty::Predicate::RegionOutlives(pred)) - } + + (ty::Predicate::RegionOutlives(pred), span) + })) } &hir::WherePredicate::EqPredicate(..) => { @@ -1865,9 +1908,7 @@ let trait_item = tcx.hir.trait_item(trait_item_ref.id); let bounds = match trait_item.node { hir::TraitItemKind::Type(ref bounds, _) => bounds, - _ => { - return vec![].into_iter(); - } + _ => return vec![].into_iter() }; let assoc_ty = @@ -1885,6 +1926,8 @@ })) } + let mut predicates = predicates.predicates; + // Subtle: before we store the predicates into the tcx, we // sort them so that predicates like `T: Foo` come // before uses of `U`. This avoids false ambiguity errors @@ -1928,6 +1971,7 @@ ) -> Bounds<'tcx> { let mut region_bounds = vec![]; let mut trait_bounds = vec![]; + for ast_bound in ast_bounds { match *ast_bound { hir::GenericBound::Trait(ref b, hir::TraitBoundModifier::None) => trait_bounds.push(b), @@ -1938,22 +1982,25 @@ let mut projection_bounds = vec![]; - let mut trait_bounds: Vec<_> = trait_bounds - .iter() - .map(|&bound| astconv.instantiate_poly_trait_ref(bound, param_ty, &mut projection_bounds)) - .collect(); + let mut trait_bounds: Vec<_> = trait_bounds.iter().map(|&bound| { + (astconv.instantiate_poly_trait_ref(bound, param_ty, &mut projection_bounds), bound.span) + }).collect(); let region_bounds = region_bounds .into_iter() - .map(|r| astconv.ast_region_to_region(r, None)) + .map(|r| (astconv.ast_region_to_region(r, None), r.span)) .collect(); - trait_bounds.sort_by_key(|t| t.def_id()); + trait_bounds.sort_by_key(|(t, _)| t.def_id()); let implicitly_sized = if let SizedByDefault::Yes = sized_by_default { - !is_unsized(astconv, ast_bounds, span) + if !is_unsized(astconv, ast_bounds, span) { + Some(span) + } else { + None + } } else { - false + None }; Bounds { @@ -1973,21 +2020,21 @@ astconv: &dyn AstConv<'tcx, 'tcx>, param_ty: Ty<'tcx>, bound: &hir::GenericBound, -) -> Vec> { +) -> Vec<(ty::Predicate<'tcx>, Span)> { match *bound { hir::GenericBound::Trait(ref tr, hir::TraitBoundModifier::None) => { let mut projections = Vec::new(); let pred = astconv.instantiate_poly_trait_ref(tr, param_ty, &mut projections); - projections - .into_iter() - .map(|p| p.to_predicate()) - .chain(Some(pred.to_predicate())) - .collect() + iter::once((pred.to_predicate(), tr.span)).chain( + projections + .into_iter() + .map(|(p, span)| (p.to_predicate(), span)) + ).collect() } hir::GenericBound::Outlives(ref lifetime) => { let region = astconv.ast_region_to_region(lifetime, None); let pred = ty::Binder::bind(ty::OutlivesPredicate(param_ty, region)); - vec![ty::Predicate::TypeOutlives(pred)] + vec![(ty::Predicate::TypeOutlives(pred), lifetime.span)] } hir::GenericBound::Trait(_, hir::TraitBoundModifier::Maybe) => vec![], } @@ -2001,7 +2048,7 @@ ) -> ty::PolyFnSig<'tcx> { let unsafety = if abi == abi::Abi::RustIntrinsic { match &*tcx.item_name(def_id).as_str() { - "size_of" | "min_align_of" => hir::Unsafety::Normal, + "size_of" | "min_align_of" | "needs_drop" => hir::Unsafety::Normal, _ => hir::Unsafety::Unsafe, } } else { @@ -2018,16 +2065,16 @@ let check = |ast_ty: &hir::Ty, ty: Ty| { if ty.is_simd() { tcx.sess - .struct_span_err( - ast_ty.span, - &format!( - "use of SIMD type `{}` in FFI is highly experimental and \ - may result in invalid code", - tcx.hir.node_to_pretty_string(ast_ty.id) - ), - ) - .help("add #![feature(simd_ffi)] to the crate attributes to enable") - .emit(); + .struct_span_err( + ast_ty.span, + &format!( + "use of SIMD type `{}` in FFI is highly experimental and \ + may result in invalid code", + tcx.hir.node_to_pretty_string(ast_ty.id) + ), + ) + .help("add #![feature(simd_ffi)] to the crate attributes to enable") + .emit(); } }; for (input, ty) in decl.inputs.iter().zip(*fty.inputs().skip_binder()) { @@ -2087,7 +2134,7 @@ }; // We allow comma separation to enable multiple features - for feature in value.as_str().split(',') { + target_features.extend(value.as_str().split(',').filter_map(|feature| { // Only allow whitelisted features per platform let feature_gate = match whitelist.get(feature) { Some(g) => g, @@ -2106,7 +2153,7 @@ } } err.emit(); - continue; + return None; } }; @@ -2133,10 +2180,10 @@ feature_gate::GateIssue::Language, &format!("the target feature `{}` is currently unstable", feature), ); - continue; + return None; } - target_features.push(Symbol::intern(feature)); - } + Some(Symbol::intern(feature)) + })); } } @@ -2169,7 +2216,7 @@ tcx.sess.span_fatal(span, "invalid linkage specified") } else { tcx.sess - .fatal(&format!("invalid linkage specified: {}", name)) + .fatal(&format!("invalid linkage specified: {}", name)) } } } @@ -2267,7 +2314,7 @@ E0558, "`export_name` attribute has invalid format" ).span_label(attr.span, "did you mean #[export_name=\"*\"]?") - .emit(); + .emit(); } } else if attr.check_name("target_feature") { if tcx.fn_sig(id).unsafety() == Unsafety::Normal { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/constrained_type_params.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/constrained_type_params.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/constrained_type_params.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/constrained_type_params.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,6 +11,7 @@ use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::fold::{TypeFoldable, TypeVisitor}; use rustc::util::nodemap::FxHashSet; +use syntax::source_map::Span; #[derive(Clone, PartialEq, Eq, Hash, Debug)] pub struct Parameter(pub u32); @@ -76,22 +77,19 @@ } fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool { - match *r { - ty::ReEarlyBound(data) => { - self.parameters.push(Parameter::from(data)); - } - _ => {} + if let ty::ReEarlyBound(data) = *r { + self.parameters.push(Parameter::from(data)); } false } } -pub fn identify_constrained_type_params<'tcx>(tcx: TyCtxt, - predicates: &[ty::Predicate<'tcx>], +pub fn identify_constrained_type_params<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, + predicates: &ty::GenericPredicates<'tcx>, impl_trait_ref: Option>, input_parameters: &mut FxHashSet) { - let mut predicates = predicates.to_owned(); + let mut predicates = predicates.predicates.clone(); setup_constraining_predicates(tcx, &mut predicates, impl_trait_ref, input_parameters); } @@ -137,7 +135,7 @@ /// by 0. I should probably pick a less tangled example, but I can't /// think of any. pub fn setup_constraining_predicates<'tcx>(tcx: TyCtxt, - predicates: &mut [ty::Predicate<'tcx>], + predicates: &mut [(ty::Predicate<'tcx>, Span)], impl_trait_ref: Option>, input_parameters: &mut FxHashSet) { @@ -169,7 +167,7 @@ changed = false; for j in i..predicates.len() { - if let ty::Predicate::Projection(ref poly_projection) = predicates[j] { + if let ty::Predicate::Projection(ref poly_projection) = predicates[j].0 { // Note that we can skip binder here because the impl // trait ref never contains any late-bound regions. let projection = poly_projection.skip_binder(); @@ -203,6 +201,6 @@ } debug!("setup_constraining_predicates: predicates={:?} \ i={} impl_trait_ref={:?} input_parameters={:?}", - predicates, i, impl_trait_ref, input_parameters); + predicates, i, impl_trait_ref, input_parameters); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/diagnostics.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/diagnostics.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/diagnostics.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/diagnostics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -4750,6 +4750,22 @@ the type is unknown. "##, +E0714: r##" +A `#[marker]` trait contained an associated item. + +The items of marker traits cannot be overridden, so there's no need to have them +when they cannot be changed per-type anyway. If you wanted them for ergonomic +reasons, consider making an extension trait instead. +"##, + +E0715: r##" +An `impl` for a `#[marker]` trait tried to override an associated item. + +Because marker traits are allowed to have multiple implementations for the same +type, it's not allowed to override anything in those implementations, as it +would be ambiguous which override should actually be used. +"##, + } register_diagnostics! { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/impl_wf_check.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/impl_wf_check.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/impl_wf_check.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/impl_wf_check.rs 2018-12-04 23:41:40.000000000 +0000 @@ -71,15 +71,12 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for ImplWfCheck<'a, 'tcx> { fn visit_item(&mut self, item: &'tcx hir::Item) { - match item.node { - hir::ItemKind::Impl(.., ref impl_item_refs) => { - let impl_def_id = self.tcx.hir.local_def_id(item.id); - enforce_impl_params_are_constrained(self.tcx, - impl_def_id, - impl_item_refs); - enforce_impl_items_are_distinct(self.tcx, impl_item_refs); - } - _ => { } + if let hir::ItemKind::Impl(.., ref impl_item_refs) = item.node { + let impl_def_id = self.tcx.hir.local_def_id(item.id); + enforce_impl_params_are_constrained(self.tcx, + impl_def_id, + impl_item_refs); + enforce_impl_items_are_distinct(self.tcx, impl_item_refs); } } @@ -100,7 +97,7 @@ let mut input_parameters = ctp::parameters_for_impl(impl_self_ty, impl_trait_ref); ctp::identify_constrained_type_params( - tcx, &impl_predicates.predicates.as_slice(), impl_trait_ref, &mut input_parameters); + tcx, &impl_predicates, impl_trait_ref, &mut input_parameters); // Disallow unconstrained lifetimes, but only if they appear in assoc types. let lifetimes_in_associated_types: FxHashSet<_> = impl_item_refs.iter() @@ -176,13 +173,13 @@ fn enforce_impl_items_are_distinct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_item_refs: &[hir::ImplItemRef]) { - let mut seen_type_items = FxHashMap(); - let mut seen_value_items = FxHashMap(); + let mut seen_type_items = FxHashMap::default(); + let mut seen_value_items = FxHashMap::default(); for impl_item_ref in impl_item_refs { let impl_item = tcx.hir.impl_item(impl_item_ref.id); let seen_items = match impl_item.node { hir::ImplItemKind::Type(_) => &mut seen_type_items, - _ => &mut seen_value_items, + _ => &mut seen_value_items, }; match seen_items.entry(impl_item.ident.modern()) { Occupied(entry) => { @@ -191,7 +188,7 @@ impl_item.ident); err.span_label(*entry.get(), format!("previous definition of `{}` here", - impl_item.ident)); + impl_item.ident)); err.span_label(impl_item.span, "duplicate definition"); err.emit(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -75,8 +75,7 @@ #![feature(box_syntax)] #![feature(crate_visibility_modifier)] #![feature(exhaustive_patterns)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(quote)] #![feature(refcell_replace_swap)] #![feature(rustc_diagnostic_macros)] @@ -147,7 +146,7 @@ span: Span) { if decl.variadic && !(abi == Abi::C || abi == Abi::Cdecl) { let mut err = struct_span_err!(tcx.sess, span, E0045, - "variadic function must have C or cdecl calling convention"); + "variadic function must have C or cdecl calling convention"); err.span_label(span, "variadics require C or cdecl calling convention").emit(); } } @@ -187,35 +186,29 @@ let main_t = tcx.type_of(main_def_id); match main_t.sty { ty::FnDef(..) => { - match tcx.hir.find(main_id) { - Some(Node::Item(it)) => { - match it.node { - hir::ItemKind::Fn(.., ref generics, _) => { - let mut error = false; - if !generics.params.is_empty() { - let msg = "`main` function is not allowed to have generic \ - parameters".to_string(); - let label = "`main` cannot have generic parameters".to_string(); - struct_span_err!(tcx.sess, generics.span, E0131, "{}", msg) - .span_label(generics.span, label) - .emit(); - error = true; - } - if let Some(sp) = generics.where_clause.span() { - struct_span_err!(tcx.sess, sp, E0646, - "`main` function is not allowed to have a `where` clause") - .span_label(sp, "`main` cannot have a `where` clause") - .emit(); - error = true; - } - if error { - return; - } - } - _ => () + if let Some(Node::Item(it)) = tcx.hir.find(main_id) { + if let hir::ItemKind::Fn(.., ref generics, _) = it.node { + let mut error = false; + if !generics.params.is_empty() { + let msg = "`main` function is not allowed to have generic \ + parameters".to_owned(); + let label = "`main` cannot have generic parameters".to_string(); + struct_span_err!(tcx.sess, generics.span, E0131, "{}", msg) + .span_label(generics.span, label) + .emit(); + error = true; + } + if let Some(sp) = generics.where_clause.span() { + struct_span_err!(tcx.sess, sp, E0646, + "`main` function is not allowed to have a `where` clause") + .span_label(sp, "`main` cannot have a `where` clause") + .emit(); + error = true; + } + if error { + return; } } - _ => () } let actual = tcx.fn_sig(main_def_id); @@ -259,34 +252,28 @@ let start_t = tcx.type_of(start_def_id); match start_t.sty { ty::FnDef(..) => { - match tcx.hir.find(start_id) { - Some(Node::Item(it)) => { - match it.node { - hir::ItemKind::Fn(.., ref generics, _) => { - let mut error = false; - if !generics.params.is_empty() { - struct_span_err!(tcx.sess, generics.span, E0132, - "start function is not allowed to have type parameters") - .span_label(generics.span, - "start function cannot have type parameters") - .emit(); - error = true; - } - if let Some(sp) = generics.where_clause.span() { - struct_span_err!(tcx.sess, sp, E0647, - "start function is not allowed to have a `where` clause") - .span_label(sp, "start function cannot have a `where` clause") - .emit(); - error = true; - } - if error { - return; - } - } - _ => () + if let Some(Node::Item(it)) = tcx.hir.find(start_id) { + if let hir::ItemKind::Fn(.., ref generics, _) = it.node { + let mut error = false; + if !generics.params.is_empty() { + struct_span_err!(tcx.sess, generics.span, E0132, + "start function is not allowed to have type parameters") + .span_label(generics.span, + "start function cannot have type parameters") + .emit(); + error = true; + } + if let Some(sp) = generics.where_clause.span() { + struct_span_err!(tcx.sess, sp, E0647, + "start function is not allowed to have a `where` clause") + .span_label(sp, "start function cannot have a `where` clause") + .emit(); + error = true; + } + if error { + return; } } - _ => () } let se_ty = tcx.mk_fn_ptr(ty::Binder::bind( @@ -389,11 +376,12 @@ let env_node_id = tcx.hir.get_parent(hir_ty.id); let env_def_id = tcx.hir.local_def_id(env_node_id); let item_cx = self::collect::ItemCtxt::new(tcx, env_def_id); + astconv::AstConv::ast_ty_to_ty(&item_cx, hir_ty) } pub fn hir_trait_to_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir_trait: &hir::TraitRef) - -> (ty::PolyTraitRef<'tcx>, Vec>) { + -> (ty::PolyTraitRef<'tcx>, Vec<(ty::PolyProjectionPredicate<'tcx>, Span)>) { // In case there are any projections etc, find the "environment" // def-id that will be used to determine the traits/predicates in // scope. This is derived from the enclosing item-like thing. @@ -404,6 +392,7 @@ let principal = astconv::AstConv::instantiate_poly_trait_ref_inner( &item_cx, hir_trait, tcx.types.err, &mut projections, true ); + (principal, projections) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/outlives/explicit.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/outlives/explicit.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/outlives/explicit.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/outlives/explicit.rs 2018-12-04 23:41:40.000000000 +0000 @@ -40,7 +40,7 @@ let mut required_predicates = RequiredPredicates::default(); // process predicates and convert to `RequiredPredicates` entry, see below - for pred in predicates.into_iter() { + for (pred, _) in predicates.into_iter() { match pred { ty::Predicate::TypeOutlives(predicate) => { let OutlivesPredicate(ref ty, ref reg) = predicate.skip_binder(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/outlives/implicit_infer.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/outlives/implicit_infer.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/outlives/implicit_infer.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/outlives/implicit_infer.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,6 +14,7 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::ty::subst::{Kind, Subst, UnpackedKind}; use rustc::ty::{self, Ty, TyCtxt}; +use rustc::ty::fold::TypeFoldable; use rustc::util::nodemap::FxHashMap; use super::explicit::ExplicitPredicatesMap; @@ -66,7 +67,8 @@ debug!("InferVisitor::visit_item(item={:?})", item_did); - let node_id = self.tcx + let node_id = self + .tcx .hir .as_local_node_id(item_did) .expect("expected local def-id"); @@ -108,7 +110,8 @@ // Therefore mark `predicates_added` as true and which will ensure // we walk the crates again and re-calculate predicates for all // items. - let item_predicates_len: usize = self.global_inferred_outlives + let item_predicates_len: usize = self + .global_inferred_outlives .get(&item_did) .map(|p| p.len()) .unwrap_or(0); @@ -201,28 +204,27 @@ debug!("Dynamic"); debug!("field_ty = {}", &field_ty); debug!("ty in field = {}", &ty); - if let Some(ex_trait_ref) = obj.principal() { - // Here, we are passing the type `usize` as a - // placeholder value with the function - // `with_self_ty`, since there is no concrete type - // `Self` for a `dyn Trait` at this - // stage. Therefore when checking explicit - // predicates in `check_explicit_predicates` we - // need to ignore checking the explicit_map for - // Self type. - let substs = ex_trait_ref - .with_self_ty(tcx, tcx.types.usize) - .skip_binder() - .substs; - check_explicit_predicates( - tcx, - &ex_trait_ref.skip_binder().def_id, - substs, - required_predicates, - explicit_map, - IgnoreSelfTy(true), - ); - } + let ex_trait_ref = obj.principal(); + // Here, we are passing the type `usize` as a + // placeholder value with the function + // `with_self_ty`, since there is no concrete type + // `Self` for a `dyn Trait` at this + // stage. Therefore when checking explicit + // predicates in `check_explicit_predicates` we + // need to ignore checking the explicit_map for + // Self type. + let substs = ex_trait_ref + .with_self_ty(tcx, tcx.types.usize) + .skip_binder() + .substs; + check_explicit_predicates( + tcx, + &ex_trait_ref.skip_binder().def_id, + substs, + required_predicates, + explicit_map, + IgnoreSelfTy(true), + ); } ty::Projection(obj) => { @@ -244,6 +246,7 @@ } } +#[derive(Debug)] pub struct IgnoreSelfTy(bool); /// We also have to check the explicit predicates @@ -269,10 +272,18 @@ explicit_map: &mut ExplicitPredicatesMap<'tcx>, ignore_self_ty: IgnoreSelfTy, ) { - debug!("def_id = {:?}", &def_id); - debug!("substs = {:?}", &substs); - debug!("explicit_map = {:?}", explicit_map); - debug!("required_predicates = {:?}", required_predicates); + debug!( + "check_explicit_predicates(def_id={:?}, \ + substs={:?}, \ + explicit_map={:?}, \ + required_predicates={:?}, \ + ignore_self_ty={:?})", + def_id, + substs, + explicit_map, + required_predicates, + ignore_self_ty, + ); let explicit_predicates = explicit_map.explicit_predicates_of(tcx, *def_id); for outlives_predicate in explicit_predicates.iter() { @@ -301,13 +312,23 @@ // // Note that we do this check for self **before** applying `substs`. In the // case that `substs` come from a `dyn Trait` type, our caller will have - // included `Self = dyn Trait<'x, X>` as the value for `Self`. If we were + // included `Self = usize` as the value for `Self`. If we were // to apply the substs, and not filter this predicate, we might then falsely // conclude that e.g. `X: 'x` was a reasonable inferred requirement. - if let UnpackedKind::Type(ty) = outlives_predicate.0.unpack() { - if ty.is_self() && ignore_self_ty.0 { - debug!("skipping self ty = {:?}", &ty); - continue; + // + // Another similar case is where we have a inferred + // requirement like `::Foo: 'b`. We presently + // ignore such requirements as well (cc #54467)-- though + // conceivably it might be better if we could extract the `Foo + // = X` binding from the object type (there must be such a + // binding) and thus infer an outlives requirement that `X: + // 'b`. + if ignore_self_ty.0 { + if let UnpackedKind::Type(ty) = outlives_predicate.0.unpack() { + if ty.has_self_ty() { + debug!("skipping self ty = {:?}", &ty); + continue; + } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/outlives/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/outlives/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/outlives/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/outlives/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -55,9 +55,7 @@ .iter() .map(|out_pred| match out_pred { ty::Predicate::RegionOutlives(p) => p.to_string(), - ty::Predicate::TypeOutlives(p) => p.to_string(), - err => bug!("unexpected predicate {:?}", err), }).collect(); pred.sort(); @@ -69,6 +67,9 @@ } err.emit(); } + + debug!("inferred_outlives_of({:?}) = {:?}", item_def_id, predicates); + predicates } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/outlives/test.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/outlives/test.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/outlives/test.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/outlives/test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,8 +14,8 @@ pub fn test_inferred_outlives<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { tcx.hir - .krate() - .visit_all_item_likes(&mut OutlivesTest { tcx }); + .krate() + .visit_all_item_likes(&mut OutlivesTest { tcx }); } struct OutlivesTest<'a, 'tcx: 'a> { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/outlives/utils.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/outlives/utils.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/outlives/utils.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/outlives/utils.rs 2018-12-04 23:41:40.000000000 +0000 @@ -148,15 +148,9 @@ // field: &'static T, // this would generate a ReStatic // } RegionKind::ReStatic => { - if tcx - .sess - .features_untracked() - .infer_static_outlives_requirements - { - true - } else { - false - } + tcx.sess + .features_untracked() + .infer_static_outlives_requirements } // Late-bound regions can appear in `fn` types: @@ -176,7 +170,7 @@ | RegionKind::ReCanonical(..) | RegionKind::ReScope(..) | RegionKind::ReVar(..) - | RegionKind::ReSkolemized(..) + | RegionKind::RePlaceholder(..) | RegionKind::ReFree(..) => { bug!("unexpected region in outlives inference: {:?}", region); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/variance/constraints.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/variance/constraints.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/variance/constraints.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/variance/constraints.rs 2018-12-04 23:41:40.000000000 +0000 @@ -311,11 +311,11 @@ let contra = self.contravariant(variance); self.add_constraints_from_region(current, r, contra); - if let Some(p) = data.principal() { - let poly_trait_ref = p.with_self_ty(self.tcx(), self.tcx().types.err); - self.add_constraints_from_trait_ref( - current, *poly_trait_ref.skip_binder(), variance); - } + let poly_trait_ref = data + .principal() + .with_self_ty(self.tcx(), self.tcx().types.err); + self.add_constraints_from_trait_ref( + current, *poly_trait_ref.skip_binder(), variance); for projection in data.projection_bounds() { self.add_constraints_from_ty( @@ -336,6 +336,7 @@ // types, where we use Error as the Self type } + ty::UnnormalizedProjection(..) | ty::GeneratorWitness(..) | ty::Infer(..) => { bug!("unexpected type encountered in \ @@ -430,7 +431,7 @@ ty::ReClosureBound(..) | ty::ReScope(..) | ty::ReVar(..) | - ty::ReSkolemized(..) | + ty::RePlaceholder(..) | ty::ReEmpty | ty::ReErased => { // We don't expect to see anything but 'static or bound diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/variance/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/variance/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustc_typeck/variance/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustc_typeck/variance/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -48,14 +48,14 @@ fn crate_variances<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) -> Lrc { assert_eq!(crate_num, LOCAL_CRATE); - let mut arena = arena::TypedArena::new(); + let mut arena = arena::TypedArena::default(); let terms_cx = terms::determine_parameters_to_be_inferred(tcx, &mut arena); let constraints_cx = constraints::add_constraints_from_crate(terms_cx); Lrc::new(solve::solve_constraints(constraints_cx)) } fn variances_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_def_id: DefId) - -> Lrc> { + -> Lrc> { let id = tcx.hir.as_local_node_id(item_def_id).expect("expected local def-id"); let unsupported = || { // Variance not relevant. diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/librustdoc/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/Cargo.toml 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/Cargo.toml 2018-12-04 23:41:40.000000000 +0000 @@ -9,5 +9,6 @@ [dependencies] pulldown-cmark = { version = "0.1.2", default-features = false } -minifier = "0.0.19" +minifier = "0.0.20" tempfile = "3" +parking_lot = "0.6.4" diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/clean/auto_trait.rs rustc-1.31.0+dfsg1+llvm/src/librustdoc/clean/auto_trait.rs --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/clean/auto_trait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/clean/auto_trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -84,7 +84,7 @@ .into_iter() .chain(self.get_auto_trait_impl_for( def_id, - name.clone(), + name, generics.clone(), def_ctor, tcx.require_lang_item(lang_items::SyncTraitLangItem), @@ -178,7 +178,7 @@ inner: ImplItem(Impl { unsafety: hir::Unsafety::Normal, generics: new_generics, - provided_trait_methods: FxHashSet(), + provided_trait_methods: Default::default(), trait_: Some(trait_.clean(self.cx)), for_: ty.clean(self.cx), items: Vec::new(), @@ -267,9 +267,9 @@ // all intermediate RegionVids. At the end, all constraints should // be between Regions (aka region variables). This gives us the information // we need to create the Generics. - let mut finished: FxHashMap<_, Vec<_>> = FxHashMap(); + let mut finished: FxHashMap<_, Vec<_>> = Default::default(); - let mut vid_map: FxHashMap = FxHashMap(); + let mut vid_map: FxHashMap = Default::default(); // Flattening is done in two parts. First, we insert all of the constraints // into a map. Each RegionTarget (either a RegionVid or a Region) maps @@ -407,7 +407,7 @@ ) -> FxHashSet { pred.walk_tys() .flat_map(|t| { - let mut regions = FxHashSet(); + let mut regions = FxHashSet::default(); tcx.collect_regions(&t, &mut regions); regions.into_iter().flat_map(|r| { @@ -576,12 +576,12 @@ .. } = full_generics.clean(self.cx); - let mut has_sized = FxHashSet(); - let mut ty_to_bounds: FxHashMap<_, FxHashSet<_>> = FxHashMap(); - let mut lifetime_to_bounds: FxHashMap<_, FxHashSet<_>> = FxHashMap(); - let mut ty_to_traits: FxHashMap> = FxHashMap(); + let mut has_sized = FxHashSet::default(); + let mut ty_to_bounds: FxHashMap<_, FxHashSet<_>> = Default::default(); + let mut lifetime_to_bounds: FxHashMap<_, FxHashSet<_>> = Default::default(); + let mut ty_to_traits: FxHashMap> = Default::default(); - let mut ty_to_fn: FxHashMap, Option)> = FxHashMap(); + let mut ty_to_fn: FxHashMap, Option)> = Default::default(); for (orig_p, p) in clean_where_predicates { match p { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/clean/blanket_impl.rs rustc-1.31.0+dfsg1+llvm/src/librustdoc/clean/blanket_impl.rs --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/clean/blanket_impl.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/clean/blanket_impl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -50,6 +50,7 @@ name: Option, ) -> Vec where F: Fn(DefId) -> Def { + debug!("get_blanket_impls(def_id={:?}, ...)", def_id); let mut impls = Vec::new(); if self.cx .tcx @@ -66,10 +67,10 @@ } let ty = self.cx.tcx.type_of(def_id); let generics = self.cx.tcx.generics_of(def_id); - let real_name = name.clone().map(|name| Ident::from_str(&name)); + let real_name = name.map(|name| Ident::from_str(&name)); let param_env = self.cx.tcx.param_env(def_id); for &trait_def_id in self.cx.all_traits.iter() { - if !self.cx.access_levels.borrow().is_doc_reachable(trait_def_id) || + if !self.cx.renderinfo.borrow().access_levels.is_doc_reachable(trait_def_id) || self.cx.generated_synthetics .borrow_mut() .get(&(def_id, trait_def_id)) @@ -78,6 +79,8 @@ } self.cx.tcx.for_each_relevant_impl(trait_def_id, ty, |impl_def_id| { self.cx.tcx.infer_ctxt().enter(|infcx| { + debug!("get_blanet_impls: Considering impl for trait '{:?}' {:?}", + trait_def_id, impl_def_id); let t_generics = infcx.tcx.generics_of(impl_def_id); let trait_ref = infcx.tcx.impl_trait_ref(impl_def_id) .expect("Cannot get impl trait"); @@ -103,11 +106,24 @@ // FIXME(eddyb) ignoring `obligations` might cause false positives. drop(obligations); - let may_apply = infcx.predicate_may_hold(&traits::Obligation::new( - cause.clone(), - param_env, - trait_ref.to_predicate(), - )); + debug!( + "invoking predicate_may_hold: param_env={:?}, trait_ref={:?}, ty={:?}", + param_env, trait_ref, ty + ); + let may_apply = match infcx.evaluate_obligation( + &traits::Obligation::new( + cause, + param_env, + trait_ref.to_predicate(), + ), + ) { + Ok(eval_result) => eval_result.may_apply(), + Err(traits::OverflowError) => true, // overflow doesn't mean yes *or* no + }; + debug!("get_blanket_impls: found applicable impl: {}\ + for trait_ref={:?}, ty={:?}", + may_apply, trait_ref, ty); + if !may_apply { return } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/clean/inline.rs rustc-1.31.0+dfsg1+llvm/src/librustdoc/clean/inline.rs --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/clean/inline.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/clean/inline.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,7 +13,7 @@ use std::iter::once; use syntax::ast; -use syntax::ext::base::MacroKind; +use syntax::ext::base::{MacroKind, SyntaxExtension}; use syntax_pos::Span; use rustc::hir; @@ -29,8 +29,6 @@ self, GetDefId, ToSource, - get_auto_traits_with_def_id, - get_blanket_impls_with_def_id, }; use super::Clean; @@ -56,7 +54,7 @@ let inner = match def { Def::Trait(did) => { record_extern_fqn(cx, did, clean::TypeKind::Trait); - ret.extend(build_impls(cx, did, false)); + ret.extend(build_impls(cx, did)); clean::TraitItem(build_external_trait(cx, did)) } Def::Fn(did) => { @@ -65,27 +63,27 @@ } Def::Struct(did) => { record_extern_fqn(cx, did, clean::TypeKind::Struct); - ret.extend(build_impls(cx, did, true)); + ret.extend(build_impls(cx, did)); clean::StructItem(build_struct(cx, did)) } Def::Union(did) => { record_extern_fqn(cx, did, clean::TypeKind::Union); - ret.extend(build_impls(cx, did, true)); + ret.extend(build_impls(cx, did)); clean::UnionItem(build_union(cx, did)) } Def::TyAlias(did) => { record_extern_fqn(cx, did, clean::TypeKind::Typedef); - ret.extend(build_impls(cx, did, false)); + ret.extend(build_impls(cx, did)); clean::TypedefItem(build_type_alias(cx, did), false) } Def::Enum(did) => { record_extern_fqn(cx, did, clean::TypeKind::Enum); - ret.extend(build_impls(cx, did, true)); + ret.extend(build_impls(cx, did)); clean::EnumItem(build_enum(cx, did)) } Def::ForeignTy(did) => { record_extern_fqn(cx, did, clean::TypeKind::Foreign); - ret.extend(build_impls(cx, did, false)); + ret.extend(build_impls(cx, did)); clean::ForeignTypeItem } // Never inline enum variants but leave them shown as re-exports. @@ -107,12 +105,12 @@ record_extern_fqn(cx, did, clean::TypeKind::Const); clean::ConstantItem(build_const(cx, did)) } - // FIXME(misdreavus): if attributes/derives come down here we should probably document them - // separately + // FIXME: proc-macros don't propagate attributes or spans across crates, so they look empty Def::Macro(did, MacroKind::Bang) => { - record_extern_fqn(cx, did, clean::TypeKind::Macro); - if let Some(mac) = build_macro(cx, did, name) { - clean::MacroItem(mac) + let mac = build_macro(cx, did, name); + if let clean::MacroItem(..) = mac { + record_extern_fqn(cx, did, clean::TypeKind::Macro); + mac } else { return None; } @@ -159,12 +157,11 @@ /// These names are used later on by HTML rendering to generate things like /// source links back to the original item. pub fn record_extern_fqn(cx: &DocContext, did: DefId, kind: clean::TypeKind) { + let mut crate_name = cx.tcx.crate_name(did.krate).to_string(); if did.is_local() { - debug!("record_extern_fqn(did={:?}, kind+{:?}): def_id is local, aborting", did, kind); - return; + crate_name = cx.crate_name.clone().unwrap_or(crate_name); } - let crate_name = cx.tcx.crate_name(did.krate).to_string(); let relative = cx.tcx.def_path(did).data.into_iter().filter_map(|elem| { // extern blocks have an empty name let s = elem.data.to_string(); @@ -179,7 +176,12 @@ } else { once(crate_name).chain(relative).collect() }; - cx.renderinfo.borrow_mut().external_paths.insert(did, (fqn, kind)); + + if did.is_local() { + cx.renderinfo.borrow_mut().exact_paths.insert(did, fqn); + } else { + cx.renderinfo.borrow_mut().external_paths.insert(did, (fqn, kind)); + } } pub fn build_external_trait(cx: &DocContext, did: DefId) -> clean::Trait { @@ -271,7 +273,7 @@ } } -pub fn build_impls(cx: &DocContext, did: DefId, auto_traits: bool) -> Vec { +pub fn build_impls(cx: &DocContext, did: DefId) -> Vec { let tcx = cx.tcx; let mut impls = Vec::new(); @@ -279,85 +281,6 @@ build_impl(cx, did, &mut impls); } - if auto_traits { - let auto_impls = get_auto_traits_with_def_id(cx, did); - { - let mut renderinfo = cx.renderinfo.borrow_mut(); - let new_impls: Vec = auto_impls.into_iter() - .filter(|i| renderinfo.inlined.insert(i.def_id)).collect(); - - impls.extend(new_impls); - } - impls.extend(get_blanket_impls_with_def_id(cx, did)); - } - - // If this is the first time we've inlined something from another crate, then - // we inline *all* impls from all the crates into this crate. Note that there's - // currently no way for us to filter this based on type, and we likely need - // many impls for a variety of reasons. - // - // Primarily, the impls will be used to populate the documentation for this - // type being inlined, but impls can also be used when generating - // documentation for primitives (no way to find those specifically). - if cx.populated_all_crate_impls.get() { - return impls; - } - - cx.populated_all_crate_impls.set(true); - - for &cnum in tcx.crates().iter() { - for did in tcx.all_trait_implementations(cnum).iter() { - build_impl(cx, *did, &mut impls); - } - } - - // Also try to inline primitive impls from other crates. - let lang_items = tcx.lang_items(); - let primitive_impls = [ - lang_items.isize_impl(), - lang_items.i8_impl(), - lang_items.i16_impl(), - lang_items.i32_impl(), - lang_items.i64_impl(), - lang_items.i128_impl(), - lang_items.usize_impl(), - lang_items.u8_impl(), - lang_items.u16_impl(), - lang_items.u32_impl(), - lang_items.u64_impl(), - lang_items.u128_impl(), - lang_items.f32_impl(), - lang_items.f64_impl(), - lang_items.f32_runtime_impl(), - lang_items.f64_runtime_impl(), - lang_items.char_impl(), - lang_items.str_impl(), - lang_items.slice_impl(), - lang_items.slice_u8_impl(), - lang_items.str_alloc_impl(), - lang_items.slice_alloc_impl(), - lang_items.slice_u8_alloc_impl(), - lang_items.const_ptr_impl(), - lang_items.mut_ptr_impl(), - ]; - - for def_id in primitive_impls.iter().filter_map(|&def_id| def_id) { - if !def_id.is_local() { - build_impl(cx, def_id, &mut impls); - - let auto_impls = get_auto_traits_with_def_id(cx, def_id); - let blanket_impls = get_blanket_impls_with_def_id(cx, def_id); - let mut renderinfo = cx.renderinfo.borrow_mut(); - - let new_impls: Vec = auto_impls.into_iter() - .chain(blanket_impls.into_iter()) - .filter(|i| renderinfo.inlined.insert(i.def_id)) - .collect(); - - impls.extend(new_impls); - } - } - impls } @@ -372,30 +295,60 @@ // Only inline impl if the implemented trait is // reachable in rustdoc generated documentation - if let Some(traitref) = associated_trait { - if !cx.access_levels.borrow().is_doc_reachable(traitref.def_id) { - return + if !did.is_local() { + if let Some(traitref) = associated_trait { + if !cx.renderinfo.borrow().access_levels.is_doc_reachable(traitref.def_id) { + return + } } } - let for_ = tcx.type_of(did).clean(cx); + let for_ = if let Some(nodeid) = tcx.hir.as_local_node_id(did) { + match tcx.hir.expect_item(nodeid).node { + hir::ItemKind::Impl(.., ref t, _) => { + t.clean(cx) + } + _ => panic!("did given to build_impl was not an impl"), + } + } else { + tcx.type_of(did).clean(cx) + }; // Only inline impl if the implementing type is // reachable in rustdoc generated documentation - if let Some(did) = for_.def_id() { - if !cx.access_levels.borrow().is_doc_reachable(did) { - return + if !did.is_local() { + if let Some(did) = for_.def_id() { + if !cx.renderinfo.borrow().access_levels.is_doc_reachable(did) { + return + } } } let predicates = tcx.predicates_of(did); - let trait_items = tcx.associated_items(did).filter_map(|item| { - if associated_trait.is_some() || item.vis == ty::Visibility::Public { - Some(item.clean(cx)) - } else { - None + let (trait_items, generics) = if let Some(nodeid) = tcx.hir.as_local_node_id(did) { + match tcx.hir.expect_item(nodeid).node { + hir::ItemKind::Impl(.., ref gen, _, _, ref item_ids) => { + ( + item_ids.iter() + .map(|ii| tcx.hir.impl_item(ii.id).clean(cx)) + .collect::>(), + gen.clean(cx), + ) + } + _ => panic!("did given to build_impl was not an impl"), } - }).collect::>(); + } else { + ( + tcx.associated_items(did).filter_map(|item| { + if associated_trait.is_some() || item.vis == ty::Visibility::Public { + Some(item.clean(cx)) + } else { + None + } + }).collect::>(), + (tcx.generics_of(did), &predicates).clean(cx), + ) + }; let polarity = tcx.impl_polarity(did); let trait_ = associated_trait.clean(cx).map(|bound| { match bound { @@ -415,12 +368,14 @@ .into_iter() .map(|meth| meth.ident.to_string()) .collect() - }).unwrap_or(FxHashSet()); + }).unwrap_or_default(); + + debug!("build_impl: impl {:?} for {:?}", trait_.def_id(), for_.def_id()); ret.push(clean::Item { inner: clean::ImplItem(clean::Impl { unsafety: hir::Unsafety::Normal, - generics: (tcx.generics_of(did), &predicates).clean(cx), + generics, provided_trait_methods: provided, trait_, for_, @@ -465,7 +420,11 @@ } pub fn print_inlined_const(cx: &DocContext, did: DefId) -> String { - cx.tcx.rendered_const(did) + if let Some(node_id) = cx.tcx.hir.as_local_node_id(did) { + cx.tcx.hir.node_to_pretty_string(node_id) + } else { + cx.tcx.rendered_const(did) + } } fn build_const(cx: &DocContext, did: DefId) -> clean::Constant { @@ -483,31 +442,41 @@ } } -fn build_macro(cx: &DocContext, did: DefId, name: ast::Name) -> Option { +fn build_macro(cx: &DocContext, did: DefId, name: ast::Name) -> clean::ItemEnum { let imported_from = cx.tcx.original_crate_name(did.krate); - let def = match cx.cstore.load_macro_untracked(did, cx.sess()) { - LoadedMacro::MacroDef(macro_def) => macro_def, - // FIXME(jseyfried): document proc macro re-exports - LoadedMacro::ProcMacro(..) => return None, - }; + match cx.cstore.load_macro_untracked(did, cx.sess()) { + LoadedMacro::MacroDef(def) => { + let matchers: hir::HirVec = if let ast::ItemKind::MacroDef(ref def) = def.node { + let tts: Vec<_> = def.stream().into_trees().collect(); + tts.chunks(4).map(|arm| arm[0].span()).collect() + } else { + unreachable!() + }; - let matchers: hir::HirVec = if let ast::ItemKind::MacroDef(ref def) = def.node { - let tts: Vec<_> = def.stream().into_trees().collect(); - tts.chunks(4).map(|arm| arm[0].span()).collect() - } else { - unreachable!() - }; + let source = format!("macro_rules! {} {{\n{}}}", + name.clean(cx), + matchers.iter().map(|span| { + format!(" {} => {{ ... }};\n", span.to_src(cx)) + }).collect::()); + + clean::MacroItem(clean::Macro { + source, + imported_from: Some(imported_from).clean(cx), + }) + } + LoadedMacro::ProcMacro(ext) => { + let helpers = match &*ext { + &SyntaxExtension::ProcMacroDerive(_, ref syms, ..) => { syms.clean(cx) } + _ => Vec::new(), + }; + + clean::ProcMacroItem(clean::ProcMacro { + kind: ext.kind(), + helpers, + }) + } + } - let source = format!("macro_rules! {} {{\n{}}}", - name.clean(cx), - matchers.iter().map(|span| { - format!(" {} => {{ ... }};\n", span.to_src(cx)) - }).collect::()); - - Some(clean::Macro { - source, - imported_from: Some(imported_from).clean(cx), - }) } /// A trait's generics clause actually contains all of the predicates for all of @@ -576,16 +545,27 @@ } pub fn record_extern_trait(cx: &DocContext, did: DefId) { - if cx.external_traits.borrow().contains_key(&did) || - cx.active_extern_traits.borrow().contains(&did) - { + if did.is_local() { return; } + { + let external_traits = cx.external_traits.lock(); + if external_traits.borrow().contains_key(&did) || + cx.active_extern_traits.borrow().contains(&did) + { + return; + } + } + cx.active_extern_traits.borrow_mut().push(did); + debug!("record_extern_trait: {:?}", did); let trait_ = build_external_trait(cx, did); - cx.external_traits.borrow_mut().insert(did, trait_); + { + let external_traits = cx.external_traits.lock(); + external_traits.borrow_mut().insert(did, trait_); + } cx.active_extern_traits.borrow_mut().remove_item(&did); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/clean/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustdoc/clean/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/clean/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/clean/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -21,6 +21,7 @@ use rustc_target::spec::abi::Abi; use syntax::ast::{self, AttrStyle, Ident}; use syntax::attr; +use syntax::ext::base::MacroKind; use syntax::source_map::{dummy_spanned, Spanned}; use syntax::ptr::P; use syntax::symbol::keywords::{self, Keyword}; @@ -28,7 +29,6 @@ use syntax_pos::{self, DUMMY_SP, Pos, FileName}; use rustc::mir::interpret::ConstValue; -use rustc::middle::privacy::AccessLevels; use rustc::middle::resolve_lifetime as rl; use rustc::ty::fold::TypeFolder; use rustc::middle::lang_items; @@ -56,6 +56,8 @@ use std::sync::Arc; use std::u32; +use parking_lot::ReentrantMutex; + use core::{self, DocContext}; use doctree; use visit_ast; @@ -73,8 +75,7 @@ use self::auto_trait::AutoTraitFinder; use self::blanket_impl::BlanketImplFinder; -thread_local!(pub static MAX_DEF_ID: RefCell> = - RefCell::new(FxHashMap())); +thread_local!(pub static MAX_DEF_ID: RefCell> = Default::default()); const FN_OUTPUT_NAME: &'static str = "Output"; @@ -135,10 +136,9 @@ pub module: Option, pub externs: Vec<(CrateNum, ExternalCrate)>, pub primitives: Vec<(DefId, PrimitiveType, Attributes)>, - pub access_levels: Arc>, // These are later on moved into `CACHEKEY`, leaving the map empty. // Only here so that they can be filtered through the rustdoc passes. - pub external_traits: FxHashMap, + pub external_traits: Arc>>>, pub masked_crates: FxHashSet, } @@ -164,7 +164,7 @@ // Clean the crate, translating the entire libsyntax AST to one that is // understood by rustdoc. let mut module = self.module.clean(cx); - let mut masked_crates = FxHashSet(); + let mut masked_crates = FxHashSet::default(); match module.inner { ModuleItem(ref module) => { @@ -209,9 +209,6 @@ })); } - let mut access_levels = cx.access_levels.borrow_mut(); - let mut external_traits = cx.external_traits.borrow_mut(); - Crate { name, version: None, @@ -219,8 +216,7 @@ module: Some(module), externs, primitives, - access_levels: Arc::new(mem::replace(&mut access_levels, Default::default())), - external_traits: mem::replace(&mut external_traits, Default::default()), + external_traits: cx.external_traits.clone(), masked_crates, } } @@ -531,6 +527,7 @@ /// `type`s from an extern block ForeignTypeItem, MacroItem(Macro), + ProcMacroItem(ProcMacro), PrimitiveItem(PrimitiveType), AssociatedConstItem(Type, Option), AssociatedTypeItem(Vec, Option), @@ -579,9 +576,9 @@ let mut items: Vec = vec![]; items.extend(self.extern_crates.iter().map(|x| x.clean(cx))); items.extend(self.imports.iter().flat_map(|x| x.clean(cx))); - items.extend(self.structs.iter().flat_map(|x| x.clean(cx))); - items.extend(self.unions.iter().flat_map(|x| x.clean(cx))); - items.extend(self.enums.iter().flat_map(|x| x.clean(cx))); + items.extend(self.structs.iter().map(|x| x.clean(cx))); + items.extend(self.unions.iter().map(|x| x.clean(cx))); + items.extend(self.enums.iter().map(|x| x.clean(cx))); items.extend(self.fns.iter().map(|x| x.clean(cx))); items.extend(self.foreigns.iter().flat_map(|x| x.clean(cx))); items.extend(self.mods.iter().map(|x| x.clean(cx))); @@ -592,6 +589,7 @@ items.extend(self.traits.iter().map(|x| x.clean(cx))); items.extend(self.impls.iter().flat_map(|x| x.clean(cx))); items.extend(self.macros.iter().map(|x| x.clean(cx))); + items.extend(self.proc_macros.iter().map(|x| x.clean(cx))); // determine if we should display the inner contents or // the outer `mod` item for the source code. @@ -1259,7 +1257,7 @@ ty::ReFree(..) | ty::ReScope(..) | ty::ReVar(..) | - ty::ReSkolemized(..) | + ty::RePlaceholder(..) | ty::ReEmpty | ty::ReClosureBound(_) | ty::ReCanonical(_) | @@ -1575,7 +1573,9 @@ } }).collect::>(); - let mut where_predicates = preds.predicates.to_vec().clean(cx); + let mut where_predicates = preds.predicates.iter() + .map(|(p, _)| p.clean(cx)) + .collect::>(); // Type parameters and have a Sized bound by default unless removed with // ?Sized. Scan through the predicates and mark any type parameter with @@ -1584,7 +1584,7 @@ // Note that associated types also have a sized bound by default, but we // don't actually know the set of associated types right here so that's // handled in cleaning associated types - let mut sized_params = FxHashSet(); + let mut sized_params = FxHashSet::default(); where_predicates.retain(|pred| { match *pred { WP::BoundPredicate { ty: Generic(ref g), ref bounds } => { @@ -2193,6 +2193,8 @@ Typedef, Foreign, Macro, + Attr, + Derive, } pub trait GetDefId { @@ -2413,6 +2415,14 @@ Array(box ty.clean(cx), length) }, TyKind::Tup(ref tys) => Tuple(tys.clean(cx)), + TyKind::Def(item_id, _) => { + let item = cx.tcx.hir.expect_item(item_id.id); + if let hir::ItemKind::Existential(ref ty) = item.node { + ImplTrait(ty.bounds.clean(cx)) + } else { + unreachable!() + } + } TyKind::Path(hir::QPath::Resolved(None, ref path)) => { if let Some(new_ty) = cx.ty_substs.borrow().get(&path.def).cloned() { return new_ty; @@ -2422,21 +2432,13 @@ if let Some(bounds) = cx.impl_trait_bounds.borrow_mut().remove(&did) { return ImplTrait(bounds); } - } else if let Def::Existential(did) = path.def { - // This block is for returned impl trait only. - if let Some(node_id) = cx.tcx.hir.as_local_node_id(did) { - let item = cx.tcx.hir.expect_item(node_id); - if let hir::ItemKind::Existential(ref ty) = item.node { - return ImplTrait(ty.bounds.clean(cx)); - } - } } let mut alias = None; if let Def::TyAlias(def_id) = path.def { // Substitute private type aliases if let Some(node_id) = cx.tcx.hir.as_local_node_id(def_id) { - if !cx.access_levels.borrow().is_exported(def_id) { + if !cx.renderinfo.borrow().access_levels.is_exported(def_id) { alias = Some(&cx.tcx.hir.expect_item(node_id).node); } } @@ -2444,8 +2446,8 @@ if let Some(&hir::ItemKind::Ty(ref ty, ref generics)) = alias { let provided_params = &path.segments.last().expect("segments were empty"); - let mut ty_substs = FxHashMap(); - let mut lt_substs = FxHashMap(); + let mut ty_substs = FxHashMap::default(); + let mut lt_substs = FxHashMap::default(); provided_params.with_generic_args(|generic_args| { let mut indices: GenericParamCount = Default::default(); for param in generics.params.iter() { @@ -2629,47 +2631,44 @@ } } ty::Dynamic(ref obj, ref reg) => { - if let Some(principal) = obj.principal() { - let did = principal.def_id(); + let principal = obj.principal(); + let did = principal.def_id(); + inline::record_extern_fqn(cx, did, TypeKind::Trait); + + let mut typarams = vec![]; + reg.clean(cx).map(|b| typarams.push(GenericBound::Outlives(b))); + for did in obj.auto_traits() { + let empty = cx.tcx.intern_substs(&[]); + let path = external_path(cx, &cx.tcx.item_name(did).as_str(), + Some(did), false, vec![], empty); inline::record_extern_fqn(cx, did, TypeKind::Trait); + let bound = GenericBound::TraitBound(PolyTrait { + trait_: ResolvedPath { + path, + typarams: None, + did, + is_generic: false, + }, + generic_params: Vec::new(), + }, hir::TraitBoundModifier::None); + typarams.push(bound); + } - let mut typarams = vec![]; - reg.clean(cx).map(|b| typarams.push(GenericBound::Outlives(b))); - for did in obj.auto_traits() { - let empty = cx.tcx.intern_substs(&[]); - let path = external_path(cx, &cx.tcx.item_name(did).as_str(), - Some(did), false, vec![], empty); - inline::record_extern_fqn(cx, did, TypeKind::Trait); - let bound = GenericBound::TraitBound(PolyTrait { - trait_: ResolvedPath { - path, - typarams: None, - did, - is_generic: false, - }, - generic_params: Vec::new(), - }, hir::TraitBoundModifier::None); - typarams.push(bound); - } - - let mut bindings = vec![]; - for pb in obj.projection_bounds() { - bindings.push(TypeBinding { - name: cx.tcx.associated_item(pb.item_def_id()).ident.name.clean(cx), - ty: pb.skip_binder().ty.clean(cx) - }); - } + let mut bindings = vec![]; + for pb in obj.projection_bounds() { + bindings.push(TypeBinding { + name: cx.tcx.associated_item(pb.item_def_id()).ident.name.clean(cx), + ty: pb.skip_binder().ty.clean(cx) + }); + } - let path = external_path(cx, &cx.tcx.item_name(did).as_str(), Some(did), - false, bindings, principal.skip_binder().substs); - ResolvedPath { - path, - typarams: Some(typarams), - did, - is_generic: false, - } - } else { - Never + let path = external_path(cx, &cx.tcx.item_name(did).as_str(), Some(did), + false, bindings, principal.skip_binder().substs); + ResolvedPath { + path, + typarams: Some(typarams), + did, + is_generic: false, } } ty::Tuple(ref t) => Tuple(t.clean(cx)), @@ -2734,6 +2733,7 @@ ty::Closure(..) | ty::Generator(..) => Tuple(vec![]), // FIXME(pcwalton) + ty::UnnormalizedProjection(..) => panic!("UnnormalizedProjection"), ty::GeneratorWitness(..) => panic!("GeneratorWitness"), ty::Infer(..) => panic!("Infer"), ty::Error => panic!("Error"), @@ -2816,14 +2816,10 @@ pub fields_stripped: bool, } -impl Clean> for doctree::Struct { - fn clean(&self, cx: &DocContext) -> Vec { - let name = self.name.clean(cx); - let mut ret = get_auto_traits_with_node_id(cx, self.id, name.clone()); - ret.extend(get_blanket_impls_with_node_id(cx, self.id, name.clone())); - - ret.push(Item { - name: Some(name), +impl Clean for doctree::Struct { + fn clean(&self, cx: &DocContext) -> Item { + Item { + name: Some(self.name.clean(cx)), attrs: self.attrs.clean(cx), source: self.whence.clean(cx), def_id: cx.tcx.hir.local_def_id(self.id), @@ -2836,20 +2832,14 @@ fields: self.fields.clean(cx), fields_stripped: false, }), - }); - - ret + } } } -impl Clean> for doctree::Union { - fn clean(&self, cx: &DocContext) -> Vec { - let name = self.name.clean(cx); - let mut ret = get_auto_traits_with_node_id(cx, self.id, name.clone()); - ret.extend(get_blanket_impls_with_node_id(cx, self.id, name.clone())); - - ret.push(Item { - name: Some(name), +impl Clean for doctree::Union { + fn clean(&self, cx: &DocContext) -> Item { + Item { + name: Some(self.name.clean(cx)), attrs: self.attrs.clean(cx), source: self.whence.clean(cx), def_id: cx.tcx.hir.local_def_id(self.id), @@ -2862,9 +2852,7 @@ fields: self.fields.clean(cx), fields_stripped: false, }), - }); - - ret + } } } @@ -2895,14 +2883,10 @@ pub variants_stripped: bool, } -impl Clean> for doctree::Enum { - fn clean(&self, cx: &DocContext) -> Vec { - let name = self.name.clean(cx); - let mut ret = get_auto_traits_with_node_id(cx, self.id, name.clone()); - ret.extend(get_blanket_impls_with_node_id(cx, self.id, name.clone())); - - ret.push(Item { - name: Some(name), +impl Clean for doctree::Enum { + fn clean(&self, cx: &DocContext) -> Item { + Item { + name: Some(self.name.clean(cx)), attrs: self.attrs.clean(cx), source: self.whence.clean(cx), def_id: cx.tcx.hir.local_def_id(self.id), @@ -2914,9 +2898,7 @@ generics: self.generics.clean(cx), variants_stripped: false, }), - }); - - ret + } } } @@ -3405,7 +3387,7 @@ .into_iter() .map(|meth| meth.ident.to_string()) .collect() - }).unwrap_or(FxHashSet()); + }).unwrap_or_default(); ret.push(Item { name: None, @@ -3445,11 +3427,7 @@ let primitive = match *target { ResolvedPath { did, .. } if did.is_local() => continue, ResolvedPath { did, .. } => { - // We set the last parameter to false to avoid looking for auto-impls for traits - // and therefore avoid an ICE. - // The reason behind this is that auto-traits don't propagate through Deref so - // we're not supposed to synthesise impls for them. - ret.extend(inline::build_impls(cx, did, false)); + ret.extend(inline::build_impls(cx, did)); continue } _ => match target.primitive_type() { @@ -3513,17 +3491,20 @@ // forcefully don't inline if this is not public or if the // #[doc(no_inline)] attribute is present. // Don't inline doc(hidden) imports so they can be stripped at a later stage. - let denied = !self.vis.node.is_pub() || self.attrs.iter().any(|a| { + let mut denied = !self.vis.node.is_pub() || self.attrs.iter().any(|a| { a.name() == "doc" && match a.meta_item_list() { Some(l) => attr::list_contains_name(&l, "no_inline") || attr::list_contains_name(&l, "hidden"), None => false, } }); + // Also check whether imports were asked to be inlined, in case we're trying to re-export a + // crate in Rust 2018+ + let please_inline = self.attrs.lists("doc").has_word("inline"); let path = self.path.clean(cx); let inner = if self.glob { if !denied { - let mut visited = FxHashSet(); + let mut visited = FxHashSet::default(); if let Some(items) = inline::try_inline_glob(cx, path.def, &mut visited) { return items; } @@ -3532,8 +3513,18 @@ Import::Glob(resolve_use_source(cx, path)) } else { let name = self.name; + if !please_inline { + match path.def { + Def::Mod(did) => if !did.is_local() && did.index == CRATE_DEF_INDEX { + // if we're `pub use`ing an extern crate root, don't inline it unless we + // were specifically asked for it + denied = true; + } + _ => {} + } + } if !denied { - let mut visited = FxHashSet(); + let mut visited = FxHashSet::default(); if let Some(items) = inline::try_inline(cx, path.def, name, &mut visited) { return items; } @@ -3633,7 +3624,7 @@ fn to_src(&self, cx: &DocContext) -> String { debug!("converting span {:?} to snippet", self.clean(cx)); let sn = match cx.sess().source_map().span_to_snippet(*self) { - Ok(x) => x.to_string(), + Ok(x) => x, Err(_) => String::new() }; debug!("got snippet {}", sn); @@ -3654,7 +3645,7 @@ fields.iter().map(|&Spanned { node: ref fp, .. }| format!("{}: {}", fp.ident, name_from_pat(&*fp.pat))) .collect::>().join(", "), - if etc { ", ..." } else { "" } + if etc { ", .." } else { "" } ) } PatKind::Tuple(ref elts, _) => format!("({})", elts.iter().map(|p| name_from_pat(&**p)) @@ -3751,7 +3742,12 @@ Def::Static(i, _) => (i, TypeKind::Static), Def::Variant(i) => (cx.tcx.parent_def_id(i).expect("cannot get parent def id"), TypeKind::Enum), - Def::Macro(i, _) => (i, TypeKind::Macro), + Def::Macro(i, mac_kind) => match mac_kind { + MacroKind::Bang => (i, TypeKind::Macro), + MacroKind::Attr => (i, TypeKind::Attr), + MacroKind::Derive => (i, TypeKind::Derive), + MacroKind::ProcMacroStub => unreachable!(), + }, Def::SelfTy(Some(def_id), _) => (def_id, TypeKind::Trait), Def::SelfTy(_, Some(impl_def_id)) => { return impl_def_id @@ -3807,6 +3803,30 @@ } #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] +pub struct ProcMacro { + pub kind: MacroKind, + pub helpers: Vec, +} + +impl Clean for doctree::ProcMacro { + fn clean(&self, cx: &DocContext) -> Item { + Item { + name: Some(self.name.clean(cx)), + attrs: self.attrs.clean(cx), + source: self.whence.clean(cx), + visibility: Some(Public), + stability: self.stab.clean(cx), + deprecation: self.depr.clean(cx), + def_id: cx.tcx.hir.local_def_id(self.id), + inner: ProcMacroItem(ProcMacro { + kind: self.kind, + helpers: self.helpers.clean(cx), + }), + } + } +} + +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct Stability { pub level: stability::StabilityLevel, pub feature: String, @@ -3980,6 +4000,7 @@ pub fn get_path_for_type(tcx: TyCtxt, def_id: DefId, def_ctor: F) -> hir::Path where F: Fn(DefId) -> Def { + #[derive(Debug)] struct AbsolutePathBuffer { names: Vec, } @@ -3997,13 +4018,15 @@ let mut apb = AbsolutePathBuffer { names: vec![] }; - tcx.push_item_path(&mut apb, def_id); + tcx.push_item_path(&mut apb, def_id, false); hir::Path { span: DUMMY_SP, def: def_ctor(def_id), segments: hir::HirVec::from_vec(apb.names.iter().map(|s| hir::PathSegment { ident: ast::Ident::from_str(&s), + id: None, + def: None, args: None, infer_types: false, }).collect()) diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/clean/simplify.rs rustc-1.31.0+dfsg1+llvm/src/librustdoc/clean/simplify.rs --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/clean/simplify.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/clean/simplify.rs 2018-12-04 23:41:40.000000000 +0000 @@ -157,7 +157,7 @@ return true } let predicates = cx.tcx.super_predicates_of(child).predicates; - predicates.iter().filter_map(|pred| { + predicates.iter().filter_map(|(pred, _)| { if let ty::Predicate::Trait(ref pred) = *pred { if pred.skip_binder().trait_ref.self_ty().is_self() { Some(pred.def_id()) diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/core.rs rustc-1.31.0+dfsg1+llvm/src/librustdoc/core.rs --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/core.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/core.rs 2018-12-04 23:41:40.000000000 +0000 @@ -26,7 +26,7 @@ use rustc_metadata::cstore::CStore; use rustc_target::spec::TargetTriple; -use syntax::ast::{self, Ident}; +use syntax::ast::{self, Ident, NodeId}; use syntax::source_map; use syntax::edition::Edition; use syntax::feature_gate::UnstableFeatures; @@ -36,11 +36,13 @@ use syntax_pos::DUMMY_SP; use errors; use errors::emitter::{Emitter, EmitterWriter}; +use parking_lot::ReentrantMutex; -use std::cell::{RefCell, Cell}; +use std::cell::RefCell; use std::mem; use rustc_data_structures::sync::{self, Lrc}; use std::rc::Rc; +use std::sync::Arc; use std::path::PathBuf; use visit_ast::RustdocVisitor; @@ -60,16 +62,13 @@ /// The stack of module NodeIds up till this point pub crate_name: Option, pub cstore: Rc, - pub populated_all_crate_impls: Cell, // Note that external items for which `doc(hidden)` applies to are shown as // non-reachable while local items aren't. This is because we're reusing // the access levels from crateanalysis. - /// Later on moved into `clean::Crate` - pub access_levels: RefCell>, /// Later on moved into `html::render::CACHE_KEY` pub renderinfo: RefCell, /// Later on moved through `clean::Crate` into `html::render::CACHE_KEY` - pub external_traits: RefCell>, + pub external_traits: Arc>>>, /// Used while populating `external_traits` to ensure we don't process the same trait twice at /// the same time. pub active_extern_traits: RefCell>, @@ -164,6 +163,16 @@ def_id.clone() } + /// Like the function of the same name on the HIR map, but skips calling it on fake DefIds. + /// (This avoids a slice-index-out-of-bounds panic.) + pub fn as_local_node_id(&self, def_id: DefId) -> Option { + if self.all_fake_def_ids.borrow().contains(&def_id) { + None + } else { + self.tcx.hir.as_local_node_id(def_id) + } + } + pub fn get_real_ty(&self, def_id: DefId, def_ctor: &F, @@ -177,6 +186,8 @@ segments.push(hir::PathSegment::new( real_name.unwrap_or(last.ident), + None, + None, self.generics_to_path_params(generics.clone()), false, )); @@ -260,9 +271,11 @@ /// /// If the given `error_format` is `ErrorOutputType::Json` and no `SourceMap` is given, a new one /// will be created for the handler. -pub fn new_handler(error_format: ErrorOutputType, source_map: Option>) - -> errors::Handler -{ +pub fn new_handler(error_format: ErrorOutputType, + source_map: Option>, + treat_err_as_bug: bool, + ui_testing: bool, +) -> errors::Handler { // rustdoc doesn't override (or allow to override) anything from this that is relevant here, so // stick to the defaults let sessopts = Options::default(); @@ -273,7 +286,7 @@ source_map.map(|cm| cm as _), false, sessopts.debugging_opts.teach, - ).ui_testing(sessopts.debugging_opts.ui_testing) + ).ui_testing(ui_testing) ), ErrorOutputType::Json(pretty) => { let source_map = source_map.unwrap_or_else( @@ -283,7 +296,7 @@ None, source_map, pretty, - ).ui_testing(sessopts.debugging_opts.ui_testing) + ).ui_testing(ui_testing) ) }, ErrorOutputType::Short(color_config) => Box::new( @@ -299,7 +312,7 @@ emitter, errors::HandlerFlags { can_emit_warnings: true, - treat_err_as_bug: false, + treat_err_as_bug, report_delayed_bugs: false, external_macro_backtrace: false, ..Default::default() @@ -323,9 +336,10 @@ lint_cap: Option, describe_lints: bool, mut manual_passes: Vec, - mut default_passes: passes::DefaultPassOption) - -> (clean::Crate, RenderInfo, Vec) -{ + mut default_passes: passes::DefaultPassOption, + treat_err_as_bug: bool, + ui_testing: bool, +) -> (clean::Crate, RenderInfo, Vec) { // Parse, resolve, and typecheck the given crate. let cpath = match input { @@ -336,12 +350,14 @@ let intra_link_resolution_failure_name = lint::builtin::INTRA_DOC_LINK_RESOLUTION_FAILURE.name; let warnings_lint_name = lint::builtin::WARNINGS.name; let missing_docs = rustc_lint::builtin::MISSING_DOCS.name; + let missing_doc_example = rustc_lint::builtin::MISSING_DOC_CODE_EXAMPLES.name; // In addition to those specific lints, we also need to whitelist those given through // command line, otherwise they'll get ignored and we don't want that. let mut whitelisted_lints = vec![warnings_lint_name.to_owned(), intra_link_resolution_failure_name.to_owned(), - missing_docs.to_owned()]; + missing_docs.to_owned(), + missing_doc_example.to_owned()]; whitelisted_lints.extend(cmd_lints.iter().map(|(lint, _)| lint).cloned()); @@ -379,6 +395,8 @@ actually_rustdoc: true, debugging_opts: config::DebuggingOptions { force_unstable_if_unmarked, + treat_err_as_bug, + ui_testing, ..config::basic_debugging_options() }, error_format, @@ -388,7 +406,10 @@ }; driver::spawn_thread_pool(sessopts, move |sessopts| { let source_map = Lrc::new(source_map::SourceMap::new(sessopts.file_path_mapping())); - let diagnostic_handler = new_handler(error_format, Some(source_map.clone())); + let diagnostic_handler = new_handler(error_format, + Some(source_map.clone()), + treat_err_as_bug, + ui_testing); let mut sess = session::build_session_( sessopts, cpath, diagnostic_handler, source_map, @@ -457,7 +478,9 @@ trait_map: resolver.trait_map.clone(), maybe_unused_trait_imports: resolver.maybe_unused_trait_imports.clone(), maybe_unused_extern_crates: resolver.maybe_unused_extern_crates.clone(), - extern_prelude: resolver.extern_prelude.clone(), + extern_prelude: resolver.extern_prelude.iter().map(|(ident, entry)| { + (ident.name, entry.introduced_by_item) + }).collect(), }; let analysis = ty::CrateAnalysis { access_levels: Lrc::new(AccessLevels::default()), @@ -505,23 +528,24 @@ clean::path_to_def(&tcx, &["core", "marker", "Send"]) }; + let mut renderinfo = RenderInfo::default(); + renderinfo.access_levels = access_levels; + let ctxt = DocContext { tcx, resolver: &resolver, crate_name, cstore: cstore.clone(), - populated_all_crate_impls: Cell::new(false), - access_levels: RefCell::new(access_levels), external_traits: Default::default(), active_extern_traits: Default::default(), - renderinfo: Default::default(), + renderinfo: RefCell::new(renderinfo), ty_substs: Default::default(), lt_substs: Default::default(), impl_trait_bounds: Default::default(), send_trait: send_trait, - fake_def_ids: RefCell::new(FxHashMap()), - all_fake_def_ids: RefCell::new(FxHashSet()), - generated_synthetics: RefCell::new(FxHashSet()), + fake_def_ids: Default::default(), + all_fake_def_ids: Default::default(), + generated_synthetics: Default::default(), all_traits: tcx.all_traits(LOCAL_CRATE).to_vec(), }; debug!("crate: {:?}", tcx.hir.krate()); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/doctree.rs rustc-1.31.0+dfsg1+llvm/src/librustdoc/doctree.rs --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/doctree.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/doctree.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,6 +15,7 @@ use syntax::ast; use syntax::ast::{Name, NodeId}; use syntax::attr; +use syntax::ext::base::MacroKind; use syntax::ptr::P; use syntax::source_map::Spanned; use syntax_pos::{self, Span}; @@ -46,6 +47,7 @@ pub impls: Vec, pub foreigns: Vec, pub macros: Vec, + pub proc_macros: Vec, pub is_crate: bool, } @@ -75,6 +77,7 @@ impls : Vec::new(), foreigns : Vec::new(), macros : Vec::new(), + proc_macros: Vec::new(), is_crate : false, } } @@ -264,6 +267,17 @@ pub whence: Span, } +pub struct ProcMacro { + pub name: Name, + pub id: NodeId, + pub kind: MacroKind, + pub helpers: Vec, + pub attrs: hir::HirVec, + pub whence: Span, + pub stab: Option, + pub depr: Option, +} + pub fn struct_type_from_def(vdata: &hir::VariantData) -> StructType { match *vdata { hir::VariantData::Struct(..) => Plain, diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/fold.rs rustc-1.31.0+dfsg1+llvm/src/librustdoc/fold.rs --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/fold.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/fold.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::mem; - use clean::*; pub struct StripItem(pub Item); @@ -116,11 +114,14 @@ fn fold_crate(&mut self, mut c: Crate) -> Crate { c.module = c.module.take().and_then(|module| self.fold_item(module)); - let traits = mem::replace(&mut c.external_traits, Default::default()); - c.external_traits.extend(traits.into_iter().map(|(k, mut v)| { - v.items = v.items.into_iter().filter_map(|i| self.fold_item(i)).collect(); - (k, v) - })); + { + let guard = c.external_traits.lock(); + let traits = guard.replace(Default::default()); + guard.borrow_mut().extend(traits.into_iter().map(|(k, mut v)| { + v.items = v.items.into_iter().filter_map(|i| self.fold_item(i)).collect(); + (k, v) + })); + } c } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/html/format.rs rustc-1.31.0+dfsg1+llvm/src/librustdoc/html/format.rs --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/html/format.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/html/format.rs 2018-12-04 23:41:40.000000000 +0000 @@ -553,6 +553,9 @@ f.write_str(name) } clean::ResolvedPath{ did, ref typarams, ref path, is_generic } => { + if typarams.is_some() { + f.write_str("dyn ")?; + } // Paths like T::Output and Self::Output should be rendered with all segments resolved_path(f, did, path, is_generic, use_absolute)?; tybounds(f, typarams) diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/html/highlight.rs rustc-1.31.0+dfsg1+llvm/src/librustdoc/html/highlight.rs --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/html/highlight.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/html/highlight.rs 2018-12-04 23:41:40.000000000 +0000 @@ -44,9 +44,21 @@ } write_header(class, &mut out).unwrap(); - let mut classifier = Classifier::new(lexer::StringReader::new(&sess, fm, None), - sess.source_map()); + let lexer = match lexer::StringReader::new_without_err(&sess, fm, None, "Output from rustc:") { + Ok(l) => l, + Err(_) => { + let first_line = src.lines().next().unwrap_or_else(|| ""); + let mut err = sess.span_diagnostic + .struct_warn(&format!("Invalid doc comment starting with: `{}`\n\ + (Ignoring this codeblock)", + first_line)); + err.emit(); + return String::new(); + } + }; + let mut classifier = Classifier::new(lexer, sess.source_map()); if classifier.write_source(&mut out).is_err() { + classifier.lexer.emit_fatal_errors(); return format!("
{}
", src); } @@ -162,11 +174,10 @@ match self.lexer.try_next_token() { Ok(tas) => Ok(tas), Err(_) => { - self.lexer.emit_fatal_errors(); - self.lexer.sess.span_diagnostic - .struct_warn("Backing out of syntax highlighting") - .note("You probably did not intend to render this as a rust code-block") - .emit(); + let mut err = self.lexer.sess.span_diagnostic + .struct_warn("Backing out of syntax highlighting"); + err.note("You probably did not intend to render this as a rust code-block"); + err.emit(); Err(io::Error::new(io::ErrorKind::Other, "")) } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/html/item_type.rs rustc-1.31.0+dfsg1+llvm/src/librustdoc/html/item_type.rs --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/html/item_type.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/html/item_type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,6 +11,7 @@ //! Item types. use std::fmt; +use syntax::ext::base::MacroKind; use clean; /// Item type. Corresponds to `clean::ItemEnum` variants. @@ -19,6 +20,11 @@ /// discriminants. JavaScript then is used to decode them into the original value. /// Consequently, every change to this type should be synchronized to /// the `itemTypes` mapping table in `static/main.js`. +/// +/// In addition, code in `html::render` uses this enum to generate CSS classes, page prefixes, and +/// module headings. If you are adding to this enum and want to ensure that the sidebar also prints +/// a heading, edit the listing in `html/render.rs`, function `sidebar_module`. This uses an +/// ordering based on a helper function inside `item_module`, in the same file. #[derive(Copy, PartialEq, Clone, Debug)] pub enum ItemType { Module = 0, @@ -44,6 +50,8 @@ ForeignType = 20, Keyword = 21, Existential = 22, + ProcAttribute = 23, + ProcDerive = 24, } @@ -88,6 +96,12 @@ clean::AssociatedTypeItem(..) => ItemType::AssociatedType, clean::ForeignTypeItem => ItemType::ForeignType, clean::KeywordItem(..) => ItemType::Keyword, + clean::ProcMacroItem(ref mac) => match mac.kind { + MacroKind::Bang => ItemType::Macro, + MacroKind::Attr => ItemType::ProcAttribute, + MacroKind::Derive => ItemType::ProcDerive, + MacroKind::ProcMacroStub => unreachable!(), + } clean::StrippedItem(..) => unreachable!(), } } @@ -107,7 +121,9 @@ clean::TypeKind::Variant => ItemType::Variant, clean::TypeKind::Typedef => ItemType::Typedef, clean::TypeKind::Foreign => ItemType::ForeignType, - clean::TypeKind::Macro => ItemType::Macro, + clean::TypeKind::Macro => ItemType::Macro, + clean::TypeKind::Attr => ItemType::ProcAttribute, + clean::TypeKind::Derive => ItemType::ProcDerive, } } } @@ -138,6 +154,8 @@ ItemType::ForeignType => "foreigntype", ItemType::Keyword => "keyword", ItemType::Existential => "existential", + ItemType::ProcAttribute => "attr", + ItemType::ProcDerive => "derive", } } @@ -166,7 +184,9 @@ ItemType::Constant | ItemType::AssociatedConst => NameSpace::Value, - ItemType::Macro => NameSpace::Macro, + ItemType::Macro | + ItemType::ProcAttribute | + ItemType::ProcDerive => NameSpace::Macro, ItemType::Keyword => NameSpace::Keyword, } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/html/layout.rs rustc-1.31.0+dfsg1+llvm/src/librustdoc/html/layout.rs --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/html/layout.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/html/layout.rs 2018-12-04 23:41:40.000000000 +0000 @@ -83,6 +83,7 @@
", + version)?; } } write!(fmt, "
")?; + if it.is_crate() { + write!(fmt, "

See all {}'s items

", + it.name.as_ref().expect("crates always have a name"))?; + } match it.inner { clean::StructItem(ref s) => sidebar_struct(fmt, it, s)?, clean::TraitItem(ref t) => sidebar_trait(fmt, it, t)?, @@ -4493,6 +4541,8 @@ ItemType::ForeignType => ("foreign-types", "Foreign Types"), ItemType::Keyword => ("keywords", "Keywords"), ItemType::Existential => ("existentials", "Existentials"), + ItemType::ProcAttribute => ("attributes", "Attribute Macros"), + ItemType::ProcDerive => ("derives", "Derive Macros"), } } @@ -4568,6 +4618,39 @@ document(w, cx, it) } +fn item_proc_macro(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, m: &clean::ProcMacro) + -> fmt::Result +{ + let name = it.name.as_ref().expect("proc-macros always have names"); + match m.kind { + MacroKind::Bang => { + write!(w, "
")?;
+            write!(w, "{}!() {{ /* proc-macro */ }}", name)?;
+            write!(w, "
")?; + } + MacroKind::Attr => { + write!(w, "
")?;
+            write!(w, "#[{}]", name)?;
+            write!(w, "
")?; + } + MacroKind::Derive => { + write!(w, "
")?;
+            write!(w, "#[derive({})]", name)?;
+            if !m.helpers.is_empty() {
+                writeln!(w, "\n{{")?;
+                writeln!(w, "    // Attributes available to this derive:")?;
+                for attr in &m.helpers {
+                    writeln!(w, "    #[{}]", attr)?;
+                }
+                write!(w, "}}")?;
+            }
+            write!(w, "
")?; + } + _ => {} + } + document(w, cx, it) +} + fn item_primitive(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, _p: &clean::PrimitiveType) -> fmt::Result { @@ -4620,7 +4703,7 @@ /// picked up the impl fn collect_paths_for_type(first_ty: clean::Type) -> Vec { let mut out = Vec::new(); - let mut visited = FxHashSet(); + let mut visited = FxHashSet::default(); let mut work = VecDeque::new(); let cache = cache(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/html/static/main.js rustc-1.31.0+dfsg1+llvm/src/librustdoc/html/static/main.js --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/html/static/main.js 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/html/static/main.js 2018-12-04 23:41:40.000000000 +0000 @@ -39,7 +39,10 @@ "associatedconstant", "union", "foreigntype", - "keyword"]; + "keyword", + "existential", + "attr", + "derive"]; var search_input = document.getElementsByClassName('search-input')[0]; @@ -1991,8 +1994,11 @@ } }; if (getCurrentValue('rustdoc-trait-implementations') !== "false") { - onEach(document.getElementById('implementations-list') - .getElementsByClassName("collapse-toggle"), collapser); + var impl_list = document.getElementById('implementations-list'); + + if (impl_list !== null) { + onEach(impl_list.getElementsByClassName("collapse-toggle"), collapser); + } } if (getCurrentValue('rustdoc-method-docs') !== "false") { var implItems = document.getElementsByClassName('impl-items'); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/html/static/rustdoc.css rustc-1.31.0+dfsg1+llvm/src/librustdoc/html/static/rustdoc.css --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/html/static/rustdoc.css 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/html/static/rustdoc.css 2018-12-04 23:41:40.000000000 +0000 @@ -97,7 +97,6 @@ h1.fqn { border-bottom: 1px dashed; margin-top: 0; - overflow: auto; } h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.type):not(.tymethod):not(.associatedconstant) { border-bottom: 1px solid; @@ -139,7 +138,7 @@ } .docblock code, .docblock-short code { border-radius: 3px; - padding: 0 0.2em; + padding: 0 0.1em; } .docblock pre code, .docblock-short pre code, .docblock code.spotlight { padding: 0; @@ -909,10 +908,9 @@ padding-top: 0px; } - .sidebar { + body > .sidebar { height: 45px; min-height: 40px; - width: calc(100% + 30px); margin: 0; margin-left: -15px; padding: 0 15px; @@ -1014,6 +1012,10 @@ .anchor { display: none !important; } + + h1.fqn { + overflow: initial; + } } @media print { @@ -1084,17 +1086,14 @@ float: left; width: 33.3%; text-align: center; - border-bottom: 1px solid; font-size: 18px; cursor: pointer; + border-top: 2px solid; } -#titles > div.selected { - border-bottom: 3px solid; -} - -#titles > div:hover { - border-bottom: 3px solid; +#titles > div:not(:last-child):not(.selected) { + margin-right: 1px; + width: calc(33.3% - 1px); } #titles > div > div.count { @@ -1113,6 +1112,18 @@ top: 2px; } +#all-types { + text-align: center; + border: 1px solid; + margin: 0 10px; + margin-bottom: 10px; + display: block; + border-radius: 7px; +} +#all-types > p { + margin: 5px 0; +} + @media (max-width: 700px) { h4 > .important-traits { position: absolute; @@ -1136,6 +1147,9 @@ background-color: rgba(0,0,0,0); height: 100%; } + .sidebar { + width: calc(100% + 30px); + } .show-it { display: block; @@ -1181,6 +1195,10 @@ .impl > .collapse-toggle { left: -10px; } + + #all-types { + margin: 10px; + } } @@ -1384,17 +1402,6 @@ #main > ul > li { list-style: none; } -#all-types { - text-align: center; - border: 1px solid; - margin: 0 10px; - margin-bottom: 10px; - display: block; - border-radius: 7px; -} -#all-types > p { - margin: 5px 0; -} .non-exhaustive { margin-bottom: 1em; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/html/static/storage.js rustc-1.31.0+dfsg1+llvm/src/librustdoc/html/static/storage.js --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/html/static/storage.js 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/html/static/storage.js 2018-12-04 23:41:40.000000000 +0000 @@ -26,8 +26,26 @@ return false; } +function usableLocalStorage() { + // Check if the browser supports localStorage at all: + if (typeof(Storage) === "undefined") { + return false; + } + // Check if we can access it; this access will fail if the browser + // preferences deny access to localStorage, e.g., to prevent storage of + // "cookies" (or cookie-likes, as is the case here). + try { + window.localStorage; + } catch(err) { + // Storage is supported, but browser preferences deny access to it. + return false; + } + + return true; +} + function updateLocalStorage(name, value) { - if (typeof(Storage) !== "undefined") { + if (usableLocalStorage()) { localStorage[name] = value; } else { // No Web Storage support so we do nothing @@ -35,7 +53,7 @@ } function getCurrentValue(name) { - if (typeof(Storage) !== "undefined" && localStorage[name] !== undefined) { + if (usableLocalStorage() && localStorage[name] !== undefined) { return localStorage[name]; } return null; diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/html/static/themes/dark.css rustc-1.31.0+dfsg1+llvm/src/librustdoc/html/static/themes/dark.css --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/html/static/themes/dark.css 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/html/static/themes/dark.css 2018-12-04 23:41:40.000000000 +0000 @@ -124,6 +124,8 @@ .content .highlighted.tymethod { background-color: #4950ed; } .content .highlighted.type { background-color: #38902c; } .content .highlighted.foreigntype { background-color: #b200d6; } +.content .highlighted.attr, +.content .highlighted.derive, .content .highlighted.macro { background-color: #217d1c; } .content .highlighted.constant, .content .highlighted.static { background-color: #0063cc; } @@ -134,6 +136,8 @@ .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.attr, .content a.attr, .block a.current.attr, +.content span.derive, .content a.derive, .block a.current.derive, .content span.macro, .content a.macro, .block a.current.macro { color: #09bd00; } .content span.union, .content a.union, .block a.current.union { color: #a6ae37; } .content span.constant, .content a.constant, .block a.current.constant, @@ -296,16 +300,13 @@ border-color: black; } -#titles > div { - border-bottom-color: #ccc; +#titles > div:not(.selected) { + background-color: #252525; + border-top-color: #252525; } -#titles > div.selected { - border-bottom-color: #0078ee; -} - -#titles > div:hover { - border-bottom-color: #0089ff; +#titles > div:hover, #titles > div.selected { + border-top-color: #0089ff; } #titles > div > div.count { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/html/static/themes/light.css rustc-1.31.0+dfsg1+llvm/src/librustdoc/html/static/themes/light.css --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/html/static/themes/light.css 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/html/static/themes/light.css 2018-12-04 23:41:40.000000000 +0000 @@ -124,6 +124,8 @@ .content .highlighted.tymethod { background-color: #c6afb3; } .content .highlighted.type { background-color: #ffc891; } .content .highlighted.foreigntype { background-color: #f5c4ff; } +.content .highlighted.attr, +.content .highlighted.derive, .content .highlighted.macro { background-color: #8ce488; } .content .highlighted.constant, .content .highlighted.static { background-color: #c3e0ff; } @@ -134,6 +136,8 @@ .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.attr, .content a.attr, .block a.current.attr, +.content span.derive, .content a.derive, .block a.current.derive, .content span.macro, .content a.macro, .block a.current.macro { color: #068000; } .content span.union, .content a.union, .block a.current.union { color: #767b27; } .content span.constant, .content a.constant, .block a.current.constant, @@ -290,16 +294,13 @@ border-color: black; } -#titles > div { - border-bottom-color: #ccc; +#titles > div:not(.selected) { + background-color: #e6e6e6; + border-top-color: #e6e6e6; } -#titles > div.selected { - border-bottom-color: #0078ee; -} - -#titles > div:hover { - border-bottom-color: #0089ff; +#titles > div:hover, #titles > div.selected { + border-top-color: #0089ff; } #titles > div > div.count { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/lib.rs rustc-1.31.0+dfsg1+llvm/src/librustdoc/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,8 +16,7 @@ #![feature(rustc_private)] #![feature(box_patterns)] #![feature(box_syntax)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(set_stdio)] #![feature(slice_sort_by_cached_key)] #![feature(test)] @@ -25,6 +24,7 @@ #![feature(ptr_offset_from)] #![feature(crate_visibility_modifier)] #![feature(const_fn)] +#![feature(drain_filter)] #![recursion_limit="256"] @@ -49,6 +49,7 @@ extern crate pulldown_cmark; extern crate tempfile; extern crate minifier; +extern crate parking_lot; extern crate serialize as rustc_serialize; // used by deriving @@ -286,7 +287,7 @@ \"light-suffix.css\"", "PATH") }), - unstable("edition", |o| { + stable("edition", |o| { o.optopt("", "edition", "edition to use when compiling rust code (default: 2015)", "EDITION") @@ -405,8 +406,14 @@ `short` (instead was `{}`)", arg)); } }; + let treat_err_as_bug = matches.opt_strs("Z").iter().any(|x| { + *x == "treat-err-as-bug" + }); + let ui_testing = matches.opt_strs("Z").iter().any(|x| { + *x == "ui-testing" + }); - let diag = core::new_handler(error_format, None); + let diag = core::new_handler(error_format, None, treat_err_as_bug, ui_testing); // check for deprecated options check_deprecated_options(&matches, &diag); @@ -453,7 +460,7 @@ let externs = match parse_externs(&matches) { Ok(ex) => ex, Err(err) => { - diag.struct_err(&err.to_string()).emit(); + diag.struct_err(&err).emit(); return 1; } }; @@ -561,7 +568,7 @@ let res = acquire_input(PathBuf::from(input), externs, edition, cg, &matches, error_format, move |out| { let Output { krate, passes, renderinfo } = out; - let diag = core::new_handler(error_format, None); + let diag = core::new_handler(error_format, None, treat_err_as_bug, ui_testing); info!("going to format"); match output_format.as_ref().map(|s| &**s) { Some("html") | None => { @@ -695,6 +702,12 @@ let force_unstable_if_unmarked = matches.opt_strs("Z").iter().any(|x| { *x == "force-unstable-if-unmarked" }); + let treat_err_as_bug = matches.opt_strs("Z").iter().any(|x| { + *x == "treat-err-as-bug" + }); + let ui_testing = matches.opt_strs("Z").iter().any(|x| { + *x == "ui-testing" + }); let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format); @@ -707,7 +720,8 @@ core::run_core(paths, cfgs, externs, Input::File(cratefile), triple, maybe_sysroot, display_warnings, crate_name.clone(), force_unstable_if_unmarked, edition, cg, error_format, - lint_opts, lint_cap, describe_lints, manual_passes, default_passes); + lint_opts, lint_cap, describe_lints, manual_passes, default_passes, + treat_err_as_bug, ui_testing); info!("finished with rustc"); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/passes/collect_intra_doc_links.rs rustc-1.31.0+dfsg1+llvm/src/librustdoc/passes/collect_intra_doc_links.rs --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/passes/collect_intra_doc_links.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/passes/collect_intra_doc_links.rs 2018-12-04 23:41:40.000000000 +0000 @@ -24,7 +24,8 @@ use core::DocContext; use fold::DocFolder; -use html::markdown::markdown_links; +use html::markdown::{find_testable_code, markdown_links, ErrorCodes, LangString}; + use passes::Pass; pub const COLLECT_INTRA_DOC_LINKS: Pass = @@ -56,6 +57,7 @@ struct LinkCollector<'a, 'tcx: 'a, 'rcx: 'a, 'cstore: 'rcx> { cx: &'a DocContext<'a, 'tcx, 'rcx, 'cstore>, mod_ids: Vec, + is_nightly_build: bool, } impl<'a, 'tcx, 'rcx, 'cstore> LinkCollector<'a, 'tcx, 'rcx, 'cstore> { @@ -63,22 +65,28 @@ LinkCollector { cx, mod_ids: Vec::new(), + is_nightly_build: UnstableFeatures::from_environment().is_nightly_build(), } } /// Resolve a given string as a path, along with whether or not it is /// in the value namespace. Also returns an optional URL fragment in the case /// of variants and methods - fn resolve(&self, path_str: &str, is_val: bool, current_item: &Option) + fn resolve(&self, + path_str: &str, + is_val: bool, + current_item: &Option, + parent_id: Option) -> Result<(Def, Option), ()> { let cx = self.cx; // In case we're in a module, try to resolve the relative // path - if let Some(id) = self.mod_ids.last() { + if let Some(id) = parent_id.or(self.mod_ids.last().cloned()) { + // FIXME: `with_scope` requires the NodeId of a module let result = cx.resolver.borrow_mut() - .with_scope(*id, + .with_scope(id, |resolver| { resolver.resolve_str_path_error(DUMMY_SP, &path_str, is_val) @@ -129,8 +137,9 @@ } } + // FIXME: `with_scope` requires the NodeId of a module let ty = cx.resolver.borrow_mut() - .with_scope(*id, + .with_scope(id, |resolver| { resolver.resolve_str_path_error(DUMMY_SP, &path, false) })?; @@ -205,6 +214,43 @@ } } +fn look_for_tests<'a, 'tcx: 'a, 'rcx: 'a, 'cstore: 'rcx>( + cx: &'a DocContext<'a, 'tcx, 'rcx, 'cstore>, + dox: &str, + item: &Item, +) { + if (item.is_mod() && cx.tcx.hir.as_local_node_id(item.def_id).is_none()) || + cx.as_local_node_id(item.def_id).is_none() { + // If non-local, no need to check anything. + return; + } + + struct Tests { + found_tests: usize, + } + + impl ::test::Tester for Tests { + fn add_test(&mut self, _: String, _: LangString, _: usize) { + self.found_tests += 1; + } + } + + let mut tests = Tests { + found_tests: 0, + }; + + if find_testable_code(&dox, &mut tests, ErrorCodes::No).is_ok() { + if tests.found_tests == 0 { + let mut diag = cx.tcx.struct_span_lint_node( + lint::builtin::MISSING_DOC_CODE_EXAMPLES, + NodeId::new(0), + span_of_attrs(&item.attrs), + "Missing code example in this documentation"); + diag.emit(); + } + } +} + impl<'a, 'tcx, 'rcx, 'cstore> DocFolder for LinkCollector<'a, 'tcx, 'rcx, 'cstore> { fn fold_item(&mut self, mut item: Item) -> Option { let item_node_id = if item.is_mod() { @@ -218,6 +264,20 @@ None }; + // FIXME: get the resolver to work with non-local resolve scopes + let parent_node = self.cx.as_local_node_id(item.def_id).and_then(|node_id| { + // FIXME: this fails hard for impls in non-module scope, but is necessary for the + // current resolve() implementation + match self.cx.tcx.hir.get_module_parent_node(node_id) { + id if id != node_id => Some(id), + _ => None, + } + }); + + if parent_node.is_some() { + debug!("got parent node for {} {:?}, id {:?}", item.type_(), item.name, item.def_id); + } + let current_item = match item.inner { ModuleItem(..) => { if item.attrs.inner_docs { @@ -227,10 +287,10 @@ None } } else { - match self.mod_ids.last() { - Some(parent) if *parent != NodeId::new(0) => { + match parent_node.or(self.mod_ids.last().cloned()) { + Some(parent) if parent != NodeId::new(0) => { //FIXME: can we pull the parent module's name from elsewhere? - Some(self.cx.tcx.hir.name(*parent).to_string()) + Some(self.cx.tcx.hir.name(parent).to_string()) } _ => None, } @@ -253,6 +313,12 @@ let cx = self.cx; let dox = item.attrs.collapsed_doc_value().unwrap_or_else(String::new); + look_for_tests(&cx, &dox, &item); + + if !self.is_nightly_build { + return None; + } + for (ori_link, link_range) in markdown_links(&dox) { // bail early for real links if ori_link.contains('/') { @@ -294,7 +360,7 @@ match kind { PathKind::Value => { - if let Ok(def) = self.resolve(path_str, true, ¤t_item) { + if let Ok(def) = self.resolve(path_str, true, ¤t_item, parent_node) { def } else { resolution_failure(cx, &item.attrs, path_str, &dox, link_range); @@ -305,7 +371,7 @@ } } PathKind::Type => { - if let Ok(def) = self.resolve(path_str, false, ¤t_item) { + if let Ok(def) = self.resolve(path_str, false, ¤t_item, parent_node) { def } else { resolution_failure(cx, &item.attrs, path_str, &dox, link_range); @@ -316,16 +382,18 @@ PathKind::Unknown => { // try everything! if let Some(macro_def) = macro_resolve(cx, path_str) { - if let Ok(type_def) = self.resolve(path_str, false, ¤t_item) { + if let Ok(type_def) = + self.resolve(path_str, false, ¤t_item, parent_node) + { let (type_kind, article, type_disambig) = type_ns_kind(type_def.0, path_str); ambiguity_error(cx, &item.attrs, path_str, article, type_kind, &type_disambig, "a", "macro", &format!("macro@{}", path_str)); continue; - } else if let Ok(value_def) = self.resolve(path_str, - true, - ¤t_item) { + } else if let Ok(value_def) = + self.resolve(path_str, true, ¤t_item, parent_node) + { let (value_kind, value_disambig) = value_ns_kind(value_def.0, path_str) .expect("struct and mod cases should have been \ @@ -335,12 +403,16 @@ "a", "macro", &format!("macro@{}", path_str)); } (macro_def, None) - } else if let Ok(type_def) = self.resolve(path_str, false, ¤t_item) { + } else if let Ok(type_def) = + self.resolve(path_str, false, ¤t_item, parent_node) + { // It is imperative we search for not-a-value first // Otherwise we will find struct ctors for when we are looking // for structs, and the link won't work. // if there is something in both namespaces - if let Ok(value_def) = self.resolve(path_str, true, ¤t_item) { + if let Ok(value_def) = + self.resolve(path_str, true, ¤t_item, parent_node) + { let kind = value_ns_kind(value_def.0, path_str); if let Some((value_kind, value_disambig)) = kind { let (type_kind, article, type_disambig) @@ -352,7 +424,9 @@ } } type_def - } else if let Ok(value_def) = self.resolve(path_str, true, ¤t_item) { + } else if let Ok(value_def) = + self.resolve(path_str, true, ¤t_item, parent_node) + { value_def } else { resolution_failure(cx, &item.attrs, path_str, &dox, link_range); @@ -403,7 +477,7 @@ let mut resolver = cx.resolver.borrow_mut(); let parent_scope = resolver.dummy_parent_scope(); if let Ok(def) = resolver.resolve_macro_to_def_inner(&path, MacroKind::Bang, - &parent_scope, false) { + &parent_scope, false, false) { if let SyntaxExtension::DeclMacro { .. } = *resolver.get_macro(def) { return Some(def); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/passes/collect_trait_impls.rs rustc-1.31.0+dfsg1+llvm/src/librustdoc/passes/collect_trait_impls.rs --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/passes/collect_trait_impls.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/passes/collect_trait_impls.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,219 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use clean::*; + +use rustc::util::nodemap::FxHashSet; +use rustc::hir::def_id::DefId; + +use super::Pass; +use core::DocContext; +use fold::DocFolder; + +pub const COLLECT_TRAIT_IMPLS: Pass = + Pass::early("collect-trait-impls", collect_trait_impls, + "retrieves trait impls for items in the crate"); + +pub fn collect_trait_impls(krate: Crate, cx: &DocContext) -> Crate { + let mut synth = SyntheticImplCollector::new(cx); + let mut krate = synth.fold_crate(krate); + + let prims: FxHashSet = + krate.primitives.iter().map(|p| p.1).collect(); + + let crate_items = { + let mut coll = ItemCollector::new(); + krate = coll.fold_crate(krate); + coll.items + }; + + let mut new_items = Vec::new(); + + for &cnum in cx.tcx.crates().iter() { + for &did in cx.tcx.all_trait_implementations(cnum).iter() { + inline::build_impl(cx, did, &mut new_items); + } + } + + // Also try to inline primitive impls from other crates. + let lang_items = cx.tcx.lang_items(); + let primitive_impls = [ + lang_items.isize_impl(), + lang_items.i8_impl(), + lang_items.i16_impl(), + lang_items.i32_impl(), + lang_items.i64_impl(), + lang_items.i128_impl(), + lang_items.usize_impl(), + lang_items.u8_impl(), + lang_items.u16_impl(), + lang_items.u32_impl(), + lang_items.u64_impl(), + lang_items.u128_impl(), + lang_items.f32_impl(), + lang_items.f64_impl(), + lang_items.f32_runtime_impl(), + lang_items.f64_runtime_impl(), + lang_items.char_impl(), + lang_items.str_impl(), + lang_items.slice_impl(), + lang_items.slice_u8_impl(), + lang_items.str_alloc_impl(), + lang_items.slice_alloc_impl(), + lang_items.slice_u8_alloc_impl(), + lang_items.const_ptr_impl(), + lang_items.mut_ptr_impl(), + ]; + + for def_id in primitive_impls.iter().filter_map(|&def_id| def_id) { + if !def_id.is_local() { + inline::build_impl(cx, def_id, &mut new_items); + + let auto_impls = get_auto_traits_with_def_id(cx, def_id); + let blanket_impls = get_blanket_impls_with_def_id(cx, def_id); + let mut renderinfo = cx.renderinfo.borrow_mut(); + + let new_impls: Vec = auto_impls.into_iter() + .chain(blanket_impls.into_iter()) + .filter(|i| renderinfo.inlined.insert(i.def_id)) + .collect(); + + new_items.extend(new_impls); + } + } + + let mut cleaner = BadImplStripper { + prims, + items: crate_items, + }; + + // scan through included items ahead of time to splice in Deref targets to the "valid" sets + for it in &new_items { + if let ImplItem(Impl { ref for_, ref trait_, ref items, .. }) = it.inner { + if cleaner.keep_item(for_) && trait_.def_id() == cx.tcx.lang_items().deref_trait() { + let target = items.iter().filter_map(|item| { + match item.inner { + TypedefItem(ref t, true) => Some(&t.type_), + _ => None, + } + }).next().expect("Deref impl without Target type"); + + if let Some(prim) = target.primitive_type() { + cleaner.prims.insert(prim); + } else if let Some(did) = target.def_id() { + cleaner.items.insert(did); + } + } + } + } + + new_items.retain(|it| { + if let ImplItem(Impl { ref for_, ref trait_, ref blanket_impl, .. }) = it.inner { + cleaner.keep_item(for_) || + trait_.as_ref().map_or(false, |t| cleaner.keep_item(t)) || + blanket_impl.is_some() + } else { + true + } + }); + + // `tcx.crates()` doesn't include the local crate, and `tcx.all_trait_implementations` + // doesn't work with it anyway, so pull them from the HIR map instead + for &trait_did in cx.all_traits.iter() { + for &impl_node in cx.tcx.hir.trait_impls(trait_did) { + let impl_did = cx.tcx.hir.local_def_id(impl_node); + inline::build_impl(cx, impl_did, &mut new_items); + } + } + + if let Some(ref mut it) = krate.module { + if let ModuleItem(Module { ref mut items, .. }) = it.inner { + items.extend(synth.impls); + items.extend(new_items); + } else { + panic!("collect-trait-impls can't run"); + } + } else { + panic!("collect-trait-impls can't run"); + } + + krate +} + +struct SyntheticImplCollector<'a, 'tcx: 'a, 'rcx: 'a, 'cstore: 'rcx> { + cx: &'a DocContext<'a, 'tcx, 'rcx, 'cstore>, + impls: Vec, +} + +impl<'a, 'tcx, 'rcx, 'cstore> SyntheticImplCollector<'a, 'tcx, 'rcx, 'cstore> { + fn new(cx: &'a DocContext<'a, 'tcx, 'rcx, 'cstore>) -> Self { + SyntheticImplCollector { + cx, + impls: Vec::new(), + } + } +} + +impl<'a, 'tcx, 'rcx, 'cstore> DocFolder for SyntheticImplCollector<'a, 'tcx, 'rcx, 'cstore> { + fn fold_item(&mut self, i: Item) -> Option { + if i.is_struct() || i.is_enum() || i.is_union() { + if let (Some(node_id), Some(name)) = + (self.cx.tcx.hir.as_local_node_id(i.def_id), i.name.clone()) + { + self.impls.extend(get_auto_traits_with_node_id(self.cx, node_id, name.clone())); + self.impls.extend(get_blanket_impls_with_node_id(self.cx, node_id, name)); + } else { + self.impls.extend(get_auto_traits_with_def_id(self.cx, i.def_id)); + self.impls.extend(get_blanket_impls_with_def_id(self.cx, i.def_id)); + } + } + + self.fold_item_recur(i) + } +} + +#[derive(Default)] +struct ItemCollector { + items: FxHashSet, +} + +impl ItemCollector { + fn new() -> Self { + Self::default() + } +} + +impl DocFolder for ItemCollector { + fn fold_item(&mut self, i: Item) -> Option { + self.items.insert(i.def_id); + + self.fold_item_recur(i) + } +} + +struct BadImplStripper { + prims: FxHashSet, + items: FxHashSet, +} + +impl BadImplStripper { + fn keep_item(&self, ty: &Type) -> bool { + if let Generic(_) = ty { + // keep impls made on generics + true + } else if let Some(prim) = ty.primitive_type() { + self.prims.contains(&prim) + } else if let Some(did) = ty.def_id() { + self.items.contains(&did) + } else { + false + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/passes/mod.rs rustc-1.31.0+dfsg1+llvm/src/librustdoc/passes/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/passes/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/passes/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -43,6 +43,9 @@ mod collect_intra_doc_links; pub use self::collect_intra_doc_links::COLLECT_INTRA_DOC_LINKS; +mod collect_trait_impls; +pub use self::collect_trait_impls::COLLECT_TRAIT_IMPLS; + /// Represents a single pass. #[derive(Copy, Clone)] pub enum Pass { @@ -132,10 +135,12 @@ STRIP_PRIV_IMPORTS, PROPAGATE_DOC_CFG, COLLECT_INTRA_DOC_LINKS, + COLLECT_TRAIT_IMPLS, ]; /// The list of passes run by default. pub const DEFAULT_PASSES: &'static [&'static str] = &[ + "collect-trait-impls", "strip-hidden", "strip-private", "collect-intra-doc-links", @@ -146,6 +151,7 @@ /// The list of default passes run with `--document-private-items` is passed to rustdoc. pub const DEFAULT_PRIVATE_PASSES: &'static [&'static str] = &[ + "collect-trait-impls", "strip-priv-imports", "collect-intra-doc-links", "collapse-docs", @@ -189,6 +195,7 @@ // We need to recurse into stripped modules to strip things // like impl methods but when doing so we must not add any // items to the `retained` set. + debug!("Stripper: recursing into stripped {} {:?}", i.type_(), i.name); let old = mem::replace(&mut self.update_retained, false); let ret = self.fold_item_recur(i); self.update_retained = old; @@ -212,6 +219,7 @@ | clean::ForeignTypeItem => { if i.def_id.is_local() { if !self.access_levels.is_exported(i.def_id) { + debug!("Stripper: stripping {} {:?}", i.type_(), i.name); return None; } } @@ -225,6 +233,7 @@ clean::ModuleItem(..) => { if i.def_id.is_local() && i.visibility != Some(clean::Public) { + debug!("Stripper: stripping module {:?}", i.name); let old = mem::replace(&mut self.update_retained, false); let ret = StripItem(self.fold_item_recur(i).unwrap()).strip(); self.update_retained = old; @@ -240,6 +249,9 @@ // tymethods/macros have no control over privacy clean::MacroItem(..) | clean::TyMethodItem(..) => {} + // Proc-macros are always public + clean::ProcMacroItem(..) => {} + // Primitives are never stripped clean::PrimitiveItem(..) => {} @@ -296,11 +308,13 @@ } if let Some(did) = imp.for_.def_id() { if did.is_local() && !imp.for_.is_generic() && !self.retained.contains(&did) { + debug!("ImplStripper: impl item for stripped type; removing"); return None; } } if let Some(did) = imp.trait_.def_id() { if did.is_local() && !self.retained.contains(&did) { + debug!("ImplStripper: impl item for stripped trait; removing"); return None; } } @@ -308,6 +322,8 @@ for typaram in generics { if let Some(did) = typaram.def_id() { if did.is_local() && !self.retained.contains(&did) { + debug!("ImplStripper: stripped item in trait's generics; \ + removing impl"); return None; } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/passes/strip_hidden.rs rustc-1.31.0+dfsg1+llvm/src/librustdoc/passes/strip_hidden.rs --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/passes/strip_hidden.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/passes/strip_hidden.rs 2018-12-04 23:41:40.000000000 +0000 @@ -35,7 +35,9 @@ // strip all impls referencing stripped items let mut stripper = ImplStripper { retained: &retained }; - stripper.fold_crate(krate) + let krate = stripper.fold_crate(krate); + + krate } struct Stripper<'a> { @@ -46,7 +48,7 @@ impl<'a> fold::DocFolder for Stripper<'a> { fn fold_item(&mut self, i: Item) -> Option { if i.attrs.lists("doc").has_word("hidden") { - debug!("found one in strip_hidden; removing"); + debug!("strip_hidden: stripping {} {:?}", i.type_(), i.name); // use a dedicated hidden item for given item type if any match i.inner { clean::StructFieldItem(..) | clean::ModuleItem(..) => { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/passes/strip_private.rs rustc-1.31.0+dfsg1+llvm/src/librustdoc/passes/strip_private.rs --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/passes/strip_private.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/passes/strip_private.rs 2018-12-04 23:41:40.000000000 +0000 @@ -22,10 +22,10 @@ /// Strip private items from the point of view of a crate or externally from a /// crate, specified by the `xcrate` flag. -pub fn strip_private(mut krate: clean::Crate, _: &DocContext) -> clean::Crate { +pub fn strip_private(mut krate: clean::Crate, cx: &DocContext) -> clean::Crate { // This stripper collects all *retained* nodes. let mut retained = DefIdSet(); - let access_levels = krate.access_levels.clone(); + let access_levels = cx.renderinfo.borrow().access_levels.clone(); // strip all private items { diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/test.rs rustc-1.31.0+dfsg1+llvm/src/librustdoc/test.rs --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/test.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -208,7 +208,7 @@ // needs to be the result of SourceMap::span_to_unmapped_path let input = config::Input::Str { name: filename.to_owned(), - input: test.to_owned(), + input: test, }; let outputs = OutputTypes::new(&[(OutputType::Exe, None)]); @@ -350,7 +350,7 @@ let newpath = { let path = env::var_os(var).unwrap_or(OsString::new()); let mut path = env::split_paths(&path).collect::>(); - path.insert(0, libdir.clone()); + path.insert(0, libdir); env::join_paths(path).unwrap() }; cmd.env(var, &newpath); @@ -465,6 +465,14 @@ (before, after) } +pub trait Tester { + fn add_test(&mut self, test: String, config: LangString, line: usize); + fn get_line(&self) -> usize { + 0 + } + fn register_header(&mut self, _name: &str, _level: u32) {} +} + pub struct Collector { pub tests: Vec, @@ -533,7 +541,31 @@ format!("{} - {} (line {})", filename, self.names.join("::"), line) } - pub fn add_test(&mut self, test: String, config: LangString, line: usize) { + pub fn set_position(&mut self, position: Span) { + self.position = position; + } + + fn get_filename(&self) -> FileName { + if let Some(ref source_map) = self.source_map { + let filename = source_map.span_to_filename(self.position); + if let FileName::Real(ref filename) = filename { + if let Ok(cur_dir) = env::current_dir() { + if let Ok(path) = filename.strip_prefix(&cur_dir) { + return path.to_owned().into(); + } + } + } + filename + } else if let Some(ref filename) = self.filename { + filename.clone().into() + } else { + FileName::Custom("input".to_owned()) + } + } +} + +impl Tester for Collector { + fn add_test(&mut self, test: String, config: LangString, line: usize) { let filename = self.get_filename(); let name = self.generate_name(line, &filename); let cfgs = self.cfgs.clone(); @@ -544,7 +576,7 @@ let opts = self.opts.clone(); let maybe_sysroot = self.maybe_sysroot.clone(); let linker = self.linker.clone(); - let edition = self.edition; + let edition = config.edition.unwrap_or(self.edition); debug!("Creating test {}: {}", name, test); self.tests.push(testing::TestDescAndFn { desc: testing::TestDesc { @@ -587,7 +619,7 @@ }); } - pub fn get_line(&self) -> usize { + fn get_line(&self) -> usize { if let Some(ref source_map) = self.source_map { let line = self.position.lo().to_usize(); let line = source_map.lookup_char_pos(BytePos(line as u32)).line; @@ -597,29 +629,7 @@ } } - pub fn set_position(&mut self, position: Span) { - self.position = position; - } - - fn get_filename(&self) -> FileName { - if let Some(ref source_map) = self.source_map { - let filename = source_map.span_to_filename(self.position); - if let FileName::Real(ref filename) = filename { - if let Ok(cur_dir) = env::current_dir() { - if let Ok(path) = filename.strip_prefix(&cur_dir) { - return path.to_owned().into(); - } - } - } - filename - } else if let Some(ref filename) = self.filename { - filename.clone().into() - } else { - FileName::Custom("input".to_owned()) - } - } - - pub fn register_header(&mut self, name: &str, level: u32) { + fn register_header(&mut self, name: &str, level: u32) { if self.use_headers { // we use these headings as test names, so it's good if // they're valid identifiers. @@ -774,7 +784,7 @@ assert_eq!(2+2, 4); }".to_string(); let output = make_test(input, None, false, &opts); - assert_eq!(output, (expected.clone(), 2)); + assert_eq!(output, (expected, 2)); } #[test] @@ -972,7 +982,7 @@ assert_eq!(2+2, 4); }".to_string(); let output = make_test(input, None, false, &opts); - assert_eq!(output, (expected.clone(), 2)); + assert_eq!(output, (expected, 2)); } #[test] @@ -987,7 +997,7 @@ //Ceci n'est pas une `fn main` assert_eq!(2+2, 4);".to_string(); let output = make_test(input, None, true, &opts); - assert_eq!(output, (expected.clone(), 1)); + assert_eq!(output, (expected, 1)); } #[test] @@ -1002,6 +1012,6 @@ assert_eq!(2+2, 4); }".to_string(); let output = make_test(input, None, false, &opts); - assert_eq!(output, (expected.clone(), 1)); + assert_eq!(output, (expected, 1)); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/visit_ast.rs rustc-1.31.0+dfsg1+llvm/src/librustdoc/visit_ast.rs --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/visit_ast.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/visit_ast.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,6 +15,7 @@ use syntax::ast; use syntax::attr; +use syntax::ext::base::MacroKind; use syntax::source_map::Spanned; use syntax_pos::{self, Span}; @@ -54,7 +55,7 @@ cx: &'a core::DocContext<'a, 'tcx, 'rcx, 'cstore> ) -> RustdocVisitor<'a, 'tcx, 'rcx, 'cstore> { // If the root is re-exported, terminate all recursion. - let mut stack = FxHashSet(); + let mut stack = FxHashSet::default(); stack.insert(ast::CRATE_NODE_ID); RustdocVisitor { module: Module::new(None), @@ -63,7 +64,7 @@ view_item_stack: stack, inlining: false, inside_public_path: true, - exact_paths: Some(FxHashMap()), + exact_paths: Some(FxHashMap::default()), } } @@ -168,24 +169,75 @@ } } - pub fn visit_fn(&mut self, item: &hir::Item, + pub fn visit_fn(&mut self, om: &mut Module, item: &hir::Item, name: ast::Name, fd: &hir::FnDecl, header: hir::FnHeader, gen: &hir::Generics, - body: hir::BodyId) -> Function { + body: hir::BodyId) { debug!("Visiting fn"); - Function { - id: item.id, - vis: item.vis.clone(), - stab: self.stability(item.id), - depr: self.deprecation(item.id), - attrs: item.attrs.clone(), - decl: fd.clone(), - name, - whence: item.span, - generics: gen.clone(), - header, - body, + let macro_kind = item.attrs.iter().filter_map(|a| { + if a.check_name("proc_macro") { + Some(MacroKind::Bang) + } else if a.check_name("proc_macro_derive") { + Some(MacroKind::Derive) + } else if a.check_name("proc_macro_attribute") { + Some(MacroKind::Attr) + } else { + None + } + }).next(); + match macro_kind { + Some(kind) => { + let name = if kind == MacroKind::Derive { + item.attrs.lists("proc_macro_derive") + .filter_map(|mi| mi.name()) + .next() + .expect("proc-macro derives require a name") + } else { + name + }; + + let mut helpers = Vec::new(); + for mi in item.attrs.lists("proc_macro_derive") { + if !mi.check_name("attributes") { + continue; + } + + if let Some(list) = mi.meta_item_list() { + for inner_mi in list { + if let Some(name) = inner_mi.name() { + helpers.push(name); + } + } + } + } + + om.proc_macros.push(ProcMacro { + name, + id: item.id, + kind, + helpers, + attrs: item.attrs.clone(), + whence: item.span, + stab: self.stability(item.id), + depr: self.deprecation(item.id), + }); + } + None => { + om.fns.push(Function { + id: item.id, + vis: item.vis.clone(), + stab: self.stability(item.id), + depr: self.deprecation(item.id), + attrs: item.attrs.clone(), + decl: fd.clone(), + name, + whence: item.span, + generics: gen.clone(), + header, + body, + }); + } } } @@ -269,7 +321,10 @@ Def::Enum(did) | Def::ForeignTy(did) | Def::TyAlias(did) if !self_is_hidden => { - self.cx.access_levels.borrow_mut().map.insert(did, AccessLevel::Public); + self.cx.renderinfo + .borrow_mut() + .access_levels.map + .insert(did, AccessLevel::Public); }, Def::Mod(did) => if !self_is_hidden { ::visit_lib::LibEmbargoVisitor::new(self.cx).visit_mod(did); @@ -284,7 +339,7 @@ Some(n) => n, None => return false }; - let is_private = !self.cx.access_levels.borrow().is_public(def_did); + let is_private = !self.cx.renderinfo.borrow().access_levels.is_public(def_did); let is_hidden = inherits_doc_hidden(self.cx, def_node_id); // Only inline if requested or if the item would otherwise be stripped @@ -422,7 +477,7 @@ hir::ItemKind::Union(ref sd, ref gen) => om.unions.push(self.visit_union_data(item, name, sd, gen)), hir::ItemKind::Fn(ref fd, header, ref gen, body) => - om.fns.push(self.visit_fn(item, name, &**fd, header, gen, body)), + self.visit_fn(om, item, name, &**fd, header, gen, body), hir::ItemKind::Ty(ref ty, ref gen) => { let t = Typedef { ty: ty.clone(), @@ -510,9 +565,9 @@ ref tr, ref ty, ref item_ids) => { - // Don't duplicate impls when inlining, we'll pick them up - // regardless of where they're located. - if !self.inlining { + // Don't duplicate impls when inlining or if it's implementing a trait, we'll pick + // them up regardless of where they're located. + if !self.inlining && tr.is_none() { let items = item_ids.iter() .map(|ii| self.cx.tcx.hir.impl_item(ii.id).clone()) .collect(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/visit_lib.rs rustc-1.31.0+dfsg1+llvm/src/librustdoc/visit_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/visit_lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/visit_lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -38,9 +38,9 @@ ) -> LibEmbargoVisitor<'a, 'tcx, 'rcx, 'cstore> { LibEmbargoVisitor { cx, - access_levels: cx.access_levels.borrow_mut(), + access_levels: RefMut::map(cx.renderinfo.borrow_mut(), |ri| &mut ri.access_levels), prev_level: Some(AccessLevel::Public), - visited_mods: FxHashSet() + visited_mods: FxHashSet::default() } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libserialize/lib.rs rustc-1.31.0+dfsg1+llvm/src/libserialize/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/libserialize/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libserialize/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -24,8 +24,7 @@ #![feature(core_intrinsics)] #![feature(specialization)] #![feature(never_type)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![cfg_attr(test, feature(test))] pub use self::serialize::{Decoder, Encoder, Decodable, Encodable}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/libserialize/serialize.rs rustc-1.31.0+dfsg1+llvm/src/libserialize/serialize.rs --- rustc-1.30.0+dfsg1+llvm/src/libserialize/serialize.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libserialize/serialize.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,6 +16,7 @@ use std::borrow::Cow; use std::intrinsics; +use std::marker::PhantomData; use std::path; use std::rc::Rc; use std::cell::{Cell, RefCell}; @@ -547,6 +548,19 @@ } } +impl Encodable for PhantomData { + fn encode(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_unit() + } +} + +impl Decodable for PhantomData { + fn decode(d: &mut D) -> Result, D::Error> { + d.read_nil()?; + Ok(PhantomData) + } +} + impl<'a, T: ?Sized + Encodable> Encodable for &'a T { fn encode(&self, s: &mut S) -> Result<(), S::Error> { (**self).encode(s) diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/alloc.rs rustc-1.31.0+dfsg1+llvm/src/libstd/alloc.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/alloc.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/alloc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -151,14 +151,12 @@ // ABI #[rustc_std_internal_symbol] - #[cfg_attr(stage0, no_mangle)] pub unsafe extern fn __rdl_alloc(size: usize, align: usize) -> *mut u8 { let layout = Layout::from_size_align_unchecked(size, align); System.alloc(layout) } #[rustc_std_internal_symbol] - #[cfg_attr(stage0, no_mangle)] pub unsafe extern fn __rdl_dealloc(ptr: *mut u8, size: usize, align: usize) { @@ -166,7 +164,6 @@ } #[rustc_std_internal_symbol] - #[cfg_attr(stage0, no_mangle)] pub unsafe extern fn __rdl_realloc(ptr: *mut u8, old_size: usize, align: usize, @@ -176,7 +173,6 @@ } #[rustc_std_internal_symbol] - #[cfg_attr(stage0, no_mangle)] pub unsafe extern fn __rdl_alloc_zeroed(size: usize, align: usize) -> *mut u8 { let layout = Layout::from_size_align_unchecked(size, align); System.alloc_zeroed(layout) diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/build.rs rustc-1.31.0+dfsg1+llvm/src/libstd/build.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/build.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/build.rs 2018-12-04 23:41:40.000000000 +0000 @@ -97,8 +97,8 @@ .file("../libbacktrace/sort.c") .file("../libbacktrace/state.c"); - let any_debug = env::var("RUSTC_DEBUGINFO").unwrap_or(String::new()) == "true" || - env::var("RUSTC_DEBUGINFO_LINES").unwrap_or(String::new()) == "true"; + let any_debug = env::var("RUSTC_DEBUGINFO").unwrap_or_default() == "true" || + env::var("RUSTC_DEBUGINFO_LINES").unwrap_or_default() == "true"; build.debug(any_debug); if target.contains("darwin") { diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/libstd/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/libstd/Cargo.toml 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/Cargo.toml 2018-12-04 23:41:40.000000000 +0000 @@ -48,4 +48,13 @@ force_alloc_system = [] panic-unwind = ["panic_unwind"] profiler = ["profiler_builtins"] + +# An off-by-default feature which enables a linux-syscall-like ABI for libstd to +# interoperate with the host environment. Currently not well documented and +# requires rebuilding the standard library to use it. wasm_syscall = [] + +# An off-by-default features to enable libstd to assume that wasm-bindgen is in +# the environment for hooking up some thread-related information like the +# current thread id and accessing/getting the current thread's TCB +wasm-bindgen-threads = [] diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/error.rs rustc-1.31.0+dfsg1+llvm/src/libstd/error.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/error.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/error.rs 2018-12-04 23:41:40.000000000 +0000 @@ -217,6 +217,35 @@ #[stable(feature = "rust1", since = "1.0.0")] impl<'a, E: Error + 'a> From for Box { + /// Converts a type of [`Error`] into a box of dyn [`Error`]. + /// + /// # Examples + /// + /// ``` + /// use std::error::Error; + /// use std::fmt; + /// use std::mem; + /// + /// #[derive(Debug)] + /// struct AnError; + /// + /// impl fmt::Display for AnError { + /// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + /// write!(f , "An error") + /// } + /// } + /// + /// impl Error for AnError { + /// fn description(&self) -> &str { + /// "Description of an error" + /// } + /// } + /// + /// let an_error = AnError; + /// assert!(0 == mem::size_of_val(&an_error)); + /// let a_boxed_error = Box::::from(an_error); + /// assert!(mem::size_of::>() == mem::size_of_val(&a_boxed_error)) + /// ``` fn from(err: E) -> Box { Box::new(err) } @@ -224,6 +253,41 @@ #[stable(feature = "rust1", since = "1.0.0")] impl<'a, E: Error + Send + Sync + 'a> From for Box { + /// Converts a type of [`Error`] + [`Send`] + [`Sync`] into a box of dyn [`Error`] + + /// [`Send`] + [`Sync`]. + /// + /// # Examples + /// + /// ``` + /// use std::error::Error; + /// use std::fmt; + /// use std::mem; + /// + /// #[derive(Debug)] + /// struct AnError; + /// + /// impl fmt::Display for AnError { + /// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + /// write!(f , "An error") + /// } + /// } + /// + /// impl Error for AnError { + /// fn description(&self) -> &str { + /// "Description of an error" + /// } + /// } + /// + /// unsafe impl Send for AnError {} + /// + /// unsafe impl Sync for AnError {} + /// + /// let an_error = AnError; + /// assert!(0 == mem::size_of_val(&an_error)); + /// let a_boxed_error = Box::::from(an_error); + /// assert!( + /// mem::size_of::>() == mem::size_of_val(&a_boxed_error)) + /// ``` fn from(err: E) -> Box { Box::new(err) } @@ -231,6 +295,19 @@ #[stable(feature = "rust1", since = "1.0.0")] impl From for Box { + /// Converts a [`String`] into a box of dyn [`Error`] + [`Send`] + [`Sync`]. + /// + /// # Examples + /// + /// ``` + /// use std::error::Error; + /// use std::mem; + /// + /// let a_string_error = "a string error".to_string(); + /// let a_boxed_error = Box::::from(a_string_error); + /// assert!( + /// mem::size_of::>() == mem::size_of_val(&a_boxed_error)) + /// ``` fn from(err: String) -> Box { #[derive(Debug)] struct StringError(String); @@ -251,6 +328,18 @@ #[stable(feature = "string_box_error", since = "1.6.0")] impl From for Box { + /// Converts a [`String`] into a box of dyn [`Error`]. + /// + /// # Examples + /// + /// ``` + /// use std::error::Error; + /// use std::mem; + /// + /// let a_string_error = "a string error".to_string(); + /// let a_boxed_error = Box::::from(a_string_error); + /// assert!(mem::size_of::>() == mem::size_of_val(&a_boxed_error)) + /// ``` fn from(str_err: String) -> Box { let err1: Box = From::from(str_err); let err2: Box = err1; @@ -260,6 +349,19 @@ #[stable(feature = "rust1", since = "1.0.0")] impl<'a, 'b> From<&'b str> for Box { + /// Converts a [`str`] into a box of dyn [`Error`] + [`Send`] + [`Sync`]. + /// + /// # Examples + /// + /// ``` + /// use std::error::Error; + /// use std::mem; + /// + /// let a_str_error = "a str error"; + /// let a_boxed_error = Box::::from(a_str_error); + /// assert!( + /// mem::size_of::>() == mem::size_of_val(&a_boxed_error)) + /// ``` fn from(err: &'b str) -> Box { From::from(String::from(err)) } @@ -267,6 +369,18 @@ #[stable(feature = "string_box_error", since = "1.6.0")] impl<'a> From<&'a str> for Box { + /// Converts a [`str`] into a box of dyn [`Error`]. + /// + /// # Examples + /// + /// ``` + /// use std::error::Error; + /// use std::mem; + /// + /// let a_str_error = "a str error"; + /// let a_boxed_error = Box::::from(a_str_error); + /// assert!(mem::size_of::>() == mem::size_of_val(&a_boxed_error)) + /// ``` fn from(err: &'a str) -> Box { From::from(String::from(err)) } @@ -274,6 +388,20 @@ #[stable(feature = "cow_box_error", since = "1.22.0")] impl<'a, 'b> From> for Box { + /// Converts a [`Cow`] into a box of dyn [`Error`] + [`Send`] + [`Sync`]. + /// + /// # Examples + /// + /// ``` + /// use std::error::Error; + /// use std::mem; + /// use std::borrow::Cow; + /// + /// let a_cow_str_error = Cow::from("a str error"); + /// let a_boxed_error = Box::::from(a_cow_str_error); + /// assert!( + /// mem::size_of::>() == mem::size_of_val(&a_boxed_error)) + /// ``` fn from(err: Cow<'b, str>) -> Box { From::from(String::from(err)) } @@ -281,6 +409,19 @@ #[stable(feature = "cow_box_error", since = "1.22.0")] impl<'a> From> for Box { + /// Converts a [`Cow`] into a box of dyn [`Error`]. + /// + /// # Examples + /// + /// ``` + /// use std::error::Error; + /// use std::mem; + /// use std::borrow::Cow; + /// + /// let a_cow_str_error = Cow::from("a str error"); + /// let a_boxed_error = Box::::from(a_cow_str_error); + /// assert!(mem::size_of::>() == mem::size_of_val(&a_boxed_error)) + /// ``` fn from(err: Cow<'a, str>) -> Box { From::from(String::from(err)) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/f32.rs rustc-1.31.0+dfsg1+llvm/src/libstd/f32.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/f32.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/f32.rs 2018-12-04 23:41:40.000000000 +0000 @@ -198,6 +198,35 @@ } } + /// Returns a number composed of the magnitude of `self` and the sign of + /// `y`. + /// + /// Equal to `self` if the sign of `self` and `y` are the same, otherwise + /// equal to `-self`. If `self` is a `NAN`, then a `NAN` with the sign of + /// `y` is returned. + /// + /// # Examples + /// + /// ``` + /// #![feature(copysign)] + /// use std::f32; + /// + /// let f = 3.5_f32; + /// + /// assert_eq!(f.copysign(0.42), 3.5_f32); + /// assert_eq!(f.copysign(-0.42), -3.5_f32); + /// assert_eq!((-f).copysign(0.42), 3.5_f32); + /// assert_eq!((-f).copysign(-0.42), -3.5_f32); + /// + /// assert!(f32::NAN.copysign(1.0).is_nan()); + /// ``` + #[inline] + #[must_use] + #[unstable(feature="copysign", issue="55169")] + pub fn copysign(self, y: f32) -> f32 { + unsafe { intrinsics::copysignf32(self, y) } + } + /// Fused multiply-add. Computes `(self * a) + b` with only one rounding /// error, yielding a more accurate result than an unfused multiply-add. /// diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/f64.rs rustc-1.31.0+dfsg1+llvm/src/libstd/f64.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/f64.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/f64.rs 2018-12-04 23:41:40.000000000 +0000 @@ -176,6 +176,35 @@ } } + /// Returns a number composed of the magnitude of `self` and the sign of + /// `y`. + /// + /// Equal to `self` if the sign of `self` and `y` are the same, otherwise + /// equal to `-self`. If `self` is a `NAN`, then a `NAN` with the sign of + /// `y` is returned. + /// + /// # Examples + /// + /// ``` + /// #![feature(copysign)] + /// use std::f64; + /// + /// let f = 3.5_f64; + /// + /// assert_eq!(f.copysign(0.42), 3.5_f64); + /// assert_eq!(f.copysign(-0.42), -3.5_f64); + /// assert_eq!((-f).copysign(0.42), 3.5_f64); + /// assert_eq!((-f).copysign(-0.42), -3.5_f64); + /// + /// assert!(f64::NAN.copysign(1.0).is_nan()); + /// ``` + #[inline] + #[must_use] + #[unstable(feature="copysign", issue="55169")] + pub fn copysign(self, y: f64) -> f64 { + unsafe { intrinsics::copysignf64(self, y) } + } + /// Fused multiply-add. Computes `(self * a) + b` with only one rounding /// error, yielding a more accurate result than an unfused multiply-add. /// diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/ffi/c_str.rs rustc-1.31.0+dfsg1+llvm/src/libstd/ffi/c_str.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/ffi/c_str.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/ffi/c_str.rs 2018-12-04 23:41:40.000000000 +0000 @@ -1040,7 +1040,8 @@ /// ``` #[inline] #[stable(feature = "cstr_from_bytes", since = "1.10.0")] - pub unsafe fn from_bytes_with_nul_unchecked(bytes: &[u8]) -> &CStr { + #[rustc_const_unstable(feature = "const_cstr_unchecked")] + pub const unsafe fn from_bytes_with_nul_unchecked(bytes: &[u8]) -> &CStr { &*(bytes as *const [u8] as *const CStr) } @@ -1471,4 +1472,13 @@ assert_eq!(&*rc2, cstr); assert_eq!(&*arc2, cstr); } + + #[test] + fn cstr_const_constructor() { + const CSTR: &'static CStr = unsafe { + CStr::from_bytes_with_nul_unchecked(b"Hello, world!\0") + }; + + assert_eq!(CSTR.to_str().unwrap(), "Hello, world!"); + } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/ffi/os_str.rs rustc-1.31.0+dfsg1+llvm/src/libstd/ffi/os_str.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/ffi/os_str.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/ffi/os_str.rs 2018-12-04 23:41:40.000000000 +0000 @@ -34,7 +34,9 @@ /// /// `OsString` and [`OsStr`] bridge this gap by simultaneously representing Rust /// and platform-native string values, and in particular allowing a Rust string -/// to be converted into an "OS" string with no cost if possible. +/// to be converted into an "OS" string with no cost if possible. A consequence +/// of this is that `OsString` instances are *not* `NUL` terminated; in order +/// to pass to e.g. Unix system call, you should create a [`CStr`]. /// /// `OsString` is to [`&OsStr`] as [`String`] is to [`&str`]: the former /// in each pair are owned strings; the latter are borrowed @@ -65,6 +67,7 @@ /// /// [`OsStr`]: struct.OsStr.html /// [`&OsStr`]: struct.OsStr.html +/// [`CStr`]: struct.CStr.html /// [`From`]: ../convert/trait.From.html /// [`String`]: ../string/struct.String.html /// [`&str`]: ../primitive.str.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/fs.rs rustc-1.31.0+dfsg1+llvm/src/libstd/fs.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/fs.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/fs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -726,7 +726,7 @@ /// If a file is opened with both read and append access, beware that after /// opening, and after every write, the position for reading may be set at the /// end of the file. So, before writing, save the current position (using - /// [`seek`]`(`[`SeekFrom`]`::`[`Current`]`(0))`, and restore it before the next read. + /// [`seek`]`(`[`SeekFrom`]`::`[`Current`]`(0))`), and restore it before the next read. /// /// ## Note /// diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/future.rs rustc-1.31.0+dfsg1+llvm/src/libstd/future.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/future.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/future.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,10 +12,10 @@ use core::cell::Cell; use core::marker::Unpin; -use core::pin::PinMut; +use core::pin::Pin; use core::option::Option; use core::ptr::NonNull; -use core::task::{self, Poll}; +use core::task::{LocalWaker, Poll}; use core::ops::{Drop, Generator, GeneratorState}; #[doc(inline)] @@ -42,8 +42,8 @@ #[unstable(feature = "gen_future", issue = "50547")] impl> Future for GenFuture { type Output = T::Return; - fn poll(self: PinMut, cx: &mut task::Context) -> Poll { - set_task_cx(cx, || match unsafe { PinMut::get_mut_unchecked(self).0.resume() } { + fn poll(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll { + set_task_waker(lw, || match unsafe { Pin::get_mut_unchecked(self).0.resume() } { GeneratorState::Yielded(()) => Poll::Pending, GeneratorState::Complete(x) => Poll::Ready(x), }) @@ -51,66 +51,61 @@ } thread_local! { - static TLS_CX: Cell>>> = Cell::new(None); + static TLS_WAKER: Cell>> = Cell::new(None); } -struct SetOnDrop(Option>>); +struct SetOnDrop(Option>); impl Drop for SetOnDrop { fn drop(&mut self) { - TLS_CX.with(|tls_cx| { - tls_cx.set(self.0.take()); + TLS_WAKER.with(|tls_waker| { + tls_waker.set(self.0.take()); }); } } #[unstable(feature = "gen_future", issue = "50547")] /// Sets the thread-local task context used by async/await futures. -pub fn set_task_cx(cx: &mut task::Context, f: F) -> R +pub fn set_task_waker(lw: &LocalWaker, f: F) -> R where F: FnOnce() -> R { - let old_cx = TLS_CX.with(|tls_cx| { - tls_cx.replace(NonNull::new( - cx - as *mut task::Context - as *mut () - as *mut task::Context<'static> - )) + let old_waker = TLS_WAKER.with(|tls_waker| { + tls_waker.replace(Some(NonNull::from(lw))) }); - let _reset_cx = SetOnDrop(old_cx); + let _reset_waker = SetOnDrop(old_waker); f() } #[unstable(feature = "gen_future", issue = "50547")] -/// Retrieves the thread-local task context used by async/await futures. +/// Retrieves the thread-local task waker used by async/await futures. /// -/// This function acquires exclusive access to the task context. +/// This function acquires exclusive access to the task waker. /// -/// Panics if no task has been set or if the task context has already been -/// retrieved by a surrounding call to get_task_cx. -pub fn get_task_cx(f: F) -> R +/// Panics if no waker has been set or if the waker has already been +/// retrieved by a surrounding call to get_task_waker. +pub fn get_task_waker(f: F) -> R where - F: FnOnce(&mut task::Context) -> R + F: FnOnce(&LocalWaker) -> R { - let cx_ptr = TLS_CX.with(|tls_cx| { - // Clear the entry so that nested `with_get_cx` calls + let waker_ptr = TLS_WAKER.with(|tls_waker| { + // Clear the entry so that nested `get_task_waker` calls // will fail or set their own value. - tls_cx.replace(None) + tls_waker.replace(None) }); - let _reset_cx = SetOnDrop(cx_ptr); + let _reset_waker = SetOnDrop(waker_ptr); - let mut cx_ptr = cx_ptr.expect( - "TLS task::Context not set. This is a rustc bug. \ + let mut waker_ptr = waker_ptr.expect( + "TLS LocalWaker not set. This is a rustc bug. \ Please file an issue on https://github.com/rust-lang/rust."); - unsafe { f(cx_ptr.as_mut()) } + unsafe { f(waker_ptr.as_mut()) } } #[unstable(feature = "gen_future", issue = "50547")] -/// Polls a future in the current thread-local task context. -pub fn poll_in_task_cx(f: PinMut) -> Poll +/// Polls a future in the current thread-local task waker. +pub fn poll_with_tls_waker(f: Pin<&mut F>) -> Poll where F: Future { - get_task_cx(|cx| f.poll(cx)) + get_task_waker(|lw| F::poll(f, lw)) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/io/error.rs rustc-1.31.0+dfsg1+llvm/src/libstd/io/error.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/io/error.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/io/error.rs 2018-12-04 23:41:40.000000000 +0000 @@ -212,6 +212,19 @@ /// the heap (for normal construction via Error::new) is too costly. #[stable(feature = "io_error_from_errorkind", since = "1.14.0")] impl From for Error { + /// Converts an [`ErrorKind`] into an [`Error`]. + /// + /// This conversion allocates a new error with a simple representation of error kind. + /// + /// # Examples + /// + /// ``` + /// use std::io::{Error, ErrorKind}; + /// + /// let not_found = ErrorKind::NotFound; + /// let error = Error::from(not_found); + /// assert_eq!("entity not found", format!("{}", error)); + /// ``` #[inline] fn from(kind: ErrorKind) -> Error { Error { diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/io/mod.rs rustc-1.31.0+dfsg1+llvm/src/libstd/io/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/io/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/io/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -1204,8 +1204,8 @@ pub trait Seek { /// Seek to an offset, in bytes, in a stream. /// - /// A seek beyond the end of a stream is allowed, but implementation - /// defined. + /// A seek beyond the end of a stream is allowed, but behavior is defined + /// by the implementation. /// /// If the seek operation completed successfully, /// this method returns the new position from the start of the stream. diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/keyword_docs.rs rustc-1.31.0+dfsg1+llvm/src/libstd/keyword_docs.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/keyword_docs.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/keyword_docs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,72 +8,713 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[doc(keyword = "fn")] +#[doc(keyword = "as")] +// +/// The keyword for casting a value to a type. +/// +/// `as` is most commonly used to turn primitive types into other primitive types, but it has other +/// uses that include turning pointers into addresses, addresses into pointers, and pointers into +/// other pointers. +/// +/// ```rust +/// let thing1: u8 = 89.0 as u8; +/// assert_eq!('B' as u32, 66); +/// assert_eq!(thing1 as char, 'Y'); +/// let thing2: f32 = thing1 as f32 + 10.5; +/// assert_eq!(true as u8 + thing2 as u8, 100); +/// ``` +/// +/// In general, any cast that can be performed via ascribing the type can also be done using `as`, +/// so instead of writing `let x: u32 = 123`, you can write `let x = 123 as u32` (Note: `let x: u32 +/// = 123` would be best in that situation). The same is not true in the other direction, however, +/// explicitly using `as` allows a few more coercions that aren't allowed implicitly, such as +/// changing the type of a raw pointer or turning closures into raw pointers. +/// +/// Other places `as` is used include as extra syntax for [`crate`] and `use`, to change the name +/// something is imported as. +/// +/// For more information on what `as` is capable of, see the [Reference] +/// +/// [Reference]: +/// https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions +/// [`crate`]: keyword.crate.html +mod as_keyword { } + +#[doc(keyword = "const")] +// +/// The keyword for defining constants. +/// +/// Sometimes a certain value is used many times throughout a program, and it can become +/// inconvenient to copy it over and over. What's more, it's not always possible or desirable to +/// make it a variable that gets carried around to each function that needs it. In these cases, the +/// `const` keyword provides a convenient alternative to code duplication. +/// +/// ```rust +/// const THING: u32 = 0xABAD1DEA; +/// +/// let foo = 123 + THING; +/// ``` +/// +/// Constants must be explicitly typed, unlike with `let` you can't ignore its type and let the +/// compiler figure it out. Any constant value can be defined in a const, which in practice happens +/// to be most things that would be reasonable to have a constant (barring `const fn`s, coming +/// soon). For example, you can't have a File as a `const`. +/// +/// The only lifetime allowed in a constant is `'static`, which is the lifetime that encompasses +/// all others in a Rust program. For example, if you wanted to define a constant string, it would +/// look like this: +/// +/// ```rust +/// const WORDS: &'static str = "hello rust!"; +/// ``` +/// +/// Thanks to static lifetime elision, you usually don't have to explicitly use 'static: +/// +/// ```rust +/// const WORDS: &str = "hello convenience!"; +/// ``` +/// +/// `const` items looks remarkably similar to `static` items, which introduces some confusion as +/// to which one should be used at which times. To put it simply, constants are inlined wherever +/// they're used, making using them identical to simply replacing the name of the const with its +/// value. Static variables on the other hand point to a single location in memory, which all +/// accesses share. This means that, unlike with constants, they can't have destructors, and act as +/// a single value across the entire codebase. +/// +/// Constants, as with statics, should always be in SCREAMING_SNAKE_CASE. +/// +/// The `const` keyword is also used in raw pointers in combination with `mut`, as seen in `*const +/// T` and `*mut T`. More about that can be read at the [pointer] primitive part of the Rust docs. +/// +/// For more detail on `const`, see the [Rust Book] or the [Reference] +/// +/// [pointer]: primitive.pointer.html +/// [Rust Book]: +/// https://doc.rust-lang.org/stable/book/2018-edition/ch03-01-variables-and-mutability.html#differences-between-variables-and-constants +/// [Reference]: https://doc.rust-lang.org/reference/items/constant-items.html +mod const_keyword { } + +#[doc(keyword = "crate")] +// +/// The `crate` keyword. +/// +/// The primary use of the `crate` keyword is as a part of `extern crate` declarations, which are +/// used to specify a dependency on a crate external to the one it's declared in. Crates are the +/// fundamental compilation unit of Rust code, and can be seen as libraries or projects. More can +/// be read about crates in the [Reference]. +/// +/// ```rust ignore +/// extern crate rand; +/// extern crate my_crate as thing; +/// extern crate std; // implicitly added to the root of every Rust project +/// ``` +/// +/// The `as` keyword can be used to change what the crate is referred to as in your project. If a +/// crate name includes a dash, it is implicitly imported with the dashes replaced by underscores. +/// +/// `crate` is also used as in conjunction with `pub` to signify that the item it's attached to +/// is public only to other members of the same crate it's in. +/// +/// ```rust +/// # #[allow(unused_imports)] +/// pub(crate) use std::io::Error as IoError; +/// pub(crate) enum CoolMarkerType { } +/// pub struct PublicThing { +/// pub(crate) semi_secret_thing: bool, +/// } +/// ``` +/// +/// [Reference]: https://doc.rust-lang.org/reference/items/extern-crates.html +mod crate_keyword { } + +#[doc(keyword = "enum")] +// +/// For defining enumerations. +/// +/// Enums in Rust are similar to those of other compiled languages like C, but have important +/// differences that make them considerably more powerful. What Rust calls enums are more commonly +/// known as [Algebraic Data Types] if you're coming from a functional programming background. The +/// important detail is that each enum variant can have data to go along with it. +/// +/// ```rust +/// # struct Coord; +/// enum SimpleEnum { +/// FirstVariant, +/// SecondVariant, +/// ThirdVariant, +/// } +/// +/// enum Location { +/// Unknown, +/// Anonymous, +/// Known(Coord), +/// } +/// +/// enum ComplexEnum { +/// Nothing, +/// Something(u32), +/// LotsOfThings { +/// usual_struct_stuff: bool, +/// blah: String, +/// } +/// } +/// +/// enum EmptyEnum { } +/// ``` +/// +/// The first enum shown is the usual kind of enum you'd find in a C-style language. The second +/// shows off a hypothetical example of something storing location data, with `Coord` being any +/// other type that's needed, for example a struct. The third example demonstrates the kind of +/// data a variant can store, ranging from nothing, to a tuple, to an anonymous struct. +/// +/// Instantiating enum variants involves explicitly using the enum's name as its namespace, +/// followed by one of its variants. `SimpleEnum::SecondVariant` would be an example from above. +/// When data follows along with a variant, such as with rust's built-in [`Option`] type, the data +/// is added as the type describes, for example `Option::Some(123)`. The same follows with +/// struct-like variants, with things looking like `ComplexEnum::LotsOfThings { usual_struct_stuff: +/// true, blah: "hello!".to_string(), }`. Empty Enums are similar to () in that they cannot be +/// instantiated at all, and are used mainly to mess with the type system in interesting ways. +/// +/// For more information, take a look at the [Rust Book] or the [Reference] +/// +/// [Algebraic Data Types]: https://en.wikipedia.org/wiki/Algebraic_data_type +/// [`Option`]: option/enum.Option.html +/// [Rust Book]: https://doc.rust-lang.org/book/second-edition/ch06-01-defining-an-enum.html +/// [Reference]: https://doc.rust-lang.org/reference/items/enumerations.html +mod enum_keyword { } + +#[doc(keyword = "extern")] // -/// The `fn` keyword. +/// For external connections in Rust code. +/// +/// The `extern` keyword is used in two places in Rust. One is in conjunction with the [`crate`] +/// keyword to make your Rust code aware of other Rust crates in your project, i.e. `extern crate +/// lazy_static;`. The other use is in foreign function interfaces (FFI). +/// +/// `extern` is used in two different contexts within FFI. The first is in the form of external +/// blocks, for declaring function interfaces that Rust code can call foreign code by. +/// +/// ```rust ignore +/// #[link(name = "my_c_library")] +/// extern "C" { +/// fn my_c_function(x: i32) -> bool; +/// } +/// ``` +/// +/// This code would attempt to link with `libmy_c_library.so` on unix-like systems and +/// `my_c_library.dll` on Windows at runtime, and panic if it can't find something to link to. Rust +/// code could then use `my_c_function` as if it were any other unsafe Rust function. Working with +/// non-Rust languages and FFI is inherently unsafe, so wrappers are usually built around C APIs. +/// +/// The mirror use case of FFI is also done via the `extern` keyword: +/// +/// ```rust +/// #[no_mangle] +/// pub extern fn callable_from_c(x: i32) -> bool { +/// x % 3 == 0 +/// } +/// ``` +/// +/// If compiled as a dylib, the resulting .so could then be linked to from a C library, and the +/// function could be used as if it was from any other library. +/// +/// For more information on FFI, check the [Rust book] or the [Reference]. /// -/// The `fn` keyword is used to declare a function. +/// [Rust book]: +/// https://doc.rust-lang.org/book/second-edition/ch19-01-unsafe-rust.html#using-extern-functions-to-call-external-code +/// [Reference]: https://doc.rust-lang.org/reference/items/external-blocks.html +mod extern_keyword { } + +#[doc(keyword = "fn")] +// +/// The keyword for defining functions. /// -/// Example: +/// Functions are the primary way code is executed within Rust. Function blocks, usually just +/// called functions, can be defined in a variety of different places and be assigned many +/// different attributes and modifiers. +/// +/// Standalone functions that just sit within a module not attached to anything else are common, +/// but most functions will end up being inside [`impl`] blocks, either on another type itself, or +/// as a trait impl for that type. /// /// ```rust -/// fn some_function() { -/// // code goes in here +/// fn standalone_function() { +/// // code +/// } +/// +/// pub fn public_thing(argument: bool) -> String { +/// // code +/// # "".to_string() +/// } +/// +/// struct Thing { +/// foo: i32, +/// } +/// +/// impl Thing { +/// pub fn new() -> Self { +/// Self { +/// foo: 42, +/// } +/// } /// } /// ``` /// -/// For more information about functions, take a look at the [Rust Book][book]. +/// In addition to presenting fixed types in the form of `fn name(arg: type, ..) -> return_type`, +/// functions can also declare a list of type parameters along with trait bounds that they fall +/// into. +/// +/// ```rust +/// fn generic_function(x: T) -> (T, T, T) { +/// (x.clone(), x.clone(), x.clone()) +/// } /// -/// [book]: https://doc.rust-lang.org/book/second-edition/ch03-03-how-functions-work.html +/// fn generic_where(x: T) -> T +/// where T: std::ops::Add + Copy +/// { +/// x + x + x +/// } +/// ``` +/// +/// Declaring trait bounds in the angle brackets is functionally identical to using a `where` +/// clause. It's up to the programmer to decide which works better in each situation, but `where` +/// tends to be better when things get longer than one line. +/// +/// Along with being made public via `pub`, `fn` can also have an [`extern`] added for use in +/// FFI. +/// +/// For more information on the various types of functions and how they're used, consult the [Rust +/// book] or the [Reference]. +/// +/// [`impl`]: keyword.impl.html +/// [`extern`]: keyword.extern.html +/// [Rust book]: https://doc.rust-lang.org/book/second-edition/ch03-03-how-functions-work.html +/// [Reference]: https://doc.rust-lang.org/reference/items/functions.html mod fn_keyword { } -#[doc(keyword = "let")] +#[doc(keyword = "for")] // -/// The `let` keyword. +/// The `for` keyword. +/// +/// `for` is primarily used in for-in-loops, but it has a few other pieces of syntactic uses such as +/// `impl Trait for Type` (see [`impl`] for more info on that). for-in-loops, or to be more +/// precise, iterator loops, are a simple syntactic sugar over an exceedingly common practice +/// within Rust, which is to loop over an iterator until that iterator returns None (or `break` +/// is called). +/// +/// ```rust +/// for i in 0..5 { +/// println!("{}", i * 2); +/// } +/// +/// for i in std::iter::repeat(5) { +/// println!("turns out {} never stops being 5", i); +/// break; // would loop forever otherwise +/// } /// -/// The `let` keyword is used to declare a variable. +/// 'outer: for x in 5..50 { +/// for y in 0..10 { +/// if x == y { +/// break 'outer; +/// } +/// } +/// } +/// ``` /// -/// Example: +/// As shown in the example above, `for` loops (along with all other loops) can be tagged, using +/// similar syntax to lifetimes (only visually similar, entirely distinct in practice). Giving the +/// same tag to `break` breaks the tagged loop, which is useful for inner loops. It is definitely +/// not a goto. +/// +/// A `for` loop expands as shown: /// /// ```rust -/// # #![allow(unused_assignments)] -/// let x = 3; // We create a variable named `x` with the value `3`. +/// # fn code() { } +/// # let iterator = 0..2; +/// for loop_variable in iterator { +/// code() +/// } /// ``` /// -/// By default, all variables are **not** mutable. If you want a mutable variable, -/// you'll have to use the `mut` keyword. +/// ```rust +/// # fn code() { } +/// # let iterator = 0..2; +/// { +/// let mut _iter = std::iter::IntoIterator::into_iter(iterator); +/// loop { +/// match _iter.next() { +/// Some(loop_variable) => { +/// code() +/// }, +/// None => break, +/// } +/// } +/// } +/// ``` +/// +/// More details on the functionality shown can be seen at the [`IntoIterator`] docs. +/// +/// For more information on for-loops, see the [Rust book] or the [Reference]. +/// +/// [`impl`]: keyword.impl.html +/// [`IntoIterator`]: iter/trait.IntoIterator.html +/// [Rust book]: +/// https://doc.rust-lang.org/book/2018-edition/ch03-05-control-flow.html#looping-through-a-collection-with-for +/// [Reference]: https://doc.rust-lang.org/reference/expressions/loop-expr.html#iterator-loops +mod for_keyword { } + +#[doc(keyword = "if")] +// +/// If statements and expressions. /// -/// Example: +/// `if` is a familiar construct to most programmers, and is the main way you'll often do logic in +/// your code. However, unlike in most languages, `if` blocks can also act as expressions. +/// +/// ```rust +/// # let rude = true; +/// if 1 == 2 { +/// println!("whoops, mathematics broke"); +/// } else { +/// println!("everything's fine!"); +/// } +/// +/// let greeting = if rude { +/// "sup nerd." +/// } else { +/// "hello, friend!" +/// }; +/// +/// if let Ok(x) = "123".parse::() { +/// println!("{} double that and you get {}!", greeting, x * 2); +/// } +/// ``` +/// +/// Shown above are the three typical forms an `if` block comes in. First is the usual kind of +/// thing you'd see in many languages, with an optional `else` block. Second uses `if` as an +/// expression, which is only possible if all branches return the same type. An `if` expression can +/// be used everywhere you'd expect. The third kind of `if` block is an `if let` block, which +/// behaves similarly to using a `match` expression: +/// +/// ```rust +/// if let Some(x) = Some(123) { +/// // code +/// # let _ = x; +/// } else { +/// // something else +/// } +/// +/// match Some(123) { +/// Some(x) => { +/// // code +/// # let _ = x; +/// }, +/// _ => { +/// // something else +/// }, +/// } +/// ``` +/// +/// Each kind of `if` expression can be mixed and matched as needed. +/// +/// ```rust +/// if true == false { +/// println!("oh no"); +/// } else if "something" == "other thing" { +/// println!("oh dear"); +/// } else if let Some(200) = "blarg".parse::().ok() { +/// println!("uh oh"); +/// } else { +/// println!("phew, nothing's broken"); +/// } +/// ``` +/// +/// The `if` keyword is used in one other place in Rust, namely as a part of pattern matching +/// itself, allowing patterns such as `Some(x) if x > 200` to be used. +/// +/// For more information on `if` expressions, see the [Rust book] or the [Reference]. +/// +/// [Rust book]: +/// https://doc.rust-lang.org/stable/book/2018-edition/ch03-05-control-flow.html#if-expressions +/// [Reference]: https://doc.rust-lang.org/reference/expressions/if-expr.html +mod if_keyword { } + +#[doc(keyword = "impl")] +// +/// The implementation-defining keyword. +/// +/// The `impl` keyword is primarily used to define implementations on types. Inherent +/// implementations are standalone, while trait implementations are used to implement traits for +/// types, or other traits. +/// +/// Functions and consts can both be defined in an implementation. A function defined in an +/// `impl` block can be standalone, meaning it would be called like `Foo::bar()`. If the function +/// takes `self`, `&self`, or `&mut self` as its first argument, it can also be called using +/// method-call syntax, a familiar feature to any object oriented programmer, like `foo.bar()`. +/// +/// ```rust +/// struct Example { +/// number: i32, +/// } +/// +/// impl Example { +/// fn boo() { +/// println!("boo! Example::boo() was called!"); +/// } +/// +/// fn answer(&mut self) { +/// self.number += 42; +/// } +/// +/// fn get_number(&self) -> i32 { +/// self.number +/// } +/// } +/// +/// trait Thingy { +/// fn do_thingy(&self); +/// } +/// +/// impl Thingy for Example { +/// fn do_thingy(&self) { +/// println!("doing a thing! also, number is {}!", self.number); +/// } +/// } +/// ``` +/// +/// For more information on implementations, see the [Rust book][book1] or the [Reference]. +/// +/// The other use of the `impl` keyword is in `impl Trait` syntax, which can be seen as a shorthand +/// for "a concrete type that implements this trait". Its primary use is working with closures, +/// which have type definitions generated at compile time that can't be simply typed out. +/// +/// ```rust +/// fn thing_returning_closure() -> impl Fn(i32) -> bool { +/// println!("here's a closure for you!"); +/// |x: i32| x % 3 == 0 +/// } +/// ``` +/// +/// For more information on `impl Trait` syntax, see the [Rust book][book2]. +/// +/// [book1]: https://doc.rust-lang.org/stable/book/2018-edition/ch05-03-method-syntax.html +/// [Reference]: https://doc.rust-lang.org/reference/items/implementations.html +/// [book2]: +/// https://doc.rust-lang.org/stable/book/2018-edition/ch10-02-traits.html#returning-traits +mod impl_keyword { } + +#[doc(keyword = "let")] +// +/// The variable binding keyword. +/// +/// The primary use for the `let` keyword is in `let` statements, which are used to introduce a new +/// set of variables into the current scope, as given by a pattern. /// /// ```rust /// # #![allow(unused_assignments)] -/// let mut x = 3; // We create a mutable variable named `x` with the value `3`. +/// let thing1: i32 = 100; +/// let thing2 = 200 + thing1; /// -/// x += 4; // `x` is now equal to `7`. +/// let mut changing_thing = true; +/// changing_thing = false; +/// +/// let (part1, part2) = ("first", "second"); +/// +/// struct Example { +/// a: bool, +/// b: u64, +/// } +/// +/// let Example { a, b: _ } = Example { +/// a: true, +/// b: 10004, +/// }; +/// assert!(a); /// ``` /// -/// For more information about the `let` keyword, take a look at the [Rust Book][book]. +/// The pattern is most commonly a single variable, which means no pattern matching is done and +/// the expression given is bound to the variable. Apart from that, patterns used in `let` bindings +/// can be as complicated as needed, given that the pattern is exhaustive. See the [Rust +/// book][book1] for more information on pattern matching. The type of the pattern is optionally +/// given afterwards, but if left blank is automatically inferred by the compiler if possible. +/// +/// Variables in Rust are immutable by default, and require the `mut` keyword to be made mutable. +/// +/// Multiple variables can be defined with the same name, known as shadowing. This doesn't affect +/// the original variable in any way beyond being unable to directly access it beyond the point of +/// shadowing. It continues to remain in scope, getting dropped only when it falls out of scope. +/// Shadowed variables don't need to have the same type as the variables shadowing them. +/// +/// ```rust +/// let shadowing_example = true; +/// let shadowing_example = 123.4; +/// let shadowing_example = shadowing_example as u32; +/// let mut shadowing_example = format!("cool! {}", shadowing_example); +/// shadowing_example += " something else!"; // not shadowing +/// ``` /// -/// [book]: https://doc.rust-lang.org/book/second-edition/ch03-01-variables-and-mutability.html +/// Other places the `let` keyword is used include along with [`if`], in the form of `if let` +/// expressions. They're useful if the pattern being matched isn't exhaustive, such as with +/// enumerations. `while let` also exists, which runs a loop with a pattern matched value until +/// that pattern can't be matched. +/// +/// For more information on the `let` keyword, see the [Rust book] or the [Reference] +/// +/// [book1]: https://doc.rust-lang.org/stable/book/2018-edition/ch06-02-match.html +/// [`if`]: keyword.if.html +/// [book2]: +/// https://doc.rust-lang.org/stable/book/2018-edition/ch18-01-all-the-places-for-patterns.html#let-statements +/// [Reference]: https://doc.rust-lang.org/reference/statements.html#let-statements mod let_keyword { } -#[doc(keyword = "struct")] +#[doc(keyword = "loop")] // -/// The `struct` keyword. +/// The loop-defining keyword. /// -/// The `struct` keyword is used to define a struct type. +/// `loop` is used to define the simplest kind of loop supported in Rust. It runs the code inside +/// it until the code uses `break` or the program exits. /// -/// Example: +/// ```rust +/// loop { +/// println!("hello world forever!"); +/// # break; +/// } /// +/// let mut i = 0; +/// loop { +/// println!("i is {}", i); +/// if i > 10 { +/// break; +/// } +/// i += 1; +/// } /// ``` -/// struct Foo { -/// field1: u32, +/// +/// Unlike the other kinds of loops in Rust (`while`, `while let`, and `for`), loops can be used as +/// expressions that return values via `break`. +/// +/// ```rust +/// let mut i = 1; +/// let something = loop { +/// i *= 2; +/// if i > 100 { +/// break i; +/// } +/// }; +/// assert_eq!(something, 128); +/// ``` +/// +/// Every `break` in a loop has to have the same type. When it's not explicitly giving something, +/// `break;` returns `()`. +/// +/// For more information on `loop` and loops in general, see the [Reference]. +/// +/// [Reference]: https://doc.rust-lang.org/reference/expressions/loop-expr.html +mod loop_keyword { } + +#[doc(keyword = "struct")] +// +/// The keyword used to define structs. +/// +/// Structs in Rust come in three flavours: Structs with named fields, tuple structs, and unit +/// structs. +/// +/// ```rust +/// struct Regular { +/// field1: f32, /// field2: String, +/// pub field3: bool /// } +/// +/// struct Tuple(u32, String); +/// +/// struct Unit; +/// ``` +/// +/// Regular structs are the most commonly used. Each field defined within them has a name and a +/// type, and once defined can be accessed using `example_struct.field` syntax. The fields of a +/// struct share its mutability, so `foo.bar = 2;` would only be valid if `foo` was mutable. Adding +/// `pub` to a field makes it visible to code in other modules, as well as allowing it to be +/// directly accessed and modified. +/// +/// Tuple structs are similar to regular structs, but its fields have no names. They are used like +/// tuples, with deconstruction possible via `let TupleStruct(x, y) = foo;` syntax. For accessing +/// individual variables, the same syntax is used as with regular tuples, namely `foo.0`, `foo.1`, +/// etc, starting at zero. +/// +/// Unit structs are most commonly used as marker. They have a size of zero bytes, but unlike empty +/// enums they can be instantiated, making them isomorphic to the unit type `()`. Unit structs are +/// useful when you need to implement a trait on something, but don't need to store any data inside +/// it. +/// +/// # Instantiation +/// +/// Structs can be instantiated in different ways, all of which can be mixed and +/// matched as needed. The most common way to make a new struct is via a constructor method such as +/// `new()`, but when that isn't available (or you're writing the constructor itself), struct +/// literal syntax is used: +/// +/// ```rust +/// # struct Foo { field1: f32, field2: String, etc: bool } +/// let example = Foo { +/// field1: 42.0, +/// field2: "blah".to_string(), +/// etc: true, +/// }; /// ``` /// -/// There are different kinds of structs. For more information, take a look at the -/// [Rust Book][book]. +/// It's only possible to directly instantiate a struct using struct literal syntax when all of its +/// fields are visible to you. +/// +/// There are a handful of shortcuts provided to make writing constructors more convenient, most +/// common of which is the Field Init shorthand. When there is a variable and a field of the same +/// name, the assignment can be simplified from `field: field` into simply `field`. The following +/// example of a hypothetical constructor demonstrates this: +/// +/// ```rust +/// struct User { +/// name: String, +/// admin: bool, +/// } +/// +/// impl User { +/// pub fn new(name: String) -> Self { +/// Self { +/// name, +/// admin: false, +/// } +/// } +/// } +/// ``` +/// +/// Another shortcut for struct instantiation is available, used when you need to make a new +/// struct that has the same values as most of a previous struct of the same type, called struct +/// update syntax: +/// +/// ```rust +/// # struct Foo { field1: String, field2: () } +/// # let thing = Foo { field1: "".to_string(), field2: () }; +/// let updated_thing = Foo { +/// field1: "a new value".to_string(), +/// ..thing +/// }; +/// ``` +/// +/// Tuple structs are instantiated in the same way as tuples themselves, except with the struct's +/// name as a prefix: `Foo(123, false, 0.1)`. +/// +/// Empty structs are instantiated with just their name, and don't need anything else. `let thing = +/// EmptyStruct;` +/// +/// # Style conventions +/// +/// Structs are always written in CamelCase, with few exceptions. While the trailing comma on a +/// struct's list of fields can be omitted, it's usually kept for convenience in adding and +/// removing fields down the line. +/// +/// For more information on structs, take a look at the [Rust Book][book] or the +/// [Reference][reference]. /// +/// [`PhantomData`]: marker/struct.PhantomData.html /// [book]: https://doc.rust-lang.org/book/second-edition/ch05-01-defining-structs.html +/// [reference]: https://doc.rust-lang.org/reference/items/structs.html mod struct_keyword { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/lib.rs rustc-1.31.0+dfsg1+llvm/src/libstd/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -185,7 +185,7 @@ //! [slice]: primitive.slice.html //! [`atomic`]: sync/atomic/index.html //! [`collections`]: collections/index.html -//! [`for`]: ../book/first-edition/loops.html#for +//! [`for`]: ../book/ch03-05-control-flow.html#looping-through-a-collection-with-for //! [`format!`]: macro.format.html //! [`fs`]: fs/index.html //! [`io`]: io/index.html @@ -200,14 +200,14 @@ //! [`sync`]: sync/index.html //! [`thread`]: thread/index.html //! [`use std::env`]: env/index.html -//! [`use`]: ../book/first-edition/crates-and-modules.html#importing-modules-with-use -//! [crate root]: ../book/first-edition/crates-and-modules.html#basic-terminology-crates-and-modules +//! [`use`]: ../book/ch07-02-modules-and-use-to-control-scope-and-privacy.html#the-use-keyword-to-bring-paths-into-a-scope +//! [crate root]: ../book/ch07-01-packages-and-crates-for-making-libraries-and-executables.html //! [crates.io]: https://crates.io -//! [deref-coercions]: ../book/second-edition/ch15-02-deref.html#implicit-deref-coercions-with-functions-and-methods +//! [deref-coercions]: ../book/ch15-02-deref.html#implicit-deref-coercions-with-functions-and-methods //! [files]: fs/struct.File.html //! [multithreading]: thread/index.html //! [other]: #what-is-in-the-standard-library-documentation -//! [primitive types]: ../book/first-edition/primitive-types.html +//! [primitive types]: ../book/ch03-02-data-types.html #![stable(feature = "rust1", since = "1.0.0")] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", @@ -250,12 +250,14 @@ #![feature(cfg_target_vendor)] #![feature(char_error_internals)] #![feature(compiler_builtins_lib)] -#![cfg_attr(stage0, feature(const_fn))] -#![cfg_attr(not(stage0), feature(min_const_fn))] +#![cfg_attr(stage0, feature(min_const_fn))] #![feature(const_int_ops)] #![feature(const_ip)] +#![feature(const_raw_ptr_deref)] +#![feature(const_cstr_unchecked)] #![feature(core_intrinsics)] #![feature(dropck_eyepatch)] +#![feature(duration_as_u128)] #![feature(exact_size_is_empty)] #![feature(external_doc)] #![feature(fixed_size_array)] @@ -270,11 +272,9 @@ #![feature(libc)] #![feature(link_args)] #![feature(linkage)] -#![cfg_attr(stage0, feature(macro_vis_matcher))] #![feature(needs_panic_runtime)] #![feature(never_type)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(exhaustive_patterns)] #![feature(on_unimplemented)] #![feature(optin_builtin_traits)] @@ -287,7 +287,7 @@ #![feature(rustc_attrs)] #![feature(rustc_const_unstable)] #![feature(std_internals)] -#![feature(stdsimd)] +#![cfg_attr(not(stage0), feature(stdsimd))] #![feature(shrink_to)] #![feature(slice_concat_ext)] #![feature(slice_internals)] @@ -303,15 +303,12 @@ #![feature(unboxed_closures)] #![feature(untagged_unions)] #![feature(unwind_attributes)] -#![cfg_attr(stage0, feature(use_extern_macros))] #![feature(doc_cfg)] #![feature(doc_masked)] #![feature(doc_spotlight)] -#![cfg_attr(all(windows, stage0), feature(used))] #![feature(doc_alias)] #![feature(doc_keyword)] #![feature(panic_info_message)] -#![cfg_attr(stage0, feature(panic_implementation))] #![feature(non_exhaustive)] #![default_lib_allocator] @@ -436,7 +433,7 @@ #[stable(feature = "rust1", since = "1.0.0")] pub use alloc_crate::format; #[unstable(feature = "pin", issue = "49150")] -pub use alloc_crate::pin; +pub use core::pin; #[stable(feature = "rust1", since = "1.0.0")] pub use alloc_crate::slice; #[stable(feature = "rust1", since = "1.0.0")] diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/macros.rs rustc-1.31.0+dfsg1+llvm/src/libstd/macros.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/macros.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/macros.rs 2018-12-04 23:41:40.000000000 +0000 @@ -32,7 +32,7 @@ /// /// [`Result`] enum is often a better solution for recovering from errors than /// using the `panic!` macro. This macro should be used to avoid proceeding using -/// incorrect values, such as from external sources. Detailed information about +/// incorrect values, such as from external sources. Detailed information about /// error handling is found in the [book]. /// /// The multi-argument form of this macro panics with a string and has the @@ -45,7 +45,7 @@ /// [`Result`]: ../std/result/enum.Result.html /// [`format!`]: ../std/macro.format.html /// [`compile_error!`]: ../std/macro.compile_error.html -/// [book]: ../book/second-edition/ch09-01-unrecoverable-errors-with-panic.html +/// [book]: ../book/ch09-00-error-handling.html /// /// # Current implementation /// @@ -139,7 +139,7 @@ /// /// [`format!`]: ../std/macro.format.html /// [`std::fmt`]: ../std/fmt/index.html -/// [`eprintln!`]: ../std/macro.eprint.html +/// [`eprintln!`]: ../std/macro.eprintln.html /// # Panics /// /// Panics if writing to `io::stdout` fails. @@ -220,6 +220,126 @@ }) } +/// A macro for quick and dirty debugging with which you can inspect +/// the value of a given expression. An example: +/// +/// ```rust +/// #![feature(dbg_macro)] +/// +/// let a = 2; +/// let b = dbg!(a * 2) + 1; +/// // ^-- prints: [src/main.rs:4] a * 2 = 4 +/// assert_eq!(b, 5); +/// ``` +/// +/// The macro works by using the `Debug` implementation of the type of +/// the given expression to print the value to [stderr] along with the +/// source location of the macro invocation as well as the source code +/// of the expression. +/// +/// Invoking the macro on an expression moves and takes ownership of it +/// before returning the evaluated expression unchanged. If the type +/// of the expression does not implement `Copy` and you don't want +/// to give up ownership, you can instead borrow with `dbg!(&expr)` +/// for some expression `expr`. +/// +/// Note that the macro is intended as a debugging tool and therefore you +/// should avoid having uses of it in version control for longer periods. +/// Use cases involving debug output that should be added to version control +/// may be better served by macros such as `debug!` from the `log` crate. +/// +/// # Stability +/// +/// The exact output printed by this macro should not be relied upon +/// and is subject to future changes. +/// +/// # Panics +/// +/// Panics if writing to `io::stderr` fails. +/// +/// # Further examples +/// +/// With a method call: +/// +/// ```rust +/// #![feature(dbg_macro)] +/// +/// fn foo(n: usize) { +/// if let Some(_) = dbg!(n.checked_sub(4)) { +/// // ... +/// } +/// } +/// +/// foo(3) +/// ``` +/// +/// This prints to [stderr]: +/// +/// ```text,ignore +/// [src/main.rs:4] n.checked_sub(4) = None +/// ``` +/// +/// Naive factorial implementation: +/// +/// ```rust +/// #![feature(dbg_macro)] +/// +/// fn factorial(n: u32) -> u32 { +/// if dbg!(n <= 1) { +/// dbg!(1) +/// } else { +/// dbg!(n * factorial(n - 1)) +/// } +/// } +/// +/// dbg!(factorial(4)); +/// ``` +/// +/// This prints to [stderr]: +/// +/// ```text,ignore +/// [src/main.rs:3] n <= 1 = false +/// [src/main.rs:3] n <= 1 = false +/// [src/main.rs:3] n <= 1 = false +/// [src/main.rs:3] n <= 1 = true +/// [src/main.rs:4] 1 = 1 +/// [src/main.rs:5] n * factorial(n - 1) = 2 +/// [src/main.rs:5] n * factorial(n - 1) = 6 +/// [src/main.rs:5] n * factorial(n - 1) = 24 +/// [src/main.rs:11] factorial(4) = 24 +/// ``` +/// +/// The `dbg!(..)` macro moves the input: +/// +/// ```compile_fail +/// #![feature(dbg_macro)] +/// +/// /// A wrapper around `usize` which importantly is not Copyable. +/// #[derive(Debug)] +/// struct NoCopy(usize); +/// +/// let a = NoCopy(42); +/// let _ = dbg!(a); // <-- `a` is moved here. +/// let _ = dbg!(a); // <-- `a` is moved again; error! +/// ``` +/// +/// [stderr]: https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr) +#[macro_export] +#[unstable(feature = "dbg_macro", issue = "54306")] +macro_rules! dbg { + ($val:expr) => { + // Use of `match` here is intentional because it affects the lifetimes + // of temporaries - https://stackoverflow.com/a/48732525/1063961 + match $val { + tmp => { + eprintln!("[{}:{}] {} = {:#?}", + file!(), line!(), stringify!($val), &tmp); + tmp + } + } + } +} + #[macro_export] #[unstable(feature = "await_macro", issue = "50547")] #[allow_internal_unstable] @@ -229,8 +349,8 @@ let mut pinned = $e; loop { if let $crate::task::Poll::Ready(x) = - $crate::future::poll_in_task_cx(unsafe { - $crate::pin::PinMut::new_unchecked(&mut pinned) + $crate::future::poll_with_tls_waker(unsafe { + $crate::pin::Pin::new_unchecked(&mut pinned) }) { break x; @@ -717,8 +837,8 @@ /// boolean expression evaluation of configuration flags. This frequently /// leads to less duplicated code. /// - /// The syntax given to this macro is the same syntax as [the `cfg` - /// attribute](../book/first-edition/conditional-compilation.html). + /// The syntax given to this macro is the same syntax as the `cfg` + /// attribute. /// /// # Examples /// @@ -793,7 +913,7 @@ /// Unsafe code relies on `assert!` to enforce run-time invariants that, if /// violated could lead to unsafety. /// - /// Other use-cases of `assert!` include [testing] and enforcing run-time + /// Other use-cases of `assert!` include testing and enforcing run-time /// invariants in safe code (whose violation cannot result in unsafety). /// /// # Custom Messages @@ -804,7 +924,6 @@ /// /// [`panic!`]: macro.panic.html /// [`debug_assert!`]: macro.debug_assert.html - /// [testing]: ../book/second-edition/ch11-01-writing-tests.html#checking-results-with-the-assert-macro /// [`std::fmt`]: ../std/fmt/index.html /// /// # Examples diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/net/addr.rs rustc-1.31.0+dfsg1+llvm/src/libstd/net/addr.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/net/addr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/net/addr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -554,6 +554,7 @@ #[stable(feature = "ip_from_ip", since = "1.16.0")] impl From for SocketAddr { + /// Converts a [`SocketAddrV4`] into a [`SocketAddr::V4`]. fn from(sock4: SocketAddrV4) -> SocketAddr { SocketAddr::V4(sock4) } @@ -561,6 +562,7 @@ #[stable(feature = "ip_from_ip", since = "1.16.0")] impl From for SocketAddr { + /// Converts a [`SocketAddrV6`] into a [`SocketAddr::V6`]. fn from(sock6: SocketAddrV6) -> SocketAddr { SocketAddr::V6(sock6) } @@ -568,6 +570,12 @@ #[stable(feature = "addr_from_into_ip", since = "1.17.0")] impl> From<(I, u16)> for SocketAddr { + /// Converts a tuple struct (Into<[`IpAddr`]>, `u16`) into a [`SocketAddr`]. + /// + /// This conversion creates a [`SocketAddr::V4`] for a [`IpAddr::V4`] + /// and creates a [`SocketAddr::V6`] for a [`IpAddr::V6`]. + /// + /// `u16` is treated as port of the newly created [`SocketAddr`]. fn from(pieces: (I, u16)) -> SocketAddr { SocketAddr::new(pieces.0.into(), pieces.1) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/net/tcp.rs rustc-1.31.0+dfsg1+llvm/src/libstd/net/tcp.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/net/tcp.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/net/tcp.rs 2018-12-04 23:41:40.000000000 +0000 @@ -43,12 +43,12 @@ /// use std::io::prelude::*; /// use std::net::TcpStream; /// -/// { -/// let mut stream = TcpStream::connect("127.0.0.1:34254").unwrap(); +/// fn main() -> std::io::Result<()> { +/// let mut stream = TcpStream::connect("127.0.0.1:34254")?; /// -/// // ignore the Result -/// let _ = stream.write(&[1]); -/// let _ = stream.read(&mut [0; 128]); // ignore here too +/// stream.write(&[1])?; +/// stream.read(&mut [0; 128])?; +/// Ok(()) /// } // the stream is closed here /// ``` #[stable(feature = "rust1", since = "1.0.0")] diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/panicking.rs rustc-1.31.0+dfsg1+llvm/src/libstd/panicking.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/panicking.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/panicking.rs 2018-12-04 23:41:40.000000000 +0000 @@ -319,8 +319,7 @@ /// Entry point of panic from the libcore crate. #[cfg(not(test))] -#[cfg_attr(stage0, panic_implementation)] -#[cfg_attr(not(stage0), panic_handler)] +#[panic_handler] #[unwind(allowed)] pub fn rust_begin_panic(info: &PanicInfo) -> ! { continue_panic_fmt(&info) @@ -398,7 +397,7 @@ #[unstable(feature = "libstd_sys_internals", reason = "used by the panic! macro", issue = "0")] -#[cfg_attr(not(any(stage0, test)), lang = "begin_panic")] +#[cfg_attr(not(test), lang = "begin_panic")] #[inline(never)] #[cold] // avoid code bloat at the call sites as much as possible pub fn begin_panic(msg: M, file_line_col: &(&'static str, u32, u32)) -> ! { // Note that this should be the only allocation performed in this code path. @@ -516,10 +515,11 @@ rust_panic(&mut RewrapBox(msg)) } -/// A private no-mangle function on which to slap yer breakpoints. -#[no_mangle] -#[allow(private_no_mangle_fns)] // yes we get it, but we like breakpoints -pub fn rust_panic(mut msg: &mut dyn BoxMeUp) -> ! { +/// An unmangled function (through `rustc_std_internal_symbol`) on which to slap +/// yer breakpoints. +#[inline(never)] +#[cfg_attr(not(test), rustc_std_internal_symbol)] +fn rust_panic(mut msg: &mut dyn BoxMeUp) -> ! { let code = unsafe { let obj = &mut msg as *mut &mut dyn BoxMeUp; __rust_start_panic(obj as usize) diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/panic.rs rustc-1.31.0+dfsg1+llvm/src/libstd/panic.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/panic.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/panic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,13 +16,13 @@ use cell::UnsafeCell; use fmt; use future::Future; -use pin::PinMut; +use pin::Pin; use ops::{Deref, DerefMut}; use panicking; use ptr::{Unique, NonNull}; use rc::Rc; use sync::{Arc, Mutex, RwLock, atomic}; -use task::{self, Poll}; +use task::{LocalWaker, Poll}; use thread::Result; #[stable(feature = "panic_hooks", since = "1.10.0")] @@ -79,7 +79,7 @@ /// /// Simply put, a type `T` implements `UnwindSafe` if it cannot easily allow /// witnessing a broken invariant through the use of `catch_unwind` (catching a -/// panic). This trait is a marker trait, so it is automatically implemented for +/// panic). This trait is an auto trait, so it is automatically implemented for /// many types, and it is also structurally composed (e.g. a struct is unwind /// safe if all of its components are unwind safe). /// @@ -327,9 +327,9 @@ impl<'a, F: Future> Future for AssertUnwindSafe { type Output = F::Output; - fn poll(self: PinMut, cx: &mut task::Context) -> Poll { - let pinned_field = unsafe { PinMut::map_unchecked(self, |x| &mut x.0) }; - pinned_field.poll(cx) + fn poll(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll { + let pinned_field = unsafe { Pin::map_unchecked_mut(self, |x| &mut x.0) }; + F::poll(pinned_field, lw) } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/primitive_docs.rs rustc-1.31.0+dfsg1+llvm/src/libstd/primitive_docs.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/primitive_docs.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/primitive_docs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -22,7 +22,7 @@ /// `bool` implements various traits, such as [`BitAnd`], [`BitOr`], [`Not`], etc., /// which allow us to perform boolean operations using `&`, `|` and `!`. /// -/// [`if`] always demands a `bool` value. [`assert!`], being an important macro in testing, +/// `if` always demands a `bool` value. [`assert!`], being an important macro in testing, /// checks whether an expression returns `true`. /// /// ``` @@ -31,7 +31,6 @@ /// ``` /// /// [`assert!`]: macro.assert.html -/// [`if`]: ../book/first-edition/if.html /// [`BitAnd`]: ops/trait.BitAnd.html /// [`BitOr`]: ops/trait.BitOr.html /// [`Not`]: ops/trait.Not.html @@ -208,7 +207,7 @@ /// # `!` and traits /// /// When writing your own traits, `!` should have an `impl` whenever there is an obvious `impl` -/// which doesn't `panic!`. As is turns out, most traits can have an `impl` for `!`. Take [`Debug`] +/// which doesn't `panic!`. As it turns out, most traits can have an `impl` for `!`. Take [`Debug`] /// for example: /// /// ``` @@ -228,9 +227,9 @@ /// [`fmt::Result`]. Since this method takes a `&!` as an argument we know that it can never be /// called (because there is no value of type `!` for it to be called with). Writing `*self` /// essentially tells the compiler "We know that this code can never be run, so just treat the -/// entire function body has having type [`fmt::Result`]". This pattern can be used a lot when +/// entire function body as having type [`fmt::Result`]". This pattern can be used a lot when /// implementing traits for `!`. Generally, any trait which only has methods which take a `self` -/// parameter should have such as impl. +/// parameter should have such an impl. /// /// On the other hand, one trait which would not be appropriate to implement is [`Default`]: /// @@ -323,8 +322,8 @@ /// let s = String::from("love: ❤️"); /// let v: Vec = s.chars().collect(); /// -/// assert_eq!(12, s.len() * std::mem::size_of::()); -/// assert_eq!(32, v.len() * std::mem::size_of::()); +/// assert_eq!(12, std::mem::size_of_val(&s[..])); +/// assert_eq!(32, std::mem::size_of_val(&v[..])); /// ``` #[stable(feature = "rust1", since = "1.0.0")] mod prim_char { } @@ -695,7 +694,7 @@ /// assert_eq!(tuple.2, 'c'); /// ``` /// -/// For more about tuples, see [the book](../book/first-edition/primitive-types.html#tuples). +/// For more about tuples, see [the book](../book/ch03-02-data-types.html#the-tuple-type). /// /// # Trait implementations /// @@ -908,11 +907,36 @@ /// `&mut T` references can be freely coerced into `&T` references with the same referent type, and /// references with longer lifetimes can be freely coerced into references with shorter ones. /// +/// Reference equality by address, instead of comparing the values pointed to, is accomplished via +/// implicit reference-pointer coercion and raw pointer equality via [`ptr::eq`], while +/// [`PartialEq`] compares values. +/// +/// [`ptr::eq`]: ptr/fn.eq.html +/// [`PartialEq`]: cmp/trait.PartialEq.html +/// +/// ``` +/// use std::ptr; +/// +/// let five = 5; +/// let other_five = 5; +/// let five_ref = &five; +/// let same_five_ref = &five; +/// let other_five_ref = &other_five; +/// +/// assert!(five_ref == same_five_ref); +/// assert!(five_ref == other_five_ref); +/// +/// assert!(ptr::eq(five_ref, same_five_ref)); +/// assert!(!ptr::eq(five_ref, other_five_ref)); +/// ``` +/// /// For more information on how to use references, see [the book's section on "References and /// Borrowing"][book-refs]. /// /// [book-refs]: ../book/second-edition/ch04-02-references-and-borrowing.html /// +/// # Trait implementations +/// /// The following traits are implemented for all `&T`, regardless of the type of its referent: /// /// * [`Copy`] diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/process.rs rustc-1.31.0+dfsg1+llvm/src/libstd/process.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/process.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/process.rs 2018-12-04 23:41:40.000000000 +0000 @@ -1016,6 +1016,28 @@ #[stable(feature = "stdio_from", since = "1.20.0")] impl From for Stdio { + /// Converts a `ChildStdin` into a `Stdio` + /// + /// # Examples + /// + /// `ChildStdin` will be converted to `Stdio` using `Stdio::from` under the hood. + /// + /// ```rust + /// use std::process::{Command, Stdio}; + /// + /// let reverse = Command::new("rev") + /// .stdin(Stdio::piped()) + /// .spawn() + /// .expect("failed reverse command"); + /// + /// let _echo = Command::new("echo") + /// .arg("Hello, world!") + /// .stdout(reverse.stdin.unwrap()) // Converted into a Stdio here + /// .output() + /// .expect("failed echo command"); + /// + /// // "!dlrow ,olleH" echoed to console + /// ``` fn from(child: ChildStdin) -> Stdio { Stdio::from_inner(child.into_inner().into()) } @@ -1023,6 +1045,28 @@ #[stable(feature = "stdio_from", since = "1.20.0")] impl From for Stdio { + /// Converts a `ChildStdout` into a `Stdio` + /// + /// # Examples + /// + /// `ChildStdout` will be converted to `Stdio` using `Stdio::from` under the hood. + /// + /// ```rust + /// use std::process::{Command, Stdio}; + /// + /// let hello = Command::new("echo") + /// .arg("Hello, world!") + /// .stdout(Stdio::piped()) + /// .spawn() + /// .expect("failed echo command"); + /// + /// let reverse = Command::new("rev") + /// .stdin(hello.stdout.unwrap()) // Converted into a Stdio here + /// .output() + /// .expect("failed reverse command"); + /// + /// assert_eq!(reverse.stdout, b"!dlrow ,olleH\n"); + /// ``` fn from(child: ChildStdout) -> Stdio { Stdio::from_inner(child.into_inner().into()) } @@ -1030,6 +1074,30 @@ #[stable(feature = "stdio_from", since = "1.20.0")] impl From for Stdio { + /// Converts a `ChildStderr` into a `Stdio` + /// + /// # Examples + /// + /// ```rust,no_run + /// use std::process::{Command, Stdio}; + /// + /// let reverse = Command::new("rev") + /// .arg("non_existing_file.txt") + /// .stderr(Stdio::piped()) + /// .spawn() + /// .expect("failed reverse command"); + /// + /// let cat = Command::new("cat") + /// .arg("-") + /// .stdin(reverse.stderr.unwrap()) // Converted into a Stdio here + /// .output() + /// .expect("failed echo command"); + /// + /// assert_eq!( + /// String::from_utf8_lossy(&cat.stdout), + /// "rev: cannot open non_existing_file.txt: No such file or directory\n" + /// ); + /// ``` fn from(child: ChildStderr) -> Stdio { Stdio::from_inner(child.into_inner().into()) } @@ -1037,6 +1105,26 @@ #[stable(feature = "stdio_from", since = "1.20.0")] impl From for Stdio { + /// Converts a `File` into a `Stdio` + /// + /// # Examples + /// + /// `File` will be converted to `Stdio` using `Stdio::from` under the hood. + /// + /// ```rust,no_run + /// use std::fs::File; + /// use std::process::Command; + /// + /// // With the `foo.txt` file containing `Hello, world!" + /// let file = File::open("foo.txt").unwrap(); + /// + /// let reverse = Command::new("rev") + /// .stdin(file) // Implicit File convertion into a Stdio + /// .output() + /// .expect("failed reverse command"); + /// + /// assert_eq!(reverse.stdout, b"!dlrow ,olleH"); + /// ``` fn from(file: fs::File) -> Stdio { Stdio::from_inner(file.into_inner().into()) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/sync/mod.rs rustc-1.31.0+dfsg1+llvm/src/libstd/sync/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/sync/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/sync/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,10 +10,154 @@ //! Useful synchronization primitives. //! -//! This module contains useful safe and unsafe synchronization primitives. -//! Most of the primitives in this module do not provide any sort of locking -//! and/or blocking at all, but rather provide the necessary tools to build -//! other types of concurrent primitives. +//! ## The need for synchronization +//! +//! Conceptually, a Rust program is a series of operations which will +//! be executed on a computer. The timeline of events happening in the +//! program is consistent with the order of the operations in the code. +//! +//! Consider the following code, operating on some global static variables: +//! +//! ```rust +//! static mut A: u32 = 0; +//! static mut B: u32 = 0; +//! static mut C: u32 = 0; +//! +//! fn main() { +//! unsafe { +//! A = 3; +//! B = 4; +//! A = A + B; +//! C = B; +//! println!("{} {} {}", A, B, C); +//! C = A; +//! } +//! } +//! ``` +//! +//! It appears as if some variables stored in memory are changed, an addition +//! is performed, result is stored in `A` and the variable `C` is +//! modified twice. +//! +//! When only a single thread is involved, the results are as expected: +//! the line `7 4 4` gets printed. +//! +//! As for what happens behind the scenes, when optimizations are enabled the +//! final generated machine code might look very different from the code: +//! +//! - The first store to `C` might be moved before the store to `A` or `B`, +//! _as if_ we had written `C = 4; A = 3; B = 4`. +//! +//! - Assignment of `A + B` to `A` might be removed, since the sum can be stored +//! in a temporary location until it gets printed, with the global variable +//! never getting updated. +//! +//! - The final result could be determined just by looking at the code +//! at compile time, so [constant folding] might turn the whole +//! block into a simple `println!("7 4 4")`. +//! +//! The compiler is allowed to perform any combination of these +//! optimizations, as long as the final optimized code, when executed, +//! produces the same results as the one without optimizations. +//! +//! Due to the [concurrency] involved in modern computers, assumptions +//! about the program's execution order are often wrong. Access to +//! global variables can lead to nondeterministic results, **even if** +//! compiler optimizations are disabled, and it is **still possible** +//! to introduce synchronization bugs. +//! +//! Note that thanks to Rust's safety guarantees, accessing global (static) +//! variables requires `unsafe` code, assuming we don't use any of the +//! synchronization primitives in this module. +//! +//! [constant folding]: https://en.wikipedia.org/wiki/Constant_folding +//! [concurrency]: https://en.wikipedia.org/wiki/Concurrency_(computer_science) +//! +//! ## Out-of-order execution +//! +//! Instructions can execute in a different order from the one we define, due to +//! various reasons: +//! +//! - The **compiler** reordering instructions: If the compiler can issue an +//! instruction at an earlier point, it will try to do so. For example, it +//! might hoist memory loads at the top of a code block, so that the CPU can +//! start [prefetching] the values from memory. +//! +//! In single-threaded scenarios, this can cause issues when writing +//! signal handlers or certain kinds of low-level code. +//! Use [compiler fences] to prevent this reordering. +//! +//! - A **single processor** executing instructions [out-of-order]: +//! Modern CPUs are capable of [superscalar] execution, +//! i.e. multiple instructions might be executing at the same time, +//! even though the machine code describes a sequential process. +//! +//! This kind of reordering is handled transparently by the CPU. +//! +//! - A **multiprocessor** system executing multiple hardware threads +//! at the same time: In multi-threaded scenarios, you can use two +//! kinds of primitives to deal with synchronization: +//! - [memory fences] to ensure memory accesses are made visible to +//! other CPUs in the right order. +//! - [atomic operations] to ensure simultaneous access to the same +//! memory location doesn't lead to undefined behavior. +//! +//! [prefetching]: https://en.wikipedia.org/wiki/Cache_prefetching +//! [compiler fences]: crate::sync::atomic::compiler_fence +//! [out-of-order]: https://en.wikipedia.org/wiki/Out-of-order_execution +//! [superscalar]: https://en.wikipedia.org/wiki/Superscalar_processor +//! [memory fences]: crate::sync::atomic::fence +//! [atomic operations]: crate::sync::atomic +//! +//! ## Higher-level synchronization objects +//! +//! Most of the low-level synchronization primitives are quite error-prone and +//! inconvenient to use, which is why the standard library also exposes some +//! higher-level synchronization objects. +//! +//! These abstractions can be built out of lower-level primitives. +//! For efficiency, the sync objects in the standard library are usually +//! implemented with help from the operating system's kernel, which is +//! able to reschedule the threads while they are blocked on acquiring +//! a lock. +//! +//! The following is an overview of the available synchronization +//! objects: +//! +//! - [`Arc`]: Atomically Reference-Counted pointer, which can be used +//! in multithreaded environments to prolong the lifetime of some +//! data until all the threads have finished using it. +//! +//! - [`Barrier`]: Ensures multiple threads will wait for each other +//! to reach a point in the program, before continuing execution all +//! together. +//! +//! - [`Condvar`]: Condition Variable, providing the ability to block +//! a thread while waiting for an event to occur. +//! +//! - [`mpsc`]: Multi-producer, single-consumer queues, used for +//! message-based communication. Can provide a lightweight +//! inter-thread synchronisation mechanism, at the cost of some +//! extra memory. +//! +//! - [`Mutex`]: Mutual Exclusion mechanism, which ensures that at +//! most one thread at a time is able to access some data. +//! +//! - [`Once`]: Used for thread-safe, one-time initialization of a +//! global variable. +//! +//! - [`RwLock`]: Provides a mutual exclusion mechanism which allows +//! multiple readers at the same time, while allowing only one +//! writer at a time. In some cases, this can be more efficient than +//! a mutex. +//! +//! [`Arc`]: crate::sync::Arc +//! [`Barrier`]: crate::sync::Barrier +//! [`Condvar`]: crate::sync::Condvar +//! [`mpsc`]: crate::sync::mpsc +//! [`Mutex`]: crate::sync::Mutex +//! [`Once`]: crate::sync::Once +//! [`RwLock`]: crate::sync::RwLock #![stable(feature = "rust1", since = "1.0.0")] diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/sync/once.rs rustc-1.31.0+dfsg1+llvm/src/libstd/sync/once.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/sync/once.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/sync/once.rs 2018-12-04 23:41:40.000000000 +0000 @@ -290,8 +290,8 @@ } /// Returns true if some `call_once` call has completed - /// successfuly. Specifically, `is_completed` will return false in - /// the following situtations: + /// successfully. Specifically, `is_completed` will return false in + /// the following situations: /// * `call_once` was not called at all, /// * `call_once` was called, but has not yet completed, /// * the `Once` instance is poisoned @@ -329,7 +329,8 @@ /// assert!(handle.join().is_err()); /// assert_eq!(INIT.is_completed(), false); /// ``` - #[unstable(feature = "once_is_completed", issue = "42")] + #[unstable(feature = "once_is_completed", issue = "54890")] + #[inline] pub fn is_completed(&self) -> bool { // An `Acquire` load is enough because that makes all the initialization // operations visible to us, and, this being a fast path, weaker diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/sys/redox/args.rs rustc-1.31.0+dfsg1+llvm/src/libstd/sys/redox/args.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/sys/redox/args.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/sys/redox/args.rs 2018-12-04 23:41:40.000000000 +0000 @@ -85,7 +85,7 @@ } pub fn args() -> Args { - let bytes = clone().unwrap_or(Vec::new()); + let bytes = clone().unwrap_or_default(); let v: Vec = bytes.into_iter().map(|v| { OsStringExt::from_vec(v) }).collect(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/sys/unix/os.rs rustc-1.31.0+dfsg1+llvm/src/libstd/sys/unix/os.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/sys/unix/os.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/sys/unix/os.rs 2018-12-04 23:41:40.000000000 +0000 @@ -27,15 +27,12 @@ use ptr; use slice; use str; -use sys_common::mutex::Mutex; +use sys_common::mutex::{Mutex, MutexGuard}; use sys::cvt; use sys::fd; use vec; const TMPBUF_SZ: usize = 128; -// We never call `ENV_LOCK.init()`, so it is UB to attempt to -// acquire this mutex reentrantly! -static ENV_LOCK: Mutex = Mutex::new(); extern { @@ -408,11 +405,18 @@ &mut environ } +pub unsafe fn env_lock() -> MutexGuard<'static> { + // We never call `ENV_LOCK.init()`, so it is UB to attempt to + // acquire this mutex reentrantly! + static ENV_LOCK: Mutex = Mutex::new(); + ENV_LOCK.lock() +} + /// Returns a vector of (variable, value) byte-vector pairs for all the /// environment variables of the current process. pub fn env() -> Env { unsafe { - let _guard = ENV_LOCK.lock(); + let _guard = env_lock(); let mut environ = *environ(); let mut result = Vec::new(); while environ != ptr::null() && *environ != ptr::null() { @@ -448,7 +452,7 @@ // always None as well let k = CString::new(k.as_bytes())?; unsafe { - let _guard = ENV_LOCK.lock(); + let _guard = env_lock(); let s = libc::getenv(k.as_ptr()) as *const libc::c_char; let ret = if s.is_null() { None @@ -464,7 +468,7 @@ let v = CString::new(v.as_bytes())?; unsafe { - let _guard = ENV_LOCK.lock(); + let _guard = env_lock(); cvt(libc::setenv(k.as_ptr(), v.as_ptr(), 1)).map(|_| ()) } } @@ -473,7 +477,7 @@ let nbuf = CString::new(n.as_bytes())?; unsafe { - let _guard = ENV_LOCK.lock(); + let _guard = env_lock(); cvt(libc::unsetenv(nbuf.as_ptr())).map(|_| ()) } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/sys/unix/process/process_unix.rs rustc-1.31.0+dfsg1+llvm/src/libstd/sys/unix/process/process_unix.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/sys/unix/process/process_unix.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/sys/unix/process/process_unix.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,9 +11,9 @@ use io::{self, Error, ErrorKind}; use libc::{self, c_int, gid_t, pid_t, uid_t}; use ptr; - use sys::cvt; use sys::process::process_common::*; +use sys; //////////////////////////////////////////////////////////////////////////////// // Command @@ -22,8 +22,6 @@ impl Command { pub fn spawn(&mut self, default: Stdio, needs_stdin: bool) -> io::Result<(Process, StdioPipes)> { - use sys; - const CLOEXEC_MSG_FOOTER: &'static [u8] = b"NOEX"; let envp = self.capture_env(); @@ -41,8 +39,21 @@ let (input, output) = sys::pipe::anon_pipe()?; + // Whatever happens after the fork is almost for sure going to touch or + // look at the environment in one way or another (PATH in `execvp` or + // accessing the `environ` pointer ourselves). Make sure no other thread + // is accessing the environment when we do the fork itself. + // + // Note that as soon as we're done with the fork there's no need to hold + // a lock any more because the parent won't do anything and the child is + // in its own process. + let result = unsafe { + let _env_lock = sys::os::env_lock(); + cvt(libc::fork())? + }; + let pid = unsafe { - match cvt(libc::fork())? { + match result { 0 => { drop(input); let err = self.do_exec(theirs, envp.as_ref()); @@ -114,7 +125,16 @@ } match self.setup_io(default, true) { - Ok((_, theirs)) => unsafe { self.do_exec(theirs, envp.as_ref()) }, + Ok((_, theirs)) => { + unsafe { + // Similar to when forking, we want to ensure that access to + // the environment is synchronized, so make sure to grab the + // environment lock before we try to exec. + let _lock = sys::os::env_lock(); + + self.do_exec(theirs, envp.as_ref()) + } + } Err(e) => e, } } @@ -193,9 +213,6 @@ if let Some(ref cwd) = *self.get_cwd() { t!(cvt(libc::chdir(cwd.as_ptr()))); } - if let Some(envp) = maybe_envp { - *sys::os::environ() = envp.as_ptr(); - } // emscripten has no signal support. #[cfg(not(any(target_os = "emscripten")))] @@ -231,6 +248,27 @@ t!(callback()); } + // Although we're performing an exec here we may also return with an + // error from this function (without actually exec'ing) in which case we + // want to be sure to restore the global environment back to what it + // once was, ensuring that our temporary override, when free'd, doesn't + // corrupt our process's environment. + let mut _reset = None; + if let Some(envp) = maybe_envp { + struct Reset(*const *const libc::c_char); + + impl Drop for Reset { + fn drop(&mut self) { + unsafe { + *sys::os::environ() = self.0; + } + } + } + + _reset = Some(Reset(*sys::os::environ())); + *sys::os::environ() = envp.as_ptr(); + } + libc::execvp(self.get_argv()[0], self.get_argv().as_ptr()); io::Error::last_os_error() } @@ -330,8 +368,10 @@ libc::POSIX_SPAWN_SETSIGMASK; cvt(libc::posix_spawnattr_setflags(&mut attrs.0, flags as _))?; + // Make sure we synchronize access to the global `environ` resource + let _env_lock = sys::os::env_lock(); let envp = envp.map(|c| c.as_ptr()) - .unwrap_or(*sys::os::environ() as *const _); + .unwrap_or_else(|| *sys::os::environ() as *const _); let ret = libc::posix_spawnp( &mut p.pid, self.get_argv()[0], diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/sys/wasm/cmath.rs rustc-1.31.0+dfsg1+llvm/src/libstd/sys/wasm/cmath.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/sys/wasm/cmath.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/sys/wasm/cmath.rs 2018-12-04 23:41:40.000000000 +0000 @@ -74,46 +74,19 @@ f64::tanh(n as f64) as f32 } -// Right now all these functions, the f64 version of the functions above, all -// shell out to random names. These names aren't actually defined anywhere, per -// se, but we need this to compile somehow. -// -// The idea with this is that when you're using wasm then, for now, we have no -// way of providing an implementation of these which delegates to a "correct" -// implementation. For example most wasm applications probably just want to -// delegate to the javascript `Math` object and its related functions, but wasm -// doesn't currently have the ability to seamlessly do that (when you -// instantiate a module you have to set that up). -// -// As a result these are just defined here with "hopefully helpful" names. The -// symbols won't ever be needed or show up unless these functions are called, -// and hopefully when they're called the errors are self-explanatory enough to -// figure out what's going on. - +// These symbols are all defined in `compiler-builtins` extern { - #[link_name = "Math_acos"] pub fn acos(n: f64) -> f64; - #[link_name = "Math_asin"] pub fn asin(n: f64) -> f64; - #[link_name = "Math_atan"] pub fn atan(n: f64) -> f64; - #[link_name = "Math_atan2"] pub fn atan2(a: f64, b: f64) -> f64; - #[link_name = "Math_cbrt"] pub fn cbrt(n: f64) -> f64; - #[link_name = "Math_cosh"] pub fn cosh(n: f64) -> f64; - #[link_name = "Math_expm1"] pub fn expm1(n: f64) -> f64; pub fn fdim(a: f64, b: f64) -> f64; - #[link_name = "Math_log1p"] pub fn log1p(n: f64) -> f64; - #[link_name = "Math_sinh"] pub fn sinh(n: f64) -> f64; - #[link_name = "Math_tan"] pub fn tan(n: f64) -> f64; - #[link_name = "Math_tanh"] pub fn tanh(n: f64) -> f64; - #[link_name = "Math_hypot"] pub fn hypot(x: f64, y: f64) -> f64; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/sys/wasm/condvar_atomics.rs rustc-1.31.0+dfsg1+llvm/src/libstd/sys/wasm/condvar_atomics.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/sys/wasm/condvar_atomics.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/sys/wasm/condvar_atomics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,104 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use arch::wasm32::atomic; +use cmp; +use mem; +use sync::atomic::{AtomicUsize, Ordering::SeqCst}; +use sys::mutex::Mutex; +use time::Duration; + +pub struct Condvar { + cnt: AtomicUsize, +} + +// Condition variables are implemented with a simple counter internally that is +// likely to cause spurious wakeups. Blocking on a condition variable will first +// read the value of the internal counter, unlock the given mutex, and then +// block if and only if the counter's value is still the same. Notifying a +// condition variable will modify the counter (add one for now) and then wake up +// a thread waiting on the address of the counter. +// +// A thread waiting on the condition variable will as a result avoid going to +// sleep if it's notified after the lock is unlocked but before it fully goes to +// sleep. A sleeping thread is guaranteed to be woken up at some point as it can +// only be woken up with a call to `wake`. +// +// Note that it's possible for 2 or more threads to be woken up by a call to +// `notify_one` with this implementation. That can happen where the modification +// of `cnt` causes any threads in the middle of `wait` to avoid going to sleep, +// and the subsequent `wake` may wake up a thread that's actually blocking. We +// consider this a spurious wakeup, though, which all users of condition +// variables must already be prepared to handle. As a result, this source of +// spurious wakeups is currently though to be ok, although it may be problematic +// later on if it causes too many spurious wakeups. + +impl Condvar { + pub const fn new() -> Condvar { + Condvar { cnt: AtomicUsize::new(0) } + } + + #[inline] + pub unsafe fn init(&mut self) { + // nothing to do + } + + pub unsafe fn notify_one(&self) { + self.cnt.fetch_add(1, SeqCst); + atomic::wake(self.ptr(), 1); + } + + #[inline] + pub unsafe fn notify_all(&self) { + self.cnt.fetch_add(1, SeqCst); + atomic::wake(self.ptr(), -1); // -1 == "wake everyone" + } + + pub unsafe fn wait(&self, mutex: &Mutex) { + // "atomically block and unlock" implemented by loading our current + // counter's value, unlocking the mutex, and blocking if the counter + // still has the same value. + // + // Notifications happen by incrementing the counter and then waking a + // thread. Incrementing the counter after we unlock the mutex will + // prevent us from sleeping and otherwise the call to `wake` will + // wake us up once we're asleep. + let ticket = self.cnt.load(SeqCst) as i32; + mutex.unlock(); + let val = atomic::wait_i32(self.ptr(), ticket, -1); + // 0 == woken, 1 == not equal to `ticket`, 2 == timeout (shouldn't happen) + debug_assert!(val == 0 || val == 1); + mutex.lock(); + } + + pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool { + let ticket = self.cnt.load(SeqCst) as i32; + mutex.unlock(); + let nanos = dur.as_nanos(); + let nanos = cmp::min(i64::max_value() as u128, nanos); + + // If the return value is 2 then a timeout happened, so we return + // `false` as we weren't actually notified. + let ret = atomic::wait_i32(self.ptr(), ticket, nanos as i64) != 2; + mutex.lock(); + return ret + } + + #[inline] + pub unsafe fn destroy(&self) { + // nothing to do + } + + #[inline] + fn ptr(&self) -> *mut i32 { + assert_eq!(mem::size_of::(), mem::size_of::()); + &self.cnt as *const AtomicUsize as *mut i32 + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/sys/wasm/mod.rs rustc-1.31.0+dfsg1+llvm/src/libstd/sys/wasm/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/sys/wasm/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/sys/wasm/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -36,24 +36,38 @@ #[cfg(feature = "backtrace")] pub mod backtrace; pub mod cmath; -pub mod condvar; pub mod env; pub mod fs; pub mod memchr; -pub mod mutex; pub mod net; pub mod os; pub mod os_str; pub mod path; pub mod pipe; pub mod process; -pub mod rwlock; pub mod stack_overflow; pub mod thread; -pub mod thread_local; pub mod time; pub mod stdio; +cfg_if! { + if #[cfg(target_feature = "atomics")] { + #[path = "condvar_atomics.rs"] + pub mod condvar; + #[path = "mutex_atomics.rs"] + pub mod mutex; + #[path = "rwlock_atomics.rs"] + pub mod rwlock; + #[path = "thread_local_atomics.rs"] + pub mod thread_local; + } else { + pub mod condvar; + pub mod mutex; + pub mod rwlock; + pub mod thread_local; + } +} + #[cfg(not(test))] pub fn init() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/sys/wasm/mutex_atomics.rs rustc-1.31.0+dfsg1+llvm/src/libstd/sys/wasm/mutex_atomics.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/sys/wasm/mutex_atomics.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/sys/wasm/mutex_atomics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,160 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use arch::wasm32::atomic; +use cell::UnsafeCell; +use mem; +use sync::atomic::{AtomicUsize, AtomicU32, Ordering::SeqCst}; +use sys::thread; + +pub struct Mutex { + locked: AtomicUsize, +} + +// Mutexes have a pretty simple implementation where they contain an `i32` +// internally that is 0 when unlocked and 1 when the mutex is locked. +// Acquisition has a fast path where it attempts to cmpxchg the 0 to a 1, and +// if it fails it then waits for a notification. Releasing a lock is then done +// by swapping in 0 and then notifying any waiters, if present. + +impl Mutex { + pub const fn new() -> Mutex { + Mutex { locked: AtomicUsize::new(0) } + } + + #[inline] + pub unsafe fn init(&mut self) { + // nothing to do + } + + pub unsafe fn lock(&self) { + while !self.try_lock() { + let val = atomic::wait_i32( + self.ptr(), + 1, // we expect our mutex is locked + -1, // wait infinitely + ); + // we should have either woke up (0) or got a not-equal due to a + // race (1). We should never time out (2) + debug_assert!(val == 0 || val == 1); + } + } + + pub unsafe fn unlock(&self) { + let prev = self.locked.swap(0, SeqCst); + debug_assert_eq!(prev, 1); + atomic::wake(self.ptr(), 1); // wake up one waiter, if any + } + + #[inline] + pub unsafe fn try_lock(&self) -> bool { + self.locked.compare_exchange(0, 1, SeqCst, SeqCst).is_ok() + } + + #[inline] + pub unsafe fn destroy(&self) { + // nothing to do + } + + #[inline] + fn ptr(&self) -> *mut i32 { + assert_eq!(mem::size_of::(), mem::size_of::()); + &self.locked as *const AtomicUsize as *mut isize as *mut i32 + } +} + +pub struct ReentrantMutex { + owner: AtomicU32, + recursions: UnsafeCell, +} + +unsafe impl Send for ReentrantMutex {} +unsafe impl Sync for ReentrantMutex {} + +// Reentrant mutexes are similarly implemented to mutexs above except that +// instead of "1" meaning unlocked we use the id of a thread to represent +// whether it has locked a mutex. That way we have an atomic counter which +// always holds the id of the thread that currently holds the lock (or 0 if the +// lock is unlocked). +// +// Once a thread acquires a lock recursively, which it detects by looking at +// the value that's already there, it will update a local `recursions` counter +// in a nonatomic fashion (as we hold the lock). The lock is then fully +// released when this recursion counter reaches 0. + +impl ReentrantMutex { + pub unsafe fn uninitialized() -> ReentrantMutex { + ReentrantMutex { + owner: AtomicU32::new(0), + recursions: UnsafeCell::new(0), + } + } + + pub unsafe fn init(&mut self) { + // nothing to do... + } + + pub unsafe fn lock(&self) { + let me = thread::my_id(); + while let Err(owner) = self._try_lock(me) { + let val = atomic::wait_i32(self.ptr(), owner as i32, -1); + debug_assert!(val == 0 || val == 1); + } + } + + #[inline] + pub unsafe fn try_lock(&self) -> bool { + self._try_lock(thread::my_id()).is_ok() + } + + #[inline] + unsafe fn _try_lock(&self, id: u32) -> Result<(), u32> { + let id = id.checked_add(1).unwrap(); // make sure `id` isn't 0 + match self.owner.compare_exchange(0, id, SeqCst, SeqCst) { + // we transitioned from unlocked to locked + Ok(_) => { + debug_assert_eq!(*self.recursions.get(), 0); + Ok(()) + } + + // we currently own this lock, so let's update our count and return + // true. + Err(n) if n == id => { + *self.recursions.get() += 1; + Ok(()) + } + + // Someone else owns the lock, let our caller take care of it + Err(other) => Err(other), + } + } + + pub unsafe fn unlock(&self) { + // If we didn't ever recursively lock the lock then we fully unlock the + // mutex and wake up a waiter, if any. Otherwise we decrement our + // recursive counter and let some one else take care of the zero. + match *self.recursions.get() { + 0 => { + self.owner.swap(0, SeqCst); + atomic::wake(self.ptr() as *mut i32, 1); // wake up one waiter, if any + } + ref mut n => *n -= 1, + } + } + + pub unsafe fn destroy(&self) { + // nothing to do... + } + + #[inline] + fn ptr(&self) -> *mut i32 { + &self.owner as *const AtomicU32 as *mut i32 + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/sys/wasm/rwlock_atomics.rs rustc-1.31.0+dfsg1+llvm/src/libstd/sys/wasm/rwlock_atomics.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/sys/wasm/rwlock_atomics.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/sys/wasm/rwlock_atomics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,161 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use cell::UnsafeCell; +use sys::mutex::Mutex; +use sys::condvar::Condvar; + +pub struct RWLock { + lock: Mutex, + cond: Condvar, + state: UnsafeCell, +} + +enum State { + Unlocked, + Reading(usize), + Writing, +} + +unsafe impl Send for RWLock {} +unsafe impl Sync for RWLock {} + +// This rwlock implementation is a relatively simple implementation which has a +// condition variable for readers/writers as well as a mutex protecting the +// internal state of the lock. A current downside of the implementation is that +// unlocking the lock will notify *all* waiters rather than just readers or just +// writers. This can cause lots of "thundering stampede" problems. While +// hopefully correct this implementation is very likely to want to be changed in +// the future. + +impl RWLock { + pub const fn new() -> RWLock { + RWLock { + lock: Mutex::new(), + cond: Condvar::new(), + state: UnsafeCell::new(State::Unlocked), + } + } + + #[inline] + pub unsafe fn read(&self) { + self.lock.lock(); + while !(*self.state.get()).inc_readers() { + self.cond.wait(&self.lock); + } + self.lock.unlock(); + } + + #[inline] + pub unsafe fn try_read(&self) -> bool { + self.lock.lock(); + let ok = (*self.state.get()).inc_readers(); + self.lock.unlock(); + return ok + } + + #[inline] + pub unsafe fn write(&self) { + self.lock.lock(); + while !(*self.state.get()).inc_writers() { + self.cond.wait(&self.lock); + } + self.lock.unlock(); + } + + #[inline] + pub unsafe fn try_write(&self) -> bool { + self.lock.lock(); + let ok = (*self.state.get()).inc_writers(); + self.lock.unlock(); + return ok + } + + #[inline] + pub unsafe fn read_unlock(&self) { + self.lock.lock(); + let notify = (*self.state.get()).dec_readers(); + self.lock.unlock(); + if notify { + // FIXME: should only wake up one of these some of the time + self.cond.notify_all(); + } + } + + #[inline] + pub unsafe fn write_unlock(&self) { + self.lock.lock(); + (*self.state.get()).dec_writers(); + self.lock.unlock(); + // FIXME: should only wake up one of these some of the time + self.cond.notify_all(); + } + + #[inline] + pub unsafe fn destroy(&self) { + self.lock.destroy(); + self.cond.destroy(); + } +} + +impl State { + fn inc_readers(&mut self) -> bool { + match *self { + State::Unlocked => { + *self = State::Reading(1); + true + } + State::Reading(ref mut cnt) => { + *cnt += 1; + true + } + State::Writing => false + } + } + + fn inc_writers(&mut self) -> bool { + match *self { + State::Unlocked => { + *self = State::Writing; + true + } + State::Reading(_) | + State::Writing => false + } + } + + fn dec_readers(&mut self) -> bool { + let zero = match *self { + State::Reading(ref mut cnt) => { + *cnt -= 1; + *cnt == 0 + } + State::Unlocked | + State::Writing => invalid(), + }; + if zero { + *self = State::Unlocked; + } + zero + } + + fn dec_writers(&mut self) { + match *self { + State::Writing => {} + State::Unlocked | + State::Reading(_) => invalid(), + } + *self = State::Unlocked; + } +} + +fn invalid() -> ! { + panic!("inconsistent rwlock"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/sys/wasm/thread_local_atomics.rs rustc-1.31.0+dfsg1+llvm/src/libstd/sys/wasm/thread_local_atomics.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/sys/wasm/thread_local_atomics.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/sys/wasm/thread_local_atomics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,71 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use sys::thread; +use sync::atomic::{AtomicUsize, Ordering::SeqCst}; + +const MAX_KEYS: usize = 128; +static NEXT_KEY: AtomicUsize = AtomicUsize::new(0); + +struct ThreadControlBlock { + keys: [*mut u8; MAX_KEYS], +} + +impl ThreadControlBlock { + fn new() -> ThreadControlBlock { + ThreadControlBlock { + keys: [0 as *mut u8; MAX_KEYS], + } + } + + fn get() -> *mut ThreadControlBlock { + let ptr = thread::tcb_get(); + if !ptr.is_null() { + return ptr as *mut ThreadControlBlock + } + let tcb = Box::into_raw(Box::new(ThreadControlBlock::new())); + thread::tcb_set(tcb as *mut u8); + tcb + } +} + +pub type Key = usize; + +pub unsafe fn create(dtor: Option) -> Key { + drop(dtor); // FIXME: need to figure out how to hook thread exit to run this + let key = NEXT_KEY.fetch_add(1, SeqCst); + if key >= MAX_KEYS { + NEXT_KEY.store(MAX_KEYS, SeqCst); + panic!("cannot allocate space for more TLS keys"); + } + // offset by 1 so we never hand out 0. This is currently required by + // `sys_common/thread_local.rs` where it can't cope with keys of value 0 + // because it messes up the atomic management. + return key + 1 +} + +pub unsafe fn set(key: Key, value: *mut u8) { + (*ThreadControlBlock::get()).keys[key - 1] = value; +} + +pub unsafe fn get(key: Key) -> *mut u8 { + (*ThreadControlBlock::get()).keys[key - 1] +} + +pub unsafe fn destroy(_key: Key) { + // FIXME: should implement this somehow, this isn't typically called but it + // can be called if two threads race to initialize a TLS slot and one ends + // up not being needed. +} + +#[inline] +pub fn requires_synchronized_create() -> bool { + false +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/sys/wasm/thread.rs rustc-1.31.0+dfsg1+llvm/src/libstd/sys/wasm/thread.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/sys/wasm/thread.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/sys/wasm/thread.rs 2018-12-04 23:41:40.000000000 +0000 @@ -33,10 +33,31 @@ // nope } + #[cfg(not(target_feature = "atomics"))] pub fn sleep(_dur: Duration) { panic!("can't sleep"); } + #[cfg(target_feature = "atomics")] + pub fn sleep(dur: Duration) { + use arch::wasm32::atomic; + use cmp; + + // Use an atomic wait to block the current thread artificially with a + // timeout listed. Note that we should never be notified (return value + // of 0) or our comparison should never fail (return value of 1) so we + // should always only resume execution through a timeout (return value + // 2). + let mut nanos = dur.as_nanos(); + while nanos > 0 { + let amt = cmp::min(i64::max_value() as u128, nanos); + let mut x = 0; + let val = unsafe { atomic::wait_i32(&mut x, 0, amt as i64) }; + debug_assert_eq!(val, 2); + nanos -= amt; + } + } + pub fn join(self) { match self.0 {} } @@ -48,3 +69,49 @@ pub unsafe fn init() -> Option { None } pub unsafe fn deinit() {} } + +cfg_if! { + if #[cfg(all(target_feature = "atomics", feature = "wasm-bindgen-threads"))] { + #[link(wasm_import_module = "__wbindgen_thread_xform__")] + extern { + fn __wbindgen_current_id() -> u32; + fn __wbindgen_tcb_get() -> u32; + fn __wbindgen_tcb_set(ptr: u32); + } + pub fn my_id() -> u32 { + unsafe { __wbindgen_current_id() } + } + + // These are currently only ever used in `thread_local_atomics.rs`, if + // you'd like to use them be sure to update that and make sure everyone + // agrees what's what. + pub fn tcb_get() -> *mut u8 { + use mem; + assert_eq!(mem::size_of::<*mut u8>(), mem::size_of::()); + unsafe { __wbindgen_tcb_get() as *mut u8 } + } + + pub fn tcb_set(ptr: *mut u8) { + unsafe { __wbindgen_tcb_set(ptr as u32); } + } + + // FIXME: still need something for hooking exiting a thread to free + // data... + + } else if #[cfg(target_feature = "atomics")] { + pub fn my_id() -> u32 { + panic!("thread ids not implemented on wasm with atomics yet") + } + + pub fn tcb_get() -> *mut u8 { + panic!("thread local data not implemented on wasm with atomics yet") + } + + pub fn tcb_set(ptr: *mut u8) { + panic!("thread local data not implemented on wasm with atomics yet") + } + } else { + // stubbed out because no functions actually access these intrinsics + // unless atomics are enabled + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/thread/local.rs rustc-1.31.0+dfsg1+llvm/src/libstd/thread/local.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/thread/local.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/thread/local.rs 2018-12-04 23:41:40.000000000 +0000 @@ -172,16 +172,22 @@ &'static $crate::cell::UnsafeCell< $crate::option::Option<$t>>> { - #[cfg(target_arch = "wasm32")] + #[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))] static __KEY: $crate::thread::__StaticLocalKeyInner<$t> = $crate::thread::__StaticLocalKeyInner::new(); #[thread_local] - #[cfg(all(target_thread_local, not(target_arch = "wasm32")))] + #[cfg(all( + target_thread_local, + not(all(target_arch = "wasm32", not(target_feature = "atomics"))), + ))] static __KEY: $crate::thread::__FastLocalKeyInner<$t> = $crate::thread::__FastLocalKeyInner::new(); - #[cfg(all(not(target_thread_local), not(target_arch = "wasm32")))] + #[cfg(all( + not(target_thread_local), + not(all(target_arch = "wasm32", not(target_feature = "atomics"))), + ))] static __KEY: $crate::thread::__OsLocalKeyInner<$t> = $crate::thread::__OsLocalKeyInner::new(); @@ -302,7 +308,7 @@ /// On some platforms like wasm32 there's no threads, so no need to generate /// thread locals and we can instead just use plain statics! #[doc(hidden)] -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))] pub mod statik { use cell::UnsafeCell; use fmt; diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/thread/mod.rs rustc-1.31.0+dfsg1+llvm/src/libstd/thread/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/thread/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/thread/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -203,7 +203,7 @@ // where available, but both are needed. #[unstable(feature = "libstd_thread_internals", issue = "0")] -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))] #[doc(hidden)] pub use self::local::statik::Key as __StaticLocalKeyInner; #[unstable(feature = "libstd_thread_internals", issue = "0")] #[cfg(target_thread_local)] @@ -576,7 +576,7 @@ /// Thus the pattern of `yield`ing after a failed poll is rather common when /// implementing low-level shared resources or synchronization primitives. /// -/// However programmers will usually prefer to use, [`channel`]s, [`Condvar`]s, +/// However programmers will usually prefer to use [`channel`]s, [`Condvar`]s, /// [`Mutex`]es or [`join`] for their synchronization routines, as they avoid /// thinking about thread scheduling. /// @@ -650,15 +650,17 @@ panicking::panicking() } -/// Puts the current thread to sleep for the specified amount of time. +/// Puts the current thread to sleep for at least the specified amount of time. /// /// The thread may sleep longer than the duration specified due to scheduling -/// specifics or platform-dependent functionality. +/// specifics or platform-dependent functionality. It will never sleep less. /// /// # Platform-specific behavior /// -/// On Unix platforms this function will not return early due to a -/// signal being received or a spurious wakeup. +/// On Unix platforms, the underlying syscall may be interrupted by a +/// spurious wakeup or signal handler. To ensure the sleep occurs for at least +/// the specified duration, this function may invoke that system call multiple +/// times. /// /// # Examples /// @@ -674,17 +676,19 @@ sleep(Duration::from_millis(ms as u64)) } -/// Puts the current thread to sleep for the specified amount of time. +/// Puts the current thread to sleep for at least the specified amount of time. /// /// The thread may sleep longer than the duration specified due to scheduling -/// specifics or platform-dependent functionality. +/// specifics or platform-dependent functionality. It will never sleep less. /// /// # Platform-specific behavior /// -/// On Unix platforms this function will not return early due to a -/// signal being received or a spurious wakeup. Platforms which do not support -/// nanosecond precision for sleeping will have `dur` rounded up to the nearest -/// granularity of time they can sleep for. +/// On Unix platforms, the underlying syscall may be interrupted by a +/// spurious wakeup or signal handler. To ensure the sleep occurs for at least +/// the specified duration, this function may invoke that system call multiple +/// times. +/// Platforms which do not support nanosecond precision for sleeping will +/// have `dur` rounded up to the nearest granularity of time they can sleep for. /// /// # Examples /// @@ -800,7 +804,14 @@ match thread.inner.state.compare_exchange(EMPTY, PARKED, SeqCst, SeqCst) { Ok(_) => {} Err(NOTIFIED) => { - thread.inner.state.store(EMPTY, SeqCst); + // We must read here, even though we know it will be `NOTIFIED`. + // This is because `unpark` may have been called again since we read + // `NOTIFIED` in the `compare_exchange` above. We must perform an + // acquire operation that synchronizes with that `unpark` to observe + // any writes it made before the call to unpark. To do that we must + // read from the write it made to `state`. + let old = thread.inner.state.swap(EMPTY, SeqCst); + assert_eq!(old, NOTIFIED, "park state changed unexpectedly"); return; } // should consume this notification, so prohibit spurious wakeups in next park. Err(_) => panic!("inconsistent park state"), @@ -889,7 +900,9 @@ match thread.inner.state.compare_exchange(EMPTY, PARKED, SeqCst, SeqCst) { Ok(_) => {} Err(NOTIFIED) => { - thread.inner.state.store(EMPTY, SeqCst); + // We must read again here, see `park`. + let old = thread.inner.state.swap(EMPTY, SeqCst); + assert_eq!(old, NOTIFIED, "park state changed unexpectedly"); return; } // should consume this notification, so prohibit spurious wakeups in next park. Err(_) => panic!("inconsistent park_timeout state"), @@ -1058,23 +1071,22 @@ /// [park]: fn.park.html #[stable(feature = "rust1", since = "1.0.0")] pub fn unpark(&self) { - loop { - match self.inner.state.compare_exchange(EMPTY, NOTIFIED, SeqCst, SeqCst) { - Ok(_) => return, // no one was waiting - Err(NOTIFIED) => return, // already unparked - Err(PARKED) => {} // gotta go wake someone up - _ => panic!("inconsistent state in unpark"), - } - - // Coordinate wakeup through the mutex and a condvar notification - let _lock = self.inner.lock.lock().unwrap(); - match self.inner.state.compare_exchange(PARKED, NOTIFIED, SeqCst, SeqCst) { - Ok(_) => return self.inner.cvar.notify_one(), - Err(NOTIFIED) => return, // a different thread unparked - Err(EMPTY) => {} // parked thread went away, try again - _ => panic!("inconsistent state in unpark"), - } + // To ensure the unparked thread will observe any writes we made + // before this call, we must perform a release operation that `park` + // can synchronize with. To do that we must write `NOTIFIED` even if + // `state` is already `NOTIFIED`. That is why this must be a swap + // rather than a compare-and-swap that returns if it reads `NOTIFIED` + // on failure. + match self.inner.state.swap(NOTIFIED, SeqCst) { + EMPTY => return, // no one was waiting + NOTIFIED => return, // already unparked + PARKED => {} // gotta go wake someone up + _ => panic!("inconsistent state in unpark"), } + + // Coordinate wakeup through the mutex and a condvar notification + let _lock = self.inner.lock.lock().unwrap(); + self.inner.cvar.notify_one() } /// Gets the thread's unique identifier. diff -Nru rustc-1.30.0+dfsg1+llvm/src/libstd/time.rs rustc-1.31.0+dfsg1+llvm/src/libstd/time.rs --- rustc-1.30.0+dfsg1+llvm/src/libstd/time.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libstd/time.rs 2018-12-04 23:41:40.000000000 +0000 @@ -481,7 +481,8 @@ let (a, b) = ($a, $b); if a != b { let (a, b) = if a > b {(a, b)} else {(b, a)}; - assert!(a - Duration::new(0, 100) <= b); + assert!(a - Duration::new(0, 1000) <= b, + "{:?} is not almost equal to {:?}", a, b); } }) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/ast.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/ast.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/ast.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/ast.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,27 +10,27 @@ // The Rust abstract syntax tree. -pub use self::UnsafeSource::*; pub use self::GenericArgs::*; +pub use self::UnsafeSource::*; pub use symbol::{Ident, Symbol as Name}; pub use util::parser::ExprPrecedence; -use syntax_pos::{Span, DUMMY_SP}; -use source_map::{dummy_spanned, respan, Spanned}; -use rustc_target::spec::abi::Abi; use ext::hygiene::{Mark, SyntaxContext}; use print::pprust; use ptr::P; use rustc_data_structures::indexed_vec; use rustc_data_structures::indexed_vec::Idx; -use symbol::{Symbol, keywords}; -use ThinVec; +use rustc_target::spec::abi::Abi; +use source_map::{dummy_spanned, respan, Spanned}; +use symbol::{keywords, Symbol}; +use syntax_pos::{Span, DUMMY_SP}; use tokenstream::{ThinTokenStream, TokenStream}; +use ThinVec; -use serialize::{self, Encoder, Decoder}; -use std::fmt; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::sync::Lrc; +use serialize::{self, Decoder, Encoder}; +use std::fmt; use std::u32; pub use rustc_target::abi::FloatTy; @@ -54,7 +54,12 @@ impl fmt::Debug for Lifetime { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "lifetime({}: {})", self.id, pprust::lifetime_to_string(self)) + write!( + f, + "lifetime({}: {})", + self.id, + pprust::lifetime_to_string(self) + ) } } @@ -94,7 +99,10 @@ // convert a span and an identifier to the corresponding // 1-segment path pub fn from_ident(ident: Ident) -> Path { - Path { segments: vec![PathSegment::from_ident(ident)], span: ident.span } + Path { + segments: vec![PathSegment::from_ident(ident)], + span: ident.span, + } } // Make a "crate root" segment for this path unless it already has it @@ -121,6 +129,8 @@ /// The identifier portion of this path segment. pub ident: Ident, + pub id: NodeId, + /// Type/lifetime parameters attached to this path. They come in /// two flavors: `Path` and `Path(A,B) -> C`. /// `None` means that no parameter list is supplied (`Path`), @@ -132,7 +142,7 @@ impl PathSegment { pub fn from_ident(ident: Ident) -> Self { - PathSegment { ident, args: None } + PathSegment { ident, id: DUMMY_NODE_ID, args: None } } pub fn crate_root(span: Span) -> Self { PathSegment::from_ident(Ident::new(keywords::CrateRoot.name(), span)) @@ -284,7 +294,7 @@ #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub enum GenericBound { Trait(PolyTraitRef, TraitBoundModifier), - Outlives(Lifetime) + Outlives(Lifetime), } impl GenericBound { @@ -304,7 +314,7 @@ Lifetime, Type { default: Option>, - } + }, } #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] @@ -328,7 +338,7 @@ impl Default for Generics { /// Creates an instance of `Generics`. - fn default() -> Generics { + fn default() -> Generics { Generics { params: Vec::new(), where_clause: WhereClause { @@ -458,7 +468,7 @@ /// Name value meta item. /// /// E.g. `feature = "foo"` as in `#[feature = "foo"]` - NameValue(Lit) + NameValue(Lit), } /// A Block (`{ .. }`). @@ -492,14 +502,17 @@ pub(super) fn to_ty(&self) -> Option> { let node = match &self.node { PatKind::Wild => TyKind::Infer, - PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), ident, None) => - TyKind::Path(None, Path::from_ident(*ident)), + PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), ident, None) => { + TyKind::Path(None, Path::from_ident(*ident)) + } PatKind::Path(qself, path) => TyKind::Path(qself.clone(), path.clone()), PatKind::Mac(mac) => TyKind::Mac(mac.clone()), - PatKind::Ref(pat, mutbl) => - pat.to_ty().map(|ty| TyKind::Rptr(None, MutTy { ty, mutbl: *mutbl }))?, - PatKind::Slice(pats, None, _) if pats.len() == 1 => - pats[0].to_ty().map(TyKind::Slice)?, + PatKind::Ref(pat, mutbl) => pat + .to_ty() + .map(|ty| TyKind::Rptr(None, MutTy { ty, mutbl: *mutbl }))?, + PatKind::Slice(pats, None, _) if pats.len() == 1 => { + pats[0].to_ty().map(TyKind::Slice)? + } PatKind::Tuple(pats, None) => { let mut tys = Vec::with_capacity(pats.len()); // FIXME(#48994) - could just be collected into an Option @@ -511,11 +524,16 @@ _ => return None, }; - Some(P(Ty { node, id: self.id, span: self.span })) + Some(P(Ty { + node, + id: self.id, + span: self.span, + })) } pub fn walk(&self, it: &mut F) -> bool - where F: FnMut(&Pat) -> bool + where + F: FnMut(&Pat) -> bool, { if !it(self) { return false; @@ -523,28 +541,22 @@ match self.node { PatKind::Ident(_, _, Some(ref p)) => p.walk(it), - PatKind::Struct(_, ref fields, _) => { - fields.iter().all(|field| field.node.pat.walk(it)) - } + PatKind::Struct(_, ref fields, _) => fields.iter().all(|field| field.node.pat.walk(it)), PatKind::TupleStruct(_, ref s, _) | PatKind::Tuple(ref s, _) => { s.iter().all(|p| p.walk(it)) } - PatKind::Box(ref s) | PatKind::Ref(ref s, _) | PatKind::Paren(ref s) => { - s.walk(it) - } + PatKind::Box(ref s) | PatKind::Ref(ref s, _) | PatKind::Paren(ref s) => s.walk(it), PatKind::Slice(ref before, ref slice, ref after) => { - before.iter().all(|p| p.walk(it)) && - slice.iter().all(|p| p.walk(it)) && - after.iter().all(|p| p.walk(it)) - } - PatKind::Wild | - PatKind::Lit(_) | - PatKind::Range(..) | - PatKind::Ident(..) | - PatKind::Path(..) | - PatKind::Mac(_) => { - true + before.iter().all(|p| p.walk(it)) + && slice.iter().all(|p| p.walk(it)) + && after.iter().all(|p| p.walk(it)) } + PatKind::Wild + | PatKind::Lit(_) + | PatKind::Range(..) + | PatKind::Ident(..) + | PatKind::Path(..) + | PatKind::Mac(_) => true, } } } @@ -623,13 +635,15 @@ /// `[a, b, ..i, y, z]` is represented as: /// `PatKind::Slice(box [a, b], Some(i), box [y, z])` Slice(Vec>, Option>, Vec>), - /// Parentheses in patters used for grouping, i.e. `(PAT)`. + /// Parentheses in patterns used for grouping, i.e. `(PAT)`. Paren(P), /// A macro pattern; pre-expansion Mac(Mac), } -#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Debug, Copy)] +#[derive( + Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Debug, Copy, +)] pub enum Mutability { Mutable, Immutable, @@ -702,25 +716,22 @@ pub fn lazy(&self) -> bool { match *self { BinOpKind::And | BinOpKind::Or => true, - _ => false + _ => false, } } pub fn is_shift(&self) -> bool { match *self { BinOpKind::Shl | BinOpKind::Shr => true, - _ => false + _ => false, } } pub fn is_comparison(&self) -> bool { use self::BinOpKind::*; match *self { - Eq | Lt | Le | Ne | Gt | Ge => - true, - And | Or | Add | Sub | Mul | Div | Rem | - BitXor | BitAnd | BitOr | Shl | Shr => - false, + Eq | Lt | Le | Ne | Gt | Ge => true, + And | Or | Add | Sub | Mul | Div | Rem | BitXor | BitAnd | BitOr | Shl | Shr => false, } } @@ -772,9 +783,9 @@ pub fn add_trailing_semicolon(mut self) -> Self { self.node = match self.node { StmtKind::Expr(expr) => StmtKind::Semi(expr), - StmtKind::Mac(mac) => StmtKind::Mac(mac.map(|(mac, _style, attrs)| { - (mac, MacStmtStyle::Semicolon, attrs) - })), + StmtKind::Mac(mac) => { + StmtKind::Mac(mac.map(|(mac, _style, attrs)| (mac, MacStmtStyle::Semicolon, attrs))) + } node => node, }; self @@ -797,11 +808,15 @@ impl fmt::Debug for Stmt { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "stmt({}: {})", self.id.to_string(), pprust::stmt_to_string(self)) + write!( + f, + "stmt({}: {})", + self.id.to_string(), + pprust::stmt_to_string(self) + ) } } - #[derive(Clone, RustcEncodable, RustcDecodable)] pub enum StmtKind { /// A local (let) binding. @@ -900,14 +915,13 @@ pub value: P, } - /// An expression #[derive(Clone, RustcEncodable, RustcDecodable)] pub struct Expr { pub id: NodeId, pub node: ExprKind, pub span: Span, - pub attrs: ThinVec + pub attrs: ThinVec, } impl Expr { @@ -937,9 +951,10 @@ fn to_bound(&self) -> Option { match &self.node { - ExprKind::Path(None, path) => - Some(GenericBound::Trait(PolyTraitRef::new(Vec::new(), path.clone(), self.span), - TraitBoundModifier::None)), + ExprKind::Path(None, path) => Some(GenericBound::Trait( + PolyTraitRef::new(Vec::new(), path.clone(), self.span), + TraitBoundModifier::None, + )), _ => None, } } @@ -949,26 +964,35 @@ ExprKind::Path(qself, path) => TyKind::Path(qself.clone(), path.clone()), ExprKind::Mac(mac) => TyKind::Mac(mac.clone()), ExprKind::Paren(expr) => expr.to_ty().map(TyKind::Paren)?, - ExprKind::AddrOf(mutbl, expr) => - expr.to_ty().map(|ty| TyKind::Rptr(None, MutTy { ty, mutbl: *mutbl }))?, - ExprKind::Repeat(expr, expr_len) => - expr.to_ty().map(|ty| TyKind::Array(ty, expr_len.clone()))?, - ExprKind::Array(exprs) if exprs.len() == 1 => - exprs[0].to_ty().map(TyKind::Slice)?, + ExprKind::AddrOf(mutbl, expr) => expr + .to_ty() + .map(|ty| TyKind::Rptr(None, MutTy { ty, mutbl: *mutbl }))?, + ExprKind::Repeat(expr, expr_len) => { + expr.to_ty().map(|ty| TyKind::Array(ty, expr_len.clone()))? + } + ExprKind::Array(exprs) if exprs.len() == 1 => exprs[0].to_ty().map(TyKind::Slice)?, ExprKind::Tup(exprs) => { - let tys = exprs.iter().map(|expr| expr.to_ty()).collect::>>()?; + let tys = exprs + .iter() + .map(|expr| expr.to_ty()) + .collect::>>()?; TyKind::Tup(tys) } - ExprKind::Binary(binop, lhs, rhs) if binop.node == BinOpKind::Add => + ExprKind::Binary(binop, lhs, rhs) if binop.node == BinOpKind::Add => { if let (Some(lhs), Some(rhs)) = (lhs.to_bound(), rhs.to_bound()) { TyKind::TraitObject(vec![lhs, rhs], TraitObjectSyntax::None) } else { return None; } + } _ => return None, }; - Some(P(Ty { node, id: self.id, span: self.span })) + Some(P(Ty { + node, + id: self.id, + span: self.span, + })) } pub fn precedence(&self) -> ExprPrecedence { @@ -1195,7 +1219,7 @@ /// a::b::Trait>::AssociatedItem`; in the case where `position == /// 0`, this is an empty span. pub path_span: Span, - pub position: usize + pub position: usize, } /// A capture clause @@ -1259,7 +1283,7 @@ /// A raw string, like `r##"foo"##` /// /// The value is the number of `#` symbols used. - Raw(u16) + Raw(u16), } /// A literal @@ -1307,9 +1331,7 @@ /// Returns true if this is a numeric literal. pub fn is_numeric(&self) -> bool { match *self { - LitKind::Int(..) | - LitKind::Float(..) | - LitKind::FloatUnsuffixed(..) => true, + LitKind::Int(..) | LitKind::Float(..) | LitKind::FloatUnsuffixed(..) => true, _ => false, } } @@ -1319,17 +1341,17 @@ pub fn is_unsuffixed(&self) -> bool { match *self { // unsuffixed variants - LitKind::Str(..) | - LitKind::ByteStr(..) | - LitKind::Byte(..) | - LitKind::Char(..) | - LitKind::Int(_, LitIntType::Unsuffixed) | - LitKind::FloatUnsuffixed(..) | - LitKind::Bool(..) => true, + LitKind::Str(..) + | LitKind::ByteStr(..) + | LitKind::Byte(..) + | LitKind::Char(..) + | LitKind::Int(_, LitIntType::Unsuffixed) + | LitKind::FloatUnsuffixed(..) + | LitKind::Bool(..) => true, // suffixed variants - LitKind::Int(_, LitIntType::Signed(..)) | - LitKind::Int(_, LitIntType::Unsigned(..)) | - LitKind::Float(..) => false, + LitKind::Int(_, LitIntType::Signed(..)) + | LitKind::Int(_, LitIntType::Unsigned(..)) + | LitKind::Float(..) => false, } } @@ -1532,7 +1554,7 @@ pub unsafety: Unsafety, pub abi: Abi, pub generic_params: Vec, - pub decl: P + pub decl: P, } /// The different kinds of types recognized by the compiler @@ -1551,7 +1573,7 @@ /// The never type (`!`) Never, /// A tuple (`(A, B, C, D,...)`) - Tup(Vec> ), + Tup(Vec>), /// A path (`module::module::...::Type`), optionally /// "qualified", e.g. ` as SomeTrait>::SomeType`. /// @@ -1584,11 +1606,19 @@ impl TyKind { pub fn is_implicit_self(&self) -> bool { - if let TyKind::ImplicitSelf = *self { true } else { false } + if let TyKind::ImplicitSelf = *self { + true + } else { + false + } } pub fn is_unit(&self) -> bool { - if let TyKind::Tup(ref tys) = *self { tys.is_empty() } else { false } + if let TyKind::Tup(ref tys) = *self { + tys.is_empty() + } else { + false + } } } @@ -1666,12 +1696,14 @@ if ident.name == keywords::SelfValue.name() { return match self.ty.node { TyKind::ImplicitSelf => Some(respan(self.pat.span, SelfKind::Value(mutbl))), - TyKind::Rptr(lt, MutTy{ref ty, mutbl}) if ty.node.is_implicit_self() => { + TyKind::Rptr(lt, MutTy { ref ty, mutbl }) if ty.node.is_implicit_self() => { Some(respan(self.pat.span, SelfKind::Region(lt, mutbl))) } - _ => Some(respan(self.pat.span.to(self.ty.span), - SelfKind::Explicit(self.ty.clone(), mutbl))), - } + _ => Some(respan( + self.pat.span.to(self.ty.span), + SelfKind::Explicit(self.ty.clone(), mutbl), + )), + }; } } None @@ -1704,11 +1736,20 @@ match eself.node { SelfKind::Explicit(ty, mutbl) => arg(mutbl, ty), SelfKind::Value(mutbl) => arg(mutbl, infer_ty), - SelfKind::Region(lt, mutbl) => arg(Mutability::Immutable, P(Ty { - id: DUMMY_NODE_ID, - node: TyKind::Rptr(lt, MutTy { ty: infer_ty, mutbl: mutbl }), - span, - })), + SelfKind::Region(lt, mutbl) => arg( + Mutability::Immutable, + P(Ty { + id: DUMMY_NODE_ID, + node: TyKind::Rptr( + lt, + MutTy { + ty: infer_ty, + mutbl: mutbl, + }, + ), + span, + }), + ), } } } @@ -1720,7 +1761,7 @@ pub struct FnDecl { pub inputs: Vec, pub output: FunctionRetTy, - pub variadic: bool + pub variadic: bool, } impl FnDecl { @@ -1736,7 +1777,7 @@ #[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)] pub enum IsAuto { Yes, - No + No, } #[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)] @@ -1765,7 +1806,10 @@ /// In case this is an `Async` return the `NodeId` for the generated impl Trait item pub fn opt_return_id(self) -> Option { match self { - IsAsync::Async { return_impl_trait_id, .. } => Some(return_impl_trait_id), + IsAsync::Async { + return_impl_trait_id, + .. + } => Some(return_impl_trait_id), IsAsync::NotAsync => None, } } @@ -1785,10 +1829,13 @@ impl fmt::Display for Unsafety { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Display::fmt(match *self { - Unsafety::Normal => "normal", - Unsafety::Unsafe => "unsafe", - }, f) + fmt::Display::fmt( + match *self { + Unsafety::Normal => "normal", + Unsafety::Unsafe => "unsafe", + }, + f, + ) } } @@ -1809,7 +1856,6 @@ } } - #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub enum FunctionRetTy { /// Return type is not specified. @@ -1841,6 +1887,8 @@ /// to the last token in the external file. pub inner: Span, pub items: Vec>, + /// For `mod foo;` inline is false, for `mod foo { .. }` it is true. + pub inline: bool, } /// Foreign module declaration. @@ -1904,8 +1952,13 @@ pub fn ident(&self) -> Ident { match self.kind { UseTreeKind::Simple(Some(rename), ..) => rename, - UseTreeKind::Simple(None, ..) => - self.prefix.segments.last().expect("empty prefix in a simple import").ident, + UseTreeKind::Simple(None, ..) => { + self.prefix + .segments + .last() + .expect("empty prefix in a simple import") + .ident + } _ => panic!("`UseTree::ident` can only be used on a simple import"), } } @@ -1920,7 +1973,9 @@ Inner, } -#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, PartialOrd, Ord, Copy)] +#[derive( + Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, PartialOrd, Ord, Copy, +)] pub struct AttrId(pub usize); impl Idx for AttrId { @@ -1971,7 +2026,10 @@ pub fn new(generic_params: Vec, path: Path, span: Span) -> Self { PolyTraitRef { bound_generic_params: generic_params, - trait_ref: TraitRef { path: path, ref_id: DUMMY_NODE_ID }, + trait_ref: TraitRef { + path: path, + ref_id: DUMMY_NODE_ID, + }, span, } } @@ -1998,7 +2056,11 @@ impl VisibilityKind { pub fn is_pub(&self) -> bool { - if let VisibilityKind::Public = *self { true } else { false } + if let VisibilityKind::Public = *self { + true + } else { + false + } } } @@ -2051,17 +2113,29 @@ } pub fn id(&self) -> NodeId { match *self { - VariantData::Struct(_, id) | VariantData::Tuple(_, id) | VariantData::Unit(id) => id + VariantData::Struct(_, id) | VariantData::Tuple(_, id) | VariantData::Unit(id) => id, } } pub fn is_struct(&self) -> bool { - if let VariantData::Struct(..) = *self { true } else { false } + if let VariantData::Struct(..) = *self { + true + } else { + false + } } pub fn is_tuple(&self) -> bool { - if let VariantData::Tuple(..) = *self { true } else { false } + if let VariantData::Tuple(..) = *self { + true + } else { + false + } } pub fn is_unit(&self) -> bool { - if let VariantData::Unit(..) = *self { true } else { false } + if let VariantData::Unit(..) = *self { + true + } else { + false + } } } @@ -2173,13 +2247,15 @@ /// An implementation. /// /// E.g. `impl Foo { .. }` or `impl Trait for Foo { .. }` - Impl(Unsafety, - ImplPolarity, - Defaultness, - Generics, - Option, // (optional) trait this impl implements - P, // self - Vec), + Impl( + Unsafety, + ImplPolarity, + Defaultness, + Generics, + Option, // (optional) trait this impl implements + P, // self + Vec, + ), /// A macro invocation. /// /// E.g. `macro_rules! foo { .. }` or `foo!(..)` @@ -2207,9 +2283,7 @@ ItemKind::Union(..) => "union", ItemKind::Trait(..) => "trait", ItemKind::TraitAlias(..) => "trait alias", - ItemKind::Mac(..) | - ItemKind::MacroDef(..) | - ItemKind::Impl(..) => "item" + ItemKind::Mac(..) | ItemKind::MacroDef(..) | ItemKind::Impl(..) => "item", } } } @@ -2251,8 +2325,8 @@ #[cfg(test)] mod tests { - use serialize; use super::*; + use serialize; // are ASTs encodable? #[test] diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/attr/builtin.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/attr/builtin.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/attr/builtin.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/attr/builtin.rs 2018-12-04 23:41:40.000000000 +0000 @@ -107,11 +107,12 @@ pub level: StabilityLevel, pub feature: Symbol, pub rustc_depr: Option, - /// `None` means the function is stable but needs to be allowed by the - /// `min_const_fn` feature + /// `None` means the function is stable but needs to be a stable const fn, too /// `Some` contains the feature gate required to be able to use the function /// as const fn pub const_stability: Option, + /// whether the function has a `#[rustc_promotable]` attribute + pub promotable: bool, } /// The available stability levels. @@ -176,6 +177,7 @@ let mut stab: Option = None; let mut rustc_depr: Option = None; let mut rustc_const_unstable: Option = None; + let mut promotable = false; 'outer: for attr in attrs_iter { if ![ @@ -183,6 +185,7 @@ "rustc_const_unstable", "unstable", "stable", + "rustc_promotable", ].iter().any(|&s| attr.path == s) { continue // not a stability level } @@ -190,8 +193,12 @@ mark_used(attr); let meta = attr.meta(); + + if attr.path == "rustc_promotable" { + promotable = true; + } // attributes with data - if let Some(MetaItem { node: MetaItemKind::List(ref metas), .. }) = meta { + else if let Some(MetaItem { node: MetaItemKind::List(ref metas), .. }) = meta { let meta = meta.as_ref().unwrap(); let get = |meta: &MetaItem, item: &mut Option| { if item.is_some() { @@ -329,6 +336,7 @@ feature, rustc_depr: None, const_stability: None, + promotable: false, }) } (None, _, _) => { @@ -378,6 +386,7 @@ feature, rustc_depr: None, const_stability: None, + promotable: false, }) } (None, _) => { @@ -419,6 +428,17 @@ either stable or unstable attribute"); } } + + // Merge the const-unstable info into the stability info + if promotable { + if let Some(ref mut stab) = stab { + stab.promotable = true; + } else { + span_err!(diagnostic, item_sp, E0717, + "rustc_promotable attribute must be paired with \ + either stable or unstable attribute"); + } + } stab } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/config.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/config.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/config.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/config.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,13 +9,21 @@ // except according to those terms. use attr::HasAttrs; -use feature_gate::{feature_err, EXPLAIN_STMT_ATTR_SYNTAX, Features, get_features, GateIssue}; +use feature_gate::{ + feature_err, + EXPLAIN_STMT_ATTR_SYNTAX, + Features, + get_features, + GateIssue, + emit_feature_err, +}; use {fold, attr}; use ast; use source_map::Spanned; use edition::Edition; use parse::{token, ParseSess}; -use OneVector; +use smallvec::SmallVec; +use errors::Applicability; use ptr::P; @@ -72,49 +80,103 @@ if self.in_cfg(node.attrs()) { Some(node) } else { None } } + /// Parse and expand all `cfg_attr` attributes into a list of attributes + /// that are within each `cfg_attr` that has a true configuration predicate. + /// + /// Gives compiler warnigns if any `cfg_attr` does not contain any + /// attributes and is in the original source code. Gives compiler errors if + /// the syntax of any `cfg_attr` is incorrect. pub fn process_cfg_attrs(&mut self, node: T) -> T { node.map_attrs(|attrs| { - attrs.into_iter().filter_map(|attr| self.process_cfg_attr(attr)).collect() + attrs.into_iter().flat_map(|attr| self.process_cfg_attr(attr)).collect() }) } - fn process_cfg_attr(&mut self, attr: ast::Attribute) -> Option { + /// Parse and expand a single `cfg_attr` attribute into a list of attributes + /// when the configuration predicate is true, or otherwise expand into an + /// empty list of attributes. + /// + /// Gives a compiler warning when the `cfg_attr` contains no attributes and + /// is in the original source file. Gives a compiler error if the syntax of + /// the attribute is incorrect + fn process_cfg_attr(&mut self, attr: ast::Attribute) -> Vec { if !attr.check_name("cfg_attr") { - return Some(attr); + return vec![attr]; } - let (cfg, path, tokens, span) = match attr.parse(self.sess, |parser| { + let gate_cfg_attr_multi = if let Some(ref features) = self.features { + !features.cfg_attr_multi + } else { + false + }; + let cfg_attr_span = attr.span; + + let (cfg_predicate, expanded_attrs) = match attr.parse(self.sess, |parser| { parser.expect(&token::OpenDelim(token::Paren))?; - let cfg = parser.parse_meta_item()?; + + let cfg_predicate = parser.parse_meta_item()?; parser.expect(&token::Comma)?; - let lo = parser.span.lo(); - let (path, tokens) = parser.parse_meta_item_unrestricted()?; - parser.eat(&token::Comma); // Optional trailing comma + + // Presumably, the majority of the time there will only be one attr. + let mut expanded_attrs = Vec::with_capacity(1); + + while !parser.check(&token::CloseDelim(token::Paren)) { + let lo = parser.span.lo(); + let (path, tokens) = parser.parse_meta_item_unrestricted()?; + expanded_attrs.push((path, tokens, parser.prev_span.with_lo(lo))); + parser.expect_one_of(&[token::Comma], &[token::CloseDelim(token::Paren)])?; + } + parser.expect(&token::CloseDelim(token::Paren))?; - Ok((cfg, path, tokens, parser.prev_span.with_lo(lo))) + Ok((cfg_predicate, expanded_attrs)) }) { Ok(result) => result, Err(mut e) => { e.emit(); - return None; + return Vec::new(); } }; - if attr::cfg_matches(&cfg, self.sess, self.features) { - self.process_cfg_attr(ast::Attribute { + // Check feature gate and lint on zero attributes in source. Even if the feature is gated, + // we still compute as if it wasn't, since the emitted error will stop compilation further + // along the compilation. + match (expanded_attrs.len(), gate_cfg_attr_multi) { + (0, false) => { + // FIXME: Emit unused attribute lint here. + }, + (1, _) => {}, + (_, true) => { + emit_feature_err( + self.sess, + "cfg_attr_multi", + cfg_attr_span, + GateIssue::Language, + "cfg_attr with zero or more than one attributes is experimental", + ); + }, + (_, false) => {} + } + + if attr::cfg_matches(&cfg_predicate, self.sess, self.features) { + // We call `process_cfg_attr` recursively in case there's a + // `cfg_attr` inside of another `cfg_attr`. E.g. + // `#[cfg_attr(false, cfg_attr(true, some_attr))]`. + expanded_attrs.into_iter() + .flat_map(|(path, tokens, span)| self.process_cfg_attr(ast::Attribute { id: attr::mk_attr_id(), style: attr.style, path, tokens, is_sugared_doc: false, span, - }) + })) + .collect() } else { - None + Vec::new() } } - // Determine if a node with the given attributes should be included in this configuration. + /// Determine if a node with the given attributes should be included in this configuration. pub fn in_cfg(&mut self, attrs: &[ast::Attribute]) -> bool { attrs.iter().all(|attr| { if !is_cfg(attr) { @@ -124,7 +186,12 @@ let error = |span, msg, suggestion: &str| { let mut err = self.sess.span_diagnostic.struct_span_err(span, msg); if !suggestion.is_empty() { - err.span_suggestion(span, "expected syntax is", suggestion.into()); + err.span_suggestion_with_applicability( + span, + "expected syntax is", + suggestion.into(), + Applicability::MaybeIncorrect, + ); } err.emit(); true @@ -159,7 +226,7 @@ }) } - // Visit attributes on expression and statements (but not attributes on items in blocks). + /// Visit attributes on expression and statements (but not attributes on items in blocks). fn visit_expr_attrs(&mut self, attrs: &[ast::Attribute]) { // flag the offending attributes for attr in attrs.iter() { @@ -333,22 +400,23 @@ Some(P(fold::noop_fold_expr(expr, self))) } - fn fold_stmt(&mut self, stmt: ast::Stmt) -> OneVector { + fn fold_stmt(&mut self, stmt: ast::Stmt) -> SmallVec<[ast::Stmt; 1]> { match self.configure_stmt(stmt) { Some(stmt) => fold::noop_fold_stmt(stmt, self), - None => return OneVector::new(), + None => return SmallVec::new(), } } - fn fold_item(&mut self, item: P) -> OneVector> { + fn fold_item(&mut self, item: P) -> SmallVec<[P; 1]> { fold::noop_fold_item(configure!(self, item), self) } - fn fold_impl_item(&mut self, item: ast::ImplItem) -> OneVector { + fn fold_impl_item(&mut self, item: ast::ImplItem) -> SmallVec<[ast::ImplItem; 1]> + { fold::noop_fold_impl_item(configure!(self, item), self) } - fn fold_trait_item(&mut self, item: ast::TraitItem) -> OneVector { + fn fold_trait_item(&mut self, item: ast::TraitItem) -> SmallVec<[ast::TraitItem; 1]> { fold::noop_fold_trait_item(configure!(self, item), self) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/diagnostic_list.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/diagnostic_list.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/diagnostic_list.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/diagnostic_list.rs 2018-12-04 23:41:40.000000000 +0000 @@ -375,15 +375,15 @@ E0705: r##" A `#![feature]` attribute was declared for a feature that is stable in -the current edition. +the current edition, but not in all editions. Erroneous code example: ```ignore (limited to a warning during 2018 edition development) #![feature(rust_2018_preview)] -#![feature(impl_header_lifetime_elision)] // error: the feature - // `impl_header_lifetime_elision` is - // included in the Rust 2018 edition +#![feature(test_2018_feature)] // error: the feature + // `test_2018_feature` is + // included in the Rust 2018 edition ``` "##, @@ -413,4 +413,5 @@ E0694, // an unknown tool name found in scoped attributes E0703, // invalid ABI E0704, // incorrect visibility restriction + E0717, // rustc_promotable without stability attribute } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/diagnostics/plugin.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/diagnostics/plugin.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/diagnostics/plugin.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/diagnostics/plugin.rs 2018-12-04 23:41:40.000000000 +0000 @@ -19,7 +19,6 @@ use ext::build::AstBuilder; use parse::token; use ptr::P; -use OneVector; use symbol::{keywords, Symbol}; use tokenstream::{TokenTree}; @@ -131,7 +130,7 @@ let sym = Ident::with_empty_ctxt(Symbol::gensym(&format!( "__register_diagnostic_{}", code ))); - MacEager::items(OneVector::from_vec(vec![ + MacEager::items(smallvec![ ecx.item_mod( span, span, @@ -139,7 +138,7 @@ Vec::new(), Vec::new() ) - ])) + ]) } pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt, @@ -214,7 +213,7 @@ ), ); - MacEager::items(OneVector::from_vec(vec![ + MacEager::items(smallvec![ P(ast::Item { ident: *name, attrs: Vec::new(), @@ -227,5 +226,5 @@ span, tokens: None, }) - ])) + ]) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/ext/base.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/ext/base.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/ext/base.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/ext/base.rs 2018-12-04 23:41:40.000000000 +0000 @@ -22,7 +22,7 @@ use parse::{self, parser, DirectoryOwnership}; use parse::token; use ptr::P; -use OneVector; +use smallvec::SmallVec; use symbol::{keywords, Ident, Symbol}; use ThinVec; @@ -332,22 +332,22 @@ None } /// Create zero or more items. - fn make_items(self: Box) -> Option>> { + fn make_items(self: Box) -> Option; 1]>> { None } /// Create zero or more impl items. - fn make_impl_items(self: Box) -> Option> { + fn make_impl_items(self: Box) -> Option> { None } /// Create zero or more trait items. - fn make_trait_items(self: Box) -> Option> { + fn make_trait_items(self: Box) -> Option> { None } /// Create zero or more items in an `extern {}` block - fn make_foreign_items(self: Box) -> Option> { None } + fn make_foreign_items(self: Box) -> Option> { None } /// Create a pattern. fn make_pat(self: Box) -> Option> { @@ -358,7 +358,7 @@ /// /// By default this attempts to create an expression statement, /// returning None if that fails. - fn make_stmts(self: Box) -> Option> { + fn make_stmts(self: Box) -> Option> { make_stmts_default!(self) } @@ -394,11 +394,11 @@ make_MacEager! { expr: P, pat: P, - items: OneVector>, - impl_items: OneVector, - trait_items: OneVector, - foreign_items: OneVector, - stmts: OneVector, + items: SmallVec<[P; 1]>, + impl_items: SmallVec<[ast::ImplItem; 1]>, + trait_items: SmallVec<[ast::TraitItem; 1]>, + foreign_items: SmallVec<[ast::ForeignItem; 1]>, + stmts: SmallVec<[ast::Stmt; 1]>, ty: P, } @@ -407,23 +407,23 @@ self.expr } - fn make_items(self: Box) -> Option>> { + fn make_items(self: Box) -> Option; 1]>> { self.items } - fn make_impl_items(self: Box) -> Option> { + fn make_impl_items(self: Box) -> Option> { self.impl_items } - fn make_trait_items(self: Box) -> Option> { + fn make_trait_items(self: Box) -> Option> { self.trait_items } - fn make_foreign_items(self: Box) -> Option> { + fn make_foreign_items(self: Box) -> Option> { self.foreign_items } - fn make_stmts(self: Box) -> Option> { + fn make_stmts(self: Box) -> Option> { match self.stmts.as_ref().map_or(0, |s| s.len()) { 0 => make_stmts_default!(self), _ => self.stmts, @@ -514,40 +514,40 @@ Some(P(DummyResult::raw_pat(self.span))) } - fn make_items(self: Box) -> Option>> { + fn make_items(self: Box) -> Option; 1]>> { // this code needs a comment... why not always just return the Some() ? if self.expr_only { None } else { - Some(OneVector::new()) + Some(SmallVec::new()) } } - fn make_impl_items(self: Box) -> Option> { + fn make_impl_items(self: Box) -> Option> { if self.expr_only { None } else { - Some(OneVector::new()) + Some(SmallVec::new()) } } - fn make_trait_items(self: Box) -> Option> { + fn make_trait_items(self: Box) -> Option> { if self.expr_only { None } else { - Some(OneVector::new()) + Some(SmallVec::new()) } } - fn make_foreign_items(self: Box) -> Option> { + fn make_foreign_items(self: Box) -> Option> { if self.expr_only { None } else { - Some(OneVector::new()) + Some(SmallVec::new()) } } - fn make_stmts(self: Box) -> Option> { + fn make_stmts(self: Box) -> Option> { Some(smallvec![ast::Stmt { id: ast::DUMMY_NODE_ID, node: ast::StmtKind::Expr(DummyResult::raw_expr(self.span)), @@ -585,6 +585,13 @@ MacroKind::ProcMacroStub => "crate-local procedural macro", } } + + pub fn article(self) -> &'static str { + match self { + MacroKind::Attr => "an", + _ => "a", + } + } } /// An enum representing the different kinds of syntax extensions. diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/ext/build.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/ext/build.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/ext/build.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/ext/build.rs 2018-12-04 23:41:40.000000000 +0000 @@ -329,7 +329,11 @@ } else { None }; - segments.push(ast::PathSegment { ident: last_ident.with_span_pos(span), args }); + segments.push(ast::PathSegment { + ident: last_ident.with_span_pos(span), + id: ast::DUMMY_NODE_ID, + args, + }); let mut path = ast::Path { span, segments }; if global { if let Some(seg) = path.make_root() { @@ -366,7 +370,7 @@ } else { None }; - path.segments.push(ast::PathSegment { ident, args }); + path.segments.push(ast::PathSegment { ident, id: ast::DUMMY_NODE_ID, args }); (ast::QSelf { ty: self_type, @@ -1101,6 +1105,7 @@ ast::ItemKind::Mod(ast::Mod { inner: inner_span, items, + inline: true }) ) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/ext/expand.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/ext/expand.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/ext/expand.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/ext/expand.rs 2018-12-04 23:41:40.000000000 +0000 @@ -25,7 +25,7 @@ use parse::token::{self, Token}; use parse::parser::Parser; use ptr::P; -use OneVector; +use smallvec::SmallVec; use symbol::Symbol; use symbol::keywords; use syntax_pos::{Span, DUMMY_SP, FileName}; @@ -147,15 +147,19 @@ Expr(P) { "expression"; one fn fold_expr; fn visit_expr; fn make_expr; } Pat(P) { "pattern"; one fn fold_pat; fn visit_pat; fn make_pat; } Ty(P) { "type"; one fn fold_ty; fn visit_ty; fn make_ty; } - Stmts(OneVector) { "statement"; many fn fold_stmt; fn visit_stmt; fn make_stmts; } - Items(OneVector>) { "item"; many fn fold_item; fn visit_item; fn make_items; } - TraitItems(OneVector) { + Stmts(SmallVec<[ast::Stmt; 1]>) { + "statement"; many fn fold_stmt; fn visit_stmt; fn make_stmts; + } + Items(SmallVec<[P; 1]>) { + "item"; many fn fold_item; fn visit_item; fn make_items; + } + TraitItems(SmallVec<[ast::TraitItem; 1]>) { "trait item"; many fn fold_trait_item; fn visit_trait_item; fn make_trait_items; } - ImplItems(OneVector) { + ImplItems(SmallVec<[ast::ImplItem; 1]>) { "impl item"; many fn fold_impl_item; fn visit_impl_item; fn make_impl_items; } - ForeignItems(OneVector) { + ForeignItems(SmallVec<[ast::ForeignItem; 1]>) { "foreign item"; many fn fold_foreign_item; fn visit_foreign_item; fn make_foreign_items; } } @@ -216,14 +220,6 @@ pub expansion_data: ExpansionData, } -// Needed for feature-gating attributes used after derives or together with test/bench -#[derive(Clone, Copy, PartialEq)] -pub enum TogetherWith { - None, - Derive, - TestBench, -} - pub enum InvocationKind { Bang { mac: ast::Mac, @@ -234,7 +230,8 @@ attr: Option, traits: Vec, item: Annotatable, - together_with: TogetherWith, + // We temporarily report errors for attribute macros placed after derives + after_derive: bool, }, Derive { path: Path, @@ -299,6 +296,7 @@ krate.module = ast::Mod { inner: orig_mod_span, items: vec![], + inline: true, }; }, _ => unreachable!(), @@ -640,8 +638,8 @@ let (kind, gate) = match *item { Annotatable::Item(ref item) => { match item.node { - ItemKind::Mod(_) if self.cx.ecfg.proc_macro_mod() => return, - ItemKind::Mod(_) => ("modules", "proc_macro_mod"), + ItemKind::Mod(_) if self.cx.ecfg.proc_macro_hygiene() => return, + ItemKind::Mod(_) => ("modules", "proc_macro_hygiene"), _ => return, } } @@ -649,9 +647,9 @@ Annotatable::ImplItem(_) => return, Annotatable::ForeignItem(_) => return, Annotatable::Stmt(_) | - Annotatable::Expr(_) if self.cx.ecfg.proc_macro_expr() => return, - Annotatable::Stmt(_) => ("statements", "proc_macro_expr"), - Annotatable::Expr(_) => ("expressions", "proc_macro_expr"), + Annotatable::Expr(_) if self.cx.ecfg.proc_macro_hygiene() => return, + Annotatable::Stmt(_) => ("statements", "proc_macro_hygiene"), + Annotatable::Expr(_) => ("expressions", "proc_macro_hygiene"), }; emit_feature_err( self.cx.parse_sess, @@ -663,7 +661,7 @@ } fn gate_proc_macro_expansion(&self, span: Span, fragment: &Option) { - if self.cx.ecfg.proc_macro_gen() { + if self.cx.ecfg.proc_macro_hygiene() { return } let fragment = match fragment { @@ -686,7 +684,7 @@ if let ast::ItemKind::MacroDef(_) = i.node { emit_feature_err( self.parse_sess, - "proc_macro_gen", + "proc_macro_hygiene", self.span, GateIssue::Language, &format!("procedural macros cannot expand to macro definitions"), @@ -880,12 +878,12 @@ AstFragmentKind::ImplItems => return, AstFragmentKind::ForeignItems => return, }; - if self.cx.ecfg.proc_macro_non_items() { + if self.cx.ecfg.proc_macro_hygiene() { return } emit_feature_err( self.cx.parse_sess, - "proc_macro_non_items", + "proc_macro_hygiene", span, GateIssue::Language, &format!("procedural macros cannot be expanded to {}", kind), @@ -980,37 +978,35 @@ -> PResult<'a, AstFragment> { Ok(match kind { AstFragmentKind::Items => { - let mut items = OneVector::new(); + let mut items = SmallVec::new(); while let Some(item) = self.parse_item()? { items.push(item); } AstFragment::Items(items) } AstFragmentKind::TraitItems => { - let mut items = OneVector::new(); + let mut items = SmallVec::new(); while self.token != token::Eof { items.push(self.parse_trait_item(&mut false)?); } AstFragment::TraitItems(items) } AstFragmentKind::ImplItems => { - let mut items = OneVector::new(); + let mut items = SmallVec::new(); while self.token != token::Eof { items.push(self.parse_impl_item(&mut false)?); } AstFragment::ImplItems(items) } AstFragmentKind::ForeignItems => { - let mut items = OneVector::new(); + let mut items = SmallVec::new(); while self.token != token::Eof { - if let Some(item) = self.parse_foreign_item()? { - items.push(item); - } + items.push(self.parse_foreign_item()?); } AstFragment::ForeignItems(items) } AstFragmentKind::Stmts => { - let mut stmts = OneVector::new(); + let mut stmts = SmallVec::new(); while self.token != token::Eof && // won't make progress on a `}` self.token != token::CloseDelim(token::Brace) { @@ -1079,19 +1075,17 @@ traits: Vec, item: Annotatable, kind: AstFragmentKind, - together_with: TogetherWith) + after_derive: bool) -> AstFragment { - self.collect(kind, InvocationKind::Attr { attr, traits, item, together_with }) + self.collect(kind, InvocationKind::Attr { attr, traits, item, after_derive }) } - fn find_attr_invoc(&self, attrs: &mut Vec, together_with: &mut TogetherWith) + fn find_attr_invoc(&self, attrs: &mut Vec, after_derive: &mut bool) -> Option { let attr = attrs.iter() .position(|a| { if a.path == "derive" { - *together_with = TogetherWith::Derive - } else if a.path == "rustc_test_marker2" { - *together_with = TogetherWith::TestBench + *after_derive = true; } !attr::is_known(a) && !is_builtin_attr(a) }) @@ -1104,19 +1098,15 @@ "non-builtin inner attributes are unstable"); } } - if together_with == &TogetherWith::None && - attrs.iter().any(|a| a.path == "rustc_test_marker2") { - *together_with = TogetherWith::TestBench; - } attr } /// If `item` is an attr invocation, remove and return the macro attribute and derive traits. fn classify_item(&mut self, mut item: T) - -> (Option, Vec, T, TogetherWith) + -> (Option, Vec, T, /* after_derive */ bool) where T: HasAttrs, { - let (mut attr, mut traits, mut together_with) = (None, Vec::new(), TogetherWith::None); + let (mut attr, mut traits, mut after_derive) = (None, Vec::new(), false); item = item.map_attrs(|mut attrs| { if let Some(legacy_attr_invoc) = self.cx.resolver.find_legacy_attr_invoc(&mut attrs, @@ -1125,20 +1115,20 @@ return attrs; } - attr = self.find_attr_invoc(&mut attrs, &mut together_with); + attr = self.find_attr_invoc(&mut attrs, &mut after_derive); traits = collect_derives(&mut self.cx, &mut attrs); attrs }); - (attr, traits, item, together_with) + (attr, traits, item, after_derive) } /// Alternative of `classify_item()` that ignores `#[derive]` so invocations fallthrough /// to the unused-attributes lint (making it an error on statements and expressions /// is a breaking change) fn classify_nonitem(&mut self, mut item: T) - -> (Option, T, TogetherWith) { - let (mut attr, mut together_with) = (None, TogetherWith::None); + -> (Option, T, /* after_derive */ bool) { + let (mut attr, mut after_derive) = (None, false); item = item.map_attrs(|mut attrs| { if let Some(legacy_attr_invoc) = self.cx.resolver.find_legacy_attr_invoc(&mut attrs, @@ -1147,11 +1137,11 @@ return attrs; } - attr = self.find_attr_invoc(&mut attrs, &mut together_with); + attr = self.find_attr_invoc(&mut attrs, &mut after_derive); attrs }); - (attr, item, together_with) + (attr, item, after_derive) } fn configure(&mut self, node: T) -> Option { @@ -1190,7 +1180,7 @@ expr.node = self.cfg.configure_expr_kind(expr.node); // ignore derives so they remain unused - let (attr, expr, together_with) = self.classify_nonitem(expr); + let (attr, expr, after_derive) = self.classify_nonitem(expr); if attr.is_some() { // collect the invoc regardless of whether or not attributes are permitted here @@ -1199,7 +1189,7 @@ // AstFragmentKind::Expr requires the macro to emit an expression return self.collect_attr(attr, vec![], Annotatable::Expr(P(expr)), - AstFragmentKind::Expr, together_with).make_expr(); + AstFragmentKind::Expr, after_derive).make_expr(); } if let ast::ExprKind::Mac(mac) = expr.node { @@ -1215,13 +1205,13 @@ expr.node = self.cfg.configure_expr_kind(expr.node); // ignore derives so they remain unused - let (attr, expr, together_with) = self.classify_nonitem(expr); + let (attr, expr, after_derive) = self.classify_nonitem(expr); if attr.is_some() { attr.as_ref().map(|a| self.cfg.maybe_emit_expr_attr_err(a)); return self.collect_attr(attr, vec![], Annotatable::Expr(P(expr)), - AstFragmentKind::OptExpr, together_with).make_opt_expr(); + AstFragmentKind::OptExpr, after_derive).make_opt_expr(); } if let ast::ExprKind::Mac(mac) = expr.node { @@ -1245,26 +1235,26 @@ }) } - fn fold_stmt(&mut self, stmt: ast::Stmt) -> OneVector { + fn fold_stmt(&mut self, stmt: ast::Stmt) -> SmallVec<[ast::Stmt; 1]> { let mut stmt = match self.cfg.configure_stmt(stmt) { Some(stmt) => stmt, - None => return OneVector::new(), + None => return SmallVec::new(), }; // we'll expand attributes on expressions separately if !stmt.is_expr() { - let (attr, derives, stmt_, together_with) = if stmt.is_item() { + let (attr, derives, stmt_, after_derive) = if stmt.is_item() { self.classify_item(stmt) } else { // ignore derives on non-item statements so it falls through // to the unused-attributes lint - let (attr, stmt, together_with) = self.classify_nonitem(stmt); - (attr, vec![], stmt, together_with) + let (attr, stmt, after_derive) = self.classify_nonitem(stmt); + (attr, vec![], stmt, after_derive) }; if attr.is_some() || !derives.is_empty() { return self.collect_attr(attr, derives, Annotatable::Stmt(P(stmt_)), - AstFragmentKind::Stmts, together_with).make_stmts(); + AstFragmentKind::Stmts, after_derive).make_stmts(); } stmt = stmt_; @@ -1303,13 +1293,13 @@ result } - fn fold_item(&mut self, item: P) -> OneVector> { + fn fold_item(&mut self, item: P) -> SmallVec<[P; 1]> { let item = configure!(self, item); - let (attr, traits, item, together_with) = self.classify_item(item); + let (attr, traits, item, after_derive) = self.classify_item(item); if attr.is_some() || !traits.is_empty() { return self.collect_attr(attr, traits, Annotatable::Item(item), - AstFragmentKind::Items, together_with).make_items(); + AstFragmentKind::Items, after_derive).make_items(); } match item.node { @@ -1378,13 +1368,13 @@ } } - fn fold_trait_item(&mut self, item: ast::TraitItem) -> OneVector { + fn fold_trait_item(&mut self, item: ast::TraitItem) -> SmallVec<[ast::TraitItem; 1]> { let item = configure!(self, item); - let (attr, traits, item, together_with) = self.classify_item(item); + let (attr, traits, item, after_derive) = self.classify_item(item); if attr.is_some() || !traits.is_empty() { return self.collect_attr(attr, traits, Annotatable::TraitItem(P(item)), - AstFragmentKind::TraitItems, together_with).make_trait_items() + AstFragmentKind::TraitItems, after_derive).make_trait_items() } match item.node { @@ -1397,13 +1387,13 @@ } } - fn fold_impl_item(&mut self, item: ast::ImplItem) -> OneVector { + fn fold_impl_item(&mut self, item: ast::ImplItem) -> SmallVec<[ast::ImplItem; 1]> { let item = configure!(self, item); - let (attr, traits, item, together_with) = self.classify_item(item); + let (attr, traits, item, after_derive) = self.classify_item(item); if attr.is_some() || !traits.is_empty() { return self.collect_attr(attr, traits, Annotatable::ImplItem(P(item)), - AstFragmentKind::ImplItems, together_with).make_impl_items(); + AstFragmentKind::ImplItems, after_derive).make_impl_items(); } match item.node { @@ -1432,13 +1422,14 @@ noop_fold_foreign_mod(self.cfg.configure_foreign_mod(foreign_mod), self) } - fn fold_foreign_item(&mut self, - foreign_item: ast::ForeignItem) -> OneVector { - let (attr, traits, foreign_item, together_with) = self.classify_item(foreign_item); + fn fold_foreign_item(&mut self, foreign_item: ast::ForeignItem) + -> SmallVec<[ast::ForeignItem; 1]> + { + let (attr, traits, foreign_item, after_derive) = self.classify_item(foreign_item); if attr.is_some() || !traits.is_empty() { return self.collect_attr(attr, traits, Annotatable::ForeignItem(P(foreign_item)), - AstFragmentKind::ForeignItems, together_with) + AstFragmentKind::ForeignItems, after_derive) .make_foreign_items(); } @@ -1606,10 +1597,7 @@ fn enable_custom_derive = custom_derive, fn enable_format_args_nl = format_args_nl, fn macros_in_extern_enabled = macros_in_extern, - fn proc_macro_mod = proc_macro_mod, - fn proc_macro_gen = proc_macro_gen, - fn proc_macro_expr = proc_macro_expr, - fn proc_macro_non_items = proc_macro_non_items, + fn proc_macro_hygiene = proc_macro_hygiene, } fn enable_custom_inner_attributes(&self) -> bool { diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/ext/placeholders.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/ext/placeholders.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/ext/placeholders.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/ext/placeholders.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,7 +16,7 @@ use tokenstream::TokenStream; use fold::*; use ptr::P; -use OneVector; +use smallvec::SmallVec; use symbol::keywords; use ThinVec; use util::move_map::MoveMap; @@ -115,7 +115,7 @@ } impl<'a, 'b> Folder for PlaceholderExpander<'a, 'b> { - fn fold_item(&mut self, item: P) -> OneVector> { + fn fold_item(&mut self, item: P) -> SmallVec<[P; 1]> { match item.node { ast::ItemKind::Mac(_) => return self.remove(item.id).make_items(), ast::ItemKind::MacroDef(_) => return smallvec![item], @@ -125,21 +125,21 @@ noop_fold_item(item, self) } - fn fold_trait_item(&mut self, item: ast::TraitItem) -> OneVector { + fn fold_trait_item(&mut self, item: ast::TraitItem) -> SmallVec<[ast::TraitItem; 1]> { match item.node { ast::TraitItemKind::Macro(_) => self.remove(item.id).make_trait_items(), _ => noop_fold_trait_item(item, self), } } - fn fold_impl_item(&mut self, item: ast::ImplItem) -> OneVector { + fn fold_impl_item(&mut self, item: ast::ImplItem) -> SmallVec<[ast::ImplItem; 1]> { match item.node { ast::ImplItemKind::Macro(_) => self.remove(item.id).make_impl_items(), _ => noop_fold_impl_item(item, self), } } - fn fold_foreign_item(&mut self, item: ast::ForeignItem) -> OneVector { + fn fold_foreign_item(&mut self, item: ast::ForeignItem) -> SmallVec<[ast::ForeignItem; 1]> { match item.node { ast::ForeignItemKind::Macro(_) => self.remove(item.id).make_foreign_items(), _ => noop_fold_foreign_item(item, self), @@ -160,7 +160,7 @@ } } - fn fold_stmt(&mut self, stmt: ast::Stmt) -> OneVector { + fn fold_stmt(&mut self, stmt: ast::Stmt) -> SmallVec<[ast::Stmt; 1]> { let (style, mut stmts) = match stmt.node { ast::StmtKind::Mac(mac) => (mac.1, self.remove(stmt.id).make_stmts()), _ => return noop_fold_stmt(stmt, self), diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/ext/source_util.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/ext/source_util.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/ext/source_util.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/ext/source_util.rs 2018-12-04 23:41:40.000000000 +0000 @@ -17,7 +17,7 @@ use parse; use print::pprust; use ptr::P; -use OneVector; +use smallvec::SmallVec; use symbol::Symbol; use tokenstream; @@ -110,9 +110,9 @@ fn make_expr(mut self: Box>) -> Option> { Some(panictry!(self.p.parse_expr())) } - fn make_items(mut self: Box>) - -> Option>> { - let mut ret = OneVector::new(); + + fn make_items(mut self: Box>) -> Option; 1]>> { + let mut ret = SmallVec::new(); while self.p.token != token::Eof { match panictry!(self.p.parse_item()) { Some(item) => ret.push(item), diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/ext/tt/macro_parser.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/ext/tt/macro_parser.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/ext/tt/macro_parser.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/ext/tt/macro_parser.rs 2018-12-04 23:41:40.000000000 +0000 @@ -92,7 +92,7 @@ use parse::parser::{Parser, PathStyle}; use parse::token::{self, DocComment, Nonterminal, Token}; use print::pprust; -use OneVector; +use smallvec::SmallVec; use symbol::keywords; use tokenstream::{DelimSpan, TokenStream}; @@ -440,10 +440,10 @@ /// A `ParseResult`. Note that matches are kept track of through the items generated. fn inner_parse_loop<'a>( sess: &ParseSess, - cur_items: &mut OneVector>, + cur_items: &mut SmallVec<[MatcherPosHandle<'a>; 1]>, next_items: &mut Vec>, - eof_items: &mut OneVector>, - bb_items: &mut OneVector>, + eof_items: &mut SmallVec<[MatcherPosHandle<'a>; 1]>, + bb_items: &mut SmallVec<[MatcherPosHandle<'a>; 1]>, token: &Token, span: syntax_pos::Span, ) -> ParseResult<()> { @@ -649,10 +649,10 @@ loop { // Matcher positions black-box parsed by parser.rs (`parser`) - let mut bb_items = OneVector::new(); + let mut bb_items = SmallVec::new(); // Matcher positions that would be valid if the macro invocation was over now - let mut eof_items = OneVector::new(); + let mut eof_items = SmallVec::new(); assert!(next_items.is_empty()); // Process `cur_items` until either we have finished the input or we need to get some diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/ext/tt/macro_rules.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/ext/tt/macro_rules.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/ext/tt/macro_rules.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/ext/tt/macro_rules.rs 2018-12-04 23:41:40.000000000 +0000 @@ -32,6 +32,11 @@ use std::collections::hash_map::Entry; use rustc_data_structures::sync::Lrc; +use errors::Applicability; + +const VALID_FRAGMENT_NAMES_MSG: &str = "valid fragment specifiers are \ + `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, \ + `path`, `meta`, `tt`, `item` and `vis`"; pub struct ParserAnyMacro<'a> { parser: Parser<'a>, @@ -128,8 +133,7 @@ // Replace all the tokens for the corresponding positions in the macro, to maintain // proper positions in error reporting, while maintaining the macro_backtrace. if rhs_spans.len() == tts.len() { - tts = tts.map_enumerated(|i, tt| { - let mut tt = tt.clone(); + tts = tts.map_enumerated(|i, mut tt| { let mut sp = rhs_spans[i]; sp = sp.with_ctxt(tt.span().ctxt()); tt.set_span(sp); @@ -187,10 +191,11 @@ if comma_span == DUMMY_SP { err.note("you might be missing a comma"); } else { - err.span_suggestion_short( + err.span_suggestion_short_with_applicability( comma_span, "missing comma here", ", ".to_string(), + Applicability::MachineApplicable, ); } } @@ -706,8 +711,7 @@ if let Err(bad_frag) = has_legal_fragment_specifier(sess, features, attrs, token) { let msg = format!("invalid fragment specifier `{}`", bad_frag); sess.span_diagnostic.struct_span_err(token.span(), &msg) - .help("valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, \ - `pat`, `ty`, `literal`, `path`, `meta`, `tt`, `item` and `vis`") + .help(VALID_FRAGMENT_NAMES_MSG) .emit(); // (This eliminates false positives and duplicates // from error messages.) @@ -900,7 +904,8 @@ "path" | "ty" => match *tok { TokenTree::Token(_, ref tok) => match *tok { OpenDelim(token::DelimToken::Brace) | OpenDelim(token::DelimToken::Bracket) | - Comma | FatArrow | Colon | Eq | Gt | Semi | BinOp(token::Or) => Ok(true), + Comma | FatArrow | Colon | Eq | Gt | BinOp(token::Shr) | Semi | + BinOp(token::Or) => Ok(true), Ident(i, false) if i.name == "as" || i.name == "where" => Ok(true), _ => Ok(false) }, @@ -936,9 +941,7 @@ }, "" => Ok(true), // keywords::Invalid _ => Err((format!("invalid fragment specifier `{}`", frag), - "valid fragment specifiers are `ident`, `block`, \ - `stmt`, `expr`, `pat`, `ty`, `path`, `meta`, `tt`, \ - `literal`, `item` and `vis`")) + VALID_FRAGMENT_NAMES_MSG)) } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/ext/tt/transcribe.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/ext/tt/transcribe.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/ext/tt/transcribe.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/ext/tt/transcribe.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,7 +15,7 @@ use ext::tt::quoted; use fold::noop_fold_tt; use parse::token::{self, Token, NtTT}; -use OneVector; +use smallvec::SmallVec; use syntax_pos::DUMMY_SP; use tokenstream::{TokenStream, TokenTree, Delimited, DelimSpan}; @@ -70,7 +70,7 @@ interp: Option>>, src: Vec) -> TokenStream { - let mut stack: OneVector = smallvec![Frame::new(src)]; + let mut stack: SmallVec<[Frame; 1]> = smallvec![Frame::new(src)]; let interpolations = interp.unwrap_or_else(FxHashMap::default); /* just a convenience */ let mut repeats = Vec::new(); let mut result: Vec = Vec::new(); @@ -219,9 +219,9 @@ LockstepIterSize::Unconstrained => other, LockstepIterSize::Contradiction(_) => self, LockstepIterSize::Constraint(l_len, ref l_id) => match other { - LockstepIterSize::Unconstrained => self.clone(), + LockstepIterSize::Unconstrained => self, LockstepIterSize::Contradiction(_) => other, - LockstepIterSize::Constraint(r_len, _) if l_len == r_len => self.clone(), + LockstepIterSize::Constraint(r_len, _) if l_len == r_len => self, LockstepIterSize::Constraint(r_len, r_id) => { let msg = format!("inconsistent lockstep iteration: \ '{}' has {} items, but '{}' has {}", diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/feature_gate.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/feature_gate.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/feature_gate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/feature_gate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -37,19 +37,9 @@ use parse::ParseSess; use symbol::{keywords, Symbol}; -use std::{env, path}; +use std::{env}; macro_rules! set { - // The const_fn feature also enables the min_const_fn feature, because `min_const_fn` allows - // the declaration `const fn`, but the `const_fn` feature gate enables things inside those - // functions that we do not want to expose to the user for now. - (const_fn) => {{ - fn f(features: &mut Features, _: Span) { - features.const_fn = true; - features.min_const_fn = true; - } - f as fn(&mut Features, Span) - }}; ($field: ident) => {{ fn f(features: &mut Features, _: Span) { features.$field = true; @@ -219,9 +209,6 @@ // Allows the definition of `const fn` functions with some advanced features. (active, const_fn, "1.2.0", Some(24111), None), - // Allows the definition of `const fn` functions. - (active, min_const_fn, "1.30.0", Some(53555), None), - // Allows let bindings and destructuring in `const fn` functions and constants. (active, const_let, "1.22.1", Some(48821), None), @@ -355,6 +342,9 @@ // Allows overlapping impls of marker traits (active, overlapping_marker_traits, "1.18.0", Some(29864), None), + // Trait attribute to allow overlapping impls + (active, marker_trait_attr, "1.30.0", Some(29864), None), + // rustc internal (active, abi_thiscall, "1.19.0", None, None), @@ -403,24 +393,15 @@ // `extern` in paths (active, extern_in_paths, "1.23.0", Some(44660), None), - // `foo.rs` as an alternative to `foo/mod.rs` - (active, non_modrs_mods, "1.24.0", Some(44660), Some(Edition::Edition2018)), - // Use `?` as the Kleene "at most one" operator (active, macro_at_most_once_rep, "1.25.0", Some(48075), None), - // Infer outlives requirements; RFC 2093 - (active, infer_outlives_requirements, "1.26.0", Some(44493), None), - // Infer static outlives requirements; RFC 2093 (active, infer_static_outlives_requirements, "1.26.0", Some(44493), None), // Multiple patterns with `|` in `if let` and `while let` (active, if_while_or_patterns, "1.26.0", Some(48215), None), - // Parentheses in patterns - (active, pattern_parentheses, "1.26.0", Some(51087), None), - // Allows `#[repr(packed)]` attribute on structs (active, repr_packed, "1.26.0", Some(33158), None), @@ -447,17 +428,11 @@ // Allows macro invocations on modules expressions and statements and // procedural macros to expand to non-items. - (active, proc_macro_mod, "1.27.0", Some(38356), None), - (active, proc_macro_expr, "1.27.0", Some(38356), None), - (active, proc_macro_non_items, "1.27.0", Some(38356), None), - (active, proc_macro_gen, "1.27.0", Some(38356), None), + (active, proc_macro_hygiene, "1.30.0", Some(54727), None), // #[doc(alias = "...")] (active, doc_alias, "1.27.0", Some(50146), None), - // Scoped lints - (active, tool_lints, "1.28.0", Some(44690), None), - // Allows irrefutable patterns in if-let and while-let statements (RFC 2086) (active, irrefutable_let_patterns, "1.27.0", Some(44495), None), @@ -487,9 +462,8 @@ (active, abi_amdgpu_kernel, "1.29.0", Some(51575), None), - // impl Iterator for &mut Iterator - // impl Debug for Foo<'_> - (active, impl_header_lifetime_elision, "1.30.0", Some(15872), Some(Edition::Edition2018)), + // Perma-unstable; added for testing E0705 + (active, test_2018_feature, "1.31.0", Some(0), Some(Edition::Edition2018)), // Support for arbitrary delimited token streams in non-macro attributes (active, unrestricted_attribute_tokens, "1.30.0", Some(44690), None), @@ -500,7 +474,7 @@ // Allows `Self` in type definitions (active, self_in_typedefs, "1.30.0", Some(49303), None), - // unsized rvalues at arguments and parameters + // Allows unsized rvalues at arguments and parameters (active, unsized_locals, "1.30.0", Some(48055), None), // #![test_runner] @@ -508,10 +482,25 @@ (active, custom_test_frameworks, "1.30.0", Some(50297), None), // Non-builtin attributes in inner attribute position - (active, custom_inner_attributes, "1.30.0", Some(38356), None), + (active, custom_inner_attributes, "1.30.0", Some(54726), None), // Self struct constructor (RFC 2302) - (active, self_struct_ctor, "1.31.0", Some(51994), None), + (active, self_struct_ctor, "1.30.0", Some(51994), None), + + // allow mixing of bind-by-move in patterns and references to + // those identifiers in guards, *if* we are using MIR-borrowck + // (aka NLL). Essentially this means you need to be on + // edition:2018 or later. + (active, bind_by_move_pattern_guards, "1.30.0", Some(15287), None), + + // Allows `impl Trait` in bindings (`let`, `const`, `static`) + (active, impl_trait_in_bindings, "1.30.0", Some(34511), None), + + // #[cfg_attr(predicate, multiple, attributes, here)] + (active, cfg_attr_multi, "1.31.0", Some(54881), None), + + // Allows `const _: TYPE = VALUE` + (active, underscore_const_names, "1.31.0", Some(54912), None), ); declare_features! ( @@ -538,6 +527,14 @@ Some("merged into `#![feature(slice_patterns)]`")), (removed, macro_reexport, "1.0.0", Some(29638), None, Some("subsumed by `pub use`")), + (removed, proc_macro_mod, "1.27.0", Some(54727), None, + Some("subsumed by `#![feature(proc_macro_hygiene)]`")), + (removed, proc_macro_expr, "1.27.0", Some(54727), None, + Some("subsumed by `#![feature(proc_macro_hygiene)]`")), + (removed, proc_macro_non_items, "1.27.0", Some(54727), None, + Some("subsumed by `#![feature(proc_macro_hygiene)]`")), + (removed, proc_macro_gen, "1.27.0", Some(54727), None, + Some("subsumed by `#![feature(proc_macro_hygiene)]`")), ); declare_features! ( @@ -654,6 +651,8 @@ (accepted, repr_transparent, "1.28.0", Some(43036), None), // Defining procedural macros in `proc-macro` crates (accepted, proc_macro, "1.29.0", Some(38356), None), + // `foo.rs` as an alternative to `foo/mod.rs` + (accepted, non_modrs_mods, "1.30.0", Some(44660), None), // Allows use of the :vis macro fragment specifier (accepted, macro_vis_matcher, "1.30.0", Some(41022), None), // Allows importing and reexporting macros with `use`, @@ -667,6 +666,8 @@ (accepted, proc_macro_path_invoc, "1.30.0", Some(38356), None), // Allows all literals in attribute lists and values of key-value pairs. (accepted, attr_literals, "1.30.0", Some(34981), None), + // Infer outlives requirements; RFC 2093 + (accepted, infer_outlives_requirements, "1.30.0", Some(44493), None), (accepted, panic_handler, "1.30.0", Some(44489), None), // Used to preserve symbols (see llvm.used) (accepted, used, "1.30.0", Some(40289), None), @@ -676,6 +677,17 @@ (accepted, extern_absolute_paths, "1.30.0", Some(44660), None), // Access to crate names passed via `--extern` through prelude (accepted, extern_prelude, "1.30.0", Some(44660), None), + // Parentheses in patterns + (accepted, pattern_parentheses, "1.31.0", Some(51087), None), + // Allows the definition of `const fn` functions. + (accepted, min_const_fn, "1.31.0", Some(53555), None), + // Scoped lints + (accepted, tool_lints, "1.31.0", Some(44690), None), + // impl Iterator for &mut Iterator + // impl Debug for Foo<'_> + (accepted, impl_header_lifetime_elision, "1.31.0", Some(15872), None), + // `extern crate foo as bar;` puts `bar` into extern prelude. + (accepted, extern_crate_item_prelude, "1.31.0", Some(55599), None), ); // If you change this, please modify src/doc/unstable-book as well. You must @@ -709,7 +721,7 @@ impl AttributeGate { fn is_deprecated(&self) -> bool { match *self { - Gated(Stability::Deprecated(_), ..) => true, + Gated(Stability::Deprecated(_, _), ..) => true, _ => false, } } @@ -718,8 +730,9 @@ #[derive(Copy, Clone, Debug)] pub enum Stability { Unstable, - // Argument is tracking issue link. - Deprecated(&'static str), + // First argument is tracking issue link; second argument is an optional + // help message, which defaults to "remove this attribute" + Deprecated(&'static str, Option<&'static str>), } // fn() is not Debug @@ -803,6 +816,12 @@ "non exhaustive is an experimental feature", cfg_fn!(non_exhaustive))), + // RFC #1268 + ("marker", Normal, Gated(Stability::Unstable, + "marker_trait_attr", + "marker traits is an experimental feature", + cfg_fn!(marker_trait_attr))), + ("plugin", CrateLevel, Gated(Stability::Unstable, "plugin", "compiler plugins are experimental \ @@ -928,6 +947,12 @@ is just used for rustc unit tests \ and will never be stable", cfg_fn!(rustc_attrs))), + ("rustc_expected_cgu_reuse", Whitelisted, Gated(Stability::Unstable, + "rustc_attrs", + "this attribute \ + is just used for rustc unit tests \ + and will never be stable", + cfg_fn!(rustc_attrs))), ("rustc_synthetic", Whitelisted, Gated(Stability::Unstable, "rustc_attrs", "this attribute \ @@ -968,10 +993,6 @@ "the `#[rustc_test_marker]` attribute \ is used internally to track tests", cfg_fn!(rustc_attrs))), - ("rustc_test_marker2", Normal, Gated(Stability::Unstable, - "rustc_attrs", - "temporarily used by rustc to report some errors", - cfg_fn!(rustc_attrs))), ("rustc_transparent_macro", Whitelisted, Gated(Stability::Unstable, "rustc_attrs", "used internally for testing macro hygiene", @@ -1046,7 +1067,7 @@ ("no_builtins", Whitelisted, Ungated), ("no_mangle", Whitelisted, Ungated), ("no_debug", Whitelisted, Gated( - Stability::Deprecated("https://github.com/rust-lang/rust/issues/29721"), + Stability::Deprecated("https://github.com/rust-lang/rust/issues/29721", None), "no_debug", "the `#[no_debug]` attribute was an experimental feature that has been \ deprecated due to lack of demand", @@ -1059,7 +1080,8 @@ cfg_fn!(omit_gdb_pretty_printer_section))), ("unsafe_destructor_blind_to_params", Normal, - Gated(Stability::Deprecated("https://github.com/rust-lang/rust/issues/34761"), + Gated(Stability::Deprecated("https://github.com/rust-lang/rust/issues/34761", + Some("replace this attribute with `#[may_dangle]`")), "dropck_parametricity", "unsafe_destructor_blind_to_params has been replaced by \ may_dangle and will be removed in the future", @@ -1129,12 +1151,6 @@ cfg_fn!(rustc_attrs))), // RFC #2093 - ("infer_outlives_requirements", Normal, Gated(Stability::Unstable, - "infer_outlives_requirements", - "infer outlives requirements is an experimental feature", - cfg_fn!(infer_outlives_requirements))), - - // RFC #2093 ("infer_static_outlives_requirements", Normal, Gated(Stability::Unstable, "infer_static_outlives_requirements", "infer 'static lifetime requirements", @@ -1144,9 +1160,10 @@ ("panic_implementation", Normal, Gated(Stability::Deprecated("https://github.com/rust-lang/rust/issues/44489\ - #issuecomment-415140224"), + #issuecomment-415140224", + Some("replace this attribute with `#[panic_handler]`")), "panic_implementation", - "This attribute was renamed to `panic_handler`", + "this attribute was renamed to `panic_handler`", cfg_fn!(panic_implementation))), // RFC 2070 @@ -1501,31 +1518,6 @@ } } -impl<'a> PostExpansionVisitor<'a> { - fn whole_crate_feature_gates(&mut self, _krate: &ast::Crate) { - for &(ident, span) in &*self.context.parse_sess.non_modrs_mods.borrow() { - if !span.allows_unstable() { - let cx = &self.context; - let level = GateStrength::Hard; - let has_feature = cx.features.non_modrs_mods; - let name = "non_modrs_mods"; - debug!("gate_feature(feature = {:?}, span = {:?}); has? {}", - name, span, has_feature); - - if !has_feature && !span.allows_unstable() { - leveled_feature_err( - cx.parse_sess, name, span, GateIssue::Language, - "mod statements in non-mod.rs files are unstable", level - ) - .help(&format!("on stable builds, rename this file to {}{}mod.rs", - ident, path::MAIN_SEPARATOR)) - .emit(); - } - } - } - } -} - impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { fn visit_attribute(&mut self, attr: &ast::Attribute) { if !attr.span.allows_unstable() { @@ -1598,6 +1590,14 @@ } } + ast::ItemKind::Static(..) | + ast::ItemKind::Const(_,_) => { + if i.ident.name == "_" { + gate_feature_post!(&self, underscore_const_names, i.span, + "naming constants with `_` is unstable"); + } + } + ast::ItemKind::ForeignMod(ref foreign_module) => { self.check_abi(foreign_module.abi, i.span); } @@ -1797,10 +1797,6 @@ gate_feature_post!(&self, exclusive_range_pattern, pattern.span, "exclusive range pattern syntax is experimental"); } - PatKind::Paren(..) => { - gate_feature_post!(&self, pattern_parentheses, pattern.span, - "parentheses in patterns are unstable"); - } _ => {} } visit::walk_pat(self, pattern) @@ -1817,9 +1813,6 @@ if header.asyncness.is_async() { gate_feature_post!(&self, async_await, span, "async fn is unstable"); } - if header.constness.node == ast::Constness::Const { - gate_feature_post!(&self, min_const_fn, span, "const fn is unstable"); - } // stability of const fn methods are covered in // visit_trait_item and visit_impl_item below; this is // because default methods don't pass through this @@ -1874,11 +1867,7 @@ } match ii.node { - ast::ImplItemKind::Method(ref sig, _) => { - if sig.header.constness.node == ast::Constness::Const { - gate_feature_post!(&self, min_const_fn, ii.span, "const fn is unstable"); - } - } + ast::ImplItemKind::Method(..) => {} ast::ImplItemKind::Existential(..) => { gate_feature_post!( &self, @@ -1946,7 +1935,7 @@ let incomplete_features = ["generic_associated_types"]; let mut features = Features::new(); - let mut edition_enabled_features = FxHashMap(); + let mut edition_enabled_features = FxHashMap::default(); for &edition in ALL_EDITIONS { if edition <= crate_edition { @@ -2092,7 +2081,6 @@ }; let visitor = &mut PostExpansionVisitor { context: &ctx }; - visitor.whole_crate_feature_gates(krate); visit::walk_crate(visitor, krate); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/fold.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/fold.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/fold.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/fold.rs 2018-12-04 23:41:40.000000000 +0000 @@ -24,14 +24,24 @@ use source_map::{Spanned, respan}; use parse::token::{self, Token}; use ptr::P; -use OneVector; +use smallvec::{Array, SmallVec}; use symbol::keywords; use ThinVec; use tokenstream::*; use util::move_map::MoveMap; use rustc_data_structures::sync::Lrc; -use rustc_data_structures::small_vec::ExpectOne; + +pub trait ExpectOne { + fn expect_one(self, err: &'static str) -> A::Item; +} + +impl ExpectOne for SmallVec { + fn expect_one(self, err: &'static str) -> A::Item { + assert!(self.len() == 1, err); + self.into_iter().next().unwrap() + } +} pub trait Folder : Sized { // Any additions to this trait should happen in form @@ -62,7 +72,7 @@ noop_fold_use_tree(use_tree, self) } - fn fold_foreign_item(&mut self, ni: ForeignItem) -> OneVector { + fn fold_foreign_item(&mut self, ni: ForeignItem) -> SmallVec<[ForeignItem; 1]> { noop_fold_foreign_item(ni, self) } @@ -70,7 +80,7 @@ noop_fold_foreign_item_simple(ni, self) } - fn fold_item(&mut self, i: P) -> OneVector> { + fn fold_item(&mut self, i: P) -> SmallVec<[P; 1]> { noop_fold_item(i, self) } @@ -90,11 +100,11 @@ noop_fold_item_kind(i, self) } - fn fold_trait_item(&mut self, i: TraitItem) -> OneVector { + fn fold_trait_item(&mut self, i: TraitItem) -> SmallVec<[TraitItem; 1]> { noop_fold_trait_item(i, self) } - fn fold_impl_item(&mut self, i: ImplItem) -> OneVector { + fn fold_impl_item(&mut self, i: ImplItem) -> SmallVec<[ImplItem; 1]> { noop_fold_impl_item(i, self) } @@ -110,7 +120,7 @@ noop_fold_block(b, self) } - fn fold_stmt(&mut self, s: Stmt) -> OneVector { + fn fold_stmt(&mut self, s: Stmt) -> SmallVec<[Stmt; 1]> { noop_fold_stmt(s, self) } @@ -458,8 +468,9 @@ pub fn noop_fold_path(Path { segments, span }: Path, fld: &mut T) -> Path { Path { - segments: segments.move_map(|PathSegment { ident, args }| PathSegment { + segments: segments.move_map(|PathSegment { ident, id, args }| PathSegment { ident: fld.fold_ident(ident), + id: fld.new_id(id), args: args.map(|args| args.map(|args| fld.fold_generic_args(args))), }), span: fld.new_span(span) @@ -955,7 +966,7 @@ polarity, defaultness, folder.fold_generics(generics), - ifce.map(|trait_ref| folder.fold_trait_ref(trait_ref.clone())), + ifce.map(|trait_ref| folder.fold_trait_ref(trait_ref)), folder.fold_ty(ty), impl_items.move_flat_map(|item| folder.fold_impl_item(item)), ), @@ -974,8 +985,7 @@ } } -pub fn noop_fold_trait_item(i: TraitItem, folder: &mut T) - -> OneVector { +pub fn noop_fold_trait_item(i: TraitItem, folder: &mut T) -> SmallVec<[TraitItem; 1]> { smallvec![TraitItem { id: folder.new_id(i.id), ident: folder.fold_ident(i.ident), @@ -1003,8 +1013,7 @@ }] } -pub fn noop_fold_impl_item(i: ImplItem, folder: &mut T) - -> OneVector { +pub fn noop_fold_impl_item(i: ImplItem, folder: &mut T)-> SmallVec<[ImplItem; 1]> { smallvec![ImplItem { id: folder.new_id(i.id), vis: folder.fold_vis(i.vis), @@ -1036,10 +1045,11 @@ header } -pub fn noop_fold_mod(Mod {inner, items}: Mod, folder: &mut T) -> Mod { +pub fn noop_fold_mod(Mod {inner, items, inline}: Mod, folder: &mut T) -> Mod { Mod { inner: folder.new_span(inner), items: items.move_flat_map(|x| folder.fold_item(x)), + inline: inline, } } @@ -1069,6 +1079,7 @@ None => (ast::Mod { inner: span, items: vec![], + inline: true, }, vec![], span) }; @@ -1080,7 +1091,7 @@ } // fold one item into possibly many items -pub fn noop_fold_item(i: P, folder: &mut T) -> OneVector> { +pub fn noop_fold_item(i: P, folder: &mut T) -> SmallVec<[P; 1]> { smallvec![i.map(|i| folder.fold_item_simple(i))] } @@ -1102,7 +1113,8 @@ } pub fn noop_fold_foreign_item(ni: ForeignItem, folder: &mut T) --> OneVector { + -> SmallVec<[ForeignItem; 1]> +{ smallvec![folder.fold_foreign_item_simple(ni)] } @@ -1223,6 +1235,7 @@ ExprKind::MethodCall( PathSegment { ident: folder.fold_ident(seg.ident), + id: folder.new_id(seg.id), args: seg.args.map(|args| { args.map(|args| folder.fold_generic_args(args)) }), @@ -1381,7 +1394,8 @@ es.move_flat_map(|e| folder.fold_opt_expr(e)) } -pub fn noop_fold_stmt(Stmt {node, span, id}: Stmt, folder: &mut T) -> OneVector { +pub fn noop_fold_stmt(Stmt {node, span, id}: Stmt, folder: &mut T) -> SmallVec<[Stmt; 1]> +{ let id = folder.new_id(id); let span = folder.new_span(span); noop_fold_stmt_kind(node, folder).into_iter().map(|node| { @@ -1389,7 +1403,7 @@ }).collect() } -pub fn noop_fold_stmt_kind(node: StmtKind, folder: &mut T) -> OneVector { +pub fn noop_fold_stmt_kind(node: StmtKind, folder: &mut T) -> SmallVec<[StmtKind; 1]> { match node { StmtKind::Local(local) => smallvec![StmtKind::Local(folder.fold_local(local))], StmtKind::Item(item) => folder.fold_item(item).into_iter().map(StmtKind::Item).collect(), diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/lib.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -21,8 +21,7 @@ #![feature(crate_visibility_modifier)] #![feature(macro_at_most_once_rep)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(rustc_attrs)] #![feature(rustc_diagnostic_macros)] #![feature(slice_sort_by_cached_key)] @@ -47,8 +46,7 @@ extern crate serialize as rustc_serialize; // used by deriving use rustc_data_structures::sync::Lock; -use rustc_data_structures::bitvec::BitVector; -pub use rustc_data_structures::small_vec::OneVector; +use rustc_data_structures::bit_set::GrowableBitSet; pub use rustc_data_structures::thin_vec::ThinVec; use ast::AttrId; @@ -83,8 +81,8 @@ } pub struct Globals { - used_attrs: Lock>, - known_attrs: Lock>, + used_attrs: Lock>, + known_attrs: Lock>, syntax_pos_globals: syntax_pos::Globals, } @@ -93,8 +91,8 @@ Globals { // We have no idea how many attributes their will be, so just // initiate the vectors with 0 bits. We'll grow them as necessary. - used_attrs: Lock::new(BitVector::new()), - known_attrs: Lock::new(BitVector::new()), + used_attrs: Lock::new(GrowableBitSet::new_empty()), + known_attrs: Lock::new(GrowableBitSet::new_empty()), syntax_pos_globals: syntax_pos::Globals::new(), } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/parse/lexer/mod.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/parse/lexer/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/parse/lexer/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/parse/lexer/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -238,6 +238,19 @@ sr } + pub fn new_without_err(sess: &'a ParseSess, + source_file: Lrc, + override_span: Option, + prepend_error_text: &str) -> Result { + let mut sr = StringReader::new_raw(sess, source_file, override_span); + if sr.advance_token().is_err() { + eprintln!("{}", prepend_error_text); + sr.emit_fatal_errors(); + return Err(()); + } + Ok(sr) + } + pub fn retokenize(sess: &'a ParseSess, mut span: Span) -> Self { let begin = sess.source_map().lookup_byte_offset(span.lo()); let end = sess.source_map().lookup_byte_offset(span.hi()); diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/parse/mod.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/parse/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/parse/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/parse/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -230,7 +230,7 @@ match sess.source_map().load_file(path) { Ok(source_file) => source_file, Err(e) => { - let msg = format!("couldn't read {:?}: {}", path.display(), e); + let msg = format!("couldn't read {}: {}", path.display(), e); match spanopt { Some(sp) => sess.span_diagnostic.span_fatal(sp, &msg).raise(), None => sess.span_diagnostic.fatal(&msg).raise() diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/parse/parser.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/parse/parser.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/parse/parser.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/parse/parser.rs 2018-12-04 23:41:40.000000000 +0000 @@ -43,7 +43,7 @@ use ast::{RangeEnd, RangeSyntax}; use {ast, attr}; use source_map::{self, SourceMap, Spanned, respan}; -use syntax_pos::{self, Span, MultiSpan, BytePos, FileName, edition::Edition}; +use syntax_pos::{self, Span, MultiSpan, BytePos, FileName}; use errors::{self, Applicability, DiagnosticBuilder, DiagnosticId}; use parse::{self, SeqSep, classify, token}; use parse::lexer::TokenAndSpan; @@ -678,7 +678,7 @@ /// Expect next token to be edible or inedible token. If edible, /// then consume it; if inedible, then return without consuming /// anything. Signal a fatal error if next token is unexpected. - fn expect_one_of(&mut self, + pub fn expect_one_of(&mut self, edible: &[token::Token], inedible: &[token::Token]) -> PResult<'a, ()>{ fn tokens_to_string(tokens: &[TokenType]) -> String { @@ -772,6 +772,11 @@ // | expected one of 8 possible tokens here err.span_label(self.span, label_exp); } + _ if self.prev_span == syntax_pos::DUMMY_SP => { + // Account for macro context where the previous span might not be + // available to avoid incorrect output (#54841). + err.span_label(self.span, "unexpected token"); + } _ => { err.span_label(sp, label_exp); err.span_label(self.span, "unexpected token"); @@ -1398,11 +1403,7 @@ // definition... // We don't allow argument names to be left off in edition 2018. - if p.span.edition() >= Edition::Edition2018 { - p.parse_arg_general(true) - } else { - p.parse_arg_general(false) - } + p.parse_arg_general(p.span.rust_2018()) })?; generics.where_clause = self.parse_where_clause()?; @@ -1430,6 +1431,23 @@ attrs.extend(inner_attrs.iter().cloned()); Some(body) } + token::Interpolated(ref nt) => { + match &nt.0 { + token::NtBlock(..) => { + *at_end = true; + let (inner_attrs, body) = self.parse_inner_attrs_and_block()?; + attrs.extend(inner_attrs.iter().cloned()); + Some(body) + } + _ => { + let token_str = self.this_token_to_string(); + let mut err = self.fatal(&format!("expected `;` or `{{`, found `{}`", + token_str)); + err.span_label(self.span, "expected `;` or `{`"); + return Err(err); + } + } + } _ => { let token_str = self.this_token_to_string(); let mut err = self.fatal(&format!("expected `;` or `{{`, found `{}`", @@ -1578,8 +1596,9 @@ impl_dyn_multi = bounds.len() > 1 || self.prev_token_kind == PrevTokenKind::Plus; TyKind::ImplTrait(ast::DUMMY_NODE_ID, bounds) } else if self.check_keyword(keywords::Dyn) && - self.look_ahead(1, |t| t.can_begin_bound() && - !can_continue_type_after_non_fn_ident(t)) { + (self.span.rust_2018() || + self.look_ahead(1, |t| t.can_begin_bound() && + !can_continue_type_after_non_fn_ident(t))) { self.bump(); // `dyn` // Always parse bounds greedily for better error recovery. let bounds = self.parse_generic_bounds()?; @@ -1776,31 +1795,55 @@ require_name); let pat = self.parse_pat()?; - self.expect(&token::Colon)?; - (pat, self.parse_ty()?) - } else { - debug!("parse_arg_general ident_to_pat"); + if let Err(mut err) = self.expect(&token::Colon) { + // If we find a pattern followed by an identifier, it could be an (incorrect) + // C-style parameter declaration. + if self.check_ident() && self.look_ahead(1, |t| { + *t == token::Comma || *t == token::CloseDelim(token::Paren) + }) { + let ident = self.parse_ident().unwrap(); + let span = pat.span.with_hi(ident.span.hi()); - let parser_snapshot_before_pat = self.clone(); + err.span_suggestion_with_applicability( + span, + "declare the type after the parameter binding", + String::from(": "), + Applicability::HasPlaceholders, + ); + } - // Once we can use edition 2018 in the compiler, - // replace this with real try blocks. - macro_rules! try_block { - ($($inside:tt)*) => ( - (||{ ::std::ops::Try::from_ok({ $($inside)* }) })() - ) + return Err(err); } - // We're going to try parsing the argument as a pattern (even though it's not - // allowed). This way we can provide better errors to the user. - let pat_arg: PResult<'a, _> = try_block! { - let pat = self.parse_pat()?; - self.expect(&token::Colon)?; - (pat, self.parse_ty()?) - }; + (pat, self.parse_ty()?) + } else { + debug!("parse_arg_general ident_to_pat"); + let parser_snapshot_before_ty = self.clone(); + let mut ty = self.parse_ty(); + if ty.is_ok() && self.token == token::Colon { + // This wasn't actually a type, but a pattern looking like a type, + // so we are going to rollback and re-parse for recovery. + ty = self.unexpected(); + } + match ty { + Ok(ty) => { + let ident = Ident::new(keywords::Invalid.name(), self.prev_span); + let pat = P(Pat { + id: ast::DUMMY_NODE_ID, + node: PatKind::Ident( + BindingMode::ByValue(Mutability::Immutable), ident, None), + span: ty.span, + }); + (pat, ty) + } + Err(mut err) => { + // Recover from attempting to parse the argument as a type without pattern. + err.cancel(); + mem::replace(self, parser_snapshot_before_ty); + let pat = self.parse_pat()?; + self.expect(&token::Colon)?; + let ty = self.parse_ty()?; - match pat_arg { - Ok((pat, ty)) => { let mut err = self.diagnostic().struct_span_err_with_code( pat.span, "patterns aren't allowed in methods without bodies", @@ -1813,6 +1856,7 @@ Applicability::MachineApplicable, ); err.emit(); + // Pretend the pattern is `_`, to avoid duplicate errors from AST validation. let pat = P(Pat { node: PatKind::Wild, @@ -1821,22 +1865,6 @@ }); (pat, ty) } - Err(mut err) => { - err.cancel(); - // Recover from attempting to parse the argument as a pattern. This means - // the type is alone, with no name, e.g. `fn foo(u32)`. - mem::replace(self, parser_snapshot_before_pat); - debug!("parse_arg_general ident_to_pat"); - let ident = Ident::new(keywords::Invalid.name(), self.prev_span); - let ty = self.parse_ty()?; - let pat = P(Pat { - id: ast::DUMMY_NODE_ID, - node: PatKind::Ident( - BindingMode::ByValue(Mutability::Immutable), ident, None), - span: ty.span, - }); - (pat, ty) - } } }; @@ -1857,7 +1885,7 @@ P(Ty { id: ast::DUMMY_NODE_ID, node: TyKind::Infer, - span: self.span, + span: self.prev_span, }) }; Ok(Arg { @@ -2011,8 +2039,9 @@ let lo = self.meta_var_span.unwrap_or(self.span); let mut segments = Vec::new(); + let mod_sep_ctxt = self.span.ctxt(); if self.eat(&token::ModSep) { - segments.push(PathSegment::crate_root(lo.shrink_to_lo())); + segments.push(PathSegment::crate_root(lo.shrink_to_lo().with_ctxt(mod_sep_ctxt))); } self.parse_path_segments(&mut segments, style, enable_warning)?; @@ -2102,7 +2131,7 @@ ParenthesisedArgs { inputs, output, span }.into() }; - PathSegment { ident, args } + PathSegment { ident, args, id: ast::DUMMY_NODE_ID } } else { // Generic arguments are not found. PathSegment::from_ident(ident) @@ -2350,8 +2379,7 @@ hi = path.span; return Ok(self.mk_expr(lo.to(hi), ExprKind::Path(Some(qself), path), attrs)); } - if self.span.edition() >= Edition::Edition2018 && - self.check_keyword(keywords::Async) + if self.span.rust_2018() && self.check_keyword(keywords::Async) { if self.is_async_block() { // check for `async {` and `async move {` return self.parse_async_block(attrs); @@ -2702,8 +2730,8 @@ token::Literal(token::Float(n), _suf) => { self.bump(); let fstr = n.as_str(); - let mut err = self.diagnostic().struct_span_err(self.prev_span, - &format!("unexpected token: `{}`", n)); + let mut err = self.diagnostic() + .struct_span_err(self.prev_span, &format!("unexpected token: `{}`", n)); err.span_label(self.prev_span, "unexpected token"); if fstr.chars().all(|x| "0123456789.".contains(x)) { let float = match fstr.parse::().ok() { @@ -2863,8 +2891,8 @@ let e = self.parse_prefix_expr(None); let (span, e) = self.interpolated_or_expr_span(e)?; let span_of_tilde = lo; - let mut err = self.diagnostic().struct_span_err(span_of_tilde, - "`~` cannot be used as a unary operator"); + let mut err = self.diagnostic() + .struct_span_err(span_of_tilde, "`~` cannot be used as a unary operator"); err.span_suggestion_short_with_applicability( span_of_tilde, "use `!` to perform bitwise negation", @@ -3196,7 +3224,7 @@ })); let expr_str = self.sess.source_map().span_to_snippet(expr.span) - .unwrap_or(pprust::expr_to_string(&expr)); + .unwrap_or_else(|_| pprust::expr_to_string(&expr)); err.span_suggestion_with_applicability( expr.span, &format!("try {} the cast value", op_verb), @@ -3363,7 +3391,7 @@ } else { Movability::Movable }; - let asyncness = if self.span.edition() >= Edition::Edition2018 { + let asyncness = if self.span.rust_2018() { self.parse_asyncness() } else { IsAsync::NotAsync @@ -3422,6 +3450,24 @@ ); err.emit(); } + let in_span = self.prev_span; + if self.eat_keyword(keywords::In) { + // a common typo: `for _ in in bar {}` + let mut err = self.sess.span_diagnostic.struct_span_err( + self.prev_span, + "expected iterable, found keyword `in`", + ); + err.span_suggestion_short_with_applicability( + in_span.until(self.prev_span), + "remove the duplicated `in`", + String::new(), + Applicability::MachineApplicable, + ); + err.note("if you meant to use emplacement syntax, it is obsolete (for now, anyway)"); + err.note("for more information on the status of emplacement syntax, see <\ + https://github.com/rust-lang/rust/issues/27779#issuecomment-378416911>"); + err.emit(); + } let expr = self.parse_expr_res(Restrictions::NO_STRUCT_LITERAL, None)?; let (iattrs, loop_block) = self.parse_inner_attrs_and_block()?; attrs.extend(iattrs); @@ -3838,6 +3884,9 @@ // check that a comma comes after every field if !ate_comma { let err = self.struct_span_err(self.prev_span, "expected `,`"); + if let Some(mut delayed) = delayed_err { + delayed.emit(); + } return Err(err); } ate_comma = false; @@ -3882,7 +3931,12 @@ if self.token == token::CloseDelim(token::Brace) { // If the struct looks otherwise well formed, recover and continue. if let Some(sp) = comma_sp { - err.span_suggestion_short(sp, "remove this comma", String::new()); + err.span_suggestion_short_with_applicability( + sp, + "remove this comma", + String::new(), + Applicability::MachineApplicable, + ); } err.emit(); break; @@ -4450,9 +4504,7 @@ fn is_try_block(&mut self) -> bool { self.token.is_keyword(keywords::Try) && self.look_ahead(1, |t| *t == token::OpenDelim(token::Brace)) && - - self.span.edition() >= Edition::Edition2018 && - + self.span.rust_2018() && // prevent `while try {} {}`, `if try {} {} else {}`, etc. !self.restrictions.contains(Restrictions::NO_STRUCT_LITERAL) } @@ -4760,12 +4812,9 @@ if !self.eat(&token::OpenDelim(token::Brace)) { let sp = self.span; let tok = self.this_token_to_string(); - let mut do_not_suggest_help = false; let mut e = self.span_fatal(sp, &format!("expected `{{`, found `{}`", tok)); - if self.token.is_keyword(keywords::In) || self.token == token::Colon { - do_not_suggest_help = true; - e.span_label(sp, "expected `{`"); - } + let do_not_suggest_help = + self.token.is_keyword(keywords::In) || self.token == token::Colon; if self.token.is_ident_named("and") { e.span_suggestion_short_with_applicability( @@ -4796,6 +4845,7 @@ || do_not_suggest_help { // if the next token is an open brace (e.g., `if a b {`), the place- // inside-a-block suggestion would be more likely wrong than right + e.span_label(sp, "expected `{`"); return Err(e); } let mut stmt_span = stmt.span; @@ -6285,11 +6335,18 @@ Ok(ast::Mod { inner: inner_lo.to(hi), items, + inline: true }) } fn parse_item_const(&mut self, m: Option) -> PResult<'a, ItemInfo> { - let id = self.parse_ident()?; + let id = match self.token { + token::Ident(ident, false) if ident.name == keywords::Underscore.name() => { + self.bump(); // `_` + ident.gensym() + }, + _ => self.parse_ident()?, + }; self.expect(&token::Colon)?; let ty = self.parse_ty()?; self.expect(&token::Eq)?; @@ -6322,6 +6379,7 @@ self.submod_path(id, &outer_attrs, id_span)?; let (module, mut attrs) = self.eval_src_mod(path, directory_ownership, id.to_string(), id_span)?; + // Record that we fetched the mod from an external file if warn { let attr = Attribute { id: attr::mk_attr_id(), @@ -6334,9 +6392,13 @@ attr::mark_known(&attr); attrs.push(attr); } - Ok((id, module, Some(attrs))) + Ok((id, ItemKind::Mod(module), Some(attrs))) } else { - let placeholder = ast::Mod { inner: syntax_pos::DUMMY_SP, items: Vec::new() }; + let placeholder = ast::Mod { + inner: syntax_pos::DUMMY_SP, + items: Vec::new(), + inline: false + }; Ok((id, ItemKind::Mod(placeholder), None)) } } else { @@ -6358,6 +6420,17 @@ self.directory.path.to_mut().push(&path.as_str()); self.directory.ownership = DirectoryOwnership::Owned { relative: None }; } else { + // We have to push on the current module name in the case of relative + // paths in order to ensure that any additional module paths from inline + // `mod x { ... }` come after the relative extension. + // + // For example, a `mod z { ... }` inside `x/y.rs` should set the current + // directory path to `/x/y/z`, not `/x/z` with a relative offset of `y`. + if let DirectoryOwnership::Owned { relative } = &mut self.directory.ownership { + if let Some(ident) = relative.take() { // remove the relative offset + self.directory.path.to_mut().push(ident.as_str()); + } + } self.directory.path.to_mut().push(&id.as_str()); } } @@ -6536,7 +6609,7 @@ directory_ownership: DirectoryOwnership, name: String, id_sp: Span) - -> PResult<'a, (ast::ItemKind, Vec )> { + -> PResult<'a, (ast::Mod, Vec )> { let mut included_mod_stack = self.sess.included_mod_stack.borrow_mut(); if let Some(i) = included_mod_stack.iter().position(|p| *p == path) { let mut err = String::from("circular modules: "); @@ -6556,9 +6629,10 @@ p0.cfg_mods = self.cfg_mods; let mod_inner_lo = p0.span; let mod_attrs = p0.parse_inner_attributes()?; - let m0 = p0.parse_mod_items(&token::Eof, mod_inner_lo)?; + let mut m0 = p0.parse_mod_items(&token::Eof, mod_inner_lo)?; + m0.inline = false; self.sess.included_mod_stack.borrow_mut().pop(); - Ok((ast::ItemKind::Mod(m0), mod_attrs)) + Ok((m0, mod_attrs)) } /// Parse a function declaration from a foreign module @@ -6699,10 +6773,9 @@ attrs.extend(self.parse_inner_attributes()?); let mut foreign_items = vec![]; - while let Some(item) = self.parse_foreign_item()? { - foreign_items.push(item); + while !self.eat(&token::CloseDelim(token::Brace)) { + foreign_items.push(self.parse_foreign_item()?); } - self.expect(&token::CloseDelim(token::Brace))?; let prev_span = self.prev_span; let m = ast::ForeignMod { @@ -7286,8 +7359,8 @@ } /// Parse a foreign item. - crate fn parse_foreign_item(&mut self) -> PResult<'a, Option> { - maybe_whole!(self, NtForeignItem, |ni| Some(ni)); + crate fn parse_foreign_item(&mut self) -> PResult<'a, ForeignItem> { + maybe_whole!(self, NtForeignItem, |ni| ni); let attrs = self.parse_outer_attributes()?; let lo = self.span; @@ -7307,20 +7380,20 @@ ).emit(); } self.bump(); // `static` or `const` - return Ok(Some(self.parse_item_foreign_static(visibility, lo, attrs)?)); + return Ok(self.parse_item_foreign_static(visibility, lo, attrs)?); } // FOREIGN FUNCTION ITEM if self.check_keyword(keywords::Fn) { - return Ok(Some(self.parse_item_foreign_fn(visibility, lo, attrs)?)); + return Ok(self.parse_item_foreign_fn(visibility, lo, attrs)?); } // FOREIGN TYPE ITEM if self.check_keyword(keywords::Type) { - return Ok(Some(self.parse_item_foreign_type(visibility, lo, attrs)?)); + return Ok(self.parse_item_foreign_type(visibility, lo, attrs)?); } match self.parse_assoc_macro_invoc("extern", Some(&visibility), &mut false)? { Some(mac) => { - Ok(Some( + Ok( ForeignItem { ident: keywords::Invalid.ident(), span: lo.to(self.prev_span), @@ -7329,14 +7402,14 @@ vis: visibility, node: ForeignItemKind::Macro(mac), } - )) + ) } None => { - if !attrs.is_empty() { + if !attrs.is_empty() { self.expected_item_err(&attrs); } - Ok(None) + self.unexpected() } } } @@ -7520,8 +7593,11 @@ self.check(&token::BinOp(token::Star)) || self.is_import_coupler() { // `use *;` or `use ::*;` or `use {...};` or `use ::{...};` + let mod_sep_ctxt = self.span.ctxt(); if self.eat(&token::ModSep) { - prefix.segments.push(PathSegment::crate_root(lo.shrink_to_lo())); + prefix.segments.push( + PathSegment::crate_root(lo.shrink_to_lo().with_ctxt(mod_sep_ctxt)) + ); } if self.eat(&token::BinOp(token::Star)) { diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/parse/token.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/parse/token.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/parse/token.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/parse/token.rs 2018-12-04 23:41:40.000000000 +0000 @@ -136,6 +136,7 @@ keywords::Unsafe.name(), keywords::Extern.name(), keywords::Typeof.name(), + keywords::Dyn.name(), ].contains(&ident.name) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/print/pprust.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/print/pprust.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/print/pprust.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/print/pprust.rs 2018-12-04 23:41:40.000000000 +0000 @@ -61,6 +61,7 @@ cur_cmnt: usize, boxes: Vec, ann: &'a (dyn PpAnn+'a), + is_expanded: bool } fn rust_printer<'a>(writer: Box, ann: &'a dyn PpAnn) -> State<'a> { @@ -72,6 +73,7 @@ cur_cmnt: 0, boxes: Vec::new(), ann, + is_expanded: false } } @@ -133,14 +135,17 @@ // If the code is post expansion, don't use the table of // literals, since it doesn't correspond with the literals // in the AST anymore. - if is_expanded { None } else { Some(lits) }) + if is_expanded { None } else { Some(lits) }, + is_expanded + ) } pub fn new(cm: &'a SourceMap, out: Box, ann: &'a dyn PpAnn, comments: Option>, - literals: Option>) -> State<'a> { + literals: Option>, + is_expanded: bool) -> State<'a> { State { s: pp::mk_printer(out, DEFAULT_COLUMNS), cm: Some(cm), @@ -149,6 +154,7 @@ cur_cmnt: 0, boxes: Vec::new(), ann, + is_expanded: is_expanded } } } @@ -1260,10 +1266,18 @@ ast::ItemKind::Mod(ref _mod) => { self.head(&visibility_qualified(&item.vis, "mod"))?; self.print_ident(item.ident)?; - self.nbsp()?; - self.bopen()?; - self.print_mod(_mod, &item.attrs)?; - self.bclose(item.span)?; + + if _mod.inline || self.is_expanded { + self.nbsp()?; + self.bopen()?; + self.print_mod(_mod, &item.attrs)?; + self.bclose(item.span)?; + } else { + self.s.word(";")?; + self.end()?; // end inner head-block + self.end()?; // end outer head-block + } + } ast::ItemKind::ForeignMod(ref nmod) => { self.head("extern")?; @@ -2214,6 +2228,9 @@ self.word_nbsp("async")?; self.print_capture_clause(capture_clause)?; self.s.space()?; + // cbox/ibox in analogy to the `ExprKind::Block` arm above + self.cbox(INDENT_UNIT)?; + self.ibox(0)?; self.print_block_with_attrs(blk, attrs)?; } ast::ExprKind::Assign(ref lhs, ref rhs) => { @@ -3102,7 +3119,7 @@ if cmnt.style != comments::Trailing { return Ok(()) } let span_line = cm.lookup_char_pos(span.hi()); let comment_line = cm.lookup_char_pos(cmnt.pos); - let next = next_pos.unwrap_or(cmnt.pos + BytePos(1)); + let next = next_pos.unwrap_or_else(|| cmnt.pos + BytePos(1)); if span.hi() < cmnt.pos && cmnt.pos < next && span_line.line == comment_line.line { self.print_comment(cmnt)?; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/source_map.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/source_map.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/source_map.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/source_map.rs 2018-12-04 23:41:40.000000000 +0000 @@ -124,6 +124,7 @@ // SourceMap // +#[derive(Default)] pub(super) struct SourceMapFiles { pub(super) file_maps: Vec>, stable_id_to_source_file: FxHashMap> @@ -143,10 +144,7 @@ impl SourceMap { pub fn new(path_mapping: FilePathMapping) -> SourceMap { SourceMap { - files: Lock::new(SourceMapFiles { - file_maps: Vec::new(), - stable_id_to_source_file: FxHashMap(), - }), + files: Default::default(), file_loader: Box::new(RealFileLoader), path_mapping, doctest_offset: None, @@ -166,10 +164,7 @@ path_mapping: FilePathMapping) -> SourceMap { SourceMap { - files: Lock::new(SourceMapFiles { - file_maps: Vec::new(), - stable_id_to_source_file: FxHashMap(), - }), + files: Default::default(), file_loader: file_loader, path_mapping, doctest_offset: None, @@ -942,7 +937,8 @@ } else { format!("{}<", &snippet[..offset]) }; - new_snippet.push_str(&self.span_to_snippet(span).unwrap_or("T".to_string())); + new_snippet.push_str( + &self.span_to_snippet(span).unwrap_or_else(|_| "T".to_string())); new_snippet.push('>'); return Some((sugg_span, new_snippet)); diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/test.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/test.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/test.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -33,15 +33,14 @@ use fold::Folder; use feature_gate::Features; use util::move_map::MoveMap; -use fold; +use fold::{self, ExpectOne}; use parse::{token, ParseSess}; use print::pprust; use ast::{self, Ident}; use ptr::P; -use OneVector; +use smallvec::SmallVec; use symbol::{self, Symbol, keywords}; use ThinVec; -use rustc_data_structures::small_vec::ExpectOne; struct Test { span: Span, @@ -113,7 +112,7 @@ folded } - fn fold_item(&mut self, i: P) -> OneVector> { + fn fold_item(&mut self, i: P) -> SmallVec<[P; 1]> { let ident = i.ident; if ident.name != keywords::Invalid.name() { self.cx.path.push(ident); @@ -171,7 +170,7 @@ } impl fold::Folder for EntryPointCleaner { - fn fold_item(&mut self, i: P) -> OneVector> { + fn fold_item(&mut self, i: P) -> SmallVec<[P; 1]> { self.depth += 1; let folded = fold::noop_fold_item(i, self).expect_one("noop did something"); self.depth -= 1; @@ -238,6 +237,7 @@ })).collect(); let reexport_mod = ast::Mod { + inline: true, inner: DUMMY_SP, items, }; @@ -346,7 +346,7 @@ test_runner.span = sp; - let test_main_path_expr = ecx.expr_path(test_runner.clone()); + let test_main_path_expr = ecx.expr_path(test_runner); let call_test_main = ecx.expr_call(sp, test_main_path_expr, vec![mk_tests_slice(cx)]); let call_test_main = ecx.stmt_expr(call_test_main); diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/tokenstream.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/tokenstream.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/tokenstream.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/tokenstream.rs 2018-12-04 23:41:40.000000000 +0000 @@ -606,7 +606,7 @@ CursorKind::JointTree(ref tree, _) => tree.clone().joint(), CursorKind::Stream(ref cursor) => TokenStream::concat_rc_vec({ cursor.stack.get(0).cloned().map(|(stream, _)| stream) - .unwrap_or(cursor.stream.clone()) + .unwrap_or_else(|| cursor.stream.clone()) }), } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax/util/move_map.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax/util/move_map.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax/util/move_map.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax/util/move_map.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,7 +9,7 @@ // except according to those terms. use std::ptr; -use OneVector; +use smallvec::{Array, SmallVec}; pub trait MoveMap: Sized { fn move_map(self, mut f: F) -> Self where F: FnMut(T) -> T { @@ -77,7 +77,7 @@ } } -impl MoveMap for OneVector { +impl> MoveMap for SmallVec { fn move_flat_map(mut self, mut f: F) -> Self where F: FnMut(T) -> I, I: IntoIterator diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax_ext/deriving/cmp/partial_ord.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax_ext/deriving/cmp/partial_ord.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax_ext/deriving/cmp/partial_ord.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax_ext/deriving/cmp/partial_ord.rs 2018-12-04 23:41:40.000000000 +0000 @@ -178,7 +178,7 @@ cx.expr_match(span, new, vec![eq_arm, neq_arm]) }, - equals_expr.clone(), + equals_expr, Box::new(|cx, span, (self_args, tag_tuple), _non_self_args| { if self_args.len() != 2 { cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`") diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax_ext/deriving/custom.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax_ext/deriving/custom.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax_ext/deriving/custom.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax_ext/deriving/custom.rs 2018-12-04 23:41:40.000000000 +0000 @@ -75,7 +75,7 @@ // Mark attributes as known, and used. MarkAttrs(&self.attrs).visit_item(&item); - let input = __internal::new_token_stream(ecx.resolver.eliminate_crate_var(item.clone())); + let input = __internal::new_token_stream(ecx.resolver.eliminate_crate_var(item)); let res = __internal::set_sess(ecx, || { let inner = self.inner; panic::catch_unwind(panic::AssertUnwindSafe(|| inner(input))) diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax_ext/format.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax_ext/format.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax_ext/format.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax_ext/format.rs 2018-12-04 23:41:40.000000000 +0000 @@ -996,9 +996,10 @@ )); } if suggestions.len() > 0 { - diag.multipart_suggestion( + diag.multipart_suggestion_with_applicability( "format specifiers use curly braces", suggestions, + Applicability::MachineApplicable, ); } }}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax_ext/lib.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax_ext/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax_ext/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax_ext/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,8 +16,7 @@ #![feature(proc_macro_internals)] #![feature(decl_macro)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(str_escape)] #![feature(quote)] #![feature(rustc_diagnostic_macros)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax_ext/test.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax_ext/test.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax_ext/test.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax_ext/test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -49,7 +49,7 @@ // If we're not in test configuration, remove the annotated item if !cx.ecfg.should_test { return vec![]; } - let mut item = + let item = if let Annotatable::Item(i) = item { i } else { cx.parse_sess.span_diagnostic.span_fatal(item.span(), @@ -192,12 +192,6 @@ debug!("Synthetic test item:\n{}\n", pprust::item_to_string(&test_const)); - // Temporarily add another marker to the original item for error reporting - let marker2 = cx.attribute( - attr_sp, cx.meta_word(attr_sp, Symbol::intern("rustc_test_marker2")) - ); - item.attrs.push(marker2); - vec![ // Access to libtest under a gensymed name Annotatable::Item(test_extern), diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax_pos/edition.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax_pos/edition.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax_pos/edition.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax_pos/edition.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,7 +12,7 @@ use std::str::FromStr; /// The edition of the compiler (RFC 2052) -#[derive(Clone, Copy, Hash, PartialEq, PartialOrd, Debug, RustcEncodable, RustcDecodable)] +#[derive(Clone, Copy, Hash, PartialEq, PartialOrd, Debug, RustcEncodable, RustcDecodable, Eq)] #[non_exhaustive] pub enum Edition { // editions must be kept in order, oldest to newest @@ -65,7 +65,7 @@ pub fn is_stable(&self) -> bool { match *self { Edition::Edition2015 => true, - Edition::Edition2018 => false, + Edition::Edition2018 => true, } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax_pos/hygiene.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax_pos/hygiene.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax_pos/hygiene.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax_pos/hygiene.rs 2018-12-04 23:41:40.000000000 +0000 @@ -156,7 +156,7 @@ pub fn least_ancestor(mut a: Mark, mut b: Mark) -> Mark { HygieneData::with(|data| { // Compute the path from a to the root - let mut a_path = FxHashSet::(); + let mut a_path = FxHashSet::::default(); while a != Mark::root() { a_path.insert(a); a = data.marks[a.0 as usize].parent; diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax_pos/lib.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax_pos/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax_pos/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax_pos/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -21,12 +21,11 @@ #![feature(const_fn)] #![feature(crate_visibility_modifier)] #![feature(custom_attribute)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(non_exhaustive)] #![feature(optin_builtin_traits)] #![feature(specialization)] -#![feature(stdsimd)] +#![cfg_attr(not(stage0), feature(stdsimd))] use std::borrow::Cow; use std::cell::Cell; @@ -326,6 +325,16 @@ |einfo| einfo.edition) } + #[inline] + pub fn rust_2015(&self) -> bool { + self.edition() == edition::Edition::Edition2015 + } + + #[inline] + pub fn rust_2018(&self) -> bool { + self.edition() >= edition::Edition::Edition2018 + } + /// Return the source callee. /// /// Returns `None` if the supplied span has no expansion trace, diff -Nru rustc-1.30.0+dfsg1+llvm/src/libsyntax_pos/symbol.rs rustc-1.31.0+dfsg1+llvm/src/libsyntax_pos/symbol.rs --- rustc-1.30.0+dfsg1+llvm/src/libsyntax_pos/symbol.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libsyntax_pos/symbol.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,7 +12,6 @@ //! allows bidirectional lookup; i.e. given a value, one can easily find the //! type, and vice versa. -use edition::Edition; use hygiene::SyntaxContext; use {Span, DUMMY_SP, GLOBALS}; @@ -224,6 +223,7 @@ } // The &'static strs in this type actually point into the arena +#[derive(Default)] pub struct Interner { arena: DroplessArena, names: FxHashMap<&'static str, Symbol>, @@ -232,17 +232,8 @@ } impl Interner { - pub fn new() -> Self { - Interner { - arena: DroplessArena::new(), - names: Default::default(), - strings: Default::default(), - gensyms: Default::default(), - } - } - fn prefill(init: &[&str]) -> Self { - let mut this = Interner::new(); + let mut this = Interner::default(); for &string in init { if string == "" { // We can't allocate empty strings in the arena, so handle this here @@ -414,26 +405,25 @@ (50, Yield, "yield") // Edition-specific keywords reserved for future use. - (51, Async, "async") // >= 2018 Edition Only - (52, Try, "try") // >= 2018 Edition Only + (51, Async, "async") // >= 2018 Edition only + (52, Dyn, "dyn") // >= 2018 Edition only + (53, Try, "try") // >= 2018 Edition only // Special lifetime names - (53, UnderscoreLifetime, "'_") - (54, StaticLifetime, "'static") + (54, UnderscoreLifetime, "'_") + (55, StaticLifetime, "'static") // Weak keywords, have special meaning only in specific contexts. - (55, Auto, "auto") - (56, Catch, "catch") - (57, Default, "default") - (58, Dyn, "dyn") + (56, Auto, "auto") + (57, Catch, "catch") + (58, Default, "default") (59, Union, "union") (60, Existential, "existential") } impl Symbol { fn is_unused_keyword_2018(self) -> bool { - self >= keywords::Async.name() && - self <= keywords::Try.name() + self >= keywords::Async.name() && self <= keywords::Try.name() } } @@ -453,7 +443,7 @@ pub fn is_unused_keyword(self) -> bool { // Note: `span.edition()` is relatively expensive, don't call it unless necessary. self.name >= keywords::Abstract.name() && self.name <= keywords::Yield.name() || - self.name.is_unused_keyword_2018() && self.span.edition() == Edition::Edition2018 + self.name.is_unused_keyword_2018() && self.span.rust_2018() } /// Returns `true` if the token is either a special identifier or a keyword. @@ -698,7 +688,7 @@ #[test] fn interner_tests() { - let mut i: Interner = Interner::new(); + let mut i: Interner = Interner::default(); // first one is zero: assert_eq!(i.intern("dog"), Symbol(0)); // re-use gets the same entry: diff -Nru rustc-1.30.0+dfsg1+llvm/src/libterm/lib.rs rustc-1.31.0+dfsg1+llvm/src/libterm/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/libterm/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libterm/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -50,8 +50,7 @@ #![cfg_attr(windows, feature(libc))] // Handle rustfmt skips #![feature(custom_attribute)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![allow(unused_attributes)] use std::io::prelude::*; diff -Nru rustc-1.30.0+dfsg1+llvm/src/libtest/lib.rs rustc-1.31.0+dfsg1+llvm/src/libtest/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/libtest/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libtest/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -35,8 +35,7 @@ #![feature(asm)] #![feature(fnbox)] #![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc))] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(set_stdio)] #![feature(panic_unwind)] #![feature(staged_api)] @@ -46,9 +45,17 @@ extern crate getopts; #[cfg(any(unix, target_os = "cloudabi"))] extern crate libc; -extern crate panic_unwind; extern crate term; +// FIXME(#54291): rustc and/or LLVM don't yet support building with panic-unwind +// on aarch64-pc-windows-msvc, so we don't link libtest against +// libunwind (for the time being), even though it means that +// libtest won't be fully functional on this platform. +// +// See also: https://github.com/rust-lang/rust/issues/54190#issuecomment-422904437 +#[cfg(not(all(windows, target_arch = "aarch64")))] +extern crate panic_unwind; + pub use self::TestFn::*; pub use self::ColorConfig::*; pub use self::TestResult::*; diff -Nru rustc-1.30.0+dfsg1+llvm/src/libunwind/lib.rs rustc-1.31.0+dfsg1+llvm/src/libunwind/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/libunwind/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/libunwind/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,8 +13,7 @@ #![feature(cfg_target_vendor)] #![feature(link_cfg)] -#![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] +#![feature(nll)] #![feature(staged_api)] #![feature(unwind_attributes)] #![feature(static_nobundle)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/llvm/lib/Target/PowerPC/PPCISelLowering.cpp rustc-1.31.0+dfsg1+llvm/src/llvm/lib/Target/PowerPC/PPCISelLowering.cpp --- rustc-1.30.0+dfsg1+llvm/src/llvm/lib/Target/PowerPC/PPCISelLowering.cpp 2018-09-11 18:51:23.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/llvm/lib/Target/PowerPC/PPCISelLowering.cpp 2018-09-15 20:17:01.000000000 +0000 @@ -3510,9 +3510,14 @@ // Argument stored in memory. assert(VA.isMemLoc()); + // Get the extended size of the argument type in stack unsigned ArgSize = VA.getLocVT().getStoreSize(); - int FI = MFI.CreateFixedObject(ArgSize, VA.getLocMemOffset(), - isImmutable); + // Get the actual size of the argument type + unsigned ObjSize = VA.getValVT().getStoreSize(); + unsigned ArgOffset = VA.getLocMemOffset(); + // Stack objects in PPC32 are right justified. + ArgOffset += ArgSize - ObjSize; + int FI = MFI.CreateFixedObject(ArgSize, ArgOffset, isImmutable); // Create load nodes to retrieve arguments from the stack. SDValue FIN = DAG.getFrameIndex(FI, PtrVT); @@ -5467,10 +5472,15 @@ Arg = PtrOff; } - if (VA.isRegLoc()) { - if (Arg.getValueType() == MVT::i1) - Arg = DAG.getNode(ISD::ZERO_EXTEND, dl, MVT::i32, Arg); + // When useCRBits() is true, there can be i1 arguments. + // It is because getRegisterType(MVT::i1) => MVT::i1, + // and for other integer types getRegisterType() => MVT::i32. + // Extend i1 and ensure callee will get i32. + if (Arg.getValueType() == MVT::i1) + Arg = DAG.getNode(Flags.isSExt() ? ISD::SIGN_EXTEND : ISD::ZERO_EXTEND, + dl, MVT::i32, Arg); + if (VA.isRegLoc()) { seenFloatArg |= VA.getLocVT().isFloatingPoint(); // Put argument in a physical register. RegsToPass.push_back(std::make_pair(VA.getLocReg(), Arg)); diff -Nru rustc-1.30.0+dfsg1+llvm/src/rustllvm/llvm-rebuild-trigger rustc-1.31.0+dfsg1+llvm/src/rustllvm/llvm-rebuild-trigger --- rustc-1.30.0+dfsg1+llvm/src/rustllvm/llvm-rebuild-trigger 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/rustllvm/llvm-rebuild-trigger 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ # 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-09-11 +2018-09-16 diff -Nru rustc-1.30.0+dfsg1+llvm/src/rustllvm/PassWrapper.cpp rustc-1.31.0+dfsg1+llvm/src/rustllvm/PassWrapper.cpp --- rustc-1.30.0+dfsg1+llvm/src/rustllvm/PassWrapper.cpp 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/rustllvm/PassWrapper.cpp 2018-12-04 23:41:40.000000000 +0000 @@ -373,7 +373,8 @@ bool DataSections, bool TrapUnreachable, bool Singlethread, - bool AsmComments) { + bool AsmComments, + bool EmitStackSizeSection) { auto OptLevel = fromRust(RustOptLevel); auto RM = fromRust(RustReloc); @@ -411,6 +412,8 @@ } #if LLVM_VERSION_GE(6, 0) + Options.EmitStackSizeSection = EmitStackSizeSection; + Optional CM; #else CodeModel::Model CM = CodeModel::Model::Default; diff -Nru rustc-1.30.0+dfsg1+llvm/src/rustllvm/rustllvm.h rustc-1.31.0+dfsg1+llvm/src/rustllvm/rustllvm.h --- rustc-1.30.0+dfsg1+llvm/src/rustllvm/rustllvm.h 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/rustllvm/rustllvm.h 2018-12-04 23:41:40.000000000 +0000 @@ -97,6 +97,7 @@ SanitizeThread = 20, SanitizeAddress = 21, SanitizeMemory = 22, + NonLazyBind = 23, }; typedef struct OpaqueRustString *RustStringRef; diff -Nru rustc-1.30.0+dfsg1+llvm/src/rustllvm/RustWrapper.cpp rustc-1.31.0+dfsg1+llvm/src/rustllvm/RustWrapper.cpp --- rustc-1.30.0+dfsg1+llvm/src/rustllvm/RustWrapper.cpp 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/rustllvm/RustWrapper.cpp 2018-12-04 23:41:40.000000000 +0000 @@ -17,6 +17,7 @@ #include "llvm/Object/Archive.h" #include "llvm/Object/ObjectFile.h" #include "llvm/Bitcode/BitcodeWriterPass.h" +#include "llvm/Support/Signals.h" #include "llvm/IR/CallSite.h" @@ -26,6 +27,8 @@ #include #endif +#include + //===----------------------------------------------------------------------=== // // This file defines alternate interfaces to core functions that are more @@ -62,6 +65,27 @@ static LLVM_THREAD_LOCAL char *LastError; +// Custom error handler for fatal LLVM errors. +// +// Notably it exits the process with code 101, unlike LLVM's default of 1. +static void FatalErrorHandler(void *UserData, + const std::string& Reason, + bool GenCrashDiag) { + // Do the same thing that the default error handler does. + std::cerr << "LLVM ERROR: " << Reason << std::endl; + + // Since this error handler exits the process, we have to run any cleanup that + // LLVM would run after handling the error. This might change with an LLVM + // upgrade. + sys::RunInterruptHandlers(); + + exit(101); +} + +extern "C" void LLVMRustInstallFatalErrorHandler() { + install_fatal_error_handler(FatalErrorHandler); +} + extern "C" LLVMMemoryBufferRef LLVMRustCreateMemoryBufferWithContentsOfFile(const char *Path) { ErrorOr> BufOr = @@ -178,6 +202,8 @@ return Attribute::SanitizeAddress; case SanitizeMemory: return Attribute::SanitizeMemory; + case NonLazyBind: + return Attribute::NonLazyBind; } report_fatal_error("bad AttributeKind"); } @@ -426,6 +452,11 @@ HasSideEffects, IsAlignStack, fromRust(Dialect))); } +extern "C" bool LLVMRustInlineAsmVerify(LLVMTypeRef Ty, + char *Constraints) { + return InlineAsm::Verify(unwrap(Ty), Constraints); +} + extern "C" void LLVMRustAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm) { unwrap(M)->appendModuleInlineAsm(StringRef(Asm)); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/stage0.txt rustc-1.31.0+dfsg1+llvm/src/stage0.txt --- rustc-1.30.0+dfsg1+llvm/src/stage0.txt 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stage0.txt 2018-12-04 23:41:40.000000000 +0000 @@ -12,9 +12,9 @@ # source tarball for a stable release you'll likely see `1.x.0` for rustc and # `0.x.0` for Cargo where they were released on `date`. -date: 2018-10-12 -rustc: 1.29.2 -cargo: 0.30.0 +date: 2018-10-25 +rustc: 1.30.0 +cargo: 0.31.0 # When making a stable release the process currently looks like: # diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/.appveyor.yml rustc-1.31.0+dfsg1+llvm/src/stdsimd/.appveyor.yml --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/.appveyor.yml 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/.appveyor.yml 2018-12-04 23:42:58.000000000 +0000 @@ -10,7 +10,7 @@ install: # Install rust, x86_64-pc-windows-msvc host - appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe - - rustup-init.exe -y --default-host x86_64-pc-windows-msvc --default-toolchain nightly + - rustup-init.exe -y --default-host x86_64-pc-windows-msvc --default-toolchain nightly-2018-10-20 - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin - if NOT "%TARGET%" == "x86_64-pc-windows-msvc" rustup target add %TARGET% - rustc -vV diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/stdsimd/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/Cargo.toml 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/Cargo.toml 2018-12-04 23:42:58.000000000 +0000 @@ -3,6 +3,9 @@ "crates/stdsimd-verify", "crates/stdsimd", ] +exclude = [ + "crates/wasm-assert-instr-tests" +] [profile.release] debug = true diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/ci/docker/wasm32-unknown-unknown/Dockerfile rustc-1.31.0+dfsg1+llvm/src/stdsimd/ci/docker/wasm32-unknown-unknown/Dockerfile --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/ci/docker/wasm32-unknown-unknown/Dockerfile 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/ci/docker/wasm32-unknown-unknown/Dockerfile 2018-12-04 23:42:58.000000000 +0000 @@ -0,0 +1,27 @@ +FROM ubuntu:18.04 + +RUN apt-get update -y && apt-get install -y --no-install-recommends \ + ca-certificates \ + clang \ + cmake \ + curl \ + git \ + libc6-dev \ + make \ + python \ + xz-utils + +# Install `wasm2wat` +RUN git clone --recursive https://github.com/WebAssembly/wabt +RUN make -C wabt -j$(nproc) +ENV PATH=$PATH:/wabt/bin + +# Install `wasm-bindgen-test-runner` +RUN curl -L https://github.com/rustwasm/wasm-bindgen/releases/download/0.2.19/wasm-bindgen-0.2.19-x86_64-unknown-linux-musl.tar.gz \ + | tar xzf - +ENV PATH=$PATH:/wasm-bindgen-0.2.19-x86_64-unknown-linux-musl +ENV CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-bindgen-test-runner + +# Install `node` +RUN curl https://nodejs.org/dist/v10.8.0/node-v10.8.0-linux-x64.tar.xz | tar xJf - +ENV PATH=$PATH:/node-v10.8.0-linux-x64/bin diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/ci/dox.sh rustc-1.31.0+dfsg1+llvm/src/stdsimd/ci/dox.sh --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/ci/dox.sh 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/ci/dox.sh 2018-12-04 23:42:58.000000000 +0000 @@ -44,6 +44,7 @@ dox powerpc64le powerpc64le-unknown-linux-gnu dox mips mips-unknown-linux-gnu dox mips64 mips64-unknown-linux-gnuabi64 +dox wasm32 wasm32-unknown-unknown # If we're on travis, not a PR, and on the right branch, publish! if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/ci/run-docker.sh rustc-1.31.0+dfsg1+llvm/src/stdsimd/ci/run-docker.sh --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/ci/run-docker.sh 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/ci/run-docker.sh 2018-12-04 23:42:58.000000000 +0000 @@ -13,8 +13,8 @@ --user `id -u`:`id -g` \ --rm \ --init \ - --volume $HOME/.cargo:/cargo \ - --env CARGO_HOME=/cargo \ + --volume $HOME/.cargo:/cargo-h \ + --env CARGO_HOME=/cargo-h \ --volume `rustc --print sysroot`:/rust:ro \ --env TARGET=$target \ --env STDSIMD_TEST_EVERYTHING \ @@ -25,7 +25,7 @@ --privileged \ stdsimd \ bash \ - -c 'PATH=$PATH:/rust/bin exec ci/run.sh' + -c 'PATH=/rust/bin:$PATH exec ci/run.sh' } if [ -z "$1" ]; then diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/ci/run.sh rustc-1.31.0+dfsg1+llvm/src/stdsimd/ci/run.sh --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/ci/run.sh 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/ci/run.sh 2018-12-04 23:42:58.000000000 +0000 @@ -33,8 +33,11 @@ # instruction assertion checks to pass below the 20 instruction limit. If # this is the default, dynamic, then too many instructions are generated # when we assert the instruction for a function and it causes tests to fail. + # + # It's not clear why `-Z plt=yes` is required here. Probably a bug in LLVM. + # If you can remove it and CI passes, please feel free to do so! i686-* | i586-*) - export RUSTFLAGS="${RUSTFLAGS} -C relocation-model=static" + export RUSTFLAGS="${RUSTFLAGS} -C relocation-model=static -Z plt=yes" ;; *android*) export STDSIMD_DISABLE_ASSERT_INSTR=1 @@ -59,13 +62,17 @@ cargo_test cargo_test "--release" -# Test x86 targets compiled with AVX. +# Test targets compiled with extra features. case ${TARGET} in x86*) RUSTFLAGS="${RUSTFLAGS} -C target-feature=+avx" export STDSIMD_DISABLE_ASSERT_INSTR=1 cargo_test "--release" ;; + wasm32-unknown-unknown*) + # export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+simd128" + cargo_test "--release --features=wasm_simd128" + ;; *) ;; esac diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/aarch64/crypto.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/aarch64/crypto.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/aarch64/crypto.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/aarch64/crypto.rs 2018-12-04 23:42:58.000000000 +0000 @@ -191,8 +191,12 @@ #[simd_test(enable = "crypto")] unsafe fn test_vaeseq_u8() { - let data = ::mem::transmute(u8x16::new(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8)); - let key = ::mem::transmute(u8x16::new(0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7)); + let data = ::mem::transmute(u8x16::new( + 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, + )); + let key = ::mem::transmute(u8x16::new( + 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, + )); let r: u8x16 = ::mem::transmute(vaeseq_u8(data, key)); assert_eq!( r, @@ -205,8 +209,12 @@ #[simd_test(enable = "crypto")] unsafe fn test_vaesdq_u8() { - let data = ::mem::transmute(u8x16::new(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8)); - let key = ::mem::transmute(u8x16::new(0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7)); + let data = ::mem::transmute(u8x16::new( + 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, + )); + let key = ::mem::transmute(u8x16::new( + 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, + )); let r: u8x16 = ::mem::transmute(vaesdq_u8(data, key)); assert_eq!( r, @@ -218,7 +226,9 @@ #[simd_test(enable = "crypto")] unsafe fn test_vaesmcq_u8() { - let data = ::mem::transmute(u8x16::new(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8)); + let data = ::mem::transmute(u8x16::new( + 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, + )); let r: u8x16 = ::mem::transmute(vaesmcq_u8(data)); assert_eq!( r, @@ -228,7 +238,9 @@ #[simd_test(enable = "crypto")] unsafe fn test_vaesimcq_u8() { - let data = ::mem::transmute(u8x16::new(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8)); + let data = ::mem::transmute(u8x16::new( + 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, + )); let r: u8x16 = ::mem::transmute(vaesimcq_u8(data)); assert_eq!( r, @@ -248,9 +260,15 @@ #[simd_test(enable = "crypto")] unsafe fn test_vsha1su0q_u32() { let r: u32x4 = ::mem::transmute(vsha1su0q_u32( - ::mem::transmute(u32x4::new(0x1234_u32, 0x5678_u32, 0x9abc_u32, 0xdef0_u32)), - ::mem::transmute(u32x4::new(0x1234_u32, 0x5678_u32, 0x9abc_u32, 0xdef0_u32)), - ::mem::transmute(u32x4::new(0x1234_u32, 0x5678_u32, 0x9abc_u32, 0xdef0_u32)), + ::mem::transmute(u32x4::new( + 0x1234_u32, 0x5678_u32, 0x9abc_u32, 0xdef0_u32, + )), + ::mem::transmute(u32x4::new( + 0x1234_u32, 0x5678_u32, 0x9abc_u32, 0xdef0_u32, + )), + ::mem::transmute(u32x4::new( + 0x1234_u32, 0x5678_u32, 0x9abc_u32, 0xdef0_u32, + )), )); assert_eq!(r, u32x4::new(0x9abc, 0xdef0, 0x1234, 0x5678)); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/aarch64/neon.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/aarch64/neon.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/aarch64/neon.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/aarch64/neon.rs 2018-12-04 23:42:58.000000000 +0000 @@ -1,9 +1,11 @@ //! ARMv8 ASIMD intrinsics +#![allow(non_camel_case_types)] + // FIXME: replace neon with asimd use coresimd::arm::*; -use coresimd::simd_llvm::simd_add; +use coresimd::simd_llvm::*; #[cfg(test)] use stdsimd_test::assert_instr; @@ -12,7 +14,56 @@ pub struct float64x1_t(f64); // FIXME: check this! /// ARM-specific 128-bit wide vector of two packed `f64`. pub struct float64x2_t(f64, f64); -} + /// ARM-specific 64-bit wide vector of one packed `p64`. + pub struct poly64x1_t(i64); // FIXME: check this! + /// ARM-specific 64-bit wide vector of two packed `p64`. + pub struct poly64x2_t(i64, i64); // FIXME: check this! +} + +/// ARM-specific type containing two `int8x16_t` vectors. +#[derive(Copy, Clone)] +pub struct int8x16x2_t(pub int8x16_t, pub int8x16_t); +/// ARM-specific type containing three `int8x16_t` vectors. +#[derive(Copy, Clone)] +pub struct int8x16x3_t(pub int8x16_t, pub int8x16_t, pub int8x16_t); +/// ARM-specific type containing four `int8x16_t` vectors. +#[derive(Copy, Clone)] +pub struct int8x16x4_t( + pub int8x16_t, + pub int8x16_t, + pub int8x16_t, + pub int8x16_t, +); + +/// ARM-specific type containing two `uint8x16_t` vectors. +#[derive(Copy, Clone)] +pub struct uint8x16x2_t(pub uint8x16_t, pub uint8x16_t); +/// ARM-specific type containing three `uint8x16_t` vectors. +#[derive(Copy, Clone)] +pub struct uint8x16x3_t(pub uint8x16_t, pub uint8x16_t, pub uint8x16_t); +/// ARM-specific type containing four `uint8x16_t` vectors. +#[derive(Copy, Clone)] +pub struct uint8x16x4_t( + pub uint8x16_t, + pub uint8x16_t, + pub uint8x16_t, + pub uint8x16_t, +); + +/// ARM-specific type containing two `poly8x16_t` vectors. +#[derive(Copy, Clone)] +pub struct poly8x16x2_t(pub poly8x16_t, pub poly8x16_t); +/// ARM-specific type containing three `poly8x16_t` vectors. +#[derive(Copy, Clone)] +pub struct poly8x16x3_t(pub poly8x16_t, pub poly8x16_t, pub poly8x16_t); +/// ARM-specific type containing four `poly8x16_t` vectors. +#[derive(Copy, Clone)] +pub struct poly8x16x4_t( + pub poly8x16_t, + pub poly8x16_t, + pub poly8x16_t, + pub poly8x16_t, +); #[allow(improper_ctypes)] extern "C" { @@ -115,6 +166,71 @@ fn vpmaxq_f32_(a: float32x4_t, b: float32x4_t) -> float32x4_t; #[link_name = "llvm.aarch64.neon.fmaxp.v2f64"] fn vpmaxq_f64_(a: float64x2_t, b: float64x2_t) -> float64x2_t; + + #[link_name = "llvm.aarch64.neon.tbl1.v8i8"] + fn vqtbl1(a: int8x16_t, b: uint8x8_t) -> int8x8_t; + #[link_name = "llvm.aarch64.neon.tbl1.v16i8"] + fn vqtbl1q(a: int8x16_t, b: uint8x16_t) -> int8x16_t; + + #[link_name = "llvm.aarch64.neon.tbx1.v8i8"] + fn vqtbx1(a: int8x8_t, b: int8x16_t, c: uint8x8_t) -> int8x8_t; + #[link_name = "llvm.aarch64.neon.tbx1.v16i8"] + fn vqtbx1q(a: int8x16_t, b: int8x16_t, c: uint8x16_t) -> int8x16_t; + + #[link_name = "llvm.aarch64.neon.tbl2.v8i8"] + fn vqtbl2(a0: int8x16_t, a1: int8x16_t, b: uint8x8_t) -> int8x8_t; + #[link_name = "llvm.aarch64.neon.tbl2.v16i8"] + fn vqtbl2q(a0: int8x16_t, a1: int8x16_t, b: uint8x16_t) -> int8x16_t; + + #[link_name = "llvm.aarch64.neon.tbx2.v8i8"] + fn vqtbx2( + a: int8x8_t, b0: int8x16_t, b1: int8x16_t, c: uint8x8_t, + ) -> int8x8_t; + #[link_name = "llvm.aarch64.neon.tbx2.v16i8"] + fn vqtbx2q( + a: int8x16_t, b0: int8x16_t, b1: int8x16_t, c: uint8x16_t, + ) -> int8x16_t; + + #[link_name = "llvm.aarch64.neon.tbl3.v8i8"] + fn vqtbl3( + a0: int8x16_t, a1: int8x16_t, a2: int8x16_t, b: uint8x8_t, + ) -> int8x8_t; + #[link_name = "llvm.aarch64.neon.tbl3.v16i8"] + fn vqtbl3q( + a0: int8x16_t, a1: int8x16_t, a2: int8x16_t, b: uint8x16_t, + ) -> int8x16_t; + + #[link_name = "llvm.aarch64.neon.tbx3.v8i8"] + fn vqtbx3( + a: int8x8_t, b0: int8x16_t, b1: int8x16_t, b2: int8x16_t, c: uint8x8_t, + ) -> int8x8_t; + #[link_name = "llvm.aarch64.neon.tbx3.v16i8"] + fn vqtbx3q( + a: int8x16_t, b0: int8x16_t, b1: int8x16_t, b2: int8x16_t, + c: uint8x16_t, + ) -> int8x16_t; + + #[link_name = "llvm.aarch64.neon.tbl4.v8i8"] + fn vqtbl4( + a0: int8x16_t, a1: int8x16_t, a2: int8x16_t, a3: int8x16_t, + b: uint8x8_t, + ) -> int8x8_t; + #[link_name = "llvm.aarch64.neon.tbl4.v16i8"] + fn vqtbl4q( + a0: int8x16_t, a1: int8x16_t, a2: int8x16_t, a3: int8x16_t, + b: uint8x16_t, + ) -> int8x16_t; + + #[link_name = "llvm.aarch64.neon.tbx4.v8i8"] + fn vqtbx4( + a: int8x8_t, b0: int8x16_t, b1: int8x16_t, b2: int8x16_t, + b3: int8x16_t, c: uint8x8_t, + ) -> int8x8_t; + #[link_name = "llvm.aarch64.neon.tbx4.v16i8"] + fn vqtbx4q( + a: int8x16_t, b0: int8x16_t, b1: int8x16_t, b2: int8x16_t, + b3: int8x16_t, c: uint8x16_t, + ) -> int8x16_t; } /// Vector add. @@ -517,6 +633,1008 @@ vpmaxq_f64_(a, b) } +/// Vector combine +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(mov))] +pub unsafe fn vcombine_s8(low: int8x8_t, high: int8x8_t) -> int8x16_t { + simd_shuffle16( + low, + high, + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + ) +} + +/// Vector combine +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(mov))] +pub unsafe fn vcombine_s16(low: int16x4_t, high: int16x4_t) -> int16x8_t { + simd_shuffle8(low, high, [0, 1, 2, 3, 4, 5, 6, 7]) +} + +/// Vector combine +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(mov))] +pub unsafe fn vcombine_s32(low: int32x2_t, high: int32x2_t) -> int32x4_t { + simd_shuffle4(low, high, [0, 1, 2, 3]) +} + +/// Vector combine +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(mov))] +pub unsafe fn vcombine_s64(low: int64x1_t, high: int64x1_t) -> int64x2_t { + simd_shuffle2(low, high, [0, 1]) +} + +/// Vector combine +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(mov))] +pub unsafe fn vcombine_u8(low: uint8x8_t, high: uint8x8_t) -> uint8x16_t { + simd_shuffle16( + low, + high, + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + ) +} + +/// Vector combine +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(mov))] +pub unsafe fn vcombine_u16(low: uint16x4_t, high: uint16x4_t) -> uint16x8_t { + simd_shuffle8(low, high, [0, 1, 2, 3, 4, 5, 6, 7]) +} + +/// Vector combine +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(mov))] +pub unsafe fn vcombine_u32(low: uint32x2_t, high: uint32x2_t) -> uint32x4_t { + simd_shuffle4(low, high, [0, 1, 2, 3]) +} + +/// Vector combine +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(mov))] +pub unsafe fn vcombine_u64(low: uint64x1_t, high: uint64x1_t) -> uint64x2_t { + simd_shuffle2(low, high, [0, 1]) +} + +/// Vector combine +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(mov))] +pub unsafe fn vcombine_p64(low: poly64x1_t, high: poly64x1_t) -> poly64x2_t { + simd_shuffle2(low, high, [0, 1]) +} + +/* FIXME: 16-bit float +/// Vector combine +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(mov))] +pub unsafe fn vcombine_f16 ( low: float16x4_t, high: float16x4_t) -> float16x8_t { + simd_shuffle8(low, high, [0, 1, 2, 3, 4, 5, 6, 7]) +} +*/ + +/// Vector combine +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(mov))] +pub unsafe fn vcombine_f32( + low: float32x2_t, high: float32x2_t, +) -> float32x4_t { + simd_shuffle4(low, high, [0, 1, 2, 3]) +} + +/// Vector combine +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(mov))] +pub unsafe fn vcombine_p8(low: poly8x8_t, high: poly8x8_t) -> poly8x16_t { + simd_shuffle16( + low, + high, + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + ) +} + +/// Vector combine +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(mov))] +pub unsafe fn vcombine_p16(low: poly16x4_t, high: poly16x4_t) -> poly16x8_t { + simd_shuffle8(low, high, [0, 1, 2, 3, 4, 5, 6, 7]) +} + +/// Vector combine +#[inline] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(mov))] +pub unsafe fn vcombine_f64( + low: float64x1_t, high: float64x1_t, +) -> float64x2_t { + simd_shuffle2(low, high, [0, 1]) +} + +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vtbl1_s8(a: int8x8_t, b: int8x8_t) -> int8x8_t { + vqtbl1_s8(vcombine_s8(a, ::mem::zeroed()), ::mem::transmute(b)) +} + +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vtbl1_u8(a: uint8x8_t, b: uint8x8_t) -> uint8x8_t { + vqtbl1_u8(vcombine_u8(a, ::mem::zeroed()), b) +} + +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vtbl1_p8(a: poly8x8_t, b: uint8x8_t) -> poly8x8_t { + vqtbl1_p8(vcombine_p8(a, ::mem::zeroed()), b) +} + +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vtbl2_s8(a: int8x8x2_t, b: int8x8_t) -> int8x8_t { + vqtbl1_s8(vcombine_s8(a.0, a.1), ::mem::transmute(b)) +} + +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vtbl2_u8(a: uint8x8x2_t, b: uint8x8_t) -> uint8x8_t { + vqtbl1_u8(vcombine_u8(a.0, a.1), b) +} + +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vtbl2_p8(a: poly8x8x2_t, b: uint8x8_t) -> poly8x8_t { + vqtbl1_p8(vcombine_p8(a.0, a.1), b) +} + +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vtbl3_s8(a: int8x8x3_t, b: int8x8_t) -> int8x8_t { + vqtbl2_s8( + int8x16x2_t(vcombine_s8(a.0, a.1), vcombine_s8(a.2, ::mem::zeroed())), + ::mem::transmute(b), + ) +} + +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vtbl3_u8(a: uint8x8x3_t, b: uint8x8_t) -> uint8x8_t { + vqtbl2_u8( + uint8x16x2_t(vcombine_u8(a.0, a.1), vcombine_u8(a.2, ::mem::zeroed())), + b, + ) +} + +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vtbl3_p8(a: poly8x8x3_t, b: uint8x8_t) -> poly8x8_t { + vqtbl2_p8( + poly8x16x2_t(vcombine_p8(a.0, a.1), vcombine_p8(a.2, ::mem::zeroed())), + b, + ) +} + +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vtbl4_s8(a: int8x8x4_t, b: int8x8_t) -> int8x8_t { + vqtbl2_s8( + int8x16x2_t(vcombine_s8(a.0, a.1), vcombine_s8(a.2, a.3)), + ::mem::transmute(b), + ) +} + +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vtbl4_u8(a: uint8x8x4_t, b: uint8x8_t) -> uint8x8_t { + vqtbl2_u8( + uint8x16x2_t(vcombine_u8(a.0, a.1), vcombine_u8(a.2, a.3)), + b, + ) +} + +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vtbl4_p8(a: poly8x8x4_t, b: uint8x8_t) -> poly8x8_t { + vqtbl2_p8( + poly8x16x2_t(vcombine_p8(a.0, a.1), vcombine_p8(a.2, a.3)), + b, + ) +} + +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vtbx1_s8(a: int8x8_t, b: int8x8_t, c: int8x8_t) -> int8x8_t { + use coresimd::simd::i8x8; + let r = vqtbx1_s8(a, vcombine_s8(b, ::mem::zeroed()), ::mem::transmute(c)); + let m: int8x8_t = simd_lt(c, ::mem::transmute(i8x8::splat(8))); + simd_select(m, r, a) +} + +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vtbx1_u8(a: uint8x8_t, b: uint8x8_t, c: uint8x8_t) -> uint8x8_t { + use coresimd::simd::u8x8; + let r = vqtbx1_u8(a, vcombine_u8(b, ::mem::zeroed()), c); + let m: int8x8_t = simd_lt(c, ::mem::transmute(u8x8::splat(8))); + simd_select(m, r, a) +} + +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vtbx1_p8(a: poly8x8_t, b: poly8x8_t, c: uint8x8_t) -> poly8x8_t { + use coresimd::simd::u8x8; + let r = vqtbx1_p8(a, vcombine_p8(b, ::mem::zeroed()), c); + let m: int8x8_t = simd_lt(c, ::mem::transmute(u8x8::splat(8))); + simd_select(m, r, a) +} + +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vtbx2_s8(a: int8x8_t, b: int8x8x2_t, c: int8x8_t) -> int8x8_t { + vqtbx1_s8(a, vcombine_s8(b.0, b.1), ::mem::transmute(c)) +} + +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vtbx2_u8( + a: uint8x8_t, b: uint8x8x2_t, c: uint8x8_t, +) -> uint8x8_t { + vqtbx1_u8(a, vcombine_u8(b.0, b.1), c) +} + +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vtbx2_p8( + a: poly8x8_t, b: poly8x8x2_t, c: uint8x8_t, +) -> poly8x8_t { + vqtbx1_p8(a, vcombine_p8(b.0, b.1), c) +} + +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vtbx3_s8(a: int8x8_t, b: int8x8x3_t, c: int8x8_t) -> int8x8_t { + use coresimd::simd::i8x8; + let r = vqtbx2_s8( + a, + int8x16x2_t(vcombine_s8(b.0, b.1), vcombine_s8(b.2, ::mem::zeroed())), + ::mem::transmute(c), + ); + let m: int8x8_t = simd_lt(c, ::mem::transmute(i8x8::splat(24))); + simd_select(m, r, a) +} + +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vtbx3_u8( + a: uint8x8_t, b: uint8x8x3_t, c: uint8x8_t, +) -> uint8x8_t { + use coresimd::simd::u8x8; + let r = vqtbx2_u8( + a, + uint8x16x2_t(vcombine_u8(b.0, b.1), vcombine_u8(b.2, ::mem::zeroed())), + c, + ); + let m: int8x8_t = simd_lt(c, ::mem::transmute(u8x8::splat(24))); + simd_select(m, r, a) +} + +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vtbx3_p8( + a: poly8x8_t, b: poly8x8x3_t, c: uint8x8_t, +) -> poly8x8_t { + use coresimd::simd::u8x8; + let r = vqtbx2_p8( + a, + poly8x16x2_t(vcombine_p8(b.0, b.1), vcombine_p8(b.2, ::mem::zeroed())), + c, + ); + let m: int8x8_t = simd_lt(c, ::mem::transmute(u8x8::splat(24))); + simd_select(m, r, a) +} + +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vtbx4_s8(a: int8x8_t, b: int8x8x4_t, c: int8x8_t) -> int8x8_t { + vqtbx2_s8( + a, + int8x16x2_t(vcombine_s8(b.0, b.1), vcombine_s8(b.2, b.3)), + ::mem::transmute(c), + ) +} + +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vtbx4_u8( + a: uint8x8_t, b: uint8x8x4_t, c: uint8x8_t, +) -> uint8x8_t { + vqtbx2_u8( + a, + uint8x16x2_t(vcombine_u8(b.0, b.1), vcombine_u8(b.2, b.3)), + c, + ) +} + +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vtbx4_p8( + a: poly8x8_t, b: poly8x8x4_t, c: uint8x8_t, +) -> poly8x8_t { + vqtbx2_p8( + a, + poly8x16x2_t(vcombine_p8(b.0, b.1), vcombine_p8(b.2, b.3)), + c, + ) +} + +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl1_s8(t: int8x16_t, idx: uint8x8_t) -> int8x8_t { + vqtbl1(t, idx) +} +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl1q_s8(t: int8x16_t, idx: uint8x16_t) -> int8x16_t { + vqtbl1q(t, idx) +} +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl1_u8(t: uint8x16_t, idx: uint8x8_t) -> uint8x8_t { + ::mem::transmute(vqtbl1(::mem::transmute(t), ::mem::transmute(idx))) +} +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl1q_u8(t: uint8x16_t, idx: uint8x16_t) -> uint8x16_t { + ::mem::transmute(vqtbl1q(::mem::transmute(t), ::mem::transmute(idx))) +} +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl1_p8(t: poly8x16_t, idx: uint8x8_t) -> poly8x8_t { + ::mem::transmute(vqtbl1(::mem::transmute(t), ::mem::transmute(idx))) +} +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl1q_p8(t: poly8x16_t, idx: uint8x16_t) -> poly8x16_t { + ::mem::transmute(vqtbl1q(::mem::transmute(t), ::mem::transmute(idx))) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx1_s8( + a: int8x8_t, t: int8x16_t, idx: uint8x8_t, +) -> int8x8_t { + vqtbx1(a, t, idx) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx1q_s8( + a: int8x16_t, t: int8x16_t, idx: uint8x16_t, +) -> int8x16_t { + vqtbx1q(a, t, idx) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx1_u8( + a: uint8x8_t, t: uint8x16_t, idx: uint8x8_t, +) -> uint8x8_t { + ::mem::transmute(vqtbx1( + ::mem::transmute(a), + ::mem::transmute(t), + ::mem::transmute(idx), + )) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx1q_u8( + a: uint8x16_t, t: uint8x16_t, idx: uint8x16_t, +) -> uint8x16_t { + ::mem::transmute(vqtbx1q( + ::mem::transmute(a), + ::mem::transmute(t), + ::mem::transmute(idx), + )) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx1_p8( + a: poly8x8_t, t: poly8x16_t, idx: uint8x8_t, +) -> poly8x8_t { + ::mem::transmute(vqtbx1( + ::mem::transmute(a), + ::mem::transmute(t), + ::mem::transmute(idx), + )) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx1q_p8( + a: poly8x16_t, t: poly8x16_t, idx: uint8x16_t, +) -> poly8x16_t { + ::mem::transmute(vqtbx1q( + ::mem::transmute(a), + ::mem::transmute(t), + ::mem::transmute(idx), + )) +} + +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl2_s8(t: int8x16x2_t, idx: uint8x8_t) -> int8x8_t { + vqtbl2(t.0, t.1, idx) +} +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl2q_s8(t: int8x16x2_t, idx: uint8x16_t) -> int8x16_t { + vqtbl2q(t.0, t.1, idx) +} +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl2_u8(t: uint8x16x2_t, idx: uint8x8_t) -> uint8x8_t { + ::mem::transmute(vqtbl2( + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(idx), + )) +} +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl2q_u8(t: uint8x16x2_t, idx: uint8x16_t) -> uint8x16_t { + ::mem::transmute(vqtbl2q( + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(idx), + )) +} +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl2_p8(t: poly8x16x2_t, idx: uint8x8_t) -> poly8x8_t { + ::mem::transmute(vqtbl2( + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(idx), + )) +} +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl2q_p8(t: poly8x16x2_t, idx: uint8x16_t) -> poly8x16_t { + ::mem::transmute(vqtbl2q( + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(idx), + )) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx2_s8( + a: int8x8_t, t: int8x16x2_t, idx: uint8x8_t, +) -> int8x8_t { + vqtbx2(a, t.0, t.1, idx) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx2q_s8( + a: int8x16_t, t: int8x16x2_t, idx: uint8x16_t, +) -> int8x16_t { + vqtbx2q(a, t.0, t.1, idx) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx2_u8( + a: uint8x8_t, t: uint8x16x2_t, idx: uint8x8_t, +) -> uint8x8_t { + ::mem::transmute(vqtbx2( + ::mem::transmute(a), + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(idx), + )) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx2q_u8( + a: uint8x16_t, t: uint8x16x2_t, idx: uint8x16_t, +) -> uint8x16_t { + ::mem::transmute(vqtbx2q( + ::mem::transmute(a), + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(idx), + )) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx2_p8( + a: poly8x8_t, t: poly8x16x2_t, idx: uint8x8_t, +) -> poly8x8_t { + ::mem::transmute(vqtbx2( + ::mem::transmute(a), + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(idx), + )) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx2q_p8( + a: poly8x16_t, t: poly8x16x2_t, idx: uint8x16_t, +) -> poly8x16_t { + ::mem::transmute(vqtbx2q( + ::mem::transmute(a), + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(idx), + )) +} + +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl3_s8(t: int8x16x3_t, idx: uint8x8_t) -> int8x8_t { + vqtbl3(t.0, t.1, t.2, idx) +} +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl3q_s8(t: int8x16x3_t, idx: uint8x16_t) -> int8x16_t { + vqtbl3q(t.0, t.1, t.2, idx) +} +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl3_u8(t: uint8x16x3_t, idx: uint8x8_t) -> uint8x8_t { + ::mem::transmute(vqtbl3( + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(t.2), + ::mem::transmute(idx), + )) +} +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl3q_u8(t: uint8x16x3_t, idx: uint8x16_t) -> uint8x16_t { + ::mem::transmute(vqtbl3q( + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(t.2), + ::mem::transmute(idx), + )) +} +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl3_p8(t: poly8x16x3_t, idx: uint8x8_t) -> poly8x8_t { + ::mem::transmute(vqtbl3( + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(t.2), + ::mem::transmute(idx), + )) +} +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl3q_p8(t: poly8x16x3_t, idx: uint8x16_t) -> poly8x16_t { + ::mem::transmute(vqtbl3q( + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(t.2), + ::mem::transmute(idx), + )) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx3_s8( + a: int8x8_t, t: int8x16x3_t, idx: uint8x8_t, +) -> int8x8_t { + vqtbx3(a, t.0, t.1, t.2, idx) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx3q_s8( + a: int8x16_t, t: int8x16x3_t, idx: uint8x16_t, +) -> int8x16_t { + vqtbx3q(a, t.0, t.1, t.2, idx) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx3_u8( + a: uint8x8_t, t: uint8x16x3_t, idx: uint8x8_t, +) -> uint8x8_t { + ::mem::transmute(vqtbx3( + ::mem::transmute(a), + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(t.2), + ::mem::transmute(idx), + )) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx3q_u8( + a: uint8x16_t, t: uint8x16x3_t, idx: uint8x16_t, +) -> uint8x16_t { + ::mem::transmute(vqtbx3q( + ::mem::transmute(a), + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(t.2), + ::mem::transmute(idx), + )) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx3_p8( + a: poly8x8_t, t: poly8x16x3_t, idx: uint8x8_t, +) -> poly8x8_t { + ::mem::transmute(vqtbx3( + ::mem::transmute(a), + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(t.2), + ::mem::transmute(idx), + )) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx3q_p8( + a: poly8x16_t, t: poly8x16x3_t, idx: uint8x16_t, +) -> poly8x16_t { + ::mem::transmute(vqtbx3q( + ::mem::transmute(a), + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(t.2), + ::mem::transmute(idx), + )) +} + +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl4_s8(t: int8x16x4_t, idx: uint8x8_t) -> int8x8_t { + vqtbl4(t.0, t.1, t.2, t.3, idx) +} +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl4q_s8(t: int8x16x4_t, idx: uint8x16_t) -> int8x16_t { + vqtbl4q(t.0, t.1, t.2, t.3, idx) +} +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl4_u8(t: uint8x16x4_t, idx: uint8x8_t) -> uint8x8_t { + ::mem::transmute(vqtbl4( + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(t.2), + ::mem::transmute(t.3), + ::mem::transmute(idx), + )) +} +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl4q_u8(t: uint8x16x4_t, idx: uint8x16_t) -> uint8x16_t { + ::mem::transmute(vqtbl4q( + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(t.2), + ::mem::transmute(t.3), + ::mem::transmute(idx), + )) +} +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl4_p8(t: poly8x16x4_t, idx: uint8x8_t) -> poly8x8_t { + ::mem::transmute(vqtbl4( + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(t.2), + ::mem::transmute(t.3), + ::mem::transmute(idx), + )) +} +/// Table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbl))] +pub unsafe fn vqtbl4q_p8(t: poly8x16x4_t, idx: uint8x16_t) -> poly8x16_t { + ::mem::transmute(vqtbl4q( + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(t.2), + ::mem::transmute(t.3), + ::mem::transmute(idx), + )) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx4_s8( + a: int8x8_t, t: int8x16x4_t, idx: uint8x8_t, +) -> int8x8_t { + vqtbx4(a, t.0, t.1, t.2, t.3, idx) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx4q_s8( + a: int8x16_t, t: int8x16x4_t, idx: uint8x16_t, +) -> int8x16_t { + vqtbx4q(a, t.0, t.1, t.2, t.3, idx) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx4_u8( + a: uint8x8_t, t: uint8x16x4_t, idx: uint8x8_t, +) -> uint8x8_t { + ::mem::transmute(vqtbx4( + ::mem::transmute(a), + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(t.2), + ::mem::transmute(t.3), + ::mem::transmute(idx), + )) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx4q_u8( + a: uint8x16_t, t: uint8x16x4_t, idx: uint8x16_t, +) -> uint8x16_t { + ::mem::transmute(vqtbx4q( + ::mem::transmute(a), + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(t.2), + ::mem::transmute(t.3), + ::mem::transmute(idx), + )) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx4_p8( + a: poly8x8_t, t: poly8x16x4_t, idx: uint8x8_t, +) -> poly8x8_t { + ::mem::transmute(vqtbx4( + ::mem::transmute(a), + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(t.2), + ::mem::transmute(t.3), + ::mem::transmute(idx), + )) +} +/// Extended table look-up +#[inline] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon")] +#[cfg_attr(test, assert_instr(tbx))] +pub unsafe fn vqtbx4q_p8( + a: poly8x16_t, t: poly8x16x4_t, idx: uint8x16_t, +) -> poly8x16_t { + ::mem::transmute(vqtbx4q( + ::mem::transmute(a), + ::mem::transmute(t.0), + ::mem::transmute(t.1), + ::mem::transmute(t.2), + ::mem::transmute(t.3), + ::mem::transmute(idx), + )) +} + #[cfg(test)] mod tests { use coresimd::aarch64::*; @@ -539,7 +1657,10 @@ let a = f64x2::new(1., 2.); let b = f64x2::new(8., 7.); let e = f64x2::new(9., 9.); - let r: f64x2 = ::mem::transmute(vaddq_f64(::mem::transmute(a), ::mem::transmute(b))); + let r: f64x2 = ::mem::transmute(vaddq_f64( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -589,7 +1710,8 @@ #[simd_test(enable = "neon")] unsafe fn test_vmaxvq_s16() { - let r = vmaxvq_s16(::mem::transmute(i16x8::new(1, 2, 7, 4, -16, 6, 7, 5))); + let r = + vmaxvq_s16(::mem::transmute(i16x8::new(1, 2, 7, 4, -16, 6, 7, 5))); assert_eq!(r, 7_i16); } @@ -631,7 +1753,8 @@ #[simd_test(enable = "neon")] unsafe fn test_vmaxvq_u16() { - let r = vmaxvq_u16(::mem::transmute(u16x8::new(1, 2, 7, 4, 16, 6, 7, 5))); + let r = + vmaxvq_u16(::mem::transmute(u16x8::new(1, 2, 7, 4, 16, 6, 7, 5))); assert_eq!(r, 16_u16); } @@ -691,7 +1814,8 @@ #[simd_test(enable = "neon")] unsafe fn test_vminvq_s16() { - let r = vminvq_s16(::mem::transmute(i16x8::new(1, 2, 7, 4, -16, 6, 7, 5))); + let r = + vminvq_s16(::mem::transmute(i16x8::new(1, 2, 7, 4, -16, 6, 7, 5))); assert_eq!(r, -16_i16); } @@ -733,7 +1857,8 @@ #[simd_test(enable = "neon")] unsafe fn test_vminvq_u16() { - let r = vminvq_u16(::mem::transmute(u16x8::new(1, 2, 7, 4, 16, 6, 7, 5))); + let r = + vminvq_u16(::mem::transmute(u16x8::new(1, 2, 7, 4, 16, 6, 7, 5))); assert_eq!(r, 1_u16); } @@ -775,7 +1900,10 @@ let b = i8x16::new(0, 3, 2, 5, 4, 7, 6, 9, 0, 3, 2, 5, 4, 7, 6, 9); #[cfg_attr(rustfmt, skip)] let e = i8x16::new(-2, -4, 5, 7, 1, 3, 5, 7, 0, 2, 4, 6, 0, 2, 4, 6); - let r: i8x16 = ::mem::transmute(vpminq_s8(::mem::transmute(a), ::mem::transmute(b))); + let r: i8x16 = ::mem::transmute(vpminq_s8( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -784,7 +1912,10 @@ let a = i16x8::new(1, -2, 3, 4, 5, 6, 7, 8); let b = i16x8::new(0, 3, 2, 5, 4, 7, 6, 9); let e = i16x8::new(-2, 3, 5, 7, 0, 2, 4, 6); - let r: i16x8 = ::mem::transmute(vpminq_s16(::mem::transmute(a), ::mem::transmute(b))); + let r: i16x8 = ::mem::transmute(vpminq_s16( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -793,7 +1924,10 @@ let a = i32x4::new(1, -2, 3, 4); let b = i32x4::new(0, 3, 2, 5); let e = i32x4::new(-2, 3, 0, 2); - let r: i32x4 = ::mem::transmute(vpminq_s32(::mem::transmute(a), ::mem::transmute(b))); + let r: i32x4 = ::mem::transmute(vpminq_s32( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -805,7 +1939,10 @@ let b = u8x16::new(0, 3, 2, 5, 4, 7, 6, 9, 0, 3, 2, 5, 4, 7, 6, 9); #[cfg_attr(rustfmt, skip)] let e = u8x16::new(1, 3, 5, 7, 1, 3, 5, 7, 0, 2, 4, 6, 0, 2, 4, 6); - let r: u8x16 = ::mem::transmute(vpminq_u8(::mem::transmute(a), ::mem::transmute(b))); + let r: u8x16 = ::mem::transmute(vpminq_u8( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -814,7 +1951,10 @@ let a = u16x8::new(1, 2, 3, 4, 5, 6, 7, 8); let b = u16x8::new(0, 3, 2, 5, 4, 7, 6, 9); let e = u16x8::new(1, 3, 5, 7, 0, 2, 4, 6); - let r: u16x8 = ::mem::transmute(vpminq_u16(::mem::transmute(a), ::mem::transmute(b))); + let r: u16x8 = ::mem::transmute(vpminq_u16( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -823,7 +1963,10 @@ let a = u32x4::new(1, 2, 3, 4); let b = u32x4::new(0, 3, 2, 5); let e = u32x4::new(1, 3, 0, 2); - let r: u32x4 = ::mem::transmute(vpminq_u32(::mem::transmute(a), ::mem::transmute(b))); + let r: u32x4 = ::mem::transmute(vpminq_u32( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -832,7 +1975,10 @@ let a = f32x4::new(1., -2., 3., 4.); let b = f32x4::new(0., 3., 2., 5.); let e = f32x4::new(-2., 3., 0., 2.); - let r: f32x4 = ::mem::transmute(vpminq_f32(::mem::transmute(a), ::mem::transmute(b))); + let r: f32x4 = ::mem::transmute(vpminq_f32( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -841,7 +1987,10 @@ let a = f64x2::new(1., -2.); let b = f64x2::new(0., 3.); let e = f64x2::new(-2., 0.); - let r: f64x2 = ::mem::transmute(vpminq_f64(::mem::transmute(a), ::mem::transmute(b))); + let r: f64x2 = ::mem::transmute(vpminq_f64( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -853,7 +2002,10 @@ let b = i8x16::new(0, 3, 2, 5, 4, 7, 6, 9, 0, 3, 2, 5, 4, 7, 6, 9); #[cfg_attr(rustfmt, skip)] let e = i8x16::new(1, 3, 6, 8, 2, 4, 6, 8, 3, 5, 7, 9, 3, 5, 7, 9); - let r: i8x16 = ::mem::transmute(vpmaxq_s8(::mem::transmute(a), ::mem::transmute(b))); + let r: i8x16 = ::mem::transmute(vpmaxq_s8( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -862,7 +2014,10 @@ let a = i16x8::new(1, -2, 3, 4, 5, 6, 7, 8); let b = i16x8::new(0, 3, 2, 5, 4, 7, 6, 9); let e = i16x8::new(1, 4, 6, 8, 3, 5, 7, 9); - let r: i16x8 = ::mem::transmute(vpmaxq_s16(::mem::transmute(a), ::mem::transmute(b))); + let r: i16x8 = ::mem::transmute(vpmaxq_s16( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -871,7 +2026,10 @@ let a = i32x4::new(1, -2, 3, 4); let b = i32x4::new(0, 3, 2, 5); let e = i32x4::new(1, 4, 3, 5); - let r: i32x4 = ::mem::transmute(vpmaxq_s32(::mem::transmute(a), ::mem::transmute(b))); + let r: i32x4 = ::mem::transmute(vpmaxq_s32( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -883,7 +2041,10 @@ let b = u8x16::new(0, 3, 2, 5, 4, 7, 6, 9, 0, 3, 2, 5, 4, 7, 6, 9); #[cfg_attr(rustfmt, skip)] let e = u8x16::new(2, 4, 6, 8, 2, 4, 6, 8, 3, 5, 7, 9, 3, 5, 7, 9); - let r: u8x16 = ::mem::transmute(vpmaxq_u8(::mem::transmute(a), ::mem::transmute(b))); + let r: u8x16 = ::mem::transmute(vpmaxq_u8( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -892,7 +2053,10 @@ let a = u16x8::new(1, 2, 3, 4, 5, 6, 7, 8); let b = u16x8::new(0, 3, 2, 5, 4, 7, 6, 9); let e = u16x8::new(2, 4, 6, 8, 3, 5, 7, 9); - let r: u16x8 = ::mem::transmute(vpmaxq_u16(::mem::transmute(a), ::mem::transmute(b))); + let r: u16x8 = ::mem::transmute(vpmaxq_u16( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -901,7 +2065,10 @@ let a = u32x4::new(1, 2, 3, 4); let b = u32x4::new(0, 3, 2, 5); let e = u32x4::new(2, 4, 3, 5); - let r: u32x4 = ::mem::transmute(vpmaxq_u32(::mem::transmute(a), ::mem::transmute(b))); + let r: u32x4 = ::mem::transmute(vpmaxq_u32( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -910,7 +2077,10 @@ let a = f32x4::new(1., -2., 3., 4.); let b = f32x4::new(0., 3., 2., 5.); let e = f32x4::new(1., 4., 3., 5.); - let r: f32x4 = ::mem::transmute(vpmaxq_f32(::mem::transmute(a), ::mem::transmute(b))); + let r: f32x4 = ::mem::transmute(vpmaxq_f32( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -919,7 +2089,53 @@ let a = f64x2::new(1., -2.); let b = f64x2::new(0., 3.); let e = f64x2::new(1., 3.); - let r: f64x2 = ::mem::transmute(vpmaxq_f64(::mem::transmute(a), ::mem::transmute(b))); + let r: f64x2 = ::mem::transmute(vpmaxq_f64( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } + + macro_rules! test_vcombine { + ($test_id:ident => $fn_id:ident ([$($a:expr),*], [$($b:expr),*])) => { + #[allow(unused_assignments)] + #[simd_test(enable = "neon")] + unsafe fn $test_id() { + let a = [$($a),*]; + let b = [$($b),*]; + let e = [$($a),* $(, $b)*]; + let c = $fn_id(::mem::transmute(a), ::mem::transmute(b)); + let mut d = e; + d = ::mem::transmute(c); + assert_eq!(d, e); + } + } + } + + test_vcombine!(test_vcombine_s8 => vcombine_s8([3_i8, -4, 5, -6, 7, 8, 9, 10], [13_i8, -14, 15, -16, 17, 18, 19, 110])); + test_vcombine!(test_vcombine_u8 => vcombine_u8([3_u8, 4, 5, 6, 7, 8, 9, 10], [13_u8, 14, 15, 16, 17, 18, 19, 110])); + test_vcombine!(test_vcombine_p8 => vcombine_p8([3_u8, 4, 5, 6, 7, 8, 9, 10], [13_u8, 14, 15, 16, 17, 18, 19, 110])); + + test_vcombine!(test_vcombine_s16 => vcombine_s16([3_i16, -4, 5, -6], [13_i16, -14, 15, -16])); + test_vcombine!(test_vcombine_u16 => vcombine_u16([3_u16, 4, 5, 6], [13_u16, 14, 15, 16])); + test_vcombine!(test_vcombine_p16 => vcombine_p16([3_u16, 4, 5, 6], [13_u16, 14, 15, 16])); + // FIXME: 16-bit floats + // test_vcombine!(test_vcombine_f16 => vcombine_f16([3_f16, 4., 5., 6.], + // [13_f16, 14., 15., 16.])); + + test_vcombine!(test_vcombine_s32 => vcombine_s32([3_i32, -4], [13_i32, -14])); + test_vcombine!(test_vcombine_u32 => vcombine_u32([3_u32, 4], [13_u32, 14])); + // note: poly32x4 does not exist, and neither does vcombine_p32 + test_vcombine!(test_vcombine_f32 => vcombine_f32([3_f32, -4.], [13_f32, -14.])); + + test_vcombine!(test_vcombine_s64 => vcombine_s64([-3_i64], [13_i64])); + test_vcombine!(test_vcombine_u64 => vcombine_u64([3_u64], [13_u64])); + test_vcombine!(test_vcombine_p64 => vcombine_p64([3_u64], [13_u64])); + test_vcombine!(test_vcombine_f64 => vcombine_f64([-3_f64], [13_f64])); + } + +#[cfg(test)] +#[cfg(target_endian = "little")] +#[path = "../arm/table_lookup_tests.rs"] +mod table_lookup_tests; diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/arm/cmsis.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/arm/cmsis.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/arm/cmsis.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/arm/cmsis.rs 2018-12-04 23:42:58.000000000 +0000 @@ -9,7 +9,8 @@ //! - Core function access -- http://arm-software.github.io/CMSIS_5/Core/html/group__Core__Register__gr.html //! - Intrinsic functions for CPU instructions -- http://arm-software.github.io/CMSIS_5/Core/html/group__intrinsic__CPU__gr.html //! -//! The reference C implementation used as the base of this Rust port can be found at +//! The reference C implementation used as the base of this Rust port can be +//! found at //! //! https://github.com/ARM-software/CMSIS_5/blob/5.3.0/CMSIS/Core/Include/cmsis_gcc.h diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/arm/dsp.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/arm/dsp.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/arm/dsp.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/arm/dsp.rs 2018-12-04 23:42:58.000000000 +0000 @@ -1,4 +1,8 @@ //! ARM DSP Intrinsics. +//! +//! Based on "Arm C Language Extensions (ACLE) Version Q2 2018" +//! +//! https://developer.arm.com/products/software-development-tools/compilers/arm-compiler-5/docs/101028/0006 #[cfg(test)] use stdsimd_test::assert_instr; @@ -54,6 +58,12 @@ #[link_name = "llvm.arm.sasx"] fn arm_sasx(a: i32, b: i32) -> i32; + #[link_name = "llvm.arm.smlad"] + fn arm_smlad(a: i32, b: i32, c: i32) -> i32; + + #[link_name = "llvm.arm.smlsd"] + fn arm_smlsd(a: i32, b: i32, c: i32) -> i32; + #[link_name = "llvm.arm.sel"] fn arm_sel(a: i32, b: i32) -> i32; @@ -80,6 +90,9 @@ #[link_name = "llvm.arm.smusdx"] fn arm_smusdx(a: i32, b: i32) -> i32; + + #[link_name = "llvm.arm.usad8"] + fn arm_usad8(a: i32, b: i32) -> u32; } /// Signed saturating addition @@ -198,6 +211,28 @@ dsp_call!(arm_sadd8, a, b) } +/// Dual 16-bit Signed Multiply with Addition of products +/// and 32-bit accumulation. +/// +/// Returns the 16-bit signed equivalent of +/// res = a\[0\] * b\[0\] + a\[1\] * b\[1\] + c +#[inline] +#[cfg_attr(test, assert_instr(smlad))] +pub unsafe fn smlad(a: int16x2_t, b: int16x2_t, c: i32) -> i32 { + arm_smlad(::mem::transmute(a), ::mem::transmute(b), c) +} + +/// Dual 16-bit Signed Multiply with Subtraction of products +/// and 32-bit accumulation and overflow detection. +/// +/// Returns the 16-bit signed equivalent of +/// res = a\[0\] * b\[0\] - a\[1\] * b\[1\] + c +#[inline] +#[cfg_attr(test, assert_instr(smlsd))] +pub unsafe fn smlsd(a: int16x2_t, b: int16x2_t, c: i32) -> i32 { + arm_smlsd(::mem::transmute(a), ::mem::transmute(b), c) +} + /// Returns the 16-bit signed equivalent of /// /// res\[0\] = a\[0\] - b\[1\] @@ -210,6 +245,8 @@ dsp_call!(arm_sasx, a, b) } +/// Select bytes from each operand according to APSR GE flags +/// /// Returns the equivalent of /// /// res\[0\] = GE\[0\] ? a\[0\] : b\[0\] @@ -284,6 +321,7 @@ /// res = a\[0\] * b\[0\] + a\[1\] * b\[1\] /// /// and sets the Q flag if overflow occurs on the addition. +#[inline] #[cfg_attr(test, assert_instr(smuad))] pub unsafe fn smuad(a: int16x2_t, b: int16x2_t) -> i32 { arm_smuad(::mem::transmute(a), ::mem::transmute(b)) @@ -328,6 +366,30 @@ arm_smusdx(::mem::transmute(a), ::mem::transmute(b)) } +/// Sum of 8-bit absolute differences. +/// +/// Returns the 8-bit unsigned equivalent of +/// +/// res = abs(a\[0\] - b\[0\]) + abs(a\[1\] - b\[1\]) +\ +/// (a\[2\] - b\[2\]) + (a\[3\] - b\[3\]) +#[inline] +#[cfg_attr(test, assert_instr(usad8))] +pub unsafe fn usad8(a: int8x4_t, b: int8x4_t) -> u32 { + arm_usad8(::mem::transmute(a), ::mem::transmute(b)) +} + +/// Sum of 8-bit absolute differences and constant. +/// +/// Returns the 8-bit unsigned equivalent of +/// +/// res = abs(a\[0\] - b\[0\]) + abs(a\[1\] - b\[1\]) +\ +/// (a\[2\] - b\[2\]) + (a\[3\] - b\[3\]) + c +#[inline] +#[cfg_attr(test, assert_instr(usad8))] +pub unsafe fn usad8a(a: int8x4_t, b: int8x4_t, c: u32) -> u32 { + usad8(a, b) + c +} + #[cfg(test)] mod tests { use coresimd::arm::*; @@ -453,6 +515,26 @@ } #[test] + fn smlad() { + unsafe { + let a = i16x2::new(1, 2); + let b = i16x2::new(3, 4); + let r = dsp::smlad(::mem::transmute(a), ::mem::transmute(b), 10); + assert_eq!(r, (1 * 3) + (2 * 4) + 10); + } + } + + #[test] + fn smlsd() { + unsafe { + let a = i16x2::new(1, 2); + let b = i16x2::new(3, 4); + let r = dsp::smlsd(::mem::transmute(a), ::mem::transmute(b), 10); + assert_eq!(r, ((1 * 3) - (2 * 4)) + 10); + } + } + + #[test] fn sel() { unsafe { let a = i8x4::new(1, 2, 3, ::std::i8::MAX); @@ -548,4 +630,25 @@ assert_eq!(r, -6); } } + + #[test] + fn usad8() { + unsafe { + let a = i8x4::new(1, 2, 3, 4); + let b = i8x4::new(4, 3, 2, 1); + let r = dsp::usad8(::mem::transmute(a), ::mem::transmute(b)); + assert_eq!(r, 8); + } + } + + #[test] + fn usad8a() { + unsafe { + let a = i8x4::new(1, 2, 3, 4); + let b = i8x4::new(4, 3, 2, 1); + let c = 10; + let r = dsp::usad8a(::mem::transmute(a), ::mem::transmute(b), c); + assert_eq!(r, 8 + c); + } + } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/arm/mod.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/arm/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/arm/mod.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/arm/mod.rs 2018-12-04 23:42:58.000000000 +0000 @@ -20,26 +20,28 @@ #[cfg(any(target_arch = "aarch64", target_feature = "v7"))] pub use self::v7::*; -#[cfg(any(all(target_feature = "v7", not(target_feature = "mclass")), dox))] +#[cfg(any( + all(target_feature = "v7", not(target_feature = "mclass")), + dox +))] mod dsp; -#[cfg(any(all(target_feature = "v7", not(target_feature = "mclass")), dox))] +#[cfg(any( + all(target_feature = "v7", not(target_feature = "mclass")), + dox +))] pub use self::dsp::*; // NEON is supported on AArch64, and on ARM when built with the v7 and neon // features. Building ARM without neon produces incorrect codegen. -#[cfg( - any( - target_arch = "aarch64", - all(target_feature = "v7", target_feature = "neon"), - dox - ) -)] +#[cfg(any( + target_arch = "aarch64", + all(target_feature = "v7", target_feature = "neon"), + dox +))] mod neon; -#[cfg( - any( - target_arch = "aarch64", - all(target_feature = "v7", target_feature = "neon"), - dox - ) -)] +#[cfg(any( + target_arch = "aarch64", + all(target_feature = "v7", target_feature = "neon"), + dox +))] pub use self::neon::*; diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/arm/neon.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/arm/neon.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/arm/neon.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/arm/neon.rs 2018-12-04 23:42:58.000000000 +0000 @@ -65,87 +65,204 @@ pub struct uint64x2_t(u64, u64); } +/// ARM-specific type containing two `int8x8_t` vectors. +#[derive(Copy, Clone)] +pub struct int8x8x2_t(pub int8x8_t, pub int8x8_t); +/// ARM-specific type containing three `int8x8_t` vectors. +#[derive(Copy, Clone)] +pub struct int8x8x3_t(pub int8x8_t, pub int8x8_t, pub int8x8_t); +/// ARM-specific type containing four `int8x8_t` vectors. +#[derive(Copy, Clone)] +pub struct int8x8x4_t(pub int8x8_t, pub int8x8_t, pub int8x8_t, pub int8x8_t); + +/// ARM-specific type containing two `uint8x8_t` vectors. +#[derive(Copy, Clone)] +pub struct uint8x8x2_t(pub uint8x8_t, pub uint8x8_t); +/// ARM-specific type containing three `uint8x8_t` vectors. +#[derive(Copy, Clone)] +pub struct uint8x8x3_t(pub uint8x8_t, pub uint8x8_t, pub uint8x8_t); +/// ARM-specific type containing four `uint8x8_t` vectors. +#[derive(Copy, Clone)] +pub struct uint8x8x4_t( + pub uint8x8_t, + pub uint8x8_t, + pub uint8x8_t, + pub uint8x8_t, +); + +/// ARM-specific type containing two `poly8x8_t` vectors. +#[derive(Copy, Clone)] +pub struct poly8x8x2_t(pub poly8x8_t, pub poly8x8_t); +/// ARM-specific type containing three `poly8x8_t` vectors. +#[derive(Copy, Clone)] +pub struct poly8x8x3_t(pub poly8x8_t, pub poly8x8_t, pub poly8x8_t); +/// ARM-specific type containing four `poly8x8_t` vectors. +#[derive(Copy, Clone)] +pub struct poly8x8x4_t( + pub poly8x8_t, + pub poly8x8_t, + pub poly8x8_t, + pub poly8x8_t, +); + #[allow(improper_ctypes)] extern "C" { #[cfg_attr( - target_arch = "aarch64", link_name = "llvm.aarch64.neon.frsqrte.v2f32" + target_arch = "aarch64", + link_name = "llvm.aarch64.neon.frsqrte.v2f32" + )] + #[cfg_attr( + target_arch = "arm", + link_name = "llvm.arm.neon.vrsqrte.v2f32" )] - #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vrsqrte.v2f32")] fn frsqrte_v2f32(a: float32x2_t) -> float32x2_t; #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vpmins.v8i8")] #[cfg_attr( - target_arch = "aarch64", link_name = "llvm.aarch64.neon.sminp.v8i8" + target_arch = "aarch64", + link_name = "llvm.aarch64.neon.sminp.v8i8" )] fn vpmins_v8i8(a: int8x8_t, b: int8x8_t) -> int8x8_t; - #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vpmins.v4i16")] #[cfg_attr( - target_arch = "aarch64", link_name = "llvm.aarch64.neon.sminp.v4i16" + target_arch = "arm", + link_name = "llvm.arm.neon.vpmins.v4i16" + )] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.neon.sminp.v4i16" )] fn vpmins_v4i16(a: int16x4_t, b: int16x4_t) -> int16x4_t; - #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vpmins.v2i32")] #[cfg_attr( - target_arch = "aarch64", link_name = "llvm.aarch64.neon.sminp.v2i32" + target_arch = "arm", + link_name = "llvm.arm.neon.vpmins.v2i32" + )] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.neon.sminp.v2i32" )] fn vpmins_v2i32(a: int32x2_t, b: int32x2_t) -> int32x2_t; #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vpminu.v8i8")] #[cfg_attr( - target_arch = "aarch64", link_name = "llvm.aarch64.neon.uminp.v8i8" + target_arch = "aarch64", + link_name = "llvm.aarch64.neon.uminp.v8i8" )] fn vpminu_v8i8(a: uint8x8_t, b: uint8x8_t) -> uint8x8_t; - #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vpminu.v4i16")] #[cfg_attr( - target_arch = "aarch64", link_name = "llvm.aarch64.neon.uminp.v4i16" + target_arch = "arm", + link_name = "llvm.arm.neon.vpminu.v4i16" + )] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.neon.uminp.v4i16" )] fn vpminu_v4i16(a: uint16x4_t, b: uint16x4_t) -> uint16x4_t; - #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vpminu.v2i32")] #[cfg_attr( - target_arch = "aarch64", link_name = "llvm.aarch64.neon.uminp.v2i32" + target_arch = "arm", + link_name = "llvm.arm.neon.vpminu.v2i32" + )] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.neon.uminp.v2i32" )] fn vpminu_v2i32(a: uint32x2_t, b: uint32x2_t) -> uint32x2_t; - #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vpmins.v2f32")] #[cfg_attr( - target_arch = "aarch64", link_name = "llvm.aarch64.neon.fminp.v2f32" + target_arch = "arm", + link_name = "llvm.arm.neon.vpmins.v2f32" + )] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.neon.fminp.v2f32" )] fn vpminf_v2f32(a: float32x2_t, b: float32x2_t) -> float32x2_t; #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vpmaxs.v8i8")] #[cfg_attr( - target_arch = "aarch64", link_name = "llvm.aarch64.neon.smaxp.v8i8" + target_arch = "aarch64", + link_name = "llvm.aarch64.neon.smaxp.v8i8" )] fn vpmaxs_v8i8(a: int8x8_t, b: int8x8_t) -> int8x8_t; - #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vpmaxs.v4i16")] #[cfg_attr( - target_arch = "aarch64", link_name = "llvm.aarch64.neon.smaxp.v4i16" + target_arch = "arm", + link_name = "llvm.arm.neon.vpmaxs.v4i16" + )] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.neon.smaxp.v4i16" )] fn vpmaxs_v4i16(a: int16x4_t, b: int16x4_t) -> int16x4_t; - #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vpmaxs.v2i32")] #[cfg_attr( - target_arch = "aarch64", link_name = "llvm.aarch64.neon.smaxp.v2i32" + target_arch = "arm", + link_name = "llvm.arm.neon.vpmaxs.v2i32" + )] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.neon.smaxp.v2i32" )] fn vpmaxs_v2i32(a: int32x2_t, b: int32x2_t) -> int32x2_t; #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vpmaxu.v8i8")] #[cfg_attr( - target_arch = "aarch64", link_name = "llvm.aarch64.neon.umaxp.v8i8" + target_arch = "aarch64", + link_name = "llvm.aarch64.neon.umaxp.v8i8" )] fn vpmaxu_v8i8(a: uint8x8_t, b: uint8x8_t) -> uint8x8_t; - #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vpmaxu.v4i16")] #[cfg_attr( - target_arch = "aarch64", link_name = "llvm.aarch64.neon.umaxp.v4i16" + target_arch = "arm", + link_name = "llvm.arm.neon.vpmaxu.v4i16" + )] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.neon.umaxp.v4i16" )] fn vpmaxu_v4i16(a: uint16x4_t, b: uint16x4_t) -> uint16x4_t; - #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vpmaxu.v2i32")] #[cfg_attr( - target_arch = "aarch64", link_name = "llvm.aarch64.neon.umaxp.v2i32" + target_arch = "arm", + link_name = "llvm.arm.neon.vpmaxu.v2i32" + )] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.neon.umaxp.v2i32" )] fn vpmaxu_v2i32(a: uint32x2_t, b: uint32x2_t) -> uint32x2_t; - #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vpmaxs.v2f32")] #[cfg_attr( - target_arch = "aarch64", link_name = "llvm.aarch64.neon.fmaxp.v2f32" + target_arch = "arm", + link_name = "llvm.arm.neon.vpmaxs.v2f32" + )] + #[cfg_attr( + target_arch = "aarch64", + link_name = "llvm.aarch64.neon.fmaxp.v2f32" )] fn vpmaxf_v2f32(a: float32x2_t, b: float32x2_t) -> float32x2_t; } +#[cfg(target_arch = "arm")] +#[allow(improper_ctypes)] +extern "C" { + #[link_name = "llvm.arm.neon.vtbl1"] + fn vtbl1(a: int8x8_t, b: int8x8_t) -> int8x8_t; + #[link_name = "llvm.arm.neon.vtbl2"] + fn vtbl2(a: int8x8_t, b: int8x8_t, b: int8x8_t) -> int8x8_t; + #[link_name = "llvm.arm.neon.vtbl3"] + fn vtbl3(a: int8x8_t, b: int8x8_t, b: int8x8_t, c: int8x8_t) -> int8x8_t; + #[link_name = "llvm.arm.neon.vtbl4"] + fn vtbl4( + a: int8x8_t, b: int8x8_t, b: int8x8_t, c: int8x8_t, d: int8x8_t, + ) -> int8x8_t; + + #[link_name = "llvm.arm.neon.vtbx1"] + fn vtbx1(a: int8x8_t, b: int8x8_t, b: int8x8_t) -> int8x8_t; + #[link_name = "llvm.arm.neon.vtbx2"] + fn vtbx2(a: int8x8_t, b: int8x8_t, b: int8x8_t, c: int8x8_t) -> int8x8_t; + #[link_name = "llvm.arm.neon.vtbx3"] + fn vtbx3( + a: int8x8_t, b: int8x8_t, b: int8x8_t, c: int8x8_t, d: int8x8_t, + ) -> int8x8_t; + #[link_name = "llvm.arm.neon.vtbx4"] + fn vtbx4( + a: int8x8_t, b: int8x8_t, b: int8x8_t, c: int8x8_t, d: int8x8_t, + e: int8x8_t, + ) -> int8x8_t; +} + /// Vector add. #[inline] #[target_feature(enable = "neon")] @@ -647,6 +764,332 @@ vpmaxf_v2f32(a, b) } +/// Table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbl))] +pub unsafe fn vtbl1_s8(a: int8x8_t, b: int8x8_t) -> int8x8_t { + vtbl1(a, b) +} + +/// Table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbl))] +pub unsafe fn vtbl1_u8(a: uint8x8_t, b: uint8x8_t) -> uint8x8_t { + ::mem::transmute(vtbl1(::mem::transmute(a), ::mem::transmute(b))) +} + +/// Table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbl))] +pub unsafe fn vtbl1_p8(a: poly8x8_t, b: poly8x8_t) -> poly8x8_t { + ::mem::transmute(vtbl1(::mem::transmute(a), ::mem::transmute(b))) +} + +/// Table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbl))] +pub unsafe fn vtbl2_s8(a: int8x8x2_t, b: int8x8_t) -> int8x8_t { + vtbl2(a.0, a.1, b) +} + +/// Table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbl))] +pub unsafe fn vtbl2_u8(a: uint8x8x2_t, b: uint8x8_t) -> uint8x8_t { + ::mem::transmute(vtbl2( + ::mem::transmute(a.0), + ::mem::transmute(a.1), + ::mem::transmute(b), + )) +} + +/// Table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbl))] +pub unsafe fn vtbl2_p8(a: poly8x8x2_t, b: uint8x8_t) -> poly8x8_t { + ::mem::transmute(vtbl2( + ::mem::transmute(a.0), + ::mem::transmute(a.1), + ::mem::transmute(b), + )) +} + +/// Table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbl))] +pub unsafe fn vtbl3_s8(a: int8x8x3_t, b: int8x8_t) -> int8x8_t { + vtbl3(a.0, a.1, a.2, b) +} + +/// Table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbl))] +pub unsafe fn vtbl3_u8(a: uint8x8x3_t, b: uint8x8_t) -> uint8x8_t { + ::mem::transmute(vtbl3( + ::mem::transmute(a.0), + ::mem::transmute(a.1), + ::mem::transmute(a.2), + ::mem::transmute(b), + )) +} + +/// Table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbl))] +pub unsafe fn vtbl3_p8(a: poly8x8x3_t, b: uint8x8_t) -> poly8x8_t { + ::mem::transmute(vtbl3( + ::mem::transmute(a.0), + ::mem::transmute(a.1), + ::mem::transmute(a.2), + ::mem::transmute(b), + )) +} + +/// Table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbl))] +pub unsafe fn vtbl4_s8(a: int8x8x4_t, b: int8x8_t) -> int8x8_t { + vtbl4(a.0, a.1, a.2, a.3, b) +} + +/// Table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbl))] +pub unsafe fn vtbl4_u8(a: uint8x8x4_t, b: uint8x8_t) -> uint8x8_t { + ::mem::transmute(vtbl4( + ::mem::transmute(a.0), + ::mem::transmute(a.1), + ::mem::transmute(a.2), + ::mem::transmute(a.3), + ::mem::transmute(b), + )) +} + +/// Table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbl))] +pub unsafe fn vtbl4_p8(a: poly8x8x4_t, b: uint8x8_t) -> poly8x8_t { + ::mem::transmute(vtbl4( + ::mem::transmute(a.0), + ::mem::transmute(a.1), + ::mem::transmute(a.2), + ::mem::transmute(a.3), + ::mem::transmute(b), + )) +} + +/// Extended table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbx))] +pub unsafe fn vtbx1_s8(a: int8x8_t, b: int8x8_t, c: int8x8_t) -> int8x8_t { + vtbx1(a, b, c) +} + +/// Extended table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbx))] +pub unsafe fn vtbx1_u8(a: uint8x8_t, b: uint8x8_t, c: uint8x8_t) -> uint8x8_t { + ::mem::transmute(vtbx1( + ::mem::transmute(a), + ::mem::transmute(b), + ::mem::transmute(c), + )) +} + +/// Extended table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbx))] +pub unsafe fn vtbx1_p8(a: poly8x8_t, b: poly8x8_t, c: uint8x8_t) -> poly8x8_t { + ::mem::transmute(vtbx1( + ::mem::transmute(a), + ::mem::transmute(b), + ::mem::transmute(c), + )) +} + +/// Extended table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbx))] +pub unsafe fn vtbx2_s8(a: int8x8_t, b: int8x8x2_t, c: int8x8_t) -> int8x8_t { + vtbx2(a, b.0, b.1, c) +} + +/// Extended table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbx))] +pub unsafe fn vtbx2_u8( + a: uint8x8_t, b: uint8x8x2_t, c: uint8x8_t, +) -> uint8x8_t { + ::mem::transmute(vtbx2( + ::mem::transmute(a), + ::mem::transmute(b.0), + ::mem::transmute(b.1), + ::mem::transmute(c), + )) +} + +/// Extended table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbx))] +pub unsafe fn vtbx2_p8( + a: poly8x8_t, b: poly8x8x2_t, c: uint8x8_t, +) -> poly8x8_t { + ::mem::transmute(vtbx2( + ::mem::transmute(a), + ::mem::transmute(b.0), + ::mem::transmute(b.1), + ::mem::transmute(c), + )) +} + +/// Extended table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbx))] +pub unsafe fn vtbx3_s8(a: int8x8_t, b: int8x8x3_t, c: int8x8_t) -> int8x8_t { + vtbx3(a, b.0, b.1, b.2, c) +} + +/// Extended table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbx))] +pub unsafe fn vtbx3_u8( + a: uint8x8_t, b: uint8x8x3_t, c: uint8x8_t, +) -> uint8x8_t { + ::mem::transmute(vtbx3( + ::mem::transmute(a), + ::mem::transmute(b.0), + ::mem::transmute(b.1), + ::mem::transmute(b.2), + ::mem::transmute(c), + )) +} + +/// Extended table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbx))] +pub unsafe fn vtbx3_p8( + a: poly8x8_t, b: poly8x8x3_t, c: uint8x8_t, +) -> poly8x8_t { + ::mem::transmute(vtbx3( + ::mem::transmute(a), + ::mem::transmute(b.0), + ::mem::transmute(b.1), + ::mem::transmute(b.2), + ::mem::transmute(c), + )) +} + +/// Extended table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbx))] +pub unsafe fn vtbx4_s8(a: int8x8_t, b: int8x8x4_t, c: int8x8_t) -> int8x8_t { + vtbx4(a, b.0, b.1, b.2, b.3, c) +} + +/// Extended table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbx))] +pub unsafe fn vtbx4_u8( + a: uint8x8_t, b: uint8x8x4_t, c: uint8x8_t, +) -> uint8x8_t { + ::mem::transmute(vtbx4( + ::mem::transmute(a), + ::mem::transmute(b.0), + ::mem::transmute(b.1), + ::mem::transmute(b.2), + ::mem::transmute(b.3), + ::mem::transmute(c), + )) +} + +/// Extended table look-up +#[inline] +#[cfg(target_arch = "arm")] +#[cfg(target_endian = "little")] +#[target_feature(enable = "neon,v7")] +#[cfg_attr(test, assert_instr(vtbx))] +pub unsafe fn vtbx4_p8( + a: poly8x8_t, b: poly8x8x4_t, c: uint8x8_t, +) -> poly8x8_t { + ::mem::transmute(vtbx4( + ::mem::transmute(a), + ::mem::transmute(b.0), + ::mem::transmute(b.1), + ::mem::transmute(b.2), + ::mem::transmute(b.3), + ::mem::transmute(c), + )) +} + #[cfg(test)] mod tests { use coresimd::arm::*; @@ -659,7 +1102,10 @@ let a = i8x8::new(1, 2, 3, 4, 5, 6, 7, 8); let b = i8x8::new(8, 7, 6, 5, 4, 3, 2, 1); let e = i8x8::new(9, 9, 9, 9, 9, 9, 9, 9); - let r: i8x8 = ::mem::transmute(vadd_s8(::mem::transmute(a), ::mem::transmute(b))); + let r: i8x8 = ::mem::transmute(vadd_s8( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -668,7 +1114,10 @@ let a = i8x16::new(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8); let b = i8x16::new(8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1); let e = i8x16::new(9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9); - let r: i8x16 = ::mem::transmute(vaddq_s8(::mem::transmute(a), ::mem::transmute(b))); + let r: i8x16 = ::mem::transmute(vaddq_s8( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -677,7 +1126,10 @@ let a = i16x4::new(1, 2, 3, 4); let b = i16x4::new(8, 7, 6, 5); let e = i16x4::new(9, 9, 9, 9); - let r: i16x4 = ::mem::transmute(vadd_s16(::mem::transmute(a), ::mem::transmute(b))); + let r: i16x4 = ::mem::transmute(vadd_s16( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -686,7 +1138,10 @@ let a = i16x8::new(1, 2, 3, 4, 5, 6, 7, 8); let b = i16x8::new(8, 7, 6, 5, 4, 3, 2, 1); let e = i16x8::new(9, 9, 9, 9, 9, 9, 9, 9); - let r: i16x8 = ::mem::transmute(vaddq_s16(::mem::transmute(a), ::mem::transmute(b))); + let r: i16x8 = ::mem::transmute(vaddq_s16( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -695,7 +1150,10 @@ let a = i32x2::new(1, 2); let b = i32x2::new(8, 7); let e = i32x2::new(9, 9); - let r: i32x2 = ::mem::transmute(vadd_s32(::mem::transmute(a), ::mem::transmute(b))); + let r: i32x2 = ::mem::transmute(vadd_s32( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -704,7 +1162,10 @@ let a = i32x4::new(1, 2, 3, 4); let b = i32x4::new(8, 7, 6, 5); let e = i32x4::new(9, 9, 9, 9); - let r: i32x4 = ::mem::transmute(vaddq_s32(::mem::transmute(a), ::mem::transmute(b))); + let r: i32x4 = ::mem::transmute(vaddq_s32( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -713,7 +1174,10 @@ let a = u8x8::new(1, 2, 3, 4, 5, 6, 7, 8); let b = u8x8::new(8, 7, 6, 5, 4, 3, 2, 1); let e = u8x8::new(9, 9, 9, 9, 9, 9, 9, 9); - let r: u8x8 = ::mem::transmute(vadd_u8(::mem::transmute(a), ::mem::transmute(b))); + let r: u8x8 = ::mem::transmute(vadd_u8( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -722,7 +1186,10 @@ let a = u8x16::new(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8); let b = u8x16::new(8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1); let e = u8x16::new(9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9); - let r: u8x16 = ::mem::transmute(vaddq_u8(::mem::transmute(a), ::mem::transmute(b))); + let r: u8x16 = ::mem::transmute(vaddq_u8( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -731,7 +1198,10 @@ let a = u16x4::new(1, 2, 3, 4); let b = u16x4::new(8, 7, 6, 5); let e = u16x4::new(9, 9, 9, 9); - let r: u16x4 = ::mem::transmute(vadd_u16(::mem::transmute(a), ::mem::transmute(b))); + let r: u16x4 = ::mem::transmute(vadd_u16( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -740,7 +1210,10 @@ let a = u16x8::new(1, 2, 3, 4, 5, 6, 7, 8); let b = u16x8::new(8, 7, 6, 5, 4, 3, 2, 1); let e = u16x8::new(9, 9, 9, 9, 9, 9, 9, 9); - let r: u16x8 = ::mem::transmute(vaddq_u16(::mem::transmute(a), ::mem::transmute(b))); + let r: u16x8 = ::mem::transmute(vaddq_u16( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -749,7 +1222,10 @@ let a = u32x2::new(1, 2); let b = u32x2::new(8, 7); let e = u32x2::new(9, 9); - let r: u32x2 = ::mem::transmute(vadd_u32(::mem::transmute(a), ::mem::transmute(b))); + let r: u32x2 = ::mem::transmute(vadd_u32( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -758,7 +1234,10 @@ let a = u32x4::new(1, 2, 3, 4); let b = u32x4::new(8, 7, 6, 5); let e = u32x4::new(9, 9, 9, 9); - let r: u32x4 = ::mem::transmute(vaddq_u32(::mem::transmute(a), ::mem::transmute(b))); + let r: u32x4 = ::mem::transmute(vaddq_u32( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -767,7 +1246,10 @@ let a = f32x2::new(1., 2.); let b = f32x2::new(8., 7.); let e = f32x2::new(9., 9.); - let r: f32x2 = ::mem::transmute(vadd_f32(::mem::transmute(a), ::mem::transmute(b))); + let r: f32x2 = ::mem::transmute(vadd_f32( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -776,7 +1258,10 @@ let a = f32x4::new(1., 2., 3., 4.); let b = f32x4::new(8., 7., 6., 5.); let e = f32x4::new(9., 9., 9., 9.); - let r: f32x4 = ::mem::transmute(vaddq_f32(::mem::transmute(a), ::mem::transmute(b))); + let r: f32x4 = ::mem::transmute(vaddq_f32( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -786,7 +1271,10 @@ let a = i8x8::new(v, v, v, v, v, v, v, v); let v = 2 * (v as i16); let e = i16x8::new(v, v, v, v, v, v, v, v); - let r: i16x8 = ::mem::transmute(vaddl_s8(::mem::transmute(a), ::mem::transmute(a))); + let r: i16x8 = ::mem::transmute(vaddl_s8( + ::mem::transmute(a), + ::mem::transmute(a), + )); assert_eq!(r, e); } @@ -796,7 +1284,10 @@ let a = i16x4::new(v, v, v, v); let v = 2 * (v as i32); let e = i32x4::new(v, v, v, v); - let r: i32x4 = ::mem::transmute(vaddl_s16(::mem::transmute(a), ::mem::transmute(a))); + let r: i32x4 = ::mem::transmute(vaddl_s16( + ::mem::transmute(a), + ::mem::transmute(a), + )); assert_eq!(r, e); } @@ -806,7 +1297,10 @@ let a = i32x2::new(v, v); let v = 2 * (v as i64); let e = i64x2::new(v, v); - let r: i64x2 = ::mem::transmute(vaddl_s32(::mem::transmute(a), ::mem::transmute(a))); + let r: i64x2 = ::mem::transmute(vaddl_s32( + ::mem::transmute(a), + ::mem::transmute(a), + )); assert_eq!(r, e); } @@ -816,7 +1310,10 @@ let a = u8x8::new(v, v, v, v, v, v, v, v); let v = 2 * (v as u16); let e = u16x8::new(v, v, v, v, v, v, v, v); - let r: u16x8 = ::mem::transmute(vaddl_u8(::mem::transmute(a), ::mem::transmute(a))); + let r: u16x8 = ::mem::transmute(vaddl_u8( + ::mem::transmute(a), + ::mem::transmute(a), + )); assert_eq!(r, e); } @@ -826,7 +1323,10 @@ let a = u16x4::new(v, v, v, v); let v = 2 * (v as u32); let e = u32x4::new(v, v, v, v); - let r: u32x4 = ::mem::transmute(vaddl_u16(::mem::transmute(a), ::mem::transmute(a))); + let r: u32x4 = ::mem::transmute(vaddl_u16( + ::mem::transmute(a), + ::mem::transmute(a), + )); assert_eq!(r, e); } @@ -836,7 +1336,10 @@ let a = u32x2::new(v, v); let v = 2 * (v as u64); let e = u64x2::new(v, v); - let r: u64x2 = ::mem::transmute(vaddl_u32(::mem::transmute(a), ::mem::transmute(a))); + let r: u64x2 = ::mem::transmute(vaddl_u32( + ::mem::transmute(a), + ::mem::transmute(a), + )); assert_eq!(r, e); } @@ -949,7 +1452,10 @@ let a = i8x8::new(1, -2, 3, -4, 5, 6, 7, 8); let b = i8x8::new(0, 3, 2, 5, 4, 7, 6, 9); let e = i8x8::new(-2, -4, 5, 7, 0, 2, 4, 6); - let r: i8x8 = ::mem::transmute(vpmin_s8(::mem::transmute(a), ::mem::transmute(b))); + let r: i8x8 = ::mem::transmute(vpmin_s8( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -958,7 +1464,10 @@ let a = i16x4::new(1, 2, 3, -4); let b = i16x4::new(0, 3, 2, 5); let e = i16x4::new(1, -4, 0, 2); - let r: i16x4 = ::mem::transmute(vpmin_s16(::mem::transmute(a), ::mem::transmute(b))); + let r: i16x4 = ::mem::transmute(vpmin_s16( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -967,7 +1476,10 @@ let a = i32x2::new(1, -2); let b = i32x2::new(0, 3); let e = i32x2::new(-2, 0); - let r: i32x2 = ::mem::transmute(vpmin_s32(::mem::transmute(a), ::mem::transmute(b))); + let r: i32x2 = ::mem::transmute(vpmin_s32( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -976,7 +1488,10 @@ let a = u8x8::new(1, 2, 3, 4, 5, 6, 7, 8); let b = u8x8::new(0, 3, 2, 5, 4, 7, 6, 9); let e = u8x8::new(1, 3, 5, 7, 0, 2, 4, 6); - let r: u8x8 = ::mem::transmute(vpmin_u8(::mem::transmute(a), ::mem::transmute(b))); + let r: u8x8 = ::mem::transmute(vpmin_u8( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -985,7 +1500,10 @@ let a = u16x4::new(1, 2, 3, 4); let b = u16x4::new(0, 3, 2, 5); let e = u16x4::new(1, 3, 0, 2); - let r: u16x4 = ::mem::transmute(vpmin_u16(::mem::transmute(a), ::mem::transmute(b))); + let r: u16x4 = ::mem::transmute(vpmin_u16( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -994,7 +1512,10 @@ let a = u32x2::new(1, 2); let b = u32x2::new(0, 3); let e = u32x2::new(1, 0); - let r: u32x2 = ::mem::transmute(vpmin_u32(::mem::transmute(a), ::mem::transmute(b))); + let r: u32x2 = ::mem::transmute(vpmin_u32( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -1003,7 +1524,10 @@ let a = f32x2::new(1., -2.); let b = f32x2::new(0., 3.); let e = f32x2::new(-2., 0.); - let r: f32x2 = ::mem::transmute(vpmin_f32(::mem::transmute(a), ::mem::transmute(b))); + let r: f32x2 = ::mem::transmute(vpmin_f32( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -1012,7 +1536,10 @@ let a = i8x8::new(1, -2, 3, -4, 5, 6, 7, 8); let b = i8x8::new(0, 3, 2, 5, 4, 7, 6, 9); let e = i8x8::new(1, 3, 6, 8, 3, 5, 7, 9); - let r: i8x8 = ::mem::transmute(vpmax_s8(::mem::transmute(a), ::mem::transmute(b))); + let r: i8x8 = ::mem::transmute(vpmax_s8( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -1021,7 +1548,10 @@ let a = i16x4::new(1, 2, 3, -4); let b = i16x4::new(0, 3, 2, 5); let e = i16x4::new(2, 3, 3, 5); - let r: i16x4 = ::mem::transmute(vpmax_s16(::mem::transmute(a), ::mem::transmute(b))); + let r: i16x4 = ::mem::transmute(vpmax_s16( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -1030,7 +1560,10 @@ let a = i32x2::new(1, -2); let b = i32x2::new(0, 3); let e = i32x2::new(1, 3); - let r: i32x2 = ::mem::transmute(vpmax_s32(::mem::transmute(a), ::mem::transmute(b))); + let r: i32x2 = ::mem::transmute(vpmax_s32( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -1039,7 +1572,10 @@ let a = u8x8::new(1, 2, 3, 4, 5, 6, 7, 8); let b = u8x8::new(0, 3, 2, 5, 4, 7, 6, 9); let e = u8x8::new(2, 4, 6, 8, 3, 5, 7, 9); - let r: u8x8 = ::mem::transmute(vpmax_u8(::mem::transmute(a), ::mem::transmute(b))); + let r: u8x8 = ::mem::transmute(vpmax_u8( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -1048,7 +1584,10 @@ let a = u16x4::new(1, 2, 3, 4); let b = u16x4::new(0, 3, 2, 5); let e = u16x4::new(2, 4, 3, 5); - let r: u16x4 = ::mem::transmute(vpmax_u16(::mem::transmute(a), ::mem::transmute(b))); + let r: u16x4 = ::mem::transmute(vpmax_u16( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -1057,7 +1596,10 @@ let a = u32x2::new(1, 2); let b = u32x2::new(0, 3); let e = u32x2::new(2, 3); - let r: u32x2 = ::mem::transmute(vpmax_u32(::mem::transmute(a), ::mem::transmute(b))); + let r: u32x2 = ::mem::transmute(vpmax_u32( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } @@ -1066,7 +1608,15 @@ let a = f32x2::new(1., -2.); let b = f32x2::new(0., 3.); let e = f32x2::new(1., 3.); - let r: f32x2 = ::mem::transmute(vpmax_f32(::mem::transmute(a), ::mem::transmute(b))); + let r: f32x2 = ::mem::transmute(vpmax_f32( + ::mem::transmute(a), + ::mem::transmute(b), + )); assert_eq!(r, e); } } + +#[cfg(test)] +#[cfg(target_endian = "little")] +#[path = "table_lookup_tests.rs"] +mod table_lookup_tests; diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/arm/table_lookup_tests.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/arm/table_lookup_tests.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/arm/table_lookup_tests.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/arm/table_lookup_tests.rs 2018-12-04 23:42:58.000000000 +0000 @@ -0,0 +1,1042 @@ +//! Tests for ARM+v7+neon table lookup (vtbl, vtbx) intrinsics. +//! +//! These are included in `{arm, aarch64}::neon`. + +use super::*; + +#[cfg(target_arch = "aarch64")] +use coresimd::aarch64::*; + +#[cfg(target_arch = "arm")] +use coresimd::arm::*; + +use coresimd::simd::*; +use std::mem; +use stdsimd_test::simd_test; + +macro_rules! test_vtbl { + ($test_name:ident => $fn_id:ident: + - table[$table_t:ident]: [$($table_v:expr),*] | + $(- ctrl[$ctrl_t:ident]: [$($ctrl_v:expr),*] => [$($exp_v:expr),*])|* + ) => { + #[simd_test(enable = "neon")] + unsafe fn $test_name() { + // create table as array, and transmute it to + // arm's table type + let table: $table_t = ::mem::transmute([$($table_v),*]); + + // For each control vector, perform a table lookup and + // verify the result: + $( + { + let ctrl: $ctrl_t = ::mem::transmute([$($ctrl_v),*]); + let result = $fn_id(table, ::mem::transmute(ctrl)); + let result: $ctrl_t = ::mem::transmute(result); + let expected: $ctrl_t = ::mem::transmute([$($exp_v),*]); + assert_eq!(result, expected); + } + )* + } + } +} + +// ARM+v7+neon and AArch64+neon tests + +test_vtbl!( + test_vtbl1_s8 => vtbl1_s8: + - table[int8x8_t]: [0_i8, -11, 2, 3, 4, 5, 6, 7] | + - ctrl[i8x8]: [3_i8, 4, 1, 6, 0, 2, 7, 5] => [3_i8, 4, -11, 6, 0, 2, 7, 5] | + - ctrl[i8x8]: [3_i8, 8, 1, -9, 10, 2, 15, 5] => [3_i8, 0, -11, 0, 0, 2, 0, 5] +); + +test_vtbl!( + test_vtbl1_u8 => vtbl1_u8: + - table[uint8x8_t]: [0_u8, 1, 2, 3, 4, 5, 6, 7] | + - ctrl[u8x8]: [3_u8, 4, 1, 6, 0, 2, 7, 5] => [3_u8, 4, 1, 6, 0, 2, 7, 5] | + - ctrl[u8x8]: [3_u8, 8, 1, 9, 10, 2, 15, 5] => [3_u8, 0, 1, 0, 0, 2, 0, 5] +); + +test_vtbl!( + test_vtbl1_p8 => vtbl1_p8: + - table[poly8x8_t]: [0_u8, 1, 2, 3, 4, 5, 6, 7] | + - ctrl[u8x8]: [3_u8, 4, 1, 6, 0, 2, 7, 5] => [3_u8, 4, 1, 6, 0, 2, 7, 5] | + - ctrl[u8x8]: [3_u8, 8, 1, 9, 10, 2, 15, 5] => [3_u8, 0, 1, 0, 0, 2, 0, 5] +); + +test_vtbl!( + test_vtbl2_s8 => vtbl2_s8: + - table[int8x8x2_t]: [ + 0_i8, -17, 34, 51, 68, 85, 102, 119, + -106, -93, -84, -117, -104, -116, -72, -121 + ] | + - ctrl[i8x8]: [127_i8, 15, 1, 14, 2, 13, 3, 12] => [0_i8, -121, -17, -72, 34, -116, 51, -104] | + - ctrl[i8x8]: [4_i8, 11, 16, 10, 6, -19, 7, 18] => [68_i8, -117, 0, -84, 102, 0, 119, 0] +); + +test_vtbl!( + test_vtbl2_u8 => vtbl2_u8: + - table[uint8x8x2_t]: [ + 0_u8, 17, 34, 51, 68, 85, 102, 119, + 136, 153, 170, 187, 204, 221, 238, 255 + ] | + - ctrl[u8x8]: [127_u8, 15, 1, 14, 2, 13, 3, 12] => [0_u8, 255, 17, 238, 34, 221, 51, 204] | + - ctrl[u8x8]: [4_u8, 11, 16, 10, 6, 19, 7, 18] => [68_u8, 187, 0, 170, 102, 0, 119, 0] +); + +test_vtbl!( + test_vtbl2_p8 => vtbl2_p8: + - table[poly8x8x2_t]: [ + 0_u8, 17, 34, 51, 68, 85, 102, 119, + 136, 153, 170, 187, 204, 221, 238, 255 + ] | + - ctrl[u8x8]: [127_u8, 15, 1, 14, 2, 13, 3, 12] => [0_u8, 255, 17, 238, 34, 221, 51, 204] | + - ctrl[u8x8]: [4_u8, 11, 16, 10, 6, 19, 7, 18] => [68_u8, 187, 0, 170, 102, 0, 119, 0] +); + +test_vtbl!( + test_vtbl3_s8 => vtbl3_s8: + - table[int8x8x3_t]: [ + 0_i8, -17, 34, 51, 68, 85, 102, 119, + -106, -93, -84, -117, -104, -116, -72, -121, + 0, 1, -2, 3, 4, -5, 6, 7 + ] | + - ctrl[i8x8]: [127_i8, 15, 1, 19, 2, 13, 21, 12] => [0_i8, -121, -17, 3, 34, -116, -5, -104] | + - ctrl[i8x8]: [4_i8, 11, 16, 10, 6, -27, 7, 18] => [68_i8, -117, 0, -84, 102, 0, 119, -2] +); + +test_vtbl!( + test_vtbl3_u8 => vtbl3_u8: + - table[uint8x8x3_t]: [ + 0_u8, 17, 34, 51, 68, 85, 102, 119, + 136, 153, 170, 187, 204, 221, 238, 255, + 0, 1, 2, 3, 4, 5, 6, 7 + ] | + - ctrl[u8x8]: [127_u8, 15, 1, 19, 2, 13, 21, 12] => [0_u8, 255, 17, 3, 34, 221, 5, 204] | + - ctrl[u8x8]: [4_u8, 11, 16, 10, 6, 27, 7, 18] => [68_u8, 187, 0, 170, 102, 0, 119, 2] +); + +test_vtbl!( + test_vtbl3_p8 => vtbl3_p8: + - table[poly8x8x3_t]: [ + 0_u8, 17, 34, 51, 68, 85, 102, 119, + 136, 153, 170, 187, 204, 221, 238, 255, + 0, 1, 2, 3, 4, 5, 6, 7 + ] | + - ctrl[u8x8]: [127_u8, 15, 1, 19, 2, 13, 21, 12] => [0_u8, 255, 17, 3, 34, 221, 5, 204] | + - ctrl[u8x8]: [4_u8, 11, 16, 10, 6, 27, 7, 18] => [68_u8, 187, 0, 170, 102, 0, 119, 2] +); + +test_vtbl!( + test_vtbl4_s8 => vtbl4_s8: + - table[int8x8x4_t]: [ + 0_i8, -17, 34, 51, 68, 85, 102, 119, + -106, -93, -84, -117, -104, -116, -72, -121, + 0, 1, -2, 3, 4, -5, 6, 7, + 8, -9, 10, 11, 12, -13, 14, 15 + ] | + - ctrl[i8x8]: [127_i8, 15, 1, 19, 2, 13, 25, 12] => [0_i8, -121, -17, 3, 34, -116, -9, -104] | + - ctrl[i8x8]: [4_i8, 11, 32, 10, -33, 27, 7, 18] => [68_i8, -117, 0, -84, 0, 11, 119, -2] +); + +test_vtbl!( + test_vtbl4_u8 => vtbl4_u8: + - table[uint8x8x4_t]: [ + 0_u8, 17, 34, 51, 68, 85, 102, 119, + 136, 153, 170, 187, 204, 221, 238, 255, + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15 + ] | + - ctrl[u8x8]: [127_u8, 15, 1, 19, 2, 13, 21, 12] => [0_u8, 255, 17, 3, 34, 221, 5, 204] | + - ctrl[u8x8]: [4_u8, 11, 16, 10, 6, 27, 7, 18] => [68_u8, 187, 0, 170, 102, 11, 119, 2] +); + +test_vtbl!( + test_vtbl4_p8 => vtbl4_p8: + - table[poly8x8x4_t]: [ + 0_u8, 17, 34, 51, 68, 85, 102, 119, + 136, 153, 170, 187, 204, 221, 238, 255, + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15 + ] | + - ctrl[u8x8]: [127_u8, 15, 1, 19, 2, 13, 21, 12] => [0_u8, 255, 17, 3, 34, 221, 5, 204] | + - ctrl[u8x8]: [4_u8, 11, 16, 10, 6, 27, 7, 18] => [68_u8, 187, 0, 170, 102, 11, 119, 2] +); + +macro_rules! test_vtbx { + ($test_name:ident => $fn_id:ident: + - table[$table_t:ident]: [$($table_v:expr),*] | + - ext[$ext_t:ident]: [$($ext_v:expr),*] | + $(- ctrl[$ctrl_t:ident]: [$($ctrl_v:expr),*] => [$($exp_v:expr),*])|* + ) => { + #[simd_test(enable = "neon")] + unsafe fn $test_name() { + // create table as array, and transmute it to + // arm's table type + let table: $table_t = ::mem::transmute([$($table_v),*]); + let ext: $ext_t = ::mem::transmute([$($ext_v),*]); + + // For each control vector, perform a table lookup and + // verify the result: + $( + { + let ctrl: $ctrl_t = ::mem::transmute([$($ctrl_v),*]); + let result = $fn_id(ext, table, ::mem::transmute(ctrl)); + let result: $ctrl_t = ::mem::transmute(result); + let expected: $ctrl_t = ::mem::transmute([$($exp_v),*]); + assert_eq!(result, expected); + } + )* + } + } +} + +test_vtbx!( + test_vtbx1_s8 => vtbx1_s8: + - table[int8x8_t]: [0_i8, 1, 2, -3, 4, 5, 6, 7] | + - ext[int8x8_t]: [50_i8, 51, 52, 53, 54, 55, 56, 57] | + - ctrl[i8x8]: [3_i8, 4, 1, 6, 0, 2, 7, 5] => [-3_i8, 4, 1, 6, 0, 2, 7, 5] | + - ctrl[i8x8]: [3_i8, 8, 1, 9, 10, 2, -15, 5] => [-3_i8, 51, 1, 53, 54, 2, 56, 5] +); + +test_vtbx!( + test_vtbx1_u8 => vtbx1_u8: + - table[uint8x8_t]: [0_u8, 1, 2, 3, 4, 5, 6, 7] | + - ext[uint8x8_t]: [50_u8, 51, 52, 53, 54, 55, 56, 57] | + - ctrl[u8x8]: [3_u8, 4, 1, 6, 0, 2, 7, 5] => [3_u8, 4, 1, 6, 0, 2, 7, 5] | + - ctrl[u8x8]: [3_u8, 8, 1, 9, 10, 2, 15, 5] => [3_u8, 51, 1, 53, 54, 2, 56, 5] +); + +test_vtbx!( + test_vtbx1_p8 => vtbx1_p8: + - table[poly8x8_t]: [0_u8, 1, 2, 3, 4, 5, 6, 7] | + - ext[poly8x8_t]: [50_u8, 51, 52, 53, 54, 55, 56, 57] | + - ctrl[u8x8]: [3_u8, 4, 1, 6, 0, 2, 7, 5] => [3_u8, 4, 1, 6, 0, 2, 7, 5] | + - ctrl[u8x8]: [3_u8, 8, 1, 9, 10, 2, 15, 5] => [3_u8, 51, 1, 53, 54, 2, 56, 5] +); + +test_vtbx!( + test_vtbx2_s8 => vtbx2_s8: + - table[int8x8x2_t]: [0_i8, 1, 2, -3, 4, 5, 6, 7, 8, 9, -10, 11, 12, -13, 14, 15] | + - ext[int8x8_t]: [50_i8, 51, 52, 53, 54, 55, 56, 57] | + - ctrl[i8x8]: [3_i8, 4, 1, 6, 10, 2, 7, 15] => [-3_i8, 4, 1, 6, -10, 2, 7, 15] | + - ctrl[i8x8]: [3_i8, 8, 1, 10, 17, 2, 15, -19] => [-3_i8, 8, 1, -10, 54, 2, 15, 57] +); + +test_vtbx!( + test_vtbx2_u8 => vtbx2_u8: + - table[uint8x8x2_t]: [0_i8, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] | + - ext[uint8x8_t]: [50_i8, 51, 52, 53, 54, 55, 56, 57] | + - ctrl[u8x8]: [3_u8, 4, 1, 6, 10, 2, 7, 15] => [3_i8, 4, 1, 6, 10, 2, 7, 15] | + - ctrl[u8x8]: [3_u8, 8, 1, 10, 17, 2, 15, 19] => [3_i8, 8, 1, 10, 54, 2, 15, 57] +); + +test_vtbx!( + test_vtbx2_p8 => vtbx2_p8: + - table[poly8x8x2_t]: [0_i8, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] | + - ext[poly8x8_t]: [50_i8, 51, 52, 53, 54, 55, 56, 57] | + - ctrl[u8x8]: [3_u8, 4, 1, 6, 10, 2, 7, 15] => [3_i8, 4, 1, 6, 10, 2, 7, 15] | + - ctrl[u8x8]: [3_u8, 8, 1, 10, 17, 2, 15, 19] => [3_i8, 8, 1, 10, 54, 2, 15, 57] +); + +test_vtbx!( + test_vtbx3_s8 => vtbx3_s8: + - table[int8x8x3_t]: [ + 0_i8, 1, 2, -3, 4, 5, 6, 7, + 8, 9, -10, 11, 12, -13, 14, 15, + 16, -17, 18, 19, 20, 21, 22, 23 ] | + - ext[int8x8_t]: [50_i8, 51, 52, 53, 54, 55, 56, 57] | + - ctrl[i8x8]: [3_i8, 4, 17, 22, 10, 2, 7, 15] => [-3_i8, 4, -17, 22, -10, 2, 7, 15] | + - ctrl[i8x8]: [3_i8, 8, 17, 10, 37, 2, 19, -29] => [-3_i8, 8, -17, -10, 54, 2, 19, 57] +); + +test_vtbx!( + test_vtbx3_u8 => vtbx3_u8: + - table[uint8x8x3_t]: [ + 0_i8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23 ] | + - ext[uint8x8_t]: [50_i8, 51, 52, 53, 54, 55, 56, 57] | + - ctrl[u8x8]: [3_u8, 4, 17, 22, 10, 2, 7, 15] => [3_i8, 4, 17, 22, 10, 2, 7, 15] | + - ctrl[u8x8]: [3_u8, 8, 17, 10, 37, 2, 19, 29] => [3_i8, 8, 17, 10, 54, 2, 19, 57] +); + +test_vtbx!( + test_vtbx3_p8 => vtbx3_p8: + - table[poly8x8x3_t]: [ + 0_i8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23 ] | + - ext[poly8x8_t]: [50_i8, 51, 52, 53, 54, 55, 56, 57] | + - ctrl[u8x8]: [3_u8, 4, 17, 22, 10, 2, 7, 15] => [3_i8, 4, 17, 22, 10, 2, 7, 15] | + - ctrl[u8x8]: [3_u8, 8, 17, 10, 37, 2, 19, 29] => [3_i8, 8, 17, 10, 54, 2, 19, 57] +); + +test_vtbx!( + test_vtbx4_s8 => vtbx4_s8: + - table[int8x8x4_t]: [ + 0_i8, 1, 2, -3, 4, 5, 6, 7, + 8, 9, -10, 11, 12, -13, 14, 15, + 16, -17, 18, 19, 20, 21, 22, 23, + -24, 25, 26, -27, 28, -29, 30, 31] | + - ext[int8x8_t]: [50_i8, 51, 52, 53, 54, 55, 56, 57] | + - ctrl[i8x8]: [3_i8, 31, 17, 22, 10, 29, 7, 15] => [-3_i8, 31, -17, 22, -10, -29, 7, 15] | + - ctrl[i8x8]: [3_i8, 8, 17, 10, 37, 2, 19, -42] => [-3_i8, 8, -17, -10, 54, 2, 19, 57] +); + +test_vtbx!( + test_vtbx4_u8 => vtbx4_u8: + - table[uint8x8x4_t]: [ + 0_i8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31] | + - ext[uint8x8_t]: [50_i8, 51, 52, 53, 54, 55, 56, 57] | + - ctrl[u8x8]: [3_u8, 31, 17, 22, 10, 29, 7, 15] => [3_i8, 31, 17, 22, 10, 29, 7, 15] | + - ctrl[u8x8]: [3_u8, 8, 17, 10, 37, 2, 19, 42] => [3_i8, 8, 17, 10, 54, 2, 19, 57] +); + +test_vtbx!( + test_vtbx4_p8 => vtbx4_p8: + - table[poly8x8x4_t]: [ + 0_i8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31] | + - ext[poly8x8_t]: [50_i8, 51, 52, 53, 54, 55, 56, 57] | + - ctrl[u8x8]: [3_u8, 31, 17, 22, 10, 29, 7, 15] => [3_i8, 31, 17, 22, 10, 29, 7, 15] | + - ctrl[u8x8]: [3_u8, 8, 17, 10, 37, 2, 19, 42] => [3_i8, 8, 17, 10, 54, 2, 19, 57] +); + +// Aarch64 tests + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl1_s8 => vqtbl1_s8: + - table[int8x16_t]: [ + 0_i8, -17, 34, 51, 68, 85, 102, 119, + -106, -93, -84, -117, -104, -116, -72, -121 + ] | + - ctrl[i8x8]: [127_i8, 15, 1, 14, 2, 13, 3, 12] => [0_i8, -121, -17, -72, 34, -116, 51, -104] | + - ctrl[i8x8]: [4_i8, 11, 16, 10, 6, 19, 7, 18] => [68_i8, -117, 0, -84, 102, 0, 119, 0] +); + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl1q_s8 => vqtbl1q_s8: + - table[int8x16_t]: [ + 0_i8, -17, 34, 51, 68, 85, 102, 119, + -106, -93, -84, -117, -104, -116, -72, -121 + ] | + - ctrl[i8x16]: [127_i8, 15, 1, 14, 2, 13, 3, 12, 4_i8, 11, 16, 10, 6, 19, 7, 18] + => [0_i8, -121, -17, -72, 34, -116, 51, -104, 68, -117, 0, -84, 102, 0, 119, 0] +); + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl1_u8 => vqtbl1_u8: + - table[uint8x16_t]: [ + 0_u8, 17, 34, 51, 68, 85, 102, 119, + 106, 93, 84, 117, 104, 116, 72, 121 + ] | + - ctrl[u8x8]: [127_u8, 15, 1, 14, 2, 13, 3, 12] => [0_u8, 121, 17, 72, 34, 116, 51, 104] | + - ctrl[u8x8]: [4_u8, 11, 16, 10, 6, 19, 7, 18] => [68_u8, 117, 0, 84, 102, 0, 119, 0] +); + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl1q_u8 => vqtbl1q_u8: + - table[uint8x16_t]: [ + 0_u8, 17, 34, 51, 68, 85, 102, 119, + 106, 93, 84, 117, 104, 116, 72, 121 + ] | + - ctrl[u8x16]: [127_u8, 15, 1, 14, 2, 13, 3, 12, 4_u8, 11, 16, 10, 6, 19, 7, 18] + => [0_u8, 121, 17, 72, 34, 116, 51, 104, 68, 117, 0, 84, 102, 0, 119, 0] +); + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl1_p8 => vqtbl1_p8: + - table[poly8x16_t]: [ + 0_u8, 17, 34, 51, 68, 85, 102, 119, + 106, 93, 84, 117, 104, 116, 72, 121 + ] | + - ctrl[u8x8]: [127_u8, 15, 1, 14, 2, 13, 3, 12] => [0_u8, 121, 17, 72, 34, 116, 51, 104] | + - ctrl[u8x8]: [4_u8, 11, 16, 10, 6, 19, 7, 18] => [68_u8, 117, 0, 84, 102, 0, 119, 0] +); + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl1q_p8 => vqtbl1q_p8: + - table[poly8x16_t]: [ + 0_u8, 17, 34, 51, 68, 85, 102, 119, + 106, 93, 84, 117, 104, 116, 72, 121 + ] | + - ctrl[u8x16]: [127_u8, 15, 1, 14, 2, 13, 3, 12, 4_u8, 11, 16, 10, 6, 19, 7, 18] + => [0_u8, 121, 17, 72, 34, 116, 51, 104, 68, 117, 0, 84, 102, 0, 119, 0] +); + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl2_s8 => vqtbl2_s8: + - table[int8x16x2_t]: [ + 0_i8, -1, 2, -3, 4, -5, 6, -7, + 8, -9, 10, -11, 12, -13, 14, -15, + 16, -17, 18, -19, 20, -21, 22, -23, + 24, -25, 26, -27, 28, -29, 30, -31 + ] | + - ctrl[i8x8]: [80_i8, 15, 1, 24, 2, 13, 3, 29] => [0_i8, -15, -1, 24, 2, -13, -3, -29] | + - ctrl[i8x8]: [4_i8, 31, 32, 10, 6, 49, 7, 18] => [4_i8, -31, 0, 10, 6, 0, -7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl2q_s8 => vqtbl2q_s8: + - table[int8x16x2_t]: [ + 0_i8, -1, 2, -3, 4, -5, 6, -7, + 8, -9, 10, -11, 12, -13, 14, -15, + 16, -17, 18, -19, 20, -21, 22, -23, + 24, -25, 26, -27, 28, -29, 30, -31 + ] | + - ctrl[i8x16]: [80_i8, 15, 1, 24, 2, 13, 3, 29, 4_i8, 31, 32, 10, 6, 49, 7, 18] + => [0_i8, -15, -1, 24, 2, -13, -3, -29, 4, -31, 0, 10, 6, 0, -7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl2_u8 => vqtbl2_u8: + - table[uint8x16x2_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31 + ] | + - ctrl[u8x8]: [80_u8, 15, 1, 24, 2, 13, 3, 29] => [0_u8, 15, 1, 24, 2, 13, 3, 29] | + - ctrl[u8x8]: [4_u8, 31, 32, 10, 6, 49, 7, 18] => [4_u8, 31, 0, 10, 6, 0, 7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl2q_u8 => vqtbl2q_u8: + - table[uint8x16x2_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31 + ] | + - ctrl[u8x16]: [80_u8, 15, 1, 24, 2, 13, 3, 29, 4_u8, 31, 32, 10, 6, 49, 7, 18] + => [0_u8, 15, 1, 24, 2, 13, 3, 29, 4, 31, 0, 10, 6, 0, 7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl2_p8 => vqtbl2_p8: + - table[poly8x16x2_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31 + ] | + - ctrl[u8x8]: [80_u8, 15, 1, 24, 2, 13, 3, 29] => [0_u8, 15, 1, 24, 2, 13, 3, 29] | + - ctrl[u8x8]: [4_u8, 31, 32, 10, 6, 49, 7, 18] => [4_u8, 31, 0, 10, 6, 0, 7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl2q_p8 => vqtbl2q_p8: + - table[poly8x16x2_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31 + ] | + - ctrl[u8x16]: [80_u8, 15, 1, 24, 2, 13, 3, 29, 4_u8, 31, 32, 10, 6, 49, 7, 18] + => [0_u8, 15, 1, 24, 2, 13, 3, 29, 4, 31, 0, 10, 6, 0, 7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl3_s8 => vqtbl3_s8: + - table[int8x16x3_t]: [ + 0_i8, -1, 2, -3, 4, -5, 6, -7, + 8, -9, 10, -11, 12, -13, 14, -15, + 16, -17, 18, -19, 20, -21, 22, -23, + 24, -25, 26, -27, 28, -29, 30, -31, + 32, -33, 34, -35, 36, -37, 38, -39, + 40, -41, 42, -43, 44, -45, 46, -47 + ] | + - ctrl[i8x8]: [80_i8, 15, 1, 24, 2, 13, 3, 29] => [0_i8, -15, -1, 24, 2, -13, -3, -29] | + - ctrl[i8x8]: [4_i8, 32, 46, 51, 6, 49, 7, 18] => [4_i8, 32, 46, 0, 6, 0, -7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl3q_s8 => vqtbl3q_s8: + - table[int8x16x3_t]: [ + 0_i8, -1, 2, -3, 4, -5, 6, -7, + 8, -9, 10, -11, 12, -13, 14, -15, + 16, -17, 18, -19, 20, -21, 22, -23, + 24, -25, 26, -27, 28, -29, 30, -31, + 32, -33, 34, -35, 36, -37, 38, -39, + 40, -41, 42, -43, 44, -45, 46, -47 + ] | + - ctrl[i8x16]: [80_i8, 15, 1, 24, 2, 13, 3, 29, 4_i8, 32, 46, 51, 6, 49, 7, 18] + => [0_i8, -15, -1, 24, 2, -13, -3, -29, 4, 32, 46, 0, 6, 0, -7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl3_u8 => vqtbl3_u8: + - table[uint8x16x3_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47 + ] | + - ctrl[u8x8]: [80_u8, 15, 1, 24, 2, 13, 3, 29] => [0_u8, 15, 1, 24, 2, 13, 3, 29] | + - ctrl[u8x8]: [4_u8, 32, 46, 51, 6, 49, 7, 18] => [4_u8, 32, 46, 0, 6, 0, 7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl3q_u8 => vqtbl3q_u8: + - table[uint8x16x3_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47 + ] | + - ctrl[u8x16]: [80_u8, 15, 1, 24, 2, 13, 3, 29, 4_u8, 32, 46, 51, 6, 49, 7, 18] + => [0_u8, 15, 1, 24, 2, 13, 3, 29, 4, 32, 46, 0, 6, 0, 7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl3_p8 => vqtbl3_p8: + - table[poly8x16x3_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47 + ] | + - ctrl[u8x8]: [80_u8, 15, 1, 24, 2, 13, 3, 29] => [0_u8, 15, 1, 24, 2, 13, 3, 29] | + - ctrl[u8x8]: [4_u8, 32, 46, 51, 6, 49, 7, 18] => [4_u8, 32, 46, 0, 6, 0, 7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl3q_p8 => vqtbl3q_p8: + - table[poly8x16x3_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47 + ] | + - ctrl[u8x16]: [80_u8, 15, 1, 24, 2, 13, 3, 29, 4_u8, 32, 46, 51, 6, 49, 7, 18] + => [0_u8, 15, 1, 24, 2, 13, 3, 29, 4, 32, 46, 0, 6, 0, 7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl4_s8 => vqtbl4_s8: + - table[int8x16x4_t]: [ + 0_i8, -1, 2, -3, 4, -5, 6, -7, + 8, -9, 10, -11, 12, -13, 14, -15, + 16, -17, 18, -19, 20, -21, 22, -23, + 24, -25, 26, -27, 28, -29, 30, -31, + 32, -33, 34, -35, 36, -37, 38, -39, + 40, -41, 42, -43, 44, -45, 46, -47, + 48, -49, 50, -51, 52, -53, 54, -55, + 56, -57, 58, -59, 60, -61, 62, -63 + ] | + - ctrl[i8x8]: [80_i8, 15, 1, 24, 2, 13, 3, 29] => [0_i8, -15, -1, 24, 2, -13, -3, -29] | + - ctrl[i8x8]: [4_i8, 46, 64, 51, 6, 71, 7, 18] => [4_i8, 46, 0, -51, 6, 0, -7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl4q_s8 => vqtbl4q_s8: + - table[int8x16x4_t]: [ + 0_i8, -1, 2, -3, 4, -5, 6, -7, + 8, -9, 10, -11, 12, -13, 14, -15, + 16, -17, 18, -19, 20, -21, 22, -23, + 24, -25, 26, -27, 28, -29, 30, -31, + 32, -33, 34, -35, 36, -37, 38, -39, + 40, -41, 42, -43, 44, -45, 46, -47, + 48, -49, 50, -51, 52, -53, 54, -55, + 56, -57, 58, -59, 60, -61, 62, -63 + ] | + - ctrl[i8x16]: [80_i8, 15, 1, 24, 2, 13, 3, 29, 4_i8, 46, 64, 51, 6, 71, 7, 18] + => [0_i8, -15, -1, 24, 2, -13, -3, -29, 4, 46, 0, -51, 6, 0, -7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl4_u8 => vqtbl4_u8: + - table[uint8x16x4_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63 + ] | + - ctrl[u8x8]: [80_u8, 15, 1, 24, 2, 13, 3, 29] => [0_u8, 15, 1, 24, 2, 13, 3, 29] | + - ctrl[u8x8]: [4_u8, 46, 64, 51, 6, 71, 7, 18] => [4_u8, 46, 0, 51, 6, 0, 7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl4q_u8 => vqtbl4q_u8: + - table[uint8x16x4_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63 + ] | + - ctrl[u8x16]: [80_u8, 15, 1, 24, 2, 13, 3, 29, 4_u8, 46, 64, 51, 6, 71, 7, 18] + => [0_u8, 15, 1, 24, 2, 13, 3, 29, 4, 46, 0, 51, 6, 0, 7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl4_p8 => vqtbl4_p8: + - table[poly8x16x4_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63 + ] | + - ctrl[u8x8]: [80_u8, 15, 1, 24, 2, 13, 3, 29] => [0_u8, 15, 1, 24, 2, 13, 3, 29] | + - ctrl[u8x8]: [4_u8, 46, 64, 51, 6, 71, 7, 18] => [4_u8, 46, 0, 51, 6, 0, 7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbl!( + test_vqtbl4q_p8 => vqtbl4q_p8: + - table[poly8x16x4_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63 + ] | + - ctrl[u8x16]: [80_u8, 15, 1, 24, 2, 13, 3, 29, 4_u8, 46, 64, 51, 6, 71, 7, 18] + => [0_u8, 15, 1, 24, 2, 13, 3, 29, 4, 46, 0, 51, 6, 0, 7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx1_s8 => vqtbx1_s8: + - table[int8x16_t]: [ + 0_i8, -17, 34, 51, 68, 85, 102, 119, + -106, -93, -84, -117, -104, -116, -72, -121 + ] | + - ext[int8x8_t]: [100_i8, -101, 102, -103, 104, -105, 106, -107] | + - ctrl[i8x8]: [127_i8, 15, 1, 14, 2, 13, 3, 12] => [100_i8, -121, -17, -72, 34, -116, 51, -104] | + - ctrl[i8x8]: [4_i8, 11, 16, 10, 6, 19, 7, 18] => [68_i8, -117, 102, -84, 102, -105, 119, -107] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx1q_s8 => vqtbx1q_s8: + - table[int8x16_t]: [ + 0_i8, -17, 34, 51, 68, 85, 102, 119, + -106, -93, -84, -117, -104, -116, -72, -121 + ] | + - ext[int8x16_t]: [ + 100_i8, -101, 102, -103, 104, -105, 106, -107, + 108, -109, 110, -111, 112, -113, 114, -115 + ] | + - ctrl[i8x16]: [127_i8, 15, 1, 14, 2, 13, 3, 12, 4_i8, 11, 16, 10, 6, 19, 7, 18] + => [100_i8, -121, -17, -72, 34, -116, 51, -104, 68, -117, 110, -84, 102, -113, 119, -115] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx1_u8 => vqtbx1_u8: + - table[uint8x16_t]: [ + 0_u8, 17, 34, 51, 68, 85, 102, 119, + 106, 93, 84, 117, 104, 116, 72, 121 + ] | + - ext[uint8x8_t]: [100_u8, 101, 102, 103, 104, 105, 106, 107] | + - ctrl[u8x8]: [127_u8, 15, 1, 14, 2, 13, 3, 12] => [100_u8, 121, 17, 72, 34, 116, 51, 104] | + - ctrl[u8x8]: [4_u8, 11, 16, 10, 6, 19, 7, 18] => [68_u8, 117, 102, 84, 102, 105, 119, 107] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx1q_u8 => vqtbx1q_u8: + - table[uint8x16_t]: [ + 0_u8, 17, 34, 51, 68, 85, 102, 119, + 106, 93, 84, 117, 104, 116, 72, 121 + ] | + - ext[uint8x16_t]: [ + 100_u8, 101, 102, 103, 104, 105, 106, 107, + 108, 109, 110, 111, 112, 113, 114, 115 + ] | + - ctrl[u8x16]: [127_u8, 15, 1, 14, 2, 13, 3, 12, 4_u8, 11, 16, 10, 6, 19, 7, 18] + => [100_u8, 121, 17, 72, 34, 116, 51, 104, 68, 117, 110, 84, 102, 113, 119, 115] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx1_p8 => vqtbx1_p8: + - table[poly8x16_t]: [ + 0_u8, 17, 34, 51, 68, 85, 102, 119, + 106, 93, 84, 117, 104, 116, 72, 121 + ] | + - ext[poly8x8_t]: [100_u8, 101, 102, 103, 104, 105, 106, 107] | + - ctrl[u8x8]: [127_u8, 15, 1, 14, 2, 13, 3, 12] => [100_u8, 121, 17, 72, 34, 116, 51, 104] | + - ctrl[u8x8]: [4_u8, 11, 16, 10, 6, 19, 7, 18] => [68_u8, 117, 102, 84, 102, 105, 119, 107] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx1q_p8 => vqtbx1q_p8: + - table[poly8x16_t]: [ + 0_u8, 17, 34, 51, 68, 85, 102, 119, + 106, 93, 84, 117, 104, 116, 72, 121 + ] | + - ext[poly8x16_t]: [ + 100_u8, 101, 102, 103, 104, 105, 106, 107, + 108, 109, 110, 111, 112, 113, 114, 115 + ] | + - ctrl[u8x16]: [127_u8, 15, 1, 14, 2, 13, 3, 12, 4_u8, 11, 16, 10, 6, 19, 7, 18] + => [100_u8, 121, 17, 72, 34, 116, 51, 104, 68, 117, 110, 84, 102, 113, 119, 115] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx2_s8 => vqtbx2_s8: + - table[int8x16x2_t]: [ + 0_i8, -1, 2, -3, 4, -5, 6, -7, + 8, -9, 10, -11, 12, -13, 14, -15, + 16, -17, 18, -19, 20, -21, 22, -23, + 24, -25, 26, -27, 28, -29, 30, -31 + ] | + - ext[int8x8_t]: [100_i8, -101, 102, -103, 104, -105, 106, -107] | + - ctrl[i8x8]: [80_i8, 15, 1, 24, 2, 13, 3, 29] => [100_i8, -15, -1, 24, 2, -13, -3, -29] | + - ctrl[i8x8]: [4_i8, 31, 32, 10, 6, 49, 7, 18] => [4_i8, -31, 102, 10, 6, -105, -7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx2q_s8 => vqtbx2q_s8: + - table[int8x16x2_t]: [ + 0_i8, -1, 2, -3, 4, -5, 6, -7, + 8, -9, 10, -11, 12, -13, 14, -15, + 16, -17, 18, -19, 20, -21, 22, -23, + 24, -25, 26, -27, 28, -29, 30, -31 + ] | + - ext[int8x16_t]: [ + 100_i8, -101, 102, -103, 104, -105, 106, -107, + 108, -109, 110, -111, 112, -113, 114, -115 + ] | + - ctrl[i8x16]: [80_i8, 15, 1, 24, 2, 13, 3, 29, 4_i8, 31, 32, 10, 6, 49, 7, 18] + => [100_i8, -15, -1, 24, 2, -13, -3, -29, 4, -31, 110, 10, 6, -113, -7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx2_u8 => vqtbx2_u8: + - table[uint8x16x2_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31 + ] | + - ext[uint8x8_t]: [100_u8, 101, 102, 103, 104, 105, 106, 107] | + - ctrl[u8x8]: [80_u8, 15, 1, 24, 2, 13, 3, 29] => [100_u8, 15, 1, 24, 2, 13, 3, 29] | + - ctrl[u8x8]: [4_u8, 31, 32, 10, 6, 49, 7, 18] => [4_u8, 31, 102, 10, 6, 105, 7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx2q_u8 => vqtbx2q_u8: + - table[uint8x16x2_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31 + ] | + - ext[uint8x16_t]: [ + 100_u8, 101, 102, 103, 104, 105, 106, 107, + 108, 109, 110, 111, 112, 113, 114, 115 + ] | + - ctrl[u8x16]: [80_u8, 15, 1, 24, 2, 13, 3, 29, 4_u8, 31, 32, 10, 6, 49, 7, 18] + => [100_u8, 15, 1, 24, 2, 13, 3, 29, 4, 31, 110, 10, 6, 113, 7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx2_p8 => vqtbx2_p8: + - table[poly8x16x2_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31 + ] | + - ext[poly8x8_t]: [100_u8, 101, 102, 103, 104, 105, 106, 107] | + - ctrl[u8x8]: [80_u8, 15, 1, 24, 2, 13, 3, 29] => [100_u8, 15, 1, 24, 2, 13, 3, 29] | + - ctrl[u8x8]: [4_u8, 31, 32, 10, 6, 49, 7, 18] => [4_u8, 31, 102, 10, 6, 105, 7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx2q_p8 => vqtbx2q_p8: + - table[poly8x16x2_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31 + ] | + - ext[poly8x16_t]: [ + 100_u8, 101, 102, 103, 104, 105, 106, 107, + 108, 109, 110, 111, 112, 113, 114, 115 + ] | + - ctrl[u8x16]: [80_u8, 15, 1, 24, 2, 13, 3, 29, 4_u8, 31, 32, 10, 6, 49, 7, 18] + => [100_u8, 15, 1, 24, 2, 13, 3, 29, 4, 31, 110, 10, 6, 113, 7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx3_s8 => vqtbx3_s8: + - table[int8x16x3_t]: [ + 0_i8, -1, 2, -3, 4, -5, 6, -7, + 8, -9, 10, -11, 12, -13, 14, -15, + 16, -17, 18, -19, 20, -21, 22, -23, + 24, -25, 26, -27, 28, -29, 30, -31, + 32, -33, 34, -35, 36, -37, 38, -39, + 40, -41, 42, -43, 44, -45, 46, -47 + ] | + - ext[int8x8_t]: [100_i8, -101, 102, -103, 104, -105, 106, -107] | + - ctrl[i8x8]: [80_i8, 15, 1, 24, 2, 13, 3, 29] => [100_i8, -15, -1, 24, 2, -13, -3, -29] | + - ctrl[i8x8]: [4_i8, 32, 46, 51, 6, 49, 7, 18] => [4_i8, 32, 46, -103, 6, -105, -7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx3q_s8 => vqtbx3q_s8: + - table[int8x16x3_t]: [ + 0_i8, -1, 2, -3, 4, -5, 6, -7, + 8, -9, 10, -11, 12, -13, 14, -15, + 16, -17, 18, -19, 20, -21, 22, -23, + 24, -25, 26, -27, 28, -29, 30, -31, + 32, -33, 34, -35, 36, -37, 38, -39, + 40, -41, 42, -43, 44, -45, 46, -47 + ] | + - ext[int8x16_t]: [ + 100_i8, -101, 102, -103, 104, -105, 106, -107, + 108, -109, 110, -111, 112, -113, 114, -115 + ] | + - ctrl[i8x16]: [80_i8, 15, 1, 24, 2, 13, 3, 29, 4_i8, 32, 46, 51, 6, 49, 7, 18] + => [100_i8, -15, -1, 24, 2, -13, -3, -29, 4, 32, 46, -111, 6, -113, -7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx3_u8 => vqtbx3_u8: + - table[uint8x16x3_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47 + ] | + - ext[uint8x8_t]: [100_u8, 101, 102, 103, 104, 105, 106, 107] | + - ctrl[u8x8]: [80_u8, 15, 1, 24, 2, 13, 3, 29] => [100_u8, 15, 1, 24, 2, 13, 3, 29] | + - ctrl[u8x8]: [4_u8, 32, 46, 51, 6, 49, 7, 18] => [4_u8, 32, 46, 103, 6, 105, 7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx3q_u8 => vqtbx3q_u8: + - table[uint8x16x3_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47 + ] | + - ext[uint8x16_t]: [ + 100_u8, 101, 102, 103, 104, 105, 106, 107, + 108, 109, 110, 111, 112, 113, 114, 115 + ] | + - ctrl[u8x16]: [80_u8, 15, 1, 24, 2, 13, 3, 29, 4_u8, 32, 46, 51, 6, 49, 7, 18] + => [100_u8, 15, 1, 24, 2, 13, 3, 29, 4, 32, 46, 111, 6, 113, 7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx3_p8 => vqtbx3_p8: + - table[poly8x16x3_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47 + ] | + - ext[poly8x8_t]: [100_u8, 101, 102, 103, 104, 105, 106, 107] | + - ctrl[u8x8]: [80_u8, 15, 1, 24, 2, 13, 3, 29] => [100_u8, 15, 1, 24, 2, 13, 3, 29] | + - ctrl[u8x8]: [4_u8, 32, 46, 51, 6, 49, 7, 18] => [4_u8, 32, 46, 103, 6, 105, 7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx3q_p8 => vqtbx3q_p8: + - table[poly8x16x3_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47 + ] | + - ext[poly8x16_t]: [ + 100_u8, 101, 102, 103, 104, 105, 106, 107, + 108, 109, 110, 111, 112, 113, 114, 115 + ] | + - ctrl[u8x16]: [80_u8, 15, 1, 24, 2, 13, 3, 29, 4_u8, 32, 46, 51, 6, 49, 7, 18] + => [100_u8, 15, 1, 24, 2, 13, 3, 29, 4, 32, 46, 111, 6, 113, 7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx4_s8 => vqtbx4_s8: + - table[int8x16x4_t]: [ + 0_i8, -1, 2, -3, 4, -5, 6, -7, + 8, -9, 10, -11, 12, -13, 14, -15, + 16, -17, 18, -19, 20, -21, 22, -23, + 24, -25, 26, -27, 28, -29, 30, -31, + 32, -33, 34, -35, 36, -37, 38, -39, + 40, -41, 42, -43, 44, -45, 46, -47, + 48, -49, 50, -51, 52, -53, 54, -55, + 56, -57, 58, -59, 60, -61, 62, -63 + ] | + - ext[int8x8_t]: [100_i8, -101, 102, -103, 104, -105, 106, -107] | + - ctrl[i8x8]: [80_i8, 15, 1, 24, 2, 13, 3, 29] => [100_i8, -15, -1, 24, 2, -13, -3, -29] | + - ctrl[i8x8]: [4_i8, 46, 64, 51, 6, 71, 7, 18] => [4_i8, 46, 102, -51, 6, -105, -7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx4q_s8 => vqtbx4q_s8: + - table[int8x16x4_t]: [ + 0_i8, -1, 2, -3, 4, -5, 6, -7, + 8, -9, 10, -11, 12, -13, 14, -15, + 16, -17, 18, -19, 20, -21, 22, -23, + 24, -25, 26, -27, 28, -29, 30, -31, + 32, -33, 34, -35, 36, -37, 38, -39, + 40, -41, 42, -43, 44, -45, 46, -47, + 48, -49, 50, -51, 52, -53, 54, -55, + 56, -57, 58, -59, 60, -61, 62, -63 + ] | + - ext[int8x16_t]: [ + 100_i8, -101, 102, -103, 104, -105, 106, -107, + 108, -109, 110, -111, 112, -113, 114, -115 + ] | + - ctrl[i8x16]: [80_i8, 15, 1, 24, 2, 13, 3, 29, 4_i8, 46, 64, 51, 6, 71, 7, 18] + => [100_i8, -15, -1, 24, 2, -13, -3, -29, 4, 46, 110, -51, 6, -113, -7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx4_u8 => vqtbx4_u8: + - table[uint8x16x4_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63 + ] | + - ext[uint8x8_t]: [100_u8, 101, 102, 103, 104, 105, 106, 107] | + - ctrl[u8x8]: [80_u8, 15, 1, 24, 2, 13, 3, 29] => [100_u8, 15, 1, 24, 2, 13, 3, 29] | + - ctrl[u8x8]: [4_u8, 46, 64, 51, 6, 71, 7, 18] => [4_u8, 46, 102, 51, 6, 105, 7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx4q_u8 => vqtbx4q_u8: + - table[uint8x16x4_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63 + ] | + - ext[uint8x16_t]: [ + 100_u8, 101, 102, 103, 104, 105, 106, 107, + 108, 109, 110, 111, 112, 113, 114, 115 + ] | + - ctrl[u8x16]: [80_u8, 15, 1, 24, 2, 13, 3, 29, 4_u8, 46, 64, 51, 6, 71, 7, 18] + => [100_u8, 15, 1, 24, 2, 13, 3, 29, 4, 46, 110, 51, 6, 113, 7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx4_p8 => vqtbx4_p8: + - table[poly8x16x4_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63 + ] | + - ext[poly8x8_t]: [100_u8, 101, 102, 103, 104, 105, 106, 107] | + - ctrl[u8x8]: [80_u8, 15, 1, 24, 2, 13, 3, 29] => [100_u8, 15, 1, 24, 2, 13, 3, 29] | + - ctrl[u8x8]: [4_u8, 46, 64, 51, 6, 71, 7, 18] => [4_u8, 46, 102, 51, 6, 105, 7, 18] +); + +#[cfg(target_arch = "aarch64")] +test_vtbx!( + test_vqtbx4q_p8 => vqtbx4q_p8: + - table[poly8x16x4_t]: [ + 0_u8, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, + 56, 57, 58, 59, 60, 61, 62, 63 + ] | + - ext[poly8x16_t]: [ + 100_u8, 101, 102, 103, 104, 105, 106, 107, + 108, 109, 110, 111, 112, 113, 114, 115 + ] | + - ctrl[u8x16]: [80_u8, 15, 1, 24, 2, 13, 3, 29, 4_u8, 46, 64, 51, 6, 71, 7, 18] + => [100_u8, 15, 1, 24, 2, 13, 3, 29, 4, 46, 110, 51, 6, 113, 7, 18] +); diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/mips/msa.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/mips/msa.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/mips/msa.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/mips/msa.rs 2018-12-04 23:42:58.000000000 +0000 @@ -55,12 +55,7 @@ -4, -3, -2, -1, -4, -3, -2, -1, ); - let r = i8x16( - 5, 5, 5, 5, - 5, 5, 5, 5, - 5, 5, 5, 5, - 5, 5, 5, 5, - ); + let r = i8x16(5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5); assert_eq!(r, msa::__msa_add_a_b(a, b)); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/mod.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/mod.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/mod.rs 2018-12-04 23:42:58.000000000 +0000 @@ -25,6 +25,8 @@ /// * [`mips64`] /// * [`PowerPC`] /// * [`PowerPC64`] +/// * [`NVPTX`] +/// * [`wasm32`] /// /// [`x86`]: https://rust-lang-nursery.github.io/stdsimd/x86/stdsimd/arch/index.html /// [`x86_64`]: https://rust-lang-nursery.github.io/stdsimd/x86_64/stdsimd/arch/index.html @@ -34,6 +36,8 @@ /// [`mips64`]: https://rust-lang-nursery.github.io/stdsimd/mips64/stdsimd/arch/index.html /// [`PowerPC`]: https://rust-lang-nursery.github.io/stdsimd/powerpc/stdsimd/arch/index.html /// [`PowerPC64`]: https://rust-lang-nursery.github.io/stdsimd/powerpc64/stdsimd/arch/index.html +/// [`NVPTX`]: https://rust-lang-nursery.github.io/stdsimd/nvptx/stdsimd/arch/index.html +/// [`wasm32`]: https://rust-lang-nursery.github.io/stdsimd/wasm32/stdsimd/arch/index.html #[stable(feature = "simd_arch", since = "1.27.0")] pub mod arch { /// Platform-specific intrinsics for the `x86` platform. @@ -84,7 +88,8 @@ /// Platform-specific intrinsics for the `wasm32` platform. /// /// See the [module documentation](../index.html) for more details. - #[cfg(target_arch = "wasm32")] + #[cfg(any(target_arch = "wasm32", dox))] + #[doc(cfg(target_arch = "mips"))] #[unstable(feature = "stdsimd", issue = "27731")] pub mod wasm32 { pub use coresimd::wasm32::*; @@ -129,6 +134,16 @@ pub mod powerpc64 { pub use coresimd::powerpc64::*; } + + /// Platform-specific intrinsics for the `NVPTX` platform. + /// + /// See the [module documentation](../index.html) for more details. + #[cfg(any(target_arch = "nvptx", target_arch = "nvptx64", dox))] + #[doc(cfg(any(target_arch = "nvptx", target_arch = "nvptx64")))] + #[unstable(feature = "stdsimd", issue = "27731")] + pub mod nvptx { + pub use coresimd::nvptx::*; + } } mod simd_llvm; @@ -146,7 +161,9 @@ #[cfg(any(target_arch = "arm", target_arch = "aarch64", dox))] #[doc(cfg(any(target_arch = "arm", target_arch = "aarch64")))] mod arm; -#[cfg(target_arch = "wasm32")] + +#[cfg(any(target_arch = "wasm32", dox))] +#[doc(cfg(target_arch = "wasm32"))] mod wasm32; #[cfg(any(target_arch = "mips", target_arch = "mips64", dox))] @@ -161,4 +178,6 @@ #[doc(cfg(target_arch = "powerpc64"))] mod powerpc64; +#[cfg(any(target_arch = "nvptx", target_arch = "nvptx64", dox))] +#[doc(cfg(any(target_arch = "nvptx", target_arch = "nvptx64")))] mod nvptx; diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/powerpc/altivec.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/powerpc/altivec.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/powerpc/altivec.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/powerpc/altivec.rs 2018-12-04 23:42:58.000000000 +0000 @@ -13,8 +13,8 @@ #![allow(non_camel_case_types)] -use coresimd::simd_llvm::*; use coresimd::simd::*; +use coresimd::simd_llvm::*; use mem; @@ -65,10 +65,87 @@ ) -> vector_signed_short; #[link_name = "llvm.ppc.altivec.vmsumuhs"] fn vmsumuhs( - a: vector_unsigned_short, b: vector_unsigned_short,c: vector_unsigned_int) -> vector_unsigned_int; + a: vector_unsigned_short, b: vector_unsigned_short, + c: vector_unsigned_int, + ) -> vector_unsigned_int; #[link_name = "llvm.ppc.altivec.vmsumshs"] fn vmsumshs( - a: vector_signed_short, b: vector_signed_short,c: vector_signed_int) -> vector_signed_int; + a: vector_signed_short, b: vector_signed_short, c: vector_signed_int, + ) -> vector_signed_int; + #[link_name = "llvm.ppc.altivec.vmsumubm"] + fn vmsumubm( + a: vector_unsigned_char, b: vector_unsigned_char, + c: vector_unsigned_int, + ) -> vector_unsigned_int; + #[link_name = "llvm.ppc.altivec.vmsummbm"] + fn vmsummbm( + a: vector_signed_char, b: vector_unsigned_char, c: vector_signed_int, + ) -> vector_signed_int; + #[link_name = "llvm.ppc.altivec.vmsumuhm"] + fn vmsumuhm( + a: vector_unsigned_short, b: vector_unsigned_short, + c: vector_unsigned_int, + ) -> vector_unsigned_int; + #[link_name = "llvm.ppc.altivec.vmsumshm"] + fn vmsumshm( + a: vector_signed_short, b: vector_signed_short, c: vector_signed_int, + ) -> vector_signed_int; + #[link_name = "llvm.ppc.altivec.vmaddfp"] + fn vmaddfp( + a: vector_float, b: vector_float, c: vector_float, + ) -> vector_float; + #[link_name = "llvm.ppc.altivec.vnmsubfp"] + fn vnmsubfp( + a: vector_float, b: vector_float, c: vector_float, + ) -> vector_float; + #[link_name = "llvm.ppc.altivec.vsum2sws"] + fn vsum2sws( + a: vector_signed_int, b: vector_signed_int, + ) -> vector_signed_int; + #[link_name = "llvm.ppc.altivec.vsum4ubs"] + fn vsum4ubs( + a: vector_unsigned_char, b: vector_unsigned_int, + ) -> vector_unsigned_int; + #[link_name = "llvm.ppc.altivec.vsum4sbs"] + fn vsum4sbs( + a: vector_signed_char, b: vector_signed_int, + ) -> vector_signed_int; + #[link_name = "llvm.ppc.altivec.vsum4shs"] + fn vsum4shs( + a: vector_signed_short, b: vector_signed_int, + ) -> vector_signed_int; + #[link_name = "llvm.ppc.altivec.vmuleub"] + fn vmuleub( + a: vector_unsigned_char, b: vector_unsigned_char, + ) -> vector_unsigned_short; + #[link_name = "llvm.ppc.altivec.vmulesb"] + fn vmulesb( + a: vector_signed_char, b: vector_signed_char, + ) -> vector_signed_short; + #[link_name = "llvm.ppc.altivec.vmuleuh"] + fn vmuleuh( + a: vector_unsigned_short, b: vector_unsigned_short, + ) -> vector_unsigned_int; + #[link_name = "llvm.ppc.altivec.vmulesh"] + fn vmulesh( + a: vector_signed_short, b: vector_signed_short, + ) -> vector_signed_int; + #[link_name = "llvm.ppc.altivec.vmuloub"] + fn vmuloub( + a: vector_unsigned_char, b: vector_unsigned_char, + ) -> vector_unsigned_short; + #[link_name = "llvm.ppc.altivec.vmulosb"] + fn vmulosb( + a: vector_signed_char, b: vector_signed_char, + ) -> vector_signed_short; + #[link_name = "llvm.ppc.altivec.vmulouh"] + fn vmulouh( + a: vector_unsigned_short, b: vector_unsigned_short, + ) -> vector_unsigned_int; + #[link_name = "llvm.ppc.altivec.vmulosh"] + fn vmulosh( + a: vector_signed_short, b: vector_signed_short, + ) -> vector_signed_int; } mod sealed { @@ -77,9 +154,317 @@ #[inline] #[target_feature(enable = "altivec")] + #[cfg_attr(test, assert_instr(vmuleub))] + unsafe fn vec_vmuleub( + a: vector_unsigned_char, b: vector_unsigned_char, + ) -> vector_unsigned_short { + vmuleub(a, b) + } + #[inline] + #[target_feature(enable = "altivec")] + #[cfg_attr(test, assert_instr(vmulesb))] + unsafe fn vec_vmulesb( + a: vector_signed_char, b: vector_signed_char, + ) -> vector_signed_short { + vmulesb(a, b) + } + #[inline] + #[target_feature(enable = "altivec")] + #[cfg_attr(test, assert_instr(vmuleuh))] + unsafe fn vec_vmuleuh( + a: vector_unsigned_short, b: vector_unsigned_short, + ) -> vector_unsigned_int { + vmuleuh(a, b) + } + #[inline] + #[target_feature(enable = "altivec")] + #[cfg_attr(test, assert_instr(vmulesh))] + unsafe fn vec_vmulesh( + a: vector_signed_short, b: vector_signed_short, + ) -> vector_signed_int { + vmulesh(a, b) + } + + pub trait VectorMule { + unsafe fn vec_mule(self, b: Self) -> Result; + } + + impl VectorMule for vector_unsigned_char { + #[inline] + #[target_feature(enable = "altivec")] + unsafe fn vec_mule(self, b: Self) -> vector_unsigned_short { + vmuleub(self, b) + } + } + impl VectorMule for vector_signed_char { + #[inline] + #[target_feature(enable = "altivec")] + unsafe fn vec_mule(self, b: Self) -> vector_signed_short { + vmulesb(self, b) + } + } + impl VectorMule for vector_unsigned_short { + #[inline] + #[target_feature(enable = "altivec")] + unsafe fn vec_mule(self, b: Self) -> vector_unsigned_int { + vmuleuh(self, b) + } + } + impl VectorMule for vector_signed_short { + #[inline] + #[target_feature(enable = "altivec")] + unsafe fn vec_mule(self, b: Self) -> vector_signed_int { + vmulesh(self, b) + } + } + + #[inline] + #[target_feature(enable = "altivec")] + #[cfg_attr(test, assert_instr(vmuloub))] + unsafe fn vec_vmuloub( + a: vector_unsigned_char, b: vector_unsigned_char, + ) -> vector_unsigned_short { + vmuloub(a, b) + } + #[inline] + #[target_feature(enable = "altivec")] + #[cfg_attr(test, assert_instr(vmulosb))] + unsafe fn vec_vmulosb( + a: vector_signed_char, b: vector_signed_char, + ) -> vector_signed_short { + vmulosb(a, b) + } + #[inline] + #[target_feature(enable = "altivec")] + #[cfg_attr(test, assert_instr(vmulouh))] + unsafe fn vec_vmulouh( + a: vector_unsigned_short, b: vector_unsigned_short, + ) -> vector_unsigned_int { + vmulouh(a, b) + } + #[inline] + #[target_feature(enable = "altivec")] + #[cfg_attr(test, assert_instr(vmulosh))] + unsafe fn vec_vmulosh( + a: vector_signed_short, b: vector_signed_short, + ) -> vector_signed_int { + vmulosh(a, b) + } + + pub trait VectorMulo { + unsafe fn vec_mulo(self, b: Self) -> Result; + } + + impl VectorMulo for vector_unsigned_char { + #[inline] + #[target_feature(enable = "altivec")] + unsafe fn vec_mulo(self, b: Self) -> vector_unsigned_short { + vmuloub(self, b) + } + } + impl VectorMulo for vector_signed_char { + #[inline] + #[target_feature(enable = "altivec")] + unsafe fn vec_mulo(self, b: Self) -> vector_signed_short { + vmulosb(self, b) + } + } + impl VectorMulo for vector_unsigned_short { + #[inline] + #[target_feature(enable = "altivec")] + unsafe fn vec_mulo(self, b: Self) -> vector_unsigned_int { + vmulouh(self, b) + } + } + impl VectorMulo for vector_signed_short { + #[inline] + #[target_feature(enable = "altivec")] + unsafe fn vec_mulo(self, b: Self) -> vector_signed_int { + vmulosh(self, b) + } + } + + #[inline] + #[target_feature(enable = "altivec")] + #[cfg_attr(test, assert_instr(vsum4ubs))] + unsafe fn vec_vsum4ubs( + a: vector_unsigned_char, b: vector_unsigned_int, + ) -> vector_unsigned_int { + vsum4ubs(a, b) + } + + #[inline] + #[target_feature(enable = "altivec")] + #[cfg_attr(test, assert_instr(vsum4sbs))] + unsafe fn vec_vsum4sbs( + a: vector_signed_char, b: vector_signed_int, + ) -> vector_signed_int { + vsum4sbs(a, b) + } + + #[inline] + #[target_feature(enable = "altivec")] + #[cfg_attr(test, assert_instr(vsum4shs))] + unsafe fn vec_vsum4shs( + a: vector_signed_short, b: vector_signed_int, + ) -> vector_signed_int { + vsum4shs(a, b) + } + + pub trait VectorSum4s { + unsafe fn vec_sum4s(self, b: Other) -> Other; + } + + impl VectorSum4s for vector_unsigned_char { + #[inline] + #[target_feature(enable = "altivec")] + unsafe fn vec_sum4s( + self, b: vector_unsigned_int, + ) -> vector_unsigned_int { + vsum4ubs(self, b) + } + } + + impl VectorSum4s for vector_signed_char { + #[inline] + #[target_feature(enable = "altivec")] + unsafe fn vec_sum4s(self, b: vector_signed_int) -> vector_signed_int { + vsum4sbs(self, b) + } + } + + impl VectorSum4s for vector_signed_short { + #[inline] + #[target_feature(enable = "altivec")] + unsafe fn vec_sum4s(self, b: vector_signed_int) -> vector_signed_int { + vsum4shs(self, b) + } + } + + #[inline] + #[target_feature(enable = "altivec")] + #[cfg_attr(test, assert_instr(vsum2sws))] + unsafe fn vec_vsum2sws( + a: vector_signed_int, b: vector_signed_int, + ) -> vector_signed_int { + vsum2sws(a, b) + } + + #[inline] + #[target_feature(enable = "altivec")] + #[cfg_attr(test, assert_instr(vnmsubfp))] + unsafe fn vec_vnmsubfp( + a: vector_float, b: vector_float, c: vector_float, + ) -> vector_float { + vnmsubfp(a, b, c) + } + + #[inline] + #[target_feature(enable = "altivec")] + #[cfg_attr(test, assert_instr(vmaddfp))] + unsafe fn vec_vmaddfp( + a: vector_float, b: vector_float, c: vector_float, + ) -> vector_float { + vmaddfp(a, b, c) + } + + #[inline] + #[target_feature(enable = "altivec")] + #[cfg_attr(test, assert_instr(vmsumubm))] + unsafe fn vec_vmsumubm( + a: vector_unsigned_char, b: vector_unsigned_char, + c: vector_unsigned_int, + ) -> vector_unsigned_int { + vmsumubm(a, b, c) + } + + #[inline] + #[target_feature(enable = "altivec")] + #[cfg_attr(test, assert_instr(vmsummbm))] + unsafe fn vec_vmsummbm( + a: vector_signed_char, b: vector_unsigned_char, c: vector_signed_int, + ) -> vector_signed_int { + vmsummbm(a, b, c) + } + + #[inline] + #[target_feature(enable = "altivec")] + #[cfg_attr(test, assert_instr(vmsumuhm))] + unsafe fn vec_vmsumuhm( + a: vector_unsigned_short, b: vector_unsigned_short, + c: vector_unsigned_int, + ) -> vector_unsigned_int { + vmsumuhm(a, b, c) + } + + #[inline] + #[target_feature(enable = "altivec")] + #[cfg_attr(test, assert_instr(vmsumshm))] + unsafe fn vec_vmsumshm( + a: vector_signed_short, b: vector_signed_short, c: vector_signed_int, + ) -> vector_signed_int { + vmsumshm(a, b, c) + } + + pub trait VectorMsum { + unsafe fn vec_msum(self, b: B, c: Other) -> Other; + } + + impl VectorMsum + for vector_unsigned_char + { + #[inline] + #[target_feature(enable = "altivec")] + unsafe fn vec_msum( + self, b: vector_unsigned_char, c: vector_unsigned_int, + ) -> vector_unsigned_int { + vmsumubm(self, b, c) + } + } + + impl VectorMsum + for vector_signed_char + { + #[inline] + #[target_feature(enable = "altivec")] + unsafe fn vec_msum( + self, b: vector_unsigned_char, c: vector_signed_int, + ) -> vector_signed_int { + vmsummbm(self, b, c) + } + } + + impl VectorMsum + for vector_unsigned_short + { + #[inline] + #[target_feature(enable = "altivec")] + unsafe fn vec_msum( + self, b: vector_unsigned_short, c: vector_unsigned_int, + ) -> vector_unsigned_int { + vmsumuhm(self, b, c) + } + } + + impl VectorMsum + for vector_signed_short + { + #[inline] + #[target_feature(enable = "altivec")] + unsafe fn vec_msum( + self, b: vector_signed_short, c: vector_signed_int, + ) -> vector_signed_int { + vmsumshm(self, b, c) + } + } + + #[inline] + #[target_feature(enable = "altivec")] #[cfg_attr(test, assert_instr(vmsumuhs))] unsafe fn vec_vmsumuhs( - a: vector_unsigned_short, b: vector_unsigned_short,c: vector_unsigned_int) -> vector_unsigned_int { + a: vector_unsigned_short, b: vector_unsigned_short, + c: vector_unsigned_int, + ) -> vector_unsigned_int { vmsumuhs(a, b, c) } @@ -87,7 +472,8 @@ #[target_feature(enable = "altivec")] #[cfg_attr(test, assert_instr(vmsumshs))] unsafe fn vec_vmsumshs( - a: vector_signed_short, b: vector_signed_short,c: vector_signed_int) -> vector_signed_int { + a: vector_signed_short, b: vector_signed_short, c: vector_signed_int, + ) -> vector_signed_int { vmsumshs(a, b, c) } @@ -96,13 +482,21 @@ } impl VectorMsums for vector_unsigned_short { - unsafe fn vec_msums(self, b: Self, c: vector_unsigned_int) -> vector_unsigned_int { + #[inline] + #[target_feature(enable = "altivec")] + unsafe fn vec_msums( + self, b: Self, c: vector_unsigned_int, + ) -> vector_unsigned_int { vmsumuhs(self, b, c) } } impl VectorMsums for vector_signed_short { - unsafe fn vec_msums(self, b: Self, c: vector_signed_int) -> vector_signed_int { + #[inline] + #[target_feature(enable = "altivec")] + unsafe fn vec_msums( + self, b: Self, c: vector_signed_int, + ) -> vector_signed_int { vmsumshs(self, b, c) } } @@ -430,6 +824,40 @@ vec_add_float_float(self, other) } } + + pub trait VectorMladd { + type Result; + unsafe fn vec_mladd(self, b: Other, c: Other) -> Self::Result; + } + + #[inline] + #[target_feature(enable = "altivec")] + #[cfg_attr(test, assert_instr(vmladduhm))] + unsafe fn mladd(a: i16x8, b: i16x8, c: i16x8) -> i16x8 { + simd_add(simd_mul(a, b), c) + } + + macro_rules! vector_mladd { + ($a: ident, $bc: ident, $d: ident) => { + impl VectorMladd<$bc> for $a { + type Result = $d; + #[inline] + #[target_feature(enable = "altivec")] + unsafe fn vec_mladd(self, b: $bc, c: $bc) -> Self::Result { + let a: i16x8 = ::mem::transmute(self); + let b: i16x8 = ::mem::transmute(b); + let c: i16x8 = ::mem::transmute(c); + + ::mem::transmute(mladd(a, b, c)) + } + } + }; + } + + vector_mladd! { vector_unsigned_short, vector_unsigned_short, vector_unsigned_short } + vector_mladd! { vector_unsigned_short, vector_signed_short, vector_signed_short } + vector_mladd! { vector_signed_short, vector_unsigned_short, vector_signed_short } + vector_mladd! { vector_signed_short, vector_signed_short, vector_signed_short } } /// Vector add. @@ -464,6 +892,44 @@ b.vec_vperm(a, c) } + + /// Vector Sum Across Partial (1/2) Saturated + #[inline] + #[target_feature(enable = "altivec")] + pub unsafe fn vec_sum2s( + a: vector_signed_int, b: vector_signed_int, + ) -> vector_signed_int { + // vsum2sws has big-endian bias + // + // swap the even b elements with the odd ones + let flip = ::mem::transmute(u8x16::new( + 4, 5, 6, 7, 0, 1, 2, 3, 12, 13, 14, 15, 8, 9, 10, 11, + )); + let b = vec_perm(b, b, flip); + let c = vsum2sws(a, b); + + vec_perm(c, c, flip) + } + + // Even and Odd are swapped in little-endian + /// Vector Multiply Even + #[inline] + #[target_feature(enable = "altivec")] + pub unsafe fn vec_mule(a: T, b: T) -> U + where + T: sealed::VectorMulo, + { + a.vec_mulo(b) + } + /// Vector Multiply Odd + #[inline] + #[target_feature(enable = "altivec")] + pub unsafe fn vec_mulo(a: T, b: T) -> U + where + T: sealed::VectorMule, + { + a.vec_mule(b) + } } /// Vector Multiply Add Saturated @@ -476,6 +942,18 @@ vmhaddshs(a, b, c) } +/// Vector Multiply Low and Add Unsigned Half Word +#[inline] +#[target_feature(enable = "altivec")] +pub unsafe fn vec_mladd( + a: T, b: U, c: U, +) -> >::Result +where + T: sealed::VectorMladd, +{ + a.vec_mladd(b, c) +} + /// Vector Multiply Round and Add Saturated #[inline] #[target_feature(enable = "altivec")] @@ -486,14 +964,54 @@ vmhraddshs(a, b, c) } +/// Vector Multiply Sum +#[inline] +#[target_feature(enable = "altivec")] +pub unsafe fn vec_msum(a: T, b: B, c: U) -> U +where + T: sealed::VectorMsum, +{ + a.vec_msum(b, c) +} + /// Vector Multiply Sum Saturated #[inline] #[target_feature(enable = "altivec")] pub unsafe fn vec_msums(a: T, b: T, c: U) -> U - where T: sealed::VectorMsums { +where + T: sealed::VectorMsums, +{ a.vec_msums(b, c) } +/// Vector Multiply Add +#[inline] +#[target_feature(enable = "altivec")] +pub unsafe fn vec_madd( + a: vector_float, b: vector_float, c: vector_float, +) -> vector_float { + vmaddfp(a, b, c) +} + +/// Vector Negative Multiply Subtract +#[inline] +#[target_feature(enable = "altivec")] +pub unsafe fn vec_nmsub( + a: vector_float, b: vector_float, c: vector_float, +) -> vector_float { + vnmsubfp(a, b, c) +} + +/// Vector Sum Across Partial (1/4) Saturated +#[inline] +#[target_feature(enable = "altivec")] +pub unsafe fn vec_sum4s(a: T, b: U) -> U +where + T: sealed::VectorSum4s, +{ + a.vec_sum4s(b) +} + #[cfg(target_endian = "big")] mod endian { use super::*; @@ -506,6 +1024,35 @@ { a.vec_vperm(b, c) } + + /// Vector Sum Across Partial (1/2) Saturated + #[inline] + #[target_feature(enable = "altivec")] + pub unsafe fn vec_sum2s( + a: vector_signed_int, b: vector_signed_int, + ) -> vector_signed_int { + vsum2sws(a, b) + } + + /// Vector Multiply Even + #[inline] + #[target_feature(enable = "altivec")] + pub unsafe fn vec_mule(a: T, b: T) -> U + where + T: sealed::VectorMule, + { + a.vec_mule(b) + } + /// Vector Multiply Odd + #[inline] + #[target_feature(enable = "altivec")] + pub unsafe fn vec_mulo(a: T, b: T) -> U + where + T: sealed::VectorMulo, + { + a.vec_mulo(b) + } + } pub use self::endian::*; @@ -623,8 +1170,9 @@ 6 * 256, 7 * 256, )); - let b: vector_signed_short = - ::mem::transmute(i16x8::new(256, 256, 256, 256, 256, 256, 256, 256)); + let b: vector_signed_short = ::mem::transmute(i16x8::new( + 256, 256, 256, 256, 256, 256, 256, 256, + )); let c: vector_signed_short = ::mem::transmute(i16x8::new(0, 1, 2, 3, 4, 5, 6, 7)); @@ -634,6 +1182,35 @@ } #[simd_test(enable = "altivec")] + unsafe fn test_vec_madd_float() { + let a: vector_float = ::mem::transmute(f32x4::new(0.1, 0.2, 0.3, 0.4)); + let b: vector_float = ::mem::transmute(f32x4::new(0.1, 0.2, 0.3, 0.4)); + let c: vector_float = ::mem::transmute(f32x4::new(0.1, 0.2, 0.3, 0.4)); + let d = f32x4::new( + 0.1 * 0.1 + 0.1, + 0.2 * 0.2 + 0.2, + 0.3 * 0.3 + 0.3, + 0.4 * 0.4 + 0.4, + ); + + assert_eq!(d, ::mem::transmute(vec_madd(a, b, c))); + } + + #[simd_test(enable = "altivec")] + unsafe fn test_vec_nmsub_float() { + let a: vector_float = ::mem::transmute(f32x4::new(0.1, 0.2, 0.3, 0.4)); + let b: vector_float = ::mem::transmute(f32x4::new(0.1, 0.2, 0.3, 0.4)); + let c: vector_float = ::mem::transmute(f32x4::new(0.1, 0.2, 0.3, 0.4)); + let d = f32x4::new( + -(0.1 * 0.1 - 0.1), + -(0.2 * 0.2 - 0.2), + -(0.3 * 0.3 - 0.3), + -(0.4 * 0.4 - 0.4), + ); + assert_eq!(d, ::mem::transmute(vec_nmsub(a, b, c))); + } + + #[simd_test(enable = "altivec")] unsafe fn test_vec_mradds() { let a: vector_signed_short = ::mem::transmute(i16x8::new( 0 * 256, @@ -645,16 +1222,143 @@ 6 * 256, 7 * 256, )); - let b: vector_signed_short = - ::mem::transmute(i16x8::new(256, 256, 256, 256, 256, 256, 256, 256)); - let c: vector_signed_short = - ::mem::transmute(i16x8::new(0, 1, 2, 3, 4, 5, 6, i16::max_value() - 1)); + let b: vector_signed_short = ::mem::transmute(i16x8::new( + 256, 256, 256, 256, 256, 256, 256, 256, + )); + let c: vector_signed_short = ::mem::transmute(i16x8::new( + 0, + 1, + 2, + 3, + 4, + 5, + 6, + i16::max_value() - 1, + )); let d = i16x8::new(0, 3, 6, 9, 12, 15, 18, i16::max_value()); assert_eq!(d, ::mem::transmute(vec_mradds(a, b, c))); } + macro_rules! test_vec_mladd { + {$name:ident, $sa:ident, $la:ident, $sbc:ident, $lbc:ident, $sd:ident, + [$($a:expr),+], [$($b:expr),+], [$($c:expr),+], [$($d:expr),+]} => { + #[simd_test(enable = "altivec")] + unsafe fn $name() { + let a: $la = ::mem::transmute($sa::new($($a),+)); + let b: $lbc = ::mem::transmute($sbc::new($($b),+)); + let c = ::mem::transmute($sbc::new($($c),+)); + let d = $sd::new($($d),+); + + assert_eq!(d, ::mem::transmute(vec_mladd(a, b, c))); + } + } + } + + test_vec_mladd! { test_vec_mladd_u16x8_u16x8, u16x8, vector_unsigned_short, u16x8, vector_unsigned_short, u16x8, + [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7], [0, 2, 6, 12, 20, 30, 42, 56] + } + test_vec_mladd! { test_vec_mladd_u16x8_i16x8, u16x8, vector_unsigned_short, i16x8, vector_unsigned_short, i16x8, + [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7], [0, 2, 6, 12, 20, 30, 42, 56] + } + test_vec_mladd! { test_vec_mladd_i16x8_u16x8, i16x8, vector_signed_short, u16x8, vector_unsigned_short, i16x8, + [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7], [0, 2, 6, 12, 20, 30, 42, 56] + } + test_vec_mladd! { test_vec_mladd_i16x8_i16x8, i16x8, vector_signed_short, i16x8, vector_unsigned_short, i16x8, + [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7], [0, 2, 6, 12, 20, 30, 42, 56] + } + + #[simd_test(enable = "altivec")] + unsafe fn test_vec_msum_unsigned_char() { + let a: vector_unsigned_char = ::mem::transmute(u8x16::new( + 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, + )); + let b: vector_unsigned_char = ::mem::transmute(u8x16::new( + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, + )); + let c: vector_unsigned_int = ::mem::transmute(u32x4::new(0, 1, 2, 3)); + let d = u32x4::new( + (0 + 1 + 2 + 3) * 255 + 0, + (4 + 5 + 6 + 7) * 255 + 1, + (0 + 1 + 2 + 3) * 255 + 2, + (4 + 5 + 6 + 7) * 255 + 3, + ); + + assert_eq!(d, ::mem::transmute(vec_msum(a, b, c))); + } + + #[simd_test(enable = "altivec")] + unsafe fn test_vec_msum_signed_char() { + let a: vector_signed_char = ::mem::transmute(i8x16::new( + 0, -1, 2, -3, 1, -1, 1, -1, 0, 1, 2, 3, 4, -5, -6, -7, + )); + let b: vector_unsigned_char = ::mem::transmute(i8x16::new( + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + )); + let c: vector_signed_int = ::mem::transmute(u32x4::new(0, 1, 2, 3)); + let d = i32x4::new( + (0 - 1 + 2 - 3) + 0, + (0) + 1, + (0 + 1 + 2 + 3) + 2, + (4 - 5 - 6 - 7) + 3, + ); + + assert_eq!(d, ::mem::transmute(vec_msum(a, b, c))); + } + #[simd_test(enable = "altivec")] + unsafe fn test_vec_msum_unsigned_short() { + let a: vector_unsigned_short = ::mem::transmute(u16x8::new( + 0 * 256, + 1 * 256, + 2 * 256, + 3 * 256, + 4 * 256, + 5 * 256, + 6 * 256, + 7 * 256, + )); + let b: vector_unsigned_short = ::mem::transmute(u16x8::new( + 256, 256, 256, 256, 256, 256, 256, 256, + )); + let c: vector_unsigned_int = ::mem::transmute(u32x4::new(0, 1, 2, 3)); + let d = u32x4::new( + (0 + 1) * 256 * 256 + 0, + (2 + 3) * 256 * 256 + 1, + (4 + 5) * 256 * 256 + 2, + (6 + 7) * 256 * 256 + 3, + ); + + assert_eq!(d, ::mem::transmute(vec_msum(a, b, c))); + } + + #[simd_test(enable = "altivec")] + unsafe fn test_vec_msum_signed_short() { + let a: vector_signed_short = ::mem::transmute(i16x8::new( + 0 * 256, + -1 * 256, + 2 * 256, + -3 * 256, + 4 * 256, + -5 * 256, + 6 * 256, + -7 * 256, + )); + let b: vector_signed_short = ::mem::transmute(i16x8::new( + 256, 256, 256, 256, 256, 256, 256, 256, + )); + let c: vector_signed_int = ::mem::transmute(i32x4::new(0, 1, 2, 3)); + let d = i32x4::new( + (0 - 1) * 256 * 256 + 0, + (2 - 3) * 256 * 256 + 1, + (4 - 5) * 256 * 256 + 2, + (6 - 7) * 256 * 256 + 3, + ); + + assert_eq!(d, ::mem::transmute(vec_msum(a, b, c))); + } + #[simd_test(enable = "altivec")] unsafe fn test_vec_msums_unsigned() { let a: vector_unsigned_short = ::mem::transmute(u16x8::new( @@ -667,8 +1371,9 @@ 6 * 256, 7 * 256, )); - let b: vector_unsigned_short = - ::mem::transmute(u16x8::new(256, 256, 256, 256, 256, 256, 256, 256)); + let b: vector_unsigned_short = ::mem::transmute(u16x8::new( + 256, 256, 256, 256, 256, 256, 256, 256, + )); let c: vector_unsigned_int = ::mem::transmute(u32x4::new(0, 1, 2, 3)); let d = u32x4::new( (0 + 1) * 256 * 256 + 0, @@ -684,16 +1389,17 @@ unsafe fn test_vec_msums_signed() { let a: vector_signed_short = ::mem::transmute(i16x8::new( 0 * 256, - -1 * 256, + -1 * 256, 2 * 256, - -3 * 256, + -3 * 256, 4 * 256, - -5 * 256, + -5 * 256, 6 * 256, - -7 * 256, + -7 * 256, + )); + let b: vector_signed_short = ::mem::transmute(i16x8::new( + 256, 256, 256, 256, 256, 256, 256, 256, )); - let b: vector_signed_short = - ::mem::transmute(i16x8::new(256, 256, 256, 256, 256, 256, 256, 256)); let c: vector_signed_int = ::mem::transmute(i32x4::new(0, 1, 2, 3)); let d = i32x4::new( (0 - 1) * 256 * 256 + 0, @@ -706,6 +1412,135 @@ } #[simd_test(enable = "altivec")] + unsafe fn test_vec_sum2s() { + let a: vector_signed_int = ::mem::transmute(i32x4::new(0, 1, 2, 3)); + let b: vector_signed_int = ::mem::transmute(i32x4::new(0, 1, 2, 3)); + let d = i32x4::new(0, 0 + 1 + 1, 0, 2 + 3 + 3); + + assert_eq!(d, ::mem::transmute(vec_sum2s(a, b))); + } + + #[simd_test(enable = "altivec")] + unsafe fn test_vec_sum4s_unsigned_char() { + let a: vector_unsigned_char = ::mem::transmute(u8x16::new( + 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, + )); + let b: vector_unsigned_int = ::mem::transmute(u32x4::new(0, 1, 2, 3)); + let d = u32x4::new( + 0 + 1 + 2 + 3 + 0, + 4 + 5 + 6 + 7 + 1, + 0 + 1 + 2 + 3 + 2, + 4 + 5 + 6 + 7 + 3, + ); + + assert_eq!(d, ::mem::transmute(vec_sum4s(a, b))); + } + #[simd_test(enable = "altivec")] + unsafe fn test_vec_sum4s_signed_char() { + let a: vector_signed_char = ::mem::transmute(i8x16::new( + 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, + )); + let b: vector_signed_int = ::mem::transmute(i32x4::new(0, 1, 2, 3)); + let d = i32x4::new( + 0 + 1 + 2 + 3 + 0, + 4 + 5 + 6 + 7 + 1, + 0 + 1 + 2 + 3 + 2, + 4 + 5 + 6 + 7 + 3, + ); + + assert_eq!(d, ::mem::transmute(vec_sum4s(a, b))); + } + #[simd_test(enable = "altivec")] + unsafe fn test_vec_sum4s_signed_short() { + let a: vector_signed_short = + ::mem::transmute(i16x8::new(0, 1, 2, 3, 4, 5, 6, 7)); + let b: vector_signed_int = ::mem::transmute(i32x4::new(0, 1, 2, 3)); + let d = i32x4::new(0 + 1 + 0, 2 + 3 + 1, 4 + 5 + 2, 6 + 7 + 3); + + assert_eq!(d, ::mem::transmute(vec_sum4s(a, b))); + } + + #[simd_test(enable = "altivec")] + unsafe fn test_vec_mule_unsigned_char() { + let a: vector_unsigned_char = ::mem::transmute(u8x16::new( + 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, + )); + let d = + u16x8::new(0 * 0, 2 * 2, 4 * 4, 6 * 6, 0 * 0, 2 * 2, 4 * 4, 6 * 6); + + assert_eq!(d, ::mem::transmute(vec_mule(a, a))); + } + + #[simd_test(enable = "altivec")] + unsafe fn test_vec_mule_signed_char() { + let a: vector_signed_char = ::mem::transmute(i8x16::new( + 0, 1, -2, 3, -4, 5, -6, 7, 0, 1, 2, 3, 4, 5, 6, 7, + )); + let d = + i16x8::new(0 * 0, 2 * 2, 4 * 4, 6 * 6, 0 * 0, 2 * 2, 4 * 4, 6 * 6); + + assert_eq!(d, ::mem::transmute(vec_mule(a, a))); + } + + #[simd_test(enable = "altivec")] + unsafe fn test_vec_mule_unsigned_short() { + let a: vector_unsigned_short = + ::mem::transmute(u16x8::new(0, 1, 2, 3, 4, 5, 6, 7)); + let d = u32x4::new(0 * 0, 2 * 2, 4 * 4, 6 * 6); + + assert_eq!(d, ::mem::transmute(vec_mule(a, a))); + } + + #[simd_test(enable = "altivec")] + unsafe fn test_vec_mule_signed_short() { + let a: vector_signed_short = + ::mem::transmute(i16x8::new(0, 1, -2, 3, -4, 5, -6, 7)); + let d = i32x4::new(0 * 0, 2 * 2, 4 * 4, 6 * 6); + + assert_eq!(d, ::mem::transmute(vec_mule(a, a))); + } + + #[simd_test(enable = "altivec")] + unsafe fn test_vec_mulo_unsigned_char() { + let a: vector_unsigned_char = ::mem::transmute(u8x16::new( + 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, + )); + let d = + u16x8::new(1 * 1, 3 * 3, 5 * 5, 7 * 7, 1 * 1, 3 * 3, 5 * 5, 7 * 7); + + assert_eq!(d, ::mem::transmute(vec_mulo(a, a))); + } + + #[simd_test(enable = "altivec")] + unsafe fn test_vec_mulo_signed_char() { + let a: vector_signed_char = ::mem::transmute(i8x16::new( + 0, 1, -2, 3, -4, 5, -6, 7, 0, 1, 2, 3, 4, 5, 6, 7, + )); + let d = + i16x8::new(1 * 1, 3 * 3, 5 * 5, 7 * 7, 1 * 1, 3 * 3, 5 * 5, 7 * 7); + + assert_eq!(d, ::mem::transmute(vec_mulo(a, a))); + } + + #[simd_test(enable = "altivec")] + unsafe fn test_vec_mulo_unsigned_short() { + let a: vector_unsigned_short = + ::mem::transmute(u16x8::new(0, 1, 2, 3, 4, 5, 6, 7)); + let d = u32x4::new(1 * 1, 3 * 3, 5 * 5, 7 * 7); + + assert_eq!(d, ::mem::transmute(vec_mulo(a, a))); + } + + #[simd_test(enable = "altivec")] + unsafe fn test_vec_mulo_signed_short() { + let a: vector_signed_short = + ::mem::transmute(i16x8::new(0, 1, -2, 3, -4, 5, -6, 7)); + let d = i32x4::new(1 * 1, 3 * 3, 5 * 5, 7 * 7); + + assert_eq!(d, ::mem::transmute(vec_mulo(a, a))); + } + + #[simd_test(enable = "altivec")] unsafe fn vec_add_i32x4_i32x4() { let x = i32x4::new(1, 2, 3, 4); let y = i32x4::new(4, 3, 2, 1); diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/powerpc/vsx.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/powerpc/vsx.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/powerpc/vsx.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/powerpc/vsx.rs 2018-12-04 23:42:58.000000000 +0000 @@ -1,4 +1,4 @@ -//! PowerPC Vectir Scalar eXtensions (VSX) intrinsics. +//! PowerPC Vector Scalar eXtensions (VSX) intrinsics. //! //! The references are: [POWER ISA v2.07B (for POWER8 & POWER8 with NVIDIA //! NVlink)] and [POWER ISA v3.0B (for POWER9)]. @@ -6,7 +6,117 @@ //! [POWER ISA v2.07B (for POWER8 & POWER8 with NVIDIA NVlink)]: https://ibm.box.com/s/jd5w15gz301s5b5dt375mshpq9c3lh4u //! [POWER ISA v3.0B (for POWER9)]: https://ibm.box.com/s/1hzcwkwf8rbju5h9iyf44wm94amnlcrv -//#[cfg(test)] -//use stdsimd_test::assert_instr; -//use coresimd::simd_llvm::simd_add; -//use coresimd::simd::*; +#![allow(non_camel_case_types)] + +use coresimd::simd_llvm::*; + +#[cfg(test)] +use stdsimd_test::assert_instr; + +use mem; + +types! { + // pub struct vector_Float16 = f16x8; + /// PowerPC-specific 128-bit wide vector of two packed `i64` + pub struct vector_signed_long(i64, i64); + /// PowerPC-specific 128-bit wide vector of two packed `u64` + pub struct vector_unsigned_long(u64, u64); + /// PowerPC-specific 128-bit wide vector mask of two elements + pub struct vector_bool_long(i64, i64); + /// PowerPC-specific 128-bit wide vector of two packed `f64` + pub struct vector_double(f64, f64); + // pub struct vector_signed_long_long = vector_signed_long; + // pub struct vector_unsigned_long_long = vector_unsigned_long; + // pub struct vector_bool_long_long = vector_bool_long; + // pub struct vector_signed___int128 = i128x1; + // pub struct vector_unsigned___int128 = i128x1; +} + +mod sealed { + use super::*; + use coresimd::simd::*; + + pub trait VectorPermDI { + unsafe fn vec_xxpermdi(self, b: Self, dm: u8) -> Self; + } + + // xxpermdi has an big-endian bias and extended mnemonics + #[inline] + #[target_feature(enable = "vsx")] + #[cfg_attr( + all(test, target_endian = "little"), + assert_instr(xxmrgld, dm = 0x0) + )] + #[cfg_attr( + all(test, target_endian = "big"), + assert_instr(xxspltd, dm = 0x0) + )] + unsafe fn xxpermdi(a: i64x2, b: i64x2, dm: u8) -> i64x2 { + match dm & 0b11 { + 0 => simd_shuffle2(a, b, [0b00, 0b10]), + 1 => simd_shuffle2(a, b, [0b01, 0b10]), + 2 => simd_shuffle2(a, b, [0b00, 0b11]), + _ => simd_shuffle2(a, b, [0b01, 0b11]), + } + } + + macro_rules! vec_xxpermdi { + {$impl: ident} => { + impl VectorPermDI for $impl { + #[inline] + #[target_feature(enable = "vsx")] + unsafe fn vec_xxpermdi(self, b: Self, dm: u8) -> Self { + mem::transmute(xxpermdi(mem::transmute(self), mem::transmute(b), dm)) + } + } + } + } + + vec_xxpermdi! { vector_unsigned_long } + vec_xxpermdi! { vector_signed_long } + vec_xxpermdi! { vector_bool_long } + vec_xxpermdi! { vector_double } +} + +/// Vector permute. +#[inline] +#[target_feature(enable = "vsx")] +#[rustc_args_required_const(2)] +pub unsafe fn vec_xxpermdi(a: T, b: T, dm: u8) -> T +where + T: sealed::VectorPermDI, +{ + a.vec_xxpermdi(b, dm) +} + +#[cfg(test)] +mod tests { + #[cfg(target_arch = "powerpc")] + use coresimd::arch::powerpc::*; + + #[cfg(target_arch = "powerpc64")] + use coresimd::arch::powerpc64::*; + + use coresimd::simd::*; + use stdsimd_test::simd_test; + + macro_rules! test_vec_xxpermdi { + {$name:ident, $shorttype:ident, $longtype:ident, [$($a:expr),+], [$($b:expr),+], [$($c:expr),+], [$($d:expr),+]} => { + #[simd_test(enable = "vsx")] + unsafe fn $name() { + let a: $longtype = ::mem::transmute($shorttype::new($($a),+, $($b),+)); + let b = ::mem::transmute($shorttype::new($($c),+, $($d),+)); + + assert_eq!($shorttype::new($($a),+, $($c),+), ::mem::transmute(vec_xxpermdi(a, b, 0))); + assert_eq!($shorttype::new($($b),+, $($c),+), ::mem::transmute(vec_xxpermdi(a, b, 1))); + assert_eq!($shorttype::new($($a),+, $($d),+), ::mem::transmute(vec_xxpermdi(a, b, 2))); + assert_eq!($shorttype::new($($b),+, $($d),+), ::mem::transmute(vec_xxpermdi(a, b, 3))); + } + } + } + + test_vec_xxpermdi!{test_vec_xxpermdi_u64x2, u64x2, vector_unsigned_long, [0], [1], [2], [3]} + test_vec_xxpermdi!{test_vec_xxpermdi_i64x2, i64x2, vector_signed_long, [0], [-1], [2], [-3]} + test_vec_xxpermdi!{test_vec_xxpermdi_m64x2, m64x2, vector_bool_long, [false], [true], [false], [true]} + test_vec_xxpermdi!{test_vec_xxpermdi_f64x2, f64x2, vector_double, [0.0], [1.0], [2.0], [3.0]} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/powerpc64/mod.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/powerpc64/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/powerpc64/mod.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/powerpc64/mod.rs 2018-12-04 23:42:58.000000000 +0000 @@ -6,6 +6,3 @@ //! [64-Bit ELF V2 ABI Specification - Power Architecture]: http://openpowerfoundation.org/wp-content/uploads/resources/leabi/leabi-20170510.pdf pub use coresimd::powerpc::*; - -mod vsx; -pub use self::vsx::*; diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/powerpc64/vsx.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/powerpc64/vsx.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/powerpc64/vsx.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/powerpc64/vsx.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,120 +0,0 @@ -//! PowerPC Vectir Scalar eXtensions (VSX) intrinsics. -//! -//! The references are: [POWER ISA v2.07B (for POWER8 & POWER8 with NVIDIA -//! NVlink)] and [POWER ISA v3.0B (for POWER9)]. -//! -//! [POWER ISA v2.07B (for POWER8 & POWER8 with NVIDIA NVlink)]: https://ibm.box.com/s/jd5w15gz301s5b5dt375mshpq9c3lh4u -//! [POWER ISA v3.0B (for POWER9)]: https://ibm.box.com/s/1hzcwkwf8rbju5h9iyf44wm94amnlcrv - -#![allow(non_camel_case_types)] - -use coresimd::simd_llvm::*; - -#[cfg(test)] -use stdsimd_test::assert_instr; - -use mem; - -types! { - // pub struct vector_Float16 = f16x8; - /// PowerPC-specific 128-bit wide vector of two packed `i64` - pub struct vector_signed_long(i64, i64); - /// PowerPC-specific 128-bit wide vector of two packed `u64` - pub struct vector_unsigned_long(u64, u64); - /// PowerPC-specific 128-bit wide vector mask of two elements - pub struct vector_bool_long(i64, i64); - /// PowerPC-specific 128-bit wide vector of two packed `f64` - pub struct vector_double(f64, f64); - // pub struct vector_signed_long_long = vector_signed_long; - // pub struct vector_unsigned_long_long = vector_unsigned_long; - // pub struct vector_bool_long_long = vector_bool_long; - // pub struct vector_signed___int128 = i128x1; - // pub struct vector_unsigned___int128 = i128x1; -} - -mod sealed { - use coresimd::simd::*; - use super::*; - - pub trait VectorPermDI { - unsafe fn vec_xxpermdi(self, b: Self, dm: u8) -> Self; - } - - // xxpermdi has an big-endian bias and extended mnemonics - #[inline] - #[target_feature(enable = "vsx")] - #[cfg_attr( - all(test, target_endian = "little"), assert_instr(xxmrgld, dm = 0x0) - )] - #[cfg_attr( - all(test, target_endian = "big"), assert_instr(xxspltd, dm = 0x0) - )] - unsafe fn xxpermdi(a: i64x2, b: i64x2, dm: u8) -> i64x2 { - match dm & 0b11 { - 0 => simd_shuffle2(a, b, [0b00, 0b10]), - 1 => simd_shuffle2(a, b, [0b01, 0b10]), - 2 => simd_shuffle2(a, b, [0b00, 0b11]), - _ => simd_shuffle2(a, b, [0b01, 0b11]), - } - } - - macro_rules! vec_xxpermdi { - {$impl: ident} => { - impl VectorPermDI for $impl { - #[inline] - #[target_feature(enable = "vsx")] - unsafe fn vec_xxpermdi(self, b: Self, dm: u8) -> Self { - mem::transmute(xxpermdi(mem::transmute(self), mem::transmute(b), dm)) - } - } - } - } - - vec_xxpermdi! { vector_unsigned_long } - vec_xxpermdi! { vector_signed_long } - vec_xxpermdi! { vector_bool_long } - vec_xxpermdi! { vector_double } -} - -/// Vector permute. -#[inline] -#[target_feature(enable = "vsx")] -#[rustc_args_required_const(2)] -pub unsafe fn vec_xxpermdi(a: T, b: T, dm: u8) -> T -where - T: sealed::VectorPermDI, -{ - a.vec_xxpermdi(b, dm) -} - -#[cfg(test)] -mod tests { - #[cfg(target_arch = "powerpc")] - use coresimd::arch::powerpc::*; - - #[cfg(target_arch = "powerpc64")] - use coresimd::arch::powerpc64::*; - - use coresimd::simd::*; - use stdsimd_test::simd_test; - - macro_rules! test_vec_xxpermdi { - {$name:ident, $shorttype:ident, $longtype:ident, [$($a:expr),+], [$($b:expr),+], [$($c:expr),+], [$($d:expr),+]} => { - #[simd_test(enable = "vsx")] - unsafe fn $name() { - let a: $longtype = ::mem::transmute($shorttype::new($($a),+, $($b),+)); - let b = ::mem::transmute($shorttype::new($($c),+, $($d),+)); - - assert_eq!($shorttype::new($($a),+, $($c),+), ::mem::transmute(vec_xxpermdi(a, b, 0))); - assert_eq!($shorttype::new($($b),+, $($c),+), ::mem::transmute(vec_xxpermdi(a, b, 1))); - assert_eq!($shorttype::new($($a),+, $($d),+), ::mem::transmute(vec_xxpermdi(a, b, 2))); - assert_eq!($shorttype::new($($b),+, $($d),+), ::mem::transmute(vec_xxpermdi(a, b, 3))); - } - } - } - - test_vec_xxpermdi!{test_vec_xxpermdi_u64x2, u64x2, vector_unsigned_long, [0], [1], [2], [3]} - test_vec_xxpermdi!{test_vec_xxpermdi_i64x2, i64x2, vector_signed_long, [0], [-1], [2], [-3]} - test_vec_xxpermdi!{test_vec_xxpermdi_m64x2, m64x2, vector_bool_long, [false], [true], [false], [true]} - test_vec_xxpermdi!{test_vec_xxpermdi_f64x2, f64x2, vector_double, [0.0], [1.0], [2.0], [3.0]} -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/simd_llvm.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/simd_llvm.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/simd_llvm.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/simd_llvm.rs 2018-12-04 23:42:58.000000000 +0000 @@ -51,8 +51,7 @@ pub fn simd_select(m: M, a: T, b: T) -> T; pub fn simd_fmin(a: T, b: T) -> T; - // FIXME: https://github.com/rust-lang-nursery/stdsimd/issues/416 - // pub fn simd_fmax(a: T, b: T) -> T; + pub fn simd_fmax(a: T, b: T) -> T; pub fn simd_fsqrt(a: T) -> T; pub fn simd_fma(a: T, b: T, c: T) -> T; diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/simd.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/simd.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/simd.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/simd.rs 2018-12-04 23:42:58.000000000 +0000 @@ -1,5 +1,7 @@ //! Internal `#[repr(simd)]` types +#![cfg_attr(rustfmt, rustfmt_skip)] + #![allow(non_camel_case_types)] macro_rules! simd_ty { @@ -25,7 +27,9 @@ #[inline] pub(crate) fn extract(self, index: usize) -> $ety { - unsafe { ::coresimd::simd_llvm::simd_extract(self, index as u32) } + unsafe { + ::coresimd::simd_llvm::simd_extract(self, index as u32) + } } } } @@ -59,7 +63,9 @@ #[inline] pub(crate) fn extract(self, index: usize) -> bool { - let r: $ety = unsafe { ::coresimd::simd_llvm::simd_extract(self, index as u32) }; + let r: $ety = unsafe { + ::coresimd::simd_llvm::simd_extract(self, index as u32) + }; r != 0 } } @@ -81,12 +87,16 @@ // 64-bit wide types: -simd_ty!(u8x8[u8]: u8, u8, u8, u8, u8, u8, u8, u8 | x0, x1, x2, x3, x4, x5, x6, x7); +simd_ty!(u8x8[u8]: + u8, u8, u8, u8, u8, u8, u8, u8 + | x0, x1, x2, x3, x4, x5, x6, x7); simd_ty!(u16x4[u16]: u16, u16, u16, u16 | x0, x1, x2, x3); simd_ty!(u32x2[u32]: u32, u32 | x0, x1); simd_ty!(u64x1[u64]: u64 | x1); -simd_ty!(i8x8[i8]: i8, i8, i8, i8, i8, i8, i8, i8 | x0, x1, x2, x3, x4, x5, x6, x7); +simd_ty!(i8x8[i8]: + i8, i8, i8, i8, i8, i8, i8, i8 + | x0, x1, x2, x3, x4, x5, x6, x7); simd_ty!(i16x4[i16]: i16, i16, i16, i16 | x0, x1, x2, x3); simd_ty!(i32x2[i32]: i32, i32 | x0, x1); simd_ty!(i64x1[i64]: i64 | x1); @@ -100,7 +110,9 @@ u8, u8, u8, u8, u8, u8, u8, u8 | x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15 ); -simd_ty!(u16x8[u16]: u16, u16, u16, u16, u16, u16, u16, u16 | x0, x1, x2, x3, x4, x5, x6, x7); +simd_ty!(u16x8[u16]: + u16, u16, u16, u16, u16, u16, u16, u16 + | x0, x1, x2, x3, x4, x5, x6, x7); simd_ty!(u32x4[u32]: u32, u32, u32, u32 | x0, x1, x2, x3); simd_ty!(u64x2[u64]: u64, u64 | x0, x1); @@ -109,7 +121,9 @@ i8, i8, i8, i8, i8, i8, i8, i8 | x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15 ); -simd_ty!(i16x8[i16]: i16, i16, i16, i16, i16, i16, i16, i16 | x0, x1, x2, x3, x4, x5, x6, x7); +simd_ty!(i16x8[i16]: + i16, i16, i16, i16, i16, i16, i16, i16 + | x0, x1, x2, x3, x4, x5, x6, x7); simd_ty!(i32x4[i32]: i32, i32, i32, i32 | x0, x1, x2, x3); simd_ty!(i64x2[i64]: i64, i64 | x0, x1); @@ -121,7 +135,9 @@ i8, i8, i8, i8, i8, i8, i8, i8 | x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15 ); -simd_m_ty!(m16x8[i16]: i16, i16, i16, i16, i16, i16, i16, i16 | x0, x1, x2, x3, x4, x5, x6, x7); +simd_m_ty!(m16x8[i16]: + i16, i16, i16, i16, i16, i16, i16, i16 + | x0, x1, x2, x3, x4, x5, x6, x7); simd_m_ty!(m32x4[i32]: i32, i32, i32, i32 | x0, x1, x2, x3); simd_m_ty!(m64x2[i64]: i64, i64 | x0, x1); @@ -132,15 +148,19 @@ u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8 - | x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, - x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, x30, x31 + | x0, x1, x2, x3, x4, x5, x6, x7, + x8, x9, x10, x11, x12, x13, x14, x15, + x16, x17, x18, x19, x20, x21, x22, x23, + x24, x25, x26, x27, x28, x29, x30, x31 ); simd_ty!(u16x16[u16]: u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16 | x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15 ); -simd_ty!(u32x8[u32]: u32, u32, u32, u32, u32, u32, u32, u32 | x0, x1, x2, x3, x4, x5, x6, x7); +simd_ty!(u32x8[u32]: + u32, u32, u32, u32, u32, u32, u32, u32 + | x0, x1, x2, x3, x4, x5, x6, x7); simd_ty!(u64x4[u64]: u64, u64, u64, u64 | x0, x1, x2, x3); simd_ty!(i8x32[i8]: @@ -148,14 +168,17 @@ i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 - | x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, - x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, x30, x31 + | x0, x1, x2, x3, x4, x5, x6, x7, + x8, x9, x10, x11, x12, x13, x14, x15, + x16, x17, x18, x19, x20, x21, x22, x23, + x24, x25, x26, x27, x28, x29, x30, x31 ); simd_ty!(i16x16[i16]: i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16 | x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15 ); -simd_ty!(i32x8[i32]: i32, i32, i32, i32, i32, i32, i32, i32 | x0, x1, x2, x3, x4, x5, x6, x7); +simd_ty!(i32x8[i32]: + i32, i32, i32, i32, i32, i32, i32, i32 + | x0, x1, x2, x3, x4, x5, x6, x7); simd_ty!(i64x4[i64]: i64, i64, i64, i64 | x0, x1, x2, x3); - diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/wasm32/atomic.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/wasm32/atomic.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/wasm32/atomic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/wasm32/atomic.rs 2018-12-04 23:42:58.000000000 +0000 @@ -0,0 +1,121 @@ +//! Intrinsics associated with WebAssembly's upcoming threads proposal. +//! +//! These intrinsics are all unstable because they're not actually stable in +//! WebAssembly itself yet. The signatures may change as [the +//! specification][spec] is updated. +//! +//! [spec]: https://github.com/WebAssembly/threads + +#![cfg(any(target_feature = "atomics", dox))] + +#[cfg(test)] +use stdsimd_test::assert_instr; +#[cfg(test)] +use wasm_bindgen_test::wasm_bindgen_test; + +extern "C" { + #[link_name = "llvm.wasm.atomic.wait.i32"] + fn llvm_atomic_wait_i32(ptr: *mut i32, exp: i32, timeout: i64) -> i32; + #[link_name = "llvm.wasm.atomic.wait.i64"] + fn llvm_atomic_wait_i64(ptr: *mut i64, exp: i64, timeout: i64) -> i32; + #[link_name = "llvm.wasm.atomic.notify"] + fn llvm_atomic_notify(ptr: *mut i32, cnt: i32) -> i32; +} + +/// Corresponding intrinsic to wasm's [`i32.atomic.wait` instruction][instr] +/// +/// This function, when called, will block the current thread if the memory +/// pointed to by `ptr` is equal to `expression` (performing this action +/// atomically). +/// +/// The argument `timeout_ns` is a maxinum number of nanoseconds the calling +/// thread will be blocked for, if it blocks. If the timeout is negative then +/// the calling thread will be blocked forever. +/// +/// The calling thread can only be woken up with a call to the `wake` intrinsic +/// once it has been blocked. Changing the memory behind `ptr` will not wake the +/// thread once it's blocked. +/// +/// # Return value +/// +/// * 0 - indicates that the thread blocked and then was woken up +/// * 1 - the loaded value from `ptr` didn't match `expression`, the thread +/// didn't block +/// * 2 - the thread blocked, but the timeout expired. +/// +/// # Availability +/// +/// This intrinsic is only available **when the standard library itself is +/// compiled with the `atomics` target feature**. This version of the standard +/// library is not obtainable via `rustup`, but rather will require the standard +/// library to be compiled from source. +/// +/// [instr]: https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md#wait +#[inline] +#[cfg_attr(test, assert_instr("i32.atomic.wait"))] +pub unsafe fn wait_i32(ptr: *mut i32, expression: i32, timeout_ns: i64) -> i32 { + llvm_atomic_wait_i32(ptr, expression, timeout_ns) +} + +/// Corresponding intrinsic to wasm's [`i64.atomic.wait` instruction][instr] +/// +/// This function, when called, will block the current thread if the memory +/// pointed to by `ptr` is equal to `expression` (performing this action +/// atomically). +/// +/// The argument `timeout_ns` is a maxinum number of nanoseconds the calling +/// thread will be blocked for, if it blocks. If the timeout is negative then +/// the calling thread will be blocked forever. +/// +/// The calling thread can only be woken up with a call to the `wake` intrinsic +/// once it has been blocked. Changing the memory behind `ptr` will not wake the +/// thread once it's blocked. +/// +/// # Return value +/// +/// * 0 - indicates that the thread blocked and then was woken up +/// * 1 - the loaded value from `ptr` didn't match `expression`, the thread +/// didn't block +/// * 2 - the thread blocked, but the timeout expired. +/// +/// # Availability +/// +/// This intrinsic is only available **when the standard library itself is +/// compiled with the `atomics` target feature**. This version of the standard +/// library is not obtainable via `rustup`, but rather will require the standard +/// library to be compiled from source. +/// +/// [instr]: https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md#wait +#[inline] +#[cfg_attr(test, assert_instr("i64.atomic.wait"))] +pub unsafe fn wait_i64(ptr: *mut i64, expression: i64, timeout_ns: i64) -> i32 { + llvm_atomic_wait_i64(ptr, expression, timeout_ns) +} + +/// Corresponding intrinsic to wasm's [`atomic.wake` instruction][instr] +/// +/// This function will wake up a number of threads blocked on the address +/// indicated by `ptr`. Threads previously blocked with the `wait_i32` and +/// `wait_i64` functions above will be woken up. +/// +/// The `waiters` argument indicates how many waiters should be woken up (a +/// maximum). If the value is negative all waiters are woken up, and if the +/// value is zero no waiters are woken up. +/// +/// # Return value +/// +/// Returns the number of waiters which were actually woken up. +/// +/// # Availability +/// +/// This intrinsic is only available **when the standard library itself is +/// compiled with the `atomics` target feature**. This version of the standard +/// library is not obtainable via `rustup`, but rather will require the standard +/// library to be compiled from source. +/// +/// [instr]: https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md#wake +#[inline] +#[cfg_attr(test, assert_instr("atomic.wake"))] +pub unsafe fn wake(ptr: *mut i32, waiters: i32) -> i32 { + llvm_atomic_notify(ptr, waiters) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/wasm32/memory.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/wasm32/memory.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/wasm32/memory.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/wasm32/memory.rs 2018-12-04 23:42:58.000000000 +0000 @@ -0,0 +1,55 @@ +#[cfg(test)] +use stdsimd_test::assert_instr; +#[cfg(test)] +use wasm_bindgen_test::wasm_bindgen_test; + +extern "C" { + #[link_name = "llvm.wasm.memory.grow.i32"] + fn llvm_memory_grow(mem: i32, pages: i32) -> i32; + #[link_name = "llvm.wasm.memory.size.i32"] + fn llvm_memory_size(mem: i32) -> i32; +} + +/// Corresponding intrinsic to wasm's [`memory.size` instruction][instr] +/// +/// This function, when called, will return the current memory size in units of +/// pages. +/// +/// The argument `mem` is the numerical index of which memory to return the +/// size of. Note that currently wasm only supports one memory, so specifying +/// a nonzero value will likely result in a runtime validation error of the +/// wasm module. +/// +/// [instr]: https://github.com/WebAssembly/design/blob/master/Semantics.md#resizing +#[inline] +#[cfg_attr(test, assert_instr("memory.size", mem = 0))] +#[rustc_args_required_const(0)] +pub unsafe fn size(mem: i32) -> i32 { + if mem != 0 { + ::intrinsics::abort(); + } + llvm_memory_size(0) +} + +/// Corresponding intrinsic to wasm's [`memory.grow` instruction][instr] +/// +/// This function, when called, will attempt to grow the default linear memory +/// by the specified `delta` of pages. If memory is successfully grown then the +/// previous size of memory, in pages, is returned. If memory cannot be grown +/// then -1 is returned. +/// +/// The argument `mem` is the numerical index of which memory to return the +/// size of. Note that currently wasm only supports one memory, so specifying +/// a nonzero value will likely result in a runtime validation error of the +/// wasm module. +/// +/// [instr]: https://github.com/WebAssembly/design/blob/master/Semantics.md#resizing +#[inline] +#[cfg_attr(test, assert_instr("memory.grow", mem = 0))] +#[rustc_args_required_const(0)] +pub unsafe fn grow(mem: i32, delta: i32) -> i32 { + if mem != 0 { + ::intrinsics::abort(); + } + llvm_memory_grow(0, delta) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/wasm32/mod.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/wasm32/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/wasm32/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/wasm32/mod.rs 2018-12-04 23:42:58.000000000 +0000 @@ -0,0 +1,40 @@ +//! WASM32 intrinsics + +#![allow(deprecated)] + +#[macro_use] +#[cfg(all(not(test), feature = "wasm_simd128"))] +mod simd128; + +#[cfg(all(test, feature = "wasm_simd128"))] +pub mod simd128; +#[cfg(all(test, feature = "wasm_simd128"))] +pub use self::simd128::*; + +#[cfg(test)] +use stdsimd_test::assert_instr; +#[cfg(test)] +use wasm_bindgen_test::wasm_bindgen_test; + +#[inline] +#[cfg_attr(test, assert_instr("memory.size"))] +#[rustc_deprecated(reason = "renamed to memory::size", since = "1.30.0")] +#[unstable(feature = "stdsimd", issue = "27731")] +#[allow(deprecated)] +#[doc(hidden)] +pub unsafe fn current_memory() -> i32 { + memory::size(0) +} + +#[inline] +#[cfg_attr(test, assert_instr("memory.grow"))] +#[rustc_deprecated(reason = "renamed to memory::grow", since = "1.30.0")] +#[unstable(feature = "stdsimd", issue = "27731")] +#[allow(deprecated)] +#[doc(hidden)] +pub unsafe fn grow_memory(delta: i32) -> i32 { + memory::grow(0, delta) +} + +pub mod atomic; +pub mod memory; diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/wasm32/simd128.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/wasm32/simd128.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/wasm32/simd128.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/wasm32/simd128.rs 2018-12-04 23:42:58.000000000 +0000 @@ -0,0 +1,1424 @@ +//! This module implements the [WebAssembly `SIMD128` ISA]. +//! +//! [WebAssembly `SIMD128` ISA]: +//! https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md +// +// This files is structured as follows: +// * first the types are defined +// * then macros implementing the different APIs are provided +// * finally the API of each type is implements +// +#![allow(non_camel_case_types)] + +#[cfg(test)] +use stdsimd_test::assert_instr; +#[cfg(test)] +use wasm_bindgen_test::wasm_bindgen_test; + +//////////////////////////////////////////////////////////////////////////////// +// Types + +/// A single unconstrained byte (0-255). +pub type ImmByte = u8; +/// A byte with values in the range 0–1 identifying a lane. +pub type LaneIdx2 = u8; +/// A byte with values in the range 0–3 identifying a lane. +pub type LaneIdx4 = u8; +/// A byte with values in the range 0–7 identifying a lane. +pub type LaneIdx8 = u8; +/// A byte with values in the range 0–15 identifying a lane. +pub type LaneIdx16 = u8; +/// A byte with values in the range 0–31 identifying a lane. +pub type LaneIdx32 = u8; + +types! { + /// WASM-specific 128-bit wide SIMD vector type + pub struct v128(i128); +} + +mod sealed { + types! { + /// 128-bit wide SIMD vector type with 8 16-bit wide signed lanes + pub struct v8x16( + pub i8, pub i8, pub i8, pub i8, pub i8, pub i8, pub i8, pub i8, + pub i8, pub i8, pub i8, pub i8, pub i8, pub i8, pub i8, pub i8, + ); + /// 128-bit wide SIMD vector type with 8 16-bit wide signed lanes + pub struct v16x8( + pub i16, pub i16, pub i16, pub i16, + pub i16, pub i16, pub i16, pub i16 + ); + /// 128-bit wide SIMD vector type with 4 32-bit wide signed lanes + pub struct v32x4(pub i32, pub i32, pub i32, pub i32); + /// 128-bit wide SIMD vector type with 2 64-bit wide signed lanes + pub struct v64x2(pub i64, pub i64); + + /// 128-bit wide SIMD vector type with 8 16-bit wide unsigned lanes + pub struct u8x16( + pub u8, pub u8, pub u8, pub u8, pub u8, pub u8, pub u8, pub u8, + pub u8, pub u8, pub u8, pub u8, pub u8, pub u8, pub u8, pub u8, + ); + /// 128-bit wide SIMD vector type with 8 16-bit wide unsigned lanes + pub struct u16x8( + pub u16, pub u16, pub u16, pub u16, + pub u16, pub u16, pub u16, pub u16 + ); + /// 128-bit wide SIMD vector type with 4 32-bit wide unsigned lanes + pub struct u32x4(pub u32, pub u32, pub u32, pub u32); + /// 128-bit wide SIMD vector type with 2 64-bit wide unsigned lanes + pub struct u64x2(pub u64, pub u64); + + /// 128-bit wide SIMD vector type with 4 32-bit wide floating-point lanes + pub struct f32x4(pub f32, pub f32, pub f32, pub f32); + /// 128-bit wide SIMD vector type with 2 64-bit wide floating-point lanes + pub struct f64x2(pub f64, pub f64); + } + + #[allow(improper_ctypes)] + extern "C" { + #[link_name = "llvm.fabs.v4f32"] + fn abs_v4f32(x: f32x4) -> f32x4; + #[link_name = "llvm.fabs.v2f64"] + fn abs_v2f64(x: f64x2) -> f64x2; + #[link_name = "llvm.sqrt.v4f32"] + fn sqrt_v4f32(x: f32x4) -> f32x4; + #[link_name = "llvm.sqrt.v2f64"] + fn sqrt_v2f64(x: f64x2) -> f64x2; + #[link_name = "shufflevector"] + pub fn shufflevector_v16i8(x: v8x16, y: v8x16, i: v8x16) -> v8x16; + + } + impl f32x4 { + #[inline(always)] + pub unsafe fn abs(self) -> Self { + abs_v4f32(self) + } + #[inline(always)] + pub unsafe fn sqrt(self) -> Self { + sqrt_v4f32(self) + } + } + impl f64x2 { + #[inline(always)] + pub unsafe fn abs(self) -> Self { + abs_v2f64(self) + } + #[inline(always)] + pub unsafe fn sqrt(self) -> Self { + sqrt_v2f64(self) + } + } +} + +//////////////////////////////////////////////////////////////////////////////// +// Macros implementing the spec APIs: + +macro_rules! impl_splat { + ($id:ident[$ivec_ty:ident : $elem_ty:ident] <= $x_ty:ident | $($lane_id:ident),*) => { + /// Create vector with identical lanes + /// + /// Construct a vector with `x` replicated to all lanes. + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($ident.splat))] + pub const unsafe fn splat(x: $x_ty) -> v128 { + union U { + vec: self::sealed::$ivec_ty, + res: v128 + } + U { vec: self::sealed::$ivec_ty($({ struct $lane_id; x as $elem_ty}),*) }.res + } + } +} + +macro_rules! impl_extract_lane { + ($id:ident[$ivec_ty:ident : $selem_ty:ident|$uelem_ty:ident]($lane_idx:ty) + => $x_ty:ident) => { + /// Extract lane as a scalar (sign-extend) + /// + /// Extract the scalar value of lane specified in the immediate + /// mode operand `imm` from `a` by sign-extending it. + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.extract_lane_s, imm = + // 0))] + #[rustc_args_required_const(1)] + pub unsafe fn extract_lane_s(a: v128, imm: $lane_idx) -> $x_ty { + use coresimd::simd_llvm::simd_extract; + union U { + vec: self::sealed::$ivec_ty, + a: v128, + } + // the vectors store a signed integer => extract into it + let v: $selem_ty = simd_extract( + U { a }.vec, + imm as u32, /* zero-extends index */ + ); + v as $x_ty + } + + /// Extract lane as a scalar (zero-extend) + /// + /// Extract the scalar value of lane specified in the immediate + /// mode operand `imm` from `a` by zero-extending it. + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.extract_lane_u, imm = + // 0))] + #[rustc_args_required_const(1)] + pub unsafe fn extract_lane_u(a: v128, imm: $lane_idx) -> $x_ty { + use coresimd::simd_llvm::simd_extract; + union U { + vec: self::sealed::$ivec_ty, + a: v128, + } + // the vectors store a signed integer => extract into it + let v: $selem_ty = simd_extract( + U { a }.vec, + imm as u32, /* zero-extends index */ + ); + // re-interpret the signed integer as an unsigned one of the + // same size (no-op) + let v: $uelem_ty = ::mem::transmute(v); + // cast the internal unsigned integer to a larger signed + // integer (zero-extends) + v as $x_ty + } + }; + ($id:ident[$ivec_ty:ident]($lane_idx:ty) => $x_ty:ident) => { + /// Extract lane as a scalar + /// + /// Extract the scalar value of lane specified in the immediate + /// mode operand `imm` from `a`. + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.extract_lane_u, imm = + // 0))] + #[rustc_args_required_const(1)] + pub unsafe fn extract_lane(a: v128, imm: $lane_idx) -> $x_ty { + use coresimd::simd_llvm::simd_extract; + union U { + vec: self::sealed::$ivec_ty, + a: v128, + } + // the vectors store a signed integer => extract into it + simd_extract(U { a }.vec, imm as u32 /* zero-extends index */) + } + }; +} + +macro_rules! impl_replace_lane { + ($id:ident[$ivec_ty:ident:$ielem_ty:ident]($lane_idx:ty) <= $x_ty:ident) => { + /// Replace lane value + /// + /// Return a new vector with lanes identical to `a`, except for + /// lane specified in the immediate mode argument `i` which + /// has the value `x`. + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.extract_lane_u))] + #[rustc_args_required_const(1)] + pub unsafe fn replace_lane(a: v128, imm: $lane_idx, x: $x_ty) -> v128 { + use coresimd::simd_llvm::simd_insert; + union U { + vec: self::sealed::$ivec_ty, + a: v128, + } + // the vectors store a signed integer => extract into it + ::mem::transmute(simd_insert( + U { a }.vec, + imm as u32, /* zero-extends index */ + x as $ielem_ty, + )) + } + }; +} + +macro_rules! impl_wrapping_add_sub_neg { + ($id:ident[$ivec_ty:ident]) => { + /// Lane-wise wrapping integer addition + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.add))] + pub unsafe fn add(a: v128, b: v128) -> v128 { + use coresimd::simd_llvm::simd_add; + let a: sealed::$ivec_ty = ::mem::transmute(a); + let b: sealed::$ivec_ty = ::mem::transmute(b); + ::mem::transmute(simd_add(a, b)) + } + + /// Lane-wise wrapping integer subtraction + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.sub))] + pub unsafe fn sub(a: v128, b: v128) -> v128 { + use coresimd::simd_llvm::simd_sub; + let a: sealed::$ivec_ty = ::mem::transmute(a); + let b: sealed::$ivec_ty = ::mem::transmute(b); + ::mem::transmute(simd_sub(a, b)) + } + + /// Lane-wise wrapping integer negation + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.neg))] + pub unsafe fn neg(a: v128) -> v128 { + use coresimd::simd_llvm::simd_mul; + let a: sealed::$ivec_ty = ::mem::transmute(a); + let b: sealed::$ivec_ty = ::mem::transmute($id::splat(-1)); + ::mem::transmute(simd_mul(b, a)) + } + + // note: multiplication explicitly omitted because i64x2 does + // not implement it + }; +} + +// TODO: Saturating integer arithmetic +// need to add intrinsics to rustc + +// note: multiplication explicitly implemented separately because i64x2 does +// not implement it + +macro_rules! impl_wrapping_mul { + ($id:ident[$ivec_ty:ident]) => { + /// Lane-wise wrapping integer multiplication + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.mul))] + pub unsafe fn mul(a: v128, b: v128) -> v128 { + use coresimd::simd_llvm::simd_mul; + let a: sealed::$ivec_ty = ::mem::transmute(a); + let b: sealed::$ivec_ty = ::mem::transmute(b); + ::mem::transmute(simd_mul(a, b)) + } + }; +} + +macro_rules! impl_shl_scalar { + ($id:ident[$ivec_ty:ident : $t:ty]) => { + /// Left shift by scalar. + /// + /// Shift the bits in each lane to the left by the same amount. + /// Only the low bits of the shift amount are used. + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.shl))] + pub unsafe fn shl(a: v128, y: i32) -> v128 { + use coresimd::simd_llvm::simd_shl; + let a: sealed::$ivec_ty = ::mem::transmute(a); + let b: sealed::$ivec_ty = ::mem::transmute($id::splat(y as $t)); + ::mem::transmute(simd_shl(a, b)) + } + }; +} + +macro_rules! impl_shr_scalar { + ($id:ident[$svec_ty:ident : $uvec_ty:ident : $t:ty]) => { + /// Arithmetic right shift by scalar. + /// + /// Shift the bits in each lane to the right by the same amount. + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.shr))] + pub unsafe fn shr_s(a: v128, y: i32) -> v128 { + use coresimd::simd_llvm::simd_shr; + let a: sealed::$svec_ty = ::mem::transmute(a); + let b: sealed::$svec_ty = ::mem::transmute($id::splat(y as $t)); + ::mem::transmute(simd_shr(a, b)) + } + + /// Logical right shift by scalar. + /// + /// Shift the bits in each lane to the right by the same amount. + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.shr))] + pub unsafe fn shr_u(a: v128, y: i32) -> v128 { + use coresimd::simd_llvm::simd_shr; + let a: sealed::$uvec_ty = ::mem::transmute(a); + let b: sealed::$uvec_ty = ::mem::transmute($id::splat(y as $t)); + ::mem::transmute(simd_shr(a, b)) + } + }; +} + +macro_rules! impl_boolean_reduction { + ($id:ident[$ivec_ty:ident]) => { + /// Any lane true + /// + /// Returns `1` if any lane in `a` is non-zero, `0` otherwise. + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.any_true))] + pub unsafe fn any_true(a: v128) -> i32 { + use coresimd::simd_llvm::simd_reduce_any; + let a: sealed::$ivec_ty = ::mem::transmute(a); + if simd_reduce_any(a) { + 1 + } else { + 0 + } + } + + /// All lanes true + /// + /// Returns `1` if all lanes in `a` are non-zero, `0` otherwise. + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.all_true))] + pub unsafe fn all_true(a: v128) -> i32 { + use coresimd::simd_llvm::simd_reduce_all; + let a: sealed::$ivec_ty = ::mem::transmute(a); + if simd_reduce_all(a) { + 1 + } else { + 0 + } + } + }; +} + +macro_rules! impl_comparisons { + ($id:ident[$ivec_ty:ident]) => { + impl_comparisons!($id[$ivec_ty=>$ivec_ty]); + }; + ($id:ident[$ivec_ty:ident=>$rvec_ty:ident]) => { + /// Equality + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.eq))] + pub unsafe fn eq(a: v128, b: v128) -> v128 { + use coresimd::simd_llvm::simd_eq; + let a: sealed::$ivec_ty = ::mem::transmute(a); + let b: sealed::$ivec_ty = ::mem::transmute(b); + let c: sealed::$rvec_ty = simd_eq(a, b); + ::mem::transmute(c) + } + /// Non-Equality + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.ne))] + pub unsafe fn ne(a: v128, b: v128) -> v128 { + use coresimd::simd_llvm::simd_ne; + let a: sealed::$ivec_ty = ::mem::transmute(a); + let b: sealed::$ivec_ty = ::mem::transmute(b); + let c: sealed::$rvec_ty = simd_ne(a, b); + ::mem::transmute(c) + } + /// Less-than + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.lt))] + pub unsafe fn lt(a: v128, b: v128) -> v128 { + use coresimd::simd_llvm::simd_lt; + let a: sealed::$ivec_ty = ::mem::transmute(a); + let b: sealed::$ivec_ty = ::mem::transmute(b); + let c: sealed::$rvec_ty = simd_lt(a, b); + ::mem::transmute(c) + } + /// Less-than or equal + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.le))] + pub unsafe fn le(a: v128, b: v128) -> v128 { + use coresimd::simd_llvm::simd_le; + let a: sealed::$ivec_ty = ::mem::transmute(a); + let b: sealed::$ivec_ty = ::mem::transmute(b); + let c: sealed::$rvec_ty = simd_le(a, b); + ::mem::transmute(c) + } + /// Greater-than + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.gt))] + pub unsafe fn gt(a: v128, b: v128) -> v128 { + use coresimd::simd_llvm::simd_gt; + let a: sealed::$ivec_ty = ::mem::transmute(a); + let b: sealed::$ivec_ty = ::mem::transmute(b); + let c: sealed::$rvec_ty = simd_gt(a, b); + ::mem::transmute(c) + } + /// Greater-than or equal + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.ge))] + pub unsafe fn ge(a: v128, b: v128) -> v128 { + use coresimd::simd_llvm::simd_ge; + let a: sealed::$ivec_ty = ::mem::transmute(a); + let b: sealed::$ivec_ty = ::mem::transmute(b); + let c: sealed::$rvec_ty = simd_ge(a, b); + ::mem::transmute(c) + } + } +} + +// Floating-point operations +macro_rules! impl_floating_point_ops { + ($id:ident) => { + /// Negation + /// + /// Apply the IEEE `negate(x)` function to each lane. This simply + /// inverts the sign bit, preserving all other bits, even for `NaN` + /// inputs. + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.neg))] + pub unsafe fn neg(a: v128) -> v128 { + use coresimd::simd_llvm::simd_mul; + let a: sealed::$id = ::mem::transmute(a); + let b: sealed::$id = ::mem::transmute($id::splat(-1.)); + ::mem::transmute(simd_mul(b, a)) + } + /// Absolute value + /// + /// Apply the IEEE `abs(x)` function to each lane. This simply + /// clears the sign bit, preserving all other bits, even for `NaN` + /// inputs. + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.abs))] + pub unsafe fn abs(a: v128) -> v128 { + let a: sealed::$id = ::mem::transmute(a); + ::mem::transmute(a.abs()) + } + /// NaN-propagating minimum + /// + /// Lane-wise minimum value, propagating `NaN`s. + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.min))] + pub unsafe fn min(a: v128, b: v128) -> v128 { + v128::bitselect(a, b, $id::lt(a, b)) + } + /// NaN-propagating maximum + /// + /// Lane-wise maximum value, propagating `NaN`s. + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.max))] + pub unsafe fn max(a: v128, b: v128) -> v128 { + v128::bitselect(a, b, $id::gt(a, b)) + } + /// Square-root + /// + /// Lane-wise square-root. + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.sqrt))] + pub unsafe fn sqrt(a: v128) -> v128 { + let a: sealed::$id = ::mem::transmute(a); + ::mem::transmute(a.sqrt()) + } + /// Lane-wise addition + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.add))] + pub unsafe fn add(a: v128, b: v128) -> v128 { + use coresimd::simd_llvm::simd_add; + let a: sealed::$id = ::mem::transmute(a); + let b: sealed::$id = ::mem::transmute(b); + ::mem::transmute(simd_add(a, b)) + } + /// Lane-wise subtraction + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.sub))] + pub unsafe fn sub(a: v128, b: v128) -> v128 { + use coresimd::simd_llvm::simd_sub; + let a: sealed::$id = ::mem::transmute(a); + let b: sealed::$id = ::mem::transmute(b); + ::mem::transmute(simd_sub(a, b)) + } + /// Lane-wise multiplication + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.mul))] + pub unsafe fn mul(a: v128, b: v128) -> v128 { + use coresimd::simd_llvm::simd_mul; + let a: sealed::$id = ::mem::transmute(a); + let b: sealed::$id = ::mem::transmute(b); + ::mem::transmute(simd_mul(a, b)) + } + /// Lane-wise division + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.div))] + pub unsafe fn div(a: v128, b: v128) -> v128 { + use coresimd::simd_llvm::simd_div; + let a: sealed::$id = ::mem::transmute(a); + let b: sealed::$id = ::mem::transmute(b); + ::mem::transmute(simd_div(a, b)) + } + }; +} + +macro_rules! impl_conversion { + ($conversion:ident[$instr:expr]: $from_ty:ident => $to_ty:ident | $id:ident) => { + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($instr))] + pub unsafe fn $conversion(a: v128) -> v128 { + use coresimd::simd_llvm::simd_cast; + let a: sealed::$from_ty = ::mem::transmute(a); + let b: sealed::$to_ty = simd_cast(a); + ::mem::transmute(b) + } + }; +} + +//////////////////////////////////////////////////////////////////////////////// +// Implementations: + +// v128 +impl v128 { + /////////////////////////////////////////////////////////////////////////// + // Const constructor: + + /// Materialize a constant SIMD value from the immediate operands. + /// + /// The `v128.const` instruction is encoded with 16 immediate bytes + /// `imm` which provide the bits of the vector directly. + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr(v128.const, imm = + // [ImmByte::new(42); 16]))] + #[rustc_args_required_const(0)] + pub const unsafe fn const_(imm: [ImmByte; 16]) -> v128 { + union U { + imm: [ImmByte; 16], + vec: v128, + } + U { imm }.vec + } + + /////////////////////////////////////////////////////////////////////////// + // Bitwise logical operations: + + /// Bitwise logical and + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.and))] + pub unsafe fn and(a: v128, b: v128) -> v128 { + use coresimd::simd_llvm::simd_and; + simd_and(a, b) + } + + /// Bitwise logical or + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.or))] + pub unsafe fn or(a: v128, b: v128) -> v128 { + use coresimd::simd_llvm::simd_or; + simd_or(a, b) + } + + /// Bitwise logical xor + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.xor))] + pub unsafe fn xor(a: v128, b: v128) -> v128 { + use coresimd::simd_llvm::simd_xor; + simd_xor(a, b) + } + + /// Bitwise logical not + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.not))] + pub unsafe fn not(a: v128) -> v128 { + union U { + v: u128, + c: [ImmByte; 16], + } + // FIXME: https://github.com/rust-lang/rust/issues/53193 + const C: [ImmByte; 16] = unsafe { + U { + v: ::_core::u128::MAX, + }.c + }; + Self::xor(v128::const_(C), a) + } + + /// Bitwise select + /// + /// Use the bits in the control mask `c` to select the corresponding bit + /// from `v1` when `1` and `v2` when `0`. + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.bitselect))] + pub unsafe fn bitselect(v1: v128, v2: v128, c: v128) -> v128 { + // FIXME: use llvm.select instead - we need to add a `simd_bitselect` + // intrinsic to rustc that converts a v128 vector into a i1x128. The + // `simd_select` intrinsic converts e.g. a i8x16 into a i1x16 which is + // not what we want here: + Self::or(Self::and(v1, c), Self::and(v2, Self::not(c))) + } + + /////////////////////////////////////////////////////////////////////////// + // Memory load/stores: + + /// Load a `v128` vector from the given heap address. + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.load))] + pub unsafe fn load(m: *const v128) -> v128 { + ::_core::ptr::read(m) + } + + /// Store a `v128` vector to the given heap address. + #[inline] + // #[target_feature(enable = "simd128")] + // FIXME: #[cfg_attr(test, assert_instr($id.store))] + pub unsafe fn store(m: *mut v128, a: v128) { + ::_core::ptr::write(m, a) + } +} + +pub use self::sealed::v8x16 as __internal_v8x16; +pub use coresimd::simd_llvm::simd_shuffle16 as __internal_v8x16_shuffle; +/// Shuffle lanes +/// +/// Create vector with lanes selected from the lanes of two input vectors +/// `a` and `b` by the indices specified in the immediate mode operand +/// `imm`. Each index selects an element of the result vector, where the +/// indices `i` in range `[0, 15]` select the `i`-th elements of `a`, and +/// the indices in range `[16, 31]` select the `i - 16`-th element of `b`. +#[macro_export] +macro_rules! v8x16_shuffle { + ($a:expr, $b:expr, [ + $imm0:expr, $imm1:expr, $imm2:expr, $imm3:expr, + $imm4:expr, $imm5:expr, $imm6:expr, $imm7:expr, + $imm8:expr, $imm9:expr, $imm10:expr, $imm11:expr, + $imm12:expr, $imm13:expr, $imm14:expr, $imm15:expr + ]) => { + #[allow(unused_unsafe)] + unsafe { + let a: $crate::arch::wasm32::v128 = $a; + let b: $crate::arch::wasm32::v128 = $b; + union U { + e: v128, + i: $crate::arch::wasm32::__internal_v8x16, + } + let a = U { e: a }.i; + let b = U { e: b }.i; + + let r: $crate::arch::wasm32::__internal_v8x16 = + $crate::arch::wasm32::__internal_v8x16_shuffle( + a, + b, + [ + $imm0 as u32, + $imm1, + $imm2, + $imm3, + $imm4, + $imm5, + $imm6, + $imm7, + $imm8, + $imm9, + $imm10, + $imm11, + $imm12, + $imm13, + $imm14, + $imm15, + ], + ); + U { i: r }.e + } + }; +} + +/// WASM-specific v8x16 instructions with modulo-arithmetic semantics +pub mod i8x16 { + use super::*; + impl_splat!( + i8x16[v8x16: i8] <= i32 | x0, + x1, + x2, + x3, + x4, + x5, + x6, + x7, + x8, + x9, + x10, + x11, + x12, + x13, + x14, + x15 + ); + impl_extract_lane!(i8x16[v8x16:i8|u8](LaneIdx16) => i32); + impl_replace_lane!(i8x16[v8x16: i8](LaneIdx16) <= i32); + impl_wrapping_add_sub_neg!(i8x16[v8x16]); + impl_wrapping_mul!(i8x16[v8x16]); + impl_shl_scalar!(i8x16[v8x16: i32]); + impl_shr_scalar!(i8x16[v8x16: u8x16: i32]); + impl_boolean_reduction!(i8x16[v8x16]); + impl_comparisons!(i8x16[v8x16]); +} + +/// WASM-specific v16x8 instructions with modulo-arithmetic semantics +pub mod i16x8 { + use super::*; + impl_splat!(i16x8[v16x8: i16] <= i32 | x0, x1, x2, x3, x4, x5, x6, x7); + impl_extract_lane!(i16x8[v16x8:i16|u16](LaneIdx8) => i32); + impl_replace_lane!(i16x8[v16x8: i16](LaneIdx8) <= i32); + impl_wrapping_add_sub_neg!(i16x8[v16x8]); + impl_wrapping_mul!(i16x8[v16x8]); + impl_shl_scalar!(i16x8[v16x8: i32]); + impl_shr_scalar!(i16x8[v16x8: u16x8: i32]); + impl_boolean_reduction!(i16x8[v16x8]); + impl_comparisons!(i16x8[v16x8]); +} + +/// WASM-specific v32x4 instructions with modulo-arithmetic semantics +pub mod i32x4 { + use super::*; + impl_splat!(i32x4[v32x4: i32] <= i32 | x0, x1, x2, x3); + impl_extract_lane!(i32x4[v32x4](LaneIdx4) => i32); + impl_replace_lane!(i32x4[v32x4: i32](LaneIdx4) <= i32); + impl_wrapping_add_sub_neg!(i32x4[v32x4]); + impl_wrapping_mul!(i32x4[v32x4]); + impl_shl_scalar!(i32x4[v32x4: i32]); + impl_shr_scalar!(i32x4[v32x4: u32x4: i32]); + impl_boolean_reduction!(i32x4[v32x4]); + impl_comparisons!(i32x4[v32x4]); + impl_conversion!(trunc_s_f32x4_sat["i32x4.trunc_s/f32x4:sat"]: f32x4 => v32x4 | i32x4); + impl_conversion!(trunc_u_f32x4_sat["i32x4.trunc_s/f32x4:sat"]: f32x4 => u32x4 | i32x4); +} + +/// WASM-specific v64x2 instructions with modulo-arithmetic semantics +pub mod i64x2 { + use super::*; + impl_splat!(i64x2[v64x2: i64] <= i64 | x0, x1); + impl_extract_lane!(i64x2[v64x2](LaneIdx2) => i64); + impl_replace_lane!(i64x2[v64x2: i64](LaneIdx2) <= i64); + impl_wrapping_add_sub_neg!(i64x2[v64x2]); + // note: wrapping multiplication for i64x2 is not part of the spec + impl_shl_scalar!(i64x2[v64x2: i64]); + impl_shr_scalar!(i64x2[v64x2: u64x2: i64]); + impl_boolean_reduction!(i64x2[v64x2]); + impl_comparisons!(i64x2[v64x2]); + impl_conversion!(trunc_s_f64x2_sat["i64x2.trunc_s/f64x2:sat"]: f64x2 => v64x2 | i64x2); + impl_conversion!(trunc_u_f64x2_sat["i64x2.trunc_s/f64x2:sat"]: f64x2 => u64x2 | i64x2); +} + +/// WASM-specific v32x4 floating-point instructions +pub mod f32x4 { + use super::*; + impl_splat!(f32x4[f32x4: f32] <= f32 | x0, x1, x2, x3); + impl_extract_lane!(f32x4[f32x4](LaneIdx4) => f32); + impl_replace_lane!(f32x4[f32x4: f32](LaneIdx4) <= f32); + impl_comparisons!(f32x4[f32x4=>v32x4]); + impl_floating_point_ops!(f32x4); + impl_conversion!(convert_s_i32x4["f32x4.convert_s/i32x4"]: v32x4 => f32x4 | f32x4); + impl_conversion!(convert_u_i32x4["f32x4.convert_u/i32x4"]: u32x4 => f32x4 | f32x4); + +} + +/// WASM-specific v64x2 floating-point instructions +pub mod f64x2 { + use super::*; + impl_splat!(f64x2[f64x2: f64] <= f64 | x0, x1); + impl_extract_lane!(f64x2[f64x2](LaneIdx2) => f64); + impl_replace_lane!(f64x2[f64x2: f64](LaneIdx2) <= f64); + impl_comparisons!(f64x2[f64x2=>v64x2]); + impl_floating_point_ops!(f64x2); + impl_conversion!(convert_s_i64x2["f64x2.convert_s/i64x2"]: v64x2 => f64x2 | f64x2); + impl_conversion!(convert_u_i64x2["f64x2.convert_u/i64x2"]: u64x2 => f64x2 | f64x2); +} + +#[cfg(test)] +pub mod tests { + use super::*; + use std; + use std::mem; + use std::prelude::v1::*; + use wasm_bindgen_test::*; + + fn compare_bytes(a: v128, b: v128) { + let a: [u8; 16] = unsafe { mem::transmute(a) }; + let b: [u8; 16] = unsafe { mem::transmute(b) }; + assert_eq!(a, b); + } + + #[wasm_bindgen_test] + fn v128_const() { + const A: v128 = unsafe { + v128::const_([ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + ]) + }; + compare_bytes(A, A); + } + + macro_rules! test_splat { + ($test_id:ident: $id:ident($val:expr) => $($vals:expr),*) => { + #[wasm_bindgen_test] + fn $test_id() { + const A: v128 = unsafe { + $id::splat($val) + }; + const B: v128 = unsafe { + v128::const_([$($vals),*]) + }; + compare_bytes(A, B); + } + } + } + + test_splat!(i8x16_splat: i8x16(42) => 42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42); + test_splat!(i16x8_splat: i16x8(42) => 42, 0, 42, 0, 42, 0, 42, 0, 42, 0, 42, 0, 42, 0, 42, 0); + test_splat!(i32x4_splat: i32x4(42) => 42, 0, 0, 0, 42, 0, 0, 0, 42, 0, 0, 0, 42, 0, 0, 0); + test_splat!(i64x2_splat: i64x2(42) => 42, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0); + test_splat!(f32x4_splat: f32x4(42.) => 0, 0, 40, 66, 0, 0, 40, 66, 0, 0, 40, 66, 0, 0, 40, 66); + test_splat!(f64x2_splat: f64x2(42.) => 0, 0, 0, 0, 0, 0, 69, 64, 0, 0, 0, 0, 0, 0, 69, 64); + + // tests extract and replace lanes + macro_rules! test_extract { + ($test_id:ident: $id:ident[$ety:ident] => $extract_fn:ident | [$val:expr; $count:expr] + | [$($vals:expr),*] => ($other:expr) + | $($ids:expr),*) => { + #[wasm_bindgen_test] + fn $test_id() { + unsafe { + // splat vector and check that all indices contain the same value + // splatted: + const A: v128 = unsafe { + $id::splat($val) + }; + $( + assert_eq!($id::$extract_fn(A, $ids) as $ety, $val); + )*; + + // create a vector from array and check that the indices contain + // the same values as in the array: + let arr: [$ety; $count] = [$($vals),*]; + let mut vec: v128 = mem::transmute(arr); + $( + assert_eq!($id::$extract_fn(vec, $ids) as $ety, arr[$ids]); + )*; + + // replace lane 0 with another value + vec = $id::replace_lane(vec, 0, $other); + assert_ne!($id::$extract_fn(vec, 0) as $ety, arr[0]); + assert_eq!($id::$extract_fn(vec, 0) as $ety, $other); + } + } + } + } + + test_extract!(i8x16_extract_u: i8x16[u8] => extract_lane_u | [255; 16] + | [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] => (42) + | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 + ); + test_extract!(i8x16_extract_s: i8x16[i8] => extract_lane_s | [-122; 16] + | [0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15] => (-42) + | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 + ); + + test_extract!(i16x8_extract_u: i16x8[u16] => extract_lane_u | [255; 8] + | [0, 1, 2, 3, 4, 5, 6, 7] => (42) | 0, 1, 2, 3, 4, 5, 6, 7 + ); + test_extract!(i16x8_extract_s: i16x8[i16] => extract_lane_s | [-122; 8] + | [0, -1, 2, -3, 4, -5, 6, -7] => (-42) | 0, 1, 2, 3, 4, 5, 6, 7 + ); + test_extract!(i32x4_extract: i32x4[i32] => extract_lane | [-122; 4] + | [0, -1, 2, -3] => (42) | 0, 1, 2, 3 + ); + test_extract!(i64x2_extract: i64x2[i64] => extract_lane | [-122; 2] + | [0, -1] => (42) | 0, 1 + ); + test_extract!(f32x4_extract: f32x4[f32] => extract_lane | [-122.; 4] + | [0., -1., 2., -3.] => (42.) | 0, 1, 2, 3 + ); + test_extract!(f64x2_extract: f64x2[f64] => extract_lane | [-122.; 2] + | [0., -1.] => (42.) | 0, 1 + ); + + #[wasm_bindgen_test] + fn v8x16_shuffle() { + unsafe { + let a = [0_u8, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]; + let b = [ + 16_u8, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, + ]; + + let vec_a: v128 = mem::transmute(a); + let vec_b: v128 = mem::transmute(b); + + let vec_r = v8x16_shuffle!( + vec_a, + vec_b, + [0, 16, 2, 18, 4, 20, 6, 22, 8, 24, 10, 26, 12, 28, 14, 30] + ); + + let e = + [0_u8, 16, 2, 18, 4, 20, 6, 22, 8, 24, 10, 26, 12, 28, 14, 30]; + let vec_e: v128 = mem::transmute(e); + compare_bytes(vec_r, vec_e); + } + } + + macro_rules! floating_point { + (f32) => { + true + }; + (f64) => { + true + }; + ($id:ident) => { + false + }; + } + + trait IsNan: Sized { + fn is_nan(self) -> bool { + false + } + } + impl IsNan for i8 {} + impl IsNan for i16 {} + impl IsNan for i32 {} + impl IsNan for i64 {} + + macro_rules! test_bop { + ($id:ident[$ety:ident; $ecount:expr] | + $binary_op:ident [$op_test_id:ident] : + ([$($in_a:expr),*], [$($in_b:expr),*]) => [$($out:expr),*]) => { + test_bop!( + $id[$ety; $ecount] => $ety | $binary_op [ $op_test_id ]: + ([$($in_a),*], [$($in_b),*]) => [$($out),*] + ); + + }; + ($id:ident[$ety:ident; $ecount:expr] => $oty:ident | + $binary_op:ident [$op_test_id:ident] : + ([$($in_a:expr),*], [$($in_b:expr),*]) => [$($out:expr),*]) => { + #[wasm_bindgen_test] + fn $op_test_id() { + unsafe { + let a_input: [$ety; $ecount] = [$($in_a),*]; + let b_input: [$ety; $ecount] = [$($in_b),*]; + let output: [$oty; $ecount] = [$($out),*]; + + let a_vec_in: v128 = mem::transmute(a_input); + let b_vec_in: v128 = mem::transmute(b_input); + let vec_res: v128 = $id::$binary_op(a_vec_in, b_vec_in); + + let res: [$oty; $ecount] = mem::transmute(vec_res); + + if !floating_point!($ety) { + assert_eq!(res, output); + } else { + for i in 0..$ecount { + let r = res[i]; + let o = output[i]; + assert_eq!(r.is_nan(), o.is_nan()); + if !r.is_nan() { + assert_eq!(r, o); + } + } + } + } + } + } + } + + macro_rules! test_bops { + ($id:ident[$ety:ident; $ecount:expr] | + $binary_op:ident [$op_test_id:ident]: + ([$($in_a:expr),*], $in_b:expr) => [$($out:expr),*]) => { + #[wasm_bindgen_test] + fn $op_test_id() { + unsafe { + let a_input: [$ety; $ecount] = [$($in_a),*]; + let output: [$ety; $ecount] = [$($out),*]; + + let a_vec_in: v128 = mem::transmute(a_input); + let vec_res: v128 = $id::$binary_op(a_vec_in, $in_b); + + let res: [$ety; $ecount] = mem::transmute(vec_res); + assert_eq!(res, output); + } + } + } + } + + macro_rules! test_uop { + ($id:ident[$ety:ident; $ecount:expr] | + $unary_op:ident [$op_test_id:ident]: [$($in_a:expr),*] => [$($out:expr),*]) => { + #[wasm_bindgen_test] + fn $op_test_id() { + unsafe { + let a_input: [$ety; $ecount] = [$($in_a),*]; + let output: [$ety; $ecount] = [$($out),*]; + + let a_vec_in: v128 = mem::transmute(a_input); + let vec_res: v128 = $id::$unary_op(a_vec_in); + + let res: [$ety; $ecount] = mem::transmute(vec_res); + assert_eq!(res, output); + } + } + } + } + + test_bop!(i8x16[i8; 16] | add[i8x16_add_test]: + ([0, -1, 2, 3, 4, 5, 6, i8::max_value(), 1, 1, 1, 1, 1, 1, 1, 1], + [8, i8::min_value(), 10, 11, 12, 13, 14, 1, 1, 1, 1, 1, 1, 1, 1, 1]) => + [8, i8::max_value(), 12, 14, 16, 18, 20, i8::min_value(), 2, 2, 2, 2, 2, 2, 2, 2]); + test_bop!(i8x16[i8; 16] | sub[i8x16_sub_test]: + ([0, -1, 2, 3, 4, 5, 6, -1, 1, 1, 1, 1, 1, 1, 1, 1], + [8, i8::min_value(), 10, 11, 12, 13, 14, i8::max_value(), 1, 1, 1, 1, 1, 1, 1, 1]) => + [-8, i8::max_value(), -8, -8, -8, -8, -8, i8::min_value(), 0, 0, 0, 0, 0, 0, 0, 0]); + test_bop!(i8x16[i8; 16] | mul[i8x16_mul_test]: + ([0, -2, 2, 3, 4, 5, 6, 2, 1, 1, 1, 1, 1, 1, 1, 1], + [8, i8::min_value(), 10, 11, 12, 13, 14, i8::max_value(), 1, 1, 1, 1, 1, 1, 1, 1]) => + [0, 0, 20, 33, 48, 65, 84, -2, 1, 1, 1, 1, 1, 1, 1, 1]); + test_uop!(i8x16[i8; 16] | neg[i8x16_neg_test]: + [8, i8::min_value(), 10, 11, 12, 13, 14, i8::max_value(), 1, 1, 1, 1, 1, 1, 1, 1] => + [-8, i8::min_value(), -10, -11, -12, -13, -14, i8::min_value() + 1, -1, -1, -1, -1, -1, -1, -1, -1]); + + test_bop!(i16x8[i16; 8] | add[i16x8_add_test]: + ([0, -1, 2, 3, 4, 5, 6, i16::max_value()], + [8, i16::min_value(), 10, 11, 12, 13, 14, 1]) => + [8, i16::max_value(), 12, 14, 16, 18, 20, i16::min_value()]); + test_bop!(i16x8[i16; 8] | sub[i16x8_sub_test]: + ([0, -1, 2, 3, 4, 5, 6, -1], + [8, i16::min_value(), 10, 11, 12, 13, 14, i16::max_value()]) => + [-8, i16::max_value(), -8, -8, -8, -8, -8, i16::min_value()]); + test_bop!(i16x8[i16; 8] | mul[i16x8_mul_test]: + ([0, -2, 2, 3, 4, 5, 6, 2], + [8, i16::min_value(), 10, 11, 12, 13, 14, i16::max_value()]) => + [0, 0, 20, 33, 48, 65, 84, -2]); + test_uop!(i16x8[i16; 8] | neg[i16x8_neg_test]: + [8, i16::min_value(), 10, 11, 12, 13, 14, i16::max_value()] => + [-8, i16::min_value(), -10, -11, -12, -13, -14, i16::min_value() + 1]); + + test_bop!(i32x4[i32; 4] | add[i32x4_add_test]: + ([0, -1, 2, i32::max_value()], + [8, i32::min_value(), 10, 1]) => + [8, i32::max_value(), 12, i32::min_value()]); + test_bop!(i32x4[i32; 4] | sub[i32x4_sub_test]: + ([0, -1, 2, -1], + [8, i32::min_value(), 10, i32::max_value()]) => + [-8, i32::max_value(), -8, i32::min_value()]); + test_bop!(i32x4[i32; 4] | mul[i32x4_mul_test]: + ([0, -2, 2, 2], + [8, i32::min_value(), 10, i32::max_value()]) => + [0, 0, 20, -2]); + test_uop!(i32x4[i32; 4] | neg[i32x4_neg_test]: + [8, i32::min_value(), 10, i32::max_value()] => + [-8, i32::min_value(), -10, i32::min_value() + 1]); + + test_bop!(i64x2[i64; 2] | add[i64x2_add_test]: + ([-1, i64::max_value()], + [i64::min_value(), 1]) => + [i64::max_value(), i64::min_value()]); + test_bop!(i64x2[i64; 2] | sub[i64x2_sub_test]: + ([-1, -1], + [i64::min_value(), i64::max_value()]) => + [ i64::max_value(), i64::min_value()]); + // note: mul for i64x2 is not part of the spec + test_uop!(i64x2[i64; 2] | neg[i64x2_neg_test]: + [i64::min_value(), i64::max_value()] => + [i64::min_value(), i64::min_value() + 1]); + + test_bops!(i8x16[i8; 16] | shl[i8x16_shl_test]: + ([0, -1, 2, 3, 4, 5, 6, i8::max_value(), 1, 1, 1, 1, 1, 1, 1, 1], 1) => + [0, -2, 4, 6, 8, 10, 12, -2, 2, 2, 2, 2, 2, 2, 2, 2]); + test_bops!(i16x8[i16; 8] | shl[i16x8_shl_test]: + ([0, -1, 2, 3, 4, 5, 6, i16::max_value()], 1) => + [0, -2, 4, 6, 8, 10, 12, -2]); + test_bops!(i32x4[i32; 4] | shl[i32x4_shl_test]: + ([0, -1, 2, 3], 1) => [0, -2, 4, 6]); + test_bops!(i64x2[i64; 2] | shl[i64x2_shl_test]: + ([0, -1], 1) => [0, -2]); + + test_bops!(i8x16[i8; 16] | shr_s[i8x16_shr_s_test]: + ([0, -1, 2, 3, 4, 5, 6, i8::max_value(), 1, 1, 1, 1, 1, 1, 1, 1], 1) => + [0, -1, 1, 1, 2, 2, 3, 63, 0, 0, 0, 0, 0, 0, 0, 0]); + test_bops!(i16x8[i16; 8] | shr_s[i16x8_shr_s_test]: + ([0, -1, 2, 3, 4, 5, 6, i16::max_value()], 1) => + [0, -1, 1, 1, 2, 2, 3, i16::max_value() / 2]); + test_bops!(i32x4[i32; 4] | shr_s[i32x4_shr_s_test]: + ([0, -1, 2, 3], 1) => [0, -1, 1, 1]); + test_bops!(i64x2[i64; 2] | shr_s[i64x2_shr_s_test]: + ([0, -1], 1) => [0, -1]); + + test_bops!(i8x16[i8; 16] | shr_u[i8x16_uhr_u_test]: + ([0, -1, 2, 3, 4, 5, 6, i8::max_value(), 1, 1, 1, 1, 1, 1, 1, 1], 1) => + [0, i8::max_value(), 1, 1, 2, 2, 3, 63, 0, 0, 0, 0, 0, 0, 0, 0]); + test_bops!(i16x8[i16; 8] | shr_u[i16x8_uhr_u_test]: + ([0, -1, 2, 3, 4, 5, 6, i16::max_value()], 1) => + [0, i16::max_value(), 1, 1, 2, 2, 3, i16::max_value() / 2]); + test_bops!(i32x4[i32; 4] | shr_u[i32x4_uhr_u_test]: + ([0, -1, 2, 3], 1) => [0, i32::max_value(), 1, 1]); + test_bops!(i64x2[i64; 2] | shr_u[i64x2_uhr_u_test]: + ([0, -1], 1) => [0, i64::max_value()]); + + #[wasm_bindgen_test] + fn v128_bitwise_logical_ops() { + unsafe { + let a: [u32; 4] = [u32::max_value(), 0, u32::max_value(), 0]; + let b: [u32; 4] = [u32::max_value(); 4]; + let c: [u32; 4] = [0; 4]; + + let vec_a: v128 = mem::transmute(a); + let vec_b: v128 = mem::transmute(b); + let vec_c: v128 = mem::transmute(c); + + let r: v128 = v128::and(vec_a, vec_a); + compare_bytes(r, vec_a); + let r: v128 = v128::and(vec_a, vec_b); + compare_bytes(r, vec_a); + let r: v128 = v128::or(vec_a, vec_b); + compare_bytes(r, vec_b); + let r: v128 = v128::not(vec_b); + compare_bytes(r, vec_c); + let r: v128 = v128::xor(vec_a, vec_c); + compare_bytes(r, vec_a); + + let r: v128 = v128::bitselect(vec_b, vec_c, vec_b); + compare_bytes(r, vec_b); + let r: v128 = v128::bitselect(vec_b, vec_c, vec_c); + compare_bytes(r, vec_c); + let r: v128 = v128::bitselect(vec_b, vec_c, vec_a); + compare_bytes(r, vec_a); + } + } + + macro_rules! test_bool_red { + ($id:ident[$test_id:ident] | [$($true:expr),*] | [$($false:expr),*] | [$($alt:expr),*]) => { + #[wasm_bindgen_test] + fn $test_id() { + unsafe { + let vec_a: v128 = mem::transmute([$($true),*]); // true + let vec_b: v128 = mem::transmute([$($false),*]); // false + let vec_c: v128 = mem::transmute([$($alt),*]); // alternating + + assert_eq!($id::any_true(vec_a), 1); + assert_eq!($id::any_true(vec_b), 0); + assert_eq!($id::any_true(vec_c), 1); + + assert_eq!($id::all_true(vec_a), 1); + assert_eq!($id::all_true(vec_b), 0); + assert_eq!($id::all_true(vec_c), 0); + } + } + } + } + + test_bool_red!( + i8x16[i8x16_boolean_reductions] + | [1_i8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] + | [0_i8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + | [1_i8, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0] + ); + test_bool_red!( + i16x8[i16x8_boolean_reductions] + | [1_i16, 1, 1, 1, 1, 1, 1, 1] + | [0_i16, 0, 0, 0, 0, 0, 0, 0] + | [1_i16, 0, 1, 0, 1, 0, 1, 0] + ); + test_bool_red!( + i32x4[i32x4_boolean_reductions] + | [1_i32, 1, 1, 1] + | [0_i32, 0, 0, 0] + | [1_i32, 0, 1, 0] + ); + test_bool_red!( + i64x2[i64x2_boolean_reductions] | [1_i64, 1] | [0_i64, 0] | [1_i64, 0] + ); + + test_bop!(i8x16[i8; 16] | eq[i8x16_eq_test]: + ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + [0, 2, 2, 4, 4, 6, 6, 7, 8, 10, 10, 12, 12, 14, 14, 15]) => + [-1, 0, -1, 0 ,-1, 0, -1, -1, -1, 0, -1, 0 ,-1, 0, -1, -1]); + test_bop!(i16x8[i16; 8] | eq[i16x8_eq_test]: + ([0, 1, 2, 3, 4, 5, 6, 7], [0, 2, 2, 4, 4, 6, 6, 7]) => + [-1, 0, -1, 0 ,-1, 0, -1, -1]); + test_bop!(i32x4[i32; 4] | eq[i32x4_eq_test]: + ([0, 1, 2, 3], [0, 2, 2, 4]) => [-1, 0, -1, 0]); + test_bop!(i64x2[i64; 2] | eq[i64x2_eq_test]: ([0, 1], [0, 2]) => [-1, 0]); + test_bop!(f32x4[f32; 4] => i32 | eq[f32x4_eq_test]: + ([0., 1., 2., 3.], [0., 2., 2., 4.]) => [-1, 0, -1, 0]); + test_bop!(f64x2[f64; 2] => i64 | eq[f64x2_eq_test]: ([0., 1.], [0., 2.]) => [-1, 0]); + + test_bop!(i8x16[i8; 16] | ne[i8x16_ne_test]: + ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + [0, 2, 2, 4, 4, 6, 6, 7, 8, 10, 10, 12, 12, 14, 14, 15]) => + [0, -1, 0, -1 ,0, -1, 0, 0, 0, -1, 0, -1 ,0, -1, 0, 0]); + test_bop!(i16x8[i16; 8] | ne[i16x8_ne_test]: + ([0, 1, 2, 3, 4, 5, 6, 7], [0, 2, 2, 4, 4, 6, 6, 7]) => + [0, -1, 0, -1 ,0, -1, 0, 0]); + test_bop!(i32x4[i32; 4] | ne[i32x4_ne_test]: + ([0, 1, 2, 3], [0, 2, 2, 4]) => [0, -1, 0, -1]); + test_bop!(i64x2[i64; 2] | ne[i64x2_ne_test]: ([0, 1], [0, 2]) => [0, -1]); + test_bop!(f32x4[f32; 4] => i32 | ne[f32x4_ne_test]: + ([0., 1., 2., 3.], [0., 2., 2., 4.]) => [0, -1, 0, -1]); + test_bop!(f64x2[f64; 2] => i64 | ne[f64x2_ne_test]: ([0., 1.], [0., 2.]) => [0, -1]); + + test_bop!(i8x16[i8; 16] | lt[i8x16_lt_test]: + ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + [0, 2, 2, 4, 4, 6, 6, 7, 8, 10, 10, 12, 12, 14, 14, 15]) => + [0, -1, 0, -1 ,0, -1, 0, 0, 0, -1, 0, -1 ,0, -1, 0, 0]); + test_bop!(i16x8[i16; 8] | lt[i16x8_lt_test]: + ([0, 1, 2, 3, 4, 5, 6, 7], [0, 2, 2, 4, 4, 6, 6, 7]) => + [0, -1, 0, -1 ,0, -1, 0, 0]); + test_bop!(i32x4[i32; 4] | lt[i32x4_lt_test]: + ([0, 1, 2, 3], [0, 2, 2, 4]) => [0, -1, 0, -1]); + test_bop!(i64x2[i64; 2] | lt[i64x2_lt_test]: ([0, 1], [0, 2]) => [0, -1]); + test_bop!(f32x4[f32; 4] => i32 | lt[f32x4_lt_test]: + ([0., 1., 2., 3.], [0., 2., 2., 4.]) => [0, -1, 0, -1]); + test_bop!(f64x2[f64; 2] => i64 | lt[f64x2_lt_test]: ([0., 1.], [0., 2.]) => [0, -1]); + + test_bop!(i8x16[i8; 16] | gt[i8x16_gt_test]: + ([0, 2, 2, 4, 4, 6, 6, 7, 8, 10, 10, 12, 12, 14, 14, 15], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) => + [0, -1, 0, -1 ,0, -1, 0, 0, 0, -1, 0, -1 ,0, -1, 0, 0]); + test_bop!(i16x8[i16; 8] | gt[i16x8_gt_test]: + ([0, 2, 2, 4, 4, 6, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]) => + [0, -1, 0, -1 ,0, -1, 0, 0]); + test_bop!(i32x4[i32; 4] | gt[i32x4_gt_test]: + ([0, 2, 2, 4], [0, 1, 2, 3]) => [0, -1, 0, -1]); + test_bop!(i64x2[i64; 2] | gt[i64x2_gt_test]: ([0, 2], [0, 1]) => [0, -1]); + test_bop!(f32x4[f32; 4] => i32 | gt[f32x4_gt_test]: + ([0., 2., 2., 4.], [0., 1., 2., 3.]) => [0, -1, 0, -1]); + test_bop!(f64x2[f64; 2] => i64 | gt[f64x2_gt_test]: ([0., 2.], [0., 1.]) => [0, -1]); + + test_bop!(i8x16[i8; 16] | ge[i8x16_ge_test]: + ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + [0, 2, 2, 4, 4, 6, 6, 7, 8, 10, 10, 12, 12, 14, 14, 15]) => + [-1, 0, -1, 0 ,-1, 0, -1, -1, -1, 0, -1, 0 ,-1, 0, -1, -1]); + test_bop!(i16x8[i16; 8] | ge[i16x8_ge_test]: + ([0, 1, 2, 3, 4, 5, 6, 7], [0, 2, 2, 4, 4, 6, 6, 7]) => + [-1, 0, -1, 0 ,-1, 0, -1, -1]); + test_bop!(i32x4[i32; 4] | ge[i32x4_ge_test]: + ([0, 1, 2, 3], [0, 2, 2, 4]) => [-1, 0, -1, 0]); + test_bop!(i64x2[i64; 2] | ge[i64x2_ge_test]: ([0, 1], [0, 2]) => [-1, 0]); + test_bop!(f32x4[f32; 4] => i32 | ge[f32x4_ge_test]: + ([0., 1., 2., 3.], [0., 2., 2., 4.]) => [-1, 0, -1, 0]); + test_bop!(f64x2[f64; 2] => i64 | ge[f64x2_ge_test]: ([0., 1.], [0., 2.]) => [-1, 0]); + + test_bop!(i8x16[i8; 16] | le[i8x16_le_test]: + ([0, 2, 2, 4, 4, 6, 6, 7, 8, 10, 10, 12, 12, 14, 14, 15], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] + ) => + [-1, 0, -1, 0 ,-1, 0, -1, -1, -1, 0, -1, 0 ,-1, 0, -1, -1]); + test_bop!(i16x8[i16; 8] | le[i16x8_le_test]: + ([0, 2, 2, 4, 4, 6, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7]) => + [-1, 0, -1, 0 ,-1, 0, -1, -1]); + test_bop!(i32x4[i32; 4] | le[i32x4_le_test]: + ([0, 2, 2, 4], [0, 1, 2, 3]) => [-1, 0, -1, 0]); + test_bop!(i64x2[i64; 2] | le[i64x2_le_test]: ([0, 2], [0, 1]) => [-1, 0]); + test_bop!(f32x4[f32; 4] => i32 | le[f32x4_le_test]: + ([0., 2., 2., 4.], [0., 1., 2., 3.]) => [-1, 0, -1, -0]); + test_bop!(f64x2[f64; 2] => i64 | le[f64x2_le_test]: ([0., 2.], [0., 1.]) => [-1, 0]); + + #[wasm_bindgen_test] + fn v128_bitwise_load_store() { + unsafe { + let mut arr: [i32; 4] = [0, 1, 2, 3]; + + let vec = v128::load(arr.as_ptr() as *const v128); + let vec = i32x4::add(vec, vec); + v128::store(arr.as_mut_ptr() as *mut v128, vec); + + assert_eq!(arr, [0, 2, 4, 6]); + } + } + + test_uop!(f32x4[f32; 4] | neg[f32x4_neg_test]: [0., 1., 2., 3.] => [ 0., -1., -2., -3.]); + test_uop!(f32x4[f32; 4] | abs[f32x4_abs_test]: [0., -1., 2., -3.] => [ 0., 1., 2., 3.]); + test_bop!(f32x4[f32; 4] | min[f32x4_min_test]: + ([0., -1., 7., 8.], [1., -3., -4., 10.]) => [0., -3., -4., 8.]); + test_bop!(f32x4[f32; 4] | min[f32x4_min_test_nan]: + ([0., -1., 7., 8.], [1., -3., -4., std::f32::NAN]) + => [0., -3., -4., std::f32::NAN]); + test_bop!(f32x4[f32; 4] | max[f32x4_max_test]: + ([0., -1., 7., 8.], [1., -3., -4., 10.]) => [1., -1., 7., 10.]); + test_bop!(f32x4[f32; 4] | max[f32x4_max_test_nan]: + ([0., -1., 7., 8.], [1., -3., -4., std::f32::NAN]) + => [1., -1., 7., std::f32::NAN]); + test_bop!(f32x4[f32; 4] | add[f32x4_add_test]: + ([0., -1., 7., 8.], [1., -3., -4., 10.]) => [1., -4., 3., 18.]); + test_bop!(f32x4[f32; 4] | sub[f32x4_sub_test]: + ([0., -1., 7., 8.], [1., -3., -4., 10.]) => [-1., 2., 11., -2.]); + test_bop!(f32x4[f32; 4] | mul[f32x4_mul_test]: + ([0., -1., 7., 8.], [1., -3., -4., 10.]) => [0., 3., -28., 80.]); + test_bop!(f32x4[f32; 4] | div[f32x4_div_test]: + ([0., -8., 70., 8.], [1., 4., 10., 2.]) => [0., -2., 7., 4.]); + + test_uop!(f64x2[f64; 2] | neg[f64x2_neg_test]: [0., 1.] => [ 0., -1.]); + test_uop!(f64x2[f64; 2] | abs[f64x2_abs_test]: [0., -1.] => [ 0., 1.]); + test_bop!(f64x2[f64; 2] | min[f64x2_min_test]: + ([0., -1.], [1., -3.]) => [0., -3.]); + test_bop!(f64x2[f64; 2] | min[f64x2_min_test_nan]: + ([7., 8.], [-4., std::f64::NAN]) + => [ -4., std::f64::NAN]); + test_bop!(f64x2[f64; 2] | max[f64x2_max_test]: + ([0., -1.], [1., -3.]) => [1., -1.]); + test_bop!(f64x2[f64; 2] | max[f64x2_max_test_nan]: + ([7., 8.], [ -4., std::f64::NAN]) + => [7., std::f64::NAN]); + test_bop!(f64x2[f64; 2] | add[f64x2_add_test]: + ([0., -1.], [1., -3.]) => [1., -4.]); + test_bop!(f64x2[f64; 2] | sub[f64x2_sub_test]: + ([0., -1.], [1., -3.]) => [-1., 2.]); + test_bop!(f64x2[f64; 2] | mul[f64x2_mul_test]: + ([0., -1.], [1., -3.]) => [0., 3.]); + test_bop!(f64x2[f64; 2] | div[f64x2_div_test]: + ([0., -8.], [1., 4.]) => [0., -2.]); + + macro_rules! test_conv { + ($test_id:ident | $conv_id:ident | $to_ty:ident | $from:expr, $to:expr) => { + #[wasm_bindgen_test] + fn $test_id() { + unsafe { + let from: v128 = mem::transmute($from); + let to: v128 = mem::transmute($to); + + let r: v128 = $to_ty::$conv_id(from); + + compare_bytes(r, to); + } + } + }; + } + + test_conv!( + f32x4_convert_s_i32x4 | convert_s_i32x4 | f32x4 | [1_i32, 2, 3, 4], + [1_f32, 2., 3., 4.] + ); + test_conv!( + f32x4_convert_u_i32x4 + | convert_u_i32x4 + | f32x4 + | [u32::max_value(), 2, 3, 4], + [u32::max_value() as f32, 2., 3., 4.] + ); + test_conv!( + f64x2_convert_s_i64x2 | convert_s_i64x2 | f64x2 | [1_i64, 2], + [1_f64, 2.] + ); + test_conv!( + f64x2_convert_u_i64x2 + | convert_u_i64x2 + | f64x2 + | [u64::max_value(), 2], + [18446744073709552000.0, 2.] + ); + + // FIXME: this fails, and produces -2147483648 instead of saturating at + // i32::max_value() test_conv!(i32x4_trunc_s_f32x4_sat | trunc_s_f32x4_sat + // | i32x4 | [1_f32, 2., (i32::max_value() as f32 + 1.), 4.], + // [1_i32, 2, i32::max_value(), 4]); FIXME: add other saturating tests +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/wasm32.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/wasm32.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/wasm32.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/wasm32.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -extern "C" { - #[link_name = "llvm.wasm.grow.memory.i32"] - fn llvm_grow_memory(pages: i32) -> i32; - #[link_name = "llvm.wasm.current.memory.i32"] - fn llvm_current_memory() -> i32; -} - -/// Corresponding intrinsic to wasm's [`current_memory` instruction][instr] -/// -/// This function, when called, will return the current memory size in units of -/// pages. -/// -/// [instr]: https://github.com/WebAssembly/design/blob/master/Semantics.md#resizing -#[inline] -pub unsafe fn current_memory() -> i32 { - llvm_current_memory() -} - -/// Corresponding intrinsic to wasm's [`grow_memory` instruction][instr] -/// -/// This function, when called, will attempt to grow the default linear memory -/// by the specified number of pages. If memory is successfully grown then the -/// previous size of memory, in pages, is returned. If memory cannot be grown -/// then -1 is returned. -/// -/// [instr]: https://github.com/WebAssembly/design/blob/master/Semantics.md#resizing -#[inline] -pub unsafe fn grow_memory(delta: i32) -> i32 { - llvm_grow_memory(delta) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/x86/cpuid.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/x86/cpuid.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/x86/cpuid.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/x86/cpuid.rs 2018-12-04 23:42:58.000000000 +0000 @@ -88,7 +88,8 @@ { // Optimization for i586 and i686 Rust targets which SSE enabled // and support cpuid: - #[cfg(target_feature = "sse")] { + #[cfg(target_feature = "sse")] + { true } @@ -99,7 +100,8 @@ // This follows the approach indicated in: // http://wiki.osdev.org/CPUID#Checking_CPUID_availability // https://software.intel.com/en-us/articles/using-cpuid-to-detect-the-presence-of-sse-41-and-sse-42-instruction-sets/ - // which detects whether `cpuid` is available by checking whether the 21st bit of the EFLAGS register is modifiable or not. + // which detects whether `cpuid` is available by checking whether + // the 21st bit of the EFLAGS register is modifiable or not. // If it is, then `cpuid` is available. let result: u32; let _temp: u32; diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/x86/eflags.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/x86/eflags.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/x86/eflags.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/x86/eflags.rs 2018-12-04 23:42:58.000000000 +0000 @@ -6,7 +6,10 @@ #[cfg(target_arch = "x86")] #[inline(always)] #[stable(feature = "simd_x86", since = "1.27.0")] -#[rustc_deprecated(since = "1.29.0", reason = "See issue #51810 - use inline assembly instead")] +#[rustc_deprecated( + since = "1.29.0", + reason = "See issue #51810 - use inline assembly instead" +)] #[doc(hidden)] pub unsafe fn __readeflags() -> u32 { let eflags: u32; @@ -20,7 +23,10 @@ #[cfg(target_arch = "x86_64")] #[inline(always)] #[stable(feature = "simd_x86", since = "1.27.0")] -#[rustc_deprecated(since = "1.29.0", reason = "See issue #51810 - use inline assembly instead")] +#[rustc_deprecated( + since = "1.29.0", + reason = "See issue #51810 - use inline assembly instead" +)] #[doc(hidden)] pub unsafe fn __readeflags() -> u64 { let eflags: u64; @@ -34,7 +40,10 @@ #[cfg(target_arch = "x86")] #[inline(always)] #[stable(feature = "simd_x86", since = "1.27.0")] -#[rustc_deprecated(since = "1.29.0", reason = "See issue #51810 - use inline assembly instead")] +#[rustc_deprecated( + since = "1.29.0", + reason = "See issue #51810 - use inline assembly instead" +)] #[doc(hidden)] pub unsafe fn __writeeflags(eflags: u32) { asm!("pushl $0; popfd" : : "r"(eflags) : "cc", "flags" : "volatile"); @@ -46,7 +55,10 @@ #[cfg(target_arch = "x86_64")] #[inline(always)] #[stable(feature = "simd_x86", since = "1.27.0")] -#[rustc_deprecated(since = "1.29.0", reason = "See issue #51810 - use inline assembly instead")] +#[rustc_deprecated( + since = "1.29.0", + reason = "See issue #51810 - use inline assembly instead" +)] #[doc(hidden)] pub unsafe fn __writeeflags(eflags: u64) { asm!("pushq $0; popfq" : : "r"(eflags) : "cc", "flags" : "volatile"); diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/x86/pclmulqdq.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/x86/pclmulqdq.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/x86/pclmulqdq.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/x86/pclmulqdq.rs 2018-12-04 23:42:58.000000000 +0000 @@ -26,19 +26,24 @@ #[inline] #[target_feature(enable = "pclmulqdq")] #[cfg_attr( - all(test, not(target_os = "linux")), assert_instr(pclmulqdq, imm8 = 0) + all(test, not(target_os = "linux")), + assert_instr(pclmulqdq, imm8 = 0) )] #[cfg_attr( - all(test, target_os = "linux"), assert_instr(pclmullqlqdq, imm8 = 0) + all(test, target_os = "linux"), + assert_instr(pclmullqlqdq, imm8 = 0) )] #[cfg_attr( - all(test, target_os = "linux"), assert_instr(pclmulhqlqdq, imm8 = 1) + all(test, target_os = "linux"), + assert_instr(pclmulhqlqdq, imm8 = 1) )] #[cfg_attr( - all(test, target_os = "linux"), assert_instr(pclmullqhqdq, imm8 = 16) + all(test, target_os = "linux"), + assert_instr(pclmullqhqdq, imm8 = 16) )] #[cfg_attr( - all(test, target_os = "linux"), assert_instr(pclmulhqhqdq, imm8 = 17) + all(test, target_os = "linux"), + assert_instr(pclmulhqhqdq, imm8 = 17) )] #[rustc_args_required_const(2)] #[stable(feature = "simd_x86", since = "1.27.0")] diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/x86/sse2.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/x86/sse2.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/x86/sse2.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/x86/sse2.rs 2018-12-04 23:42:58.000000000 +0000 @@ -1286,7 +1286,8 @@ #[target_feature(enable = "sse2")] // FIXME movd on windows, movd on i686 #[cfg_attr( - all(test, not(windows), target_arch = "x86_64"), assert_instr(movq) + all(test, not(windows), target_arch = "x86_64"), + assert_instr(movq) )] #[stable(feature = "simd_x86", since = "1.27.0")] pub unsafe fn _mm_move_epi64(a: __m128i) -> __m128i { @@ -2786,7 +2787,7 @@ #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86", since = "1.27.0")] pub unsafe fn _mm_castpd_si128(a: __m128d) -> __m128i { - mem::transmute::(simd_cast(a)) + mem::transmute(a) } /// Casts a 128-bit floating-point vector of `[4 x float]` into a 128-bit @@ -2819,7 +2820,7 @@ #[target_feature(enable = "sse2")] #[stable(feature = "simd_x86", since = "1.27.0")] pub unsafe fn _mm_castsi128_pd(a: __m128i) -> __m128d { - simd_cast(a.as_i64x2()) + mem::transmute(a) } /// Casts a 128-bit integer vector into a 128-bit floating-point vector diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/x86/sse.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/x86/sse.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/coresimd/x86/sse.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/coresimd/x86/sse.rs 2018-12-04 23:42:58.000000000 +0000 @@ -976,12 +976,13 @@ __m128(0.0, 0.0, 0.0, 0.0) } -/// A utility function for creating masks to use with Intel shuffle and permute intrinsics. +/// A utility function for creating masks to use with Intel shuffle and +/// permute intrinsics. #[inline] #[allow(non_snake_case)] #[unstable(feature = "stdsimd", issue = "27731")] pub const fn _MM_SHUFFLE(z: u32, y: u32, x: u32, w: u32) -> u32 { - (z << 6) | (y << 4) | (x << 2) | w + (z << 6) | (y << 4) | (x << 2) | w } /// Shuffle packed single-precision (32-bit) floating-point elements in `a` and @@ -1347,7 +1348,8 @@ // On i586 (no SSE2) it just generates plain MOV instructions. #[cfg_attr( all(test, any(target_arch = "x86_64", target_feature = "sse2")), - assert_instr(movhpd) + // assert_instr(movhpd) + assert_instr(movhps) // LLVM7 prefers single-precision instructions )] pub unsafe fn _mm_storeh_pi(p: *mut __m64, a: __m128) { #[cfg(target_arch = "x86")] diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/assert-instr-macro/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/assert-instr-macro/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/assert-instr-macro/Cargo.toml 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/assert-instr-macro/Cargo.toml 2018-12-04 23:42:58.000000000 +0000 @@ -10,4 +10,4 @@ [dependencies] proc-macro2 = { version = "0.4", features = ["nightly"] } quote = "0.6" -syn = { version = "0.14", features = ["full"] } +syn = { version = "0.15", features = ["full"] } diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/assert-instr-macro/src/lib.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/assert-instr-macro/src/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/assert-instr-macro/src/lib.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/assert-instr-macro/src/lib.rs 2018-12-04 23:42:58.000000000 +0000 @@ -12,7 +12,6 @@ extern crate proc_macro2; #[macro_use] extern crate quote; -#[macro_use] extern crate syn; use proc_macro2::TokenStream; @@ -38,17 +37,9 @@ // testing for. let disable_assert_instr = std::env::var("STDSIMD_DISABLE_ASSERT_INSTR").is_ok(); - let maybe_ignore = if cfg!(optimized) && !disable_assert_instr { - TokenStream::new() - } else { - (quote! { #[ignore] }).into() - }; use quote::ToTokens; let instr_str = instr - .clone() - .into_token_stream() - .to_string() .replace('.', "_") .replace(|c: char| c.is_whitespace(), ""); let assert_name = syn::Ident::new( @@ -94,8 +85,7 @@ .ident .to_string() .starts_with("target") - }) - .collect::>(); + }).collect::>(); let attrs = Append(&attrs); // Use an ABI on Windows that passes SIMD values in registers, like what @@ -125,16 +115,22 @@ } }; + // If instruction tests are disabled avoid emitting this shim at all, just + // return the original item without our attribute. + if !cfg!(optimized) || disable_assert_instr { + return (quote! { #item }).into(); + } + let tts: TokenStream = quote! { - #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] + #[cfg_attr(not(target_arch = "wasm32"), test)] #[allow(non_snake_case)] - #maybe_ignore fn #assert_name() { #to_test ::stdsimd_test::assert(#shim_name as usize, stringify!(#shim_name), - stringify!(#instr)); + #instr); } }.into(); // why? necessary now to get tests to work? @@ -149,25 +145,27 @@ } struct Invoc { - instr: syn::Expr, + instr: String, args: Vec<(syn::Ident, syn::Expr)>, } -impl syn::synom::Synom for Invoc { - named!(parse -> Self, do_parse!( - instr: syn!(syn::Expr) >> - args: many0!(do_parse!( - syn!(syn::token::Comma) >> - name: syn!(syn::Ident) >> - syn!(syn::token::Eq) >> - expr: syn!(syn::Expr) >> - (name, expr) - )) >> - (Invoc { - instr, - args, - }) - )); +impl syn::parse::Parse for Invoc { + fn parse(input: syn::parse::ParseStream) -> syn::parse::Result { + use syn::Token; + + let instr = match input.parse::() { + Ok(s) => s.to_string(), + Err(_) => input.parse::()?.value(), + }; + let mut args = Vec::new(); + while input.parse::().is_ok() { + let name = input.parse::()?; + input.parse::()?; + let expr = input.parse::()?; + args.push((name, expr)); + } + Ok(Invoc { instr, args }) + } } struct Append(T); diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/coresimd/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/coresimd/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/coresimd/Cargo.toml 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/coresimd/Cargo.toml 2018-12-04 23:42:58.000000000 +0000 @@ -22,9 +22,14 @@ stdsimd-test = { version = "0.*", path = "../stdsimd-test" } stdsimd = { version = "0.0.3", path = "../stdsimd" } +[target.wasm32-unknown-unknown.dev-dependencies] +wasm-bindgen-test = "=0.2.19" + [features] # Internal-usage only: denies all warnings. strict = [] # Internal-usage only: enables only those intrinsics supported by Intel's # Software Development Environment (SDE). intel_sde = [] +# Enables wasm simd128 intrinsics +wasm_simd128 = [] diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/coresimd/src/lib.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/coresimd/src/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/coresimd/src/lib.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/coresimd/src/lib.rs 2018-12-04 23:42:58.000000000 +0000 @@ -10,24 +10,52 @@ #![allow(dead_code)] #![allow(unused_features)] #![feature( - const_fn, link_llvm_intrinsics, platform_intrinsics, repr_simd, simd_ffi, - asm, proc_macro_gen, integer_atomics, stmt_expr_attributes, - core_intrinsics, crate_in_paths, no_core, attr_literals, rustc_attrs, - stdsimd, staged_api, core_float, core_slice_ext, align_offset, doc_cfg, - mmx_target_feature, tbm_target_feature, sse4a_target_feature, - arm_target_feature, aarch64_target_feature, mips_target_feature, - powerpc_target_feature + const_fn, + const_fn_union, + link_llvm_intrinsics, + platform_intrinsics, + repr_simd, + simd_ffi, + asm, + proc_macro_hygiene, + integer_atomics, + stmt_expr_attributes, + core_intrinsics, + no_core, + rustc_attrs, + stdsimd, + staged_api, + align_offset, + doc_cfg, + mmx_target_feature, + tbm_target_feature, + sse4a_target_feature, + arm_target_feature, + aarch64_target_feature, + mips_target_feature, + powerpc_target_feature, )] #![cfg_attr( test, - feature(use_extern_macros, test, attr_literals, abi_vectorcall, untagged_unions) + feature( + test, + abi_vectorcall, + untagged_unions + ) )] #![cfg_attr( feature = "cargo-clippy", allow( - inline_always, too_many_arguments, cast_sign_loss, cast_lossless, - cast_possible_wrap, cast_possible_truncation, cast_precision_loss, - shadow_reuse, cyclomatic_complexity, similar_names, + inline_always, + too_many_arguments, + cast_sign_loss, + cast_lossless, + cast_possible_wrap, + cast_possible_truncation, + cast_precision_loss, + shadow_reuse, + cyclomatic_complexity, + similar_names, many_single_char_names ) )] @@ -51,6 +79,9 @@ #[cfg(test)] extern crate test; +#[cfg(all(test, target_arch = "wasm32"))] +extern crate wasm_bindgen_test; + #[path = "../../../coresimd/mod.rs"] mod coresimd; diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/stdsimd/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/stdsimd/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/stdsimd/Cargo.toml 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/stdsimd/Cargo.toml 2018-12-04 23:42:58.000000000 +0000 @@ -25,7 +25,7 @@ [dev-dependencies] auxv = "0.3.3" -quickcheck = "0.6" +quickcheck = "0.7" rand = "0.5" cupid = "0.6.0" @@ -37,3 +37,7 @@ name = "wasm" crate-type = ["cdylib"] path = "../../examples/wasm.rs" + +[features] +default = [] +wasm_simd128 = ["coresimd/wasm_simd128"] \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/stdsimd/src/lib.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/stdsimd/src/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/stdsimd/src/lib.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/stdsimd/src/lib.rs 2018-12-04 23:42:58.000000000 +0000 @@ -1,7 +1,7 @@ //! SIMD and vendor intrinsics support library. //! //! This crate defines the vendor intrinsics and types primarily used for SIMD -//! in Rust. +//! in Rust. #![feature(const_fn, integer_atomics, staged_api, stdsimd)] #![feature(doc_cfg, allow_internal_unstable)] @@ -17,6 +17,7 @@ extern crate std as __do_not_use_this_import; #[cfg(test)] +#[allow(unused_imports)] #[macro_use(println, print)] extern crate std; @@ -30,6 +31,6 @@ #[allow(unused_imports)] use __do_not_use_this_import::io; #[allow(unused_imports)] -use __do_not_use_this_import::prelude; -#[allow(unused_imports)] use __do_not_use_this_import::mem; +#[allow(unused_imports)] +use __do_not_use_this_import::prelude; diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/stdsimd/tests/cpu-detection.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/stdsimd/tests/cpu-detection.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/stdsimd/tests/cpu-detection.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/stdsimd/tests/cpu-detection.rs 2018-12-04 23:42:58.000000000 +0000 @@ -5,30 +5,32 @@ allow(option_unwrap_used, use_debug, print_stdout) )] -#[cfg( - any( - target_arch = "arm", - target_arch = "aarch64", - target_arch = "x86", - target_arch = "x86_64", - target_arch = "powerpc", - target_arch = "powerpc64" - ) -)] +#[cfg(any( + target_arch = "arm", + target_arch = "aarch64", + target_arch = "x86", + target_arch = "x86_64", + target_arch = "powerpc", + target_arch = "powerpc64" +))] #[macro_use] extern crate stdsimd; #[test] -#[cfg(all(target_arch = "arm", - any(target_os = "linux", target_os = "android")))] +#[cfg(all( + target_arch = "arm", + any(target_os = "linux", target_os = "android") +))] fn arm_linux() { println!("neon: {}", is_arm_feature_detected!("neon")); println!("pmull: {}", is_arm_feature_detected!("pmull")); } #[test] -#[cfg(all(target_arch = "aarch64", - any(target_os = "linux", target_os = "android")))] +#[cfg(all( + target_arch = "aarch64", + any(target_os = "linux", target_os = "android") +))] fn aarch64_linux() { println!("fp: {}", is_aarch64_feature_detected!("fp")); println!("fp16: {}", is_aarch64_feature_detected!("fp16")); diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-test/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-test/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-test/Cargo.toml 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-test/Cargo.toml 2018-12-04 23:42:58.000000000 +0000 @@ -10,3 +10,11 @@ cc = "1.0" lazy_static = "1.0" rustc-demangle = "0.1.8" +cfg-if = "0.1" + +[target.wasm32-unknown-unknown.dependencies] +wasm-bindgen = "=0.2.19" +console_error_panic_hook = "0.1" + +[features] +default = [] diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-test/src/disassembly.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-test/src/disassembly.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-test/src/disassembly.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-test/src/disassembly.rs 2018-12-04 23:42:58.000000000 +0000 @@ -0,0 +1,214 @@ +//! Disassembly calling function for most targets. + +use ::*; +use std::process::Command; + +pub(crate) fn disassemble_myself() -> HashMap> { + let me = env::current_exe().expect("failed to get current exe"); + + if cfg!(target_arch = "x86_64") + && cfg!(target_os = "windows") + && cfg!(target_env = "msvc") + { + let mut cmd = cc::windows_registry::find( + "x86_64-pc-windows-msvc", + "dumpbin.exe", + ).expect("failed to find `dumpbin` tool"); + let output = cmd + .arg("/DISASM") + .arg(&me) + .output() + .expect("failed to execute dumpbin"); + println!( + "{}\n{}", + output.status, + String::from_utf8_lossy(&output.stderr) + ); + assert!(output.status.success()); + parse_dumpbin(&String::from_utf8_lossy(&output.stdout)) + } else if cfg!(target_os = "windows") { + panic!("disassembly unimplemented") + } else if cfg!(target_os = "macos") { + let output = Command::new("otool") + .arg("-vt") + .arg(&me) + .output() + .expect("failed to execute otool"); + println!( + "{}\n{}", + output.status, + String::from_utf8_lossy(&output.stderr) + ); + assert!(output.status.success()); + + parse_otool(str::from_utf8(&output.stdout).expect("stdout not utf8")) + } else { + let objdump = + env::var("OBJDUMP").unwrap_or_else(|_| "objdump".to_string()); + let output = Command::new(objdump.clone()) + .arg("--disassemble") + .arg(&me) + .output() + .expect(&format!( + "failed to execute objdump. OBJDUMP={}", + objdump + )); + println!( + "{}\n{}", + output.status, + String::from_utf8_lossy(&output.stderr) + ); + assert!(output.status.success()); + + parse_objdump(str::from_utf8(&output.stdout).expect("stdout not utf8")) + } +} + +fn parse_objdump(output: &str) -> HashMap> { + let mut lines = output.lines(); + let expected_len = + if cfg!(target_arch = "arm") || cfg!(target_arch = "aarch64") { + 8 + } else { + 2 + }; + + for line in output.lines().take(100) { + println!("{}", line); + } + + let mut ret = HashMap::new(); + while let Some(header) = lines.next() { + // symbols should start with `$hex_addr <$name>:` + if !header.ends_with(">:") { + continue; + } + let start = header.find('<') + .expect(&format!("\"<\" not found in symbol pattern of the form \"$hex_addr <$name>\": {}", header)); + let symbol = &header[start + 1..header.len() - 2]; + + let mut instructions = Vec::new(); + while let Some(instruction) = lines.next() { + if instruction.is_empty() { + break; + } + // Each line of instructions should look like: + // + // $rel_offset: ab cd ef 00 $instruction... + let parts = instruction + .split_whitespace() + .skip(1) + .skip_while(|s| { + s.len() == expected_len + && usize::from_str_radix(s, 16).is_ok() + }).map(|s| s.to_string()) + .collect::>(); + instructions.push(Instruction { parts }); + } + + ret.entry(normalize(symbol)) + .or_insert_with(Vec::new) + .push(Function { + addr: None, + instrs: instructions, + }); + } + + ret +} + +fn parse_otool(output: &str) -> HashMap> { + let mut lines = output.lines(); + + for line in output.lines().take(100) { + println!("{}", line); + } + + let mut ret = HashMap::new(); + let mut cached_header = None; + while let Some(header) = cached_header.take().or_else(|| lines.next()) { + // symbols should start with `$symbol:` + if !header.ends_with(':') { + continue; + } + // strip the leading underscore and the trailing colon + let symbol = &header[1..header.len() - 1]; + + let mut instructions = Vec::new(); + while let Some(instruction) = lines.next() { + if instruction.ends_with(':') { + cached_header = Some(instruction); + break; + } + // Each line of instructions should look like: + // + // $addr $instruction... + let parts = instruction + .split_whitespace() + .skip(1) + .map(|s| s.to_string()) + .collect::>(); + instructions.push(Instruction { parts }); + } + + ret.entry(normalize(symbol)) + .or_insert_with(Vec::new) + .push(Function { + addr: None, + instrs: instructions, + }); + } + + ret +} + +fn parse_dumpbin(output: &str) -> HashMap> { + let mut lines = output.lines(); + + for line in output.lines().take(100) { + println!("{}", line); + } + + let mut ret = HashMap::new(); + let mut cached_header = None; + while let Some(header) = cached_header.take().or_else(|| lines.next()) { + // symbols should start with `$symbol:` + if !header.ends_with(':') { + continue; + } + // strip the trailing colon + let symbol = &header[..header.len() - 1]; + + let mut instructions = Vec::new(); + while let Some(instruction) = lines.next() { + if !instruction.starts_with(" ") { + cached_header = Some(instruction); + break; + } + // Each line looks like: + // + // > $addr: ab cd ef $instr.. + // > 00 12 # this line os optional + if instruction.starts_with(" ") { + continue; + } + let parts = instruction + .split_whitespace() + .skip(1) + .skip_while(|s| { + s.len() == 2 && usize::from_str_radix(s, 16).is_ok() + }).map(|s| s.to_string()) + .collect::>(); + instructions.push(Instruction { parts }); + } + + ret.entry(normalize(symbol)) + .or_insert_with(Vec::new) + .push(Function { + addr: None, + instrs: instructions, + }); + } + + ret +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-test/src/lib.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-test/src/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-test/src/lib.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-test/src/lib.rs 2018-12-04 23:42:58.000000000 +0000 @@ -4,7 +4,6 @@ //! output once globally and then provides the `assert` function which makes //! assertions about the disassembly of a function. -#![feature(use_extern_macros)] #![cfg_attr( feature = "cargo-clippy", allow(missing_docs_in_private_items, print_stdout) @@ -17,14 +16,24 @@ extern crate lazy_static; extern crate rustc_demangle; extern crate simd_test_macro; - -use std::collections::HashMap; -use std::env; -use std::process::Command; -use std::str; +#[macro_use] +extern crate cfg_if; pub use assert_instr_macro::*; pub use simd_test_macro::*; +use std::{collections::HashMap, env, str}; + +cfg_if! { + if #[cfg(target_arch = "wasm32")] { + extern crate wasm_bindgen; + extern crate console_error_panic_hook; + pub mod wasm; + use wasm::disassemble_myself; + } else { + mod disassembly; + use disassembly::disassemble_myself; + } +} lazy_static! { static ref DISASSEMBLY: HashMap> = @@ -32,6 +41,7 @@ } struct Function { + addr: Option, instrs: Vec, } @@ -39,215 +49,6 @@ parts: Vec, } -fn disassemble_myself() -> HashMap> { - let me = env::current_exe().expect("failed to get current exe"); - - if cfg!(target_arch = "x86_64") - && cfg!(target_os = "windows") - && cfg!(target_env = "msvc") - { - let mut cmd = cc::windows_registry::find( - "x86_64-pc-windows-msvc", - "dumpbin.exe", - ).expect("failed to find `dumpbin` tool"); - let output = cmd - .arg("/DISASM") - .arg(&me) - .output() - .expect("failed to execute dumpbin"); - println!( - "{}\n{}", - output.status, - String::from_utf8_lossy(&output.stderr) - ); - assert!(output.status.success()); - parse_dumpbin(&String::from_utf8_lossy(&output.stdout)) - } else if cfg!(target_os = "windows") { - panic!("disassembly unimplemented") - } else if cfg!(target_os = "macos") { - let output = Command::new("otool") - .arg("-vt") - .arg(&me) - .output() - .expect("failed to execute otool"); - println!( - "{}\n{}", - output.status, - String::from_utf8_lossy(&output.stderr) - ); - assert!(output.status.success()); - - parse_otool(str::from_utf8(&output.stdout).expect("stdout not utf8")) - } else { - let objdump = - env::var("OBJDUMP").unwrap_or_else(|_| "objdump".to_string()); - let output = Command::new(objdump.clone()) - .arg("--disassemble") - .arg(&me) - .output() - .expect(&format!( - "failed to execute objdump. OBJDUMP={}", - objdump - )); - println!( - "{}\n{}", - output.status, - String::from_utf8_lossy(&output.stderr) - ); - assert!(output.status.success()); - - parse_objdump(str::from_utf8(&output.stdout).expect("stdout not utf8")) - } -} - -fn parse_objdump(output: &str) -> HashMap> { - let mut lines = output.lines(); - let expected_len = - if cfg!(target_arch = "arm") || cfg!(target_arch = "aarch64") { - 8 - } else { - 2 - }; - - for line in output.lines().take(100) { - println!("{}", line); - } - - let mut ret = HashMap::new(); - while let Some(header) = lines.next() { - // symbols should start with `$hex_addr <$name>:` - if !header.ends_with(">:") { - continue; - } - let start = header.find('<') - .expect(&format!("\"<\" not found in symbol pattern of the form \"$hex_addr <$name>\": {}", header)); - let symbol = &header[start + 1..header.len() - 2]; - - let mut instructions = Vec::new(); - while let Some(instruction) = lines.next() { - if instruction.is_empty() { - break; - } - // Each line of instructions should look like: - // - // $rel_offset: ab cd ef 00 $instruction... - let parts = instruction - .split_whitespace() - .skip(1) - .skip_while(|s| { - s.len() == expected_len - && usize::from_str_radix(s, 16).is_ok() - }) - .map(|s| s.to_string()) - .collect::>(); - instructions.push(Instruction { parts }); - } - - ret.entry(normalize(symbol)) - .or_insert_with(Vec::new) - .push(Function { - instrs: instructions, - }); - } - - ret -} - -fn parse_otool(output: &str) -> HashMap> { - let mut lines = output.lines(); - - for line in output.lines().take(100) { - println!("{}", line); - } - - let mut ret = HashMap::new(); - let mut cached_header = None; - while let Some(header) = cached_header.take().or_else(|| lines.next()) { - // symbols should start with `$symbol:` - if !header.ends_with(':') { - continue; - } - // strip the leading underscore and the trailing colon - let symbol = &header[1..header.len() - 1]; - - let mut instructions = Vec::new(); - while let Some(instruction) = lines.next() { - if instruction.ends_with(':') { - cached_header = Some(instruction); - break; - } - // Each line of instructions should look like: - // - // $addr $instruction... - let parts = instruction - .split_whitespace() - .skip(1) - .map(|s| s.to_string()) - .collect::>(); - instructions.push(Instruction { parts }); - } - - ret.entry(normalize(symbol)) - .or_insert_with(Vec::new) - .push(Function { - instrs: instructions, - }); - } - - ret -} - -fn parse_dumpbin(output: &str) -> HashMap> { - let mut lines = output.lines(); - - for line in output.lines().take(100) { - println!("{}", line); - } - - let mut ret = HashMap::new(); - let mut cached_header = None; - while let Some(header) = cached_header.take().or_else(|| lines.next()) { - // symbols should start with `$symbol:` - if !header.ends_with(':') { - continue; - } - // strip the trailing colon - let symbol = &header[..header.len() - 1]; - - let mut instructions = Vec::new(); - while let Some(instruction) = lines.next() { - if !instruction.starts_with(" ") { - cached_header = Some(instruction); - break; - } - // Each line looks like: - // - // > $addr: ab cd ef $instr.. - // > 00 12 # this line os optional - if instruction.starts_with(" ") { - continue; - } - let parts = instruction - .split_whitespace() - .skip(1) - .skip_while(|s| { - s.len() == 2 && usize::from_str_radix(s, 16).is_ok() - }) - .map(|s| s.to_string()) - .collect::>(); - instructions.push(Instruction { parts }); - } - - ret.entry(normalize(symbol)) - .or_insert_with(Vec::new) - .push(Function { - instrs: instructions, - }); - } - - ret -} - fn normalize(symbol: &str) -> String { let symbol = rustc_demangle::demangle(symbol).to_string(); match symbol.rfind("::h") { @@ -261,27 +62,8 @@ /// This asserts that the function at `fnptr` contains the instruction /// `expected` provided. pub fn assert(fnptr: usize, fnname: &str, expected: &str) { - // Translate this function pointer to a symbolic name that we'd have found - // in the disassembly. - let mut sym = None; - backtrace::resolve(fnptr as *mut _, |name| { - sym = name.name().and_then(|s| s.as_str()).map(normalize); - }); - - let functions = - if let Some(s) = sym.as_ref().and_then(|s| DISASSEMBLY.get(s)) { - s - } else { - if let Some(sym) = sym { - println!("assumed symbol name: `{}`", sym); - } - println!("maybe related functions"); - for f in DISASSEMBLY.keys().filter(|k| k.contains(fnname)) { - println!("\t- {}", f); - } - panic!("failed to find disassembly of {:#x} ({})", fnptr, fnname); - }; - + let mut fnname = fnname.to_string(); + let functions = get_functions(fnptr, &mut fnname); assert_eq!(functions.len(), 1); let function = &functions[0]; @@ -336,26 +118,29 @@ break; } - let instruction_limit = match expected { - // cpuid returns a pretty big aggregate structure so excempt it from - // the slightly more restrictive 22 instructions below - "cpuid" => 30, - - // Apparently on Windows LLVM generates a bunch of saves/restores of - // xmm registers around these intstructions which blows the 20 - // limit below. As it seems dictates by Windows's abi (I - // guess?) we probably can't do much about it... - "vzeroall" | "vzeroupper" if cfg!(windows) => 30, - - // Intrinsics using `cvtpi2ps` are typically "composites" and in some - // cases exceed the limit. - "cvtpi2ps" => 25, - - // Original limit was 20 instructions, but ARM DSP Intrinsics are - // exactly 20 instructions long. So bump the limit to 22 instead of - // adding here a long list of expections. - _ => 22, - }; + let instruction_limit = std::env::var("STDSIMD_ASSERT_INSTR_LIMIT") + .map(|v| v.parse().unwrap()) + .unwrap_or_else(|_| match expected { + // cpuid returns a pretty big aggregate structure so exempt it from + // the slightly more restrictive 22 instructions below + "cpuid" => 30, + + // Apparently on Windows LLVM generates a bunch of saves/restores + // of xmm registers around these intstructions which + // blows the 20 limit below. As it seems dictates by + // Windows's abi (I guess?) we probably can't do much + // about it... + "vzeroall" | "vzeroupper" if cfg!(windows) => 30, + + // Intrinsics using `cvtpi2ps` are typically "composites" and in + // some cases exceed the limit. + "cvtpi2ps" => 25, + + // Original limit was 20 instructions, but ARM DSP Intrinsics are + // exactly 20 instructions long. So bump the limit to 22 instead of + // adding here a long list of exceptions. + _ => 22, + }); let probably_only_one_instruction = instrs.len() < instruction_limit; if found && probably_only_one_instruction && !inlining_failed { @@ -364,16 +149,14 @@ // Help debug by printing out the found disassembly, and then panic as we // didn't find the instruction. - println!( - "disassembly for {}: ", - sym.as_ref().expect("symbol not found") - ); + println!("disassembly for {}: ", fnname,); for (i, instr) in instrs.iter().enumerate() { - print!("\t{:2}: ", i); + let mut s = format!("\t{:2}: ", i); for part in &instr.parts { - print!("{} ", part); + s.push_str(part); + s.push_str(" "); } - println!(); + println!("{}", s); } if !found { @@ -396,6 +179,39 @@ } } +fn get_functions(fnptr: usize, fnname: &mut String) -> &'static [Function] { + // Translate this function pointer to a symbolic name that we'd have found + // in the disassembly. + let mut sym = None; + backtrace::resolve(fnptr as *mut _, |name| { + sym = name.name().and_then(|s| s.as_str()).map(normalize); + }); + + if let Some(sym) = &sym { + if let Some(s) = DISASSEMBLY.get(sym) { + *fnname = sym.to_string(); + return s; + } + } + + let exact_match = DISASSEMBLY + .iter() + .find(|(_, list)| list.iter().any(|f| f.addr == Some(fnptr))); + if let Some((name, list)) = exact_match { + *fnname = name.to_string(); + return list; + } + + if let Some(sym) = sym { + println!("assumed symbol name: `{}`", sym); + } + println!("maybe related functions"); + for f in DISASSEMBLY.keys().filter(|k| k.contains(&**fnname)) { + println!("\t- {}", f); + } + panic!("failed to find disassembly of {:#x} ({})", fnptr, fnname); +} + pub fn assert_skip_test_ok(name: &str) { if env::var("STDSIMD_TEST_EVERYTHING").is_err() { return; diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-test/src/wasm.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-test/src/wasm.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-test/src/wasm.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-test/src/wasm.rs 2018-12-04 23:42:58.000000000 +0000 @@ -0,0 +1,99 @@ +//! Disassembly calling function for `wasm32` targets. +use wasm_bindgen::prelude::*; + +use ::*; + +#[wasm_bindgen(module = "child_process")] +extern "C" { + #[wasm_bindgen(js_name = execSync)] + fn exec_sync(cmd: &str) -> Buffer; +} + +#[wasm_bindgen(module = "buffer")] +extern "C" { + type Buffer; + #[wasm_bindgen(method, js_name = toString)] + fn to_string(this: &Buffer) -> String; +} + +#[wasm_bindgen] +extern "C" { + #[wasm_bindgen(js_namespace = require)] + fn resolve(module: &str) -> String; + #[wasm_bindgen(js_namespace = console, js_name = log)] + fn js_console_log(s: &str); +} + +// println! doesn't work on wasm32 right now, so shadow the compiler's println! +// macro with our own shim that redirects to `console.log`. +#[allow(unused)] +macro_rules! println { + ($($args:tt)*) => (js_console_log(&format!($($args)*))) +} + +pub(crate) fn disassemble_myself() -> HashMap> { + use std::path::Path; + ::console_error_panic_hook::set_once(); + // Our wasm module in the wasm-bindgen test harness is called + // "wasm-bindgen-test_bg". When running in node this is actually a shim JS + // file. Ask node where that JS file is, and then we use that with a wasm + // extension to find the wasm file itself. + let js_shim = resolve("wasm-bindgen-test_bg"); + let js_shim = Path::new(&js_shim).with_extension("wasm"); + + // Execute `wasm2wat` synchronously, waiting for and capturing all of its + // output. + let output = + exec_sync(&format!("wasm2wat {}", js_shim.display())).to_string(); + + let mut ret: HashMap> = HashMap::new(); + let mut lines = output.lines().map(|s| s.trim()); + while let Some(line) = lines.next() { + // If we found the table of function pointers, fill in the known + // address for all our `Function` instances + if line.starts_with("(elem") { + for (i, name) in line.split_whitespace().skip(4).enumerate() { + let name = name.trim_right_matches(")"); + for f in ret.get_mut(name).expect("ret.get_mut(name) failed") { + f.addr = Some(i + 1); + } + } + continue; + } + + // If this isn't a function, we don't care about it. + if !line.starts_with("(func ") { + continue; + } + + let mut function = Function { + instrs: Vec::new(), + addr: None, + }; + + // Empty functions will end in `))` so there's nothing to do, otherwise + // we'll have a bunch of following lines which are instructions. + // + // Lines that have an imbalanced `)` mark the end of a function. + if !line.ends_with("))") { + while let Some(line) = lines.next() { + function.instrs.push(Instruction { + parts: line + .split_whitespace() + .map(|s| s.to_string()) + .collect(), + }); + if !line.starts_with("(") && line.ends_with(")") { + break; + } + } + } + + // The second element here split on whitespace should be the name of + // the function, skipping the type/params/results + ret.entry(line.split_whitespace().nth(1).unwrap().to_string()) + .or_insert(Vec::new()) + .push(function); + } + return ret; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-verify/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-verify/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-verify/Cargo.toml 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-verify/Cargo.toml 2018-12-04 23:42:58.000000000 +0000 @@ -6,7 +6,7 @@ [dependencies] proc-macro2 = "0.4" quote = "0.6" -syn = { version = "0.14", features = ["full"] } +syn = { version = "0.15", features = ["full"] } [lib] proc-macro = true diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-verify/src/lib.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-verify/src/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-verify/src/lib.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-verify/src/lib.rs 2018-12-04 23:42:58.000000000 +0000 @@ -83,8 +83,7 @@ required_const: &[#(#required_const),*], } } - }) - .collect::>(); + }).collect::>(); let ret = quote! { #input: &[Function] = &[#(#functions),*]; }; // println!("{}", ret); @@ -93,28 +92,30 @@ fn to_type(t: &syn::Type) -> proc_macro2::TokenStream { match *t { - syn::Type::Path(ref p) => match extract_path_ident(&p.path).to_string().as_ref() { - "__m128" => quote! { &M128 }, - "__m128d" => quote! { &M128D }, - "__m128i" => quote! { &M128I }, - "__m256" => quote! { &M256 }, - "__m256d" => quote! { &M256D }, - "__m256i" => quote! { &M256I }, - "__m64" => quote! { &M64 }, - "bool" => quote! { &BOOL }, - "f32" => quote! { &F32 }, - "f64" => quote! { &F64 }, - "i16" => quote! { &I16 }, - "i32" => quote! { &I32 }, - "i64" => quote! { &I64 }, - "i8" => quote! { &I8 }, - "u16" => quote! { &U16 }, - "u32" => quote! { &U32 }, - "u64" => quote! { &U64 }, - "u8" => quote! { &U8 }, - "CpuidResult" => quote! { &CPUID }, - s => panic!("unspported type: {}", s), - }, + syn::Type::Path(ref p) => { + match extract_path_ident(&p.path).to_string().as_ref() { + "__m128" => quote! { &M128 }, + "__m128d" => quote! { &M128D }, + "__m128i" => quote! { &M128I }, + "__m256" => quote! { &M256 }, + "__m256d" => quote! { &M256D }, + "__m256i" => quote! { &M256I }, + "__m64" => quote! { &M64 }, + "bool" => quote! { &BOOL }, + "f32" => quote! { &F32 }, + "f64" => quote! { &F64 }, + "i16" => quote! { &I16 }, + "i32" => quote! { &I32 }, + "i64" => quote! { &I64 }, + "i8" => quote! { &I8 }, + "u16" => quote! { &U16 }, + "u32" => quote! { &U32 }, + "u64" => quote! { &U64 }, + "u8" => quote! { &U8 }, + "CpuidResult" => quote! { &CPUID }, + s => panic!("unspported type: {}", s), + } + } syn::Type::Ptr(syn::TypePtr { ref elem, .. }) | syn::Type::Reference(syn::TypeReference { ref elem, .. }) => { let tokens = to_type(&elem); @@ -183,8 +184,7 @@ } } _ => None, - }) - .filter_map(|nested| match nested { + }).filter_map(|nested| match nested { syn::NestedMeta::Meta(syn::Meta::List(i)) => { if i.ident == "assert_instr" { i.nested.into_iter().next() @@ -193,12 +193,10 @@ } } _ => None, - }) - .filter_map(|nested| match nested { + }).filter_map(|nested| match nested { syn::NestedMeta::Meta(syn::Meta::Word(i)) => Some(i), _ => None, - }) - .collect() + }).collect() } fn find_target_feature(attrs: &[syn::Attribute]) -> Option { @@ -214,13 +212,11 @@ } } _ => None, - }) - .flat_map(|list| list) + }).flat_map(|list| list) .filter_map(|nested| match nested { syn::NestedMeta::Meta(m) => Some(m), syn::NestedMeta::Literal(_) => None, - }) - .filter_map(|m| match m { + }).filter_map(|m| match m { syn::Meta::NameValue(i) => { if i.ident == "enable" { Some(i.lit) @@ -229,8 +225,7 @@ } } _ => None, - }) - .next() + }).next() } fn find_required_const(attrs: &[syn::Attribute]) -> Vec { @@ -247,15 +242,16 @@ args: Vec, } -impl syn::synom::Synom for RustcArgsRequiredConst { - named!(parse -> Self, do_parse!( - items: parens!( - call!(syn::punctuated::Punctuated::::parse_terminated) - ) >> - (RustcArgsRequiredConst { - args: items.1.into_iter() +impl syn::parse::Parse for RustcArgsRequiredConst { + fn parse(input: syn::parse::ParseStream) -> syn::parse::Result { + let content; + parenthesized!(content in input); + let list = syn::punctuated::Punctuated:: + ::parse_terminated(&content)?; + Ok(RustcArgsRequiredConst { + args: list.into_iter() .map(|a| a.value() as usize) .collect(), }) - )); + } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-verify/tests/x86-intel.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-verify/tests/x86-intel.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-verify/tests/x86-intel.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/crates/stdsimd-verify/tests/x86-intel.rs 2018-12-04 23:42:58.000000000 +0000 @@ -1,10 +1,15 @@ -#![feature(use_extern_macros)] #![allow(bad_style)] #![cfg_attr( feature = "cargo-clippy", allow( - shadow_reuse, cast_lossless, match_same_arms, nonminimal_bool, - print_stdout, use_debug, eq_op, useless_format + shadow_reuse, + cast_lossless, + match_same_arms, + nonminimal_bool, + print_stdout, + use_debug, + eq_op, + useless_format ) )] @@ -324,12 +329,15 @@ } } - let any_i64 = rust.arguments.iter().cloned().chain(rust.ret).any(|arg| { - match *arg { - Type::PrimSigned(64) | Type::PrimUnsigned(64) => true, - _ => false, - } - }); + let any_i64 = + rust.arguments + .iter() + .cloned() + .chain(rust.ret) + .any(|arg| match *arg { + Type::PrimSigned(64) | Type::PrimUnsigned(64) => true, + _ => false, + }); let any_i64_exempt = match rust.name { // These intrinsics have all been manually verified against Clang's // headers to be available on x86, and the u64 arguments seem diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/examples/hex.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/examples/hex.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/examples/hex.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/examples/hex.rs 2018-12-04 23:42:58.000000000 +0000 @@ -17,8 +17,13 @@ #![cfg_attr( feature = "cargo-clippy", allow( - result_unwrap_used, print_stdout, option_unwrap_used, shadow_reuse, - cast_possible_wrap, cast_sign_loss, missing_docs_in_private_items + result_unwrap_used, + print_stdout, + option_unwrap_used, + shadow_reuse, + cast_possible_wrap, + cast_sign_loss, + missing_docs_in_private_items ) )] diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/examples/wasm.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/examples/wasm.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/examples/wasm.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/examples/wasm.rs 2018-12-04 23:42:58.000000000 +0000 @@ -20,7 +20,7 @@ return ret as *mut u8; } - let ret = grow_memory(1); + let ret = memory::grow(0, 1); // if we failed to allocate a page then return null if ret == -1 { @@ -39,7 +39,7 @@ #[no_mangle] pub unsafe extern "C" fn memory_used() -> usize { - (page_size() * (current_memory() as u32)) as usize + (page_size() * (memory::size(0) as u32)) as usize } fn page_size() -> u32 { diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/stdsimd/mod.rs rustc-1.31.0+dfsg1+llvm/src/stdsimd/stdsimd/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/stdsimd/mod.rs 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/stdsimd/mod.rs 2018-12-04 23:42:58.000000000 +0000 @@ -187,6 +187,8 @@ /// * [`mips64`] /// * [`powerpc`] /// * [`powerpc64`] +/// * [`nvptx`] +/// * [`wasm32`] /// /// [`x86`]: x86/index.html /// [`x86_64`]: x86_64/index.html @@ -196,6 +198,8 @@ /// [`mips64`]: mips64/index.html /// [`powerpc`]: powerpc/index.html /// [`powerpc64`]: powerpc64/index.html +/// [`nvptx`]: nvptx/index.html +/// [`wasm32`]: wasm32/index.html /// /// # Examples /// @@ -360,10 +364,6 @@ #[unstable(feature = "stdsimd", issue = "27731")] pub use coresimd::arch::aarch64; - #[cfg(target_arch = "wasm32")] - #[unstable(feature = "stdsimd", issue = "27731")] - pub use coresimd::arch::wasm32; - #[cfg(all(not(dox), target_arch = "mips"))] #[unstable(feature = "stdsimd", issue = "27731")] pub use coresimd::arch::mips; @@ -380,6 +380,14 @@ #[unstable(feature = "stdsimd", issue = "27731")] pub use coresimd::arch::powerpc64; + #[cfg(all(not(dox), any(target_arch = "nvptx", target_arch = "nvptx64")))] + #[unstable(feature = "stdsimd", issue = "27731")] + pub use coresimd::arch::nvptx; + + #[cfg(all(not(dox), target_arch = "wasm32"))] + #[unstable(feature = "stdsimd", issue = "27731")] + pub use coresimd::arch::wasm32; + #[doc(hidden)] // unstable implementation detail #[unstable(feature = "stdsimd", issue = "27731")] pub mod detect; @@ -479,4 +487,28 @@ #[doc(cfg(target_arch = "powerpc64"))] #[unstable(feature = "stdsimd", issue = "27731")] pub mod powerpc64 {} + + /// Platform-specific intrinsics for the `nvptx` platform. + /// + /// The documentation with the full listing of `nvptx` intrinsics is + /// available in [libcore], but the module is re-exported here in std + /// as well. + /// + /// [libcore]: ../../../core/arch/nvptx/index.html + #[cfg(dox)] + #[doc(cfg(any(target_arch = "nvptx", target_arch = "nvptx64")))] + #[unstable(feature = "stdsimd", issue = "27731")] + pub mod nvptx {} + + /// Platform-specific intrinsics for the `wasm32` platform. + /// + /// The documentation with the full listing of `wasm32` intrinsics is + /// available in [libcore], but the module is re-exported here in std + /// as well. + /// + /// [libcore]: ../../../core/arch/wasm32/index.html + #[cfg(dox)] + #[doc(cfg(target_arch = "wasm32"))] + #[unstable(feature = "stdsimd", issue = "27731")] + pub mod wasm32 {} } diff -Nru rustc-1.30.0+dfsg1+llvm/src/stdsimd/.travis.yml rustc-1.31.0+dfsg1+llvm/src/stdsimd/.travis.yml --- rustc-1.30.0+dfsg1+llvm/src/stdsimd/.travis.yml 2018-10-24 20:01:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/stdsimd/.travis.yml 2018-12-04 23:42:58.000000000 +0000 @@ -6,9 +6,13 @@ fast_finish: true include: - env: TARGET=i586-unknown-linux-gnu + rust: nightly-2018-10-20 - env: TARGET=i686-unknown-linux-gnu + rust: nightly-2018-10-20 - env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1 + rust: nightly-2018-10-20 - env: TARGET=x86_64-unknown-linux-gnu-emulated NO_ADD=1 STDSIMD_TEST_EVERYTHING=1 + rust: nightly-2018-10-20 - env: TARGET=x86_64-linux-android - env: TARGET=arm-unknown-linux-gnueabihf - env: TARGET=arm-linux-androideabi @@ -26,22 +30,12 @@ - os: osx env: TARGET=i686-apple-darwin script: ci/run.sh + rust: nightly-2018-10-20 - os: osx env: TARGET=x86_64-apple-darwin NO_ADD=1 script: ci/run.sh + rust: nightly-2018-10-20 - env: TARGET=wasm32-unknown-unknown - before_script: - - git clone --recursive https://github.com/WebAssembly/wabt - - (cd wabt && git reset --hard a0bdeb7 && make -j4) - - export PATH=$PATH:$PWD/wabt/bin - script: - - cargo build --target wasm32-unknown-unknown -p stdsimd - - cargo build --target wasm32-unknown-unknown -p stdsimd --release - - cargo rustc --target wasm32-unknown-unknown -p stdsimd --release --example wasm -- -C lto - - wasm2wat target/wasm32-unknown-unknown/release/examples/wasm.wasm -o wasm.wat - - cat wasm.wat - - grep current_memory wasm.wat - - grep grow_memory wasm.wat - env: TARGET=thumbv6m-none-eabi NOSTD=1 - env: TARGET=thumbv7m-none-eabi NOSTD=1 - env: TARGET=thumbv7em-none-eabi NOSTD=1 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/codegen/align-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/codegen/align-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/codegen/align-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/codegen/align-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -48,6 +48,16 @@ a64 } +// For issue 54028: make sure that we are specifying the correct alignment for fields of aligned +// structs +// CHECK-LABEL: @align64_load +#[no_mangle] +pub fn align64_load(a: Align64) -> i32 { +// CHECK: [[FIELD:%.*]] = bitcast %Align64* %{{.*}} to i32* +// CHECK: {{%.*}} = load i32, i32* [[FIELD]], align 64 + a.0 +} + // CHECK-LABEL: @nested64 #[no_mangle] pub fn nested64(a: Align64, b: i32, c: i32, d: i8) -> Nested64 { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/codegen/box-maybe-uninit.rs rustc-1.31.0+dfsg1+llvm/src/test/codegen/box-maybe-uninit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/codegen/box-maybe-uninit.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/codegen/box-maybe-uninit.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -O +#![crate_type="lib"] +#![feature(maybe_uninit)] + +use std::mem::MaybeUninit; + +// Boxing a `MaybeUninit` value should not copy junk from the stack +#[no_mangle] +pub fn box_uninitialized() -> Box> { + // CHECK-LABEL: @box_uninitialized + // CHECK-NOT: store + Box::new(MaybeUninit::uninitialized()) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/codegen/export-no-mangle.rs rustc-1.31.0+dfsg1+llvm/src/test/codegen/export-no-mangle.rs --- rustc-1.30.0+dfsg1+llvm/src/test/codegen/export-no-mangle.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/codegen/export-no-mangle.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +mod private { + // CHECK: @FOO = + #[no_mangle] + pub static FOO: u32 = 3; + + // CHECK: @BAR = + #[export_name = "BAR"] + static BAR: u32 = 3; + + // CHECK: void @foo() + #[no_mangle] + pub extern fn foo() {} + + // CHECK: void @bar() + #[export_name = "bar"] + extern fn bar() {} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/codegen/external-no-mangle-fns.rs rustc-1.31.0+dfsg1+llvm/src/test/codegen/external-no-mangle-fns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/codegen/external-no-mangle-fns.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/codegen/external-no-mangle-fns.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,63 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -O +// `#[no_mangle]`d functions always have external linkage, i.e. no `internal` in their `define`s + +#![crate_type = "lib"] +#![no_std] + +// CHECK: define void @a() +#[no_mangle] +fn a() {} + +// CHECK: define void @b() +#[no_mangle] +pub fn b() {} + +mod private { + // CHECK: define void @c() + #[no_mangle] + fn c() {} + + // CHECK: define void @d() + #[no_mangle] + pub fn d() {} +} + +const HIDDEN: () = { + // CHECK: define void @e() + #[no_mangle] + fn e() {} + + // CHECK: define void @f() + #[no_mangle] + pub fn f() {} +}; + +// The surrounding item should not accidentally become external +// CHECK: define internal {{.*}} void @_ZN22external_no_mangle_fns1x +#[inline(never)] +fn x() { + // CHECK: define void @g() + #[no_mangle] + fn g() { + x(); + } + + // CHECK: define void @h() + #[no_mangle] + pub fn h() {} + + // side effect to keep `x` around + unsafe { + core::ptr::read_volatile(&42); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/codegen/external-no-mangle-statics.rs rustc-1.31.0+dfsg1+llvm/src/test/codegen/external-no-mangle-statics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/codegen/external-no-mangle-statics.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/codegen/external-no-mangle-statics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,88 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -O +// `#[no_mangle]`d static variables always have external linkage, i.e. no `internal` in their +// definitions + +#![crate_type = "lib"] +#![no_std] + +// CHECK: @A = local_unnamed_addr constant +#[no_mangle] +static A: u8 = 0; + +// CHECK: @B = local_unnamed_addr global +#[no_mangle] +static mut B: u8 = 0; + +// CHECK: @C = local_unnamed_addr constant +#[no_mangle] +pub static C: u8 = 0; + +// CHECK: @D = local_unnamed_addr global +#[no_mangle] +pub static mut D: u8 = 0; + +mod private { + // CHECK: @E = local_unnamed_addr constant + #[no_mangle] + static E: u8 = 0; + + // CHECK: @F = local_unnamed_addr global + #[no_mangle] + static mut F: u8 = 0; + + // CHECK: @G = local_unnamed_addr constant + #[no_mangle] + pub static G: u8 = 0; + + // CHECK: @H = local_unnamed_addr global + #[no_mangle] + pub static mut H: u8 = 0; +} + +const HIDDEN: () = { + // CHECK: @I = local_unnamed_addr constant + #[no_mangle] + static I: u8 = 0; + + // CHECK: @J = local_unnamed_addr global + #[no_mangle] + static mut J: u8 = 0; + + // CHECK: @K = local_unnamed_addr constant + #[no_mangle] + pub static K: u8 = 0; + + // CHECK: @L = local_unnamed_addr global + #[no_mangle] + pub static mut L: u8 = 0; +}; + +// The surrounding item should not accidentally become external +fn x() { + // CHECK: @M = local_unnamed_addr constant + #[no_mangle] + static M: fn() = x; + + // CHECK: @N = local_unnamed_addr global + #[no_mangle] + static mut N: u8 = 0; + + // CHECK: @O = local_unnamed_addr constant + #[no_mangle] + pub static O: u8 = 0; + + // CHECK: @P = local_unnamed_addr global + #[no_mangle] + pub static mut P: u8 = 0; +} +// CHECK: define internal void @_ZN26external_no_mangle_statics1x{{.*$}} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/codegen/issue-32364.rs rustc-1.31.0+dfsg1+llvm/src/test/codegen/issue-32364.rs --- rustc-1.30.0+dfsg1+llvm/src/test/codegen/issue-32364.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/codegen/issue-32364.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-arm -// ignore-aarch64 +// Test that `extern "stdcall"` is properly translated. + +// only-x86 // compile-flags: -C no-prepopulate-passes diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/codegen/issue-44056-macos-tls-align.rs rustc-1.31.0+dfsg1+llvm/src/test/codegen/issue-44056-macos-tls-align.rs --- rustc-1.30.0+dfsg1+llvm/src/test/codegen/issue-44056-macos-tls-align.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/codegen/issue-44056-macos-tls-align.rs 2018-12-04 23:41:40.000000000 +0000 @@ -17,15 +17,13 @@ #![crate_type = "rlib"] #![feature(thread_local)] -// CHECK: @STATIC_VAR_1 = internal thread_local unnamed_addr global <{ [32 x i8] }> zeroinitializer, section "__DATA,__thread_bss", align 4 +// CHECK: @STATIC_VAR_1 = thread_local local_unnamed_addr global <{ [32 x i8] }> zeroinitializer, section "__DATA,__thread_bss", align 4 #[no_mangle] -#[allow(private_no_mangle_statics)] #[thread_local] static mut STATIC_VAR_1: [u32; 8] = [0; 8]; -// CHECK: @STATIC_VAR_2 = internal thread_local unnamed_addr global <{ [32 x i8] }> <{{[^>]*}}>, section "__DATA,__thread_data", align 4 +// CHECK: @STATIC_VAR_2 = thread_local local_unnamed_addr global <{ [32 x i8] }> <{{[^>]*}}>, section "__DATA,__thread_data", align 4 #[no_mangle] -#[allow(private_no_mangle_statics)] #[thread_local] static mut STATIC_VAR_2: [u32; 8] = [4; 8]; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/codegen/issue-56267-2.rs rustc-1.31.0+dfsg1+llvm/src/test/codegen/issue-56267-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/codegen/issue-56267-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/codegen/issue-56267-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// compile-flags: -C no-prepopulate-passes + +#![crate_type="rlib"] + +#[allow(dead_code)] +pub struct Foo { + foo: u64, + bar: T, +} + +// The load from bar.1 should have alignment 4. Not checking +// other loads here, as the alignment will be platform-dependent. + +// CHECK: %{{.+}} = load i32, i32* %{{.+}}, align 4 +#[no_mangle] +pub fn test(x: Foo<(i32, i32)>) -> (i32, i32) { + x.bar +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/codegen/issue-56267.rs rustc-1.31.0+dfsg1+llvm/src/test/codegen/issue-56267.rs --- rustc-1.30.0+dfsg1+llvm/src/test/codegen/issue-56267.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/codegen/issue-56267.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// compile-flags: -C no-prepopulate-passes + +#![crate_type="rlib"] + +#[allow(dead_code)] +pub struct Foo { + foo: u64, + bar: T, +} + +// The store writing to bar.1 should have alignment 4. Not checking +// other stores here, as the alignment will be platform-dependent. + +// CHECK: store i32 [[TMP1:%.+]], i32* [[TMP2:%.+]], align 4 +#[no_mangle] +pub fn test(x: (i32, i32)) -> Foo<(i32, i32)> { + Foo { foo: 0, bar: x } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/codegen/link-dead-code.rs rustc-1.31.0+dfsg1+llvm/src/test/codegen/link-dead-code.rs --- rustc-1.30.0+dfsg1+llvm/src/test/codegen/link-dead-code.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/codegen/link-dead-code.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,6 @@ // compile-flags:-Clink-dead-code -#![feature(min_const_fn)] #![crate_type = "rlib"] // This test makes sure that, when -Clink-dead-code is specified, we generate diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/codegen/lto-removes-invokes.rs rustc-1.31.0+dfsg1+llvm/src/test/codegen/lto-removes-invokes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/codegen/lto-removes-invokes.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/codegen/lto-removes-invokes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -20,8 +20,8 @@ fn foo() { let _a = Box::new(3); bar(); -// CHECK-LABEL: foo -// CHECK: call {{.*}} void @bar +// CHECK-LABEL: define void @foo +// CHECK: call void @bar } #[inline(never)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/codegen/naked-functions.rs rustc-1.31.0+dfsg1+llvm/src/test/codegen/naked-functions.rs --- rustc-1.30.0+dfsg1+llvm/src/test/codegen/naked-functions.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/codegen/naked-functions.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,7 +15,7 @@ #![crate_type = "lib"] #![feature(naked_functions)] -// CHECK: Function Attrs: naked uwtable +// CHECK: Function Attrs: naked // CHECK-NEXT: define void @naked_empty() #[no_mangle] #[naked] @@ -24,7 +24,7 @@ // CHECK-NEXT: ret void } -// CHECK: Function Attrs: naked uwtable +// CHECK: Function Attrs: naked #[no_mangle] #[naked] // CHECK-NEXT: define void @naked_with_args(i{{[0-9]+}}) @@ -35,7 +35,7 @@ // CHECK: ret void } -// CHECK: Function Attrs: naked uwtable +// CHECK: Function Attrs: naked // CHECK-NEXT: define i{{[0-9]+}} @naked_with_return() #[no_mangle] #[naked] @@ -45,7 +45,7 @@ 0 } -// CHECK: Function Attrs: naked uwtable +// CHECK: Function Attrs: naked // CHECK-NEXT: define i{{[0-9]+}} @naked_with_args_and_return(i{{[0-9]+}}) #[no_mangle] #[naked] @@ -57,7 +57,7 @@ a } -// CHECK: Function Attrs: naked uwtable +// CHECK: Function Attrs: naked // CHECK-NEXT: define void @naked_recursive() #[no_mangle] #[naked] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/codegen/no-plt.rs rustc-1.31.0+dfsg1+llvm/src/test/codegen/no-plt.rs --- rustc-1.30.0+dfsg1+llvm/src/test/codegen/no-plt.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/codegen/no-plt.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -C relocation-model=pic -Z plt=no + +#![crate_type = "lib"] + +// We need a function which is normally called through the PLT. +extern "C" { + // CHECK: Function Attrs: nounwind nonlazybind + fn getenv(name: *const u8) -> *mut u8; +} + +// Ensure the function gets referenced. +pub unsafe fn call_through_plt() -> *mut u8 { + getenv(b"\0".as_ptr()) +} + +// Ensure intrinsics also skip the PLT +// CHECK: !"RtLibUseGOT" diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/codegen-units/item-collection/unreferenced-const-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/codegen-units/item-collection/unreferenced-const-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/codegen-units/item-collection/unreferenced-const-fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/codegen-units/item-collection/unreferenced-const-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,7 +13,6 @@ // NB: We do not expect *any* monomorphization to be generated here. -#![feature(min_const_fn)] #![deny(dead_code)] #![crate_type = "rlib"] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/compile-fail/const-fn-error.rs rustc-1.31.0+dfsg1+llvm/src/test/compile-fail/const-fn-error.rs --- rustc-1.30.0+dfsg1+llvm/src/test/compile-fail/const-fn-error.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/compile-fail/const-fn-error.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(const_fn)] + +const X : usize = 2; + +const fn f(x: usize) -> usize { + let mut sum = 0; + //~^ let bindings in constant functions are unstable + //~| statements in constant functions are unstable + for i in 0..x { + //~^ ERROR E0015 + //~| ERROR E0019 + sum += i; + } + sum +} + +#[allow(unused_variables)] +fn main() { + let a : [i32; f(X)]; //~ ERROR E0080 +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/compile-fail/issue-43733-2.rs rustc-1.31.0+dfsg1+llvm/src/test/compile-fail/issue-43733-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/compile-fail/issue-43733-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/compile-fail/issue-43733-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(min_const_fn)] #![feature(cfg_target_thread_local, thread_local_internals)] // On platforms *without* `#[thread_local]`, use diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/compile-fail/issue-52443.rs rustc-1.31.0+dfsg1+llvm/src/test/compile-fail/issue-52443.rs --- rustc-1.30.0+dfsg1+llvm/src/test/compile-fail/issue-52443.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/compile-fail/issue-52443.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + [(); & { loop { continue } } ]; //~ ERROR mismatched types + [(); loop { break }]; //~ ERROR mismatched types + [(); {while true {break}; 0}]; //~ ERROR constant contains unimplemented expression type + [(); { for _ in 0usize.. {}; 0}]; //~ ERROR calls in constants are limited to constant functions + //~^ ERROR constant contains unimplemented expression type + //~| ERROR could not evaluate repeat length +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/compile-fail-fulldeps/auxiliary/lint_for_crate.rs rustc-1.31.0+dfsg1+llvm/src/test/compile-fail-fulldeps/auxiliary/lint_for_crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/compile-fail-fulldeps/auxiliary/lint_for_crate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/compile-fail-fulldeps/auxiliary/lint_for_crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,7 +12,6 @@ #![feature(plugin_registrar, rustc_private)] #![feature(box_syntax)] -#![cfg_attr(stage0, feature(macro_vis_matcher))] #![feature(macro_at_most_once_rep)] #[macro_use] extern crate rustc; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs rustc-1.31.0+dfsg1+llvm/src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs --- rustc-1.30.0+dfsg1+llvm/src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,7 +12,6 @@ #![feature(plugin_registrar)] #![feature(box_syntax, rustc_private)] -#![cfg_attr(stage0, feature(macro_vis_matcher))] #![feature(macro_at_most_once_rep)] // Load rustc as a plugin to get macros diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/compile-fail-fulldeps/auxiliary/lint_plugin_test.rs rustc-1.31.0+dfsg1+llvm/src/test/compile-fail-fulldeps/auxiliary/lint_plugin_test.rs --- rustc-1.30.0+dfsg1+llvm/src/test/compile-fail-fulldeps/auxiliary/lint_plugin_test.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/compile-fail-fulldeps/auxiliary/lint_plugin_test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,7 +12,6 @@ #![feature(plugin_registrar)] #![feature(box_syntax, rustc_private)] -#![cfg_attr(stage0, feature(macro_vis_matcher))] #![feature(macro_at_most_once_rep)] extern crate syntax; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/compile-fail-fulldeps/dropck_tarena_cycle_checked.rs rustc-1.31.0+dfsg1+llvm/src/test/compile-fail-fulldeps/dropck_tarena_cycle_checked.rs --- rustc-1.30.0+dfsg1+llvm/src/test/compile-fail-fulldeps/dropck_tarena_cycle_checked.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/compile-fail-fulldeps/dropck_tarena_cycle_checked.rs 2018-12-04 23:41:40.000000000 +0000 @@ -122,6 +122,6 @@ } fn main() { - let arena = TypedArena::new(); + let arena = TypedArena::default(); f(&arena); } //~^ ERROR `arena` does not live long enough diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/compile-fail-fulldeps/dropck_tarena_unsound_drop.rs rustc-1.31.0+dfsg1+llvm/src/test/compile-fail-fulldeps/dropck_tarena_unsound_drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/compile-fail-fulldeps/dropck_tarena_unsound_drop.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/compile-fail-fulldeps/dropck_tarena_unsound_drop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -47,7 +47,7 @@ fn f<'a>(_arena: &'a TypedArena>) {} fn main() { - let arena: TypedArena = TypedArena::new(); + let arena: TypedArena = TypedArena::default(); f(&arena); } //~^ ERROR `arena` does not live long enough diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs rustc-1.31.0+dfsg1+llvm/src/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,7 +13,7 @@ //! Attributes producing expressions in invalid locations -#![feature(stmt_expr_attributes, proc_macro_expr)] +#![feature(stmt_expr_attributes, proc_macro_hygiene)] extern crate attr_stmt_expr; use attr_stmt_expr::{duplicate, no_output}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/compile-fail-fulldeps/proc-macro/attr-stmt-expr.rs rustc-1.31.0+dfsg1+llvm/src/test/compile-fail-fulldeps/proc-macro/attr-stmt-expr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/compile-fail-fulldeps/proc-macro/attr-stmt-expr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/compile-fail-fulldeps/proc-macro/attr-stmt-expr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ // aux-build:attr-stmt-expr.rs // ignore-stage1 -#![feature(proc_macro_expr)] +#![feature(proc_macro_hygiene)] extern crate attr_stmt_expr; use attr_stmt_expr::{expect_let, expect_print_stmt, expect_expr, expect_print_expr}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/compile-fail-fulldeps/proc-macro/lints_in_proc_macros.rs rustc-1.31.0+dfsg1+llvm/src/test/compile-fail-fulldeps/proc-macro/lints_in_proc_macros.rs --- rustc-1.30.0+dfsg1+llvm/src/test/compile-fail-fulldeps/proc-macro/lints_in_proc_macros.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/compile-fail-fulldeps/proc-macro/lints_in_proc_macros.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ // aux-build:bang_proc_macro2.rs // ignore-stage1 -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] #![allow(unused_macros)] extern crate bang_proc_macro2; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates.rs rustc-1.31.0+dfsg1+llvm/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates.rs --- rustc-1.30.0+dfsg1+llvm/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,11 +9,7 @@ // except according to those terms. // aux-build:proc-macro-gates.rs -// gate-test-proc_macro_non_items -// gate-test-proc_macro_mod line -// gate-test-proc_macro_expr -// gate-test-proc_macro_mod -// gate-test-proc_macro_gen +// gate-test-proc_macro_hygiene #![feature(stmt_expr_attributes)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/associated-types.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/associated-types.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/associated-types.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/associated-types.rs 2018-12-04 23:41:40.000000000 +0000 @@ -51,33 +51,42 @@ // lldb-command:run // lldb-command:print arg -// lldb-check:[...]$0 = Struct { b: -1, b1: 0 } +// lldbg-check:[...]$0 = Struct { b: -1, b1: 0 } +// lldbr-check:(associated_types::Struct) arg = Struct { b: -1, b1: 0 } // lldb-command:continue // lldb-command:print inferred -// lldb-check:[...]$1 = 1 +// lldbg-check:[...]$1 = 1 +// lldbr-check:(i64) inferred = 1 // lldb-command:print explicitly -// lldb-check:[...]$2 = 1 +// lldbg-check:[...]$2 = 1 +// lldbr-check:(i64) explicitly = 1 // lldb-command:continue // lldb-command:print arg -// lldb-check:[...]$3 = 2 +// lldbg-check:[...]$3 = 2 +// lldbr-check:(i64) arg = 2 // lldb-command:continue // lldb-command:print arg -// lldb-check:[...]$4 = (4, 5) +// lldbg-check:[...]$4 = (4, 5) +// lldbr-check:((i32, i64)) arg = { = 4 = 5 } // lldb-command:continue // lldb-command:print a -// lldb-check:[...]$5 = 6 +// lldbg-check:[...]$5 = 6 +// lldbr-check:(i32) a = 6 // lldb-command:print b -// lldb-check:[...]$6 = 7 +// lldbg-check:[...]$6 = 7 +// lldbr-check:(i64) b = 7 // lldb-command:continue // lldb-command:print a -// lldb-check:[...]$7 = 8 +// lldbg-check:[...]$7 = 8 +// lldbr-check:(i64) a = 8 // lldb-command:print b -// lldb-check:[...]$8 = 9 +// lldbg-check:[...]$8 = 9 +// lldbr-check:(i32) b = 9 // lldb-command:continue #![allow(unused_variables)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/basic-types.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/basic-types.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/basic-types.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/basic-types.rs 2018-12-04 23:41:40.000000000 +0000 @@ -56,36 +56,49 @@ // lldb-command:run // lldb-command:print b -// lldb-check:[...]$0 = false +// lldbg-check:[...]$0 = false +// lldbr-check:(bool) b = false // lldb-command:print i -// lldb-check:[...]$1 = -1 +// lldbg-check:[...]$1 = -1 +// lldbr-check:(isize) i = -1 -// NOTE: LLDB does not support 32bit chars -// d ebugger:print (usize)(c) -// c heck:$3 = 97 +// NOTE: only rust-enabled lldb supports 32bit chars +// lldbr-command:print c +// lldbr-check:(char) c = 'a' // lldb-command:print i8 -// lldb-check:[...]$2 = 'D' +// lldbg-check:[...]$2 = 'D' +// lldbr-check:(i8) i8 = 68 // lldb-command:print i16 -// lldb-check:[...]$3 = -16 +// lldbg-check:[...]$3 = -16 +// lldbr-check:(i16) i16 = -16 // lldb-command:print i32 -// lldb-check:[...]$4 = -32 +// lldbg-check:[...]$4 = -32 +// lldbr-check:(i32) i32 = -32 // lldb-command:print i64 -// lldb-check:[...]$5 = -64 +// lldbg-check:[...]$5 = -64 +// lldbr-check:(i64) i64 = -64 // lldb-command:print u -// lldb-check:[...]$6 = 1 +// lldbg-check:[...]$6 = 1 +// lldbr-check:(usize) u = 1 // lldb-command:print u8 -// lldb-check:[...]$7 = 'd' +// lldbg-check:[...]$7 = 'd' +// lldbr-check:(u8) u8 = 100 // lldb-command:print u16 -// lldb-check:[...]$8 = 16 +// lldbg-check:[...]$8 = 16 +// lldbr-check:(u16) u16 = 16 // lldb-command:print u32 -// lldb-check:[...]$9 = 32 +// lldbg-check:[...]$9 = 32 +// lldbr-check:(u32) u32 = 32 // lldb-command:print u64 -// lldb-check:[...]$10 = 64 +// lldbg-check:[...]$10 = 64 +// lldbr-check:(u64) u64 = 64 // lldb-command:print f32 -// lldb-check:[...]$11 = 2.5 +// lldbg-check:[...]$11 = 2.5 +// lldbr-check:(f32) f32 = 2.5 // lldb-command:print f64 -// lldb-check:[...]$12 = 3.5 +// lldbg-check:[...]$12 = 3.5 +// lldbr-check:(f64) f64 = 3.5 #![allow(unused_variables)] #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/borrowed-basic.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/borrowed-basic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/borrowed-basic.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/borrowed-basic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -68,47 +68,60 @@ // lldb-command:run // lldb-command:print *bool_ref -// lldb-check:[...]$0 = true +// lldbg-check:[...]$0 = true +// lldbr-check:(bool) *bool_ref = true // lldb-command:print *int_ref -// lldb-check:[...]$1 = -1 +// lldbg-check:[...]$1 = -1 +// lldbr-check:(isize) *int_ref = -1 -// NOTE: lldb doesn't support 32bit chars at the moment -// d ebugger:print *char_ref -// c heck:[...]$x = 97 +// NOTE: only rust-enabled lldb supports 32bit chars +// lldbr-command:print *char_ref +// lldbr-check:(char) *char_ref = 'a' // lldb-command:print *i8_ref -// lldb-check:[...]$2 = 'D' +// lldbg-check:[...]$2 = 'D' +// lldbr-check:(i8) *i8_ref = 68 // lldb-command:print *i16_ref -// lldb-check:[...]$3 = -16 +// lldbg-check:[...]$3 = -16 +// lldbr-check:(i16) *i16_ref = -16 // lldb-command:print *i32_ref -// lldb-check:[...]$4 = -32 +// lldbg-check:[...]$4 = -32 +// lldbr-check:(i32) *i32_ref = -32 // lldb-command:print *i64_ref -// lldb-check:[...]$5 = -64 +// lldbg-check:[...]$5 = -64 +// lldbr-check:(i64) *i64_ref = -64 // lldb-command:print *uint_ref -// lldb-check:[...]$6 = 1 +// lldbg-check:[...]$6 = 1 +// lldbr-check:(usize) *uint_ref = 1 // lldb-command:print *u8_ref -// lldb-check:[...]$7 = 'd' +// lldbg-check:[...]$7 = 'd' +// lldbr-check:(u8) *u8_ref = 100 // lldb-command:print *u16_ref -// lldb-check:[...]$8 = 16 +// lldbg-check:[...]$8 = 16 +// lldbr-check:(u16) *u16_ref = 16 // lldb-command:print *u32_ref -// lldb-check:[...]$9 = 32 +// lldbg-check:[...]$9 = 32 +// lldbr-check:(u32) *u32_ref = 32 // lldb-command:print *u64_ref -// lldb-check:[...]$10 = 64 +// lldbg-check:[...]$10 = 64 +// lldbr-check:(u64) *u64_ref = 64 // lldb-command:print *f32_ref -// lldb-check:[...]$11 = 2.5 +// lldbg-check:[...]$11 = 2.5 +// lldbr-check:(f32) *f32_ref = 2.5 // lldb-command:print *f64_ref -// lldb-check:[...]$12 = 3.5 +// lldbg-check:[...]$12 = 3.5 +// lldbr-check:(f64) *f64_ref = 3.5 #![allow(unused_variables)] #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/borrowed-c-style-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/borrowed-c-style-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/borrowed-c-style-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/borrowed-c-style-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -34,13 +34,16 @@ // lldb-command:run // lldb-command:print *the_a_ref -// lldb-check:[...]$0 = TheA +// lldbg-check:[...]$0 = TheA +// lldbr-check:(borrowed_c_style_enum::ABC) *the_a_ref = borrowed_c_style_enum::ABC::TheA // lldb-command:print *the_b_ref -// lldb-check:[...]$1 = TheB +// lldbg-check:[...]$1 = TheB +// lldbr-check:(borrowed_c_style_enum::ABC) *the_b_ref = borrowed_c_style_enum::ABC::TheB // lldb-command:print *the_c_ref -// lldb-check:[...]$2 = TheC +// lldbg-check:[...]$2 = TheC +// lldbr-check:(borrowed_c_style_enum::ABC) *the_c_ref = borrowed_c_style_enum::ABC::TheC #![allow(unused_variables)] #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/borrowed-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/borrowed-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/borrowed-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/borrowed-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -36,11 +36,14 @@ // lldb-command:run // lldb-command:print *the_a_ref -// lldb-check:[...]$0 = TheA { x: 0, y: 8970181431921507452 } +// lldbg-check:[...]$0 = TheA { x: 0, y: 8970181431921507452 } +// lldbr-check:(borrowed_enum::ABC::TheA) *the_a_ref = TheA { borrowed_enum::ABC::TheA: 0, borrowed_enum::ABC::TheB: 8970181431921507452 } // lldb-command:print *the_b_ref -// lldb-check:[...]$1 = TheB(0, 286331153, 286331153) +// lldbg-check:[...]$1 = TheB(0, 286331153, 286331153) +// lldbr-check:(borrowed_enum::ABC::TheB) *the_b_ref = { = 0 = 286331153 = 286331153 } // lldb-command:print *univariant_ref -// lldb-check:[...]$2 = TheOnlyCase(4820353753753434) +// lldbg-check:[...]$2 = TheOnlyCase(4820353753753434) +// lldbr-check:(borrowed_enum::Univariant) *univariant_ref = { borrowed_enum::TheOnlyCase = { = 4820353753753434 } } #![allow(unused_variables)] #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/borrowed-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/borrowed-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/borrowed-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/borrowed-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -45,25 +45,32 @@ // lldb-command:run // lldb-command:print *stack_val_ref -// lldb-check:[...]$0 = SomeStruct { x: 10, y: 23.5 } +// lldbg-check:[...]$0 = SomeStruct { x: 10, y: 23.5 } +// lldbr-check:(borrowed_struct::SomeStruct) *stack_val_ref = SomeStruct { x: 10, y: 23.5 } // lldb-command:print *stack_val_interior_ref_1 -// lldb-check:[...]$1 = 10 +// lldbg-check:[...]$1 = 10 +// lldbr-check:(isize) *stack_val_interior_ref_1 = 10 // lldb-command:print *stack_val_interior_ref_2 -// lldb-check:[...]$2 = 23.5 +// lldbg-check:[...]$2 = 23.5 +// lldbr-check:(f64) *stack_val_interior_ref_2 = 23.5 // lldb-command:print *ref_to_unnamed -// lldb-check:[...]$3 = SomeStruct { x: 11, y: 24.5 } +// lldbg-check:[...]$3 = SomeStruct { x: 11, y: 24.5 } +// lldbr-check:(borrowed_struct::SomeStruct) *ref_to_unnamed = SomeStruct { x: 11, y: 24.5 } // lldb-command:print *unique_val_ref -// lldb-check:[...]$4 = SomeStruct { x: 13, y: 26.5 } +// lldbg-check:[...]$4 = SomeStruct { x: 13, y: 26.5 } +// lldbr-check:(borrowed_struct::SomeStruct) *unique_val_ref = SomeStruct { x: 13, y: 26.5 } // lldb-command:print *unique_val_interior_ref_1 -// lldb-check:[...]$5 = 13 +// lldbg-check:[...]$5 = 13 +// lldbr-check:(isize) *unique_val_interior_ref_1 = 13 // lldb-command:print *unique_val_interior_ref_2 -// lldb-check:[...]$6 = 26.5 +// lldbg-check:[...]$6 = 26.5 +// lldbr-check:(f64) *unique_val_interior_ref_2 = 26.5 #![allow(unused_variables)] #![feature(box_syntax)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/borrowed-tuple.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/borrowed-tuple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/borrowed-tuple.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/borrowed-tuple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -34,13 +34,16 @@ // lldb-command:run // lldb-command:print *stack_val_ref -// lldb-check:[...]$0 = (-14, -19) +// lldbg-check:[...]$0 = (-14, -19) +// lldbr-check:((i16, f32)) *stack_val_ref = { = -14 = -19 } // lldb-command:print *ref_to_unnamed -// lldb-check:[...]$1 = (-15, -20) +// lldbg-check:[...]$1 = (-15, -20) +// lldbr-check:((i16, f32)) *ref_to_unnamed = { = -15 = -20 } // lldb-command:print *unique_val_ref -// lldb-check:[...]$2 = (-17, -22) +// lldbg-check:[...]$2 = (-17, -22) +// lldbr-check:((i16, f32)) *unique_val_ref = { = -17 = -22 } #![allow(unused_variables)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/borrowed-unique-basic.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/borrowed-unique-basic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/borrowed-unique-basic.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/borrowed-unique-basic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -70,46 +70,60 @@ // lldb-command:run // lldb-command:print *bool_ref -// lldb-check:[...]$0 = true +// lldbg-check:[...]$0 = true +// lldbr-check:(bool) *bool_ref = true // lldb-command:print *int_ref -// lldb-check:[...]$1 = -1 +// lldbg-check:[...]$1 = -1 +// lldbr-check:(isize) *int_ref = -1 -// d ebugger:print *char_ref -// c heck:[...]$3 = 97 +// NOTE: only rust-enabled lldb supports 32bit chars +// lldbr-command:print *char_ref +// lldbr-check:(char) *char_ref = 97 // lldb-command:print *i8_ref -// lldb-check:[...]$2 = 68 +// lldbg-check:[...]$2 = 68 +// lldbr-check:(i8) *i8_ref = 68 // lldb-command:print *i16_ref -// lldb-check:[...]$3 = -16 +// lldbg-check:[...]$3 = -16 +// lldbr-check:(i16) *i16_ref = -16 // lldb-command:print *i32_ref -// lldb-check:[...]$4 = -32 +// lldbg-check:[...]$4 = -32 +// lldbr-check:(i32) *i32_ref = -32 // lldb-command:print *i64_ref -// lldb-check:[...]$5 = -64 +// lldbg-check:[...]$5 = -64 +// lldbr-check:(i64) *i64_ref = -64 // lldb-command:print *uint_ref -// lldb-check:[...]$6 = 1 +// lldbg-check:[...]$6 = 1 +// lldbr-check:(usize) *uint_ref = 1 // lldb-command:print *u8_ref -// lldb-check:[...]$7 = 100 +// lldbg-check:[...]$7 = 100 +// lldbr-check:(u8) *u8_ref = 100 // lldb-command:print *u16_ref -// lldb-check:[...]$8 = 16 +// lldbg-check:[...]$8 = 16 +// lldbr-check:(u16) *u16_ref = 16 // lldb-command:print *u32_ref -// lldb-check:[...]$9 = 32 +// lldbg-check:[...]$9 = 32 +// lldbr-check:(u32) *u32_ref = 32 // lldb-command:print *u64_ref -// lldb-check:[...]$10 = 64 +// lldbg-check:[...]$10 = 64 +// lldbr-check:(u64) *u64_ref = 64 // lldb-command:print *f32_ref -// lldb-check:[...]$11 = 2.5 +// lldbg-check:[...]$11 = 2.5 +// lldbr-check:(f32) *f32_ref = 2.5 // lldb-command:print *f64_ref -// lldb-check:[...]$12 = 3.5 +// lldbg-check:[...]$12 = 3.5 +// lldbr-check:(f64) *f64_ref = 3.5 #![allow(unused_variables)] #![feature(box_syntax)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/boxed-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/boxed-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/boxed-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/boxed-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-tidy-linelength + // min-lldb-version: 310 // compile-flags:-g @@ -30,10 +32,12 @@ // lldb-command:run // lldb-command:print *unique -// lldb-check:[...]$0 = StructWithSomePadding { x: 99, y: 999, z: 9999, w: 99999 } +// lldbg-check:[...]$0 = StructWithSomePadding { x: 99, y: 999, z: 9999, w: 99999 } +// lldbr-check:(boxed_struct::StructWithSomePadding) *unique = StructWithSomePadding { x: 99, y: 999, z: 9999, w: 99999 } // lldb-command:print *unique_dtor -// lldb-check:[...]$1 = StructWithDestructor { x: 77, y: 777, z: 7777, w: 77777 } +// lldbg-check:[...]$1 = StructWithDestructor { x: 77, y: 777, z: 7777, w: 77777 } +// lldbr-check:(boxed_struct::StructWithDestructor) *unique_dtor = StructWithDestructor { x: 77, y: 777, z: 7777, w: 77777 } #![allow(unused_variables)] #![feature(box_syntax)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/box.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/box.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/box.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/box.rs 2018-12-04 23:41:40.000000000 +0000 @@ -27,9 +27,11 @@ // lldb-command:run // lldb-command:print *a -// lldb-check:[...]$0 = 1 +// lldbg-check:[...]$0 = 1 +// lldbr-check:(i32) *a = 1 // lldb-command:print *b -// lldb-check:[...]$1 = (2, 3.5) +// lldbg-check:[...]$1 = (2, 3.5) +// lldbr-check:((i32, f64)) *b = { = 2 = 3.5 } #![allow(unused_variables)] #![feature(box_syntax)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/by-value-self-argument-in-trait-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/by-value-self-argument-in-trait-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/by-value-self-argument-in-trait-impl.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/by-value-self-argument-in-trait-impl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -36,15 +36,18 @@ // lldb-command:run // lldb-command:print self -// lldb-check:[...]$0 = 1111 +// lldbg-check:[...]$0 = 1111 +// lldbr-check:(isize) self = 1111 // lldb-command:continue // lldb-command:print self -// lldb-check:[...]$1 = Struct { x: 2222, y: 3333 } +// lldbg-check:[...]$1 = Struct { x: 2222, y: 3333 } +// lldbr-check:(by_value_self_argument_in_trait_impl::Struct) self = Struct { x: 2222, y: 3333 } // lldb-command:continue // lldb-command:print self -// lldb-check:[...]$2 = (4444.5, 5555, 6666, 7777.5) +// lldbg-check:[...]$2 = (4444.5, 5555, 6666, 7777.5) +// lldbr-check:((f64, isize, isize, f64)) self = { = 4444.5 = 5555 = 6666 = 7777.5 } // lldb-command:continue #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/closure-in-generic-function.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/closure-in-generic-function.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/closure-in-generic-function.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/closure-in-generic-function.rs 2018-12-04 23:41:40.000000000 +0000 @@ -34,15 +34,19 @@ // lldb-command:run // lldb-command:print x -// lldb-check:[...]$0 = 0.5 +// lldbg-check:[...]$0 = 0.5 +// lldbr-check:(f64) x = 0.5 // lldb-command:print y -// lldb-check:[...]$1 = 10 +// lldbg-check:[...]$1 = 10 +// lldbr-check:(i32) y = 10 // lldb-command:continue // lldb-command:print *x -// lldb-check:[...]$2 = 29 +// lldbg-check:[...]$2 = 29 +// lldbr-check:(i32) *x = 29 // lldb-command:print *y -// lldb-check:[...]$3 = 110 +// lldbg-check:[...]$3 = 110 +// lldbr-check:(i32) *y = 110 // lldb-command:continue #![feature(box_syntax)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/cross-crate-spans.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/cross-crate-spans.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/cross-crate-spans.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/cross-crate-spans.rs 2018-12-04 23:41:40.000000000 +0000 @@ -50,19 +50,25 @@ // lldb-command:run // lldb-command:print result -// lldb-check:[...]$0 = (17, 17) +// lldbg-check:[...]$0 = (17, 17) +// lldbr-check:((u32, u32)) result = { = 17 = 17 } // lldb-command:print a_variable -// lldb-check:[...]$1 = 123456789 +// lldbg-check:[...]$1 = 123456789 +// lldbr-check:(u32) a_variable = 123456789 // lldb-command:print another_variable -// lldb-check:[...]$2 = 123456789.5 +// lldbg-check:[...]$2 = 123456789.5 +// lldbr-check:(f64) another_variable = 123456789.5 // lldb-command:continue // lldb-command:print result -// lldb-check:[...]$3 = (1212, 1212) +// lldbg-check:[...]$3 = (1212, 1212) +// lldbr-check:((i16, i16)) result = { = 1212 = 1212 } // lldb-command:print a_variable -// lldb-check:[...]$4 = 123456789 +// lldbg-check:[...]$4 = 123456789 +// lldbr-check:(u32) a_variable = 123456789 // lldb-command:print another_variable -// lldb-check:[...]$5 = 123456789.5 +// lldbg-check:[...]$5 = 123456789.5 +// lldbr-check:(f64) another_variable = 123456789.5 // lldb-command:continue diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/c-style-enum-in-composite.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/c-style-enum-in-composite.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/c-style-enum-in-composite.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/c-style-enum-in-composite.rs 2018-12-04 23:41:40.000000000 +0000 @@ -50,24 +50,31 @@ // lldb-command:run // lldb-command:print tuple_interior_padding -// lldb-check:[...]$0 = (0, OneHundred) +// lldbg-check:[...]$0 = (0, OneHundred) +// lldbr-check:((i16, c_style_enum_in_composite::AnEnum)) tuple_interior_padding = { = 0 = c_style_enum_in_composite::AnEnum::OneHundred } // lldb-command:print tuple_padding_at_end -// lldb-check:[...]$1 = ((1, OneThousand), 2) +// lldbg-check:[...]$1 = ((1, OneThousand), 2) +// lldbr-check:(((u64, c_style_enum_in_composite::AnEnum), u64)) tuple_padding_at_end = { = { = 1 = c_style_enum_in_composite::AnEnum::OneThousand } = 2 } // lldb-command:print tuple_different_enums -// lldb-check:[...]$2 = (OneThousand, MountainView, OneMillion, Vienna) +// lldbg-check:[...]$2 = (OneThousand, MountainView, OneMillion, Vienna) +// lldbr-check:((c_style_enum_in_composite::AnEnum, c_style_enum_in_composite::AnotherEnum, c_style_enum_in_composite::AnEnum, c_style_enum_in_composite::AnotherEnum)) tuple_different_enums = { = c_style_enum_in_composite::AnEnum::OneThousand = c_style_enum_in_composite::AnotherEnum::MountainView = c_style_enum_in_composite::AnEnum::OneMillion = c_style_enum_in_composite::AnotherEnum::Vienna } // lldb-command:print padded_struct -// lldb-check:[...]$3 = PaddedStruct { a: 3, b: OneMillion, c: 4, d: Toronto, e: 5 } +// lldbg-check:[...]$3 = PaddedStruct { a: 3, b: OneMillion, c: 4, d: Toronto, e: 5 } +// lldbr-check:(c_style_enum_in_composite::PaddedStruct) padded_struct = PaddedStruct { a: 3, b: c_style_enum_in_composite::AnEnum::OneMillion, c: 4, d: c_style_enum_in_composite::AnotherEnum::Toronto, e: 5 } // lldb-command:print packed_struct -// lldb-check:[...]$4 = PackedStruct { a: 6, b: OneHundred, c: 7, d: Vienna, e: 8 } +// lldbg-check:[...]$4 = PackedStruct { a: 6, b: OneHundred, c: 7, d: Vienna, e: 8 } +// lldbr-check:(c_style_enum_in_composite::PackedStruct) packed_struct = PackedStruct { a: 6, b: c_style_enum_in_composite::AnEnum::OneHundred, c: 7, d: c_style_enum_in_composite::AnotherEnum::Vienna, e: 8 } // lldb-command:print non_padded_struct -// lldb-check:[...]$5 = NonPaddedStruct { a: OneMillion, b: MountainView, c: OneThousand, d: Toronto } +// lldbg-check:[...]$5 = NonPaddedStruct { a: OneMillion, b: MountainView, c: OneThousand, d: Toronto } +// lldbr-check:(c_style_enum_in_composite::NonPaddedStruct) non_padded_struct = NonPaddedStruct { a: c_style_enum_in_composite::AnEnum::OneMillion, b: c_style_enum_in_composite::AnotherEnum::MountainView, c: c_style_enum_in_composite::AnEnum::OneThousand, d: c_style_enum_in_composite::AnotherEnum::Toronto } // lldb-command:print struct_with_drop -// lldb-check:[...]$6 = (StructWithDrop { a: OneHundred, b: Vienna }, 9) +// lldbg-check:[...]$6 = (StructWithDrop { a: OneHundred, b: Vienna }, 9) +// lldbr-check:((c_style_enum_in_composite::StructWithDrop, i64)) struct_with_drop = { = StructWithDrop { a: c_style_enum_in_composite::AnEnum::OneHundred, b: c_style_enum_in_composite::AnotherEnum::Vienna } = 9 } #![allow(unused_variables)] #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/c-style-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/c-style-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/c-style-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/c-style-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-tidy-linelength + // ignore-aarch64 // ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // min-lldb-version: 310 @@ -107,25 +109,32 @@ // lldb-command:run // lldb-command:print auto_one -// lldb-check:[...]$0 = One +// lldbg-check:[...]$0 = One +// lldbr-check:(c_style_enum::AutoDiscriminant) auto_one = c_style_enum::AutoDiscriminant::One // lldb-command:print auto_two -// lldb-check:[...]$1 = Two +// lldbg-check:[...]$1 = Two +// lldbr-check:(c_style_enum::AutoDiscriminant) auto_two = c_style_enum::AutoDiscriminant::Two // lldb-command:print auto_three -// lldb-check:[...]$2 = Three +// lldbg-check:[...]$2 = Three +// lldbr-check:(c_style_enum::AutoDiscriminant) auto_three = c_style_enum::AutoDiscriminant::Three // lldb-command:print manual_one_hundred -// lldb-check:[...]$3 = OneHundred +// lldbg-check:[...]$3 = OneHundred +// lldbr-check:(c_style_enum::ManualDiscriminant) manual_one_hundred = c_style_enum::ManualDiscriminant::OneHundred // lldb-command:print manual_one_thousand -// lldb-check:[...]$4 = OneThousand +// lldbg-check:[...]$4 = OneThousand +// lldbr-check:(c_style_enum::ManualDiscriminant) manual_one_thousand = c_style_enum::ManualDiscriminant::OneThousand // lldb-command:print manual_one_million -// lldb-check:[...]$5 = OneMillion +// lldbg-check:[...]$5 = OneMillion +// lldbr-check:(c_style_enum::ManualDiscriminant) manual_one_million = c_style_enum::ManualDiscriminant::OneMillion // lldb-command:print single_variant -// lldb-check:[...]$6 = TheOnlyVariant +// lldbg-check:[...]$6 = TheOnlyVariant +// lldbr-check:(c_style_enum::SingleVariant) single_variant = c_style_enum::SingleVariant::TheOnlyVariant #![allow(unused_variables)] #![allow(dead_code)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/destructured-fn-argument.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/destructured-fn-argument.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/destructured-fn-argument.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/destructured-fn-argument.rs 2018-12-04 23:41:40.000000000 +0000 @@ -174,147 +174,196 @@ // lldb-command:run // lldb-command:print a -// lldb-check:[...]$0 = 1 +// lldbg-check:[...]$0 = 1 +// lldbr-check:(isize) a = 1 // lldb-command:print b -// lldb-check:[...]$1 = false +// lldbg-check:[...]$1 = false +// lldbr-check:(bool) b = false // lldb-command:continue // lldb-command:print a -// lldb-check:[...]$2 = 2 +// lldbg-check:[...]$2 = 2 +// lldbr-check:(isize) a = 2 // lldb-command:print b -// lldb-check:[...]$3 = 3 +// lldbg-check:[...]$3 = 3 +// lldbr-check:(u16) b = 3 // lldb-command:print c -// lldb-check:[...]$4 = 4 +// lldbg-check:[...]$4 = 4 +// lldbr-check:(u16) c = 4 // lldb-command:continue // lldb-command:print a -// lldb-check:[...]$5 = 5 +// lldbg-check:[...]$5 = 5 +// lldbr-check:(isize) a = 5 // lldb-command:print b -// lldb-check:[...]$6 = (6, 7) +// lldbg-check:[...]$6 = (6, 7) +// lldbr-check:((u32, u32)) b = { = 6 = 7 } // lldb-command:continue // lldb-command:print h -// lldb-check:[...]$7 = 8 +// lldbg-check:[...]$7 = 8 +// lldbr-check:(i16) h = 8 // lldb-command:print i -// lldb-check:[...]$8 = Struct { a: 9, b: 10 } +// lldbg-check:[...]$8 = Struct { a: 9, b: 10 } +// lldbr-check:(destructured_fn_argument::Struct) i = Struct { a: 9, b: 10 } // lldb-command:print j -// lldb-check:[...]$9 = 11 +// lldbg-check:[...]$9 = 11 +// lldbr-check:(i16) j = 11 // lldb-command:continue // lldb-command:print k -// lldb-check:[...]$10 = 12 +// lldbg-check:[...]$10 = 12 +// lldbr-check:(i64) k = 12 // lldb-command:print l -// lldb-check:[...]$11 = 13 +// lldbg-check:[...]$11 = 13 +// lldbr-check:(i32) l = 13 // lldb-command:continue // lldb-command:print m -// lldb-check:[...]$12 = 14 +// lldbg-check:[...]$12 = 14 +// lldbr-check:(isize) m = 14 // lldb-command:print n -// lldb-check:[...]$13 = 16 +// lldbg-check:[...]$13 = 16 +// lldbr-check:(i32) n = 16 // lldb-command:continue // lldb-command:print o -// lldb-check:[...]$14 = 18 +// lldbg-check:[...]$14 = 18 +// lldbr-check:(i32) o = 18 // lldb-command:continue // lldb-command:print p -// lldb-check:[...]$15 = 19 +// lldbg-check:[...]$15 = 19 +// lldbr-check:(i64) p = 19 // lldb-command:print q -// lldb-check:[...]$16 = 20 +// lldbg-check:[...]$16 = 20 +// lldbr-check:(i32) q = 20 // lldb-command:print r -// lldb-check:[...]$17 = Struct { a: 21, b: 22 } +// lldbg-check:[...]$17 = Struct { a: 21, b: 22 } +// lldbr-check:(destructured_fn_argument::Struct) r = Struct { a: 21, b: 22 } // lldb-command:continue // lldb-command:print s -// lldb-check:[...]$18 = 24 +// lldbg-check:[...]$18 = 24 +// lldbr-check:(i32) s = 24 // lldb-command:print t -// lldb-check:[...]$19 = 23 +// lldbg-check:[...]$19 = 23 +// lldbr-check:(i64) t = 23 // lldb-command:continue // lldb-command:print u -// lldb-check:[...]$20 = 25 +// lldbg-check:[...]$20 = 25 +// lldbr-check:(i16) u = 25 // lldb-command:print v -// lldb-check:[...]$21 = 26 +// lldbg-check:[...]$21 = 26 +// lldbr-check:(i32) v = 26 // lldb-command:print w -// lldb-check:[...]$22 = 27 +// lldbg-check:[...]$22 = 27 +// lldbr-check:(i64) w = 27 // lldb-command:print x -// lldb-check:[...]$23 = 28 +// lldbg-check:[...]$23 = 28 +// lldbr-check:(i32) x = 28 // lldb-command:print y -// lldb-check:[...]$24 = 29 +// lldbg-check:[...]$24 = 29 +// lldbr-check:(i64) y = 29 // lldb-command:print z -// lldb-check:[...]$25 = 30 +// lldbg-check:[...]$25 = 30 +// lldbr-check:(i32) z = 30 // lldb-command:print ae -// lldb-check:[...]$26 = 31 +// lldbg-check:[...]$26 = 31 +// lldbr-check:(i64) ae = 31 // lldb-command:print oe -// lldb-check:[...]$27 = 32 +// lldbg-check:[...]$27 = 32 +// lldbr-check:(i32) oe = 32 // lldb-command:print ue -// lldb-check:[...]$28 = 33 +// lldbg-check:[...]$28 = 33 +// lldbr-check:(u16) ue = 33 // lldb-command:continue // lldb-command:print aa -// lldb-check:[...]$29 = (34, 35) +// lldbg-check:[...]$29 = (34, 35) +// lldbr-check:((isize, isize)) aa = { = 34 = 35 } // lldb-command:continue // lldb-command:print bb -// lldb-check:[...]$30 = (36, 37) +// lldbg-check:[...]$30 = (36, 37) +// lldbr-check:((isize, isize)) bb = { = 36 = 37 } // lldb-command:continue // lldb-command:print cc -// lldb-check:[...]$31 = 38 +// lldbg-check:[...]$31 = 38 +// lldbr-check:(isize) cc = 38 // lldb-command:continue // lldb-command:print dd -// lldb-check:[...]$32 = (40, 41, 42) +// lldbg-check:[...]$32 = (40, 41, 42) +// lldbr-check:((isize, isize, isize)) dd = { = 40 = 41 = 42 } // lldb-command:continue // lldb-command:print *ee -// lldb-check:[...]$33 = (43, 44, 45) +// lldbg-check:[...]$33 = (43, 44, 45) +// lldbr-check:((isize, isize, isize)) *ee = { = 43 = 44 = 45 } // lldb-command:continue // lldb-command:print *ff -// lldb-check:[...]$34 = 46 +// lldbg-check:[...]$34 = 46 +// lldbr-check:(isize) *ff = 46 // lldb-command:print gg -// lldb-check:[...]$35 = (47, 48) +// lldbg-check:[...]$35 = (47, 48) +// lldbr-check:((isize, isize)) gg = { = 47 = 48 } // lldb-command:continue // lldb-command:print *hh -// lldb-check:[...]$36 = 50 +// lldbg-check:[...]$36 = 50 +// lldbr-check:(i32) *hh = 50 // lldb-command:continue // lldb-command:print ii -// lldb-check:[...]$37 = 51 +// lldbg-check:[...]$37 = 51 +// lldbr-check:(i32) ii = 51 // lldb-command:continue // lldb-command:print *jj -// lldb-check:[...]$38 = 52 +// lldbg-check:[...]$38 = 52 +// lldbr-check:(i32) *jj = 52 // lldb-command:continue // lldb-command:print kk -// lldb-check:[...]$39 = 53 +// lldbg-check:[...]$39 = 53 +// lldbr-check:(f64) kk = 53 // lldb-command:print ll -// lldb-check:[...]$40 = 54 +// lldbg-check:[...]$40 = 54 +// lldbr-check:(isize) ll = 54 // lldb-command:continue // lldb-command:print mm -// lldb-check:[...]$41 = 55 +// lldbg-check:[...]$41 = 55 +// lldbr-check:(f64) mm = 55 // lldb-command:print *nn -// lldb-check:[...]$42 = 56 +// lldbg-check:[...]$42 = 56 +// lldbr-check:(isize) *nn = 56 // lldb-command:continue // lldb-command:print oo -// lldb-check:[...]$43 = 57 +// lldbg-check:[...]$43 = 57 +// lldbr-check:(isize) oo = 57 // lldb-command:print pp -// lldb-check:[...]$44 = 58 +// lldbg-check:[...]$44 = 58 +// lldbr-check:(isize) pp = 58 // lldb-command:print qq -// lldb-check:[...]$45 = 59 +// lldbg-check:[...]$45 = 59 +// lldbr-check:(isize) qq = 59 // lldb-command:continue // lldb-command:print rr -// lldb-check:[...]$46 = 60 +// lldbg-check:[...]$46 = 60 +// lldbr-check:(isize) rr = 60 // lldb-command:print ss -// lldb-check:[...]$47 = 61 +// lldbg-check:[...]$47 = 61 +// lldbr-check:(isize) ss = 61 // lldb-command:print tt -// lldb-check:[...]$48 = 62 +// lldbg-check:[...]$48 = 62 +// lldbr-check:(isize) tt = 62 // lldb-command:continue #![allow(unused_variables)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/destructured-for-loop-variable.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/destructured-for-loop-variable.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/destructured-for-loop-variable.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/destructured-for-loop-variable.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-tidy-linelength + // min-lldb-version: 310 // compile-flags:-g @@ -91,66 +93,90 @@ // DESTRUCTURED STRUCT // lldb-command:print x -// lldb-check:[...]$0 = 400 +// lldbg-check:[...]$0 = 400 +// lldbr-check:(i16) x = 400 // lldb-command:print y -// lldb-check:[...]$1 = 401.5 +// lldbg-check:[...]$1 = 401.5 +// lldbr-check:(f32) y = 401.5 // lldb-command:print z -// lldb-check:[...]$2 = true +// lldbg-check:[...]$2 = true +// lldbr-check:(bool) z = true // lldb-command:continue // DESTRUCTURED TUPLE // lldb-command:print _i8 -// lldb-check:[...]$3 = 0x6f +// lldbg-check:[...]$3 = 0x6f +// lldbr-check:(i8) _i8 = 111 // lldb-command:print _u8 -// lldb-check:[...]$4 = 0x70 +// lldbg-check:[...]$4 = 0x70 +// lldbr-check:(u8) _u8 = 112 // lldb-command:print _i16 -// lldb-check:[...]$5 = -113 +// lldbg-check:[...]$5 = -113 +// lldbr-check:(i16) _i16 = -113 // lldb-command:print _u16 -// lldb-check:[...]$6 = 114 +// lldbg-check:[...]$6 = 114 +// lldbr-check:(u16) _u16 = 114 // lldb-command:print _i32 -// lldb-check:[...]$7 = -115 +// lldbg-check:[...]$7 = -115 +// lldbr-check:(i32) _i32 = -115 // lldb-command:print _u32 -// lldb-check:[...]$8 = 116 +// lldbg-check:[...]$8 = 116 +// lldbr-check:(u32) _u32 = 116 // lldb-command:print _i64 -// lldb-check:[...]$9 = -117 +// lldbg-check:[...]$9 = -117 +// lldbr-check:(i64) _i64 = -117 // lldb-command:print _u64 -// lldb-check:[...]$10 = 118 +// lldbg-check:[...]$10 = 118 +// lldbr-check:(u64) _u64 = 118 // lldb-command:print _f32 -// lldb-check:[...]$11 = 119.5 +// lldbg-check:[...]$11 = 119.5 +// lldbr-check:(f32) _f32 = 119.5 // lldb-command:print _f64 -// lldb-check:[...]$12 = 120.5 +// lldbg-check:[...]$12 = 120.5 +// lldbr-check:(f64) _f64 = 120.5 // lldb-command:continue // MORE COMPLEX CASE // lldb-command:print v1 -// lldb-check:[...]$13 = 80000 +// lldbg-check:[...]$13 = 80000 +// lldbr-check:(i32) v1 = 80000 // lldb-command:print x1 -// lldb-check:[...]$14 = 8000 +// lldbg-check:[...]$14 = 8000 +// lldbr-check:(i16) x1 = 8000 // lldb-command:print *y1 -// lldb-check:[...]$15 = 80001.5 +// lldbg-check:[...]$15 = 80001.5 +// lldbr-check:(f32) *y1 = 80001.5 // lldb-command:print z1 -// lldb-check:[...]$16 = false +// lldbg-check:[...]$16 = false +// lldbr-check:(bool) z1 = false // lldb-command:print *x2 -// lldb-check:[...]$17 = -30000 +// lldbg-check:[...]$17 = -30000 +// lldbr-check:(i16) *x2 = -30000 // lldb-command:print y2 -// lldb-check:[...]$18 = -300001.5 +// lldbg-check:[...]$18 = -300001.5 +// lldbr-check:(f32) y2 = -300001.5 // lldb-command:print *z2 -// lldb-check:[...]$19 = true +// lldbg-check:[...]$19 = true +// lldbr-check:(bool) *z2 = true // lldb-command:print v2 -// lldb-check:[...]$20 = 854237.5 +// lldbg-check:[...]$20 = 854237.5 +// lldbr-check:(f64) v2 = 854237.5 // lldb-command:continue // SIMPLE IDENTIFIER // lldb-command:print i -// lldb-check:[...]$21 = 1234 +// lldbg-check:[...]$21 = 1234 +// lldbr-check:(i32) i = 1234 // lldb-command:continue // lldb-command:print simple_struct_ident -// lldb-check:[...]$22 = Struct { x: 3537, y: 35437.5, z: true } +// lldbg-check:[...]$22 = Struct { x: 3537, y: 35437.5, z: true } +// lldbr-check:(destructured_for_loop_variable::Struct) simple_struct_ident = Struct { x: 3537, y: 35437.5, z: true } // lldb-command:continue // lldb-command:print simple_tuple_ident -// lldb-check:[...]$23 = (34903493, 232323) +// lldbg-check:[...]$23 = (34903493, 232323) +// lldbr-check:((u32, i64)) simple_tuple_ident = { = 34903493 = 232323 } // lldb-command:continue #![allow(unused_variables)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/destructured-local.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/destructured-local.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/destructured-local.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/destructured-local.rs 2018-12-04 23:41:40.000000000 +0000 @@ -140,114 +140,157 @@ // lldb-command:run // lldb-command:print a -// lldb-check:[...]$0 = 1 +// lldbg-check:[...]$0 = 1 +// lldbr-check:(isize) a = 1 // lldb-command:print b -// lldb-check:[...]$1 = false +// lldbg-check:[...]$1 = false +// lldbr-check:(bool) b = false // lldb-command:print c -// lldb-check:[...]$2 = 2 +// lldbg-check:[...]$2 = 2 +// lldbr-check:(isize) c = 2 // lldb-command:print d -// lldb-check:[...]$3 = 3 +// lldbg-check:[...]$3 = 3 +// lldbr-check:(u16) d = 3 // lldb-command:print e -// lldb-check:[...]$4 = 4 +// lldbg-check:[...]$4 = 4 +// lldbr-check:(u16) e = 4 // lldb-command:print f -// lldb-check:[...]$5 = 5 +// lldbg-check:[...]$5 = 5 +// lldbr-check:(isize) f = 5 // lldb-command:print g -// lldb-check:[...]$6 = (6, 7) +// lldbg-check:[...]$6 = (6, 7) +// lldbr-check:((u32, u32)) g = { = 6 = 7 } // lldb-command:print h -// lldb-check:[...]$7 = 8 +// lldbg-check:[...]$7 = 8 +// lldbr-check:(i16) h = 8 // lldb-command:print i -// lldb-check:[...]$8 = Struct { a: 9, b: 10 } +// lldbg-check:[...]$8 = Struct { a: 9, b: 10 } +// lldbr-check:(destructured_local::Struct) i = Struct { a: 9, b: 10 } // lldb-command:print j -// lldb-check:[...]$9 = 11 +// lldbg-check:[...]$9 = 11 +// lldbr-check:(i16) j = 11 // lldb-command:print k -// lldb-check:[...]$10 = 12 +// lldbg-check:[...]$10 = 12 +// lldbr-check:(i64) k = 12 // lldb-command:print l -// lldb-check:[...]$11 = 13 +// lldbg-check:[...]$11 = 13 +// lldbr-check:(i32) l = 13 // lldb-command:print m -// lldb-check:[...]$12 = 14 +// lldbg-check:[...]$12 = 14 +// lldbr-check:(i32) m = 14 // lldb-command:print n -// lldb-check:[...]$13 = 16 +// lldbg-check:[...]$13 = 16 +// lldbr-check:(i32) n = 16 // lldb-command:print o -// lldb-check:[...]$14 = 18 +// lldbg-check:[...]$14 = 18 +// lldbr-check:(i32) o = 18 // lldb-command:print p -// lldb-check:[...]$15 = 19 +// lldbg-check:[...]$15 = 19 +// lldbr-check:(i64) p = 19 // lldb-command:print q -// lldb-check:[...]$16 = 20 +// lldbg-check:[...]$16 = 20 +// lldbr-check:(i32) q = 20 // lldb-command:print r -// lldb-check:[...]$17 = Struct { a: 21, b: 22 } +// lldbg-check:[...]$17 = Struct { a: 21, b: 22 } +// lldbr-check:(destructured_local::Struct) r = Struct { a: 21, b: 22 } // lldb-command:print s -// lldb-check:[...]$18 = 24 +// lldbg-check:[...]$18 = 24 +// lldbr-check:(i32) s = 24 // lldb-command:print t -// lldb-check:[...]$19 = 23 +// lldbg-check:[...]$19 = 23 +// lldbr-check:(i64) t = 23 // lldb-command:print u -// lldb-check:[...]$20 = 25 +// lldbg-check:[...]$20 = 25 +// lldbr-check:(i32) u = 25 // lldb-command:print v -// lldb-check:[...]$21 = 26 +// lldbg-check:[...]$21 = 26 +// lldbr-check:(i32) v = 26 // lldb-command:print w -// lldb-check:[...]$22 = 27 +// lldbg-check:[...]$22 = 27 +// lldbr-check:(i32) w = 27 // lldb-command:print x -// lldb-check:[...]$23 = 28 +// lldbg-check:[...]$23 = 28 +// lldbr-check:(i32) x = 28 // lldb-command:print y -// lldb-check:[...]$24 = 29 +// lldbg-check:[...]$24 = 29 +// lldbr-check:(i64) y = 29 // lldb-command:print z -// lldb-check:[...]$25 = 30 +// lldbg-check:[...]$25 = 30 +// lldbr-check:(i32) z = 30 // lldb-command:print ae -// lldb-check:[...]$26 = 31 +// lldbg-check:[...]$26 = 31 +// lldbr-check:(i64) ae = 31 // lldb-command:print oe -// lldb-check:[...]$27 = 32 +// lldbg-check:[...]$27 = 32 +// lldbr-check:(i32) oe = 32 // lldb-command:print ue -// lldb-check:[...]$28 = 33 +// lldbg-check:[...]$28 = 33 +// lldbr-check:(i32) ue = 33 // lldb-command:print aa -// lldb-check:[...]$29 = (34, 35) +// lldbg-check:[...]$29 = (34, 35) +// lldbr-check:((i32, i32)) aa = { = 34 = 35 } // lldb-command:print bb -// lldb-check:[...]$30 = (36, 37) +// lldbg-check:[...]$30 = (36, 37) +// lldbr-check:((i32, i32)) bb = { = 36 = 37 } // lldb-command:print cc -// lldb-check:[...]$31 = 38 +// lldbg-check:[...]$31 = 38 +// lldbr-check:(i32) cc = 38 // lldb-command:print dd -// lldb-check:[...]$32 = (40, 41, 42) +// lldbg-check:[...]$32 = (40, 41, 42) +// lldbr-check:((i32, i32, i32)) dd = { = 40 = 41 = 42 } // lldb-command:print *ee -// lldb-check:[...]$33 = (43, 44, 45) +// lldbg-check:[...]$33 = (43, 44, 45) +// lldbr-check:((i32, i32, i32)) *ee = { = 43 = 44 = 45 } // lldb-command:print *ff -// lldb-check:[...]$34 = 46 +// lldbg-check:[...]$34 = 46 +// lldbr-check:(i32) *ff = 46 // lldb-command:print gg -// lldb-check:[...]$35 = (47, 48) +// lldbg-check:[...]$35 = (47, 48) +// lldbr-check:((i32, i32)) gg = { = 47 = 48 } // lldb-command:print *hh -// lldb-check:[...]$36 = 50 +// lldbg-check:[...]$36 = 50 +// lldbr-check:(i32) *hh = 50 // lldb-command:print ii -// lldb-check:[...]$37 = 51 +// lldbg-check:[...]$37 = 51 +// lldbr-check:(i32) ii = 51 // lldb-command:print *jj -// lldb-check:[...]$38 = 52 +// lldbg-check:[...]$38 = 52 +// lldbr-check:(i32) *jj = 52 // lldb-command:print kk -// lldb-check:[...]$39 = 53 +// lldbg-check:[...]$39 = 53 +// lldbr-check:(f64) kk = 53 // lldb-command:print ll -// lldb-check:[...]$40 = 54 +// lldbg-check:[...]$40 = 54 +// lldbr-check:(isize) ll = 54 // lldb-command:print mm -// lldb-check:[...]$41 = 55 +// lldbg-check:[...]$41 = 55 +// lldbr-check:(f64) mm = 55 // lldb-command:print *nn -// lldb-check:[...]$42 = 56 +// lldbg-check:[...]$42 = 56 +// lldbr-check:(isize) *nn = 56 #![allow(unused_variables)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/evec-in-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/evec-in-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/evec-in-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/evec-in-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-tidy-linelength + // min-lldb-version: 310 // compile-flags:-g @@ -41,18 +43,23 @@ // lldb-command:run // lldb-command:print no_padding1 -// lldb-check:[...]$0 = NoPadding1 { x: [0, 1, 2], y: -3, z: [4.5, 5.5] } +// lldbg-check:[...]$0 = NoPadding1 { x: [0, 1, 2], y: -3, z: [4.5, 5.5] } +// lldbr-check:(evec_in_struct::NoPadding1) no_padding1 = NoPadding1 { x: [0, 1, 2], y: -3, z: [4.5, 5.5] } // lldb-command:print no_padding2 -// lldb-check:[...]$1 = NoPadding2 { x: [6, 7, 8], y: [[9, 10], [11, 12]] } +// lldbg-check:[...]$1 = NoPadding2 { x: [6, 7, 8], y: [[9, 10], [11, 12]] } +// lldbr-check:(evec_in_struct::NoPadding2) no_padding2 = NoPadding2 { x: [6, 7, 8], y: [[9, 10], [11, 12]] } // lldb-command:print struct_internal_padding -// lldb-check:[...]$2 = StructInternalPadding { x: [13, 14], y: [15, 16] } +// lldbg-check:[...]$2 = StructInternalPadding { x: [13, 14], y: [15, 16] } +// lldbr-check:(evec_in_struct::StructInternalPadding) struct_internal_padding = StructInternalPadding { x: [13, 14], y: [15, 16] } // lldb-command:print single_vec -// lldb-check:[...]$3 = SingleVec { x: [17, 18, 19, 20, 21] } +// lldbg-check:[...]$3 = SingleVec { x: [17, 18, 19, 20, 21] } +// lldbr-check:(evec_in_struct::SingleVec) single_vec = SingleVec { x: [17, 18, 19, 20, 21] } // lldb-command:print struct_padded_at_end -// lldb-check:[...]$4 = StructPaddedAtEnd { x: [22, 23], y: [24, 25] } +// lldbg-check:[...]$4 = StructPaddedAtEnd { x: [22, 23], y: [24, 25] } +// lldbr-check:(evec_in_struct::StructPaddedAtEnd) struct_padded_at_end = StructPaddedAtEnd { x: [22, 23], y: [24, 25] } #![allow(unused_variables)] #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/extern-c-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/extern-c-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/extern-c-fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/extern-c-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -33,13 +33,17 @@ // lldb-command:run // lldb-command:print len -// lldb-check:[...]$0 = 20 +// lldbg-check:[...]$0 = 20 +// lldbr-check:(i32) len = 20 // lldb-command:print local0 -// lldb-check:[...]$1 = 19 +// lldbg-check:[...]$1 = 19 +// lldbr-check:(i32) local0 = 19 // lldb-command:print local1 -// lldb-check:[...]$2 = true +// lldbg-check:[...]$2 = true +// lldbr-check:(bool) local1 = true // lldb-command:print local2 -// lldb-check:[...]$3 = 20.5 +// lldbg-check:[...]$3 = 20.5 +// lldbr-check:(f64) local2 = 20.5 // lldb-command:continue diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/function-arguments.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/function-arguments.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/function-arguments.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/function-arguments.rs 2018-12-04 23:41:40.000000000 +0000 @@ -33,15 +33,19 @@ // lldb-command:run // lldb-command:print x -// lldb-check:[...]$0 = 111102 +// lldbg-check:[...]$0 = 111102 +// lldbr-check:(isize) x = 111102 // lldb-command:print y -// lldb-check:[...]$1 = true +// lldbg-check:[...]$1 = true +// lldbr-check:(bool) y = true // lldb-command:continue // lldb-command:print a -// lldb-check:[...]$2 = 2000 +// lldbg-check:[...]$2 = 2000 +// lldbr-check:(i32) a = 2000 // lldb-command:print b -// lldb-check:[...]$3 = 3000 +// lldbg-check:[...]$3 = 3000 +// lldbr-check:(i64) b = 3000 // lldb-command:continue diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/generic-function.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/generic-function.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/generic-function.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/generic-function.rs 2018-12-04 23:41:40.000000000 +0000 @@ -52,27 +52,36 @@ // lldb-command:run // lldb-command:print *t0 -// lldb-check:[...]$0 = 1 +// lldbg-check:[...]$0 = 1 +// lldbr-check:(i32) *t0 = 1 // lldb-command:print *t1 -// lldb-check:[...]$1 = 2.5 +// lldbg-check:[...]$1 = 2.5 +// lldbr-check:(f64) *t1 = 2.5 // lldb-command:print ret -// lldb-check:[...]$2 = ((1, 2.5), (2.5, 1)) +// lldbg-check:[...]$2 = ((1, 2.5), (2.5, 1)) +// lldbr-check:(((i32, f64), (f64, i32))) ret = { = { = 1 = 2.5 } = { = 2.5 = 1 } } // lldb-command:continue // lldb-command:print *t0 -// lldb-check:[...]$3 = 3.5 +// lldbg-check:[...]$3 = 3.5 +// lldbr-check:(f64) *t0 = 3.5 // lldb-command:print *t1 -// lldb-check:[...]$4 = 4 +// lldbg-check:[...]$4 = 4 +// lldbr-check:(u16) *t1 = 4 // lldb-command:print ret -// lldb-check:[...]$5 = ((3.5, 4), (4, 3.5)) +// lldbg-check:[...]$5 = ((3.5, 4), (4, 3.5)) +// lldbr-check:(((f64, u16), (u16, f64))) ret = { = { = 3.5 = 4 } = { = 4 = 3.5 } } // lldb-command:continue // lldb-command:print *t0 -// lldb-check:[...]$6 = 5 +// lldbg-check:[...]$6 = 5 +// lldbr-check:(i32) *t0 = 5 // lldb-command:print *t1 -// lldb-check:[...]$7 = Struct { a: 6, b: 7.5 } +// lldbg-check:[...]$7 = Struct { a: 6, b: 7.5 } +// lldbr-check:(generic_function::Struct) *t1 = Struct { a: 6, b: 7.5 } // lldb-command:print ret -// lldb-check:[...]$8 = ((5, Struct { a: 6, b: 7.5 }), (Struct { a: 6, b: 7.5 }, 5)) +// lldbg-check:[...]$8 = ((5, Struct { a: 6, b: 7.5 }), (Struct { a: 6, b: 7.5 }, 5)) +// lldbr-check:(((i32, generic_function::Struct), (generic_function::Struct, i32))) ret = { = { = 5 = Struct { a: 6, b: 7.5 } } = { = Struct { a: 6, b: 7.5 } = 5 } } // lldb-command:continue #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/generic-functions-nested.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/generic-functions-nested.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/generic-functions-nested.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/generic-functions-nested.rs 2018-12-04 23:41:40.000000000 +0000 @@ -46,27 +46,35 @@ // lldb-command:run // lldb-command:print x -// lldb-check:[...]$0 = -1 +// lldbg-check:[...]$0 = -1 +// lldbr-check:(i32) x = -1 // lldb-command:print y -// lldb-check:[...]$1 = 1 +// lldbg-check:[...]$1 = 1 +// lldbr-check:(i32) y = 1 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$2 = -1 +// lldbg-check:[...]$2 = -1 +// lldbr-check:(i32) x = -1 // lldb-command:print y -// lldb-check:[...]$3 = 2.5 +// lldbg-check:[...]$3 = 2.5 +// lldbr-check:(f64) y = 2.5 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$4 = -2.5 +// lldbg-check:[...]$4 = -2.5 +// lldbr-check:(f64) x = -2.5 // lldb-command:print y -// lldb-check:[...]$5 = 1 +// lldbg-check:[...]$5 = 1 +// lldbr-check:(i32) y = 1 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$6 = -2.5 +// lldbg-check:[...]$6 = -2.5 +// lldbr-check:(f64) x = -2.5 // lldb-command:print y -// lldb-check:[...]$7 = 2.5 +// lldbg-check:[...]$7 = 2.5 +// lldbr-check:(f64) y = 2.5 // lldb-command:continue diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/generic-method-on-generic-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/generic-method-on-generic-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/generic-method-on-generic-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/generic-method-on-generic-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-tidy-linelength // compile-flags:-g // min-lldb-version: 310 @@ -73,47 +74,62 @@ // STACK BY REF // lldb-command:print *self -// lldb-check:[...]$0 = Struct<(u32, i32)> { x: (8888, -8888) } +// lldbg-check:[...]$0 = Struct<(u32, i32)> { x: (8888, -8888) } +// lldbr-check:(generic_method_on_generic_struct::Struct<(u32, i32)>) *self = { x = { = 8888 = -8888 } } // lldb-command:print arg1 -// lldb-check:[...]$1 = -1 +// lldbg-check:[...]$1 = -1 +// lldbr-check:(isize) arg1 = -1 // lldb-command:print arg2 -// lldb-check:[...]$2 = 2 +// lldbg-check:[...]$2 = 2 +// lldbr-check:(u16) arg2 = 2 // lldb-command:continue // STACK BY VAL // lldb-command:print self -// lldb-check:[...]$3 = Struct<(u32, i32)> { x: (8888, -8888) } +// lldbg-check:[...]$3 = Struct<(u32, i32)> { x: (8888, -8888) } +// lldbr-check:(generic_method_on_generic_struct::Struct<(u32, i32)>) self = { x = { = 8888 = -8888 } } // lldb-command:print arg1 -// lldb-check:[...]$4 = -3 +// lldbg-check:[...]$4 = -3 +// lldbr-check:(isize) arg1 = -3 // lldb-command:print arg2 -// lldb-check:[...]$5 = -4 +// lldbg-check:[...]$5 = -4 +// lldbr-check:(i16) arg2 = -4 // lldb-command:continue // OWNED BY REF // lldb-command:print *self -// lldb-check:[...]$6 = Struct { x: 1234.5 } +// lldbg-check:[...]$6 = Struct { x: 1234.5 } +// lldbr-check:(generic_method_on_generic_struct::Struct) *self = Struct { x: 1234.5 } // lldb-command:print arg1 -// lldb-check:[...]$7 = -5 +// lldbg-check:[...]$7 = -5 +// lldbr-check:(isize) arg1 = -5 // lldb-command:print arg2 -// lldb-check:[...]$8 = -6 +// lldbg-check:[...]$8 = -6 +// lldbr-check:(i32) arg2 = -6 // lldb-command:continue // OWNED BY VAL // lldb-command:print self -// lldb-check:[...]$9 = Struct { x: 1234.5 } +// lldbg-check:[...]$9 = Struct { x: 1234.5 } +// lldbr-check:(generic_method_on_generic_struct::Struct) self = Struct { x: 1234.5 } // lldb-command:print arg1 -// lldb-check:[...]$10 = -7 +// lldbg-check:[...]$10 = -7 +// lldbr-check:(isize) arg1 = -7 // lldb-command:print arg2 -// lldb-check:[...]$11 = -8 +// lldbg-check:[...]$11 = -8 +// lldbr-check:(i64) arg2 = -8 // lldb-command:continue // OWNED MOVED // lldb-command:print *self -// lldb-check:[...]$12 = Struct { x: 1234.5 } +// lldbg-check:[...]$12 = Struct { x: 1234.5 } +// lldbr-check:(generic_method_on_generic_struct::Struct) *self = Struct { x: 1234.5 } // lldb-command:print arg1 -// lldb-check:[...]$13 = -9 +// lldbg-check:[...]$13 = -9 +// lldbr-check:(isize) arg1 = -9 // lldb-command:print arg2 -// lldb-check:[...]$14 = -10.5 +// lldbg-check:[...]$14 = -10.5 +// lldbr-check:(f32) arg2 = -10.5 // lldb-command:continue #![feature(box_syntax)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/generic-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/generic-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/generic-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/generic-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -35,14 +35,18 @@ // lldb-command:run // lldb-command:print int_int -// lldb-check:[...]$0 = AGenericStruct { key: 0, value: 1 } +// lldbg-check:[...]$0 = AGenericStruct { key: 0, value: 1 } +// lldbr-check:(generic_struct::AGenericStruct) int_int = AGenericStruct { key: 0, value: 1 } // lldb-command:print int_float -// lldb-check:[...]$1 = AGenericStruct { key: 2, value: 3.5 } +// lldbg-check:[...]$1 = AGenericStruct { key: 2, value: 3.5 } +// lldbr-check:(generic_struct::AGenericStruct) int_float = AGenericStruct { key: 2, value: 3.5 } // lldb-command:print float_int -// lldb-check:[...]$2 = AGenericStruct { key: 4.5, value: 5 } +// lldbg-check:[...]$2 = AGenericStruct { key: 4.5, value: 5 } +// lldbr-check:(generic_struct::AGenericStruct) float_int = AGenericStruct { key: 4.5, value: 5 } // lldb-command:print float_int_float -// lldb-check:[...]$3 = AGenericStruct> { key: 6.5, value: AGenericStruct { key: 7, value: 8.5 } } +// lldbg-check:[...]$3 = AGenericStruct> { key: 6.5, value: AGenericStruct { key: 7, value: 8.5 } } +// lldbr-check:(generic_struct::AGenericStruct>) float_int_float = AGenericStruct> { key: 6.5, value: AGenericStruct { key: 7, value: 8.5 } } #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/generic-tuple-style-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/generic-tuple-style-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/generic-tuple-style-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/generic-tuple-style-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -41,16 +41,20 @@ // lldb-command:run // lldb-command:print case1 -// lldb-check:[...]$0 = Case1(0, 31868, 31868, 31868, 31868) +// lldbg-check:[...]$0 = Case1(0, 31868, 31868, 31868, 31868) +// lldbr-check:(generic_tuple_style_enum::Regular::Case1) case1 = { = 0 = 31868 = 31868 = 31868 = 31868 } // lldb-command:print case2 -// lldb-check:[...]$1 = Case2(0, 286331153, 286331153) +// lldbg-check:[...]$1 = Case2(0, 286331153, 286331153) +// lldbr-check:(generic_tuple_style_enum::Regular::Case2) case2 = Regular::Case2 { generic_tuple_style_enum::Regular::Case1: 0, generic_tuple_style_enum::Regular::Case2: 286331153, generic_tuple_style_enum::Regular::Case3: 286331153 } // lldb-command:print case3 -// lldb-check:[...]$2 = Case3(0, 6438275382588823897) +// lldbg-check:[...]$2 = Case3(0, 6438275382588823897) +// lldbr-check:(generic_tuple_style_enum::Regular::Case3) case3 = Regular::Case3 { generic_tuple_style_enum::Regular::Case1: 0, generic_tuple_style_enum::Regular::Case2: 6438275382588823897 } // lldb-command:print univariant -// lldb-check:[...]$3 = TheOnlyCase(-1) +// lldbg-check:[...]$3 = TheOnlyCase(-1) +// lldbr-check:(generic_tuple_style_enum::Univariant) univariant = { generic_tuple_style_enum::TheOnlyCase = { = -1 } } #![feature(omit_gdb_pretty_printer_section)] #![omit_gdb_pretty_printer_section] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/include_string.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/include_string.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/include_string.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/include_string.rs 2018-12-04 23:41:40.000000000 +0000 @@ -26,11 +26,14 @@ // lldb-command:run // lldb-command:print string1.length -// lldb-check:[...]$0 = 48 +// lldbg-check:[...]$0 = 48 +// lldbr-check:(usize) length = 48 // lldb-command:print string2.length -// lldb-check:[...]$1 = 49 +// lldbg-check:[...]$1 = 49 +// lldbr-check:(usize) length = 49 // lldb-command:print string3.length -// lldb-check:[...]$2 = 50 +// lldbg-check:[...]$2 = 50 +// lldbr-check:(usize) length = 50 // lldb-command:continue diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/issue-22656.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/issue-22656.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/issue-22656.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/issue-22656.rs 2018-12-04 23:41:40.000000000 +0000 @@ -23,10 +23,12 @@ // lldb-command:run // lldb-command:print v -// lldb-check:[...]$0 = vec![1, 2, 3] +// lldbg-check:[...]$0 = vec![1, 2, 3] +// lldbr-check:(alloc::vec::Vec) v = vec![1, 2, 3] // lldb-command:print zs -// lldb-check:[...]$1 = StructWithZeroSizedField { x: ZeroSizedStruct, y: 123, z: ZeroSizedStruct, w: 456 } -// lldb-command:continue +// lldbg-check:[...]$1 = StructWithZeroSizedField { x: ZeroSizedStruct, y: 123, z: ZeroSizedStruct, w: 456 } +// lldbr-check:(issue_22656::StructWithZeroSizedField) zs = StructWithZeroSizedField { x: ZeroSizedStruct { }, y: 123, z: ZeroSizedStruct { }, w: 456 } +// lldbr-command:continue #![allow(unused_variables)] #![allow(dead_code)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-for-loop.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-for-loop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-for-loop.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-for-loop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -55,34 +55,41 @@ // FIRST ITERATION // lldb-command:print x -// lldb-check:[...]$0 = 1 +// lldbg-check:[...]$0 = 1 +// lldbr-check:(i32) x = 1 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$1 = -1 +// lldbg-check:[...]$1 = -1 +// lldbr-check:(i32) x = -1 // lldb-command:continue // SECOND ITERATION // lldb-command:print x -// lldb-check:[...]$2 = 2 +// lldbg-check:[...]$2 = 2 +// lldbr-check:(i32) x = 2 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$3 = -2 +// lldbg-check:[...]$3 = -2 +// lldbr-check:(i32) x = -2 // lldb-command:continue // THIRD ITERATION // lldb-command:print x -// lldb-check:[...]$4 = 3 +// lldbg-check:[...]$4 = 3 +// lldbr-check:(i32) x = 3 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$5 = -3 +// lldbg-check:[...]$5 = -3 +// lldbr-check:(i32) x = -3 // lldb-command:continue // AFTER LOOP // lldb-command:print x -// lldb-check:[...]$6 = 1000000 +// lldbg-check:[...]$6 = 1000000 +// lldbr-check:(i32) x = 1000000 // lldb-command:continue #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-if.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-if.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-if.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-if.rs 2018-12-04 23:41:40.000000000 +0000 @@ -79,58 +79,74 @@ // BEFORE if // lldb-command:print x -// lldb-check:[...]$0 = 999 +// lldbg-check:[...]$0 = 999 +// lldbr-check:(i32) x = 999 // lldb-command:print y -// lldb-check:[...]$1 = -1 +// lldbg-check:[...]$1 = -1 +// lldbr-check:(i32) y = -1 // lldb-command:continue // AT BEGINNING of 'then' block // lldb-command:print x -// lldb-check:[...]$2 = 999 +// lldbg-check:[...]$2 = 999 +// lldbr-check:(i32) x = 999 // lldb-command:print y -// lldb-check:[...]$3 = -1 +// lldbg-check:[...]$3 = -1 +// lldbr-check:(i32) y = -1 // lldb-command:continue // AFTER 1st redeclaration of 'x' // lldb-command:print x -// lldb-check:[...]$4 = 1001 +// lldbg-check:[...]$4 = 1001 +// lldbr-check:(i32) x = 1001 // lldb-command:print y -// lldb-check:[...]$5 = -1 +// lldbg-check:[...]$5 = -1 +// lldbr-check:(i32) y = -1 // lldb-command:continue // AFTER 2st redeclaration of 'x' // lldb-command:print x -// lldb-check:[...]$6 = 1002 +// lldbg-check:[...]$6 = 1002 +// lldbr-check:(i32) x = 1002 // lldb-command:print y -// lldb-check:[...]$7 = 1003 +// lldbg-check:[...]$7 = 1003 +// lldbr-check:(i32) y = 1003 // lldb-command:continue // AFTER 1st if expression // lldb-command:print x -// lldb-check:[...]$8 = 999 +// lldbg-check:[...]$8 = 999 +// lldbr-check:(i32) x = 999 // lldb-command:print y -// lldb-check:[...]$9 = -1 +// lldbg-check:[...]$9 = -1 +// lldbr-check:(i32) y = -1 // lldb-command:continue // BEGINNING of else branch // lldb-command:print x -// lldb-check:[...]$10 = 999 +// lldbg-check:[...]$10 = 999 +// lldbr-check:(i32) x = 999 // lldb-command:print y -// lldb-check:[...]$11 = -1 +// lldbg-check:[...]$11 = -1 +// lldbr-check:(i32) y = -1 // lldb-command:continue // BEGINNING of else branch // lldb-command:print x -// lldb-check:[...]$12 = 1004 +// lldbg-check:[...]$12 = 1004 +// lldbr-check:(i32) x = 1004 // lldb-command:print y -// lldb-check:[...]$13 = 1005 +// lldbg-check:[...]$13 = 1005 +// lldbr-check:(i32) y = 1005 // lldb-command:continue // BEGINNING of else branch // lldb-command:print x -// lldb-check:[...]$14 = 999 +// lldbg-check:[...]$14 = 999 +// lldbr-check:(i32) x = 999 // lldb-command:print y -// lldb-check:[...]$15 = -1 +// lldbg-check:[...]$15 = -1 +// lldbr-check:(i32) y = -1 // lldb-command:continue #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-match.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-match.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -74,55 +74,73 @@ // lldb-command:run // lldb-command:print shadowed -// lldb-check:[...]$0 = 231 +// lldbg-check:[...]$0 = 231 +// lldbr-check:(i32) shadowed = 231 // lldb-command:print not_shadowed -// lldb-check:[...]$1 = 232 +// lldbg-check:[...]$1 = 232 +// lldbr-check:(i32) not_shadowed = 232 // lldb-command:continue // lldb-command:print shadowed -// lldb-check:[...]$2 = 233 +// lldbg-check:[...]$2 = 233 +// lldbr-check:(i32) shadowed = 233 // lldb-command:print not_shadowed -// lldb-check:[...]$3 = 232 +// lldbg-check:[...]$3 = 232 +// lldbr-check:(i32) not_shadowed = 232 // lldb-command:print local_to_arm -// lldb-check:[...]$4 = 234 +// lldbg-check:[...]$4 = 234 +// lldbr-check:(i32) local_to_arm = 234 // lldb-command:continue // lldb-command:print shadowed -// lldb-check:[...]$5 = 236 +// lldbg-check:[...]$5 = 236 +// lldbr-check:(i32) shadowed = 236 // lldb-command:print not_shadowed -// lldb-check:[...]$6 = 232 +// lldbg-check:[...]$6 = 232 +// lldbr-check:(i32) not_shadowed = 232 // lldb-command:continue // lldb-command:print shadowed -// lldb-check:[...]$7 = 237 +// lldbg-check:[...]$7 = 237 +// lldbr-check:(isize) shadowed = 237 // lldb-command:print not_shadowed -// lldb-check:[...]$8 = 232 +// lldbg-check:[...]$8 = 232 +// lldbr-check:(i32) not_shadowed = 232 // lldb-command:print local_to_arm -// lldb-check:[...]$9 = 238 +// lldbg-check:[...]$9 = 238 +// lldbr-check:(isize) local_to_arm = 238 // lldb-command:continue // lldb-command:print shadowed -// lldb-check:[...]$10 = 239 +// lldbg-check:[...]$10 = 239 +// lldbr-check:(isize) shadowed = 239 // lldb-command:print not_shadowed -// lldb-check:[...]$11 = 232 +// lldbg-check:[...]$11 = 232 +// lldbr-check:(i32) not_shadowed = 232 // lldb-command:continue // lldb-command:print shadowed -// lldb-check:[...]$12 = 241 +// lldbg-check:[...]$12 = 241 +// lldbr-check:(isize) shadowed = 241 // lldb-command:print not_shadowed -// lldb-check:[...]$13 = 232 +// lldbg-check:[...]$13 = 232 +// lldbr-check:(i32) not_shadowed = 232 // lldb-command:continue // lldb-command:print shadowed -// lldb-check:[...]$14 = 243 +// lldbg-check:[...]$14 = 243 +// lldbr-check:(i32) shadowed = 243 // lldb-command:print *local_to_arm -// lldb-check:[...]$15 = 244 +// lldbg-check:[...]$15 = 244 +// lldbr-check:(i32) *local_to_arm = 244 // lldb-command:continue // lldb-command:print shadowed -// lldb-check:[...]$16 = 231 +// lldbg-check:[...]$16 = 231 +// lldbr-check:(i32) shadowed = 231 // lldb-command:print not_shadowed -// lldb-check:[...]$17 = 232 +// lldbg-check:[...]$17 = 232 +// lldbr-check:(i32) not_shadowed = 232 // lldb-command:continue #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-stack-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-stack-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-stack-closure.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-stack-closure.rs 2018-12-04 23:41:40.000000000 +0000 @@ -46,27 +46,33 @@ // lldb-command:run // lldb-command:print x -// lldb-check:[...]$0 = false +// lldbg-check:[...]$0 = false +// lldbr-check:(bool) x = false // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$1 = false +// lldbg-check:[...]$1 = false +// lldbr-check:(bool) x = false // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$2 = 1000 +// lldbg-check:[...]$2 = 1000 +// lldbr-check:(isize) x = 1000 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$3 = 2.5 +// lldbg-check:[...]$3 = 2.5 +// lldbr-check:(f64) x = 2.5 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$4 = true +// lldbg-check:[...]$4 = true +// lldbr-check:(bool) x = true // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$5 = false +// lldbg-check:[...]$5 = false +// lldbr-check:(bool) x = false // lldb-command:continue #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-unconditional-loop.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-unconditional-loop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-unconditional-loop.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-unconditional-loop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -78,57 +78,70 @@ // FIRST ITERATION // lldb-command:print x -// lldb-check:[...]$0 = 0 +// lldbg-check:[...]$0 = 0 +// lldbr-check:(i32) x = 0 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$1 = 1 +// lldbg-check:[...]$1 = 1 +// lldbr-check:(i32) x = 1 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$2 = 101 +// lldbg-check:[...]$2 = 101 +// lldbr-check:(i32) x = 101 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$3 = 101 +// lldbg-check:[...]$3 = 101 +// lldbr-check:(i32) x = 101 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$4 = -987 +// lldbg-check:[...]$4 = -987 +// lldbr-check:(i32) x = -987 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$5 = 101 +// lldbg-check:[...]$5 = 101 +// lldbr-check:(i32) x = 101 // lldb-command:continue // SECOND ITERATION // lldb-command:print x -// lldb-check:[...]$6 = 1 +// lldbg-check:[...]$6 = 1 +// lldbr-check:(i32) x = 1 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$7 = 2 +// lldbg-check:[...]$7 = 2 +// lldbr-check:(i32) x = 2 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$8 = 102 +// lldbg-check:[...]$8 = 102 +// lldbr-check:(i32) x = 102 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$9 = 102 +// lldbg-check:[...]$9 = 102 +// lldbr-check:(i32) x = 102 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$10 = -987 +// lldbg-check:[...]$10 = -987 +// lldbr-check:(i32) x = -987 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$11 = 102 +// lldbg-check:[...]$11 = 102 +// lldbr-check:(i32) x = 102 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$12 = 2 +// lldbg-check:[...]$12 = 2 +// lldbr-check:(i32) x = 2 // lldb-command:continue #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-unique-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-unique-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-unique-closure.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-unique-closure.rs 2018-12-04 23:41:40.000000000 +0000 @@ -46,27 +46,33 @@ // lldb-command:run // lldb-command:print x -// lldb-check:[...]$0 = false +// lldbg-check:[...]$0 = false +// lldbr-check:(bool) x = false // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$1 = false +// lldbg-check:[...]$1 = false +// lldbr-check:(bool) x = false // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$2 = 1000 +// lldbg-check:[...]$2 = 1000 +// lldbr-check:(isize) x = 1000 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$3 = 2.5 +// lldbg-check:[...]$3 = 2.5 +// lldbr-check:(f64) x = 2.5 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$4 = true +// lldbg-check:[...]$4 = true +// lldbr-check:(bool) x = true // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$5 = false +// lldbg-check:[...]$5 = false +// lldbr-check:(bool) x = false // lldb-command:continue diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-while.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-while.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-while.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-in-while.rs 2018-12-04 23:41:40.000000000 +0000 @@ -78,57 +78,70 @@ // FIRST ITERATION // lldb-command:print x -// lldb-check:[...]$0 = 0 +// lldbg-check:[...]$0 = 0 +// lldbr-check:(i32) x = 0 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$1 = 1 +// lldbg-check:[...]$1 = 1 +// lldbr-check:(i32) x = 1 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$2 = 101 +// lldbg-check:[...]$2 = 101 +// lldbr-check:(i32) x = 101 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$3 = 101 +// lldbg-check:[...]$3 = 101 +// lldbr-check:(i32) x = 101 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$4 = -987 +// lldbg-check:[...]$4 = -987 +// lldbr-check:(i32) x = -987 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$5 = 101 +// lldbg-check:[...]$5 = 101 +// lldbr-check:(i32) x = 101 // lldb-command:continue // SECOND ITERATION // lldb-command:print x -// lldb-check:[...]$6 = 1 +// lldbg-check:[...]$6 = 1 +// lldbr-check:(i32) x = 1 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$7 = 2 +// lldbg-check:[...]$7 = 2 +// lldbr-check:(i32) x = 2 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$8 = 102 +// lldbg-check:[...]$8 = 102 +// lldbr-check:(i32) x = 102 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$9 = 102 +// lldbg-check:[...]$9 = 102 +// lldbr-check:(i32) x = 102 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$10 = -987 +// lldbg-check:[...]$10 = -987 +// lldbr-check:(i32) x = -987 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$11 = 102 +// lldbg-check:[...]$11 = 102 +// lldbr-check:(i32) x = 102 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$12 = 2 +// lldbg-check:[...]$12 = 2 +// lldbr-check:(i32) x = 2 // lldb-command:continue #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/lexical-scopes-in-block-expression.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/lexical-scopes-in-block-expression.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/lexical-scopes-in-block-expression.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/lexical-scopes-in-block-expression.rs 2018-12-04 23:41:40.000000000 +0000 @@ -205,155 +205,203 @@ // STRUCT EXPRESSION // lldb-command:print val -// lldb-check:[...]$0 = -1 +// lldbg-check:[...]$0 = -1 +// lldbr-check:(i32) val = -1 // lldb-command:print ten -// lldb-check:[...]$1 = 10 +// lldbg-check:[...]$1 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue // lldb-command:print val -// lldb-check:[...]$2 = 11 +// lldbg-check:[...]$2 = 11 +// lldbr-check:(isize) val = 11 // lldb-command:print ten -// lldb-check:[...]$3 = 10 +// lldbg-check:[...]$3 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue // lldb-command:print val -// lldb-check:[...]$4 = -1 +// lldbg-check:[...]$4 = -1 +// lldbr-check:(i32) val = -1 // lldb-command:print ten -// lldb-check:[...]$5 = 10 +// lldbg-check:[...]$5 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue // FUNCTION CALL // lldb-command:print val -// lldb-check:[...]$6 = -1 +// lldbg-check:[...]$6 = -1 +// lldbr-check:(i32) val = -1 // lldb-command:print ten -// lldb-check:[...]$7 = 10 +// lldbg-check:[...]$7 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue // lldb-command:print val -// lldb-check:[...]$8 = 12 +// lldbg-check:[...]$8 = 12 +// lldbr-check:(isize) val = 12 // lldb-command:print ten -// lldb-check:[...]$9 = 10 +// lldbg-check:[...]$9 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue // lldb-command:print val -// lldb-check:[...]$10 = -1 +// lldbg-check:[...]$10 = -1 +// lldbr-check:(i32) val = -1 // lldb-command:print ten -// lldb-check:[...]$11 = 10 +// lldbg-check:[...]$11 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue // TUPLE EXPRESSION // lldb-command:print val -// lldb-check:[...]$12 = -1 +// lldbg-check:[...]$12 = -1 +// lldbr-check:(i32) val = -1 // lldb-command:print ten -// lldb-check:[...]$13 = 10 +// lldbg-check:[...]$13 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue // lldb-command:print val -// lldb-check:[...]$14 = 13 +// lldbg-check:[...]$14 = 13 +// lldbr-check:(isize) val = 13 // lldb-command:print ten -// lldb-check:[...]$15 = 10 +// lldbg-check:[...]$15 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue // lldb-command:print val -// lldb-check:[...]$16 = -1 +// lldbg-check:[...]$16 = -1 +// lldbr-check:(i32) val = -1 // lldb-command:print ten -// lldb-check:[...]$17 = 10 +// lldbg-check:[...]$17 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue // VEC EXPRESSION // lldb-command:print val -// lldb-check:[...]$18 = -1 +// lldbg-check:[...]$18 = -1 +// lldbr-check:(i32) val = -1 // lldb-command:print ten -// lldb-check:[...]$19 = 10 +// lldbg-check:[...]$19 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue // lldb-command:print val -// lldb-check:[...]$20 = 14 +// lldbg-check:[...]$20 = 14 +// lldbr-check:(isize) val = 14 // lldb-command:print ten -// lldb-check:[...]$21 = 10 +// lldbg-check:[...]$21 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue // lldb-command:print val -// lldb-check:[...]$22 = -1 +// lldbg-check:[...]$22 = -1 +// lldbr-check:(i32) val = -1 // lldb-command:print ten -// lldb-check:[...]$23 = 10 +// lldbg-check:[...]$23 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue // REPEAT VEC EXPRESSION // lldb-command:print val -// lldb-check:[...]$24 = -1 +// lldbg-check:[...]$24 = -1 +// lldbr-check:(i32) val = -1 // lldb-command:print ten -// lldb-check:[...]$25 = 10 +// lldbg-check:[...]$25 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue // lldb-command:print val -// lldb-check:[...]$26 = 15 +// lldbg-check:[...]$26 = 15 +// lldbr-check:(isize) val = 15 // lldb-command:print ten -// lldb-check:[...]$27 = 10 +// lldbg-check:[...]$27 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue // lldb-command:print val -// lldb-check:[...]$28 = -1 +// lldbg-check:[...]$28 = -1 +// lldbr-check:(i32) val = -1 // lldb-command:print ten -// lldb-check:[...]$29 = 10 +// lldbg-check:[...]$29 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue // ASSIGNMENT EXPRESSION // lldb-command:print val -// lldb-check:[...]$30 = -1 +// lldbg-check:[...]$30 = -1 +// lldbr-check:(i32) val = -1 // lldb-command:print ten -// lldb-check:[...]$31 = 10 +// lldbg-check:[...]$31 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue // lldb-command:print val -// lldb-check:[...]$32 = 16 +// lldbg-check:[...]$32 = 16 +// lldbr-check:(isize) val = 16 // lldb-command:print ten -// lldb-check:[...]$33 = 10 +// lldbg-check:[...]$33 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue // lldb-command:print val -// lldb-check:[...]$34 = -1 +// lldbg-check:[...]$34 = -1 +// lldbr-check:(i32) val = -1 // lldb-command:print ten -// lldb-check:[...]$35 = 10 +// lldbg-check:[...]$35 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue // ARITHMETIC EXPRESSION // lldb-command:print val -// lldb-check:[...]$36 = -1 +// lldbg-check:[...]$36 = -1 +// lldbr-check:(i32) val = -1 // lldb-command:print ten -// lldb-check:[...]$37 = 10 +// lldbg-check:[...]$37 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue // lldb-command:print val -// lldb-check:[...]$38 = 17 +// lldbg-check:[...]$38 = 17 +// lldbr-check:(isize) val = 17 // lldb-command:print ten -// lldb-check:[...]$39 = 10 +// lldbg-check:[...]$39 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue // lldb-command:print val -// lldb-check:[...]$40 = -1 +// lldbg-check:[...]$40 = -1 +// lldbr-check:(i32) val = -1 // lldb-command:print ten -// lldb-check:[...]$41 = 10 +// lldbg-check:[...]$41 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue // INDEX EXPRESSION // lldb-command:print val -// lldb-check:[...]$42 = -1 +// lldbg-check:[...]$42 = -1 +// lldbr-check:(i32) val = -1 // lldb-command:print ten -// lldb-check:[...]$43 = 10 +// lldbg-check:[...]$43 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue // lldb-command:print val -// lldb-check:[...]$44 = 18 +// lldbg-check:[...]$44 = 18 +// lldbr-check:(isize) val = 18 // lldb-command:print ten -// lldb-check:[...]$45 = 10 +// lldbg-check:[...]$45 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue // lldb-command:print val -// lldb-check:[...]$46 = -1 +// lldbg-check:[...]$46 = -1 +// lldbr-check:(i32) val = -1 // lldb-command:print ten -// lldb-check:[...]$47 = 10 +// lldbg-check:[...]$47 = 10 +// lldbr-check:(isize) ten = 10 // lldb-command:continue #![allow(unused_variables)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-with-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-with-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-with-macro.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/lexical-scope-with-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,7 +9,7 @@ // except according to those terms. // min-lldb-version: 310 -// ignore-macos FIXME #48807 +// ignore-lldb FIXME #48807 // compile-flags:-g -Zdebug-macros @@ -67,48 +67,57 @@ // lldb-command:run // lldb-command:print a -// lldb-check:[...]$0 = 10 +// lldbg-check:[...]$0 = 10 +// lldbr-check:(i32) a = 10 // lldb-command:print b -// lldb-check:[...]$1 = 34 +// lldbg-check:[...]$1 = 34 +// lldbr-check:(i32) b = 34 // lldb-command:continue // lldb-command:print a -// lldb-check:[...]$2 = 890242 +// lldbg-check:[...]$2 = 890242 +// lldbr-check:(i32) a = 10 // lldb-command:print b -// lldb-check:[...]$3 = 34 +// lldbg-check:[...]$3 = 34 +// lldbr-check:(i32) b = 34 // lldb-command:continue // lldb-command:print a -// lldb-check:[...]$4 = 10 +// lldbg-check:[...]$4 = 10 +// lldbr-check:(i32) a = 10 // lldb-command:print b -// lldb-check:[...]$5 = 34 +// lldbg-check:[...]$5 = 34 +// lldbr-check:(i32) b = 34 // lldb-command:continue // lldb-command:print a -// lldb-check:[...]$6 = 102 +// lldbg-check:[...]$6 = 102 +// lldbr-check:(i32) a = 10 // lldb-command:print b -// lldb-check:[...]$7 = 34 +// lldbg-check:[...]$7 = 34 +// lldbr-check:(i32) b = 34 // lldb-command:continue -// lldb-command:print a -// lldb-check:[...]$8 = 110 -// lldb-command:print b -// lldb-check:[...]$9 = 34 -// lldb-command:continue +// Don't test this with rust-enabled lldb for now; see issue #48807 +// lldbg-command:print a +// lldbg-check:[...]$8 = 110 +// lldbg-command:print b +// lldbg-check:[...]$9 = 34 +// lldbg-command:continue -// lldb-command:print a -// lldb-check:[...]$10 = 10 -// lldb-command:print b -// lldb-check:[...]$11 = 34 -// lldb-command:continue +// lldbg-command:print a +// lldbg-check:[...]$10 = 10 +// lldbg-command:print b +// lldbg-check:[...]$11 = 34 +// lldbg-command:continue -// lldb-command:print a -// lldb-check:[...]$12 = 10 -// lldb-command:print b -// lldb-check:[...]$13 = 34 -// lldb-command:print c -// lldb-check:[...]$14 = 400 -// lldb-command:continue +// lldbg-command:print a +// lldbg-check:[...]$12 = 10 +// lldbg-command:print b +// lldbg-check:[...]$13 = 34 +// lldbg-command:print c +// lldbg-check:[...]$14 = 400 +// lldbg-command:continue #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/method-on-generic-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/method-on-generic-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/method-on-generic-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/method-on-generic-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -73,47 +73,62 @@ // STACK BY REF // lldb-command:print *self -// lldb-check:[...]$0 = Struct<(u32, i32)> { x: (8888, -8888) } +// lldbg-check:[...]$0 = Struct<(u32, i32)> { x: (8888, -8888) } +// lldbr-check:(method_on_generic_struct::Struct<(u32, i32)>) *self = { x = { = 8888 = -8888 } } // lldb-command:print arg1 -// lldb-check:[...]$1 = -1 +// lldbg-check:[...]$1 = -1 +// lldbr-check:(isize) arg1 = -1 // lldb-command:print arg2 -// lldb-check:[...]$2 = -2 +// lldbg-check:[...]$2 = -2 +// lldbr-check:(isize) arg2 = -2 // lldb-command:continue // STACK BY VAL // lldb-command:print self -// lldb-check:[...]$3 = Struct<(u32, i32)> { x: (8888, -8888) } +// lldbg-check:[...]$3 = Struct<(u32, i32)> { x: (8888, -8888) } +// lldbr-check:(method_on_generic_struct::Struct<(u32, i32)>) self = { x = { = 8888 = -8888 } } // lldb-command:print arg1 -// lldb-check:[...]$4 = -3 +// lldbg-check:[...]$4 = -3 +// lldbr-check:(isize) arg1 = -3 // lldb-command:print arg2 -// lldb-check:[...]$5 = -4 +// lldbg-check:[...]$5 = -4 +// lldbr-check:(isize) arg2 = -4 // lldb-command:continue // OWNED BY REF // lldb-command:print *self -// lldb-check:[...]$6 = Struct { x: 1234.5 } +// lldbg-check:[...]$6 = Struct { x: 1234.5 } +// lldbr-check:(method_on_generic_struct::Struct) *self = Struct { x: 1234.5 } // lldb-command:print arg1 -// lldb-check:[...]$7 = -5 +// lldbg-check:[...]$7 = -5 +// lldbr-check:(isize) arg1 = -5 // lldb-command:print arg2 -// lldb-check:[...]$8 = -6 +// lldbg-check:[...]$8 = -6 +// lldbr-check:(isize) arg2 = -6 // lldb-command:continue // OWNED BY VAL // lldb-command:print self -// lldb-check:[...]$9 = Struct { x: 1234.5 } +// lldbg-check:[...]$9 = Struct { x: 1234.5 } +// lldbr-check:(method_on_generic_struct::Struct) self = Struct { x: 1234.5 } // lldb-command:print arg1 -// lldb-check:[...]$10 = -7 +// lldbg-check:[...]$10 = -7 +// lldbr-check:(isize) arg1 = -7 // lldb-command:print arg2 -// lldb-check:[...]$11 = -8 +// lldbg-check:[...]$11 = -8 +// lldbr-check:(isize) arg2 = -8 // lldb-command:continue // OWNED MOVED // lldb-command:print *self -// lldb-check:[...]$12 = Struct { x: 1234.5 } +// lldbg-check:[...]$12 = Struct { x: 1234.5 } +// lldbr-check:(method_on_generic_struct::Struct) *self = Struct { x: 1234.5 } // lldb-command:print arg1 -// lldb-check:[...]$13 = -9 +// lldbg-check:[...]$13 = -9 +// lldbr-check:(isize) arg1 = -9 // lldb-command:print arg2 -// lldb-check:[...]$14 = -10 +// lldbg-check:[...]$14 = -10 +// lldbr-check:(isize) arg2 = -10 // lldb-command:continue diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/method-on-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/method-on-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/method-on-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/method-on-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -73,47 +73,62 @@ // STACK BY REF // lldb-command:print *self -// lldb-check:[...]$0 = Struct { x: 100 } +// lldbg-check:[...]$0 = Struct { x: 100 } +// lldbr-check:(method_on_struct::Struct) *self = Struct { x: 100 } // lldb-command:print arg1 -// lldb-check:[...]$1 = -1 +// lldbg-check:[...]$1 = -1 +// lldbr-check:(isize) arg1 = -1 // lldb-command:print arg2 -// lldb-check:[...]$2 = -2 +// lldbg-check:[...]$2 = -2 +// lldbr-check:(isize) arg2 = -2 // lldb-command:continue // STACK BY VAL // lldb-command:print self -// lldb-check:[...]$3 = Struct { x: 100 } +// lldbg-check:[...]$3 = Struct { x: 100 } +// lldbr-check:(method_on_struct::Struct) self = Struct { x: 100 } // lldb-command:print arg1 -// lldb-check:[...]$4 = -3 +// lldbg-check:[...]$4 = -3 +// lldbr-check:(isize) arg1 = -3 // lldb-command:print arg2 -// lldb-check:[...]$5 = -4 +// lldbg-check:[...]$5 = -4 +// lldbr-check:(isize) arg2 = -4 // lldb-command:continue // OWNED BY REF // lldb-command:print *self -// lldb-check:[...]$6 = Struct { x: 200 } +// lldbg-check:[...]$6 = Struct { x: 200 } +// lldbr-check:(method_on_struct::Struct) *self = Struct { x: 200 } // lldb-command:print arg1 -// lldb-check:[...]$7 = -5 +// lldbg-check:[...]$7 = -5 +// lldbr-check:(isize) arg1 = -5 // lldb-command:print arg2 -// lldb-check:[...]$8 = -6 +// lldbg-check:[...]$8 = -6 +// lldbr-check:(isize) arg2 = -6 // lldb-command:continue // OWNED BY VAL // lldb-command:print self -// lldb-check:[...]$9 = Struct { x: 200 } +// lldbg-check:[...]$9 = Struct { x: 200 } +// lldbr-check:(method_on_struct::Struct) self = Struct { x: 200 } // lldb-command:print arg1 -// lldb-check:[...]$10 = -7 +// lldbg-check:[...]$10 = -7 +// lldbr-check:(isize) arg1 = -7 // lldb-command:print arg2 -// lldb-check:[...]$11 = -8 +// lldbg-check:[...]$11 = -8 +// lldbr-check:(isize) arg2 = -8 // lldb-command:continue // OWNED MOVED // lldb-command:print *self -// lldb-check:[...]$12 = Struct { x: 200 } +// lldbg-check:[...]$12 = Struct { x: 200 } +// lldbr-check:(method_on_struct::Struct) *self = Struct { x: 200 } // lldb-command:print arg1 -// lldb-check:[...]$13 = -9 +// lldbg-check:[...]$13 = -9 +// lldbr-check:(isize) arg1 = -9 // lldb-command:print arg2 -// lldb-check:[...]$14 = -10 +// lldbg-check:[...]$14 = -10 +// lldbr-check:(isize) arg2 = -10 // lldb-command:continue diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/method-on-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/method-on-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/method-on-trait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/method-on-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -73,47 +73,62 @@ // STACK BY REF // lldb-command:print *self -// lldb-check:[...]$0 = Struct { x: 100 } +// lldbg-check:[...]$0 = Struct { x: 100 } +// lldbr-check:(method_on_trait::Struct) *self = Struct { x: 100 } // lldb-command:print arg1 -// lldb-check:[...]$1 = -1 +// lldbg-check:[...]$1 = -1 +// lldbr-check:(isize) arg1 = -1 // lldb-command:print arg2 -// lldb-check:[...]$2 = -2 +// lldbg-check:[...]$2 = -2 +// lldbr-check:(isize) arg2 = -2 // lldb-command:continue // STACK BY VAL // lldb-command:print self -// lldb-check:[...]$3 = Struct { x: 100 } +// lldbg-check:[...]$3 = Struct { x: 100 } +// lldbr-check:(method_on_trait::Struct) self = Struct { x: 100 } // lldb-command:print arg1 -// lldb-check:[...]$4 = -3 +// lldbg-check:[...]$4 = -3 +// lldbr-check:(isize) arg1 = -3 // lldb-command:print arg2 -// lldb-check:[...]$5 = -4 +// lldbg-check:[...]$5 = -4 +// lldbr-check:(isize) arg2 = -4 // lldb-command:continue // OWNED BY REF // lldb-command:print *self -// lldb-check:[...]$6 = Struct { x: 200 } +// lldbg-check:[...]$6 = Struct { x: 200 } +// lldbr-check:(method_on_trait::Struct) *self = Struct { x: 200 } // lldb-command:print arg1 -// lldb-check:[...]$7 = -5 +// lldbg-check:[...]$7 = -5 +// lldbr-check:(isize) arg1 = -5 // lldb-command:print arg2 -// lldb-check:[...]$8 = -6 +// lldbg-check:[...]$8 = -6 +// lldbr-check:(isize) arg2 = -6 // lldb-command:continue // OWNED BY VAL // lldb-command:print self -// lldb-check:[...]$9 = Struct { x: 200 } +// lldbg-check:[...]$9 = Struct { x: 200 } +// lldbr-check:(method_on_trait::Struct) self = Struct { x: 200 } // lldb-command:print arg1 -// lldb-check:[...]$10 = -7 +// lldbg-check:[...]$10 = -7 +// lldbr-check:(isize) arg1 = -7 // lldb-command:print arg2 -// lldb-check:[...]$11 = -8 +// lldbg-check:[...]$11 = -8 +// lldbr-check:(isize) arg2 = -8 // lldb-command:continue // OWNED MOVED // lldb-command:print *self -// lldb-check:[...]$12 = Struct { x: 200 } +// lldbg-check:[...]$12 = Struct { x: 200 } +// lldbr-check:(method_on_trait::Struct) *self = Struct { x: 200 } // lldb-command:print arg1 -// lldb-check:[...]$13 = -9 +// lldbg-check:[...]$13 = -9 +// lldbr-check:(isize) arg1 = -9 // lldb-command:print arg2 -// lldb-check:[...]$14 = -10 +// lldbg-check:[...]$14 = -10 +// lldbr-check:(isize) arg2 = -10 // lldb-command:continue diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/method-on-tuple-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/method-on-tuple-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/method-on-tuple-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/method-on-tuple-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -73,47 +73,62 @@ // STACK BY REF // lldb-command:print *self -// lldb-check:[...]$0 = TupleStruct(100, -100.5) +// lldbg-check:[...]$0 = TupleStruct(100, -100.5) +// lldbr-check:(method_on_tuple_struct::TupleStruct) *self = { = 100 = -100.5 } // lldb-command:print arg1 -// lldb-check:[...]$1 = -1 +// lldbg-check:[...]$1 = -1 +// lldbr-check:(isize) arg1 = -1 // lldb-command:print arg2 -// lldb-check:[...]$2 = -2 +// lldbg-check:[...]$2 = -2 +// lldbr-check:(isize) arg2 = -2 // lldb-command:continue // STACK BY VAL // lldb-command:print self -// lldb-check:[...]$3 = TupleStruct(100, -100.5) +// lldbg-check:[...]$3 = TupleStruct(100, -100.5) +// lldbr-check:(method_on_tuple_struct::TupleStruct) self = { = 100 = -100.5 } // lldb-command:print arg1 -// lldb-check:[...]$4 = -3 +// lldbg-check:[...]$4 = -3 +// lldbr-check:(isize) arg1 = -3 // lldb-command:print arg2 -// lldb-check:[...]$5 = -4 +// lldbg-check:[...]$5 = -4 +// lldbr-check:(isize) arg2 = -4 // lldb-command:continue // OWNED BY REF // lldb-command:print *self -// lldb-check:[...]$6 = TupleStruct(200, -200.5) +// lldbg-check:[...]$6 = TupleStruct(200, -200.5) +// lldbr-check:(method_on_tuple_struct::TupleStruct) *self = { = 200 = -200.5 } // lldb-command:print arg1 -// lldb-check:[...]$7 = -5 +// lldbg-check:[...]$7 = -5 +// lldbr-check:(isize) arg1 = -5 // lldb-command:print arg2 -// lldb-check:[...]$8 = -6 +// lldbg-check:[...]$8 = -6 +// lldbr-check:(isize) arg2 = -6 // lldb-command:continue // OWNED BY VAL // lldb-command:print self -// lldb-check:[...]$9 = TupleStruct(200, -200.5) +// lldbg-check:[...]$9 = TupleStruct(200, -200.5) +// lldbr-check:(method_on_tuple_struct::TupleStruct) self = { = 200 = -200.5 } // lldb-command:print arg1 -// lldb-check:[...]$10 = -7 +// lldbg-check:[...]$10 = -7 +// lldbr-check:(isize) arg1 = -7 // lldb-command:print arg2 -// lldb-check:[...]$11 = -8 +// lldbg-check:[...]$11 = -8 +// lldbr-check:(isize) arg2 = -8 // lldb-command:continue // OWNED MOVED // lldb-command:print *self -// lldb-check:[...]$12 = TupleStruct(200, -200.5) +// lldbg-check:[...]$12 = TupleStruct(200, -200.5) +// lldbr-check:(method_on_tuple_struct::TupleStruct) *self = { = 200 = -200.5 } // lldb-command:print arg1 -// lldb-check:[...]$13 = -9 +// lldbg-check:[...]$13 = -9 +// lldbr-check:(isize) arg1 = -9 // lldb-command:print arg2 -// lldb-check:[...]$14 = -10 +// lldbg-check:[...]$14 = -10 +// lldbr-check:(isize) arg2 = -10 // lldb-command:continue diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/multi-cgu.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/multi-cgu.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/multi-cgu.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/multi-cgu.rs 2018-12-04 23:41:40.000000000 +0000 @@ -35,11 +35,13 @@ // lldb-command:run // lldb-command:print xxx -// lldb-check:[...]$0 = 12345 +// lldbg-check:[...]$0 = 12345 +// lldbr-check:(u32) xxx = 12345 // lldb-command:continue // lldb-command:print yyy -// lldb-check:[...]$1 = 67890 +// lldbg-check:[...]$1 = 67890 +// lldbr-check:(u64) yyy = 67890 // lldb-command:continue diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/multiple-functions-equal-var-names.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/multiple-functions-equal-var-names.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/multiple-functions-equal-var-names.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/multiple-functions-equal-var-names.rs 2018-12-04 23:41:40.000000000 +0000 @@ -33,15 +33,18 @@ // lldb-command:run // lldb-command:print abc -// lldb-check:[...]$0 = 10101 +// lldbg-check:[...]$0 = 10101 +// lldbr-check:(i32) abc = 10101 // lldb-command:continue // lldb-command:print abc -// lldb-check:[...]$1 = 20202 +// lldbg-check:[...]$1 = 20202 +// lldbr-check:(i32) abc = 20202 // lldb-command:continue // lldb-command:print abc -// lldb-check:[...]$2 = 30303 +// lldbg-check:[...]$2 = 30303 +// lldbr-check:(i32) abc = 30303 #![allow(unused_variables)] #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/multiple-functions.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/multiple-functions.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/multiple-functions.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/multiple-functions.rs 2018-12-04 23:41:40.000000000 +0000 @@ -33,15 +33,18 @@ // lldb-command:run // lldb-command:print a -// lldb-check:[...]$0 = 10101 +// lldbg-check:[...]$0 = 10101 +// lldbr-check:(i32) a = 10101 // lldb-command:continue // lldb-command:print b -// lldb-check:[...]$1 = 20202 +// lldbg-check:[...]$1 = 20202 +// lldbr-check:(i32) b = 20202 // lldb-command:continue // lldb-command:print c -// lldb-check:[...]$2 = 30303 +// lldbg-check:[...]$2 = 30303 +// lldbr-check:(i32) c = 30303 #![allow(unused_variables)] #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/name-shadowing-and-scope-nesting.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/name-shadowing-and-scope-nesting.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/name-shadowing-and-scope-nesting.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/name-shadowing-and-scope-nesting.rs 2018-12-04 23:41:40.000000000 +0000 @@ -58,39 +58,51 @@ // lldb-command:run // lldb-command:print x -// lldb-check:[...]$0 = false +// lldbg-check:[...]$0 = false +// lldbr-check:(bool) x = false // lldb-command:print y -// lldb-check:[...]$1 = true +// lldbg-check:[...]$1 = true +// lldbr-check:(bool) y = true // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$2 = 10 +// lldbg-check:[...]$2 = 10 +// lldbr-check:(i32) x = 10 // lldb-command:print y -// lldb-check:[...]$3 = true +// lldbg-check:[...]$3 = true +// lldbr-check:(bool) y = true // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$4 = 10.5 +// lldbg-check:[...]$4 = 10.5 +// lldbr-check:(f64) x = 10.5 // lldb-command:print y -// lldb-check:[...]$5 = 20 +// lldbg-check:[...]$5 = 20 +// lldbr-check:(i32) y = 20 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$6 = true +// lldbg-check:[...]$6 = true +// lldbr-check:(bool) x = true // lldb-command:print y -// lldb-check:[...]$7 = 2220 +// lldbg-check:[...]$7 = 2220 +// lldbr-check:(i32) y = 2220 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$8 = 203203.5 +// lldbg-check:[...]$8 = 203203.5 +// lldbr-check:(f64) x = 203203.5 // lldb-command:print y -// lldb-check:[...]$9 = 2220 +// lldbg-check:[...]$9 = 2220 +// lldbr-check:(i32) y = 2220 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$10 = 10.5 +// lldbg-check:[...]$10 = 10.5 +// lldbr-check:(f64) x = 10.5 // lldb-command:print y -// lldb-check:[...]$11 = 20 +// lldbg-check:[...]$11 = 20 +// lldbr-check:(i32) y = 20 // lldb-command:continue #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/nil-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/nil-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/nil-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/nil-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// NOTE Instantiating an empty enum is UB. This test may break in the future. + // LLDB can't handle zero-sized values // ignore-lldb @@ -25,8 +27,11 @@ #![allow(unused_variables)] #![feature(omit_gdb_pretty_printer_section)] +#![feature(maybe_uninit)] #![omit_gdb_pretty_printer_section] +use std::mem::MaybeUninit; + enum ANilEnum {} enum AnotherNilEnum {} @@ -35,8 +40,8 @@ // The error from gdbr is expected since nil enums are not supposed to exist. fn main() { unsafe { - let first: ANilEnum = ::std::mem::zeroed(); - let second: AnotherNilEnum = ::std::mem::zeroed(); + let first: ANilEnum = MaybeUninit::uninitialized().into_inner(); + let second: AnotherNilEnum = MaybeUninit::uninitialized().into_inner(); zzz(); // #break } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/packed-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/packed-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/packed-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/packed-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -46,22 +46,28 @@ // lldb-command:run // lldb-command:print packed -// lldb-check:[...]$0 = Packed { x: 123, y: 234, z: 345 } +// lldbg-check:[...]$0 = Packed { x: 123, y: 234, z: 345 } +// lldbr-check:(packed_struct::Packed) packed = Packed { x: 123, y: 234, z: 345 } // lldb-command:print packedInPacked -// lldb-check:[...]$1 = PackedInPacked { a: 1111, b: Packed { x: 2222, y: 3333, z: 4444 }, c: 5555, d: Packed { x: 6666, y: 7777, z: 8888 } } +// lldbg-check:[...]$1 = PackedInPacked { a: 1111, b: Packed { x: 2222, y: 3333, z: 4444 }, c: 5555, d: Packed { x: 6666, y: 7777, z: 8888 } } +// lldbr-check:(packed_struct::PackedInPacked) packedInPacked = PackedInPacked { a: 1111, b: Packed { x: 2222, y: 3333, z: 4444 }, c: 5555, d: Packed { x: 6666, y: 7777, z: 8888 } } // lldb-command:print packedInUnpacked -// lldb-check:[...]$2 = PackedInUnpacked { a: -1111, b: Packed { x: -2222, y: -3333, z: -4444 }, c: -5555, d: Packed { x: -6666, y: -7777, z: -8888 } } +// lldbg-check:[...]$2 = PackedInUnpacked { a: -1111, b: Packed { x: -2222, y: -3333, z: -4444 }, c: -5555, d: Packed { x: -6666, y: -7777, z: -8888 } } +// lldbr-check:(packed_struct::PackedInUnpacked) packedInUnpacked = PackedInUnpacked { a: -1111, b: Packed { x: -2222, y: -3333, z: -4444 }, c: -5555, d: Packed { x: -6666, y: -7777, z: -8888 } } // lldb-command:print unpackedInPacked -// lldb-check:[...]$3 = UnpackedInPacked { a: 987, b: Unpacked { x: 876, y: 765, z: 654, w: 543 }, c: Unpacked { x: 432, y: 321, z: 210, w: 109 }, d: -98 } +// lldbg-check:[...]$3 = UnpackedInPacked { a: 987, b: Unpacked { x: 876, y: 765, z: 654, w: 543 }, c: Unpacked { x: 432, y: 321, z: 210, w: 109 }, d: -98 } +// lldbr-check:(packed_struct::UnpackedInPacked) unpackedInPacked = UnpackedInPacked { a: 987, b: Unpacked { x: 876, y: 765, z: 654, w: 543 }, c: Unpacked { x: 432, y: 321, z: 210, w: 109 }, d: -98 } // lldb-command:print sizeof(packed) -// lldb-check:[...]$4 = 14 +// lldbg-check:[...]$4 = 14 +// lldbr-check:(usize) = 14 // lldb-command:print sizeof(packedInPacked) -// lldb-check:[...]$5 = 40 +// lldbg-check:[...]$5 = 40 +// lldbr-check:(usize) = 40 #![allow(unused_variables)] #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/packed-struct-with-destructor.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/packed-struct-with-destructor.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/packed-struct-with-destructor.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/packed-struct-with-destructor.rs 2018-12-04 23:41:40.000000000 +0000 @@ -56,28 +56,36 @@ // lldb-command:run // lldb-command:print packed -// lldb-check:[...]$0 = Packed { x: 123, y: 234, z: 345 } +// lldbg-check:[...]$0 = Packed { x: 123, y: 234, z: 345 } +// lldbr-check:(packed_struct_with_destructor::Packed) packed = Packed { x: 123, y: 234, z: 345 } // lldb-command:print packedInPacked -// lldb-check:[...]$1 = PackedInPacked { a: 1111, b: Packed { x: 2222, y: 3333, z: 4444 }, c: 5555, d: Packed { x: 6666, y: 7777, z: 8888 } } +// lldbg-check:[...]$1 = PackedInPacked { a: 1111, b: Packed { x: 2222, y: 3333, z: 4444 }, c: 5555, d: Packed { x: 6666, y: 7777, z: 8888 } } +// lldbr-check:(packed_struct_with_destructor::PackedInPacked) packedInPacked = PackedInPacked { a: 1111, b: Packed { x: 2222, y: 3333, z: 4444 }, c: 5555, d: Packed { x: 6666, y: 7777, z: 8888 } } // lldb-command:print packedInUnpacked -// lldb-check:[...]$2 = PackedInUnpacked { a: -1111, b: Packed { x: -2222, y: -3333, z: -4444 }, c: -5555, d: Packed { x: -6666, y: -7777, z: -8888 } } +// lldbg-check:[...]$2 = PackedInUnpacked { a: -1111, b: Packed { x: -2222, y: -3333, z: -4444 }, c: -5555, d: Packed { x: -6666, y: -7777, z: -8888 } } +// lldbr-check:(packed_struct_with_destructor::PackedInUnpacked) packedInUnpacked = PackedInUnpacked { a: -1111, b: Packed { x: -2222, y: -3333, z: -4444 }, c: -5555, d: Packed { x: -6666, y: -7777, z: -8888 } } // lldb-command:print unpackedInPacked -// lldb-check:[...]$3 = UnpackedInPacked { a: 987, b: Unpacked { x: 876, y: 765, z: 654 }, c: Unpacked { x: 543, y: 432, z: 321 }, d: 210 } +// lldbg-check:[...]$3 = UnpackedInPacked { a: 987, b: Unpacked { x: 876, y: 765, z: 654 }, c: Unpacked { x: 543, y: 432, z: 321 }, d: 210 } +// lldbr-check:(packed_struct_with_destructor::UnpackedInPacked) unpackedInPacked = UnpackedInPacked { a: 987, b: Unpacked { x: 876, y: 765, z: 654 }, c: Unpacked { x: 543, y: 432, z: 321 }, d: 210 } // lldb-command:print packedInPackedWithDrop -// lldb-check:[...]$4 = PackedInPackedWithDrop { a: 11, b: Packed { x: 22, y: 33, z: 44 }, c: 55, d: Packed { x: 66, y: 77, z: 88 } } +// lldbg-check:[...]$4 = PackedInPackedWithDrop { a: 11, b: Packed { x: 22, y: 33, z: 44 }, c: 55, d: Packed { x: 66, y: 77, z: 88 } } +// lldbr-check:(packed_struct_with_destructor::PackedInPackedWithDrop) packedInPackedWithDrop = PackedInPackedWithDrop { a: 11, b: Packed { x: 22, y: 33, z: 44 }, c: 55, d: Packed { x: 66, y: 77, z: 88 } } // lldb-command:print packedInUnpackedWithDrop -// lldb-check:[...]$5 = PackedInUnpackedWithDrop { a: -11, b: Packed { x: -22, y: -33, z: -44 }, c: -55, d: Packed { x: -66, y: -77, z: -88 } } +// lldbg-check:[...]$5 = PackedInUnpackedWithDrop { a: -11, b: Packed { x: -22, y: -33, z: -44 }, c: -55, d: Packed { x: -66, y: -77, z: -88 } } +// lldbr-check:(packed_struct_with_destructor::PackedInUnpackedWithDrop) packedInUnpackedWithDrop = PackedInUnpackedWithDrop { a: -11, b: Packed { x: -22, y: -33, z: -44 }, c: -55, d: Packed { x: -66, y: -77, z: -88 } } // lldb-command:print unpackedInPackedWithDrop -// lldb-check:[...]$6 = UnpackedInPackedWithDrop { a: 98, b: Unpacked { x: 87, y: 76, z: 65 }, c: Unpacked { x: 54, y: 43, z: 32 }, d: 21 } +// lldbg-check:[...]$6 = UnpackedInPackedWithDrop { a: 98, b: Unpacked { x: 87, y: 76, z: 65 }, c: Unpacked { x: 54, y: 43, z: 32 }, d: 21 } +// lldbr-check:(packed_struct_with_destructor::UnpackedInPackedWithDrop) unpackedInPackedWithDrop = UnpackedInPackedWithDrop { a: 98, b: Unpacked { x: 87, y: 76, z: 65 }, c: Unpacked { x: 54, y: 43, z: 32 }, d: 21 } // lldb-command:print deeplyNested -// lldb-check:[...]$7 = DeeplyNested { a: PackedInPacked { a: 1, b: Packed { x: 2, y: 3, z: 4 }, c: 5, d: Packed { x: 6, y: 7, z: 8 } }, b: UnpackedInPackedWithDrop { a: 9, b: Unpacked { x: 10, y: 11, z: 12 }, c: Unpacked { x: 13, y: 14, z: 15 }, d: 16 }, c: PackedInUnpacked { a: 17, b: Packed { x: 18, y: 19, z: 20 }, c: 21, d: Packed { x: 22, y: 23, z: 24 } }, d: PackedInUnpackedWithDrop { a: 25, b: Packed { x: 26, y: 27, z: 28 }, c: 29, d: Packed { x: 30, y: 31, z: 32 } }, e: UnpackedInPacked { a: 33, b: Unpacked { x: 34, y: 35, z: 36 }, c: Unpacked { x: 37, y: 38, z: 39 }, d: 40 }, f: PackedInPackedWithDrop { a: 41, b: Packed { x: 42, y: 43, z: 44 }, c: 45, d: Packed { x: 46, y: 47, z: 48 } } } +// lldbg-check:[...]$7 = DeeplyNested { a: PackedInPacked { a: 1, b: Packed { x: 2, y: 3, z: 4 }, c: 5, d: Packed { x: 6, y: 7, z: 8 } }, b: UnpackedInPackedWithDrop { a: 9, b: Unpacked { x: 10, y: 11, z: 12 }, c: Unpacked { x: 13, y: 14, z: 15 }, d: 16 }, c: PackedInUnpacked { a: 17, b: Packed { x: 18, y: 19, z: 20 }, c: 21, d: Packed { x: 22, y: 23, z: 24 } }, d: PackedInUnpackedWithDrop { a: 25, b: Packed { x: 26, y: 27, z: 28 }, c: 29, d: Packed { x: 30, y: 31, z: 32 } }, e: UnpackedInPacked { a: 33, b: Unpacked { x: 34, y: 35, z: 36 }, c: Unpacked { x: 37, y: 38, z: 39 }, d: 40 }, f: PackedInPackedWithDrop { a: 41, b: Packed { x: 42, y: 43, z: 44 }, c: 45, d: Packed { x: 46, y: 47, z: 48 } } } +// lldbr-check:(packed_struct_with_destructor::DeeplyNested) deeplyNested = DeeplyNested { a: PackedInPacked { a: 1, b: Packed { x: 2, y: 3, z: 4 }, c: 5, d: Packed { x: 6, y: 7, z: 8 } }, b: UnpackedInPackedWithDrop { a: 9, b: Unpacked { x: 10, y: 11, z: 12 }, c: Unpacked { x: 13, y: 14, z: 15 }, d: 16 }, c: PackedInUnpacked { a: 17, b: Packed { x: 18, y: 19, z: 20 }, c: 21, d: Packed { x: 22, y: 23, z: 24 } }, d: PackedInUnpackedWithDrop { a: 25, b: Packed { x: 26, y: 27, z: 28 }, c: 29, d: Packed { x: 30, y: 31, z: 32 } }, e: UnpackedInPacked { a: 33, b: Unpacked { x: 34, y: 35, z: 36 }, c: Unpacked { x: 37, y: 38, z: 39 }, d: 40 }, f: PackedInPackedWithDrop { a: 41, b: Packed { x: 42, y: 43, z: 44 }, c: 45, d: Packed { x: 46, y: 47, z: 48 } } } #![allow(unused_variables)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/self-in-default-method.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/self-in-default-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/self-in-default-method.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/self-in-default-method.rs 2018-12-04 23:41:40.000000000 +0000 @@ -73,47 +73,62 @@ // STACK BY REF // lldb-command:print *self -// lldb-check:[...]$0 = Struct { x: 100 } +// lldbg-check:[...]$0 = Struct { x: 100 } +// lldbr-check:(self_in_default_method::Struct) *self = Struct { x: 100 } // lldb-command:print arg1 -// lldb-check:[...]$1 = -1 +// lldbg-check:[...]$1 = -1 +// lldbr-check:(isize) arg1 = -1 // lldb-command:print arg2 -// lldb-check:[...]$2 = -2 +// lldbg-check:[...]$2 = -2 +// lldbr-check:(isize) arg2 = -2 // lldb-command:continue // STACK BY VAL // lldb-command:print self -// lldb-check:[...]$3 = Struct { x: 100 } +// lldbg-check:[...]$3 = Struct { x: 100 } +// lldbr-check:(self_in_default_method::Struct) self = Struct { x: 100 } // lldb-command:print arg1 -// lldb-check:[...]$4 = -3 +// lldbg-check:[...]$4 = -3 +// lldbr-check:(isize) arg1 = -3 // lldb-command:print arg2 -// lldb-check:[...]$5 = -4 +// lldbg-check:[...]$5 = -4 +// lldbr-check:(isize) arg2 = -4 // lldb-command:continue // OWNED BY REF // lldb-command:print *self -// lldb-check:[...]$6 = Struct { x: 200 } +// lldbg-check:[...]$6 = Struct { x: 200 } +// lldbr-check:(self_in_default_method::Struct) *self = Struct { x: 200 } // lldb-command:print arg1 -// lldb-check:[...]$7 = -5 +// lldbg-check:[...]$7 = -5 +// lldbr-check:(isize) arg1 = -5 // lldb-command:print arg2 -// lldb-check:[...]$8 = -6 +// lldbg-check:[...]$8 = -6 +// lldbr-check:(isize) arg2 = -6 // lldb-command:continue // OWNED BY VAL // lldb-command:print self -// lldb-check:[...]$9 = Struct { x: 200 } +// lldbg-check:[...]$9 = Struct { x: 200 } +// lldbr-check:(self_in_default_method::Struct) self = Struct { x: 200 } // lldb-command:print arg1 -// lldb-check:[...]$10 = -7 +// lldbg-check:[...]$10 = -7 +// lldbr-check:(isize) arg1 = -7 // lldb-command:print arg2 -// lldb-check:[...]$11 = -8 +// lldbg-check:[...]$11 = -8 +// lldbr-check:(isize) arg2 = -8 // lldb-command:continue // OWNED MOVED // lldb-command:print *self -// lldb-check:[...]$12 = Struct { x: 200 } +// lldbg-check:[...]$12 = Struct { x: 200 } +// lldbr-check:(self_in_default_method::Struct) *self = Struct { x: 200 } // lldb-command:print arg1 -// lldb-check:[...]$13 = -9 +// lldbg-check:[...]$13 = -9 +// lldbr-check:(isize) arg1 = -9 // lldb-command:print arg2 -// lldb-check:[...]$14 = -10 +// lldbg-check:[...]$14 = -10 +// lldbr-check:(isize) arg2 = -10 // lldb-command:continue #![feature(box_syntax)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/self-in-generic-default-method.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/self-in-generic-default-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/self-in-generic-default-method.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/self-in-generic-default-method.rs 2018-12-04 23:41:40.000000000 +0000 @@ -73,47 +73,62 @@ // STACK BY REF // lldb-command:print *self -// lldb-check:[...]$0 = Struct { x: 987 } +// lldbg-check:[...]$0 = Struct { x: 987 } +// lldbr-check:(self_in_generic_default_method::Struct) *self = Struct { x: 987 } // lldb-command:print arg1 -// lldb-check:[...]$1 = -1 +// lldbg-check:[...]$1 = -1 +// lldbr-check:(isize) arg1 = -1 // lldb-command:print arg2 -// lldb-check:[...]$2 = 2 +// lldbg-check:[...]$2 = 2 +// lldbr-check:(u16) arg2 = 2 // lldb-command:continue // STACK BY VAL // lldb-command:print self -// lldb-check:[...]$3 = Struct { x: 987 } +// lldbg-check:[...]$3 = Struct { x: 987 } +// lldbr-check:(self_in_generic_default_method::Struct) self = Struct { x: 987 } // lldb-command:print arg1 -// lldb-check:[...]$4 = -3 +// lldbg-check:[...]$4 = -3 +// lldbr-check:(isize) arg1 = -3 // lldb-command:print arg2 -// lldb-check:[...]$5 = -4 +// lldbg-check:[...]$5 = -4 +// lldbr-check:(i16) arg2 = -4 // lldb-command:continue // OWNED BY REF // lldb-command:print *self -// lldb-check:[...]$6 = Struct { x: 879 } +// lldbg-check:[...]$6 = Struct { x: 879 } +// lldbr-check:(self_in_generic_default_method::Struct) *self = Struct { x: 879 } // lldb-command:print arg1 -// lldb-check:[...]$7 = -5 +// lldbg-check:[...]$7 = -5 +// lldbr-check:(isize) arg1 = -5 // lldb-command:print arg2 -// lldb-check:[...]$8 = -6 +// lldbg-check:[...]$8 = -6 +// lldbr-check:(i32) arg2 = -6 // lldb-command:continue // OWNED BY VAL // lldb-command:print self -// lldb-check:[...]$9 = Struct { x: 879 } +// lldbg-check:[...]$9 = Struct { x: 879 } +// lldbr-check:(self_in_generic_default_method::Struct) self = Struct { x: 879 } // lldb-command:print arg1 -// lldb-check:[...]$10 = -7 +// lldbg-check:[...]$10 = -7 +// lldbr-check:(isize) arg1 = -7 // lldb-command:print arg2 -// lldb-check:[...]$11 = -8 +// lldbg-check:[...]$11 = -8 +// lldbr-check:(i64) arg2 = -8 // lldb-command:continue // OWNED MOVED // lldb-command:print *self -// lldb-check:[...]$12 = Struct { x: 879 } +// lldbg-check:[...]$12 = Struct { x: 879 } +// lldbr-check:(self_in_generic_default_method::Struct) *self = Struct { x: 879 } // lldb-command:print arg1 -// lldb-check:[...]$13 = -9 +// lldbg-check:[...]$13 = -9 +// lldbr-check:(isize) arg1 = -9 // lldb-command:print arg2 -// lldb-check:[...]$14 = -10.5 +// lldbg-check:[...]$14 = -10.5 +// lldbr-check:(f32) arg2 = -10.5 // lldb-command:continue #![feature(box_syntax)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/shadowed-argument.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/shadowed-argument.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/shadowed-argument.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/shadowed-argument.rs 2018-12-04 23:41:40.000000000 +0000 @@ -40,21 +40,27 @@ // lldb-command:run // lldb-command:print x -// lldb-check:[...]$0 = false +// lldbg-check:[...]$0 = false +// lldbr-check:(bool) x = false // lldb-command:print y -// lldb-check:[...]$1 = true +// lldbg-check:[...]$1 = true +// lldbr-check:(bool) y = true // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$2 = 10 +// lldbg-check:[...]$2 = 10 +// lldbr-check:(i32) x = 10 // lldb-command:print y -// lldb-check:[...]$3 = true +// lldbg-check:[...]$3 = true +// lldbr-check:(bool) y = true // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$4 = 10.5 +// lldbg-check:[...]$4 = 10.5 +// lldbr-check:(f64) x = 10.5 // lldb-command:print y -// lldb-check:[...]$5 = 20 +// lldbg-check:[...]$5 = 20 +// lldbr-check:(i32) y = 20 // lldb-command:continue diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/shadowed-variable.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/shadowed-variable.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/shadowed-variable.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/shadowed-variable.rs 2018-12-04 23:41:40.000000000 +0000 @@ -50,33 +50,43 @@ // lldb-command:run // lldb-command:print x -// lldb-check:[...]$0 = false +// lldbg-check:[...]$0 = false +// lldbr-check:(bool) x = false // lldb-command:print y -// lldb-check:[...]$1 = true +// lldbg-check:[...]$1 = true +// lldbr-check:(bool) y = true // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$2 = 10 +// lldbg-check:[...]$2 = 10 +// lldbr-check:(i32) x = 10 // lldb-command:print y -// lldb-check:[...]$3 = true +// lldbg-check:[...]$3 = true +// lldbr-check:(bool) y = true // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$4 = 10.5 +// lldbg-check:[...]$4 = 10.5 +// lldbr-check:(f64) x = 10.5 // lldb-command:print y -// lldb-check:[...]$5 = 20 +// lldbg-check:[...]$5 = 20 +// lldbr-check:(i32) y = 20 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$6 = 10.5 +// lldbg-check:[...]$6 = 10.5 +// lldbr-check:(f64) x = 10.5 // lldb-command:print y -// lldb-check:[...]$7 = 20 +// lldbg-check:[...]$7 = 20 +// lldbr-check:(i32) y = 20 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$8 = 11.5 +// lldbg-check:[...]$8 = 11.5 +// lldbr-check:(f64) x = 11.5 // lldb-command:print y -// lldb-check:[...]$9 = 20 +// lldbg-check:[...]$9 = 20 +// lldbr-check:(i32) y = 20 // lldb-command:continue #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/simple-lexical-scope.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/simple-lexical-scope.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/simple-lexical-scope.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/simple-lexical-scope.rs 2018-12-04 23:41:40.000000000 +0000 @@ -50,31 +50,38 @@ // lldb-command:run // lldb-command:print x -// lldb-check:[...]$0 = false +// lldbg-check:[...]$0 = false +// lldbr-check:(bool) x = false // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$1 = false +// lldbg-check:[...]$1 = false +// lldbr-check:(bool) x = false // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$2 = 10 +// lldbg-check:[...]$2 = 10 +// lldbr-check:(i32) x = 10 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$3 = 10 +// lldbg-check:[...]$3 = 10 +// lldbr-check:(i32) x = 10 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$4 = 10.5 +// lldbg-check:[...]$4 = 10.5 +// lldbr-check:(f64) x = 10.5 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$5 = 10 +// lldbg-check:[...]$5 = 10 +// lldbr-check:(i32) x = 10 // lldb-command:continue // lldb-command:print x -// lldb-check:[...]$6 = false +// lldbg-check:[...]$6 = false +// lldbr-check:(bool) x = false // lldb-command:continue diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/simple-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/simple-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/simple-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/simple-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-tidy-linelength + // min-lldb-version: 310 // ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 @@ -108,22 +110,28 @@ // lldb-command:run // lldb-command:print no_padding16 -// lldb-check:[...]$0 = NoPadding16 { x: 10000, y: -10001 } +// lldbg-check:[...]$0 = NoPadding16 { x: 10000, y: -10001 } +// lldbr-check:(simple_struct::NoPadding16) no_padding16 = NoPadding16 { x: 10000, y: -10001 } // lldb-command:print no_padding32 -// lldb-check:[...]$1 = NoPadding32 { x: -10002, y: -10003.5, z: 10004 } +// lldbg-check:[...]$1 = NoPadding32 { x: -10002, y: -10003.5, z: 10004 } +// lldbr-check:(simple_struct::NoPadding32) no_padding32 = NoPadding32 { x: -10002, y: -10003.5, z: 10004 } // lldb-command:print no_padding64 -// lldb-check:[...]$2 = NoPadding64 { x: -10005.5, y: 10006, z: 10007 } +// lldbg-check:[...]$2 = NoPadding64 { x: -10005.5, y: 10006, z: 10007 } +// lldbr-check:(simple_struct::NoPadding64) no_padding64 = NoPadding64 { x: -10005.5, y: 10006, z: 10007 } // lldb-command:print no_padding163264 -// lldb-check:[...]$3 = NoPadding163264 { a: -10008, b: 10009, c: 10010, d: 10011 } +// lldbg-check:[...]$3 = NoPadding163264 { a: -10008, b: 10009, c: 10010, d: 10011 } +// lldbr-check:(simple_struct::NoPadding163264) no_padding163264 = NoPadding163264 { a: -10008, b: 10009, c: 10010, d: 10011 } // lldb-command:print internal_padding -// lldb-check:[...]$4 = InternalPadding { x: 10012, y: -10013 } +// lldbg-check:[...]$4 = InternalPadding { x: 10012, y: -10013 } +// lldbr-check:(simple_struct::InternalPadding) internal_padding = InternalPadding { x: 10012, y: -10013 } // lldb-command:print padding_at_end -// lldb-check:[...]$5 = PaddingAtEnd { x: -10014, y: 10015 } +// lldbg-check:[...]$5 = PaddingAtEnd { x: -10014, y: 10015 } +// lldbr-check:(simple_struct::PaddingAtEnd) padding_at_end = PaddingAtEnd { x: -10014, y: 10015 } #![allow(unused_variables)] #![allow(dead_code)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/simple-tuple.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/simple-tuple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/simple-tuple.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/simple-tuple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -110,21 +110,28 @@ // lldb-command:run // lldb-command:print/d noPadding8 -// lldb-check:[...]$0 = (-100, 100) +// lldbg-check:[...]$0 = (-100, 100) +// lldbr-check:((i8, u8)) noPadding8 = { = -100 -100 = 100 100 } // lldb-command:print noPadding16 -// lldb-check:[...]$1 = (0, 1, 2) +// lldbg-check:[...]$1 = (0, 1, 2) +// lldbr-check:((i16, i16, u16)) noPadding16 = { = 0 = 1 = 2 } // lldb-command:print noPadding32 -// lldb-check:[...]$2 = (3, 4.5, 5) +// lldbg-check:[...]$2 = (3, 4.5, 5) +// lldbr-check:((i32, f32, u32)) noPadding32 = { = 3 = 4.5 = 5 } // lldb-command:print noPadding64 -// lldb-check:[...]$3 = (6, 7.5, 8) +// lldbg-check:[...]$3 = (6, 7.5, 8) +// lldbr-check:((i64, f64, u64)) noPadding64 = { = 6 = 7.5 = 8 } // lldb-command:print internalPadding1 -// lldb-check:[...]$4 = (9, 10) +// lldbg-check:[...]$4 = (9, 10) +// lldbr-check:((i16, i32)) internalPadding1 = { = 9 = 10 } // lldb-command:print internalPadding2 -// lldb-check:[...]$5 = (11, 12, 13, 14) +// lldbg-check:[...]$5 = (11, 12, 13, 14) +// lldbr-check:((i16, i32, u32, u64)) internalPadding2 = { = 11 = 12 = 13 = 14 } // lldb-command:print paddingAtEnd -// lldb-check:[...]$6 = (15, 16) +// lldbg-check:[...]$6 = (15, 16) +// lldbr-check:((i32, i16)) paddingAtEnd = { = 15 = 16 } #![allow(unused_variables)] #![allow(dead_code)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/static-method-on-struct-and-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/static-method-on-struct-and-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/static-method-on-struct-and-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/static-method-on-struct-and-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -39,18 +39,23 @@ // STRUCT // lldb-command:print arg1 -// lldb-check:[...]$0 = 1 +// lldbg-check:[...]$0 = 1 +// lldbr-check:(isize) arg1 = 1 // lldb-command:print arg2 -// lldb-check:[...]$1 = 2 +// lldbg-check:[...]$1 = 2 +// lldbr-check:(isize) arg2 = 2 // lldb-command:continue // ENUM // lldb-command:print arg1 -// lldb-check:[...]$2 = -3 +// lldbg-check:[...]$2 = -3 +// lldbr-check:(isize) arg1 = -3 // lldb-command:print arg2 -// lldb-check:[...]$3 = 4.5 +// lldbg-check:[...]$3 = 4.5 +// lldbr-check:(f64) arg2 = 4.5 // lldb-command:print arg3 -// lldb-check:[...]$4 = 5 +// lldbg-check:[...]$4 = 5 +// lldbr-check:(usize) arg3 = 5 // lldb-command:continue #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/struct-in-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/struct-in-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/struct-in-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/struct-in-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -35,28 +35,36 @@ // lldb-command:run // lldb-command:print three_simple_structs -// lldb-check:[...]$0 = ThreeSimpleStructs { x: Simple { x: 1 }, y: Simple { x: 2 }, z: Simple { x: 3 } } +// lldbg-check:[...]$0 = ThreeSimpleStructs { x: Simple { x: 1 }, y: Simple { x: 2 }, z: Simple { x: 3 } } +// lldbr-check:(struct_in_struct::ThreeSimpleStructs) three_simple_structs = ThreeSimpleStructs { x: Simple { x: 1 }, y: Simple { x: 2 }, z: Simple { x: 3 } } // lldb-command:print internal_padding_parent -// lldb-check:[...]$1 = InternalPaddingParent { x: InternalPadding { x: 4, y: 5 }, y: InternalPadding { x: 6, y: 7 }, z: InternalPadding { x: 8, y: 9 } } +// lldbg-check:[...]$1 = InternalPaddingParent { x: InternalPadding { x: 4, y: 5 }, y: InternalPadding { x: 6, y: 7 }, z: InternalPadding { x: 8, y: 9 } } +// lldbr-check:(struct_in_struct::InternalPaddingParent) internal_padding_parent = InternalPaddingParent { x: InternalPadding { x: 4, y: 5 }, y: InternalPadding { x: 6, y: 7 }, z: InternalPadding { x: 8, y: 9 } } // lldb-command:print padding_at_end_parent -// lldb-check:[...]$2 = PaddingAtEndParent { x: PaddingAtEnd { x: 10, y: 11 }, y: PaddingAtEnd { x: 12, y: 13 }, z: PaddingAtEnd { x: 14, y: 15 } } +// lldbg-check:[...]$2 = PaddingAtEndParent { x: PaddingAtEnd { x: 10, y: 11 }, y: PaddingAtEnd { x: 12, y: 13 }, z: PaddingAtEnd { x: 14, y: 15 } } +// lldbr-check:(struct_in_struct::PaddingAtEndParent) padding_at_end_parent = PaddingAtEndParent { x: PaddingAtEnd { x: 10, y: 11 }, y: PaddingAtEnd { x: 12, y: 13 }, z: PaddingAtEnd { x: 14, y: 15 } } // lldb-command:print mixed -// lldb-check:[...]$3 = Mixed { x: PaddingAtEnd { x: 16, y: 17 }, y: InternalPadding { x: 18, y: 19 }, z: Simple { x: 20 }, w: 21 } +// lldbg-check:[...]$3 = Mixed { x: PaddingAtEnd { x: 16, y: 17 }, y: InternalPadding { x: 18, y: 19 }, z: Simple { x: 20 }, w: 21 } +// lldbr-check:(struct_in_struct::Mixed) mixed = Mixed { x: PaddingAtEnd { x: 16, y: 17 }, y: InternalPadding { x: 18, y: 19 }, z: Simple { x: 20 }, w: 21 } // lldb-command:print bag -// lldb-check:[...]$4 = Bag { x: Simple { x: 22 } } +// lldbg-check:[...]$4 = Bag { x: Simple { x: 22 } } +// lldbr-check:(struct_in_struct::Bag) bag = Bag { x: Simple { x: 22 } } // lldb-command:print bag_in_bag -// lldb-check:[...]$5 = BagInBag { x: Bag { x: Simple { x: 23 } } } +// lldbg-check:[...]$5 = BagInBag { x: Bag { x: Simple { x: 23 } } } +// lldbr-check:(struct_in_struct::BagInBag) bag_in_bag = BagInBag { x: Bag { x: Simple { x: 23 } } } // lldb-command:print tjo -// lldb-check:[...]$6 = ThatsJustOverkill { x: BagInBag { x: Bag { x: Simple { x: 24 } } } } +// lldbg-check:[...]$6 = ThatsJustOverkill { x: BagInBag { x: Bag { x: Simple { x: 24 } } } } +// lldbr-check:(struct_in_struct::ThatsJustOverkill) tjo = ThatsJustOverkill { x: BagInBag { x: Bag { x: Simple { x: 24 } } } } // lldb-command:print tree -// lldb-check:[...]$7 = Tree { x: Simple { x: 25 }, y: InternalPaddingParent { x: InternalPadding { x: 26, y: 27 }, y: InternalPadding { x: 28, y: 29 }, z: InternalPadding { x: 30, y: 31 } }, z: BagInBag { x: Bag { x: Simple { x: 32 } } } } +// lldbg-check:[...]$7 = Tree { x: Simple { x: 25 }, y: InternalPaddingParent { x: InternalPadding { x: 26, y: 27 }, y: InternalPadding { x: 28, y: 29 }, z: InternalPadding { x: 30, y: 31 } }, z: BagInBag { x: Bag { x: Simple { x: 32 } } } } +// lldbr-check:(struct_in_struct::Tree) tree = Tree { x: Simple { x: 25 }, y: InternalPaddingParent { x: InternalPadding { x: 26, y: 27 }, y: InternalPadding { x: 28, y: 29 }, z: InternalPadding { x: 30, y: 31 } }, z: BagInBag { x: Bag { x: Simple { x: 32 } } } } #![allow(unused_variables)] #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/struct-namespace.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/struct-namespace.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/struct-namespace.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/struct-namespace.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,14 +16,18 @@ // lldb-command:run // lldb-command:p struct1 -// lldb-check:(struct_namespace::Struct1) $0 = [...] +// lldbg-check:(struct_namespace::Struct1) $0 = [...] +// lldbr-check:(struct_namespace::Struct1) struct1 = Struct1 { a: 0, b: 1 } // lldb-command:p struct2 -// lldb-check:(struct_namespace::Struct2) $1 = [...] +// lldbg-check:(struct_namespace::Struct2) $1 = [...] +// lldbr-check:(struct_namespace::Struct2) struct2 = { = 2 } // lldb-command:p mod1_struct1 -// lldb-check:(struct_namespace::mod1::Struct1) $2 = [...] +// lldbg-check:(struct_namespace::mod1::Struct1) $2 = [...] +// lldbr-check:(struct_namespace::mod1::Struct1) mod1_struct1 = Struct1 { a: 3, b: 4 } // lldb-command:p mod1_struct2 -// lldb-check:(struct_namespace::mod1::Struct2) $3 = [...] +// lldbg-check:(struct_namespace::mod1::Struct2) $3 = [...] +// lldbr-check:(struct_namespace::mod1::Struct2) mod1_struct2 = { = 5 } #![allow(unused_variables)] #![allow(dead_code)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/struct-style-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/struct-style-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/struct-style-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/struct-style-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -41,16 +41,20 @@ // lldb-command:run // lldb-command:print case1 -// lldb-check:[...]$0 = Case1 { a: 0, b: 31868, c: 31868, d: 31868, e: 31868 } +// lldbg-check:[...]$0 = Case1 { a: 0, b: 31868, c: 31868, d: 31868, e: 31868 } +// lldbr-check:(struct_style_enum::Regular::Case1) case1 = { a = 0 b = 31868 c = 31868 d = 31868 e = 31868 } // lldb-command:print case2 -// lldb-check:[...]$1 = Case2 { a: 0, b: 286331153, c: 286331153 } +// lldbg-check:[...]$1 = Case2 { a: 0, b: 286331153, c: 286331153 } +// lldbr-check:(struct_style_enum::Regular::Case2) case2 = Case2 { struct_style_enum::Regular::Case1: 0, struct_style_enum::Regular::Case2: 286331153, struct_style_enum::Regular::Case3: 286331153 } // lldb-command:print case3 -// lldb-check:[...]$2 = Case3 { a: 0, b: 6438275382588823897 } +// lldbg-check:[...]$2 = Case3 { a: 0, b: 6438275382588823897 } +// lldbr-check:(struct_style_enum::Regular::Case3) case3 = Case3 { struct_style_enum::Regular::Case1: 0, struct_style_enum::Regular::Case2: 6438275382588823897 } // lldb-command:print univariant -// lldb-check:[...]$3 = TheOnlyCase { a: -1 } +// lldbg-check:[...]$3 = TheOnlyCase { a: -1 } +// lldbr-check:(struct_style_enum::Univariant) univariant = Univariant { struct_style_enum::TheOnlyCase: TheOnlyCase { a: -1 } } #![allow(unused_variables)] #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/struct-with-destructor.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/struct-with-destructor.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/struct-with-destructor.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/struct-with-destructor.rs 2018-12-04 23:41:40.000000000 +0000 @@ -38,16 +38,20 @@ // lldb-command:run // lldb-command:print simple -// lldb-check:[...]$0 = WithDestructor { x: 10, y: 20 } +// lldbg-check:[...]$0 = WithDestructor { x: 10, y: 20 } +// lldbr-check:(struct_with_destructor::WithDestructor) simple = WithDestructor { x: 10, y: 20 } // lldb-command:print noDestructor -// lldb-check:[...]$1 = NoDestructorGuarded { a: NoDestructor { x: 10, y: 20 }, guard: -1 } +// lldbg-check:[...]$1 = NoDestructorGuarded { a: NoDestructor { x: 10, y: 20 }, guard: -1 } +// lldbr-check:(struct_with_destructor::NoDestructorGuarded) noDestructor = NoDestructorGuarded { a: NoDestructor { x: 10, y: 20 }, guard: -1 } // lldb-command:print withDestructor -// lldb-check:[...]$2 = WithDestructorGuarded { a: WithDestructor { x: 10, y: 20 }, guard: -1 } +// lldbg-check:[...]$2 = WithDestructorGuarded { a: WithDestructor { x: 10, y: 20 }, guard: -1 } +// lldbr-check:(struct_with_destructor::WithDestructorGuarded) withDestructor = WithDestructorGuarded { a: WithDestructor { x: 10, y: 20 }, guard: -1 } // lldb-command:print nested -// lldb-check:[...]$3 = NestedOuter { a: NestedInner { a: WithDestructor { x: 7890, y: 9870 } } } +// lldbg-check:[...]$3 = NestedOuter { a: NestedInner { a: WithDestructor { x: 7890, y: 9870 } } } +// lldbr-check:(struct_with_destructor::NestedOuter) nested = NestedOuter { a: NestedInner { a: WithDestructor { x: 7890, y: 9870 } } } #![allow(unused_variables)] #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/tuple-in-tuple.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/tuple-in-tuple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/tuple-in-tuple.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/tuple-in-tuple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -46,21 +46,28 @@ // lldb-command:run // lldb-command:print no_padding1 -// lldb-check:[...]$0 = ((0, 1), 2, 3) +// lldbg-check:[...]$0 = ((0, 1), 2, 3) +// lldbr-check:(((u32, u32), u32, u32)) no_padding1 = { = { = 0 = 1 } = 2 = 3 } // lldb-command:print no_padding2 -// lldb-check:[...]$1 = (4, (5, 6), 7) +// lldbg-check:[...]$1 = (4, (5, 6), 7) +// lldbr-check:((u32, (u32, u32), u32)) no_padding2 = { = 4 = { = 5 = 6 } = 7 } // lldb-command:print no_padding3 -// lldb-check:[...]$2 = (8, 9, (10, 11)) +// lldbg-check:[...]$2 = (8, 9, (10, 11)) +// lldbr-check:((u32, u32, (u32, u32))) no_padding3 = { = 8 = 9 = { = 10 = 11 } } // lldb-command:print internal_padding1 -// lldb-check:[...]$3 = (12, (13, 14)) +// lldbg-check:[...]$3 = (12, (13, 14)) +// lldbr-check:((i16, (i32, i32))) internal_padding1 = { = 12 = { = 13 = 14 } } // lldb-command:print internal_padding2 -// lldb-check:[...]$4 = (15, (16, 17)) +// lldbg-check:[...]$4 = (15, (16, 17)) +// lldbr-check:((i16, (i16, i32))) internal_padding2 = { = 15 = { = 16 = 17 } } // lldb-command:print padding_at_end1 -// lldb-check:[...]$5 = (18, (19, 20)) +// lldbg-check:[...]$5 = (18, (19, 20)) +// lldbr-check:((i32, (i32, i16))) padding_at_end1 = { = 18 = { = 19 = 20 } } // lldb-command:print padding_at_end2 -// lldb-check:[...]$6 = ((21, 22), 23) +// lldbg-check:[...]$6 = ((21, 22), 23) +// lldbr-check:(((i32, i16), i32)) padding_at_end2 = { = { = 21 = 22 } = 23 } #![allow(unused_variables)] #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/tuple-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/tuple-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/tuple-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/tuple-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-tidy-linelength + // min-lldb-version: 310 // compile-flags:-g @@ -46,22 +48,28 @@ // lldb-command:run // lldb-command:print no_padding16 -// lldb-check:[...]$0 = NoPadding16(10000, -10001) +// lldbg-check:[...]$0 = NoPadding16(10000, -10001) +// lldbr-check:(tuple_struct::NoPadding16) no_padding16 = { = 10000 = -10001 } // lldb-command:print no_padding32 -// lldb-check:[...]$1 = NoPadding32(-10002, -10003.5, 10004) +// lldbg-check:[...]$1 = NoPadding32(-10002, -10003.5, 10004) +// lldbr-check:(tuple_struct::NoPadding32) no_padding32 = { = -10002 = -10003.5 = 10004 } // lldb-command:print no_padding64 -// lldb-check:[...]$2 = NoPadding64(-10005.5, 10006, 10007) +// lldbg-check:[...]$2 = NoPadding64(-10005.5, 10006, 10007) +// lldbr-check:(tuple_struct::NoPadding64) no_padding64 = { = -10005.5 = 10006 = 10007 } // lldb-command:print no_padding163264 -// lldb-check:[...]$3 = NoPadding163264(-10008, 10009, 10010, 10011) +// lldbg-check:[...]$3 = NoPadding163264(-10008, 10009, 10010, 10011) +// lldbr-check:(tuple_struct::NoPadding163264) no_padding163264 = { = -10008 = 10009 = 10010 = 10011 } // lldb-command:print internal_padding -// lldb-check:[...]$4 = InternalPadding(10012, -10013) +// lldbg-check:[...]$4 = InternalPadding(10012, -10013) +// lldbr-check:(tuple_struct::InternalPadding) internal_padding = { = 10012 = -10013 } // lldb-command:print padding_at_end -// lldb-check:[...]$5 = PaddingAtEnd(-10014, 10015) +// lldbg-check:[...]$5 = PaddingAtEnd(-10014, 10015) +// lldbr-check:(tuple_struct::PaddingAtEnd) padding_at_end = { = -10014 = 10015 } // This test case mainly makes sure that no field names are generated for tuple structs (as opposed // to all fields having the name ""). Otherwise they are handled the same a normal diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/tuple-style-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/tuple-style-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/tuple-style-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/tuple-style-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -41,16 +41,20 @@ // lldb-command:run // lldb-command:print case1 -// lldb-check:[...]$0 = Case1(0, 31868, 31868, 31868, 31868) +// lldbg-check:[...]$0 = Case1(0, 31868, 31868, 31868, 31868) +// lldbr-check:(tuple_style_enum::Regular::Case1) case1 = { = 0 = 31868 = 31868 = 31868 = 31868 } // lldb-command:print case2 -// lldb-check:[...]$1 = Case2(0, 286331153, 286331153) +// lldbg-check:[...]$1 = Case2(0, 286331153, 286331153) +// lldbr-check:(tuple_style_enum::Regular::Case2) case2 = Case2 { tuple_style_enum::Regular::Case1: 0, tuple_style_enum::Regular::Case2: 286331153, tuple_style_enum::Regular::Case3: 286331153 } // lldb-command:print case3 -// lldb-check:[...]$2 = Case3(0, 6438275382588823897) +// lldbg-check:[...]$2 = Case3(0, 6438275382588823897) +// lldbr-check:(tuple_style_enum::Regular::Case3) case3 = Case3 { tuple_style_enum::Regular::Case1: 0, tuple_style_enum::Regular::Case2: 6438275382588823897 } // lldb-command:print univariant -// lldb-check:[...]$3 = TheOnlyCase(-1) +// lldbg-check:[...]$3 = TheOnlyCase(-1) +// lldbr-check:(tuple_style_enum::Univariant) univariant = { tuple_style_enum::TheOnlyCase = { = -1 } } #![allow(unused_variables)] #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/union-smoke.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/union-smoke.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/union-smoke.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/union-smoke.rs 2018-12-04 23:41:40.000000000 +0000 @@ -29,9 +29,13 @@ // lldb-command:run // lldb-command:print u -// lldb-check:[...]$0 = U { a: ('\x02', '\x02'), b: 514 } -// lldb-command:print union_smoke::SU -// lldb-check:[...]$1 = U { a: ('\x01', '\x01'), b: 257 } +// lldbg-check:[...]$0 = U { a: ('\x02', '\x02'), b: 514 } +// lldbr-check:(union_smoke::U) u = { a = { = 2 = 2 } b = 514 } + +// Don't test this with rust-enabled lldb for now; see +// https://github.com/rust-lang-nursery/lldb/issues/18 +// lldbg-command:print union_smoke::SU +// lldbg-check:[...]$1 = U { a: ('\x01', '\x01'), b: 257 } #![allow(unused)] #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/unique-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/unique-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/unique-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/unique-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -36,13 +36,16 @@ // lldb-command:run // lldb-command:print *the_a -// lldb-check:[...]$0 = TheA { x: 0, y: 8970181431921507452 } +// lldbg-check:[...]$0 = TheA { x: 0, y: 8970181431921507452 } +// lldbr-check:(unique_enum::ABC::TheA) *the_a = TheA { unique_enum::ABC::TheA: 0, unique_enum::ABC::TheB: 8970181431921507452 } // lldb-command:print *the_b -// lldb-check:[...]$1 = TheB(0, 286331153, 286331153) +// lldbg-check:[...]$1 = TheB(0, 286331153, 286331153) +// lldbr-check:(unique_enum::ABC::TheB) *the_b = { = 0 = 286331153 = 286331153 } // lldb-command:print *univariant -// lldb-check:[...]$2 = TheOnlyCase(123234) +// lldbg-check:[...]$2 = TheOnlyCase(123234) +// lldbr-check:(unique_enum::Univariant) *univariant = { unique_enum::TheOnlyCase = { = 123234 } } #![allow(unused_variables)] #![feature(box_syntax)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/var-captured-in-nested-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/var-captured-in-nested-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/var-captured-in-nested-closure.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/var-captured-in-nested-closure.rs 2018-12-04 23:41:40.000000000 +0000 @@ -54,31 +54,43 @@ // lldb-command:run // lldb-command:print variable -// lldb-check:[...]$0 = 1 +// lldbg-check:[...]$0 = 1 +// lldbr-check:(isize) variable = 1 // lldb-command:print constant -// lldb-check:[...]$1 = 2 +// lldbg-check:[...]$1 = 2 +// lldbr-check:(isize) constant = 2 // lldb-command:print a_struct -// lldb-check:[...]$2 = Struct { a: -3, b: 4.5, c: 5 } +// lldbg-check:[...]$2 = Struct { a: -3, b: 4.5, c: 5 } +// lldbr-check:(var_captured_in_nested_closure::Struct) a_struct = Struct { a: -3, b: 4.5, c: 5 } // lldb-command:print *struct_ref -// lldb-check:[...]$3 = Struct { a: -3, b: 4.5, c: 5 } +// lldbg-check:[...]$3 = Struct { a: -3, b: 4.5, c: 5 } +// lldbr-check:(var_captured_in_nested_closure::Struct) *struct_ref = Struct { a: -3, b: 4.5, c: 5 } // lldb-command:print *owned -// lldb-check:[...]$4 = 6 +// lldbg-check:[...]$4 = 6 +// lldbr-check:(isize) *owned = 6 // lldb-command:print closure_local -// lldb-check:[...]$5 = 8 +// lldbg-check:[...]$5 = 8 +// lldbr-check:(isize) closure_local = 8 // lldb-command:continue // lldb-command:print variable -// lldb-check:[...]$6 = 1 +// lldbg-check:[...]$6 = 1 +// lldbr-check:(isize) variable = 1 // lldb-command:print constant -// lldb-check:[...]$7 = 2 +// lldbg-check:[...]$7 = 2 +// lldbr-check:(isize) constant = 2 // lldb-command:print a_struct -// lldb-check:[...]$8 = Struct { a: -3, b: 4.5, c: 5 } +// lldbg-check:[...]$8 = Struct { a: -3, b: 4.5, c: 5 } +// lldbr-check:(var_captured_in_nested_closure::Struct) a_struct = Struct { a: -3, b: 4.5, c: 5 } // lldb-command:print *struct_ref -// lldb-check:[...]$9 = Struct { a: -3, b: 4.5, c: 5 } +// lldbg-check:[...]$9 = Struct { a: -3, b: 4.5, c: 5 } +// lldbr-check:(var_captured_in_nested_closure::Struct) *struct_ref = Struct { a: -3, b: 4.5, c: 5 } // lldb-command:print *owned -// lldb-check:[...]$10 = 6 +// lldbg-check:[...]$10 = 6 +// lldbr-check:(isize) *owned = 6 // lldb-command:print closure_local -// lldb-check:[...]$11 = 8 +// lldbg-check:[...]$11 = 8 +// lldbr-check:(isize) closure_local = 8 // lldb-command:continue #![allow(unused_variables)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/var-captured-in-sendable-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/var-captured-in-sendable-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/var-captured-in-sendable-closure.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/var-captured-in-sendable-closure.rs 2018-12-04 23:41:40.000000000 +0000 @@ -34,11 +34,14 @@ // lldb-command:run // lldb-command:print constant -// lldb-check:[...]$0 = 1 +// lldbg-check:[...]$0 = 1 +// lldbr-check:(isize) constant = 1 // lldb-command:print a_struct -// lldb-check:[...]$1 = Struct { a: -2, b: 3.5, c: 4 } +// lldbg-check:[...]$1 = Struct { a: -2, b: 3.5, c: 4 } +// lldbr-check:(var_captured_in_sendable_closure::Struct) a_struct = Struct { a: -2, b: 3.5, c: 4 } // lldb-command:print *owned -// lldb-check:[...]$2 = 5 +// lldbg-check:[...]$2 = 5 +// lldbr-check:(isize) *owned = 5 #![allow(unused_variables)] #![feature(box_syntax)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/var-captured-in-stack-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/var-captured-in-stack-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/var-captured-in-stack-closure.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/var-captured-in-stack-closure.rs 2018-12-04 23:41:40.000000000 +0000 @@ -50,28 +50,38 @@ // lldb-command:run // lldb-command:print variable -// lldb-check:[...]$0 = 1 +// lldbg-check:[...]$0 = 1 +// lldbr-check:(isize) variable = 1 // lldb-command:print constant -// lldb-check:[...]$1 = 2 +// lldbg-check:[...]$1 = 2 +// lldbr-check:(isize) constant = 2 // lldb-command:print a_struct -// lldb-check:[...]$2 = Struct { a: -3, b: 4.5, c: 5 } +// lldbg-check:[...]$2 = Struct { a: -3, b: 4.5, c: 5 } +// lldbr-check:(var_captured_in_stack_closure::Struct) a_struct = Struct { a: -3, b: 4.5, c: 5 } // lldb-command:print *struct_ref -// lldb-check:[...]$3 = Struct { a: -3, b: 4.5, c: 5 } +// lldbg-check:[...]$3 = Struct { a: -3, b: 4.5, c: 5 } +// lldbr-check:(var_captured_in_stack_closure::Struct) *struct_ref = Struct { a: -3, b: 4.5, c: 5 } // lldb-command:print *owned -// lldb-check:[...]$4 = 6 +// lldbg-check:[...]$4 = 6 +// lldbr-check:(isize) *owned = 6 // lldb-command:continue // lldb-command:print variable -// lldb-check:[...]$5 = 2 +// lldbg-check:[...]$5 = 2 +// lldbr-check:(isize) variable = 2 // lldb-command:print constant -// lldb-check:[...]$6 = 2 +// lldbg-check:[...]$6 = 2 +// lldbr-check:(isize) constant = 2 // lldb-command:print a_struct -// lldb-check:[...]$7 = Struct { a: -3, b: 4.5, c: 5 } +// lldbg-check:[...]$7 = Struct { a: -3, b: 4.5, c: 5 } +// lldbr-check:(var_captured_in_stack_closure::Struct) a_struct = Struct { a: -3, b: 4.5, c: 5 } // lldb-command:print *struct_ref -// lldb-check:[...]$8 = Struct { a: -3, b: 4.5, c: 5 } +// lldbg-check:[...]$8 = Struct { a: -3, b: 4.5, c: 5 } +// lldbr-check:(var_captured_in_stack_closure::Struct) *struct_ref = Struct { a: -3, b: 4.5, c: 5 } // lldb-command:print *owned -// lldb-check:[...]$9 = 6 +// lldbg-check:[...]$9 = 6 +// lldbr-check:(isize) *owned = 6 #![feature(box_syntax)] #![allow(unused_variables)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/vec.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/vec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/vec.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/vec.rs 2018-12-04 23:41:40.000000000 +0000 @@ -28,7 +28,8 @@ // lldb-command:run // lldb-command:print a -// lldb-check:[...]$0 = [1, 2, 3] +// lldbg-check:[...]$0 = [1, 2, 3] +// lldbr-check:([i32; 3]) a = [1, 2, 3] #![allow(unused_variables)] #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/vec-slices.rs rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/vec-slices.rs --- rustc-1.30.0+dfsg1+llvm/src/test/debuginfo/vec-slices.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/debuginfo/vec-slices.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-tidy-linelength + // ignore-windows // ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155 // min-lldb-version: 310 @@ -80,22 +82,28 @@ // lldb-command:run // lldb-command:print empty -// lldb-check:[...]$0 = &[] +// lldbg-check:[...]$0 = &[] +// lldbr-check:(&[i64]) empty = &[] // lldb-command:print singleton -// lldb-check:[...]$1 = &[1] +// lldbg-check:[...]$1 = &[1] +// lldbr-check:(&[i64]) singleton = &[1] // lldb-command:print multiple -// lldb-check:[...]$2 = &[2, 3, 4, 5] +// lldbg-check:[...]$2 = &[2, 3, 4, 5] +// lldbr-check:(&[i64]) multiple = &[2, 3, 4, 5] // lldb-command:print slice_of_slice -// lldb-check:[...]$3 = &[3, 4] +// lldbg-check:[...]$3 = &[3, 4] +// lldbr-check:(&[i64]) slice_of_slice = &[3, 4] // lldb-command:print padded_tuple -// lldb-check:[...]$4 = &[(6, 7), (8, 9)] +// lldbg-check:[...]$4 = &[(6, 7), (8, 9)] +// lldbr-check:(&[(i32, i16)]) padded_tuple = { data_ptr = *0x555555554ff0 length = 2 } // lldb-command:print padded_struct -// lldb-check:[...]$5 = &[AStruct { x: 10, y: 11, z: 12 }, AStruct { x: 13, y: 14, z: 15 }] +// lldbg-check:[...]$5 = &[AStruct { x: 10, y: 11, z: 12 }, AStruct { x: 13, y: 14, z: 15 }] +// lldbr-check:(&[vec_slices::AStruct]) padded_struct = &[AStruct { x: 10, y: 11, z: 12 }, AStruct { x: 13, y: 14, z: 15 }] #![allow(dead_code, unused_variables)] #![feature(omit_gdb_pretty_printer_section)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/incremental/hashes/closure_expressions.rs rustc-1.31.0+dfsg1+llvm/src/test/incremental/hashes/closure_expressions.rs --- rustc-1.30.0+dfsg1+llvm/src/test/incremental/hashes/closure_expressions.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/incremental/hashes/closure_expressions.rs 2018-12-04 23:41:40.000000000 +0000 @@ -95,7 +95,7 @@ } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="HirBody")] +#[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, TypeckTables")] #[rustc_clean(cfg="cfail3")] pub fn add_type_ascription_to_parameter() { let closure = |x: u32| x + 1u32; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/incremental/hashes/trait_defs.rs rustc-1.31.0+dfsg1+llvm/src/test/incremental/hashes/trait_defs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/incremental/hashes/trait_defs.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/incremental/hashes/trait_defs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -270,7 +270,7 @@ #[rustc_clean(label="Hir", cfg="cfail2")] #[rustc_clean(label="Hir", cfg="cfail3")] trait TraitChangeModeSelfOwnToMut: Sized { - #[rustc_clean(label="Hir", cfg="cfail2")] + #[rustc_dirty(label="Hir", cfg="cfail2")] #[rustc_clean(label="Hir", cfg="cfail3")] #[rustc_dirty(label="HirBody", cfg="cfail2")] #[rustc_clean(label="HirBody", cfg="cfail3")] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/incremental/issue-51409.rs rustc-1.31.0+dfsg1+llvm/src/test/incremental/issue-51409.rs --- rustc-1.30.0+dfsg1+llvm/src/test/incremental/issue-51409.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/incremental/issue-51409.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,8 +13,6 @@ // Regression test that `infer_outlives_predicates` can be // used with incremental without an ICE. -#![feature(infer_outlives_requirements)] - struct Foo<'a, T> { x: &'a T } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/incremental/remove-private-item-cross-crate/main.rs rustc-1.31.0+dfsg1+llvm/src/test/incremental/remove-private-item-cross-crate/main.rs --- rustc-1.30.0+dfsg1+llvm/src/test/incremental/remove-private-item-cross-crate/main.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/incremental/remove-private-item-cross-crate/main.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,6 +13,7 @@ // revisions:rpass1 rpass2 // aux-build:a.rs +// compile-flags: -Zquery-dep-graph #![feature(rustc_attrs)] #![crate_type = "bin"] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/incremental/thinlto/cgu_invalidated_via_import.rs rustc-1.31.0+dfsg1+llvm/src/test/incremental/thinlto/cgu_invalidated_via_import.rs --- rustc-1.30.0+dfsg1+llvm/src/test/incremental/thinlto/cgu_invalidated_via_import.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/incremental/thinlto/cgu_invalidated_via_import.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,57 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +// This test checks that the LTO phase is re-done for CGUs that import something +// via ThinLTO and that imported thing changes while the definition of the CGU +// stays untouched. + +// revisions: cfail1 cfail2 cfail3 +// compile-flags: -Z query-dep-graph -O +// compile-pass + +#![feature(rustc_attrs)] +#![crate_type="rlib"] + +#![rustc_expected_cgu_reuse(module="cgu_invalidated_via_import-foo", + cfg="cfail2", + kind="no")] +#![rustc_expected_cgu_reuse(module="cgu_invalidated_via_import-foo", + cfg="cfail3", + kind="post-lto")] + +#![rustc_expected_cgu_reuse(module="cgu_invalidated_via_import-bar", + cfg="cfail2", + kind="pre-lto")] +#![rustc_expected_cgu_reuse(module="cgu_invalidated_via_import-bar", + cfg="cfail3", + kind="post-lto")] + +mod foo { + + // Trivial functions like this one are imported very reliably by ThinLTO. + #[cfg(cfail1)] + pub fn inlined_fn() -> u32 { + 1234 + } + + #[cfg(not(cfail1))] + pub fn inlined_fn() -> u32 { + 1234 + } +} + +pub mod bar { + use foo::inlined_fn; + + pub fn caller() -> u32 { + inlined_fn() + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/incremental/thinlto/independent_cgus_dont_affect_each_other.rs rustc-1.31.0+dfsg1+llvm/src/test/incremental/thinlto/independent_cgus_dont_affect_each_other.rs --- rustc-1.30.0+dfsg1+llvm/src/test/incremental/thinlto/independent_cgus_dont_affect_each_other.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/incremental/thinlto/independent_cgus_dont_affect_each_other.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,67 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +// This test checks that a change in a CGU does not invalidate an unrelated CGU +// during incremental ThinLTO. + +// revisions: cfail1 cfail2 cfail3 +// compile-flags: -Z query-dep-graph -O +// compile-pass + +#![feature(rustc_attrs)] +#![crate_type="rlib"] + +#![rustc_expected_cgu_reuse(module="independent_cgus_dont_affect_each_other-foo", + cfg="cfail2", + kind="no")] +#![rustc_expected_cgu_reuse(module="independent_cgus_dont_affect_each_other-foo", + cfg="cfail3", + kind="post-lto")] + +#![rustc_expected_cgu_reuse(module="independent_cgus_dont_affect_each_other-bar", + cfg="cfail2", + kind="pre-lto")] +#![rustc_expected_cgu_reuse(module="independent_cgus_dont_affect_each_other-bar", + cfg="cfail3", + kind="post-lto")] + +#![rustc_expected_cgu_reuse(module="independent_cgus_dont_affect_each_other-baz", + cfg="cfail2", + kind="post-lto")] +#![rustc_expected_cgu_reuse(module="independent_cgus_dont_affect_each_other-baz", + cfg="cfail3", + kind="post-lto")] +mod foo { + + #[cfg(cfail1)] + pub fn inlined_fn() -> u32 { + 1234 + } + + #[cfg(not(cfail1))] + pub fn inlined_fn() -> u32 { + 1234 + } +} + +pub mod bar { + use foo::inlined_fn; + + pub fn caller() -> u32 { + inlined_fn() + } +} + +pub mod baz { + pub fn unrelated_to_other_fns() -> u64 { + 0xbeef + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/basic_assignment.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/basic_assignment.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/basic_assignment.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/basic_assignment.rs 2018-12-04 23:41:40.000000000 +0000 @@ -47,6 +47,7 @@ // bb0: { // StorageLive(_1); // _1 = const false; +// FakeRead(ForLet, _1); // StorageLive(_2); // StorageLive(_3); // _3 = _1; @@ -54,7 +55,8 @@ // StorageDead(_3); // StorageLive(_4); // _4 = std::option::Option>::None; -// AscribeUserType(_4, o, Canonical { variables: [], value: std::option::Option> }); +// FakeRead(ForLet, _4); +// AscribeUserType(_4, o, UserTypeProjection { base: Ty(Canonical { variables: [], value: std::option::Option> }), projs: [] }); // StorageLive(_5); // StorageLive(_6); // _6 = move _4; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/end_region_1.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/end_region_1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/end_region_1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/end_region_1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -22,17 +22,19 @@ // START rustc.main.SimplifyCfg-qualify-consts.after.mir // let mut _0: (); // ... -// let _2: &'10_1rs i32; +// let _2: &'11_1rs i32; // ... // let _1: i32; // ... // bb0: { // StorageLive(_1); // _1 = const 3i32; +// FakeRead(ForLet, _1); // StorageLive(_2); -// _2 = &'10_1rs _1; +// _2 = &'11_1rs _1; +// FakeRead(ForLet, _2); // _0 = (); -// EndRegion('10_1rs); +// EndRegion('11_1rs); // StorageDead(_2); // StorageDead(_1); // return; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/end_region_2.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/end_region_2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/end_region_2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/end_region_2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -27,9 +27,9 @@ // START rustc.main.SimplifyCfg-qualify-consts.after.mir // let mut _0: (); // ... -// let _7: &'23_3rs bool; +// let _7: &'26_3rs bool; // ... -// let _3: &'23_1rs bool; +// let _3: &'26_1rs bool; // ... // let _2: bool; // ... @@ -45,8 +45,10 @@ // bb2: { // StorageLive(_2); // _2 = const true; +// FakeRead(ForLet, _2); // StorageLive(_3); -// _3 = &'23_1rs _2; +// _3 = &'26_1rs _2; +// FakeRead(ForLet, _3); // StorageLive(_5); // _5 = _2; // switchInt(move _5) -> [false: bb5, otherwise: bb4]; @@ -57,7 +59,7 @@ // bb4: { // _0 = (); // StorageDead(_5); -// EndRegion('23_1rs); +// EndRegion('26_1rs); // StorageDead(_3); // StorageDead(_2); // return; @@ -66,11 +68,12 @@ // _4 = (); // StorageDead(_5); // StorageLive(_7); -// _7 = &'23_3rs _2; +// _7 = &'26_3rs _2; +// FakeRead(ForLet, _7); // _1 = (); -// EndRegion('23_3rs); +// EndRegion('26_3rs); // StorageDead(_7); -// EndRegion('23_1rs); +// EndRegion('26_1rs); // StorageDead(_3); // StorageDead(_2); // goto -> bb1; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/end_region_3.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/end_region_3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/end_region_3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/end_region_3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -28,9 +28,9 @@ // START rustc.main.SimplifyCfg-qualify-consts.after.mir // let mut _0: (); // ... -// let _7: &'26_3rs bool; +// let _7: &'30_3rs bool; // ... -// let _3: &'26_1rs bool; +// let _3: &'30_1rs bool; // ... // let mut _1: bool; // ... @@ -48,7 +48,8 @@ // bb2: { // _1 = const true; // StorageLive(_3); -// _3 = &'26_1rs _1; +// _3 = &'30_1rs _1; +// FakeRead(ForLet, _3); // StorageLive(_5); // _5 = _1; // switchInt(move _5) -> [false: bb5, otherwise: bb4]; @@ -59,7 +60,7 @@ // bb4: { // _0 = (); // StorageDead(_5); -// EndRegion('26_1rs); +// EndRegion('30_1rs); // StorageDead(_3); // StorageDead(_1); // return; @@ -68,11 +69,12 @@ // _4 = (); // StorageDead(_5); // StorageLive(_7); -// _7 = &'26_3rs _1; +// _7 = &'30_3rs _1; +// FakeRead(ForLet, _7); // _2 = (); -// EndRegion('26_3rs); +// EndRegion('30_3rs); // StorageDead(_7); -// EndRegion('26_1rs); +// EndRegion('30_1rs); // StorageDead(_3); // goto -> bb1; // } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/end_region_4.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/end_region_4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/end_region_4.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/end_region_4.rs 2018-12-04 23:41:40.000000000 +0000 @@ -32,9 +32,9 @@ // START rustc.main.SimplifyCfg-qualify-consts.after.mir // let mut _0: (); // ... -// let _6: &'26_4rs i32; +// let _6: &'31_4rs i32; // ... -// let _3: &'26_2rs i32; +// let _3: &'31_2rs i32; // ... // let _2: i32; // ... @@ -45,10 +45,13 @@ // bb0: { // StorageLive(_1); // _1 = D::{{constructor}}(const 0i32,); +// FakeRead(ForLet, _1); // StorageLive(_2); // _2 = const 0i32; +// FakeRead(ForLet, _2); // StorageLive(_3); -// _3 = &'26_2rs _2; +// _3 = &'31_2rs _2; +// FakeRead(ForLet, _3); // StorageLive(_5); // _5 = (*_3); // _4 = const foo(move _5) -> [return: bb2, unwind: bb3]; @@ -59,17 +62,18 @@ // bb2: { // StorageDead(_5); // StorageLive(_6); -// _6 = &'26_4rs _2; +// _6 = &'31_4rs _2; +// FakeRead(ForLet, _6); // _0 = (); -// EndRegion('26_4rs); +// EndRegion('31_4rs); // StorageDead(_6); -// EndRegion('26_2rs); +// EndRegion('31_2rs); // StorageDead(_3); // StorageDead(_2); // drop(_1) -> [return: bb4, unwind: bb1]; // } // bb3: { -// EndRegion('26_2rs); +// EndRegion('31_2rs); // drop(_1) -> bb1; // } // bb4: { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/end_region_5.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/end_region_5.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/end_region_5.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/end_region_5.rs 2018-12-04 23:41:40.000000000 +0000 @@ -33,15 +33,16 @@ // let _1: D; // ... // let mut _2: (); -// let mut _3: [closure@NodeId(18) d:&'14s D]; -// let mut _4: &'14s D; +// let mut _3: [closure@NodeId(28) d:&'18s D]; +// let mut _4: &'18s D; // bb0: { // StorageLive(_1); // _1 = D::{{constructor}}(const 0i32,); +// FakeRead(ForLet, _1); // StorageLive(_3); // StorageLive(_4); -// _4 = &'14s _1; -// _3 = [closure@NodeId(18)] { d: move _4 }; +// _4 = &'18s _1; +// _3 = [closure@NodeId(28)] { d: move _4 }; // StorageDead(_4); // _2 = const foo(move _3) -> [return: bb2, unwind: bb3]; // } @@ -49,13 +50,13 @@ // resume; // } // bb2: { -// EndRegion('14s); +// EndRegion('18s); // StorageDead(_3); // _0 = (); // drop(_1) -> [return: bb4, unwind: bb1]; // } // bb3: { -// EndRegion('14s); +// EndRegion('18s); // drop(_1) -> bb1; // } // bb4: { @@ -66,11 +67,11 @@ // END rustc.main.SimplifyCfg-qualify-consts.after.mir // START rustc.main-{{closure}}.SimplifyCfg-qualify-consts.after.mir -// fn main::{{closure}}(_1: [closure@NodeId(18) d:&'14s D]) -> i32 { +// fn main::{{closure}}(_1: [closure@NodeId(28) d:&'18s D]) -> i32 { // let mut _0: i32; // // bb0: { -// _0 = ((*(_1.0: &'14s D)).0: i32); +// _0 = ((*(_1.0: &'18s D)).0: i32); // return; // } // END rustc.main-{{closure}}.SimplifyCfg-qualify-consts.after.mir diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/end_region_6.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/end_region_6.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/end_region_6.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/end_region_6.rs 2018-12-04 23:41:40.000000000 +0000 @@ -33,15 +33,16 @@ // let _1: D; // ... // let mut _2: (); -// let mut _3: [closure@NodeId(22) d:&'19s D]; -// let mut _4: &'19s D; +// let mut _3: [closure@NodeId(33) d:&'24s D]; +// let mut _4: &'24s D; // bb0: { // StorageLive(_1); // _1 = D::{{constructor}}(const 0i32,); +// FakeRead(ForLet, _1); // StorageLive(_3); // StorageLive(_4); -// _4 = &'19s _1; -// _3 = [closure@NodeId(22)] { d: move _4 }; +// _4 = &'24s _1; +// _3 = [closure@NodeId(33)] { d: move _4 }; // StorageDead(_4); // _2 = const foo(move _3) -> [return: bb2, unwind: bb3]; // } @@ -49,13 +50,13 @@ // resume; // } // bb2: { -// EndRegion('19s); +// EndRegion('24s); // StorageDead(_3); // _0 = (); // drop(_1) -> [return: bb4, unwind: bb1]; // } // bb3: { -// EndRegion('19s); +// EndRegion('24s); // drop(_1) -> bb1; // } // bb4: { @@ -65,16 +66,17 @@ // END rustc.main.SimplifyCfg-qualify-consts.after.mir // START rustc.main-{{closure}}.SimplifyCfg-qualify-consts.after.mir -// fn main::{{closure}}(_1: [closure@NodeId(22) d:&'19s D]) -> i32 { +// fn main::{{closure}}(_1: [closure@NodeId(33) d:&'24s D]) -> i32 { // let mut _0: i32; // ... -// let _2: &'16_0rs D; +// let _2: &'21_0rs D; // ... // bb0: { // StorageLive(_2); -// _2 = &'16_0rs (*(_1.0: &'19s D)); +// _2 = &'21_0rs (*(_1.0: &'24s D)); +// FakeRead(ForLet, _2); // _0 = ((*_2).0: i32); -// EndRegion('16_0rs); +// EndRegion('21_0rs); // StorageDead(_2); // return; // } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/end_region_7.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/end_region_7.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/end_region_7.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/end_region_7.rs 2018-12-04 23:41:40.000000000 +0000 @@ -33,12 +33,13 @@ // let _1: D; // ... // let mut _2: (); -// let mut _3: [closure@NodeId(22) d:D]; +// let mut _3: [closure@NodeId(33) d:D]; // bb0: { // StorageLive(_1); // _1 = D::{{constructor}}(const 0i32,); +// FakeRead(ForLet, _1); // StorageLive(_3); -// _3 = [closure@NodeId(22)] { d: move _1 }; +// _3 = [closure@NodeId(33)] { d: move _1 }; // _2 = const foo(move _3) -> [return: bb2, unwind: bb4]; // } // bb1: { @@ -66,16 +67,17 @@ // END rustc.main.SimplifyCfg-qualify-consts.after.mir // START rustc.main-{{closure}}.SimplifyCfg-qualify-consts.after.mir -// fn main::{{closure}}(_1: [closure@NodeId(22) d:D]) -> i32 { +// fn main::{{closure}}(_1: [closure@NodeId(33) d:D]) -> i32 { // let mut _0: i32; // ... -// let _2: &'16_0rs D; +// let _2: &'21_0rs D; // ... // bb0: { // StorageLive(_2); -// _2 = &'16_0rs (_1.0: D); +// _2 = &'21_0rs (_1.0: D); +// FakeRead(ForLet, _2); // _0 = ((*_2).0: i32); -// EndRegion('16_0rs); +// EndRegion('21_0rs); // StorageDead(_2); // drop(_1) -> [return: bb2, unwind: bb1]; // } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/end_region_8.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/end_region_8.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/end_region_8.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/end_region_8.rs 2018-12-04 23:41:40.000000000 +0000 @@ -31,35 +31,37 @@ // fn main() -> () { // let mut _0: (); // ... -// let _2: &'21_1rs D; +// let _2: &'26_1rs D; // ... // let _1: D; // ... // let mut _3: (); -// let mut _4: [closure@NodeId(22) r:&'19s D]; +// let mut _4: [closure@NodeId(33) r:&'24s D]; // bb0: { // StorageLive(_1); // _1 = D::{{constructor}}(const 0i32,); +// FakeRead(ForLet, _1); // StorageLive(_2); -// _2 = &'21_1rs _1; +// _2 = &'26_1rs _1; +// FakeRead(ForLet, _2); // StorageLive(_4); -// _4 = [closure@NodeId(22)] { r: _2 }; +// _4 = [closure@NodeId(33)] { r: _2 }; // _3 = const foo(move _4) -> [return: bb2, unwind: bb3]; // } // bb1: { // resume; // } // bb2: { -// EndRegion('19s); +// EndRegion('24s); // StorageDead(_4); // _0 = (); -// EndRegion('21_1rs); +// EndRegion('26_1rs); // StorageDead(_2); // drop(_1) -> [return: bb4, unwind: bb1]; // } // bb3: { -// EndRegion('19s); -// EndRegion('21_1rs); +// EndRegion('24s); +// EndRegion('26_1rs); // drop(_1) -> bb1; // } // bb4: { @@ -70,11 +72,11 @@ // END rustc.main.SimplifyCfg-qualify-consts.after.mir // START rustc.main-{{closure}}.SimplifyCfg-qualify-consts.after.mir -// fn main::{{closure}}(_1: [closure@NodeId(22) r:&'19s D]) -> i32 { +// fn main::{{closure}}(_1: [closure@NodeId(33) r:&'24s D]) -> i32 { // let mut _0: i32; // // bb0: { -// _0 = ((*(_1.0: &'21_1rs D)).0: i32); +// _0 = ((*(_1.0: &'26_1rs D)).0: i32); // return; // } // } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/end_region_9.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/end_region_9.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/end_region_9.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/end_region_9.rs 2018-12-04 23:41:40.000000000 +0000 @@ -41,7 +41,7 @@ // fn main() -> () { // let mut _0: (); // ... -// let mut _4: &'33_0rs i32; +// let mut _4: &'37_0rs i32; // ... // let _2: i32; // ... @@ -55,8 +55,10 @@ // bb0: { // StorageLive(_1); // _1 = const false; +// FakeRead(ForLet, _1); // StorageLive(_2); // _2 = const 3i32; +// FakeRead(ForLet, _2); // falseUnwind -> [real: bb2, cleanup: bb1]; // } // bb1: { @@ -77,14 +79,14 @@ // bb5: { // _0 = (); // StorageDead(_7); -// EndRegion('33_0rs); +// EndRegion('37_0rs); // StorageDead(_4); // StorageDead(_2); // StorageDead(_1); // return; // } // bb6: { -// _4 = &'33_0rs _2; +// _4 = &'37_0rs _2; // _6 = (); // StorageDead(_7); // _1 = const true; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/end_region_cyclic.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/end_region_cyclic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/end_region_cyclic.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/end_region_cyclic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -45,24 +45,24 @@ // scope 1 { // } // scope 2 { -// let _2: S<'36_0rs>; +// let _2: S<'49_0rs>; // } // let mut _1: (); -// let mut _3: std::cell::Cell>>; -// let mut _4: std::option::Option<&'36_0rs S<'36_0rs>>; +// let mut _3: std::cell::Cell>>; +// let mut _4: std::option::Option<&'49_0rs S<'49_0rs>>; // let mut _5: (); -// let mut _6: &'17s std::cell::Cell>>; -// let mut _7: std::option::Option<&'36_0rs S<'36_0rs>>; -// let mut _8: &'36_0rs S<'36_0rs>; -// let mut _9: &'36_0rs S<'36_0rs>; +// let mut _6: &'25s std::cell::Cell>>; +// let mut _7: std::option::Option<&'49_0rs S<'49_0rs>>; +// let mut _8: &'49_0rs S<'49_0rs>; +// let mut _9: &'49_0rs S<'49_0rs>; // let mut _10: (); // let mut _11: bool; // let mut _12: !; // let mut _13: (); -// let mut _14: &'34s std::cell::Cell>>; -// let mut _15: std::option::Option<&'36_0rs S<'36_0rs>>; -// let mut _16: &'36_0rs S<'36_0rs>; -// let mut _17: &'36_0rs S<'36_0rs>; +// let mut _14: &'47s std::cell::Cell>>; +// let mut _15: std::option::Option<&'49_0rs S<'49_0rs>>; +// let mut _16: &'49_0rs S<'49_0rs>; +// let mut _17: &'49_0rs S<'49_0rs>; // bb0: { // goto -> bb1; // } @@ -73,7 +73,7 @@ // StorageLive(_2); // StorageLive(_3); // StorageLive(_4); -// _4 = std::option::Option<&'36_0rs S<'36_0rs>>::None; +// _4 = std::option::Option<&'49_0rs S<'49_0rs>>::None; // _3 = const >::new(move _4) -> [return: bb4, unwind: bb3]; // } // bb3: { @@ -81,21 +81,22 @@ // } // bb4: { // StorageDead(_4); -// _2 = S<'36_0rs> { r: move _3 }; +// _2 = S<'49_0rs> { r: move _3 }; // StorageDead(_3); +// FakeRead(ForLet, _2); // StorageLive(_6); -// _6 = &'17s (_2.0: std::cell::Cell>>); +// _6 = &'25s (_2.0: std::cell::Cell>>); // StorageLive(_7); // StorageLive(_8); // StorageLive(_9); -// _9 = &'36_0rs _2; -// _8 = &'36_0rs (*_9); -// _7 = std::option::Option<&'36_0rs S<'36_0rs>>::Some(move _8,); +// _9 = &'49_0rs _2; +// _8 = &'49_0rs (*_9); +// _7 = std::option::Option<&'49_0rs S<'49_0rs>>::Some(move _8,); // StorageDead(_8); // _5 = const >::set(move _6, move _7) -> [return: bb5, unwind: bb3]; // } // bb5: { -// EndRegion('17s); +// EndRegion('25s); // StorageDead(_7); // StorageDead(_6); // StorageDead(_9); @@ -108,7 +109,7 @@ // bb7: { // _0 = (); // StorageDead(_11); -// EndRegion('36_0rs); +// EndRegion('49_0rs); // StorageDead(_2); // return; // } @@ -116,23 +117,23 @@ // _10 = (); // StorageDead(_11); // StorageLive(_14); -// _14 = &'34s (_2.0: std::cell::Cell>>); +// _14 = &'47s (_2.0: std::cell::Cell>>); // StorageLive(_15); // StorageLive(_16); // StorageLive(_17); -// _17 = &'36_0rs _2; -// _16 = &'36_0rs (*_17); -// _15 = std::option::Option<&'36_0rs S<'36_0rs>>::Some(move _16,); +// _17 = &'49_0rs _2; +// _16 = &'49_0rs (*_17); +// _15 = std::option::Option<&'49_0rs S<'49_0rs>>::Some(move _16,); // StorageDead(_16); // _13 = const >::set(move _14, move _15) -> [return: bb9, unwind: bb3]; // } // bb9: { -// EndRegion('34s); +// EndRegion('47s); // StorageDead(_15); // StorageDead(_14); // StorageDead(_17); // _1 = (); -// EndRegion('36_0rs); +// EndRegion('49_0rs); // StorageDead(_2); // goto -> bb1; // } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/end_region_destruction_extents_1.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/end_region_destruction_extents_1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/end_region_destruction_extents_1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/end_region_destruction_extents_1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -41,16 +41,16 @@ // Notes on the MIR output below: // -// 1. The `EndRegion('10s)` is allowed to precede the `drop(_3)` +// 1. The `EndRegion('13s)` is allowed to precede the `drop(_3)` // solely because of the #[may_dangle] mentioned above. // -// 2. Regarding the occurrence of `EndRegion('12ds)` *after* `StorageDead(_6)` -// (where we have borrows `&'12ds _6`): Eventually: +// 2. Regarding the occurrence of `EndRegion('15ds)` *after* `StorageDead(_6)` +// (where we have borrows `&'15ds _6`): Eventually: // // i. this code should be rejected (by mir-borrowck), or // // ii. the MIR code generation should be changed so that the -// EndRegion('12ds)` precedes `StorageDead(_6)` in the +// EndRegion('15ds)` precedes `StorageDead(_6)` in the // control-flow. (Note: arielb1 views drop+storagedead as one // unit, and does not see this option as a useful avenue to // explore.), or @@ -66,13 +66,13 @@ // START rustc.main.QualifyAndPromoteConstants.before.mir // fn main() -> () { // let mut _0: (); -// let mut _1: &'12ds S1; -// let mut _2: D1<'12ds, '10s>; -// let mut _3: &'12ds S1; -// let mut _4: &'12ds S1; +// let mut _1: &'15ds S1; +// let mut _2: D1<'15ds, '13s>; +// let mut _3: &'15ds S1; +// let mut _4: &'15ds S1; // let _5: S1; -// let mut _6: &'10s S1; -// let mut _7: &'10s S1; +// let mut _6: &'13s S1; +// let mut _7: &'13s S1; // let _8: S1; // bb0: { // StorageLive(_2); @@ -80,19 +80,19 @@ // StorageLive(_4); // StorageLive(_5); // _5 = S1::{{constructor}}(const "ex1",); -// _4 = &'12ds _5; -// _3 = &'12ds (*_4); +// _4 = &'15ds _5; +// _3 = &'15ds (*_4); // StorageLive(_6); // StorageLive(_7); // StorageLive(_8); // _8 = S1::{{constructor}}(const "dang1",); -// _7 = &'10s _8; -// _6 = &'10s (*_7); -// _2 = D1<'12ds, '10s>::{{constructor}}(move _3, move _6); -// EndRegion('10s); +// _7 = &'13s _8; +// _6 = &'13s (*_7); +// _2 = D1<'15ds, '13s>::{{constructor}}(move _3, move _6); +// EndRegion('13s); // StorageDead(_6); // StorageDead(_3); -// _1 = (_2.0: &'12ds S1); +// _1 = (_2.0: &'15ds S1); // drop(_2) -> [return: bb2, unwind: bb1]; // } // bb1: { @@ -104,7 +104,7 @@ // StorageDead(_8); // StorageDead(_4); // StorageDead(_5); -// EndRegion('12ds); +// EndRegion('15ds); // _0 = (); // return; // } @@ -114,29 +114,29 @@ // START rustc.main.QualifyAndPromoteConstants.after.mir // fn main() -> (){ // let mut _0: (); -// let mut _1: &'12ds S1; -// let mut _2: D1<'12ds, '10s>; -// let mut _3: &'12ds S1; -// let mut _4: &'12ds S1; +// let mut _1: &'15ds S1; +// let mut _2: D1<'15ds, '13s>; +// let mut _3: &'15ds S1; +// let mut _4: &'15ds S1; // let _5: S1; -// let mut _6: &'10s S1; -// let mut _7: &'10s S1; +// let mut _6: &'13s S1; +// let mut _7: &'13s S1; // let _8: S1; // bb0: { // StorageLive(_2); // StorageLive(_3); // StorageLive(_4); -// _4 = &'12ds (promoted[1]: S1); -// _3 = &'12ds (*_4); +// _4 = &'15ds (promoted[1]: S1); +// _3 = &'15ds (*_4); // StorageLive(_6); // StorageLive(_7); -// _7 = &'10s (promoted[0]: S1); -// _6 = &'10s (*_7); -// _2 = D1<'12ds, '10s>::{{constructor}}(move _3, move _6); -// EndRegion('10s); +// _7 = &'13s (promoted[0]: S1); +// _6 = &'13s (*_7); +// _2 = D1<'15ds, '13s>::{{constructor}}(move _3, move _6); +// EndRegion('13s); // StorageDead(_6); // StorageDead(_3); -// _1 = (_2.0: &'12ds S1); +// _1 = (_2.0: &'15ds S1); // drop(_2) -> [return: bb2, unwind: bb1]; // } // bb1: { @@ -146,7 +146,7 @@ // StorageDead(_2); // StorageDead(_7); // StorageDead(_4); -// EndRegion('12ds); +// EndRegion('15ds); // _0 = (); // return; // } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/inline-any-operand.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/inline-any-operand.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/inline-any-operand.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/inline-any-operand.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z span_free_formats + +// Tests that MIR inliner works for any operand + +fn main() { + println!("{}", bar()); +} + +#[inline(always)] +fn foo(x: i32, y: i32) -> bool { + x == y +} + +fn bar() -> bool { + let f = foo; + f(1, -1) +} + +// END RUST SOURCE +// START rustc.bar.Inline.after.mir +// ... +// bb0: { +// ... +// _0 = Eq(move _3, move _4); +// ... +// return; +// } +// ... +// END rustc.bar.Inline.after.mir diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/inline-closure-borrows-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/inline-closure-borrows-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/inline-closure-borrows-arg.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/inline-closure-borrows-arg.rs 2018-12-04 23:41:40.000000000 +0000 @@ -30,7 +30,7 @@ // ... // bb0: { // ... -// _3 = [closure@NodeId(39)]; +// _3 = [closure@NodeId(53)]; // ... // _4 = &_3; // ... @@ -40,6 +40,7 @@ // _5 = (move _6, move _7); // _8 = move (_5.0: &i32); // _9 = move (_5.1: &i32); +// ... // _0 = (*_8); // ... // return; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/inline-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/inline-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/inline-closure.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/inline-closure.rs 2018-12-04 23:41:40.000000000 +0000 @@ -26,7 +26,7 @@ // ... // bb0: { // ... -// _3 = [closure@NodeId(28)]; +// _3 = [closure@NodeId(39)]; // ... // _4 = &_3; // ... diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/inline-trait-method.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/inline-trait-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/inline-trait-method.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/inline-trait-method.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// compile-flags: -Z span_free_formats + +fn main() { + println!("{}", test(&())); +} + +fn test(x: &dyn X) -> u32 { + x.y() +} + +trait X { + fn y(&self) -> u32 { + 1 + } +} + +impl X for () { + fn y(&self) -> u32 { + 2 + } +} + +// END RUST SOURCE +// START rustc.test.Inline.after.mir +// ... +// bb0: { +// ... +// _0 = const X::y(move _2) -> bb1; +// } +// ... +// END rustc.test.Inline.after.mir diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/issue-38669.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/issue-38669.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/issue-38669.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/issue-38669.rs 2018-12-04 23:41:40.000000000 +0000 @@ -25,6 +25,7 @@ // bb0: { // StorageLive(_1); // _1 = const false; +// FakeRead(ForLet, _1); // goto -> bb2; // } // bb1: { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/issue-49232.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/issue-49232.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/issue-49232.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/issue-49232.rs 2018-12-04 23:41:40.000000000 +0000 @@ -34,10 +34,9 @@ // } // let mut _1: (); // let mut _3: bool; -// let mut _4: u8; -// let mut _5: !; -// let mut _6: (); -// let mut _7: &i32; +// let mut _4: !; +// let mut _5: (); +// let mut _6: &i32; // bb0: { // goto -> bb1; // } @@ -51,7 +50,7 @@ // StorageLive(_2); // StorageLive(_3); // _3 = const true; -// _4 = discriminant(_3); +// FakeRead(ForMatchedPlace, _3); // switchInt(_3) -> [false: bb11, otherwise: bb10]; // } // bb4: { @@ -87,10 +86,11 @@ // goto -> bb6; // } // bb14: { +// FakeRead(ForLet, _2); // StorageDead(_3); -// StorageLive(_7); -// _7 = &_2; -// _6 = const std::mem::drop(move _7) -> [return: bb28, unwind: bb4]; +// StorageLive(_6); +// _6 = &_2; +// _5 = const std::mem::drop(move _6) -> [return: bb28, unwind: bb4]; // } // bb15: { // goto -> bb16; @@ -128,15 +128,15 @@ // goto -> bb2; // } // bb26: { -// _5 = (); +// _4 = (); // unreachable; // } // bb27: { -// StorageDead(_5); +// StorageDead(_4); // goto -> bb14; // } // bb28: { -// StorageDead(_7); +// StorageDead(_6); // _1 = (); // StorageDead(_2); // goto -> bb1; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/loop_test.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/loop_test.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/loop_test.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/loop_test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -42,6 +42,7 @@ // bb5: { // The loop body (body_block) // StorageLive(_5); // _5 = const 1i32; +// FakeRead(ForLet, _5); // StorageDead(_5); // goto -> bb4; // } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/lower_128bit_debug_test.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/lower_128bit_debug_test.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/lower_128bit_debug_test.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/lower_128bit_debug_test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,8 +15,6 @@ // compile-flags: -Z lower_128bit_ops=yes -C debug_assertions=yes -#![feature(min_const_fn)] - static TEST_SIGNED: i128 = const_signed(-222); static TEST_UNSIGNED: u128 = const_unsigned(200); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/lower_128bit_test.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/lower_128bit_test.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/lower_128bit_test.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/lower_128bit_test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,8 +12,6 @@ // compile-flags: -Z lower_128bit_ops=yes -C debug_assertions=no -O -#![feature(min_const_fn)] - static TEST_SIGNED: i128 = const_signed(-222); static TEST_UNSIGNED: u128 = const_unsigned(200); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/match_false_edges.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/match_false_edges.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/match_false_edges.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/match_false_edges.rs 2018-12-04 23:41:40.000000000 +0000 @@ -53,10 +53,11 @@ // bb0: { // ... // _2 = std::option::Option::Some(const 42i32,); -// _3 = discriminant(_2); -// _4 = &(promoted[1]: std::option::Option); -// _9 = discriminant(_2); -// switchInt(move _9) -> [0isize: bb5, 1isize: bb3, otherwise: bb7]; +// FakeRead(ForMatchedPlace, _2); +// _7 = discriminant(_2); +// _9 = &shallow (promoted[2]: std::option::Option); +// _10 = &(((promoted[1]: std::option::Option) as Some).0: i32); +// switchInt(move _7) -> [0isize: bb5, 1isize: bb3, otherwise: bb7]; // } // bb1: { // resume; @@ -66,15 +67,18 @@ // goto -> bb13; // } // bb3: { // binding3(empty) and arm3 -// ReadForMatch(_4); +// FakeRead(ForMatchGuard, _9); +// FakeRead(ForMatchGuard, _10); // falseEdges -> [real: bb8, imaginary: bb4]; //pre_binding1 // } // bb4: { -// ReadForMatch(_4); +// FakeRead(ForMatchGuard, _9); +// FakeRead(ForMatchGuard, _10); // falseEdges -> [real: bb12, imaginary: bb5]; //pre_binding2 // } // bb5: { -// ReadForMatch(_4); +// FakeRead(ForMatchGuard, _9); +// FakeRead(ForMatchGuard, _10); // falseEdges -> [real: bb2, imaginary: bb6]; //pre_binding3 // } // bb6: { @@ -84,31 +88,31 @@ // unreachable; // } // bb8: { // binding1 and guard -// StorageLive(_7); -// _7 = &(((promoted[0]: std::option::Option) as Some).0: i32); -// StorageLive(_10); -// _10 = const guard() -> [return: bb9, unwind: bb1]; +// StorageLive(_5); +// _5 = &(((promoted[0]: std::option::Option) as Some).0: i32); +// StorageLive(_8); +// _8 = const guard() -> [return: bb9, unwind: bb1]; // } // bb9: { -// switchInt(move _10) -> [false: bb10, otherwise: bb11]; +// switchInt(move _8) -> [false: bb10, otherwise: bb11]; // } // bb10: { // to pre_binding2 // falseEdges -> [real: bb4, imaginary: bb4]; // } // bb11: { // bindingNoLandingPads.before.mir2 and arm2 -// StorageLive(_5); -// _5 = ((_2 as Some).0: i32); +// StorageLive(_3); +// _3 = ((_2 as Some).0: i32); // StorageLive(_11); -// _11 = _5; +// _11 = _3; // _1 = (const 1i32, move _11); // StorageDead(_11); // goto -> bb13; // } // bb12: { -// StorageLive(_8); -// _8 = ((_2 as Some).0: i32); +// StorageLive(_6); +// _6 = ((_2 as Some).0: i32); // StorageLive(_12); -// _12 = _8; +// _12 = _6; // _1 = (const 2i32, move_12); // StorageDead(_12); // goto -> bb13; @@ -123,10 +127,11 @@ // bb0: { // ... // _2 = std::option::Option::Some(const 42i32,); -// _3 = discriminant(_2); -// _4 = &_2; -// _9 = discriminant(_2); -// switchInt(move _9) -> [0isize: bb4, 1isize: bb3, otherwise: bb7]; +// FakeRead(ForMatchedPlace, _2); +// _7 = discriminant(_2); +// _9 = &shallow _2; +// _10 = &((_2 as Some).0: i32); +// switchInt(move _7) -> [0isize: bb4, 1isize: bb3, otherwise: bb7]; // } // bb1: { // resume; @@ -136,15 +141,18 @@ // goto -> bb13; // } // bb3: { -// ReadForMatch(_4); +// FakeRead(ForMatchGuard, _9); +// FakeRead(ForMatchGuard, _10); // falseEdges -> [real: bb8, imaginary: bb4]; //pre_binding1 // } // bb4: { -// ReadForMatch(_4); +// FakeRead(ForMatchGuard, _9); +// FakeRead(ForMatchGuard, _10); // falseEdges -> [real: bb2, imaginary: bb5]; //pre_binding2 // } // bb5: { -// ReadForMatch(_4); +// FakeRead(ForMatchGuard, _9); +// FakeRead(ForMatchGuard, _10); // falseEdges -> [real: bb12, imaginary: bb6]; //pre_binding3 // } // bb6: { @@ -154,31 +162,31 @@ // unreachable; // } // bb8: { // binding1 and guard -// StorageLive(_7); -// _7 = &((_2 as Some).0: i32); -// StorageLive(_10); -// _10 = const guard() -> [return: bb9, unwind: bb1]; +// StorageLive(_5); +// _5 = &((_2 as Some).0: i32); +// StorageLive(_8); +// _8 = const guard() -> [return: bb9, unwind: bb1]; // } // bb9: { // end of guard -// switchInt(move _10) -> [false: bb10, otherwise: bb11]; +// switchInt(move _8) -> [false: bb10, otherwise: bb11]; // } // bb10: { // to pre_binding3 (can skip 2 since this is `Some`) // falseEdges -> [real: bb5, imaginary: bb4]; // } // bb11: { // arm1 -// StorageLive(_5); -// _5 = ((_2 as Some).0: i32); +// StorageLive(_3); +// _3 = ((_2 as Some).0: i32); // StorageLive(_11); -// _11 = _5; +// _11 = _3; // _1 = (const 1i32, move _11); // StorageDead(_11); // goto -> bb13; // } // bb12: { // binding3 and arm3 -// StorageLive(_8); -// _8 = ((_2 as Some).0: i32); +// StorageLive(_6); +// _6 = ((_2 as Some).0: i32); // StorageLive(_12); -// _12 = _8; +// _12 = _6; // _1 = (const 2i32, move _12); // StorageDead(_12); // goto -> bb13; @@ -193,81 +201,86 @@ // bb0: { // ... // _2 = std::option::Option::Some(const 1i32,); -// _3 = discriminant(_2); -// _4 = &_2; -// _13 = discriminant(_2); -// switchInt(move _13) -> [1isize: bb2, otherwise: bb3]; +// FakeRead(ForMatchedPlace, _2); +// _11 = discriminant(_2); +// _16 = &shallow _2; +// _17 = &((_2 as Some).0: i32); +// switchInt(move _11) -> [1isize: bb2, otherwise: bb3]; // } // bb1: { // resume; // } // bb2: { -// ReadForMatch(_4); +// FakeRead(ForMatchGuard, _16); +// FakeRead(ForMatchGuard, _17); // falseEdges -> [real: bb7, imaginary: bb3]; //pre_binding1 // } // bb3: { -// ReadForMatch(_4); +// FakeRead(ForMatchGuard, _16); +// FakeRead(ForMatchGuard, _17); // falseEdges -> [real: bb11, imaginary: bb4]; //pre_binding2 // } // bb4: { -// ReadForMatch(_4); +// FakeRead(ForMatchGuard, _16); +// FakeRead(ForMatchGuard, _17); // falseEdges -> [real: bb12, imaginary: bb5]; //pre_binding3 // } // bb5: { -// ReadForMatch(_4); +// FakeRead(ForMatchGuard, _16); +// FakeRead(ForMatchGuard, _17); // falseEdges -> [real: bb16, imaginary: bb6]; //pre_binding4 // } // bb6: { // unreachable; // } // bb7: { // binding1: Some(w) if guard() -// StorageLive(_7); -// _7 = &((_2 as Some).0: i32); -// StorageLive(_14); -// _14 = const guard() -> [return: bb8, unwind: bb1]; +// StorageLive(_5); +// _5 = &((_2 as Some).0: i32); +// StorageLive(_12); +// _12 = const guard() -> [return: bb8, unwind: bb1]; // } // bb8: { //end of guard -// switchInt(move _14) -> [false: bb9, otherwise: bb10]; +// switchInt(move _12) -> [false: bb9, otherwise: bb10]; // } // bb9: { // to pre_binding2 // falseEdges -> [real: bb3, imaginary: bb3]; // } // bb10: { // set up bindings for arm1 -// StorageLive(_5); -// _5 = ((_2 as Some).0: i32); +// StorageLive(_3); +// _3 = ((_2 as Some).0: i32); // _1 = const 1i32; // goto -> bb17; // } // bb11: { // binding2 & arm2 -// StorageLive(_8); -// _8 = _2; +// StorageLive(_6); +// _6 = _2; // _1 = const 2i32; // goto -> bb17; // } // bb12: { // binding3: Some(y) if guard2(y) -// StorageLive(_11); -// _11 = &((_2 as Some).0: i32); -// StorageLive(_16); -// StorageLive(_17); -// _17 = (*_11); -// _16 = const guard2(move _17) -> [return: bb13, unwind: bb1]; +// StorageLive(_9); +// _9 = &((_2 as Some).0: i32); +// StorageLive(_14); +// StorageLive(_15); +// _15 = (*_9); +// _14 = const guard2(move _15) -> [return: bb13, unwind: bb1]; // } // bb13: { // end of guard2 -// StorageDead(_17); -// switchInt(move _16) -> [false: bb14, otherwise: bb15]; +// StorageDead(_15); +// switchInt(move _14) -> [false: bb14, otherwise: bb15]; // } // bb14: { // to pre_binding4 // falseEdges -> [real: bb5, imaginary: bb5]; // } // bb15: { // set up bindings for arm3 -// StorageLive(_9); -// _9 = ((_2 as Some).0: i32); +// StorageLive(_7); +// _7 = ((_2 as Some).0: i32); // _1 = const 3i32; // goto -> bb17; // } // bb16: { // binding4 & arm4 -// StorageLive(_12); -// _12 = _2; +// StorageLive(_10); +// _10 = _2; // _1 = const 4i32; // goto -> bb17; // } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/nll/region-subtyping-basic.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/nll/region-subtyping-basic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/nll/region-subtyping-basic.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/nll/region-subtyping-basic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -32,9 +32,9 @@ // END RUST SOURCE // START rustc.main.nll.0.mir -// | '_#2r | U0 | {bb2[0..=3], bb3[0..=1]} -// | '_#3r | U0 | {bb2[1..=3], bb3[0..=1]} -// | '_#4r | U0 | {bb2[3], bb3[0..=1]} +// | '_#2r | U0 | {bb2[0..=5], bb3[0..=1]} +// | '_#3r | U0 | {bb2[1..=5], bb3[0..=1]} +// | '_#4r | U0 | {bb2[4..=5], bb3[0..=1]} // END rustc.main.nll.0.mir // START rustc.main.nll.0.mir // let _6: &'_#4r usize; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/remove_fake_borrows.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/remove_fake_borrows.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/remove_fake_borrows.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/remove_fake_borrows.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,122 @@ +// Test that the fake borrows for matches are removed after borrow checking. + +// ignore-wasm32-bare + +#![feature(nll)] + +fn match_guard(x: Option<&&i32>) -> i32 { + match x { + Some(0) if true => 0, + _ => 1, + } +} + +fn main() { + match_guard(None); +} + +// END RUST SOURCE + +// START rustc.match_guard.CleanFakeReadsAndBorrows.before.mir +// bb0: { +// FakeRead(ForMatchedPlace, _1); +// _2 = discriminant(_1); +// _3 = &shallow _1; +// _4 = &shallow ((_1 as Some).0: &' &' i32); +// _5 = &shallow (*((_1 as Some).0: &' &' i32)); +// _6 = &shallow (*(*((_1 as Some).0: &' &' i32))); +// switchInt(move _2) -> [1isize: bb6, otherwise: bb4]; +// } +// bb1: { +// _0 = const 0i32; +// goto -> bb9; +// } +// bb2: { +// _0 = const 1i32; +// goto -> bb9; +// } +// bb3: { +// FakeRead(ForMatchGuard, _3); +// FakeRead(ForMatchGuard, _4); +// FakeRead(ForMatchGuard, _5); +// FakeRead(ForMatchGuard, _6); +// goto -> bb7; +// } +// bb4: { +// FakeRead(ForMatchGuard, _3); +// FakeRead(ForMatchGuard, _4); +// FakeRead(ForMatchGuard, _5); +// FakeRead(ForMatchGuard, _6); +// goto -> bb2; +// } +// bb5: { +// unreachable; +// } +// bb6: { +// switchInt((*(*((_1 as Some).0: &' &' i32)))) -> [0i32: bb3, otherwise: bb4]; +// } +// bb7: { +// goto -> bb1; +// } +// bb8: { +// goto -> bb4; +// } +// bb9: { +// return; +// } +// bb10: { +// resume; +// } +// END rustc.match_guard.CleanFakeReadsAndBorrows.before.mir + +// START rustc.match_guard.CleanFakeReadsAndBorrows.after.mir +// bb0: { +// nop; +// _2 = discriminant(_1); +// nop; +// nop; +// nop; +// nop; +// switchInt(move _2) -> [1isize: bb6, otherwise: bb4]; +// } +// bb1: { +// _0 = const 0i32; +// goto -> bb9; +// } +// bb2: { +// _0 = const 1i32; +// goto -> bb9; +// } +// bb3: { +// nop; +// nop; +// nop; +// nop; +// goto -> bb7; +// } +// bb4: { +// nop; +// nop; +// nop; +// nop; +// goto -> bb2; +// } +// bb5: { +// unreachable; +// } +// bb6: { +// switchInt((*(*((_1 as Some).0: &' &' i32)))) -> [0i32: bb3, otherwise: bb4]; +// } +// bb7: { +// goto -> bb1; +// } +// bb8: { +// goto -> bb4; +// } +// bb9: { +// return; +// } +// bb10: { +// resume; +// } +// END rustc.match_guard.CleanFakeReadsAndBorrows.after.mir diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/storage_ranges.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/storage_ranges.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/storage_ranges.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/storage_ranges.rs 2018-12-04 23:41:40.000000000 +0000 @@ -23,6 +23,7 @@ // bb0: { // StorageLive(_1); // _1 = const 0i32; +// FakeRead(ForLet, _1); // StorageLive(_3); // StorageLive(_4); // StorageLive(_5); @@ -30,11 +31,13 @@ // _4 = std::option::Option::Some(move _5,); // StorageDead(_5); // _3 = &_4; +// FakeRead(ForLet, _3); // _2 = (); // StorageDead(_4); // StorageDead(_3); // StorageLive(_6); // _6 = const 1i32; +// FakeRead(ForLet, _6); // _0 = (); // StorageDead(_6); // StorageDead(_1); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/validate_1.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/validate_1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/validate_1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/validate_1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -40,35 +40,35 @@ // ... // bb0: { // ... -// Validate(Suspend(ReScope(Node(ItemLocalId(10)))), [_1: i32]); +// Validate(Suspend(ReScope(Node(ItemLocalId(13)))), [_1: i32]); // _6 = &ReErased mut _1; -// Validate(Acquire, [(*_6): i32/ReScope(Node(ItemLocalId(10)))]); -// Validate(Suspend(ReScope(Node(ItemLocalId(10)))), [(*_6): i32/ReScope(Node(ItemLocalId(10)))]); +// Validate(Acquire, [(*_6): i32/ReScope(Node(ItemLocalId(13)))]); +// Validate(Suspend(ReScope(Node(ItemLocalId(13)))), [(*_6): i32/ReScope(Node(ItemLocalId(13)))]); // _5 = &ReErased mut (*_6); -// Validate(Acquire, [(*_5): i32/ReScope(Node(ItemLocalId(10)))]); -// Validate(Release, [_2: (), _3: &ReScope(Node(ItemLocalId(10))) Test, _5: &ReScope(Node(ItemLocalId(10))) mut i32]); +// Validate(Acquire, [(*_5): i32/ReScope(Node(ItemLocalId(13)))]); +// Validate(Release, [_2: (), _3: &ReScope(Node(ItemLocalId(13))) Test, _5: &ReScope(Node(ItemLocalId(13))) mut i32]); // _2 = const Test::foo(move _3, move _5) -> bb1; // } // // bb1: { // Validate(Acquire, [_2: ()]); -// EndRegion(ReScope(Node(ItemLocalId(10)))); +// EndRegion(ReScope(Node(ItemLocalId(13)))); // ... // return; // } // } // END rustc.main.EraseRegions.after.mir // START rustc.main-{{closure}}.EraseRegions.after.mir -// fn main::{{closure}}(_1: &ReErased [closure@NodeId(50)], _2: &ReErased mut i32) -> i32 { +// fn main::{{closure}}(_1: &ReErased [closure@NodeId(65)], _2: &ReErased mut i32) -> i32 { // ... // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId(0/1:11 ~ validate_1[317d]::main[0]::{{closure}}[0]), BrEnv) [closure@NodeId(50)], _2: &ReFree(DefId(0/1:11 ~ validate_1[317d]::main[0]::{{closure}}[0]), BrAnon(0)) mut i32]); +// Validate(Acquire, [_1: &ReFree(DefId(0/1:11 ~ validate_1[317d]::main[0]::{{closure}}[0]), BrEnv) [closure@NodeId(65)], _2: &ReFree(DefId(0/1:11 ~ validate_1[317d]::main[0]::{{closure}}[0]), BrAnon(0)) mut i32]); // StorageLive(_3); -// Validate(Suspend(ReScope(Remainder { block: ItemLocalId(25), first_statement_index: 0 })), [(*_2): i32]); +// Validate(Suspend(ReScope(Remainder { block: ItemLocalId(31), first_statement_index: 0 })), [(*_2): i32]); // _3 = &ReErased (*_2); -// Validate(Acquire, [(*_3): i32/ReScope(Remainder { block: ItemLocalId(25), first_statement_index: 0 }) (imm)]); +// Validate(Acquire, [(*_3): i32/ReScope(Remainder { block: ItemLocalId(31), first_statement_index: 0 }) (imm)]); // _0 = (*_3); -// EndRegion(ReScope(Remainder { block: ItemLocalId(25), first_statement_index: 0 })); +// EndRegion(ReScope(Remainder { block: ItemLocalId(31), first_statement_index: 0 })); // StorageDead(_3); // return; // } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/validate_3.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/validate_3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/validate_3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/validate_3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -48,27 +48,27 @@ // StorageLive(_1); // _1 = Test { x: const 0i32 }; // StorageLive(_2); -// Validate(Suspend(ReScope(Remainder { block: ItemLocalId(20), first_statement_index: 3 })), [_1: Test]); +// Validate(Suspend(ReScope(Remainder { block: ItemLocalId(24), first_statement_index: 3 })), [_1: Test]); // _2 = &ReErased _1; -// Validate(Acquire, [(*_2): Test/ReScope(Remainder { block: ItemLocalId(20), first_statement_index: 3 }) (imm)]); +// Validate(Acquire, [(*_2): Test/ReScope(Remainder { block: ItemLocalId(24), first_statement_index: 3 }) (imm)]); // StorageLive(_4); // StorageLive(_5); -// Validate(Suspend(ReScope(Node(ItemLocalId(18)))), [((*_2).0: i32): i32/ReScope(Remainder { block: ItemLocalId(20), first_statement_index: 3 }) (imm)]); +// Validate(Suspend(ReScope(Node(ItemLocalId(22)))), [((*_2).0: i32): i32/ReScope(Remainder { block: ItemLocalId(24), first_statement_index: 3 }) (imm)]); // _5 = &ReErased ((*_2).0: i32); -// Validate(Acquire, [(*_5): i32/ReScope(Node(ItemLocalId(18))) (imm)]); -// Validate(Suspend(ReScope(Node(ItemLocalId(18)))), [(*_5): i32/ReScope(Node(ItemLocalId(18))) (imm)]); +// Validate(Acquire, [(*_5): i32/ReScope(Node(ItemLocalId(22))) (imm)]); +// Validate(Suspend(ReScope(Node(ItemLocalId(22)))), [(*_5): i32/ReScope(Node(ItemLocalId(22))) (imm)]); // _4 = &ReErased (*_5); -// Validate(Acquire, [(*_4): i32/ReScope(Node(ItemLocalId(18))) (imm)]); -// Validate(Release, [_3: (), _4: &ReScope(Node(ItemLocalId(18))) i32]); +// Validate(Acquire, [(*_4): i32/ReScope(Node(ItemLocalId(22))) (imm)]); +// Validate(Release, [_3: (), _4: &ReScope(Node(ItemLocalId(22))) i32]); // _3 = const foo(move _4) -> bb1; // } // bb1: { // Validate(Acquire, [_3: ()]); -// EndRegion(ReScope(Node(ItemLocalId(18)))); +// EndRegion(ReScope(Node(ItemLocalId(22)))); // StorageDead(_4); // StorageDead(_5); // _0 = (); -// EndRegion(ReScope(Remainder { block: ItemLocalId(20), first_statement_index: 3 })); +// EndRegion(ReScope(Remainder { block: ItemLocalId(24), first_statement_index: 3 })); // StorageDead(_2); // StorageDead(_1); // return; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/validate_4.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/validate_4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/validate_4.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/validate_4.rs 2018-12-04 23:41:40.000000000 +0000 @@ -48,11 +48,11 @@ // } // END rustc.write_42.EraseRegions.after.mir // START rustc.write_42-{{closure}}.EraseRegions.after.mir -// fn write_42::{{closure}}(_1: &ReErased [closure@NodeId(22)], _2: *mut i32) -> () { +// fn write_42::{{closure}}(_1: &ReErased [closure@NodeId(32)], _2: *mut i32) -> () { // ... // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId(0/1:9 ~ validate_4[317d]::write_42[0]::{{closure}}[0]), BrEnv) [closure@NodeId(22)], _2: *mut i32]); -// Validate(Release, [_1: &ReFree(DefId(0/1:9 ~ validate_4[317d]::write_42[0]::{{closure}}[0]), BrEnv) [closure@NodeId(22)], _2: *mut i32]); +// Validate(Acquire, [_1: &ReFree(DefId(0/1:9 ~ validate_4[317d]::write_42[0]::{{closure}}[0]), BrEnv) [closure@NodeId(32)], _2: *mut i32]); +// Validate(Release, [_1: &ReFree(DefId(0/1:9 ~ validate_4[317d]::write_42[0]::{{closure}}[0]), BrEnv) [closure@NodeId(32)], _2: *mut i32]); // (*_2) = const 23i32; // _0 = (); // return; @@ -76,11 +76,11 @@ // } // END rustc.test.EraseRegions.after.mir // START rustc.main-{{closure}}.EraseRegions.after.mir -// fn main::{{closure}}(_1: &ReErased [closure@NodeId(60)], _2: &ReErased mut i32) -> bool { +// fn main::{{closure}}(_1: &ReErased [closure@NodeId(80)], _2: &ReErased mut i32) -> bool { // ... // bb0: { -// Validate(Acquire, [_1: &ReFree(DefId(0/1:10 ~ validate_4[317d]::main[0]::{{closure}}[0]), BrEnv) [closure@NodeId(60)], _2: &ReFree(DefId(0/1:10 ~ validate_4[317d]::main[0]::{{closure}}[0]), BrAnon(0)) mut i32]); -// Validate(Release, [_1: &ReFree(DefId(0/1:10 ~ validate_4[317d]::main[0]::{{closure}}[0]), BrEnv) [closure@NodeId(60)], _2: &ReFree(DefId(0/1:10 ~ validate_4[317d]::main[0]::{{closure}}[0]), BrAnon(0)) mut i32]); +// Validate(Acquire, [_1: &ReFree(DefId(0/1:10 ~ validate_4[317d]::main[0]::{{closure}}[0]), BrEnv) [closure@NodeId(80)], _2: &ReFree(DefId(0/1:10 ~ validate_4[317d]::main[0]::{{closure}}[0]), BrAnon(0)) mut i32]); +// Validate(Release, [_1: &ReFree(DefId(0/1:10 ~ validate_4[317d]::main[0]::{{closure}}[0]), BrEnv) [closure@NodeId(80)], _2: &ReFree(DefId(0/1:10 ~ validate_4[317d]::main[0]::{{closure}}[0]), BrAnon(0)) mut i32]); // StorageLive(_3); // ... // _0 = const write_42(move _3) -> bb1; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/validate_5.rs rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/validate_5.rs --- rustc-1.30.0+dfsg1+llvm/src/test/mir-opt/validate_5.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/mir-opt/validate_5.rs 2018-12-04 23:41:40.000000000 +0000 @@ -46,19 +46,19 @@ // } // END rustc.test.EraseRegions.after.mir // START rustc.main-{{closure}}.EraseRegions.after.mir -// fn main::{{closure}}(_1: &ReErased [closure@NodeId(46)], _2: &ReErased mut i32) -> bool { +// fn main::{{closure}}(_1: &ReErased [closure@NodeId(62)], _2: &ReErased mut i32) -> bool { // ... // bb0: { -// 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]); +// Validate(Acquire, [_1: &ReFree(DefId(0/1:9 ~ validate_5[317d]::main[0]::{{closure}}[0]), BrEnv) [closure@NodeId(62)], _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(12)))), [(*_2): i32]); +// Validate(Suspend(ReScope(Node(ItemLocalId(16)))), [(*_2): i32]); // _5 = &ReErased mut (*_2); -// Validate(Acquire, [(*_5): i32/ReScope(Node(ItemLocalId(12)))]); +// Validate(Acquire, [(*_5): i32/ReScope(Node(ItemLocalId(16)))]); // _4 = move _5 as *mut i32 (Misc); // _3 = move _4; -// EndRegion(ReScope(Node(ItemLocalId(12)))); +// EndRegion(ReScope(Node(ItemLocalId(16)))); // StorageDead(_4); // StorageDead(_5); // Validate(Release, [_0: bool, _3: *mut i32]); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/ascii-only-character-escape.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/ascii-only-character-escape.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/ascii-only-character-escape.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/ascii-only-character-escape.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -fn main() { - let x = "\x80"; //~ ERROR may only be used - let y = "\xff"; //~ ERROR may only be used - let z = "\xe2"; //~ ERROR may only be used - let a = b"\x00e2"; // ok because byte literal -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/associated-types-project-from-hrtb-explicit.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/associated-types-project-from-hrtb-explicit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/associated-types-project-from-hrtb-explicit.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/associated-types-project-from-hrtb-explicit.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -// Test you can't use a higher-ranked trait bound inside of a qualified -// path (just won't parse). - -pub trait Foo { - type A; - - fn get(&self, t: T) -> Self::A; -} - -fn foo2(x: Foo<&'x isize>>::A) - //~^ ERROR expected identifier, found keyword `for` - //~| ERROR expected one of `::` or `>` -{ -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/assoc-oddities-1.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/assoc-oddities-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/assoc-oddities-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/assoc-oddities-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn that_odd_parse() { - // following lines below parse and must not fail - x = if c { a } else { b }(); - x = if true { 1 } else { 0 } as *mut _; - // however this does not parse and probably should fail to retain compat? - // NB: `..` here is arbitrary, failure happens/should happen ∀ops that aren’t `=` - // see assoc-oddities-2 and assoc-oddities-3 - ..if c { a } else { b }[n]; //~ ERROR expected one of -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/assoc-oddities-2.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/assoc-oddities-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/assoc-oddities-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/assoc-oddities-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn that_odd_parse() { - // see assoc-oddities-1 for explanation - x..if c { a } else { b }[n]; //~ ERROR expected one of -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/attr-bad-meta-2.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/attr-bad-meta-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/attr-bad-meta-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/attr-bad-meta-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[path =] //~ ERROR unexpected token: `]` -mod m {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/attr-bad-meta-3.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/attr-bad-meta-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/attr-bad-meta-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/attr-bad-meta-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[path() token] //~ ERROR expected `]`, found `token` -mod m {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/attr-bad-meta.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/attr-bad-meta.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/attr-bad-meta.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/attr-bad-meta.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(unrestricted_attribute_tokens)] - -#[path*] //~ ERROR expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `*` -mod m {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/attr-before-eof.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/attr-before-eof.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/attr-before-eof.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/attr-before-eof.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -#[derive(Debug)] //~ERROR expected item after attributes diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/attr-dangling-in-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/attr-dangling-in-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/attr-dangling-in-fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/attr-dangling-in-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// error-pattern:expected statement - -fn f() { - #[foo = "bar"] -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/attr-dangling-in-mod.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/attr-dangling-in-mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/attr-dangling-in-mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/attr-dangling-in-mod.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// error-pattern:expected item - -fn main() { -} - -#[foo = "bar"] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/attr.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/attr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/attr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/attr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -#![feature(lang_items)] - -fn main() {} - -#![lang(foo)] //~ ERROR an inner attribute is not permitted in this context -fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/attrs-after-extern-mod.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/attrs-after-extern-mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/attrs-after-extern-mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/attrs-after-extern-mod.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// Constants (static variables) can be used to match in patterns, but mutable -// statics cannot. This ensures that there's some form of error if this is -// attempted. - -extern crate libc; - -extern { - static mut rust_dbg_static_mut: libc::c_int; - pub fn rust_dbg_static_mut_check_four(); - #[cfg(stage37)] //~ ERROR expected item after attributes -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bad-char-literals.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bad-char-literals.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bad-char-literals.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bad-char-literals.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -// ignore-tidy-cr -// ignore-tidy-tab -fn main() { - // these literals are just silly. - '''; - //~^ ERROR: character constant must be escaped: ' - - // note that this is a literal "\n" byte - ' -'; - //~^^ ERROR: character constant must be escaped: \n - - // note that this is a literal "\r" byte - ' '; //~ ERROR: character constant must be escaped: \r - - // note that this is a literal tab character here - ' '; - //~^ ERROR: character constant must be escaped: \t -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bad-lit-suffixes.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bad-lit-suffixes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bad-lit-suffixes.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bad-lit-suffixes.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - - -extern - "C"suffix //~ ERROR ABI spec with a suffix is invalid - fn foo() {} - -extern - "C"suffix //~ ERROR ABI spec with a suffix is invalid -{} - -fn main() { - ""suffix; //~ ERROR string literal with a suffix is invalid - b""suffix; //~ ERROR byte string literal with a suffix is invalid - r#""#suffix; //~ ERROR string literal with a suffix is invalid - br#""#suffix; //~ ERROR byte string literal with a suffix is invalid - 'a'suffix; //~ ERROR char literal with a suffix is invalid - b'a'suffix; //~ ERROR byte literal with a suffix is invalid - - 1234u1024; //~ ERROR invalid width `1024` for integer literal - 1234i1024; //~ ERROR invalid width `1024` for integer literal - 1234f1024; //~ ERROR invalid width `1024` for float literal - 1234.5f1024; //~ ERROR invalid width `1024` for float literal - - 1234suffix; //~ ERROR invalid suffix `suffix` for numeric literal - 0b101suffix; //~ ERROR invalid suffix `suffix` for numeric literal - 1.0suffix; //~ ERROR invalid suffix `suffix` for float literal - 1.0e10suffix; //~ ERROR invalid suffix `suffix` for float literal -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bad-match.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bad-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bad-match.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bad-match.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// error-pattern: expected - -fn main() { - let isize x = 5; - match x; -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bad-name.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bad-name.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bad-name.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bad-name.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// error-pattern: expected - -fn main() { - let x.y::.z foo; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bad-pointer-type.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bad-pointer-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bad-pointer-type.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bad-pointer-type.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn foo(_: *()) { - //~^ expected mut or const in raw pointer type (use `*mut T` or `*const T` as appropriate) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bad-value-ident-false.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bad-value-ident-false.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bad-value-ident-false.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bad-value-ident-false.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn false() { } //~ ERROR expected identifier, found keyword `false` -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bad-value-ident-true.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bad-value-ident-true.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bad-value-ident-true.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bad-value-ident-true.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn true() { } //~ ERROR expected identifier, found keyword `true` -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/better-expected.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/better-expected.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/better-expected.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/better-expected.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - let x: [isize 3]; //~ ERROR expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `3` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bind-struct-early-modifiers.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bind-struct-early-modifiers.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bind-struct-early-modifiers.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bind-struct-early-modifiers.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - struct Foo { x: isize } - match (Foo { x: 10 }) { - Foo { ref x: ref x } => {}, //~ ERROR expected `,` - _ => {} - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bound-single-question-mark.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bound-single-question-mark.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bound-single-question-mark.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bound-single-question-mark.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn f() {} //~ ERROR expected identifier, found `>` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bounds-lifetime-1.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bounds-lifetime-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bounds-lifetime-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bounds-lifetime-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -type A = for<'a 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `'b` - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bounds-lifetime-2.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bounds-lifetime-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bounds-lifetime-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bounds-lifetime-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -type A = for<'a + 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `+` - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bounds-lifetime.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bounds-lifetime.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bounds-lifetime.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bounds-lifetime.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -type A = for<'a:> fn(); // OK -type A = for<'a:,> fn(); // OK -type A = for<'a> fn(); // OK -type A = for<> fn(); // OK -type A = for<'a: 'b + 'c> fn(); // OK (rejected later by ast_validation) -type A = for<'a: 'b,> fn(); // OK(rejected later by ast_validation) -type A = for<'a: 'b +> fn(); // OK (rejected later by ast_validation) -type A = for<'a, T> fn(); // OK (rejected later by ast_validation) -type A = for<,> fn(); //~ ERROR expected one of `>`, identifier, or lifetime, found `,` - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bounds-lifetime-where-1.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bounds-lifetime-where-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bounds-lifetime-where-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bounds-lifetime-where-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -type A where 'a; //~ ERROR expected `:`, found `;` - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bounds-lifetime-where.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bounds-lifetime-where.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bounds-lifetime-where.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bounds-lifetime-where.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -type A where 'a: 'b + 'c = u8; // OK -type A where 'a: 'b, = u8; // OK -type A where 'a: = u8; // OK -type A where 'a:, = u8; // OK -type A where 'a: 'b + 'c = u8; // OK -type A where = u8; // OK -type A where 'a: 'b + = u8; // OK -type A where , = u8; //~ ERROR expected one of `=`, lifetime, or type, found `,` - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bounds-type.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bounds-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bounds-type.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bounds-type.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -struct S< - T: 'a + Tr, // OK - T: Tr + 'a, // OK - T: 'a, // OK - T:, // OK - T: ?for<'a> Trait, // OK - T: Tr +, // OK - T: ?'a, //~ ERROR `?` may only modify trait bounds, not lifetime bounds ->; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bounds-type-where.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bounds-type-where.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/bounds-type-where.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/bounds-type-where.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -type A where for<'a> for<'b> Trait1 + ?Trait2: 'a + Trait = u8; // OK -type A where T: Trait, = u8; // OK -type A where T: = u8; // OK -type A where T:, = u8; // OK -type A where T: Trait + Trait = u8; // OK -type A where = u8; // OK -type A where T: Trait + = u8; // OK -type A where T, = u8; -//~^ ERROR expected one of `!`, `(`, `+`, `::`, `:`, `<`, `==`, or `=`, found `,` - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/brace-after-qualified-path-in-match.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/brace-after-qualified-path-in-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/brace-after-qualified-path-in-match.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/brace-after-qualified-path-in-match.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn foo() { - match x { - ::Type{key: value} => (), - //~^ ERROR unexpected `{` after qualified path - _ => (), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/byte-literals.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/byte-literals.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/byte-literals.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/byte-literals.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - - -// ignore-tidy-tab - -static FOO: u8 = b'\f'; //~ ERROR unknown byte escape - -pub fn main() { - b'\f'; //~ ERROR unknown byte escape - b'\x0Z'; //~ ERROR invalid character in numeric character escape: Z - b' '; //~ ERROR byte constant must be escaped - b'''; //~ ERROR byte constant must be escaped - b'é'; //~ ERROR byte constant must be ASCII - b'a //~ ERROR unterminated byte constant -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/byte-string-literals.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/byte-string-literals.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/byte-string-literals.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/byte-string-literals.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - - -// ignore-tidy-tab - -static FOO: &'static [u8] = b"\f"; //~ ERROR unknown byte escape - -pub fn main() { - b"\f"; //~ ERROR unknown byte escape - b"\x0Z"; //~ ERROR invalid character in numeric character escape: Z - b"é"; //~ ERROR byte constant must be ASCII - b"a //~ ERROR unterminated double quote byte string -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/circular_modules_hello.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/circular_modules_hello.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/circular_modules_hello.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/circular_modules_hello.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// ignore-test: this is an auxiliary file for circular-modules-main.rs - -#[path = "circular_modules_main.rs"] -mod circular_modules_main; - -pub fn say_hello() { - println!("{}", circular_modules_main::hi_str()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/circular_modules_main.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/circular_modules_main.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/circular_modules_main.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/circular_modules_main.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -#[path = "circular_modules_hello.rs"] -mod circular_modules_hello; //~ ERROR: circular modules - -pub fn hi_str() -> String { - "Hi!".to_string() -} - -fn main() { - circular_modules_hello::say_hello(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/class-implements-bad-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/class-implements-bad-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/class-implements-bad-trait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/class-implements-bad-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// error-pattern:nonexistent -class cat : nonexistent { - let meows: usize; - new(in_x : usize) { self.meows = in_x; } -} - -fn main() { - let nyan = cat(0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/closure-return-syntax.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/closure-return-syntax.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/closure-return-syntax.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/closure-return-syntax.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we cannot parse a closure with an explicit return type -// unless it uses braces. - -fn main() { - let x = || -> i32 22; - //~^ ERROR expected one of `!`, `(`, `+`, `::`, `<`, or `{`, found `22` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/column-offset-1-based.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/column-offset-1-based.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/column-offset-1-based.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/column-offset-1-based.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -# //~ ERROR 13:1: 13:2: expected `[`, found `` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/default.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/default.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/default.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/default.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// Test successful and unsuccessful parsing of the `default` contextual keyword - -trait Foo { - fn foo() -> T; -} - -impl Foo for u8 { - default fn foo() -> T { - T::default() - } -} - -impl Foo for u16 { - pub default fn foo() -> T { - T::default() - } -} - -impl Foo for u32 { - default pub fn foo() -> T { T::default() } //~ ERROR expected one of -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/doc-after-struct-field.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/doc-after-struct-field.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/doc-after-struct-field.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/doc-after-struct-field.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z continue-parse-after-error - -struct X { - a: u8 /** document a */, - //~^ ERROR found a documentation comment that doesn't document anything - //~| HELP maybe a comment was intended -} - -struct Y { - a: u8 /// document a - //~^ ERROR found a documentation comment that doesn't document anything - //~| HELP maybe a comment was intended -} - -fn main() { - let x = X { a: 1 }; - let y = Y { a: 1 }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/do-catch-suggests-try.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/do-catch-suggests-try.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/do-catch-suggests-try.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/do-catch-suggests-try.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - let _: Option<()> = do catch {}; - //~^ ERROR found removed `do catch` syntax - //~^^ HELP Following RFC #2388, the new non-placeholder syntax is `try` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/doc-before-attr.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/doc-before-attr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/doc-before-attr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/doc-before-attr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -/// hi -#[derive(Debug)] //~ERROR expected item after attributes diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/doc-before-eof.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/doc-before-eof.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/doc-before-eof.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/doc-before-eof.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -/// hi //~ERROR expected item after doc comment diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/doc-before-extern-rbrace.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/doc-before-extern-rbrace.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/doc-before-extern-rbrace.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/doc-before-extern-rbrace.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -extern { - /// hi - //~^ ERROR expected item after doc comment -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/doc-before-fn-rbrace.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/doc-before-fn-rbrace.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/doc-before-fn-rbrace.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/doc-before-fn-rbrace.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z continue-parse-after-error -fn main() { - /// document - //~^ ERROR found a documentation comment that doesn't document anything - //~| HELP maybe a comment was intended -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/doc-before-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/doc-before-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/doc-before-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/doc-before-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z continue-parse-after-error -fn /// document -foo() {} -//~^^ ERROR expected identifier, found `/// document` - -fn main() { - foo(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/doc-before-mod-rbrace.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/doc-before-mod-rbrace.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/doc-before-mod-rbrace.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/doc-before-mod-rbrace.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z continue-parse-after-error -mod Foo { - /// document - //~^ ERROR expected item after doc comment -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/doc-before-rbrace.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/doc-before-rbrace.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/doc-before-rbrace.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/doc-before-rbrace.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - println!("Hi"); /// hi - //~^ ERROR found a documentation comment that doesn't document anything - //~| HELP maybe a comment was intended -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/doc-before-semi.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/doc-before-semi.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/doc-before-semi.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/doc-before-semi.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - /// hi - //~^ ERROR found a documentation comment that doesn't document anything - //~| HELP maybe a comment was intended - ; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/doc-before-struct-rbrace-1.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/doc-before-struct-rbrace-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/doc-before-struct-rbrace-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/doc-before-struct-rbrace-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z continue-parse-after-error -struct X { - a: u8, - /// document - //~^ ERROR found a documentation comment that doesn't document anything - //~| HELP maybe a comment was intended -} - -fn main() { - let y = X {a: 1}; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/doc-before-struct-rbrace-2.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/doc-before-struct-rbrace-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/doc-before-struct-rbrace-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/doc-before-struct-rbrace-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z continue-parse-after-error -struct X { - a: u8 /// document - //~^ ERROR found a documentation comment that doesn't document anything - //~| HELP maybe a comment was intended -} - -fn main() { - let y = X {a: 1}; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/duplicate-visibility.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/duplicate-visibility.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/duplicate-visibility.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/duplicate-visibility.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// error-pattern:expected one of `(`, `fn`, `static`, `type`, or `}` here -extern { - pub pub fn foo(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/empty-impl-semicolon.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/empty-impl-semicolon.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/empty-impl-semicolon.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/empty-impl-semicolon.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -impl Foo; //~ ERROR expected one of `!`, `(`, `+`, `::`, `<`, `for`, `where`, or `{`, found `;` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/extern-crate-unexpected-token.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/extern-crate-unexpected-token.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/extern-crate-unexpected-token.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/extern-crate-unexpected-token.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crte foo; //~ ERROR expected one of `crate`, `fn`, or `{`, found `crte` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/extern-expected-fn-or-brace.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/extern-expected-fn-or-brace.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/extern-expected-fn-or-brace.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/extern-expected-fn-or-brace.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// Verifies that the expected token errors for `extern crate` are -// raised - -extern "C" mod foo; //~ERROR expected one of `fn` or `{`, found `mod` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/extern-foreign-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/extern-foreign-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/extern-foreign-crate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/extern-foreign-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// Verifies that the expected token errors for `extern crate` are -// raised - -extern crate foo {} //~ERROR expected one of `;` or `as`, found `{` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/extern-no-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/extern-no-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/extern-no-fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/extern-no-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -extern { //~ ERROR missing `fn`, `type`, or `static` for extern-item declaration - f(); -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/impl-qpath.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/impl-qpath.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/impl-qpath.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/impl-qpath.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -impl <*const u8>::AssocTy {} // OK -impl ::AssocTy {} // OK -impl <'a + Trait>::AssocTy {} // OK -impl <::AssocTy>::AssocTy {} // OK - -FAIL //~ ERROR diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/import-from-path.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/import-from-path.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/import-from-path.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/import-from-path.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// error-pattern:expected -use foo::{bar}::baz diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/import-from-rename.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/import-from-rename.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/import-from-rename.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/import-from-rename.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// error-pattern:expected - -use foo::{bar} as baz; - -mod foo { - pub fn bar() {} -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/import-glob-path.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/import-glob-path.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/import-glob-path.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/import-glob-path.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// error-pattern:expected -use foo::*::bar diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/import-glob-rename.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/import-glob-rename.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/import-glob-rename.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/import-glob-rename.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// error-pattern:expected - -use foo::* as baz; - -mod foo { - pub fn bar() {} -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/inner-attr-after-doc-comment.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/inner-attr-after-doc-comment.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/inner-attr-after-doc-comment.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/inner-attr-after-doc-comment.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -#![feature(lang_items)] -/** - * My module - */ - -#![recursion_limit="100"] -//~^ ERROR an inner attribute is not permitted following an outer doc comment -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/inner-attr.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/inner-attr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/inner-attr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/inner-attr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -#[feature(lang_items)] - -#![recursion_limit="100"] //~ ERROR an inner attribute is not permitted following an outer attribute -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/int-literal-too-large-span.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/int-literal-too-large-span.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/int-literal-too-large-span.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/int-literal-too-large-span.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// issue #17123 - -fn main() { - 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 - //~^ ERROR int literal is too large - ; // the span shouldn't point to this. -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-10392-2.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-10392-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-10392-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-10392-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -struct A { foo: isize } - -fn a() -> A { panic!() } - -fn main() { - let A { .., } = a(); //~ ERROR: expected `}` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-10392.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-10392.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-10392.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-10392.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -struct A { foo: isize } - -fn a() -> A { panic!() } - -fn main() { - let A { , } = a(); //~ ERROR: expected ident -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-14303-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-14303-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-14303-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-14303-enum.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -enum X<'a, T, 'b> { -//~^ ERROR lifetime parameters must be declared prior to type parameters - A(&'a T) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-14303-fncall.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-14303-fncall.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-14303-fncall.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-14303-fncall.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - (0..4) - .map(|x| x * 2) - .collect::>() - //~^ ERROR lifetime parameters must be declared prior to type parameters -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-14303-fn-def.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-14303-fn-def.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-14303-fn-def.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-14303-fn-def.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn foo<'a, T, 'b>(x: &'a T) {} -//~^ ERROR lifetime parameters must be declared prior to type parameters diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-14303-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-14303-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-14303-impl.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-14303-impl.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -struct X { x: isize } - -impl<'a, T, 'b> X {} -//~^ ERROR lifetime parameters must be declared prior to type parameters diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-14303-path.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-14303-path.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-14303-path.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-14303-path.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn bar<'a, T>(x: mymodule::X<'a, T, 'b, 'c>) {} -//~^ ERROR lifetime parameters must be declared prior to type parameters diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-14303-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-14303-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-14303-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-14303-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -struct X<'a, T, 'b> { -//~^ ERROR lifetime parameters must be declared prior to type parameters - x: &'a T -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-14303-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-14303-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-14303-trait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-14303-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -trait Foo<'a, T, 'b> {} -//~^ ERROR lifetime parameters must be declared prior to type parameters diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-15914.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-15914.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-15914.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-15914.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - let ref - (); //~ ERROR expected identifier, found `(` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-1655.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-1655.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-1655.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-1655.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// error-pattern:expected `[`, found `vec` -mod blade_runner { - #vec[doc( - brief = "Blade Runner is probably the best movie ever", - desc = "I like that in the world of Blade Runner it is always - raining, and that it's always night time. And Aliens - was also a really good movie. - - Alien 3 was crap though." - )] -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-17383.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-17383.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-17383.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-17383.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -enum X { - A = - b'a' //~ ERROR discriminator values can only be used with a field-less enum - , - B(isize) -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-17718-const-mut.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-17718-const-mut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-17718-const-mut.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-17718-const-mut.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -const -mut //~ ERROR: const globals cannot be mutable -//~^ HELP did you mean to declare a static? -FOO: usize = 3; - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-17904-2.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-17904-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-17904-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-17904-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -struct Bar { x: T } where T: Copy //~ ERROR expected item, found `where` - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-17904.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-17904.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-17904.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-17904.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -struct Baz where U: Eq(U); //This is parsed as the new Fn* style parenthesis syntax. -struct Baz where U: Eq(U) -> R; // Notice this parses as well. -struct Baz(U) where U: Eq; // This rightfully signals no error as well. -struct Foo where T: Copy, (T); //~ ERROR expected one of `:`, `==`, or `=`, found `;` - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-1802-1.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-1802-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-1802-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-1802-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// error-pattern:no valid digits found for number -fn main() { - log(error, 0b); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-1802-2.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-1802-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-1802-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-1802-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// error-pattern:no valid digits found for number -fn main() { - log(error, 0b_usize); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-19096.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-19096.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-19096.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-19096.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - let t = (42, 42); - t.0::; //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `::` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-19398.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-19398.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-19398.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-19398.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -trait T { - extern "Rust" unsafe fn foo(); //~ ERROR expected `fn`, found `unsafe` -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-20711-2.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-20711-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-20711-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-20711-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -// ignore-tidy-linelength - -struct Foo; - -impl Foo { - fn foo() {} - - #[stable(feature = "rust1", since = "1.0.0")] -} //~ ERROR expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, or - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-20711.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-20711.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-20711.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-20711.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -// ignore-tidy-linelength - -struct Foo; - -impl Foo { - #[stable(feature = "rust1", since = "1.0.0")] -} //~ ERROR expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, or - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-21153.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-21153.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-21153.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-21153.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -trait MyTrait: Iterator { //~ ERROR missing `fn`, `type`, or `const` - Item = T; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-22647.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-22647.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-22647.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-22647.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let caller = |f: F| //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `<` - where F: Fn() -> i32 - { - let x = f(); - println!("Y {}",x); - return x; - }; - - caller(bar_handler); -} - -fn bar_handler() -> i32 { - 5 -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-22712.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-22712.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-22712.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-22712.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Foo { - buffer: B -} - -fn bar() { - let Foo> //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `<` -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-2354-1.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-2354-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-2354-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-2354-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -static foo: isize = 2; } //~ ERROR unexpected close delimiter: diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-23620-invalid-escapes.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-23620-invalid-escapes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-23620-invalid-escapes.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-23620-invalid-escapes.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -fn main() { - let _ = b"\u{a66e}"; - //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string - - let _ = b'\u{a66e}'; - //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string - - let _ = b'\u'; - //~^ ERROR incorrect unicode escape sequence - //~^^ ERROR unicode escape sequences cannot be used as a byte or in a byte string - - let _ = b'\x5'; - //~^ ERROR numeric character escape is too short - - let _ = b'\xxy'; - //~^ ERROR invalid character in numeric character escape: x - //~^^ ERROR invalid character in numeric character escape: y - - let _ = '\x5'; - //~^ ERROR numeric character escape is too short - - let _ = '\xxy'; - //~^ ERROR invalid character in numeric character escape: x - //~^^ ERROR invalid character in numeric character escape: y - - let _ = b"\u{a4a4} \xf \u"; - //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string - //~^^ ERROR invalid character in numeric character escape: - //~^^^ ERROR incorrect unicode escape sequence - //~^^^^ ERROR unicode escape sequences cannot be used as a byte or in a byte string - - let _ = "\xf \u"; - //~^ ERROR invalid character in numeric character escape: - //~^^ ERROR form of character escape may only be used with characters in the range [\x00-\x7f] - //~^^^ ERROR incorrect unicode escape sequence -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-24197.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-24197.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-24197.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-24197.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let buf[0] = 0; //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `[` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-24375.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-24375.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-24375.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-24375.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -static tmp : [&'static str; 2] = ["hello", "he"]; - -fn main() { - let z = "hello"; - match z { - tmp[0] => {} //~ ERROR expected one of `=>`, `@`, `if`, or `|`, found `[` - _ => {} - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-24780.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-24780.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-24780.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-24780.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Verify that '>' is not both expected and found at the same time, as it used -// to happen in #24780. For example, following should be an error: -// expected one of ..., `>`, ... found `>` -// -// compile-flags: -Z parse-only - -fn foo() -> Vec> { - //~^ ERROR expected one of `!`, `+`, `::`, `where`, or `{`, found `>` - Vec::new() -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-27255.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-27255.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-27255.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-27255.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -impl A .. {} //~ ERROR - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-30318.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-30318.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-30318.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-30318.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn foo() { } - -//! Misplaced comment... -//~^ ERROR expected outer doc comment -//~| NOTE inner doc comments like this (starting with `//!` or `/*!`) can only appear before items - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-3036.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-3036.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-3036.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-3036.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// Testing that semicolon tokens are printed correctly in errors - -fn main() -{ - let x = 3 -} //~ ERROR: expected one of `.`, `;`, `?`, or an operator, found `}` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-32214.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-32214.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-32214.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-32214.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -pub fn test >() {} -//~^ ERROR type parameters must be declared prior to associated type bindings - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-32446.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-32446.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-32446.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-32446.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() {} - -// This used to end up in an infite loop trying to bump past EOF. -trait T { ... } //~ ERROR diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-32501.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-32501.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-32501.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-32501.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - let a = 0; - let _b = 0; - let _ = 0; - let mut b = 0; - let mut _b = 0; - let mut _ = 0; //~ ERROR expected identifier, found reserved identifier `_` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-32505.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-32505.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-32505.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-32505.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -pub fn test() { - foo(|_|) //~ ERROR expected expression, found `)` -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-33262.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-33262.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-33262.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-33262.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// Issue #33262 - -pub fn main() { - for i in 0..a as { } - //~^ ERROR expected type, found `{` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-33413.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-33413.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-33413.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-33413.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -impl S { - fn f(*, a: u8) -> u8 {} //~ ERROR expected pattern, found `*` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-33455.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-33455.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-33455.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-33455.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use foo.bar; //~ ERROR expected one of `::`, `;`, or `as`, found `.` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-33569.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-33569.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-33569.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-33569.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z no-analysis - -macro_rules! foo { - { $+ } => { //~ ERROR expected identifier, found `+` - //~^ ERROR missing fragment specifier - $(x)(y) //~ ERROR expected `*` or `+` - } -} - -foo!(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-37113.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-37113.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-37113.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-37113.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! test_macro { - ( $( $t:ty ),* $(),*) => { - enum SomeEnum { - $( $t, )* //~ ERROR expected identifier, found `String` - }; - }; -} - -fn main() { - test_macro!(String,); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-37234.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-37234.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-37234.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-37234.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! failed { - () => {{ - let x = 5 ""; //~ ERROR found `""` - }} -} - -fn main() { - failed!(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-43692.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-43692.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-43692.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-43692.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - '\u{_10FFFF}'; //~ ERROR invalid start of unicode escape -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-5544-a.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-5544-a.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-5544-a.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-5544-a.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - let __isize = 340282366920938463463374607431768211456; // 2^128 - //~^ ERROR int literal is too large -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-5544-b.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-5544-b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-5544-b.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-5544-b.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - let __isize = 0xffff_ffff_ffff_ffff_ffff_ffff_ffff_ffff_ff; - //~^ ERROR int literal is too large -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-5806.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-5806.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-5806.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-5806.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-windows -// ignore-freebsd -// ignore-openbsd -// ignore-netbsd -// ignore-bitrig - -// compile-flags: -Z parse-only - -#[path = "../compile-fail"] -mod foo; //~ ERROR: a directory - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-6610.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-6610.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-6610.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-6610.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -trait Foo { fn a() } //~ ERROR expected `;` or `{`, found `}` - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-8537.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-8537.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/issue-8537.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/issue-8537.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -pub extern - "invalid-ab_isize" //~ ERROR invalid ABI -fn foo() {} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-abstract.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-abstract.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-abstract.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-abstract.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - let abstract = (); //~ ERROR expected pattern, found reserved keyword `abstract` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-as-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-as-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-as-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-as-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py as' - -fn main() { - let as = "foo"; //~ error: expected pattern, found keyword `as` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-box-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-box-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-box-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-box-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - let box = "foo"; //~ error: expected pattern, found `=` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-break-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-break-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-break-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-break-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py break' - -fn main() { - let break = "foo"; //~ error: expected pattern, found keyword `break` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-const-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-const-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-const-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-const-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py const' - -fn main() { - let const = "foo"; //~ error: expected pattern, found keyword `const` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-continue-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-continue-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-continue-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-continue-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py continue' - -fn main() { - let continue = "foo"; //~ error: expected pattern, found keyword `continue` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-else-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-else-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-else-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-else-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py else' - -fn main() { - let else = "foo"; //~ error: expected pattern, found keyword `else` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-enum-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-enum-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-enum-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-enum-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py enum' - -fn main() { - let enum = "foo"; //~ error: expected pattern, found keyword `enum` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-final.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-final.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-final.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-final.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - let final = (); //~ ERROR expected pattern, found reserved keyword `final` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-fn-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-fn-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-fn-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-fn-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py fn' - -fn main() { - let fn = "foo"; //~ error: expected pattern, found keyword `fn` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-for-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-for-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-for-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-for-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py for' - -fn main() { - let for = "foo"; //~ error: expected pattern, found keyword `for` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-if-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-if-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-if-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-if-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py if' - -fn main() { - let if = "foo"; //~ error: expected pattern, found keyword `if` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-impl-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-impl-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-impl-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-impl-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py impl' - -fn main() { - let impl = "foo"; //~ error: expected pattern, found keyword `impl` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-in-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-in-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-in-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-in-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py in' - -fn main() { - let in = "foo"; //~ error: expected pattern, found keyword `in` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-let-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-let-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-let-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-let-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py let' - -fn main() { - let let = "foo"; //~ error: expected pattern, found keyword `let` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-loop-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-loop-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-loop-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-loop-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py loop' - -fn main() { - let loop = "foo"; //~ error: expected pattern, found keyword `loop` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-match-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-match-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-match-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-match-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py match' - -fn main() { - let match = "foo"; //~ error: expected pattern, found keyword `match` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-mod-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-mod-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-mod-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-mod-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py mod' - -fn main() { - let mod = "foo"; //~ error: expected pattern, found keyword `mod` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-move-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-move-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-move-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-move-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py move' - -fn main() { - let move = "foo"; //~ error: expected pattern, found keyword `move` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-mut-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-mut-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-mut-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-mut-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - let mut = "foo"; //~ error: expected identifier, found `=` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-override.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-override.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-override.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-override.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - let override = (); //~ ERROR expected pattern, found reserved keyword `override` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-pub-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-pub-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-pub-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-pub-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py pub' - -fn main() { - let pub = "foo"; //~ error: expected pattern, found keyword `pub` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-ref-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-ref-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-ref-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-ref-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - let ref = "foo"; //~ error: expected identifier, found `=` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-return-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-return-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-return-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-return-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py return' - -fn main() { - let return = "foo"; //~ error: expected pattern, found keyword `return` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -pub mod break { - //~^ ERROR expected identifier, found keyword `break` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keywords-followed-by-double-colon.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keywords-followed-by-double-colon.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keywords-followed-by-double-colon.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keywords-followed-by-double-colon.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - struct::foo(); - //~^ ERROR expected identifier -} -fn bar() { - mut::baz(); - //~^ ERROR expected expression, found keyword `mut` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-static-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-static-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-static-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-static-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py static' - -fn main() { - let static = "foo"; //~ error: expected pattern, found keyword `static` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-struct-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-struct-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-struct-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-struct-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py struct' - -fn main() { - let struct = "foo"; //~ error: expected pattern, found keyword `struct` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-trait-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-trait-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-trait-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-trait-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py trait' - -fn main() { - let trait = "foo"; //~ error: expected pattern, found keyword `trait` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-try-as-identifier-edition2018.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-try-as-identifier-edition2018.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-try-as-identifier-edition2018.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-try-as-identifier-edition2018.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only --edition 2018 - -fn main() { - let try = "foo"; //~ error: expected pattern, found reserved keyword `try` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-type-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-type-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-type-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-type-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py type' - -fn main() { - let type = "foo"; //~ error: expected pattern, found keyword `type` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-typeof.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-typeof.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-typeof.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-typeof.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - let typeof = (); //~ ERROR expected pattern, found reserved keyword `typeof` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-unsafe-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-unsafe-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-unsafe-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-unsafe-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py unsafe' - -fn main() { - let unsafe = "foo"; //~ error: expected pattern, found keyword `unsafe` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-use-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-use-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-use-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-use-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py use' - -fn main() { - let use = "foo"; //~ error: expected pattern, found keyword `use` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-where-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-where-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-where-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-where-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py where' - -fn main() { - let where = "foo"; //~ error: expected pattern, found keyword `where` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-while-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-while-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/keyword-while-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/keyword-while-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This file was auto-generated using 'src/etc/generate-keyword-tests.py while' - -fn main() { - let while = "foo"; //~ error: expected pattern, found keyword `while` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lex-bad-binary-literal.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lex-bad-binary-literal.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lex-bad-binary-literal.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lex-bad-binary-literal.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -fn main() { - 0b121; //~ ERROR invalid digit for a base 2 literal - 0b10_10301; //~ ERROR invalid digit for a base 2 literal - 0b30; //~ ERROR invalid digit for a base 2 literal - 0b41; //~ ERROR invalid digit for a base 2 literal - 0b5; //~ ERROR invalid digit for a base 2 literal - 0b6; //~ ERROR invalid digit for a base 2 literal - 0b7; //~ ERROR invalid digit for a base 2 literal - 0b8; //~ ERROR invalid digit for a base 2 literal - 0b9; //~ ERROR invalid digit for a base 2 literal -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lex-bad-char-literals-1.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lex-bad-char-literals-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lex-bad-char-literals-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lex-bad-char-literals-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error -static c3: char = - '\x1' //~ ERROR: numeric character escape is too short -; - -static s: &'static str = - "\x1" //~ ERROR: numeric character escape is too short -; - -static c: char = - '\●' //~ ERROR: unknown character escape -; - -static s: &'static str = - "\●" //~ ERROR: unknown character escape -; - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lex-bad-char-literals-2.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lex-bad-char-literals-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lex-bad-char-literals-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lex-bad-char-literals-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This test needs to the last one appearing in this file as it kills the parser -static c: char = - 'nope' //~ ERROR: character literal may only contain one codepoint: 'nope' -; - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lex-bad-char-literals-3.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lex-bad-char-literals-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lex-bad-char-literals-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lex-bad-char-literals-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// This test needs to the last one appearing in this file as it kills the parser -static c: char = - '●●' //~ ERROR: character literal may only contain one codepoint -; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lex-bad-char-literals-4.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lex-bad-char-literals-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lex-bad-char-literals-4.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lex-bad-char-literals-4.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -// -// This test needs to the last one appearing in this file as it kills the parser -static c: char = - '● //~ ERROR: character literal may only contain one codepoint: '● -; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lex-bad-char-literals-5.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lex-bad-char-literals-5.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lex-bad-char-literals-5.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lex-bad-char-literals-5.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -// -// This test needs to the last one appearing in this file as it kills the parser -static c: char = - '\x10\x10' //~ ERROR: character literal may only contain one codepoint -; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lex-bad-numeric-literals.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lex-bad-numeric-literals.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lex-bad-numeric-literals.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lex-bad-numeric-literals.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -fn main() { - 0o1.0; //~ ERROR: octal float literal is not supported - 0o2f32; //~ ERROR: octal float literal is not supported - 0o3.0f32; //~ ERROR: octal float literal is not supported - 0o4e4; //~ ERROR: octal float literal is not supported - 0o5.0e5; //~ ERROR: octal float literal is not supported - 0o6e6f32; //~ ERROR: octal float literal is not supported - 0o7.0e7f64; //~ ERROR: octal float literal is not supported - 0x8.0e+9; //~ ERROR: hexadecimal float literal is not supported - 0x9.0e-9; //~ ERROR: hexadecimal float literal is not supported - 0o; //~ ERROR: no valid digits - 1e+; //~ ERROR: expected at least one digit in exponent - 0x539.0; //~ ERROR: hexadecimal float literal is not supported - 9900000000000000000000000000999999999999999999999999999999; //~ ERROR: int literal is too large - 9900000000000000000000000000999999999999999999999999999999; //~ ERROR: int literal is too large - 0x; //~ ERROR: no valid digits - 0xu32; //~ ERROR: no valid digits - 0ou32; //~ ERROR: no valid digits - 0bu32; //~ ERROR: no valid digits - 0b; //~ ERROR: no valid digits - 0o123f64; //~ ERROR: octal float literal is not supported - 0o123.456; //~ ERROR: octal float literal is not supported - 0b101f64; //~ ERROR: binary float literal is not supported - 0b111.101; //~ ERROR: binary float literal is not supported -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lex-bad-octal-literal.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lex-bad-octal-literal.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lex-bad-octal-literal.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lex-bad-octal-literal.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -fn main() { - 0o18; //~ ERROR invalid digit for a base 8 literal - 0o1234_9_5670; //~ ERROR invalid digit for a base 8 literal -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lex-bad-token.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lex-bad-token.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lex-bad-token.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lex-bad-token.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -● //~ ERROR: unknown start of token diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lex-bare-cr-string-literal-doc-comment.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lex-bare-cr-string-literal-doc-comment.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lex-bare-cr-string-literal-doc-comment.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lex-bare-cr-string-literal-doc-comment.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -// ignore-tidy-cr - -/// doc comment with bare CR: ' ' -pub fn foo() {} -//~^^ ERROR: bare CR not allowed in doc-comment - -/** block doc comment with bare CR: ' ' */ -pub fn bar() {} -//~^^ ERROR: bare CR not allowed in block doc-comment - -fn main() { - //! doc comment with bare CR: ' ' - //~^ ERROR: bare CR not allowed in doc-comment - - /*! block doc comment with bare CR: ' ' */ - //~^ ERROR: bare CR not allowed in block doc-comment - - // the following string literal has a bare CR in it - let _s = "foo bar"; //~ ERROR: bare CR not allowed in string - - // the following string literal has a bare CR in it - let _s = r"bar foo"; //~ ERROR: bare CR not allowed in raw string - - // the following string literal has a bare CR in it - let _s = "foo\ bar"; //~ ERROR: unknown character escape: \r -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lex-stray-backslash.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lex-stray-backslash.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lex-stray-backslash.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lex-stray-backslash.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -\ //~ ERROR: unknown start of token: \ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lifetime-in-pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lifetime-in-pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lifetime-in-pattern.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lifetime-in-pattern.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn test(&'a str) { - //~^ ERROR unexpected lifetime `'a` in pattern -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lifetime-semicolon.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lifetime-semicolon.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/lifetime-semicolon.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/lifetime-semicolon.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -struct Foo<'a, 'b> { - a: &'a &'b i32 -} - -fn foo<'a, 'b>(x: &mut Foo<'a; 'b>) {} -//~^ ERROR expected one of `,` or `>`, found `;` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/macro-bad-delimiter-ident.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/macro-bad-delimiter-ident.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/macro-bad-delimiter-ident.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/macro-bad-delimiter-ident.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - foo! bar < //~ ERROR expected `(` or `{`, found `<` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/macro-doc-comments-1.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/macro-doc-comments-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/macro-doc-comments-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/macro-doc-comments-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! outer { - (#[$outer:meta]) => () -} - -outer! { - //! Inner -} //~^ ERROR no rules expected the token `!` - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/macro-doc-comments-2.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/macro-doc-comments-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/macro-doc-comments-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/macro-doc-comments-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! inner { - (#![$inner:meta]) => () -} - -inner! { - /// Outer -} //~^ ERROR no rules expected the token `[` - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/macro-keyword.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/macro-keyword.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/macro-keyword.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/macro-keyword.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn macro() { //~ ERROR expected identifier, found reserved keyword `macro` -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/macro-mismatched-delim-brace-paren.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/macro-mismatched-delim-brace-paren.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/macro-mismatched-delim-brace-paren.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/macro-mismatched-delim-brace-paren.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - foo! { - bar, "baz", 1, 2.0 - ) //~ ERROR incorrect close delimiter -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/macro-mismatched-delim-paren-brace.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/macro-mismatched-delim-paren-brace.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/macro-mismatched-delim-paren-brace.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/macro-mismatched-delim-paren-brace.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - foo! ( - bar, "baz", 1, 2.0 - } //~ ERROR incorrect close delimiter -} //~ ERROR unexpected close delimiter: `}` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/macro-repeat.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/macro-repeat.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/macro-repeat.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/macro-repeat.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! mac { - ( $($v:tt)* ) => ( - $v //~ ERROR still repeating at this depth - ) -} - -fn main() { - mac!(0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/macros-no-semicolon-items.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/macros-no-semicolon-items.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/macros-no-semicolon-items.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/macros-no-semicolon-items.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -macro_rules! foo() //~ ERROR semicolon - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/macros-no-semicolon.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/macros-no-semicolon.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/macros-no-semicolon.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/macros-no-semicolon.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - assert_eq!(1, 2) - assert_eq!(3, 4) //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `assert_eq` - println!("hello"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/match-arrows-block-then-binop.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/match-arrows-block-then-binop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/match-arrows-block-then-binop.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/match-arrows-block-then-binop.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - - match 0 { - 0 => { - } + 5 //~ ERROR expected pattern, found `+` - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/match-vec-invalid.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/match-vec-invalid.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/match-vec-invalid.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/match-vec-invalid.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - let a = Vec::new(); - match a { - [1, tail.., tail..] => {}, //~ ERROR: expected one of `,` or `@`, found `..` - _ => () - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/mod_file_not_exist.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/mod_file_not_exist.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/mod_file_not_exist.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/mod_file_not_exist.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-windows - -// compile-flags: -Z parse-only - -mod not_a_real_file; //~ ERROR file not found for module `not_a_real_file` -//~^ HELP name the file either not_a_real_file.rs or not_a_real_file/mod.rs inside the directory - -fn main() { - assert_eq!(mod_file_aux::bar(), 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/mod_file_not_exist_windows.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/mod_file_not_exist_windows.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/mod_file_not_exist_windows.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/mod_file_not_exist_windows.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-android -// ignore-bitrig -// ignore-cloudabi -// ignore-dragonfly -// ignore-emscripten -// ignore-freebsd -// ignore-gnu -// ignore-haiku -// ignore-ios -// ignore-linux -// ignore-macos -// ignore-netbsd -// ignore-openbsd -// ignore-solaris - -// compile-flags: -Z parse-only - -mod not_a_real_file; //~ ERROR file not found for module `not_a_real_file` -//~^ HELP name the file either not_a_real_file.rs or not_a_real_file\mod.rs inside the directory - -fn main() { - assert_eq!(mod_file_aux::bar(), 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/mod_file_with_path_attr.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/mod_file_with_path_attr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/mod_file_with_path_attr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/mod_file_with_path_attr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -#[path = "not_a_real_file.rs"] -mod m; //~ ERROR not_a_real_file.rs - -fn main() { - assert_eq!(m::foo(), 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/multiline-comment-line-tracking.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/multiline-comment-line-tracking.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/multiline-comment-line-tracking.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/multiline-comment-line-tracking.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:18:3 - -/* 1 - * 2 - * 3 - */ -fn main() { - %; // parse error on line 18, but is reported on line 6 instead. -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/multitrait.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/multitrait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/multitrait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/multitrait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -struct S { - y: isize -} - -impl Cmp, ToString for S { -//~^ ERROR: expected one of `!`, `(`, `+`, `::`, `<`, `for`, `where`, or `{`, found `,` - fn eq(&&other: S) { false } - fn to_string(&self) -> String { "hi".to_string() } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/mut-patterns.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/mut-patterns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/mut-patterns.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/mut-patterns.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// Can't put mut in non-ident pattern - -pub fn main() { - struct Foo { x: isize } - let mut Foo { x: x } = Foo { x: 3 }; //~ ERROR: expected one of `:`, `;`, `=`, or `@`, found `{` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/new-unicode-escapes-1.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/new-unicode-escapes-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/new-unicode-escapes-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/new-unicode-escapes-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -pub fn main() { - let s = "\u{2603"; //~ ERROR unterminated unicode escape (needed a `}`) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/new-unicode-escapes-2.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/new-unicode-escapes-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/new-unicode-escapes-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/new-unicode-escapes-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -pub fn main() { - let s = "\u{260311111111}"; //~ ERROR overlong unicode escape (must have at most 6 hex digits) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/new-unicode-escapes-3.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/new-unicode-escapes-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/new-unicode-escapes-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/new-unicode-escapes-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -pub fn main() { - let s1 = "\u{d805}"; //~ ERROR invalid unicode character escape - let s2 = "\u{ffffff}"; //~ ERROR invalid unicode character escape -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/new-unicode-escapes-4.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/new-unicode-escapes-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/new-unicode-escapes-4.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/new-unicode-escapes-4.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -pub fn main() { - let s = "\u{lol}"; - //~^ ERROR invalid character in unicode escape: l -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/no-binary-float-literal.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/no-binary-float-literal.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/no-binary-float-literal.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/no-binary-float-literal.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// error-pattern:binary float literal is not supported - -fn main() { - 0b101010f64; - 0b101.010; - 0b101p4f64; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/no-hex-float-literal.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/no-hex-float-literal.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/no-hex-float-literal.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/no-hex-float-literal.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// error-pattern:hexadecimal float literal is not supported - -fn main() { - 0xABC.Df; - 0x567.89; - 0xDEAD.BEEFp-2f; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/not-a-pred.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/not-a-pred.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/not-a-pred.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/not-a-pred.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// error-pattern: lt - -fn f(a: isize, b: isize) : lt(a, b) { } - -fn lt(a: isize, b: isize) { } - -fn main() { let a: isize = 10; let b: isize = 23; check (lt(a, b)); f(a, b); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/no-unsafe-self.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/no-unsafe-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/no-unsafe-self.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/no-unsafe-self.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -trait A { - fn foo(*mut self); //~ ERROR cannot pass `self` by raw pointer - fn baz(*const self); //~ ERROR cannot pass `self` by raw pointer - fn bar(*self); //~ ERROR cannot pass `self` by raw pointer -} - -struct X; -impl A for X { - fn foo(*mut self) { } //~ ERROR cannot pass `self` by raw pointer - fn baz(*const self) { } //~ ERROR cannot pass `self` by raw pointer - fn bar(*self) { } //~ ERROR cannot pass `self` by raw pointer -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/omitted-arg-in-item-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/omitted-arg-in-item-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/omitted-arg-in-item-fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/omitted-arg-in-item-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn foo(x) { //~ ERROR expected one of `:` or `@`, found `)` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/paamayim-nekudotayim.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/paamayim-nekudotayim.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/paamayim-nekudotayim.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/paamayim-nekudotayim.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// http://phpsadness.com/sad/1 - -fn main() { - ::; //~ ERROR expected identifier, found `;` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/paren-after-qualified-path-in-match.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/paren-after-qualified-path-in-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/paren-after-qualified-path-in-match.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/paren-after-qualified-path-in-match.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn foo() { - match x { - ::Type(2) => (), - //~^ ERROR unexpected `(` after qualified path - _ => (), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-1.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - match 42 { - x < 7 => (), - //~^ error: expected one of `=>`, `@`, `if`, or `|`, found `<` - _ => () - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-2.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn a(B<) {} - //~^ error: expected one of `:` or `@`, found `<` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-3.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct Foo(T, T); - -impl Foo { - fn foo(&self) { - match *self { - Foo(x, y) => { - //~^ error: expected one of `=>`, `@`, `if`, or `|`, found `<` - println!("Goodbye, World!") - } - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-4.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-4.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-4.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -enum BtNode { - Node(u32,Box,Box), - Leaf(u32), -} - -fn main() { - let y = match x { - Foo::A(value) => value, //~ error: expected one of `=>`, `@`, `if`, or `|`, found `<` - Foo::B => 7, - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-5.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-5.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-5.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-5.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let v[0] = v[1]; //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `[` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-6.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-6.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-6.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-6.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let Test(&desc[..]) = x; //~ ERROR: expected one of `)`, `,`, or `@`, found `[` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-7.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-7.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-7.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-lt-bracket-7.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - for thing(x[]) in foo {} //~ ERROR: expected one of `)`, `,`, or `@`, found `[` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-ranges-1.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-ranges-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-ranges-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-ranges-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Parsing of range patterns - -fn main() { - let macropus!() ..= 11 = 12; //~ error: expected one of `:`, `;`, or `=`, found `..=` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-ranges-2.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-ranges-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-ranges-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-ranges-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Parsing of range patterns - -fn main() { - let 10 ..= makropulos!() = 12; //~ error: expected one of `::`, `:`, `;`, or `=`, found `!` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-ranges-3.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-ranges-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-ranges-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-ranges-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Parsing of range patterns - -fn main() { - let 10 ..= 10 + 3 = 12; //~ expected one of `:`, `;`, or `=`, found `+` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-ranges-4.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-ranges-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-ranges-4.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-ranges-4.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Parsing of range patterns - -fn main() { - let 10 - 3 ..= 10 = 8; - //~^ error: expected one of `...`, `..=`, `..`, `:`, `;`, or `=`, found `-` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-ref-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-ref-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-ref-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-ref-enum.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn matcher(x: Option) { - match x { - ref Some(i) => {} //~ ERROR expected identifier, found enum pattern - None => {} - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-tuple-1.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-tuple-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-tuple-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-tuple-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - match 0 { - (, ..) => {} //~ ERROR expected pattern, found `,` - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-tuple-2.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-tuple-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-tuple-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-tuple-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - match 0 { - (pat, ..,) => {} //~ ERROR trailing comma is not permitted after `..` - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-tuple-3.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-tuple-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-tuple-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-tuple-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - match 0 { - (.., pat, ..) => {} //~ ERROR `..` can only be used once per tuple or tuple struct pattern - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-tuple-4.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-tuple-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-tuple-4.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-tuple-4.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - match 0 { - (.. pat) => {} //~ ERROR expected one of `)` or `,`, found `pat` - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-tuple-5.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-tuple-5.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pat-tuple-5.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pat-tuple-5.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - match 0 { - (pat ..) => {} //~ ERROR unexpected token: `)` - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pub-item-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pub-item-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pub-item-macro.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pub-item-macro.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Issue #14660 - -macro_rules! priv_x { () => { - static x: u32 = 0; -}} - -macro_rules! pub_x { () => { - pub priv_x!(); //~ ERROR can't qualify macro invocation with `pub` - //~^ HELP try adjusting the macro to put `pub` inside the invocation -}} - -mod foo { - pub_x!(); -} - -fn main() { - let y: u32 = foo::x; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pub-method-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pub-method-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/pub-method-macro.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/pub-method-macro.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Issue #18317 - -mod bleh { - macro_rules! defn { - ($n:ident) => ( - fn $n (&self) -> i32 { - println!("{}", stringify!($n)); - 1 - } - ) - } - - #[derive(Copy, Clone)] - pub struct S; - - impl S { - pub defn!(f); //~ ERROR can't qualify macro invocation with `pub` - //~^ HELP try adjusting the macro to put `pub` inside the invocation - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/range-3.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/range-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/range-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/range-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// Test range syntax - syntax errors. - -pub fn main() { - let r = 1..2..3; - //~^ ERROR expected one of `.`, `;`, `?`, or an operator, found `..` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/range-4.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/range-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/range-4.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/range-4.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// Test range syntax - syntax errors. - -pub fn main() { - let r = ..1..2; - //~^ ERROR expected one of `.`, `;`, `?`, or an operator, found `..` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/range_inclusive_dotdotdot.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/range_inclusive_dotdotdot.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/range_inclusive_dotdotdot.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/range_inclusive_dotdotdot.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -// Make sure that inclusive ranges with `...` syntax don't parse. - -use std::ops::RangeToInclusive; - -fn return_range_to() -> RangeToInclusive { - return ...1; //~ERROR unexpected token: `...` - //~^HELP use `..` for an exclusive range - //~^^HELP or `..=` for an inclusive range -} - -pub fn main() { - let x = ...0; //~ERROR unexpected token: `...` - //~^HELP use `..` for an exclusive range - //~^^HELP or `..=` for an inclusive range - - let x = 5...5; //~ERROR unexpected token: `...` - //~^HELP use `..` for an exclusive range - //~^^HELP or `..=` for an inclusive range - - for _ in 0...1 {} //~ERROR unexpected token: `...` - //~^HELP use `..` for an exclusive range - //~^^HELP or `..=` for an inclusive range -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/range_inclusive.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/range_inclusive.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/range_inclusive.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/range_inclusive.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Make sure that inclusive ranges with no end point don't parse. - -pub fn main() { - for _ in 1..= {} //~ERROR inclusive range with no end - //~^HELP bounded at the end -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/raw-byte-string-eof.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/raw-byte-string-eof.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/raw-byte-string-eof.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/raw-byte-string-eof.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - - -pub fn main() { - br##"a"#; //~ unterminated raw string -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/raw-byte-string-literals.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/raw-byte-string-literals.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/raw-byte-string-literals.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/raw-byte-string-literals.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - - -pub fn main() { - br"é"; //~ ERROR raw byte string must be ASCII - br##~"a"~##; //~ ERROR only `#` is allowed in raw string delimitation -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/raw-str-delim.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/raw-str-delim.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/raw-str-delim.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/raw-str-delim.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -static s: &'static str = - r#~"#"~# //~ ERROR found invalid character; only `#` is allowed in raw string delimitation -; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/raw-str-unbalanced.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/raw-str-unbalanced.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/raw-str-unbalanced.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/raw-str-unbalanced.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -static s: &'static str = - r#" - "## //~ ERROR expected one of `.`, `;`, `?`, or an operator, found `#` -; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/raw-str-unterminated.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/raw-str-unterminated.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/raw-str-unterminated.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/raw-str-unterminated.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -static s: &'static str = - r#" string literal goes on - and on - //~^^ ERROR unterminated raw string diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/recover-enum2.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/recover-enum2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/recover-enum2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/recover-enum2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -fn main() { - enum Test { - Var1, - Var2(String), - Var3 { - abc: {}, //~ ERROR: expected type, found `{` - }, - } - - // recover... - let a = 1; - enum Test2 { - Fine, - } - - enum Test3 { - StillFine { - def: i32, - }, - } - - { - // fail again - enum Test4 { - Nope(i32 {}) //~ ERROR: found `{` - //~^ ERROR: found `{` - } - } - // still recover later - let bad_syntax = _; //~ ERROR: expected expression, found reserved identifier `_` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/recover-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/recover-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/recover-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/recover-enum.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -fn main() { - enum Test { - Very - Bad //~ ERROR found `Bad` - Stuff - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/recover-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/recover-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/recover-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/recover-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -fn main() { - struct Test { - Very - Bad //~ ERROR found `Bad` - Stuff - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/regions-out-of-scope-slice.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/regions-out-of-scope-slice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/regions-out-of-scope-slice.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/regions-out-of-scope-slice.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// ignore-test blk region isn't supported in the front-end - -fn foo(cond: bool) { - // Here we will infer a type that uses the - // region of the if stmt then block, but in the scope: - let mut x; //~ ERROR foo - - if cond { - x = &'blk [1,2,3]; - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-closure-lifetime.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-closure-lifetime.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-closure-lifetime.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-closure-lifetime.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -type closure = Box; -//~^ ERROR expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `/` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-enum-newtype.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-enum-newtype.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-enum-newtype.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-enum-newtype.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -enum e = isize; //~ ERROR expected one of `<`, `where`, or `{`, found `=` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-extern-const.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-extern-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-extern-const.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-extern-const.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -extern { - const i: isize; - //~^ ERROR extern items cannot be `const` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-field-let.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-field-let.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-field-let.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-field-let.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -struct s { - let foo: (), - //~^ ERROR expected identifier, found keyword `let` - //~^^ ERROR expected `:`, found `foo` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-field-semicolon.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-field-semicolon.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-field-semicolon.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-field-semicolon.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -struct s { - bar: (); - //~^ ERROR expected `,`, or `}`, found `;` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-fixed-vec.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-fixed-vec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-fixed-vec.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-fixed-vec.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -type v = [isize * 3]; //~ ERROR expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `*` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-fn-sigil.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-fn-sigil.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-fn-sigil.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-fn-sigil.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn f() { - let x: fn~() = || (); //~ ERROR expected `(`, found `~` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-mode.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-mode.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-mode.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-mode.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn f(+x: isize) {} //~ ERROR expected pattern, found `+` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-mut-vec-expr.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-mut-vec-expr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-mut-vec-expr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-mut-vec-expr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn f() { - let v = [mut 1, 2, 3, 4]; //~ ERROR expected expression, found keyword `mut` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-mut-vec-ty.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-mut-vec-ty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-mut-vec-ty.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-mut-vec-ty.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -type v = [mut isize]; //~ ERROR expected type, found keyword `mut` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-ptr-lifetime.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-ptr-lifetime.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-ptr-lifetime.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-ptr-lifetime.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -type bptr = &lifetime/isize; //~ ERROR expected one of `!`, `(`, `::`, `;`, or `<`, found `/` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-record.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-record.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-record.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-record.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -type t = { f: () }; //~ ERROR expected type, found `{` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-static-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-static-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-static-fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-static-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -// ignore-tidy-linelength - -struct S; - -impl S { - static fn f() {} -} -//~^^ ERROR expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-uniq-mut-expr.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-uniq-mut-expr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-uniq-mut-expr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-uniq-mut-expr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn f() { - let a_box = box mut 42; //~ ERROR expected expression, found keyword `mut` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-uniq-mut-ty.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-uniq-mut-ty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-uniq-mut-ty.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-uniq-mut-ty.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -type mut_box = Box; //~ ERROR expected one of `>`, lifetime, or type, found `mut` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-with-1.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-with-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-with-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-with-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn removed_with() { - struct S { - foo: (), - bar: (), - } - - let a = S { foo: (), bar: () }; - let b = S { foo: () with a }; - //~^ ERROR expected one of `,`, `.`, `?`, `}`, or an operator, found `with` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-with-2.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-with-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-with-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/removed-syntax-with-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn removed_with() { - struct S { - foo: (), - bar: (), - } - - let a = S { foo: (), bar: () }; - let b = S { foo: (), with a }; - //~^ ERROR expected one of `,` or `}`, found `a` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/require-parens-for-chained-comparison.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/require-parens-for-chained-comparison.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/require-parens-for-chained-comparison.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/require-parens-for-chained-comparison.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn f() {} - -fn main() { - false == false == false; - //~^ ERROR: chained comparison operators require parentheses - - false == 0 < 2; - //~^ ERROR: chained comparison operators require parentheses - - f(); - //~^ ERROR: chained comparison operators require parentheses - //~| HELP: use `::<...>` instead of `<...>` - //~| HELP: or use `(...)` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/struct-field-numeric-shorthand.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/struct-field-numeric-shorthand.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/struct-field-numeric-shorthand.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/struct-field-numeric-shorthand.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -struct Rgb(u8, u8, u8); - -fn main() { - let _ = Rgb { 0, 1, 2 }; //~ ERROR expected identifier, found `0` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/struct-literal-in-for.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/struct-literal-in-for.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/struct-literal-in-for.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/struct-literal-in-for.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -struct Foo { - x: isize, -} - -impl Foo { - fn hi(&self) -> bool { - true - } -} - -fn main() { - for x in Foo { - x: 3 //~ ERROR expected type, found `3` - }.hi() { //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `{` - println!("yo"); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/struct-literal-in-if.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/struct-literal-in-if.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/struct-literal-in-if.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/struct-literal-in-if.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -struct Foo { - x: isize, -} - -impl Foo { - fn hi(&self) -> bool { - true - } -} - -fn main() { - if Foo { - x: 3 //~ ERROR expected type, found `3` - }.hi() { //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `{` - println!("yo"); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/struct-literal-in-match-discriminant.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/struct-literal-in-match-discriminant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/struct-literal-in-match-discriminant.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/struct-literal-in-match-discriminant.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -struct Foo { - x: isize, -} - -fn main() { - match Foo { - x: 3 //~ ERROR expected one of `=>`, `@`, `if`, or `|`, found `:` - } { - Foo { - x: x - } => {} //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `=>` - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/struct-literal-in-while.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/struct-literal-in-while.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/struct-literal-in-while.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/struct-literal-in-while.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -struct Foo { - x: isize, -} - -impl Foo { - fn hi(&self) -> bool { - true - } -} - -fn main() { - while Foo { - x: 3 //~ ERROR expected type, found `3` - }.hi() { //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `{` - println!("yo"); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/struct-literal-restrictions-in-lamda.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/struct-literal-restrictions-in-lamda.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/struct-literal-restrictions-in-lamda.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/struct-literal-restrictions-in-lamda.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -struct Foo { - x: isize, -} - -impl Foo { - fn hi(&self) -> bool { - true - } -} - -fn main() { - while || Foo { - x: 3 //~ ERROR expected type, found `3` - }.hi() { //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `{` - println!("yo"); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/tag-variant-disr-non-nullary.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/tag-variant-disr-non-nullary.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/tag-variant-disr-non-nullary.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/tag-variant-disr-non-nullary.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -//error-pattern: discriminator values can only be used with a field-less enum - -enum color { - red = 0xff0000, - green = 0x00ff00, - blue = 0x0000ff, - black = 0x000000, - white = 0xffffff, - other (str), -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trailing-carriage-return-in-string.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trailing-carriage-return-in-string.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trailing-carriage-return-in-string.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trailing-carriage-return-in-string.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// ignore-tidy-cr -// Issue #11669 - -fn main() { - // \r\n - let ok = "This is \ - a test"; - // \r only - let bad = "This is \ a test"; - //~^ ERROR unknown character escape: \r - //~^^ HELP this is an isolated carriage return - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trait-bounds-not-on-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trait-bounds-not-on-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trait-bounds-not-on-impl.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trait-bounds-not-on-impl.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -trait Foo { -} - -struct Bar; - -impl Foo + Owned for Bar { //~ ERROR expected a trait, found type -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trait-non-item-macros.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trait-non-item-macros.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trait-non-item-macros.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trait-non-item-macros.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! bah { - ($a:expr) => ($a) - //~^ ERROR expected one of `async`, `const`, `extern`, `fn`, `type`, or `unsafe`, found `2` -} - -trait bar { - bah!(2); -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trait-object-bad-parens.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trait-object-bad-parens.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trait-object-bad-parens.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trait-object-bad-parens.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -fn main() { - let _: Box<((Copy)) + Copy>; - //~^ ERROR expected a path on the left-hand side of `+`, not `((Copy))` - let _: Box<(Copy + Copy) + Copy>; - //~^ ERROR expected a path on the left-hand side of `+`, not `(Copy + Copy)` - let _: Box<(Copy +) + Copy>; - //~^ ERROR expected a path on the left-hand side of `+`, not `(Copy)` - let _: Box<(dyn Copy) + Copy>; - //~^ ERROR expected a path on the left-hand side of `+`, not `(dyn Copy)` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trait-object-lifetime-parens.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trait-object-lifetime-parens.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trait-object-lifetime-parens.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trait-object-lifetime-parens.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -fn f() {} //~ ERROR parenthesized lifetime bounds are not supported - -fn main() { - let _: Box; //~ ERROR parenthesized lifetime bounds are not supported - let _: Box<('a) + Copy>; //~ ERROR expected type, found `'a` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trait-object-macro-matcher.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trait-object-macro-matcher.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trait-object-macro-matcher.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trait-object-macro-matcher.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// A single lifetime is not parsed as a type. -// `ty` matcher in particular doesn't accept a single lifetime - -macro_rules! m { - ($t: ty) => ( let _: $t; ) -} - -fn main() { - m!('static); //~ ERROR expected type, found `'static` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trait-object-polytrait-priority.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trait-object-polytrait-priority.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trait-object-polytrait-priority.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trait-object-polytrait-priority.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Trait<'a> {} - -fn main() { - let _: &for<'a> Trait<'a> + 'static; - //~^ ERROR expected a path on the left-hand side of `+`, not `&for<'a> Trait<'a>` - //~| HELP try adding parentheses - //~| SUGGESTION &(for<'a> Trait<'a> + 'static) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trait-object-trait-parens.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trait-object-trait-parens.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trait-object-trait-parens.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trait-object-trait-parens.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn f Trait<'a>)>() {} - -fn main() { - let _: Box<(Copy) + (?Sized) + (for<'a> Trait<'a>)>; - let _: Box<(?Sized) + (for<'a> Trait<'a>) + (Copy)>; - let _: Box<(for<'a> Trait<'a>) + (Copy) + (?Sized)>; -} - -FAIL //~ ERROR diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trait-plusequal-splitting.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trait-plusequal-splitting.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trait-plusequal-splitting.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trait-plusequal-splitting.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -// Fixes issue where `+` in generics weren't parsed if they were part of a `+=`. - -struct Whitespace { t: T } -struct TokenSplit { t: T } - -fn main() { -} - -FAIL //~ ERROR diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trait-pub-assoc-const.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trait-pub-assoc-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trait-pub-assoc-const.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trait-pub-assoc-const.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Foo { - pub const Foo: u32; - //~^ ERROR expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trait-pub-assoc-ty.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trait-pub-assoc-ty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trait-pub-assoc-ty.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trait-pub-assoc-ty.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Foo { - pub type Foo; - //~^ ERROR expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trait-pub-method.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trait-pub-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/trait-pub-method.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/trait-pub-method.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Foo { - pub fn foo(); - //~^ ERROR expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/type-parameters-in-field-exprs.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/type-parameters-in-field-exprs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/type-parameters-in-field-exprs.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/type-parameters-in-field-exprs.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -struct Foo { - x: isize, - y: isize, -} - -fn main() { - let f = Foo { - x: 1, - y: 2, - }; - f.x::; - //~^ ERROR field expressions may not have generic arguments - f.x::<>; - //~^ ERROR field expressions may not have generic arguments - f.x::(); - //~^ ERROR field expressions may not have generic arguments -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/unbalanced-doublequote.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/unbalanced-doublequote.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/unbalanced-doublequote.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/unbalanced-doublequote.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - - -// error-pattern: unterminated double quote string - - -fn main() { - " -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/underscore-suffix-for-float.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/underscore-suffix-for-float.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/underscore-suffix-for-float.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/underscore-suffix-for-float.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let a = 42._; //~ ERROR expected identifier, found reserved identifier `_` - //~^ ERROR `{integer}` is a primitive type and therefore doesn't have fields -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/underscore-suffix-for-string.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/underscore-suffix-for-string.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/underscore-suffix-for-string.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/underscore-suffix-for-string.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let _ = "Foo"_; - //~^ WARNING underscore literal suffix is not allowed - //~| WARNING this was previously accepted - //~| NOTE issue #42326 -} - -FAIL -//~^ ERROR -//~| NOTE diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/unicode-chars.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/unicode-chars.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/unicode-chars.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/unicode-chars.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - let y = 0; - //~^ ERROR unknown start of token: \u{37e} - //~^^ HELP Unicode character ';' (Greek Question Mark) looks like ';' (Semicolon), but it is not -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/unsized2.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/unsized2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/unsized2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/unsized2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// Test syntax checks for `type` keyword. - -fn f() {} - -pub fn main() { - f(); //~ ERROR expected expression, found keyword `type` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/unsized.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/unsized.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/unsized.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/unsized.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// Test syntax checks for `type` keyword. - -struct S1 for type; //~ ERROR expected `where`, `{`, `(`, or `;` after struct name, found `for` - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/use-as-where-use-ends-with-mod-sep.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/use-as-where-use-ends-with-mod-sep.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/use-as-where-use-ends-with-mod-sep.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/use-as-where-use-ends-with-mod-sep.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -use std::any:: as foo; //~ ERROR expected identifier, found keyword `as` -//~^ ERROR: expected one of `::`, `;`, or `as`, found `foo` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/use-ends-with-mod-sep.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/use-ends-with-mod-sep.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/use-ends-with-mod-sep.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/use-ends-with-mod-sep.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -use std::any::; //~ ERROR expected identifier, found `;` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/variadic-ffi-3.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/variadic-ffi-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/variadic-ffi-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/variadic-ffi-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn foo(x: isize, ...) { - //~^ ERROR: only foreign functions are allowed to be variadic -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/variadic-ffi-4.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/variadic-ffi-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/variadic-ffi-4.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/variadic-ffi-4.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -extern "C" fn foo(x: isize, ...) { - //~^ ERROR: only foreign functions are allowed to be variadic -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/virtual-structs.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/virtual-structs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/virtual-structs.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/virtual-structs.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -// Test diagnostics for the removed struct inheritance feature. - -virtual struct SuperStruct { //~ ERROR expected item, found `virtual` - f1: isize, -} - -struct Struct : SuperStruct; - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/where-clauses-no-bounds-or-predicates.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/where-clauses-no-bounds-or-predicates.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/where-clauses-no-bounds-or-predicates.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/where-clauses-no-bounds-or-predicates.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -// Empty predicate list is OK -fn equal1(_: &T, _: &T) -> bool where { - true -} - -// Empty bound list is OK -fn equal2(_: &T, _: &T) -> bool where T: { - true -} - -fn foo<'a>() where 'a {} -//~^ ERROR expected `:`, found `{` - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/where_with_bound.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/where_with_bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/where_with_bound.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/where_with_bound.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn foo() where ::Item: ToString, T: Iterator { } -//~^ ERROR generic parameters on `where` clauses are reserved for future use - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/wrong-escape-of-curly-braces.rs rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/wrong-escape-of-curly-braces.rs --- rustc-1.30.0+dfsg1+llvm/src/test/parse-fail/wrong-escape-of-curly-braces.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/parse-fail/wrong-escape-of-curly-braces.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn f() { - let ok = "{{everything fine}}"; - let bad = "\{it is wrong\}"; - //~^ ERROR unknown character escape: { - //~^^ HELP if used in a formatting string, curly braces are escaped with `{{` and `}}` - //~^^^ ERROR unknown character escape: } - //~^^^^ HELP if used in a formatting string, curly braces are escaped with `{{` and `}}` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/pretty/issue_12590_a.rs rustc-1.31.0+dfsg1+llvm/src/test/pretty/issue_12590_a.rs --- rustc-1.30.0+dfsg1+llvm/src/test/pretty/issue_12590_a.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/pretty/issue_12590_a.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// pp-exact + +// The next line should not be expanded + +mod issue_12590_b; + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/pretty/issue_12590_b.rs rustc-1.31.0+dfsg1+llvm/src/test/pretty/issue_12590_b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/pretty/issue_12590_b.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/pretty/issue_12590_b.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Second part of two file test +fn b() { } + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/pretty/issue_12590_c.pp rustc-1.31.0+dfsg1+llvm/src/test/pretty/issue_12590_c.pp --- rustc-1.30.0+dfsg1+llvm/src/test/pretty/issue_12590_c.pp 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/pretty/issue_12590_c.pp 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +#![feature(prelude_import)] +#![no_std] +#[prelude_import] +use ::std::prelude::v1::*; +#[macro_use] +extern crate std; +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// pretty-compare-only +// pretty-mode:expanded +// pp-exact:issue_12590_c.pp + +// The next line should be expanded + +mod issue_12590_b { + + fn b() { } + fn main() { } +} +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/pretty/issue_12590_c.rs rustc-1.31.0+dfsg1+llvm/src/test/pretty/issue_12590_c.rs --- rustc-1.30.0+dfsg1+llvm/src/test/pretty/issue_12590_c.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/pretty/issue_12590_c.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// pretty-compare-only +// pretty-mode:expanded +// pp-exact:issue_12590_c.pp + +// The next line should be expanded + +mod issue_12590_b; + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/pretty/issue-54752-async-block.rs rustc-1.31.0+dfsg1+llvm/src/test/pretty/issue-54752-async-block.rs --- rustc-1.30.0+dfsg1+llvm/src/test/pretty/issue-54752-async-block.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/pretty/issue-54752-async-block.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,7 @@ +#![feature(async_await)] +#![allow(unused_parens)] + +// edition:2018 +// pp-exact + +fn main() { let _a = (async { }); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-fail/issue-29798.rs rustc-1.31.0+dfsg1+llvm/src/test/run-fail/issue-29798.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-fail/issue-29798.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-fail/issue-29798.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,6 @@ // error-pattern:index out of bounds: the len is 5 but the index is 5 -#![feature(min_const_fn)] const fn test(x: usize) -> i32 { [42;5][x] } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-make/thumb-none-cortex-m/Makefile rustc-1.31.0+dfsg1+llvm/src/test/run-make/thumb-none-cortex-m/Makefile --- rustc-1.30.0+dfsg1+llvm/src/test/run-make/thumb-none-cortex-m/Makefile 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-make/thumb-none-cortex-m/Makefile 2018-12-04 23:41:40.000000000 +0000 @@ -25,6 +25,8 @@ CRATE_URL := https://github.com/rust-embedded/cortex-m CRATE_SHA1 := a448e9156e2cb1e556e5441fd65426952ef4b927 # 0.5.0 +export RUSTFLAGS := --cap-lints=allow + all: env mkdir -p $(WORK_DIR) diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-make/wasm-export-all-symbols/bar.rs rustc-1.31.0+dfsg1+llvm/src/test/run-make/wasm-export-all-symbols/bar.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-make/wasm-export-all-symbols/bar.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-make/wasm-export-all-symbols/bar.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +#[no_mangle] +pub extern fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-make/wasm-export-all-symbols/foo.rs rustc-1.31.0+dfsg1+llvm/src/test/run-make/wasm-export-all-symbols/foo.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-make/wasm-export-all-symbols/foo.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-make/wasm-export-all-symbols/foo.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "cdylib"] + +extern crate bar; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-make/wasm-export-all-symbols/Makefile rustc-1.31.0+dfsg1+llvm/src/test/run-make/wasm-export-all-symbols/Makefile --- rustc-1.30.0+dfsg1+llvm/src/test/run-make/wasm-export-all-symbols/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-make/wasm-export-all-symbols/Makefile 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +-include ../../run-make-fulldeps/tools.mk + +ifeq ($(TARGET),wasm32-unknown-unknown) +all: + $(RUSTC) bar.rs --target wasm32-unknown-unknown + $(RUSTC) foo.rs --target wasm32-unknown-unknown + $(NODE) verify.js $(TMPDIR)/foo.wasm + $(RUSTC) bar.rs --target wasm32-unknown-unknown -O + $(RUSTC) foo.rs --target wasm32-unknown-unknown -O + $(NODE) verify.js $(TMPDIR)/foo.wasm + $(RUSTC) foo.rs --target wasm32-unknown-unknown -C lto + $(NODE) verify.js $(TMPDIR)/foo.wasm +else +all: +endif + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-make/wasm-export-all-symbols/verify.js rustc-1.31.0+dfsg1+llvm/src/test/run-make/wasm-export-all-symbols/verify.js --- rustc-1.30.0+dfsg1+llvm/src/test/run-make/wasm-export-all-symbols/verify.js 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-make/wasm-export-all-symbols/verify.js 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const fs = require('fs'); +const process = require('process'); +const assert = require('assert'); +const buffer = fs.readFileSync(process.argv[2]); + +let m = new WebAssembly.Module(buffer); +let list = WebAssembly.Module.exports(m); +console.log('exports', list); + +const my_exports = {}; +let nexports = 0; +for (const entry of list) { + if (entry.kind !== 'function') + continue; + my_exports[entry.name] = true; + nexports += 1; +} + +if (nexports != 1) + throw new Error("should only have one function export"); +if (my_exports.foo === undefined) + throw new Error("`foo` wasn't defined"); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-make-fulldeps/emit-stack-sizes/foo.rs rustc-1.31.0+dfsg1+llvm/src/test/run-make-fulldeps/emit-stack-sizes/foo.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-make-fulldeps/emit-stack-sizes/foo.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-make-fulldeps/emit-stack-sizes/foo.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +pub fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-make-fulldeps/emit-stack-sizes/Makefile rustc-1.31.0+dfsg1+llvm/src/test/run-make-fulldeps/emit-stack-sizes/Makefile --- rustc-1.30.0+dfsg1+llvm/src/test/run-make-fulldeps/emit-stack-sizes/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-make-fulldeps/emit-stack-sizes/Makefile 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +-include ../tools.mk + +# This feature only works when the output object format is ELF so we ignore +# macOS and Windows +ifdef IS_WINDOWS +# Do nothing on Windows. +all: + exit 0 +else ifneq (,$(filter $(TARGET),i686-apple-darwin x86_64-apple-darwin)) +# Do nothing on macOS. +all: + exit 0 +else +# check that the .stack_sizes section is generated +# this test requires LLVM >= 6.0.0 +vers = $(shell $(RUSTC) -Vv) +ifneq (,$(findstring LLVM version: 3,$(vers))) +all: + exit 0 +else ifneq (,$(findstring LLVM version: 4,$(vers))) +all: + exit 0 +else ifneq (,$(findstring LLVM version: 5,$(vers))) +all: + exit 0 +else +all: + $(RUSTC) -C opt-level=3 -Z emit-stack-sizes --emit=obj foo.rs + size -A $(TMPDIR)/foo.o | $(CGREP) .stack_sizes +endif +endif diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-make-fulldeps/extern-fn-reachable/main.rs rustc-1.31.0+dfsg1+llvm/src/test/run-make-fulldeps/extern-fn-reachable/main.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-make-fulldeps/extern-fn-reachable/main.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-make-fulldeps/extern-fn-reachable/main.rs 2018-12-04 23:41:40.000000000 +0000 @@ -20,8 +20,8 @@ let path = Path::new("libdylib.so"); let a = DynamicLibrary::open(Some(&path)).unwrap(); assert!(a.symbol::("fun1").is_ok()); - assert!(a.symbol::("fun2").is_err()); - assert!(a.symbol::("fun3").is_err()); + assert!(a.symbol::("fun2").is_ok()); + assert!(a.symbol::("fun3").is_ok()); assert!(a.symbol::("fun4").is_ok()); assert!(a.symbol::("fun5").is_ok()); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/abort-on-c-abi.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/abort-on-c-abi.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/abort-on-c-abi.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/abort-on-c-abi.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_must_use)] // Since we mark some ABIs as "nounwind" to LLVM, we must make sure that // we never unwind through them. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/alias-uninit-value.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/alias-uninit-value.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/alias-uninit-value.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/alias-uninit-value.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(dead_code)] + // Regression test for issue #374 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/alignment-gep-tup-like-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/alignment-gep-tup-like-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/alignment-gep-tup-like-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/alignment-gep-tup-like-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(dead_code)] + #![feature(box_syntax)] struct pair { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/align-with-extern-c-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/align-with-extern-c-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/align-with-extern-c-fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/align-with-extern-c-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(stable_features)] +#![allow(unused_variables)] + // #45662 #![feature(repr_align)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/alloca-from-derived-tydesc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/alloca-from-derived-tydesc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/alloca-from-derived-tydesc.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/alloca-from-derived-tydesc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(dead_code)] + // pretty-expanded FIXME #23616 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/allocator/auxiliary/custom-as-global.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/allocator/auxiliary/custom-as-global.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/allocator/auxiliary/custom-as-global.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/allocator/auxiliary/custom-as-global.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "rlib"] + +extern crate custom; + +use std::sync::atomic::{ATOMIC_USIZE_INIT, Ordering}; + +use custom::A; + +#[global_allocator] +static ALLOCATOR: A = A(ATOMIC_USIZE_INIT); + +pub fn get() -> usize { + ALLOCATOR.0.load(Ordering::SeqCst) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/allocator/auxiliary/custom.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/allocator/auxiliary/custom.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/allocator/auxiliary/custom.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/allocator/auxiliary/custom.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![feature(allocator_api)] +#![crate_type = "rlib"] + +use std::alloc::{GlobalAlloc, System, Layout}; +use std::sync::atomic::{AtomicUsize, Ordering}; + +pub struct A(pub AtomicUsize); + +unsafe impl GlobalAlloc for A { + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + self.0.fetch_add(1, Ordering::SeqCst); + System.alloc(layout) + } + + unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { + self.0.fetch_add(1, Ordering::SeqCst); + System.dealloc(ptr, layout) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/allocator/auxiliary/helper.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/allocator/auxiliary/helper.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/allocator/auxiliary/helper.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/allocator/auxiliary/helper.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "rlib"] + +use std::fmt; + +pub fn work_with(p: &fmt::Debug) { + drop(p); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/allocator/custom.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/allocator/custom.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/allocator/custom.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/allocator/custom.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,68 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// aux-build:helper.rs +// no-prefer-dynamic + +#![feature(allocator_api)] + +extern crate helper; + +use std::alloc::{self, Global, Alloc, System, Layout}; +use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; + +static HITS: AtomicUsize = ATOMIC_USIZE_INIT; + +struct A; + +unsafe impl alloc::GlobalAlloc for A { + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + HITS.fetch_add(1, Ordering::SeqCst); + System.alloc(layout) + } + + unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { + HITS.fetch_add(1, Ordering::SeqCst); + System.dealloc(ptr, layout) + } +} + +#[global_allocator] +static GLOBAL: A = A; + +fn main() { + println!("hello!"); + + let n = HITS.load(Ordering::SeqCst); + assert!(n > 0); + unsafe { + let layout = Layout::from_size_align(4, 2).unwrap(); + + let ptr = Global.alloc(layout.clone()).unwrap(); + helper::work_with(&ptr); + assert_eq!(HITS.load(Ordering::SeqCst), n + 1); + Global.dealloc(ptr, layout.clone()); + assert_eq!(HITS.load(Ordering::SeqCst), n + 2); + + let s = String::with_capacity(10); + helper::work_with(&s); + assert_eq!(HITS.load(Ordering::SeqCst), n + 3); + drop(s); + assert_eq!(HITS.load(Ordering::SeqCst), n + 4); + + let ptr = System.alloc(layout.clone()).unwrap(); + assert_eq!(HITS.load(Ordering::SeqCst), n + 4); + helper::work_with(&ptr); + System.dealloc(ptr, layout); + assert_eq!(HITS.load(Ordering::SeqCst), n + 4); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/allocator/xcrate-use2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/allocator/xcrate-use2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/allocator/xcrate-use2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/allocator/xcrate-use2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,58 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// aux-build:custom.rs +// aux-build:custom-as-global.rs +// aux-build:helper.rs +// no-prefer-dynamic + +#![feature(allocator_api)] + +extern crate custom; +extern crate custom_as_global; +extern crate helper; + +use std::alloc::{alloc, dealloc, GlobalAlloc, System, Layout}; +use std::sync::atomic::{Ordering, ATOMIC_USIZE_INIT}; + +static GLOBAL: custom::A = custom::A(ATOMIC_USIZE_INIT); + +fn main() { + unsafe { + let n = custom_as_global::get(); + let layout = Layout::from_size_align(4, 2).unwrap(); + + // Global allocator routes to the `custom_as_global` global + let ptr = alloc(layout.clone()); + helper::work_with(&ptr); + assert_eq!(custom_as_global::get(), n + 1); + dealloc(ptr, layout.clone()); + assert_eq!(custom_as_global::get(), n + 2); + + // Usage of the system allocator avoids all globals + let ptr = System.alloc(layout.clone()); + helper::work_with(&ptr); + assert_eq!(custom_as_global::get(), n + 2); + System.dealloc(ptr, layout.clone()); + assert_eq!(custom_as_global::get(), n + 2); + + // Usage of our personal allocator doesn't affect other instances + let ptr = GLOBAL.alloc(layout.clone()); + helper::work_with(&ptr); + assert_eq!(custom_as_global::get(), n + 2); + assert_eq!(GLOBAL.0.load(Ordering::SeqCst), 1); + GLOBAL.dealloc(ptr, layout); + assert_eq!(custom_as_global::get(), n + 2); + assert_eq!(GLOBAL.0.load(Ordering::SeqCst), 2); + } +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/allocator/xcrate-use.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/allocator/xcrate-use.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/allocator/xcrate-use.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/allocator/xcrate-use.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// aux-build:custom.rs +// aux-build:helper.rs +// no-prefer-dynamic + +#![feature(allocator_api)] + +extern crate custom; +extern crate helper; + +use std::alloc::{Global, Alloc, System, Layout}; +use std::sync::atomic::{Ordering, ATOMIC_USIZE_INIT}; + +#[global_allocator] +static GLOBAL: custom::A = custom::A(ATOMIC_USIZE_INIT); + +fn main() { + unsafe { + let n = GLOBAL.0.load(Ordering::SeqCst); + let layout = Layout::from_size_align(4, 2).unwrap(); + + let ptr = Global.alloc(layout.clone()).unwrap(); + helper::work_with(&ptr); + assert_eq!(GLOBAL.0.load(Ordering::SeqCst), n + 1); + Global.dealloc(ptr, layout.clone()); + assert_eq!(GLOBAL.0.load(Ordering::SeqCst), n + 2); + + let ptr = System.alloc(layout.clone()).unwrap(); + assert_eq!(GLOBAL.0.load(Ordering::SeqCst), n + 2); + helper::work_with(&ptr); + System.dealloc(ptr, layout); + assert_eq!(GLOBAL.0.load(Ordering::SeqCst), n + 2); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/allocator-alloc-one.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/allocator-alloc-one.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/allocator-alloc-one.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/allocator-alloc-one.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(stable_features)] + #![feature(allocator_api, nonnull)] use std::alloc::{Alloc, Global, Layout, handle_alloc_error}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/array_const_index-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/array_const_index-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/array_const_index-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/array_const_index-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(stable_features)] + +#![feature(const_indexing)] + +fn main() { + const ARR: [i32; 6] = [42, 43, 44, 45, 46, 47]; + const IDX: usize = 3; + const VAL: i32 = ARR[IDX]; + const BLUB: [i32; (ARR[0] - 41) as usize] = [5]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/arr_cycle.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/arr_cycle.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/arr_cycle.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/arr_cycle.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::cell::Cell; + +#[derive(Debug)] +struct B<'a> { + a: [Cell>>; 2] +} + +impl<'a> B<'a> { + fn new() -> B<'a> { + B { a: [Cell::new(None), Cell::new(None)] } + } +} + +fn f() { + let (b1, b2, b3); + b1 = B::new(); + b2 = B::new(); + b3 = B::new(); + b1.a[0].set(Some(&b2)); + b1.a[1].set(Some(&b3)); + b2.a[0].set(Some(&b2)); + b2.a[1].set(Some(&b3)); + b3.a[0].set(Some(&b1)); + b3.a[1].set(Some(&b2)); +} + +fn main() { + f(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/box-of-array-of-drop-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/box-of-array-of-drop-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/box-of-array-of-drop-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/box-of-array-of-drop-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,57 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(overflowing_literals)] + +// Test that we cleanup a fixed size Box<[D; k]> properly when D has a +// destructor. + +// ignore-emscripten no threads support + +use std::thread; +use std::sync::atomic::{AtomicUsize, Ordering}; + +static LOG: AtomicUsize = AtomicUsize::new(0); + +struct D(u8); + +impl Drop for D { + fn drop(&mut self) { + println!("Dropping {}", self.0); + let old = LOG.load(Ordering::SeqCst); + LOG.compare_and_swap(old, old << 4 | self.0 as usize, Ordering::SeqCst); + } +} + +fn main() { + fn die() -> D { panic!("Oh no"); } + let g = thread::spawn(|| { + let _b1: Box<[D; 4]> = Box::new([D( 1), D( 2), D( 3), D( 4)]); + let _b2: Box<[D; 4]> = Box::new([D( 5), D( 6), D( 7), D( 8)]); + let _b3: Box<[D; 4]> = Box::new([D( 9), D(10), die(), D(12)]); + let _b4: Box<[D; 4]> = Box::new([D(13), D(14), D(15), D(16)]); + }); + assert!(g.join().is_err()); + + // When the panic occurs, we will be in the midst of constructing + // the input to `_b3`. Therefore, we drop the elements of the + // partially filled array first, before we get around to dropping + // the elements of `_b1` and _b2`. + + // Issue 23222: The order in which the elements actually get + // dropped is a little funky. See similar notes in nested-vec-3; + // in essence, I would not be surprised if we change the ordering + // given in `expect` in the future. + + let expect = 0x__A_9__5_6_7_8__1_2_3_4; + let actual = LOG.load(Ordering::SeqCst); + assert!(actual == expect, "expect: 0x{:x} actual: 0x{:x}", expect, actual); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/box-of-array-of-drop-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/box-of-array-of-drop-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/box-of-array-of-drop-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/box-of-array-of-drop-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,57 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(overflowing_literals)] + +// Test that we cleanup dynamic sized Box<[D]> properly when D has a +// destructor. + +// ignore-emscripten no threads support + +use std::thread; +use std::sync::atomic::{AtomicUsize, Ordering}; + +static LOG: AtomicUsize = AtomicUsize::new(0); + +struct D(u8); + +impl Drop for D { + fn drop(&mut self) { + println!("Dropping {}", self.0); + let old = LOG.load(Ordering::SeqCst); + LOG.compare_and_swap(old, old << 4 | self.0 as usize, Ordering::SeqCst); + } +} + +fn main() { + fn die() -> D { panic!("Oh no"); } + let g = thread::spawn(|| { + let _b1: Box<[D; 4]> = Box::new([D( 1), D( 2), D( 3), D( 4)]); + let _b2: Box<[D; 4]> = Box::new([D( 5), D( 6), D( 7), D( 8)]); + let _b3: Box<[D; 4]> = Box::new([D( 9), D(10), die(), D(12)]); + let _b4: Box<[D; 4]> = Box::new([D(13), D(14), D(15), D(16)]); + }); + assert!(g.join().is_err()); + + // When the panic occurs, we will be in the midst of constructing + // the input to `_b3`. Therefore, we drop the elements of the + // partially filled array first, before we get around to dropping + // the elements of `_b1` and _b2`. + + // Issue 23222: The order in which the elements actually get + // dropped is a little funky. See similar notes in nested-vec-3; + // in essence, I would not be surprised if we change the ordering + // given in `expect` in the future. + + let expect = 0x__A_9__5_6_7_8__1_2_3_4; + let actual = LOG.load(Ordering::SeqCst); + assert!(actual == expect, "expect: 0x{:x} actual: 0x{:x}", expect, actual); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/cast-in-array-size.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/cast-in-array-size.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/cast-in-array-size.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/cast-in-array-size.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +// issues #10618 and #16382 +// pretty-expanded FIXME #23616 + +const SIZE: isize = 25; + +fn main() { + let _a: [bool; 1 as usize]; + let _b: [isize; SIZE as usize] = [1; SIZE as usize]; + let _c: [bool; '\n' as usize] = [true; '\n' as usize]; + let _d: [bool; true as usize] = [true; true as usize]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/check-static-mut-slices.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/check-static-mut-slices.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/check-static-mut-slices.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/check-static-mut-slices.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +// Checks that mutable static items can have mutable slices + + +static mut TEST: &'static mut [isize] = &mut [1]; +static mut EMPTY: &'static mut [isize] = &mut []; + +pub fn main() { + unsafe { + TEST[0] += 1; + assert_eq!(TEST[0], 2); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/check-static-slice.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/check-static-slice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/check-static-slice.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/check-static-slice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// Check that the various ways of getting to a reference to a vec (both sized +// and unsized) work properly. + + +const AA: [isize; 3] = [1, 2, 3]; +const AB: &'static [isize; 3] = &AA; +const AC: &'static [isize] = AB; +const AD: &'static [isize] = &AA; +const AE: &'static [isize; 3] = &[1, 2, 3]; +const AF: &'static [isize] = &[1, 2, 3]; + +static CA: isize = AA[0]; +static CB: isize = AB[1]; +static CC: isize = AC[2]; +static CD: isize = AD[0]; +static CE: isize = AE[1]; +static CF: isize = AF[2]; + +static AG: &'static isize = &AA[2]; + +fn main () { + let b: &[isize] = &[1, 2, 3]; + assert_eq!(AC, b); + assert_eq!(AD, b); + assert_eq!(AF, b); + assert_eq!(*AG, 3); + + assert_eq!(CA, 1); + assert_eq!(CB, 2); + assert_eq!(CC, 3); + assert_eq!(CD, 1); + assert_eq!(CE, 2); + assert_eq!(CF, 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/copy-out-of-array-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/copy-out-of-array-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/copy-out-of-array-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/copy-out-of-array-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// Ensure that we can copy out of a fixed-size array. +// +// (Compare with compile-fail/move-out-of-array-1.rs) + +#[derive(Copy, Clone)] +struct C { _x: u8 } + +fn main() { + fn d() -> C { C { _x: 0 } } + + let _d1 = foo([d(), d(), d(), d()], 1); + let _d3 = foo([d(), d(), d(), d()], 3); +} + +fn foo(a: [C; 4], i: usize) -> C { + a[i] +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/destructure-array-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/destructure-array-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/destructure-array-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/destructure-array-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// Ensure that we can do a destructuring bind of a fixed-size array, +// even when the element type has a destructor. + +struct D { x: u8 } + +impl Drop for D { fn drop(&mut self) { } } + +fn main() { + fn d(x: u8) -> D { D { x: x } } + + let d1 = foo([d(1), d(2), d(3), d(4)], 1); + let d3 = foo([d(5), d(6), d(7), d(8)], 3); + assert_eq!(d1.x, 2); + assert_eq!(d3.x, 8); +} + +fn foo([a, b, c, d]: [D; 4], i: usize) -> D { + match i { + 0 => a, + 1 => b, + 2 => c, + 3 => d, + _ => panic!("unmatched"), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/empty-mutable-vec.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/empty-mutable-vec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/empty-mutable-vec.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/empty-mutable-vec.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// pretty-expanded FIXME #23616 + +#![allow(unused_mut)] + + +pub fn main() { let mut _v: Vec = Vec::new(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/estr-slice.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/estr-slice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/estr-slice.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/estr-slice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,60 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +pub fn main() { + let x = "hello"; + let v = "hello"; + let y : &str = "there"; + + println!("{}", x); + println!("{}", y); + + assert_eq!(x.as_bytes()[0], 'h' as u8); + assert_eq!(x.as_bytes()[4], 'o' as u8); + + let z : &str = "thing"; + assert_eq!(v, x); + assert!(x != z); + + let a = "aaaa"; + let b = "bbbb"; + + let c = "cccc"; + let cc = "ccccc"; + + println!("{}", a); + + assert!(a < b); + assert!(a <= b); + assert!(a != b); + assert!(b >= a); + assert!(b > a); + + println!("{}", b); + + assert!(a < c); + assert!(a <= c); + assert!(a != c); + assert!(c >= a); + assert!(c > a); + + println!("{}", c); + + assert!(c < cc); + assert!(c <= cc); + assert!(c != cc); + assert!(cc >= c); + assert!(cc > c); + + println!("{}", cc); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/evec-slice.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/evec-slice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/evec-slice.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/evec-slice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,57 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_assignments)] + +pub fn main() { + let x : &[isize] = &[1,2,3,4,5]; + let mut z : &[isize] = &[1,2,3,4,5]; + z = x; + assert_eq!(z[0], 1); + assert_eq!(z[4], 5); + + let a : &[isize] = &[1,1,1,1,1]; + let b : &[isize] = &[2,2,2,2,2]; + let c : &[isize] = &[2,2,2,2,3]; + let cc : &[isize] = &[2,2,2,2,2,2]; + + println!("{:?}", a); + + assert!(a < b); + assert!(a <= b); + assert!(a != b); + assert!(b >= a); + assert!(b > a); + + println!("{:?}", b); + + assert!(b < c); + assert!(b <= c); + assert!(b != c); + assert!(c >= b); + assert!(c > b); + + assert!(a < c); + assert!(a <= c); + assert!(a != c); + assert!(c >= a); + assert!(c > a); + + println!("{:?}", c); + + assert!(a < cc); + assert!(a <= cc); + assert!(a != cc); + assert!(cc >= a); + assert!(cc > a); + + println!("{:?}", cc); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/fixed_length_copy.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/fixed_length_copy.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/fixed_length_copy.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/fixed_length_copy.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +pub fn main() { + let arr = [1,2,3]; + let arr2 = arr; + assert_eq!(arr[1], 2); + assert_eq!(arr2[2], 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/huge-largest-array.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/huge-largest-array.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/huge-largest-array.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/huge-largest-array.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +use std::mem::size_of; + +#[cfg(target_pointer_width = "32")] +pub fn main() { + assert_eq!(size_of::<[u8; (1 << 31) - 1]>(), (1 << 31) - 1); +} + +#[cfg(target_pointer_width = "64")] +pub fn main() { + assert_eq!(size_of::<[u8; (1 << 47) - 1]>(), (1 << 47) - 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/ivec-pass-by-value.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/ivec-pass-by-value.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/ivec-pass-by-value.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/ivec-pass-by-value.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn f(_a: Vec ) { } +pub fn main() { f(vec![1, 2, 3, 4, 5]); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/mutability-inherits-through-fixed-length-vec.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/mutability-inherits-through-fixed-length-vec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/mutability-inherits-through-fixed-length-vec.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/mutability-inherits-through-fixed-length-vec.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +fn test1() { + let mut ints = [0; 32]; + ints[0] += 1; + assert_eq!(ints[0], 1); +} + +fn test2() { + let mut ints = [0; 32]; + for i in &mut ints { *i += 22; } + for i in &ints { assert_eq!(*i, 22); } +} + +pub fn main() { + test1(); + test2(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/mutable-alias-vec.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/mutable-alias-vec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/mutable-alias-vec.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/mutable-alias-vec.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn grow(v: &mut Vec ) { + v.push(1); +} + +pub fn main() { + let mut v: Vec = Vec::new(); + grow(&mut v); + grow(&mut v); + grow(&mut v); + let len = v.len(); + println!("{}", len); + assert_eq!(len, 3 as usize); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/nested-vec-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/nested-vec-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/nested-vec-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/nested-vec-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// Test that using the `vec!` macro nested within itself works + +fn main() { + let nested = vec![vec![1u32, 2u32, 3u32]]; + assert_eq!(nested[0][1], 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/nested-vec-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/nested-vec-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/nested-vec-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/nested-vec-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// Test that using the `vec!` macro nested within itself works +// when the contents implement Drop + +struct D(u32); + +impl Drop for D { + fn drop(&mut self) { println!("Dropping {}", self.0); } +} + +fn main() { + let nested = vec![vec![D(1u32), D(2u32), D(3u32)]]; + assert_eq!(nested[0][1].0, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/nested-vec-3.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/nested-vec-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/nested-vec-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/nested-vec-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,64 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(overflowing_literals)] + +// ignore-emscripten no threads support + +// Test that using the `vec!` macro nested within itself works when +// the contents implement Drop and we hit a panic in the middle of +// construction. + +use std::thread; +use std::sync::atomic::{AtomicUsize, Ordering}; + +static LOG: AtomicUsize = AtomicUsize::new(0); + +struct D(u8); + +impl Drop for D { + fn drop(&mut self) { + println!("Dropping {}", self.0); + let old = LOG.load(Ordering::SeqCst); + LOG.compare_and_swap(old, old << 4 | self.0 as usize, Ordering::SeqCst); + } +} + +fn main() { + fn die() -> D { panic!("Oh no"); } + let g = thread::spawn(|| { + let _nested = vec![vec![D( 1), D( 2), D( 3), D( 4)], + vec![D( 5), D( 6), D( 7), D( 8)], + vec![D( 9), D(10), die(), D(12)], + vec![D(13), D(14), D(15), D(16)]]; + }); + assert!(g.join().is_err()); + + // When the panic occurs, we will be in the midst of constructing the + // second inner vector. Therefore, we drop the elements of the + // partially filled vector first, before we get around to dropping + // the elements of the filled vector. + + // Issue 23222: The order in which the elements actually get + // dropped is a little funky: as noted above, we'll drop the 9+10 + // first, but due to #23222, they get dropped in reverse + // order. Likewise, again due to #23222, we will drop the second + // filled vec before the first filled vec. + // + // If Issue 23222 is "fixed", then presumably the corrected + // expected order of events will be 0x__9_A__1_2_3_4__5_6_7_8; + // that is, we would still drop 9+10 first, since they belong to + // the more deeply nested expression when the panic occurs. + + let expect = 0x__A_9__5_6_7_8__1_2_3_4; + let actual = LOG.load(Ordering::SeqCst); + assert!(actual == expect, "expect: 0x{:x} actual: 0x{:x}", expect, actual); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/new-style-fixed-length-vec.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/new-style-fixed-length-vec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/new-style-fixed-length-vec.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/new-style-fixed-length-vec.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +static FOO: [isize; 3] = [1, 2, 3]; + +pub fn main() { + println!("{} {} {}", FOO[0], FOO[1], FOO[2]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/rcvr-borrowed-to-slice.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/rcvr-borrowed-to-slice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/rcvr-borrowed-to-slice.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/rcvr-borrowed-to-slice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![allow(non_camel_case_types)] + +trait sum { + fn sum_(self) -> isize; +} + +// Note: impl on a slice +impl<'a> sum for &'a [isize] { + fn sum_(self) -> isize { + self.iter().fold(0, |a, &b| a + b) + } +} + +fn call_sum(x: &[isize]) -> isize { x.sum_() } + +pub fn main() { + let x = vec![1, 2, 3]; + let y = call_sum(&x); + println!("y=={}", y); + assert_eq!(y, 6); + + let x = vec![1, 2, 3]; + let y = x.sum_(); + println!("y=={}", y); + assert_eq!(y, 6); + + let x = vec![1, 2, 3]; + let y = x.sum_(); + println!("y=={}", y); + assert_eq!(y, 6); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/repeated-vector-syntax.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/repeated-vector-syntax.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/repeated-vector-syntax.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/repeated-vector-syntax.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + let x = [ [true]; 512 ]; + let y = [ 0; 1 ]; + + print!("["); + for xi in &x[..] { + print!("{:?}, ", &xi[..]); + } + println!("]"); + println!("{:?}", &y[..]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/show-boxed-slice.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/show-boxed-slice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/show-boxed-slice.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/show-boxed-slice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#[derive(Debug)] +struct Foo(Box<[u8]>); + +pub fn main() { + println!("{:?}", Foo(Box::new([0, 1, 2]))); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,72 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// Test slicing expressions on slices and Vecs. + + +fn main() { + let x: &[isize] = &[1, 2, 3, 4, 5]; + let cmp: &[isize] = &[1, 2, 3, 4, 5]; + assert_eq!(&x[..], cmp); + let cmp: &[isize] = &[3, 4, 5]; + assert_eq!(&x[2..], cmp); + let cmp: &[isize] = &[1, 2, 3]; + assert_eq!(&x[..3], cmp); + let cmp: &[isize] = &[2, 3, 4]; + assert_eq!(&x[1..4], cmp); + + let x: Vec = vec![1, 2, 3, 4, 5]; + let cmp: &[isize] = &[1, 2, 3, 4, 5]; + assert_eq!(&x[..], cmp); + let cmp: &[isize] = &[3, 4, 5]; + assert_eq!(&x[2..], cmp); + let cmp: &[isize] = &[1, 2, 3]; + assert_eq!(&x[..3], cmp); + let cmp: &[isize] = &[2, 3, 4]; + assert_eq!(&x[1..4], cmp); + + let x: &mut [isize] = &mut [1, 2, 3, 4, 5]; + { + let cmp: &mut [isize] = &mut [1, 2, 3, 4, 5]; + assert_eq!(&mut x[..], cmp); + } + { + let cmp: &mut [isize] = &mut [3, 4, 5]; + assert_eq!(&mut x[2..], cmp); + } + { + let cmp: &mut [isize] = &mut [1, 2, 3]; + assert_eq!(&mut x[..3], cmp); + } + { + let cmp: &mut [isize] = &mut [2, 3, 4]; + assert_eq!(&mut x[1..4], cmp); + } + + let mut x: Vec = vec![1, 2, 3, 4, 5]; + { + let cmp: &mut [isize] = &mut [1, 2, 3, 4, 5]; + assert_eq!(&mut x[..], cmp); + } + { + let cmp: &mut [isize] = &mut [3, 4, 5]; + assert_eq!(&mut x[2..], cmp); + } + { + let cmp: &mut [isize] = &mut [1, 2, 3]; + assert_eq!(&mut x[..3], cmp); + } + { + let cmp: &mut [isize] = &mut [2, 3, 4]; + assert_eq!(&mut x[1..4], cmp); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice_binary_search.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice_binary_search.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice_binary_search.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice_binary_search.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// Test binary_search_by_key lifetime. Issue #34683 + +#[derive(Debug)] +struct Assignment { + topic: String, + partition: i32, +} + +fn main() { + let xs = vec![ + Assignment { topic: "abc".into(), partition: 1 }, + Assignment { topic: "def".into(), partition: 2 }, + Assignment { topic: "ghi".into(), partition: 3 }, + ]; + + let key: &str = "def"; + let r = xs.binary_search_by_key(&key, |e| &e.topic); + assert_eq!(Ok(1), r.map(|i| i)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice-of-zero-size-elements.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice-of-zero-size-elements.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice-of-zero-size-elements.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice-of-zero-size-elements.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,63 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(stable_features)] + +// compile-flags: -C debug-assertions + +#![feature(iter_to_slice)] + +use std::slice; + +fn foo(v: &[T]) -> Option<&[T]> { + let mut it = v.iter(); + for _ in 0..5 { + let _ = it.next(); + } + Some(it.as_slice()) +} + +fn foo_mut(v: &mut [T]) -> Option<&mut [T]> { + let mut it = v.iter_mut(); + for _ in 0..5 { + let _ = it.next(); + } + Some(it.into_slice()) +} + +pub fn main() { + // In a slice of zero-size elements the pointer is meaningless. + // Ensure iteration still works even if the pointer is at the end of the address space. + let slice: &[()] = unsafe { slice::from_raw_parts(-5isize as *const (), 10) }; + assert_eq!(slice.len(), 10); + assert_eq!(slice.iter().count(), 10); + + // .nth() on the iterator should also behave correctly + let mut it = slice.iter(); + assert!(it.nth(5).is_some()); + assert_eq!(it.count(), 4); + + // Converting Iter to a slice should never have a null pointer + assert!(foo(slice).is_some()); + + // Test mutable iterators as well + let slice: &mut [()] = unsafe { slice::from_raw_parts_mut(-5isize as *mut (), 10) }; + assert_eq!(slice.len(), 10); + assert_eq!(slice.iter_mut().count(), 10); + + { + let mut it = slice.iter_mut(); + assert!(it.nth(5).is_some()); + assert_eq!(it.count(), 4); + } + + assert!(foo_mut(slice).is_some()) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice-panic-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice-panic-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice-panic-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice-panic-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// ignore-emscripten no threads support + +// Test that if a slicing expr[..] fails, the correct cleanups happen. + + +use std::thread; + +struct Foo; + +static mut DTOR_COUNT: isize = 0; + +impl Drop for Foo { + fn drop(&mut self) { unsafe { DTOR_COUNT += 1; } } +} + +fn foo() { + let x: &[_] = &[Foo, Foo]; + &x[3..4]; +} + +fn main() { + let _ = thread::spawn(move|| foo()).join(); + unsafe { assert_eq!(DTOR_COUNT, 2); } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice-panic-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice-panic-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice-panic-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice-panic-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// ignore-emscripten no threads support + +// Test that if a slicing expr[..] fails, the correct cleanups happen. + + +use std::thread; + +struct Foo; + +static mut DTOR_COUNT: isize = 0; + +impl Drop for Foo { + fn drop(&mut self) { unsafe { DTOR_COUNT += 1; } } +} + +fn bar() -> usize { + panic!(); +} + +fn foo() { + let x: &[_] = &[Foo, Foo]; + &x[3..bar()]; +} + +fn main() { + let _ = thread::spawn(move|| foo()).join(); + unsafe { assert_eq!(DTOR_COUNT, 2); } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/slice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,91 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] + +// Test slicing sugar. + +extern crate core; +use core::ops::{Index, IndexMut, Range, RangeTo, RangeFrom, RangeFull}; + +static mut COUNT: usize = 0; + +struct Foo; + +impl Index> for Foo { + type Output = Foo; + fn index(&self, index: Range) -> &Foo { + unsafe { COUNT += 1; } + self + } +} +impl Index> for Foo { + type Output = Foo; + fn index(&self, index: RangeTo) -> &Foo { + unsafe { COUNT += 1; } + self + } +} +impl Index> for Foo { + type Output = Foo; + fn index(&self, index: RangeFrom) -> &Foo { + unsafe { COUNT += 1; } + self + } +} +impl Index for Foo { + type Output = Foo; + fn index(&self, _index: RangeFull) -> &Foo { + unsafe { COUNT += 1; } + self + } +} + +impl IndexMut> for Foo { + fn index_mut(&mut self, index: Range) -> &mut Foo { + unsafe { COUNT += 1; } + self + } +} +impl IndexMut> for Foo { + fn index_mut(&mut self, index: RangeTo) -> &mut Foo { + unsafe { COUNT += 1; } + self + } +} +impl IndexMut> for Foo { + fn index_mut(&mut self, index: RangeFrom) -> &mut Foo { + unsafe { COUNT += 1; } + self + } +} +impl IndexMut for Foo { + fn index_mut(&mut self, _index: RangeFull) -> &mut Foo { + unsafe { COUNT += 1; } + self + } +} + + +fn main() { + let mut x = Foo; + &x[..]; + &x[Foo..]; + &x[..Foo]; + &x[Foo..Foo]; + &mut x[..]; + &mut x[Foo..]; + &mut x[..Foo]; + &mut x[Foo..Foo]; + unsafe { + assert_eq!(COUNT, 8); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/variance-vec-covariant.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/variance-vec-covariant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/variance-vec-covariant.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/variance-vec-covariant.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// Test that vec is now covariant in its argument type. + +#![allow(dead_code)] + +fn foo<'a,'b>(v1: Vec<&'a i32>, v2: Vec<&'b i32>) -> i32 { + bar(v1, v2).cloned().unwrap_or(0) // only type checks if we can intersect 'a and 'b +} + +fn bar<'c>(v1: Vec<&'c i32>, v2: Vec<&'c i32>) -> Option<&'c i32> { + v1.get(0).cloned().or_else(|| v2.get(0).cloned()) +} + +fn main() { + let x = 22; + let y = 44; + assert_eq!(foo(vec![&x], vec![&y]), 22); + assert_eq!(foo(vec![&y], vec![&x]), 44); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-concat.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-concat.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-concat.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-concat.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::vec; + +pub fn main() { + let a: Vec = vec![1, 2, 3, 4, 5]; + let b: Vec = vec![6, 7, 8, 9, 0]; + let mut v: Vec = a; + v.extend_from_slice(&b); + println!("{}", v[9]); + assert_eq!(v[0], 1); + assert_eq!(v[7], 8); + assert_eq!(v[9], 0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec_cycle.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec_cycle.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec_cycle.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec_cycle.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,49 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::cell::Cell; + +#[derive(Debug)] +struct C<'a> { + v: Vec>>>, +} + +impl<'a> C<'a> { + fn new() -> C<'a> { + C { v: Vec::new() } + } +} + +fn f() { + let (mut c1, mut c2, mut c3); + c1 = C::new(); + c2 = C::new(); + c3 = C::new(); + + c1.v.push(Cell::new(None)); + c1.v.push(Cell::new(None)); + c2.v.push(Cell::new(None)); + c2.v.push(Cell::new(None)); + c3.v.push(Cell::new(None)); + c3.v.push(Cell::new(None)); + + c1.v[0].set(Some(&c2)); + c1.v[1].set(Some(&c3)); + c2.v[0].set(Some(&c2)); + c2.v[1].set(Some(&c3)); + c3.v[0].set(Some(&c1)); + c3.v[1].set(Some(&c2)); +} + +fn main() { + f(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec_cycle_wrapped.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec_cycle_wrapped.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec_cycle_wrapped.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec_cycle_wrapped.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,60 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::cell::Cell; + +#[derive(Debug)] +struct Refs<'a> { + v: Vec>>>, +} + +#[derive(Debug)] +struct C<'a> { + refs: Refs<'a>, +} + +impl<'a> Refs<'a> { + fn new() -> Refs<'a> { + Refs { v: Vec::new() } + } +} + +impl<'a> C<'a> { + fn new() -> C<'a> { + C { refs: Refs::new() } + } +} + +fn f() { + let (mut c1, mut c2, mut c3); + c1 = C::new(); + c2 = C::new(); + c3 = C::new(); + + c1.refs.v.push(Cell::new(None)); + c1.refs.v.push(Cell::new(None)); + c2.refs.v.push(Cell::new(None)); + c2.refs.v.push(Cell::new(None)); + c3.refs.v.push(Cell::new(None)); + c3.refs.v.push(Cell::new(None)); + + c1.refs.v[0].set(Some(&c2)); + c1.refs.v[1].set(Some(&c3)); + c2.refs.v[0].set(Some(&c2)); + c2.refs.v[1].set(Some(&c3)); + c3.refs.v[0].set(Some(&c1)); + c3.refs.v[1].set(Some(&c2)); +} + +fn main() { + f(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-dst.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-dst.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-dst.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-dst.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(box_syntax)] + +pub fn main() { + // Tests for indexing into box/& [T; n] + let x: [isize; 3] = [1, 2, 3]; + let mut x: Box<[isize; 3]> = box x; + assert_eq!(x[0], 1); + assert_eq!(x[1], 2); + assert_eq!(x[2], 3); + x[1] = 45; + assert_eq!(x[0], 1); + assert_eq!(x[1], 45); + assert_eq!(x[2], 3); + + let mut x: [isize; 3] = [1, 2, 3]; + let x: &mut [isize; 3] = &mut x; + assert_eq!(x[0], 1); + assert_eq!(x[1], 2); + assert_eq!(x[2], 3); + x[1] = 45; + assert_eq!(x[0], 1); + assert_eq!(x[1], 45); + assert_eq!(x[2], 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-fixed-length.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-fixed-length.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-fixed-length.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-fixed-length.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +use std::mem::size_of; + +#[cfg(not(target_pointer_width = "64"))] +fn test_big_vec() {} + +#[cfg(target_pointer_width = "64")] +fn test_big_vec() +{ + assert_eq!(size_of::<[u8; (1 << 32)]>(), (1 << 32)); +} + +fn main() { + let x: [isize; 4] = [1, 2, 3, 4]; + assert_eq!(x[0], 1); + assert_eq!(x[1], 2); + assert_eq!(x[2], 3); + assert_eq!(x[3], 4); + + assert_eq!(size_of::<[u8; 4]>(), 4); + test_big_vec(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-growth.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-growth.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-growth.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-growth.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + +pub fn main() { + let mut v = vec![1]; + v.push(2); + v.push(3); + v.push(4); + v.push(5); + assert_eq!(v[0], 1); + assert_eq!(v[1], 2); + assert_eq!(v[2], 3); + assert_eq!(v[3], 4); + assert_eq!(v[4], 5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-late-init.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-late-init.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-late-init.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-late-init.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] + + +pub fn main() { + let mut later: Vec ; + if true { later = vec![1]; } else { later = vec![2]; } + println!("{}", later[0]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-macro-no-std.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-macro-no-std.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-macro-no-std.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-macro-no-std.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// ignore-emscripten no no_std executables + +#![feature(lang_items, start, libc, alloc)] +#![no_std] + +extern crate std as other; + +extern crate libc; + +#[macro_use] +extern crate alloc; + +use alloc::vec::Vec; + +// Issue #16806 + +#[start] +fn start(_argc: isize, _argv: *const *const u8) -> isize { + let x: Vec = vec![0, 1, 2]; + match x.last() { + Some(&2) => (), + _ => panic!(), + } + 0 +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-macro-repeat.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-macro-repeat.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-macro-repeat.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-macro-repeat.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + +pub fn main() { + assert_eq!(vec![1; 3], vec![1, 1, 1]); + assert_eq!(vec![1; 2], vec![1, 1]); + assert_eq!(vec![1; 1], vec![1]); + assert_eq!(vec![1; 0], vec![]); + + // from_elem syntax (see RFC 832) + let el = Box::new(1); + let n = 3; + assert_eq!(vec![el; n], vec![Box::new(1), Box::new(1), Box::new(1)]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-macro-rvalue-scope.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-macro-rvalue-scope.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-macro-rvalue-scope.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-macro-rvalue-scope.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +fn one() -> i32 { 1 } + +// Make sure the vec![...] macro doesn't introduce hidden rvalue +// scopes (such as blocks) around the element expressions. +pub fn main() { + assert_eq!(vec![&one(), &one(), &2], vec![&1, &1, &(one()+one())]); + assert_eq!(vec![&one(); 2], vec![&1, &one()]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-macro-with-brackets.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-macro-with-brackets.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-macro-with-brackets.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-macro-with-brackets.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] + +// pretty-expanded FIXME #23616 + +macro_rules! vec [ + ($($e:expr),*) => ({ + let mut _temp = ::std::vec::Vec::new(); + $(_temp.push($e);)* + _temp + }) +]; + +pub fn main() { + let my_vec = vec![1, 2, 3, 4, 5]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-macro-with-trailing-comma.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-macro-with-trailing-comma.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-macro-with-trailing-comma.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-macro-with-trailing-comma.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + +pub fn main() { + assert_eq!(vec![1], vec![1,]); + assert_eq!(vec![1, 2, 3], vec![1, 2, 3,]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-matching-autoslice.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-matching-autoslice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-matching-autoslice.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-matching-autoslice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(illegal_floating_point_literal_pattern)] // FIXME #41620 + +pub fn main() { + let x = [1, 2, 3]; + match x { + [2, _, _] => panic!(), + [1, a, b] => { + assert_eq!([a, b], [2, 3]); + } + [_, _, _] => panic!(), + } + + let y = ([(1, true), (2, false)], 0.5f64); + match y { + ([(1, a), (b, false)], _) => { + assert_eq!(a, true); + assert_eq!(b, 2); + } + ([_, _], 0.5) => panic!(), + ([_, _], _) => panic!(), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-matching-fixed.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-matching-fixed.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-matching-fixed.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-matching-fixed.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(slice_patterns)] + +fn a() { + let x = [1, 2, 3]; + match x { + [1, 2, 4] => unreachable!(), + [0, 2, 3, ..] => unreachable!(), + [0, .., 3] => unreachable!(), + [0, ..] => unreachable!(), + [1, 2, 3] => (), + [_, _, _] => unreachable!(), + } + match x { + [..] => (), + } + match x { + [_, _, _, ..] => (), + } + match x { + [a, b, c] => { + assert_eq!(1, a); + assert_eq!(2, b); + assert_eq!(3, c); + } + } +} + +pub fn main() { + a(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-matching-fold.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-matching-fold.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-matching-fold.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-matching-fold.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,58 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(slice_patterns)] + +use std::fmt::Debug; + +fn foldl(values: &[T], + initial: U, + mut function: F) + -> U where + U: Clone+Debug, T:Debug, + F: FnMut(U, &T) -> U, +{ match values { + &[ref head, ref tail..] => + foldl(tail, function(initial, head), function), + &[] => { + // FIXME: call guards + let res = initial.clone(); res + } + } +} + +fn foldr(values: &[T], + initial: U, + mut function: F) + -> U where + U: Clone, + F: FnMut(&T, U) -> U, +{ + match values { + &[ref head.., ref tail] => + foldr(head, function(tail, initial), function), + &[] => { + // FIXME: call guards + let res = initial.clone(); res + } + } +} + +pub fn main() { + let x = &[1, 2, 3, 4, 5]; + + let product = foldl(x, 1, |a, b| a * *b); + assert_eq!(product, 120); + + let sum = foldr(x, 0, |a, b| *a + b); + assert_eq!(sum, 15); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-matching-legal-tail-element-borrow.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-matching-legal-tail-element-borrow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-matching-legal-tail-element-borrow.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-matching-legal-tail-element-borrow.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] + +#![feature(slice_patterns)] + +pub fn main() { + let x = &[1, 2, 3, 4, 5]; + let x: &[isize] = &[1, 2, 3, 4, 5]; + if !x.is_empty() { + let el = match x { + &[1, ref tail..] => &tail[0], + _ => unreachable!() + }; + println!("{}", *el); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-matching.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-matching.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-matching.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-matching.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,169 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(slice_patterns)] + +fn a() { + let x = [1]; + match x { + [a] => { + assert_eq!(a, 1); + } + } +} + +fn b() { + let x = [1, 2, 3]; + match x { + [a, b, c..] => { + assert_eq!(a, 1); + assert_eq!(b, 2); + let expected: &[_] = &[3]; + assert_eq!(c, expected); + } + } + match x { + [a.., b, c] => { + let expected: &[_] = &[1]; + assert_eq!(a, expected); + assert_eq!(b, 2); + assert_eq!(c, 3); + } + } + match x { + [a, b.., c] => { + assert_eq!(a, 1); + let expected: &[_] = &[2]; + assert_eq!(b, expected); + assert_eq!(c, 3); + } + } + match x { + [a, b, c] => { + assert_eq!(a, 1); + assert_eq!(b, 2); + assert_eq!(c, 3); + } + } +} + + +fn b_slice() { + let x : &[_] = &[1, 2, 3]; + match x { + &[a, b, ref c..] => { + assert_eq!(a, 1); + assert_eq!(b, 2); + let expected: &[_] = &[3]; + assert_eq!(c, expected); + } + _ => unreachable!() + } + match x { + &[ref a.., b, c] => { + let expected: &[_] = &[1]; + assert_eq!(a, expected); + assert_eq!(b, 2); + assert_eq!(c, 3); + } + _ => unreachable!() + } + match x { + &[a, ref b.., c] => { + assert_eq!(a, 1); + let expected: &[_] = &[2]; + assert_eq!(b, expected); + assert_eq!(c, 3); + } + _ => unreachable!() + } + match x { + &[a, b, c] => { + assert_eq!(a, 1); + assert_eq!(b, 2); + assert_eq!(c, 3); + } + _ => unreachable!() + } +} + +fn c() { + let x = [1]; + match x { + [2, ..] => panic!(), + [..] => () + } +} + +fn d() { + let x = [1, 2, 3]; + let branch = match x { + [1, 1, ..] => 0, + [1, 2, 3, ..] => 1, + [1, 2, ..] => 2, + _ => 3 + }; + assert_eq!(branch, 1); +} + +fn e() { + let x: &[isize] = &[1, 2, 3]; + let a = match *x { + [1, 2] => 0, + [..] => 1, + }; + + assert_eq!(a, 1); + + let b = match *x { + [2, ..] => 0, + [1, 2, ..] => 1, + [_] => 2, + [..] => 3 + }; + + assert_eq!(b, 1); + + + let c = match *x { + [_, _, _, _, ..] => 0, + [1, 2, ..] => 1, + [_] => 2, + [..] => 3 + }; + + assert_eq!(c, 1); +} + +fn f() { + let x = &[1, 2, 3, 4, 5]; + let [a, [b, [c, ..].., d].., e] = *x; + assert_eq!((a, b, c, d, e), (1, 2, 3, 4, 5)); + + let x: &[isize] = x; + let (a, b, c, d, e) = match *x { + [a, [b, [c, ..].., d].., e] => (a, b, c, d, e), + _ => unimplemented!() + }; + + assert_eq!((a, b, c, d, e), (1, 2, 3, 4, 5)); +} + +pub fn main() { + a(); + b(); + b_slice(); + c(); + d(); + e(); + f(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-push.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-push.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-push.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-push.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { let mut v = vec![1, 2, 3]; v.push(1); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-repeat-with-cast.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-repeat-with-cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-repeat-with-cast.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-repeat-with-cast.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// pretty-expanded FIXME #23616 + +pub fn main() { let _a = [0; 1 as usize]; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + +pub fn main() { + let v: Vec = vec![10, 20]; + assert_eq!(v[0], 10); + assert_eq!(v[1], 20); + let mut x: usize = 0; + assert_eq!(v[x], 10); + assert_eq!(v[x + 1], 20); + x = x + 1; + assert_eq!(v[x], 20); + assert_eq!(v[x - 1], 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-slice-drop.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-slice-drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-slice-drop.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-slice-drop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![allow(non_camel_case_types)] + +use std::cell::Cell; + +// Make sure that destructors get run on slice literals +struct foo<'a> { + x: &'a Cell, +} + +impl<'a> Drop for foo<'a> { + fn drop(&mut self) { + self.x.set(self.x.get() + 1); + } +} + +fn foo(x: &Cell) -> foo { + foo { + x: x + } +} + +pub fn main() { + let x = &Cell::new(0); + { + let l = &[foo(x)]; + assert_eq!(l[0].x.get(), 0); + } + assert_eq!(x.get(), 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-slice.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-slice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-slice.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-slice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +pub fn main() { + let v = vec![1,2,3,4,5]; + let v2 = &v[1..3]; + assert_eq!(v2[0], 2); + assert_eq!(v2[1], 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-tail-matching.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-tail-matching.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-tail-matching.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-tail-matching.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(slice_patterns)] + +struct Foo { + string: &'static str +} + +pub fn main() { + let x = [ + Foo { string: "foo" }, + Foo { string: "bar" }, + Foo { string: "baz" } + ]; + match x { + [ref first, ref tail..] => { + assert_eq!(first.string, "foo"); + assert_eq!(tail.len(), 2); + assert_eq!(tail[0].string, "bar"); + assert_eq!(tail[1].string, "baz"); + + match *(tail as &[_]) { + [Foo { .. }, _, Foo { .. }, ref _tail..] => { + unreachable!(); + } + [Foo { string: ref a }, Foo { string: ref b }] => { + assert_eq!("bar", &a[0..a.len()]); + assert_eq!("baz", &b[0..b.len()]); + } + _ => { + unreachable!(); + } + } + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vector-no-ann-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vector-no-ann-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vector-no-ann-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vector-no-ann-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + +pub fn main() { let _quux: Box> = box Vec::new(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-to_str.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-to_str.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-to_str.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/array-slice-vec/vec-to_str.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +pub fn main() { + assert_eq!(format!("{:?}", vec![0, 1]), "[0, 1]".to_string()); + + let foo = vec![3, 4]; + let bar: &[isize] = &[4, 5]; + + assert_eq!(format!("{:?}", foo), "[3, 4]"); + assert_eq!(format!("{:?}", bar), "[4, 5]"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/asm-in-moved.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/asm-in-moved.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/asm-in-moved.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/asm-in-moved.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,6 +12,7 @@ //[mir]compile-flags: -Z borrowck=mir #![feature(asm)] +#![allow(dead_code)] use std::cell::Cell; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-const-eval.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-const-eval.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-const-eval.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-const-eval.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +trait Foo { + const NUM: usize; +} + +impl Foo for i32 { + const NUM: usize = 1; +} + +const FOO: usize = ::NUM; + +fn main() { + assert_eq!(1, FOO); + + match 1 { + ::NUM => {}, + _ => assert!(false) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-cross-crate-const-eval.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-cross-crate-const-eval.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-cross-crate-const-eval.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-cross-crate-const-eval.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:associated-const-cc-lib.rs + + +extern crate associated_const_cc_lib as foolib; + +pub struct LocalFoo; + +impl foolib::Foo for LocalFoo { + const BAR: usize = 1; +} + +const FOO_1: usize = ::BAR; +const FOO_2: usize = ::BAR; +const FOO_3: usize = foolib::InherentBar::BAR; + +fn main() { + assert_eq!(0, FOO_1); + assert_eq!(1, FOO_2); + assert_eq!(3, FOO_3); + + match 0 { + ::BAR => {}, + ::BAR => assert!(false), + foolib::InherentBar::BAR => assert!(false), + _ => assert!(false) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-cross-crate-defaults.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-cross-crate-defaults.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-cross-crate-defaults.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-cross-crate-defaults.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:associated-const-cc-lib.rs + + +extern crate associated_const_cc_lib as foolib; + +pub struct LocalFooUseDefault; + +impl foolib::FooDefault for LocalFooUseDefault {} + +pub struct LocalFooOverwriteDefault; + +impl foolib::FooDefault for LocalFooOverwriteDefault { + const BAR: usize = 4; +} + +fn main() { + assert_eq!(1, ::BAR); + assert_eq!(2, ::BAR); + assert_eq!(1, ::BAR); + assert_eq!(4, ::BAR); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-cross-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:associated-const-cc-lib.rs + + +extern crate associated_const_cc_lib as foolib; + +pub struct LocalFoo; + +impl foolib::Foo for LocalFoo { + const BAR: usize = 1; +} + +fn main() { + assert_eq!(0, ::BAR); + assert_eq!(1, ::BAR); + assert_eq!(3, foolib::InherentBar::BAR); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-in-global-const.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-in-global-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-in-global-const.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-in-global-const.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +struct Foo; + +impl Foo { + const BAR: f32 = 1.5; +} + +const FOOBAR: f32 = ::BAR; + +fn main() { + assert_eq!(1.5f32, FOOBAR); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-inherent-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-inherent-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-inherent-impl.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-inherent-impl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +struct Foo; + +impl Foo { + const ID: i32 = 1; +} + +fn main() { + assert_eq!(1, Foo::ID); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-marks-live-code.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-marks-live-code.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-marks-live-code.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-marks-live-code.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![deny(dead_code)] + +const GLOBAL_BAR: u32 = 1; + +struct Foo; + +impl Foo { + const BAR: u32 = GLOBAL_BAR; +} + +pub fn main() { + let _: u32 = Foo::BAR; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-match-patterns.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-match-patterns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-match-patterns.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-match-patterns.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,78 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:empty-struct.rs + + +extern crate empty_struct; +use empty_struct::XEmpty2 as XFoo; + +struct Foo; + +#[derive(PartialEq, Eq)] +enum Bar { + Var1, + Var2, +} + +// Use inherent and trait impls to test UFCS syntax. +impl Foo { + const MYBAR: Bar = Bar::Var2; +} + +trait HasBar { + const THEBAR: Bar; +} + +impl HasBar for Foo { + const THEBAR: Bar = Bar::Var1; +} + +impl HasBar for XFoo { + const THEBAR: Bar = Bar::Var1; +} + +fn main() { + // Inherent impl + assert!(match Bar::Var2 { + Foo::MYBAR => true, + _ => false, + }); + assert!(match Bar::Var2 { + ::MYBAR => true, + _ => false, + }); + // Trait impl + assert!(match Bar::Var1 { + Foo::THEBAR => true, + _ => false, + }); + assert!(match Bar::Var1 { + ::THEBAR => true, + _ => false, + }); + assert!(match Bar::Var1 { + ::THEBAR => true, + _ => false, + }); + assert!(match Bar::Var1 { + XFoo::THEBAR => true, + _ => false, + }); + assert!(match Bar::Var1 { + ::THEBAR => true, + _ => false, + }); + assert!(match Bar::Var1 { + ::THEBAR => true, + _ => false, + }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-outer-ty-refs.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-outer-ty-refs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-outer-ty-refs.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-outer-ty-refs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait Lattice { + const BOTTOM: Self; +} + +impl Lattice for Option { + const BOTTOM: Option = None; +} + +fn main(){} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-overwrite-default.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-overwrite-default.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-overwrite-default.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-overwrite-default.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +trait Foo { + const ID: i32 = 2; +} + +impl Foo for i32 { + const ID: i32 = 1; +} + +fn main() { + assert_eq!(1, ::ID); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-public-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-public-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-public-impl.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-public-impl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +mod bar1 { + pub use self::bar2::Foo; + mod bar2 { + pub struct Foo; + + impl Foo { + pub const ID: i32 = 1; + } + } +} + +fn main() { + assert_eq!(1, bar1::Foo::ID); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-range-match-patterns.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-range-match-patterns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-range-match-patterns.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-range-match-patterns.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +struct Foo; + +trait HasNum { + const NUM: isize; +} +impl HasNum for Foo { + const NUM: isize = 1; +} + +fn main() { + assert!(match 2 { + Foo::NUM ... 3 => true, + _ => false, + }); + assert!(match 0 { + -1 ... ::NUM => true, + _ => false, + }); + assert!(match 1 { + ::NUM ... ::NUM => true, + _ => false, + }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-resolution-order.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-resolution-order.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-resolution-order.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-resolution-order.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +struct MyType; + +impl MyType { + const IMPL_IS_INHERENT: bool = true; +} + +trait MyTrait { + const IMPL_IS_INHERENT: bool; + const IMPL_IS_ON_TRAIT: bool; +} + +impl MyTrait for MyType { + const IMPL_IS_INHERENT: bool = false; + const IMPL_IS_ON_TRAIT: bool = true; +} + +fn main() { + // Check that the inherent impl is used before the trait, but that the trait + // can still be accessed. + assert!(::IMPL_IS_INHERENT); + assert!(!::IMPL_IS_INHERENT); + assert!(::IMPL_IS_ON_TRAIT); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +trait Foo { + const ID: i32; +} + +impl Foo for i32 { + const ID: i32 = 1; +} + +fn main() { + assert_eq!(1, ::ID); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-self-type.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-self-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-self-type.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-self-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +trait MyInt { + const ONE: Self; +} + +impl MyInt for i32 { + const ONE: i32 = 1; +} + +fn main() { + assert_eq!(1, ::ONE); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-type-parameters.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-type-parameters.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-type-parameters.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-type-parameters.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,54 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +trait Foo { + const X: i32; + fn get_x() -> i32 { + Self::X + } +} + +struct Abc; +impl Foo for Abc { + const X: i32 = 11; +} + +struct Def; +impl Foo for Def { + const X: i32 = 97; +} + +struct Proxy(T); + +impl Foo for Proxy { + const X: i32 = T::X; +} + +fn sub() -> i32 { + A::X - B::X +} + +trait Bar: Foo { + const Y: i32 = Self::X; +} + +fn main() { + assert_eq!(11, Abc::X); + assert_eq!(97, Def::X); + assert_eq!(11, Abc::get_x()); + assert_eq!(97, Def::get_x()); + assert_eq!(-86, sub::()); + assert_eq!(86, sub::()); + assert_eq!(-86, sub::, Def>()); + assert_eq!(-86, sub::>()); + assert_eq!(86, sub::, Proxy>()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-ufcs-infer-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-ufcs-infer-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-ufcs-infer-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-ufcs-infer-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +trait Foo { + const ID: i32; +} + +impl Foo for i32 { + const ID: i32 = 1; +} + +fn main() { + assert_eq!(1, ::ID); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-use-default.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-use-default.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-use-default.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-use-default.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +trait Foo { + const ID: i32 = 1; +} + +impl Foo for i32 {} + +fn main() { + assert_eq!(1, ::ID); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-use-impl-of-same-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-use-impl-of-same-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-use-impl-of-same-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/associated-const-use-impl-of-same-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// The main purpose of this test is to ensure that different impls of the same +// trait can refer to each other without setting off the static recursion check +// (as long as there's no actual recursion). + +trait Foo { + const BAR: u32; +} + +struct IsFoo1; + +impl Foo for IsFoo1 { + const BAR: u32 = 1; +} + +struct IsFoo2; + +impl Foo for IsFoo2 { + const BAR: u32 = ::BAR; +} + +fn main() { + assert_eq!(::BAR, ::BAR); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/auxiliary/associated-const-cc-lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/auxiliary/associated-const-cc-lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/auxiliary/associated-const-cc-lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/auxiliary/associated-const-cc-lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +#![crate_type="lib"] + +// These items are for testing that associated consts work cross-crate. +pub trait Foo { + const BAR: usize; +} + +pub struct FooNoDefault; + +impl Foo for FooNoDefault { + const BAR: usize = 0; +} + +// These test that defaults and default resolution work cross-crate. +pub trait FooDefault { + const BAR: usize = 1; +} + +pub struct FooOverwriteDefault; + +impl FooDefault for FooOverwriteDefault { + const BAR: usize = 2; +} + +pub struct FooUseDefault; + +impl FooDefault for FooUseDefault {} + +// Test inherent impls. +pub struct InherentBar; + +impl InherentBar { + pub const BAR: usize = 3; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/auxiliary/empty-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/auxiliary/empty-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-consts/auxiliary/empty-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-consts/auxiliary/empty-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct XEmpty1 {} +pub struct XEmpty2; +pub struct XEmpty7(); + +pub enum XE { + XEmpty3 {}, + XEmpty4, + XEmpty6(), +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-basic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-basic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-basic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-basic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait Foo { + type T; +} + +impl Foo for i32 { + type T = isize; +} + +fn main() { + let x: ::T = 22; + let y: isize = 44; + assert_eq!(x * 2, y); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-binding-in-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-binding-in-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-binding-in-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-binding-in-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test a case where the associated type binding (to `bool`, in this +// case) is derived from the trait definition. Issue #21636. + + +use std::vec; + +pub trait BitIter { + type Iter: Iterator; + fn bit_iter(self) -> ::Iter; +} + +impl BitIter for Vec { + type Iter = vec::IntoIter; + fn bit_iter(self) -> ::Iter { + self.into_iter() + } +} + +fn count(arg: T) -> usize + where T: BitIter +{ + let mut sum = 0; + for i in arg.bit_iter() { + if i { + sum += 1; + } + } + sum +} + +fn main() { + let v = vec![true, false, true]; + let c = count(v); + assert_eq!(c, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-binding-in-where-clause.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-binding-in-where-clause.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-binding-in-where-clause.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-binding-in-where-clause.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,48 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test equality constraints on associated types in a where clause. + +// pretty-expanded FIXME #23616 + +pub trait Foo { + type A; + fn boo(&self) -> ::A; +} + +#[derive(PartialEq)] +pub struct Bar; + +impl Foo for isize { + type A = usize; + fn boo(&self) -> usize { 42 } +} + +impl Foo for char { + type A = Bar; + fn boo(&self) -> Bar { Bar } +} + +fn foo_bar>(x: I) -> Bar { + x.boo() +} + +fn foo_uint>(x: I) -> usize { + x.boo() +} + +pub fn main() { + let a = 42; + foo_uint(a); + + let a = 'a'; + foo_bar(a); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-bound.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-bound.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,53 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test equality constrai32s on associated types in a where clause. + + +pub trait ToI32 { + fn to_i32(&self) -> i32; +} + +impl ToI32 for i32 { + fn to_i32(&self) -> i32 { *self } +} + +impl ToI32 for u32 { + fn to_i32(&self) -> i32 { *self as i32 } +} + +pub trait GetToI32 +{ + type R : ToI32; + + fn get(&self) -> ::R; +} + +impl GetToI32 for i32 { + type R = i32; + fn get(&self) -> i32 { *self } +} + +impl GetToI32 for u32 { + type R = u32; + fn get(&self) -> u32 { *self } +} + +fn foo(g: G) -> i32 + where G : GetToI32 +{ + ToI32::to_i32(&g.get()) +} + +pub fn main() { + assert_eq!(foo(22i32), 22); + assert_eq!(foo(22u32), 22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-cc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-cc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-cc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-cc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// aux-build:associated-types-cc-lib.rs + +// Test that we are able to reference cross-crate traits that employ +// associated types. + +extern crate associated_types_cc_lib as bar; + +use bar::Bar; + +fn foo(b: B) -> ::T { + Bar::get(None::) +} + +fn main() { + println!("{}", foo(3)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-conditional-dispatch.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-conditional-dispatch.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-conditional-dispatch.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-conditional-dispatch.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,76 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we evaluate projection predicates to winnow out +// candidates during trait selection and method resolution (#20296). +// If we don't properly winnow out candidates based on the output type +// `Target=[A]`, then the impl marked with `(*)` is seen to conflict +// with all the others. + +// pretty-expanded FIXME #23616 + +use std::marker::PhantomData; +use std::ops::Deref; + +pub trait MyEq { + fn eq(&self, u: &U) -> bool; +} + +impl MyEq<[B]> for [A] + where A : MyEq +{ + fn eq(&self, other: &[B]) -> bool { + self.len() == other.len() && + self.iter().zip(other).all(|(a, b)| MyEq::eq(a, b)) + } +} + +// (*) This impl conflicts with everything unless the `Target=[A]` +// constraint is considered. +impl<'a, A, B, Lhs> MyEq<[B; 0]> for Lhs + where A: MyEq, Lhs: Deref +{ + fn eq(&self, other: &[B; 0]) -> bool { + MyEq::eq(&**self, other) + } +} + +struct DerefWithHelper { + pub helper: H, + pub marker: PhantomData, +} + +trait Helper { + fn helper_borrow(&self) -> &T; +} + +impl Helper for Option { + fn helper_borrow(&self) -> &T { + self.as_ref().unwrap() + } +} + +impl> Deref for DerefWithHelper { + type Target = T; + + fn deref(&self) -> &T { + self.helper.helper_borrow() + } +} + +pub fn check(x: T, y: T) -> bool { + let d: DerefWithHelper, T> = DerefWithHelper { helper: Some(x), + marker: PhantomData }; + d.eq(&y) +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-constant-type.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-constant-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-constant-type.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-constant-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +trait SignedUnsigned { + type Opposite; + fn convert(self) -> Self::Opposite; +} + +impl SignedUnsigned for isize { + type Opposite = usize; + + fn convert(self) -> usize { + self as usize + } +} + +impl SignedUnsigned for usize { + type Opposite = isize; + + fn convert(self) -> isize { + self as isize + } +} + +fn get(x: isize) -> ::Opposite { + x.convert() +} + +fn main() { + let x = get(22); + assert_eq!(22, x); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-doubleendediterator-object.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-doubleendediterator-object.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-doubleendediterator-object.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-doubleendediterator-object.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +fn pairwise_sub(mut t: Box>) -> isize { + let mut result = 0; + loop { + let front = t.next(); + let back = t.next_back(); + match (front, back) { + (Some(f), Some(b)) => { result += b - f; } + _ => { return result; } + } + } +} + +fn main() { + let v = vec![1, 2, 3, 4, 5, 6]; + let r = pairwise_sub(Box::new(v.into_iter())); + assert_eq!(r, 9); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-duplicate-binding-in-env-hrtb.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-duplicate-binding-in-env-hrtb.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-duplicate-binding-in-env-hrtb.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-duplicate-binding-in-env-hrtb.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Check that we do not report ambiguities when equivalent predicates +// (modulo bound lifetime names) appears in the environment +// twice. Issue #21965. + +// pretty-expanded FIXME #23616 + +fn foo(t: T) -> i32 + where T : for<'a> Fn(&'a u8) -> i32, + T : for<'b> Fn(&'b u8) -> i32, +{ + t(&3) +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-duplicate-binding-in-env.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-duplicate-binding-in-env.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-duplicate-binding-in-env.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-duplicate-binding-in-env.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Check that we do not report ambiguities when the same predicate +// appears in the environment twice. Issue #21965. + +// pretty-expanded FIXME #23616 + +trait Foo { + type B; + + fn get() -> Self::B; +} + +fn foo() -> () + where T : Foo, T : Foo +{ + ::get() +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-enum-field-named.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-enum-field-named.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-enum-field-named.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-enum-field-named.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test associated types appearing in struct-like enum variants. + + +use self::VarValue::*; + +pub trait UnifyKey { + type Value; + fn to_index(&self) -> usize; +} + +pub enum VarValue { + Redirect { to: K }, + Root { value: K::Value, rank: usize }, +} + +fn get<'a,K:UnifyKey>,V>(table: &'a Vec>, key: &K) -> &'a Option { + match table[key.to_index()] { + VarValue::Redirect { to: ref k } => get(table, k), + VarValue::Root { value: ref v, rank: _ } => v, + } +} + +impl UnifyKey for usize { + type Value = Option; + fn to_index(&self) -> usize { *self } +} + +fn main() { + let table = vec![/* 0 */ Redirect { to: 1 }, + /* 1 */ Redirect { to: 3 }, + /* 2 */ Root { value: Some('x'), rank: 0 }, + /* 3 */ Redirect { to: 2 }]; + assert_eq!(get(&table, &0), &Some('x')); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-enum-field-numbered.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-enum-field-numbered.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-enum-field-numbered.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-enum-field-numbered.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test associated types appearing in tuple-like enum variants. + + +use self::VarValue::*; + +pub trait UnifyKey { + type Value; + fn to_index(&self) -> usize; +} + +pub enum VarValue { + Redirect(K), + Root(K::Value, usize), +} + +fn get<'a,K:UnifyKey>,V>(table: &'a Vec>, key: &K) -> &'a Option { + match table[key.to_index()] { + VarValue::Redirect(ref k) => get(table, k), + VarValue::Root(ref v, _) => v, + } +} + +impl UnifyKey for usize { + type Value = Option; + fn to_index(&self) -> usize { *self } +} + +fn main() { + let table = vec![/* 0 */ Redirect(1), + /* 1 */ Redirect(3), + /* 2 */ Root(Some('x'), 0), + /* 3 */ Redirect(2)]; + assert_eq!(get(&table, &0), &Some('x')); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-eq-obj.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-eq-obj.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-eq-obj.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-eq-obj.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test equality constraints on associated types inside of an object type + +// pretty-expanded FIXME #23616 + +pub trait Foo { + type A; + fn boo(&self) -> ::A; +} + +pub struct Bar; + +impl Foo for char { + type A = Bar; + fn boo(&self) -> Bar { Bar } +} + +fn baz(x: &Foo) -> Bar { + x.boo() +} + +pub fn main() { + let a = 'a'; + baz(&a); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-impl-redirect.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-impl-redirect.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-impl-redirect.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-impl-redirect.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,61 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_mut)] +#![allow(unused_imports)] +// Test how resolving a projection interacts with inference. In this +// case, we were eagerly unifying the type variable for the iterator +// type with `I` from the where clause, ignoring the in-scope `impl` +// for `ByRef`. The right answer was to consider the result ambiguous +// until more type information was available. + +#![feature(lang_items)] +#![no_implicit_prelude] + +use std::marker::Sized; +use std::option::Option::{None, Some, self}; + +trait Iterator { + type Item; + + fn next(&mut self) -> Option; +} + +trait IteratorExt: Iterator + Sized { + fn by_ref(&mut self) -> ByRef { + ByRef(self) + } +} + +impl IteratorExt for I where I: Iterator {} + +struct ByRef<'a, I: 'a + Iterator>(&'a mut I); + +impl<'a, I: Iterator> Iterator for ByRef<'a, I> { + type Item = I::Item; + + fn next(&mut self) -> Option< ::Item > { + self.0.next() + } +} + +fn is_iterator_of>(_: &I) {} + +fn test>(mut it: I) { + is_iterator_of::(&it.by_ref()); +} + +fn test2, I2: Iterator>(mut it: I2) { + is_iterator_of::(&it) +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-in-bound-type-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-in-bound-type-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-in-bound-type-arg.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-in-bound-type-arg.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test the case where we resolve `C::Result` and the trait bound +// itself includes a `Self::Item` shorthand. +// +// Regression test for issue #33425. + +trait ParallelIterator { + type Item; + fn drive_unindexed(self, consumer: C) -> C::Result + where C: Consumer; +} + +pub trait Consumer { + type Result; +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-in-default-method.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-in-default-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-in-default-method.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-in-default-method.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +trait Get { + type Value; + fn get(&self) -> &::Value; + fn grab(&self) -> &::Value { + self.get() + } +} + +struct Struct { + x: isize, +} + +impl Get for Struct { + type Value = isize; + fn get(&self) -> &isize { + &self.x + } +} + +fn main() { + let s = Struct { + x: 100, + }; + assert_eq!(*s.grab(), 100); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-in-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-in-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-in-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-in-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +trait Get { + type Value; + fn get(&self) -> &::Value; +} + +struct Struct { + x: isize, +} + +impl Get for Struct { + type Value = isize; + fn get(&self) -> &isize { + &self.x + } +} + +fn grab(x: &T) -> &::Value { + x.get() +} + +fn main() { + let s = Struct { + x: 100, + }; + assert_eq!(*grab(&s), 100); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-in-impl-generics.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-in-impl-generics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-in-impl-generics.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-in-impl-generics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +trait Get { + type Value; + fn get(&self) -> &::Value; +} + +struct Struct { + x: isize, +} + +impl Get for Struct { + type Value = isize; + fn get(&self) -> &isize { + &self.x + } +} + +trait Grab { + type U; + fn grab(&self) -> &::U; +} + +impl Grab for T { + type U = ::Value; + fn grab(&self) -> &::Value { + self.get() + } +} + +fn main() { + let s = Struct { + x: 100, + }; + assert_eq!(*s.grab(), 100); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-in-inherent-method.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-in-inherent-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-in-inherent-method.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-in-inherent-method.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +trait Get { + type Value; + fn get(&self) -> &::Value; +} + +struct Struct { + x: isize, +} + +impl Get for Struct { + type Value = isize; + fn get(&self) -> &isize { + &self.x + } +} + +impl Struct { + fn grab(x: &T) -> &::Value { + x.get() + } +} + +fn main() { + let s = Struct { + x: 100, + }; + assert_eq!(*Struct::grab(&s), 100); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-issue-20220.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-issue-20220.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-issue-20220.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-issue-20220.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test references to `Self::Item` in the trait. Issue #20220. + + +use std::vec; + +trait IntoIteratorX { + type Item; + type IntoIter: Iterator; + + fn into_iter_x(self) -> Self::IntoIter; +} + +impl IntoIteratorX for Vec { + type Item = T; + type IntoIter = vec::IntoIter; + + fn into_iter_x(self) -> vec::IntoIter { + self.into_iter() + } +} + +fn main() { + let vec = vec![1, 2, 3]; + for (i, e) in vec.into_iter().enumerate() { + assert_eq!(i+1, e); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-issue-20371.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-issue-20371.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-issue-20371.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-issue-20371.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we are able to have an impl that defines an associated type +// before the actual trait. + +// pretty-expanded FIXME #23616 + +impl X for f64 { type Y = isize; } +trait X { type Y; } +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-issue-21212.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-issue-21212.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-issue-21212.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-issue-21212.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// Regression test for #21212: an overflow occurred during trait +// checking where normalizing `Self::Input` led to normalizing the +// where clauses in the environment which in turn required normalizing +// `Self::Input`. + + +pub trait Parser { + type Input; + + fn parse(input: ::Input) { + panic!() + } +} + +impl

(&self, pred: P) -> Splits where P: FnMut(&T) -> bool { + loop {} + } + + fn splitn2

(&self, n: usize, pred: P) -> SplitsN> where P: FnMut(&T) -> bool { + self.split2(pred); + loop {} + } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-normalize-in-bounds-ufcs.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-normalize-in-bounds-ufcs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-normalize-in-bounds-ufcs.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-normalize-in-bounds-ufcs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// Test that we normalize associated types that appear in bounds; if +// we didn't, the call to `self.split2()` fails to type check. + +// pretty-expanded FIXME #23616 + +use std::marker::PhantomData; + +struct Splits<'a, T:'a, P>(PhantomData<(&'a T, P)>); +struct SplitsN(PhantomData); + +trait SliceExt2 { + type Item; + + fn split2<'a, P>(&'a self, pred: P) -> Splits<'a, Self::Item, P> + where P: FnMut(&Self::Item) -> bool; + fn splitn2<'a, P>(&'a self, n: u32, pred: P) -> SplitsN> + where P: FnMut(&Self::Item) -> bool; +} + +impl SliceExt2 for [T] { + type Item = T; + + fn split2

(&self, pred: P) -> Splits where P: FnMut(&T) -> bool { + loop {} + } + + fn splitn2

(&self, n: u32, pred: P) -> SplitsN> where P: FnMut(&T) -> bool { + SliceExt2::split2(self, pred); + loop {} + } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-normalize-unifield-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-normalize-unifield-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-normalize-unifield-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-normalize-unifield-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for issue #21010: Normalize associated types in +// various special paths in the `type_is_immediate` function. + +pub trait OffsetState: Sized {} +pub trait Offset { + type State: OffsetState; + fn dummy(&self) { } +} + +#[derive(Copy, Clone)] pub struct X; +impl Offset for X { type State = Y; } + +#[derive(Copy, Clone)] pub struct Y; +impl OffsetState for Y {} + +pub fn now() -> DateTime { from_utc(Y) } + +pub struct DateTime { pub offset: Off::State } +pub fn from_utc(offset: Off::State) -> DateTime { DateTime { offset: offset } } + +pub fn main() { + let _x = now(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-project-from-type-param-via-bound-in-where.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-project-from-type-param-via-bound-in-where.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-project-from-type-param-via-bound-in-where.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-project-from-type-param-via-bound-in-where.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,108 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Various uses of `T::Item` syntax where the bound that supplies +// `Item` originates in a where-clause, not the declaration of +// `T`. Issue #20300. + +use std::marker::{PhantomData}; +use std::sync::atomic::{AtomicUsize}; +use std::sync::atomic::Ordering::SeqCst; + +static COUNTER: AtomicUsize = AtomicUsize::new(0); + +// Preamble. +trait Trait { type Item; } +struct Struct; +impl Trait for Struct { + type Item = u32; +} + +// Where-clause attached on the method which declares `T`. +struct A; +impl A { + fn foo(_x: T::Item) where T: Trait { + COUNTER.fetch_add(1, SeqCst); + } +} + +// Where-clause attached on the method to a parameter from the struct. +struct B(PhantomData); +impl B { + fn foo(_x: T::Item) where T: Trait { + COUNTER.fetch_add(10, SeqCst); + } +} + +// Where-clause attached to free fn. +fn c(_: T::Item) where T : Trait { + COUNTER.fetch_add(100, SeqCst); +} + +// Where-clause attached to defaulted and non-defaulted trait method. +trait AnotherTrait { + fn method(&self, _: T::Item) where T: Trait; + fn default_method(&self, _: T::Item) where T: Trait { + COUNTER.fetch_add(1000, SeqCst); + } +} +struct D; +impl AnotherTrait for D { + fn method(&self, _: T::Item) where T: Trait { + COUNTER.fetch_add(10000, SeqCst); + } +} + +// Where-clause attached to trait and impl containing the method. +trait YetAnotherTrait + where T : Trait +{ + fn method(&self, _: T::Item); + fn default_method(&self, _: T::Item) { + COUNTER.fetch_add(100000, SeqCst); + } +} +struct E(PhantomData); +impl YetAnotherTrait for E + where T : Trait +{ + fn method(&self, _: T::Item) { + COUNTER.fetch_add(1000000, SeqCst); + } +} + +// Where-clause attached to inherent impl containing the method. +struct F(PhantomData); +impl F where T : Trait { + fn method(&self, _: T::Item) { + COUNTER.fetch_add(10000000, SeqCst); + } +} + +// Where-clause attached to struct. +#[allow(dead_code)] +struct G where T : Trait { + data: T::Item, + phantom: PhantomData, +} + +fn main() { + A::foo::(22); + B::::foo(22); + c::(22); + D.method::(22); + D.default_method::(22); + E(PhantomData::).method(22); + E(PhantomData::).default_method(22); + F(PhantomData::).method(22); + G:: { data: 22, phantom: PhantomData }; + assert_eq!(COUNTER.load(SeqCst), 11111111); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-bound-in-supertraits.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-bound-in-supertraits.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-bound-in-supertraits.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-bound-in-supertraits.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// Test that we correctly handle projection bounds appearing in the +// supertrait list (and in conjunction with overloaded operators). In +// this case, the `Result=Self` binding in the supertrait listing of +// `Int` was being ignored. + +trait Not { + type Result; + + fn not(self) -> Self::Result; +} + +trait Int: Not + Sized { + fn count_ones(self) -> usize; + fn count_zeros(self) -> usize { + // neither works + let x: Self = self.not(); + 0 + } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-from-known-type-in-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-from-known-type-in-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-from-known-type-in-impl.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-from-known-type-in-impl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,48 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test where the impl self type uses a projection from a constant type. + + +trait Int +{ + type T; + + fn dummy(&self) { } +} + +trait NonZero +{ + fn non_zero(self) -> bool; +} + +impl Int for i32 { type T = i32; } +impl Int for i64 { type T = i64; } +impl Int for u32 { type T = u32; } +impl Int for u64 { type T = u64; } + +impl NonZero for ::T { fn non_zero(self) -> bool { self != 0 } } +impl NonZero for ::T { fn non_zero(self) -> bool { self != 0 } } +impl NonZero for ::T { fn non_zero(self) -> bool { self != 0 } } +impl NonZero for ::T { fn non_zero(self) -> bool { self != 0 } } + +fn main () +{ + assert!(NonZero::non_zero(22_i32)); + assert!(NonZero::non_zero(22_i64)); + assert!(NonZero::non_zero(22_u32)); + assert!(NonZero::non_zero(22_u64)); + + assert!(!NonZero::non_zero(0_i32)); + assert!(!NonZero::non_zero(0_i64)); + assert!(!NonZero::non_zero(0_u32)); + assert!(!NonZero::non_zero(0_u64)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-in-object-type.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-in-object-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-in-object-type.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-in-object-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,50 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_imports)] +// Corrected regression test for #20831. The original did not compile. +// When fixed, it revealed another problem concerning projections that +// appear in associated type bindings in object types, which were not +// being properly flagged. + +// pretty-expanded FIXME #23616 + +use std::ops::{Shl, Shr}; +use std::cell::RefCell; + +pub trait Subscriber { + type Input; + + fn dummy(&self) { } +} + +pub trait Publisher<'a> { + type Output; + fn subscribe(&mut self, _: Box + 'a>); +} + +pub trait Processor<'a> : Subscriber + Publisher<'a> { } + +impl<'a, P> Processor<'a> for P where P : Subscriber + Publisher<'a> { } + +struct MyStruct<'a> { + sub: Box + 'a> +} + +impl<'a> Publisher<'a> for MyStruct<'a> { + type Output = u64; + fn subscribe(&mut self, t : Box + 'a>) { + self.sub = t; + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-in-supertrait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-in-supertrait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-in-supertrait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-in-supertrait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,55 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Test that we are handle to correctly handle a projection type +// that appears in a supertrait bound. Issue #20559. + + +trait A +{ + type TA; + + fn dummy(&self) { } +} + +trait B +{ + fn foo (&self, t : TB) -> String; +} + +trait C : B<::TA> { } + +struct X; + +impl A for X +{ + type TA = i32; +} + +struct Y; + +impl C for Y { } + +// Both of these impls are required for successful compilation +impl B for Y +{ + fn foo (&self, t : i32) -> String + { + format!("First {}", t) + } +} + +fn main () +{ + let y = Y; + assert_eq!(y.foo(5), format!("First 5")); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-in-where-clause.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-in-where-clause.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-in-where-clause.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-in-where-clause.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// Test a where clause that uses a non-normalized projection type. + +// pretty-expanded FIXME #23616 + +trait Int +{ + type T; + + fn dummy(&self) { } +} + +trait NonZero +{ + fn non_zero(self) -> bool; +} + +fn foo,J>(t: I) -> bool + where ::T : NonZero + // ^~~~~~~~~~~~~ canonical form is just J +{ + bar::() +} + +fn bar() -> bool { true } + +fn main () +{ +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-to-unrelated-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-to-unrelated-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-to-unrelated-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-projection-to-unrelated-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Check that we do not get an error when you use `::Value` in +// the trait definition if there is no default method and for every impl, +// `Self` does implement `Get`. +// +// See also compile-fail tests associated-types-no-suitable-supertrait +// and associated-types-no-suitable-supertrait-2, which show how small +// variants of the code below can fail. + +trait Get { + type Value; +} + +trait Other { + fn okay(&self, foo: U, bar: ::Value) + where Self: Get; +} + +impl Get for () { + type Value = f32; +} + +impl Get for f64 { + type Value = u32; +} + +impl Other for () { + fn okay(&self, _foo: U, _bar: ::Value) { } +} + +impl Other for f64 { + fn okay(&self, _foo: U, _bar: ::Value) { } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-qualified-path-with-trait-with-type-parameters.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-qualified-path-with-trait-with-type-parameters.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-qualified-path-with-trait-with-type-parameters.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-qualified-path-with-trait-with-type-parameters.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +trait Foo { + type Bar; + fn get_bar() -> >::Bar; +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-ref-from-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-ref-from-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-ref-from-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-ref-from-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,65 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test associated type references in structure fields. + +// pretty-expanded FIXME #23616 + +trait Test { + type V; + + fn test(&self, value: &Self::V) -> bool; +} + +/////////////////////////////////////////////////////////////////////////// + +struct TesterPair { + tester: T, + value: T::V, +} + +impl TesterPair { + fn new(tester: T, value: T::V) -> TesterPair { + TesterPair { tester: tester, value: value } + } + + fn test(&self) -> bool { + self.tester.test(&self.value) + } +} + +/////////////////////////////////////////////////////////////////////////// + +struct EqU32(u32); +impl Test for EqU32 { + type V = u32; + + fn test(&self, value: &u32) -> bool { + self.0 == *value + } +} + +struct EqI32(i32); +impl Test for EqI32 { + type V = i32; + + fn test(&self, value: &i32) -> bool { + self.0 == *value + } +} + +fn main() { + let tester = TesterPair::new(EqU32(22), 23); + tester.test(); + + let tester = TesterPair::new(EqI32(22), 23); + tester.test(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-ref-in-struct-literal.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-ref-in-struct-literal.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-ref-in-struct-literal.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-ref-in-struct-literal.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test associated type references in a struct literal. Issue #20535. + + +pub trait Foo { + type Bar; + + fn dummy(&self) { } +} + +impl Foo for isize { + type Bar = isize; +} + +struct Thing { + a: F, + b: F::Bar, +} + +fn main() { + let thing = Thing{a: 1, b: 2}; + assert_eq!(thing.a + 1, thing.b); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-region-erasure-issue-20582.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-region-erasure-issue-20582.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-region-erasure-issue-20582.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-region-erasure-issue-20582.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Regression test for #20582. This test caused an ICE related to +// inconsistent region erasure in codegen. + +// pretty-expanded FIXME #23616 + +struct Foo<'a> { + buf: &'a[u8] +} + +impl<'a> Iterator for Foo<'a> { + type Item = &'a[u8]; + + fn next(&mut self) -> Option<::Item> { + Some(self.buf) + } +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-resolve-lifetime.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-resolve-lifetime.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-resolve-lifetime.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-resolve-lifetime.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +trait Get { + fn get(&self) -> T; +} + +trait Trait<'a> { + type T: 'static; + type U: Get<&'a isize>; + + fn dummy(&'a self) { } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-return.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-return.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-return.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-return.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,56 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test equality constraints on associated types in a where clause. + + +pub trait Foo { + type A; + fn boo(&self) -> ::A; +} + +#[derive(PartialEq, Debug)] +pub struct Bar; + +impl Foo for isize { + type A = usize; + fn boo(&self) -> usize { 42 } +} + +impl Foo for Bar { + type A = isize; + fn boo(&self) -> isize { 43 } +} + +impl Foo for char { + type A = Bar; + fn boo(&self) -> Bar { Bar } +} + +fn foo1>(x: I) -> Bar { + x.boo() +} + +fn foo2(x: I) -> ::A { + x.boo() +} + +pub fn main() { + let a = 42; + assert_eq!(foo2(a), 42); + + let a = Bar; + assert_eq!(foo2(a), 43); + + let a = 'a'; + foo1(a); + assert_eq!(foo2(a), Bar); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-simple.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-simple.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-simple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +trait Get { + type Value; + fn get(&self) -> &::Value; +} + +struct Struct { + x: isize, +} + +impl Get for Struct { + type Value = isize; + fn get(&self) -> &isize { + &self.x + } +} + +fn main() { + let s = Struct { + x: 100, + }; + assert_eq!(*s.get(), 100); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-stream.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-stream.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-stream.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-stream.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,49 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test references to the trait `Stream` in the bounds for associated +// types defined on `Stream`. Issue #20551. + + +trait Stream { + type Car; + type Cdr: Stream; + + fn car(&self) -> Self::Car; + fn cdr(self) -> Self::Cdr; +} + +impl Stream for () { + type Car = (); + type Cdr = (); + fn car(&self) -> () { () } + fn cdr(self) -> () { self } +} + +impl Stream for (T, U) + where T : Clone, U : Stream +{ + type Car = T; + type Cdr = U; + fn car(&self) -> T { self.0.clone() } + fn cdr(self) -> U { self.1 } +} + +fn main() { + let p = (22, (44, (66, ()))); + assert_eq!(p.car(), 22); + + let p = p.cdr(); + assert_eq!(p.car(), 44); + + let p = p.cdr(); + assert_eq!(p.car(), 66); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-struct-field-named.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-struct-field-named.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-struct-field-named.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-struct-field-named.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we correctly normalize the type of a struct field +// which has an associated type. + + +pub trait UnifyKey { + type Value; + + fn dummy(&self) { } +} + +pub struct Node { + pub key: K, + pub value: K::Value, +} + +fn foo>,V : Clone>(node: &Node) -> Option { + node.value.clone() +} + +impl UnifyKey for i32 { + type Value = Option; +} + +impl UnifyKey for u32 { + type Value = Option; +} + +pub fn main() { + let node: Node = Node { key: 1, value: Some(22) }; + assert_eq!(foo(&node), Some(22)); + + let node: Node = Node { key: 1, value: Some(22) }; + assert_eq!(foo(&node), Some(22)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-struct-field-numbered.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-struct-field-numbered.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-struct-field-numbered.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-struct-field-numbered.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we correctly normalize the type of a struct field +// which has an associated type. + + +pub trait UnifyKey { + type Value; + + fn dummy(&self) { } +} + +pub struct Node(K, K::Value); + +fn foo>,V : Clone>(node: &Node) -> Option { + node.1.clone() +} + +impl UnifyKey for i32 { + type Value = Option; +} + +impl UnifyKey for u32 { + type Value = Option; +} + +pub fn main() { + let node: Node = Node(1, Some(22)); + assert_eq!(foo(&node), Some(22)); + + let node: Node = Node(1, Some(22)); + assert_eq!(foo(&node), Some(22)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-sugar-path.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-sugar-path.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-sugar-path.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-sugar-path.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,51 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(unused_imports)] +// Test paths to associated types using the type-parameter-only sugar. + +use std::ops::Deref; + +pub trait Foo { + type A; + fn boo(&self) -> Self::A; +} + +impl Foo for isize { + type A = usize; + fn boo(&self) -> usize { + 5 + } +} + +// Using a type via a function. +pub fn bar(a: T, x: T::A) -> T::A { + let _: T::A = a.boo(); + x +} + +// Using a type via an impl. +trait C { + fn f(); + fn g(&self) { } +} +struct B(X); +impl C for B { + fn f() { + let x: T::A = panic!(); + } +} + +pub fn main() { + let z: usize = bar(2, 4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-where-clause-impl-ambiguity.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-where-clause-impl-ambiguity.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-where-clause-impl-ambiguity.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-where-clause-impl-ambiguity.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,56 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_imports)] +// Test how resolving a projection interacts with inference. In this +// case, we were eagerly unifying the type variable for the iterator +// type with `I` from the where clause, ignoring the in-scope `impl` +// for `ByRef`. The right answer was to consider the result ambiguous +// until more type information was available. + +#![feature(lang_items)] +#![no_implicit_prelude] + +use std::marker::Sized; +use std::option::Option::{None, Some, self}; + +trait Iterator { + type Item; + + fn next(&mut self) -> Option; +} + +trait IteratorExt: Iterator + Sized { + fn by_ref(&mut self) -> ByRef { + ByRef(self) + } +} + +impl IteratorExt for I where I: Iterator {} + +struct ByRef<'a, I: 'a + Iterator>(&'a mut I); + +impl<'a, A, I> Iterator for ByRef<'a, I> where I: Iterator { + type Item = A; + + fn next(&mut self) -> Option< ::Item > { + self.0.next() + } +} + +fn is_iterator_of>(_: &I) {} + +fn test>(mut it: I) { + is_iterator_of::(&it.by_ref()); +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/auxiliary/associated-types-cc-lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/auxiliary/associated-types-cc-lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/auxiliary/associated-types-cc-lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/auxiliary/associated-types-cc-lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Helper for test issue-18048, which tests associated types in a +// cross-crate scenario. + +#![crate_type="lib"] + +pub trait Bar: Sized { + type T; + + fn get(x: Option) -> ::T; +} + +impl Bar for isize { + type T = usize; + + fn get(_: Option) -> usize { 22 } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/async-await.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/async-await.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/async-await.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/async-await.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,17 +12,14 @@ #![feature(arbitrary_self_types, async_await, await_macro, futures_api, pin)] -use std::pin::PinBox; -use std::pin::PinMut; +use std::pin::Pin; use std::future::Future; use std::sync::{ Arc, atomic::{self, AtomicUsize}, }; -use std::future::FutureObj; use std::task::{ - Context, Poll, Wake, - Spawn, SpawnObjError, + LocalWaker, Poll, Wake, local_waker_from_nonlocal, }; @@ -36,24 +33,17 @@ } } -struct NoopSpawner; -impl Spawn for NoopSpawner { - fn spawn_obj(&mut self, _: FutureObj<'static, ()>) -> Result<(), SpawnObjError> { - Ok(()) - } -} - struct WakeOnceThenComplete(bool); fn wake_and_yield_once() -> WakeOnceThenComplete { WakeOnceThenComplete(false) } impl Future for WakeOnceThenComplete { type Output = (); - fn poll(mut self: PinMut, cx: &mut Context) -> Poll<()> { + fn poll(mut self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<()> { if self.0 { Poll::Ready(()) } else { - cx.waker().wake(); + lw.wake(); self.0 = true; Poll::Pending } @@ -148,16 +138,13 @@ F: FnOnce(u8) -> Fut, Fut: Future, { - let mut fut = PinBox::new(f(9)); + let mut fut = Box::pinned(f(9)); let counter = Arc::new(Counter { wakes: AtomicUsize::new(0) }); let waker = local_waker_from_nonlocal(counter.clone()); - let spawner = &mut NoopSpawner; - let cx = &mut Context::new(&waker, spawner); - assert_eq!(0, counter.wakes.load(atomic::Ordering::SeqCst)); - assert_eq!(Poll::Pending, fut.as_pin_mut().poll(cx)); + assert_eq!(Poll::Pending, fut.as_mut().poll(&waker)); assert_eq!(1, counter.wakes.load(atomic::Ordering::SeqCst)); - assert_eq!(Poll::Ready(9), fut.as_pin_mut().poll(cx)); + assert_eq!(Poll::Ready(9), fut.as_mut().poll(&waker)); } fn main() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/atomic-access-bool.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/atomic-access-bool.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/atomic-access-bool.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/atomic-access-bool.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(stable_features)] #![feature(atomic_access)] use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT}; use std::sync::atomic::Ordering::*; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/atomic-compare_exchange.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/atomic-compare_exchange.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/atomic-compare_exchange.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/atomic-compare_exchange.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(stable_features)] + #![feature(extended_compare_and_swap)] use std::sync::atomic::{AtomicIsize, ATOMIC_ISIZE_INIT}; use std::sync::atomic::Ordering::*; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/atomic-print.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/atomic-print.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/atomic-print.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/atomic-print.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_must_use)] +#![allow(deprecated)] // ignore-cloudabi no process support // ignore-emscripten no threads support diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/attr-before-view-item2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/attr-before-view-item2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/attr-before-view-item2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/attr-before-view-item2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_attributes)] + // pretty-expanded FIXME #23616 #![feature(custom_attribute, test)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/attr-before-view-item.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/attr-before-view-item.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/attr-before-view-item.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/attr-before-view-item.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_attributes)] + // pretty-expanded FIXME #23616 #![feature(custom_attribute, test)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/attr-mix-new.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/attr-mix-new.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/attr-mix-new.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/attr-mix-new.rs 2018-12-04 23:41:40.000000000 +0000 @@ -7,6 +7,10 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. + +#![allow(unused_attributes)] +#![allow(unknown_lints)] + // pretty-expanded FIXME #23616 #![allow(unused_attribute)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/attr-on-generic-formals.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/attr-on-generic-formals.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/attr-on-generic-formals.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/attr-on-generic-formals.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_attributes)] + // This test ensures we can attach attributes to the formals in all // places where generic parameter lists occur, assuming appropriate // feature gates are enabled. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/augmented-assignments.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/augmented-assignments.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/augmented-assignments.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/augmented-assignments.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_imports)] #![deny(unused_assignments)] use std::mem; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/auto-instantiate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/auto-instantiate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/auto-instantiate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/auto-instantiate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] #[derive(Debug)] struct Pair { a: T, b: U } struct Triple { x: isize, y: isize, z: isize } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/auto-is-contextual.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/auto-is-contextual.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/auto-is-contextual.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/auto-is-contextual.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(path_statements)] +#![allow(dead_code)] macro_rules! auto { () => (struct S;) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-and-borrow-method-receiver.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-and-borrow-method-receiver.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-and-borrow-method-receiver.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-and-borrow-method-receiver.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +struct Foo { + x: isize, +} + +impl Foo { + pub fn f(&self) {} +} + +fn g(x: &mut Foo) { + x.f(); +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-method-on-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-method-on-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-method-on-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-method-on-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] +#![feature(box_syntax)] + +trait double { + fn double(self: Box) -> usize; +} + +impl double for usize { + fn double(self: Box) -> usize { *self * 2 } +} + +pub fn main() { + let x: Box<_> = box (box 3usize as Box); + assert_eq!(x.double(), 6); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-method-priority.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-method-priority.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-method-priority.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-method-priority.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] +#![feature(box_syntax)] + +trait double { + fn double(self) -> usize; +} + +impl double for usize { + fn double(self) -> usize { self } +} + +impl double for Box { + fn double(self) -> usize { *self * 2 } +} + +pub fn main() { + let x: Box<_> = box 3; + assert_eq!(x.double(), 6); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-method.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-method.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-method.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] +#![feature(box_syntax)] + +trait double { + fn double(self: Box) -> usize; +} + +impl double for usize { + fn double(self: Box) -> usize { *self * 2 } +} + +pub fn main() { + let x: Box<_> = box 3; + assert_eq!(x.double(), 6); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-method-twice-but-not-thrice.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-method-twice-but-not-thrice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-method-twice-but-not-thrice.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-method-twice-but-not-thrice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] +#![feature(box_syntax)] + +trait double { + fn double(self: Box) -> usize; +} + +impl double for Box { + fn double(self: Box>) -> usize { **self * 2 } +} + +pub fn main() { + let x: Box>>>> = box box box box box 3; + assert_eq!(x.double(), 6); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-method-twice.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-method-twice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-method-twice.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-method-twice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] +#![feature(box_syntax)] + +trait double { + fn double(self: Box) -> usize; +} + +impl double for usize { + fn double(self: Box) -> usize { *self * 2 } +} + +pub fn main() { + let x: Box> = box box 3; + assert_eq!(x.double(), 6); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-privacy.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-privacy.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-privacy.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoderef-privacy.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,61 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Check we do not select a private method or field when computing autoderefs + +#![allow(unused)] + +#[derive(Default)] +pub struct Bar2 { i: i32 } +#[derive(Default)] +pub struct Baz2(i32); + +impl Bar2 { + fn f(&self) -> bool { true } +} + +mod foo { + #[derive(Default)] + pub struct Bar { i: ::Bar2 } + #[derive(Default)] + pub struct Baz(::Baz2); + + impl Bar { + fn f(&self) -> bool { false } + } + + impl ::std::ops::Deref for Bar { + type Target = ::Bar2; + fn deref(&self) -> &::Bar2 { &self.i } + } + + impl ::std::ops::Deref for Baz { + type Target = ::Baz2; + fn deref(&self) -> &::Baz2 { &self.0 } + } + + pub fn f(bar: &Bar, baz: &Baz) { + // Since the private fields and methods are visible here, there should be no autoderefs. + let _: &::Bar2 = &bar.i; + let _: &::Baz2 = &baz.0; + assert!(!bar.f()); + } +} + +fn main() { + let bar = foo::Bar::default(); + let baz = foo::Baz::default(); + foo::f(&bar, &baz); + + let _: i32 = bar.i; + let _: i32 = baz.0; + assert!(bar.f()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/auto-ref-bounded-ty-param.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/auto-ref-bounded-ty-param.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/auto-ref-bounded-ty-param.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/auto-ref-bounded-ty-param.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait Foo { + fn f(&self); +} + +struct Bar { + x: isize +} + +trait Baz { + fn g(&self); +} + +impl Foo for T { + fn f(&self) { + self.g(); + } +} + +impl Baz for Bar { + fn g(&self) { + println!("{}", self.x); + } +} + +pub fn main() { + let y = Bar { x: 42 }; + y.f(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoref-intermediate-types-issue-3585.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoref-intermediate-types-issue-3585.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoref-intermediate-types-issue-3585.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/autoref-intermediate-types-issue-3585.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +trait Foo { + fn foo(&self) -> String; +} + +impl Foo for Box { + fn foo(&self) -> String { + format!("box {}", (**self).foo()) + } +} + +impl Foo for usize { + fn foo(&self) -> String { + format!("{}", *self) + } +} + +pub fn main() { + let x: Box<_> = box 3; + assert_eq!(x.foo(), "box 3".to_string()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/auto-ref.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/auto-ref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/auto-ref.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/auto-ref.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct Foo { + x: isize, +} + +trait Stuff { + fn printme(&self); +} + +impl Stuff for Foo { + fn printme(&self) { + println!("{}", self.x); + } +} + +pub fn main() { + let x = Foo { x: 3 }; + x.printme(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/auto-ref-sliceable.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/auto-ref-sliceable.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/auto-ref-sliceable.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/autoref-autoderef/auto-ref-sliceable.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +trait Pushable { + fn push_val(&mut self, t: T); +} + +impl Pushable for Vec { + fn push_val(&mut self, t: T) { + self.push(t); + } +} + +pub fn main() { + let mut v = vec![1]; + v.push_val(2); + v.push_val(3); + assert_eq!(v, [1, 2, 3]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/bench/issue-32062.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/bench/issue-32062.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/bench/issue-32062.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/bench/issue-32062.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,60 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// pretty-expanded FIXME #23616 + +fn main() { + let _ = test(Some(0).into_iter()); +} + +trait Parser { + type Input: Iterator; + type Output; + fn parse(self, input: Self::Input) -> Result<(Self::Output, Self::Input), ()>; + fn chain

(self, p: P) -> Chain where Self: Sized { + Chain(self, p) + } +} + +struct Token(T::Item) where T: Iterator; + +impl Parser for Token where T: Iterator { + type Input = T; + type Output = T::Item; + fn parse(self, _input: Self::Input) -> Result<(Self::Output, Self::Input), ()> { + Err(()) + } +} + +struct Chain(L, R); + +impl Parser for Chain where L: Parser, R: Parser { + type Input = L::Input; + type Output = (L::Output, R::Output); + fn parse(self, _input: Self::Input) -> Result<(Self::Output, Self::Input), ()> { + Err(()) + } +} + +fn test(i: I) -> Result<((), I), ()> where I: Iterator { + Chain(Token(0), Token(1)) + .chain(Chain(Token(0), Token(1))) + .chain(Chain(Token(0), Token(1))) + .chain(Chain(Token(0), Token(1))) + .chain(Chain(Token(0), Token(1))) + .chain(Chain(Token(0), Token(1))) + .chain(Chain(Token(0), Token(1))) + .chain(Chain(Token(0), Token(1))) + .chain(Chain(Token(0), Token(1))) + .parse(i) + .map(|(_, i)| ((), i)) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/allow_irrefutable_let_patterns.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/allow_irrefutable_let_patterns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/allow_irrefutable_let_patterns.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/allow_irrefutable_let_patterns.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(irrefutable_let_patterns)] + +// must-compile-successfully-irrefutable_let_patterns_with_gate +#[allow(irrefutable_let_patterns)] +fn main() { + if let _ = 5 {} + + while let _ = 5 { + break; + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/bind-field-short-with-modifiers.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/bind-field-short-with-modifiers.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/bind-field-short-with-modifiers.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/bind-field-short-with-modifiers.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_assignments)] +#![allow(unused_variables)] +#![allow(non_shorthand_field_patterns)] + +pub fn main() { + struct Foo { x: isize, y: isize } + let mut f = Foo { x: 10, y: 0 }; + match f { + Foo { ref mut x, .. } => *x = 11, + } + match f { + Foo { ref x, ref y } => { + assert_eq!(f.x, 11); + assert_eq!(f.y, 0); + } + } + match f { + Foo { mut x, y: ref mut y } => { + x = 12; + *y = 1; + } + } + assert_eq!(f.x, 11); + assert_eq!(f.y, 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/borrowed-ptr-pattern-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/borrowed-ptr-pattern-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/borrowed-ptr-pattern-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/borrowed-ptr-pattern-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn foo(s: &String) -> bool { + match &**s { + "kitty" => true, + _ => false + } +} + +pub fn main() { + assert!(foo(&"kitty".to_string())); + assert!(!foo(&"gata".to_string())); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/borrowed-ptr-pattern-3.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/borrowed-ptr-pattern-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/borrowed-ptr-pattern-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/borrowed-ptr-pattern-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn foo<'r>(s: &'r usize) -> bool { + match s { + &3 => true, + _ => false + } +} + +pub fn main() { + assert!(foo(&3)); + assert!(!foo(&4)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/borrowed-ptr-pattern-infallible.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/borrowed-ptr-pattern-infallible.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/borrowed-ptr-pattern-infallible.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/borrowed-ptr-pattern-infallible.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +pub fn main() { + let (&x, &y) = (&3, &'a'); + assert_eq!(x, 3); + assert_eq!(y, 'a'); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/borrowed-ptr-pattern-option.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/borrowed-ptr-pattern-option.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/borrowed-ptr-pattern-option.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/borrowed-ptr-pattern-option.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn select<'r>(x: &'r Option, y: &'r Option) -> &'r Option { + match (x, y) { + (&None, &None) => x, + (&Some(_), _) => x, + (&None, &Some(_)) => y + } +} + +pub fn main() { + let x = None; + let y = Some(3); + assert_eq!(select(&x, &y).unwrap(), 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/borrowed-ptr-pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/borrowed-ptr-pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/borrowed-ptr-pattern.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/borrowed-ptr-pattern.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn foo(x: &T) -> T{ + match x { + &ref a => (*a).clone() + } +} + +pub fn main() { + assert_eq!(foo(&3), 3); + assert_eq!(foo(&'a'), 'a'); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/empty-types-in-patterns.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/empty-types-in-patterns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/empty-types-in-patterns.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/empty-types-in-patterns.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,67 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(never_type)] +#![feature(exhaustive_patterns)] +#![feature(slice_patterns)] +#![allow(unreachable_patterns)] +#![allow(unreachable_code)] + +#[allow(dead_code)] +fn foo(z: !) { + let x: Result = Ok(z); + + let Ok(_y) = x; + let Err(_y) = x; + + let x = [z; 1]; + + match x {}; + match x { + [q] => q, + }; +} + +fn bar(nevers: &[!]) { + match nevers { + &[] => (), + }; + + match nevers { + &[] => (), + &[_] => (), + &[_, _, _, ..] => (), + }; +} + +fn main() { + let x: Result = Ok(123); + let Ok(y) = x; + + assert_eq!(123, y); + + match x { + Ok(y) => y, + }; + + match x { + Ok(y) => y, + Err(e) => match e {}, + }; + + let x: Result = Ok(123); + match x { + Ok(y) => y, + }; + + bar(&[]); +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/exhaustive-bool-match-sanity.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/exhaustive-bool-match-sanity.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/exhaustive-bool-match-sanity.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/exhaustive-bool-match-sanity.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Issue #33540 +// We previously used to generate a 3-armed boolean `SwitchInt` in the +// MIR of the function `foo` below. #33583 changed rustc to +// generate an `If` terminator instead. This test is to just ensure +// sanity in that we generate an if-else chain giving the correct +// results. + +fn foo(x: bool, y: bool) -> u32 { + match (x, y) { + (false, _) => 0, + (_, false) => 1, + (true, true) => 2 + } +} + +fn main() { + assert_eq!(foo(false, true), 0); + assert_eq!(foo(false, false), 0); + assert_eq!(foo(true, false), 1); + assert_eq!(foo(true, true), 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-generic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-generic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-generic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-generic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +type compare = extern "Rust" fn(T, T) -> bool; + +fn test_generic(expected: T, eq: compare) { + let actual: T = match true { true => { expected.clone() }, _ => panic!("wat") }; + assert!((eq(expected, actual))); +} + +fn test_bool() { + fn compare_bool(b1: bool, b2: bool) -> bool { return b1 == b2; } + test_generic::(true, compare_bool); +} + +#[derive(Clone)] +struct Pair { + a: isize, + b: isize, +} + +fn test_rec() { + fn compare_rec(t1: Pair, t2: Pair) -> bool { + t1.a == t2.a && t1.b == t2.b + } + test_generic::(Pair {a: 1, b: 2}, compare_rec); +} + +pub fn main() { test_bool(); test_rec(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-generic-unique1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-generic-unique1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-generic-unique1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-generic-unique1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +fn test_generic(expected: Box, eq: F) where F: FnOnce(Box, Box) -> bool { + let actual: Box = match true { + true => { expected.clone() }, + _ => panic!("wat") + }; + assert!(eq(expected, actual)); +} + +fn test_box() { + fn compare_box(b1: Box, b2: Box) -> bool { + return *b1 == *b2; + } + test_generic::(box true, compare_box); +} + +pub fn main() { test_box(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-generic-unique2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-generic-unique2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-generic-unique2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-generic-unique2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +fn test_generic(expected: T, eq: F) where F: FnOnce(T, T) -> bool { + let actual: T = match true { + true => expected.clone(), + _ => panic!("wat") + }; + assert!(eq(expected, actual)); +} + +fn test_vec() { + fn compare_box(v1: Box, v2: Box) -> bool { return v1 == v2; } + test_generic::, _>(box 1, compare_box); +} + +pub fn main() { test_vec(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-panic-all.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-panic-all.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-panic-all.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-panic-all.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + +// When all branches of a match expression result in panic, the entire +// match expression results in panic. + +pub fn main() { + let _x = + match true { + true => { 10 } + false => { match true { true => { panic!() } false => { panic!() } } } + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-panic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-panic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-panic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-panic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +fn test_simple() { + let r = match true { true => { true } false => { panic!() } }; + assert_eq!(r, true); +} + +fn test_box() { + let r = match true { true => { vec![10] } false => { panic!() } }; + assert_eq!(r[0], 10); +} + +pub fn main() { test_simple(); test_box(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/expr-match.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/expr-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/expr-match.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/expr-match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,55 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + + +// Tests for using match as an expression + +fn test_basic() { + let mut rs: bool = match true { true => { true } false => { false } }; + assert!((rs)); + rs = match false { true => { false } false => { true } }; + assert!((rs)); +} + +fn test_inferrence() { + let rs = match true { true => { true } false => { false } }; + assert!((rs)); +} + +fn test_alt_as_alt_head() { + // Yeah, this is kind of confusing ... + + let rs = + match match false { true => { true } false => { false } } { + true => { false } + false => { true } + }; + assert!((rs)); +} + +fn test_alt_as_block_result() { + let rs = + match false { + true => { false } + false => { match true { true => { true } false => { false } } } + }; + assert!((rs)); +} + +pub fn main() { + test_basic(); + test_inferrence(); + test_alt_as_alt_head(); + test_alt_as_block_result(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-unique.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-unique.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-unique.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/expr-match-unique.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +// Tests for match as expressions resulting in boxed types +fn test_box() { + let res: Box<_> = match true { true => { box 100 }, _ => panic!() }; + assert_eq!(*res, 100); +} + +pub fn main() { test_box(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/fat-arrow-match.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/fat-arrow-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/fat-arrow-match.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/fat-arrow-match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +enum color { + red, + green, + blue +} + +pub fn main() { + println!("{}", match color::red { + color::red => { 1 } + color::green => { 2 } + color::blue => { 3 } + }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/fn-pattern-expected-type-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/fn-pattern-expected-type-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/fn-pattern-expected-type-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/fn-pattern-expected-type-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn main() { + let v : &[(isize,isize)] = &[ (1, 2), (3, 4), (5, 6) ]; + for &(x, y) in v { + println!("{}", y); + println!("{}", x); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/fn-pattern-expected-type.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/fn-pattern-expected-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/fn-pattern-expected-type.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/fn-pattern-expected-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + let f = |(x, y): (isize, isize)| { + assert_eq!(x, 1); + assert_eq!(y, 2); + }; + f((1, 2)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/func-arg-incomplete-pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/func-arg-incomplete-pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/func-arg-incomplete-pattern.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/func-arg-incomplete-pattern.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Test that we do not leak when the arg pattern must drop part of the +// argument (in this case, the `y` field). + +#![feature(box_syntax)] + +struct Foo { + x: Box, + y: Box, +} + +fn foo(Foo {x, ..}: Foo) -> *const usize { + let addr: *const usize = &*x; + addr +} + +pub fn main() { + let obj: Box<_> = box 1; + let objptr: *const usize = &*obj; + let f = Foo {x: obj, y: box 2}; + let xptr = foo(f); + assert_eq!(objptr, xptr); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/func-arg-ref-pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/func-arg-ref-pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/func-arg-ref-pattern.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/func-arg-ref-pattern.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// exec-env:RUST_POISON_ON_FREE=1 + +// Test argument patterns where we create refs to the inside of +// boxes. Make sure that we don't free the box as we match the +// pattern. + +#![feature(box_patterns)] +#![feature(box_syntax)] + +fn getaddr(box ref x: Box) -> *const usize { + let addr: *const usize = &*x; + addr +} + +fn checkval(box ref x: Box) -> usize { + *x +} + +pub fn main() { + let obj: Box<_> = box 1; + let objptr: *const usize = &*obj; + let xptr = getaddr(obj); + assert_eq!(objptr, xptr); + + let obj = box 22; + assert_eq!(checkval(obj), 22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/func-arg-wild-pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/func-arg-wild-pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/func-arg-wild-pattern.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/func-arg-wild-pattern.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we can compile code that uses a `_` in function argument +// patterns. + + +fn foo((x, _): (isize, isize)) -> isize { + x +} + +pub fn main() { + assert_eq!(foo((22, 23)), 22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/if-let.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/if-let.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/if-let.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/if-let.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,70 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +pub fn main() { + let x = Some(3); + if let Some(y) = x { + assert_eq!(y, 3); + } else { + panic!("if-let panicked"); + } + let mut worked = false; + if let Some(_) = x { + worked = true; + } + assert!(worked); + let clause: usize; + if let None = Some("test") { + clause = 1; + } else if 4_usize > 5 { + clause = 2; + } else if let Ok(()) = Err::<(),&'static str>("test") { + clause = 3; + } else { + clause = 4; + } + assert_eq!(clause, 4_usize); + + if 3 > 4 { + panic!("bad math"); + } else if let 1 = 2 { + panic!("bad pattern match"); + } + + enum Foo { + One, + Two(usize), + Three(String, isize) + } + + let foo = Foo::Three("three".to_string(), 42); + if let Foo::One = foo { + panic!("bad pattern match"); + } else if let Foo::Two(_x) = foo { + panic!("bad pattern match"); + } else if let Foo::Three(s, _) = foo { + assert_eq!(s, "three"); + } else { + panic!("bad else"); + } + + if false { + panic!("wat"); + } else if let a@Foo::Two(_) = Foo::Two(42_usize) { + if let Foo::Two(b) = a { + assert_eq!(b, 42_usize); + } else { + panic!("panic in nested if-let"); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/inconsistent-lifetime-mismatch.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/inconsistent-lifetime-mismatch.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/inconsistent-lifetime-mismatch.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/inconsistent-lifetime-mismatch.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +fn foo(_: &[&str]) {} + +fn bad(a: &str, b: &str) { + foo(&[a, b]); +} + +fn good(a: &str, b: &str) { + foo(&[a, b]); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/inferred-suffix-in-pattern-range.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/inferred-suffix-in-pattern-range.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/inferred-suffix-in-pattern-range.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/inferred-suffix-in-pattern-range.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + let x = 2; + let x_message = match x { + 0 ..= 1 => { "not many".to_string() } + _ => { "lots".to_string() } + }; + assert_eq!(x_message, "lots".to_string()); + + let y = 2; + let y_message = match y { + 0 ..= 1 => { "not many".to_string() } + _ => { "lots".to_string() } + }; + assert_eq!(y_message, "lots".to_string()); + + let z = 1u64; + let z_message = match z { + 0 ..= 1 => { "not many".to_string() } + _ => { "lots".to_string() } + }; + assert_eq!(z_message, "not many".to_string()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/irrefutable-slice-patterns.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/irrefutable-slice-patterns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/irrefutable-slice-patterns.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/irrefutable-slice-patterns.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// #47096 + +#![feature(slice_patterns)] + +fn foo(s: &[i32]) -> &[i32] { + let &[ref xs..] = s; + xs +} + +fn main() { + let x = [1, 2, 3]; + let y = foo(&x); + assert_eq!(x, y); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/let-assignability.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/let-assignability.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/let-assignability.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/let-assignability.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +fn f() { + let a: Box<_> = box 1; + let b: &isize = &*a; + println!("{}", b); +} + +pub fn main() { + f(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/let-destruct-ref.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/let-destruct-ref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/let-destruct-ref.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/let-destruct-ref.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + let x = 3_usize; + let ref y = x; + assert_eq!(x, *y); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/let-var-hygiene.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/let-var-hygiene.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/let-var-hygiene.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/let-var-hygiene.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// shouldn't affect evaluation of $ex: + +macro_rules! bad_macro { + ($ex:expr) => ({let _x = 9; $ex}) +} + +pub fn main() { + let _x = 8; + assert_eq!(bad_macro!(_x),8) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-arm-statics.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-arm-statics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-arm-statics.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-arm-statics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,176 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// compile-flags: -g + +#[derive(PartialEq, Eq)] +struct NewBool(bool); + +#[derive(PartialEq, Eq)] +enum Direction { + North, + East, + South, + West +} + +#[derive(PartialEq, Eq)] +struct Foo { + bar: Option, + baz: NewBool +} + +#[derive(PartialEq, Eq)] +enum EnumWithStructVariants { + Variant1(bool), + Variant2 { + dir: Direction + } +} + +const TRUE_TRUE: (bool, bool) = (true, true); +const NONE: Option = None; +const EAST: Direction = Direction::East; +const NEW_FALSE: NewBool = NewBool(false); +const STATIC_FOO: Foo = Foo { bar: Some(Direction::South), baz: NEW_FALSE }; +const VARIANT2_NORTH: EnumWithStructVariants = EnumWithStructVariants::Variant2 { + dir: Direction::North }; + +pub mod glfw { + #[derive(Copy, Clone, PartialEq, Eq)] + pub struct InputState(usize); + + pub const RELEASE : InputState = InputState(0); + pub const PRESS : InputState = InputState(1); + pub const REPEAT : InputState = InputState(2); +} + +fn issue_6533() { + use glfw; + + fn action_to_str(state: glfw::InputState) -> &'static str { + use glfw::{RELEASE, PRESS, REPEAT}; + match state { + RELEASE => { "Released" } + PRESS => { "Pressed" } + REPEAT => { "Repeated" } + _ => { "Unknown" } + } + } + + assert_eq!(action_to_str(glfw::RELEASE), "Released"); + assert_eq!(action_to_str(glfw::PRESS), "Pressed"); + assert_eq!(action_to_str(glfw::REPEAT), "Repeated"); +} + +fn issue_13626() { + const VAL: [u8; 1] = [0]; + match [1] { + VAL => unreachable!(), + _ => () + } +} + +fn issue_14576() { + type Foo = (i32, i32); + const ON: Foo = (1, 1); + const OFF: Foo = (0, 0); + + match (1, 1) { + OFF => unreachable!(), + ON => (), + _ => unreachable!() + } + + #[derive(PartialEq, Eq)] + enum C { D = 3, E = 4 } + const F : C = C::D; + + assert_eq!(match C::D { F => 1, _ => 2, }, 1); + + // test gaps + #[derive(PartialEq, Eq)] + enum G { H = 3, I = 5 } + const K : G = G::I; + + assert_eq!(match G::I { K => 1, _ => 2, }, 1); +} + +fn issue_13731() { + #[derive(PartialEq, Eq)] + enum A { AA(()) } + const B: A = A::AA(()); + + match A::AA(()) { + B => () + } +} + +fn issue_15393() { + #![allow(dead_code)] + #[derive(PartialEq, Eq)] + struct Flags { + bits: usize + } + + const FOO: Flags = Flags { bits: 0x01 }; + const BAR: Flags = Flags { bits: 0x02 }; + match (Flags { bits: 0x02 }) { + FOO => unreachable!(), + BAR => (), + _ => unreachable!() + } +} + +fn main() { + assert_eq!(match (true, false) { + TRUE_TRUE => 1, + (false, false) => 2, + (false, true) => 3, + (true, false) => 4 + }, 4); + + assert_eq!(match Some(Some(Direction::North)) { + Some(NONE) => 1, + Some(Some(Direction::North)) => 2, + Some(Some(EAST)) => 3, + Some(Some(Direction::South)) => 4, + Some(Some(Direction::West)) => 5, + None => 6 + }, 2); + + assert_eq!(match (Foo { bar: Some(Direction::West), baz: NewBool(true) }) { + Foo { bar: None, baz: NewBool(true) } => 1, + Foo { bar: NONE, baz: NEW_FALSE } => 2, + STATIC_FOO => 3, + Foo { bar: _, baz: NEW_FALSE } => 4, + Foo { bar: Some(Direction::West), baz: NewBool(true) } => 5, + Foo { bar: Some(Direction::South), baz: NewBool(true) } => 6, + Foo { bar: Some(EAST), .. } => 7, + Foo { bar: Some(Direction::North), baz: NewBool(true) } => 8 + }, 5); + + assert_eq!(match (EnumWithStructVariants::Variant2 { dir: Direction::North }) { + EnumWithStructVariants::Variant1(true) => 1, + EnumWithStructVariants::Variant1(false) => 2, + EnumWithStructVariants::Variant2 { dir: Direction::West } => 3, + VARIANT2_NORTH => 4, + EnumWithStructVariants::Variant2 { dir: Direction::South } => 5, + EnumWithStructVariants::Variant2 { dir: Direction::East } => 6 + }, 4); + + issue_6533(); + issue_13626(); + issue_13731(); + issue_14576(); + issue_15393(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-beginning-vert.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-beginning-vert.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-beginning-vert.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-beginning-vert.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +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!"), + | _ => {}, + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-borrowed_str.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-borrowed_str.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-borrowed_str.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-borrowed_str.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,58 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn f1(ref_string: &str) -> String { + match ref_string { + "a" => "found a".to_string(), + "b" => "found b".to_string(), + _ => "not found".to_string() + } +} + +fn f2(ref_string: &str) -> String { + match ref_string { + "a" => "found a".to_string(), + "b" => "found b".to_string(), + s => format!("not found ({})", s) + } +} + +fn g1(ref_1: &str, ref_2: &str) -> String { + match (ref_1, ref_2) { + ("a", "b") => "found a,b".to_string(), + ("b", "c") => "found b,c".to_string(), + _ => "not found".to_string() + } +} + +fn g2(ref_1: &str, ref_2: &str) -> String { + match (ref_1, ref_2) { + ("a", "b") => "found a,b".to_string(), + ("b", "c") => "found b,c".to_string(), + (s1, s2) => format!("not found ({}, {})", s1, s2) + } +} + +pub fn main() { + assert_eq!(f1("b"), "found b".to_string()); + assert_eq!(f1("c"), "not found".to_string()); + assert_eq!(f1("d"), "not found".to_string()); + assert_eq!(f2("b"), "found b".to_string()); + assert_eq!(f2("c"), "not found (c)".to_string()); + assert_eq!(f2("d"), "not found (d)".to_string()); + assert_eq!(g1("b", "c"), "found b,c".to_string()); + assert_eq!(g1("c", "d"), "not found".to_string()); + assert_eq!(g1("d", "e"), "not found".to_string()); + assert_eq!(g2("b", "c"), "found b,c".to_string()); + assert_eq!(g2("c", "d"), "not found (c, d)".to_string()); + assert_eq!(g2("d", "e"), "not found (d, e)".to_string()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-bot-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-bot-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-bot-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-bot-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unreachable_code)] +// n.b. This was only ever failing with optimization disabled. + +fn a() -> isize { match return 1 { 2 => 3, _ => panic!() } } +pub fn main() { a(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-bot.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-bot.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-bot.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-bot.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + let i: isize = + match Some::(3) { None:: => { panic!() } Some::(_) => { 5 } }; + println!("{}", i); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-byte-array-patterns.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-byte-array-patterns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-byte-array-patterns.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-byte-array-patterns.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,55 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(slice_patterns)] + +fn main() { + let buf = &[0u8; 4]; + match buf { + &[0, 1, 0, 0] => unimplemented!(), + b"true" => unimplemented!(), + _ => {} + } + + match buf { + b"true" => unimplemented!(), + &[0, 1, 0, 0] => unimplemented!(), + _ => {} + } + + match buf { + b"true" => unimplemented!(), + &[0, x, 0, 0] => assert_eq!(x, 0), + _ => unimplemented!(), + } + + let buf: &[u8] = buf; + + match buf { + &[0, 1, 0, 0] => unimplemented!(), + &[_] => unimplemented!(), + &[_, _, _, _, _, ..] => unimplemented!(), + b"true" => unimplemented!(), + _ => {} + } + + match buf { + b"true" => unimplemented!(), + &[0, 1, 0, 0] => unimplemented!(), + _ => {} + } + + match buf { + b"true" => unimplemented!(), + &[0, x, 0, 0] => assert_eq!(x, 0), + _ => unimplemented!(), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-enum-struct-0.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-enum-struct-0.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-enum-struct-0.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-enum-struct-0.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// regression test for issue #5625 + + +enum E { + Foo{f : isize}, + Bar +} + +pub fn main() { + let e = E::Bar; + match e { + E::Foo{f: _f} => panic!(), + _ => (), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-enum-struct-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-enum-struct-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-enum-struct-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-enum-struct-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +enum E { + Foo{f : isize}, + Bar +} + +pub fn main() { + let e = E::Foo{f: 1}; + match e { + E::Foo{..} => (), + _ => panic!(), + } + match e { + E::Foo{f: _f} => (), + _ => panic!(), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-implicit-copy-unique.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-implicit-copy-unique.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-implicit-copy-unique.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-implicit-copy-unique.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_shorthand_field_patterns)] +#![feature(box_syntax)] + +struct Pair { a: Box, b: Box } + +pub fn main() { + let mut x: Box<_> = box Pair {a: box 10, b: box 20}; + let x_internal = &mut *x; + match *x_internal { + Pair {a: ref mut a, b: ref mut _b} => { + assert_eq!(**a, 10); + *a = box 30; + assert_eq!(**a, 30); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-in-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-in-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-in-macro.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-in-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +enum Foo { + B { b1: isize, bb1: isize}, +} + +macro_rules! match_inside_expansion { + () => ( + match (Foo::B { b1:29 , bb1: 100}) { + Foo::B { b1:b2 , bb1:bb2 } => b2+bb2 + } + ) +} + +pub fn main() { + assert_eq!(match_inside_expansion!(),129); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-join.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-join.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-join.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-join.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +fn foo(y: Option) { + let mut x: isize; + let mut rs: Vec = Vec::new(); + /* tests that x doesn't get put in the precondition for the + entire if expression */ + + if true { + } else { + match y { + None:: => x = 17, + _ => x = 42 + } + rs.push(x); + } + return; +} + +pub fn main() { println!("hello"); foo::(Some::(5)); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-larger-const.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-larger-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-larger-const.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-larger-const.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(Eq, PartialEq)] +pub struct Data([u8; 4]); + +const DATA: Data = Data([1, 2, 3, 4]); + +fn main() { + match DATA { + DATA => (), + _ => (), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-naked-record-expr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-naked-record-expr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-naked-record-expr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-naked-record-expr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +struct X { x: isize } + +pub fn main() { + let _x = match 0 { + _ => X { + x: 0 + }.x + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-naked-record.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-naked-record.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-naked-record.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-naked-record.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +struct X { x: isize } + +pub fn main() { + let _x = match 0 { + _ => X { + x: 0 + } + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-path.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-path.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-path.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-path.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + + +// pretty-expanded FIXME #23616 + +mod m1 { + pub enum foo { foo1, foo2, } +} + +fn bar(x: m1::foo) { match x { m1::foo::foo1 => { } m1::foo::foo2 => { } } } + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-pattern-bindings.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-pattern-bindings.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-pattern-bindings.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-pattern-bindings.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn main() { + let value = Some(1); + assert_eq!(match value { + ref a @ Some(_) => a, + ref b @ None => b + }, &Some(1)); + assert_eq!(match value { + ref c @ Some(_) => c, + ref b @ None => b + }, &Some(1)); + assert_eq!(match "foobarbaz" { + b @ _ => b + }, "foobarbaz"); + let a @ _ = "foobarbaz"; + assert_eq!(a, "foobarbaz"); + let value = Some(true); + let ref a @ _ = value; + assert_eq!(a, &Some(true)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-pattern-lit.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-pattern-lit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-pattern-lit.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-pattern-lit.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +fn altlit(f: isize) -> isize { + match f { + 10 => { println!("case 10"); return 20; } + 11 => { println!("case 11"); return 22; } + _ => panic!("the impossible happened") + } +} + +pub fn main() { + assert_eq!(altlit(10), 20); + assert_eq!(altlit(11), 22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-pattern-no-type-params.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-pattern-no-type-params.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-pattern-no-type-params.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-pattern-no-type-params.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +enum maybe { nothing, just(T), } + +fn foo(x: maybe) { + match x { + maybe::nothing => { println!("A"); } + maybe::just(_a) => { println!("B"); } + } +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-pattern-simple.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-pattern-simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-pattern-simple.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-pattern-simple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + + +// pretty-expanded FIXME #23616 + +fn altsimple(f: isize) { match f { _x => () } } + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-phi.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-phi.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-phi.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-phi.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_assignments)] +// pretty-expanded FIXME #23616 +#![allow(non_camel_case_types)] +#![allow(unused_variables)] + +enum thing { a, b, c, } + +fn foo(it: F) where F: FnOnce(isize) { it(10); } + +pub fn main() { + let mut x = true; + match thing::a { + thing::a => { x = true; foo(|_i| { } ) } + thing::b => { x = false; } + thing::c => { x = false; } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-pipe-binding.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-pipe-binding.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-pipe-binding.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-pipe-binding.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,71 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags: -Z borrowck=compare + +fn test1() { + // from issue 6338 + match ((1, "a".to_string()), (2, "b".to_string())) { + ((1, a), (2, b)) | ((2, b), (1, a)) => { + assert_eq!(a, "a".to_string()); + assert_eq!(b, "b".to_string()); + }, + _ => panic!(), + } +} + +fn test2() { + match (1, 2, 3) { + (1, a, b) | (2, b, a) => { + assert_eq!(a, 2); + assert_eq!(b, 3); + }, + _ => panic!(), + } +} + +fn test3() { + match (1, 2, 3) { + (1, ref a, ref b) | (2, ref b, ref a) => { + assert_eq!(*a, 2); + assert_eq!(*b, 3); + }, + _ => panic!(), + } +} + +fn test4() { + match (1, 2, 3) { + (1, a, b) | (2, b, a) if a == 2 => { + assert_eq!(a, 2); + assert_eq!(b, 3); + }, + _ => panic!(), + } +} + +fn test5() { + match (1, 2, 3) { + (1, ref a, ref b) | (2, ref b, ref a) if *a == 2 => { + assert_eq!(*a, 2); + assert_eq!(*b, 3); + }, + _ => panic!(), + } +} + +pub fn main() { + test1(); + test2(); + test3(); + test4(); + test5(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-range-infer.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-range-infer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-range-infer.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-range-infer.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that type inference for range patterns works correctly (is bi-directional). + +pub fn main() { + match 1 { + 1 ..= 3 => {} + _ => panic!("should match range") + } + match 1 { + 1 ..= 3u16 => {} + _ => panic!("should match range with inferred start type") + } + match 1 { + 1u16 ..= 3 => {} + _ => panic!("should match range with inferred end type") + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-range.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-range.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-range.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-range.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,61 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(illegal_floating_point_literal_pattern)] // FIXME #41620 +#![feature(exclusive_range_pattern)] + +pub fn main() { + match 5_usize { + 1_usize..=5_usize => {} + _ => panic!("should match range"), + } + match 1_usize { + 1_usize..5_usize => {} + _ => panic!("should match range start"), + } + match 5_usize { + 6_usize..=7_usize => panic!("shouldn't match range"), + _ => {} + } + match 7_usize { + 6_usize..7_usize => panic!("shouldn't match range end"), + _ => {}, + } + match 5_usize { + 1_usize => panic!("should match non-first range"), + 2_usize..=6_usize => {} + _ => panic!("math is broken") + } + match 'c' { + 'a'..='z' => {} + _ => panic!("should support char ranges") + } + match -3 { + -7..=5 => {} + _ => panic!("should match signed range") + } + match 3.0f64 { + 1.0..=5.0 => {} + _ => panic!("should match float range") + } + match -1.5f64 { + -3.6..=3.6 => {} + _ => panic!("should match negative float range") + } + match 3.5 { + 0.0..3.5 => panic!("should not match the range end"), + _ => {}, + } + match 0.0 { + 0.0..3.5 => {}, + _ => panic!("should match the range start"), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-range-static.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-range-static.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-range-static.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-range-static.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 +#![allow(non_upper_case_globals)] + +const s: isize = 1; +const e: isize = 42; + +pub fn main() { + match 7 { + s..=e => (), + _ => (), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-reassign.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-reassign.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-reassign.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-reassign.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for #23698: The reassignment checker only cared +// about the last assignment in a match arm body + +// Use an extra function to make sure no extra assignments +// are introduced by macros in the match statement +fn check_eq(x: i32, y: i32) { + assert_eq!(x, y); +} + +#[allow(unused_assignments)] +fn main() { + let mut x = Box::new(1); + match x { + y => { + x = Box::new(2); + let _tmp = 1; // This assignment used to throw off the reassignment checker + check_eq(*y, 1); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-ref-binding-in-guard-3256.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-ref-binding-in-guard-3256.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-ref-binding-in-guard-3256.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-ref-binding-in-guard-3256.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::sync::Mutex; + +pub fn main() { + let x = Some(Mutex::new(true)); + match x { + Some(ref z) if *z.lock().unwrap() => { + assert!(*z.lock().unwrap()); + }, + _ => panic!() + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-ref-binding-mut-option.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-ref-binding-mut-option.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-ref-binding-mut-option.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-ref-binding-mut-option.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + let mut v = Some(22); + match v { + None => {} + Some(ref mut p) => { *p += 1; } + } + assert_eq!(v, Some(23)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-ref-binding-mut.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-ref-binding-mut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-ref-binding-mut.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-ref-binding-mut.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_shorthand_field_patterns)] + +struct Rec { + f: isize +} + +fn destructure(x: &mut Rec) { + match *x { + Rec {f: ref mut f} => *f += 1 + } +} + +pub fn main() { + let mut v = Rec {f: 22}; + destructure(&mut v); + assert_eq!(v.f, 23); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-ref-binding.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-ref-binding.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-ref-binding.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-ref-binding.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn destructure(x: Option) -> isize { + match x { + None => 0, + Some(ref v) => *v + } +} + +pub fn main() { + assert_eq!(destructure(Some(22)), 22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-ref-unsized.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-ref-unsized.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-ref-unsized.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-ref-unsized.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Binding unsized expressions to ref patterns + +pub fn main() { + let ref a = *"abcdef"; + assert_eq!(a, "abcdef"); + + match *"12345" { + ref b => { assert_eq!(b, "12345") } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-static-const-rename.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-static-const-rename.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-static-const-rename.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-static-const-rename.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,74 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Issue #7526: lowercase static constants in patterns look like bindings + +// This is similar to compile-fail/match-static-const-lc, except it +// shows the expected usual workaround (choosing a different name for +// the static definition) and also demonstrates that one can work +// around this problem locally by renaming the constant in the `use` +// form to an uppercase identifier that placates the lint. + + +#![deny(non_upper_case_globals)] + +pub const A : isize = 97; + +fn f() { + let r = match (0,0) { + (0, A) => 0, + (x, y) => 1 + x + y, + }; + assert_eq!(r, 1); + let r = match (0,97) { + (0, A) => 0, + (x, y) => 1 + x + y, + }; + assert_eq!(r, 0); +} + +mod m { + #[allow(non_upper_case_globals)] + pub const aha : isize = 7; +} + +fn g() { + use self::m::aha as AHA; + let r = match (0,0) { + (0, AHA) => 0, + (x, y) => 1 + x + y, + }; + assert_eq!(r, 1); + let r = match (0,7) { + (0, AHA) => 0, + (x, y) => 1 + x + y, + }; + assert_eq!(r, 0); +} + +fn h() { + let r = match (0,0) { + (0, self::m::aha) => 0, + (x, y) => 1 + x + y, + }; + assert_eq!(r, 1); + let r = match (0,7) { + (0, self::m::aha) => 0, + (x, y) => 1 + x + y, + }; + assert_eq!(r, 0); +} + +pub fn main () { + f(); + g(); + h(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-str.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-str.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-str.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-str.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Issue #53 +#![allow(non_camel_case_types)] + + +pub fn main() { + match "test" { "not-test" => panic!(), "test" => (), _ => panic!() } + + enum t { tag1(String), tag2, } + + + match t::tag1("test".to_string()) { + t::tag2 => panic!(), + t::tag1(ref s) if "test" != &**s => panic!(), + t::tag1(ref s) if "test" == &**s => (), + _ => panic!() + } + + let x = match "a" { "a" => 1, "b" => 2, _ => panic!() }; + assert_eq!(x, 1); + + match "a" { "a" => { } "b" => { }, _ => panic!() } + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-struct-0.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-struct-0.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-struct-0.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-struct-0.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +struct Foo{ + f : isize, +} + +pub fn main() { + let f = Foo{f: 1}; + match f { + Foo{f: 0} => panic!(), + Foo{..} => (), + } + match f { + Foo{f: 0} => panic!(), + Foo{f: _f} => (), + } + match f { + Foo{f: 0} => panic!(), + _ => (), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-tag.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-tag.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-tag.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-tag.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +#![allow(non_camel_case_types)] + + + +enum color { + rgb(isize, isize, isize), + rgba(isize, isize, isize, isize), + hsl(isize, isize, isize), +} + +fn process(c: color) -> isize { + let mut x: isize; + match c { + color::rgb(r, _, _) => { x = r; } + color::rgba(_, _, _, a) => { x = a; } + color::hsl(_, s, _) => { x = s; } + } + return x; +} + +pub fn main() { + let gray: color = color::rgb(127, 127, 127); + let clear: color = color::rgba(50, 150, 250, 0); + let red: color = color::hsl(0, 255, 255); + assert_eq!(process(gray), 127); + assert_eq!(process(clear), 0); + assert_eq!(process(red), 255); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-unique-bind.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-unique-bind.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-unique-bind.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-unique-bind.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_patterns)] +#![feature(box_syntax)] + +pub fn main() { + match box 100 { + box x => { + println!("{}", x); + assert_eq!(x, 100); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-unsized.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-unsized.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-unsized.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-unsized.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + let data: &'static str = "Hello, World!"; + match data { + &ref xs => { + assert_eq!(data, xs); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-value-binding-in-guard-3291.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-value-binding-in-guard-3291.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-value-binding-in-guard-3291.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-value-binding-in-guard-3291.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + +fn foo(x: Option>, b: bool) -> isize { + match x { + None => { 1 } + Some(ref x) if b => { *x.clone() } + Some(_) => { 0 } + } +} + +pub fn main() { + foo(Some(box 22), true); + foo(Some(box 22), false); + foo(None, true); + foo(None, false); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-var-hygiene.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-var-hygiene.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-var-hygiene.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-var-hygiene.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// shouldn't affect evaluation of $ex. +macro_rules! bad_macro { ($ex:expr) => ( + {match 9 {_x => $ex}} +)} + +fn main() { + match 8 { + _x => assert_eq!(bad_macro!(_x),8) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-vec-alternatives.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-vec-alternatives.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-vec-alternatives.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-vec-alternatives.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,91 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(slice_patterns)] + +fn match_vecs<'a, T>(l1: &'a [T], l2: &'a [T]) -> &'static str { + match (l1, l2) { + (&[], &[]) => "both empty", + (&[], &[..]) | (&[..], &[]) => "one empty", + (&[..], &[..]) => "both non-empty" + } +} + +fn match_vecs_cons<'a, T>(l1: &'a [T], l2: &'a [T]) -> &'static str { + match (l1, l2) { + (&[], &[]) => "both empty", + (&[], &[_, ..]) | (&[_, ..], &[]) => "one empty", + (&[_, ..], &[_, ..]) => "both non-empty" + } +} + +fn match_vecs_snoc<'a, T>(l1: &'a [T], l2: &'a [T]) -> &'static str { + match (l1, l2) { + (&[], &[]) => "both empty", + (&[], &[.., _]) | (&[.., _], &[]) => "one empty", + (&[.., _], &[.., _]) => "both non-empty" + } +} + +fn match_nested_vecs_cons<'a, T>(l1: Option<&'a [T]>, l2: Result<&'a [T], ()>) -> &'static str { + match (l1, l2) { + (Some(&[]), Ok(&[])) => "Some(empty), Ok(empty)", + (Some(&[_, ..]), Ok(_)) | (Some(&[_, ..]), Err(())) => "Some(non-empty), any", + (None, Ok(&[])) | (None, Err(())) | (None, Ok(&[_])) => "None, Ok(less than one element)", + (None, Ok(&[_, _, ..])) => "None, Ok(at least two elements)", + _ => "other" + } +} + +fn match_nested_vecs_snoc<'a, T>(l1: Option<&'a [T]>, l2: Result<&'a [T], ()>) -> &'static str { + match (l1, l2) { + (Some(&[]), Ok(&[])) => "Some(empty), Ok(empty)", + (Some(&[.., _]), Ok(_)) | (Some(&[.., _]), Err(())) => "Some(non-empty), any", + (None, Ok(&[])) | (None, Err(())) | (None, Ok(&[_])) => "None, Ok(less than one element)", + (None, Ok(&[.., _, _])) => "None, Ok(at least two elements)", + _ => "other" + } +} + +fn main() { + assert_eq!(match_vecs(&[1, 2], &[2, 3]), "both non-empty"); + assert_eq!(match_vecs(&[], &[1, 2, 3, 4]), "one empty"); + assert_eq!(match_vecs::(&[], &[]), "both empty"); + assert_eq!(match_vecs(&[1, 2, 3], &[]), "one empty"); + + assert_eq!(match_vecs_cons(&[1, 2], &[2, 3]), "both non-empty"); + assert_eq!(match_vecs_cons(&[], &[1, 2, 3, 4]), "one empty"); + assert_eq!(match_vecs_cons::(&[], &[]), "both empty"); + assert_eq!(match_vecs_cons(&[1, 2, 3], &[]), "one empty"); + + assert_eq!(match_vecs_snoc(&[1, 2], &[2, 3]), "both non-empty"); + assert_eq!(match_vecs_snoc(&[], &[1, 2, 3, 4]), "one empty"); + assert_eq!(match_vecs_snoc::(&[], &[]), "both empty"); + assert_eq!(match_vecs_snoc(&[1, 2, 3], &[]), "one empty"); + + assert_eq!(match_nested_vecs_cons(None, Ok::<&[_], ()>(&[4_usize, 2_usize])), + "None, Ok(at least two elements)"); + assert_eq!(match_nested_vecs_cons::(None, Err(())), "None, Ok(less than one element)"); + assert_eq!(match_nested_vecs_cons::(Some::<&[_]>(&[]), Ok::<&[_], ()>(&[])), + "Some(empty), Ok(empty)"); + assert_eq!(match_nested_vecs_cons(Some::<&[_]>(&[1]), Err(())), "Some(non-empty), any"); + assert_eq!(match_nested_vecs_cons(Some::<&[_]>(&[(42, ())]), Ok::<&[_], ()>(&[(1, ())])), + "Some(non-empty), any"); + + assert_eq!(match_nested_vecs_snoc(None, Ok::<&[_], ()>(&[4_usize, 2_usize])), + "None, Ok(at least two elements)"); + assert_eq!(match_nested_vecs_snoc::(None, Err(())), "None, Ok(less than one element)"); + assert_eq!(match_nested_vecs_snoc::(Some::<&[_]>(&[]), Ok::<&[_], ()>(&[])), + "Some(empty), Ok(empty)"); + assert_eq!(match_nested_vecs_snoc(Some::<&[_]>(&[1]), Err(())), "Some(non-empty), any"); + assert_eq!(match_nested_vecs_snoc(Some::<&[_]>(&[(42, ())]), Ok::<&[_], ()>(&[(1, ())])), + "Some(non-empty), any"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-vec-rvalue.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-vec-rvalue.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-vec-rvalue.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-vec-rvalue.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests that matching rvalues with drops does not crash. + + + +pub fn main() { + match vec![1, 2, 3] { + x => { + assert_eq!(x.len(), 3); + assert_eq!(x[0], 1); + assert_eq!(x[1], 2); + assert_eq!(x[2], 3); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-with-ret-arm.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-with-ret-arm.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/match-with-ret-arm.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/match-with-ret-arm.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn main() { + // sometimes we have had trouble finding + // the right type for f, as we unified + // bot and u32 here + let f = match "1234".parse::().ok() { + None => return (), + Some(num) => num as u32 + }; + assert_eq!(f, 1234); + println!("{}", f) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/multi-let.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/multi-let.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/multi-let.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/multi-let.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + let x = 10; + let y = x; + assert_eq!(y, 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/mut-in-ident-patterns.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/mut-in-ident-patterns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/mut-in-ident-patterns.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/mut-in-ident-patterns.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,86 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_assignments)] +#![allow(non_camel_case_types)] +#![allow(non_shorthand_field_patterns)] + +trait Foo { + fn foo(&self, mut x: isize) -> isize { + let val = x; + x = 37 * x; + val + x + } +} + +struct X; +impl Foo for X {} + +pub fn main() { + let (a, mut b) = (23, 4); + assert_eq!(a, 23); + assert_eq!(b, 4); + b = a + b; + assert_eq!(b, 27); + + + assert_eq!(X.foo(2), 76); + + enum Bar { + Foo(isize), + Baz(f32, u8) + } + + let (x, mut y) = (32, Bar::Foo(21)); + + match x { + mut z @ 32 => { + assert_eq!(z, 32); + z = 34; + assert_eq!(z, 34); + } + _ => {} + } + + check_bar(&y); + y = Bar::Baz(10.0, 3); + check_bar(&y); + + fn check_bar(y: &Bar) { + match y { + &Bar::Foo(a) => { + assert_eq!(a, 21); + } + &Bar::Baz(a, b) => { + assert_eq!(a, 10.0); + assert_eq!(b, 3); + } + } + } + + fn foo1((x, mut y): (f64, isize), mut z: isize) -> isize { + y = 2 * 6; + z = y + (x as isize); + y - z + } + + struct A { + x: isize + } + let A { x: mut x } = A { x: 10 }; + assert_eq!(x, 10); + x = 30; + assert_eq!(x, 30); + + (|A { x: mut t }: A| { t = t+1; t })(A { x: 34 }); + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/nested-exhaustive-match.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/nested-exhaustive-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/nested-exhaustive-match.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/nested-exhaustive-match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +struct Foo { foo: bool, bar: Option, baz: isize } + +pub fn main() { + match (Foo{foo: true, bar: Some(10), baz: 20}) { + Foo{foo: true, bar: Some(_), ..} => {} + Foo{foo: false, bar: None, ..} => {} + Foo{foo: true, bar: None, ..} => {} + Foo{foo: false, bar: Some(_), ..} => {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/nested-matchs.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/nested-matchs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/nested-matchs.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/nested-matchs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] // under NLL we get warning about `bar` below +fn baz() -> ! { panic!(); } + +fn foo() { + match Some::(5) { + Some::(_x) => { + let mut bar; + match None:: { None:: => { bar = 5; } _ => { baz(); } } + println!("{}", bar); + } + None:: => { println!("hello"); } + } +} + +pub fn main() { foo(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/nested-pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/nested-pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/nested-pattern.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/nested-pattern.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// a bug was causing this to complain about leaked memory on exit + +enum t { foo(isize, usize), bar(isize, Option), } + +fn nested(o: t) { + match o { + t::bar(_i, Some::(_)) => { println!("wrong pattern matched"); panic!(); } + _ => { println!("succeeded"); } + } +} + +pub fn main() { nested(t::bar(1, None::)); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/nil-pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/nil-pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/nil-pattern.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/nil-pattern.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +pub fn main() { let x = (); match x { () => { } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/nullary-or-pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/nullary-or-pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/nullary-or-pattern.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/nullary-or-pattern.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +enum blah { a, b, } + +fn or_alt(q: blah) -> isize { + match q { blah::a | blah::b => { 42 } } +} + +pub fn main() { + assert_eq!(or_alt(blah::a), 42); + assert_eq!(or_alt(blah::b), 42); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/optional_comma_in_match_arm.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/optional_comma_in_match_arm.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/optional_comma_in_match_arm.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/optional_comma_in_match_arm.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,50 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_unsafe)] +// ignore-pretty issue #37199 +#![allow(while_true)] + +fn main() { + let x = 1; + + match x { + 1 => loop { break; }, + 2 => while true { break; }, + 3 => if true { () }, + 4 => if true { () } else { () }, + 5 => match () { () => () }, + 6 => { () }, + 7 => unsafe { () }, + _ => (), + } + + match x { + 1 => loop { break; } + 2 => while true { break; } + 3 => if true { () } + 4 => if true { () } else { () } + 5 => match () { () => () } + 6 => { () } + 7 => unsafe { () } + _ => () + } + + let r: &i32 = &x; + + match r { + // Absence of comma should not cause confusion between a pattern + // and a bitwise and. + &1 => if true { () } else { () } + &2 => (), + _ =>() + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/order-drop-with-match.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/order-drop-with-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/order-drop-with-match.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/order-drop-with-match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,67 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// Test to make sure the destructors run in the right order. +// Each destructor sets it's tag in the corresponding entry +// in ORDER matching up to when it ran. +// Correct order is: matched, inner, outer + + +static mut ORDER: [usize; 3] = [0, 0, 0]; +static mut INDEX: usize = 0; + +struct A; +impl Drop for A { + fn drop(&mut self) { + unsafe { + ORDER[INDEX] = 1; + INDEX = INDEX + 1; + } + } +} + +struct B; +impl Drop for B { + fn drop(&mut self) { + unsafe { + ORDER[INDEX] = 2; + INDEX = INDEX + 1; + } + } +} + +struct C; +impl Drop for C { + fn drop(&mut self) { + unsafe { + ORDER[INDEX] = 3; + INDEX = INDEX + 1; + } + } +} + +fn main() { + { + let matched = A; + let _outer = C; + { + match matched { + _s => {} + } + let _inner = B; + } + } + unsafe { + let expected: &[_] = &[1, 2, 3]; + assert_eq!(expected, ORDER); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/or-pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/or-pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/or-pattern.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/or-pattern.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +enum blah { a(isize, isize, usize), b(isize, isize), c, } + +fn or_alt(q: blah) -> isize { + match q { blah::a(x, y, _) | blah::b(x, y) => { return x + y; } blah::c => { return 0; } } +} + +pub fn main() { + assert_eq!(or_alt(blah::c), 0); + assert_eq!(or_alt(blah::a(10, 100, 0)), 110); + assert_eq!(or_alt(blah::b(20, 200)), 220); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/pat-ranges.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/pat-ranges.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/pat-ranges.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/pat-ranges.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Parsing of range patterns + +const NUM1: i32 = 10; + +mod m { + pub const NUM2: i32 = 16; +} + +fn main() { + if let NUM1 ... m::NUM2 = 10 {} else { panic!() } + if let ::NUM1 ... ::m::NUM2 = 11 {} else { panic!() } + if let -13 ... -10 = 12 { panic!() } else {} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/pattern-bound-var-in-for-each.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/pattern-bound-var-in-for-each.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/pattern-bound-var-in-for-each.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/pattern-bound-var-in-for-each.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests that codegen_path checks whether a +// pattern-bound var is an upvar (when codegenning +// the for-each body) + + +fn foo(src: usize) { + + match Some(src) { + Some(src_id) => { + for _i in 0_usize..10_usize { + let yyy = src_id; + assert_eq!(yyy, 0_usize); + } + } + _ => { } + } +} + +pub fn main() { foo(0_usize); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/pattern-in-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/pattern-in-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/pattern-in-closure.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/pattern-in-closure.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_shorthand_field_patterns)] + +struct Foo { + x: isize, + y: isize +} + +pub fn main() { + let f = |(x, _): (isize, isize)| println!("{}", x + 1); + let g = |Foo { x: x, y: _y }: Foo| println!("{}", x + 1); + f((2, 3)); + g(Foo { x: 1, y: 2 }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,103 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn tuple() { + let x = (1, 2, 3); + match x { + (a, b, ..) => { + assert_eq!(a, 1); + assert_eq!(b, 2); + } + } + match x { + (.., b, c) => { + assert_eq!(b, 2); + assert_eq!(c, 3); + } + } + match x { + (a, .., c) => { + assert_eq!(a, 1); + assert_eq!(c, 3); + } + } + match x { + (a, b, c) => { + assert_eq!(a, 1); + assert_eq!(b, 2); + assert_eq!(c, 3); + } + } + match x { + (a, b, c, ..) => { + assert_eq!(a, 1); + assert_eq!(b, 2); + assert_eq!(c, 3); + } + } + match x { + (.., a, b, c) => { + assert_eq!(a, 1); + assert_eq!(b, 2); + assert_eq!(c, 3); + } + } +} + +fn tuple_struct() { + struct S(u8, u8, u8); + + let x = S(1, 2, 3); + match x { + S(a, b, ..) => { + assert_eq!(a, 1); + assert_eq!(b, 2); + } + } + match x { + S(.., b, c) => { + assert_eq!(b, 2); + assert_eq!(c, 3); + } + } + match x { + S(a, .., c) => { + assert_eq!(a, 1); + assert_eq!(c, 3); + } + } + match x { + S(a, b, c) => { + assert_eq!(a, 1); + assert_eq!(b, 2); + assert_eq!(c, 3); + } + } + match x { + S(a, b, c, ..) => { + assert_eq!(a, 1); + assert_eq!(b, 2); + assert_eq!(c, 3); + } + } + match x { + S(.., a, b, c) => { + assert_eq!(a, 1); + assert_eq!(b, 2); + assert_eq!(c, 3); + } + } +} + +fn main() { + tuple(); + tuple_struct(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn tuple() { + let x = (1,); + match x { + (2, ..) => panic!(), + (..) => () + } +} + +fn tuple_struct() { + struct S(u8); + + let x = S(1); + match x { + S(2, ..) => panic!(), + S(..) => () + } +} + +fn main() { + tuple(); + tuple_struct(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-3.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn tuple() { + let x = (1, 2, 3); + let branch = match x { + (1, 1, ..) => 0, + (1, 2, 3, ..) => 1, + (1, 2, ..) => 2, + _ => 3 + }; + assert_eq!(branch, 1); +} + +fn tuple_struct() { + struct S(u8, u8, u8); + + let x = S(1, 2, 3); + let branch = match x { + S(1, 1, ..) => 0, + S(1, 2, 3, ..) => 1, + S(1, 2, ..) => 2, + _ => 3 + }; + assert_eq!(branch, 1); +} + +fn main() { + tuple(); + tuple_struct(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-4.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-4.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-4.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,67 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn tuple() { + let x = (1, 2, 3); + match x { + (1, 2, 4) => unreachable!(), + (0, 2, 3, ..) => unreachable!(), + (0, .., 3) => unreachable!(), + (0, ..) => unreachable!(), + (1, 2, 3) => (), + (_, _, _) => unreachable!(), + } + match x { + (..) => (), + } + match x { + (_, _, _, ..) => (), + } + match x { + (a, b, c) => { + assert_eq!(1, a); + assert_eq!(2, b); + assert_eq!(3, c); + } + } +} + +fn tuple_struct() { + struct S(u8, u8, u8); + + let x = S(1, 2, 3); + match x { + S(1, 2, 4) => unreachable!(), + S(0, 2, 3, ..) => unreachable!(), + S(0, .., 3) => unreachable!(), + S(0, ..) => unreachable!(), + S(1, 2, 3) => (), + S(_, _, _) => unreachable!(), + } + match x { + S(..) => (), + } + match x { + S(_, _, _, ..) => (), + } + match x { + S(a, b, c) => { + assert_eq!(1, a); + assert_eq!(2, b); + assert_eq!(3, c); + } + } +} + +fn main() { + tuple(); + tuple_struct(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-5.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-5.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-5.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-5.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn tuple() { + struct S; + struct Z; + struct W; + let x = (S, Z, W); + match x { (S, ..) => {} } + match x { (.., W) => {} } + match x { (S, .., W) => {} } + match x { (.., Z, _) => {} } +} + +fn tuple_struct() { + struct SS(S, Z, W); + + struct S; + struct Z; + struct W; + let x = SS(S, Z, W); + match x { SS(S, ..) => {} } + match x { SS(.., W) => {} } + match x { SS(S, .., W) => {} } + match x { SS(.., Z, _) => {} } +} + +fn main() { + tuple(); + tuple_struct(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-6.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-6.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-6.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-6.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,55 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn tuple() { + let x = (1, 2, 3, 4, 5); + match x { + (a, .., b, c) => { + assert_eq!(a, 1); + assert_eq!(b, 4); + assert_eq!(c, 5); + } + } + match x { + (a, b, c, .., d) => { + assert_eq!(a, 1); + assert_eq!(b, 2); + assert_eq!(c, 3); + assert_eq!(d, 5); + } + } +} + +fn tuple_struct() { + struct S(u8, u8, u8, u8, u8); + + let x = S(1, 2, 3, 4, 5); + match x { + S(a, .., b, c) => { + assert_eq!(a, 1); + assert_eq!(b, 4); + assert_eq!(c, 5); + } + } + match x { + S(a, b, c, .., d) => { + assert_eq!(a, 1); + assert_eq!(b, 2); + assert_eq!(c, 3); + assert_eq!(d, 5); + } + } +} + +fn main() { + tuple(); + tuple_struct(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-7.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-7.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-7.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/pat-tuple-7.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn main() { + #[allow(unused_parens)] + match 0 { + (pat) => assert_eq!(pat, 0) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/range-inclusive-pattern-precedence.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/range-inclusive-pattern-precedence.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/range-inclusive-pattern-precedence.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/range-inclusive-pattern-precedence.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_patterns)] + +const VALUE: usize = 21; + +pub fn main() { + match &18 { + &(18..=18) => {} + _ => { unreachable!(); } + } + match &21 { + &(VALUE..=VALUE) => {} + _ => { unreachable!(); } + } + match Box::new(18) { + box (18..=18) => {} + _ => { unreachable!(); } + } + match Box::new(21) { + box (VALUE..=VALUE) => {} + _ => { unreachable!(); } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/simple-generic-match.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/simple-generic-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/simple-generic-match.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/simple-generic-match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +enum clam { a(T), } + +pub fn main() { let c = clam::a(2); match c { clam::a::(_) => { } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/use-uninit-match2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/use-uninit-match2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/use-uninit-match2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/use-uninit-match2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_mut)] +#![allow(non_camel_case_types)] + + +fn foo(o: myoption) -> isize { + let mut x: isize; + match o { + myoption::none:: => { panic!(); } + myoption::some::(_t) => { x = 5; } + } + return x; +} + +enum myoption { none, some(T), } + +pub fn main() { println!("{}", 5); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/use-uninit-match.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/use-uninit-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/use-uninit-match.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/use-uninit-match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + + +fn foo(o: myoption) -> isize { + let mut x: isize = 5; + match o { + myoption::none:: => { } + myoption::some::(_t) => { x += 1; } + } + return x; +} + +enum myoption { none, some(T), } + +pub fn main() { println!("{}", 5); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/zero_sized_subslice_match.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/zero_sized_subslice_match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binding/zero_sized_subslice_match.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binding/zero_sized_subslice_match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(slice_patterns)] + +fn main() { + let x = [(), ()]; + + // The subslice used to go out of bounds for zero-sized array items, check that this doesn't + // happen anymore + match x { + [_, ref y..] => assert_eq!(&x[1] as *const (), &y[0] as *const ()) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binops.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binops.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/binops.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/binops.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] // Binop corner cases fn test_nil() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/blind-item-local-shadow.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/blind-item-local-shadow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/blind-item-local-shadow.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/blind-item-local-shadow.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] +#![allow(unused_imports)] mod bar { pub fn foo() -> bool { true } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/block-arg-call-as.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/block-arg-call-as.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/block-arg-call-as.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/block-arg-call-as.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_snake_case)] fn asBlock(f: F) -> usize where F: FnOnce() -> usize { return f(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/block-expr-precedence.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/block-expr-precedence.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/block-expr-precedence.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/block-expr-precedence.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_must_use)] +#![allow(unused_parens)] // This test has some extra semis in it that the pretty-printer won't // reproduce so we don't want to automatically reformat it diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-assignment-to-static-mut.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-assignment-to-static-mut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-assignment-to-static-mut.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-assignment-to-static-mut.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Test taken from #45641 (https://github.com/rust-lang/rust/issues/45641) + +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +static mut Y: u32 = 0; + +unsafe fn should_ok() { + Y = 1; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-assign-to-subfield.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-assign-to-subfield.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-assign-to-subfield.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-assign-to-subfield.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +pub fn main() { + struct A { + a: isize, + w: B, + } + struct B { + a: isize + } + let mut p = A { + a: 1, + w: B {a: 1}, + }; + + // even though `x` is not declared as a mutable field, + // `p` as a whole is mutable, so it can be modified. + p.a = 2; + + // this is true for an interior field too + p.w.a = 2; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-binding-mutbl.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-binding-mutbl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-binding-mutbl.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-binding-mutbl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +struct F { f: Vec } + +fn impure(_v: &[isize]) { +} + +pub fn main() { + let mut x = F {f: vec![3]}; + + match x { + F {f: ref mut v} => { + impure(v); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-borrow-from-expr-block.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-borrow-from-expr-block.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-borrow-from-expr-block.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-borrow-from-expr-block.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +fn borrow(x: &isize, f: F) where F: FnOnce(&isize) { + f(x) +} + +fn test1(x: &Box) { + borrow(&*(*x).clone(), |p| { + let x_a = &**x as *const isize; + assert!((x_a as usize) != (p as *const isize as usize)); + assert_eq!(unsafe{*x_a}, *p); + }) +} + +pub fn main() { + test1(&box 22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-borrow-of-mut-base-ptr-safe.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-borrow-of-mut-base-ptr-safe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-borrow-of-mut-base-ptr-safe.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-borrow-of-mut-base-ptr-safe.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_mut)] +#![allow(unused_variables)] +// Test that freezing an `&mut` pointer while referent is +// frozen is legal. +// +// Example from src/librustc_borrowck/borrowck/README.md + +// pretty-expanded FIXME #23616 + +fn foo<'a>(mut t0: &'a mut isize, + mut t1: &'a mut isize) { + let p: &isize = &*t0; // Freezes `*t0` + let mut t2 = &t0; + let q: &isize = &**t2; // Freezes `*t0`, but that's ok... + let r: &isize = &*t0; // ...after all, could do same thing directly. +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-closures-two-imm.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-closures-two-imm.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-closures-two-imm.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-closures-two-imm.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,51 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests that two closures can simultaneously have immutable +// access to the variable, whether that immutable access be used +// for direct reads or for taking immutable ref. Also check +// that the main function can read the variable too while +// the closures are in scope. Issue #6801. + + +fn a() -> i32 { + let mut x = 3; + x += 1; + let c1 = || x * 4; + let c2 = || x * 5; + c1() * c2() * x +} + +fn get(x: &i32) -> i32 { + *x * 4 +} + +fn b() -> i32 { + let mut x = 3; + x += 1; + let c1 = || get(&x); + let c2 = || get(&x); + c1() * c2() * x +} + +fn c() -> i32 { + let mut x = 3; + x += 1; + let c1 = || x * 5; + let c2 = || get(&x); + c1() * c2() * x +} + +pub fn main() { + assert_eq!(a(), 1280); + assert_eq!(b(), 1024); + assert_eq!(c(), 1280); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-field-sensitivity.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-field-sensitivity.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-field-sensitivity.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-field-sensitivity.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,276 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +#![allow(unused_variables)] +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + +struct A { a: isize, b: Box } +struct B { a: Box, b: Box } + +fn move_after_copy() { + let x = A { a: 1, b: box 2 }; + drop(x.a); + drop(x.b); +} + +fn move_after_fu_copy() { + let x = A { a: 1, b: box 2 }; + let _y = A { b: box 3, .. x }; + drop(x.b); +} + +fn fu_move_after_copy() { + let x = A { a: 1, b: box 2 }; + drop(x.a); + let _y = A { a: 3, .. x }; +} + +fn fu_move_after_fu_copy() { + let x = A { a: 1, b: box 2 }; + let _y = A { b: box 3, .. x }; + let _z = A { a: 4, .. x }; +} + +fn copy_after_move() { + let x = A { a: 1, b: box 2 }; + drop(x.b); + drop(x.a); +} + +fn copy_after_fu_move() { + let x = A { a: 1, b: box 2 }; + let y = A { a: 3, .. x }; + drop(x.a); +} + +fn fu_copy_after_move() { + let x = A { a: 1, b: box 2 }; + drop(x.b); + let _y = A { b: box 3, .. x }; +} + +fn fu_copy_after_fu_move() { + let x = A { a: 1, b: box 2 }; + let _y = A { a: 3, .. x }; + let _z = A { b: box 3, .. x }; +} + +fn borrow_after_move() { + let x = A { a: 1, b: box 2 }; + drop(x.b); + let p = &x.a; + drop(*p); +} + +fn borrow_after_fu_move() { + let x = A { a: 1, b: box 2 }; + let _y = A { a: 3, .. x }; + let p = &x.a; + drop(*p); +} + +fn move_after_borrow() { + let x = A { a: 1, b: box 2 }; + let p = &x.a; + drop(x.b); + drop(*p); +} + +fn fu_move_after_borrow() { + let x = A { a: 1, b: box 2 }; + let p = &x.a; + let _y = A { a: 3, .. x }; + drop(*p); +} + +fn mut_borrow_after_mut_borrow() { + let mut x = A { a: 1, b: box 2 }; + let p = &mut x.a; + let q = &mut x.b; + drop(*p); + drop(**q); +} + +fn move_after_move() { + let x = B { a: box 1, b: box 2 }; + drop(x.a); + drop(x.b); +} + +fn move_after_fu_move() { + let x = B { a: box 1, b: box 2 }; + let y = B { a: box 3, .. x }; + drop(x.a); +} + +fn fu_move_after_move() { + let x = B { a: box 1, b: box 2 }; + drop(x.a); + let z = B { a: box 3, .. x }; + drop(z.b); +} + +fn fu_move_after_fu_move() { + let x = B { a: box 1, b: box 2 }; + let _y = B { b: box 3, .. x }; + let _z = B { a: box 4, .. x }; +} + +fn copy_after_assign_after_move() { + let mut x = A { a: 1, b: box 2 }; + drop(x.b); + x = A { a: 3, b: box 4 }; + drop(*x.b); +} + +fn copy_after_assign_after_fu_move() { + let mut x = A { a: 1, b: box 2 }; + let _y = A { a: 3, .. x }; + x = A { a: 3, b: box 4 }; + drop(*x.b); +} + +fn copy_after_field_assign_after_move() { + let mut x = A { a: 1, b: box 2 }; + drop(x.b); + x.b = box 3; + drop(*x.b); +} + +fn copy_after_field_assign_after_fu_move() { + let mut x = A { a: 1, b: box 2 }; + let _y = A { a: 3, .. x }; + x.b = box 3; + drop(*x.b); +} + +fn borrow_after_assign_after_move() { + let mut x = A { a: 1, b: box 2 }; + drop(x.b); + x = A { a: 3, b: box 4 }; + let p = &x.b; + drop(**p); +} + +fn borrow_after_assign_after_fu_move() { + let mut x = A { a: 1, b: box 2 }; + let _y = A { a: 3, .. x }; + x = A { a: 3, b: box 4 }; + let p = &x.b; + drop(**p); +} + +fn borrow_after_field_assign_after_move() { + let mut x = A { a: 1, b: box 2 }; + drop(x.b); + x.b = box 3; + let p = &x.b; + drop(**p); +} + +fn borrow_after_field_assign_after_fu_move() { + let mut x = A { a: 1, b: box 2 }; + let _y = A { a: 3, .. x }; + x.b = box 3; + let p = &x.b; + drop(**p); +} + +fn move_after_assign_after_move() { + let mut x = A { a: 1, b: box 2 }; + let _y = x.b; + x = A { a: 3, b: box 4 }; + drop(x.b); +} + +fn move_after_assign_after_fu_move() { + let mut x = A { a: 1, b: box 2 }; + let _y = A { a: 3, .. x }; + x = A { a: 3, b: box 4 }; + drop(x.b); +} + +fn move_after_field_assign_after_move() { + let mut x = A { a: 1, b: box 2 }; + drop(x.b); + x.b = box 3; + drop(x.b); +} + +fn move_after_field_assign_after_fu_move() { + let mut x = A { a: 1, b: box 2 }; + let _y = A { a: 3, .. x }; + x.b = box 3; + drop(x.b); +} + +fn copy_after_assign_after_uninit() { + let mut x: A; + x = A { a: 1, b: box 2 }; + drop(x.a); +} + +fn borrow_after_assign_after_uninit() { + let mut x: A; + x = A { a: 1, b: box 2 }; + let p = &x.a; + drop(*p); +} + +fn move_after_assign_after_uninit() { + let mut x: A; + x = A { a: 1, b: box 2 }; + drop(x.b); +} + +fn main() { + move_after_copy(); + move_after_fu_copy(); + fu_move_after_copy(); + fu_move_after_fu_copy(); + copy_after_move(); + copy_after_fu_move(); + fu_copy_after_move(); + fu_copy_after_fu_move(); + + borrow_after_move(); + borrow_after_fu_move(); + move_after_borrow(); + fu_move_after_borrow(); + mut_borrow_after_mut_borrow(); + + move_after_move(); + move_after_fu_move(); + fu_move_after_move(); + fu_move_after_fu_move(); + + copy_after_assign_after_move(); + copy_after_assign_after_fu_move(); + copy_after_field_assign_after_move(); + copy_after_field_assign_after_fu_move(); + + borrow_after_assign_after_move(); + borrow_after_assign_after_fu_move(); + borrow_after_field_assign_after_move(); + borrow_after_field_assign_after_fu_move(); + + move_after_assign_after_move(); + move_after_assign_after_fu_move(); + move_after_field_assign_after_move(); + move_after_field_assign_after_fu_move(); + + copy_after_assign_after_uninit(); + borrow_after_assign_after_uninit(); + move_after_assign_after_uninit(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-fixed-length-vecs.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-fixed-length-vecs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-fixed-length-vecs.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-fixed-length-vecs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + let x = [22]; + let y = &x[0]; + assert_eq!(*y, 22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-freeze-frozen-mut.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-freeze-frozen-mut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-freeze-frozen-mut.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-freeze-frozen-mut.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that a `&mut` inside of an `&` is freezable. + + +struct MutSlice<'a, T:'a> { + data: &'a mut [T] +} + +fn get<'a, T>(ms: &'a MutSlice<'a, T>, index: usize) -> &'a T { + &ms.data[index] +} + +pub fn main() { + let mut data = [1, 2, 3]; + { + let slice = MutSlice { data: &mut data }; + slice.data[0] += 4; + let index0 = get(&slice, 0); + let index1 = get(&slice, 1); + let index2 = get(&slice, 2); + assert_eq!(*index0, 5); + assert_eq!(*index1, 2); + assert_eq!(*index2, 3); + } + assert_eq!(data[0], 5); + assert_eq!(data[1], 2); + assert_eq!(data[2], 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-lend-args.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-lend-args.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-lend-args.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-lend-args.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +// pretty-expanded FIXME #23616 + +fn borrow(_v: &isize) {} + +fn borrow_from_arg_imm_ref(v: Box) { + borrow(&*v); +} + +fn borrow_from_arg_mut_ref(v: &mut Box) { + borrow(&**v); +} + +fn borrow_from_arg_copy(v: Box) { + borrow(&*v); +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-macro-interaction-issue-6304.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-macro-interaction-issue-6304.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-macro-interaction-issue-6304.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-macro-interaction-issue-6304.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,48 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(unconditional_recursion)] + +// Check that we do not ICE when compiling this +// macro, which reuses the expression `$id` + + +#![feature(box_patterns)] +#![feature(box_syntax)] + +struct Foo { + a: isize +} + +pub enum Bar { + Bar1, Bar2(isize, Box), +} + +impl Foo { + fn elaborate_stm(&mut self, s: Box) -> Box { + macro_rules! declare { + ($id:expr, $rest:expr) => ({ + self.check_id($id); + box Bar::Bar2($id, $rest) + }) + } + match s { + box Bar::Bar2(id, rest) => declare!(id, self.elaborate_stm(rest)), + _ => panic!() + } + } + + fn check_id(&mut self, s: isize) { panic!() } +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-move-by-capture-ok.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-move-by-capture-ok.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-move-by-capture-ok.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-move-by-capture-ok.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +pub fn main() { + let bar: Box<_> = box 3; + let h = || -> isize { *bar }; + assert_eq!(h(), 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-multiple-borrows-interior-boxes.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-multiple-borrows-interior-boxes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-multiple-borrows-interior-boxes.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-multiple-borrows-interior-boxes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// Test case from #39963. + +#![feature(nll)] + +#[derive(Clone)] +struct Foo(Option>, Option>); + +fn test(f: &mut Foo) { + match *f { + Foo(Some(ref mut left), Some(ref mut right)) => match **left { + Foo(Some(ref mut left), Some(ref mut right)) => panic!(), + _ => panic!(), + }, + _ => panic!(), + } +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-mut-uniq.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-mut-uniq.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-mut-uniq.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-mut-uniq.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +use std::mem::swap; + +#[derive(Debug)] +struct Ints {sum: Box, values: Vec } + +fn add_int(x: &mut Ints, v: isize) { + *x.sum += v; + let mut values = Vec::new(); + swap(&mut values, &mut x.values); + values.push(v); + swap(&mut values, &mut x.values); +} + +fn iter_ints(x: &Ints, mut f: F) -> bool where F: FnMut(&isize) -> bool { + let l = x.values.len(); + (0..l).all(|i| f(&x.values[i])) +} + +pub fn main() { + let mut ints: Box<_> = box Ints {sum: box 0, values: Vec::new()}; + add_int(&mut *ints, 22); + add_int(&mut *ints, 44); + + iter_ints(&*ints, |i| { + println!("isize = {:?}", *i); + true + }); + + println!("ints={:?}", ints); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-mut-vec-as-imm-slice.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-mut-vec-as-imm-slice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-mut-vec-as-imm-slice.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-mut-vec-as-imm-slice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +fn want_slice(v: &[isize]) -> isize { + let mut sum = 0; + for i in v { sum += *i; } + sum +} + +fn has_mut_vec(v: Vec ) -> isize { + want_slice(&v) +} + +pub fn main() { + assert_eq!(has_mut_vec(vec![1, 2, 3]), 6); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-pat-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-pat-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-pat-enum.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-pat-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,49 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// ignore-pretty issue #37199 + +fn match_ref(v: Option) -> isize { + match v { + Some(ref i) => { + *i + } + None => {0} + } +} + +fn match_ref_unused(v: Option) { + match v { + Some(_) => {} + None => {} + } +} + +fn impure(_i: isize) { +} + +fn match_imm_reg(v: &Option) { + match *v { + Some(ref i) => {impure(*i)} // OK because immutable + None => {} + } +} + +fn match_mut_reg(v: &mut Option) { + match *v { + Some(ref i) => {impure(*i)} // OK, frozen + None => {} + } +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-pat-reassign-no-binding.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-pat-reassign-no-binding.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-pat-reassign-no-binding.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-pat-reassign-no-binding.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + let mut x = None; + match x { + None => { + // It is ok to reassign x here, because there is in + // fact no outstanding loan of x! + x = Some(0); + } + Some(_) => { } + } + assert_eq!(x, Some(0)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-rvalues-mutable.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-rvalues-mutable.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-rvalues-mutable.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-rvalues-mutable.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +struct Counter { + value: usize +} + +impl Counter { + fn new(v: usize) -> Counter { + Counter {value: v} + } + + fn inc<'a>(&'a mut self) -> &'a mut Counter { + self.value += 1; + self + } + + fn get(&self) -> usize { + self.value + } + + fn get_and_inc(&mut self) -> usize { + let v = self.value; + self.value += 1; + v + } +} + +pub fn main() { + let v = Counter::new(22).get_and_inc(); + assert_eq!(v, 22); + + let v = Counter::new(22).inc().inc().get(); + assert_eq!(v, 24); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-scope-of-deref-issue-4666.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-scope-of-deref-issue-4666.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-scope-of-deref-issue-4666.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-scope-of-deref-issue-4666.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,52 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests that the scope of the pointer returned from `get()` is +// limited to the deref operation itself, and does not infect the +// block as a whole. + + +struct Box { + x: usize +} + +impl Box { + fn get(&self) -> &usize { + &self.x + } + fn set(&mut self, x: usize) { + self.x = x; + } +} + +fn fun1() { + // in the past, borrow checker behaved differently when + // init and decl of `v` were distinct + let v; + let mut a_box = Box {x: 0}; + a_box.set(22); + v = *a_box.get(); + a_box.set(v+1); + assert_eq!(23, *a_box.get()); +} + +fn fun2() { + let mut a_box = Box {x: 0}; + a_box.set(22); + let v = *a_box.get(); + a_box.set(v+1); + assert_eq!(23, *a_box.get()); +} + +pub fn main() { + fun1(); + fun2(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-slice-pattern-element-loan.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-slice-pattern-element-loan.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-slice-pattern-element-loan.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-slice-pattern-element-loan.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +//compile-flags: -Z borrowck=mir + +#![feature(slice_patterns)] + +fn mut_head_tail<'a, A>(v: &'a mut [A]) -> Option<(&'a mut A, &'a mut [A])> { + match *v { + [ref mut head, ref mut tail..] => { + Some((head, tail)) + } + [] => None + } +} + +fn main() { + let mut v = [1,2,3,4]; + match mut_head_tail(&mut v) { + None => {}, + Some((h,t)) => { + *h = 1000; + t.reverse(); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-static-item-in-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-static-item-in-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-static-item-in-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-static-item-in-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Regression test for issue #7740 + +// pretty-expanded FIXME #23616 + +pub fn main() { + static A: &'static char = &'A'; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-trait-lifetime.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-trait-lifetime.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-trait-lifetime.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-trait-lifetime.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +// This test verifies that casting from the same lifetime on a value +// to the same lifetime on a trait succeeds. See issue #10766. + +// pretty-expanded FIXME #23616 + +#![allow(dead_code)] + +use std::marker; + +fn main() { + trait T { fn foo(&self) {} } + + fn f<'a, V: T>(v: &'a V) -> &'a T { + v as &'a T + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-uniq-via-ref.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-uniq-via-ref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-uniq-via-ref.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-uniq-via-ref.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,59 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +// pretty-expanded FIXME #23616 + +struct Rec { + f: Box, +} + +struct Outer { + f: Inner +} + +struct Inner { + g: Innermost +} + +struct Innermost { + h: Box, +} + +fn borrow(_v: &isize) {} + +fn box_mut(v: &mut Box) { + borrow(&**v); // OK: &mut -> &imm +} + +fn box_mut_rec(v: &mut Rec) { + borrow(&*v.f); // OK: &mut -> &imm +} + +fn box_mut_recs(v: &mut Outer) { + borrow(&*v.f.g.h); // OK: &mut -> &imm +} + +fn box_imm(v: &Box) { + borrow(&**v); // OK +} + +fn box_imm_rec(v: &Rec) { + borrow(&*v.f); // OK +} + +fn box_imm_recs(v: &Outer) { + borrow(&*v.f.g.h); // OK +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-univariant-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-univariant-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-univariant-enum.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-univariant-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +use std::cell::Cell; + +#[derive(Copy, Clone)] +enum newtype { + newvar(isize) +} + +pub fn main() { + + // Test that borrowck treats enums with a single variant + // specially. + + let x = &Cell::new(5); + let y = &Cell::new(newtype::newvar(3)); + let z = match y.get() { + newtype::newvar(b) => { + x.set(x.get() + 1); + x.get() * b + } + }; + assert_eq!(z, 18); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-unsafe-static-mutable-borrows.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-unsafe-static-mutable-borrows.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-unsafe-static-mutable-borrows.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-unsafe-static-mutable-borrows.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// revisions: ast mir +//[mir]compile-flags: -Z borrowck=mir + +// Test file taken from issue 45129 (https://github.com/rust-lang/rust/issues/45129) + +struct Foo { x: [usize; 2] } + +static mut SFOO: Foo = Foo { x: [23, 32] }; + +impl Foo { + fn x(&mut self) -> &mut usize { &mut self.x[0] } +} + +fn main() { + unsafe { + let sfoo: *mut Foo = &mut SFOO; + let x = (*sfoo).x(); + (*sfoo).x[1] += 1; + *x += 1; + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-unused-mut-locals.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-unused-mut-locals.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-unused-mut-locals.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-unused-mut-locals.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,57 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(nll)] +#![deny(unused_mut)] + +#[derive(Debug)] +struct A {} + +fn init_a() -> A { + A {} +} + +#[derive(Debug)] +struct B<'a> { + ed: &'a mut A, +} + +fn init_b<'a>(ed: &'a mut A) -> B<'a> { + B { ed } +} + +#[derive(Debug)] +struct C<'a> { + pd: &'a mut B<'a>, +} + +fn init_c<'a>(pd: &'a mut B<'a>) -> C<'a> { + C { pd } +} + +#[derive(Debug)] +struct D<'a> { + sd: &'a mut C<'a>, +} + +fn init_d<'a>(sd: &'a mut C<'a>) -> D<'a> { + D { sd } +} + +fn main() { + let mut a = init_a(); + let mut b = init_b(&mut a); + let mut c = init_c(&mut b); + + let d = init_d(&mut c); + + println!("{:?}", d) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-use-mut-borrow.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-use-mut-borrow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-use-mut-borrow.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/borrowck-use-mut-borrow.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,61 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + +struct A { a: isize, b: Box } + +fn field_copy_after_field_borrow() { + let mut x = A { a: 1, b: box 2 }; + let p = &mut x.b; + drop(x.a); + **p = 3; +} + +fn fu_field_copy_after_field_borrow() { + let mut x = A { a: 1, b: box 2 }; + let p = &mut x.b; + let y = A { b: box 3, .. x }; + drop(y); + **p = 4; +} + +fn field_deref_after_field_borrow() { + let mut x = A { a: 1, b: box 2 }; + let p = &mut x.a; + drop(*x.b); + *p = 3; +} + +fn field_move_after_field_borrow() { + let mut x = A { a: 1, b: box 2 }; + let p = &mut x.a; + drop(x.b); + *p = 3; +} + +fn fu_field_move_after_field_borrow() { + let mut x = A { a: 1, b: box 2 }; + let p = &mut x.a; + let y = A { a: 3, .. x }; + drop(y); + *p = 4; +} + +fn main() { + field_copy_after_field_borrow(); + fu_field_copy_after_field_borrow(); + field_deref_after_field_borrow(); + field_move_after_field_borrow(); + fu_field_move_after_field_borrow(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/two-phase-baseline.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/two-phase-baseline.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/two-phase-baseline.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/two-phase-baseline.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags: -Z borrowck=mir -Z two-phase-borrows + +// This is the "goto example" for why we want two phase borrows. + +fn main() { + let mut v = vec![0, 1, 2]; + v.push(v.len()); + assert_eq!(v, [0, 1, 2, 3]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/two-phase-bin-ops.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/two-phase-bin-ops.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/two-phase-bin-ops.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/two-phase-bin-ops.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,49 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// revisions: lxl nll + +#![cfg_attr(nll, feature(nll))] + +use std::ops::{AddAssign, SubAssign, MulAssign, DivAssign, RemAssign}; +use std::ops::{BitAndAssign, BitOrAssign, BitXorAssign, ShlAssign, ShrAssign}; + +struct A(i32); + +macro_rules! trivial_binop { + ($Trait:ident, $m:ident) => { + impl $Trait 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 main() { + let mut a = A(10); + a += a.0; + a -= a.0; + a *= a.0; + a /= a.0; + a &= a.0; + a |= a.0; + a ^= a.0; + a <<= a.0; + a >>= a.0; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/two-phase-control-flow-split-before-activation.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/two-phase-control-flow-split-before-activation.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/borrowck/two-phase-control-flow-split-before-activation.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/borrowck/two-phase-control-flow-split-before-activation.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// revisions: lxl nll +//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows + +#![cfg_attr(nll, feature(nll))] + +fn main() { + let mut a = 0; + let mut b = 0; + let p = if maybe() { + &mut a + } else { + &mut b + }; + use_(p); +} + +fn maybe() -> bool { false } +fn use_(_: T) { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/builtin-clone-unwind.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/builtin-clone-unwind.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/builtin-clone-unwind.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/builtin-clone-unwind.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_variables)] +#![allow(unused_imports)] // ignore-wasm32-bare compiled with panic=abort by default // Test that builtin implementations of `Clone` cleanup everything diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/builtin-superkinds-in-metadata.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/builtin-superkinds-in-metadata.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/builtin-superkinds-in-metadata.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/builtin-superkinds-in-metadata.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_imports)] // aux-build:trait_superkinds_in_metadata.rs diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/builtin-superkinds-phantom-typaram.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/builtin-superkinds-phantom-typaram.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/builtin-superkinds-phantom-typaram.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/builtin-superkinds-phantom-typaram.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // Tests that even when a type parameter doesn't implement a required // super-builtin-kind of a trait, if the type parameter is never used, // the type can implement the trait anyway. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cast.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cast.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cast.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_assignments)] +#![allow(unused_variables)] pub fn main() { let i: isize = 'Q' as isize; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cell-does-not-clone.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cell-does-not-clone.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cell-does-not-clone.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cell-does-not-clone.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] use std::cell::Cell; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/auxiliary/cfg_inner_static.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/auxiliary/cfg_inner_static.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/auxiliary/cfg_inner_static.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/auxiliary/cfg_inner_static.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// this used to just ICE on compiling +pub fn foo() { + if cfg!(foo) { + static a: isize = 3; + a + } else { 3 }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/auxiliary/crate-attributes-using-cfg_attr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/auxiliary/crate-attributes-using-cfg_attr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/auxiliary/crate-attributes-using-cfg_attr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/auxiliary/crate-attributes-using-cfg_attr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic +// compile-flags: --cfg foo + +#![cfg_attr(foo, crate_type="lib")] + +pub fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-attr-cfg.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-attr-cfg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-attr-cfg.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-attr-cfg.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// main is conditionally compiled, but the conditional compilation +// is conditional too! + +// pretty-expanded FIXME #23616 + +#[cfg_attr(foo, cfg(bar))] +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-attr-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-attr-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-attr-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-attr-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// https://github.com/rust-lang/rust/issues/21833#issuecomment-72353044 + +// pretty-expanded FIXME #23616 + +#![cfg_attr(not_used, no_core)] + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg_attr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg_attr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg_attr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg_attr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,60 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags:--cfg set1 --cfg set2 +#![allow(dead_code)] +use std::fmt::Debug; + +struct NotDebugable; + +#[cfg_attr(set1, derive(Debug))] +struct Set1; + +#[cfg_attr(notset, derive(Debug))] +struct Notset(NotDebugable); + +#[cfg_attr(not(notset), derive(Debug))] +struct NotNotset; + +#[cfg_attr(not(set1), derive(Debug))] +struct NotSet1(NotDebugable); + +#[cfg_attr(all(set1, set2), derive(Debug))] +struct AllSet1Set2; + +#[cfg_attr(all(set1, notset), derive(Debug))] +struct AllSet1Notset(NotDebugable); + +#[cfg_attr(any(set1, notset), derive(Debug))] +struct AnySet1Notset; + +#[cfg_attr(any(notset, notset2), derive(Debug))] +struct AnyNotsetNotset2(NotDebugable); + +#[cfg_attr(all(not(notset), any(set1, notset)), derive(Debug))] +struct Complex; + +#[cfg_attr(any(notset, not(any(set1, notset))), derive(Debug))] +struct ComplexNot(NotDebugable); + +#[cfg_attr(any(target_endian = "little", target_endian = "big"), derive(Debug))] +struct KeyValue; + +fn is_show() {} + +fn main() { + is_show::(); + is_show::(); + is_show::(); + is_show::(); + is_show::(); + is_show::(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-family.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-family.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-family.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-family.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 +// ignore-cloudabi no target_family +// ignore-wasm32-bare no target_family + +#[cfg(windows)] +pub fn main() { +} + +#[cfg(unix)] +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-in-crate-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-in-crate-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-in-crate-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-in-crate-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags: --cfg bar -D warnings +#![cfg(bar)] + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg_inner_static.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg_inner_static.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg_inner_static.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg_inner_static.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:cfg_inner_static.rs + +// pretty-expanded FIXME #23616 + +extern crate cfg_inner_static; + +pub fn main() { + cfg_inner_static::foo(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-macros-foo.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-macros-foo.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-macros-foo.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-macros-foo.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags: --cfg foo + +// check that cfg correctly chooses between the macro impls (see also +// cfg-macros-notfoo.rs) + + +#[cfg(foo)] +#[macro_use] +mod foo { + macro_rules! bar { + () => { true } + } +} + +#[cfg(not(foo))] +#[macro_use] +mod foo { + macro_rules! bar { + () => { false } + } +} + +pub fn main() { + assert!(bar!()) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-macros-notfoo.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-macros-notfoo.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-macros-notfoo.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-macros-notfoo.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags: + +// check that cfg correctly chooses between the macro impls (see also +// cfg-macros-foo.rs) + + +#[cfg(foo)] +#[macro_use] +mod foo { + macro_rules! bar { + () => { true } + } +} + +#[cfg(not(foo))] +#[macro_use] +mod foo { + macro_rules! bar { + () => { false } + } +} + +pub fn main() { + assert!(!bar!()) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-match-arm.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-match-arm.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-match-arm.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-match-arm.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +enum Foo { + Bar, + Baz, +} + +fn foo(f: Foo) { + match f { + Foo::Bar => {}, + #[cfg(not(asdfa))] + Foo::Baz => {}, + #[cfg(afsd)] + Basdfwe => {} + } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfgs-on-items.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfgs-on-items.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfgs-on-items.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfgs-on-items.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags: --cfg fooA --cfg fooB + +// fooA AND !bar + +#[cfg(all(fooA, not(bar)))] +fn foo1() -> isize { 1 } + +// !fooA AND !bar +#[cfg(all(not(fooA), not(bar)))] +fn foo2() -> isize { 2 } + +// fooC OR (fooB AND !bar) +#[cfg(any(fooC, all(fooB, not(bar))))] +fn foo2() -> isize { 3 } + +// fooA AND bar +#[cfg(all(fooA, bar))] +fn foo3() -> isize { 2 } + +// !(fooA AND bar) +#[cfg(not(all(fooA, bar)))] +fn foo3() -> isize { 3 } + +pub fn main() { + assert_eq!(1, foo1()); + assert_eq!(3, foo2()); + assert_eq!(3, foo3()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg_stmt_expr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg_stmt_expr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg_stmt_expr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg_stmt_expr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,102 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_mut)] +#![allow(unused_variables)] +#![deny(non_snake_case)] +#![feature(stmt_expr_attributes)] + +fn main() { + let a = 413; + #[cfg(unset)] + let a = (); + assert_eq!(a, 413); + + let mut b = 612; + #[cfg(unset)] + { + b = 1111; + } + assert_eq!(b, 612); + + #[cfg(unset)] + undefined_fn(); + + #[cfg(unset)] + undefined_macro!(); + #[cfg(unset)] + undefined_macro![]; + #[cfg(unset)] + undefined_macro!{}; + + // pretty printer bug... + // #[cfg(unset)] + // undefined_macro!{} + + let () = (#[cfg(unset)] 341,); // Should this also work on parens? + let t = (1, #[cfg(unset)] 3, 4); + assert_eq!(t, (1, 4)); + + let f = |_: u32, _: u32| (); + f(2, 1, #[cfg(unset)] 6); + + let _: u32 = a.clone(#[cfg(unset)] undefined); + + let _: [(); 0] = [#[cfg(unset)] 126]; + let t = [#[cfg(unset)] 1, 2, 6]; + assert_eq!(t, [2, 6]); + + { + let r; + #[cfg(unset)] + (r = 5); + #[cfg(not(unset))] + (r = 10); + assert_eq!(r, 10); + } + + // check that macro expanded code works + + macro_rules! if_cfg { + ($cfg:meta $ib:block else $eb:block) => { + { + let r; + #[cfg($cfg)] + (r = $ib); + #[cfg(not($cfg))] + (r = $eb); + r + } + } + } + + let n = if_cfg!(unset { + 413 + } else { + 612 + }); + + assert_eq!((#[cfg(unset)] 1, #[cfg(not(unset))] 2), (2,)); + assert_eq!(n, 612); + + // check that lints work + + #[allow(non_snake_case)] + let FOOBAR = { + fn SYLADEX() {} + }; + + #[allow(non_snake_case)] + { + fn CRUXTRUDER() {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-target-family.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-target-family.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-target-family.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-target-family.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-cloudabi no target_family +// ignore-wasm32-bare no target_family + +// pretty-expanded FIXME #23616 + +#[cfg(target_family = "windows")] +pub fn main() { +} + +#[cfg(target_family = "unix")] +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-target-vendor.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-target-vendor.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-target-vendor.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/cfg-target-vendor.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(cfg_target_vendor)] + +#[cfg(target_vendor = "unknown")] +pub fn main() { +} + +#[cfg(not(target_vendor = "unknown"))] +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/conditional-compile-arch.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/conditional-compile-arch.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/conditional-compile-arch.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/conditional-compile-arch.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,48 @@ +// Copyright 2012-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#[cfg(target_arch = "x86")] +pub fn main() { } + +#[cfg(target_arch = "x86_64")] +pub fn main() { } + +#[cfg(target_arch = "arm")] +pub fn main() { } + +#[cfg(target_arch = "aarch64")] +pub fn main() { } + +#[cfg(target_arch = "mips")] +pub fn main() { } + +#[cfg(target_arch = "mips64")] +pub fn main() { } + +#[cfg(target_arch = "powerpc")] +pub fn main() { } + +#[cfg(target_arch = "powerpc64")] +pub fn main() { } + +#[cfg(target_arch = "s390x")] +pub fn main() { } + +#[cfg(target_arch = "asmjs")] +pub fn main() { } + +#[cfg(target_arch = "wasm32")] +pub fn main() { } + +#[cfg(target_arch = "sparc64")] +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/conditional-compile.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/conditional-compile.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/conditional-compile.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/conditional-compile.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,159 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(improper_ctypes)] + +// Crate use statements + +#[cfg(bogus)] +use flippity; + +#[cfg(bogus)] +static b: bool = false; + +static b: bool = true; + +mod rustrt { + #[cfg(bogus)] + extern { + // This symbol doesn't exist and would be a link error if this + // module was codegened + pub fn bogus(); + } + + extern {} +} + +#[cfg(bogus)] +type t = isize; + +type t = bool; + +#[cfg(bogus)] +enum tg { foo, } + +enum tg { bar, } + +#[cfg(bogus)] +struct r { + i: isize, +} + +#[cfg(bogus)] +fn r(i:isize) -> r { + r { + i: i + } +} + +struct r { + i: isize, +} + +fn r(i:isize) -> r { + r { + i: i + } +} + +#[cfg(bogus)] +mod m { + // This needs to parse but would fail in typeck. Since it's not in + // the current config it should not be typechecked. + pub fn bogus() { return 0; } +} + +mod m { + // Submodules have slightly different code paths than the top-level + // module, so let's make sure this jazz works here as well + #[cfg(bogus)] + pub fn f() { } + + pub fn f() { } +} + +// Since the bogus configuration isn't defined main will just be +// parsed, but nothing further will be done with it +#[cfg(bogus)] +pub fn main() { panic!() } + +pub fn main() { + // Exercise some of the configured items in ways that wouldn't be possible + // if they had the bogus definition + assert!((b)); + let _x: t = true; + let _y: tg = tg::bar; + + test_in_fn_ctxt(); +} + +fn test_in_fn_ctxt() { + #[cfg(bogus)] + fn f() { panic!() } + fn f() { } + f(); + + #[cfg(bogus)] + static i: isize = 0; + static i: isize = 1; + assert_eq!(i, 1); +} + +mod test_foreign_items { + pub mod rustrt { + extern { + #[cfg(bogus)] + pub fn write() -> String; + pub fn write() -> String; + } + } +} + +mod test_use_statements { + #[cfg(bogus)] + use flippity_foo; +} + +mod test_methods { + struct Foo { + bar: usize + } + + impl Fooable for Foo { + #[cfg(bogus)] + fn what(&self) { } + + fn what(&self) { } + + #[cfg(bogus)] + fn the(&self) { } + + fn the(&self) { } + } + + trait Fooable { + #[cfg(bogus)] + fn what(&self); + + fn what(&self); + + #[cfg(bogus)] + fn the(&self); + + fn the(&self); + } +} + +#[cfg(any())] +mod nonexistent_file; // Check that unconfigured non-inline modules are not loaded or parsed. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/crate-attributes-using-cfg_attr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/crate-attributes-using-cfg_attr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cfg/crate-attributes-using-cfg_attr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cfg/crate-attributes-using-cfg_attr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:crate-attributes-using-cfg_attr.rs + +extern crate crate_attributes_using_cfg_attr; + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/check-static-recursion-foreign.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/check-static-recursion-foreign.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/check-static-recursion-foreign.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/check-static-recursion-foreign.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // Static recursion check shouldn't fail when given a foreign item (#18279) // aux-build:check_static_recursion_foreign_helper.rs diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cleanup-arm-conditional.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cleanup-arm-conditional.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cleanup-arm-conditional.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cleanup-arm-conditional.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(stable_features)] +#![allow(unused_imports)] // Test that cleanup scope for temporaries created in a match // arm is confined to the match arm itself. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cleanup-rvalue-for-scope.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cleanup-rvalue-for-scope.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cleanup-rvalue-for-scope.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cleanup-rvalue-for-scope.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_snake_case)] +#![allow(dead_code)] +#![allow(unused_variables)] // Test that the lifetime of rvalues in for loops is extended // to the for loop itself. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cleanup-rvalue-scopes.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cleanup-rvalue-scopes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cleanup-rvalue-scopes.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cleanup-rvalue-scopes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_snake_case)] +#![allow(unused_variables)] // Test that destructors for rvalue temporaries run either at end of // statement or end of block, as appropriate given the temporary // lifetime rules. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_must_use)] +#![allow(dead_code)] +#![allow(unused_variables)] // Test cleanup of rvalue temporary that occurs while `box` construction // is in progress. This scenario revealed a rather terrible bug. The // ingredients are: diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/clone-with-exterior.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/clone-with-exterior.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/clone-with-exterior.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/clone-with-exterior.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_must_use)] // ignore-emscripten no threads support #![feature(box_syntax)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/close-over-big-then-small-data.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/close-over-big-then-small-data.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/close-over-big-then-small-data.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/close-over-big-then-small-data.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // If we use GEPi rather than GEP_tup_like when // storing closure data (as we used to do), the u64 would // overwrite the u16. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-expect-unsized.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-expect-unsized.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-expect-unsized.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-expect-unsized.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,53 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +use std::cell::RefCell; +use std::fmt::Debug; +use std::rc::Rc; + +// Check that coercions apply at the pointer level and don't cause +// rvalue expressions to be unsized. See #20169 for more information. + +pub fn main() { + let _: Box<[isize]> = Box::new({ [1, 2, 3] }); + let _: Box<[isize]> = Box::new(if true { [1, 2, 3] } else { [1, 3, 4] }); + let _: Box<[isize]> = Box::new(match true { true => [1, 2, 3], false => [1, 3, 4] }); + let _: Box _> = Box::new({ |x| (x as u8) }); + let _: Box = Box::new(if true { false } else { true }); + let _: Box = Box::new(match true { true => 'a', false => 'b' }); + + let _: &[isize] = &{ [1, 2, 3] }; + let _: &[isize] = &if true { [1, 2, 3] } else { [1, 3, 4] }; + let _: &[isize] = &match true { true => [1, 2, 3], false => [1, 3, 4] }; + let _: &Fn(isize) -> _ = &{ |x| (x as u8) }; + let _: &Debug = &if true { false } else { true }; + let _: &Debug = &match true { true => 'a', false => 'b' }; + + let _: &str = &{ String::new() }; + let _: &str = &if true { String::from("...") } else { 5.to_string() }; + let _: &str = &match true { + true => format!("{}", false), + false => ["x", "y"].join("+") + }; + + let _: Box<[isize]> = Box::new([1, 2, 3]); + let _: Box _> = Box::new(|x| (x as u8)); + + let _: Rc> = Rc::new(RefCell::new([1, 2, 3])); + let _: Rc _>> = Rc::new(RefCell::new(|x| (x as u8))); + + let _: Vec _>> = vec![ + Box::new(|x| (x as u8)), + Box::new(|x| (x as i16 as u8)), + ]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-overloaded-autoderef.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-overloaded-autoderef.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-overloaded-autoderef.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-overloaded-autoderef.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,77 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +use std::rc::Rc; + +// Examples from the "deref coercions" RFC, at rust-lang/rfcs#241. + +fn use_ref(_: &T) {} +fn use_mut(_: &mut T) {} + +fn use_rc(t: Rc) { + use_ref(&*t); // what you have to write today + use_ref(&t); // what you'd be able to write + use_ref(&&&&&&t); + use_ref(&mut &&&&&t); + use_ref(&&&mut &&&t); +} + +fn use_mut_box(mut t: &mut Box) { + use_mut(&mut *t); // what you have to write today + use_mut(t); // what you'd be able to write + use_mut(&mut &mut &mut t); + + use_ref(&*t); // what you have to write today + use_ref(t); // what you'd be able to write + use_ref(&&&&&&t); + use_ref(&mut &&&&&t); + use_ref(&&&mut &&&t); +} + +fn use_nested(t: &Box) { + use_ref(&**t); // what you have to write today + use_ref(t); // what you'd be able to write (note: recursive deref) + use_ref(&&&&&&t); + use_ref(&mut &&&&&t); + use_ref(&&&mut &&&t); +} + +fn use_slice(_: &[u8]) {} +fn use_slice_mut(_: &mut [u8]) {} + +fn use_vec(mut v: Vec) { + use_slice_mut(&mut v[..]); // what you have to write today + use_slice_mut(&mut v); // what you'd be able to write + use_slice_mut(&mut &mut &mut v); + + use_slice(&v[..]); // what you have to write today + use_slice(&v); // what you'd be able to write + use_slice(&&&&&&v); + use_slice(&mut &&&&&v); + use_slice(&&&mut &&&v); +} + +fn use_vec_ref(v: &Vec) { + use_slice(&v[..]); // what you have to write today + use_slice(v); // what you'd be able to write + use_slice(&&&&&&v); + use_slice(&mut &&&&&v); + use_slice(&&&mut &&&v); +} + +fn use_op_rhs(s: &mut String) { + *s += {&String::from(" ")}; +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-imm-ptr-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-imm-ptr-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-imm-ptr-arg.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-imm-ptr-arg.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +fn negate(x: &isize) -> isize { + -*x +} + +fn negate_mut(y: &mut isize) -> isize { + negate(y) +} + +fn negate_imm(y: &isize) -> isize { + negate(y) +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-imm-ptr-rcvr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-imm-ptr-rcvr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-imm-ptr-rcvr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-imm-ptr-rcvr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +struct SpeechMaker { + speeches: usize +} + +impl SpeechMaker { + pub fn how_many(&self) -> usize { self.speeches } +} + +fn foo(speaker: &SpeechMaker) -> usize { + speaker.how_many() + 33 +} + +pub fn main() { + let lincoln = SpeechMaker {speeches: 22}; + assert_eq!(foo(&lincoln), 55); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-imm-vec-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-imm-vec-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-imm-vec-arg.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-imm-vec-arg.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +fn sum(x: &[isize]) -> isize { + let mut sum = 0; + for y in x { sum += *y; } + return sum; +} + +fn sum_mut(y: &mut [isize]) -> isize { + sum(y) +} + +fn sum_imm(y: &[isize]) -> isize { + sum(y) +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-imm-vec-rcvr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-imm-vec-rcvr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-imm-vec-rcvr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-imm-vec-rcvr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +fn bar(v: &mut [usize]) -> Vec { + v.to_vec() +} + +fn bip(v: &[usize]) -> Vec { + v.to_vec() +} + +pub fn main() { + let mut the_vec = vec![1, 2, 3, 100]; + assert_eq!(the_vec.clone(), bar(&mut the_vec)); + assert_eq!(the_vec.clone(), bip(&the_vec)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-mut-ptr-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-mut-ptr-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-mut-ptr-arg.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-mut-ptr-arg.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +struct SpeechMaker { + speeches: usize +} + +fn talk(x: &mut SpeechMaker) { + x.speeches += 1; +} + +fn give_a_few_speeches(speaker: &mut SpeechMaker) { + + // Here speaker is reborrowed for each call, so we don't get errors + // about speaker being moved. + + talk(speaker); + talk(speaker); + talk(speaker); +} + +pub fn main() { + let mut lincoln = SpeechMaker {speeches: 22}; + give_a_few_speeches(&mut lincoln); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-mut-ptr-rcvr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-mut-ptr-rcvr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-mut-ptr-rcvr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-mut-ptr-rcvr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +struct SpeechMaker { + speeches: usize +} + +impl SpeechMaker { + pub fn talk(&mut self) { + self.speeches += 1; + } +} + +fn give_a_few_speeches(speaker: &mut SpeechMaker) { + + // Here speaker is reborrowed for each call, so we don't get errors + // about speaker being moved. + + speaker.talk(); + speaker.talk(); + speaker.talk(); +} + +pub fn main() { + let mut lincoln = SpeechMaker {speeches: 22}; + give_a_few_speeches(&mut lincoln); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-mut-vec-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-mut-vec-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-mut-vec-arg.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-mut-vec-arg.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +fn reverse(v: &mut [usize]) { + v.reverse(); +} + +fn bar(v: &mut [usize]) { + reverse(v); + reverse(v); + reverse(v); +} + +pub fn main() { + let mut the_vec = vec![1, 2, 3, 100]; + bar(&mut the_vec); + assert_eq!(the_vec, [100, 3, 2, 1]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-mut-vec-rcvr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-mut-vec-rcvr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-mut-vec-rcvr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-reborrow-mut-vec-rcvr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +fn bar(v: &mut [usize]) { + v.reverse(); + v.reverse(); + v.reverse(); +} + +pub fn main() { + let mut the_vec = vec![1, 2, 3, 100]; + bar(&mut the_vec); + assert_eq!(the_vec, [100, 3, 2, 1]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-unify-return.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-unify-return.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-unify-return.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-unify-return.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Check that coercions unify the expected return type of a polymorphic +// function call, instead of leaving the type variables as they were. + +// pretty-expanded FIXME #23616 + +struct Foo; +impl Foo { + fn foo(self, x: T) -> Option { Some(x) } +} + +pub fn main() { + let _: Option = Some(main); + let _: Option = Foo.foo(main); + + // The same two cases, with implicit type variables made explicit. + let _: Option = Some::<_>(main); + let _: Option = Foo.foo::<_>(main); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-unify.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-unify.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-unify.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-unify.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,78 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Check that coercions can unify if-else, match arms and array elements. + +// Try to construct if-else chains, matches and arrays out of given expressions. +macro_rules! check { + ($last:expr $(, $rest:expr)+) => { + // Last expression comes first because of whacky ifs and matches. + let _ = $(if false { $rest })else+ else { $last }; + + let _ = match 0 { $(_ if false => $rest,)+ _ => $last }; + + let _ = [$($rest,)+ $last]; + } +} + +// Check all non-uniform cases of 2 and 3 expressions of 2 types. +macro_rules! check2 { + ($a:expr, $b:expr) => { + check!($a, $b); + check!($b, $a); + + check!($a, $a, $b); + check!($a, $b, $a); + check!($a, $b, $b); + + check!($b, $a, $a); + check!($b, $a, $b); + check!($b, $b, $a); + } +} + +// Check all non-uniform cases of 2 and 3 expressions of 3 types. +macro_rules! check3 { + ($a:expr, $b:expr, $c:expr) => { + // Delegate to check2 for cases where a type repeats. + check2!($a, $b); + check2!($b, $c); + check2!($a, $c); + + // Check the remaining cases, i.e. permutations of ($a, $b, $c). + check!($a, $b, $c); + check!($a, $c, $b); + check!($b, $a, $c); + check!($b, $c, $a); + check!($c, $a, $b); + check!($c, $b, $a); + } +} + +use std::mem::size_of; + +fn foo() {} +fn bar() {} + +pub fn main() { + check3!(foo, bar, foo as fn()); + check3!(size_of::, size_of::, size_of:: as fn() -> usize); + + let s = String::from("bar"); + check2!("foo", &s); + + let a = [1, 2, 3]; + let v = vec![1, 2, 3]; + check2!(&a[..], &v); + + // Make sure in-array coercion still works. + let _ = [("a", Default::default()), (Default::default(), "b"), (&s, &s)]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-unsize-subtype.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-unsize-subtype.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-unsize-subtype.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coerce/coerce-unsize-subtype.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,50 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +use std::rc::Rc; + +fn lub_short<'a, T>(_: &[&'a T], _: &[&'a T]) {} + +// The two arguments are a subtype of their LUB, after coercion. +fn long_and_short<'a, T>(xs: &[&'static T; 1], ys: &[&'a T; 1]) { + lub_short(xs, ys); +} + +// The argument coerces to a subtype of the return type. +fn long_to_short<'a, 'b, T>(xs: &'b [&'static T; 1]) -> &'b [&'a T] { + xs +} + +// Rc is covariant over T just like &T. +fn long_to_short_rc<'a, T>(xs: Rc<[&'static T; 1]>) -> Rc<[&'a T]> { + xs +} + +// LUB-coercion (if-else/match/array) coerces `xs: &'b [&'static T: N]` +// to a subtype of the LUB of `xs` and `ys` (i.e. `&'b [&'a T]`), +// regardless of the order they appear (in if-else/match/array). +fn long_and_short_lub1<'a, 'b, T>(xs: &'b [&'static T; 1], ys: &'b [&'a T]) { + let _order1 = [xs, ys]; + let _order2 = [ys, xs]; +} + +// LUB-coercion should also have the exact same effect when `&'b [&'a T; N]` +// needs to be coerced, i.e. the resulting type is not &'b [&'static T], but +// rather the `&'b [&'a T]` LUB. +fn long_and_short_lub2<'a, 'b, T>(xs: &'b [&'static T], ys: &'b [&'a T; 1]) { + let _order1 = [xs, ys]; + let _order2 = [ys, xs]; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/auxiliary/coherence_copy_like_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/auxiliary/coherence_copy_like_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/auxiliary/coherence_copy_like_lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/auxiliary/coherence_copy_like_lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![feature(fundamental)] + +pub trait MyCopy { } +impl MyCopy for i32 { } + +pub struct MyStruct(T); + +#[fundamental] +pub struct MyFundamentalStruct(T); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/auxiliary/coherence_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/auxiliary/coherence_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/auxiliary/coherence_lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/auxiliary/coherence_lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] + +pub trait Remote { + fn foo(&self) { } +} + +pub trait Remote1 { + fn foo(&self, t: T) { } +} + +pub trait Remote2 { + fn foo(&self, t: T, u: U) { } +} + +pub struct Pair(T,U); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-bigint-int.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-bigint-int.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-bigint-int.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-bigint-int.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:coherence_lib.rs + +// pretty-expanded FIXME #23616 + +extern crate coherence_lib as lib; +use lib::Remote1; + +pub struct BigInt; + +impl Remote1 for isize { } + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-bigint-vecint.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-bigint-vecint.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-bigint-vecint.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-bigint-vecint.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:coherence_lib.rs + +// pretty-expanded FIXME #23616 + +extern crate coherence_lib as lib; +use lib::Remote1; + +pub struct BigInt; + +impl Remote1 for Vec { } + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-blanket.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-blanket.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-blanket.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-blanket.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +// aux-build:coherence_lib.rs + +// pretty-expanded FIXME #23616 + +extern crate coherence_lib as lib; +use lib::Remote1; + +pub trait Local { + fn foo(&self) { } +} + +impl Local for T { } + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence_copy_like.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence_copy_like.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence_copy_like.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence_copy_like.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Test that we are able to introduce a negative constraint that +// `MyType: !MyTrait` along with other "fundamental" wrappers. + +// aux-build:coherence_copy_like_lib.rs + +extern crate coherence_copy_like_lib as lib; + +struct MyType { x: i32 } + +trait MyTrait { } +impl MyTrait for T { } +impl MyTrait for MyType { } +impl<'a> MyTrait for &'a MyType { } +impl MyTrait for Box { } +impl<'a> MyTrait for &'a Box { } + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-covered-type-parameter.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-covered-type-parameter.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-covered-type-parameter.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-covered-type-parameter.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// aux-build:coherence_lib.rs + +// pretty-expanded FIXME #23616 + +extern crate coherence_lib as lib; +use lib::Remote; + +struct Foo(T); + +impl Remote for Foo { } + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-impl-in-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-impl-in-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-impl-in-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-impl-in-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +pub fn main() { + #[derive(Copy, Clone)] + enum x { foo } + impl ::std::cmp::PartialEq for x { + fn eq(&self, other: &x) -> bool { + (*self) as isize == (*other) as isize + } + fn ne(&self, other: &x) -> bool { !(*self).eq(other) } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-iterator-vec-any-elem.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-iterator-vec-any-elem.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-iterator-vec-any-elem.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-iterator-vec-any-elem.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// aux-build:coherence_lib.rs + +// pretty-expanded FIXME #23616 + +extern crate coherence_lib as lib; +use lib::Remote1; + +struct Foo(T); + +impl Remote1 for Foo { } + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-iterator-vec.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-iterator-vec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-iterator-vec.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-iterator-vec.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// aux-build:coherence_lib.rs + +// pretty-expanded FIXME #23616 + +extern crate coherence_lib as lib; +use lib::Remote1; + +struct Foo(T); + +impl Remote1 for Foo { } + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-multidispatch-tuple.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-multidispatch-tuple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-multidispatch-tuple.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-multidispatch-tuple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +// pretty-expanded FIXME #23616 + +use std::fmt::Debug; +use std::default::Default; + +// Test that an impl for homogeneous pairs does not conflict with a +// heterogeneous pair. + +trait MyTrait { + fn get(&self) -> usize; +} + +impl MyTrait for (T,T) { + fn get(&self) -> usize { 0 } +} + +impl MyTrait for (usize,isize) { + fn get(&self) -> usize { 0 } +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-negative-impls-safe.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-negative-impls-safe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-negative-impls-safe.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-negative-impls-safe.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +#![feature(optin_builtin_traits)] + +use std::marker::Send; + +struct TestType; + +impl !Send for TestType {} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-rfc447-constrained.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-rfc447-constrained.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-rfc447-constrained.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-rfc447-constrained.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// check that trait matching can handle impls whose types are only +// constrained by a projection. + +trait IsU32 {} +impl IsU32 for u32 {} + +trait Mirror { type Image: ?Sized; } +impl Mirror for T { type Image = T; } + +trait Bar {} +impl, L: Mirror> Bar for V + where U::Image: IsU32 {} + +trait Foo { fn name() -> &'static str; } +impl Foo for u64 { fn name() -> &'static str { "u64" } } +impl Foo for T { fn name() -> &'static str { "Bar" }} + +fn main() { + assert_eq!(::name(), "u64"); + assert_eq!(::name(), "Bar"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-subtyping.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-subtyping.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-subtyping.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-subtyping.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,49 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that two distinct impls which match subtypes of one another +// yield coherence errors (or not) depending on the variance. + +trait Contravariant { + fn foo(&self) { } +} + +impl Contravariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 { +} + +impl Contravariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 { +} + +/////////////////////////////////////////////////////////////////////////// + +trait Covariant { + fn foo(&self) { } +} + +impl Covariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 { +} + +impl Covariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 { +} + +/////////////////////////////////////////////////////////////////////////// + +trait Invariant { + fn foo(&self) { } +} + +impl Invariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 { +} + +impl Invariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 { +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-where-clause.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-where-clause.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-where-clause.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/coherence/coherence-where-clause.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::fmt::Debug; +use std::default::Default; + +trait MyTrait { + fn get(&self) -> Self; +} + +impl MyTrait for T + where T : Default +{ + fn get(&self) -> T { + Default::default() + } +} + +#[derive(Clone, Copy, Debug, PartialEq)] +struct MyType { + dummy: usize +} + +impl MyTrait for MyType { + fn get(&self) -> MyType { (*self).clone() } +} + +fn test_eq(m: M, n: M) +where M : MyTrait + Debug + PartialEq +{ + assert_eq!(m.get(), n); +} + +pub fn main() { + test_eq(0_usize, 0_usize); + + let value = MyType { dummy: 256 + 22 }; + test_eq(value, value); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/collections-const-new.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/collections-const-new.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/collections-const-new.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/collections-const-new.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // Test several functions can be used for constants // 1. Vec::new() // 2. String::new() diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/command-before-exec.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/command-before-exec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/command-before-exec.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/command-before-exec.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(stable_features)] // ignore-windows - this is a unix-specific test // ignore-cloudabi no processes // ignore-emscripten no processes diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/command-exec.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/command-exec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/command-exec.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/command-exec.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(stable_features)] // ignore-windows - this is a unix-specific test // ignore-pretty issue #37199 // ignore-cloudabi no processes @@ -47,6 +48,23 @@ println!("passed"); } + "exec-test5" => { + env::set_var("VARIABLE", "ABC"); + Command::new("definitely-not-a-real-binary").env("VARIABLE", "XYZ").exec(); + assert_eq!(env::var("VARIABLE").unwrap(), "ABC"); + println!("passed"); + } + + "exec-test6" => { + let err = Command::new("echo").arg("passed").env_clear().exec(); + panic!("failed to spawn: {}", err); + } + + "exec-test7" => { + let err = Command::new("echo").arg("passed").env_remove("PATH").exec(); + panic!("failed to spawn: {}", err); + } + _ => panic!("unknown argument: {}", arg), } return @@ -71,4 +89,23 @@ assert!(output.status.success()); assert!(output.stderr.is_empty()); assert_eq!(output.stdout, b"passed\n"); + + let output = Command::new(&me).arg("exec-test5").output().unwrap(); + assert!(output.status.success()); + assert!(output.stderr.is_empty()); + assert_eq!(output.stdout, b"passed\n"); + + if cfg!(target_os = "linux") { + let output = Command::new(&me).arg("exec-test6").output().unwrap(); + println!("{:?}", output); + assert!(output.status.success()); + assert!(output.stderr.is_empty()); + assert_eq!(output.stdout, b"passed\n"); + + let output = Command::new(&me).arg("exec-test7").output().unwrap(); + println!("{:?}", output); + assert!(output.status.success()); + assert!(output.stderr.is_empty()); + assert_eq!(output.stdout, b"passed\n"); + } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/complex.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/complex.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/complex.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/complex.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unconditional_recursion)] +#![allow(non_camel_case_types)] +#![allow(dead_code)] +#![allow(unused_mut)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/const-needs_drop.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/const-needs_drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/const-needs_drop.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/const-needs_drop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(const_needs_drop)] + +use std::mem; + +struct Trivial(u8, f32); + +struct NonTrivial(u8, String); + +const CONST_U8: bool = mem::needs_drop::(); +const CONST_STRING: bool = mem::needs_drop::(); +const CONST_TRIVIAL: bool = mem::needs_drop::(); +const CONST_NON_TRIVIAL: bool = mem::needs_drop::(); + +static STATIC_U8: bool = mem::needs_drop::(); +static STATIC_STRING: bool = mem::needs_drop::(); +static STATIC_TRIVIAL: bool = mem::needs_drop::(); +static STATIC_NON_TRIVIAL: bool = mem::needs_drop::(); + +fn main() { + assert!(!CONST_U8); + assert!(CONST_STRING); + assert!(!CONST_TRIVIAL); + assert!(CONST_NON_TRIVIAL); + + assert!(!STATIC_U8); + assert!(STATIC_STRING); + assert!(!STATIC_TRIVIAL); + assert!(STATIC_NON_TRIVIAL); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/auxiliary/anon-extern-mod-cross-crate-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/auxiliary/anon-extern-mod-cross-crate-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/auxiliary/anon-extern-mod-cross-crate-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/auxiliary/anon-extern-mod-cross-crate-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="anonexternmod"] +#![feature(libc)] + +extern crate libc; + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + pub fn rust_get_test_int() -> libc::intptr_t; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/auxiliary/cci_borrow_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/auxiliary/cci_borrow_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/auxiliary/cci_borrow_lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/auxiliary/cci_borrow_lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo(x: &usize) -> usize { + *x +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/auxiliary/cci_const_block.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/auxiliary/cci_const_block.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/auxiliary/cci_const_block.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/auxiliary/cci_const_block.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub static BLOCK_FN_DEF: fn(usize) -> usize = { + fn foo(a: usize) -> usize { + a + 10 + } + foo +}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/auxiliary/cci_const.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/auxiliary/cci_const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/auxiliary/cci_const.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/auxiliary/cci_const.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub extern fn bar() { +} + +pub const foopy: &'static str = "hi there"; +pub const uint_val: usize = 12; +pub const uint_expr: usize = (1 << uint_val) - 1; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/auxiliary/const_fn_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/auxiliary/const_fn_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/auxiliary/const_fn_lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/auxiliary/const_fn_lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Crate that exports a const fn. Used for testing cross-crate. + +#![crate_type="rlib"] + +pub const fn foo() -> usize { 22 } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-adt-align-mismatch.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-adt-align-mismatch.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-adt-align-mismatch.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-adt-align-mismatch.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(deprecated)] + +use std::mem; + +#[derive(PartialEq, Debug)] +enum Foo { + A(u32), + Bar([u16; 4]), + C +} + +// NOTE(eddyb) Don't make this a const, needs to be a static +// so it is always instantiated as a LLVM constant value. +static FOO: Foo = Foo::C; + +fn main() { + assert_eq!(FOO, Foo::C); + assert_eq!(mem::size_of::(), 12); + assert_eq!(mem::min_align_of::(), 4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-autoderef.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-autoderef.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-autoderef.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-autoderef.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +const A: [u8; 1] = ['h' as u8]; +const B: u8 = (&A)[0]; +const C: &'static &'static &'static &'static [u8; 1] = & & & &A; +const D: u8 = (&C)[0]; + +pub fn main() { + assert_eq!(B, A[0]); + assert_eq!(D, A[0]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-big-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-big-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-big-enum.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-big-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +enum Foo { + Bar(u32), + Baz, + Quux(u64, u16) +} + +static X: Foo = Foo::Baz; + +pub fn main() { + match X { + Foo::Baz => {} + _ => panic!() + } + match Y { + Foo::Bar(s) => assert_eq!(s, 2654435769), + _ => panic!() + } + match Z { + Foo::Quux(d,h) => { + assert_eq!(d, 0x123456789abcdef0); + assert_eq!(h, 0x1234); + } + _ => panic!() + } +} + +static Y: Foo = Foo::Bar(2654435769); +static Z: Foo = Foo::Quux(0x123456789abcdef0, 0x1234); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-binops.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-binops.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-binops.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-binops.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,136 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +macro_rules! assert_approx_eq { + ($a:expr, $b:expr) => ({ + let (a, b) = (&$a, &$b); + assert!((*a - *b).abs() < 1.0e-6, + "{} is not approximately equal to {}", *a, *b); + }) +} + +static A: isize = -4 + 3; +static A2: usize = 3 + 3; +static B: f64 = 3.0 + 2.7; + +static C: isize = 3 - 4; +static D: usize = 3 - 3; +static E: f64 = 3.0 - 2.7; + +static E2: isize = -3 * 3; +static F: usize = 3 * 3; +static G: f64 = 3.3 * 3.3; + +static H: isize = 3 / -1; +static I: usize = 3 / 3; +static J: f64 = 3.3 / 3.3; + +static N: bool = true && false; + +static O: bool = true || false; + +static P: isize = 3 & 1; +static Q: usize = 1 & 3; + +static R: isize = 3 | 1; +static S: usize = 1 | 3; + +static T: isize = 3 ^ 1; +static U: usize = 1 ^ 3; + +static V: isize = 1 << 3; + +// NOTE: better shr coverage +static W: isize = 1024 >> 4; +static X: usize = 1024 >> 4; + +static Y: bool = 1 == 1; +static Z: bool = 1.0f64 == 1.0; + +static AA: bool = 1 <= 2; +static AB: bool = -1 <= 2; +static AC: bool = 1.0f64 <= 2.0; + +static AD: bool = 1 < 2; +static AE: bool = -1 < 2; +static AF: bool = 1.0f64 < 2.0; + +static AG: bool = 1 != 2; +static AH: bool = -1 != 2; +static AI: bool = 1.0f64 != 2.0; + +static AJ: bool = 2 >= 1; +static AK: bool = 2 >= -2; +static AL: bool = 1.0f64 >= -2.0; + +static AM: bool = 2 > 1; +static AN: bool = 2 > -2; +static AO: bool = 1.0f64 > -2.0; + +pub fn main() { + assert_eq!(A, -1); + assert_eq!(A2, 6); + assert_approx_eq!(B, 5.7); + + assert_eq!(C, -1); + assert_eq!(D, 0); + assert_approx_eq!(E, 0.3); + + assert_eq!(E2, -9); + assert_eq!(F, 9); + assert_approx_eq!(G, 10.89); + + assert_eq!(H, -3); + assert_eq!(I, 1); + assert_approx_eq!(J, 1.0); + + assert_eq!(N, false); + + assert_eq!(O, true); + + assert_eq!(P, 1); + assert_eq!(Q, 1); + + assert_eq!(R, 3); + assert_eq!(S, 3); + + assert_eq!(T, 2); + assert_eq!(U, 2); + + assert_eq!(V, 8); + + assert_eq!(W, 64); + assert_eq!(X, 64); + + assert_eq!(Y, true); + assert_eq!(Z, true); + + assert_eq!(AA, true); + assert_eq!(AB, true); + assert_eq!(AC, true); + + assert_eq!(AD, true); + assert_eq!(AE, true); + assert_eq!(AF, true); + + assert_eq!(AG, true); + assert_eq!(AH, true); + assert_eq!(AI, true); + + assert_eq!(AJ, true); + assert_eq!(AK, true); + assert_eq!(AL, true); + + assert_eq!(AM, true); + assert_eq!(AN, true); + assert_eq!(AO, true); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-bitshift-rhs-inference.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-bitshift-rhs-inference.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-bitshift-rhs-inference.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-bitshift-rhs-inference.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +const RHS: u8 = 8; +const IRHS: i8 = 8; +const RHS16: u16 = 8; +const IRHS16: i16 = 8; +const RHS32: u32 = 8; +const IRHS32: i32 = 8; +const RHS64: u64 = 8; +const IRHS64: i64 = 8; +const RHSUS: usize = 8; +const IRHSIS: isize = 8; + +fn main() { + let _: [&'static str; 1 << RHS] = [""; 256]; + let _: [&'static str; 1 << IRHS] = [""; 256]; + let _: [&'static str; 1 << RHS16] = [""; 256]; + let _: [&'static str; 1 << IRHS16] = [""; 256]; + let _: [&'static str; 1 << RHS32] = [""; 256]; + let _: [&'static str; 1 << IRHS32] = [""; 256]; + let _: [&'static str; 1 << RHS64] = [""; 256]; + let _: [&'static str; 1 << IRHS64] = [""; 256]; + let _: [&'static str; 1 << RHSUS] = [""; 256]; + let _: [&'static str; 1 << IRHSIS] = [""; 256]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-block-cross-crate-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-block-cross-crate-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-block-cross-crate-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-block-cross-crate-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:cci_const_block.rs + + +extern crate cci_const_block; + +pub fn main() { + assert_eq!(cci_const_block::BLOCK_FN_DEF(390), 400); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-block-item-macro-codegen.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-block-item-macro-codegen.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-block-item-macro-codegen.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-block-item-macro-codegen.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,50 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// General test that function items in static blocks +// can be generated with a macro. + + +struct MyType { + desc: &'static str, + data: usize, + code: fn(usize, usize) -> usize +} + +impl MyType { + fn eval(&self, a: usize) -> usize { + (self.code)(self.data, a) + } +} + +macro_rules! codegen { + ($e:expr, $v:expr) => { + { + fn generated(a: usize, b: usize) -> usize { + a - ($e * b) + } + MyType { + desc: "test", + data: $v, + code: generated + } + } + } +} + +static GENERATED_CODE_1: MyType = codegen!(2, 100); +static GENERATED_CODE_2: MyType = codegen!(5, 1000); + +pub fn main() { + assert_eq!(GENERATED_CODE_1.eval(10), 80); + assert_eq!(GENERATED_CODE_2.eval(100), 500); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-block-item.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-block-item.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-block-item.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-block-item.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,51 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] + +mod foo { + pub trait Value { + fn value(&self) -> usize; + } +} + +static BLOCK_USE: usize = { + use foo::Value; + 100 +}; + +static BLOCK_STRUCT_DEF: usize = { + struct Foo { + a: usize + } + Foo{ a: 300 }.a +}; + +static BLOCK_FN_DEF: fn(usize) -> usize = { + fn foo(a: usize) -> usize { + a + 10 + } + foo +}; + +static BLOCK_MACRO_RULES: usize = { + macro_rules! baz { + () => (412) + } + baz!() +}; + +pub fn main() { + assert_eq!(BLOCK_USE, 100); + assert_eq!(BLOCK_STRUCT_DEF, 300); + assert_eq!(BLOCK_FN_DEF(390), 400); + assert_eq!(BLOCK_MACRO_RULES, 412); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-block.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-block.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-block.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-block.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,55 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![allow(dead_code)] +#![allow(unused_unsafe)] + +use std::marker::Sync; + +struct Foo { + a: usize, + b: *const () +} + +unsafe impl Sync for Foo {} + +fn foo(a: T) -> T { + a +} + +static BLOCK_INTEGRAL: usize = { 1 }; +static BLOCK_EXPLICIT_UNIT: () = { () }; +static BLOCK_IMPLICIT_UNIT: () = { }; +static BLOCK_FLOAT: f64 = { 1.0 }; +static BLOCK_ENUM: Option = { Some(100) }; +static BLOCK_STRUCT: Foo = { Foo { a: 12, b: 0 as *const () } }; +static BLOCK_UNSAFE: usize = unsafe { 1000 }; + +static BLOCK_FN_INFERRED: fn(usize) -> usize = { foo }; + +static BLOCK_FN: fn(usize) -> usize = { foo:: }; + +static BLOCK_ENUM_CONSTRUCTOR: fn(usize) -> Option = { Some }; + +pub fn main() { + assert_eq!(BLOCK_INTEGRAL, 1); + assert_eq!(BLOCK_EXPLICIT_UNIT, ()); + assert_eq!(BLOCK_IMPLICIT_UNIT, ()); + assert_eq!(BLOCK_FLOAT, 1.0_f64); + assert_eq!(BLOCK_STRUCT.a, 12); + assert_eq!(BLOCK_STRUCT.b, 0 as *const ()); + assert_eq!(BLOCK_ENUM, Some(100)); + assert_eq!(BLOCK_UNSAFE, 1000); + assert_eq!(BLOCK_FN_INFERRED(300), 300); + assert_eq!(BLOCK_FN(300), 300); + assert_eq!(BLOCK_ENUM_CONSTRUCTOR(200), Some(200)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-bound.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-bound.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Make sure const bounds work on things, and test that a few types +// are const. + +// pretty-expanded FIXME #23616 + +fn foo(x: T) -> T { x } + +struct F { field: isize } + +pub fn main() { + /*foo(1); + foo("hi".to_string()); + foo(vec![1, 2, 3]); + foo(F{field: 42}); + foo((1, 2)); + foo(@1);*/ + foo(Box::new(1)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-byte-str-cast.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-byte-str-cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-byte-str-cast.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-byte-str-cast.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[deny(warnings)] + +pub fn main() { + let _ = b"x" as &[u8]; + let _ = b"y" as &[u8; 1]; + let _ = b"z" as *const u8; + let _ = "ä" as *const str; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-cast-ptr-int.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-cast-ptr-int.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-cast-ptr-int.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-cast-ptr-int.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_upper_case_globals)] + +use std::ptr; + +struct TestStruct { + x: *const u8 +} + +unsafe impl Sync for TestStruct {} + +static a: TestStruct = TestStruct{x: 0 as *const u8}; + +pub fn main() { + assert_eq!(a.x, ptr::null()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-cast.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-cast.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-cast.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_upper_case_globals)] + +struct TestStruct { + x: *const u8, +} + +unsafe impl Sync for TestStruct {} + +extern fn foo() {} +const x: extern "C" fn() = foo; +static y: TestStruct = TestStruct { x: x as *const u8 }; + +pub fn main() { + assert_eq!(x as *const u8, y.x); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-const.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-const.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-const.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_upper_case_globals)] + +const a: isize = 1; +const b: isize = a + 2; + +pub fn main() { + assert_eq!(b, 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-contents.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-contents.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-contents.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-contents.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Issue #570 +#![allow(non_upper_case_globals)] + +static lsl : isize = 1 << 2; +static add : isize = 1 + 2; +static addf : f64 = 1.0 + 2.0; +static not : isize = !0; +static notb : bool = !true; +static neg : isize = -(1); + +pub fn main() { + assert_eq!(lsl, 4); + assert_eq!(add, 3); + assert_eq!(addf, 3.0); + assert_eq!(not, -1); + assert_eq!(notb, false); + assert_eq!(neg, -1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-cross-crate-const.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-cross-crate-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-cross-crate-const.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-cross-crate-const.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:cci_const.rs +#![allow(non_upper_case_globals)] + +extern crate cci_const; +static foo: &'static str = cci_const::foopy; +static a: usize = cci_const::uint_val; +static b: usize = cci_const::uint_expr + 5; + +pub fn main() { + assert_eq!(a, 12); + let foo2 = a; + assert_eq!(foo2, cci_const::uint_val); + assert_eq!(b, cci_const::uint_expr + 5); + assert_eq!(foo, cci_const::foopy); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-cross-crate-extern.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-cross-crate-extern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-cross-crate-extern.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-cross-crate-extern.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:cci_const.rs +#![allow(non_upper_case_globals)] + +extern crate cci_const; +use cci_const::bar; +static foo: extern "C" fn() = bar; + +pub fn main() { + assert!(foo == bar); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-deref.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-deref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-deref.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-deref.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +const C: &'static isize = &1000; +static D: isize = *C; + +pub fn main() { + assert_eq!(D, 1000); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-endianess.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-endianess.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-endianess.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-endianess.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(const_int_ops)] +#![feature(test)] + +extern crate test; +use test::black_box as b; + +const BE_U32: u32 = 55u32.to_be(); +const LE_U32: u32 = 55u32.to_le(); + + +fn main() { + assert_eq!(BE_U32, b(55u32).to_be()); + assert_eq!(LE_U32, b(55u32).to_le()); + + #[cfg(not(target_arch = "asmjs"))] + { + const BE_U128: u128 = 999999u128.to_be(); + const LE_I128: i128 = (-999999i128).to_le(); + assert_eq!(BE_U128, b(999999u128).to_be()); + assert_eq!(LE_I128, b(-999999i128).to_le()); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-byref.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-byref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-byref.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-byref.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +enum E { V, VV(isize) } +static C: E = E::V; + +fn f(a: &E) { + match *a { + E::V => {} + E::VV(..) => panic!() + } +} + +pub fn main() { + f(&C) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-byref-self.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-byref-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-byref-self.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-byref-self.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +enum E { V, VV(isize) } +static C: E = E::V; + +impl E { + pub fn method(&self) { + match *self { + E::V => {} + E::VV(..) => panic!() + } + } +} + +pub fn main() { + C.method() +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-cast.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-cast.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-cast.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_upper_case_globals)] + +enum A { A1, A2 } +enum B { B1=0, B2=2 } + +pub fn main () { + static c1: isize = A::A2 as isize; + static c2: isize = B::B2 as isize; + let a1 = A::A2 as isize; + let a2 = B::B2 as isize; + assert_eq!(c1, 1); + assert_eq!(c2, 2); + assert_eq!(a1, 1); + assert_eq!(a2, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-ptr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-ptr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-ptr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-ptr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +enum E { V0, V1(isize) } +static C: &'static E = &E::V0; + +pub fn main() { + match *C { + E::V0 => (), + _ => panic!() + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-struct2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-struct2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-struct2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-struct2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +enum E { V0, V16(u16) } +struct S { a: E, b: u16, c: u16 } +static C: S = S { a: E::V0, b: 0x600D, c: 0xBAD }; + +pub fn main() { + let n = C.b; + assert!(n != 0xBAD); + assert_eq!(n, 0x600D); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-structlike.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-structlike.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-structlike.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-structlike.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +enum E { + S0 { s: String }, + S1 { u: usize } +} + +static C: E = E::S1 { u: 23 }; + +pub fn main() { + match C { + E::S0 { .. } => panic!(), + E::S1 { u } => assert_eq!(u, 23) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +enum E { V16(u16), V32(u32) } +struct S { a: E, b: u16, c: u16 } +static C: S = S { a: E::V16(0xDEAD), b: 0x600D, c: 0xBAD }; + +pub fn main() { + let n = C.b; + assert!(n != 0xBAD); + assert_eq!(n, 0x600D); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-tuple2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-tuple2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-tuple2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-tuple2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +enum E { V0, V16(u16) } +static C: (E, u16, u16) = (E::V0, 0x600D, 0xBAD); + +pub fn main() { + let (_, n, _) = C; + assert!(n != 0xBAD); + assert_eq!(n, 0x600D); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-tuple.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-tuple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-tuple.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-tuple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +enum E { V16(u16), V32(u32) } +static C: (E, u16, u16) = (E::V16(0xDEAD), 0x600D, 0xBAD); + +pub fn main() { + let (_, n, _) = C; + assert!(n != 0xBAD); + assert_eq!(n, 0x600D); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-tuplestruct2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-tuplestruct2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-tuplestruct2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-tuplestruct2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +enum E { V0, V16(u16) } +struct S(E, u16, u16); +static C: S = S(E::V0, 0x600D, 0xBAD); + +pub fn main() { + let S(_, n, _) = C; + assert!(n != 0xBAD); + assert_eq!(n, 0x600D); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-tuplestruct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-tuplestruct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-tuplestruct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-tuplestruct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +enum E { V16(u16), V32(u32) } +struct S(E, u16, u16); +static C: S = S(E::V16(0xDEAD), 0x600D, 0xBAD); + +pub fn main() { + let S(_, n, _) = C; + assert!(n != 0xBAD); + assert_eq!(n, 0x600D); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-vec-index.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-vec-index.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-vec-index.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-vec-index.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(Copy, Clone)] +enum E { V1(isize), V0 } + +const C: &'static [E] = &[E::V0, E::V1(0xDEADBEE)]; +static C0: E = C[0]; +static C1: E = C[1]; +const D: &'static [E; 2] = &[E::V0, E::V1(0xDEAFBEE)]; +static D0: E = D[0]; +static D1: E = D[1]; + +pub fn main() { + match C0 { + E::V0 => (), + _ => panic!() + } + match C1 { + E::V1(n) => assert_eq!(n, 0xDEADBEE), + _ => panic!() + } + + match D0 { + E::V0 => (), + _ => panic!() + } + match D1 { + E::V1(n) => assert_eq!(n, 0xDEAFBEE), + _ => panic!() + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-vec-ptr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-vec-ptr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-vec-ptr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-vec-ptr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +enum E { V1(isize), V0 } +static C: &'static [E] = &[E::V0, E::V1(0xDEADBEE), E::V0]; + +pub fn main() { + match C[1] { + E::V1(n) => assert_eq!(n, 0xDEADBEE), + _ => panic!() + } + match C[2] { + E::V0 => (), + _ => panic!() + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-vector.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-vector.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-vector.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-enum-vector.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +enum E { V1(isize), V0 } +static C: [E; 3] = [E::V0, E::V1(0xDEADBEE), E::V0]; + +pub fn main() { + match C[1] { + E::V1(n) => assert_eq!(n, 0xDEADBEE), + _ => panic!() + } + match C[2] { + E::V0 => (), + _ => panic!() + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-err.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-err.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-err.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-err.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// check for const_err regressions + +#![deny(const_err)] + +const X: *const u8 = b"" as _; +const Y: bool = 'A' == 'B'; +const Z: char = 'A'; +const W: bool = Z <= 'B'; + + +fn main() { + let _ = ((-1 as i8) << 8 - 1) as f32; + let _ = 0u8 as char; + let _ = true > false; + let _ = true >= false; + let _ = true < false; + let _ = true >= false; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-expr-in-fixed-length-vec.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-expr-in-fixed-length-vec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-expr-in-fixed-length-vec.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-expr-in-fixed-length-vec.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Check that constant expressions can be used for declaring the +// type of a fixed length vector. + +// pretty-expanded FIXME #23616 + +pub fn main() { + + const FOO: usize = 2; + let _v: [isize; FOO*3]; + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-expr-in-vec-repeat.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-expr-in-vec-repeat.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-expr-in-vec-repeat.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-expr-in-vec-repeat.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Check that constant expressions can be used in vec repeat syntax. + +// pretty-expanded FIXME #23616 + +pub fn main() { + + const FOO: usize = 2; + let _v = [0; FOO*3*2/2]; + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-extern-function.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-extern-function.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-extern-function.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-extern-function.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_upper_case_globals)] + +extern fn foopy() {} + +static f: extern "C" fn() = foopy; +static s: S = S { f: foopy }; + +struct S { + f: extern "C" fn() +} + +pub fn main() { + assert!(foopy as extern "C" fn() == f); + assert!(f == s.f); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-fields-and-indexing.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-fields-and-indexing.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-fields-and-indexing.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-fields-and-indexing.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_upper_case_globals)] + +const x : [isize; 4] = [1,2,3,4]; +static p : isize = x[2]; +const y : &'static [isize] = &[1,2,3,4]; +static q : isize = y[2]; + +struct S {a: isize, b: isize} + +const s : S = S {a: 10, b: 20}; +static t : isize = s.b; + +struct K {a: isize, b: isize, c: D} +struct D { d: isize, e: isize } + +const k : K = K {a: 10, b: 20, c: D {d: 30, e: 40}}; +static m : isize = k.c.e; + +pub fn main() { + println!("{}", p); + println!("{}", q); + println!("{}", t); + assert_eq!(p, 3); + assert_eq!(q, 3); + assert_eq!(t, 20); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-const-eval.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-const-eval.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-const-eval.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-const-eval.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +const fn add(x: usize, y: usize) -> usize { + x + y +} + +const ARR: [i32; add(1, 2)] = [5, 6, 7]; + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-feature-flags.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-feature-flags.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-feature-flags.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-feature-flags.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test use of stabilized const fns in std formerly using individual feature gates. + +use std::cell::Cell; + +const CELL: Cell = Cell::new(42); + +fn main() { + let v = CELL.get(); + CELL.set(v+1); + + assert_eq!(CELL.get(), v); +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-method.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-method.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-method.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +struct Foo { value: u32 } + +impl Foo { + const fn new() -> Foo { + Foo { value: 22 } + } +} + +const FOO: Foo = Foo::new(); + +pub fn main() { + assert_eq!(FOO.value, 22); + let _: [&'static str; Foo::new().value as usize] = ["hey"; 22]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-nested.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-nested.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-nested.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-nested.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test a call whose argument is the result of another call. + +const fn sub(x: u32, y: u32) -> u32 { + x - y +} + +const X: u32 = sub(sub(88, 44), 22); + +fn main() { + assert_eq!(X, 22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,52 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(stable_features)] + +// A very basic test of const fn functionality. + +#![feature(const_fn, const_indexing)] + +const fn add(x: u32, y: u32) -> u32 { + x + y +} + +const fn sub(x: u32, y: u32) -> u32 { + x - y +} + +const unsafe fn div(x: u32, y: u32) -> u32 { + x / y +} + +const fn generic(t: T) -> T { + t +} + +const fn generic_arr(t: [T; 1]) -> T { + t[0] +} + +const SUM: u32 = add(44, 22); +const DIFF: u32 = sub(44, 22); +const DIV: u32 = unsafe{div(44, 22)}; + +fn main() { + assert_eq!(SUM, 66); + assert!(SUM != 88); + + assert_eq!(DIFF, 22); + assert_eq!(DIV, 2); + + let _: [&'static str; sub(100, 99) as usize] = ["hi"]; + let _: [&'static str; generic(1)] = ["hi"]; + let _: [&'static str; generic_arr([1])] = ["hi"]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-stability-calls.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-stability-calls.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-stability-calls.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-stability-calls.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// Test use of const fn from another crate without a feature gate. + +// aux-build:const_fn_lib.rs + +extern crate const_fn_lib; + +use const_fn_lib::foo; + +static FOO: usize = foo(); +const BAR: usize = foo(); + +macro_rules! constant { + ($n:ident: $t:ty = $v:expr) => { + const $n: $t = $v; + } +} + +constant! { + BAZ: usize = foo() +} + +fn main() { + let x: [usize; foo()] = [42; foo()]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-val.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-val.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-val.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-fn-val.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_upper_case_globals)] +#![allow(overflowing_literals)] + +fn foo() -> isize { + return 0xca7f000d; +} + +struct Bar where F: FnMut() -> isize { f: F } + +static mut b : Bar isize> = Bar { f: foo as fn() -> isize}; + +pub fn main() { + unsafe { assert_eq!((b.f)(), 0xca7f000d); } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-index-feature-gate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-index-feature-gate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-index-feature-gate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-index-feature-gate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +const ARR: [usize; 1] = [2]; +const ARR2: [i32; ARR[0]] = [5, 6]; + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-meth-pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-meth-pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-meth-pattern.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-meth-pattern.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +struct A; + +impl A { + const fn banana() -> bool { + true + } +} + +const ABANANA: bool = A::banana(); + +fn main() { + match true { + ABANANA => {}, + _ => panic!("what?") + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-negation.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-negation.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-negation.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-negation.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(overflowing_literals)] + +#[deny(const_err)] + +fn main() { + #[cfg(target_pointer_width = "32")] + const I: isize = -2147483648isize; + #[cfg(target_pointer_width = "64")] + const I: isize = -9223372036854775808isize; + assert_eq!(::std::i32::MIN as u64, 0xffffffff80000000); + assert_eq!(-2147483648isize as u64, 0xffffffff80000000); + assert_eq!(-2147483648i32 as u64, 0xffffffff80000000); + assert_eq!(::std::i64::MIN as u64, 0x8000000000000000); + #[cfg(target_pointer_width = "64")] + assert_eq!(-9223372036854775808isize as u64, 0x8000000000000000); + #[cfg(target_pointer_width = "32")] + assert_eq!(-9223372036854775808isize as u64, 0); + assert_eq!(-9223372036854775808i32 as u64, 0); + const J: usize = ::std::i32::MAX as usize; + const K: usize = -1i32 as u32 as usize; + const L: usize = ::std::i32::MIN as usize; + const M: usize = ::std::i64::MIN as usize; + match 5 { + J => {}, + K => {}, + L => {}, + M => {}, + _ => {} + } + match 5 { + I => {}, + _ => {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-negative.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-negative.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-negative.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-negative.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Issue #358 +#![allow(non_upper_case_globals)] + +static toplevel_mod: isize = -1; + +pub fn main() { + assert_eq!(toplevel_mod, -1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-nullary-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-nullary-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-nullary-enum.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-nullary-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +enum Foo { + Bar, + Baz, + Boo, +} + +static X: Foo = Foo::Bar; + +pub fn main() { + match X { + Foo::Bar => {} + Foo::Baz | Foo::Boo => panic!() + } + match Y { + Foo::Baz => {} + Foo::Bar | Foo::Boo => panic!() + } +} + +static Y: Foo = Foo::Baz; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-nullary-univariant-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-nullary-univariant-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-nullary-univariant-enum.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-nullary-univariant-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#[derive(Copy, Clone)] +enum Foo { + Bar = 0xDEADBEE +} + +static X: Foo = Foo::Bar; + +pub fn main() { + assert_eq!((X as usize), 0xDEADBEE); + assert_eq!((Y as usize), 0xDEADBEE); +} + +static Y: Foo = Foo::Bar; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-pattern-variant.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-pattern-variant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-pattern-variant.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-pattern-variant.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unreachable_patterns)] + +#[derive(PartialEq, Eq)] +enum Cake { + BlackForest, + Marmor, +} +use Cake::*; + +const BOO: (Cake, Cake) = (Marmor, BlackForest); +const FOO: Cake = BOO.1; + +const fn foo() -> Cake { + Marmor +} + +const WORKS: Cake = Marmor; + +const GOO: Cake = foo(); + +fn main() { + match BlackForest { + FOO => println!("hi"), + GOO => println!("meh"), + WORKS => println!("möp"), + _ => println!("bye"), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-rec-and-tup.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-rec-and-tup.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-rec-and-tup.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-rec-and-tup.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_upper_case_globals)] +#![allow(overflowing_literals)] + +struct Pair { a: f64, b: f64 } + +struct AnotherPair { x: (i64, i64), y: Pair } + +static x : (i32,i32) = (0xfeedf00dd,0xca11ab1e); +static y : AnotherPair = AnotherPair{ x: (0xf0f0f0f0_f0f0f0f0, + 0xabababab_abababab), + y: Pair { a: 3.14159265358979323846, + b: 2.7182818284590452354 }}; + +pub fn main() { + let (p, _) = y.x; + assert_eq!(p, - 1085102592571150096); + println!("{:#x}", p); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-region-ptrs-noncopy.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-region-ptrs-noncopy.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-region-ptrs-noncopy.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-region-ptrs-noncopy.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_upper_case_globals)] + +type Big = [u64; 8]; +struct Pair<'a> { a: isize, b: &'a Big } +const x: &'static Big = &([13, 14, 10, 13, 11, 14, 14, 15]); +const y: &'static Pair<'static> = &Pair {a: 15, b: x}; + +pub fn main() { + assert_eq!(x as *const Big, y.b as *const Big); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-region-ptrs.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-region-ptrs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-region-ptrs.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-region-ptrs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_upper_case_globals)] + +struct Pair<'a> { a: isize, b: &'a isize } + +const x: &'static isize = &10; + +const y: &'static Pair<'static> = &Pair {a: 15, b: x}; + +pub fn main() { + println!("x = {}", *x); + println!("y = {{a: {}, b: {}}}", y.a, *(y.b)); + assert_eq!(*x, 10); + assert_eq!(*(y.b), 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-repeated-values.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-repeated-values.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-repeated-values.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-repeated-values.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +const FOO: isize = 42; + +enum Bar { + Boo = *[&FOO; 4][3], +} + +fn main() { + assert_eq!(Bar::Boo as isize, 42); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_upper_case_globals)] + +static i: isize = 10; + +pub fn main() { println!("{}", i); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/consts-in-patterns.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/consts-in-patterns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/consts-in-patterns.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/consts-in-patterns.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +const FOO: isize = 10; +const BAR: isize = 3; + +const fn foo() -> isize { 4 } +const BOO: isize = foo(); + +pub fn main() { + let x: isize = 3; + let y = match x { + FOO => 1, + BAR => 2, + BOO => 4, + _ => 3 + }; + assert_eq!(y, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-size_of-align_of.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-size_of-align_of.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-size_of-align_of.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-size_of-align_of.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,61 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +use std::mem; + +// Get around the limitations of CTFE in today's Rust. +const fn choice_u64(c: bool, a: u64, b: u64) -> u64 { + (-(c as i64) as u64) & a | (-(!c as i64) as u64) & b +} + +const fn max_usize(a: usize, b: usize) -> usize { + choice_u64(a > b, a as u64, b as u64) as usize +} + +const fn align_to(size: usize, align: usize) -> usize { + (size + (align - 1)) & !(align - 1) +} + +const fn packed_union_size_of() -> usize { + max_usize(mem::size_of::(), mem::size_of::()) +} + +const fn union_align_of() -> usize { + max_usize(mem::align_of::(), mem::align_of::()) +} + +const fn union_size_of() -> usize { + align_to(packed_union_size_of::(), union_align_of::()) +} + +macro_rules! fake_union { + ($name:ident { $a:ty, $b:ty }) => ( + struct $name { + _align: ([$a; 0], [$b; 0]), + _bytes: [u8; union_size_of::<$a, $b>()] + } + ) +} + +// Check that we can (poorly) emulate unions by +// calling size_of and align_of at compile-time. +fake_union!(U { u16, [u8; 3] }); + +fn test(u: U) { + assert_eq!(mem::size_of_val(&u._bytes), 4); +} + +fn main() { + assert_eq!(mem::size_of::(), 4); + assert_eq!(mem::align_of::(), 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-str-ptr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-str-ptr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-str-ptr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-str-ptr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +use std::{str, string}; + +const A: [u8; 2] = ['h' as u8, 'i' as u8]; +const B: &'static [u8; 2] = &A; +const C: *const u8 = B as *const u8; + +pub fn main() { + unsafe { + let foo = &A as *const u8; + assert_eq!(foo, C); + assert_eq!(str::from_utf8_unchecked(&A), "hi"); + assert_eq!(*C, A[0]); + assert_eq!(*(&B[0] as *const u8), A[0]); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-struct-offsets.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-struct-offsets.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-struct-offsets.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-struct-offsets.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 +#![allow(non_upper_case_globals)] + +enum Foo { + IntVal(i32), + Int64Val(i64) +} + +struct Bar { + i: i32, + v: Foo +} + +static bar: Bar = Bar { i: 0, v: Foo::IntVal(0) }; + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] +#![allow(non_upper_case_globals)] + +use std::cmp; + +#[derive(Debug)] +struct foo { a: isize, b: isize, c: isize } + +impl cmp::PartialEq for foo { + fn eq(&self, other: &foo) -> bool { + (*self).a == (*other).a && + (*self).b == (*other).b && + (*self).c == (*other).c + } + fn ne(&self, other: &foo) -> bool { !(*self).eq(other) } +} + +const x : foo = foo { a:1, b:2, c: 3 }; +const y : foo = foo { b:2, c:3, a: 1 }; +const z : &'static foo = &foo { a: 10, b: 22, c: 12 }; +const w : foo = foo { a:5, ..x }; + +pub fn main() { + assert_eq!(x.b, 2); + assert_eq!(x, y); + assert_eq!(z.b, 22); + assert_eq!(w.a, 5); + assert_eq!(w.c, 3); + println!("{:#x}", x.b); + println!("{:#x}", z.c); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-trait-to-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-trait-to-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-trait-to-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-trait-to-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// Issue #24644 - block causes a &Trait -> &Trait coercion: +trait Trait {} + +struct Bar; +impl Trait for Bar {} + +fn main() { + let x: &[&Trait] = &[{ &Bar }]; +} + +// Issue #25748 - the cast causes an &Encoding -> &Encoding coercion: +pub struct UTF8Encoding; +pub const UTF_8: &'static UTF8Encoding = &UTF8Encoding; +pub trait Encoding {} +impl Encoding for UTF8Encoding {} +pub fn f() -> &'static Encoding { UTF_8 as &'static Encoding } + +// Root of the problem: &Trait -> &Trait coercions: +const FOO: &'static Trait = &Bar; +const BAR: &'static Trait = FOO; +fn foo() { let _x = BAR; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-tuple-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-tuple-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-tuple-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-tuple-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +struct Bar(isize, isize); + +static X: Bar = Bar(1, 2); + +pub fn main() { + match X { + Bar(x, y) => { + assert_eq!(x, 1); + assert_eq!(y, 2); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-typeid-of.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-typeid-of.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-typeid-of.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-typeid-of.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(core_intrinsics)] +#![feature(const_type_id)] + +use std::any::TypeId; + +struct A; + +static ID_ISIZE: TypeId = TypeId::of::(); + +pub fn main() { + assert_eq!(ID_ISIZE, TypeId::of::()); + + // sanity test of TypeId + const T: (TypeId, TypeId, TypeId) = (TypeId::of::(), + TypeId::of::<&'static str>(), + TypeId::of::()); + let (d, e, f) = (TypeId::of::(), TypeId::of::<&'static str>(), + TypeId::of::()); + + 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:: A) -> A>(), + TypeId::of:: A, A) -> A>()); + + assert!(F.0 != F.1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-unit-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-unit-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-unit-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-unit-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +struct Foo; + +static X: Foo = Foo; + +pub fn main() { + match X { + Foo => {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-unsafe-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-unsafe-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-unsafe-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-unsafe-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// A quick test of 'unsafe const fn' functionality + +const unsafe fn dummy(v: u32) -> u32 { + !v +} + +struct Type; +impl Type { + const unsafe fn new() -> Type { + Type + } +} + +const VAL: u32 = unsafe { dummy(0xFFFF) }; +const TYPE_INST: Type = unsafe { Type::new() }; + +fn main() { + assert_eq!(VAL, 0xFFFF0000); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-vec-of-fns.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-vec-of-fns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-vec-of-fns.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-vec-of-fns.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 +#![allow(non_upper_case_globals)] + +/*! + * Try to double-check that static fns have the right size (with or + * without dummy env ptr, as appropriate) by iterating a size-2 array. + * If the static size differs from the runtime size, the second element + * should be read as a null or otherwise wrong pointer and crash. + */ + +fn f() { } +static bare_fns: &'static [fn()] = &[f, f]; +struct S(F); +static mut closures: &'static mut [S] = &mut [S(f as fn()), S(f as fn())]; + +pub fn main() { + unsafe { + for &bare_fn in bare_fns { bare_fn() } + for closure in &mut *closures { + let S(ref mut closure) = *closure; + (*closure)() + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-vecs-and-slices.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-vecs-and-slices.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-vecs-and-slices.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-vecs-and-slices.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_upper_case_globals)] + +static x : [isize; 4] = [1,2,3,4]; +static y : &'static [isize] = &[1,2,3,4]; +static z : &'static [isize; 4] = &[1,2,3,4]; +static zz : &'static [isize] = &[1,2,3,4]; + +pub fn main() { + println!("{}", x[1]); + println!("{}", y[1]); + println!("{}", z[1]); + println!("{}", zz[1]); + assert_eq!(x[1], 2); + assert_eq!(x[3], 4); + assert_eq!(x[3], y[3]); + assert_eq!(z[1], 2); + assert_eq!(z[3], 4); + assert_eq!(z[3], y[3]); + assert_eq!(zz[1], 2); + assert_eq!(zz[3], 4); + assert_eq!(zz[3], y[3]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-vec-syntax.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-vec-syntax.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/consts/const-vec-syntax.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/consts/const-vec-syntax.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +fn f(_: &[isize]) {} + +pub fn main() { + let v = [ 1, 2, 3 ]; + f(&v); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/core-run-destroy.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/core-run-destroy.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/core-run-destroy.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/core-run-destroy.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_must_use)] +#![allow(stable_features)] +#![allow(deprecated)] +#![allow(unused_imports)] // compile-flags:--test // ignore-cloudabi no processes // ignore-emscripten no processes diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/anon-extern-mod-cross-crate-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/anon-extern-mod-cross-crate-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/anon-extern-mod-cross-crate-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/anon-extern-mod-cross-crate-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:anon-extern-mod-cross-crate-1.rs +// pretty-expanded FIXME #23616 +// ignore-wasm32-bare no libc to test ffi with + +extern crate anonexternmod; + +use anonexternmod::rust_get_test_int; + +pub fn main() { + unsafe { + rust_get_test_int(); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="anonexternmod"] +#![feature(libc)] + +extern crate libc; + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + pub fn rust_get_test_int() -> libc::intptr_t; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/anon_trait_static_method_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/anon_trait_static_method_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/anon_trait_static_method_lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/anon_trait_static_method_lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Foo { + pub x: isize +} + +impl Foo { + pub fn new() -> Foo { + Foo { x: 3 } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_borrow_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_borrow_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_borrow_lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_borrow_lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo(x: &usize) -> usize { + *x +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_capture_clause.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_capture_clause.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_capture_clause.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_capture_clause.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::thread; +use std::sync::mpsc::{Receiver, channel}; + +pub fn foo(x: T) -> Receiver { + let (tx, rx) = channel(); + thread::spawn(move|| { + tx.send(x.clone()); + }); + rx +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_const.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_const.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_const.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub extern fn bar() { +} + +pub const foopy: &'static str = "hi there"; +pub const uint_val: usize = 12; +pub const uint_expr: usize = (1 << uint_val) - 1; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_impl_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_impl_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_impl_lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_impl_lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="cci_impl_lib"] + +pub trait uint_helpers { + fn to(&self, v: usize, f: F) where F: FnMut(usize); +} + +impl uint_helpers for usize { + #[inline] + fn to(&self, v: usize, mut f: F) where F: FnMut(usize) { + let mut i = *self; + while i < v { + f(i); + i += 1; + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_iter_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_iter_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_iter_lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_iter_lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="cci_iter_lib"] + +#[inline] +pub fn iter(v: &[T], mut f: F) where F: FnMut(&T) { + let mut i = 0; + let n = v.len(); + while i < n { + f(&v[i]); + i += 1; + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_nested_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_nested_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_nested_lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_nested_lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,62 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] + +use std::cell::RefCell; + +pub struct Entry { + key: A, + value: B +} + +pub struct alist { + eq_fn: extern "Rust" fn(A,A) -> bool, + data: Box>>>, +} + +pub fn alist_add(lst: &alist, k: A, v: B) { + let mut data = lst.data.borrow_mut(); + (*data).push(Entry{key:k, value:v}); +} + +pub fn alist_get( + lst: &alist, + k: A) + -> B { + let eq_fn = lst.eq_fn; + let data = lst.data.borrow(); + for entry in &(*data) { + if eq_fn(entry.key.clone(), k.clone()) { + return entry.value.clone(); + } + } + panic!(); +} + +#[inline] +pub fn new_int_alist() -> alist { + fn eq_int(a: isize, b: isize) -> bool { a == b } + return alist { + eq_fn: eq_int, + data: box RefCell::new(Vec::new()), + }; +} + +#[inline] +pub fn new_int_alist_2() -> alist { + #[inline] + fn eq_int(a: isize, b: isize) -> bool { a == b } + return alist { + eq_fn: eq_int, + data: box RefCell::new(Vec::new()), + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_no_inline_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_no_inline_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_no_inline_lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/cci_no_inline_lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="cci_no_inline_lib"] + + +// same as cci_iter_lib, more-or-less, but not marked inline +pub fn iter(v: Vec , mut f: F) where F: FnMut(usize) { + let mut i = 0; + let n = v.len(); + while i < n { + f(v[i]); + i += 1; + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/moves_based_on_type_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/moves_based_on_type_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/moves_based_on_type_lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/moves_based_on_type_lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] + +pub struct S { + x: isize, +} + +impl Drop for S { + fn drop(&mut self) { + println!("goodbye"); + } +} + +pub fn f() { + let x = S { x: 1 }; + let y = x; + let _z = y; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/newtype_struct_xc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/newtype_struct_xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/newtype_struct_xc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/newtype_struct_xc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] + +pub struct Au(pub isize); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/pub_static_array.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/pub_static_array.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/pub_static_array.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/pub_static_array.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub static ARRAY: [u8; 1] = [1]; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/reexported_static_methods.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/reexported_static_methods.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/reexported_static_methods.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/reexported_static_methods.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,53 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub use sub_foo::Foo; +pub use self::Bar as Baz; +pub use sub_foo::Boz; +pub use sub_foo::Bort; + +pub trait Bar { + fn bar() -> Self; +} + +impl Bar for isize { + fn bar() -> isize { 84 } +} + +pub mod sub_foo { + pub trait Foo { + fn foo() -> Self; + } + + impl Foo for isize { + fn foo() -> isize { 42 } + } + + pub struct Boz { + unused_str: String + } + + impl Boz { + pub fn boz(i: isize) -> bool { + i > 0 + } + } + + pub enum Bort { + Bort1, + Bort2 + } + + impl Bort { + pub fn bort() -> String { + "bort()".to_string() + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate_address_insignificant.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate_address_insignificant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate_address_insignificant.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate_address_insignificant.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() -> isize { + static a: isize = 3; + a +} + +pub fn bar() -> isize { + foo::() +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate_associated_type_defaults.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate_associated_type_defaults.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate_associated_type_defaults.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate_associated_type_defaults.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(associated_type_defaults)] + +pub trait Foo { + type Out: Default + ToString = T; +} + +impl Foo for () { +} + +impl Foo for () { + type Out = bool; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate_generic_fn_nested_return.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate_generic_fn_nested_return.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate_generic_fn_nested_return.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate_generic_fn_nested_return.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Request { + pub id: String, + pub arg: String, +} + +pub fn decode() -> Result { + (|| { + Ok(Request { + id: "hi".to_owned(), + arg: match Err(()) { + Ok(v) => v, + Err(e) => return Err(e) + }, + }) + })() +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate_static_addresses.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate_static_addresses.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate_static_addresses.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate_static_addresses.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub static global: isize = 3; + +static global0: isize = 4; + +pub static global2: &'static isize = &global0; + +pub fn verify_same(a: &'static isize) { + let a = a as *const isize as usize; + let b = &global as *const isize as usize; + assert_eq!(a, b); +} + +pub fn verify_same2(a: &'static isize) { + let a = a as *const isize as usize; + let b = global2 as *const isize as usize; + assert_eq!(a, b); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate-trait-lifetime-param.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate-trait-lifetime-param.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate-trait-lifetime-param.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate-trait-lifetime-param.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait FromBuf<'a> { + fn from_buf(_: &'a [u8]) -> Self; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate_unit_struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate_unit_struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate_unit_struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/auxiliary/xcrate_unit_struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +// used by the rpass test + +#[derive(Copy, Clone)] +pub struct Struct; + +#[derive(Copy, Clone)] +pub enum Unit { + UnitVariant, + Argument(Struct) +} + +#[derive(Copy, Clone)] +pub struct TupleStruct(pub usize, pub &'static str); + +// used by the cfail test + +#[derive(Copy, Clone)] +pub struct StructWithFields { + foo: isize, +} + +#[derive(Copy, Clone)] +pub enum EnumWithVariants { + EnumVariant, + EnumVariantArg(isize) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_borrow.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_borrow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_borrow.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_borrow.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:cci_borrow_lib.rs + +#![feature(box_syntax)] + +extern crate cci_borrow_lib; +use cci_borrow_lib::foo; + +pub fn main() { + let p: Box<_> = box 22; + let r = foo(&*p); + println!("r={}", r); + assert_eq!(r, 22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_capture_clause.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_capture_clause.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_capture_clause.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_capture_clause.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:cci_capture_clause.rs + +// This test makes sure we can do cross-crate inlining on functions +// that use capture clauses. + +// pretty-expanded FIXME #23616 +// ignore-emscripten no threads support + +extern crate cci_capture_clause; + +pub fn main() { + cci_capture_clause::foo(()).recv().unwrap(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_impl_exe.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_impl_exe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_impl_exe.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_impl_exe.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:cci_impl_lib.rs + +extern crate cci_impl_lib; +use cci_impl_lib::uint_helpers; + +pub fn main() { + //let bt0 = sys::frame_address(); + //println!("%?", bt0); + + 3.to(10, |i| { + println!("{}", i); + + //let bt1 = sys::frame_address(); + //println!("%?", bt1); + //assert_eq!(bt0, bt1); + }) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_iter_exe.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_iter_exe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_iter_exe.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_iter_exe.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:cci_iter_lib.rs + +extern crate cci_iter_lib; + +pub fn main() { + //let bt0 = sys::rusti::frame_address(1); + //println!("%?", bt0); + cci_iter_lib::iter(&[1, 2, 3], |i| { + println!("{}", *i); + //assert_eq!(bt0, sys::rusti::frame_address(2)); + }) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_nested_exe.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_nested_exe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_nested_exe.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_nested_exe.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:cci_nested_lib.rs + + +extern crate cci_nested_lib; +use cci_nested_lib::*; + +pub fn main() { + let lst = new_int_alist(); + alist_add(&lst, 22, "hi".to_string()); + alist_add(&lst, 44, "ho".to_string()); + assert_eq!(alist_get(&lst, 22), "hi".to_string()); + assert_eq!(alist_get(&lst, 44), "ho".to_string()); + + let lst = new_int_alist_2(); + alist_add(&lst, 22, "hi".to_string()); + alist_add(&lst, 44, "ho".to_string()); + assert_eq!(alist_get(&lst, 22), "hi".to_string()); + assert_eq!(alist_get(&lst, 44), "ho".to_string()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_no_inline_exe.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_no_inline_exe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_no_inline_exe.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/cci_no_inline_exe.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:cci_no_inline_lib.rs + +extern crate cci_no_inline_lib; +use cci_no_inline_lib::iter; + +pub fn main() { + // Check that a cross-crate call function not marked as inline + // does not, in fact, get inlined. Also, perhaps more + // importantly, checks that our scheme of using + // sys::frame_address() to determine if we are inlining is + // actually working. + //let bt0 = sys::frame_address(); + //println!("%?", bt0); + iter(vec![1, 2, 3], |i| { + println!("{}", i); + + //let bt1 = sys::frame_address(); + //println!("%?", bt1); + + //assert!(bt0 != bt1); + }) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/cross-crate-const-pat.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/cross-crate-const-pat.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/cross-crate-const-pat.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/cross-crate-const-pat.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:cci_const.rs + +// pretty-expanded FIXME #23616 + +extern crate cci_const; + +pub fn main() { + let x = cci_const::uint_val; + match x { + cci_const::uint_val => {} + _ => {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/cross-crate-newtype-struct-pat.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/cross-crate-newtype-struct-pat.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/cross-crate-newtype-struct-pat.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/cross-crate-newtype-struct-pat.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:newtype_struct_xc.rs + + +extern crate newtype_struct_xc; + +pub fn main() { + let x = newtype_struct_xc::Au(21); + match x { + newtype_struct_xc::Au(n) => assert_eq!(n, 21) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/moves-based-on-type-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/moves-based-on-type-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/moves-based-on-type-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/moves-based-on-type-cross-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:moves_based_on_type_lib.rs + +// pretty-expanded FIXME #23616 + +extern crate moves_based_on_type_lib; +use moves_based_on_type_lib::f; + +pub fn main() { + f(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/reexported-static-methods-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/reexported-static-methods-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/reexported-static-methods-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/reexported-static-methods-cross-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:reexported_static_methods.rs + +extern crate reexported_static_methods; + +use reexported_static_methods::Foo; +use reexported_static_methods::Baz; +use reexported_static_methods::Boz; +use reexported_static_methods::Bort; + +pub fn main() { + assert_eq!(42_isize, Foo::foo()); + assert_eq!(84_isize, Baz::bar()); + assert!(Boz::boz(1)); + assert_eq!("bort()".to_string(), Bort::bort()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/static-array-across-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/static-array-across-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/static-array-across-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/static-array-across-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// aux-build:pub_static_array.rs + +extern crate pub_static_array as array; + +use array::ARRAY; + +static X: &'static u8 = &ARRAY[0]; +static Y: &'static u8 = &(&ARRAY)[0]; +static Z: u8 = (&ARRAY)[0]; + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate-address-insignificant.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate-address-insignificant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate-address-insignificant.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate-address-insignificant.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:xcrate_address_insignificant.rs + + +extern crate xcrate_address_insignificant as foo; + +pub fn main() { + assert_eq!(foo::foo::(), foo::bar()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate-associated-type-defaults.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate-associated-type-defaults.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate-associated-type-defaults.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate-associated-type-defaults.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:xcrate_associated_type_defaults.rs + +extern crate xcrate_associated_type_defaults; +use xcrate_associated_type_defaults::Foo; + +struct LocalDefault; +impl Foo for LocalDefault {} + +struct LocalOverride; +impl Foo for LocalOverride { + type Out = bool; +} + +fn main() { + assert_eq!( + <() as Foo>::Out::default().to_string(), + "0"); + assert_eq!( + <() as Foo>::Out::default().to_string(), + "false"); + + assert_eq!( + >::Out::default().to_string(), + "0"); + assert_eq!( + >::Out::default().to_string(), + "false"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate_generic_fn_nested_return.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate_generic_fn_nested_return.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate_generic_fn_nested_return.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate_generic_fn_nested_return.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:xcrate_generic_fn_nested_return.rs + +extern crate xcrate_generic_fn_nested_return as test; + +pub fn main() { + assert!(test::decode::<()>().is_err()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate-static-addresses.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate-static-addresses.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate-static-addresses.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate-static-addresses.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:xcrate_static_addresses.rs + +// pretty-expanded FIXME #23616 + +extern crate xcrate_static_addresses; + +use xcrate_static_addresses as other; + +pub fn main() { + other::verify_same(&other::global); + other::verify_same2(other::global2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate-trait-lifetime-param.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate-trait-lifetime-param.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate-trait-lifetime-param.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate-trait-lifetime-param.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// aux-build:xcrate-trait-lifetime-param.rs + +// pretty-expanded FIXME #23616 + +extern crate xcrate_trait_lifetime_param as other; + +struct Reader<'a> { + b : &'a [u8] +} + +impl <'a> other::FromBuf<'a> for Reader<'a> { + fn from_buf(b : &'a [u8]) -> Reader<'a> { + Reader { b : b } + } +} + +pub fn main () {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate-unit-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate-unit-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate-unit-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/cross-crate/xcrate-unit-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:xcrate_unit_struct.rs +// pretty-expanded FIXME #23616 +#![allow(non_upper_case_globals)] + +extern crate xcrate_unit_struct; + +const s1: xcrate_unit_struct::Struct = xcrate_unit_struct::Struct; +static s2: xcrate_unit_struct::Unit = xcrate_unit_struct::Unit::UnitVariant; +static s3: xcrate_unit_struct::Unit = + xcrate_unit_struct::Unit::Argument(xcrate_unit_struct::Struct); +static s4: xcrate_unit_struct::Unit = xcrate_unit_struct::Unit::Argument(s1); +static s5: xcrate_unit_struct::TupleStruct = xcrate_unit_struct::TupleStruct(20, "foo"); + +fn f1(_: xcrate_unit_struct::Struct) {} +fn f2(_: xcrate_unit_struct::Unit) {} +fn f3(_: xcrate_unit_struct::TupleStruct) {} + +pub fn main() { + f1(xcrate_unit_struct::Struct); + f2(xcrate_unit_struct::Unit::UnitVariant); + f2(xcrate_unit_struct::Unit::Argument(xcrate_unit_struct::Struct)); + f3(xcrate_unit_struct::TupleStruct(10, "bar")); + + f1(s1); + f2(s2); + f2(s3); + f2(s4); + f3(s5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/crt-static-off-works.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/crt-static-off-works.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/crt-static-off-works.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/crt-static-off-works.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(stable_features)] // compile-flags:-C target-feature=-crt-static -Z unstable-options // ignore-musl - requires changing the linker which is hard diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/crt-static-on-works.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/crt-static-on-works.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/crt-static-on-works.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/crt-static-on-works.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(stable_features)] // compile-flags:-C target-feature=+crt-static -Z unstable-options #![feature(cfg_target_feature)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/assoc-const.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/assoc-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/assoc-const.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/assoc-const.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] + +trait Nat { + const VALUE: usize; +} + +struct Zero; +struct Succ(N); + +impl Nat for Zero { + const VALUE: usize = 0; +} + +impl Nat for Succ { + const VALUE: usize = N::VALUE + 1; +} + +fn main() { + let x: [i32; >>>>::VALUE] = [1, 2, 3, 4]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/bswap-const.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/bswap-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/bswap-const.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/bswap-const.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(core_intrinsics)] + +use std::intrinsics; + +const SWAPPED_U8: u8 = unsafe { intrinsics::bswap(0x12_u8) }; +const SWAPPED_U16: u16 = unsafe { intrinsics::bswap(0x12_34_u16) }; +const SWAPPED_I32: i32 = unsafe { intrinsics::bswap(0x12_34_56_78_i32) }; + +fn main() { + assert_eq!(SWAPPED_U8, 0x12); + assert_eq!(SWAPPED_U16, 0x34_12); + assert_eq!(SWAPPED_I32, 0x78_56_34_12); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/chained-constants-stackoverflow.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/chained-constants-stackoverflow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/chained-constants-stackoverflow.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/chained-constants-stackoverflow.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,366 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// https://github.com/rust-lang/rust/issues/34997 + +pub const CST_1: u32 = 0; +pub const CST_2: u32 = CST_1+1; +pub const CST_3: u32 = CST_2+1; +pub const CST_4: u32 = CST_3+1; +pub const CST_5: u32 = CST_4+1; +pub const CST_6: u32 = CST_5+1; +pub const CST_7: u32 = CST_6+1; +pub const CST_8: u32 = CST_7+1; +pub const CST_9: u32 = CST_8+1; +pub const CST_10: u32 = CST_9+1; +pub const CST_11: u32 = CST_10+1; +pub const CST_12: u32 = CST_11+1; +pub const CST_13: u32 = CST_12+1; +pub const CST_14: u32 = CST_13+1; +pub const CST_15: u32 = CST_14+1; +pub const CST_16: u32 = CST_15+1; +pub const CST_17: u32 = CST_16+1; +pub const CST_18: u32 = CST_17+1; +pub const CST_19: u32 = CST_18+1; +pub const CST_20: u32 = CST_19+1; +pub const CST_21: u32 = CST_20+1; +pub const CST_22: u32 = CST_21+1; +pub const CST_23: u32 = CST_22+1; +pub const CST_24: u32 = CST_23+1; +pub const CST_25: u32 = CST_24+1; +pub const CST_26: u32 = CST_25+1; +pub const CST_27: u32 = CST_26+1; +pub const CST_28: u32 = CST_27+1; +pub const CST_29: u32 = CST_28+1; +pub const CST_30: u32 = CST_29+1; +pub const CST_31: u32 = CST_30+1; +pub const CST_32: u32 = CST_31+1; +pub const CST_33: u32 = CST_32+1; +pub const CST_34: u32 = CST_33+1; +pub const CST_35: u32 = CST_34+1; +pub const CST_36: u32 = CST_35+1; +pub const CST_37: u32 = CST_36+1; +pub const CST_38: u32 = CST_37+1; +pub const CST_39: u32 = CST_38+1; +pub const CST_40: u32 = CST_39+1; +pub const CST_41: u32 = CST_40+1; +pub const CST_42: u32 = CST_41+1; +pub const CST_43: u32 = CST_42+1; +pub const CST_44: u32 = CST_43+1; +pub const CST_45: u32 = CST_44+1; +pub const CST_46: u32 = CST_45+1; +pub const CST_47: u32 = CST_46+1; +pub const CST_48: u32 = CST_47+1; +pub const CST_49: u32 = CST_48+1; +pub const CST_50: u32 = CST_49+1; +pub const CST_51: u32 = CST_50+1; +pub const CST_52: u32 = CST_51+1; +pub const CST_53: u32 = CST_52+1; +pub const CST_54: u32 = CST_53+1; +pub const CST_55: u32 = CST_54+1; +pub const CST_56: u32 = CST_55+1; +pub const CST_57: u32 = CST_56+1; +pub const CST_58: u32 = CST_57+1; +pub const CST_59: u32 = CST_58+1; +pub const CST_60: u32 = CST_59+1; +pub const CST_61: u32 = CST_60+1; +pub const CST_62: u32 = CST_61+1; +pub const CST_63: u32 = CST_62+1; +pub const CST_64: u32 = CST_63+1; +pub const CST_65: u32 = CST_64+1; +pub const CST_66: u32 = CST_65+1; +pub const CST_67: u32 = CST_66+1; +pub const CST_68: u32 = CST_67+1; +pub const CST_69: u32 = CST_68+1; +pub const CST_70: u32 = CST_69+1; +pub const CST_71: u32 = CST_70+1; +pub const CST_72: u32 = CST_71+1; +pub const CST_73: u32 = CST_72+1; +pub const CST_74: u32 = CST_73+1; +pub const CST_75: u32 = CST_74+1; +pub const CST_76: u32 = CST_75+1; +pub const CST_77: u32 = CST_76+1; +pub const CST_78: u32 = CST_77+1; +pub const CST_79: u32 = CST_78+1; +pub const CST_80: u32 = CST_79+1; +pub const CST_81: u32 = CST_80+1; +pub const CST_82: u32 = CST_81+1; +pub const CST_83: u32 = CST_82+1; +pub const CST_84: u32 = CST_83+1; +pub const CST_85: u32 = CST_84+1; +pub const CST_86: u32 = CST_85+1; +pub const CST_87: u32 = CST_86+1; +pub const CST_88: u32 = CST_87+1; +pub const CST_89: u32 = CST_88+1; +pub const CST_90: u32 = CST_89+1; +pub const CST_91: u32 = CST_90+1; +pub const CST_92: u32 = CST_91+1; +pub const CST_93: u32 = CST_92+1; +pub const CST_94: u32 = CST_93+1; +pub const CST_95: u32 = CST_94+1; +pub const CST_96: u32 = CST_95+1; +pub const CST_97: u32 = CST_96+1; +pub const CST_98: u32 = CST_97+1; +pub const CST_99: u32 = CST_98+1; +pub const CST_100: u32 = CST_99+1; +pub const CST_101: u32 = CST_100+1; +pub const CST_102: u32 = CST_101+1; +pub const CST_103: u32 = CST_102+1; +pub const CST_104: u32 = CST_103+1; +pub const CST_105: u32 = CST_104+1; +pub const CST_106: u32 = CST_105+1; +pub const CST_107: u32 = CST_106+1; +pub const CST_108: u32 = CST_107+1; +pub const CST_109: u32 = CST_108+1; +pub const CST_110: u32 = CST_109+1; +pub const CST_111: u32 = CST_110+1; +pub const CST_112: u32 = CST_111+1; +pub const CST_113: u32 = CST_112+1; +pub const CST_114: u32 = CST_113+1; +pub const CST_115: u32 = CST_114+1; +pub const CST_116: u32 = CST_115+1; +pub const CST_117: u32 = CST_116+1; +pub const CST_118: u32 = CST_117+1; +pub const CST_119: u32 = CST_118+1; +pub const CST_120: u32 = CST_119+1; +pub const CST_121: u32 = CST_120+1; +pub const CST_122: u32 = CST_121+1; +pub const CST_123: u32 = CST_122+1; +pub const CST_124: u32 = CST_123+1; +pub const CST_125: u32 = CST_124+1; +pub const CST_126: u32 = CST_125+1; +pub const CST_127: u32 = CST_126+1; +pub const CST_128: u32 = CST_127+1; +pub const CST_129: u32 = CST_128+1; +pub const CST_130: u32 = CST_129+1; +pub const CST_131: u32 = CST_130+1; +pub const CST_132: u32 = CST_131+1; +pub const CST_133: u32 = CST_132+1; +pub const CST_134: u32 = CST_133+1; +pub const CST_135: u32 = CST_134+1; +pub const CST_136: u32 = CST_135+1; +pub const CST_137: u32 = CST_136+1; +pub const CST_138: u32 = CST_137+1; +pub const CST_139: u32 = CST_138+1; +pub const CST_140: u32 = CST_139+1; +pub const CST_141: u32 = CST_140+1; +pub const CST_142: u32 = CST_141+1; +pub const CST_143: u32 = CST_142+1; +pub const CST_144: u32 = CST_143+1; +pub const CST_145: u32 = CST_144+1; +pub const CST_146: u32 = CST_145+1; +pub const CST_147: u32 = CST_146+1; +pub const CST_148: u32 = CST_147+1; +pub const CST_149: u32 = CST_148+1; +pub const CST_150: u32 = CST_149+1; +pub const CST_151: u32 = CST_150+1; +pub const CST_152: u32 = CST_151+1; +pub const CST_153: u32 = CST_152+1; +pub const CST_154: u32 = CST_153+1; +pub const CST_155: u32 = CST_154+1; +pub const CST_156: u32 = CST_155+1; +pub const CST_157: u32 = CST_156+1; +pub const CST_158: u32 = CST_157+1; +pub const CST_159: u32 = CST_158+1; +pub const CST_160: u32 = CST_159+1; +pub const CST_161: u32 = CST_160+1; +pub const CST_162: u32 = CST_161+1; +pub const CST_163: u32 = CST_162+1; +pub const CST_164: u32 = CST_163+1; +pub const CST_165: u32 = CST_164+1; +pub const CST_166: u32 = CST_165+1; +pub const CST_167: u32 = CST_166+1; +pub const CST_168: u32 = CST_167+1; +pub const CST_169: u32 = CST_168+1; +pub const CST_170: u32 = CST_169+1; +pub const CST_171: u32 = CST_170+1; +pub const CST_172: u32 = CST_171+1; +pub const CST_173: u32 = CST_172+1; +pub const CST_174: u32 = CST_173+1; +pub const CST_175: u32 = CST_174+1; +pub const CST_176: u32 = CST_175+1; +pub const CST_177: u32 = CST_176+1; +pub const CST_178: u32 = CST_177+1; +pub const CST_179: u32 = CST_178+1; +pub const CST_180: u32 = CST_179+1; +pub const CST_181: u32 = CST_180+1; +pub const CST_182: u32 = CST_181+1; +pub const CST_183: u32 = CST_182+1; +pub const CST_184: u32 = CST_183+1; +pub const CST_185: u32 = CST_184+1; +pub const CST_186: u32 = CST_185+1; +pub const CST_187: u32 = CST_186+1; +pub const CST_188: u32 = CST_187+1; +pub const CST_189: u32 = CST_188+1; +pub const CST_190: u32 = CST_189+1; +pub const CST_191: u32 = CST_190+1; +pub const CST_192: u32 = CST_191+1; +pub const CST_193: u32 = CST_192+1; +pub const CST_194: u32 = CST_193+1; +pub const CST_195: u32 = CST_194+1; +pub const CST_196: u32 = CST_195+1; +pub const CST_197: u32 = CST_196+1; +pub const CST_198: u32 = CST_197+1; +pub const CST_199: u32 = CST_198+1; +pub const CST_200: u32 = CST_199+1; +pub const CST_201: u32 = CST_200+1; +pub const CST_202: u32 = CST_201+1; +pub const CST_203: u32 = CST_202+1; +pub const CST_204: u32 = CST_203+1; +pub const CST_205: u32 = CST_204+1; +pub const CST_206: u32 = CST_205+1; +pub const CST_207: u32 = CST_206+1; +pub const CST_208: u32 = CST_207+1; +pub const CST_209: u32 = CST_208+1; +pub const CST_210: u32 = CST_209+1; +pub const CST_211: u32 = CST_210+1; +pub const CST_212: u32 = CST_211+1; +pub const CST_213: u32 = CST_212+1; +pub const CST_214: u32 = CST_213+1; +pub const CST_215: u32 = CST_214+1; +pub const CST_216: u32 = CST_215+1; +pub const CST_217: u32 = CST_216+1; +pub const CST_218: u32 = CST_217+1; +pub const CST_219: u32 = CST_218+1; +pub const CST_220: u32 = CST_219+1; +pub const CST_221: u32 = CST_220+1; +pub const CST_222: u32 = CST_221+1; +pub const CST_223: u32 = CST_222+1; +pub const CST_224: u32 = CST_223+1; +pub const CST_225: u32 = CST_224+1; +pub const CST_226: u32 = CST_225+1; +pub const CST_227: u32 = CST_226+1; +pub const CST_228: u32 = CST_227+1; +pub const CST_229: u32 = CST_228+1; +pub const CST_230: u32 = CST_229+1; +pub const CST_231: u32 = CST_230+1; +pub const CST_232: u32 = CST_231+1; +pub const CST_233: u32 = CST_232+1; +pub const CST_234: u32 = CST_233+1; +pub const CST_235: u32 = CST_234+1; +pub const CST_236: u32 = CST_235+1; +pub const CST_237: u32 = CST_236+1; +pub const CST_238: u32 = CST_237+1; +pub const CST_239: u32 = CST_238+1; +pub const CST_240: u32 = CST_239+1; +pub const CST_241: u32 = CST_240+1; +pub const CST_242: u32 = CST_241+1; +pub const CST_243: u32 = CST_242+1; +pub const CST_244: u32 = CST_243+1; +pub const CST_245: u32 = CST_244+1; +pub const CST_246: u32 = CST_245+1; +pub const CST_247: u32 = CST_246+1; +pub const CST_248: u32 = CST_247+1; +pub const CST_249: u32 = CST_248+1; +pub const CST_250: u32 = CST_249+1; +pub const CST_251: u32 = CST_250+1; +pub const CST_252: u32 = CST_251+1; +pub const CST_253: u32 = CST_252+1; +pub const CST_254: u32 = CST_253+1; +pub const CST_255: u32 = CST_254+1; +pub const CST_256: u32 = CST_255+1; +pub const CST_257: u32 = CST_256+1; +pub const CST_258: u32 = CST_257+1; +pub const CST_259: u32 = CST_258+1; +pub const CST_260: u32 = CST_259+1; +pub const CST_261: u32 = CST_260+1; +pub const CST_262: u32 = CST_261+1; +pub const CST_263: u32 = CST_262+1; +pub const CST_264: u32 = CST_263+1; +pub const CST_265: u32 = CST_264+1; +pub const CST_266: u32 = CST_265+1; +pub const CST_267: u32 = CST_266+1; +pub const CST_268: u32 = CST_267+1; +pub const CST_269: u32 = CST_268+1; +pub const CST_270: u32 = CST_269+1; +pub const CST_271: u32 = CST_270+1; +pub const CST_272: u32 = CST_271+1; +pub const CST_273: u32 = CST_272+1; +pub const CST_274: u32 = CST_273+1; +pub const CST_275: u32 = CST_274+1; +pub const CST_276: u32 = CST_275+1; +pub const CST_277: u32 = CST_276+1; +pub const CST_278: u32 = CST_277+1; +pub const CST_279: u32 = CST_278+1; +pub const CST_280: u32 = CST_279+1; +pub const CST_281: u32 = CST_280+1; +pub const CST_282: u32 = CST_281+1; +pub const CST_283: u32 = CST_282+1; +pub const CST_284: u32 = CST_283+1; +pub const CST_285: u32 = CST_284+1; +pub const CST_286: u32 = CST_285+1; +pub const CST_287: u32 = CST_286+1; +pub const CST_288: u32 = CST_287+1; +pub const CST_289: u32 = CST_288+1; +pub const CST_290: u32 = CST_289+1; +pub const CST_291: u32 = CST_290+1; +pub const CST_292: u32 = CST_291+1; +pub const CST_293: u32 = CST_292+1; +pub const CST_294: u32 = CST_293+1; +pub const CST_295: u32 = CST_294+1; +pub const CST_296: u32 = CST_295+1; +pub const CST_297: u32 = CST_296+1; +pub const CST_298: u32 = CST_297+1; +pub const CST_299: u32 = CST_298+1; +pub const CST_300: u32 = CST_299+1; +pub const CST_301: u32 = CST_300+1; +pub const CST_302: u32 = CST_301+1; +pub const CST_303: u32 = CST_302+1; +pub const CST_304: u32 = CST_303+1; +pub const CST_305: u32 = CST_304+1; +pub const CST_306: u32 = CST_305+1; +pub const CST_307: u32 = CST_306+1; +pub const CST_308: u32 = CST_307+1; +pub const CST_309: u32 = CST_308+1; +pub const CST_310: u32 = CST_309+1; +pub const CST_311: u32 = CST_310+1; +pub const CST_312: u32 = CST_311+1; +pub const CST_313: u32 = CST_312+1; +pub const CST_314: u32 = CST_313+1; +pub const CST_315: u32 = CST_314+1; +pub const CST_316: u32 = CST_315+1; +pub const CST_317: u32 = CST_316+1; +pub const CST_318: u32 = CST_317+1; +pub const CST_319: u32 = CST_318+1; +pub const CST_320: u32 = CST_319+1; +pub const CST_321: u32 = CST_320+1; +pub const CST_322: u32 = CST_321+1; +pub const CST_323: u32 = CST_322+1; +pub const CST_324: u32 = CST_323+1; +pub const CST_325: u32 = CST_324+1; +pub const CST_326: u32 = CST_325+1; +pub const CST_327: u32 = CST_326+1; +pub const CST_328: u32 = CST_327+1; +pub const CST_329: u32 = CST_328+1; +pub const CST_330: u32 = CST_329+1; +pub const CST_331: u32 = CST_330+1; +pub const CST_332: u32 = CST_331+1; +pub const CST_333: u32 = CST_332+1; +pub const CST_334: u32 = CST_333+1; +pub const CST_335: u32 = CST_334+1; +pub const CST_336: u32 = CST_335+1; +pub const CST_337: u32 = CST_336+1; +pub const CST_338: u32 = CST_337+1; +pub const CST_339: u32 = CST_338+1; +pub const CST_340: u32 = CST_339+1; +pub const CST_341: u32 = CST_340+1; +pub const CST_342: u32 = CST_341+1; +pub const CST_343: u32 = CST_342+1; +pub const CST_344: u32 = CST_343+1; +pub const CST_345: u32 = CST_344+1; +pub const CST_346: u32 = CST_345+1; +pub const CST_347: u32 = CST_346+1; +pub const CST_348: u32 = CST_347+1; +pub const CST_349: u32 = CST_348+1; +pub const CST_350: u32 = CST_349+1; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/const-block-non-item-statement-3.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/const-block-non-item-statement-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/const-block-non-item-statement-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/const-block-non-item-statement-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +#![feature(const_let)] + +type Array = [u32; { let x = 2; 5 }]; + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/const-block-non-item-statement.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/const-block-non-item-statement.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/const-block-non-item-statement.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/const-block-non-item-statement.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +#![feature(const_let)] + +enum Foo { + Bar = { let x = 1; 3 } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/const-fn-destructuring-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/const-fn-destructuring-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/const-fn-destructuring-arg.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/const-fn-destructuring-arg.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +// test that certain things are disallowed in constant functions + +#![feature(const_fn, const_let)] + +// no destructuring +const fn i(( + a, + b + ): (u32, u32)) -> u32 { + a + b +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/deref_in_pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/deref_in_pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/deref_in_pattern.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/deref_in_pattern.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// https://github.com/rust-lang/rust/issues/25574 + +const A: [u8; 4] = *b"fooo"; + +fn main() { + match *b"xxxx" { + A => {}, + _ => {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/ice-48279.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/ice-48279.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/ice-48279.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/ice-48279.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_unsafe)] + +// https://github.com/rust-lang/rust/issues/48279 + +#[derive(PartialEq, Eq)] +pub struct NonZeroU32 { + value: u32 +} + +impl NonZeroU32 { + const unsafe fn new_unchecked(value: u32) -> Self { + NonZeroU32 { value } + } +} + +//pub const FOO_ATOM: NonZeroU32 = unsafe { NonZeroU32::new_unchecked(7) }; +pub const FOO_ATOM: NonZeroU32 = unsafe { NonZeroU32 { value: 7 } }; + +fn main() { + match None { + Some(FOO_ATOM) => {} + _ => {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/issue-37550.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/issue-37550.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/issue-37550.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/issue-37550.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] + +#![feature(const_fn, const_let)] + +const fn x() { + let t = true; + let x = || t; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/issue-broken-mir.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/issue-broken-mir.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/issue-broken-mir.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/issue-broken-mir.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// https://github.com/rust-lang/rust/issues/27918 + +fn main() { + match b" " { + b"1234" => {}, + _ => {}, + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/locals-in-const-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/locals-in-const-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/locals-in-const-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/locals-in-const-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// https://github.com/rust-lang/rust/issues/48821 + +#![feature(const_fn, const_let)] + +const fn foo(i: usize) -> usize { + let x = i; + x +} + +static FOO: usize = foo(42); + +const fn bar(mut i: usize) -> usize { + i += 8; + let x = &i; + *x +} + +static BAR: usize = bar(42); + +const fn boo(mut i: usize) -> usize { + { + let mut x = i; + x += 10; + i = x; + } + i +} + +static BOO: usize = boo(42); + +fn main() { + assert!(FOO == 42); + assert!(BAR == 50); + assert!(BOO == 52); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/match-const-fn-structs.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/match-const-fn-structs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/match-const-fn-structs.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/match-const-fn-structs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] + +// https://github.com/rust-lang/rust/issues/46114 + +#[derive(Eq, PartialEq)] +struct A { value: u32 } + +const fn new(value: u32) -> A { + A { value } +} + +const A_1: A = new(1); +const A_2: A = new(2); + +fn main() { + let a_str = match new(42) { + A_1 => "A 1", + A_2 => "A 2", + _ => "Unknown A", + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/mozjs-error.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/mozjs-error.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/mozjs-error.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/mozjs-error.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_upper_case_globals)] + +struct CustomAutoRooterVFTable { + trace: unsafe extern "C" fn(this: *mut i32, trc: *mut u32), +} + +unsafe trait CustomAutoTraceable: Sized { + const vftable: CustomAutoRooterVFTable = CustomAutoRooterVFTable { + trace: Self::trace, + }; + + unsafe extern "C" fn trace(this: *mut i32, trc: *mut u32) { + let this = this as *const Self; + let this = this.as_ref().unwrap(); + Self::do_trace(this, trc); + } + + fn do_trace(&self, trc: *mut u32); +} + +unsafe impl CustomAutoTraceable for () { + fn do_trace(&self, _: *mut u32) { + // nop + } +} + +fn main() { + let _ = <()>::vftable; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/non-scalar-cast.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/non-scalar-cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/non-scalar-cast.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/non-scalar-cast.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// https://github.com/rust-lang/rust/issues/37448 + +fn main() { + struct A; + const FOO: &A = &(A as A); + let _x = FOO; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/promotion.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/promotion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/promotion.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/promotion.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// compile-flags: -O + +fn foo(_: &'static [&'static str]) {} +fn bar(_: &'static [&'static str; 3]) {} +fn baz_i32(_: &'static i32) {} +fn baz_u32(_: &'static u32) {} + +fn main() { + foo(&["a", "b", "c"]); + bar(&["d", "e", "f"]); + + // make sure that these do not cause trouble despite overflowing + baz_u32(&(0-1)); + baz_i32(&-std::i32::MIN); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/references.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/references.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/references.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/references.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +const FOO: &[u8] = b"foo"; +const BAR: &[u8] = &[1, 2, 3]; + +const BOO: &i32 = &42; + +fn main() { + match &[1u8, 2, 3] as &[u8] { + FOO => panic!("a"), + BAR => println!("b"), + _ => panic!("c"), + } + + match b"foo" as &[u8] { + FOO => println!("a"), + BAR => panic!("b"), + _ => panic!("c"), + } + + match &43 { + &42 => panic!(), + BOO => panic!(), + _ => println!("d"), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/repeat_match.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/repeat_match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/repeat_match.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/repeat_match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// https://github.com/rust-lang/rust/issues/45044 + +const X: [u8; 1] = [0; 1]; + +fn main() { + match &X { + &X => println!("a"), + _ => println!("b"), + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/return-in-const-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/return-in-const-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/return-in-const-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/return-in-const-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// https://github.com/rust-lang/rust/issues/43754 + +const fn foo(x: usize) -> usize { + return x; +} +fn main() { + [0; foo(2)]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/signed_enum_discr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/signed_enum_discr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/signed_enum_discr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/signed_enum_discr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// https://github.com/rust-lang/rust/issues/49181 + +#[derive(Eq, PartialEq)] +#[repr(i8)] +pub enum A { + B = -1, + C = 1, +} + +pub const D: A = A::B; + +fn main() { + match A::C { + D => {}, + _ => {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/transmute-const.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/transmute-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/transmute-const.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/transmute-const.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(const_transmute)] + +use std::mem; + +#[repr(transparent)] +struct Foo(u32); + +const TRANSMUTED_U32: u32 = unsafe { mem::transmute(Foo(3)) }; + +fn main() { + assert_eq!(TRANSMUTED_U32, 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/tuple-struct-constructors.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/tuple-struct-constructors.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ctfe/tuple-struct-constructors.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ctfe/tuple-struct-constructors.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// https://github.com/rust-lang/rust/issues/41898 + +use std::num::NonZeroU64; + +fn main() { + const FOO: NonZeroU64 = unsafe { NonZeroU64::new_unchecked(2) }; + if let FOO = FOO {} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/default-method-simple.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/default-method-simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/default-method-simple.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/default-method-simple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] trait Foo { fn f(&self) { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/defaults-well-formedness.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/defaults-well-formedness.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/defaults-well-formedness.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/defaults-well-formedness.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] trait Trait {} struct Foo(U, V) where U: Trait; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/auxiliary/derive-no-std.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/auxiliary/derive-no-std.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/auxiliary/derive-no-std.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/auxiliary/derive-no-std.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "rlib"] +#![no_std] + +// Issue #16803 + +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord, + Debug, Default, Copy)] +pub struct Foo { + pub x: u32, +} + +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord, + Debug, Copy)] +pub enum Bar { + Qux, + Quux(u32), +} + +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord, + Debug, Copy)] +pub enum Void {} +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord, + Debug, Copy)] +pub struct Empty; +#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord, + Debug, Copy)] +pub struct AlsoEmpty {} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/derive-no-std.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/derive-no-std.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/derive-no-std.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/derive-no-std.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:derive-no-std.rs + +extern crate derive_no_std; +use derive_no_std::*; + +fn main() { + let f = Foo { x: 0 }; + assert_eq!(f.clone(), Foo::default()); + + assert!(Bar::Qux < Bar::Quux(42)); +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/derive-partialord-correctness.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/derive-partialord-correctness.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/derive-partialord-correctness.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/derive-partialord-correctness.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Original issue: #49650 + +#[derive(PartialOrd, PartialEq)] +struct FloatWrapper(f64); + +fn main() { + assert!((0.0 / 0.0 >= 0.0) == (FloatWrapper(0.0 / 0.0) >= FloatWrapper(0.0))) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-associated-types.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-associated-types.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-associated-types.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-associated-types.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,209 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub trait DeclaredTrait { + type Type; +} + +impl DeclaredTrait for i32 { + type Type = i32; +} + +pub trait WhereTrait { + type Type; +} + +impl WhereTrait for i32 { + type Type = i32; +} + +// Make sure we don't add a bound that just shares a name with an associated +// type. +pub mod module { + pub type Type = i32; +} + +#[derive(PartialEq, Debug)] +struct PrivateStruct(T); + +#[derive(PartialEq, Debug)] +struct TupleStruct( + module::Type, + Option, + A, + PrivateStruct, + B, + B::Type, + Option, + ::Type, + Option<::Type>, + C, + C::Type, + Option, + ::Type, + Option<::Type>, + ::Type, +) where C: WhereTrait; + +#[derive(PartialEq, Debug)] +pub struct Struct where C: WhereTrait { + m1: module::Type, + m2: Option, + a1: A, + a2: PrivateStruct, + b: B, + b1: B::Type, + b2: Option, + b3: ::Type, + b4: Option<::Type>, + c: C, + c1: C::Type, + c2: Option, + c3: ::Type, + c4: Option<::Type>, + d: ::Type, +} + +#[derive(PartialEq, Debug)] +enum Enum where C: WhereTrait { + Unit, + Seq( + module::Type, + Option, + A, + PrivateStruct, + B, + B::Type, + Option, + ::Type, + Option<::Type>, + C, + C::Type, + Option, + ::Type, + Option<::Type>, + ::Type, + ), + Map { + m1: module::Type, + m2: Option, + a1: A, + a2: PrivateStruct, + b: B, + b1: B::Type, + b2: Option, + b3: ::Type, + b4: Option<::Type>, + c: C, + c1: C::Type, + c2: Option, + c3: ::Type, + c4: Option<::Type>, + d: ::Type, + }, +} + +fn main() { + let e: TupleStruct< + i32, + i32, + i32, + > = TupleStruct( + 0, + None, + 0, + PrivateStruct(0), + 0, + 0, + None, + 0, + None, + 0, + 0, + None, + 0, + None, + 0, + ); + assert_eq!(e, e); + + let e: Struct< + i32, + i32, + i32, + > = Struct { + m1: 0, + m2: None, + a1: 0, + a2: PrivateStruct(0), + b: 0, + b1: 0, + b2: None, + b3: 0, + b4: None, + c: 0, + c1: 0, + c2: None, + c3: 0, + c4: None, + d: 0, + }; + assert_eq!(e, e); + + let e = Enum::Unit::; + assert_eq!(e, e); + + let e: Enum< + i32, + i32, + i32, + > = Enum::Seq( + 0, + None, + 0, + PrivateStruct(0), + 0, + 0, + None, + 0, + None, + 0, + 0, + None, + 0, + None, + 0, + ); + assert_eq!(e, e); + + let e: Enum< + i32, + i32, + i32, + > = Enum::Map { + m1: 0, + m2: None, + a1: 0, + a2: PrivateStruct(0), + b: 0, + b1: 0, + b2: None, + b3: 0, + b4: None, + c: 0, + c1: 0, + c2: None, + c3: 0, + c4: None, + d: 0, + }; + assert_eq!(e, e); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-bounds.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-bounds.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-bounds.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-bounds.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(Copy, Clone)] +struct Test; + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-array.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-array.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-array.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-array.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// test for issue #30244 + +#[derive(Copy, Clone)] +struct Array { + arr: [[u8; 256]; 4] +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-enum.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +#[derive(Clone)] +enum E { + A, + B(()), + C +} + +pub fn main() { + let _ = E::A.clone(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-generic-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-generic-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-generic-enum.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-generic-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +#[derive(Clone)] +enum E { + A(T), + B(T,U), + C +} + +pub fn main() { + let _ = E::A::(1).clone(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-generic-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-generic-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-generic-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-generic-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#[derive(Clone)] +struct S { + foo: (), + bar: (), + baz: T, +} + +pub fn main() { + let _ = S { foo: (), bar: (), baz: 1 }.clone(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-generic-tuple-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-generic-tuple-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-generic-tuple-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-generic-tuple-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#[derive(Clone)] +struct S(T, ()); + +pub fn main() { + let _ = S(1, ()).clone(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#[derive(Clone)] +struct S { + _int: isize, + _i8: i8, + _i16: i16, + _i32: i32, + _i64: i64, + + _uint: usize, + _u8: u8, + _u16: u16, + _u32: u32, + _u64: u64, + + _f32: f32, + _f64: f64, + + _bool: bool, + _char: char, + _nil: () +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-tuple-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-tuple-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-tuple-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-clone-tuple-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#[derive(Clone)] +struct S((), ()); + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-cmp-generic-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-cmp-generic-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-cmp-generic-enum.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-cmp-generic-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,54 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(PartialEq, Eq, PartialOrd, Ord)] +enum E { + E0, + E1(T), + E2(T,T) +} + +pub fn main() { + let e0 = E::E0; + let e11 = E::E1(1); + let e12 = E::E1(2); + let e21 = E::E2(1, 1); + let e22 = E::E2(1, 2); + + // in order for both PartialOrd and Ord + let es = [e0, e11, e12, e21, e22]; + + for (i, e1) in es.iter().enumerate() { + for (j, e2) in es.iter().enumerate() { + let ord = i.cmp(&j); + + let eq = i == j; + let lt = i < j; + let le = i <= j; + let gt = i > j; + let ge = i >= j; + + // PartialEq + assert_eq!(*e1 == *e2, eq); + assert_eq!(*e1 != *e2, !eq); + + // PartialOrd + assert_eq!(*e1 < *e2, lt); + assert_eq!(*e1 > *e2, gt); + + assert_eq!(*e1 <= *e2, le); + assert_eq!(*e1 >= *e2, ge); + + // Ord + assert_eq!(e1.cmp(e2), ord); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-cmp-generic-struct-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-cmp-generic-struct-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-cmp-generic-struct-enum.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-cmp-generic-struct-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,58 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(PartialEq, Eq, PartialOrd, Ord)] +enum ES { + ES1 { x: T }, + ES2 { x: T, y: T } +} + + +pub fn main() { + let (es11, es12, es21, es22) = (ES::ES1 { + x: 1 + }, ES::ES1 { + x: 2 + }, ES::ES2 { + x: 1, + y: 1 + }, ES::ES2 { + x: 1, + y: 2 + }); + + // in order for both PartialOrd and Ord + let ess = [es11, es12, es21, es22]; + + for (i, es1) in ess.iter().enumerate() { + for (j, es2) in ess.iter().enumerate() { + let ord = i.cmp(&j); + + let eq = i == j; + let (lt, le) = (i < j, i <= j); + let (gt, ge) = (i > j, i >= j); + + // PartialEq + assert_eq!(*es1 == *es2, eq); + assert_eq!(*es1 != *es2, !eq); + + // PartialOrd + assert_eq!(*es1 < *es2, lt); + assert_eq!(*es1 > *es2, gt); + + assert_eq!(*es1 <= *es2, le); + assert_eq!(*es1 >= *es2, ge); + + // Ord + assert_eq!(es1.cmp(es2), ord); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-cmp-generic-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-cmp-generic-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-cmp-generic-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-cmp-generic-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,50 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(PartialEq, Eq, PartialOrd, Ord)] +struct S { + x: T, + y: T +} + +pub fn main() { + let s1 = S {x: 1, y: 1}; + let s2 = S {x: 1, y: 2}; + + // in order for both PartialOrd and Ord + let ss = [s1, s2]; + + for (i, s1) in ss.iter().enumerate() { + for (j, s2) in ss.iter().enumerate() { + let ord = i.cmp(&j); + + let eq = i == j; + let lt = i < j; + let le = i <= j; + let gt = i > j; + let ge = i >= j; + + // PartialEq + assert_eq!(*s1 == *s2, eq); + assert_eq!(*s1 != *s2, !eq); + + // PartialOrd + assert_eq!(*s1 < *s2, lt); + assert_eq!(*s1 > *s2, gt); + + assert_eq!(*s1 <= *s2, le); + assert_eq!(*s1 >= *s2, ge); + + // Ord + assert_eq!(s1.cmp(s2), ord); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-cmp-generic-tuple-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-cmp-generic-tuple-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-cmp-generic-tuple-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-cmp-generic-tuple-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,48 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(PartialEq, Eq, PartialOrd, Ord)] +struct TS(T,T); + + +pub fn main() { + let ts1 = TS(1, 1); + let ts2 = TS(1, 2); + + // in order for both PartialOrd and Ord + let tss = [ts1, ts2]; + + for (i, ts1) in tss.iter().enumerate() { + for (j, ts2) in tss.iter().enumerate() { + let ord = i.cmp(&j); + + let eq = i == j; + let lt = i < j; + let le = i <= j; + let gt = i > j; + let ge = i >= j; + + // PartialEq + assert_eq!(*ts1 == *ts2, eq); + assert_eq!(*ts1 != *ts2, !eq); + + // PartialOrd + assert_eq!(*ts1 < *ts2, lt); + assert_eq!(*ts1 > *ts2, gt); + + assert_eq!(*ts1 <= *ts2, le); + assert_eq!(*ts1 >= *ts2, ge); + + // Ord + assert_eq!(ts1.cmp(ts2), ord); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-cmp-shortcircuit.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-cmp-shortcircuit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-cmp-shortcircuit.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-cmp-shortcircuit.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// check that the derived impls for the comparison traits shortcircuit +// where possible, by having a type that panics when compared as the +// second element, so this passes iff the instances shortcircuit. + + +use std::cmp::Ordering; + +pub struct FailCmp; +impl PartialEq for FailCmp { + fn eq(&self, _: &FailCmp) -> bool { panic!("eq") } +} + +impl PartialOrd for FailCmp { + fn partial_cmp(&self, _: &FailCmp) -> Option { panic!("partial_cmp") } +} + +impl Eq for FailCmp {} + +impl Ord for FailCmp { + fn cmp(&self, _: &FailCmp) -> Ordering { panic!("cmp") } +} + +#[derive(PartialEq,PartialOrd,Eq,Ord)] +struct ShortCircuit { + x: isize, + y: FailCmp +} + +pub fn main() { + let a = ShortCircuit { x: 1, y: FailCmp }; + let b = ShortCircuit { x: 2, y: FailCmp }; + + assert!(a != b); + assert!(a < b); + assert_eq!(a.cmp(&b), ::std::cmp::Ordering::Less); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-copyclone.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-copyclone.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-copyclone.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-copyclone.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,49 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +//! Test that #[derive(Copy, Clone)] produces a shallow copy +//! even when a member violates RFC 1521 + +use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering}; + +/// A struct that pretends to be Copy, but actually does something +/// in its Clone impl +#[derive(Copy)] +struct Liar; + +/// Static cooperating with the rogue Clone impl +static CLONED: AtomicBool = ATOMIC_BOOL_INIT; + +impl Clone for Liar { + fn clone(&self) -> Self { + // this makes Clone vs Copy observable + CLONED.store(true, Ordering::SeqCst); + + *self + } +} + +/// This struct is actually Copy... at least, it thinks it is! +#[derive(Copy, Clone)] +struct Innocent(Liar); + +impl Innocent { + fn new() -> Self { + Innocent(Liar) + } +} + +fn main() { + let _ = Innocent::new().clone(); + // if Innocent was byte-for-byte copied, CLONED will still be false + assert!(!CLONED.load(Ordering::SeqCst)); +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-default-box.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-default-box.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-default-box.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-default-box.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +use std::default::Default; + +#[derive(Default)] +struct A { + foo: Box<[bool]>, +} + +pub fn main() { + let a: A = Default::default(); + let b: Box<[_]> = Box::<[bool; 0]>::new([]); + assert_eq!(a.foo, b); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-enum-single-variant.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-enum-single-variant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-enum-single-variant.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-enum-single-variant.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 +#![allow(non_camel_case_types)] + +pub type task_id = isize; + +#[derive(PartialEq)] +pub enum Task { + TaskHandle(task_id) +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-eq-ord-boxed-slice.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-eq-ord-boxed-slice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-eq-ord-boxed-slice.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-eq-ord-boxed-slice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(PartialEq, PartialOrd, Eq, Ord, Debug)] +struct Foo(Box<[u8]>); + +pub fn main() { + let a = Foo(Box::new([0, 1, 2])); + let b = Foo(Box::new([0, 1, 2])); + assert_eq!(a, b); + println!("{}", a != b); + println!("{}", a < b); + println!("{}", a <= b); + println!("{}", a == b); + println!("{}", a > b); + println!("{}", a >= b); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-hash.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-hash.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-hash.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-hash.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,86 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_imports)] +#![allow(deprecated)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(overflowing_literals)] + +use std::hash::{Hash, SipHasher, Hasher}; +use std::mem::size_of; + +#[derive(Hash)] +struct Person { + id: usize, + name: String, + phone: usize, +} + +// test for hygiene name collisions +#[derive(Hash)] struct __H__H; +#[derive(Hash)] enum Collision<__H> { __H { __H__H: __H } } + +#[derive(Hash)] +enum E { A=1, B } + +fn hash(t: &T) -> u64 { + let mut s = SipHasher::new_with_keys(0, 0); + t.hash(&mut s); + s.finish() +} + +struct FakeHasher<'a>(&'a mut Vec); +impl<'a> Hasher for FakeHasher<'a> { + fn finish(&self) -> u64 { + unimplemented!() + } + + fn write(&mut self, bytes: &[u8]) { + self.0.extend(bytes); + } +} + +fn fake_hash(v: &mut Vec, a: A) { + a.hash(&mut FakeHasher(v)); +} + +fn main() { + let person1 = Person { + id: 5, + name: "Janet".to_string(), + phone: 555_666_7777 + }; + let person2 = Person { + id: 5, + name: "Bob".to_string(), + phone: 555_666_7777 + }; + assert_eq!(hash(&person1), hash(&person1)); + assert!(hash(&person1) != hash(&person2)); + + // test #21714 + let mut va = vec![]; + let mut vb = vec![]; + fake_hash(&mut va, E::A); + fake_hash(&mut vb, E::B); + assert!(va != vb); + + // issue #39137: single variant enum hash should not hash discriminant + #[derive(Hash)] + enum SingleVariantEnum { + A(u8), + } + let mut v = vec![]; + fake_hash(&mut v, SingleVariantEnum::A(17)); + assert_eq!(vec![17], v); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-in-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-in-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-in-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-in-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn main() { + #[derive(Debug)] + struct Foo { + foo: isize, + } + + let f = Foo { foo: 10 }; + format!("{:?}", f); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-in-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-in-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-in-macro.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-in-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 +#![allow(non_camel_case_types)] + +macro_rules! define_vec { + () => ( + mod foo { + #[derive(PartialEq)] + pub struct bar; + } + ) +} + +define_vec![]; + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-meta-multiple.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-meta-multiple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-meta-multiple.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-meta-multiple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +#![allow(unused_imports)] +// pretty-expanded FIXME #23616 +#![allow(deprecated)] + +use std::hash::{Hash, SipHasher}; + +// testing multiple separate deriving attributes +#[derive(PartialEq)] +#[derive(Clone)] +#[derive(Hash)] +struct Foo { + bar: usize, + baz: isize +} + +fn hash(_t: &T) {} + +pub fn main() { + let a = Foo {bar: 4, baz: -3}; + + a == a; // check for PartialEq impl w/o testing its correctness + a.clone(); // check for Clone impl w/o testing its correctness + hash(&a); // check for Hash impl w/o testing its correctness +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-meta.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-meta.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-meta.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-meta.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +#![allow(unused_imports)] +// pretty-expanded FIXME #23616 +#![allow(deprecated)] + +use std::hash::{Hash, SipHasher}; + +#[derive(PartialEq, Clone, Hash)] +struct Foo { + bar: usize, + baz: isize +} + +fn hash(_t: &T) {} + +pub fn main() { + let a = Foo {bar: 4, baz: -3}; + + a == a; // check for PartialEq impl w/o testing its correctness + a.clone(); // check for Clone impl w/o testing its correctness + hash(&a); // check for Hash impl w/o testing its correctness +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-self-lifetime-totalord-totaleq.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-self-lifetime-totalord-totaleq.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-self-lifetime-totalord-totaleq.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-self-lifetime-totalord-totaleq.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::cmp::Ordering::{Less,Equal,Greater}; + +#[derive(PartialEq, Eq, PartialOrd, Ord)] +struct A<'a> { + x: &'a isize +} +pub fn main() { + let (a, b) = (A { x: &1 }, A { x: &2 }); + + assert_eq!(a.cmp(&a), Equal); + assert_eq!(b.cmp(&b), Equal); + + assert_eq!(a.cmp(&b), Less); + assert_eq!(b.cmp(&a), Greater); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-show-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-show-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-show-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-show-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,64 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +use std::fmt; + +#[derive(Debug)] +enum A {} +#[derive(Debug)] +enum B { B1, B2, B3 } +#[derive(Debug)] +enum C { C1(isize), C2(B), C3(String) } +#[derive(Debug)] +enum D { D1{ a: isize } } +#[derive(Debug)] +struct E; +#[derive(Debug)] +struct F(isize); +#[derive(Debug)] +struct G(isize, isize); +#[derive(Debug)] +struct H { a: isize } +#[derive(Debug)] +struct I { a: isize, b: isize } +#[derive(Debug)] +struct J(Custom); + +struct Custom; +impl fmt::Debug for Custom { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "yay") + } +} + +trait ToDebug { + fn to_show(&self) -> String; +} + +impl ToDebug for T { + fn to_show(&self) -> String { + format!("{:?}", self) + } +} + +pub fn main() { + assert_eq!(B::B1.to_show(), "B1".to_string()); + assert_eq!(B::B2.to_show(), "B2".to_string()); + assert_eq!(C::C1(3).to_show(), "C1(3)".to_string()); + assert_eq!(C::C2(B::B2).to_show(), "C2(B2)".to_string()); + assert_eq!(D::D1{ a: 2 }.to_show(), "D1 { a: 2 }".to_string()); + assert_eq!(E.to_show(), "E".to_string()); + assert_eq!(F(3).to_show(), "F(3)".to_string()); + assert_eq!(G(3, 4).to_show(), "G(3, 4)".to_string()); + assert_eq!(I{ a: 2, b: 4 }.to_show(), "I { a: 2, b: 4 }".to_string()); + assert_eq!(J(Custom).to_show(), "J(yay)".to_string()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-show.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-show.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-show.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-show.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#[derive(Debug)] +struct Unit; + +#[derive(Debug)] +struct Tuple(isize, usize); + +#[derive(Debug)] +struct Struct { x: isize, y: usize } + +#[derive(Debug)] +enum Enum { + Nullary, + Variant(isize, usize), + StructVariant { x: isize, y : usize } +} + +#[derive(Debug)] +struct Pointers(*const Send, *mut Sync); + +macro_rules! t { + ($x:expr, $expected:expr) => { + assert_eq!(format!("{:?}", $x), $expected.to_string()) + } +} + +pub fn main() { + t!(Unit, "Unit"); + t!(Tuple(1, 2), "Tuple(1, 2)"); + t!(Struct { x: 1, y: 2 }, "Struct { x: 1, y: 2 }"); + t!(Enum::Nullary, "Nullary"); + t!(Enum::Variant(1, 2), "Variant(1, 2)"); + t!(Enum::StructVariant { x: 1, y: 2 }, "StructVariant { x: 1, y: 2 }"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-c-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-c-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-c-enum.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-c-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#[derive(PartialEq, Debug)] +enum Foo { + Bar, + Baz, + Boo +} + +pub fn main() { + let a = Foo::Bar; + let b = Foo::Bar; + assert_eq!(a, b); + assert!(!(a != b)); + assert!(a.eq(&b)); + assert!(!a.ne(&b)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-enum.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#[derive(PartialEq, Debug)] +enum Foo { + Bar(isize, isize), + Baz(f64, f64) +} + +pub fn main() { + let a = Foo::Bar(1, 2); + let b = Foo::Bar(1, 2); + assert_eq!(a, b); + assert!(!(a != b)); + assert!(a.eq(&b)); + assert!(!a.ne(&b)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-hash-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-hash-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-hash-enum.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-hash-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#[derive(Hash)] +enum Foo { + Bar(isize, char), + Baz(char, isize) +} + +#[derive(Hash)] +enum A { + B, + C, + D, + E +} + +pub fn main(){} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-hash-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-hash-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-hash-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-hash-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +#[derive(Hash)] +struct Foo { + x: isize, + y: isize, + z: isize +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-struct-empty.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-struct-empty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-struct-empty.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-struct-empty.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(PartialEq, Debug)] +struct Foo; + +pub fn main() { + assert_eq!(Foo, Foo); + assert!(!(Foo != Foo)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-struct-like-enum-variant.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-struct-like-enum-variant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-struct-like-enum-variant.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-struct-like-enum-variant.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#[derive(PartialEq, Debug)] +enum S { + X { x: isize, y: isize }, + Y +} + +pub fn main() { + let x = S::X { x: 1, y: 2 }; + assert_eq!(x, x); + assert!(!(x != x)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(PartialEq, Debug)] +struct Foo { + x: isize, + y: isize, + z: isize, +} + +pub fn main() { + let a = Foo { x: 1, y: 2, z: 3 }; + let b = Foo { x: 1, y: 2, z: 3 }; + assert_eq!(a, b); + assert!(!(a != b)); + assert!(a.eq(&b)); + assert!(!a.ne(&b)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-struct-tuple.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-struct-tuple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-struct-tuple.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-struct-tuple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(PartialEq, Debug)] +struct Foo(isize, isize, String); + +pub fn main() { + let a1 = Foo(5, 6, "abc".to_string()); + let a2 = Foo(5, 6, "abc".to_string()); + let b = Foo(5, 7, "def".to_string()); + + assert_eq!(a1, a1); + assert_eq!(a2, a1); + assert!(!(a1 == b)); + + assert!(a1 != b); + assert!(!(a1 != a1)); + assert!(!(a2 != a1)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-type-params.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-type-params.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-type-params.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-via-extension-type-params.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(PartialEq, Hash, Debug)] +struct Foo { + x: isize, + y: T, + z: isize +} + +pub fn main() { + let a = Foo { x: 1, y: 2.0f64, z: 3 }; + let b = Foo { x: 1, y: 2.0f64, z: 3 }; + assert_eq!(a, b); + assert!(!(a != b)); + assert!(a.eq(&b)); + assert!(!a.ne(&b)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-with-repr-packed.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-with-repr-packed.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-with-repr-packed.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/deriving/deriving-with-repr-packed.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// check that derive on a packed struct does not call field +// methods with a misaligned field. + +use std::mem; + +#[derive(Copy, Clone)] +struct Aligned(usize); + +#[inline(never)] +fn check_align(ptr: *const Aligned) { + assert_eq!(ptr as usize % mem::align_of::(), + 0); +} + +impl PartialEq for Aligned { + fn eq(&self, other: &Self) -> bool { + check_align(self); + check_align(other); + self.0 == other.0 + } +} + +#[repr(packed)] +#[derive(Copy, Clone, PartialEq)] +struct Packed(Aligned, Aligned); + +#[derive(PartialEq)] +#[repr(C)] +struct Dealigned(u8, T); + +fn main() { + let d1 = Dealigned(0, Packed(Aligned(1), Aligned(2))); + let ck = d1 == d1; + assert!(ck); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/discriminant_value.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/discriminant_value.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/discriminant_value.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/discriminant_value.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(stable_features)] #![feature(core, core_intrinsics)] extern crate core; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/diverging-fallback-control-flow.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/diverging-fallback-control-flow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/diverging-fallback-control-flow.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/diverging-fallback-control-flow.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] +#![allow(unused_assignments)] +#![allow(unused_variables)] +#![allow(unreachable_code)] // Test various cases where we permit an unconstrained variable // to fallback based on control-flow. // diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/diverging-fallback-method-chain.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/diverging-fallback-method-chain.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/diverging-fallback-method-chain.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/diverging-fallback-method-chain.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_imports)] // Test a regression found when building compiler. The `produce()` // error type `T` winds up getting unified with result of `x.parse()`; // the type of the closure given to `unwrap_or_else` needs to be diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/double-ref.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/double-ref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/double-ref.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/double-ref.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // pretty-expanded FIXME #23616 fn check_expr() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/auxiliary/dropck_eyepatch_extern_crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/auxiliary/dropck_eyepatch_extern_crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/auxiliary/dropck_eyepatch_extern_crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/auxiliary/dropck_eyepatch_extern_crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,60 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(dropck_eyepatch)] + +// The point of this test is to illustrate that the `#[may_dangle]` +// attribute specifically allows, in the context of a type +// implementing `Drop`, a generic parameter to be instantiated with a +// lifetime that does not strictly outlive the owning type itself, +// and that this attributes effects are preserved when importing +// the type from another crate. +// +// See also dropck-eyepatch.rs for more information about the general +// structure of the test. + +use std::cell::RefCell; + +pub trait Foo { fn foo(&self, _: &str); } + +pub struct Dt(pub &'static str, pub A); +pub struct Dr<'a, B:'a+Foo>(pub &'static str, pub &'a B); +pub struct Pt(pub &'static str, pub A, pub B); +pub struct Pr<'a, 'b, B:'a+'b+Foo>(pub &'static str, pub &'a B, pub &'b B); +pub struct St(pub &'static str, pub A); +pub struct Sr<'a, B:'a+Foo>(pub &'static str, pub &'a B); + +impl Drop for Dt { + fn drop(&mut self) { println!("drop {}", self.0); self.1.foo(self.0); } +} +impl<'a, B: Foo> Drop for Dr<'a, B> { + fn drop(&mut self) { println!("drop {}", self.0); self.1.foo(self.0); } +} +unsafe impl<#[may_dangle] A, B: Foo> Drop for Pt { + // (unsafe to access self.1 due to #[may_dangle] on A) + fn drop(&mut self) { println!("drop {}", self.0); self.2.foo(self.0); } +} +unsafe impl<#[may_dangle] 'a, 'b, B: Foo> Drop for Pr<'a, 'b, B> { + // (unsafe to access self.1 due to #[may_dangle] on 'a) + fn drop(&mut self) { println!("drop {}", self.0); self.2.foo(self.0); } +} + +impl Foo for RefCell { + fn foo(&self, s: &str) { + let s2 = format!("{}|{}", *self.borrow(), s); + *self.borrow_mut() = s2; + } +} + +impl<'a, T:Foo> Foo for &'a T { + fn foo(&self, s: &str) { + (*self).foo(s); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/dropck-eyepatch-extern-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/dropck-eyepatch-extern-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/dropck-eyepatch-extern-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/dropck-eyepatch-extern-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,49 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:dropck_eyepatch_extern_crate.rs + +extern crate dropck_eyepatch_extern_crate as other; + +use other::{Dt,Dr,Pt,Pr,St,Sr}; + +fn main() { + use std::cell::RefCell; + + struct CheckOnDrop(RefCell, &'static str); + impl Drop for CheckOnDrop { + fn drop(&mut self) { assert_eq!(*self.0.borrow(), self.1); } + } + + let c_long; + let (c, dt, dr, pt, pr, st, sr) + : (CheckOnDrop, Dt<_>, Dr<_>, Pt<_, _>, Pr<_>, St<_>, Sr<_>); + c_long = CheckOnDrop(RefCell::new("c_long".to_string()), + "c_long|pr|pt|dr|dt"); + c = CheckOnDrop(RefCell::new("c".to_string()), + "c"); + + // No error: sufficiently long-lived state can be referenced in dtors + dt = Dt("dt", &c_long.0); + dr = Dr("dr", &c_long.0); + + // No error: Drop impl asserts .1 (A and &'a _) are not accessed + pt = Pt("pt", &c.0, &c_long.0); + pr = Pr("pr", &c.0, &c_long.0); + + // No error: St and Sr have no destructor. + st = St("st", &c.0); + sr = Sr("sr", &c.0); + + println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0)); + assert_eq!(*c_long.0.borrow(), "c_long"); + assert_eq!(*c.0.borrow(), "c"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/dropck-eyepatch-reorder.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/dropck-eyepatch-reorder.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/dropck-eyepatch-reorder.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/dropck-eyepatch-reorder.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,89 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(dropck_eyepatch)] + +// The point of this test is to test uses of `#[may_dangle]` attribute +// where the formal declaration order (in the impl generics) does not +// match the actual usage order (in the type instantiation). +// +// See also dropck-eyepatch.rs for more information about the general +// structure of the test. + +trait Foo { fn foo(&self, _: &str); } + +struct Dt(&'static str, A); +struct Dr<'a, B:'a+Foo>(&'static str, &'a B); +struct Pt(&'static str, A, B); +struct Pr<'a, 'b, B:'a+'b+Foo>(&'static str, &'a B, &'b B); +struct St(&'static str, A); +struct Sr<'a, B:'a+Foo>(&'static str, &'a B); + +impl Drop for Dt { + fn drop(&mut self) { println!("drop {}", self.0); self.1.foo(self.0); } +} +impl<'a, B: Foo> Drop for Dr<'a, B> { + fn drop(&mut self) { println!("drop {}", self.0); self.1.foo(self.0); } +} +unsafe impl Drop for Pt { + // (unsafe to access self.1 due to #[may_dangle] on A) + fn drop(&mut self) { println!("drop {}", self.0); self.2.foo(self.0); } +} +unsafe impl<'b, #[may_dangle] 'a, B: Foo> Drop for Pr<'a, 'b, B> { + // (unsafe to access self.1 due to #[may_dangle] on 'a) + fn drop(&mut self) { println!("drop {}", self.0); self.2.foo(self.0); } +} + +fn main() { + use std::cell::RefCell; + + impl Foo for RefCell { + fn foo(&self, s: &str) { + let s2 = format!("{}|{}", *self.borrow(), s); + *self.borrow_mut() = s2; + } + } + + impl<'a, T:Foo> Foo for &'a T { + fn foo(&self, s: &str) { + (*self).foo(s); + } + } + + struct CheckOnDrop(RefCell, &'static str); + impl Drop for CheckOnDrop { + fn drop(&mut self) { assert_eq!(*self.0.borrow(), self.1); } + } + + let c_long; + let (c, dt, dr, pt, pr, st, sr) + : (CheckOnDrop, Dt<_>, Dr<_>, Pt<_, _>, Pr<_>, St<_>, Sr<_>); + c_long = CheckOnDrop(RefCell::new("c_long".to_string()), + "c_long|pr|pt|dr|dt"); + c = CheckOnDrop(RefCell::new("c".to_string()), + "c"); + + // No error: sufficiently long-lived state can be referenced in dtors + dt = Dt("dt", &c_long.0); + dr = Dr("dr", &c_long.0); + + // No error: Drop impl asserts .1 (A and &'a _) are not accessed + pt = Pt("pt", &c.0, &c_long.0); + pr = Pr("pr", &c.0, &c_long.0); + + // No error: St and Sr have no destructor. + st = St("st", &c.0); + sr = Sr("sr", &c.0); + + println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0)); + assert_eq!(*c_long.0.borrow(), "c_long"); + assert_eq!(*c.0.borrow(), "c"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/dropck-eyepatch.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/dropck-eyepatch.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/dropck-eyepatch.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/dropck-eyepatch.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,112 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(dropck_eyepatch)] + +// The point of this test is to illustrate that the `#[may_dangle]` +// attribute specifically allows, in the context of a type +// implementing `Drop`, a generic parameter to be instantiated with a +// lifetime that does not strictly outlive the owning type itself. +// +// Here we test that a model use of `#[may_dangle]` will compile and run. +// +// The illustration is made concrete by comparison with two variations +// on the type with `#[may_dangle]`: +// +// 1. an analogous type that does not implement `Drop` (and thus +// should exhibit maximal flexibility with respect to dropck), and +// +// 2. an analogous type that does not use `#[may_dangle]` (and thus +// should exhibit the standard limitations imposed by dropck. +// +// The types in this file follow a pattern, {D,P,S}{t,r}, where: +// +// - D means "I implement Drop" +// +// - P means "I implement Drop but guarantee my (first) parameter is +// pure, i.e. not accessed from the destructor"; no other parameters +// are pure. +// +// - S means "I do not implement Drop" +// +// - t suffix is used when the first generic is a type +// +// - r suffix is used when the first generic is a lifetime. + +trait Foo { fn foo(&self, _: &str); } + +struct Dt(&'static str, A); +struct Dr<'a, B:'a+Foo>(&'static str, &'a B); +struct Pt(&'static str, A, B); +struct Pr<'a, 'b, B:'a+'b+Foo>(&'static str, &'a B, &'b B); +struct St(&'static str, A); +struct Sr<'a, B:'a+Foo>(&'static str, &'a B); + +impl Drop for Dt { + fn drop(&mut self) { println!("drop {}", self.0); self.1.foo(self.0); } +} +impl<'a, B: Foo> Drop for Dr<'a, B> { + fn drop(&mut self) { println!("drop {}", self.0); self.1.foo(self.0); } +} +unsafe impl<#[may_dangle] A, B: Foo> Drop for Pt { + // (unsafe to access self.1 due to #[may_dangle] on A) + fn drop(&mut self) { println!("drop {}", self.0); self.2.foo(self.0); } +} +unsafe impl<#[may_dangle] 'a, 'b, B: Foo> Drop for Pr<'a, 'b, B> { + // (unsafe to access self.1 due to #[may_dangle] on 'a) + fn drop(&mut self) { println!("drop {}", self.0); self.2.foo(self.0); } +} + +fn main() { + use std::cell::RefCell; + + impl Foo for RefCell { + fn foo(&self, s: &str) { + let s2 = format!("{}|{}", *self.borrow(), s); + *self.borrow_mut() = s2; + } + } + + impl<'a, T:Foo> Foo for &'a T { + fn foo(&self, s: &str) { + (*self).foo(s); + } + } + + struct CheckOnDrop(RefCell, &'static str); + impl Drop for CheckOnDrop { + fn drop(&mut self) { assert_eq!(*self.0.borrow(), self.1); } + } + + let c_long; + let (c, dt, dr, pt, pr, st, sr) + : (CheckOnDrop, Dt<_>, Dr<_>, Pt<_, _>, Pr<_>, St<_>, Sr<_>); + c_long = CheckOnDrop(RefCell::new("c_long".to_string()), + "c_long|pr|pt|dr|dt"); + c = CheckOnDrop(RefCell::new("c".to_string()), + "c"); + + // No error: sufficiently long-lived state can be referenced in dtors + dt = Dt("dt", &c_long.0); + dr = Dr("dr", &c_long.0); + + // No error: Drop impl asserts .1 (A and &'a _) are not accessed + pt = Pt("pt", &c.0, &c_long.0); + pr = Pr("pr", &c.0, &c_long.0); + + // No error: St and Sr have no destructor. + st = St("st", &c.0); + sr = Sr("sr", &c.0); + + println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0)); + assert_eq!(*c_long.0.borrow(), "c_long"); + assert_eq!(*c.0.borrow(), "c"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/dropck_legal_cycles.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/dropck_legal_cycles.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/dropck_legal_cycles.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/dropck_legal_cycles.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,1193 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// This test exercises cases where cyclic structure is legal, +// including when the cycles go through data-structures such +// as `Vec` or `TypedArena`. +// +// The intent is to cover as many such cases as possible, ensuring +// that if the compiler did not complain circa Rust 1.x (1.2 as of +// this writing), then it will continue to not complain in the future. +// +// Note that while some of the tests are only exercising using the +// given collection as a "backing store" for a set of nodes that hold +// the actual cycle (and thus the cycle does not go through the +// collection itself in such cases), in general we *do* want to make +// sure to have at least one example exercising a cycle that goes +// through the collection, for every collection type that supports +// this. + +// HIGH LEVEL DESCRIPTION OF THE TEST ARCHITECTURE +// ----------------------------------------------- +// +// We pick a data structure and want to make a cyclic construction +// from it. Each test of interest is labelled starting with "Cycle N: +// { ... }" where N is the test number and the "..."`is filled in with +// a graphviz-style description of the graph structure that the +// author believes is being made. So "{ a -> b, b -> (c,d), (c,d) -> e }" +// describes a line connected to a diamond: +// +// c +// / \ +// a - b e +// \ / +// d +// +// (Note that the above directed graph is actually acyclic.) +// +// The different graph structures are often composed of different data +// types. Some may be built atop `Vec`, others atop `HashMap`, etc. +// +// For each graph structure, we actually *confirm* that a cycle exists +// (as a safe-guard against a test author accidentally leaving it out) +// by traversing each graph and "proving" that a cycle exists within it. +// +// To do this, while trying to keep the code uniform (despite working +// with different underlying collection and smart-pointer types), we +// have a standard traversal API: +// +// 1. every node in the graph carries a `mark` (a u32, init'ed to 0). +// +// 2. every node provides a method to visit its children +// +// 3. a traversal attmepts to visit the nodes of the graph and prove that +// it sees the same node twice. It does this by setting the mark of each +// node to a fresh non-zero value, and if it sees the current mark, it +// "knows" that it must have found a cycle, and stops attempting further +// traversal. +// +// 4. each traversal is controlled by a bit-string that tells it which child +// it visit when it can take different paths. As a simple example, +// in a binary tree, 0 could mean "left" (and 1, "right"), so that +// "00010" means "left, left, left, right, left". (In general it will +// read as many bits as it needs to choose one child.) +// +// The graphs in this test are all meant to be very small, and thus +// short bitstrings of less than 64 bits should always suffice. +// +// (An earlier version of this test infrastructure simply had any +// given traversal visit all children it encountered, in a +// depth-first manner; one problem with this approach is that an +// acyclic graph can still have sharing, which would then be treated +// as a repeat mark and reported as a detected cycle.) +// +// The travseral code is a little more complicated because it has been +// programmed in a somewhat defensive manner. For example it also has +// a max threshold for the number of nodes it will visit, to guard +// against scenarios where the nodes are not correctly setting their +// mark when asked. There are various other methods not discussed here +// that are for aiding debugging the test when it runs, such as the +// `name` method that all nodes provide. +// +// So each test: +// +// 1. allocates the nodes in the graph, +// +// 2. sets up the links in the graph, +// +// 3. clones the "ContextData" +// +// 4. chooses a new current mark value for this test +// +// 5. initiates a traversal, potentially from multiple starting points +// (aka "roots"), with a given control-string (potentially a +// different string for each root). if it does start from a +// distinct root, then such a test should also increment the +// current mark value, so that this traversal is considered +// distinct from the prior one on this graph structure. +// +// Note that most of the tests work with the default control string +// of all-zeroes. +// +// 6. assert that the context confirms that it actually saw a cycle (since a traversal +// might have terminated, e.g. on a tree structure that contained no cycles). + +use std::cell::{Cell, RefCell}; +use std::cmp::Ordering; +use std::collections::BinaryHeap; +use std::collections::HashMap; +use std::collections::LinkedList; +use std::collections::VecDeque; +use std::collections::btree_map::BTreeMap; +use std::collections::btree_set::BTreeSet; +use std::hash::{Hash, Hasher}; +use std::rc::Rc; +use std::sync::{Arc, RwLock, Mutex}; + +const PRINT: bool = false; + +pub fn main() { + let c_orig = ContextData { + curr_depth: 0, + max_depth: 3, + visited: 0, + max_visits: 1000, + skipped: 0, + curr_mark: 0, + saw_prev_marked: false, + control_bits: 0, + }; + + // SANITY CHECK FOR TEST SUITE (thus unnumbered) + // Not a cycle: { v[0] -> (v[1], v[2]), v[1] -> v[3], v[2] -> v[3] }; + let v: Vec = vec![Named::new("s0"), + Named::new("s1"), + Named::new("s2"), + Named::new("s3")]; + v[0].next.set((Some(&v[1]), Some(&v[2]))); + v[1].next.set((Some(&v[3]), None)); + v[2].next.set((Some(&v[3]), None)); + v[3].next.set((None, None)); + + let mut c = c_orig.clone(); + c.curr_mark = 10; + assert!(!c.saw_prev_marked); + v[0].descend_into_self(&mut c); + assert!(!c.saw_prev_marked); // <-- different from below, b/c acyclic above + + if PRINT { println!(""); } + + // Cycle 1: { v[0] -> v[1], v[1] -> v[0] }; + // does not exercise `v` itself + let v: Vec = vec![Named::new("s0"), + Named::new("s1")]; + v[0].next.set(Some(&v[1])); + v[1].next.set(Some(&v[0])); + + let mut c = c_orig.clone(); + c.curr_mark = 10; + assert!(!c.saw_prev_marked); + v[0].descend_into_self(&mut c); + assert!(c.saw_prev_marked); + + if PRINT { println!(""); } + + // Cycle 2: { v[0] -> v, v[1] -> v } + let v: V = Named::new("v"); + v.contents[0].set(Some(&v)); + v.contents[1].set(Some(&v)); + + let mut c = c_orig.clone(); + c.curr_mark = 20; + assert!(!c.saw_prev_marked); + v.descend_into_self(&mut c); + assert!(c.saw_prev_marked); + + if PRINT { println!(""); } + + // Cycle 3: { hk0 -> hv0, hv0 -> hk0, hk1 -> hv1, hv1 -> hk1 }; + // does not exercise `h` itself + + let mut h: HashMap = HashMap::new(); + h.insert(Named::new("hk0"), Named::new("hv0")); + h.insert(Named::new("hk1"), Named::new("hv1")); + for (key, val) in h.iter() { + val.next.set(Some(key)); + key.next.set(Some(val)); + } + + let mut c = c_orig.clone(); + c.curr_mark = 30; + for (key, _) in h.iter() { + c.curr_mark += 1; + c.saw_prev_marked = false; + key.descend_into_self(&mut c); + assert!(c.saw_prev_marked); + } + + if PRINT { println!(""); } + + // Cycle 4: { h -> (hmk0,hmv0,hmk1,hmv1), {hmk0,hmv0,hmk1,hmv1} -> h } + + let mut h: HashMap = HashMap::new(); + h.insert(Named::new("hmk0"), Named::new("hmv0")); + h.insert(Named::new("hmk0"), Named::new("hmv0")); + for (key, val) in h.iter() { + val.contents.set(Some(&h)); + key.contents.set(Some(&h)); + } + + let mut c = c_orig.clone(); + c.max_depth = 2; + c.curr_mark = 40; + for (key, _) in h.iter() { + c.curr_mark += 1; + c.saw_prev_marked = false; + key.descend_into_self(&mut c); + assert!(c.saw_prev_marked); + // break; + } + + if PRINT { println!(""); } + + // Cycle 5: { vd[0] -> vd[1], vd[1] -> vd[0] }; + // does not exercise vd itself + let mut vd: VecDeque = VecDeque::new(); + vd.push_back(Named::new("d0")); + vd.push_back(Named::new("d1")); + vd[0].next.set(Some(&vd[1])); + vd[1].next.set(Some(&vd[0])); + + let mut c = c_orig.clone(); + c.curr_mark = 50; + assert!(!c.saw_prev_marked); + vd[0].descend_into_self(&mut c); + assert!(c.saw_prev_marked); + + if PRINT { println!(""); } + + // Cycle 6: { vd -> (vd0, vd1), {vd0, vd1} -> vd } + let mut vd: VecDeque = VecDeque::new(); + vd.push_back(Named::new("vd0")); + vd.push_back(Named::new("vd1")); + vd[0].contents.set(Some(&vd)); + vd[1].contents.set(Some(&vd)); + + let mut c = c_orig.clone(); + c.curr_mark = 60; + assert!(!c.saw_prev_marked); + vd[0].descend_into_self(&mut c); + assert!(c.saw_prev_marked); + + if PRINT { println!(""); } + + // Cycle 7: { vm -> (vm0, vm1), {vm0, vm1} -> vm } + let mut vm: HashMap = HashMap::new(); + vm.insert(0, Named::new("vm0")); + vm.insert(1, Named::new("vm1")); + vm[&0].contents.set(Some(&vm)); + vm[&1].contents.set(Some(&vm)); + + let mut c = c_orig.clone(); + c.curr_mark = 70; + assert!(!c.saw_prev_marked); + vm[&0].descend_into_self(&mut c); + assert!(c.saw_prev_marked); + + if PRINT { println!(""); } + + // Cycle 8: { ll -> (ll0, ll1), {ll0, ll1} -> ll } + let mut ll: LinkedList = LinkedList::new(); + ll.push_back(Named::new("ll0")); + ll.push_back(Named::new("ll1")); + for e in &ll { + e.contents.set(Some(&ll)); + } + + let mut c = c_orig.clone(); + c.curr_mark = 80; + for e in &ll { + c.curr_mark += 1; + c.saw_prev_marked = false; + e.descend_into_self(&mut c); + assert!(c.saw_prev_marked); + // break; + } + + if PRINT { println!(""); } + + // Cycle 9: { bh -> (bh0, bh1), {bh0, bh1} -> bh } + let mut bh: BinaryHeap = BinaryHeap::new(); + bh.push(Named::new("bh0")); + bh.push(Named::new("bh1")); + for b in bh.iter() { + b.contents.set(Some(&bh)); + } + + let mut c = c_orig.clone(); + c.curr_mark = 90; + for b in &bh { + c.curr_mark += 1; + c.saw_prev_marked = false; + b.descend_into_self(&mut c); + assert!(c.saw_prev_marked); + // break; + } + + if PRINT { println!(""); } + + // Cycle 10: { btm -> (btk0, btv1), {bt0, bt1} -> btm } + let mut btm: BTreeMap = BTreeMap::new(); + btm.insert(Named::new("btk0"), Named::new("btv0")); + btm.insert(Named::new("btk1"), Named::new("btv1")); + for (k, v) in btm.iter() { + k.contents.set(Some(&btm)); + v.contents.set(Some(&btm)); + } + + let mut c = c_orig.clone(); + c.curr_mark = 100; + for (k, _) in &btm { + c.curr_mark += 1; + c.saw_prev_marked = false; + k.descend_into_self(&mut c); + assert!(c.saw_prev_marked); + // break; + } + + if PRINT { println!(""); } + + // Cycle 10: { bts -> (bts0, bts1), {bts0, bts1} -> btm } + let mut bts: BTreeSet = BTreeSet::new(); + bts.insert(Named::new("bts0")); + bts.insert(Named::new("bts1")); + for v in bts.iter() { + v.contents.set(Some(&bts)); + } + + let mut c = c_orig.clone(); + c.curr_mark = 100; + for b in &bts { + c.curr_mark += 1; + c.saw_prev_marked = false; + b.descend_into_self(&mut c); + assert!(c.saw_prev_marked); + // break; + } + + if PRINT { println!(""); } + + // Cycle 11: { rc0 -> (rc1, rc2), rc1 -> (), rc2 -> rc0 } + let (rc0, rc1, rc2): (RCRC, RCRC, RCRC); + rc0 = RCRC::new("rcrc0"); + rc1 = RCRC::new("rcrc1"); + rc2 = RCRC::new("rcrc2"); + rc0.0.borrow_mut().children.0 = Some(&rc1); + rc0.0.borrow_mut().children.1 = Some(&rc2); + rc2.0.borrow_mut().children.0 = Some(&rc0); + + let mut c = c_orig.clone(); + c.control_bits = 0b1; + c.curr_mark = 110; + assert!(!c.saw_prev_marked); + rc0.descend_into_self(&mut c); + assert!(c.saw_prev_marked); + + if PRINT { println!(""); } + + // We want to take the previous Rc case and generalize it to Arc. + // + // We can use refcells if we're single-threaded (as this test is). + // If one were to generalize these constructions to a + // multi-threaded context, then it might seem like we could choose + // between either a RwLock or a Mutex to hold the owned arcs on + // each node. + // + // Part of the point of this test is to actually confirm that the + // cycle exists by traversing it. We can do that just fine with an + // RwLock (since we can grab the child pointers in read-only + // mode), but we cannot lock a std::sync::Mutex to guard reading + // from each node via the same pattern, since once you hit the + // cycle, you'll be trying to acquiring the same lock twice. + // (We deal with this by exiting the traversal early if try_lock fails.) + + // Cycle 12: { arc0 -> (arc1, arc2), arc1 -> (), arc2 -> arc0 }, refcells + let (arc0, arc1, arc2): (ARCRC, ARCRC, ARCRC); + arc0 = ARCRC::new("arcrc0"); + arc1 = ARCRC::new("arcrc1"); + arc2 = ARCRC::new("arcrc2"); + arc0.0.borrow_mut().children.0 = Some(&arc1); + arc0.0.borrow_mut().children.1 = Some(&arc2); + arc2.0.borrow_mut().children.0 = Some(&arc0); + + let mut c = c_orig.clone(); + c.control_bits = 0b1; + c.curr_mark = 110; + assert!(!c.saw_prev_marked); + arc0.descend_into_self(&mut c); + assert!(c.saw_prev_marked); + + if PRINT { println!(""); } + + // Cycle 13: { arc0 -> (arc1, arc2), arc1 -> (), arc2 -> arc0 }, rwlocks + let (arc0, arc1, arc2): (ARCRW, ARCRW, ARCRW); + arc0 = ARCRW::new("arcrw0"); + arc1 = ARCRW::new("arcrw1"); + arc2 = ARCRW::new("arcrw2"); + arc0.0.write().unwrap().children.0 = Some(&arc1); + arc0.0.write().unwrap().children.1 = Some(&arc2); + arc2.0.write().unwrap().children.0 = Some(&arc0); + + let mut c = c_orig.clone(); + c.control_bits = 0b1; + c.curr_mark = 110; + assert!(!c.saw_prev_marked); + arc0.descend_into_self(&mut c); + assert!(c.saw_prev_marked); + + if PRINT { println!(""); } + + // Cycle 14: { arc0 -> (arc1, arc2), arc1 -> (), arc2 -> arc0 }, mutexs + let (arc0, arc1, arc2): (ARCM, ARCM, ARCM); + arc0 = ARCM::new("arcm0"); + arc1 = ARCM::new("arcm1"); + arc2 = ARCM::new("arcm2"); + arc0.1.lock().unwrap().children.0 = Some(&arc1); + arc0.1.lock().unwrap().children.1 = Some(&arc2); + arc2.1.lock().unwrap().children.0 = Some(&arc0); + + let mut c = c_orig.clone(); + c.control_bits = 0b1; + c.curr_mark = 110; + assert!(!c.saw_prev_marked); + arc0.descend_into_self(&mut c); + assert!(c.saw_prev_marked); +} + +trait Named { + fn new(_: &'static str) -> Self; + fn name(&self) -> &str; +} + +trait Marked { + fn mark(&self) -> M; + fn set_mark(&self, mark: M); +} + +struct S<'a> { + name: &'static str, + mark: Cell, + next: Cell>>, +} + +impl<'a> Named for S<'a> { + fn new(name: &'static str) -> S<'a> { + S { name: name, mark: Cell::new(0), next: Cell::new(None) } + } + fn name(&self) -> &str { self.name } +} + +impl<'a> Marked for S<'a> { + fn mark(&self) -> u32 { self.mark.get() } + fn set_mark(&self, mark: u32) { self.mark.set(mark); } +} + +struct S2<'a> { + name: &'static str, + mark: Cell, + next: Cell<(Option<&'a S2<'a>>, Option<&'a S2<'a>>)>, +} + +impl<'a> Named for S2<'a> { + fn new(name: &'static str) -> S2<'a> { + S2 { name: name, mark: Cell::new(0), next: Cell::new((None, None)) } + } + fn name(&self) -> &str { self.name } +} + +impl<'a> Marked for S2<'a> { + fn mark(&self) -> u32 { self.mark.get() } + fn set_mark(&self, mark: u32) { + self.mark.set(mark); + } +} + +struct V<'a> { + name: &'static str, + mark: Cell, + contents: Vec>>>, +} + +impl<'a> Named for V<'a> { + fn new(name: &'static str) -> V<'a> { + V { name: name, + mark: Cell::new(0), + contents: vec![Cell::new(None), Cell::new(None)] + } + } + fn name(&self) -> &str { self.name } +} + +impl<'a> Marked for V<'a> { + fn mark(&self) -> u32 { self.mark.get() } + fn set_mark(&self, mark: u32) { self.mark.set(mark); } +} + +#[derive(Eq)] +struct H<'a> { + name: &'static str, + mark: Cell, + next: Cell>>, +} + +impl<'a> Named for H<'a> { + fn new(name: &'static str) -> H<'a> { + H { name: name, mark: Cell::new(0), next: Cell::new(None) } + } + fn name(&self) -> &str { self.name } +} + +impl<'a> Marked for H<'a> { + fn mark(&self) -> u32 { self.mark.get() } + fn set_mark(&self, mark: u32) { self.mark.set(mark); } +} + +impl<'a> PartialEq for H<'a> { + fn eq(&self, rhs: &H<'a>) -> bool { + self.name == rhs.name + } +} + +impl<'a> Hash for H<'a> { + fn hash(&self, state: &mut H) { + self.name.hash(state) + } +} + +#[derive(Eq)] +struct HM<'a> { + name: &'static str, + mark: Cell, + contents: Cell, HM<'a>>>>, +} + +impl<'a> Named for HM<'a> { + fn new(name: &'static str) -> HM<'a> { + HM { name: name, + mark: Cell::new(0), + contents: Cell::new(None) + } + } + fn name(&self) -> &str { self.name } +} + +impl<'a> Marked for HM<'a> { + fn mark(&self) -> u32 { self.mark.get() } + fn set_mark(&self, mark: u32) { self.mark.set(mark); } +} + +impl<'a> PartialEq for HM<'a> { + fn eq(&self, rhs: &HM<'a>) -> bool { + self.name == rhs.name + } +} + +impl<'a> Hash for HM<'a> { + fn hash(&self, state: &mut H) { + self.name.hash(state) + } +} + + +struct VD<'a> { + name: &'static str, + mark: Cell, + contents: Cell>>>, +} + +impl<'a> Named for VD<'a> { + fn new(name: &'static str) -> VD<'a> { + VD { name: name, + mark: Cell::new(0), + contents: Cell::new(None) + } + } + fn name(&self) -> &str { self.name } +} + +impl<'a> Marked for VD<'a> { + fn mark(&self) -> u32 { self.mark.get() } + fn set_mark(&self, mark: u32) { self.mark.set(mark); } +} + +struct VM<'a> { + name: &'static str, + mark: Cell, + contents: Cell>>>, +} + +impl<'a> Named for VM<'a> { + fn new(name: &'static str) -> VM<'a> { + VM { name: name, + mark: Cell::new(0), + contents: Cell::new(None) + } + } + fn name(&self) -> &str { self.name } +} + +impl<'a> Marked for VM<'a> { + fn mark(&self) -> u32 { self.mark.get() } + fn set_mark(&self, mark: u32) { self.mark.set(mark); } +} + +struct LL<'a> { + name: &'static str, + mark: Cell, + contents: Cell>>>, +} + +impl<'a> Named for LL<'a> { + fn new(name: &'static str) -> LL<'a> { + LL { name: name, + mark: Cell::new(0), + contents: Cell::new(None) + } + } + fn name(&self) -> &str { self.name } +} + +impl<'a> Marked for LL<'a> { + fn mark(&self) -> u32 { self.mark.get() } + fn set_mark(&self, mark: u32) { self.mark.set(mark); } +} + +struct BH<'a> { + name: &'static str, + mark: Cell, + contents: Cell>>>, +} + +impl<'a> Named for BH<'a> { + fn new(name: &'static str) -> BH<'a> { + BH { name: name, + mark: Cell::new(0), + contents: Cell::new(None) + } + } + fn name(&self) -> &str { self.name } +} + +impl<'a> Marked for BH<'a> { + fn mark(&self) -> u32 { self.mark.get() } + fn set_mark(&self, mark: u32) { self.mark.set(mark); } +} + +impl<'a> Eq for BH<'a> { } + +impl<'a> PartialEq for BH<'a> { + fn eq(&self, rhs: &BH<'a>) -> bool { + self.name == rhs.name + } +} + +impl<'a> PartialOrd for BH<'a> { + fn partial_cmp(&self, rhs: &BH<'a>) -> Option { + Some(self.cmp(rhs)) + } +} + +impl<'a> Ord for BH<'a> { + fn cmp(&self, rhs: &BH<'a>) -> Ordering { + self.name.cmp(rhs.name) + } +} + +struct BTM<'a> { + name: &'static str, + mark: Cell, + contents: Cell, BTM<'a>>>>, +} + +impl<'a> Named for BTM<'a> { + fn new(name: &'static str) -> BTM<'a> { + BTM { name: name, + mark: Cell::new(0), + contents: Cell::new(None) + } + } + fn name(&self) -> &str { self.name } +} + +impl<'a> Marked for BTM<'a> { + fn mark(&self) -> u32 { self.mark.get() } + fn set_mark(&self, mark: u32) { self.mark.set(mark); } +} + +impl<'a> Eq for BTM<'a> { } + +impl<'a> PartialEq for BTM<'a> { + fn eq(&self, rhs: &BTM<'a>) -> bool { + self.name == rhs.name + } +} + +impl<'a> PartialOrd for BTM<'a> { + fn partial_cmp(&self, rhs: &BTM<'a>) -> Option { + Some(self.cmp(rhs)) + } +} + +impl<'a> Ord for BTM<'a> { + fn cmp(&self, rhs: &BTM<'a>) -> Ordering { + self.name.cmp(rhs.name) + } +} + +struct BTS<'a> { + name: &'static str, + mark: Cell, + contents: Cell>>>, +} + +impl<'a> Named for BTS<'a> { + fn new(name: &'static str) -> BTS<'a> { + BTS { name: name, + mark: Cell::new(0), + contents: Cell::new(None) + } + } + fn name(&self) -> &str { self.name } +} + +impl<'a> Marked for BTS<'a> { + fn mark(&self) -> u32 { self.mark.get() } + fn set_mark(&self, mark: u32) { self.mark.set(mark); } +} + +impl<'a> Eq for BTS<'a> { } + +impl<'a> PartialEq for BTS<'a> { + fn eq(&self, rhs: &BTS<'a>) -> bool { + self.name == rhs.name + } +} + +impl<'a> PartialOrd for BTS<'a> { + fn partial_cmp(&self, rhs: &BTS<'a>) -> Option { + Some(self.cmp(rhs)) + } +} + +impl<'a> Ord for BTS<'a> { + fn cmp(&self, rhs: &BTS<'a>) -> Ordering { + self.name.cmp(rhs.name) + } +} + +#[derive(Clone)] +struct RCRCData<'a> { + name: &'static str, + mark: Cell, + children: (Option<&'a RCRC<'a>>, Option<&'a RCRC<'a>>), +} +#[derive(Clone)] +struct RCRC<'a>(Rc>>); + +impl<'a> Named for RCRC<'a> { + fn new(name: &'static str) -> Self { + RCRC(Rc::new(RefCell::new(RCRCData { + name: name, mark: Cell::new(0), children: (None, None), }))) + } + fn name(&self) -> &str { self.0.borrow().name } +} + +impl<'a> Marked for RCRC<'a> { + fn mark(&self) -> u32 { self.0.borrow().mark.get() } + fn set_mark(&self, mark: u32) { self.0.borrow().mark.set(mark); } +} + +impl<'a> Children<'a> for RCRC<'a> { + fn count_children(&self) -> usize { 2 } + fn descend_one_child(&self, context: &mut C, index: usize) + where C: Context + PrePost, Self: Sized + { + let children = &self.0.borrow().children; + let child = match index { + 0 => if let Some(child) = children.0 { child } else { return; }, + 1 => if let Some(child) = children.1 { child } else { return; }, + _ => panic!("bad children"), + }; + // println!("S2 {} descending into child {} at index {}", self.name, child.name, index); + child.descend_into_self(context); + } +} +#[derive(Clone)] +struct ARCRCData<'a> { + name: &'static str, + mark: Cell, + children: (Option<&'a ARCRC<'a>>, Option<&'a ARCRC<'a>>), +} +#[derive(Clone)] +struct ARCRC<'a>(Arc>>); + +impl<'a> Named for ARCRC<'a> { + fn new(name: &'static str) -> Self { + ARCRC(Arc::new(RefCell::new(ARCRCData { + name: name, mark: Cell::new(0), children: (None, None), }))) + } + fn name(&self) -> &str { self.0.borrow().name } +} + +impl<'a> Marked for ARCRC<'a> { + fn mark(&self) -> u32 { self.0.borrow().mark.get() } + fn set_mark(&self, mark: u32) { self.0.borrow().mark.set(mark); } +} + +impl<'a> Children<'a> for ARCRC<'a> { + fn count_children(&self) -> usize { 2 } + fn descend_one_child(&self, context: &mut C, index: usize) + where C: Context + PrePost, Self: Sized + { + let children = &self.0.borrow().children; + match index { + 0 => if let Some(ref child) = children.0 { + child.descend_into_self(context); + }, + 1 => if let Some(ref child) = children.1 { + child.descend_into_self(context); + }, + _ => panic!("bad children!"), + } + } +} + +#[derive(Clone)] +struct ARCMData<'a> { + mark: Cell, + children: (Option<&'a ARCM<'a>>, Option<&'a ARCM<'a>>), +} + +#[derive(Clone)] +struct ARCM<'a>(&'static str, Arc>>); + +impl<'a> Named for ARCM<'a> { + fn new(name: &'static str) -> Self { + ARCM(name, Arc::new(Mutex::new(ARCMData { + mark: Cell::new(0), children: (None, None), }))) + } + fn name(&self) -> &str { self.0 } +} + +impl<'a> Marked for ARCM<'a> { + fn mark(&self) -> u32 { self.1.lock().unwrap().mark.get() } + fn set_mark(&self, mark: u32) { self.1.lock().unwrap().mark.set(mark); } +} + +impl<'a> Children<'a> for ARCM<'a> { + fn count_children(&self) -> usize { 2 } + fn descend_one_child(&self, context: &mut C, index: usize) + where C: Context + PrePost, Self: Sized + { + let ref children = if let Ok(data) = self.1.try_lock() { + data.children + } else { return; }; + match index { + 0 => if let Some(ref child) = children.0 { + child.descend_into_self(context); + }, + 1 => if let Some(ref child) = children.1 { + child.descend_into_self(context); + }, + _ => panic!("bad children!"), + } + } +} + +#[derive(Clone)] +struct ARCRWData<'a> { + name: &'static str, + mark: Cell, + children: (Option<&'a ARCRW<'a>>, Option<&'a ARCRW<'a>>), +} + +#[derive(Clone)] +struct ARCRW<'a>(Arc>>); + +impl<'a> Named for ARCRW<'a> { + fn new(name: &'static str) -> Self { + ARCRW(Arc::new(RwLock::new(ARCRWData { + name: name, mark: Cell::new(0), children: (None, None), }))) + } + fn name(&self) -> &str { self.0.read().unwrap().name } +} + +impl<'a> Marked for ARCRW<'a> { + fn mark(&self) -> u32 { self.0.read().unwrap().mark.get() } + fn set_mark(&self, mark: u32) { self.0.read().unwrap().mark.set(mark); } +} + +impl<'a> Children<'a> for ARCRW<'a> { + fn count_children(&self) -> usize { 2 } + fn descend_one_child(&self, context: &mut C, index: usize) + where C: Context + PrePost, Self: Sized + { + let children = &self.0.read().unwrap().children; + match index { + 0 => if let Some(ref child) = children.0 { + child.descend_into_self(context); + }, + 1 => if let Some(ref child) = children.1 { + child.descend_into_self(context); + }, + _ => panic!("bad children!"), + } + } +} + +trait Context { + fn next_index(&mut self, len: usize) -> usize; + fn should_act(&self) -> bool; + fn increase_visited(&mut self); + fn increase_skipped(&mut self); + fn increase_depth(&mut self); + fn decrease_depth(&mut self); +} + +trait PrePost { + fn pre(&mut self, _: &T); + fn post(&mut self, _: &T); + fn hit_limit(&mut self, _: &T); +} + +trait Children<'a> { + fn count_children(&self) -> usize; + fn descend_one_child(&self, context: &mut C, index: usize) + where C: Context + PrePost, Self: Sized; + + fn next_child(&self, context: &mut C) + where C: Context + PrePost, Self: Sized + { + let index = context.next_index(self.count_children()); + self.descend_one_child(context, index); + } + + fn descend_into_self(&self, context: &mut C) + where C: Context + PrePost, Self: Sized + { + context.pre(self); + if context.should_act() { + context.increase_visited(); + context.increase_depth(); + self.next_child(context); + context.decrease_depth(); + } else { + context.hit_limit(self); + context.increase_skipped(); + } + context.post(self); + } + + fn descend<'b, C>(&self, c: &Cell>, context: &mut C) + where C: Context + PrePost, Self: Sized + { + if let Some(r) = c.get() { + r.descend_into_self(context); + } + } +} + +impl<'a> Children<'a> for S<'a> { + fn count_children(&self) -> usize { 1 } + fn descend_one_child(&self, context: &mut C, _: usize) + where C: Context + PrePost, Self: Sized { + self.descend(&self.next, context); + } +} + +impl<'a> Children<'a> for S2<'a> { + fn count_children(&self) -> usize { 2 } + fn descend_one_child(&self, context: &mut C, index: usize) + where C: Context + PrePost, Self: Sized + { + let children = self.next.get(); + let child = match index { + 0 => if let Some(child) = children.0 { child } else { return; }, + 1 => if let Some(child) = children.1 { child } else { return; }, + _ => panic!("bad children"), + }; + // println!("S2 {} descending into child {} at index {}", self.name, child.name, index); + child.descend_into_self(context); + } +} + +impl<'a> Children<'a> for V<'a> { + fn count_children(&self) -> usize { self.contents.len() } + fn descend_one_child(&self, context: &mut C, index: usize) + where C: Context + PrePost, Self: Sized + { + if let Some(child) = self.contents[index].get() { + child.descend_into_self(context); + } + } +} + +impl<'a> Children<'a> for H<'a> { + fn count_children(&self) -> usize { 1 } + fn descend_one_child(&self, context: &mut C, _: usize) + where C: Context + PrePost, Self: Sized + { + self.descend(&self.next, context); + } +} + +impl<'a> Children<'a> for HM<'a> { + fn count_children(&self) -> usize { + if let Some(m) = self.contents.get() { 2 * m.iter().count() } else { 0 } + } + fn descend_one_child(&self, context: &mut C, index: usize) + where C: Context + PrePost, Self: Sized + { + if let Some(ref hm) = self.contents.get() { + for (k, v) in hm.iter().nth(index / 2) { + [k, v][index % 2].descend_into_self(context); + } + } + } +} + +impl<'a> Children<'a> for VD<'a> { + fn count_children(&self) -> usize { + if let Some(d) = self.contents.get() { d.iter().count() } else { 0 } + } + fn descend_one_child(&self, context: &mut C, index: usize) + where C: Context + PrePost, Self: Sized + { + if let Some(ref vd) = self.contents.get() { + for r in vd.iter().nth(index) { + r.descend_into_self(context); + } + } + } +} + +impl<'a> Children<'a> for VM<'a> { + fn count_children(&self) -> usize { + if let Some(m) = self.contents.get() { m.iter().count() } else { 0 } + } + fn descend_one_child(&self, context: &mut C, index: usize) + where C: Context + PrePost> + { + if let Some(ref vd) = self.contents.get() { + for (_idx, r) in vd.iter().nth(index) { + r.descend_into_self(context); + } + } + } +} + +impl<'a> Children<'a> for LL<'a> { + fn count_children(&self) -> usize { + if let Some(l) = self.contents.get() { l.iter().count() } else { 0 } + } + fn descend_one_child(&self, context: &mut C, index: usize) + where C: Context + PrePost> + { + if let Some(ref ll) = self.contents.get() { + for r in ll.iter().nth(index) { + r.descend_into_self(context); + } + } + } +} + +impl<'a> Children<'a> for BH<'a> { + fn count_children(&self) -> usize { + if let Some(h) = self.contents.get() { h.iter().count() } else { 0 } + } + fn descend_one_child(&self, context: &mut C, index: usize) + where C: Context + PrePost> + { + if let Some(ref bh) = self.contents.get() { + for r in bh.iter().nth(index) { + r.descend_into_self(context); + } + } + } +} + +impl<'a> Children<'a> for BTM<'a> { + fn count_children(&self) -> usize { + if let Some(m) = self.contents.get() { 2 * m.iter().count() } else { 0 } + } + fn descend_one_child(&self, context: &mut C, index: usize) + where C: Context + PrePost> + { + if let Some(ref bh) = self.contents.get() { + for (k, v) in bh.iter().nth(index / 2) { + [k, v][index % 2].descend_into_self(context); + } + } + } +} + +impl<'a> Children<'a> for BTS<'a> { + fn count_children(&self) -> usize { + if let Some(s) = self.contents.get() { s.iter().count() } else { 0 } + } + fn descend_one_child(&self, context: &mut C, index: usize) + where C: Context + PrePost> + { + if let Some(ref bh) = self.contents.get() { + for r in bh.iter().nth(index) { + r.descend_into_self(context); + } + } + } +} + +#[derive(Copy, Clone)] +struct ContextData { + curr_depth: usize, + max_depth: usize, + visited: usize, + max_visits: usize, + skipped: usize, + curr_mark: u32, + saw_prev_marked: bool, + control_bits: u64, +} + +impl Context for ContextData { + fn next_index(&mut self, len: usize) -> usize { + if len < 2 { return 0; } + let mut pow2 = len.next_power_of_two(); + let _pow2_orig = pow2; + let mut idx = 0; + let mut bits = self.control_bits; + while pow2 > 1 { + idx = (idx << 1) | (bits & 1) as usize; + bits = bits >> 1; + pow2 = pow2 >> 1; + } + idx = idx % len; + // println!("next_index({} [{:b}]) says {}, pre(bits): {:b} post(bits): {:b}", + // len, _pow2_orig, idx, self.control_bits, bits); + self.control_bits = bits; + return idx; + } + fn should_act(&self) -> bool { + self.curr_depth < self.max_depth && self.visited < self.max_visits + } + fn increase_visited(&mut self) { self.visited += 1; } + fn increase_skipped(&mut self) { self.skipped += 1; } + fn increase_depth(&mut self) { self.curr_depth += 1; } + fn decrease_depth(&mut self) { self.curr_depth -= 1; } +} + +impl> PrePost for ContextData { + fn pre(&mut self, t: &T) { + for _ in 0..self.curr_depth { + if PRINT { print!(" "); } + } + if PRINT { println!("prev {}", t.name()); } + if t.mark() == self.curr_mark { + for _ in 0..self.curr_depth { + if PRINT { print!(" "); } + } + if PRINT { println!("(probably previously marked)"); } + self.saw_prev_marked = true; + } + t.set_mark(self.curr_mark); + } + fn post(&mut self, t: &T) { + for _ in 0..self.curr_depth { + if PRINT { print!(" "); } + } + if PRINT { println!("post {}", t.name()); } + } + fn hit_limit(&mut self, t: &T) { + for _ in 0..self.curr_depth { + if PRINT { print!(" "); } + } + if PRINT { println!("LIMIT {}", t.name()); } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/drop-on-empty-block-exit.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/drop-on-empty-block-exit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/drop-on-empty-block-exit.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/drop-on-empty-block-exit.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 +#![allow(non_camel_case_types)] + +#![feature(box_syntax)] + +enum t { foo(Box), } + +pub fn main() { + let tt = t::foo(box 10); + match tt { t::foo(_z) => { } } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/drop-on-ret.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/drop-on-ret.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/drop-on-ret.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/drop-on-ret.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + +// pretty-expanded FIXME #23616 + +fn f() -> isize { + if true { + let _s: String = "should not leak".to_string(); + return 1; + } + return 0; +} + +pub fn main() { f(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/drop-struct-as-object.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/drop-struct-as-object.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/drop-struct-as-object.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/drop-struct-as-object.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,48 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +#![allow(non_upper_case_globals)] + +// Test that destructor on a struct runs successfully after the struct +// is boxed and converted to an object. + +#![feature(box_syntax)] + +static mut value: usize = 0; + +struct Cat { + name : usize, +} + +trait Dummy { + fn get(&self) -> usize; +} + +impl Dummy for Cat { + fn get(&self) -> usize { self.name } +} + +impl Drop for Cat { + fn drop(&mut self) { + unsafe { value = self.name; } + } +} + +pub fn main() { + { + let x = box Cat {name: 22}; + let nyan: Box = x as Box; + } + unsafe { + assert_eq!(value, 22); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/drop-trait-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/drop-trait-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/drop-trait-enum.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/drop-trait-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,105 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_assignments)] +#![allow(unused_variables)] +// ignore-emscripten no threads support + +#![feature(box_syntax)] + +use std::thread; +use std::sync::mpsc::{channel, Sender}; + +#[derive(PartialEq, Debug)] +enum Message { + Dropped, + DestructorRan +} + +struct SendOnDrop { + sender: Sender +} + +impl Drop for SendOnDrop { + fn drop(&mut self) { + self.sender.send(Message::Dropped).unwrap(); + } +} + +enum Foo { + SimpleVariant(Sender), + NestedVariant(Box, SendOnDrop, Sender), + FailingVariant { on_drop: SendOnDrop } +} + +impl Drop for Foo { + fn drop(&mut self) { + match self { + &mut Foo::SimpleVariant(ref mut sender) => { + sender.send(Message::DestructorRan).unwrap(); + } + &mut Foo::NestedVariant(_, _, ref mut sender) => { + sender.send(Message::DestructorRan).unwrap(); + } + &mut Foo::FailingVariant { .. } => { + panic!("Failed"); + } + } + } +} + +pub fn main() { + let (sender, receiver) = channel(); + { + let v = Foo::SimpleVariant(sender); + } + assert_eq!(receiver.recv().unwrap(), Message::DestructorRan); + assert_eq!(receiver.recv().ok(), None); + + let (sender, receiver) = channel(); + { + let v = Foo::NestedVariant(box 42, SendOnDrop { sender: sender.clone() }, sender); + } + assert_eq!(receiver.recv().unwrap(), Message::DestructorRan); + assert_eq!(receiver.recv().unwrap(), Message::Dropped); + assert_eq!(receiver.recv().ok(), None); + + let (sender, receiver) = channel(); + let t = thread::spawn(move|| { + let v = Foo::FailingVariant { on_drop: SendOnDrop { sender: sender } }; + }); + assert_eq!(receiver.recv().unwrap(), Message::Dropped); + assert_eq!(receiver.recv().ok(), None); + drop(t.join()); + + let (sender, receiver) = channel(); + let t = { + thread::spawn(move|| { + let mut v = Foo::NestedVariant(box 42, SendOnDrop { + sender: sender.clone() + }, sender.clone()); + v = Foo::NestedVariant(box 42, + SendOnDrop { sender: sender.clone() }, + sender.clone()); + v = Foo::SimpleVariant(sender.clone()); + v = Foo::FailingVariant { on_drop: SendOnDrop { sender: sender } }; + }) + }; + assert_eq!(receiver.recv().unwrap(), Message::DestructorRan); + assert_eq!(receiver.recv().unwrap(), Message::Dropped); + assert_eq!(receiver.recv().unwrap(), Message::DestructorRan); + assert_eq!(receiver.recv().unwrap(), Message::Dropped); + assert_eq!(receiver.recv().unwrap(), Message::DestructorRan); + assert_eq!(receiver.recv().unwrap(), Message::Dropped); + assert_eq!(receiver.recv().ok(), None); + drop(t.join()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/drop-trait-generic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/drop-trait-generic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/drop-trait-generic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/drop-trait-generic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +struct S { + x: T +} + +impl ::std::ops::Drop for S { + fn drop(&mut self) { + println!("bye"); + } +} + +pub fn main() { + let _x = S { x: 1 }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/drop-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/drop-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/drop-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/drop-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +struct Foo { + x: isize +} + +impl Drop for Foo { + fn drop(&mut self) { + println!("bye"); + } +} + +pub fn main() { + let _x: Foo = Foo { x: 3 }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/drop-uninhabited-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/drop-uninhabited-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/drop-uninhabited-enum.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/drop-uninhabited-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// pretty-expanded FIXME #23616 + +enum Foo { } + +impl Drop for Foo { + fn drop(&mut self) { } +} + +fn foo(x: Foo) { } + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/drop-with-type-ascription-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/drop-with-type-ascription-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/drop-with-type-ascription-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/drop-with-type-ascription-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn main() { + let foo = "hello".to_string(); + let foo: Vec<&str> = foo.split_whitespace().collect(); + let invalid_string = &foo[0]; + assert_eq!(*invalid_string, "hello"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/drop-with-type-ascription-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/drop-with-type-ascription-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/drop-with-type-ascription-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/drop-with-type-ascription-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn main() { + let args = vec!["foobie", "asdf::asdf"]; + let arr: Vec<&str> = args[1].split("::").collect(); + assert_eq!(arr[0], "asdf"); + assert_eq!(arr[0], "asdf"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/dynamic-drop.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/dynamic-drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/dynamic-drop.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/dynamic-drop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,357 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_assignments)] +#![allow(unused_variables)] +// revisions:lexical nll +#![cfg_attr(nll, feature(nll))] + +// ignore-wasm32-bare compiled with panic=abort by default + +#![feature(generators, generator_trait, untagged_unions)] +#![feature(slice_patterns)] + +use std::cell::{Cell, RefCell}; +use std::ops::Generator; +use std::panic; +use std::usize; + +struct InjectedFailure; + +struct Allocator { + data: RefCell>, + failing_op: usize, + cur_ops: Cell, +} + +impl panic::UnwindSafe for Allocator {} +impl panic::RefUnwindSafe for Allocator {} + +impl Drop for Allocator { + fn drop(&mut self) { + let data = self.data.borrow(); + if data.iter().any(|d| *d) { + panic!("missing free: {:?}", data); + } + } +} + +impl Allocator { + fn new(failing_op: usize) -> Self { + Allocator { + failing_op: failing_op, + cur_ops: Cell::new(0), + data: RefCell::new(vec![]) + } + } + fn alloc(&self) -> Ptr { + self.cur_ops.set(self.cur_ops.get() + 1); + + if self.cur_ops.get() == self.failing_op { + panic!(InjectedFailure); + } + + let mut data = self.data.borrow_mut(); + let addr = data.len(); + data.push(true); + Ptr(addr, self) + } +} + +struct Ptr<'a>(usize, &'a Allocator); +impl<'a> Drop for Ptr<'a> { + fn drop(&mut self) { + match self.1.data.borrow_mut()[self.0] { + false => { + panic!("double free at index {:?}", self.0) + } + ref mut d => *d = false + } + + self.1.cur_ops.set(self.1.cur_ops.get()+1); + + if self.1.cur_ops.get() == self.1.failing_op { + panic!(InjectedFailure); + } + } +} + +fn dynamic_init(a: &Allocator, c: bool) { + let _x; + if c { + _x = Some(a.alloc()); + } +} + +fn dynamic_drop(a: &Allocator, c: bool) { + let x = a.alloc(); + if c { + Some(x) + } else { + None + }; +} + +struct TwoPtrs<'a>(Ptr<'a>, Ptr<'a>); +fn struct_dynamic_drop(a: &Allocator, c0: bool, c1: bool, c: bool) { + for i in 0..2 { + let x; + let y; + if (c0 && i == 0) || (c1 && i == 1) { + x = (a.alloc(), a.alloc(), a.alloc()); + y = TwoPtrs(a.alloc(), a.alloc()); + if c { + drop(x.1); + drop(y.0); + } + } + } +} + +fn field_assignment(a: &Allocator, c0: bool) { + let mut x = (TwoPtrs(a.alloc(), a.alloc()), a.alloc()); + + x.1 = a.alloc(); + x.1 = a.alloc(); + + let f = (x.0).0; + if c0 { + (x.0).0 = f; + } +} + +fn assignment2(a: &Allocator, c0: bool, c1: bool) { + let mut _v = a.alloc(); + let mut _w = a.alloc(); + if c0 { + drop(_v); + } + _v = _w; + if c1 { + _w = a.alloc(); + } +} + +fn assignment1(a: &Allocator, c0: bool) { + let mut _v = a.alloc(); + let mut _w = a.alloc(); + if c0 { + drop(_v); + } + _v = _w; +} + +#[allow(unions_with_drop_fields)] +union Boxy { + a: T, + b: T, +} + +fn union1(a: &Allocator) { + unsafe { + let mut u = Boxy { a: a.alloc() }; + u.b = a.alloc(); + drop(u.a); + } +} + +fn array_simple(a: &Allocator) { + let _x = [a.alloc(), a.alloc(), a.alloc(), a.alloc()]; +} + +fn vec_simple(a: &Allocator) { + let _x = vec![a.alloc(), a.alloc(), a.alloc(), a.alloc()]; +} + +fn generator(a: &Allocator, run_count: usize) { + assert!(run_count < 4); + + let mut gen = || { + (a.alloc(), + yield a.alloc(), + a.alloc(), + yield a.alloc() + ); + }; + for _ in 0..run_count { + unsafe { gen.resume(); } + } +} + +fn mixed_drop_and_nondrop(a: &Allocator) { + // check that destructor panics handle drop + // and non-drop blocks in the same scope correctly. + // + // Surprisingly enough, this used to not work. + let (x, y, z); + x = a.alloc(); + y = 5; + z = a.alloc(); +} + +#[allow(unreachable_code)] +fn vec_unreachable(a: &Allocator) { + let _x = vec![a.alloc(), a.alloc(), a.alloc(), return]; +} + +fn slice_pattern_first(a: &Allocator) { + let[_x, ..] = [a.alloc(), a.alloc(), a.alloc()]; +} + +fn slice_pattern_middle(a: &Allocator) { + let[_, _x, _] = [a.alloc(), a.alloc(), a.alloc()]; +} + +fn slice_pattern_two(a: &Allocator) { + let[_x, _, _y, _] = [a.alloc(), a.alloc(), a.alloc(), a.alloc()]; +} + +fn slice_pattern_last(a: &Allocator) { + let[.., _y] = [a.alloc(), a.alloc(), a.alloc(), a.alloc()]; +} + +fn slice_pattern_one_of(a: &Allocator, i: usize) { + let array = [a.alloc(), a.alloc(), a.alloc(), a.alloc()]; + let _x = match i { + 0 => { let [a, ..] = array; a } + 1 => { let [_, a, ..] = array; a } + 2 => { let [_, _, a, _] = array; a } + 3 => { let [_, _, _, a] = array; a } + _ => panic!("unmatched"), + }; +} + +fn subslice_pattern_from_end(a: &Allocator, arg: bool) { + let a = [a.alloc(), a.alloc(), a.alloc()]; + if arg { + let[.., _x, _] = a; + } else { + let[_, _y..] = a; + } +} + +fn subslice_pattern_from_end_with_drop(a: &Allocator, arg: bool, arg2: bool) { + let a = [a.alloc(), a.alloc(), a.alloc(), a.alloc(), a.alloc()]; + if arg2 { + drop(a); + return; + } + + if arg { + let[.., _x, _] = a; + } else { + let[_, _y..] = a; + } +} + +fn slice_pattern_reassign(a: &Allocator) { + let mut ar = [a.alloc(), a.alloc()]; + let[_, _x] = ar; + ar = [a.alloc(), a.alloc()]; + let[.., _y] = ar; +} + +fn subslice_pattern_reassign(a: &Allocator) { + let mut ar = [a.alloc(), a.alloc(), a.alloc()]; + let[_, _, _x] = ar; + ar = [a.alloc(), a.alloc(), a.alloc()]; + let[_, _y..] = ar; +} + +fn run_test(mut f: F) + where F: FnMut(&Allocator) +{ + let first_alloc = Allocator::new(usize::MAX); + f(&first_alloc); + + for failing_op in 1..first_alloc.cur_ops.get()+1 { + let alloc = Allocator::new(failing_op); + let alloc = &alloc; + let f = panic::AssertUnwindSafe(&mut f); + let result = panic::catch_unwind(move || { + f.0(alloc); + }); + match result { + Ok(..) => panic!("test executed {} ops but now {}", + first_alloc.cur_ops.get(), alloc.cur_ops.get()), + Err(e) => { + if e.downcast_ref::().is_none() { + panic::resume_unwind(e); + } + } + } + } +} + +fn run_test_nopanic(mut f: F) + where F: FnMut(&Allocator) +{ + let first_alloc = Allocator::new(usize::MAX); + f(&first_alloc); +} + +fn main() { + run_test(|a| dynamic_init(a, false)); + run_test(|a| dynamic_init(a, true)); + run_test(|a| dynamic_drop(a, false)); + run_test(|a| dynamic_drop(a, true)); + + run_test(|a| assignment2(a, false, false)); + run_test(|a| assignment2(a, false, true)); + run_test(|a| assignment2(a, true, false)); + run_test(|a| assignment2(a, true, true)); + + run_test(|a| assignment1(a, false)); + run_test(|a| assignment1(a, true)); + + run_test(|a| array_simple(a)); + run_test(|a| vec_simple(a)); + run_test(|a| vec_unreachable(a)); + + run_test(|a| struct_dynamic_drop(a, false, false, false)); + run_test(|a| struct_dynamic_drop(a, false, false, true)); + run_test(|a| struct_dynamic_drop(a, false, true, false)); + run_test(|a| struct_dynamic_drop(a, false, true, true)); + run_test(|a| struct_dynamic_drop(a, true, false, false)); + run_test(|a| struct_dynamic_drop(a, true, false, true)); + run_test(|a| struct_dynamic_drop(a, true, true, false)); + run_test(|a| struct_dynamic_drop(a, true, true, true)); + + run_test(|a| field_assignment(a, false)); + run_test(|a| field_assignment(a, true)); + + run_test(|a| generator(a, 0)); + run_test(|a| generator(a, 1)); + run_test(|a| generator(a, 2)); + run_test(|a| generator(a, 3)); + + run_test(|a| mixed_drop_and_nondrop(a)); + + run_test(|a| slice_pattern_first(a)); + run_test(|a| slice_pattern_middle(a)); + run_test(|a| slice_pattern_two(a)); + run_test(|a| slice_pattern_last(a)); + run_test(|a| slice_pattern_one_of(a, 0)); + run_test(|a| slice_pattern_one_of(a, 1)); + run_test(|a| slice_pattern_one_of(a, 2)); + run_test(|a| slice_pattern_one_of(a, 3)); + + run_test(|a| subslice_pattern_from_end(a, true)); + run_test(|a| subslice_pattern_from_end(a, false)); + run_test(|a| subslice_pattern_from_end_with_drop(a, true, true)); + run_test(|a| subslice_pattern_from_end_with_drop(a, true, false)); + run_test(|a| subslice_pattern_from_end_with_drop(a, false, true)); + run_test(|a| subslice_pattern_from_end_with_drop(a, false, false)); + run_test(|a| slice_pattern_reassign(a)); + run_test(|a| subslice_pattern_reassign(a)); + + run_test_nopanic(|a| union1(a)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/no-drop-flag-size.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/no-drop-flag-size.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/no-drop-flag-size.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/no-drop-flag-size.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +use std::mem::size_of; + +struct Test { + a: T +} + +impl Drop for Test { + fn drop(&mut self) { } +} + +pub fn main() { + assert_eq!(size_of::(), size_of::>()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/nondrop-cycle.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/nondrop-cycle.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/drop/nondrop-cycle.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/drop/nondrop-cycle.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +use std::cell::Cell; + +struct C<'a> { + p: Cell>>, +} + +impl<'a> C<'a> { + fn new() -> C<'a> { C { p: Cell::new(None) } } +} + +fn f1() { + let (c1, c2) = (C::new(), C::new()); + c1.p.set(Some(&c2)); + c2.p.set(Some(&c1)); +} + +fn f2() { + let (c1, c2); + c1 = C::new(); + c2 = C::new(); + c1.p.set(Some(&c2)); + c2.p.set(Some(&c1)); +} + +fn main() { + f1(); + f2(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-coerce-custom.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-coerce-custom.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-coerce-custom.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-coerce-custom.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,53 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test a very simple custom DST coercion. + +#![feature(unsize, coerce_unsized)] + +use std::ops::CoerceUnsized; +use std::marker::Unsize; + +struct Bar { + x: *const T, +} + +impl, U: ?Sized> CoerceUnsized> for Bar {} + +trait Baz { + fn get(&self) -> i32; +} + +impl Baz for i32 { + fn get(&self) -> i32 { + *self + } +} + +fn main() { + // Arrays. + let a: Bar<[i32; 3]> = Bar { x: &[1, 2, 3] }; + // This is the actual coercion. + let b: Bar<[i32]> = a; + + unsafe { + assert_eq!((*b.x)[0], 1); + assert_eq!((*b.x)[1], 2); + assert_eq!((*b.x)[2], 3); + } + + // Trait objects. + let a: Bar = Bar { x: &42 }; + let b: Bar = a; + unsafe { + assert_eq!((*b.x).get(), 42); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-coerce-rc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-coerce-rc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-coerce-rc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-coerce-rc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,52 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +#![allow(stable_features)] +// Test a very simple custom DST coercion. + +#![feature(core, rc_weak)] + +use std::cell::RefCell; +use std::rc::{Rc, Weak}; + +trait Baz { + fn get(&self) -> i32; +} + +impl Baz for i32 { + fn get(&self) -> i32 { + *self + } +} + +fn main() { + let a: Rc<[i32; 3]> = Rc::new([1, 2, 3]); + let b: Rc<[i32]> = a; + assert_eq!(b[0], 1); + assert_eq!(b[1], 2); + assert_eq!(b[2], 3); + + let a: Rc = Rc::new(42); + let b: Rc = a.clone(); + assert_eq!(b.get(), 42); + + let c: Weak = Rc::downgrade(&a); + let d: Weak = c.clone(); + + let _c = b.clone(); + + let a: Rc> = Rc::new(RefCell::new(42)); + let b: Rc> = a.clone(); + assert_eq!(b.borrow().get(), 42); + // FIXME + let c: Weak> = Rc::downgrade(&a) as Weak<_>; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-coercions.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-coercions.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-coercions.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-coercions.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// Test coercions involving DST and/or raw pointers + +// pretty-expanded FIXME #23616 + +struct S; +trait T { fn dummy(&self) { } } +impl T for S {} + +pub fn main() { + let x: &T = &S; + // Test we can convert from &-ptr to *-ptr of trait objects + let x: *const T = &S; + + // Test we can convert from &-ptr to *-ptr of struct pointer (not DST) + let x: *const S = &S; + + // As above, but mut + let x: &mut T = &mut S; + let x: *mut T = &mut S; + + let x: *mut S = &mut S; + + // Test we can change the mutability from mut to const. + let x: &T = &mut S; + let x: *const T = &mut S; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-deref-mut.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-deref-mut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-deref-mut.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-deref-mut.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that a custom deref with a fat pointer return type does not ICE + + +use std::ops::{Deref, DerefMut}; + +pub struct Arr { + ptr: Box<[usize]> +} + +impl Deref for Arr { + type Target = [usize]; + + fn deref(&self) -> &[usize] { + panic!(); + } +} + +impl DerefMut for Arr { + fn deref_mut(&mut self) -> &mut [usize] { + &mut *self.ptr + } +} + +pub fn foo(arr: &mut Arr) { + let x: &mut [usize] = &mut **arr; + assert_eq!(x[0], 1); + assert_eq!(x[1], 2); + assert_eq!(x[2], 3); +} + +fn main() { + let mut a = Arr { ptr: Box::new([1, 2, 3]) }; + foo(&mut a); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-deref.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-deref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-deref.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-deref.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that a custom deref with a fat pointer return type does not ICE + + +use std::ops::Deref; + +pub struct Arr { + ptr: Box<[usize]> +} + +impl Deref for Arr { + type Target = [usize]; + + fn deref(&self) -> &[usize] { + &*self.ptr + } +} + +pub fn foo(arr: &Arr) { + assert_eq!(arr.len(), 3); + let x: &[usize] = &**arr; + assert_eq!(x[0], 1); + assert_eq!(x[1], 2); + assert_eq!(x[2], 3); +} + +fn main() { + let a = Arr { ptr: Box::new([1, 2, 3]) }; + foo(&a); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-field-align.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-field-align.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-field-align.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-field-align.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,77 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +struct Foo { + a: u16, + b: T +} + +trait Bar { + fn get(&self) -> usize; +} + +impl Bar for usize { + fn get(&self) -> usize { *self } +} + +struct Baz { + a: T +} + +struct HasDrop { + ptr: Box, + data: T +} + +fn main() { + // Test that zero-offset works properly + let b : Baz = Baz { a: 7 }; + assert_eq!(b.a.get(), 7); + let b : &Baz = &b; + assert_eq!(b.a.get(), 7); + + // Test that the field is aligned properly + let f : Foo = Foo { a: 0, b: 11 }; + assert_eq!(f.b.get(), 11); + let ptr1 : *const u8 = &f.b as *const _ as *const u8; + + let f : &Foo = &f; + let ptr2 : *const u8 = &f.b as *const _ as *const u8; + assert_eq!(f.b.get(), 11); + + // The pointers should be the same + assert_eq!(ptr1, ptr2); + + // Test that nested DSTs work properly + let f : Foo> = Foo { a: 0, b: Foo { a: 1, b: 17 }}; + assert_eq!(f.b.b.get(), 17); + let f : &Foo> = &f; + assert_eq!(f.b.b.get(), 17); + + // Test that get the pointer via destructuring works + + let f : Foo = Foo { a: 0, b: 11 }; + let f : &Foo = &f; + let &Foo { a: _, b: ref bar } = f; + assert_eq!(bar.get(), 11); + + // Make sure that drop flags don't screw things up + + let d : HasDrop> = HasDrop { + ptr: Box::new(0), + data: Baz { a: [1,2,3,4] } + }; + assert_eq!([1,2,3,4], d.data.a); + + let d : &HasDrop> = &d; + assert_eq!(&[1,2,3,4], &d.data.a); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-index.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-index.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-index.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-index.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// Test that overloaded index expressions with DST result types +// work and don't ICE. + +use std::ops::Index; +use std::fmt::Debug; + +struct S; + +impl Index for S { + type Output = str; + + fn index<'a>(&'a self, _: usize) -> &'a str { + "hello" + } +} + +struct T; + +impl Index for T { + type Output = Debug + 'static; + + fn index<'a>(&'a self, idx: usize) -> &'a (Debug + 'static) { + static X: usize = 42; + &X as &(Debug + 'static) + } +} + +fn main() { + assert_eq!(&S[0], "hello"); + &T[0]; + // let x = &x as &Debug; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-irrefutable-bind.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-irrefutable-bind.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-irrefutable-bind.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-irrefutable-bind.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(unsized_tuple_coercion)] + +struct Test(T); + +fn main() { + let x = Test([1,2,3]); + let x : &Test<[i32]> = &x; + + let & ref _y = x; + + // Make sure binding to a fat pointer behind a reference + // still works + let slice = &[1,2,3]; + let x = Test(&slice); + let Test(&_slice) = x; + + + let x = (10, [1,2,3]); + let x : &(i32, [i32]) = &x; + + let & ref _y = x; + + let slice = &[1,2,3]; + let x = (10, &slice); + let (_, &_slice) = x; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-raw.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-raw.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-raw.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-raw.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,148 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test DST raw pointers + + +#![feature(unsized_tuple_coercion)] + +trait Trait { + fn foo(&self) -> isize; +} + +struct A { + f: isize +} +impl Trait for A { + fn foo(&self) -> isize { + self.f + } +} + +struct Foo { + f: T +} + +pub fn main() { + // raw trait object + let x = A { f: 42 }; + let z: *const Trait = &x; + let r = unsafe { + (&*z).foo() + }; + assert_eq!(r, 42); + + // raw DST struct + let p = Foo {f: A { f: 42 }}; + let o: *const Foo = &p; + let r = unsafe { + (&*o).f.foo() + }; + assert_eq!(r, 42); + + // raw DST tuple + let p = (A { f: 42 },); + let o: *const (Trait,) = &p; + let r = unsafe { + (&*o).0.foo() + }; + assert_eq!(r, 42); + + // raw slice + let a: *const [_] = &[1, 2, 3]; + unsafe { + let b = (*a)[2]; + assert_eq!(b, 3); + let len = (*a).len(); + assert_eq!(len, 3); + } + + // raw slice with explicit cast + let a = &[1, 2, 3] as *const [i32]; + unsafe { + let b = (*a)[2]; + assert_eq!(b, 3); + let len = (*a).len(); + assert_eq!(len, 3); + } + + // raw DST struct with slice + let c: *const Foo<[_]> = &Foo {f: [1, 2, 3]}; + unsafe { + let b = (&*c).f[0]; + assert_eq!(b, 1); + let len = (&*c).f.len(); + assert_eq!(len, 3); + } + + // raw DST tuple with slice + let c: *const ([_],) = &([1, 2, 3],); + unsafe { + let b = (&*c).0[0]; + assert_eq!(b, 1); + let len = (&*c).0.len(); + assert_eq!(len, 3); + } + + // all of the above with *mut + let mut x = A { f: 42 }; + let z: *mut Trait = &mut x; + let r = unsafe { + (&*z).foo() + }; + assert_eq!(r, 42); + + let mut p = Foo {f: A { f: 42 }}; + let o: *mut Foo = &mut p; + let r = unsafe { + (&*o).f.foo() + }; + assert_eq!(r, 42); + + let mut p = (A { f: 42 },); + let o: *mut (Trait,) = &mut p; + let r = unsafe { + (&*o).0.foo() + }; + assert_eq!(r, 42); + + let a: *mut [_] = &mut [1, 2, 3]; + unsafe { + let b = (*a)[2]; + assert_eq!(b, 3); + let len = (*a).len(); + assert_eq!(len, 3); + } + + let a = &mut [1, 2, 3] as *mut [i32]; + unsafe { + let b = (*a)[2]; + assert_eq!(b, 3); + let len = (*a).len(); + assert_eq!(len, 3); + } + + let c: *mut Foo<[_]> = &mut Foo {f: [1, 2, 3]}; + unsafe { + let b = (&*c).f[0]; + assert_eq!(b, 1); + let len = (&*c).f.len(); + assert_eq!(len, 3); + } + + let c: *mut ([_],) = &mut ([1, 2, 3],); + unsafe { + let b = (&*c).0[0]; + assert_eq!(b, 1); + let len = (&*c).0.len(); + assert_eq!(len, 3); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,132 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +struct Fat { + f1: isize, + f2: &'static str, + ptr: T +} + +// x is a fat pointer +fn foo(x: &Fat<[isize]>) { + let y = &x.ptr; + assert_eq!(x.ptr.len(), 3); + assert_eq!(y[0], 1); + assert_eq!(x.ptr[1], 2); + assert_eq!(x.f1, 5); + assert_eq!(x.f2, "some str"); +} + +fn foo2(x: &Fat<[T]>) { + let y = &x.ptr; + let bar = Bar; + assert_eq!(x.ptr.len(), 3); + assert_eq!(y[0].to_bar(), bar); + assert_eq!(x.ptr[1].to_bar(), bar); + assert_eq!(x.f1, 5); + assert_eq!(x.f2, "some str"); +} + +fn foo3(x: &Fat>) { + let y = &x.ptr.ptr; + assert_eq!(x.f1, 5); + assert_eq!(x.f2, "some str"); + assert_eq!(x.ptr.f1, 8); + assert_eq!(x.ptr.f2, "deep str"); + assert_eq!(x.ptr.ptr.len(), 3); + assert_eq!(y[0], 1); + assert_eq!(x.ptr.ptr[1], 2); +} + + +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +struct Bar; + +trait ToBar { + fn to_bar(&self) -> Bar; +} + +impl ToBar for Bar { + fn to_bar(&self) -> Bar { + *self + } +} + +pub fn main() { + // With a vec of ints. + let f1 = Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] }; + foo(&f1); + let f2 = &f1; + foo(f2); + let f3: &Fat<[isize]> = f2; + foo(f3); + let f4: &Fat<[isize]> = &f1; + foo(f4); + let f5: &Fat<[isize]> = &Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] }; + foo(f5); + + // With a vec of Bars. + let bar = Bar; + let f1 = Fat { f1: 5, f2: "some str", ptr: [bar, bar, bar] }; + foo2(&f1); + let f2 = &f1; + foo2(f2); + let f3: &Fat<[Bar]> = f2; + foo2(f3); + let f4: &Fat<[Bar]> = &f1; + foo2(f4); + let f5: &Fat<[Bar]> = &Fat { f1: 5, f2: "some str", ptr: [bar, bar, bar] }; + foo2(f5); + + // Assignment. + let f5: &mut Fat<[isize]> = &mut Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] }; + f5.ptr[1] = 34; + assert_eq!(f5.ptr[0], 1); + assert_eq!(f5.ptr[1], 34); + assert_eq!(f5.ptr[2], 3); + + // Zero size vec. + let f5: &Fat<[isize]> = &Fat { f1: 5, f2: "some str", ptr: [] }; + assert!(f5.ptr.is_empty()); + let f5: &Fat<[Bar]> = &Fat { f1: 5, f2: "some str", ptr: [] }; + assert!(f5.ptr.is_empty()); + + // Deeply nested. + let f1 = Fat { f1: 5, f2: "some str", ptr: Fat { f1: 8, f2: "deep str", ptr: [1, 2, 3]} }; + foo3(&f1); + let f2 = &f1; + foo3(f2); + let f3: &Fat> = f2; + foo3(f3); + let f4: &Fat> = &f1; + foo3(f4); + let f5: &Fat> = + &Fat { f1: 5, f2: "some str", ptr: Fat { f1: 8, f2: "deep str", ptr: [1, 2, 3]} }; + foo3(f5); + + // Box. + let f1 = Box::new([1, 2, 3]); + assert_eq!((*f1)[1], 2); + let f2: Box<[isize]> = f1; + assert_eq!((*f2)[1], 2); + + // Nested Box. + let f1 : Box> = box Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] }; + foo(&*f1); + let f2 : Box> = f1; + foo(&*f2); + + let f3 : Box> = + Box::>::new(Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] }); + foo(&*f3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-struct-sole.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-struct-sole.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-struct-sole.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-struct-sole.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,86 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// As dst-struct.rs, but the unsized field is the only field in the struct. + + +struct Fat { + ptr: T +} + +// x is a fat pointer +fn foo(x: &Fat<[isize]>) { + let y = &x.ptr; + assert_eq!(x.ptr.len(), 3); + assert_eq!(y[0], 1); + assert_eq!(x.ptr[1], 2); +} + +fn foo2(x: &Fat<[T]>) { + let y = &x.ptr; + let bar = Bar; + assert_eq!(x.ptr.len(), 3); + assert_eq!(y[0].to_bar(), bar); + assert_eq!(x.ptr[1].to_bar(), bar); +} + +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +struct Bar; + +trait ToBar { + fn to_bar(&self) -> Bar; +} + +impl ToBar for Bar { + fn to_bar(&self) -> Bar { + *self + } +} + +pub fn main() { + // With a vec of ints. + let f1 = Fat { ptr: [1, 2, 3] }; + foo(&f1); + let f2 = &f1; + foo(f2); + let f3: &Fat<[isize]> = f2; + foo(f3); + let f4: &Fat<[isize]> = &f1; + foo(f4); + let f5: &Fat<[isize]> = &Fat { ptr: [1, 2, 3] }; + foo(f5); + + // With a vec of Bars. + let bar = Bar; + let f1 = Fat { ptr: [bar, bar, bar] }; + foo2(&f1); + let f2 = &f1; + foo2(f2); + let f3: &Fat<[Bar]> = f2; + foo2(f3); + let f4: &Fat<[Bar]> = &f1; + foo2(f4); + let f5: &Fat<[Bar]> = &Fat { ptr: [bar, bar, bar] }; + foo2(f5); + + // Assignment. + let f5: &mut Fat<[isize]> = &mut Fat { ptr: [1, 2, 3] }; + f5.ptr[1] = 34; + assert_eq!(f5.ptr[0], 1); + assert_eq!(f5.ptr[1], 34); + assert_eq!(f5.ptr[2], 3); + + // Zero size vec. + let f5: &Fat<[isize]> = &Fat { ptr: [] }; + assert!(f5.ptr.is_empty()); + let f5: &Fat<[Bar]> = &Fat { ptr: [] }; + assert!(f5.ptr.is_empty()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,115 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +struct Fat { + f1: isize, + f2: &'static str, + ptr: T +} + +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +struct Bar; + +#[derive(Copy, Clone, PartialEq, Eq)] +struct Bar1 { + f: isize +} + +trait ToBar { + fn to_bar(&self) -> Bar; + fn to_val(&self) -> isize; +} + +impl ToBar for Bar { + fn to_bar(&self) -> Bar { + *self + } + fn to_val(&self) -> isize { + 0 + } +} +impl ToBar for Bar1 { + fn to_bar(&self) -> Bar { + Bar + } + fn to_val(&self) -> isize { + self.f + } +} + +// x is a fat pointer +fn foo(x: &Fat) { + assert_eq!(x.f1, 5); + assert_eq!(x.f2, "some str"); + assert_eq!(x.ptr.to_bar(), Bar); + assert_eq!(x.ptr.to_val(), 42); + + let y = &x.ptr; + assert_eq!(y.to_bar(), Bar); + assert_eq!(y.to_val(), 42); +} + +fn bar(x: &ToBar) { + assert_eq!(x.to_bar(), Bar); + assert_eq!(x.to_val(), 42); +} + +fn baz(x: &Fat>) { + assert_eq!(x.f1, 5); + assert_eq!(x.f2, "some str"); + assert_eq!(x.ptr.f1, 8); + assert_eq!(x.ptr.f2, "deep str"); + assert_eq!(x.ptr.ptr.to_bar(), Bar); + assert_eq!(x.ptr.ptr.to_val(), 42); + + let y = &x.ptr.ptr; + assert_eq!(y.to_bar(), Bar); + assert_eq!(y.to_val(), 42); + +} + +pub fn main() { + let f1 = Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; + foo(&f1); + let f2 = &f1; + foo(f2); + let f3: &Fat = f2; + foo(f3); + let f4: &Fat = &f1; + foo(f4); + let f5: &Fat = &Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; + foo(f5); + + // Zero size object. + let f6: &Fat = &Fat { f1: 5, f2: "some str", ptr: Bar }; + assert_eq!(f6.ptr.to_bar(), Bar); + + // &* + // + let f7: Box = Box::new(Bar1 {f :42}); + bar(&*f7); + + // Deep nesting + let f1 = + Fat { f1: 5, f2: "some str", ptr: Fat { f1: 8, f2: "deep str", ptr: Bar1 {f :42}} }; + baz(&f1); + let f2 = &f1; + baz(f2); + let f3: &Fat> = f2; + baz(f3); + let f4: &Fat> = &f1; + baz(f4); + let f5: &Fat> = + &Fat { f1: 5, f2: "some str", ptr: Fat { f1: 8, f2: "deep str", ptr: Bar1 {f :42}} }; + baz(f5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-trait-tuple.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-trait-tuple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-trait-tuple.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-trait-tuple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,113 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(type_alias_bounds)] + +#![allow(unused_features)] +#![feature(box_syntax)] +#![feature(unsized_tuple_coercion)] + +type Fat = (isize, &'static str, T); + +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +struct Bar; + +#[derive(Copy, Clone, PartialEq, Eq)] +struct Bar1 { + f: isize +} + +trait ToBar { + fn to_bar(&self) -> Bar; + fn to_val(&self) -> isize; +} + +impl ToBar for Bar { + fn to_bar(&self) -> Bar { + *self + } + fn to_val(&self) -> isize { + 0 + } +} +impl ToBar for Bar1 { + fn to_bar(&self) -> Bar { + Bar + } + fn to_val(&self) -> isize { + self.f + } +} + +// x is a fat pointer +fn foo(x: &Fat) { + assert_eq!(x.0, 5); + assert_eq!(x.1, "some str"); + assert_eq!(x.2.to_bar(), Bar); + assert_eq!(x.2.to_val(), 42); + + let y = &x.2; + assert_eq!(y.to_bar(), Bar); + assert_eq!(y.to_val(), 42); +} + +fn bar(x: &ToBar) { + assert_eq!(x.to_bar(), Bar); + assert_eq!(x.to_val(), 42); +} + +fn baz(x: &Fat>) { + assert_eq!(x.0, 5); + assert_eq!(x.1, "some str"); + assert_eq!((x.2).0, 8); + assert_eq!((x.2).1, "deep str"); + assert_eq!((x.2).2.to_bar(), Bar); + assert_eq!((x.2).2.to_val(), 42); + + let y = &(x.2).2; + assert_eq!(y.to_bar(), Bar); + assert_eq!(y.to_val(), 42); + +} + +pub fn main() { + let f1 = (5, "some str", Bar1 {f :42}); + foo(&f1); + let f2 = &f1; + foo(f2); + let f3: &Fat = f2; + foo(f3); + let f4: &Fat = &f1; + foo(f4); + let f5: &Fat = &(5, "some str", Bar1 {f :42}); + foo(f5); + + // Zero size object. + let f6: &Fat = &(5, "some str", Bar); + assert_eq!(f6.2.to_bar(), Bar); + + // &* + // + let f7: Box = Box::new(Bar1 {f :42}); + bar(&*f7); + + // Deep nesting + let f1 = (5, "some str", (8, "deep str", Bar1 {f :42})); + baz(&f1); + let f2 = &f1; + baz(f2); + let f3: &Fat> = f2; + baz(f3); + let f4: &Fat> = &f1; + baz(f4); + let f5: &Fat> = &(5, "some str", (8, "deep str", Bar1 {f :42})); + baz(f5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-tuple.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-tuple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-tuple.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-tuple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,130 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(type_alias_bounds)] + +#![feature(box_syntax)] +#![feature(unsized_tuple_coercion)] + +type Fat = (isize, &'static str, T); + +// x is a fat pointer +fn foo(x: &Fat<[isize]>) { + let y = &x.2; + assert_eq!(x.2.len(), 3); + assert_eq!(y[0], 1); + assert_eq!(x.2[1], 2); + assert_eq!(x.0, 5); + assert_eq!(x.1, "some str"); +} + +fn foo2(x: &Fat<[T]>) { + let y = &x.2; + let bar = Bar; + assert_eq!(x.2.len(), 3); + assert_eq!(y[0].to_bar(), bar); + assert_eq!(x.2[1].to_bar(), bar); + assert_eq!(x.0, 5); + assert_eq!(x.1, "some str"); +} + +fn foo3(x: &Fat>) { + let y = &(x.2).2; + assert_eq!(x.0, 5); + assert_eq!(x.1, "some str"); + assert_eq!((x.2).0, 8); + assert_eq!((x.2).1, "deep str"); + assert_eq!((x.2).2.len(), 3); + assert_eq!(y[0], 1); + assert_eq!((x.2).2[1], 2); +} + + +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +struct Bar; + +trait ToBar { + fn to_bar(&self) -> Bar; +} + +impl ToBar for Bar { + fn to_bar(&self) -> Bar { + *self + } +} + +pub fn main() { + // With a vec of ints. + let f1 = (5, "some str", [1, 2, 3]); + foo(&f1); + let f2 = &f1; + foo(f2); + let f3: &Fat<[isize]> = f2; + foo(f3); + let f4: &Fat<[isize]> = &f1; + foo(f4); + let f5: &Fat<[isize]> = &(5, "some str", [1, 2, 3]); + foo(f5); + + // With a vec of Bars. + let bar = Bar; + let f1 = (5, "some str", [bar, bar, bar]); + foo2(&f1); + let f2 = &f1; + foo2(f2); + let f3: &Fat<[Bar]> = f2; + foo2(f3); + let f4: &Fat<[Bar]> = &f1; + foo2(f4); + let f5: &Fat<[Bar]> = &(5, "some str", [bar, bar, bar]); + foo2(f5); + + // Assignment. + let f5: &mut Fat<[isize]> = &mut (5, "some str", [1, 2, 3]); + f5.2[1] = 34; + assert_eq!(f5.2[0], 1); + assert_eq!(f5.2[1], 34); + assert_eq!(f5.2[2], 3); + + // Zero size vec. + let f5: &Fat<[isize]> = &(5, "some str", []); + assert!(f5.2.is_empty()); + let f5: &Fat<[Bar]> = &(5, "some str", []); + assert!(f5.2.is_empty()); + + // Deeply nested. + let f1 = (5, "some str", (8, "deep str", [1, 2, 3])); + foo3(&f1); + let f2 = &f1; + foo3(f2); + let f3: &Fat> = f2; + foo3(f3); + let f4: &Fat> = &f1; + foo3(f4); + let f5: &Fat> = &(5, "some str", (8, "deep str", [1, 2, 3])); + foo3(f5); + + // Box. + let f1 = Box::new([1, 2, 3]); + assert_eq!((*f1)[1], 2); + let f2: Box<[isize]> = f1; + assert_eq!((*f2)[1], 2); + + // Nested Box. + let f1 : Box> = box (5, "some str", [1, 2, 3]); + foo(&*f1); + let f2 : Box> = f1; + foo(&*f2); + + let f3 : Box> = + Box::>::new((5, "some str", [1, 2, 3])); + foo(&*f3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-tuple-sole.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-tuple-sole.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-tuple-sole.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/dynamically-sized-types/dst-tuple-sole.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,89 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(stable_features)] +#![allow(type_alias_bounds)] + +// As dst-tuple.rs, but the unsized field is the only field in the tuple. + + +#![feature(unsized_tuple_coercion)] + +type Fat = (T,); + +// x is a fat pointer +fn foo(x: &Fat<[isize]>) { + let y = &x.0; + assert_eq!(x.0.len(), 3); + assert_eq!(y[0], 1); + assert_eq!(x.0[1], 2); +} + +fn foo2(x: &Fat<[T]>) { + let y = &x.0; + let bar = Bar; + assert_eq!(x.0.len(), 3); + assert_eq!(y[0].to_bar(), bar); + assert_eq!(x.0[1].to_bar(), bar); +} + +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +struct Bar; + +trait ToBar { + fn to_bar(&self) -> Bar; +} + +impl ToBar for Bar { + fn to_bar(&self) -> Bar { + *self + } +} + +pub fn main() { + // With a vec of ints. + let f1 = ([1, 2, 3],); + foo(&f1); + let f2 = &f1; + foo(f2); + let f3: &Fat<[isize]> = f2; + foo(f3); + let f4: &Fat<[isize]> = &f1; + foo(f4); + let f5: &Fat<[isize]> = &([1, 2, 3],); + foo(f5); + + // With a vec of Bars. + let bar = Bar; + let f1 = ([bar, bar, bar],); + foo2(&f1); + let f2 = &f1; + foo2(f2); + let f3: &Fat<[Bar]> = f2; + foo2(f3); + let f4: &Fat<[Bar]> = &f1; + foo2(f4); + let f5: &Fat<[Bar]> = &([bar, bar, bar],); + foo2(f5); + + // Assignment. + let f5: &mut Fat<[isize]> = &mut ([1, 2, 3],); + f5.0[1] = 34; + assert_eq!(f5.0[0], 1); + assert_eq!(f5.0[1], 34); + assert_eq!(f5.0[2], 3); + + // Zero size vec. + let f5: &Fat<[isize]> = &([],); + assert!(f5.0.is_empty()); + let f5: &Fat<[Bar]> = &([],); + assert!(f5.0.is_empty()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/early-ret-binop-add.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/early-ret-binop-add.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/early-ret-binop-add.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/early-ret-binop-add.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] +#![allow(unreachable_code)] // pretty-expanded FIXME #23616 use std::ops::Add; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/early-vtbl-resolution.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/early-vtbl-resolution.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/early-vtbl-resolution.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/early-vtbl-resolution.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(dead_code)] // pretty-expanded FIXME #23616 trait thing { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/edition-keywords-2015-2015.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/edition-keywords-2015-2015.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/edition-keywords-2015-2015.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/edition-keywords-2015-2015.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_mut)] +#![allow(unused_assignments)] +#![allow(unused_variables)] // edition:2015 // aux-build:edition-kw-macro-2015.rs diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/edition-keywords-2015-2018.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/edition-keywords-2015-2018.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/edition-keywords-2015-2018.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/edition-keywords-2015-2018.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_mut)] +#![allow(unused_assignments)] +#![allow(unused_variables)] // edition:2015 // aux-build:edition-kw-macro-2018.rs diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/edition-keywords-2018-2015.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/edition-keywords-2018-2015.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/edition-keywords-2018-2015.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/edition-keywords-2018-2015.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_assignments)] // edition:2018 // aux-build:edition-kw-macro-2015.rs diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/edition-keywords-2018-2018.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/edition-keywords-2018-2018.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/edition-keywords-2018-2018.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/edition-keywords-2018-2018.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_assignments)] // edition:2018 // aux-build:edition-kw-macro-2018.rs diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/empty-allocation-rvalue-non-null.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/empty-allocation-rvalue-non-null.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/empty-allocation-rvalue-non-null.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/empty-allocation-rvalue-non-null.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_variables)] // pretty-expanded FIXME #23616 pub fn main() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/env-home-dir.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/env-home-dir.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/env-home-dir.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/env-home-dir.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_variables)] +#![allow(deprecated)] // ignore-cloudabi no environment variables present // ignore-emscripten env vars don't work? diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/env-null-vars.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/env-null-vars.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/env-null-vars.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/env-null-vars.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_imports)] + // ignore-windows // ignore-wasm32-bare no libc to test ffi with diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/epoch-gate-feature.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/epoch-gate-feature.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/epoch-gate-feature.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/epoch-gate-feature.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] +#![allow(unused_variables)] // Checks if the correct registers are being used to pass arguments // when the sysv64 ABI is specified. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/estr-uniq.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/estr-uniq.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/estr-uniq.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/estr-uniq.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_assignments)] +#![allow(unknown_lints)] #![allow(dead_assignment)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/existential_type.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/existential_type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/existential_type.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/existential_type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] +#![allow(unused_assignments)] +#![allow(unused_variables)] #![feature(existential_type)] fn main() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/explicit-i-suffix.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/explicit-i-suffix.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/explicit-i-suffix.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/explicit-i-suffix.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_must_use)] // pretty-expanded FIXME #23616 pub fn main() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/export-glob-imports-target.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/export-glob-imports-target.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/export-glob-imports-target.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/export-glob-imports-target.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_upper_case_globals)] +#![allow(dead_code)] // Test that a glob-export functions as an import // when referenced within its own local scope. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/expr-block.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/expr-block.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/expr-block.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/expr-block.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/expr-empty-ret.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/expr-empty-ret.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/expr-empty-ret.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/expr-empty-ret.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // Issue #521 // pretty-expanded FIXME #23616 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/exterior.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/exterior.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/exterior.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/exterior.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] use std::cell::Cell; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/auxiliary/extern_calling_convention.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/auxiliary/extern_calling_convention.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/auxiliary/extern_calling_convention.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/auxiliary/extern_calling_convention.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Make sure Rust generates the correct calling convention for extern +// functions. + +#[inline(never)] +#[cfg(target_arch = "x86_64")] +pub extern "win64" fn foo(a: isize, b: isize, c: isize, d: isize) { + assert_eq!(a, 1); + assert_eq!(b, 2); + assert_eq!(c, 3); + assert_eq!(d, 4); + + println!("a: {}, b: {}, c: {}, d: {}", + a, b, c, d) +} + +#[inline(never)] +#[cfg(not(target_arch = "x86_64"))] +pub extern fn foo(a: isize, b: isize, c: isize, d: isize) { + assert_eq!(a, 1); + assert_eq!(b, 2); + assert_eq!(c, 3); + assert_eq!(d, 4); + + println!("a: {}, b: {}, c: {}, d: {}", + a, b, c, d) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/auxiliary/extern-crosscrate-source.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/auxiliary/extern-crosscrate-source.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/auxiliary/extern-crosscrate-source.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/auxiliary/extern-crosscrate-source.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="externcallback"] +#![crate_type = "lib"] +#![feature(libc)] + +extern crate libc; + +pub mod rustrt { + extern crate libc; + + #[link(name = "rust_test_helpers", kind = "static")] + extern { + pub fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t, + data: libc::uintptr_t) + -> libc::uintptr_t; + } +} + +pub fn fact(n: libc::uintptr_t) -> libc::uintptr_t { + unsafe { + println!("n = {}", n); + rustrt::rust_dbg_call(cb, n) + } +} + +pub extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t { + if data == 1 { + data + } else { + fact(data - 1) * data + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/auxiliary/extern_mod_ordering_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/auxiliary/extern_mod_ordering_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/auxiliary/extern_mod_ordering_lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/auxiliary/extern_mod_ordering_lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] + +pub mod extern_mod_ordering_lib { + pub fn f() {} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/auxiliary/extern-take-value.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/auxiliary/extern-take-value.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/auxiliary/extern-take-value.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/auxiliary/extern-take-value.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub extern fn f() -> i32 { 1 } +pub extern fn g() -> i32 { 2 } + +pub fn get_f() -> extern fn() -> i32 { f } +pub fn get_g() -> extern fn() -> i32 { g } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/auxiliary/fat_drop.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/auxiliary/fat_drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/auxiliary/fat_drop.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/auxiliary/fat_drop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub static mut DROPPED: bool = false; + +pub struct S { + _unsized: [u8] +} + +impl Drop for S { + fn drop(&mut self) { + unsafe { + DROPPED = true; + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +extern fn f() { +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-call-deep2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-call-deep2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-call-deep2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-call-deep2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,54 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// ignore-emscripten no threads support + +#![feature(libc)] + +extern crate libc; +use std::thread; + +mod rustrt { + extern crate libc; + + #[link(name = "rust_test_helpers", kind = "static")] + extern { + pub fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t, + data: libc::uintptr_t) + -> libc::uintptr_t; + } +} + +extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t { + if data == 1 { + data + } else { + count(data - 1) + 1 + } +} + +fn count(n: libc::uintptr_t) -> libc::uintptr_t { + unsafe { + println!("n = {}", n); + rustrt::rust_dbg_call(cb, n) + } +} + +pub fn main() { + // Make sure we're on a thread with small Rust stacks (main currently + // has a large stack) + thread::spawn(move|| { + let result = count(1000); + println!("result = {}", result); + assert_eq!(result, 1000); + }).join(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-call-deep.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-call-deep.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-call-deep.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-call-deep.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,48 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-wasm32-bare no libc to test ffi with + +#![feature(libc)] + +extern crate libc; + +mod rustrt { + extern crate libc; + + #[link(name = "rust_test_helpers", kind = "static")] + extern { + pub fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t, + data: libc::uintptr_t) + -> libc::uintptr_t; + } +} + +extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t { + if data == 1 { + data + } else { + count(data - 1) + 1 + } +} + +fn count(n: libc::uintptr_t) -> libc::uintptr_t { + unsafe { + println!("n = {}", n); + rustrt::rust_dbg_call(cb, n) + } +} + +pub fn main() { + let result = count(1000); + println!("result = {}", result); + assert_eq!(result, 1000); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-call-direct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-call-direct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-call-direct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-call-direct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test direct calls to extern fns. + + +extern fn f(x: usize) -> usize { x * 2 } + +pub fn main() { + let x = f(22); + assert_eq!(x, 44); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-call-indirect.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-call-indirect.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-call-indirect.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-call-indirect.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,48 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-wasm32-bare no libc to test ffi with + +#![feature(libc)] + +extern crate libc; + +mod rustrt { + extern crate libc; + + #[link(name = "rust_test_helpers", kind = "static")] + extern { + pub fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t, + data: libc::uintptr_t) + -> libc::uintptr_t; + } +} + +extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t { + if data == 1 { + data + } else { + fact(data - 1) * data + } +} + +fn fact(n: libc::uintptr_t) -> libc::uintptr_t { + unsafe { + println!("n = {}", n); + rustrt::rust_dbg_call(cb, n) + } +} + +pub fn main() { + let result = fact(10); + println!("result = {}", result); + assert_eq!(result, 3628800); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-calling-convention-test.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-calling-convention-test.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-calling-convention-test.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-calling-convention-test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:extern_calling_convention.rs + +// pretty-expanded FIXME #23616 + +extern crate extern_calling_convention; + +use extern_calling_convention::foo; + +pub fn main() { + foo(1, 2, 3, 4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-call-scrub.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-call-scrub.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-call-scrub.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-call-scrub.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,58 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// This time we're testing repeatedly going up and down both stacks to +// make sure the stack pointers are maintained properly in both +// directions + +// ignore-emscripten no threads support + +#![feature(libc)] + +extern crate libc; +use std::thread; + +mod rustrt { + extern crate libc; + + #[link(name = "rust_test_helpers", kind = "static")] + extern { + pub fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t, + data: libc::uintptr_t) + -> libc::uintptr_t; + } +} + +extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t { + if data == 1 { + data + } else { + count(data - 1) + count(data - 1) + } +} + +fn count(n: libc::uintptr_t) -> libc::uintptr_t { + unsafe { + println!("n = {}", n); + rustrt::rust_dbg_call(cb, n) + } +} + +pub fn main() { + // Make sure we're on a thread with small Rust stacks (main currently + // has a large stack) + thread::spawn(move|| { + let result = count(12); + println!("result = {}", result); + assert_eq!(result, 2048); + }).join(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-compare-with-return-type.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-compare-with-return-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-compare-with-return-type.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-compare-with-return-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests that we can compare various kinds of extern fn signatures. +#![allow(non_camel_case_types)] + +extern fn voidret1() {} +extern fn voidret2() {} + +extern fn uintret() -> usize { 22 } + +extern fn uintvoidret(_x: usize) {} + +extern fn uintuintuintuintret(x: usize, y: usize, z: usize) -> usize { x+y+z } +type uintuintuintuintret = extern fn(usize,usize,usize) -> usize; + +pub fn main() { + assert!(voidret1 as extern fn() == voidret1 as extern fn()); + assert!(voidret1 as extern fn() != voidret2 as extern fn()); + + assert!(uintret as extern fn() -> usize == uintret as extern fn() -> usize); + + assert!(uintvoidret as extern fn(usize) == uintvoidret as extern fn(usize)); + + assert!(uintuintuintuintret as uintuintuintuintret == + uintuintuintuintret as uintuintuintuintret); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-crosscrate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-crosscrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-crosscrate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-crosscrate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:extern-crosscrate-source.rs +// ignore-wasm32-bare no libc to test ffi with + +#![feature(libc)] + +extern crate externcallback; +extern crate libc; + +fn fact(n: libc::uintptr_t) -> libc::uintptr_t { + unsafe { + println!("n = {}", n); + externcallback::rustrt::rust_dbg_call(externcallback::cb, n) + } +} + +pub fn main() { + let result = fact(10); + println!("result = {}", result); + assert_eq!(result, 3628800); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern_fat_drop.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern_fat_drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern_fat_drop.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern_fat_drop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:fat_drop.rs + +extern crate fat_drop; + +fn main() { + unsafe { + let data: &mut [u8] = &mut [0]; + let s: &mut fat_drop::S = std::mem::transmute::<&mut [u8], _>(data); + std::ptr::drop_in_place(s); + assert!(fat_drop::DROPPED); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-foreign-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-foreign-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-foreign-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-foreign-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +extern crate std as mystd; + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-methods.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-methods.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-methods.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-methods.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-arm +// ignore-aarch64 + +trait A { + extern "fastcall" fn test1(i: i32); + extern fn test2(i: i32); +} + +struct S; +impl S { + extern "stdcall" fn test3(i: i32) { + assert_eq!(i, 3); + } +} + +impl A for S { + extern "fastcall" fn test1(i: i32) { + assert_eq!(i, 1); + } + extern fn test2(i: i32) { + assert_eq!(i, 2); + } +} + +fn main() { + ::test1(1); + ::test2(2); + S::test3(3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-mod-abi.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-mod-abi.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-mod-abi.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-mod-abi.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +extern "C" { + fn pow(x: f64, y: f64) -> f64; +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-mod-ordering-exe.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-mod-ordering-exe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-mod-ordering-exe.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-mod-ordering-exe.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:extern_mod_ordering_lib.rs + +// pretty-expanded FIXME #23616 + +extern crate extern_mod_ordering_lib; + +use extern_mod_ordering_lib::extern_mod_ordering_lib as the_lib; + +pub fn main() { + the_lib::f(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-char.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-char.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-char.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-char.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-wasm32-bare no libc for ffi testing + +// Test a function that takes/returns a u8. + + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + pub fn rust_dbg_extern_identity_u8(v: u8) -> u8; +} + +pub fn main() { + unsafe { + assert_eq!(22, rust_dbg_extern_identity_u8(22)); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-double.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-double.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-double.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-double.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-wasm32-bare no libc for ffi testing + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + pub fn rust_dbg_extern_identity_double(v: f64) -> f64; +} + +pub fn main() { + unsafe { + assert_eq!(22.0_f64, rust_dbg_extern_identity_double(22.0_f64)); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-empty.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-empty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-empty.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-empty.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,65 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(improper_ctypes)] // FIXME: this test is inherently not FFI-safe. + +// Test a foreign function that accepts empty struct. + +// pretty-expanded FIXME #23616 +// ignore-msvc +// ignore-emscripten emcc asserts on an empty struct as an argument + +#[repr(C)] +struct TwoU8s { + one: u8, + two: u8, +} + +#[repr(C)] +struct ManyInts { + arg1: i8, + arg2: i16, + arg3: i32, + arg4: i16, + arg5: i8, + arg6: TwoU8s, +} + +#[repr(C)] +struct Empty; + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + fn rust_dbg_extern_empty_struct(v1: ManyInts, e: Empty, v2: ManyInts); +} + +pub fn main() { + unsafe { + let x = ManyInts { + arg1: 2, + arg2: 3, + arg3: 4, + arg4: 5, + arg5: 6, + arg6: TwoU8s { one: 7, two: 8, } + }; + let y = ManyInts { + arg1: 1, + arg2: 2, + arg3: 3, + arg4: 4, + arg5: 5, + arg6: TwoU8s { one: 6, two: 7, } + }; + let empty = Empty; + rust_dbg_extern_empty_struct(x, empty, y); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-TwoU16s.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-TwoU16s.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-TwoU16s.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-TwoU16s.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(improper_ctypes)] + +// ignore-wasm32-bare no libc for ffi testing + +// Test a foreign function that accepts and returns a struct +// by value. + +#[derive(Copy, Clone, PartialEq, Debug)] +pub struct TwoU16s { + one: u16, two: u16 +} + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + pub fn rust_dbg_extern_identity_TwoU16s(v: TwoU16s) -> TwoU16s; +} + +pub fn main() { + unsafe { + let x = TwoU16s {one: 22, two: 23}; + let y = rust_dbg_extern_identity_TwoU16s(x); + assert_eq!(x, y); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-TwoU32s.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-TwoU32s.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-TwoU32s.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-TwoU32s.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(improper_ctypes)] + +// ignore-wasm32-bare no libc for ffi testing + +// Test a foreign function that accepts and returns a struct +// by value. + +#[derive(Copy, Clone, PartialEq, Debug)] +pub struct TwoU32s { + one: u32, two: u32 +} + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + pub fn rust_dbg_extern_identity_TwoU32s(v: TwoU32s) -> TwoU32s; +} + +pub fn main() { + unsafe { + let x = TwoU32s {one: 22, two: 23}; + let y = rust_dbg_extern_identity_TwoU32s(x); + assert_eq!(x, y); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-TwoU64s.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-TwoU64s.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-TwoU64s.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-TwoU64s.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(improper_ctypes)] + +// ignore-wasm32-bare no libc for ffi testing + +// Test a foreign function that accepts and returns a struct +// by value. + +#[derive(Copy, Clone, PartialEq, Debug)] +pub struct TwoU64s { + one: u64, two: u64 +} + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + pub fn rust_dbg_extern_identity_TwoU64s(v: TwoU64s) -> TwoU64s; +} + +pub fn main() { + unsafe { + let x = TwoU64s {one: 22, two: 23}; + let y = rust_dbg_extern_identity_TwoU64s(x); + assert_eq!(x, y); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-TwoU8s.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-TwoU8s.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-TwoU8s.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-TwoU8s.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(improper_ctypes)] + +// ignore-wasm32-bare no libc for ffi testing + +// Test a foreign function that accepts and returns a struct +// by value. + +#[derive(Copy, Clone, PartialEq, Debug)] +pub struct TwoU8s { + one: u8, two: u8 +} + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + pub fn rust_dbg_extern_identity_TwoU8s(v: TwoU8s) -> TwoU8s; +} + +pub fn main() { + unsafe { + let x = TwoU8s {one: 22, two: 23}; + let y = rust_dbg_extern_identity_TwoU8s(x); + assert_eq!(x, y); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-u32.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-u32.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-u32.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-u32.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-wasm32-bare no libc for ffi testing + +// Test a function that takes/returns a u32. + + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + pub fn rust_dbg_extern_identity_u32(v: u32) -> u32; +} + +pub fn main() { + unsafe { + assert_eq!(22, rust_dbg_extern_identity_u32(22)); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-u64.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-u64.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-u64.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-pass-u64.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-wasm32-bare no libc for ffi testing + +// Test a call to a function that takes/returns a u64. + + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + pub fn rust_dbg_extern_identity_u64(v: u64) -> u64; +} + +pub fn main() { + unsafe { + assert_eq!(22, rust_dbg_extern_identity_u64(22)); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-prelude-core.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-prelude-core.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-prelude-core.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-prelude-core.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(extern_prelude, lang_items, start, alloc)] +#![no_std] + +extern crate std as other; + +mod foo { + pub fn test() { + let x = core::cmp::min(2, 3); + assert_eq!(x, 2); + } +} + +#[start] +fn start(_argc: isize, _argv: *const *const u8) -> isize { + foo::test(); + 0 +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-prelude-core.stderr rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-prelude-core.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-prelude-core.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-prelude-core.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +warning: the feature `extern_prelude` has been stable since 1.30.0 and no longer requires an attribute to enable + --> $DIR/extern-prelude-core.rs:12:12 + | +LL | #![feature(extern_prelude, lang_items, start, alloc)] + | ^^^^^^^^^^^^^^ + | + = note: #[warn(stable_features)] on by default + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-prelude-no-speculative.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-prelude-no-speculative.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-prelude-no-speculative.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-prelude-no-speculative.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// compile-flags: --extern LooksLikeExternCrate + +mod m { + pub struct LooksLikeExternCrate; +} + +fn main() { + // OK, speculative resolution for `unused_qualifications` doesn't try + // to resolve this as an extern crate and load that crate + let s = m::LooksLikeExternCrate {}; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-prelude-std.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-prelude-std.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-prelude-std.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-prelude-std.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(extern_prelude)] + +mod foo { + pub fn test() { + let x = std::cmp::min(2, 3); + assert_eq!(x, 2); + } +} + +fn main() { + foo::test(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-prelude-std.stderr rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-prelude-std.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-prelude-std.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-prelude-std.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +warning: the feature `extern_prelude` has been stable since 1.30.0 and no longer requires an attribute to enable + --> $DIR/extern-prelude-std.rs:12:12 + | +LL | #![feature(extern_prelude)] + | ^^^^^^^^^^^^^^ + | + = note: #[warn(stable_features)] on by default + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-pub.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-pub.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-pub.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-pub.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +extern { + pub fn free(p: *const u8); +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-return-TwoU16s.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-return-TwoU16s.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-return-TwoU16s.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-return-TwoU16s.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(improper_ctypes)] + +// ignore-wasm32-bare no libc to test ffi with + +pub struct TwoU16s { + one: u16, two: u16 +} + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + pub fn rust_dbg_extern_return_TwoU16s() -> TwoU16s; +} + +pub fn main() { + unsafe { + let y = rust_dbg_extern_return_TwoU16s(); + assert_eq!(y.one, 10); + assert_eq!(y.two, 20); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-return-TwoU32s.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-return-TwoU32s.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-return-TwoU32s.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-return-TwoU32s.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(improper_ctypes)] + +// ignore-wasm32-bare no libc to test ffi with + +pub struct TwoU32s { + one: u32, two: u32 +} + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + pub fn rust_dbg_extern_return_TwoU32s() -> TwoU32s; +} + +pub fn main() { + unsafe { + let y = rust_dbg_extern_return_TwoU32s(); + assert_eq!(y.one, 10); + assert_eq!(y.two, 20); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-return-TwoU64s.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-return-TwoU64s.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-return-TwoU64s.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-return-TwoU64s.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(improper_ctypes)] + +// ignore-wasm32-bare no libc to test ffi with + +pub struct TwoU64s { + one: u64, two: u64 +} + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + pub fn rust_dbg_extern_return_TwoU64s() -> TwoU64s; +} + +pub fn main() { + unsafe { + let y = rust_dbg_extern_return_TwoU64s(); + assert_eq!(y.one, 10); + assert_eq!(y.two, 20); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-return-TwoU8s.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-return-TwoU8s.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-return-TwoU8s.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-return-TwoU8s.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(improper_ctypes)] + +// ignore-wasm32-bare no libc to test ffi with + +pub struct TwoU8s { + one: u8, two: u8 +} + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + pub fn rust_dbg_extern_return_TwoU8s() -> TwoU8s; +} + +pub fn main() { + unsafe { + let y = rust_dbg_extern_return_TwoU8s(); + assert_eq!(y.one, 10); + assert_eq!(y.two, 20); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-rust.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-rust.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-rust.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-rust.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#[repr(C)] +pub struct Foo(u32); + +// ICE trigger, bad handling of differing types between rust and external ABIs +pub extern fn bar() -> Foo { + Foo(0) +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-take-value.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-take-value.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-take-value.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-take-value.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:extern-take-value.rs + +extern crate extern_take_value; + +pub fn main() { + let a: extern "C" fn() -> i32 = extern_take_value::get_f(); + let b: extern "C" fn() -> i32 = extern_take_value::get_f(); + let c: extern "C" fn() -> i32 = extern_take_value::get_g(); + + assert!(a == b); + assert!(a != c); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-thiscall.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-thiscall.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-thiscall.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-thiscall.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-arm +// ignore-aarch64 + +#![feature(abi_thiscall)] + +trait A { + extern "thiscall" fn test1(i: i32); +} + +struct S; + +impl A for S { + extern "thiscall" fn test1(i: i32) { + assert_eq!(i, 1); + } +} + +extern "thiscall" fn test2(i: i32) { + assert_eq!(i, 2); +} + +fn main() { + ::test1(1); + test2(2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-inherent-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-inherent-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-inherent-impl.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-inherent-impl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Test that inherent impls can be defined for extern types. + +#![feature(extern_types)] + +extern { + type A; +} + +impl A { + fn foo(&self) { } +} + +fn use_foo(x: &A) { + x.foo(); +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-manual-sync-send.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-manual-sync-send.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-manual-sync-send.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-manual-sync-send.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that unsafe impl for Sync/Send can be provided for extern types. + +#![feature(extern_types)] + +extern { + type A; +} + +unsafe impl Sync for A { } +unsafe impl Send for A { } + +fn assert_sync() { } +fn assert_send() { } + +fn main() { + assert_sync::(); + assert_send::(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-pointer-cast.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-pointer-cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-pointer-cast.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-pointer-cast.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Test that pointers to extern types can be cast from/to usize, +// despite being !Sized. + +#![feature(extern_types)] + +extern { + type A; +} + +struct Foo { + x: u8, + tail: A, +} + +struct Bar { + x: u8, + tail: T, +} + +#[cfg(target_pointer_width = "32")] +const MAGIC: usize = 0xdeadbeef; +#[cfg(target_pointer_width = "64")] +const MAGIC: usize = 0x12345678deadbeef; + +fn main() { + assert_eq!((MAGIC as *const A) as usize, MAGIC); + assert_eq!((MAGIC as *const Foo) as usize, MAGIC); + assert_eq!((MAGIC as *const Bar) as usize, MAGIC); + assert_eq!((MAGIC as *const Bar>) as usize, MAGIC); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-size_of_val.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-size_of_val.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-size_of_val.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-size_of_val.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(extern_types)] + +use std::mem::{size_of_val, align_of_val}; + +extern { + type A; +} + +fn main() { + let x: &A = unsafe { + &*(1usize as *const A) + }; + + assert_eq!(size_of_val(x), 0); + assert_eq!(align_of_val(x), 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-thin-pointer.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-thin-pointer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-thin-pointer.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-thin-pointer.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,53 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Test that pointers and references to extern types are thin, ie they have the same size and +// alignment as a pointer to (). + +#![feature(extern_types)] + +use std::mem::{align_of, size_of}; + +extern { + type A; +} + +struct Foo { + x: u8, + tail: A, +} + +struct Bar { + x: u8, + tail: T, +} + +fn assert_thin() { + assert_eq!(size_of::<*const T>(), size_of::<*const ()>()); + assert_eq!(align_of::<*const T>(), align_of::<*const ()>()); + + assert_eq!(size_of::<*mut T>(), size_of::<*mut ()>()); + assert_eq!(align_of::<*mut T>(), align_of::<*mut ()>()); + + assert_eq!(size_of::<&T>(), size_of::<&()>()); + assert_eq!(align_of::<&T>(), align_of::<&()>()); + + assert_eq!(size_of::<&mut T>(), size_of::<&mut ()>()); + assert_eq!(align_of::<&mut T>(), align_of::<&mut ()>()); +} + +fn main() { + assert_thin::(); + assert_thin::(); + assert_thin::>(); + assert_thin::>>(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-trait-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-trait-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-trait-impl.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-types-trait-impl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Test that traits can be implemented for extern types. + +#![feature(extern_types)] + +extern { + type A; +} + +trait Foo { + fn foo(&self) { } +} + +impl Foo for A { + fn foo(&self) { } +} + +fn assert_foo() { } + +fn use_foo(x: &Foo) { + x.foo(); +} + +fn main() { + assert_foo::(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-vectorcall.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-vectorcall.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/extern/extern-vectorcall.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/extern/extern-vectorcall.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-arm +// ignore-aarch64 + +#![feature(abi_vectorcall)] + +trait A { + extern "vectorcall" fn test1(i: i32); +} + +struct S; + +impl A for S { + extern "vectorcall" fn test1(i: i32) { + assert_eq!(i, 1); + } +} + +extern "vectorcall" fn test2(i: i32) { + assert_eq!(i, 2); +} + +fn main() { + ::test1(1); + test2(2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/fixup-deref-mut.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/fixup-deref-mut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/fixup-deref-mut.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/fixup-deref-mut.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // pretty-expanded FIXME #23616 use std::ops::{Deref, DerefMut}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/auxiliary/fn-abi.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/auxiliary/fn-abi.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/auxiliary/fn-abi.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/auxiliary/fn-abi.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[no_mangle] +pub extern fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/auxiliary/foreign_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/auxiliary/foreign_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/auxiliary/foreign_lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/auxiliary/foreign_lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,48 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="foreign_lib"] + +#![feature(libc)] + +pub mod rustrt { + extern crate libc; + + #[link(name = "rust_test_helpers", kind = "static")] + extern { + pub fn rust_get_test_int() -> libc::intptr_t; + } +} + +pub mod rustrt2 { + extern crate libc; + + extern { + pub fn rust_get_test_int() -> libc::intptr_t; + } +} + +pub mod rustrt3 { + // Different type, but same ABI (on all supported platforms). + // Ensures that we don't ICE or trigger LLVM asserts when + // importing the same symbol under different types. + // See https://github.com/rust-lang/rust/issues/32740. + extern { + pub fn rust_get_test_int() -> *const u8; + } +} + +pub fn local_uses() { + unsafe { + let x = rustrt::rust_get_test_int(); + assert_eq!(x, rustrt2::rust_get_test_int()); + assert_eq!(x as *const _, rustrt3::rust_get_test_int()); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/foreign2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/foreign2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/foreign2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/foreign2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// ignore-wasm32-bare no libc to test ffi with +// pretty-expanded FIXME #23616 + +#![feature(libc)] + +extern crate libc; + +mod bar { + extern {} +} + +mod zed { + extern {} +} + +mod mlibc { + use libc::{c_int, c_void, size_t, ssize_t}; + + extern { + pub fn write(fd: c_int, buf: *const c_void, count: size_t) -> ssize_t; + } +} + +mod baz { + extern {} +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-call-no-runtime.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-call-no-runtime.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-call-no-runtime.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-call-no-runtime.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,65 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten no threads support + +#![feature(libc)] + +extern crate libc; + +use std::mem; +use std::thread; + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t), + data: libc::uintptr_t) -> libc::uintptr_t; +} + +pub fn main() { + unsafe { + thread::spawn(move|| { + let i: isize = 100; + rust_dbg_call(callback_isize, mem::transmute(&i)); + }).join().unwrap(); + + thread::spawn(move|| { + let i: i32 = 100; + rust_dbg_call(callback_i32, mem::transmute(&i)); + }).join().unwrap(); + + thread::spawn(move|| { + let i: i64 = 100; + rust_dbg_call(callback_i64, mem::transmute(&i)); + }).join().unwrap(); + } +} + +extern fn callback_isize(data: libc::uintptr_t) { + unsafe { + let data: *const isize = mem::transmute(data); + assert_eq!(*data, 100); + } +} + +extern fn callback_i64(data: libc::uintptr_t) { + unsafe { + let data: *const i64 = mem::transmute(data); + assert_eq!(*data, 100); + } +} + +extern fn callback_i32(data: libc::uintptr_t) { + unsafe { + let data: *const i32 = mem::transmute(data); + assert_eq!(*data, 100); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-dupe.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-dupe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-dupe.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-dupe.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:foreign_lib.rs +// ignore-wasm32-bare no libc to test ffi with + +// Check that we can still call duplicated extern (imported) functions +// which were declared in another crate. See issues #32740 and #32783. + + +extern crate foreign_lib; + +pub fn main() { + unsafe { + let x = foreign_lib::rustrt::rust_get_test_int(); + assert_eq!(x, foreign_lib::rustrt2::rust_get_test_int()); + assert_eq!(x as *const _, foreign_lib::rustrt3::rust_get_test_int()); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-fn-linkname.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-fn-linkname.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-fn-linkname.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-fn-linkname.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-wasm32-bare no libc to test ffi with + +#![feature(libc)] + +extern crate libc; +use std::ffi::CString; + +mod mlibc { + use libc::{c_char, size_t}; + + extern { + #[link_name = "strlen"] + pub fn my_strlen(str: *const c_char) -> size_t; + } +} + +fn strlen(str: String) -> usize { + // C string is terminated with a zero + let s = CString::new(str).unwrap(); + unsafe { + mlibc::my_strlen(s.as_ptr()) as usize + } +} + +pub fn main() { + let len = strlen("Rust".to_string()); + assert_eq!(len, 4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-fn-with-byval.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-fn-with-byval.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-fn-with-byval.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-fn-with-byval.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(improper_ctypes)] + +// ignore-wasm32-bare no libc to test ffi with + +#[derive(Copy, Clone)] +pub struct S { + x: u64, + y: u64, + z: u64, +} + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + pub fn get_x(x: S) -> u64; + pub fn get_y(x: S) -> u64; + pub fn get_z(x: S) -> u64; +} + +#[inline(never)] +fn indirect_call(func: unsafe extern fn(s: S) -> u64, s: S) -> u64 { + unsafe { + func(s) + } +} + +fn main() { + let s = S { x: 1, y: 2, z: 3 }; + assert_eq!(s.x, indirect_call(get_x, s)); + assert_eq!(s.y, indirect_call(get_y, s)); + assert_eq!(s.z, indirect_call(get_z, s)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-int-types.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-int-types.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-int-types.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-int-types.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![forbid(improper_ctypes)] +#![allow(dead_code)] + +mod xx { + extern { + pub fn strlen(str: *const u8) -> usize; + pub fn foo(x: isize, y: usize); + } +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-mod-src/inner.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-mod-src/inner.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-mod-src/inner.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-mod-src/inner.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + +pub fn main() { + let f = "Makefile"; + let s = rustrt.str_buf(f); + let buf = libc.malloc(1024); + let fd = libc.open(s, 0, 0); + libc.read(fd, buf, 1024); + libc.write(1, buf, 1024); + libc.close(fd); + libc.free(buf); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-mod-unused-const.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-mod-unused-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-mod-unused-const.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-mod-unused-const.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +mod foo { + extern { + pub static errno: u32; + } +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-no-abi.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-no-abi.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-no-abi.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-no-abi.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ABI is cdecl by default + +// ignore-wasm32-bare no libc to test ffi with +// pretty-expanded FIXME #23616 + +#![feature(libc)] + +mod rustrt { + extern crate libc; + + #[link(name = "rust_test_helpers", kind = "static")] + extern { + pub fn rust_get_test_int() -> libc::intptr_t; + } +} + +pub fn main() { + unsafe { + rustrt::rust_get_test_int(); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-src/foreign.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-src/foreign.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-src/foreign.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-src/foreign.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + +pub fn main() { + libc.puts(rustrt.str_buf("hello, extern world 1")); + libc.puts(rustrt.str_buf("hello, extern world 2")); + libc.puts(rustrt.str_buf("hello, extern world 3")); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-truncated-arguments.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-truncated-arguments.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-truncated-arguments.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/foreign/foreign-truncated-arguments.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags: -O +// Regression test for https://github.com/rust-lang/rust/issues/33868 + +#[repr(C)] +pub struct S { + a: u32, + b: f32, + c: u32 +} + +#[no_mangle] +#[inline(never)] +pub extern "C" fn test(s: S) -> u32 { + s.c +} + +fn main() { + assert_eq!(test(S{a: 0, b: 0.0, c: 42}), 42); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/auto-loop.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/auto-loop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/auto-loop.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/auto-loop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + let mut sum = 0; + let xs = vec![1, 2, 3, 4, 5]; + for x in &xs { + sum += *x; + } + assert_eq!(sum, 15); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/break.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/break.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/break.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/break.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + let mut i = 0; + while i < 20 { i += 1; if i == 10 { break; } } + assert_eq!(i, 10); + loop { i += 1; if i == 20 { break; } } + assert_eq!(i, 20); + let xs = [1, 2, 3, 4, 5, 6]; + for x in &xs { + if *x == 3 { break; } assert!((*x <= 3)); + } + i = 0; + while i < 10 { i += 1; if i % 2 == 0 { continue; } assert!((i % 2 != 0)); } + i = 0; + loop { + i += 1; if i % 2 == 0 { continue; } assert!((i % 2 != 0)); + if i >= 10 { break; } + } + let ys = vec![1, 2, 3, 4, 5, 6]; + for x in &ys { + if *x % 2 == 0 { continue; } + assert!((*x % 2 != 0)); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/break-value.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/break-value.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/break-value.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/break-value.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unreachable_code)] +// pretty-expanded FIXME #23616 + +fn int_id(x: isize) -> isize { return x; } + +pub fn main() { loop { int_id(break); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-destruct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-destruct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-destruct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-destruct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +struct Pair { x: isize, y: isize } + +pub fn main() { + for elt in &(vec![Pair {x: 10, y: 20}, Pair {x: 30, y: 0}]) { + assert_eq!(elt.x + elt.y, 30); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators-break.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators-break.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators-break.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators-break.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + let x = [1; 100]; + let mut y = 0; + for i in &x[..] { + if y > 10 { + break; + } + y += *i; + } + assert_eq!(y, 11); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators-hashmap-break-restart.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators-hashmap-break-restart.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators-hashmap-break-restart.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators-hashmap-break-restart.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::collections::HashMap; + +// This is a fancy one: it uses an external iterator established +// outside the loop, breaks, then _picks back up_ and continues +// iterating with it. + +pub fn main() { + let mut h = HashMap::new(); + let kvs = [(1, 10), (2, 20), (3, 30)]; + for &(k,v) in &kvs { + h.insert(k,v); + } + let mut x = 0; + let mut y = 0; + + let mut i = h.iter(); + + for (&k,&v) in i.by_ref() { + x += k; + y += v; + break; + } + + for (&k,&v) in i { + x += k; + y += v; + } + + assert_eq!(x, 6); + assert_eq!(y, 60); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators-hashmap.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators-hashmap.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators-hashmap.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators-hashmap.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::collections::HashMap; + +pub fn main() { + let mut h = HashMap::new(); + let kvs = [(1, 10), (2, 20), (3, 30)]; + for &(k,v) in &kvs { + h.insert(k,v); + } + let mut x = 0; + let mut y = 0; + for (&k,&v) in &h { + x += k; + y += v; + } + assert_eq!(x, 6); + assert_eq!(y, 60); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators-loop.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators-loop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators-loop.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators-loop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + let x = [1; 100]; + let mut y = 0; + for (n,i) in x.iter().enumerate() { + if n < 10 { + continue; + } + y += *i; + } + assert_eq!(y, 90); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators-nested.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators-nested.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators-nested.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators-nested.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + let x = [1; 100]; + let y = [2; 100]; + let mut p = 0; + let mut q = 0; + for i in &x[..] { + for j in &y[..] { + p += *j; + } + q += *i + p; + } + assert_eq!(q, 1010100); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-external-iterators.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + let x = [1; 100]; + let mut y = 0; + for i in &x[..] { + y += *i + } + assert_eq!(y, 100); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-nested.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-nested.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-nested.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-nested.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +fn two(mut it: F) where F: FnMut(isize) { it(0); it(1); } + +pub fn main() { + let mut a: Vec = vec![-1, -1, -1, -1]; + let mut p: isize = 0; + two(|i| { + two(|j| { a[p as usize] = 10 * i + j; p += 1; }) + }); + assert_eq!(a[0], 0); + assert_eq!(a[1], 1); + assert_eq!(a[2], 10); + assert_eq!(a[3], 11); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-put-structured.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-put-structured.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-put-structured.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-put-structured.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +fn pairs(mut it: F) where F: FnMut((isize, isize)) { + let mut i: isize = 0; + let mut j: isize = 0; + while i < 10 { it((i, j)); i += 1; j += i; } +} + +pub fn main() { + let mut i: isize = 10; + let mut j: isize = 0; + pairs(|p| { + let (_0, _1) = p; + println!("{}", _0); + println!("{}", _1); + assert_eq!(_0 + 10, i); + i += 1; + j = _1; + }); + assert_eq!(j, 45); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-simple-outer-slot.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-simple-outer-slot.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-simple-outer-slot.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/foreach-simple-outer-slot.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + +pub fn main() { + let mut sum: isize = 0; + first_ten(|i| { println!("main"); println!("{}", i); sum = sum + i; }); + println!("sum"); + println!("{}", sum); + assert_eq!(sum, 45); +} + +fn first_ten(mut it: F) where F: FnMut(isize) { + let mut i: isize = 0; + while i < 10 { println!("first_ten"); it(i); i = i + 1; } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-goofiness.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-goofiness.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-goofiness.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-goofiness.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +enum BogusOption { + None, + Some(T), +} + +type Iterator = isize; + +pub fn main() { + let x = [ 3, 3, 3 ]; + for i in &x { + assert_eq!(*i, 3); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-has-unit-body.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-has-unit-body.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-has-unit-body.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-has-unit-body.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + // Check that the tail statement in the body unifies with something + for _ in 0..3 { + unsafe { std::mem::uninitialized() } + } + + // Check that the tail statement in the body can be unit + for _ in 0..3 { + () + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-into-iterator.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-into-iterator.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-into-iterator.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-into-iterator.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that for loops can do what RFC #235 claims + + +fn main() { + let mut v = vec![1]; + + for x in &v { + assert_eq!(x, &1); + } + + for x in &mut v { + assert_eq!(x, &mut 1); + } + + for x in v { + assert_eq!(x, 1); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-lifetime-of-unbound-values.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-lifetime-of-unbound-values.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-lifetime-of-unbound-values.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-lifetime-of-unbound-values.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test when destructors run in a for loop. The intention is +// that the value for each iteration is dropped *after* the loop +// body has executed. This is true even when the value is assigned +// to a `_` pattern (and hence ignored). + +use std::cell::Cell; + +struct Flag<'a>(&'a Cell); + +impl<'a> Drop for Flag<'a> { + fn drop(&mut self) { + self.0.set(false) + } +} + +fn main() { + let alive2 = Cell::new(true); + for _i in std::iter::once(Flag(&alive2)) { + // The Flag value should be alive in the for loop body + assert_eq!(alive2.get(), true); + } + // The Flag value should be dead outside of the loop + assert_eq!(alive2.get(), false); + + let alive = Cell::new(true); + for _ in std::iter::once(Flag(&alive)) { + // The Flag value should be alive in the for loop body even if it wasn't + // bound by the for loop + assert_eq!(alive.get(), true); + } + // The Flag value should be dead outside of the loop + assert_eq!(alive.get(), false); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-macro.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +macro_rules! var { + ( $name:ident ) => ( $name ); +} + +pub fn main() { + let x = [ 3, 3, 3 ]; + for var!(i) in &x { + assert_eq!(*i, 3); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-mut-ref-element.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-mut-ref-element.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-mut-ref-element.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-mut-ref-element.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests that for loops can bind elements as mutable references + +fn main() { + for ref mut _a in std::iter::once(true) {} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-no-std.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-no-std.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-no-std.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-no-std.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +#![feature(lang_items, start, alloc)] +#![no_std] + +extern crate std as other; + +#[macro_use] extern crate alloc; + +#[start] +fn start(_argc: isize, _argv: *const *const u8) -> isize { + for _ in [1,2,3].iter() { } + 0 +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-panic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-panic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-panic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-panic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +pub fn main() { let x: Vec = Vec::new(); for _ in &x { panic!("moop"); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-unconstrained-element-type-i32-fallback.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-unconstrained-element-type-i32-fallback.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-unconstrained-element-type-i32-fallback.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/for-loop-unconstrained-element-type-i32-fallback.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that the type of `sum` falls back to `i32` here, +// and that the for loop desugaring doesn't interfere with +// that. + +fn main() { + let mut sum = 0; + for i in Vec::new() { + sum += &i; + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/label_break_value.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/label_break_value.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/label_break_value.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/label_break_value.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,126 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_assignments)] +#![feature(label_break_value)] + +// Test control flow to follow label_break_value semantics +fn label_break(a: bool, b: bool) -> u32 { + let mut v = 0; + 'b: { + v = 1; + if a { + break 'b; + } + v = 2; + if b { + break 'b; + } + v = 3; + } + return v; +} + +// Test that values can be returned +fn break_value(a: bool, b: bool) -> u32 { + let result = 'block: { + if a { break 'block 1; } + if b { break 'block 2; } + 3 + }; + result +} + +// Test nesting of labeled blocks +// here we only check that it compiles +fn label_break_nested() { + 'b: { + println!("hi"); + if false { + break 'b; + } + 'c: { + if false { + break 'b; + } + break 'c; + } + println!("hello"); + if true { + break 'b; + } + } +} + +// Tests for mixing labeled blocks with loop constructs +// This function should be the identity function +fn label_break_mixed(v: u32) -> u32 { + let mut r = 0; + 'b: { + // Unlabeled break still works + // (only crossing boundaries is an error) + loop { + break; + } + if v == 0 { + break 'b; + } + // Labeled breaking an inner loop still works + 'c: loop { + if r == 1 { + break 'c; + } + r += 1; + } + assert_eq!(r, 1); + if v == 1 { + break 'b; + } + // Labeled breaking an outer loop still works + 'd: loop { + 'e: { + if v == r { + break 'b; + } + if r == 5 { + break 'd; + } + r += 1; + } + } + assert_eq!(r, 5); + assert!(v > r); + // Here we test return from inside a labeled block + return v; + } + r +} + +pub fn main() { + assert_eq!(label_break(true, false), 1); + assert_eq!(label_break(false, true), 2); + assert_eq!(label_break(false, false), 3); + + assert_eq!(break_value(true, false), 1); + assert_eq!(break_value(false, true), 2); + assert_eq!(break_value(false, false), 3); + + assert_eq!(label_break_mixed(0), 0); + assert_eq!(label_break_mixed(1), 1); + assert_eq!(label_break_mixed(2), 2); + assert_eq!(label_break_mixed(3), 3); + assert_eq!(label_break_mixed(4), 4); + assert_eq!(label_break_mixed(5), 5); + assert_eq!(label_break_mixed(6), 6); + + // FIXME: ensure that labeled blocks work if produced by macros and in match arms +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/labeled-break.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/labeled-break.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/labeled-break.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/labeled-break.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +pub fn main() { + 'foo: loop { + loop { + break 'foo; + } + } + + 'bar: for _ in 0..100 { + loop { + break 'bar; + } + } + + 'foobar: while 1 + 1 == 2 { + loop { + break 'foobar; + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/linear-for-loop.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/linear-for-loop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/linear-for-loop.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/linear-for-loop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn main() { + let x = vec![1, 2, 3]; + let mut y = 0; + for i in &x { println!("{}", *i); y += *i; } + println!("{}", y); + assert_eq!(y, 6); + let s = "hello there".to_string(); + let mut i: isize = 0; + for c in s.bytes() { + if i == 0 { assert_eq!(c, 'h' as u8); } + if i == 1 { assert_eq!(c, 'e' as u8); } + if i == 2 { assert_eq!(c, 'l' as u8); } + if i == 3 { assert_eq!(c, 'l' as u8); } + if i == 4 { assert_eq!(c, 'o' as u8); } + // ... + + i += 1; + println!("{}", i); + println!("{}", c); + } + assert_eq!(i, 11); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/liveness-assign-imm-local-after-loop.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/liveness-assign-imm-local-after-loop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/liveness-assign-imm-local-after-loop.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/liveness-assign-imm-local-after-loop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_assignments)] +// pretty-expanded FIXME #23616 + +#![allow(unreachable_code)] +#![allow(unused_variables)] + +fn test(_cond: bool) { + let v: isize; + v = 1; + loop { } // loop never terminates, so no error is reported + v = 2; +} + +pub fn main() { + // note: don't call test()... :) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/liveness-loop-break.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/liveness-loop-break.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/liveness-loop-break.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/liveness-loop-break.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn test() { + let v; + loop { + v = 3; + break; + } + println!("{}", v); +} + +pub fn main() { + test(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/liveness-move-in-loop.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/liveness-move-in-loop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/liveness-move-in-loop.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/liveness-move-in-loop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +// pretty-expanded FIXME #23616 + +fn take(x: isize) -> isize {x} + +fn the_loop() { + let mut list = Vec::new(); + loop { + let x = 5; + if x > 3 { + list.push(take(x)); + } else { + break; + } + } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-break-cont-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-break-cont-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-break-cont-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-break-cont-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + let _i = 0_usize; + loop { + break; + } + assert!(true); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-break-cont.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-break-cont.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-break-cont.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-break-cont.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,49 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn main() { + let mut i = 0_usize; + loop { + println!("a"); + i += 1_usize; + if i == 10_usize { + break; + } + } + assert_eq!(i, 10_usize); + let mut is_even = false; + loop { + if i == 21_usize { + break; + } + println!("b"); + is_even = false; + i += 1_usize; + if i % 2_usize != 0_usize { + continue; + } + is_even = true; + } + assert!(!is_even); + loop { + println!("c"); + if i == 22_usize { + break; + } + is_even = false; + i += 1_usize; + if i % 2_usize != 0_usize { + continue; + } + is_even = true; + } + assert!(is_even); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-break-value.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-break-value.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-break-value.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-break-value.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,148 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unreachable_code)] +#![feature(never_type)] + +#[allow(unused)] +fn never_returns() { + loop { + break loop {}; + } +} + +pub fn main() { + let value = 'outer: loop { + if 1 == 1 { + break 13; + } else { + let _never: ! = loop { + break loop { + break 'outer panic!(); + } + }; + } + }; + assert_eq!(value, 13); + + let x = [1, 3u32, 5]; + let y = [17]; + let z = []; + let coerced: &[_] = loop { + match 2 { + 1 => break &x, + 2 => break &y, + 3 => break &z, + _ => (), + } + }; + assert_eq!(coerced, &[17u32]); + + let trait_unified = loop { + break if true { + break Default::default() + } else { + break [13, 14] + }; + }; + assert_eq!(trait_unified, [0, 0]); + + let trait_unified_2 = loop { + if false { + break [String::from("Hello")] + } else { + break Default::default() + }; + }; + assert_eq!(trait_unified_2, [""]); + + let trait_unified_3 = loop { + break if false { + break [String::from("Hello")] + } else { + ["Yes".into()] + }; + }; + assert_eq!(trait_unified_3, ["Yes"]); + + let regular_break = loop { + if true { + break; + } else { + break break Default::default(); + } + }; + assert_eq!(regular_break, ()); + + let regular_break_2 = loop { + if true { + break Default::default(); + } else { + break; + } + }; + assert_eq!(regular_break_2, ()); + + let regular_break_3 = loop { + break if true { + Default::default() + } else { + break; + } + }; + assert_eq!(regular_break_3, ()); + + let regular_break_4 = loop { + break (); + break; + }; + assert_eq!(regular_break_4, ()); + + let regular_break_5 = loop { + break; + break (); + }; + assert_eq!(regular_break_5, ()); + + let nested_break_value = 'outer2: loop { + let _a: u32 = 'inner: loop { + if true { + break 'outer2 "hello"; + } else { + break 'inner 17; + } + }; + panic!(); + }; + assert_eq!(nested_break_value, "hello"); + + let break_from_while_cond = loop { + 'inner_loop: while break 'inner_loop { + panic!(); + } + break 123; + }; + assert_eq!(break_from_while_cond, 123); + + let break_from_while_to_outer = 'outer_loop: loop { + while break 'outer_loop 567 { + panic!("from_inner"); + } + panic!("from outer"); + }; + assert_eq!(break_from_while_to_outer, 567); + + let rust = true; + let value = loop { + break rust; + }; + assert!(value); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-diverges.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-diverges.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-diverges.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-diverges.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_parens)] +// pretty-expanded FIXME #23616 + +/* Make sure a loop{} can be the tailexpr in the body +of a diverging function */ + +fn forever() -> ! { + loop{} +} + +pub fn main() { + if (1 == 2) { forever(); } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-labeled-break-value.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-labeled-break-value.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-labeled-break-value.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-labeled-break-value.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +fn main() { + 'outer: loop { + let _: i32 = loop { break 'outer }; + } + 'outer2: loop { + let _: i32 = loop { loop { break 'outer2 } }; + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-label-shadowing.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-label-shadowing.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-label-shadowing.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-label-shadowing.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Issue #12512. + +// pretty-expanded FIXME #23616 + +fn main() { + let mut foo = Vec::new(); + 'foo: for i in &[1, 2, 3] { + foo.push(*i); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-no-reinit-needed-post-bot.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-no-reinit-needed-post-bot.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-no-reinit-needed-post-bot.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-no-reinit-needed-post-bot.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +struct S; +// Ensure S is moved, not copied, on assignment. +impl Drop for S { fn drop(&mut self) { } } + +// user-defined function "returning" bottom (i.e. no return at all). +fn my_panic() -> ! { loop {} } + +pub fn step(f: bool) { + let mut g = S; + let mut i = 0; + loop + { + if i > 10 { break; } else { i += 1; } + + let _g = g; + + if f { + // re-initialize g, but only before restarting loop. + g = S; + continue; + } + + my_panic(); + + // we never get here, so we do not need to re-initialize g. + } +} + +pub fn main() { + step(true); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-scope.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-scope.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-scope.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/loop-scope.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + let x = vec![10, 20, 30]; + let mut sum = 0; + for x in &x { sum += *x; } + assert_eq!(sum, 60); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-cont.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-cont.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-cont.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-cont.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Issue #825: Should recheck the loop condition after continuing +pub fn main() { + let mut i = 1; + while i > 0 { + assert!((i > 0)); + println!("{}", i); + i -= 1; + continue; + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-flow-graph.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-flow-graph.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-flow-graph.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-flow-graph.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +// pretty-expanded FIXME #23616 + +pub fn main() { let x: isize = 10; while x == 10 && x == 11 { let _y = 0xf00_usize; } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-label.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-label.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-label.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-label.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unreachable_code)] + + +pub fn main() { + let mut i = 100; + 'w: while 1 + 1 == 2 { + i -= 1; + if i == 95 { + break 'w; + panic!("Should have broken out of loop"); + } + } + assert_eq!(i, 95); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-let.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-let.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-let.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-let.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,56 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::collections::BinaryHeap; + +fn make_pq() -> BinaryHeap { + BinaryHeap::from(vec![1,2,3]) +} + +pub fn main() { + let mut pq = make_pq(); + let mut sum = 0; + while let Some(x) = pq.pop() { + sum += x; + } + assert_eq!(sum, 6); + + pq = make_pq(); + sum = 0; + 'a: while let Some(x) = pq.pop() { + sum += x; + if x == 2 { + break 'a; + } + } + assert_eq!(sum, 5); + + pq = make_pq(); + sum = 0; + 'a2: while let Some(x) = pq.pop() { + if x == 3 { + continue 'a2; + } + sum += x; + } + assert_eq!(sum, 3); + + let mut pq1 = make_pq(); + sum = 0; + while let Some(x) = pq1.pop() { + let mut pq2 = make_pq(); + while let Some(y) = pq2.pop() { + sum += x * y; + } + } + assert_eq!(sum, 6 + 12 + 18); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-loop-constraints-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-loop-constraints-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-loop-constraints-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-loop-constraints-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_assignments)] +#![allow(unused_variables)] + +pub fn main() { + let mut y: isize = 42; + let mut z: isize = 42; + let mut x: isize; + while z < 50 { + z += 1; + while false { x = y; y = z; } + println!("{}", y); + } + assert!((y == 42 && z == 50)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-prelude-drop.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-prelude-drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-prelude-drop.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-prelude-drop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +use std::string::String; + +#[derive(PartialEq)] +enum t { a, b(String), } + +fn make(i: isize) -> t { + if i > 10 { return t::a; } + let mut s = String::from("hello"); + // Ensure s is non-const. + + s.push_str("there"); + return t::b(s); +} + +pub fn main() { + let mut i = 0; + + + // The auto slot for the result of make(i) should not leak. + while make(i) != t::a { i += 1; } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +pub fn main() { + let mut x: isize = 10; + let mut y: isize = 0; + while y < x { println!("{}", y); println!("hello"); y = y + 1; } + while x > 0 { + println!("goodbye"); + x = x - 1; + println!("{}", x); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-with-break.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-with-break.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-with-break.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/for-loop-while/while-with-break.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + let mut i: isize = 90; + while i < 100 { + println!("{}", i); + i = i + 1; + if i == 95 { + let _v: Vec = + vec![1, 2, 3, 4, 5]; // we check that it is freed by break + + println!("breaking"); + break; + } + } + assert_eq!(i, 95); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/format-hygiene.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/format-hygiene.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/format-hygiene.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/format-hygiene.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_upper_case_globals)] pub const arg0: u8 = 1; pub fn main() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/fsu-moves-and-copies.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/fsu-moves-and-copies.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/fsu-moves-and-copies.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/fsu-moves-and-copies.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(stable_features)] // Issue 4691: Ensure that functional-struct-updates operates // correctly and moves rather than copy when appropriate. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/auxiliary/fn-abi.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/auxiliary/fn-abi.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/auxiliary/fn-abi.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/auxiliary/fn-abi.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[no_mangle] +pub extern fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/call-closure-from-overloaded-op.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/call-closure-from-overloaded-op.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/call-closure-from-overloaded-op.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/call-closure-from-overloaded-op.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn foo() -> isize { 22 } + +pub fn main() { + let mut x: Vec isize> = Vec::new(); + x.push(foo); + assert_eq!((x[0])(), 22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/capture-clauses-boxed-closures.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/capture-clauses-boxed-closures.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/capture-clauses-boxed-closures.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/capture-clauses-boxed-closures.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn each(x: &[T], mut f: F) where F: FnMut(&T) { + for val in x { + f(val) + } +} + +fn main() { + let mut sum = 0_usize; + let elems = [ 1_usize, 2, 3, 4, 5 ]; + each(&elems, |val| sum += *val); + assert_eq!(sum, 15); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/capture-clauses-unboxed-closures.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/capture-clauses-unboxed-closures.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/capture-clauses-unboxed-closures.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/capture-clauses-unboxed-closures.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn each<'a,T,F:FnMut(&'a T)>(x: &'a [T], mut f: F) { + for val in x { + f(val) + } +} + +fn main() { + let mut sum = 0; + let elems = [ 1, 2, 3, 4, 5 ]; + each(&elems, |val: &usize| sum += *val); + assert_eq!(sum, 15); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/clone-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/clone-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/clone-closure.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/clone-closure.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Check that closures implement `Clone`. + +#[derive(Clone)] +struct S(i32); + +fn main() { + let mut a = S(5); + let mut hello = move || { + a.0 += 1; + println!("Hello {}", a.0); + a.0 + }; + + let mut hello2 = hello.clone(); + assert_eq!(6, hello2()); + assert_eq!(6, hello()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-bounds-can-capture-chan.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-bounds-can-capture-chan.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-bounds-can-capture-chan.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-bounds-can-capture-chan.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +use std::sync::mpsc::channel; + +fn foo(blk: F) { + blk(); +} + +pub fn main() { + let (tx, rx) = channel(); + foo(move || { + tx.send(()).unwrap(); + }); + rx.recv().unwrap(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-expected-type/expect-infer-supply-two-infers.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-expected-type/expect-infer-supply-two-infers.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-expected-type/expect-infer-supply-two-infers.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-expected-type/expect-infer-supply-two-infers.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +fn with_closure(_: F) + where F: FnOnce(Vec, A) +{ +} + +fn expect_free_supply_free<'x>(x: &'x u32) { + with_closure(|mut x: Vec<_>, y| { + // Shows that the call to `x.push()` is influencing type of `y`... + x.push(22_u32); + + // ...since we now know the type of `y` and can resolve the method call. + y.wrapping_add(1); + }); +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-expected-type/issue-38714.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-expected-type/issue-38714.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-expected-type/issue-38714.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-expected-type/issue-38714.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +struct UsizeRef<'a> { + a: &'a usize +} + +type RefTo = Box Fn(&'r Vec) -> UsizeRef<'r>>; + +fn ref_to<'a>(vec: &'a Vec) -> UsizeRef<'a> { + UsizeRef{ a: &vec[0]} +} + +fn main() { + // Regression test: this was causing ICEs; it should compile. + let a: RefTo = Box::new(|vec: &Vec| { + UsizeRef{ a: &vec[0] } + }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-expected-type/README.md rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-expected-type/README.md --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-expected-type/README.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-expected-type/README.md 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +Some tests targeted at how we deduce the types of closure arguments. +This process is a result of some heuristics aimed at combining the +*expected type* we have with the *actual types* that we get from +inputs. This investigation was kicked off by #38714, which revealed +some pretty deep flaws in the ad-hoc way that we were doing things +before. + +See also `src/test/compile-fail/closure-expected-type`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-expected-type/supply-just-return-type.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-expected-type/supply-just-return-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-expected-type/supply-just-return-type.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-expected-type/supply-just-return-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn with_closure(f: F) -> Result + where F: FnOnce(&char) -> Result, +{ + f(&'a') +} + +fn main() { + // Test that supplying the `-> Result` manually here + // (which is needed to constrain `R`) still allows us to figure + // out that the type of `x` is `&'a char` where `'a` is bound in + // the closure (if we didn't, we'd get a type-error because + // `with_closure` requires a bound region). + // + // This pattern was found in the wild. + let z = with_closure(|x| -> Result { Ok(*x) }); + assert_eq!(z.unwrap(), 'a'); + + // It also works with `_`: + let z = with_closure(|x: _| -> Result { Ok(*x) }); + assert_eq!(z.unwrap(), 'a'); + + // It also works with `&_`: + let z = with_closure(|x: &_| -> Result { Ok(*x) }); + assert_eq!(z.unwrap(), 'a'); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-expected-type/supply-nothing.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-expected-type/supply-nothing.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-expected-type/supply-nothing.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-expected-type/supply-nothing.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn with_closure(f: F) -> u32 + where F: FnOnce(&u32, &u32) -> u32 +{ + f(&22, &44) +} + +fn main() { + let z = with_closure(|x, y| x + y).wrapping_add(1); + assert_eq!(z, 22 + 44 + 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-immediate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-immediate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-immediate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-immediate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// After the work to reoptimize structs, it became possible for immediate logic to fail. +// This test verifies that it actually works. + +fn main() { + let c = |a: u8, b: u16, c: u8| { + assert_eq!(a, 1); + assert_eq!(b, 2); + assert_eq!(c, 3); + }; + c(1, 2, 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-inference2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-inference2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-inference2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-inference2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test a rather underspecified example: + + +pub fn main() { + let f = {|i| i}; + assert_eq!(f(2), 2); + assert_eq!(f(5), 5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-inference.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-inference.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-inference.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-inference.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +fn foo(i: isize) -> isize { i + 1 } + +fn apply(f: F, v: A) -> A where F: FnOnce(A) -> A { f(v) } + +pub fn main() { + let f = {|i| foo(i)}; + assert_eq!(apply(f, 2), 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-reform.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-reform.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-reform.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-reform.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,66 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +fn call_it(f: F) + where F : FnOnce(String) -> String +{ + println!("{}", f("Fred".to_string())) +} + +fn call_a_thunk(f: F) where F: FnOnce() { + f(); +} + +fn call_this(f: F) where F: FnOnce(&str) + Send { + f("Hello!"); +} + +fn call_bare(f: fn(&str)) { + f("Hello world!") +} + +fn call_bare_again(f: extern "Rust" fn(&str)) { + f("Goodbye world!") +} + +pub fn main() { + // Procs + + let greeting = "Hello ".to_string(); + call_it(|s| { + format!("{}{}", greeting, s) + }); + + let greeting = "Goodbye ".to_string(); + call_it(|s| format!("{}{}", greeting, s)); + + let greeting = "How's life, ".to_string(); + call_it(|s: String| -> String { + format!("{}{}", greeting, s) + }); + + // Closures + + call_a_thunk(|| println!("Hello world!")); + + call_this(|s| println!("{}", s)); + + // External functions + + fn foo(s: &str) {} + call_bare(foo); + + call_bare_again(foo); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-returning-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-returning-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-returning-closure.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-returning-closure.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + let f = |_||x, y| x+y; + assert_eq!(f(())(1, 2), 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure_to_fn_coercion-expected-types.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure_to_fn_coercion-expected-types.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure_to_fn_coercion-expected-types.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure_to_fn_coercion-expected-types.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// Ensure that we deduce expected argument types when a `fn()` type is expected (#41755) + +fn foo(f: fn(Vec) -> usize) { } + +fn main() { + foo(|x| x.len()) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-to-fn-coercion.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-to-fn-coercion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-to-fn-coercion.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/closure-to-fn-coercion.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::mem; + +const FOO: fn(u8) -> u8 = |v: u8| { v }; + +const BAR: [fn(&mut u32); 5] = [ + |_: &mut u32| {}, + |v: &mut u32| *v += 1, + |v: &mut u32| *v += 2, + |v: &mut u32| *v += 3, + |v: &mut u32| *v += 4, +]; +fn func_specific() -> (fn() -> u32) { + || return 42 +} + +fn generic(_: T) -> fn() -> usize { + || mem::size_of::() +} + +fn main() { + // Items + assert_eq!(func_specific()(), 42); + let foo: fn(u8) -> u8 = |v: u8| { v }; + assert_eq!(foo(31), 31); + // Constants + assert_eq!(FOO(31), 31); + let mut a: u32 = 0; + assert_eq!({ BAR[0](&mut a); a }, 0); + assert_eq!({ BAR[1](&mut a); a }, 1); + assert_eq!({ BAR[2](&mut a); a }, 3); + assert_eq!({ BAR[3](&mut a); a }, 6); + assert_eq!({ BAR[4](&mut a); a }, 10); + assert_eq!(generic(0i8)(), 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/copy-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/copy-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/copy-closure.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/copy-closure.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Check that closures implement `Copy`. + +fn call T>(f: F) -> T { f() } + +fn main() { + let a = 5; + let hello = || { + println!("Hello {}", a); + a + }; + + assert_eq!(5, call(hello.clone())); + assert_eq!(5, call(hello)); + assert_eq!(5, call(hello)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-abi.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-abi.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-abi.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-abi.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Ensure that declarations and types which use `extern fn` both have the same +// ABI (#9309). + +// pretty-expanded FIXME #23616 +// aux-build:fn-abi.rs + +extern crate fn_abi; + +extern { + fn foo(); +} + +pub fn main() { + // Will only type check if the type of _p and the decl of foo use the + // same ABI + let _p: unsafe extern fn() = foo; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-bare-assign.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-bare-assign.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-bare-assign.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-bare-assign.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn f(i: isize, called: &mut bool) { + assert_eq!(i, 10); + *called = true; +} + +fn g(f: fn(isize, v: &mut bool), called: &mut bool) { + f(10, called); +} + +pub fn main() { + let mut called = false; + let h = f; + g(h, &mut called); + assert_eq!(called, true); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-bare-coerce-to-block.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-bare-coerce-to-block.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-bare-coerce-to-block.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-bare-coerce-to-block.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +fn bare() {} + +fn likes_block(f: F) where F: FnOnce() { f() } + +pub fn main() { + likes_block(bare); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-bare-item.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-bare-item.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-bare-item.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-bare-item.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn f() { + println!("This is a bare function"); +} + +pub fn main() { + f(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-bare-size.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-bare-size.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-bare-size.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-bare-size.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::mem; + +pub fn main() { + // Bare functions should just be a pointer + assert_eq!(mem::size_of::(), mem::size_of::()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-bare-spawn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-bare-spawn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-bare-spawn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-bare-spawn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// This is what the signature to spawn should look like with bare functions + + +fn spawn(val: T, f: fn(T)) { + f(val); +} + +fn f(i: isize) { + assert_eq!(i, 100); +} + +pub fn main() { + spawn(100, f); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-coerce-field.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-coerce-field.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-coerce-field.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-coerce-field.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 +#![allow(non_camel_case_types)] + +struct r where F: FnOnce() { + field: F, +} + +pub fn main() { + fn f() {} + let _i: r = r {field: f as fn()}; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-item-type-cast.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-item-type-cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-item-type-cast.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-item-type-cast.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// Test explicit coercions from a fn item type to a fn pointer type. + + +fn foo(x: isize) -> isize { x * 2 } +fn bar(x: isize) -> isize { x * 4 } +type IntMap = fn(isize) -> isize; + +fn eq(x: T, y: T) { } + +static TEST: Option = Some(foo as IntMap); + +fn main() { + let f = foo as IntMap; + + let f = if true { foo as IntMap } else { bar as IntMap }; + assert_eq!(f(4), 8); + + eq(foo as IntMap, bar as IntMap); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-item-type-coerce.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-item-type-coerce.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-item-type-coerce.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-item-type-coerce.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// Test implicit coercions from a fn item type to a fn pointer type. + +// pretty-expanded FIXME #23616 + +fn foo(x: isize) -> isize { x * 2 } +fn bar(x: isize) -> isize { x * 4 } +type IntMap = fn(isize) -> isize; + +fn eq(x: T, y: T) { } + +fn main() { + let f: IntMap = foo; + + eq::(foo, bar); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-item-type-zero-sized.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-item-type-zero-sized.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-item-type-zero-sized.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-item-type-zero-sized.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that fn item types are zero-sized. + +use std::mem::{size_of, size_of_val}; + +fn main() { + assert_eq!(size_of_val(&main), 0); + + let (a, b) = (size_of::, size_of::); + assert_eq!(size_of_val(&a), 0); + assert_eq!(size_of_val(&b), 0); + assert_eq!((a(), b()), (1, 2)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-lval.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-lval.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-lval.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-lval.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + +// pretty-expanded FIXME #23616 + +fn foo(_f: fn(isize) -> isize) { } + +fn id(x: isize) -> isize { return x; } + +pub fn main() { foo(id); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-type-infer.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-type-infer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-type-infer.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/fn-type-infer.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#![allow(unused_variables)] + +pub fn main() { + // We should be able to type infer inside of ||s. + let _f = || { + let i = 10; + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/implied-bounds-closure-arg-outlives.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/implied-bounds-closure-arg-outlives.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/implied-bounds-closure-arg-outlives.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/implied-bounds-closure-arg-outlives.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we are able to handle the relationships between free +// regions bound in a closure callback. + +#[derive(Copy, Clone)] +struct MyCx<'short, 'long: 'short> { + short: &'short u32, + long: &'long u32, +} + +impl<'short, 'long> MyCx<'short, 'long> { + fn short(self) -> &'short u32 { self.short } + fn long(self) -> &'long u32 { self.long } + fn set_short(&mut self, v: &'short u32) { self.short = v; } +} + +fn with(op: F) -> R +where + F: for<'short, 'long> FnOnce(MyCx<'short, 'long>) -> R, +{ + op(MyCx { + short: &22, + long: &22, + }) +} + +fn main() { + with(|mut cx| { + // For this to type-check, we need to be able to deduce that + // the lifetime of `l` can be `'short`, even though it has + // input from `'long`. + let l = if true { cx.long() } else { cx.short() }; + cx.set_short(l); + }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/nullable-pointer-opt-closures.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/nullable-pointer-opt-closures.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/nullable-pointer-opt-closures.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/nullable-pointer-opt-closures.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::mem; + +pub fn main() { + // By Ref Capture + let a = 10i32; + let b = Some(|| println!("{}", a)); + // When we capture by reference we can use any of the + // captures as the discriminant since they're all + // behind a pointer. + assert_eq!(mem::size_of_val(&b), mem::size_of::()); + + // By Value Capture + let a = Box::new(12i32); + let b = Some(move || println!("{}", a)); + // We captured `a` by value and since it's a `Box` we can use it + // as the discriminant. + assert_eq!(mem::size_of_val(&b), mem::size_of::>()); + + // By Value Capture - Transitive case + let a = "Hello".to_string(); // String -> Vec -> Unique -> NonZero + let b = Some(move || println!("{}", a)); + // We captured `a` by value and since down the chain it contains + // a `NonZero` field, we can use it as the discriminant. + assert_eq!(mem::size_of_val(&b), mem::size_of::()); + + // By Value - No Optimization + let a = 14i32; + let b = Some(move || println!("{}", a)); + // We captured `a` by value but we can't use it as the discriminant + // thus we end up with an extra field for the discriminant + assert_eq!(mem::size_of_val(&b), mem::size_of::<(i32, i32)>()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/parallel-codegen-closures.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/parallel-codegen-closures.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/parallel-codegen-closures.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/parallel-codegen-closures.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(stable_features)] + +// Tests parallel codegen - this can fail if the symbol for the anonymous +// closure in `sum` pollutes the second codegen unit from the first. + +// ignore-bitrig +// compile-flags: -C codegen_units=2 + +#![feature(iter_arith)] + +mod a { + fn foo() { + let x = ["a", "bob", "c"]; + let len: usize = x.iter().map(|s| s.len()).sum(); + } +} + +mod b { + fn bar() { + let x = ["a", "bob", "c"]; + let len: usize = x.iter().map(|s| s.len()).sum(); + } +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/return-from-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/return-from-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/functions-closures/return-from-closure.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/functions-closures/return-from-closure.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_upper_case_globals)] +// just to make sure that `return` is only returning from the closure, +// not the surrounding function. + +static mut calls: usize = 0; + +fn surrounding() { + let return_works = |n: isize| { + unsafe { calls += 1 } + + if n >= 0 { return; } + panic!() + }; + + return_works(10); + return_works(20); + + let return_works_proc = |n: isize| { + unsafe { calls += 1 } + + if n >= 0 { return; } + panic!() + }; + + return_works_proc(10); +} + +pub fn main() { + surrounding(); + + assert_eq!(unsafe {calls}, 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/futures-api.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/futures-api.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/futures-api.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/futures-api.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,19 +11,15 @@ #![feature(arbitrary_self_types, futures_api, pin)] #![allow(unused)] -use std::pin::PinBox; use std::future::Future; -use std::pin::PinMut; +use std::pin::Pin; use std::rc::Rc; use std::sync::{ Arc, atomic::{self, AtomicUsize}, }; -use std::future::FutureObj; use std::task::{ - Context, Poll, - Wake, Waker, LocalWaker, - Spawn, SpawnObjError, + Poll, Wake, Waker, LocalWaker, local_waker, local_waker_from_nonlocal, }; @@ -42,24 +38,17 @@ } } -struct NoopSpawner; - -impl Spawn for NoopSpawner { - fn spawn_obj(&mut self, _: FutureObj<'static, ()>) -> Result<(), SpawnObjError> { - Ok(()) - } -} - struct MyFuture; impl Future for MyFuture { type Output = (); - fn poll(self: PinMut, cx: &mut Context) -> Poll { - // Ensure all the methods work appropriately - cx.waker().wake(); - cx.waker().wake(); - cx.local_waker().wake(); - cx.spawner().spawn_obj(PinBox::new(MyFuture).into()).unwrap(); + fn poll(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll { + // Wake once locally + lw.wake(); + // Wake twice non-locally + let waker = lw.clone().into_waker(); + waker.wake(); + waker.wake(); Poll::Ready(()) } } @@ -70,9 +59,7 @@ nonlocal_wakes: AtomicUsize::new(0), }); let waker = unsafe { local_waker(counter.clone()) }; - let spawner = &mut NoopSpawner; - let cx = &mut Context::new(&waker, spawner); - assert_eq!(Poll::Ready(()), PinMut::new(&mut MyFuture).poll(cx)); + assert_eq!(Poll::Ready(()), Pin::new(&mut MyFuture).poll(&waker)); assert_eq!(1, counter.local_wakes.load(atomic::Ordering::SeqCst)); assert_eq!(2, counter.nonlocal_wakes.load(atomic::Ordering::SeqCst)); } @@ -83,9 +70,7 @@ nonlocal_wakes: AtomicUsize::new(0), }); let waker: LocalWaker = local_waker_from_nonlocal(counter.clone()); - let spawner = &mut NoopSpawner; - let cx = &mut Context::new(&waker, spawner); - assert_eq!(Poll::Ready(()), PinMut::new(&mut MyFuture).poll(cx)); + assert_eq!(Poll::Ready(()), Pin::new(&mut MyFuture).poll(&waker)); assert_eq!(0, counter.local_wakes.load(atomic::Ordering::SeqCst)); assert_eq!(3, counter.nonlocal_wakes.load(atomic::Ordering::SeqCst)); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/auxiliary/xcrate-reachable.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/auxiliary/xcrate-reachable.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/auxiliary/xcrate-reachable.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/auxiliary/xcrate-reachable.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(generators, generator_trait)] + +use std::ops::Generator; + +fn msg() -> u32 { + 0 +} + +pub fn foo() -> impl Generator { + || { + yield; + return msg(); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/auxiliary/xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/auxiliary/xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/auxiliary/xcrate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/auxiliary/xcrate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(generators, generator_trait)] + +use std::ops::Generator; + +pub fn foo() -> impl Generator { + || { + if false { + yield; + } + } +} + +pub fn bar(t: T) -> Box> { + Box::new(|| { + yield t; + }) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/borrow-in-tail-expr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/borrow-in-tail-expr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/borrow-in-tail-expr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/borrow-in-tail-expr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(generators)] + +fn main() { + let _a = || { + yield; + let a = String::new(); + a.len() + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/conditional-drop.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/conditional-drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/conditional-drop.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/conditional-drop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,67 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(generators, generator_trait)] + +use std::ops::Generator; +use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; + +static A: AtomicUsize = ATOMIC_USIZE_INIT; + +struct B; + +impl Drop for B { + fn drop(&mut self) { + A.fetch_add(1, Ordering::SeqCst); + } +} + + +fn test() -> bool { true } +fn test2() -> bool { false } + +fn main() { + t1(); + t2(); +} + +fn t1() { + let mut a = || { + let b = B; + if test() { + drop(b); + } + yield; + }; + + let n = A.load(Ordering::SeqCst); + unsafe { a.resume() }; + assert_eq!(A.load(Ordering::SeqCst), n + 1); + unsafe { a.resume() }; + assert_eq!(A.load(Ordering::SeqCst), n + 1); +} + +fn t2() { + let mut a = || { + let b = B; + if test2() { + drop(b); + } + yield; + }; + + let n = A.load(Ordering::SeqCst); + unsafe { a.resume() }; + assert_eq!(A.load(Ordering::SeqCst), n); + unsafe { a.resume() }; + assert_eq!(A.load(Ordering::SeqCst), n + 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/control-flow.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/control-flow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/control-flow.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/control-flow.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,58 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(generators, generator_trait)] + +use std::ops::{GeneratorState, Generator}; + +fn finish(mut amt: usize, mut t: T) -> T::Return + where T: Generator +{ + loop { + match unsafe { t.resume() } { + GeneratorState::Yielded(()) => amt = amt.checked_sub(1).unwrap(), + GeneratorState::Complete(ret) => { + assert_eq!(amt, 0); + return ret + } + } + } + +} + +fn main() { + finish(1, || yield); + finish(8, || { + for _ in 0..8 { + yield; + } + }); + finish(1, || { + if true { + yield; + } else { + } + }); + finish(1, || { + if false { + } else { + yield; + } + }); + finish(2, || { + if { yield; false } { + yield; + panic!() + } + yield + }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/drop-env.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/drop-env.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/drop-env.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/drop-env.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,72 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(generators, generator_trait)] + +use std::ops::Generator; +use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; + +static A: AtomicUsize = ATOMIC_USIZE_INIT; + +struct B; + +impl Drop for B { + fn drop(&mut self) { + A.fetch_add(1, Ordering::SeqCst); + } +} + +fn main() { + t1(); + t2(); + t3(); +} + +fn t1() { + let b = B; + let mut foo = || { + yield; + drop(b); + }; + + let n = A.load(Ordering::SeqCst); + drop(unsafe { foo.resume() }); + assert_eq!(A.load(Ordering::SeqCst), n); + drop(foo); + assert_eq!(A.load(Ordering::SeqCst), n + 1); +} + +fn t2() { + let b = B; + let mut foo = || { + yield b; + }; + + let n = A.load(Ordering::SeqCst); + drop(unsafe { foo.resume() }); + assert_eq!(A.load(Ordering::SeqCst), n + 1); + drop(foo); + assert_eq!(A.load(Ordering::SeqCst), n + 1); +} + +fn t3() { + let b = B; + let foo = || { + yield; + drop(b); + }; + + let n = A.load(Ordering::SeqCst); + assert_eq!(A.load(Ordering::SeqCst), n); + drop(foo); + assert_eq!(A.load(Ordering::SeqCst), n + 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/issue-44197.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/issue-44197.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/issue-44197.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/issue-44197.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(generators, generator_trait)] + +use std::ops::{ Generator, GeneratorState }; + +fn foo(_: &str) -> String { + String::new() +} + +fn bar(baz: String) -> impl Generator { + move || { + yield foo(&baz); + } +} + +fn foo2(_: &str) -> Result { + Err(()) +} + +fn bar2(baz: String) -> impl Generator { + move || { + if let Ok(quux) = foo2(&baz) { + yield quux; + } + } +} + +fn main() { + unsafe { + assert_eq!(bar(String::new()).resume(), GeneratorState::Yielded(String::new())); + assert_eq!(bar2(String::new()).resume(), GeneratorState::Complete(())); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/issue-52398.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/issue-52398.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/issue-52398.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/issue-52398.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] + +#![feature(generators)] + +use std::cell::RefCell; + +struct A; + +impl A { + fn test(&self, a: ()) {} +} + +fn main() { + // Test that the MIR local with type &A created for the auto-borrow adjustment + // is caught by typeck + move || { + A.test(yield); + }; + + // Test that the std::cell::Ref temporary returned from the `borrow` call + // is caught by typeck + let y = RefCell::new(true); + static move || { + yield *y.borrow(); + return "Done"; + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/iterator-count.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/iterator-count.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/iterator-count.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/iterator-count.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,52 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(generators, generator_trait)] + +use std::ops::{GeneratorState, Generator}; + +struct W(T); + +// This impl isn't safe in general, but the generator used in this test is movable +// so it won't cause problems. +impl> Iterator for W { + type Item = T::Yield; + + fn next(&mut self) -> Option { + match unsafe { self.0.resume() } { + GeneratorState::Complete(..) => None, + GeneratorState::Yielded(v) => Some(v), + } + } +} + +fn test() -> impl Generator { + || { + for i in 1..6 { + yield i + } + } +} + +fn main() { + let end = 11; + + let closure_test = |start| { + move || { + for i in start..end { + yield i + } + } + }; + + assert!(W(test()).chain(W(closure_test(6))).eq(1..11)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/live-upvar-across-yield.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/live-upvar-across-yield.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/live-upvar-across-yield.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/live-upvar-across-yield.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(generators, generator_trait)] + +use std::ops::Generator; + +fn main() { + let b = |_| 3; + let mut a = || { + b(yield); + }; + unsafe { a.resume() }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/match-bindings.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/match-bindings.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/match-bindings.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/match-bindings.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +#![feature(generators)] + +enum Enum { + A(String), + B +} + +fn main() { + || { + loop { + if let true = true { + match Enum::A(String::new()) { + Enum::A(_var) => {} + Enum::B => {} + } + } + yield; + } + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/nested_generators.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/nested_generators.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/nested_generators.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/nested_generators.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(generators)] +#![feature(generator_trait)] + +use std::ops::Generator; +use std::ops::GeneratorState; + +fn main() { + let _generator = || { + let mut sub_generator = || { + yield 2; + }; + + match unsafe { sub_generator.resume() } { + GeneratorState::Yielded(x) => { + yield x; + } + _ => panic!(), + }; + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/panic-drops.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/panic-drops.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/panic-drops.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/panic-drops.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,66 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// ignore-wasm32-bare compiled as panic=abort by default + +#![feature(generators, generator_trait)] + +use std::ops::Generator; +use std::panic; +use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; + +static A: AtomicUsize = ATOMIC_USIZE_INIT; + +struct B; + +impl Drop for B { + fn drop(&mut self) { + A.fetch_add(1, Ordering::SeqCst); + } +} + +fn bool_true() -> bool { + true +} + +fn main() { + let b = B; + let mut foo = || { + if bool_true() { + panic!(); + } + drop(b); + yield; + }; + + assert_eq!(A.load(Ordering::SeqCst), 0); + let res = panic::catch_unwind(panic::AssertUnwindSafe(|| { + unsafe { foo.resume() } + })); + assert!(res.is_err()); + assert_eq!(A.load(Ordering::SeqCst), 1); + + let mut foo = || { + if bool_true() { + panic!(); + } + drop(B); + yield; + }; + + assert_eq!(A.load(Ordering::SeqCst), 1); + let res = panic::catch_unwind(panic::AssertUnwindSafe(|| { + unsafe { foo.resume() } + })); + assert!(res.is_err()); + assert_eq!(A.load(Ordering::SeqCst), 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/panic-safe.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/panic-safe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/panic-safe.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/panic-safe.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// ignore-wasm32-bare compiled with panic=abort by default + +#![feature(generators, generator_trait)] + +use std::ops::Generator; +use std::panic; + +fn main() { + let mut foo = || { + if true { + panic!(); + } + yield; + }; + + let res = panic::catch_unwind(panic::AssertUnwindSafe(|| { + unsafe { foo.resume() } + })); + assert!(res.is_err()); + + for _ in 0..10 { + let res = panic::catch_unwind(panic::AssertUnwindSafe(|| { + unsafe { foo.resume() } + })); + assert!(res.is_err()); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/reborrow-mut-upvar.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/reborrow-mut-upvar.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/reborrow-mut-upvar.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/reborrow-mut-upvar.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(generators)] + +fn _run(bar: &mut i32) { + || { + { + let _baz = &*bar; + yield; + } + + *bar = 2; + }; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/resume-after-return.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/resume-after-return.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/resume-after-return.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/resume-after-return.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// ignore-wasm32-bare compiled with panic=abort by default + +#![feature(generators, generator_trait)] + +use std::ops::{GeneratorState, Generator}; +use std::panic; + +fn main() { + let mut foo = || { + if true { + return + } + yield; + }; + + match unsafe { foo.resume() } { + GeneratorState::Complete(()) => {} + s => panic!("bad state: {:?}", s), + } + + match panic::catch_unwind(move || unsafe { foo.resume() }) { + Ok(_) => panic!("generator successfully resumed"), + Err(_) => {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/smoke.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/smoke.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/smoke.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/smoke.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,183 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// ignore-emscripten no threads support +// compile-flags: --test + +#![feature(generators, generator_trait)] + +use std::ops::{GeneratorState, Generator}; +use std::thread; + +#[test] +fn simple() { + let mut foo = || { + if false { + yield; + } + }; + + match unsafe { foo.resume() } { + GeneratorState::Complete(()) => {} + s => panic!("bad state: {:?}", s), + } +} + +#[test] +fn return_capture() { + let a = String::from("foo"); + let mut foo = || { + if false { + yield; + } + a + }; + + match unsafe { foo.resume() } { + GeneratorState::Complete(ref s) if *s == "foo" => {} + s => panic!("bad state: {:?}", s), + } +} + +#[test] +fn simple_yield() { + let mut foo = || { + yield; + }; + + match unsafe { foo.resume() } { + GeneratorState::Yielded(()) => {} + s => panic!("bad state: {:?}", s), + } + match unsafe { foo.resume() } { + GeneratorState::Complete(()) => {} + s => panic!("bad state: {:?}", s), + } +} + +#[test] +fn yield_capture() { + let b = String::from("foo"); + let mut foo = || { + yield b; + }; + + match unsafe { foo.resume() } { + GeneratorState::Yielded(ref s) if *s == "foo" => {} + s => panic!("bad state: {:?}", s), + } + match unsafe { foo.resume() } { + GeneratorState::Complete(()) => {} + s => panic!("bad state: {:?}", s), + } +} + +#[test] +fn simple_yield_value() { + let mut foo = || { + yield String::from("bar"); + return String::from("foo") + }; + + match unsafe { foo.resume() } { + GeneratorState::Yielded(ref s) if *s == "bar" => {} + s => panic!("bad state: {:?}", s), + } + match unsafe { foo.resume() } { + GeneratorState::Complete(ref s) if *s == "foo" => {} + s => panic!("bad state: {:?}", s), + } +} + +#[test] +fn return_after_yield() { + let a = String::from("foo"); + let mut foo = || { + yield; + return a + }; + + match unsafe { foo.resume() } { + GeneratorState::Yielded(()) => {} + s => panic!("bad state: {:?}", s), + } + match unsafe { foo.resume() } { + GeneratorState::Complete(ref s) if *s == "foo" => {} + s => panic!("bad state: {:?}", s), + } +} + +#[test] +fn send_and_sync() { + assert_send_sync(|| { + yield + }); + assert_send_sync(|| { + yield String::from("foo"); + }); + assert_send_sync(|| { + yield; + return String::from("foo"); + }); + let a = 3; + assert_send_sync(|| { + yield a; + return + }); + let a = 3; + assert_send_sync(move || { + yield a; + return + }); + let a = String::from("a"); + assert_send_sync(|| { + yield ; + drop(a); + return + }); + let a = String::from("a"); + assert_send_sync(move || { + yield ; + drop(a); + return + }); + + fn assert_send_sync(_: T) {} +} + +#[test] +fn send_over_threads() { + let mut foo = || { yield }; + thread::spawn(move || { + match unsafe { foo.resume() } { + GeneratorState::Yielded(()) => {} + s => panic!("bad state: {:?}", s), + } + match unsafe { foo.resume() } { + GeneratorState::Complete(()) => {} + s => panic!("bad state: {:?}", s), + } + }).join().unwrap(); + + let a = String::from("a"); + let mut foo = || { yield a }; + thread::spawn(move || { + match unsafe { foo.resume() } { + GeneratorState::Yielded(ref s) if *s == "a" => {} + s => panic!("bad state: {:?}", s), + } + match unsafe { foo.resume() } { + GeneratorState::Complete(()) => {} + s => panic!("bad state: {:?}", s), + } + }).join().unwrap(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/static-generators.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/static-generators.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/static-generators.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/static-generators.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(generators, generator_trait)] + +use std::ops::{Generator, GeneratorState}; + +fn main() { + let mut generator = static || { + let a = true; + let b = &a; + yield; + assert_eq!(b as *const _, &a as *const _); + }; + unsafe { + assert_eq!(generator.resume(), GeneratorState::Yielded(())); + assert_eq!(generator.resume(), GeneratorState::Complete(())); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/too-live-local-in-immovable-gen.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/too-live-local-in-immovable-gen.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/too-live-local-in-immovable-gen.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/too-live-local-in-immovable-gen.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_unsafe)] + +#![feature(generators)] + +fn main() { + unsafe { + static move || { + // Tests that the generator transformation finds out that `a` is not live + // during the yield expression. Type checking will also compute liveness + // and it should also find out that `a` is not live. + // The compiler will panic if the generator transformation finds that + // `a` is live and type checking finds it dead. + let a = { + yield (); + 4i32 + }; + &a; + }; + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/xcrate-reachable.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/xcrate-reachable.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/xcrate-reachable.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/xcrate-reachable.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// aux-build:xcrate-reachable.rs + +#![feature(generator_trait)] + +extern crate xcrate_reachable as foo; + +use std::ops::Generator; + +fn main() { + unsafe { foo::foo().resume(); } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/xcrate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/xcrate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// aux-build:xcrate.rs + +#![feature(generators, generator_trait)] + +extern crate xcrate; + +use std::ops::{GeneratorState, Generator}; + +fn main() { + let mut foo = xcrate::foo(); + + match unsafe { foo.resume() } { + GeneratorState::Complete(()) => {} + s => panic!("bad state: {:?}", s), + } + + let mut foo = xcrate::bar(3); + + match unsafe { foo.resume() } { + GeneratorState::Yielded(3) => {} + s => panic!("bad state: {:?}", s), + } + match unsafe { foo.resume() } { + GeneratorState::Complete(()) => {} + s => panic!("bad state: {:?}", s), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/yield-in-args-rev.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/yield-in-args-rev.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/yield-in-args-rev.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/yield-in-args-rev.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +// Test that a borrow that occurs after a yield in the same +// argument list is not treated as live across the yield by +// type-checking. + +#![feature(generators)] + +fn foo(_a: (), _b: &bool) {} + +fn bar() { + || { + let b = true; + foo(yield, &b); + }; +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/yield-in-box.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/yield-in-box.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/yield-in-box.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/yield-in-box.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// Test that box-statements with yields in them work. + +#![feature(generators, box_syntax)] + +fn main() { + let x = 0i32; + || { + let y = 2u32; + { + let _t = box (&x, yield 0, &y); + } + match box (&x, yield 0, &y) { + _t => {} + } + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/yield-in-initializer.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/yield-in-initializer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/yield-in-initializer.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/yield-in-initializer.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(generators)] + +fn main() { + static || { + loop { + // Test that `opt` is not live across the yield, even when borrowed in a loop + // See https://github.com/rust-lang/rust/issues/52792 + let opt = { + yield; + true + }; + &opt; + } + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/yield-subtype.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/yield-subtype.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generator/yield-subtype.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generator/yield-subtype.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(dead_code)] + +// revisions:lexical nll +//[nll]compile-flags: -Z disable-nll-user-type-assert +#![cfg_attr(nll, feature(nll))] + +#![feature(generators)] + +fn bar<'a>() { + let a: &'static str = "hi"; + let b: &'a str = a; + + || { + yield a; + yield b; + }; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/auxiliary/default_type_params_xc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/auxiliary/default_type_params_xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/auxiliary/default_type_params_xc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/auxiliary/default_type_params_xc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Heap; + +pub struct FakeHeap; + +pub struct FakeVec { pub f: Option<(T,A)> } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-alias-unique.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-alias-unique.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-alias-unique.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-alias-unique.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +fn id(t: T) -> T { return t; } + +pub fn main() { + let expected: Box<_> = box 100; + let actual = id::>(expected.clone()); + println!("{}", *actual); + assert_eq!(*expected, *actual); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-default-type-params-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-default-type-params-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-default-type-params-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-default-type-params-cross-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:default_type_params_xc.rs + +// pretty-expanded FIXME #23616 + +extern crate default_type_params_xc; + +struct Vec(Option<(T,A)>); + +struct Foo; + +fn main() { + let _a = Vec::(None); + let _b = Vec::(None); + let _c = default_type_params_xc::FakeVec:: { f: None }; + let _d = default_type_params_xc::FakeVec:: { f: None }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-default-type-params.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-default-type-params.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-default-type-params.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-default-type-params.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,63 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct Foo { + a: A +} + +impl Foo { + fn bar_int(&self) -> isize { + self.a + } +} + +impl Foo { + fn bar_char(&self) -> char { + self.a + } +} + +impl Foo { + fn bar(&self) { + let (i, c): (isize, char) = self.a; + assert_eq!(Foo { a: i }.bar_int(), i); + assert_eq!(Foo { a: c }.bar_char(), c); + } +} + +impl Foo { + fn baz(&self) -> A { + self.a.clone() + } +} + +fn default_foo(x: Foo) { + let (i, c): (isize, char) = x.a; + assert_eq!(i, 1); + assert_eq!(c, 'a'); + + x.bar(); + assert_eq!(x.baz(), (1, 'a')); +} + +#[derive(PartialEq, Debug)] +struct BazHelper(T); + +#[derive(PartialEq, Debug)] +// Ensure that we can use previous type parameters in defaults. +struct Baz, V = Option>(T, U, V); + +fn main() { + default_foo(Foo { a: (1, 'a') }); + + let x: Baz = Baz(true, BazHelper(false), Some(BazHelper(true))); + assert_eq!(x, Baz(true, BazHelper(false), Some(BazHelper(true)))); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-derived-type.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-derived-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-derived-type.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-derived-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn g(x: X) -> X { return x; } + +#[derive(Clone)] +struct Pair { + a: T, + b: T +} + +fn f(t: T) -> Pair { + let x: Pair = Pair {a: t.clone(), b: t}; + return g::>(x); +} + +pub fn main() { + let b = f::(10); + println!("{}" ,b.a); + println!("{}", b.b); + assert_eq!(b.a, 10); + assert_eq!(b.b, 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-exterior-unique.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-exterior-unique.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-exterior-unique.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-exterior-unique.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +struct Recbox {x: Box} + +fn reclift(t: T) -> Recbox { return Recbox {x: box t}; } + +pub fn main() { + let foo: isize = 17; + let rbfoo: Recbox = reclift::(foo); + assert_eq!(*rbfoo.x, foo); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-extern-mangle.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-extern-mangle.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-extern-mangle.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-extern-mangle.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::ops::Add; + +extern "C" fn foo(a: T, b: T) -> T::Output { a + b } + +fn main() { + assert_eq!(100u8, foo(0u8, 100u8)); + assert_eq!(100u16, foo(0u16, 100u16)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-fn-infer.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-fn-infer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-fn-infer.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-fn-infer.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + + +// Issue #45: infer type parameters in function applications + +fn id(x: T) -> T { return x; } + +pub fn main() { let x: isize = 42; let y: isize = id(x); assert_eq!(x, y); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_assignments)] + +fn id(x: T) -> T { return x; } + +#[derive(Copy, Clone)] +struct Triple {x: isize, y: isize, z: isize} + +pub fn main() { + let mut x = 62; + let mut y = 63; + let a = 'a'; + let mut b = 'b'; + let p: Triple = Triple {x: 65, y: 66, z: 67}; + let mut q: Triple = Triple {x: 68, y: 69, z: 70}; + y = id::(x); + println!("{}", y); + assert_eq!(x, y); + b = id::(a); + println!("{}", b); + assert_eq!(a, b); + q = id::(p); + x = p.z; + y = q.z; + println!("{}", y); + assert_eq!(x, y); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-fn-twice.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-fn-twice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-fn-twice.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-fn-twice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + +// pretty-expanded FIXME #23616 + +mod foomod { + pub fn foo() { } +} + +pub fn main() { foomod::foo::(); foomod::foo::(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-fn-unique.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-fn-unique.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-fn-unique.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-fn-unique.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +fn f(x: Box) -> Box { return x; } + +pub fn main() { let x = f(box 3); println!("{}", *x); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-ivec-leak.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-ivec-leak.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-ivec-leak.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-ivec-leak.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] +enum wrapper { wrapped(T), } + +pub fn main() { let _w = wrapper::wrapped(vec![1, 2, 3, 4, 5]); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-newtype-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-newtype-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-newtype-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-newtype-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +struct S(T); + +pub fn main() { + let _s = S(2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-object.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-object.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-object.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-object.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +trait Foo { + fn get(&self) -> T; +} + +struct S { + x: isize +} + +impl Foo for S { + fn get(&self) -> isize { + self.x + } +} + +pub fn main() { + let x = box S { x: 1 }; + let y = x as Box>; + assert_eq!(y.get(), 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-recursive-tag.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-recursive-tag.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-recursive-tag.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-recursive-tag.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] +#![feature(box_syntax)] + +enum list { cons(Box, Box>), nil, } + +pub fn main() { + let _a: list = + list::cons::(box 10, + box list::cons::(box 12, + box list::cons::(box 13, + box list::nil::))); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-static-methods.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-static-methods.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-static-methods.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-static-methods.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + + +trait vec_utils { + fn map_(x: &Self, f: F) -> Vec where F: FnMut(&T) -> U; +} + +impl vec_utils for Vec { + fn map_(x: &Vec , mut f: F) -> Vec where F: FnMut(&T) -> U { + let mut r = Vec::new(); + for elt in x { + r.push(f(elt)); + } + r + } +} + +pub fn main() { + assert_eq!(vec_utils::map_(&vec![1,2,3], |&x| x+1), [2,3,4]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-tag-corruption.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-tag-corruption.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-tag-corruption.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-tag-corruption.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + + +// This used to cause memory corruption in stage 0. +// pretty-expanded FIXME #23616 + +enum thing { some(K), } + +pub fn main() { let _x = thing::some("hi".to_string()); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-tag-local.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-tag-local.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-tag-local.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-tag-local.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +enum clam { a(T), } + +pub fn main() { let _c = clam::a(3); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-tag-match.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-tag-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-tag-match.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-tag-match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_assignments)] +#![allow(non_camel_case_types)] + +enum foo { arm(T), } + +fn altfoo(f: foo) { + let mut hit = false; + match f { foo::arm::(_x) => { println!("in arm"); hit = true; } } + assert!((hit)); +} + +pub fn main() { altfoo::(foo::arm::(10)); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-tag.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-tag.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-tag.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-tag.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_assignments)] +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +#![allow(unused_variables)] +#![feature(box_syntax)] + +enum option { some(Box), none, } + +pub fn main() { + let mut a: option = option::some::(box 10); + a = option::none::; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-tag-values.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-tag-values.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-tag-values.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-tag-values.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +enum noption { some(T), } + +struct Pair { x: isize, y: isize } + +pub fn main() { + let nop: noption = noption::some::(5); + match nop { noption::some::(n) => { println!("{}", n); assert_eq!(n, 5); } } + let nop2: noption = noption::some(Pair{x: 17, y: 42}); + match nop2 { + noption::some(t) => { + println!("{}", t.x); + println!("{}", t.y); + assert_eq!(t.x, 17); + assert_eq!(t.y, 42); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-temporary.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-temporary.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-temporary.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-temporary.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn mk() -> isize { return 1; } + +fn chk(a: isize) { println!("{}", a); assert_eq!(a, 1); } + +fn apply(produce: fn() -> T, + consume: fn(T)) { + consume(produce()); +} + +pub fn main() { + let produce: fn() -> isize = mk; + let consume: fn(v: isize) = chk; + apply::(produce, consume); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-tup.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-tup.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-tup.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-tup.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn get_third(t: (T, T, T)) -> T { let (_, _, x) = t; return x; } + +pub fn main() { + println!("{}", get_third((1, 2, 3))); + assert_eq!(get_third((1, 2, 3)), 3); + assert_eq!(get_third((5u8, 6u8, 7u8)), 7u8); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-type.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-type.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + +struct Pair {x: T, y: T} + +pub fn main() { + let x: Pair = Pair {x: 10, y: 12}; + assert_eq!(x.x, 10); + assert_eq!(x.y, 12); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-type-synonym.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-type-synonym.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-type-synonym.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-type-synonym.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + + +// pretty-expanded FIXME #23616 + +struct Foo { + a: T +} + +type Bar = Foo; + +fn takebar(_b: Bar) { } + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-unique.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-unique.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/generics/generic-unique.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/generics/generic-unique.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![feature(box_syntax)] + +struct Triple { x: T, y: T, z: T } + +fn box_it(x: Triple) -> Box> { return box x; } + +pub fn main() { + let x: Box> = box_it::(Triple{x: 1, y: 2, z: 3}); + assert_eq!(x.y, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/guards-not-exhaustive.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/guards-not-exhaustive.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/guards-not-exhaustive.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/guards-not-exhaustive.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_snake_case)] #[derive(Copy, Clone)] enum Q { R(Option) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/guards.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/guards.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/guards.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/guards.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_shorthand_field_patterns)] #[derive(Copy, Clone)] struct Pair { x: isize, y: isize } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hashmap-memory.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hashmap-memory.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hashmap-memory.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hashmap-memory.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(dead_code)] +#![allow(unused_mut)] // ignore-emscripten No support for threads /** diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// Test that we handle binder levels in object types correctly. +// Initially, the reference to `'tcx` in the object type +// `&Typer<'tcx>` was getting an incorrect binder level, yielding +// weird compilation ICEs and so forth. + +// pretty-expanded FIXME #23616 + +trait Typer<'tcx> { + fn method(&self, data: &'tcx isize) -> &'tcx isize { data } +} + +struct Tcx<'tcx> { + fields: &'tcx isize +} + +impl<'tcx> Typer<'tcx> for Tcx<'tcx> { +} + +fn g<'tcx>(typer: &Typer<'tcx>) { +} + +fn check_static_type<'x>(tcx: &Tcx<'x>) { + g(tcx) +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +trait Typer<'tcx> { + fn method(&self, data: &'tcx isize) -> &'tcx isize { data } + fn dummy(&self) { } +} + +fn g(_: F) where F: FnOnce(&Typer) {} + +fn h() { + g(|typer| typer.dummy()) +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait-object.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait-object.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait-object.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait-object.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// A basic test of using a higher-ranked trait bound. + + +trait FnLike { + fn call(&self, arg: A) -> R; +} + +type FnObject<'b> = for<'a> FnLike<&'a isize, &'a isize> + 'b; + +struct Identity; + +impl<'a, T> FnLike<&'a T, &'a T> for Identity { + fn call(&self, arg: &'a T) -> &'a T { + arg + } +} + +fn call_repeatedly(f: &FnObject) { + let x = 3; + let y = f.call(&x); + assert_eq!(3, *y); +} + +fn main() { + call_repeatedly(&Identity); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// A basic test of using a higher-ranked trait bound. + + +trait FnLike { + fn call(&self, arg: A) -> R; +} + +struct Identity; + +impl<'a, T> FnLike<&'a T, &'a T> for Identity { + fn call(&self, arg: &'a T) -> &'a T { + arg + } +} + +fn call_repeatedly(f: F) + where F : for<'a> FnLike<&'a isize, &'a isize> +{ + let x = 3; + let y = f.call(&x); + assert_eq!(3, *y); +} + +fn main() { + call_repeatedly(Identity); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-opt-in-copy.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-opt-in-copy.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-opt-in-copy.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-opt-in-copy.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we handle binder levels correctly when checking whether a +// type can implement `Copy`. In particular, we had a bug where we failed to +// liberate the late-bound regions from the impl, and thus wound up +// searching for an impl of `for<'tcx> Foo<&'tcx T>`. The impl that +// exists however is `impl Copy for Foo` and the current rules +// did not consider that a match (something I would like to revise in +// a later PR). + +#![allow(dead_code)] + +use std::marker::PhantomData; + +#[derive(Copy, Clone)] +struct Foo { x: T } + +type Ty<'tcx> = &'tcx TyS<'tcx>; + +enum TyS<'tcx> { + Boop(PhantomData<*mut &'tcx ()>) +} + +#[derive(Copy, Clone)] +enum Bar<'tcx> { + Baz(Foo>) +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-parse.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-parse.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-parse.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-parse.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we can parse all the various places that a `for` keyword +// can appear representing universal quantification. + +// pretty-expanded FIXME #23616 + +#![allow(unused_variables)] +#![allow(dead_code)] + +trait Get { + fn get(&self, arg: A) -> R; +} + +// Parse HRTB with explicit `for` in a where-clause: + +fn foo00(t: T) + where T : for<'a> Get<&'a i32, &'a i32> +{ +} + +fn foo01 Get<&'a i32, &'a i32>>(t: T) +{ +} + +// Parse HRTB with explicit `for` in various sorts of types: + +fn foo10(t: Box Get>) { } +fn foo11(t: Box Fn(i32) -> i32>) { } + +fn foo20(t: for<'a> fn(i32) -> i32) { } +fn foo21(t: for<'a> unsafe fn(i32) -> i32) { } +fn foo22(t: for<'a> extern "C" fn(i32) -> i32) { } +fn foo23(t: for<'a> unsafe extern "C" fn(i32) -> i32) { } + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +// Test that `Fn(isize) -> isize + 'static` parses as `(Fn(isize) -> isize) + +// 'static` and not `Fn(isize) -> (isize + 'static)`. The latter would +// cause a compilation error. Issue #18772. + +fn adder(y: isize) -> Box isize + 'static> { + Box::new(move |x| y + x) +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus-where-clause.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus-where-clause.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus-where-clause.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus-where-clause.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// pretty-expanded FIXME #23616 + +// Test that `F : Fn(isize) -> isize + Send` is interpreted as two +// distinct bounds on `F`. + +fn foo1(f: F) + where F : FnOnce(isize) -> isize + Send +{ + bar(f); +} + +fn foo2(f: F) + where F : FnOnce(isize) -> isize + Send +{ + baz(f); +} + +fn bar(f: F) { } + +fn baz isize>(f: F) { } + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// A basic test of using a higher-ranked trait bound. + +// pretty-expanded FIXME #23616 + +trait FnLike { + fn call(&self, arg: A) -> R; +} + +type FnObject<'b> = for<'a> FnLike<&'a isize, &'a isize> + 'b; + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-paren-notation.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-paren-notation.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-paren-notation.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-paren-notation.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// A basic test of using a higher-ranked trait bound. + +trait FnLike { + fn call(&self, arg: A) -> R; +} + +type FnObject<'b> = for<'a> FnLike<(&'a i32,), &'a i32> + 'b; + +struct Identity; + +impl<'a, T> FnLike<(&'a T,), &'a T> for Identity { + fn call(&self, (arg,): (&'a T,)) -> &'a T { + arg + } +} + +fn call_repeatedly(f: &FnObject) { + let x = 3; + let y = f.call((&x,)); + assert_eq!(3, *y); +} + +fn main() { + call_repeatedly(&Identity); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Test that `&PrinterSupport`, which is really short for `&'a +// PrinterSupport<'b>`, gets properly expanded when it appears in a +// closure type. This used to result in messed up De Bruijn indices. + +// pretty-expanded FIXME #23616 + +trait PrinterSupport<'ast> { + fn ast_map(&self) -> Option<&'ast usize> { None } +} + +struct NoAnn<'ast> { + f: Option<&'ast usize> +} + +impl<'ast> PrinterSupport<'ast> for NoAnn<'ast> { +} + +fn foo<'ast, G>(f: Option<&'ast usize>, g: G) where G: FnOnce(&PrinterSupport) { + let annotation = NoAnn { f: f }; + g(&annotation) +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-type-outlives.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-type-outlives.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-type-outlives.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-type-outlives.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,58 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// Test what happens when a HR obligation is applied to an impl with +// "outlives" bounds. Currently we're pretty conservative here; this +// will probably improve in time. + +trait Foo { + fn foo(&self, x: X) { } +} + +fn want_foo() + where T : for<'a> Foo<&'a isize> +{ +} + +/////////////////////////////////////////////////////////////////////////// +// Expressed as a where clause + +struct SomeStruct { + x: X +} + +impl<'a,X> Foo<&'a isize> for SomeStruct + where X : 'a +{ +} + +fn one() { + want_foo::>(); +} + +/////////////////////////////////////////////////////////////////////////// +// Expressed as shorthand + +struct AnotherStruct { + x: X +} + +impl<'a,X:'a> Foo<&'a isize> for AnotherStruct +{ +} + +fn two() { + want_foo::>(); +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-unboxed-closure-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-unboxed-closure-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-unboxed-closure-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/higher-rank-trait-bounds/hrtb-unboxed-closure-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test HRTB used with the `Fn` trait. + +fn foo(f: F) { + let x = 22; + f(&x); +} + +fn main() { + foo(|x: &isize| println!("{}", *x)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/html-literals.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/html-literals.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/html-literals.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/html-literals.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] // A test of the macro system. Can we do HTML literals? /* diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/auxiliary/legacy_interaction.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/auxiliary/legacy_interaction.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/auxiliary/legacy_interaction.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/auxiliary/legacy_interaction.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-pretty pretty-printing is unhygienic + +#[macro_export] +macro_rules! m { + () => { + fn f() {} // (2) + g(); // (1) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/auxiliary/my_crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/auxiliary/my_crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/auxiliary/my_crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/auxiliary/my_crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn f() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/auxiliary/unhygienic_example.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/auxiliary/unhygienic_example.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/auxiliary/unhygienic_example.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/auxiliary/unhygienic_example.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![crate_type = "lib"] + +extern crate my_crate; + +pub fn g() {} // (a) + +#[macro_export] +macro_rules! unhygienic_macro { + () => { + // (1) unhygienic: depends on `my_crate` in the crate root at the invocation site. + ::my_crate::f(); + + // (2) unhygienic: defines `f` at the invocation site (in addition to the above point). + use my_crate::f; + f(); + + g(); // (3) unhygienic: `g` needs to be in scope at use site. + + $crate::g(); // (4) hygienic: this always resolves to (a) + } +} + +#[allow(unused)] +fn test_unhygienic() { + unhygienic_macro!(); + f(); // `f` was defined at the use site +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/auxiliary/xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/auxiliary/xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/auxiliary/xcrate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/auxiliary/xcrate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(decl_macro)] +#![allow(unused)] + +pub use bar::test; + +extern crate std as foo; + +pub fn f() {} +use f as f2; + +mod bar { + pub fn g() {} + use baz::h; + + pub macro test() { + use std::mem; + use foo::cell; + ::f(); + ::f2(); + g(); + h(); + ::bar::h(); + } +} + +mod baz { + pub fn h() {} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/hygiene-dodging-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/hygiene-dodging-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/hygiene-dodging-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/hygiene-dodging-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] + +mod x { + pub fn g() -> usize {14} +} + +pub fn main(){ + // should *not* shadow the module x: + let x = 9; + // use it to avoid warnings: + x+3; + assert_eq!(x::g(),14); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/hygiene.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/hygiene.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/hygiene.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/hygiene.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,124 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused)] + +fn f() { + let x = 0; + macro_rules! foo { () => { + assert_eq!(x, 0); + } } + + let x = 1; + foo!(); +} + +fn g() { + let x = 0; + macro_rules! m { ($m1:ident, $m2:ident, $x:ident) => { + macro_rules! $m1 { () => { ($x, x) } } + let x = 1; + macro_rules! $m2 { () => { ($x, x) } } + } } + + let x = 2; + m!(m2, m3, x); + + let x = 3; + assert_eq!(m2!(), (2, 0)); + assert_eq!(m3!(), (2, 1)); + + let x = 4; + m!(m4, m5, x); + assert_eq!(m4!(), (4, 0)); + assert_eq!(m5!(), (4, 1)); +} + +mod foo { + macro_rules! m { + ($f:ident : |$x:ident| $e:expr) => { + pub fn $f() -> (i32, i32) { + let x = 0; + let $x = 1; + (x, $e) + } + } + } + + m!(f: |x| x + 10); +} + +fn interpolated_pattern() { + let x = 0; + macro_rules! m { + ($p:pat, $e:expr) => { + let $p = 1; + assert_eq!((x, $e), (0, 1)); + } + } + + m!(x, x); +} + +fn patterns_in_macro_generated_macros() { + let x = 0; + macro_rules! m { + ($a:expr, $b:expr) => { + assert_eq!(x, 0); + let x = $a; + macro_rules! n { + () => { + (x, $b) + } + } + } + } + + let x = 1; + m!(2, x); + + let x = 3; + assert_eq!(n!(), (2, 1)); +} + +fn match_hygiene() { + let x = 0; + + macro_rules! m { + ($p:pat, $e:expr) => { + for result in &[Ok(1), Err(1)] { + match *result { + $p => { assert_eq!(($e, x), (1, 0)); } + Err(x) => { assert_eq!(($e, x), (2, 1)); } + } + } + } + } + + let x = 2; + m!(Ok(x), x); +} + +fn label_hygiene() { + 'a: loop { + macro_rules! m { () => { break 'a; } } + m!(); + } +} + +fn main() { + f(); + g(); + assert_eq!(foo::f(), (0, 11)); + interpolated_pattern(); + patterns_in_macro_generated_macros(); + match_hygiene(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/hygienic-labels-in-let.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/hygienic-labels-in-let.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/hygienic-labels-in-let.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/hygienic-labels-in-let.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,85 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unreachable_code)] + +// Test that labels injected by macros do not break hygiene. This +// checks cases where the macros invocations are under the rhs of a +// let statement. + +// Issue #24278: The label/lifetime shadowing checker from #24162 +// conservatively ignores hygiene, and thus issues warnings that are +// both true- and false-positives for this test. + +macro_rules! loop_x { + ($e: expr) => { + // $e shouldn't be able to interact with this 'x + 'x: loop { $e } + } +} + +macro_rules! while_true { + ($e: expr) => { + // $e shouldn't be able to interact with this 'x + 'x: while 1 + 1 == 2 { $e } + } +} + +macro_rules! run_once { + ($e: expr) => { + // ditto + 'x: for _ in 0..1 { $e } + } +} + +pub fn main() { + let mut i = 0; + + let j: isize = { + 'x: loop { + // this 'x should refer to the outer loop, lexically + loop_x!(break 'x); + i += 1; + } + i + 1 + }; + assert_eq!(j, 1); + + let k: isize = { + 'x: for _ in 0..1 { + // ditto + loop_x!(break 'x); + i += 1; + } + i + 1 + }; + assert_eq!(k, 1); + + let l: isize = { + 'x: for _ in 0..1 { + // ditto + while_true!(break 'x); + i += 1; + } + i + 1 + }; + assert_eq!(l, 1); + + let n: isize = { + 'x: for _ in 0..1 { + // ditto + run_once!(continue 'x); + i += 1; + } + i + 1 + }; + assert_eq!(n, 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/hygienic-labels-in-let.stderr rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/hygienic-labels-in-let.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/hygienic-labels-in-let.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/hygienic-labels-in-let.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,300 @@ +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:25:9 + | +LL | 'x: loop { $e } + | ^^ lifetime 'x already in scope +... +LL | 'x: loop { + | -- first declared here +LL | // this 'x should refer to the outer loop, lexically +LL | loop_x!(break 'x); + | ------------------ in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:57:9 + | +LL | 'x: loop { + | -- first declared here +... +LL | 'x: for _ in 0..1 { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:57:9 + | +LL | 'x: loop { $e } + | -- first declared here +... +LL | 'x: for _ in 0..1 { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:25:9 + | +LL | 'x: loop { $e } + | ^^ lifetime 'x already in scope +... +LL | 'x: loop { + | -- first declared here +... +LL | loop_x!(break 'x); + | ------------------ in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:25:9 + | +LL | 'x: loop { $e } + | ^^ + | | + | first declared here + | lifetime 'x already in scope +... +LL | loop_x!(break 'x); + | ------------------ in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:25:9 + | +LL | 'x: loop { $e } + | ^^ lifetime 'x already in scope +... +LL | 'x: for _ in 0..1 { + | -- first declared here +LL | // ditto +LL | loop_x!(break 'x); + | ------------------ in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:67:9 + | +LL | 'x: loop { + | -- first declared here +... +LL | 'x: for _ in 0..1 { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:67:9 + | +LL | 'x: loop { $e } + | -- first declared here +... +LL | 'x: for _ in 0..1 { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:67:9 + | +LL | 'x: for _ in 0..1 { + | -- first declared here +... +LL | 'x: for _ in 0..1 { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:67:9 + | +LL | 'x: loop { $e } + | -- first declared here +... +LL | 'x: for _ in 0..1 { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:32:9 + | +LL | 'x: while 1 + 1 == 2 { $e } + | ^^ lifetime 'x already in scope +... +LL | 'x: loop { + | -- first declared here +... +LL | while_true!(break 'x); + | ---------------------- in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:32:9 + | +LL | 'x: loop { $e } + | -- first declared here +... +LL | 'x: while 1 + 1 == 2 { $e } + | ^^ lifetime 'x already in scope +... +LL | while_true!(break 'x); + | ---------------------- in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:32:9 + | +LL | 'x: while 1 + 1 == 2 { $e } + | ^^ lifetime 'x already in scope +... +LL | 'x: for _ in 0..1 { + | -- first declared here +... +LL | while_true!(break 'x); + | ---------------------- in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:32:9 + | +LL | 'x: loop { $e } + | -- first declared here +... +LL | 'x: while 1 + 1 == 2 { $e } + | ^^ lifetime 'x already in scope +... +LL | while_true!(break 'x); + | ---------------------- in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:32:9 + | +LL | 'x: while 1 + 1 == 2 { $e } + | ^^ lifetime 'x already in scope +... +LL | 'x: for _ in 0..1 { + | -- first declared here +LL | // ditto +LL | while_true!(break 'x); + | ---------------------- in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:77:9 + | +LL | 'x: loop { + | -- first declared here +... +LL | 'x: for _ in 0..1 { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:77:9 + | +LL | 'x: loop { $e } + | -- first declared here +... +LL | 'x: for _ in 0..1 { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:77:9 + | +LL | 'x: for _ in 0..1 { + | -- first declared here +... +LL | 'x: for _ in 0..1 { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:77:9 + | +LL | 'x: loop { $e } + | -- first declared here +... +LL | 'x: for _ in 0..1 { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:77:9 + | +LL | 'x: for _ in 0..1 { + | -- first declared here +... +LL | 'x: for _ in 0..1 { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:77:9 + | +LL | 'x: while 1 + 1 == 2 { $e } + | -- first declared here +... +LL | 'x: for _ in 0..1 { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:39:9 + | +LL | 'x: for _ in 0..1 { $e } + | ^^ lifetime 'x already in scope +... +LL | 'x: loop { + | -- first declared here +... +LL | run_once!(continue 'x); + | ----------------------- in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:39:9 + | +LL | 'x: loop { $e } + | -- first declared here +... +LL | 'x: for _ in 0..1 { $e } + | ^^ lifetime 'x already in scope +... +LL | run_once!(continue 'x); + | ----------------------- in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:39:9 + | +LL | 'x: for _ in 0..1 { $e } + | ^^ lifetime 'x already in scope +... +LL | 'x: for _ in 0..1 { + | -- first declared here +... +LL | run_once!(continue 'x); + | ----------------------- in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:39:9 + | +LL | 'x: loop { $e } + | -- first declared here +... +LL | 'x: for _ in 0..1 { $e } + | ^^ lifetime 'x already in scope +... +LL | run_once!(continue 'x); + | ----------------------- in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:39:9 + | +LL | 'x: for _ in 0..1 { $e } + | ^^ lifetime 'x already in scope +... +LL | 'x: for _ in 0..1 { + | -- first declared here +... +LL | run_once!(continue 'x); + | ----------------------- in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:39:9 + | +LL | 'x: while 1 + 1 == 2 { $e } + | -- first declared here +... +LL | 'x: for _ in 0..1 { $e } + | ^^ lifetime 'x already in scope +... +LL | run_once!(continue 'x); + | ----------------------- in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels-in-let.rs:39:9 + | +LL | 'x: for _ in 0..1 { $e } + | ^^ lifetime 'x already in scope +... +LL | 'x: for _ in 0..1 { + | -- first declared here +LL | // ditto +LL | run_once!(continue 'x); + | ----------------------- in this macro invocation + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/hygienic-labels.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/hygienic-labels.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/hygienic-labels.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/hygienic-labels.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,63 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unreachable_code)] +// Test that labels injected by macros do not break hygiene. + +// Issue #24278: The label/lifetime shadowing checker from #24162 +// conservatively ignores hygiene, and thus issues warnings that are +// both true- and false-positives for this test. + +macro_rules! loop_x { + ($e: expr) => { + // $e shouldn't be able to interact with this 'x + 'x: loop { $e } + } +} + +macro_rules! run_once { + ($e: expr) => { + // ditto + 'x: for _ in 0..1 { $e } + } +} + +macro_rules! while_x { + ($e: expr) => { + // ditto + 'x: while 1 + 1 == 2 { $e } + } +} + +pub fn main() { + 'x: for _ in 0..1 { + // this 'x should refer to the outer loop, lexically + loop_x!(break 'x); + panic!("break doesn't act hygienically inside for loop"); + } + + 'x: loop { + // ditto + loop_x!(break 'x); + panic!("break doesn't act hygienically inside infinite loop"); + } + + 'x: while 1 + 1 == 2 { + while_x!(break 'x); + panic!("break doesn't act hygienically inside infinite while loop"); + } + + 'x: for _ in 0..1 { + // ditto + run_once!(continue 'x); + panic!("continue doesn't act hygienically inside for loop"); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/hygienic-labels.stderr rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/hygienic-labels.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/hygienic-labels.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/hygienic-labels.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,299 @@ +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:22:9 + | +LL | 'x: loop { $e } + | ^^ lifetime 'x already in scope +... +LL | 'x: for _ in 0..1 { + | -- first declared here +LL | // this 'x should refer to the outer loop, lexically +LL | loop_x!(break 'x); + | ------------------ in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:47:5 + | +LL | 'x: for _ in 0..1 { + | -- first declared here +... +LL | 'x: loop { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:47:5 + | +LL | 'x: loop { $e } + | -- first declared here +... +LL | 'x: loop { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:22:9 + | +LL | 'x: loop { $e } + | ^^ lifetime 'x already in scope +... +LL | 'x: for _ in 0..1 { + | -- first declared here +... +LL | loop_x!(break 'x); + | ------------------ in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:22:9 + | +LL | 'x: loop { $e } + | ^^ + | | + | first declared here + | lifetime 'x already in scope +... +LL | loop_x!(break 'x); + | ------------------ in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:22:9 + | +LL | 'x: loop { $e } + | ^^ lifetime 'x already in scope +... +LL | 'x: loop { + | -- first declared here +LL | // ditto +LL | loop_x!(break 'x); + | ------------------ in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:53:5 + | +LL | 'x: for _ in 0..1 { + | -- first declared here +... +LL | 'x: while 1 + 1 == 2 { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:53:5 + | +LL | 'x: loop { $e } + | -- first declared here +... +LL | 'x: while 1 + 1 == 2 { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:53:5 + | +LL | 'x: loop { + | -- first declared here +... +LL | 'x: while 1 + 1 == 2 { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:53:5 + | +LL | 'x: loop { $e } + | -- first declared here +... +LL | 'x: while 1 + 1 == 2 { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:36:9 + | +LL | 'x: while 1 + 1 == 2 { $e } + | ^^ lifetime 'x already in scope +... +LL | 'x: for _ in 0..1 { + | -- first declared here +... +LL | while_x!(break 'x); + | ------------------- in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:36:9 + | +LL | 'x: loop { $e } + | -- first declared here +... +LL | 'x: while 1 + 1 == 2 { $e } + | ^^ lifetime 'x already in scope +... +LL | while_x!(break 'x); + | ------------------- in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:36:9 + | +LL | 'x: while 1 + 1 == 2 { $e } + | ^^ lifetime 'x already in scope +... +LL | 'x: loop { + | -- first declared here +... +LL | while_x!(break 'x); + | ------------------- in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:36:9 + | +LL | 'x: loop { $e } + | -- first declared here +... +LL | 'x: while 1 + 1 == 2 { $e } + | ^^ lifetime 'x already in scope +... +LL | while_x!(break 'x); + | ------------------- in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:36:9 + | +LL | 'x: while 1 + 1 == 2 { $e } + | ^^ lifetime 'x already in scope +... +LL | 'x: while 1 + 1 == 2 { + | -- first declared here +LL | while_x!(break 'x); + | ------------------- in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:58:5 + | +LL | 'x: for _ in 0..1 { + | -- first declared here +... +LL | 'x: for _ in 0..1 { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:58:5 + | +LL | 'x: loop { $e } + | -- first declared here +... +LL | 'x: for _ in 0..1 { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:58:5 + | +LL | 'x: loop { + | -- first declared here +... +LL | 'x: for _ in 0..1 { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:58:5 + | +LL | 'x: loop { $e } + | -- first declared here +... +LL | 'x: for _ in 0..1 { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:58:5 + | +LL | 'x: while 1 + 1 == 2 { + | -- first declared here +... +LL | 'x: for _ in 0..1 { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:58:5 + | +LL | 'x: while 1 + 1 == 2 { $e } + | -- first declared here +... +LL | 'x: for _ in 0..1 { + | ^^ lifetime 'x already in scope + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:29:9 + | +LL | 'x: for _ in 0..1 { $e } + | ^^ lifetime 'x already in scope +... +LL | 'x: for _ in 0..1 { + | -- first declared here +... +LL | run_once!(continue 'x); + | ----------------------- in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:29:9 + | +LL | 'x: loop { $e } + | -- first declared here +... +LL | 'x: for _ in 0..1 { $e } + | ^^ lifetime 'x already in scope +... +LL | run_once!(continue 'x); + | ----------------------- in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:29:9 + | +LL | 'x: for _ in 0..1 { $e } + | ^^ lifetime 'x already in scope +... +LL | 'x: loop { + | -- first declared here +... +LL | run_once!(continue 'x); + | ----------------------- in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:29:9 + | +LL | 'x: loop { $e } + | -- first declared here +... +LL | 'x: for _ in 0..1 { $e } + | ^^ lifetime 'x already in scope +... +LL | run_once!(continue 'x); + | ----------------------- in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:29:9 + | +LL | 'x: for _ in 0..1 { $e } + | ^^ lifetime 'x already in scope +... +LL | 'x: while 1 + 1 == 2 { + | -- first declared here +... +LL | run_once!(continue 'x); + | ----------------------- in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:29:9 + | +LL | 'x: for _ in 0..1 { $e } + | ^^ lifetime 'x already in scope +... +LL | 'x: while 1 + 1 == 2 { $e } + | -- first declared here +... +LL | run_once!(continue 'x); + | ----------------------- in this macro invocation + +warning: label name `'x` shadows a label name that is already in scope + --> $DIR/hygienic-labels.rs:29:9 + | +LL | 'x: for _ in 0..1 { $e } + | ^^ lifetime 'x already in scope +... +LL | 'x: for _ in 0..1 { + | -- first declared here +LL | // ditto +LL | run_once!(continue 'x); + | ----------------------- in this macro invocation + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/issue-44128.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/issue-44128.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/issue-44128.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/issue-44128.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +#![feature(decl_macro)] + +pub macro create_struct($a:ident) { + struct $a; + impl Clone for $a { + fn clone(&self) -> Self { + $a + } + } +} + +fn main() { + create_struct!(Test); + Test.clone(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/issue-47311.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/issue-47311.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/issue-47311.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/issue-47311.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-pretty pretty-printing is unhygienic + +#![feature(decl_macro)] +#![allow(unused)] + +macro m($S:ident, $x:ident) { + $S { $x: 0 } +} + +mod foo { + struct S { x: i32 } + + fn f() { ::m!(S, x); } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/issue-47312.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/issue-47312.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/issue-47312.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/issue-47312.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-pretty pretty-printing is unhygienic + +#![feature(decl_macro)] +#![allow(unused)] + +mod foo { + pub macro m($s:tt, $i:tt) { + $s.$i + } +} + +mod bar { + struct S(i32); + fn f() { + let s = S(0); + ::foo::m!(s, 0); + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/items.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/items.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/items.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/items.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-pretty pretty-printing is unhygienic + +#![feature(decl_macro)] + +pub macro m($foo:ident, $f:ident, $e:expr) { + mod foo { + pub fn f() -> u32 { 0 } + pub fn $f() -> u64 { 0 } + } + + mod $foo { + pub fn f() -> i32 { 0 } + pub fn $f() -> i64 { 0 } + } + + let _: u32 = foo::f(); + let _: u64 = foo::$f(); + let _: i32 = $foo::f(); + let _: i64 = $foo::$f(); + let _: i64 = $e; +} + +fn main() { + m!(foo, f, foo::f()); + let _: i64 = foo::f(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/legacy_interaction.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/legacy_interaction.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/legacy_interaction.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/legacy_interaction.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,52 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// ignore-pretty pretty-printing is unhygienic + +// aux-build:legacy_interaction.rs + +#![feature(decl_macro)] +#[allow(unused)] + +extern crate legacy_interaction; +// ^ defines +// ```rust +// macro_rules! m { +// () => { +// fn f() // (1) +// g() // (2) +// } +// } +// ```rust + +mod def_site { + // Unless this macro opts out of hygiene, it should resolve the same wherever it is invoked. + pub macro m2() { + ::legacy_interaction::m!(); + f(); // This should resolve to (1) + fn g() {} // We want (2) resolve to this, not to (4) + } +} + +mod use_site { + fn test() { + fn f() -> bool { true } // (3) + fn g() -> bool { true } // (4) + + ::def_site::m2!(); + + let _: bool = f(); // This should resolve to (3) + let _: bool = g(); // This should resolve to (4) + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/lexical.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/lexical.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/lexical.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/lexical.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-pretty pretty-printing is unhygienic + +#![feature(decl_macro)] + +mod bar { + mod baz { + pub fn f() {} + } + + pub macro m($f:ident) { + baz::f(); + let _: i32 = $f(); + { + fn $f() -> u32 { 0 } + let _: u32 = $f(); + } + } +} + +fn main() { + fn f() -> i32 { 0 } + bar::m!(f); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/specialization.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/specialization.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/specialization.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/specialization.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-pretty pretty-printing is unhygienic + +#![feature(decl_macro)] + +trait Tr { + fn f(&self) -> &'static str { + "This shouldn't happen" + } +} + +pub macro m($t:ty) { + impl Tr for $t { + fn f(&self) -> &'static str { + "Run me" + } + } +} + +struct S; +m!(S); + +fn main() { + assert_eq!(S.f(), "Run me"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/trait_items.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/trait_items.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/trait_items.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/trait_items.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-pretty pretty-printing is unhygienic + +#![feature(decl_macro)] + +macro m($T:ident, $f:ident) { + pub trait $T { + fn f(&self) -> u32 { 0 } + fn $f(&self) -> i32 { 0 } + } + impl $T for () {} + + let _: u32 = ().f(); + let _: i32 = ().$f(); +} + +fn main() { + m!(T, f); + let _: i32 = ().f(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/ty_params.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/ty_params.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/ty_params.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/ty_params.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-pretty pretty-printing is unhygienic + +#![feature(decl_macro)] + +macro m($T:ident) { + fn f(t: T, t2: $T) -> (T, $T) { + (t, t2) + } +} + +m!(T); + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/wrap_unhygienic_example.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/wrap_unhygienic_example.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/wrap_unhygienic_example.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/wrap_unhygienic_example.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-pretty pretty-printing is unhygienic + +// aux-build:my_crate.rs +// aux-build:unhygienic_example.rs + +#![feature(decl_macro)] + +extern crate unhygienic_example; +extern crate my_crate; // (b) + +// Hygienic version of `unhygienic_macro`. +pub macro hygienic_macro() { + fn g() {} // (c) + ::unhygienic_example::unhygienic_macro!(); + // ^ Even though we invoke an unhygienic macro, `hygienic_macro` remains hygienic. + // In the above expansion: + // (1) `my_crate` always resolves to (b) regardless of invocation site. + // (2) The defined function `f` is only usable inside this macro definition. + // (3) `g` always resolves to (c) regardless of invocation site. + // (4) `$crate::g` remains hygienic and continues to resolve to (a). + + f(); +} + +#[allow(unused)] +fn test_hygienic_macro() { + hygienic_macro!(); + + fn f() {} // (d) no conflict + f(); // resolves to (d) +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/hygiene/xcrate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/hygiene/xcrate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-pretty pretty-printing is unhygienic + +// aux-build:xcrate.rs + +#![feature(decl_macro)] + +extern crate xcrate; + +fn main() { + xcrate::test!(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/if-ret.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/if-ret.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/if-ret.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/if-ret.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_parens)] // pretty-expanded FIXME #23616 fn foo() { if (return) { } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ignore-all-the-things.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ignore-all-the-things.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ignore-all-the-things.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ignore-all-the-things.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_shorthand_field_patterns)] +#![allow(dead_code)] +#![allow(unused_variables)] // pretty-expanded FIXME #23616 #![feature(slice_patterns)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/auto-trait-leak.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/auto-trait-leak.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/auto-trait-leak.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/auto-trait-leak.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// Fast path, main can see the concrete type returned. +fn before() -> impl FnMut(i32) { + let mut p = Box::new(0); + move |x| *p = x +} + +fn send(_: T) {} + +fn main() { + send(before()); + send(after()); +} + +// Deferred path, main has to wait until typeck finishes, +// to check if the return type of after is Send. +fn after() -> impl FnMut(i32) { + let mut p = Box::new(0); + move |x| *p = x +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/auxiliary/xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/auxiliary/xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/auxiliary/xcrate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/auxiliary/xcrate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// NOTE commented out due to issue #45994 +//pub fn fourway_add(a: i32) -> impl Fn(i32) -> impl Fn(i32) -> impl Fn(i32) -> i32 { +// move |b| move |c| move |d| a + b + c + d +//} + +fn some_internal_fn() -> u32 { + 1 +} + +fn other_internal_fn() -> u32 { + 1 +} + +// See #40839 +pub fn return_closure_accessing_internal_fn() -> impl Fn() -> u32 { + || { + some_internal_fn() + 1 + } +} + +pub fn return_internal_fn() -> impl Fn() -> u32 { + other_internal_fn +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/bounds_regression.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/bounds_regression.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/bounds_regression.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/bounds_regression.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub trait FakeGenerator { + type Yield; + type Return; +} + +pub trait FakeFuture { + type Output; +} + +pub fn future_from_generator< + T: FakeGenerator +>(x: T) -> impl FakeFuture { + GenFuture(x) +} + +struct GenFuture>(T); + +impl> FakeFuture for GenFuture { + type Output = T::Return; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/equality.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/equality.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/equality.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/equality.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,58 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(specialization)] + +trait Foo: std::fmt::Debug + Eq {} + +impl Foo for T {} + +fn hide(x: T) -> impl Foo { + x +} + +trait Leak: Sized { + fn leak(self) -> T; +} +impl Leak for U { + default fn leak(self) -> T { panic!("type mismatch") } +} +impl Leak for T { + fn leak(self) -> T { self } +} + +trait CheckIfSend: Sized { + type T: Default; + fn check(self) -> Self::T { Default::default() } +} +impl CheckIfSend for T { + default type T = (); +} +impl CheckIfSend for T { + type T = bool; +} + +fn lucky_seven() -> impl Fn(usize) -> u8 { + let a = [1, 2, 3, 4, 5, 6, 7]; + move |i| a[i] +} + +fn main() { + assert_eq!(hide(42), hide(42)); + + assert_eq!(std::mem::size_of_val(&hide([0_u8; 5])), 5); + assert_eq!(std::mem::size_of_val(&lucky_seven()), 7); + + assert_eq!(Leak::::leak(hide(5_i32)), 5_i32); + + assert_eq!(CheckIfSend::check(hide(0_i32)), false); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/example-calendar.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/example-calendar.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/example-calendar.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/example-calendar.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,894 @@ +// Copyright 2016-2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// revisions: normal nll +//[nll] compile-flags:-Zborrowck=mir + +#![feature(fn_traits, + step_trait, + unboxed_closures, +)] + +//! Derived from: . +//! +//! Originally converted to Rust by [Daniel Keep](https://github.com/DanielKeep). + +use std::fmt::Write; +use std::mem; + +/// Date representation. +#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] +struct NaiveDate(i32, u32, u32); + +impl NaiveDate { + pub fn from_ymd(y: i32, m: u32, d: u32) -> NaiveDate { + assert!(1 <= m && m <= 12, "m = {:?}", m); + assert!(1 <= d && d <= NaiveDate(y, m, 1).days_in_month(), "d = {:?}", d); + NaiveDate(y, m, d) + } + + pub fn year(&self) -> i32 { + self.0 + } + + pub fn month(&self) -> u32 { + self.1 + } + + pub fn day(&self) -> u32 { + self.2 + } + + pub fn succ(&self) -> NaiveDate { + let (mut y, mut m, mut d, n) = ( + self.year(), self.month(), self.day()+1, self.days_in_month()); + if d > n { + d = 1; + m += 1; + } + if m > 12 { + m = 1; + y += 1; + } + NaiveDate::from_ymd(y, m, d) + } + + pub fn weekday(&self) -> Weekday { + use Weekday::*; + + // 0 = Sunday + let year = self.year(); + let dow_jan_1 = (year*365 + ((year-1) / 4) - ((year-1) / 100) + ((year-1) / 400)) % 7; + let dow = (dow_jan_1 + (self.day_of_year() as i32 - 1)) % 7; + [Sun, Mon, Tue, Wed, Thu, Fri, Sat][dow as usize] + } + + pub fn isoweekdate(&self) -> (i32, u32, Weekday) { + let first_dow_mon_0 = self.year_first_day_of_week().num_days_from_monday(); + + // Work out this date's DOtY and week number, not including year adjustment. + let doy_0 = self.day_of_year() - 1; + let mut week_mon_0: i32 = ((first_dow_mon_0 + doy_0) / 7) as i32; + + if self.first_week_in_prev_year() { + week_mon_0 -= 1; + } + + let weeks_in_year = self.last_week_number(); + + // Work out the final result. + // If the week is -1 or >= weeks_in_year, we will need to adjust the year. + let year = self.year(); + let wd = self.weekday(); + + if week_mon_0 < 0 { + (year - 1, NaiveDate::from_ymd(year - 1, 1, 1).last_week_number(), wd) + } else if week_mon_0 >= weeks_in_year as i32 { + (year + 1, (week_mon_0 + 1 - weeks_in_year as i32) as u32, wd) + } else { + (year, (week_mon_0 + 1) as u32, wd) + } + } + + fn first_week_in_prev_year(&self) -> bool { + let first_dow_mon_0 = self.year_first_day_of_week().num_days_from_monday(); + + // Any day in the year *before* the first Monday of that year + // is considered to be in the last week of the previous year, + // assuming the first week has *less* than four days in it. + // Adjust the week appropriately. + ((7 - first_dow_mon_0) % 7) < 4 + } + + fn year_first_day_of_week(&self) -> Weekday { + NaiveDate::from_ymd(self.year(), 1, 1).weekday() + } + + fn weeks_in_year(&self) -> u32 { + let days_in_last_week = self.year_first_day_of_week().num_days_from_monday() + 1; + if days_in_last_week >= 4 { 53 } else { 52 } + } + + fn last_week_number(&self) -> u32 { + let wiy = self.weeks_in_year(); + if self.first_week_in_prev_year() { wiy - 1 } else { wiy } + } + + fn day_of_year(&self) -> u32 { + (1..self.1).map(|m| NaiveDate::from_ymd(self.year(), m, 1).days_in_month()) + .fold(0, |a,b| a+b) + self.day() + } + + fn is_leap_year(&self) -> bool { + let year = self.year(); + if year % 4 != 0 { + return false + } else if year % 100 != 0 { + return true + } else if year % 400 != 0 { + return false + } else { + return true + } + } + + fn days_in_month(&self) -> u32 { + match self.month() { + /* Jan */ 1 => 31, + /* Feb */ 2 => if self.is_leap_year() { 29 } else { 28 }, + /* Mar */ 3 => 31, + /* Apr */ 4 => 30, + /* May */ 5 => 31, + /* Jun */ 6 => 30, + /* Jul */ 7 => 31, + /* Aug */ 8 => 31, + /* Sep */ 9 => 30, + /* Oct */ 10 => 31, + /* Nov */ 11 => 30, + /* Dec */ 12 => 31, + _ => unreachable!() + } + } +} + +impl<'a, 'b> std::ops::Add<&'b NaiveDate> for &'a NaiveDate { + type Output = NaiveDate; + + fn add(self, other: &'b NaiveDate) -> NaiveDate { + assert_eq!(*other, NaiveDate(0, 0, 1)); + self.succ() + } +} + +impl std::iter::Step for NaiveDate { + fn steps_between(_: &Self, _: &Self) -> Option { + unimplemented!() + } + + fn replace_one(&mut self) -> Self { + mem::replace(self, NaiveDate(0, 0, 1)) + } + + fn replace_zero(&mut self) -> Self { + mem::replace(self, NaiveDate(0, 0, 0)) + } + + fn add_one(&self) -> Self { + self.succ() + } + + fn sub_one(&self) -> Self { + unimplemented!() + } + + fn add_usize(&self, _: usize) -> Option { + unimplemented!() + } +} + +#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] +pub enum Weekday { + Mon, + Tue, + Wed, + Thu, + Fri, + Sat, + Sun, +} + +impl Weekday { + pub fn num_days_from_monday(&self) -> u32 { + use Weekday::*; + match *self { + Mon => 0, + Tue => 1, + Wed => 2, + Thu => 3, + Fri => 4, + Sat => 5, + Sun => 6, + } + } + + pub fn num_days_from_sunday(&self) -> u32 { + use Weekday::*; + match *self { + Sun => 0, + Mon => 1, + Tue => 2, + Wed => 3, + Thu => 4, + Fri => 5, + Sat => 6, + } + } +} + +/// GroupBy implementation. +struct GroupBy { + it: std::iter::Peekable, + f: F, +} + +impl Clone for GroupBy +where + It: Iterator + Clone, + It::Item: Clone, + F: Clone, +{ + fn clone(&self) -> Self { + GroupBy { + it: self.it.clone(), + f: self.f.clone(), + } + } +} + +impl<'a, G, It: 'a, F: 'a> Iterator for GroupBy +where It: Iterator + Clone, + It::Item: Clone, + F: Clone + FnMut(&It::Item) -> G, + G: Eq + Clone +{ + type Item = (G, InGroup, F, G>); + + fn next(&mut self) -> Option { + self.it.peek().map(&mut self.f).map(|key| { + let start = self.it.clone(); + while let Some(k) = self.it.peek().map(&mut self.f) { + if key != k { + break; + } + self.it.next(); + } + + (key.clone(), InGroup { + it: start, + f: self.f.clone(), + g: key + }) + }) + } +} + +#[derive(Copy, Clone)] +struct InGroup { + it: It, + f: F, + g: G +} + +impl G, G: Eq> Iterator for InGroup { + type Item = It::Item; + + fn next(&mut self) -> Option { + self.it.next().and_then(|x| { + if (self.f)(&x) == self.g { Some(x) } else { None } + }) + } +} + +trait IteratorExt: Iterator + Sized { + fn group_by(self, f: F) -> GroupBy + where F: Clone + FnMut(&Self::Item) -> G, + G: Eq + { + GroupBy { it: self.peekable(), f } + } + + fn join(mut self, sep: &str) -> String + where Self::Item: std::fmt::Display { + let mut s = String::new(); + if let Some(e) = self.next() { + write!(s, "{}", e).unwrap(); + for e in self { + s.push_str(sep); + write!(s, "{}", e).unwrap(); + } + } + s + } + + // HACK(eddyb) Only needed because `impl Trait` can't be + // used with trait methods: `.foo()` becomes `.__(foo)`. + fn __(self, f: F) -> R + where F: FnOnce(Self) -> R { + f(self) + } +} + +impl IteratorExt for It where It: Iterator {} + +/// +/// Generates an iterator that yields exactly n spaces. +/// +fn spaces(n: usize) -> std::iter::Take> { + std::iter::repeat(' ').take(n) +} + +fn test_spaces() { + assert_eq!(spaces(0).collect::(), ""); + assert_eq!(spaces(10).collect::(), " ") +} + +/// +/// Returns an iterator of dates in a given year. +/// +fn dates_in_year(year: i32) -> impl Iterator+Clone { + InGroup { + it: NaiveDate::from_ymd(year, 1, 1).., + f: |d: &NaiveDate| d.year(), + g: year + } +} + +fn test_dates_in_year() { + { + let mut dates = dates_in_year(2013); + assert_eq!(dates.next(), Some(NaiveDate::from_ymd(2013, 1, 1))); + + // Check increment + assert_eq!(dates.next(), Some(NaiveDate::from_ymd(2013, 1, 2))); + + // Check monthly rollover + for _ in 3..31 { + assert!(dates.next() != None); + } + + assert_eq!(dates.next(), Some(NaiveDate::from_ymd(2013, 1, 31))); + assert_eq!(dates.next(), Some(NaiveDate::from_ymd(2013, 2, 1))); + } + + { + // Check length of year + let mut dates = dates_in_year(2013); + for _ in 0..365 { + assert!(dates.next() != None); + } + assert_eq!(dates.next(), None); + } + + { + // Check length of leap year + let mut dates = dates_in_year(1984); + for _ in 0..366 { + assert!(dates.next() != None); + } + assert_eq!(dates.next(), None); + } +} + +/// +/// Convenience trait for verifying that a given type iterates over +/// `NaiveDate`s. +/// +trait DateIterator: Iterator + Clone {} +impl DateIterator for It where It: Iterator + Clone {} + +fn test_group_by() { + let input = [ + [1, 1], + [1, 1], + [1, 2], + [2, 2], + [2, 3], + [2, 3], + [3, 3] + ]; + + let by_x = input.iter().cloned().group_by(|a| a[0]); + let expected_1: &[&[[i32; 2]]] = &[ + &[[1, 1], [1, 1], [1, 2]], + &[[2, 2], [2, 3], [2, 3]], + &[[3, 3]] + ]; + for ((_, a), b) in by_x.zip(expected_1.iter().cloned()) { + assert_eq!(&a.collect::>()[..], b); + } + + let by_y = input.iter().cloned().group_by(|a| a[1]); + let expected_2: &[&[[i32; 2]]] = &[ + &[[1, 1], [1, 1]], + &[[1, 2], [2, 2]], + &[[2, 3], [2, 3], [3, 3]] + ]; + for ((_, a), b) in by_y.zip(expected_2.iter().cloned()) { + assert_eq!(&a.collect::>()[..], b); + } +} + +/// +/// Groups an iterator of dates by month. +/// +fn by_month(it: impl Iterator + Clone) + -> impl Iterator + Clone)> + Clone +{ + it.group_by(|d| d.month()) +} + +fn test_by_month() { + let mut months = dates_in_year(2013).__(by_month); + for (month, (_, mut date)) in (1..13).zip(&mut months) { + assert_eq!(date.nth(0).unwrap(), NaiveDate::from_ymd(2013, month, 1)); + } + assert!(months.next().is_none()); +} + +/// +/// Groups an iterator of dates by week. +/// +fn by_week(it: impl DateIterator) + -> impl Iterator + Clone +{ + // We go forward one day because `isoweekdate` considers the week to start on a Monday. + it.group_by(|d| d.succ().isoweekdate().1) +} + +fn test_isoweekdate() { + fn weeks_uniq(year: i32) -> Vec<((i32, u32), u32)> { + let mut weeks = dates_in_year(year).map(|d| d.isoweekdate()) + .map(|(y,w,_)| (y,w)); + let mut result = vec![]; + let mut accum = (weeks.next().unwrap(), 1); + for yw in weeks { + if accum.0 == yw { + accum.1 += 1; + } else { + result.push(accum); + accum = (yw, 1); + } + } + result.push(accum); + result + } + + let wu_1984 = weeks_uniq(1984); + assert_eq!(&wu_1984[..2], &[((1983, 52), 1), ((1984, 1), 7)]); + assert_eq!(&wu_1984[wu_1984.len()-2..], &[((1984, 52), 7), ((1985, 1), 1)]); + + let wu_2013 = weeks_uniq(2013); + assert_eq!(&wu_2013[..2], &[((2013, 1), 6), ((2013, 2), 7)]); + assert_eq!(&wu_2013[wu_2013.len()-2..], &[((2013, 52), 7), ((2014, 1), 2)]); + + let wu_2015 = weeks_uniq(2015); + assert_eq!(&wu_2015[..2], &[((2015, 1), 4), ((2015, 2), 7)]); + assert_eq!(&wu_2015[wu_2015.len()-2..], &[((2015, 52), 7), ((2015, 53), 4)]); +} + +fn test_by_week() { + let mut weeks = dates_in_year(2013).__(by_week); + assert_eq!( + &*weeks.next().unwrap().1.collect::>(), + &[ + NaiveDate::from_ymd(2013, 1, 1), + NaiveDate::from_ymd(2013, 1, 2), + NaiveDate::from_ymd(2013, 1, 3), + NaiveDate::from_ymd(2013, 1, 4), + NaiveDate::from_ymd(2013, 1, 5), + ] + ); + assert_eq!( + &*weeks.next().unwrap().1.collect::>(), + &[ + NaiveDate::from_ymd(2013, 1, 6), + NaiveDate::from_ymd(2013, 1, 7), + NaiveDate::from_ymd(2013, 1, 8), + NaiveDate::from_ymd(2013, 1, 9), + NaiveDate::from_ymd(2013, 1, 10), + NaiveDate::from_ymd(2013, 1, 11), + NaiveDate::from_ymd(2013, 1, 12), + ] + ); + assert_eq!(weeks.next().unwrap().1.nth(0).unwrap(), NaiveDate::from_ymd(2013, 1, 13)); +} + +/// The number of columns per day in the formatted output. +const COLS_PER_DAY: u32 = 3; + +/// The number of columns per week in the formatted output. +const COLS_PER_WEEK: u32 = 7 * COLS_PER_DAY; + +/// +/// Formats an iterator of weeks into an iterator of strings. +/// +fn format_weeks(it: impl Iterator) -> impl Iterator { + it.map(|week| { + let mut buf = String::with_capacity((COLS_PER_DAY * COLS_PER_WEEK + 2) as usize); + + // Format each day into its own cell and append to target string. + let mut last_day = 0; + let mut first = true; + for d in week { + last_day = d.weekday().num_days_from_sunday(); + + // Insert enough filler to align the first day with its respective day-of-week. + if first { + buf.extend(spaces((COLS_PER_DAY * last_day) as usize)); + first = false; + } + + write!(buf, " {:>2}", d.day()).unwrap(); + } + + // Insert more filler at the end to fill up the remainder of the week, + // if its a short week (e.g. at the end of the month). + buf.extend(spaces((COLS_PER_DAY * (6 - last_day)) as usize)); + buf + }) +} + +fn test_format_weeks() { + let jan_2013 = dates_in_year(2013) + .__(by_month).next() // pick January 2013 for testing purposes + // NOTE: This `map` is because `next` returns an `Option<_>`. + .map(|(_, month)| + month.__(by_week) + .map(|(_, weeks)| weeks) + .__(format_weeks) + .join("\n")); + + assert_eq!( + jan_2013.as_ref().map(|s| &**s), + Some(" 1 2 3 4 5\n\ + \x20 6 7 8 9 10 11 12\n\ + \x2013 14 15 16 17 18 19\n\ + \x2020 21 22 23 24 25 26\n\ + \x2027 28 29 30 31 ") + ); +} + +/// +/// Formats the name of a month, centered on COLS_PER_WEEK. +/// +fn month_title(month: u32) -> String { + const MONTH_NAMES: &'static [&'static str] = &[ + "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December" + ]; + assert_eq!(MONTH_NAMES.len(), 12); + + // Determine how many spaces before and after the month name + // we need to center it over the formatted weeks in the month. + let name = MONTH_NAMES[(month - 1) as usize]; + assert!(name.len() < COLS_PER_WEEK as usize); + let before = (COLS_PER_WEEK as usize - name.len()) / 2; + let after = COLS_PER_WEEK as usize - name.len() - before; + + // NOTE: Being slightly more verbose to avoid extra allocations. + let mut result = String::with_capacity(COLS_PER_WEEK as usize); + result.extend(spaces(before)); + result.push_str(name); + result.extend(spaces(after)); + result +} + +fn test_month_title() { + assert_eq!(month_title(1).len(), COLS_PER_WEEK as usize); +} + +/// +/// Formats a month. +/// +fn format_month(it: impl DateIterator) -> impl Iterator { + let mut month_days = it.peekable(); + let title = month_title(month_days.peek().unwrap().month()); + + Some(title).into_iter() + .chain(month_days.__(by_week) + .map(|(_, week)| week) + .__(format_weeks)) +} + +fn test_format_month() { + let month_fmt = dates_in_year(2013) + .__(by_month).next() // Pick January as a test case + .map(|(_, days)| days.into_iter() + .__(format_month) + .join("\n")); + + assert_eq!( + month_fmt.as_ref().map(|s| &**s), + Some(" January \n\ + \x20 1 2 3 4 5\n\ + \x20 6 7 8 9 10 11 12\n\ + \x2013 14 15 16 17 18 19\n\ + \x2020 21 22 23 24 25 26\n\ + \x2027 28 29 30 31 ") + ); +} + + +/// +/// Formats an iterator of months. +/// +fn format_months(it: impl Iterator) + -> impl Iterator> +{ + it.map(format_month) +} + +/// +/// Takes an iterator of iterators of strings; the sub-iterators are consumed +/// in lock-step, with their elements joined together. +/// +trait PasteBlocks: Iterator + Sized +where Self::Item: Iterator { + fn paste_blocks(self, sep_width: usize) -> PasteBlocksIter { + PasteBlocksIter { + iters: self.collect(), + cache: vec![], + col_widths: None, + sep_width: sep_width, + } + } +} + +impl PasteBlocks for It where It: Iterator, It::Item: Iterator {} + +struct PasteBlocksIter +where StrIt: Iterator { + iters: Vec, + cache: Vec>, + col_widths: Option>, + sep_width: usize, +} + +impl Iterator for PasteBlocksIter +where StrIt: Iterator { + type Item = String; + + fn next(&mut self) -> Option { + self.cache.clear(); + + // `cache` is now the next line from each iterator. + self.cache.extend(self.iters.iter_mut().map(|it| it.next())); + + // If every line in `cache` is `None`, we have nothing further to do. + if self.cache.iter().all(|e| e.is_none()) { return None } + + // Get the column widths if we haven't already. + let col_widths = match self.col_widths { + Some(ref v) => &**v, + None => { + self.col_widths = Some(self.cache.iter() + .map(|ms| ms.as_ref().map(|s| s.len()).unwrap_or(0)) + .collect()); + &**self.col_widths.as_ref().unwrap() + } + }; + + // Fill in any `None`s with spaces. + let mut parts = col_widths.iter().cloned().zip(self.cache.iter_mut()) + .map(|(w,ms)| ms.take().unwrap_or_else(|| spaces(w).collect())); + + // Join them all together. + let first = parts.next().unwrap_or(String::new()); + let sep_width = self.sep_width; + Some(parts.fold(first, |mut accum, next| { + accum.extend(spaces(sep_width)); + accum.push_str(&next); + accum + })) + } +} + +fn test_paste_blocks() { + let row = dates_in_year(2013) + .__(by_month).map(|(_, days)| days) + .take(3) + .__(format_months) + .paste_blocks(1) + .join("\n"); + assert_eq!( + &*row, + " January February March \n\ + \x20 1 2 3 4 5 1 2 1 2\n\ + \x20 6 7 8 9 10 11 12 3 4 5 6 7 8 9 3 4 5 6 7 8 9\n\ + \x2013 14 15 16 17 18 19 10 11 12 13 14 15 16 10 11 12 13 14 15 16\n\ + \x2020 21 22 23 24 25 26 17 18 19 20 21 22 23 17 18 19 20 21 22 23\n\ + \x2027 28 29 30 31 24 25 26 27 28 24 25 26 27 28 29 30\n\ + \x20 31 " + ); +} + +/// +/// Produces an iterator that yields `n` elements at a time. +/// +trait Chunks: Iterator + Sized { + fn chunks(self, n: usize) -> ChunksIter { + assert!(n > 0); + ChunksIter { + it: self, + n: n, + } + } +} + +impl Chunks for It where It: Iterator {} + +struct ChunksIter +where It: Iterator { + it: It, + n: usize, +} + +// NOTE: `chunks` in Rust is more-or-less impossible without overhead of some kind. +// Aliasing rules mean you need to add dynamic borrow checking, and the design of +// `Iterator` means that you need to have the iterator's state kept in an allocation +// that is jointly owned by the iterator itself and the sub-iterator. +// As such, I've chosen to cop-out and just heap-allocate each chunk. + +impl Iterator for ChunksIter +where It: Iterator { + type Item = Vec; + + fn next(&mut self) -> Option> { + let first = match self.it.next() { + Some(e) => e, + None => return None + }; + + let mut result = Vec::with_capacity(self.n); + result.push(first); + + Some((&mut self.it).take(self.n-1) + .fold(result, |mut acc, next| { acc.push(next); acc })) + } +} + +fn test_chunks() { + let r = &[1, 2, 3, 4, 5, 6, 7]; + let c = r.iter().cloned().chunks(3).collect::>(); + assert_eq!(&*c, &[vec![1, 2, 3], vec![4, 5, 6], vec![7]]); +} + +/// +/// Formats a year. +/// +fn format_year(year: i32, months_per_row: usize) -> String { + const COL_SPACING: usize = 1; + + // Start by generating all dates for the given year. + dates_in_year(year) + + // Group them by month and throw away month number. + .__(by_month).map(|(_, days)| days) + + // Group the months into horizontal rows. + .chunks(months_per_row) + + // Format each row + .map(|r| r.into_iter() + // By formatting each month + .__(format_months) + + // Horizontally pasting each respective month's lines together. + .paste_blocks(COL_SPACING) + .join("\n") + ) + + // Insert a blank line between each row + .join("\n\n") +} + +fn test_format_year() { + const MONTHS_PER_ROW: usize = 3; + + macro_rules! assert_eq_cal { + ($lhs:expr, $rhs:expr) => { + if $lhs != $rhs { + println!("got:\n```\n{}\n```\n", $lhs.replace(" ", ".")); + println!("expected:\n```\n{}\n```", $rhs.replace(" ", ".")); + panic!("calendars didn't match!"); + } + } + } + + assert_eq_cal!(&format_year(1984, MONTHS_PER_ROW), "\ +\x20 January February March \n\ +\x20 1 2 3 4 5 6 7 1 2 3 4 1 2 3\n\ +\x20 8 9 10 11 12 13 14 5 6 7 8 9 10 11 4 5 6 7 8 9 10\n\ +\x2015 16 17 18 19 20 21 12 13 14 15 16 17 18 11 12 13 14 15 16 17\n\ +\x2022 23 24 25 26 27 28 19 20 21 22 23 24 25 18 19 20 21 22 23 24\n\ +\x2029 30 31 26 27 28 29 25 26 27 28 29 30 31\n\ +\n\ +\x20 April May June \n\ +\x20 1 2 3 4 5 6 7 1 2 3 4 5 1 2\n\ +\x20 8 9 10 11 12 13 14 6 7 8 9 10 11 12 3 4 5 6 7 8 9\n\ +\x2015 16 17 18 19 20 21 13 14 15 16 17 18 19 10 11 12 13 14 15 16\n\ +\x2022 23 24 25 26 27 28 20 21 22 23 24 25 26 17 18 19 20 21 22 23\n\ +\x2029 30 27 28 29 30 31 24 25 26 27 28 29 30\n\ +\n\ +\x20 July August September \n\ +\x20 1 2 3 4 5 6 7 1 2 3 4 1\n\ +\x20 8 9 10 11 12 13 14 5 6 7 8 9 10 11 2 3 4 5 6 7 8\n\ +\x2015 16 17 18 19 20 21 12 13 14 15 16 17 18 9 10 11 12 13 14 15\n\ +\x2022 23 24 25 26 27 28 19 20 21 22 23 24 25 16 17 18 19 20 21 22\n\ +\x2029 30 31 26 27 28 29 30 31 23 24 25 26 27 28 29\n\ +\x20 30 \n\ +\n\ +\x20 October November December \n\ +\x20 1 2 3 4 5 6 1 2 3 1\n\ +\x20 7 8 9 10 11 12 13 4 5 6 7 8 9 10 2 3 4 5 6 7 8\n\ +\x2014 15 16 17 18 19 20 11 12 13 14 15 16 17 9 10 11 12 13 14 15\n\ +\x2021 22 23 24 25 26 27 18 19 20 21 22 23 24 16 17 18 19 20 21 22\n\ +\x2028 29 30 31 25 26 27 28 29 30 23 24 25 26 27 28 29\n\ +\x20 30 31 "); + + assert_eq_cal!(&format_year(2015, MONTHS_PER_ROW), "\ +\x20 January February March \n\ +\x20 1 2 3 1 2 3 4 5 6 7 1 2 3 4 5 6 7\n\ +\x20 4 5 6 7 8 9 10 8 9 10 11 12 13 14 8 9 10 11 12 13 14\n\ +\x2011 12 13 14 15 16 17 15 16 17 18 19 20 21 15 16 17 18 19 20 21\n\ +\x2018 19 20 21 22 23 24 22 23 24 25 26 27 28 22 23 24 25 26 27 28\n\ +\x2025 26 27 28 29 30 31 29 30 31 \n\ +\n\ +\x20 April May June \n\ +\x20 1 2 3 4 1 2 1 2 3 4 5 6\n\ +\x20 5 6 7 8 9 10 11 3 4 5 6 7 8 9 7 8 9 10 11 12 13\n\ +\x2012 13 14 15 16 17 18 10 11 12 13 14 15 16 14 15 16 17 18 19 20\n\ +\x2019 20 21 22 23 24 25 17 18 19 20 21 22 23 21 22 23 24 25 26 27\n\ +\x2026 27 28 29 30 24 25 26 27 28 29 30 28 29 30 \n\ +\x20 31 \n\ +\n\ +\x20 July August September \n\ +\x20 1 2 3 4 1 1 2 3 4 5\n\ +\x20 5 6 7 8 9 10 11 2 3 4 5 6 7 8 6 7 8 9 10 11 12\n\ +\x2012 13 14 15 16 17 18 9 10 11 12 13 14 15 13 14 15 16 17 18 19\n\ +\x2019 20 21 22 23 24 25 16 17 18 19 20 21 22 20 21 22 23 24 25 26\n\ +\x2026 27 28 29 30 31 23 24 25 26 27 28 29 27 28 29 30 \n\ +\x20 30 31 \n\ +\n\ +\x20 October November December \n\ +\x20 1 2 3 1 2 3 4 5 6 7 1 2 3 4 5\n\ +\x20 4 5 6 7 8 9 10 8 9 10 11 12 13 14 6 7 8 9 10 11 12\n\ +\x2011 12 13 14 15 16 17 15 16 17 18 19 20 21 13 14 15 16 17 18 19\n\ +\x2018 19 20 21 22 23 24 22 23 24 25 26 27 28 20 21 22 23 24 25 26\n\ +\x2025 26 27 28 29 30 31 29 30 27 28 29 30 31 "); +} + +fn main() { + // Run tests. + test_spaces(); + test_dates_in_year(); + test_group_by(); + test_by_month(); + test_isoweekdate(); + test_by_week(); + test_format_weeks(); + test_month_title(); + test_format_month(); + test_paste_blocks(); + test_chunks(); + test_format_year(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/example-st.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/example-st.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/example-st.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/example-st.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +struct State; +type Error = (); + +trait Bind { + type Output; + fn bind(self, f: F) -> Self::Output; +} + +fn bind(mut a: A, mut f: F) + -> impl FnMut(&mut State) -> Result +where F: FnMut(T) -> B, + A: FnMut(&mut State) -> Result, + B: FnMut(&mut State) -> Result +{ + move |state | { + let r = a(state)?; + f(r)(state) + } +} + +fn atom(x: T) -> impl FnMut(&mut State) -> Result { + let mut x = Some(x); + move |_| x.take().map_or(Err(()), Ok) +} + +fn main() { + assert_eq!(bind(atom(5), |x| atom(x > 4))(&mut State), Ok(true)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/existential-minimal.stderr rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/existential-minimal.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/existential-minimal.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/existential-minimal.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -warning: function is never used: `foo` - --> $DIR/existential-minimal.rs:15:1 - | -LL | fn foo() -> impl std::fmt::Debug { "cake" } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: #[warn(dead_code)] on by default - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/issue-42479.stderr rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/issue-42479.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/issue-42479.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/issue-42479.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -warning: struct is never constructed: `Foo` - --> $DIR/issue-42479.rs:15:1 - | -LL | struct Foo { - | ^^^^^^^^^^ - | - = note: #[warn(dead_code)] on by default - -warning: method is never used: `inside` - --> $DIR/issue-42479.rs:20:5 - | -LL | fn inside(&self) -> impl Iterator { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/issue-49376.stderr rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/issue-49376.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/issue-49376.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/issue-49376.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -warning: function is never used: `gen` - --> $DIR/issue-49376.rs:18:1 - | -LL | fn gen() -> impl PartialOrd + PartialEq + Debug { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: #[warn(dead_code)] on by default - -warning: struct is never constructed: `Bar` - --> $DIR/issue-49376.rs:20:1 - | -LL | struct Bar {} - | ^^^^^^^^^^ - -warning: function is never used: `foo` - --> $DIR/issue-49376.rs:24:1 - | -LL | fn foo() -> impl Foo { - | ^^^^^^^^^^^^^^^^^^^^ - -warning: function is never used: `test_impl_ops` - --> $DIR/issue-49376.rs:28:1 - | -LL | fn test_impl_ops() -> impl Add + Sub + Mul + Div { 1 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: function is never used: `test_impl_assign_ops` - --> $DIR/issue-49376.rs:29:1 - | -LL | fn test_impl_assign_ops() -> impl AddAssign + SubAssign + MulAssign + DivAssign { 1 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/lifetimes.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/lifetimes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/lifetimes.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/lifetimes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,128 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![allow(warnings)] + +use std::fmt::Debug; + +fn any_lifetime<'a>() -> &'a u32 { &5 } + +fn static_lifetime() -> &'static u32 { &5 } + +fn any_lifetime_as_static_impl_trait() -> impl Debug { + any_lifetime() +} + +fn lifetimes_as_static_impl_trait() -> impl Debug { + static_lifetime() +} + +fn no_params_or_lifetimes_is_static() -> impl Debug + 'static { + lifetimes_as_static_impl_trait() +} + +fn static_input_type_is_static(x: T) -> impl Debug + 'static { x } + +fn type_outlives_reference_lifetime<'a, T: Debug>(x: &'a T) -> impl Debug + 'a { x } +fn type_outlives_reference_lifetime_elided(x: &T) -> impl Debug + '_ { x } + +trait SingleRegionTrait<'a> {} +impl<'a> SingleRegionTrait<'a> for u32 {} +impl<'a> SingleRegionTrait<'a> for &'a u32 {} +struct SingleRegionStruct<'a>(&'a u32); + +fn simple_type_hrtb<'b>() -> impl for<'a> SingleRegionTrait<'a> { 5 } +// FIXME(cramertj) add test after #45992 lands to ensure lint is triggered +fn elision_single_region_trait(x: &u32) -> impl SingleRegionTrait { x } +fn elision_single_region_struct(x: SingleRegionStruct) -> impl Into { x } + +fn closure_hrtb() -> impl for<'a> Fn(&'a u32) { |_| () } +fn closure_hr_elided() -> impl Fn(&u32) { |_| () } +fn closure_hr_elided_return() -> impl Fn(&u32) -> &u32 { |x| x } +fn closure_pass_through_elided_return(x: impl Fn(&u32) -> &u32) -> impl Fn(&u32) -> &u32 { x } +fn closure_pass_through_reference_elided(x: &impl Fn(&u32) -> &u32) -> &impl Fn(&u32) -> &u32 { x } + +fn nested_lifetime<'a>(input: &'a str) + -> impl Iterator + 'a> + 'a +{ + input.lines().map(|line| { + line.split_whitespace().map(|cell| cell.parse().unwrap()) + }) +} + +fn pass_through_elision(x: &u32) -> impl Into<&u32> { x } +fn pass_through_elision_with_fn_ptr(x: &fn(&u32) -> &u32) -> impl Into<&fn(&u32) -> &u32> { x } + +fn pass_through_elision_with_fn_path &u32>( + x: &T +) -> &impl Fn(&u32) -> &u32 { x } + +fn foo(x: &impl Debug) -> &impl Debug { x } +fn foo_explicit_lifetime<'a>(x: &'a impl Debug) -> &'a impl Debug { x } +fn foo_explicit_arg(x: &T) -> &impl Debug { x } + +fn mixed_lifetimes<'a>() -> impl for<'b> Fn(&'b &'a u32) { |_| () } +fn mixed_as_static() -> impl Fn(&'static &'static u32) { mixed_lifetimes() } + +trait MultiRegionTrait<'a, 'b>: Debug {} + +#[derive(Debug)] +struct MultiRegionStruct<'a, 'b>(&'a u32, &'b u32); +impl<'a, 'b> MultiRegionTrait<'a, 'b> for MultiRegionStruct<'a, 'b> {} + +#[derive(Debug)] +struct NoRegionStruct; +impl<'a, 'b> MultiRegionTrait<'a, 'b> for NoRegionStruct {} + +fn finds_least_region<'a: 'b, 'b>(x: &'a u32, y: &'b u32) -> impl MultiRegionTrait<'a, 'b> { + MultiRegionStruct(x, y) +} + +fn finds_explicit_bound<'a: 'b, 'b> + (x: &'a u32, y: &'b u32) -> impl MultiRegionTrait<'a, 'b> + 'b +{ + MultiRegionStruct(x, y) +} + +fn finds_explicit_bound_even_without_least_region<'a, 'b> + (x: &'a u32, y: &'b u32) -> impl MultiRegionTrait<'a, 'b> + 'b +{ + NoRegionStruct +} + +/* FIXME: `impl Trait<'a> + 'b` should live as long as 'b, even if 'b outlives 'a +fn outlives_bounds_even_with_contained_regions<'a, 'b> + (x: &'a u32, y: &'b u32) -> impl Debug + 'b +{ + finds_explicit_bound_even_without_least_region(x, y) +} +*/ + +fn unnamed_lifetimes_arent_contained_in_impl_trait_and_will_unify<'a, 'b> + (x: &'a u32, y: &'b u32) -> impl Debug +{ + fn deref<'lt>(x: &'lt u32) -> impl Debug { *x } + + if true { deref(x) } else { deref(y) } +} + +fn can_add_region_bound_to_static_type<'a, 'b>(_: &'a u32) -> impl Debug + 'a { 5 } + +struct MyVec(Vec>); + +impl<'unnecessary_lifetime> MyVec { + fn iter_doesnt_capture_unnecessary_lifetime<'s>(&'s self) -> impl Iterator { + self.0.iter().flat_map(|inner_vec| inner_vec.iter()) + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/nesting.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/nesting.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/nesting.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/nesting.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +fn foo(t: T) -> impl Into<[T; { const FOO: usize = 1; FOO }]> { + [t] +} + +fn bar() -> impl Into<[u8; { const FOO: usize = 1; FOO }]> { + [99] +} + +fn main() { + println!("{:?}", foo(42).into()); + println!("{:?}", bar().into()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_hrtb_anon.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_hrtb_anon.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_hrtb_anon.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_hrtb_anon.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn hrtb(f: impl Fn(&u32) -> u32) -> u32 { + f(&22) + f(&44) +} + +fn main() { + let sum = hrtb(|x| x * 2); + assert_eq!(sum, 22*2 + 44*2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_hrtb_named.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_hrtb_named.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_hrtb_named.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_hrtb_named.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn hrtb(f: impl for<'a> Fn(&'a u32) -> &'a u32) -> u32 { + f(&22) + f(&44) +} + +fn main() { + let sum = hrtb(|x| x); + assert_eq!(sum, 22 + 44); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_in_adt_in_parameters.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_in_adt_in_parameters.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_in_adt_in_parameters.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_in_adt_in_parameters.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::fmt::Display; + +fn check_display_eq(iter: &Vec) { + let mut collected = String::new(); + for it in iter { + let disp = format!("{} ", it); + collected.push_str(&disp); + } + assert_eq!("0 3 27 823 4891 1 0", collected.trim()); +} + +fn main() { + let i32_list_vec = vec![0i32, 3, 27, 823, 4891, 1, 0]; + let u32_list_vec = vec![0u32, 3, 27, 823, 4891, 1, 0]; + let str_list_vec = vec!["0", "3", "27", "823", "4891", "1", "0"]; + + check_display_eq(&i32_list_vec); + check_display_eq(&u32_list_vec); + check_display_eq(&str_list_vec); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_in_impl_trait_in_parameters.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_in_impl_trait_in_parameters.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_in_impl_trait_in_parameters.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_in_impl_trait_in_parameters.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::fmt::Display; + +fn check_display_eq(iter: impl IntoIterator) { + let mut collected = String::new(); + for it in iter { + let disp = format!("{} ", it); + collected.push_str(&disp); + } + assert_eq!("0 3 27 823 4891 1 0", collected.trim()); +} + +fn main() { + let i32_list = [0i32, 3, 27, 823, 4891, 1, 0]; + let i32_list_vec = vec![0i32, 3, 27, 823, 4891, 1, 0]; + let u32_list = [0u32, 3, 27, 823, 4891, 1, 0]; + let u32_list_vec = vec![0u32, 3, 27, 823, 4891, 1, 0]; + let u16_list = [0u16, 3, 27, 823, 4891, 1, 0]; + let str_list = ["0", "3", "27", "823", "4891", "1", "0"]; + let str_list_vec = vec!["0", "3", "27", "823", "4891", "1", "0"]; + + check_display_eq(&i32_list); + check_display_eq(i32_list_vec); + check_display_eq(&u32_list); + check_display_eq(u32_list_vec); + check_display_eq(&u16_list); + check_display_eq(&str_list); + check_display_eq(str_list_vec); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_in_trait_defn_parameters.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_in_trait_defn_parameters.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_in_trait_defn_parameters.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_in_trait_defn_parameters.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::fmt::Debug; + +trait InTraitDefnParameters { + fn in_parameters(_: impl Debug) -> String; +} + +impl InTraitDefnParameters for () { + fn in_parameters(v: impl Debug) -> String { + format!("() + {:?}", v) + } +} + +fn main() { + let s = <() as InTraitDefnParameters>::in_parameters(22); + assert_eq!(s, "() + 22"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_multiple_bounds.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_multiple_bounds.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_multiple_bounds.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/universal_multiple_bounds.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::fmt::Display; + +fn foo(f: impl Display + Clone) -> String { + let g = f.clone(); + format!("{} + {}", f, g) +} + +fn main() { + let sum = foo(format!("22")); + assert_eq!(sum, r"22 + 22"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/xcrate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/xcrate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// aux-build:xcrate.rs + +extern crate xcrate; + +fn main() { +// NOTE line below commeted out due to issue #45994 +// assert_eq!(xcrate::fourway_add(1)(2)(3)(4), 10); + xcrate::return_closure_accessing_internal_fn()(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/xcrate_simple.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/xcrate_simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait/xcrate_simple.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait/xcrate_simple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// aux-build:xcrate.rs + +extern crate xcrate; + +fn main() { + xcrate::return_internal_fn()(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait-in-bindings.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait-in-bindings.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/impl-trait-in-bindings.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/impl-trait-in-bindings.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,56 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(impl_trait_in_bindings)] + +use std::fmt::Debug; + +const FOO: impl Debug + Clone + PartialEq = 42; + +static BAR: impl Debug + Clone + PartialEq = 42; + +fn a(x: T) { + let y: impl Clone = x; + let _ = y.clone(); +} + +fn b(x: T) { + let f = move || { + let y: impl Clone = x; + let _ = y.clone(); + }; + f(); +} + +trait Foo { + fn a(x: T) { + let y: impl Clone = x; + let _ = y.clone(); + } +} + +impl Foo for i32 { + fn a(x: T) { + let y: impl Clone = x; + let _ = y.clone(); + } +} + +fn main() { + let foo: impl Debug + Clone + PartialEq = 42; + + assert_eq!(FOO.clone(), 42); + assert_eq!(BAR.clone(), 42); + assert_eq!(foo.clone(), 42); + + a(42); + b(42); + i32::a(42); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use zed::bar; + +mod zed { + pub fn bar() { println!("bar"); } +} + +pub fn main() { bar(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import3.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] + +use baz::zed; +use baz::zed::bar; + +mod baz { + pub mod zed { + pub fn bar() { println!("bar2"); } + } +} + +pub fn main() { bar(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import4.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import4.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import4.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use zed::bar; + +mod zed { + pub fn bar() { println!("bar"); } +} + +pub fn main() { let _zed = 42; bar(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import5.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import5.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import5.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import5.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use foo::bar; +mod foo { + pub use foo::zed::bar; + pub mod zed { + pub fn bar() { println!("foo"); } + } +} + +pub fn main() { bar(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import6.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import6.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import6.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import6.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] + +use foo::zed; +use bar::baz; + +mod foo { + pub mod zed { + pub fn baz() { println!("baz"); } + } +} +mod bar { + pub use foo::zed::baz; +} +pub fn main() { baz(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import7.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import7.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import7.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import7.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] + +use foo::zed; +use bar::baz; + +mod foo { + pub mod zed { + pub fn baz() { println!("baz"); } + } +} +mod bar { + pub use foo::zed::baz; + pub mod foo { + pub mod zed {} + } +} +pub fn main() { baz(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import8.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import8.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import8.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import8.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use foo::x; +use foo::x as z; + +mod foo { + pub fn x(y: isize) { println!("{}", y); } +} + +pub fn main() { x(10); z(10); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans_macros.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans_macros.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans_macros.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans_macros.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! add1 { + ($e:expr) => ({ + let a = 1 + $e; + let b = $e + 1; + a + b - 1 + }) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +// no-prefer-dynamic + +// compile-flags: -g + +#[macro_use] +mod crate_with_invalid_spans_macros; + +pub fn exported_generic(x: T, y: u32) -> (T, u32) { + // Using the add1 macro will produce an invalid span, because the `y` passed + // to the macro will have a span from this file, but the rest of the code + // generated from the macro will have spans from the macro-defining file. + // The AST node for the (1 + y) expression generated by the macro will then + // take it's `lo` span bound from the `1` literal in the macro-defining file + // and it's `hi` bound from `y` in this file, which should be lower than the + // `lo` and even lower than the lower bound of the FileMap it is supposedly + // contained in because the FileMap for this file was allocated earlier than + // the FileMap of the macro-defining file. + return (x, add1!(y)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import-crate-with-invalid-spans/main.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import-crate-with-invalid-spans/main.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import-crate-with-invalid-spans/main.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import-crate-with-invalid-spans/main.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:crate_with_invalid_spans.rs + +// pretty-expanded FIXME #23616 + +extern crate crate_with_invalid_spans; + +fn main() { + // The AST of `exported_generic` stored in crate_with_invalid_spans's + // metadata should contain an invalid span where span.lo() > span.hi(). + // Let's make sure the compiler doesn't crash when encountering this. + let _ = crate_with_invalid_spans::exported_generic(32u32, 7u32); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import-from.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import-from.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import-from.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import-from.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +use spam::{ham, eggs}; + +mod spam { + pub fn ham() { } + pub fn eggs() { } +} + +pub fn main() { ham(); eggs(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import-glob-0.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import-glob-0.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import-glob-0.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import-glob-0.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +use module_of_many_things::*; +use dug::too::greedily::and::too::deep::*; + +mod module_of_many_things { + pub fn f1() { println!("f1"); } + pub fn f2() { println!("f2"); } + fn f3() { println!("f3"); } + pub fn f4() { println!("f4"); } +} + +mod dug { + pub mod too { + pub mod greedily { + pub mod and { + pub mod too { + pub mod deep { + pub fn nameless_fear() { println!("Boo!"); } + pub fn also_redstone() { println!("Whatever."); } + } + } + } + } + } +} + + +pub fn main() { f1(); f2(); f4(); nameless_fear(); also_redstone(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import-glob-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import-glob-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import-glob-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import-glob-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_imports)] +// This should resolve fine. Prior to fix, the last import +// was being tried too early, and marked as unrsolved before +// the glob import had a chance to be resolved. + +mod bar { + pub use self::middle::*; + + mod middle { + pub use self::baz::Baz; + + mod baz { + pub enum Baz { + Baz1, + Baz2 + } + } + } +} + +mod foo { + use bar::Baz::{Baz1, Baz2}; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import-glob-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import-glob-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import-glob-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import-glob-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::mem::*; + +pub fn main() { + assert_eq!(size_of::(), 1); + let (mut x, mut y) = (1, 2); + swap(&mut x, &mut y); + assert_eq!(x, 2); + assert_eq!(y, 1); +} + +#[allow(unused)] +fn f() { + mod foo { pub use *; } + mod bar { pub use ::*; } + + foo::main(); + bar::main(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import-in-block.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import-in-block.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import-in-block.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import-in-block.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +pub fn main() { + use std::mem::replace; + let mut x = 5; + replace(&mut x, 6); + { + use std::mem::*; + let mut y = 6; + swap(&mut x, &mut y); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import-prefix-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import-prefix-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import-prefix-macro.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import-prefix-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +mod a { + pub mod b { + pub mod c { + pub struct S; + pub struct Z; + } + pub struct W; + } +} + +macro_rules! import { + (1 $p: path) => (use $p;); + (2 $p: path) => (use $p::{Z};); + (3 $p: path) => (use $p::*;); +} + +import! { 1 a::b::c::S } +import! { 2 a::b::c } +import! { 3 a::b } + +fn main() { + let s = S; + let z = Z; + let w = W; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import-rename.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import-rename.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import-rename.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import-rename.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +use foo::{x, y as fooy}; +use Maybe::{Yes as MaybeYes}; + +pub enum Maybe { Yes, No } +mod foo { + use super::Maybe::{self as MaybeFoo}; + pub fn x(a: MaybeFoo) {} + pub fn y(a: i32) { println!("{}", a); } +} + +pub fn main() { x(MaybeYes); fooy(10); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +mod foo { + pub fn x(y: isize) { println!("{}", y); } +} + +mod bar { + use foo::x; + use foo::x as z; + pub fn thing() { x(10); z(10); } +} + +pub fn main() { bar::thing(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/imports.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/imports.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/imports.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/imports.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,76 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused)] + +// Like other items, private imports can be imported and used non-lexically in paths. +mod a { + use a as foo; + use self::foo::foo as bar; + + mod b { + use super::bar; + } +} + +mod foo { pub fn f() {} } +mod bar { pub fn f() {} } + +pub fn f() -> bool { true } + +// Items and explicit imports shadow globs. +fn g() { + use foo::*; + use bar::*; + fn f() -> bool { true } + let _: bool = f(); +} + +fn h() { + use foo::*; + use bar::*; + use f; + let _: bool = f(); +} + +// Here, there appears to be shadowing but isn't because of namespaces. +mod b { + use foo::*; // This imports `f` in the value namespace. + use super::b as f; // This imports `f` only in the type namespace, + fn test() { self::f(); } // so the glob isn't shadowed. +} + +// Here, there is shadowing in one namespace, but not the other. +mod c { + mod test { + pub fn f() {} + pub mod f {} + } + use self::test::*; // This glob-imports `f` in both namespaces. + mod f { pub fn f() {} } // This shadows the glob only in the value namespace. + + fn test() { + self::f(); // Check that the glob-imported value isn't shadowed. + self::f::f(); // Check that the glob-imported module is shadowed. + } +} + +// Unused names can be ambiguous. +mod d { + pub use foo::*; // This imports `f` in the value namespace. + pub use bar::*; // This also imports `f` in the value namespace. +} + +mod e { + pub use d::*; // n.b. Since `e::f` is not used, this is not considered to be a use of `d::f`. +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import-trailing-comma.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import-trailing-comma.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/imports/import-trailing-comma.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/imports/import-trailing-comma.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +use foo::bar::{baz, quux,}; + +mod foo { + pub mod bar { + pub fn baz() { } + pub fn quux() { } + } +} + +pub fn main() { baz(); quux(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/infer-fn-tail-expr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/infer-fn-tail-expr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/infer-fn-tail-expr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/infer-fn-tail-expr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // issue #680 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/init-large-type.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/init-large-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/init-large-type.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/init-large-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_must_use)] // Makes sure that zero-initializing large types is reasonably fast, // Doing it incorrectly causes massive slowdown in LLVM during // optimisation. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/init-res-into-things.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/init-res-into-things.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/init-res-into-things.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/init-res-into-things.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(dead_code)] #![feature(box_syntax)] use std::cell::Cell; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/instantiable.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/instantiable.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/instantiable.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/instantiable.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(dead_code)] // pretty-expanded FIXME #23616 use std::ptr; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/intrinsics/auxiliary/cci_intrinsic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/intrinsics/auxiliary/cci_intrinsic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/intrinsics/auxiliary/cci_intrinsic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/intrinsics/auxiliary/cci_intrinsic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(intrinsics)] + +pub mod rusti { + extern "rust-intrinsic" { + pub fn atomic_xchg(dst: *mut T, src: T) -> T; + } +} + +#[inline(always)] +pub fn atomic_xchg(dst: *mut isize, src: isize) -> isize { + unsafe { + rusti::atomic_xchg(dst, src) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-alignment.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-alignment.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-alignment.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-alignment.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,84 @@ +// Copyright 2012-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-wasm32-bare seems not important to test here + +#![feature(intrinsics, main)] + +mod rusti { + extern "rust-intrinsic" { + pub fn pref_align_of() -> usize; + pub fn min_align_of() -> usize; + } +} + +#[cfg(any(target_os = "android", + target_os = "cloudabi", + target_os = "dragonfly", + target_os = "emscripten", + target_os = "freebsd", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", + target_os = "solaris"))] +mod m { + #[main] + #[cfg(target_arch = "x86")] + pub fn main() { + unsafe { + assert_eq!(::rusti::pref_align_of::(), 8); + assert_eq!(::rusti::min_align_of::(), 4); + } + } + + #[main] + #[cfg(not(target_arch = "x86"))] + pub fn main() { + unsafe { + assert_eq!(::rusti::pref_align_of::(), 8); + assert_eq!(::rusti::min_align_of::(), 8); + } + } +} + +#[cfg(target_os = "bitrig")] +mod m { + #[main] + #[cfg(target_arch = "x86_64")] + pub fn main() { + unsafe { + assert_eq!(::rusti::pref_align_of::(), 8); + assert_eq!(::rusti::min_align_of::(), 8); + } + } +} + +#[cfg(target_os = "windows")] +mod m { + #[main] + #[cfg(target_arch = "x86")] + pub fn main() { + unsafe { + assert_eq!(::rusti::pref_align_of::(), 8); + assert_eq!(::rusti::min_align_of::(), 8); + } + } + + #[main] + #[cfg(target_arch = "x86_64")] + pub fn main() { + unsafe { + assert_eq!(::rusti::pref_align_of::(), 8); + assert_eq!(::rusti::min_align_of::(), 8); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-assume.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-assume.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-assume.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-assume.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(core_intrinsics)] + +use std::intrinsics::assume; + +unsafe fn f(x: i32) -> i32 { + assume(x == 34); + match x { + 34 => 42, + _ => 30 + } +} + +fn main() { + let x = unsafe { f(34) }; + assert_eq!(x, 42); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-atomics-cc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-atomics-cc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-atomics-cc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-atomics-cc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:cci_intrinsic.rs + + +extern crate cci_intrinsic; +use cci_intrinsic::atomic_xchg; + +pub fn main() { + let mut x = 1; + atomic_xchg(&mut x, 5); + assert_eq!(x, 5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-atomics.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-atomics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-atomics.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-atomics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,113 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] +#![feature(intrinsics)] + +mod rusti { + extern "rust-intrinsic" { + pub fn atomic_cxchg(dst: *mut T, old: T, src: T) -> (T, bool); + pub fn atomic_cxchg_acq(dst: *mut T, old: T, src: T) -> (T, bool); + pub fn atomic_cxchg_rel(dst: *mut T, old: T, src: T) -> (T, bool); + + pub fn atomic_cxchgweak(dst: *mut T, old: T, src: T) -> (T, bool); + pub fn atomic_cxchgweak_acq(dst: *mut T, old: T, src: T) -> (T, bool); + pub fn atomic_cxchgweak_rel(dst: *mut T, old: T, src: T) -> (T, bool); + + pub fn atomic_load(src: *const T) -> T; + pub fn atomic_load_acq(src: *const T) -> T; + + pub fn atomic_store(dst: *mut T, val: T); + pub fn atomic_store_rel(dst: *mut T, val: T); + + pub fn atomic_xchg(dst: *mut T, src: T) -> T; + pub fn atomic_xchg_acq(dst: *mut T, src: T) -> T; + pub fn atomic_xchg_rel(dst: *mut T, src: T) -> T; + + pub fn atomic_xadd(dst: *mut T, src: T) -> T; + pub fn atomic_xadd_acq(dst: *mut T, src: T) -> T; + pub fn atomic_xadd_rel(dst: *mut T, src: T) -> T; + + pub fn atomic_xsub(dst: *mut T, src: T) -> T; + pub fn atomic_xsub_acq(dst: *mut T, src: T) -> T; + pub fn atomic_xsub_rel(dst: *mut T, src: T) -> T; + } +} + +pub fn main() { + unsafe { + let mut x: Box<_> = box 1; + + assert_eq!(rusti::atomic_load(&*x), 1); + *x = 5; + assert_eq!(rusti::atomic_load_acq(&*x), 5); + + rusti::atomic_store(&mut *x,3); + assert_eq!(*x, 3); + rusti::atomic_store_rel(&mut *x,1); + assert_eq!(*x, 1); + + assert_eq!(rusti::atomic_cxchg(&mut *x, 1, 2), (1, true)); + assert_eq!(*x, 2); + + assert_eq!(rusti::atomic_cxchg_acq(&mut *x, 1, 3), (2, false)); + assert_eq!(*x, 2); + + assert_eq!(rusti::atomic_cxchg_rel(&mut *x, 2, 1), (2, true)); + assert_eq!(*x, 1); + + assert_eq!(rusti::atomic_xchg(&mut *x, 0), 1); + assert_eq!(*x, 0); + + assert_eq!(rusti::atomic_xchg_acq(&mut *x, 1), 0); + assert_eq!(*x, 1); + + assert_eq!(rusti::atomic_xchg_rel(&mut *x, 0), 1); + assert_eq!(*x, 0); + + assert_eq!(rusti::atomic_xadd(&mut *x, 1), 0); + assert_eq!(rusti::atomic_xadd_acq(&mut *x, 1), 1); + assert_eq!(rusti::atomic_xadd_rel(&mut *x, 1), 2); + assert_eq!(*x, 3); + + assert_eq!(rusti::atomic_xsub(&mut *x, 1), 3); + assert_eq!(rusti::atomic_xsub_acq(&mut *x, 1), 2); + assert_eq!(rusti::atomic_xsub_rel(&mut *x, 1), 1); + assert_eq!(*x, 0); + + loop { + let res = rusti::atomic_cxchgweak(&mut *x, 0, 1); + assert_eq!(res.0, 0); + if res.1 { + break; + } + } + assert_eq!(*x, 1); + + loop { + let res = rusti::atomic_cxchgweak_acq(&mut *x, 1, 2); + assert_eq!(res.0, 1); + if res.1 { + break; + } + } + assert_eq!(*x, 2); + + loop { + let res = rusti::atomic_cxchgweak_rel(&mut *x, 2, 3); + assert_eq!(res.0, 2); + if res.1 { + break; + } + } + assert_eq!(*x, 3); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-move-val-cleanups.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-move-val-cleanups.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-move-val-cleanups.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-move-val-cleanups.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,200 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_unsafe)] +#![allow(unreachable_code)] +// ignore-emscripten no threads support +#![allow(stable_features)] + +// This test is checking that the move_val_init intrinsic is +// respecting cleanups for both of its argument expressions. +// +// In other words, if either DEST or SOURCE in +// +// `intrinsics::move_val_init(DEST, SOURCE) +// +// introduce temporaries that require cleanup, and SOURCE panics, then +// make sure the cleanups still occur. + +#![feature(core_intrinsics, sync_poison)] + +use std::cell::RefCell; +use std::intrinsics; +use std::sync::{Arc, LockResult, Mutex, MutexGuard}; +use std::thread; + +type LogEntry = (&'static str, i32); +type Guarded = RefCell>; +#[derive(Clone)] +struct Log(Arc>); +struct Acquired<'a>(MutexGuard<'a, Guarded>); +type LogState = (MutexWas, &'static [LogEntry]); + +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +enum MutexWas { Poisoned, NotPoisoned } + +impl Log { + fn lock(&self) -> LockResult>>> { self.0.lock() } + fn acquire(&self) -> Acquired { Acquired(self.0.lock().unwrap()) } +} + +impl<'a> Acquired<'a> { + fn log(&self, s: &'static str, i: i32) { self.0.borrow_mut().push((s, i)); } +} + +const TEST1_EXPECT: LogState = (MutexWas::NotPoisoned, + &[("double-check non-poisoning path", 1) + ]); + +fn test1(log: Log) { + { + let acq = log.acquire(); + acq.log("double-check non-poisoning path", 1); + } + panic!("every test ends in a panic"); +} + +const TEST2_EXPECT: LogState = (MutexWas::Poisoned, + &[("double-check poisoning path", 1), + ("and multiple log entries", 2), + ]); +fn test2(log: Log) { + let acq = log.acquire(); + acq.log("double-check poisoning path", 1); + acq.log("and multiple log entries", 2); + panic!("every test ends in a panic"); +} + +struct LogOnDrop<'a>(&'a Acquired<'a>, &'static str, i32); +impl<'a> Drop for LogOnDrop<'a> { + fn drop(&mut self) { + self.0.log(self.1, self.2); + } +} + +const TEST3_EXPECT: LogState = (MutexWas::Poisoned, + &[("double-check destructors can log", 1), + ("drop d2", 2), + ("drop d1", 3), + ]); +fn test3(log: Log) { + let acq = log.acquire(); + acq.log("double-check destructors can log", 1); + let _d1 = LogOnDrop(&acq, "drop d1", 3); + let _d2 = LogOnDrop(&acq, "drop d2", 2); + panic!("every test ends in a panic"); +} + +// The *real* tests of panic-handling for move_val_init intrinsic +// start here. + +const TEST4_EXPECT: LogState = (MutexWas::Poisoned, + &[("neither arg panics", 1), + ("drop temp LOD", 2), + ("drop temp LOD", 3), + ("drop dest_b", 4), + ("drop dest_a", 5), + ]); +fn test4(log: Log) { + let acq = log.acquire(); + acq.log("neither arg panics", 1); + let mut dest_a = LogOnDrop(&acq, "a will be overwritten, not dropped", 0); + let mut dest_b = LogOnDrop(&acq, "b will be overwritten, not dropped", 0); + unsafe { + intrinsics::move_val_init({ LogOnDrop(&acq, "drop temp LOD", 2); &mut dest_a }, + LogOnDrop(&acq, "drop dest_a", 5)); + intrinsics::move_val_init(&mut dest_b, { LogOnDrop(&acq, "drop temp LOD", 3); + LogOnDrop(&acq, "drop dest_b", 4) }); + } + panic!("every test ends in a panic"); +} + + +// Check that move_val_init(PANIC, SOURCE_EXPR) never evaluates SOURCE_EXPR +const TEST5_EXPECT: LogState = (MutexWas::Poisoned, + &[("first arg panics", 1), + ("drop orig dest_a", 2), + ]); +fn test5(log: Log) { + let acq = log.acquire(); + acq.log("first arg panics", 1); + let mut _dest_a = LogOnDrop(&acq, "drop orig dest_a", 2); + unsafe { + intrinsics::move_val_init({ panic!("every test ends in a panic") }, + LogOnDrop(&acq, "we never get here", 0)); + } +} + +// Check that move_val_init(DEST_EXPR, PANIC) cleans up temps from DEST_EXPR. +const TEST6_EXPECT: LogState = (MutexWas::Poisoned, + &[("second arg panics", 1), + ("drop temp LOD", 2), + ("drop orig dest_a", 3), + ]); +fn test6(log: Log) { + let acq = log.acquire(); + acq.log("second arg panics", 1); + let mut dest_a = LogOnDrop(&acq, "drop orig dest_a", 3); + unsafe { + intrinsics::move_val_init({ LogOnDrop(&acq, "drop temp LOD", 2); &mut dest_a }, + { panic!("every test ends in a panic"); }); + } +} + +// Check that move_val_init(DEST_EXPR, COMPLEX_PANIC) cleans up temps from COMPLEX_PANIC. +const TEST7_EXPECT: LogState = (MutexWas::Poisoned, + &[("second arg panics", 1), + ("drop temp LOD", 2), + ("drop temp LOD", 3), + ("drop orig dest_a", 4), + ]); +fn test7(log: Log) { + let acq = log.acquire(); + acq.log("second arg panics", 1); + let mut dest_a = LogOnDrop(&acq, "drop orig dest_a", 4); + unsafe { + intrinsics::move_val_init({ LogOnDrop(&acq, "drop temp LOD", 2); &mut dest_a }, + { LogOnDrop(&acq, "drop temp LOD", 3); + panic!("every test ends in a panic"); }); + } +} + +const TEST_SUITE: &'static [(&'static str, fn (Log), LogState)] = + &[("test1", test1, TEST1_EXPECT), + ("test2", test2, TEST2_EXPECT), + ("test3", test3, TEST3_EXPECT), + ("test4", test4, TEST4_EXPECT), + ("test5", test5, TEST5_EXPECT), + ("test6", test6, TEST6_EXPECT), + ("test7", test7, TEST7_EXPECT), + ]; + +fn main() { + for &(name, test, expect) in TEST_SUITE { + let log = Log(Arc::new(Mutex::new(RefCell::new(Vec::new())))); + let ret = { let log = log.clone(); thread::spawn(move || test(log)).join() }; + assert!(ret.is_err(), "{} must end with panic", name); + { + let l = log.lock(); + match l { + Ok(acq) => { + assert_eq!((MutexWas::NotPoisoned, &acq.borrow()[..]), expect); + println!("{} (unpoisoned) log: {:?}", name, *acq); + } + Err(e) => { + let acq = e.into_inner(); + assert_eq!((MutexWas::Poisoned, &acq.borrow()[..]), expect); + println!("{} (poisoned) log: {:?}", name, *acq); + } + } + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-move-val.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-move-val.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-move-val.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-move-val.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,92 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(box_syntax)] +#![feature(intrinsics)] + +mod rusti { + extern "rust-intrinsic" { + pub fn init() -> T; + pub fn move_val_init(dst: *mut T, src: T); + } +} + +pub fn main() { + unsafe { + // sanity check + check_drops_state(0, None); + + let mut x: Box = box D(1); + assert_eq!(x.0, 1); + + // A normal overwrite, to demonstrate `check_drops_state`. + x = box D(2); + + // At this point, one destructor has run, because the + // overwrite of `x` drops its initial value. + check_drops_state(1, Some(1)); + + let mut y: Box = rusti::init(); + + // An initial binding does not overwrite anything. + check_drops_state(1, Some(1)); + + // Since `y` has been initialized via the `init` intrinsic, it + // would be unsound to directly overwrite its value via normal + // assignment. + // + // The code currently generated by the compiler is overly + // accepting, however, in that it will check if `y` is itself + // null and thus avoid the unsound action of attempting to + // free null. In other words, if we were to do a normal + // assignment like `y = box D(4);` here, it probably would not + // crash today. But the plan is that it may well crash in the + // future, (I believe). + + // `x` is moved here; the manner in which this is tracked by the + // compiler is hidden. + rusti::move_val_init(&mut y, x); + + // But what we *can* observe is how many times the destructor + // for `D` is invoked, and what the last value we saw was + // during such a destructor call. We do so after the end of + // this scope. + + assert_eq!(y.0, 2); + y.0 = 3; + assert_eq!(y.0, 3); + + check_drops_state(1, Some(1)); + } + + check_drops_state(2, Some(3)); +} + +static mut NUM_DROPS: i32 = 0; +static mut LAST_DROPPED: Option = None; + +fn check_drops_state(num_drops: i32, last_dropped: Option) { + unsafe { + assert_eq!(NUM_DROPS, num_drops); + assert_eq!(LAST_DROPPED, last_dropped); + } +} + +struct D(i32); +impl Drop for D { + fn drop(&mut self) { + unsafe { + NUM_DROPS += 1; + LAST_DROPPED = Some(self.0); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsics-integer.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsics-integer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsics-integer.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsics-integer.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,180 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten no i128 support + +#![feature(intrinsics)] + +mod rusti { + extern "rust-intrinsic" { + pub fn ctpop(x: T) -> T; + pub fn ctlz(x: T) -> T; + pub fn ctlz_nonzero(x: T) -> T; + pub fn cttz(x: T) -> T; + pub fn cttz_nonzero(x: T) -> T; + pub fn bswap(x: T) -> T; + pub fn bitreverse(x: T) -> T; + } +} + +pub fn main() { + unsafe { + use rusti::*; + + assert_eq!(ctpop(0u8), 0); assert_eq!(ctpop(0i8), 0); + assert_eq!(ctpop(0u16), 0); assert_eq!(ctpop(0i16), 0); + assert_eq!(ctpop(0u32), 0); assert_eq!(ctpop(0i32), 0); + assert_eq!(ctpop(0u64), 0); assert_eq!(ctpop(0i64), 0); + assert_eq!(ctpop(0u128), 0); assert_eq!(ctpop(0i128), 0); + + assert_eq!(ctpop(1u8), 1); assert_eq!(ctpop(1i8), 1); + assert_eq!(ctpop(1u16), 1); assert_eq!(ctpop(1i16), 1); + assert_eq!(ctpop(1u32), 1); assert_eq!(ctpop(1i32), 1); + assert_eq!(ctpop(1u64), 1); assert_eq!(ctpop(1i64), 1); + assert_eq!(ctpop(1u128), 1); assert_eq!(ctpop(1i128), 1); + + assert_eq!(ctpop(10u8), 2); assert_eq!(ctpop(10i8), 2); + assert_eq!(ctpop(10u16), 2); assert_eq!(ctpop(10i16), 2); + assert_eq!(ctpop(10u32), 2); assert_eq!(ctpop(10i32), 2); + assert_eq!(ctpop(10u64), 2); assert_eq!(ctpop(10i64), 2); + assert_eq!(ctpop(10u128), 2); assert_eq!(ctpop(10i128), 2); + + assert_eq!(ctpop(100u8), 3); assert_eq!(ctpop(100i8), 3); + assert_eq!(ctpop(100u16), 3); assert_eq!(ctpop(100i16), 3); + assert_eq!(ctpop(100u32), 3); assert_eq!(ctpop(100i32), 3); + assert_eq!(ctpop(100u64), 3); assert_eq!(ctpop(100i64), 3); + assert_eq!(ctpop(100u128), 3); assert_eq!(ctpop(100i128), 3); + + assert_eq!(ctpop(-1i8 as u8), 8); assert_eq!(ctpop(-1i8), 8); + assert_eq!(ctpop(-1i16 as u16), 16); assert_eq!(ctpop(-1i16), 16); + assert_eq!(ctpop(-1i32 as u32), 32); assert_eq!(ctpop(-1i32), 32); + assert_eq!(ctpop(-1i64 as u64), 64); assert_eq!(ctpop(-1i64), 64); + assert_eq!(ctpop(-1i128 as u128), 128); assert_eq!(ctpop(-1i128), 128); + + assert_eq!(ctlz(0u8), 8); assert_eq!(ctlz(0i8), 8); + assert_eq!(ctlz(0u16), 16); assert_eq!(ctlz(0i16), 16); + assert_eq!(ctlz(0u32), 32); assert_eq!(ctlz(0i32), 32); + assert_eq!(ctlz(0u64), 64); assert_eq!(ctlz(0i64), 64); + assert_eq!(ctlz(0u128), 128); assert_eq!(ctlz(0i128), 128); + + assert_eq!(ctlz(1u8), 7); assert_eq!(ctlz(1i8), 7); + assert_eq!(ctlz(1u16), 15); assert_eq!(ctlz(1i16), 15); + assert_eq!(ctlz(1u32), 31); assert_eq!(ctlz(1i32), 31); + assert_eq!(ctlz(1u64), 63); assert_eq!(ctlz(1i64), 63); + assert_eq!(ctlz(1u128), 127); assert_eq!(ctlz(1i128), 127); + + assert_eq!(ctlz(10u8), 4); assert_eq!(ctlz(10i8), 4); + assert_eq!(ctlz(10u16), 12); assert_eq!(ctlz(10i16), 12); + assert_eq!(ctlz(10u32), 28); assert_eq!(ctlz(10i32), 28); + assert_eq!(ctlz(10u64), 60); assert_eq!(ctlz(10i64), 60); + assert_eq!(ctlz(10u128), 124); assert_eq!(ctlz(10i128), 124); + + assert_eq!(ctlz(100u8), 1); assert_eq!(ctlz(100i8), 1); + assert_eq!(ctlz(100u16), 9); assert_eq!(ctlz(100i16), 9); + assert_eq!(ctlz(100u32), 25); assert_eq!(ctlz(100i32), 25); + assert_eq!(ctlz(100u64), 57); assert_eq!(ctlz(100i64), 57); + assert_eq!(ctlz(100u128), 121); assert_eq!(ctlz(100i128), 121); + + assert_eq!(ctlz_nonzero(1u8), 7); assert_eq!(ctlz_nonzero(1i8), 7); + assert_eq!(ctlz_nonzero(1u16), 15); assert_eq!(ctlz_nonzero(1i16), 15); + assert_eq!(ctlz_nonzero(1u32), 31); assert_eq!(ctlz_nonzero(1i32), 31); + assert_eq!(ctlz_nonzero(1u64), 63); assert_eq!(ctlz_nonzero(1i64), 63); + assert_eq!(ctlz_nonzero(1u128), 127); assert_eq!(ctlz_nonzero(1i128), 127); + + assert_eq!(ctlz_nonzero(10u8), 4); assert_eq!(ctlz_nonzero(10i8), 4); + assert_eq!(ctlz_nonzero(10u16), 12); assert_eq!(ctlz_nonzero(10i16), 12); + assert_eq!(ctlz_nonzero(10u32), 28); assert_eq!(ctlz_nonzero(10i32), 28); + assert_eq!(ctlz_nonzero(10u64), 60); assert_eq!(ctlz_nonzero(10i64), 60); + assert_eq!(ctlz_nonzero(10u128), 124); assert_eq!(ctlz_nonzero(10i128), 124); + + assert_eq!(ctlz_nonzero(100u8), 1); assert_eq!(ctlz_nonzero(100i8), 1); + assert_eq!(ctlz_nonzero(100u16), 9); assert_eq!(ctlz_nonzero(100i16), 9); + assert_eq!(ctlz_nonzero(100u32), 25); assert_eq!(ctlz_nonzero(100i32), 25); + assert_eq!(ctlz_nonzero(100u64), 57); assert_eq!(ctlz_nonzero(100i64), 57); + assert_eq!(ctlz_nonzero(100u128), 121); assert_eq!(ctlz_nonzero(100i128), 121); + + assert_eq!(cttz(-1i8 as u8), 0); assert_eq!(cttz(-1i8), 0); + assert_eq!(cttz(-1i16 as u16), 0); assert_eq!(cttz(-1i16), 0); + assert_eq!(cttz(-1i32 as u32), 0); assert_eq!(cttz(-1i32), 0); + assert_eq!(cttz(-1i64 as u64), 0); assert_eq!(cttz(-1i64), 0); + assert_eq!(cttz(-1i128 as u128), 0); assert_eq!(cttz(-1i128), 0); + + assert_eq!(cttz(0u8), 8); assert_eq!(cttz(0i8), 8); + assert_eq!(cttz(0u16), 16); assert_eq!(cttz(0i16), 16); + assert_eq!(cttz(0u32), 32); assert_eq!(cttz(0i32), 32); + assert_eq!(cttz(0u64), 64); assert_eq!(cttz(0i64), 64); + assert_eq!(cttz(0u128), 128); assert_eq!(cttz(0i128), 128); + + assert_eq!(cttz(1u8), 0); assert_eq!(cttz(1i8), 0); + assert_eq!(cttz(1u16), 0); assert_eq!(cttz(1i16), 0); + assert_eq!(cttz(1u32), 0); assert_eq!(cttz(1i32), 0); + assert_eq!(cttz(1u64), 0); assert_eq!(cttz(1i64), 0); + assert_eq!(cttz(1u128), 0); assert_eq!(cttz(1i128), 0); + + assert_eq!(cttz(10u8), 1); assert_eq!(cttz(10i8), 1); + assert_eq!(cttz(10u16), 1); assert_eq!(cttz(10i16), 1); + assert_eq!(cttz(10u32), 1); assert_eq!(cttz(10i32), 1); + assert_eq!(cttz(10u64), 1); assert_eq!(cttz(10i64), 1); + assert_eq!(cttz(10u128), 1); assert_eq!(cttz(10i128), 1); + + assert_eq!(cttz(100u8), 2); assert_eq!(cttz(100i8), 2); + assert_eq!(cttz(100u16), 2); assert_eq!(cttz(100i16), 2); + assert_eq!(cttz(100u32), 2); assert_eq!(cttz(100i32), 2); + assert_eq!(cttz(100u64), 2); assert_eq!(cttz(100i64), 2); + assert_eq!(cttz(100u128), 2); assert_eq!(cttz(100i128), 2); + + assert_eq!(cttz_nonzero(-1i8 as u8), 0); assert_eq!(cttz_nonzero(-1i8), 0); + assert_eq!(cttz_nonzero(-1i16 as u16), 0); assert_eq!(cttz_nonzero(-1i16), 0); + assert_eq!(cttz_nonzero(-1i32 as u32), 0); assert_eq!(cttz_nonzero(-1i32), 0); + assert_eq!(cttz_nonzero(-1i64 as u64), 0); assert_eq!(cttz_nonzero(-1i64), 0); + assert_eq!(cttz_nonzero(-1i128 as u128), 0); assert_eq!(cttz_nonzero(-1i128), 0); + + assert_eq!(cttz_nonzero(1u8), 0); assert_eq!(cttz_nonzero(1i8), 0); + assert_eq!(cttz_nonzero(1u16), 0); assert_eq!(cttz_nonzero(1i16), 0); + assert_eq!(cttz_nonzero(1u32), 0); assert_eq!(cttz_nonzero(1i32), 0); + assert_eq!(cttz_nonzero(1u64), 0); assert_eq!(cttz_nonzero(1i64), 0); + assert_eq!(cttz_nonzero(1u128), 0); assert_eq!(cttz_nonzero(1i128), 0); + + assert_eq!(cttz_nonzero(10u8), 1); assert_eq!(cttz_nonzero(10i8), 1); + assert_eq!(cttz_nonzero(10u16), 1); assert_eq!(cttz_nonzero(10i16), 1); + assert_eq!(cttz_nonzero(10u32), 1); assert_eq!(cttz_nonzero(10i32), 1); + assert_eq!(cttz_nonzero(10u64), 1); assert_eq!(cttz_nonzero(10i64), 1); + assert_eq!(cttz_nonzero(10u128), 1); assert_eq!(cttz_nonzero(10i128), 1); + + assert_eq!(cttz_nonzero(100u8), 2); assert_eq!(cttz_nonzero(100i8), 2); + assert_eq!(cttz_nonzero(100u16), 2); assert_eq!(cttz_nonzero(100i16), 2); + assert_eq!(cttz_nonzero(100u32), 2); assert_eq!(cttz_nonzero(100i32), 2); + assert_eq!(cttz_nonzero(100u64), 2); assert_eq!(cttz_nonzero(100i64), 2); + assert_eq!(cttz_nonzero(100u128), 2); assert_eq!(cttz_nonzero(100i128), 2); + + assert_eq!(bswap(0x0Au8), 0x0A); // no-op + assert_eq!(bswap(0x0Ai8), 0x0A); // no-op + assert_eq!(bswap(0x0A0Bu16), 0x0B0A); + assert_eq!(bswap(0x0A0Bi16), 0x0B0A); + assert_eq!(bswap(0x0ABBCC0Du32), 0x0DCCBB0A); + assert_eq!(bswap(0x0ABBCC0Di32), 0x0DCCBB0A); + assert_eq!(bswap(0x0122334455667708u64), 0x0877665544332201); + assert_eq!(bswap(0x0122334455667708i64), 0x0877665544332201); + assert_eq!(bswap(0x0122334455667708u128), 0x08776655443322010000000000000000); + assert_eq!(bswap(0x0122334455667708i128), 0x08776655443322010000000000000000); + + assert_eq!(bitreverse(0x0Au8), 0x50); + assert_eq!(bitreverse(0x0Ai8), 0x50); + assert_eq!(bitreverse(0x0A0Cu16), 0x3050); + assert_eq!(bitreverse(0x0A0Ci16), 0x3050); + assert_eq!(bitreverse(0x0ABBCC0Eu32), 0x7033DD50); + assert_eq!(bitreverse(0x0ABBCC0Ei32), 0x7033DD50); + assert_eq!(bitreverse(0x0122334455667708u64), 0x10EE66AA22CC4480); + assert_eq!(bitreverse(0x0122334455667708i64), 0x10EE66AA22CC4480); + assert_eq!(bitreverse(0x0122334455667708u128), 0x10EE66AA22CC44800000000000000000); + assert_eq!(bitreverse(0x0122334455667708i128), 0x10EE66AA22CC44800000000000000000); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsics-math.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsics-math.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsics-math.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsics-math.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,70 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten fma not implemented in emscripten + +macro_rules! assert_approx_eq { + ($a:expr, $b:expr) => ({ + let (a, b) = (&$a, &$b); + assert!((*a - *b).abs() < 1.0e-6, + "{} is not approximately equal to {}", *a, *b); + }) +} + +pub fn main() { + use std::f32; + use std::f64; + + assert_approx_eq!(64f32.sqrt(), 8f32); + assert_approx_eq!(64f64.sqrt(), 8f64); + + assert_approx_eq!(25f32.powi(-2), 0.0016f32); + assert_approx_eq!(23.2f64.powi(2), 538.24f64); + + assert_approx_eq!(0f32.sin(), 0f32); + assert_approx_eq!((f64::consts::PI / 2f64).sin(), 1f64); + + assert_approx_eq!(0f32.cos(), 1f32); + assert_approx_eq!((f64::consts::PI * 2f64).cos(), 1f64); + + assert_approx_eq!(25f32.powf(-2f32), 0.0016f32); + assert_approx_eq!(400f64.powf(0.5f64), 20f64); + + assert_approx_eq!((1f32.exp() - f32::consts::E).abs(), 0f32); + assert_approx_eq!(1f64.exp(), f64::consts::E); + + assert_approx_eq!(10f32.exp2(), 1024f32); + assert_approx_eq!(50f64.exp2(), 1125899906842624f64); + + assert_approx_eq!((f32::consts::E.ln() - 1f32).abs(), 0f32); + assert_approx_eq!(1f64.ln(), 0f64); + + assert_approx_eq!(10f32.log10(), 1f32); + assert_approx_eq!(f64::consts::E.log10(), f64::consts::LOG10_E); + + assert_approx_eq!(8f32.log2(), 3f32); + assert_approx_eq!(f64::consts::E.log2(), f64::consts::LOG2_E); + + assert_approx_eq!(1.0f32.mul_add(2.0f32, 5.0f32), 7.0f32); + assert_approx_eq!(0.0f64.mul_add(-2.0f64, f64::consts::E), f64::consts::E); + + assert_approx_eq!((-1.0f32).abs(), 1.0f32); + assert_approx_eq!(34.2f64.abs(), 34.2f64); + + assert_approx_eq!(3.8f32.floor(), 3.0f32); + assert_approx_eq!((-1.1f64).floor(), -2.0f64); + + assert_approx_eq!((-2.3f32).ceil(), -2.0f32); + assert_approx_eq!(3.8f64.ceil(), 4.0f64); + + assert_approx_eq!(0.1f32.trunc(), 0.0f32); + assert_approx_eq!((-0.1f64).trunc(), 0.0f64); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-uninit.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-uninit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-uninit.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-uninit.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#![feature(intrinsics)] + +mod rusti { + extern "rust-intrinsic" { + pub fn uninit() -> T; + } +} +pub fn main() { + let _a : isize = unsafe {rusti::uninit()}; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-unreachable.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-unreachable.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-unreachable.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/intrinsics/intrinsic-unreachable.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(core_intrinsics)] + +use std::intrinsics; + +// See also src/test/run-make/intrinsic-unreachable. + +unsafe fn f(x: usize) -> usize { + match x { + 17 => 23, + _ => intrinsics::unreachable(), + } +} + +fn main() { + assert_eq!(unsafe { f(17) }, 23); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/invalid_const_promotion.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/invalid_const_promotion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/invalid_const_promotion.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/invalid_const_promotion.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,12 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_mut)] // ignore-wasm32 // ignore-emscripten // compile-flags: -C debug_assertions=yes -#![feature(const_fn, libc)] +#![stable(feature = "rustc", since = "1.0.0")] +#![feature(const_fn, libc, staged_api, rustc_attrs)] #![allow(const_err)] extern crate libc; @@ -22,6 +24,8 @@ use std::process::{Command, Stdio}; // this will panic in debug mode and overflow in release mode +#[stable(feature = "rustc", since = "1.0.0")] +#[rustc_promotable] const fn bar() -> usize { 0 - 1 } fn foo() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issue-53728.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issue-53728.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issue-53728.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issue-53728.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] #[repr(u16)] enum DeviceKind { Nil = 0, diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issue-54467.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issue-54467.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issue-54467.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issue-54467.rs 2018-12-04 23:41:40.000000000 +0000 @@ -37,7 +37,7 @@ pub struct Reserved<'a, I> where I: Stream + 'a, I::Error: ParseError, -// <::Error as ParseError>::Output: 'a // comment this to compile + <::Error as ParseError>::Output: 'a { x: Lex<'a, I> diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issue-55376.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issue-55376.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issue-55376.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issue-55376.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that paths in `pub(...)` don't fail HIR verification. + +#![allow(unused_imports)] +#![allow(dead_code)] + +pub(self) use self::my_mod::Foo; + +mod my_mod { + pub(super) use self::Foo as Bar; + pub(in super::my_mod) use self::Foo as Baz; + + pub struct Foo; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/cgu_test_a.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/cgu_test_a.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/cgu_test_a.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/cgu_test_a.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic +// compile-flags: -Ccodegen-units=2 --crate-type=lib + +extern crate cgu_test; + +pub mod a { + pub fn a() { + ::cgu_test::id(0); + } +} +pub mod b { + pub fn a() { + ::cgu_test::id(0); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/cgu_test_b.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/cgu_test_b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/cgu_test_b.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/cgu_test_b.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic +// compile-flags: -Ccodegen-units=2 --crate-type=lib + +extern crate cgu_test; + +pub mod a { + pub fn a() { + ::cgu_test::id(0); + } +} +pub mod b { + pub fn a() { + ::cgu_test::id(0); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/cgu_test.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/cgu_test.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/cgu_test.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/cgu_test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic +// compile-flags: --crate-type=lib + +pub fn id(t: T) -> T { + t +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/i8.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/i8.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/i8.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/i8.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// A crate named after a built-in type. + +pub struct Test; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/iss.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/iss.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/iss.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/iss.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="issue6919_3"] + +// part of issue-6919.rs + +pub struct C where K: FnOnce() { + pub k: K, +} + +fn no_op() { } +pub const D : C = C { + k: no_op as fn() +}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-10028.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-10028.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-10028.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-10028.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct ZeroLengthThingWithDestructor; +impl Drop for ZeroLengthThingWithDestructor { + fn drop(&mut self) {} +} +impl ZeroLengthThingWithDestructor { + pub fn new() -> ZeroLengthThingWithDestructor { + ZeroLengthThingWithDestructor + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_10031_aux.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_10031_aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_10031_aux.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_10031_aux.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Wrap(pub A); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11224.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11224.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11224.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11224.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(dead_code)] + +mod inner { + pub trait Trait { + fn f(&self) { f(); } + } + + impl Trait for isize {} + + fn f() {} +} + +pub fn foo() { + let a = &1isize as &inner::Trait; + a.f(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11225-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11225-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11225-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11225-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod inner { + pub trait Trait { + fn f(&self) { f(); } + fn f_ufcs(&self) { f_ufcs(); } + } + + impl Trait for isize {} + + fn f() {} + fn f_ufcs() {} +} + +pub fn foo(t: T) { + t.f(); +} +pub fn foo_ufcs(t: T) { + T::f_ufcs(&t); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11225-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11225-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11225-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11225-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use inner::Trait; + +mod inner { + pub struct Foo; + pub trait Trait { + fn f(&self); + fn f_ufcs(&self); + } + + impl Trait for Foo { + fn f(&self) { } + fn f_ufcs(&self) { } + } +} + +pub trait Outer { + fn foo(&self, t: T) { t.f(); } + fn foo_ufcs(&self, t: T) { T::f(&t); } +} + +impl Outer for isize {} + +pub fn foo(t: T) { + t.foo(inner::Foo); +} +pub fn foo_ufcs(t: T) { + T::foo_ufcs(&t, inner::Foo) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11225-3.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11225-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11225-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11225-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait PrivateTrait { + fn private_trait_method(&self); + fn private_trait_method_ufcs(&self); +} + +struct PrivateStruct; + +impl PrivateStruct { + fn private_inherent_method(&self) { } + fn private_inherent_method_ufcs(&self) { } +} + +impl PrivateTrait for PrivateStruct { + fn private_trait_method(&self) { } + fn private_trait_method_ufcs(&self) { } +} + +#[inline] +pub fn public_inlinable_function() { + PrivateStruct.private_trait_method(); + PrivateStruct.private_inherent_method(); +} + +#[inline] +pub fn public_inlinable_function_ufcs() { + PrivateStruct::private_trait_method(&PrivateStruct); + PrivateStruct::private_inherent_method(&PrivateStruct); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11508.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11508.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11508.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11508.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Closed01(pub F); + +pub trait Bar { fn new() -> Self; } + +impl Bar for Closed01 { + fn new() -> Closed01 { Closed01(Bar::new()) } +} +impl Bar for f32 { fn new() -> f32 { 1.0 } } + +pub fn random() -> T { Bar::new() } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11529.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11529.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11529.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-11529.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct A<'a>(pub &'a isize); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-12133-dylib2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-12133-dylib2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-12133-dylib2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-12133-dylib2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "dylib"] + +extern crate issue_12133_rlib as a; +extern crate issue_12133_dylib as b; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-12133-dylib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-12133-dylib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-12133-dylib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-12133-dylib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-12133-rlib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-12133-rlib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-12133-rlib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-12133-rlib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "rlib"] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_12612_1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_12612_1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_12612_1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_12612_1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod bar { + pub fn foo() {} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_12612_2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_12612_2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_12612_2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_12612_2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn baz() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-12660-aux.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-12660-aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-12660-aux.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-12660-aux.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] +#![crate_name="issue12660aux"] + +pub use my_mod::{MyStruct, my_fn}; + +mod my_mod { + pub struct MyStruct; + + pub fn my_fn(my_struct: MyStruct) { + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue13507.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue13507.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue13507.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue13507.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,97 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod testtypes { + use std::any::TypeId; + + pub fn type_ids() -> Vec { + vec![ + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::() + ] + } + + // Tests Bool + pub type FooBool = bool; + + // Tests Char + pub type FooChar = char; + + // Tests Int (does not test all variants of IntTy) + pub type FooInt = isize; + + // Tests Uint (does not test all variants of UintTy) + pub type FooUint = usize; + + // Tests Float (does not test all variants of FloatTy) + pub type FooFloat = f64; + + // Tests Str + pub type FooStr = str; + + // Tests Array + pub type FooArray = [u8; 1]; + + // Tests Slice + pub type FooSlice = [u8]; + + // Tests Box (of u8) + pub type FooBox = Box; + + // Tests RawPtr + pub type FooPtr = *const u8; + + // Tests Ref + pub type FooRef = &'static u8; + + // Tests FnPtr + pub type FooFnPtr = fn(u8) -> bool; + + // Tests Dynamic + pub trait FooTrait { + fn foo_method(&self) -> usize; + } + + // Tests struct + pub struct FooStruct { + pub pub_foo_field: usize, + foo_field: usize + } + + // Tests enum + pub enum FooEnum { + VarA(usize), + VarB(usize, usize) + } + + // Tests Tuple + pub type FooNil = (); + pub type FooTuple = (u8, i8, bool); + + // Skipping Param + + // Skipping Infer + + // Skipping Error +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-13620-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-13620-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-13620-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-13620-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Foo { + pub foo: extern fn() +} + +extern fn the_foo() {} + +pub const FOO: Foo = Foo { + foo: the_foo +}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-13620-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-13620-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-13620-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-13620-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate issue_13620_1 as crate1; + +pub static FOO2: crate1::Foo = crate1::FOO; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-13872-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-13872-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-13872-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-13872-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub enum A { B } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-13872-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-13872-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-13872-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-13872-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate issue_13872_1 as foo; + +pub use foo::A::B; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-13872-3.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-13872-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-13872-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-13872-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate issue_13872_2 as bar; + +use bar::B; + +pub fn foo() { + match B { + B => {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-14344-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-14344-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-14344-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-14344-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "rlib"] + +pub fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-14344-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-14344-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-14344-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-14344-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate issue_14344_1; + +pub fn bar() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-14421.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-14421.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-14421.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-14421.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] +#![deny(warnings)] +#![allow(dead_code)] + +pub use src::aliases::B; +pub use src::hidden_core::make; + +mod src { + pub mod aliases { + use super::hidden_core::A; + pub type B = A; + } + + pub mod hidden_core { + use super::aliases::B; + + pub struct A { t: T } + + pub fn make() -> B { A { t: 1.0 } } + + impl A { + pub fn foo(&mut self) { println!("called foo"); } + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-14422.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-14422.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-14422.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-14422.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] +#![deny(warnings)] + +pub use src::aliases::B; +pub use src::hidden_core::make; + +mod src { + pub mod aliases { + use super::hidden_core::A; + pub type B = A; + } + + pub mod hidden_core { + use super::aliases::B; + + #[derive(Copy, Clone)] + pub struct A; + + pub fn make() -> B { A } + + impl A { + pub fn foo(&mut self) { println!("called foo"); } + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-15562.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-15562.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-15562.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-15562.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +extern { + pub fn transmute(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-16643.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-16643.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-16643.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-16643.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +pub struct TreeBuilder { pub h: H } + +impl TreeBuilder { + pub fn process_token(&mut self) { + match self { + _ => for _y in self.by_ref() {} + } + } +} + +impl Iterator for TreeBuilder { + type Item = H; + + fn next(&mut self) -> Option { + None + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-17662.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-17662.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-17662.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-17662.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +pub trait Foo<'a, T> { + fn foo(&'a self) -> T; +} + +pub fn foo<'a, T>(x: &'a Foo<'a, T>) -> T { + let x: &'a Foo = x; + // ^ the lifetime parameter of Foo is left to be inferred. + x.foo() + // ^ encoding this method call in metadata triggers an ICE. +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-17718-aux.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-17718-aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-17718-aux.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-17718-aux.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::sync::atomic; + +pub const C1: usize = 1; +pub const C2: atomic::AtomicUsize = atomic::AtomicUsize::new(0); +pub const C3: fn() = { fn foo() {} foo }; +pub const C4: usize = C1 * C1 + C1 / C1; +pub const C5: &'static usize = &C4; + +pub static S1: usize = 3; +pub static S2: atomic::AtomicUsize = atomic::AtomicUsize::new(0); + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-18501.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-18501.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-18501.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-18501.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +struct Foo; + +trait Tr { + fn tr(&self); +} + +impl Tr for Foo { + fn tr(&self) {} +} + +fn take_method(f: fn(&T), t: &T) {} + +#[inline] +pub fn pass_method() { + take_method(Tr::tr, &Foo); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-18514.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-18514.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-18514.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-18514.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +pub trait Tr { + fn tr(&self); +} + +pub struct St(pub Vec); + +impl Tr for St { + fn tr(&self) { + match self { + &St(ref v) => { + v.iter(); + } + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-18711.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-18711.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-18711.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-18711.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +pub fn inner(f: F) -> F { + (move || f)() +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-18913-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-18913-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-18913-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-18913-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "rlib"] +#![crate_name = "foo"] + +pub fn foo() -> i32 { 0 } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-18913-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-18913-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-18913-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-18913-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "rlib"] +#![crate_name = "foo"] + +pub fn foo() -> i32 { 1 } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_19293.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_19293.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_19293.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_19293.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Foo (pub isize); +pub enum MyEnum { + Foo(Foo), +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-19340-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-19340-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-19340-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-19340-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub enum Homura { + Madoka { name: String }, +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_20389.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_20389.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_20389.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_20389.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait T { + type C; + fn dummy(&self) { } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue2170lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue2170lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue2170lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue2170lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo(_x: i32) { +} + +pub struct rsrc { + x: i32, +} + +impl Drop for rsrc { + fn drop(&mut self) { + foo(self.x); + } +} + +pub fn rsrc(x: i32) -> rsrc { + rsrc { + x: x + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_2316_a.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_2316_a.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_2316_a.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_2316_a.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum cat { + tabby, calico, tortoiseshell +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_2316_b.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_2316_b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_2316_b.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_2316_b.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_imports)] + +extern crate issue_2316_a; + +pub mod cloth { + use issue_2316_a::*; + + pub enum fabric { + gingham, flannel, calico + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-2380.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-2380.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-2380.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-2380.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="a"] +#![crate_type = "lib"] + +#![feature(box_syntax)] + +pub trait i +{ + fn dummy(&self, t: T) -> T { panic!() } +} + +pub fn f() -> Box+'static> { + impl i for () { } + + box () as Box+'static> +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-2414-a.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-2414-a.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-2414-a.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-2414-a.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="a"] +#![crate_type = "lib"] + +type t1 = usize; + +trait foo { + fn foo(&self); +} + +impl foo for String { + fn foo(&self) {} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-2414-b.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-2414-b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-2414-b.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-2414-b.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +#![crate_name="b"] +#![crate_type = "lib"] + +extern crate a; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_2472_b.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_2472_b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_2472_b.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_2472_b.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +pub struct S(pub ()); + +impl S { + pub fn foo(&self) { } +} + +pub trait T { + fn bar(&self); +} + +impl T for S { + fn bar(&self) { } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-25185-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-25185-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-25185-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-25185-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "rlib"] + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + pub fn rust_dbg_extern_identity_u32(u: u32) -> u32; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-25185-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-25185-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-25185-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-25185-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate issue_25185_1; + +pub use issue_25185_1::rust_dbg_extern_identity_u32; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-2526.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-2526.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-2526.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-2526.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,54 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="issue_2526"] +#![crate_type = "lib"] + +use std::marker; + +pub struct arc_destruct { + _data: isize, + _marker: marker::PhantomData +} + +impl Drop for arc_destruct { + fn drop(&mut self) {} +} + +fn arc_destruct(data: isize) -> arc_destruct { + arc_destruct { + _data: data, + _marker: marker::PhantomData + } +} + +fn arc(_data: T) -> arc_destruct { + arc_destruct(0) +} + +fn init() -> arc_destruct { + arc(context_res()) +} + +pub struct context_res { + ctx : isize, +} + +impl Drop for context_res { + fn drop(&mut self) {} +} + +fn context_res() -> context_res { + context_res { + ctx: 0 + } +} + +pub type context = arc_destruct; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-25467.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-25467.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-25467.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-25467.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] + +pub trait Trait { + // the issue is sensitive to interning order - so use names + // unlikely to appear in libstd. + type Issue25467FooT; + type Issue25467BarT; +} + +pub type Object = Option>>; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-2631-a.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-2631-a.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-2631-a.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-2631-a.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="req"] +#![crate_type = "lib"] + +use std::cell::RefCell; +use std::collections::HashMap; +use std::rc::Rc; + +pub type header_map = HashMap>>>>; + +// the unused ty param is necessary so this gets monomorphized +pub fn request(req: &header_map) { + let data = req[&"METHOD".to_string()].clone(); + let _x = data.borrow().clone()[0].clone(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_2723_a.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_2723_a.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_2723_a.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_2723_a.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +pub unsafe fn f(xs: Vec ) { + xs.iter().map(|_x| { unsafe fn q() { panic!(); } }).collect::>(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-29485.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-29485.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-29485.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-29485.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="a"] +#![crate_type = "lib"] + +pub struct X(pub u8); + +impl Drop for X { + fn drop(&mut self) { + assert_eq!(self.0, 1) + } +} + +pub fn f(x: &mut X, g: fn()) { + x.0 = 1; + g(); + x.0 = 0; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-3012-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-3012-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-3012-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-3012-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="socketlib"] +#![crate_type = "lib"] + +pub mod socket { + pub struct socket_handle { + sockfd: u32, + } + + impl Drop for socket_handle { + fn drop(&mut self) { + /* c::close(self.sockfd); */ + } + } + + pub fn socket_handle(x: u32) -> socket_handle { + socket_handle { + sockfd: x + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_3136_a.rc rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_3136_a.rc --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_3136_a.rc 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_3136_a.rc 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +pub mod issue_3136_a; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_3136_a.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_3136_a.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_3136_a.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_3136_a.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait x { + fn use_x(&self); +} +struct y(()); +impl x for y { + fn use_x(&self) { + struct foo { //~ ERROR quux + i: () + } + fn new_foo(i: ()) -> foo { + foo { i: i } + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue34796aux.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue34796aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue34796aux.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue34796aux.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +pub trait Future { + type Item; + type Error; +} + +impl Future for u32 { + type Item = (); + type Error = Box<()>; +} + +fn foo() -> Box>> { + Box::new(0u32) +} + +pub fn bar(_s: F) + where F: Fn(A) -> B, +{ + foo(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-36954.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-36954.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-36954.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-36954.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +const fn foo(i: i32) -> i32 { + i +} + +pub const FOO: i32 = foo(1); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_38190.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_38190.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_38190.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_38190.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[macro_export] +macro_rules! m { ([$i:item]) => {} } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_38226_aux.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_38226_aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_38226_aux.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_38226_aux.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="rlib"] + +#[inline(never)] +pub fn foo() { + let _: Box = Box::new(SomeTraitImpl); +} + +pub fn bar() { + SomeTraitImpl.bar(); +} + +mod submod { + pub trait SomeTrait { + fn bar(&self) { + panic!("NO") + } + } +} + +use self::submod::SomeTrait; + +pub struct SomeTraitImpl; +impl SomeTrait for SomeTraitImpl {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_38715-modern.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_38715-modern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_38715-modern.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_38715-modern.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(duplicate_macro_exports)] + +#[macro_export] +macro_rules! foo_modern { ($i:ident) => {} } + +#[macro_export] +macro_rules! foo_modern { () => {} } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_38715.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_38715.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_38715.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_38715.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(duplicate_macro_exports)] + +#[macro_export] +macro_rules! foo { ($i:ident) => {} } + +#[macro_export] +macro_rules! foo { () => {} } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_3979_traits.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_3979_traits.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_3979_traits.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_3979_traits.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="issue_3979_traits"] + +#![crate_type = "lib"] + +pub trait Positioned { + fn SetX(&mut self, _: isize); + fn X(&self) -> isize; +} + +pub trait Movable: Positioned { + fn translate(&mut self, dx: isize) { + let x = self.X() + dx; + self.SetX(x); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_39823.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_39823.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_39823.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_39823.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="rlib"] + +#[derive(Debug, PartialEq)] +pub struct RemoteC(pub u32); + +#[derive(Debug, PartialEq)] +pub struct RemoteG(pub T); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_40469.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_40469.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_40469.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_40469.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! m { () => { $crate::main(); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_41053.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_41053.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_41053.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_41053.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Test; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-41394.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-41394.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-41394.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-41394.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +#[repr(u32)] +pub enum Foo { + Foo = Private::Variant as u32 +} + +#[repr(u8)] +enum Private { + Variant = 42 +} + +#[inline(always)] +pub fn foo() -> Foo { + Foo::Foo +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_42007_s.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_42007_s.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_42007_s.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_42007_s.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[repr(u8)] +pub enum E { + B = 1 as u8, +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-4208-cc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-4208-cc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-4208-cc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-4208-cc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="numeric"] +#![crate_type = "lib"] + +pub trait Trig { + fn sin(&self) -> T; +} + +pub fn sin, R>(theta: &T) -> R { theta.sin() } + +pub trait Angle: Trig {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-4545.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-4545.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-4545.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-4545.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct S(Option); +pub fn mk() -> S { S(None) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-48984-aux.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-48984-aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-48984-aux.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-48984-aux.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +#![crate_name = "issue48984aux"] + +pub trait Foo { type Item; } + +pub trait Bar: Foo { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-5518.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-5518.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-5518.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-5518.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait A<'a, T> { + fn f(&mut self) -> &'a mut T; + fn p() -> T; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-5521.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-5521.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-5521.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-5521.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +use std::collections::HashMap; + +pub type map = Box>; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-7178.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-7178.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-7178.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-7178.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Foo<'a, A:'a>(&'a A); + +impl<'a, A> Foo<'a, A> { + pub fn new(a: &'a A) -> Foo<'a, A> { + Foo(a) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-7899.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-7899.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-7899.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-7899.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct V2(pub T, pub T); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-8044.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-8044.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-8044.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-8044.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct BTree { + pub node: TreeItem, +} + +pub enum TreeItem { + TreeLeaf { value: V }, +} + +pub fn leaf(value: V) -> TreeItem { + TreeItem::TreeLeaf { value: value } +} + +fn main() { + BTree:: { node: leaf(1) }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-8259.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-8259.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-8259.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-8259.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +pub enum Foo<'a> { + A, + B(&'a str), +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_8401.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_8401.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_8401.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_8401.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// for this issue, this code must be built in a library + +use std::mem; + +trait A { + fn dummy(&self) { } +} +struct B; +impl A for B {} + +fn bar(_: &mut A, _: &T) {} + +fn foo(t: &T) { + let mut b = B; + bar(&mut b as &mut A, t) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_9123.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_9123.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_9123.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_9123.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +pub trait X { + fn x() { + fn f() { } + f(); + } + fn dummy(&self) { } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_9155.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_9155.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_9155.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_9155.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Foo(T); + +impl Foo { + pub fn new(t: T) -> Foo { + Foo(t) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_9188.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_9188.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_9188.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue_9188.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() -> &'static isize { + if false { + static a: isize = 4; + return &a; + } else { + static a: isize = 5; + return &a; + } +} + +pub fn bar() -> &'static isize { + foo::() +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-9906.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-9906.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-9906.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-9906.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub use other::FooBar; +pub use other::foo; + +mod other { + pub struct FooBar{value: isize} + impl FooBar{ + pub fn new(val: isize) -> FooBar { + FooBar{value: val} + } + } + + pub fn foo(){ + 1+1; + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-9968.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-9968.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-9968.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/auxiliary/issue-9968.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub use internal::core::{Trait, Struct}; + +mod internal { + pub mod core { + pub struct Struct; + impl Struct { + pub fn init() -> Struct { + Struct + } + } + + pub trait Trait { + fn test(&self) { + private(); + } + } + + impl Trait for Struct {} + + fn private() { } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10025.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10025.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10025.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10025.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +unsafe extern fn foo() {} +unsafe extern "C" fn bar() {} + +fn main() { + let _a: unsafe extern fn() = foo; + let _a: unsafe extern "C" fn() = foo; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10028.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10028.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10028.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10028.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// aux-build:issue-10028.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_10028 as issue10028; + +use issue10028::ZeroLengthThingWithDestructor; + +struct Foo { + zero_length_thing: ZeroLengthThingWithDestructor +} + +fn make_foo() -> Foo { + Foo { zero_length_thing: ZeroLengthThingWithDestructor::new() } +} + +fn main() { + let _f:Foo = make_foo(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10031.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10031.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10031.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10031.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue_10031_aux.rs +// pretty-expanded FIXME #23616 + +extern crate issue_10031_aux; + +pub fn main() { + let _ = issue_10031_aux::Wrap(()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10228.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10228.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10228.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10228.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// pretty-expanded FIXME #23616 + +enum StdioContainer { + CreatePipe(bool) +} + +struct Test<'a> { + args: &'a [String], + io: &'a [StdioContainer] +} + +pub fn main() { + let test = Test { + args: &[], + io: &[StdioContainer::CreatePipe(true)] + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10392.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10392.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10392.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10392.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] + +struct A { foo: isize } +struct B { a: isize, b: isize, c: isize } + +fn mka() -> A { panic!() } +fn mkb() -> B { panic!() } + +fn test() { + let A { foo, } = mka(); + let A { + foo, + } = mka(); + + let B { a, b, c, } = mkb(); + + match mka() { + A { foo: _foo, } => {} + } + + match Some(mka()) { + Some(A { foo: _foo, }) => {} + None => {} + } +} + +pub fn main() { + if false { test() } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10436.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10436.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10436.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10436.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn works(x: T) -> Vec { vec![x] } + +fn also_works(x: T) -> Vec { vec![x] } + +fn main() { + let _: Vec = works(0); + let _: Vec = also_works(0); + let _ = works(0); + let _ = also_works(0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10626.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10626.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10626.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10626.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-cloudabi no processes +// ignore-emscripten no processes + +// Make sure that if a process doesn't have its stdio/stderr descriptors set up +// that we don't die in a large ball of fire + +use std::env; +use std::process::{Command, Stdio}; + +pub fn main () { + let args: Vec = env::args().collect(); + if args.len() > 1 && args[1] == "child" { + for _ in 0..1000 { + println!("hello?"); + } + for _ in 0..1000 { + println!("hello?"); + } + return; + } + + let mut p = Command::new(&args[0]); + p.arg("child").stdout(Stdio::null()).stderr(Stdio::null()); + println!("{:?}", p.spawn().unwrap().wait()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10638.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10638.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10638.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10638.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +pub fn main() { + //// I am not a doc comment! + ////////////////// still not a doc comment + /////**** nope, me neither */ + /*** And neither am I! */ + 5; + /*****! certainly not I */ +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10682.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10682.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10682.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10682.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for issue #10682 +// Nested `proc` usage can't use outer owned data + +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + +fn work(_: Box) {} +fn foo(_: F) {} + +pub fn main() { + let a = box 1; + foo(move|| { foo(move|| { work(a) }) }) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10683.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10683.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10683.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10683.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +static NAME: &'static str = "hello world"; + +fn main() { + match &*NAME.to_ascii_lowercase() { + "foo" => {} + _ => {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10718.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10718.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10718.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10718.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +fn f(p: F) { + p(); +} + +pub fn main() { + let p = || (); + f(p); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10734.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10734.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10734.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10734.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_upper_case_globals)] + +static mut drop_count: usize = 0; + +struct Foo { + dropped: bool +} + +impl Drop for Foo { + fn drop(&mut self) { + // Test to make sure we haven't dropped already + assert!(!self.dropped); + self.dropped = true; + // And record the fact that we dropped for verification later + unsafe { drop_count += 1; } + } +} + +pub fn main() { + // An `if true { expr }` statement should compile the same as `{ expr }`. + if true { + let _a = Foo{ dropped: false }; + } + // Check that we dropped already (as expected from a `{ expr }`). + unsafe { assert_eq!(drop_count, 1); } + + // An `if false {} else { expr }` statement should compile the same as `{ expr }`. + if false { + panic!(); + } else { + let _a = Foo{ dropped: false }; + } + // Check that we dropped already (as expected from a `{ expr }`). + unsafe { assert_eq!(drop_count, 2); } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10764.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10764.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10764.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10764.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +extern "Rust" fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10767.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10767.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10767.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10767.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + +pub fn main() { + fn f() { + }; + let _: Box = box (f as fn()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10802.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10802.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10802.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10802.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,56 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![feature(box_syntax)] + +struct DroppableStruct; +enum DroppableEnum { + DroppableVariant1, DroppableVariant2 +} + +static mut DROPPED: bool = false; + +impl Drop for DroppableStruct { + fn drop(&mut self) { + unsafe { DROPPED = true; } + } +} +impl Drop for DroppableEnum { + fn drop(&mut self) { + unsafe { DROPPED = true; } + } +} + +trait MyTrait { fn dummy(&self) { } } +impl MyTrait for Box {} +impl MyTrait for Box {} + +struct Whatever { w: Box } +impl Whatever { + fn new(w: Box) -> Whatever { + Whatever { w: w } + } +} + +fn main() { + { + let f: Box<_> = box DroppableStruct; + let _a = Whatever::new(box f as Box); + } + assert!(unsafe { DROPPED }); + unsafe { DROPPED = false; } + { + let f: Box<_> = box DroppableEnum::DroppableVariant1; + let _a = Whatever::new(box f as Box); + } + assert!(unsafe { DROPPED }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10806.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10806.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-10806.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-10806.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,48 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] + +// pretty-expanded FIXME #23616 + +pub fn foo() -> isize { + 3 +} +pub fn bar() -> isize { + 4 +} + +pub mod baz { + use {foo, bar}; + pub fn quux() -> isize { + foo() + bar() + } +} + +pub mod grault { + use {foo}; + pub fn garply() -> isize { + foo() + } +} + +pub mod waldo { + use {}; + pub fn plugh() -> isize { + 0 + } +} + +pub fn main() { + let _x = baz::quux(); + let _y = grault::garply(); + let _z = waldo::plugh(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11047.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11047.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11047.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11047.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that static methods can be invoked on `type` aliases + +#![allow(unused_variables)] + +pub mod foo { + pub mod bar { + pub mod baz { + pub struct Qux; + + impl Qux { + pub fn new() {} + } + } + } +} + +fn main() { + + type Ham = foo::bar::baz::Qux; + let foo = foo::bar::baz::Qux::new(); // invoke directly + let bar = Ham::new(); // invoke via type alias + + type StringVec = Vec; + let sv = StringVec::new(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11085.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11085.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11085.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11085.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,56 @@ +// Copyright 2012-2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// compile-flags: --cfg foo + +// pretty-expanded FIXME #23616 + +struct Foo { + #[cfg(fail)] + bar: baz, + foo: isize, +} + +struct Foo2 { + #[cfg(foo)] + foo: isize, +} + +enum Bar1 { + Bar1_1, + #[cfg(fail)] + Bar1_2(NotAType), +} + +enum Bar2 { + #[cfg(fail)] + Bar2_1(NotAType), +} + +enum Bar3 { + Bar3_1 { + #[cfg(fail)] + foo: isize, + bar: isize, + } +} + +pub fn main() { + let _f = Foo { foo: 3 }; + let _f = Foo2 { foo: 3 }; + + match Bar1::Bar1_1 { + Bar1::Bar1_1 => {} + } + + let _f = Bar3::Bar3_1 { bar: 3 }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-1112.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-1112.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-1112.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-1112.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Issue #1112 +// Alignment of interior pointers to dynamic-size types + + +struct X { + a: T, + b: u8, + c: bool, + d: u8, + e: u16, + f: u8, + g: u8 +} + +pub fn main() { + let x: X = X { + a: 12345678, + b: 9, + c: true, + d: 10, + e: 11, + f: 12, + g: 13 + }; + bar(x); +} + +fn bar(x: X) { + assert_eq!(x.b, 9); + assert_eq!(x.c, true); + assert_eq!(x.d, 10); + assert_eq!(x.e, 11); + assert_eq!(x.f, 12); + assert_eq!(x.g, 13); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11205.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11205.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11205.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11205.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,95 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#![allow(dead_code)] + +trait Foo { fn dummy(&self) { } } +impl Foo for isize {} +fn foo(_: [&Foo; 2]) {} +fn foos(_: &[&Foo]) {} +fn foog(_: &[T], _: &[T]) {} + +fn bar(_: [Box; 2]) {} +fn bars(_: &[Box]) {} + +fn main() { + let x: [&Foo; 2] = [&1, &2]; + foo(x); + foo([&1, &2]); + + let r = &1; + let x: [&Foo; 2] = [r; 2]; + foo(x); + foo([&1; 2]); + + let x: &[&Foo] = &[&1, &2]; + foos(x); + foos(&[&1, &2]); + + let x: &[&Foo] = &[&1, &2]; + let r = &1; + foog(x, &[r]); + + let x: [Box; 2] = [Box::new(1), Box::new(2)]; + bar(x); + bar([Box::new(1), Box::new(2)]); + + let x: &[Box] = &[Box::new(1), Box::new(2)]; + bars(x); + bars(&[Box::new(1), Box::new(2)]); + + let x: &[Box] = &[Box::new(1), Box::new(2)]; + foog(x, &[Box::new(1)]); + + struct T<'a> { + t: [&'a (Foo+'a); 2] + } + let _n = T { + t: [&1, &2] + }; + let r = &1; + let _n = T { + t: [r; 2] + }; + let x: [&Foo; 2] = [&1, &2]; + let _n = T { + t: x + }; + + struct F<'b> { + t: &'b [&'b (Foo+'b)] + } + let _n = F { + t: &[&1, &2] + }; + let r = &1; + let r: [&Foo; 2] = [r; 2]; + let _n = F { + t: &r + }; + let x: [&Foo; 2] = [&1, &2]; + let _n = F { + t: &x + }; + + struct M<'a> { + t: &'a [Box] + } + let _n = M { + t: &[Box::new(1), Box::new(2)] + }; + let x: [Box; 2] = [Box::new(1), Box::new(2)]; + let _n = M { + t: &x + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11224.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11224.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11224.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11224.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-11224.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_11224 as unused; + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11225-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11225-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11225-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11225-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-11225-1.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_11225_1 as foo; + +pub fn main() { + foo::foo(1); + foo::foo_ufcs(1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11225-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11225-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11225-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11225-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-11225-2.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_11225_2 as foo; + +pub fn main() { + foo::foo(1); + foo::foo_ufcs(1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11225-3.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11225-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11225-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11225-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-11225-3.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_11225_3; + +pub fn main() { + issue_11225_3::public_inlinable_function(); + issue_11225_3::public_inlinable_function_ufcs(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11267.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11267.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11267.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11267.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests that unary structs can be mutably borrowed. + +struct Empty; + +trait T { + fn next(&mut self) -> Option; +} +impl T for Empty { + fn next(&mut self) -> Option { None } +} + +fn do_something_with(a : &mut T) { + println!("{:?}", a.next()) +} + +pub fn main() { + do_something_with(&mut Empty); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11382.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11382.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11382.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11382.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + println!("{}", 1.2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11508.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11508.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11508.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11508.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-11508.rs + +extern crate issue_11508 as rand; + +use rand::{Closed01, random}; + +fn main() { + let Closed01(val) = random::>(); + println!("{}", val); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11529.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11529.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11529.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11529.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-11529.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_11529 as a; + +fn main() { + let one = 1; + let _a = a::A(&one); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11552.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11552.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11552.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11552.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_patterns)] +#![feature(box_syntax)] + +#[derive(Clone)] +enum Noun +{ + Atom(isize), + Cell(Box, Box) +} + +fn fas(n: &Noun) -> Noun +{ + match n { + &Noun::Cell(box Noun::Atom(2), box Noun::Cell(ref a, _)) => (**a).clone(), + _ => panic!("Invalid fas pattern") + } +} + +pub fn main() { + fas(&Noun::Cell(box Noun::Atom(2), box Noun::Cell(box Noun::Atom(2), box Noun::Atom(3)))); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11577.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11577.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11577.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11577.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Destructuring struct variants would ICE where regular structs wouldn't + +enum Foo { + VBar { num: isize } +} + +struct SBar { num: isize } + +pub fn main() { + let vbar = Foo::VBar { num: 1 }; + let Foo::VBar { num } = vbar; + assert_eq!(num, 1); + + let sbar = SBar { num: 2 }; + let SBar { num } = sbar; + assert_eq!(num, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11677.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11677.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11677.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11677.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] + +#![allow(dead_code)] + +// this code used to cause an ICE + +use std::marker; + +trait X { + fn dummy(&self) -> T { panic!() } +} + +struct S {f: Box+'static>, + g: Box+'static>} + +struct F; +impl X for F { +} + +fn main() { + S {f: Box::new(F), g: Box::new(F) }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11709.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11709.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11709.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11709.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,48 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// ignore-pretty issue #37199 + +// Don't panic on blocks without results +// There are several tests in this run-pass that raised +// when this bug was opened. The cases where the compiler +// panics before the fix have a comment. + +struct S {x:()} + +fn test(slot: &mut Option Box>>) -> () { + let a = slot.take(); + let _a = match a { + // `{let .. a(); }` would break + Some(mut a) => { let _a = a(); }, + None => (), + }; +} + +fn not(b: bool) -> bool { + if b { + !b + } else { + // `panic!(...)` would break + panic!("Break the compiler"); + } +} + +pub fn main() { + // {} would break + let _r = {}; + let mut slot = None; + // `{ test(...); }` would break + let _s : S = S{ x: { test(&mut slot); } }; + + let _b = not(true); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11820.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11820.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11820.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11820.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +struct NoClone; + +fn main() { + let rnc = &NoClone; + let rsnc = &Some(NoClone); + + let _: &NoClone = rnc.clone(); + let _: &Option = rsnc.clone(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11940.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11940.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11940.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11940.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +const TEST_STR: &'static str = "abcd"; + +fn main() { + let s = "abcd"; + match s { + TEST_STR => (), + _ => unreachable!() + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11958.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11958.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-11958.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-11958.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![forbid(warnings)] + +// We shouldn't need to rebind a moved upvar as mut if it's already +// marked as mut + +pub fn main() { + let mut x = 1; + let _thunk = Box::new(move|| { x = 2; }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12033.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12033.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12033.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12033.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::cell::RefCell; + +fn main() { + let x = RefCell::new(0); + if *x.borrow() == 0 {} else {} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12133-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12133-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12133-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12133-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-12133-rlib.rs +// aux-build:issue-12133-dylib.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_12133_rlib as a; +extern crate issue_12133_dylib as b; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12133-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12133-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12133-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12133-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-12133-rlib.rs +// aux-build:issue-12133-dylib.rs +// no-prefer-dynamic + +// pretty-expanded FIXME #23616 + +extern crate issue_12133_rlib as a; +extern crate issue_12133_dylib as b; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12133-3.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12133-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12133-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12133-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-12133-rlib.rs +// aux-build:issue-12133-dylib.rs +// aux-build:issue-12133-dylib2.rs +// ignore-cloudabi no dylib support +// ignore-emscripten no dylib support +// ignore-musl + +// pretty-expanded FIXME #23616 + +extern crate issue_12133_dylib2 as other; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12285.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12285.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12285.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12285.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +struct S; + +fn main() { + match Some(&S) { + Some(&S) => {}, + _x => unreachable!() + } + match Some(&S) { + Some(&S) => {}, + None => unreachable!() + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-1257.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-1257.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-1257.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-1257.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +pub fn main () { + let mut line = "".to_string(); + let mut i = 0; + while line != "exit".to_string() { + line = if i == 9 { "exit".to_string() } else { "notexit".to_string() }; + i += 1; + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12582.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12582.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12582.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12582.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + let x = 1; + let y = 2; + + assert_eq!(3, match (x, y) { + (1, 1) => 1, + (2, 2) => 2, + (1..=2, 2) => 3, + _ => 4, + }); + + // nested tuple + assert_eq!(3, match ((x, y),) { + ((1, 1),) => 1, + ((2, 2),) => 2, + ((1..=2, 2),) => 3, + _ => 4, + }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12612.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12612.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12612.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12612.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +// aux-build:issue_12612_1.rs +// aux-build:issue_12612_2.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_12612_1 as foo; +extern crate issue_12612_2 as bar; + +mod test { + use bar::baz; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12660.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12660.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12660.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12660.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-12660-aux.rs + +// pretty-expanded FIXME #23616 + +extern crate issue12660aux; + +use issue12660aux::{my_fn, MyStruct}; + +#[allow(path_statements)] +fn main() { + my_fn(MyStruct); + MyStruct; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12677.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12677.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12677.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12677.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn main() { + let s = "Hello"; + let first = s.bytes(); + let second = first.clone(); + + assert_eq!(first.collect::>(), second.collect::>()) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12699.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12699.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12699.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12699.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-wasm32-bare can't block the thread +#![allow(deprecated)] + +use std::thread; + +fn main() { + thread::sleep_ms(250); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12744.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12744.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12744.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12744.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + fn test() -> Box { Box::new(1) } + println!("{:?}", test()) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12860.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12860.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12860.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12860.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,59 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::collections::HashSet; + +#[derive(Copy, Clone, PartialEq, Eq, Hash)] +struct XYZ { + x: isize, + y: isize, + z: isize +} + +fn main() { + let mut connected = HashSet::new(); + let mut border = HashSet::new(); + + let middle = XYZ{x: 0, y: 0, z: 0}; + border.insert(middle); + + while !border.is_empty() && connected.len() < 10000 { + let choice = *(border.iter().next().unwrap()); + border.remove(&choice); + connected.insert(choice); + + let cxp = XYZ{x: choice.x + 1, y: choice.y, z: choice.z}; + let cxm = XYZ{x: choice.x - 1, y: choice.y, z: choice.z}; + let cyp = XYZ{x: choice.x, y: choice.y + 1, z: choice.z}; + let cym = XYZ{x: choice.x, y: choice.y - 1, z: choice.z}; + let czp = XYZ{x: choice.x, y: choice.y, z: choice.z + 1}; + let czm = XYZ{x: choice.x, y: choice.y, z: choice.z - 1}; + + if !connected.contains(&cxp) { + border.insert(cxp); + } + if !connected.contains(&cxm){ + border.insert(cxm); + } + if !connected.contains(&cyp){ + border.insert(cyp); + } + if !connected.contains(&cym) { + border.insert(cym); + } + if !connected.contains(&czp){ + border.insert(czp); + } + if !connected.contains(&czm) { + border.insert(czm); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12909.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12909.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-12909.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-12909.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// pretty-expanded FIXME #23616 + +use std::collections::HashMap; + +fn copy(&x: &T) -> T { + x +} + +fn main() { + let arr = [(1, 1), (2, 2), (3, 3)]; + + let v1: Vec<&_> = arr.iter().collect(); + let v2: Vec<_> = arr.iter().map(copy).collect(); + + let m1: HashMap<_, _> = arr.iter().map(copy).collect(); + let m2: HashMap = arr.iter().map(copy).collect(); + let m3: HashMap<_, usize> = arr.iter().map(copy).collect(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13027.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13027.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13027.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13027.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,188 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// Tests that match expression handles overlapped literal and range +// properly in the presence of guard function. + +fn val() -> usize { 1 } + +static CONST: usize = 1; + +pub fn main() { + lit_shadow_range(); + range_shadow_lit(); + range_shadow_range(); + multi_pats_shadow_lit(); + multi_pats_shadow_range(); + lit_shadow_multi_pats(); + range_shadow_multi_pats(); + misc(); +} + +fn lit_shadow_range() { + assert_eq!(2, match 1 { + 1 if false => 1, + 1..=2 => 2, + _ => 3 + }); + + let x = 0; + assert_eq!(2, match x+1 { + 0 => 0, + 1 if false => 1, + 1..=2 => 2, + _ => 3 + }); + + assert_eq!(2, match val() { + 1 if false => 1, + 1..=2 => 2, + _ => 3 + }); + + assert_eq!(2, match CONST { + 0 => 0, + 1 if false => 1, + 1..=2 => 2, + _ => 3 + }); + + // value is out of the range of second arm, should match wildcard pattern + assert_eq!(3, match 3 { + 1 if false => 1, + 1..=2 => 2, + _ => 3 + }); +} + +fn range_shadow_lit() { + assert_eq!(2, match 1 { + 1..=2 if false => 1, + 1 => 2, + _ => 3 + }); + + let x = 0; + assert_eq!(2, match x+1 { + 0 => 0, + 1..=2 if false => 1, + 1 => 2, + _ => 3 + }); + + assert_eq!(2, match val() { + 1..=2 if false => 1, + 1 => 2, + _ => 3 + }); + + assert_eq!(2, match CONST { + 0 => 0, + 1..=2 if false => 1, + 1 => 2, + _ => 3 + }); + + // ditto + assert_eq!(3, match 3 { + 1..=2 if false => 1, + 1 => 2, + _ => 3 + }); +} + +fn range_shadow_range() { + assert_eq!(2, match 1 { + 0..=2 if false => 1, + 1..=3 => 2, + _ => 3, + }); + + let x = 0; + assert_eq!(2, match x+1 { + 100 => 0, + 0..=2 if false => 1, + 1..=3 => 2, + _ => 3, + }); + + assert_eq!(2, match val() { + 0..=2 if false => 1, + 1..=3 => 2, + _ => 3, + }); + + assert_eq!(2, match CONST { + 100 => 0, + 0..=2 if false => 1, + 1..=3 => 2, + _ => 3, + }); + + // ditto + assert_eq!(3, match 5 { + 0..=2 if false => 1, + 1..=3 => 2, + _ => 3, + }); +} + +fn multi_pats_shadow_lit() { + assert_eq!(2, match 1 { + 100 => 0, + 0 | 1..=10 if false => 1, + 1 => 2, + _ => 3, + }); +} + +fn multi_pats_shadow_range() { + assert_eq!(2, match 1 { + 100 => 0, + 0 | 1..=10 if false => 1, + 1..=3 => 2, + _ => 3, + }); +} + +fn lit_shadow_multi_pats() { + assert_eq!(2, match 1 { + 100 => 0, + 1 if false => 1, + 0 | 1..=10 => 2, + _ => 3, + }); +} + +fn range_shadow_multi_pats() { + assert_eq!(2, match 1 { + 100 => 0, + 1..=3 if false => 1, + 0 | 1..=10 => 2, + _ => 3, + }); +} + +fn misc() { + enum Foo { + Bar(usize, bool) + } + // This test basically mimics how trace_macros! macro is implemented, + // which is a rare combination of vector patterns, multiple wild-card + // patterns and guard functions. + let r = match [Foo::Bar(0, false)] { + [Foo::Bar(_, pred)] if pred => 1, + [Foo::Bar(_, pred)] if !pred => 2, + _ => 0, + }; + assert_eq!(2, r); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13204.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13204.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13204.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13204.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +// Test that when instantiating trait default methods, typeck handles +// lifetime parameters defined on the method bound correctly. + + +pub trait Foo { + fn bar<'a, I: Iterator>(&self, it: I) -> usize { + let mut xs = it.filter(|_| true); + xs.count() + } +} + +pub struct Baz; + +impl Foo for Baz { + // When instantiating `Foo::bar` for `Baz` here, typeck used to + // ICE due to the lifetime parameter of `bar`. +} + +fn main() { + let x = Baz; + let y = vec![(), (), ()]; + assert_eq!(x.bar(y.iter()), 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13259-windows-tcb-trash.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13259-windows-tcb-trash.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13259-windows-tcb-trash.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13259-windows-tcb-trash.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,52 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(libc)] + +extern crate libc; + +#[cfg(windows)] +mod imp { + type LPVOID = *mut u8; + type DWORD = u32; + type LPWSTR = *mut u16; + + extern "system" { + fn FormatMessageW(flags: DWORD, + lpSrc: LPVOID, + msgId: DWORD, + langId: DWORD, + buf: LPWSTR, + nsize: DWORD, + args: *const u8) + -> DWORD; + } + + pub fn test() { + let mut buf: [u16; 50] = [0; 50]; + let ret = unsafe { + FormatMessageW(0x1000, 0 as *mut _, 1, 0x400, + buf.as_mut_ptr(), buf.len() as u32, 0 as *const _) + }; + // On some 32-bit Windowses (Win7-8 at least) this will panic with segmented + // stacks taking control of pvArbitrary + assert!(ret != 0); + } +} + +#[cfg(not(windows))] +mod imp { + pub fn test() { } +} + +fn main() { + imp::test() +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13264.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13264.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13264.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13264.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,84 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] + +use std::ops::Deref; + +struct Root { + jsref: JSRef +} + +impl Deref for Root { + type Target = JSRef; + + fn deref<'a>(&'a self) -> &'a JSRef { + &self.jsref + } +} + +#[derive(Copy, Clone)] +struct JSRef { + node: *const Node +} + +impl Deref for JSRef { + type Target = Node; + + fn deref<'a>(&'a self) -> &'a Node { + self.get() + } +} + +trait INode { + fn RemoveChild(&self); +} + +impl INode for JSRef { + fn RemoveChild(&self) { + self.get().RemoveChild(0) + } +} + +impl JSRef { + fn AddChild(&self) { + self.get().AddChild(0); + } + + fn get<'a>(&'a self) -> &'a Node { + unsafe { + &*self.node + } + } +} + +struct Node; + +impl Node { + fn RemoveChild(&self, _a: usize) { + } + + fn AddChild(&self, _a: usize) { + } +} + +fn main() { + let n = Node; + let jsref = JSRef { node: &n }; + let root = Root { jsref: jsref }; + + root.AddChild(); + jsref.AddChild(); + + root.RemoveChild(); + jsref.RemoveChild(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13304.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13304.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13304.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13304.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,49 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +// ignore-cloudabi no processes +// ignore-emscripten no processes + +use std::env; +use std::io::prelude::*; +use std::io; +use std::process::{Command, Stdio}; +use std::str; + +fn main() { + let args: Vec = env::args().collect(); + if args.len() > 1 && args[1] == "child" { + child(); + } else { + parent(); + } +} + +fn parent() { + let args: Vec = env::args().collect(); + let mut p = Command::new(&args[0]).arg("child") + .stdout(Stdio::piped()) + .stdin(Stdio::piped()) + .spawn().unwrap(); + p.stdin.as_mut().unwrap().write_all(b"test1\ntest2\ntest3").unwrap(); + let out = p.wait_with_output().unwrap(); + assert!(out.status.success()); + let s = str::from_utf8(&out.stdout).unwrap(); + assert_eq!(s, "test1\ntest2\ntest3\n"); +} + +fn child() { + let mut stdin = io::stdin(); + for line in stdin.lock().lines() { + println!("{}", line.unwrap()); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13323.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13323.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13323.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13323.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,69 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +struct StrWrap { + s: String +} + +impl StrWrap { + fn new(s: &str) -> StrWrap { + StrWrap { s: s.to_string() } + } + + fn get_s<'a>(&'a self) -> &'a str { + &self.s + } +} + +struct MyStruct { + s: StrWrap +} + +impl MyStruct { + fn new(s: &str) -> MyStruct { + MyStruct { s: StrWrap::new(s) } + } + + fn get_str_wrap<'a>(&'a self) -> &'a StrWrap { + &self.s + } +} + +trait Matcher { + fn matches(&self, actual: T) -> bool; +} + +fn assert_that>(actual: T, matcher: &U) { + assert!(matcher.matches(actual)); +} + +struct EqualTo { + expected: T +} + +impl Matcher for EqualTo { + fn matches(&self, actual: T) -> bool { + self.expected.eq(&actual) + } +} + +fn equal_to(expected: T) -> Box> { + box EqualTo { expected: expected } +} + +pub fn main() { + let my_struct = MyStruct::new("zomg"); + let s = my_struct.get_str_wrap(); + + assert_that(s.get_s(), &*equal_to("zomg")); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13434.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13434.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13434.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13434.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(Debug)] +struct MyStruct; + +trait Repro { + fn repro(self, s: MyStruct) -> String; +} + +impl Repro for F where F: FnOnce(MyStruct) -> String { + fn repro(self, s: MyStruct) -> String { + self(s) + } +} + +fn do_stuff(r: R) -> String { + r.repro(MyStruct) +} + +pub fn main() { + assert_eq!("MyStruct".to_string(), do_stuff(|s: MyStruct| format!("{:?}", s))); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13494.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13494.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13494.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13494.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// ignore-emscripten no threads support + +// This test may not always fail, but it can be flaky if the race it used to +// expose is still present. + +#![feature(mpsc_select)] + +use std::sync::mpsc::{channel, Sender, Receiver}; +use std::thread; + +fn helper(rx: Receiver>) { + for tx in rx.iter() { + let _ = tx.send(()); + } +} + +fn main() { + let (tx, rx) = channel(); + let t = thread::spawn(move|| { helper(rx) }); + let (snd, rcv) = channel::(); + for _ in 1..100000 { + snd.send(1).unwrap(); + let (tx2, rx2) = channel(); + tx.send(tx2).unwrap(); + select! { + _ = rx2.recv() => (), + _ = rcv.recv() => () + } + } + drop(tx); + t.join(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13507-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13507-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13507-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13507-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +// aux-build:issue13507.rs + +extern crate issue13507; +use issue13507::testtypes; + +use std::any::TypeId; + +pub fn type_ids() -> Vec { + use issue13507::testtypes::*; + vec![ + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::(), + TypeId::of::() + ] +} + +pub fn main() { + let othercrate = issue13507::testtypes::type_ids(); + let thiscrate = type_ids(); + assert_eq!(thiscrate, othercrate); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13620.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13620.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13620.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13620.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-13620-1.rs +// aux-build:issue-13620-2.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_13620_2 as crate2; + +fn main() { + (crate2::FOO2.foo)(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13655.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13655.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13655.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13655.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(fn_traits, unboxed_closures)] +use std::ops::Fn; + +struct Foo(T); + +impl Fn<()> for Foo { + extern "rust-call" fn call(&self, _: ()) -> T { + match *self { + Foo(t) => t + } + } +} + +impl FnMut<()> for Foo { + extern "rust-call" fn call_mut(&mut self, _: ()) -> T { + self.call(()) + } +} + +impl FnOnce<()> for Foo { + type Output = T; + + extern "rust-call" fn call_once(self, _: ()) -> T { + self.call(()) + } +} + +fn main() { + let t: u8 = 1; + println!("{}", Foo(t)()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13665.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13665.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13665.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13665.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +fn foo<'r>() { + let maybe_value_ref: Option<&'r u8> = None; + + let _ = maybe_value_ref.map(|& ref v| v); + let _ = maybe_value_ref.map(|& ref v| -> &'r u8 {v}); + let _ = maybe_value_ref.map(|& ref v: &'r u8| -> &'r u8 {v}); + let _ = maybe_value_ref.map(|& ref v: &'r u8| {v}); +} + +fn main() { + foo(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13763.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13763.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13763.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13763.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +mod u8 { + pub const BITS: usize = 8; +} + +const NUM: usize = u8::BITS; + +struct MyStruct { nums: [usize; 8] } + +fn main() { + let _s = MyStruct { nums: [0; NUM] }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13808.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13808.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13808.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13808.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// pretty-expanded FIXME #23616 + +struct Foo<'a> { + listener: Box, +} + +impl<'a> Foo<'a> { + fn new(listener: F) -> Foo<'a> where F: FnMut() + 'a { + Foo { listener: Box::new(listener) } + } +} + +fn main() { + let a = Foo::new(|| {}); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13867.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13867.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13867.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13867.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,59 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that codegen works correctly when there are multiple refutable +// patterns in match expression. + + +enum Foo { + FooUint(usize), + FooNullary, +} + +fn main() { + let r = match (Foo::FooNullary, 'a') { + (Foo::FooUint(..), 'a'..='z') => 1, + (Foo::FooNullary, 'x') => 2, + _ => 0 + }; + assert_eq!(r, 0); + + let r = match (Foo::FooUint(0), 'a') { + (Foo::FooUint(1), 'a'..='z') => 1, + (Foo::FooUint(..), 'x') => 2, + (Foo::FooNullary, 'a') => 3, + _ => 0 + }; + assert_eq!(r, 0); + + let r = match ('a', Foo::FooUint(0)) { + ('a'..='z', Foo::FooUint(1)) => 1, + ('x', Foo::FooUint(..)) => 2, + ('a', Foo::FooNullary) => 3, + _ => 0 + }; + assert_eq!(r, 0); + + let r = match ('a', 'a') { + ('a'..='z', 'b') => 1, + ('x', 'a'..='z') => 2, + _ => 0 + }; + assert_eq!(r, 0); + + let r = match ('a', 'a') { + ('a'..='z', 'b') => 1, + ('x', 'a'..='z') => 2, + ('a', 'a') => 3, + _ => 0 + }; + assert_eq!(r, 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13872.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13872.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13872.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13872.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-13872-1.rs +// aux-build:issue-13872-2.rs +// aux-build:issue-13872-3.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_13872_3 as other; + +fn main() { + other::foo(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13902.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13902.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-13902.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-13902.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +const JSVAL_TAG_CLEAR: u32 = 0xFFFFFF80; +const JSVAL_TYPE_INT32: u8 = 0x01; +const JSVAL_TYPE_UNDEFINED: u8 = 0x02; +#[repr(u32)] +enum ValueTag { + JSVAL_TAG_INT32 = JSVAL_TAG_CLEAR | (JSVAL_TYPE_INT32 as u32), + JSVAL_TAG_UNDEFINED = JSVAL_TAG_CLEAR | (JSVAL_TYPE_UNDEFINED as u32), +} + +fn main() { + let _ = ValueTag::JSVAL_TAG_INT32; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14229.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14229.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14229.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14229.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait Foo: Sized { + fn foo(self) {} +} + +trait Bar: Sized { + fn bar(self) {} +} + +struct S; + +impl<'l> Foo for &'l S {} + +impl Bar for T {} + +fn main() { + let s = S; + s.foo(); + (&s).bar(); + s.bar(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14308.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14308.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14308.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14308.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +struct A(isize); + +fn main() { + let x = match A(3) { + A(..) => 1 + }; + assert_eq!(x, 1); + let x = match A(4) { + A(1) => 1, + A(..) => 2 + }; + assert_eq!(x, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14344.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14344.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14344.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14344.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-14344-1.rs +// aux-build:issue-14344-2.rs + +extern crate issue_14344_1; +extern crate issue_14344_2; + +fn main() { + issue_14344_1::foo(); + issue_14344_2::bar(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14382.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14382.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14382.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14382.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(Debug)] +struct Matrix4(S); +trait POrd {} + +fn translate>(s: S) -> Matrix4 { Matrix4(s) } + +impl POrd for f32 {} +impl POrd for f64 {} + +fn main() { + let x = 1.0; + let m : Matrix4 = translate(x); + println!("m: {:?}", m); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14393.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14393.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14393.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14393.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +fn main() { + match ("", 1_usize) { + (_, 42_usize) => (), + ("", _) => (), + _ => () + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14399.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14399.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14399.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14399.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// #14399 +// We'd previously ICE if we had a method call whose return +// value was coerced to a trait object. (v.clone() returns Box +// which is coerced to Box). + +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + +#[derive(Clone)] +struct B1; + +trait A { fn foo(&self) {} } +impl A for B1 {} + +fn main() { + let v: Box<_> = box B1; + let _c: Box = v.clone(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14421.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14421.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14421.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14421.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_snake_case)] + +// aux-build:issue-14421.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_14421 as bug_lib; + +use bug_lib::B; +use bug_lib::make; + +pub fn main() { + let mut an_A: B = make(); + an_A.foo(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14422.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14422.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14422.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14422.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_snake_case)] + +// aux-build:issue-14422.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_14422 as bug_lib; + +use bug_lib::B; +use bug_lib::make; + +pub fn main() { + let mut an_A: B = make(); + an_A.foo(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14456.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14456.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14456.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14456.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +// ignore-cloudabi no processes +// ignore-emscripten no processes + +use std::env; +use std::io::prelude::*; +use std::io; +use std::process::{Command, Stdio}; + +fn main() { + let args: Vec = env::args().collect(); + if args.len() > 1 && args[1] == "child" { + return child() + } + + test(); +} + +fn child() { + writeln!(&mut io::stdout(), "foo").unwrap(); + writeln!(&mut io::stderr(), "bar").unwrap(); + let mut stdin = io::stdin(); + let mut s = String::new(); + stdin.lock().read_line(&mut s).unwrap(); + assert_eq!(s.len(), 0); +} + +fn test() { + let args: Vec = env::args().collect(); + let mut p = Command::new(&args[0]).arg("child") + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn().unwrap(); + assert!(p.wait().unwrap().success()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-1451.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-1451.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-1451.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-1451.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 +#![allow(non_snake_case)] +#![allow(unused_variables)] + +struct T { f: extern "Rust" fn() } +struct S { f: extern "Rust" fn() } + +fn fooS(t: S) { +} + +fn fooT(t: T) { +} + +fn bar() { +} + +pub fn main() { + let x: extern "Rust" fn() = bar; + fooS(S {f: x}); + fooS(S {f: bar}); + + let x: extern "Rust" fn() = bar; + fooT(T {f: x}); + fooT(T {f: bar}); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14589.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14589.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14589.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14589.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// All 3 expressions should work in that the argument gets +// coerced to a trait object + +// pretty-expanded FIXME #23616 + +fn main() { + send::>(Box::new(Output(0))); + Test::>::foo(Box::new(Output(0))); + Test::>::new().send(Box::new(Output(0))); +} + +fn send(_: T) {} + +struct Test { marker: std::marker::PhantomData } +impl Test { + fn new() -> Test { Test { marker: ::std::marker::PhantomData } } + fn foo(_: T) {} + fn send(&self, _: T) {} +} + +trait Foo { fn dummy(&self) { }} +struct Output(isize); +impl Foo for Output {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-1460.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-1460.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-1460.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-1460.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// pretty-expanded FIXME #23616 + +pub fn main() { + {|i: u32| if 1 == i { }}; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14821.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14821.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14821.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14821.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +trait SomeTrait {} +struct Meow; +impl SomeTrait for Meow {} + +struct Foo<'a> { + x: &'a SomeTrait, + y: &'a SomeTrait, +} + +impl<'a> Foo<'a> { + pub fn new<'b>(x: &'b SomeTrait, y: &'b SomeTrait) -> Foo<'b> { Foo { x: x, y: y } } +} + +fn main() { + let r = Meow; + let s = Meow; + let q = Foo::new(&r as &SomeTrait, &s as &SomeTrait); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14865.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14865.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14865.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14865.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +enum X { + Foo(usize), + Bar(bool) +} + +fn main() { + let x = match X::Foo(42) { + X::Foo(..) => 1, + _ if true => 0, + X::Bar(..) => panic!("Oh dear") + }; + assert_eq!(x, 1); + + let x = match X::Foo(42) { + _ if true => 0, + X::Foo(..) => 1, + X::Bar(..) => panic!("Oh dear") + }; + assert_eq!(x, 0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14875.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14875.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14875.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14875.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-wasm32-bare always compiled as panic=abort right now + +// Check that values are not leaked when a dtor panics (#14875) + +use std::panic::{self, UnwindSafe}; + +struct SetInnerOnDrop<'a>(&'a mut bool); + +impl<'a> UnwindSafe for SetInnerOnDrop<'a> {} + +impl<'a> Drop for SetInnerOnDrop<'a> { + fn drop(&mut self) { + *self.0 = true; + } +} + +struct PanicOnDrop; +impl Drop for PanicOnDrop { + fn drop(&mut self) { + panic!("test panic"); + } +} + +fn main() { + let mut set_on_drop = false; + { + let set_inner_on_drop = SetInnerOnDrop(&mut set_on_drop); + let _ = panic::catch_unwind(|| { + let _set_inner_on_drop = set_inner_on_drop; + let _panic_on_drop = PanicOnDrop; + }); + } + assert!(set_on_drop); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14919.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14919.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14919.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14919.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,65 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +trait Matcher { + fn next_match(&mut self) -> Option<(usize, usize)>; +} + +struct CharPredMatcher<'a, 'b> { + str: &'a str, + pred: Box bool + 'b>, +} + +impl<'a, 'b> Matcher for CharPredMatcher<'a, 'b> { + fn next_match(&mut self) -> Option<(usize, usize)> { + None + } +} + +trait IntoMatcher<'a, T> { + fn into_matcher(self, _: &'a str) -> T; +} + +impl<'a, 'b, F> IntoMatcher<'a, CharPredMatcher<'a, 'b>> for F where F: FnMut(char) -> bool + 'b { + fn into_matcher(self, s: &'a str) -> CharPredMatcher<'a, 'b> { + CharPredMatcher { + str: s, + pred: Box::new(self), + } + } +} + +struct MatchIndices { + matcher: M +} + +impl Iterator for MatchIndices { + type Item = (usize, usize); + + fn next(&mut self) -> Option<(usize, usize)> { + self.matcher.next_match() + } +} + +fn match_indices<'a, M, T: IntoMatcher<'a, M>>(s: &'a str, from: T) -> MatchIndices { + let string_matcher = from.into_matcher(s); + MatchIndices { matcher: string_matcher } +} + +fn main() { + let s = "abcbdef"; + match_indices(s, |c: char| c == 'b') + .collect::>(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14940.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14940.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14940.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14940.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-cloudabi no processes +// ignore-emscripten no processes + +use std::env; +use std::process::Command; +use std::io::{self, Write}; + +fn main() { + let mut args = env::args(); + if args.len() > 1 { + let mut out = io::stdout(); + out.write(&['a' as u8; 128 * 1024]).unwrap(); + } else { + let out = Command::new(&args.next().unwrap()).arg("child").output(); + let out = out.unwrap(); + assert!(out.status.success()); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14958.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14958.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-14958.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-14958.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#![feature(fn_traits, unboxed_closures)] + +trait Foo { fn dummy(&self) { }} + +struct Bar; + +impl<'a> std::ops::Fn<(&'a (Foo+'a),)> for Bar { + extern "rust-call" fn call(&self, _: (&'a Foo,)) {} +} + +impl<'a> std::ops::FnMut<(&'a (Foo+'a),)> for Bar { + extern "rust-call" fn call_mut(&mut self, a: (&'a Foo,)) { self.call(a) } +} + +impl<'a> std::ops::FnOnce<(&'a (Foo+'a),)> for Bar { + type Output = (); + extern "rust-call" fn call_once(self, a: (&'a Foo,)) { self.call(a) } +} + +struct Baz; + +impl Foo for Baz {} + +fn main() { + let bar = Bar; + let baz = &Baz; + bar(baz); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15043.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15043.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15043.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15043.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#![allow(warnings)] + +struct S(T); + +static s1: S>=S(S(0)); +static s2: S=S(0); + +fn main() { + let foo: S>=S(S(0)); + let foo: S=S(0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15063.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15063.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15063.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15063.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +enum Two { A, B} +impl Drop for Two { + fn drop(&mut self) { + println!("Dropping!"); + } +} +fn main() { + let k = Two::A; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15080.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15080.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15080.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15080.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(slice_patterns)] + +fn main() { + let mut x: &[_] = &[1, 2, 3, 4]; + + let mut result = vec![]; + loop { + x = match *x { + [1, n, 3, ref rest..] => { + result.push(n); + rest + } + [n, ref rest..] => { + result.push(n); + rest + } + [] => + break + } + } + assert_eq!(result, [2, 4]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15104.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15104.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15104.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15104.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(slice_patterns)] + +fn main() { + assert_eq!(count_members(&[1, 2, 3, 4]), 4); +} + +fn count_members(v: &[usize]) -> usize { + match *v { + [] => 0, + [_] => 1, + [_, ref xs..] => 1 + count_members(xs) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15129.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15129.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15129.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15129.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub enum T { + T1(()), + T2(()) +} + +pub enum V { + V1(isize), + V2(bool) +} + +fn foo(x: (T, V)) -> String { + match x { + (T::T1(()), V::V1(i)) => format!("T1(()), V1({})", i), + (T::T2(()), V::V2(b)) => format!("T2(()), V2({})", b), + _ => String::new() + } +} + + +fn main() { + assert_eq!(foo((T::T1(()), V::V1(99))), "T1(()), V1(99)".to_string()); + assert_eq!(foo((T::T2(()), V::V2(true))), "T2(()), V2(true)".to_string()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15155.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15155.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15155.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15155.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait TraitWithSend: Send {} +trait IndirectTraitWithSend: TraitWithSend {} + +// Check struct instantiation (Box will only have Send if TraitWithSend has Send) +#[allow(dead_code)] +struct Blah { x: Box } +impl TraitWithSend for Blah {} + +// Struct instantiation 2-levels deep +#[allow(dead_code)] +struct IndirectBlah { x: Box } +impl TraitWithSend for IndirectBlah {} +impl IndirectTraitWithSend for IndirectBlah {} + +fn test_trait() { println!("got here!") } + +fn main() { + test_trait::(); + test_trait::(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15189.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15189.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15189.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15189.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +macro_rules! third { + ($e:expr) => ({let x = 2; $e[x]}) +} + +fn main() { + let x = vec![10_usize,11_usize,12_usize,13_usize]; + let t = third!(x); + assert_eq!(t,12_usize); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15221.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15221.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15221.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15221.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(path_statements)] +// pretty-expanded FIXME #23616 + +macro_rules! inner { + ($e:pat ) => ($e) +} + +macro_rules! outer { + ($e:pat ) => (inner!($e)) +} + +fn main() { + let outer!(g1) = 13; + g1; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15444.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15444.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15444.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15444.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +trait MyTrait { + fn foo(&self); +} + +impl MyTrait for fn(A, B) -> C { + fn foo(&self) {} +} + +fn bar(t: &T) { + t.foo() +} + +fn thing(a: isize, b: isize) -> isize { + a + b +} + +fn main() { + let thing: fn(isize, isize) -> isize = thing; // coerce to fn type + bar(&thing); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15487.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15487.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15487.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15487.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_attributes)] +// ignore-windows +// ignore-wasm32-bare no libs to link + +#![feature(link_args)] + +#[link_args="-lc -lm"] +#[link_args=" -lc"] +#[link_args="-lc "] +extern {} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15523-big.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15523-big.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15523-big.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15523-big.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,49 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Issue 15523: derive(PartialOrd) should use the provided +// discriminant values for the derived ordering. +// +// This test is checking corner cases that arise when you have +// 64-bit values in the variants. + +#[derive(PartialEq, PartialOrd)] +#[repr(u64)] +enum Eu64 { + Pos2 = 2, + PosMax = !0, + Pos1 = 1, +} + +#[derive(PartialEq, PartialOrd)] +#[repr(i64)] +enum Ei64 { + Pos2 = 2, + Neg1 = -1, + NegMin = 1 << 63, + PosMax = !(1 << 63), + Pos1 = 1, +} + +fn main() { + assert!(Eu64::Pos2 > Eu64::Pos1); + assert!(Eu64::Pos2 < Eu64::PosMax); + assert!(Eu64::Pos1 < Eu64::PosMax); + + + assert!(Ei64::Pos2 > Ei64::Pos1); + assert!(Ei64::Pos2 > Ei64::Neg1); + assert!(Ei64::Pos1 > Ei64::Neg1); + assert!(Ei64::Pos2 > Ei64::NegMin); + assert!(Ei64::Pos1 > Ei64::NegMin); + assert!(Ei64::Pos2 < Ei64::PosMax); + assert!(Ei64::Pos1 < Ei64::PosMax); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15523.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15523.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15523.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15523.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,52 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Issue 15523: derive(PartialOrd) should use the provided +// discriminant values for the derived ordering. +// +// This is checking the basic functionality. + +#[derive(PartialEq, PartialOrd)] +enum E1 { + Pos2 = 2, + Neg1 = -1, + Pos1 = 1, +} + +#[derive(PartialEq, PartialOrd)] +#[repr(u8)] +enum E2 { + Pos2 = 2, + PosMax = !0 as u8, + Pos1 = 1, +} + +#[derive(PartialEq, PartialOrd)] +#[repr(i8)] +enum E3 { + Pos2 = 2, + Neg1 = -1_i8, + Pos1 = 1, +} + +fn main() { + assert!(E1::Pos2 > E1::Pos1); + assert!(E1::Pos1 > E1::Neg1); + assert!(E1::Pos2 > E1::Neg1); + + assert!(E2::Pos2 > E2::Pos1); + assert!(E2::Pos1 < E2::PosMax); + assert!(E2::Pos2 < E2::PosMax); + + assert!(E3::Pos2 > E3::Pos1); + assert!(E3::Pos1 > E3::Neg1); + assert!(E3::Pos2 > E3::Neg1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15562.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15562.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15562.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15562.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-15562.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_15562 as i; + +pub fn main() { + unsafe { + transmute(); + i::transmute(); + } +} + +// We declare this so we don't run into unresolved symbol errors +// The above extern is NOT `extern "rust-intrinsic"` and thus +// means it'll try to find a corresponding symbol to link to. +#[no_mangle] +pub extern fn transmute() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15571.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15571.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15571.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15571.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,68 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +fn match_on_local() { + let mut foo: Option> = Some(box 5); + match foo { + None => {}, + Some(x) => { + foo = Some(x); + } + } + println!("'{}'", foo.unwrap()); +} + +fn match_on_arg(mut foo: Option>) { + match foo { + None => {} + Some(x) => { + foo = Some(x); + } + } + println!("'{}'", foo.unwrap()); +} + +fn match_on_binding() { + match Some(Box::new(7)) { + mut foo => { + match foo { + None => {}, + Some(x) => { + foo = Some(x); + } + } + println!("'{}'", foo.unwrap()); + } + } +} + +fn match_on_upvar() { + let mut foo: Option> = Some(box 8); + let f = move|| { + match foo { + None => {}, + Some(x) => { + foo = Some(x); + } + } + println!("'{}'", foo.unwrap()); + }; + f(); +} + +fn main() { + match_on_local(); + match_on_arg(Some(box 6)); + match_on_binding(); + match_on_upvar(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15673.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15673.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15673.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15673.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(stable_features)] + +#![feature(iter_arith)] + +fn main() { + let x: [u64; 3] = [1, 2, 3]; + assert_eq!(6, (0..3).map(|i| x[i]).sum::()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15689-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15689-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15689-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15689-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#[derive(PartialEq, Debug)] +enum Test<'a> { + Slice(&'a isize) +} + +fn main() { + assert_eq!(Test::Slice(&1), Test::Slice(&1)) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15730.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15730.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15730.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15730.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +#![allow(unused_variables)] +// pretty-expanded FIXME #23616 + +fn main() { + let mut array = [1, 2, 3]; + let pie_slice = &array[1..2]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15734.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15734.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15734.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15734.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,68 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// If `Index` used an associated type for its output, this test would +// work more smoothly. + +use std::ops::Index; + +struct Mat { data: Vec, cols: usize, } + +impl Mat { + fn new(data: Vec, cols: usize) -> Mat { + Mat { data: data, cols: cols } + } + fn row<'a>(&'a self, row: usize) -> Row<&'a Mat> { + Row { mat: self, row: row, } + } +} + +impl Index<(usize, usize)> for Mat { + type Output = T; + + fn index<'a>(&'a self, (row, col): (usize, usize)) -> &'a T { + &self.data[row * self.cols + col] + } +} + +impl<'a, T> Index<(usize, usize)> for &'a Mat { + type Output = T; + + fn index<'b>(&'b self, index: (usize, usize)) -> &'b T { + (*self).index(index) + } +} + +struct Row { mat: M, row: usize, } + +impl> Index for Row { + type Output = T; + + fn index<'a>(&'a self, col: usize) -> &'a T { + &self.mat[(self.row, col)] + } +} + +fn main() { + let m = Mat::new(vec![1, 2, 3, 4, 5, 6], 3); + let r = m.row(1); + + assert_eq!(r.index(2), &6); + assert_eq!(r[2], 6); + assert_eq!(r[2], 6); + assert_eq!(6, r[2]); + + let e = r[2]; + assert_eq!(e, 6); + + let e: usize = r[2]; + assert_eq!(e, 6); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15763.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15763.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15763.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15763.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,99 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unreachable_code)] +#![feature(box_syntax)] + +#[derive(PartialEq, Debug)] +struct Bar { + x: isize +} +impl Drop for Bar { + fn drop(&mut self) { + assert_eq!(self.x, 22); + } +} + +#[derive(PartialEq, Debug)] +struct Foo { + x: Bar, + a: isize +} + +fn foo() -> Result { + return Ok(Foo { + x: Bar { x: 22 }, + a: return Err(32) + }); +} + +fn baz() -> Result { + Ok(Foo { + x: Bar { x: 22 }, + a: return Err(32) + }) +} + +// explicit immediate return +fn aa() -> isize { + return 3; +} + +// implicit immediate return +fn bb() -> isize { + 3 +} + +// implicit outptr return +fn cc() -> Result { + Ok(3) +} + +// explicit outptr return +fn dd() -> Result { + return Ok(3); +} + +trait A { + fn aaa(&self) -> isize { + 3 + } + fn bbb(&self) -> isize { + return 3; + } + fn ccc(&self) -> Result { + Ok(3) + } + fn ddd(&self) -> Result { + return Ok(3); + } +} + +impl A for isize {} + +fn main() { + assert_eq!(foo(), Err(32)); + assert_eq!(baz(), Err(32)); + + assert_eq!(aa(), 3); + assert_eq!(bb(), 3); + assert_eq!(cc().unwrap(), 3); + assert_eq!(dd().unwrap(), 3); + + let i = box 32isize as Box; + assert_eq!(i.aaa(), 3); + let i = box 32isize as Box; + assert_eq!(i.bbb(), 3); + let i = box 32isize as Box; + assert_eq!(i.ccc().unwrap(), 3); + let i = box 32isize as Box; + assert_eq!(i.ddd().unwrap(), 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15774.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15774.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15774.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15774.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#![deny(warnings)] +#![allow(unused_imports)] + +pub enum Foo { A } +mod bar { + pub fn normal(x: ::Foo) { + use Foo::A; + match x { + A => {} + } + } + pub fn wrong(x: ::Foo) { + match x { + ::Foo::A => {} + } + } +} + +pub fn main() { + bar::normal(Foo::A); + bar::wrong(Foo::A); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15793.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15793.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15793.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15793.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +enum NestedEnum { + First, + Second, + Third +} +enum Enum { + Variant1(bool), + Variant2(NestedEnum) +} + +#[inline(never)] +fn foo(x: Enum) -> isize { + match x { + Enum::Variant1(true) => 1, + Enum::Variant1(false) => 2, + Enum::Variant2(NestedEnum::Second) => 3, + Enum::Variant2(NestedEnum::Third) => 4, + Enum::Variant2(NestedEnum::First) => 5 + } +} + +fn main() { + assert_eq!(foo(Enum::Variant2(NestedEnum::Third)), 4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15858.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15858.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15858.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15858.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +static mut DROP_RAN: bool = false; + +trait Bar { + fn do_something(&mut self); +} + +struct BarImpl; + +impl Bar for BarImpl { + fn do_something(&mut self) {} +} + + +struct Foo(B); + +impl Drop for Foo { + fn drop(&mut self) { + unsafe { + DROP_RAN = true; + } + } +} + + +fn main() { + { + let _x: Foo = Foo(BarImpl); + } + unsafe { + assert_eq!(DROP_RAN, true); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15881-model-lexer-dotdotdot.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15881-model-lexer-dotdotdot.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-15881-model-lexer-dotdotdot.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-15881-model-lexer-dotdotdot.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(illegal_floating_point_literal_pattern)] // FIXME #41620 + +// regression test for the model lexer handling the DOTDOTDOT syntax (#15877) + + +pub fn main() { + match 5_usize { + 1_usize...5_usize => {} + _ => panic!("should match range"), + } + match 5_usize { + 6_usize...7_usize => panic!("shouldn't match range"), + _ => {} + } + match 5_usize { + 1_usize => panic!("should match non-first range"), + 2_usize...6_usize => {} + _ => panic!("math is broken") + } + match 'c' { + 'a'...'z' => {} + _ => panic!("should support char ranges") + } + match -3_isize { + -7...5 => {} + _ => panic!("should match signed range") + } + match 3.0f64 { + 1.0...5.0 => {} + _ => panic!("should match float range") + } + match -1.5f64 { + -3.6...3.6 => {} + _ => panic!("should match negative float range") + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16151.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16151.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16151.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16151.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::mem; + +static mut DROP_COUNT: usize = 0; + +struct Fragment; + +impl Drop for Fragment { + fn drop(&mut self) { + unsafe { + DROP_COUNT += 1; + } + } +} + +fn main() { + { + let mut fragments = vec![Fragment, Fragment, Fragment]; + let _new_fragments: Vec = mem::replace(&mut fragments, vec![]) + .into_iter() + .skip_while(|_fragment| { + true + }).collect(); + } + unsafe { + assert_eq!(DROP_COUNT, 3); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16256.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16256.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16256.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16256.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +fn main() { + let mut buf = Vec::new(); + |c: u8| buf.push(c); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16272.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16272.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16272.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16272.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-cloudabi no processes +// ignore-emscripten no processes + +use std::process::Command; +use std::env; + +fn main() { + let len = env::args().len(); + + if len == 1 { + test(); + } else { + assert_eq!(len, 3); + } +} + +fn test() { + let status = Command::new(&env::current_exe().unwrap()) + .arg("foo").arg("") + .status().unwrap(); + assert!(status.success()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16278.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16278.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16278.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16278.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-tidy-cr + +// this file has some special \r\n endings (use xxd to see them) + +fn main() {assert_eq!(b"", b"\ + "); +assert_eq!(b"\n", b" +"); +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16441.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16441.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16441.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16441.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +struct Empty; + +// This used to cause an ICE +extern "C" fn ice(_a: Empty) {} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16452.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16452.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16452.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16452.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +fn main() { + if true { return } + match () { + () => { static MAGIC: usize = 0; } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16492.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16492.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16492.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16492.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,77 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_snake_case)] + +use std::rc::Rc; +use std::cell::Cell; + +struct Field { + number: usize, + state: Rc> +} + +impl Field { + fn new(number: usize, state: Rc>) -> Field { + Field { + number: number, + state: state + } + } +} + +impl Drop for Field { + fn drop(&mut self) { + println!("Dropping field {}", self.number); + assert_eq!(self.state.get(), self.number); + self.state.set(self.state.get()+1); + } +} + +struct NoDropImpl { + _one: Field, + _two: Field, + _three: Field +} + +struct HasDropImpl { + _one: Field, + _two: Field, + _three: Field +} + +impl Drop for HasDropImpl { + fn drop(&mut self) { + println!("HasDropImpl.drop()"); + assert_eq!(self._one.state.get(), 0); + self._one.state.set(1); + } +} + +pub fn main() { + let state = Rc::new(Cell::new(1)); + let noImpl = NoDropImpl { + _one: Field::new(1, state.clone()), + _two: Field::new(2, state.clone()), + _three: Field::new(3, state.clone()) + }; + drop(noImpl); + assert_eq!(state.get(), 4); + + state.set(0); + let hasImpl = HasDropImpl { + _one: Field::new(1, state.clone()), + _two: Field::new(2, state.clone()), + _three: Field::new(3, state.clone()) + }; + drop(hasImpl); + assert_eq!(state.get(), 4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16530.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16530.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16530.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16530.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(deprecated)] + +use std::hash::{SipHasher, Hasher, Hash}; + +#[derive(Hash)] +struct Empty; + +pub fn main() { + let mut s1 = SipHasher::new_with_keys(0, 0); + Empty.hash(&mut s1); + let mut s2 = SipHasher::new_with_keys(0, 0); + Empty.hash(&mut s2); + assert_eq!(s1.finish(), s2.finish()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16560.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16560.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16560.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16560.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// ignore-emscripten no threads support + +use std::thread; +use std::mem; + +fn main() { + let y = 0u8; + let closure = move |x: u8| y + x; + + // Check that both closures are capturing by value + assert_eq!(1, mem::size_of_val(&closure)); + + thread::spawn(move|| { + let ok = closure; + }).join().ok().unwrap(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16597-empty.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16597-empty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16597-empty.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16597-empty.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags:--test + +// This verifies that the test generation doesn't crash when we have +// no tests - for more information, see PR #16892. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16597.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16597.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16597.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16597.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +// compile-flags:--test + +mod tests { + use super::*; + + #[test] + pub fn test(){} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16602-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16602-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16602-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16602-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + let mut t = [1; 2]; + t = [t[1] * 2, t[0] * 2]; + assert_eq!(&t[..], &[2, 2]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16602-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16602-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16602-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16602-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct A { + pub x: u32, + pub y: u32, +} + +fn main() { + let mut a = A { x: 1, y: 1 }; + a = A { x: a.y * 2, y: a.x * 2 }; + assert_eq!(a.x, 2); + assert_eq!(a.y, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16602-3.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16602-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16602-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16602-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +#![allow(unused_assignments)] +#[derive(Debug)] +enum Foo { + Bar(u32, u32), + Baz(&'static u32, &'static u32) +} + +static NUM: u32 = 100; + +fn main () { + let mut b = Foo::Baz(&NUM, &NUM); + b = Foo::Bar(f(&b), g(&b)); +} + +static FNUM: u32 = 1; + +fn f (b: &Foo) -> u32 { + FNUM +} + +static GNUM: u32 = 2; + +fn g (b: &Foo) -> u32 { + GNUM +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-1660.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-1660.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-1660.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-1660.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_upper_case_globals)] + +// pretty-expanded FIXME #23616 + +pub fn main() { + static _x: isize = 1<<2; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16643.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16643.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16643.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16643.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-16643.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_16643 as i; + +pub fn main() { + i::TreeBuilder { h: 3 }.process_token(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16648.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16648.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16648.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16648.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + let x: (isize, &[isize]) = (2, &[1, 2]); + assert_eq!(match x { + (0, &[_, _]) => 0, + (1, _) => 1, + (2, &[_, _]) => 2, + (2, _) => 3, + _ => 4 + }, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16671.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16671.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16671.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16671.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +//compile-flags: -Z borrowck=compare -Z emit-end-regions + +#![deny(warnings)] + +fn foo(_f: F) { } + +fn main() { + let mut var = Vec::new(); + foo(move|| { + var.push(1); + }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16739.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16739.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16739.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16739.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,60 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] +#![feature(unboxed_closures, fn_traits)] + +// Test that unboxing shim for calling rust-call ABI methods through a +// trait box works and does not cause an ICE. + +struct Foo { foo: u32 } + +impl FnMut<()> for Foo { + extern "rust-call" fn call_mut(&mut self, _: ()) -> u32 { self.foo } +} + +impl FnOnce<()> for Foo { + type Output = u32; + extern "rust-call" fn call_once(mut self, _: ()) -> u32 { self.call_mut(()) } +} + +///////////////////////////////////////////////////////////////////////// + +impl FnMut<(u32,)> for Foo { + extern "rust-call" fn call_mut(&mut self, (x,): (u32,)) -> u32 { self.foo + x } +} + +impl FnOnce<(u32,)> for Foo { + type Output = u32; + extern "rust-call" fn call_once(mut self, args: (u32,)) -> u32 { self.call_mut(args) } +} + +///////////////////////////////////////////////////////////////////////// + +impl FnMut<(u32,u32)> for Foo { + extern "rust-call" fn call_mut(&mut self, (x, y): (u32, u32)) -> u32 { self.foo + x + y } +} + +impl FnOnce<(u32,u32)> for Foo { + type Output = u32; + extern "rust-call" fn call_once(mut self, args: (u32,u32)) -> u32 { self.call_mut(args) } +} + +fn main() { + let mut f = box Foo { foo: 42 } as Box u32>; + assert_eq!(f.call_mut(()), 42); + + let mut f = box Foo { foo: 40 } as Box u32>; + assert_eq!(f.call_mut((2,)), 42); + + let mut f = box Foo { foo: 40 } as Box u32>; + assert_eq!(f.call_mut((1, 1)), 42); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16745.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16745.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16745.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16745.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + const X: u8 = 0; + let out: u8 = match 0u8 { + X => 99, + b'\t' => 1, + 1u8 => 2, + _ => 3, + }; + assert_eq!(out, 99); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16774.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16774.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16774.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16774.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,56 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] +#![feature(box_patterns)] + +use std::ops::{Deref, DerefMut}; + +struct X(Box); + +static mut DESTRUCTOR_RAN: bool = false; + +impl Drop for X { + fn drop(&mut self) { + unsafe { + assert!(!DESTRUCTOR_RAN); + DESTRUCTOR_RAN = true; + } + } +} + +impl Deref for X { + type Target = isize; + + fn deref(&self) -> &isize { + let &X(box ref x) = self; + x + } +} + +impl DerefMut for X { + fn deref_mut(&mut self) -> &mut isize { + let &mut X(box ref mut x) = self; + x + } +} + +fn main() { + { + let mut test = X(box 5); + { + let mut change = || { *test = 10 }; + change(); + } + assert_eq!(*test, 10); + } + assert!(unsafe { DESTRUCTOR_RAN }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16783.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16783.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16783.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16783.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// pretty-expanded FIXME #23616 + +pub fn main() { + let x = [1, 2, 3]; + let y = x; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16819.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16819.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16819.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16819.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// `#[cfg]` on struct field permits empty unusable struct + +struct S { + #[cfg(untrue)] + a: int, +} + +fn main() { + let s = S {}; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16922.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16922.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-16922.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-16922.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +use std::any::Any; + +fn foo(_: &u8) { +} + +fn main() { + let _ = &foo as &Any; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-1696.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-1696.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-1696.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-1696.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::collections::HashMap; + +pub fn main() { + let mut m = HashMap::new(); + m.insert(b"foo".to_vec(), b"bar".to_vec()); + println!("{:?}", m); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-1701.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-1701.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-1701.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-1701.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + + +enum pattern { tabby, tortoiseshell, calico } +enum breed { beagle, rottweiler, pug } +type name = String; +enum ear_kind { lop, upright } +enum animal { cat(pattern), dog(breed), rabbit(name, ear_kind), tiger } + +fn noise(a: animal) -> Option { + match a { + animal::cat(..) => { Some("meow".to_string()) } + animal::dog(..) => { Some("woof".to_string()) } + animal::rabbit(..) => { None } + animal::tiger => { Some("roar".to_string()) } + } +} + +pub fn main() { + assert_eq!(noise(animal::cat(pattern::tabby)), Some("meow".to_string())); + assert_eq!(noise(animal::dog(breed::pug)), Some("woof".to_string())); + assert_eq!(noise(animal::rabbit("Hilbert".to_string(), ear_kind::upright)), None); + assert_eq!(noise(animal::tiger), Some("roar".to_string())); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17068.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17068.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17068.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17068.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that regionck creates the right region links in the pattern +// binding of a for loop + +fn foo<'a>(v: &'a [usize]) -> &'a usize { + for &ref x in v { return x; } + unreachable!() +} + +fn main() { + assert_eq!(foo(&[0]), &0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17074.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17074.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17074.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17074.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +static X2: u64 = !0 as u16 as u64; +static Y2: u64 = !0 as u32 as u64; +const X: u64 = !0 as u16 as u64; +const Y: u64 = !0 as u32 as u64; + +fn main() { + assert_eq!(match 1 { + X => unreachable!(), + Y => unreachable!(), + _ => 1 + }, 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17170.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17170.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17170.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17170.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(repr_simd)] + +#[repr(simd)] +struct T(f64, f64, f64); + +static X: T = T(0.0, 0.0, 0.0); + +fn main() { + let _ = X; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17216.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17216.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17216.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17216.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +struct Leak<'a> { + dropped: &'a mut bool +} + +impl<'a> Drop for Leak<'a> { + fn drop(&mut self) { + *self.dropped = true; + } +} + +fn main() { + let mut dropped = false; + { + let leak = Leak { dropped: &mut dropped }; + for ((), leaked) in Some(((), leak)).into_iter() {} + } + + assert!(dropped); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17233.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17233.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17233.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17233.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +const X1: &'static [u8] = &[b'1']; +const X2: &'static [u8] = b"1"; +const X3: &'static [u8; 1] = &[b'1']; +const X4: &'static [u8; 1] = b"1"; + +static Y1: u8 = X1[0]; +static Y2: u8 = X2[0]; +static Y3: u8 = X3[0]; +static Y4: u8 = X4[0]; + +fn main() { + assert_eq!(Y1, Y2); + assert_eq!(Y1, Y3); + assert_eq!(Y1, Y4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17302.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17302.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17302.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17302.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +static mut DROPPED: [bool; 2] = [false, false]; + +struct A(usize); +struct Foo { _a: A, _b: isize } + +impl Drop for A { + fn drop(&mut self) { + let A(i) = *self; + unsafe { DROPPED[i] = true; } + } +} + +fn main() { + { + Foo { + _a: A(0), + ..Foo { _a: A(1), _b: 2 } + }; + } + unsafe { + assert!(DROPPED[0]); + assert!(DROPPED[1]); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17322.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17322.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17322.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17322.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + +use std::io::{self, Write}; + +fn f(wr: &mut Write) { + wr.write_all(b"hello").ok().expect("failed"); +} + +fn main() { + let mut wr = box io::stdout() as Box; + f(&mut wr); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17351.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17351.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17351.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17351.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +trait Str { fn foo(&self) {} } +impl Str for str {} +impl<'a, S: ?Sized> Str for &'a S where S: Str {} + +fn main() { + let _: &Str = &"x"; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17361.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17361.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17361.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17361.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that astconv doesn't forget about mutability of &mut str + +// pretty-expanded FIXME #23616 + +fn main() { + fn foo(_: &mut T) {} + let _f: fn(&mut str) = foo; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17503.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17503.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17503.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17503.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + let s: &[isize] = &[0, 1, 2, 3, 4]; + let ss: &&[isize] = &s; + let sss: &&&[isize] = &ss; + + println!("{:?}", &s[..3]); + println!("{:?}", &ss[3..]); + println!("{:?}", &sss[2..4]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17662.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17662.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17662.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17662.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-17662.rs + + +extern crate issue_17662 as i; + +use std::marker; + +struct Bar<'a> { m: marker::PhantomData<&'a ()> } + +impl<'a> i::Foo<'a, usize> for Bar<'a> { + fn foo(&self) -> usize { 5 } +} + +pub fn main() { + assert_eq!(i::foo(&Bar { m: marker::PhantomData }), 5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17718-borrow-interior.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17718-borrow-interior.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17718-borrow-interior.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17718-borrow-interior.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +struct S { a: usize } + +static A: S = S { a: 3 }; +static B: &'static usize = &A.a; +static C: &'static usize = &(A.a); + +static D: [usize; 1] = [1]; +static E: usize = D[0]; +static F: &'static usize = &D[0]; + +fn main() { + assert_eq!(*B, A.a); + assert_eq!(*B, A.a); + + assert_eq!(E, D[0]); + assert_eq!(*F, D[0]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17718-parse-const.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17718-parse-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17718-parse-const.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17718-parse-const.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +const FOO: usize = 3; + +fn main() { + assert_eq!(FOO, 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17718.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17718.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17718.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17718.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,85 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// aux-build:issue-17718-aux.rs + +extern crate issue_17718_aux as other; + +use std::sync::atomic::{AtomicUsize, Ordering}; + +const C1: usize = 1; +const C2: AtomicUsize = AtomicUsize::new(0); +const C3: fn() = foo; +const C4: usize = C1 * C1 + C1 / C1; +const C5: &'static usize = &C4; +const C6: usize = { + const C: usize = 3; + C +}; + +static S1: usize = 3; +static S2: AtomicUsize = AtomicUsize::new(0); + +mod test { + static A: usize = 4; + static B: &'static usize = &A; + static C: &'static usize = &(A); +} + +fn foo() {} + +fn main() { + assert_eq!(C1, 1); + assert_eq!(C3(), ()); + assert_eq!(C2.fetch_add(1, Ordering::SeqCst), 0); + assert_eq!(C2.fetch_add(1, Ordering::SeqCst), 0); + assert_eq!(C4, 2); + assert_eq!(*C5, 2); + assert_eq!(C6, 3); + assert_eq!(S1, 3); + assert_eq!(S2.fetch_add(1, Ordering::SeqCst), 0); + assert_eq!(S2.fetch_add(1, Ordering::SeqCst), 1); + + match 1 { + C1 => {} + _ => unreachable!(), + } + + let _a = C1; + let _a = C2; + let _a = C3; + let _a = C4; + let _a = C5; + let _a = C6; + let _a = S1; + + assert_eq!(other::C1, 1); + assert_eq!(other::C3(), ()); + assert_eq!(other::C2.fetch_add(1, Ordering::SeqCst), 0); + assert_eq!(other::C2.fetch_add(1, Ordering::SeqCst), 0); + assert_eq!(other::C4, 2); + assert_eq!(*other::C5, 2); + assert_eq!(other::S1, 3); + assert_eq!(other::S2.fetch_add(1, Ordering::SeqCst), 0); + assert_eq!(other::S2.fetch_add(1, Ordering::SeqCst), 1); + + let _a = other::C1; + let _a = other::C2; + let _a = other::C3; + let _a = other::C4; + let _a = other::C5; + + match 1 { + other::C1 => {} + _ => unreachable!(), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17718-static-unsafe-interior.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17718-static-unsafe-interior.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17718-static-unsafe-interior.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17718-static-unsafe-interior.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,62 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(unused_imports)] +// pretty-expanded FIXME #23616 + +use std::marker; +use std::cell::UnsafeCell; + +struct MyUnsafePack(UnsafeCell); + +unsafe impl Sync for MyUnsafePack {} + +struct MyUnsafe { + value: MyUnsafePack +} + +impl MyUnsafe { + fn forbidden(&self) {} +} + +unsafe impl Sync for MyUnsafe {} + +enum UnsafeEnum { + VariantSafe, + VariantUnsafe(UnsafeCell) +} + +unsafe impl Sync for UnsafeEnum {} + +static STATIC1: UnsafeEnum = UnsafeEnum::VariantSafe; + +static STATIC2: MyUnsafePack = MyUnsafePack(UnsafeCell::new(1)); +const CONST: MyUnsafePack = MyUnsafePack(UnsafeCell::new(1)); +static STATIC3: MyUnsafe = MyUnsafe{value: CONST}; + +static STATIC4: &'static MyUnsafePack = &STATIC2; + +struct Wrap { + value: T +} + +unsafe impl Sync for Wrap {} + +static UNSAFE: MyUnsafePack = MyUnsafePack(UnsafeCell::new(2)); +static WRAPPED_UNSAFE: Wrap<&'static MyUnsafePack> = Wrap { value: &UNSAFE }; + +fn main() { + let a = &STATIC1; + + STATIC3.forbidden() +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17734.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17734.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17734.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17734.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that generating drop glue for Box doesn't ICE + + +fn f(s: Box) -> Box { + s +} + +fn main() { + // There is currently no safe way to construct a `Box`, so improvise + let box_arr: Box<[u8]> = Box::new(['h' as u8, 'e' as u8, 'l' as u8, 'l' as u8, 'o' as u8]); + let box_str: Box = unsafe { std::mem::transmute(box_arr) }; + assert_eq!(&*box_str, "hello"); + f(box_str); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17756.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17756.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17756.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17756.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +#![allow(non_upper_case_globals)] + +const count : usize = 2 as usize; +fn main() { + let larger : [usize; count*2]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17771.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17771.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17771.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17771.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +trait Aaa { fn dummy(&self) { } } + +impl<'a> Aaa for &'a mut (Aaa + 'a) {} + +struct Bar<'a> { + writer: &'a mut (Aaa + 'a), +} + +fn baz(_: &mut Aaa) { +} + +fn foo<'a>(mut bar: Bar<'a>) { + baz(&mut bar.writer); +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17816.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17816.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17816.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17816.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +use std::marker::PhantomData; + +fn main() { + struct Symbol<'a, F: Fn(Vec<&'a str>) -> &'a str> { function: F, marker: PhantomData<&'a ()> } + let f = |x: Vec<&str>| -> &str { "foobar" }; + let sym = Symbol { function: f, marker: PhantomData }; + (sym.function)(vec![]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17877.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17877.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17877.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17877.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(slice_patterns)] + +fn main() { + assert_eq!(match [0u8; 1024] { + _ => 42_usize, + }, 42_usize); + + assert_eq!(match [0u8; 1024] { + [1, _..] => 0_usize, + [0, _..] => 1_usize, + _ => 2_usize + }, 1_usize); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17897.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17897.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-17897.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-17897.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn action(mut cb: Box usize>) -> usize { + cb(1) +} + +pub fn main() { + println!("num: {}", action(Box::new(move |u| u))); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18060.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18060.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18060.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18060.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for #18060: match arms were matching in the wrong order. + +fn main() { + assert_eq!(2, match (1, 3) { (0, 2..=5) => 1, (1, 3) => 2, (_, 2..=5) => 3, (_, _) => 4 }); + assert_eq!(2, match (1, 3) { (1, 3) => 2, (_, 2..=5) => 3, (_, _) => 4 }); + assert_eq!(2, match (1, 7) { (0, 2..=5) => 1, (1, 7) => 2, (_, 2..=5) => 3, (_, _) => 4 }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18075.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18075.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18075.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18075.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// exec-env:RUST_LOG=rustc::middle=debug + +fn main() { + let b = 1isize; + println!("{}", b); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18110.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18110.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18110.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18110.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unreachable_code)] +// pretty-expanded FIXME #23616 + +fn main() { + ({return},); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18173.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18173.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18173.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18173.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait Foo { + type T; +} + +// should be able to use a trait with an associated type without specifying it as an argument +trait Bar { + fn bar(foo: &F); +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18232.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18232.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18232.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18232.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +struct Cursor<'a>(::std::marker::PhantomData<&'a ()>); + +trait CursorNavigator { + fn init_cursor<'a, 'b:'a>(&'a self, cursor: &mut Cursor<'b>) -> bool; +} + +struct SimpleNavigator; + +impl CursorNavigator for SimpleNavigator { + fn init_cursor<'a, 'b: 'a>(&'a self, _cursor: &mut Cursor<'b>) -> bool { + false + } +} + +fn main() { + let mut c = Cursor(::std::marker::PhantomData); + let n = SimpleNavigator; + n.init_cursor(&mut c); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18352.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18352.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18352.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18352.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +const X: &'static str = "12345"; + +fn test(s: String) -> bool { + match &*s { + X => true, + _ => false + } +} + +fn main() { + assert!(test("12345".to_string())); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18353.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18353.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18353.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18353.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Test that wrapping an unsized struct in an enum which gets optimised does +// not ICE. + +// pretty-expanded FIXME #23616 + +struct Str { + f: [u8] +} + +fn main() { + let str: Option<&Str> = None; + str.is_some(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18412.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18412.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18412.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18412.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that non-static methods can be assigned to local variables as +// function pointers. + + +trait Foo { + fn foo(&self) -> usize; +} + +struct A(usize); + +impl A { + fn bar(&self) -> usize { self.0 } +} + +impl Foo for A { + fn foo(&self) -> usize { self.bar() } +} + +fn main() { + let f = A::bar; + let g = Foo::foo; + let a = A(42); + + assert_eq!(f(&a), g(&a)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18425.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18425.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18425.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18425.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Check that codegen doesn't ICE when codegenning an array repeat +// expression with a count of 1 and a non-Copy element type. + +// pretty-expanded FIXME #23616 + +fn main() { + let _ = [Box::new(1_usize); 1]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18464.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18464.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18464.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18464.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![deny(dead_code)] + +const LOW_RANGE: char = '0'; +const HIGH_RANGE: char = '9'; + +fn main() { + match '5' { + LOW_RANGE..=HIGH_RANGE => (), + _ => () + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18501.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18501.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18501.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18501.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we don't ICE when inlining a function from another +// crate that uses a trait method as a value due to incorrectly +// translating the def ID of the trait during AST decoding. + +// aux-build:issue-18501.rs +// pretty-expanded FIXME #23616 + +extern crate issue_18501 as issue; + +fn main() { + issue::pass_method(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18514.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18514.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18514.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18514.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we don't ICE when codegenning a generic impl method from +// an extern crate that contains a match expression on a local +// variable place where one of the match case bodies contains an +// expression that autoderefs through an overloaded generic deref +// impl. + +// aux-build:issue-18514.rs + +extern crate issue_18514 as ice; +use ice::{Tr, St}; + +fn main() { + let st: St<()> = St(vec![]); + st.tr(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18539.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18539.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18539.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18539.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that coercing bare fn's that return a zero sized type to +// a closure doesn't cause an LLVM ERROR + +// pretty-expanded FIXME #23616 + +struct Foo; + +fn uint_to_foo(_: usize) -> Foo { + Foo +} + +#[allow(unused_must_use)] +fn main() { + (0..10).map(uint_to_foo); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18652.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18652.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18652.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18652.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests multiple free variables being passed by value into an unboxed +// once closure as an optimization by codegen. This used to hit an +// incorrect assert. + +fn main() { + let x = 2u8; + let y = 3u8; + assert_eq!((move || x + y)(), 5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18655.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18655.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18655.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18655.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait Factory { + type Product; + fn create(&self) -> ::Product; +} + +impl Factory for f64 { + type Product = f64; + fn create(&self) -> f64 { *self * *self } +} + +impl Factory for (A, B) { + type Product = (::Product, ::Product); + fn create(&self) -> (::Product, ::Product) { + let (ref a, ref b) = *self; + (a.create(), b.create()) + } +} + +fn main() { + assert_eq!((16., 25.), (4., 5.).create()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18661.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18661.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18661.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18661.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that param substitutions from the correct environment are +// used when codegenning unboxed closure calls. + +// pretty-expanded FIXME #23616 + +pub fn inside(c: F) { + c(); +} + +// Use different number of type parameters and closure type to trigger +// an obvious ICE when param environments are mixed up +pub fn outside() { + inside(|| {}); +} + +fn main() { + outside::<(),()>(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18685.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18685.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18685.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18685.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that the self param space is not used in a conflicting +// manner by unboxed closures within a default method on a trait + +// pretty-expanded FIXME #23616 + +trait Tr { + fn foo(&self); + + fn bar(&self) { + (|| { self.foo() })() + } +} + +impl Tr for () { + fn foo(&self) {} +} + +fn main() { + ().bar(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18711.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18711.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18711.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18711.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we don't panic on a RefCell borrow conflict in certain +// code paths involving unboxed closures. + +// pretty-expanded FIXME #23616 + +// aux-build:issue-18711.rs +extern crate issue_18711 as issue; + +fn main() { + (|| issue::inner(()))(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18767.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18767.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18767.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18767.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that regionck uses the right memcat for patterns in for loops +// and doesn't ICE. + + +fn main() { + for &&x in Some(&0_usize).iter() { + assert_eq!(x, 0) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18804/auxiliary/lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18804/auxiliary/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18804/auxiliary/lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18804/auxiliary/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![feature(linkage)] + +pub fn foo() -> *const() { + extern { + #[linkage = "extern_weak"] + static FOO: *const(); + } + unsafe { FOO } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18804/main.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18804/main.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18804/main.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18804/main.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test for issue #18804, #[linkage] does not propagate through generic +// functions. Failure results in a linker error. + +// ignore-asmjs no weak symbol support +// ignore-emscripten no weak symbol support + +// aux-build:lib.rs + +extern crate lib; + +fn main() { + lib::foo::(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18845.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18845.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18845.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18845.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// This used to generate invalid IR in that even if we took the +// `false` branch we'd still try to free the Box from the other +// arm. This was due to treating `*Box::new(9)` as an rvalue datum +// instead of as a place. + +fn test(foo: bool) -> u8 { + match foo { + true => *Box::new(9), + false => 0 + } +} + +fn main() { + assert_eq!(9, test(true)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18859.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18859.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18859.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18859.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +mod foo { + pub mod bar { + pub mod baz { + pub fn name() -> &'static str { + module_path!() + } + } + } +} + +fn main() { + assert_eq!(module_path!(), "issue_18859"); + assert_eq!(foo::bar::baz::name(), "issue_18859::foo::bar::baz"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18913.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18913.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18913.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18913.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-18913-1.rs +// aux-build:issue-18913-2.rs + +extern crate foo; + +fn main() { + assert_eq!(foo::foo(), 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18937-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18937-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-18937-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-18937-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we are able to type-check this example. In particular, +// knowing that `T: 'a` allows us to deduce that `[U]: 'a` (because +// when `T=[U]` it implies that `U: 'a`). +// +// Regr. test for live code we found in the wild when fixing #18937. + +pub trait Leak { + fn leak<'a>(self) -> &'a T where T: 'a; +} + +impl Leak<[U]> for Vec { + fn leak<'a>(mut self) -> &'a [U] where [U]: 'a { + let r: *mut [U] = &mut self[..]; + std::mem::forget(self); + unsafe { &mut *r } + } +} +fn main() { + println!("Hello, world!"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-19001.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-19001.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-19001.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-19001.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// check that we handle recursive arrays correctly in `type_of` + +struct Loopy { + ptr: *mut [Loopy; 1] +} + +fn main() { + let _t = Loopy { ptr: 0 as *mut _ }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-19127.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-19127.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-19127.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-19127.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// pretty-expanded FIXME #23616 + +fn foo T>(f: F) {} +fn id<'a>(input: &'a u8) -> &'a u8 { input } + +fn main() { + foo(id); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-19135.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-19135.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-19135.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-19135.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::marker::PhantomData; + +#[derive(Debug)] +struct LifetimeStruct<'a>(PhantomData<&'a ()>); + +fn main() { + takes_hrtb_closure(|lts| println!("{:?}", lts)); +} + +fn takes_hrtb_closureFnMut(LifetimeStruct<'a>)>(mut f: F) { + f(LifetimeStruct(PhantomData)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-19244.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-19244.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-19244.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-19244.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +struct MyStruct { field: usize } +struct Nested { nested: MyStruct } +struct Mix2 { nested: ((usize,),) } + +const STRUCT: MyStruct = MyStruct { field: 42 }; +const TUP: (usize,) = (43,); +const NESTED_S: Nested = Nested { nested: MyStruct { field: 5 } }; +const NESTED_T: ((usize,),) = ((4,),); +const MIX_1: ((Nested,),) = ((Nested { nested: MyStruct { field: 3 } },),); +const MIX_2: Mix2 = Mix2 { nested: ((2,),) }; +const INSTANT_1: usize = (MyStruct { field: 1 }).field; +const INSTANT_2: usize = (0,).0; + +fn main() { + let a = [0; STRUCT.field]; + let b = [0; TUP.0]; + let c = [0; NESTED_S.nested.field]; + let d = [0; (NESTED_T.0).0]; + let e = [0; (MIX_1.0).0.nested.field]; + let f = [0; (MIX_2.nested.0).0]; + let g = [0; INSTANT_1]; + let h = [0; INSTANT_2]; + + assert_eq!(a.len(), 42); + assert_eq!(b.len(), 43); + assert_eq!(c.len(), 5); + assert_eq!(d.len(), 4); + assert_eq!(e.len(), 3); + assert_eq!(f.len(), 2); + assert_eq!(g.len(), 1); + assert_eq!(h.len(), 0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-19293.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-19293.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-19293.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-19293.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue_19293.rs +// pretty-expanded FIXME #23616 + +extern crate issue_19293; +use issue_19293::{Foo, MyEnum}; + +fn main() { + MyEnum::Foo(Foo(5)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-19340-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-19340-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-19340-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-19340-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// aux-build:issue-19340-1.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_19340_1 as lib; + +use lib::Homura; + +fn main() { + let homura = Homura::Madoka { name: "Kaname".to_string() }; + + match homura { + Homura::Madoka { name } => (), + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-19340-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-19340-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-19340-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-19340-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// pretty-expanded FIXME #23616 + +enum Homura { + Madoka { + name: String, + age: u32, + }, +} + +fn main() { + let homura = Homura::Madoka { + name: "Akemi".to_string(), + age: 14, + }; + + match homura { + Homura::Madoka { + name, + age, + } => (), + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-19358.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-19358.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-19358.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-19358.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait Trait { fn dummy(&self) { } } + +#[derive(Debug)] +struct Foo { + foo: T, +} + +#[derive(Debug)] +struct Bar where T: Trait { + bar: T, +} + +impl Trait for isize {} + +fn main() { + let a = Foo { foo: 12 }; + let b = Bar { bar: 12 }; + println!("{:?} {:?}", a, b); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-19367.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-19367.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-19367.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-19367.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct S { + o: Option +} + +// Make sure we don't reuse the same alloca when matching +// on field of struct or tuple which we reassign in the match body. + +fn main() { + let mut a = (0, Some("right".to_string())); + let b = match a.1 { + Some(v) => { + a.1 = Some("wrong".to_string()); + v + } + None => String::new() + }; + println!("{}", b); + assert_eq!(b, "right"); + + + let mut s = S{ o: Some("right".to_string()) }; + let b = match s.o { + Some(v) => { + s.o = Some("wrong".to_string()); + v + } + None => String::new(), + }; + println!("{}", b); + assert_eq!(b, "right"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-19499.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-19499.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-19499.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-19499.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(path_statements)] +#![allow(unused_variables)] +// Regression test for issue #19499. Due to incorrect caching of trait +// results for closures with upvars whose types were not fully +// computed, this rather bizarre little program (along with many more +// reasonable examples) let to ambiguity errors about not being able +// to infer sufficient type information. + +// pretty-expanded FIXME #23616 + +fn main() { + let n = 0; + let it = Some(1_usize).into_iter().inspect(|_| {n;}); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-1974.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-1974.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-1974.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-1974.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Issue 1974 +// Don't double free the condition allocation +// pretty-expanded FIXME #23616 + +pub fn main() { + let s = "hej".to_string(); + while s != "".to_string() { + return; + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-19811-escape-unicode.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-19811-escape-unicode.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-19811-escape-unicode.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-19811-escape-unicode.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn main() { + let mut escaped = String::from(""); + for c in '\u{10401}'.escape_unicode() { + escaped.push(c); + } + assert_eq!("\\u{10401}", escaped); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20055-box-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20055-box-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20055-box-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20055-box-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,51 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// See Issues #20055 and #21695. + +// We are checking here that the temporaries `Box<[i8, k]>`, for `k` +// in 1, 2, 3, 4, that are induced by the match expression are +// properly handled, in that only *one* will be initialized by +// whichever arm is run, and subsequently dropped at the end of the +// statement surrounding the `match`. + +trait Boo { + fn dummy(&self) { } +} + +impl Boo for [i8; 1] { } +impl Boo for [i8; 2] { } +impl Boo for [i8; 3] { } +impl Boo for [i8; 4] { } + +pub fn foo(box_1: fn () -> Box<[i8; 1]>, + box_2: fn () -> Box<[i8; 2]>, + box_3: fn () -> Box<[i8; 3]>, + box_4: fn () -> Box<[i8; 4]>, + ) { + println!("Hello World 1"); + let _: Box = match 3 { + 1 => box_1(), + 2 => box_2(), + 3 => box_3(), + _ => box_4(), + }; + println!("Hello World 2"); +} + +pub fn main() { + fn box_1() -> Box<[i8; 1]> { Box::new( [1; 1] ) } + fn box_2() -> Box<[i8; 2]> { Box::new( [1; 2] ) } + fn box_3() -> Box<[i8; 3]> { Box::new( [1; 3] ) } + fn box_4() -> Box<[i8; 4]> { Box::new( [1; 4] ) } + + foo(box_1, box_2, box_3, box_4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20055-box-unsized-array.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20055-box-unsized-array.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20055-box-unsized-array.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20055-box-unsized-array.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Issue #2005: Check that boxed fixed-size arrays are properly +// accounted for (namely, only deallocated if they were actually +// created) when they appear as temporaries in unused arms of a match +// expression. + +pub fn foo(box_1: fn () -> Box<[i8; 1]>, + box_2: fn () -> Box<[i8; 20]>, + box_3: fn () -> Box<[i8; 300]>, + box_4: fn () -> Box<[i8; 4000]>, + ) { + println!("Hello World 1"); + let _: Box<[i8]> = match 3 { + 1 => box_1(), + 2 => box_2(), + 3 => box_3(), + _ => box_4(), + }; + println!("Hello World 2"); +} + +pub fn main() { + fn box_1() -> Box<[i8; 1]> { Box::new( [1] ) } + fn box_2() -> Box<[i8; 20]> { Box::new( [1; 20] ) } + fn box_3() -> Box<[i8; 300]> { Box::new( [1; 300] ) } + fn box_4() -> Box<[i8; 4000]> { Box::new( [1; 4000] ) } + + foo(box_1, box_2, box_3, box_4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20174.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20174.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20174.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20174.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct GradFn usize>(F); + +fn main() { + let GradFn(x_squared) : GradFn<_> = GradFn(|| -> usize { 2 }); + let _ = x_squared(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20313.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20313.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20313.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20313.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +#![feature(link_llvm_intrinsics)] + +extern { + #[link_name = "llvm.sqrt.f32"] + fn sqrt(x: f32) -> f32; +} + +fn main(){ +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20343.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20343.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20343.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20343.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// Regression test for Issue #20343. + +// pretty-expanded FIXME #23616 + +#![deny(dead_code)] + +struct B { b: u32 } +struct C; +struct D; + +trait T { fn dummy(&self, a: A) { } } +impl T for () {} + +impl B { + // test for unused code in arguments + fn foo(B { b }: B) -> u32 { b } + + // test for unused code in return type + fn bar() -> C { unsafe { ::std::mem::transmute(()) } } + + // test for unused code in generics + fn baz>() {} +} + +pub fn main() { + let b = B { b: 3 }; + B::foo(b); + B::bar(); + B::baz::<()>(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20389.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20389.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20389.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20389.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// aux-build:issue_20389.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_20389; + +struct Foo; + +impl issue_20389::T for Foo { + type C = (); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20427.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20427.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20427.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20427.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,98 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(unused_imports)] +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] + +// aux-build:i8.rs +// ignore-pretty issue #37201 + +extern crate i8; +use std::string as i16; +static i32: i32 = 0; +const i64: i64 = 0; +fn u8(f32: f32) {} +fn f(f64: f64) {} +enum u32 {} +struct u64; +trait bool {} + +mod char { + extern crate i8; + static i32_: i32 = 0; + const i64_: i64 = 0; + fn u8_(f32: f32) {} + fn f_(f64: f64_) {} + type u16_ = u16; + enum u32_ {} + struct u64_; + trait bool_ {} + mod char_ {} + + mod str { + use super::i8 as i8; + use super::i32_ as i32; + use super::i64_ as i64; + use super::u8_ as u8; + use super::f_ as f64; + use super::u16_ as u16; + use super::u32_ as u32; + use super::u64_ as u64; + use super::bool_ as bool; + use super::{bool_ as str}; + use super::char_ as char; + } +} + +trait isize_ { + type isize; +} + +fn usize<'usize>(usize: &'usize usize) -> &'usize usize { usize } + +mod reuse { + use std::mem::size_of; + + type u8 = u64; + use std::string::String as i16; + + pub fn check() { + assert_eq!(size_of::(), 8); + assert_eq!(size_of::<::u64>(), 0); + assert_eq!(size_of::(), 3 * size_of::<*const ()>()); + assert_eq!(size_of::(), 0); + } +} + +mod guard { + pub fn check() { + use std::u8; // bring module u8 in scope + fn f() -> u8 { // OK, resolves to primitive u8, not to std::u8 + u8::max_value() // OK, resolves to associated function ::max_value, + // not to non-existent std::u8::max_value + } + assert_eq!(f(), u8::MAX); // OK, resolves to std::u8::MAX + } +} + +fn main() { + let bool = true; + let _ = match bool { + str @ true => if str { i32 as i64 } else { i64 }, + false => i64, + }; + + reuse::check::(); + guard::check(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20544.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20544.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20544.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20544.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(unboxed_closures)] +#![feature(fn_traits)] + +struct Fun(F); + +impl FnOnce<(T,)> for Fun where F: Fn(T) -> T { + type Output = T; + + extern "rust-call" fn call_once(self, (t,): (T,)) -> T { + (self.0)(t) + } +} + +fn main() { + let fun = Fun(|i: isize| i * 2); + println!("{}", fun(3)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20575.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20575.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20575.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20575.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that overloaded calls work with zero arity closures + +// pretty-expanded FIXME #23616 + +fn main() { + let functions: [Box Option<()>>; 1] = [Box::new(|| None)]; + + let _: Option> = functions.iter().map(|f| (*f)()).collect(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20616.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20616.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20616.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20616.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,54 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +type MyType<'a, T> = &'a T; + +// combine lifetime bounds and type arguments in usual way +type TypeA<'a> = MyType<'a, ()>; + +// ensure token `>>` works fine +type TypeB = Box>; +type TypeB_ = Box>; + +// trailing comma when combine lifetime bounds and type arguments +type TypeC<'a> = MyType<'a, (),>; + +// normal lifetime bounds +type TypeD = TypeA<'static>; + +// trailing comma on lifetime bounds +type TypeE = TypeA<'static,>; + +// normal type argument +type TypeF = Box; + +// type argument with trailing comma +type TypeG = Box; + +// trailing comma on lifetime defs +type TypeH<'a,> = &'a (); + +// trailing comma on type argument +type TypeI = T; + +static STATIC: () = (); + +fn main() { + + // ensure token `>=` works fine + let _: TypeA<'static>= &STATIC; + let _: TypeA<'static,>= &STATIC; + + // ensure token `>>=` works fine + let _: Box>= Box::new(&STATIC); + let _: Box>= Box::new(&STATIC); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2063.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2063.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2063.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2063.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// test that autoderef of a type like this does not +// cause compiler to loop. Note that no instances +// of such a type could ever be constructed. + +struct T(Box); + +trait ToStr2 { + fn my_to_string(&self) -> String; +} + +impl ToStr2 for T { + fn my_to_string(&self) -> String { "t".to_string() } +} + +#[allow(dead_code)] +fn new_t(x: T) { + x.my_to_string(); +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20676.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20676.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20676.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20676.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for #20676. Error was that we didn't support +// UFCS-style calls to a method in `Trait` where `Self` was bound to a +// trait object of type `Trait`. See also `ufcs-trait-object.rs`. + + +use std::fmt; + +fn main() { + let a: &fmt::Debug = &1; + format!("{:?}", a); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2074.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2074.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2074.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2074.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#![allow(non_camel_case_types)] + +pub fn main() { + let one = || { + enum r { a }; + r::a as usize + }; + let two = || { + enum r { a }; + r::a as usize + }; + one(); two(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20803.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20803.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20803.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20803.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::ops::Add; + +fn foo(x: T) -> >::Output where i32: Add { + 42i32 + x +} + +fn main() { + println!("{}", foo(0i32)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20823.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20823.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20823.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20823.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags: --test + +#[test] +pub fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20847.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20847.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20847.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20847.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(fn_traits)] + +use std::ops::Fn; + +fn say(x: u32, y: u32) { + println!("{} {}", x, y); +} + +fn main() { + Fn::call(&say, (1, 2)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20953.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20953.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-20953.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-20953.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +#![allow(unused_variables)] +fn main() { + let mut shrinker: Box> = Box::new(vec![1].into_iter()); + println!("{:?}", shrinker.next()); + for v in shrinker { assert!(false); } + + let mut shrinker: &mut Iterator = &mut vec![1].into_iter(); + println!("{:?}", shrinker.next()); + for v in shrinker { assert!(false); } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21033.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21033.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21033.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21033.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,59 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +#![allow(unused_variables)] +// pretty-expanded FIXME #23616 + +#![feature(box_patterns)] +#![feature(box_syntax)] + +enum E { + StructVar { boxed: Box } +} + +fn main() { + + // Test matching each shorthand notation for field patterns. + let mut a = E::StructVar { boxed: box 3 }; + match a { + E::StructVar { box boxed } => { } + } + match a { + E::StructVar { box ref boxed } => { } + } + match a { + E::StructVar { box mut boxed } => { } + } + match a { + E::StructVar { box ref mut boxed } => { } + } + match a { + E::StructVar { ref boxed } => { } + } + match a { + E::StructVar { ref mut boxed } => { } + } + match a { + E::StructVar { mut boxed } => { } + } + + // Test matching non shorthand notation. Recreate a since last test + // moved `boxed` + let mut a = E::StructVar { boxed: box 3 }; + match a { + E::StructVar { boxed: box ref mut num } => { } + } + match a { + E::StructVar { boxed: ref mut num } => { } + } + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21058.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21058.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21058.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21058.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![feature(core_intrinsics)] + +struct NT(str); +struct DST { a: u32, b: str } + +fn main() { + // type_name should support unsized types + assert_eq!(unsafe {( + // Slice + std::intrinsics::type_name::<[u8]>(), + // str + std::intrinsics::type_name::(), + // Trait + std::intrinsics::type_name::(), + // Newtype + std::intrinsics::type_name::(), + // DST + std::intrinsics::type_name::() + )}, ("[u8]", "str", "dyn std::marker::Send", "NT", "DST")); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21291.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21291.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21291.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21291.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten no threads support + +// Regression test for unwrapping the result of `join`, issue #21291 + +use std::thread; + +fn main() { + thread::spawn(|| {}).join().unwrap() +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21306.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21306.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21306.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21306.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::sync::Arc; + +fn main() { + let x = 5; + let command = Arc::new(Box::new(|| { x*2 })); + assert_eq!(command(), 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21361.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21361.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21361.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21361.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn main() { + let v = vec![1, 2, 3]; + let boxed: Box> = Box::new(v.into_iter()); + assert_eq!(boxed.max(), Some(3)); + + let v = vec![1, 2, 3]; + let boxed: &mut Iterator = &mut v.into_iter(); + assert_eq!(boxed.max(), Some(3)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21384.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21384.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21384.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21384.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use ::std::ops::RangeFull; + +fn test(arg: T) -> T { + arg.clone() +} + +#[derive(PartialEq, Debug)] +struct Test(isize); + +fn main() { + // Check that ranges implement clone + assert_eq!(test(1..5), (1..5)); + assert_eq!(test(..5), (..5)); + assert_eq!(test(1..), (1..)); + assert_eq!(test(RangeFull), (RangeFull)); + + // Check that ranges can still be used with non-clone limits + assert_eq!((Test(1)..Test(5)), (Test(1)..Test(5))); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21400.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21400.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21400.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21400.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,67 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for #21400 which itself was extracted from +// stackoverflow.com/questions/28031155/is-my-borrow-checker-drunk/28031580 + +fn main() { + let mut t = Test; + assert_eq!(t.method1("one"), Ok(1)); + assert_eq!(t.method2("two"), Ok(2)); + assert_eq!(t.test(), Ok(2)); +} + +struct Test; + +impl Test { + fn method1(&mut self, _arg: &str) -> Result { + Ok(1) + } + + fn method2(self: &mut Test, _arg: &str) -> Result { + Ok(2) + } + + fn test(self: &mut Test) -> Result { + let s = format!("abcde"); + // (Originally, this invocation of method2 was saying that `s` + // does not live long enough.) + let data = match self.method2(&*s) { + Ok(r) => r, + Err(e) => return Err(e) + }; + Ok(data) + } +} + +// Below is a closer match for the original test that was failing to compile + +pub struct GitConnect; + +impl GitConnect { + fn command(self: &mut GitConnect, _s: &str) -> Result>, &str> { + unimplemented!() + } + + pub fn git_upload_pack(self: &mut GitConnect) -> Result { + let c = format!("git-upload-pack"); + + let mut out = String::new(); + let data = self.command(&c)?; + + for line in data.iter() { + out.push_str(&format!("{:?}", line)); + } + + Ok(out) + } +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21475.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21475.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21475.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21475.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +// pretty-expanded FIXME #23616 + +use m::{START, END}; + +fn main() { + match 42 { + m::START..=m::END => {}, + 0..=m::END => {}, + m::START..=59 => {}, + _ => {}, + } +} + +mod m { + pub const START: u32 = 4; + pub const END: u32 = 14; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21486.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21486.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21486.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21486.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,87 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unreachable_code)] +// Issue #21486: Make sure that all structures are dropped, even when +// created via FRU and control-flow breaks in the middle of +// construction. + +use std::sync::atomic::{Ordering, AtomicUsize}; + +#[derive(Debug)] +struct Noisy(u8); +impl Drop for Noisy { + fn drop(&mut self) { + // println!("splat #{}", self.0); + event(self.0); + } +} + +#[allow(dead_code)] +#[derive(Debug)] +struct Foo { n0: Noisy, n1: Noisy } +impl Foo { + fn vals(&self) -> (u8, u8) { (self.n0.0, self.n1.0) } +} + +fn leak_1_ret() -> Foo { + let _old_foo = Foo { n0: Noisy(1), n1: Noisy(2) }; + Foo { n0: { return Foo { n0: Noisy(3), n1: Noisy(4) } }, + .._old_foo + }; +} + +fn leak_2_ret() -> Foo { + let _old_foo = Foo { n0: Noisy(1), n1: Noisy(2) }; + Foo { n1: { return Foo { n0: Noisy(3), n1: Noisy(4) } }, + .._old_foo + }; +} + +// In this case, the control flow break happens *before* we construct +// `Foo(Noisy(1),Noisy(2))`, so there should be no record of it in the +// event log. +fn leak_3_ret() -> Foo { + let _old_foo = || Foo { n0: Noisy(1), n1: Noisy(2) }; + Foo { n1: { return Foo { n0: Noisy(3), n1: Noisy(4) } }, + .._old_foo() + }; +} + +pub fn main() { + reset_log(); + assert_eq!(leak_1_ret().vals(), (3,4)); + assert_eq!(0x01_02_03_04, event_log()); + + reset_log(); + assert_eq!(leak_2_ret().vals(), (3,4)); + assert_eq!(0x01_02_03_04, event_log()); + + reset_log(); + assert_eq!(leak_3_ret().vals(), (3,4)); + assert_eq!(0x03_04, event_log()); +} + +static LOG: AtomicUsize = AtomicUsize::new(0); + +fn reset_log() { + LOG.store(0, Ordering::SeqCst); +} + +fn event_log() -> usize { + LOG.load(Ordering::SeqCst) +} + +fn event(tag: u8) { + let old_log = LOG.load(Ordering::SeqCst); + let new_log = (old_log << 8) + tag as usize; + LOG.store(new_log, Ordering::SeqCst); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21655.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21655.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21655.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21655.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn test(it: &mut Iterator) { + for x in it { + assert_eq!(x, 1) + } +} + +fn main() { + let v = vec![1]; + test(&mut v.into_iter()) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue2170exe.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue2170exe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue2170exe.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue2170exe.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue2170lib.rs +// pretty-expanded FIXME #23616 + +extern crate issue2170lib; + +pub fn main() { + // let _ = issue2170lib::rsrc(2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21721.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21721.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21721.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21721.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn main() { + static NONE: Option<((), &'static u8)> = None; + let ptr = unsafe { + *(&NONE as *const _ as *const *const u8) + }; + assert!(ptr.is_null()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2190-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2190-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2190-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2190-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +#![allow(non_upper_case_globals)] + +// pretty-expanded FIXME #23616 +// ignore-emscripten no threads + +use std::thread::Builder; + +static generations: usize = 1024+256+128+49; + +fn spawn(mut f: Box) { + Builder::new().stack_size(32 * 1024).spawn(move|| f()); +} + +fn child_no(x: usize) -> Box { + Box::new(move|| { + if x < generations { + spawn(child_no(x+1)); + } + }) +} + +pub fn main() { + spawn(child_no(0)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21909.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21909.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21909.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21909.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +trait A { + fn dummy(&self, arg: X); +} + +trait B { + type X; + type Y: A; + + fn dummy(&self); +} + +fn main () { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21922.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21922.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-21922.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-21922.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::ops::Add; +fn show(z: i32) { + println!("{}", z) +} +fn main() { + let x = 23; + let y = 42; + show(Add::add( x, y)); + show(Add::add( x, &y)); + show(Add::add(&x, y)); + show(Add::add(&x, &y)); + show( x + y); + show( x + &y); + show(&x + y); + show(&x + &y); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22008.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22008.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22008.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22008.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn main() { + let command = "a"; + + match command { + "foo" => println!("foo"), + _ => println!("{}", command), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22036.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22036.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22036.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22036.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +trait DigitCollection: Sized { + type Iter: Iterator; + fn digit_iter(self) -> Self::Iter; + + fn digit_sum(self) -> u32 { + self.digit_iter() + .map(|digit: u8| digit as u32) + .fold(0, |sum, digit| sum + digit) + } +} + +impl DigitCollection for I where I: Iterator { + type Iter = I; + + fn digit_iter(self) -> I { + self + } +} + +fn main() { + let xs = vec![1, 2, 3, 4, 5]; + assert_eq!(xs.into_iter().digit_sum(), 15); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2214.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2214.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2214.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2214.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,51 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-wasm32-bare no libc to test ffi with + +#![feature(libc)] + +extern crate libc; + +use std::mem; +use libc::{c_double, c_int}; + +fn to_c_int(v: &mut isize) -> &mut c_int { + unsafe { + mem::transmute_copy(&v) + } +} + +fn lgamma(n: c_double, value: &mut isize) -> c_double { + unsafe { + return m::lgamma(n, to_c_int(value)); + } +} + +mod m { + use libc::{c_double, c_int}; + + #[link_name = "m"] + extern { + #[cfg(any(unix, target_os = "cloudabi"))] + #[link_name="lgamma_r"] + pub fn lgamma(n: c_double, sign: &mut c_int) -> c_double; + #[cfg(windows)] + #[link_name="lgamma"] + pub fn lgamma(n: c_double, sign: &mut c_int) -> c_double; + } +} + +pub fn main() { + let mut y: isize = 5; + let x: &mut isize = &mut y; + assert_eq!(lgamma(1.0 as c_double, x), 0.0 as c_double); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2216.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2216.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2216.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2216.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unreachable_code)] +pub fn main() { + let mut x = 0; + + 'foo: loop { + 'bar: loop { + 'quux: loop { + if 1 == 2 { + break 'foo; + } + else { + break 'bar; + } + } + continue 'foo; + } + x = 42; + break; + } + + println!("{}", x); + assert_eq!(x, 42); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22258.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22258.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22258.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22258.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::ops::Add; + +fn f(a: T, b: T) -> ::Output { + a + b +} + +fn main() { + println!("a + b is {}", f::(100f32, 200f32)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22346.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22346.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22346.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22346.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +// This used to cause an ICE because the retslot for the "return" had the wrong type +fn testcase<'a>() -> Box + 'a> { + return Box::new((0..3).map(|i| { return i; })); +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22403.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22403.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22403.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22403.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + let x = Box::new([1, 2, 3]); + let y = x as Box<[i32]>; + println!("y: {:?}", y); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22426.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22426.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22426.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22426.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +fn main() { + match 42 { + x if x < 7 => (), + _ => () + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22463.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22463.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22463.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22463.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +macro_rules! items { + () => { + type A = (); + fn a() {} + } +} + +trait Foo { + type A; + fn a(); +} + +impl Foo for () { + items!(); +} + +fn main() { + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22536-copy-mustnt-zero.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22536-copy-mustnt-zero.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22536-copy-mustnt-zero.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22536-copy-mustnt-zero.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for Issue #22536: If a type implements Copy, then +// moving it must not zero the original memory. + + +trait Resources { + type Buffer: Copy; + fn foo(&self) {} +} + +struct BufferHandle { + raw: ::Buffer, +} +impl Copy for BufferHandle {} +impl Clone for BufferHandle { + fn clone(&self) -> BufferHandle { *self } +} + +enum Res {} +impl Resources for Res { + type Buffer = u32; +} + +fn main() { + let b: BufferHandle = BufferHandle { raw: 1 }; + let c = b; + assert_eq!(c.raw, b.raw) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22546.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22546.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22546.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22546.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,62 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// Parsing patterns with paths with type parameters (issue #22544) + +use std::default::Default; + +#[derive(Default)] +pub struct Foo(T, T); + +impl Foo { + fn foo(&self) { + match *self { + Foo::(ref x, ref y) => println!("Goodbye, World! {} {}", x, y) + } + } +} + +trait Tr { + type U; +} + +impl Tr for Foo { + type U = T; +} + +struct Wrapper { + value: T +} + +fn main() { + let Foo::(a, b) = Default::default(); + + let f = Foo(2,3); + f.foo(); + + let w = Wrapper { value: Foo(10u8, 11u8) }; + match w { + Wrapper::> { value: Foo(10, 11) } => {}, + ::Wrapper::< as Tr>::U> { value: Foo::(11, 16) } => { panic!() }, + _ => { panic!() } + } + + if let None:: = Some(8) { + panic!(); + } + if let None:: { .. } = Some(8) { + panic!(); + } + if let Option::None:: { .. } = Some(8) { + panic!(); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22577.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22577.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22577.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22577.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 +// ignore-cloudabi no std::fs + +use std::{fs, net}; + +fn assert_both() {} +fn assert_send() {} + +fn main() { + assert_both::(); + assert_both::(); + assert_both::(); + assert_both::(); + assert_both::(); + assert_both::(); + + assert_both::(); + assert_both::(); + assert_both::(); + assert_both::(); + assert_both::(); + assert_both::(); + assert_both::(); + assert_both::(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22629.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22629.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22629.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22629.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +// Test transitive analysis for associated types. Collected types +// should be normalized and new obligations generated. + +// pretty-expanded FIXME #23616 + +use std::borrow::{ToOwned, Cow}; + +fn assert_send(_: T) {} + +fn main() { + assert_send(Cow::Borrowed("foo")); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22828.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22828.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22828.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22828.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Test transitive analysis for associated types. Collected types +// should be normalized and new obligations generated. + +// pretty-expanded FIXME #23616 + +trait Foo { + type A; + fn foo(&self) {} +} + +impl Foo for usize { + type A = usize; +} + +struct Bar { inner: T::A } + +fn is_send() {} + +fn main() { + is_send::>(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2284.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2284.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2284.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2284.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +trait Send { + fn f(&self); +} + +fn f(t: T) { + t.f(); +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22864-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22864-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22864-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22864-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn main() { + struct Fun(F); + let f = Fun(|x| 3*x); + let Fun(g) = f; + println!("{:?}",g(4)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22864-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22864-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22864-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22864-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten no threads support + +pub fn main() { + let f = || || 0; + std::thread::spawn(f()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2288.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2288.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2288.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2288.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +#![feature(box_syntax)] + +trait clam { + fn chowder(&self, y: A); +} + +#[derive(Copy, Clone)] +struct foo { + x: A, +} + +impl clam for foo { + fn chowder(&self, _y: A) { + } +} + +fn foo(b: A) -> foo { + foo { + x: b + } +} + +fn f(x: Box>, a: A) { + x.chowder(a); +} + +pub fn main() { + + let c = foo(42); + let d: Box> = box c as Box>; + f(d, c.x); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22992-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22992-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22992-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22992-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct A(B); +struct B; + +use std::ops::Deref; + +impl Deref for A { + type Target = B; + fn deref(&self) -> &B { &self.0 } +} + +impl B { + fn foo(&self) {} +} + +fn main() { + A(B).foo(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22992.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22992.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-22992.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-22992.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,86 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-pretty issue #37201 + +struct X { val: i32 } +impl std::ops::Deref for X { + type Target = i32; + fn deref(&self) -> &i32 { &self.val } +} + + +trait M { fn m(self); } +impl M for i32 { fn m(self) { println!("i32::m()"); } } +impl M for X { fn m(self) { println!("X::m()"); } } +impl<'a> M for &'a X { fn m(self) { println!("&X::m()"); } } +impl<'a, 'b> M for &'a &'b X { fn m(self) { println!("&&X::m()"); } } +impl<'a, 'b, 'c> M for &'a &'b &'c X { fn m(self) { println!("&&&X::m()"); } } + +trait RefM { fn refm(&self); } +impl RefM for i32 { fn refm(&self) { println!("i32::refm()"); } } +impl RefM for X { fn refm(&self) { println!("X::refm()"); } } +impl<'a> RefM for &'a X { fn refm(&self) { println!("&X::refm()"); } } +impl<'a, 'b> RefM for &'a &'b X { fn refm(&self) { println!("&&X::refm()"); } } +impl<'a, 'b, 'c> RefM for &'a &'b &'c X { fn refm(&self) { println!("&&&X::refm()"); } } + +struct Y { val: i32 } +impl std::ops::Deref for Y { + type Target = i32; + fn deref(&self) -> &i32 { &self.val } +} + +struct Z { val: Y } +impl std::ops::Deref for Z { + type Target = Y; + fn deref(&self) -> &Y { &self.val } +} + +struct A; +impl std::marker::Copy for A {} +impl Clone for A { fn clone(&self) -> Self { *self } } +impl M for A { fn m(self) { println!("A::m()"); } } +impl<'a, 'b, 'c> M for &'a &'b &'c A { fn m(self) { println!("&&&A::m()"); } } +impl RefM for A { fn refm(&self) { println!("A::refm()"); } } +impl<'a, 'b, 'c> RefM for &'a &'b &'c A { fn refm(&self) { println!("&&&A::refm()"); } } + +fn main() { + // I'll use @ to denote left side of the dot operator + (*X{val:42}).m(); // i32::refm() , self == @ + X{val:42}.m(); // X::m() , self == @ + (&X{val:42}).m(); // &X::m() , self == @ + (&&X{val:42}).m(); // &&X::m() , self == @ + (&&&X{val:42}).m(); // &&&X:m() , self == @ + (&&&&X{val:42}).m(); // &&&X::m() , self == *@ + (&&&&&X{val:42}).m(); // &&&X::m() , self == **@ + + (*X{val:42}).refm(); // i32::refm() , self == @ + X{val:42}.refm(); // X::refm() , self == @ + (&X{val:42}).refm(); // X::refm() , self == *@ + (&&X{val:42}).refm(); // &X::refm() , self == *@ + (&&&X{val:42}).refm(); // &&X::refm() , self == *@ + (&&&&X{val:42}).refm(); // &&&X::refm(), self == *@ + (&&&&&X{val:42}).refm(); // &&&X::refm(), self == **@ + + Y{val:42}.refm(); // i32::refm() , self == *@ + Z{val:Y{val:42}}.refm(); // i32::refm() , self == **@ + + A.m(); // A::m() , self == @ + // without the Copy trait, (&A).m() would be a compilation error: + // cannot move out of borrowed content + (&A).m(); // A::m() , self == *@ + (&&A).m(); // &&&A::m() , self == &@ + (&&&A).m(); // &&&A::m() , self == @ + A.refm(); // A::refm() , self == @ + (&A).refm(); // A::refm() , self == *@ + (&&A).refm(); // A::refm() , self == **@ + (&&&A).refm(); // &&&A::refm(), self == @ +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23036.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23036.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23036.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23036.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-cloudabi no std::path + +use std::collections::HashMap; +use std::path::Path; + +fn main() { + let mut map = HashMap::new(); + map.insert(Path::new("a"), 0); + map.get(Path::new("a")); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2316-c.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2316-c.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2316-c.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2316-c.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue_2316_a.rs +// aux-build:issue_2316_b.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_2316_b; +use issue_2316_b::cloth; + +pub fn main() { + let _c: cloth::fabric = cloth::fabric::calico; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23208.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23208.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23208.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23208.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait TheTrait : TheSuperTrait<::Item> { + type Item; +} + +trait TheSuperTrait { + fn get(&self) -> T; +} + +impl TheTrait for i32 { + type Item = u32; +} + +impl TheSuperTrait for i32 { + fn get(&self) -> u32 { + *self as u32 + } +} + +fn foo>(t: &T) -> u32 { + t.get() +} + +fn main() { + foo::(&22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23261.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23261.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23261.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23261.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,71 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Matching on a DST struct should not trigger an LLVM assertion. + +struct Foo { + a: i32, + inner: T +} + +trait Get { + fn get(&self) -> i32; +} + +impl Get for i32 { + fn get(&self) -> i32 { + *self + } +} + +fn check_val(val: &Foo<[u8]>) { + match *val { + Foo { a, .. } => { + assert_eq!(a, 32); + } + } +} + +fn check_dst_val(val: &Foo<[u8]>) { + match *val { + Foo { ref inner, .. } => { + assert_eq!(inner, [1, 2, 3]); + } + } +} + +fn check_both(val: &Foo<[u8]>) { + match *val { + Foo { a, ref inner } => { + assert_eq!(a, 32); + assert_eq!(inner, [1, 2, 3]); + } + } +} + +fn check_trait_obj(val: &Foo) { + match *val { + Foo { a, ref inner } => { + assert_eq!(a, 32); + assert_eq!(inner.get(), 32); + } + } +} + +fn main() { + let foo: &Foo<[u8]> = &Foo { a: 32, inner: [1, 2, 3] }; + check_val(foo); + check_dst_val(foo); + check_both(foo); + + let foo: &Foo = &Foo { a: 32, inner: 32 }; + check_trait_obj(foo); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23304-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23304-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23304-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23304-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +#[repr(u8)] +#[allow(dead_code)] +enum ValueType { + DOUBLE = 0x00, + INT32 = 0x01, +} + +#[repr(u32)] +enum ValueTag { + INT32 = 0x1FFF0u32 | (ValueType::INT32 as u32), + X, +} + +#[repr(u64)] +enum ValueShiftedTag { + INT32 = ValueTag::INT32 as u64, + X, +} + +fn main() { + println!("{}", ValueTag::INT32 as u32); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23304-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23304-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23304-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23304-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +enum X { A = 42 as isize } + +enum Y { A = X::A as isize } + +fn main() { + let x = X::A; + let x = x as isize; + assert_eq!(x, 42); + assert_eq!(Y::A as isize, 42); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23311.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23311.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23311.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23311.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we do not ICE when pattern matching an array against a slice. + +#![feature(slice_patterns)] + +fn main() { + match "foo".as_bytes() { + b"food" => (), + &[b'f', ..] => (), + _ => () + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23336.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23336.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23336.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23336.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub trait Data { fn doit(&self) {} } +impl Data for T {} +pub trait UnaryLogic { type D: Data; } +impl UnaryLogic for () { type D = i32; } + +pub fn crashes(t: T::D) { + t.doit(); +} + +fn main() { crashes::<()>(0); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23338-ensure-param-drop-order.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23338-ensure-param-drop-order.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23338-ensure-param-drop-order.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23338-ensure-param-drop-order.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,174 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_upper_case_globals)] + +// ignore-pretty issue #37201 + +// This test is ensuring that parameters are indeed dropped after +// temporaries in a fn body. + +use std::cell::RefCell; + +use self::d::D; + +pub fn main() { + let log = RefCell::new(vec![]); + d::println("created empty log"); + test(&log); + + assert_eq!(&log.borrow()[..], + [ + // created empty log + // +-- Make D(da_0, 0) + // | +-- Make D(de_1, 1) + // | | calling foo + // | | entered foo + // | | +-- Make D(de_2, 2) + // | | | +-- Make D(da_1, 3) + // | | | | +-- Make D(de_3, 4) + // | | | | | +-- Make D(de_4, 5) + 3, // | | | +-- Drop D(da_1, 3) + // | | | | | + 4, // | | | +-- Drop D(de_3, 4) + // | | | | + // | | | | eval tail of foo + // | | | +-- Make D(de_5, 6) + // | | | | +-- Make D(de_6, 7) + 5, // | | | | | +-- Drop D(de_4, 5) + // | | | | | + 2, // | | +-- Drop D(de_2, 2) + // | | | | + 6, // | | +-- Drop D(de_5, 6) + // | | | + 1, // | +-- Drop D(de_1, 1) + // | | + 0, // +-- Drop D(da_0, 0) + // | + // | result D(de_6, 7) + 7 // +-- Drop D(de_6, 7) + + ]); +} + +fn test<'a>(log: d::Log<'a>) { + let da = D::new("da", 0, log); + let de = D::new("de", 1, log); + d::println("calling foo"); + let result = foo(da, de); + d::println(&format!("result {}", result)); +} + +fn foo<'a>(da0: D<'a>, de1: D<'a>) -> D<'a> { + d::println("entered foo"); + let de2 = de1.incr(); // creates D(de_2, 2) + let de4 = { + let _da1 = da0.incr(); // creates D(da_1, 3) + de2.incr().incr() // creates D(de_3, 4) and D(de_4, 5) + }; + d::println("eval tail of foo"); + de4.incr().incr() // creates D(de_5, 6) and D(de_6, 7) +} + +// This module provides simultaneous printouts of the dynamic extents +// of all of the D values, in addition to logging the order that each +// is dropped. + +const PREF_INDENT: u32 = 16; + +pub mod d { + #![allow(unused_parens)] + use std::fmt; + use std::mem; + use std::cell::RefCell; + + static mut counter: u32 = 0; + static mut trails: u64 = 0; + + pub type Log<'a> = &'a RefCell>; + + pub fn current_width() -> u32 { + unsafe { max_width() - trails.leading_zeros() } + } + + pub fn max_width() -> u32 { + unsafe { + (mem::size_of_val(&trails)*8) as u32 + } + } + + pub fn indent_println(my_trails: u32, s: &str) { + let mut indent: String = String::new(); + for i in 0..my_trails { + unsafe { + if trails & (1 << i) != 0 { + indent = indent + "| "; + } else { + indent = indent + " "; + } + } + } + println!("{}{}", indent, s); + } + + pub fn println(s: &str) { + indent_println(super::PREF_INDENT, s); + } + + fn first_avail() -> u32 { + unsafe { + for i in 0..64 { + if trails & (1 << i) == 0 { + return i; + } + } + } + panic!("exhausted trails"); + } + + pub struct D<'a> { + name: &'static str, i: u32, uid: u32, trail: u32, log: Log<'a> + } + + impl<'a> fmt::Display for D<'a> { + fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { + write!(w, "D({}_{}, {})", self.name, self.i, self.uid) + } + } + + impl<'a> D<'a> { + pub fn new(name: &'static str, i: u32, log: Log<'a>) -> D<'a> { + unsafe { + let trail = first_avail(); + let ctr = counter; + counter += 1; + trails |= (1 << trail); + let ret = D { + name: name, i: i, log: log, uid: ctr, trail: trail + }; + indent_println(trail, &format!("+-- Make {}", ret)); + ret + } + } + pub fn incr(&self) -> D<'a> { + D::new(self.name, self.i + 1, self.log) + } + } + + impl<'a> Drop for D<'a> { + fn drop(&mut self) { + unsafe { trails &= !(1 << self.trail); }; + self.log.borrow_mut().push(self.uid); + indent_println(self.trail, &format!("+-- Drop {}", self)); + indent_println(::PREF_INDENT, ""); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23338-params-outlive-temps-of-body.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23338-params-outlive-temps-of-body.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23338-params-outlive-temps-of-body.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23338-params-outlive-temps-of-body.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// This is largely checking that we now accept code where temp values +// are borrowing from the input parameters (the `foo` case below). +// +// Compare to run-pass/issue-23338-params-outlive-temps-of-body.rs +// +// (The `foo2` case is just for parity with the above test, which +// shows what happens when you move the `y`-binding to the inside of +// the inner block.) + +use std::cell::RefCell; + +fn foo(x: RefCell) -> String { + x.borrow().clone() +} + +fn foo2(x: RefCell) -> String { + let y = x; + let ret = { + y.borrow().clone() + }; + ret +} + +pub fn main() { + let r = RefCell::new(format!("data")); + assert_eq!(foo(r), "data"); + let r = RefCell::new(format!("data")); + assert_eq!(foo2(r), "data"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23433.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23433.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23433.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23433.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Don't fail if we encounter a NonNull where T is an unsized type + +use std::ptr::NonNull; + +fn main() { + let mut a = [0u8; 5]; + let b: Option> = Some(NonNull::from(&mut a)); + match b { + Some(_) => println!("Got `Some`"), + None => panic!("Unexpected `None`"), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23485.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23485.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23485.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23485.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,60 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +// Test for an ICE that occurred when a default method implementation +// was applied to a type that did not meet the prerequisites. The +// problem occurred specifically because normalizing +// `Self::Item::Target` was impossible in this case. + +use std::boxed::Box; +use std::marker::Sized; +use std::clone::Clone; +use std::ops::Deref; +use std::option::Option; +use std::option::Option::{Some,None}; + +trait Iterator { + type Item; + + fn next(&mut self) -> Option; + + fn clone_first(mut self) -> Option<::Target> where + Self: Sized, + Self::Item: Deref, + ::Target: Clone, + { + self.next().map(|x| x.clone()) + } +} + +struct Counter { + value: i32 +} + +struct Token { + value: i32 +} + +impl Iterator for Counter { + type Item = Token; + + fn next(&mut self) -> Option { + let x = self.value; + self.value += 1; + Some(Token { value: x }) + } +} + +fn main() { + let mut x: Box> = Box::new(Counter { value: 22 }); + assert_eq!(x.next().unwrap().value, 22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23491.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23491.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23491.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23491.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +#![feature(box_syntax)] + +struct Node(T); + +fn main() { + let x: Box> = box Node([]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23611-enum-swap-in-drop.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23611-enum-swap-in-drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23611-enum-swap-in-drop.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23611-enum-swap-in-drop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,268 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_upper_case_globals)] + +// Issue 23611: this test is ensuring that, for an instance `X` of the +// enum `E`, if you swap in a different variant during the execution +// of the `::drop`, then the appropriate substructure will +// be torn down after the `::drop` method returns. + +use std::cell::RefCell; +use std::mem; + +use self::d::D; + +pub fn main() { + let log = RefCell::new(vec![]); + d::println("created empty log"); + test(&log); + + // println!("log: {:?}", &log.borrow()[..]); + assert_eq!( + &log.borrow()[..], + [ + // created empty log + // +-- Make D(test_1, 10000000) + // | +-- Make D(g_b_5, 50000001) + // | | in g_B(b2b0) from E::drop, b=b4b0 + // | +-- Drop D(g_b_5, 50000001) + 50000001, + // | + // | +-- Make D(drop_6, 60000002) + // | | +-- Make D(g_b_5, 50000003) + // | | | in g_B(b2b0) from E::drop, b=b4b1 + // | | +-- Drop D(g_b_5, 50000003) + 50000003, + // | | + // | | +-- Make D(GaspB::drop_3, 30000004) + // | | | +-- Make D(g_b_5, 50000005) + // | | | | in g_B(b4b2) from GaspB::drop + // | | | +-- Drop D(g_b_5, 50000005) + 50000005, + // | | | + // | | +-- Drop D(GaspB::drop_3, 30000004) + 30000004, + // | | + // +-- Drop D(test_1, 10000000) + 10000000, + // | + // +-- Make D(GaspA::drop_2, 20000006) + // | | +-- Make D(f_a_4, 40000007) + // | | | in f_A(a3a0) from GaspA::drop + // | | +-- Drop D(f_a_4, 40000007) + 40000007, + // | | + // +-- Drop D(GaspA::drop_2, 20000006) + 20000006, + // | + // +-- Drop D(drop_6, 60000002) + 60000002 + // + ]); + + // For reference purposes, the old (incorrect) behavior would produce the following + // output, which you can compare to the above: + // + // created empty log + // +-- Make D(test_1, 10000000) + // | +-- Make D(g_b_5, 50000001) + // | | in g_B(b2b0) from E::drop, b=b4b0 + // | +-- Drop D(g_b_5, 50000001) + // | + // | +-- Make D(drop_6, 60000002) + // | | +-- Make D(g_b_5, 50000003) + // | | | in g_B(b2b0) from E::drop, b=b4b1 + // | | +-- Drop D(g_b_5, 50000003) + // | | + // | | +-- Make D(GaspB::drop_3, 30000004) + // | | | +-- Make D(g_b_5, 50000005) + // | | | | in g_B(b4b2) from GaspB::drop + // | | | +-- Drop D(g_b_5, 50000005) + // | | | + // | | +-- Drop D(GaspB::drop_3, 30000004) + // | | + // +-- Drop D(test_1, 10000000) + // | + // +-- Make D(GaspB::drop_3, 30000006) + // | | +-- Make D(f_a_4, 40000007) + // | | | in f_A(a3a0) from GaspB::drop + // | | +-- Drop D(f_a_4, 40000007) + // | | + // +-- Drop D(GaspB::drop_3, 30000006) + // | + // +-- Drop D(drop_6, 60000002) + + // Note that this calls f_A from GaspB::drop (and thus creates a D + // with a uid incorporating the origin of GaspB's drop that + // surrounds the f_A invocation), but the code as written only + // ever hands f_A off to instances of GaspA, and thus one should + // be able to prove the invariant that f_A is *only* invoked from + // from an instance of GaspA (either via the GaspA drop + // implementation or the E drop implementaton). Yet the old (bad) + // behavior allowed a call to f_A to leak in while we are tearing + // down a value of type GaspB. +} + +fn test<'a>(log: d::Log<'a>) { + let _e = E::B(GaspB(g_b, 0xB4B0, log, D::new("test", 1, log)), true); +} + +struct GaspA<'a>(for <'b> fn(u32, &'b str, d::Log<'a>), u32, d::Log<'a>, d::D<'a>); +struct GaspB<'a>(for <'b> fn(u32, &'b str, d::Log<'a>), u32, d::Log<'a>, d::D<'a>); + +impl<'a> Drop for GaspA<'a> { + fn drop(&mut self) { + let _d = d::D::new("GaspA::drop", 2, self.2); + (self.0)(self.1, "GaspA::drop", self.2); + } +} + +impl<'a> Drop for GaspB<'a> { + fn drop(&mut self) { + let _d = d::D::new("GaspB::drop", 3, self.2); + (self.0)(self.1, "GaspB::drop", self.2); + } +} + +enum E<'a> { + A(GaspA<'a>, bool), B(GaspB<'a>, bool), +} + +fn f_a(x: u32, ctxt: &str, log: d::Log) { + let _d = d::D::new("f_a", 4, log); + d::println(&format!("in f_A({:x}) from {}", x, ctxt)); +} +fn g_b(y: u32, ctxt: &str, log: d::Log) { + let _d = d::D::new("g_b", 5, log); + d::println(&format!("in g_B({:x}) from {}", y, ctxt)); +} + +impl<'a> Drop for E<'a> { + fn drop(&mut self) { + let (do_drop, log) = match *self { + E::A(GaspA(ref f, ref mut val_a, log, ref _d_a), ref mut do_drop) => { + f(0xA1A0, &format!("E::drop, a={:x}", val_a), log); + *val_a += 1; + // swap in do_drop := false to avoid infinite dtor regress + (mem::replace(do_drop, false), log) + } + E::B(GaspB(ref g, ref mut val_b, log, ref _d_b), ref mut do_drop) => { + g(0xB2B0, &format!("E::drop, b={:x}", val_b), log); + *val_b += 1; + // swap in do_drop := false to avoid infinite dtor regress + (mem::replace(do_drop, false), log) + } + }; + + if do_drop { + mem::replace(self, E::A(GaspA(f_a, 0xA3A0, log, D::new("drop", 6, log)), true)); + } + } +} + +// This module provides simultaneous printouts of the dynamic extents +// of all of the D values, in addition to logging the order that each +// is dropped. +// +// This code is similar to a support code module embedded within +// test/run-pass/issue-123338-ensure-param-drop-order.rs; however, +// that (slightly simpler) code only identifies objects in the log via +// (creation) time-stamps; this incorporates both timestamping and the +// point of origin within the source code into the unique ID (uid). + +const PREF_INDENT: u32 = 20; + +pub mod d { + #![allow(unused_parens)] + use std::fmt; + use std::mem; + use std::cell::RefCell; + + static mut counter: u16 = 0; + static mut trails: u64 = 0; + + pub type Log<'a> = &'a RefCell>; + + pub fn current_width() -> u32 { + unsafe { max_width() - trails.leading_zeros() } + } + + pub fn max_width() -> u32 { + unsafe { + (mem::size_of_val(&trails)*8) as u32 + } + } + + pub fn indent_println(my_trails: u32, s: &str) { + let mut indent: String = String::new(); + for i in 0..my_trails { + unsafe { + if trails & (1 << i) != 0 { + indent = indent + "| "; + } else { + indent = indent + " "; + } + } + } + println!("{}{}", indent, s); + } + + pub fn println(s: &str) { + indent_println(super::PREF_INDENT, s); + } + + fn first_avail() -> u32 { + unsafe { + for i in 0..64 { + if trails & (1 << i) == 0 { + return i; + } + } + } + panic!("exhausted trails"); + } + + pub struct D<'a> { + name: &'static str, i: u8, uid: u32, trail: u32, log: Log<'a> + } + + impl<'a> fmt::Display for D<'a> { + fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { + write!(w, "D({}_{}, {})", self.name, self.i, self.uid) + } + } + + impl<'a> D<'a> { + pub fn new(name: &'static str, i: u8, log: Log<'a>) -> D<'a> { + unsafe { + let trail = first_avail(); + let ctr = ((i as u32) * 10_000_000) + (counter as u32); + counter += 1; + trails |= (1 << trail); + let ret = D { + name: name, i: i, log: log, uid: ctr, trail: trail + }; + indent_println(trail, &format!("+-- Make {}", ret)); + ret + } + } + } + + impl<'a> Drop for D<'a> { + fn drop(&mut self) { + unsafe { trails &= !(1 << self.trail); }; + self.log.borrow_mut().push(self.uid); + indent_println(self.trail, &format!("+-- Drop {}", self)); + indent_println(::PREF_INDENT, ""); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23649-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23649-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23649-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23649-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::mem; + +pub struct X([u8]); + +fn _f(x: &X) -> usize { match *x { X(ref x) => { x.len() } } } + +fn main() { + let b: &[u8] = &[11; 42]; + let v: &X = unsafe { mem::transmute(b) }; + assert_eq!(_f(v), 42); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23649-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23649-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23649-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23649-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-cloudabi no std::path + +use std::collections::HashMap; +use std::path::{Path, PathBuf}; + +fn main() { + let m: HashMap = HashMap::new(); + let k = Path::new("foo"); + println!("{:?}", m.get(k)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23699.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23699.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23699.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23699.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +fn gimme_a_raw_pointer(_: *const T) { } + +fn test(t: T) { } + +fn main() { + // Clearly `pointer` must be of type `*const ()`. + let pointer = &() as *const _; + gimme_a_raw_pointer(pointer); + + let t = test as fn (i32); + t(0i32); +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23781.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23781.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23781.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23781.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::fmt; + +struct Foo; +impl fmt::Debug for Foo { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + println!("::fmt()"); + + write!(fmt, "") + } +} + +fn test1() { + let foo_str = format!("{:?}", Foo); + + println!("{}", foo_str); +} + +fn test2() { + println!("{:?}", Foo); +} + +fn main() { + // This works fine + test1(); + + // This fails + test2(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23808.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23808.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23808.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23808.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,68 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![deny(dead_code)] + +// use different types / traits to test all combinations + +trait Const { + const C: (); +} + +trait StaticFn { + fn sfn(); +} + +struct ConstStruct; +struct StaticFnStruct; + +enum ConstEnum {} +enum StaticFnEnum {} + +struct AliasedConstStruct; +struct AliasedStaticFnStruct; + +enum AliasedConstEnum {} +enum AliasedStaticFnEnum {} + +type AliasConstStruct = AliasedConstStruct; +type AliasStaticFnStruct = AliasedStaticFnStruct; +type AliasConstEnum = AliasedConstEnum; +type AliasStaticFnEnum = AliasedStaticFnEnum; + +macro_rules! impl_Const {($($T:ident),*) => {$( + impl Const for $T { + const C: () = (); + } +)*}} + +macro_rules! impl_StaticFn {($($T:ident),*) => {$( + impl StaticFn for $T { + fn sfn() {} + } +)*}} + +impl_Const!(ConstStruct, ConstEnum, AliasedConstStruct, AliasedConstEnum); +impl_StaticFn!(StaticFnStruct, StaticFnEnum, AliasedStaticFnStruct, AliasedStaticFnEnum); + +fn main() { + let _ = ConstStruct::C; + let _ = ConstEnum::C; + + StaticFnStruct::sfn(); + StaticFnEnum::sfn(); + + let _ = AliasConstStruct::C; + let _ = AliasConstEnum::C; + + AliasStaticFnStruct::sfn(); + AliasStaticFnEnum::sfn(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2380-b.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2380-b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2380-b.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2380-b.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-2380.rs + +// pretty-expanded FIXME #23616 + +extern crate a; + +pub fn main() { + a::f::<()>(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23825.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23825.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23825.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23825.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait Stringify { + fn to_string(&self) -> String; +} + +impl Stringify for u32 { + fn to_string(&self) -> String { format!("u32: {}", *self) } +} + +impl Stringify for f32 { + fn to_string(&self) -> String { format!("f32: {}", *self) } +} + +fn print(x: T) -> String { + x.to_string() +} + +fn main() { + assert_eq!(&print(5), "u32: 5"); + assert_eq!(&print(5.0), "f32: 5"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23833.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23833.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23833.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23833.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +use std::fmt; +use std::{i8, i16, i32, i64, isize}; +use std::{u8, u16, u32, u64, usize}; + +const A_I8_T + : [u32; (i8::MAX as i8 - 1i8) as usize] + = [0; (i8::MAX as usize) - 1]; + +fn main() { + foo(&A_I8_T[..]); +} + +fn foo(x: T) { + println!("{:?}", x); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2383.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2383.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2383.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2383.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +use std::collections::VecDeque; + +pub fn main() { + let mut q = VecDeque::new(); + q.push_front(10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23891.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23891.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23891.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23891.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +macro_rules! id { + ($s: pat) => ($s); +} + +fn main() { + match (Some(123), Some(456)) { + (id!(Some(a)), _) | (_, id!(Some(a))) => println!("{}", a), + _ => (), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23898.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23898.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23898.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23898.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +// Note: This test was used to demonstrate #5873 (now #23898). + +enum State { ST_NULL, ST_WHITESPACE } + +fn main() { + [State::ST_NULL; (State::ST_WHITESPACE as usize)]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23958.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23958.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23958.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23958.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait Collection where for<'a> &'a Self: IntoIterator { + fn my_iter(&self) -> <&Self as IntoIterator>::IntoIter { + self.into_iter() + } +} + +impl Collection for [T] { } + +fn main() { + let v = [0usize]; + let _ = v.my_iter(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23968-const-not-overflow.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23968-const-not-overflow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23968-const-not-overflow.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23968-const-not-overflow.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +const U8_MAX_HALF: u8 = !0u8 / 2; +const U16_MAX_HALF: u16 = !0u16 / 2; +const U32_MAX_HALF: u32 = !0u32 / 2; +const U64_MAX_HALF: u64 = !0u64 / 2; + +fn main() { + assert_eq!(U8_MAX_HALF, 0x7f); + assert_eq!(U16_MAX_HALF, 0x7fff); + assert_eq!(U32_MAX_HALF, 0x7fff_ffff); + assert_eq!(U64_MAX_HALF, 0x7fff_ffff_ffff_ffff); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23992.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23992.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-23992.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-23992.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub struct Outer(T); +pub struct Inner<'a> { value: &'a bool } + +pub trait Trait { + type Error; + fn ready(self) -> Self::Error; +} + +impl<'a> Trait for Inner<'a> { + type Error = Outer>; + fn ready(self) -> Outer> { Outer(self) } +} + +fn main() { + let value = true; + let inner = Inner { value: &value }; + assert_eq!(inner.ready().0.value, &value); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24086.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24086.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24086.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24086.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_mut)] +#![allow(unused_variables)] +pub struct Registry<'a> { + listener: &'a mut (), +} + +pub struct Listener<'a> { + pub announce: Option>, + pub remove: Option>, +} + +impl<'a> Drop for Registry<'a> { + fn drop(&mut self) {} +} + +fn main() { + let mut registry_listener = Listener { + announce: None, + remove: None, + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2414-c.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2414-c.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2414-c.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2414-c.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-2414-a.rs +// aux-build:issue-2414-b.rs + +// pretty-expanded FIXME #23616 + +extern crate b; + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2428.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2428.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2428.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2428.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_upper_case_globals)] + + +pub fn main() { + let _foo = 100; + const quux: isize = 5; + + enum Stuff { + Bar = quux + } + + assert_eq!(Stuff::Bar as isize, quux); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24308.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24308.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24308.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24308.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub trait Foo { + fn method1() {} + fn method2(); +} + +struct Slice<'a, T: 'a>(&'a [T]); + +impl<'a, T: 'a> Foo for Slice<'a, T> { + fn method2() { + ::method1(); + } +} + +fn main() { + as Foo>::method2(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24313.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24313.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24313.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24313.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-cloudabi no processes +// ignore-emscripten no threads + +use std::thread; +use std::env; +use std::process::Command; + +struct Handle(i32); + +impl Drop for Handle { + fn drop(&mut self) { panic!(); } +} + +thread_local!(static HANDLE: Handle = Handle(0)); + +fn main() { + let args = env::args().collect::>(); + if args.len() == 1 { + let out = Command::new(&args[0]).arg("test").output().unwrap(); + let stderr = std::str::from_utf8(&out.stderr).unwrap(); + assert!(stderr.contains("panicked at 'explicit panic'"), + "bad failure message:\n{}\n", stderr); + } else { + // TLS dtors are not always run on process exit + thread::spawn(|| { + HANDLE.with(|h| { + println!("{}", h.0); + }); + }).join().unwrap(); + } +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24353.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24353.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24353.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24353.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unreachable_code)] +fn main() { + return (); + + let x = (); + x +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2445-b.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2445-b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2445-b.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2445-b.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +struct c1 { + x: T, +} + +impl c1 { + pub fn f1(&self, _x: isize) { + } +} + +fn c1(x: T) -> c1 { + c1 { + x: x + } +} + +impl c1 { + pub fn f2(&self, _x: isize) { + } +} + + +pub fn main() { + c1::(3).f1(4); + c1::(3).f2(4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2445.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2445.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2445.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2445.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +struct c1 { + x: T, +} + +impl c1 { + pub fn f1(&self, _x: T) {} +} + +fn c1(x: T) -> c1 { + c1 { + x: x + } +} + +impl c1 { + pub fn f2(&self, _x: T) {} +} + + +pub fn main() { + c1::(3).f1(4); + c1::(3).f2(4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24533.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24533.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24533.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24533.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +use std::slice::Iter; +use std::io::{Error, ErrorKind, Result}; +use std::vec::*; + +fn foo(it: &mut Iter) -> Result { + Ok(*it.next().unwrap()) +} + +fn bar() -> Result { + let data: Vec = Vec::new(); + + if true { + return Err(Error::new(ErrorKind::NotFound, "msg")); + } + + let mut it = data.iter(); + foo(&mut it) +} + +fn main() { + bar(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24535-allow-mutable-borrow-in-match-guard.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24535-allow-mutable-borrow-in-match-guard.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24535-allow-mutable-borrow-in-match-guard.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24535-allow-mutable-borrow-in-match-guard.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,68 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// This test illustrates that under NLL, we can remove our overly +// conservative approach for disallowing mutations of match inputs. + +// See further discussion on rust-lang/rust#24535, +// rust-lang/rfcs#1006, and rust-lang/rfcs#107 + +#![feature(nll)] +#![feature(bind_by_move_pattern_guards)] + +fn main() { + rust_issue_24535(); + rfcs_issue_1006_1(); + rfcs_issue_1006_2(); +} + +fn rust_issue_24535() { + fn compare(a: &u8, b: &mut u8) -> bool { + a == b + } + + let a = 3u8; + + match a { + 0 => panic!("nope"), + 3 if compare(&a, &mut 3) => (), + _ => panic!("nope"), + } +} + +fn rfcs_issue_1006_1() { + let v = vec!["1".to_string(), "2".to_string(), "3".to_string()]; + match Some(&v) { + Some(iv) if iv.iter().any(|x| &x[..]=="2") => true, + _ => panic!("nope"), + }; +} + +fn rfcs_issue_1006_2() { + #[inline(always)] + fn check<'a, I: Iterator>(mut i: I) -> bool { + i.any(|&x| x == 2) + } + + let slice = [1, 2, 3]; + + match 42 { + _ if slice.iter().any(|&x| x == 2) => { true }, + _ => { panic!("nope"); } + }; + + // (This match is just illustrating how easy it was to circumvent + // the checking performed for the previous `match`.) + match 42 { + _ if check(slice.iter()) => { true }, + _ => { panic!("nope"); } + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24589.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24589.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24589.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24589.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub struct _X([u8]); + +impl std::ops::Deref for _X { + type Target = [u8]; + + fn deref(&self) -> &[u8] { + &self.0 + } +} + +pub fn _g(x: &_X) -> &[u8] { + x +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2463.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2463.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2463.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2463.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +struct Pair { f: isize, g: isize } + +pub fn main() { + + let x = Pair { + f: 0, + g: 0, + }; + + let _y = Pair { + f: 1, + g: 1, + .. x + }; + + let _z = Pair { + f: 1, + .. x + }; + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue24687-embed-debuginfo/auxiliary/issue24687_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue24687-embed-debuginfo/auxiliary/issue24687_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue24687-embed-debuginfo/auxiliary/issue24687_lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue24687-embed-debuginfo/auxiliary/issue24687_lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] + +// This is a file that pulls in a separate file as a submodule, where +// that separate file has many multi-byte characters, to try to +// encourage the compiler to trip on them. + +mod issue24687_mbcs_in_comments; + +pub use issue24687_mbcs_in_comments::D; + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue24687-embed-debuginfo/auxiliary/issue24687_mbcs_in_comments.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue24687-embed-debuginfo/auxiliary/issue24687_mbcs_in_comments.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue24687-embed-debuginfo/auxiliary/issue24687_mbcs_in_comments.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue24687-embed-debuginfo/auxiliary/issue24687_mbcs_in_comments.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::fmt; + +// This ia file with many multi-byte characters, to try to encourage +// the compiler to trip on them. The Drop implementation below will +// need to have its source location embedded into the debug info for +// the output file. + +// αααααααααααααααααααααααααααααααααααααααααααααααααααααααααααααααααααααα +// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ +// γγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγ +// δδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδ +// εεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεε + +// ζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζ +// ηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηη +// θθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθ +// ιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιι +// κκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκ + +pub struct D(pub X); + +impl Drop for D { + fn drop(&mut self) { + // λλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλ + println!("Dropping D({:?})", self.0); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue24687-embed-debuginfo/main.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue24687-embed-debuginfo/main.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue24687-embed-debuginfo/main.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue24687-embed-debuginfo/main.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue24687_lib.rs +// compile-flags:-g + +extern crate issue24687_lib as d; + +fn main() { + // Create a d, which has a destructor whose body will be codegen'ed + // into the generated code here, and thus the local debuginfo will + // need references into the original source locations from + // `importer` above. + let _d = d::D("Hi"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2472.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2472.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2472.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2472.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue_2472_b.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_2472_b; + +use issue_2472_b::{S, T}; + +pub fn main() { + let s = S(()); + s.foo(); + s.bar(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24779.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24779.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24779.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24779.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + assert_eq!((||||42)()(), 42); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24805-dropck-itemless.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24805-dropck-itemless.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24805-dropck-itemless.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24805-dropck-itemless.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,89 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(deprecated)] + +// Check that item-less traits do not cause dropck to inject extra +// region constraints. + +#![allow(non_camel_case_types)] + +#![feature(dropck_parametricity)] + +trait UserDefined { } + +impl UserDefined for i32 { } +impl<'a, T> UserDefined for &'a T { } + +// e.g. `impl_drop!(Send, D_Send)` expands to: +// ```rust +// struct D_Send(T); +// impl Drop for D_Send { fn drop(&mut self) { } } +// ``` +macro_rules! impl_drop { + ($Bound:ident, $Id:ident) => { + struct $Id(T); + impl Drop for $Id { + #[unsafe_destructor_blind_to_params] + fn drop(&mut self) { } + } + } +} + +impl_drop!{Send, D_Send} +impl_drop!{Sized, D_Sized} + +// See note below regarding Issue 24895 +// impl_drop!{Copy, D_Copy} + +impl_drop!{Sync, D_Sync} +impl_drop!{UserDefined, D_UserDefined} + +macro_rules! body { + ($id:ident) => { { + // `_d` and `d1` are assigned the *same* lifetime by region inference ... + let (_d, d1); + + d1 = $id(1); + // ... we store a reference to `d1` within `_d` ... + _d = $id(&d1); + + // ... a *conservative* dropck will thus complain, because it + // thinks Drop of _d could access the already dropped `d1`. + } } +} + +fn f_send() { body!(D_Send) } +fn f_sized() { body!(D_Sized) } +fn f_sync() { body!(D_Sync) } + +// Issue 24895: Copy: Clone implies `impl Drop for ...` can +// access a user-defined clone() method, which causes this test case +// to fail. +// +// If 24895 is resolved by removing the `Copy: Clone` relationship, +// then this definition and the call below should be uncommented. If +// it is resolved by deciding to keep the `Copy: Clone` relationship, +// then this comment and the associated bits of code can all be +// removed. + +// fn f_copy() { body!(D_Copy) } + +fn f_userdefined() { body!(D_UserDefined) } + +fn main() { + f_send(); + f_sized(); + // See note above regarding Issue 24895. + // f_copy(); + f_sync(); + f_userdefined(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24945-repeat-dash-opts.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24945-repeat-dash-opts.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24945-repeat-dash-opts.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24945-repeat-dash-opts.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// This test is just checking that we continue to accept `-g -g -O -O` +// as options to the compiler. + +// compile-flags:-g -g -O -O + +fn main() { + assert_eq!(1, 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24947.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24947.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24947.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24947.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// #24947 ICE using a trait-associated const in an array size + + +struct Foo; + +impl Foo { + const SIZE: usize = 8; +} + +trait Bar { + const BAR_SIZE: usize; +} + +impl Bar for Foo { + const BAR_SIZE: usize = 12; +} + +#[allow(unused_variables)] +fn main() { + let w: [u8; 12] = [0u8; ::BAR_SIZE]; + let x: [u8; 12] = [0u8; ::BAR_SIZE]; + let y: [u8; 8] = [0u8; ::SIZE]; + let z: [u8; 8] = [0u8; Foo::SIZE]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24954.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24954.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-24954.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-24954.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +macro_rules! foo { + ($y:expr) => ({ + $y = 2; + }) +} + +#[allow(unused_variables)] +#[allow(unused_assignments)] +fn main() { + let mut x = 1; + foo!(x); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25089.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25089.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25089.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25089.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten no threads support + +use std::thread; + +struct Foo(i32); + +impl Drop for Foo { + fn drop(&mut self) { + static mut DROPPED: bool = false; + unsafe { + assert!(!DROPPED); + DROPPED = true; + } + } +} + +struct Empty; + +fn empty() -> Empty { Empty } + +fn should_panic(_: Foo, _: Empty) { + panic!("test panic"); +} + +fn test() { + should_panic(Foo(1), empty()); +} + +fn main() { + let ret = thread::spawn(test).join(); + assert!(ret.is_err()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25145.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25145.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25145.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25145.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +struct S; + +impl S { + const N: usize = 3; +} + +static STUFF: [u8; S::N] = [0; S::N]; + +fn main() { + assert_eq!(STUFF, [0; 3]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25185.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25185.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25185.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25185.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-25185-1.rs +// aux-build:issue-25185-2.rs +// ignore-wasm32-bare no libc for ffi testing + +extern crate issue_25185_2; + +fn main() { + let x = unsafe { + issue_25185_2::rust_dbg_extern_identity_u32(1) + }; + assert_eq!(x, 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2526-a.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2526-a.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2526-a.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2526-a.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-2526.rs + +// pretty-expanded FIXME #23616 + +#![allow(unused_imports)] + +extern crate issue_2526; +use issue_2526::*; + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25279.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25279.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25279.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25279.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct S<'a>(&'a ()); + +impl<'a> S<'a> { + fn foo(self) -> &'a () { + ::bar(self) + } + + fn bar(self) -> &'a () { + self.0 + } +} + +fn main() { + S(&()).foo(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25339.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25339.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25339.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25339.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +#![feature(associated_type_defaults)] + +use std::marker::PhantomData; + +pub trait Routing { + type Output; + fn resolve(&self, input: I); +} + +pub trait ToRouting { + type Input; + type Routing : ?Sized = Routing; + fn to_routing(self) -> Self::Routing; +} + +pub struct Mount> { + action: R, + _marker: PhantomData +} + +impl> Mount { + pub fn create>(mount: &str, input: T) { + input.to_routing(); + } +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25343.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25343.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25343.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25343.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[allow(unused)] +fn main() { + || { + 'label: loop { + } + }; + + // More cases added from issue 31754 + + 'label2: loop { + break; + } + + let closure = || { + 'label2: loop {} + }; + + fn inner_fn() { + 'label2: loop {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25467.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25467.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25467.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25467.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// aux-build:issue-25467.rs + +pub type Issue25467BarT = (); +pub type Issue25467FooT = (); + +extern crate issue_25467 as aux; + +fn main() { + let o: aux::Object = None; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25497.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25497.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25497.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25497.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(Clone, Debug, PartialEq)] +enum Expression { + Dummy, + Add(Box), +} + +use Expression::*; + +fn simplify(exp: Expression) -> Expression { + match exp { + Add(n) => *n.clone(), + _ => Dummy + } +} + +fn main() { + assert_eq!(simplify(Add(Box::new(Dummy))), Dummy); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2550.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2550.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2550.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2550.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_snake_case)] + +// pretty-expanded FIXME #23616 + +struct C { + x: usize, +} + +fn C(x: usize) -> C { + C { + x: x + } +} + +fn f(_x: T) { +} + +pub fn main() { + f(C(1)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25515.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25515.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25515.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25515.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::rc::Rc; + +struct Foo<'r>(&'r mut i32); + +impl<'r> Drop for Foo<'r> { + fn drop(&mut self) { + *self.0 += 1; + } +} + +fn main() { + let mut drops = 0; + + { + let _: Rc = Rc::new(Foo(&mut drops)); + } + + assert_eq!(1, drops); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25549-multiple-drop.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25549-multiple-drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25549-multiple-drop.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25549-multiple-drop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +struct Foo<'r>(&'r mut i32); + +impl<'r> Drop for Foo<'r> { + fn drop(&mut self) { + *self.0 += 1; + } +} + +trait Trait {} +impl<'r> Trait for Foo<'r> {} + +struct Holder(T); + +fn main() { + let mut drops = 0; + + { + let y = &Holder([Foo(&mut drops)]) as &Holder<[Foo]>; + // this used to cause an extra drop of the Foo instance + let x = &y.0; + } + assert_eq!(1, drops); + + drops = 0; + { + let y = &Holder(Foo(&mut drops)) as &Holder; + // this used to cause an extra drop of the Foo instance + let x = &y.0; + } + assert_eq!(1, drops); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25679.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25679.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25679.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25679.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait Device { + type Resources; +} +struct Foo(D, R); + +impl Foo { + fn present(&self) {} +} + +struct Res; +struct Dev; + +impl Device for Dev { type Resources = Res; } + +fn main() { + let foo = Foo(Dev, Res); + foo.present(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25693.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25693.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25693.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25693.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +pub trait Parameters { type SelfRef; } + +struct RP<'a> { _marker: std::marker::PhantomData<&'a ()> } +struct BP; + +impl<'a> Parameters for RP<'a> { type SelfRef = &'a X>; } +impl Parameters for BP { type SelfRef = Box>; } + +pub struct Y; +pub enum X { + Nothing, + SameAgain(P::SelfRef, Y) +} + +fn main() { + let bnil: Box> = Box::new(X::Nothing); + let bx: Box> = Box::new(X::SameAgain(bnil, Y)); + let rnil: X = X::Nothing; + let rx: X = X::SameAgain(&rnil, Y); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25700-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25700-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25700-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25700-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct S(Option<&'static T>); + +trait Tr { type Out; } +impl Tr for T { type Out = T; } + +impl Copy for S where S: Tr {} +impl Clone for S where S: Tr { + fn clone(&self) -> Self { *self } +} +fn main() { + S::<()>(None); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25700-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25700-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25700-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25700-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub trait Parser { + type Input; +} + +pub struct Iter(P, P::Input); + +pub struct Map(P, F); +impl Parser for Map where F: FnMut(P) { + type Input = u8; +} + +trait AstId { type Untyped; } +impl AstId for u32 { type Untyped = u32; } + +fn record_type(i: Id::Untyped) -> u8 { + Iter(Map(i, |_: Id::Untyped| {}), 42).1 +} + +pub fn main() { + assert_eq!(record_type::(3), 42); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25746-bool-transmute.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25746-bool-transmute.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25746-bool-transmute.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25746-bool-transmute.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::mem::transmute; + +fn main() { + unsafe { + let _: i8 = transmute(false); + let _: i8 = transmute(true); + let _: bool = transmute(0u8); + let _: bool = transmute(1u8); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25757.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25757.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25757.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25757.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct Foo { + a: u32 +} + +impl Foo { + fn x(&mut self) { + self.a = 5; + } +} + +const FUNC: &'static Fn(&mut Foo) -> () = &Foo::x; + +fn main() { + let mut foo = Foo { a: 137 }; + FUNC(&mut foo); + assert_eq!(foo.a, 5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25810.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25810.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25810.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25810.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + let x = X(15); + let y = x.foo(); + println!("{:?}",y); +} + +trait Foo + where for<'a> &'a Self: Bar +{ + fn foo<'a>(&'a self) -> <&'a Self as Bar>::Output; +} + +trait Bar { + type Output; +} + +struct X(i32); + +impl<'a> Bar for &'a X { + type Output = &'a i32; +} + +impl Foo for X { + fn foo<'a>(&'a self) -> <&'a Self as Bar>::Output { + &self.0 + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25916.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25916.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-25916.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-25916.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] + +fn main() { + macro_rules! f { + () => { 0 + 0 } + } + // 16 per line + f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); + f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); + f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); + f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); + + f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); + f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); + f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); + f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); + + f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); + f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); + f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); + f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); + + f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); + f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); + f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); + f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26127.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26127.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26127.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26127.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait Tr { type T; } +impl Tr for u8 { type T=(); } +struct S(I::T); + +fn foo(i: I::T) { + S::(i); +} + +fn main() { + foo::(()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26251.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26251.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26251.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26251.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + let x = 'a'; + + let y = match x { + 'a'..='b' if false => "one", + 'a' => "two", + 'a'..='b' => "three", + _ => panic!("what?"), + }; + + assert_eq!(y, "two"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2631-b.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2631-b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2631-b.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2631-b.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// aux-build:issue-2631-a.rs + +extern crate req; + +use req::request; +use std::cell::RefCell; +use std::collections::HashMap; +use std::rc::Rc; + +pub fn main() { + let v = vec![Rc::new("hi".to_string())]; + let mut m: req::header_map = HashMap::new(); + m.insert("METHOD".to_string(), Rc::new(RefCell::new(v))); + request::(&m); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26322.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26322.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26322.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26322.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] + +macro_rules! columnline { + () => ( + (column!(), line!()) + ) +} + +macro_rules! indirectcolumnline { + () => ( + (||{ columnline!() })() + ) +} + +fn main() { + let closure = || { + columnline!() + }; + let iflet = if let Some(_) = Some(0) { + columnline!() + } else { (0, 0) }; + let cl = columnline!(); + assert_eq!(closure(), (9, 29)); + assert_eq!(iflet, (9, 32)); + assert_eq!(cl, (14, 34)); + let indirect = indirectcolumnline!(); + assert_eq!(indirect, (20, 38)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2633-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2633-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2633-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2633-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + + +fn a_val(x: Box, y: Box) -> isize { + *x + *y +} + +pub fn main() { + let z: Box<_> = box 22; + a_val(z.clone(), z.clone()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2633.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2633.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2633.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2633.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +#[derive(Copy, Clone)] +struct cat { + meow: extern "Rust" fn(), +} + +fn meow() { + println!("meow") +} + +fn cat() -> cat { + cat { + meow: meow, + } +} + +#[derive(Copy, Clone)] +struct KittyInfo {kitty: cat} + +// Code compiles and runs successfully if we add a + before the first arg +fn nyan(kitty: cat, _kitty_info: KittyInfo) { + (kitty.meow)(); +} + +pub fn main() { + let kitty = cat(); + nyan(kitty, KittyInfo {kitty: kitty}); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2642.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2642.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2642.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2642.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +fn f() { + let _x: usize = loop { loop { break; } }; +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26468.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26468.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26468.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26468.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +enum FooMode { + Check = 0x1001, +} + +enum BarMode { + Check = 0x2001, +} + +enum Mode { + Foo(FooMode), + Bar(BarMode), +} + +#[inline(never)] +fn broken(mode: &Mode) -> u32 { + for _ in 0..1 { + if let Mode::Foo(FooMode::Check) = *mode { return 17 } + if let Mode::Bar(BarMode::Check) = *mode { return 19 } + } + return 42; +} + +fn main() { + let mode = Mode::Bar(BarMode::Check); + assert_eq!(broken(&mode), 19); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26484.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26484.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26484.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26484.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags:-g + +fn helper bool>(_f: F) { + print!(""); +} + +fn main() { + let cond = 0; + helper(|v| v == cond) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26641.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26641.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26641.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26641.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct Parser<'a>(Box); + +fn main() { + let _x = Parser(Box::new(|_|{})); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26655.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26655.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26655.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26655.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten no threads support + +// Check that the destructors of simple enums are run on unwinding + +use std::sync::atomic::{Ordering, AtomicUsize}; +use std::thread; + +static LOG: AtomicUsize = AtomicUsize::new(0); + +enum WithDtor { Val } +impl Drop for WithDtor { + fn drop(&mut self) { + LOG.store(LOG.load(Ordering::SeqCst)+1,Ordering::SeqCst); + } +} + +pub fn main() { + thread::spawn(move|| { + let _e: WithDtor = WithDtor::Val; + panic!("fail"); + }).join().unwrap_err(); + + assert_eq!(LOG.load(Ordering::SeqCst), 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26709.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26709.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26709.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26709.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct Wrapper<'a, T: ?Sized>(&'a mut i32, T); + +impl<'a, T: ?Sized> Drop for Wrapper<'a, T> { + fn drop(&mut self) { + *self.0 = 432; + } +} + +fn main() { + let mut x = 0; + { + let wrapper = Box::new(Wrapper(&mut x, 123)); + let _: Box> = wrapper; + } + assert_eq!(432, x) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26802.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26802.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26802.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26802.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait Foo<'a> { + fn bar<'b>(&self, x: &'b u8) -> u8 where 'a: 'b { *x+7 } +} + +pub struct FooBar; +impl Foo<'static> for FooBar {} +fn test(foobar: FooBar) -> Box> { + Box::new(foobar) +} + +fn main() { + assert_eq!(test(FooBar).bar(&4), 11); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26805.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26805.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26805.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26805.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct NonOrd; + +fn main() { + let _: Box> = Box::new(vec![NonOrd].into_iter()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue_26873_multifile/A/B.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue_26873_multifile/A/B.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue_26873_multifile/A/B.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue_26873_multifile/A/B.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use super::*; + +pub struct S; + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue_26873_multifile/A/C.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue_26873_multifile/A/C.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue_26873_multifile/A/C.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue_26873_multifile/A/C.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use super::*; + +use super::B::S; + +pub struct T { i: i32 } + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue_26873_multifile/A/mod.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue_26873_multifile/A/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue_26873_multifile/A/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue_26873_multifile/A/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub mod B; +pub mod C; + +pub use self::C::T; + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue_26873_multifile/mod.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue_26873_multifile/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue_26873_multifile/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue_26873_multifile/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +mod A; + +use self::A::*; + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26873-multifile.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26873-multifile.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26873-multifile.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26873-multifile.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_imports)] +#![allow(non_snake_case)] + +// ignore-pretty issue #37195 + +mod issue_26873_multifile; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26873-onefile.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26873-onefile.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26873-onefile.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26873-onefile.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_imports)] +#![allow(non_snake_case)] + +mod A { + pub mod B { + use super::*; + + pub struct S; + } + + pub mod C { + use super::*; + use super::B::S; + + pub struct T; + } + + pub use self::C::T; +} + +use A::*; + +fn main() {} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26905.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26905.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26905.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26905.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(unsize, coerce_unsized)] + +// Verfies that PhantomData is ignored for DST coercions + +use std::marker::{Unsize, PhantomData}; +use std::ops::CoerceUnsized; + +struct MyRc { + _ptr: *const T, + _boo: PhantomData, +} + +impl, U: ?Sized> CoerceUnsized> for MyRc{ } + +fn main() { + let data = [1, 2, 3]; + let iter = data.iter(); + let x = MyRc { _ptr: &iter, _boo: PhantomData }; + let _y: MyRc> = x; +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26996.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26996.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-26996.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-26996.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// This test is bogus (i.e. should be compile-fail) during the period +// where #54986 is implemented and #54987 is *not* implemented. For +// now: just ignore it under nll +// +// ignore-compare-mode-nll + +// This test is checking that the write to `c.0` (which has been moved out of) +// won't overwrite the state in `c2`. +// +// That's a fine thing to test when this code is accepted by the +// compiler, and this code is being transcribed accordingly into +// the ui test issue-21232-partial-init-and-use.rs + +fn main() { + let mut c = (1, "".to_owned()); + match c { + c2 => { + c.0 = 2; + assert_eq!(c2.0, 1); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27021.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27021.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27021.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27021.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// This test is bogus (i.e. should be compile-fail) during the period +// where #54986 is implemented and #54987 is *not* implemented. For +// now: just ignore it under nll +// +// ignore-compare-mode-nll + +// These are variants of issue-26996.rs. In all cases we are writing +// into a record field that has been moved out of, and ensuring that +// such a write won't overwrite the state of the thing it was moved +// into. +// +// That's a fine thing to test when this code is accepted by the +// compiler, and this code is being transcribed accordingly into +// the ui test issue-21232-partial-init-and-use.rs + +fn main() { + let mut c = (1, (1, "".to_owned())); + match c { + c2 => { (c.1).0 = 2; assert_eq!((c2.1).0, 1); } + } + + let mut c = (1, (1, (1, "".to_owned()))); + match c.1 { + c2 => { ((c.1).1).0 = 3; assert_eq!((c2.1).0, 1); } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27054-primitive-binary-ops.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27054-primitive-binary-ops.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27054-primitive-binary-ops.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27054-primitive-binary-ops.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + let x = &mut 1; + assert_eq!(*x + { *x=2; 1 }, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27060.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27060.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27060.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27060.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#[repr(packed)] +pub struct Good { + data: &'static u32, + data2: [&'static u32; 2], + aligned: [u8; 32], +} + +#[repr(packed)] +pub struct JustArray { + array: [u32] +} + +// kill this test when that turns to a hard error +#[allow(safe_packed_borrows)] +fn main() { + let good = Good { + data: &0, + data2: [&0, &0], + aligned: [0; 32] + }; + + unsafe { + let _ = &good.data; // ok + let _ = &good.data2[0]; // ok + } + + let _ = &good.data; + let _ = &good.data2[0]; + let _ = &*good.data; // ok, behind a pointer + let _ = &good.aligned; // ok, has align 1 + let _ = &good.aligned[2]; // ok, has align 1 +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2708.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2708.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2708.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2708.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_snake_case)] + +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + +struct Font { + fontbuf: usize, + cairo_font: usize, + font_dtor: usize, + +} + +impl Drop for Font { + fn drop(&mut self) {} +} + +fn Font() -> Font { + Font { + fontbuf: 0, + cairo_font: 0, + font_dtor: 0 + } +} + +pub fn main() { + let _f: Box<_> = box Font(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2718.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2718.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2718.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2718.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,337 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_unsafe)] +#![allow(unused_imports)] +#![allow(non_camel_case_types)] + +pub type Task = isize; + +// tjc: I don't know why +pub mod pipes { + use self::state::{empty, full, blocked, terminated}; + use super::Task; + use std::mem::{forget, transmute}; + use std::mem::{replace, swap}; + use std::mem; + use std::thread; + use std::marker::Send; + + pub struct Stuff { + state: state, + blocked_task: Option, + payload: Option + } + + #[derive(PartialEq, Debug)] + #[repr(isize)] + pub enum state { + empty, + full, + blocked, + terminated + } + + pub struct packet { + state: state, + blocked_task: Option, + payload: Option + } + + unsafe impl Send for packet {} + + pub fn packet() -> *const packet { + unsafe { + let p: *const packet = mem::transmute(Box::new(Stuff{ + state: empty, + blocked_task: None::, + payload: None:: + })); + p + } + } + + mod rusti { + pub fn atomic_xchg(_dst: &mut isize, _src: isize) -> isize { panic!(); } + pub fn atomic_xchg_acq(_dst: &mut isize, _src: isize) -> isize { panic!(); } + pub fn atomic_xchg_rel(_dst: &mut isize, _src: isize) -> isize { panic!(); } + } + + // We should consider moving this to ::std::unsafe, although I + // suspect graydon would want us to use void pointers instead. + pub unsafe fn uniquify(x: *const T) -> Box { + mem::transmute(x) + } + + pub fn swap_state_acq(dst: &mut state, src: state) -> state { + unsafe { + transmute(rusti::atomic_xchg_acq(transmute(dst), src as isize)) + } + } + + pub fn swap_state_rel(dst: &mut state, src: state) -> state { + unsafe { + transmute(rusti::atomic_xchg_rel(transmute(dst), src as isize)) + } + } + + pub fn send(mut p: send_packet, payload: T) { + let p = p.unwrap(); + let mut p = unsafe { uniquify(p) }; + assert!((*p).payload.is_none()); + (*p).payload = Some(payload); + let old_state = swap_state_rel(&mut (*p).state, full); + match old_state { + empty => { + // Yay, fastpath. + + // The receiver will eventually clean this up. + unsafe { forget(p); } + } + full => { panic!("duplicate send") } + blocked => { + + // The receiver will eventually clean this up. + unsafe { forget(p); } + } + terminated => { + // The receiver will never receive this. Rely on drop_glue + // to clean everything up. + } + } + } + + pub fn recv(mut p: recv_packet) -> Option { + let p = p.unwrap(); + let mut p = unsafe { uniquify(p) }; + loop { + let old_state = swap_state_acq(&mut (*p).state, + blocked); + match old_state { + empty | blocked => { thread::yield_now(); } + full => { + let payload = replace(&mut p.payload, None); + return Some(payload.unwrap()) + } + terminated => { + assert_eq!(old_state, terminated); + return None; + } + } + } + } + + pub fn sender_terminate(p: *const packet) { + let mut p = unsafe { uniquify(p) }; + match swap_state_rel(&mut (*p).state, terminated) { + empty | blocked => { + // The receiver will eventually clean up. + unsafe { forget(p) } + } + full => { + // This is impossible + panic!("you dun goofed") + } + terminated => { + // I have to clean up, use drop_glue + } + } + } + + pub fn receiver_terminate(p: *const packet) { + let mut p = unsafe { uniquify(p) }; + match swap_state_rel(&mut (*p).state, terminated) { + empty => { + // the sender will clean up + unsafe { forget(p) } + } + blocked => { + // this shouldn't happen. + panic!("terminating a blocked packet") + } + terminated | full => { + // I have to clean up, use drop_glue + } + } + } + + pub struct send_packet { + p: Option<*const packet>, + } + + impl Drop for send_packet { + fn drop(&mut self) { + unsafe { + if self.p != None { + let self_p: &mut Option<*const packet> = + mem::transmute(&mut self.p); + let p = replace(self_p, None); + sender_terminate(p.unwrap()) + } + } + } + } + + impl send_packet { + pub fn unwrap(&mut self) -> *const packet { + replace(&mut self.p, None).unwrap() + } + } + + pub fn send_packet(p: *const packet) -> send_packet { + send_packet { + p: Some(p) + } + } + + pub struct recv_packet { + p: Option<*const packet>, + } + + impl Drop for recv_packet { + fn drop(&mut self) { + unsafe { + if self.p != None { + let self_p: &mut Option<*const packet> = + mem::transmute(&mut self.p); + let p = replace(self_p, None); + receiver_terminate(p.unwrap()) + } + } + } + } + + impl recv_packet { + pub fn unwrap(&mut self) -> *const packet { + replace(&mut self.p, None).unwrap() + } + } + + pub fn recv_packet(p: *const packet) -> recv_packet { + recv_packet { + p: Some(p) + } + } + + pub fn entangle() -> (send_packet, recv_packet) { + let p = packet(); + (send_packet(p), recv_packet(p)) + } +} + +pub mod pingpong { + use std::mem; + + pub struct ping(::pipes::send_packet); + + unsafe impl Send for ping {} + + pub struct pong(::pipes::send_packet); + + unsafe impl Send for pong {} + + pub fn liberate_ping(p: ping) -> ::pipes::send_packet { + unsafe { + let _addr : *const ::pipes::send_packet = match &p { + &ping(ref x) => { mem::transmute(x) } + }; + panic!() + } + } + + pub fn liberate_pong(p: pong) -> ::pipes::send_packet { + unsafe { + let _addr : *const ::pipes::send_packet = match &p { + &pong(ref x) => { mem::transmute(x) } + }; + panic!() + } + } + + pub fn init() -> (client::ping, server::ping) { + ::pipes::entangle() + } + + pub mod client { + use pingpong; + + pub type ping = ::pipes::send_packet; + pub type pong = ::pipes::recv_packet; + + pub fn do_ping(c: ping) -> pong { + let (sp, rp) = ::pipes::entangle(); + + ::pipes::send(c, pingpong::ping(sp)); + rp + } + + pub fn do_pong(c: pong) -> (ping, ()) { + let packet = ::pipes::recv(c); + if packet.is_none() { + panic!("sender closed the connection") + } + (pingpong::liberate_pong(packet.unwrap()), ()) + } + } + + pub mod server { + use pingpong; + + pub type ping = ::pipes::recv_packet; + pub type pong = ::pipes::send_packet; + + pub fn do_ping(c: ping) -> (pong, ()) { + let packet = ::pipes::recv(c); + if packet.is_none() { + panic!("sender closed the connection") + } + (pingpong::liberate_ping(packet.unwrap()), ()) + } + + pub fn do_pong(c: pong) -> ping { + let (sp, rp) = ::pipes::entangle(); + ::pipes::send(c, pingpong::pong(sp)); + rp + } + } +} + +fn client(chan: pingpong::client::ping) { + let chan = pingpong::client::do_ping(chan); + println!("Sent ping"); + let (_chan, _data) = pingpong::client::do_pong(chan); + println!("Received pong"); +} + +fn server(chan: pingpong::server::ping) { + let (chan, _data) = pingpong::server::do_ping(chan); + println!("Received ping"); + let _chan = pingpong::server::do_pong(chan); + println!("Sent pong"); +} + +pub fn main() { + /* +// Commented out because of option::get error + + let (client_, server_) = pingpong::init(); + + task::spawn {|client_| + let client__ = client_.take(); + client(client__); + }; + task::spawn {|server_| + let server__ = server_.take(); + server(server_ˊ); + }; + */ +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2723-b.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2723-b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2723-b.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2723-b.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue_2723_a.rs + +extern crate issue_2723_a; +use issue_2723_a::f; + +pub fn main() { + unsafe { + f(vec![2]); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27240.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27240.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27240.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27240.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_assignments)] +#![allow(unused_variables)] +use std::fmt; +struct NoisyDrop(T); +impl Drop for NoisyDrop { + fn drop(&mut self) {} +} + +struct Bar([*const NoisyDrop; 2]); + +fn fine() { + let (u,b); + u = vec![43]; + b = Bar([&NoisyDrop(&u), &NoisyDrop(&u)]); +} + +struct Bar2(*const NoisyDrop, *const NoisyDrop); + +fn lolwut() { + let (u,v); + u = vec![43]; + v = Bar2(&NoisyDrop(&u), &NoisyDrop(&u)); +} + +fn main() { fine(); lolwut() } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27268.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27268.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27268.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27268.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + const _C: &'static Fn() = &||{}; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27320.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27320.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27320.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27320.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +#![allow(dead_code)] + +macro_rules! piece( + ($piece:pat) => ($piece); +); + +enum Piece {A, B} + +fn main() { + match Piece::A { + piece!(pt@ Piece::A) | piece!(pt@ Piece::B) => {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2734.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2734.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2734.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2734.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + +trait hax { + fn dummy(&self) { } +} +impl hax for A { } + +fn perform_hax(x: Box) -> Box { + box x as Box +} + +fn deadcode() { + perform_hax(box "deadcode".to_string()); +} + +pub fn main() { + let _ = perform_hax(box 42); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2735-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2735-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2735-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2735-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +use std::cell::Cell; + +// This test should behave exactly like issue-2735-3 +struct defer<'a> { + b: &'a Cell, +} + +impl<'a> Drop for defer<'a> { + fn drop(&mut self) { + self.b.set(true); + } +} + +fn defer(b: &Cell) -> defer { + defer { + b: b + } +} + +pub fn main() { + let dtor_ran = &Cell::new(false); + let _ = defer(dtor_ran); + assert!(dtor_ran.get()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2735-3.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2735-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2735-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2735-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +use std::cell::Cell; + +// This test should behave exactly like issue-2735-2 +struct defer<'a> { + b: &'a Cell, +} + +impl<'a> Drop for defer<'a> { + fn drop(&mut self) { + self.b.set(true); + } +} + +fn defer(b: &Cell) -> defer { + defer { + b: b + } +} + +pub fn main() { + let dtor_ran = &Cell::new(false); + defer(dtor_ran); + assert!(dtor_ran.get()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2735.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2735.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2735.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2735.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + +trait hax { + fn dummy(&self) { } +} +impl hax for A { } + +fn perform_hax(x: Box) -> Box { + box x as Box +} + +fn deadcode() { + perform_hax(box "deadcode".to_string()); +} + +pub fn main() { + perform_hax(box 42); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27401-dropflag-reinit.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27401-dropflag-reinit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27401-dropflag-reinit.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27401-dropflag-reinit.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-pretty issue #37201 + +// Check that when a `let`-binding occurs in a loop, its associated +// drop-flag is reinitialized (to indicate "needs-drop" at the end of +// the owning variable's scope). + +struct A<'a>(&'a mut i32); + +impl<'a> Drop for A<'a> { + fn drop(&mut self) { + *self.0 += 1; + } +} + +fn main() { + let mut cnt = 0; + for i in 0..2 { + let a = A(&mut cnt); + if i == 1 { // Note that + break; // both this break + } // and also + drop(a); // this move of `a` + // are necessary to expose the bug + } + assert_eq!(cnt, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2748-b.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2748-b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2748-b.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2748-b.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn thing<'r>(x: &'r [isize]) -> &'r [isize] { x } + +pub fn main() { + let x = &[1,2,3]; + let y = x; + let z = thing(x); + assert_eq!(z[2], x[2]); + assert_eq!(z[1], y[1]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27639.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27639.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27639.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27639.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_upper_case_globals)] + +fn main() { + const iter: i32 = 0; + + for i in 1..10 { + println!("{}", i); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27859.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27859.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27859.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27859.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-cloudabi no std::env +// ignore-wasm32 issue 42629 + +#[inline(never)] +fn foo(a: f32, b: f32) -> f32 { + a % b +} + +#[inline(never)] +fn bar(a: f32, b: f32) -> f32 { + ((a as f64) % (b as f64)) as f32 +} + +fn main() { + let unknown_float = std::env::args().len(); + println!("{}", foo(4.0, unknown_float as f32)); + println!("{}", foo(5.0, (unknown_float as f32) + 1.0)); + println!("{}", bar(6.0, (unknown_float as f32) + 2.0)); + println!("{}", bar(7.0, (unknown_float as f32) + 3.0)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27890.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27890.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27890.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27890.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +static PLUS_ONE: &'static (Fn(i32) -> i32 + Sync) = (&|x: i32| { x + 1 }) + as &'static (Fn(i32) -> i32 + Sync); + +fn main() { + assert_eq!(PLUS_ONE(2), 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27901.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27901.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27901.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27901.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait Stream { type Item; } +impl<'a> Stream for &'a str { type Item = u8; } +fn f<'s>(s: &'s str) -> (&'s str, <&'s str as Stream>::Item) { + (s, 42) +} + +fn main() { + let fx = f as for<'t> fn(&'t str) -> (&'t str, <&'t str as Stream>::Item); + assert_eq!(fx("hi"), ("hi", 42)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27997.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27997.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-27997.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-27997.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::sync::atomic::{Ordering, AtomicUsize}; + +use std::mem; +struct S { + _u: U, + size_of_u: usize, + _v: V, + size_of_v: usize +} + +impl S { + fn new(u: U, v: V) -> Self { + S { + _u: u, + size_of_u: mem::size_of::(), + _v: v, + size_of_v: mem::size_of::() + } + } +} + +static COUNT: AtomicUsize = AtomicUsize::new(0); + +impl Drop for S { + fn drop(&mut self) { + assert_eq!(mem::size_of::(), self.size_of_u); + assert_eq!(mem::size_of::(), self.size_of_v); + COUNT.store(COUNT.load(Ordering::SeqCst)+1, Ordering::SeqCst); + } +} + +fn main() { + assert_eq!(COUNT.load(Ordering::SeqCst), 0); + { S::new(0u8, 1u16); } + assert_eq!(COUNT.load(Ordering::SeqCst), 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-28181.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-28181.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-28181.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-28181.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn bar(f: F) -> usize where F: Fn([usize; 1]) -> usize { f([2]) } + +fn main() { + bar(|u| { u[0] }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-must-work-ex1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-must-work-ex1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-must-work-ex1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-must-work-ex1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Example taken from RFC 1238 text + +// https://github.com/rust-lang/rfcs/blob/master/text/1238-nonparametric-dropck.md +// #examples-of-code-that-must-continue-to-work + +use std::cell::Cell; + +struct Concrete<'a>(u32, Cell>>); + +fn main() { + let mut data = Vec::new(); + data.push(Concrete(0, Cell::new(None))); + data.push(Concrete(0, Cell::new(None))); + + data[0].1.set(Some(&data[1])); + data[1].1.set(Some(&data[0])); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-must-work-ex2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-must-work-ex2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-must-work-ex2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-must-work-ex2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Example taken from RFC 1238 text + +// https://github.com/rust-lang/rfcs/blob/master/text/1238-nonparametric-dropck.md +// #examples-of-code-that-must-continue-to-work + +use std::cell::Cell; + +struct Concrete<'a>(u32, Cell>>); + +struct Foo { data: Vec } + +fn main() { + let mut foo = Foo { data: Vec::new() }; + foo.data.push(Concrete(0, Cell::new(None))); + foo.data.push(Concrete(0, Cell::new(None))); + + foo.data[0].1.set(Some(&foo.data[1])); + foo.data[1].1.set(Some(&foo.data[0])); +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-ugeh-ex1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-ugeh-ex1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-ugeh-ex1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-ugeh-ex1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(deprecated)] // FIXME: switch to `#[may_dangle]` below. + +// Example taken from RFC 1238 text + +// https://github.com/rust-lang/rfcs/blob/master/text/1238-nonparametric-dropck.md +// #example-of-the-unguarded-escape-hatch + +#![feature(dropck_parametricity)] +use std::cell::Cell; + +struct Concrete<'a>(u32, Cell>>); + +struct Foo { data: Vec } + +impl Drop for Foo { + // Below is the UGEH attribute + #[unsafe_destructor_blind_to_params] + fn drop(&mut self) { } +} + +fn main() { + let mut foo = Foo { data: Vec::new() }; + foo.data.push(Concrete(0, Cell::new(None))); + foo.data.push(Concrete(0, Cell::new(None))); + + foo.data[0].1.set(Some(&foo.data[1])); + foo.data[1].1.set(Some(&foo.data[0])); +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-ugeh-with-lifetime-param.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-ugeh-with-lifetime-param.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-ugeh-with-lifetime-param.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-ugeh-with-lifetime-param.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,51 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(deprecated)] // FIXME: switch to `#[may_dangle]` below. + +// Demonstrate the use of the unguarded escape hatch with a lifetime param +// to assert that destructor will not access any dead data. +// +// Compare with compile-fail/issue28498-reject-lifetime-param.rs + +#![feature(dropck_parametricity)] + +#[derive(Debug)] +struct ScribbleOnDrop(String); + +impl Drop for ScribbleOnDrop { + fn drop(&mut self) { + self.0 = format!("DROPPED"); + } +} + +struct Foo<'a>(u32, &'a ScribbleOnDrop); + +impl<'a> Drop for Foo<'a> { + #[unsafe_destructor_blind_to_params] + fn drop(&mut self) { + // Use of `unsafe_destructor_blind_to_params` is sound, + // because destructor never accesses `self.1`. + println!("Dropping Foo({}, _)", self.0); + } +} + +fn main() { + let (last_dropped, foo0); + let (foo1, first_dropped); + + last_dropped = ScribbleOnDrop(format!("last")); + first_dropped = ScribbleOnDrop(format!("first")); + foo0 = Foo(0, &last_dropped); + foo1 = Foo(1, &first_dropped); + + println!("foo0.1: {:?} foo1.1: {:?}", foo0.1, foo1.1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-ugeh-with-passed-to-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-ugeh-with-passed-to-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-ugeh-with-passed-to-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-ugeh-with-passed-to-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,59 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(deprecated)] // FIXME: switch to `#[may_dangle]` below. + +// Demonstrate the use of the unguarded escape hatch with a type param in negative position +// to assert that destructor will not access any dead data. +// +// Compare with compile-fail/issue28498-reject-lifetime-param.rs + +// Demonstrate that a type param in negative position causes dropck to reject code +// that might indirectly access previously dropped value. +// +// Compare with run-pass/issue28498-ugeh-with-passed-to-fn.rs + +#![feature(dropck_parametricity)] + +#[derive(Debug)] +struct ScribbleOnDrop(String); + +impl Drop for ScribbleOnDrop { + fn drop(&mut self) { + self.0 = format!("DROPPED"); + } +} + +struct Foo(u32, T, Box fn(&'r T) -> String>); + +impl Drop for Foo { + #[unsafe_destructor_blind_to_params] + fn drop(&mut self) { + // Use of `unsafe_destructor_blind_to_params` is sound, + // because destructor never passes a `self.1` to the callback + // (in `self.2`) despite having it available. + println!("Dropping Foo({}, _)", self.0); + } +} + +fn callback(s: & &ScribbleOnDrop) -> String { format!("{:?}", s) } + +fn main() { + let (last_dropped, foo0); + let (foo1, first_dropped); + + last_dropped = ScribbleOnDrop(format!("last")); + first_dropped = ScribbleOnDrop(format!("first")); + foo0 = Foo(0, &last_dropped, Box::new(callback)); + foo1 = Foo(1, &first_dropped, Box::new(callback)); + + println!("foo0.1: {:?} foo1.1: {:?}", foo0.1, foo1.1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-ugeh-with-trait-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-ugeh-with-trait-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-ugeh-with-trait-bound.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue28498-ugeh-with-trait-bound.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,54 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(deprecated)] // FIXME: switch to `#[may_dangle]` below. + +// Demonstrate the use of the unguarded escape hatch with a trait bound +// to assert that destructor will not access any dead data. +// +// Compare with compile-fail/issue28498-reject-trait-bound.rs + +#![feature(dropck_parametricity)] + +use std::fmt; + +#[derive(Debug)] +struct ScribbleOnDrop(String); + +impl Drop for ScribbleOnDrop { + fn drop(&mut self) { + self.0 = format!("DROPPED"); + } +} + +struct Foo(u32, T); + +impl Drop for Foo { + #[unsafe_destructor_blind_to_params] + fn drop(&mut self) { + // Use of `unsafe_destructor_blind_to_params` is sound, + // because destructor never accesses the `Debug::fmt` method + // of `T`, despite having it available. + println!("Dropping Foo({}, _)", self.0); + } +} + +fn main() { + let (last_dropped, foo0); + let (foo1, first_dropped); + + last_dropped = ScribbleOnDrop(format!("last")); + first_dropped = ScribbleOnDrop(format!("first")); + foo0 = Foo(0, &last_dropped); + foo1 = Foo(1, &first_dropped); + + println!("foo0.1: {:?} foo1.1: {:?}", foo0.1, foo1.1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-28550.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-28550.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-28550.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-28550.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct AT,T>(F::Output); +struct BT,T>(A); + +// Removing Option causes it to compile. +fn fooT>(f: F) -> Option> { + Some(B(A(f()))) +} + +fn main() { + let v = (|| foo(||4))(); + match v { + Some(B(A(4))) => {}, + _ => unreachable!() + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-28676.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-28676.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-28676.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-28676.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// Copyright 2012-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(improper_ctypes)] + +// ignore-wasm32-bare no libc to test ffi with + +#[derive(Copy, Clone)] +pub struct Quad { a: u64, b: u64, c: u64, d: u64 } + +mod rustrt { + use super::Quad; + + #[link(name = "rust_test_helpers", kind = "static")] + extern { + pub fn get_c_many_params(_: *const (), _: *const (), + _: *const (), _: *const (), f: Quad) -> u64; + } +} + +fn test() { + unsafe { + let null = std::ptr::null(); + let q = Quad { + a: 1, + b: 2, + c: 3, + d: 4 + }; + assert_eq!(rustrt::get_c_many_params(null, null, null, null, q), q.c); + } +} + +pub fn main() { + test(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-28777.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-28777.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-28777.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-28777.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + let v1 = { 1 + {2} * {3} }; + let v2 = 1 + {2} * {3} ; + + assert_eq!(7, v1); + assert_eq!(7, v2); + + let v3; + v3 = { 1 + {2} * {3} }; + let v4; + v4 = 1 + {2} * {3}; + assert_eq!(7, v3); + assert_eq!(7, v4); + + let v5 = { 1 + {2} * 3 }; + assert_eq!(7, v5); + + let v9 = { 1 + if 1 > 2 {1} else {2} * {3} }; + assert_eq!(7, v9); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-28828.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-28828.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-28828.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-28828.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub trait Foo { + type Out; +} + +impl Foo for () { + type Out = bool; +} + +fn main() { + type Bool = <() as Foo>::Out; + + let x: Bool = true; + assert!(x); + + let y: Option = None; + assert_eq!(y, None); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-28839.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-28839.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-28839.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-28839.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-pretty issue #37199 + +pub struct Foo; + +pub fn get_foo2<'a>(foo: &'a mut Option<&'a mut Foo>) -> &'a mut Foo { + match foo { + // Ensure that this is not considered a move, but rather a reborrow. + &mut Some(ref mut x) => *x, + &mut None => panic!(), + } +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-28950.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-28950.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-28950.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-28950.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten no threads +// compile-flags: -O + +// Tests that the `vec!` macro does not overflow the stack when it is +// given data larger than the stack. + +// FIXME(eddyb) Improve unoptimized codegen to avoid the temporary, +// and thus run successfully even when compiled at -C opt-level=0. + +const LEN: usize = 1 << 15; + +use std::thread::Builder; + +fn main() { + assert!(Builder::new().stack_size(LEN / 2).spawn(|| { + // FIXME(eddyb) this can be vec![[0: LEN]] pending + // https://llvm.org/bugs/show_bug.cgi?id=28987 + let vec = vec![unsafe { std::mem::zeroed::<[u8; LEN]>() }]; + assert_eq!(vec.len(), 1); + }).unwrap().join().is_ok()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2895.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2895.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2895.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2895.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// Copyright 2012-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +use std::mem; + +struct Cat { + x: isize +} + +struct Kitty { + x: isize, +} + +impl Drop for Kitty { + fn drop(&mut self) {} +} + +#[cfg(target_pointer_width = "64")] +pub fn main() { + assert_eq!(mem::size_of::(), 8 as usize); + assert_eq!(mem::size_of::(), 8 as usize); +} + +#[cfg(target_pointer_width = "32")] +pub fn main() { + assert_eq!(mem::size_of::(), 4 as usize); + assert_eq!(mem::size_of::(), 4 as usize); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-28983.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-28983.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-28983.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-28983.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub trait Test { type T; } + +impl Test for u32 { + type T = i32; +} + +pub mod export { + #[no_mangle] + pub extern "C" fn issue_28983(t: ::T) -> i32 { t*3 } +} + +// to test both exporting and importing functions, import +// a function from ourselves. +extern "C" { + fn issue_28983(t: ::T) -> i32; +} + +fn main() { + assert_eq!(export::issue_28983(2), 6); + assert_eq!(unsafe { issue_28983(3) }, 9); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29053.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29053.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29053.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29053.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + let x: &'static str = "x"; + + { + let y = "y".to_string(); + let ref mut x = &*x; + *x = &*y; + } + + assert_eq!(x, "x"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29071-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29071-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29071-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29071-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +fn t1() -> u32 { + let x; + x = if true { [1, 2, 3] } else { [2, 3, 4] }[0]; + x +} + +fn t2() -> [u32; 1] { + if true { [1, 2, 3]; } else { [2, 3, 4]; } + [0] +} + +fn t3() -> u32 { + let x; + x = if true { i1 as F } else { i2 as F }(); + x +} + +fn t4() -> () { + if true { i1 as F; } else { i2 as F; } + () +} + +type F = fn() -> u32; +fn i1() -> u32 { 1 } +fn i2() -> u32 { 2 } + +fn main() { + assert_eq!(t1(), 1); + assert_eq!(t3(), 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29092.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29092.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29092.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29092.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for Issue #29092. +// +// (Possibly redundant with regression test run-pass/issue-30530.rs) + +use self::Term::*; + +#[derive(Clone)] +pub enum Term { + Dummy, + A(Box), + B(Box), +} + +// a small-step evaluator +pub fn small_eval(v: Term) -> Term { + match v { + A(t) => *t.clone(), + B(t) => *t.clone(), + _ => Dummy, + } +} + +fn main() { + small_eval(Dummy); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29147.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29147.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29147.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29147.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![recursion_limit="1024"] + +use std::mem; + +pub struct S0(T,T); +pub struct S1(Option>>>,Option>>>); +pub struct S2(Option>>>,Option>>>); +pub struct S3(Option>>>,Option>>>); +pub struct S4(Option>>>,Option>>>); +pub struct S5(Option>>>,Option>>>,Option); + +trait Foo { fn xxx(&self); } +/// some local of #[fundamental] trait +trait Bar {} + +impl Foo for T where T: Bar, T: Sync { + fn xxx(&self) {} +} + +impl Foo for S5 { fn xxx(&self) {} } + +fn main() { + let s = S5(None,None,None); + s.xxx(); + assert_eq!(mem::size_of_val(&s.2), mem::size_of::>()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29166.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29166.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29166.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29166.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// This test ensures that vec.into_iter does not overconstrain element lifetime. + +pub fn main() { + original_report(); + revision_1(); + revision_2(); +} + +fn original_report() { + drop(vec![&()].into_iter()) +} + +fn revision_1() { + // below is what above `vec!` expands into at time of this writing. + drop(<[_]>::into_vec(::std::boxed::Box::new([&()])).into_iter()) +} + +fn revision_2() { + drop((match (Vec::new(), &()) { (mut v, b) => { v.push(b); v } }).into_iter()) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29227.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29227.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29227.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29227.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,152 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-tidy-linelength + +// Regression test for #29227. The problem here was that MIR +// construction for these gigantic match expressions was very +// inefficient. + +pub trait CharExt : Sized + Copy { + fn is_unicode_uppercase_letter(self) -> bool { false } + fn is_unicode_lowercase_letter(self) -> bool { false } + fn is_unicode_titlecase_letter(self) -> bool { false } + fn is_unicode_modifier_letter(self) -> bool { false } + fn is_unicode_other_letter(self) -> bool { false } + fn is_unicode_letter_number(self) -> bool { false } + fn is_unicode_nonspacing_mark(self) -> bool { false } + fn is_unicode_combining_spacing_mark(self) -> bool { false } + fn is_unicode_decimal_number(self) -> bool{ false } + fn is_unicode_connector_punctiation(self) -> bool { false } + fn is_unicode_space_separator(self) -> bool { false } + + fn is_es_identifier_start(self) -> bool { false } + fn is_es_identifier_part(self) -> bool { false } + fn is_es_whitespace(self) -> bool { false } + fn is_es_line_terminator(self) -> bool { false } + + fn is_unicode_letter(self) -> bool { + self.is_unicode_uppercase_letter() + || self.is_unicode_lowercase_letter() + || self.is_unicode_titlecase_letter() + || self.is_unicode_modifier_letter() + || self.is_unicode_modifier_letter() + || self.is_unicode_letter_number() + } + +} + + +macro_rules! match_char_class { + ($thing:expr, $($c:expr),*) => { + match $thing { + $($c)|* => true, + _ => false + } + } +} + +impl CharExt for char { + fn is_unicode_uppercase_letter(self) -> bool { + match_char_class!(self, + '\u{0041}', '\u{0042}', '\u{0043}', '\u{0044}', '\u{0045}', '\u{0046}', '\u{0047}', '\u{0048}', '\u{0049}', '\u{004A}', '\u{004B}', '\u{004C}', '\u{004D}', '\u{004E}', '\u{004F}', '\u{0050}', '\u{0051}', '\u{0052}', '\u{0053}', '\u{0054}', '\u{0055}', '\u{0056}', '\u{0057}', '\u{0058}', '\u{0059}', '\u{005A}', '\u{00C0}', '\u{00C1}', '\u{00C2}', '\u{00C3}', '\u{00C4}', '\u{00C5}', '\u{00C6}', '\u{00C7}', '\u{00C8}', '\u{00C9}', '\u{00CA}', '\u{00CB}', '\u{00CC}', '\u{00CD}', '\u{00CE}', '\u{00CF}', '\u{00D0}', '\u{00D1}', '\u{00D2}', '\u{00D3}', '\u{00D4}', '\u{00D5}', '\u{00D6}', '\u{00D8}', '\u{00D9}', '\u{00DA}', '\u{00DB}', '\u{00DC}', '\u{00DD}', '\u{00DE}', '\u{0100}', '\u{0102}', '\u{0104}', '\u{0106}', '\u{0108}', '\u{010A}', '\u{010C}', '\u{010E}', '\u{0110}', '\u{0112}', '\u{0114}', '\u{0116}', '\u{0118}', '\u{011A}', '\u{011C}', '\u{011E}', '\u{0120}', '\u{0122}', '\u{0124}', '\u{0126}', '\u{0128}', '\u{012A}', '\u{012C}', '\u{012E}', '\u{0130}', '\u{0132}', '\u{0134}', '\u{0136}', '\u{0139}', '\u{013B}', '\u{013D}', '\u{013F}', '\u{0141}', '\u{0143}', '\u{0145}', '\u{0147}', '\u{014A}', '\u{014C}', '\u{014E}', '\u{0150}', '\u{0152}', '\u{0154}', '\u{0156}', '\u{0158}', '\u{015A}', '\u{015C}', '\u{015E}', '\u{0160}', '\u{0162}', '\u{0164}', '\u{0166}', '\u{0168}', '\u{016A}', '\u{016C}', '\u{016E}', '\u{0170}', '\u{0172}', '\u{0174}', '\u{0176}', '\u{0178}', '\u{0179}', '\u{017B}', '\u{017D}', '\u{0181}', '\u{0182}', '\u{0184}', '\u{0186}', '\u{0187}', '\u{0189}', '\u{018A}', '\u{018B}', '\u{018E}', '\u{018F}', '\u{0190}', '\u{0191}', '\u{0193}', '\u{0194}', '\u{0196}', '\u{0197}', '\u{0198}', '\u{019C}', '\u{019D}', '\u{019F}', '\u{01A0}', '\u{01A2}', '\u{01A4}', '\u{01A6}', '\u{01A7}', '\u{01A9}', '\u{01AC}', '\u{01AE}', '\u{01AF}', '\u{01B1}', '\u{01B2}', '\u{01B3}', '\u{01B5}', '\u{01B7}', '\u{01B8}', '\u{01BC}', '\u{01C4}', '\u{01C7}', '\u{01CA}', '\u{01CD}', '\u{01CF}', '\u{01D1}', '\u{01D3}', '\u{01D5}', '\u{01D7}', '\u{01D9}', '\u{01DB}', '\u{01DE}', '\u{01E0}', '\u{01E2}', '\u{01E4}', '\u{01E6}', '\u{01E8}', '\u{01EA}', '\u{01EC}', '\u{01EE}', '\u{01F1}', '\u{01F4}', '\u{01F6}', '\u{01F7}', '\u{01F8}', '\u{01FA}', '\u{01FC}', '\u{01FE}', '\u{0200}', '\u{0202}', '\u{0204}', '\u{0206}', '\u{0208}', '\u{020A}', '\u{020C}', '\u{020E}', '\u{0210}', '\u{0212}', '\u{0214}', '\u{0216}', '\u{0218}', '\u{021A}', '\u{021C}', '\u{021E}', '\u{0220}', '\u{0222}', '\u{0224}', '\u{0226}', '\u{0228}', '\u{022A}', '\u{022C}', '\u{022E}', '\u{0230}', '\u{0232}', '\u{023A}', '\u{023B}', '\u{023D}', '\u{023E}', '\u{0241}', '\u{0243}', '\u{0244}', '\u{0245}', '\u{0246}', '\u{0248}', '\u{024A}', '\u{024C}', '\u{024E}', '\u{0370}', '\u{0372}', '\u{0376}', '\u{0386}', '\u{0388}', '\u{0389}', '\u{038A}', '\u{038C}', '\u{038E}', '\u{038F}', '\u{0391}', '\u{0392}', '\u{0393}', '\u{0394}', '\u{0395}', '\u{0396}', '\u{0397}', '\u{0398}', '\u{0399}', '\u{039A}', '\u{039B}', '\u{039C}', '\u{039D}', '\u{039E}', '\u{039F}', '\u{03A0}', '\u{03A1}', '\u{03A3}', '\u{03A4}', '\u{03A5}', '\u{03A6}', '\u{03A7}', '\u{03A8}', '\u{03A9}', '\u{03AA}', '\u{03AB}', '\u{03CF}', '\u{03D2}', '\u{03D3}', '\u{03D4}', '\u{03D8}', '\u{03DA}', '\u{03DC}', '\u{03DE}', '\u{03E0}', '\u{03E2}', '\u{03E4}', '\u{03E6}', '\u{03E8}', '\u{03EA}', '\u{03EC}', '\u{03EE}', '\u{03F4}', '\u{03F7}', '\u{03F9}', '\u{03FA}', '\u{03FD}', '\u{03FE}', '\u{03FF}', '\u{0400}', '\u{0401}', '\u{0402}', '\u{0403}', '\u{0404}', '\u{0405}', '\u{0406}', '\u{0407}', '\u{0408}', '\u{0409}', '\u{040A}', '\u{040B}', '\u{040C}', '\u{040D}', '\u{040E}', '\u{040F}', '\u{0410}', '\u{0411}', '\u{0412}', '\u{0413}', '\u{0414}', '\u{0415}', '\u{0416}', '\u{0417}', '\u{0418}', '\u{0419}', '\u{041A}', '\u{041B}', '\u{041C}', '\u{041D}', '\u{041E}', '\u{041F}', '\u{0420}', '\u{0421}', '\u{0422}', '\u{0423}', '\u{0424}', '\u{0425}', '\u{0426}', '\u{0427}', '\u{0428}', '\u{0429}', '\u{042A}', '\u{042B}', '\u{042C}', '\u{042D}', '\u{042E}', '\u{042F}', '\u{0460}', '\u{0462}', '\u{0464}', '\u{0466}', '\u{0468}', '\u{046A}', '\u{046C}', '\u{046E}', '\u{0470}', '\u{0472}', '\u{0474}', '\u{0476}', '\u{0478}', '\u{047A}', '\u{047C}', '\u{047E}', '\u{0480}', '\u{048A}', '\u{048C}', '\u{048E}', '\u{0490}', '\u{0492}', '\u{0494}', '\u{0496}', '\u{0498}', '\u{049A}', '\u{049C}', '\u{049E}', '\u{04A0}', '\u{04A2}', '\u{04A4}', '\u{04A6}', '\u{04A8}', '\u{04AA}', '\u{04AC}', '\u{04AE}', '\u{04B0}', '\u{04B2}', '\u{04B4}', '\u{04B6}', '\u{04B8}', '\u{04BA}', '\u{04BC}', '\u{04BE}', '\u{04C0}', '\u{04C1}', '\u{04C3}', '\u{04C5}', '\u{04C7}', '\u{04C9}', '\u{04CB}', '\u{04CD}', '\u{04D0}', '\u{04D2}', '\u{04D4}', '\u{04D6}', '\u{04D8}', '\u{04DA}', '\u{04DC}', '\u{04DE}', '\u{04E0}', '\u{04E2}', '\u{04E4}', '\u{04E6}', '\u{04E8}', '\u{04EA}', '\u{04EC}', '\u{04EE}', '\u{04F0}', '\u{04F2}', '\u{04F4}', '\u{04F6}', '\u{04F8}', '\u{04FA}', '\u{04FC}', '\u{04FE}', '\u{0500}', '\u{0502}', '\u{0504}', '\u{0506}', '\u{0508}', '\u{050A}', '\u{050C}', '\u{050E}', '\u{0510}', '\u{0512}', '\u{0514}', '\u{0516}', '\u{0518}', '\u{051A}', '\u{051C}', '\u{051E}', '\u{0520}', '\u{0522}', '\u{0531}', '\u{0532}', '\u{0533}', '\u{0534}', '\u{0535}', '\u{0536}', '\u{0537}', '\u{0538}', '\u{0539}', '\u{053A}', '\u{053B}', '\u{053C}', '\u{053D}', '\u{053E}', '\u{053F}', '\u{0540}', '\u{0541}', '\u{0542}', '\u{0543}', '\u{0544}', '\u{0545}', '\u{0546}', '\u{0547}', '\u{0548}', '\u{0549}', '\u{054A}', '\u{054B}', '\u{054C}', '\u{054D}', '\u{054E}', '\u{054F}', '\u{0550}', '\u{0551}', '\u{0552}', '\u{0553}', '\u{0554}', '\u{0555}', '\u{0556}', '\u{10A0}', '\u{10A1}', '\u{10A2}', '\u{10A3}', '\u{10A4}', '\u{10A5}', '\u{10A6}', '\u{10A7}', '\u{10A8}', '\u{10A9}', '\u{10AA}', '\u{10AB}', '\u{10AC}', '\u{10AD}', '\u{10AE}', '\u{10AF}', '\u{10B0}', '\u{10B1}', '\u{10B2}', '\u{10B3}', '\u{10B4}', '\u{10B5}', '\u{10B6}', '\u{10B7}', '\u{10B8}', '\u{10B9}', '\u{10BA}', '\u{10BB}', '\u{10BC}', '\u{10BD}', '\u{10BE}', '\u{10BF}', '\u{10C0}', '\u{10C1}', '\u{10C2}', '\u{10C3}', '\u{10C4}', '\u{10C5}', '\u{1E00}', '\u{1E02}', '\u{1E04}', '\u{1E06}', '\u{1E08}', '\u{1E0A}', '\u{1E0C}', '\u{1E0E}', '\u{1E10}', '\u{1E12}', '\u{1E14}', '\u{1E16}', '\u{1E18}', '\u{1E1A}', '\u{1E1C}', '\u{1E1E}', '\u{1E20}', '\u{1E22}', '\u{1E24}', '\u{1E26}', '\u{1E28}', '\u{1E2A}', '\u{1E2C}', '\u{1E2E}', '\u{1E30}', '\u{1E32}', '\u{1E34}', '\u{1E36}', '\u{1E38}', '\u{1E3A}', '\u{1E3C}', '\u{1E3E}', '\u{1E40}', '\u{1E42}', '\u{1E44}', '\u{1E46}', '\u{1E48}', '\u{1E4A}', '\u{1E4C}', '\u{1E4E}', '\u{1E50}', '\u{1E52}', '\u{1E54}', '\u{1E56}', '\u{1E58}', '\u{1E5A}', '\u{1E5C}', '\u{1E5E}', '\u{1E60}', '\u{1E62}', '\u{1E64}', '\u{1E66}', '\u{1E68}', '\u{1E6A}', '\u{1E6C}', '\u{1E6E}', '\u{1E70}', '\u{1E72}', '\u{1E74}', '\u{1E76}', '\u{1E78}', '\u{1E7A}', '\u{1E7C}', '\u{1E7E}', '\u{1E80}', '\u{1E82}', '\u{1E84}', '\u{1E86}', '\u{1E88}', '\u{1E8A}', '\u{1E8C}', '\u{1E8E}', '\u{1E90}', '\u{1E92}', '\u{1E94}', '\u{1E9E}', '\u{1EA0}', '\u{1EA2}', '\u{1EA4}', '\u{1EA6}', '\u{1EA8}', '\u{1EAA}', '\u{1EAC}', '\u{1EAE}', '\u{1EB0}', '\u{1EB2}', '\u{1EB4}', '\u{1EB6}', '\u{1EB8}', '\u{1EBA}', '\u{1EBC}', '\u{1EBE}', '\u{1EC0}', '\u{1EC2}', '\u{1EC4}', '\u{1EC6}', '\u{1EC8}', '\u{1ECA}', '\u{1ECC}', '\u{1ECE}', '\u{1ED0}', '\u{1ED2}', '\u{1ED4}', '\u{1ED6}', '\u{1ED8}', '\u{1EDA}', '\u{1EDC}', '\u{1EDE}', '\u{1EE0}', '\u{1EE2}', '\u{1EE4}', '\u{1EE6}', '\u{1EE8}', '\u{1EEA}', '\u{1EEC}', '\u{1EEE}', '\u{1EF0}', '\u{1EF2}', '\u{1EF4}', '\u{1EF6}', '\u{1EF8}', '\u{1EFA}', '\u{1EFC}', '\u{1EFE}', '\u{1F08}', '\u{1F09}', '\u{1F0A}', '\u{1F0B}', '\u{1F0C}', '\u{1F0D}', '\u{1F0E}', '\u{1F0F}', '\u{1F18}', '\u{1F19}', '\u{1F1A}', '\u{1F1B}', '\u{1F1C}', '\u{1F1D}', '\u{1F28}', '\u{1F29}', '\u{1F2A}', '\u{1F2B}', '\u{1F2C}', '\u{1F2D}', '\u{1F2E}', '\u{1F2F}', '\u{1F38}', '\u{1F39}', '\u{1F3A}', '\u{1F3B}', '\u{1F3C}', '\u{1F3D}', '\u{1F3E}', '\u{1F3F}', '\u{1F48}', '\u{1F49}', '\u{1F4A}', '\u{1F4B}', '\u{1F4C}', '\u{1F4D}', '\u{1F59}', '\u{1F5B}', '\u{1F5D}', '\u{1F5F}', '\u{1F68}', '\u{1F69}', '\u{1F6A}', '\u{1F6B}', '\u{1F6C}', '\u{1F6D}', '\u{1F6E}', '\u{1F6F}', '\u{1FB8}', '\u{1FB9}', '\u{1FBA}', '\u{1FBB}', '\u{1FC8}', '\u{1FC9}', '\u{1FCA}', '\u{1FCB}', '\u{1FD8}', '\u{1FD9}', '\u{1FDA}', '\u{1FDB}', '\u{1FE8}', '\u{1FE9}', '\u{1FEA}', '\u{1FEB}', '\u{1FEC}', '\u{1FF8}', '\u{1FF9}', '\u{1FFA}', '\u{1FFB}', '\u{2102}', '\u{2107}', '\u{210B}', '\u{210C}', '\u{210D}', '\u{2110}', '\u{2111}', '\u{2112}', '\u{2115}', '\u{2119}', '\u{211A}', '\u{211B}', '\u{211C}', '\u{211D}', '\u{2124}', '\u{2126}', '\u{2128}', '\u{212A}', '\u{212B}', '\u{212C}', '\u{212D}', '\u{2130}', '\u{2131}', '\u{2132}', '\u{2133}', '\u{213E}', '\u{213F}', '\u{2145}', '\u{2183}', '\u{2C00}', '\u{2C01}', '\u{2C02}', '\u{2C03}', '\u{2C04}', '\u{2C05}', '\u{2C06}', '\u{2C07}', '\u{2C08}', '\u{2C09}', '\u{2C0A}', '\u{2C0B}', '\u{2C0C}', '\u{2C0D}', '\u{2C0E}', '\u{2C0F}', '\u{2C10}', '\u{2C11}', '\u{2C12}', '\u{2C13}', '\u{2C14}', '\u{2C15}', '\u{2C16}', '\u{2C17}', '\u{2C18}', '\u{2C19}', '\u{2C1A}', '\u{2C1B}', '\u{2C1C}', '\u{2C1D}', '\u{2C1E}', '\u{2C1F}', '\u{2C20}', '\u{2C21}', '\u{2C22}', '\u{2C23}', '\u{2C24}', '\u{2C25}', '\u{2C26}', '\u{2C27}', '\u{2C28}', '\u{2C29}', '\u{2C2A}', '\u{2C2B}', '\u{2C2C}', '\u{2C2D}', '\u{2C2E}', '\u{2C60}', '\u{2C62}', '\u{2C63}', '\u{2C64}', '\u{2C67}', '\u{2C69}', '\u{2C6B}', '\u{2C6D}', '\u{2C6E}', '\u{2C6F}', '\u{2C72}', '\u{2C75}', '\u{2C80}', '\u{2C82}', '\u{2C84}', '\u{2C86}', '\u{2C88}', '\u{2C8A}', '\u{2C8C}', '\u{2C8E}', '\u{2C90}', '\u{2C92}', '\u{2C94}', '\u{2C96}', '\u{2C98}', '\u{2C9A}', '\u{2C9C}', '\u{2C9E}', '\u{2CA0}', '\u{2CA2}', '\u{2CA4}', '\u{2CA6}', '\u{2CA8}', '\u{2CAA}', '\u{2CAC}', '\u{2CAE}', '\u{2CB0}', '\u{2CB2}', '\u{2CB4}', '\u{2CB6}', '\u{2CB8}', '\u{2CBA}', '\u{2CBC}', '\u{2CBE}', '\u{2CC0}', '\u{2CC2}', '\u{2CC4}', '\u{2CC6}', '\u{2CC8}', '\u{2CCA}', '\u{2CCC}', '\u{2CCE}', '\u{2CD0}', '\u{2CD2}', '\u{2CD4}', '\u{2CD6}', '\u{2CD8}', '\u{2CDA}', '\u{2CDC}', '\u{2CDE}', '\u{2CE0}', '\u{2CE2}', '\u{A640}', '\u{A642}', '\u{A644}', '\u{A646}', '\u{A648}', '\u{A64A}', '\u{A64C}', '\u{A64E}', '\u{A650}', '\u{A652}', '\u{A654}', '\u{A656}', '\u{A658}', '\u{A65A}', '\u{A65C}', '\u{A65E}', '\u{A662}', '\u{A664}', '\u{A666}', '\u{A668}', '\u{A66A}', '\u{A66C}', '\u{A680}', '\u{A682}', '\u{A684}', '\u{A686}', '\u{A688}', '\u{A68A}', '\u{A68C}', '\u{A68E}', '\u{A690}', '\u{A692}', '\u{A694}', '\u{A696}', '\u{A722}', '\u{A724}', '\u{A726}', '\u{A728}', '\u{A72A}', '\u{A72C}', '\u{A72E}', '\u{A732}', '\u{A734}', '\u{A736}', '\u{A738}', '\u{A73A}', '\u{A73C}', '\u{A73E}', '\u{A740}', '\u{A742}', '\u{A744}', '\u{A746}', '\u{A748}', '\u{A74A}', '\u{A74C}', '\u{A74E}', '\u{A750}', '\u{A752}', '\u{A754}', '\u{A756}', '\u{A758}', '\u{A75A}', '\u{A75C}', '\u{A75E}', '\u{A760}', '\u{A762}', '\u{A764}', '\u{A766}', '\u{A768}', '\u{A76A}', '\u{A76C}', '\u{A76E}', '\u{A779}', '\u{A77B}', '\u{A77D}', '\u{A77E}', '\u{A780}', '\u{A782}', '\u{A784}', '\u{A786}', '\u{A78B}', '\u{FF21}', '\u{FF22}', '\u{FF23}', '\u{FF24}', '\u{FF25}', '\u{FF26}', '\u{FF27}', '\u{FF28}', '\u{FF29}', '\u{FF2A}', '\u{FF2B}', '\u{FF2C}', '\u{FF2D}', '\u{FF2E}', '\u{FF2F}', '\u{FF30}', '\u{FF31}', '\u{FF32}', '\u{FF33}', '\u{FF34}', '\u{FF35}', '\u{FF36}', '\u{FF37}', '\u{FF38}', '\u{FF39}', '\u{FF3A}') + } + + fn is_unicode_lowercase_letter(self) -> bool { + match_char_class!(self, + '\u{0061}', '\u{0062}', '\u{0063}', '\u{0064}', '\u{0065}', '\u{0066}', '\u{0067}', '\u{0068}', '\u{0069}', '\u{006A}', '\u{006B}', '\u{006C}', '\u{006D}', '\u{006E}', '\u{006F}', '\u{0070}', '\u{0071}', '\u{0072}', '\u{0073}', '\u{0074}', '\u{0075}', '\u{0076}', '\u{0077}', '\u{0078}', '\u{0079}', '\u{007A}', '\u{00AA}', '\u{00B5}', '\u{00BA}', '\u{00DF}', '\u{00E0}', '\u{00E1}', '\u{00E2}', '\u{00E3}', '\u{00E4}', '\u{00E5}', '\u{00E6}', '\u{00E7}', '\u{00E8}', '\u{00E9}', '\u{00EA}', '\u{00EB}', '\u{00EC}', '\u{00ED}', '\u{00EE}', '\u{00EF}', '\u{00F0}', '\u{00F1}', '\u{00F2}', '\u{00F3}', '\u{00F4}', '\u{00F5}', '\u{00F6}', '\u{00F8}', '\u{00F9}', '\u{00FA}', '\u{00FB}', '\u{00FC}', '\u{00FD}', '\u{00FE}', '\u{00FF}', '\u{0101}', '\u{0103}', '\u{0105}', '\u{0107}', '\u{0109}', '\u{010B}', '\u{010D}', '\u{010F}', '\u{0111}', '\u{0113}', '\u{0115}', '\u{0117}', '\u{0119}', '\u{011B}', '\u{011D}', '\u{011F}', '\u{0121}', '\u{0123}', '\u{0125}', '\u{0127}', '\u{0129}', '\u{012B}', '\u{012D}', '\u{012F}', '\u{0131}', '\u{0133}', '\u{0135}', '\u{0137}', '\u{0138}', '\u{013A}', '\u{013C}', '\u{013E}', '\u{0140}', '\u{0142}', '\u{0144}', '\u{0146}', '\u{0148}', '\u{0149}', '\u{014B}', '\u{014D}', '\u{014F}', '\u{0151}', '\u{0153}', '\u{0155}', '\u{0157}', '\u{0159}', '\u{015B}', '\u{015D}', '\u{015F}', '\u{0161}', '\u{0163}', '\u{0165}', '\u{0167}', '\u{0169}', '\u{016B}', '\u{016D}', '\u{016F}', '\u{0171}', '\u{0173}', '\u{0175}', '\u{0177}', '\u{017A}', '\u{017C}', '\u{017E}', '\u{017F}', '\u{0180}', '\u{0183}', '\u{0185}', '\u{0188}', '\u{018C}', '\u{018D}', '\u{0192}', '\u{0195}', '\u{0199}', '\u{019A}', '\u{019B}', '\u{019E}', '\u{01A1}', '\u{01A3}', '\u{01A5}', '\u{01A8}', '\u{01AA}', '\u{01AB}', '\u{01AD}', '\u{01B0}', '\u{01B4}', '\u{01B6}', '\u{01B9}', '\u{01BA}', '\u{01BD}', '\u{01BE}', '\u{01BF}', '\u{01C6}', '\u{01C9}', '\u{01CC}', '\u{01CE}', '\u{01D0}', '\u{01D2}', '\u{01D4}', '\u{01D6}', '\u{01D8}', '\u{01DA}', '\u{01DC}', '\u{01DD}', '\u{01DF}', '\u{01E1}', '\u{01E3}', '\u{01E5}', '\u{01E7}', '\u{01E9}', '\u{01EB}', '\u{01ED}', '\u{01EF}', '\u{01F0}', '\u{01F3}', '\u{01F5}', '\u{01F9}', '\u{01FB}', '\u{01FD}', '\u{01FF}', '\u{0201}', '\u{0203}', '\u{0205}', '\u{0207}', '\u{0209}', '\u{020B}', '\u{020D}', '\u{020F}', '\u{0211}', '\u{0213}', '\u{0215}', '\u{0217}', '\u{0219}', '\u{021B}', '\u{021D}', '\u{021F}', '\u{0221}', '\u{0223}', '\u{0225}', '\u{0227}', '\u{0229}', '\u{022B}', '\u{022D}', '\u{022F}', '\u{0231}', '\u{0233}', '\u{0234}', '\u{0235}', '\u{0236}', '\u{0237}', '\u{0238}', '\u{0239}', '\u{023C}', '\u{023F}', '\u{0240}', '\u{0242}', '\u{0247}', '\u{0249}', '\u{024B}', '\u{024D}', '\u{024F}', '\u{0250}', '\u{0251}', '\u{0252}', '\u{0253}', '\u{0254}', '\u{0255}', '\u{0256}', '\u{0257}', '\u{0258}', '\u{0259}', '\u{025A}', '\u{025B}', '\u{025C}', '\u{025D}', '\u{025E}', '\u{025F}', '\u{0260}', '\u{0261}', '\u{0262}', '\u{0263}', '\u{0264}', '\u{0265}', '\u{0266}', '\u{0267}', '\u{0268}', '\u{0269}', '\u{026A}', '\u{026B}', '\u{026C}', '\u{026D}', '\u{026E}', '\u{026F}', '\u{0270}', '\u{0271}', '\u{0272}', '\u{0273}', '\u{0274}', '\u{0275}', '\u{0276}', '\u{0277}', '\u{0278}', '\u{0279}', '\u{027A}', '\u{027B}', '\u{027C}', '\u{027D}', '\u{027E}', '\u{027F}', '\u{0280}', '\u{0281}', '\u{0282}', '\u{0283}', '\u{0284}', '\u{0285}', '\u{0286}', '\u{0287}', '\u{0288}', '\u{0289}', '\u{028A}', '\u{028B}', '\u{028C}', '\u{028D}', '\u{028E}', '\u{028F}', '\u{0290}', '\u{0291}', '\u{0292}', '\u{0293}', '\u{0295}', '\u{0296}', '\u{0297}', '\u{0298}', '\u{0299}', '\u{029A}', '\u{029B}', '\u{029C}', '\u{029D}', '\u{029E}', '\u{029F}', '\u{02A0}', '\u{02A1}', '\u{02A2}', '\u{02A3}', '\u{02A4}', '\u{02A5}', '\u{02A6}', '\u{02A7}', '\u{02A8}', '\u{02A9}', '\u{02AA}', '\u{02AB}', '\u{02AC}', '\u{02AD}', '\u{02AE}', '\u{02AF}', '\u{0371}', '\u{0373}', '\u{0377}', '\u{037B}', '\u{037C}', '\u{037D}', '\u{0390}', '\u{03AC}', '\u{03AD}', '\u{03AE}', '\u{03AF}', '\u{03B0}', '\u{03B1}', '\u{03B2}', '\u{03B3}', '\u{03B4}', '\u{03B5}', '\u{03B6}', '\u{03B7}', '\u{03B8}', '\u{03B9}', '\u{03BA}', '\u{03BB}', '\u{03BC}', '\u{03BD}', '\u{03BE}', '\u{03BF}', '\u{03C0}', '\u{03C1}', '\u{03C2}', '\u{03C3}', '\u{03C4}', '\u{03C5}', '\u{03C6}', '\u{03C7}', '\u{03C8}', '\u{03C9}', '\u{03CA}', '\u{03CB}', '\u{03CC}', '\u{03CD}', '\u{03CE}', '\u{03D0}', '\u{03D1}', '\u{03D5}', '\u{03D6}', '\u{03D7}', '\u{03D9}', '\u{03DB}', '\u{03DD}', '\u{03DF}', '\u{03E1}', '\u{03E3}', '\u{03E5}', '\u{03E7}', '\u{03E9}', '\u{03EB}', '\u{03ED}', '\u{03EF}', '\u{03F0}', '\u{03F1}', '\u{03F2}', '\u{03F3}', '\u{03F5}', '\u{03F8}', '\u{03FB}', '\u{03FC}', '\u{0430}', '\u{0431}', '\u{0432}', '\u{0433}', '\u{0434}', '\u{0435}', '\u{0436}', '\u{0437}', '\u{0438}', '\u{0439}', '\u{043A}', '\u{043B}', '\u{043C}', '\u{043D}', '\u{043E}', '\u{043F}', '\u{0440}', '\u{0441}', '\u{0442}', '\u{0443}', '\u{0444}', '\u{0445}', '\u{0446}', '\u{0447}', '\u{0448}', '\u{0449}', '\u{044A}', '\u{044B}', '\u{044C}', '\u{044D}', '\u{044E}', '\u{044F}', '\u{0450}', '\u{0451}', '\u{0452}', '\u{0453}', '\u{0454}', '\u{0455}', '\u{0456}', '\u{0457}', '\u{0458}', '\u{0459}', '\u{045A}', '\u{045B}', '\u{045C}', '\u{045D}', '\u{045E}', '\u{045F}', '\u{0461}', '\u{0463}', '\u{0465}', '\u{0467}', '\u{0469}', '\u{046B}', '\u{046D}', '\u{046F}', '\u{0471}', '\u{0473}', '\u{0475}', '\u{0477}', '\u{0479}', '\u{047B}', '\u{047D}', '\u{047F}', '\u{0481}', '\u{048B}', '\u{048D}', '\u{048F}', '\u{0491}', '\u{0493}', '\u{0495}', '\u{0497}', '\u{0499}', '\u{049B}', '\u{049D}', '\u{049F}', '\u{04A1}', '\u{04A3}', '\u{04A5}', '\u{04A7}', '\u{04A9}', '\u{04AB}', '\u{04AD}', '\u{04AF}', '\u{04B1}', '\u{04B3}', '\u{04B5}', '\u{04B7}', '\u{04B9}', '\u{04BB}', '\u{04BD}', '\u{04BF}', '\u{04C2}', '\u{04C4}', '\u{04C6}', '\u{04C8}', '\u{04CA}', '\u{04CC}', '\u{04CE}', '\u{04CF}', '\u{04D1}', '\u{04D3}', '\u{04D5}', '\u{04D7}', '\u{04D9}', '\u{04DB}', '\u{04DD}', '\u{04DF}', '\u{04E1}', '\u{04E3}', '\u{04E5}', '\u{04E7}', '\u{04E9}', '\u{04EB}', '\u{04ED}', '\u{04EF}', '\u{04F1}', '\u{04F3}', '\u{04F5}', '\u{04F7}', '\u{04F9}', '\u{04FB}', '\u{04FD}', '\u{04FF}', '\u{0501}', '\u{0503}', '\u{0505}', '\u{0507}', '\u{0509}', '\u{050B}', '\u{050D}', '\u{050F}', '\u{0511}', '\u{0513}', '\u{0515}', '\u{0517}', '\u{0519}', '\u{051B}', '\u{051D}', '\u{051F}', '\u{0521}', '\u{0523}', '\u{0561}', '\u{0562}', '\u{0563}', '\u{0564}', '\u{0565}', '\u{0566}', '\u{0567}', '\u{0568}', '\u{0569}', '\u{056A}', '\u{056B}', '\u{056C}', '\u{056D}', '\u{056E}', '\u{056F}', '\u{0570}', '\u{0571}', '\u{0572}', '\u{0573}', '\u{0574}', '\u{0575}', '\u{0576}', '\u{0577}', '\u{0578}', '\u{0579}', '\u{057A}', '\u{057B}', '\u{057C}', '\u{057D}', '\u{057E}', '\u{057F}', '\u{0580}', '\u{0581}', '\u{0582}', '\u{0583}', '\u{0584}', '\u{0585}', '\u{0586}', '\u{0587}', '\u{1D00}', '\u{1D01}', '\u{1D02}', '\u{1D03}', '\u{1D04}', '\u{1D05}', '\u{1D06}', '\u{1D07}', '\u{1D08}', '\u{1D09}', '\u{1D0A}', '\u{1D0B}', '\u{1D0C}', '\u{1D0D}', '\u{1D0E}', '\u{1D0F}', '\u{1D10}', '\u{1D11}', '\u{1D12}', '\u{1D13}', '\u{1D14}', '\u{1D15}', '\u{1D16}', '\u{1D17}', '\u{1D18}', '\u{1D19}', '\u{1D1A}', '\u{1D1B}', '\u{1D1C}', '\u{1D1D}', '\u{1D1E}', '\u{1D1F}', '\u{1D20}', '\u{1D21}', '\u{1D22}', '\u{1D23}', '\u{1D24}', '\u{1D25}', '\u{1D26}', '\u{1D27}', '\u{1D28}', '\u{1D29}', '\u{1D2A}', '\u{1D2B}', '\u{1D62}', '\u{1D63}', '\u{1D64}', '\u{1D65}', '\u{1D66}', '\u{1D67}', '\u{1D68}', '\u{1D69}', '\u{1D6A}', '\u{1D6B}', '\u{1D6C}', '\u{1D6D}', '\u{1D6E}', '\u{1D6F}', '\u{1D70}', '\u{1D71}', '\u{1D72}', '\u{1D73}', '\u{1D74}', '\u{1D75}', '\u{1D76}', '\u{1D77}', '\u{1D79}', '\u{1D7A}', '\u{1D7B}', '\u{1D7C}', '\u{1D7D}', '\u{1D7E}', '\u{1D7F}', '\u{1D80}', '\u{1D81}', '\u{1D82}', '\u{1D83}', '\u{1D84}', '\u{1D85}', '\u{1D86}', '\u{1D87}', '\u{1D88}', '\u{1D89}', '\u{1D8A}', '\u{1D8B}', '\u{1D8C}', '\u{1D8D}', '\u{1D8E}', '\u{1D8F}', '\u{1D90}', '\u{1D91}', '\u{1D92}', '\u{1D93}', '\u{1D94}', '\u{1D95}', '\u{1D96}', '\u{1D97}', '\u{1D98}', '\u{1D99}', '\u{1D9A}', '\u{1E01}', '\u{1E03}', '\u{1E05}', '\u{1E07}', '\u{1E09}', '\u{1E0B}', '\u{1E0D}', '\u{1E0F}', '\u{1E11}', '\u{1E13}', '\u{1E15}', '\u{1E17}', '\u{1E19}', '\u{1E1B}', '\u{1E1D}', '\u{1E1F}', '\u{1E21}', '\u{1E23}', '\u{1E25}', '\u{1E27}', '\u{1E29}', '\u{1E2B}', '\u{1E2D}', '\u{1E2F}', '\u{1E31}', '\u{1E33}', '\u{1E35}', '\u{1E37}', '\u{1E39}', '\u{1E3B}', '\u{1E3D}', '\u{1E3F}', '\u{1E41}', '\u{1E43}', '\u{1E45}', '\u{1E47}', '\u{1E49}', '\u{1E4B}', '\u{1E4D}', '\u{1E4F}', '\u{1E51}', '\u{1E53}', '\u{1E55}', '\u{1E57}', '\u{1E59}', '\u{1E5B}', '\u{1E5D}', '\u{1E5F}', '\u{1E61}', '\u{1E63}', '\u{1E65}', '\u{1E67}', '\u{1E69}', '\u{1E6B}', '\u{1E6D}', '\u{1E6F}', '\u{1E71}', '\u{1E73}', '\u{1E75}', '\u{1E77}', '\u{1E79}', '\u{1E7B}', '\u{1E7D}', '\u{1E7F}', '\u{1E81}', '\u{1E83}', '\u{1E85}', '\u{1E87}', '\u{1E89}', '\u{1E8B}', '\u{1E8D}', '\u{1E8F}', '\u{1E91}', '\u{1E93}', '\u{1E95}', '\u{1E96}', '\u{1E97}', '\u{1E98}', '\u{1E99}', '\u{1E9A}', '\u{1E9B}', '\u{1E9C}', '\u{1E9D}', '\u{1E9F}', '\u{1EA1}', '\u{1EA3}', '\u{1EA5}', '\u{1EA7}', '\u{1EA9}', '\u{1EAB}', '\u{1EAD}', '\u{1EAF}', '\u{1EB1}', '\u{1EB3}', '\u{1EB5}', '\u{1EB7}', '\u{1EB9}', '\u{1EBB}', '\u{1EBD}', '\u{1EBF}', '\u{1EC1}', '\u{1EC3}', '\u{1EC5}', '\u{1EC7}', '\u{1EC9}', '\u{1ECB}', '\u{1ECD}', '\u{1ECF}', '\u{1ED1}', '\u{1ED3}', '\u{1ED5}', '\u{1ED7}', '\u{1ED9}', '\u{1EDB}', '\u{1EDD}', '\u{1EDF}', '\u{1EE1}', '\u{1EE3}', '\u{1EE5}', '\u{1EE7}', '\u{1EE9}', '\u{1EEB}', '\u{1EED}', '\u{1EEF}', '\u{1EF1}', '\u{1EF3}', '\u{1EF5}', '\u{1EF7}', '\u{1EF9}', '\u{1EFB}', '\u{1EFD}', '\u{1EFF}', '\u{1F00}', '\u{1F01}', '\u{1F02}', '\u{1F03}', '\u{1F04}', '\u{1F05}', '\u{1F06}', '\u{1F07}', '\u{1F10}', '\u{1F11}', '\u{1F12}', '\u{1F13}', '\u{1F14}', '\u{1F15}', '\u{1F20}', '\u{1F21}', '\u{1F22}', '\u{1F23}', '\u{1F24}', '\u{1F25}', '\u{1F26}', '\u{1F27}', '\u{1F30}', '\u{1F31}', '\u{1F32}', '\u{1F33}', '\u{1F34}', '\u{1F35}', '\u{1F36}', '\u{1F37}', '\u{1F40}', '\u{1F41}', '\u{1F42}', '\u{1F43}', '\u{1F44}', '\u{1F45}', '\u{1F50}', '\u{1F51}', '\u{1F52}', '\u{1F53}', '\u{1F54}', '\u{1F55}', '\u{1F56}', '\u{1F57}', '\u{1F60}', '\u{1F61}', '\u{1F62}', '\u{1F63}', '\u{1F64}', '\u{1F65}', '\u{1F66}', '\u{1F67}', '\u{1F70}', '\u{1F71}', '\u{1F72}', '\u{1F73}', '\u{1F74}', '\u{1F75}', '\u{1F76}', '\u{1F77}', '\u{1F78}', '\u{1F79}', '\u{1F7A}', '\u{1F7B}', '\u{1F7C}', '\u{1F7D}', '\u{1F80}', '\u{1F81}', '\u{1F82}', '\u{1F83}', '\u{1F84}', '\u{1F85}', '\u{1F86}', '\u{1F87}', '\u{1F90}', '\u{1F91}', '\u{1F92}', '\u{1F93}', '\u{1F94}', '\u{1F95}', '\u{1F96}', '\u{1F97}', '\u{1FA0}', '\u{1FA1}', '\u{1FA2}', '\u{1FA3}', '\u{1FA4}', '\u{1FA5}', '\u{1FA6}', '\u{1FA7}', '\u{1FB0}', '\u{1FB1}', '\u{1FB2}', '\u{1FB3}', '\u{1FB4}', '\u{1FB6}', '\u{1FB7}', '\u{1FBE}', '\u{1FC2}', '\u{1FC3}', '\u{1FC4}', '\u{1FC6}', '\u{1FC7}', '\u{1FD0}', '\u{1FD1}', '\u{1FD2}', '\u{1FD3}', '\u{1FD6}', '\u{1FD7}', '\u{1FE0}', '\u{1FE1}', '\u{1FE2}', '\u{1FE3}', '\u{1FE4}', '\u{1FE5}', '\u{1FE6}', '\u{1FE7}', '\u{1FF2}', '\u{1FF3}', '\u{1FF4}', '\u{1FF6}', '\u{1FF7}', '\u{2071}', '\u{207F}', '\u{210A}', '\u{210E}', '\u{210F}', '\u{2113}', '\u{212F}', '\u{2134}', '\u{2139}', '\u{213C}', '\u{213D}', '\u{2146}', '\u{2147}', '\u{2148}', '\u{2149}', '\u{214E}', '\u{2184}', '\u{2C30}', '\u{2C31}', '\u{2C32}', '\u{2C33}', '\u{2C34}', '\u{2C35}', '\u{2C36}', '\u{2C37}', '\u{2C38}', '\u{2C39}', '\u{2C3A}', '\u{2C3B}', '\u{2C3C}', '\u{2C3D}', '\u{2C3E}', '\u{2C3F}', '\u{2C40}', '\u{2C41}', '\u{2C42}', '\u{2C43}', '\u{2C44}', '\u{2C45}', '\u{2C46}', '\u{2C47}', '\u{2C48}', '\u{2C49}', '\u{2C4A}', '\u{2C4B}', '\u{2C4C}', '\u{2C4D}', '\u{2C4E}', '\u{2C4F}', '\u{2C50}', '\u{2C51}', '\u{2C52}', '\u{2C53}', '\u{2C54}', '\u{2C55}', '\u{2C56}', '\u{2C57}', '\u{2C58}', '\u{2C59}', '\u{2C5A}', '\u{2C5B}', '\u{2C5C}', '\u{2C5D}', '\u{2C5E}', '\u{2C61}', '\u{2C65}', '\u{2C66}', '\u{2C68}', '\u{2C6A}', '\u{2C6C}', '\u{2C71}', '\u{2C73}', '\u{2C74}', '\u{2C76}', '\u{2C77}', '\u{2C78}', '\u{2C79}', '\u{2C7A}', '\u{2C7B}', '\u{2C7C}', '\u{2C81}', '\u{2C83}', '\u{2C85}', '\u{2C87}', '\u{2C89}', '\u{2C8B}', '\u{2C8D}', '\u{2C8F}', '\u{2C91}', '\u{2C93}', '\u{2C95}', '\u{2C97}', '\u{2C99}', '\u{2C9B}', '\u{2C9D}', '\u{2C9F}', '\u{2CA1}', '\u{2CA3}', '\u{2CA5}', '\u{2CA7}', '\u{2CA9}', '\u{2CAB}', '\u{2CAD}', '\u{2CAF}', '\u{2CB1}', '\u{2CB3}', '\u{2CB5}', '\u{2CB7}', '\u{2CB9}', '\u{2CBB}', '\u{2CBD}', '\u{2CBF}', '\u{2CC1}', '\u{2CC3}', '\u{2CC5}', '\u{2CC7}', '\u{2CC9}', '\u{2CCB}', '\u{2CCD}', '\u{2CCF}', '\u{2CD1}', '\u{2CD3}', '\u{2CD5}', '\u{2CD7}', '\u{2CD9}', '\u{2CDB}', '\u{2CDD}', '\u{2CDF}', '\u{2CE1}', '\u{2CE3}', '\u{2CE4}', '\u{2D00}', '\u{2D01}', '\u{2D02}', '\u{2D03}', '\u{2D04}', '\u{2D05}', '\u{2D06}', '\u{2D07}', '\u{2D08}', '\u{2D09}', '\u{2D0A}', '\u{2D0B}', '\u{2D0C}', '\u{2D0D}', '\u{2D0E}', '\u{2D0F}', '\u{2D10}', '\u{2D11}', '\u{2D12}', '\u{2D13}', '\u{2D14}', '\u{2D15}', '\u{2D16}', '\u{2D17}', '\u{2D18}', '\u{2D19}', '\u{2D1A}', '\u{2D1B}', '\u{2D1C}', '\u{2D1D}', '\u{2D1E}', '\u{2D1F}', '\u{2D20}', '\u{2D21}', '\u{2D22}', '\u{2D23}', '\u{2D24}', '\u{2D25}', '\u{A641}', '\u{A643}', '\u{A645}', '\u{A647}', '\u{A649}', '\u{A64B}', '\u{A64D}', '\u{A64F}', '\u{A651}', '\u{A653}', '\u{A655}', '\u{A657}', '\u{A659}', '\u{A65B}', '\u{A65D}', '\u{A65F}', '\u{A663}', '\u{A665}', '\u{A667}', '\u{A669}', '\u{A66B}', '\u{A66D}', '\u{A681}', '\u{A683}', '\u{A685}', '\u{A687}', '\u{A689}', '\u{A68B}', '\u{A68D}', '\u{A68F}', '\u{A691}', '\u{A693}', '\u{A695}', '\u{A697}', '\u{A723}', '\u{A725}', '\u{A727}', '\u{A729}', '\u{A72B}', '\u{A72D}', '\u{A72F}', '\u{A730}', '\u{A731}', '\u{A733}', '\u{A735}', '\u{A737}', '\u{A739}', '\u{A73B}', '\u{A73D}', '\u{A73F}', '\u{A741}', '\u{A743}', '\u{A745}', '\u{A747}', '\u{A749}', '\u{A74B}', '\u{A74D}', '\u{A74F}', '\u{A751}', '\u{A753}', '\u{A755}', '\u{A757}', '\u{A759}', '\u{A75B}', '\u{A75D}', '\u{A75F}', '\u{A761}', '\u{A763}', '\u{A765}', '\u{A767}', '\u{A769}', '\u{A76B}', '\u{A76D}', '\u{A76F}', '\u{A771}', '\u{A772}', '\u{A773}', '\u{A774}', '\u{A775}', '\u{A776}', '\u{A777}', '\u{A778}', '\u{A77A}', '\u{A77C}', '\u{A77F}', '\u{A781}', '\u{A783}', '\u{A785}', '\u{A787}', '\u{A78C}', '\u{FB00}', '\u{FB01}', '\u{FB02}', '\u{FB03}', '\u{FB04}', '\u{FB05}', '\u{FB06}', '\u{FB13}', '\u{FB14}', '\u{FB15}', '\u{FB16}', '\u{FB17}', '\u{FF41}', '\u{FF42}', '\u{FF43}', '\u{FF44}', '\u{FF45}', '\u{FF46}', '\u{FF47}', '\u{FF48}', '\u{FF49}', '\u{FF4A}', '\u{FF4B}', '\u{FF4C}', '\u{FF4D}', '\u{FF4E}', '\u{FF4F}', '\u{FF50}', '\u{FF51}', '\u{FF52}', '\u{FF53}', '\u{FF54}', '\u{FF55}', '\u{FF56}', '\u{FF57}', '\u{FF58}', '\u{FF59}', '\u{FF5A}') + + } + + fn is_unicode_titlecase_letter(self) -> bool { + match_char_class!(self, + '\u{01C5}', '\u{01C8}', '\u{01CB}', '\u{01F2}', '\u{1F88}', '\u{1F89}', '\u{1F8A}', '\u{1F8B}', '\u{1F8C}', '\u{1F8D}', '\u{1F8E}', '\u{1F8F}', '\u{1F98}', '\u{1F99}', '\u{1F9A}', '\u{1F9B}', '\u{1F9C}', '\u{1F9D}', '\u{1F9E}', '\u{1F9F}', '\u{1FA8}', '\u{1FA9}', '\u{1FAA}', '\u{1FAB}', '\u{1FAC}', '\u{1FAD}', '\u{1FAE}', '\u{1FAF}', '\u{1FBC}', '\u{1FCC}') + } + + fn is_unicode_modifier_letter(self) -> bool { + match_char_class!(self, + '\u{02B0}', '\u{02B1}', '\u{02B2}', '\u{02B3}', '\u{02B4}', '\u{02B5}', '\u{02B6}', '\u{02B7}', '\u{02B8}', '\u{02B9}', '\u{02BA}', '\u{02BB}', '\u{02BC}', '\u{02BD}', '\u{02BE}', '\u{02BF}', '\u{02C0}', '\u{02C1}', '\u{02C6}', '\u{02C7}', '\u{02C8}', '\u{02C9}', '\u{02CA}', '\u{02CB}', '\u{02CC}', '\u{02CD}', '\u{02CE}', '\u{02CF}', '\u{02D0}', '\u{02D1}', '\u{02E0}', '\u{02E1}', '\u{02E2}', '\u{02E3}', '\u{02E4}', '\u{02EC}', '\u{02EE}', '\u{0374}', '\u{037A}', '\u{0559}', '\u{0640}', '\u{06E5}', '\u{06E6}', '\u{07F4}', '\u{07F5}', '\u{07FA}', '\u{0971}', '\u{0E46}', '\u{0EC6}', '\u{10FC}', '\u{17D7}', '\u{1843}', '\u{1C78}', '\u{1C79}', '\u{1C7A}', '\u{1C7B}', '\u{1C7C}', '\u{1C7D}', '\u{1D2C}', '\u{1D2D}', '\u{1D2E}', '\u{1D2F}', '\u{1D30}', '\u{1D31}', '\u{1D32}', '\u{1D33}', '\u{1D34}', '\u{1D35}', '\u{1D36}', '\u{1D37}', '\u{1D38}', '\u{1D39}', '\u{1D3A}', '\u{1D3B}', '\u{1D3C}', '\u{1D3D}', '\u{1D3E}', '\u{1D3F}', '\u{1D40}', '\u{1D41}', '\u{1D42}', '\u{1D43}', '\u{1D44}', '\u{1D45}', '\u{1D46}', '\u{1D47}', '\u{1D48}', '\u{1D49}', '\u{1D4A}', '\u{1D4B}', '\u{1D4C}', '\u{1D4D}', '\u{1D4E}', '\u{1D4F}', '\u{1D50}', '\u{1D51}', '\u{1D52}', '\u{1D53}', '\u{1D54}', '\u{1D55}', '\u{1D56}', '\u{1D57}', '\u{1D58}', '\u{1D59}', '\u{1D5A}', '\u{1D5B}', '\u{1D5C}', '\u{1D5D}', '\u{1D5E}', '\u{1D5F}', '\u{1D60}', '\u{1D61}', '\u{1D78}', '\u{1D9B}', '\u{1D9C}', '\u{1D9D}', '\u{1D9E}', '\u{1D9F}', '\u{1DA0}', '\u{1DA1}', '\u{1DA2}', '\u{1DA3}', '\u{1DA4}', '\u{1DA5}', '\u{1DA6}', '\u{1DA7}', '\u{1DA8}', '\u{1DA9}', '\u{1DAA}', '\u{1DAB}', '\u{1DAC}', '\u{1DAD}', '\u{1DAE}', '\u{1DAF}', '\u{1DB0}', '\u{1DB1}', '\u{1DB2}', '\u{1DB3}', '\u{1DB4}', '\u{1DB5}', '\u{1DB6}', '\u{1DB7}', '\u{1DB8}', '\u{1DB9}', '\u{1DBA}', '\u{1DBB}', '\u{1DBC}', '\u{1DBD}', '\u{1DBE}', '\u{1DBF}', '\u{2090}', '\u{2091}', '\u{2092}', '\u{2093}', '\u{2094}', '\u{2C7D}', '\u{2D6F}', '\u{2E2F}', '\u{3005}', '\u{3031}', '\u{3032}', '\u{3033}', '\u{3034}', '\u{3035}', '\u{303B}', '\u{309D}', '\u{309E}', '\u{30FC}', '\u{30FD}', '\u{30FE}', '\u{A015}', '\u{A60C}', '\u{A67F}', '\u{A717}', '\u{A718}', '\u{A719}', '\u{A71A}', '\u{A71B}', '\u{A71C}', '\u{A71D}', '\u{A71E}', '\u{A71F}', '\u{A770}', '\u{A788}', '\u{FF70}', '\u{FF9E}', '\u{FF9F}') + } + + fn is_unicode_other_letter(self) -> bool { + match_char_class!(self, + '\u{01BB}', '\u{01C0}', '\u{01C1}', '\u{01C2}', '\u{01C3}', '\u{0294}', '\u{05D0}', '\u{05D1}', '\u{05D2}', '\u{05D3}', '\u{05D4}', '\u{05D5}', '\u{05D6}', '\u{05D7}', '\u{05D8}', '\u{05D9}', '\u{05DA}', '\u{05DB}', '\u{05DC}', '\u{05DD}', '\u{05DE}', '\u{05DF}', '\u{05E0}', '\u{05E1}', '\u{05E2}', '\u{05E3}', '\u{05E4}', '\u{05E5}', '\u{05E6}', '\u{05E7}', '\u{05E8}', '\u{05E9}', '\u{05EA}', '\u{05F0}', '\u{05F1}', '\u{05F2}', '\u{0621}', '\u{0622}', '\u{0623}', '\u{0624}', '\u{0625}', '\u{0626}', '\u{0627}', '\u{0628}', '\u{0629}', '\u{062A}', '\u{062B}', '\u{062C}', '\u{062D}', '\u{062E}', '\u{062F}', '\u{0630}', '\u{0631}', '\u{0632}', '\u{0633}', '\u{0634}', '\u{0635}', '\u{0636}', '\u{0637}', '\u{0638}', '\u{0639}', '\u{063A}', '\u{063B}', '\u{063C}', '\u{063D}', '\u{063E}', '\u{063F}', '\u{0641}', '\u{0642}', '\u{0643}', '\u{0644}', '\u{0645}', '\u{0646}', '\u{0647}', '\u{0648}', '\u{0649}', '\u{064A}', '\u{066E}', '\u{066F}', '\u{0671}', '\u{0672}', '\u{0673}', '\u{0674}', '\u{0675}', '\u{0676}', '\u{0677}', '\u{0678}', '\u{0679}', '\u{067A}', '\u{067B}', '\u{067C}', '\u{067D}', '\u{067E}', '\u{067F}', '\u{0680}', '\u{0681}', '\u{0682}', '\u{0683}', '\u{0684}', '\u{0685}', '\u{0686}', '\u{0687}', '\u{0688}', '\u{0689}', '\u{068A}', '\u{068B}', '\u{068C}', '\u{068D}', '\u{068E}', '\u{068F}', '\u{0690}', '\u{0691}', '\u{0692}', '\u{0693}', '\u{0694}', '\u{0695}', '\u{0696}', '\u{0697}', '\u{0698}', '\u{0699}', '\u{069A}', '\u{069B}', '\u{069C}', '\u{069D}', '\u{069E}', '\u{069F}', '\u{06A0}', '\u{06A1}', '\u{06A2}', '\u{06A3}', '\u{06A4}', '\u{06A5}', '\u{06A6}', '\u{06A7}', '\u{06A8}', '\u{06A9}', '\u{06AA}', '\u{06AB}', '\u{06AC}', '\u{06AD}', '\u{06AE}', '\u{06AF}', '\u{06B0}', '\u{06B1}', '\u{06B2}', '\u{06B3}', '\u{06B4}', '\u{06B5}', '\u{06B6}', '\u{06B7}', '\u{06B8}', '\u{06B9}', '\u{06BA}', '\u{06BB}', '\u{06BC}', '\u{06BD}', '\u{06BE}', '\u{06BF}', '\u{06C0}', '\u{06C1}', '\u{06C2}', '\u{06C3}', '\u{06C4}', '\u{06C5}', '\u{06C6}', '\u{06C7}', '\u{06C8}', '\u{06C9}', '\u{06CA}', '\u{06CB}', '\u{06CC}', '\u{06CD}', '\u{06CE}', '\u{06CF}', '\u{06D0}', '\u{06D1}', '\u{06D2}', '\u{06D3}', '\u{06D5}', '\u{06EE}', '\u{06EF}', '\u{06FA}', '\u{06FB}', '\u{06FC}', '\u{06FF}', '\u{0710}', '\u{0712}', '\u{0713}', '\u{0714}', '\u{0715}', '\u{0716}', '\u{0717}', '\u{0718}', '\u{0719}', '\u{071A}', '\u{071B}', '\u{071C}', '\u{071D}', '\u{071E}', '\u{071F}', '\u{0720}', '\u{0721}', '\u{0722}', '\u{0723}', '\u{0724}', '\u{0725}', '\u{0726}', '\u{0727}', '\u{0728}', '\u{0729}', '\u{072A}', '\u{072B}', '\u{072C}', '\u{072D}', '\u{072E}', '\u{072F}', '\u{074D}', '\u{074E}', '\u{074F}', '\u{0750}', '\u{0751}', '\u{0752}', '\u{0753}', '\u{0754}', '\u{0755}', '\u{0756}', '\u{0757}', '\u{0758}', '\u{0759}', '\u{075A}', '\u{075B}', '\u{075C}', '\u{075D}', '\u{075E}', '\u{075F}', '\u{0760}', '\u{0761}', '\u{0762}', '\u{0763}', '\u{0764}', '\u{0765}', '\u{0766}', '\u{0767}', '\u{0768}', '\u{0769}', '\u{076A}', '\u{076B}', '\u{076C}', '\u{076D}', '\u{076E}', '\u{076F}', '\u{0770}', '\u{0771}', '\u{0772}', '\u{0773}', '\u{0774}', '\u{0775}', '\u{0776}', '\u{0777}', '\u{0778}', '\u{0779}', '\u{077A}', '\u{077B}', '\u{077C}', '\u{077D}', '\u{077E}', '\u{077F}', '\u{0780}', '\u{0781}', '\u{0782}', '\u{0783}', '\u{0784}', '\u{0785}', '\u{0786}', '\u{0787}', '\u{0788}', '\u{0789}', '\u{078A}', '\u{078B}', '\u{078C}', '\u{078D}', '\u{078E}', '\u{078F}', '\u{0790}', '\u{0791}', '\u{0792}', '\u{0793}', '\u{0794}', '\u{0795}', '\u{0796}', '\u{0797}', '\u{0798}', '\u{0799}', '\u{079A}', '\u{079B}', '\u{079C}', '\u{079D}', '\u{079E}', '\u{079F}', '\u{07A0}', '\u{07A1}', '\u{07A2}', '\u{07A3}', '\u{07A4}', '\u{07A5}', '\u{07B1}', '\u{07CA}', '\u{07CB}', '\u{07CC}', '\u{07CD}', '\u{07CE}', '\u{07CF}', '\u{07D0}', '\u{07D1}', '\u{07D2}', '\u{07D3}', '\u{07D4}', '\u{07D5}', '\u{07D6}', '\u{07D7}', '\u{07D8}', '\u{07D9}', '\u{07DA}', '\u{07DB}', '\u{07DC}', '\u{07DD}', '\u{07DE}', '\u{07DF}', '\u{07E0}', '\u{07E1}', '\u{07E2}', '\u{07E3}', '\u{07E4}', '\u{07E5}', '\u{07E6}', '\u{07E7}', '\u{07E8}', '\u{07E9}', '\u{07EA}', '\u{0904}', '\u{0905}', '\u{0906}', '\u{0907}', '\u{0908}', '\u{0909}', '\u{090A}', '\u{090B}', '\u{090C}', '\u{090D}', '\u{090E}', '\u{090F}', '\u{0910}', '\u{0911}', '\u{0912}', '\u{0913}', '\u{0914}', '\u{0915}', '\u{0916}', '\u{0917}', '\u{0918}', '\u{0919}', '\u{091A}', '\u{091B}', '\u{091C}', '\u{091D}', '\u{091E}', '\u{091F}', '\u{0920}', '\u{0921}', '\u{0922}', '\u{0923}', '\u{0924}', '\u{0925}', '\u{0926}', '\u{0927}', '\u{0928}', '\u{0929}', '\u{092A}', '\u{092B}', '\u{092C}', '\u{092D}', '\u{092E}', '\u{092F}', '\u{0930}', '\u{0931}', '\u{0932}', '\u{0933}', '\u{0934}', '\u{0935}', '\u{0936}', '\u{0937}', '\u{0938}', '\u{0939}', '\u{093D}', '\u{0950}', '\u{0958}', '\u{0959}', '\u{095A}', '\u{095B}', '\u{095C}', '\u{095D}', '\u{095E}', '\u{095F}', '\u{0960}', '\u{0961}', '\u{0972}', '\u{097B}', '\u{097C}', '\u{097D}', '\u{097E}', '\u{097F}', '\u{0985}', '\u{0986}', '\u{0987}', '\u{0988}', '\u{0989}', '\u{098A}', '\u{098B}', '\u{098C}', '\u{098F}', '\u{0990}', '\u{0993}', '\u{0994}', '\u{0995}', '\u{0996}', '\u{0997}', '\u{0998}', '\u{0999}', '\u{099A}', '\u{099B}', '\u{099C}', '\u{099D}', '\u{099E}', '\u{099F}', '\u{09A0}', '\u{09A1}', '\u{09A2}', '\u{09A3}', '\u{09A4}', '\u{09A5}', '\u{09A6}', '\u{09A7}', '\u{09A8}', '\u{09AA}', '\u{09AB}', '\u{09AC}', '\u{09AD}', '\u{09AE}', '\u{09AF}', '\u{09B0}', '\u{09B2}', '\u{09B6}', '\u{09B7}', '\u{09B8}', '\u{09B9}', '\u{09BD}', '\u{09CE}', '\u{09DC}', '\u{09DD}', '\u{09DF}', '\u{09E0}', '\u{09E1}', '\u{09F0}', '\u{09F1}', '\u{0A05}', '\u{0A06}', '\u{0A07}', '\u{0A08}', '\u{0A09}', '\u{0A0A}', '\u{0A0F}', '\u{0A10}', '\u{0A13}', '\u{0A14}', '\u{0A15}', '\u{0A16}', '\u{0A17}', '\u{0A18}', '\u{0A19}', '\u{0A1A}', '\u{0A1B}', '\u{0A1C}', '\u{0A1D}', '\u{0A1E}', '\u{0A1F}', '\u{0A20}', '\u{0A21}', '\u{0A22}', '\u{0A23}', '\u{0A24}', '\u{0A25}', '\u{0A26}', '\u{0A27}', '\u{0A28}', '\u{0A2A}', '\u{0A2B}', '\u{0A2C}', '\u{0A2D}', '\u{0A2E}', '\u{0A2F}', '\u{0A30}', '\u{0A32}', '\u{0A33}', '\u{0A35}', '\u{0A36}', '\u{0A38}', '\u{0A39}', '\u{0A59}', '\u{0A5A}', '\u{0A5B}', '\u{0A5C}', '\u{0A5E}', '\u{0A72}', '\u{0A73}', '\u{0A74}', '\u{0A85}', '\u{0A86}', '\u{0A87}', '\u{0A88}', '\u{0A89}', '\u{0A8A}', '\u{0A8B}', '\u{0A8C}', '\u{0A8D}', '\u{0A8F}', '\u{0A90}', '\u{0A91}', '\u{0A93}', '\u{0A94}', '\u{0A95}', '\u{0A96}', '\u{0A97}', '\u{0A98}', '\u{0A99}', '\u{0A9A}', '\u{0A9B}', '\u{0A9C}', '\u{0A9D}', '\u{0A9E}', '\u{0A9F}', '\u{0AA0}', '\u{0AA1}', '\u{0AA2}', '\u{0AA3}', '\u{0AA4}', '\u{0AA5}', '\u{0AA6}', '\u{0AA7}', '\u{0AA8}', '\u{0AAA}', '\u{0AAB}', '\u{0AAC}', '\u{0AAD}', '\u{0AAE}', '\u{0AAF}', '\u{0AB0}', '\u{0AB2}', '\u{0AB3}', '\u{0AB5}', '\u{0AB6}', '\u{0AB7}', '\u{0AB8}', '\u{0AB9}', '\u{0ABD}', '\u{0AD0}', '\u{0AE0}', '\u{0AE1}', '\u{0B05}', '\u{0B06}', '\u{0B07}', '\u{0B08}', '\u{0B09}', '\u{0B0A}', '\u{0B0B}', '\u{0B0C}', '\u{0B0F}', '\u{0B10}', '\u{0B13}', '\u{0B14}', '\u{0B15}', '\u{0B16}', '\u{0B17}', '\u{0B18}', '\u{0B19}', '\u{0B1A}', '\u{0B1B}', '\u{0B1C}', '\u{0B1D}', '\u{0B1E}', '\u{0B1F}', '\u{0B20}', '\u{0B21}', '\u{0B22}', '\u{0B23}', '\u{0B24}', '\u{0B25}', '\u{0B26}', '\u{0B27}', '\u{0B28}', '\u{0B2A}', '\u{0B2B}', '\u{0B2C}', '\u{0B2D}', '\u{0B2E}', '\u{0B2F}', '\u{0B30}', '\u{0B32}', '\u{0B33}', '\u{0B35}', '\u{0B36}', '\u{0B37}', '\u{0B38}', '\u{0B39}', '\u{0B3D}', '\u{0B5C}', '\u{0B5D}', '\u{0B5F}', '\u{0B60}', '\u{0B61}', '\u{0B71}', '\u{0B83}', '\u{0B85}', '\u{0B86}', '\u{0B87}', '\u{0B88}', '\u{0B89}', '\u{0B8A}', '\u{0B8E}', '\u{0B8F}', '\u{0B90}', '\u{0B92}', '\u{0B93}', '\u{0B94}', '\u{0B95}', '\u{0B99}', '\u{0B9A}', '\u{0B9C}', '\u{0B9E}', '\u{0B9F}', '\u{0BA3}', '\u{0BA4}', '\u{0BA8}', '\u{0BA9}', '\u{0BAA}', '\u{0BAE}', '\u{0BAF}', '\u{0BB0}', '\u{0BB1}', '\u{0BB2}', '\u{0BB3}', '\u{0BB4}', '\u{0BB5}', '\u{0BB6}', '\u{0BB7}', '\u{0BB8}', '\u{0BB9}', '\u{0BD0}', '\u{0C05}', '\u{0C06}', '\u{0C07}', '\u{0C08}', '\u{0C09}', '\u{0C0A}', '\u{0C0B}', '\u{0C0C}', '\u{0C0E}', '\u{0C0F}', '\u{0C10}', '\u{0C12}', '\u{0C13}', '\u{0C14}', '\u{0C15}', '\u{0C16}', '\u{0C17}', '\u{0C18}', '\u{0C19}', '\u{0C1A}', '\u{0C1B}', '\u{0C1C}', '\u{0C1D}', '\u{0C1E}', '\u{0C1F}', '\u{0C20}', '\u{0C21}', '\u{0C22}', '\u{0C23}', '\u{0C24}', '\u{0C25}', '\u{0C26}', '\u{0C27}', '\u{0C28}', '\u{0C2A}', '\u{0C2B}', '\u{0C2C}', '\u{0C2D}', '\u{0C2E}', '\u{0C2F}', '\u{0C30}', '\u{0C31}', '\u{0C32}', '\u{0C33}', '\u{0C35}', '\u{0C36}', '\u{0C37}', '\u{0C38}', '\u{0C39}', '\u{0C3D}', '\u{0C58}', '\u{0C59}', '\u{0C60}', '\u{0C61}', '\u{0C85}', '\u{0C86}', '\u{0C87}', '\u{0C88}', '\u{0C89}', '\u{0C8A}', '\u{0C8B}', '\u{0C8C}', '\u{0C8E}', '\u{0C8F}', '\u{0C90}', '\u{0C92}', '\u{0C93}', '\u{0C94}', '\u{0C95}', '\u{0C96}', '\u{0C97}', '\u{0C98}', '\u{0C99}', '\u{0C9A}', '\u{0C9B}', '\u{0C9C}', '\u{0C9D}', '\u{0C9E}', '\u{0C9F}', '\u{0CA0}', '\u{0CA1}', '\u{0CA2}', '\u{0CA3}', '\u{0CA4}', '\u{0CA5}', '\u{0CA6}', '\u{0CA7}', '\u{0CA8}', '\u{0CAA}', '\u{0CAB}', '\u{0CAC}', '\u{0CAD}', '\u{0CAE}', '\u{0CAF}', '\u{0CB0}', '\u{0CB1}', '\u{0CB2}', '\u{0CB3}', '\u{0CB5}', '\u{0CB6}', '\u{0CB7}', '\u{0CB8}', '\u{0CB9}', '\u{0CBD}', '\u{0CDE}', '\u{0CE0}', '\u{0CE1}', '\u{0D05}', '\u{0D06}', '\u{0D07}', '\u{0D08}', '\u{0D09}', '\u{0D0A}', '\u{0D0B}', '\u{0D0C}', '\u{0D0E}', '\u{0D0F}', '\u{0D10}', '\u{0D12}', '\u{0D13}', '\u{0D14}', '\u{0D15}', '\u{0D16}', '\u{0D17}', '\u{0D18}', '\u{0D19}', '\u{0D1A}', '\u{0D1B}', '\u{0D1C}', '\u{0D1D}', '\u{0D1E}', '\u{0D1F}', '\u{0D20}', '\u{0D21}', '\u{0D22}', '\u{0D23}', '\u{0D24}', '\u{0D25}', '\u{0D26}', '\u{0D27}', '\u{0D28}', '\u{0D2A}', '\u{0D2B}', '\u{0D2C}', '\u{0D2D}', '\u{0D2E}', '\u{0D2F}', '\u{0D30}', '\u{0D31}', '\u{0D32}', '\u{0D33}', '\u{0D34}', '\u{0D35}', '\u{0D36}', '\u{0D37}', '\u{0D38}', '\u{0D39}', '\u{0D3D}', '\u{0D60}', '\u{0D61}', '\u{0D7A}', '\u{0D7B}', '\u{0D7C}', '\u{0D7D}', '\u{0D7E}', '\u{0D7F}', '\u{0D85}', '\u{0D86}', '\u{0D87}', '\u{0D88}', '\u{0D89}', '\u{0D8A}', '\u{0D8B}', '\u{0D8C}', '\u{0D8D}', '\u{0D8E}', '\u{0D8F}', '\u{0D90}', '\u{0D91}', '\u{0D92}', '\u{0D93}', '\u{0D94}', '\u{0D95}', '\u{0D96}', '\u{0D9A}', '\u{0D9B}', '\u{0D9C}', '\u{0D9D}', '\u{0D9E}', '\u{0D9F}', '\u{0DA0}', '\u{0DA1}', '\u{0DA2}', '\u{0DA3}', '\u{0DA4}', '\u{0DA5}', '\u{0DA6}', '\u{0DA7}', '\u{0DA8}', '\u{0DA9}', '\u{0DAA}', '\u{0DAB}', '\u{0DAC}', '\u{0DAD}', '\u{0DAE}', '\u{0DAF}', '\u{0DB0}', '\u{0DB1}', '\u{0DB3}', '\u{0DB4}', '\u{0DB5}', '\u{0DB6}', '\u{0DB7}', '\u{0DB8}', '\u{0DB9}', '\u{0DBA}', '\u{0DBB}', '\u{0DBD}', '\u{0DC0}', '\u{0DC1}', '\u{0DC2}', '\u{0DC3}', '\u{0DC4}', '\u{0DC5}', '\u{0DC6}', '\u{0E01}', '\u{0E02}', '\u{0E03}', '\u{0E04}', '\u{0E05}', '\u{0E06}', '\u{0E07}', '\u{0E08}', '\u{0E09}', '\u{0E0A}', '\u{0E0B}', '\u{0E0C}', '\u{0E0D}', '\u{0E0E}', '\u{0E0F}', '\u{0E10}', '\u{0E11}', '\u{0E12}', '\u{0E13}', '\u{0E14}', '\u{0E15}', '\u{0E16}', '\u{0E17}', '\u{0E18}', '\u{0E19}', '\u{0E1A}', '\u{0E1B}', '\u{0E1C}', '\u{0E1D}', '\u{0E1E}', '\u{0E1F}', '\u{0E20}', '\u{0E21}', '\u{0E22}', '\u{0E23}', '\u{0E24}', '\u{0E25}', '\u{0E26}', '\u{0E27}', '\u{0E28}', '\u{0E29}', '\u{0E2A}', '\u{0E2B}', '\u{0E2C}', '\u{0E2D}', '\u{0E2E}', '\u{0E2F}', '\u{0E30}', '\u{0E32}', '\u{0E33}', '\u{0E40}', '\u{0E41}', '\u{0E42}', '\u{0E43}', '\u{0E44}', '\u{0E45}', '\u{0E81}', '\u{0E82}', '\u{0E84}', '\u{0E87}', '\u{0E88}', '\u{0E8A}', '\u{0E8D}', '\u{0E94}', '\u{0E95}', '\u{0E96}', '\u{0E97}', '\u{0E99}', '\u{0E9A}', '\u{0E9B}', '\u{0E9C}', '\u{0E9D}', '\u{0E9E}', '\u{0E9F}', '\u{0EA1}', '\u{0EA2}', '\u{0EA3}', '\u{0EA5}', '\u{0EA7}', '\u{0EAA}', '\u{0EAB}', '\u{0EAD}', '\u{0EAE}', '\u{0EAF}', '\u{0EB0}', '\u{0EB2}', '\u{0EB3}', '\u{0EBD}', '\u{0EC0}', '\u{0EC1}', '\u{0EC2}', '\u{0EC3}', '\u{0EC4}', '\u{0EDC}', '\u{0EDD}', '\u{0F00}', '\u{0F40}', '\u{0F41}', '\u{0F42}', '\u{0F43}', '\u{0F44}', '\u{0F45}', '\u{0F46}', '\u{0F47}', '\u{0F49}', '\u{0F4A}', '\u{0F4B}', '\u{0F4C}', '\u{0F4D}', '\u{0F4E}', '\u{0F4F}', '\u{0F50}', '\u{0F51}', '\u{0F52}', '\u{0F53}', '\u{0F54}', '\u{0F55}', '\u{0F56}', '\u{0F57}', '\u{0F58}', '\u{0F59}', '\u{0F5A}', '\u{0F5B}', '\u{0F5C}', '\u{0F5D}', '\u{0F5E}', '\u{0F5F}', '\u{0F60}', '\u{0F61}', '\u{0F62}', '\u{0F63}', '\u{0F64}', '\u{0F65}', '\u{0F66}', '\u{0F67}', '\u{0F68}', '\u{0F69}', '\u{0F6A}', '\u{0F6B}', '\u{0F6C}', '\u{0F88}', '\u{0F89}', '\u{0F8A}', '\u{0F8B}', '\u{1000}', '\u{1001}', '\u{1002}', '\u{1003}', '\u{1004}', '\u{1005}', '\u{1006}', '\u{1007}', '\u{1008}', '\u{1009}', '\u{100A}', '\u{100B}', '\u{100C}', '\u{100D}', '\u{100E}', '\u{100F}', '\u{1010}', '\u{1011}', '\u{1012}', '\u{1013}', '\u{1014}', '\u{1015}', '\u{1016}', '\u{1017}', '\u{1018}', '\u{1019}', '\u{101A}', '\u{101B}', '\u{101C}', '\u{101D}', '\u{101E}', '\u{101F}', '\u{1020}', '\u{1021}', '\u{1022}', '\u{1023}', '\u{1024}', '\u{1025}', '\u{1026}', '\u{1027}', '\u{1028}', '\u{1029}', '\u{102A}', '\u{103F}', '\u{1050}', '\u{1051}', '\u{1052}', '\u{1053}', '\u{1054}', '\u{1055}', '\u{105A}', '\u{105B}', '\u{105C}', '\u{105D}', '\u{1061}', '\u{1065}', '\u{1066}', '\u{106E}', '\u{106F}', '\u{1070}', '\u{1075}', '\u{1076}', '\u{1077}', '\u{1078}', '\u{1079}', '\u{107A}', '\u{107B}', '\u{107C}', '\u{107D}', '\u{107E}', '\u{107F}', '\u{1080}', '\u{1081}', '\u{108E}', '\u{10D0}', '\u{10D1}', '\u{10D2}', '\u{10D3}', '\u{10D4}', '\u{10D5}', '\u{10D6}', '\u{10D7}', '\u{10D8}', '\u{10D9}', '\u{10DA}', '\u{10DB}', '\u{10DC}', '\u{10DD}', '\u{10DE}', '\u{10DF}', '\u{10E0}', '\u{10E1}', '\u{10E2}', '\u{10E3}', '\u{10E4}', '\u{10E5}', '\u{10E6}', '\u{10E7}', '\u{10E8}', '\u{10E9}', '\u{10EA}', '\u{10EB}', '\u{10EC}', '\u{10ED}', '\u{10EE}', '\u{10EF}', '\u{10F0}', '\u{10F1}', '\u{10F2}', '\u{10F3}', '\u{10F4}', '\u{10F5}', '\u{10F6}', '\u{10F7}', '\u{10F8}', '\u{10F9}', '\u{10FA}', '\u{1100}', '\u{1101}', '\u{1102}', '\u{1103}', '\u{1104}', '\u{1105}', '\u{1106}', '\u{1107}', '\u{1108}', '\u{1109}', '\u{110A}', '\u{110B}', '\u{110C}', '\u{110D}', '\u{110E}', '\u{110F}', '\u{1110}', '\u{1111}', '\u{1112}', '\u{1113}', '\u{1114}', '\u{1115}', '\u{1116}', '\u{1117}', '\u{1118}', '\u{1119}', '\u{111A}', '\u{111B}', '\u{111C}', '\u{111D}', '\u{111E}', '\u{111F}', '\u{1120}', '\u{1121}', '\u{1122}', '\u{1123}', '\u{1124}', '\u{1125}', '\u{1126}', '\u{1127}', '\u{1128}', '\u{1129}', '\u{112A}', '\u{112B}', '\u{112C}', '\u{112D}', '\u{112E}', '\u{112F}', '\u{1130}', '\u{1131}', '\u{1132}', '\u{1133}', '\u{1134}', '\u{1135}', '\u{1136}', '\u{1137}', '\u{1138}', '\u{1139}', '\u{113A}', '\u{113B}', '\u{113C}', '\u{113D}', '\u{113E}', '\u{113F}', '\u{1140}', '\u{1141}', '\u{1142}', '\u{1143}', '\u{1144}', '\u{1145}', '\u{1146}', '\u{1147}', '\u{1148}', '\u{1149}', '\u{114A}', '\u{114B}', '\u{114C}', '\u{114D}', '\u{114E}', '\u{114F}', '\u{1150}', '\u{1151}', '\u{1152}', '\u{1153}', '\u{1154}', '\u{1155}', '\u{1156}', '\u{1157}', '\u{1158}', '\u{1159}', '\u{115F}', '\u{1160}', '\u{1161}', '\u{1162}', '\u{1163}', '\u{1164}', '\u{1165}', '\u{1166}', '\u{1167}', '\u{1168}', '\u{1169}', '\u{116A}', '\u{116B}', '\u{116C}', '\u{116D}', '\u{116E}', '\u{116F}', '\u{1170}', '\u{1171}', '\u{1172}', '\u{1173}', '\u{1174}', '\u{1175}', '\u{1176}', '\u{1177}', '\u{1178}', '\u{1179}', '\u{117A}', '\u{117B}', '\u{117C}', '\u{117D}', '\u{117E}', '\u{117F}', '\u{1180}', '\u{1181}', '\u{1182}', '\u{1183}', '\u{1184}', '\u{1185}', '\u{1186}', '\u{1187}', '\u{1188}', '\u{1189}', '\u{118A}', '\u{118B}', '\u{118C}', '\u{118D}', '\u{118E}', '\u{118F}', '\u{1190}', '\u{1191}', '\u{1192}', '\u{1193}', '\u{1194}', '\u{1195}', '\u{1196}', '\u{1197}', '\u{1198}', '\u{1199}', '\u{119A}', '\u{119B}', '\u{119C}', '\u{119D}', '\u{119E}', '\u{119F}', '\u{11A0}', '\u{11A1}', '\u{11A2}', '\u{11A8}', '\u{11A9}', '\u{11AA}', '\u{11AB}', '\u{11AC}', '\u{11AD}', '\u{11AE}', '\u{11AF}', '\u{11B0}', '\u{11B1}', '\u{11B2}', '\u{11B3}', '\u{11B4}', '\u{11B5}', '\u{11B6}', '\u{11B7}', '\u{11B8}', '\u{11B9}', '\u{11BA}', '\u{11BB}', '\u{11BC}', '\u{11BD}', '\u{11BE}', '\u{11BF}', '\u{11C0}', '\u{11C1}', '\u{11C2}', '\u{11C3}', '\u{11C4}', '\u{11C5}', '\u{11C6}', '\u{11C7}', '\u{11C8}', '\u{11C9}', '\u{11CA}', '\u{11CB}', '\u{11CC}', '\u{11CD}', '\u{11CE}', '\u{11CF}', '\u{11D0}', '\u{11D1}', '\u{11D2}', '\u{11D3}', '\u{11D4}', '\u{11D5}', '\u{11D6}', '\u{11D7}', '\u{11D8}', '\u{11D9}', '\u{11DA}', '\u{11DB}', '\u{11DC}', '\u{11DD}', '\u{11DE}', '\u{11DF}', '\u{11E0}', '\u{11E1}', '\u{11E2}', '\u{11E3}', '\u{11E4}', '\u{11E5}', '\u{11E6}', '\u{11E7}', '\u{11E8}', '\u{11E9}', '\u{11EA}', '\u{11EB}', '\u{11EC}', '\u{11ED}', '\u{11EE}', '\u{11EF}', '\u{11F0}', '\u{11F1}', '\u{11F2}', '\u{11F3}', '\u{11F4}', '\u{11F5}', '\u{11F6}', '\u{11F7}', '\u{11F8}', '\u{11F9}', '\u{1200}', '\u{1201}', '\u{1202}', '\u{1203}', '\u{1204}', '\u{1205}', '\u{1206}', '\u{1207}', '\u{1208}', '\u{1209}', '\u{120A}', '\u{120B}', '\u{120C}', '\u{120D}', '\u{120E}', '\u{120F}', '\u{1210}', '\u{1211}', '\u{1212}', '\u{1213}', '\u{1214}', '\u{1215}', '\u{1216}', '\u{1217}', '\u{1218}', '\u{1219}', '\u{121A}', '\u{121B}', '\u{121C}', '\u{121D}', '\u{121E}', '\u{121F}', '\u{1220}', '\u{1221}', '\u{1222}', '\u{1223}', '\u{1224}', '\u{1225}', '\u{1226}', '\u{1227}', '\u{1228}', '\u{1229}', '\u{122A}', '\u{122B}', '\u{122C}', '\u{122D}', '\u{122E}', '\u{122F}', '\u{1230}', '\u{1231}', '\u{1232}', '\u{1233}', '\u{1234}', '\u{1235}', '\u{1236}', '\u{1237}', '\u{1238}', '\u{1239}', '\u{123A}', '\u{123B}', '\u{123C}', '\u{123D}', '\u{123E}', '\u{123F}', '\u{1240}', '\u{1241}', '\u{1242}', '\u{1243}', '\u{1244}', '\u{1245}', '\u{1246}', '\u{1247}', '\u{1248}', '\u{124A}', '\u{124B}', '\u{124C}', '\u{124D}', '\u{1250}', '\u{1251}', '\u{1252}', '\u{1253}', '\u{1254}', '\u{1255}', '\u{1256}', '\u{1258}', '\u{125A}', '\u{125B}', '\u{125C}', '\u{125D}', '\u{1260}', '\u{1261}', '\u{1262}', '\u{1263}', '\u{1264}', '\u{1265}', '\u{1266}', '\u{1267}', '\u{1268}', '\u{1269}', '\u{126A}', '\u{126B}', '\u{126C}', '\u{126D}', '\u{126E}', '\u{126F}', '\u{1270}', '\u{1271}', '\u{1272}', '\u{1273}', '\u{1274}', '\u{1275}', '\u{1276}', '\u{1277}', '\u{1278}', '\u{1279}', '\u{127A}', '\u{127B}', '\u{127C}', '\u{127D}', '\u{127E}', '\u{127F}', '\u{1280}', '\u{1281}', '\u{1282}', '\u{1283}', '\u{1284}', '\u{1285}', '\u{1286}', '\u{1287}', '\u{1288}', '\u{128A}', '\u{128B}', '\u{128C}', '\u{128D}', '\u{1290}', '\u{1291}', '\u{1292}', '\u{1293}', '\u{1294}', '\u{1295}', '\u{1296}', '\u{1297}', '\u{1298}', '\u{1299}', '\u{129A}', '\u{129B}', '\u{129C}', '\u{129D}', '\u{129E}', '\u{129F}', '\u{12A0}', '\u{12A1}', '\u{12A2}', '\u{12A3}', '\u{12A4}', '\u{12A5}', '\u{12A6}', '\u{12A7}', '\u{12A8}', '\u{12A9}', '\u{12AA}', '\u{12AB}', '\u{12AC}', '\u{12AD}', '\u{12AE}', '\u{12AF}', '\u{12B0}', '\u{12B2}', '\u{12B3}', '\u{12B4}', '\u{12B5}', '\u{12B8}', '\u{12B9}', '\u{12BA}', '\u{12BB}', '\u{12BC}', '\u{12BD}', '\u{12BE}', '\u{12C0}', '\u{12C2}', '\u{12C3}', '\u{12C4}', '\u{12C5}', '\u{12C8}', '\u{12C9}', '\u{12CA}', '\u{12CB}', '\u{12CC}', '\u{12CD}', '\u{12CE}', '\u{12CF}', '\u{12D0}', '\u{12D1}', '\u{12D2}', '\u{12D3}', '\u{12D4}', '\u{12D5}', '\u{12D6}', '\u{12D8}', '\u{12D9}', '\u{12DA}', '\u{12DB}', '\u{12DC}', '\u{12DD}', '\u{12DE}', '\u{12DF}', '\u{12E0}', '\u{12E1}', '\u{12E2}', '\u{12E3}', '\u{12E4}', '\u{12E5}', '\u{12E6}', '\u{12E7}', '\u{12E8}', '\u{12E9}', '\u{12EA}', '\u{12EB}', '\u{12EC}', '\u{12ED}', '\u{12EE}', '\u{12EF}', '\u{12F0}', '\u{12F1}', '\u{12F2}', '\u{12F3}', '\u{12F4}', '\u{12F5}', '\u{12F6}', '\u{12F7}', '\u{12F8}', '\u{12F9}', '\u{12FA}', '\u{12FB}', '\u{12FC}', '\u{12FD}', '\u{12FE}', '\u{12FF}', '\u{1300}', '\u{1301}', '\u{1302}', '\u{1303}', '\u{1304}', '\u{1305}', '\u{1306}', '\u{1307}', '\u{1308}', '\u{1309}', '\u{130A}', '\u{130B}', '\u{130C}', '\u{130D}', '\u{130E}', '\u{130F}', '\u{1310}', '\u{1312}', '\u{1313}', '\u{1314}', '\u{1315}', '\u{1318}', '\u{1319}', '\u{131A}', '\u{131B}', '\u{131C}', '\u{131D}', '\u{131E}', '\u{131F}', '\u{1320}', '\u{1321}', '\u{1322}', '\u{1323}', '\u{1324}', '\u{1325}', '\u{1326}', '\u{1327}', '\u{1328}', '\u{1329}', '\u{132A}', '\u{132B}', '\u{132C}', '\u{132D}', '\u{132E}', '\u{132F}', '\u{1330}', '\u{1331}', '\u{1332}', '\u{1333}', '\u{1334}', '\u{1335}', '\u{1336}', '\u{1337}', '\u{1338}', '\u{1339}', '\u{133A}', '\u{133B}', '\u{133C}', '\u{133D}', '\u{133E}', '\u{133F}', '\u{1340}', '\u{1341}', '\u{1342}', '\u{1343}', '\u{1344}', '\u{1345}', '\u{1346}', '\u{1347}', '\u{1348}', '\u{1349}', '\u{134A}', '\u{134B}', '\u{134C}', '\u{134D}', '\u{134E}', '\u{134F}', '\u{1350}', '\u{1351}', '\u{1352}', '\u{1353}', '\u{1354}', '\u{1355}', '\u{1356}', '\u{1357}', '\u{1358}', '\u{1359}', '\u{135A}', '\u{1380}', '\u{1381}', '\u{1382}', '\u{1383}', '\u{1384}', '\u{1385}', '\u{1386}', '\u{1387}', '\u{1388}', '\u{1389}', '\u{138A}', '\u{138B}', '\u{138C}', '\u{138D}', '\u{138E}', '\u{138F}', '\u{13A0}', '\u{13A1}', '\u{13A2}', '\u{13A3}', '\u{13A4}', '\u{13A5}', '\u{13A6}', '\u{13A7}', '\u{13A8}', '\u{13A9}', '\u{13AA}', '\u{13AB}', '\u{13AC}', '\u{13AD}', '\u{13AE}', '\u{13AF}', '\u{13B0}', '\u{13B1}', '\u{13B2}', '\u{13B3}', '\u{13B4}', '\u{13B5}', '\u{13B6}', '\u{13B7}', '\u{13B8}', '\u{13B9}', '\u{13BA}', '\u{13BB}', '\u{13BC}', '\u{13BD}', '\u{13BE}', '\u{13BF}', '\u{13C0}', '\u{13C1}', '\u{13C2}', '\u{13C3}', '\u{13C4}', '\u{13C5}', '\u{13C6}', '\u{13C7}', '\u{13C8}', '\u{13C9}', '\u{13CA}', '\u{13CB}', '\u{13CC}', '\u{13CD}', '\u{13CE}', '\u{13CF}', '\u{13D0}', '\u{13D1}', '\u{13D2}', '\u{13D3}', '\u{13D4}', '\u{13D5}', '\u{13D6}', '\u{13D7}', '\u{13D8}', '\u{13D9}', '\u{13DA}', '\u{13DB}', '\u{13DC}', '\u{13DD}', '\u{13DE}', '\u{13DF}', '\u{13E0}', '\u{13E1}', '\u{13E2}', '\u{13E3}', '\u{13E4}', '\u{13E5}', '\u{13E6}', '\u{13E7}', '\u{13E8}', '\u{13E9}', '\u{13EA}', '\u{13EB}', '\u{13EC}', '\u{13ED}', '\u{13EE}', '\u{13EF}', '\u{13F0}', '\u{13F1}', '\u{13F2}', '\u{13F3}', '\u{13F4}', '\u{1401}', '\u{1402}', '\u{1403}', '\u{1404}', '\u{1405}', '\u{1406}', '\u{1407}', '\u{1408}', '\u{1409}', '\u{140A}', '\u{140B}', '\u{140C}', '\u{140D}', '\u{140E}', '\u{140F}', '\u{1410}', '\u{1411}', '\u{1412}', '\u{1413}', '\u{1414}', '\u{1415}', '\u{1416}', '\u{1417}', '\u{1418}', '\u{1419}', '\u{141A}', '\u{141B}', '\u{141C}', '\u{141D}', '\u{141E}', '\u{141F}', '\u{1420}', '\u{1421}', '\u{1422}', '\u{1423}', '\u{1424}', '\u{1425}', '\u{1426}', '\u{1427}', '\u{1428}', '\u{1429}', '\u{142A}', '\u{142B}', '\u{142C}', '\u{142D}', '\u{142E}', '\u{142F}', '\u{1430}', '\u{1431}', '\u{1432}', '\u{1433}', '\u{1434}', '\u{1435}', '\u{1436}', '\u{1437}', '\u{1438}', '\u{1439}', '\u{143A}', '\u{143B}', '\u{143C}', '\u{143D}', '\u{143E}', '\u{143F}', '\u{1440}', '\u{1441}', '\u{1442}', '\u{1443}', '\u{1444}', '\u{1445}', '\u{1446}', '\u{1447}', '\u{1448}', '\u{1449}', '\u{144A}', '\u{144B}', '\u{144C}', '\u{144D}', '\u{144E}', '\u{144F}', '\u{1450}', '\u{1451}', '\u{1452}', '\u{1453}', '\u{1454}', '\u{1455}', '\u{1456}', '\u{1457}', '\u{1458}', '\u{1459}', '\u{145A}', '\u{145B}', '\u{145C}', '\u{145D}', '\u{145E}', '\u{145F}', '\u{1460}', '\u{1461}', '\u{1462}', '\u{1463}', '\u{1464}', '\u{1465}', '\u{1466}', '\u{1467}', '\u{1468}', '\u{1469}', '\u{146A}', '\u{146B}', '\u{146C}', '\u{146D}', '\u{146E}', '\u{146F}', '\u{1470}', '\u{1471}', '\u{1472}', '\u{1473}', '\u{1474}', '\u{1475}', '\u{1476}', '\u{1477}', '\u{1478}', '\u{1479}', '\u{147A}', '\u{147B}', '\u{147C}', '\u{147D}', '\u{147E}', '\u{147F}', '\u{1480}', '\u{1481}', '\u{1482}', '\u{1483}', '\u{1484}', '\u{1485}', '\u{1486}', '\u{1487}', '\u{1488}', '\u{1489}', '\u{148A}', '\u{148B}', '\u{148C}', '\u{148D}', '\u{148E}', '\u{148F}', '\u{1490}', '\u{1491}', '\u{1492}', '\u{1493}', '\u{1494}', '\u{1495}', '\u{1496}', '\u{1497}', '\u{1498}', '\u{1499}', '\u{149A}', '\u{149B}', '\u{149C}', '\u{149D}', '\u{149E}', '\u{149F}', '\u{14A0}', '\u{14A1}', '\u{14A2}', '\u{14A3}', '\u{14A4}', '\u{14A5}', '\u{14A6}', '\u{14A7}', '\u{14A8}', '\u{14A9}', '\u{14AA}', '\u{14AB}', '\u{14AC}', '\u{14AD}', '\u{14AE}', '\u{14AF}', '\u{14B0}', '\u{14B1}', '\u{14B2}', '\u{14B3}', '\u{14B4}', '\u{14B5}', '\u{14B6}', '\u{14B7}', '\u{14B8}', '\u{14B9}', '\u{14BA}', '\u{14BB}', '\u{14BC}', '\u{14BD}', '\u{14BE}', '\u{14BF}', '\u{14C0}', '\u{14C1}', '\u{14C2}', '\u{14C3}', '\u{14C4}', '\u{14C5}', '\u{14C6}', '\u{14C7}', '\u{14C8}', '\u{14C9}', '\u{14CA}', '\u{14CB}', '\u{14CC}', '\u{14CD}', '\u{14CE}', '\u{14CF}', '\u{14D0}', '\u{14D1}', '\u{14D2}', '\u{14D3}', '\u{14D4}', '\u{14D5}', '\u{14D6}', '\u{14D7}', '\u{14D8}', '\u{14D9}', '\u{14DA}', '\u{14DB}', '\u{14DC}', '\u{14DD}', '\u{14DE}', '\u{14DF}', '\u{14E0}', '\u{14E1}', '\u{14E2}', '\u{14E3}', '\u{14E4}', '\u{14E5}', '\u{14E6}', '\u{14E7}', '\u{14E8}', '\u{14E9}', '\u{14EA}', '\u{14EB}', '\u{14EC}', '\u{14ED}', '\u{14EE}', '\u{14EF}', '\u{14F0}', '\u{14F1}', '\u{14F2}', '\u{14F3}', '\u{14F4}', '\u{14F5}', '\u{14F6}', '\u{14F7}', '\u{14F8}', '\u{14F9}', '\u{14FA}', '\u{14FB}', '\u{14FC}', '\u{14FD}', '\u{14FE}', '\u{14FF}', '\u{1500}', '\u{1501}', '\u{1502}', '\u{1503}', '\u{1504}', '\u{1505}', '\u{1506}', '\u{1507}', '\u{1508}', '\u{1509}', '\u{150A}', '\u{150B}', '\u{150C}', '\u{150D}', '\u{150E}', '\u{150F}', '\u{1510}', '\u{1511}', '\u{1512}', '\u{1513}', '\u{1514}', '\u{1515}', '\u{1516}', '\u{1517}', '\u{1518}', '\u{1519}', '\u{151A}', '\u{151B}', '\u{151C}', '\u{151D}', '\u{151E}', '\u{151F}', '\u{1520}', '\u{1521}', '\u{1522}', '\u{1523}', '\u{1524}', '\u{1525}', '\u{1526}', '\u{1527}', '\u{1528}', '\u{1529}', '\u{152A}', '\u{152B}', '\u{152C}', '\u{152D}', '\u{152E}', '\u{152F}', '\u{1530}', '\u{1531}', '\u{1532}', '\u{1533}', '\u{1534}', '\u{1535}', '\u{1536}', '\u{1537}', '\u{1538}', '\u{1539}', '\u{153A}', '\u{153B}', '\u{153C}', '\u{153D}', '\u{153E}', '\u{153F}', '\u{1540}', '\u{1541}', '\u{1542}', '\u{1543}', '\u{1544}', '\u{1545}', '\u{1546}', '\u{1547}', '\u{1548}', '\u{1549}', '\u{154A}', '\u{154B}', '\u{154C}', '\u{154D}', '\u{154E}', '\u{154F}', '\u{1550}', '\u{1551}', '\u{1552}', '\u{1553}', '\u{1554}', '\u{1555}', '\u{1556}', '\u{1557}', '\u{1558}', '\u{1559}', '\u{155A}', '\u{155B}', '\u{155C}', '\u{155D}', '\u{155E}', '\u{155F}', '\u{1560}', '\u{1561}', '\u{1562}', '\u{1563}', '\u{1564}', '\u{1565}', '\u{1566}', '\u{1567}', '\u{1568}', '\u{1569}', '\u{156A}', '\u{156B}', '\u{156C}', '\u{156D}', '\u{156E}', '\u{156F}', '\u{1570}', '\u{1571}', '\u{1572}', '\u{1573}', '\u{1574}', '\u{1575}', '\u{1576}', '\u{1577}', '\u{1578}', '\u{1579}', '\u{157A}', '\u{157B}', '\u{157C}', '\u{157D}', '\u{157E}', '\u{157F}', '\u{1580}', '\u{1581}', '\u{1582}', '\u{1583}', '\u{1584}', '\u{1585}', '\u{1586}', '\u{1587}', '\u{1588}', '\u{1589}', '\u{158A}', '\u{158B}', '\u{158C}', '\u{158D}', '\u{158E}', '\u{158F}', '\u{1590}', '\u{1591}', '\u{1592}', '\u{1593}', '\u{1594}', '\u{1595}', '\u{1596}', '\u{1597}', '\u{1598}', '\u{1599}', '\u{159A}', '\u{159B}', '\u{159C}', '\u{159D}', '\u{159E}', '\u{159F}', '\u{15A0}', '\u{15A1}', '\u{15A2}', '\u{15A3}', '\u{15A4}', '\u{15A5}', '\u{15A6}', '\u{15A7}', '\u{15A8}', '\u{15A9}', '\u{15AA}', '\u{15AB}', '\u{15AC}', '\u{15AD}', '\u{15AE}', '\u{15AF}', '\u{15B0}', '\u{15B1}', '\u{15B2}', '\u{15B3}', '\u{15B4}', '\u{15B5}', '\u{15B6}', '\u{15B7}', '\u{15B8}', '\u{15B9}', '\u{15BA}', '\u{15BB}', '\u{15BC}', '\u{15BD}', '\u{15BE}', '\u{15BF}', '\u{15C0}', '\u{15C1}', '\u{15C2}', '\u{15C3}', '\u{15C4}', '\u{15C5}', '\u{15C6}', '\u{15C7}', '\u{15C8}', '\u{15C9}', '\u{15CA}', '\u{15CB}', '\u{15CC}', '\u{15CD}', '\u{15CE}', '\u{15CF}', '\u{15D0}', '\u{15D1}', '\u{15D2}', '\u{15D3}', '\u{15D4}', '\u{15D5}', '\u{15D6}', '\u{15D7}', '\u{15D8}', '\u{15D9}', '\u{15DA}', '\u{15DB}', '\u{15DC}', '\u{15DD}', '\u{15DE}', '\u{15DF}', '\u{15E0}', '\u{15E1}', '\u{15E2}', '\u{15E3}', '\u{15E4}', '\u{15E5}', '\u{15E6}', '\u{15E7}', '\u{15E8}', '\u{15E9}', '\u{15EA}', '\u{15EB}', '\u{15EC}', '\u{15ED}', '\u{15EE}', '\u{15EF}', '\u{15F0}', '\u{15F1}', '\u{15F2}', '\u{15F3}', '\u{15F4}', '\u{15F5}', '\u{15F6}', '\u{15F7}', '\u{15F8}', '\u{15F9}', '\u{15FA}', '\u{15FB}', '\u{15FC}', '\u{15FD}', '\u{15FE}', '\u{15FF}', '\u{1600}', '\u{1601}', '\u{1602}', '\u{1603}', '\u{1604}', '\u{1605}', '\u{1606}', '\u{1607}', '\u{1608}', '\u{1609}', '\u{160A}', '\u{160B}', '\u{160C}', '\u{160D}', '\u{160E}', '\u{160F}', '\u{1610}', '\u{1611}', '\u{1612}', '\u{1613}', '\u{1614}', '\u{1615}', '\u{1616}', '\u{1617}', '\u{1618}', '\u{1619}', '\u{161A}', '\u{161B}', '\u{161C}', '\u{161D}', '\u{161E}', '\u{161F}', '\u{1620}', '\u{1621}', '\u{1622}', '\u{1623}', '\u{1624}', '\u{1625}', '\u{1626}', '\u{1627}', '\u{1628}', '\u{1629}', '\u{162A}', '\u{162B}', '\u{162C}', '\u{162D}', '\u{162E}', '\u{162F}', '\u{1630}', '\u{1631}', '\u{1632}', '\u{1633}', '\u{1634}', '\u{1635}', '\u{1636}', '\u{1637}', '\u{1638}', '\u{1639}', '\u{163A}', '\u{163B}', '\u{163C}', '\u{163D}', '\u{163E}', '\u{163F}', '\u{1640}', '\u{1641}', '\u{1642}', '\u{1643}', '\u{1644}', '\u{1645}', '\u{1646}', '\u{1647}', '\u{1648}', '\u{1649}', '\u{164A}', '\u{164B}', '\u{164C}', '\u{164D}', '\u{164E}', '\u{164F}', '\u{1650}', '\u{1651}', '\u{1652}', '\u{1653}', '\u{1654}', '\u{1655}', '\u{1656}', '\u{1657}', '\u{1658}', '\u{1659}', '\u{165A}', '\u{165B}', '\u{165C}', '\u{165D}', '\u{165E}', '\u{165F}', '\u{1660}', '\u{1661}', '\u{1662}', '\u{1663}', '\u{1664}', '\u{1665}', '\u{1666}', '\u{1667}', '\u{1668}', '\u{1669}', '\u{166A}', '\u{166B}', '\u{166C}', '\u{166F}', '\u{1670}', '\u{1671}', '\u{1672}', '\u{1673}', '\u{1674}', '\u{1675}', '\u{1676}', '\u{1681}', '\u{1682}', '\u{1683}', '\u{1684}', '\u{1685}', '\u{1686}', '\u{1687}', '\u{1688}', '\u{1689}', '\u{168A}', '\u{168B}', '\u{168C}', '\u{168D}', '\u{168E}', '\u{168F}', '\u{1690}', '\u{1691}', '\u{1692}', '\u{1693}', '\u{1694}', '\u{1695}', '\u{1696}', '\u{1697}', '\u{1698}', '\u{1699}', '\u{169A}', '\u{16A0}', '\u{16A1}', '\u{16A2}', '\u{16A3}', '\u{16A4}', '\u{16A5}', '\u{16A6}', '\u{16A7}', '\u{16A8}', '\u{16A9}', '\u{16AA}', '\u{16AB}', '\u{16AC}', '\u{16AD}', '\u{16AE}', '\u{16AF}', '\u{16B0}', '\u{16B1}', '\u{16B2}', '\u{16B3}', '\u{16B4}', '\u{16B5}', '\u{16B6}', '\u{16B7}', '\u{16B8}', '\u{16B9}', '\u{16BA}', '\u{16BB}', '\u{16BC}', '\u{16BD}', '\u{16BE}', '\u{16BF}', '\u{16C0}', '\u{16C1}', '\u{16C2}', '\u{16C3}', '\u{16C4}', '\u{16C5}', '\u{16C6}', '\u{16C7}', '\u{16C8}', '\u{16C9}', '\u{16CA}', '\u{16CB}', '\u{16CC}', '\u{16CD}', '\u{16CE}', '\u{16CF}', '\u{16D0}', '\u{16D1}', '\u{16D2}', '\u{16D3}', '\u{16D4}', '\u{16D5}', '\u{16D6}', '\u{16D7}', '\u{16D8}', '\u{16D9}', '\u{16DA}', '\u{16DB}', '\u{16DC}', '\u{16DD}', '\u{16DE}', '\u{16DF}', '\u{16E0}', '\u{16E1}', '\u{16E2}', '\u{16E3}', '\u{16E4}', '\u{16E5}', '\u{16E6}', '\u{16E7}', '\u{16E8}', '\u{16E9}', '\u{16EA}', '\u{1700}', '\u{1701}', '\u{1702}', '\u{1703}', '\u{1704}', '\u{1705}', '\u{1706}', '\u{1707}', '\u{1708}', '\u{1709}', '\u{170A}', '\u{170B}', '\u{170C}', '\u{170E}', '\u{170F}', '\u{1710}', '\u{1711}', '\u{1720}', '\u{1721}', '\u{1722}', '\u{1723}', '\u{1724}', '\u{1725}', '\u{1726}', '\u{1727}', '\u{1728}', '\u{1729}', '\u{172A}', '\u{172B}', '\u{172C}', '\u{172D}', '\u{172E}', '\u{172F}', '\u{1730}', '\u{1731}', '\u{1740}', '\u{1741}', '\u{1742}', '\u{1743}', '\u{1744}', '\u{1745}', '\u{1746}', '\u{1747}', '\u{1748}', '\u{1749}', '\u{174A}', '\u{174B}', '\u{174C}', '\u{174D}', '\u{174E}', '\u{174F}', '\u{1750}', '\u{1751}', '\u{1760}', '\u{1761}', '\u{1762}', '\u{1763}', '\u{1764}', '\u{1765}', '\u{1766}', '\u{1767}', '\u{1768}', '\u{1769}', '\u{176A}', '\u{176B}', '\u{176C}', '\u{176E}', '\u{176F}', '\u{1770}', '\u{1780}', '\u{1781}', '\u{1782}', '\u{1783}', '\u{1784}', '\u{1785}', '\u{1786}', '\u{1787}', '\u{1788}', '\u{1789}', '\u{178A}', '\u{178B}', '\u{178C}', '\u{178D}', '\u{178E}', '\u{178F}', '\u{1790}', '\u{1791}', '\u{1792}', '\u{1793}', '\u{1794}', '\u{1795}', '\u{1796}', '\u{1797}', '\u{1798}', '\u{1799}', '\u{179A}', '\u{179B}', '\u{179C}', '\u{179D}', '\u{179E}', '\u{179F}', '\u{17A0}', '\u{17A1}', '\u{17A2}', '\u{17A3}', '\u{17A4}', '\u{17A5}', '\u{17A6}', '\u{17A7}', '\u{17A8}', '\u{17A9}', '\u{17AA}', '\u{17AB}', '\u{17AC}', '\u{17AD}', '\u{17AE}', '\u{17AF}', '\u{17B0}', '\u{17B1}', '\u{17B2}', '\u{17B3}', '\u{17DC}', '\u{1820}', '\u{1821}', '\u{1822}', '\u{1823}', '\u{1824}', '\u{1825}', '\u{1826}', '\u{1827}', '\u{1828}', '\u{1829}', '\u{182A}', '\u{182B}', '\u{182C}', '\u{182D}', '\u{182E}', '\u{182F}', '\u{1830}', '\u{1831}', '\u{1832}', '\u{1833}', '\u{1834}', '\u{1835}', '\u{1836}', '\u{1837}', '\u{1838}', '\u{1839}', '\u{183A}', '\u{183B}', '\u{183C}', '\u{183D}', '\u{183E}', '\u{183F}', '\u{1840}', '\u{1841}', '\u{1842}', '\u{1844}', '\u{1845}', '\u{1846}', '\u{1847}', '\u{1848}', '\u{1849}', '\u{184A}', '\u{184B}', '\u{184C}', '\u{184D}', '\u{184E}', '\u{184F}', '\u{1850}', '\u{1851}', '\u{1852}', '\u{1853}', '\u{1854}', '\u{1855}', '\u{1856}', '\u{1857}', '\u{1858}', '\u{1859}', '\u{185A}', '\u{185B}', '\u{185C}', '\u{185D}', '\u{185E}', '\u{185F}', '\u{1860}', '\u{1861}', '\u{1862}', '\u{1863}', '\u{1864}', '\u{1865}', '\u{1866}', '\u{1867}', '\u{1868}', '\u{1869}', '\u{186A}', '\u{186B}', '\u{186C}', '\u{186D}', '\u{186E}', '\u{186F}', '\u{1870}', '\u{1871}', '\u{1872}', '\u{1873}', '\u{1874}', '\u{1875}', '\u{1876}', '\u{1877}', '\u{1880}', '\u{1881}', '\u{1882}', '\u{1883}', '\u{1884}', '\u{1885}', '\u{1886}', '\u{1887}', '\u{1888}', '\u{1889}', '\u{188A}', '\u{188B}', '\u{188C}', '\u{188D}', '\u{188E}', '\u{188F}', '\u{1890}', '\u{1891}', '\u{1892}', '\u{1893}', '\u{1894}', '\u{1895}', '\u{1896}', '\u{1897}', '\u{1898}', '\u{1899}', '\u{189A}', '\u{189B}', '\u{189C}', '\u{189D}', '\u{189E}', '\u{189F}', '\u{18A0}', '\u{18A1}', '\u{18A2}', '\u{18A3}', '\u{18A4}', '\u{18A5}', '\u{18A6}', '\u{18A7}', '\u{18A8}', '\u{18AA}', '\u{1900}', '\u{1901}', '\u{1902}', '\u{1903}', '\u{1904}', '\u{1905}', '\u{1906}', '\u{1907}', '\u{1908}', '\u{1909}', '\u{190A}', '\u{190B}', '\u{190C}', '\u{190D}', '\u{190E}', '\u{190F}', '\u{1910}', '\u{1911}', '\u{1912}', '\u{1913}', '\u{1914}', '\u{1915}', '\u{1916}', '\u{1917}', '\u{1918}', '\u{1919}', '\u{191A}', '\u{191B}', '\u{191C}', '\u{1950}', '\u{1951}', '\u{1952}', '\u{1953}', '\u{1954}', '\u{1955}', '\u{1956}', '\u{1957}', '\u{1958}', '\u{1959}', '\u{195A}', '\u{195B}', '\u{195C}', '\u{195D}', '\u{195E}', '\u{195F}', '\u{1960}', '\u{1961}', '\u{1962}', '\u{1963}', '\u{1964}', '\u{1965}', '\u{1966}', '\u{1967}', '\u{1968}', '\u{1969}', '\u{196A}', '\u{196B}', '\u{196C}', '\u{196D}', '\u{1970}', '\u{1971}', '\u{1972}', '\u{1973}', '\u{1974}', '\u{1980}', '\u{1981}', '\u{1982}', '\u{1983}', '\u{1984}', '\u{1985}', '\u{1986}', '\u{1987}', '\u{1988}', '\u{1989}', '\u{198A}', '\u{198B}', '\u{198C}', '\u{198D}', '\u{198E}', '\u{198F}', '\u{1990}', '\u{1991}', '\u{1992}', '\u{1993}', '\u{1994}', '\u{1995}', '\u{1996}', '\u{1997}', '\u{1998}', '\u{1999}', '\u{199A}', '\u{199B}', '\u{199C}', '\u{199D}', '\u{199E}', '\u{199F}', '\u{19A0}', '\u{19A1}', '\u{19A2}', '\u{19A3}', '\u{19A4}', '\u{19A5}', '\u{19A6}', '\u{19A7}', '\u{19A8}', '\u{19A9}', '\u{19C1}', '\u{19C2}', '\u{19C3}', '\u{19C4}', '\u{19C5}', '\u{19C6}', '\u{19C7}', '\u{1A00}', '\u{1A01}', '\u{1A02}', '\u{1A03}', '\u{1A04}', '\u{1A05}', '\u{1A06}', '\u{1A07}', '\u{1A08}', '\u{1A09}', '\u{1A0A}', '\u{1A0B}', '\u{1A0C}', '\u{1A0D}', '\u{1A0E}', '\u{1A0F}', '\u{1A10}', '\u{1A11}', '\u{1A12}', '\u{1A13}', '\u{1A14}', '\u{1A15}', '\u{1A16}', '\u{1B05}', '\u{1B06}', '\u{1B07}', '\u{1B08}', '\u{1B09}', '\u{1B0A}', '\u{1B0B}', '\u{1B0C}', '\u{1B0D}', '\u{1B0E}', '\u{1B0F}', '\u{1B10}', '\u{1B11}', '\u{1B12}', '\u{1B13}', '\u{1B14}', '\u{1B15}', '\u{1B16}', '\u{1B17}', '\u{1B18}', '\u{1B19}', '\u{1B1A}', '\u{1B1B}', '\u{1B1C}', '\u{1B1D}', '\u{1B1E}', '\u{1B1F}', '\u{1B20}', '\u{1B21}', '\u{1B22}', '\u{1B23}', '\u{1B24}', '\u{1B25}', '\u{1B26}', '\u{1B27}', '\u{1B28}', '\u{1B29}', '\u{1B2A}', '\u{1B2B}', '\u{1B2C}', '\u{1B2D}', '\u{1B2E}', '\u{1B2F}', '\u{1B30}', '\u{1B31}', '\u{1B32}', '\u{1B33}', '\u{1B45}', '\u{1B46}', '\u{1B47}', '\u{1B48}', '\u{1B49}', '\u{1B4A}', '\u{1B4B}', '\u{1B83}', '\u{1B84}', '\u{1B85}', '\u{1B86}', '\u{1B87}', '\u{1B88}', '\u{1B89}', '\u{1B8A}', '\u{1B8B}', '\u{1B8C}', '\u{1B8D}', '\u{1B8E}', '\u{1B8F}', '\u{1B90}', '\u{1B91}', '\u{1B92}', '\u{1B93}', '\u{1B94}', '\u{1B95}', '\u{1B96}', '\u{1B97}', '\u{1B98}', '\u{1B99}', '\u{1B9A}', '\u{1B9B}', '\u{1B9C}', '\u{1B9D}', '\u{1B9E}', '\u{1B9F}', '\u{1BA0}', '\u{1BAE}', '\u{1BAF}', '\u{1C00}', '\u{1C01}', '\u{1C02}', '\u{1C03}', '\u{1C04}', '\u{1C05}', '\u{1C06}', '\u{1C07}', '\u{1C08}', '\u{1C09}', '\u{1C0A}', '\u{1C0B}', '\u{1C0C}', '\u{1C0D}', '\u{1C0E}', '\u{1C0F}', '\u{1C10}', '\u{1C11}', '\u{1C12}', '\u{1C13}', '\u{1C14}', '\u{1C15}', '\u{1C16}', '\u{1C17}', '\u{1C18}', '\u{1C19}', '\u{1C1A}', '\u{1C1B}', '\u{1C1C}', '\u{1C1D}', '\u{1C1E}', '\u{1C1F}', '\u{1C20}', '\u{1C21}', '\u{1C22}', '\u{1C23}', '\u{1C4D}', '\u{1C4E}', '\u{1C4F}', '\u{1C5A}', '\u{1C5B}', '\u{1C5C}', '\u{1C5D}', '\u{1C5E}', '\u{1C5F}', '\u{1C60}', '\u{1C61}', '\u{1C62}', '\u{1C63}', '\u{1C64}', '\u{1C65}', '\u{1C66}', '\u{1C67}', '\u{1C68}', '\u{1C69}', '\u{1C6A}', '\u{1C6B}', '\u{1C6C}', '\u{1C6D}', '\u{1C6E}', '\u{1C6F}', '\u{1C70}', '\u{1C71}', '\u{1C72}', '\u{1C73}', '\u{1C74}', '\u{1C75}', '\u{1C76}', '\u{1C77}', '\u{2135}', '\u{2136}', '\u{2137}', '\u{2138}', '\u{2D30}', '\u{2D31}', '\u{2D32}', '\u{2D33}', '\u{2D34}', '\u{2D35}', '\u{2D36}', '\u{2D37}', '\u{2D38}', '\u{2D39}', '\u{2D3A}', '\u{2D3B}', '\u{2D3C}', '\u{2D3D}', '\u{2D3E}', '\u{2D3F}', '\u{2D40}', '\u{2D41}', '\u{2D42}', '\u{2D43}', '\u{2D44}', '\u{2D45}', '\u{2D46}', '\u{2D47}', '\u{2D48}', '\u{2D49}', '\u{2D4A}', '\u{2D4B}', '\u{2D4C}', '\u{2D4D}', '\u{2D4E}', '\u{2D4F}', '\u{2D50}', '\u{2D51}', '\u{2D52}', '\u{2D53}', '\u{2D54}', '\u{2D55}', '\u{2D56}', '\u{2D57}', '\u{2D58}', '\u{2D59}', '\u{2D5A}', '\u{2D5B}', '\u{2D5C}', '\u{2D5D}', '\u{2D5E}', '\u{2D5F}', '\u{2D60}', '\u{2D61}', '\u{2D62}', '\u{2D63}', '\u{2D64}', '\u{2D65}', '\u{2D80}', '\u{2D81}', '\u{2D82}', '\u{2D83}', '\u{2D84}', '\u{2D85}', '\u{2D86}', '\u{2D87}', '\u{2D88}', '\u{2D89}', '\u{2D8A}', '\u{2D8B}', '\u{2D8C}', '\u{2D8D}', '\u{2D8E}', '\u{2D8F}', '\u{2D90}', '\u{2D91}', '\u{2D92}', '\u{2D93}', '\u{2D94}', '\u{2D95}', '\u{2D96}', '\u{2DA0}', '\u{2DA1}', '\u{2DA2}', '\u{2DA3}', '\u{2DA4}', '\u{2DA5}', '\u{2DA6}', '\u{2DA8}', '\u{2DA9}', '\u{2DAA}', '\u{2DAB}', '\u{2DAC}', '\u{2DAD}', '\u{2DAE}', '\u{2DB0}', '\u{2DB1}', '\u{2DB2}', '\u{2DB3}', '\u{2DB4}', '\u{2DB5}', '\u{2DB6}', '\u{2DB8}', '\u{2DB9}', '\u{2DBA}', '\u{2DBB}', '\u{2DBC}', '\u{2DBD}', '\u{2DBE}', '\u{2DC0}', '\u{2DC1}', '\u{2DC2}', '\u{2DC3}', '\u{2DC4}', '\u{2DC5}', '\u{2DC6}', '\u{2DC8}', '\u{2DC9}', '\u{2DCA}', '\u{2DCB}', '\u{2DCC}', '\u{2DCD}', '\u{2DCE}', '\u{2DD0}', '\u{2DD1}', '\u{2DD2}', '\u{2DD3}', '\u{2DD4}', '\u{2DD5}', '\u{2DD6}', '\u{2DD8}', '\u{2DD9}', '\u{2DDA}', '\u{2DDB}', '\u{2DDC}', '\u{2DDD}', '\u{2DDE}', '\u{3006}', '\u{303C}', '\u{3041}', '\u{3042}', '\u{3043}', '\u{3044}', '\u{3045}', '\u{3046}', '\u{3047}', '\u{3048}', '\u{3049}', '\u{304A}', '\u{304B}', '\u{304C}', '\u{304D}', '\u{304E}', '\u{304F}', '\u{3050}', '\u{3051}', '\u{3052}', '\u{3053}', '\u{3054}', '\u{3055}', '\u{3056}', '\u{3057}', '\u{3058}', '\u{3059}', '\u{305A}', '\u{305B}', '\u{305C}', '\u{305D}', '\u{305E}', '\u{305F}', '\u{3060}', '\u{3061}', '\u{3062}', '\u{3063}', '\u{3064}', '\u{3065}', '\u{3066}', '\u{3067}', '\u{3068}', '\u{3069}', '\u{306A}', '\u{306B}', '\u{306C}', '\u{306D}', '\u{306E}', '\u{306F}', '\u{3070}', '\u{3071}', '\u{3072}', '\u{3073}', '\u{3074}', '\u{3075}', '\u{3076}', '\u{3077}', '\u{3078}', '\u{3079}', '\u{307A}', '\u{307B}', '\u{307C}', '\u{307D}', '\u{307E}', '\u{307F}', '\u{3080}', '\u{3081}', '\u{3082}', '\u{3083}', '\u{3084}', '\u{3085}', '\u{3086}', '\u{3087}', '\u{3088}', '\u{3089}', '\u{308A}', '\u{308B}', '\u{308C}', '\u{308D}', '\u{308E}', '\u{308F}', '\u{3090}', '\u{3091}', '\u{3092}', '\u{3093}', '\u{3094}', '\u{3095}', '\u{3096}', '\u{309F}', '\u{30A1}', '\u{30A2}', '\u{30A3}', '\u{30A4}', '\u{30A5}', '\u{30A6}', '\u{30A7}', '\u{30A8}', '\u{30A9}', '\u{30AA}', '\u{30AB}', '\u{30AC}', '\u{30AD}', '\u{30AE}', '\u{30AF}', '\u{30B0}', '\u{30B1}', '\u{30B2}', '\u{30B3}', '\u{30B4}', '\u{30B5}', '\u{30B6}', '\u{30B7}', '\u{30B8}', '\u{30B9}', '\u{30BA}', '\u{30BB}', '\u{30BC}', '\u{30BD}', '\u{30BE}', '\u{30BF}', '\u{30C0}', '\u{30C1}', '\u{30C2}', '\u{30C3}', '\u{30C4}', '\u{30C5}', '\u{30C6}', '\u{30C7}', '\u{30C8}', '\u{30C9}', '\u{30CA}', '\u{30CB}', '\u{30CC}', '\u{30CD}', '\u{30CE}', '\u{30CF}', '\u{30D0}', '\u{30D1}', '\u{30D2}', '\u{30D3}', '\u{30D4}', '\u{30D5}', '\u{30D6}', '\u{30D7}', '\u{30D8}', '\u{30D9}', '\u{30DA}', '\u{30DB}', '\u{30DC}', '\u{30DD}', '\u{30DE}', '\u{30DF}', '\u{30E0}', '\u{30E1}', '\u{30E2}', '\u{30E3}', '\u{30E4}', '\u{30E5}', '\u{30E6}', '\u{30E7}', '\u{30E8}', '\u{30E9}', '\u{30EA}', '\u{30EB}', '\u{30EC}', '\u{30ED}', '\u{30EE}', '\u{30EF}', '\u{30F0}', '\u{30F1}', '\u{30F2}', '\u{30F3}', '\u{30F4}', '\u{30F5}', '\u{30F6}', '\u{30F7}', '\u{30F8}', '\u{30F9}', '\u{30FA}', '\u{30FF}', '\u{3105}', '\u{3106}', '\u{3107}', '\u{3108}', '\u{3109}', '\u{310A}', '\u{310B}', '\u{310C}', '\u{310D}', '\u{310E}', '\u{310F}', '\u{3110}', '\u{3111}', '\u{3112}', '\u{3113}', '\u{3114}', '\u{3115}', '\u{3116}', '\u{3117}', '\u{3118}', '\u{3119}', '\u{311A}', '\u{311B}', '\u{311C}', '\u{311D}', '\u{311E}', '\u{311F}', '\u{3120}', '\u{3121}', '\u{3122}', '\u{3123}', '\u{3124}', '\u{3125}', '\u{3126}', '\u{3127}', '\u{3128}', '\u{3129}', '\u{312A}', '\u{312B}', '\u{312C}', '\u{312D}', '\u{3131}', '\u{3132}', '\u{3133}', '\u{3134}', '\u{3135}', '\u{3136}', '\u{3137}', '\u{3138}', '\u{3139}', '\u{313A}', '\u{313B}', '\u{313C}', '\u{313D}', '\u{313E}', '\u{313F}', '\u{3140}', '\u{3141}', '\u{3142}', '\u{3143}', '\u{3144}', '\u{3145}', '\u{3146}', '\u{3147}', '\u{3148}', '\u{3149}', '\u{314A}', '\u{314B}', '\u{314C}', '\u{314D}', '\u{314E}', '\u{314F}', '\u{3150}', '\u{3151}', '\u{3152}', '\u{3153}', '\u{3154}', '\u{3155}', '\u{3156}', '\u{3157}', '\u{3158}', '\u{3159}', '\u{315A}', '\u{315B}', '\u{315C}', '\u{315D}', '\u{315E}', '\u{315F}', '\u{3160}', '\u{3161}', '\u{3162}', '\u{3163}', '\u{3164}', '\u{3165}', '\u{3166}', '\u{3167}', '\u{3168}', '\u{3169}', '\u{316A}', '\u{316B}', '\u{316C}', '\u{316D}', '\u{316E}', '\u{316F}', '\u{3170}', '\u{3171}', '\u{3172}', '\u{3173}', '\u{3174}', '\u{3175}', '\u{3176}', '\u{3177}', '\u{3178}', '\u{3179}', '\u{317A}', '\u{317B}', '\u{317C}', '\u{317D}', '\u{317E}', '\u{317F}', '\u{3180}', '\u{3181}', '\u{3182}', '\u{3183}', '\u{3184}', '\u{3185}', '\u{3186}', '\u{3187}', '\u{3188}', '\u{3189}', '\u{318A}', '\u{318B}', '\u{318C}', '\u{318D}', '\u{318E}', '\u{31A0}', '\u{31A1}', '\u{31A2}', '\u{31A3}', '\u{31A4}', '\u{31A5}', '\u{31A6}', '\u{31A7}', '\u{31A8}', '\u{31A9}', '\u{31AA}', '\u{31AB}', '\u{31AC}', '\u{31AD}', '\u{31AE}', '\u{31AF}', '\u{31B0}', '\u{31B1}', '\u{31B2}', '\u{31B3}', '\u{31B4}', '\u{31B5}', '\u{31B6}', '\u{31B7}', '\u{31F0}', '\u{31F1}', '\u{31F2}', '\u{31F3}', '\u{31F4}', '\u{31F5}', '\u{31F6}', '\u{31F7}', '\u{31F8}', '\u{31F9}', '\u{31FA}', '\u{31FB}', '\u{31FC}', '\u{31FD}', '\u{31FE}', '\u{31FF}', '\u{3400}', '\u{4DB5}', '\u{4E00}', '\u{9FC3}', '\u{A000}', '\u{A001}', '\u{A002}', '\u{A003}', '\u{A004}', '\u{A005}', '\u{A006}', '\u{A007}', '\u{A008}', '\u{A009}', '\u{A00A}', '\u{A00B}', '\u{A00C}', '\u{A00D}', '\u{A00E}', '\u{A00F}', '\u{A010}', '\u{A011}', '\u{A012}', '\u{A013}', '\u{A014}', '\u{A016}', '\u{A017}', '\u{A018}', '\u{A019}', '\u{A01A}', '\u{A01B}', '\u{A01C}', '\u{A01D}', '\u{A01E}', '\u{A01F}', '\u{A020}', '\u{A021}', '\u{A022}', '\u{A023}', '\u{A024}', '\u{A025}', '\u{A026}', '\u{A027}', '\u{A028}', '\u{A029}', '\u{A02A}', '\u{A02B}', '\u{A02C}', '\u{A02D}', '\u{A02E}', '\u{A02F}', '\u{A030}', '\u{A031}', '\u{A032}', '\u{A033}', '\u{A034}', '\u{A035}', '\u{A036}', '\u{A037}', '\u{A038}', '\u{A039}', '\u{A03A}', '\u{A03B}', '\u{A03C}', '\u{A03D}', '\u{A03E}', '\u{A03F}', '\u{A040}', '\u{A041}', '\u{A042}', '\u{A043}', '\u{A044}', '\u{A045}', '\u{A046}', '\u{A047}', '\u{A048}', '\u{A049}', '\u{A04A}', '\u{A04B}', '\u{A04C}', '\u{A04D}', '\u{A04E}', '\u{A04F}', '\u{A050}', '\u{A051}', '\u{A052}', '\u{A053}', '\u{A054}', '\u{A055}', '\u{A056}', '\u{A057}', '\u{A058}', '\u{A059}', '\u{A05A}', '\u{A05B}', '\u{A05C}', '\u{A05D}', '\u{A05E}', '\u{A05F}', '\u{A060}', '\u{A061}', '\u{A062}', '\u{A063}', '\u{A064}', '\u{A065}', '\u{A066}', '\u{A067}', '\u{A068}', '\u{A069}', '\u{A06A}', '\u{A06B}', '\u{A06C}', '\u{A06D}', '\u{A06E}', '\u{A06F}', '\u{A070}', '\u{A071}', '\u{A072}', '\u{A073}', '\u{A074}', '\u{A075}', '\u{A076}', '\u{A077}', '\u{A078}', '\u{A079}', '\u{A07A}', '\u{A07B}', '\u{A07C}', '\u{A07D}', '\u{A07E}', '\u{A07F}', '\u{A080}', '\u{A081}', '\u{A082}', '\u{A083}', '\u{A084}', '\u{A085}', '\u{A086}', '\u{A087}', '\u{A088}', '\u{A089}', '\u{A08A}', '\u{A08B}', '\u{A08C}', '\u{A08D}', '\u{A08E}', '\u{A08F}', '\u{A090}', '\u{A091}', '\u{A092}', '\u{A093}', '\u{A094}', '\u{A095}', '\u{A096}', '\u{A097}', '\u{A098}', '\u{A099}', '\u{A09A}', '\u{A09B}', '\u{A09C}', '\u{A09D}', '\u{A09E}', '\u{A09F}', '\u{A0A0}', '\u{A0A1}', '\u{A0A2}', '\u{A0A3}', '\u{A0A4}', '\u{A0A5}', '\u{A0A6}', '\u{A0A7}', '\u{A0A8}', '\u{A0A9}', '\u{A0AA}', '\u{A0AB}', '\u{A0AC}', '\u{A0AD}', '\u{A0AE}', '\u{A0AF}', '\u{A0B0}', '\u{A0B1}', '\u{A0B2}', '\u{A0B3}', '\u{A0B4}', '\u{A0B5}', '\u{A0B6}', '\u{A0B7}', '\u{A0B8}', '\u{A0B9}', '\u{A0BA}', '\u{A0BB}', '\u{A0BC}', '\u{A0BD}', '\u{A0BE}', '\u{A0BF}', '\u{A0C0}', '\u{A0C1}', '\u{A0C2}', '\u{A0C3}', '\u{A0C4}', '\u{A0C5}', '\u{A0C6}', '\u{A0C7}', '\u{A0C8}', '\u{A0C9}', '\u{A0CA}', '\u{A0CB}', '\u{A0CC}', '\u{A0CD}', '\u{A0CE}', '\u{A0CF}', '\u{A0D0}', '\u{A0D1}', '\u{A0D2}', '\u{A0D3}', '\u{A0D4}', '\u{A0D5}', '\u{A0D6}', '\u{A0D7}', '\u{A0D8}', '\u{A0D9}', '\u{A0DA}', '\u{A0DB}', '\u{A0DC}', '\u{A0DD}', '\u{A0DE}', '\u{A0DF}', '\u{A0E0}', '\u{A0E1}', '\u{A0E2}', '\u{A0E3}', '\u{A0E4}', '\u{A0E5}', '\u{A0E6}', '\u{A0E7}', '\u{A0E8}', '\u{A0E9}', '\u{A0EA}', '\u{A0EB}', '\u{A0EC}', '\u{A0ED}', '\u{A0EE}', '\u{A0EF}', '\u{A0F0}', '\u{A0F1}', '\u{A0F2}', '\u{A0F3}', '\u{A0F4}', '\u{A0F5}', '\u{A0F6}', '\u{A0F7}', '\u{A0F8}', '\u{A0F9}', '\u{A0FA}', '\u{A0FB}', '\u{A0FC}', '\u{A0FD}', '\u{A0FE}', '\u{A0FF}', '\u{A100}', '\u{A101}', '\u{A102}', '\u{A103}', '\u{A104}', '\u{A105}', '\u{A106}', '\u{A107}', '\u{A108}', '\u{A109}', '\u{A10A}', '\u{A10B}', '\u{A10C}', '\u{A10D}', '\u{A10E}', '\u{A10F}', '\u{A110}', '\u{A111}', '\u{A112}', '\u{A113}', '\u{A114}', '\u{A115}', '\u{A116}', '\u{A117}', '\u{A118}', '\u{A119}', '\u{A11A}', '\u{A11B}', '\u{A11C}', '\u{A11D}', '\u{A11E}', '\u{A11F}', '\u{A120}', '\u{A121}', '\u{A122}', '\u{A123}', '\u{A124}', '\u{A125}', '\u{A126}', '\u{A127}', '\u{A128}', '\u{A129}', '\u{A12A}', '\u{A12B}', '\u{A12C}', '\u{A12D}', '\u{A12E}', '\u{A12F}', '\u{A130}', '\u{A131}', '\u{A132}', '\u{A133}', '\u{A134}', '\u{A135}', '\u{A136}', '\u{A137}', '\u{A138}', '\u{A139}', '\u{A13A}', '\u{A13B}', '\u{A13C}', '\u{A13D}', '\u{A13E}', '\u{A13F}', '\u{A140}', '\u{A141}', '\u{A142}', '\u{A143}', '\u{A144}', '\u{A145}', '\u{A146}', '\u{A147}', '\u{A148}', '\u{A149}', '\u{A14A}', '\u{A14B}', '\u{A14C}', '\u{A14D}', '\u{A14E}', '\u{A14F}', '\u{A150}', '\u{A151}', '\u{A152}', '\u{A153}', '\u{A154}', '\u{A155}', '\u{A156}', '\u{A157}', '\u{A158}', '\u{A159}', '\u{A15A}', '\u{A15B}', '\u{A15C}', '\u{A15D}', '\u{A15E}', '\u{A15F}', '\u{A160}', '\u{A161}', '\u{A162}', '\u{A163}', '\u{A164}', '\u{A165}', '\u{A166}', '\u{A167}', '\u{A168}', '\u{A169}', '\u{A16A}', '\u{A16B}', '\u{A16C}', '\u{A16D}', '\u{A16E}', '\u{A16F}', '\u{A170}', '\u{A171}', '\u{A172}', '\u{A173}', '\u{A174}', '\u{A175}', '\u{A176}', '\u{A177}', '\u{A178}', '\u{A179}', '\u{A17A}', '\u{A17B}', '\u{A17C}', '\u{A17D}', '\u{A17E}', '\u{A17F}', '\u{A180}', '\u{A181}', '\u{A182}', '\u{A183}', '\u{A184}', '\u{A185}', '\u{A186}', '\u{A187}', '\u{A188}', '\u{A189}', '\u{A18A}', '\u{A18B}', '\u{A18C}', '\u{A18D}', '\u{A18E}', '\u{A18F}', '\u{A190}', '\u{A191}', '\u{A192}', '\u{A193}', '\u{A194}', '\u{A195}', '\u{A196}', '\u{A197}', '\u{A198}', '\u{A199}', '\u{A19A}', '\u{A19B}', '\u{A19C}', '\u{A19D}', '\u{A19E}', '\u{A19F}', '\u{A1A0}', '\u{A1A1}', '\u{A1A2}', '\u{A1A3}', '\u{A1A4}', '\u{A1A5}', '\u{A1A6}', '\u{A1A7}', '\u{A1A8}', '\u{A1A9}', '\u{A1AA}', '\u{A1AB}', '\u{A1AC}', '\u{A1AD}', '\u{A1AE}', '\u{A1AF}') + } + + fn is_unicode_letter_number(self) -> bool { + match_char_class!(self, + '\u{16EE}', '\u{16EF}', '\u{16F0}', '\u{2160}', '\u{2161}', '\u{2162}', '\u{2163}', '\u{2164}', '\u{2165}', '\u{2166}', '\u{2167}', '\u{2168}', '\u{2169}', '\u{216A}', '\u{216B}', '\u{216C}', '\u{216D}', '\u{216E}', '\u{216F}', '\u{2170}', '\u{2171}', '\u{2172}', '\u{2173}', '\u{2174}', '\u{2175}', '\u{2176}', '\u{2177}', '\u{2178}', '\u{2179}', '\u{217A}', '\u{217B}', '\u{217C}', '\u{217D}', '\u{217E}', '\u{217F}', '\u{2180}', '\u{2181}', '\u{2182}', '\u{2185}', '\u{2186}', '\u{2187}', '\u{2188}', '\u{3007}', '\u{3021}', '\u{3022}', '\u{3023}', '\u{3024}', '\u{3025}', '\u{3026}', '\u{3027}', '\u{3028}', '\u{3029}', '\u{3038}', '\u{3039}', '\u{303A}') + } + + fn is_unicode_nonspacing_mark(self) -> bool { + match_char_class!(self, + '\u{0300}', '\u{0301}', '\u{0302}', '\u{0303}', '\u{0304}', '\u{0305}', '\u{0306}', '\u{0307}', '\u{0308}', '\u{0309}', '\u{030A}', '\u{030B}', '\u{030C}', '\u{030D}', '\u{030E}', '\u{030F}', '\u{0310}', '\u{0311}', '\u{0312}', '\u{0313}', '\u{0314}', '\u{0315}', '\u{0316}', '\u{0317}', '\u{0318}', '\u{0319}', '\u{031A}', '\u{031B}', '\u{031C}', '\u{031D}', '\u{031E}', '\u{031F}', '\u{0320}', '\u{0321}', '\u{0322}', '\u{0323}', '\u{0324}', '\u{0325}', '\u{0326}', '\u{0327}', '\u{0328}', '\u{0329}', '\u{032A}', '\u{032B}', '\u{032C}', '\u{032D}', '\u{032E}', '\u{032F}', '\u{0330}', '\u{0331}', '\u{0332}', '\u{0333}', '\u{0334}', '\u{0335}', '\u{0336}', '\u{0337}', '\u{0338}', '\u{0339}', '\u{033A}', '\u{033B}', '\u{033C}', '\u{033D}', '\u{033E}', '\u{033F}', '\u{0340}', '\u{0341}', '\u{0342}', '\u{0343}', '\u{0344}', '\u{0345}', '\u{0346}', '\u{0347}', '\u{0348}', '\u{0349}', '\u{034A}', '\u{034B}', '\u{034C}', '\u{034D}', '\u{034E}', '\u{034F}', '\u{0350}', '\u{0351}', '\u{0352}', '\u{0353}', '\u{0354}', '\u{0355}', '\u{0356}', '\u{0357}', '\u{0358}', '\u{0359}', '\u{035A}', '\u{035B}', '\u{035C}', '\u{035D}', '\u{035E}', '\u{035F}', '\u{0360}', '\u{0361}', '\u{0362}', '\u{0363}', '\u{0364}', '\u{0365}', '\u{0366}', '\u{0367}', '\u{0368}', '\u{0369}', '\u{036A}', '\u{036B}', '\u{036C}', '\u{036D}', '\u{036E}', '\u{036F}', '\u{0483}', '\u{0484}', '\u{0485}', '\u{0486}', '\u{0487}', '\u{0591}', '\u{0592}', '\u{0593}', '\u{0594}', '\u{0595}', '\u{0596}', '\u{0597}', '\u{0598}', '\u{0599}', '\u{059A}', '\u{059B}', '\u{059C}', '\u{059D}', '\u{059E}', '\u{059F}', '\u{05A0}', '\u{05A1}', '\u{05A2}', '\u{05A3}', '\u{05A4}', '\u{05A5}', '\u{05A6}', '\u{05A7}', '\u{05A8}', '\u{05A9}', '\u{05AA}', '\u{05AB}', '\u{05AC}', '\u{05AD}', '\u{05AE}', '\u{05AF}', '\u{05B0}', '\u{05B1}', '\u{05B2}', '\u{05B3}', '\u{05B4}', '\u{05B5}', '\u{05B6}', '\u{05B7}', '\u{05B8}', '\u{05B9}', '\u{05BA}', '\u{05BB}', '\u{05BC}', '\u{05BD}', '\u{05BF}', '\u{05C1}', '\u{05C2}', '\u{05C4}', '\u{05C5}', '\u{05C7}', '\u{0610}', '\u{0611}', '\u{0612}', '\u{0613}', '\u{0614}', '\u{0615}', '\u{0616}', '\u{0617}', '\u{0618}', '\u{0619}', '\u{061A}', '\u{064B}', '\u{064C}', '\u{064D}', '\u{064E}', '\u{064F}', '\u{0650}', '\u{0651}', '\u{0652}', '\u{0653}', '\u{0654}', '\u{0655}', '\u{0656}', '\u{0657}', '\u{0658}', '\u{0659}', '\u{065A}', '\u{065B}', '\u{065C}', '\u{065D}', '\u{065E}', '\u{0670}', '\u{06D6}', '\u{06D7}', '\u{06D8}', '\u{06D9}', '\u{06DA}', '\u{06DB}', '\u{06DC}', '\u{06DF}', '\u{06E0}', '\u{06E1}', '\u{06E2}', '\u{06E3}', '\u{06E4}', '\u{06E7}', '\u{06E8}', '\u{06EA}', '\u{06EB}', '\u{06EC}', '\u{06ED}', '\u{0711}', '\u{0730}', '\u{0731}', '\u{0732}', '\u{0733}', '\u{0734}', '\u{0735}', '\u{0736}', '\u{0737}', '\u{0738}', '\u{0739}', '\u{073A}', '\u{073B}', '\u{073C}', '\u{073D}', '\u{073E}', '\u{073F}', '\u{0740}', '\u{0741}', '\u{0742}', '\u{0743}', '\u{0744}', '\u{0745}', '\u{0746}', '\u{0747}', '\u{0748}', '\u{0749}', '\u{074A}', '\u{07A6}', '\u{07A7}', '\u{07A8}', '\u{07A9}', '\u{07AA}', '\u{07AB}', '\u{07AC}', '\u{07AD}', '\u{07AE}', '\u{07AF}', '\u{07B0}', '\u{07EB}', '\u{07EC}', '\u{07ED}', '\u{07EE}', '\u{07EF}', '\u{07F0}', '\u{07F1}', '\u{07F2}', '\u{07F3}', '\u{0901}', '\u{0902}', '\u{093C}', '\u{0941}', '\u{0942}', '\u{0943}', '\u{0944}', '\u{0945}', '\u{0946}', '\u{0947}', '\u{0948}', '\u{094D}', '\u{0951}', '\u{0952}', '\u{0953}', '\u{0954}', '\u{0962}', '\u{0963}', '\u{0981}', '\u{09BC}', '\u{09C1}', '\u{09C2}', '\u{09C3}', '\u{09C4}', '\u{09CD}', '\u{09E2}', '\u{09E3}', '\u{0A01}', '\u{0A02}', '\u{0A3C}', '\u{0A41}', '\u{0A42}', '\u{0A47}', '\u{0A48}', '\u{0A4B}', '\u{0A4C}', '\u{0A4D}', '\u{0A51}', '\u{0A70}', '\u{0A71}', '\u{0A75}', '\u{0A81}', '\u{0A82}', '\u{0ABC}', '\u{0AC1}', '\u{0AC2}', '\u{0AC3}', '\u{0AC4}', '\u{0AC5}', '\u{0AC7}', '\u{0AC8}', '\u{0ACD}', '\u{0AE2}', '\u{0AE3}', '\u{0B01}', '\u{0B3C}', '\u{0B3F}', '\u{0B41}', '\u{0B42}', '\u{0B43}', '\u{0B44}', '\u{0B4D}', '\u{0B56}', '\u{0B62}', '\u{0B63}', '\u{0B82}', '\u{0BC0}', '\u{0BCD}', '\u{0C3E}', '\u{0C3F}', '\u{0C40}', '\u{0C46}', '\u{0C47}', '\u{0C48}', '\u{0C4A}', '\u{0C4B}', '\u{0C4C}', '\u{0C4D}', '\u{0C55}', '\u{0C56}', '\u{0C62}', '\u{0C63}', '\u{0CBC}', '\u{0CBF}', '\u{0CC6}', '\u{0CCC}', '\u{0CCD}', '\u{0CE2}', '\u{0CE3}', '\u{0D41}', '\u{0D42}', '\u{0D43}', '\u{0D44}', '\u{0D4D}', '\u{0D62}', '\u{0D63}', '\u{0DCA}', '\u{0DD2}', '\u{0DD3}', '\u{0DD4}', '\u{0DD6}', '\u{0E31}', '\u{0E34}', '\u{0E35}', '\u{0E36}', '\u{0E37}', '\u{0E38}', '\u{0E39}', '\u{0E3A}', '\u{0E47}', '\u{0E48}', '\u{0E49}', '\u{0E4A}', '\u{0E4B}', '\u{0E4C}', '\u{0E4D}', '\u{0E4E}', '\u{0EB1}', '\u{0EB4}', '\u{0EB5}', '\u{0EB6}', '\u{0EB7}', '\u{0EB8}', '\u{0EB9}', '\u{0EBB}', '\u{0EBC}', '\u{0EC8}', '\u{0EC9}', '\u{0ECA}', '\u{0ECB}', '\u{0ECC}', '\u{0ECD}', '\u{0F18}', '\u{0F19}', '\u{0F35}', '\u{0F37}', '\u{0F39}', '\u{0F71}', '\u{0F72}', '\u{0F73}', '\u{0F74}', '\u{0F75}', '\u{0F76}', '\u{0F77}', '\u{0F78}', '\u{0F79}', '\u{0F7A}', '\u{0F7B}', '\u{0F7C}', '\u{0F7D}', '\u{0F7E}', '\u{0F80}', '\u{0F81}', '\u{0F82}', '\u{0F83}', '\u{0F84}', '\u{0F86}', '\u{0F87}', '\u{0F90}', '\u{0F91}', '\u{0F92}', '\u{0F93}', '\u{0F94}', '\u{0F95}', '\u{0F96}', '\u{0F97}', '\u{0F99}', '\u{0F9A}', '\u{0F9B}', '\u{0F9C}', '\u{0F9D}', '\u{0F9E}', '\u{0F9F}', '\u{0FA0}', '\u{0FA1}', '\u{0FA2}', '\u{0FA3}', '\u{0FA4}', '\u{0FA5}', '\u{0FA6}', '\u{0FA7}', '\u{0FA8}', '\u{0FA9}', '\u{0FAA}', '\u{0FAB}', '\u{0FAC}', '\u{0FAD}', '\u{0FAE}', '\u{0FAF}', '\u{0FB0}', '\u{0FB1}', '\u{0FB2}', '\u{0FB3}', '\u{0FB4}', '\u{0FB5}', '\u{0FB6}', '\u{0FB7}', '\u{0FB8}', '\u{0FB9}', '\u{0FBA}', '\u{0FBB}', '\u{0FBC}', '\u{0FC6}', '\u{102D}', '\u{102E}', '\u{102F}', '\u{1030}', '\u{1032}', '\u{1033}', '\u{1034}', '\u{1035}', '\u{1036}', '\u{1037}', '\u{1039}', '\u{103A}', '\u{103D}', '\u{103E}', '\u{1058}', '\u{1059}', '\u{105E}', '\u{105F}', '\u{1060}', '\u{1071}', '\u{1072}', '\u{1073}', '\u{1074}', '\u{1082}', '\u{1085}', '\u{1086}', '\u{108D}', '\u{135F}', '\u{1712}', '\u{1713}', '\u{1714}', '\u{1732}', '\u{1733}', '\u{1734}', '\u{1752}', '\u{1753}', '\u{1772}', '\u{1773}', '\u{17B7}', '\u{17B8}', '\u{17B9}', '\u{17BA}', '\u{17BB}', '\u{17BC}', '\u{17BD}', '\u{17C6}', '\u{17C9}', '\u{17CA}', '\u{17CB}', '\u{17CC}', '\u{17CD}', '\u{17CE}', '\u{17CF}', '\u{17D0}', '\u{17D1}', '\u{17D2}', '\u{17D3}', '\u{17DD}', '\u{180B}', '\u{180C}', '\u{180D}', '\u{18A9}', '\u{1920}', '\u{1921}', '\u{1922}', '\u{1927}', '\u{1928}', '\u{1932}', '\u{1939}', '\u{193A}', '\u{193B}', '\u{1A17}', '\u{1A18}', '\u{1B00}', '\u{1B01}', '\u{1B02}', '\u{1B03}', '\u{1B34}', '\u{1B36}', '\u{1B37}', '\u{1B38}', '\u{1B39}', '\u{1B3A}', '\u{1B3C}', '\u{1B42}', '\u{1B6B}', '\u{1B6C}', '\u{1B6D}', '\u{1B6E}', '\u{1B6F}', '\u{1B70}', '\u{1B71}', '\u{1B72}', '\u{1B73}', '\u{1B80}', '\u{1B81}', '\u{1BA2}', '\u{1BA3}', '\u{1BA4}', '\u{1BA5}', '\u{1BA8}', '\u{1BA9}', '\u{1C2C}', '\u{1C2D}', '\u{1C2E}', '\u{1C2F}', '\u{1C30}', '\u{1C31}', '\u{1C32}', '\u{1C33}', '\u{1C36}', '\u{1C37}', '\u{1DC0}', '\u{1DC1}', '\u{1DC2}', '\u{1DC3}', '\u{1DC4}', '\u{1DC5}', '\u{1DC6}', '\u{1DC7}', '\u{1DC8}', '\u{1DC9}', '\u{1DCA}', '\u{1DCB}', '\u{1DCC}', '\u{1DCD}', '\u{1DCE}', '\u{1DCF}', '\u{1DD0}', '\u{1DD1}', '\u{1DD2}', '\u{1DD3}', '\u{1DD4}', '\u{1DD5}', '\u{1DD6}', '\u{1DD7}', '\u{1DD8}', '\u{1DD9}', '\u{1DDA}', '\u{1DDB}', '\u{1DDC}', '\u{1DDD}', '\u{1DDE}', '\u{1DDF}', '\u{1DE0}', '\u{1DE1}', '\u{1DE2}', '\u{1DE3}', '\u{1DE4}', '\u{1DE5}', '\u{1DE6}', '\u{1DFE}', '\u{1DFF}', '\u{20D0}', '\u{20D1}', '\u{20D2}', '\u{20D3}', '\u{20D4}', '\u{20D5}', '\u{20D6}', '\u{20D7}', '\u{20D8}', '\u{20D9}', '\u{20DA}', '\u{20DB}', '\u{20DC}', '\u{20E1}', '\u{20E5}', '\u{20E6}', '\u{20E7}', '\u{20E8}', '\u{20E9}', '\u{20EA}', '\u{20EB}', '\u{20EC}', '\u{20ED}', '\u{20EE}', '\u{20EF}', '\u{20F0}', '\u{2DE0}', '\u{2DE1}', '\u{2DE2}', '\u{2DE3}', '\u{2DE4}', '\u{2DE5}', '\u{2DE6}', '\u{2DE7}', '\u{2DE8}', '\u{2DE9}', '\u{2DEA}', '\u{2DEB}', '\u{2DEC}', '\u{2DED}', '\u{2DEE}', '\u{2DEF}', '\u{2DF0}', '\u{2DF1}', '\u{2DF2}', '\u{2DF3}', '\u{2DF4}', '\u{2DF5}', '\u{2DF6}', '\u{2DF7}', '\u{2DF8}', '\u{2DF9}', '\u{2DFA}', '\u{2DFB}', '\u{2DFC}', '\u{2DFD}', '\u{2DFE}', '\u{2DFF}', '\u{302A}', '\u{302B}', '\u{302C}', '\u{302D}', '\u{302E}', '\u{302F}', '\u{3099}', '\u{309A}', '\u{A66F}', '\u{A67C}', '\u{A67D}', '\u{A802}', '\u{A806}', '\u{A80B}', '\u{A825}', '\u{A826}', '\u{A8C4}', '\u{A926}', '\u{A927}', '\u{A928}', '\u{A929}', '\u{A92A}', '\u{A92B}', '\u{A92C}', '\u{A92D}', '\u{A947}', '\u{A948}', '\u{A949}', '\u{A94A}', '\u{A94B}', '\u{A94C}', '\u{A94D}', '\u{A94E}', '\u{A94F}', '\u{A950}', '\u{A951}', '\u{AA29}', '\u{AA2A}', '\u{AA2B}', '\u{AA2C}', '\u{AA2D}', '\u{AA2E}', '\u{AA31}', '\u{AA32}', '\u{AA35}', '\u{AA36}', '\u{AA43}', '\u{AA4C}', '\u{FB1E}', '\u{FE00}', '\u{FE01}', '\u{FE02}', '\u{FE03}', '\u{FE04}', '\u{FE05}', '\u{FE06}', '\u{FE07}', '\u{FE08}', '\u{FE09}', '\u{FE0A}', '\u{FE0B}', '\u{FE0C}', '\u{FE0D}', '\u{FE0E}', '\u{FE0F}', '\u{FE20}', '\u{FE21}', '\u{FE22}', '\u{FE23}', '\u{FE24}', '\u{FE25}', '\u{FE26}', '\u{01BB}', '\u{01C0}', '\u{01C1}', '\u{01C2}', '\u{01C3}', '\u{0294}', '\u{05D0}', '\u{05D1}', '\u{05D2}', '\u{05D3}', '\u{05D4}', '\u{05D5}', '\u{05D6}', '\u{05D7}', '\u{05D8}', '\u{05D9}', '\u{05DA}', '\u{05DB}', '\u{05DC}', '\u{05DD}', '\u{05DE}', '\u{05DF}', '\u{05E0}', '\u{05E1}', '\u{05E2}', '\u{05E3}', '\u{05E4}', '\u{05E5}', '\u{05E6}', '\u{05E7}', '\u{05E8}', '\u{05E9}', '\u{05EA}', '\u{05F0}', '\u{05F1}', '\u{05F2}', '\u{0621}', '\u{0622}', '\u{0623}', '\u{0624}', '\u{0625}', '\u{0626}', '\u{0627}', '\u{0628}', '\u{0629}', '\u{062A}', '\u{062B}', '\u{062C}', '\u{062D}', '\u{062E}', '\u{062F}', '\u{0630}', '\u{0631}', '\u{0632}', '\u{0633}', '\u{0634}', '\u{0635}', '\u{0636}', '\u{0637}', '\u{0638}', '\u{0639}', '\u{063A}', '\u{063B}', '\u{063C}', '\u{063D}', '\u{063E}', '\u{063F}', '\u{0641}', '\u{0642}', '\u{0643}', '\u{0644}', '\u{0645}', '\u{0646}', '\u{0647}', '\u{0648}', '\u{0649}', '\u{064A}', '\u{066E}', '\u{066F}', '\u{0671}', '\u{0672}', '\u{0673}', '\u{0674}', '\u{0675}', '\u{0676}', '\u{0677}', '\u{0678}', '\u{0679}', '\u{067A}', '\u{067B}', '\u{067C}', '\u{067D}', '\u{067E}', '\u{067F}', '\u{0680}', '\u{0681}', '\u{0682}', '\u{0683}', '\u{0684}', '\u{0685}', '\u{0686}', '\u{0687}', '\u{0688}', '\u{0689}', '\u{068A}', '\u{068B}', '\u{068C}', '\u{068D}', '\u{068E}', '\u{068F}', '\u{0690}', '\u{0691}', '\u{0692}', '\u{0693}', '\u{0694}', '\u{0695}', '\u{0696}', '\u{0697}', '\u{0698}', '\u{0699}', '\u{069A}', '\u{069B}', '\u{069C}', '\u{069D}', '\u{069E}', '\u{069F}', '\u{06A0}', '\u{06A1}', '\u{06A2}', '\u{06A3}', '\u{06A4}', '\u{06A5}', '\u{06A6}', '\u{06A7}', '\u{06A8}', '\u{06A9}', '\u{06AA}', '\u{06AB}', '\u{06AC}', '\u{06AD}', '\u{06AE}', '\u{06AF}', '\u{06B0}', '\u{06B1}', '\u{06B2}', '\u{06B3}', '\u{06B4}', '\u{06B5}', '\u{06B6}', '\u{06B7}', '\u{06B8}', '\u{06B9}', '\u{06BA}', '\u{06BB}', '\u{06BC}', '\u{06BD}', '\u{06BE}', '\u{06BF}', '\u{06C0}', '\u{06C1}', '\u{06C2}', '\u{06C3}', '\u{06C4}', '\u{06C5}', '\u{06C6}', '\u{06C7}', '\u{06C8}', '\u{06C9}', '\u{06CA}', '\u{06CB}', '\u{06CC}', '\u{06CD}', '\u{06CE}', '\u{06CF}', '\u{06D0}', '\u{06D1}', '\u{06D2}', '\u{06D3}', '\u{06D5}', '\u{06EE}', '\u{06EF}', '\u{06FA}', '\u{06FB}', '\u{06FC}', '\u{06FF}', '\u{0710}', '\u{0712}', '\u{0713}', '\u{0714}', '\u{0715}', '\u{0716}', '\u{0717}', '\u{0718}', '\u{0719}', '\u{071A}', '\u{071B}', '\u{071C}', '\u{071D}', '\u{071E}', '\u{071F}', '\u{0720}', '\u{0721}', '\u{0722}', '\u{0723}', '\u{0724}', '\u{0725}', '\u{0726}', '\u{0727}', '\u{0728}', '\u{0729}', '\u{072A}', '\u{072B}', '\u{072C}', '\u{072D}', '\u{072E}', '\u{072F}', '\u{074D}', '\u{074E}', '\u{074F}', '\u{0750}', '\u{0751}', '\u{0752}', '\u{0753}', '\u{0754}', '\u{0755}', '\u{0756}', '\u{0757}', '\u{0758}', '\u{0759}', '\u{075A}', '\u{075B}', '\u{075C}', '\u{075D}', '\u{075E}', '\u{075F}', '\u{0760}', '\u{0761}', '\u{0762}', '\u{0763}', '\u{0764}', '\u{0765}', '\u{0766}', '\u{0767}', '\u{0768}', '\u{0769}', '\u{076A}', '\u{076B}', '\u{076C}', '\u{076D}', '\u{076E}', '\u{076F}', '\u{0770}', '\u{0771}', '\u{0772}', '\u{0773}', '\u{0774}', '\u{0775}', '\u{0776}', '\u{0777}', '\u{0778}', '\u{0779}', '\u{077A}', '\u{077B}', '\u{077C}', '\u{077D}', '\u{077E}', '\u{077F}', '\u{0780}', '\u{0781}', '\u{0782}', '\u{0783}', '\u{0784}', '\u{0785}', '\u{0786}', '\u{0787}', '\u{0788}', '\u{0789}', '\u{078A}', '\u{078B}', '\u{078C}', '\u{078D}', '\u{078E}', '\u{078F}', '\u{0790}', '\u{0791}', '\u{0792}', '\u{0793}', '\u{0794}', '\u{0795}', '\u{0796}', '\u{0797}', '\u{0798}', '\u{0799}', '\u{079A}', '\u{079B}', '\u{079C}', '\u{079D}', '\u{079E}', '\u{079F}', '\u{07A0}', '\u{07A1}', '\u{07A2}', '\u{07A3}', '\u{07A4}', '\u{07A5}', '\u{07B1}', '\u{07CA}', '\u{07CB}', '\u{07CC}', '\u{07CD}', '\u{07CE}', '\u{07CF}', '\u{07D0}', '\u{07D1}', '\u{07D2}', '\u{07D3}', '\u{07D4}', '\u{07D5}', '\u{07D6}', '\u{07D7}', '\u{07D8}', '\u{07D9}', '\u{07DA}', '\u{07DB}', '\u{07DC}', '\u{07DD}', '\u{07DE}', '\u{07DF}', '\u{07E0}', '\u{07E1}', '\u{07E2}', '\u{07E3}', '\u{07E4}', '\u{07E5}', '\u{07E6}', '\u{07E7}', '\u{07E8}', '\u{07E9}', '\u{07EA}', '\u{0904}', '\u{0905}', '\u{0906}', '\u{0907}', '\u{0908}', '\u{0909}', '\u{090A}', '\u{090B}', '\u{090C}', '\u{090D}', '\u{090E}', '\u{090F}', '\u{0910}', '\u{0911}', '\u{0912}', '\u{0913}', '\u{0914}', '\u{0915}', '\u{0916}', '\u{0917}', '\u{0918}', '\u{0919}', '\u{091A}', '\u{091B}', '\u{091C}', '\u{091D}', '\u{091E}', '\u{091F}', '\u{0920}', '\u{0921}', '\u{0922}', '\u{0923}', '\u{0924}', '\u{0925}', '\u{0926}', '\u{0927}', '\u{0928}', '\u{0929}', '\u{092A}', '\u{092B}', '\u{092C}', '\u{092D}', '\u{092E}', '\u{092F}', '\u{0930}', '\u{0931}', '\u{0932}', '\u{0933}', '\u{0934}', '\u{0935}', '\u{0936}', '\u{0937}', '\u{0938}', '\u{0939}', '\u{093D}', '\u{0950}', '\u{0958}', '\u{0959}', '\u{095A}', '\u{095B}', '\u{095C}', '\u{095D}', '\u{095E}', '\u{095F}', '\u{0960}', '\u{0961}', '\u{0972}', '\u{097B}', '\u{097C}', '\u{097D}', '\u{097E}', '\u{097F}', '\u{0985}', '\u{0986}', '\u{0987}', '\u{0988}', '\u{0989}', '\u{098A}', '\u{098B}', '\u{098C}', '\u{098F}', '\u{0990}', '\u{0993}', '\u{0994}', '\u{0995}', '\u{0996}', '\u{0997}', '\u{0998}', '\u{0999}', '\u{099A}', '\u{099B}', '\u{099C}', '\u{099D}', '\u{099E}', '\u{099F}', '\u{09A0}', '\u{09A1}', '\u{09A2}', '\u{09A3}', '\u{09A4}', '\u{09A5}', '\u{09A6}', '\u{09A7}', '\u{09A8}', '\u{09AA}', '\u{09AB}', '\u{09AC}', '\u{09AD}', '\u{09AE}', '\u{09AF}', '\u{09B0}', '\u{09B2}', '\u{09B6}', '\u{09B7}', '\u{09B8}', '\u{09B9}', '\u{09BD}', '\u{09CE}', '\u{09DC}', '\u{09DD}', '\u{09DF}', '\u{09E0}', '\u{09E1}', '\u{09F0}', '\u{09F1}', '\u{0A05}', '\u{0A06}', '\u{0A07}', '\u{0A08}', '\u{0A09}', '\u{0A0A}', '\u{0A0F}', '\u{0A10}', '\u{0A13}', '\u{0A14}', '\u{0A15}', '\u{0A16}', '\u{0A17}', '\u{0A18}', '\u{0A19}', '\u{0A1A}', '\u{0A1B}', '\u{0A1C}', '\u{0A1D}', '\u{0A1E}', '\u{0A1F}', '\u{0A20}', '\u{0A21}', '\u{0A22}', '\u{0A23}', '\u{0A24}', '\u{0A25}', '\u{0A26}', '\u{0A27}', '\u{0A28}', '\u{0A2A}', '\u{0A2B}', '\u{0A2C}', '\u{0A2D}', '\u{0A2E}', '\u{0A2F}', '\u{0A30}', '\u{0A32}', '\u{0A33}', '\u{0A35}', '\u{0A36}', '\u{0A38}', '\u{0A39}', '\u{0A59}', '\u{0A5A}', '\u{0A5B}', '\u{0A5C}', '\u{0A5E}', '\u{0A72}', '\u{0A73}', '\u{0A74}', '\u{0A85}', '\u{0A86}', '\u{0A87}', '\u{0A88}', '\u{0A89}', '\u{0A8A}', '\u{0A8B}', '\u{0A8C}', '\u{0A8D}', '\u{0A8F}', '\u{0A90}', '\u{0A91}', '\u{0A93}', '\u{0A94}', '\u{0A95}', '\u{0A96}', '\u{0A97}', '\u{0A98}', '\u{0A99}', '\u{0A9A}', '\u{0A9B}', '\u{0A9C}', '\u{0A9D}', '\u{0A9E}', '\u{0A9F}', '\u{0AA0}', '\u{0AA1}', '\u{0AA2}', '\u{0AA3}', '\u{0AA4}', '\u{0AA5}', '\u{0AA6}', '\u{0AA7}', '\u{0AA8}', '\u{0AAA}', '\u{0AAB}', '\u{0AAC}', '\u{0AAD}', '\u{0AAE}', '\u{0AAF}', '\u{0AB0}', '\u{0AB2}', '\u{0AB3}', '\u{0AB5}', '\u{0AB6}', '\u{0AB7}', '\u{0AB8}', '\u{0AB9}', '\u{0ABD}', '\u{0AD0}', '\u{0AE0}', '\u{0AE1}', '\u{0B05}', '\u{0B06}', '\u{0B07}', '\u{0B08}', '\u{0B09}', '\u{0B0A}', '\u{0B0B}', '\u{0B0C}', '\u{0B0F}', '\u{0B10}', '\u{0B13}', '\u{0B14}', '\u{0B15}', '\u{0B16}', '\u{0B17}', '\u{0B18}', '\u{0B19}', '\u{0B1A}', '\u{0B1B}', '\u{0B1C}', '\u{0B1D}', '\u{0B1E}', '\u{0B1F}', '\u{0B20}', '\u{0B21}', '\u{0B22}', '\u{0B23}', '\u{0B24}', '\u{0B25}', '\u{0B26}', '\u{0B27}', '\u{0B28}', '\u{0B2A}', '\u{0B2B}', '\u{0B2C}', '\u{0B2D}', '\u{0B2E}', '\u{0B2F}', '\u{0B30}', '\u{0B32}', '\u{0B33}', '\u{0B35}', '\u{0B36}', '\u{0B37}', '\u{0B38}', '\u{0B39}', '\u{0B3D}', '\u{0B5C}', '\u{0B5D}', '\u{0B5F}', '\u{0B60}', '\u{0B61}', '\u{0B71}', '\u{0B83}', '\u{0B85}', '\u{0B86}', '\u{0B87}', '\u{0B88}', '\u{0B89}', '\u{0B8A}', '\u{0B8E}', '\u{0B8F}', '\u{0B90}', '\u{0B92}', '\u{0B93}', '\u{0B94}', '\u{0B95}', '\u{0B99}', '\u{0B9A}', '\u{0B9C}', '\u{0B9E}', '\u{0B9F}', '\u{0BA3}', '\u{0BA4}', '\u{0BA8}', '\u{0BA9}', '\u{0BAA}', '\u{0BAE}', '\u{0BAF}', '\u{0BB0}', '\u{0BB1}', '\u{0BB2}', '\u{0BB3}', '\u{0BB4}', '\u{0BB5}', '\u{0BB6}', '\u{0BB7}', '\u{0BB8}', '\u{0BB9}', '\u{0BD0}', '\u{0C05}', '\u{0C06}', '\u{0C07}', '\u{0C08}', '\u{0C09}', '\u{0C0A}', '\u{0C0B}', '\u{0C0C}', '\u{0C0E}', '\u{0C0F}', '\u{0C10}', '\u{0C12}', '\u{0C13}', '\u{0C14}', '\u{0C15}', '\u{0C16}', '\u{0C17}', '\u{0C18}', '\u{0C19}', '\u{0C1A}', '\u{0C1B}', '\u{0C1C}', '\u{0C1D}', '\u{0C1E}', '\u{0C1F}', '\u{0C20}', '\u{0C21}', '\u{0C22}', '\u{0C23}', '\u{0C24}', '\u{0C25}', '\u{0C26}', '\u{0C27}', '\u{0C28}', '\u{0C2A}', '\u{0C2B}', '\u{0C2C}', '\u{0C2D}', '\u{0C2E}', '\u{0C2F}', '\u{0C30}', '\u{0C31}', '\u{0C32}', '\u{0C33}', '\u{0C35}', '\u{0C36}', '\u{0C37}', '\u{0C38}', '\u{0C39}', '\u{0C3D}', '\u{0C58}', '\u{0C59}', '\u{0C60}', '\u{0C61}', '\u{0C85}', '\u{0C86}', '\u{0C87}', '\u{0C88}', '\u{0C89}', '\u{0C8A}', '\u{0C8B}', '\u{0C8C}', '\u{0C8E}', '\u{0C8F}', '\u{0C90}', '\u{0C92}', '\u{0C93}', '\u{0C94}', '\u{0C95}', '\u{0C96}', '\u{0C97}', '\u{0C98}', '\u{0C99}', '\u{0C9A}', '\u{0C9B}', '\u{0C9C}', '\u{0C9D}', '\u{0C9E}', '\u{0C9F}', '\u{0CA0}', '\u{0CA1}', '\u{0CA2}', '\u{0CA3}', '\u{0CA4}', '\u{0CA5}', '\u{0CA6}', '\u{0CA7}', '\u{0CA8}', '\u{0CAA}', '\u{0CAB}', '\u{0CAC}', '\u{0CAD}', '\u{0CAE}', '\u{0CAF}', '\u{0CB0}', '\u{0CB1}', '\u{0CB2}', '\u{0CB3}', '\u{0CB5}', '\u{0CB6}', '\u{0CB7}', '\u{0CB8}', '\u{0CB9}', '\u{0CBD}', '\u{0CDE}', '\u{0CE0}', '\u{0CE1}', '\u{0D05}', '\u{0D06}', '\u{0D07}', '\u{0D08}', '\u{0D09}', '\u{0D0A}', '\u{0D0B}', '\u{0D0C}', '\u{0D0E}', '\u{0D0F}', '\u{0D10}', '\u{0D12}', '\u{0D13}', '\u{0D14}', '\u{0D15}', '\u{0D16}', '\u{0D17}', '\u{0D18}', '\u{0D19}', '\u{0D1A}', '\u{0D1B}', '\u{0D1C}', '\u{0D1D}', '\u{0D1E}', '\u{0D1F}', '\u{0D20}', '\u{0D21}', '\u{0D22}', '\u{0D23}', '\u{0D24}', '\u{0D25}', '\u{0D26}', '\u{0D27}', '\u{0D28}', '\u{0D2A}', '\u{0D2B}', '\u{0D2C}', '\u{0D2D}', '\u{0D2E}', '\u{0D2F}', '\u{0D30}', '\u{0D31}', '\u{0D32}', '\u{0D33}', '\u{0D34}', '\u{0D35}', '\u{0D36}', '\u{0D37}', '\u{0D38}', '\u{0D39}', '\u{0D3D}', '\u{0D60}', '\u{0D61}', '\u{0D7A}', '\u{0D7B}', '\u{0D7C}', '\u{0D7D}', '\u{0D7E}', '\u{0D7F}', '\u{0D85}', '\u{0D86}', '\u{0D87}', '\u{0D88}', '\u{0D89}', '\u{0D8A}', '\u{0D8B}', '\u{0D8C}', '\u{0D8D}', '\u{0D8E}', '\u{0D8F}', '\u{0D90}', '\u{0D91}', '\u{0D92}', '\u{0D93}', '\u{0D94}', '\u{0D95}', '\u{0D96}', '\u{0D9A}', '\u{0D9B}', '\u{0D9C}', '\u{0D9D}', '\u{0D9E}', '\u{0D9F}', '\u{0DA0}', '\u{0DA1}', '\u{0DA2}', '\u{0DA3}', '\u{0DA4}', '\u{0DA5}', '\u{0DA6}', '\u{0DA7}', '\u{0DA8}', '\u{0DA9}', '\u{0DAA}', '\u{0DAB}', '\u{0DAC}', '\u{0DAD}', '\u{0DAE}', '\u{0DAF}', '\u{0DB0}', '\u{0DB1}', '\u{0DB3}', '\u{0DB4}', '\u{0DB5}', '\u{0DB6}', '\u{0DB7}', '\u{0DB8}', '\u{0DB9}', '\u{0DBA}', '\u{0DBB}', '\u{0DBD}', '\u{0DC0}', '\u{0DC1}', '\u{0DC2}', '\u{0DC3}', '\u{0DC4}', '\u{0DC5}', '\u{0DC6}', '\u{0E01}', '\u{0E02}', '\u{0E03}', '\u{0E04}', '\u{0E05}', '\u{0E06}', '\u{0E07}', '\u{0E08}', '\u{0E09}', '\u{0E0A}', '\u{0E0B}', '\u{0E0C}', '\u{0E0D}', '\u{0E0E}', '\u{0E0F}', '\u{0E10}', '\u{0E11}', '\u{0E12}', '\u{0E13}', '\u{0E14}', '\u{0E15}', '\u{0E16}', '\u{0E17}', '\u{0E18}', '\u{0E19}', '\u{0E1A}', '\u{0E1B}', '\u{0E1C}', '\u{0E1D}', '\u{0E1E}', '\u{0E1F}', '\u{0E20}', '\u{0E21}', '\u{0E22}', '\u{0E23}', '\u{0E24}', '\u{0E25}', '\u{0E26}', '\u{0E27}', '\u{0E28}', '\u{0E29}', '\u{0E2A}', '\u{0E2B}', '\u{0E2C}', '\u{0E2D}', '\u{0E2E}', '\u{0E2F}', '\u{0E30}', '\u{0E32}', '\u{0E33}', '\u{0E40}', '\u{0E41}', '\u{0E42}', '\u{0E43}', '\u{0E44}', '\u{0E45}', '\u{0E81}', '\u{0E82}', '\u{0E84}', '\u{0E87}', '\u{0E88}', '\u{0E8A}', '\u{0E8D}', '\u{0E94}', '\u{0E95}', '\u{0E96}', '\u{0E97}', '\u{0E99}', '\u{0E9A}', '\u{0E9B}', '\u{0E9C}', '\u{0E9D}', '\u{0E9E}', '\u{0E9F}', '\u{0EA1}', '\u{0EA2}', '\u{0EA3}', '\u{0EA5}', '\u{0EA7}', '\u{0EAA}', '\u{0EAB}', '\u{0EAD}', '\u{0EAE}', '\u{0EAF}', '\u{0EB0}', '\u{0EB2}', '\u{0EB3}', '\u{0EBD}', '\u{0EC0}', '\u{0EC1}', '\u{0EC2}', '\u{0EC3}', '\u{0EC4}', '\u{0EDC}', '\u{0EDD}', '\u{0F00}', '\u{0F40}', '\u{0F41}', '\u{0F42}', '\u{0F43}', '\u{0F44}', '\u{0F45}', '\u{0F46}', '\u{0F47}', '\u{0F49}', '\u{0F4A}', '\u{0F4B}', '\u{0F4C}', '\u{0F4D}', '\u{0F4E}', '\u{0F4F}', '\u{0F50}', '\u{0F51}', '\u{0F52}', '\u{0F53}', '\u{0F54}', '\u{0F55}', '\u{0F56}', '\u{0F57}', '\u{0F58}', '\u{0F59}', '\u{0F5A}', '\u{0F5B}', '\u{0F5C}', '\u{0F5D}', '\u{0F5E}', '\u{0F5F}', '\u{0F60}', '\u{0F61}', '\u{0F62}', '\u{0F63}', '\u{0F64}', '\u{0F65}', '\u{0F66}', '\u{0F67}', '\u{0F68}', '\u{0F69}', '\u{0F6A}', '\u{0F6B}', '\u{0F6C}', '\u{0F88}', '\u{0F89}', '\u{0F8A}', '\u{0F8B}', '\u{1000}', '\u{1001}', '\u{1002}', '\u{1003}', '\u{1004}', '\u{1005}', '\u{1006}', '\u{1007}', '\u{1008}', '\u{1009}', '\u{100A}', '\u{100B}', '\u{100C}', '\u{100D}', '\u{100E}', '\u{100F}', '\u{1010}', '\u{1011}', '\u{1012}', '\u{1013}', '\u{1014}', '\u{1015}', '\u{1016}', '\u{1017}', '\u{1018}', '\u{1019}', '\u{101A}', '\u{101B}', '\u{101C}', '\u{101D}', '\u{101E}', '\u{101F}', '\u{1020}', '\u{1021}', '\u{1022}', '\u{1023}', '\u{1024}', '\u{1025}', '\u{1026}', '\u{1027}', '\u{1028}', '\u{1029}', '\u{102A}', '\u{103F}', '\u{1050}', '\u{1051}', '\u{1052}', '\u{1053}', '\u{1054}', '\u{1055}', '\u{105A}', '\u{105B}', '\u{105C}', '\u{105D}', '\u{1061}', '\u{1065}', '\u{1066}', '\u{106E}', '\u{106F}', '\u{1070}', '\u{1075}', '\u{1076}', '\u{1077}', '\u{1078}', '\u{1079}', '\u{107A}', '\u{107B}', '\u{107C}', '\u{107D}', '\u{107E}', '\u{107F}', '\u{1080}', '\u{1081}', '\u{108E}', '\u{10D0}', '\u{10D1}', '\u{10D2}', '\u{10D3}', '\u{10D4}', '\u{10D5}', '\u{10D6}', '\u{10D7}', '\u{10D8}', '\u{10D9}', '\u{10DA}', '\u{10DB}', '\u{10DC}', '\u{10DD}', '\u{10DE}', '\u{10DF}', '\u{10E0}', '\u{10E1}', '\u{10E2}', '\u{10E3}', '\u{10E4}', '\u{10E5}', '\u{10E6}', '\u{10E7}', '\u{10E8}', '\u{10E9}', '\u{10EA}', '\u{10EB}', '\u{10EC}', '\u{10ED}', '\u{10EE}', '\u{10EF}', '\u{10F0}', '\u{10F1}', '\u{10F2}', '\u{10F3}', '\u{10F4}', '\u{10F5}', '\u{10F6}', '\u{10F7}', '\u{10F8}', '\u{10F9}', '\u{10FA}', '\u{1100}', '\u{1101}', '\u{1102}', '\u{1103}', '\u{1104}', '\u{1105}', '\u{1106}', '\u{1107}', '\u{1108}', '\u{1109}', '\u{110A}', '\u{110B}', '\u{110C}', '\u{110D}', '\u{110E}', '\u{110F}', '\u{1110}', '\u{1111}', '\u{1112}', '\u{1113}', '\u{1114}', '\u{1115}', '\u{1116}', '\u{1117}', '\u{1118}', '\u{1119}', '\u{111A}', '\u{111B}', '\u{111C}', '\u{111D}', '\u{111E}', '\u{111F}', '\u{1120}', '\u{1121}', '\u{1122}', '\u{1123}', '\u{1124}', '\u{1125}', '\u{1126}', '\u{1127}', '\u{1128}', '\u{1129}', '\u{112A}', '\u{112B}', '\u{112C}', '\u{112D}', '\u{112E}', '\u{112F}', '\u{1130}', '\u{1131}', '\u{1132}', '\u{1133}', '\u{1134}', '\u{1135}', '\u{1136}', '\u{1137}', '\u{1138}', '\u{1139}', '\u{113A}', '\u{113B}', '\u{113C}', '\u{113D}', '\u{113E}', '\u{113F}', '\u{1140}', '\u{1141}', '\u{1142}', '\u{1143}', '\u{1144}', '\u{1145}', '\u{1146}', '\u{1147}', '\u{1148}', '\u{1149}', '\u{114A}', '\u{114B}', '\u{114C}', '\u{114D}', '\u{114E}', '\u{114F}', '\u{1150}', '\u{1151}', '\u{1152}', '\u{1153}', '\u{1154}', '\u{1155}', '\u{1156}', '\u{1157}', '\u{1158}', '\u{1159}', '\u{115F}', '\u{1160}', '\u{1161}', '\u{1162}', '\u{1163}', '\u{1164}', '\u{1165}', '\u{1166}', '\u{1167}', '\u{1168}', '\u{1169}', '\u{116A}', '\u{116B}', '\u{116C}', '\u{116D}', '\u{116E}', '\u{116F}', '\u{1170}', '\u{1171}', '\u{1172}', '\u{1173}', '\u{1174}', '\u{1175}', '\u{1176}', '\u{1177}', '\u{1178}', '\u{1179}', '\u{117A}', '\u{117B}', '\u{117C}', '\u{117D}', '\u{117E}', '\u{117F}', '\u{1180}', '\u{1181}', '\u{1182}', '\u{1183}', '\u{1184}', '\u{1185}', '\u{1186}', '\u{1187}', '\u{1188}', '\u{1189}', '\u{118A}', '\u{118B}', '\u{118C}', '\u{118D}', '\u{118E}', '\u{118F}', '\u{1190}', '\u{1191}', '\u{1192}', '\u{1193}', '\u{1194}', '\u{1195}', '\u{1196}', '\u{1197}', '\u{1198}', '\u{1199}', '\u{119A}', '\u{119B}', '\u{119C}', '\u{119D}', '\u{119E}', '\u{119F}', '\u{11A0}', '\u{11A1}', '\u{11A2}', '\u{11A8}', '\u{11A9}', '\u{11AA}', '\u{11AB}', '\u{11AC}', '\u{11AD}', '\u{11AE}', '\u{11AF}', '\u{11B0}', '\u{11B1}', '\u{11B2}', '\u{11B3}', '\u{11B4}', '\u{11B5}', '\u{11B6}', '\u{11B7}', '\u{11B8}', '\u{11B9}', '\u{11BA}', '\u{11BB}', '\u{11BC}', '\u{11BD}', '\u{11BE}', '\u{11BF}', '\u{11C0}', '\u{11C1}', '\u{11C2}', '\u{11C3}', '\u{11C4}', '\u{11C5}', '\u{11C6}', '\u{11C7}', '\u{11C8}', '\u{11C9}', '\u{11CA}', '\u{11CB}', '\u{11CC}', '\u{11CD}', '\u{11CE}', '\u{11CF}', '\u{11D0}', '\u{11D1}', '\u{11D2}', '\u{11D3}', '\u{11D4}', '\u{11D5}', '\u{11D6}', '\u{11D7}', '\u{11D8}', '\u{11D9}', '\u{11DA}', '\u{11DB}', '\u{11DC}', '\u{11DD}', '\u{11DE}', '\u{11DF}', '\u{11E0}', '\u{11E1}', '\u{11E2}', '\u{11E3}', '\u{11E4}', '\u{11E5}', '\u{11E6}', '\u{11E7}', '\u{11E8}', '\u{11E9}', '\u{11EA}', '\u{11EB}', '\u{11EC}', '\u{11ED}', '\u{11EE}', '\u{11EF}', '\u{11F0}', '\u{11F1}', '\u{11F2}', '\u{11F3}', '\u{11F4}', '\u{11F5}', '\u{11F6}', '\u{11F7}', '\u{11F8}', '\u{11F9}', '\u{1200}', '\u{1201}', '\u{1202}', '\u{1203}', '\u{1204}', '\u{1205}', '\u{1206}', '\u{1207}', '\u{1208}', '\u{1209}', '\u{120A}', '\u{120B}', '\u{120C}', '\u{120D}', '\u{120E}', '\u{120F}', '\u{1210}', '\u{1211}', '\u{1212}', '\u{1213}', '\u{1214}', '\u{1215}', '\u{1216}', '\u{1217}', '\u{1218}', '\u{1219}', '\u{121A}', '\u{121B}', '\u{121C}', '\u{121D}', '\u{121E}', '\u{121F}', '\u{1220}', '\u{1221}', '\u{1222}', '\u{1223}', '\u{1224}', '\u{1225}', '\u{1226}', '\u{1227}', '\u{1228}', '\u{1229}', '\u{122A}', '\u{122B}', '\u{122C}', '\u{122D}', '\u{122E}', '\u{122F}', '\u{1230}', '\u{1231}', '\u{1232}', '\u{1233}', '\u{1234}', '\u{1235}', '\u{1236}', '\u{1237}', '\u{1238}', '\u{1239}', '\u{123A}', '\u{123B}', '\u{123C}', '\u{123D}', '\u{123E}', '\u{123F}', '\u{1240}', '\u{1241}', '\u{1242}', '\u{1243}', '\u{1244}', '\u{1245}', '\u{1246}', '\u{1247}', '\u{1248}', '\u{124A}', '\u{124B}', '\u{124C}', '\u{124D}', '\u{1250}', '\u{1251}', '\u{1252}', '\u{1253}', '\u{1254}', '\u{1255}', '\u{1256}', '\u{1258}', '\u{125A}', '\u{125B}', '\u{125C}', '\u{125D}', '\u{1260}', '\u{1261}', '\u{1262}', '\u{1263}', '\u{1264}', '\u{1265}', '\u{1266}', '\u{1267}', '\u{1268}', '\u{1269}', '\u{126A}', '\u{126B}', '\u{126C}', '\u{126D}', '\u{126E}', '\u{126F}', '\u{1270}', '\u{1271}', '\u{1272}', '\u{1273}', '\u{1274}', '\u{1275}', '\u{1276}', '\u{1277}', '\u{1278}', '\u{1279}', '\u{127A}', '\u{127B}', '\u{127C}', '\u{127D}', '\u{127E}', '\u{127F}', '\u{1280}', '\u{1281}', '\u{1282}', '\u{1283}', '\u{1284}', '\u{1285}', '\u{1286}', '\u{1287}', '\u{1288}', '\u{128A}', '\u{128B}', '\u{128C}', '\u{128D}', '\u{1290}', '\u{1291}', '\u{1292}', '\u{1293}', '\u{1294}', '\u{1295}', '\u{1296}', '\u{1297}', '\u{1298}', '\u{1299}', '\u{129A}', '\u{129B}', '\u{129C}', '\u{129D}', '\u{129E}', '\u{129F}', '\u{12A0}', '\u{12A1}', '\u{12A2}', '\u{12A3}', '\u{12A4}', '\u{12A5}', '\u{12A6}', '\u{12A7}', '\u{12A8}', '\u{12A9}', '\u{12AA}', '\u{12AB}', '\u{12AC}', '\u{12AD}', '\u{12AE}', '\u{12AF}', '\u{12B0}', '\u{12B2}', '\u{12B3}', '\u{12B4}', '\u{12B5}', '\u{12B8}', '\u{12B9}', '\u{12BA}', '\u{12BB}', '\u{12BC}', '\u{12BD}', '\u{12BE}', '\u{12C0}', '\u{12C2}', '\u{12C3}', '\u{12C4}', '\u{12C5}', '\u{12C8}', '\u{12C9}', '\u{12CA}', '\u{12CB}', '\u{12CC}', '\u{12CD}', '\u{12CE}', '\u{12CF}', '\u{12D0}', '\u{12D1}', '\u{12D2}', '\u{12D3}', '\u{12D4}', '\u{12D5}', '\u{12D6}', '\u{12D8}', '\u{12D9}', '\u{12DA}', '\u{12DB}', '\u{12DC}', '\u{12DD}', '\u{12DE}', '\u{12DF}', '\u{12E0}', '\u{12E1}', '\u{12E2}', '\u{12E3}', '\u{12E4}', '\u{12E5}', '\u{12E6}', '\u{12E7}', '\u{12E8}', '\u{12E9}', '\u{12EA}', '\u{12EB}', '\u{12EC}', '\u{12ED}', '\u{12EE}', '\u{12EF}', '\u{12F0}', '\u{12F1}', '\u{12F2}', '\u{12F3}', '\u{12F4}', '\u{12F5}', '\u{12F6}', '\u{12F7}', '\u{12F8}', '\u{12F9}', '\u{12FA}', '\u{12FB}', '\u{12FC}', '\u{12FD}', '\u{12FE}', '\u{12FF}', '\u{1300}', '\u{1301}', '\u{1302}', '\u{1303}', '\u{1304}', '\u{1305}', '\u{1306}', '\u{1307}', '\u{1308}', '\u{1309}', '\u{130A}', '\u{130B}', '\u{130C}', '\u{130D}', '\u{130E}', '\u{130F}', '\u{1310}', '\u{1312}', '\u{1313}', '\u{1314}', '\u{1315}', '\u{1318}', '\u{1319}', '\u{131A}', '\u{131B}', '\u{131C}', '\u{131D}', '\u{131E}', '\u{131F}', '\u{1320}', '\u{1321}', '\u{1322}', '\u{1323}', '\u{1324}', '\u{1325}', '\u{1326}', '\u{1327}', '\u{1328}', '\u{1329}', '\u{132A}', '\u{132B}', '\u{132C}', '\u{132D}', '\u{132E}', '\u{132F}', '\u{1330}', '\u{1331}', '\u{1332}', '\u{1333}', '\u{1334}', '\u{1335}', '\u{1336}', '\u{1337}', '\u{1338}', '\u{1339}', '\u{133A}', '\u{133B}', '\u{133C}', '\u{133D}', '\u{133E}', '\u{133F}', '\u{1340}', '\u{1341}', '\u{1342}', '\u{1343}', '\u{1344}', '\u{1345}', '\u{1346}', '\u{1347}', '\u{1348}', '\u{1349}', '\u{134A}', '\u{134B}', '\u{134C}', '\u{134D}', '\u{134E}', '\u{134F}', '\u{1350}', '\u{1351}', '\u{1352}', '\u{1353}', '\u{1354}', '\u{1355}', '\u{1356}', '\u{1357}', '\u{1358}', '\u{1359}', '\u{135A}', '\u{1380}', '\u{1381}', '\u{1382}', '\u{1383}', '\u{1384}', '\u{1385}', '\u{1386}', '\u{1387}', '\u{1388}', '\u{1389}', '\u{138A}', '\u{138B}', '\u{138C}', '\u{138D}', '\u{138E}', '\u{138F}', '\u{13A0}', '\u{13A1}', '\u{13A2}', '\u{13A3}', '\u{13A4}', '\u{13A5}', '\u{13A6}', '\u{13A7}', '\u{13A8}', '\u{13A9}', '\u{13AA}', '\u{13AB}', '\u{13AC}', '\u{13AD}', '\u{13AE}', '\u{13AF}', '\u{13B0}', '\u{13B1}', '\u{13B2}', '\u{13B3}', '\u{13B4}', '\u{13B5}', '\u{13B6}', '\u{13B7}', '\u{13B8}', '\u{13B9}', '\u{13BA}', '\u{13BB}', '\u{13BC}', '\u{13BD}', '\u{13BE}', '\u{13BF}', '\u{13C0}', '\u{13C1}', '\u{13C2}', '\u{13C3}', '\u{13C4}', '\u{13C5}', '\u{13C6}', '\u{13C7}', '\u{13C8}', '\u{13C9}', '\u{13CA}', '\u{13CB}', '\u{13CC}', '\u{13CD}', '\u{13CE}', '\u{13CF}', '\u{13D0}', '\u{13D1}', '\u{13D2}', '\u{13D3}', '\u{13D4}', '\u{13D5}', '\u{13D6}', '\u{13D7}', '\u{13D8}', '\u{13D9}', '\u{13DA}', '\u{13DB}', '\u{13DC}', '\u{13DD}', '\u{13DE}', '\u{13DF}', '\u{13E0}', '\u{13E1}', '\u{13E2}', '\u{13E3}', '\u{13E4}', '\u{13E5}', '\u{13E6}', '\u{13E7}', '\u{13E8}', '\u{13E9}', '\u{13EA}', '\u{13EB}', '\u{13EC}', '\u{13ED}', '\u{13EE}', '\u{13EF}', '\u{13F0}', '\u{13F1}', '\u{13F2}', '\u{13F3}', '\u{13F4}', '\u{1401}', '\u{1402}', '\u{1403}', '\u{1404}', '\u{1405}', '\u{1406}', '\u{1407}', '\u{1408}', '\u{1409}', '\u{140A}', '\u{140B}', '\u{140C}', '\u{140D}', '\u{140E}', '\u{140F}', '\u{1410}', '\u{1411}', '\u{1412}', '\u{1413}', '\u{1414}', '\u{1415}', '\u{1416}', '\u{1417}', '\u{1418}', '\u{1419}', '\u{141A}', '\u{141B}', '\u{141C}', '\u{141D}', '\u{141E}', '\u{141F}', '\u{1420}', '\u{1421}', '\u{1422}', '\u{1423}', '\u{1424}', '\u{1425}', '\u{1426}', '\u{1427}', '\u{1428}', '\u{1429}', '\u{142A}', '\u{142B}', '\u{142C}', '\u{142D}', '\u{142E}', '\u{142F}', '\u{1430}', '\u{1431}', '\u{1432}', '\u{1433}', '\u{1434}', '\u{1435}', '\u{1436}', '\u{1437}', '\u{1438}', '\u{1439}', '\u{143A}', '\u{143B}', '\u{143C}', '\u{143D}', '\u{143E}', '\u{143F}', '\u{1440}', '\u{1441}', '\u{1442}', '\u{1443}', '\u{1444}', '\u{1445}', '\u{1446}', '\u{1447}', '\u{1448}', '\u{1449}', '\u{144A}', '\u{144B}', '\u{144C}', '\u{144D}', '\u{144E}', '\u{144F}', '\u{1450}', '\u{1451}', '\u{1452}', '\u{1453}', '\u{1454}', '\u{1455}', '\u{1456}', '\u{1457}', '\u{1458}', '\u{1459}', '\u{145A}', '\u{145B}', '\u{145C}', '\u{145D}', '\u{145E}', '\u{145F}', '\u{1460}', '\u{1461}', '\u{1462}', '\u{1463}', '\u{1464}', '\u{1465}', '\u{1466}', '\u{1467}', '\u{1468}', '\u{1469}', '\u{146A}', '\u{146B}', '\u{146C}', '\u{146D}', '\u{146E}', '\u{146F}', '\u{1470}', '\u{1471}', '\u{1472}', '\u{1473}', '\u{1474}', '\u{1475}', '\u{1476}', '\u{1477}', '\u{1478}', '\u{1479}', '\u{147A}', '\u{147B}', '\u{147C}', '\u{147D}', '\u{147E}', '\u{147F}', '\u{1480}', '\u{1481}', '\u{1482}', '\u{1483}', '\u{1484}', '\u{1485}', '\u{1486}', '\u{1487}', '\u{1488}', '\u{1489}', '\u{148A}', '\u{148B}', '\u{148C}', '\u{148D}', '\u{148E}', '\u{148F}', '\u{1490}', '\u{1491}', '\u{1492}', '\u{1493}', '\u{1494}', '\u{1495}', '\u{1496}', '\u{1497}', '\u{1498}', '\u{1499}', '\u{149A}', '\u{149B}', '\u{149C}', '\u{149D}', '\u{149E}', '\u{149F}', '\u{14A0}', '\u{14A1}', '\u{14A2}', '\u{14A3}', '\u{14A4}', '\u{14A5}', '\u{14A6}', '\u{14A7}', '\u{14A8}', '\u{14A9}', '\u{14AA}', '\u{14AB}', '\u{14AC}', '\u{14AD}', '\u{14AE}', '\u{14AF}', '\u{14B0}', '\u{14B1}', '\u{14B2}', '\u{14B3}', '\u{14B4}', '\u{14B5}', '\u{14B6}', '\u{14B7}', '\u{14B8}', '\u{14B9}', '\u{14BA}', '\u{14BB}', '\u{14BC}', '\u{14BD}', '\u{14BE}', '\u{14BF}', '\u{14C0}', '\u{14C1}', '\u{14C2}', '\u{14C3}', '\u{14C4}', '\u{14C5}', '\u{14C6}', '\u{14C7}', '\u{14C8}', '\u{14C9}', '\u{14CA}', '\u{14CB}', '\u{14CC}', '\u{14CD}', '\u{14CE}', '\u{14CF}', '\u{14D0}', '\u{14D1}', '\u{14D2}', '\u{14D3}', '\u{14D4}', '\u{14D5}', '\u{14D6}', '\u{14D7}', '\u{14D8}', '\u{14D9}', '\u{14DA}', '\u{14DB}', '\u{14DC}', '\u{14DD}', '\u{14DE}', '\u{14DF}', '\u{14E0}', '\u{14E1}', '\u{14E2}', '\u{14E3}', '\u{14E4}', '\u{14E5}', '\u{14E6}', '\u{14E7}', '\u{14E8}', '\u{14E9}', '\u{14EA}', '\u{14EB}', '\u{14EC}', '\u{14ED}', '\u{14EE}', '\u{14EF}', '\u{14F0}', '\u{14F1}', '\u{14F2}', '\u{14F3}', '\u{14F4}', '\u{14F5}', '\u{14F6}', '\u{14F7}', '\u{14F8}', '\u{14F9}', '\u{14FA}', '\u{14FB}', '\u{14FC}', '\u{14FD}', '\u{14FE}', '\u{14FF}', '\u{1500}', '\u{1501}', '\u{1502}', '\u{1503}', '\u{1504}', '\u{1505}', '\u{1506}', '\u{1507}', '\u{1508}', '\u{1509}', '\u{150A}', '\u{150B}', '\u{150C}', '\u{150D}', '\u{150E}', '\u{150F}', '\u{1510}', '\u{1511}', '\u{1512}', '\u{1513}', '\u{1514}', '\u{1515}', '\u{1516}', '\u{1517}', '\u{1518}', '\u{1519}', '\u{151A}', '\u{151B}', '\u{151C}', '\u{151D}', '\u{151E}', '\u{151F}', '\u{1520}', '\u{1521}', '\u{1522}', '\u{1523}', '\u{1524}', '\u{1525}', '\u{1526}', '\u{1527}', '\u{1528}', '\u{1529}', '\u{152A}', '\u{152B}', '\u{152C}', '\u{152D}', '\u{152E}', '\u{152F}', '\u{1530}', '\u{1531}', '\u{1532}', '\u{1533}', '\u{1534}', '\u{1535}', '\u{1536}', '\u{1537}', '\u{1538}', '\u{1539}', '\u{153A}', '\u{153B}', '\u{153C}', '\u{153D}', '\u{153E}', '\u{153F}', '\u{1540}', '\u{1541}', '\u{1542}', '\u{1543}', '\u{1544}', '\u{1545}', '\u{1546}', '\u{1547}', '\u{1548}', '\u{1549}', '\u{154A}', '\u{154B}', '\u{154C}', '\u{154D}', '\u{154E}', '\u{154F}', '\u{1550}', '\u{1551}', '\u{1552}', '\u{1553}', '\u{1554}', '\u{1555}', '\u{1556}', '\u{1557}', '\u{1558}', '\u{1559}', '\u{155A}', '\u{155B}', '\u{155C}', '\u{155D}', '\u{155E}', '\u{155F}', '\u{1560}', '\u{1561}', '\u{1562}', '\u{1563}', '\u{1564}', '\u{1565}', '\u{1566}', '\u{1567}', '\u{1568}', '\u{1569}', '\u{156A}', '\u{156B}', '\u{156C}', '\u{156D}', '\u{156E}', '\u{156F}', '\u{1570}', '\u{1571}', '\u{1572}', '\u{1573}', '\u{1574}', '\u{1575}', '\u{1576}', '\u{1577}', '\u{1578}', '\u{1579}', '\u{157A}', '\u{157B}', '\u{157C}', '\u{157D}', '\u{157E}', '\u{157F}', '\u{1580}', '\u{1581}', '\u{1582}', '\u{1583}', '\u{1584}', '\u{1585}', '\u{1586}', '\u{1587}', '\u{1588}', '\u{1589}', '\u{158A}', '\u{158B}', '\u{158C}', '\u{158D}', '\u{158E}', '\u{158F}', '\u{1590}', '\u{1591}', '\u{1592}', '\u{1593}', '\u{1594}', '\u{1595}', '\u{1596}', '\u{1597}', '\u{1598}', '\u{1599}', '\u{159A}', '\u{159B}', '\u{159C}', '\u{159D}', '\u{159E}', '\u{159F}', '\u{15A0}', '\u{15A1}', '\u{15A2}', '\u{15A3}', '\u{15A4}', '\u{15A5}', '\u{15A6}', '\u{15A7}', '\u{15A8}', '\u{15A9}', '\u{15AA}', '\u{15AB}', '\u{15AC}', '\u{15AD}', '\u{15AE}', '\u{15AF}', '\u{15B0}', '\u{15B1}', '\u{15B2}', '\u{15B3}', '\u{15B4}', '\u{15B5}', '\u{15B6}', '\u{15B7}', '\u{15B8}', '\u{15B9}', '\u{15BA}', '\u{15BB}', '\u{15BC}', '\u{15BD}', '\u{15BE}', '\u{15BF}', '\u{15C0}', '\u{15C1}', '\u{15C2}', '\u{15C3}', '\u{15C4}', '\u{15C5}', '\u{15C6}', '\u{15C7}', '\u{15C8}', '\u{15C9}', '\u{15CA}', '\u{15CB}', '\u{15CC}', '\u{15CD}', '\u{15CE}', '\u{15CF}', '\u{15D0}', '\u{15D1}', '\u{15D2}', '\u{15D3}', '\u{15D4}', '\u{15D5}', '\u{15D6}', '\u{15D7}', '\u{15D8}', '\u{15D9}', '\u{15DA}', '\u{15DB}', '\u{15DC}', '\u{15DD}', '\u{15DE}', '\u{15DF}', '\u{15E0}', '\u{15E1}', '\u{15E2}', '\u{15E3}', '\u{15E4}', '\u{15E5}', '\u{15E6}', '\u{15E7}', '\u{15E8}', '\u{15E9}', '\u{15EA}', '\u{15EB}', '\u{15EC}', '\u{15ED}', '\u{15EE}', '\u{15EF}', '\u{15F0}', '\u{15F1}', '\u{15F2}', '\u{15F3}', '\u{15F4}', '\u{15F5}', '\u{15F6}', '\u{15F7}', '\u{15F8}', '\u{15F9}', '\u{15FA}', '\u{15FB}', '\u{15FC}', '\u{15FD}', '\u{15FE}', '\u{15FF}', '\u{1600}', '\u{1601}', '\u{1602}', '\u{1603}', '\u{1604}', '\u{1605}', '\u{1606}', '\u{1607}', '\u{1608}', '\u{1609}', '\u{160A}', '\u{160B}', '\u{160C}', '\u{160D}', '\u{160E}', '\u{160F}', '\u{1610}', '\u{1611}', '\u{1612}', '\u{1613}', '\u{1614}', '\u{1615}', '\u{1616}', '\u{1617}', '\u{1618}', '\u{1619}', '\u{161A}', '\u{161B}', '\u{161C}', '\u{161D}', '\u{161E}', '\u{161F}', '\u{1620}', '\u{1621}', '\u{1622}', '\u{1623}', '\u{1624}', '\u{1625}', '\u{1626}', '\u{1627}', '\u{1628}', '\u{1629}', '\u{162A}', '\u{162B}', '\u{162C}', '\u{162D}', '\u{162E}', '\u{162F}', '\u{1630}', '\u{1631}', '\u{1632}', '\u{1633}', '\u{1634}', '\u{1635}', '\u{1636}', '\u{1637}', '\u{1638}', '\u{1639}', '\u{163A}', '\u{163B}', '\u{163C}', '\u{163D}', '\u{163E}', '\u{163F}', '\u{1640}', '\u{1641}', '\u{1642}', '\u{1643}', '\u{1644}', '\u{1645}', '\u{1646}', '\u{1647}', '\u{1648}', '\u{1649}', '\u{164A}', '\u{164B}', '\u{164C}', '\u{164D}', '\u{164E}', '\u{164F}', '\u{1650}', '\u{1651}', '\u{1652}', '\u{1653}', '\u{1654}', '\u{1655}', '\u{1656}', '\u{1657}', '\u{1658}', '\u{1659}', '\u{165A}', '\u{165B}', '\u{165C}', '\u{165D}', '\u{165E}', '\u{165F}', '\u{1660}', '\u{1661}', '\u{1662}', '\u{1663}', '\u{1664}', '\u{1665}', '\u{1666}', '\u{1667}', '\u{1668}', '\u{1669}', '\u{166A}', '\u{166B}', '\u{166C}', '\u{166F}', '\u{1670}', '\u{1671}', '\u{1672}', '\u{1673}', '\u{1674}', '\u{1675}', '\u{1676}', '\u{1681}', '\u{1682}', '\u{1683}', '\u{1684}', '\u{1685}', '\u{1686}', '\u{1687}', '\u{1688}', '\u{1689}', '\u{168A}', '\u{168B}', '\u{168C}', '\u{168D}', '\u{168E}', '\u{168F}', '\u{1690}', '\u{1691}', '\u{1692}', '\u{1693}', '\u{1694}', '\u{1695}', '\u{1696}', '\u{1697}', '\u{1698}', '\u{1699}', '\u{169A}', '\u{16A0}', '\u{16A1}', '\u{16A2}', '\u{16A3}', '\u{16A4}', '\u{16A5}', '\u{16A6}', '\u{16A7}', '\u{16A8}', '\u{16A9}', '\u{16AA}', '\u{16AB}', '\u{16AC}', '\u{16AD}', '\u{16AE}', '\u{16AF}', '\u{16B0}', '\u{16B1}', '\u{16B2}', '\u{16B3}', '\u{16B4}', '\u{16B5}', '\u{16B6}', '\u{16B7}', '\u{16B8}', '\u{16B9}', '\u{16BA}', '\u{16BB}', '\u{16BC}', '\u{16BD}', '\u{16BE}', '\u{16BF}', '\u{16C0}', '\u{16C1}', '\u{16C2}', '\u{16C3}', '\u{16C4}', '\u{16C5}', '\u{16C6}', '\u{16C7}', '\u{16C8}', '\u{16C9}', '\u{16CA}', '\u{16CB}', '\u{16CC}', '\u{16CD}', '\u{16CE}', '\u{16CF}', '\u{16D0}', '\u{16D1}', '\u{16D2}', '\u{16D3}', '\u{16D4}', '\u{16D5}', '\u{16D6}', '\u{16D7}', '\u{16D8}', '\u{16D9}', '\u{16DA}', '\u{16DB}', '\u{16DC}', '\u{16DD}', '\u{16DE}', '\u{16DF}', '\u{16E0}', '\u{16E1}', '\u{16E2}', '\u{16E3}', '\u{16E4}', '\u{16E5}', '\u{16E6}', '\u{16E7}', '\u{16E8}', '\u{16E9}', '\u{16EA}', '\u{1700}', '\u{1701}', '\u{1702}', '\u{1703}', '\u{1704}', '\u{1705}', '\u{1706}', '\u{1707}', '\u{1708}', '\u{1709}', '\u{170A}', '\u{170B}', '\u{170C}', '\u{170E}', '\u{170F}', '\u{1710}', '\u{1711}', '\u{1720}', '\u{1721}', '\u{1722}', '\u{1723}', '\u{1724}', '\u{1725}', '\u{1726}', '\u{1727}', '\u{1728}', '\u{1729}', '\u{172A}', '\u{172B}', '\u{172C}', '\u{172D}', '\u{172E}', '\u{172F}', '\u{1730}', '\u{1731}', '\u{1740}', '\u{1741}', '\u{1742}', '\u{1743}', '\u{1744}', '\u{1745}', '\u{1746}', '\u{1747}', '\u{1748}', '\u{1749}', '\u{174A}', '\u{174B}', '\u{174C}', '\u{174D}', '\u{174E}', '\u{174F}', '\u{1750}', '\u{1751}', '\u{1760}', '\u{1761}', '\u{1762}', '\u{1763}', '\u{1764}', '\u{1765}', '\u{1766}', '\u{1767}', '\u{1768}', '\u{1769}', '\u{176A}', '\u{176B}', '\u{176C}', '\u{176E}', '\u{176F}', '\u{1770}', '\u{1780}', '\u{1781}', '\u{1782}', '\u{1783}', '\u{1784}', '\u{1785}', '\u{1786}', '\u{1787}', '\u{1788}', '\u{1789}', '\u{178A}', '\u{178B}', '\u{178C}', '\u{178D}', '\u{178E}', '\u{178F}', '\u{1790}', '\u{1791}', '\u{1792}', '\u{1793}', '\u{1794}', '\u{1795}', '\u{1796}', '\u{1797}', '\u{1798}', '\u{1799}', '\u{179A}', '\u{179B}', '\u{179C}', '\u{179D}', '\u{179E}', '\u{179F}', '\u{17A0}', '\u{17A1}', '\u{17A2}', '\u{17A3}', '\u{17A4}', '\u{17A5}', '\u{17A6}', '\u{17A7}', '\u{17A8}', '\u{17A9}', '\u{17AA}', '\u{17AB}', '\u{17AC}', '\u{17AD}', '\u{17AE}', '\u{17AF}', '\u{17B0}', '\u{17B1}', '\u{17B2}', '\u{17B3}', '\u{17DC}', '\u{1820}', '\u{1821}', '\u{1822}', '\u{1823}', '\u{1824}', '\u{1825}', '\u{1826}', '\u{1827}', '\u{1828}', '\u{1829}', '\u{182A}', '\u{182B}', '\u{182C}', '\u{182D}', '\u{182E}', '\u{182F}', '\u{1830}', '\u{1831}', '\u{1832}', '\u{1833}', '\u{1834}', '\u{1835}', '\u{1836}', '\u{1837}', '\u{1838}', '\u{1839}', '\u{183A}', '\u{183B}', '\u{183C}', '\u{183D}', '\u{183E}', '\u{183F}', '\u{1840}', '\u{1841}', '\u{1842}', '\u{1844}', '\u{1845}', '\u{1846}', '\u{1847}', '\u{1848}', '\u{1849}', '\u{184A}', '\u{184B}', '\u{184C}', '\u{184D}', '\u{184E}', '\u{184F}', '\u{1850}', '\u{1851}', '\u{1852}', '\u{1853}', '\u{1854}', '\u{1855}', '\u{1856}', '\u{1857}', '\u{1858}', '\u{1859}', '\u{185A}', '\u{185B}', '\u{185C}', '\u{185D}', '\u{185E}', '\u{185F}', '\u{1860}', '\u{1861}', '\u{1862}', '\u{1863}', '\u{1864}', '\u{1865}', '\u{1866}', '\u{1867}', '\u{1868}', '\u{1869}', '\u{186A}', '\u{186B}', '\u{186C}', '\u{186D}', '\u{186E}', '\u{186F}', '\u{1870}', '\u{1871}', '\u{1872}', '\u{1873}', '\u{1874}', '\u{1875}', '\u{1876}', '\u{1877}', '\u{1880}', '\u{1881}', '\u{1882}', '\u{1883}', '\u{1884}', '\u{1885}', '\u{1886}', '\u{1887}', '\u{1888}', '\u{1889}', '\u{188A}', '\u{188B}', '\u{188C}', '\u{188D}', '\u{188E}', '\u{188F}', '\u{1890}', '\u{1891}', '\u{1892}', '\u{1893}', '\u{1894}', '\u{1895}', '\u{1896}', '\u{1897}', '\u{1898}', '\u{1899}', '\u{189A}', '\u{189B}', '\u{189C}', '\u{189D}', '\u{189E}', '\u{189F}', '\u{18A0}', '\u{18A1}', '\u{18A2}', '\u{18A3}', '\u{18A4}', '\u{18A5}', '\u{18A6}', '\u{18A7}', '\u{18A8}', '\u{18AA}', '\u{1900}', '\u{1901}', '\u{1902}', '\u{1903}', '\u{1904}', '\u{1905}', '\u{1906}', '\u{1907}', '\u{1908}', '\u{1909}', '\u{190A}', '\u{190B}', '\u{190C}', '\u{190D}', '\u{190E}', '\u{190F}', '\u{1910}', '\u{1911}', '\u{1912}', '\u{1913}', '\u{1914}', '\u{1915}', '\u{1916}', '\u{1917}', '\u{1918}', '\u{1919}', '\u{191A}', '\u{191B}', '\u{191C}', '\u{1950}', '\u{1951}', '\u{1952}', '\u{1953}', '\u{1954}', '\u{1955}', '\u{1956}', '\u{1957}', '\u{1958}', '\u{1959}', '\u{195A}', '\u{195B}', '\u{195C}', '\u{195D}', '\u{195E}', '\u{195F}', '\u{1960}', '\u{1961}', '\u{1962}', '\u{1963}', '\u{1964}', '\u{1965}', '\u{1966}', '\u{1967}', '\u{1968}', '\u{1969}', '\u{196A}', '\u{196B}', '\u{196C}', '\u{196D}', '\u{1970}', '\u{1971}', '\u{1972}', '\u{1973}', '\u{1974}', '\u{1980}', '\u{1981}', '\u{1982}', '\u{1983}', '\u{1984}', '\u{1985}', '\u{1986}', '\u{1987}', '\u{1988}', '\u{1989}', '\u{198A}', '\u{198B}', '\u{198C}', '\u{198D}', '\u{198E}', '\u{198F}', '\u{1990}', '\u{1991}', '\u{1992}', '\u{1993}', '\u{1994}', '\u{1995}', '\u{1996}', '\u{1997}', '\u{1998}', '\u{1999}', '\u{199A}', '\u{199B}', '\u{199C}', '\u{199D}', '\u{199E}', '\u{199F}', '\u{19A0}', '\u{19A1}', '\u{19A2}', '\u{19A3}', '\u{19A4}', '\u{19A5}', '\u{19A6}', '\u{19A7}', '\u{19A8}', '\u{19A9}', '\u{19C1}', '\u{19C2}', '\u{19C3}', '\u{19C4}', '\u{19C5}', '\u{19C6}', '\u{19C7}', '\u{1A00}', '\u{1A01}', '\u{1A02}', '\u{1A03}', '\u{1A04}', '\u{1A05}', '\u{1A06}', '\u{1A07}', '\u{1A08}', '\u{1A09}', '\u{1A0A}', '\u{1A0B}', '\u{1A0C}', '\u{1A0D}', '\u{1A0E}', '\u{1A0F}', '\u{1A10}', '\u{1A11}', '\u{1A12}', '\u{1A13}', '\u{1A14}', '\u{1A15}', '\u{1A16}', '\u{1B05}', '\u{1B06}', '\u{1B07}', '\u{1B08}', '\u{1B09}', '\u{1B0A}', '\u{1B0B}', '\u{1B0C}', '\u{1B0D}', '\u{1B0E}', '\u{1B0F}', '\u{1B10}', '\u{1B11}', '\u{1B12}', '\u{1B13}', '\u{1B14}', '\u{1B15}', '\u{1B16}', '\u{1B17}', '\u{1B18}', '\u{1B19}', '\u{1B1A}', '\u{1B1B}', '\u{1B1C}', '\u{1B1D}', '\u{1B1E}', '\u{1B1F}', '\u{1B20}', '\u{1B21}', '\u{1B22}', '\u{1B23}', '\u{1B24}', '\u{1B25}', '\u{1B26}', '\u{1B27}', '\u{1B28}', '\u{1B29}', '\u{1B2A}', '\u{1B2B}', '\u{1B2C}', '\u{1B2D}', '\u{1B2E}', '\u{1B2F}', '\u{1B30}', '\u{1B31}', '\u{1B32}', '\u{1B33}', '\u{1B45}', '\u{1B46}', '\u{1B47}', '\u{1B48}', '\u{1B49}', '\u{1B4A}', '\u{1B4B}', '\u{1B83}', '\u{1B84}', '\u{1B85}', '\u{1B86}', '\u{1B87}', '\u{1B88}', '\u{1B89}', '\u{1B8A}', '\u{1B8B}', '\u{1B8C}', '\u{1B8D}', '\u{1B8E}', '\u{1B8F}', '\u{1B90}', '\u{1B91}', '\u{1B92}', '\u{1B93}', '\u{1B94}', '\u{1B95}', '\u{1B96}', '\u{1B97}', '\u{1B98}', '\u{1B99}', '\u{1B9A}', '\u{1B9B}', '\u{1B9C}', '\u{1B9D}', '\u{1B9E}', '\u{1B9F}', '\u{1BA0}', '\u{1BAE}', '\u{1BAF}', '\u{1C00}', '\u{1C01}', '\u{1C02}', '\u{1C03}', '\u{1C04}', '\u{1C05}', '\u{1C06}', '\u{1C07}', '\u{1C08}', '\u{1C09}', '\u{1C0A}', '\u{1C0B}', '\u{1C0C}', '\u{1C0D}', '\u{1C0E}', '\u{1C0F}', '\u{1C10}', '\u{1C11}', '\u{1C12}', '\u{1C13}', '\u{1C14}', '\u{1C15}', '\u{1C16}', '\u{1C17}', '\u{1C18}', '\u{1C19}', '\u{1C1A}', '\u{1C1B}', '\u{1C1C}', '\u{1C1D}', '\u{1C1E}', '\u{1C1F}', '\u{1C20}', '\u{1C21}', '\u{1C22}', '\u{1C23}', '\u{1C4D}', '\u{1C4E}', '\u{1C4F}', '\u{1C5A}', '\u{1C5B}', '\u{1C5C}', '\u{1C5D}', '\u{1C5E}', '\u{1C5F}', '\u{1C60}', '\u{1C61}', '\u{1C62}', '\u{1C63}', '\u{1C64}', '\u{1C65}', '\u{1C66}', '\u{1C67}', '\u{1C68}', '\u{1C69}', '\u{1C6A}', '\u{1C6B}', '\u{1C6C}', '\u{1C6D}', '\u{1C6E}', '\u{1C6F}', '\u{1C70}', '\u{1C71}', '\u{1C72}', '\u{1C73}', '\u{1C74}', '\u{1C75}', '\u{1C76}', '\u{1C77}', '\u{2135}', '\u{2136}', '\u{2137}', '\u{2138}', '\u{2D30}', '\u{2D31}', '\u{2D32}', '\u{2D33}', '\u{2D34}', '\u{2D35}', '\u{2D36}', '\u{2D37}', '\u{2D38}', '\u{2D39}', '\u{2D3A}', '\u{2D3B}', '\u{2D3C}', '\u{2D3D}', '\u{2D3E}', '\u{2D3F}', '\u{2D40}', '\u{2D41}', '\u{2D42}', '\u{2D43}', '\u{2D44}', '\u{2D45}', '\u{2D46}', '\u{2D47}', '\u{2D48}', '\u{2D49}', '\u{2D4A}', '\u{2D4B}', '\u{2D4C}', '\u{2D4D}', '\u{2D4E}', '\u{2D4F}', '\u{2D50}', '\u{2D51}', '\u{2D52}', '\u{2D53}', '\u{2D54}', '\u{2D55}', '\u{2D56}', '\u{2D57}', '\u{2D58}', '\u{2D59}', '\u{2D5A}', '\u{2D5B}', '\u{2D5C}', '\u{2D5D}', '\u{2D5E}', '\u{2D5F}', '\u{2D60}', '\u{2D61}', '\u{2D62}', '\u{2D63}', '\u{2D64}', '\u{2D65}', '\u{2D80}', '\u{2D81}', '\u{2D82}', '\u{2D83}', '\u{2D84}', '\u{2D85}', '\u{2D86}', '\u{2D87}', '\u{2D88}', '\u{2D89}', '\u{2D8A}', '\u{2D8B}', '\u{2D8C}', '\u{2D8D}', '\u{2D8E}', '\u{2D8F}', '\u{2D90}', '\u{2D91}', '\u{2D92}', '\u{2D93}', '\u{2D94}', '\u{2D95}', '\u{2D96}', '\u{2DA0}', '\u{2DA1}', '\u{2DA2}', '\u{2DA3}', '\u{2DA4}', '\u{2DA5}', '\u{2DA6}', '\u{2DA8}', '\u{2DA9}', '\u{2DAA}', '\u{2DAB}', '\u{2DAC}', '\u{2DAD}', '\u{2DAE}', '\u{2DB0}', '\u{2DB1}', '\u{2DB2}', '\u{2DB3}', '\u{2DB4}', '\u{2DB5}', '\u{2DB6}', '\u{2DB8}', '\u{2DB9}', '\u{2DBA}', '\u{2DBB}', '\u{2DBC}', '\u{2DBD}', '\u{2DBE}', '\u{2DC0}', '\u{2DC1}', '\u{2DC2}', '\u{2DC3}', '\u{2DC4}', '\u{2DC5}', '\u{2DC6}', '\u{2DC8}', '\u{2DC9}', '\u{2DCA}', '\u{2DCB}', '\u{2DCC}', '\u{2DCD}', '\u{2DCE}', '\u{2DD0}', '\u{2DD1}', '\u{2DD2}', '\u{2DD3}', '\u{2DD4}', '\u{2DD5}', '\u{2DD6}', '\u{2DD8}', '\u{2DD9}', '\u{2DDA}', '\u{2DDB}', '\u{2DDC}', '\u{2DDD}', '\u{2DDE}', '\u{3006}', '\u{303C}', '\u{3041}', '\u{3042}', '\u{3043}', '\u{3044}', '\u{3045}', '\u{3046}', '\u{3047}', '\u{3048}', '\u{3049}', '\u{304A}', '\u{304B}', '\u{304C}', '\u{304D}', '\u{304E}', '\u{304F}', '\u{3050}', '\u{3051}', '\u{3052}', '\u{3053}', '\u{3054}', '\u{3055}', '\u{3056}', '\u{3057}', '\u{3058}', '\u{3059}', '\u{305A}', '\u{305B}', '\u{305C}', '\u{305D}', '\u{305E}', '\u{305F}', '\u{3060}', '\u{3061}', '\u{3062}', '\u{3063}', '\u{3064}', '\u{3065}', '\u{3066}', '\u{3067}', '\u{3068}', '\u{3069}', '\u{306A}', '\u{306B}', '\u{306C}', '\u{306D}', '\u{306E}', '\u{306F}', '\u{3070}', '\u{3071}', '\u{3072}', '\u{3073}', '\u{3074}', '\u{3075}', '\u{3076}', '\u{3077}', '\u{3078}', '\u{3079}', '\u{307A}', '\u{307B}', '\u{307C}', '\u{307D}', '\u{307E}', '\u{307F}', '\u{3080}', '\u{3081}', '\u{3082}', '\u{3083}', '\u{3084}', '\u{3085}', '\u{3086}', '\u{3087}', '\u{3088}', '\u{3089}', '\u{308A}', '\u{308B}', '\u{308C}', '\u{308D}', '\u{308E}', '\u{308F}', '\u{3090}', '\u{3091}', '\u{3092}', '\u{3093}', '\u{3094}', '\u{3095}', '\u{3096}', '\u{309F}', '\u{30A1}', '\u{30A2}', '\u{30A3}', '\u{30A4}', '\u{30A5}', '\u{30A6}', '\u{30A7}', '\u{30A8}', '\u{30A9}', '\u{30AA}', '\u{30AB}', '\u{30AC}', '\u{30AD}', '\u{30AE}', '\u{30AF}', '\u{30B0}', '\u{30B1}', '\u{30B2}', '\u{30B3}', '\u{30B4}', '\u{30B5}', '\u{30B6}', '\u{30B7}', '\u{30B8}', '\u{30B9}', '\u{30BA}', '\u{30BB}', '\u{30BC}', '\u{30BD}', '\u{30BE}', '\u{30BF}', '\u{30C0}', '\u{30C1}', '\u{30C2}', '\u{30C3}', '\u{30C4}', '\u{30C5}', '\u{30C6}', '\u{30C7}', '\u{30C8}', '\u{30C9}', '\u{30CA}', '\u{30CB}', '\u{30CC}', '\u{30CD}', '\u{30CE}', '\u{30CF}', '\u{30D0}', '\u{30D1}', '\u{30D2}', '\u{30D3}', '\u{30D4}', '\u{30D5}', '\u{30D6}', '\u{30D7}', '\u{30D8}', '\u{30D9}', '\u{30DA}', '\u{30DB}', '\u{30DC}', '\u{30DD}', '\u{30DE}', '\u{30DF}', '\u{30E0}', '\u{30E1}', '\u{30E2}', '\u{30E3}', '\u{30E4}', '\u{30E5}', '\u{30E6}', '\u{30E7}', '\u{30E8}', '\u{30E9}', '\u{30EA}', '\u{30EB}', '\u{30EC}', '\u{30ED}', '\u{30EE}', '\u{30EF}', '\u{30F0}', '\u{30F1}', '\u{30F2}', '\u{30F3}', '\u{30F4}', '\u{30F5}', '\u{30F6}', '\u{30F7}', '\u{30F8}', '\u{30F9}', '\u{30FA}', '\u{30FF}', '\u{3105}', '\u{3106}', '\u{3107}', '\u{3108}', '\u{3109}', '\u{310A}', '\u{310B}', '\u{310C}', '\u{310D}', '\u{310E}', '\u{310F}', '\u{3110}', '\u{3111}', '\u{3112}', '\u{3113}', '\u{3114}', '\u{3115}', '\u{3116}', '\u{3117}', '\u{3118}', '\u{3119}', '\u{311A}', '\u{311B}', '\u{311C}', '\u{311D}', '\u{311E}', '\u{311F}', '\u{3120}', '\u{3121}', '\u{3122}', '\u{3123}', '\u{3124}', '\u{3125}', '\u{3126}', '\u{3127}', '\u{3128}', '\u{3129}', '\u{312A}', '\u{312B}', '\u{312C}', '\u{312D}', '\u{3131}', '\u{3132}', '\u{3133}', '\u{3134}', '\u{3135}', '\u{3136}', '\u{3137}', '\u{3138}', '\u{3139}', '\u{313A}', '\u{313B}', '\u{313C}', '\u{313D}', '\u{313E}', '\u{313F}', '\u{3140}', '\u{3141}', '\u{3142}', '\u{3143}', '\u{3144}', '\u{3145}', '\u{3146}', '\u{3147}', '\u{3148}', '\u{3149}', '\u{314A}', '\u{314B}', '\u{314C}', '\u{314D}', '\u{314E}', '\u{314F}', '\u{3150}', '\u{3151}', '\u{3152}', '\u{3153}', '\u{3154}', '\u{3155}', '\u{3156}', '\u{3157}', '\u{3158}', '\u{3159}', '\u{315A}', '\u{315B}', '\u{315C}', '\u{315D}', '\u{315E}', '\u{315F}', '\u{3160}', '\u{3161}', '\u{3162}', '\u{3163}', '\u{3164}', '\u{3165}', '\u{3166}', '\u{3167}', '\u{3168}', '\u{3169}', '\u{316A}', '\u{316B}', '\u{316C}', '\u{316D}', '\u{316E}', '\u{316F}', '\u{3170}', '\u{3171}', '\u{3172}', '\u{3173}', '\u{3174}', '\u{3175}', '\u{3176}', '\u{3177}', '\u{3178}', '\u{3179}', '\u{317A}', '\u{317B}', '\u{317C}', '\u{317D}', '\u{317E}', '\u{317F}', '\u{3180}', '\u{3181}', '\u{3182}', '\u{3183}', '\u{3184}', '\u{3185}', '\u{3186}', '\u{3187}', '\u{3188}', '\u{3189}', '\u{318A}', '\u{318B}', '\u{318C}', '\u{318D}', '\u{318E}', '\u{31A0}', '\u{31A1}', '\u{31A2}', '\u{31A3}', '\u{31A4}', '\u{31A5}', '\u{31A6}', '\u{31A7}', '\u{31A8}', '\u{31A9}', '\u{31AA}', '\u{31AB}', '\u{31AC}', '\u{31AD}', '\u{31AE}', '\u{31AF}', '\u{31B0}', '\u{31B1}', '\u{31B2}', '\u{31B3}', '\u{31B4}', '\u{31B5}', '\u{31B6}', '\u{31B7}', '\u{31F0}', '\u{31F1}', '\u{31F2}', '\u{31F3}', '\u{31F4}', '\u{31F5}', '\u{31F6}', '\u{31F7}', '\u{31F8}', '\u{31F9}', '\u{31FA}', '\u{31FB}', '\u{31FC}', '\u{31FD}', '\u{31FE}', '\u{31FF}', '\u{3400}', '\u{4DB5}', '\u{4E00}', '\u{9FC3}', '\u{A000}', '\u{A001}', '\u{A002}', '\u{A003}', '\u{A004}', '\u{A005}', '\u{A006}', '\u{A007}', '\u{A008}', '\u{A009}', '\u{A00A}', '\u{A00B}', '\u{A00C}', '\u{A00D}', '\u{A00E}', '\u{A00F}', '\u{A010}', '\u{A011}', '\u{A012}', '\u{A013}', '\u{A014}', '\u{A016}', '\u{A017}', '\u{A018}', '\u{A019}', '\u{A01A}', '\u{A01B}', '\u{A01C}', '\u{A01D}', '\u{A01E}', '\u{A01F}', '\u{A020}', '\u{A021}', '\u{A022}', '\u{A023}', '\u{A024}', '\u{A025}', '\u{A026}', '\u{A027}', '\u{A028}', '\u{A029}', '\u{A02A}', '\u{A02B}', '\u{A02C}', '\u{A02D}', '\u{A02E}', '\u{A02F}', '\u{A030}', '\u{A031}', '\u{A032}', '\u{A033}', '\u{A034}', '\u{A035}', '\u{A036}', '\u{A037}', '\u{A038}', '\u{A039}', '\u{A03A}', '\u{A03B}', '\u{A03C}', '\u{A03D}', '\u{A03E}', '\u{A03F}', '\u{A040}', '\u{A041}', '\u{A042}', '\u{A043}', '\u{A044}', '\u{A045}', '\u{A046}', '\u{A047}', '\u{A048}', '\u{A049}', '\u{A04A}', '\u{A04B}', '\u{A04C}', '\u{A04D}', '\u{A04E}', '\u{A04F}', '\u{A050}', '\u{A051}', '\u{A052}', '\u{A053}', '\u{A054}', '\u{A055}', '\u{A056}', '\u{A057}', '\u{A058}', '\u{A059}', '\u{A05A}', '\u{A05B}', '\u{A05C}', '\u{A05D}', '\u{A05E}', '\u{A05F}', '\u{A060}', '\u{A061}', '\u{A062}', '\u{A063}', '\u{A064}', '\u{A065}', '\u{A066}', '\u{A067}', '\u{A068}', '\u{A069}', '\u{A06A}', '\u{A06B}', '\u{A06C}', '\u{A06D}', '\u{A06E}', '\u{A06F}', '\u{A070}', '\u{A071}', '\u{A072}', '\u{A073}', '\u{A074}', '\u{A075}', '\u{A076}', '\u{A077}', '\u{A078}', '\u{A079}', '\u{A07A}', '\u{A07B}', '\u{A07C}', '\u{A07D}', '\u{A07E}', '\u{A07F}', '\u{A080}', '\u{A081}', '\u{A082}', '\u{A083}', '\u{A084}', '\u{A085}', '\u{A086}', '\u{A087}', '\u{A088}', '\u{A089}', '\u{A08A}', '\u{A08B}', '\u{A08C}', '\u{A08D}', '\u{A08E}', '\u{A08F}', '\u{A090}', '\u{A091}', '\u{A092}', '\u{A093}', '\u{A094}', '\u{A095}', '\u{A096}', '\u{A097}', '\u{A098}', '\u{A099}', '\u{A09A}', '\u{A09B}', '\u{A09C}', '\u{A09D}', '\u{A09E}', '\u{A09F}', '\u{A0A0}', '\u{A0A1}', '\u{A0A2}', '\u{A0A3}', '\u{A0A4}', '\u{A0A5}', '\u{A0A6}', '\u{A0A7}', '\u{A0A8}', '\u{A0A9}', '\u{A0AA}', '\u{A0AB}', '\u{A0AC}', '\u{A0AD}', '\u{A0AE}', '\u{A0AF}', '\u{A0B0}', '\u{A0B1}', '\u{A0B2}', '\u{A0B3}', '\u{A0B4}', '\u{A0B5}', '\u{A0B6}', '\u{A0B7}', '\u{A0B8}', '\u{A0B9}', '\u{A0BA}', '\u{A0BB}', '\u{A0BC}', '\u{A0BD}', '\u{A0BE}', '\u{A0BF}', '\u{A0C0}', '\u{A0C1}', '\u{A0C2}', '\u{A0C3}', '\u{A0C4}', '\u{A0C5}', '\u{A0C6}', '\u{A0C7}', '\u{A0C8}', '\u{A0C9}', '\u{A0CA}', '\u{A0CB}', '\u{A0CC}', '\u{A0CD}', '\u{A0CE}', '\u{A0CF}', '\u{A0D0}', '\u{A0D1}', '\u{A0D2}', '\u{A0D3}', '\u{A0D4}', '\u{A0D5}', '\u{A0D6}', '\u{A0D7}', '\u{A0D8}', '\u{A0D9}', '\u{A0DA}', '\u{A0DB}', '\u{A0DC}', '\u{A0DD}', '\u{A0DE}', '\u{A0DF}', '\u{A0E0}', '\u{A0E1}', '\u{A0E2}', '\u{A0E3}', '\u{A0E4}', '\u{A0E5}', '\u{A0E6}', '\u{A0E7}', '\u{A0E8}', '\u{A0E9}', '\u{A0EA}', '\u{A0EB}', '\u{A0EC}', '\u{A0ED}', '\u{A0EE}', '\u{A0EF}', '\u{A0F0}', '\u{A0F1}', '\u{A0F2}', '\u{A0F3}', '\u{A0F4}', '\u{A0F5}', '\u{A0F6}', '\u{A0F7}', '\u{A0F8}', '\u{A0F9}', '\u{A0FA}', '\u{A0FB}', '\u{A0FC}', '\u{A0FD}', '\u{A0FE}', '\u{A0FF}', '\u{A100}', '\u{A101}', '\u{A102}', '\u{A103}', '\u{A104}', '\u{A105}', '\u{A106}', '\u{A107}', '\u{A108}', '\u{A109}', '\u{A10A}', '\u{A10B}', '\u{A10C}', '\u{A10D}', '\u{A10E}', '\u{A10F}', '\u{A110}', '\u{A111}', '\u{A112}', '\u{A113}', '\u{A114}', '\u{A115}', '\u{A116}', '\u{A117}', '\u{A118}', '\u{A119}', '\u{A11A}', '\u{A11B}', '\u{A11C}', '\u{A11D}', '\u{A11E}', '\u{A11F}', '\u{A120}', '\u{A121}', '\u{A122}', '\u{A123}', '\u{A124}', '\u{A125}', '\u{A126}', '\u{A127}', '\u{A128}', '\u{A129}', '\u{A12A}', '\u{A12B}', '\u{A12C}', '\u{A12D}', '\u{A12E}', '\u{A12F}', '\u{A130}', '\u{A131}', '\u{A132}', '\u{A133}', '\u{A134}', '\u{A135}', '\u{A136}', '\u{A137}', '\u{A138}', '\u{A139}', '\u{A13A}', '\u{A13B}', '\u{A13C}', '\u{A13D}', '\u{A13E}', '\u{A13F}', '\u{A140}', '\u{A141}', '\u{A142}', '\u{A143}', '\u{A144}', '\u{A145}', '\u{A146}', '\u{A147}', '\u{A148}', '\u{A149}', '\u{A14A}', '\u{A14B}', '\u{A14C}', '\u{A14D}', '\u{A14E}', '\u{A14F}', '\u{A150}', '\u{A151}', '\u{A152}', '\u{A153}', '\u{A154}', '\u{A155}', '\u{A156}', '\u{A157}', '\u{A158}', '\u{A159}', '\u{A15A}', '\u{A15B}', '\u{A15C}', '\u{A15D}', '\u{A15E}', '\u{A15F}', '\u{A160}', '\u{A161}', '\u{A162}', '\u{A163}', '\u{A164}', '\u{A165}', '\u{A166}', '\u{A167}', '\u{A168}', '\u{A169}', '\u{A16A}', '\u{A16B}', '\u{A16C}', '\u{A16D}', '\u{A16E}', '\u{A16F}', '\u{A170}', '\u{A171}', '\u{A172}', '\u{A173}', '\u{A174}', '\u{A175}', '\u{A176}', '\u{A177}', '\u{A178}', '\u{A179}', '\u{A17A}', '\u{A17B}', '\u{A17C}', '\u{A17D}', '\u{A17E}', '\u{A17F}', '\u{A180}', '\u{A181}', '\u{A182}', '\u{A183}', '\u{A184}', '\u{A185}', '\u{A186}', '\u{A187}', '\u{A188}', '\u{A189}', '\u{A18A}', '\u{A18B}', '\u{A18C}', '\u{A18D}', '\u{A18E}', '\u{A18F}', '\u{A190}', '\u{A191}', '\u{A192}', '\u{A193}', '\u{A194}', '\u{A195}', '\u{A196}', '\u{A197}', '\u{A198}', '\u{A199}', '\u{A19A}', '\u{A19B}', '\u{A19C}', '\u{A19D}', '\u{A19E}', '\u{A19F}', '\u{A1A0}', '\u{A1A1}', '\u{A1A2}', '\u{A1A3}', '\u{A1A4}', '\u{A1A5}', '\u{A1A6}', '\u{A1A7}', '\u{A1A8}', '\u{A1A9}', '\u{A1AA}', '\u{A1AB}', '\u{A1AC}', '\u{A1AD}', '\u{A1AE}', '\u{A1AF}') + } + + fn is_unicode_combining_spacing_mark(self) -> bool { + match_char_class!(self, + '\u{0903}', '\u{093E}', '\u{093F}', '\u{0940}', '\u{0949}', '\u{094A}', '\u{094B}', '\u{094C}', '\u{0982}', '\u{0983}', '\u{09BE}', '\u{09BF}', '\u{09C0}', '\u{09C7}', '\u{09C8}', '\u{09CB}', '\u{09CC}', '\u{09D7}', '\u{0A03}', '\u{0A3E}', '\u{0A3F}', '\u{0A40}', '\u{0A83}', '\u{0ABE}', '\u{0ABF}', '\u{0AC0}', '\u{0AC9}', '\u{0ACB}', '\u{0ACC}', '\u{0B02}', '\u{0B03}', '\u{0B3E}', '\u{0B40}', '\u{0B47}', '\u{0B48}', '\u{0B4B}', '\u{0B4C}', '\u{0B57}', '\u{0BBE}', '\u{0BBF}', '\u{0BC1}', '\u{0BC2}', '\u{0BC6}', '\u{0BC7}', '\u{0BC8}', '\u{0BCA}', '\u{0BCB}', '\u{0BCC}', '\u{0BD7}', '\u{0C01}', '\u{0C02}', '\u{0C03}', '\u{0C41}', '\u{0C42}', '\u{0C43}', '\u{0C44}', '\u{0C82}', '\u{0C83}', '\u{0CBE}', '\u{0CC0}', '\u{0CC1}', '\u{0CC2}', '\u{0CC3}', '\u{0CC4}', '\u{0CC7}', '\u{0CC8}', '\u{0CCA}', '\u{0CCB}', '\u{0CD5}', '\u{0CD6}', '\u{0D02}', '\u{0D03}', '\u{0D3E}', '\u{0D3F}', '\u{0D40}', '\u{0D46}', '\u{0D47}', '\u{0D48}', '\u{0D4A}', '\u{0D4B}', '\u{0D4C}', '\u{0D57}', '\u{0D82}', '\u{0D83}', '\u{0DCF}', '\u{0DD0}', '\u{0DD1}', '\u{0DD8}', '\u{0DD9}', '\u{0DDA}', '\u{0DDB}', '\u{0DDC}', '\u{0DDD}', '\u{0DDE}', '\u{0DDF}', '\u{0DF2}', '\u{0DF3}', '\u{0F3E}', '\u{0F3F}', '\u{0F7F}', '\u{102B}', '\u{102C}', '\u{1031}', '\u{1038}', '\u{103B}', '\u{103C}', '\u{1056}', '\u{1057}', '\u{1062}', '\u{1063}', '\u{1064}', '\u{1067}', '\u{1068}', '\u{1069}', '\u{106A}', '\u{106B}', '\u{106C}', '\u{106D}', '\u{1083}', '\u{1084}', '\u{1087}', '\u{1088}', '\u{1089}', '\u{108A}', '\u{108B}', '\u{108C}', '\u{108F}', '\u{17B6}', '\u{17BE}', '\u{17BF}', '\u{17C0}', '\u{17C1}', '\u{17C2}', '\u{17C3}', '\u{17C4}', '\u{17C5}', '\u{17C7}', '\u{17C8}', '\u{1923}', '\u{1924}', '\u{1925}', '\u{1926}', '\u{1929}', '\u{192A}', '\u{192B}', '\u{1930}', '\u{1931}', '\u{1933}', '\u{1934}', '\u{1935}', '\u{1936}', '\u{1937}', '\u{1938}', '\u{19B0}', '\u{19B1}', '\u{19B2}', '\u{19B3}', '\u{19B4}', '\u{19B5}', '\u{19B6}', '\u{19B7}', '\u{19B8}', '\u{19B9}', '\u{19BA}', '\u{19BB}', '\u{19BC}', '\u{19BD}', '\u{19BE}', '\u{19BF}', '\u{19C0}', '\u{19C8}', '\u{19C9}', '\u{1A19}', '\u{1A1A}', '\u{1A1B}', '\u{1B04}', '\u{1B35}', '\u{1B3B}', '\u{1B3D}', '\u{1B3E}', '\u{1B3F}', '\u{1B40}', '\u{1B41}', '\u{1B43}', '\u{1B44}', '\u{1B82}', '\u{1BA1}', '\u{1BA6}', '\u{1BA7}', '\u{1BAA}', '\u{1C24}', '\u{1C25}', '\u{1C26}', '\u{1C27}', '\u{1C28}', '\u{1C29}', '\u{1C2A}', '\u{1C2B}', '\u{1C34}', '\u{1C35}', '\u{A823}', '\u{A824}', '\u{A827}', '\u{A880}', '\u{A881}', '\u{A8B4}', '\u{A8B5}', '\u{A8B6}', '\u{A8B7}', '\u{A8B8}', '\u{A8B9}', '\u{A8BA}', '\u{A8BB}', '\u{A8BC}', '\u{A8BD}', '\u{A8BE}', '\u{A8BF}', '\u{A8C0}', '\u{A8C1}', '\u{A8C2}', '\u{A8C3}', '\u{A952}', '\u{A953}', '\u{AA2F}', '\u{AA30}', '\u{AA33}', '\u{AA34}', '\u{AA4D}') + } + + fn is_unicode_decimal_number(self) -> bool { + match_char_class!(self, + '\u{0030}', '\u{0031}', '\u{0032}', '\u{0033}', '\u{0034}', '\u{0035}', '\u{0036}', '\u{0037}', '\u{0038}', '\u{0039}', '\u{0660}', '\u{0661}', '\u{0662}', '\u{0663}', '\u{0664}', '\u{0665}', '\u{0666}', '\u{0667}', '\u{0668}', '\u{0669}', '\u{06F0}', '\u{06F1}', '\u{06F2}', '\u{06F3}', '\u{06F4}', '\u{06F5}', '\u{06F6}', '\u{06F7}', '\u{06F8}', '\u{06F9}', '\u{07C0}', '\u{07C1}', '\u{07C2}', '\u{07C3}', '\u{07C4}', '\u{07C5}', '\u{07C6}', '\u{07C7}', '\u{07C8}', '\u{07C9}', '\u{0966}', '\u{0967}', '\u{0968}', '\u{0969}', '\u{096A}', '\u{096B}', '\u{096C}', '\u{096D}', '\u{096E}', '\u{096F}', '\u{09E6}', '\u{09E7}', '\u{09E8}', '\u{09E9}', '\u{09EA}', '\u{09EB}', '\u{09EC}', '\u{09ED}', '\u{09EE}', '\u{09EF}', '\u{0A66}', '\u{0A67}', '\u{0A68}', '\u{0A69}', '\u{0A6A}', '\u{0A6B}', '\u{0A6C}', '\u{0A6D}', '\u{0A6E}', '\u{0A6F}', '\u{0AE6}', '\u{0AE7}', '\u{0AE8}', '\u{0AE9}', '\u{0AEA}', '\u{0AEB}', '\u{0AEC}', '\u{0AED}', '\u{0AEE}', '\u{0AEF}', '\u{0B66}', '\u{0B67}', '\u{0B68}', '\u{0B69}', '\u{0B6A}', '\u{0B6B}', '\u{0B6C}', '\u{0B6D}', '\u{0B6E}', '\u{0B6F}', '\u{0BE6}', '\u{0BE7}', '\u{0BE8}', '\u{0BE9}', '\u{0BEA}', '\u{0BEB}', '\u{0BEC}', '\u{0BED}', '\u{0BEE}', '\u{0BEF}', '\u{0C66}', '\u{0C67}', '\u{0C68}', '\u{0C69}', '\u{0C6A}', '\u{0C6B}', '\u{0C6C}', '\u{0C6D}', '\u{0C6E}', '\u{0C6F}', '\u{0CE6}', '\u{0CE7}', '\u{0CE8}', '\u{0CE9}', '\u{0CEA}', '\u{0CEB}', '\u{0CEC}', '\u{0CED}', '\u{0CEE}', '\u{0CEF}', '\u{0D66}', '\u{0D67}', '\u{0D68}', '\u{0D69}', '\u{0D6A}', '\u{0D6B}', '\u{0D6C}', '\u{0D6D}', '\u{0D6E}', '\u{0D6F}', '\u{0E50}', '\u{0E51}', '\u{0E52}', '\u{0E53}', '\u{0E54}', '\u{0E55}', '\u{0E56}', '\u{0E57}', '\u{0E58}', '\u{0E59}', '\u{0ED0}', '\u{0ED1}', '\u{0ED2}', '\u{0ED3}', '\u{0ED4}', '\u{0ED5}', '\u{0ED6}', '\u{0ED7}', '\u{0ED8}', '\u{0ED9}', '\u{0F20}', '\u{0F21}', '\u{0F22}', '\u{0F23}', '\u{0F24}', '\u{0F25}', '\u{0F26}', '\u{0F27}', '\u{0F28}', '\u{0F29}', '\u{1040}', '\u{1041}', '\u{1042}', '\u{1043}', '\u{1044}', '\u{1045}', '\u{1046}', '\u{1047}', '\u{1048}', '\u{1049}', '\u{1090}', '\u{1091}', '\u{1092}', '\u{1093}', '\u{1094}', '\u{1095}', '\u{1096}', '\u{1097}', '\u{1098}', '\u{1099}', '\u{17E0}', '\u{17E1}', '\u{17E2}', '\u{17E3}', '\u{17E4}', '\u{17E5}', '\u{17E6}', '\u{17E7}', '\u{17E8}', '\u{17E9}', '\u{1810}', '\u{1811}', '\u{1812}', '\u{1813}', '\u{1814}', '\u{1815}', '\u{1816}', '\u{1817}', '\u{1818}', '\u{1819}', '\u{1946}', '\u{1947}', '\u{1948}', '\u{1949}', '\u{194A}', '\u{194B}', '\u{194C}', '\u{194D}', '\u{194E}', '\u{194F}', '\u{19D0}', '\u{19D1}', '\u{19D2}', '\u{19D3}', '\u{19D4}', '\u{19D5}', '\u{19D6}', '\u{19D7}', '\u{19D8}', '\u{19D9}', '\u{1B50}', '\u{1B51}', '\u{1B52}', '\u{1B53}', '\u{1B54}', '\u{1B55}', '\u{1B56}', '\u{1B57}', '\u{1B58}', '\u{1B59}', '\u{1BB0}', '\u{1BB1}', '\u{1BB2}', '\u{1BB3}', '\u{1BB4}', '\u{1BB5}', '\u{1BB6}', '\u{1BB7}', '\u{1BB8}', '\u{1BB9}', '\u{1C40}', '\u{1C41}', '\u{1C42}', '\u{1C43}', '\u{1C44}', '\u{1C45}', '\u{1C46}', '\u{1C47}', '\u{1C48}', '\u{1C49}', '\u{1C50}', '\u{1C51}', '\u{1C52}', '\u{1C53}', '\u{1C54}', '\u{1C55}', '\u{1C56}', '\u{1C57}', '\u{1C58}', '\u{1C59}', '\u{A620}', '\u{A621}', '\u{A622}', '\u{A623}', '\u{A624}', '\u{A625}', '\u{A626}', '\u{A627}', '\u{A628}', '\u{A629}', '\u{A8D0}', '\u{A8D1}', '\u{A8D2}', '\u{A8D3}', '\u{A8D4}', '\u{A8D5}', '\u{A8D6}', '\u{A8D7}', '\u{A8D8}', '\u{A8D9}', '\u{A900}', '\u{A901}', '\u{A902}', '\u{A903}', '\u{A904}', '\u{A905}', '\u{A906}', '\u{A907}', '\u{A908}', '\u{A909}', '\u{AA50}', '\u{AA51}', '\u{AA52}', '\u{AA53}', '\u{AA54}', '\u{AA55}', '\u{AA56}', '\u{AA57}', '\u{AA58}', '\u{AA59}', '\u{FF10}', '\u{FF11}', '\u{FF12}', '\u{FF13}', '\u{FF14}', '\u{FF15}', '\u{FF16}', '\u{FF17}', '\u{FF18}', '\u{FF19}') + } + + fn is_unicode_connector_punctiation(self) -> bool { + match_char_class!(self, + '\u{005F}', '\u{203F}', '\u{2040}', '\u{2054}', '\u{FE33}', '\u{FE34}', '\u{FE4D}', '\u{FE4E}', '\u{FE4F}', '\u{FF3F}') + } + + fn is_unicode_space_separator(self) -> bool { + match_char_class!(self, + '\u{0020}', '\u{00A0}', '\u{1680}', '\u{2000}', '\u{2001}', '\u{2002}', '\u{2003}', '\u{2004}', '\u{2005}', '\u{2006}', '\u{2007}', '\u{2008}', '\u{2009}', '\u{200A}', '\u{202F}', '\u{205F}', '\u{3000}') + } + + fn is_es_identifier_start(self) -> bool { + match self { + '$' | '_' | '\\' => true, + c if c.is_unicode_letter() => true, + _ => false + } + } + + // see section 7.6 + fn is_es_identifier_part(self) -> bool { + match self { + '\u{200C}' | '\u{200D}' => true, + c if c.is_es_identifier_start() => true, + c if c.is_unicode_combining_spacing_mark() => true, + c if c.is_unicode_nonspacing_mark() => true, + c if c.is_unicode_decimal_number() => true, + c if c.is_unicode_connector_punctiation() => true, + _ => false + } + } + + fn is_es_whitespace(self) -> bool { + match self { + '\t' | '\u{000B}' | '\u{000C}' | '\u{0020}' | '\u{00A0}' | '\u{FEFF}' => true, + c => c.is_unicode_space_separator() + } + } + + fn is_es_line_terminator(self) -> bool { + match self { + '\n' | '\r' | '\u{2028}' | '\u{2029}' => true, + _ => false + } + } +} + +fn main() { + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2935.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2935.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2935.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2935.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] +#![feature(box_syntax)] + +//type t = { a: isize }; +// type t = { a: bool }; +type t = bool; + +trait it { + fn f(&self); +} + +impl it for t { + fn f(&self) { } +} + +pub fn main() { + // let x = ({a: 4} as it); + // let y = box ({a: 4}); + // let z = box ({a: 4} as it); + // let z = box ({a: true} as it); + let z: Box<_> = box (box true as Box); + // x.f(); + // y.f(); + // (*z).f(); + println!("ok so far..."); + z.f(); //segfault +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2936.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2936.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2936.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2936.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +trait bar { + fn get_bar(&self) -> T; +} + +fn foo>(b: U) -> T { + b.get_bar() +} + +struct cbar { + x: isize, +} + +impl bar for cbar { + fn get_bar(&self) -> isize { + self.x + } +} + +fn cbar(x: isize) -> cbar { + cbar { + x: x + } +} + +pub fn main() { + let x: isize = foo::(cbar(5)); + assert_eq!(x, 5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29466.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29466.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29466.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29466.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,3609 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +macro_rules! m( + ($e1:expr => $e2:expr) => ({ $e1 }) +); + +fn main() { + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + let x = m!(1 => 2); + + println!("{}", x); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29485.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29485.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29485.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29485.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_attributes)] +// aux-build:issue-29485.rs +// ignore-emscripten no threads + +#[feature(recover)] + +extern crate a; + +fn main() { + let _ = std::thread::spawn(move || { + a::f(&mut a::X(0), g); + }).join(); +} + +fn g() { + panic!(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29488.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29488.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29488.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29488.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten no threads support + +use std::thread; + +struct Foo; + +impl Drop for Foo { + fn drop(&mut self) { + println!("test2"); + } +} + +thread_local!(static FOO: Foo = Foo); + +fn main() { + // Off the main thread due to #28129, be sure to initialize FOO first before + // calling `println!` + thread::spawn(|| { + FOO.with(|_| {}); + println!("test1"); + }).join().unwrap(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29522.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29522.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29522.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29522.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// check that we don't accidentally capture upvars just because their name +// occurs in a path + +fn assert_static(_t: T) {} + +mod foo { + pub fn scope() {} +} + +fn main() { + let scope = &mut 0; + assert_static(|| { + foo::scope(); + }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29663.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29663.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29663.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29663.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,66 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(stable_features)] +// write_volatile causes an LLVM assert with composite types + +#![feature(volatile)] +use std::ptr::{read_volatile, write_volatile}; + +#[derive(Debug, Eq, PartialEq)] +struct A(u32); +#[derive(Debug, Eq, PartialEq)] +struct B(u64); +#[derive(Debug, Eq, PartialEq)] +struct C(u32, u32); +#[derive(Debug, Eq, PartialEq)] +struct D(u64, u64); +#[derive(Debug, Eq, PartialEq)] +struct E([u64; 32]); + +fn main() { + unsafe { + let mut x: u32 = 0; + write_volatile(&mut x, 1); + assert_eq!(read_volatile(&x), 1); + assert_eq!(x, 1); + + let mut x: u64 = 0; + write_volatile(&mut x, 1); + assert_eq!(read_volatile(&x), 1); + assert_eq!(x, 1); + + let mut x = A(0); + write_volatile(&mut x, A(1)); + assert_eq!(read_volatile(&x), A(1)); + assert_eq!(x, A(1)); + + let mut x = B(0); + write_volatile(&mut x, B(1)); + assert_eq!(read_volatile(&x), B(1)); + assert_eq!(x, B(1)); + + let mut x = C(0, 0); + write_volatile(&mut x, C(1, 1)); + assert_eq!(read_volatile(&x), C(1, 1)); + assert_eq!(x, C(1, 1)); + + let mut x = D(0, 0); + write_volatile(&mut x, D(1, 1)); + assert_eq!(read_volatile(&x), D(1, 1)); + assert_eq!(x, D(1, 1)); + + let mut x = E([0; 32]); + write_volatile(&mut x, E([1; 32])); + assert_eq!(read_volatile(&x), E([1; 32])); + assert_eq!(x, E([1; 32])); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29668.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29668.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29668.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29668.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Functions can return unnameable types + +mod m1 { + mod m2 { + #[derive(Debug)] + pub struct A; + } + use self::m2::A; + pub fn x() -> A { A } +} + +fn main() { + let x = m1::x(); + println!("{:?}", x); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29746.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29746.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29746.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29746.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// zip!(a1,a2,a3,a4) is equivalent to: +// a1.zip(a2).zip(a3).zip(a4).map(|(((x1,x2),x3),x4)| (x1,x2,x3,x4)) +macro_rules! zip { + // Entry point + ([$a:expr, $b:expr, $($rest:expr),*]) => { + zip!([$($rest),*], $a.zip($b), (x,y), [x,y]) + }; + + // Intermediate steps to build the zipped expression, the match pattern, and + // and the output tuple of the closure, using macro hygiene to repeatedly + // introduce new variables named 'x'. + ([$a:expr, $($rest:expr),*], $zip:expr, $pat:pat, [$($flat:expr),*]) => { + zip!([$($rest),*], $zip.zip($a), ($pat,x), [$($flat),*, x]) + }; + + // Final step + ([], $zip:expr, $pat:pat, [$($flat:expr),+]) => { + $zip.map(|$pat| ($($flat),+)) + }; + + // Comma + ([$a:expr], $zip:expr, $pat:pat, [$($flat:expr),*]) => { + zip!([$a,], $zip, $pat, [$($flat),*]) + }; +} + +fn main() { + let p1 = vec![1i32, 2].into_iter(); + let p2 = vec!["10", "20"].into_iter(); + let p3 = vec![100u16, 200].into_iter(); + let p4 = vec![1000i64, 2000].into_iter(); + + let e = zip!([p1,p2,p3,p4]).collect::>(); + assert_eq!(e[0], (1i32,"10",100u16,1000i64)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29844.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29844.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29844.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29844.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::sync::Arc; + +pub struct DescriptorSet<'a> { + pub slots: Vec> +} + +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(Arc) +} + +fn main() { + let _x = DescriptorSet {slots: Vec::new()}; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2989.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2989.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-2989.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-2989.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +trait methods { + fn to_bytes(&self) -> Vec ; +} + +impl methods for () { + fn to_bytes(&self) -> Vec { + Vec::new() + } +} + +// the position of this function is significant! - if it comes before methods +// then it works, if it comes after it then it doesn't! +fn to_bools(bitv: Storage) -> Vec { + (0..8).map(|i| { + let w = i / 64; + let b = i % 64; + let x = 1 & (bitv.storage[w] >> b); + x == 1 + }).collect() +} + +struct Storage { storage: Vec } + +pub fn main() { + let bools = vec![false, false, true, false, false, true, true, false]; + let bools2 = to_bools(Storage{storage: vec![0b01100100]}); + + for i in 0..8 { + println!("{} => {} vs {}", i, bools[i], bools2[i]); + } + + assert_eq!(bools, bools2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29914-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29914-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29914-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29914-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +const ARR: [usize; 5] = [5, 4, 3, 2, 1]; + +fn main() { + assert_eq!(3, ARR[ARR[3]]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29914-3.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29914-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29914-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29914-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +const ARR: [usize; 5] = [5, 4, 3, 2, 1]; +const BLA: usize = ARR[ARR[3]]; + +fn main() { + assert_eq!(3, BLA); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29914.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29914.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29914.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29914.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(stable_features)] + +#![feature(const_indexing)] + +const ARR: [usize; 5] = [5, 4, 3, 2, 1]; + +fn main() { + assert_eq!(3, ARR[ARR[3]]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue29927-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue29927-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue29927-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue29927-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +const fn f() -> usize { + 5 +} +struct A { + field: usize, +} +fn main() { + let _ = [0; f()]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29927.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29927.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29927.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29927.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +struct A { + field: usize, +} +const fn f() -> usize { + 5 +} +fn main() { + let _ = [0; f()]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29948.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29948.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-29948.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-29948.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,50 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-wasm32-bare compiled with panic=abort by default + +use std::panic; + +impl<'a> panic::UnwindSafe for Foo<'a> {} +impl<'a> panic::RefUnwindSafe for Foo<'a> {} + +struct Foo<'a>(&'a mut bool); + +impl<'a> Drop for Foo<'a> { + fn drop(&mut self) { + *self.0 = true; + } +} + +fn f(t: T) { + t() +} + +fn main() { + let mut ran_drop = false; + { + let x = Foo(&mut ran_drop); + let x = move || { let _ = x; }; + f(x); + } + assert!(ran_drop); + + let mut ran_drop = false; + { + let x = Foo(&mut ran_drop); + let result = panic::catch_unwind(move || { + let x = move || { let _ = x; panic!() }; + f(x); + }); + assert!(result.is_err()); + } + assert!(ran_drop); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-30018-nopanic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-30018-nopanic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-30018-nopanic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-30018-nopanic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,113 @@ +// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unreachable_code)] +// More thorough regression test for Issues #30018 and #30822. This +// attempts to explore different ways that array element construction +// (for both scratch arrays and non-scratch ones) interacts with +// breaks in the control-flow, in terms of the order of evaluation of +// the destructors (which may change; see RFC Issue 744) and the +// number of times that the destructor evaluates for each value (which +// should never exceed 1; this latter case is what #30822 is about). + +use std::cell::RefCell; + +struct D<'a>(&'a RefCell>, i32); + +impl<'a> Drop for D<'a> { + fn drop(&mut self) { + println!("Dropping D({})", self.1); + (self.0).borrow_mut().push(self.1); + } +} + +fn main() { + println!("Start"); + break_during_elem(); + break_after_whole(); + println!("Finis"); +} + +fn break_during_elem() { + let log = &RefCell::new(Vec::new()); + + // CASE 1: Fixed-size array itself is stored in _r slot. + loop { + let _r = [D(log, 10), + D(log, 11), + { D(log, 12); break; }, + D(log, 13)]; + } + assert_eq!(&log.borrow()[..], &[12, 11, 10]); + log.borrow_mut().clear(); + + // CASE 2: Slice (borrow of array) is stored in _r slot. + // This is the case that is actually being reported in #30018. + loop { + let _r = &[D(log, 20), + D(log, 21), + { D(log, 22); break; }, + D(log, 23)]; + } + assert_eq!(&log.borrow()[..], &[22, 21, 20]); + log.borrow_mut().clear(); + + // CASE 3: (Borrow of) slice-index of array is stored in _r slot. + loop { + let _r = &[D(log, 30), + D(log, 31), + { D(log, 32); break; }, + D(log, 33)][..]; + } + assert_eq!(&log.borrow()[..], &[32, 31, 30]); + log.borrow_mut().clear(); +} + +// The purpose of these functions is to test what happens when we +// panic after an array has been constructed in its entirety. +// +// It is meant to act as proof that we still need to continue +// scheduling the destruction of an array even after we've scheduling +// drop for its elements during construction; the latter is tested by +// `fn break_during_elem()`. +fn break_after_whole() { + let log = &RefCell::new(Vec::new()); + + // CASE 1: Fixed-size array itself is stored in _r slot. + loop { + let _r = [D(log, 10), + D(log, 11), + D(log, 12)]; + break; + } + assert_eq!(&log.borrow()[..], &[10, 11, 12]); + log.borrow_mut().clear(); + + // CASE 2: Slice (borrow of array) is stored in _r slot. + loop { + let _r = &[D(log, 20), + D(log, 21), + D(log, 22)]; + break; + } + assert_eq!(&log.borrow()[..], &[20, 21, 22]); + log.borrow_mut().clear(); + + // CASE 3: (Borrow of) slice-index of array is stored in _r slot. + loop { + let _r = &[D(log, 30), + D(log, 31), + D(log, 32)][..]; + break; + } + assert_eq!(&log.borrow()[..], &[30, 31, 32]); + log.borrow_mut().clear(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-30018-panic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-30018-panic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-30018-panic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-30018-panic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for Issue #30018. This is very similar to the +// original reported test, except that the panic is wrapped in a +// spawned thread to isolate the expected error result from the +// SIGTRAP injected by the drop-flag consistency checking. + +// ignore-emscripten no threads support + +struct Foo; + +impl Drop for Foo { + fn drop(&mut self) {} +} + +fn foo() -> Foo { + panic!(); +} + +fn main() { + use std::thread; + let handle = thread::spawn(|| { + let _ = &[foo()]; + }); + let _ = handle.join(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-30081.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-30081.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-30081.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-30081.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2012-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// This used to segfault #30081 + +pub enum Instruction { + Increment(i8), + Loop(Box>), +} + +fn main() { + let instrs: Option<(u8, Box)> = None; + instrs.into_iter() + .map(|(_, instr)| instr) + .map(|instr| match *instr { _other => {} }) + .last(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3012-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3012-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3012-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3012-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-3012-1.rs + +// pretty-expanded FIXME #23616 + +extern crate socketlib; + +use socketlib::socket; + +pub fn main() { + let fd: u32 = 1 as u32; + let _sock: Box<_> = Box::new(socket::socket_handle(fd)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-30240.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-30240.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-30240.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-30240.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + let &ref a = &[0i32] as &[_]; + assert_eq!(a, &[0i32] as &[_]); + + let &ref a = "hello"; + assert_eq!(a, "hello"); + + match "foo" { + "fool" => unreachable!(), + "foo" => {}, + ref _x => unreachable!() + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3026.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3026.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3026.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3026.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + +use std::collections::HashMap; + +pub fn main() { + let x: Box<_>; + let mut buggy_map: HashMap = HashMap::new(); + x = box 1; + buggy_map.insert(42, &*x); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-30371.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-30371.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-30371.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-30371.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unreachable_code)] +#![allow(unused_mut)] // rust-lang/rust#54586 +#![deny(unused_variables)] + +fn main() { + for _ in match return () { + () => Some(0), + } {} +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3037.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3037.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3037.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3037.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 +#![allow(non_camel_case_types)] + +enum what { } + +fn what_to_string(x: what) -> String +{ + match x { + } +} + +pub fn main() +{ +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-30490.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-30490.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-30490.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-30490.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,111 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-cloudabi no processes +// ignore-emscripten no processes + +// Previously libstd would set stdio descriptors of a child process +// by `dup`ing the requested descriptors to inherit directly into the +// stdio descriptors. This, however, would incorrectly handle cases +// where the descriptors to inherit were already stdio descriptors. +// This test checks to avoid that regression. + +#![cfg_attr(unix, feature(libc))] +#![cfg_attr(windows, allow(unused_imports))] + +#[cfg(unix)] +extern crate libc; + +use std::fs::File; +use std::io::{Read, Write}; +use std::io::{stdout, stderr}; +use std::process::{Command, Stdio}; + +#[cfg(unix)] +use std::os::unix::io::FromRawFd; + +#[cfg(not(unix))] +fn main() { + // Bug not present in Windows +} + +#[cfg(unix)] +fn main() { + let mut args = std::env::args(); + let name = args.next().unwrap(); + let args: Vec = args.collect(); + if let Some("--child") = args.get(0).map(|s| &**s) { + return child(); + } else if !args.is_empty() { + panic!("unknown options"); + } + + let stdout_backup = unsafe { libc::dup(libc::STDOUT_FILENO) }; + let stderr_backup = unsafe { libc::dup(libc::STDERR_FILENO) }; + assert!(stdout_backup > -1); + assert!(stderr_backup > -1); + + let (stdout_reader, stdout_writer) = pipe(); + let (stderr_reader, stderr_writer) = pipe(); + assert!(unsafe { libc::dup2(stdout_writer, libc::STDOUT_FILENO) } > -1); + assert!(unsafe { libc::dup2(stderr_writer, libc::STDERR_FILENO) } > -1); + + // Make sure we close any duplicates of the writer end of the pipe, + // otherwise we can get stuck reading from the pipe which has open + // writers but no one supplying any input + assert_eq!(unsafe { libc::close(stdout_writer) }, 0); + assert_eq!(unsafe { libc::close(stderr_writer) }, 0); + + stdout().write_all("parent stdout\n".as_bytes()).expect("failed to write to stdout"); + stderr().write_all("parent stderr\n".as_bytes()).expect("failed to write to stderr"); + + let child = { + Command::new(name) + .arg("--child") + .stdin(Stdio::inherit()) + .stdout(unsafe { Stdio::from_raw_fd(libc::STDERR_FILENO) }) + .stderr(unsafe { Stdio::from_raw_fd(libc::STDOUT_FILENO) }) + .spawn() + }; + + // The Stdio passed into the Command took over (and closed) std{out, err} + // so we should restore them as they were. + assert!(unsafe { libc::dup2(stdout_backup, libc::STDOUT_FILENO) } > -1); + assert!(unsafe { libc::dup2(stderr_backup, libc::STDERR_FILENO) } > -1); + + // Using File as a shim around the descriptor + let mut read = String::new(); + let mut f: File = unsafe { FromRawFd::from_raw_fd(stdout_reader) }; + f.read_to_string(&mut read).expect("failed to read from stdout file"); + assert_eq!(read, "parent stdout\nchild stderr\n"); + + // Using File as a shim around the descriptor + read.clear(); + let mut f: File = unsafe { FromRawFd::from_raw_fd(stderr_reader) }; + f.read_to_string(&mut read).expect("failed to read from stderr file"); + assert_eq!(read, "parent stderr\nchild stdout\n"); + + assert!(child.expect("failed to execute child process").wait().unwrap().success()); +} + +#[cfg(unix)] +fn child() { + stdout().write_all("child stdout\n".as_bytes()).expect("child failed to write to stdout"); + stderr().write_all("child stderr\n".as_bytes()).expect("child failed to write to stderr"); +} + +#[cfg(unix)] +/// Returns a pipe (reader, writer combo) +fn pipe() -> (i32, i32) { + let mut fds = [0; 2]; + assert_eq!(unsafe { libc::pipe(fds.as_mut_ptr()) }, 0); + (fds[0], fds[1]) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3052.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3052.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3052.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3052.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +type Connection = Box) + 'static>; + +fn f() -> Option { + let mock_connection: Connection = Box::new(|_| {}); + Some(mock_connection) +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-30530.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-30530.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-30530.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-30530.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for Issue #30530: alloca's created for storing +// intermediate scratch values during brace-less match arms need to be +// initialized with their drop-flag set to "dropped" (or else we end +// up running the destructors on garbage data at the end of the +// function). + +pub enum Handler { + Default, + #[allow(dead_code)] + Custom(*mut Box), +} + +fn main() { + take(Handler::Default, Box::new(main)); +} + +#[inline(never)] +pub fn take(h: Handler, f: Box) -> Box { + unsafe { + match h { + Handler::Custom(ptr) => *Box::from_raw(ptr), + Handler::Default => f, + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-30615.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-30615.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-30615.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-30615.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + &0u8 as *const u8 as *const PartialEq; + &[0u8] as *const [u8; 1] as *const [u8]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-30756.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-30756.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-30756.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-30756.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![forbid(unsafe_code)] + +thread_local!(static FOO: u8 = 1); + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-30891.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-30891.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-30891.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-30891.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +const ERROR_CONST: bool = true; + +fn get() -> bool { + false || ERROR_CONST +} + +pub fn main() { + assert_eq!(get(), true); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3091.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3091.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3091.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3091.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + let x = 1; + let y = 1; + assert_eq!(&x, &y); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3109.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3109.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3109.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3109.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn main() { + println!("{:?}", ("hi there!", "you")); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3121.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3121.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3121.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3121.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] +#![feature(box_syntax)] + +#[derive(Copy, Clone)] +enum side { mayo, catsup, vinegar } +#[derive(Copy, Clone)] +enum order { hamburger, fries(side), shake } +#[derive(Copy, Clone)] +enum meal { to_go(order), for_here(order) } + +fn foo(m: Box, cond: bool) { + match *m { + meal::to_go(_) => { } + meal::for_here(_) if cond => {} + meal::for_here(order::hamburger) => {} + meal::for_here(order::fries(_s)) => {} + meal::for_here(order::shake) => {} + } +} + +pub fn main() { + foo(box meal::for_here(order::hamburger), true) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-31267-additional.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-31267-additional.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-31267-additional.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-31267-additional.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#[derive(Clone, Copy, Debug)] +struct Bar; + +const BAZ: Bar = Bar; + +#[derive(Debug)] +struct Foo([Bar; 1]); + +struct Biz; + +impl Biz { + const BAZ: Foo = Foo([BAZ; 1]); +} + +fn main() { + let foo = Biz::BAZ; + println!("{:?}", foo); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-31267.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-31267.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-31267.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-31267.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for issue #31267 + + +struct Foo; + +impl Foo { + const FOO: [i32; 3] = [0; 3]; +} + +pub fn main() { + let foo = Foo::FOO; + assert_eq!(foo, [0i32, 0, 0]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-31299.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-31299.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-31299.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-31299.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for #31299. This was generating an overflow error +// because of eager normalization: +// +// proving `M: Sized` requires +// - proving `PtrBack>: Sized` requires +// - normalizing `Vec< as Front>::Back>>: Sized` requires +// - proving `Vec: Front` requires +// - `M: Sized` <-- cycle! +// +// If we skip the normalization step, though, everything goes fine. +// +// This could be fixed by implementing lazy normalization everywhere. +// +// However, we want this to work before then. For that, when checking +// whether a type is Sized we only check that the tails are Sized. As +// PtrBack does not have a tail, we don't need to normalize anything +// and this compiles + +trait Front { + type Back; +} + +impl Front for Vec { + type Back = Vec; +} + +struct PtrBack(Vec); + +struct M(PtrBack>); + +fn main() { + std::mem::size_of::(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue_3136_b.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue_3136_b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue_3136_b.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue_3136_b.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue_3136_a.rc + +// pretty-expanded FIXME #23616 + +extern crate issue_3136_a; +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-31702.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-31702.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-31702.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-31702.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-31702-1.rs +// aux-build:issue-31702-2.rs +// ignore-test: FIXME(#31702) when this test was added it was thought that the +// accompanying llvm update would fix it, but +// unfortunately it appears that was not the case. In +// the interest of not deleting the test, though, +// this is just tagged with ignore-test + +// this test is actually entirely in the linked library crates + +extern crate issue_31702_1; +extern crate issue_31702_2; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-31776.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-31776.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-31776.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-31776.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,67 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// Various scenarios in which `pub` is required in blocks + +struct S; + +mod m { + fn f() { + impl ::S { + pub fn s(&self) {} + } + } +} + +// ------------------------------------------------------ + +pub trait Tr { + type A; +} +pub struct S1; + +fn f() { + pub struct Z; + + impl ::Tr for ::S1 { + type A = Z; // Private-in-public error unless `struct Z` is pub + } +} + +// ------------------------------------------------------ + +trait Tr1 { + type A; + fn pull(&self) -> Self::A; +} +struct S2; + +mod m1 { + fn f() { + pub struct Z { + pub field: u8 + } + + impl ::Tr1 for ::S2 { + type A = Z; + fn pull(&self) -> Self::A { Z{field: 10} } + } + } +} + +// ------------------------------------------------------ + +fn main() { + S.s(); // Privacy error, unless `fn s` is pub + let a = S2.pull().field; // Privacy error unless `field: u8` is pub +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-32008.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-32008.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-32008.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-32008.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// Tests that binary operators allow subtyping on both the LHS and RHS, +// and as such do not introduce unnecessarily strict lifetime constraints. + +use std::ops::Add; + +struct Foo; + +impl<'a> Add<&'a Foo> for &'a Foo { + type Output = (); + fn add(self, rhs: &'a Foo) {} +} + +fn try_to_add(input: &Foo) { + let local = Foo; + + // Manual reborrow worked even with invariant trait search. + &*input + &local; + + // Direct use of the reference on the LHS requires additional + // subtyping before searching (invariantly) for `LHS: Add`. + input + &local; +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3211.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3211.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3211.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3211.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn main() { + let mut x = 0; + for _ in 0..4096 { x += 1; } + assert_eq!(x, 4096); + println!("x = {}", x); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3220.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3220.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3220.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3220.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] +// pretty-expanded FIXME #23616 + +struct thing { x: isize, } + +impl Drop for thing { + fn drop(&mut self) {} +} + +fn thing() -> thing { + thing { + x: 0 + } +} + +impl thing { + pub fn f(self) {} +} + +pub fn main() { + let z = thing(); + (z).f(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-32292.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-32292.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-32292.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-32292.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![deny(warnings)] + +#[derive(Hash, Ord, PartialOrd, Eq, PartialEq, Debug, Clone, Copy)] +struct Foo; + +fn main() { + let _ = Foo; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-32389.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-32389.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-32389.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-32389.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn foo() -> T { loop {} } + +fn test() { + let ref mut a: &mut FnMut((i8,), i16) = foo(); + a((0,), 0); +} + +fn main() { + let _ = test; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-32518.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-32518.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-32518.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-32518.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// no-prefer-dynamic +// aux-build:cgu_test.rs +// aux-build:cgu_test_a.rs +// aux-build:cgu_test_b.rs + +extern crate cgu_test_a; +extern crate cgu_test_b; + +fn main() { + cgu_test_a::a::a(); + cgu_test_b::a::a(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-32805.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-32805.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-32805.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-32805.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn const_mir() -> f32 { 9007199791611905.0 } + +fn main() { + let original = "9007199791611905.0"; // (1<<53)+(1<<29)+1 + let expected = "9007200000000000"; + + assert_eq!(const_mir().to_string(), expected); + assert_eq!(original.parse::().unwrap().to_string(), expected); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3290.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3290.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3290.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3290.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +pub fn main() { + let mut x: Box<_> = box 3; + x = x; + assert_eq!(*x, 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-32947.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-32947.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-32947.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-32947.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten FIXME(#45351) + +#![feature(repr_simd, test)] + +extern crate test; + +#[repr(simd)] +pub struct Mu64(pub u64, pub u64, pub u64, pub u64); + +fn main() { + // This ensures an unaligned pointer even in optimized builds, though LLVM + // gets enough type information to actually not mess things up in that case, + // but at the time of writing this, it's enough to trigger the bug in + // non-optimized builds + unsafe { + let memory = &mut [0u64; 8] as *mut _ as *mut u8; + let misaligned_ptr: &mut [u8; 32] = { + std::mem::transmute(memory.offset(1)) + }; + *misaligned_ptr = std::mem::transmute(Mu64(1, 1, 1, 1)); + test::black_box(memory); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-33096.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-33096.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-33096.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-33096.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags: -g + +use std::ops::Deref; + +trait Foo { + fn foo() {} +} + +impl Foo for u8 {} + +fn bar() where T::Target: Foo { + <::Target as Foo>::foo() +} + +fn main() { + bar::<&u8>(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-33185.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-33185.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-33185.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-33185.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +#[macro_export] +macro_rules! state { + ( $( $name:ident : $field:ty )* ) => ( + #[derive(Default)] + struct State { + $($name : $field),* + } + ) +} + +state! { x: i64 } + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-33187.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-33187.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-33187.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-33187.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct Foo(::Data); + +impl Copy for Foo where ::Data: Copy { } +impl Clone for Foo where ::Data: Clone { + fn clone(&self) -> Self { Foo(self.0.clone()) } +} + +trait Repr { + type Data; +} + +impl Repr for A { + type Data = u32; +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-33202.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-33202.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-33202.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-33202.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[repr(C)] +pub enum CPOption { + PSome(T), +} + +fn main() { + println!("sizeof CPOption {}", std::mem::size_of::>()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-33387.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-33387.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-33387.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-33387.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(rustc_attrs)] + +use std::sync::Arc; + +trait Foo { + fn get(&self) -> [u8; 2]; +} + +impl Foo for [u8; 2] { + fn get(&self) -> [u8; 2] { + *self + } +} + +struct Bar(T); + +fn unsize_fat_ptr<'a>(x: &'a Bar) -> &'a Bar { + x +} + +fn unsize_nested_fat_ptr(x: Arc) -> Arc { + x +} + +fn main() { + let x: Box> = Box::new(Bar([1,2])); + assert_eq!(unsize_fat_ptr(&*x).0.get(), [1, 2]); + + let x: Arc = Arc::new([3, 4]); + assert_eq!(unsize_nested_fat_ptr(x).get(), [3, 4]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-333.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-333.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-333.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-333.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn quux(x: T) -> T { let f = id::; return f(x); } + +fn id(x: T) -> T { return x; } + +pub fn main() { assert_eq!(quux(10), 10); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-33461.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-33461.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-33461.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-33461.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +use std::marker::PhantomData; + +struct TheType { + t: PhantomData +} + +pub trait TheTrait { + type TheAssociatedType; +} + +impl TheTrait for () { + type TheAssociatedType = (); +} + +pub trait Shape { + fn doit(&self) { + } +} + +impl Shape

for TheType { +} + +fn main() { + let ball = TheType { t: PhantomData }; + let handle: &Shape<()> = &ball; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-33498.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-33498.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-33498.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-33498.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +pub fn main() { + let x = (0, 2); + + match x { + (0, ref y) => {} + (y, 0) => {} + _ => (), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-33537.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-33537.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-33537.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-33537.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +const fn foo() -> *const i8 { + b"foo" as *const _ as *const i8 +} + +const fn bar() -> i32 { + *&{(1, 2, 3).1} +} + +fn main() { + assert_eq!(foo(), b"foo" as *const _ as *const i8); + assert_eq!(bar(), 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-33687.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-33687.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-33687.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-33687.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(unboxed_closures)] +#![feature(fn_traits)] + +struct Test; + +impl FnOnce<(u32, u32)> for Test { + type Output = u32; + + extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 { + a + b + } +} + +fn main() { + assert_eq!(Test(1u32, 2u32), 3u32); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-33770.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-33770.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-33770.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-33770.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,104 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-cloudabi no processes +// ignore-emscripten no processes + +use std::process::{Command, Stdio}; +use std::env; +use std::sync::{Mutex, RwLock}; +use std::time::Duration; +use std::thread; + +fn test_mutex() { + let m = Mutex::new(0); + let _g = m.lock().unwrap(); + let _g2 = m.lock().unwrap(); +} + +fn test_try_mutex() { + let m = Mutex::new(0); + let _g = m.lock().unwrap(); + let _g2 = m.try_lock().unwrap(); +} + +fn test_rwlock_ww() { + let m = RwLock::new(0); + let _g = m.write().unwrap(); + let _g2 = m.write().unwrap(); +} + +fn test_try_rwlock_ww() { + let m = RwLock::new(0); + let _g = m.write().unwrap(); + let _g2 = m.try_write().unwrap(); +} + +fn test_rwlock_rw() { + let m = RwLock::new(0); + let _g = m.read().unwrap(); + let _g2 = m.write().unwrap(); +} + +fn test_try_rwlock_rw() { + let m = RwLock::new(0); + let _g = m.read().unwrap(); + let _g2 = m.try_write().unwrap(); +} + +fn test_rwlock_wr() { + let m = RwLock::new(0); + let _g = m.write().unwrap(); + let _g2 = m.read().unwrap(); +} + +fn test_try_rwlock_wr() { + let m = RwLock::new(0); + let _g = m.write().unwrap(); + let _g2 = m.try_read().unwrap(); +} + +fn main() { + let args: Vec = env::args().collect(); + if args.len() > 1 { + match &*args[1] { + "mutex" => test_mutex(), + "try_mutex" => test_try_mutex(), + "rwlock_ww" => test_rwlock_ww(), + "try_rwlock_ww" => test_try_rwlock_ww(), + "rwlock_rw" => test_rwlock_rw(), + "try_rwlock_rw" => test_try_rwlock_rw(), + "rwlock_wr" => test_rwlock_wr(), + "try_rwlock_wr" => test_try_rwlock_wr(), + _ => unreachable!(), + } + // If we reach this point then the test failed + println!("TEST FAILED: {}", args[1]); + } else { + let mut v = vec![]; + v.push(Command::new(&args[0]).arg("mutex").stderr(Stdio::null()).spawn().unwrap()); + v.push(Command::new(&args[0]).arg("try_mutex").stderr(Stdio::null()).spawn().unwrap()); + v.push(Command::new(&args[0]).arg("rwlock_ww").stderr(Stdio::null()).spawn().unwrap()); + v.push(Command::new(&args[0]).arg("try_rwlock_ww").stderr(Stdio::null()).spawn().unwrap()); + v.push(Command::new(&args[0]).arg("rwlock_rw").stderr(Stdio::null()).spawn().unwrap()); + v.push(Command::new(&args[0]).arg("try_rwlock_rw").stderr(Stdio::null()).spawn().unwrap()); + v.push(Command::new(&args[0]).arg("rwlock_wr").stderr(Stdio::null()).spawn().unwrap()); + v.push(Command::new(&args[0]).arg("try_rwlock_wr").stderr(Stdio::null()).spawn().unwrap()); + + thread::sleep(Duration::new(1, 0)); + + // Make sure all subprocesses either panicked or were killed because they deadlocked + for mut c in v { + c.kill().ok(); + assert!(!c.wait().unwrap().success()); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3389.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3389.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3389.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3389.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +struct trie_node { + content: Vec , + children: Vec , +} + +fn print_str_vector(vector: Vec ) { + for string in &vector { + println!("{}", *string); + } +} + +pub fn main() { + let mut node: trie_node = trie_node { + content: Vec::new(), + children: Vec::new() + }; + let v = vec!["123".to_string(), "abc".to_string()]; + node.content = vec!["123".to_string(), "abc".to_string()]; + print_str_vector(v); + print_str_vector(node.content.clone()); + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-33992.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-33992.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-33992.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-33992.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-windows +// ignore-macos +// ignore-wasm32-bare common linkage not implemented right now + +#![feature(linkage)] + +#[linkage = "common"] +pub static mut TEST1: u32 = 0u32; + +#[linkage = "external"] +pub static TEST2: bool = true; + +#[linkage = "internal"] +pub static TEST3: bool = true; + +#[linkage = "linkonce"] +pub static TEST4: bool = true; + +#[linkage = "linkonce_odr"] +pub static TEST5: bool = true; + +#[linkage = "private"] +pub static TEST6: bool = true; + +#[linkage = "weak"] +pub static TEST7: bool = true; + +#[linkage = "weak_odr"] +pub static TEST8: bool = true; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-34053.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-34053.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-34053.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-34053.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; + +static DROP_COUNTER: AtomicUsize = ATOMIC_USIZE_INIT; + +struct A(i32); + +impl Drop for A { + fn drop(&mut self) { + // update global drop count + DROP_COUNTER.fetch_add(1, Ordering::SeqCst); + } +} + +static FOO: A = A(123); +const BAR: A = A(456); + +impl A { + const BAZ: A = A(789); +} + +fn main() { + assert_eq!(DROP_COUNTER.load(Ordering::SeqCst), 0); + assert_eq!(&FOO.0, &123); + assert_eq!(DROP_COUNTER.load(Ordering::SeqCst), 0); + assert_eq!(BAR.0, 456); + assert_eq!(DROP_COUNTER.load(Ordering::SeqCst), 1); + assert_eq!(A::BAZ.0, 789); + assert_eq!(DROP_COUNTER.load(Ordering::SeqCst), 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-34074.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-34074.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-34074.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-34074.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Make sure several unnamed function parameters don't conflict with each other + +trait Tr { + #[allow(anonymous_parameters)] + fn f(u8, u8) {} +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3429.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3429.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3429.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3429.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +pub fn main() { + let x = 1_usize; + let y = || x; + let _z = y(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-34427.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-34427.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-34427.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-34427.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Issue #34427: On ARM, the code in `foo` at one time was generating +// a machine code instruction of the form: `str r0, [r0, rN]!` (for +// some N), which is not legal because the source register and base +// register cannot be identical in the preindexed form signalled by +// the `!`. +// +// See LLVM bug: https://llvm.org/bugs/show_bug.cgi?id=28809 + +#[inline(never)] +fn foo(n: usize) -> Vec> { + (0..n).map(|_| None).collect() +} + +fn main() { + let _ = (foo(10), foo(32)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3447.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3447.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3447.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3447.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_snake_case)] +#![allow(non_camel_case_types)] +#![feature(box_syntax)] + +use std::cell::RefCell; + +static S: &'static str = "str"; + +struct list { + element: T, + next: Option>>> +} + +impl list { + pub fn addEnd(&mut self, element: T) { + let newList = list { + element: element, + next: None + }; + + self.next = Some(box RefCell::new(newList)); + } +} + +pub fn main() { + let ls = list { + element: S, + next: None + }; + println!("{}", ls.element); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-34503.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-34503.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-34503.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-34503.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + struct X; + trait Foo { + fn foo(&self) where (T, Option): Ord {} + fn bar(&self, x: &Option) -> bool + where Option: Ord { *x < *x } + } + impl Foo for () {} + let _ = &() as &Foo; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-34569.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-34569.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-34569.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-34569.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags:-g + +// In this test we just want to make sure that the code below does not lead to +// a debuginfo verification assertion during compilation. This was caused by the +// closure in the guard being codegened twice due to how match expressions are +// handled. +// +// See https://github.com/rust-lang/rust/issues/34569 for details. + +fn main() { + match 0 { + e if (|| { e == 0 })() => {}, + 1 => {}, + _ => {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-34571.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-34571.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-34571.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-34571.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[repr(u8)] +enum Foo { + Foo(u8), +} + +fn main() { + match Foo::Foo(1) { + _ => () + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-34784.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-34784.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-34784.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-34784.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +const C: *const u8 = &0; + +fn foo(x: *const u8) { + match x { + C => {} + _ => {} + } +} + +const D: *const [u8; 4] = b"abcd"; + +fn main() { + match D { + D => {} + _ => {} + } +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-34796.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-34796.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-34796.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-34796.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// This test case exposes conditions where the encoding of a trait object type +// with projection predicates would differ between this crate and the upstream +// crate, because the predicates were encoded in different order within each +// crate. This led to different symbol hashes of functions using these type, +// which in turn led to linker errors because the two crates would not agree on +// the symbol name. +// The fix was to make the order in which predicates get encoded stable. + +// aux-build:issue34796aux.rs +extern crate issue34796aux; + +fn mk() -> T { loop {} } + +struct Data { + data: T, + error: E, +} + +fn main() { + issue34796aux::bar(|()| { + Data::<(), std::io::Error> { + data: mk(), + error: mk(), + } + }) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-34798.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-34798.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-34798.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-34798.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![forbid(improper_ctypes)] +#![allow(dead_code)] + +#[repr(C)] +pub struct Foo { + size: u8, + __value: ::std::marker::PhantomData, +} + +#[repr(C)] +pub struct ZeroSizeWithPhantomData(::std::marker::PhantomData); + +#[repr(C)] +pub struct Bar { + size: u8, + baz: ZeroSizeWithPhantomData, +} + +extern "C" { + pub fn bar(_: *mut Foo, _: *mut Bar); +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-34932.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-34932.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-34932.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-34932.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags:--test +// rustc-env:RUSTC_BOOTSTRAP_KEY= +#![cfg(any())] // This test should be configured away +#![feature(rustc_attrs)] // Test that this is allowed on stable/beta +#![feature(iter_arith_traits)] // Test that this is not unused +#![deny(unused_features)] + +#[test] +fn dummy() { + let () = "this should not reach type-checking"; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3500.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3500.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3500.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3500.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +pub fn main() { + let x = &Some(1); + match x { + &Some(_) => (), + &None => (), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-35423.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-35423.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-35423.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-35423.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main () { + let x = 4; + match x { + ref r if *r < 0 => println!("got negative num {} < 0", r), + e @ 1 ..= 100 => println!("got number within range [1,100] {}", e), + _ => println!("no"), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3556.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3556.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3556.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3556.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +#[derive(Debug)] +enum Token { + Text(String), + ETag(Vec, String), + UTag(Vec, String), + Section(Vec, bool, Vec, String, + String, String, String, String), + IncompleteSection(Vec, bool, String, bool), + Partial(String, String, String), +} + +fn check_strs(actual: &str, expected: &str) -> bool +{ + if actual != expected + { + println!("Found {}, but expected {}", actual, expected); + return false; + } + return true; +} + +pub fn main() +{ + let t = Token::Text("foo".to_string()); + let u = Token::Section(vec!["alpha".to_string()], + true, + vec![t], + "foo".to_string(), + "foo".to_string(), "foo".to_string(), "foo".to_string(), + "foo".to_string()); + let v = format!("{:?}", u); // this is the line that causes the seg fault + assert!(!v.is_empty()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3559.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3559.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3559.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3559.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::collections::HashMap; + +fn check_strs(actual: &str, expected: &str) -> bool { + if actual != expected { + println!("Found {}, but expected {}", actual, expected); + return false; + } + return true; +} + +pub fn main() { + let mut table = HashMap::new(); + table.insert("one".to_string(), 1); + table.insert("two".to_string(), 2); + assert!(check_strs(&format!("{:?}", table), "{\"one\": 1, \"two\": 2}") || + check_strs(&format!("{:?}", table), "{\"two\": 2, \"one\": 1}")); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-35600.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-35600.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-35600.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-35600.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +trait Foo { + type bar; + fn bar(); +} + +impl Foo for () { + type bar = (); + fn bar() {} +} + +fn main() { + let x: <() as Foo>::bar = (); + <()>::bar(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3563-3.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3563-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3563-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3563-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,190 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +#![allow(non_snake_case)] + +// ASCII art shape renderer. Demonstrates traits, impls, operator overloading, +// non-copyable struct, unit testing. To run execute: rustc --test shapes.rs && +// ./shapes + +// Rust's std library is tightly bound to the language itself so it is +// automatically linked in. However the extra library is designed to be +// optional (for code that must run on constrained environments like embedded +// devices or special environments like kernel code) so it must be explicitly +// linked in. + +// Extern mod controls linkage. Use controls the visibility of names to modules +// that are already linked in. Using WriterUtil allows us to use the write_line +// method. + +use std::fmt; +use std::iter::repeat; +use std::slice; + +// Represents a position on a canvas. +#[derive(Copy, Clone)] +struct Point { + x: isize, + y: isize, +} + +// Represents an offset on a canvas. (This has the same structure as a Point. +// but different semantics). +#[derive(Copy, Clone)] +struct Size { + width: isize, + height: isize, +} + +#[derive(Copy, Clone)] +struct Rect { + top_left: Point, + size: Size, +} + +// Contains the information needed to do shape rendering via ASCII art. +struct AsciiArt { + width: usize, + height: usize, + fill: char, + lines: Vec > , + + // This struct can be quite large so we'll disable copying: developers need + // to either pass these structs around via references or move them. +} + +impl Drop for AsciiArt { + fn drop(&mut self) {} +} + +// It's common to define a constructor sort of function to create struct instances. +// If there is a canonical constructor it is typically named the same as the type. +// Other constructor sort of functions are typically named from_foo, from_bar, etc. +fn AsciiArt(width: usize, height: usize, fill: char) -> AsciiArt { + // Build a vector of vectors containing blank characters for each position in + // our canvas. + let lines = vec![vec!['.'; width]; height]; + + // Rust code often returns values by omitting the trailing semi-colon + // instead of using an explicit return statement. + AsciiArt {width: width, height: height, fill: fill, lines: lines} +} + +// Methods particular to the AsciiArt struct. +impl AsciiArt { + fn add_pt(&mut self, x: isize, y: isize) { + if x >= 0 && x < self.width as isize { + if y >= 0 && y < self.height as isize { + // Note that numeric types don't implicitly convert to each other. + let v = y as usize; + let h = x as usize; + + // Vector subscripting will normally copy the element, but &v[i] + // will return a reference which is what we need because the + // element is: + // 1) potentially large + // 2) needs to be modified + let row = &mut self.lines[v]; + row[h] = self.fill; + } + } + } +} + +// Allows AsciiArt to be converted to a string using the libcore ToString trait. +// Note that the %s fmt! specifier will not call this automatically. +impl fmt::Display for AsciiArt { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + // Convert each line into a string. + let lines = self.lines.iter() + .map(|line| line.iter().cloned().collect()) + .collect::>(); + + // Concatenate the lines together using a new-line. + write!(f, "{}", lines.join("\n")) + } +} + +// This is similar to an interface in other languages: it defines a protocol which +// developers can implement for arbitrary concrete types. +trait Canvas { + fn add_point(&mut self, shape: Point); + fn add_rect(&mut self, shape: Rect); + + // Unlike interfaces traits support default implementations. + // Got an ICE as soon as I added this method. + fn add_points(&mut self, shapes: &[Point]) { + for pt in shapes {self.add_point(*pt)}; + } +} + +// Here we provide an implementation of the Canvas methods for AsciiArt. +// Other implementations could also be provided (e.g. for PDF or Apple's Quartz) +// and code can use them polymorphically via the Canvas trait. +impl Canvas for AsciiArt { + fn add_point(&mut self, shape: Point) { + self.add_pt(shape.x, shape.y); + } + + fn add_rect(&mut self, shape: Rect) { + // Add the top and bottom lines. + for x in shape.top_left.x..shape.top_left.x + shape.size.width { + self.add_pt(x, shape.top_left.y); + self.add_pt(x, shape.top_left.y + shape.size.height - 1); + } + + // Add the left and right lines. + for y in shape.top_left.y..shape.top_left.y + shape.size.height { + self.add_pt(shape.top_left.x, y); + self.add_pt(shape.top_left.x + shape.size.width - 1, y); + } + } +} + +// Rust's unit testing framework is currently a bit under-developed so we'll use +// this little helper. +pub fn check_strs(actual: &str, expected: &str) -> bool { + if actual != expected { + println!("Found:\n{}\nbut expected\n{}", actual, expected); + return false; + } + return true; +} + + +fn test_ascii_art_ctor() { + let art = AsciiArt(3, 3, '*'); + assert!(check_strs(&art.to_string(), "...\n...\n...")); +} + + +fn test_add_pt() { + let mut art = AsciiArt(3, 3, '*'); + art.add_pt(0, 0); + art.add_pt(0, -10); + art.add_pt(1, 2); + assert!(check_strs(&art.to_string(), "*..\n...\n.*.")); +} + + +fn test_shapes() { + let mut art = AsciiArt(4, 4, '*'); + art.add_rect(Rect {top_left: Point {x: 0, y: 0}, size: Size {width: 4, height: 4}}); + art.add_point(Point {x: 2, y: 2}); + assert!(check_strs(&art.to_string(), "****\n*..*\n*.**\n****")); +} + +pub fn main() { + test_ascii_art_ctor(); + test_add_pt(); + test_shapes(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3574.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3574.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3574.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3574.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// rustc --test match_borrowed_str.rs.rs && ./match_borrowed_str.rs + + +fn compare(x: &str, y: &str) -> bool { + match x { + "foo" => y == "foo", + _ => y == "bar", + } +} + +pub fn main() { + assert!(compare("foo", "foo")); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-35815.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-35815.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-35815.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-35815.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +use std::mem; + +struct Foo { + a: i64, + b: bool, + c: T, +} + +fn main() { + let foo: &Foo = &Foo { a: 1, b: false, c: 2i32 }; + let foo_unsized: &Foo = foo; + assert_eq!(mem::size_of_val(foo), mem::size_of_val(foo_unsized)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36023.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36023.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36023.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36023.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +use std::ops::Deref; + +fn main() { + if env_var("FOOBAR").as_ref().map(Deref::deref).ok() == Some("yes") { + panic!() + } + + let env_home: Result = Ok("foo-bar-baz".to_string()); + let env_home = env_home.as_ref().map(Deref::deref).ok(); + + if env_home == Some("") { panic!() } +} + +#[inline(never)] +fn env_var(s: &str) -> Result { + Err(VarError::NotPresent) +} + +pub enum VarError { + NotPresent, + NotUnicode(String), +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36036-associated-type-layout.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36036-associated-type-layout.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36036-associated-type-layout.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36036-associated-type-layout.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Issue 36036: computing the layout of a type composed from another +// trait's associated type caused compiler to ICE when the associated +// type was allowed to be unsized, even though the known instantiated +// type is itself sized. + +#![allow(dead_code)] + +trait Context { + type Container: ?Sized; +} + +impl Context for u16 { + type Container = u8; +} + +struct Wrapper { + container: &'static C::Container +} + +fn foobar(_: Wrapper) {} + +static VALUE: u8 = 0; + +fn main() { + foobar(Wrapper { container: &VALUE }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36053.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36053.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36053.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36053.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for #36053. ICE was caused due to obligations being +// added to a special, dedicated fulfillment cx during a +// probe. Problem seems to be related to the particular definition of +// `FusedIterator` in std but I was not able to isolate that into an +// external crate. + +use std::iter::FusedIterator; + +struct Thing<'a>(&'a str); +impl<'a> Iterator for Thing<'a> { + type Item = &'a str; + fn next(&mut self) -> Option<&'a str> { + None + } +} + +impl<'a> FusedIterator for Thing<'a> {} + +fn main() { + Thing("test").fuse().filter(|_| true).count(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36139-normalize-closure-sig.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36139-normalize-closure-sig.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36139-normalize-closure-sig.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36139-normalize-closure-sig.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Previously the closure's argument would be inferred to +// >::Item, causing an error in MIR type +// checking + +trait ITrait<'a> {type Item;} + +struct S {} + +impl<'a> ITrait<'a> for S { type Item = &'a mut usize; } + +fn m(_: F) + where I: for<'a> ITrait<'a>, + F: for<'a> FnMut(>::Item) { } + + +fn main() { + m::(|x| { *x += 1; }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36260.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36260.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36260.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36260.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2012-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Make sure this compiles without getting a linker error because of missing +// drop-glue because the collector missed adding drop-glue for the closure: + +fn create_fn() -> Box { + let text = String::new(); + + Box::new(move || { let _ = &text; }) +} + +fn main() { + let _ = create_fn(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36278-prefix-nesting.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36278-prefix-nesting.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36278-prefix-nesting.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36278-prefix-nesting.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Issue 36278: On an unsized struct with >1 level of nontrivial +// nesting, ensure we are computing dynamic size of prefix correctly. + +use std::mem; + +const SZ: usize = 100; +struct P([u8; SZ], T); + +type Ack = P>; + +fn main() { + let size_of_sized; let size_of_unsized; + let x: Box> = Box::new(P([0; SZ], P([0; SZ], [0; 0]))); + size_of_sized = mem::size_of_val::>(&x); + let y: Box> = x; + size_of_unsized = mem::size_of_val::>(&y); + assert_eq!(size_of_sized, size_of_unsized); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36381.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36381.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36381.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36381.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for #36381. The monomorphization collector was asserting that +// there are no projection types, but the `<&str as +// StreamOnce>::Position` projection contained a late-bound region, +// and we don't currently normalize in that case until the function is +// actually invoked. + +pub trait StreamOnce { + type Position; +} + +impl<'a> StreamOnce for &'a str { + type Position = usize; +} + +pub fn parser(_: F) { +} + +fn follow(_: &str) -> <&str as StreamOnce>::Position { + panic!() +} + +fn main() { + parser(follow); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36401.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36401.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36401.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36401.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(Debug)] +pub enum Event { + Key(u8), + Resize, + Unknown(u16), +} + +static XTERM_SINGLE_BYTES : [(u8, Event); 1] = [(1, Event::Resize)]; + +fn main() { + match XTERM_SINGLE_BYTES[0] { + (1, Event::Resize) => {}, + ref bad => panic!("unexpected {:?}", bad) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36474.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36474.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36474.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36474.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + remove_axis(&3, 0); +} + +trait Dimension { + fn slice(&self) -> &[usize]; +} + +impl Dimension for () { + fn slice(&self) -> &[usize] { &[] } +} + +impl Dimension for usize { + fn slice(&self) -> &[usize] { + unsafe { + ::std::slice::from_raw_parts(self, 1) + } + } +} + +fn remove_axis(value: &usize, axis: usize) -> () { + let tup = (); + let mut it = tup.slice().iter(); + for (i, _) in value.slice().iter().enumerate() { + if i == axis { + continue; + } + it.next(); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3656.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3656.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3656.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3656.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(improper_ctypes)] + +// Issue #3656 +// Incorrect struct size computation in the FFI, because of not taking +// the alignment of elements into account. + +// pretty-expanded FIXME #23616 +// ignore-wasm32-bare no libc to test with + +#![feature(libc)] + +extern crate libc; +use libc::{c_uint, uint32_t, c_void}; + +pub struct KEYGEN { + hash_algorithm: [c_uint; 2], + count: uint32_t, + salt: *const c_void, + salt_size: uint32_t, +} + +extern { + // Bogus signature, just need to test if it compiles. + pub fn malloc(data: KEYGEN); +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36744-bitcast-args-if-needed.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36744-bitcast-args-if-needed.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36744-bitcast-args-if-needed.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36744-bitcast-args-if-needed.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// This tests for an ICE (and, if ignored, subsequent LLVM abort) when +// a lifetime-parametric fn is passed into a context whose expected +// type has a differing lifetime parameterization. + +struct A<'a> { + _a: &'a i32, +} + +fn call(s: T, functions: &Vec fn(&'n T)>) { + for function in functions { + function(&s); + } +} + +fn f(a: &A) { println!("a holds {}", a._a); } + +fn main() { + let a = A { _a: &10 }; + + let vec: Vec fn(&'u A<'v>)> = vec![f]; + call(a, &vec); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36768.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36768.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36768.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36768.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags:--test +#![deny(private_in_public)] + +#[test] fn foo() {} +mod foo {} + +#[test] fn core() {} +extern crate core; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36786-resolve-call.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36786-resolve-call.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36786-resolve-call.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36786-resolve-call.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Ensure that types that rely on obligations are autoderefed +// correctly + +fn main() { + let x : Vec> = vec![Box::new(|| ())]; + x[0]() +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36792.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36792.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36792.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36792.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn foo() -> impl Copy { + foo +} +fn main() { + foo(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36816.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36816.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36816.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36816.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +macro_rules! m { () => { 1 } } +macro_rules! n { () => { 1 + m!() } } + +fn main() { + let _: [u32; n!()] = [0, 0]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3683.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3683.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3683.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3683.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +trait Foo { + fn a(&self) -> isize; + fn b(&self) -> isize { + self.a() + 2 + } +} + +impl Foo for isize { + fn a(&self) -> isize { + 3 + } +} + +pub fn main() { + assert_eq!(3.b(), 5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36856.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36856.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36856.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36856.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for #36856. + +// compile-flags:-g + +fn g() -> bool { + false +} + +pub fn main() { + let a = !g(); + if a != !g() { + panic!(); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36936.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36936.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36936.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36936.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// check that casts are not being treated as lexprs. + +fn main() { + let mut a = 0i32; + let b = &(a as i32); + a = 1; + assert_ne!(&a as *const i32, b as *const i32); + assert_eq!(*b, 0); + + assert_eq!(issue_36936(), 1); +} + + +struct A(u32); + +impl Drop for A { + fn drop(&mut self) { + self.0 = 0; + } +} + +fn issue_36936() -> u32 { + let a = &(A(1) as A); + a.0 +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36954.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36954.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-36954.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-36954.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-36954.rs + +extern crate issue_36954 as lib; + +fn main() { + let _ = lib::FOO; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3702.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3702.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3702.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3702.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +pub fn main() { + trait Text { + fn to_string(&self) -> String; + } + + fn to_string(t: Box) { + println!("{}", (*t).to_string()); + } + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-37109.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-37109.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-37109.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-37109.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait ToRef<'a> { + type Ref: 'a; +} + +impl<'a, U: 'a> ToRef<'a> for U { + type Ref = &'a U; +} + +fn example<'a, T>(value: &'a T) -> (>::Ref, u32) { + (value, 0) +} + +fn main() { + example(&0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-37175.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-37175.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-37175.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-37175.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +macro_rules! m { (<$t:ty>) => { stringify!($t) } } +fn main() { + println!("{}", m!(>)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-37222.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-37222.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-37222.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-37222.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#[derive(Debug, PartialEq)] +enum Bar { + A(i64), + B(i32), + C, +} + +#[derive(Debug, PartialEq)] +struct Foo(Bar, u8); + +static FOO: [Foo; 2] = [Foo(Bar::C, 0), Foo(Bar::C, 0xFF)]; + +fn main() { + assert_eq!(&FOO[1], &Foo(Bar::C, 0xFF)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-37291/auxiliary/lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-37291/auxiliary/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-37291/auxiliary/lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-37291/auxiliary/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,52 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +use std::ops::Mul; + +pub trait A {} +pub trait B { + type AT: A; +} +pub trait C { + type BT: B; +} + +pub struct AV; +impl A for AV {} + +pub struct BV; +impl B for BV { + type AT = AV; +} + +pub struct CV; +impl C for CV { + type BT = BV; +} + +pub struct WrapperB(pub T); +pub struct WrapperC(pub T); + +impl Mul::AT>> for WrapperC + where C1: C +{ + type Output = u8; + fn mul(self, _: WrapperB<::AT>) -> Self::Output { + loop {} + } +} +impl Mul> for WrapperC { + type Output = u8; + fn mul(self, _: WrapperC) -> Self::Output { + loop {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-37291/main.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-37291/main.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-37291/main.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-37291/main.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +// aux-build:lib.rs + +// Regression test for #37291. The problem was that the starting +// environment for a specialization check was not including the +// where-clauses from the impl when attempting to normalize the impl's +// trait-ref, so things like `::Item` could not resolve, +// since the `C: Foo` trait bound was not included in the environment. + +extern crate lib; + +use lib::{CV, WrapperB, WrapperC}; + +fn main() { + let a = WrapperC(CV); + let b = WrapperC(CV); + if false { + let _ = a * b; + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3743.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3743.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3743.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3743.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,65 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// If `Mul` used an associated type for its output, this test would +// work more smoothly. + +use std::ops::Mul; + +#[derive(Copy, Clone)] +struct Vec2 { + x: f64, + y: f64 +} + +// methods we want to export as methods as well as operators +impl Vec2 { +#[inline(always)] + fn vmul(self, other: f64) -> Vec2 { + Vec2 { x: self.x * other, y: self.y * other } + } +} + +// Right-hand-side operator visitor pattern +trait RhsOfVec2Mul { + type Result; + + fn mul_vec2_by(&self, lhs: &Vec2) -> Self::Result; +} + +// Vec2's implementation of Mul "from the other side" using the above trait +impl> Mul for Vec2 { + type Output = Res; + + fn mul(self, rhs: Rhs) -> Res { rhs.mul_vec2_by(&self) } +} + +// Implementation of 'f64 as right-hand-side of Vec2::Mul' +impl RhsOfVec2Mul for f64 { + type Result = Vec2; + + fn mul_vec2_by(&self, lhs: &Vec2) -> Vec2 { lhs.vmul(*self) } +} + +// Usage with failing inference +pub fn main() { + let a = Vec2 { x: 3.0f64, y: 4.0f64 }; + + // the following compiles and works properly + let v1: Vec2 = a * 3.0f64; + println!("{} {}", v1.x, v1.y); + + // the following compiles but v2 will not be Vec2 yet and + // using it later will cause an error that the type of v2 + // must be known + let v2 = a * 3.0f64; + println!("{} {}", v2.x, v2.y); // error regarding v2's type +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3753.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3753.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3753.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3753.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Issue #3656 +// Issue Name: pub method preceded by attribute can't be parsed +// Abstract: Visibility parsing failed when compiler parsing + +use std::f64; + +#[derive(Copy, Clone)] +pub struct Point { + x: f64, + y: f64 +} + +#[derive(Copy, Clone)] +pub enum Shape { + Circle(Point, f64), + Rectangle(Point, Point) +} + +impl Shape { + pub fn area(&self, sh: Shape) -> f64 { + match sh { + Shape::Circle(_, size) => f64::consts::PI * size * size, + Shape::Rectangle(Point {x, y}, Point {x: x2, y: y2}) => (x2 - x) * (y2 - y) + } + } +} + +pub fn main(){ + let s = Shape::Circle(Point { x: 1.0, y: 2.0 }, 3.0); + println!("{}", s.area(s)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-37686.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-37686.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-37686.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-37686.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + match (0, 0) { + (std::usize::MIN, std::usize::MAX) => {} + _ => {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3794.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3794.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3794.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3794.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +trait T { + fn print(&self); +} + +#[derive(Debug)] +struct S { + s: isize, +} + +impl T for S { + fn print(&self) { + println!("{:?}", self); + } +} + +fn print_t(t: &T) { + t.print(); +} + +fn print_s(s: &S) { + s.print(); +} + +pub fn main() { + let s: Box = box S { s: 5 }; + print_s(&*s); + let t: Box = s as Box; + print_t(&*t); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-37991.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-37991.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-37991.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-37991.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +const fn foo() -> i64 { + 3 +} + +const fn bar(x: i64) -> i64 { + x*2 +} + +fn main() { + let val = &(foo() % 2); + assert_eq!(*val, 1); + + let val2 = &(bar(1+1) % 3); + assert_eq!(*val2, 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38002.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38002.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38002.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38002.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Check that constant ADTs are codegened OK, part k of N. + +enum Bar { + C +} + +enum Foo { + A {}, + B { + y: usize, + z: Bar + }, +} + +const LIST: [(usize, Foo); 2] = [ + (51, Foo::B { y: 42, z: Bar::C }), + (52, Foo::B { y: 45, z: Bar::C }), +]; + +pub fn main() { + match LIST { + [ + (51, Foo::B { y: 42, z: Bar::C }), + (52, Foo::B { y: 45, z: Bar::C }) + ] => {} + _ => { + // I would want to print the enum here, but if + // the discriminant is garbage this causes an + // `unreachable` and silent process exit. + panic!("trivial match failed") + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38033.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38033.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38033.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38033.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,89 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::marker; +use std::mem; + +fn main() { + let workers = (0..0).map(|_| result::()); + drop(join_all(workers).poll()); +} + +trait Future { + type Item; + type Error; + + fn poll(&mut self) -> Result; +} + +trait IntoFuture { + type Future: Future; + type Item; + type Error; + + fn into_future(self) -> Self::Future; +} + +impl IntoFuture for F { + type Future = F; + type Item = F::Item; + type Error = F::Error; + + fn into_future(self) -> F { + self + } +} + +struct FutureResult { + _inner: marker::PhantomData<(T, E)>, +} + +fn result() -> FutureResult { + loop {} +} + +impl Future for FutureResult { + type Item = T; + type Error = E; + + fn poll(&mut self) -> Result { + loop {} + } +} + +struct JoinAll + where I: IntoIterator, + I::Item: IntoFuture, +{ + elems: Vec<::Item>, +} + +fn join_all(_: I) -> JoinAll + where I: IntoIterator, + I::Item: IntoFuture, +{ + JoinAll { elems: vec![] } +} + +impl Future for JoinAll + where I: IntoIterator, + I::Item: IntoFuture, +{ + type Item = Vec<::Item>; + type Error = ::Error; + + fn poll(&mut self) -> Result { + let elems = mem::replace(&mut self.elems, Vec::new()); + Ok(elems.into_iter().map(|e| { + e + }).collect::>()) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38074.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38074.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38074.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38074.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten FIXME(#45351) + +#![feature(platform_intrinsics, repr_simd)] + +extern "platform-intrinsic" { + fn simd_shuffle2(x: T, y: T, idx: [u32; 2]) -> U; +} + +#[repr(simd)] +#[derive(Clone, Copy)] +#[allow(non_camel_case_types)] +struct u64x2(u64, u64); + +fn main() { + let a = u64x2(1, 2); + let r: u64x2 = unsafe { simd_shuffle2(a, a, [0-0, 0-0]) }; + assert_eq!(r.0, 1); + assert_eq!(r.1, 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38091.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38091.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38091.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38091.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(specialization)] + +trait Iterate<'a> { + type Ty: Valid; + fn iterate(self); +} +impl<'a, T> Iterate<'a> for T where T: Check { + default type Ty = (); + default fn iterate(self) {} +} + +trait Check {} +impl<'a, T> Check for T where >::Ty: Valid {} + +trait Valid {} + +fn main() { + Iterate::iterate(0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38190.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38190.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38190.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38190.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue_38190.rs +// ignore-pretty issue #37195 + +#[macro_use] +extern crate issue_38190; + +mod auxiliary { + m!([mod issue_38190;]); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38226.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38226.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38226.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38226.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// This test makes sure that we don't run into a linker error because of the +// middle::reachable pass missing trait methods with default impls. + +// aux-build:issue_38226_aux.rs + +// Need -Cno-prepopulate-passes to really disable inlining, otherwise the faulty +// code gets optimized out: +// compile-flags: -Cno-prepopulate-passes -Cpasses=name-anon-globals + +extern crate issue_38226_aux; + +fn main() { + issue_38226_aux::foo::<()>(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38437.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38437.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38437.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38437.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,56 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Check that drop elaboration clears the "master" discriminant +// drop flag even if it protects no fields. + +struct Good(usize); +impl Drop for Good { + #[inline(never)] + fn drop(&mut self) { + println!("dropping Good({})", self.0); + } +} + +struct Void; +impl Drop for Void { + #[inline(never)] + fn drop(&mut self) { + panic!("Suddenly, a Void appears."); + } +} + +enum E { + Never(Void), + Fine(Good) +} + +fn main() { + let mut go = true; + + loop { + let next; + match go { + true => next = E::Fine(Good(123)), + false => return, + } + + match next { + E::Never(_) => return, + E::Fine(_good) => go = false, + } + + // `next` is dropped and StorageDead'd here. We must reset the + // discriminant's drop flag to avoid random variants being + // dropped. + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3847.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3847.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3847.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3847.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +mod buildings { + pub struct Tower { pub height: usize } +} + +pub fn main() { + let sears = buildings::Tower { height: 1451 }; + let h: usize = match sears { + buildings::Tower { height: h } => { h } + }; + + println!("{}", h); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38556.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38556.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38556.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38556.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +pub struct Foo; + +macro_rules! reexport { + () => { use Foo as Bar; } +} + +reexport!(); + +fn main() { + use Bar; + fn f(_: Bar) {} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38715.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38715.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38715.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38715.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue_38715.rs +// aux-build:issue_38715-modern.rs + +// Test that `#[macro_export] macro_rules!` shadow earlier `#[macro_export] macro_rules!` + +#[macro_use] +extern crate issue_38715; +#[macro_use] +extern crate issue_38715_modern; + +fn main() { + foo!(); + foo_modern!(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38763.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38763.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38763.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38763.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten + +#[repr(C)] +pub struct Foo(i128); + +#[no_mangle] +pub extern "C" fn foo(x: Foo) -> Foo { x } + +fn main() { + foo(Foo(1)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3878.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3878.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3878.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3878.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#![allow(path_statements)] +#![feature(box_syntax)] + +pub fn main() { + let y: Box<_> = box 1; + y; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38942.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38942.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38942.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38942.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// See https://github.com/rust-lang/rust/issues/38942 + +#[repr(u64)] +pub enum NSEventType { + NSEventTypePressure, +} + +pub const A: u64 = NSEventType::NSEventTypePressure as u64; + +fn banana() -> u64 { + A +} + +fn main() { + println!("banana! {}", banana()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3895.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3895.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3895.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3895.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +pub fn main() { + enum State { BadChar, BadSyntax } + + match State::BadChar { + _ if true => State::BadChar, + State::BadChar | State::BadSyntax => panic!() , + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38987.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38987.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-38987.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-38987.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + let _ = -0x8000_0000_0000_0000_0000_0000_0000_0000i128; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3904.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3904.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3904.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3904.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn example_err(prog: &str, arg: &str) { + println!("{}: {}", prog, arg) +} + +fn exit(print: F, prog: &str, arg: &str) where F: FnOnce(&str, &str) { + print(prog, arg); +} + +struct X where F: FnOnce(&str, &str) { + err: F, +} + +impl X where F: FnOnce(&str, &str) { + pub fn boom(self) { + exit(self.err, "prog", "arg"); + } +} + +pub fn main(){ + let val = X { + err: example_err, + }; + val.boom(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-39292.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-39292.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-39292.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-39292.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for issue #39292. The object vtable was being +// incorrectly left with a null pointer. + +trait Foo { + fn print<'a>(&'a self) where T: 'a { println!("foo"); } +} + +impl<'a> Foo<&'a ()> for () { } + +trait Bar: for<'a> Foo<&'a ()> { } + +impl Bar for () {} + +fn main() { + (&() as &Bar).print(); // Segfault +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3935.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3935.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3935.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3935.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#[derive(PartialEq)] +struct Bike { + name: String, +} + +pub fn main() { + let town_bike = Bike { name: "schwinn".to_string() }; + let my_bike = Bike { name: "surly".to_string() }; + + assert!(town_bike != my_bike); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-39367.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-39367.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-39367.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-39367.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,50 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::ops::Deref; + +struct ArenaSet::Target>(U, &'static V) + where V: 'static + ?Sized; + +static Z: [u8; 4] = [1,2,3,4]; + +fn arena() -> &'static ArenaSet> { + fn __static_ref_initialize() -> ArenaSet> { + ArenaSet(vec![], &Z) + } + unsafe { + use std::sync::{Once, ONCE_INIT}; + fn require_sync(_: &T) { } + unsafe fn __stability() -> &'static ArenaSet> { + use std::mem::transmute; + use std::boxed::Box; + static mut DATA: *const ArenaSet> = 0 as *const ArenaSet>; + + static mut ONCE: Once = ONCE_INIT; + ONCE.call_once(|| { + DATA = transmute + ::>>, *const ArenaSet>> + (Box::new(__static_ref_initialize())); + }); + + &*DATA + } + let static_ref = __stability(); + require_sync(static_ref); + static_ref + } +} + +fn main() { + let &ArenaSet(ref u, v) = arena(); + assert!(u.is_empty()); + assert_eq!(v, Z); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-39548.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-39548.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-39548.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-39548.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +type Array = [(); ((1 < 2) == false) as usize]; + +fn main() { + let _: Array = []; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-39709.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-39709.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-39709.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-39709.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_macros)] +fn main() { + println!("{}", { macro_rules! x { ($(t:tt)*) => {} } 33 }); +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-39720.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-39720.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-39720.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-39720.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_snake_case)] + +// ignore-emscripten FIXME(#45351) + +#![feature(repr_simd, platform_intrinsics)] + +#[repr(C)] +#[repr(simd)] +#[derive(Copy, Clone, Debug)] +pub struct char3(pub i8, pub i8, pub i8); + +#[repr(C)] +#[repr(simd)] +#[derive(Copy, Clone, Debug)] +pub struct short3(pub i16, pub i16, pub i16); + +extern "platform-intrinsic" { + fn simd_cast(x: T) -> U; +} + +fn main() { + let cast: short3 = unsafe { simd_cast(char3(10, -3, -9)) }; + + println!("{:?}", cast); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-39720.stderr rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-39720.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-39720.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-39720.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +warning[E0566]: conflicting representation hints + --> $DIR/issue-39720.rs:18:8 + | +LL | #[repr(C)] + | ^ +LL | #[repr(simd)] + | ^^^^ + +warning[E0566]: conflicting representation hints + --> $DIR/issue-39720.rs:23:8 + | +LL | #[repr(C)] + | ^ +LL | #[repr(simd)] + | ^^^^ + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3979-generics.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3979-generics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3979-generics.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3979-generics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_snake_case)] + +use std::ops::Add; + +trait Positioned { + fn SetX(&mut self, _: S); + fn X(&self) -> S; +} + +trait Movable>: Positioned { + fn translate(&mut self, dx: S) { + let x = self.X() + dx; + self.SetX(x); + } +} + +struct Point { x: isize, y: isize } + +impl Positioned for Point { + fn SetX(&mut self, x: isize) { + self.x = x; + } + fn X(&self) -> isize { + self.x + } +} + +impl Movable for Point {} + +pub fn main() { + let mut p = Point{ x: 1, y: 2}; + p.translate(3); + assert_eq!(p.X(), 4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3979.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3979.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3979.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3979.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_snake_case)] + +trait Positioned { + fn SetX(&mut self, _: isize); + fn X(&self) -> isize; +} + +trait Movable: Positioned { + fn translate(&mut self, dx: isize) { + let x = self.X(); + self.SetX(x + dx); + } +} + +struct Point { x: isize, y: isize } + +impl Positioned for Point { + fn SetX(&mut self, x: isize) { + self.x = x; + } + fn X(&self) -> isize { + self.x + } +} + +impl Movable for Point {} + +pub fn main() { + let mut p = Point{ x: 1, y: 2}; + p.translate(3); + assert_eq!(p.X(), 4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3979-xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3979-xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-3979-xcrate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-3979-xcrate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// aux-build:issue_3979_traits.rs + +extern crate issue_3979_traits; +use issue_3979_traits::{Positioned, Movable}; + +struct Point { x: isize, y: isize } + +impl Positioned for Point { + fn SetX(&mut self, x: isize) { + self.x = x; + } + fn X(&self) -> isize { + self.x + } +} + +impl Movable for Point {} + +pub fn main() { + let mut p = Point{ x: 1, y: 2}; + p.translate(3); + assert_eq!(p.X(), 4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-39808.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-39808.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-39808.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-39808.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unreachable_code)] + +// Regression test for #39808. The type parameter of `Owned` was +// considered to be "unconstrained" because the type resulting from +// `format!` (`String`) was not being propagated upward, owing to the +// fact that the expression diverges. + +use std::borrow::Cow; + +fn main() { + let _ = if false { + Cow::Owned(format!("{:?}", panic!())) + } else { + Cow::Borrowed("") + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-39823.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-39823.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-39823.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-39823.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue_39823.rs + +extern crate issue_39823; +use issue_39823::{RemoteC, RemoteG}; + +#[derive(Debug, PartialEq)] +struct LocalC(u32); + +#[derive(Debug, PartialEq)] +struct LocalG(T); + +fn main() { + let virtual_localc : &Fn(_) -> LocalC = &LocalC; + assert_eq!(virtual_localc(1), LocalC(1)); + + let virtual_localg : &Fn(_) -> LocalG = &LocalG; + assert_eq!(virtual_localg(1), LocalG(1)); + + let virtual_remotec : &Fn(_) -> RemoteC = &RemoteC; + assert_eq!(virtual_remotec(1), RemoteC(1)); + + let virtual_remoteg : &Fn(_) -> RemoteG = &RemoteG; + assert_eq!(virtual_remoteg(1), RemoteG(1)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-39827.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-39827.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-39827.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-39827.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(core_intrinsics)] + +use std::intrinsics::{ volatile_copy_memory, volatile_store, volatile_load, + volatile_copy_nonoverlapping_memory, + volatile_set_memory }; + +// +// This test ensures that volatile intrinsics can be specialised with +// zero-sized types and, in case of copy/set functions, can accept +// number of elements equal to zero. +// +fn main () { + let mut dst_pair = (1, 2); + let src_pair = (3, 4); + let mut dst_empty = (); + let src_empty = (); + + const COUNT_0: usize = 0; + const COUNT_100: usize = 100; + + unsafe { + volatile_copy_memory(&mut dst_pair, &dst_pair, COUNT_0); + volatile_copy_nonoverlapping_memory(&mut dst_pair, &src_pair, 0); + volatile_copy_memory(&mut dst_empty, &dst_empty, 100); + volatile_copy_nonoverlapping_memory(&mut dst_empty, &src_empty, + COUNT_100); + volatile_set_memory(&mut dst_empty, 0, COUNT_100); + volatile_set_memory(&mut dst_pair, 0, COUNT_0); + volatile_store(&mut dst_empty, ()); + volatile_store(&mut dst_empty, src_empty); + volatile_load(&src_empty); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-40003.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-40003.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-40003.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-40003.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,188 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +fn main() { + if false { test(); } +} + +fn test() { + let rx = Err::, u32>(1).into_future(); + + rx.map(|l: Vec| stream::iter(l.into_iter().map(|i| Ok(i)))) + .flatten_stream() + .chunks(50) + .buffer_unordered(5); +} + +use future::{Future, IntoFuture}; +mod future { + use std::result; + + use {stream, Stream}; + + pub trait Future { + type Item; + type Error; + + fn map(self, _: F) -> Map + where F: FnOnce(Self::Item) -> U, + Self: Sized, + { + panic!() + } + + fn flatten_stream(self) -> FlattenStream + where ::Item: stream::Stream, + Self: Sized + { + panic!() + } + } + + pub trait IntoFuture { + type Future: Future; + type Item; + type Error; + fn into_future(self) -> Self::Future; + } + + impl IntoFuture for F { + type Future = F; + type Item = F::Item; + type Error = F::Error; + + fn into_future(self) -> F { + panic!() + } + } + + impl IntoFuture for result::Result { + type Future = FutureResult; + type Item = T; + type Error = E; + + fn into_future(self) -> FutureResult { + panic!() + } + } + + pub struct Map { + _a: (A, F), + } + + impl Future for Map + where A: Future, + F: FnOnce(A::Item) -> U, + { + type Item = U; + type Error = A::Error; + } + + pub struct FlattenStream { + _f: F, + } + + impl Stream for FlattenStream + where F: Future, + ::Item: Stream, + { + type Item = ::Item; + type Error = ::Error; + } + + pub struct FutureResult { + _inner: (T, E), + } + + impl Future for FutureResult { + type Item = T; + type Error = E; + } +} + +mod stream { + use IntoFuture; + + pub trait Stream { + type Item; + type Error; + + fn buffer_unordered(self, amt: usize) -> BufferUnordered + where Self::Item: IntoFuture::Error>, + Self: Sized + { + new(self, amt) + } + + fn chunks(self, _capacity: usize) -> Chunks + where Self: Sized + { + panic!() + } + } + + pub struct IterStream { + _iter: I, + } + + pub fn iter(_: J) -> IterStream + where J: IntoIterator>, + { + panic!() + } + + impl Stream for IterStream + where I: Iterator>, + { + type Item = T; + type Error = E; + } + + pub struct Chunks { + _stream: S + } + + impl Stream for Chunks + where S: Stream + { + type Item = Result::Item>, u32>; + type Error = ::Error; + } + + pub struct BufferUnordered { + _stream: S, + } + + enum Slot { + Next(usize), + _Data { _a: T }, + } + + fn new(_s: S, _amt: usize) -> BufferUnordered + where S: Stream, + S::Item: IntoFuture::Error>, + { + (0..0).map(|_| { + Slot::Next::<::Future>(1) + }).collect::>(); + panic!() + } + + impl Stream for BufferUnordered + where S: Stream, + S::Item: IntoFuture::Error>, + { + type Item = ::Item; + type Error = ::Error; + } +} +use stream::Stream; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-40085.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-40085.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-40085.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-40085.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::ops::Index; +fn bar() {} +static UNIT: () = (); +struct S; +impl Index for S { + type Output = (); + fn index(&self, _: fn()) -> &() { &UNIT } +} +fn main() { + S.index(bar); + S[bar]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-40235.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-40235.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-40235.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-40235.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +fn foo() {} + +fn main() { + while let Some(foo) = Some(1) { break } + foo(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-40408.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-40408.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-40408.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-40408.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + println!("{}", 0E+10); + println!("{}", 0e+10); + println!("{}", 00e+10); + println!("{}", 00E+10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-40469.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-40469.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-40469.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-40469.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-pretty issue #37195 + +#![allow(dead_code)] + +include!("auxiliary/issue_40469.rs"); +fn f() { m!(); } + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-40770.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-40770.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-40770.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-40770.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_macros)] +macro_rules! m { + ($e:expr) => { + macro_rules! n { () => { $e } } + } +} + +fn main() { + m!(foo!()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-40847.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-40847.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-40847.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-40847.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +macro_rules! gen { + ($name:ident ( $($dol:tt $var:ident)* ) $($body:tt)*) => { + macro_rules! $name { + ($($dol $var:ident)*) => { + $($body)* + } + } + } +} + +gen!(m($var) $var); + +fn main() { + let x = 1; + assert_eq!(m!(x), 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-40883.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-40883.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-40883.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-40883.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,103 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// check that we don't have linear stack usage with multiple calls to `push` + +#![feature(test)] + +extern crate test; +use std::mem; + +fn meal() -> Big { + if test::black_box(false) { + panic!() + } + Big { drop_me: [ + None, None, None, None, None, None, None, None, + None, None, None, None, None, None, None, None, + None, None, None, None, None, None, None, None, + None, None, None, None, None, None, None, None, + None, None, None, None, None, None, None, None, + None, None, None, None, None, None, None, None, + ]} +} + +pub struct Big { + drop_me: [Option>; 48], +} + +#[inline] +fn push(out: &mut Vec) { + out.push(meal()); +} + +#[inline(never)] +pub fn supersize_me(out: &mut Vec) { + push(out); + push(out); + push(out); + push(out); + push(out); + push(out); + push(out); + push(out); + push(out); + push(out); + push(out); + push(out); + push(out); + push(out); + push(out); + push(out); // 16 calls to `push` + + verify_stack_usage(out); + + push(out); + push(out); + push(out); + push(out); + push(out); + push(out); + push(out); + push(out); + push(out); + push(out); + push(out); + push(out); + push(out); + push(out); + push(out); + push(out); // 16 calls to `push` +} + +#[inline(never)] +fn verify_stack_usage(before_ptr: *mut Vec) { + // to check stack usage, create locals before and after + // and check the difference in addresses between them. + let mut stack_var: Vec = vec![]; + test::black_box(&mut stack_var); + let stack_usage = isize::abs( + (&mut stack_var as *mut _ as isize) - + (before_ptr as isize)) as usize; + // give space for 2 copies of `Big` + 128 "misc" bytes. + if stack_usage > mem::size_of::() * 2 + 128 { + panic!("used {} bytes of stack, but `struct Big` is only {} bytes", + stack_usage, mem::size_of::()); + } + +} + +pub fn main() { + let mut v = vec![]; + test::black_box(&mut v); + supersize_me(&mut v); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-40951.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-40951.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-40951.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-40951.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// Regression test for #40951. + +const FOO: [&'static str; 1] = ["foo"]; + +fn find(t: &[T], element: &T) { } + +fn main() { + let x = format!("hi"); + find(&FOO, &&*x); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41053.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41053.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41053.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41053.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue_41053.rs + +pub trait Trait { fn foo(&self) {} } + +pub struct Foo; + +impl Iterator for Foo { + type Item = Box; + fn next(&mut self) -> Option> { + extern crate issue_41053; + impl ::Trait for issue_41053::Test { + fn foo(&self) {} + } + Some(Box::new(issue_41053::Test)) + } +} + +fn main() { + Foo.next().unwrap().foo(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4107.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4107.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4107.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4107.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +pub fn main() { + let _id: &Mat2 = &Matrix::identity(1.0); +} + +pub trait Index { fn get(&self, _: Index) -> Result { panic!() } } +pub trait Dimensional: Index { } + +pub struct Mat2 { x: T } +pub struct Vec2 { x: T } + +impl Dimensional> for Mat2 { } +impl Index> for Mat2 { } + +impl Dimensional for Vec2 { } +impl Index for Vec2 { } + +pub trait Matrix: Dimensional { + fn identity(t:T) -> Self; +} + +impl Matrix> for Mat2 { + fn identity(t:T) -> Mat2 { Mat2{ x: t } } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41213.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41213.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41213.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41213.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +enum A { + A1, + A2, + A3, +} + +enum B { + B1(String, String), + B2(String, String), +} + +fn main() { + let a = A::A1; + loop { + let _ctor = match a { + A::A3 => break, + A::A1 => B::B1, + A::A2 => B::B2, + }; + break; + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41394.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41394.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41394.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41394.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-41394.rs + +extern crate issue_41394 as lib; + +fn main() { + assert_eq!(lib::foo() as u32, 42); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41479.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41479.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41479.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41479.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn split(pair: (A, B)) { + let _a = pair.0; + let _b = pair.1; +} + +fn main() { + split(((), ((), ()))); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41498.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41498.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41498.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41498.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// regression test for issue #41498. + +struct S; +impl S { + fn mutate(&mut self) {} +} + +fn call_and_ref T>(x: &mut Option, f: F) -> &mut T { + *x = Some(f()); + x.as_mut().unwrap() +} + +fn main() { + let mut n = None; + call_and_ref(&mut n, || [S])[0].mutate(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41604.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41604.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41604.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41604.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct B; + +impl B { + fn init(&mut self) {} +} + +fn main() { + let mut b = [B]; + b[1-1].init(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41677.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41677.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41677.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41677.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for #41677. The local variable was winding up with +// a type `Receiver` where `?T` was unconstrained, because we +// failed to enforce the WF obligations and `?T` is a bivariant type +// parameter position. + +#![allow(unused_variables, dead_code)] + +use std::marker::PhantomData; + +trait Handle { + type Inner; +} + +struct ResizingHandle(PhantomData); +impl Handle for ResizingHandle { + type Inner = H; +} + +struct Receiver>(PhantomData); + +fn channel(size: usize) -> Receiver> { + let rx = Receiver(PhantomData); + rx +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41696.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41696.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41696.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41696.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,63 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// this used to cause exponential code-size blowup during LLVM passes. + +#![feature(test)] + +extern crate test; + +struct MayUnwind; + +impl Drop for MayUnwind { + fn drop(&mut self) { + if test::black_box(false) { + panic!() + } + } +} + +struct DS { + may_unwind: MayUnwind, + name: String, + next: U, +} + +fn add(ds: DS, name: String) -> DS> { + DS { + may_unwind: MayUnwind, + name: "?".to_owned(), + next: ds, + } +} + +fn main() { + let deserializers = DS { may_unwind: MayUnwind, name: "?".to_owned(), next: () }; + let deserializers = add(deserializers, "?".to_owned()); + let deserializers = add(deserializers, "?".to_owned()); + let deserializers = add(deserializers, "?".to_owned()); + let deserializers = add(deserializers, "?".to_owned()); + let deserializers = add(deserializers, "?".to_owned()); + let deserializers = add(deserializers, "?".to_owned()); + let deserializers = add(deserializers, "?".to_owned()); // 0.7s + let deserializers = add(deserializers, "?".to_owned()); // 1.3s + let deserializers = add(deserializers, "?".to_owned()); // 2.4s + let deserializers = add(deserializers, "?".to_owned()); // 6.7s + let deserializers = add(deserializers, "?".to_owned()); // 26.0s + let deserializers = add(deserializers, "?".to_owned()); // 114.0s + let deserializers = add(deserializers, "?".to_owned()); // 228.0s + let deserializers = add(deserializers, "?".to_owned()); // 400.0s + let deserializers = add(deserializers, "?".to_owned()); // 800.0s + let deserializers = add(deserializers, "?".to_owned()); // 1600.0s + let deserializers = add(deserializers, "?".to_owned()); // 3200.0s +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41744.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41744.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41744.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41744.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait Tc {} +impl Tc for bool {} + +fn main() { + let _: &[&Tc] = &[&true]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41803.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41803.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41803.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41803.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +/// A compile-time map from identifiers to arbitrary (heterogeneous) expressions +macro_rules! ident_map { + ( $name:ident = { $($key:ident => $e:expr,)* } ) => { + macro_rules! $name { + $( + ( $key ) => { $e }; + )* + // Empty invocation expands to nothing. Needed when the map is empty. + () => {}; + } + }; +} + +ident_map!(my_map = { + main => 0, +}); + +fn main() { + my_map!(main); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41849-variance-req.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41849-variance-req.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41849-variance-req.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41849-variance-req.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Regression test for #41849. + +use std::ops::Mul; + +const C: usize = 1; +const CAPACITY: usize = 1 * C; + +struct A { + f: [X; CAPACITY], +} + +struct B { + f: T, +} + +impl Mul for B { + type Output = Self; + fn mul(self, _rhs: B) -> Self::Output { + self + } +} + +impl Mul for B { + type Output = Self; + fn mul(self, _rhs: usize) -> Self::Output { + self + } +} + +fn main() { + let a = A { f: [1] }; + let _ = B { f: a }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41888.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41888.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-41888.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-41888.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { let _ = g(Some(E::F(K))); } + +type R = Result<(), ()>; +struct K; + +enum E { + F(K), // must not be built-in type + #[allow(dead_code)] + G(Box, Box), +} + +fn translate(x: R) -> R { x } + +fn g(mut status: Option) -> R { + loop { + match status { + Some(infix_or_postfix) => match infix_or_postfix { + E::F(_op) => { // <- must be captured by value + match Ok(()) { + Err(err) => return Err(err), + Ok(_) => {}, + }; + } + _ => (), + }, + _ => match translate(Err(())) { + Err(err) => return Err(err), + Ok(_) => {}, + } + } + status = None; + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-42007.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-42007.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-42007.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-42007.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// aux-build:issue_42007_s.rs + +extern crate issue_42007_s; + +enum I { + E(issue_42007_s::E), +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4208.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4208.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4208.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4208.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// aux-build:issue-4208-cc.rs + +// pretty-expanded FIXME #23616 + +extern crate numeric; +use numeric::{sin, Angle}; + +fn foo>(theta: A) -> T { sin(&theta) } + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-42148.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-42148.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-42148.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-42148.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct Zst; + +fn main() { + unsafe { ::std::ptr::write_volatile(1 as *mut Zst, Zst) } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-42210.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-42210.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-42210.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-42210.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for #42210. + +// compile-flags: -g + +trait Foo { + fn foo() { } +} + +struct Bar; + +trait Baz { +} + +impl Foo for (Bar, Baz) { } + + +fn main() { + <(Bar, Baz) as Foo>::foo() +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4228.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4228.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4228.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4228.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +struct Foo; + +impl Foo { + fn first() {} +} +impl Foo { + fn second() {} +} + +pub fn main() { + Foo::first(); + Foo::second(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-42453.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-42453.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-42453.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-42453.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +#[derive(Debug)] +struct builder; + +fn main() { + +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-42463.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-42463.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-42463.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-42463.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::ops::{Deref, DerefMut}; + +struct CheckedDeref { + value: T, + check: F +} + +impl bool, T> Deref for CheckedDeref { + type Target = T; + fn deref(&self) -> &T { + assert!((self.check)(&self.value)); + &self.value + } +} + +impl bool, T> DerefMut for CheckedDeref { + fn deref_mut(&mut self) -> &mut T { + assert!((self.check)(&self.value)); + &mut self.value + } +} + + +fn main() { + let mut v = CheckedDeref { + value: vec![0], + check: |v: &Vec<_>| !v.is_empty() + }; + v.push(1); + assert_eq!(*v, vec![0, 1]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4252.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4252.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4252.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4252.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait X { + fn call(&self, x: &T); + fn default_method(&self, x: &T) { + println!("X::default_method {:?}", x); + } +} + +#[derive(Debug)] +struct Y(isize); + +#[derive(Debug)] +struct Z { + x: T +} + +impl X for Y { + fn call(&self, x: &T) { + println!("X::call {:?} {:?}", self, x); + } +} + +impl Drop for Z { + fn drop(&mut self) { + // These statements used to cause an ICE. + self.x.call(self); + self.x.default_method(self); + } +} + +pub fn main() { + let _z = Z {x: Y(42)}; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-42552.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-42552.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-42552.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-42552.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for an obscure issue with the projection cache. + +fn into_iter(a: &I) -> Groups { + Groups { _a: a } +} + +pub struct Groups<'a, I: 'a> { + _a: &'a I, +} + +impl<'a, I: Iterator> Iterator for Groups<'a, I> { + type Item = Group<'a, I>; + fn next(&mut self) -> Option { + None + } +} + +pub struct Group<'a, I: Iterator + 'a> + where I::Item: 'a // <-- needed to trigger ICE! +{ + _phantom: &'a (), + _ice_trigger: I::Item, // <-- needed to trigger ICE! +} + + +fn main() { + let _ = into_iter(&[0].iter().map(|_| 0)).map(|grp| { + let _g = grp; + }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-42679.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-42679.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-42679.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-42679.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] +#![feature(box_patterns)] + +#[derive(Debug, PartialEq)] +enum Test { + Foo(usize), + Bar(isize), +} + +fn main() { + let a = box Test::Foo(10); + let b = box Test::Bar(-20); + match (a, b) { + (_, box Test::Foo(_)) => unreachable!(), + (box Test::Foo(x), b) => { + assert_eq!(x, 10); + assert_eq!(b, box Test::Bar(-20)); + }, + _ => unreachable!(), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-42747.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-42747.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-42747.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-42747.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,56 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +macro_rules! fooN { + ($cur:ident $prev:ty) => { + #[allow(dead_code)] + enum $cur { + Empty, + First($prev), + Second($prev), + Third($prev), + Fourth($prev), + } + } +} + +fooN!(Foo0 ()); +fooN!(Foo1 Foo0); +fooN!(Foo2 Foo1); +fooN!(Foo3 Foo2); +fooN!(Foo4 Foo3); +fooN!(Foo5 Foo4); +fooN!(Foo6 Foo5); +fooN!(Foo7 Foo6); +fooN!(Foo8 Foo7); +fooN!(Foo9 Foo8); +fooN!(Foo10 Foo9); +fooN!(Foo11 Foo10); +fooN!(Foo12 Foo11); +fooN!(Foo13 Foo12); +fooN!(Foo14 Foo13); +fooN!(Foo15 Foo14); +fooN!(Foo16 Foo15); +fooN!(Foo17 Foo16); +fooN!(Foo18 Foo17); +fooN!(Foo19 Foo18); +fooN!(Foo20 Foo19); +fooN!(Foo21 Foo20); +fooN!(Foo22 Foo21); +fooN!(Foo23 Foo22); +fooN!(Foo24 Foo23); +fooN!(Foo25 Foo24); +fooN!(Foo26 Foo25); +fooN!(Foo27 Foo26); + +fn main() { + let _foo = Foo27::Empty; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-43132.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-43132.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-43132.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-43132.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,75 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused)] + +fn main() { +} + +fn foo() { + let b = mk::< + Forward<(Box>,)>, + >(); + b.map_err(|_| ()).join(); +} + +fn mk() -> T { + loop {} +} + +impl, E> Future for (I,) { + type Error = E; +} + +struct Forward { + _a: T, +} + +impl Future for Forward +where + T::Error: From, +{ + type Error = T::Error; +} + +trait Future { + type Error; + + fn map_err(self, _: F) -> (Self, F) + where + F: FnOnce(Self::Error) -> E, + Self: Sized, + { + loop {} + } + + fn join(self) -> (MaybeDone, ()) + where + Self: Sized, + { + loop {} + } +} + +impl Future for Box { + type Error = S::Error; +} + +enum MaybeDone { + _Done(A::Error), +} + +impl Future for (A, F) +where + F: FnOnce(A::Error) -> U, +{ + type Error = U; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-43205.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-43205.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-43205.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-43205.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + &&[()][0]; + println!("{:?}", &[(),()][1]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-43291.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-43291.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-43291.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-43291.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn main() { + assert_eq!(!0usize as *const (), foo(0, 1)); + assert_eq!(!0usize as *const (), (0i8 - 1) as *const ()); +} + +pub fn foo(a: i8, b: i8) -> *const () { + (a - b) as *const () +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4333.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4333.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4333.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4333.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// pretty-expanded FIXME #23616 + +use std::io; + +pub fn main() { + let stdout = &mut io::stdout() as &mut io::Write; + stdout.write(b"Hello!"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-43692.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-43692.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-43692.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-43692.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + assert_eq!('\u{10__FFFF}', '\u{10FFFF}'); + assert_eq!("\u{10_F0FF__}foo\u{1_0_0_0__}", "\u{10F0FF}foo\u{1000}"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-43853.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-43853.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-43853.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-43853.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-wasm32-bare compiled with panic=abort by default + +use std::panic; + +fn test() { + wait(|| panic!()); +} + +fn wait T>(f: F) -> F::Output { + From::from(f()) +} + +fn main() { + let result = panic::catch_unwind(move || test()); + assert!(result.is_err()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4387.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4387.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4387.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4387.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +pub fn main() { + let _foo = [0; 2*4]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-43910.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-43910.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-43910.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-43910.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![deny(unused_variables)] + +fn main() { + #[allow(unused_variables)] + let x = 12; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-43923.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-43923.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-43923.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-43923.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +struct A { ptr: T } + +fn foo(x: &A<[T]>) {} + +fn main() { + let a = foo; + let b = A { ptr: [a, a, a] }; + a(&A { ptr: [()] }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4401.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4401.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4401.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4401.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn main() { + let mut count = 0; + for _ in 0..999_999 { count += 1; } + assert_eq!(count, 999_999); + println!("{}", count); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-44333.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-44333.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-44333.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-44333.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +type Func = fn(usize, usize) -> usize; + +fn foo(a: usize, b: usize) -> usize { a + b } +fn bar(a: usize, b: usize) -> usize { a * b } +fn test(x: usize) -> Func { + if x % 2 == 0 { foo } + else { bar } +} + +const FOO: Func = foo; +const BAR: Func = bar; + +fn main() { + match test(std::env::consts::ARCH.len()) { + FOO => println!("foo"), + BAR => println!("bar"), + _ => unreachable!(), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4446.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4446.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4446.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4446.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten no threads support + +use std::sync::mpsc::channel; +use std::thread; + +pub fn main() { + let (tx, rx) = channel(); + + tx.send("hello, world").unwrap(); + + thread::spawn(move|| { + println!("{}", rx.recv().unwrap()); + }).join().ok().unwrap(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4448.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4448.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4448.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4448.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten no threads support + +use std::sync::mpsc::channel; +use std::thread; + +pub fn main() { + let (tx, rx) = channel::<&'static str>(); + + let t = thread::spawn(move|| { + assert_eq!(rx.recv().unwrap(), "hello, world"); + }); + + tx.send("hello, world").unwrap(); + t.join().ok().unwrap(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-45124.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-45124.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-45124.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-45124.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unreachable_code)] +// compile-flags: --edition 2018 + +#![feature(try_blocks)] + +fn main() { + let mut a = 0; + let () = { + let _: Result<(), ()> = try { + let _ = Err(())?; + return + }; + a += 1; + }; + a += 2; + assert_eq!(a, 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-45152.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-45152.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-45152.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-45152.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +#![feature(unsize, coerce_unsized)] + +#[repr(packed)] +struct UnalignedPtr<'a, T: ?Sized> + where T: 'a, +{ + data: &'a T, +} + +fn main() { + + impl<'a, T, U> std::ops::CoerceUnsized> for UnalignedPtr<'a, T> + where + T: std::marker::Unsize + ?Sized, + U: ?Sized, + { } + + let arr = [1, 2, 3]; + let arr_unaligned: UnalignedPtr<[i32; 3]> = UnalignedPtr { data: &arr }; + let arr_unaligned: UnalignedPtr<[i32]> = arr_unaligned; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4541.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4541.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4541.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4541.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-cloudabi no std::env + +fn parse_args() -> String { + let args: Vec<_> = ::std::env::args().collect(); + let mut n = 0; + + while n < args.len() { + match &*args[n] { + "-v" => (), + s => { + return s.to_string(); + } + } + n += 1; + } + + return "".to_string() +} + +pub fn main() { + println!("{}", parse_args()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4542.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4542.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4542.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4542.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 +// ignore-cloudabi no std::env + +use std::env; + +pub fn main() { + for arg in env::args() { + match arg.clone() { + _s => { } + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4545.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4545.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4545.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4545.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-4545.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_4545 as somelib; +pub fn main() { somelib::mk::(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-45731.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-45731.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-45731.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-45731.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// compile-flags:--test -g + +#[cfg(target_os = "macos")] +#[test] +fn simple_test() { + use std::{env, panic, fs}; + + // Find our dSYM and replace the DWARF binary with an empty file + let mut dsym_path = env::current_exe().unwrap(); + let executable_name = dsym_path.file_name().unwrap().to_str().unwrap().to_string(); + assert!(dsym_path.pop()); // Pop executable + dsym_path.push(format!("{}.dSYM/Contents/Resources/DWARF/{0}", executable_name)); + { + let file = fs::OpenOptions::new().read(false).write(true).truncate(true).create(false) + .open(&dsym_path).unwrap(); + } + + env::set_var("RUST_BACKTRACE", "1"); + + // We don't need to die of panic, just trigger a backtrace + let _ = panic::catch_unwind(|| { + assert!(false); + }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-46069.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-46069.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-46069.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-46069.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::iter::{Fuse, Cloned}; +use std::slice::Iter; + +struct Foo<'a, T: 'a>(&'a T); +impl<'a, T: 'a> Copy for Foo<'a, T> {} +impl<'a, T: 'a> Clone for Foo<'a, T> { + fn clone(&self) -> Self { *self } +} + +fn copy_ex() { + let s = 2; + let k1 = || s; + let upvar = Foo(&k1); + let k = || upvar; + k(); +} + +fn main() { + let _f = 0 as *mut >> as Iterator>::Item; + + copy_ex(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-46095.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-46095.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-46095.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-46095.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct A; + +impl A { + fn take_mutably(&mut self) {} +} + +fn identity(t: T) -> T { + t +} + +// Issue 46095 +// Built-in indexing should be used even when the index is not +// trivially an integer +// Overloaded indexing would cause wrapped to be borrowed mutably + +fn main() { + let mut a1 = A; + let mut a2 = A; + + let wrapped = [&mut a1, &mut a2]; + + { + wrapped[0 + 1 - 1].take_mutably(); + } + + { + wrapped[identity(0)].take_mutably(); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-46519.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-46519.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-46519.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-46519.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags:--test -O + +#[test] +#[should_panic(expected = "creating inhabited type")] +fn test() { + FontLanguageOverride::system_font(SystemFont::new()); +} + +pub enum FontLanguageOverride { + Normal, + Override(&'static str), + System(SystemFont) +} + +pub enum SystemFont {} + +impl FontLanguageOverride { + fn system_font(f: SystemFont) -> Self { + FontLanguageOverride::System(f) + } +} + +impl SystemFont { + fn new() -> Self { + panic!("creating inhabited type") + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-46553.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-46553.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-46553.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-46553.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(const_fn)] +#![deny(const_err)] + +pub struct Data { + function: fn() -> T, +} + +impl Data { + pub const fn new(function: fn() -> T) -> Data { + Data { + function: function, + } + } +} + +pub static DATA: Data = Data::new(|| { + 413i32 +}); + +fn main() { + print!("{:?}", (DATA.function)()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-46845.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-46845.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-46845.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-46845.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// To work around #46855 +// compile-flags: -Z mir-opt-level=0 +// Regression test for the inhabitedness of unions with uninhabited variants, issue #46845 + +use std::mem; + +#[derive(Copy, Clone)] +enum Never { } + +// A single uninhabited variant shouldn't make the whole union uninhabited. +union Foo { + a: u64, + _b: Never +} + +// If all the variants are uninhabited, however, the union should be uninhabited. +// NOTE(#49298) the union being uninhabited shouldn't change its size. +union Bar { + _a: (Never, u64), + _b: (u64, Never) +} + +fn main() { + assert_eq!(mem::size_of::(), 8); + // See the note on `Bar`'s definition for why this isn't `0`. + assert_eq!(mem::size_of::(), 8); + + let f = [Foo { a: 42 }, Foo { a: 10 }]; + println!("{}", unsafe { f[0].a }); + assert_eq!(unsafe { f[1].a }, 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-46855.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-46855.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-46855.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-46855.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// compile-flags: -Zmir-opt-level=1 + +use std::mem; + +#[derive(Copy, Clone)] +enum Never {} + +union Foo { + a: u64, + b: Never +} + +fn foo(xs: [(Never, u32); 1]) -> u32 { xs[0].1 } + +fn bar([(_, x)]: [(Never, u32); 1]) -> u32 { x } + +fn main() { + println!("{}", mem::size_of::()); + + let f = [Foo { a: 42 }, Foo { a: 10 }]; + println!("{:?}", unsafe { f[0].a }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-46920-byte-array-patterns.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-46920-byte-array-patterns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-46920-byte-array-patterns.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-46920-byte-array-patterns.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +const CURSOR_PARTITION_LABEL: &'static [u8] = b"partition"; +const CURSOR_EVENT_TYPE_LABEL: &'static [u8] = b"event_type"; +const BYTE_PATTERN: &'static [u8; 5] = b"hello"; + +fn match_slice(x: &[u8]) -> u32 { + match x { + CURSOR_PARTITION_LABEL => 0, + CURSOR_EVENT_TYPE_LABEL => 1, + _ => 2, + } +} + +fn match_array(x: &[u8; 5]) -> bool { + match x { + BYTE_PATTERN => true, + _ => false + } +} + +fn main() { + assert_eq!(match_slice(b"abcde"), 2); + assert_eq!(match_slice(b"event_type"), 1); + assert_eq!(match_slice(b"partition"), 0); + + assert_eq!(match_array(b"hello"), true); + assert_eq!(match_array(b"hella"), false); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-47139-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-47139-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-47139-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-47139-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,88 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for issue #47139: +// +// Coherence was encountering an (unnecessary) overflow trying to +// decide if the two impls of dummy overlap. +// +// The overflow went something like: +// +// - `&'a ?T: Insertable` ? +// - let ?T = Option ? +// - `Option: Insertable` ? +// - `Option<&'a ?U>: Insertable` ? +// - `&'a ?U: Insertable` ? +// +// While somewhere in the middle, a projection would occur, which +// broke cycle detection. +// +// It turned out that this cycle was being kicked off due to some +// extended diagnostic attempts in coherence, so removing those +// sidestepped the issue for now. + +#![allow(dead_code)] + +pub trait Insertable { + type Values; + + fn values(self) -> Self::Values; +} + +impl Insertable for Option + where + T: Insertable, + T::Values: Default, +{ + type Values = T::Values; + + fn values(self) -> Self::Values { + self.map(Insertable::values).unwrap_or_default() + } +} + +impl<'a, T> Insertable for &'a Option + where + Option<&'a T>: Insertable, +{ + type Values = as Insertable>::Values; + + fn values(self) -> Self::Values { + self.as_ref().values() + } +} + +impl<'a, T> Insertable for &'a [T] +{ + type Values = Self; + + fn values(self) -> Self::Values { + self + } +} + +trait Unimplemented { } + +trait Dummy { } + +struct Foo { t: T } + +impl<'a, U> Dummy for Foo<&'a U> + where &'a U: Insertable +{ +} + +impl Dummy for T + where T: Unimplemented +{ } + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-47139-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-47139-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-47139-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-47139-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,76 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for issue #47139: +// +// Same as issue-47139-1.rs, but the impls of dummy are in the +// opposite order. This influenced the way that coherence ran and in +// some cases caused the overflow to occur when it wouldn't otherwise. +// In an effort to make the regr test more robust, I am including both +// orderings. + +#![allow(dead_code)] + +pub trait Insertable { + type Values; + + fn values(self) -> Self::Values; +} + +impl Insertable for Option + where + T: Insertable, + T::Values: Default, +{ + type Values = T::Values; + + fn values(self) -> Self::Values { + self.map(Insertable::values).unwrap_or_default() + } +} + +impl<'a, T> Insertable for &'a Option + where + Option<&'a T>: Insertable, +{ + type Values = as Insertable>::Values; + + fn values(self) -> Self::Values { + self.as_ref().values() + } +} + +impl<'a, T> Insertable for &'a [T] +{ + type Values = Self; + + fn values(self) -> Self::Values { + self + } +} + +trait Unimplemented { } + +trait Dummy { } + +struct Foo { t: T } + +impl Dummy for T + where T: Unimplemented +{ } + +impl<'a, U> Dummy for Foo<&'a U> + where &'a U: Insertable +{ +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4734.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4734.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4734.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4734.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Ensures that destructors are run for expressions of the form "e;" where +// `e` is a type which requires a destructor. + + +#![allow(path_statements)] + +struct A { n: isize } +struct B; + +static mut NUM_DROPS: usize = 0; + +impl Drop for A { + fn drop(&mut self) { + unsafe { NUM_DROPS += 1; } + } +} + +impl Drop for B { + fn drop(&mut self) { + unsafe { NUM_DROPS += 1; } + } +} + +fn main() { + assert_eq!(unsafe { NUM_DROPS }, 0); + { let _a = A { n: 1 }; } + assert_eq!(unsafe { NUM_DROPS }, 1); + { A { n: 3 }; } + assert_eq!(unsafe { NUM_DROPS }, 2); + + { let _b = B; } + assert_eq!(unsafe { NUM_DROPS }, 3); + { B; } + assert_eq!(unsafe { NUM_DROPS }, 4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4735.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4735.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4735.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4735.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +use std::mem::transmute; + +struct NonCopyable(*const u8); + +impl Drop for NonCopyable { + fn drop(&mut self) { + let NonCopyable(p) = *self; + let _v = unsafe { transmute::<*const u8, Box>(p) }; + } +} + +pub fn main() { + let t = Box::new(0); + let p = unsafe { transmute::, *const u8>(t) }; + let _z = NonCopyable(p); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-47364.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-47364.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-47364.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-47364.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,69 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// compile-flags: -C codegen-units=8 -O +#![allow(non_snake_case)] + +fn main() { + nom_sql::selection(b"x "); +} + +pub enum Err

{ + Position(P), + NodePosition(u32), +} + +pub enum IResult { + Done(I,O), + Error(Err), + Incomplete(u32, u64) +} + +pub fn multispace(input: T) -> ::IResult { + ::IResult::Done(0, 0) +} + +mod nom_sql { + fn where_clause(i: &[u8]) -> ::IResult<&[u8], Option> { + let X = match ::multispace(i) { + ::IResult::Done(..) => ::IResult::Done(i, None::), + _ => ::IResult::Error(::Err::NodePosition(0)), + }; + match X { + ::IResult::Done(_, _) => ::IResult::Done(i, None), + _ => X + } + } + + pub fn selection(i: &[u8]) { + let Y = match { + match { + where_clause(i) + } { + ::IResult::Done(_, o) => ::IResult::Done(i, Some(o)), + ::IResult::Error(_) => ::IResult::Done(i, None), + _ => ::IResult::Incomplete(0, 0), + } + } { + ::IResult::Done(z, _) => ::IResult::Done(z, None::), + _ => return () + }; + match Y { + ::IResult::Done(x, _) => { + let bytes = b"; "; + let len = x.len(); + bytes[len]; + } + _ => () + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4759-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4759-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4759-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4759-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait U { fn f(self); } +impl U for isize { fn f(self) {} } +pub fn main() { 4.f(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4759.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4759.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4759.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4759.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 +#![allow(non_shorthand_field_patterns)] + +#![feature(box_syntax)] + +struct T { a: Box } + +trait U { + fn f(self); +} + +impl U for Box { + fn f(self) { } +} + +pub fn main() { + let T { a: a } = T { a: box 0 }; + a.f(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-47638.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-47638.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-47638.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-47638.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +fn id<'c, 'b>(f: &'c &'b Fn(&i32)) -> &'c &'b Fn(&'static i32) { + f +} + +fn main() { + let f: &Fn(&i32) = &|x| {}; + id(&f); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-48159.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-48159.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-48159.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-48159.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(repr_packed)] +#![allow(non_camel_case_types)] + +use std::mem; + +pub enum c_void {} + +type uintptr_t = usize; +type int16_t = u16; +type uint16_t = int16_t; +type uint32_t = u32; +type intptr_t = uintptr_t; + +#[repr(C)] +#[repr(packed(4))] +pub struct kevent { + pub ident: uintptr_t, + pub filter: int16_t, + pub flags: uint16_t, + pub fflags: uint32_t, + pub data: intptr_t, + pub udata: *mut c_void, +} + +fn main() { + assert_eq!(mem::align_of::(), 4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-48508-aux.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-48508-aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-48508-aux.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-48508-aux.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-test Not a test. Used by issue-48508.rs + +pub fn other() -> f64 { + let µ = 1.0; + µ +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-48508.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-48508.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-48508.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-48508.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for issue #48508: +// +// Confusion between global and local file offsets caused incorrect handling of multibyte character +// spans when compiling multiple files. One visible effect was an ICE generating debug information +// when a multibyte character is at the end of a scope. The problematic code is actually in +// issue-48508-aux.rs + +// compile-flags:-g +// ignore-pretty issue #37195 + +#![feature(non_ascii_idents)] + +#[path = "issue-48508-aux.rs"] +mod other_file; + +fn main() { + other_file::other(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4865-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4865-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4865-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4865-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +// This should resolve fine. +// Prior to fix, the crossed imports between a and b +// would block on the glob import, itself never being resolved +// because these previous imports were not resolved. + +pub mod a { + use b::fn_b; + use c::*; + + pub fn fn_a(){ + } +} + +pub mod b { + use a::fn_a; + use c::*; + + pub fn fn_b(){ + } +} + +pub mod c{ + pub fn fn_c(){ + } +} + +use a::fn_a; +use b::fn_b; + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4865-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4865-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4865-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4865-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Previously, this would have failed to resolve due to the circular +// block between `use say` and `pub use hello::*`. +// +// Now, as `use say` is not `pub`, the glob import can resolve +// without any problem and this resolves fine. + +pub use hello::*; + +pub mod say { + pub fn hello() { println!("hello"); } +} + +pub mod hello { + use say; + + pub fn hello() { + say::hello(); + } +} + +fn main() { + hello(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4865-3.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4865-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4865-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4865-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +// This should resolve fine even with the circular imports as +// they are not `pub`. + +pub mod a { + use b::*; +} + +pub mod b { + use a::*; +} + +use a::*; + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4875.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4875.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-4875.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-4875.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// regression test for issue 4875 + +// pretty-expanded FIXME #23616 + +pub struct Foo { + data: T, +} + +fn foo(Foo{..}: Foo) { +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-48962.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-48962.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-48962.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-48962.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// Test that we are able to reinitialize box with moved referent +#![feature(nll)] +static mut ORDER: [usize; 3] = [0, 0, 0]; +static mut INDEX: usize = 0; + +struct Dropee (usize); + +impl Drop for Dropee { + fn drop(&mut self) { + unsafe { + ORDER[INDEX] = self.0; + INDEX = INDEX + 1; + } + } +} + +fn add_sentintel() { + unsafe { + ORDER[INDEX] = 2; + INDEX = INDEX + 1; + } +} + +fn main() { + let mut x = Box::new(Dropee(1)); + *x; // move out from `*x` + add_sentintel(); + *x = Dropee(3); // re-initialize `*x` + {x}; // drop value + unsafe { + assert_eq!(ORDER, [1, 2, 3]); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-48984.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-48984.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-48984.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-48984.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// aux-build:issue-48984-aux.rs +extern crate issue48984aux; +use issue48984aux::Bar; + +fn do_thing() { } + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-49298.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-49298.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-49298.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-49298.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,52 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(test)] +#![allow(unused_mut)] // under NLL we get warning about `x` below: rust-lang/rust#54499 + +// This test is bogus (i.e. should be compile-fail) during the period +// where #54986 is implemented and #54987 is *not* implemented. For +// now: just ignore it under nll +// +// ignore-compare-mode-nll + +// This test is checking that the space allocated for `x.1` does not +// overlap with `y`. (The reason why such a thing happened at one +// point was because `x.0: Void` and thus the whole type of `x` was +// uninhabited, and so the compiler thought it was safe to use the +// space of `x.1` to hold `y`.) +// +// That's a fine thing to test when this code is accepted by the +// compiler, and this code is being transcribed accordingly into +// the ui test issue-21232-partial-init-and-use.rs + +extern crate test; + +enum Void {} + +fn main() { + let mut x: (Void, usize); + let mut y = 42; + x.1 = 13; + + // Make sure `y` stays on the stack. + test::black_box(&mut y); + + // Check that the write to `x.1` did not overwrite `y`. + // Note that this doesn't fail with optimizations enabled, + // because we can't keep `x.1` on the stack, like we can `y`, + // as we can't borrow partially initialized variables. + assert_eq!(y.to_string(), "42"); + + // Check that `(Void, usize)` has space for the `usize` field. + assert_eq!(std::mem::size_of::<(Void, usize)>(), + std::mem::size_of::()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-49556.stderr rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-49556.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-49556.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-49556.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -warning: function is never used: `iter` - --> $DIR/issue-49556.rs:12:1 - | -LL | fn iter<'a>(data: &'a [usize]) -> impl Iterator + 'a { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: #[warn(dead_code)] on by default - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-49588-non-shorthand-field-patterns-in-pattern-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-49588-non-shorthand-field-patterns-in-pattern-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-49588-non-shorthand-field-patterns-in-pattern-macro.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-49588-non-shorthand-field-patterns-in-pattern-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +#![deny(non_shorthand_field_patterns)] + +pub struct Value { pub value: A } + +#[macro_export] +macro_rules! pat { + ($a:pat) => { + Value { value: $a } + }; +} + +fn main() { + let pat!(value) = Value { value: () }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-49632.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-49632.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-49632.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-49632.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(stmt_expr_attributes)] + +pub fn main() { + let _x = #[inline(always)] || {}; + let _y = #[inline(never)] || {}; + let _z = #[inline] || {}; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-49685.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-49685.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-49685.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-49685.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for #49685: drop elaboration was not revealing the +// value of `impl Trait` returns, leading to an ICE. + +fn main() { + let _ = Some(()) + .into_iter() + .flat_map(|_| Some(()).into_iter().flat_map(func)); +} + +fn func(_: ()) -> impl Iterator { + Some(()).into_iter().flat_map(|_| vec![]) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-49854.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-49854.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-49854.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-49854.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::ffi::OsString; + +fn main() { + let os_str = OsString::from("Hello Rust!"); + + assert_eq!(os_str, "Hello Rust!"); + assert_eq!("Hello Rust!", os_str); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-49955-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-49955-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-49955-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-49955-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags: -Z borrowck=mir + +use std::cell::Cell; + +const FIVE: Cell = Cell::new(5); + +#[inline(never)] +fn tuple_field() -> &'static u32 { + // This test is MIR-borrowck-only because the old borrowck + // doesn't agree that borrows of "frozen" (i.e. without any + // interior mutability) fields of non-frozen temporaries, + // should be promoted, while MIR promotion does promote them. + &(FIVE, 42).1 +} + +fn main() { + assert_eq!(tuple_field().to_string(), "42"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-49955.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-49955.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-49955.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-49955.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags: -Z borrowck=compare + +const ALL_THE_NUMS: [u32; 1] = [ + 1 +]; + +#[inline(never)] +fn array(i: usize) -> &'static u32 { + return &ALL_THE_NUMS[i]; +} + +#[inline(never)] +fn tuple_field() -> &'static u32 { + &(42,).0 +} + +fn main() { + assert_eq!(tuple_field().to_string(), "42"); + assert_eq!(array(0).to_string(), "1"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-49973.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-49973.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-49973.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-49973.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(Debug)] +#[repr(i32)] +enum E { + Min = -2147483648i32, + _Max = 2147483647i32, +} + +fn main() { + assert_eq!(Some(E::Min).unwrap() as i32, -2147483648i32); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5008-borrowed-traitobject-method-call.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5008-borrowed-traitobject-method-call.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5008-borrowed-traitobject-method-call.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5008-borrowed-traitobject-method-call.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +/* + +#5008 cast to &Trait causes code to segfault on method call + +It fixes itself if the &Trait is changed to @Trait. +*/ + +trait Debuggable { + fn debug_name(&self) -> String; +} + +#[derive(Clone)] +struct Thing { + name: String, +} + +impl Thing { + fn new() -> Thing { Thing { name: "dummy".to_string() } } +} + +impl Debuggable for Thing { + fn debug_name(&self) -> String { self.name.clone() } +} + +fn print_name(x: &Debuggable) +{ + println!("debug_name = {}", x.debug_name()); +} + +pub fn main() { + let thing = Thing::new(); + print_name(&thing as &Debuggable); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-50415.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-50415.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-50415.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-50415.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + // -------- Simplified test case -------- + + let _ = || 0..=1; + + // -------- Original test case -------- + + let full_length = 1024; + let range = { + // do some stuff, omit here + None + }; + + let range = range.map(|(s, t)| s..=t).unwrap_or(0..=(full_length-1)); + + assert_eq!(range, 0..=1023); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-50442.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-50442.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-50442.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-50442.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +enum Void {} + +enum Foo { + A(i32), + B(Void), + C(i32) +} + +fn main() { + let _foo = Foo::A(0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5060.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5060.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5060.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5060.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +macro_rules! print_hd_tl { + ($field_hd:ident, $($field_tl:ident),+) => ({ + print!("{}", stringify!($field_hd)); + print!("::["); + $( + print!("{}", stringify!($field_tl)); + print!(", "); + )+ + print!("]\n"); + }) +} + +pub fn main() { + print_hd_tl!(x, y, z, w) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-50689.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-50689.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-50689.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-50689.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +enum Foo { + Bar = (|x: i32| { }, 42).1, +} + +fn main() { + assert_eq!(Foo::Bar as usize, 42); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-50731.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-50731.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-50731.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-50731.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +enum Void {} +fn foo(_: Result<(Void, u32), (Void, String)>) {} +fn main() { + let _: fn(_) = foo; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-50811.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-50811.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-50811.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-50811.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,66 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(test)] + +extern crate test; + +use std::f64::{NAN, NEG_INFINITY, INFINITY, MAX}; +use std::mem::size_of; +use test::black_box; + +// Ensure the const-eval result and runtime result of float comparison are equivalent. + +macro_rules! compare { + ($op:tt) => { + compare!( + [NEG_INFINITY, -MAX, -1.0, -0.0, 0.0, 1.0, MAX, INFINITY, NAN], + $op + ); + }; + ([$($lhs:expr),+], $op:tt) => { + $(compare!( + $lhs, + $op, + [NEG_INFINITY, -MAX, -1.0, -0.0, 0.0, 1.0, MAX, INFINITY, NAN] + );)+ + }; + ($lhs:expr, $op:tt, [$($rhs:expr),+]) => { + $({ + // Wrap the check in its own function to reduce time needed to borrowck. + fn check() { + static CONST_EVAL: bool = $lhs $op $rhs; + let runtime_eval = black_box($lhs) $op black_box($rhs); + assert_eq!(CONST_EVAL, runtime_eval, stringify!($lhs $op $rhs)); + assert_eq!( + size_of::<[u8; ($lhs $op $rhs) as usize]>(), + runtime_eval as usize, + stringify!($lhs $op $rhs (forced const eval)) + ); + } + check(); + })+ + }; +} + +fn main() { + assert_eq!(0.0/0.0 < 0.0/0.0, false); + assert_eq!(0.0/0.0 > 0.0/0.0, false); + assert_eq!(NAN < NAN, false); + assert_eq!(NAN > NAN, false); + + compare!(==); + compare!(!=); + compare!(<); + compare!(<=); + compare!(>); + compare!(>=); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-50865-private-impl-trait/auxiliary/lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-50865-private-impl-trait/auxiliary/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-50865-private-impl-trait/auxiliary/lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-50865-private-impl-trait/auxiliary/lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +pub fn bar

( // Error won't happen if "bar" is not generic + _baz: P, +) { + hide_foo()(); +} + +fn hide_foo() -> impl Fn() { // Error won't happen if "iterate" hasn't impl Trait or has generics + foo +} + +fn foo() { // Error won't happen if "foo" isn't used in "iterate" or has generics +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-50865-private-impl-trait/main.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-50865-private-impl-trait/main.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-50865-private-impl-trait/main.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-50865-private-impl-trait/main.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:lib.rs + +// Regression test for #50865. +// When using generics or specifying the type directly, this example +// codegens `foo` internally. However, when using a private `impl Trait` +// function which references another private item, `foo` (in this case) +// wouldn't be codegenned until main.rs used `bar`, as with impl Trait +// it is not cast to `fn()` automatically to satisfy e.g. +// `fn foo() -> fn() { ... }`. + +extern crate lib; + +fn main() { + lib::bar(()); // Error won't happen if bar is called from same crate +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-51185.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-51185.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-51185.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-51185.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn foo() -> impl Into fn(&'a ())> { + (|_| {}) as for<'a> fn(&'a ()) +} + +fn main() { + foo().into()(&()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-51345.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-51345.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-51345.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-51345.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unreachable_code)] +#![feature(nll)] + +fn main() { + let mut v = Vec::new(); + + loop { v.push(break) } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-51582.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-51582.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-51582.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-51582.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(core_intrinsics)] + +#[repr(i8)] +pub enum Enum { + VariantA, + VariantB, +} + +fn make_b() -> Enum { Enum::VariantB } + +fn main() { + assert_eq!(1, make_b() as i8); + assert_eq!(1, make_b() as u8); + assert_eq!(1, make_b() as i32); + assert_eq!(1, make_b() as u32); + assert_eq!(1, unsafe { std::intrinsics::discriminant_value(&make_b()) }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-51907.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-51907.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-51907.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-51907.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait Foo { + extern fn borrow(&self); + extern fn take(self: Box); +} + +struct Bar; +impl Foo for Bar { + extern fn borrow(&self) {} + extern fn take(self: Box) {} +} + +fn main() { + let foo: Box = Box::new(Bar); + foo.borrow(); + foo.take() +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5192.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5192.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5192.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5192.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,51 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + +pub trait EventLoop { + fn dummy(&self) { } +} + +pub struct UvEventLoop { + uvio: isize +} + +impl UvEventLoop { + pub fn new() -> UvEventLoop { + UvEventLoop { + uvio: 0 + } + } +} + +impl EventLoop for UvEventLoop { +} + +pub struct Scheduler { + event_loop: Box, +} + +impl Scheduler { + + pub fn new(event_loop: Box) -> Scheduler { + Scheduler { + event_loop: event_loop, + } + } +} + +pub fn main() { + let _sched = Scheduler::new(box UvEventLoop::new() as Box); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-52140/auxiliary/some_crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-52140/auxiliary/some_crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-52140/auxiliary/some_crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-52140/auxiliary/some_crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +pub fn hello() { + println!("Hello, world!"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-52140/main.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-52140/main.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-52140/main.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-52140/main.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:some_crate.rs +// compile-flags:--extern some_crate +// edition:2018 + +mod foo { + pub use some_crate; +} + +fn main() { + ::some_crate::hello(); + foo::some_crate::hello(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-52141/auxiliary/some_crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-52141/auxiliary/some_crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-52141/auxiliary/some_crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-52141/auxiliary/some_crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +pub fn hello() { + println!("Hello, world!"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-52141/main.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-52141/main.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-52141/main.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-52141/main.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:some_crate.rs +// compile-flags:--extern some_crate +// edition:2018 + +use some_crate as some_name; + +mod foo { + pub use crate::some_name::*; +} + +fn main() { + ::some_crate::hello(); + some_name::hello(); + foo::hello(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-52169.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-52169.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-52169.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-52169.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(macro_literal_matcher)] + +macro_rules! a { + ($i:literal) => { "right" }; + ($i:tt) => { "wrong" }; +} + +macro_rules! b { + ($i:literal) => { a!($i) }; +} + +fn main() { + assert_eq!(b!(0), "right"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5239-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5239-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5239-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5239-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for issue #5239 + + +pub fn main() { + let _f = |ref x: isize| { *x }; + let foo = 10; + assert_eq!(_f(foo), 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5243.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5243.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5243.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5243.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Check that merely having lifetime parameters is not +// enough for codegen to consider this as non-monomorphic, +// which led to various assertions and failures in turn. + +// pretty-expanded FIXME #23616 + +struct S<'a> { + v: &'a isize +} + +fn f<'lt>(_s: &'lt S<'lt>) {} + +pub fn main() { + f(& S { v: &42 }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-52557.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-52557.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-52557.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-52557.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +// This test checks for namespace pollution by private tests. +// Tests used to marked as public causing name conflicts with normal +// functions only in test builds. + +// compile-flags: --test + +mod a { + pub fn foo() -> bool { + true + } +} + +mod b { + #[test] + fn foo() { + local_name(); // ensure the local name still works + } + + #[test] + fn local_name() {} +} + +use a::*; +use b::*; + +pub fn conflict() { + let _: bool = foo(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-52705/auxiliary/png2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-52705/auxiliary/png2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-52705/auxiliary/png2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-52705/auxiliary/png2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +pub struct DecodingError; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-52705/main.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-52705/main.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-52705/main.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-52705/main.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// aux-build:png2.rs +// compile-flags:--extern png2 +// edition:2018 + +mod png { + use png2 as png_ext; + + fn foo() -> png_ext::DecodingError { unimplemented!() } +} + +fn main() { + println!("Hello, world!"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5280.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5280.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5280.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5280.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +type FontTableTag = u32; + +trait FontTableTagConversions { + fn tag_to_string(self); +} + +impl FontTableTagConversions for FontTableTag { + fn tag_to_string(self) { + &self; + } +} + +pub fn main() { + 5.tag_to_string(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5315.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5315.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5315.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5315.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +struct A(bool); + +pub fn main() { + let f = A; + f(true); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5321-immediates-with-bare-self.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5321-immediates-with-bare-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5321-immediates-with-bare-self.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5321-immediates-with-bare-self.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +trait Fooable { + fn yes(self); +} + +impl Fooable for usize { + fn yes(self) { + for _ in 0..self { println!("yes"); } + } +} + +pub fn main() { + 2.yes(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-53333.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-53333.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-53333.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-53333.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +// edition:2018 + +fn main() { + use std; + let std = "std"; + println!("{}", std); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-54696.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-54696.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-54696.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-54696.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +// run-pass + +fn main() { + // We shouldn't promote this + &(main as fn() == main as fn()); + // Also check nested case + &(&(main as fn()) == &(main as fn())); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5518.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5518.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5518.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5518.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-5518.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_5518 as other; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5521.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5521.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5521.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5521.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// aux-build:issue-5521.rs + + + +extern crate issue_5521 as foo; + +fn bar(a: foo::map) { + if false { + panic!(); + } else { + let _b = &(*a)[&2]; + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5530.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5530.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5530.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5530.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,50 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +enum Enum { + Foo { foo: usize }, + Bar { bar: usize } +} + +fn fun1(e1: &Enum, e2: &Enum) -> usize { + match (e1, e2) { + (&Enum::Foo { foo: _ }, &Enum::Foo { foo: _ }) => 0, + (&Enum::Foo { foo: _ }, &Enum::Bar { bar: _ }) => 1, + (&Enum::Bar { bar: _ }, &Enum::Bar { bar: _ }) => 2, + (&Enum::Bar { bar: _ }, &Enum::Foo { foo: _ }) => 3, + } +} + +fn fun2(e1: &Enum, e2: &Enum) -> usize { + match (e1, e2) { + (&Enum::Foo { foo: _ }, &Enum::Foo { foo: _ }) => 0, + (&Enum::Foo { foo: _ }, _ ) => 1, + (&Enum::Bar { bar: _ }, &Enum::Bar { bar: _ }) => 2, + (&Enum::Bar { bar: _ }, _ ) => 3, + } +} + +pub fn main() { + let foo = Enum::Foo { foo: 1 }; + let bar = Enum::Bar { bar: 1 }; + + assert_eq!(fun1(&foo, &foo), 0); + assert_eq!(fun1(&foo, &bar), 1); + assert_eq!(fun1(&bar, &bar), 2); + assert_eq!(fun1(&bar, &foo), 3); + + assert_eq!(fun2(&foo, &foo), 0); + assert_eq!(fun2(&foo, &bar), 1); // fun2 returns 0 + assert_eq!(fun2(&bar, &bar), 2); + assert_eq!(fun2(&bar, &foo), 3); // fun2 returns 2 +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5550.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5550.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5550.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5550.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_assignments)] +// pretty-expanded FIXME #23616 + +pub fn main() { + let s: String = "foobar".to_string(); + let mut t: &str = &s; + t = &t[0..3]; // for master: str::view(t, 0, 3) maybe +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5554.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5554.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5554.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5554.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +use std::default::Default; + +pub struct X { + a: T, +} + +// reordering these bounds stops the ICE +// +// nmatsakis: This test used to have the bounds Default + PartialEq + +// Default, but having duplicate bounds became illegal. +impl Default for X { + fn default() -> X { + X { a: Default::default() } + } +} + +macro_rules! constants { + () => { + let _ : X = Default::default(); + } +} + +pub fn main() { + constants!(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5666.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5666.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5666.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5666.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +struct Dog { + name : String +} + +trait Barks { + fn bark(&self) -> String; +} + +impl Barks for Dog { + fn bark(&self) -> String { + return format!("woof! (I'm {})", self.name); + } +} + + +pub fn main() { + let snoopy = box Dog{name: "snoopy".to_string()}; + let bubbles = box Dog{name: "bubbles".to_string()}; + let barker = [snoopy as Box, bubbles as Box]; + + for pup in &barker { + println!("{}", pup.bark()); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5688.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5688.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5688.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5688.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +/* +# Corrupted initialization in the static struct + +...should print &[1, 2, 3] but instead prints something like +&[4492532864, 24]. It is pretty evident that the compiler messed up +with the representation of [isize; n] and [isize] somehow, or at least +failed to typecheck correctly. +*/ + +#[derive(Copy, Clone)] +struct X { vec: &'static [isize] } + +static V: &'static [X] = &[X { vec: &[1, 2, 3] }]; + +pub fn main() { + for &v in V { + println!("{:?}", v.vec); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5708.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5708.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5708.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5708.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,65 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +/* +# ICE when returning struct with reference to trait + +A function which takes a reference to a trait and returns a +struct with that reference results in an ICE. + +This does not occur with concrete types, only with references +to traits. +*/ + + +// original +trait Inner { + fn print(&self); +} + +impl Inner for isize { + fn print(&self) { print!("Inner: {}\n", *self); } +} + +struct Outer<'a> { + inner: &'a (Inner+'a) +} + +impl<'a> Outer<'a> { + fn new(inner: &Inner) -> Outer { + Outer { + inner: inner + } + } +} + +pub fn main() { + let inner: isize = 5; + let outer = Outer::new(&inner as &Inner); + outer.inner.print(); +} + + +// minimal +pub trait MyTrait { + fn dummy(&self, t: T) -> T { panic!() } +} + +pub struct MyContainer<'a, T:'a> { + foos: Vec<&'a (MyTrait+'a)> , +} + +impl<'a, T> MyContainer<'a, T> { + pub fn add (&mut self, foo: &'a MyTrait) { + self.foos.push(foo); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5718.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5718.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5718.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5718.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + +struct Element; + +macro_rules! foo { + ($tag: expr, $string: expr) => { + if $tag == $string { + let element: Box<_> = box Element; + unsafe { + return std::mem::transmute::<_, usize>(element); + } + } + } +} + +fn bar() -> usize { + foo!("a", "b"); + 0 +} + +fn main() { + bar(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5741.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5741.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5741.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5741.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 +#![allow(while_true)] +#![allow(unreachable_code)] + +pub fn main() { + return; + while true {}; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5791.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5791.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5791.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5791.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +extern { + #[link_name = "malloc"] + fn malloc1(len: i32) -> *const u8; + #[link_name = "malloc"] + fn malloc2(len: i32, foo: i32) -> *const u8; +} + +pub fn main () {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5917.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5917.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5917.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5917.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_upper_case_globals)] + +struct T (&'static [isize]); +static t : T = T (&[5, 4, 3]); +pub fn main () { + let T(ref v) = t; + assert_eq!(v[0], 5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5988.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5988.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5988.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5988.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +trait B { + fn f(&self); +} + +trait T : B { +} + +struct A; + +impl B for U { + fn f(&self) { } +} + +impl T for A { +} + +fn main() { + let a = A; + let br = &a as &B; + br.f(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5997.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5997.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-5997.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-5997.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +fn f() -> bool { + enum E { V(T) } + + struct S(T); + + true +} + +fn main() { + let b = f::(); + assert!(b); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6117.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6117.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6117.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6117.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +enum Either { Left(T), Right(U) } + +pub fn main() { + match Either::Left(Box::new(17)) { + Either::Right(()) => {} + _ => {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6128.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6128.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6128.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6128.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(box_syntax)] + +use std::collections::HashMap; + +trait Graph { + fn f(&self, _: Edge); + fn g(&self, _: Node); +} + +impl Graph for HashMap { + fn f(&self, _e: E) { + panic!(); + } + fn g(&self, _e: isize) { + panic!(); + } +} + +pub fn main() { + let g : Box> = box HashMap::new(); + let _g2 : Box> = g as Box>; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6130.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6130.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6130.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6130.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + let i: usize = 0; + assert!(i <= 0xFFFF_FFFF); + + let i: isize = 0; + assert!(i >= -0x8000_0000); + assert!(i <= 0x7FFF_FFFF); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6153.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6153.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6153.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6153.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +fn swap(f: F) -> Vec where F: FnOnce(Vec) -> Vec { + let x = vec![1, 2, 3]; + f(x) +} + +pub fn main() { + let v = swap(|mut x| { x.push(4); x }); + let w = swap(|mut x| { x.push(4); x }); + assert_eq!(v, w); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6157.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6157.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6157.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6157.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +pub trait OpInt { fn call(&mut self, _: isize, _: isize) -> isize; } + +impl OpInt for F where F: FnMut(isize, isize) -> isize { + fn call(&mut self, a:isize, b:isize) -> isize { + (*self)(a, b) + } +} + +fn squarei<'a>(x: isize, op: &'a mut OpInt) -> isize { op.call(x, x) } + +fn muli(x:isize, y:isize) -> isize { x * y } + +pub fn main() { + let mut f = |x, y| muli(x, y); + { + let g = &mut f; + let h = g as &mut OpInt; + squarei(3, h); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6318.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6318.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6318.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6318.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + +pub enum Thing { + A(Box) +} + +pub trait Foo { + fn dummy(&self) { } +} + +pub struct Struct; + +impl Foo for Struct {} + +pub fn main() { + match Thing::A(box Struct as Box) { + Thing::A(_a) => 0, + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6334.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6334.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6334.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6334.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,56 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests that everything still compiles and runs fine even when +// we reorder the bounds. + + +trait A { + fn a(&self) -> usize; +} + +trait B { + fn b(&self) -> usize; +} + +trait C { + fn combine(&self, t: &T) -> usize; +} + +struct Foo; + +impl A for Foo { + fn a(&self) -> usize { 1 } +} + +impl B for Foo { + fn b(&self) -> usize { 2 } +} + +struct Bar; + +impl C for Bar { + // Note below: bounds in impl decl are in reverse order. + fn combine(&self, t: &T) -> usize { + (t.a() * 100) + t.b() + } +} + +fn use_c(s: &S, t: &T) -> usize { + s.combine(t) +} + +pub fn main() { + let foo = Foo; + let bar = Bar; + let r = use_c(&bar, &foo); + assert_eq!(r, 102); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6344-let.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6344-let.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6344-let.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6344-let.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_shorthand_field_patterns)] + +struct A { x: usize } + +impl Drop for A { + fn drop(&mut self) {} +} + +pub fn main() { + let a = A { x: 0 }; + + let A { x: ref x } = a; + println!("{}", x) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6344-match.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6344-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6344-match.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6344-match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_shorthand_field_patterns)] + +struct A { x: usize } + +impl Drop for A { + fn drop(&mut self) {} +} + +pub fn main() { + let a = A { x: 0 }; + + match a { + A { x : ref x } => { + println!("{}", x) + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6449.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6449.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6449.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6449.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,54 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +enum Foo { + Bar(isize), + Baz, +} + +enum Other { + Other1(Foo), + Other2(Foo, Foo), +} + +fn main() { + match Foo::Baz { + ::Foo::Bar(3) => panic!(), + ::Foo::Bar(_) if false => panic!(), + ::Foo::Bar(..) if false => panic!(), + ::Foo::Bar(_n) => panic!(), + ::Foo::Baz => {} + } + match Foo::Bar(3) { + ::Foo::Bar(3) => {} + ::Foo::Bar(_) if false => panic!(), + ::Foo::Bar(..) if false => panic!(), + ::Foo::Bar(_n) => panic!(), + ::Foo::Baz => panic!(), + } + match Foo::Bar(4) { + ::Foo::Bar(3) => panic!(), + ::Foo::Bar(_) if false => panic!(), + ::Foo::Bar(..) if false => panic!(), + ::Foo::Bar(n) => assert_eq!(n, 4), + ::Foo::Baz => panic!(), + } + + match Other::Other1(Foo::Baz) { + ::Other::Other1(::Foo::Baz) => {} + ::Other::Other1(::Foo::Bar(_)) => {} + ::Other::Other2(::Foo::Baz, ::Foo::Bar(_)) => {} + ::Other::Other2(::Foo::Bar(..), ::Foo::Baz) => {} + ::Other::Other2(..) => {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6892.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6892.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6892.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6892.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,68 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Ensures that destructors are run for expressions of the form "let _ = e;" +// where `e` is a type which requires a destructor. + + +struct Foo; +struct Bar { x: isize } +struct Baz(isize); +enum FooBar { _Foo(Foo), _Bar(usize) } + +static mut NUM_DROPS: usize = 0; + +impl Drop for Foo { + fn drop(&mut self) { + unsafe { NUM_DROPS += 1; } + } +} +impl Drop for Bar { + fn drop(&mut self) { + unsafe { NUM_DROPS += 1; } + } +} +impl Drop for Baz { + fn drop(&mut self) { + unsafe { NUM_DROPS += 1; } + } +} +impl Drop for FooBar { + fn drop(&mut self) { + unsafe { NUM_DROPS += 1; } + } +} + +fn main() { + assert_eq!(unsafe { NUM_DROPS }, 0); + { let _x = Foo; } + assert_eq!(unsafe { NUM_DROPS }, 1); + { let _x = Bar { x: 21 }; } + assert_eq!(unsafe { NUM_DROPS }, 2); + { let _x = Baz(21); } + assert_eq!(unsafe { NUM_DROPS }, 3); + { let _x = FooBar::_Foo(Foo); } + assert_eq!(unsafe { NUM_DROPS }, 5); + { let _x = FooBar::_Bar(42); } + assert_eq!(unsafe { NUM_DROPS }, 6); + + { let _ = Foo; } + assert_eq!(unsafe { NUM_DROPS }, 7); + { let _ = Bar { x: 21 }; } + assert_eq!(unsafe { NUM_DROPS }, 8); + { let _ = Baz(21); } + assert_eq!(unsafe { NUM_DROPS }, 9); + { let _ = FooBar::_Foo(Foo); } + assert_eq!(unsafe { NUM_DROPS }, 11); + { let _ = FooBar::_Bar(42); } + assert_eq!(unsafe { NUM_DROPS }, 12); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6919.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6919.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-6919.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-6919.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_attributes)] +// aux-build:iss.rs + +// pretty-expanded FIXME #23616 + +#![crate_id="issue-6919"] +extern crate issue6919_3; + +pub fn main() { + let _ = issue6919_3::D.k; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7012.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7012.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7012.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7012.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] +#![allow(non_upper_case_globals)] + +/* +# Comparison of static arrays + +The expected behaviour would be that test==test1, therefore 'true' +would be printed, however the below prints false. +*/ + +struct signature<'a> { pattern : &'a [u32] } + +static test1: signature<'static> = signature { + pattern: &[0x243f6a88,0x85a308d3,0x13198a2e,0x03707344,0xa4093822,0x299f31d0] +}; + +pub fn main() { + let test: &[u32] = &[0x243f6a88,0x85a308d3,0x13198a2e, + 0x03707344,0xa4093822,0x299f31d0]; + println!("{}",test==test1.pattern); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7178.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7178.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7178.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7178.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-7178.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_7178 as cross_crate_self; + +pub fn main() { + let _ = cross_crate_self::Foo::new(&1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7222.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7222.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7222.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7222.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 +#![allow(illegal_floating_point_literal_pattern)] // FIXME #41620 + +pub fn main() { + const FOO: f64 = 10.0; + + match 0.0 { + 0.0 ..= FOO => (), + _ => () + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7344.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7344.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7344.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7344.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// pretty-expanded FIXME #23616 + +#![allow(unreachable_code)] + +fn foo() -> bool { false } + +fn bar() { + return; + !foo(); +} + +fn baz() { + return; + if "" == "" {} +} + +pub fn main() { + bar(); + baz(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7519-match-unit-in-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7519-match-unit-in-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7519-match-unit-in-arg.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7519-match-unit-in-arg.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +/* +#7519 ICE pattern matching unit in function argument +*/ + +fn foo(():()) { } + +pub fn main() { + foo(()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7563.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7563.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7563.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7563.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +trait IDummy { + fn do_nothing(&self); +} + +#[derive(Debug)] +struct A { a: isize } +#[derive(Debug)] +struct B<'a> { b: isize, pa: &'a A } + + impl IDummy for A { + fn do_nothing(&self) { + println!("A::do_nothing() is called"); + } + } + +impl<'a> B<'a> { + fn get_pa(&self) -> &'a IDummy { self.pa as &'a IDummy } +} + +pub fn main() { + let sa = A { a: 100 }; + let sb = B { b: 200, pa: &sa }; + + println!("sa is {:?}", sa); + println!("sb is {:?}", sb); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7575.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7575.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7575.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7575.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +trait Foo { + fn new() -> bool { false } + fn dummy(&self) { } +} + +trait Bar { + fn new(&self) -> bool { true } +} + +impl Bar for isize {} +impl Foo for isize {} + +fn main() { + assert!(1.new()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7660.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7660.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7660.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7660.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// Regression test for issue 7660 +// rvalue lifetime too short when equivalent `match` works + +// pretty-expanded FIXME #23616 + +use std::collections::HashMap; + +struct A(isize, isize); + +pub fn main() { + let mut m: HashMap = HashMap::new(); + m.insert(1, A(0, 0)); + + let A(ref _a, ref _b) = m[&1]; + let (a, b) = match m[&1] { A(ref _a, ref _b) => (_a, _b) }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7663.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7663.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7663.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7663.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![allow(unused_imports, dead_code)] + +mod test1 { + + mod foo { pub fn p() -> isize { 1 } } + mod bar { pub fn p() -> isize { 2 } } + + pub mod baz { + use test1::bar::p; + + pub fn my_main() { assert_eq!(p(), 2); } + } +} + +mod test2 { + + mod foo { pub fn p() -> isize { 1 } } + mod bar { pub fn p() -> isize { 2 } } + + pub mod baz { + use test2::bar::p; + + pub fn my_main() { assert_eq!(p(), 2); } + } +} + +fn main() { + test1::baz::my_main(); + test2::baz::my_main(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7784.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7784.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7784.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7784.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(slice_patterns)] + +use std::ops::Add; + +fn foo + Clone>([x, y, z]: [T; 3]) -> (T, T, T) { + (x.clone(), x.clone() + y.clone(), x + y + z) +} +fn bar(a: &'static str, b: &'static str) -> [&'static str; 4] { + [a, b, b, a] +} + +fn main() { + assert_eq!(foo([1, 2, 3]), (1, 3, 6)); + + let [a, b, c, d] = bar("foo", "bar"); + assert_eq!(a, "foo"); + assert_eq!(b, "bar"); + assert_eq!(c, "bar"); + assert_eq!(d, "foo"); + + let [a, _, _, d] = bar("baz", "foo"); + assert_eq!(a, "baz"); + assert_eq!(d, "baz"); + + let out = bar("baz", "foo"); + let [a, xs.., d] = out; + assert_eq!(a, "baz"); + assert_eq!(xs, ["foo", "foo"]); + assert_eq!(d, "baz"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7899.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7899.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7899.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7899.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// aux-build:issue-7899.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_7899 as testcrate; + +fn main() { + let f = testcrate::V2(1.0f32, 2.0f32); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7911.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7911.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-7911.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-7911.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// (Closes #7911) Test that we can use the same self expression +// with different mutability in macro in two methods + +#![allow(unused_variables)] // unused foobar_immut + foobar_mut +trait FooBar { + fn dummy(&self) { } +} +struct Bar(i32); +struct Foo { bar: Bar } + +impl FooBar for Bar {} + +trait Test { + fn get_immut(&self) -> &FooBar; + fn get_mut(&mut self) -> &mut FooBar; +} + +macro_rules! generate_test { ($type_:path, $slf:ident, $field:expr) => ( + impl Test for $type_ { + fn get_immut(&$slf) -> &FooBar { + &$field as &FooBar + } + + fn get_mut(&mut $slf) -> &mut FooBar { + &mut $field as &mut FooBar + } + } +)} + +generate_test!(Foo, self, self.bar); + +pub fn main() { + let mut foo: Foo = Foo { bar: Bar(42) }; + { let foobar_immut = foo.get_immut(); } + { let foobar_mut = foo.get_mut(); } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8044.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8044.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8044.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8044.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-8044.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_8044 as minimal; +use minimal::{BTree, leaf}; + +pub fn main() { + BTree:: { node: leaf(1) }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8248.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8248.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8248.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8248.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +trait A { + fn dummy(&self) { } +} +struct B; +impl A for B {} + +fn foo(_: &mut A) {} + +pub fn main() { + let mut b = B; + foo(&mut b as &mut A); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8249.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8249.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8249.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8249.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +trait A { + fn dummy(&self) { } +} +struct B; +impl A for B {} + +struct C<'a> { + foo: &'a mut (A+'a), +} + +fn foo(a: &mut A) { + C{ foo: a }; +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8259.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8259.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8259.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8259.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_upper_case_globals)] + +// aux-build:issue-8259.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_8259 as other; +static a: other::Foo<'static> = other::Foo::A; + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8351-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8351-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8351-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8351-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +enum E { + Foo{f: isize}, + Bar, +} + +pub fn main() { + let e = E::Foo{f: 0}; + match e { + E::Foo{f: 1} => panic!(), + E::Foo{..} => (), + _ => panic!(), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8351-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8351-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8351-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8351-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +enum E { + Foo{f: isize, b: bool}, + Bar, +} + +pub fn main() { + let e = E::Foo{f: 0, b: false}; + match e { + E::Foo{f: 1, b: true} => panic!(), + E::Foo{b: false, f: 0} => (), + _ => panic!(), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8391.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8391.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8391.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8391.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn main() { + let x = match Some(1) { + ref _y @ Some(_) => 1, + None => 2, + }; + assert_eq!(x, 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8401.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8401.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8401.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8401.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue_8401.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_8401; + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8460.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8460.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8460.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8460.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,61 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// ignore-emscripten no threads support +#![feature(rustc_attrs)] + +use std::thread; + +trait Int { + fn zero() -> Self; + fn one() -> Self; +} +macro_rules! doit { + ($($t:ident)*) => ($(impl Int for $t { + fn zero() -> $t { 0 } + fn one() -> $t { 1 } + })*) +} +doit! { i8 i16 i32 i64 isize } + +macro_rules! check { + ($($e:expr),*) => { + $(assert!(thread::spawn({ + move|| { $e; } + }).join().is_err());)* + } +} + +fn main() { + check![ + isize::min_value() / -isize::one(), + i8::min_value() / -i8::one(), + i16::min_value() / -i16::one(), + i32::min_value() / -i32::one(), + i64::min_value() / -i64::one(), + 1isize / isize::zero(), + 1i8 / i8::zero(), + 1i16 / i16::zero(), + 1i32 / i32::zero(), + 1i64 / i64::zero(), + isize::min_value() % -isize::one(), + i8::min_value() % -i8::one(), + i16::min_value() % -i16::one(), + i32::min_value() % -i32::one(), + i64::min_value() % -i64::one(), + 1isize % isize::zero(), + 1i8 % i8::zero(), + 1i16 % i16::zero(), + 1i32 % i32::zero(), + 1i64 % i64::zero() + ]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8498.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8498.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8498.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8498.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + match &[(Box::new(5),Box::new(7))] { + ps => { + let (ref y, _) = ps[0]; + assert_eq!(**y, 5); + } + } + + match Some(&[(Box::new(5),)]) { + Some(ps) => { + let (ref y,) = ps[0]; + assert_eq!(**y, 5); + } + None => () + } + + match Some(&[(Box::new(5),Box::new(7))]) { + Some(ps) => { + let (ref y, ref z) = ps[0]; + assert_eq!(**y, 5); + assert_eq!(**z, 7); + } + None => () + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8506.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8506.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8506.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8506.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 +#![allow(non_upper_case_globals)] + +#![allow(dead_code)] + +enum Either { + One, + Other(String,String) +} + +static one : Either = Either::One; + +pub fn main () { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-868.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-868.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-868.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-868.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_parens)] +// pretty-expanded FIXME #23616 + +fn f(g: F) -> T where F: FnOnce() -> T { g() } + +pub fn main() { + let _x = f( | | { 10 }); + // used to be: cannot determine a type for this expression + f(| | { }); + // ditto + f( | | { ()}); + // always worked + let _: () = f(| | { }); + // empty block with no type info should compile too + let _ = f(||{}); + let _ = (||{}); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8709.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8709.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8709.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8709.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +macro_rules! sty { + ($t:ty) => (stringify!($t)) +} + +macro_rules! spath { + ($t:path) => (stringify!($t)) +} + +fn main() { + assert_eq!(sty!(isize), "isize"); + assert_eq!(spath!(std::option), "std::option"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8783.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8783.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8783.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8783.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// pretty-expanded FIXME #23616 + +use std::default::Default; + +struct X { pub x: usize } +impl Default for X { + fn default() -> X { + X { x: 42 } + } +} + +struct Y { pub y: T } +impl Default for Y { + fn default() -> Y { + Y { y: Default::default() } + } +} + +fn main() { + let X { x: _ } = Default::default(); + let Y { y: X { x } } = Default::default(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8827.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8827.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8827.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8827.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,63 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten no threads support + +use std::thread; +use std::sync::mpsc::{channel, Receiver}; + +fn periodical(n: isize) -> Receiver { + let (chan, port) = channel(); + thread::spawn(move|| { + loop { + for _ in 1..n { + match chan.send(false) { + Ok(()) => {} + Err(..) => break, + } + } + match chan.send(true) { + Ok(()) => {} + Err(..) => break + } + } + }); + return port; +} + +fn integers() -> Receiver { + let (chan, port) = channel(); + thread::spawn(move|| { + let mut i = 1; + loop { + match chan.send(i) { + Ok(()) => {} + Err(..) => break, + } + i = i + 1; + } + }); + return port; +} + +fn main() { + let ints = integers(); + let threes = periodical(3); + let fives = periodical(5); + for _ in 1..100 { + match (ints.recv().unwrap(), threes.recv().unwrap(), fives.recv().unwrap()) { + (_, true, true) => println!("FizzBuzz"), + (_, true, false) => println!("Fizz"), + (_, false, true) => println!("Buzz"), + (i, false, false) => println!("{}", i) + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8851.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8851.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8851.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8851.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// after fixing #9384 and implementing hygiene for match bindings, +// this now fails because the insertion of the 'y' into the match +// doesn't cause capture. Making this macro hygienic (as I've done) +// could very well make this test case completely pointless.... + +// pretty-expanded FIXME #23616 + +enum T { + A(isize), + B(usize) +} + +macro_rules! test { + ($id:ident, $e:expr) => ( + fn foo(t: T) -> isize { + match t { + T::A($id) => $e, + T::B($id) => $e + } + } + ) +} + +test!(y, 10 + (y as isize)); + +pub fn main() { + foo(T::A(20)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8860.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8860.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8860.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8860.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,60 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// compile-flags: -Z borrowck=compare + +static mut DROP: isize = 0; +static mut DROP_S: isize = 0; +static mut DROP_T: isize = 0; + +struct S; +impl Drop for S { + fn drop(&mut self) { + unsafe { + DROP_S += 1; + DROP += 1; + } + } +} +fn f(ref _s: S) {} + +struct T { i: isize } +impl Drop for T { + fn drop(&mut self) { + unsafe { + DROP_T += 1; + DROP += 1; + } + } +} +fn g(ref _t: T) {} + +fn do_test() { + let s = S; + f(s); + unsafe { + assert_eq!(1, DROP); + assert_eq!(1, DROP_S); + } + let t = T { i: 1 }; + g(t); + unsafe { assert_eq!(1, DROP_T); } +} + +fn main() { + do_test(); + unsafe { + assert_eq!(2, DROP); + assert_eq!(1, DROP_S); + assert_eq!(1, DROP_T); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8898.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8898.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-8898.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-8898.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn assert_repr_eq(obj : T, expected : String) { + assert_eq!(expected, format!("{:?}", obj)); +} + +pub fn main() { + let abc = [1, 2, 3]; + let tf = [true, false]; + let x = [(), ()]; + let slice = &x[..1]; + + assert_repr_eq(&abc[..], "[1, 2, 3]".to_string()); + assert_repr_eq(&tf[..], "[true, false]".to_string()); + assert_repr_eq(&x[..], "[(), ()]".to_string()); + assert_repr_eq(slice, "[()]".to_string()); + assert_repr_eq(&x[..], "[(), ()]".to_string()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9047.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9047.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9047.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9047.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +#![allow(unused_variables)] +fn decode() -> String { + 'outer: loop { + let mut ch_start: usize; + break 'outer; + } + "".to_string() +} + +pub fn main() { + println!("{}", decode()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9123.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9123.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9123.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9123.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue_9123.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_9123; + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9129.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9129.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9129.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9129.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +// ignore-pretty unreported + +#![feature(box_syntax)] + +pub trait bomb { fn boom(&self, _: Ident); } +pub struct S; +impl bomb for S { fn boom(&self, _: Ident) { } } + +pub struct Ident { name: usize } + +// macro_rules! int3 { () => ( unsafe { asm!( "int3" ); } ) } +macro_rules! int3 { () => ( { } ) } + +fn Ident_new() -> Ident { + int3!(); + Ident {name: 0x6789ABCD } +} + +pub fn light_fuse(fld: Box) { + int3!(); + let f = || { + int3!(); + fld.boom(Ident_new()); // *** 1 + }; + f(); +} + +pub fn main() { + let b = box S as Box; + light_fuse(b); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue_9155.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue_9155.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue_9155.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue_9155.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue_9155.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_9155; + +struct Baz; + +pub fn main() { + issue_9155::Foo::new(Baz); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9188.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9188.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9188.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9188.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue_9188.rs + + +extern crate issue_9188; + +pub fn main() { + let a = issue_9188::bar(); + let b = issue_9188::foo::(); + assert_eq!(*a, *b); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9259.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9259.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9259.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9259.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +struct A<'a> { + a: &'a [String], + b: Option<&'a [String]>, +} + +pub fn main() { + let b: &[String] = &["foo".to_string()]; + let a = A { + a: &["test".to_string()], + b: Some(b), + }; + assert_eq!(a.b.as_ref().unwrap()[0], "foo"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9382.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9382.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9382.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9382.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,50 @@ +// pretty-expanded FIXME #23616 + +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![feature(box_syntax)] + +// Tests for a previous bug that occurred due to an interaction +// between struct field initialization and the auto-coercion +// from a vector to a slice. The drop glue was being invoked on +// the temporary slice with a wrong type, triggering an LLVM assert. + + +struct Thing1<'a> { + baz: &'a [Box], + bar: Box, +} + +struct Thing2<'a> { + baz: &'a [Box], + bar: u64, +} + +pub fn main() { + let _t1_fixed = Thing1 { + baz: &[], + bar: box 32, + }; + Thing1 { + baz: &Vec::new(), + bar: box 32, + }; + let _t2_fixed = Thing2 { + baz: &[], + bar: 32, + }; + Thing2 { + baz: &Vec::new(), + bar: 32, + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9394-inherited-trait-calls.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9394-inherited-trait-calls.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9394-inherited-trait-calls.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9394-inherited-trait-calls.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,72 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +trait Base: Base2 + Base3{ + fn foo(&self) -> String; + fn foo1(&self) -> String; + fn foo2(&self) -> String{ + "base foo2".to_string() + } +} + +trait Base2: Base3{ + fn baz(&self) -> String; +} + +trait Base3{ + fn root(&self) -> String; +} + +trait Super: Base{ + fn bar(&self) -> String; +} + +struct X; + +impl Base for X { + fn foo(&self) -> String{ + "base foo".to_string() + } + fn foo1(&self) -> String{ + "base foo1".to_string() + } + +} + +impl Base2 for X { + fn baz(&self) -> String{ + "base2 baz".to_string() + } +} + +impl Base3 for X { + fn root(&self) -> String{ + "base3 root".to_string() + } +} + +impl Super for X { + fn bar(&self) -> String{ + "super bar".to_string() + } +} + +pub fn main() { + let n = X; + let s = &n as &Super; + assert_eq!(s.bar(),"super bar".to_string()); + assert_eq!(s.foo(),"base foo".to_string()); + assert_eq!(s.foo1(),"base foo1".to_string()); + assert_eq!(s.foo2(),"base foo2".to_string()); + assert_eq!(s.baz(),"base2 baz".to_string()); + assert_eq!(s.root(),"base3 root".to_string()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9396.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9396.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9396.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9396.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +#![allow(deprecated)] +// ignore-emscripten no threads support + +use std::sync::mpsc::{TryRecvError, channel}; +use std::thread; + +pub fn main() { + let (tx, rx) = channel(); + let t = thread::spawn(move||{ + thread::sleep_ms(10); + tx.send(()).unwrap(); + }); + loop { + match rx.try_recv() { + Ok(()) => break, + Err(TryRecvError::Empty) => {} + Err(TryRecvError::Disconnected) => unreachable!() + } + } + t.join(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9446.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9446.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9446.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9446.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct Wrapper(String); + +impl Wrapper { + pub fn new(wrapped: String) -> Wrapper { + Wrapper(wrapped) + } + + pub fn say_hi(&self) { + let Wrapper(ref s) = *self; + println!("hello {}", *s); + } +} + +impl Drop for Wrapper { + fn drop(&mut self) {} +} + +pub fn main() { + { + // This runs without complaint. + let x = Wrapper::new("Bob".to_string()); + x.say_hi(); + } + { + // This fails to compile, circa 0.8-89-gc635fba. + // error: internal compiler error: drop_ty_immediate: non-box ty + Wrapper::new("Bob".to_string()).say_hi(); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9737.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9737.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9737.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9737.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +macro_rules! f { + (v: $x:expr) => ( println!("{}", $x) ) +} + +fn main () { + let v = 5; + f!(v: 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-979.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-979.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-979.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-979.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +use std::cell::Cell; + +struct r<'a> { + b: &'a Cell, +} + +impl<'a> Drop for r<'a> { + fn drop(&mut self) { + self.b.set(self.b.get() + 1); + } +} + +fn r(b: &Cell) -> r { + r { + b: b + } +} + +pub fn main() { + let b = &Cell::new(0); + { + let _p = Some(r(b)); + } + + assert_eq!(b.get(), 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9837.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9837.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9837.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9837.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +const C1: i32 = 0x12345678; +const C2: isize = C1 as i16 as isize; + +enum E { + V = C2 +} + +fn main() { + assert_eq!(C2 as u64, E::V as u64); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9906.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9906.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9906.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9906.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-9906.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_9906 as testmod; + +pub fn main() { + testmod::foo(); + testmod::FooBar::new(1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9918.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9918.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9918.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9918.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + assert_eq!((0 + 0u8) as char, '\0'); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9942.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9942.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9942.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9942.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +pub fn main() { + const S: usize = 23 as usize; [0; S]; () +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9951.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9951.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9951.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9951.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#![allow(unused_variables)] + +trait Bar { + fn noop(&self); +} +impl Bar for u8 { + fn noop(&self) {} +} + +fn main() { + let (a, b) = (&5u8 as &Bar, &9u8 as &Bar); + let (c, d): (&Bar, &Bar) = (a, b); + + let (a, b) = (Box::new(5u8) as Box, Box::new(9u8) as Box); + let (c, d): (&Bar, &Bar) = (&*a, &*b); + + let (c, d): (&Bar, &Bar) = (&5, &9); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9968.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9968.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/issues/issue-9968.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/issues/issue-9968.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:issue-9968.rs + +// pretty-expanded FIXME #23616 + +extern crate issue_9968 as lib; + +use lib::{Trait, Struct}; + +pub fn main() +{ + Struct::init().test(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/item-attributes.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/item-attributes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/item-attributes.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/item-attributes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(non_upper_case_globals)] +#![allow(unused_attributes)] +#![allow(dead_code)] +#![allow(unknown_lints)] // These are attributes of the implicit crate. Really this just needs to parse // for completeness since .rs files linked from .rc files support this // notation to specify their module's attributes diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/item-name-overload.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/item-name-overload.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/item-name-overload.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/item-name-overload.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/iterators/into-iterator-type-inference-shift.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/iterators/into-iterator-type-inference-shift.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/iterators/into-iterator-type-inference-shift.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/iterators/into-iterator-type-inference-shift.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +#![allow(dead_code)] +#![allow(unused_mut)] +#![allow(unused_variables)] +// Regression test for type inference failure around shifting. In this +// case, the iteration yields an isize, but we hadn't run the full type +// propagation yet, and so we just saw a type variable, yielding an +// error. + +// pretty-expanded FIXME #23616 + +trait IntoIterator { + type Iter: Iterator; + + fn into_iter(self) -> Self::Iter; +} + +impl IntoIterator for I where I: Iterator { + type Iter = I; + + fn into_iter(self) -> I { + self + } +} + +fn desugared_for_loop_bad(byte: u8) -> u8 { + let mut result = 0; + let mut x = IntoIterator::into_iter(0..8); + let mut y = Iterator::next(&mut x); + let mut z = y.unwrap(); + byte >> z; + 1 +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/iterators/iter-cloned-type-inference.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/iterators/iter-cloned-type-inference.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/iterators/iter-cloned-type-inference.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/iterators/iter-cloned-type-inference.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(stable_features)] + +// Test to see that the element type of .cloned() can be inferred +// properly. Previously this would fail to deduce the type of `sum`. + +#![feature(iter_arith)] + +fn square_sum(v: &[i64]) -> i64 { + let sum: i64 = v.iter().cloned().sum(); + sum * sum +} + +fn main() { + assert_eq!(36, square_sum(&[1,2,3])); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/iterators/iter-range.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/iterators/iter-range.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/iterators/iter-range.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/iterators/iter-range.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +fn range_(a: isize, b: isize, mut it: F) where F: FnMut(isize) { + assert!((a < b)); + let mut i: isize = a; + while i < b { it(i); i += 1; } +} + +pub fn main() { + let mut sum: isize = 0; + range_(0, 100, |x| sum += x ); + println!("{}", sum); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/iterators/iter-step-overflow-debug.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/iterators/iter-step-overflow-debug.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/iterators/iter-step-overflow-debug.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/iterators/iter-step-overflow-debug.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-wasm32-bare compiled with panic=abort by default +// compile-flags: -C debug_assertions=yes + +use std::panic; + +fn main() { + let r = panic::catch_unwind(|| { + let mut it = u8::max_value()..; + it.next().unwrap(); // 255 + it.next().unwrap(); + }); + assert!(r.is_err()); + + let r = panic::catch_unwind(|| { + let mut it = i8::max_value()..; + it.next().unwrap(); // 127 + it.next().unwrap(); + }); + assert!(r.is_err()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/iterators/iter-step-overflow-ndebug.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/iterators/iter-step-overflow-ndebug.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/iterators/iter-step-overflow-ndebug.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/iterators/iter-step-overflow-ndebug.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags: -C debug_assertions=no + +fn main() { + let mut it = u8::max_value()..; + assert_eq!(it.next().unwrap(), 255); + assert_eq!(it.next().unwrap(), u8::min_value()); + + let mut it = i8::max_value()..; + assert_eq!(it.next().unwrap(), 127); + assert_eq!(it.next().unwrap(), i8::min_value()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/iterators/iter-sum-overflow-debug.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/iterators/iter-sum-overflow-debug.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/iterators/iter-sum-overflow-debug.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/iterators/iter-sum-overflow-debug.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-wasm32-bare compiled with panic=abort by default +// compile-flags: -C debug_assertions=yes + +use std::panic; + +fn main() { + let r = panic::catch_unwind(|| { + [1, i32::max_value()].iter().sum::(); + }); + assert!(r.is_err()); + + let r = panic::catch_unwind(|| { + [2, i32::max_value()].iter().product::(); + }); + assert!(r.is_err()); + + let r = panic::catch_unwind(|| { + [1, i32::max_value()].iter().cloned().sum::(); + }); + assert!(r.is_err()); + + let r = panic::catch_unwind(|| { + [2, i32::max_value()].iter().cloned().product::(); + }); + assert!(r.is_err()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/iterators/iter-sum-overflow-ndebug.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/iterators/iter-sum-overflow-ndebug.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/iterators/iter-sum-overflow-ndebug.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/iterators/iter-sum-overflow-ndebug.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags: -C debug_assertions=no + +fn main() { + assert_eq!([1i32, i32::max_value()].iter().sum::(), + 1i32.wrapping_add(i32::max_value())); + assert_eq!([2i32, i32::max_value()].iter().product::(), + 2i32.wrapping_mul(i32::max_value())); + + assert_eq!([1i32, i32::max_value()].iter().cloned().sum::(), + 1i32.wrapping_add(i32::max_value())); + assert_eq!([2i32, i32::max_value()].iter().cloned().product::(), + 2i32.wrapping_mul(i32::max_value())); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/iterators/iter-sum-overflow-overflow-checks.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/iterators/iter-sum-overflow-overflow-checks.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/iterators/iter-sum-overflow-overflow-checks.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/iterators/iter-sum-overflow-overflow-checks.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-wasm32-bare compiled with panic=abort by default +// compile-flags: -C overflow-checks + +use std::panic; + +fn main() { + let r = panic::catch_unwind(|| { + [1, i32::max_value()].iter().sum::(); + }); + assert!(r.is_err()); + + let r = panic::catch_unwind(|| { + [2, i32::max_value()].iter().product::(); + }); + assert!(r.is_err()); + + let r = panic::catch_unwind(|| { + [1, i32::max_value()].iter().cloned().sum::(); + }); + assert!(r.is_err()); + + let r = panic::catch_unwind(|| { + [2, i32::max_value()].iter().cloned().product::(); + }); + assert!(r.is_err()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/iterators/iter-zip.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/iterators/iter-zip.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/iterators/iter-zip.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/iterators/iter-zip.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,113 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that .zip() specialization preserves side effects +// in sideeffectful iterator adaptors. + +use std::cell::Cell; + +#[derive(Debug)] +struct CountClone(Cell); + +fn count_clone() -> CountClone { CountClone(Cell::new(0)) } + +impl PartialEq for CountClone { + fn eq(&self, rhs: &i32) -> bool { + self.0.get() == *rhs + } +} + +impl Clone for CountClone { + fn clone(&self) -> Self { + let ret = CountClone(self.0.clone()); + let n = self.0.get(); + self.0.set(n + 1); + ret + } +} + +fn test_zip_cloned_sideffectful() { + let xs = [count_clone(), count_clone(), count_clone(), count_clone()]; + let ys = [count_clone(), count_clone()]; + + for _ in xs.iter().cloned().zip(ys.iter().cloned()) { } + + assert_eq!(&xs, &[1, 1, 1, 0][..]); + assert_eq!(&ys, &[1, 1][..]); + + let xs = [count_clone(), count_clone()]; + let ys = [count_clone(), count_clone(), count_clone(), count_clone()]; + + for _ in xs.iter().cloned().zip(ys.iter().cloned()) { } + + assert_eq!(&xs, &[1, 1][..]); + assert_eq!(&ys, &[1, 1, 0, 0][..]); +} + +fn test_zip_map_sideffectful() { + let mut xs = [0; 6]; + let mut ys = [0; 4]; + + for _ in xs.iter_mut().map(|x| *x += 1).zip(ys.iter_mut().map(|y| *y += 1)) { } + + assert_eq!(&xs, &[1, 1, 1, 1, 1, 0]); + assert_eq!(&ys, &[1, 1, 1, 1]); + + let mut xs = [0; 4]; + let mut ys = [0; 6]; + + for _ in xs.iter_mut().map(|x| *x += 1).zip(ys.iter_mut().map(|y| *y += 1)) { } + + assert_eq!(&xs, &[1, 1, 1, 1]); + assert_eq!(&ys, &[1, 1, 1, 1, 0, 0]); +} + +fn test_zip_map_rev_sideffectful() { + let mut xs = [0; 6]; + let mut ys = [0; 4]; + + { + let mut it = xs.iter_mut().map(|x| *x += 1).zip(ys.iter_mut().map(|y| *y += 1)); + it.next_back(); + } + assert_eq!(&xs, &[0, 0, 0, 1, 1, 1]); + assert_eq!(&ys, &[0, 0, 0, 1]); + + let mut xs = [0; 6]; + let mut ys = [0; 4]; + + { + let mut it = xs.iter_mut().map(|x| *x += 1).zip(ys.iter_mut().map(|y| *y += 1)); + (&mut it).take(5).count(); + it.next_back(); + } + assert_eq!(&xs, &[1, 1, 1, 1, 1, 1]); + assert_eq!(&ys, &[1, 1, 1, 1]); +} + +fn test_zip_nested_sideffectful() { + let mut xs = [0; 6]; + let ys = [0; 4]; + + { + // test that it has the side effect nested inside enumerate + let it = xs.iter_mut().map(|x| *x = 1).enumerate().zip(&ys); + it.count(); + } + assert_eq!(&xs, &[1, 1, 1, 1, 1, 0]); +} + +fn main() { + test_zip_cloned_sideffectful(); + test_zip_map_sideffectful(); + test_zip_map_rev_sideffectful(); + test_zip_nested_sideffectful(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/keyword-changes-2012-07-31.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/keyword-changes-2012-07-31.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/keyword-changes-2012-07-31.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/keyword-changes-2012-07-31.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // return -> return // mod -> module // match -> match diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/kindck-implicit-close-over-mut-var.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/kindck-implicit-close-over-mut-var.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/kindck-implicit-close-over-mut-var.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/kindck-implicit-close-over-mut-var.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_must_use)] +#![allow(dead_code)] use std::thread; fn user(_i: isize) {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/lambda-infer-unresolved.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/lambda-infer-unresolved.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/lambda-infer-unresolved.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/lambda-infer-unresolved.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_mut)] // This should typecheck even though the type of e is not fully // resolved when we finish typechecking the ||. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/large-records.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/large-records.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/large-records.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/large-records.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/last-use-in-block.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/last-use-in-block.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/last-use-in-block.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/last-use-in-block.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] +#![allow(unused_parens)] // Issue #1818 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/last-use-in-cap-clause.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/last-use-in-cap-clause.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/last-use-in-cap-clause.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/last-use-in-cap-clause.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // Make sure #1399 stays fixed struct A { a: Box } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/last-use-is-capture.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/last-use-is-capture.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/last-use-is-capture.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/last-use-is-capture.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // Make sure #1399 stays fixed #![feature(box_syntax)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/lazy-init.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/lazy-init.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/lazy-init.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/lazy-init.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_mut)] fn foo(x: isize) { println!("{}", x); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/lib-defaults.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/lib-defaults.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/lib-defaults.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/lib-defaults.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// dont-check-compiler-stderr (rust-lang/rust#54222) + // ignore-wasm32-bare no libc to test ffi with // compile-flags: -lrust_test_helpers diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/link-section.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/link-section.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/link-section.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/link-section.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_upper_case_globals)] #[cfg(not(target_os = "macos"))] #[link_section=".moretext"] fn i_live_in_more_text() -> &'static str { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/lint-non-camel-case-types-non-uppercase-statics-unicode.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/lint-non-camel-case-types-non-uppercase-statics-unicode.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/lint-non-camel-case-types-non-uppercase-statics-unicode.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/lint-non-camel-case-types-non-uppercase-statics-unicode.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. // +#![allow(dead_code)] #![forbid(non_camel_case_types)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/lint-non-camel-case-with-trailing-underscores.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/lint-non-camel-case-with-trailing-underscores.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/lint-non-camel-case-with-trailing-underscores.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/lint-non-camel-case-with-trailing-underscores.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // This is ok because we often use the trailing underscore to mean 'prime' // pretty-expanded FIXME #23616 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/list.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/list.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/list.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/list.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] // pretty-expanded FIXME #23616 #![feature(box_syntax)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/liveness-assign-imm-local-after-ret.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/liveness-assign-imm-local-after-ret.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/liveness-assign-imm-local-after-ret.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/liveness-assign-imm-local-after-ret.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unreachable_code)] // pretty-expanded FIXME #23616 #![allow(dead_code)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(dead_code)] #[derive(Clone, Debug)] enum foo { a(usize), diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/log-knows-the-names-of-variants.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/log-knows-the-names-of-variants.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/log-knows-the-names-of-variants.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/log-knows-the-names-of-variants.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(dead_code)] #[derive(Debug)] enum foo { a(usize), diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/assert-eq-macro-success.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/assert-eq-macro-success.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/assert-eq-macro-success.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/assert-eq-macro-success.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(PartialEq, Debug)] +struct Point { x : isize } + +pub fn main() { + assert_eq!(14,14); + assert_eq!("abc".to_string(),"abc".to_string()); + assert_eq!(Box::new(Point{x:34}),Box::new(Point{x:34})); + assert_eq!(&Point{x:34},&Point{x:34}); + assert_eq!(42, 42, "foo bar"); + assert_eq!(42, 42, "a {} c", "b"); + assert_eq!(42, 42, "{x}, {y}, {z}", x = 1, y = 2, z = 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/assert-eq-macro-unsized.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/assert-eq-macro-unsized.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/assert-eq-macro-unsized.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/assert-eq-macro-unsized.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn main() { + assert_eq!([1, 2, 3][..], vec![1, 2, 3][..]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/assert-ne-macro-success.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/assert-ne-macro-success.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/assert-ne-macro-success.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/assert-ne-macro-success.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(PartialEq, Debug)] +struct Point { x : isize } + +pub fn main() { + assert_ne!(666,14); + assert_ne!("666".to_string(),"abc".to_string()); + assert_ne!(Box::new(Point{x:666}),Box::new(Point{x:34})); + assert_ne!(&Point{x:666},&Point{x:34}); + assert_ne!(666, 42, "no gods no masters"); + assert_ne!(666, 42, "6 {} 6", "6"); + assert_ne!(666, 42, "{x}, {y}, {z}", x = 6, y = 6, z = 6); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/assert-ne-macro-unsized.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/assert-ne-macro-unsized.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/assert-ne-macro-unsized.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/assert-ne-macro-unsized.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn main() { + assert_ne!([6, 6, 6][..], vec![1, 2, 3][..]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro-comma-support.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro-comma-support.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro-comma-support.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro-comma-support.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +() diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro_crate_def_only.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro_crate_def_only.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro_crate_def_only.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro_crate_def_only.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[macro_export] +macro_rules! make_a_5 { + () => (5) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro_crate_nonterminal.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro_crate_nonterminal.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro_crate_nonterminal.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro_crate_nonterminal.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn increment(x: usize) -> usize { + x + 1 +} + +#[macro_export] +macro_rules! increment { + ($x:expr) => ($crate::increment($x)) +} + +pub fn check_local() { + assert_eq!(increment!(3), 4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro_export_inner_module.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro_export_inner_module.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro_export_inner_module.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro_export_inner_module.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod inner { + #[macro_export] + macro_rules! foo { + () => (1) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro-include-items-expr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro-include-items-expr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro-include-items-expr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro-include-items-expr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-test: this is not a test + +1 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro-include-items-item.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro-include-items-item.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro-include-items-item.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro-include-items-item.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-test: this is not a test + +fn foo() { bar() } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro_with_super_1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro_with_super_1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro_with_super_1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/macro_with_super_1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +#[macro_export] +macro_rules! declare { + () => ( + pub fn aaa() {} + + pub mod bbb { + use super::aaa; + + pub fn ccc() { + aaa(); + } + } + ) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/two_macros.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/two_macros.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/two_macros.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/two_macros.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[macro_export] +macro_rules! macro_one { ($($t:tt)*) => ($($t)*) } + +#[macro_export] +macro_rules! macro_two { ($($t:tt)*) => ($($t)*) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/unstable-macros.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/unstable-macros.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/unstable-macros.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/unstable-macros.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(staged_api)] +#![stable(feature = "unit_test", since = "1.0.0")] + +#[unstable(feature = "unstable_macros", issue = "0")] +#[macro_export] +macro_rules! unstable_macro{ () => () } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/use-macro-self.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/use-macro-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/use-macro-self.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/auxiliary/use-macro-self.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod foobarius {} + +#[macro_export] +macro_rules! foobarius { + () => { () } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/colorful-write-macros.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/colorful-write-macros.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/colorful-write-macros.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/colorful-write-macros.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +use std::io::Write; +use std::fmt; + +struct Foo<'a> { + writer: &'a mut (Write+'a), + other: &'a str, +} + +struct Bar; + +impl fmt::Write for Bar { + fn write_str(&mut self, _: &str) -> fmt::Result { + Ok(()) + } +} + +fn borrowing_writer_from_struct_and_formatting_struct_field(foo: Foo) { + write!(foo.writer, "{}", foo.other).unwrap(); +} + +fn main() { + let mut w = Vec::new(); + write!(&mut w as &mut Write, "").unwrap(); + write!(&mut w, "").unwrap(); // should coerce + println!("ok"); + + let mut s = Bar; + { + use std::fmt::Write; + write!(&mut s, "test").unwrap(); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/conditional-debug-macro-on.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/conditional-debug-macro-on.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/conditional-debug-macro-on.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/conditional-debug-macro-on.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn main() { + // exits early if println! evaluates its arguments, otherwise it + // will hit the panic. + println!("{:?}", { if true { return; } }); + + panic!(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/die-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/die-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/die-macro.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/die-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Just testing that panic!() type checks in statement or expr + + +#![allow(unreachable_code)] + +fn f() { + panic!(); + + let _x: isize = panic!(); +} + +pub fn main() { + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/issue-25274.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/issue-25274.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/issue-25274.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/issue-25274.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +macro_rules! test { + ( + fn fun() -> Option>; + ) => { + fn fun(x: $t) -> Option> + { Some(Box::new(x)) } + } +} + +test! { + fn fun() -> Option>; +} + +fn main() { + println!("{}", fun(0).unwrap()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/log_syntax-trace_macros-macro-locations.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/log_syntax-trace_macros-macro-locations.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/log_syntax-trace_macros-macro-locations.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/log_syntax-trace_macros-macro-locations.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#![feature(trace_macros, log_syntax)] + +// make sure these macros can be used as in the various places that +// macros can occur. + +// items +trace_macros!(false); +log_syntax!(); + +fn main() { + + // statements + trace_macros!(false); + log_syntax!(); + + // expressions + (trace_macros!(false), + log_syntax!()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/log_syntax-trace_macros-macro-locations.stdout rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/log_syntax-trace_macros-macro-locations.stdout --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/log_syntax-trace_macros-macro-locations.stdout 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/log_syntax-trace_macros-macro-locations.stdout 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,3 @@ + + + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn main() { + + macro_rules! mylambda_tt { + ($x:ident, $body:expr) => ({ + fn f($x: isize) -> isize { return $body; }; + f + }) + } + + assert_eq!(mylambda_tt!(y, y * 2)(8), 16); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-as-fn-body.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-as-fn-body.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-as-fn-body.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-as-fn-body.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// run-pass +// +// Description - ensure Interpolated blocks can act as valid function bodies +// Covered cases: free functions, struct methods, and default trait functions + +macro_rules! def_fn { + ($body:block) => { + fn bar() $body + } +} + +trait Foo { + def_fn!({ println!("foo"); }); +} + +struct Baz {} + +impl Foo for Baz {} + +struct Qux {} + +impl Qux { + def_fn!({ println!("qux"); }); +} + +def_fn!({ println!("quux"); }); + +pub fn main() { + Baz::bar(); + Qux::bar(); + bar(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-at-most-once-rep.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-at-most-once-rep.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-at-most-once-rep.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-at-most-once-rep.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +// 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. + +// edition:2018 + +#![feature(macro_at_most_once_rep)] + +macro_rules! foo { + ($($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); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-attribute-expansion.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-attribute-expansion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-attribute-expansion.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-attribute-expansion.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +macro_rules! descriptions { + ($name:ident is $desc:expr) => { + // Check that we will correctly expand attributes + #[doc = $desc] + #[allow(dead_code)] + const $name : &'static str = $desc; + } +} + +// item +descriptions! { DOG is "an animal" } +descriptions! { RUST is "a language" } + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-attributes.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-attributes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-attributes.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-attributes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(custom_attribute)] + +macro_rules! compiles_fine { + (#[$at:meta]) => { + // test that the different types of attributes work + #[attribute] + /// Documentation! + #[$at] + + // check that the attributes are recognised by requiring this + // to be removed to avoid a compile error + #[cfg(always_remove)] + static MISTYPED: () = "foo"; + } +} + +// item +compiles_fine!(#[foo]); + +pub fn main() { + // statement + compiles_fine!(#[bar]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-block-nonterminal.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-block-nonterminal.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-block-nonterminal.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-block-nonterminal.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +macro_rules! do_block{ + ($val:block) => {$val} +} + +fn main() { + let s; + do_block!({ s = "it works!"; }); + assert_eq!(s, "it works!"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-comma-behavior.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-comma-behavior.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-comma-behavior.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-comma-behavior.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,100 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +// Ideally, any macro call with a trailing comma should behave +// identically to a call without the comma. +// +// This checks the behavior of macros with trailing commas in key +// places where regressions in behavior seem highly possible (due +// to it being e.g. a place where the addition of an argument +// causes it to go down a code path with subtly different behavior). +// +// There is a companion test in compile-fail. + +// compile-flags: --test -C debug_assertions=yes +// revisions: std core + +#![cfg_attr(core, no_std)] + +#[cfg(std)] use std::fmt; +#[cfg(core)] use core::fmt; + +// an easy mistake in the implementation of 'assert!' +// would cause this to say "explicit panic" +#[test] +#[should_panic(expected = "assertion failed")] +fn assert_1arg() { + assert!(false,); +} + +// same as 'assert_1arg' +#[test] +#[should_panic(expected = "assertion failed")] +fn debug_assert_1arg() { + debug_assert!(false,); +} + +// make sure we don't accidentally forward to `write!("text")` +#[cfg(std)] +#[test] +fn writeln_1arg() { + use fmt::Write; + + let mut s = String::new(); + writeln!(&mut s,).unwrap(); + assert_eq!(&s, "\n"); +} + +// A number of format_args-like macros have special-case treatment +// for a single message string, which is not formatted. +// +// This test ensures that the addition of a trailing comma does not +// suddenly cause these strings to get formatted when they otherwise +// would not be. This is an easy mistake to make by having such a macro +// accept ", $($tok:tt)*" instead of ", $($tok:tt)+" after its minimal +// set of arguments. +// +// (Example: Issue #48042) +#[test] +fn to_format_or_not_to_format() { + // ("{}" is the easiest string to test because if this gets + // sent to format_args!, it'll simply fail to compile. + // "{{}}" is an example of an input that could compile and + // produce an incorrect program, but testing the panics + // would be burdensome.) + let falsum = || false; + + assert!(true, "{}",); + + // assert_eq!(1, 1, "{}",); // see compile-fail + // assert_ne!(1, 2, "{}",); // see compile-fail + + debug_assert!(true, "{}",); + + // debug_assert_eq!(1, 1, "{}",); // see compile-fail + // debug_assert_ne!(1, 2, "{}",); // see compile-fail + // eprint!("{}",); // see compile-fail + // eprintln!("{}",); // see compile-fail + // format!("{}",); // see compile-fail + // format_args!("{}",); // see compile-fail + + if falsum() { panic!("{}",); } + + // print!("{}",); // see compile-fail + // println!("{}",); // see compile-fail + // unimplemented!("{}",); // see compile-fail + + if falsum() { unreachable!("{}",); } + + // write!(&mut stdout, "{}",); // see compile-fail + // writeln!(&mut stdout, "{}",); // see compile-fail +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-comma-support.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-comma-support.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-comma-support.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-comma-support.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,360 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// This is meant to be a comprehensive test of invocations with/without +// trailing commas (or other, similar optionally-trailing separators). +// Every macro is accounted for, even those not tested in this file. +// (There will be a note indicating why). + +// std and core are both tested because they may contain separate +// implementations for some macro_rules! macros as an implementation +// detail. + +// ignore-pretty issue #37195 + +// compile-flags: --test -C debug_assertions=yes +// revisions: std core + +#![cfg_attr(core, no_std)] + +#![feature(concat_idents)] + +#[cfg(std)] use std::fmt; +#[cfg(core)] use core::fmt; + +#[test] +fn assert() { + assert!(true); + assert!(true,); + assert!(true, "hello"); + assert!(true, "hello",); + assert!(true, "hello {}", "world"); + assert!(true, "hello {}", "world",); +} + +#[test] +fn assert_eq() { + assert_eq!(1, 1); + assert_eq!(1, 1,); + assert_eq!(1, 1, "hello"); + assert_eq!(1, 1, "hello",); + assert_eq!(1, 1, "hello {}", "world"); + assert_eq!(1, 1, "hello {}", "world",); +} + +#[test] +fn assert_ne() { + assert_ne!(1, 2); + assert_ne!(1, 2,); + assert_ne!(1, 2, "hello"); + assert_ne!(1, 2, "hello",); + assert_ne!(1, 2, "hello {}", "world"); + assert_ne!(1, 2, "hello {}", "world",); +} + +#[test] +fn cfg() { + let _ = cfg!(pants); + let _ = cfg!(pants,); + let _ = cfg!(pants = "pants"); + let _ = cfg!(pants = "pants",); + let _ = cfg!(all(pants)); + let _ = cfg!(all(pants),); + let _ = cfg!(all(pants,)); + let _ = cfg!(all(pants,),); +} + +#[test] +fn column() { + let _ = column!(); +} + +// compile_error! is in a companion to this test in compile-fail + +#[test] +fn concat() { + let _ = concat!(); + let _ = concat!("hello"); + let _ = concat!("hello",); + let _ = concat!("hello", " world"); + let _ = concat!("hello", " world",); +} + +#[test] +fn concat_idents() { + fn foo() {} + fn foobar() {} + + concat_idents!(foo)(); + concat_idents!(foo,)(); + concat_idents!(foo, bar)(); + concat_idents!(foo, bar,)(); +} + +#[test] +fn debug_assert() { + debug_assert!(true); + debug_assert!(true, ); + debug_assert!(true, "hello"); + debug_assert!(true, "hello",); + debug_assert!(true, "hello {}", "world"); + debug_assert!(true, "hello {}", "world",); +} + +#[test] +fn debug_assert_eq() { + debug_assert_eq!(1, 1); + debug_assert_eq!(1, 1,); + debug_assert_eq!(1, 1, "hello"); + debug_assert_eq!(1, 1, "hello",); + debug_assert_eq!(1, 1, "hello {}", "world"); + debug_assert_eq!(1, 1, "hello {}", "world",); +} + +#[test] +fn debug_assert_ne() { + debug_assert_ne!(1, 2); + debug_assert_ne!(1, 2,); + debug_assert_ne!(1, 2, "hello"); + debug_assert_ne!(1, 2, "hello",); + debug_assert_ne!(1, 2, "hello {}", "world"); + debug_assert_ne!(1, 2, "hello {}", "world",); +} + +#[test] +fn env() { + let _ = env!("PATH"); + let _ = env!("PATH",); + let _ = env!("PATH", "not found"); + let _ = env!("PATH", "not found",); +} + +#[cfg(std)] +#[test] +fn eprint() { + eprint!("hello"); + eprint!("hello",); + eprint!("hello {}", "world"); + eprint!("hello {}", "world",); +} + +#[cfg(std)] +#[test] +fn eprintln() { + eprintln!(); + eprintln!("hello"); + eprintln!("hello",); + eprintln!("hello {}", "world"); + eprintln!("hello {}", "world",); +} + +#[test] +fn file() { + let _ = file!(); +} + +#[cfg(std)] +#[test] +fn format() { + let _ = format!("hello"); + let _ = format!("hello",); + let _ = format!("hello {}", "world"); + let _ = format!("hello {}", "world",); +} + +#[test] +fn format_args() { + let _ = format_args!("hello"); + let _ = format_args!("hello",); + let _ = format_args!("hello {}", "world"); + let _ = format_args!("hello {}", "world",); +} + +#[test] +fn include() { + let _ = include!("auxiliary/macro-comma-support.rs"); + let _ = include!("auxiliary/macro-comma-support.rs",); +} + +#[test] +fn include_bytes() { + let _ = include_bytes!("auxiliary/macro-comma-support.rs"); + let _ = include_bytes!("auxiliary/macro-comma-support.rs",); +} + +#[test] +fn include_str() { + let _ = include_str!("auxiliary/macro-comma-support.rs"); + let _ = include_str!("auxiliary/macro-comma-support.rs",); +} + +#[test] +fn line() { + let _ = line!(); +} + +#[test] +fn module_path() { + let _ = module_path!(); +} + +#[test] +fn option_env() { + let _ = option_env!("PATH"); + let _ = option_env!("PATH",); +} + +#[test] +fn panic() { + // prevent 'unreachable code' warnings + let falsum = || false; + + if falsum() { panic!(); } + if falsum() { panic!("hello"); } + if falsum() { panic!("hello",); } + if falsum() { panic!("hello {}", "world"); } + if falsum() { panic!("hello {}", "world",); } +} + +#[cfg(std)] +#[test] +fn print() { + print!("hello"); + print!("hello",); + print!("hello {}", "world"); + print!("hello {}", "world",); +} + +#[cfg(std)] +#[test] +fn println() { + println!(); + println!("hello"); + println!("hello",); + println!("hello {}", "world"); + println!("hello {}", "world",); +} + +// select! is too troublesome and unlikely to be stabilized + +// stringify! is N/A + +#[cfg(std)] +#[test] +fn thread_local() { + // this has an optional trailing *semicolon* + thread_local! { + #[allow(unused)] pub static A: () = () + } + + thread_local! { + #[allow(unused)] pub static AA: () = (); + } + + thread_local! { + #[allow(unused)] pub static AAA: () = (); + #[allow(unused)] pub static AAAA: () = () + } + + thread_local! { + #[allow(unused)] pub static AAAAG: () = (); + #[allow(unused)] pub static AAAAGH: () = (); + } +} + +#[test] +fn try() { + fn inner() -> Result<(), ()> { + try!(Ok(())); + try!(Ok(()),); + Ok(()) + } + + inner().unwrap(); +} + +#[test] +fn unimplemented() { + // prevent 'unreachable code' warnings + let falsum = || false; + + if falsum() { unimplemented!(); } + if falsum() { unimplemented!("hello"); } + if falsum() { unimplemented!("hello",); } + if falsum() { unimplemented!("hello {}", "world"); } + if falsum() { unimplemented!("hello {}", "world",); } +} + +#[test] +fn unreachable() { + // prevent 'unreachable code' warnings + let falsum = || false; + + if falsum() { unreachable!(); } + if falsum() { unreachable!("hello"); } + if falsum() { unreachable!("hello",); } + if falsum() { unreachable!("hello {}", "world"); } + if falsum() { unreachable!("hello {}", "world",); } +} + +#[cfg(std)] +#[test] +fn vec() { + let _: Vec<()> = vec![]; + let _ = vec![0]; + let _ = vec![0,]; + let _ = vec![0, 1]; + let _ = vec![0, 1,]; +} + +// give a test body access to a fmt::Formatter, which seems +// to be the easiest way to use 'write!' on core. +macro_rules! test_with_formatter { + ( + #[test] + fn $fname:ident($f:ident: &mut fmt::Formatter) $block:block + ) => { + #[test] + fn $fname() { + struct Struct; + impl fmt::Display for Struct { + fn fmt(&self, $f: &mut fmt::Formatter) -> fmt::Result { + Ok($block) + } + } + + // suppress "unused" + assert!(true, "{}", Struct); + } + }; +} + +test_with_formatter! { + #[test] + fn write(f: &mut fmt::Formatter) { + let _ = write!(f, "hello"); + let _ = write!(f, "hello",); + let _ = write!(f, "hello {}", "world"); + let _ = write!(f, "hello {}", "world",); + } +} + +test_with_formatter! { + #[test] + fn writeln(f: &mut fmt::Formatter) { + let _ = writeln!(f); + let _ = writeln!(f,); + let _ = writeln!(f, "hello"); + let _ = writeln!(f, "hello",); + let _ = writeln!(f, "hello {}", "world"); + let _ = writeln!(f, "hello {}", "world",); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-crate-def-only.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-crate-def-only.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-crate-def-only.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-crate-def-only.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:macro_crate_def_only.rs + + +#[macro_use] #[no_link] +extern crate macro_crate_def_only; + +pub fn main() { + assert_eq!(5, make_a_5!()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-crate-nonterminal-renamed.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-crate-nonterminal-renamed.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-crate-nonterminal-renamed.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-crate-nonterminal-renamed.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:macro_crate_nonterminal.rs + +#[macro_use] +extern crate macro_crate_nonterminal as new_name; + +pub fn main() { + new_name::check_local(); + assert_eq!(increment!(5), 6); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-crate-nonterminal.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-crate-nonterminal.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-crate-nonterminal.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-crate-nonterminal.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:macro_crate_nonterminal.rs + +#[macro_use] +extern crate macro_crate_nonterminal; + +pub fn main() { + macro_crate_nonterminal::check_local(); + assert_eq!(increment!(5), 6); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-crate-use.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-crate-use.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-crate-use.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-crate-use.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn increment(x: usize) -> usize { + x + 1 +} + +#[macro_export] +macro_rules! increment { + ($x:expr) => ({ + use $crate::increment; + increment($x) + }) +} + +fn main() { + assert_eq!(increment!(3), 4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-deep_expansion.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-deep_expansion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-deep_expansion.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-deep_expansion.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +macro_rules! foo2 { + () => { + "foo" + } +} + +macro_rules! foo { + () => { + foo2!() + } +} + +fn main() { + assert_eq!(concat!(foo!(), "bar"), "foobar") +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-delimiter-significance.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-delimiter-significance.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-delimiter-significance.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-delimiter-significance.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + vec![1_usize, 2, 3].len(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-doc-comments.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-doc-comments.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-doc-comments.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-doc-comments.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_snake_case)] + +macro_rules! doc { + ( + $(#[$outer:meta])* + mod $i:ident { + $(#![$inner:meta])* + } + ) => + ( + $(#[$outer])* + pub mod $i { + $(#![$inner])* + } + ) +} + +doc! { + /// Outer doc + mod Foo { + //! Inner doc + } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-doc-escapes.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-doc-escapes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-doc-escapes.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-doc-escapes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// When expanding a macro, documentation attributes (including documentation comments) must be +// passed "as is" without being parsed. Otherwise, some text will be incorrectly interpreted as +// escape sequences, leading to an ICE. +// +// Related issues: #25929, #25943 + +macro_rules! homura { + (#[$x:meta]) => () +} + +homura! { + /// \madoka \x41 +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-doc-raw-str-hashes.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-doc-raw-str-hashes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-doc-raw-str-hashes.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-doc-raw-str-hashes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// The number of `#`s used to wrap the documentation comment should differ regarding the content. +// +// Related issue: #27489 + +macro_rules! homura { + ($x:expr, #[$y:meta]) => (assert_eq!($x, stringify!($y))) +} + +fn main() { + homura! { + r#"doc = r" Madoka""#, + /// Madoka + }; + + homura! { + r##"doc = r#" One quote mark: ["]"#"##, + /// One quote mark: ["] + }; + + homura! { + r##"doc = r#" Two quote marks: [""]"#"##, + /// Two quote marks: [""] + }; + + homura! { + r#####"doc = r####" Raw string ending sequences: ["###]"####"#####, + /// Raw string ending sequences: ["###] + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-export-inner-module.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-export-inner-module.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-export-inner-module.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-export-inner-module.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +//aux-build:macro_export_inner_module.rs + +#[macro_use] #[no_link] +extern crate macro_export_inner_module; + +pub fn main() { + assert_eq!(1, foo!()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-first-set.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-first-set.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-first-set.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-first-set.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,288 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +//{{{ issue 40569 ============================================================== + +macro_rules! my_struct { + ($(#[$meta:meta])* $ident:ident) => { + $(#[$meta])* struct $ident; + } +} + +my_struct!(#[derive(Debug, PartialEq)] Foo40569); + +fn test_40569() { + assert_eq!(Foo40569, Foo40569); +} + +//}}} + +//{{{ issue 26444 ============================================================== + +macro_rules! foo_26444 { + ($($beginning:ident),*; $middle:ident; $($end:ident),*) => { + stringify!($($beginning,)* $middle $(,$end)*) + } +} + +fn test_26444() { + assert_eq!("a , b , c , d , e", foo_26444!(a, b; c; d, e)); + assert_eq!("f", foo_26444!(; f ;)); +} + +macro_rules! pat_26444 { + ($fname:ident $($arg:pat)* =) => {} +} + +pat_26444!(foo 1 2 5...7 =); +pat_26444!(bar Some(ref x) Ok(ref mut y) &(w, z) =); + +//}}} + +//{{{ issue 40984 ============================================================== + +macro_rules! thread_local_40984 { + () => {}; + ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr; $($rest:tt)*) => { + thread_local_40984!($($rest)*); + }; + ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr) => {}; +} + +thread_local_40984! { + // no docs + #[allow(unused)] + static FOO: i32 = 42; + /// docs + pub static BAR: String = String::from("bar"); + + // look at these restrictions!! + pub(crate) static BAZ: usize = 0; + pub(in foo) static QUUX: usize = 0; +} + +//}}} + +//{{{ issue 35650 ============================================================== + +macro_rules! size { + ($ty:ty) => { + std::mem::size_of::<$ty>() + }; + ($size:tt) => { + $size + }; +} + +fn test_35650() { + assert_eq!(size!(u64), 8); + assert_eq!(size!(5), 5); +} + +//}}} + +//{{{ issue 27832 ============================================================== + +macro_rules! m { + ( $i:ident ) => (); + ( $t:tt $j:tt ) => (); +} + +m!(c); +m!(t 9); +m!(0 9); +m!(struct); +m!(struct Foo); + +macro_rules! m2 { + ( $b:expr ) => (); + ( $t:tt $u:tt ) => (); +} + +m2!(3); +m2!(1 2); +m2!(_ 1); +m2!(enum Foo); + +//}}} + +//{{{ issue 39964 ============================================================== + +macro_rules! foo_39964 { + ($a:ident) => {}; + (_) => {}; +} + +foo_39964!(_); + +//}}} + +//{{{ issue 34030 ============================================================== + +macro_rules! foo_34030 { + ($($t:ident),* /) => {}; +} + +foo_34030!(a, b/); +foo_34030!(a/); +foo_34030!(/); + +//}}} + +//{{{ issue 24189 ============================================================== + +macro_rules! foo_24189 { + ( + pub enum $name:ident { + $( #[$attr:meta] )* $var:ident + } + ) => { + pub enum $name { + $( #[$attr] )* $var + } + }; +} + +foo_24189! { + pub enum Foo24189 { + #[doc = "Bar"] Baz + } +} + +macro_rules! serializable { + ( + $(#[$struct_meta:meta])* + pub struct $name:ident { + $( + $(#[$field_meta:meta])* + $field:ident: $type_:ty + ),* , + } + ) => { + $(#[$struct_meta])* + pub struct $name { + $( + $(#[$field_meta])* + $field: $type_ + ),* , + } + } +} + +serializable! { + #[allow(dead_code)] + /// This is a test + pub struct Tester { + #[allow(dead_code)] + name: String, + } +} + +macro_rules! foo_24189_c { + ( $( > )* $x:ident ) => { }; +} +foo_24189_c!( > a ); + +fn test_24189() { + let _ = Foo24189::Baz; + let _ = Tester { name: "".to_owned() }; +} + +//}}} + +//{{{ issue 50903 ============================================================== + +macro_rules! foo_50903 { + ($($lif:lifetime ,)* #) => {}; +} + +foo_50903!('a, 'b, #); +foo_50903!('a, #); +foo_50903!(#); + +//}}} + +//{{{ issue 51477 ============================================================== + +macro_rules! foo_51477 { + ($lifetime:lifetime) => { + "last token is lifetime" + }; + ($other:tt) => { + "last token is other" + }; + ($first:tt $($rest:tt)*) => { + foo_51477!($($rest)*) + }; +} + +fn test_51477() { + assert_eq!("last token is lifetime", foo_51477!('a)); + assert_eq!("last token is other", foo_51477!(@)); + assert_eq!("last token is lifetime", foo_51477!(@ {} 'a)); +} + +//}}} + +//{{{ some more tests ========================================================== + +macro_rules! test_block { + (< $($b:block)* >) => {} +} + +test_block!(<>); +test_block!(<{}>); +test_block!(<{1}{2}>); + +macro_rules! test_ty { + ($($t:ty),* $(,)*) => {} +} + +test_ty!(); +test_ty!(,); +test_ty!(u8); +test_ty!(u8,); + +macro_rules! test_path { + ($($t:path),* $(,)*) => {} +} + +test_path!(); +test_path!(,); +test_path!(::std); +test_path!(std::u8,); +test_path!(any, super, super::super::self::path, X::Z<'a, T=U>); + +macro_rules! test_meta_block { + ($($m:meta)* $b:block) => {}; +} + +test_meta_block!(windows {}); + +macro_rules! test_lifetime { + (1. $($l:lifetime)* $($b:block)*) => {}; + (2. $($b:block)* $($l:lifetime)*) => {}; +} + +test_lifetime!(1. 'a 'b {} {}); +test_lifetime!(2. {} {} 'a 'b); + +//}}} + +fn main() { + test_26444(); + test_40569(); + test_35650(); + test_24189(); + test_51477(); +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-followed-by-seq.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-followed-by-seq.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-followed-by-seq.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-followed-by-seq.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_macros)] +// Regression test for issue #25436: check that things which can be +// followed by any token also permit X* to come afterwards. + +macro_rules! foo { + ( $a:tt $($b:tt)* ) => { }; + ( $a:ident $($b:tt)* ) => { }; + ( $a:item $($b:tt)* ) => { }; + ( $a:block $($b:tt)* ) => { }; + ( $a:meta $($b:tt)* ) => { } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-follow.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-follow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-follow.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-follow.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,194 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_macros)] +// Check the macro follow sets (see corresponding cfail test). + +// FOLLOW(pat) = {FatArrow, Comma, Eq, Or, Ident(if), Ident(in)} +macro_rules! follow_pat { + ($p:pat =>) => {}; + ($p:pat ,) => {}; + ($p:pat =) => {}; + ($p:pat |) => {}; + ($p:pat if) => {}; + ($p:pat in) => {}; +} +// FOLLOW(expr) = {FatArrow, Comma, Semicolon} +macro_rules! follow_expr { + ($e:expr =>) => {}; + ($e:expr ,) => {}; + ($e:expr ;) => {}; +} +// FOLLOW(ty) = {OpenDelim(Brace), Comma, FatArrow, Colon, Eq, Gt, Semi, Or, +// Ident(as), Ident(where), OpenDelim(Bracket), Nonterminal(Block)} +macro_rules! follow_ty { + ($t:ty {}) => {}; + ($t:ty ,) => {}; + ($t:ty =>) => {}; + ($t:ty :) => {}; + ($t:ty =) => {}; + ($t:ty >) => {}; + ($t:ty ;) => {}; + ($t:ty |) => {}; + ($t:ty as) => {}; + ($t:ty where) => {}; + ($t:ty []) => {}; + ($t:ty $b:block) => {}; +} +// FOLLOW(stmt) = FOLLOW(expr) +macro_rules! follow_stmt { + ($s:stmt =>) => {}; + ($s:stmt ,) => {}; + ($s:stmt ;) => {}; +} +// FOLLOW(path) = FOLLOW(ty) +macro_rules! follow_path { + ($p:path {}) => {}; + ($p:path ,) => {}; + ($p:path =>) => {}; + ($p:path :) => {}; + ($p:path =) => {}; + ($p:path >) => {}; + ($p:path ;) => {}; + ($p:path |) => {}; + ($p:path as) => {}; + ($p:path where) => {}; + ($p:path []) => {}; + ($p:path $b:block) => {}; +} +// FOLLOW(block) = any token +macro_rules! follow_block { + ($b:block ()) => {}; + ($b:block []) => {}; + ($b:block {}) => {}; + ($b:block ,) => {}; + ($b:block =>) => {}; + ($b:block :) => {}; + ($b:block =) => {}; + ($b:block >) => {}; + ($b:block ;) => {}; + ($b:block |) => {}; + ($b:block +) => {}; + ($b:block ident) => {}; + ($b:block $p:pat) => {}; + ($b:block $e:expr) => {}; + ($b:block $t:ty) => {}; + ($b:block $s:stmt) => {}; + ($b:block $p:path) => {}; + ($b:block $b:block) => {}; + ($b:block $i:ident) => {}; + ($b:block $t:tt) => {}; + ($b:block $i:item) => {}; + ($b:block $m:meta) => {}; +} +// FOLLOW(ident) = any token +macro_rules! follow_ident { + ($i:ident ()) => {}; + ($i:ident []) => {}; + ($i:ident {}) => {}; + ($i:ident ,) => {}; + ($i:ident =>) => {}; + ($i:ident :) => {}; + ($i:ident =) => {}; + ($i:ident >) => {}; + ($i:ident ;) => {}; + ($i:ident |) => {}; + ($i:ident +) => {}; + ($i:ident ident) => {}; + ($i:ident $p:pat) => {}; + ($i:ident $e:expr) => {}; + ($i:ident $t:ty) => {}; + ($i:ident $s:stmt) => {}; + ($i:ident $p:path) => {}; + ($i:ident $b:block) => {}; + ($i:ident $i:ident) => {}; + ($i:ident $t:tt) => {}; + ($i:ident $i:item) => {}; + ($i:ident $m:meta) => {}; +} +// FOLLOW(tt) = any token +macro_rules! follow_tt { + ($t:tt ()) => {}; + ($t:tt []) => {}; + ($t:tt {}) => {}; + ($t:tt ,) => {}; + ($t:tt =>) => {}; + ($t:tt :) => {}; + ($t:tt =) => {}; + ($t:tt >) => {}; + ($t:tt ;) => {}; + ($t:tt |) => {}; + ($t:tt +) => {}; + ($t:tt ident) => {}; + ($t:tt $p:pat) => {}; + ($t:tt $e:expr) => {}; + ($t:tt $t:ty) => {}; + ($t:tt $s:stmt) => {}; + ($t:tt $p:path) => {}; + ($t:tt $b:block) => {}; + ($t:tt $i:ident) => {}; + ($t:tt $t:tt) => {}; + ($t:tt $i:item) => {}; + ($t:tt $m:meta) => {}; +} +// FOLLOW(item) = any token +macro_rules! follow_item { + ($i:item ()) => {}; + ($i:item []) => {}; + ($i:item {}) => {}; + ($i:item ,) => {}; + ($i:item =>) => {}; + ($i:item :) => {}; + ($i:item =) => {}; + ($i:item >) => {}; + ($i:item ;) => {}; + ($i:item |) => {}; + ($i:item +) => {}; + ($i:item ident) => {}; + ($i:item $p:pat) => {}; + ($i:item $e:expr) => {}; + ($i:item $t:ty) => {}; + ($i:item $s:stmt) => {}; + ($i:item $p:path) => {}; + ($i:item $b:block) => {}; + ($i:item $i:ident) => {}; + ($i:item $t:tt) => {}; + ($i:item $i:item) => {}; + ($i:item $m:meta) => {}; +} +// FOLLOW(meta) = any token +macro_rules! follow_meta { + ($m:meta ()) => {}; + ($m:meta []) => {}; + ($m:meta {}) => {}; + ($m:meta ,) => {}; + ($m:meta =>) => {}; + ($m:meta :) => {}; + ($m:meta =) => {}; + ($m:meta >) => {}; + ($m:meta ;) => {}; + ($m:meta |) => {}; + ($m:meta +) => {}; + ($m:meta ident) => {}; + ($m:meta $p:pat) => {}; + ($m:meta $e:expr) => {}; + ($m:meta $t:ty) => {}; + ($m:meta $s:stmt) => {}; + ($m:meta $p:path) => {}; + ($m:meta $b:block) => {}; + ($m:meta $i:ident) => {}; + ($m:meta $t:tt) => {}; + ($m:meta $i:item) => {}; + ($m:meta $m:meta) => {}; +} + +fn main() {} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-include-items.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-include-items.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-include-items.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-include-items.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +// ignore-pretty issue #37195 + +fn bar() {} + +include!(concat!("", "", "auxiliary/", "macro-include-items-item.rs")); + +fn main() { + foo(); + assert_eq!(include!(concat!("", "auxiliary/", "macro-include-items-expr.rs")), 1_usize); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-interpolation.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-interpolation.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-interpolation.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-interpolation.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +macro_rules! overly_complicated { + ($fnname:ident, $arg:ident, $ty:ty, $body:block, $val:expr, $pat:pat, $res:path) => + ({ + fn $fnname($arg: $ty) -> Option<$ty> $body + match $fnname($val) { + Some($pat) => { + $res + } + _ => { panic!(); } + } + }) + +} + +pub fn main() { + assert!(overly_complicated!(f, x, Option, { return Some(x); }, + Some(8), Some(y), y) == 8) + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-invocation-in-count-expr-fixed-array-type.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-invocation-in-count-expr-fixed-array-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-invocation-in-count-expr-fixed-array-type.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-invocation-in-count-expr-fixed-array-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +macro_rules! four { + () => (4) +} + +fn main() { + let _x: [u16; four!()]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-lifetime.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-lifetime.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-lifetime.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-lifetime.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +macro_rules! foo { + ($l:lifetime) => { + fn f<$l>(arg: &$l str) -> &$l str { + arg + } + } +} + +pub fn main() { + foo!('a); + let x: &'static str = f("hi"); + assert_eq!("hi", x); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-lifetime-used-with-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-lifetime-used-with-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-lifetime-used-with-bound.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-lifetime-used-with-bound.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +macro_rules! foo { + ($l:lifetime, $l2:lifetime) => { + fn f<$l: $l2, $l2>(arg: &$l str, arg2: &$l2 str) -> &$l str { + arg + } + } +} + +pub fn main() { + foo!('a, 'b); + let x: &'static str = f("hi", "there"); + assert_eq!("hi", x); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-lifetime-used-with-labels.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-lifetime-used-with-labels.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-lifetime-used-with-labels.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-lifetime-used-with-labels.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(stable_features)] + +#![allow(unreachable_code)] + +macro_rules! x { + ($a:lifetime) => { + $a: loop { + break $a; + panic!("failed"); + } + } +} +macro_rules! br { + ($a:lifetime) => { + break $a; + } +} +macro_rules! br2 { + ($b:lifetime) => { + 'b: loop { + break $b; // this $b should refer to the outer loop. + } + } +} +fn main() { + x!('a); + 'c: loop { + br!('c); + panic!("failed"); + } + 'b: loop { + br2!('b); + panic!("failed"); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-lifetime-used-with-labels.stderr rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-lifetime-used-with-labels.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-lifetime-used-with-labels.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-lifetime-used-with-labels.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +warning: label name `'b` shadows a label name that is already in scope + --> $DIR/macro-lifetime-used-with-labels.rs:31:9 + | +LL | 'b: loop { + | ^^ lifetime 'b already in scope +... +LL | 'b: loop { + | -- first declared here +LL | br2!('b); + | --------- in this macro invocation + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-lifetime-used-with-static.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-lifetime-used-with-static.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-lifetime-used-with-static.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-lifetime-used-with-static.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +macro_rules! foo { + ($l:lifetime) => { + fn f(arg: &$l str) -> &$l str { + arg + } + } +} + +pub fn main() { + foo!('static); + let x: &'static str = f("hi"); + assert_eq!("hi", x); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-literal.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-literal.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-literal.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-literal.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,144 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(macro_literal_matcher)] + +macro_rules! mtester { + ($l:literal) => { + &format!("macro caught literal: {}", $l) + }; + ($e:expr) => { + &format!("macro caught expr: {}", $e) + }; +} + +macro_rules! two_negative_literals { + ($l1:literal $l2:literal) => { + &format!("macro caught literals: {}, {}", $l1, $l2) + }; +} + +macro_rules! only_expr { + ($e:expr) => { + &format!("macro caught expr: {}", $e) + }; +} + +macro_rules! mtester_dbg { + ($l:literal) => { + &format!("macro caught literal: {:?}", $l) + }; + ($e:expr) => { + &format!("macro caught expr: {:?}", $e) + }; +} + +macro_rules! catch_range { + ($s:literal ..= $e:literal) => { + &format!("macro caught literal: {} ..= {}", $s, $e) + }; + (($s:expr) ..= ($e:expr)) => { // Must use ')' before '..=' + &format!("macro caught expr: {} ..= {}", $s, $e) + }; +} + +macro_rules! pat_match { + ($s:literal ..= $e:literal) => { + match 3 { + $s ..= $e => "literal, in range", + _ => "literal, other", + } + }; + ($s:pat) => { + match 3 { + $s => "pat, single", + _ => "pat, other", + } + }; +} + +macro_rules! match_attr { + (#[$attr:meta] $e:literal) => { + "attr matched literal" + }; + (#[$attr:meta] $e:expr) => { + "attr matched expr" + }; +} + +macro_rules! match_produced_attr { + ($lit: literal) => { + // Struct with doc comment passed via $literal + #[doc = $lit] + struct LiteralProduced; + }; + ($expr: expr) => { + struct ExprProduced; + }; +} + +macro_rules! test_user { + ($s:literal, $e:literal) => { + { + let mut v = Vec::new(); + for i in $s .. $e { + v.push(i); + } + "literal" + } + }; + ($s:expr, $e: expr) => { + { + let mut v = Vec::new(); + for i in $s .. $e { + v.push(i); + } + "expr" + } + }; +} + +pub fn main() { + // Cases where 'literal' catches + assert_eq!(mtester!("str"), "macro caught literal: str"); + assert_eq!(mtester!(2), "macro caught literal: 2"); + assert_eq!(mtester!(2.2), "macro caught literal: 2.2"); + assert_eq!(mtester!(1u32), "macro caught literal: 1"); + assert_eq!(mtester!(0x32), "macro caught literal: 50"); + assert_eq!(mtester!('c'), "macro caught literal: c"); + assert_eq!(mtester!(-1.2), "macro caught literal: -1.2"); + assert_eq!(two_negative_literals!(-2 -3), "macro caught literals: -2, -3"); + assert_eq!(catch_range!(2 ..= 3), "macro caught literal: 2 ..= 3"); + assert_eq!(match_attr!(#[attr] 1), "attr matched literal"); + assert_eq!(test_user!(10, 20), "literal"); + assert_eq!(mtester!(false), "macro caught literal: false"); + assert_eq!(mtester!(true), "macro caught literal: true"); + match_produced_attr!("a"); + let _a = LiteralProduced; + assert_eq!(pat_match!(1 ..= 3), "literal, in range"); + assert_eq!(pat_match!(4 ..= 6), "literal, other"); + + // Cases where 'expr' catches + assert_eq!(mtester!((-1.2)), "macro caught expr: -1.2"); + assert_eq!(only_expr!(-1.2), "macro caught expr: -1.2"); + assert_eq!(mtester!((1 + 3)), "macro caught expr: 4"); + assert_eq!(mtester_dbg!(()), "macro caught expr: ()"); + assert_eq!(catch_range!((1 + 1) ..= (2 + 2)), "macro caught expr: 2 ..= 4"); + assert_eq!(match_attr!(#[attr] (1 + 2)), "attr matched expr"); + assert_eq!(test_user!(10, (20 + 2)), "expr"); + + match_produced_attr!((3 + 2)); + let _b = ExprProduced; + + // Cases where 'pat' matched + assert_eq!(pat_match!(3), "pat, single"); + assert_eq!(pat_match!(6), "pat, other"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-meta-items.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-meta-items.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-meta-items.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-meta-items.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// compile-flags: --cfg foo + +macro_rules! compiles_fine { + ($at:meta) => { + #[cfg($at)] + static MISTYPED: () = "foo"; + } +} +macro_rules! emit { + ($at:meta) => { + #[cfg($at)] + static MISTYPED: &'static str = "foo"; + } +} + +// item +compiles_fine!(bar); +emit!(foo); + +fn foo() { + println!("{}", MISTYPED); +} + +pub fn main() { + // statement + compiles_fine!(baz); + emit!(baz); + println!("{}", MISTYPED); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-method-issue-4621.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-method-issue-4621.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-method-issue-4621.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-method-issue-4621.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +struct A; + +macro_rules! make_thirteen_method {() => (fn thirteen(&self)->isize {13})} +impl A { make_thirteen_method!(); } + +fn main() { + assert_eq!(A.thirteen(),13); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-multiple-items.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-multiple-items.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-multiple-items.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-multiple-items.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +macro_rules! make_foo { + () => ( + struct Foo; + + impl Foo { + fn bar(&self) {} + } + ) +} + +make_foo!(); + +pub fn main() { + Foo.bar() +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-named-default.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-named-default.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-named-default.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-named-default.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +macro_rules! default { + ($($x:tt)*) => { $($x)* } +} + +default! { + struct A; +} + +impl A { + default! { + fn foo(&self) {} + } +} + +fn main() { + A.foo(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-nested_definition_issue-31946.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-nested_definition_issue-31946.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-nested_definition_issue-31946.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-nested_definition_issue-31946.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + println!("{}", { + macro_rules! foo { + ($name:expr) => { concat!("hello ", $name) } + } + foo!("rust") + }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-nested_expr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-nested_expr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-nested_expr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-nested_expr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// #42164 + +#![feature(decl_macro)] +#![allow(dead_code)] + +pub macro m($inner_str:expr) { + #[doc = $inner_str] + struct S; +} + +macro_rules! define_f { + ($name:expr) => { + #[export_name = $name] + fn f() {} + } +} + +fn main() { + define_f!(concat!("exported_", "f")); + m!(stringify!(foo)); +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-nested_stmt_macros.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-nested_stmt_macros.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-nested_stmt_macros.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-nested_stmt_macros.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +macro_rules! foo { + () => { + struct Bar; + struct Baz; + } +} + +macro_rules! grault { + () => { + foo!(); + struct Xyzzy; + } +} + +fn static_assert_exists() { } + +fn main() { + grault!(); + static_assert_exists::(); + static_assert_exists::(); + static_assert_exists::(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-nt-list.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-nt-list.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-nt-list.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-nt-list.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +macro_rules! list { + ( ($($id:ident),*) ) => (()); + ( [$($id:ident),*] ) => (()); + ( {$($id:ident),*} ) => (()); +} + +macro_rules! tt_list { + ( ($($tt:tt),*) ) => (()); +} + +pub fn main() { + list!( () ); + list!( [] ); + list!( {} ); + + tt_list!( (a, b, c) ); + tt_list!( () ); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-of-higher-order.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-of-higher-order.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-of-higher-order.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-of-higher-order.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +macro_rules! higher_order { + (subst $lhs:tt => $rhs:tt) => ({ + macro_rules! anon { $lhs => $rhs } + anon!(1_usize, 2_usize, "foo") + }); +} + +macro_rules! outer { + ($x:expr; $fragment:ident) => { + macro_rules! inner { ($y:$fragment) => { $x + $y } } + } +} + +fn main() { + let val = higher_order!(subst ($x:expr, $y:expr, $foo:expr) => (($x + $y, $foo))); + assert_eq!(val, (3, "foo")); + + outer!(2; expr); + assert_eq!(inner!(3), 5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-pat-follow.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-pat-follow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-pat-follow.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-pat-follow.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +macro_rules! pat_in { + ($p:pat in $e:expr) => {{ + let mut iter = $e.into_iter(); + while let $p = iter.next() {} + }} +} + +macro_rules! pat_if { + ($p:pat if $e:expr) => {{ + match Some(1u8) { + $p if $e => {}, + _ => {} + } + }} +} + +macro_rules! pat_bar { + ($p:pat | $p2:pat) => {{ + match Some(1u8) { + $p | $p2 => {}, + _ => {} + } + }} +} + +fn main() { + pat_in!(Some(_) in 0..10); + pat_if!(Some(x) if x > 0); + pat_bar!(Some(1u8) | None); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-path.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-path.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-path.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-path.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + + +mod m { + pub type t = isize; +} + +macro_rules! foo { + ($p:path) => ({ + fn f() -> $p { 10 }; + f() + }) +} + +pub fn main() { + assert_eq!(foo!(m::t), 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-pat-neg-lit.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-pat-neg-lit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-pat-neg-lit.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-pat-neg-lit.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +macro_rules! enum_number { + ($name:ident { $($variant:ident = $value:expr, )* }) => { + enum $name { + $($variant = $value,)* + } + + fn foo(value: i32) -> Option<$name> { + match value { + $( $value => Some($name::$variant), )* + _ => None + } + } + } +} + +enum_number!(Change { + Down = -1, + None = 0, + Up = 1, +}); + +fn main() { + if let Some(Change::Down) = foo(-1) {} else { panic!() } +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-pat.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-pat.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-pat.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-pat.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,75 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +macro_rules! mypat { + () => ( + Some('y') + ) +} + +macro_rules! char_x { + () => ( + 'x' + ) +} + +macro_rules! some { + ($x:pat) => ( + Some($x) + ) +} + +macro_rules! indirect { + () => ( + some!(char_x!()) + ) +} + +macro_rules! ident_pat { + ($x:ident) => ( + $x + ) +} + +fn f(c: Option) -> usize { + match c { + Some('x') => 1, + mypat!() => 2, + _ => 3, + } +} + +pub fn main() { + assert_eq!(1, f(Some('x'))); + assert_eq!(2, f(Some('y'))); + assert_eq!(3, f(None)); + + assert_eq!(1, match Some('x') { + Some(char_x!()) => 1, + _ => 2, + }); + + assert_eq!(1, match Some('x') { + some!(char_x!()) => 1, + _ => 2, + }); + + assert_eq!(1, match Some('x') { + indirect!() => 1, + _ => 2, + }); + + assert_eq!(3, { + let ident_pat!(x) = 2; + x+1 + }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-pub-matcher.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-pub-matcher.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-pub-matcher.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-pub-matcher.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,128 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code, unused_imports)] +#![feature(crate_visibility_modifier)] + +/** +Ensure that `:vis` matches can be captured in existing positions, and passed +through without the need for reparse tricks. +*/ +macro_rules! vis_passthru { + ($vis:vis const $name:ident: $ty:ty = $e:expr;) => { $vis const $name: $ty = $e; }; + ($vis:vis enum $name:ident {}) => { $vis struct $name {} }; + ($vis:vis extern "C" fn $name:ident() {}) => { $vis extern "C" fn $name() {} }; + ($vis:vis fn $name:ident() {}) => { $vis fn $name() {} }; + ($vis:vis mod $name:ident {}) => { $vis mod $name {} }; + ($vis:vis static $name:ident: $ty:ty = $e:expr;) => { $vis static $name: $ty = $e; }; + ($vis:vis struct $name:ident;) => { $vis struct $name; }; + ($vis:vis trait $name:ident {}) => { $vis trait $name {} }; + ($vis:vis type $name:ident = $ty:ty;) => { $vis type $name = $ty; }; + ($vis:vis use $path:ident as $name:ident;) => { $vis use self::$path as $name; }; +} + +mod with_pub { + vis_passthru! { pub const A: i32 = 0; } + vis_passthru! { pub enum B {} } + vis_passthru! { pub extern "C" fn c() {} } + vis_passthru! { pub mod d {} } + vis_passthru! { pub static E: i32 = 0; } + vis_passthru! { pub struct F; } + vis_passthru! { pub trait G {} } + vis_passthru! { pub type H = i32; } + vis_passthru! { pub use A as I; } +} + +mod without_pub { + vis_passthru! { const A: i32 = 0; } + vis_passthru! { enum B {} } + vis_passthru! { extern "C" fn c() {} } + vis_passthru! { mod d {} } + vis_passthru! { static E: i32 = 0; } + vis_passthru! { struct F; } + vis_passthru! { trait G {} } + vis_passthru! { type H = i32; } + vis_passthru! { use A as I; } +} + +mod with_pub_restricted { + vis_passthru! { pub(crate) const A: i32 = 0; } + vis_passthru! { pub(crate) enum B {} } + vis_passthru! { pub(crate) extern "C" fn c() {} } + vis_passthru! { pub(crate) mod d {} } + vis_passthru! { pub(crate) static E: i32 = 0; } + vis_passthru! { pub(crate) struct F; } + vis_passthru! { pub(crate) trait G {} } + vis_passthru! { pub(crate) type H = i32; } + vis_passthru! { pub(crate) use A as I; } +} + +mod with_crate { + vis_passthru! { crate const A: i32 = 0; } + vis_passthru! { crate enum B {} } + vis_passthru! { crate extern "C" fn c() {} } + vis_passthru! { crate mod d {} } + vis_passthru! { crate static E: i32 = 0; } + vis_passthru! { crate struct F; } + vis_passthru! { crate trait G {} } + vis_passthru! { crate type H = i32; } + vis_passthru! { crate use A as I; } +} + +mod garden { + mod with_pub_restricted_path { + vis_passthru! { pub(in garden) const A: i32 = 0; } + vis_passthru! { pub(in garden) enum B {} } + vis_passthru! { pub(in garden) extern "C" fn c() {} } + vis_passthru! { pub(in garden) mod d {} } + vis_passthru! { pub(in garden) static E: i32 = 0; } + vis_passthru! { pub(in garden) struct F; } + vis_passthru! { pub(in garden) trait G {} } + vis_passthru! { pub(in garden) type H = i32; } + vis_passthru! { pub(in garden) use A as I; } + } +} + +/* +Ensure that the `:vis` matcher works in a more complex situation: parsing a +struct definition. +*/ +macro_rules! vis_parse_struct { + ($(#[$($attrs:tt)*])* $vis:vis struct $name:ident {$($body:tt)*}) => { + vis_parse_struct! { @parse_fields $(#[$($attrs)*])*, $vis, $name, $($body)* } + }; + + ($(#[$($attrs:tt)*])* $vis:vis struct $name:ident ($($body:tt)*);) => { + vis_parse_struct! { @parse_tuple $(#[$($attrs)*])*, $vis, $name, $($body)* } + }; + + (@parse_fields + $(#[$attrs:meta])*, $vis:vis, $name:ident, $($fvis:vis $fname:ident: $fty:ty),* $(,)*) => { + $(#[$attrs])* $vis struct $name { $($fvis $fname: $fty,)* } + }; + + (@parse_tuple + $(#[$attrs:meta])*, $vis:vis, $name:ident, $($fvis:vis $fty:ty),* $(,)*) => { + $(#[$attrs])* $vis struct $name ( $($fvis $fty,)* ); + }; +} + +mod test_struct { + vis_parse_struct! { pub(crate) struct A { pub a: i32, b: i32, pub(crate) c: i32 } } + vis_parse_struct! { pub struct B { a: i32, pub(crate) b: i32, pub c: i32 } } + vis_parse_struct! { struct C { pub(crate) a: i32, pub b: i32, c: i32 } } + + vis_parse_struct! { pub(crate) struct D (pub i32, i32, pub(crate) i32); } + vis_parse_struct! { pub struct E (i32, pub(crate) i32, pub i32); } + vis_parse_struct! { struct F (pub(crate) i32, pub i32, i32); } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-seq-followed-by-seq.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-seq-followed-by-seq.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-seq-followed-by-seq.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-seq-followed-by-seq.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test of allowing two sequences repetitions in a row, +// functionality added as byproduct of RFC amendment #1384 +// https://github.com/rust-lang/rfcs/pull/1384 + +// Old version of Rust would reject this macro definition, even though +// there are no local ambiguities (the initial `banana` and `orange` +// tokens are enough for the expander to distinguish which case is +// intended). +macro_rules! foo { + ( $(banana $a:ident)* $(orange $b:tt)* ) => { }; +} + +fn main() { + foo!( banana id1 banana id2 + orange hi orange (hello world) ); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macros-in-extern.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macros-in-extern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macros-in-extern.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macros-in-extern.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-wasm32 + +#![feature(decl_macro, macros_in_extern)] + +macro_rules! returns_isize( + ($ident:ident) => ( + fn $ident() -> isize; + ) +); + +macro takes_u32_returns_u32($ident:ident) { + fn $ident (arg: u32) -> u32; +} + +macro_rules! emits_nothing( + () => () +); + +fn main() { + assert_eq!(unsafe { rust_get_test_int() }, 1isize); + assert_eq!(unsafe { rust_dbg_extern_identity_u32(0xDEADBEEF) }, 0xDEADBEEFu32); +} + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + returns_isize!(rust_get_test_int); + takes_u32_returns_u32!(rust_dbg_extern_identity_u32); + emits_nothing!(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-stability.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-stability.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-stability.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-stability.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:unstable-macros.rs + +#![feature(unstable_macros)] + +#[macro_use] extern crate unstable_macros; + +#[unstable(feature = "local_unstable", issue = "0")] +macro_rules! local_unstable { () => () } + +fn main() { + unstable_macro!(); + local_unstable!(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-stmt_macro_in_expr_macro.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-stmt_macro_in_expr_macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-stmt_macro_in_expr_macro.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-stmt_macro_in_expr_macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +macro_rules! foo { + () => { + struct Bar; + struct Baz; + } +} + +macro_rules! grault { + () => {{ + foo!(); + struct Xyzzy; + 0 + }} +} + +fn main() { + let x = grault!(); + assert_eq!(x, 0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-stmt.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-stmt.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-stmt.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-stmt.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +macro_rules! myfn { + ( $f:ident, ( $( $x:ident ),* ), $body:block ) => ( + fn $f( $( $x : isize),* ) -> isize $body + ) +} + +myfn!(add, (a,b), { return a+b; } ); + +pub fn main() { + + macro_rules! mylet { + ($x:ident, $val:expr) => ( + let $x = $val; + ) + } + + mylet!(y, 8*2); + assert_eq!(y, 16); + + myfn!(mult, (a,b), { a*b } ); + + assert_eq!(mult(2, add(4,4)), 16); + + macro_rules! actually_an_expr_macro { + () => ( 16 ) + } + + assert_eq!({ actually_an_expr_macro!() }, 16); + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-tt-followed-by-seq.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-tt-followed-by-seq.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-tt-followed-by-seq.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-tt-followed-by-seq.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for issue #25436: permit token-trees to be followed +// by sequences, enabling more general parsing. + +use self::Join::*; + +#[derive(Debug)] +enum Join { + Keep(A,B), + Skip(A,B), +} + +macro_rules! parse_list { + ( < $a:expr; > $($b:tt)* ) => { Keep(parse_item!($a),parse_list!($($b)*)) }; + ( $a:tt $($b:tt)* ) => { Skip(parse_item!($a), parse_list!($($b)*)) }; + ( ) => { () }; +} + +macro_rules! parse_item { + ( $x:expr ) => { $x } +} + +fn main() { + let list = parse_list!(<1;> 2 <3;> 4); + assert_eq!("Keep(1, Skip(2, Keep(3, Skip(4, ()))))", + format!("{:?}", list)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-use-all-and-none.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-use-all-and-none.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-use-all-and-none.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-use-all-and-none.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:two_macros.rs + +#[macro_use] +#[macro_use()] +extern crate two_macros; + +pub fn main() { + macro_one!(); + macro_two!(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-use-all-and-none.stderr rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-use-all-and-none.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-use-all-and-none.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-use-all-and-none.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +warning: unused attribute + --> $DIR/macro-use-all-and-none.rs:15:1 + | +LL | #[macro_use()] + | ^^^^^^^^^^^^^^ + | + = note: #[warn(unused_attributes)] on by default + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-use-all.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-use-all.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-use-all.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-use-all.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:two_macros.rs + +#[macro_use] +extern crate two_macros; + +pub fn main() { + macro_one!(); + macro_two!(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-use-both.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-use-both.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-use-both.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-use-both.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:two_macros.rs + +#[macro_use(macro_one, macro_two)] +extern crate two_macros; + +pub fn main() { + macro_one!(); + macro_two!(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-use-one.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-use-one.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-use-one.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-use-one.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:two_macros.rs + +#[macro_use(macro_two)] +extern crate two_macros; + +pub fn main() { + macro_two!(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-with-attrs1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-with-attrs1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-with-attrs1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-with-attrs1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags: --cfg foo + + +#[cfg(foo)] +macro_rules! foo { () => (1) } + +#[cfg(not(foo))] +macro_rules! foo { () => (2) } + +pub fn main() { + assert_eq!(foo!(), 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-with-attrs2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-with-attrs2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-with-attrs2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-with-attrs2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#[cfg(foo)] +macro_rules! foo { () => (1) } + +#[cfg(not(foo))] +macro_rules! foo { () => (2) } + +pub fn main() { + assert_eq!(foo!(), 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-with-braces-in-expr-position.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-with-braces-in-expr-position.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro-with-braces-in-expr-position.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro-with-braces-in-expr-position.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// ignore-emscripten no threads support + +use std::thread; + +macro_rules! expr { ($e: expr) => { $e } } + +macro_rules! spawn { + ($($code: tt)*) => { + expr!(thread::spawn(move|| {$($code)*}).join()) + } +} + +pub fn main() { + spawn! { + println!("stmt"); + }; + let _ = spawn! { + println!("expr"); + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro_with_super_2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro_with_super_2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/macro_with_super_2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/macro_with_super_2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:macro_with_super_1.rs + +// pretty-expanded FIXME #23616 + +#[macro_use] +extern crate macro_with_super_1; + +declare!(); + +fn main() { + bbb::ccc(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/parse-complex-macro-invoc-op.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/parse-complex-macro-invoc-op.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/parse-complex-macro-invoc-op.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/parse-complex-macro-invoc-op.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,52 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +#![allow(dead_code)] +#![allow(unused_assignments)] +#![allow(unused_variables)] +#![allow(stable_features)] + +// Test parsing binary operators after macro invocations. + +// pretty-expanded FIXME #23616 + +#![feature(macro_rules)] + +macro_rules! id { + ($e: expr) => { $e } +} + +fn foo() { + id!(1) + 1; + id![1] - 1; + id!(1) * 1; + id![1] / 1; + id!(1) % 1; + + id!(1) & 1; + id![1] | 1; + id!(1) ^ 1; + + let mut x = 1; + id![x] = 2; + id!(x) += 1; + + id!(1f64).clone(); + + id!([1, 2, 3])[1]; + id![drop](1); + + id!(true) && true; + id![true] || true; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/paths-in-macro-invocations.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/paths-in-macro-invocations.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/paths-in-macro-invocations.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/paths-in-macro-invocations.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// aux-build:two_macros.rs + +extern crate two_macros; + +::two_macros::macro_one!(); +two_macros::macro_one!(); + +mod foo { pub use two_macros::macro_one as bar; } + +trait T { + foo::bar!(); + ::foo::bar!(); +} + +struct S { + x: foo::bar!(i32), + y: ::foo::bar!(i32), +} + +impl S { + foo::bar!(); + ::foo::bar!(); +} + +fn main() { + foo::bar!(); + ::foo::bar!(); + + let _ = foo::bar!(0); + let _ = ::foo::bar!(0); + + let foo::bar!(_) = 0; + let ::foo::bar!(_) = 0; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/pub-item-inside-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/pub-item-inside-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/pub-item-inside-macro.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/pub-item-inside-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Issue #14660 + +// pretty-expanded FIXME #23616 + +mod bleh { + macro_rules! foo { + () => { + pub fn bar() { } + } + } + + foo!(); +} + +fn main() { + bleh::bar(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/pub-method-inside-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/pub-method-inside-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/pub-method-inside-macro.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/pub-method-inside-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Issue #17436 + +// pretty-expanded FIXME #23616 + +mod bleh { + macro_rules! foo { + () => { + pub fn bar(&self) { } + } + } + + pub struct S; + + impl S { + foo!(); + } +} + +fn main() { + bleh::S.bar(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/semi-after-macro-ty.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/semi-after-macro-ty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/semi-after-macro-ty.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/semi-after-macro-ty.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +macro_rules! foo { + ($t:ty; $p:path;) => {} +} + +fn main() { + foo!(i32; i32;); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/stmt_expr_attr_macro_parse.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/stmt_expr_attr_macro_parse.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/stmt_expr_attr_macro_parse.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/stmt_expr_attr_macro_parse.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +macro_rules! m { + ($e:expr) => { + "expr includes attr" + }; + (#[$attr:meta] $e:expr) => { + "expr excludes attr" + } +} + +macro_rules! n { + (#[$attr:meta] $e:expr) => { + "expr excludes attr" + }; + ($e:expr) => { + "expr includes attr" + } +} + +fn main() { + assert_eq!(m!(#[attr] 1), "expr includes attr"); + assert_eq!(n!(#[attr] 1), "expr excludes attr"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/syntax-extension-cfg.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/syntax-extension-cfg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/syntax-extension-cfg.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/syntax-extension-cfg.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags: --cfg foo --cfg qux="foo" + + +pub fn main() { + // check + if ! cfg!(foo) { panic!() } + if cfg!(not(foo)) { panic!() } + + if ! cfg!(qux="foo") { panic!() } + if cfg!(not(qux="foo")) { panic!() } + + if ! cfg!(all(foo, qux="foo")) { panic!() } + if cfg!(not(all(foo, qux="foo"))) { panic!() } + if cfg!(all(not(all(foo, qux="foo")))) { panic!() } + + if cfg!(not_a_cfg) { panic!() } + if cfg!(all(not_a_cfg, foo, qux="foo")) { panic!() } + if cfg!(all(not_a_cfg, foo, qux="foo")) { panic!() } + if ! cfg!(any(not_a_cfg, foo)) { panic!() } + + if ! cfg!(not(not_a_cfg)) { panic!() } + if ! cfg!(all(not(not_a_cfg), foo, qux="foo")) { panic!() } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/syntax-extension-source-utils-files/includeme.fragment rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/syntax-extension-source-utils-files/includeme.fragment --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/syntax-extension-source-utils-files/includeme.fragment 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/syntax-extension-source-utils-files/includeme.fragment 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,7 @@ +/* this is for run-pass/syntax-extension-source-utils.rs */ + +{ + assert!(file!().ends_with("includeme.fragment")); + assert_eq!(line!(), 5u32); + format!("victory robot {}", line!()) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/syntax-extension-source-utils.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/syntax-extension-source-utils.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/syntax-extension-source-utils.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/syntax-extension-source-utils.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// Copyright 2012-2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(stable_features)] + +// ignore-pretty issue #37195 + +pub mod m1 { + pub mod m2 { + pub fn where_am_i() -> String { + (module_path!()).to_string() + } + } +} + +macro_rules! indirect_line { () => ( line!() ) } + +pub fn main() { + assert_eq!(line!(), 27); + assert_eq!(column!(), 16); + assert_eq!(indirect_line!(), 29); + assert!((file!().ends_with("syntax-extension-source-utils.rs"))); + assert_eq!(stringify!((2*3) + 5).to_string(), "( 2 * 3 ) + 5".to_string()); + assert!(include!("syntax-extension-source-utils-files/includeme.\ + fragment").to_string() + == "victory robot 6".to_string()); + + assert!( + include_str!("syntax-extension-source-utils-files/includeme.\ + fragment").to_string() + .starts_with("/* this is for ")); + assert!( + include_bytes!("syntax-extension-source-utils-files/includeme.fragment") + [1] == (42 as u8)); // '*' + // The Windows tests are wrapped in an extra module for some reason + assert!((m1::m2::where_am_i().ends_with("m1::m2"))); + + assert_eq!((46, "( 2 * 3 ) + 5"), (line!(), stringify!((2*3) + 5))); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/try-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/try-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/try-macro.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/try-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,58 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::num::{ParseFloatError, ParseIntError}; + +fn main() { + assert_eq!(simple(), Ok(1)); + assert_eq!(nested(), Ok(2)); + assert_eq!(merge_ok(), Ok(3.0)); + assert_eq!(merge_int_err(), Err(Error::Int)); + assert_eq!(merge_float_err(), Err(Error::Float)); +} + +fn simple() -> Result { + Ok(try!("1".parse())) +} + +fn nested() -> Result { + Ok(try!(try!("2".parse::()).to_string().parse::())) +} + +fn merge_ok() -> Result { + Ok(try!("1".parse::()) as f32 + try!("2.0".parse::())) +} + +fn merge_int_err() -> Result { + Ok(try!("a".parse::()) as f32 + try!("2.0".parse::())) +} + +fn merge_float_err() -> Result { + Ok(try!("1".parse::()) as f32 + try!("b".parse::())) +} + +#[derive(Debug, PartialEq)] +enum Error { + Int, + Float, +} + +impl From for Error { + fn from(_: ParseIntError) -> Error { + Error::Int + } +} + +impl From for Error { + fn from(_: ParseFloatError) -> Error { + Error::Float + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/two-macro-use.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/two-macro-use.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/two-macro-use.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/two-macro-use.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:two_macros.rs + +#[macro_use(macro_one)] +#[macro_use(macro_two)] +extern crate two_macros; + +pub fn main() { + macro_one!(); + macro_two!(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/typeck-macro-interaction-issue-8852.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/typeck-macro-interaction-issue-8852.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/typeck-macro-interaction-issue-8852.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/typeck-macro-interaction-issue-8852.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +enum T { + A(isize), + B(f64) +} + +// after fixing #9384 and implementing hygiene for match bindings, +// this now fails because the insertion of the 'y' into the match +// doesn't cause capture. Making this macro hygienic (as I've done) +// could very well make this test case completely pointless.... + +macro_rules! test { + ($id1:ident, $id2:ident, $e:expr) => ( + fn foo(a:T, b:T) -> T { + match (a, b) { + (T::A($id1), T::A($id2)) => T::A($e), + (T::B($id1), T::B($id2)) => T::B($e), + _ => panic!() + } + } + ) +} + +test!(x,y,x + y); + +pub fn main() { + foo(T::A(1), T::A(2)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/type-macros-hlist.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/type-macros-hlist.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/type-macros-hlist.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/type-macros-hlist.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,88 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::ops::*; + +#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] +struct Nil; + // empty HList +#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] +struct Cons(H, T); + // cons cell of HList + + // trait to classify valid HLists +trait HList { } +impl HList for Nil { } +impl HList for Cons { } + +// term-level macro for HLists +macro_rules! hlist({ } => { Nil } ; { $ head : expr } => { + Cons ( $ head , Nil ) } ; { + $ head : expr , $ ( $ tail : expr ) , * } => { + Cons ( $ head , hlist ! ( $ ( $ tail ) , * ) ) } ;); + +// type-level macro for HLists +macro_rules! HList({ } => { Nil } ; { $ head : ty } => { + Cons < $ head , Nil > } ; { + $ head : ty , $ ( $ tail : ty ) , * } => { + Cons < $ head , HList ! ( $ ( $ tail ) , * ) > } ;); + +// nil case for HList append +impl Add for Nil { + type + Output + = + Ys; + + fn add(self, rhs: Ys) -> Ys { rhs } +} + +// cons case for HList append +impl Add for Cons + where Xs: Add { + type + Output + = + Cons; + + fn add(self, rhs: Ys) -> Cons { Cons(self.0, self.1 + rhs) } +} + +// type macro Expr allows us to expand the + operator appropriately +macro_rules! Expr({ ( $ ( $ LHS : tt ) + ) } => { Expr ! ( $ ( $ LHS ) + ) } ; + { HList ! [ $ ( $ LHS : tt ) * ] + $ ( $ RHS : tt ) + } => { + < Expr ! ( HList ! [ $ ( $ LHS ) * ] ) as Add < Expr ! ( + $ ( $ RHS ) + ) >> :: Output } ; { + $ LHS : tt + $ ( $ RHS : tt ) + } => { + < Expr ! ( $ LHS ) as Add < Expr ! ( $ ( $ RHS ) + ) >> :: + Output } ; { $ LHS : ty } => { $ LHS } ;); + +// test demonstrating term level `xs + ys` and type level `Expr!(Xs + Ys)` +fn main() { + fn aux(xs: Xs, ys: Ys) -> Expr!(Xs + Ys) where + Xs: Add { + xs + ys + } + + let xs: HList!(& str , bool , Vec < u64 >) = + hlist!("foo" , false , vec ! [ ]); + let ys: HList!(u64 , [ u8 ; 3 ] , ( )) = + hlist!(0 , [ 0 , 1 , 2 ] , ( )); + + // demonstrate recursive expansion of Expr! + let zs: + Expr!(( + HList ! [ & str ] + HList ! [ bool ] + HList ! [ Vec < u64 > + ] ) + ( HList ! [ u64 ] + HList ! [ [ u8 ; 3 ] , ( ) ] ) + + HList ! [ ]) = aux(xs, ys); + assert_eq!(zs , hlist ! [ + "foo" , false , vec ! [ ] , 0 , [ 0 , 1 , 2 ] , ( ) ]) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/type-macros-simple.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/type-macros-simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/type-macros-simple.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/type-macros-simple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +macro_rules! Tuple { + { $A:ty,$B:ty } => { ($A, $B) } +} + +fn main() { + let x: Tuple!(i32, i32) = (1, 2); +} + +fn issue_36540() { + let i32 = 0; + macro_rules! m { () => { i32 } } + struct S(m!(), T) where T: Trait; + + let x: m!() = m!(); + std::cell::Cell::::new(m!()); + impl std::ops::Index for Trait<(m!(), T)> + where T: Trait + { + type Output = m!(); + fn index(&self, i: m!()) -> &m!() { + unimplemented!() + } + } +} + +trait Trait {} +impl Trait for i32 {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/use-macro-self.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/use-macro-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/macros/use-macro-self.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/macros/use-macro-self.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +// aux-build:use-macro-self.rs + +#[macro_use] +extern crate use_macro_self; + +use use_macro_self::foobarius::{self}; + +fn main() { + let _: () = foobarius!(); // OK, the macro returns `()` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/max-min-classes.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/max-min-classes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/max-min-classes.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/max-min-classes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_snake_case)] trait Product { fn product(&self) -> isize; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/auxiliary/method_self_arg1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/auxiliary/method_self_arg1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/auxiliary/method_self_arg1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/auxiliary/method_self_arg1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +#![feature(box_syntax)] + +static mut COUNT: u64 = 1; + +pub fn get_count() -> u64 { unsafe { COUNT } } + +#[derive(Copy, Clone)] +pub struct Foo; + +impl Foo { + pub fn foo(self, x: &Foo) { + unsafe { COUNT *= 2; } + // Test internal call. + Foo::bar(&self); + Foo::bar(x); + + Foo::baz(self); + Foo::baz(*x); + + Foo::qux(box self); + Foo::qux(box *x); + } + + pub fn bar(&self) { + unsafe { COUNT *= 3; } + } + + pub fn baz(self) { + unsafe { COUNT *= 5; } + } + + pub fn qux(self: Box) { + unsafe { COUNT *= 7; } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/auxiliary/method_self_arg2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/auxiliary/method_self_arg2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/auxiliary/method_self_arg2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/auxiliary/method_self_arg2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,64 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +#![feature(box_syntax)] + +static mut COUNT: u64 = 1; + +pub fn get_count() -> u64 { unsafe { COUNT } } + +#[derive(Copy, Clone)] +pub struct Foo; + +impl Foo { + pub fn run_trait(self) { + unsafe { COUNT *= 17; } + // Test internal call. + Bar::foo1(&self); + Bar::foo2(self); + Bar::foo3(box self); + + Bar::bar1(&self); + Bar::bar2(self); + Bar::bar3(box self); + } +} + +pub trait Bar : Sized { + fn foo1(&self); + fn foo2(self); + fn foo3(self: Box); + + fn bar1(&self) { + unsafe { COUNT *= 7; } + } + fn bar2(self) { + unsafe { COUNT *= 11; } + } + fn bar3(self: Box) { + unsafe { COUNT *= 13; } + } +} + +impl Bar for Foo { + fn foo1(&self) { + unsafe { COUNT *= 2; } + } + + fn foo2(self) { + unsafe { COUNT *= 3; } + } + + fn foo3(self: Box) { + unsafe { COUNT *= 5; } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-argument-inference-associated-type.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-argument-inference-associated-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-argument-inference-associated-type.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-argument-inference-associated-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub struct ClientMap; +pub struct ClientMap2; + +pub trait Service { + type Request; + fn call(&self, _req: Self::Request); +} + +pub struct S(T); + +impl Service for ClientMap { + type Request = S>; + fn call(&self, _req: Self::Request) {} +} + + +impl Service for ClientMap2 { + type Request = (Box,); + fn call(&self, _req: Self::Request) {} +} + + +fn main() { + ClientMap.call(S { 0: Box::new(|_msgid| ()) }); + ClientMap.call(S(Box::new(|_msgid| ()))); + ClientMap2.call((Box::new(|_msgid| ()),)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-attributes.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-attributes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-attributes.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-attributes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_attributes)] +#![allow(non_camel_case_types)] + +// pp-exact - Make sure we print all the attributes +// pretty-expanded FIXME #23616 + +#![feature(custom_attribute)] + +#[frobable] +trait frobable { + #[frob_attr] + fn frob(&self); + #[defrob_attr] + fn defrob(&self); +} + +#[int_frobable] +impl frobable for isize { + #[frob_attr1] + fn frob(&self) { + #![frob_attr2] + } + + #[defrob_attr1] + fn defrob(&self) { + #![defrob_attr2] + } +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-early-bound-lifetimes-on-self.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-early-bound-lifetimes-on-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-early-bound-lifetimes-on-self.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-early-bound-lifetimes-on-self.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Check that we successfully handle methods where the `self` type has +// an early-bound lifetime. Issue #18208. + +// pretty-expanded FIXME #23616 + +#![allow(dead_code)] + +use std::marker; + +struct Cursor<'a> { + m: marker::PhantomData<&'a ()> +} + +trait CursorNavigator { + fn init_cursor<'a, 'b:'a>(&'a self, cursor: &mut Cursor<'b>) -> bool; +} + +struct SimpleNavigator; + +impl CursorNavigator for SimpleNavigator { + fn init_cursor<'a, 'b: 'a>(&'a self, _cursor: &mut Cursor<'b>) -> bool { + false + } +} + +fn main() { + let mut c = Cursor { m: marker::PhantomData }; + let n = SimpleNavigator; + n.init_cursor(&mut c); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-mut-self-modifies-mut-slice-lvalue.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-mut-self-modifies-mut-slice-lvalue.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-mut-self-modifies-mut-slice-lvalue.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-mut-self-modifies-mut-slice-lvalue.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,54 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that an `&mut self` method, when invoked on a place whose +// type is `&mut [u8]`, passes in a pointer to the place and not a +// temporary. Issue #19147. + +use std::slice; +use std::cmp; + +trait MyWriter { + fn my_write(&mut self, buf: &[u8]) -> Result<(), ()>; +} + +impl<'a> MyWriter for &'a mut [u8] { + fn my_write(&mut self, buf: &[u8]) -> Result<(), ()> { + let amt = cmp::min(self.len(), buf.len()); + self[..amt].clone_from_slice(&buf[..amt]); + + let write_len = buf.len(); + unsafe { + *self = slice::from_raw_parts_mut( + self.as_mut_ptr().add(write_len), + self.len() - write_len + ); + } + + Ok(()) + } +} + +fn main() { + let mut buf = [0; 6]; + + { + let mut writer: &mut [_] = &mut buf; + writer.my_write(&[0, 1, 2]).unwrap(); + writer.my_write(&[3, 4, 5]).unwrap(); + } + + // If `my_write` is not modifying `buf` in place, then we will + // wind up with `[3, 4, 5, 0, 0, 0]` because the first call to + // `my_write()` doesn't update the starting point for the write. + + assert_eq!(buf, [0, 1, 2, 3, 4, 5]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-normalize-bounds-issue-20604.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-normalize-bounds-issue-20604.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-normalize-bounds-issue-20604.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-normalize-bounds-issue-20604.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,71 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(stable_features)] + +// Test that we handle projection types which wind up important for +// resolving methods. This test was reduced from a larger example; the +// call to `foo()` at the end was failing to resolve because the +// winnowing stage of method resolution failed to handle an associated +// type projection. + +// pretty-expanded FIXME #23616 + +#![feature(associated_types)] + +trait Hasher { + type Output; + fn finish(&self) -> Self::Output; +} + +trait Hash { + fn hash(&self, h: &mut H); +} + +trait HashState { + type Wut: Hasher; + fn hasher(&self) -> Self::Wut; +} + +struct SipHasher; +impl Hasher for SipHasher { + type Output = u64; + fn finish(&self) -> u64 { 4 } +} + +impl Hash for isize { + fn hash(&self, h: &mut SipHasher) {} +} + +struct SipState; +impl HashState for SipState { + type Wut = SipHasher; + fn hasher(&self) -> SipHasher { SipHasher } +} + +struct Map { + s: S, +} + +impl Map + where S: HashState, + ::Wut: Hasher, +{ + fn foo(&self, k: K) where K: Hash< ::Wut> {} +} + +fn foo>(map: &Map) { + map.foo(22); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-projection.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-projection.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-projection.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-projection.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,80 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we can use method notation to call methods based on a +// projection bound from a trait. Issue #20469. + +/////////////////////////////////////////////////////////////////////////// + + +trait MakeString { + fn make_string(&self) -> String; +} + +impl MakeString for isize { + fn make_string(&self) -> String { + format!("{}", *self) + } +} + +impl MakeString for usize { + fn make_string(&self) -> String { + format!("{}", *self) + } +} + +/////////////////////////////////////////////////////////////////////////// + +trait Foo { + type F: MakeString; + + fn get(&self) -> &Self::F; +} + +fn foo(f: &F) -> String { + f.get().make_string() +} + +/////////////////////////////////////////////////////////////////////////// + +struct SomeStruct { + field: isize, +} + +impl Foo for SomeStruct { + type F = isize; + + fn get(&self) -> &isize { + &self.field + } +} + +/////////////////////////////////////////////////////////////////////////// + +struct SomeOtherStruct { + field: usize, +} + +impl Foo for SomeOtherStruct { + type F = usize; + + fn get(&self) -> &usize { + &self.field + } +} + +fn main() { + let x = SomeStruct { field: 22 }; + assert_eq!(foo(&x), format!("22")); + + let x = SomeOtherStruct { field: 44 }; + assert_eq!(foo(&x), format!("44")); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-recursive-blanket-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-recursive-blanket-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-recursive-blanket-impl.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-recursive-blanket-impl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,51 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +#![allow(unused_imports)] +// Test that we don't trigger on the blanket impl for all `&'a T` but +// rather keep autoderefing and trigger on the underlying impl. To +// know not to stop at the blanket, we have to recursively evaluate +// the `T:Foo` bound. + +// pretty-expanded FIXME #23616 + +use std::marker::Sized; + +// Note: this must be generic for the problem to show up +trait Foo { + fn foo(&self, a: A); +} + +impl Foo for [u8] { + fn foo(&self, a: u8) {} +} + +impl<'a, A, T> Foo for &'a T where T: Foo { + fn foo(&self, a: A) { + Foo::foo(*self, a) + } +} + +trait Bar { + fn foo(&self); +} + +struct MyType; + +impl Bar for MyType { + fn foo(&self) {} +} + +fn main() { + let mut m = MyType; + (&mut m).foo() +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-self-arg-aux1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-self-arg-aux1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-self-arg-aux1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-self-arg-aux1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test method calls with self as an argument (cross-crate) + +#![feature(box_syntax)] + +// aux-build:method_self_arg1.rs +extern crate method_self_arg1; +use method_self_arg1::Foo; + +fn main() { + let x = Foo; + // Test external call. + Foo::bar(&x); + Foo::baz(x); + Foo::qux(box x); + + x.foo(&x); + + assert_eq!(method_self_arg1::get_count(), 2*3*3*3*5*5*5*7*7*7); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-self-arg-aux2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-self-arg-aux2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-self-arg-aux2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-self-arg-aux2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test method calls with self as an argument (cross-crate) + +#![feature(box_syntax)] + +// aux-build:method_self_arg2.rs +extern crate method_self_arg2; +use method_self_arg2::{Foo, Bar}; + +fn main() { + let x = Foo; + // Test external call. + Bar::foo1(&x); + Bar::foo2(x); + Bar::foo3(box x); + + Bar::bar1(&x); + Bar::bar2(x); + Bar::bar3(box x); + + x.run_trait(); + + assert_eq!(method_self_arg2::get_count(), 2*2*3*3*5*5*7*7*11*11*13*13*17); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-self-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-self-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-self-arg.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-self-arg.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,58 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test method calls with self as an argument + +#![feature(box_syntax)] + +static mut COUNT: usize = 1; + +#[derive(Copy, Clone)] +struct Foo; + +impl Foo { + fn foo(self, x: &Foo) { + unsafe { COUNT *= 2; } + // Test internal call. + Foo::bar(&self); + Foo::bar(x); + + Foo::baz(self); + Foo::baz(*x); + + Foo::qux(box self); + Foo::qux(box *x); + } + + fn bar(&self) { + unsafe { COUNT *= 3; } + } + + fn baz(self) { + unsafe { COUNT *= 5; } + } + + fn qux(self: Box) { + unsafe { COUNT *= 7; } + } +} + +fn main() { + let x = Foo; + // Test external call. + Foo::bar(&x); + Foo::baz(x); + Foo::qux(box x); + + x.foo(&x); + + unsafe { assert_eq!(COUNT, 2*3*3*3*5*5*5*7*7*7); } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-self-arg-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-self-arg-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-self-arg-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-self-arg-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,79 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test method calls with self as an argument + +#![feature(box_syntax)] + +static mut COUNT: u64 = 1; + +#[derive(Copy, Clone)] +struct Foo; + +trait Bar : Sized { + fn foo1(&self); + fn foo2(self); + fn foo3(self: Box); + + fn bar1(&self) { + unsafe { COUNT *= 7; } + } + fn bar2(self) { + unsafe { COUNT *= 11; } + } + fn bar3(self: Box) { + unsafe { COUNT *= 13; } + } +} + +impl Bar for Foo { + fn foo1(&self) { + unsafe { COUNT *= 2; } + } + + fn foo2(self) { + unsafe { COUNT *= 3; } + } + + fn foo3(self: Box) { + unsafe { COUNT *= 5; } + } +} + +impl Foo { + fn baz(self) { + unsafe { COUNT *= 17; } + // Test internal call. + Bar::foo1(&self); + Bar::foo2(self); + Bar::foo3(box self); + + Bar::bar1(&self); + Bar::bar2(self); + Bar::bar3(box self); + } +} + +fn main() { + let x = Foo; + // Test external call. + Bar::foo1(&x); + Bar::foo2(x); + Bar::foo3(box x); + + Bar::bar1(&x); + Bar::bar2(x); + Bar::bar3(box x); + + x.baz(); + + unsafe { assert_eq!(COUNT, 2*2*3*3*5*5*7*7*11*11*13*13*17); } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-two-trait-defer-resolution-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-two-trait-defer-resolution-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-two-trait-defer-resolution-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-two-trait-defer-resolution-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +// Test that we pick which version of `foo` to run based on the +// type that is (ultimately) inferred for `x`. + + +trait foo { + fn foo(&self) -> i32; +} + +impl foo for Vec { + fn foo(&self) -> i32 {1} +} + +impl foo for Vec { + fn foo(&self) -> i32 {2} +} + +fn call_foo_uint() -> i32 { + let mut x = Vec::new(); + let y = x.foo(); + x.push(0u32); + y +} + +fn call_foo_int() -> i32 { + let mut x = Vec::new(); + let y = x.foo(); + x.push(0i32); + y +} + +fn main() { + assert_eq!(call_foo_uint(), 1); + assert_eq!(call_foo_int(), 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-two-trait-defer-resolution-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-two-trait-defer-resolution-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-two-trait-defer-resolution-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-two-trait-defer-resolution-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,58 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that when we write `x.foo()`, we do not have to know the +// complete type of `x` in order to type-check the method call. In +// this case, we know that `x: Vec<_1>`, but we don't know what type +// `_1` is (because the call to `push` comes later). To pick between +// the impls, we would have to know `_1`, since we have to know +// whether `_1: MyCopy` or `_1 == Box`. However (and this is the +// point of the test), we don't have to pick between the two impls -- +// it is enough to know that `foo` comes from the `Foo` trait. We can +// codegen the call as `Foo::foo(&x)` and let the specific impl get +// chosen later. + +#![feature(box_syntax)] + +trait Foo { + fn foo(&self) -> isize; +} + +trait MyCopy { fn foo(&self) { } } +impl MyCopy for i32 { } + +impl Foo for Vec { + fn foo(&self) -> isize {1} +} + +impl Foo for Vec> { + fn foo(&self) -> isize {2} +} + +fn call_foo_copy() -> isize { + let mut x = Vec::new(); + let y = x.foo(); + x.push(0_i32); + y +} + +fn call_foo_other() -> isize { + let mut x: Vec<_> = Vec::new(); + let y = x.foo(); + let z: Box = box 0; + x.push(z); + y +} + +fn main() { + assert_eq!(call_foo_copy(), 1); + assert_eq!(call_foo_other(), 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-two-traits-distinguished-via-where-clause.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-two-traits-distinguished-via-where-clause.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-two-traits-distinguished-via-where-clause.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-two-traits-distinguished-via-where-clause.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we select between traits A and B. To do that, we must +// consider the `Sized` bound. + +// pretty-expanded FIXME #23616 + +trait A { + fn foo(self); +} + +trait B { + fn foo(self); +} + +impl A for *const T { + fn foo(self) {} +} + +impl B for *const [T] { + fn foo(self) {} +} + +fn main() { + let x: [isize; 4] = [1,2,3,4]; + let xptr = &x[..] as *const [isize]; + xptr.foo(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-where-clause.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-where-clause.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/methods/method-where-clause.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/methods/method-where-clause.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we can use method notation to call methods based on a +// where clause type, and not only type parameters. + + +trait Foo { + fn foo(&self) -> i32; +} + +impl Foo for Option +{ + fn foo(&self) -> i32 { + self.unwrap_or(22) + } +} + +impl Foo for Option +{ + fn foo(&self) -> i32 { + self.unwrap_or(22) as i32 + } +} + +fn check(x: Option) -> (i32, i32) + where Option : Foo +{ + let y: Option = None; + (x.foo(), y.foo()) +} + +fn main() { + assert_eq!(check(Some(23u32)), (23, 22)); + assert_eq!(check(Some(23)), (23, 22)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mid-path-type-params.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mid-path-type-params.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mid-path-type-params.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mid-path-type-params.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // pretty-expanded FIXME #23616 struct S { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/auxiliary/mir_external_refs.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/auxiliary/mir_external_refs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/auxiliary/mir_external_refs.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/auxiliary/mir_external_refs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +pub struct S(pub u8); + +impl S { + pub fn hey() -> u8 { 24 } +} + +pub trait X { + fn hoy(&self) -> u8 { 25 } +} + +impl X for S {} + +pub enum E { + U(u8) +} + +pub fn regular_fn() -> u8 { 12 } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_adt_construction.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_adt_construction.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_adt_construction.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_adt_construction.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,102 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::fmt; + +#[repr(C)] +enum CEnum { + Hello = 30, + World = 60 +} + +fn test1(c: CEnum) -> i32 { + let c2 = CEnum::Hello; + match (c, c2) { + (CEnum::Hello, CEnum::Hello) => 42, + (CEnum::World, CEnum::Hello) => 0, + _ => 1 + } +} + +#[repr(packed)] +struct Pakd { + a: u64, + b: u32, + c: u16, + d: u8, + e: () +} + +// It is unsafe to use #[derive(Debug)] on a packed struct because the code generated by the derive +// macro takes references to the fields instead of accessing them directly. +impl fmt::Debug for Pakd { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + // It's important that we load the fields into locals by-value here. This will do safe + // unaligned loads into the locals, then pass references to the properly-aligned locals to + // the formatting code. + let Pakd { a, b, c, d, e } = *self; + f.debug_struct("Pakd") + .field("a", &a) + .field("b", &b) + .field("c", &c) + .field("d", &d) + .field("e", &e) + .finish() + } +} + +// It is unsafe to use #[derive(PartialEq)] on a packed struct because the code generated by the +// derive macro takes references to the fields instead of accessing them directly. +impl PartialEq for Pakd { + fn eq(&self, other: &Pakd) -> bool { + self.a == other.a && + self.b == other.b && + self.c == other.c && + self.d == other.d && + self.e == other.e + } +} + +impl Drop for Pakd { + fn drop(&mut self) {} +} + +fn test2() -> Pakd { + Pakd { a: 42, b: 42, c: 42, d: 42, e: () } +} + +#[derive(PartialEq, Debug)] +struct TupleLike(u64, u32); + +fn test3() -> TupleLike { + TupleLike(42, 42) +} + +fn test4(x: fn(u64, u32) -> TupleLike) -> (TupleLike, TupleLike) { + let y = TupleLike; + (x(42, 84), y(42, 84)) +} + +fn test5(x: fn(u32) -> Option) -> (Option, Option) { + let y = Some; + (x(42), y(42)) +} + +fn main() { + assert_eq!(test1(CEnum::Hello), 42); + assert_eq!(test1(CEnum::World), 0); + assert_eq!(test2(), Pakd { a: 42, b: 42, c: 42, d: 42, e: () }); + assert_eq!(test3(), TupleLike(42, 42)); + let t4 = test4(TupleLike); + assert_eq!(t4.0, t4.1); + let t5 = test5(Some); + assert_eq!(t5.0, t5.1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_ascription_coercion.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_ascription_coercion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_ascription_coercion.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_ascription_coercion.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests that the result of type ascription has adjustments applied + +#![feature(type_ascription)] + +fn main() { + let x = [1, 2, 3]; + // The RHS should coerce to &[i32] + let _y : &[i32] = &x : &[i32; 3]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_augmented_assignments.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_augmented_assignments.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_augmented_assignments.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_augmented_assignments.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,170 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::mem; +use std::ops::{ + AddAssign, BitAndAssign, BitOrAssign, BitXorAssign, DivAssign, MulAssign, RemAssign, + ShlAssign, ShrAssign, SubAssign, +}; + +#[derive(Debug, PartialEq)] +struct Int(i32); + +struct Slice([i32]); + +impl Slice { + fn new(slice: &mut [i32]) -> &mut Slice { + unsafe { + mem::transmute(slice) + } + } +} + +fn main() { + main_mir(); +} + +fn main_mir() { + let mut x = Int(1); + + x += Int(2); + assert_eq!(x, Int(0b11)); + + x &= Int(0b01); + assert_eq!(x, Int(0b01)); + + x |= Int(0b10); + assert_eq!(x, Int(0b11)); + + x ^= Int(0b01); + assert_eq!(x, Int(0b10)); + + x /= Int(2); + assert_eq!(x, Int(1)); + + x *= Int(3); + assert_eq!(x, Int(3)); + + x %= Int(2); + assert_eq!(x, Int(1)); + + // overloaded RHS + x <<= 1u8; + assert_eq!(x, Int(2)); + + x <<= 1u16; + assert_eq!(x, Int(4)); + + x >>= 1u8; + assert_eq!(x, Int(2)); + + x >>= 1u16; + assert_eq!(x, Int(1)); + + x -= Int(1); + assert_eq!(x, Int(0)); + + // indexed LHS + // FIXME(mir-drop): use the vec![..] macro + let mut v = Vec::new(); + v.push(Int(1)); + v.push(Int(2)); + v[0] += Int(2); + assert_eq!(v[0], Int(3)); + + // unsized RHS + let mut array = [0, 1, 2]; + *Slice::new(&mut array) += 1; + assert_eq!(array[0], 1); + assert_eq!(array[1], 2); + assert_eq!(array[2], 3); + +} + +impl AddAssign for Int { + fn add_assign(&mut self, rhs: Int) { + self.0 += rhs.0; + } +} + +impl BitAndAssign for Int { + fn bitand_assign(&mut self, rhs: Int) { + self.0 &= rhs.0; + } +} + +impl BitOrAssign for Int { + fn bitor_assign(&mut self, rhs: Int) { + self.0 |= rhs.0; + } +} + +impl BitXorAssign for Int { + fn bitxor_assign(&mut self, rhs: Int) { + self.0 ^= rhs.0; + } +} + +impl DivAssign for Int { + fn div_assign(&mut self, rhs: Int) { + self.0 /= rhs.0; + } +} + +impl MulAssign for Int { + fn mul_assign(&mut self, rhs: Int) { + self.0 *= rhs.0; + } +} + +impl RemAssign for Int { + fn rem_assign(&mut self, rhs: Int) { + self.0 %= rhs.0; + } +} + +impl ShlAssign for Int { + fn shl_assign(&mut self, rhs: u8) { + self.0 <<= rhs; + } +} + +impl ShlAssign for Int { + fn shl_assign(&mut self, rhs: u16) { + self.0 <<= rhs; + } +} + +impl ShrAssign for Int { + fn shr_assign(&mut self, rhs: u8) { + self.0 >>= rhs; + } +} + +impl ShrAssign for Int { + fn shr_assign(&mut self, rhs: u16) { + self.0 >>= rhs; + } +} + +impl SubAssign for Int { + fn sub_assign(&mut self, rhs: Int) { + self.0 -= rhs.0; + } +} + +impl AddAssign for Slice { + fn add_assign(&mut self, rhs: i32) { + for lhs in &mut self.0 { + *lhs += rhs; + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_autoderef.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_autoderef.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_autoderef.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_autoderef.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::ops::{Deref, DerefMut}; + +pub struct MyRef(u32); + +impl Deref for MyRef { + type Target = u32; + fn deref(&self) -> &u32 { &self.0 } +} + +impl DerefMut for MyRef { + fn deref_mut(&mut self) -> &mut u32 { &mut self.0 } +} + + +fn deref(x: &MyRef) -> &u32 { + x +} + +fn deref_mut(x: &mut MyRef) -> &mut u32 { + x +} + +fn main() { + let mut r = MyRef(2); + assert_eq!(deref(&r) as *const _, &r.0 as *const _); + assert_eq!(deref_mut(&mut r) as *mut _, &mut r.0 as *mut _); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_boxing.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_boxing.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_boxing.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_boxing.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +fn test() -> Box { + box 42 +} + +fn main() { + assert_eq!(*test(), 42); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_build_match_comparisons.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_build_match_comparisons.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_build_match_comparisons.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_build_match_comparisons.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,69 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +fn test1(x: i8) -> i32 { + match x { + 1...10 => 0, + _ => 1, + } +} + +const U: Option = Some(10); +const S: &'static str = "hello"; + +fn test2(x: i8) -> i32 { + match Some(x) { + U => 0, + _ => 1, + } +} + +fn test3(x: &'static str) -> i32 { + match x { + S => 0, + _ => 1, + } +} + +enum Opt { + Some { v: T }, + None +} + +fn test4(x: u64) -> i32 { + let opt = Opt::Some{ v: x }; + match opt { + Opt::Some { v: 10 } => 0, + _ => 1, + } +} + + +fn main() { + assert_eq!(test1(0), 1); + assert_eq!(test1(1), 0); + assert_eq!(test1(2), 0); + assert_eq!(test1(5), 0); + assert_eq!(test1(9), 0); + assert_eq!(test1(10), 0); + assert_eq!(test1(11), 1); + assert_eq!(test1(20), 1); + assert_eq!(test2(10), 0); + assert_eq!(test2(0), 1); + assert_eq!(test2(20), 1); + assert_eq!(test3("hello"), 0); + assert_eq!(test3(""), 1); + assert_eq!(test3("world"), 1); + assert_eq!(test4(10), 0); + assert_eq!(test4(0), 1); + assert_eq!(test4(20), 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_calls_to_shims.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_calls_to_shims.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_calls_to_shims.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_calls_to_shims.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,59 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-wasm32-bare compiled with panic=abort by default + +#![feature(fn_traits)] +#![feature(never_type)] + +use std::panic; + +fn foo(x: u32, y: u32) -> u32 { x/y } +fn foo_diverges() -> ! { panic!() } + +fn test_fn_ptr(mut t: T) + where T: Fn(u32, u32) -> u32, +{ + let as_fn = >::call; + assert_eq!(as_fn(&t, (9, 3)), 3); + let as_fn_mut = >::call_mut; + assert_eq!(as_fn_mut(&mut t, (18, 3)), 6); + let as_fn_once = >::call_once; + assert_eq!(as_fn_once(t, (24, 3)), 8); +} + +fn assert_panics(f: F) where F: FnOnce() { + let f = panic::AssertUnwindSafe(f); + let result = panic::catch_unwind(move || { + f.0() + }); + if let Ok(..) = result { + panic!("diverging function returned"); + } +} + +fn test_fn_ptr_panic(mut t: T) + where T: Fn() -> ! +{ + let as_fn = >::call; + assert_panics(|| as_fn(&t, ())); + let as_fn_mut = >::call_mut; + assert_panics(|| as_fn_mut(&mut t, ())); + let as_fn_once = >::call_once; + assert_panics(|| as_fn_once(t, ())); +} + +fn main() { + test_fn_ptr(foo); + test_fn_ptr(foo as fn(u32, u32) -> u32); + test_fn_ptr_panic(foo_diverges); + test_fn_ptr_panic(foo_diverges as fn() -> !); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_call_with_associated_type.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_call_with_associated_type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_call_with_associated_type.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_call_with_associated_type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait Trait { + type Type; +} + +impl<'a> Trait for &'a () { + type Type = u32; +} + +fn foo<'a>(t: <&'a () as Trait>::Type) -> <&'a () as Trait>::Type { + t +} + +fn main() { + assert_eq!(foo(4), 4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_cast_fn_ret.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_cast_fn_ret.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_cast_fn_ret.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_cast_fn_ret.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub extern "C" fn tuple2() -> (u16, u8) { + (1, 2) +} + +pub extern "C" fn tuple3() -> (u8, u8, u8) { + (1, 2, 3) +} + +pub fn test2() -> u8 { + tuple2().1 +} + +pub fn test3() -> u8 { + tuple3().2 +} + +fn main() { + assert_eq!(test2(), 2); + assert_eq!(test3(), 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_array_2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_array_2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_array_2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_array_2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn into_inner(x: u64) -> [u64; 1024] { + [x; 2*4*8*16] +} + +fn main(){ + let x: &[u64] = &[42; 1024]; + assert_eq!(&into_inner(42)[..], x); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_array.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_array.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_array.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_array.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +fn into_inner() -> [u64; 1024] { + let mut x = 10 + 20; + [x; 1024] +} + +fn main(){ + let x: &[u64] = &[30; 1024]; + assert_eq!(&into_inner()[..], x); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_call_converging.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_call_converging.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_call_converging.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_call_converging.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn converging_fn() -> u64 { + 43 +} + +fn mir() -> u64 { + let x; + loop { + x = converging_fn(); + break; + } + x +} + +fn main() { + assert_eq!(mir(), 43); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_calls.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_calls.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_calls.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_calls.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,201 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(fn_traits, test)] + +extern crate test; + +fn test1(a: isize, b: (i32, i32), c: &[i32]) -> (isize, (i32, i32), &[i32]) { + // Test passing a number of arguments including a fat pointer. + // Also returning via an out pointer + fn callee(a: isize, b: (i32, i32), c: &[i32]) -> (isize, (i32, i32), &[i32]) { + (a, b, c) + } + callee(a, b, c) +} + +fn test2(a: isize) -> isize { + // Test passing a single argument. + // Not using out pointer. + fn callee(a: isize) -> isize { + a + } + callee(a) +} + +#[derive(PartialEq, Eq, Debug)] +struct Foo; +impl Foo { + fn inherent_method(&self, a: isize) -> isize { a } +} + +fn test3(x: &Foo, a: isize) -> isize { + // Test calling inherent method + x.inherent_method(a) +} + +trait Bar { + fn extension_method(&self, a: isize) -> isize { a } +} +impl Bar for Foo {} + +fn test4(x: &Foo, a: isize) -> isize { + // Test calling extension method + x.extension_method(a) +} + +fn test5(x: &Bar, a: isize) -> isize { + // Test calling method on trait object + x.extension_method(a) +} + +fn test6(x: &T, a: isize) -> isize { + // Test calling extension method on generic callee + x.extension_method(a) +} + +trait One { + fn one() -> T; +} +impl One for isize { + fn one() -> isize { 1 } +} + +fn test7() -> isize { + // Test calling trait static method + ::one() +} + +struct Two; +impl Two { + fn two() -> isize { 2 } +} + +fn test8() -> isize { + // Test calling impl static method + Two::two() +} + +extern fn simple_extern(x: u32, y: (u32, u32)) -> u32 { + x + y.0 * y.1 +} + +fn test9() -> u32 { + simple_extern(41, (42, 43)) +} + +fn test_closure(f: &F, x: i32, y: i32) -> i32 + where F: Fn(i32, i32) -> i32 +{ + f(x, y) +} + +fn test_fn_object(f: &Fn(i32, i32) -> i32, x: i32, y: i32) -> i32 { + f(x, y) +} + +fn test_fn_impl(f: &&Fn(i32, i32) -> i32, x: i32, y: i32) -> i32 { + // This call goes through the Fn implementation for &Fn provided in + // core::ops::impls. It expands to a static Fn::call() that calls the + // Fn::call() implementation of the object shim underneath. + f(x, y) +} + +fn test_fn_direct_call(f: &F, x: i32, y: i32) -> i32 + where F: Fn(i32, i32) -> i32 +{ + f.call((x, y)) +} + +fn test_fn_const_call(f: &F) -> i32 + where F: Fn(i32, i32) -> i32 +{ + f.call((100, -1)) +} + +fn test_fn_nil_call(f: &F) -> i32 + where F: Fn() -> i32 +{ + f() +} + +fn test_fn_transmute_zst(x: ()) -> [(); 1] { + fn id(x: T) -> T {x} + + id(unsafe { + std::mem::transmute(x) + }) +} + +fn test_fn_ignored_pair() -> ((), ()) { + ((), ()) +} + +fn test_fn_ignored_pair_0() { + test_fn_ignored_pair().0 +} + +fn id(x: T) -> T { x } + +fn ignored_pair_named() -> (Foo, Foo) { + (Foo, Foo) +} + +fn test_fn_ignored_pair_named() -> (Foo, Foo) { + id(ignored_pair_named()) +} + +fn test_fn_nested_pair(x: &((f32, f32), u32)) -> (f32, f32) { + let y = *x; + let z = y.0; + (z.0, z.1) +} + +fn test_fn_const_arg_by_ref(mut a: [u64; 4]) -> u64 { + // Mutate the by-reference argument, which won't work with + // a non-immediate constant unless it's copied to the stack. + let a = test::black_box(&mut a); + a[0] += a[1]; + a[0] += a[2]; + a[0] += a[3]; + a[0] +} + +fn main() { + assert_eq!(test1(1, (2, 3), &[4, 5, 6]), (1, (2, 3), &[4, 5, 6][..])); + assert_eq!(test2(98), 98); + assert_eq!(test3(&Foo, 42), 42); + assert_eq!(test4(&Foo, 970), 970); + assert_eq!(test5(&Foo, 8576), 8576); + assert_eq!(test6(&Foo, 12367), 12367); + assert_eq!(test7(), 1); + assert_eq!(test8(), 2); + assert_eq!(test9(), 41 + 42 * 43); + + let r = 3; + let closure = |x: i32, y: i32| { r*(x + (y*2)) }; + assert_eq!(test_fn_const_call(&closure), 294); + assert_eq!(test_closure(&closure, 100, 1), 306); + let function_object = &closure as &Fn(i32, i32) -> i32; + assert_eq!(test_fn_object(function_object, 100, 2), 312); + assert_eq!(test_fn_impl(&function_object, 100, 3), 318); + assert_eq!(test_fn_direct_call(&closure, 100, 4), 324); + + assert_eq!(test_fn_nil_call(&(|| 42)), 42); + assert_eq!(test_fn_transmute_zst(()), [()]); + + assert_eq!(test_fn_ignored_pair_0(), ()); + assert_eq!(test_fn_ignored_pair_named(), (Foo, Foo)); + assert_eq!(test_fn_nested_pair(&((1.0, 2.0), 0)), (1.0, 2.0)); + + const ARRAY: [u64; 4] = [1, 2, 3, 4]; + assert_eq!(test_fn_const_arg_by_ref(ARRAY), 1 + 2 + 3 + 4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_calls_variadic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_calls_variadic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_calls_variadic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_calls_variadic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-wasm32-bare no libc to test ffi with + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + fn rust_interesting_average(_: i64, ...) -> f64; +} + +fn test(a: i64, b: i64, c: i64, d: i64, e: i64, f: T, g: U) -> i64 { + unsafe { + rust_interesting_average(6, a, a as f64, + b, b as f64, + c, c as f64, + d, d as f64, + e, e as f64, + f, g) as i64 + } +} + +fn main(){ + assert_eq!(test(10, 20, 30, 40, 50, 60_i64, 60.0_f64), 70); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_critical_edge.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_critical_edge.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_critical_edge.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_critical_edge.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,54 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// This code produces a CFG with critical edges that, if we don't +// handle properly, will cause invalid codegen. + +#![feature(rustc_attrs)] + +enum State { + Both, + Front, + Back +} + +pub struct Foo { + state: State, + a: A, + b: B +} + +impl Foo +where A: Iterator, B: Iterator +{ + // This is the function we care about + fn next(&mut self) -> Option { + match self.state { + State::Both => match self.a.next() { + elt @ Some(..) => elt, + None => { + self.state = State::Back; + self.b.next() + } + }, + State::Front => self.a.next(), + State::Back => self.b.next(), + } + } +} + +// Make sure we actually codegen a version of the function +pub fn do_stuff(mut f: Foo>, Box>>) { + let _x = f.next(); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_spike1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_spike1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_spike1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_spike1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// A simple spike test for MIR version of codegen. + +fn sum(x: i32, y: i32) -> i32 { + x + y +} + +fn main() { + let x = sum(22, 44); + assert_eq!(x, 66); + println!("sum()={:?}", x); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_switchint.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_switchint.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_switchint.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_switchint.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn foo(x: i8) -> i32 { + match x { + 1 => 0, + _ => 1, + } +} + +fn main() { + assert_eq!(foo(0), 1); + assert_eq!(foo(1), 0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_switch.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_switch.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_switch.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_codegen_switch.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +enum Abc { + A(u8), + B(i8), + C, + D, +} + +fn foo(x: Abc) -> i32 { + match x { + Abc::C => 3, + Abc::D => 4, + Abc::B(_) => 2, + Abc::A(_) => 1, + } +} + +fn foo2(x: Abc) -> bool { + match x { + Abc::D => true, + _ => false + } +} + +fn main() { + assert_eq!(1, foo(Abc::A(42))); + assert_eq!(2, foo(Abc::B(-100))); + assert_eq!(3, foo(Abc::C)); + assert_eq!(4, foo(Abc::D)); + + assert_eq!(false, foo2(Abc::A(1))); + assert_eq!(false, foo2(Abc::B(2))); + assert_eq!(false, foo2(Abc::C)); + assert_eq!(true, foo2(Abc::D)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_coercion_casts.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_coercion_casts.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_coercion_casts.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_coercion_casts.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests the coercion casts are handled properly + +fn main() { + // This should produce only a reification of f, + // not a fn -> fn cast as well + let _ = f as fn(&()); +} + +fn f<'a>(_: &'a ()) { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_coercions.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_coercions.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_coercions.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_coercions.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,81 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(coerce_unsized, unsize)] + +use std::ops::CoerceUnsized; +use std::marker::Unsize; + +fn identity_coercion(x: &(Fn(u32)->u32 + Send)) -> &Fn(u32)->u32 { + x +} +fn fn_coercions(f: &fn(u32) -> u32) -> + (unsafe fn(u32) -> u32, + &(Fn(u32) -> u32+Send)) +{ + (*f, f) +} + +fn simple_array_coercion(x: &[u8; 3]) -> &[u8] { x } + +fn square(a: u32) -> u32 { a * a } + +#[derive(PartialEq,Eq)] +struct PtrWrapper<'a, T: 'a+?Sized>(u32, u32, (), &'a T); +impl<'a, T: ?Sized+Unsize, U: ?Sized> + CoerceUnsized> for PtrWrapper<'a, T> {} + +struct TrivPtrWrapper<'a, T: 'a+?Sized>(&'a T); +impl<'a, T: ?Sized+Unsize, U: ?Sized> + CoerceUnsized> for TrivPtrWrapper<'a, T> {} + +fn coerce_ptr_wrapper(p: PtrWrapper<[u8; 3]>) -> PtrWrapper<[u8]> { + p +} + +fn coerce_triv_ptr_wrapper(p: TrivPtrWrapper<[u8; 3]>) -> TrivPtrWrapper<[u8]> { + p +} + +fn coerce_fat_ptr_wrapper(p: PtrWrapper u32+Send>) + -> PtrWrapper u32> { + p +} + +fn coerce_ptr_wrapper_poly<'a, T, Trait: ?Sized>(p: PtrWrapper<'a, T>) + -> PtrWrapper<'a, Trait> + where PtrWrapper<'a, T>: CoerceUnsized> +{ + p +} + +fn main() { + let a = [0,1,2]; + let square_local : fn(u32) -> u32 = square; + let (f,g) = fn_coercions(&square_local); + assert_eq!(f as usize, square as usize); + assert_eq!(g(4), 16); + assert_eq!(identity_coercion(g)(5), 25); + + assert_eq!(simple_array_coercion(&a), &a); + let w = coerce_ptr_wrapper(PtrWrapper(2,3,(),&a)); + assert!(w == PtrWrapper(2,3,(),&a) as PtrWrapper<[u8]>); + + let w = coerce_triv_ptr_wrapper(TrivPtrWrapper(&a)); + assert_eq!(&w.0, &a); + + let z = coerce_fat_ptr_wrapper(PtrWrapper(2,3,(),&square_local)); + assert_eq!((z.3)(6), 36); + + let z: PtrWrapper u32> = + coerce_ptr_wrapper_poly(PtrWrapper(2,3,(),&square_local)); + assert_eq!((z.3)(6), 36); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_constval_adts.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_constval_adts.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_constval_adts.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_constval_adts.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(PartialEq, Debug)] +struct Point { + _x: i32, + _y: i32, +} + +#[derive(PartialEq, Eq, Debug)] +struct Newtype(T); + +const STRUCT: Point = Point { _x: 42, _y: 42 }; +const TUPLE1: (i32, i32) = (42, 42); +const TUPLE2: (&'static str, &'static str) = ("hello","world"); +const PAIR_NEWTYPE: (Newtype, Newtype) = (Newtype(42), Newtype(42)); + +fn mir() -> (Point, (i32, i32), (&'static str, &'static str), (Newtype, Newtype)) { + let struct1 = STRUCT; + let tuple1 = TUPLE1; + let tuple2 = TUPLE2; + let pair_newtype = PAIR_NEWTYPE; + (struct1, tuple1, tuple2, pair_newtype) +} + +const NEWTYPE: Newtype<&'static str> = Newtype("foobar"); + +fn test_promoted_newtype_str_ref() { + let x = &NEWTYPE; + assert_eq!(x, &Newtype("foobar")); +} + +fn main(){ + assert_eq!(mir(), (STRUCT, TUPLE1, TUPLE2, PAIR_NEWTYPE)); + test_promoted_newtype_str_ref(); +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_drop_order.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_drop_order.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_drop_order.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_drop_order.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,58 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-wasm32-bare compiled with panic=abort by default + +use std::cell::RefCell; +use std::panic; + +pub struct DropLogger<'a> { + id: usize, + log: &'a panic::AssertUnwindSafe>> +} + +impl<'a> Drop for DropLogger<'a> { + fn drop(&mut self) { + self.log.0.borrow_mut().push(self.id); + } +} + +struct InjectedFailure; + +#[allow(unreachable_code)] +fn main() { + let log = panic::AssertUnwindSafe(RefCell::new(vec![])); + let d = |id| DropLogger { id: id, log: &log }; + let get = || -> Vec<_> { + let mut m = log.0.borrow_mut(); + let n = m.drain(..); + n.collect() + }; + + { + let _x = (d(0), &d(1), d(2), &d(3)); + // all borrows are extended - nothing has been dropped yet + assert_eq!(get(), vec![]); + } + // in a let-statement, extended places are dropped + // *after* the let result (tho they have the same scope + // as far as scope-based borrowck goes). + assert_eq!(get(), vec![0, 2, 3, 1]); + + let _ = std::panic::catch_unwind(|| { + (d(4), &d(5), d(6), &d(7), panic!(InjectedFailure)); + }); + + // here, the temporaries (5/7) live until the end of the + // containing statement, which is destroyed after the operands + // (4/6) on a panic. + assert_eq!(get(), vec![6, 4, 7, 5]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_early_return_scope.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_early_return_scope.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_early_return_scope.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_early_return_scope.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +static mut DROP: bool = false; + +struct ConnWrap(Conn); +impl ::std::ops::Deref for ConnWrap { + type Target=Conn; + fn deref(&self) -> &Conn { &self.0 } +} + +struct Conn; +impl Drop for Conn { + fn drop(&mut self) { unsafe { DROP = true; } } +} + +fn inner() { + let conn = &*match Some(ConnWrap(Conn)) { + Some(val) => val, + None => return, + }; + return; +} + +fn main() { + inner(); + unsafe { + assert_eq!(DROP, true); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_fat_ptr_drop.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_fat_ptr_drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_fat_ptr_drop.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_fat_ptr_drop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +#![allow(stable_features)] + +// test that ordinary fat pointer operations work. + +#![feature(braced_empty_structs)] +#![feature(rustc_attrs)] + +use std::sync::atomic; +use std::sync::atomic::Ordering::SeqCst; + +static COUNTER: atomic::AtomicUsize = atomic::ATOMIC_USIZE_INIT; + +struct DropMe { +} + +impl Drop for DropMe { + fn drop(&mut self) { + COUNTER.fetch_add(1, SeqCst); + } +} + +fn fat_ptr_move_then_drop(a: Box<[DropMe]>) { + let b = a; +} + +fn main() { + let a: Box<[DropMe]> = Box::new([DropMe { }]); + fat_ptr_move_then_drop(a); + assert_eq!(COUNTER.load(SeqCst), 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_fat_ptr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_fat_ptr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_fat_ptr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_fat_ptr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,62 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// test that ordinary fat pointer operations work. + +struct Wrapper(u32, T); + +struct FatPtrContainer<'a> { + ptr: &'a [u8] +} + +fn fat_ptr_project(a: &Wrapper<[u8]>) -> &[u8] { + &a.1 +} + +fn fat_ptr_simple(a: &[u8]) -> &[u8] { + a +} + +fn fat_ptr_via_local(a: &[u8]) -> &[u8] { + let x = a; + x +} + +fn fat_ptr_from_struct(s: FatPtrContainer) -> &[u8] { + s.ptr +} + +fn fat_ptr_to_struct(a: &[u8]) -> FatPtrContainer { + FatPtrContainer { ptr: a } +} + +fn fat_ptr_store_to<'a>(a: &'a [u8], b: &mut &'a [u8]) { + *b = a; +} + +fn fat_ptr_constant() -> &'static str { + "HELLO" +} + +fn main() { + let a = Wrapper(4, [7,6,5]); + + let p = fat_ptr_project(&a); + let p = fat_ptr_simple(p); + let p = fat_ptr_via_local(p); + let p = fat_ptr_from_struct(fat_ptr_to_struct(p)); + + let mut target : &[u8] = &[42]; + fat_ptr_store_to(p, &mut target); + assert_eq!(target, &a.1); + + assert_eq!(fat_ptr_constant(), "HELLO"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_heavy_promoted.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_heavy_promoted.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_heavy_promoted.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_heavy_promoted.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten apparently only works in optimized mode + +const TEST_DATA: [u8; 32 * 1024 * 1024] = [42; 32 * 1024 * 1024]; + +// Check that the promoted copy of TEST_DATA doesn't +// leave an alloca from an unused temp behind, which, +// without optimizations, can still blow the stack. +fn main() { + println!("{}", TEST_DATA.len()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir-inlining/ice-issue-45493.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir-inlining/ice-issue-45493.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir-inlining/ice-issue-45493.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir-inlining/ice-issue-45493.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags:-Zmir-opt-level=2 + +trait Array { + type Item; +} + +fn foo() { + let _: *mut A::Item = std::ptr::null_mut(); +} + +struct Foo; +impl Array for Foo { type Item = i32; } + +fn main() { + foo::(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir-inlining/ice-issue-45885.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir-inlining/ice-issue-45885.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir-inlining/ice-issue-45885.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir-inlining/ice-issue-45885.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags:-Zmir-opt-level=2 + +pub enum Enum { + A, + B, +} + +trait SliceIndex { + type Output; + fn get(&self) -> &Self::Output; +} + +impl SliceIndex for usize { + type Output = Enum; + #[inline(never)] + fn get(&self) -> &Enum { + &Enum::A + } +} + +#[inline(always)] +fn index(t: &T) -> &T::Output { + t.get() +} + +fn main() { + match *index(&0) { Enum::A => true, _ => false }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir-inlining/no-trait-method-issue-40473.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir-inlining/no-trait-method-issue-40473.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir-inlining/no-trait-method-issue-40473.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir-inlining/no-trait-method-issue-40473.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags:-Zmir-opt-level=2 +pub trait Foo { + fn bar(&self) -> usize { 2 } +} + +impl Foo for () { + fn bar(&self) -> usize { 3 } +} + +// Test a case where MIR would inline the default trait method +// instead of bailing out. Issue #40473. +fn main() { + let result = ().bar(); + assert_eq!(result, 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_match_arm_guard.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_match_arm_guard.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_match_arm_guard.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_match_arm_guard.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// #30527 - We were not generating arms with guards in certain cases. + +fn match_with_guard(x: Option) -> i8 { + match x { + Some(xyz) if xyz > 100 => 0, + Some(_) => -1, + None => -2 + } +} + +fn main() { + assert_eq!(match_with_guard(Some(111)), 0); + assert_eq!(match_with_guard(Some(2)), -1); + assert_eq!(match_with_guard(None), -2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_misc_casts.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_misc_casts.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_misc_casts.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_misc_casts.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,330 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn func(){} + +const STR: &'static str = "hello"; +const BSTR: &'static [u8; 5] = b"hello"; + +fn from_ptr() +-> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, *const ()) { + let f = 1_usize as *const String; + let c1 = f as isize; + let c2 = f as usize; + let c3 = f as i8; + let c4 = f as i16; + let c5 = f as i32; + let c6 = f as i64; + let c7 = f as u8; + let c8 = f as u16; + let c9 = f as u32; + let c10 = f as u64; + let c11 = f as *const (); + (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11) +} + +fn from_1() +-> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, *const String) { + let c1 = 1 as isize; + let c2 = 1 as usize; + let c3 = 1 as i8; + let c4 = 1 as i16; + let c5 = 1 as i32; + let c6 = 1 as i64; + let c7 = 1 as u8; + let c8 = 1 as u16; + let c9 = 1 as u32; + let c10 = 1 as u64; + let c11 = 1 as f32; + let c12 = 1 as f64; + let c13 = 1 as *const String; + (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) +} + +fn from_1usize() +-> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, *const String) { + let c1 = 1_usize as isize; + let c2 = 1_usize as usize; + let c3 = 1_usize as i8; + let c4 = 1_usize as i16; + let c5 = 1_usize as i32; + let c6 = 1_usize as i64; + let c7 = 1_usize as u8; + let c8 = 1_usize as u16; + let c9 = 1_usize as u32; + let c10 = 1_usize as u64; + let c11 = 1_usize as f32; + let c12 = 1_usize as f64; + let c13 = 1_usize as *const String; + (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) +} + +fn from_1isize() +-> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, *const String) { + let c1 = 1_isize as isize; + let c2 = 1_isize as usize; + let c3 = 1_isize as i8; + let c4 = 1_isize as i16; + let c5 = 1_isize as i32; + let c6 = 1_isize as i64; + let c7 = 1_isize as u8; + let c8 = 1_isize as u16; + let c9 = 1_isize as u32; + let c10 = 1_isize as u64; + let c11 = 1_isize as f32; + let c12 = 1_isize as f64; + let c13 = 1_isize as *const String; + (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) +} + +fn from_1u8() +-> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, *const String) { + let c1 = 1_u8 as isize; + let c2 = 1_u8 as usize; + let c3 = 1_u8 as i8; + let c4 = 1_u8 as i16; + let c5 = 1_u8 as i32; + let c6 = 1_u8 as i64; + let c7 = 1_u8 as u8; + let c8 = 1_u8 as u16; + let c9 = 1_u8 as u32; + let c10 = 1_u8 as u64; + let c11 = 1_u8 as f32; + let c12 = 1_u8 as f64; + let c13 = 1_u8 as *const String; + (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) +} + +fn from_1i8() +-> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, *const String) { + let c1 = 1_i8 as isize; + let c2 = 1_i8 as usize; + let c3 = 1_i8 as i8; + let c4 = 1_i8 as i16; + let c5 = 1_i8 as i32; + let c6 = 1_i8 as i64; + let c7 = 1_i8 as u8; + let c8 = 1_i8 as u16; + let c9 = 1_i8 as u32; + let c10 = 1_i8 as u64; + let c11 = 1_i8 as f32; + let c12 = 1_i8 as f64; + let c13 = 1_i8 as *const String; + (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) +} + +fn from_1u16() +-> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, *const String) { + let c1 = 1_u16 as isize; + let c2 = 1_u16 as usize; + let c3 = 1_u16 as i8; + let c4 = 1_u16 as i16; + let c5 = 1_u16 as i32; + let c6 = 1_u16 as i64; + let c7 = 1_u16 as u8; + let c8 = 1_u16 as u16; + let c9 = 1_u16 as u32; + let c10 = 1_u16 as u64; + let c11 = 1_u16 as f32; + let c12 = 1_u16 as f64; + let c13 = 1_u16 as *const String; + (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) +} + +fn from_1i16() +-> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, *const String) { + let c1 = 1_i16 as isize; + let c2 = 1_i16 as usize; + let c3 = 1_i16 as i8; + let c4 = 1_i16 as i16; + let c5 = 1_i16 as i32; + let c6 = 1_i16 as i64; + let c7 = 1_i16 as u8; + let c8 = 1_i16 as u16; + let c9 = 1_i16 as u32; + let c10 = 1_i16 as u64; + let c11 = 1_i16 as f32; + let c12 = 1_i16 as f64; + let c13 = 1_i16 as *const String; + (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) +} + +fn from_1u32() +-> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, *const String) { + let c1 = 1_u32 as isize; + let c2 = 1_u32 as usize; + let c3 = 1_u32 as i8; + let c4 = 1_u32 as i16; + let c5 = 1_u32 as i32; + let c6 = 1_u32 as i64; + let c7 = 1_u32 as u8; + let c8 = 1_u32 as u16; + let c9 = 1_u32 as u32; + let c10 = 1_u32 as u64; + let c11 = 1_u32 as f32; + let c12 = 1_u32 as f64; + let c13 = 1_u32 as *const String; + (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) +} + +fn from_1i32() +-> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, *const String) { + let c1 = 1_i32 as isize; + let c2 = 1_i32 as usize; + let c3 = 1_i32 as i8; + let c4 = 1_i32 as i16; + let c5 = 1_i32 as i32; + let c6 = 1_i32 as i64; + let c7 = 1_i32 as u8; + let c8 = 1_i32 as u16; + let c9 = 1_i32 as u32; + let c10 = 1_i32 as u64; + let c11 = 1_i32 as f32; + let c12 = 1_i32 as f64; + let c13 = 1_i32 as *const String; + (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) +} + +fn from_1u64() +-> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, *const String) { + let c1 = 1_u64 as isize; + let c2 = 1_u64 as usize; + let c3 = 1_u64 as i8; + let c4 = 1_u64 as i16; + let c5 = 1_u64 as i32; + let c6 = 1_u64 as i64; + let c7 = 1_u64 as u8; + let c8 = 1_u64 as u16; + let c9 = 1_u64 as u32; + let c10 = 1_u64 as u64; + let c11 = 1_u64 as f32; + let c12 = 1_u64 as f64; + let c13 = 1_u64 as *const String; + (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) +} + +fn from_1i64() +-> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, *const String) { + let c1 = 1_i64 as isize; + let c2 = 1_i64 as usize; + let c3 = 1_i64 as i8; + let c4 = 1_i64 as i16; + let c5 = 1_i64 as i32; + let c6 = 1_i64 as i64; + let c7 = 1_i64 as u8; + let c8 = 1_i64 as u16; + let c9 = 1_i64 as u32; + let c10 = 1_i64 as u64; + let c11 = 1_i64 as f32; + let c12 = 1_i64 as f64; + let c13 = 1_i64 as *const String; + (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) +} + +fn from_bool() +-> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64) { + let c1 = true as isize; + let c2 = true as usize; + let c3 = true as i8; + let c4 = true as i16; + let c5 = true as i32; + let c6 = true as i64; + let c7 = true as u8; + let c8 = true as u16; + let c9 = true as u32; + let c10 = true as u64; + (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) +} + +fn from_1f32() +-> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64) { + let c1 = 1.0_f32 as isize; + let c2 = 1.0_f32 as usize; + let c3 = 1.0_f32 as i8; + let c4 = 1.0_f32 as i16; + let c5 = 1.0_f32 as i32; + let c6 = 1.0_f32 as i64; + let c7 = 1.0_f32 as u8; + let c8 = 1.0_f32 as u16; + let c9 = 1.0_f32 as u32; + let c10 = 1.0_f32 as u64; + let c11 = 1.0_f32 as f32; + let c12 = 1.0_f32 as f64; + (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12) +} + +fn from_1f64() +-> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64) { + let c1 = 1.0f64 as isize; + let c2 = 1.0f64 as usize; + let c3 = 1.0f64 as i8; + let c4 = 1.0f64 as i16; + let c5 = 1.0f64 as i32; + let c6 = 1.0f64 as i64; + let c7 = 1.0f64 as u8; + let c8 = 1.0f64 as u16; + let c9 = 1.0f64 as u32; + let c10 = 1.0f64 as u64; + let c11 = 1.0f64 as f32; + let c12 = 1.0f64 as f64; + (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12) +} + +fn other_casts() +-> (*const u8, *const isize, *const u8, *const u8) { + let c1 = func as *const u8; + let c2 = c1 as *const isize; + + let r = &42u32; + let _ = r as *const u32; + + // fat-ptr -> fat-ptr -> fat-raw-ptr -> thin-ptr + let c3 = STR as &str as *const str as *const u8; + + let c4 = BSTR as *const [u8] as *const [u16] as *const u8; + (c1, c2, c3, c4) +} + +pub fn assert_eq_13(l: (isize, usize, i8, i16, i32, i64, u8, + u16, u32, u64, f32, f64, *const String), + r: (isize, usize, i8, i16, i32, i64, u8, + u16, u32, u64, f32, f64, *const String)) -> bool { + let (l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13) = l; + let (r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13) = r; + l1 == r1 && l2 == r2 && l3 == r3 && l4 == r4 && l5 == r5 && l6 == r6 && l7 == r7 && + l8 == r8 && l9 == r9 && l10 == r10 && l11 == r11 && l12 == r12 && l13 == r13 +} + + +pub fn main() { + let f = 1_usize as *const String; + let t13 = (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.0, 1.0, f); + let t12 = (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.0, 1.0); + assert_eq_13(from_1(), t13); + assert_eq_13(from_1usize(), t13); + assert_eq_13(from_1isize(), t13); + assert_eq_13(from_1u8(), t13); + assert_eq_13(from_1i8(), t13); + assert_eq_13(from_1u16(), t13); + assert_eq_13(from_1i16(), t13); + assert_eq_13(from_1u32(), t13); + assert_eq_13(from_1i32(), t13); + assert_eq_13(from_1u64(), t13); + assert_eq_13(from_1i64(), t13); + assert_eq!(from_1f32(), t12); + assert_eq!(from_1f64(), t12); + + assert_eq!(from_ptr(), (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 as *const ())); + assert_eq!(from_bool(), (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)); + + assert_eq!(other_casts(), (func as *const u8, func as *const isize, + STR as *const str as *const u8, BSTR as *const [u8] as *const u8)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_overflow_off.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_overflow_off.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_overflow_off.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_overflow_off.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags: -Z force-overflow-checks=off + +// Test that with MIR codegen, overflow checks can be +// turned off, even when they're from core::ops::*. + +use std::ops::*; + +fn main() { + assert_eq!(i8::neg(-0x80), -0x80); + + assert_eq!(u8::add(0xff, 1), 0_u8); + assert_eq!(u8::sub(0, 1), 0xff_u8); + assert_eq!(u8::mul(0xff, 2), 0xfe_u8); + assert_eq!(u8::shl(1, 9), 2_u8); + assert_eq!(u8::shr(2, 9), 1_u8); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_raw_fat_ptr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_raw_fat_ptr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_raw_fat_ptr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_raw_fat_ptr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,168 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// check raw fat pointer ops in mir +// FIXME: please improve this when we get monomorphization support + +use std::mem; + +#[derive(Debug, PartialEq, Eq)] +struct ComparisonResults { + lt: bool, + le: bool, + gt: bool, + ge: bool, + eq: bool, + ne: bool +} + +const LT: ComparisonResults = ComparisonResults { + lt: true, + le: true, + gt: false, + ge: false, + eq: false, + ne: true +}; + +const EQ: ComparisonResults = ComparisonResults { + lt: false, + le: true, + gt: false, + ge: true, + eq: true, + ne: false +}; + +const GT: ComparisonResults = ComparisonResults { + lt: false, + le: false, + gt: true, + ge: true, + eq: false, + ne: true +}; + +fn compare_su8(a: *const S<[u8]>, b: *const S<[u8]>) -> ComparisonResults { + ComparisonResults { + lt: a < b, + le: a <= b, + gt: a > b, + ge: a >= b, + eq: a == b, + ne: a != b + } +} + +fn compare_au8(a: *const [u8], b: *const [u8]) -> ComparisonResults { + ComparisonResults { + lt: a < b, + le: a <= b, + gt: a > b, + ge: a >= b, + eq: a == b, + ne: a != b + } +} + +fn compare_foo<'a>(a: *const (Foo+'a), b: *const (Foo+'a)) -> ComparisonResults { + ComparisonResults { + lt: a < b, + le: a <= b, + gt: a > b, + ge: a >= b, + eq: a == b, + ne: a != b + } +} + +fn simple_eq<'a>(a: *const (Foo+'a), b: *const (Foo+'a)) -> bool { + let result = a == b; + result +} + +fn assert_inorder(a: &[T], + compare: fn(T, T) -> ComparisonResults) { + for i in 0..a.len() { + for j in 0..a.len() { + let cres = compare(a[i], a[j]); + if i < j { + assert_eq!(cres, LT); + } else if i == j { + assert_eq!(cres, EQ); + } else { + assert_eq!(cres, GT); + } + } + } +} + +trait Foo { fn foo(&self) -> usize; } +impl Foo for T { + fn foo(&self) -> usize { + mem::size_of::() + } +} + +struct S(u32, T); + +fn main() { + let array = [0,1,2,3,4]; + let array2 = [5,6,7,8,9]; + + // fat ptr comparison: addr then extra + + // check ordering for arrays + let mut ptrs: Vec<*const [u8]> = vec![ + &array[0..0], &array[0..1], &array, &array[1..] + ]; + + let array_addr = &array as *const [u8] as *const u8 as usize; + let array2_addr = &array2 as *const [u8] as *const u8 as usize; + if array2_addr < array_addr { + ptrs.insert(0, &array2); + } else { + ptrs.push(&array2); + } + assert_inorder(&ptrs, compare_au8); + + let u8_ = (0u8, 1u8); + let u32_ = (4u32, 5u32); + + // check ordering for ptrs + let buf: &mut [*const Foo] = &mut [ + &u8_, &u8_.0, + &u32_, &u32_.0, + ]; + buf.sort_by(|u,v| { + let u : [*const (); 2] = unsafe { mem::transmute(*u) }; + let v : [*const (); 2] = unsafe { mem::transmute(*v) }; + u.cmp(&v) + }); + assert_inorder(buf, compare_foo); + + // check ordering for structs containing arrays + let ss: (S<[u8; 2]>, + S<[u8; 3]>, + S<[u8; 2]>) = ( + S(7, [8, 9]), + S(10, [11, 12, 13]), + S(4, [5, 6]) + ); + assert_inorder(&[ + &ss.0 as *const S<[u8]>, + &ss.1 as *const S<[u8]>, + &ss.2 as *const S<[u8]> + ], compare_su8); + + assert!(simple_eq(&0u8 as *const _, &0u8 as *const _)); + assert!(!simple_eq(&0u8 as *const _, &1u8 as *const _)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_refs_correct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_refs_correct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_refs_correct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_refs_correct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,219 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:mir_external_refs.rs + +extern crate mir_external_refs as ext; + +struct S(u8); +#[derive(Debug, PartialEq, Eq)] +struct Unit; + +impl S { + fn hey() -> u8 { 42 } + fn hey2(&self) -> u8 { 44 } +} + +trait X { + fn hoy(&self) -> u8 { 43 } + fn hoy2() -> u8 { 45 } +} + +trait F { + fn f(self, other: U) -> u64; +} + +impl F for u32 { + fn f(self, other: u32) -> u64 { self as u64 + other as u64 } +} + +impl F for u32 { + fn f(self, other: u64) -> u64 { self as u64 - other } +} + +impl F for u64 { + fn f(self, other: u64) -> u64 { self * other } +} + +impl F for u64 { + fn f(self, other: u32) -> u64 { self ^ other as u64 } +} + +trait T { + fn staticmeth(i: I, o: O) -> (I, O) { (i, o) } +} + +impl T for O {} + +impl X for S {} + +enum E { + U(u8) +} + +#[derive(PartialEq, Debug, Eq)] +enum CEnum { + A = 0x321, + B = 0x123 +} + +const C: u8 = 84; +const C2: [u8; 5] = [42; 5]; +const C3: [u8; 3] = [42, 41, 40]; +const C4: fn(u8) -> S = S; + +fn regular() -> u8 { + 21 +} + +fn parametric(u: T) -> T { + u +} + +fn t1() -> fn()->u8 { + regular +} + +fn t2() -> fn(u8)->E { + E::U +} + +fn t3() -> fn(u8)->S { + S +} + +fn t4() -> fn()->u8 { + S::hey +} + +fn t5() -> fn(&S)-> u8 { + ::hoy +} + + +fn t6() -> fn()->u8{ + ext::regular_fn +} + +fn t7() -> fn(u8)->ext::E { + ext::E::U +} + +fn t8() -> fn(u8)->ext::S { + ext::S +} + +fn t9() -> fn()->u8 { + ext::S::hey +} + +fn t10() -> fn(&ext::S)->u8 { + ::hoy +} + +fn t11() -> fn(u8)->u8 { + parametric +} + +fn t12() -> u8 { + C +} + +fn t13() -> [u8; 5] { + C2 +} + +fn t13_2() -> [u8; 3] { + C3 +} + +fn t14() -> fn()-> u8 { + ::hoy2 +} + +fn t15() -> fn(&S)-> u8 { + S::hey2 +} + +fn t16() -> fn(u32, u32)->u64 { + F::f +} + +fn t17() -> fn(u32, u64)->u64 { + F::f +} + +fn t18() -> fn(u64, u64)->u64 { + F::f +} + +fn t19() -> fn(u64, u32)->u64 { + F::f +} + +fn t20() -> fn(u64, u32)->(u64, u32) { + >::staticmeth +} + +fn t21() -> Unit { + Unit +} + +fn t22() -> Option { + None +} + +fn t23() -> (CEnum, CEnum) { + (CEnum::A, CEnum::B) +} + +fn t24() -> fn(u8) -> S { + C4 +} + +fn main() { + assert_eq!(t1()(), regular()); + + assert_eq!(t2() as *mut (), E::U as *mut ()); + assert_eq!(t3() as *mut (), S as *mut ()); + + assert_eq!(t4()(), S::hey()); + let s = S(42); + assert_eq!(t5()(&s), ::hoy(&s)); + + + assert_eq!(t6()(), ext::regular_fn()); + assert_eq!(t7() as *mut (), ext::E::U as *mut ()); + assert_eq!(t8() as *mut (), ext::S as *mut ()); + + assert_eq!(t9()(), ext::S::hey()); + let sext = ext::S(6); + assert_eq!(t10()(&sext), ::hoy(&sext)); + + let p = parametric::; + assert_eq!(t11() as *mut (), p as *mut ()); + + assert_eq!(t12(), C); + assert_eq!(t13(), C2); + assert_eq!(t13_2(), C3); + + assert_eq!(t14()(), ::hoy2()); + assert_eq!(t15()(&s), S::hey2(&s)); + assert_eq!(t16()(10u32, 20u32), F::f(10u32, 20u32)); + assert_eq!(t17()(30u32, 10u64), F::f(30u32, 10u64)); + assert_eq!(t18()(50u64, 5u64), F::f(50u64, 5u64)); + assert_eq!(t19()(322u64, 2u32), F::f(322u64, 2u32)); + assert_eq!(t20()(123u64, 38u32), >::staticmeth(123, 38)); + assert_eq!(t21(), Unit); + assert_eq!(t22(), None); + assert_eq!(t23(), (CEnum::A, CEnum::B)); + assert_eq!(t24(), C4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_small_agg_arg.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_small_agg_arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_small_agg_arg.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_small_agg_arg.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +fn foo((x, y): (i8, i8)) { +} + +fn main() { + foo((0, 1)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_struct_with_assoc_ty.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_struct_with_assoc_ty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_struct_with_assoc_ty.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_struct_with_assoc_ty.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::marker::PhantomData; + +pub trait DataBind { + type Data; +} + +impl DataBind for Global { + type Data = T; +} + +pub struct Global(PhantomData); + +pub struct Data { + pub offsets: as DataBind>::Data, +} + +fn create_data() -> Data { + let mut d = Data { offsets: [1, 2] }; + d.offsets[0] = 3; + d +} + + +fn main() { + let d = create_data(); + assert_eq!(d.offsets[0], 3); + assert_eq!(d.offsets[1], 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_temp_promotions.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_temp_promotions.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_temp_promotions.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_temp_promotions.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn test1(f: f32) -> bool { + // test that we properly promote temporaries to allocas when a temporary is assigned to + // multiple times (assignment is still happening once ∀ possible dataflows). + !(f.is_nan() || f.is_infinite()) +} + +fn main() { + assert_eq!(test1(0.0), true); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir-typeck-normalize-fn-sig.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir-typeck-normalize-fn-sig.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir-typeck-normalize-fn-sig.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir-typeck-normalize-fn-sig.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// This code was creating an ICE in the MIR type checker. The reason +// is that we are reifying a reference to a function (`foo::<'x>`), +// which involves extracting its signature, but we were not +// normalizing the signature afterwards. As a result, we sometimes got +// errors around the `>::Value`, which can be +// normalized to `f64`. + +#![allow(dead_code)] + +trait Foo<'x> { + type Value; +} + +impl<'x> Foo<'x> for u32 { + type Value = f64; +} + +struct Providers<'x> { + foo: for<'y> fn(x: &'x u32, y: &'y u32) -> >::Value, +} + +fn foo<'y, 'x: 'x>(x: &'x u32, y: &'y u32) -> >::Value { + *x as f64 +} + +fn main() { + Providers { foo }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_void_return_2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_void_return_2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_void_return_2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_void_return_2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn nil() {} + +fn mir(){ + nil() +} + +pub fn main() { + mir(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_void_return.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_void_return.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mir/mir_void_return.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mir/mir_void_return.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn mir() -> (){ + let x = 1; + let mut y = 0; + while y < x { + y += 1 + } +} + +pub fn main() { + mir(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/auxiliary/two_macros_2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/auxiliary/two_macros_2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/auxiliary/two_macros_2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/auxiliary/two_macros_2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! macro_one { ($($t:tt)*) => ($($t)*) } + +macro_rules! macro_two { ($($t:tt)*) => ($($t)*) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_implicit_aux/mod.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_implicit_aux/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_implicit_aux/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_implicit_aux/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn foo() -> isize { 10 } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_implicit.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_implicit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_implicit.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_implicit.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-pretty issue #37195 + +mod mod_dir_implicit_aux; + +pub fn main() { + assert_eq!(mod_dir_implicit_aux::foo(), 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_path2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_path2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_path2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_path2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-pretty issue #37195 + +#[path = "mod_dir_simple"] +mod pancakes { + #[path = "test.rs"] + pub mod syrup; +} + +pub fn main() { + assert_eq!(pancakes::syrup::foo(), 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_path3.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_path3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_path3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_path3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-pretty issue #37195 + +#[path = "mod_dir_simple"] +mod pancakes { + pub mod test; +} + +pub fn main() { + assert_eq!(pancakes::test::foo(), 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_path_multi.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_path_multi.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_path_multi.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_path_multi.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-pretty issue #37195 + +#[path = "mod_dir_simple"] +mod biscuits { + pub mod test; +} + +#[path = "mod_dir_simple"] +mod gravy { + pub mod test; +} + +pub fn main() { + assert_eq!(biscuits::test::foo(), 10); + assert_eq!(gravy::test::foo(), 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_path.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_path.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_path.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_path.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_macros)] +// ignore-pretty issue #37195 + +mod mod_dir_simple { + #[path = "test.rs"] + pub mod syrup; +} + +pub fn main() { + assert_eq!(mod_dir_simple::syrup::foo(), 10); + + #[path = "auxiliary"] + mod foo { + mod two_macros_2; + } + + #[path = "auxiliary"] + mod bar { + macro_rules! m { () => { mod two_macros_2; } } + m!(); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_recursive.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_recursive.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_recursive.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_recursive.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-pretty issue #37195 + +// Testing that the parser for each file tracks its modules +// and paths independently. The load_another_mod module should +// not try to reuse the 'mod_dir_simple' path. + +mod mod_dir_simple { + pub mod load_another_mod; +} + +pub fn main() { + assert_eq!(mod_dir_simple::load_another_mod::test::foo(), 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_simple/load_another_mod.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_simple/load_another_mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_simple/load_another_mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_simple/load_another_mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[path = "test.rs"] +pub mod test; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_simple/test.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_simple/test.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_simple/test.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_simple/test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn foo() -> isize { 10 } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_simple.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_simple.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_dir_simple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-pretty issue #37195 + +mod mod_dir_simple { + pub mod test; +} + +pub fn main() { + assert_eq!(mod_dir_simple::test::foo(), 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_file_aux.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_file_aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_file_aux.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_file_aux.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-test Not a test. Used by other tests + +pub fn foo() -> isize { 10 } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_file.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_file.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_file.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_file.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-pretty issue #37195 + +// Testing that a plain .rs file can load modules from other source files + +mod mod_file_aux; + +pub fn main() { + assert_eq!(mod_file_aux::foo(), 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_file_with_path_attr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_file_with_path_attr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod_file_with_path_attr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod_file_with_path_attr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-pretty issue #37195 + +// Testing that a plain .rs file can load modules from other source files + +#[path = "mod_file_aux.rs"] +mod m; + +pub fn main() { + assert_eq!(m::foo(), 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod-inside-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod-inside-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod-inside-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod-inside-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn f() -> isize { + mod m { + pub fn g() -> isize { 720 } + } + + m::g() +} + +pub fn main() { + assert_eq!(f(), 720); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/module-polymorphism3-files/float-template/inst_f32.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/module-polymorphism3-files/float-template/inst_f32.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/module-polymorphism3-files/float-template/inst_f32.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/module-polymorphism3-files/float-template/inst_f32.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub type T = f32; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/module-polymorphism3-files/float-template/inst_f64.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/module-polymorphism3-files/float-template/inst_f64.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/module-polymorphism3-files/float-template/inst_f64.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/module-polymorphism3-files/float-template/inst_f64.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub type T = f64; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/module-polymorphism3-files/float-template/inst_float.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/module-polymorphism3-files/float-template/inst_float.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/module-polymorphism3-files/float-template/inst_float.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/module-polymorphism3-files/float-template/inst_float.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub type T = float; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod-view-items.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod-view-items.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/modules/mod-view-items.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/modules/mod-view-items.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test view items inside non-file-level mods + +// This is a regression test for an issue where we were failing to +// pretty-print such view items. If that happens again, this should +// begin failing. + +// pretty-expanded FIXME #23616 + +mod m { + pub fn f() -> Vec { Vec::new() } +} + +pub fn main() { let _x = m::f(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/monad.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/monad.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/monad.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/monad.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/monomorphize-abi-alignment.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/monomorphize-abi-alignment.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/monomorphize-abi-alignment.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/monomorphize-abi-alignment.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_upper_case_globals)] /*! * On x86_64-linux-gnu and possibly other platforms, structs get 8-byte "preferred" alignment, * but their "ABI" alignment (i.e., what actually matters for data layout) is the largest alignment diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-1-unique.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-1-unique.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-1-unique.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-1-unique.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +#![feature(box_syntax)] + +#[derive(Clone)] +struct Triple { + x: isize, + y: isize, + z: isize, +} + +fn test(x: bool, foo: Box) -> isize { + let bar = foo; + let mut y: Box; + if x { y = bar; } else { y = box Triple{x: 4, y: 5, z: 6}; } + return y.y; +} + +pub fn main() { + let x: Box<_> = box Triple{x: 1, y: 2, z: 3}; + assert_eq!(test(true, x.clone()), 2); + assert_eq!(test(true, x.clone()), 2); + assert_eq!(test(true, x.clone()), 2); + assert_eq!(test(false, x), 5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![feature(box_syntax)] + +struct X { x: isize, y: isize, z: isize } + +pub fn main() { let x: Box<_> = box X {x: 1, y: 2, z: 3}; let y = x; assert_eq!(y.y, 2); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-2-unique.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-2-unique.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-2-unique.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-2-unique.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![feature(box_syntax)] + +struct X { x: isize, y: isize, z: isize } + +pub fn main() { + let x: Box<_> = box X{x: 1, y: 2, z: 3}; + let y = x; + assert_eq!(y.y, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-3-unique.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-3-unique.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-3-unique.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-3-unique.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +#![feature(box_syntax)] + +#[derive(Clone)] +struct Triple { + x: isize, + y: isize, + z: isize, +} + +fn test(x: bool, foo: Box) -> isize { + let bar = foo; + let mut y: Box; + if x { y = bar; } else { y = box Triple {x: 4, y: 5, z: 6}; } + return y.y; +} + +pub fn main() { + let x: Box<_> = box Triple{x: 1, y: 2, z: 3}; + for _ in 0_usize..10000_usize { + assert_eq!(test(true, x.clone()), 2); + } + assert_eq!(test(false, x), 5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-4.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-4.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-4.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![feature(box_syntax)] + +struct Triple { a: isize, b: isize, c: isize } + +fn test(foo: Box) -> Box { + let foo = foo; + let bar = foo; + let baz = bar; + let quux = baz; + return quux; +} + +pub fn main() { + let x = box Triple{a: 1, b: 2, c: 3}; + let y = test(x); + assert_eq!(y.c, 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-4-unique.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-4-unique.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-4-unique.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-4-unique.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![feature(box_syntax)] + +struct Triple {a: isize, b: isize, c: isize} + +fn test(foo: Box) -> Box { + let foo = foo; + let bar = foo; + let baz = bar; + let quux = baz; + return quux; +} + +pub fn main() { + let x = box Triple{a: 1, b: 2, c: 3}; + let y = test(x); + assert_eq!(y.c, 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-arg-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-arg-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-arg-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-arg-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +fn test(foo: Box>) { assert_eq!((*foo)[0], 10); } + +pub fn main() { + let x = box vec![10]; + // Test forgetting a local by move-in + test(x); + + // Test forgetting a temporary by move-in. + test(box vec![10]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-arg-2-unique.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-arg-2-unique.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-arg-2-unique.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-arg-2-unique.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +fn test(foo: Box> ) { assert_eq!((*foo)[0], 10); } + +pub fn main() { + let x = box vec![10]; + // Test forgetting a local by move-in + test(x); + + // Test forgetting a temporary by move-in. + test(box vec![10]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-arg.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-arg.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn test(foo: isize) { assert_eq!(foo, 10); } + +pub fn main() { let x = 10; test(x); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-nullary-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-nullary-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-nullary-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-nullary-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Issue #922 +// pretty-expanded FIXME #23616 + +fn f2(_thing: F) where F: FnOnce() { } + +fn f(thing: F) where F: FnOnce() { + f2(thing); +} + +pub fn main() { + f(|| {}); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-out-of-field.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-out-of-field.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-out-of-field.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-out-of-field.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::string::String; + +struct StringBuffer { + s: String, +} + +impl StringBuffer { + pub fn append(&mut self, v: &str) { + self.s.push_str(v); + } +} + +fn to_string(sb: StringBuffer) -> String { + sb.s +} + +pub fn main() { + let mut sb = StringBuffer { + s: String::new(), + }; + sb.append("Hello, "); + sb.append("World!"); + let str = to_string(sb); + assert_eq!(str, "Hello, World!"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/moves-based-on-type-capture-clause.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/moves-based-on-type-capture-clause.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/moves-based-on-type-capture-clause.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/moves-based-on-type-capture-clause.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// ignore-emscripten no threads support + +use std::thread; + +pub fn main() { + let x = "Hello world!".to_string(); + thread::spawn(move|| { + println!("{}", x); + }).join(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-scalar.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-scalar.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/moves/move-scalar.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/moves/move-scalar.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] + +pub fn main() { + + let y: isize = 42; + let mut x: isize; + x = y; + assert_eq!(x, 42); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/multiple-reprs.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/multiple-reprs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/multiple-reprs.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/multiple-reprs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] use std::mem::{size_of, align_of}; use std::os::raw::c_int; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mutual-recursion-group.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mutual-recursion-group.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/mutual-recursion-group.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/mutual-recursion-group.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(dead_code)] // pretty-expanded FIXME #23616 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nested-class.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nested-class.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nested-class.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nested-class.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] pub fn main() { struct b { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/never-result.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/never-result.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/never-result.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/never-result.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_variables)] +#![allow(unreachable_code)] // Test that we can extract a ! through pattern matching then use it as several different types. #![feature(never_type)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/newlambdas-ret-infer2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/newlambdas-ret-infer2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/newlambdas-ret-infer2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/newlambdas-ret-infer2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // Test that the lambda kind is inferred correctly as a return // expression diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/newlambdas-ret-infer.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/newlambdas-ret-infer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/newlambdas-ret-infer.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/newlambdas-ret-infer.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // Test that the lambda kind is inferred correctly as a return // expression diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/newtype-polymorphic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/newtype-polymorphic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/newtype-polymorphic.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/newtype-polymorphic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] #[derive(Clone)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/newtype.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/newtype.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/newtype.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/newtype.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] #[derive(Copy, Clone)] struct mytype(Mytype); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nil-decl-in-foreign.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nil-decl-in-foreign.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nil-decl-in-foreign.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nil-decl-in-foreign.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(improper_ctypes)] +#![allow(dead_code)] // Issue #901 // pretty-expanded FIXME #23616 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nll/issue-47153-generic-const.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nll/issue-47153-generic-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nll/issue-47153-generic-const.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nll/issue-47153-generic-const.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// Regression test for #47153: constants in a generic context (such as +// a trait) used to ICE. + +#![feature(nll)] +#![allow(warnings)] + +trait Foo { + const B: bool = true; +} + +struct Bar { x: T } + +impl Bar { + const B: bool = true; +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nll/issue-47589.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nll/issue-47589.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nll/issue-47589.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nll/issue-47589.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(nll)] + +pub struct DescriptorSet<'a> { + pub slots: Vec> +} + +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) +} + +fn main() { + let _x = DescriptorSet {slots: Vec::new()}; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nll/issue-48623-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nll/issue-48623-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nll/issue-48623-closure.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nll/issue-48623-closure.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(path_statements)] +#![allow(dead_code)] + +#![feature(nll)] + +struct WithDrop; + +impl Drop for WithDrop { + fn drop(&mut self) {} +} + +fn reborrow_from_closure(r: &mut ()) -> &mut () { + let d = WithDrop; + (move || { d; &mut *r })() +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nll/issue-48623-generator.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nll/issue-48623-generator.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nll/issue-48623-generator.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nll/issue-48623-generator.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(path_statements)] +#![allow(dead_code)] + +#![feature(nll)] +#![feature(generators, generator_trait)] + +struct WithDrop; + +impl Drop for WithDrop { + fn drop(&mut self) {} +} + +fn reborrow_from_generator(r: &mut ()) { + let d = WithDrop; + move || { d; yield; &mut *r }; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nll/issue-50343.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nll/issue-50343.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nll/issue-50343.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nll/issue-50343.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(nll)] +#![deny(unused_mut)] + +fn main() { + vec![42].iter().map(|_| ()).count(); + vec![(42, 22)].iter().map(|(_x, _y)| ()).count(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nll/issue-50461-used-mut-from-moves.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nll/issue-50461-used-mut-from-moves.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nll/issue-50461-used-mut-from-moves.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nll/issue-50461-used-mut-from-moves.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(nll)] +#![deny(unused_mut)] + +struct Foo { + pub value: i32 +} + +fn use_foo_mut(mut foo: Foo) { + foo = foo; + println!("{}", foo.value); +} + +fn main() { + use_foo_mut(Foo { value: 413 }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nll/issue-53123-raw-pointer-cast.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nll/issue-53123-raw-pointer-cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nll/issue-53123-raw-pointer-cast.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nll/issue-53123-raw-pointer-cast.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(nll)] +#![allow(unused_variables)] + +pub trait TryTransform { + fn try_transform(self, f: F) + where + Self: Sized, + F: FnOnce(Self); +} + +impl<'a, T> TryTransform for &'a mut T { + fn try_transform(self, f: F) + where + // The bug was that `Self: Sized` caused the lifetime of `this` to "extend" for all + // of 'a instead of only lasting as long as the binding is used (for just that line). + Self: Sized, + F: FnOnce(Self), + { + let this: *mut T = self as *mut T; + f(self); + } +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nll/mutating_references.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nll/mutating_references.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nll/mutating_references.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nll/mutating_references.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(nll)] + +struct List { + value: T, + next: Option>>, +} + +fn to_refs(mut list: &mut List) -> Vec<&mut T> { + let mut result = vec![]; + loop { + result.push(&mut list.value); + if let Some(n) = list.next.as_mut() { + list = n; + } else { + return result; + } + } +} + +fn main() { + let mut list = List { value: 1, next: None }; + let vec = to_refs(&mut list); + assert_eq!(vec![&mut 1], vec); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nll/process_or_insert_default.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nll/process_or_insert_default.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nll/process_or_insert_default.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nll/process_or_insert_default.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(nll)] + +use std::collections::HashMap; + +fn process_or_insert_default(map: &mut HashMap, key: usize) { + match map.get_mut(&key) { + Some(value) => { + process(value); + } + None => { + map.insert(key, "".to_string()); + } + } +} + +fn process(x: &str) { + assert_eq!(x, "Hello, world"); +} + +fn main() { + let map = &mut HashMap::new(); + map.insert(22, format!("Hello, world")); + map.insert(44, format!("Goodbye, world")); + process_or_insert_default(map, 22); + process_or_insert_default(map, 66); + assert_eq!(map[&66], ""); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nll/rc-loop.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nll/rc-loop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nll/rc-loop.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nll/rc-loop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// A test for something that NLL enables. It sometimes happens that +// the `while let` pattern makes some borrows from a variable (in this +// case, `x`) that you need in order to compute the next value for +// `x`. The lexical checker makes this very painful. The NLL checker +// does not. + +#![feature(nll)] + +use std::rc::Rc; + +#[derive(Debug, PartialEq, Eq)] +enum Foo { + Base(usize), + Next(Rc), +} + +fn find_base(mut x: Rc) -> Rc { + while let Foo::Next(n) = &*x { + x = n.clone(); + } + x +} + +fn main() { + let chain = Rc::new(Foo::Next(Rc::new(Foo::Base(44)))); + let base = find_base(chain); + assert_eq!(&*base, &Foo::Base(44)); +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/no-core-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/no-core-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/no-core-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/no-core-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(stable_features)] #![feature(no_core, core)] #![no_core] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/foors_mod/inner_foors_mod/innest.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/foors_mod/inner_foors_mod/innest.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/foors_mod/inner_foors_mod/innest.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/foors_mod/inner_foors_mod/innest.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/foors_mod/inner_foors_mod.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/foors_mod/inner_foors_mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/foors_mod/inner_foors_mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/foors_mod/inner_foors_mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod innest; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/innest.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/innest.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/innest.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/innest.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/mod.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod innest; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/foors_mod.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/foors_mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/foors_mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/foors_mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// ignore-test: not a test, used by non_modrs_mods.rs + +pub mod inner_modrs_mod; +pub mod inner_foors_mod; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod/innest.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod/innest.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod/innest.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod/innest.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod innest; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/innest.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/innest.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/innest.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/innest.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/mod.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod innest; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/modrs_mod/mod.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/modrs_mod/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/modrs_mod/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/modrs_mod/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod inner_modrs_mod; +pub mod inner_foors_mod; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/arbitrary_name.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/arbitrary_name.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/arbitrary_name.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/arbitrary_name.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod inner_modrs_mod; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/innest.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/innest.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/innest.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/innest.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/mod.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod innest; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nullable-pointer-size.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nullable-pointer-size.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/nullable-pointer-size.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/nullable-pointer-size.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] use std::mem; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/arith-0.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/arith-0.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/arith-0.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/arith-0.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +pub fn main() { + let a: isize = 10; + println!("{}", a); + assert_eq!(a * (a - 1), 90); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/arith-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/arith-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/arith-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/arith-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +pub fn main() { + let i32_a: isize = 10; + assert_eq!(i32_a, 10); + assert_eq!(i32_a - 10, 0); + assert_eq!(i32_a / 10, 1); + assert_eq!(i32_a - 20, -10); + assert_eq!(i32_a << 10, 10240); + assert_eq!(i32_a << 16, 655360); + assert_eq!(i32_a * 16, 160); + assert_eq!(i32_a * i32_a * i32_a, 1000); + assert_eq!(i32_a * i32_a * i32_a * i32_a, 10000); + assert_eq!(i32_a * i32_a / i32_a * i32_a, 100); + assert_eq!(i32_a * (i32_a - 1) << (2 + i32_a as usize), 368640); + let i32_b: isize = 0x10101010; + assert_eq!(i32_b + 1 - 1, i32_b); + assert_eq!(i32_b << 1, i32_b << 1); + assert_eq!(i32_b >> 1, i32_b >> 1); + assert_eq!(i32_b & i32_b << 1, 0); + println!("{}", i32_b | i32_b << 1); + assert_eq!(i32_b | i32_b << 1, 0x30303030); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/arith-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/arith-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/arith-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/arith-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + +pub fn main() { + let i32_c: isize = 0x10101010; + assert_eq!(i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3), + i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/arith-unsigned.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/arith-unsigned.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/arith-unsigned.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/arith-unsigned.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_comparisons)] + +// Unsigned integer operations +pub fn main() { + assert!((0u8 < 255u8)); + assert!((0u8 <= 255u8)); + assert!((255u8 > 0u8)); + assert!((255u8 >= 0u8)); + assert_eq!(250u8 / 10u8, 25u8); + assert_eq!(255u8 % 10u8, 5u8); + assert!((0u16 < 60000u16)); + assert!((0u16 <= 60000u16)); + assert!((60000u16 > 0u16)); + assert!((60000u16 >= 0u16)); + assert_eq!(60000u16 / 10u16, 6000u16); + assert_eq!(60005u16 % 10u16, 5u16); + assert!((0u32 < 4000000000u32)); + assert!((0u32 <= 4000000000u32)); + assert!((4000000000u32 > 0u32)); + assert!((4000000000u32 >= 0u32)); + assert_eq!(4000000000u32 / 10u32, 400000000u32); + assert_eq!(4000000005u32 % 10u32, 5u32); + // 64-bit numbers have some flakiness yet. Not tested + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/div-mod.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/div-mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/div-mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/div-mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + + +pub fn main() { + let x: isize = 15; + let y: isize = 5; + assert_eq!(x / 5, 3); + assert_eq!(x / 4, 3); + assert_eq!(x / 3, 5); + assert_eq!(x / y, 3); + assert_eq!(15 / y, 3); + assert_eq!(x % 5, 0); + assert_eq!(x % 4, 3); + assert_eq!(x % 3, 0); + assert_eq!(x % y, 0); + assert_eq!(15 % y, 0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + +pub fn main() { + let a = 1.5e6f64; + let b = 1.5E6f64; + let c = 1e6f64; + let d = 1E6f64; + let e = 3.0f32; + let f = 5.9f64; + let g = 1e6f32; + let h = 1.0e7f64; + let i = 1.0E7f64; + let j = 3.1e+9f64; + let k = 3.2e-10f64; + assert_eq!(a, b); + assert!((c < b)); + assert_eq!(c, d); + assert!((e < g)); + assert!((f < h)); + assert_eq!(g, 1000000.0f32); + assert_eq!(h, i); + assert!((j > k)); + assert!((k < a)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float-int-invalid-const-cast.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float-int-invalid-const-cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float-int-invalid-const-cast.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float-int-invalid-const-cast.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,63 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten no i128 support + +#![deny(const_err)] + +use std::{f32, f64}; + +// Forces evaluation of constants, triggering hard error +fn force(_: T) {} + +fn main() { + { const X: u16 = -1. as u16; force(X); } + { const X: u128 = -100. as u128; force(X); } + + { const X: i8 = f32::NAN as i8; force(X); } + { const X: i32 = f32::NAN as i32; force(X); } + { const X: u64 = f32::NAN as u64; force(X); } + { const X: u128 = f32::NAN as u128; force(X); } + + { const X: i8 = f32::INFINITY as i8; force(X); } + { const X: u32 = f32::INFINITY as u32; force(X); } + { const X: i128 = f32::INFINITY as i128; force(X); } + { const X: u128 = f32::INFINITY as u128; force(X); } + + { const X: u8 = f32::NEG_INFINITY as u8; force(X); } + { const X: u16 = f32::NEG_INFINITY as u16; force(X); } + { const X: i64 = f32::NEG_INFINITY as i64; force(X); } + { const X: i128 = f32::NEG_INFINITY as i128; force(X); } + + { const X: i8 = f64::NAN as i8; force(X); } + { const X: i32 = f64::NAN as i32; force(X); } + { const X: u64 = f64::NAN as u64; force(X); } + { const X: u128 = f64::NAN as u128; force(X); } + + { const X: i8 = f64::INFINITY as i8; force(X); } + { const X: u32 = f64::INFINITY as u32; force(X); } + { const X: i128 = f64::INFINITY as i128; force(X); } + { const X: u128 = f64::INFINITY as u128; force(X); } + + { const X: u8 = f64::NEG_INFINITY as u8; force(X); } + { const X: u16 = f64::NEG_INFINITY as u16; force(X); } + { const X: i64 = f64::NEG_INFINITY as i64; force(X); } + { const X: i128 = f64::NEG_INFINITY as i128; force(X); } + + { const X: u8 = 256. as u8; force(X); } + { const X: i8 = -129. as i8; force(X); } + { const X: i8 = 128. as i8; force(X); } + { const X: i32 = 2147483648. as i32; force(X); } + { const X: i32 = -2147483904. as i32; force(X); } + { const X: u32 = 4294967296. as u32; force(X); } + { const X: u128 = 1e40 as u128; force(X); } + { const X: i128 = 1e40 as i128; force(X); } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float-literal-inference.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float-literal-inference.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float-literal-inference.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float-literal-inference.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct S { + z: f64 +} + +pub fn main() { + let x: f32 = 4.0; + println!("{}", x); + let y: f64 = 64.0; + println!("{}", y); + let z = S { z: 1.0 }; + println!("{}", z.z); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/floatlits.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/floatlits.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/floatlits.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/floatlits.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + +pub fn main() { + let f = 4.999999999999f64; + assert!((f > 4.90f64)); + assert!((f < 5.0f64)); + let g = 4.90000000001e-10f64; + assert!((g > 5e-11f64)); + assert!((g < 5e-9f64)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float_math.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float_math.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float_math.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float_math.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(core_intrinsics)] + +use std::intrinsics::{fadd_fast, fsub_fast, fmul_fast, fdiv_fast, frem_fast}; + +#[inline(never)] +pub fn test_operations(a: f64, b: f64) { + // make sure they all map to the correct operation + unsafe { + assert_eq!(fadd_fast(a, b), a + b); + assert_eq!(fsub_fast(a, b), a - b); + assert_eq!(fmul_fast(a, b), a * b); + assert_eq!(fdiv_fast(a, b), a / b); + assert_eq!(frem_fast(a, b), a % b); + } +} + +fn main() { + test_operations(1., 2.); + test_operations(10., 5.); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float-nan.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float-nan.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float-nan.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float-nan.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,93 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::f64; + +pub fn main() { + let nan: f64 = f64::NAN; + assert!((nan).is_nan()); + + let inf: f64 = f64::INFINITY; + let neg_inf: f64 = -f64::INFINITY; + assert_eq!(-inf, neg_inf); + + assert!( nan != nan); + assert!( nan != -nan); + assert!(-nan != -nan); + assert!(-nan != nan); + + assert!( nan != 1.); + assert!( nan != 0.); + assert!( nan != inf); + assert!( nan != -inf); + + assert!( 1. != nan); + assert!( 0. != nan); + assert!( inf != nan); + assert!(-inf != nan); + + assert!(!( nan == nan)); + assert!(!( nan == -nan)); + assert!(!( nan == 1.)); + assert!(!( nan == 0.)); + assert!(!( nan == inf)); + assert!(!( nan == -inf)); + assert!(!( 1. == nan)); + assert!(!( 0. == nan)); + assert!(!( inf == nan)); + assert!(!(-inf == nan)); + assert!(!(-nan == nan)); + assert!(!(-nan == -nan)); + + assert!(!( nan > nan)); + assert!(!( nan > -nan)); + assert!(!( nan > 0.)); + assert!(!( nan > inf)); + assert!(!( nan > -inf)); + assert!(!( 0. > nan)); + assert!(!( inf > nan)); + assert!(!(-inf > nan)); + assert!(!(-nan > nan)); + + assert!(!(nan < 0.)); + assert!(!(nan < 1.)); + assert!(!(nan < -1.)); + assert!(!(nan < inf)); + assert!(!(nan < -inf)); + assert!(!(nan < nan)); + assert!(!(nan < -nan)); + + assert!(!( 0. < nan)); + assert!(!( 1. < nan)); + assert!(!( -1. < nan)); + assert!(!( inf < nan)); + assert!(!(-inf < nan)); + assert!(!(-nan < nan)); + + assert!((nan + inf).is_nan()); + assert!((nan + -inf).is_nan()); + assert!((nan + 0.).is_nan()); + assert!((nan + 1.).is_nan()); + assert!((nan * 1.).is_nan()); + assert!((nan / 1.).is_nan()); + assert!((nan / 0.).is_nan()); + assert!((0.0/0.0f64).is_nan()); + assert!((-inf + inf).is_nan()); + assert!((inf - inf).is_nan()); + + assert!(!(-1.0f64).is_nan()); + assert!(!(0.0f64).is_nan()); + assert!(!(0.1f64).is_nan()); + assert!(!(1.0f64).is_nan()); + assert!(!(inf).is_nan()); + assert!(!(-inf).is_nan()); + assert!(!(1./-inf).is_nan()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn main() { + let pi = 3.1415927f64; + println!("{}", -pi * (pi + 2.0 / pi) - pi * 5.0); + if pi == 5.0 || pi < 10.0 || pi <= 2.0 || pi != 22.0 / 7.0 || pi >= 10.0 + || pi > 1.0 { + println!("yes"); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float-signature.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float-signature.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float-signature.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/float-signature.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +pub fn main() { + fn foo(n: f64) -> f64 { return n + 0.12345; } + let n: f64 = 0.1; + let m: f64 = foo(n); + println!("{}", m); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/i128-ffi.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/i128-ffi.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/i128-ffi.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/i128-ffi.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(improper_ctypes)] + +// MSVC doesn't support 128 bit integers, and other Windows +// C compilers have very inconsistent views on how the ABI +// should look like. + +// ignore-windows +// ignore-32bit + +#[link(name = "rust_test_helpers", kind = "static")] +extern "C" { + fn identity(f: u128) -> u128; + fn square(f: i128) -> i128; + fn sub(f: i128, f: i128) -> i128; +} + +fn main() { + unsafe { + let a = 0x734C_C2F2_A521; + let b = 0x33EE_0E2A_54E2_59DA_A0E7_8E41; + let b_out = identity(b); + assert_eq!(b, b_out); + let a_square = square(a); + assert_eq!(b, a_square as u128); + let k = 0x1234_5678_9ABC_DEFF_EDCB_A987_6543_210; + let k_d = 0x2468_ACF1_3579_BDFF_DB97_530E_CA86_420; + let k_out = sub(k_d, k); + assert_eq!(k, k_out); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/i128.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/i128.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/i128.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/i128.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,121 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(overflowing_literals)] + +// ignore-emscripten i128 doesn't work + +// compile-flags: -Z borrowck=compare + +#![feature(test)] + +extern crate test; +use test::black_box as b; + +fn main() { + let x: i128 = -1; + assert_eq!(0, !x); + let y: i128 = -2; + assert_eq!(!1, y); + let z: i128 = 0xABCD_EF; + assert_eq!(z * z, 0x734C_C2F2_A521); + assert_eq!(z * z * z * z, 0x33EE_0E2A_54E2_59DA_A0E7_8E41); + assert_eq!(-z * -z, 0x734C_C2F2_A521); + assert_eq!(-z * -z * -z * -z, 0x33EE_0E2A_54E2_59DA_A0E7_8E41); + assert_eq!(-z + -z + -z + -z, -0x2AF3_7BC); + let k: i128 = -0x1234_5678_9ABC_DEFF_EDCB_A987_6543_210; + assert_eq!(k + k, -0x2468_ACF1_3579_BDFF_DB97_530E_CA86_420); + assert_eq!(0, k - k); + assert_eq!(-0x1234_5678_9ABC_DEFF_EDCB_A987_5A86_421, k + z); + assert_eq!(-0x1000_0000_0000_0000_0000_0000_0000_000, + k + 0x234_5678_9ABC_DEFF_EDCB_A987_6543_210); + assert_eq!(-0x6EF5_DE4C_D3BC_2AAA_3BB4_CC5D_D6EE_8, k / 42); + assert_eq!(-k, k / -1); + assert_eq!(-0x91A2_B3C4_D5E6_F8, k >> 65); + assert_eq!(-0xFDB9_7530_ECA8_6420_0000_0000_0000_0000, k << 65); + assert!(k < z); + assert!(y > k); + assert!(y < x); + assert_eq!(x as i64, -1); + assert_eq!(z as i64, 0xABCD_EF); + assert_eq!(k as i64, -0xFEDC_BA98_7654_3210); + assert_eq!(k as u128, 0xFEDC_BA98_7654_3210_0123_4567_89AB_CDF0); + assert_eq!(-k as u128, 0x1234_5678_9ABC_DEFF_EDCB_A987_6543_210); + assert_eq!((-z as f64) as i128, -z); + assert_eq!((-z as f32) as i128, -z); + assert_eq!((-z as f64 * 16.0) as i128, -z * 16); + assert_eq!((-z as f32 * 16.0) as i128, -z * 16); + // Same stuff as above, but blackboxed, to force use of intrinsics + let x: i128 = b(-1); + assert_eq!(0, !x); + let y: i128 = b(-2); + assert_eq!(!1, y); + let z: i128 = b(0xABCD_EF); + assert_eq!(z * z, 0x734C_C2F2_A521); + assert_eq!(z * z * z * z, 0x33EE_0E2A_54E2_59DA_A0E7_8E41); + assert_eq!(-z * -z, 0x734C_C2F2_A521); + assert_eq!(-z * -z * -z * -z, 0x33EE_0E2A_54E2_59DA_A0E7_8E41); + assert_eq!(-z + -z + -z + -z, -0x2AF3_7BC); + let k: i128 = b(-0x1234_5678_9ABC_DEFF_EDCB_A987_6543_210); + assert_eq!(k + k, -0x2468_ACF1_3579_BDFF_DB97_530E_CA86_420); + assert_eq!(0, k - k); + assert_eq!(-0x1234_5678_9ABC_DEFF_EDCB_A987_5A86_421, k + z); + assert_eq!(-0x1000_0000_0000_0000_0000_0000_0000_000, + k + 0x234_5678_9ABC_DEFF_EDCB_A987_6543_210); + assert_eq!(-0x6EF5_DE4C_D3BC_2AAA_3BB4_CC5D_D6EE_8, k / 42); + assert_eq!(-k, k / -1); + assert_eq!(-0x91A2_B3C4_D5E6_F8, k >> 65); + assert_eq!(-0xFDB9_7530_ECA8_6420_0000_0000_0000_0000, k << 65); + assert!(k < z); + assert!(y > k); + assert!(y < x); + assert_eq!(x as i64, -1); + assert_eq!(z as i64, 0xABCD_EF); + assert_eq!(k as i64, -0xFEDC_BA98_7654_3210); + assert_eq!(k as u128, 0xFEDC_BA98_7654_3210_0123_4567_89AB_CDF0); + assert_eq!(-k as u128, 0x1234_5678_9ABC_DEFF_EDCB_A987_6543_210); + assert_eq!((-z as f64) as i128, -z); + assert_eq!((-z as f32) as i128, -z); + assert_eq!((-z as f64 * 16.0) as i128, -z * 16); + assert_eq!((-z as f32 * 16.0) as i128, -z * 16); + // formatting + let j: i128 = -(1 << 67); + assert_eq!("-147573952589676412928", format!("{}", j)); + assert_eq!("fffffffffffffff80000000000000000", format!("{:x}", j)); + assert_eq!("3777777777777777777760000000000000000000000", format!("{:o}", j)); + assert_eq!("1111111111111111111111111111111111111111111111111111111111111\ + 0000000000000000000000000000000000000000000000000000000000000000000", + format!("{:b}", j)); + assert_eq!("-147573952589676412928", format!("{:?}", j)); + // common traits + assert_eq!(x, b(x.clone())); + // overflow checks + assert_eq!((-z).checked_mul(-z), Some(0x734C_C2F2_A521)); + assert_eq!((z).checked_mul(z), Some(0x734C_C2F2_A521)); + assert_eq!((k).checked_mul(k), None); + let l: i128 = b(i128::min_value()); + let o: i128 = b(17); + assert_eq!(l.checked_sub(b(2)), None); + assert_eq!(l.checked_add(l), None); + assert_eq!((-(l + 1)).checked_add(2), None); + assert_eq!(l.checked_sub(l), Some(0)); + assert_eq!(b(1u128).checked_shl(b(127)), Some(1 << 127)); + assert_eq!(o.checked_shl(b(128)), None); + + // https://github.com/rust-lang/rust/issues/41228 + assert_eq!(b(-87559967289969187895646876466835277875_i128) / + b(84285771033834995895337664386045050880_i128), + -1i128); + + // iter-arithmetic traits + assert_eq!(10i128, [1i128, 2, 3, 4].iter().sum()); + assert_eq!(24i128, [1i128, 2, 3, 4].iter().product()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/i32-sub.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/i32-sub.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/i32-sub.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/i32-sub.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + + +pub fn main() { let mut x: i32 = -400; x = 0 - x; assert_eq!(x, 400); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/i8-incr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/i8-incr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/i8-incr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/i8-incr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + + +pub fn main() { + let mut x: i8 = -12; + let y: i8 = -12; + x = x + 1; + x = x - 1; + assert_eq!(x, y); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/int-abs-overflow.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/int-abs-overflow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/int-abs-overflow.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/int-abs-overflow.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags: -Z force-overflow-checks=on +// ignore-emscripten no threads support + +use std::thread; + +fn main() { + assert!(thread::spawn(|| i8::min_value().abs()).join().is_err()); + assert!(thread::spawn(|| i16::min_value().abs()).join().is_err()); + assert!(thread::spawn(|| i32::min_value().abs()).join().is_err()); + assert!(thread::spawn(|| i64::min_value().abs()).join().is_err()); + assert!(thread::spawn(|| isize::min_value().abs()).join().is_err()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/integer-literal-radix.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/integer-literal-radix.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/integer-literal-radix.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/integer-literal-radix.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub fn main() { + let a = 0xBEEF_isize; + let b = 0o755_isize; + let c = 0b10101_isize; + let d = -0xBEEF_isize; + let e = -0o755_isize; + let f = -0b10101_isize; + + assert_eq!(a, 48879); + assert_eq!(b, 493); + assert_eq!(c, 21); + assert_eq!(d, -48879); + assert_eq!(e, -493); + assert_eq!(f, -21); + + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/integer-literal-suffix-inference-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/integer-literal-suffix-inference-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/integer-literal-suffix-inference-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/integer-literal-suffix-inference-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +fn foo(_: *const ()) {} + +fn main() { + let a = 3; + foo(&a as *const _ as *const ()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/integer-literal-suffix-inference-3.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/integer-literal-suffix-inference-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/integer-literal-suffix-inference-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/integer-literal-suffix-inference-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() { + println!("{}", std::mem::size_of_val(&1)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/integer-literal-suffix-inference.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/integer-literal-suffix-inference.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/integer-literal-suffix-inference.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/integer-literal-suffix-inference.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,70 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +pub fn main() { + fn id_i8(n: i8) -> i8 { n } + fn id_i16(n: i16) -> i16 { n } + fn id_i32(n: i32) -> i32 { n } + fn id_i64(n: i64) -> i64 { n } + + fn id_uint(n: usize) -> usize { n } + fn id_u8(n: u8) -> u8 { n } + fn id_u16(n: u16) -> u16 { n } + fn id_u32(n: u32) -> u32 { n } + fn id_u64(n: u64) -> u64 { n } + + let _i: i8 = -128; + let j = -128; + id_i8(j); + id_i8(-128); + + let _i: i16 = -32_768; + let j = -32_768; + id_i16(j); + id_i16(-32_768); + + let _i: i32 = -2_147_483_648; + let j = -2_147_483_648; + id_i32(j); + id_i32(-2_147_483_648); + + let _i: i64 = -9_223_372_036_854_775_808; + let j = -9_223_372_036_854_775_808; + id_i64(j); + id_i64(-9_223_372_036_854_775_808); + + let _i: usize = 1; + let j = 1; + id_uint(j); + id_uint(1); + + let _i: u8 = 255; + let j = 255; + id_u8(j); + id_u8(255); + + let _i: u16 = 65_535; + let j = 65_535; + id_u16(j); + id_u16(65_535); + + let _i: u32 = 4_294_967_295; + let j = 4_294_967_295; + id_u32(j); + id_u32(4_294_967_295); + + let _i: u64 = 18_446_744_073_709_551_615; + let j = 18_446_744_073_709_551_615; + id_u64(j); + id_u64(18_446_744_073_709_551_615); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/int.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/int.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/int.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/int.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + +// pretty-expanded FIXME #23616 + +pub fn main() { let _x: isize = 10; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/next-power-of-two-overflow-debug.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/next-power-of-two-overflow-debug.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/next-power-of-two-overflow-debug.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/next-power-of-two-overflow-debug.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags: -C debug_assertions=yes +// ignore-wasm32-bare compiled with panic=abort by default +// ignore-emscripten dies with an LLVM error + +use std::panic; + +fn main() { + macro_rules! overflow_test { + ($t:ident) => ( + let r = panic::catch_unwind(|| { + ($t::max_value()).next_power_of_two() + }); + assert!(r.is_err()); + + let r = panic::catch_unwind(|| { + (($t::max_value() >> 1) + 2).next_power_of_two() + }); + assert!(r.is_err()); + ) + } + overflow_test!(u8); + overflow_test!(u16); + overflow_test!(u32); + overflow_test!(u64); + overflow_test!(u128); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/next-power-of-two-overflow-ndebug.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/next-power-of-two-overflow-ndebug.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/next-power-of-two-overflow-ndebug.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/next-power-of-two-overflow-ndebug.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags: -C debug_assertions=no +// ignore-emscripten dies with an LLVM error + +fn main() { + for i in 129..256 { + assert_eq!((i as u8).next_power_of_two(), 0); + } + + assert_eq!(((1u16 << 15) + 1).next_power_of_two(), 0); + assert_eq!(((1u32 << 31) + 1).next_power_of_two(), 0); + assert_eq!(((1u64 << 63) + 1).next_power_of_two(), 0); + assert_eq!(((1u128 << 127) + 1).next_power_of_two(), 0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/numeric-method-autoexport.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/numeric-method-autoexport.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/numeric-method-autoexport.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/numeric-method-autoexport.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// This file is intended to test only that methods are automatically +// reachable for each numeric type, for each exported impl, with no imports +// necessary. Testing the methods of the impls is done within the source +// file for each numeric type. + +use std::ops::Add; + +pub fn main() { +// ints + // num + assert_eq!(15_isize.add(6_isize), 21_isize); + assert_eq!(15_i8.add(6i8), 21_i8); + assert_eq!(15_i16.add(6i16), 21_i16); + assert_eq!(15_i32.add(6i32), 21_i32); + assert_eq!(15_i64.add(6i64), 21_i64); + +// uints + // num + assert_eq!(15_usize.add(6_usize), 21_usize); + assert_eq!(15_u8.add(6u8), 21_u8); + assert_eq!(15_u16.add(6u16), 21_u16); + assert_eq!(15_u32.add(6u32), 21_u32); + assert_eq!(15_u64.add(6u64), 21_u64); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/num-wrapping.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/num-wrapping.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/num-wrapping.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/num-wrapping.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,457 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_macros)] + +// compile-flags: -C debug-assertions +// +// Test std::num::Wrapping for {uN, iN, usize, isize} + +#![feature(test)] + +extern crate test; + +use std::num::Wrapping; +use std::ops::{ + Add, Sub, Mul, Div, Rem, BitXor, BitOr, BitAnd, + AddAssign, SubAssign, MulAssign, DivAssign, RemAssign, BitXorAssign, BitOrAssign, BitAndAssign, + Shl, Shr, ShlAssign, ShrAssign +}; +use test::black_box; + +macro_rules! int_modules { + ($(($name:ident, $size:expr),)*) => ($( + mod $name { + pub const BITS: usize = $size; + pub use std::$name::*; + } + )*) +} + +int_modules! { + (i8, 8), + (i16, 16), + (i32, 32), + (i64, 64), + (u8, 8), + (u16, 16), + (u32, 32), + (u64, 64), +} + +#[cfg(target_pointer_width = "32")] +int_modules! { + (isize, 32), + (usize, 32), +} + +#[cfg(target_pointer_width = "64")] +int_modules! { + (isize, 64), + (usize, 64), +} + +fn main() { + test_ops(); + test_op_assigns(); + test_sh_ops(); + test_sh_op_assigns(); +} + +fn test_ops() { + macro_rules! op_test { + ($op:ident ($lhs:expr, $rhs:expr) == $ans:expr) => { + assert_eq!(black_box(Wrapping($lhs).$op(Wrapping($rhs))), Wrapping($ans)); + // FIXME(30524): uncomment this test when it's implemented + // assert_eq!(black_box(Wrapping($lhs).$op($rhs)), Wrapping($ans)); + } + } + + op_test!(add(i8::MAX, 1) == i8::MIN); + op_test!(add(i16::MAX, 1) == i16::MIN); + op_test!(add(i32::MAX, 1) == i32::MIN); + op_test!(add(i64::MAX, 1) == i64::MIN); + op_test!(add(isize::MAX, 1) == isize::MIN); + + op_test!(add(u8::MAX, 1) == 0); + op_test!(add(u16::MAX, 1) == 0); + op_test!(add(u32::MAX, 1) == 0); + op_test!(add(u64::MAX, 1) == 0); + op_test!(add(usize::MAX, 1) == 0); + + + op_test!(sub(i8::MIN, 1) == i8::MAX); + op_test!(sub(i16::MIN, 1) == i16::MAX); + op_test!(sub(i32::MIN, 1) == i32::MAX); + op_test!(sub(i64::MIN, 1) == i64::MAX); + op_test!(sub(isize::MIN, 1) == isize::MAX); + + op_test!(sub(0u8, 1) == u8::MAX); + op_test!(sub(0u16, 1) == u16::MAX); + op_test!(sub(0u32, 1) == u32::MAX); + op_test!(sub(0u64, 1) == u64::MAX); + op_test!(sub(0usize, 1) == usize::MAX); + + + op_test!(mul(i8::MAX, 2) == -2); + op_test!(mul(i16::MAX, 2) == -2); + op_test!(mul(i32::MAX, 2) == -2); + op_test!(mul(i64::MAX, 2) == -2); + op_test!(mul(isize::MAX, 2) == -2); + + op_test!(mul(u8::MAX, 2) == u8::MAX - 1); + op_test!(mul(u16::MAX, 2) == u16::MAX - 1); + op_test!(mul(u32::MAX, 2) == u32::MAX - 1); + op_test!(mul(u64::MAX, 2) == u64::MAX - 1); + op_test!(mul(usize::MAX, 2) == usize::MAX - 1); + + + op_test!(div(i8::MIN, -1) == i8::MIN); + op_test!(div(i16::MIN, -1) == i16::MIN); + op_test!(div(i32::MIN, -1) == i32::MIN); + op_test!(div(i64::MIN, -1) == i64::MIN); + op_test!(div(isize::MIN, -1) == isize::MIN); + + + op_test!(rem(i8::MIN, -1) == 0); + op_test!(rem(i16::MIN, -1) == 0); + op_test!(rem(i32::MIN, -1) == 0); + op_test!(rem(i64::MIN, -1) == 0); + op_test!(rem(isize::MIN, -1) == 0); + + // these are not that interesting, just testing to make sure they are implemented correctly + op_test!(bitxor(0b101010i8, 0b100110) == 0b001100); + op_test!(bitxor(0b101010i16, 0b100110) == 0b001100); + op_test!(bitxor(0b101010i32, 0b100110) == 0b001100); + op_test!(bitxor(0b101010i64, 0b100110) == 0b001100); + op_test!(bitxor(0b101010isize, 0b100110) == 0b001100); + + op_test!(bitxor(0b101010u8, 0b100110) == 0b001100); + op_test!(bitxor(0b101010u16, 0b100110) == 0b001100); + op_test!(bitxor(0b101010u32, 0b100110) == 0b001100); + op_test!(bitxor(0b101010u64, 0b100110) == 0b001100); + op_test!(bitxor(0b101010usize, 0b100110) == 0b001100); + + + op_test!(bitor(0b101010i8, 0b100110) == 0b101110); + op_test!(bitor(0b101010i16, 0b100110) == 0b101110); + op_test!(bitor(0b101010i32, 0b100110) == 0b101110); + op_test!(bitor(0b101010i64, 0b100110) == 0b101110); + op_test!(bitor(0b101010isize, 0b100110) == 0b101110); + + op_test!(bitor(0b101010u8, 0b100110) == 0b101110); + op_test!(bitor(0b101010u16, 0b100110) == 0b101110); + op_test!(bitor(0b101010u32, 0b100110) == 0b101110); + op_test!(bitor(0b101010u64, 0b100110) == 0b101110); + op_test!(bitor(0b101010usize, 0b100110) == 0b101110); + + + op_test!(bitand(0b101010i8, 0b100110) == 0b100010); + op_test!(bitand(0b101010i16, 0b100110) == 0b100010); + op_test!(bitand(0b101010i32, 0b100110) == 0b100010); + op_test!(bitand(0b101010i64, 0b100110) == 0b100010); + op_test!(bitand(0b101010isize, 0b100110) == 0b100010); + + op_test!(bitand(0b101010u8, 0b100110) == 0b100010); + op_test!(bitand(0b101010u16, 0b100110) == 0b100010); + op_test!(bitand(0b101010u32, 0b100110) == 0b100010); + op_test!(bitand(0b101010u64, 0b100110) == 0b100010); + op_test!(bitand(0b101010usize, 0b100110) == 0b100010); +} + +fn test_op_assigns() { + macro_rules! op_assign_test { + ($op:ident ($initial:expr, $rhs:expr) == $ans:expr) => { + { + let mut tmp = Wrapping($initial); + tmp = black_box(tmp); + tmp.$op(Wrapping($rhs)); + assert_eq!(black_box(tmp), Wrapping($ans)); + } + + // also test that a &Wrapping right-hand side is possible + { + let mut tmp = Wrapping($initial); + tmp = black_box(tmp); + tmp.$op(&Wrapping($rhs)); + assert_eq!(black_box(tmp), Wrapping($ans)); + } + + // FIXME(30524): Uncomment this test + /* + { + let mut tmp = Wrapping($initial); + tmp = black_box(tmp); + tmp.$op($rhs); + assert_eq!(black_box(tmp), Wrapping($ans)); + } + */ + } + } + op_assign_test!(add_assign(i8::MAX, 1) == i8::MIN); + op_assign_test!(add_assign(i16::MAX, 1) == i16::MIN); + op_assign_test!(add_assign(i32::MAX, 1) == i32::MIN); + op_assign_test!(add_assign(i64::MAX, 1) == i64::MIN); + op_assign_test!(add_assign(isize::MAX, 1) == isize::MIN); + + op_assign_test!(add_assign(u8::MAX, 1) == u8::MIN); + op_assign_test!(add_assign(u16::MAX, 1) == u16::MIN); + op_assign_test!(add_assign(u32::MAX, 1) == u32::MIN); + op_assign_test!(add_assign(u64::MAX, 1) == u64::MIN); + op_assign_test!(add_assign(usize::MAX, 1) == usize::MIN); + + + op_assign_test!(sub_assign(i8::MIN, 1) == i8::MAX); + op_assign_test!(sub_assign(i16::MIN, 1) == i16::MAX); + op_assign_test!(sub_assign(i32::MIN, 1) == i32::MAX); + op_assign_test!(sub_assign(i64::MIN, 1) == i64::MAX); + op_assign_test!(sub_assign(isize::MIN, 1) == isize::MAX); + + op_assign_test!(sub_assign(u8::MIN, 1) == u8::MAX); + op_assign_test!(sub_assign(u16::MIN, 1) == u16::MAX); + op_assign_test!(sub_assign(u32::MIN, 1) == u32::MAX); + op_assign_test!(sub_assign(u64::MIN, 1) == u64::MAX); + op_assign_test!(sub_assign(usize::MIN, 1) == usize::MAX); + + + op_assign_test!(mul_assign(i8::MAX, 2) == -2); + op_assign_test!(mul_assign(i16::MAX, 2) == -2); + op_assign_test!(mul_assign(i32::MAX, 2) == -2); + op_assign_test!(mul_assign(i64::MAX, 2) == -2); + op_assign_test!(mul_assign(isize::MAX, 2) == -2); + + op_assign_test!(mul_assign(u8::MAX, 2) == u8::MAX - 1); + op_assign_test!(mul_assign(u16::MAX, 2) == u16::MAX - 1); + op_assign_test!(mul_assign(u32::MAX, 2) == u32::MAX - 1); + op_assign_test!(mul_assign(u64::MAX, 2) == u64::MAX - 1); + op_assign_test!(mul_assign(usize::MAX, 2) == usize::MAX - 1); + + + op_assign_test!(div_assign(i8::MIN, -1) == i8::MIN); + op_assign_test!(div_assign(i16::MIN, -1) == i16::MIN); + op_assign_test!(div_assign(i32::MIN, -1) == i32::MIN); + op_assign_test!(div_assign(i64::MIN, -1) == i64::MIN); + op_assign_test!(div_assign(isize::MIN, -1) == isize::MIN); + + + op_assign_test!(rem_assign(i8::MIN, -1) == 0); + op_assign_test!(rem_assign(i16::MIN, -1) == 0); + op_assign_test!(rem_assign(i32::MIN, -1) == 0); + op_assign_test!(rem_assign(i64::MIN, -1) == 0); + op_assign_test!(rem_assign(isize::MIN, -1) == 0); + + + // these are not that interesting, just testing to make sure they are implemented correctly + op_assign_test!(bitxor_assign(0b101010i8, 0b100110) == 0b001100); + op_assign_test!(bitxor_assign(0b101010i16, 0b100110) == 0b001100); + op_assign_test!(bitxor_assign(0b101010i32, 0b100110) == 0b001100); + op_assign_test!(bitxor_assign(0b101010i64, 0b100110) == 0b001100); + op_assign_test!(bitxor_assign(0b101010isize, 0b100110) == 0b001100); + + op_assign_test!(bitxor_assign(0b101010u8, 0b100110) == 0b001100); + op_assign_test!(bitxor_assign(0b101010u16, 0b100110) == 0b001100); + op_assign_test!(bitxor_assign(0b101010u32, 0b100110) == 0b001100); + op_assign_test!(bitxor_assign(0b101010u64, 0b100110) == 0b001100); + op_assign_test!(bitxor_assign(0b101010usize, 0b100110) == 0b001100); + + + op_assign_test!(bitor_assign(0b101010i8, 0b100110) == 0b101110); + op_assign_test!(bitor_assign(0b101010i16, 0b100110) == 0b101110); + op_assign_test!(bitor_assign(0b101010i32, 0b100110) == 0b101110); + op_assign_test!(bitor_assign(0b101010i64, 0b100110) == 0b101110); + op_assign_test!(bitor_assign(0b101010isize, 0b100110) == 0b101110); + + op_assign_test!(bitor_assign(0b101010u8, 0b100110) == 0b101110); + op_assign_test!(bitor_assign(0b101010u16, 0b100110) == 0b101110); + op_assign_test!(bitor_assign(0b101010u32, 0b100110) == 0b101110); + op_assign_test!(bitor_assign(0b101010u64, 0b100110) == 0b101110); + op_assign_test!(bitor_assign(0b101010usize, 0b100110) == 0b101110); + + + op_assign_test!(bitand_assign(0b101010i8, 0b100110) == 0b100010); + op_assign_test!(bitand_assign(0b101010i16, 0b100110) == 0b100010); + op_assign_test!(bitand_assign(0b101010i32, 0b100110) == 0b100010); + op_assign_test!(bitand_assign(0b101010i64, 0b100110) == 0b100010); + op_assign_test!(bitand_assign(0b101010isize, 0b100110) == 0b100010); + + op_assign_test!(bitand_assign(0b101010u8, 0b100110) == 0b100010); + op_assign_test!(bitand_assign(0b101010u16, 0b100110) == 0b100010); + op_assign_test!(bitand_assign(0b101010u32, 0b100110) == 0b100010); + op_assign_test!(bitand_assign(0b101010u64, 0b100110) == 0b100010); + op_assign_test!(bitand_assign(0b101010usize, 0b100110) == 0b100010); +} + +fn test_sh_ops() { + macro_rules! sh_test { + ($op:ident ($lhs:expr, $rhs:expr) == $ans:expr) => { + assert_eq!(black_box(Wrapping($lhs).$op($rhs)), Wrapping($ans)); + } + } + // NOTE: This will break for i8 if we ever get i/u128 + macro_rules! sh_test_all { + ($t:ty) => { + sh_test!(shl(i8::MAX, (i8::BITS + 1) as $t) == -2); + sh_test!(shl(i16::MAX, (i16::BITS + 1) as $t) == -2); + sh_test!(shl(i32::MAX, (i32::BITS + 1) as $t) == -2); + sh_test!(shl(i64::MAX, (i64::BITS + 1) as $t) == -2); + sh_test!(shl(isize::MAX, (isize::BITS + 1) as $t) == -2); + + sh_test!(shl(u8::MAX, (u8::BITS + 1) as $t) == u8::MAX - 1); + sh_test!(shl(u16::MAX, (u16::BITS + 1) as $t) == u16::MAX - 1); + sh_test!(shl(u32::MAX, (u32::BITS + 1) as $t) == u32::MAX - 1); + sh_test!(shl(u64::MAX, (u64::BITS + 1) as $t) == u64::MAX - 1); + sh_test!(shl(usize::MAX, (usize::BITS + 1) as $t) == usize::MAX - 1); + + + sh_test!(shr(i8::MAX, (i8::BITS + 1) as $t) == i8::MAX / 2); + sh_test!(shr(i16::MAX, (i16::BITS + 1) as $t) == i16::MAX / 2); + sh_test!(shr(i32::MAX, (i32::BITS + 1) as $t) == i32::MAX / 2); + sh_test!(shr(i64::MAX, (i64::BITS + 1) as $t) == i64::MAX / 2); + sh_test!(shr(isize::MAX, (isize::BITS + 1) as $t) == isize::MAX / 2); + + sh_test!(shr(u8::MAX, (u8::BITS + 1) as $t) == u8::MAX / 2); + sh_test!(shr(u16::MAX, (u16::BITS + 1) as $t) == u16::MAX / 2); + sh_test!(shr(u32::MAX, (u32::BITS + 1) as $t) == u32::MAX / 2); + sh_test!(shr(u64::MAX, (u64::BITS + 1) as $t) == u64::MAX / 2); + sh_test!(shr(usize::MAX, (usize::BITS + 1) as $t) == usize::MAX / 2); + } + } + macro_rules! sh_test_negative_all { + ($t:ty) => { + sh_test!(shr(i8::MAX, -((i8::BITS + 1) as $t)) == -2); + sh_test!(shr(i16::MAX, -((i16::BITS + 1) as $t)) == -2); + sh_test!(shr(i32::MAX, -((i32::BITS + 1) as $t)) == -2); + sh_test!(shr(i64::MAX, -((i64::BITS + 1) as $t)) == -2); + sh_test!(shr(isize::MAX, -((isize::BITS + 1) as $t)) == -2); + + sh_test!(shr(u8::MAX, -((u8::BITS + 1) as $t)) == u8::MAX - 1); + sh_test!(shr(u16::MAX, -((u16::BITS + 1) as $t)) == u16::MAX - 1); + sh_test!(shr(u32::MAX, -((u32::BITS + 1) as $t)) == u32::MAX - 1); + sh_test!(shr(u64::MAX, -((u64::BITS + 1) as $t)) == u64::MAX - 1); + sh_test!(shr(usize::MAX, -((usize::BITS + 1) as $t)) == usize::MAX - 1); + + + sh_test!(shl(i8::MAX, -((i8::BITS + 1) as $t)) == i8::MAX / 2); + sh_test!(shl(i16::MAX, -((i16::BITS + 1) as $t)) == i16::MAX / 2); + sh_test!(shl(i32::MAX, -((i32::BITS + 1) as $t)) == i32::MAX / 2); + sh_test!(shl(i64::MAX, -((i64::BITS + 1) as $t)) == i64::MAX / 2); + sh_test!(shl(isize::MAX, -((isize::BITS + 1) as $t)) == isize::MAX / 2); + + sh_test!(shl(u8::MAX, -((u8::BITS + 1) as $t)) == u8::MAX / 2); + sh_test!(shl(u16::MAX, -((u16::BITS + 1) as $t)) == u16::MAX / 2); + sh_test!(shl(u32::MAX, -((u32::BITS + 1) as $t)) == u32::MAX / 2); + sh_test!(shl(u64::MAX, -((u64::BITS + 1) as $t)) == u64::MAX / 2); + sh_test!(shl(usize::MAX, -((usize::BITS + 1) as $t)) == usize::MAX / 2); + } + } + // FIXME(#23545): Uncomment the remaining tests + //sh_test_all!(i8); + //sh_test_all!(u8); + //sh_test_all!(i16); + //sh_test_all!(u16); + //sh_test_all!(i32); + //sh_test_all!(u32); + //sh_test_all!(i64); + //sh_test_all!(u64); + //sh_test_all!(isize); + sh_test_all!(usize); + + //sh_test_negative_all!(i8); + //sh_test_negative_all!(i16); + //sh_test_negative_all!(i32); + //sh_test_negative_all!(i64); + //sh_test_negative_all!(isize); +} + +fn test_sh_op_assigns() { + macro_rules! sh_assign_test { + ($op:ident ($initial:expr, $rhs:expr) == $ans:expr) => {{ + let mut tmp = Wrapping($initial); + tmp = black_box(tmp); + tmp.$op($rhs); + assert_eq!(black_box(tmp), Wrapping($ans)); + }} + } + macro_rules! sh_assign_test_all { + ($t:ty) => { + sh_assign_test!(shl_assign(i8::MAX, (i8::BITS + 1) as $t) == -2); + sh_assign_test!(shl_assign(i16::MAX, (i16::BITS + 1) as $t) == -2); + sh_assign_test!(shl_assign(i32::MAX, (i32::BITS + 1) as $t) == -2); + sh_assign_test!(shl_assign(i64::MAX, (i64::BITS + 1) as $t) == -2); + sh_assign_test!(shl_assign(isize::MAX, (isize::BITS + 1) as $t) == -2); + + sh_assign_test!(shl_assign(u8::MAX, (u8::BITS + 1) as $t) == u8::MAX - 1); + sh_assign_test!(shl_assign(u16::MAX, (u16::BITS + 1) as $t) == u16::MAX - 1); + sh_assign_test!(shl_assign(u32::MAX, (u32::BITS + 1) as $t) == u32::MAX - 1); + sh_assign_test!(shl_assign(u64::MAX, (u64::BITS + 1) as $t) == u64::MAX - 1); + sh_assign_test!(shl_assign(usize::MAX, (usize::BITS + 1) as $t) == usize::MAX - 1); + + + sh_assign_test!(shr_assign(i8::MAX, (i8::BITS + 1) as $t) == i8::MAX / 2); + sh_assign_test!(shr_assign(i16::MAX, (i16::BITS + 1) as $t) == i16::MAX / 2); + sh_assign_test!(shr_assign(i32::MAX, (i32::BITS + 1) as $t) == i32::MAX / 2); + sh_assign_test!(shr_assign(i64::MAX, (i64::BITS + 1) as $t) == i64::MAX / 2); + sh_assign_test!(shr_assign(isize::MAX, (isize::BITS + 1) as $t) == isize::MAX / 2); + + sh_assign_test!(shr_assign(u8::MAX, (u8::BITS + 1) as $t) == u8::MAX / 2); + sh_assign_test!(shr_assign(u16::MAX, (u16::BITS + 1) as $t) == u16::MAX / 2); + sh_assign_test!(shr_assign(u32::MAX, (u32::BITS + 1) as $t) == u32::MAX / 2); + sh_assign_test!(shr_assign(u64::MAX, (u64::BITS + 1) as $t) == u64::MAX / 2); + sh_assign_test!(shr_assign(usize::MAX, (usize::BITS + 1) as $t) == usize::MAX / 2); + } + } + macro_rules! sh_assign_test_negative_all { + ($t:ty) => { + sh_assign_test!(shr_assign(i8::MAX, -((i8::BITS + 1) as $t)) == -2); + sh_assign_test!(shr_assign(i16::MAX, -((i16::BITS + 1) as $t)) == -2); + sh_assign_test!(shr_assign(i32::MAX, -((i32::BITS + 1) as $t)) == -2); + sh_assign_test!(shr_assign(i64::MAX, -((i64::BITS + 1) as $t)) == -2); + sh_assign_test!(shr_assign(isize::MAX, -((isize::BITS + 1) as $t)) == -2); + + sh_assign_test!(shr_assign(u8::MAX, -((u8::BITS + 1) as $t)) == u8::MAX - 1); + sh_assign_test!(shr_assign(u16::MAX, -((u16::BITS + 1) as $t)) == u16::MAX - 1); + sh_assign_test!(shr_assign(u32::MAX, -((u32::BITS + 1) as $t)) == u32::MAX - 1); + sh_assign_test!(shr_assign(u64::MAX, -((u64::BITS + 1) as $t)) == u64::MAX - 1); + sh_assign_test!(shr_assign(usize::MAX, -((usize::BITS + 1) as $t)) == usize::MAX - 1); + + + sh_assign_test!(shl_assign(i8::MAX, -((i8::BITS + 1) as $t)) == i8::MAX / 2); + sh_assign_test!(shl_assign(i16::MAX, -((i16::BITS + 1) as $t)) == i16::MAX / 2); + sh_assign_test!(shl_assign(i32::MAX, -((i32::BITS + 1) as $t)) == i32::MAX / 2); + sh_assign_test!(shl_assign(i64::MAX, -((i64::BITS + 1) as $t)) == i64::MAX / 2); + sh_assign_test!(shl_assign(isize::MAX, -((isize::BITS + 1) as $t)) == isize::MAX / 2); + + sh_assign_test!(shl_assign(u8::MAX, -((u8::BITS + 1) as $t)) == u8::MAX / 2); + sh_assign_test!(shl_assign(u16::MAX, -((u16::BITS + 1) as $t)) == u16::MAX / 2); + sh_assign_test!(shl_assign(u32::MAX, -((u32::BITS + 1) as $t)) == u32::MAX / 2); + sh_assign_test!(shl_assign(u64::MAX, -((u64::BITS + 1) as $t)) == u64::MAX / 2); + sh_assign_test!(shl_assign(usize::MAX, -((usize::BITS + 1) as $t)) == usize::MAX / 2); + } + } + + // FIXME(#23545): Uncomment the remaining tests + //sh_assign_test_all!(i8); + //sh_assign_test_all!(u8); + //sh_assign_test_all!(i16); + //sh_assign_test_all!(u16); + //sh_assign_test_all!(i32); + //sh_assign_test_all!(u32); + //sh_assign_test_all!(i64); + //sh_assign_test_all!(u64); + //sh_assign_test_all!(isize); + sh_assign_test_all!(usize); + + //sh_assign_test_negative_all!(i8); + //sh_assign_test_negative_all!(i16); + //sh_assign_test_negative_all!(i32); + //sh_assign_test_negative_all!(i64); + //sh_assign_test_negative_all!(isize); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/promoted_overflow_opt.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/promoted_overflow_opt.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/promoted_overflow_opt.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/promoted_overflow_opt.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(const_err)] + +// compile-flags: -O + +fn main() { + let x = &(0u32 - 1); + assert_eq!(*x, u32::max_value()) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/saturating-float-casts.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/saturating-float-casts.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/saturating-float-casts.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/saturating-float-casts.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,145 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests saturating float->int casts. See u128-as-f32.rs for the opposite direction. +// compile-flags: -Z saturating-float-casts + +#![feature(test, stmt_expr_attributes)] +#![deny(overflowing_literals)] +extern crate test; + +use std::{f32, f64}; +use std::{u8, i8, u16, i16, u32, i32, u64, i64}; +#[cfg(not(target_os="emscripten"))] +use std::{u128, i128}; +use test::black_box; + +macro_rules! test { + ($val:expr, $src_ty:ident -> $dest_ty:ident, $expected:expr) => ( + // black_box disables constant evaluation to test run-time conversions: + assert_eq!(black_box::<$src_ty>($val) as $dest_ty, $expected, + "run-time {} -> {}", stringify!($src_ty), stringify!($dest_ty)); + ); + + ($fval:expr, f* -> $ity:ident, $ival:expr) => ( + test!($fval, f32 -> $ity, $ival); + test!($fval, f64 -> $ity, $ival); + ) +} + +// This macro tests const eval in addition to run-time evaluation. +// If and when saturating casts are adopted, this macro should be merged with test!() to ensure +// that run-time and const eval agree on inputs that currently trigger a const eval error. +macro_rules! test_c { + ($val:expr, $src_ty:ident -> $dest_ty:ident, $expected:expr) => ({ + test!($val, $src_ty -> $dest_ty, $expected); + { + const X: $src_ty = $val; + const Y: $dest_ty = X as $dest_ty; + assert_eq!(Y, $expected, + "const eval {} -> {}", stringify!($src_ty), stringify!($dest_ty)); + } + }); + + ($fval:expr, f* -> $ity:ident, $ival:expr) => ( + test_c!($fval, f32 -> $ity, $ival); + test_c!($fval, f64 -> $ity, $ival); + ) +} + +macro_rules! common_fptoi_tests { + ($fty:ident -> $($ity:ident)+) => ({ $( + test!($fty::NAN, $fty -> $ity, 0); + test!($fty::INFINITY, $fty -> $ity, $ity::MAX); + test!($fty::NEG_INFINITY, $fty -> $ity, $ity::MIN); + // These two tests are not solely float->int tests, in particular the latter relies on + // `u128::MAX as f32` not being UB. But that's okay, since this file tests int->float + // as well, the test is just slightly misplaced. + test!($ity::MIN as $fty, $fty -> $ity, $ity::MIN); + test!($ity::MAX as $fty, $fty -> $ity, $ity::MAX); + test_c!(0., $fty -> $ity, 0); + test_c!($fty::MIN_POSITIVE, $fty -> $ity, 0); + test!(-0.9, $fty -> $ity, 0); + test_c!(1., $fty -> $ity, 1); + test_c!(42., $fty -> $ity, 42); + )+ }); + + (f* -> $($ity:ident)+) => ({ + common_fptoi_tests!(f32 -> $($ity)+); + common_fptoi_tests!(f64 -> $($ity)+); + }) +} + +macro_rules! fptoui_tests { + ($fty: ident -> $($ity: ident)+) => ({ $( + test!(-0., $fty -> $ity, 0); + test!(-$fty::MIN_POSITIVE, $fty -> $ity, 0); + test!(-0.99999994, $fty -> $ity, 0); + test!(-1., $fty -> $ity, 0); + test!(-100., $fty -> $ity, 0); + test!(#[allow(overflowing_literals)] -1e50, $fty -> $ity, 0); + test!(#[allow(overflowing_literals)] -1e130, $fty -> $ity, 0); + )+ }); + + (f* -> $($ity:ident)+) => ({ + fptoui_tests!(f32 -> $($ity)+); + fptoui_tests!(f64 -> $($ity)+); + }) +} + +pub fn main() { + common_fptoi_tests!(f* -> i8 i16 i32 i64 u8 u16 u32 u64); + fptoui_tests!(f* -> u8 u16 u32 u64); + // FIXME emscripten does not support i128 + #[cfg(not(target_os="emscripten"))] { + common_fptoi_tests!(f* -> i128 u128); + fptoui_tests!(f* -> u128); + } + + // The following tests cover edge cases for some integer types. + + // # u8 + test_c!(254., f* -> u8, 254); + test!(256., f* -> u8, 255); + + // # i8 + test_c!(-127., f* -> i8, -127); + test!(-129., f* -> i8, -128); + test_c!(126., f* -> i8, 126); + test!(128., f* -> i8, 127); + + // # i32 + // -2147483648. is i32::MIN (exactly) + test_c!(-2147483648., f* -> i32, i32::MIN); + // 2147483648. is i32::MAX rounded up + test!(2147483648., f32 -> i32, 2147483647); + // With 24 significand bits, floats with magnitude in [2^30 + 1, 2^31] are rounded to + // multiples of 2^7. Therefore, nextDown(round(i32::MAX)) is 2^31 - 128: + test_c!(2147483520., f32 -> i32, 2147483520); + // Similarly, nextUp(i32::MIN) is i32::MIN + 2^8 and nextDown(i32::MIN) is i32::MIN - 2^7 + test!(-2147483904., f* -> i32, i32::MIN); + test_c!(-2147483520., f* -> i32, -2147483520); + + // # u32 + // round(MAX) and nextUp(round(MAX)) + test_c!(4294967040., f* -> u32, 4294967040); + test!(4294967296., f* -> u32, 4294967295); + + // # u128 + #[cfg(not(target_os="emscripten"))] + { + // float->int: + test_c!(f32::MAX, f32 -> u128, 0xffffff00000000000000000000000000); + // nextDown(f32::MAX) = 2^128 - 2 * 2^104 + const SECOND_LARGEST_F32: f32 = 340282326356119256160033759537265639424.; + test_c!(SECOND_LARGEST_F32, f32 -> u128, 0xfffffe00000000000000000000000000); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/shift-near-oflo.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/shift-near-oflo.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/shift-near-oflo.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/shift-near-oflo.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,110 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// compile-flags: -C debug-assertions + +// Check that we do *not* overflow on a number of edge cases. +// (compare with test/run-fail/overflowing-{lsh,rsh}*.rs) + +fn main() { + test_left_shift(); + test_right_shift(); +} + +pub static mut HACK: i32 = 0; + +// Work around constant-evaluation +// The point of this test is to exercise the code generated for execution at runtime, +// `id` can never be flagged as a const fn by future aggressive analyses... +// due to the modification of the static +#[inline(never)] +fn id(x: T) -> T { + unsafe { HACK += 1; } + x +} + +fn test_left_shift() { + // negative rhs can panic, but values in [0,N-1] are okay for iN + + macro_rules! tests { + ($iN:ty, $uN:ty, $max_rhs:expr, $expect_i:expr, $expect_u:expr) => { { + let x = (1 as $iN) << id(0); + assert_eq!(x, 1); + let x = (1 as $uN) << id(0); + assert_eq!(x, 1); + let x = (1 as $iN) << id($max_rhs); + assert_eq!(x, $expect_i); + let x = (1 as $uN) << id($max_rhs); + assert_eq!(x, $expect_u); + // high-order bits on LHS are silently discarded without panic. + let x = (3 as $iN) << id($max_rhs); + assert_eq!(x, $expect_i); + let x = (3 as $uN) << id($max_rhs); + assert_eq!(x, $expect_u); + } } + } + + let x = 1_i8 << id(0); + assert_eq!(x, 1); + let x = 1_u8 << id(0); + assert_eq!(x, 1); + let x = 1_i8 << id(7); + assert_eq!(x, std::i8::MIN); + let x = 1_u8 << id(7); + assert_eq!(x, 0x80); + // high-order bits on LHS are silently discarded without panic. + let x = 3_i8 << id(7); + assert_eq!(x, std::i8::MIN); + let x = 3_u8 << id(7); + assert_eq!(x, 0x80); + + // above is (approximately) expanded from: + tests!(i8, u8, 7, std::i8::MIN, 0x80_u8); + + tests!(i16, u16, 15, std::i16::MIN, 0x8000_u16); + tests!(i32, u32, 31, std::i32::MIN, 0x8000_0000_u32); + tests!(i64, u64, 63, std::i64::MIN, 0x8000_0000_0000_0000_u64); +} + +fn test_right_shift() { + // negative rhs can panic, but values in [0,N-1] are okay for iN + + macro_rules! tests { + ($iN:ty, $uN:ty, $max_rhs:expr, + $signbit_i:expr, $highbit_i:expr, $highbit_u:expr) => + { { + let x = (1 as $iN) >> id(0); + assert_eq!(x, 1); + let x = (1 as $uN) >> id(0); + assert_eq!(x, 1); + let x = ($highbit_i) >> id($max_rhs-1); + assert_eq!(x, 1); + let x = ($highbit_u) >> id($max_rhs); + assert_eq!(x, 1); + // sign-bit is carried by arithmetic right shift + let x = ($signbit_i) >> id($max_rhs); + assert_eq!(x, -1); + // low-order bits on LHS are silently discarded without panic. + let x = ($highbit_i + 1) >> id($max_rhs-1); + assert_eq!(x, 1); + let x = ($highbit_u + 1) >> id($max_rhs); + assert_eq!(x, 1); + let x = ($signbit_i + 1) >> id($max_rhs); + assert_eq!(x, -1); + } } + } + + tests!(i8, u8, 7, std::i8::MIN, 0x40_i8, 0x80_u8); + tests!(i16, u16, 15, std::i16::MIN, 0x4000_u16, 0x8000_u16); + tests!(i32, u32, 31, std::i32::MIN, 0x4000_0000_u32, 0x8000_0000_u32); + tests!(i64, u64, 63, std::i64::MIN, + 0x4000_0000_0000_0000_u64, 0x8000_0000_0000_0000_u64); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/shift.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/shift.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/shift.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/shift.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,86 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_upper_case_globals)] +#![allow(overflowing_literals)] + +// Testing shifts for various combinations of integers +// Issue #1570 + + +pub fn main() { + test_misc(); + test_expr(); + test_const(); +} + +fn test_misc() { + assert_eq!(1 << 1 << 1 << 1 << 1 << 1, 32); +} + +fn test_expr() { + let v10 = 10 as usize; + let v4 = 4 as u8; + let v2 = 2 as u8; + assert_eq!(v10 >> v2 as usize, v2 as usize); + assert_eq!(v10 << v4 as usize, 160 as usize); + + let v10 = 10 as u8; + let v4 = 4 as usize; + let v2 = 2 as usize; + assert_eq!(v10 >> v2 as usize, v2 as u8); + assert_eq!(v10 << v4 as usize, 160 as u8); + + let v10 = 10 as isize; + let v4 = 4 as i8; + let v2 = 2 as i8; + assert_eq!(v10 >> v2 as usize, v2 as isize); + assert_eq!(v10 << v4 as usize, 160 as isize); + + let v10 = 10 as i8; + let v4 = 4 as isize; + let v2 = 2 as isize; + assert_eq!(v10 >> v2 as usize, v2 as i8); + assert_eq!(v10 << v4 as usize, 160 as i8); + + let v10 = 10 as usize; + let v4 = 4 as isize; + let v2 = 2 as isize; + assert_eq!(v10 >> v2 as usize, v2 as usize); + assert_eq!(v10 << v4 as usize, 160 as usize); +} + +fn test_const() { + static r1_1: usize = 10_usize >> 2_usize; + static r2_1: usize = 10_usize << 4_usize; + assert_eq!(r1_1, 2 as usize); + assert_eq!(r2_1, 160 as usize); + + static r1_2: u8 = 10u8 >> 2_usize; + static r2_2: u8 = 10u8 << 4_usize; + assert_eq!(r1_2, 2 as u8); + assert_eq!(r2_2, 160 as u8); + + static r1_3: isize = 10 >> 2_usize; + static r2_3: isize = 10 << 4_usize; + assert_eq!(r1_3, 2 as isize); + assert_eq!(r2_3, 160 as isize); + + static r1_4: i8 = 10i8 >> 2_usize; + static r2_4: i8 = 10i8 << 4_usize; + assert_eq!(r1_4, 2 as i8); + assert_eq!(r2_4, 160 as i8); + + static r1_5: usize = 10_usize >> 2_usize; + static r2_5: usize = 10_usize << 4_usize; + assert_eq!(r1_5, 2 as usize); + assert_eq!(r2_5, 160 as usize); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/shift-various-types.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/shift-various-types.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/shift-various-types.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/shift-various-types.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,58 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we can do shifts by any integral type. + + +struct Panolpy { + i8: i8, + i16: i16, + i32: i32, + i64: i64, + isize: isize, + + u8: u8, + u16: u16, + u32: u32, + u64: u64, + usize: usize, +} + +fn foo(p: &Panolpy) { + assert_eq!(22 >> p.i8, 11); + assert_eq!(22 >> p.i16, 11); + assert_eq!(22 >> p.i32, 11); + assert_eq!(22 >> p.i64, 11); + assert_eq!(22 >> p.isize, 11); + + assert_eq!(22 >> p.u8, 11); + assert_eq!(22 >> p.u16, 11); + assert_eq!(22 >> p.u32, 11); + assert_eq!(22 >> p.u64, 11); + assert_eq!(22 >> p.usize, 11); +} + +fn main() { + let p = Panolpy { + i8: 1, + i16: 1, + i32: 1, + i64: 1, + isize: 1, + + u8: 1, + u16: 1, + u32: 1, + u64: 1, + usize: 1, + }; + foo(&p) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/signed-shift-const-eval.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/signed-shift-const-eval.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/signed-shift-const-eval.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/signed-shift-const-eval.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + + +enum test { thing = -5 >> 1_usize } +pub fn main() { + assert_eq!(test::thing as isize, -3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/u128-as-f32.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/u128-as-f32.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/u128-as-f32.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/u128-as-f32.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,59 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten u128 not supported + +#![feature(test)] +#![deny(overflowing_literals)] +extern crate test; + +use std::f32; +use std::u128; +use test::black_box; + +macro_rules! test { + ($val:expr, $src_ty:ident -> $dest_ty:ident, $expected:expr) => ({ + { + const X: $src_ty = $val; + const Y: $dest_ty = X as $dest_ty; + assert_eq!(Y, $expected, + "const eval {} -> {}", stringify!($src_ty), stringify!($dest_ty)); + } + // black_box disables constant evaluation to test run-time conversions: + assert_eq!(black_box::<$src_ty>($val) as $dest_ty, $expected, + "run-time {} -> {}", stringify!($src_ty), stringify!($dest_ty)); + }); +} + +pub fn main() { + // nextDown(f32::MAX) = 2^128 - 2 * 2^104 + const SECOND_LARGEST_F32: f32 = 340282326356119256160033759537265639424.; + + // f32::MAX - 0.5 ULP and smaller should be rounded down + test!(0xfffffe00000000000000000000000000, u128 -> f32, SECOND_LARGEST_F32); + test!(0xfffffe7fffffffffffffffffffffffff, u128 -> f32, SECOND_LARGEST_F32); + test!(0xfffffe80000000000000000000000000, u128 -> f32, SECOND_LARGEST_F32); + // numbers within < 0.5 ULP of f32::MAX it should be rounded to f32::MAX + test!(0xfffffe80000000000000000000000001, u128 -> f32, f32::MAX); + test!(0xfffffeffffffffffffffffffffffffff, u128 -> f32, f32::MAX); + test!(0xffffff00000000000000000000000000, u128 -> f32, f32::MAX); + test!(0xffffff00000000000000000000000001, u128 -> f32, f32::MAX); + test!(0xffffff7fffffffffffffffffffffffff, u128 -> f32, f32::MAX); + // f32::MAX + 0.5 ULP and greater should be rounded to infinity + test!(0xffffff80000000000000000000000000, u128 -> f32, f32::INFINITY); + test!(0xffffff80000000f00000000000000000, u128 -> f32, f32::INFINITY); + test!(0xffffff87ffffffffffffffff00000001, u128 -> f32, f32::INFINITY); + + // u128->f64 should not be affected by the u128->f32 checks + test!(0xffffff80000000000000000000000000, u128 -> f64, + 340282356779733661637539395458142568448.0); + test!(u128::MAX, u128 -> f64, 340282366920938463463374607431768211455.0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/u128.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/u128.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/u128.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/u128.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,132 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten u128 not supported + +// compile-flags: -Z borrowck=compare + +#![feature(test)] + +extern crate test; +use test::black_box as b; + +fn main() { + let x: u128 = 0xFFFF_FFFF_FFFF_FFFF__FFFF_FFFF_FFFF_FFFF; + assert_eq!(0, !x); + assert_eq!(0, !x); + let y: u128 = 0xFFFF_FFFF_FFFF_FFFF__FFFF_FFFF_FFFF_FFFE; + assert_eq!(!1, y); + assert_eq!(x, y | 1); + assert_eq!(0xFAFF_0000_FF8F_0000__FFFF_0000_FFFF_FFFE, + y & + 0xFAFF_0000_FF8F_0000__FFFF_0000_FFFF_FFFF); + let z: u128 = 0xABCD_EF; + assert_eq!(z * z, 0x734C_C2F2_A521); + assert_eq!(z * z * z * z, 0x33EE_0E2A_54E2_59DA_A0E7_8E41); + assert_eq!(z + z + z + z, 0x2AF3_7BC); + let k: u128 = 0x1234_5678_9ABC_DEFF_EDCB_A987_6543_210; + assert_eq!(k + k, 0x2468_ACF1_3579_BDFF_DB97_530E_CA86_420); + assert_eq!(0, k - k); + assert_eq!(0x1234_5678_9ABC_DEFF_EDCB_A987_5A86_421, k - z); + assert_eq!(0x1000_0000_0000_0000_0000_0000_0000_000, + k - 0x234_5678_9ABC_DEFF_EDCB_A987_6543_210); + assert_eq!(0x6EF5_DE4C_D3BC_2AAA_3BB4_CC5D_D6EE_8, k / 42); + assert_eq!(0, k % 42); + assert_eq!(15, z % 42); + assert_eq!(0x169D_A8020_CEC18, k % 0x3ACB_FE49_FF24_AC); + assert_eq!(0x91A2_B3C4_D5E6_F7, k >> 65); + assert_eq!(0xFDB9_7530_ECA8_6420_0000_0000_0000_0000, k << 65); + assert!(k > z); + assert!(y > k); + assert!(y < x); + assert_eq!(x as u64, !0); + assert_eq!(z as u64, 0xABCD_EF); + assert_eq!(k as u64, 0xFEDC_BA98_7654_3210); + assert_eq!(k as i128, 0x1234_5678_9ABC_DEFF_EDCB_A987_6543_210); + assert_eq!((z as f64) as u128, z); + assert_eq!((z as f32) as u128, z); + assert_eq!((z as f64 * 16.0) as u128, z * 16); + assert_eq!((z as f32 * 16.0) as u128, z * 16); + let l :u128 = 432 << 100; + assert_eq!((l as f32) as u128, l); + assert_eq!((l as f64) as u128, l); + // formatting + let j: u128 = 1 << 67; + assert_eq!("147573952589676412928", format!("{}", j)); + assert_eq!("80000000000000000", format!("{:x}", j)); + assert_eq!("20000000000000000000000", format!("{:o}", j)); + assert_eq!("10000000000000000000000000000000000000000000000000000000000000000000", + format!("{:b}", j)); + assert_eq!("340282366920938463463374607431768211455", + format!("{}", u128::max_value())); + assert_eq!("147573952589676412928", format!("{:?}", j)); + // common traits + assert_eq!(x, b(x.clone())); + // overflow checks + assert_eq!((z).checked_mul(z), Some(0x734C_C2F2_A521)); + assert_eq!((k).checked_mul(k), None); + let l: u128 = b(u128::max_value() - 10); + let o: u128 = b(17); + assert_eq!(l.checked_add(b(11)), None); + assert_eq!(l.checked_sub(l), Some(0)); + assert_eq!(o.checked_sub(b(18)), None); + assert_eq!(b(1u128).checked_shl(b(127)), Some(1 << 127)); + assert_eq!(o.checked_shl(b(128)), None); + + // Test cases for all udivmodti4 branches. + // case "0X/0X" + assert_eq!(b(0x69545bd57727c050_u128) / + b(0x3283527a3350d88c_u128), + 2u128); + // case "0X/KX" + assert_eq!(b(0x0_8003c9c50b473ae6_u128) / + b(0x1_283e8838c30fa8f4_u128), + 0u128); + // case "K0/K0" + assert_eq!(b(0xc43f42a207978720_u128 << 64) / + b(0x098e62b74c23cf1a_u128 << 64), + 20u128); + // case "KK/K0" for power-of-two D. + assert_eq!(b(0xa9008fb6c9d81e42_0e25730562a601c8_u128) / + b(1u128 << 120), + 169u128); + // case "KK/K0" with N >= D (https://github.com/rust-lang/rust/issues/41228). + assert_eq!(b(0xe4d26e59f0640328_06da5b06efe83a41_u128) / + b(0x330fcb030ea4447c_u128 << 64), + 4u128); + assert_eq!(b(3u128 << 64 | 1) / + b(3u128 << 64), + 1u128); + // case "KK/K0" with N < D. + assert_eq!(b(0x6655c9fb66ca2884_e2d1dfd470158c62_u128) / + b(0xb35b667cab7e355b_u128 << 64), + 0u128); + // case "KX/0K" for power-of-two D. + assert_eq!(b(0x3e49dd84feb2df59_7b2f97d93a253969_u128) / + b(1u128 << 4), + 0x03e49dd84feb2df5_97b2f97d93a25396_u128); + // case "KX/0K" in general. + assert_eq!(b(0x299692b3a1dae5bd_6162e6f489d2620e_u128) / + b(0x900b6f027571d6f7_u128), + 0x49e95f54b0442578_u128); + // case "KX/KK" with N >= D. + assert_eq!(b(0xc7b889180b67b07d_bc1a3c88783d35b5_u128) / + b(0x1d7e69f53160b9e2_60074771e852f244_u128), + 6u128); + // case "KX/KK" with N < D. + assert_eq!(b(0x679289ac23bb334f_36144401cf882172_u128) / + b(0x7b0b271b64865f05_f54a7b72746c062f_u128), + 0u128); + + // iter-arithmetic traits + assert_eq!(10u128, [1u128, 2, 3, 4].iter().sum()); + assert_eq!(24u128, [1u128, 2, 3, 4].iter().product()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/u32-decr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/u32-decr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/u32-decr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/u32-decr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + + +pub fn main() { + let mut word: u32 = 200000; + word = word - 1; + assert_eq!(word, 199999); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/u8-incr-decr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/u8-incr-decr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/u8-incr-decr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/u8-incr-decr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + + +// These constants were chosen because they aren't used anywhere +// in the rest of the generated code so they're easily grep-able. + +pub fn main() { + let mut x: u8 = 19; // 0x13 + + let mut y: u8 = 35; // 0x23 + + x = x + 7; // 0x7 + + y = y - 9; // 0x9 + + assert_eq!(x, y); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/u8-incr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/u8-incr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/u8-incr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/u8-incr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + + +pub fn main() { + let mut x: u8 = 12; + let y: u8 = 12; + x = x + 1; + x = x - 1; + assert_eq!(x, y); + // x = 14; + // x = x + 1; + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/uint.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/uint.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/uint.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/numbers-arithmetic/uint.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + +// pretty-expanded FIXME #23616 + +pub fn main() { let _x: usize = 10 as usize; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/operator-overloading.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/operator-overloading.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/operator-overloading.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/operator-overloading.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_variables)] use std::cmp; use std::ops; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/optimization-fuel-0.stdout rustc-1.31.0+dfsg1+llvm/src/test/run-pass/optimization-fuel-0.stdout --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/optimization-fuel-0.stdout 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/optimization-fuel-0.stdout 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1 @@ +optimization-fuel-exhausted: Reorder fields of "S1" diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/optimization-fuel-1.stdout rustc-1.31.0+dfsg1+llvm/src/test/run-pass/optimization-fuel-1.stdout --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/optimization-fuel-1.stdout 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/optimization-fuel-1.stdout 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1 @@ +optimization-fuel-exhausted: Reorder fields of "S2" diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/option-unwrap.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/option-unwrap.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/option-unwrap.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/option-unwrap.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] use std::cell::Cell; struct dtor<'a> { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/out-of-stack.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/out-of-stack.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/out-of-stack.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/out-of-stack.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_must_use)] +#![allow(unconditional_recursion)] // ignore-android: FIXME (#20004) // ignore-musl // ignore-cloudabi no processes diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/output-slot-variants.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/output-slot-variants.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/output-slot-variants.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/output-slot-variants.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] +#![allow(unused_assignments)] +#![allow(unknown_lints)] // pretty-expanded FIXME #23616 #![allow(dead_assignment)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/over-constrained-vregs.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/over-constrained-vregs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/over-constrained-vregs.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/over-constrained-vregs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_must_use)] // Regression test for issue #152. pub fn main() { let mut b: usize = 1_usize; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overlap-permitted-for-annotated-marker-traits.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overlap-permitted-for-annotated-marker-traits.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overlap-permitted-for-annotated-marker-traits.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overlap-permitted-for-annotated-marker-traits.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests for RFC 1268: we allow overlapping impls of marker traits, +// that is, traits with #[marker]. In this case, a type `T` is +// `MyMarker` if it is either `Debug` or `Display`. + +#![feature(marker_trait_attr)] + +use std::fmt::{Debug, Display}; + +#[marker] trait MyMarker {} + +impl MyMarker for T {} +impl MyMarker for T {} + +fn foo(t: T) -> T { + t +} + +fn main() { + // Debug && Display: + assert_eq!(1, foo(1)); + assert_eq!(2.0, foo(2.0)); + + // Debug && !Display: + assert_eq!(vec![1], foo(vec![1])); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/auxiliary/overloaded_autoderef_xc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/auxiliary/overloaded_autoderef_xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/auxiliary/overloaded_autoderef_xc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/auxiliary/overloaded_autoderef_xc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::ops::Deref; + +struct DerefWithHelper { + pub helper: H, + pub value: Option +} + +trait Helper { + fn helper_borrow(&self) -> &T; +} + +impl Helper for Option { + fn helper_borrow(&self) -> &T { + self.as_ref().unwrap() + } +} + +impl> Deref for DerefWithHelper { + type Target = T; + + fn deref(&self) -> &T { + self.helper.helper_borrow() + } +} + +// Test cross-crate autoderef + vtable. +pub fn check(x: T, y: T) -> bool { + let d: DerefWithHelper, T> = DerefWithHelper { helper: Some(x), value: None }; + d.eq(&y) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef-count.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef-count.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef-count.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef-count.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,84 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::cell::Cell; +use std::ops::{Deref, DerefMut}; + +#[derive(PartialEq)] +struct DerefCounter { + count_imm: Cell, + count_mut: usize, + value: T +} + +impl DerefCounter { + fn new(value: T) -> DerefCounter { + DerefCounter { + count_imm: Cell::new(0), + count_mut: 0, + value: value + } + } + + fn counts(&self) -> (usize, usize) { + (self.count_imm.get(), self.count_mut) + } +} + +impl Deref for DerefCounter { + type Target = T; + + fn deref(&self) -> &T { + self.count_imm.set(self.count_imm.get() + 1); + &self.value + } +} + +impl DerefMut for DerefCounter { + fn deref_mut(&mut self) -> &mut T { + self.count_mut += 1; + &mut self.value + } +} + +#[derive(PartialEq, Debug)] +struct Point { + x: isize, + y: isize +} + +impl Point { + fn get(&self) -> (isize, isize) { + (self.x, self.y) + } +} + +pub fn main() { + let mut p = DerefCounter::new(Point {x: 0, y: 0}); + + let _ = p.x; + assert_eq!(p.counts(), (1, 0)); + + let _ = &p.x; + assert_eq!(p.counts(), (2, 0)); + + let _ = &mut p.y; + assert_eq!(p.counts(), (2, 1)); + + p.x += 3; + assert_eq!(p.counts(), (2, 2)); + + p.get(); + assert_eq!(p.counts(), (3, 2)); + + // Check the final state. + assert_eq!(*p, Point {x: 3, y: 0}); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef-indexing.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef-indexing.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef-indexing.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef-indexing.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::ops::Deref; + +struct DerefArray<'a, T:'a> { + inner: &'a [T] +} + +impl<'a, T> Deref for DerefArray<'a, T> { + type Target = &'a [T]; + + fn deref<'b>(&'b self) -> &'b &'a [T] { + &self.inner + } +} + +pub fn main() { + let a = &[1, 2, 3]; + assert_eq!(DerefArray {inner: a}[1], 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef-order.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef-order.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef-order.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef-order.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,81 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::rc::Rc; +use std::ops::Deref; + +#[derive(Copy, Clone)] +struct DerefWrapper { + x: X, + y: Y +} + +impl DerefWrapper { + fn get_x(self) -> X { + self.x + } +} + +impl Deref for DerefWrapper { + type Target = Y; + + fn deref(&self) -> &Y { + &self.y + } +} + +mod priv_test { + use std::ops::Deref; + + #[derive(Copy, Clone)] + pub struct DerefWrapperHideX { + x: X, + pub y: Y + } + + impl DerefWrapperHideX { + pub fn new(x: X, y: Y) -> DerefWrapperHideX { + DerefWrapperHideX { + x: x, + y: y + } + } + } + + impl Deref for DerefWrapperHideX { + type Target = Y; + + fn deref(&self) -> &Y { + &self.y + } + } +} + +pub fn main() { + let nested = DerefWrapper {x: true, y: DerefWrapper {x: 0, y: 1}}; + + // Use the first field that you can find. + assert_eq!(nested.x, true); + assert_eq!((*nested).x, 0); + + // Same for methods, even though there are multiple + // candidates (at different nesting levels). + assert_eq!(nested.get_x(), true); + assert_eq!((*nested).get_x(), 0); + + // Also go through multiple levels of indirection. + assert_eq!(Rc::new(nested).x, true); + + let nested_priv = priv_test::DerefWrapperHideX::new(true, DerefWrapper {x: 0, y: 1}); + assert_eq!(nested_priv.x, 0); + assert_eq!((*nested_priv).x, 0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,55 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +#![allow(stable_features)] + +#![feature(box_syntax, core)] + +use std::cell::RefCell; +use std::rc::Rc; + +#[derive(PartialEq, Debug)] +struct Point { + x: isize, + y: isize +} + +pub fn main() { + let box_5: Box<_> = box 5_usize; + let point = Rc::new(Point {x: 2, y: 4}); + assert_eq!(point.x, 2); + assert_eq!(point.y, 4); + + let i = Rc::new(RefCell::new(2)); + let i_value = *i.borrow(); + *i.borrow_mut() = 5; + assert_eq!((i_value, *i.borrow()), (2, 5)); + + let s = Rc::new("foo".to_string()); + assert_eq!(&**s, "foo"); + + let mut_s = Rc::new(RefCell::new(String::from("foo"))); + mut_s.borrow_mut().push_str("bar"); + // HACK assert_eq! would panic here because it stores the LHS and RHS in two locals. + assert_eq!(&**mut_s.borrow(), "foobar"); + assert_eq!(&**mut_s.borrow_mut(), "foobar"); + + let p = Rc::new(RefCell::new(Point {x: 1, y: 2})); + p.borrow_mut().x = 3; + p.borrow_mut().y += 3; + assert_eq!(*p.borrow(), Point {x: 3, y: 5}); + + let v = Rc::new(RefCell::new([1, 2, 3])); + v.borrow_mut()[0] = 3; + v.borrow_mut()[1] += 3; + assert_eq!((v.borrow()[0], v.borrow()[1], v.borrow()[2]), (3, 5, 3)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef-vtable.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef-vtable.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef-vtable.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef-vtable.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,49 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +use std::ops::Deref; + +struct DerefWithHelper { + helper: H, + value: T +} + +trait Helper { + fn helper_borrow(&self) -> &T; +} + +impl Helper for Option { + fn helper_borrow(&self) -> &T { + self.as_ref().unwrap() + } +} + +impl> Deref for DerefWithHelper { + type Target = T; + + fn deref(&self) -> &T { + self.helper.helper_borrow() + } +} + +struct Foo {x: isize} + +impl Foo { + fn foo(&self) -> isize {self.x} +} + +pub fn main() { + let x: DerefWithHelper, Foo> = + DerefWithHelper { helper: Some(Foo {x: 5}), value: Foo { x: 2 } }; + assert_eq!(x.foo(), 5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef-xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef-xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef-xcrate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-autoderef-xcrate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:overloaded_autoderef_xc.rs + + +extern crate overloaded_autoderef_xc; + +fn main() { + assert!(overloaded_autoderef_xc::check(5, 5)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-object-one-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-object-one-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-object-one-arg.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-object-one-arg.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests calls to closure arguments where the closure takes 1 argument. +// This is a bit tricky due to rust-call ABI. + + +fn foo(f: &mut FnMut(isize) -> isize) -> isize { + f(22) +} + +fn main() { + let z = foo(&mut |x| x *100); + assert_eq!(z, 2200); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-object-two-args.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-object-two-args.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-object-two-args.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-object-two-args.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests calls to closure arguments where the closure takes 2 arguments. +// This is a bit tricky due to rust-call ABI. + + +fn foo(f: &mut FnMut(isize, isize) -> isize) -> isize { + f(1, 2) +} + +fn main() { + let z = foo(&mut |x, y| x * 10 + y); + assert_eq!(z, 12); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-object-zero-args.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-object-zero-args.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-object-zero-args.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-object-zero-args.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests calls to closure arguments where the closure takes 0 arguments. +// This is a bit tricky due to rust-call ABI. + + +fn foo(f: &mut FnMut() -> isize) -> isize { + f() +} + +fn main() { + let z = foo(&mut || 22); + assert_eq!(z, 22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-param-vtables.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-param-vtables.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-param-vtables.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-param-vtables.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests that nested vtables work with overloaded calls. + +// pretty-expanded FIXME #23616 + +#![feature(unboxed_closures, fn_traits)] + +use std::marker::PhantomData; +use std::ops::Fn; +use std::ops::Add; + +struct G(PhantomData); + +impl<'a, A: Add> Fn<(A,)> for G { + extern "rust-call" fn call(&self, (arg,): (A,)) -> i32 { + arg.add(1) + } +} + +impl<'a, A: Add> FnMut<(A,)> for G { + extern "rust-call" fn call_mut(&mut self, args: (A,)) -> i32 { self.call(args) } +} + +impl<'a, A: Add> FnOnce<(A,)> for G { + type Output = i32; + extern "rust-call" fn call_once(self, args: (A,)) -> i32 { self.call(args) } +} + +fn main() { + // ICE trigger + (G(PhantomData))(1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-simple.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-simple.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-simple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,88 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(lang_items, unboxed_closures, fn_traits)] + +use std::ops::{Fn, FnMut, FnOnce}; + +struct S1 { + x: i32, + y: i32, +} + +impl FnMut<(i32,)> for S1 { + extern "rust-call" fn call_mut(&mut self, (z,): (i32,)) -> i32 { + self.x * self.y * z + } +} + +impl FnOnce<(i32,)> for S1 { + type Output = i32; + extern "rust-call" fn call_once(mut self, args: (i32,)) -> i32 { + self.call_mut(args) + } +} + +struct S2 { + x: i32, + y: i32, +} + +impl Fn<(i32,)> for S2 { + extern "rust-call" fn call(&self, (z,): (i32,)) -> i32 { + self.x * self.y * z + } +} + +impl FnMut<(i32,)> for S2 { + extern "rust-call" fn call_mut(&mut self, args: (i32,)) -> i32 { self.call(args) } +} + +impl FnOnce<(i32,)> for S2 { + type Output = i32; + extern "rust-call" fn call_once(self, args: (i32,)) -> i32 { self.call(args) } +} + +struct S3 { + x: i32, + y: i32, +} + +impl FnOnce<(i32,i32)> for S3 { + type Output = i32; + extern "rust-call" fn call_once(self, (z,zz): (i32,i32)) -> i32 { + self.x * self.y * z * zz + } +} + +fn main() { + let mut s = S1 { + x: 3, + y: 3, + }; + let ans = s(3); + + assert_eq!(ans, 27); + let s = S2 { + x: 3, + y: 3, + }; + let ans = s.call((3,)); + assert_eq!(ans, 27); + + let s = S3 { + x: 3, + y: 3, + }; + let ans = s(3, 1); + assert_eq!(ans, 27); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-zero-args.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-zero-args.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-zero-args.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-calls-zero-args.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(unboxed_closures, fn_traits)] + +use std::ops::FnMut; + +struct S { + x: i32, + y: i32, +} + +impl FnMut<()> for S { + extern "rust-call" fn call_mut(&mut self, (): ()) -> i32 { + self.x * self.y + } +} + +impl FnOnce<()> for S { + type Output = i32; + extern "rust-call" fn call_once(mut self, args: ()) -> i32 { self.call_mut(args) } +} + +fn main() { + let mut s = S { + x: 3, + y: 3, + }; + let ans = s(); + assert_eq!(ans, 9); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-deref-count.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-deref-count.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-deref-count.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-deref-count.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,88 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::cell::Cell; +use std::ops::{Deref, DerefMut}; +use std::vec::Vec; + +struct DerefCounter { + count_imm: Cell, + count_mut: usize, + value: T +} + +impl DerefCounter { + fn new(value: T) -> DerefCounter { + DerefCounter { + count_imm: Cell::new(0), + count_mut: 0, + value: value + } + } + + fn counts(&self) -> (usize, usize) { + (self.count_imm.get(), self.count_mut) + } +} + +impl Deref for DerefCounter { + type Target = T; + + fn deref(&self) -> &T { + self.count_imm.set(self.count_imm.get() + 1); + &self.value + } +} + +impl DerefMut for DerefCounter { + fn deref_mut(&mut self) -> &mut T { + self.count_mut += 1; + &mut self.value + } +} + +pub fn main() { + let mut n = DerefCounter::new(0); + let mut v = DerefCounter::new(Vec::new()); + + let _ = *n; // Immutable deref + copy a POD. + assert_eq!(n.counts(), (1, 0)); + + let _ = (&*n, &*v); // Immutable deref + borrow. + assert_eq!(n.counts(), (2, 0)); assert_eq!(v.counts(), (1, 0)); + + let _ = (&mut *n, &mut *v); // Mutable deref + mutable borrow. + assert_eq!(n.counts(), (2, 1)); assert_eq!(v.counts(), (1, 1)); + + let mut v2 = Vec::new(); + v2.push(1); + + *n = 5; *v = v2; // Mutable deref + assignment. + assert_eq!(n.counts(), (2, 2)); assert_eq!(v.counts(), (1, 2)); + + *n -= 3; // Mutable deref + assignment with binary operation. + assert_eq!(n.counts(), (2, 3)); + + // Immutable deref used for calling a method taking &self. (The + // typechecker is smarter now about doing this.) + (*n).to_string(); + assert_eq!(n.counts(), (3, 3)); + + // Mutable deref used for calling a method taking &mut self. + (*v).push(2); + assert_eq!(v.counts(), (1, 3)); + + // Check the final states. + assert_eq!(*n, 2); + let expected: &[_] = &[1, 2]; + assert_eq!((*v), expected); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-deref.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-deref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-deref.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-deref.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,53 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::cell::RefCell; +use std::rc::Rc; +use std::string::String; + +#[derive(PartialEq, Debug)] +struct Point { + x: isize, + y: isize +} + +pub fn main() { + assert_eq!(*Rc::new(5), 5); + assert_eq!(***Rc::new(Box::new(Box::new(5))), 5); + assert_eq!(*Rc::new(Point {x: 2, y: 4}), Point {x: 2, y: 4}); + + let i = Rc::new(RefCell::new(2)); + let i_value = *(*i).borrow(); + *(*i).borrow_mut() = 5; + assert_eq!((i_value, *(*i).borrow()), (2, 5)); + + let s = Rc::new("foo".to_string()); + assert_eq!(*s, "foo".to_string()); + assert_eq!((*s), "foo"); + + let mut_s = Rc::new(RefCell::new(String::from("foo"))); + (*(*mut_s).borrow_mut()).push_str("bar"); + // assert_eq! would panic here because it stores the LHS and RHS in two locals. + assert_eq!((*(*mut_s).borrow()), "foobar"); + assert_eq!((*(*mut_s).borrow_mut()), "foobar"); + + let p = Rc::new(RefCell::new(Point {x: 1, y: 2})); + (*(*p).borrow_mut()).x = 3; + (*(*p).borrow_mut()).y += 3; + assert_eq!(*(*p).borrow(), Point {x: 3, y: 5}); + + let v = Rc::new(RefCell::new(vec![1, 2, 3])); + (*(*v).borrow_mut())[0] = 3; + (*(*v).borrow_mut())[1] += 3; + assert_eq!(((*(*v).borrow())[0], + (*(*v).borrow())[1], + (*(*v).borrow())[2]), (3, 5, 3)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded_deref_with_ref_pattern_issue15609.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded_deref_with_ref_pattern_issue15609.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded_deref_with_ref_pattern_issue15609.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded_deref_with_ref_pattern_issue15609.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// Test that we choose Deref or DerefMut appropriately based on mutability of ref bindings (#15609). + +fn main() { + use std::cell::RefCell; + + struct S { + node: E, + } + + enum E { + Foo(u32), + Bar, + } + + // Check match + let x = RefCell::new(S { node: E::Foo(0) }); + + let mut b = x.borrow_mut(); + match b.node { + E::Foo(ref mut n) => *n += 1, + _ => (), + } + + // Check let + let x = RefCell::new(0); + let mut y = x.borrow_mut(); + let ref mut z = *y; + + fn foo(a: &mut RefCell>) { + if let Some(ref mut s) = *a.borrow_mut() { + s.push('a') + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded_deref_with_ref_pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded_deref_with_ref_pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded_deref_with_ref_pattern.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded_deref_with_ref_pattern.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,105 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +#![allow(unused_variables)] +// Test that we choose Deref or DerefMut appropriately based on mutability of ref bindings (#15609). + +use std::ops::{Deref, DerefMut}; + +struct DerefOk(T); +struct DerefMutOk(T); + +impl Deref for DerefOk { + type Target = T; + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl DerefMut for DerefOk { + fn deref_mut(&mut self) -> &mut Self::Target { + panic!() + } +} + +impl Deref for DerefMutOk { + type Target = T; + fn deref(&self) -> &Self::Target { + panic!() + } +} + +impl DerefMut for DerefMutOk { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + +fn main() { + // Check that mutable ref binding in match picks DerefMut + let mut b = DerefMutOk(0); + match *b { + ref mut n => n, + }; + + // Check that mutable ref binding in let picks DerefMut + let mut y = DerefMutOk(1); + let ref mut z = *y; + + // Check that immutable ref binding in match picks Deref + let mut b = DerefOk(2); + match *b { + ref n => n, + }; + + // Check that immutable ref binding in let picks Deref + let mut y = DerefOk(3); + let ref z = *y; + + // Check that mixed mutable/immutable ref binding in match picks DerefMut + let mut b = DerefMutOk((0, 9)); + match *b { + (ref mut n, ref m) => (n, m), + }; + + let mut b = DerefMutOk((0, 9)); + match *b { + (ref n, ref mut m) => (n, m), + }; + + // Check that mixed mutable/immutable ref binding in let picks DerefMut + let mut y = DerefMutOk((1, 8)); + let (ref mut z, ref a) = *y; + + let mut y = DerefMutOk((1, 8)); + let (ref z, ref mut a) = *y; + + // Check that multiple immutable ref bindings in match picks Deref + let mut b = DerefOk((2, 7)); + match *b { + (ref n, ref m) => (n, m), + }; + + // Check that multiple immutable ref bindings in let picks Deref + let mut y = DerefOk((3, 6)); + let (ref z, ref a) = *y; + + // Check that multiple mutable ref bindings in match picks DerefMut + let mut b = DerefMutOk((4, 5)); + match *b { + (ref mut n, ref mut m) => (n, m), + }; + + // Check that multiple mutable ref bindings in let picks DerefMut + let mut y = DerefMutOk((5, 4)); + let (ref mut z, ref mut a) = *y; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-index-assoc-list.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-index-assoc-list.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-index-assoc-list.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-index-assoc-list.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,58 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test overloading of the `[]` operator. In particular test that it +// takes its argument *by reference*. + +use std::ops::Index; + +struct AssociationList { + pairs: Vec> } + +#[derive(Clone)] +struct AssociationPair { + key: K, + value: V +} + +impl AssociationList { + fn push(&mut self, key: K, value: V) { + self.pairs.push(AssociationPair {key: key, value: value}); + } +} + +impl<'a, K: PartialEq + std::fmt::Debug, V:Clone> Index<&'a K> for AssociationList { + type Output = V; + + fn index(&self, index: &K) -> &V { + for pair in &self.pairs { + if pair.key == *index { + return &pair.value + } + } + panic!("No value found for key: {:?}", index); + } +} + +pub fn main() { + let foo = "foo".to_string(); + let bar = "bar".to_string(); + + let mut list = AssociationList {pairs: Vec::new()}; + list.push(foo.clone(), 22); + list.push(bar.clone(), 44); + + assert_eq!(list[&foo], 22); + assert_eq!(list[&bar], 44); + + assert_eq!(list[&foo], 22); + assert_eq!(list[&bar], 44); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-index-autoderef.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-index-autoderef.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-index-autoderef.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-index-autoderef.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,87 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(stable_features)] + +// Test overloaded indexing combined with autoderef. + +#![feature(box_syntax, core)] + +use std::ops::{Index, IndexMut}; + +struct Foo { + x: isize, + y: isize, +} + +impl Index for Foo { + type Output = isize; + + fn index(&self, z: isize) -> &isize { + if z == 0 { + &self.x + } else { + &self.y + } + } +} + +impl IndexMut for Foo { + fn index_mut(&mut self, z: isize) -> &mut isize { + if z == 0 { + &mut self.x + } else { + &mut self.y + } + } +} + +trait Int { + fn get(self) -> isize; + fn get_from_ref(&self) -> isize; + fn inc(&mut self); +} + +impl Int for isize { + fn get(self) -> isize { self } + fn get_from_ref(&self) -> isize { *self } + fn inc(&mut self) { *self += 1; } +} + +fn main() { + let mut f: Box<_> = box Foo { + x: 1, + y: 2, + }; + + assert_eq!(f[1], 2); + + f[0] = 3; + + assert_eq!(f[0], 3); + + // Test explicit IndexMut where `f` must be autoderef: + { + let p = &mut f[1]; + *p = 4; + } + + // Test explicit Index where `f` must be autoderef: + { + let p = &f[1]; + assert_eq!(*p, 4); + } + + // Test calling methods with `&mut self`, `self, and `&self` receivers: + f[1].inc(); + assert_eq!(f[1].get(), 5); + assert_eq!(f[1].get_from_ref(), 5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-index-in-field.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-index-in-field.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-index-in-field.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-index-in-field.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,56 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test using overloaded indexing when the "map" is stored in a +// field. This caused problems at some point. + +use std::ops::Index; + +struct Foo { + x: isize, + y: isize, +} + +struct Bar { + foo: Foo +} + +impl Index for Foo { + type Output = isize; + + fn index(&self, z: isize) -> &isize { + if z == 0 { + &self.x + } else { + &self.y + } + } +} + +trait Int { + fn get(self) -> isize; + fn get_from_ref(&self) -> isize; + fn inc(&mut self); +} + +impl Int for isize { + fn get(self) -> isize { self } + fn get_from_ref(&self) -> isize { *self } + fn inc(&mut self) { *self += 1; } +} + +fn main() { + let f = Bar { foo: Foo { + x: 1, + y: 2, + } }; + assert_eq!(f.foo[1].get(), 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-index.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-index.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-index.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/overloaded/overloaded-index.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,74 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::ops::{Index, IndexMut}; + +struct Foo { + x: isize, + y: isize, +} + +impl Index for Foo { + type Output = isize; + + fn index(&self, z: isize) -> &isize { + if z == 0 { + &self.x + } else { + &self.y + } + } +} + +impl IndexMut for Foo { + fn index_mut(&mut self, z: isize) -> &mut isize { + if z == 0 { + &mut self.x + } else { + &mut self.y + } + } +} + +trait Int { + fn get(self) -> isize; + fn get_from_ref(&self) -> isize; + fn inc(&mut self); +} + +impl Int for isize { + fn get(self) -> isize { self } + fn get_from_ref(&self) -> isize { *self } + fn inc(&mut self) { *self += 1; } +} + +fn main() { + let mut f = Foo { + x: 1, + y: 2, + }; + assert_eq!(f[1], 2); + f[0] = 3; + assert_eq!(f[0], 3); + { + let p = &mut f[1]; + *p = 4; + } + { + let p = &f[1]; + assert_eq!(*p, 4); + } + + // Test calling methods with `&mut self`, `self, and `&self` receivers: + f[1].inc(); + assert_eq!(f[1].get(), 5); + assert_eq!(f[1].get_from_ref(), 5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/auxiliary/packed.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/auxiliary/packed.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/auxiliary/packed.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/auxiliary/packed.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(repr_packed)] + +#[repr(packed)] +pub struct P1S5 { + a: u8, + b: u32 +} + +#[repr(packed(2))] +pub struct P2S6 { + a: u8, + b: u32, + c: u8 +} + +#[repr(C, packed(2))] +pub struct P2CS8 { + a: u8, + b: u32, + c: u8 +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-borrow-element.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-borrow-element.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-borrow-element.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-borrow-element.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// ignore-emscripten weird assertion? + +#![feature(repr_packed)] + +#[repr(packed)] +struct Foo1 { + bar: u8, + baz: usize +} + +#[repr(packed(2))] +struct Foo2 { + bar: u8, + baz: usize +} + +#[repr(C, packed(4))] +struct Foo4C { + bar: u8, + baz: usize +} + +pub fn main() { + let foo = Foo1 { bar: 1, baz: 2 }; + let brw = unsafe { &foo.baz }; + assert_eq!(*brw, 2); + + let foo = Foo2 { bar: 1, baz: 2 }; + let brw = unsafe { &foo.baz }; + assert_eq!(*brw, 2); + + let foo = Foo4C { bar: 1, baz: 2 }; + let brw = unsafe { &foo.baz }; + assert_eq!(*brw, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-drop-aligned.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-drop-aligned.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-drop-aligned.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-drop-aligned.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::cell::Cell; +use std::mem; + +struct Aligned<'a> { + drop_count: &'a Cell +} + +#[inline(never)] +fn check_align(ptr: *const Aligned) { + assert_eq!(ptr as usize % mem::align_of::(), + 0); +} + +impl<'a> Drop for Aligned<'a> { + fn drop(&mut self) { + check_align(self); + self.drop_count.set(self.drop_count.get() + 1); + } +} + +#[repr(packed)] +struct Packed<'a>(u8, Aligned<'a>); + +fn main() { + let drop_count = &Cell::new(0); + { + let mut p = Packed(0, Aligned { drop_count }); + p.1 = Aligned { drop_count }; + assert_eq!(drop_count.get(), 1); + } + assert_eq!(drop_count.get(), 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-generic-layout.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-generic-layout.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-generic-layout.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-generic-layout.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(overflowing_literals)] + + +use std::mem; + +#[repr(packed)] +struct S { + a: T, + b: u8, + c: S +} + +pub fn main() { + unsafe { + let s = S { a: 0xff_ff_ff_ffu32, b: 1, c: 0xaa_aa_aa_aa as i32 }; + let transd : [u8; 9] = mem::transmute(s); + // Don't worry about endianness, the numbers are palindromic. + assert_eq!(transd, + [0xff, 0xff, 0xff, 0xff, + 1, + 0xaa, 0xaa, 0xaa, 0xaa]); + + + let s = S { a: 1u8, b: 2u8, c: 0b10000001_10000001 as i16}; + let transd : [u8; 4] = mem::transmute(s); + // Again, no endianness problems. + assert_eq!(transd, + [1, 2, 0b10000001, 0b10000001]); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-generic-size.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-generic-size.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-generic-size.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-generic-size.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,57 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(stable_features)] +#![allow(unused_comparisons)] + +#![feature(repr_packed)] + +use std::mem; + +#[repr(packed)] +struct P1 { + a: T, + b: u8, + c: S +} + +#[repr(packed(2))] +struct P2 { + a: T, + b: u8, + c: S +} + +#[repr(C, packed(4))] +struct P4C { + a: T, + b: u8, + c: S +} + +macro_rules! check { + ($t:ty, $align:expr, $size:expr) => ({ + assert_eq!(mem::align_of::<$t>(), $align); + assert_eq!(mem::size_of::<$t>(), $size); + }); +} + +pub fn main() { + check!(P1::, 1, 3); + check!(P1::, 1, 11); + + check!(P2::, 1, 3); + check!(P2::, 2, 12); + + check!(P4C::, 1, 3); + check!(P4C::, 4, 12); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-generic-size.stderr rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-generic-size.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-generic-size.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-generic-size.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +warning: unnecessary path disambiguator + --> $DIR/packed-struct-generic-size.rs:49:14 + | +LL | check!(P1::, 1, 3); + | ^^ try removing `::` + +warning: unnecessary path disambiguator + --> $DIR/packed-struct-generic-size.rs:50:14 + | +LL | check!(P1::, 1, 11); + | ^^ try removing `::` + +warning: unnecessary path disambiguator + --> $DIR/packed-struct-generic-size.rs:52:14 + | +LL | check!(P2::, 1, 3); + | ^^ try removing `::` + +warning: unnecessary path disambiguator + --> $DIR/packed-struct-generic-size.rs:53:14 + | +LL | check!(P2::, 2, 12); + | ^^ try removing `::` + +warning: unnecessary path disambiguator + --> $DIR/packed-struct-generic-size.rs:55:15 + | +LL | check!(P4C::, 1, 3); + | ^^ try removing `::` + +warning: unnecessary path disambiguator + --> $DIR/packed-struct-generic-size.rs:56:15 + | +LL | check!(P4C::, 4, 12); + | ^^ try removing `::` + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-layout.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-layout.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-layout.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-layout.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +use std::mem; + +#[repr(packed)] +struct S4 { + a: u8, + b: [u8; 3], +} + +#[repr(packed)] +struct S5 { + a: u8, + b: u32 +} + +pub fn main() { + unsafe { + let s4 = S4 { a: 1, b: [2,3,4] }; + let transd : [u8; 4] = mem::transmute(s4); + assert_eq!(transd, [1, 2, 3, 4]); + + let s5 = S5 { a: 1, b: 0xff_00_00_ff }; + let transd : [u8; 5] = mem::transmute(s5); + // Don't worry about endianness, the u32 is palindromic. + assert_eq!(transd, [1, 0xff, 0, 0, 0xff]); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-match.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-match.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,56 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(repr_packed)] + +#[repr(packed)] +struct Foo1 { + bar: u8, + baz: usize +} + +#[repr(packed(2))] +struct Foo2 { + bar: u8, + baz: usize +} + +#[repr(C, packed(4))] +struct Foo4C { + bar: u8, + baz: usize +} + +pub fn main() { + let foo1 = Foo1 { bar: 1, baz: 2 }; + match foo1 { + Foo1 {bar, baz} => { + assert_eq!(bar, 1); + assert_eq!(baz, 2); + } + } + + let foo2 = Foo2 { bar: 1, baz: 2 }; + match foo2 { + Foo2 {bar, baz} => { + assert_eq!(bar, 1); + assert_eq!(baz, 2); + } + } + + let foo4 = Foo4C { bar: 1, baz: 2 }; + match foo4 { + Foo4C {bar, baz} => { + assert_eq!(bar, 1); + assert_eq!(baz, 2); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-optimized-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-optimized-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-optimized-enum.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-optimized-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[repr(packed)] +struct Packed(T); + +impl Copy for Packed {} +impl Clone for Packed { + fn clone(&self) -> Self { *self } +} + +fn sanity_check_size(one: T) { + let two = [one, one]; + let stride = (&two[1] as *const _ as usize) - (&two[0] as *const _ as usize); + let (size, align) = (std::mem::size_of::(), std::mem::align_of::()); + assert_eq!(stride, size); + assert_eq!(size % align, 0); +} + +fn main() { + // This can fail if rustc and LLVM disagree on the size of a type. + // In this case, `Option>` was erroneously not + // marked as packed despite needing alignment `1` and containing + // its `&()` discriminant, which has alignment larger than `1`. + sanity_check_size((Some(Packed((&(), 0))), true)); + + // In #46769, `Option<(Packed<&()>, bool)>` was found to have + // pointer alignment, without actually being aligned in size. + // E.g. on 64-bit platforms, it had alignment `8` but size `9`. + type PackedRefAndBool<'a> = (Packed<&'a ()>, bool); + sanity_check_size::>(Some((Packed(&()), true))); + + // Make sure we don't pay for the enum optimization in size, + // e.g. we shouldn't need extra padding after the packed data. + assert_eq!(std::mem::align_of::>(), 1); + assert_eq!(std::mem::size_of::>(), + std::mem::size_of::()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-size.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-size.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-size.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-size.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,170 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] +#![allow(non_upper_case_globals)] + +#![feature(repr_packed)] + + +use std::mem; + +#[repr(packed)] +struct P1S4 { + a: u8, + b: [u8; 3], +} + +#[repr(packed(2))] +struct P2S4 { + a: u8, + b: [u8; 3], +} + +#[repr(packed)] +struct P1S5 { + a: u8, + b: u32 +} + +#[repr(packed(2))] +struct P2S2 { + a: u8, + b: u8 +} + +#[repr(packed(2))] +struct P2S6 { + a: u8, + b: u32 +} + +#[repr(packed(2))] +struct P2S12 { + a: u32, + b: u64 +} + +#[repr(packed)] +struct P1S13 { + a: i64, + b: f32, + c: u8, +} + +#[repr(packed(2))] +struct P2S14 { + a: i64, + b: f32, + c: u8, +} + +#[repr(packed(4))] +struct P4S16 { + a: u8, + b: f32, + c: i64, + d: u16, +} + +#[repr(C, packed(4))] +struct P4CS20 { + a: u8, + b: f32, + c: i64, + d: u16, +} + +enum Foo { + Bar = 1, + Baz = 2 +} + +#[repr(packed)] +struct P1S3_Foo { + a: u8, + b: u16, + c: Foo +} + +#[repr(packed(2))] +struct P2_Foo { + a: Foo, +} + +#[repr(packed(2))] +struct P2S3_Foo { + a: u8, + b: u16, + c: Foo +} + +#[repr(packed)] +struct P1S7_Option { + a: f32, + b: u8, + c: u16, + d: Option> +} + +#[repr(packed(2))] +struct P2_Option { + a: Option> +} + +#[repr(packed(2))] +struct P2S7_Option { + a: f32, + b: u8, + c: u16, + d: Option> +} + +// Placing packed structs in statics should work +static TEST_P1S4: P1S4 = P1S4 { a: 1, b: [2, 3, 4] }; +static TEST_P1S5: P1S5 = P1S5 { a: 3, b: 67 }; +static TEST_P1S3_Foo: P1S3_Foo = P1S3_Foo { a: 1, b: 2, c: Foo::Baz }; +static TEST_P2S2: P2S2 = P2S2 { a: 1, b: 2 }; +static TEST_P2S4: P2S4 = P2S4 { a: 1, b: [2, 3, 4] }; +static TEST_P2S6: P2S6 = P2S6 { a: 1, b: 2 }; +static TEST_P2S12: P2S12 = P2S12 { a: 1, b: 2 }; +static TEST_P4S16: P4S16 = P4S16 { a: 1, b: 2.0, c: 3, d: 4 }; +static TEST_P4CS20: P4CS20 = P4CS20 { a: 1, b: 2.0, c: 3, d: 4 }; + +fn align_to(value: usize, align: usize) -> usize { + (value + (align - 1)) & !(align - 1) +} + +macro_rules! check { + ($t:ty, $align:expr, $size:expr) => ({ + assert_eq!(mem::align_of::<$t>(), $align); + assert_eq!(mem::size_of::<$t>(), $size); + }); +} + +pub fn main() { + check!(P1S4, 1, 4); + check!(P1S5, 1, 5); + check!(P1S13, 1, 13); + check!(P1S3_Foo, 1, 3 + mem::size_of::()); + check!(P1S7_Option, 1, 7 + mem::size_of::>>()); + + check!(P2S2, 1, 2); + check!(P2S4, 1, 4); + check!(P2S6, 2, 6); + check!(P2S12, 2, 12); + check!(P2S14, 2, 14); + check!(P4S16, 4, 16); + check!(P4CS20, 4, 20); + check!(P2S3_Foo, 2, align_to(3 + mem::size_of::(), 2)); + check!(P2S7_Option, 2, align_to(7 + mem::size_of::(), 2)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-size-xc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-size-xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-size-xc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-size-xc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:packed.rs + + +extern crate packed; + +use std::mem; + +macro_rules! check { + ($t:ty, $align:expr, $size:expr) => ({ + assert_eq!(mem::align_of::<$t>(), $align); + assert_eq!(mem::size_of::<$t>(), $size); + }); +} + +pub fn main() { + check!(packed::P1S5, 1, 5); + check!(packed::P2S6, 2, 6); + check!(packed::P2CS8, 2, 8); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-vec.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-vec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-vec.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-struct-vec.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,131 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(repr_packed)] + +use std::fmt; +use std::mem; + +#[repr(packed)] +#[derive(Copy, Clone)] +struct Foo1 { + bar: u8, + baz: u64 +} + +impl PartialEq for Foo1 { + fn eq(&self, other: &Foo1) -> bool { + self.bar == other.bar && self.baz == other.baz + } +} + +impl fmt::Debug for Foo1 { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let bar = self.bar; + let baz = self.baz; + + f.debug_struct("Foo1") + .field("bar", &bar) + .field("baz", &baz) + .finish() + } +} + +#[repr(packed(2))] +#[derive(Copy, Clone)] +struct Foo2 { + bar: u8, + baz: u64 +} + +impl PartialEq for Foo2 { + fn eq(&self, other: &Foo2) -> bool { + self.bar == other.bar && self.baz == other.baz + } +} + +impl fmt::Debug for Foo2 { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let bar = self.bar; + let baz = self.baz; + + f.debug_struct("Foo2") + .field("bar", &bar) + .field("baz", &baz) + .finish() + } +} + +#[repr(C, packed(4))] +#[derive(Copy, Clone)] +struct Foo4C { + bar: u8, + baz: u64 +} + +impl PartialEq for Foo4C { + fn eq(&self, other: &Foo4C) -> bool { + self.bar == other.bar && self.baz == other.baz + } +} + +impl fmt::Debug for Foo4C { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let bar = self.bar; + let baz = self.baz; + + f.debug_struct("Foo4C") + .field("bar", &bar) + .field("baz", &baz) + .finish() + } +} + +pub fn main() { + let foo1s = [Foo1 { bar: 1, baz: 2 }; 10]; + + assert_eq!(mem::align_of::<[Foo1; 10]>(), 1); + assert_eq!(mem::size_of::<[Foo1; 10]>(), 90); + + for i in 0..10 { + assert_eq!(foo1s[i], Foo1 { bar: 1, baz: 2}); + } + + for &foo in &foo1s { + assert_eq!(foo, Foo1 { bar: 1, baz: 2 }); + } + + let foo2s = [Foo2 { bar: 1, baz: 2 }; 10]; + + assert_eq!(mem::align_of::<[Foo2; 10]>(), 2); + assert_eq!(mem::size_of::<[Foo2; 10]>(), 100); + + for i in 0..10 { + assert_eq!(foo2s[i], Foo2 { bar: 1, baz: 2}); + } + + for &foo in &foo2s { + assert_eq!(foo, Foo2 { bar: 1, baz: 2 }); + } + + let foo4s = [Foo4C { bar: 1, baz: 2 }; 10]; + + assert_eq!(mem::align_of::<[Foo4C; 10]>(), 4); + assert_eq!(mem::size_of::<[Foo4C; 10]>(), 120); + + for i in 0..10 { + assert_eq!(foo4s[i], Foo4C { bar: 1, baz: 2}); + } + + for &foo in &foo4s { + assert_eq!(foo, Foo4C { bar: 1, baz: 2 }); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-tuple-struct-layout.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-tuple-struct-layout.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-tuple-struct-layout.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-tuple-struct-layout.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::mem; + +#[repr(packed)] +struct S4(u8,[u8; 3]); + +#[repr(packed)] +struct S5(u8,u32); + +pub fn main() { + unsafe { + let s4 = S4(1, [2,3,4]); + let transd : [u8; 4] = mem::transmute(s4); + assert_eq!(transd, [1, 2, 3, 4]); + + let s5 = S5(1, 0xff_00_00_ff); + let transd : [u8; 5] = mem::transmute(s5); + // Don't worry about endianness, the u32 is palindromic. + assert_eq!(transd, [1, 0xff, 0, 0, 0xff]); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-tuple-struct-size.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-tuple-struct-size.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/packed/packed-tuple-struct-size.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/packed/packed-tuple-struct-size.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,91 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +#![feature(repr_packed)] + +use std::mem; + +#[repr(packed)] +struct P1S4(u8,[u8; 3]); + +#[repr(packed(2))] +struct P2S4(u8,[u8; 3]); + +#[repr(packed)] +struct P1S5(u8, u32); + +#[repr(packed(2))] +struct P2S6(u8, u32); + +#[repr(packed)] +struct P1S13(i64, f32, u8); + +#[repr(packed(2))] +struct P2S14(i64, f32, u8); + +#[repr(packed(4))] +struct P4S16(u8, f32, i64, u16); + +#[repr(C, packed(4))] +struct P4CS20(u8, f32, i64, u16); + +enum Foo { + Bar = 1, + Baz = 2 +} + +#[repr(packed)] +struct P1S3_Foo(u8, u16, Foo); + +#[repr(packed(2))] +struct P2_Foo(Foo); + +#[repr(packed(2))] +struct P2S3_Foo(u8, u16, Foo); + +#[repr(packed)] +struct P1S7_Option(f32, u8, u16, Option>); + +#[repr(packed(2))] +struct P2_Option(Option>); + +#[repr(packed(2))] +struct P2S7_Option(f32, u8, u16, Option>); + +fn align_to(value: usize, align: usize) -> usize { + (value + (align - 1)) & !(align - 1) +} + +macro_rules! check { + ($t:ty, $align:expr, $size:expr) => ({ + assert_eq!(mem::align_of::<$t>(), $align); + assert_eq!(mem::size_of::<$t>(), $size); + }); +} + +pub fn main() { + check!(P1S4, 1, 4); + check!(P1S5, 1, 5); + check!(P1S13, 1, 13); + check!(P1S3_Foo, 1, 3 + mem::size_of::()); + check!(P1S7_Option, 1, 7 + mem::size_of::>>()); + + check!(P2S4, 1, 4); + check!(P2S6, 2, 6); + check!(P2S14, 2, 14); + check!(P4S16, 4, 16); + check!(P4CS20, 4, 20); + check!(P2S3_Foo, 2, align_to(3 + mem::size_of::(), 2)); + check!(P2S7_Option, 2, align_to(7 + mem::size_of::(), 2)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panic-runtime/abort-link-to-unwinding-crates.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panic-runtime/abort-link-to-unwinding-crates.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panic-runtime/abort-link-to-unwinding-crates.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panic-runtime/abort-link-to-unwinding-crates.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,50 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// compile-flags:-C panic=abort +// aux-build:exit-success-if-unwind.rs +// no-prefer-dynamic +// ignore-cloudabi no processes +// ignore-emscripten no processes +// ignore-macos + +extern crate exit_success_if_unwind; + +use std::process::Command; +use std::env; + +fn main() { + let mut args = env::args_os(); + let me = args.next().unwrap(); + + if let Some(s) = args.next() { + if &*s == "foo" { + exit_success_if_unwind::bar(do_panic); + } + } + + let mut cmd = Command::new(env::args_os().next().unwrap()); + cmd.arg("foo"); + + + // ARMv6 hanges while printing the backtrace, see #41004 + if cfg!(target_arch = "arm") && cfg!(target_env = "gnu") { + cmd.env("RUST_BACKTRACE", "0"); + } + + let s = cmd.status(); + assert!(s.unwrap().code() != Some(0)); +} + +fn do_panic() { + panic!("try to catch me"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panic-runtime/abort.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panic-runtime/abort.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panic-runtime/abort.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panic-runtime/abort.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,53 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// compile-flags:-C panic=abort +// no-prefer-dynamic +// ignore-cloudabi no processes +// ignore-emscripten no processes +// ignore-macos + +use std::process::Command; +use std::env; + +struct Bomb; + +impl Drop for Bomb { + fn drop(&mut self) { + std::process::exit(0); + } +} + +fn main() { + let mut args = env::args_os(); + let me = args.next().unwrap(); + + if let Some(s) = args.next() { + if &*s == "foo" { + + let _bomb = Bomb; + + panic!("try to catch me"); + } + } + + let mut cmd = Command::new(env::args_os().next().unwrap()); + cmd.arg("foo"); + + // ARMv6 hanges while printing the backtrace, see #41004 + if cfg!(target_arch = "arm") && cfg!(target_env = "gnu") { + cmd.env("RUST_BACKTRACE", "0"); + } + + let s = cmd.status(); + assert!(s.unwrap().code() != Some(0)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panic-runtime/auxiliary/exit-success-if-unwind.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panic-runtime/auxiliary/exit-success-if-unwind.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panic-runtime/auxiliary/exit-success-if-unwind.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panic-runtime/auxiliary/exit-success-if-unwind.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "rlib"] + +struct Bomb; + +impl Drop for Bomb { + fn drop(&mut self) { + std::process::exit(0); + } +} + +pub fn bar(f: fn()) { + let _bomb = Bomb; + f(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panic-runtime/link-to-abort.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panic-runtime/link-to-abort.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panic-runtime/link-to-abort.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panic-runtime/link-to-abort.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// compile-flags:-C panic=abort +// no-prefer-dynamic +// ignore-macos + +#![feature(panic_abort)] + +extern crate panic_abort; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panic-runtime/link-to-unwind.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panic-runtime/link-to-unwind.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panic-runtime/link-to-unwind.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panic-runtime/link-to-unwind.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// no-prefer-dynamic + +#![feature(panic_unwind)] + +extern crate panic_unwind; + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panic-runtime/lto-abort.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panic-runtime/lto-abort.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panic-runtime/lto-abort.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panic-runtime/lto-abort.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// compile-flags:-C lto -C panic=abort +// no-prefer-dynamic +// ignore-cloudabi no processes +// ignore-emscripten no processes + +use std::process::Command; +use std::env; + +struct Bomb; + +impl Drop for Bomb { + fn drop(&mut self) { + std::process::exit(0); + } +} + +fn main() { + let mut args = env::args_os(); + let me = args.next().unwrap(); + + if let Some(s) = args.next() { + if &*s == "foo" { + + let _bomb = Bomb; + + panic!("try to catch me"); + } + } + let s = Command::new(env::args_os().next().unwrap()).arg("foo").status(); + assert!(s.unwrap().code() != Some(0)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panic-runtime/lto-unwind.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panic-runtime/lto-unwind.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panic-runtime/lto-unwind.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panic-runtime/lto-unwind.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] + +// compile-flags:-C lto -C panic=unwind +// no-prefer-dynamic +// ignore-cloudabi no processes +// ignore-emscripten no processes + +use std::process::Command; +use std::env; + +struct Bomb; + +impl Drop for Bomb { + fn drop(&mut self) { + println!("hurray you ran me"); + } +} + +fn main() { + let mut args = env::args_os(); + let me = args.next().unwrap(); + + if let Some(s) = args.next() { + if &*s == "foo" { + + let _bomb = Bomb; + + panic!("try to catch me"); + } + } + let s = Command::new(env::args_os().next().unwrap()).arg("foo").output(); + let s = s.unwrap(); + assert!(!s.status.success()); + assert!(String::from_utf8_lossy(&s.stdout).contains("hurray you ran me")); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panics/panic-handler-chain.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panics/panic-handler-chain.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panics/panic-handler-chain.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panics/panic-handler-chain.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(stable_features)] + +// ignore-emscripten no threads support + +#![feature(std_panic)] + +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::panic; +use std::thread; + +static A: AtomicUsize = AtomicUsize::new(0); +static B: AtomicUsize = AtomicUsize::new(0); + +fn main() { + panic::set_hook(Box::new(|_| { A.fetch_add(1, Ordering::SeqCst); })); + let hook = panic::take_hook(); + panic::set_hook(Box::new(move |info| { + B.fetch_add(1, Ordering::SeqCst); + hook(info); + })); + + let _ = thread::spawn(|| { + panic!(); + }).join(); + + assert_eq!(1, A.load(Ordering::SeqCst)); + assert_eq!(1, B.load(Ordering::SeqCst)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panics/panic-handler-flail-wildly.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panics/panic-handler-flail-wildly.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panics/panic-handler-flail-wildly.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panics/panic-handler-flail-wildly.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,63 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(stable_features)] + +// ignore-emscripten no threads support + +#![feature(std_panic)] + +use std::panic; +use std::thread; + +fn a() { + panic::set_hook(Box::new(|_| println!("hello yes this is a"))); + panic::take_hook(); + panic::set_hook(Box::new(|_| println!("hello yes this is a part 2"))); + panic::take_hook(); +} + +fn b() { + panic::take_hook(); + panic::take_hook(); + panic::take_hook(); + panic::take_hook(); + panic::take_hook(); + panic!(); +} + +fn c() { + panic::set_hook(Box::new(|_| ())); + panic::set_hook(Box::new(|_| ())); + panic::set_hook(Box::new(|_| ())); + panic::set_hook(Box::new(|_| ())); + panic::set_hook(Box::new(|_| ())); + panic::set_hook(Box::new(|_| ())); + panic!(); +} + +fn main() { + for _ in 0..10 { + let mut handles = vec![]; + for _ in 0..10 { + handles.push(thread::spawn(a)); + } + for _ in 0..10 { + handles.push(thread::spawn(b)); + } + for _ in 0..10 { + handles.push(thread::spawn(c)); + } + for handle in handles { + let _ = handle.join(); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panics/panic-handler-set-twice.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panics/panic-handler-set-twice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panics/panic-handler-set-twice.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panics/panic-handler-set-twice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +#![allow(stable_features)] + +#![feature(std_panic)] + +// ignore-emscripten no threads support + +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::panic; +use std::thread; + +static A: AtomicUsize = AtomicUsize::new(0); + +fn main() { + panic::set_hook(Box::new(|_| ())); + panic::set_hook(Box::new(|info| { A.fetch_add(1, Ordering::SeqCst); })); + + let _ = thread::spawn(|| { + panic!(); + }).join(); + + assert_eq!(1, A.load(Ordering::SeqCst)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panics/panic-in-dtor-drops-fields.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panics/panic-in-dtor-drops-fields.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panics/panic-in-dtor-drops-fields.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panics/panic-in-dtor-drops-fields.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_upper_case_globals)] + +// ignore-emscripten no threads support + +use std::thread; + +static mut dropped: bool = false; + +struct A { + b: B, +} + +struct B { + foo: isize, +} + +impl Drop for A { + fn drop(&mut self) { + panic!() + } +} + +impl Drop for B { + fn drop(&mut self) { + unsafe { dropped = true; } + } +} + +pub fn main() { + let ret = thread::spawn(move|| { + let _a = A { b: B { foo: 3 } }; + }).join(); + assert!(ret.is_err()); + unsafe { assert!(dropped); } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panics/panic-recover-propagate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panics/panic-recover-propagate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panics/panic-recover-propagate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panics/panic-recover-propagate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten no threads support + +use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; +use std::panic; +use std::thread; + +static A: AtomicUsize = ATOMIC_USIZE_INIT; + +fn main() { + panic::set_hook(Box::new(|_| { + A.fetch_add(1, Ordering::SeqCst); + })); + + let result = thread::spawn(|| { + let result = panic::catch_unwind(|| { + panic!("hi there"); + }); + + panic::resume_unwind(result.unwrap_err()); + }).join(); + + let msg = *result.unwrap_err().downcast::<&'static str>().unwrap(); + assert_eq!("hi there", msg); + assert_eq!(1, A.load(Ordering::SeqCst)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panics/panic-safe.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panics/panic-safe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panics/panic-safe.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panics/panic-safe.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,61 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +use std::panic::{UnwindSafe, AssertUnwindSafe}; +use std::cell::RefCell; +use std::sync::{Mutex, RwLock, Arc}; +use std::rc::Rc; + +struct Foo { a: i32 } + +fn assert() {} + +fn main() { + assert::(); + assert::<&i32>(); + assert::<*mut i32>(); + assert::<*const i32>(); + assert::(); + assert::(); + assert::<&str>(); + assert::(); + assert::<&Foo>(); + assert::>(); + assert::(); + assert::>(); + assert::>(); + assert::>(); + assert::>(); + assert::<&Mutex>(); + assert::<&RwLock>(); + assert::>(); + assert::>(); + assert::>(); + + trait Trait: UnwindSafe {} + assert::>(); + + fn bar() { + assert::>(); + assert::>(); + } + fn baz() { + assert::>(); + assert::>(); + assert::>(); + assert::>(); + assert::<&AssertUnwindSafe>(); + assert::>>(); + assert::>>(); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panic-uninitialized-zeroed.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panic-uninitialized-zeroed.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/panic-uninitialized-zeroed.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/panic-uninitialized-zeroed.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,83 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-wasm32-bare always compiled as panic=abort right now and this requires unwinding +// This test checks that instantiating an uninhabited type via `mem::{uninitialized,zeroed}` results +// in a runtime panic. + +#![feature(never_type)] + +use std::{mem, panic}; + +#[allow(dead_code)] +struct Foo { + x: u8, + y: !, +} + +enum Bar {} + +fn main() { + unsafe { + assert_eq!( + panic::catch_unwind(|| { + mem::uninitialized::() + }).err().and_then(|a| a.downcast_ref::().map(|s| { + s == "Attempted to instantiate uninhabited type ! using mem::uninitialized" + })), + Some(true) + ); + + assert_eq!( + panic::catch_unwind(|| { + mem::zeroed::() + }).err().and_then(|a| a.downcast_ref::().map(|s| { + s == "Attempted to instantiate uninhabited type ! using mem::zeroed" + })), + Some(true) + ); + + assert_eq!( + panic::catch_unwind(|| { + mem::uninitialized::() + }).err().and_then(|a| a.downcast_ref::().map(|s| { + s == "Attempted to instantiate uninhabited type Foo using mem::uninitialized" + })), + Some(true) + ); + + assert_eq!( + panic::catch_unwind(|| { + mem::zeroed::() + }).err().and_then(|a| a.downcast_ref::().map(|s| { + s == "Attempted to instantiate uninhabited type Foo using mem::zeroed" + })), + Some(true) + ); + + assert_eq!( + panic::catch_unwind(|| { + mem::uninitialized::() + }).err().and_then(|a| a.downcast_ref::().map(|s| { + s == "Attempted to instantiate uninhabited type Bar using mem::uninitialized" + })), + Some(true) + ); + + assert_eq!( + panic::catch_unwind(|| { + mem::zeroed::() + }).err().and_then(|a| a.downcast_ref::().map(|s| { + s == "Attempted to instantiate uninhabited type Bar using mem::zeroed" + })), + Some(true) + ); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/parse-panic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/parse-panic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/parse-panic.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/parse-panic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] #![allow(unreachable_code)] fn dont_call_me() { panic!(); println!("{}", 1); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/paths-containing-nul.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/paths-containing-nul.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/paths-containing-nul.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/paths-containing-nul.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(deprecated)] // ignore-cloudabi no files or I/O // ignore-wasm32-bare no files or I/O diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/auxiliary/privacy_reexport.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/auxiliary/privacy_reexport.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/auxiliary/privacy_reexport.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/auxiliary/privacy_reexport.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub extern crate core; +pub use foo as bar; + +pub mod foo { + pub fn frob() {} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/auxiliary/priv-impl-prim-ty.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/auxiliary/priv-impl-prim-ty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/auxiliary/priv-impl-prim-ty.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/auxiliary/priv-impl-prim-ty.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait A { + fn frob(&self); +} + +impl A for isize { fn frob(&self) {} } + +pub fn frob(t: T) { + t.frob(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/auxiliary/pub_use_mods_xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/auxiliary/pub_use_mods_xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/auxiliary/pub_use_mods_xcrate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/auxiliary/pub_use_mods_xcrate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod a { + pub use a::b::c; + + pub mod b { + pub mod c { + fn f(){} + fn g(){} + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/auxiliary/pub_use_xcrate1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/auxiliary/pub_use_xcrate1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/auxiliary/pub_use_xcrate1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/auxiliary/pub_use_xcrate1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Foo { + pub name: isize +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/auxiliary/pub_use_xcrate2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/auxiliary/pub_use_xcrate2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/auxiliary/pub_use_xcrate2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/auxiliary/pub_use_xcrate2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate pub_use_xcrate1; + +pub use pub_use_xcrate1::Foo; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/privacy1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/privacy1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/privacy1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/privacy1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +pub mod test2 { + // This used to generate an ICE (make sure that default functions are + // parented to their trait to find the first private thing as the trait). + + struct B; + trait A { fn foo(&self) {} } + impl A for B {} + + mod tests { + use super::A; + fn foo() { + let a = super::B; + a.foo(); + } + } +} + + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/privacy-ns.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/privacy-ns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/privacy-ns.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/privacy-ns.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,124 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_snake_case)] + + +// Check we do the correct privacy checks when we import a name and there is an +// item with that name in both the value and type namespaces. + +// pretty-expanded FIXME #23616 + +#![allow(dead_code)] +#![allow(unused_imports)] + + +// public type, private value +pub mod foo1 { + pub trait Bar { + fn dummy(&self) { } + } + pub struct Baz; + + fn Bar() { } +} + +fn test_unused1() { + use foo1::*; +} + +fn test_single1() { + use foo1::Bar; + + let _x: Box; +} + +fn test_list1() { + use foo1::{Bar,Baz}; + + let _x: Box; +} + +fn test_glob1() { + use foo1::*; + + let _x: Box; +} + +// private type, public value +pub mod foo2 { + trait Bar { + fn dummy(&self) { } + } + pub struct Baz; + + pub fn Bar() { } +} + +fn test_unused2() { + use foo2::*; +} + +fn test_single2() { + use foo2::Bar; + + Bar(); +} + +fn test_list2() { + use foo2::{Bar,Baz}; + + Bar(); +} + +fn test_glob2() { + use foo2::*; + + Bar(); +} + +// public type, public value +pub mod foo3 { + pub trait Bar { + fn dummy(&self) { } + } + pub struct Baz; + + pub fn Bar() { } +} + +fn test_unused3() { + use foo3::*; +} + +fn test_single3() { + use foo3::Bar; + + Bar(); + let _x: Box; +} + +fn test_list3() { + use foo3::{Bar,Baz}; + + Bar(); + let _x: Box; +} + +fn test_glob3() { + use foo3::*; + + Bar(); + let _x: Box; +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/privacy-reexport.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/privacy-reexport.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/privacy-reexport.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/privacy-reexport.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:privacy_reexport.rs + +// pretty-expanded FIXME #23616 + +extern crate privacy_reexport; + +pub fn main() { + // Check that public extern crates are visible to outside crates + privacy_reexport::core::cell::Cell::new(0); + + privacy_reexport::bar::frob(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/private-class-field.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/private-class-field.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/private-class-field.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/private-class-field.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + + +struct cat { + meows : usize, + + how_hungry : isize, +} + +impl cat { + pub fn meow_count(&mut self) -> usize { self.meows } +} + +fn cat(in_x : usize, in_y : isize) -> cat { + cat { + meows: in_x, + how_hungry: in_y + } +} + +pub fn main() { + let mut nyan : cat = cat(52, 99); + assert_eq!(nyan.meow_count(), 52); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/private-method.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/private-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/private-method.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/private-method.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +struct cat { + meows : usize, + + how_hungry : isize, +} + +impl cat { + pub fn play(&mut self) { + self.meows += 1_usize; + self.nap(); + } +} + +impl cat { + fn nap(&mut self) { for _ in 1_usize..10_usize { } } +} + +fn cat(in_x : usize, in_y : isize) -> cat { + cat { + meows: in_x, + how_hungry: in_y + } +} + +pub fn main() { + let mut nyan : cat = cat(52_usize, 99); + nyan.play(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/priv-impl-prim-ty.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/priv-impl-prim-ty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/priv-impl-prim-ty.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/priv-impl-prim-ty.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:priv-impl-prim-ty.rs + +// pretty-expanded FIXME #23616 + +extern crate priv_impl_prim_ty as bar; + +pub fn main() { + bar::frob(1); + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/pub-extern-privacy.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/pub-extern-privacy.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/pub-extern-privacy.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/pub-extern-privacy.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-wasm32-bare no libc to test ffi with + +// pretty-expanded FIXME #23616 + +use std::mem::transmute; + +mod a { + extern { + pub fn free(x: *const u8); + } +} + +pub fn main() { + unsafe { + a::free(transmute(0_usize)); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/pub_use_mods_xcrate_exe.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/pub_use_mods_xcrate_exe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/pub_use_mods_xcrate_exe.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/pub_use_mods_xcrate_exe.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:pub_use_mods_xcrate.rs + +// pretty-expanded FIXME #23616 + +#![allow(unused_imports)] + +extern crate pub_use_mods_xcrate; +use pub_use_mods_xcrate::a::c; + +pub fn main(){} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/pub-use-xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/pub-use-xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/privacy/pub-use-xcrate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/privacy/pub-use-xcrate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:pub_use_xcrate1.rs +// aux-build:pub_use_xcrate2.rs + +// pretty-expanded FIXME #23616 + +extern crate pub_use_xcrate2; + +use pub_use_xcrate2::Foo; + +pub fn main() { + let _foo: Foo = Foo { + name: 0 + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/process/process-envs.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/process/process-envs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/process/process-envs.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/process/process-envs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,62 @@ +// Copyright 2014, 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-cloudabi no processes +// ignore-emscripten no processes + +use std::process::Command; +use std::env; +use std::collections::HashMap; + +#[cfg(all(unix, not(target_os="android")))] +pub fn env_cmd() -> Command { + Command::new("env") +} +#[cfg(target_os="android")] +pub fn env_cmd() -> Command { + let mut cmd = Command::new("/system/bin/sh"); + cmd.arg("-c").arg("set"); + cmd +} + +#[cfg(windows)] +pub fn env_cmd() -> Command { + let mut cmd = Command::new("cmd"); + cmd.arg("/c").arg("set"); + cmd +} + +fn main() { + // save original environment + let old_env = env::var_os("RUN_TEST_NEW_ENV"); + + env::set_var("RUN_TEST_NEW_ENV", "123"); + + // create filtered environment vector + let filtered_env : HashMap = + env::vars().filter(|&(ref k, _)| k == "PATH").collect(); + + let mut cmd = env_cmd(); + cmd.env_clear(); + cmd.envs(&filtered_env); + + // restore original environment + match old_env { + None => env::remove_var("RUN_TEST_NEW_ENV"), + Some(val) => env::set_var("RUN_TEST_NEW_ENV", &val) + } + + let result = cmd.output().unwrap(); + let output = String::from_utf8_lossy(&result.stdout); + + assert!(!output.contains("RUN_TEST_NEW_ENV"), + "found RUN_TEST_NEW_ENV inside of:\n\n{}", output); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/process/process-exit.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/process/process-exit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/process/process-exit.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/process/process-exit.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +// ignore-cloudabi no processes +// ignore-emscripten no processes + +use std::env; +use std::process::{self, Command, Stdio}; + +fn main() { + let args: Vec = env::args().collect(); + if args.len() > 1 && args[1] == "child" { + child(); + } else { + parent(); + } +} + +fn parent() { + let args: Vec = env::args().collect(); + let status = Command::new(&args[0]).arg("child").status().unwrap(); + assert_eq!(status.code(), Some(2)); +} + +fn child() -> i32 { + process::exit(2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/process/process-remove-from-env.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/process/process-remove-from-env.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/process/process-remove-from-env.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/process/process-remove-from-env.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,56 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-cloudabi no processes +// ignore-emscripten no processes + +use std::process::Command; +use std::env; + +#[cfg(all(unix, not(target_os="android")))] +pub fn env_cmd() -> Command { + Command::new("env") +} +#[cfg(target_os="android")] +pub fn env_cmd() -> Command { + let mut cmd = Command::new("/system/bin/sh"); + cmd.arg("-c").arg("set"); + cmd +} + +#[cfg(windows)] +pub fn env_cmd() -> Command { + let mut cmd = Command::new("cmd"); + cmd.arg("/c").arg("set"); + cmd +} + +fn main() { + // save original environment + let old_env = env::var_os("RUN_TEST_NEW_ENV"); + + env::set_var("RUN_TEST_NEW_ENV", "123"); + + let mut cmd = env_cmd(); + cmd.env_remove("RUN_TEST_NEW_ENV"); + + // restore original environment + match old_env { + None => env::remove_var("RUN_TEST_NEW_ENV"), + Some(val) => env::set_var("RUN_TEST_NEW_ENV", &val) + } + + let result = cmd.output().unwrap(); + let output = String::from_utf8_lossy(&result.stdout); + + assert!(!output.contains("RUN_TEST_NEW_ENV"), + "found RUN_TEST_NEW_ENV inside of:\n\n{}", output); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/process/process-sigpipe.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/process/process-sigpipe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/process/process-sigpipe.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/process/process-sigpipe.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +#![allow(deprecated)] + +// ignore-android since the dynamic linker sets a SIGPIPE handler (to do +// a crash report) so inheritance is moot on the entire platform + +// libstd ignores SIGPIPE, and other libraries may set signal masks. +// Make sure that these behaviors don't get inherited to children +// spawned via std::process, since they're needed for traditional UNIX +// filter behavior. This test checks that `yes | head` terminates +// (instead of running forever), and that it does not print an error +// message about a broken pipe. + +// ignore-cloudabi no subprocesses support +// ignore-emscripten no threads support + +use std::process; +use std::thread; + +#[cfg(unix)] +fn main() { + // Just in case `yes` doesn't check for EPIPE... + thread::spawn(|| { + thread::sleep_ms(5000); + process::exit(1); + }); + let output = process::Command::new("sh").arg("-c").arg("yes | head").output().unwrap(); + assert!(output.status.success()); + assert!(output.stderr.len() == 0); +} + +#[cfg(not(unix))] +fn main() { + // Not worried about signal masks on other platforms +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/process/process-spawn-nonexistent.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/process/process-spawn-nonexistent.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/process/process-spawn-nonexistent.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/process/process-spawn-nonexistent.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-cloudabi no processes +// ignore-emscripten no processes + +use std::io::ErrorKind; +use std::process::Command; + +fn main() { + assert_eq!(Command::new("nonexistent") + .spawn() + .unwrap_err() + .kind(), + ErrorKind::NotFound); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/process/process-spawn-with-unicode-params.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/process/process-spawn-with-unicode-params.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/process/process-spawn-with-unicode-params.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/process/process-spawn-with-unicode-params.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,86 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// no-prefer-dynamic + +// The test copies itself into a subdirectory with a non-ASCII name and then +// runs it as a child process within the subdirectory. The parent process +// also adds an environment variable and an argument, both containing +// non-ASCII characters. The child process ensures all the strings are +// intact. + +// ignore-cloudabi no processes +// ignore-emscripten no processes + +use std::io::prelude::*; +use std::io; +use std::fs; +use std::process::Command; +use std::env; +use std::path::Path; + +fn main() { + let my_args = env::args().collect::>(); + let my_cwd = env::current_dir().unwrap(); + let my_env = env::vars().collect::>(); + let my_path = env::current_exe().unwrap(); + let my_dir = my_path.parent().unwrap(); + let my_ext = my_path.extension().and_then(|s| s.to_str()).unwrap_or(""); + + // some non-ASCII characters + let blah = "\u{3c0}\u{42f}\u{97f3}\u{e6}\u{221e}"; + + let child_name = "child"; + let child_dir = format!("process-spawn-with-unicode-params-{}", blah); + + // parameters sent to child / expected to be received from parent + let arg = blah; + let cwd = my_dir.join(&child_dir); + let env = ("RUST_TEST_PROC_SPAWN_UNICODE".to_string(), blah.to_string()); + + // am I the parent or the child? + if my_args.len() == 1 { // parent + + let child_filestem = Path::new(child_name); + let child_filename = child_filestem.with_extension(my_ext); + let child_path = cwd.join(&child_filename); + + // make a separate directory for the child + let _ = fs::create_dir(&cwd); + fs::copy(&my_path, &child_path).unwrap(); + + // run child + let p = Command::new(&child_path) + .arg(arg) + .current_dir(&cwd) + .env(&env.0, &env.1) + .spawn().unwrap().wait_with_output().unwrap(); + + // display the output + io::stdout().write_all(&p.stdout).unwrap(); + io::stderr().write_all(&p.stderr).unwrap(); + + // make sure the child succeeded + assert!(p.status.success()); + + } else { // child + + // check working directory (don't try to compare with `cwd` here!) + assert!(my_cwd.ends_with(&child_dir)); + + // check arguments + assert_eq!(&*my_args[1], arg); + + // check environment variable + assert!(my_env.contains(&env)); + + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/process/process-status-inherits-stdin.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/process/process-status-inherits-stdin.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/process/process-status-inherits-stdin.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/process/process-status-inherits-stdin.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-cloudabi no processes +// ignore-emscripten no processes + +use std::env; +use std::io; +use std::io::Write; +use std::process::{Command, Stdio}; + +fn main() { + let mut args = env::args(); + let me = args.next().unwrap(); + let arg = args.next(); + match arg.as_ref().map(|s| &s[..]) { + None => { + let mut s = Command::new(&me) + .arg("a1") + .stdin(Stdio::piped()) + .spawn() + .unwrap(); + s.stdin.take().unwrap().write_all(b"foo\n").unwrap(); + let s = s.wait().unwrap(); + assert!(s.success()); + } + Some("a1") => { + let s = Command::new(&me).arg("a2").status().unwrap(); + assert!(s.success()); + } + Some(..) => { + let mut s = String::new(); + io::stdin().read_line(&mut s).unwrap(); + assert_eq!(s, "foo\n"); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/project-cache-issue-37154.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/project-cache-issue-37154.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/project-cache-issue-37154.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/project-cache-issue-37154.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,9 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // Regression test for #37154: the problem here was that the cache -// results in a false error because it was caching skolemized results -// even after those skolemized regions had been popped. +// results in a false error because it was caching placeholder results +// even after those placeholder regions had been popped. trait Foo { fn method(&self) {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/project-defer-unification.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/project-defer-unification.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/project-defer-unification.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/project-defer-unification.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(unreachable_code)] // A regression test extracted from image-0.3.11. The point of // failure was in `index_colors` below. @@ -92,6 +95,10 @@ -> ImageBuffer, Vec> where Pix: Pixel + 'static, { + // When NLL-enabled, `let mut` below is deemed unnecessary (due to + // the remaining code being unreachable); so ignore that lint. + #![allow(unused_mut)] + let mut indices: ImageBuffer<_,Vec<_>> = loop { }; for (pixel, idx) in image.pixels().zip(indices.pixels_mut()) { // failured occurred here ^^ because we were requiring that we diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ptr-coercion.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ptr-coercion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ptr-coercion.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ptr-coercion.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_variables)] // Test coercions between pointers which don't do anything fancy like unsizing. // pretty-expanded FIXME #23616 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/pure-sum.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/pure-sum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/pure-sum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/pure-sum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // Check that functions can modify local state. // pretty-expanded FIXME #23616 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/range_inclusive_gate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/range_inclusive_gate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/range_inclusive_gate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/range_inclusive_gate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_comparisons)] // Test that you only need the syntax gate if you don't mention the structs. // (Obsoleted since both features are stabilized) diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/range.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/range.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/range.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/range.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_comparisons)] +#![allow(dead_code)] +#![allow(unused_mut)] // Test range syntax. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/range-type-infer.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/range-type-infer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/range-type-infer.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/range-type-infer.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_must_use)] // Make sure the type inference for the new range expression work as // good as the old one. Check out issue #21672, #21595 and #21649 for // more details. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rcvr-borrowed-to-region.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rcvr-borrowed-to-region.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rcvr-borrowed-to-region.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rcvr-borrowed-to-region.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] #![feature(box_syntax)] trait get { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/readalias.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/readalias.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/readalias.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/readalias.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-addr-of-interior-of-unique-box.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-addr-of-interior-of-unique-box.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-addr-of-interior-of-unique-box.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-addr-of-interior-of-unique-box.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +// pretty-expanded FIXME #23616 + +struct Point { + x: isize, + y: isize +} + +struct Character { + pos: Box, +} + +fn get_x(x: &Character) -> &isize { + // interesting case because the scope of this + // borrow of the unique pointer is in fact + // larger than the fn itself + return &x.pos.x; +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-addr-of-ret.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-addr-of-ret.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-addr-of-ret.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-addr-of-ret.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn f(x: &isize) -> &isize { + return &*x; +} + +pub fn main() { + let three = &3; + println!("{}", *f(three)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-assoc-type-region-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-assoc-type-region-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-assoc-type-region-bound.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-assoc-type-region-bound.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Test that the compiler considers the 'a bound declared in the +// trait. Issue #20890. + +// pretty-expanded FIXME #23616 + +trait Foo<'a> { + type Value: 'a; + + fn get(&self) -> &'a Self::Value; +} + +fn takes_foo<'a,F: Foo<'a>>(f: &'a F) { + // This call would be illegal, because it results in &'a F::Value, + // and the only way we know that `F::Value : 'a` is because of the + // trait declaration. + + f.get(); +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-assoc-type-static-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-assoc-type-static-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-assoc-type-static-bound.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-assoc-type-static-bound.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Test that the compiler considers the 'static bound declared in the +// trait. Issue #20890. + +// pretty-expanded FIXME #23616 + +trait Foo { + type Value: 'static; + fn dummy(&self) { } +} + +fn require_static() {} + +fn takes_foo() { + require_static::() +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-borrow-at.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-borrow-at.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-borrow-at.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-borrow-at.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +fn foo(x: &usize) -> usize { + *x +} + +pub fn main() { + let p: Box<_> = box 22; + let r = foo(&*p); + println!("r={}", r); + assert_eq!(r, 22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-borrow-evec-fixed.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-borrow-evec-fixed.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-borrow-evec-fixed.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-borrow-evec-fixed.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn foo(x: &[isize]) -> isize { + x[0] +} + +pub fn main() { + let p = &[1,2,3,4,5]; + assert_eq!(foo(p), 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-borrow-evec-uniq.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-borrow-evec-uniq.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-borrow-evec-uniq.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-borrow-evec-uniq.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +fn foo(x: &[isize]) -> isize { + x[0] +} + +pub fn main() { + let p = vec![1,2,3,4,5]; + let r = foo(&p); + assert_eq!(r, 1); + + let p = vec![5,4,3,2,1]; + let r = foo(&p); + assert_eq!(r, 5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-borrow-uniq.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-borrow-uniq.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-borrow-uniq.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-borrow-uniq.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +fn foo(x: &usize) -> usize { + *x +} + +pub fn main() { + let p: Box<_> = box 3; + let r = foo(&*p); + assert_eq!(r, 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-bot.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-bot.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-bot.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-bot.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// A very limited test of the "bottom" region + + +fn produce_static() -> &'static T { panic!(); } + +fn foo(_x: &T) -> &usize { produce_static() } + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-bound-lists-feature-gate-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-bound-lists-feature-gate-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-bound-lists-feature-gate-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-bound-lists-feature-gate-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(stable_features)] + +#![feature(issue_5723_bootstrap)] + +trait Foo { + fn dummy(&self) { } +} + +fn foo<'a, 'b, 'c:'a+'b, 'd>() { +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-bound-lists-feature-gate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-bound-lists-feature-gate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-bound-lists-feature-gate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-bound-lists-feature-gate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(stable_features)] + +#![feature(issue_5723_bootstrap)] + +trait Foo { + fn dummy(&self) { } +} + +fn foo<'a>(x: Box) { +} + +fn bar<'a, T: 'a>() { +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-close-over-type-parameter-successfully.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-close-over-type-parameter-successfully.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-close-over-type-parameter-successfully.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-close-over-type-parameter-successfully.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// A test where we (successfully) close over a reference into +// an object. + +#![feature(box_syntax)] + +trait SomeTrait { fn get(&self) -> isize; } + +impl<'a> SomeTrait for &'a isize { + fn get(&self) -> isize { + **self + } +} + +fn make_object<'a,A:SomeTrait+'a>(v: A) -> Box { + box v as Box +} + +fn main() { + let i: isize = 22; + let obj = make_object(&i); + assert_eq!(22, obj.get()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-copy-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-copy-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-copy-closure.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-copy-closure.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +struct closure_box<'a> { + cl: Box, +} + +fn box_it<'a>(x: Box) -> closure_box<'a> { + closure_box {cl: x} +} + +pub fn main() { + let mut i = 3; + assert_eq!(i, 3); + { + let cl = || i += 1; + let mut cl_box = box_it(Box::new(cl)); + (cl_box.cl)(); + } + assert_eq!(i, 4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-creating-enums2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-creating-enums2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-creating-enums2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-creating-enums2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +enum ast<'a> { + num(usize), + add(&'a ast<'a>, &'a ast<'a>) +} + +fn mk_add_ok<'r>(x: &'r ast<'r>, y: &'r ast<'r>) -> ast<'r> { + ast::add(x, y) +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-creating-enums5.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-creating-enums5.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-creating-enums5.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-creating-enums5.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +enum ast<'a> { + num(usize), + add(&'a ast<'a>, &'a ast<'a>) +} + +fn mk_add_ok<'a>(x: &'a ast<'a>, y: &'a ast<'a>, _z: &ast) -> ast<'a> { + ast::add(x, y) +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-debruijn-of-object.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-debruijn-of-object.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-debruijn-of-object.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-debruijn-of-object.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +struct ctxt<'tcx> { + x: &'tcx i32 +} + +trait AstConv<'tcx> { + fn tcx<'a>(&'a self) -> &'a ctxt<'tcx>; +} + +fn foo(conv: &AstConv) { } + +fn bar<'tcx>(conv: &AstConv<'tcx>) { + foo(conv) +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-dependent-addr-of.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-dependent-addr-of.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-dependent-addr-of.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-dependent-addr-of.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,123 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test lifetimes are linked properly when we create dependent region pointers. +// Issue #3148. + +#![feature(box_patterns)] +#![feature(box_syntax)] + +struct A { + value: B +} + +struct B { + v1: isize, + v2: [isize; 3], + v3: Vec , + v4: C, + v5: Box, + v6: Option +} + +#[derive(Copy, Clone)] +struct C { + f: isize +} + +fn get_v1(a: &A) -> &isize { + // Region inferencer must deduce that &v < L2 < L1 + let foo = &a.value; // L1 + &foo.v1 // L2 +} + +fn get_v2(a: &A, i: usize) -> &isize { + let foo = &a.value; + &foo.v2[i] +} + +fn get_v3(a: &A, i: usize) -> &isize { + let foo = &a.value; + &foo.v3[i] +} + +fn get_v4(a: &A, _i: usize) -> &isize { + let foo = &a.value; + &foo.v4.f +} + +fn get_v5(a: &A, _i: usize) -> &isize { + let foo = &a.value; + &foo.v5.f +} + +fn get_v6_a(a: &A, _i: usize) -> &isize { + match a.value.v6 { + Some(ref v) => &v.f, + None => panic!() + } +} + +fn get_v6_b(a: &A, _i: usize) -> &isize { + match *a { + A { value: B { v6: Some(ref v), .. } } => &v.f, + _ => panic!() + } +} + +fn get_v6_c(a: &A, _i: usize) -> &isize { + match a { + &A { value: B { v6: Some(ref v), .. } } => &v.f, + _ => panic!() + } +} + +fn get_v5_ref(a: &A, _i: usize) -> &isize { + match &a.value { + &B {v5: box C {f: ref v}, ..} => v + } +} + +pub fn main() { + let a = A {value: B {v1: 22, + v2: [23, 24, 25], + v3: vec![26, 27, 28], + v4: C { f: 29 }, + v5: box C { f: 30 }, + v6: Some(C { f: 31 })}}; + + let p = get_v1(&a); + assert_eq!(*p, a.value.v1); + + let p = get_v2(&a, 1); + assert_eq!(*p, a.value.v2[1]); + + let p = get_v3(&a, 1); + assert_eq!(*p, a.value.v3[1]); + + let p = get_v4(&a, 1); + assert_eq!(*p, a.value.v4.f); + + let p = get_v5(&a, 1); + assert_eq!(*p, a.value.v5.f); + + let p = get_v6_a(&a, 1); + assert_eq!(*p, a.value.v6.unwrap().f); + + let p = get_v6_b(&a, 1); + assert_eq!(*p, a.value.v6.unwrap().f); + + let p = get_v6_c(&a, 1); + assert_eq!(*p, a.value.v6.unwrap().f); + + let p = get_v5_ref(&a, 1); + assert_eq!(*p, a.value.v5.f); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-dependent-autofn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-dependent-autofn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-dependent-autofn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-dependent-autofn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test lifetimes are linked properly when we autoslice a vector. +// Issue #3148. + +// pretty-expanded FIXME #23616 + +fn subslice(v: F) -> F where F: FnOnce() { v } + +fn both(v: F) -> F where F: FnOnce() { + subslice(subslice(v)) +} + +pub fn main() { + both(main); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-dependent-autoslice.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-dependent-autoslice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-dependent-autoslice.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-dependent-autoslice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test lifetimes are linked properly when we autoslice a vector. +// Issue #3148. + +fn subslice1<'r>(v: &'r [usize]) -> &'r [usize] { v } + +fn both<'r>(v: &'r [usize]) -> &'r [usize] { + subslice1(subslice1(v)) +} + +pub fn main() { + let v = vec![1,2,3]; + both(&v); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-dependent-let-ref.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-dependent-let-ref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-dependent-let-ref.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-dependent-let-ref.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test lifetimes are linked properly when we take reference +// to interior. + +// pretty-expanded FIXME #23616 + +struct Foo(isize); +pub fn main() { + // Here the lifetime of the `&` should be at least the + // block, since a ref binding is created to the interior. + let &Foo(ref _x) = &Foo(3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-early-bound-lifetime-in-assoc-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-early-bound-lifetime-in-assoc-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-early-bound-lifetime-in-assoc-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-early-bound-lifetime-in-assoc-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +// Test that we are able to compile calls to associated fns like +// `decode()` where the bound on the `Self` parameter references a +// lifetime parameter of the trait. This example indicates why trait +// lifetime parameters must be early bound in the type of the +// associated item. + +// pretty-expanded FIXME #23616 + +use std::marker; + +pub enum Value<'v> { + A(&'v str), + B, +} + +pub trait Decoder<'v> { + fn read(&mut self) -> Value<'v>; +} + +pub trait Decodable<'v, D: Decoder<'v>> { + fn decode(d: &mut D) -> Self; +} + +impl<'v, D: Decoder<'v>> Decodable<'v, D> for () { + fn decode(d: &mut D) -> () { + match d.read() { + Value::A(..) => (), + Value::B => Decodable::decode(d), + } + } +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-early-bound-trait-param.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-early-bound-trait-param.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-early-bound-trait-param.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-early-bound-trait-param.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,144 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests that you can use an early-bound lifetime parameter as +// on of the generic parameters in a trait. + +#![feature(box_syntax)] + +trait Trait<'a> { + fn long(&'a self) -> isize; + fn short<'b>(&'b self) -> isize; +} + +fn poly_invoke<'c, T: Trait<'c>>(x: &'c T) -> (isize, isize) { + let l = x.long(); + let s = x.short(); + (l,s) +} + +fn object_invoke1<'d>(x: &'d Trait<'d>) -> (isize, isize) { + let l = x.long(); + let s = x.short(); + (l,s) +} + +struct Struct1<'e> { + f: &'e (Trait<'e>+'e) +} + +fn field_invoke1<'f, 'g>(x: &'g Struct1<'f>) -> (isize,isize) { + let l = x.f.long(); + let s = x.f.short(); + (l,s) +} + +struct Struct2<'h, 'i:'h> { + f: &'h (Trait<'i>+'h) +} + +fn object_invoke2<'j, 'k>(x: &'k Trait<'j>) -> isize { + x.short() +} + +fn field_invoke2<'l, 'm, 'n>(x: &'n Struct2<'l,'m>) -> isize { + x.f.short() +} + +trait MakerTrait { + fn mk() -> Self; +} + +fn make_val() -> T { + MakerTrait::mk() +} + +trait RefMakerTrait<'q> { + fn mk(_: Self) -> &'q Self; +} + +fn make_ref<'r, T:RefMakerTrait<'r>>(t:T) -> &'r T { + RefMakerTrait::mk(t) +} + +impl<'s> Trait<'s> for (isize,isize) { + fn long(&'s self) -> isize { + let &(x,_) = self; + x + } + fn short<'b>(&'b self) -> isize { + let &(_,y) = self; + y + } +} + +impl<'t> MakerTrait for Box+'static> { + fn mk() -> Box+'static> { + let tup: Box<(isize, isize)> = box (4,5); + tup as Box + } +} + +enum List<'l> { + Cons(isize, &'l List<'l>), + Null +} + +impl<'l> List<'l> { + fn car<'m>(&'m self) -> isize { + match self { + &List::Cons(car, _) => car, + &List::Null => panic!(), + } + } + fn cdr<'n>(&'n self) -> &'l List<'l> { + match self { + &List::Cons(_, cdr) => cdr, + &List::Null => panic!(), + } + } +} + +impl<'t> RefMakerTrait<'t> for List<'t> { + fn mk(l:List<'t>) -> &'t List<'t> { + l.cdr() + } +} + +pub fn main() { + let t = (2,3); + let o = &t as &Trait; + let s1 = Struct1 { f: o }; + let s2 = Struct2 { f: o }; + assert_eq!(poly_invoke(&t), (2,3)); + assert_eq!(object_invoke1(&t), (2,3)); + assert_eq!(field_invoke1(&s1), (2,3)); + assert_eq!(object_invoke2(&t), 3); + assert_eq!(field_invoke2(&s2), 3); + + let m : Box = make_val(); + // assert_eq!(object_invoke1(&*m), (4,5)); + // ~~~~~~~~~~~~~~~~~~~ + // this call yields a compilation error; see compile-fail/dropck-object-cycle.rs + // for details. + assert_eq!(object_invoke2(&*m), 5); + + // The RefMakerTrait above is pretty strange (i.e. it is strange + // to consume a value of type T and return a &T). Easiest thing + // that came to my mind: consume a cell of a linked list and + // return a reference to the list it points to. + let l0 = List::Null; + let l1 = List::Cons(1, &l0); + let l2 = List::Cons(2, &l1); + let rl1 = &l1; + let r = make_ref(l2); + assert_eq!(rl1.car(), r.car()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-early-bound-used-in-bound-method.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-early-bound-used-in-bound-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-early-bound-used-in-bound-method.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-early-bound-used-in-bound-method.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests that you can use a fn lifetime parameter as part of +// the value for a type parameter in a bound. + + +trait GetRef<'a> { + fn get(&self) -> &'a isize; +} + +#[derive(Copy, Clone)] +struct Box<'a> { + t: &'a isize +} + +impl<'a> GetRef<'a> for Box<'a> { + fn get(&self) -> &'a isize { + self.t + } +} + +impl<'a> Box<'a> { + fn add<'b,G:GetRef<'b>>(&self, g2: G) -> isize { + *self.t + *g2.get() + } +} + +pub fn main() { + let b1 = Box { t: &3 }; + assert_eq!(b1.add(b1), 6); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-early-bound-used-in-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-early-bound-used-in-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-early-bound-used-in-bound.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-early-bound-used-in-bound.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests that you can use a fn lifetime parameter as part of +// the value for a type parameter in a bound. + + +trait GetRef<'a, T> { + fn get(&self) -> &'a T; +} + +#[derive(Copy, Clone)] +struct Box<'a, T:'a> { + t: &'a T +} + +impl<'a,T:Clone> GetRef<'a,T> for Box<'a,T> { + fn get(&self) -> &'a T { + self.t + } +} + +fn add<'a,G:GetRef<'a, isize>>(g1: G, g2: G) -> isize { + *g1.get() + *g2.get() +} + +pub fn main() { + let b1 = Box { t: &3 }; + assert_eq!(add(b1, b1), 6); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-early-bound-used-in-type-param.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-early-bound-used-in-type-param.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-early-bound-used-in-type-param.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-early-bound-used-in-type-param.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests that you can use a fn lifetime parameter as part of +// the value for a type parameter in a bound. + + +trait Get { + fn get(&self) -> T; +} + +#[derive(Copy, Clone)] +struct Box { + t: T +} + +impl Get for Box { + fn get(&self) -> T { + self.t.clone() + } +} + +fn add<'a,G:Get<&'a isize>>(g1: G, g2: G) -> isize { + *g1.get() + *g2.get() +} + +pub fn main() { + let b1 = Box { t: &3 }; + assert_eq!(add(b1, b1), 6); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-escape-into-other-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-escape-into-other-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-escape-into-other-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-escape-into-other-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +fn foo(x: &usize) -> &usize { x } +fn bar(x: &usize) -> usize { *x } + +pub fn main() { + let p: Box<_> = box 3; + assert_eq!(bar(foo(&*p)), 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-expl-self.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-expl-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-expl-self.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-expl-self.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Test that you can insert an explicit lifetime in explicit self. + +// pretty-expanded FIXME #23616 + +struct Foo { + f: usize +} + +impl Foo { + pub fn foo<'a>(&'a self) {} +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-fn-subtyping-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-fn-subtyping-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-fn-subtyping-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-fn-subtyping-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Issue #2263. + +// Here, `f` is a function that takes a pointer `x` and a function +// `g`, where `g` requires its argument `y` to be in the same region +// that `x` is in. +// pretty-expanded FIXME #23616 + +fn has_same_region(f: Box FnMut(&'a isize, Box)>) { + // `f` should be the type that `wants_same_region` wants, but + // right now the compiler complains that it isn't. + wants_same_region(f); +} + +fn wants_same_region(_f: Box FnMut(&'b isize, Box)>) { +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-fn-subtyping.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-fn-subtyping.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-fn-subtyping.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-fn-subtyping.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_assignments)] +// Issue #2263. + +// pretty-expanded FIXME #23616 + +#![allow(unused_variables)] + +// Should pass region checking. +fn ok(f: Box) { + // Here, g is a function that can accept a usize pointer with + // lifetime r, and f is a function that can accept a usize pointer + // with any lifetime. The assignment g = f should be OK (i.e., + // f's type should be a subtype of g's type), because f can be + // used in any context that expects g's type. But this currently + // fails. + let mut g: Box FnMut(&'r usize)> = Box::new(|x| { }); + g = f; +} + +// This version is the same as above, except that here, g's type is +// inferred. +fn ok_inferred(f: Box) { + let mut g: Box FnMut(&'r usize)> = Box::new(|_| {}); + g = f; +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-free-region-outlives-static-outlives-free-region.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-free-region-outlives-static-outlives-free-region.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-free-region-outlives-static-outlives-free-region.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-free-region-outlives-static-outlives-free-region.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Test that we recognize that if you have +// +// 'a : 'static +// +// then +// +// 'a : 'b + +fn test<'a,'b>(x: &'a i32) -> &'b i32 + where 'a: 'static +{ + x +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-borrow-scope-addr-of.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-borrow-scope-addr-of.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-borrow-scope-addr-of.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-borrow-scope-addr-of.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::mem::swap; + +pub fn main() { + let mut x = 4; + + for i in 0_usize..3 { + // ensure that the borrow in this alt + // does not interfere with the swap + // below. note that it would it you + // naively borrowed &x for the lifetime + // of the variable x, as we once did + match i { + i => { + let y = &x; + assert!(i < *y); + } + } + let mut y = 4; + swap(&mut y, &mut x); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-borrow-scope.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-borrow-scope.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-borrow-scope.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-borrow-scope.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![feature(box_syntax)] + +struct Point {x: isize, y: isize} + +fn x_coord(p: &Point) -> &isize { + return &p.x; +} + +pub fn main() { + let p: Box<_> = box Point {x: 3, y: 4}; + let xc = x_coord(&*p); + assert_eq!(*xc, 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-borrow-scope-view.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-borrow-scope-view.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-borrow-scope-view.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-borrow-scope-view.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +fn view(x: &[T]) -> &[T] {x} + +pub fn main() { + let v = vec![1, 2, 3]; + let x = view(&v); + let y = view(x); + assert!((v[0] == x[0]) && (v[0] == y[0])); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-borrow-scope-within-loop-ok.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-borrow-scope-within-loop-ok.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-borrow-scope-within-loop-ok.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-borrow-scope-within-loop-ok.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +fn borrow(x: &T) -> &T {x} + +pub fn main() { + let x: Box<_> = box 3; + loop { + let y = borrow(&*x); + assert_eq!(*x, *y); + break; + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-call-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-call-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-call-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-call-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn takes_two(x: &isize, y: &isize) -> isize { *x + *y } + +fn with(f: F) -> T where F: FnOnce(&isize) -> T { + f(&20) +} + +fn has_one<'a>(x: &'a isize) -> isize { + with(|y| takes_two(x, y)) +} + +pub fn main() { + assert_eq!(has_one(&2), 22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-call.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-call.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-call.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-call.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn takes_two(x: &isize, y: &isize) -> isize { *x + *y } + +fn has_two<'a,'b>(x: &'a isize, y: &'b isize) -> isize { + takes_two(x, y) +} + +pub fn main() { + assert_eq!(has_two(&20, &2), 22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-contravariance-due-to-ret.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-contravariance-due-to-ret.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-contravariance-due-to-ret.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-contravariance-due-to-ret.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + + +struct boxed_int<'a> { + f: &'a isize, +} + +fn max<'r>(bi: &'r boxed_int, f: &'r isize) -> isize { + if *bi.f > *f {*bi.f} else {*f} +} + +fn with(bi: &boxed_int) -> isize { + let i = 22; + max(bi, &i) +} + +pub fn main() { + let g = 21; + let foo = boxed_int { f: &g }; + assert_eq!(with(&foo), 22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-reborrow-ref-mut-recurse.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-reborrow-ref-mut-recurse.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-reborrow-ref-mut-recurse.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-reborrow-ref-mut-recurse.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Test an edge case in region inference: the lifetime of the borrow +// of `*x` must be extended to at least 'a. + +// pretty-expanded FIXME #23616 + +fn foo<'a,'b>(x: &'a &'b mut isize) -> &'a isize { + let y = &*x; // should be inferred to have type &'a &'b mut isize... + + // ...because if we inferred, say, &'x &'b mut isize where 'x <= 'a, + // this reborrow would be illegal: + &**y +} + +pub fn main() { + /* Just want to know that it compiles. */ +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-region-in-fn-but-not-type.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-region-in-fn-but-not-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-region-in-fn-but-not-type.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-region-in-fn-but-not-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(non_camel_case_types)] + + +// check that the &isize here does not cause us to think that `foo` +// contains region pointers +// pretty-expanded FIXME #23616 + +struct foo(Box); + +fn take_foo(x: T) {} + +fn have_foo(f: foo) { + take_foo(f); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-static-from-proc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-static-from-proc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-static-from-proc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-infer-static-from-proc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_upper_case_globals)] + +// Check that the 'static bound on a proc influences lifetimes of +// region variables contained within (otherwise, region inference will +// give `x` a very short lifetime). + +// pretty-expanded FIXME #23616 + +static i: usize = 3; +fn foo(_: F) {} +fn read(_: usize) { } +pub fn main() { + let x = &i; + foo(move|| { + read(*x); + }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-issue-21422.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-issue-21422.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-issue-21422.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-issue-21422.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Regression test for issue #21422, which was related to failing to +// add inference constraints that the operands of a binary operator +// should outlive the binary operation itself. + +// pretty-expanded FIXME #23616 + +pub struct P<'a> { + _ptr: *const &'a u8, +} + +impl <'a> PartialEq for P<'a> { + fn eq(&self, other: &P<'a>) -> bool { + (self as *const _) == (other as *const _) + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-issue-22246.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-issue-22246.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-issue-22246.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-issue-22246.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +// Regression test for issue #22246 -- we should be able to deduce +// that `&'a B::Owned` implies that `B::Owned : 'a`. + +// pretty-expanded FIXME #23616 + +#![allow(dead_code)] + +use std::ops::Deref; + +pub trait ToOwned: Sized { + type Owned: Borrow; + fn to_owned(&self) -> Self::Owned; +} + +pub trait Borrow { + fn borrow(&self) -> &Borrowed; +} + +pub struct Foo { + owned: B::Owned +} + +fn foo(this: &Foo) -> &B { + this.owned.borrow() +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-lifetime-nonfree-late-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-lifetime-nonfree-late-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-lifetime-nonfree-late-bound.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-lifetime-nonfree-late-bound.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// This is a regression test for the ICE from issue #10846. +// +// The original issue causing the ICE: the LUB-computations during +// type inference were encountering late-bound lifetimes, and +// asserting that such lifetimes should have already been substituted +// with a concrete lifetime. +// +// However, those encounters were occurring within the lexical scope +// of the binding for the late-bound lifetime; that is, the late-bound +// lifetimes were perfectly valid. The core problem was that the type +// folding code was over-zealously passing back all lifetimes when +// doing region-folding, when really all clients of the region-folding +// case only want to see FREE lifetime variables, not bound ones. + +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + +pub fn main() { + fn explicit() { + fn test(_x: Option>) where F: FnMut(Box FnMut(&'a isize)>) {} + test(Some(box |_f: Box FnMut(&'a isize)>| {})); + } + + // The code below is shorthand for the code above (and more likely + // to represent what one encounters in practice). + fn implicit() { + fn test(_x: Option>) where F: FnMut(Box< FnMut(& isize)>) {} + test(Some(box |_f: Box< FnMut(& isize)>| {})); + } + + explicit(); + implicit(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-lifetime-static-items-enclosing-scopes.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-lifetime-static-items-enclosing-scopes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-lifetime-static-items-enclosing-scopes.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-lifetime-static-items-enclosing-scopes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// This test verifies that temporary lifetime is correctly computed +// for static objects in enclosing scopes. + + +use std::cmp::PartialEq; + +fn f(o: &mut Option) { + assert_eq!(*o, None); +} + +pub fn main() { + mod t { + enum E {V=1, A=0} + static C: E = E::V; + } + + f::(&mut None); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-link-fn-args.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-link-fn-args.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-link-fn-args.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-link-fn-args.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that region inference correctly links up the regions when a +// `ref` borrow occurs inside a fn argument. + +// pretty-expanded FIXME #23616 + +#![allow(dead_code)] + +fn with<'a, F>(_: F) where F: FnOnce(&'a Vec) -> &'a Vec { } + +fn foo() { + with(|&ref ints| ints); +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-lub-ref-ref-rc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-lub-ref-ref-rc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-lub-ref-ref-rc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-lub-ref-ref-rc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Test a corner case of LUB coercion. In this case, one arm of the +// match requires a deref coercion and the other doesn't, and there +// is an extra `&` on the `rc`. We want to be sure that the lifetime +// assigned to this `&rc` value is not `'a` but something smaller. In +// other words, the type from `rc` is `&'a Rc` and the type +// from `&rc` should be `&'x &'a Rc`, where `'x` is something +// small. + +use std::rc::Rc; + +#[derive(Clone)] +enum CachedMir<'mir> { + Ref(&'mir String), + Owned(Rc), +} + +impl<'mir> CachedMir<'mir> { + fn get_ref<'a>(&'a self) -> &'a String { + match *self { + CachedMir::Ref(r) => r, + CachedMir::Owned(ref rc) => &rc, + } + } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-mock-codegen.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-mock-codegen.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-mock-codegen.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-mock-codegen.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,66 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +#![feature(allocator_api)] + +use std::alloc::{Alloc, Global, Layout, handle_alloc_error}; +use std::ptr::NonNull; + +struct arena(()); + +struct Bcx<'a> { + fcx: &'a Fcx<'a> +} + +struct Fcx<'a> { + arena: &'a arena, + ccx: &'a Ccx +} + +struct Ccx { + x: isize +} + +fn alloc<'a>(_bcx : &'a arena) -> &'a Bcx<'a> { + unsafe { + let layout = Layout::new::(); + let ptr = Global.alloc(layout).unwrap_or_else(|_| handle_alloc_error(layout)); + &*(ptr.as_ptr() as *const _) + } +} + +fn h<'a>(bcx : &'a Bcx<'a>) -> &'a Bcx<'a> { + return alloc(bcx.fcx.arena); +} + +fn g(fcx : &Fcx) { + let bcx = Bcx { fcx: fcx }; + let bcx2 = h(&bcx); + unsafe { + Global.dealloc(NonNull::new_unchecked(bcx2 as *const _ as *mut _), Layout::new::()); + } +} + +fn f(ccx : &Ccx) { + let a = arena(()); + let fcx = Fcx { arena: &a, ccx: ccx }; + return g(&fcx); +} + +pub fn main() { + let ccx = Ccx { x: 0 }; + f(&ccx); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-no-bound-in-argument-cleanup.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-no-bound-in-argument-cleanup.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-no-bound-in-argument-cleanup.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-no-bound-in-argument-cleanup.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +use std::marker; + +pub struct Foo(marker::PhantomData); + +impl Iterator for Foo { + type Item = T; + + fn next(&mut self) -> Option { + None + } +} + +impl Drop for Foo { + fn drop(&mut self) { + self.next(); + } +} + +pub fn foo<'a>(_: Foo<&'a ()>) {} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-no-variance-from-fn-generics.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-no-variance-from-fn-generics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-no-variance-from-fn-generics.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-no-variance-from-fn-generics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,54 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// Issue #12856: a lifetime formal binding introduced by a generic fn +// should not upset the variance inference for actual occurrences of +// that lifetime in type expressions. + + +pub trait HasLife<'a> { + fn dummy(&'a self) { } // just to induce a variance on 'a +} + +trait UseLife01 { + fn refs<'a, H: HasLife<'a>>(&'a self) -> H; +} + +trait UseLife02 { + fn refs<'a, T: 'a, H: HasType<&'a T>>(&'a self) -> H; +} + + +pub trait HasType +{ + fn dummy(&self, t: T) -> T { panic!() } +} + + +trait UseLife03 { + fn refs<'a, H: HasType<&'a T>>(&'a self) -> H where T: 'a; +} + + +// (The functions below were not actually a problem observed during +// fixing of #12856; they just seem like natural tests to put in to +// cover a couple more points in the testing space) + +pub fn top_refs_1<'a, H: HasLife<'a>>(_s: &'a ()) -> H { + unimplemented!() +} + +pub fn top_refs_2<'a, T: 'a, H: HasType<&'a T>>(_s: &'a ()) -> H { + unimplemented!() +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-nullary-variant.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-nullary-variant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-nullary-variant.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-nullary-variant.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +enum roption<'a> { + a, b(&'a usize) +} + +fn mk(cond: bool, ptr: &usize) -> roption { + if cond {roption::a} else {roption::b(ptr)} +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-params.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-params.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-params.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-params.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_parens)] + + +fn region_identity(x: &usize) -> &usize { x } + +fn apply(t: T, f: F) -> T where F: FnOnce(T) -> T { f(t) } + +fn parameterized(x: &usize) -> usize { + let z = apply(x, ({|y| + region_identity(y) + })); + *z +} + +pub fn main() { + let x = 3; + assert_eq!(parameterized(&x), 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-reassign-let-bound-pointer.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-reassign-let-bound-pointer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-reassign-let-bound-pointer.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-reassign-let-bound-pointer.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_assignments)] +#![allow(unused_variables)] +// Check that the type checker permits us to reassign `z` which +// started out with a longer lifetime and was reassigned to a shorter +// one (it should infer to be the intersection). + +// pretty-expanded FIXME #23616 + +fn foo(x: &isize) { + let a = 1; + let mut z = x; + z = &a; +} + +pub fn main() { + foo(&1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-reassign-match-bound-pointer.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-reassign-match-bound-pointer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-reassign-match-bound-pointer.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-reassign-match-bound-pointer.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_assignments)] +#![allow(unused_variables)] +// Check that the type checker permits us to reassign `z` which +// started out with a longer lifetime and was reassigned to a shorter +// one (it should infer to be the intersection). + +// pretty-expanded FIXME #23616 + +fn foo(x: &isize) { + let a = 1; + match x { + mut z => { + z = &a; + } + } +} + +pub fn main() { + foo(&1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-refcell.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-refcell.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-refcell.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-refcell.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,55 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// This is a regression test for something that only came up while +// attempting to bootstrap librustc with new destructor lifetime +// semantics. + + +use std::collections::HashMap; +use std::cell::RefCell; + +// This version does not yet work (associated type issues)... +#[cfg(cannot_use_this_yet)] +fn foo<'a>(map: RefCell>) { + let one = [1]; + assert_eq!(map.borrow().get("one"), Some(&one[..])); +} + +#[cfg(cannot_use_this_yet_either)] +// ... and this version does not work (the lifetime of `one` is +// supposed to match the lifetime `'a`) ... +fn foo<'a>(map: RefCell>) { + let one = [1]; + assert_eq!(map.borrow().get("one"), Some(&&one[..])); +} + +#[cfg(all(not(cannot_use_this_yet),not(cannot_use_this_yet_either)))] +fn foo<'a>(map: RefCell>) { + // ...so instead we walk through the trivial slice and make sure + // it contains the element we expect. + + for (i, &x) in map.borrow().get("one").unwrap().iter().enumerate() { + assert_eq!((i, x), (0, 1)); + } +} + +fn main() { + let zer = [0]; + let one = [1]; + let two = [2]; + let mut map = HashMap::new(); + map.insert("zero", &zer[..]); + map.insert("one", &one[..]); + map.insert("two", &two[..]); + let map = RefCell::new(map); + foo(map); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,69 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Test that this fairly specialized, but also reasonable, pattern +// typechecks. The pattern involves regions bound in closures that +// wind up related to inference variables. +// +// NB. Changes to the region implementations have broken this pattern +// a few times, but it happens to be used in the compiler so those +// changes were caught. However, those uses in the compiler could +// easily get changed or refactored away in the future. + +#![feature(box_syntax)] + +struct Ctxt<'tcx> { + x: &'tcx Vec +} + +struct Foo<'a,'tcx:'a> { + cx: &'a Ctxt<'tcx>, +} + +impl<'a,'tcx> Foo<'a,'tcx> { + fn bother(&mut self) -> isize { + self.elaborate_bounds(Box::new(|this| { + // (*) Here: type of `this` is `&'f0 Foo<&'f1, '_2>`, + // where `'f0` and `'f1` are fresh, free regions that + // result from the bound regions on the closure, and `'2` + // is a region inference variable created by the call. Due + // to the constraints on the type, we find that `'_2 : 'f1 + // + 'f2` must hold (and can be assumed by the callee). + // Region inference has to do some clever stuff to avoid + // inferring `'_2` to be `'static` in this case, because + // it is created outside the closure but then related to + // regions bound by the closure itself. See the + // `region_constraints.rs` file (and the `givens` field, in + // particular) for more details. + this.foo() + })) + } + + fn foo(&mut self) -> isize { + 22 + } + + fn elaborate_bounds( + &mut self, + mut mk_cand: Box FnMut(&mut Foo<'b, 'tcx>) -> isize>) + -> isize + { + mk_cand(self) + } +} + +fn main() { + let v = vec![]; + let cx = Ctxt { x: &v }; + let mut foo = Foo { cx: &cx }; + assert_eq!(foo.bother(), 22); // just so the code is not dead, basically +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-return-interior-of-option.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-return-interior-of-option.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-return-interior-of-option.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-return-interior-of-option.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn get(opt: &Option) -> &T { + match *opt { + Some(ref v) => v, + None => panic!("none") + } +} + +pub fn main() { + let mut x = Some(23); + + { + let y = get(&x); + assert_eq!(*y, 23); + } + + x = Some(24); + + { + let y = get(&x); + assert_eq!(*y, 24); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-scope-chain-example.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-scope-chain-example.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-scope-chain-example.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-scope-chain-example.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,53 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// This is an example where the older inference algorithm failed. The +// specifics of why it failed are somewhat, but not entirely, tailed +// to the algorithm. Ultimately the problem is that when computing the +// mutual supertype of both sides of the `if` it would be faced with a +// choice of tightening bounds or unifying variables and it took the +// wrong path. The new algorithm avoids this problem and hence this +// example typechecks correctly. + +// pretty-expanded FIXME #23616 + +enum ScopeChain<'a> { + Link(Scope<'a>), + End +} + +type Scope<'a> = &'a ScopeChain<'a>; + +struct OuterContext; + +struct Context<'a> { + foo: &'a OuterContext +} + +impl<'a> Context<'a> { + fn foo(&mut self, scope: Scope) { + let link = if 1 < 2 { + let l = ScopeChain::Link(scope); + self.take_scope(&l); + l + } else { + ScopeChain::Link(scope) + }; + self.take_scope(&link); + } + + fn take_scope(&mut self, x: Scope) { + } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-self-impls.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-self-impls.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-self-impls.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-self-impls.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +struct Clam<'a> { + chowder: &'a isize +} + +trait get_chowder<'a> { + fn get_chowder(&self) -> &'a isize; +} + +impl<'a> get_chowder<'a> for Clam<'a> { + fn get_chowder(&self) -> &'a isize { return self.chowder; } +} + +pub fn main() { + let clam = Clam { chowder: &3 }; + println!("{}", *clam.get_chowder()); + clam.get_chowder(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-self-in-enums.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-self-in-enums.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-self-in-enums.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-self-in-enums.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +#![allow(non_camel_case_types)] + +enum int_wrapper<'a> { + int_wrapper_ctor(&'a isize) +} + +pub fn main() { + let x = 3; + let y = int_wrapper::int_wrapper_ctor(&x); + let mut z : &isize; + match y { + int_wrapper::int_wrapper_ctor(zz) => { z = zz; } + } + println!("{}", *z); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-simple.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-simple.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-simple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn main() { + let mut x: isize = 3; + let y: &mut isize = &mut x; + *y = 5; + println!("{}", *y); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-static-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-static-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-static-bound.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-static-bound.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn invariant_id<'a,'b>(t: &'b mut &'static ()) -> &'b mut &'a () + where 'a: 'static { t } +fn static_id<'a>(t: &'a ()) -> &'static () + where 'a: 'static { t } +fn static_id_indirect<'a,'b>(t: &'a ()) -> &'static () + where 'a: 'b, 'b: 'static { t } +fn ref_id<'a>(t: &'a ()) -> &'a () where 'static: 'a { t } + +static UNIT: () = (); + +fn main() +{ + let mut val : &'static () = &UNIT; + invariant_id(&mut val); + static_id(val); + static_id_indirect(val); + ref_id(val); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-static-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-static-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-static-closure.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-static-closure.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +struct closure_box<'a> { + cl: Box, +} + +fn box_it<'a>(x: Box) -> closure_box<'a> { + closure_box {cl: x} +} + +fn call_static_closure(mut cl: closure_box<'static>) { + (cl.cl)(); +} + +pub fn main() { + let cl_box = box_it(Box::new(|| println!("Hello, world!"))); + call_static_closure(cl_box); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-trait-object-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-trait-object-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-trait-object-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-trait-object-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// This is a regression test for something that only came up while +// attempting to bootstrap libsyntax; it is adapted from +// `syntax::ext::tt::generic_extension`. + + +pub struct E<'a> { + pub f: &'a u8, +} +impl<'b> E<'b> { + pub fn m(&self) -> &'b u8 { self.f } +} + +pub struct P<'c> { + pub g: &'c u8, +} +pub trait M { + fn n(&self) -> u8; +} +impl<'d> M for P<'d> { + fn n(&self) -> u8 { *self.g } +} + +fn extension<'e>(x: &'e E<'e>) -> Box { + loop { + let p = P { g: x.m() }; + return Box::new(p) as Box; + } +} + +fn main() { + let w = E { f: &10 }; + let o = extension(&w); + assert_eq!(o.n(), 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-variance-contravariant-use-contravariant.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-variance-contravariant-use-contravariant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-variance-contravariant-use-contravariant.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-variance-contravariant-use-contravariant.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// Test that a type which is contravariant with respect to its region +// parameter compiles successfully when used in a contravariant way. +// +// Note: see compile-fail/variance-regions-*.rs for the tests that check that the +// variance inference works in the first place. + +// pretty-expanded FIXME #23616 + +struct Contravariant<'a> { + f: &'a isize +} + +fn use_<'a>(c: Contravariant<'a>) { + let x = 3; + + // 'b winds up being inferred to this call. + // Contravariant<'a> <: Contravariant<'call> is true + // if 'call <= 'a, which is true, so no error. + collapse(&x, c); + + fn collapse<'b>(x: &'b isize, c: Contravariant<'b>) { } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-variance-covariant-use-covariant.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-variance-covariant-use-covariant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/regions/regions-variance-covariant-use-covariant.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/regions/regions-variance-covariant-use-covariant.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Test that a type which is covariant with respect to its region +// parameter is successful when used in a covariant way. +// +// Note: see compile-fail/variance-regions-*.rs for the tests that +// check that the variance inference works in the first place. + +// This is covariant with respect to 'a, meaning that +// Covariant<'foo> <: Covariant<'static> because +// 'foo <= 'static +// pretty-expanded FIXME #23616 + +struct Covariant<'a> { + f: extern "Rust" fn(&'a isize) +} + +fn use_<'a>(c: Covariant<'a>) { + // OK Because Covariant<'a> <: Covariant<'static> iff 'a <= 'static + let _: Covariant<'static> = c; +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/resolve-issue-2428.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/resolve-issue-2428.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/resolve-issue-2428.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/resolve-issue-2428.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(non_upper_case_globals)] const foo: isize = 4 >> 1; enum bs { thing = foo } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/resolve-pseudo-shadowing.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/resolve-pseudo-shadowing.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/resolve-pseudo-shadowing.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/resolve-pseudo-shadowing.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,7 +12,7 @@ fn check(_c: Clone) { fn check2() { - <() as std::clone::Clone>::clone(&()); + let _ = <() as std::clone::Clone>::clone(&()); } check2(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/resource-assign-is-not-copy.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/resource-assign-is-not-copy.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/resource-assign-is-not-copy.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/resource-assign-is-not-copy.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] use std::cell::Cell; #[derive(Debug)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/resource-destruct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/resource-destruct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/resource-destruct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/resource-destruct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] use std::cell::Cell; struct shrinky_pointer<'a> { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ret-none.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ret-none.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/ret-none.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/ret-none.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(dead_code)] // pretty-expanded FIXME #23616 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1014-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1014-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1014-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1014-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +#![feature(libc)] + +extern crate libc; + +type DWORD = u32; +type HANDLE = *mut u8; +type BOOL = i32; + +#[cfg(windows)] +extern "system" { + fn SetStdHandle(nStdHandle: DWORD, nHandle: HANDLE) -> BOOL; +} + +#[cfg(windows)] +fn close_stdout() { + const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD; + unsafe { SetStdHandle(STD_OUTPUT_HANDLE, 0 as HANDLE); } +} + +#[cfg(windows)] +fn main() { + close_stdout(); + println!("hello world"); +} + +#[cfg(not(windows))] +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1014.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1014.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1014.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1014.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// ignore-cloudabi stdout does not map to file descriptor 1 by default +// ignore-wasm32-bare no libc + +#![feature(libc)] + +extern crate libc; + +type DWORD = u32; +type HANDLE = *mut u8; + +#[cfg(windows)] +extern "system" { + fn GetStdHandle(which: DWORD) -> HANDLE; + fn CloseHandle(handle: HANDLE) -> i32; +} + +#[cfg(windows)] +fn close_stdout() { + const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD; + unsafe { CloseHandle(GetStdHandle(STD_OUTPUT_HANDLE)); } +} + +#[cfg(not(windows))] +fn close_stdout() { + unsafe { libc::close(1); } +} + +fn main() { + close_stdout(); + println!("hello world"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1445/eq-allows-match-on-ty-in-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1445/eq-allows-match-on-ty-in-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1445/eq-allows-match-on-ty-in-macro.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1445/eq-allows-match-on-ty-in-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +macro_rules! foo { + (#[$attr:meta] $x:ident) => { + #[$attr] + struct $x { + x: u32 + } + } +} + +foo! { #[derive(PartialEq, Eq)] Foo } + +const FOO: Foo = Foo { x: 0 }; + +fn main() { + let y = Foo { x: 1 }; + match y { + FOO => { } + _ => { } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1445/eq-allows-match.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1445/eq-allows-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1445/eq-allows-match.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1445/eq-allows-match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +#[derive(PartialEq, Eq)] +struct Foo { + x: u32 +} + +const FOO: Foo = Foo { x: 0 }; + +fn main() { + let y = Foo { x: 1 }; + match y { + FOO => { } + _ => { } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1623.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1623.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1623.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1623.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,85 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +#![allow(non_upper_case_globals)] + +#![allow(dead_code)] + +// very simple test for a 'static static with default lifetime +static STATIC_STR: &str = "&'static str"; +const CONST_STR: &str = "&'static str"; + +// this should be the same as without default: +static EXPLICIT_STATIC_STR: &'static str = "&'static str"; +const EXPLICIT_CONST_STR: &'static str = "&'static str"; + +// a function that elides to an unbound lifetime for both in- and output +fn id_u8_slice(arg: &[u8]) -> &[u8] { + arg +} + +// one with a function, argument elided +static STATIC_SIMPLE_FN: &fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]); +const CONST_SIMPLE_FN: &fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]); + +// this should be the same as without elision +static STATIC_NON_ELIDED_fN: &for<'a> fn(&'a [u8]) -> &'a [u8] = + &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); +const CONST_NON_ELIDED_fN: &for<'a> fn(&'a [u8]) -> &'a [u8] = + &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); + +// another function that elides, each to a different unbound lifetime +fn multi_args(a: &u8, b: &u8, c: &u8) {} + +static STATIC_MULTI_FN: &fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8)); +const CONST_MULTI_FN: &fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8)); + +struct Foo<'a> { + bools: &'a [bool], +} + +static STATIC_FOO: Foo = Foo { bools: &[true, false] }; +const CONST_FOO: Foo = Foo { bools: &[true, false] }; + +type Bar<'a> = Foo<'a>; + +static STATIC_BAR: Bar = Bar { bools: &[true, false] }; +const CONST_BAR: Bar = Bar { bools: &[true, false] }; + +type Baz<'a> = fn(&'a [u8]) -> Option; + +fn baz(e: &[u8]) -> Option { + e.first().map(|x| *x) +} + +static STATIC_BAZ: &Baz = &(baz as Baz); +const CONST_BAZ: &Baz = &(baz as Baz); + +static BYTES: &[u8] = &[1, 2, 3]; + +fn main() { + // make sure that the lifetime is actually elided (and not defaulted) + let x = &[1u8, 2, 3]; + STATIC_SIMPLE_FN(x); + CONST_SIMPLE_FN(x); + + STATIC_BAZ(BYTES); // neees static lifetime + CONST_BAZ(BYTES); + + // make sure this works with different lifetimes + let a = &1; + { + let b = &2; + let c = &3; + CONST_MULTI_FN(a, b, c); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1717/auxiliary/clibrary.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1717/auxiliary/clibrary.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1717/auxiliary/clibrary.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1717/auxiliary/clibrary.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic +#![crate_type = "staticlib"] + +#[no_mangle] +pub extern "C" fn foo(x:i32) -> i32 { x } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1717/library-override.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1717/library-override.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1717/library-override.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1717/library-override.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-wasm32-bare no libc to test ffi with +// compile-flags: -lstatic=wronglibrary:rust_test_helpers + +#[link(name = "wronglibrary", kind = "dylib")] +extern "C" { + pub fn rust_dbg_extern_identity_u32(x: u32) -> u32; +} + +fn main() { + unsafe { + rust_dbg_extern_identity_u32(42); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1789-as-cell/from-mut.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1789-as-cell/from-mut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1789-as-cell/from-mut.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1789-as-cell/from-mut.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(as_cell)] + +use std::cell::Cell; + +fn main() { + let slice: &mut [i32] = &mut [1, 2, 3]; + let cell_slice: &Cell<[i32]> = Cell::from_mut(slice); + let slice_cell: &[Cell] = cell_slice.as_slice_of_cells(); + + assert_eq!(slice_cell.len(), 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1857-drop-order.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1857-drop-order.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1857-drop-order.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc1857-drop-order.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,234 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-wasm32-bare compiled with panic=abort by default + +#![allow(dead_code, unreachable_code)] + +use std::cell::RefCell; +use std::rc::Rc; +use std::panic::{self, AssertUnwindSafe, UnwindSafe}; + +// This struct is used to record the order in which elements are dropped +struct PushOnDrop { + vec: Rc>>, + val: u32 +} + +impl PushOnDrop { + fn new(val: u32, vec: Rc>>) -> PushOnDrop { + PushOnDrop { vec, val } + } +} + +impl Drop for PushOnDrop { + fn drop(&mut self) { + self.vec.borrow_mut().push(self.val) + } +} + +impl UnwindSafe for PushOnDrop { } + +// Structs +struct TestStruct { + x: PushOnDrop, + y: PushOnDrop, + z: PushOnDrop +} + +// Tuple structs +struct TestTupleStruct(PushOnDrop, PushOnDrop, PushOnDrop); + +// Enum variants +enum TestEnum { + Tuple(PushOnDrop, PushOnDrop, PushOnDrop), + Struct { x: PushOnDrop, y: PushOnDrop, z: PushOnDrop } +} + +fn test_drop_tuple() { + // Tuple fields are dropped in the same order they are declared + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let test_tuple = (PushOnDrop::new(1, dropped_fields.clone()), + PushOnDrop::new(2, dropped_fields.clone())); + drop(test_tuple); + assert_eq!(*dropped_fields.borrow(), &[1, 2]); + + // Panic during construction means that fields are treated as local variables + // Therefore they are dropped in reverse order of initialization + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let cloned = AssertUnwindSafe(dropped_fields.clone()); + panic::catch_unwind(|| { + (PushOnDrop::new(2, cloned.clone()), + PushOnDrop::new(1, cloned.clone()), + panic!("this panic is caught :D")); + }).err().unwrap(); + assert_eq!(*dropped_fields.borrow(), &[1, 2]); +} + +fn test_drop_struct() { + // Struct fields are dropped in the same order they are declared + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let test_struct = TestStruct { + x: PushOnDrop::new(1, dropped_fields.clone()), + y: PushOnDrop::new(2, dropped_fields.clone()), + z: PushOnDrop::new(3, dropped_fields.clone()), + }; + drop(test_struct); + assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); + + // The same holds for tuple structs + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let test_tuple_struct = TestTupleStruct(PushOnDrop::new(1, dropped_fields.clone()), + PushOnDrop::new(2, dropped_fields.clone()), + PushOnDrop::new(3, dropped_fields.clone())); + drop(test_tuple_struct); + assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); + + // Panic during struct construction means that fields are treated as local variables + // Therefore they are dropped in reverse order of initialization + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let cloned = AssertUnwindSafe(dropped_fields.clone()); + panic::catch_unwind(|| { + TestStruct { + x: PushOnDrop::new(2, cloned.clone()), + y: PushOnDrop::new(1, cloned.clone()), + z: panic!("this panic is caught :D") + }; + }).err().unwrap(); + assert_eq!(*dropped_fields.borrow(), &[1, 2]); + + // Test with different initialization order + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let cloned = AssertUnwindSafe(dropped_fields.clone()); + panic::catch_unwind(|| { + TestStruct { + y: PushOnDrop::new(2, cloned.clone()), + x: PushOnDrop::new(1, cloned.clone()), + z: panic!("this panic is caught :D") + }; + }).err().unwrap(); + assert_eq!(*dropped_fields.borrow(), &[1, 2]); + + // The same holds for tuple structs + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let cloned = AssertUnwindSafe(dropped_fields.clone()); + panic::catch_unwind(|| { + TestTupleStruct(PushOnDrop::new(2, cloned.clone()), + PushOnDrop::new(1, cloned.clone()), + panic!("this panic is caught :D")); + }).err().unwrap(); + assert_eq!(*dropped_fields.borrow(), &[1, 2]); +} + +fn test_drop_enum() { + // Enum variants are dropped in the same order they are declared + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let test_struct_enum = TestEnum::Struct { + x: PushOnDrop::new(1, dropped_fields.clone()), + y: PushOnDrop::new(2, dropped_fields.clone()), + z: PushOnDrop::new(3, dropped_fields.clone()) + }; + drop(test_struct_enum); + assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); + + // The same holds for tuple enum variants + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let test_tuple_enum = TestEnum::Tuple(PushOnDrop::new(1, dropped_fields.clone()), + PushOnDrop::new(2, dropped_fields.clone()), + PushOnDrop::new(3, dropped_fields.clone())); + drop(test_tuple_enum); + assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); + + // Panic during enum construction means that fields are treated as local variables + // Therefore they are dropped in reverse order of initialization + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let cloned = AssertUnwindSafe(dropped_fields.clone()); + panic::catch_unwind(|| { + TestEnum::Struct { + x: PushOnDrop::new(2, cloned.clone()), + y: PushOnDrop::new(1, cloned.clone()), + z: panic!("this panic is caught :D") + }; + }).err().unwrap(); + assert_eq!(*dropped_fields.borrow(), &[1, 2]); + + // Test with different initialization order + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let cloned = AssertUnwindSafe(dropped_fields.clone()); + panic::catch_unwind(|| { + TestEnum::Struct { + y: PushOnDrop::new(2, cloned.clone()), + x: PushOnDrop::new(1, cloned.clone()), + z: panic!("this panic is caught :D") + }; + }).err().unwrap(); + assert_eq!(*dropped_fields.borrow(), &[1, 2]); + + // The same holds for tuple enum variants + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let cloned = AssertUnwindSafe(dropped_fields.clone()); + panic::catch_unwind(|| { + TestEnum::Tuple(PushOnDrop::new(2, cloned.clone()), + PushOnDrop::new(1, cloned.clone()), + panic!("this panic is caught :D")); + }).err().unwrap(); + assert_eq!(*dropped_fields.borrow(), &[1, 2]); +} + +fn test_drop_list() { + // Elements in a Vec are dropped in the same order they are pushed + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let xs = vec![PushOnDrop::new(1, dropped_fields.clone()), + PushOnDrop::new(2, dropped_fields.clone()), + PushOnDrop::new(3, dropped_fields.clone())]; + drop(xs); + assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); + + // The same holds for arrays + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let xs = [PushOnDrop::new(1, dropped_fields.clone()), + PushOnDrop::new(2, dropped_fields.clone()), + PushOnDrop::new(3, dropped_fields.clone())]; + drop(xs); + assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); + + // Panic during vec construction means that fields are treated as local variables + // Therefore they are dropped in reverse order of initialization + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let cloned = AssertUnwindSafe(dropped_fields.clone()); + panic::catch_unwind(|| { + vec![ + PushOnDrop::new(2, cloned.clone()), + PushOnDrop::new(1, cloned.clone()), + panic!("this panic is caught :D") + ]; + }).err().unwrap(); + assert_eq!(*dropped_fields.borrow(), &[1, 2]); + + // The same holds for arrays + let dropped_fields = Rc::new(RefCell::new(Vec::new())); + let cloned = AssertUnwindSafe(dropped_fields.clone()); + panic::catch_unwind(|| { + [ + PushOnDrop::new(2, cloned.clone()), + PushOnDrop::new(1, cloned.clone()), + panic!("this panic is caught :D") + ]; + }).err().unwrap(); + assert_eq!(*dropped_fields.borrow(), &[1, 2]); +} + +fn main() { + test_drop_tuple(); + test_drop_struct(); + test_drop_enum(); + test_drop_list(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::error::Error; + +fn main() -> Result<(), Box> { + Ok(()) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-empty.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-empty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-empty.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-empty.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-exitcode.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-exitcode.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-exitcode.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-exitcode.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(process_exitcode_placeholder)] + +use std::process::ExitCode; + +fn main() -> ExitCode { + ExitCode::SUCCESS +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-impl-termination.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-impl-termination.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-impl-termination.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-impl-termination.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(termination_trait_lib)] + +fn main() -> impl std::process::Termination { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-result-box-error_ok.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-result-box-error_ok.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-result-box-error_ok.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-result-box-error_ok.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::io::Error; + +fn main() -> Result<(), Box> { + Ok(()) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-result.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-result.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-result.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-result.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::io::Error; + +fn main() -> Result<(), Error> { + Ok(()) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-str.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-str.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-str.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-str.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn main() -> Result<(), &'static str> { + Ok(()) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/box.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/box.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/box.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/box.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unreachable_patterns)] +#![feature(box_syntax, box_patterns)] + +struct Foo{} + +pub fn main() { + let b = box Foo{}; + let box f = &b; + let _: &Foo = f; + + match &&&b { + box f => { + let _: &Foo = f; + }, + _ => panic!(), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/constref.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/constref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/constref.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/constref.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,50 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +const CONST_REF: &[u8; 3] = b"foo"; + +trait Foo { + const CONST_REF_DEFAULT: &'static [u8; 3] = b"bar"; + const CONST_REF: &'static [u8; 3]; +} + +impl Foo for i32 { + const CONST_REF: &'static [u8; 3] = b"jjj"; +} + +impl Foo for i64 { + const CONST_REF_DEFAULT: &'static [u8; 3] = b"ggg"; + const CONST_REF: &'static [u8; 3] = b"fff"; +} + +// Check that (associated and free) const references are not mistaken for a +// non-reference pattern (in which case they would be auto-dereferenced, making +// the types mismatched). + +fn const_ref() -> bool { + let f = b"foo"; + match f { + CONST_REF => true, + _ => false, + } +} + +fn associated_const_ref() -> bool { + match (b"bar", b"jjj", b"ggg", b"fff") { + (i32::CONST_REF_DEFAULT, i32::CONST_REF, i64::CONST_REF_DEFAULT, i64::CONST_REF) => true, + _ => false, + } +} + +pub fn main() { + assert!(const_ref()); + assert!(associated_const_ref()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/enum.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/enum.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,55 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +enum Wrapper { + Wrap(i32), +} + +use Wrapper::Wrap; + +pub fn main() { + let Wrap(x) = &Wrap(3); + println!("{}", *x); + + let Wrap(x) = &mut Wrap(3); + println!("{}", *x); + + if let Some(x) = &Some(3) { + println!("{}", *x); + } else { + panic!(); + } + + if let Some(x) = &mut Some(3) { + println!("{}", *x); + } else { + panic!(); + } + + if let Some(x) = &mut Some(3) { + *x += 1; + } else { + panic!(); + } + + while let Some(x) = &Some(3) { + println!("{}", *x); + break; + } + while let Some(x) = &mut Some(3) { + println!("{}", *x); + break; + } + while let Some(x) = &mut Some(3) { + *x += 1; + break; + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/for.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/for.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/for.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/for.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn main() { + let mut tups = vec![(0u8, 1u8)]; + + for (n, m) in &tups { + let _: &u8 = n; + let _: &u8 = m; + } + + for (n, m) in &mut tups { + *n += 1; + *m += 2; + } + + assert_eq!(tups, vec![(1u8, 3u8)]); + + for (n, m) in tups { + println!("{} {}", m, n); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/general.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/general.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/general.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/general.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,259 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +fn some_or_wildcard(r: &Option, b: &i32) { + let _: &i32 = match r { + Some(a) => a, + _ => b, + }; +} + +fn none_or_wildcard(r: &Option, b: &i32) { + let _: &i32 = match r { + None => b, + _ => b, + }; +} + +fn some_or_ref_none(r: &Option, b: &i32) { + let _: &i32 = match r { + Some(a) => a, + &None => b, + }; +} + +fn ref_some_or_none(r: &Option, b: &i32) { + let _: &i32 = match r { + &Some(ref a) => a, + None => b, + }; +} + +fn some_or_self(r: &Option) { + let _: &Option = match r { + Some(n) => { + let _: &i32 = n; + r + }, + x => x, + }; +} + +fn multiple_deref(r: &&&&&Option) { + let _: i32 = match r { + Some(a) => *a, + None => 5, + }; +} + +fn match_with_or() { + // FIXME(tschottdorf): #44912. + // + // let x = &Some((3, 3)); + // let _: &i32 = match x { + // Some((x, 3)) | &Some((ref x, 5)) => x, + // _ => &5i32, + // }; +} + +fn nested_mixed() { + match (&Some(5), &Some(6)) { + (Some(a), &Some(mut b)) => { + // Here, the `a` will be `&i32`, because in the first half of the tuple + // we hit a non-reference pattern and shift into `ref` mode. + // + // In the second half of the tuple there's no non-reference pattern, + // so `b` will be `i32` (bound with `move` mode). Moreover, `b` is + // mutable. + let _: &i32 = a; + b = 7; + let _: i32 = b; + }, + _ => {}, + }; +} + +fn nested_mixed_multiple_deref_1() { + let x = (1, &Some(5)); + let y = &Some(x); + match y { + Some((a, Some(b))) => { + let _: &i32 = a; + let _: &i32 = b; + }, + _ => {}, + }; +} + +fn nested_mixed_multiple_deref_2() { + let x = &Some(5); + let y = &x; + match y { + Some(z) => { + let _: &i32 = z; + }, + _ => {}, + } +} + +fn new_mutable_reference() { + let mut x = &mut Some(5); + match &mut x { + Some(y) => { + *y = 5; + }, + None => { }, + } + + match &mut x { + Some(y) => { + println!("{}", *y); + }, + None => {}, + } +} + +fn let_implicit_ref_binding() { + struct Foo(i32); + + // Note that these rules apply to any pattern matching + // whether it be in a `match` or a `let`. + // For example, `x` here is a `ref` binding: + let Foo(x) = &Foo(3); + let _: &i32 = x; +} + +fn explicit_mut_binding() { + match &Some(5i32) { + Some(mut n) => { + n += 1; + let _ = n; + } + None => {}, + }; + + match &mut Some(5i32) { + Some(n) => { + *n += 1; + let _ = n; + } + None => {}, + }; + + match &mut &mut Some(5i32) { + Some(n) => { + let _: &mut i32 = n; + } + None => {}, + }; +} + +fn tuple_mut_and_mut_mut() { + match (Some(5i32), &Some(5i32)) { + (Some(n), Some(m)) => { + // `n` and `m` are bound as immutable references. Make new references from them to + // assert that. + let r = n; + let _ = r; + let q = m; + let _ = q; + + // Assert the types. Note that we use `n` and `m` here which would fail had they been + // moved due to the assignments above. + let _: i32 = n; + let _: &i32 = m; + } + (_, _) => {}, + }; + + match (&Some(5i32), &&Some(5i32)) { + (Some(n), Some(m)) => { + let _: &i32 = n; + let _: &i32 = m; + } + (_, _) => {}, + }; + + match &mut &mut (Some(5i32), Some(5i32)) { + (Some(n), Some(m)) => { + // Dereferenced through &mut &mut, so a mutable binding results. + let _: &mut i32 = n; + let _: &mut i32 = m; + } + (_, _) => {}, + }; + + match (&mut Some(5i32), &mut &mut Some(5i32)) { + (Some(n), Some(m)) => { + let _: &mut i32 = n; + let _: &mut i32 = m; + } + (_, _) => {}, + }; +} + +fn min_mir_embedded_type() { + // The reduced invocation that an ICE was diagnosed with (was consuming + // adjustments in wrong order). + match (0u8, &&Some(5i32)) { + (_, Some(m)) => { + let _: &i32 = m; + } + (_, _) => {}, + }; +} + +fn no_autoderef() { + // Binding. + let x = &3; + println!("{}", *x); + + // Wildcard. + let _ = &3; + + // Constant of generic type (string) + const Y: &'static str = "foo"; + assert_eq!(0, match "foo" { + Y => 0, + _ => 1, + }); + + // Reference pattern. + let &x = &3; +} + +pub fn main() { + let r: &Option = &Some(3); + let b = &4i32; + + none_or_wildcard(r, b); + some_or_wildcard(r, b); + some_or_ref_none(r, b); + ref_some_or_none(r, b); + + some_or_self(r); + multiple_deref(&&&&r); + match_with_or(); + + nested_mixed(); + nested_mixed_multiple_deref_1(); + nested_mixed_multiple_deref_2(); + + new_mutable_reference(); + explicit_mut_binding(); + tuple_mut_and_mut_mut(); + min_mir_embedded_type(); + + let_implicit_ref_binding(); + + no_autoderef(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/lit.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/lit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/lit.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/lit.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +fn with_u8() { + let s = 5u8; + let r = match &s { + 4 => false, + 5 => true, + _ => false, + }; + assert!(r); +} + +// A string literal isn't mistaken for a non-ref pattern (in which case we'd +// deref `s` and mess things up). +fn with_str() { + let s: &'static str = "abc"; + match s { + "abc" => true, + _ => panic!(), + }; +} + +// Ditto with byte strings. +fn with_bytes() { + let s: &'static [u8] = b"abc"; + match s { + b"abc" => true, + _ => panic!(), + }; +} + +pub fn main() { + with_str(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/range.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/range.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/range.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/range.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn main() { + let i = 5; + match &&&&i { + 1 ..= 3 => panic!(), + 3 ..= 8 => {}, + _ => panic!(), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/ref-region.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/ref-region.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/ref-region.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/ref-region.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn foo<'a, 'b>(x: &'a &'b Option) -> &'a u32 { + let x: &'a &'a Option = x; + match x { + Some(r) => { + let _: &u32 = r; + r + }, + &None => panic!(), + } +} + +pub fn main() { + let x = Some(5); + foo(&&x); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/reset-mode.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/reset-mode.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/reset-mode.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/reset-mode.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we "reset" the mode as we pass through a `&` pattern. +// +// cc #46688 + +fn surprise(x: i32) { + assert_eq!(x, 2); +} + +fn main() { + let x = &(1, &2); + let (_, &b) = x; + surprise(b); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/slice.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/slice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/slice.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/slice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(slice_patterns)] + +fn slice_pat() { + let sl: &[u8] = b"foo"; + + match sl { + [first, remainder..] => { + let _: &u8 = first; + assert_eq!(first, &b'f'); + assert_eq!(remainder, b"oo"); + } + [] => panic!(), + } +} + +fn slice_pat_omission() { + match &[0, 1, 2] { + [..] => {} + }; +} + +fn main() { + slice_pat(); + slice_pat_omission(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(Debug, PartialEq)] +struct Foo { + x: u8, +} + +pub fn main() { + let mut foo = Foo { + x: 1, + }; + + match &mut foo { + Foo{x: n} => { + *n += 1; + }, + }; + + assert_eq!(foo, Foo{x: 2}); + + let Foo{x: n} = &foo; + assert_eq!(*n, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/tuple.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/tuple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/tuple.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/tuple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn main() { + let foo = (Some(1), (), (), vec![2, 3]); + + match &foo { + (Some(n), .., v) => { + assert_eq!((*v).len(), 2); + assert_eq!(*n, 1); + } + (None, (), (), ..) => panic!(), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/tuple-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/tuple-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/tuple-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2005-default-binding-mode/tuple-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +enum Foo { + Bar(Option, (), (), Vec), + Baz, +} + +pub fn main() { + let foo = Foo::Bar(Some(1), (), (), vec![2, 3]); + + match &foo { + Foo::Baz => panic!(), + Foo::Bar(None, ..) => panic!(), + Foo::Bar(Some(n), .., v) => { + assert_eq!((*v).len(), 2); + assert_eq!(*n, 1); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/enums.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/enums.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/enums.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/enums.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![crate_type = "rlib"] +#![feature(non_exhaustive)] + +#[non_exhaustive] +pub enum NonExhaustiveEnum { + Unit, + Tuple(u32), + Struct { field: u32 } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/structs.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/structs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/structs.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/structs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(non_exhaustive)] + +#[non_exhaustive] +pub struct NormalStruct { + pub first_field: u16, + pub second_field: u16, +} + +#[non_exhaustive] +pub struct UnitStruct; + +#[non_exhaustive] +pub struct TupleStruct (pub u16, pub u16); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/variants.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/variants.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/variants.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/variants.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![crate_type = "rlib"] +#![feature(non_exhaustive)] + +pub enum NonExhaustiveVariants { + #[non_exhaustive] Unit, + #[non_exhaustive] Tuple(u32), + #[non_exhaustive] Struct { field: u32 } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/enums.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/enums.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/enums.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/enums.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,63 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:enums.rs +extern crate enums; + +// ignore-pretty issue #37199 + +use enums::NonExhaustiveEnum; + +fn main() { + let enum_unit = NonExhaustiveEnum::Unit; + + match enum_unit { + NonExhaustiveEnum::Unit => 1, + NonExhaustiveEnum::Tuple(_) => 2, + // This particular arm tests that a enum marked as non-exhaustive + // will not error if its variants are matched exhaustively. + NonExhaustiveEnum::Struct { field } => field, + _ => 0 // no error with wildcard + }; + + match enum_unit { + _ => "no error with only wildcard" + }; + + + // issue #53549 - check that variant constructors can still be called normally. + + match NonExhaustiveEnum::Unit { + NonExhaustiveEnum::Unit => {}, + _ => {} + }; + + match NonExhaustiveEnum::Tuple(2) { + NonExhaustiveEnum::Tuple(2) => {}, + _ => {} + }; + + match (NonExhaustiveEnum::Unit {}) { + NonExhaustiveEnum::Unit {} => {}, + _ => {} + }; + + match (NonExhaustiveEnum::Tuple { 0: 2 }) { + NonExhaustiveEnum::Tuple { 0: 2 } => {}, + _ => {} + }; + + match (NonExhaustiveEnum::Struct { field: 2 }) { + NonExhaustiveEnum::Struct { field: 2 } => {}, + _ => {} + }; + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/enums_same_crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/enums_same_crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/enums_same_crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/enums_same_crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(non_exhaustive)] + +#[non_exhaustive] +pub enum NonExhaustiveEnum { + Unit, + Tuple(u32), + Struct { field: u32 } +} + +fn main() { + let enum_unit = NonExhaustiveEnum::Unit; + + match enum_unit { + NonExhaustiveEnum::Unit => "first", + NonExhaustiveEnum::Tuple(_) => "second", + NonExhaustiveEnum::Struct { .. } => "third", + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/structs.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/structs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/structs.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/structs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// aux-build:structs.rs +extern crate structs; + +use structs::{NormalStruct, UnitStruct, TupleStruct}; + +// We only test matching here as we cannot create non-exhaustive +// structs from another crate. ie. they'll never pass in run-pass tests. + +fn match_structs(ns: NormalStruct, ts: TupleStruct, us: UnitStruct) { + let NormalStruct { first_field, second_field, .. } = ns; + + let TupleStruct { 0: first, 1: second, .. } = ts; + + let UnitStruct { .. } = us; +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/structs_same_crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/structs_same_crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/structs_same_crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/structs_same_crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +#![feature(non_exhaustive)] + +#[non_exhaustive] +pub struct NormalStruct { + pub first_field: u16, + pub second_field: u16, +} + +#[non_exhaustive] +pub struct UnitStruct; + +#[non_exhaustive] +pub struct TupleStruct (pub u16, pub u16); + +fn main() { + let ns = NormalStruct { first_field: 640, second_field: 480 }; + + let NormalStruct { first_field, second_field } = ns; + + let ts = TupleStruct { 0: 340, 1: 480 }; + let ts_constructor = TupleStruct(340, 480); + + let TupleStruct { 0: first, 1: second } = ts; + let TupleStruct(first, second) = ts_constructor; + + let us = UnitStruct {}; + let us_constructor = UnitStruct; + + let UnitStruct { } = us; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/variants.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/variants.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/variants.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/variants.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:variants.rs +extern crate variants; + +use variants::NonExhaustiveVariants; + +/* + * The initial implementation of #[non_exhaustive] (RFC 2008) does not include support for + * variants. See issue #44109 and PR 45394. + */ +// ignore-test + +fn main() { + let variant_tuple = NonExhaustiveVariants::Tuple { 0: 340 }; + let variant_struct = NonExhaustiveVariants::Struct { field: 340 }; + + match variant_struct { + NonExhaustiveVariants::Unit => "", + NonExhaustiveVariants::Struct { field, .. } => "", + NonExhaustiveVariants::Tuple(fe_tpl, ..) => "" + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/variants_same_crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/variants_same_crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/variants_same_crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2008-non-exhaustive/variants_same_crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(non_exhaustive)] + +/* + * The initial implementation of #[non_exhaustive] (RFC 2008) does not include support for + * variants. See issue #44109 and PR 45394. + */ +// ignore-test + +pub enum NonExhaustiveVariants { + #[non_exhaustive] Unit, + #[non_exhaustive] Tuple(u32), + #[non_exhaustive] Struct { field: u32 } +} + +fn main() { + let variant_tuple = NonExhaustiveVariants::Tuple(340); + let variant_struct = NonExhaustiveVariants::Struct { field: 340 }; + + match variant_tuple { + NonExhaustiveVariants::Unit => "", + NonExhaustiveVariants::Tuple(fe_tpl) => "", + NonExhaustiveVariants::Struct { field } => "" + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,52 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(crate_in_paths)] +#![allow(dead_code)] +use crate::m::f; +use crate as root; + +mod m { + pub fn f() -> u8 { 1 } + pub fn g() -> u8 { 2 } + pub fn h() -> u8 { 3 } + + // OK, visibilities are implicitly absolute like imports + pub(in crate::m) struct S; +} + +mod n { + use crate::m::f; + use crate as root; + pub fn check() { + assert_eq!(f(), 1); + assert_eq!(crate::m::g(), 2); + assert_eq!(root::m::h(), 3); + } +} + +mod p { + use {super::f, crate::m::g, self::root::m::h}; + use crate as root; + pub fn check() { + assert_eq!(f(), 1); + assert_eq!(g(), 2); + assert_eq!(h(), 3); + } +} + +fn main() { + assert_eq!(f(), 1); + assert_eq!(crate::m::g(), 2); + assert_eq!(root::m::h(), 3); + n::check(); + p::check(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.stderr rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +warning: the feature `crate_in_paths` has been stable since 1.30.0 and no longer requires an attribute to enable + --> $DIR/crate-path-absolute.rs:12:12 + | +LL | #![feature(crate_in_paths)] + | ^^^^^^^^^^^^^^ + | + = note: #[warn(stable_features)] on by default + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-crate-paths/crate-path-visibility-ambiguity.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-crate-paths/crate-path-visibility-ambiguity.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-crate-paths/crate-path-visibility-ambiguity.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-crate-paths/crate-path-visibility-ambiguity.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(crate_in_paths)] +#![feature(crate_visibility_modifier)] +#![allow(dead_code)] +mod m { + pub struct Z; + pub struct S1(crate (::m::Z)); // OK + pub struct S2((crate ::m::Z)); // OK + pub struct S3(crate ::m::Z); // OK + pub struct S4(crate crate::m::Z); // OK +} + +fn main() { + crate struct S; // OK (item in statement position) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-crate-paths/crate-path-visibility-ambiguity.stderr rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-crate-paths/crate-path-visibility-ambiguity.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-crate-paths/crate-path-visibility-ambiguity.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-crate-paths/crate-path-visibility-ambiguity.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +warning: the feature `crate_in_paths` has been stable since 1.30.0 and no longer requires an attribute to enable + --> $DIR/crate-path-visibility-ambiguity.rs:12:12 + | +LL | #![feature(crate_in_paths)] + | ^^^^^^^^^^^^^^ + | + = note: #[warn(stable_features)] on by default + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[derive(Debug, PartialEq)] +pub struct S; + +#[derive(Debug)] +pub struct Z; + +pub trait Tr<'a> {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/basic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/basic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/basic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/basic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// aux-build:xcrate.rs +// compile-flags:--extern xcrate +// edition:2018 + +use xcrate::Z; + +fn f() { + use xcrate; + use xcrate as ycrate; + let s = xcrate::S; + assert_eq!(format!("{:?}", s), "S"); + let z = ycrate::Z; + assert_eq!(format!("{:?}", z), "Z"); +} + +fn main() { + let s = ::xcrate::S; + assert_eq!(format!("{:?}", s), "S"); + let z = Z; + assert_eq!(format!("{:?}", z), "Z"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/extern.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/extern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/extern.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/extern.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// aux-build:xcrate.rs +// compile-flags:--extern xcrate + +#![feature(extern_in_paths)] + +use extern::xcrate::Z; + +type A = extern::xcrate::S; +type B = for<'a> extern::xcrate::Tr<'a>; + +fn f() { + use extern::xcrate; + use extern::xcrate as ycrate; + let s = xcrate::S; + assert_eq!(format!("{:?}", s), "S"); + let z = ycrate::Z; + assert_eq!(format!("{:?}", z), "Z"); +} + +fn main() { + let s = extern::xcrate::S; + assert_eq!(format!("{:?}", s), "S"); + let z = Z; + assert_eq!(format!("{:?}", z), "Z"); + assert_eq!(A {}, extern::xcrate::S {}); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/test.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/test.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/test.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Check that `#[test]` works with extern-absolute-paths enabled. +// +// Regression test for #47075. + +// edition:2018 +// compile-flags: --test + +#[test] +fn test() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/whitelisted.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/whitelisted.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/whitelisted.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/whitelisted.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// edition:2018 + +// Tests that `core` and `std` are always available. +use core::iter; +use std::io; +// FIXME(eddyb) Add a `meta` crate to the distribution. +// use meta; + +fn main() { + for _ in iter::once(()) { + io::stdout(); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2151-raw-identifiers/attr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2151-raw-identifiers/attr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2151-raw-identifiers/attr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2151-raw-identifiers/attr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::mem; + +#[r#repr(r#C, r#packed)] +struct Test { + a: bool, b: u64 +} + +#[r#derive(r#Debug)] +struct Test2(u32); + +pub fn main() { + assert_eq!(mem::size_of::(), 9); + assert_eq!("Test2(123)", format!("{:?}", Test2(123))); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2151-raw-identifiers/basic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2151-raw-identifiers/basic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2151-raw-identifiers/basic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2151-raw-identifiers/basic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +fn r#fn(r#match: u32) -> u32 { + r#match +} + +pub fn main() { + let r#struct = 1; + assert_eq!(1, r#struct); + + let foo = 2; + assert_eq!(2, r#foo); + + let r#bar = 3; + assert_eq!(3, bar); + + assert_eq!(4, r#fn(4)); + + let r#true = false; + assert_eq!(r#true, false); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2151-raw-identifiers/items.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2151-raw-identifiers/items.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2151-raw-identifiers/items.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2151-raw-identifiers/items.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(Debug, PartialEq, Eq)] +struct IntWrapper(u32); + +#[derive(Debug, Ord, PartialOrd, PartialEq, Eq, Hash, Copy, Clone, Default)] +struct HasKeywordField { + r#struct: u32, +} + +struct Generic(T); + +trait Trait { + fn r#trait(&self) -> u32; +} +impl Trait for Generic { + fn r#trait(&self) -> u32 { + self.0 + } +} + +pub fn main() { + assert_eq!(IntWrapper(1), r#IntWrapper(1)); + + match IntWrapper(2) { + r#IntWrapper(r#struct) => assert_eq!(2, r#struct), + } + + assert_eq!("HasKeywordField { struct: 3 }", format!("{:?}", HasKeywordField { r#struct: 3 })); + + assert_eq!(4, Generic(4).0); + assert_eq!(5, Generic(5).r#trait()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2151-raw-identifiers/macros.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2151-raw-identifiers/macros.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2151-raw-identifiers/macros.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2151-raw-identifiers/macros.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,48 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(decl_macro)] + +r#macro_rules! r#struct { + ($r#struct:expr) => { $r#struct } +} + +macro_rules! old_macro { + ($a:expr) => {$a} +} + +macro r#decl_macro($r#fn:expr) { + $r#fn +} + +macro passthrough($id:ident) { + $id +} + +macro_rules! test_pat_match { + (a) => { 6 }; + (r#a) => { 7 }; +} + +pub fn main() { + r#println!("{struct}", r#struct = 1); + assert_eq!(2, r#struct!(2)); + assert_eq!(3, r#old_macro!(3)); + assert_eq!(4, decl_macro!(4)); + + let r#match = 5; + assert_eq!(5, passthrough!(r#match)); + + assert_eq!("r#struct", stringify!(r#struct)); + + assert_eq!(6, test_pat_match!(a)); + assert_eq!(7, test_pat_match!(r#a)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2175-or-if-while-let/basic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2175-or-if-while-let/basic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2175-or-if-while-let/basic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2175-or-if-while-let/basic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![feature(if_while_or_patterns)] + +enum E { + V(u8), + U(u8), + W, +} +use E::*; + +fn main() { + let mut e = V(10); + + if let V(x) | U(x) = e { + assert_eq!(x, 10); + } + while let V(x) | U(x) = e { + assert_eq!(x, 10); + e = W; + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2302-self-struct-ctor.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2302-self-struct-ctor.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2302-self-struct-ctor.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2302-self-struct-ctor.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,129 @@ +// run-pass + +#![feature(self_struct_ctor)] + +#![allow(dead_code)] + +use std::fmt::Display; + +struct ST1(i32, i32); + +impl ST1 { + fn new() -> Self { + ST1(0, 1) + } + + fn ctor() -> Self { + Self(1,2) // Self as a constructor + } + + fn pattern(self) { + match self { + Self(x, y) => println!("{} {}", x, y), // Self as a pattern + } + } +} + +struct ST2(T); // With type parameter + +impl ST2 where T: Display { + + fn ctor(v: T) -> Self { + Self(v) + } + + fn pattern(&self) { + match self { + Self(ref v) => println!("{}", v), + } + } +} + +struct ST3<'a>(&'a i32); // With lifetime parameter + +impl<'a> ST3<'a> { + + fn ctor(v: &'a i32) -> Self { + Self(v) + } + + fn pattern(self) { + let Self(ref v) = self; + println!("{}", v); + } +} + +struct ST4(usize); + +impl ST4 { + fn map(opt: Option) -> Option { + opt.map(Self) // use `Self` as a function passed somewhere + } +} + +struct ST5; // unit struct + +impl ST5 { + fn ctor() -> Self { + Self // `Self` as a unit struct value + } + + fn pattern(self) -> Self { + match self { + Self => Self, // `Self` as a unit struct value for matching + } + } +} + +struct ST6(i32); +type T = ST6; +impl T { + fn ctor() -> Self { + ST6(1) + } + + fn type_alias(self) { + let Self(_x) = match self { Self(x) => Self(x) }; + let _opt: Option = Some(0).map(Self); + } +} + +struct ST7(T1, T2); + +impl ST7 { + + fn ctor() -> Self { + Self(1, 2) + } + + fn pattern(self) -> Self { + match self { + Self(x, y) => Self(x, y), + } + } +} + +fn main() { + let v1 = ST1::ctor(); + v1.pattern(); + + let v2 = ST2::ctor(10); + v2.pattern(); + + let local = 42; + let v3 = ST3::ctor(&local); + v3.pattern(); + + let v4 = Some(1usize); + let _ = ST4::map(v4); + + let v5 = ST5::ctor(); + v5.pattern(); + + let v6 = ST6::ctor(); + v6.type_alias(); + + let v7 = ST7::::ctor(); + let r = v7.pattern(); + println!("{} {}", r.0, r.1) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2421-unreserve-pure-offsetof-sizeof-alignof.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2421-unreserve-pure-offsetof-sizeof-alignof.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2421-unreserve-pure-offsetof-sizeof-alignof.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rfcs/rfc-2421-unreserve-pure-offsetof-sizeof-alignof.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// Test that removed keywords are allowed as identifiers. +fn main () { + let offsetof = (); + let alignof = (); + let sizeof = (); + let pure = (); +} + +fn offsetof() {} +fn alignof() {} +fn sizeof() {} +fn pure() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rustc-rust-log.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rustc-rust-log.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/rustc-rust-log.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/rustc-rust-log.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// This test is just checking that we won't ICE if logging is turned +// on; don't bother trying to compare that (copious) output. (Note +// also that this test potentially silly, since we do not build+test +// debug versions of rustc as part of our continuous integration +// process...) +// +// dont-check-compiler-stdout +// dont-check-compiler-stderr + // rustc-env:RUST_LOG=debug fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/segfault-no-out-of-stack.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/segfault-no-out-of-stack.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/segfault-no-out-of-stack.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/segfault-no-out-of-stack.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_imports)] // ignore-cloudabi can't run commands // ignore-emscripten can't run commands diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_raw_pointer_struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_raw_pointer_struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_raw_pointer_struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_raw_pointer_struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(arbitrary_self_types)] + +use std::rc::Rc; + +struct Foo(String); + +impl Foo { + unsafe fn foo(self: *const Self) -> *const str { + (*self).0.as_ref() + } + + fn complicated_1(self: *const Rc) -> &'static str { + "Foo::complicated_1" + } + + unsafe fn complicated_2(self: Rc<*const Self>) -> *const str { + (**self).0.as_ref() + } +} + +fn main() { + let foo = Foo("abc123".into()); + assert_eq!("abc123", unsafe { &*(&foo as *const Foo).foo() }); + assert_eq!("Foo::complicated_1", std::ptr::null::>().complicated_1()); + let rc = Rc::new(&foo as *const Foo); + assert_eq!("abc123", unsafe { &*rc.complicated_2()}); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_raw_pointer_trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_raw_pointer_trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_raw_pointer_trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_raw_pointer_trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,71 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(arbitrary_self_types)] + +use std::ptr; + +trait Foo { + fn foo(self: *const Self) -> &'static str; + + unsafe fn bar(self: *const Self) -> i64; + + unsafe fn complicated(self: *const *const Self) -> i64 where Self: Sized { + (*self).bar() + } +} + +impl Foo for i32 { + fn foo(self: *const Self) -> &'static str { + "I'm an i32!" + } + + unsafe fn bar(self: *const Self) -> i64 { + *self as i64 + } +} + +impl Foo for u32 { + fn foo(self: *const Self) -> &'static str { + "I'm a u32!" + } + + unsafe fn bar(self: *const Self) -> i64 { + *self as i64 + } +} + +fn main() { + let null_i32 = ptr::null::() as *const Foo; + let null_u32 = ptr::null::() as *const Foo; + + assert_eq!("I'm an i32!", null_i32.foo()); + assert_eq!("I'm a u32!", null_u32.foo()); + + let valid_i32 = 5i32; + let valid_i32_thin = &valid_i32 as *const i32; + assert_eq!("I'm an i32!", valid_i32_thin.foo()); + assert_eq!(5, unsafe { valid_i32_thin.bar() }); + assert_eq!(5, unsafe { (&valid_i32_thin as *const *const i32).complicated() }); + let valid_i32_fat = valid_i32_thin as *const Foo; + assert_eq!("I'm an i32!", valid_i32_fat.foo()); + assert_eq!(5, unsafe { valid_i32_fat.bar() }); + + let valid_u32 = 18u32; + let valid_u32_thin = &valid_u32 as *const u32; + assert_eq!("I'm a u32!", valid_u32_thin.foo()); + assert_eq!(18, unsafe { valid_u32_thin.bar() }); + assert_eq!(18, unsafe { (&valid_u32_thin as *const *const u32).complicated() }); + let valid_u32_fat = valid_u32_thin as *const Foo; + assert_eq!("I'm a u32!", valid_u32_fat.foo()); + assert_eq!(18, unsafe { valid_u32_fat.bar() }); + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_silly.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_silly.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_silly.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_silly.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(arbitrary_self_types)] + +struct Foo; +struct Bar; + +impl std::ops::Deref for Bar { + type Target = Foo; + + fn deref(&self) -> &Foo { + &Foo + } +} + +impl Foo { + fn bar(self: Bar) -> i32 { 3 } +} + +fn main() { + assert_eq!(3, Bar.bar()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(arbitrary_self_types)] + +use std::rc::Rc; + +struct Foo { + x: i32, + y: i32, +} + +impl Foo { + fn x(self: &Rc) -> i32 { + self.x + } + + fn y(self: Rc) -> i32 { + self.y + } +} + +fn main() { + let foo = Rc::new(Foo {x: 3, y: 4}); + assert_eq!(3, foo.x()); + assert_eq!(4, foo.y()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(arbitrary_self_types)] + +use std::rc::Rc; + +trait Trait { + fn trait_method<'a>(self: &'a Box>) -> &'a [i32]; +} + +impl Trait for Vec { + fn trait_method<'a>(self: &'a Box>) -> &'a [i32] { + &***self + } +} + +fn main() { + let v = vec![1,2,3]; + + assert_eq!(&[1,2,3], Box::new(Rc::new(v)).trait_method()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_unsized_struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_unsized_struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_unsized_struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/arbitrary_self_types_unsized_struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(arbitrary_self_types)] + +use std::rc::Rc; + +struct Foo(T); + +impl Foo<[u8]> { + fn len(self: Rc) -> usize { + self.0.len() + } +} + +fn main() { + let rc = Rc::new(Foo([1u8,2,3])) as Rc>; + assert_eq!(3, rc.len()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/auxiliary/explicit_self_xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/auxiliary/explicit_self_xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/auxiliary/explicit_self_xcrate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/auxiliary/explicit_self_xcrate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait Foo { + #[inline(always)] + fn f(&self); +} + +pub struct Bar { + pub x: String +} + +impl Foo for Bar { + #[inline(always)] + fn f(&self) { + println!("{}", (*self).x); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/builtin-superkinds-self-type.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/builtin-superkinds-self-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/builtin-superkinds-self-type.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/builtin-superkinds-self-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests the ability for the Self type in default methods to use +// capabilities granted by builtin kinds as supertraits. + + +use std::sync::mpsc::{Sender, channel}; + +trait Foo : Send + Sized + 'static { + fn foo(self, tx: Sender) { + tx.send(self).unwrap(); + } +} + +impl Foo for T { } + +pub fn main() { + let (tx, rx) = channel(); + 1193182.foo(tx); + assert_eq!(rx.recv().unwrap(), 1193182); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/by-value-self-in-mut-slot.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/by-value-self-in-mut-slot.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/by-value-self-in-mut-slot.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/by-value-self-in-mut-slot.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +struct X { + a: isize +} + +trait Changer { + fn change(self) -> Self; +} + +impl Changer for X { + fn change(mut self) -> X { + self.a = 55; + self + } +} + +pub fn main() { + let x = X { a: 32 }; + let new_x = x.change(); + assert_eq!(new_x.a, 55); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/explicit-self-closures.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/explicit-self-closures.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/explicit-self-closures.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/explicit-self-closures.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Test to make sure that explicit self params work inside closures + +// pretty-expanded FIXME #23616 + +struct Box { + x: usize +} + +impl Box { + pub fn set_many(&mut self, xs: &[usize]) { + for x in xs { self.x = *x; } + } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/explicit-self-generic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/explicit-self-generic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/explicit-self-generic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/explicit-self-generic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![feature(box_syntax)] + +#[derive(Copy, Clone)] +struct LM { resize_at: usize, size: usize } + +enum HashMap { + HashMap_(LM, Vec<(K,V)>) +} + +fn linear_map() -> HashMap { + HashMap::HashMap_(LM{ + resize_at: 32, + size: 0}, Vec::new()) +} + +impl HashMap { + pub fn len(&mut self) -> usize { + match *self { + HashMap::HashMap_(ref l, _) => l.size + } + } +} + +pub fn main() { + let mut m: Box<_> = box linear_map::<(),()>(); + assert_eq!(m.len(), 0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/explicit-self-objects-uniq.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/explicit-self-objects-uniq.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/explicit-self-objects-uniq.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/explicit-self-objects-uniq.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +trait Foo { + fn f(self: Box); +} + +struct S { + x: isize +} + +impl Foo for S { + fn f(self: Box) { + assert_eq!(self.x, 3); + } +} + +pub fn main() { + let x = box S { x: 3 }; + let y = x as Box; + y.f(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/explicit-self.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/explicit-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/explicit-self.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/explicit-self.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,83 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] +#![allow(non_upper_case_globals)] + +#![feature(box_syntax)] + +static tau: f64 = 2.0*3.14159265358979323; + +struct Point {x: f64, y: f64} +struct Size {w: f64, h: f64} +enum shape { + circle(Point, f64), + rectangle(Point, Size) +} + + +fn compute_area(shape: &shape) -> f64 { + match *shape { + shape::circle(_, radius) => 0.5 * tau * radius * radius, + shape::rectangle(_, ref size) => size.w * size.h + } +} + +impl shape { + // self is in the implicit self region + pub fn select<'r, T>(&self, threshold: f64, a: &'r T, b: &'r T) + -> &'r T { + if compute_area(self) > threshold {a} else {b} + } +} + +fn select_based_on_unit_circle<'r, T>( + threshold: f64, a: &'r T, b: &'r T) -> &'r T { + + let shape = &shape::circle(Point{x: 0.0, y: 0.0}, 1.0); + shape.select(threshold, a, b) +} + +#[derive(Clone)] +struct thing { + x: A +} + +#[derive(Clone)] +struct A { + a: isize +} + +fn thing(x: A) -> thing { + thing { + x: x + } +} + +impl thing { + pub fn bar(self: Box) -> isize { self.x.a } + pub fn quux(&self) -> isize { self.x.a } + pub fn baz<'a>(&'a self) -> &'a A { &self.x } + pub fn spam(self) -> isize { self.x.a } +} + +trait Nus { fn f(&self); } +impl Nus for thing { fn f(&self) {} } + +pub fn main() { + let y: Box<_> = box thing(A {a: 10}); + assert_eq!(y.clone().bar(), 10); + assert_eq!(y.quux(), 10); + + let z = thing(A {a: 11}); + assert_eq!(z.spam(), 11); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/explicit_self_xcrate_exe.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/explicit_self_xcrate_exe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/explicit_self_xcrate_exe.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/explicit_self_xcrate_exe.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:explicit_self_xcrate.rs + +// pretty-expanded FIXME #23616 + +extern crate explicit_self_xcrate; +use explicit_self_xcrate::{Foo, Bar}; + +pub fn main() { + let x = Bar { x: "hello".to_string() }; + x.f(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/move-self.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/move-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/move-self.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/move-self.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct S { + x: String +} + +impl S { + pub fn foo(self) { + self.bar(); + } + + pub fn bar(self) { + println!("{}", self.x); + } +} + +pub fn main() { + let x = S { x: "Hello!".to_string() }; + x.foo(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/object-safety-sized-self-by-value-self.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/object-safety-sized-self-by-value-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/object-safety-sized-self-by-value-self.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/object-safety-sized-self-by-value-self.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,49 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +// Check that a trait is still object-safe (and usable) if it has +// methods with by-value self so long as they require `Self : Sized`. + + +trait Counter { + fn tick(&mut self) -> u32; + fn get(self) -> u32 where Self : Sized; +} + +struct CCounter { + c: u32 +} + +impl Counter for CCounter { + fn tick(&mut self) -> u32 { self.c += 1; self.c } + fn get(self) -> u32 where Self : Sized { self.c } +} + +fn tick1(mut c: C) -> u32 { + tick2(&mut c); + c.get() +} + +fn tick2(c: &mut Counter) { + tick3(c); +} + +fn tick3(c: &mut C) { + c.tick(); + c.tick(); +} + +fn main() { + let mut c = CCounter { c: 0 }; + let value = tick1(c); + assert_eq!(value, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/object-safety-sized-self-generic-method.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/object-safety-sized-self-generic-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/object-safety-sized-self-generic-method.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/object-safety-sized-self-generic-method.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,49 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// Check that a trait is still object-safe (and usable) if it has +// generic methods so long as they require `Self : Sized`. + + +trait Counter { + fn tick(&mut self) -> u32; + fn with(&self, f: F) where Self : Sized; +} + +struct CCounter { + c: u32 +} + +impl Counter for CCounter { + fn tick(&mut self) -> u32 { self.c += 1; self.c } + fn with(&self, f: F) { f(self.c); } +} + +fn tick1(c: &mut C) { + tick2(c); + c.with(|i| ()); +} + +fn tick2(c: &mut Counter) { + tick3(c); +} + +fn tick3(c: &mut C) { + c.tick(); + c.tick(); +} + +fn main() { + let mut c = CCounter { c: 0 }; + tick1(&mut c); + assert_eq!(c.tick(), 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/object-safety-sized-self-return-Self.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/object-safety-sized-self-return-Self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/object-safety-sized-self-return-Self.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/object-safety-sized-self-return-Self.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,49 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Check that a trait is still object-safe (and usable) if it has +// methods that return `Self` so long as they require `Self : Sized`. + + +trait Counter { + fn new() -> Self where Self : Sized; + fn tick(&mut self) -> u32; +} + +struct CCounter { + c: u32 +} + +impl Counter for CCounter { + fn new() -> CCounter { CCounter { c: 0 } } + fn tick(&mut self) -> u32 { self.c += 1; self.c } +} + +fn preticked() -> C { + let mut c: C = Counter::new(); + tick(&mut c); + c +} + +fn tick(c: &mut Counter) { + tick_generic(c); +} + +fn tick_generic(c: &mut C) { + c.tick(); + c.tick(); +} + +fn main() { + let mut c = preticked::(); + tick(&mut c); + assert_eq!(c.tick(), 5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/self-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/self-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/self-impl.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/self-impl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,80 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// Test that we can use `Self` types in impls in the expected way. + +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + +struct Foo; + +// Test uses on inherent impl. +impl Foo { + fn foo(_x: Self, _y: &Self, _z: Box) -> Self { + Foo + } + + fn baz() { + // Test that Self cannot be shadowed. + type Foo = i32; + // There is no empty method on i32. + Self::empty(); + + let _: Self = Foo; + } + + fn empty() {} +} + +// Test uses when implementing a trait and with a type parameter. +pub struct Baz { + pub f: X, +} + +trait SuperBar { + type SuperQux; +} + +trait Bar: SuperBar { + type Qux; + + fn bar(x: Self, y: &Self, z: Box, _: Self::SuperQux) -> Self; + fn dummy(&self, x: X) { } +} + +impl SuperBar for Box> { + type SuperQux = bool; +} + +impl Bar for Box> { + type Qux = i32; + + fn bar(_x: Self, _y: &Self, _z: Box, _: Self::SuperQux) -> Self { + let _: Self::Qux = 42; + let _: >::Qux = 42; + + let _: Self::SuperQux = true; + let _: ::SuperQux = true; + + box Baz { f: 42 } + } +} + +fn main() { + let _: Foo = Foo::foo(Foo, &Foo, box Foo); + let _: Box> = Bar::bar(box Baz { f: 42 }, + &box Baz { f: 42 }, + box box Baz { f: 42 }, + true); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/self-in-mut-slot-default-method.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/self-in-mut-slot-default-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/self-in-mut-slot-default-method.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/self-in-mut-slot-default-method.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +struct X { + a: isize +} + +trait Changer : Sized { + fn change(mut self) -> Self { + self.set_to(55); + self + } + + fn change_again(mut self: Box) -> Box { + self.set_to(45); + self + } + + fn set_to(&mut self, a: isize); +} + +impl Changer for X { + fn set_to(&mut self, a: isize) { + self.a = a; + } +} + +pub fn main() { + let x = X { a: 32 }; + let new_x = x.change(); + assert_eq!(new_x.a, 55); + + let x: Box<_> = box new_x; + let new_x = x.change_again(); + assert_eq!(new_x.a, 45); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/self-in-mut-slot-immediate-value.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/self-in-mut-slot-immediate-value.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/self-in-mut-slot-immediate-value.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/self-in-mut-slot-immediate-value.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Assert that `mut self` on an immediate value doesn't +// allow mutating the original - issue #10615. + + +#[derive(Copy, Clone)] +struct Value { + n: isize +} + +impl Value { + fn squared(mut self) -> Value { + self.n *= self.n; + self + } +} + +pub fn main() { + let x = Value { n: 3 }; + let y = x.squared(); + assert_eq!(x.n, 3); + assert_eq!(y.n, 9); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/self-in-typedefs.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/self-in-typedefs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/self-in-typedefs.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/self-in-typedefs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unions_with_drop_fields)] + +#![feature(self_in_typedefs)] +#![feature(untagged_unions)] + +#![allow(dead_code)] + +enum A<'a, T: 'a> +where + Self: Send, T: PartialEq +{ + Foo(&'a Self), + Bar(T), +} + +struct B<'a, T: 'a> +where + Self: Send, T: PartialEq +{ + foo: &'a Self, + bar: T, +} + +union C<'a, T: 'a> +where + Self: Send, T: PartialEq +{ + foo: &'a Self, + bar: T, +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/self-re-assign.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/self-re-assign.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/self-re-assign.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/self-re-assign.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Ensure assigning an owned or managed variable to itself works. In particular, +// that we do not glue_drop before we glue_take (#3290). + +#![feature(box_syntax)] + +use std::rc::Rc; + +pub fn main() { + let mut x: Box<_> = box 3; + x = x; + assert_eq!(*x, 3); + + let mut x = Rc::new(3); + x = x; + assert_eq!(*x, 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/self-shadowing-import.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/self-shadowing-import.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/self-shadowing-import.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/self-shadowing-import.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +mod a { + pub mod b { + pub mod a { + pub fn foo() -> isize { return 1; } + } + } +} + +mod c { + use a::b::a; + pub fn bar() { assert_eq!(a::foo(), 1); } +} + +pub fn main() { c::bar(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/self-type-param.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/self-type-param.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/self-type-param.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/self-type-param.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +trait MyTrait { + fn f(&self) -> Self; +} + +struct S { + x: isize +} + +impl MyTrait for S { + fn f(&self) -> S { + S { x: 3 } + } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/string-self-append.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/string-self-append.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/string-self-append.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/string-self-append.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub fn main() { + // Make sure we properly handle repeated self-appends. + let mut a: String = "A".to_string(); + let mut i = 20; + let mut expected_len = 1; + while i > 0 { + println!("{}", a.len()); + assert_eq!(a.len(), expected_len); + a = format!("{}{}", a, a); + i -= 1; + expected_len *= 2; + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/ufcs-explicit-self.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/ufcs-explicit-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/ufcs-explicit-self.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/ufcs-explicit-self.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,59 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +#[derive(Copy, Clone)] +struct Foo { + f: isize, +} + +impl Foo { + fn foo(self: Foo, x: isize) -> isize { + self.f + x + } + fn bar(self: &Foo, x: isize) -> isize { + self.f + x + } + fn baz(self: Box, x: isize) -> isize { + self.f + x + } +} + +#[derive(Copy, Clone)] +struct Bar { + f: T, +} + +impl Bar { + fn foo(self: Bar, x: isize) -> isize { + x + } + fn bar<'a>(self: &'a Bar, x: isize) -> isize { + x + } + fn baz(self: Bar, x: isize) -> isize { + x + } +} + +fn main() { + let foo: Box<_> = box Foo { + f: 1, + }; + println!("{} {} {}", foo.foo(2), foo.bar(2), foo.baz(2)); + let bar: Box<_> = box Bar { + f: 1, + }; + println!("{} {} {}", bar.foo(2), bar.bar(2), bar.baz(2)); + let bar: Box> = bar; + println!("{} {} {}", bar.foo(2), bar.bar(2), bar.baz(2)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/uniq-self-in-mut-slot.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/uniq-self-in-mut-slot.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/uniq-self-in-mut-slot.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/uniq-self-in-mut-slot.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +struct X { + a: isize +} + +trait Changer { + fn change(self: Box) -> Box; +} + +impl Changer for X { + fn change(mut self: Box) -> Box { + self.a = 55; + self + } +} + +pub fn main() { + let x: Box<_> = box X { a: 32 }; + let new_x = x.change(); + assert_eq!(new_x.a, 55); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/where-for-self.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/where-for-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/self/where-for-self.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/self/where-for-self.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,61 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we can quantify lifetimes outside a constraint (i.e., including +// the self type) in a where clause. + + +static mut COUNT: u32 = 1; + +trait Bar<'a> { + fn bar(&self); +} + +trait Baz<'a> +{ + fn baz(&self); +} + +impl<'a, 'b> Bar<'b> for &'a u32 { + fn bar(&self) { + unsafe { COUNT *= 2; } + } +} + +impl<'a, 'b> Baz<'b> for &'a u32 { + fn baz(&self) { + unsafe { COUNT *= 3; } + } +} + +// Test we can use the syntax for HRL including the self type. +fn foo1(x: &T) + where for<'a, 'b> &'a T: Bar<'b> +{ + x.bar() +} + +// Test we can quantify multiple bounds (i.e., the precedence is sensible). +fn foo2(x: &T) + where for<'a, 'b> &'a T: Bar<'b> + Baz<'b> +{ + x.baz(); + x.bar() +} + +fn main() { + let x = 42; + foo1(&x); + foo2(&x); + unsafe { + assert_eq!(COUNT, 12); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/semistatement-in-lambda.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/semistatement-in-lambda.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/semistatement-in-lambda.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/semistatement-in-lambda.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_must_use)] pub fn main() { // Test that lambdas behave as unary expressions with block-like expressions diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sepcomp/auxiliary/sepcomp_cci_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sepcomp/auxiliary/sepcomp_cci_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sepcomp/auxiliary/sepcomp_cci_lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sepcomp/auxiliary/sepcomp_cci_lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[inline] +pub fn cci_fn() -> usize { + 1200 +} + +pub const CCI_CONST: usize = 34; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sepcomp/auxiliary/sepcomp-extern-lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sepcomp/auxiliary/sepcomp-extern-lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sepcomp/auxiliary/sepcomp-extern-lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sepcomp/auxiliary/sepcomp-extern-lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[no_mangle] +pub extern "C" fn foo() -> usize { + 1234 +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sepcomp/auxiliary/sepcomp_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sepcomp/auxiliary/sepcomp_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sepcomp/auxiliary/sepcomp_lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sepcomp/auxiliary/sepcomp_lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -C codegen-units=3 --crate-type=rlib,dylib -g + +pub mod a { + pub fn one() -> usize { + 1 + } +} + +pub mod b { + pub fn two() -> usize { + 2 + } +} + +pub mod c { + use a::one; + use b::two; + pub fn three() -> usize { + one() + two() + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-cci.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-cci.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-cci.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-cci.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-bitrig +// compile-flags: -C codegen-units=3 +// aux-build:sepcomp_cci_lib.rs + +// Test accessing cross-crate inlined items from multiple compilation units. + + +extern crate sepcomp_cci_lib; +use sepcomp_cci_lib::{cci_fn, CCI_CONST}; + +fn call1() -> usize { + cci_fn() + CCI_CONST +} + +mod a { + use sepcomp_cci_lib::{cci_fn, CCI_CONST}; + pub fn call2() -> usize { + cci_fn() + CCI_CONST + } +} + +mod b { + use sepcomp_cci_lib::{cci_fn, CCI_CONST}; + pub fn call3() -> usize { + cci_fn() + CCI_CONST + } +} + +fn main() { + assert_eq!(call1(), 1234); + assert_eq!(a::call2(), 1234); + assert_eq!(b::call3(), 1234); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-extern.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-extern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-extern.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-extern.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-bitrig +// compile-flags: -C codegen-units=3 +// aux-build:sepcomp-extern-lib.rs + +// Test accessing external items from multiple compilation units. + +extern crate sepcomp_extern_lib; + +extern { + fn foo() -> usize; +} + +fn call1() -> usize { + unsafe { foo() } +} + +mod a { + pub fn call2() -> usize { + unsafe { ::foo() } + } +} + +mod b { + pub fn call3() -> usize { + unsafe { ::foo() } + } +} + +fn main() { + assert_eq!(call1(), 1234); + assert_eq!(a::call2(), 1234); + assert_eq!(b::call3(), 1234); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-fns-backwards.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-fns-backwards.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-fns-backwards.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-fns-backwards.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// ignore-bitrig +// compile-flags: -C codegen-units=3 + +// Test references to items that haven't been codegened yet. + +// Generate some code in the first compilation unit before declaring any +// modules. This ensures that the first module doesn't go into the same +// compilation unit as the top-level module. + +fn pad() -> usize { 0 } + +mod b { + pub fn three() -> usize { + ::one() + ::a::two() + } +} + +mod a { + pub fn two() -> usize { + ::one() + ::one() + } +} + +fn one() -> usize { + 1 +} + +fn main() { + assert_eq!(one(), 1); + assert_eq!(a::two(), 2); + assert_eq!(b::three(), 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-fns.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-fns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-fns.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-fns.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-bitrig +// compile-flags: -C codegen-units=3 + +// Test basic separate compilation functionality. The functions should be able +// to call each other even though they will be placed in different compilation +// units. + +// Generate some code in the first compilation unit before declaring any +// modules. This ensures that the first module doesn't go into the same +// compilation unit as the top-level module. + +fn one() -> usize { 1 } + +mod a { + pub fn two() -> usize { + ::one() + ::one() + } +} + +mod b { + pub fn three() -> usize { + ::one() + ::a::two() + } +} + +fn main() { + assert_eq!(one(), 1); + assert_eq!(a::two(), 2); + assert_eq!(b::three(), 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-lib-lto.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-lib-lto.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-lib-lto.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-lib-lto.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Check that we can use `-C lto` when linking against libraries that were +// separately compiled. + +// aux-build:sepcomp_lib.rs +// compile-flags: -C lto -g +// no-prefer-dynamic + +extern crate sepcomp_lib; +use sepcomp_lib::a::one; +use sepcomp_lib::b::two; +use sepcomp_lib::c::three; + +fn main() { + assert_eq!(one(), 1); + assert_eq!(two(), 2); + assert_eq!(three(), 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:sepcomp_lib.rs + +// Test linking against a library built with -C codegen-units > 1 + + +extern crate sepcomp_lib; +use sepcomp_lib::a::one; +use sepcomp_lib::b::two; +use sepcomp_lib::c::three; + +fn main() { + assert_eq!(one(), 1); + assert_eq!(two(), 2); + assert_eq!(three(), 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-statics.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-statics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-statics.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-statics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// ignore-bitrig +// compile-flags: -C codegen-units=3 + +// Test references to static items across compilation units. + + +fn pad() -> usize { 0 } + +const ONE: usize = 1; + +mod b { + // Separate compilation always switches to the LLVM module with the fewest + // instructions. Make sure we have some instructions in this module so + // that `a` and `b` don't go into the same compilation unit. + fn pad() -> usize { 0 } + + pub static THREE: usize = ::ONE + ::a::TWO; +} + +mod a { + fn pad() -> usize { 0 } + + pub const TWO: usize = ::ONE + ::ONE; +} + +fn main() { + assert_eq!(ONE, 1); + assert_eq!(a::TWO, 2); + assert_eq!(b::THREE, 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-unwind.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-unwind.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-unwind.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sepcomp/sepcomp-unwind.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// ignore-bitrig +// compile-flags: -C codegen-units=3 +// ignore-emscripten no threads support + +// Test unwinding through multiple compilation units. + +// According to acrichto, in the distant past `ld -r` (which is used during +// linking when codegen-units > 1) was known to produce object files with +// damaged unwinding tables. This may be related to GNU binutils bug #6893 +// ("Partial linking results in corrupt .eh_frame_hdr"), but I'm not certain. +// In any case, this test should let us know if enabling parallel codegen ever +// breaks unwinding. + + +use std::thread; + +fn pad() -> usize { 0 } + +mod a { + pub fn f() { + panic!(); + } +} + +mod b { + pub fn g() { + ::a::f(); + } +} + +fn main() { + thread::spawn(move|| { ::b::g() }).join().unwrap_err(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/shadowed-use-visibility.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/shadowed-use-visibility.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/shadowed-use-visibility.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/shadowed-use-visibility.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_imports)] mod foo { pub fn f() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/shadow.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/shadow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/shadow.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/shadow.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(dead_code)] fn foo(c: Vec ) { let a: isize = 5; let mut b: Vec = Vec::new(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sigpipe-should-be-ignored.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sigpipe-should-be-ignored.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sigpipe-should-be-ignored.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sigpipe-should-be-ignored.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_must_use)] // Be sure that when a SIGPIPE would have been received that the entire process // doesn't die in a ball of fire, but rather it's gracefully handled. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-generics.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-generics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-generics.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-generics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,49 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + + + +#![feature(repr_simd, platform_intrinsics)] + +use std::ops; + +#[repr(simd)] +#[derive(Copy, Clone)] +struct f32x4(f32, f32, f32, f32); + +extern "platform-intrinsic" { + fn simd_add(x: T, y: T) -> T; +} + +fn add>(lhs: T, rhs: T) -> T { + lhs + rhs +} + +impl ops::Add for f32x4 { + type Output = f32x4; + + fn add(self, rhs: f32x4) -> f32x4 { + unsafe {simd_add(self, rhs)} + } +} + +pub fn main() { + let lr = f32x4(1.0f32, 2.0f32, 3.0f32, 4.0f32); + + // lame-o + let f32x4(x, y, z, w) = add(lr, lr); + assert_eq!(x, 2.0f32); + assert_eq!(y, 4.0f32); + assert_eq!(z, 6.0f32); + assert_eq!(w, 8.0f32); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-float-math.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-float-math.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-float-math.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-float-math.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,113 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten +// ignore-android + +// FIXME: this test fails on arm-android because the NDK version 14 is too old. +// It needs at least version 18. We disable it on all android build bots because +// there is no way in compile-test to disable it for an (arch,os) pair. + +// Test that the simd floating-point math intrinsics produce correct results. + +#![feature(repr_simd, platform_intrinsics)] +#![allow(non_camel_case_types)] + +#[repr(simd)] +#[derive(Copy, Clone, PartialEq, Debug)] +struct f32x4(pub f32, pub f32, pub f32, pub f32); + +extern "platform-intrinsic" { + fn simd_fsqrt(x: T) -> T; + fn simd_fabs(x: T) -> T; + fn simd_fsin(x: T) -> T; + fn simd_fcos(x: T) -> T; + fn simd_ceil(x: T) -> T; + fn simd_fexp(x: T) -> T; + fn simd_fexp2(x: T) -> T; + fn simd_floor(x: T) -> T; + fn simd_fma(x: T, y: T, z: T) -> T; + fn simd_flog(x: T) -> T; + fn simd_flog10(x: T) -> T; + fn simd_flog2(x: T) -> T; + fn simd_fpow(x: T, y: T) -> T; + fn simd_fpowi(x: T, y: i32) -> T; +} + +macro_rules! assert_approx_eq_f32 { + ($a:expr, $b:expr) => ({ + let (a, b) = (&$a, &$b); + assert!((*a - *b).abs() < 1.0e-6, + "{} is not approximately equal to {}", *a, *b); + }) +} +macro_rules! assert_approx_eq { + ($a:expr, $b:expr) => ({ + let a = $a; + let b = $b; + assert_approx_eq_f32!(a.0, b.0); + assert_approx_eq_f32!(a.1, b.1); + assert_approx_eq_f32!(a.2, b.2); + assert_approx_eq_f32!(a.3, b.3); + }) +} + +fn main() { + let x = f32x4(1.0, 1.0, 1.0, 1.0); + let y = f32x4(-1.0, -1.0, -1.0, -1.0); + let z = f32x4(0.0, 0.0, 0.0, 0.0); + + let h = f32x4(0.5, 0.5, 0.5, 0.5); + + unsafe { + let r = simd_fabs(y); + assert_approx_eq!(x, r); + + let r = simd_fcos(z); + assert_approx_eq!(x, r); + + let r = simd_ceil(h); + assert_approx_eq!(x, r); + + let r = simd_fexp(z); + assert_approx_eq!(x, r); + + let r = simd_fexp2(z); + assert_approx_eq!(x, r); + + let r = simd_floor(h); + assert_approx_eq!(z, r); + + let r = simd_fma(x, h, h); + assert_approx_eq!(x, r); + + let r = simd_fsqrt(x); + assert_approx_eq!(x, r); + + let r = simd_flog(x); + assert_approx_eq!(z, r); + + let r = simd_flog2(x); + assert_approx_eq!(z, r); + + let r = simd_flog10(x); + assert_approx_eq!(z, r); + + let r = simd_fpow(h, x); + assert_approx_eq!(h, r); + + let r = simd_fpowi(h, 1); + assert_approx_eq!(h, r); + + let r = simd_fsin(z); + assert_approx_eq!(z, r); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-float-minmax.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-float-minmax.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-float-minmax.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-float-minmax.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,64 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten +// min-llvm-version 7.0 +// error-pattern: panicked + +// Test that the simd_f{min,max} intrinsics produce the correct results. + +#![feature(repr_simd, platform_intrinsics)] +#![allow(non_camel_case_types)] + +#[repr(simd)] +#[derive(Copy, Clone, PartialEq, Debug)] +struct f32x4(pub f32, pub f32, pub f32, pub f32); + +extern "platform-intrinsic" { + fn simd_fmin(x: T, y: T) -> T; + fn simd_fmax(x: T, y: T) -> T; +} + +fn main() { + let x = f32x4(1.0, 2.0, 3.0, 4.0); + let y = f32x4(2.0, 1.0, 4.0, 3.0); + + #[cfg(not(any(target_arch = "mips", target_arch = "mips64")))] + let nan = ::std::f32::NAN; + // MIPS hardware treats f32::NAN as SNAN. Clear the signaling bit. + // See https://github.com/rust-lang/rust/issues/52746. + #[cfg(any(target_arch = "mips", target_arch = "mips64"))] + let nan = f32::from_bits(::std::f32::NAN.to_bits() - 1); + + let n = f32x4(nan, nan, nan, nan); + + unsafe { + let min0 = simd_fmin(x, y); + let min1 = simd_fmin(y, x); + assert_eq!(min0, min1); + let e = f32x4(1.0, 1.0, 3.0, 3.0); + assert_eq!(min0, e); + let minn = simd_fmin(x, n); + assert_eq!(minn, x); + let minn = simd_fmin(y, n); + assert_eq!(minn, y); + + let max0 = simd_fmax(x, y); + let max1 = simd_fmax(y, x); + assert_eq!(max0, max1); + let e = f32x4(2.0, 2.0, 4.0, 4.0); + assert_eq!(max0, e); + let maxn = simd_fmax(x, n); + assert_eq!(maxn, x); + let maxn = simd_fmax(y, n); + assert_eq!(maxn, y); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-arithmetic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-arithmetic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-arithmetic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-arithmetic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,130 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +// ignore-emscripten FIXME(#45351) hits an LLVM assert + +#![feature(repr_simd, platform_intrinsics)] + +#[repr(simd)] +#[derive(Copy, Clone)] +struct i32x4(pub i32, pub i32, pub i32, pub i32); + +#[repr(simd)] +#[derive(Copy, Clone)] +struct u32x4(pub u32, pub u32, pub u32, pub u32); + +#[repr(simd)] +#[derive(Copy, Clone)] +struct f32x4(pub f32, pub f32, pub f32, pub f32); + +macro_rules! all_eq { + ($a: expr, $b: expr) => {{ + let a = $a; + let b = $b; + assert!(a.0 == b.0 && a.1 == b.1 && a.2 == b.2 && a.3 == b.3); + }} +} + +extern "platform-intrinsic" { + fn simd_add(x: T, y: T) -> T; + fn simd_sub(x: T, y: T) -> T; + fn simd_mul(x: T, y: T) -> T; + fn simd_div(x: T, y: T) -> T; + fn simd_rem(x: T, y: T) -> T; + fn simd_shl(x: T, y: T) -> T; + fn simd_shr(x: T, y: T) -> T; + fn simd_and(x: T, y: T) -> T; + fn simd_or(x: T, y: T) -> T; + fn simd_xor(x: T, y: T) -> T; +} + +fn main() { + let x1 = i32x4(1, 2, 3, 4); + let y1 = u32x4(1, 2, 3, 4); + let z1 = f32x4(1.0, 2.0, 3.0, 4.0); + let x2 = i32x4(2, 3, 4, 5); + let y2 = u32x4(2, 3, 4, 5); + let z2 = f32x4(2.0, 3.0, 4.0, 5.0); + + unsafe { + all_eq!(simd_add(x1, x2), i32x4(3, 5, 7, 9)); + all_eq!(simd_add(x2, x1), i32x4(3, 5, 7, 9)); + all_eq!(simd_add(y1, y2), u32x4(3, 5, 7, 9)); + all_eq!(simd_add(y2, y1), u32x4(3, 5, 7, 9)); + all_eq!(simd_add(z1, z2), f32x4(3.0, 5.0, 7.0, 9.0)); + all_eq!(simd_add(z2, z1), f32x4(3.0, 5.0, 7.0, 9.0)); + + all_eq!(simd_mul(x1, x2), i32x4(2, 6, 12, 20)); + all_eq!(simd_mul(x2, x1), i32x4(2, 6, 12, 20)); + all_eq!(simd_mul(y1, y2), u32x4(2, 6, 12, 20)); + all_eq!(simd_mul(y2, y1), u32x4(2, 6, 12, 20)); + all_eq!(simd_mul(z1, z2), f32x4(2.0, 6.0, 12.0, 20.0)); + all_eq!(simd_mul(z2, z1), f32x4(2.0, 6.0, 12.0, 20.0)); + + all_eq!(simd_sub(x2, x1), i32x4(1, 1, 1, 1)); + all_eq!(simd_sub(x1, x2), i32x4(-1, -1, -1, -1)); + all_eq!(simd_sub(y2, y1), u32x4(1, 1, 1, 1)); + all_eq!(simd_sub(y1, y2), u32x4(!0, !0, !0, !0)); + all_eq!(simd_sub(z2, z1), f32x4(1.0, 1.0, 1.0, 1.0)); + all_eq!(simd_sub(z1, z2), f32x4(-1.0, -1.0, -1.0, -1.0)); + + all_eq!(simd_div(x1, x1), i32x4(1, 1, 1, 1)); + all_eq!(simd_div(i32x4(2, 4, 6, 8), i32x4(2, 2, 2, 2)), x1); + all_eq!(simd_div(y1, y1), u32x4(1, 1, 1, 1)); + all_eq!(simd_div(u32x4(2, 4, 6, 8), u32x4(2, 2, 2, 2)), y1); + all_eq!(simd_div(z1, z1), f32x4(1.0, 1.0, 1.0, 1.0)); + all_eq!(simd_div(z1, z2), f32x4(1.0/2.0, 2.0/3.0, 3.0/4.0, 4.0/5.0)); + all_eq!(simd_div(z2, z1), f32x4(2.0/1.0, 3.0/2.0, 4.0/3.0, 5.0/4.0)); + + all_eq!(simd_rem(x1, x1), i32x4(0, 0, 0, 0)); + all_eq!(simd_rem(x2, x1), i32x4(0, 1, 1, 1)); + all_eq!(simd_rem(y1, y1), u32x4(0, 0, 0, 0)); + all_eq!(simd_rem(y2, y1), u32x4(0, 1, 1, 1)); + all_eq!(simd_rem(z1, z1), f32x4(0.0, 0.0, 0.0, 0.0)); + all_eq!(simd_rem(z1, z2), z1); + all_eq!(simd_rem(z2, z1), f32x4(0.0, 1.0, 1.0, 1.0)); + + all_eq!(simd_shl(x1, x2), i32x4(1 << 2, 2 << 3, 3 << 4, 4 << 5)); + all_eq!(simd_shl(x2, x1), i32x4(2 << 1, 3 << 2, 4 << 3, 5 << 4)); + all_eq!(simd_shl(y1, y2), u32x4(1 << 2, 2 << 3, 3 << 4, 4 << 5)); + all_eq!(simd_shl(y2, y1), u32x4(2 << 1, 3 << 2, 4 << 3, 5 << 4)); + + // test right-shift by assuming left-shift is correct + all_eq!(simd_shr(simd_shl(x1, x2), x2), x1); + all_eq!(simd_shr(simd_shl(x2, x1), x1), x2); + all_eq!(simd_shr(simd_shl(y1, y2), y2), y1); + all_eq!(simd_shr(simd_shl(y2, y1), y1), y2); + + // ensure we get logical vs. arithmetic shifts correct + let (a, b, c, d) = (-12, -123, -1234, -12345); + all_eq!(simd_shr(i32x4(a, b, c, d), x1), i32x4(a >> 1, b >> 2, c >> 3, d >> 4)); + all_eq!(simd_shr(u32x4(a as u32, b as u32, c as u32, d as u32), y1), + u32x4((a as u32) >> 1, (b as u32) >> 2, (c as u32) >> 3, (d as u32) >> 4)); + + all_eq!(simd_and(x1, x2), i32x4(0, 2, 0, 4)); + all_eq!(simd_and(x2, x1), i32x4(0, 2, 0, 4)); + all_eq!(simd_and(y1, y2), u32x4(0, 2, 0, 4)); + all_eq!(simd_and(y2, y1), u32x4(0, 2, 0, 4)); + + all_eq!(simd_or(x1, x2), i32x4(3, 3, 7, 5)); + all_eq!(simd_or(x2, x1), i32x4(3, 3, 7, 5)); + all_eq!(simd_or(y1, y2), u32x4(3, 3, 7, 5)); + all_eq!(simd_or(y2, y1), u32x4(3, 3, 7, 5)); + + all_eq!(simd_xor(x1, x2), i32x4(3, 1, 7, 1)); + all_eq!(simd_xor(x2, x1), i32x4(3, 1, 7, 1)); + all_eq!(simd_xor(y1, y2), u32x4(3, 1, 7, 1)); + all_eq!(simd_xor(y2, y1), u32x4(3, 1, 7, 1)); + + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-cast.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-cast.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-cast.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,131 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// ignore-emscripten FIXME(#45351) hits an LLVM assert + +#![feature(repr_simd, platform_intrinsics, concat_idents, test)] +#![allow(non_camel_case_types)] + +extern crate test; + +#[repr(simd)] +#[derive(PartialEq, Debug)] +struct i32x4(i32, i32, i32, i32); +#[repr(simd)] +#[derive(PartialEq, Debug)] +struct i8x4(i8, i8, i8, i8); + +#[repr(simd)] +#[derive(PartialEq, Debug)] +struct u32x4(u32, u32, u32, u32); +#[repr(simd)] +#[derive(PartialEq, Debug)] +struct u8x4(u8, u8, u8, u8); + +#[repr(simd)] +#[derive(PartialEq, Debug)] +struct f32x4(f32, f32, f32, f32); + +#[repr(simd)] +#[derive(PartialEq, Debug)] +struct f64x4(f64, f64, f64, f64); + + +extern "platform-intrinsic" { + fn simd_cast(x: T) -> U; +} + +const A: i32 = -1234567; +const B: i32 = 12345678; +const C: i32 = -123456789; +const D: i32 = 1234567890; + +trait Foo { + fn is_float() -> bool { false } + fn in_range(x: i32) -> bool; +} +impl Foo for i32 { + fn in_range(_: i32) -> bool { true } +} +impl Foo for i8 { + fn in_range(x: i32) -> bool { -128 <= x && x < 128 } +} +impl Foo for u32 { + fn in_range(x: i32) -> bool { 0 <= x } +} +impl Foo for u8 { + fn in_range(x: i32) -> bool { 0 <= x && x < 128 } +} +impl Foo for f32 { + fn is_float() -> bool { true } + fn in_range(_: i32) -> bool { true } +} +impl Foo for f64 { + fn is_float() -> bool { true } + fn in_range(_: i32) -> bool { true } +} + +fn main() { + macro_rules! test { + ($from: ident, $to: ident) => {{ + // force the casts to actually happen, or else LLVM/rustc + // may fold them and get slightly different results. + let (a, b, c, d) = test::black_box((A as $from, B as $from, C as $from, D as $from)); + // the SIMD vectors are all FOOx4, so we can concat_idents + // so we don't have to pass in the extra args to the macro + let mut from = simd_cast(concat_idents!($from, x4)(a, b, c, d)); + let mut to = concat_idents!($to, x4)(a as $to, + b as $to, + c as $to, + d as $to); + // assist type inference, it needs to know what `from` is + // for the `if` statements. + to == from; + + // there are platform differences for some out of range + // casts, so we just normalize such things: it's OK for + // "invalid" calculations to result in nonsense answers. + // (E.g. negative float to unsigned integer goes through a + // library routine on the default i686 platforms, and the + // implementation of that routine differs on e.g. Linux + // vs. macOS, resulting in different answers.) + if $from::is_float() { + if !$to::in_range(A) { from.0 = 0 as $to; to.0 = 0 as $to; } + if !$to::in_range(B) { from.1 = 0 as $to; to.1 = 0 as $to; } + if !$to::in_range(C) { from.2 = 0 as $to; to.2 = 0 as $to; } + if !$to::in_range(D) { from.3 = 0 as $to; to.3 = 0 as $to; } + } + + assert!(to == from, + "{} -> {} ({:?} != {:?})", stringify!($from), stringify!($to), + from, to); + }} + } + macro_rules! tests { + (: $($to: ident),*) => { () }; + // repeating the list twice is easier than writing a cartesian + // product macro + ($from: ident $(, $from_: ident)*: $($to: ident),*) => { + fn $from() { unsafe { $( test!($from, $to); )* } } + tests!($($from_),*: $($to),*) + }; + ($($types: ident),*) => {{ + tests!($($types),* : $($types),*); + $($types();)* + }} + } + + // test various combinations, including truncation, + // signed/unsigned extension, and floating point casts. + tests!(i32, i8, u32, u8, f32); + tests!(i32, u32, f32, f64) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-comparison.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-comparison.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-comparison.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-comparison.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,116 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten FIXME(#45351) hits an LLVM assert + +#![feature(repr_simd, platform_intrinsics, concat_idents)] +#![allow(non_camel_case_types)] + +use std::f32::NAN; + +#[repr(simd)] +#[derive(Copy, Clone)] +struct i32x4(i32, i32, i32, i32); +#[repr(simd)] +#[derive(Copy, Clone)] +struct u32x4(pub u32, pub u32, pub u32, pub u32); +#[repr(simd)] +#[derive(Copy, Clone)] +struct f32x4(pub f32, pub f32, pub f32, pub f32); + +extern "platform-intrinsic" { + fn simd_eq(x: T, y: T) -> U; + fn simd_ne(x: T, y: T) -> U; + fn simd_lt(x: T, y: T) -> U; + fn simd_le(x: T, y: T) -> U; + fn simd_gt(x: T, y: T) -> U; + fn simd_ge(x: T, y: T) -> U; +} + +macro_rules! cmp { + ($method: ident($lhs: expr, $rhs: expr)) => {{ + let lhs = $lhs; + let rhs = $rhs; + let e: u32x4 = concat_idents!(simd_, $method)($lhs, $rhs); + // assume the scalar version is correct/the behaviour we want. + assert!((e.0 != 0) == lhs.0 .$method(&rhs.0)); + assert!((e.1 != 0) == lhs.1 .$method(&rhs.1)); + assert!((e.2 != 0) == lhs.2 .$method(&rhs.2)); + assert!((e.3 != 0) == lhs.3 .$method(&rhs.3)); + }} +} +macro_rules! tests { + ($($lhs: ident, $rhs: ident;)*) => {{ + $( + (|| { + cmp!(eq($lhs, $rhs)); + cmp!(ne($lhs, $rhs)); + + // test both directions + cmp!(lt($lhs, $rhs)); + cmp!(lt($rhs, $lhs)); + + cmp!(le($lhs, $rhs)); + cmp!(le($rhs, $lhs)); + + cmp!(gt($lhs, $rhs)); + cmp!(gt($rhs, $lhs)); + + cmp!(ge($lhs, $rhs)); + cmp!(ge($rhs, $lhs)); + })(); + )* + }} +} +fn main() { + // 13 vs. -100 tests that we get signed vs. unsigned comparisons + // correct (i32: 13 > -100, u32: 13 < -100). let i1 = i32x4(10, -11, 12, 13); + let i1 = i32x4(10, -11, 12, 13); + let i2 = i32x4(5, -5, 20, -100); + let i3 = i32x4(10, -11, 20, -100); + + let u1 = u32x4(10, !11+1, 12, 13); + let u2 = u32x4(5, !5+1, 20, !100+1); + let u3 = u32x4(10, !11+1, 20, !100+1); + + let f1 = f32x4(10.0, -11.0, 12.0, 13.0); + let f2 = f32x4(5.0, -5.0, 20.0, -100.0); + let f3 = f32x4(10.0, -11.0, 20.0, -100.0); + + unsafe { + tests! { + i1, i1; + u1, u1; + f1, f1; + + i1, i2; + u1, u2; + f1, f2; + + i1, i3; + u1, u3; + f1, f3; + } + } + + // NAN comparisons are special: + // -11 (*) 13 + // -5 -100 (*) + let f4 = f32x4(NAN, f1.1, NAN, f2.3); + + unsafe { + tests! { + f1, f4; + f2, f4; + f4, f4; + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-elements.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-elements.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-elements.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-elements.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,135 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten FIXME(#45351) hits an LLVM assert + +#![feature(repr_simd, platform_intrinsics)] + +#[repr(simd)] +#[derive(Copy, Clone, Debug, PartialEq)] +#[allow(non_camel_case_types)] +struct i32x2(i32, i32); +#[repr(simd)] +#[derive(Copy, Clone, Debug, PartialEq)] +#[allow(non_camel_case_types)] +struct i32x3(i32, i32, i32); +#[repr(simd)] +#[derive(Copy, Clone, Debug, PartialEq)] +#[allow(non_camel_case_types)] +struct i32x4(i32, i32, i32, i32); +#[repr(simd)] +#[derive(Copy, Clone, Debug, PartialEq)] +#[allow(non_camel_case_types)] +struct i32x8(i32, i32, i32, i32, + i32, i32, i32, i32); + +extern "platform-intrinsic" { + fn simd_insert(x: T, idx: u32, y: E) -> T; + fn simd_extract(x: T, idx: u32) -> E; + + fn simd_shuffle2(x: T, y: T, idx: [u32; 2]) -> U; + fn simd_shuffle3(x: T, y: T, idx: [u32; 3]) -> U; + fn simd_shuffle4(x: T, y: T, idx: [u32; 4]) -> U; + fn simd_shuffle8(x: T, y: T, idx: [u32; 8]) -> U; +} + +macro_rules! all_eq { + ($a: expr, $b: expr) => {{ + let a = $a; + let b = $b; + // type inference works better with the concrete type on the + // left, but humans work better with the expected on the + // right. + assert!(b == a, + "{:?} != {:?}", a, b); + }} +} + +fn main() { + let x2 = i32x2(20, 21); + let x3 = i32x3(30, 31, 32); + let x4 = i32x4(40, 41, 42, 43); + let x8 = i32x8(80, 81, 82, 83, 84, 85, 86, 87); + unsafe { + all_eq!(simd_insert(x2, 0, 100), i32x2(100, 21)); + all_eq!(simd_insert(x2, 1, 100), i32x2(20, 100)); + + all_eq!(simd_insert(x3, 0, 100), i32x3(100, 31, 32)); + all_eq!(simd_insert(x3, 1, 100), i32x3(30, 100, 32)); + all_eq!(simd_insert(x3, 2, 100), i32x3(30, 31, 100)); + + all_eq!(simd_insert(x4, 0, 100), i32x4(100, 41, 42, 43)); + all_eq!(simd_insert(x4, 1, 100), i32x4(40, 100, 42, 43)); + all_eq!(simd_insert(x4, 2, 100), i32x4(40, 41, 100, 43)); + all_eq!(simd_insert(x4, 3, 100), i32x4(40, 41, 42, 100)); + + all_eq!(simd_insert(x8, 0, 100), i32x8(100, 81, 82, 83, 84, 85, 86, 87)); + all_eq!(simd_insert(x8, 1, 100), i32x8(80, 100, 82, 83, 84, 85, 86, 87)); + all_eq!(simd_insert(x8, 2, 100), i32x8(80, 81, 100, 83, 84, 85, 86, 87)); + all_eq!(simd_insert(x8, 3, 100), i32x8(80, 81, 82, 100, 84, 85, 86, 87)); + all_eq!(simd_insert(x8, 4, 100), i32x8(80, 81, 82, 83, 100, 85, 86, 87)); + all_eq!(simd_insert(x8, 5, 100), i32x8(80, 81, 82, 83, 84, 100, 86, 87)); + all_eq!(simd_insert(x8, 6, 100), i32x8(80, 81, 82, 83, 84, 85, 100, 87)); + all_eq!(simd_insert(x8, 7, 100), i32x8(80, 81, 82, 83, 84, 85, 86, 100)); + + all_eq!(simd_extract(x2, 0), 20); + all_eq!(simd_extract(x2, 1), 21); + + all_eq!(simd_extract(x3, 0), 30); + all_eq!(simd_extract(x3, 1), 31); + all_eq!(simd_extract(x3, 2), 32); + + all_eq!(simd_extract(x4, 0), 40); + all_eq!(simd_extract(x4, 1), 41); + all_eq!(simd_extract(x4, 2), 42); + all_eq!(simd_extract(x4, 3), 43); + + all_eq!(simd_extract(x8, 0), 80); + all_eq!(simd_extract(x8, 1), 81); + all_eq!(simd_extract(x8, 2), 82); + all_eq!(simd_extract(x8, 3), 83); + all_eq!(simd_extract(x8, 4), 84); + all_eq!(simd_extract(x8, 5), 85); + all_eq!(simd_extract(x8, 6), 86); + all_eq!(simd_extract(x8, 7), 87); + } + + let y2 = i32x2(120, 121); + let y3 = i32x3(130, 131, 132); + let y4 = i32x4(140, 141, 142, 143); + let y8 = i32x8(180, 181, 182, 183, 184, 185, 186, 187); + unsafe { + all_eq!(simd_shuffle2(x2, y2, [3, 0]), i32x2(121, 20)); + all_eq!(simd_shuffle3(x2, y2, [3, 0, 1]), i32x3(121, 20, 21)); + all_eq!(simd_shuffle4(x2, y2, [3, 0, 1, 2]), i32x4(121, 20, 21, 120)); + all_eq!(simd_shuffle8(x2, y2, [3, 0, 1, 2, 1, 2, 3, 0]), + i32x8(121, 20, 21, 120, 21, 120, 121, 20)); + + all_eq!(simd_shuffle2(x3, y3, [4, 2]), i32x2(131, 32)); + all_eq!(simd_shuffle3(x3, y3, [4, 2, 3]), i32x3(131, 32, 130)); + all_eq!(simd_shuffle4(x3, y3, [4, 2, 3, 0]), i32x4(131, 32, 130, 30)); + all_eq!(simd_shuffle8(x3, y3, [4, 2, 3, 0, 1, 5, 5, 1]), + i32x8(131, 32, 130, 30, 31, 132, 132, 31)); + + all_eq!(simd_shuffle2(x4, y4, [7, 2]), i32x2(143, 42)); + all_eq!(simd_shuffle3(x4, y4, [7, 2, 5]), i32x3(143, 42, 141)); + all_eq!(simd_shuffle4(x4, y4, [7, 2, 5, 0]), i32x4(143, 42, 141, 40)); + all_eq!(simd_shuffle8(x4, y4, [7, 2, 5, 0, 3, 6, 4, 1]), + i32x8(143, 42, 141, 40, 43, 142, 140, 41)); + + all_eq!(simd_shuffle2(x8, y8, [11, 5]), i32x2(183, 85)); + all_eq!(simd_shuffle3(x8, y8, [11, 5, 15]), i32x3(183, 85, 187)); + all_eq!(simd_shuffle4(x8, y8, [11, 5, 15, 0]), i32x4(183, 85, 187, 80)); + all_eq!(simd_shuffle8(x8, y8, [11, 5, 15, 0, 3, 8, 12, 1]), + i32x8(183, 85, 187, 80, 83, 180, 184, 81)); + } + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-gather.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-gather.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-gather.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-gather.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,152 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten +// min-llvm-version 6.0 + +// Test that the simd_{gather,scatter} intrinsics produce the correct results. + +#![feature(repr_simd, platform_intrinsics)] +#![allow(non_camel_case_types)] + +#[repr(simd)] +#[derive(Copy, Clone, PartialEq, Debug)] +struct x4(pub T, pub T, pub T, pub T); + +extern "platform-intrinsic" { + fn simd_gather(x: T, y: U, z: V) -> T; + fn simd_scatter(x: T, y: U, z: V) -> (); +} + +fn main() { + let mut x = [0_f32, 1., 2., 3., 4., 5., 6., 7.]; + + let default = x4(-3_f32, -3., -3., -3.); + let s_strided = x4(0_f32, 2., -3., 6.); + let mask = x4(-1_i32, -1, 0, -1); + + // reading from *const + unsafe { + let pointer = &x[0] as *const f32; + let pointers = x4( + pointer.offset(0) as *const f32, + pointer.offset(2), + pointer.offset(4), + pointer.offset(6) + ); + + let r_strided = simd_gather(default, pointers, mask); + + assert_eq!(r_strided, s_strided); + } + + // reading from *mut + unsafe { + let pointer = &mut x[0] as *mut f32; + let pointers = x4( + pointer.offset(0) as *mut f32, + pointer.offset(2), + pointer.offset(4), + pointer.offset(6) + ); + + let r_strided = simd_gather(default, pointers, mask); + + assert_eq!(r_strided, s_strided); + } + + // writing to *mut + unsafe { + let pointer = &mut x[0] as *mut f32; + let pointers = x4( + pointer.offset(0) as *mut f32, + pointer.offset(2), + pointer.offset(4), + pointer.offset(6) + ); + + let values = x4(42_f32, 43_f32, 44_f32, 45_f32); + simd_scatter(values, pointers, mask); + + assert_eq!(x, [42., 1., 43., 3., 4., 5., 45., 7.]); + } + + // test modifying array of *const f32 + let mut y = [ + &x[0] as *const f32, + &x[1] as *const f32, + &x[2] as *const f32, + &x[3] as *const f32, + &x[4] as *const f32, + &x[5] as *const f32, + &x[6] as *const f32, + &x[7] as *const f32 + ]; + + let default = x4(y[0], y[0], y[0], y[0]); + let s_strided = x4(y[0], y[2], y[0], y[6]); + + // reading from *const + unsafe { + let pointer = &y[0] as *const *const f32; + let pointers = x4( + pointer.offset(0) as *const *const f32, + pointer.offset(2), + pointer.offset(4), + pointer.offset(6) + ); + + let r_strided = simd_gather(default, pointers, mask); + + assert_eq!(r_strided, s_strided); + } + + // reading from *mut + unsafe { + let pointer = &mut y[0] as *mut *const f32; + let pointers = x4( + pointer.offset(0) as *mut *const f32, + pointer.offset(2), + pointer.offset(4), + pointer.offset(6) + ); + + let r_strided = simd_gather(default, pointers, mask); + + assert_eq!(r_strided, s_strided); + } + + // writing to *mut + unsafe { + let pointer = &mut y[0] as *mut *const f32; + let pointers = x4( + pointer.offset(0) as *mut *const f32, + pointer.offset(2), + pointer.offset(4), + pointer.offset(6) + ); + + let values = x4(y[7], y[6], y[5], y[1]); + simd_scatter(values, pointers, mask); + + let s = [ + &x[7] as *const f32, + &x[1] as *const f32, + &x[6] as *const f32, + &x[3] as *const f32, + &x[4] as *const f32, + &x[5] as *const f32, + &x[1] as *const f32, + &x[7] as *const f32 + ]; + assert_eq!(y, s); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-reduction.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-reduction.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-reduction.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-reduction.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,174 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +// ignore-emscripten + +// Test that the simd_reduce_{op} intrinsics produce the correct results. + +#![feature(repr_simd, platform_intrinsics)] +#[allow(non_camel_case_types)] + +#[repr(simd)] +#[derive(Copy, Clone)] +struct i32x4(pub i32, pub i32, pub i32, pub i32); + +#[repr(simd)] +#[derive(Copy, Clone)] +struct u32x4(pub u32, pub u32, pub u32, pub u32); + +#[repr(simd)] +#[derive(Copy, Clone)] +struct f32x4(pub f32, pub f32, pub f32, pub f32); + +#[repr(simd)] +#[derive(Copy, Clone)] +struct b8x4(pub i8, pub i8, pub i8, pub i8); + +#[repr(simd)] +#[derive(Copy, Clone)] +struct b8x16( + pub i8, pub i8, pub i8, pub i8, + pub i8, pub i8, pub i8, pub i8, + pub i8, pub i8, pub i8, pub i8, + pub i8, pub i8, pub i8, pub i8 +); + +extern "platform-intrinsic" { + fn simd_reduce_add_unordered(x: T) -> U; + fn simd_reduce_mul_unordered(x: T) -> U; + fn simd_reduce_add_ordered(x: T, acc: U) -> U; + fn simd_reduce_mul_ordered(x: T, acc: U) -> U; + fn simd_reduce_min(x: T) -> U; + fn simd_reduce_max(x: T) -> U; + fn simd_reduce_min_nanless(x: T) -> U; + fn simd_reduce_max_nanless(x: T) -> U; + fn simd_reduce_and(x: T) -> U; + fn simd_reduce_or(x: T) -> U; + fn simd_reduce_xor(x: T) -> U; + fn simd_reduce_all(x: T) -> bool; + fn simd_reduce_any(x: T) -> bool; +} + +fn main() { + unsafe { + let x = i32x4(1, -2, 3, 4); + let r: i32 = simd_reduce_add_unordered(x); + assert_eq!(r, 6_i32); + let r: i32 = simd_reduce_mul_unordered(x); + assert_eq!(r, -24_i32); + let r: i32 = simd_reduce_add_ordered(x, -1); + assert_eq!(r, 5_i32); + let r: i32 = simd_reduce_mul_ordered(x, -1); + assert_eq!(r, 24_i32); + + let r: i32 = simd_reduce_min(x); + assert_eq!(r, -2_i32); + let r: i32 = simd_reduce_max(x); + assert_eq!(r, 4_i32); + + let x = i32x4(-1, -1, -1, -1); + let r: i32 = simd_reduce_and(x); + assert_eq!(r, -1_i32); + let r: i32 = simd_reduce_or(x); + assert_eq!(r, -1_i32); + let r: i32 = simd_reduce_xor(x); + assert_eq!(r, 0_i32); + + let x = i32x4(-1, -1, 0, -1); + let r: i32 = simd_reduce_and(x); + assert_eq!(r, 0_i32); + let r: i32 = simd_reduce_or(x); + assert_eq!(r, -1_i32); + let r: i32 = simd_reduce_xor(x); + assert_eq!(r, -1_i32); + } + + unsafe { + let x = u32x4(1, 2, 3, 4); + let r: u32 = simd_reduce_add_unordered(x); + assert_eq!(r, 10_u32); + let r: u32 = simd_reduce_mul_unordered(x); + assert_eq!(r, 24_u32); + let r: u32 = simd_reduce_add_ordered(x, 1); + assert_eq!(r, 11_u32); + let r: u32 = simd_reduce_mul_ordered(x, 2); + assert_eq!(r, 48_u32); + + let r: u32 = simd_reduce_min(x); + assert_eq!(r, 1_u32); + let r: u32 = simd_reduce_max(x); + assert_eq!(r, 4_u32); + + let t = u32::max_value(); + let x = u32x4(t, t, t, t); + let r: u32 = simd_reduce_and(x); + assert_eq!(r, t); + let r: u32 = simd_reduce_or(x); + assert_eq!(r, t); + let r: u32 = simd_reduce_xor(x); + assert_eq!(r, 0_u32); + + let x = u32x4(t, t, 0, t); + let r: u32 = simd_reduce_and(x); + assert_eq!(r, 0_u32); + let r: u32 = simd_reduce_or(x); + assert_eq!(r, t); + let r: u32 = simd_reduce_xor(x); + assert_eq!(r, t); + } + + unsafe { + let x = f32x4(1., -2., 3., 4.); + let r: f32 = simd_reduce_add_unordered(x); + assert_eq!(r, 6_f32); + let r: f32 = simd_reduce_mul_unordered(x); + assert_eq!(r, -24_f32); + // FIXME: only works correctly for accumulator, 0: + // https://bugs.llvm.org/show_bug.cgi?id=36734 + let r: f32 = simd_reduce_add_ordered(x, 0.); + assert_eq!(r, 6_f32); + // FIXME: only works correctly for accumulator, 1: + // https://bugs.llvm.org/show_bug.cgi?id=36734 + let r: f32 = simd_reduce_mul_ordered(x, 1.); + assert_eq!(r, -24_f32); + + let r: f32 = simd_reduce_min(x); + assert_eq!(r, -2_f32); + let r: f32 = simd_reduce_max(x); + assert_eq!(r, 4_f32); + let r: f32 = simd_reduce_min_nanless(x); + assert_eq!(r, -2_f32); + let r: f32 = simd_reduce_max_nanless(x); + assert_eq!(r, 4_f32); + } + + unsafe { + let x = b8x4(!0, !0, !0, !0); + let r: bool = simd_reduce_all(x); + assert_eq!(r, true); + let r: bool = simd_reduce_any(x); + assert_eq!(r, true); + + let x = b8x4(!0, !0, 0, !0); + let r: bool = simd_reduce_all(x); + assert_eq!(r, false); + let r: bool = simd_reduce_any(x); + assert_eq!(r, true); + + let x = b8x4(0, 0, 0, 0); + let r: bool = simd_reduce_all(x); + assert_eq!(r, false); + let r: bool = simd_reduce_any(x); + assert_eq!(r, false); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-select.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-select.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-select.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-intrinsic-generic-select.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,149 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +// ignore-emscripten + +// Test that the simd_select intrinsics produces correct results. + +#![feature(repr_simd, platform_intrinsics)] +#[allow(non_camel_case_types)] + +#[repr(simd)] +#[derive(Copy, Clone, PartialEq, Debug)] +struct i32x4(pub i32, pub i32, pub i32, pub i32); + +#[repr(simd)] +#[derive(Copy, Clone, PartialEq, Debug)] +struct u32x4(pub u32, pub u32, pub u32, pub u32); + +#[repr(simd)] +#[derive(Copy, Clone, PartialEq, Debug)] +struct f32x4(pub f32, pub f32, pub f32, pub f32); + +#[repr(simd)] +#[derive(Copy, Clone, PartialEq, Debug)] +struct b8x4(pub i8, pub i8, pub i8, pub i8); + +extern "platform-intrinsic" { + fn simd_select(x: T, a: U, b: U) -> U; +} + +fn main() { + let m0 = b8x4(!0, !0, !0, !0); + let m1 = b8x4(0, 0, 0, 0); + let m2 = b8x4(!0, !0, 0, 0); + let m3 = b8x4(0, 0, !0, !0); + let m4 = b8x4(!0, 0, !0, 0); + + unsafe { + let a = i32x4(1, -2, 3, 4); + let b = i32x4(5, 6, -7, 8); + + let r: i32x4 = simd_select(m0, a, b); + let e = a; + assert_eq!(r, e); + + let r: i32x4 = simd_select(m1, a, b); + let e = b; + assert_eq!(r, e); + + let r: i32x4 = simd_select(m2, a, b); + let e = i32x4(1, -2, -7, 8); + assert_eq!(r, e); + + let r: i32x4 = simd_select(m3, a, b); + let e = i32x4(5, 6, 3, 4); + assert_eq!(r, e); + + let r: i32x4 = simd_select(m4, a, b); + let e = i32x4(1, 6, 3, 8); + assert_eq!(r, e); + } + + unsafe { + let a = u32x4(1, 2, 3, 4); + let b = u32x4(5, 6, 7, 8); + + let r: u32x4 = simd_select(m0, a, b); + let e = a; + assert_eq!(r, e); + + let r: u32x4 = simd_select(m1, a, b); + let e = b; + assert_eq!(r, e); + + let r: u32x4 = simd_select(m2, a, b); + let e = u32x4(1, 2, 7, 8); + assert_eq!(r, e); + + let r: u32x4 = simd_select(m3, a, b); + let e = u32x4(5, 6, 3, 4); + assert_eq!(r, e); + + let r: u32x4 = simd_select(m4, a, b); + let e = u32x4(1, 6, 3, 8); + assert_eq!(r, e); + } + + unsafe { + let a = f32x4(1., 2., 3., 4.); + let b = f32x4(5., 6., 7., 8.); + + let r: f32x4 = simd_select(m0, a, b); + let e = a; + assert_eq!(r, e); + + let r: f32x4 = simd_select(m1, a, b); + let e = b; + assert_eq!(r, e); + + let r: f32x4 = simd_select(m2, a, b); + let e = f32x4(1., 2., 7., 8.); + assert_eq!(r, e); + + let r: f32x4 = simd_select(m3, a, b); + let e = f32x4(5., 6., 3., 4.); + assert_eq!(r, e); + + let r: f32x4 = simd_select(m4, a, b); + let e = f32x4(1., 6., 3., 8.); + assert_eq!(r, e); + } + + unsafe { + let t = !0 as i8; + let f = 0 as i8; + let a = b8x4(t, f, t, f); + let b = b8x4(f, f, f, t); + + let r: b8x4 = simd_select(m0, a, b); + let e = a; + assert_eq!(r, e); + + let r: b8x4 = simd_select(m1, a, b); + let e = b; + assert_eq!(r, e); + + let r: b8x4 = simd_select(m2, a, b); + let e = b8x4(t, f, f, t); + assert_eq!(r, e); + + let r: b8x4 = simd_select(m3, a, b); + let e = b8x4(f, f, t, f); + assert_eq!(r, e); + + let r: b8x4 = simd_select(m4, a, b); + let e = b8x4(t, f, t, t); + assert_eq!(r, e); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-size-align.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-size-align.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-size-align.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-size-align.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,74 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(deprecated)] + + +#![feature(repr_simd)] +#![allow(non_camel_case_types)] + +use std::mem; + +/// `T` should satisfy `size_of T (mod min_align_of T) === 0` to be stored at `Vec` properly +/// Please consult the issue #20460 +fn check() { + assert_eq!(mem::size_of::() % mem::min_align_of::(), 0) +} + +fn main() { + check::(); + check::(); + check::(); + check::(); + check::(); + check::(); + check::(); + + check::(); + check::(); + check::(); + check::(); + check::(); + check::(); + check::(); + + check::(); + check::(); + check::(); + check::(); + check::(); + check::(); + check::(); +} + +#[repr(simd)] struct u8x2(u8, u8); +#[repr(simd)] struct u8x3(u8, u8, u8); +#[repr(simd)] struct u8x4(u8, u8, u8, u8); +#[repr(simd)] struct u8x5(u8, u8, u8, u8, u8); +#[repr(simd)] struct u8x6(u8, u8, u8, u8, u8, u8); +#[repr(simd)] struct u8x7(u8, u8, u8, u8, u8, u8, u8); +#[repr(simd)] struct u8x8(u8, u8, u8, u8, u8, u8, u8, u8); + +#[repr(simd)] struct i16x2(i16, i16); +#[repr(simd)] struct i16x3(i16, i16, i16); +#[repr(simd)] struct i16x4(i16, i16, i16, i16); +#[repr(simd)] struct i16x5(i16, i16, i16, i16, i16); +#[repr(simd)] struct i16x6(i16, i16, i16, i16, i16, i16); +#[repr(simd)] struct i16x7(i16, i16, i16, i16, i16, i16, i16); +#[repr(simd)] struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16); + +#[repr(simd)] struct f32x2(f32, f32); +#[repr(simd)] struct f32x3(f32, f32, f32); +#[repr(simd)] struct f32x4(f32, f32, f32, f32); +#[repr(simd)] struct f32x5(f32, f32, f32, f32, f32); +#[repr(simd)] struct f32x6(f32, f32, f32, f32, f32, f32); +#[repr(simd)] struct f32x7(f32, f32, f32, f32, f32, f32, f32); +#[repr(simd)] struct f32x8(f32, f32, f32, f32, f32, f32, f32, f32); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-target-feature-mixup.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-target-feature-mixup.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-target-feature-mixup.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-target-feature-mixup.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,194 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +#![allow(stable_features)] +#![allow(overflowing_literals)] + +// ignore-emscripten + +#![feature(repr_simd, target_feature, cfg_target_feature)] +#![feature(avx512_target_feature)] + +use std::process::{Command, ExitStatus}; +use std::env; + +fn main() { + if let Some(level) = env::args().nth(1) { + return test::main(&level) + } + + let me = env::current_exe().unwrap(); + for level in ["sse", "avx", "avx512"].iter() { + let status = Command::new(&me).arg(level).status().unwrap(); + if status.success() { + println!("success with {}", level); + continue + } + + // We don't actually know if our computer has the requisite target features + // for the test below. Testing for that will get added to libstd later so + // for now just assume sigill means this is a machine that can't run this test. + if is_sigill(status) { + println!("sigill with {}, assuming spurious", level); + continue + } + panic!("invalid status at {}: {}", level, status); + } +} + +#[cfg(unix)] +fn is_sigill(status: ExitStatus) -> bool { + use std::os::unix::prelude::*; + status.signal() == Some(4) +} + +#[cfg(windows)] +fn is_sigill(status: ExitStatus) -> bool { + status.code() == Some(0xc000001d) +} + +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[allow(nonstandard_style)] +mod test { + // An SSE type + #[repr(simd)] + #[derive(PartialEq, Debug, Clone, Copy)] + struct __m128i(u64, u64); + + // An AVX type + #[repr(simd)] + #[derive(PartialEq, Debug, Clone, Copy)] + struct __m256i(u64, u64, u64, u64); + + // An AVX-512 type + #[repr(simd)] + #[derive(PartialEq, Debug, Clone, Copy)] + struct __m512i(u64, u64, u64, u64, u64, u64, u64, u64); + + pub fn main(level: &str) { + unsafe { + main_normal(level); + main_sse(level); + if level == "sse" { + return + } + main_avx(level); + if level == "avx" { + return + } + main_avx512(level); + } + } + + macro_rules! mains { + ($( + $(#[$attr:meta])* + unsafe fn $main:ident(level: &str) { + ... + } + )*) => ($( + $(#[$attr])* + unsafe fn $main(level: &str) { + let m128 = __m128i(1, 2); + let m256 = __m256i(3, 4, 5, 6); + let m512 = __m512i(7, 8, 9, 10, 11, 12, 13, 14); + assert_eq!(id_sse_128(m128), m128); + assert_eq!(id_sse_256(m256), m256); + assert_eq!(id_sse_512(m512), m512); + + if level == "sse" { + return + } + assert_eq!(id_avx_128(m128), m128); + assert_eq!(id_avx_256(m256), m256); + assert_eq!(id_avx_512(m512), m512); + + if level == "avx" { + return + } + assert_eq!(id_avx512_128(m128), m128); + assert_eq!(id_avx512_256(m256), m256); + assert_eq!(id_avx512_512(m512), m512); + } + )*) + } + + mains! { + unsafe fn main_normal(level: &str) { ... } + #[target_feature(enable = "sse2")] + unsafe fn main_sse(level: &str) { ... } + #[target_feature(enable = "avx")] + unsafe fn main_avx(level: &str) { ... } + #[target_feature(enable = "avx512bw")] + unsafe fn main_avx512(level: &str) { ... } + } + + + #[target_feature(enable = "sse2")] + unsafe fn id_sse_128(a: __m128i) -> __m128i { + assert_eq!(a, __m128i(1, 2)); + a.clone() + } + + #[target_feature(enable = "sse2")] + unsafe fn id_sse_256(a: __m256i) -> __m256i { + assert_eq!(a, __m256i(3, 4, 5, 6)); + a.clone() + } + + #[target_feature(enable = "sse2")] + unsafe fn id_sse_512(a: __m512i) -> __m512i { + assert_eq!(a, __m512i(7, 8, 9, 10, 11, 12, 13, 14)); + a.clone() + } + + #[target_feature(enable = "avx")] + unsafe fn id_avx_128(a: __m128i) -> __m128i { + assert_eq!(a, __m128i(1, 2)); + a.clone() + } + + #[target_feature(enable = "avx")] + unsafe fn id_avx_256(a: __m256i) -> __m256i { + assert_eq!(a, __m256i(3, 4, 5, 6)); + a.clone() + } + + #[target_feature(enable = "avx")] + unsafe fn id_avx_512(a: __m512i) -> __m512i { + assert_eq!(a, __m512i(7, 8, 9, 10, 11, 12, 13, 14)); + a.clone() + } + + #[target_feature(enable = "avx512bw")] + unsafe fn id_avx512_128(a: __m128i) -> __m128i { + assert_eq!(a, __m128i(1, 2)); + a.clone() + } + + #[target_feature(enable = "avx512bw")] + unsafe fn id_avx512_256(a: __m256i) -> __m256i { + assert_eq!(a, __m256i(3, 4, 5, 6)); + a.clone() + } + + #[target_feature(enable = "avx512bw")] + unsafe fn id_avx512_512(a: __m512i) -> __m512i { + assert_eq!(a, __m512i(7, 8, 9, 10, 11, 12, 13, 14)); + a.clone() + } +} + +#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] +mod test { + pub fn main(level: &str) {} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-type.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-type.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +// pretty-expanded FIXME #23616 + +#![feature(repr_simd)] + +#[repr(simd)] +struct RGBA { + r: f32, + g: f32, + b: f32, + a: f32 +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-upgraded.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-upgraded.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simd/simd-upgraded.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simd/simd-upgraded.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(stable_features)] +#![allow(non_camel_case_types)] + +// Test that removed LLVM SIMD intrinsics continue +// to work via the "AutoUpgrade" mechanism. + +#![feature(cfg_target_feature, repr_simd)] +#![feature(platform_intrinsics, stmt_expr_attributes)] + +#[repr(simd)] +#[derive(PartialEq, Debug)] +struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16); + +fn main() { + #[cfg(target_feature = "sse2")] unsafe { + extern "platform-intrinsic" { + fn x86_mm_min_epi16(x: i16x8, y: i16x8) -> i16x8; + } + assert_eq!(x86_mm_min_epi16(i16x8(0, 1, 2, 3, 4, 5, 6, 7), + i16x8(7, 6, 5, 4, 3, 2, 1, 0)), + i16x8(0, 1, 2, 3, 3, 2, 1, 0)); + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simple_global_asm.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simple_global_asm.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simple_global_asm.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simple_global_asm.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,6 +10,7 @@ #![feature(global_asm)] #![feature(naked_functions)] +#![allow(dead_code)] #[cfg(any(target_arch = "x86_64", target_arch = "x86"))] global_asm!(r#" diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simple-infer.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simple-infer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/simple-infer.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/simple-infer.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_mut)] pub fn main() { let mut n; n = 1; println!("{}", n); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/size-and-align.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/size-and-align.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/size-and-align.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/size-and-align.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] enum clam { a(T, isize), b, } fn uhoh(v: Vec> ) { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sized-borrowed-pointer.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sized-borrowed-pointer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sized-borrowed-pointer.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sized-borrowed-pointer.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // Possibly-dynamic size of typaram should be cleared at pointer boundary. // pretty-expanded FIXME #23616 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sized-owned-pointer.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sized-owned-pointer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sized-owned-pointer.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sized-owned-pointer.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // Possibly-dynamic size of typaram should be cleared at pointer boundary. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/snake-case-no-lowercase-equivalent.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/snake-case-no-lowercase-equivalent.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/snake-case-no-lowercase-equivalent.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/snake-case-no-lowercase-equivalent.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // pretty-expanded FIXME #23616 #![feature(non_ascii_idents)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/assoc-ty-graph-cycle.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/assoc-ty-graph-cycle.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/assoc-ty-graph-cycle.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/assoc-ty-graph-cycle.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// Make sure we don't crash with a cycle error during coherence. + +#![feature(specialization)] + +trait Trait { + type Assoc; +} + +impl Trait for Vec { + default type Assoc = (); +} + +impl Trait for Vec { + type Assoc = u8; +} + +impl Trait for String { + type Assoc = (); +} + +impl Trait< as Trait>::Assoc> for String {} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/auxiliary/cross_crates_defaults.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/auxiliary/cross_crates_defaults.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/auxiliary/cross_crates_defaults.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/auxiliary/cross_crates_defaults.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,49 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +#![feature(specialization)] + +// First, test only use of explicit `default` items: + +pub trait Foo { + fn foo(&self) -> bool; +} + +impl Foo for T { + default fn foo(&self) -> bool { false } +} + +impl Foo for i32 {} + +impl Foo for i64 { + fn foo(&self) -> bool { true } +} + +// Next, test mixture of explicit `default` and provided methods: + +pub trait Bar { + fn bar(&self) -> i32 { 0 } +} + +impl Bar for T {} // use the provided method + +impl Bar for i32 { + fn bar(&self) -> i32 { 1 } +} +impl<'a> Bar for &'a str {} + +impl Bar for Vec { + default fn bar(&self) -> i32 { 2 } +} +impl Bar for Vec {} +impl Bar for Vec { + fn bar(&self) -> i32 { 3 } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/auxiliary/go_trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/auxiliary/go_trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/auxiliary/go_trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/auxiliary/go_trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,53 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(specialization)] + +// Common code used for tests that model the Fn/FnMut/FnOnce hierarchy. + +pub trait Go { + fn go(&self, arg: isize); +} + +pub fn go(this: &G, arg: isize) { + this.go(arg) +} + +pub trait GoMut { + fn go_mut(&mut self, arg: isize); +} + +pub fn go_mut(this: &mut G, arg: isize) { + this.go_mut(arg) +} + +pub trait GoOnce { + fn go_once(self, arg: isize); +} + +pub fn go_once(this: G, arg: isize) { + this.go_once(arg) +} + +impl GoMut for G + where G : Go +{ + default fn go_mut(&mut self, arg: isize) { + go(&*self, arg) + } +} + +impl GoOnce for G + where G : GoMut +{ + default fn go_once(mut self, arg: isize) { + go_mut(&mut self, arg) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/auxiliary/specialization_cross_crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/auxiliary/specialization_cross_crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/auxiliary/specialization_cross_crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/auxiliary/specialization_cross_crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,82 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(specialization)] + +pub trait Foo { + fn foo(&self) -> &'static str; +} + +impl Foo for T { + default fn foo(&self) -> &'static str { + "generic" + } +} + +impl Foo for T { + default fn foo(&self) -> &'static str { + "generic Clone" + } +} + +impl Foo for (T, U) where T: Clone, U: Clone { + default fn foo(&self) -> &'static str { + "generic pair" + } +} + +impl Foo for (T, T) { + default fn foo(&self) -> &'static str { + "generic uniform pair" + } +} + +impl Foo for (u8, u32) { + default fn foo(&self) -> &'static str { + "(u8, u32)" + } +} + +impl Foo for (u8, u8) { + default fn foo(&self) -> &'static str { + "(u8, u8)" + } +} + +impl Foo for Vec { + default fn foo(&self) -> &'static str { + "generic Vec" + } +} + +impl Foo for Vec { + fn foo(&self) -> &'static str { + "Vec" + } +} + +impl Foo for String { + fn foo(&self) -> &'static str { + "String" + } +} + +impl Foo for i32 { + fn foo(&self) -> &'static str { + "i32" + } +} + +pub trait MyMarker {} +impl Foo for T { + default fn foo(&self) -> &'static str { + "generic Clone + MyMarker" + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/cross-crate-defaults.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/cross-crate-defaults.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/cross-crate-defaults.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/cross-crate-defaults.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,51 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// aux-build:cross_crates_defaults.rs + +#![feature(specialization)] + +extern crate cross_crates_defaults; + +use cross_crates_defaults::*; + +struct LocalDefault; +struct LocalOverride; + +impl Foo for LocalDefault {} + +impl Foo for LocalOverride { + fn foo(&self) -> bool { true } +} + +fn test_foo() { + assert!(!0i8.foo()); + assert!(!0i32.foo()); + assert!(0i64.foo()); + + assert!(!LocalDefault.foo()); + assert!(LocalOverride.foo()); +} + +fn test_bar() { + assert!(0u8.bar() == 0); + assert!(0i32.bar() == 1); + assert!("hello".bar() == 0); + assert!(vec![()].bar() == 2); + assert!(vec![0i32].bar() == 2); + assert!(vec![0i64].bar() == 3); +} + +fn main() { + test_foo(); + test_bar(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/allowed-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/allowed-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/allowed-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/allowed-cross-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(unused_imports)] + +// aux-build:go_trait.rs + +#![feature(specialization)] + +extern crate go_trait; + +use go_trait::{Go,GoMut}; +use std::fmt::Debug; +use std::default::Default; + +struct MyThingy; + +impl Go for MyThingy { + fn go(&self, arg: isize) { } +} + +impl GoMut for MyThingy { + fn go_mut(&mut self, arg: isize) { } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/auxiliary/go_trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/auxiliary/go_trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/auxiliary/go_trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/auxiliary/go_trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,53 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(specialization)] + +// Common code used for tests that model the Fn/FnMut/FnOnce hierarchy. + +pub trait Go { + fn go(&self, arg: isize); +} + +pub fn go(this: &G, arg: isize) { + this.go(arg) +} + +pub trait GoMut { + fn go_mut(&mut self, arg: isize); +} + +pub fn go_mut(this: &mut G, arg: isize) { + this.go_mut(arg) +} + +pub trait GoOnce { + fn go_once(self, arg: isize); +} + +pub fn go_once(this: G, arg: isize) { + this.go_once(arg) +} + +default impl GoMut for G + where G : Go +{ + fn go_mut(&mut self, arg: isize) { + go(&*self, arg) + } +} + +default impl GoOnce for G + where G : GoMut +{ + fn go_once(mut self, arg: isize) { + go_mut(&mut self, arg) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/out-of-order.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/out-of-order.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/out-of-order.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/out-of-order.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// Test that you can list the more specific impl before the more general one. + +#![feature(specialization)] + +trait Foo { + type Out; +} + +impl Foo for bool { + type Out = (); +} + +default impl Foo for T { + type Out = bool; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/overlap-projection.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/overlap-projection.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/overlap-projection.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/overlap-projection.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// Test that impls on projected self types can resolve overlap, even when the +// projections involve specialization, so long as the associated type is +// provided by the most specialized impl. + +#![feature(specialization)] + +trait Assoc { + type Output; +} + +default impl Assoc for T { + type Output = bool; +} + +impl Assoc for u8 { type Output = u8; } +impl Assoc for u16 { type Output = u16; } + +trait Foo {} +impl Foo for u32 {} +impl Foo for ::Output {} +impl Foo for ::Output {} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/projection.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/projection.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/projection.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/projection.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,52 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +#![feature(specialization)] + +// Make sure we *can* project non-defaulted associated types +// cf compile-fail/specialization-default-projection.rs + +// First, do so without any use of specialization + +trait Foo { + type Assoc; +} + +impl Foo for T { + type Assoc = (); +} + +fn generic_foo() -> ::Assoc { + () +} + +// Next, allow for one layer of specialization + +trait Bar { + type Assoc; +} + +default impl Bar for T { + type Assoc = (); +} + +impl Bar for T { + type Assoc = u8; +} + +fn generic_bar_clone() -> ::Assoc { + 0u8 +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/specialization-trait-item-not-implemented.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/specialization-trait-item-not-implemented.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/specialization-trait-item-not-implemented.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/defaultimpl/specialization-trait-item-not-implemented.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// Tests that we can combine a default impl that supplies one method with a +// full impl that supplies the other, and they can invoke one another. + +#![feature(specialization)] + +trait Foo { + fn foo_one(&self) -> &'static str; + fn foo_two(&self) -> &'static str; + fn foo_three(&self) -> &'static str; +} + +struct MyStruct; + +default impl Foo for T { + fn foo_one(&self) -> &'static str { + self.foo_three() + } +} + +impl Foo for MyStruct { + fn foo_two(&self) -> &'static str { + self.foo_one() + } + + fn foo_three(&self) -> &'static str { + "generic" + } +} + +fn main() { + assert!(MyStruct.foo_two() == "generic"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/README.md rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/README.md --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/README.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/README.md 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +Tests that specialization is working correctly: + +- Dispatch + - [On methods](specialization-basics.rs), includes: + - Specialization via adding a trait bound + - Including both remote and local traits + - Specialization via pure structure (e.g. `(T, U)` vs `(T, T)`) + - Specialization via concrete types vs unknown types + - In top level of the trait reference + - Embedded within another type (`Vec` vs `Vec`) + - [Specialization based on super trait relationships](specialization-super-traits.rs) + - [On assoc fns](specialization-assoc-fns.rs) + - [Ensure that impl order doesn't matter](specialization-out-of-order.rs) + +- Item inheritance + - [Correct default cascading for methods](specialization-default-methods.rs) + - Inheritance works across impls with varying generics + - [With projections](specialization-translate-projections.rs) + - [With projections that involve input types](specialization-translate-projections-with-params.rs) + +- Normalization issues + - [Non-default assoc types can be projected](specialization-projection.rs) + - Including non-specialized cases + - Including specialized cases + - [Specialized Impls can happen on projections](specialization-on-projection.rs) + - [Projections and aliases play well together](specialization-projection-alias.rs) + - [Projections involving specialization allowed in the trait ref for impls, and overlap can still be determined](specialization-overlap-projection.rs) + - Only works for the simple case where the most specialized impl directly + provides a non-`default` associated type + +- Across crates + - [For traits defined in upstream crate](specialization-allowed-cross-crate.rs) + - [Full method dispatch tests, drawing from upstream crate](specialization-cross-crate.rs) + - Including *additional* local specializations + - [Full method dispatch tests, *without* turning on specialization in local crate](specialization-cross-crate-no-gate.rs) + - [Test that defaults cascade correctly from upstream crates](specialization-cross-crate-defaults.rs) + - Including *additional* local use of defaults diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-allowed-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-allowed-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-allowed-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-allowed-cross-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(unused_imports)] + +// aux-build:go_trait.rs + +#![feature(specialization)] + +extern crate go_trait; + +use go_trait::{Go,GoMut}; +use std::fmt::Debug; +use std::default::Default; + +struct MyThingy; + +impl Go for MyThingy { + fn go(&self, arg: isize) { } +} + +impl GoMut for MyThingy { + fn go_mut(&mut self, arg: isize) { } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-assoc-fns.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-assoc-fns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-assoc-fns.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-assoc-fns.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// Test that non-method associated functions can be specialized + +#![feature(specialization)] + +trait Foo { + fn mk() -> Self; +} + +impl Foo for T { + default fn mk() -> T { + T::default() + } +} + +impl Foo for Vec { + fn mk() -> Vec { + vec![0] + } +} + +fn main() { + let v1: Vec = Foo::mk(); + let v2: Vec = Foo::mk(); + + assert!(v1.len() == 0); + assert!(v2.len() == 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-basics.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-basics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-basics.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-basics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,108 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(specialization)] + +// Tests a variety of basic specialization scenarios and method +// dispatch for them. + +trait Foo { + fn foo(&self) -> &'static str; +} + +impl Foo for T { + default fn foo(&self) -> &'static str { + "generic" + } +} + +impl Foo for T { + default fn foo(&self) -> &'static str { + "generic Clone" + } +} + +impl Foo for (T, U) where T: Clone, U: Clone { + default fn foo(&self) -> &'static str { + "generic pair" + } +} + +impl Foo for (T, T) { + default fn foo(&self) -> &'static str { + "generic uniform pair" + } +} + +impl Foo for (u8, u32) { + default fn foo(&self) -> &'static str { + "(u8, u32)" + } +} + +impl Foo for (u8, u8) { + default fn foo(&self) -> &'static str { + "(u8, u8)" + } +} + +impl Foo for Vec { + default fn foo(&self) -> &'static str { + "generic Vec" + } +} + +impl Foo for Vec { + fn foo(&self) -> &'static str { + "Vec" + } +} + +impl Foo for String { + fn foo(&self) -> &'static str { + "String" + } +} + +impl Foo for i32 { + fn foo(&self) -> &'static str { + "i32" + } +} + +struct NotClone; + +trait MyMarker {} +impl Foo for T { + default fn foo(&self) -> &'static str { + "generic Clone + MyMarker" + } +} + +#[derive(Clone)] +struct MarkedAndClone; +impl MyMarker for MarkedAndClone {} + +fn main() { + assert!(NotClone.foo() == "generic"); + assert!(0u8.foo() == "generic Clone"); + assert!(vec![NotClone].foo() == "generic"); + assert!(vec![0u8].foo() == "generic Vec"); + assert!(vec![0i32].foo() == "Vec"); + assert!(0i32.foo() == "i32"); + assert!(String::new().foo() == "String"); + assert!(((), 0).foo() == "generic pair"); + assert!(((), ()).foo() == "generic uniform pair"); + assert!((0u8, 0u32).foo() == "(u8, u32)"); + assert!((0u8, 0u8).foo() == "(u8, u8)"); + assert!(MarkedAndClone.foo() == "generic Clone + MyMarker"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-cross-crate-no-gate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-cross-crate-no-gate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-cross-crate-no-gate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-cross-crate-no-gate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// Test that specialization works even if only the upstream crate enables it + +// aux-build:specialization_cross_crate.rs + +extern crate specialization_cross_crate; + +use specialization_cross_crate::*; + +fn main() { + assert!(0u8.foo() == "generic Clone"); + assert!(vec![0u8].foo() == "generic Vec"); + assert!(vec![0i32].foo() == "Vec"); + assert!(0i32.foo() == "i32"); + assert!(String::new().foo() == "String"); + assert!(((), 0).foo() == "generic pair"); + assert!(((), ()).foo() == "generic uniform pair"); + assert!((0u8, 0u32).foo() == "(u8, u32)"); + assert!((0u8, 0u8).foo() == "(u8, u8)"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-cross-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,60 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// aux-build:specialization_cross_crate.rs + +#![feature(specialization)] + +extern crate specialization_cross_crate; + +use specialization_cross_crate::*; + +struct NotClone; + +#[derive(Clone)] +struct MarkedAndClone; +impl MyMarker for MarkedAndClone {} + +struct MyType(T); +impl Foo for MyType { + default fn foo(&self) -> &'static str { + "generic MyType" + } +} + +impl Foo for MyType { + fn foo(&self) -> &'static str { + "MyType" + } +} + +struct MyOtherType; +impl Foo for MyOtherType {} + +fn main() { + assert!(NotClone.foo() == "generic"); + assert!(0u8.foo() == "generic Clone"); + assert!(vec![NotClone].foo() == "generic"); + assert!(vec![0u8].foo() == "generic Vec"); + assert!(vec![0i32].foo() == "Vec"); + assert!(0i32.foo() == "i32"); + assert!(String::new().foo() == "String"); + assert!(((), 0).foo() == "generic pair"); + assert!(((), ()).foo() == "generic uniform pair"); + assert!((0u8, 0u32).foo() == "(u8, u32)"); + assert!((0u8, 0u8).foo() == "(u8, u8)"); + assert!(MarkedAndClone.foo() == "generic Clone + MyMarker"); + + assert!(MyType(()).foo() == "generic MyType"); + assert!(MyType(0u8).foo() == "MyType"); + assert!(MyOtherType.foo() == "generic"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-default-methods.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-default-methods.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-default-methods.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-default-methods.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,96 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(specialization)] + +// Test that default methods are cascaded correctly + +// First, test only use of explicit `default` items: + +trait Foo { + fn foo(&self) -> bool; +} + +// Specialization tree for Foo: +// +// T +// / \ +// i32 i64 + +impl Foo for T { + default fn foo(&self) -> bool { false } +} + +impl Foo for i32 {} + +impl Foo for i64 { + fn foo(&self) -> bool { true } +} + +fn test_foo() { + assert!(!0i8.foo()); + assert!(!0i32.foo()); + assert!(0i64.foo()); +} + +// Next, test mixture of explicit `default` and provided methods: + +trait Bar { + fn bar(&self) -> i32 { 0 } +} + +// Specialization tree for Bar. +// Uses of $ designate that method is provided +// +// $Bar (the trait) +// | +// T +// /|\ +// / | \ +// / | \ +// / | \ +// / | \ +// / | \ +// $i32 &str $Vec +// /\ +// / \ +// Vec $Vec + +// use the provided method +impl Bar for T {} + +impl Bar for i32 { + fn bar(&self) -> i32 { 1 } +} +impl<'a> Bar for &'a str {} + +impl Bar for Vec { + default fn bar(&self) -> i32 { 2 } +} +impl Bar for Vec {} +impl Bar for Vec { + fn bar(&self) -> i32 { 3 } +} + +fn test_bar() { + assert!(0u8.bar() == 0); + assert!(0i32.bar() == 1); + assert!("hello".bar() == 0); + assert!(vec![()].bar() == 2); + assert!(vec![0i32].bar() == 2); + assert!(vec![0i64].bar() == 3); +} + +fn main() { + test_foo(); + test_bar(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-on-projection.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-on-projection.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-on-projection.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-on-projection.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +#![feature(specialization)] + +// Ensure that specialization works for impls defined directly on a projection + +trait Foo {} + +trait Assoc { + type Item; +} + +impl Foo for T {} + +struct Struct; + +impl Assoc for Struct { + type Item = u8; +} + +impl Foo for Struct {} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-out-of-order.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-out-of-order.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-out-of-order.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-out-of-order.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// Test that you can list the more specific impl before the more general one. + +#![feature(specialization)] + +trait Foo { + type Out; +} + +impl Foo for bool { + type Out = (); +} + +impl Foo for T { + default type Out = bool; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-overlap-projection.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-overlap-projection.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-overlap-projection.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-overlap-projection.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// Test that impls on projected self types can resolve overlap, even when the +// projections involve specialization, so long as the associated type is +// provided by the most specialized impl. + +#![feature(specialization)] + +trait Assoc { + type Output; +} + +impl Assoc for T { + default type Output = bool; +} + +impl Assoc for u8 { type Output = u8; } +impl Assoc for u16 { type Output = u16; } + +trait Foo {} +impl Foo for u32 {} +impl Foo for ::Output {} +impl Foo for ::Output {} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-projection-alias.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-projection-alias.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-projection-alias.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-projection-alias.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] + +#![feature(specialization)] + +// Regression test for ICE when combining specialized associated types and type +// aliases + +trait Id_ { + type Out; +} + +type Id = ::Out; + +impl Id_ for T { + default type Out = T; +} + +fn test_proection() { + let x: Id = panic!(); +} + +fn main() { + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-projection.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-projection.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-projection.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-projection.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,52 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +#![feature(specialization)] + +// Make sure we *can* project non-defaulted associated types +// cf compile-fail/specialization-default-projection.rs + +// First, do so without any use of specialization + +trait Foo { + type Assoc; +} + +impl Foo for T { + type Assoc = (); +} + +fn generic_foo() -> ::Assoc { + () +} + +// Next, allow for one layer of specialization + +trait Bar { + type Assoc; +} + +impl Bar for T { + default type Assoc = (); +} + +impl Bar for T { + type Assoc = u8; +} + +fn generic_bar_clone() -> ::Assoc { + 0u8 +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-super-traits.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-super-traits.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-super-traits.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-super-traits.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(specialization)] + +// Test that you can specialize via an explicit trait hierarchy + +// FIXME: this doesn't work yet... + +trait Parent {} +trait Child: Parent {} + +trait Foo {} + +impl Foo for T {} +impl Foo for T {} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-translate-projections.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-translate-projections.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-translate-projections.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-translate-projections.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// Ensure that provided items are inherited properly even when impls vary in +// type parameters *and* rely on projections. + +#![feature(specialization)] + +use std::convert::Into; + +trait Trait { + fn to_u8(&self) -> u8; +} +trait WithAssoc { + type Item; + fn to_item(&self) -> Self::Item; +} + +impl Trait for T where T: WithAssoc, U: Into { + fn to_u8(&self) -> u8 { + self.to_item().into() + } +} + +impl WithAssoc for u8 { + type Item = u8; + fn to_item(&self) -> u8 { *self } +} + +impl Trait for u8 {} + +fn main() { + assert!(3u8.to_u8() == 3u8); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-translate-projections-with-lifetimes.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-translate-projections-with-lifetimes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-translate-projections-with-lifetimes.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-translate-projections-with-lifetimes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(specialization)] + +trait Iterator { + fn next(&self); +} + +trait WithAssoc { + type Item; +} + +impl<'a> WithAssoc for &'a () { + type Item = &'a u32; +} + +struct Cloned(I); + +impl<'a, I, T: 'a> Iterator for Cloned + where I: WithAssoc, T: Clone +{ + fn next(&self) {} +} + +impl<'a, I, T: 'a> Iterator for Cloned + where I: WithAssoc, T: Copy +{ + +} + +fn main() { + Cloned(&()).next(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-translate-projections-with-params.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-translate-projections-with-params.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-translate-projections-with-params.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/specialization/specialization-translate-projections-with-params.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// Ensure that provided items are inherited properly even when impls vary in +// type parameters *and* rely on projections, and the type parameters are input +// types on the trait. + +#![feature(specialization)] + +trait Trait { + fn convert(&self) -> T; +} +trait WithAssoc { + type Item; + fn as_item(&self) -> &Self::Item; +} + +impl Trait for T where T: WithAssoc, U: Clone { + fn convert(&self) -> U { + self.as_item().clone() + } +} + +impl WithAssoc for u8 { + type Item = u8; + fn as_item(&self) -> &u8 { self } +} + +impl Trait for u8 {} + +fn main() { + assert!(3u8.convert() == 3u8); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sse2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sse2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/sse2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/sse2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(stable_features)] // min-llvm-version 6.0 // ^ needs MCSubtargetInfo::checkFeatures() // ignore-cloudabi no std::env diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/auxiliary/static_fn_inline_xc_aux.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/auxiliary/static_fn_inline_xc_aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/auxiliary/static_fn_inline_xc_aux.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/auxiliary/static_fn_inline_xc_aux.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +pub mod num { + pub trait Num2 { + fn from_int2(n: isize) -> Self; + } +} + +pub mod f64 { + impl ::num::Num2 for f64 { + #[inline] + fn from_int2(n: isize) -> f64 { return n as f64; } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/auxiliary/static_fn_trait_xc_aux.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/auxiliary/static_fn_trait_xc_aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/auxiliary/static_fn_trait_xc_aux.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/auxiliary/static_fn_trait_xc_aux.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod num { + pub trait Num2 { + fn from_int2(n: isize) -> Self; + } +} + +pub mod f64 { + impl ::num::Num2 for f64 { + fn from_int2(n: isize) -> f64 { return n as f64; } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/auxiliary/static-function-pointer-aux.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/auxiliary/static-function-pointer-aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/auxiliary/static-function-pointer-aux.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/auxiliary/static-function-pointer-aux.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +pub fn f(x: isize) -> isize { -x } + +pub static F: fn(isize) -> isize = f; +pub static mut MutF: fn(isize) -> isize = f; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/auxiliary/static-methods-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/auxiliary/static-methods-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/auxiliary/static-methods-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/auxiliary/static-methods-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="static_methods_crate"] +#![crate_type = "lib"] + +pub trait read: Sized { + fn readMaybe(s: String) -> Option; +} + +impl read for isize { + fn readMaybe(s: String) -> Option { + s.parse().ok() + } +} + +impl read for bool { + fn readMaybe(s: String) -> Option { + match &*s { + "true" => Some(true), + "false" => Some(false), + _ => None + } + } +} + +pub fn read(s: String) -> T { + match read::readMaybe(s) { + Some(x) => x, + _ => panic!("read panicked!") + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/auxiliary/static_mut_xc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/auxiliary/static_mut_xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/auxiliary/static_mut_xc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/auxiliary/static_mut_xc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub static mut a: isize = 3; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-fn-inline-xc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-fn-inline-xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-fn-inline-xc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-fn-inline-xc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:static_fn_inline_xc_aux.rs + +// pretty-expanded FIXME #23616 + +extern crate static_fn_inline_xc_aux as mycore; + +use mycore::num; + +pub fn main() { + let _1: f64 = num::Num2::from_int2(1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-fn-trait-xc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-fn-trait-xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-fn-trait-xc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-fn-trait-xc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:static_fn_trait_xc_aux.rs + +// pretty-expanded FIXME #23616 + +extern crate static_fn_trait_xc_aux as mycore; + +use mycore::num; + +pub fn main() { + let _1: f64 = num::Num2::from_int2(1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-function-pointer.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-function-pointer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-function-pointer.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-function-pointer.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn f(x: isize) -> isize { x } +fn g(x: isize) -> isize { 2 * x } + +static F: fn(isize) -> isize = f; +static mut G: fn(isize) -> isize = f; + +pub fn main() { + assert_eq!(F(42), 42); + unsafe { + assert_eq!(G(42), 42); + G = g; + assert_eq!(G(42), 84); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-function-pointer-xc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-function-pointer-xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-function-pointer-xc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-function-pointer-xc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:static-function-pointer-aux.rs + +extern crate static_function_pointer_aux as aux; + +fn f(x: isize) -> isize { x } + +pub fn main() { + assert_eq!(aux::F(42), -42); + unsafe { + assert_eq!(aux::MutF(42), -42); + aux::MutF = f; + assert_eq!(aux::MutF(42), 42); + aux::MutF = aux::f; + assert_eq!(aux::MutF(42), -42); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-impl.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-impl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,76 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + + + + +pub trait plus { + fn plus(&self) -> isize; +} + +mod a { + use plus; + impl plus for usize { fn plus(&self) -> isize { *self as isize + 20 } } +} + +mod b { + use plus; + impl plus for String { fn plus(&self) -> isize { 200 } } +} + +trait uint_utils { + fn str(&self) -> String; + fn multi(&self, f: F) where F: FnMut(usize); +} + +impl uint_utils for usize { + fn str(&self) -> String { + self.to_string() + } + fn multi(&self, mut f: F) where F: FnMut(usize) { + let mut c = 0_usize; + while c < *self { f(c); c += 1_usize; } + } +} + +trait vec_utils { + fn length_(&self, ) -> usize; + fn iter_(&self, f: F) where F: FnMut(&T); + fn map_(&self, f: F) -> Vec where F: FnMut(&T) -> U; +} + +impl vec_utils for Vec { + fn length_(&self) -> usize { self.len() } + fn iter_(&self, mut f: F) where F: FnMut(&T) { for x in self { f(x); } } + fn map_(&self, mut f: F) -> Vec where F: FnMut(&T) -> U { + let mut r = Vec::new(); + for elt in self { + r.push(f(elt)); + } + r + } +} + +pub fn main() { + assert_eq!(10_usize.plus(), 30); + assert_eq!(("hi".to_string()).plus(), 200); + + assert_eq!((vec![1]).length_().str(), "1".to_string()); + let vect = vec![3, 4].map_(|a| *a + 4); + assert_eq!(vect[0], 7); + let vect = (vec![3, 4]).map_::(|a| *a as usize + 4_usize); + assert_eq!(vect[0], 7_usize); + let mut x = 0_usize; + 10_usize.multi(|_n| x += 2_usize ); + assert_eq!(x, 20_usize); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-method-in-trait-with-tps-intracrate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-method-in-trait-with-tps-intracrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-method-in-trait-with-tps-intracrate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-method-in-trait-with-tps-intracrate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +trait Deserializer { + fn read_int(&self) -> isize; +} + +trait Deserializable { + fn deserialize(d: &D) -> Self; +} + +impl Deserializable for isize { + fn deserialize(d: &D) -> isize { + return d.read_int(); + } +} + +struct FromThinAir { dummy: () } + +impl Deserializer for FromThinAir { + fn read_int(&self) -> isize { 22 } +} + +pub fn main() { + let d = FromThinAir { dummy: () }; + let i: isize = Deserializable::deserialize(&d); + assert_eq!(i, 22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-methods-in-traits2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-methods-in-traits2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-methods-in-traits2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-methods-in-traits2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +pub trait Number: NumConv { + fn from(n: T) -> Self; +} + +impl Number for f64 { + fn from(n: T) -> f64 { n.to_float() } +} + +pub trait NumConv { + fn to_float(&self) -> f64; +} + +impl NumConv for f64 { + fn to_float(&self) -> f64 { *self } +} + +pub fn main() { + let _: f64 = Number::from(0.0f64); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-methods-in-traits.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-methods-in-traits.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-methods-in-traits.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-methods-in-traits.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +mod a { + pub trait Foo { + fn foo() -> Self; + } + + impl Foo for isize { + fn foo() -> isize { + 3 + } + } + + impl Foo for usize { + fn foo() -> usize { + 5 + } + } +} + +pub fn main() { + let x: isize = a::Foo::foo(); + let y: usize = a::Foo::foo(); + assert_eq!(x, 3); + assert_eq!(y, 5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-method-xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-method-xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-method-xcrate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-method-xcrate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:static-methods-crate.rs + +extern crate static_methods_crate; + +use static_methods_crate::read; + +pub fn main() { + let result: isize = read("5".to_string()); + assert_eq!(result, 5); + assert_eq!(read::readMaybe("false".to_string()), Some(false)); + assert_eq!(read::readMaybe("foo".to_string()), None::); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-mut-foreign.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-mut-foreign.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-mut-foreign.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-mut-foreign.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,51 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Constants (static variables) can be used to match in patterns, but mutable +// statics cannot. This ensures that there's some form of error if this is +// attempted. + +// ignore-wasm32-bare no libc to test ffi with + +#![feature(libc)] + +extern crate libc; + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + static mut rust_dbg_static_mut: libc::c_int; + pub fn rust_dbg_static_mut_check_four(); +} + +unsafe fn static_bound(_: &'static libc::c_int) {} + +fn static_bound_set(a: &'static mut libc::c_int) { + *a = 3; +} + +unsafe fn run() { + assert_eq!(rust_dbg_static_mut, 3); + rust_dbg_static_mut = 4; + assert_eq!(rust_dbg_static_mut, 4); + rust_dbg_static_mut_check_four(); + rust_dbg_static_mut += 1; + assert_eq!(rust_dbg_static_mut, 5); + rust_dbg_static_mut *= 3; + assert_eq!(rust_dbg_static_mut, 15); + rust_dbg_static_mut = -3; + assert_eq!(rust_dbg_static_mut, -3); + static_bound(&rust_dbg_static_mut); + static_bound_set(&mut rust_dbg_static_mut); +} + +pub fn main() { + unsafe { run() } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-mut-xc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-mut-xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-mut-xc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-mut-xc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,49 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_upper_case_globals)] + +// Constants (static variables) can be used to match in patterns, but mutable +// statics cannot. This ensures that there's some form of error if this is +// attempted. + +// aux-build:static_mut_xc.rs + + +extern crate static_mut_xc; + +unsafe fn static_bound(_: &'static isize) {} + +fn static_bound_set(a: &'static mut isize) { + *a = 3; +} + +unsafe fn run() { + assert_eq!(static_mut_xc::a, 3); + static_mut_xc::a = 4; + assert_eq!(static_mut_xc::a, 4); + static_mut_xc::a += 1; + assert_eq!(static_mut_xc::a, 5); + static_mut_xc::a *= 3; + assert_eq!(static_mut_xc::a, 15); + static_mut_xc::a = -3; + assert_eq!(static_mut_xc::a, -3); + static_bound(&static_mut_xc::a); + static_bound_set(&mut static_mut_xc::a); +} + +pub fn main() { + unsafe { run() } +} + +pub mod inner { + pub static mut a: isize = 4; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-recursive.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-recursive.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/statics/static-recursive.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/statics/static-recursive.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +static mut S: *const u8 = unsafe { &S as *const *const u8 as *const u8 }; + +struct StaticDoubleLinked { + prev: &'static StaticDoubleLinked, + next: &'static StaticDoubleLinked, + data: i32, + head: bool +} + +static L1: StaticDoubleLinked = StaticDoubleLinked{prev: &L3, next: &L2, data: 1, head: true}; +static L2: StaticDoubleLinked = StaticDoubleLinked{prev: &L1, next: &L3, data: 2, head: false}; +static L3: StaticDoubleLinked = StaticDoubleLinked{prev: &L2, next: &L1, data: 3, head: false}; + + +pub fn main() { + unsafe { assert_eq!(S, *(S as *const *const u8)); } + + let mut test_vec = Vec::new(); + let mut cur = &L1; + loop { + test_vec.push(cur.data); + cur = cur.next; + if cur.head { break } + } + assert_eq!(&test_vec, &[1,2,3]); + + let mut test_vec = Vec::new(); + let mut cur = &L1; + loop { + cur = cur.prev; + test_vec.push(cur.data); + if cur.head { break } + } + assert_eq!(&test_vec, &[3,2,1]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/align-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/align-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/align-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/align-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,256 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![feature(box_syntax)] +#![feature(repr_packed)] + +use std::mem; + +// Raising alignment +#[repr(align(16))] +#[derive(Clone, Copy, Debug)] +struct Align16(i32); + +// Lowering has no effect +#[repr(align(1))] +struct Align1(i32); + +// Multiple attributes take the max +#[repr(align(4))] +#[repr(align(16))] +#[repr(align(8))] +struct AlignMany(i32); + +// Raising alignment may not alter size. +#[repr(align(8))] +#[allow(dead_code)] +struct Align8Many { + a: i32, + b: i32, + c: i32, + d: u8, +} + +enum Enum { + #[allow(dead_code)] + A(i32), + B(Align16) +} + +// Nested alignment - use `#[repr(C)]` to suppress field reordering for sizeof test +#[repr(C)] +struct Nested { + a: i32, + b: i32, + c: Align16, + d: i8, +} + +#[repr(packed)] +struct Packed(i32); + +#[repr(align(16))] +struct AlignContainsPacked { + a: Packed, + b: Packed, +} + +#[repr(C, packed(4))] +struct Packed4C { + a: u32, + b: u64, +} + +#[repr(align(16))] +struct AlignContainsPacked4C { + a: Packed4C, + b: u64, +} + +// The align limit was originally smaller (2^15). +// Check that it works with big numbers. +#[repr(align(0x10000))] +struct AlignLarge { + stuff: [u8; 0x10000], +} + +union UnionContainsAlign { + a: Align16, + b: f32 +} + +impl Align16 { + // return aligned type + pub fn new(i: i32) -> Align16 { + Align16(i) + } + // pass aligned type + pub fn consume(a: Align16) -> i32 { + a.0 + } +} + +const CONST_ALIGN16: Align16 = Align16(7); +static STATIC_ALIGN16: Align16 = Align16(8); + +// Check the actual address is aligned +fn is_aligned_to(p: &T, align: usize) -> bool { + let addr = p as *const T as usize; + (addr & (align - 1)) == 0 +} + +pub fn main() { + // check alignment and size by type and value + assert_eq!(mem::align_of::(), 16); + assert_eq!(mem::size_of::(), 16); + + let a = Align16(7); + assert_eq!(a.0, 7); + assert_eq!(mem::align_of_val(&a), 16); + assert_eq!(mem::size_of_val(&a), 16); + + assert!(is_aligned_to(&a, 16)); + + // lowering should have no effect + assert_eq!(mem::align_of::(), 4); + assert_eq!(mem::size_of::(), 4); + let a = Align1(7); + assert_eq!(a.0, 7); + assert_eq!(mem::align_of_val(&a), 4); + assert_eq!(mem::size_of_val(&a), 4); + assert!(is_aligned_to(&a, 4)); + + // when multiple attributes are specified the max should be used + assert_eq!(mem::align_of::(), 16); + assert_eq!(mem::size_of::(), 16); + let a = AlignMany(7); + assert_eq!(a.0, 7); + assert_eq!(mem::align_of_val(&a), 16); + assert_eq!(mem::size_of_val(&a), 16); + assert!(is_aligned_to(&a, 16)); + + // raising alignment should not reduce size + assert_eq!(mem::align_of::(), 8); + assert_eq!(mem::size_of::(), 16); + let a = Align8Many { a: 1, b: 2, c: 3, d: 4 }; + assert_eq!(a.a, 1); + assert_eq!(mem::align_of_val(&a), 8); + assert_eq!(mem::size_of_val(&a), 16); + assert!(is_aligned_to(&a, 8)); + + // return type + let a = Align16::new(1); + assert_eq!(mem::align_of_val(&a), 16); + assert_eq!(mem::size_of_val(&a), 16); + assert_eq!(a.0, 1); + assert!(is_aligned_to(&a, 16)); + assert_eq!(Align16::consume(a), 1); + + // check const alignment, size and value + assert_eq!(mem::align_of_val(&CONST_ALIGN16), 16); + assert_eq!(mem::size_of_val(&CONST_ALIGN16), 16); + assert_eq!(CONST_ALIGN16.0, 7); + assert!(is_aligned_to(&CONST_ALIGN16, 16)); + + // check global static alignment, size and value + assert_eq!(mem::align_of_val(&STATIC_ALIGN16), 16); + assert_eq!(mem::size_of_val(&STATIC_ALIGN16), 16); + assert_eq!(STATIC_ALIGN16.0, 8); + assert!(is_aligned_to(&STATIC_ALIGN16, 16)); + + // Note that the size of Nested may change if struct field re-ordering is enabled + assert_eq!(mem::align_of::(), 16); + assert_eq!(mem::size_of::(), 48); + let a = Nested{ a: 1, b: 2, c: Align16(3), d: 4}; + assert_eq!(mem::align_of_val(&a), 16); + assert_eq!(mem::align_of_val(&a.b), 4); + assert_eq!(mem::align_of_val(&a.c), 16); + assert_eq!(mem::size_of_val(&a), 48); + assert!(is_aligned_to(&a, 16)); + // check the correct fields are indexed + assert_eq!(a.a, 1); + assert_eq!(a.b, 2); + assert_eq!(a.c.0, 3); + assert_eq!(a.d, 4); + + // enum should be aligned to max alignment + assert_eq!(mem::align_of::(), 16); + assert_eq!(mem::align_of_val(&Enum::B(Align16(0))), 16); + let e = Enum::B(Align16(15)); + match e { + Enum::B(ref a) => { + assert_eq!(a.0, 15); + assert_eq!(mem::align_of_val(a), 16); + assert_eq!(mem::size_of_val(a), 16); + }, + _ => () + } + assert!(is_aligned_to(&e, 16)); + + // check union alignment + assert_eq!(mem::align_of::(), 16); + assert_eq!(mem::size_of::(), 16); + let u = UnionContainsAlign { a: Align16(10) }; + unsafe { + assert_eq!(mem::align_of_val(&u.a), 16); + assert_eq!(mem::size_of_val(&u.a), 16); + assert_eq!(u.a.0, 10); + let UnionContainsAlign { a } = u; + assert_eq!(a.0, 10); + } + + // arrays of aligned elements should also be aligned + assert_eq!(mem::align_of::<[Align16;2]>(), 16); + assert_eq!(mem::size_of::<[Align16;2]>(), 32); + + let a = [Align16(0), Align16(1)]; + assert_eq!(mem::align_of_val(&a[0]), 16); + assert_eq!(mem::align_of_val(&a[1]), 16); + assert!(is_aligned_to(&a, 16)); + + // check heap value is aligned + assert_eq!(mem::align_of_val(Box::new(Align16(0)).as_ref()), 16); + + // check heap array is aligned + let a = vec!(Align16(0), Align16(1)); + assert_eq!(mem::align_of_val(&a[0]), 16); + assert_eq!(mem::align_of_val(&a[1]), 16); + + assert_eq!(mem::align_of::(), 16); + assert_eq!(mem::size_of::(), 16); + let a = AlignContainsPacked { a: Packed(1), b: Packed(2) }; + assert_eq!(mem::align_of_val(&a), 16); + assert_eq!(mem::align_of_val(&a.a), 1); + assert_eq!(mem::align_of_val(&a.b), 1); + assert_eq!(mem::size_of_val(&a), 16); + assert!(is_aligned_to(&a, 16)); + + assert_eq!(mem::align_of::(), 16); + assert_eq!(mem::size_of::(), 32); + let a = AlignContainsPacked4C { a: Packed4C{ a: 1, b: 2 }, b: 3 }; + assert_eq!(mem::align_of_val(&a), 16); + assert_eq!(mem::align_of_val(&a.a), 4); + assert_eq!(mem::align_of_val(&a.b), mem::align_of::()); + assert_eq!(mem::size_of_val(&a), 32); + assert!(is_aligned_to(&a, 16)); + + let mut large = box AlignLarge { + stuff: [0; 0x10000], + }; + large.stuff[0] = 132; + *large.stuff.last_mut().unwrap() = 102; + assert_eq!(large.stuff[0], 132); + assert_eq!(large.stuff.last(), Some(&102)); + assert_eq!(mem::align_of::(), 0x10000); + assert_eq!(mem::align_of_val(&*large), 0x10000); + assert!(is_aligned_to(&*large, 0x10000)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod kitties { + pub struct cat { + meows : usize, + + pub how_hungry : isize, + + } + + impl cat { + pub fn speak(&self) {} + } + + pub fn cat(in_x : usize, in_y : isize) -> cat { + cat { + meows: in_x, + how_hungry: in_y + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_3.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod kitties { + pub struct cat { + meows : usize, + + pub how_hungry : isize, + } + + impl cat { + pub fn speak(&mut self) { self.meows += 1; } + pub fn meow_count(&mut self) -> usize { self.meows } + } + + pub fn cat(in_x : usize, in_y : isize) -> cat { + cat { + meows: in_x, + how_hungry: in_y + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_4.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_4.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_4.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,51 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod kitties { + pub struct cat { + meows : usize, + + pub how_hungry : isize, + pub name : String, + } + + impl cat { + pub fn speak(&mut self) { self.meow(); } + + pub fn eat(&mut self) -> bool { + if self.how_hungry > 0 { + println!("OM NOM NOM"); + self.how_hungry -= 2; + return true; + } else { + println!("Not hungry!"); + return false; + } + } + } + + impl cat { + pub fn meow(&mut self) { + println!("Meow"); + self.meows += 1; + if self.meows % 5 == 0 { + self.how_hungry += 1; + } + } + } + + pub fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { + cat { + meows: in_x, + how_hungry: in_y, + name: in_name + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_6.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_6.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_6.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_6.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod kitties { + + pub struct cat { + info : Vec , + meows : usize, + + pub how_hungry : isize, + } + + impl cat { + pub fn speak(&mut self, stuff: Vec ) { + self.meows += stuff.len(); + } + + pub fn meow_count(&mut self) -> usize { self.meows } + } + + pub fn cat(in_x : usize, in_y : isize, in_info: Vec ) -> cat { + cat { + meows: in_x, + how_hungry: in_y, + info: in_info + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_cast.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_cast.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_cast.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,60 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod kitty { + use std::fmt; + + pub struct cat { + meows : usize, + pub how_hungry : isize, + pub name : String, + } + + impl fmt::Display for cat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.name) + } + } + + impl cat { + fn meow(&mut self) { + println!("Meow"); + self.meows += 1; + if self.meows % 5 == 0 { + self.how_hungry += 1; + } + } + + } + + impl cat { + pub fn speak(&mut self) { self.meow(); } + + pub fn eat(&mut self) -> bool { + if self.how_hungry > 0 { + println!("OM NOM NOM"); + self.how_hungry -= 2; + return true; + } + else { + println!("Not hungry!"); + return false; + } + } + } + + pub fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { + cat { + meows: in_x, + how_hungry: in_y, + name: in_name + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod kitties { + pub struct cat { + meows : usize, + + pub how_hungry : isize, + } + + pub fn cat(in_x : usize, in_y : isize) -> cat { + cat { + meows: in_x, + how_hungry: in_y + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/cci_class_trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod animals { + pub trait noisy { + fn speak(&mut self); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/empty-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/empty-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/empty-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/empty-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct XEmpty1 {} +pub struct XEmpty2; +pub struct XEmpty7(); + +pub enum XE { + XEmpty3 {}, + XEmpty4, + XEmpty6(), +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/namespaced_enum_emulate_flat.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/namespaced_enum_emulate_flat.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/namespaced_enum_emulate_flat.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/namespaced_enum_emulate_flat.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub use Foo::*; + +pub enum Foo { + A, + B(isize), + C { a: isize }, +} + +impl Foo { + pub fn foo() {} +} + +pub mod nest { + pub use self::Bar::*; + + pub enum Bar { + D, + E(isize), + F { a: isize }, + } + + impl Bar { + pub fn foo() {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/namespaced_enums.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/namespaced_enums.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/namespaced_enums.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/namespaced_enums.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub enum Foo { + A, + B(isize), + C { a: isize }, +} + +impl Foo { + pub fn foo() {} + pub fn bar(&self) {} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/newtype_struct_xc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/newtype_struct_xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/newtype_struct_xc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/newtype_struct_xc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] + +pub struct Au(pub isize); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/struct_destructuring_cross_crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/struct_destructuring_cross_crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/struct_destructuring_cross_crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/struct_destructuring_cross_crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] + +pub struct S { + pub x: isize, + pub y: isize, +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/struct_variant_xc_aux.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/struct_variant_xc_aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/struct_variant_xc_aux.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/struct_variant_xc_aux.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="struct_variant_xc_aux"] +#![crate_type = "lib"] + +#[derive(Copy, Clone)] +pub enum Enum { + Variant(u8), + StructVariant { arg: u8 } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/xcrate_struct_aliases.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/xcrate_struct_aliases.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/xcrate_struct_aliases.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/auxiliary/xcrate_struct_aliases.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct S { + pub x: isize, + pub y: isize, +} + +pub type S2 = S; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/borrow-tuple-fields.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/borrow-tuple-fields.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/borrow-tuple-fields.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/borrow-tuple-fields.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,48 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +struct Foo(isize, isize); + +fn main() { + let x = (1, 2); + let a = &x.0; + let b = &x.0; + assert_eq!(*a, 1); + assert_eq!(*b, 1); + + let mut x = (1, 2); + { + let a = &x.0; + let b = &mut x.1; + *b = 5; + assert_eq!(*a, 1); + } + assert_eq!(x.0, 1); + assert_eq!(x.1, 5); + + + let x = Foo(1, 2); + let a = &x.0; + let b = &x.0; + assert_eq!(*a, 1); + assert_eq!(*b, 1); + + let mut x = Foo(1, 2); + { + let a = &x.0; + let b = &mut x.1; + *b = 5; + assert_eq!(*a, 1); + } + assert_eq!(x.0, 1); + assert_eq!(x.1, 5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-attributes-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-attributes-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-attributes-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-attributes-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_attributes)] +#![allow(non_camel_case_types)] + +// pp-exact - Make sure we actually print the attributes +#![feature(custom_attribute)] + +struct cat { + name: String, +} + +impl Drop for cat { + #[cat_dropper] + fn drop(&mut self) { println!("{} landed on hir feet" , self . name); } +} + + +#[cat_maker] +fn cat(name: String) -> cat { cat{name: name,} } + +pub fn main() { let _kitty = cat("Spotty".to_string()); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-attributes-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-attributes-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-attributes-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-attributes-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_attributes)] +#![allow(non_camel_case_types)] + +#![feature(custom_attribute)] + +struct cat { + name: String, +} + +impl Drop for cat { + #[cat_dropper] + /** + Actually, cats don't always land on their feet when you drop them. + */ + fn drop(&mut self) { + println!("{} landed on hir feet", self.name); + } +} + +#[cat_maker] +/** +Maybe it should technically be a kitten_maker. +*/ +fn cat(name: String) -> cat { + cat { + name: name + } +} + +pub fn main() { + let _kitty = cat("Spotty".to_string()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-cast-to-trait-cross-crate-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-cast-to-trait-cross-crate-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-cast-to-trait-cross-crate-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-cast-to-trait-cross-crate-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:cci_class_cast.rs + +#![feature(box_syntax)] + +extern crate cci_class_cast; + +use std::string::ToString; +use cci_class_cast::kitty::cat; + +fn print_out(thing: Box, expected: String) { + let actual = (*thing).to_string(); + println!("{}", actual); + assert_eq!(actual.to_string(), expected); +} + +pub fn main() { + let nyan: Box = box cat(0, 2, "nyan".to_string()) as Box; + print_out(nyan, "nyan".to_string()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-cast-to-trait-multiple-types.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-cast-to-trait-multiple-types.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-cast-to-trait-multiple-types.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-cast-to-trait-multiple-types.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,103 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +trait noisy { + fn speak(&mut self) -> isize; +} + +struct dog { + barks: usize, + + volume: isize, +} + +impl dog { + fn bark(&mut self) -> isize { + println!("Woof {} {}", self.barks, self.volume); + self.barks += 1_usize; + if self.barks % 3_usize == 0_usize { + self.volume += 1; + } + if self.barks % 10_usize == 0_usize { + self.volume -= 2; + } + println!("Grrr {} {}", self.barks, self.volume); + self.volume + } +} + +impl noisy for dog { + fn speak(&mut self) -> isize { + self.bark() + } +} + +fn dog() -> dog { + dog { + volume: 0, + barks: 0_usize + } +} + +#[derive(Clone)] +struct cat { + meows: usize, + + how_hungry: isize, + name: String, +} + +impl noisy for cat { + fn speak(&mut self) -> isize { + self.meow() as isize + } +} + +impl cat { + pub fn meow_count(&self) -> usize { + self.meows + } +} + +impl cat { + fn meow(&mut self) -> usize { + println!("Meow"); + self.meows += 1_usize; + if self.meows % 5_usize == 0_usize { + self.how_hungry += 1; + } + self.meows + } +} + +fn cat(in_x: usize, in_y: isize, in_name: String) -> cat { + cat { + meows: in_x, + how_hungry: in_y, + name: in_name + } +} + + +fn annoy_neighbors(critter: &mut noisy) { + for _i in 0_usize..10 { critter.speak(); } +} + +pub fn main() { + let mut nyan: cat = cat(0_usize, 2, "nyan".to_string()); + let mut whitefang: dog = dog(); + annoy_neighbors(&mut nyan); + annoy_neighbors(&mut whitefang); + assert_eq!(nyan.meow_count(), 10_usize); + assert_eq!(whitefang.volume, 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-cast-to-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-cast-to-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-cast-to-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-cast-to-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,70 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_mut)] +#![allow(non_camel_case_types)] + +// ignore-freebsd FIXME fails on BSD + + +trait noisy { + fn speak(&mut self); +} + +struct cat { + meows: usize, + how_hungry: isize, + name: String, +} + +impl noisy for cat { + fn speak(&mut self) { self.meow(); } +} + +impl cat { + pub fn eat(&mut self) -> bool { + if self.how_hungry > 0 { + println!("OM NOM NOM"); + self.how_hungry -= 2; + return true; + } + else { + println!("Not hungry!"); + return false; + } + } +} + +impl cat { + fn meow(&mut self) { + println!("Meow"); + self.meows += 1; + if self.meows % 5 == 0 { + self.how_hungry += 1; + } + } +} + +fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { + cat { + meows: in_x, + how_hungry: in_y, + name: in_name + } +} + + +pub fn main() { + let mut nyan = cat(0, 2, "nyan".to_string()); + let mut nyan: &mut noisy = &mut nyan; + nyan.speak(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-dtor.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-dtor.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-dtor.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-dtor.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +struct cat { + done : extern fn(usize), + meows : usize, +} + +impl Drop for cat { + fn drop(&mut self) { + (self.done)(self.meows); + } +} + +fn cat(done: extern fn(usize)) -> cat { + cat { + meows: 0, + done: done + } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes-cross-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:cci_class_4.rs + +extern crate cci_class_4; +use cci_class_4::kitties::cat; + +pub fn main() { + let mut nyan = cat(0_usize, 2, "nyan".to_string()); + nyan.eat(); + assert!((!nyan.eat())); + for _ in 1_usize..10_usize { nyan.speak(); }; + assert!((nyan.eat())); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,61 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +struct cat { + meows : usize, + + how_hungry : isize, + name : String, +} + +impl cat { + pub fn speak(&mut self) { self.meow(); } + + pub fn eat(&mut self) -> bool { + if self.how_hungry > 0 { + println!("OM NOM NOM"); + self.how_hungry -= 2; + return true; + } else { + println!("Not hungry!"); + return false; + } + } +} + +impl cat { + fn meow(&mut self) { + println!("Meow"); + self.meows += 1_usize; + if self.meows % 5_usize == 0_usize { + self.how_hungry += 1; + } + } +} + +fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { + cat { + meows: in_x, + how_hungry: in_y, + name: in_name + } +} + +pub fn main() { + let mut nyan = cat(0_usize, 2, "nyan".to_string()); + nyan.eat(); + assert!((!nyan.eat())); + for _ in 1_usize..10_usize { nyan.speak(); }; + assert!((nyan.eat())); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes-self-referential.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes-self-referential.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes-self-referential.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes-self-referential.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + + +// pretty-expanded FIXME #23616 + +struct kitten { + cat: Option, +} + +fn kitten(cat: Option) -> kitten { + kitten { + cat: cat + } +} + +type cat = Box; + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes-simple-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes-simple-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes-simple-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes-simple-cross-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:cci_class.rs + +extern crate cci_class; +use cci_class::kitties::cat; + +pub fn main() { + let nyan : cat = cat(52, 99); + let kitty = cat(1000, 2); + assert_eq!(nyan.how_hungry, 99); + assert_eq!(kitty.how_hungry, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes-simple-method.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes-simple-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes-simple-method.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes-simple-method.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +struct cat { + meows : usize, + + how_hungry : isize, +} + +impl cat { + pub fn speak(&mut self) {} +} + +fn cat(in_x : usize, in_y : isize) -> cat { + cat { + meows: in_x, + how_hungry: in_y + } +} + +pub fn main() { + let mut nyan : cat = cat(52, 99); + let kitty = cat(1000, 2); + assert_eq!(nyan.how_hungry, 99); + assert_eq!(kitty.how_hungry, 2); + nyan.speak(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes-simple.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes-simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes-simple.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/classes-simple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +struct cat { + meows : usize, + + how_hungry : isize, +} + +fn cat(in_x : usize, in_y : isize) -> cat { + cat { + meows: in_x, + how_hungry: in_y + } +} + +pub fn main() { + let nyan : cat = cat(52, 99); + let kitty = cat(1000, 2); + assert_eq!(nyan.how_hungry, 99); + assert_eq!(kitty.how_hungry, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-exports.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-exports.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-exports.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-exports.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +/* Test that exporting a class also exports its + public fields and methods */ + +use kitty::cat; + +mod kitty { + pub struct cat { + meows: usize, + name: String, + } + + impl cat { + pub fn get_name(&self) -> String { self.name.clone() } + } + + pub fn cat(in_name: String) -> cat { + cat { + name: in_name, + meows: 0 + } + } +} + +pub fn main() { + assert_eq!(cat("Spreckles".to_string()).get_name(), + "Spreckles".to_string()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-implement-trait-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-implement-trait-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-implement-trait-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-implement-trait-cross-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,69 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// aux-build:cci_class_trait.rs +extern crate cci_class_trait; +use cci_class_trait::animals::noisy; + +struct cat { + meows: usize, + + how_hungry : isize, + name : String, +} + +impl cat { + pub fn eat(&mut self) -> bool { + if self.how_hungry > 0 { + println!("OM NOM NOM"); + self.how_hungry -= 2; + return true; + } + else { + println!("Not hungry!"); + return false; + } + } +} + +impl noisy for cat { + fn speak(&mut self) { self.meow(); } +} + +impl cat { + fn meow(&mut self) { + println!("Meow"); + self.meows += 1_usize; + if self.meows % 5_usize == 0_usize { + self.how_hungry += 1; + } + } +} + +fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { + cat { + meows: in_x, + how_hungry: in_y, + name: in_name + } +} + + +pub fn main() { + let mut nyan = cat(0_usize, 2, "nyan".to_string()); + nyan.eat(); + assert!((!nyan.eat())); + for _ in 1_usize..10_usize { nyan.speak(); }; + assert!((nyan.eat())); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-implement-traits.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-implement-traits.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-implement-traits.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-implement-traits.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,73 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +trait noisy { + fn speak(&mut self); +} + +#[derive(Clone)] +struct cat { + meows : usize, + + how_hungry : isize, + name : String, +} + +impl cat { + fn meow(&mut self) { + println!("Meow"); + self.meows += 1_usize; + if self.meows % 5_usize == 0_usize { + self.how_hungry += 1; + } + } +} + +impl cat { + pub fn eat(&mut self) -> bool { + if self.how_hungry > 0 { + println!("OM NOM NOM"); + self.how_hungry -= 2; + return true; + } else { + println!("Not hungry!"); + return false; + } + } +} + +impl noisy for cat { + fn speak(&mut self) { self.meow(); } +} + +fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { + cat { + meows: in_x, + how_hungry: in_y, + name: in_name.clone() + } +} + + +fn make_speak(mut c: C) { + c.speak(); +} + +pub fn main() { + let mut nyan = cat(0_usize, 2, "nyan".to_string()); + nyan.eat(); + assert!((!nyan.eat())); + for _ in 1_usize..10_usize { + make_speak(nyan.clone()); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-impl-very-parameterized-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-impl-very-parameterized-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-impl-very-parameterized-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-impl-very-parameterized-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,117 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +use std::cmp; + +#[derive(Copy, Clone, Debug)] +enum cat_type { tuxedo, tabby, tortoiseshell } + +impl cmp::PartialEq for cat_type { + fn eq(&self, other: &cat_type) -> bool { + ((*self) as usize) == ((*other) as usize) + } + fn ne(&self, other: &cat_type) -> bool { !(*self).eq(other) } +} + +// Very silly -- this just returns the value of the name field +// for any isize value that's less than the meows field + +// ok: T should be in scope when resolving the trait ref for map +struct cat { + // Yes, you can have negative meows + meows : isize, + + how_hungry : isize, + name : T, +} + +impl cat { + pub fn speak(&mut self) { self.meow(); } + + pub fn eat(&mut self) -> bool { + if self.how_hungry > 0 { + println!("OM NOM NOM"); + self.how_hungry -= 2; + return true; + } else { + println!("Not hungry!"); + return false; + } + } + fn len(&self) -> usize { self.meows as usize } + fn is_empty(&self) -> bool { self.meows == 0 } + fn clear(&mut self) {} + fn contains_key(&self, k: &isize) -> bool { *k <= self.meows } + + fn find(&self, k: &isize) -> Option<&T> { + if *k <= self.meows { + Some(&self.name) + } else { + None + } + } + fn insert(&mut self, k: isize, _: T) -> bool { + self.meows += k; + true + } + + fn find_mut(&mut self, _k: &isize) -> Option<&mut T> { panic!() } + + fn remove(&mut self, k: &isize) -> bool { + if self.find(k).is_some() { + self.meows -= *k; true + } else { + false + } + } + + fn pop(&mut self, _k: &isize) -> Option { panic!() } + + fn swap(&mut self, _k: isize, _v: T) -> Option { panic!() } +} + +impl cat { + pub fn get(&self, k: &isize) -> &T { + match self.find(k) { + Some(v) => { v } + None => { panic!("epic fail"); } + } + } + + pub fn new(in_x: isize, in_y: isize, in_name: T) -> cat { + cat{meows: in_x, how_hungry: in_y, name: in_name } + } +} + +impl cat { + fn meow(&mut self) { + self.meows += 1; + println!("Meow {}", self.meows); + if self.meows % 5 == 0 { + self.how_hungry += 1; + } + } +} + +pub fn main() { + let mut nyan: cat = cat::new(0, 2, "nyan".to_string()); + for _ in 1_usize..5 { nyan.speak(); } + assert_eq!(*nyan.find(&1).unwrap(), "nyan".to_string()); + assert_eq!(nyan.find(&10), None); + let mut spotty: cat = cat::new(2, 57, cat_type::tuxedo); + for _ in 0_usize..6 { spotty.speak(); } + assert_eq!(spotty.len(), 8); + assert!((spotty.contains_key(&2))); + assert_eq!(spotty.get(&3), &cat_type::tuxedo); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-method-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-method-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-method-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-method-cross-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:cci_class_2.rs + +extern crate cci_class_2; +use cci_class_2::kitties::cat; + +pub fn main() { + let nyan : cat = cat(52, 99); + let kitty = cat(1000, 2); + assert_eq!(nyan.how_hungry, 99); + assert_eq!(kitty.how_hungry, 2); + nyan.speak(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-methods-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-methods-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-methods-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-methods-cross-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:cci_class_3.rs + +extern crate cci_class_3; +use cci_class_3::kitties::cat; + +pub fn main() { + let mut nyan : cat = cat(52, 99); + let kitty = cat(1000, 2); + assert_eq!(nyan.how_hungry, 99); + assert_eq!(kitty.how_hungry, 2); + nyan.speak(); + assert_eq!(nyan.meow_count(), 53); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-methods.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-methods.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-methods.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-methods.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + + +struct cat { + meows : usize, + + how_hungry : isize, +} + +impl cat { + pub fn speak(&mut self) { self.meows += 1; } + pub fn meow_count(&mut self) -> usize { self.meows } +} + +fn cat(in_x: usize, in_y: isize) -> cat { + cat { + meows: in_x, + how_hungry: in_y + } +} + +pub fn main() { + let mut nyan: cat = cat(52, 99); + let kitty = cat(1000, 2); + assert_eq!(nyan.how_hungry, 99); + assert_eq!(kitty.how_hungry, 2); + nyan.speak(); + assert_eq!(nyan.meow_count(), 53); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-poly-methods-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-poly-methods-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-poly-methods-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-poly-methods-cross-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:cci_class_6.rs + +extern crate cci_class_6; +use cci_class_6::kitties::cat; + +pub fn main() { + let mut nyan : cat = cat::(52_usize, 99, vec!['p']); + let mut kitty = cat(1000_usize, 2, vec!["tabby".to_string()]); + assert_eq!(nyan.how_hungry, 99); + assert_eq!(kitty.how_hungry, 2); + nyan.speak(vec![1_usize,2_usize,3_usize]); + assert_eq!(nyan.meow_count(), 55_usize); + kitty.speak(vec!["meow".to_string(), "mew".to_string(), "purr".to_string(), "chirp".to_string()]); + assert_eq!(kitty.meow_count(), 1004_usize); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-poly-methods.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-poly-methods.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-poly-methods.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-poly-methods.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + + +struct cat { + info : Vec , + meows : usize, + + how_hungry : isize, +} + +impl cat { + pub fn speak(&mut self, stuff: Vec ) { + self.meows += stuff.len(); + } + pub fn meow_count(&mut self) -> usize { self.meows } +} + +fn cat(in_x : usize, in_y : isize, in_info: Vec ) -> cat { + cat { + meows: in_x, + how_hungry: in_y, + info: in_info + } +} + +pub fn main() { + let mut nyan : cat = cat::(52, 99, vec![9]); + let mut kitty = cat(1000, 2, vec!["tabby".to_string()]); + assert_eq!(nyan.how_hungry, 99); + assert_eq!(kitty.how_hungry, 2); + nyan.speak(vec![1,2,3]); + assert_eq!(nyan.meow_count(), 55); + kitty.speak(vec!["meow".to_string(), "mew".to_string(), "purr".to_string(), "chirp".to_string()]); + assert_eq!(kitty.meow_count(), 1004); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-separate-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-separate-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-separate-impl.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-separate-impl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,75 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +#![feature(box_syntax)] + +use std::fmt; + +struct cat { + meows : usize, + + how_hungry : isize, + name : String, +} + +impl cat { + pub fn speak(&mut self) { self.meow(); } + + pub fn eat(&mut self) -> bool { + if self.how_hungry > 0 { + println!("OM NOM NOM"); + self.how_hungry -= 2; + return true; + } + else { + println!("Not hungry!"); + return false; + } + } +} + +impl cat { + fn meow(&mut self) { + println!("Meow"); + self.meows += 1; + if self.meows % 5 == 0 { + self.how_hungry += 1; + } + } +} + +fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { + cat { + meows: in_x, + how_hungry: in_y, + name: in_name + } +} + +impl fmt::Display for cat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.name) + } +} + +fn print_out(thing: Box, expected: String) { + let actual = (*thing).to_string(); + println!("{}", actual); + assert_eq!(actual.to_string(), expected); +} + +pub fn main() { + let nyan: Box = box cat(0, 2, "nyan".to_string()) as Box; + print_out(nyan, "nyan".to_string()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-str-field.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-str-field.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-str-field.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-str-field.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +struct cat { + + name : String, + +} + +fn cat(in_name: String) -> cat { + cat { + name: in_name + } +} + +pub fn main() { + let _nyan = cat("nyan".to_string()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-typarams.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-typarams.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-typarams.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/class-typarams.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +use std::marker::PhantomData; + +struct cat { + meows : usize, + how_hungry : isize, + m: PhantomData +} + +impl cat { + pub fn speak(&mut self) { self.meows += 1; } + pub fn meow_count(&mut self) -> usize { self.meows } +} + +fn cat(in_x : usize, in_y : isize) -> cat { + cat { + meows: in_x, + how_hungry: in_y, + m: PhantomData + } +} + + +pub fn main() { + let _nyan : cat = cat::(52, 99); + // let mut kitty = cat(1000, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/codegen-tag-static-padding.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/codegen-tag-static-padding.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/codegen-tag-static-padding.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/codegen-tag-static-padding.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,69 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_upper_case_globals)] + +// Issue #13186 + +// For simplicity of explanations assuming code is compiled for x86_64 +// Linux ABI. + +// Size of TestOption is 16, and alignment of TestOption is 8. +// Size of u8 is 1, and alignment of u8 is 1. +// So size of Request is 24, and alignment of Request must be 8: +// the maximum alignment of its fields. +// Last 7 bytes of Request struct are not occupied by any fields. + + + +enum TestOption { + TestNone, + TestSome(T), +} + +pub struct Request { + foo: TestOption, + bar: u8, +} + +fn default_instance() -> &'static Request { + static instance: Request = Request { + // LLVM does not allow to specify alignment of expressions, thus + // alignment of `foo` in constant is 1, not 8. + foo: TestOption::TestNone, + bar: 17, + // Space after last field is not occupied by any data, but it is + // reserved to make struct aligned properly. If compiler does + // not insert padding after last field when emitting constant, + // size of struct may be not equal to size of struct, and + // compiler crashes in internal assertion check. + }; + &instance +} + +fn non_default_instance() -> &'static Request { + static instance: Request = Request { + foo: TestOption::TestSome(0x1020304050607080), + bar: 19, + }; + &instance +} + +pub fn main() { + match default_instance() { + &Request { foo: TestOption::TestNone, bar: 17 } => {}, + _ => panic!(), + }; + match non_default_instance() { + &Request { foo: TestOption::TestSome(0x1020304050607080), bar: 19 } => {}, + _ => panic!(), + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/compare-generic-enums.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/compare-generic-enums.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/compare-generic-enums.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/compare-generic-enums.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + + +type an_int = isize; + +fn cmp(x: Option, y: Option) -> bool { + x == y +} + +pub fn main() { + assert!(!cmp(Some(3), None)); + assert!(!cmp(Some(3), Some(4))); + assert!(cmp(Some(3), Some(3))); + assert!(cmp(None, None)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/discrim-explicit-23030.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/discrim-explicit-23030.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/discrim-explicit-23030.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/discrim-explicit-23030.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,157 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Issue 23030: Workaround overflowing discriminant +// with explicit assignments. + +// See also compile-fail/overflow-discrim.rs, which shows what +// happens if you leave the OhNo explicit cases out here. + +use std::{i8,u8,i16,u16,i32,u32,i64,u64,isize,usize}; + +fn f_i8() { + #[repr(i8)] + enum A { + Ok = i8::MAX - 1, + Ok2, + OhNo = i8::MIN, + NotTheEnd = -1, + Zero, + } + + let _x = (A::Ok, A::Ok2, A::OhNo); + let z = (A::NotTheEnd, A::Zero).1 as i8; + assert_eq!(z, 0); +} + +fn f_u8() { + #[repr(u8)] + enum A { + Ok = u8::MAX - 1, + Ok2, + OhNo = u8::MIN, + } + + let _x = (A::Ok, A::Ok2, A::OhNo); +} + +fn f_i16() { + #[repr(i16)] + enum A { + Ok = i16::MAX - 1, + Ok2, + OhNo = i16::MIN, + NotTheEnd = -1, + Zero, + } + + let _x = (A::Ok, A::Ok2, A::OhNo); + let z = (A::NotTheEnd, A::Zero).1 as i16; + assert_eq!(z, 0); +} + +fn f_u16() { + #[repr(u16)] + enum A { + Ok = u16::MAX - 1, + Ok2, + OhNo = u16::MIN, + } + + let _x = (A::Ok, A::Ok2, A::OhNo); +} + +fn f_i32() { + #[repr(i32)] + enum A { + Ok = i32::MAX - 1, + Ok2, + OhNo = i32::MIN, + NotTheEnd = -1, + Zero, + } + + let _x = (A::Ok, A::Ok2, A::OhNo); + let z = (A::NotTheEnd, A::Zero).1 as i32; + assert_eq!(z, 0); +} + +fn f_u32() { + #[repr(u32)] + enum A { + Ok = u32::MAX - 1, + Ok2, + OhNo = u32::MIN, + } + + let _x = (A::Ok, A::Ok2, A::OhNo); +} + +fn f_i64() { + #[repr(i64)] + enum A { + Ok = i64::MAX - 1, + Ok2, + OhNo = i64::MIN, + NotTheEnd = -1, + Zero, + } + + let _x = (A::Ok, A::Ok2, A::OhNo); + let z = (A::NotTheEnd, A::Zero).1 as i64; + assert_eq!(z, 0); +} + +fn f_u64() { + #[repr(u64)] + enum A { + Ok = u64::MAX - 1, + Ok2, + OhNo = u64::MIN, + } + + let _x = (A::Ok, A::Ok2, A::OhNo); +} + +fn f_isize() { + #[repr(isize)] + enum A { + Ok = isize::MAX - 1, + Ok2, + OhNo = isize::MIN, + NotTheEnd = -1, + Zero, + } + + let _x = (A::Ok, A::Ok2, A::OhNo); + let z = (A::NotTheEnd, A::Zero).1 as isize; + assert_eq!(z, 0); +} + +fn f_usize() { + #[repr(usize)] + enum A { + Ok = usize::MAX - 1, + Ok2, + OhNo = usize::MIN, + } + + let _x = (A::Ok, A::Ok2, A::OhNo); +} + +fn main() { + f_i8(); f_u8(); + f_i16(); f_u16(); + f_i32(); f_u32(); + f_i64(); f_u64(); + + f_isize(); f_usize(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/empty-struct-braces.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/empty-struct-braces.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/empty-struct-braces.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/empty-struct-braces.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,223 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +#![allow(non_upper_case_globals)] + +// Empty struct defined with braces add names into type namespace +// Empty struct defined without braces add names into both type and value namespaces + +// aux-build:empty-struct.rs + +extern crate empty_struct; +use empty_struct::*; + +struct Empty1 {} +struct Empty2; +struct Empty7(); + +#[derive(PartialEq, Eq)] +struct Empty3 {} + +const Empty3: Empty3 = Empty3 {}; + +enum E { + Empty4 {}, + Empty5, + Empty6(), +} + +fn local() { + let e1: Empty1 = Empty1 {}; + let e2: Empty2 = Empty2 {}; + let e2: Empty2 = Empty2; + let e3: Empty3 = Empty3 {}; + let e3: Empty3 = Empty3; + let e4: E = E::Empty4 {}; + let e5: E = E::Empty5 {}; + let e5: E = E::Empty5; + let e6: E = E::Empty6 {}; + let e6: E = E::Empty6(); + let ctor6: fn() -> E = E::Empty6; + let e7: Empty7 = Empty7 {}; + let e7: Empty7 = Empty7(); + let ctor7: fn() -> Empty7 = Empty7; + + match e1 { + Empty1 {} => {} + } + match e2 { + Empty2 {} => {} + } + match e3 { + Empty3 {} => {} + } + match e4 { + E::Empty4 {} => {} + _ => {} + } + match e5 { + E::Empty5 {} => {} + _ => {} + } + match e6 { + E::Empty6 {} => {} + _ => {} + } + match e7 { + Empty7 {} => {} + } + + match e1 { + Empty1 { .. } => {} + } + match e2 { + Empty2 { .. } => {} + } + match e3 { + Empty3 { .. } => {} + } + match e4 { + E::Empty4 { .. } => {} + _ => {} + } + match e5 { + E::Empty5 { .. } => {} + _ => {} + } + match e6 { + E::Empty6 { .. } => {} + _ => {} + } + match e7 { + Empty7 { .. } => {} + } + + match e2 { + Empty2 => {} + } + match e3 { + Empty3 => {} + } + match e5 { + E::Empty5 => {} + _ => {} + } + match e6 { + E::Empty6() => {} + _ => {} + } + match e6 { + E::Empty6(..) => {} + _ => {} + } + match e7 { + Empty7() => {} + } + match e7 { + Empty7(..) => {} + } + + let e11: Empty1 = Empty1 { ..e1 }; + let e22: Empty2 = Empty2 { ..e2 }; + let e33: Empty3 = Empty3 { ..e3 }; + let e77: Empty7 = Empty7 { ..e7 }; +} + +fn xcrate() { + let e1: XEmpty1 = XEmpty1 {}; + let e2: XEmpty2 = XEmpty2 {}; + let e2: XEmpty2 = XEmpty2; + let e3: XE = XE::XEmpty3 {}; + let e4: XE = XE::XEmpty4 {}; + let e4: XE = XE::XEmpty4; + let e6: XE = XE::XEmpty6 {}; + let e6: XE = XE::XEmpty6(); + let ctor6: fn() -> XE = XE::XEmpty6; + let e7: XEmpty7 = XEmpty7 {}; + let e7: XEmpty7 = XEmpty7(); + let ctor7: fn() -> XEmpty7 = XEmpty7; + + match e1 { + XEmpty1 {} => {} + } + match e2 { + XEmpty2 {} => {} + } + match e3 { + XE::XEmpty3 {} => {} + _ => {} + } + match e4 { + XE::XEmpty4 {} => {} + _ => {} + } + match e6 { + XE::XEmpty6 {} => {} + _ => {} + } + match e7 { + XEmpty7 {} => {} + } + + match e1 { + XEmpty1 { .. } => {} + } + match e2 { + XEmpty2 { .. } => {} + } + match e3 { + XE::XEmpty3 { .. } => {} + _ => {} + } + match e4 { + XE::XEmpty4 { .. } => {} + _ => {} + } + match e6 { + XE::XEmpty6 { .. } => {} + _ => {} + } + match e7 { + XEmpty7 { .. } => {} + } + + match e2 { + XEmpty2 => {} + } + match e4 { + XE::XEmpty4 => {} + _ => {} + } + match e6 { + XE::XEmpty6() => {} + _ => {} + } + match e6 { + XE::XEmpty6(..) => {} + _ => {} + } + match e7 { + XEmpty7() => {} + } + match e7 { + XEmpty7(..) => {} + } + + let e11: XEmpty1 = XEmpty1 { ..e1 }; + let e22: XEmpty2 = XEmpty2 { ..e2 }; + let e77: XEmpty7 = XEmpty7 { ..e7 }; +} + +fn main() { + local(); + xcrate(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/empty-tag.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/empty-tag.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/empty-tag.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/empty-tag.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +#[derive(Copy, Clone, Debug)] +enum chan { chan_t, } + +impl PartialEq for chan { + fn eq(&self, other: &chan) -> bool { + ((*self) as usize) == ((*other) as usize) + } + fn ne(&self, other: &chan) -> bool { !(*self).eq(other) } +} + +fn wrapper3(i: chan) { + assert_eq!(i, chan::chan_t); +} + +pub fn main() { + let wrapped = {||wrapper3(chan::chan_t)}; + wrapped(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-alignment.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-alignment.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-alignment.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-alignment.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(deprecated)] + +use std::mem; + +fn addr_of(ptr: &T) -> usize { + ptr as *const T as usize +} + +fn is_aligned(ptr: &T) -> bool { + unsafe { + let addr: usize = mem::transmute(ptr); + (addr % mem::min_align_of::()) == 0 + } +} + +pub fn main() { + let x = Some(0u64); + match x { + None => panic!(), + Some(ref y) => assert!(is_aligned(y)) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-clike-ffi-as-int.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-clike-ffi-as-int.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-clike-ffi-as-int.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-clike-ffi-as-int.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +/*! + * C-like enums have to be represented as LLVM ints, not wrapped in a + * struct, because it's important for the FFI that they interoperate + * with C integers/enums, and the ABI can treat structs differently. + * For example, on i686-linux-gnu, a struct return value is passed by + * storing to a hidden out parameter, whereas an integer would be + * returned in a register. + * + * This test just checks that the ABIs for the enum and the plain + * integer are compatible, rather than actually calling C code. + * The unused parameter to `foo` is to increase the likelihood of + * crashing if something goes wrong here. + */ + +#[repr(u32)] +enum Foo { + A = 0, + B = 23 +} + +#[inline(never)] +extern "C" fn foo(_x: usize) -> Foo { Foo::B } + +pub fn main() { + unsafe { + let f: extern "C" fn(usize) -> u32 = + ::std::mem::transmute(foo as extern "C" fn(usize) -> Foo); + assert_eq!(f(0xDEADBEEF), Foo::B as u32); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-discrim-autosizing.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-discrim-autosizing.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-discrim-autosizing.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-discrim-autosizing.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,63 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(overflowing_literals)] + +use std::mem::size_of; + +enum Ei8 { + Ai8 = -1, + Bi8 = 0 +} + +enum Eu8 { + Au8 = 0, + Bu8 = 0x80 +} + +enum Ei16 { + Ai16 = -1, + Bi16 = 0x80 +} + +enum Eu16 { + Au16 = 0, + Bu16 = 0x8000 +} + +enum Ei32 { + Ai32 = -1, + Bi32 = 0x8000 +} + +enum Eu32 { + Au32 = 0, + Bu32 = 0x8000_0000 +} + +enum Ei64 { + Ai64 = -1, + Bi64 = 0x8000_0000 +} + +pub fn main() { + assert_eq!(size_of::(), 1); + assert_eq!(size_of::(), 1); + assert_eq!(size_of::(), 2); + assert_eq!(size_of::(), 2); + assert_eq!(size_of::(), 4); + assert_eq!(size_of::(), 4); + #[cfg(target_pointer_width = "64")] + assert_eq!(size_of::(), 8); + #[cfg(target_pointer_width = "32")] + assert_eq!(size_of::(), 4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-discrim-manual-sizing.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-discrim-manual-sizing.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-discrim-manual-sizing.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-discrim-manual-sizing.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,121 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +use std::mem::{size_of, align_of}; + +#[repr(i8)] +enum Ei8 { + Ai8 = 0, + Bi8 = 1 +} + +#[repr(u8)] +enum Eu8 { + Au8 = 0, + Bu8 = 1 +} + +#[repr(i16)] +enum Ei16 { + Ai16 = 0, + Bi16 = 1 +} + +#[repr(u16)] +enum Eu16 { + Au16 = 0, + Bu16 = 1 +} + +#[repr(i32)] +enum Ei32 { + Ai32 = 0, + Bi32 = 1 +} + +#[repr(u32)] +enum Eu32 { + Au32 = 0, + Bu32 = 1 +} + +#[repr(i64)] +enum Ei64 { + Ai64 = 0, + Bi64 = 1 +} + +#[repr(u64)] +enum Eu64 { + Au64 = 0, + Bu64 = 1 +} + +#[repr(isize)] +enum Eint { + Aint = 0, + Bint = 1 +} + +#[repr(usize)] +enum Euint { + Auint = 0, + Buint = 1 +} + +#[repr(u8)] +enum Eu8NonCLike { + _None, + _Some(T), +} + +#[repr(i64)] +enum Ei64NonCLike { + _None, + _Some(T), +} + +#[repr(u64)] +enum Eu64NonCLike { + _None, + _Some(T), +} + +pub fn main() { + assert_eq!(size_of::(), 1); + assert_eq!(size_of::(), 1); + assert_eq!(size_of::(), 2); + assert_eq!(size_of::(), 2); + assert_eq!(size_of::(), 4); + assert_eq!(size_of::(), 4); + assert_eq!(size_of::(), 8); + assert_eq!(size_of::(), 8); + assert_eq!(size_of::(), size_of::()); + assert_eq!(size_of::(), size_of::()); + assert_eq!(size_of::>(), 1); + assert_eq!(size_of::>(), 8); + assert_eq!(size_of::>(), 8); + let u8_expected_size = round_up(9, align_of::>()); + assert_eq!(size_of::>(), u8_expected_size); + let array_expected_size = round_up(28, align_of::>()); + assert_eq!(size_of::>(), array_expected_size); + assert_eq!(size_of::>(), 32); + + assert_eq!(align_of::(), align_of::()); + assert_eq!(align_of::>(), align_of::()); +} + +// Rounds x up to the next multiple of a +fn round_up(x: usize, a: usize) -> usize { + ((x + (a - 1)) / a) * a +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-discrim-range-overflow.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-discrim-range-overflow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-discrim-range-overflow.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-discrim-range-overflow.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(overflowing_literals)] + +// pretty-expanded FIXME #23616 + +pub enum E64 { + H64 = 0x7FFF_FFFF_FFFF_FFFF, + L64 = 0x8000_0000_0000_0000 +} +pub enum E32 { + H32 = 0x7FFF_FFFF, + L32 = 0x8000_0000 +} + +pub fn f(e64: E64, e32: E32) -> (bool,bool) { + (match e64 { + E64::H64 => true, + E64::L64 => false + }, + match e32 { + E32::H32 => true, + E32::L32 => false + }) +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-discrim-width-stuff.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-discrim-width-stuff.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-discrim-width-stuff.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-discrim-width-stuff.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,54 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(overflowing_literals)] +#![allow(dead_code)] + +macro_rules! check { + ($m:ident, $t:ty, $v:expr) => {{ + mod $m { + use std::mem::size_of; + #[derive(Copy, Clone, Debug)] + enum E { + V = $v, + A = 0 + } + static C: E = E::V; + pub fn check() { + assert_eq!(size_of::(), size_of::<$t>()); + assert_eq!(E::V as $t, $v as $t); + assert_eq!(C as $t, $v as $t); + assert_eq!(format!("{:?}", E::V), "V".to_string()); + assert_eq!(format!("{:?}", C), "V".to_string()); + } + } + $m::check(); + }} +} + +pub fn main() { + check!(a, u8, 0x17); + check!(b, u8, 0xe8); + check!(c, u16, 0x1727); + check!(d, u16, 0xe8d8); + check!(e, u32, 0x17273747); + check!(f, u32, 0xe8d8c8b8); + + check!(z, i8, 0x17); + check!(y, i8, -0x17); + check!(x, i16, 0x1727); + check!(w, i16, -0x1727); + check!(v, i32, 0x17273747); + check!(u, i32, -0x17273747); + + enum Simple { A, B } + assert_eq!(::std::mem::size_of::(), 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-discr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-discr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-discr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-discr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +enum Animal { + Cat = 0, + Dog = 1, + Horse = 2, + Snake = 3, +} + +enum Hero { + Batman = -1, + Superman = -2, + Ironman = -3, + Spiderman = -4 +} + +pub fn main() { + let pet: Animal = Animal::Snake; + let hero: Hero = Hero::Superman; + assert_eq!(pet as usize, 3); + assert_eq!(hero as isize, -2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-disr-val-pretty.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-disr-val-pretty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-disr-val-pretty.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-disr-val-pretty.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] +// pp-exact + + +enum color { red = 1, green, blue, imaginary = -1, } + +pub fn main() { + test_color(color::red, 1, "red".to_string()); + test_color(color::green, 2, "green".to_string()); + test_color(color::blue, 3, "blue".to_string()); + test_color(color::imaginary, -1, "imaginary".to_string()); +} + +fn test_color(color: color, val: isize, _name: String) { + assert_eq!(color as isize , val); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-export-inheritance.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-export-inheritance.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-export-inheritance.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-export-inheritance.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +mod a { + pub enum Foo { + Bar, + Baz, + Boo + } +} + +pub fn main() { + let _x = a::Foo::Bar; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-layout-optimization.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-layout-optimization.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-layout-optimization.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-layout-optimization.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,60 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we will do various size optimizations to enum layout, but +// *not* if `#[repr(u8)]` or `#[repr(C)]` is passed. See also #40029. + +#![allow(dead_code)] + +use std::mem; + +enum Nullable { + Alive(T), + Dropped, +} + +#[repr(u8)] +enum NullableU8 { + Alive(T), + Dropped, +} + +#[repr(C)] +enum NullableC { + Alive(T), + Dropped, +} + +struct StructNewtype(T); + +#[repr(C)] +struct StructNewtypeC(T); + +enum EnumNewtype { Variant(T) } + +#[repr(u8)] +enum EnumNewtypeU8 { Variant(T) } + +#[repr(C)] +enum EnumNewtypeC { Variant(T) } + +fn main() { + assert!(mem::size_of::>() == mem::size_of::>>()); + assert!(mem::size_of::>() < mem::size_of::>>()); + assert!(mem::size_of::>() < mem::size_of::>>()); + + assert!(mem::size_of::() == mem::size_of::>()); + assert!(mem::size_of::() == mem::size_of::>()); + + assert!(mem::size_of::() == mem::size_of::>()); + assert!(mem::size_of::() < mem::size_of::>()); + assert!(mem::size_of::() < mem::size_of::>()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-non-c-like-repr-c-and-int.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-non-c-like-repr-c-and-int.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-non-c-like-repr-c-and-int.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-non-c-like-repr-c-and-int.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,178 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// This test deserializes an enum in-place by transmuting to a union that +// should have the same layout, and manipulating the tag and payloads +// independently. This verifies that `repr(some_int)` has a stable representation, +// and that we don't miscompile these kinds of manipulations. + +use std::time::Duration; +use std::mem; + +#[repr(C, u8)] +#[derive(Copy, Clone, Eq, PartialEq, Debug)] +enum MyEnum { + A(u32), // Single primitive value + B { x: u8, y: i16 }, // Composite, and the offset of `y` depends on tag being internal + C, // Empty + D(Option), // Contains an enum + E(Duration), // Contains a struct +} + +#[repr(C)] +struct MyEnumRepr { + tag: MyEnumTag, + payload: MyEnumPayload, +} + +#[repr(C)] +#[allow(non_snake_case)] +union MyEnumPayload { + A: MyEnumVariantA, + B: MyEnumVariantB, + D: MyEnumVariantD, + E: MyEnumVariantE, +} + +#[repr(u8)] #[derive(Copy, Clone)] enum MyEnumTag { A, B, C, D, E } +#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantA(u32); +#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantB {x: u8, y: i16 } +#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantD(Option); +#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantE(Duration); + +fn main() { + let result: Vec> = vec![ + Ok(MyEnum::A(17)), + Ok(MyEnum::B { x: 206, y: 1145 }), + Ok(MyEnum::C), + Err(()), + Ok(MyEnum::D(Some(407))), + Ok(MyEnum::D(None)), + Ok(MyEnum::E(Duration::from_secs(100))), + Err(()), + ]; + + // Binary serialized version of the above (little-endian) + let input: Vec = vec![ + 0, 17, 0, 0, 0, + 1, 206, 121, 4, + 2, + 8, /* invalid tag value */ + 3, 0, 151, 1, 0, 0, + 3, 1, + 4, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, /* incomplete value */ + ]; + + let mut output = vec![]; + let mut buf = &input[..]; + + unsafe { + // This should be safe, because we don't match on it unless it's fully formed, + // and it doesn't have a destructor. + let mut dest: MyEnum = mem::uninitialized(); + while buf.len() > 0 { + match parse_my_enum(&mut dest, &mut buf) { + Ok(()) => output.push(Ok(dest)), + Err(()) => output.push(Err(())), + } + } + } + + assert_eq!(output, result); +} + +fn parse_my_enum<'a>(dest: &'a mut MyEnum, buf: &mut &[u8]) -> Result<(), ()> { + unsafe { + // Should be correct to do this transmute. + let dest: &'a mut MyEnumRepr = mem::transmute(dest); + let tag = read_u8(buf)?; + + dest.tag = match tag { + 0 => MyEnumTag::A, + 1 => MyEnumTag::B, + 2 => MyEnumTag::C, + 3 => MyEnumTag::D, + 4 => MyEnumTag::E, + _ => return Err(()), + }; + + match dest.tag { + MyEnumTag::A => { + dest.payload.A.0 = read_u32_le(buf)?; + } + MyEnumTag::B => { + dest.payload.B.x = read_u8(buf)?; + dest.payload.B.y = read_u16_le(buf)? as i16; + } + MyEnumTag::C => { + /* do nothing */ + } + MyEnumTag::D => { + let is_some = read_u8(buf)? == 0; + if is_some { + dest.payload.D.0 = Some(read_u32_le(buf)?); + } else { + dest.payload.D.0 = None; + } + } + MyEnumTag::E => { + let secs = read_u64_le(buf)?; + let nanos = read_u32_le(buf)?; + dest.payload.E.0 = Duration::new(secs, nanos); + } + } + Ok(()) + } +} + + + +// reader helpers + +fn read_u64_le(buf: &mut &[u8]) -> Result { + if buf.len() < 8 { return Err(()) } + let val = (buf[0] as u64) << 0 + | (buf[1] as u64) << 8 + | (buf[2] as u64) << 16 + | (buf[3] as u64) << 24 + | (buf[4] as u64) << 32 + | (buf[5] as u64) << 40 + | (buf[6] as u64) << 48 + | (buf[7] as u64) << 56; + *buf = &buf[8..]; + Ok(val) +} + +fn read_u32_le(buf: &mut &[u8]) -> Result { + if buf.len() < 4 { return Err(()) } + let val = (buf[0] as u32) << 0 + | (buf[1] as u32) << 8 + | (buf[2] as u32) << 16 + | (buf[3] as u32) << 24; + *buf = &buf[4..]; + Ok(val) +} + +fn read_u16_le(buf: &mut &[u8]) -> Result { + if buf.len() < 2 { return Err(()) } + let val = (buf[0] as u16) << 0 + | (buf[1] as u16) << 8; + *buf = &buf[2..]; + Ok(val) +} + +fn read_u8(buf: &mut &[u8]) -> Result { + if buf.len() < 1 { return Err(()) } + let val = buf[0]; + *buf = &buf[1..]; + Ok(val) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-non-c-like-repr-c.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-non-c-like-repr-c.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-non-c-like-repr-c.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-non-c-like-repr-c.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,178 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// This test deserializes an enum in-place by transmuting to a union that +// should have the same layout, and manipulating the tag and payloads +// independently. This verifies that `repr(some_int)` has a stable representation, +// and that we don't miscompile these kinds of manipulations. + +use std::time::Duration; +use std::mem; + +#[repr(C)] +#[derive(Copy, Clone, Eq, PartialEq, Debug)] +enum MyEnum { + A(u32), // Single primitive value + B { x: u8, y: i16 }, // Composite, and the offset of `y` depends on tag being internal + C, // Empty + D(Option), // Contains an enum + E(Duration), // Contains a struct +} + +#[repr(C)] +struct MyEnumRepr { + tag: MyEnumTag, + payload: MyEnumPayload, +} + +#[repr(C)] +#[allow(non_snake_case)] +union MyEnumPayload { + A: MyEnumVariantA, + B: MyEnumVariantB, + D: MyEnumVariantD, + E: MyEnumVariantE, +} + +#[repr(C)] #[derive(Copy, Clone)] enum MyEnumTag { A, B, C, D, E } +#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantA(u32); +#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantB {x: u8, y: i16 } +#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantD(Option); +#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantE(Duration); + +fn main() { + let result: Vec> = vec![ + Ok(MyEnum::A(17)), + Ok(MyEnum::B { x: 206, y: 1145 }), + Ok(MyEnum::C), + Err(()), + Ok(MyEnum::D(Some(407))), + Ok(MyEnum::D(None)), + Ok(MyEnum::E(Duration::from_secs(100))), + Err(()), + ]; + + // Binary serialized version of the above (little-endian) + let input: Vec = vec![ + 0, 17, 0, 0, 0, + 1, 206, 121, 4, + 2, + 8, /* invalid tag value */ + 3, 0, 151, 1, 0, 0, + 3, 1, + 4, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, /* incomplete value */ + ]; + + let mut output = vec![]; + let mut buf = &input[..]; + + unsafe { + // This should be safe, because we don't match on it unless it's fully formed, + // and it doesn't have a destructor. + let mut dest: MyEnum = mem::uninitialized(); + while buf.len() > 0 { + match parse_my_enum(&mut dest, &mut buf) { + Ok(()) => output.push(Ok(dest)), + Err(()) => output.push(Err(())), + } + } + } + + assert_eq!(output, result); +} + +fn parse_my_enum<'a>(dest: &'a mut MyEnum, buf: &mut &[u8]) -> Result<(), ()> { + unsafe { + // Should be correct to do this transmute. + let dest: &'a mut MyEnumRepr = mem::transmute(dest); + let tag = read_u8(buf)?; + + dest.tag = match tag { + 0 => MyEnumTag::A, + 1 => MyEnumTag::B, + 2 => MyEnumTag::C, + 3 => MyEnumTag::D, + 4 => MyEnumTag::E, + _ => return Err(()), + }; + + match dest.tag { + MyEnumTag::A => { + dest.payload.A.0 = read_u32_le(buf)?; + } + MyEnumTag::B => { + dest.payload.B.x = read_u8(buf)?; + dest.payload.B.y = read_u16_le(buf)? as i16; + } + MyEnumTag::C => { + /* do nothing */ + } + MyEnumTag::D => { + let is_some = read_u8(buf)? == 0; + if is_some { + dest.payload.D.0 = Some(read_u32_le(buf)?); + } else { + dest.payload.D.0 = None; + } + } + MyEnumTag::E => { + let secs = read_u64_le(buf)?; + let nanos = read_u32_le(buf)?; + dest.payload.E.0 = Duration::new(secs, nanos); + } + } + Ok(()) + } +} + + + +// reader helpers + +fn read_u64_le(buf: &mut &[u8]) -> Result { + if buf.len() < 8 { return Err(()) } + let val = (buf[0] as u64) << 0 + | (buf[1] as u64) << 8 + | (buf[2] as u64) << 16 + | (buf[3] as u64) << 24 + | (buf[4] as u64) << 32 + | (buf[5] as u64) << 40 + | (buf[6] as u64) << 48 + | (buf[7] as u64) << 56; + *buf = &buf[8..]; + Ok(val) +} + +fn read_u32_le(buf: &mut &[u8]) -> Result { + if buf.len() < 4 { return Err(()) } + let val = (buf[0] as u32) << 0 + | (buf[1] as u32) << 8 + | (buf[2] as u32) << 16 + | (buf[3] as u32) << 24; + *buf = &buf[4..]; + Ok(val) +} + +fn read_u16_le(buf: &mut &[u8]) -> Result { + if buf.len() < 2 { return Err(()) } + let val = (buf[0] as u16) << 0 + | (buf[1] as u16) << 8; + *buf = &buf[2..]; + Ok(val) +} + +fn read_u8(buf: &mut &[u8]) -> Result { + if buf.len() < 1 { return Err(()) } + let val = buf[0]; + *buf = &buf[1..]; + Ok(val) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-non-c-like-repr-int.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-non-c-like-repr-int.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-non-c-like-repr-int.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-non-c-like-repr-int.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,174 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// This test deserializes an enum in-place by transmuting to a union that +// should have the same layout, and manipulating the tag and payloads +// independently. This verifies that `repr(some_int)` has a stable representation, +// and that we don't miscompile these kinds of manipulations. + +use std::time::Duration; +use std::mem; + +#[repr(u8)] +#[derive(Copy, Clone, Eq, PartialEq, Debug)] +enum MyEnum { + A(u32), // Single primitive value + B { x: u8, y: i16 }, // Composite, and the offset of `y` depends on tag being internal + C, // Empty + D(Option), // Contains an enum + E(Duration), // Contains a struct +} + +#[allow(non_snake_case)] +#[repr(C)] +union MyEnumRepr { + A: MyEnumVariantA, + B: MyEnumVariantB, + C: MyEnumVariantC, + D: MyEnumVariantD, + E: MyEnumVariantE, +} + +#[repr(u8)] #[derive(Copy, Clone)] enum MyEnumTag { A, B, C, D, E } +#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantA(MyEnumTag, u32); +#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantB { tag: MyEnumTag, x: u8, y: i16 } +#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantC(MyEnumTag); +#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantD(MyEnumTag, Option); +#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantE(MyEnumTag, Duration); + +fn main() { + let result: Vec> = vec![ + Ok(MyEnum::A(17)), + Ok(MyEnum::B { x: 206, y: 1145 }), + Ok(MyEnum::C), + Err(()), + Ok(MyEnum::D(Some(407))), + Ok(MyEnum::D(None)), + Ok(MyEnum::E(Duration::from_secs(100))), + Err(()), + ]; + + // Binary serialized version of the above (little-endian) + let input: Vec = vec![ + 0, 17, 0, 0, 0, + 1, 206, 121, 4, + 2, + 8, /* invalid tag value */ + 3, 0, 151, 1, 0, 0, + 3, 1, + 4, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, /* incomplete value */ + ]; + + let mut output = vec![]; + let mut buf = &input[..]; + + unsafe { + // This should be safe, because we don't match on it unless it's fully formed, + // and it doesn't have a destructor. + let mut dest: MyEnum = mem::uninitialized(); + while buf.len() > 0 { + match parse_my_enum(&mut dest, &mut buf) { + Ok(()) => output.push(Ok(dest)), + Err(()) => output.push(Err(())), + } + } + } + + assert_eq!(output, result); +} + +fn parse_my_enum<'a>(dest: &'a mut MyEnum, buf: &mut &[u8]) -> Result<(), ()> { + unsafe { + // Should be correct to do this transmute. + let dest: &'a mut MyEnumRepr = mem::transmute(dest); + let tag = read_u8(buf)?; + + dest.A.0 = match tag { + 0 => MyEnumTag::A, + 1 => MyEnumTag::B, + 2 => MyEnumTag::C, + 3 => MyEnumTag::D, + 4 => MyEnumTag::E, + _ => return Err(()), + }; + + match dest.B.tag { + MyEnumTag::A => { + dest.A.1 = read_u32_le(buf)?; + } + MyEnumTag::B => { + dest.B.x = read_u8(buf)?; + dest.B.y = read_u16_le(buf)? as i16; + } + MyEnumTag::C => { + /* do nothing */ + } + MyEnumTag::D => { + let is_some = read_u8(buf)? == 0; + if is_some { + dest.D.1 = Some(read_u32_le(buf)?); + } else { + dest.D.1 = None; + } + } + MyEnumTag::E => { + let secs = read_u64_le(buf)?; + let nanos = read_u32_le(buf)?; + dest.E.1 = Duration::new(secs, nanos); + } + } + Ok(()) + } +} + + + +// reader helpers + +fn read_u64_le(buf: &mut &[u8]) -> Result { + if buf.len() < 8 { return Err(()) } + let val = (buf[0] as u64) << 0 + | (buf[1] as u64) << 8 + | (buf[2] as u64) << 16 + | (buf[3] as u64) << 24 + | (buf[4] as u64) << 32 + | (buf[5] as u64) << 40 + | (buf[6] as u64) << 48 + | (buf[7] as u64) << 56; + *buf = &buf[8..]; + Ok(val) +} + +fn read_u32_le(buf: &mut &[u8]) -> Result { + if buf.len() < 4 { return Err(()) } + let val = (buf[0] as u32) << 0 + | (buf[1] as u32) << 8 + | (buf[2] as u32) << 16 + | (buf[3] as u32) << 24; + *buf = &buf[4..]; + Ok(val) +} + +fn read_u16_le(buf: &mut &[u8]) -> Result { + if buf.len() < 2 { return Err(()) } + let val = (buf[0] as u16) << 0 + | (buf[1] as u16) << 8; + *buf = &buf[2..]; + Ok(val) +} + +fn read_u8(buf: &mut &[u8]) -> Result { + if buf.len() < 1 { return Err(()) } + let val = buf[0]; + *buf = &buf[1..]; + Ok(val) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-nullable-const-null-with-fields.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-nullable-const-null-with-fields.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-nullable-const-null-with-fields.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-nullable-const-null-with-fields.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::result::Result; +use std::result::Result::Ok; + +static C: Result<(), Box> = Ok(()); + +// This is because of yet another bad assertion (ICE) about the null side of a nullable enum. +// So we won't actually compile if the bug is present, but we check the value in main anyway. + +pub fn main() { + assert!(C.is_ok()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-nullable-simplifycfg-misopt.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-nullable-simplifycfg-misopt.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-nullable-simplifycfg-misopt.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-nullable-simplifycfg-misopt.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +/*! + * This is a regression test for a bug in LLVM, fixed in upstream r179587, + * where the switch instructions generated for destructuring enums + * represented with nullable pointers could be misoptimized in some cases. + */ + +enum List { Nil, Cons(X, Box>) } +pub fn main() { + match List::Cons(10, box List::Nil) { + List::Cons(10, _) => {} + List::Nil => {} + _ => panic!() + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-null-pointer-opt.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-null-pointer-opt.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-null-pointer-opt.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-null-pointer-opt.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,74 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::mem::size_of; +use std::num::NonZeroUsize; +use std::ptr::NonNull; +use std::rc::Rc; +use std::sync::Arc; + +trait Trait { fn dummy(&self) { } } +trait Mirror { type Image; } +impl Mirror for T { type Image = T; } +struct ParamTypeStruct(T); +struct AssocTypeStruct(::Image); + +fn main() { + // Functions + assert_eq!(size_of::(), size_of::>()); + assert_eq!(size_of::(), size_of::>()); + + // Slices - &str / &[T] / &mut [T] + assert_eq!(size_of::<&str>(), size_of::>()); + assert_eq!(size_of::<&[isize]>(), size_of::>()); + assert_eq!(size_of::<&mut [isize]>(), size_of::>()); + + // Traits - Box / &Trait / &mut Trait + assert_eq!(size_of::>(), size_of::>>()); + assert_eq!(size_of::<&Trait>(), size_of::>()); + assert_eq!(size_of::<&mut Trait>(), size_of::>()); + + // Pointers - Box + assert_eq!(size_of::>(), size_of::>>()); + + // The optimization can't apply to raw pointers + assert!(size_of::>() != size_of::<*const isize>()); + assert!(Some(0 as *const isize).is_some()); // Can't collapse None to null + + struct Foo { + _a: Box + } + struct Bar(Box); + + // Should apply through structs + assert_eq!(size_of::(), size_of::>()); + assert_eq!(size_of::(), size_of::>()); + // and tuples + assert_eq!(size_of::<(u8, Box)>(), size_of::)>>()); + // and fixed-size arrays + assert_eq!(size_of::<[Box; 1]>(), size_of::; 1]>>()); + + // Should apply to NonZero + assert_eq!(size_of::(), size_of::>()); + assert_eq!(size_of::>(), size_of::>>()); + + // Should apply to types that use NonZero internally + assert_eq!(size_of::>(), size_of::>>()); + assert_eq!(size_of::>(), size_of::>>()); + assert_eq!(size_of::>(), size_of::>>()); + + // Should apply to types that have NonZero transitively + assert_eq!(size_of::(), size_of::>()); + + // Should apply to types where the pointer is substituted + assert_eq!(size_of::<&u8>(), size_of::>>()); + assert_eq!(size_of::<&u8>(), size_of::>>()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-univariant-repr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-univariant-repr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-univariant-repr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-univariant-repr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,61 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::mem; + +// Univariant C-like enum +#[repr(i32)] +enum Univariant { + X = 17 +} + +#[repr(u16)] +enum UnivariantWithoutDescr { + Y +} + +#[repr(u8)] +enum UnivariantWithData { + Z(u8), +} + +pub fn main() { + { + assert_eq!(4, mem::size_of::()); + assert_eq!(17, Univariant::X as i32); + + let enums: &[Univariant] = + &[Univariant::X, Univariant::X, Univariant::X]; + let ints: &[i32] = unsafe { mem::transmute(enums) }; + // check it has the same memory layout as i32 + assert_eq!(&[17, 17, 17], ints); + } + + { + assert_eq!(2, mem::size_of::()); + let descr = UnivariantWithoutDescr::Y as u16; + + let enums: &[UnivariantWithoutDescr] = + &[UnivariantWithoutDescr::Y, UnivariantWithoutDescr::Y, UnivariantWithoutDescr::Y]; + let ints: &[u16] = unsafe { mem::transmute(enums) }; + // check it has the same memory layout as u16 + assert_eq!(&[descr, descr, descr], ints); + } + + { + assert_eq!(2, mem::size_of::()); + + match UnivariantWithData::Z(4) { + UnivariantWithData::Z(x) => assert_eq!(x, 4), + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-variants.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-variants.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-variants.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-variants.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_assignments)] +// pretty-expanded FIXME #23616 + +#![allow(unused_variables)] + +enum Animal { + Dog (String, f64), + Cat { name: String, weight: f64 } +} + +pub fn main() { + let mut a: Animal = Animal::Dog("Cocoa".to_string(), 37.2); + a = Animal::Cat{ name: "Spotty".to_string(), weight: 2.7 }; + // permuting the fields should work too + let _c = Animal::Cat { weight: 3.1, name: "Spreckles".to_string() }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-vec-initializer.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-vec-initializer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-vec-initializer.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/enum-vec-initializer.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +enum Flopsy { + Bunny = 2 +} + +const BAR:usize = Flopsy::Bunny as usize; +const BAR2:usize = BAR; + +pub fn main() { + let _v = [0; Flopsy::Bunny as usize]; + let _v = [0; BAR]; + let _v = [0; BAR2]; + const BAR3:usize = BAR2; + let _v = [0; BAR3]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/export-abstract-tag.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/export-abstract-tag.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/export-abstract-tag.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/export-abstract-tag.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +// We can export tags without exporting the variants to create a simple +// sort of ADT. + +// pretty-expanded FIXME #23616 + +mod foo { + pub enum t { t1, } + + pub fn f() -> t { return t::t1; } +} + +pub fn main() { let _v: foo::t = foo::f(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/export-tag-variant.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/export-tag-variant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/export-tag-variant.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/export-tag-variant.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] +// pretty-expanded FIXME #23616 + +mod foo { + pub enum t { t1, } +} + +pub fn main() { let _v = foo::t::t1; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/expr-if-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/expr-if-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/expr-if-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/expr-if-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + + + + +// Tests for if as expressions returning nominal types + +#[derive(Copy, Clone)] +struct I { i: isize } + +fn test_rec() { + let rs = if true { I {i: 100} } else { I {i: 101} }; + assert_eq!(rs.i, 100); +} + +#[derive(Copy, Clone, Debug)] +enum mood { happy, sad, } + +impl PartialEq for mood { + fn eq(&self, other: &mood) -> bool { + ((*self) as usize) == ((*other) as usize) + } + fn ne(&self, other: &mood) -> bool { !(*self).eq(other) } +} + +fn test_tag() { + let rs = if true { mood::happy } else { mood::sad }; + assert_eq!(rs, mood::happy); +} + +pub fn main() { test_rec(); test_tag(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/expr-match-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/expr-match-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/expr-match-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/expr-match-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + + + + +// Tests for match as expressions resulting in struct types +#[derive(Copy, Clone)] +struct R { i: isize } + +fn test_rec() { + let rs = match true { true => R {i: 100}, _ => panic!() }; + assert_eq!(rs.i, 100); +} + +#[derive(Copy, Clone, Debug)] +enum mood { happy, sad, } + +impl PartialEq for mood { + fn eq(&self, other: &mood) -> bool { + ((*self) as usize) == ((*other) as usize) + } + fn ne(&self, other: &mood) -> bool { !(*self).eq(other) } +} + +fn test_tag() { + let rs = match true { true => { mood::happy } false => { mood::sad } }; + assert_eq!(rs, mood::happy); +} + +pub fn main() { test_rec(); test_tag(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/field-destruction-order.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/field-destruction-order.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/field-destruction-order.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/field-destruction-order.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,57 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_upper_case_globals)] + +// In theory, it doesn't matter what order destructors are run in for rust +// because we have explicit ownership of values meaning that there's no need to +// run one before another. With unsafe code, however, there may be a safe +// interface which relies on fields having their destructors run in a particular +// order. At the time of this writing, std::rt::sched::Scheduler is an example +// of a structure which contains unsafe handles to FFI-like types, and the +// destruction order of the fields matters in the sense that some handles need +// to get destroyed before others. +// +// In C++, destruction order happens bottom-to-top in order of field +// declarations, but we currently run them top-to-bottom. I don't think the +// order really matters that much as long as we define what it is. + + +struct A; +struct B; +struct C { + a: A, + b: B, +} + +static mut hit: bool = false; + +impl Drop for A { + fn drop(&mut self) { + unsafe { + assert!(!hit); + hit = true; + } + } +} + +impl Drop for B { + fn drop(&mut self) { + unsafe { + assert!(hit); + } + } +} + +pub fn main() { + let _c = C { a: A, b: B }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/foreign-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/foreign-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/foreign-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/foreign-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// Passing enums by value + +// pretty-expanded FIXME #23616 + +pub enum void { } + +mod bindgen { + use super::void; + + extern { + pub fn printf(v: void); + } +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/functional-struct-upd.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/functional-struct-upd.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/functional-struct-upd.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/functional-struct-upd.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(Debug)] +struct Foo { + x: isize, + y: isize +} + +pub fn main() { + let a = Foo { x: 1, y: 2 }; + let c = Foo { x: 4, .. a}; + println!("{:?}", c); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/ivec-tag.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/ivec-tag.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/ivec-tag.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/ivec-tag.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// ignore-emscripten no threads support + +use std::thread; +use std::sync::mpsc::{channel, Sender}; + +fn producer(tx: &Sender>) { + tx.send( + vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13]).unwrap(); +} + +pub fn main() { + let (tx, rx) = channel::>(); + let prod = thread::spawn(move|| { + producer(&tx) + }); + + let _data: Vec = rx.recv().unwrap(); + prod.join(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/module-qualified-struct-destructure.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/module-qualified-struct-destructure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/module-qualified-struct-destructure.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/module-qualified-struct-destructure.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +mod m { + pub struct S { + pub x: isize, + pub y: isize + } +} + +pub fn main() { + let x = m::S { x: 1, y: 2 }; + let m::S { x: _a, y: _b } = x; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enum-emulate-flat.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enum-emulate-flat.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enum-emulate-flat.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enum-emulate-flat.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,54 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +pub use Foo::*; +use nest::{Bar, D, E, F}; + +pub enum Foo { + A, + B(isize), + C { a: isize }, +} + +impl Foo { + pub fn foo() {} +} + +fn _f(f: Foo) { + match f { + A | B(_) | C { .. } => {} + } +} + +mod nest { + pub use self::Bar::*; + + pub enum Bar { + D, + E(isize), + F { a: isize }, + } + + impl Bar { + pub fn foo() {} + } +} + +fn _f2(f: Bar) { + match f { + D | E(_) | F { .. } => {} + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enum-emulate-flat-xc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enum-emulate-flat-xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enum-emulate-flat-xc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enum-emulate-flat-xc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +// aux-build:namespaced_enum_emulate_flat.rs + +// pretty-expanded FIXME #23616 + +extern crate namespaced_enum_emulate_flat; + +use namespaced_enum_emulate_flat::{Foo, A, B, C}; +use namespaced_enum_emulate_flat::nest::{Bar, D, E, F}; + +fn _f(f: Foo) { + match f { + A | B(_) | C { .. } => {} + } +} + +fn _f2(f: Bar) { + match f { + D | E(_) | F { .. } => {} + } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enum-glob-import.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enum-glob-import.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enum-glob-import.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enum-glob-import.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +mod m2 { + pub enum Foo { + A, + B(isize), + C { a: isize }, + } + + impl Foo { + pub fn foo() {} + } +} + +mod m { + pub use m2::Foo::*; +} + +fn _f(f: m2::Foo) { + use m2::Foo::*; + + match f { + A | B(_) | C { .. } => {} + } +} + +fn _f2(f: m2::Foo) { + match f { + m::A | m::B(_) | m::C { .. } => {} + } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enum-glob-import-xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enum-glob-import-xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enum-glob-import-xcrate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enum-glob-import-xcrate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:namespaced_enums.rs + +// pretty-expanded FIXME #23616 + +extern crate namespaced_enums; + +fn _f(f: namespaced_enums::Foo) { + use namespaced_enums::Foo::*; + + match f { + A | B(_) | C { .. } => {} + } +} + +mod m { + pub use namespaced_enums::Foo::*; +} + +fn _f2(f: namespaced_enums::Foo) { + match f { + m::A | m::B(_) | m::C { .. } => {} + } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enums.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enums.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enums.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enums.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +enum Foo { + A, + B(isize), + C { a: isize }, +} + +fn _foo (f: Foo) { + match f { + Foo::A | Foo::B(_) | Foo::C { .. } => {} + } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enums-xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enums-xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enums-xcrate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/namespaced-enums-xcrate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:namespaced_enums.rs + +// pretty-expanded FIXME #23616 + +extern crate namespaced_enums; + +use namespaced_enums::Foo; + +fn _foo (f: Foo) { + match f { + Foo::A | Foo::B(_) | Foo::C { .. } => {} + } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/nested-enum-same-names.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/nested-enum-same-names.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/nested-enum-same-names.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/nested-enum-same-names.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +/* + +#7770 ICE with sibling methods containing same-name-enum containing + same-name-member + +If you have two methods in an impl block, each containing an enum +(with the same name), each containing at least one value with the same +name, rustc gives the same LLVM symbol for the two of them and fails, +as it does not include the method name in the symbol name. + +*/ + +pub struct Foo; +impl Foo { + pub fn foo() { + enum Panic { Common }; + } + pub fn bar() { + enum Panic { Common }; + } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/newtype-struct-drop-run.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/newtype-struct-drop-run.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/newtype-struct-drop-run.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/newtype-struct-drop-run.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Make sure the destructor is run for newtype structs. + +use std::cell::Cell; + +struct Foo<'a>(&'a Cell); + +impl<'a> Drop for Foo<'a> { + fn drop(&mut self) { + let Foo(i) = *self; + i.set(23); + } +} + +pub fn main() { + let y = &Cell::new(32); + { + let _x = Foo(y); + } + assert_eq!(y.get(), 23); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/newtype-struct-with-dtor.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/newtype-struct-with-dtor.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/newtype-struct-with-dtor.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/newtype-struct-with-dtor.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_unsafe)] +#![allow(unused_variables)] +// pretty-expanded FIXME #23616 + +pub struct Fd(u32); + +fn foo(a: u32) {} + +impl Drop for Fd { + fn drop(&mut self) { + unsafe { + let Fd(s) = *self; + foo(s); + } + } +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/newtype-struct-xc-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/newtype-struct-xc-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/newtype-struct-xc-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/newtype-struct-xc-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:newtype_struct_xc.rs + +// pretty-expanded FIXME #23616 + +extern crate newtype_struct_xc; +use newtype_struct_xc::Au; + +fn f() -> Au { + Au(2) +} + +pub fn main() { + let _ = f(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/newtype-struct-xc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/newtype-struct-xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/newtype-struct-xc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/newtype-struct-xc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:newtype_struct_xc.rs + +// pretty-expanded FIXME #23616 + +extern crate newtype_struct_xc; + +pub fn main() { + let _ = newtype_struct_xc::Au(2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/nonzero-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/nonzero-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/nonzero-enum.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/nonzero-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +use std::mem::size_of; + +enum E { + A = 1, + B = 2, + C = 3, +} + +struct S { + a: u16, + b: u8, + e: E, +} + +fn main() { + assert_eq!(size_of::(), 1); + assert_eq!(size_of::>(), 1); + assert_eq!(size_of::>(), 1); + assert_eq!(size_of::>(), size_of::()); + let enone = None::; + let esome = Some(E::A); + if let Some(..) = enone { + panic!(); + } + if let None = esome { + panic!(); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/numeric-fields.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/numeric-fields.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/numeric-fields.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/numeric-fields.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct S(u8, u16); + +fn main() { + let s = S{1: 10, 0: 11}; + match s { + S{0: a, 1: b, ..} => { + assert_eq!(a, 11); + assert_eq!(b, 10); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/object-lifetime-default-from-ref-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/object-lifetime-default-from-ref-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/object-lifetime-default-from-ref-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/object-lifetime-default-from-ref-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,68 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that the lifetime of the enclosing `&` is used for the object +// lifetime bound. + +// pretty-expanded FIXME #23616 + +#![allow(dead_code)] + +use std::fmt::Display; + +trait Test { + fn foo(&self) { } +} + +struct Ref<'a,T:'a+?Sized> { + r: &'a T +} + +struct Ref2<'a,'b,T:'a+'b+?Sized> { + a: &'a T, + b: &'b T +} + +struct SomeStruct<'a> { + t: Ref<'a,Test>, + u: Ref<'a,Test+'a>, +} + +fn a<'a>(t: Ref<'a,Test>, mut ss: SomeStruct<'a>) { + ss.t = t; +} + +fn b<'a>(t: Ref<'a,Test>, mut ss: SomeStruct<'a>) { + ss.u = t; +} + +fn c<'a>(t: Ref<'a,Test+'a>, mut ss: SomeStruct<'a>) { + ss.t = t; +} + +fn d<'a>(t: Ref<'a,Test+'a>, mut ss: SomeStruct<'a>) { + ss.u = t; +} + +fn e<'a>(_: Ref<'a, Display+'static>) {} +fn g<'a, 'b>(_: Ref2<'a, 'b, Display+'static>) {} + + +fn main() { + // Inside a function body, we can just infer all + // lifetimes, to allow Ref<'tmp, Display+'static> + // and Ref2<'tmp, 'tmp, Display+'static>. + let x = &0 as &(Display+'static); + let r: Ref = Ref { r: x }; + let r2: Ref2 = Ref2 { a: x, b: x }; + e(r); + g(r2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/object-lifetime-default-from-rptr-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/object-lifetime-default-from-rptr-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/object-lifetime-default-from-rptr-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/object-lifetime-default-from-rptr-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that the lifetime from the enclosing `&` is "inherited" +// through the `MyBox` struct. + +// pretty-expanded FIXME #23616 + +#![allow(dead_code)] + +trait Test { + fn foo(&self) { } +} + +struct SomeStruct<'a> { + t: &'a MyBox, + u: &'a MyBox, +} + +struct MyBox { + b: Box +} + +fn a<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { + ss.t = t; +} + +fn b<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { + ss.u = t; +} + +// see also compile-fail/object-lifetime-default-from-rptr-box-error.rs + +fn d<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { + ss.u = t; +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec-align-u32.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec-align-u32.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec-align-u32.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec-align-u32.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,66 @@ +// Copyright 2012-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_unsafe)] +// Issue #2303 + +#![feature(intrinsics)] + +use std::mem; + +mod rusti { + extern "rust-intrinsic" { + pub fn pref_align_of() -> usize; + pub fn min_align_of() -> usize; + } +} + +// This is the type with the questionable alignment +#[derive(Debug)] +struct Inner { + c64: u32 +} + +// This is the type that contains the type with the +// questionable alignment, for testing +#[derive(Debug)] +struct Outer { + c8: u8, + t: Inner +} + +mod m { + pub fn align() -> usize { 4 } + pub fn size() -> usize { 8 } +} + +pub fn main() { + unsafe { + let x = Outer {c8: 22, t: Inner {c64: 44}}; + + // Send it through the shape code + let y = format!("{:?}", x); + + println!("align inner = {:?}", rusti::min_align_of::()); + println!("size outer = {:?}", mem::size_of::()); + println!("y = {:?}", y); + + // per clang/gcc the alignment of `inner` is 4 on x86. + assert_eq!(rusti::min_align_of::(), m::align()); + + // per clang/gcc the size of `outer` should be 12 + // because `inner`s alignment was 4. + assert_eq!(mem::size_of::(), m::size()); + + assert_eq!(y, "Outer { c8: 22, t: Inner { c64: 44 } }".to_string()); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec-align-u64.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec-align-u64.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec-align-u64.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec-align-u64.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,111 @@ +// Copyright 2012-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_unsafe)] +// ignore-wasm32-bare seems unimportant to test + +// Issue #2303 + +#![feature(intrinsics)] + +use std::mem; + +mod rusti { + extern "rust-intrinsic" { + pub fn pref_align_of() -> usize; + pub fn min_align_of() -> usize; + } +} + +// This is the type with the questionable alignment +#[derive(Debug)] +struct Inner { + c64: u64 +} + +// This is the type that contains the type with the +// questionable alignment, for testing +#[derive(Debug)] +struct Outer { + c8: u8, + t: Inner +} + + +#[cfg(any(target_os = "android", + target_os = "cloudabi", + target_os = "dragonfly", + target_os = "emscripten", + target_os = "freebsd", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", + target_os = "solaris"))] +mod m { + #[cfg(target_arch = "x86")] + pub mod m { + pub fn align() -> usize { 4 } + pub fn size() -> usize { 12 } + } + + #[cfg(not(target_arch = "x86"))] + pub mod m { + pub fn align() -> usize { 8 } + pub fn size() -> usize { 16 } + } +} + +#[cfg(target_os = "bitrig")] +mod m { + #[cfg(target_arch = "x86_64")] + pub mod m { + pub fn align() -> usize { 8 } + pub fn size() -> usize { 16 } + } +} + +#[cfg(target_os = "windows")] +mod m { + #[cfg(target_arch = "x86")] + pub mod m { + pub fn align() -> usize { 8 } + pub fn size() -> usize { 16 } + } + + #[cfg(target_arch = "x86_64")] + pub mod m { + pub fn align() -> usize { 8 } + pub fn size() -> usize { 16 } + } +} + +pub fn main() { + unsafe { + let x = Outer {c8: 22, t: Inner {c64: 44}}; + + let y = format!("{:?}", x); + + println!("align inner = {:?}", rusti::min_align_of::()); + println!("size outer = {:?}", mem::size_of::()); + println!("y = {:?}", y); + + // per clang/gcc the alignment of `Inner` is 4 on x86. + assert_eq!(rusti::min_align_of::(), m::m::align()); + + // per clang/gcc the size of `Outer` should be 12 + // because `Inner`s alignment was 4. + assert_eq!(mem::size_of::(), m::m::size()); + + assert_eq!(y, "Outer { c8: 22, t: Inner { c64: 44 } }".to_string()); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec-auto.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec-auto.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec-auto.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec-auto.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + + +// Issue #50. + +struct X { foo: String, bar: String } + +pub fn main() { + let x = X {foo: "hello".to_string(), bar: "world".to_string()}; + println!("{}", x.foo.clone()); + println!("{}", x.bar.clone()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec-extend.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec-extend.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec-extend.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec-extend.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + + + +struct Point {x: isize, y: isize} + +pub fn main() { + let origin: Point = Point {x: 0, y: 0}; + let right: Point = Point {x: origin.x + 10,.. origin}; + let up: Point = Point {y: origin.y + 10,.. origin}; + assert_eq!(origin.x, 0); + assert_eq!(origin.y, 0); + assert_eq!(right.x, 10); + assert_eq!(right.y, 0); + assert_eq!(up.x, 0); + assert_eq!(up.y, 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/record-pat.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/record-pat.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/record-pat.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/record-pat.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] +#![allow(non_shorthand_field_patterns)] + +enum t1 { a(isize), b(usize), } +struct T2 {x: t1, y: isize} +enum t3 { c(T2, usize), } + +fn m(input: t3) -> isize { + match input { + t3::c(T2 {x: t1::a(m), ..}, _) => { return m; } + t3::c(T2 {x: t1::b(m), y: y}, z) => { return ((m + z) as isize) + y; } + } +} + +pub fn main() { + assert_eq!(m(t3::c(T2 {x: t1::a(10), y: 5}, 4)), 10); + assert_eq!(m(t3::c(T2 {x: t1::b(10), y: 5}, 4)), 19); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#[derive(Copy, Clone)] +struct Rect {x: isize, y: isize, w: isize, h: isize} + +fn f(r: Rect, x: isize, y: isize, w: isize, h: isize) { + assert_eq!(r.x, x); + assert_eq!(r.y, y); + assert_eq!(r.w, w); + assert_eq!(r.h, h); +} + +pub fn main() { + let r: Rect = Rect {x: 10, y: 20, w: 100, h: 200}; + assert_eq!(r.x, 10); + assert_eq!(r.y, 20); + assert_eq!(r.w, 100); + assert_eq!(r.h, 200); + let r2: Rect = r; + let x: isize = r2.x; + assert_eq!(x, 10); + f(r, 10, 20, 100, 200); + f(r2, 10, 20, 100, 200); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec-tup.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec-tup.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec-tup.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/rec-tup.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + + +#[derive(Copy, Clone)] +struct Point {x: isize, y: isize} + +type rect = (Point, Point); + +fn fst(r: rect) -> Point { let (fst, _) = r; return fst; } +fn snd(r: rect) -> Point { let (_, snd) = r; return snd; } + +fn f(r: rect, x1: isize, y1: isize, x2: isize, y2: isize) { + assert_eq!(fst(r).x, x1); + assert_eq!(fst(r).y, y1); + assert_eq!(snd(r).x, x2); + assert_eq!(snd(r).y, y2); +} + +pub fn main() { + let r: rect = (Point {x: 10, y: 20}, Point {x: 11, y: 22}); + assert_eq!(fst(r).x, 10); + assert_eq!(fst(r).y, 20); + assert_eq!(snd(r).x, 11); + assert_eq!(snd(r).y, 22); + let r2 = r; + let x: isize = fst(r2).x; + assert_eq!(x, 10); + f(r, 10, 20, 11, 22); + f(r2, 10, 20, 11, 22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/resource-in-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/resource-in-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/resource-in-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/resource-in-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +// Ensures that class dtors run if the object is inside an enum +// variant + +use std::cell::Cell; + +type closable<'a> = &'a Cell; + +struct close_res<'a> { + i: closable<'a>, + +} + +impl<'a> Drop for close_res<'a> { + fn drop(&mut self) { + self.i.set(false); + } +} + +fn close_res(i: closable) -> close_res { + close_res { + i: i + } +} + +enum option { none, some(T), } + +fn sink(_res: option) { } + +pub fn main() { + let c = &Cell::new(true); + sink(option::none); + sink(option::some(close_res(c))); + assert!(!c.get()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/simple-generic-tag.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/simple-generic-tag.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/simple-generic-tag.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/simple-generic-tag.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + + + +// pretty-expanded FIXME #23616 + +enum clam { a(T), } + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/simple-match-generic-tag.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/simple-match-generic-tag.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/simple-match-generic-tag.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/simple-match-generic-tag.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +enum opt { none, some(T) } + +pub fn main() { + let x = opt::none::; + match x { + opt::none:: => { println!("hello world"); } + opt::some(_) => { } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/small-enum-range-edge.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/small-enum-range-edge.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/small-enum-range-edge.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/small-enum-range-edge.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_upper_case_globals)] + +// Tests the range assertion wraparound case when reading discriminants. + +#[repr(u8)] +#[derive(Copy, Clone)] +enum Eu { Lu = 0, Hu = 255 } + +static CLu: Eu = Eu::Lu; +static CHu: Eu = Eu::Hu; + +#[repr(i8)] +#[derive(Copy, Clone)] +enum Es { Ls = -128, Hs = 127 } + +static CLs: Es = Es::Ls; +static CHs: Es = Es::Hs; + +pub fn main() { + assert_eq!((Eu::Hu as u8).wrapping_add(1), Eu::Lu as u8); + assert_eq!((Es::Hs as i8).wrapping_add(1), Es::Ls as i8); + assert_eq!(CLu as u8, Eu::Lu as u8); + assert_eq!(CHu as u8, Eu::Hu as u8); + assert_eq!(CLs as i8, Es::Ls as i8); + assert_eq!(CHs as i8, Es::Hs as i8); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/small-enums-with-fields.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/small-enums-with-fields.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/small-enums-with-fields.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/small-enums-with-fields.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::mem::size_of; + +#[derive(PartialEq, Debug)] +enum Either { Left(T), Right(U) } + +macro_rules! check { + ($t:ty, $sz:expr, $($e:expr, $s:expr),*) => {{ + assert_eq!(size_of::<$t>(), $sz); + $({ + static S: $t = $e; + let v: $t = $e; + assert_eq!(S, v); + assert_eq!(format!("{:?}", v), $s); + assert_eq!(format!("{:?}", S), $s); + });* + }} +} + +pub fn main() { + check!(Option, 2, + None, "None", + Some(129), "Some(129)"); + check!(Option, 4, + None, "None", + Some(-20000), "Some(-20000)"); + check!(Either, 2, + Either::Left(132), "Left(132)", + Either::Right(-32), "Right(-32)"); + check!(Either, 4, + Either::Left(132), "Left(132)", + Either::Right(-20000), "Right(-20000)"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-aliases.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-aliases.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-aliases.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-aliases.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,74 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_shorthand_field_patterns)] + +use std::mem; + +struct S { + x: isize, + y: isize, +} + +type S2 = S; + +struct S3 { + x: U, + y: V +} + +type S4 = S3; + +fn main() { + let s = S2 { + x: 1, + y: 2, + }; + match s { + S2 { + x: x, + y: y + } => { + assert_eq!(x, 1); + assert_eq!(y, 2); + } + } + // check that generics can be specified from the pattern + let s = S4 { + x: 4, + y: 'a' + }; + match s { + S4:: { + x: x, + y: y + } => { + assert_eq!(x, 4); + assert_eq!(y, 'a'); + assert_eq!(mem::size_of_val(&x), 1); + } + }; + // check that generics can be specified from the constructor + let s = S4:: { + x: 5, + y: 'b' + }; + match s { + S4 { + x: x, + y: y + } => { + assert_eq!(x, 5); + assert_eq!(y, 'b'); + assert_eq!(mem::size_of_val(&x), 2); + } + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-aliases-xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-aliases-xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-aliases-xcrate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-aliases-xcrate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +#![allow(non_shorthand_field_patterns)] + +// aux-build:xcrate_struct_aliases.rs + +extern crate xcrate_struct_aliases; + +use xcrate_struct_aliases::{S, S2}; + +fn main() { + let s = S2 { + x: 1, + y: 2, + }; + match s { + S2 { + x: x, + y: y + } => { + assert_eq!(x, 1); + assert_eq!(y, 2); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-destructuring-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-destructuring-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-destructuring-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-destructuring-cross-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:struct_destructuring_cross_crate.rs + + +extern crate struct_destructuring_cross_crate; + +pub fn main() { + let x = struct_destructuring_cross_crate::S { x: 1, y: 2 }; + let struct_destructuring_cross_crate::S { x: a, y: b } = x; + assert_eq!(a, 1); + assert_eq!(b, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-field-shorthand.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-field-shorthand.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-field-shorthand.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-field-shorthand.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct Foo { + x: i32, + y: bool, + z: i32 +} + +struct Bar { + x: i32 +} + +pub fn main() { + let (x, y, z) = (1, true, 2); + let a = Foo { x, y: y, z }; + assert_eq!(a.x, x); + assert_eq!(a.y, y); + assert_eq!(a.z, z); + + let b = Bar { x, }; + assert_eq!(b.x, x); + + let c = Foo { z, y, x }; + assert_eq!(c.x, x); + assert_eq!(c.y, y); + assert_eq!(c.z, z); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-like-variant-construct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-like-variant-construct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-like-variant-construct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-like-variant-construct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +enum Foo { + Bar { + a: isize, + b: isize + }, + Baz { + c: f64, + d: f64 + } +} + +pub fn main() { + let _x = Foo::Bar { a: 2, b: 3 }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-like-variant-match.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-like-variant-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-like-variant-match.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-like-variant-match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_shorthand_field_patterns)] + +enum Foo { + Bar { + x: isize, + y: isize + }, + Baz { + x: f64, + y: f64 + } +} + +fn f(x: &Foo) { + match *x { + Foo::Baz { x: x, y: y } => { + assert_eq!(x, 1.0); + assert_eq!(y, 2.0); + } + Foo::Bar { y: y, x: x } => { + assert_eq!(x, 1); + assert_eq!(y, 2); + } + } +} + +pub fn main() { + let x = Foo::Bar { x: 1, y: 2 }; + f(&x); + let y = Foo::Baz { x: 1.0, y: 2.0 }; + f(&y); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-literal-dtor.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-literal-dtor.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-literal-dtor.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-literal-dtor.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +struct foo { + x: String, +} + +impl Drop for foo { + fn drop(&mut self) { + println!("{}", self.x); + } +} + +pub fn main() { + let _z = foo { + x: "Hello".to_string() + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-lit-functional-no-fields.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-lit-functional-no-fields.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-lit-functional-no-fields.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-lit-functional-no-fields.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(Debug,PartialEq,Clone)] +struct Foo { + bar: T, + baz: T +} + +pub fn main() { + let foo = Foo { + bar: 0, + baz: 1 + }; + + let foo_ = foo.clone(); + let foo = Foo { ..foo }; + assert_eq!(foo, foo_); + + let foo = Foo { + bar: "one".to_string(), + baz: "two".to_string() + }; + + let foo_ = foo.clone(); + let foo = Foo { ..foo }; + assert_eq!(foo, foo_); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-new-as-field-name.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-new-as-field-name.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-new-as-field-name.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-new-as-field-name.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +struct Foo { + new: isize, +} + +pub fn main() { + let foo = Foo{ new: 3 }; + assert_eq!(foo.new, 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-order-of-eval-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-order-of-eval-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-order-of-eval-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-order-of-eval-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +struct S { f0: String, f1: isize } + +pub fn main() { + let s = "Hello, world!".to_string(); + let s = S { + f0: s.to_string(), + ..S { + f0: s, + f1: 23 + } + }; + assert_eq!(s.f0, "Hello, world!"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-order-of-eval-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-order-of-eval-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-order-of-eval-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-order-of-eval-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +struct S { + f0: String, + f1: String, +} + +pub fn main() { + let s = "Hello, world!".to_string(); + let s = S { + f1: s.to_string(), + f0: s + }; + assert_eq!(s.f0, "Hello, world!"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-order-of-eval-3.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-order-of-eval-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-order-of-eval-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-order-of-eval-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Checks that functional-record-update order-of-eval is as expected +// even when no Drop-implementations are involved. + +use std::sync::atomic::{Ordering, AtomicUsize}; + +struct W { wrapped: u32 } +struct S { f0: W, _f1: i32 } + +pub fn main() { + const VAL: u32 = 0x89AB_CDEF; + let w = W { wrapped: VAL }; + let s = S { + f0: { event(0x01); W { wrapped: w.wrapped + 1 } }, + ..S { + f0: { event(0x02); w}, + _f1: 23 + } + }; + assert_eq!(s.f0.wrapped, VAL + 1); + let actual = event_log(); + let expect = 0x01_02; + assert!(expect == actual, + "expect: 0x{:x} actual: 0x{:x}", expect, actual); +} + +static LOG: AtomicUsize = AtomicUsize::new(0); + +fn event_log() -> usize { + LOG.load(Ordering::SeqCst) +} + +fn event(tag: u8) { + let old_log = LOG.load(Ordering::SeqCst); + let new_log = (old_log << 8) + tag as usize; + LOG.store(new_log, Ordering::SeqCst); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-order-of-eval-4.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-order-of-eval-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-order-of-eval-4.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-order-of-eval-4.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Checks that struct-literal expression order-of-eval is as expected +// even when no Drop-implementations are involved. + +use std::sync::atomic::{Ordering, AtomicUsize}; + +struct W { wrapped: u32 } +struct S { f0: W, _f1: i32 } + +pub fn main() { + const VAL: u32 = 0x89AB_CDEF; + let w = W { wrapped: VAL }; + let s = S { + _f1: { event(0x01); 23 }, + f0: { event(0x02); w }, + }; + assert_eq!(s.f0.wrapped, VAL); + let actual = event_log(); + let expect = 0x01_02; + assert!(expect == actual, + "expect: 0x{:x} actual: 0x{:x}", expect, actual); +} + +static LOG: AtomicUsize = AtomicUsize::new(0); + +fn event_log() -> usize { + LOG.load(Ordering::SeqCst) +} + +fn event(tag: u8) { + let old_log = LOG.load(Ordering::SeqCst); + let new_log = (old_log << 8) + tag as usize; + LOG.store(new_log, Ordering::SeqCst); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-partial-move-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-partial-move-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-partial-move-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-partial-move-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(PartialEq, Debug)] +pub struct Partial { x: T, y: T } + +#[derive(PartialEq, Debug)] +struct S { val: isize } +impl S { fn new(v: isize) -> S { S { val: v } } } +impl Drop for S { fn drop(&mut self) { } } + +pub fn f((b1, b2): (T, T), mut f: F) -> Partial where F: FnMut(T) -> T { + let p = Partial { x: b1, y: b2 }; + + // Move of `p` is legal even though we are also moving `p.y`; the + // `..p` moves all fields *except* `p.y` in this context. + Partial { y: f(p.y), ..p } +} + +pub fn main() { + let p = f((S::new(3), S::new(4)), |S { val: z }| S::new(z+1)); + assert_eq!(p, Partial { x: S::new(3), y: S::new(5) }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-partial-move-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-partial-move-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-partial-move-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-partial-move-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(PartialEq, Debug)] +pub struct Partial { x: T, y: T } + +#[derive(PartialEq, Debug)] +struct S { val: isize } +impl S { fn new(v: isize) -> S { S { val: v } } } +impl Drop for S { fn drop(&mut self) { } } + +pub type Two = (Partial, Partial); + +pub fn f((b1, b2): (T, T), (b3, b4): (T, T), mut f: F) -> Two where F: FnMut(T) -> T { + let p = Partial { x: b1, y: b2 }; + let q = Partial { x: b3, y: b4 }; + + // Move of `q` is legal even though we have already moved `q.y`; + // the `..q` moves all fields *except* `q.y` in this context. + // Likewise, the move of `p.x` is legal for similar reasons. + (Partial { x: f(q.y), ..p }, Partial { y: f(p.x), ..q }) +} + +pub fn main() { + let two = f((S::new(1), S::new(3)), + (S::new(5), S::new(7)), + |S { val: z }| S::new(z+1)); + assert_eq!(two, (Partial { x: S::new(8), y: S::new(3) }, + Partial { x: S::new(5), y: S::new(2) })); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-path-associated-type.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-path-associated-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-path-associated-type.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-path-associated-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +struct S { + a: T, + b: U, +} + +trait Tr { + type A; +} +impl Tr for u8 { + type A = S; +} + +fn f>>() { + let s = T::A { a: 0, b: 1 }; + match s { + T::A { a, b } => { + assert_eq!(a, 0); + assert_eq!(b, 1); + } + } +} + +fn main() { + f::(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-path-self.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-path-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-path-self.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-path-self.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,55 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::ops::Add; + +struct S { + a: T, + b: U, +} + +trait Tr { + fn f(&self) -> Self; +} + +impl, U: Default> Tr for S { + fn f(&self) -> Self { + let s = Self { a: Default::default(), b: Default::default() }; + match s { + Self { a, b } => Self { a: a + 1, b: b } + } + } +} + +impl> S { + fn g(&self) -> Self { + let s = Self { a: Default::default(), b: Default::default() }; + match s { + Self { a, b } => Self { a: a, b: b + 1 } + } + } +} + +impl S { + fn new() -> Self { + Self { a: 0, b: 1 } + } +} + +fn main() { + let s0 = S::new(); + let s1 = s0.f(); + assert_eq!(s1.a, 1); + assert_eq!(s1.b, 0); + let s2 = s0.g(); + assert_eq!(s2.a, 0); + assert_eq!(s2.b, 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-pattern-matching.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-pattern-matching.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-pattern-matching.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-pattern-matching.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_shorthand_field_patterns)] + +struct Foo { + x: isize, + y: isize, +} + +pub fn main() { + let a = Foo { x: 1, y: 2 }; + match a { + Foo { x: x, y: y } => println!("yes, {}, {}", x, y) + } + + match a { + Foo { .. } => () + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-return.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-return.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-return.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-return.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,74 @@ +// Copyright 2012-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// ignore-wasm32-bare no libc to test ffi with + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct Quad { a: u64, b: u64, c: u64, d: u64 } + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct Floats { a: f64, b: u8, c: f64 } + +mod rustrt { + use super::{Floats, Quad}; + + #[link(name = "rust_test_helpers", kind = "static")] + extern { + pub fn rust_dbg_abi_1(q: Quad) -> Quad; + pub fn rust_dbg_abi_2(f: Floats) -> Floats; + } +} + +fn test1() { + unsafe { + let q = Quad { a: 0xaaaa_aaaa_aaaa_aaaa, + b: 0xbbbb_bbbb_bbbb_bbbb, + c: 0xcccc_cccc_cccc_cccc, + d: 0xdddd_dddd_dddd_dddd }; + let qq = rustrt::rust_dbg_abi_1(q); + println!("a: {:x}", qq.a as usize); + println!("b: {:x}", qq.b as usize); + println!("c: {:x}", qq.c as usize); + println!("d: {:x}", qq.d as usize); + assert_eq!(qq.a, q.c + 1); + assert_eq!(qq.b, q.d - 1); + assert_eq!(qq.c, q.a + 1); + assert_eq!(qq.d, q.b - 1); + } +} + +#[cfg(target_pointer_width = "64")] +fn test2() { + unsafe { + let f = Floats { a: 1.234567890e-15_f64, + b: 0b_1010_1010, + c: 1.0987654321e-15_f64 }; + let ff = rustrt::rust_dbg_abi_2(f); + println!("a: {}", ff.a as f64); + println!("b: {}", ff.b as usize); + println!("c: {}", ff.c as f64); + assert_eq!(ff.a, f.c + 1.0f64); + assert_eq!(ff.b, 0xff); + assert_eq!(ff.c, f.a - 1.0f64); + } +} + +#[cfg(target_pointer_width = "32")] +fn test2() { +} + +pub fn main() { + test1(); + test2(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-variant-field-visibility.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-variant-field-visibility.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-variant-field-visibility.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct-variant-field-visibility.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +mod foo { + pub enum Foo { + Bar { a: isize } + } +} + +fn f(f: foo::Foo) { + match f { + foo::Foo::Bar { a: _a } => {} + } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct_variant_xc_match.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct_variant_xc_match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct_variant_xc_match.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct_variant_xc_match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:struct_variant_xc_aux.rs + +extern crate struct_variant_xc_aux; + +use struct_variant_xc_aux::Enum::{StructVariant, Variant}; + +pub fn main() { + let arg = match (StructVariant { arg: 42 }) { + Variant(_) => unreachable!(), + StructVariant { arg } => arg + }; + assert_eq!(arg, 42); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct_variant_xc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct_variant_xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct_variant_xc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/struct_variant_xc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:struct_variant_xc_aux.rs +// pretty-expanded FIXME #23616 + +extern crate struct_variant_xc_aux; + +use struct_variant_xc_aux::Enum::StructVariant; + +pub fn main() { + let _ = StructVariant { arg: 1 }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-align-dyn-u64.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-align-dyn-u64.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-align-dyn-u64.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-align-dyn-u64.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(deprecated)] + +use std::mem; + +enum Tag { + Tag2(A) +} + +struct Rec { + c8: u8, + t: Tag +} + +fn mk_rec() -> Rec { + return Rec { c8:0, t:Tag::Tag2(0) }; +} + +fn is_u64_aligned(u: &Tag) -> bool { + let p: usize = unsafe { mem::transmute(u) }; + let u64_align = std::mem::min_align_of::(); + return (p & (u64_align - 1)) == 0; +} + +pub fn main() { + let x = mk_rec(); + assert!(is_u64_aligned(&x.t)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-align-dyn-variants.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-align-dyn-variants.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-align-dyn-variants.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-align-dyn-variants.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,77 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(deprecated)] +#![allow(non_snake_case)] + +use std::mem; + +enum Tag { + VarA(A), + VarB(B), +} + +struct Rec { + chA: u8, + tA: Tag, + chB: u8, + tB: Tag, +} + +fn mk_rec(a: A, b: B) -> Rec { + Rec { chA:0, tA:Tag::VarA(a), chB:1, tB:Tag::VarB(b) } +} + +fn is_aligned(amnt: usize, u: &A) -> bool { + let p: usize = unsafe { mem::transmute(u) }; + return (p & (amnt-1)) == 0; +} + +fn variant_data_is_aligned(amnt: usize, u: &Tag) -> bool { + match u { + &Tag::VarA(ref a) => is_aligned(amnt, a), + &Tag::VarB(ref b) => is_aligned(amnt, b) + } +} + +pub fn main() { + let u64_align = std::mem::min_align_of::(); + let x = mk_rec(22u64, 23u64); + assert!(is_aligned(u64_align, &x.tA)); + assert!(variant_data_is_aligned(u64_align, &x.tA)); + assert!(is_aligned(u64_align, &x.tB)); + assert!(variant_data_is_aligned(u64_align, &x.tB)); + + let x = mk_rec(22u64, 23u32); + assert!(is_aligned(u64_align, &x.tA)); + assert!(variant_data_is_aligned(u64_align, &x.tA)); + assert!(is_aligned(u64_align, &x.tB)); + assert!(variant_data_is_aligned(4, &x.tB)); + + let x = mk_rec(22u32, 23u64); + assert!(is_aligned(u64_align, &x.tA)); + assert!(variant_data_is_aligned(4, &x.tA)); + assert!(is_aligned(u64_align, &x.tB)); + assert!(variant_data_is_aligned(u64_align, &x.tB)); + + let x = mk_rec(22u32, 23u32); + assert!(is_aligned(4, &x.tA)); + assert!(variant_data_is_aligned(4, &x.tA)); + assert!(is_aligned(4, &x.tB)); + assert!(variant_data_is_aligned(4, &x.tB)); + + let x = mk_rec(22f64, 23f64); + assert!(is_aligned(u64_align, &x.tA)); + assert!(variant_data_is_aligned(u64_align, &x.tA)); + assert!(is_aligned(u64_align, &x.tB)); + assert!(variant_data_is_aligned(u64_align, &x.tB)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-align-shape.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-align-shape.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-align-shape.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-align-shape.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +#[derive(Debug)] +enum a_tag { + a_tag_var(u64) +} + +#[derive(Debug)] +struct t_rec { + c8: u8, + t: a_tag +} + +pub fn main() { + let x = t_rec {c8: 22, t: a_tag::a_tag_var(44)}; + let y = format!("{:?}", x); + println!("y = {:?}", y); + assert_eq!(y, "t_rec { c8: 22, t: a_tag_var(44) }".to_string()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-align-u64.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-align-u64.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-align-u64.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-align-u64.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(deprecated)] + +use std::mem; + +enum Tag { + TagInner(u64) +} + +struct Rec { + c8: u8, + t: Tag +} + +fn mk_rec() -> Rec { + return Rec { c8:0, t:Tag::TagInner(0) }; +} + +fn is_u64_aligned(u: &Tag) -> bool { + let p: usize = unsafe { mem::transmute(u) }; + let u64_align = std::mem::min_align_of::(); + return (p & (u64_align - 1)) == 0; +} + +pub fn main() { + let x = mk_rec(); + assert!(is_u64_aligned(&x.t)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-disr-val-shape.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-disr-val-shape.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-disr-val-shape.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-disr-val-shape.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +#[derive(Debug)] +enum color { + red = 0xff0000, + green = 0x00ff00, + blue = 0x0000ff, + black = 0x000000, + white = 0xFFFFFF, +} + +pub fn main() { + let act = format!("{:?}", color::red); + println!("{}", act); + assert_eq!("red".to_string(), act); + assert_eq!("green".to_string(), format!("{:?}", color::green)); + assert_eq!("white".to_string(), format!("{:?}", color::white)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-exports.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-exports.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-exports.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-exports.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +use alder::*; + +mod alder { + pub enum burnside { couch, davis } + pub enum everett { flanders, glisan, hoyt } + pub enum irving { johnson, kearney, lovejoy } + pub enum marshall { northrup, overton } +} + +pub fn main() { + let _pettygrove: burnside = burnside::couch; + let _quimby: everett = everett::flanders; + let _raleigh: irving = irving::johnson; + let _savier: marshall; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-in-block.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-in-block.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-in-block.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-in-block.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + + + +// pretty-expanded FIXME #23616 + +fn foo() { + fn zed(_z: bar) { } + enum bar { nil, } + fn baz() { zed(bar::nil); } +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_parens)] +#![allow(non_camel_case_types)] + + +enum colour { red(isize, isize), green, } + +impl PartialEq for colour { + fn eq(&self, other: &colour) -> bool { + match *self { + colour::red(a0, b0) => { + match (*other) { + colour::red(a1, b1) => a0 == a1 && b0 == b1, + colour::green => false, + } + } + colour::green => { + match (*other) { + colour::red(..) => false, + colour::green => true + } + } + } + } + fn ne(&self, other: &colour) -> bool { !(*self).eq(other) } +} + +fn f() { let x = colour::red(1, 2); let y = colour::green; assert!((x != y)); } + +pub fn main() { f(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-variant-disr-type-mismatch.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-variant-disr-type-mismatch.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-variant-disr-type-mismatch.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-variant-disr-type-mismatch.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +enum color { + red = 1, + blue = 2, +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-variant-disr-val.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-variant-disr-val.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-variant-disr-val.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tag-variant-disr-val.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,76 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +use color::{red, green, blue, black, white, imaginary, purple, orange}; + +#[derive(Copy, Clone)] +enum color { + red = 0xff0000, + green = 0x00ff00, + blue = 0x0000ff, + black = 0x000000, + white = 0xFFFFFF, + imaginary = -1, + purple = 1 << 1, + orange = 8 >> 1 +} + +impl PartialEq for color { + fn eq(&self, other: &color) -> bool { + ((*self) as usize) == ((*other) as usize) + } + fn ne(&self, other: &color) -> bool { !(*self).eq(other) } +} + +pub fn main() { + test_color(red, 0xff0000, "red".to_string()); + test_color(green, 0x00ff00, "green".to_string()); + test_color(blue, 0x0000ff, "blue".to_string()); + test_color(black, 0x000000, "black".to_string()); + test_color(white, 0xFFFFFF, "white".to_string()); + test_color(imaginary, -1, "imaginary".to_string()); + test_color(purple, 2, "purple".to_string()); + test_color(orange, 4, "orange".to_string()); +} + +fn test_color(color: color, val: isize, name: String) { + //assert_eq!(unsafe::transmute(color), val); + assert_eq!(color as isize, val); + assert_eq!(get_color_alt(color), name); + assert_eq!(get_color_if(color), name); +} + +fn get_color_alt(color: color) -> String { + match color { + red => {"red".to_string()} + green => {"green".to_string()} + blue => {"blue".to_string()} + black => {"black".to_string()} + white => {"white".to_string()} + imaginary => {"imaginary".to_string()} + purple => {"purple".to_string()} + orange => {"orange".to_string()} + } +} + +fn get_color_if(color: color) -> String { + if color == red {"red".to_string()} + else if color == green {"green".to_string()} + else if color == blue {"blue".to_string()} + else if color == black {"black".to_string()} + else if color == white {"white".to_string()} + else if color == imaginary {"imaginary".to_string()} + else if color == purple {"purple".to_string()} + else if color == orange {"orange".to_string()} + else {"unknown".to_string()} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tuple-struct-constructor-pointer.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tuple-struct-constructor-pointer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tuple-struct-constructor-pointer.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tuple-struct-constructor-pointer.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(PartialEq, Debug)] +struct Foo(isize); +#[derive(PartialEq, Debug)] +struct Bar(isize, isize); + +pub fn main() { + let f: fn(isize) -> Foo = Foo; + let g: fn(isize, isize) -> Bar = Bar; + assert_eq!(f(42), Foo(42)); + assert_eq!(g(4, 7), Bar(4, 7)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tuple-struct-construct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tuple-struct-construct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tuple-struct-construct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tuple-struct-construct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#[derive(Debug)] +struct Foo(isize, isize); + +pub fn main() { + let x = Foo(1, 2); + println!("{:?}", x); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tuple-struct-destructuring.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tuple-struct-destructuring.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tuple-struct-destructuring.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tuple-struct-destructuring.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct Foo(isize, isize); + +pub fn main() { + let x = Foo(1, 2); + let Foo(y, z) = x; + println!("{} {}", y, z); + assert_eq!(y, 1); + assert_eq!(z, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tuple-struct-matching.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tuple-struct-matching.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tuple-struct-matching.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tuple-struct-matching.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct Foo(isize, isize); + +pub fn main() { + let x = Foo(1, 2); + match x { + Foo(a, b) => { + assert_eq!(a, 1); + assert_eq!(b, 2); + println!("{} {}", a, b); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tuple-struct-trivial.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tuple-struct-trivial.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/tuple-struct-trivial.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/tuple-struct-trivial.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +struct Foo(isize, isize, isize); + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/uninstantiable-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/uninstantiable-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/uninstantiable-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/uninstantiable-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub struct Z(&'static Z); + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/unit-like-struct-drop-run.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/unit-like-struct-drop-run.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/unit-like-struct-drop-run.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/unit-like-struct-drop-run.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten no threads support + +// Make sure the destructor is run for unit-like structs. + + +#![feature(alloc)] + +use std::thread; + +struct Foo; + +impl Drop for Foo { + fn drop(&mut self) { + panic!("This panic should happen."); + } +} + +pub fn main() { + let x = thread::spawn(move|| { + let _b = Foo; + }).join(); + + let s = x.unwrap_err().downcast::<&'static str>().unwrap(); + assert_eq!(&**s, "This panic should happen."); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/unit-like-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/unit-like-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/unit-like-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/unit-like-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct Foo; + +pub fn main() { + let x: Foo = Foo; + match x { + Foo => { println!("hi"); } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/variant-structs-trivial.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/variant-structs-trivial.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structs-enums/variant-structs-trivial.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structs-enums/variant-structs-trivial.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +enum Foo { + Bar { x: isize }, + Baz { y: isize } +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structured-compare.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structured-compare.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/structured-compare.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/structured-compare.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] #[derive(Copy, Clone, Debug)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/super-fast-paren-parsing.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/super-fast-paren-parsing.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/super-fast-paren-parsing.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/super-fast-paren-parsing.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_upper_case_globals)] +#![allow(dead_code)] // exec-env:RUST_MIN_STACK=16000000 // rustc-env:RUST_MIN_STACK=16000000 // diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/super.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/super.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/super.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/super.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // pretty-expanded FIXME #23616 pub mod a { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/swap-overlapping.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/swap-overlapping.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/swap-overlapping.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/swap-overlapping.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // Issue #5041 - avoid overlapping memcpy when src and dest of a swap are the same // pretty-expanded FIXME #23616 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/thinlto/all-crates.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/thinlto/all-crates.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/thinlto/all-crates.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/thinlto/all-crates.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// compile-flags: -Clto=thin +// no-prefer-dynamic + +fn main() { + println!("hello!"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/thinlto/auxiliary/dylib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/thinlto/auxiliary/dylib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/thinlto/auxiliary/dylib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/thinlto/auxiliary/dylib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z thinlto -C codegen-units=8 + +#[inline] +pub fn foo(b: u8) { + b.to_string(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/thinlto/auxiliary/msvc-imp-present.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/thinlto/auxiliary/msvc-imp-present.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/thinlto/auxiliary/msvc-imp-present.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/thinlto/auxiliary/msvc-imp-present.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic +// compile-flags: -Z thinlto -C codegen-units=8 -C prefer-dynamic + +#![crate_type = "rlib"] +#![crate_type = "dylib"] + +pub static A: u32 = 43; + +pub mod a { + pub static A: u32 = 43; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/thinlto/auxiliary/thin-lto-inlines-aux.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/thinlto/auxiliary/thin-lto-inlines-aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/thinlto/auxiliary/thin-lto-inlines-aux.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/thinlto/auxiliary/thin-lto-inlines-aux.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "rlib"] + +pub fn bar() -> u32 { + 3 +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/thinlto/dylib-works.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/thinlto/dylib-works.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/thinlto/dylib-works.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/thinlto/dylib-works.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// aux-build:dylib.rs + +extern crate dylib; + +fn main() { + dylib::foo(1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/thinlto/msvc-imp-present.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/thinlto/msvc-imp-present.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/thinlto/msvc-imp-present.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/thinlto/msvc-imp-present.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// aux-build:msvc-imp-present.rs +// compile-flags: -Z thinlto -C codegen-units=8 +// no-prefer-dynamic + +// On MSVC we have a "hack" where we emit symbols that look like `_imp_$name` +// for all exported statics. This is done because we apply `dllimport` to all +// imported constants and this allows everything to actually link correctly. +// +// The ThinLTO passes aggressively remove symbols if they can, and this test +// asserts that the ThinLTO passes don't remove these compiler-generated +// `_imp_*` symbols. The external library that we link in here is compiled with +// ThinLTO and multiple codegen units and has a few exported constants. Note +// that we also namely compile the library as both a dylib and an rlib, but we +// link the rlib to ensure that we assert those generated symbols exist. + +extern crate msvc_imp_present as bar; + +fn main() { + println!("{}", bar::A); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/thinlto/thin-lto-inlines2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/thinlto/thin-lto-inlines2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/thinlto/thin-lto-inlines2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/thinlto/thin-lto-inlines2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// compile-flags: -C codegen-units=8 -O -C lto=thin +// aux-build:thin-lto-inlines-aux.rs +// no-prefer-dynamic +// ignore-emscripten can't inspect instructions on emscripten + +// We want to assert here that ThinLTO will inline across codegen units. There's +// not really a great way to do that in general so we sort of hack around it by +// praying two functions go into separate codegen units and then assuming that +// if inlining *doesn't* happen the first byte of the functions will differ. + +extern crate thin_lto_inlines_aux as bar; + +pub fn foo() -> u32 { + bar::bar() +} + +fn main() { + println!("{} {}", foo(), bar::bar()); + + unsafe { + let foo = foo as usize as *const u8; + let bar = bar::bar as usize as *const u8; + + assert_eq!(*foo, *bar); + } +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/thinlto/thin-lto-inlines.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/thinlto/thin-lto-inlines.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/thinlto/thin-lto-inlines.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/thinlto/thin-lto-inlines.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// compile-flags: -Z thinlto -C codegen-units=8 -O +// ignore-emscripten can't inspect instructions on emscripten + +// We want to assert here that ThinLTO will inline across codegen units. There's +// not really a great way to do that in general so we sort of hack around it by +// praying two functions go into separate codegen units and then assuming that +// if inlining *doesn't* happen the first byte of the functions will differ. + +pub fn foo() -> u32 { + bar::bar() +} + +mod bar { + pub fn bar() -> u32 { + 3 + } +} + +fn main() { + println!("{} {}", foo(), bar::bar()); + + unsafe { + let foo = foo as usize as *const u8; + let bar = bar::bar as usize as *const u8; + + assert_eq!(*foo, *bar); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/thinlto/weak-works.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/thinlto/weak-works.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/thinlto/weak-works.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/thinlto/weak-works.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// compile-flags: -C codegen-units=8 -Z thinlto +// ignore-windows + +#![feature(linkage)] + +pub mod foo { + #[linkage = "weak"] + #[no_mangle] + pub extern "C" fn FOO() -> i32 { + 0 + } +} + +mod bar { + extern "C" { + fn FOO() -> i32; + } + + pub fn bar() -> i32 { + unsafe { FOO() } + } +} + +fn main() { + bar::bar(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/auxiliary/thread-local-extern-static.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/auxiliary/thread-local-extern-static.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/auxiliary/thread-local-extern-static.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/auxiliary/thread-local-extern-static.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(cfg_target_thread_local, const_fn, thread_local)] +#![crate_type = "lib"] + +#[cfg(target_thread_local)] +use std::cell::Cell; + +#[no_mangle] +#[cfg(target_thread_local)] +#[thread_local] +pub static FOO: Cell = Cell::new(3); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/comm.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/comm.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/comm.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/comm.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// ignore-emscripten no threads support + +use std::thread; +use std::sync::mpsc::{channel, Sender}; + +pub fn main() { + let (tx, rx) = channel(); + let t = thread::spawn(move|| { child(&tx) }); + let y = rx.recv().unwrap(); + println!("received"); + println!("{}", y); + assert_eq!(y, 10); + t.join(); +} + +fn child(c: &Sender) { + println!("sending"); + c.send(10).unwrap(); + println!("value sent"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sendable-class.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sendable-class.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sendable-class.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sendable-class.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(non_camel_case_types)] + +// Test that a class with only sendable fields can be sent + +// pretty-expanded FIXME #23616 + +use std::sync::mpsc::channel; + +struct foo { + i: isize, + j: char, +} + +fn foo(i:isize, j: char) -> foo { + foo { + i: i, + j: j + } +} + +pub fn main() { + let (tx, rx) = channel(); + tx.send(foo(42, 'c')); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sendfn-is-a-block.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sendfn-is-a-block.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sendfn-is-a-block.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sendfn-is-a-block.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +fn test(f: F) -> usize where F: FnOnce(usize) -> usize { + return f(22); +} + +pub fn main() { + let y = test(|x| 4 * x); + assert_eq!(y, 88); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sendfn-spawn-with-fn-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sendfn-spawn-with-fn-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sendfn-spawn-with-fn-arg.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sendfn-spawn-with-fn-arg.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten no threads support + +#![feature(box_syntax)] + +use std::thread; + +pub fn main() { test05(); } + +fn test05_start(f: F) { + f(22); +} + +fn test05() { + let three: Box<_> = box 3; + let fn_to_send = move|n:isize| { + println!("{}", *three + n); // will copy x into the closure + assert_eq!(*three, 3); + }; + thread::spawn(move|| { + test05_start(fn_to_send); + }).join().ok().unwrap(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/send-is-not-static-par-for.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/send-is-not-static-par-for.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/send-is-not-static-par-for.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/send-is-not-static-par-for.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +use std::thread; +use std::sync::Mutex; + +fn par_for(iter: I, f: F) + where I: Iterator, + I::Item: Send, + F: Fn(I::Item) + Sync +{ + for item in iter { + f(item) + } +} + +fn sum(x: &[i32]) { + let sum_lengths = Mutex::new(0); + par_for(x.windows(4), |x| { + *sum_lengths.lock().unwrap() += x.len() + }); + + assert_eq!(*sum_lengths.lock().unwrap(), (x.len() - 3) * 4); +} + +fn main() { + let mut elements = [0; 20]; + + // iterators over references into this stack frame + par_for(elements.iter_mut().enumerate(), |(i, x)| { + *x = i as i32 + }); + + sum(&elements) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/send-resource.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/send-resource.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/send-resource.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/send-resource.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,49 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 +// ignore-emscripten no threads support + +use std::thread; +use std::sync::mpsc::channel; + +struct test { + f: isize, +} + +impl Drop for test { + fn drop(&mut self) {} +} + +fn test(f: isize) -> test { + test { + f: f + } +} + +pub fn main() { + let (tx, rx) = channel(); + + let t = thread::spawn(move|| { + let (tx2, rx2) = channel(); + tx.send(tx2).unwrap(); + + let _r = rx2.recv().unwrap(); + }); + + rx.recv().unwrap().send(test(42)).unwrap(); + + t.join(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/send_str_hashmap.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/send_str_hashmap.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/send_str_hashmap.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/send_str_hashmap.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,63 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::collections::HashMap; +use std::borrow::Cow; + +use std::borrow::Cow::Borrowed as B; +use std::borrow::Cow::Owned as O; + +type SendStr = Cow<'static, str>; + +fn main() { + let mut map: HashMap = HashMap::new(); + assert!(map.insert(B("foo"), 42).is_none()); + assert!(map.insert(O("foo".to_string()), 42).is_some()); + assert!(map.insert(B("foo"), 42).is_some()); + assert!(map.insert(O("foo".to_string()), 42).is_some()); + + assert!(map.insert(B("foo"), 43).is_some()); + assert!(map.insert(O("foo".to_string()), 44).is_some()); + assert!(map.insert(B("foo"), 45).is_some()); + assert!(map.insert(O("foo".to_string()), 46).is_some()); + + let v = 46; + + assert_eq!(map.get(&O("foo".to_string())), Some(&v)); + assert_eq!(map.get(&B("foo")), Some(&v)); + + let (a, b, c, d) = (50, 51, 52, 53); + + assert!(map.insert(B("abc"), a).is_none()); + assert!(map.insert(O("bcd".to_string()), b).is_none()); + assert!(map.insert(B("cde"), c).is_none()); + assert!(map.insert(O("def".to_string()), d).is_none()); + + assert!(map.insert(B("abc"), a).is_some()); + assert!(map.insert(O("bcd".to_string()), b).is_some()); + assert!(map.insert(B("cde"), c).is_some()); + assert!(map.insert(O("def".to_string()), d).is_some()); + + assert!(map.insert(O("abc".to_string()), a).is_some()); + assert!(map.insert(B("bcd"), b).is_some()); + assert!(map.insert(O("cde".to_string()), c).is_some()); + assert!(map.insert(B("def"), d).is_some()); + + assert_eq!(map.get("abc"), Some(&a)); + assert_eq!(map.get("bcd"), Some(&b)); + assert_eq!(map.get("cde"), Some(&c)); + assert_eq!(map.get("def"), Some(&d)); + + assert_eq!(map.get(&B("abc")), Some(&a)); + assert_eq!(map.get(&B("bcd")), Some(&b)); + assert_eq!(map.get(&B("cde")), Some(&c)); + assert_eq!(map.get(&B("def")), Some(&d)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/send_str_treemap.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/send_str_treemap.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/send_str_treemap.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/send_str_treemap.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,68 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::collections::BTreeMap; +use std::borrow::Cow; + +use std::borrow::Cow::{Owned as O, Borrowed as B}; + +type SendStr = Cow<'static, str>; + +fn main() { + let mut map: BTreeMap = BTreeMap::new(); + assert!(map.insert(B("foo"), 42).is_none()); + assert!(map.insert(O("foo".to_string()), 42).is_some()); + assert!(map.insert(B("foo"), 42).is_some()); + assert!(map.insert(O("foo".to_string()), 42).is_some()); + + assert!(map.insert(B("foo"), 43).is_some()); + assert!(map.insert(O("foo".to_string()), 44).is_some()); + assert!(map.insert(B("foo"), 45).is_some()); + assert!(map.insert(O("foo".to_string()), 46).is_some()); + + let v = 46; + + assert_eq!(map.get(&O("foo".to_string())), Some(&v)); + assert_eq!(map.get(&B("foo")), Some(&v)); + + let (a, b, c, d) = (50, 51, 52, 53); + + assert!(map.insert(B("abc"), a).is_none()); + assert!(map.insert(O("bcd".to_string()), b).is_none()); + assert!(map.insert(B("cde"), c).is_none()); + assert!(map.insert(O("def".to_string()), d).is_none()); + + assert!(map.insert(B("abc"), a).is_some()); + assert!(map.insert(O("bcd".to_string()), b).is_some()); + assert!(map.insert(B("cde"), c).is_some()); + assert!(map.insert(O("def".to_string()), d).is_some()); + + assert!(map.insert(O("abc".to_string()), a).is_some()); + assert!(map.insert(B("bcd"), b).is_some()); + assert!(map.insert(O("cde".to_string()), c).is_some()); + assert!(map.insert(B("def"), d).is_some()); + + assert_eq!(map.get(&B("abc")), Some(&a)); + assert_eq!(map.get(&B("bcd")), Some(&b)); + assert_eq!(map.get(&B("cde")), Some(&c)); + assert_eq!(map.get(&B("def")), Some(&d)); + + assert_eq!(map.get(&O("abc".to_string())), Some(&a)); + assert_eq!(map.get(&O("bcd".to_string())), Some(&b)); + assert_eq!(map.get(&O("cde".to_string())), Some(&c)); + assert_eq!(map.get(&O("def".to_string())), Some(&d)); + + assert!(map.remove(&B("foo")).is_some()); + assert_eq!(map.into_iter().map(|(k, v)| format!("{}{}", k, v)) + .collect::>() + .concat(), + "abc50bcd51cde52def53".to_string()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/send-type-inference.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/send-type-inference.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/send-type-inference.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/send-type-inference.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +#![allow(dead_code)] +#![allow(unused_mut)] +// pretty-expanded FIXME #23616 + +use std::sync::mpsc::{channel, Sender}; + +// tests that ctrl's type gets inferred properly +struct Command { + key: K, + val: V +} + +fn cache_server(mut tx: Sender>>) { + let (tx1, _rx) = channel(); + tx.send(tx1); +} +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/spawn2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/spawn2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/spawn2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/spawn2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten no threads support + +use std::thread; + +pub fn main() { + let t = thread::spawn(move|| child((10, 20, 30, 40, 50, 60, 70, 80, 90)) ); + t.join().ok().unwrap(); // forget Err value, since it doesn't implement Debug +} + +fn child(args: (isize, isize, isize, isize, isize, isize, isize, isize, isize)) { + let (i1, i2, i3, i4, i5, i6, i7, i8, i9) = args; + println!("{}", i1); + println!("{}", i2); + println!("{}", i3); + println!("{}", i4); + println!("{}", i5); + println!("{}", i6); + println!("{}", i7); + println!("{}", i8); + println!("{}", i9); + assert_eq!(i1, 10); + assert_eq!(i2, 20); + assert_eq!(i3, 30); + assert_eq!(i4, 40); + assert_eq!(i5, 50); + assert_eq!(i6, 60); + assert_eq!(i7, 70); + assert_eq!(i8, 80); + assert_eq!(i9, 90); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/spawn-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/spawn-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/spawn-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/spawn-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// ignore-emscripten no threads support + +use std::thread; + +fn x(s: String, n: isize) { + println!("{}", s); + println!("{}", n); +} + +pub fn main() { + let t1 = thread::spawn(|| x("hello from first spawned fn".to_string(), 65) ); + let t2 = thread::spawn(|| x("hello from second spawned fn".to_string(), 66) ); + let t3 = thread::spawn(|| x("hello from third spawned fn".to_string(), 67) ); + let mut i = 30; + while i > 0 { + i = i - 1; + println!("parent sleeping"); + thread::yield_now(); + } + t1.join(); + t2.join(); + t3.join(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/spawning-with-debug.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/spawning-with-debug.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/spawning-with-debug.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/spawning-with-debug.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +#![allow(unused_mut)] +// ignore-windows +// exec-env:RUST_LOG=debug +// ignore-emscripten no threads support + +// regression test for issue #10405, make sure we don't call println! too soon. + +use std::thread::Builder; + +pub fn main() { + let mut t = Builder::new(); + t.spawn(move|| ()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/spawn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/spawn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/spawn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/spawn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten no threads support + +use std::thread; + +pub fn main() { + thread::spawn(move|| child(10)).join().ok().unwrap(); +} + +fn child(i: isize) { println!("{}", i); assert_eq!(i, 10); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/spawn-types.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/spawn-types.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/spawn-types.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/spawn-types.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +// ignore-emscripten no threads support + +/* + Make sure we can spawn tasks that take different types of + parameters. This is based on a test case for #520 provided by Rob + Arnold. + */ + +use std::thread; +use std::sync::mpsc::{channel, Sender}; + +type ctx = Sender; + +fn iotask(_tx: &ctx, ip: String) { + assert_eq!(ip, "localhost".to_string()); +} + +pub fn main() { + let (tx, _rx) = channel::(); + let t = thread::spawn(move|| iotask(&tx, "localhost".to_string()) ); + t.join().ok().unwrap(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/std-sync-right-kind-impls.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/std-sync-right-kind-impls.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/std-sync-right-kind-impls.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/std-sync-right-kind-impls.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +use std::sync; + +fn assert_both() {} + +fn main() { + assert_both::>(); + assert_both::(); + assert_both::>(); + assert_both::(); + assert_both::>(); + assert_both::>(); + assert_both::(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sync-send-atomics.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sync-send-atomics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sync-send-atomics.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sync-send-atomics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// pretty-expanded FIXME #23616 + +use std::sync::atomic::*; + +trait SendSync: Send + Sync {} + +impl SendSync for AtomicBool {} +impl SendSync for AtomicIsize {} +impl SendSync for AtomicUsize {} +impl SendSync for AtomicPtr {} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sync-send-in-std.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sync-send-in-std.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sync-send-in-std.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sync-send-in-std.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// ignore-cloudabi networking not available +// ignore-wasm32-bare networking not available + +use std::net::ToSocketAddrs; + +fn is_sync(_: T) where T: Sync {} +fn is_send(_: T) where T: Send {} + +macro_rules! all_sync_send { + ($ctor:expr, $($iter:ident),+) => ({ + $( + let mut x = $ctor; + is_sync(x.$iter()); + let mut y = $ctor; + is_send(y.$iter()); + )+ + }) +} + +fn main() { + all_sync_send!("localhost:80".to_socket_addrs().unwrap(), next); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sync-send-iterators-in-libcollections.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sync-send-iterators-in-libcollections.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sync-send-iterators-in-libcollections.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sync-send-iterators-in-libcollections.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,80 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![allow(warnings)] +#![feature(drain, collections_bound, btree_range)] + +use std::collections::BinaryHeap; +use std::collections::{BTreeMap, BTreeSet}; +use std::collections::LinkedList; +use std::collections::VecDeque; +use std::collections::HashMap; +use std::collections::HashSet; + +use std::mem; +use std::ops::Bound::Included; + +fn is_sync(_: T) where T: Sync {} +fn is_send(_: T) where T: Send {} + +macro_rules! all_sync_send { + ($ctor:expr, $($iter:ident),+) => ({ + $( + let mut x = $ctor; + is_sync(x.$iter()); + let mut y = $ctor; + is_send(y.$iter()); + )+ + }) +} + +macro_rules! is_sync_send { + ($ctor:expr, $iter:ident($($param:expr),+)) => ({ + let mut x = $ctor; + is_sync(x.$iter($( $param ),+)); + let mut y = $ctor; + is_send(y.$iter($( $param ),+)); + }) +} + +fn main() { + // The iterator "generator" list should exhaust what corresponding + // implementations have where `Sync` and `Send` semantics apply. + all_sync_send!(BinaryHeap::::new(), iter, drain, into_iter); + + all_sync_send!(BTreeMap::::new(), iter, iter_mut, into_iter, keys, values); + is_sync_send!(BTreeMap::::new(), range((Included(&0), Included(&9)))); + is_sync_send!(BTreeMap::::new(), range_mut((Included(&0), Included(&9)))); + + all_sync_send!(BTreeSet::::new(), iter, into_iter); + is_sync_send!(BTreeSet::::new(), range((Included(&0), Included(&9)))); + is_sync_send!(BTreeSet::::new(), difference(&BTreeSet::::new())); + is_sync_send!(BTreeSet::::new(), symmetric_difference(&BTreeSet::::new())); + is_sync_send!(BTreeSet::::new(), intersection(&BTreeSet::::new())); + is_sync_send!(BTreeSet::::new(), union(&BTreeSet::::new())); + + all_sync_send!(HashMap::::new(), iter, iter_mut, drain, into_iter, keys, values); + all_sync_send!(HashSet::::new(), iter, drain, into_iter); + is_sync_send!(HashSet::::new(), difference(&HashSet::::new())); + is_sync_send!(HashSet::::new(), symmetric_difference(&HashSet::::new())); + is_sync_send!(HashSet::::new(), intersection(&HashSet::::new())); + is_sync_send!(HashSet::::new(), union(&HashSet::::new())); + + all_sync_send!(LinkedList::::new(), iter, iter_mut, into_iter); + + all_sync_send!(VecDeque::::new(), iter, iter_mut, into_iter); + is_sync_send!(VecDeque::::new(), drain(..)); + + all_sync_send!(Vec::::new(), into_iter); + is_sync_send!(Vec::::new(), drain(..)); + is_sync_send!(String::new(), drain(..)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sync-send-iterators-in-libcore.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sync-send-iterators-in-libcore.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sync-send-iterators-in-libcore.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/sync-send-iterators-in-libcore.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,117 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#![allow(warnings)] +#![feature(iter_empty)] +#![feature(iter_once)] +#![feature(str_escape)] + +use std::iter::{empty, once, repeat}; + +fn is_sync(_: T) where T: Sync {} +fn is_send(_: T) where T: Send {} + +macro_rules! all_sync_send { + ($ctor:expr, $iter:ident) => ({ + let mut x = $ctor; + is_sync(x.$iter()); + let mut y = $ctor; + is_send(y.$iter()); + }); + ($ctor:expr, $iter:ident($($param:expr),+)) => ({ + let mut x = $ctor; + is_sync(x.$iter($( $param ),+)); + let mut y = $ctor; + is_send(y.$iter($( $param ),+)); + }); + ($ctor:expr, $iter:ident, $($rest:tt)*) => ({ + all_sync_send!($ctor, $iter); + all_sync_send!($ctor, $($rest)*); + }); + ($ctor:expr, $iter:ident($($param:expr),+), $($rest:tt)*) => ({ + all_sync_send!($ctor, $iter($( $param ),+)); + all_sync_send!($ctor, $($rest)*); + }); +} + +macro_rules! all_sync_send_mutable_ref { + ($ctor:expr, $($iter:ident),+) => ({ + $( + let mut x = $ctor; + is_sync((&mut x).$iter()); + let mut y = $ctor; + is_send((&mut y).$iter()); + )+ + }) +} + +macro_rules! is_sync_send { + ($ctor:expr) => ({ + let x = $ctor; + is_sync(x); + let y = $ctor; + is_send(y); + }) +} + +fn main() { + // for char.rs + all_sync_send!("Я", escape_debug, escape_default, escape_unicode); + + // for iter.rs + all_sync_send_mutable_ref!([1], iter); + + // Bytes implements DoubleEndedIterator + all_sync_send!("a".bytes(), rev); + + let a = [1]; + let b = [2]; + all_sync_send!(a.iter(), + cloned, + cycle, + chain([2].iter()), + zip([2].iter()), + map(|_| 1), + filter(|_| true), + filter_map(|_| Some(1)), + enumerate, + peekable, + skip_while(|_| true), + take_while(|_| true), + skip(1), + take(1), + scan(1, |_, _| Some(1)), + flat_map(|_| b.iter()), + fuse, + inspect(|_| ())); + + is_sync_send!((1..).step_by(2)); + is_sync_send!((1..2).step_by(2)); + is_sync_send!((1..2)); + is_sync_send!((1..)); + is_sync_send!(repeat(1)); + is_sync_send!(empty::()); + is_sync_send!(once(1)); + + // for option.rs + // FIXME + + // for result.rs + // FIXME + + // for slice.rs + // FIXME + + // for str/mod.rs + // FIXME +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-0.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-0.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-0.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-0.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// ignore-emscripten no threads support + +use std::thread; +use std::sync::mpsc::{channel, Sender}; + +pub fn main() { test05(); } + +fn test05_start(tx : &Sender) { + tx.send(10).unwrap(); + println!("sent 10"); + tx.send(20).unwrap(); + println!("sent 20"); + tx.send(30).unwrap(); + println!("sent 30"); +} + +fn test05() { + let (tx, rx) = channel(); + let t = thread::spawn(move|| { test05_start(&tx) }); + let mut value: isize = rx.recv().unwrap(); + println!("{}", value); + value = rx.recv().unwrap(); + println!("{}", value); + value = rx.recv().unwrap(); + println!("{}", value); + assert_eq!(value, 30); + t.join(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-10.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-10.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-10.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-10.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +#![allow(unused_mut)] +// ignore-emscripten no threads support + +use std::thread; +use std::sync::mpsc::{channel, Sender}; + +fn start(tx: &Sender>) { + let (tx2, rx) = channel(); + tx.send(tx2).unwrap(); + + let mut a; + let mut b; + a = rx.recv().unwrap(); + assert_eq!(a, "A".to_string()); + println!("{}", a); + b = rx.recv().unwrap(); + assert_eq!(b, "B".to_string()); + println!("{}", b); +} + +pub fn main() { + let (tx, rx) = channel(); + let child = thread::spawn(move|| { start(&tx) }); + + let mut c = rx.recv().unwrap(); + c.send("A".to_string()).unwrap(); + c.send("B".to_string()).unwrap(); + thread::yield_now(); + + child.join(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-11.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-11.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-11.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-11.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// pretty-expanded FIXME #23616 +// ignore-emscripten no threads support + +use std::sync::mpsc::{channel, Sender}; +use std::thread; + +fn start(tx: &Sender>) { + let (tx2, _rx) = channel(); + tx.send(tx2).unwrap(); +} + +pub fn main() { + let (tx, rx) = channel(); + let child = thread::spawn(move|| { + start(&tx) + }); + let _tx = rx.recv().unwrap(); + child.join(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-12.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-12.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-12.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-12.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +#![allow(unused_mut)] +// ignore-emscripten no threads support + +use std::thread; + +pub fn main() { test00(); } + +fn start(_task_number: isize) { println!("Started / Finished task."); } + +fn test00() { + let i: isize = 0; + let mut result = thread::spawn(move|| { + start(i) + }); + + // Sleep long enough for the thread to finish. + let mut i = 0_usize; + while i < 10000 { + thread::yield_now(); + i += 1; + } + + // Try joining threads that have already finished. + result.join(); + + println!("Joined task."); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-13.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-13.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-13.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-13.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// ignore-emscripten no threads support + +use std::sync::mpsc::{channel, Sender}; +use std::thread; + +fn start(tx: &Sender, start: isize, number_of_messages: isize) { + let mut i: isize = 0; + while i< number_of_messages { tx.send(start + i).unwrap(); i += 1; } +} + +pub fn main() { + println!("Check that we don't deadlock."); + let (tx, rx) = channel(); + let _ = thread::spawn(move|| { start(&tx, 0, 10) }).join(); + println!("Joined task"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-14.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-14.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-14.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-14.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_parens)] +// ignore-emscripten no threads support + +use std::sync::mpsc::{channel, Sender}; +use std::thread; + +pub fn main() { + let (tx, rx) = channel(); + + // Spawn 10 threads each sending us back one isize. + let mut i = 10; + while (i > 0) { + println!("{}", i); + let tx = tx.clone(); + thread::spawn({let i = i; move|| { child(i, &tx) }}); + i = i - 1; + } + + // Spawned threads are likely killed before they get a chance to send + // anything back, so we deadlock here. + + i = 10; + while (i > 0) { + println!("{}", i); + rx.recv().unwrap(); + i = i - 1; + } + + println!("main thread exiting"); +} + +fn child(x: isize, tx: &Sender) { + println!("{}", x); + tx.send(x).unwrap(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-15.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-15.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-15.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-15.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// ignore-emscripten no threads support +// pretty-expanded FIXME #23616 + +use std::sync::mpsc::{channel, Sender}; +use std::thread; + +fn start(tx: &Sender, i0: isize) { + let mut i = i0; + while i > 0 { + tx.send(0).unwrap(); + i = i - 1; + } +} + +pub fn main() { + // Spawn a thread that sends us back messages. The parent thread + // is likely to terminate before the child completes, so from + // the child's point of view the receiver may die. We should + // drop messages on the floor in this case, and not crash! + let (tx, rx) = channel(); + let t = thread::spawn(move|| { + start(&tx, 10) + }); + rx.recv(); + t.join(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-16.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-16.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-16.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-16.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,121 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +#![allow(unused_parens)] +#![allow(non_camel_case_types)] + +use std::sync::mpsc::channel; +use std::cmp; + +// Tests of ports and channels on various types +fn test_rec() { + struct R {val0: isize, val1: u8, val2: char} + + let (tx, rx) = channel(); + let r0: R = R {val0: 0, val1: 1, val2: '2'}; + tx.send(r0).unwrap(); + let mut r1: R; + r1 = rx.recv().unwrap(); + assert_eq!(r1.val0, 0); + assert_eq!(r1.val1, 1); + assert_eq!(r1.val2, '2'); +} + +fn test_vec() { + let (tx, rx) = channel(); + let v0: Vec = vec![0, 1, 2]; + tx.send(v0).unwrap(); + let v1 = rx.recv().unwrap(); + assert_eq!(v1[0], 0); + assert_eq!(v1[1], 1); + assert_eq!(v1[2], 2); +} + +fn test_str() { + let (tx, rx) = channel(); + let s0 = "test".to_string(); + tx.send(s0).unwrap(); + let s1 = rx.recv().unwrap(); + assert_eq!(s1.as_bytes()[0], 't' as u8); + assert_eq!(s1.as_bytes()[1], 'e' as u8); + assert_eq!(s1.as_bytes()[2], 's' as u8); + assert_eq!(s1.as_bytes()[3], 't' as u8); +} + +#[derive(Debug)] +enum t { + tag1, + tag2(isize), + tag3(isize, u8, char) +} + +impl cmp::PartialEq for t { + fn eq(&self, other: &t) -> bool { + match *self { + t::tag1 => { + match (*other) { + t::tag1 => true, + _ => false + } + } + t::tag2(e0a) => { + match (*other) { + t::tag2(e0b) => e0a == e0b, + _ => false + } + } + t::tag3(e0a, e1a, e2a) => { + match (*other) { + t::tag3(e0b, e1b, e2b) => + e0a == e0b && e1a == e1b && e2a == e2b, + _ => false + } + } + } + } + fn ne(&self, other: &t) -> bool { !(*self).eq(other) } +} + +fn test_tag() { + let (tx, rx) = channel(); + tx.send(t::tag1).unwrap(); + tx.send(t::tag2(10)).unwrap(); + tx.send(t::tag3(10, 11, 'A')).unwrap(); + let mut t1: t; + t1 = rx.recv().unwrap(); + assert_eq!(t1, t::tag1); + t1 = rx.recv().unwrap(); + assert_eq!(t1, t::tag2(10)); + t1 = rx.recv().unwrap(); + assert_eq!(t1, t::tag3(10, 11, 'A')); +} + +fn test_chan() { + let (tx1, rx1) = channel(); + let (tx2, rx2) = channel(); + tx1.send(tx2).unwrap(); + let tx2 = rx1.recv().unwrap(); + // Does the transmitted channel still work? + + tx2.send(10).unwrap(); + let mut i: isize; + i = rx2.recv().unwrap(); + assert_eq!(i, 10); +} + +pub fn main() { + test_rec(); + test_vec(); + test_str(); + test_tag(); + test_chan(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-17.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-17.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-17.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-17.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// ignore-emscripten no threads support +// pretty-expanded FIXME #23616 + +// Issue #922 + +// This test is specifically about spawning temporary closures. + +use std::thread; + +fn f() { +} + +pub fn main() { + thread::spawn(move|| f() ).join(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// ignore-emscripten no threads support + +use std::thread; + +pub fn main() { test00(); } + +fn start() { println!("Started / Finished task."); } + +fn test00() { + thread::spawn(move|| start() ).join(); + println!("Completing."); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-3.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,73 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// ignore-emscripten no threads support + +use std::thread; +use std::sync::mpsc::{channel, Sender}; + +pub fn main() { println!("===== WITHOUT THREADS ====="); test00(); } + +fn test00_start(ch: &Sender, message: isize, count: isize) { + println!("Starting test00_start"); + let mut i: isize = 0; + while i < count { + println!("Sending Message"); + ch.send(message + 0).unwrap(); + i = i + 1; + } + println!("Ending test00_start"); +} + +fn test00() { + let number_of_tasks: isize = 16; + let number_of_messages: isize = 4; + + println!("Creating tasks"); + + let (tx, rx) = channel(); + + let mut i: isize = 0; + + // Create and spawn threads... + let mut results = Vec::new(); + while i < number_of_tasks { + let tx = tx.clone(); + results.push(thread::spawn({ + let i = i; + move|| { + test00_start(&tx, i, number_of_messages) + } + })); + i = i + 1; + } + + // Read from spawned threads... + let mut sum = 0; + for _r in &results { + i = 0; + while i < number_of_messages { + let value = rx.recv().unwrap(); + sum += value; + i = i + 1; + } + } + + // Join spawned threads... + for r in results { r.join(); } + + println!("Completed: Final number is: "); + println!("{}", sum); + // assert (sum == (((number_of_threads * (number_of_threads - 1)) / 2) * + // number_of_messages)); + assert_eq!(sum, 480); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-4.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-4.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-4.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,55 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_assignments)] + +use std::sync::mpsc::channel; + +pub fn main() { test00(); } + +fn test00() { + let mut r: isize = 0; + let mut sum: isize = 0; + let (tx, rx) = channel(); + tx.send(1).unwrap(); + tx.send(2).unwrap(); + tx.send(3).unwrap(); + tx.send(4).unwrap(); + r = rx.recv().unwrap(); + sum += r; + println!("{}", r); + r = rx.recv().unwrap(); + sum += r; + println!("{}", r); + r = rx.recv().unwrap(); + sum += r; + println!("{}", r); + r = rx.recv().unwrap(); + sum += r; + println!("{}", r); + tx.send(5).unwrap(); + tx.send(6).unwrap(); + tx.send(7).unwrap(); + tx.send(8).unwrap(); + r = rx.recv().unwrap(); + sum += r; + println!("{}", r); + r = rx.recv().unwrap(); + sum += r; + println!("{}", r); + r = rx.recv().unwrap(); + sum += r; + println!("{}", r); + r = rx.recv().unwrap(); + sum += r; + println!("{}", r); + assert_eq!(sum, 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-5.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-5.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-5.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-5.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::sync::mpsc::channel; + +pub fn main() { test00(); } + +fn test00() { + let _r: isize = 0; + let mut sum: isize = 0; + let (tx, rx) = channel(); + let number_of_messages: isize = 1000; + let mut i: isize = 0; + while i < number_of_messages { tx.send(i + 0).unwrap(); i += 1; } + i = 0; + while i < number_of_messages { sum += rx.recv().unwrap(); i += 1; } + assert_eq!(sum, number_of_messages * (number_of_messages - 1) / 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-6.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-6.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-6.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-6.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,52 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +#![allow(unused_assignments)] + +use std::sync::mpsc::channel; + +pub fn main() { test00(); } + +fn test00() { + let mut r: isize = 0; + let mut sum: isize = 0; + let (tx, rx) = channel(); + let mut tx0 = tx.clone(); + let mut tx1 = tx.clone(); + let mut tx2 = tx.clone(); + let mut tx3 = tx.clone(); + let number_of_messages: isize = 1000; + let mut i: isize = 0; + while i < number_of_messages { + tx0.send(i + 0).unwrap(); + tx1.send(i + 0).unwrap(); + tx2.send(i + 0).unwrap(); + tx3.send(i + 0).unwrap(); + i += 1; + } + i = 0; + while i < number_of_messages { + r = rx.recv().unwrap(); + sum += r; + r = rx.recv().unwrap(); + sum += r; + r = rx.recv().unwrap(); + sum += r; + r = rx.recv().unwrap(); + sum += r; + i += 1; + } + assert_eq!(sum, 1998000); + // assert (sum == 4 * ((number_of_messages * + // (number_of_messages - 1)) / 2)); + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-7.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-7.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-7.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-7.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,69 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +#![allow(unused_assignments)] +// ignore-emscripten no threads support + +use std::sync::mpsc::{channel, Sender}; +use std::thread; + +pub fn main() { test00(); } + +fn test00_start(c: &Sender, start: isize, + number_of_messages: isize) { + let mut i: isize = 0; + while i < number_of_messages { c.send(start + i).unwrap(); i += 1; } +} + +fn test00() { + let mut r: isize = 0; + let mut sum: isize = 0; + let (tx, rx) = channel(); + let number_of_messages: isize = 10; + + let tx2 = tx.clone(); + let t1 = thread::spawn(move|| { + test00_start(&tx2, number_of_messages * 0, number_of_messages); + }); + let tx2 = tx.clone(); + let t2 = thread::spawn(move|| { + test00_start(&tx2, number_of_messages * 1, number_of_messages); + }); + let tx2 = tx.clone(); + let t3 = thread::spawn(move|| { + test00_start(&tx2, number_of_messages * 2, number_of_messages); + }); + let tx2 = tx.clone(); + let t4 = thread::spawn(move|| { + test00_start(&tx2, number_of_messages * 3, number_of_messages); + }); + + let mut i: isize = 0; + while i < number_of_messages { + r = rx.recv().unwrap(); + sum += r; + r = rx.recv().unwrap(); + sum += r; + r = rx.recv().unwrap(); + sum += r; + r = rx.recv().unwrap(); + sum += r; + i += 1; + } + + assert_eq!(sum, number_of_messages * 4 * (number_of_messages * 4 - 1) / 2); + + t1.join(); + t2.join(); + t3.join(); + t4.join(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-9.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-9.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-9.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-9.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// ignore-emscripten no threads support + +use std::thread; +use std::sync::mpsc::{channel, Sender}; + +pub fn main() { test00(); } + +fn test00_start(c: &Sender, number_of_messages: isize) { + let mut i: isize = 0; + while i < number_of_messages { c.send(i + 0).unwrap(); i += 1; } +} + +fn test00() { + let r: isize = 0; + let mut sum: isize = 0; + let (tx, rx) = channel(); + let number_of_messages: isize = 10; + + let result = thread::spawn(move|| { + test00_start(&tx, number_of_messages); + }); + + let mut i: isize = 0; + while i < number_of_messages { + sum += rx.recv().unwrap(); + println!("{}", r); + i += 1; + } + + result.join(); + + assert_eq!(sum, number_of_messages * (number_of_messages - 1) / 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-chan-nil.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-chan-nil.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-chan-nil.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-comm-chan-nil.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::sync::mpsc::channel; + +// rustboot can't transmit nils across channels because they don't have +// any size, but rustc currently can because they do have size. Whether +// or not this is desirable I don't know, but here's a regression test. +pub fn main() { + let (tx, rx) = channel(); + tx.send(()).unwrap(); + let n: () = rx.recv().unwrap(); + assert_eq!(n, ()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-life-0.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-life-0.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-life-0.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-life-0.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// ignore-emscripten no threads support +// pretty-expanded FIXME #23616 + +use std::thread; + +pub fn main() { + thread::spawn(move|| child("Hello".to_string()) ).join(); +} + +fn child(_s: String) { + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-spawn-move-and-copy.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-spawn-move-and-copy.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-spawn-move-and-copy.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-spawn-move-and-copy.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// ignore-emscripten no threads support + +#![feature(box_syntax)] + +use std::thread; +use std::sync::mpsc::channel; + +pub fn main() { + let (tx, rx) = channel::(); + + let x: Box = box 1; + let x_in_parent = &(*x) as *const isize as usize; + + let t = thread::spawn(move || { + let x_in_child = &(*x) as *const isize as usize; + tx.send(x_in_child).unwrap(); + }); + + let x_in_child = rx.recv().unwrap(); + assert_eq!(x_in_parent, x_in_child); + + t.join(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-stderr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-stderr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-stderr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/task-stderr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-emscripten no threads support + +#![feature(box_syntax, set_stdio)] + +use std::io::prelude::*; +use std::io; +use std::str; +use std::sync::{Arc, Mutex}; +use std::thread; + +struct Sink(Arc>>); +impl Write for Sink { + fn write(&mut self, data: &[u8]) -> io::Result { + Write::write(&mut *self.0.lock().unwrap(), data) + } + fn flush(&mut self) -> io::Result<()> { Ok(()) } +} + +fn main() { + let data = Arc::new(Mutex::new(Vec::new())); + let sink = Sink(data.clone()); + let res = thread::Builder::new().spawn(move|| -> () { + io::set_panic(Some(Box::new(sink))); + panic!("Hello, world!") + }).unwrap().join(); + assert!(res.is_err()); + + let output = data.lock().unwrap(); + let output = str::from_utf8(&output).unwrap(); + assert!(output.contains("Hello, world!")); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/thread-local-extern-static.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/thread-local-extern-static.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/thread-local-extern-static.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/thread-local-extern-static.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-windows +// aux-build:thread-local-extern-static.rs + +#![feature(cfg_target_thread_local, thread_local)] + +#[cfg(target_thread_local)] +extern crate thread_local_extern_static; + +#[cfg(target_thread_local)] +use std::cell::Cell; + +#[cfg(target_thread_local)] +extern { + #[thread_local] + static FOO: Cell; +} + +#[cfg(target_thread_local)] +fn main() { + unsafe { + assert_eq!(FOO.get(), 3); + } +} + +#[cfg(not(target_thread_local))] +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/thread-local-syntax.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/thread-local-syntax.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/thread-local-syntax.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/thread-local-syntax.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![deny(missing_docs)] +//! this tests the syntax of `thread_local!` + +mod foo { + mod bar { + thread_local! { + // no docs + #[allow(unused)] + static FOO: i32 = 42; + /// docs + pub static BAR: String = String::from("bar"); + + // look at these restrictions!! + pub(crate) static BAZ: usize = 0; + pub(in foo) static QUUX: usize = 0; + } + thread_local!(static SPLOK: u32 = 0); + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/threads.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/threads.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/threads.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/threads.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// ignore-emscripten no threads support + +use std::thread; + +pub fn main() { + let mut i = 10; + while i > 0 { + thread::spawn({let i = i; move|| child(i)}).join(); + i = i - 1; + } + println!("main thread exiting"); +} + +fn child(x: isize) { println!("{}", x); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/tls-dtors-are-run-in-a-static-binary.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/tls-dtors-are-run-in-a-static-binary.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/tls-dtors-are-run-in-a-static-binary.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/tls-dtors-are-run-in-a-static-binary.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// no-prefer-dynamic +// ignore-emscripten no threads support + +static mut HIT: bool = false; + +struct Foo; + +impl Drop for Foo { + fn drop(&mut self) { + unsafe { HIT = true; } + } +} + +thread_local!(static FOO: Foo = Foo); + +fn main() { + std::thread::spawn(|| { + FOO.with(|_| {}); + }).join().unwrap(); + assert!(unsafe { HIT }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/tls-init-on-init.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/tls-init-on-init.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/tls-init-on-init.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/tls-init-on-init.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,54 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(stable_features)] + +// ignore-emscripten no threads support + +#![feature(thread_local_try_with)] + +use std::thread; +use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; + +struct Foo { cnt: usize } + +thread_local!(static FOO: Foo = Foo::init()); + +static CNT: AtomicUsize = ATOMIC_USIZE_INIT; + +impl Foo { + fn init() -> Foo { + let cnt = CNT.fetch_add(1, Ordering::SeqCst); + if cnt == 0 { + FOO.with(|_| {}); + } + Foo { cnt: cnt } + } +} + +impl Drop for Foo { + fn drop(&mut self) { + if self.cnt == 1 { + FOO.with(|foo| assert_eq!(foo.cnt, 0)); + } else { + assert_eq!(self.cnt, 0); + if FOO.try_with(|_| ()).is_ok() { + panic!("should not be in valid state"); + } + } + } +} + +fn main() { + thread::spawn(|| { + FOO.with(|_| {}); + }).join().unwrap(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/tls-try-with.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/tls-try-with.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/tls-try-with.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/threads-sendsync/tls-try-with.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(stable_features)] + +// ignore-emscripten no threads support + +#![feature(thread_local_try_with)] + +use std::thread; + +static mut DROP_RUN: bool = false; + +struct Foo; + +thread_local!(static FOO: Foo = Foo {}); + +impl Drop for Foo { + fn drop(&mut self) { + assert!(FOO.try_with(|_| panic!("`try_with` closure run")).is_err()); + unsafe { DROP_RUN = true; } + } +} + +fn main() { + thread::spawn(|| { + assert_eq!(FOO.try_with(|_| { + 132 + }).expect("`try_with` failed"), 132); + }).join().unwrap(); + assert!(unsafe { DROP_RUN }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/tool_lints_2018_preview.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/tool_lints_2018_preview.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/tool_lints_2018_preview.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/tool_lints_2018_preview.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(tool_lints)] + #![feature(rust_2018_preview)] #![deny(unknown_lints)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/tool_lints.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/tool_lints.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/tool_lints.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/tool_lints.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(tool_lints)] + #![deny(unknown_lints)] #[allow(clippy::almost_swapped)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/anon_trait_static_method_exe.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/anon_trait_static_method_exe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/anon_trait_static_method_exe.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/anon_trait_static_method_exe.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +// aux-build:anon_trait_static_method_lib.rs + +extern crate anon_trait_static_method_lib; +use anon_trait_static_method_lib::Foo; + +pub fn main() { + let x = Foo::new(); + println!("{}", x.x); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/anon-trait-static-method.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/anon-trait-static-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/anon-trait-static-method.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/anon-trait-static-method.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +struct Foo { + x: isize +} + +impl Foo { + pub fn new() -> Foo { + Foo { x: 3 } + } +} + +pub fn main() { + let x = Foo::new(); + println!("{}", x.x); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/assignability-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/assignability-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/assignability-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/assignability-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,57 @@ +// Copyright 2012-4 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +// Tests that type assignability is used to search for instances when +// making method calls, but only if there aren't any matches without +// it. + +trait iterable { + fn iterate(&self, blk: F) -> bool where F: FnMut(&A) -> bool; +} + +impl<'a,A> iterable for &'a [A] { + fn iterate(&self, f: F) -> bool where F: FnMut(&A) -> bool { + self.iter().all(f) + } +} + +impl iterable for Vec { + fn iterate(&self, f: F) -> bool where F: FnMut(&A) -> bool { + self.iter().all(f) + } +} + +fn length>(x: T) -> usize { + let mut len = 0; + x.iterate(|_y| { + len += 1; + true + }); + return len; +} + +pub fn main() { + let x: Vec = vec![0,1,2,3]; + // Call a method + x.iterate(|y| { assert_eq!(x[*y as usize], *y); true }); + // Call a parameterized function + assert_eq!(length(x.clone()), x.len()); + // Call a parameterized function, with type arguments that require + // a borrow + assert_eq!(length::(&*x), x.len()); + + // Now try it with a type that *needs* to be borrowed + let z = [0,1,2,3]; + // Call a parameterized function + assert_eq!(length::(&z), z.len()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/astconv-cycle-between-trait-and-type.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/astconv-cycle-between-trait-and-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/astconv-cycle-between-trait-and-type.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/astconv-cycle-between-trait-and-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we are able to successfully compile a setup where a trait +// (`Trait1`) references a struct (`SomeType`) which in turn +// carries a predicate that references the trait (`u32 : Trait1`, +// substituted). + +// pretty-expanded FIXME #23616 + +#![allow(dead_code)] + +trait Trait1 : Trait2> { + fn dumb(&self) { } +} + +trait Trait2 { + fn dumber(&self, _: A) { } +} + +struct SomeType + where A : Trait1 +{ + a: A +} + +impl Trait1 for u32 { } + +impl Trait2> for u32 { } + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/augmented-assignments-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/augmented-assignments-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/augmented-assignments-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/augmented-assignments-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::ops::AddAssign; + +struct Int(i32); + +impl AddAssign for Int { + fn add_assign(&mut self, _: Int) { + unimplemented!() + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/auto-traits.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/auto-traits.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/auto-traits.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/auto-traits.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_doc_comments)] +#![feature(optin_builtin_traits)] + +auto trait Auto {} +unsafe auto trait AutoUnsafe {} + +impl !Auto for bool {} +impl !AutoUnsafe for bool {} + +struct AutoBool(bool); + +impl Auto for AutoBool {} +unsafe impl AutoUnsafe for AutoBool {} + +fn take_auto(_: T) {} +fn take_auto_unsafe(_: T) {} + +fn main() { + // Parse inside functions. + auto trait AutoInner {} + unsafe auto trait AutoUnsafeInner {} + + take_auto(0); + take_auto(AutoBool(true)); + take_auto_unsafe(0); + take_auto_unsafe(AutoBool(true)); + + /// Auto traits are allowed in trait object bounds. + let _: &(Send + Auto) = &0; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/anon_trait_static_method_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/anon_trait_static_method_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/anon_trait_static_method_lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/anon_trait_static_method_lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Foo { + pub x: isize +} + +impl Foo { + pub fn new() -> Foo { + Foo { x: 3 } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/go_trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/go_trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/go_trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/go_trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,53 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(specialization)] + +// Common code used for tests that model the Fn/FnMut/FnOnce hierarchy. + +pub trait Go { + fn go(&self, arg: isize); +} + +pub fn go(this: &G, arg: isize) { + this.go(arg) +} + +pub trait GoMut { + fn go_mut(&mut self, arg: isize); +} + +pub fn go_mut(this: &mut G, arg: isize) { + this.go_mut(arg) +} + +pub trait GoOnce { + fn go_once(self, arg: isize); +} + +pub fn go_once(this: G, arg: isize) { + this.go_once(arg) +} + +impl GoMut for G + where G : Go +{ + default fn go_mut(&mut self, arg: isize) { + go(&*self, arg) + } +} + +impl GoOnce for G + where G : GoMut +{ + default fn go_once(mut self, arg: isize) { + go_mut(&mut self, arg) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_default_method_xc_aux_2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_default_method_xc_aux_2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_default_method_xc_aux_2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_default_method_xc_aux_2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:trait_default_method_xc_aux.rs + +extern crate trait_default_method_xc_aux as aux; +use aux::A; + +pub struct a_struct { pub x: isize } + +impl A for a_struct { + fn f(&self) -> isize { 10 } +} + +// This function will need to get inlined, and badness may result. +pub fn welp(x: A) -> A { + let a = a_struct { x: 0 }; + a.g(); + x +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_default_method_xc_aux.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_default_method_xc_aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_default_method_xc_aux.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_default_method_xc_aux.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,50 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Something { pub x: isize } + +pub trait A { + fn f(&self) -> isize; + fn g(&self) -> isize { 10 } + fn h(&self) -> isize { 11 } + fn lurr(x: &Self, y: &Self) -> isize { x.g() + y.h() } +} + + +impl A for isize { + fn f(&self) -> isize { 10 } +} + +impl A for Something { + fn f(&self) -> isize { 10 } +} + +pub trait B { + fn thing(&self, x: T, y: U) -> (T, U) { (x, y) } + fn staticthing(_z: &Self, x: T, y: U) -> (T, U) { (x, y) } +} + +impl B for isize { } +impl B for bool { } + + + +pub trait TestEquality { + fn test_eq(&self, rhs: &Self) -> bool; + fn test_neq(&self, rhs: &Self) -> bool { + !self.test_eq(rhs) + } +} + +impl TestEquality for isize { + fn test_eq(&self, rhs: &isize) -> bool { + *self == *rhs + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/traitimpl.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/traitimpl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/traitimpl.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/traitimpl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test inherent trait impls work cross-crait. + +pub trait Bar<'a> : 'a {} + +impl<'a> Bar<'a> { + pub fn bar(&self) {} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_inheritance_auto_xc_2_aux.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_inheritance_auto_xc_2_aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_inheritance_auto_xc_2_aux.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_inheritance_auto_xc_2_aux.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait Foo { fn f(&self) -> isize; } +pub trait Bar { fn g(&self) -> isize; } +pub trait Baz { fn h(&self) -> isize; } + +pub struct A { pub x: isize } + +impl Foo for A { fn f(&self) -> isize { 10 } } +impl Bar for A { fn g(&self) -> isize { 20 } } +impl Baz for A { fn h(&self) -> isize { 30 } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_inheritance_auto_xc_aux.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_inheritance_auto_xc_aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_inheritance_auto_xc_aux.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_inheritance_auto_xc_aux.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait Foo { fn f(&self) -> isize; } +pub trait Bar { fn g(&self) -> isize; } +pub trait Baz { fn h(&self) -> isize; } + +pub trait Quux: Foo + Bar + Baz { } + +impl Quux for T { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_inheritance_overloading_xc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_inheritance_overloading_xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_inheritance_overloading_xc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_inheritance_overloading_xc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,48 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::cmp::PartialEq; +use std::ops::{Add, Sub, Mul}; + +pub trait MyNum : Add + Sub + Mul + PartialEq + Clone { +} + +#[derive(Clone, Debug)] +pub struct MyInt { + pub val: isize +} + +impl Add for MyInt { + type Output = MyInt; + + fn add(self, other: MyInt) -> MyInt { mi(self.val + other.val) } +} + +impl Sub for MyInt { + type Output = MyInt; + + fn sub(self, other: MyInt) -> MyInt { mi(self.val - other.val) } +} + +impl Mul for MyInt { + type Output = MyInt; + + fn mul(self, other: MyInt) -> MyInt { mi(self.val * other.val) } +} + +impl PartialEq for MyInt { + fn eq(&self, other: &MyInt) -> bool { self.val == other.val } + + fn ne(&self, other: &MyInt) -> bool { !self.eq(other) } +} + +impl MyNum for MyInt {} + +fn mi(v: isize) -> MyInt { MyInt { val: v } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_safety_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_safety_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_safety_lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_safety_lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Simple smoke test that unsafe traits can be compiled etc. + +pub unsafe trait Foo { + fn foo(&self) -> isize; +} + +unsafe impl Foo for isize { + fn foo(&self) -> isize { *self } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_xc_call_aux.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_xc_call_aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_xc_call_aux.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/auxiliary/trait_xc_call_aux.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +pub trait Foo { + fn f(&self) -> isize; +} + +pub struct A { + pub x: isize +} + +impl Foo for A { + fn f(&self) -> isize { 10 } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/conservative_impl_trait.stderr rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/conservative_impl_trait.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/conservative_impl_trait.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/conservative_impl_trait.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -warning: function is never used: `batches` - --> $DIR/conservative_impl_trait.rs:14:1 - | -LL | fn batches(n: &u32) -> impl Iterator { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: #[warn(dead_code)] on by default - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/cycle-trait-type-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/cycle-trait-type-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/cycle-trait-type-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/cycle-trait-type-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Test a case where a supertrait references a type that references +// the original trait. This poses no problem at the moment. + +// pretty-expanded FIXME #23616 + +trait Chromosome: Get> { +} + +trait Get { + fn get(&self) -> A; +} + +struct Struct { c: C } + +impl Chromosome for i32 { } + +impl Get> for i32 { + fn get(&self) -> Struct { + Struct { c: *self } + } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/default-method-supertrait-vtable.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/default-method-supertrait-vtable.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/default-method-supertrait-vtable.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/default-method-supertrait-vtable.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +// Tests that we can call a function bounded over a supertrait from +// a default method + +fn require_y(x: T) -> isize { x.y() } + +trait Y { + fn y(self) -> isize; +} + + +trait Z: Y + Sized { + fn x(self) -> isize { + require_y(self) + } +} + +impl Y for isize { + fn y(self) -> isize { self } +} + +impl Z for isize {} + +pub fn main() { + assert_eq!(12.x(), 12); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/dyn-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/dyn-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/dyn-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/dyn-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// ignore-pretty `dyn ::foo` parses differently in the current edition + +use std::fmt::Display; + +static BYTE: u8 = 33; + +fn main() { + let x: &(dyn 'static + Display) = &BYTE; + let y: Box = Box::new(BYTE); + let _: &dyn (Display) = &BYTE; + let _: &dyn (::std::fmt::Display) = &BYTE; + let xstr = format!("{}", x); + let ystr = format!("{}", y); + assert_eq!(xstr, "33"); + assert_eq!(ystr, "33"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/fmt-pointer-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/fmt-pointer-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/fmt-pointer-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/fmt-pointer-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::ptr; +use std::rc::Rc; +use std::sync::Arc; + +fn main() { + let p: *const u8 = ptr::null(); + let rc = Rc::new(1usize); + let arc = Arc::new(1usize); + let b = Box::new("hi"); + + let _ = format!("{:p}{:p}{:p}", + rc, arc, b); + + if cfg!(target_pointer_width = "32") { + assert_eq!(format!("{:#p}", p), + "0x00000000"); + } else { + assert_eq!(format!("{:#p}", p), + "0x0000000000000000"); + } + assert_eq!(format!("{:p}", p), + "0x0"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/impl-implicit-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/impl-implicit-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/impl-implicit-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/impl-implicit-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +enum option_ { + none_, + some_(T), +} + +impl option_ { + pub fn foo(&self) -> bool { true } +} + +enum option__ { + none__, + some__(isize) +} + +impl option__ { + pub fn foo(&self) -> bool { true } +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/impl-inherent-prefer-over-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/impl-inherent-prefer-over-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/impl-inherent-prefer-over-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/impl-inherent-prefer-over-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +struct Foo; + +trait Trait { + fn bar(&self); +} + +// Inherent impls should be preferred over trait ones. +impl Foo { + fn bar(&self) {} +} + +impl Trait { + fn baz(_: &Foo) {} +} + +impl Trait for Foo { + fn bar(&self) { panic!("wrong method called!") } +} + +fn main() { + Foo.bar(); + Foo::bar(&Foo); + ::bar(&Foo); + + // Should work even if Trait::baz doesn't exist. + // N.B: `::bar` would be ambiguous. + ::baz(&Foo); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/infer-from-object-trait-issue-26952.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/infer-from-object-trait-issue-26952.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/infer-from-object-trait-issue-26952.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/infer-from-object-trait-issue-26952.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// Test that when we match a trait reference like `Foo: Foo<_#0t>`, +// we unify with `_#0t` with `A`. In this code, if we failed to do +// that, then you get an unconstrained type-variable in `call`. +// +// Also serves as a regression test for issue #26952, though the test +// was derived from another reported regression with the same cause. + +use std::marker::PhantomData; + +trait Trait { fn foo(&self); } + +struct Type { a: PhantomData } + +fn as_trait(t: &Type) -> &Trait { loop { } } + +fn want+?Sized>(t: &T) { } + +fn call(p: Type) { + let q = as_trait(&p); + want(q); // parameter A to `want` *would* be unconstrained +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/inherent-trait-method-order.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/inherent-trait-method-order.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/inherent-trait-method-order.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/inherent-trait-method-order.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +struct Foo; + +impl Foo { + #[allow(dead_code)] + fn foo(self) { + panic!("wrong method!") + } +} + +trait Trait { + fn foo(self); +} + +impl<'a,'b,'c> Trait for &'a &'b &'c Foo { + fn foo(self) { + // ok + } +} + +fn main() { + let x = &(&(&Foo)); + x.foo(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/kindck-owned-trait-contains-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/kindck-owned-trait-contains-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/kindck-owned-trait-contains-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/kindck-owned-trait-contains-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_snake_case)] +#![allow(non_camel_case_types)] + +#![feature(box_syntax)] + +trait repeat { fn get(&self) -> A; } + +impl repeat for Box { + fn get(&self) -> A { + (**self).clone() + } +} + +fn repeater(v: Box) -> Box+'static> { + box v as Box+'static> // No +} + +pub fn main() { + let x = 3; + let y = repeater(box x); + assert_eq!(x, y.get()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/multiple-trait-bounds.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/multiple-trait-bounds.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/multiple-trait-bounds.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/multiple-trait-bounds.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +fn f(_: T) { +} + +pub fn main() { + f(3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/object-one-type-two-traits.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/object-one-type-two-traits.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/object-one-type-two-traits.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/object-one-type-two-traits.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// Testing creating two vtables with the same self type, but different +// traits. + +#![feature(box_syntax)] + +use std::any::Any; + +trait Wrap { + fn get(&self) -> isize; + fn wrap(self: Box) -> Box; +} + +impl Wrap for isize { + fn get(&self) -> isize { + *self + } + fn wrap(self: Box) -> Box { + self as Box + } +} + +fn is(x: &Any) -> bool { + x.is::() +} + +fn main() { + let x = box 22isize as Box; + println!("x={}", x.get()); + let y = x.wrap(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/overlap-permitted-for-marker-traits-neg.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/overlap-permitted-for-marker-traits-neg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/overlap-permitted-for-marker-traits-neg.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/overlap-permitted-for-marker-traits-neg.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![feature(overlapping_marker_traits)] +#![feature(optin_builtin_traits)] + +// Overlapping negative impls for `MyStruct` are permitted: +struct MyStruct; +impl !Send for MyStruct {} +impl !Send for MyStruct {} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/overlap-permitted-for-marker-traits.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/overlap-permitted-for-marker-traits.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/overlap-permitted-for-marker-traits.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/overlap-permitted-for-marker-traits.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests for RFC 1268: we allow overlapping impls of marker traits, +// that is, traits without items. In this case, a type `T` is +// `MyMarker` if it is either `Debug` or `Display`. + +#![feature(overlapping_marker_traits)] +#![feature(optin_builtin_traits)] + +use std::fmt::{Debug, Display}; + +trait MyMarker {} + +impl MyMarker for T {} +impl MyMarker for T {} + +fn foo(t: T) -> T { + t +} + +fn main() { + // Debug && Display: + assert_eq!(1, foo(1)); + assert_eq!(2.0, foo(2.0)); + + // Debug && !Display: + assert_eq!(vec![1], foo(vec![1])); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/parameterized-trait-with-bounds.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/parameterized-trait-with-bounds.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/parameterized-trait-with-bounds.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/parameterized-trait-with-bounds.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#![allow(dead_code)] + + +trait A { fn get(self) -> T; } +trait B { fn get(self) -> (T,U); } +trait C<'a, U> { fn get(self) -> &'a U; } + +mod foo { + pub trait D<'a, T> { fn get(self) -> &'a T; } +} + +fn foo1(_: &(A + Send)) {} +fn foo2(_: Box + Send + Sync>) {} +fn foo3(_: Box + 'static>) {} +fn foo4<'a, T>(_: Box + 'static + Send>) {} +fn foo5<'a, T>(_: Box + 'static + Send>) {} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/supertrait-default-generics.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/supertrait-default-generics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/supertrait-default-generics.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/supertrait-default-generics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,49 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_snake_case)] + +// There is some other borrowck bug, so we make the stuff not mut. + + +use std::ops::Add; + +trait Positioned { + fn SetX(&mut self, _: S); + fn X(&self) -> S; +} + +trait Movable>: Positioned { + fn translate(&mut self, dx: S) { + let x = self.X() + dx; + self.SetX(x); + } +} + +struct Point { x: S, y: S } + +impl Positioned for Point { + fn SetX(&mut self, x: S) { + self.x = x; + } + fn X(&self) -> S { + self.x.clone() + } +} + +impl> Movable for Point {} + +pub fn main() { + let mut p = Point{ x: 1, y: 2}; + p.translate(3); + assert_eq!(p.X(), 4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/syntax-trait-polarity.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/syntax-trait-polarity.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/syntax-trait-polarity.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/syntax-trait-polarity.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +#![feature(optin_builtin_traits)] + +struct TestType; + +impl TestType {} + +trait TestTrait {} + +impl !Send for TestType {} + +struct TestType2(T); + +impl TestType2 {} + +impl !Send for TestType2 {} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds-basic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds-basic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds-basic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds-basic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unconditional_recursion)] + +// pretty-expanded FIXME #23616 + +trait Foo { +} + +fn b(_x: Box) { +} + +fn c(x: Box) { + e(x); +} + +fn d(x: Box) { + e(x); +} + +fn e(x: Box) { + e(x); +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds-impl-comparison-duplicates.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds-impl-comparison-duplicates.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds-impl-comparison-duplicates.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds-impl-comparison-duplicates.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests that type parameter bounds on an implementation need not match the +// trait exactly, as long as the implementation doesn't demand *more* bounds +// than the trait. + +// pretty-expanded FIXME #23616 + +trait A { + fn foo(&self); +} + +impl A for isize { + fn foo(&self) {} // Ord implies Eq, so this is ok. +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds-in-arc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds-in-arc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds-in-arc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds-in-arc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,119 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// Tests that a heterogeneous list of existential types can be put inside an Arc +// and shared between threads as long as all types fulfill Send. + +// ignore-emscripten no threads support + +#![feature(box_syntax)] + +use std::sync::Arc; +use std::sync::mpsc::channel; +use std::thread; + +trait Pet { + fn name(&self, blk: Box); + fn num_legs(&self) -> usize; + fn of_good_pedigree(&self) -> bool; +} + +struct Catte { + num_whiskers: usize, + name: String, +} + +struct Dogge { + bark_decibels: usize, + tricks_known: usize, + name: String, +} + +struct Goldfyshe { + swim_speed: usize, + name: String, +} + +impl Pet for Catte { + fn name(&self, mut blk: Box) { blk(&self.name) } + fn num_legs(&self) -> usize { 4 } + fn of_good_pedigree(&self) -> bool { self.num_whiskers >= 4 } +} +impl Pet for Dogge { + fn name(&self, mut blk: Box) { blk(&self.name) } + fn num_legs(&self) -> usize { 4 } + fn of_good_pedigree(&self) -> bool { + self.bark_decibels < 70 || self.tricks_known > 20 + } +} +impl Pet for Goldfyshe { + fn name(&self, mut blk: Box) { blk(&self.name) } + fn num_legs(&self) -> usize { 0 } + fn of_good_pedigree(&self) -> bool { self.swim_speed >= 500 } +} + +pub fn main() { + let catte = Catte { num_whiskers: 7, name: "alonzo_church".to_string() }; + let dogge1 = Dogge { + bark_decibels: 100, + tricks_known: 42, + name: "alan_turing".to_string(), + }; + let dogge2 = Dogge { + bark_decibels: 55, + tricks_known: 11, + name: "albert_einstein".to_string(), + }; + let fishe = Goldfyshe { + swim_speed: 998, + name: "alec_guinness".to_string(), + }; + let arc = Arc::new(vec![box catte as Box, + box dogge1 as Box, + box fishe as Box, + box dogge2 as Box]); + let (tx1, rx1) = channel(); + let arc1 = arc.clone(); + let t1 = thread::spawn(move|| { check_legs(arc1); tx1.send(()); }); + let (tx2, rx2) = channel(); + let arc2 = arc.clone(); + let t2 = thread::spawn(move|| { check_names(arc2); tx2.send(()); }); + let (tx3, rx3) = channel(); + let arc3 = arc.clone(); + let t3 = thread::spawn(move|| { check_pedigree(arc3); tx3.send(()); }); + rx1.recv(); + rx2.recv(); + rx3.recv(); + t1.join(); + t2.join(); + t3.join(); +} + +fn check_legs(arc: Arc>>) { + let mut legs = 0; + for pet in arc.iter() { + legs += pet.num_legs(); + } + assert!(legs == 12); +} +fn check_names(arc: Arc>>) { + for pet in arc.iter() { + pet.name(Box::new(|name| { + assert!(name.as_bytes()[0] == 'a' as u8 && name.as_bytes()[1] == 'l' as u8); + })) + } +} +fn check_pedigree(arc: Arc>>) { + for pet in arc.iter() { + assert!(pet.of_good_pedigree()); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds-on-structs-and-enums.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds-on-structs-and-enums.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds-on-structs-and-enums.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds-on-structs-and-enums.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// pretty-expanded FIXME #23616 + +trait U {} +trait T { fn get(self) -> X; } + +trait S2 { + fn m(x: Box+'static>) {} +} + +struct St { + f: Box+'static>, +} + +impl St { + fn blah() {} +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds-recursion.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds-recursion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds-recursion.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds-recursion.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +trait I { fn i(&self) -> Self; } + +trait A { + fn id(x:T) -> T { x.i() } +} + +trait J { fn j(&self) -> T; } + +trait B> { + fn id(x:T) -> T { x.j() } +} + +trait C { + fn id>(x:T) -> T { x.j() } +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-bounds.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] + +trait connection { + fn read(&self) -> isize; +} + +trait connection_factory { + fn create(&self) -> C; +} + +type my_connection = (); +type my_connection_factory = (); + +impl connection for () { + fn read(&self) -> isize { 43 } +} + +impl connection_factory for my_connection_factory { + fn create(&self) -> my_connection { () } +} + +pub fn main() { + let factory = (); + let connection = factory.create(); + let result = connection.read(); + assert_eq!(result, 43); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-cache-issue-18209.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-cache-issue-18209.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-cache-issue-18209.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-cache-issue-18209.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that the cache results from the default method do not pollute +// the cache for the later call in `load()`. +// +// See issue #18209. + +// pretty-expanded FIXME #23616 + +pub trait Foo { + fn load_from() -> Box; + fn load() -> Box { + Foo::load_from() + } +} + +pub fn load() -> Box { + Foo::load() +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-coercion-generic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-coercion-generic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-coercion-generic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-coercion-generic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +trait Trait { + fn f(&self, x: T); +} + +#[derive(Copy, Clone)] +struct Struct { + x: isize, + y: isize, +} + +impl Trait<&'static str> for Struct { + fn f(&self, x: &'static str) { + println!("Hi, {}!", x); + } +} + +pub fn main() { + let a = Struct { x: 1, y: 2 }; + let b: Box> = Box::new(a); + b.f("Mary"); + let c: &Trait<&'static str> = &a; + c.f("Joe"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-coercion.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-coercion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-coercion.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-coercion.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_mut)] +#![allow(unused_variables)] +#![feature(box_syntax)] + +use std::io::{self, Write}; + +trait Trait { + fn f(&self); +} + +#[derive(Copy, Clone)] +struct Struct { + x: isize, + y: isize, +} + +impl Trait for Struct { + fn f(&self) { + println!("Hi!"); + } +} + +fn foo(mut a: Box) {} + +pub fn main() { + let a = Struct { x: 1, y: 2 }; + let b: Box = Box::new(a); + b.f(); + let c: &Trait = &a; + c.f(); + + let out = io::stdout(); + foo(Box::new(out)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-composition-trivial.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-composition-trivial.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-composition-trivial.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-composition-trivial.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +trait Foo { + fn foo(&self); +} + +trait Bar : Foo { + fn bar(&self); +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-copy-guessing.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-copy-guessing.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-copy-guessing.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-copy-guessing.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,48 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// "guessing" in trait selection can affect `copy_or_move`. Check that this +// is correctly handled. I am not sure what is the "correct" behaviour, +// but we should at least not ICE. + +use std::mem; + +struct U([u8; 1337]); + +struct S<'a,T:'a>(&'a T); +impl<'a, T> Clone for S<'a, T> { fn clone(&self) -> Self { S(self.0) } } +/// This impl triggers inference "guessing" - S<_>: Copy => _ = U +impl<'a> Copy for S<'a, Option> {} + +fn assert_impls_fnR>(_: &T){} + +fn main() { + let n = None; + let e = S(&n); + let f = || { + // S being copy is critical for this to work + drop(e); + mem::size_of_val(e.0) + }; + assert_impls_fn(&f); + assert_eq!(f(), 1337+1); + + assert_eq!((|| { + // S being Copy is not critical here, but + // we check it anyway. + let n = None; + let e = S(&n); + let ret = mem::size_of_val(e.0); + drop(e); + ret + })(), 1337+1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-bound.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-bound.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +trait A { + fn g(&self) -> isize { 10 } +} + +impl A for isize { } + +fn f(i: T) { + assert_eq!(i.g(), 10); +} + +pub fn main () { + f(0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-bound-subst2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-bound-subst2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-bound-subst2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-bound-subst2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +trait A { + fn g(&self, x: T) -> T { x } +} + +impl A for isize { } + +fn f>(i: V, j: T) -> T { + i.g(j) +} + +pub fn main () { + assert_eq!(f(0, 2), 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-bound-subst3.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-bound-subst3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-bound-subst3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-bound-subst3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +trait A { + fn g(&self, x: T, y: T) -> (T, T) { (x, y) } +} + +impl A for isize { } + +fn f(i: V, j: T, k: T) -> (T, T) { + i.g(j, k) +} + +pub fn main () { + assert_eq!(f(0, 1, 2), (1, 2)); + assert_eq!(f(0, 1u8, 2u8), (1u8, 2u8)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-bound-subst4.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-bound-subst4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-bound-subst4.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-bound-subst4.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] + + +trait A { + fn g(&self, x: usize) -> usize { x } + fn h(&self, x: T) { } +} + +impl A for isize { } + +fn f>(i: V, j: usize) -> usize { + i.g(j) +} + +pub fn main () { + assert_eq!(f::(0, 2), 2); + assert_eq!(f::(0, 2), 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-bound-subst.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-bound-subst.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-bound-subst.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-bound-subst.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +trait A { + fn g(&self, x: T, y: U) -> (T, U) { (x, y) } +} + +impl A for i32 { } +impl A for u32 { } + +fn f>(i: V, j: T, k: U) -> (T, U) { + i.g(j, k) +} + +pub fn main () { + assert_eq!(f(0, 1, 2), (1, 2)); + assert_eq!(f(0, 1, 2), (1, 2)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-xc-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-xc-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-xc-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-xc-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:trait_default_method_xc_aux.rs +// aux-build:trait_default_method_xc_aux_2.rs + + + +extern crate trait_default_method_xc_aux as aux; +extern crate trait_default_method_xc_aux_2 as aux2; +use aux::A; +use aux2::{a_struct, welp}; + + +pub fn main () { + + let a = a_struct { x: 0 }; + let b = a_struct { x: 1 }; + + assert_eq!(0.g(), 10); + assert_eq!(a.g(), 10); + assert_eq!(a.h(), 11); + assert_eq!(b.g(), 10); + assert_eq!(b.h(), 11); + assert_eq!(A::lurr(&a, &b), 21); + + welp(&0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-xc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-xc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-default-method-xc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,91 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// aux-build:trait_default_method_xc_aux.rs + + +extern crate trait_default_method_xc_aux as aux; +use aux::{A, TestEquality, Something}; +use aux::B; + +fn f(i: T) { + assert_eq!(i.g(), 10); +} + +fn welp(i: isize, _x: &T) -> isize { + i.g() +} + +mod stuff { + pub struct thing { pub x: isize } +} + +impl A for stuff::thing { + fn f(&self) -> isize { 10 } +} + +fn g>(i: V, j: T, k: U) -> (T, U) { + i.thing(j, k) +} + +fn eq(lhs: &T, rhs: &T) -> bool { + lhs.test_eq(rhs) +} +fn neq(lhs: &T, rhs: &T) -> bool { + lhs.test_neq(rhs) +} + + +impl TestEquality for stuff::thing { + fn test_eq(&self, rhs: &stuff::thing) -> bool { + //self.x.test_eq(&rhs.x) + eq(&self.x, &rhs.x) + } +} + + +pub fn main() { + // Some tests of random things + f(0); + + assert_eq!(A::lurr(&0, &1), 21); + + let a = stuff::thing { x: 0 }; + let b = stuff::thing { x: 1 }; + let c = Something { x: 1 }; + + assert_eq!(0.g(), 10); + assert_eq!(a.g(), 10); + assert_eq!(a.h(), 11); + assert_eq!(c.h(), 11); + + assert_eq!(0.thing(3.14f64, 1), (3.14f64, 1)); + assert_eq!(B::staticthing(&0, 3.14f64, 1), (3.14f64, 1)); + assert_eq!(B::::staticthing::(&0, 3.14, 1), (3.14, 1)); + + assert_eq!(g(0, 3.14f64, 1), (3.14f64, 1)); + assert_eq!(g(false, 3.14f64, 1), (3.14, 1)); + + + // Trying out a real one + assert!(12.test_neq(&10)); + assert!(!10.test_neq(&10)); + assert!(a.test_neq(&b)); + assert!(!a.test_neq(&a)); + + assert!(neq(&12, &10)); + assert!(!neq(&10, &10)); + assert!(neq(&a, &b)); + assert!(!neq(&a, &a)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-false-ambiguity-where-clause-builtin-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-false-ambiguity-where-clause-builtin-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-false-ambiguity-where-clause-builtin-bound.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-false-ambiguity-where-clause-builtin-bound.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we do not error out because of a (False) ambiguity +// between the builtin rules for Sized and the where clause. Issue +// #20959. + +// pretty-expanded FIXME #23616 + +fn foo(x: Option) + where Option : Sized +{ + let _y = x; +} + +fn main() { + foo(Some(22)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-generic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-generic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-generic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-generic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,55 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + + + +trait to_str { + fn to_string_(&self) -> String; +} +impl to_str for isize { + fn to_string_(&self) -> String { self.to_string() } +} +impl to_str for String { + fn to_string_(&self) -> String { self.clone() } +} +impl to_str for () { + fn to_string_(&self) -> String { "()".to_string() } +} + +trait map { + fn map(&self, f: F) -> Vec where F: FnMut(&T) -> U; +} +impl map for Vec { + fn map(&self, mut f: F) -> Vec where F: FnMut(&T) -> U { + let mut r = Vec::new(); + for i in self { + r.push(f(i)); + } + r + } +} + +fn foo>(x: T) -> Vec { + x.map(|_e| "hi".to_string() ) +} +fn bar>(x: T) -> Vec { + x.map(|_e| _e.to_string_() ) +} + +pub fn main() { + assert_eq!(foo(vec![1]), ["hi".to_string()]); + assert_eq!(bar:: >(vec![4, 5]), ["4".to_string(), "5".to_string()]); + assert_eq!(bar:: >(vec!["x".to_string(), "y".to_string()]), + ["x".to_string(), "y".to_string()]); + assert_eq!(bar::<(), Vec<()>>(vec![()]), ["()".to_string()]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-impl-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-impl-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-impl-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-impl-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_snake_case)] + +// pretty-expanded FIXME #23616 + +pub mod Foo { + pub trait Trait { + fn foo(&self); + } +} + +mod Bar { + impl<'a> ::Foo::Trait+'a { + fn bar(&self) { self.foo() } + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-impl.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-impl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,51 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test calling methods on an impl for a bare trait. + +// aux-build:traitimpl.rs + +extern crate traitimpl; +use traitimpl::Bar; + +static mut COUNT: usize = 1; + +trait T { + fn t(&self) {} +} + +impl<'a> T+'a { + fn foo(&self) { + unsafe { COUNT *= 2; } + } + fn bar() { + unsafe { COUNT *= 3; } + } +} + +impl T for isize {} + +struct Foo; +impl<'a> Bar<'a> for Foo {} + +fn main() { + let x: &T = &42; + + x.foo(); + T::foo(x); + T::bar(); + + unsafe { assert_eq!(COUNT, 12); } + + // Cross-crait case + let x: &Bar = &Foo; + x.bar(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +trait Foo { fn f(&self) -> isize; } +trait Bar { fn g(&self) -> isize; } +trait Baz { fn h(&self) -> isize; } + +trait Quux: Foo + Bar + Baz { } + +struct A { x: isize } + +impl Foo for A { fn f(&self) -> isize { 10 } } +impl Bar for A { fn g(&self) -> isize { 20 } } +impl Baz for A { fn h(&self) -> isize { 30 } } +impl Quux for A {} + +fn f(a: &T) { + assert_eq!(a.f(), 10); + assert_eq!(a.g(), 20); + assert_eq!(a.h(), 30); +} + +pub fn main() { + let a = &A { x: 3 }; + f(a); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-auto.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-auto.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-auto.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-auto.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Testing that this impl turns A into a Quux, because +// A is already a Foo Bar Baz + +impl Quux for T { } + +trait Foo { fn f(&self) -> isize; } +trait Bar { fn g(&self) -> isize; } +trait Baz { fn h(&self) -> isize; } + +trait Quux: Foo + Bar + Baz { } + +struct A { x: isize } + +impl Foo for A { fn f(&self) -> isize { 10 } } +impl Bar for A { fn g(&self) -> isize { 20 } } +impl Baz for A { fn h(&self) -> isize { 30 } } + +fn f(a: &T) { + assert_eq!(a.f(), 10); + assert_eq!(a.g(), 20); + assert_eq!(a.h(), 30); +} + +pub fn main() { + let a = &A { x: 3 }; + f(a); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-auto-xc-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-auto-xc-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-auto-xc-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-auto-xc-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:trait_inheritance_auto_xc_2_aux.rs + + +extern crate trait_inheritance_auto_xc_2_aux as aux; + +// aux defines impls of Foo, Bar and Baz for A +use aux::{Foo, Bar, Baz, A}; + +// We want to extend all Foo, Bar, Bazes to Quuxes +pub trait Quux: Foo + Bar + Baz { } +impl Quux for T { } + +fn f(a: &T) { + assert_eq!(a.f(), 10); + assert_eq!(a.g(), 20); + assert_eq!(a.h(), 30); +} + +pub fn main() { + let a = &A { x: 3 }; + f(a); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-auto-xc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-auto-xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-auto-xc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-auto-xc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// aux-build:trait_inheritance_auto_xc_aux.rs + + +extern crate trait_inheritance_auto_xc_aux as aux; + +use aux::{Foo, Bar, Baz, Quux}; + +struct A { x: isize } + +impl Foo for A { fn f(&self) -> isize { 10 } } +impl Bar for A { fn g(&self) -> isize { 20 } } +impl Baz for A { fn h(&self) -> isize { 30 } } + +fn f(a: &T) { + assert_eq!(a.f(), 10); + assert_eq!(a.g(), 20); + assert_eq!(a.h(), 30); +} + +pub fn main() { + let a = &A { x: 3 }; + f(a); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-call-bound-inherited2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-call-bound-inherited2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-call-bound-inherited2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-call-bound-inherited2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +trait Foo { fn f(&self) -> isize; } +trait Bar : Foo { fn g(&self) -> isize; } +trait Baz : Bar { fn h(&self) -> isize; } + +struct A { x: isize } + +impl Foo for A { fn f(&self) -> isize { 10 } } +impl Bar for A { fn g(&self) -> isize { 20 } } +impl Baz for A { fn h(&self) -> isize { 30 } } + +// Call a function on Foo, given a T: Baz, +// which is inherited via Bar +fn gg(a: &T) -> isize { + a.f() +} + +pub fn main() { + let a = &A { x: 3 }; + assert_eq!(gg(a), 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-call-bound-inherited.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-call-bound-inherited.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-call-bound-inherited.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-call-bound-inherited.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +trait Foo { fn f(&self) -> isize; } +trait Bar : Foo { fn g(&self) -> isize; } + +struct A { x: isize } + +impl Foo for A { fn f(&self) -> isize { 10 } } +impl Bar for A { fn g(&self) -> isize { 20 } } + +// Call a function on Foo, given a T: Bar +fn gg(a: &T) -> isize { + a.f() +} + +pub fn main() { + let a = &A { x: 3 }; + assert_eq!(gg(a), 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-cast.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-cast.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-cast.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Testing that supertrait methods can be called on subtrait object types + + +trait Foo { + fn f(&self) -> isize; +} + +trait Bar : Foo { + fn g(&self) -> isize; +} + +struct A { + x: isize +} + +impl Foo for A { + fn f(&self) -> isize { 10 } +} + +impl Bar for A { + fn g(&self) -> isize { 20 } +} + +pub fn main() { + let a = &A { x: 3 }; + let afoo = a as &Foo; + let abar = a as &Bar; + assert_eq!(afoo.f(), 10); + assert_eq!(abar.g(), 20); + assert_eq!(abar.f(), 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-cast-without-call-to-supertrait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-cast-without-call-to-supertrait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-cast-without-call-to-supertrait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-cast-without-call-to-supertrait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Testing that we can cast to a subtrait and call subtrait +// methods. Not testing supertrait methods + + +trait Foo { + fn f(&self) -> isize; +} + +trait Bar : Foo { + fn g(&self) -> isize; +} + +struct A { + x: isize +} + +impl Foo for A { + fn f(&self) -> isize { 10 } +} + +impl Bar for A { + fn g(&self) -> isize { 20 } +} + +pub fn main() { + let a = &A { x: 3 }; + let afoo = a as &Foo; + let abar = a as &Bar; + assert_eq!(afoo.f(), 10); + assert_eq!(abar.g(), 20); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-cross-trait-call.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-cross-trait-call.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-cross-trait-call.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-cross-trait-call.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +trait Foo { fn f(&self) -> isize; } +trait Bar : Foo { fn g(&self) -> isize; } + +struct A { x: isize } + +impl Foo for A { fn f(&self) -> isize { 10 } } + +impl Bar for A { + // Testing that this impl can call the impl of Foo + fn g(&self) -> isize { self.f() } +} + +pub fn main() { + let a = &A { x: 3 }; + assert_eq!(a.g(), 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-cross-trait-call-xc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-cross-trait-call-xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-cross-trait-call-xc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-cross-trait-call-xc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:trait_xc_call_aux.rs + + +extern crate trait_xc_call_aux as aux; + +use aux::Foo; + +trait Bar : Foo { + fn g(&self) -> isize; +} + +impl Bar for aux::A { + fn g(&self) -> isize { self.f() } +} + +pub fn main() { + let a = &aux::A { x: 3 }; + assert_eq!(a.g(), 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-diamond.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-diamond.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-diamond.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-diamond.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// B and C both require A, so D does as well, twice, but that's just fine + + +trait A { fn a(&self) -> isize; } +trait B: A { fn b(&self) -> isize; } +trait C: A { fn c(&self) -> isize; } +trait D: B + C { fn d(&self) -> isize; } + +struct S { bogus: () } + +impl A for S { fn a(&self) -> isize { 10 } } +impl B for S { fn b(&self) -> isize { 20 } } +impl C for S { fn c(&self) -> isize { 30 } } +impl D for S { fn d(&self) -> isize { 40 } } + +fn f(x: &T) { + assert_eq!(x.a(), 10); + assert_eq!(x.b(), 20); + assert_eq!(x.c(), 30); + assert_eq!(x.d(), 40); +} + +pub fn main() { + let value = &S { bogus: () }; + f(value); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-multiple-inheritors.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-multiple-inheritors.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-multiple-inheritors.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-multiple-inheritors.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +trait A { fn a(&self) -> isize; } +trait B: A { fn b(&self) -> isize; } +trait C: A { fn c(&self) -> isize; } + +struct S { bogus: () } + +impl A for S { fn a(&self) -> isize { 10 } } +impl B for S { fn b(&self) -> isize { 20 } } +impl C for S { fn c(&self) -> isize { 30 } } + +// Both B and C inherit from A +fn f(x: &T) { + assert_eq!(x.a(), 10); + assert_eq!(x.b(), 20); + assert_eq!(x.c(), 30); +} + +pub fn main() { + f(&S { bogus: () }) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-multiple-params.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-multiple-params.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-multiple-params.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-multiple-params.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +trait A { fn a(&self) -> isize; } +trait B: A { fn b(&self) -> isize; } +trait C: A { fn c(&self) -> isize; } + +struct S { bogus: () } + +impl A for S { fn a(&self) -> isize { 10 } } +impl B for S { fn b(&self) -> isize { 20 } } +impl C for S { fn c(&self) -> isize { 30 } } + +// Multiple type params, multiple levels of inheritance +fn f(x: &X, y: &Y, z: &Z) { + assert_eq!(x.a(), 10); + assert_eq!(y.a(), 10); + assert_eq!(y.b(), 20); + assert_eq!(z.a(), 10); + assert_eq!(z.c(), 30); +} + +pub fn main() { + let s = &S { bogus: () }; + f(s, s, s); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num0.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num0.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num0.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num0.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Extending Num and using inherited static methods + +// pretty-expanded FIXME #23616 + +use std::cmp::PartialOrd; + +pub trait NumCast: Sized { + fn from(i: i32) -> Option; +} + +pub trait Num { + fn from_int(i: isize) -> Self; + fn gt(&self, other: &Self) -> bool; +} + +pub trait NumExt: NumCast + PartialOrd { } + +fn greater_than_one(n: &T) -> bool { + n.gt(&NumCast::from(1).unwrap()) +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +pub trait NumCast: Sized { + fn from(i: i32) -> Option; +} + +pub trait NumExt: NumCast + PartialOrd { } + +fn greater_than_one(n: &T) -> bool { + *n > NumCast::from(1).unwrap() +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,96 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// A more complex example of numeric extensions + +pub trait TypeExt {} + +impl TypeExt for u8 {} +impl TypeExt for u16 {} +impl TypeExt for u32 {} +impl TypeExt for u64 {} +impl TypeExt for usize {} + +impl TypeExt for i8 {} +impl TypeExt for i16 {} +impl TypeExt for i32 {} +impl TypeExt for i64 {} +impl TypeExt for isize {} + +impl TypeExt for f32 {} +impl TypeExt for f64 {} + + +pub trait NumExt: TypeExt + PartialEq + PartialOrd {} + +impl NumExt for u8 {} +impl NumExt for u16 {} +impl NumExt for u32 {} +impl NumExt for u64 {} +impl NumExt for usize {} + +impl NumExt for i8 {} +impl NumExt for i16 {} +impl NumExt for i32 {} +impl NumExt for i64 {} +impl NumExt for isize {} + +impl NumExt for f32 {} +impl NumExt for f64 {} + + +pub trait UnSignedExt: NumExt {} + +impl UnSignedExt for u8 {} +impl UnSignedExt for u16 {} +impl UnSignedExt for u32 {} +impl UnSignedExt for u64 {} +impl UnSignedExt for usize {} + + +pub trait SignedExt: NumExt {} + +impl SignedExt for i8 {} +impl SignedExt for i16 {} +impl SignedExt for i32 {} +impl SignedExt for i64 {} +impl SignedExt for isize {} + +impl SignedExt for f32 {} +impl SignedExt for f64 {} + + +pub trait IntegerExt: NumExt {} + +impl IntegerExt for u8 {} +impl IntegerExt for u16 {} +impl IntegerExt for u32 {} +impl IntegerExt for u64 {} +impl IntegerExt for usize {} + +impl IntegerExt for i8 {} +impl IntegerExt for i16 {} +impl IntegerExt for i32 {} +impl IntegerExt for i64 {} +impl IntegerExt for isize {} + + +pub trait FloatExt: NumExt {} + +impl FloatExt for f32 {} +impl FloatExt for f64 {} + + +fn test_float_ext(n: T) { println!("{}", n < n) } + +pub fn main() { + test_float_ext(1f32); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num3.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub trait NumCast: Sized { + fn from(i: i32) -> Option; +} + +pub trait NumExt: PartialEq + PartialOrd + NumCast {} + +impl NumExt for f32 {} +impl NumCast for f32 { + fn from(i: i32) -> Option { Some(i as f32) } +} + +fn num_eq_one(n: T) { + println!("{}", n == NumCast::from(1).unwrap()) +} + +pub fn main() { + num_eq_one(1f32); // you need to actually use the function to trigger the ICE +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num5.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num5.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num5.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num5.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +pub trait NumCast: Sized { + fn from(i: i32) -> Option; +} + +pub trait NumExt: PartialEq + NumCast {} + +impl NumExt for f32 {} +impl NumExt for isize {} + +impl NumCast for f32 { + fn from(i: i32) -> Option { Some(i as f32) } +} +impl NumCast for isize { + fn from(i: i32) -> Option { Some(i as isize) } +} + +fn num_eq_one() -> T { + NumCast::from(1).unwrap() +} + +pub fn main() { + num_eq_one::(); // you need to actually use the function to trigger the ICE +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-num.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// pretty-expanded FIXME #23616 + +pub trait NumExt: PartialEq + PartialOrd {} + +pub trait FloatExt: NumExt {} + +fn greater_than_one(n: &T) -> bool { loop {} } +fn greater_than_one_float(n: &T) -> bool { loop {} } + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-overloading.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-overloading.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-overloading.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-overloading.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,57 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::cmp::PartialEq; +use std::ops::{Add, Sub, Mul}; + +trait MyNum : Add + Sub + Mul + PartialEq + Clone { } + +#[derive(Clone, Debug)] +struct MyInt { val: isize } + +impl Add for MyInt { + type Output = MyInt; + + fn add(self, other: MyInt) -> MyInt { mi(self.val + other.val) } +} + +impl Sub for MyInt { + type Output = MyInt; + + fn sub(self, other: MyInt) -> MyInt { mi(self.val - other.val) } +} + +impl Mul for MyInt { + type Output = MyInt; + + fn mul(self, other: MyInt) -> MyInt { mi(self.val * other.val) } +} + +impl PartialEq for MyInt { + fn eq(&self, other: &MyInt) -> bool { self.val == other.val } + fn ne(&self, other: &MyInt) -> bool { !self.eq(other) } +} + +impl MyNum for MyInt {} + +fn f(x: T, y: T) -> (T, T, T) { + return (x.clone() + y.clone(), x.clone() - y.clone(), x * y); +} + +fn mi(v: isize) -> MyInt { MyInt { val: v } } + +pub fn main() { + let (x, y) = (mi(3), mi(5)); + let (a, b, c) = f(x, y); + assert_eq!(a, mi(8)); + assert_eq!(b, mi(-2)); + assert_eq!(c, mi(15)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-overloading-simple.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-overloading-simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-overloading-simple.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-overloading-simple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +use std::cmp::PartialEq; + +trait MyNum : PartialEq { } + +#[derive(Debug)] +struct MyInt { val: isize } + +impl PartialEq for MyInt { + fn eq(&self, other: &MyInt) -> bool { self.val == other.val } + fn ne(&self, other: &MyInt) -> bool { !self.eq(other) } +} + +impl MyNum for MyInt {} + +fn f(x: T, y: T) -> bool { + return x == y; +} + +fn mi(v: isize) -> MyInt { MyInt { val: v } } + +pub fn main() { + let (x, y, z) = (mi(3), mi(5), mi(3)); + assert!(x != y); + assert_eq!(x, z); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-overloading-xc-exe.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-overloading-xc-exe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-overloading-xc-exe.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-overloading-xc-exe.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:trait_inheritance_overloading_xc.rs + + +extern crate trait_inheritance_overloading_xc; +use trait_inheritance_overloading_xc::{MyNum, MyInt}; + +fn f(x: T, y: T) -> (T, T, T) { + return (x.clone() + y.clone(), x.clone() - y.clone(), x * y); +} + +fn mi(v: isize) -> MyInt { MyInt { val: v } } + +pub fn main() { + let (x, y) = (mi(3), mi(5)); + let (a, b, c) = f(x, y); + assert_eq!(a, mi(8)); + assert_eq!(b, mi(-2)); + assert_eq!(c, mi(15)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-self-in-supertype.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-self-in-supertype.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-self-in-supertype.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-self-in-supertype.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,72 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test for issue #4183: use of Self in supertraits. + +pub static FUZZY_EPSILON: f64 = 0.1; + +pub trait FuzzyEq { + fn fuzzy_eq(&self, other: &Self) -> bool; + fn fuzzy_eq_eps(&self, other: &Self, epsilon: &Eps) -> bool; +} + +trait Float: Sized+FuzzyEq { + fn two_pi() -> Self; +} + +impl FuzzyEq for f32 { + fn fuzzy_eq(&self, other: &f32) -> bool { + self.fuzzy_eq_eps(other, &(FUZZY_EPSILON as f32)) + } + + fn fuzzy_eq_eps(&self, other: &f32, epsilon: &f32) -> bool { + (*self - *other).abs() < *epsilon + } +} + +impl Float for f32 { + fn two_pi() -> f32 { 6.28318530717958647692528676655900576_f32 } +} + +impl FuzzyEq for f64 { + fn fuzzy_eq(&self, other: &f64) -> bool { + self.fuzzy_eq_eps(other, &(FUZZY_EPSILON as f64)) + } + + fn fuzzy_eq_eps(&self, other: &f64, epsilon: &f64) -> bool { + (*self - *other).abs() < *epsilon + } +} + +impl Float for f64 { + fn two_pi() -> f64 { 6.28318530717958647692528676655900576_f64 } +} + +fn compare(f1: F) -> bool { + let f2 = Float::two_pi(); + f1.fuzzy_eq(&f2) +} + +pub fn main() { + assert!(compare::(6.28318530717958647692528676655900576)); + assert!(compare::(6.29)); + assert!(compare::(6.3)); + assert!(compare::(6.19)); + assert!(!compare::(7.28318530717958647692528676655900576)); + assert!(!compare::(6.18)); + + assert!(compare::(6.28318530717958647692528676655900576)); + assert!(compare::(6.29)); + assert!(compare::(6.3)); + assert!(compare::(6.19)); + assert!(!compare::(7.28318530717958647692528676655900576)); + assert!(!compare::(6.18)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-self.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-self.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-self.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait Foo { + fn f(&self, x: &T); +} + +trait Bar : Sized + Foo { + fn g(&self); +} + +struct S { + x: isize +} + +impl Foo for S { + fn f(&self, x: &S) { + println!("{}", x.x); + } +} + +impl Bar for S { + fn g(&self) { + self.f(self); + } +} + +pub fn main() { + let s = S { x: 1 }; + s.g(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-simple.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-simple.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-simple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +trait Foo { fn f(&self) -> isize; } +trait Bar : Foo { fn g(&self) -> isize; } + +struct A { x: isize } + +impl Foo for A { fn f(&self) -> isize { 10 } } +impl Bar for A { fn g(&self) -> isize { 20 } } + +fn ff(a: &T) -> isize { + a.f() +} + +fn gg(a: &T) -> isize { + a.g() +} + +pub fn main() { + let a = &A { x: 3 }; + assert_eq!(ff(a), 10); + assert_eq!(gg(a), 20); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-static2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-static2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-static2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-static2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +pub trait MyEq {} + +pub trait MyNum { + fn from_int(_: isize) -> Self; +} + +pub trait NumExt: MyEq + MyNum { } + +struct S { v: isize } + +impl MyEq for S { } + +impl MyNum for S { + fn from_int(i: isize) -> S { + S { + v: i + } + } +} + +impl NumExt for S { } + +fn greater_than_one() -> T { MyNum::from_int(1) } + +pub fn main() { + let v: S = greater_than_one(); + assert_eq!(v.v, 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-static.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-static.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-static.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-static.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub trait MyNum { + fn from_int(_: isize) -> Self; +} + +pub trait NumExt: MyNum { } + +struct S { v: isize } + +impl MyNum for S { + fn from_int(i: isize) -> S { + S { + v: i + } + } +} + +impl NumExt for S { } + +fn greater_than_one() -> T { MyNum::from_int(1) } + +pub fn main() { + let v: S = greater_than_one(); + assert_eq!(v.v, 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-subst2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-subst2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-subst2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-subst2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +trait Panda { + fn chomp(&self, bamboo: &T) -> T; +} + +trait Add: Panda { + fn add(&self, rhs: &RHS) -> Result; +} + +trait MyNum : Sized + Add { } + +struct MyInt { val: isize } + +impl Panda for MyInt { + fn chomp(&self, bamboo: &MyInt) -> MyInt { + mi(self.val + bamboo.val) + } +} + +impl Add for MyInt { + fn add(&self, other: &MyInt) -> MyInt { self.chomp(other) } +} + +impl MyNum for MyInt {} + +fn f(x: T, y: T) -> T { + return x.add(&y).chomp(&y); +} + +fn mi(v: isize) -> MyInt { MyInt { val: v } } + +pub fn main() { + let (x, y) = (mi(3), mi(5)); + let z = f(x, y); + assert_eq!(z.val, 13); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-subst.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-subst.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-subst.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-subst.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub trait Add { + fn add(&self, rhs: &RHS) -> Result; +} + +trait MyNum : Sized + Add { } + +struct MyInt { val: isize } + +impl Add for MyInt { + fn add(&self, other: &MyInt) -> MyInt { mi(self.val + other.val) } +} + +impl MyNum for MyInt {} + +fn f(x: T, y: T) -> T { + return x.add(&y); +} + +fn mi(v: isize) -> MyInt { MyInt { val: v } } + +pub fn main() { + let (x, y) = (mi(3), mi(5)); + let z = f(x, y); + assert_eq!(z.val, 8) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-visibility.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-visibility.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-visibility.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-inheritance-visibility.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +mod traits { + pub trait Foo { fn f(&self) -> isize; } + + impl Foo for isize { fn f(&self) -> isize { 10 } } +} + +trait Quux: traits::Foo { } +impl Quux for T { } + +// Foo is not in scope but because Quux is we can still access +// Foo's methods on a Quux bound typaram +fn f(x: &T) { + assert_eq!(x.f(), 10); +} + +pub fn main() { + f(&0) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-item-inside-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-item-inside-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-item-inside-macro.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-item-inside-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Issue #34183 + +macro_rules! foo { + () => { + fn foo() { } + } +} + +macro_rules! bar { + () => { + fn bar(); + } +} + +trait Bleh { + foo!(); + bar!(); +} + +struct Test; + +impl Bleh for Test { + fn bar() {} +} + +fn main() { + Test::bar(); + Test::foo(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-object-auto-dedup.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-object-auto-dedup.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-object-auto-dedup.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-object-auto-dedup.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,55 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_assignments)] +// Test that duplicate auto trait bounds in trait objects don't create new types. +#[allow(unused_assignments)] + +use std::marker::Send as SendAlias; + +// A dummy trait for the non-auto trait. +trait Trait {} + +// A dummy struct to implement Trait, Send, and . +struct Struct; + +impl Trait for Struct {} + +// These three functions should be equivalent. +fn takes_dyn_trait_send(_: Box) {} +fn takes_dyn_trait_send_send(_: Box) {} +fn takes_dyn_trait_send_sendalias(_: Box) {} + +impl dyn Trait + Send + Send { + fn do_nothing(&self) {} +} + +fn main() { + // 1. Moving into a variable with more Sends and back. + let mut dyn_trait_send = Box::new(Struct) as Box; + let dyn_trait_send_send: Box = dyn_trait_send; + dyn_trait_send = dyn_trait_send_send; + + // 2. Calling methods with different number of Sends. + let dyn_trait_send = Box::new(Struct) as Box; + takes_dyn_trait_send_send(dyn_trait_send); + + let dyn_trait_send_send = Box::new(Struct) as Box; + takes_dyn_trait_send(dyn_trait_send_send); + + // 3. Aliases to the trait are transparent. + let dyn_trait_send = Box::new(Struct) as Box; + takes_dyn_trait_send_sendalias(dyn_trait_send); + + // 4. Calling an impl that duplicates an auto trait. + let dyn_trait_send = Box::new(Struct) as Box; + dyn_trait_send.do_nothing(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-object-exclusion.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-object-exclusion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-object-exclusion.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-object-exclusion.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait Future: 'static { + // The requirement for Self: Sized must prevent instantiation of + // Future::forget in vtables, otherwise there's an infinite type + // recursion through as Future>::forget. + fn forget(self) where Self: Sized { + Box::new(Map(self)) as Box; + } +} + +struct Map(A); +impl Future for Map {} + +pub struct Promise; +impl Future for Promise {} + +fn main() { + Promise.forget(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-object-generics.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-object-generics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-object-generics.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-object-generics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,53 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// test for #8664 + +#![feature(box_syntax)] + +use std::marker; + +pub trait Trait2 { + fn doit(&self) -> A; +} + +pub struct Impl { + m1: marker::PhantomData<(A1,A2,A3)>, + /* + * With A2 we get the ICE: + * task failed at 'index out of bounds: the len is 1 but the index is 1', + * src/librustc/middle/subst.rs:58 + */ + t: Box+'static> +} + +impl Impl { + pub fn step(&self) { + self.t.doit(); + } +} + +// test for #8601 + +enum Type { Constant(T) } + +trait Trait { + fn method(&self, _: Type<(K,V)>) -> isize; +} + +impl Trait for () { + fn method(&self, _x: Type<(u8,V)>) -> isize { 0 } +} + +pub fn main() { + let a = box () as Box>; + assert_eq!(a.method(Type::Constant((1, 2))), 0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-object-lifetime-first.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-object-lifetime-first.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-object-lifetime-first.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-object-lifetime-first.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::fmt::Display; + +static BYTE: u8 = 33; + +fn main() { + let x: &('static + Display) = &BYTE; + let y: Box<'static + Display> = Box::new(BYTE); + let xstr = format!("{}", x); + let ystr = format!("{}", y); + assert_eq!(xstr, "33"); + assert_eq!(ystr, "33"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-object-with-lifetime-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-object-with-lifetime-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-object-with-lifetime-bound.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-object-with-lifetime-bound.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Uncovered during work on new scoping rules for safe destructors +// as an important use case to support properly. + + +pub struct E<'a> { + pub f: &'a u8, +} +impl<'b> E<'b> { + pub fn m(&self) -> &'b u8 { self.f } +} + +pub struct P<'c> { + pub g: &'c u8, +} +pub trait M { + fn n(&self) -> u8; +} +impl<'d> M for P<'d> { + fn n(&self) -> u8 { *self.g } +} + +fn extension<'e>(x: &'e E<'e>) -> Box { + loop { + let p = P { g: x.m() }; + return Box::new(p) as Box; + } +} + +fn main() { + let w = E { f: &10 }; + let o = extension(&w); + assert_eq!(o.n(), 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-region-pointer-simple.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-region-pointer-simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-region-pointer-simple.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-region-pointer-simple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait Foo { + fn f(&self) -> isize; +} + +struct A { + x: isize +} + +impl Foo for A { + fn f(&self) -> isize { + println!("Today's number is {}", self.x); + return self.x; + } +} + +pub fn main() { + let a = A { x: 3 }; + let b = (&a) as &Foo; + assert_eq!(b.f(), 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-safety-ok-cc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-safety-ok-cc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-safety-ok-cc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-safety-ok-cc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:trait_safety_lib.rs + +// Simple smoke test that unsafe traits can be compiled across crates. + + +extern crate trait_safety_lib as lib; + +use lib::Foo; + +struct Bar { x: isize } +unsafe impl Foo for Bar { + fn foo(&self) -> isize { self.x } +} + +fn take_foo(f: &F) -> isize { f.foo() } + +fn main() { + let x: isize = 22; + assert_eq!(22, take_foo(&x)); + + let x: Bar = Bar { x: 23 }; + assert_eq!(23, take_foo(&x)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-safety-ok.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-safety-ok.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-safety-ok.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-safety-ok.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Simple smoke test that unsafe traits can be compiled etc. + + +unsafe trait Foo { + fn foo(&self) -> isize; +} + +unsafe impl Foo for isize { + fn foo(&self) -> isize { *self } +} + +fn take_foo(f: &F) -> isize { f.foo() } + +fn main() { + let x: isize = 22; + assert_eq!(22, take_foo(&x)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-assoc-type-in-supertrait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-assoc-type-in-supertrait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-assoc-type-in-supertrait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-assoc-type-in-supertrait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test case where an associated type is referenced from within the +// supertrait definition. Issue #20220. + + +use std::vec::IntoIter; + +pub trait Foo: Iterator::Key> { + type Key; +} + +impl Foo for IntoIter { + type Key = i32; +} + +fn sum_foo>(f: F) -> i32 { + f.fold(0, |a,b| a + b) +} + +fn main() { + let x = sum_foo(vec![11, 10, 1].into_iter()); + assert_eq!(x, 22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-conditional-dispatch.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-conditional-dispatch.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-conditional-dispatch.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-conditional-dispatch.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we are able to resolve conditional dispatch. Here, the +// blanket impl for T:Copy coexists with an impl for Box, because +// Box does not impl Copy. + +#![feature(box_syntax)] + +trait Get { + fn get(&self) -> Self; +} + +trait MyCopy { fn copy(&self) -> Self; } +impl MyCopy for u16 { fn copy(&self) -> Self { *self } } +impl MyCopy for u32 { fn copy(&self) -> Self { *self } } +impl MyCopy for i32 { fn copy(&self) -> Self { *self } } +impl MyCopy for Option { fn copy(&self) -> Self { *self } } + +impl Get for T { + fn get(&self) -> T { self.copy() } +} + +impl Get for Box { + fn get(&self) -> Box { box get_it(&**self) } +} + +fn get_it(t: &T) -> T { + (*t).get() +} + +fn main() { + assert_eq!(get_it(&1_u32), 1_u32); + assert_eq!(get_it(&1_u16), 1_u16); + assert_eq!(get_it(&Some(1_u16)), Some(1_u16)); + assert_eq!(get_it(&Box::new(1)), Box::new(1)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-conditional-model-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-conditional-model-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-conditional-model-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-conditional-model-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,70 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +// A model for how the `Fn` traits could work. You can implement at +// most one of `Go`, `GoMut`, or `GoOnce`, and then the others follow +// automatically. + +// aux-build:go_trait.rs + + +extern crate go_trait; + +use go_trait::{Go, GoMut, GoOnce, go, go_mut, go_once}; + +use std::rc::Rc; +use std::cell::Cell; + +/////////////////////////////////////////////////////////////////////////// + +struct SomeGoableThing { + counter: Rc> +} + +impl Go for SomeGoableThing { + fn go(&self, arg: isize) { + self.counter.set(self.counter.get() + arg); + } +} + +/////////////////////////////////////////////////////////////////////////// + +struct SomeGoOnceableThing { + counter: Rc> +} + +impl GoOnce for SomeGoOnceableThing { + fn go_once(self, arg: isize) { + self.counter.set(self.counter.get() + arg); + } +} + +/////////////////////////////////////////////////////////////////////////// + +fn main() { + let counter = Rc::new(Cell::new(0)); + let mut x = SomeGoableThing { counter: counter.clone() }; + + go(&x, 10); + assert_eq!(counter.get(), 10); + + go_mut(&mut x, 100); + assert_eq!(counter.get(), 110); + + go_once(x, 1_000); + assert_eq!(counter.get(), 1_110); + + let x = SomeGoOnceableThing { counter: counter.clone() }; + + go_once(x, 10_000); + assert_eq!(counter.get(), 11_110); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-default-method-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-default-method-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-default-method-macro.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-default-method-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +trait Foo { + fn bar(&self) -> String { + format!("test") + } +} + +enum Baz { + Quux +} + +impl Foo for Baz { +} + +pub fn main() { + let q = Baz::Quux; + assert_eq!(q.bar(), "test".to_string()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-default-method-mut.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-default-method-mut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-default-method-mut.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-default-method-mut.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_assignments)] +// pretty-expanded FIXME #23616 + +#![allow(unused_variables)] + +trait Foo { + fn foo(&self, mut v: isize) { v = 1; } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-default-method-self.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-default-method-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-default-method-self.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-default-method-self.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +trait Cat { + fn meow(&self) -> bool; + fn scratch(&self) -> bool { self.purr() } + fn purr(&self) -> bool { true } +} + +impl Cat for isize { + fn meow(&self) -> bool { + self.scratch() + } +} + +pub fn main() { + assert!(5.meow()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-default-method-trivial.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-default-method-trivial.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-default-method-trivial.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-default-method-trivial.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + + +trait Cat { + fn meow(&self) -> bool; + fn scratch(&self) -> bool; + fn purr(&self) -> bool { true } +} + +impl Cat for isize { + fn meow(&self) -> bool { + self.scratch() + } + fn scratch(&self) -> bool { + self.purr() + } +} + +pub fn main() { + assert!(5.meow()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-elaborate-type-region.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-elaborate-type-region.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-elaborate-type-region.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-elaborate-type-region.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,59 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +// Test that we elaborate `Type: 'region` constraints and infer various important things. + +trait Master<'a, T: ?Sized> { + fn foo() where T: 'a; +} + +// [U]: 'a => U: 'a +impl<'a, U> Master<'a, [U]> for () { + fn foo() where U: 'a { } +} + +// &'b U: 'a => 'b: 'a, U: 'a +impl<'a, 'b, U> Master<'a, &'b U> for () { + fn foo() where 'b: 'a, U: 'a { } +} + +// &'b [U]: 'a => 'b: 'a, U: 'a +impl<'a, 'b, U> Master<'a, &'b [U]> for () { + fn foo() where 'b: 'a, U: 'a { } +} + +// Foo<'b>: 'a => 'b: 'a +struct Foo<'a> { x: &'a () } +impl<'a, 'b> Master<'a, Foo<'b>> for () { + fn foo() where 'b: 'a { } +} + +// Bar<'b, T>: 'a => 'b: 'a, T: 'a +struct Bar<'a, T: 'a> { x: &'a T } +impl<'a, 'b, T> Master<'a, Bar<'b, T>> for () { + fn foo() where 'b: 'a, T: 'a { } +} + +// fn(T): 'a => T: 'a +impl<'a, T> Master<'a, fn(T)> for () { + fn foo() where T: 'a { } +} + +// fn() -> T: 'a => T: 'a +impl<'a, T> Master<'a, fn() -> T> for () { + fn foo() where T: 'a { } +} + +fn main() { + println!("Hello, world!"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-impl-object-overlap-issue-23853.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-impl-object-overlap-issue-23853.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-impl-object-overlap-issue-23853.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-impl-object-overlap-issue-23853.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we are able to compile the case where both a blanket impl +// and the object type itself supply the required trait obligation. +// In this case, the blanket impl for `Foo` applies to any type, +// including `Bar`, but the object type `Bar` also implicitly supplies +// this context. + +trait Foo { fn dummy(&self) { } } + +trait Bar: Foo { } + +impl Foo for T { } + +fn want_foo() { } + +fn main() { + want_foo::(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-issue-22019.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-issue-22019.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-issue-22019.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-issue-22019.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test an issue where global caching was causing free regions from +// distinct scopes to be compared (`'g` and `'h`). The only important +// thing is that compilation succeeds here. + +// pretty-expanded FIXME #23616 + +#![allow(missing_copy_implementations)] +#![allow(unused_variables)] + +use std::borrow::ToOwned; + +pub struct CFGNode; + +pub type Node<'a> = &'a CFGNode; + +pub trait GraphWalk<'c, N> { + /// Returns all the nodes in this graph. + fn nodes(&'c self) where [N]:ToOwned>; +} + +impl<'g> GraphWalk<'g, Node<'g>> for u32 +{ + fn nodes(&'g self) where [Node<'g>]:ToOwned>> + { loop { } } +} + +impl<'h> GraphWalk<'h, Node<'h>> for u64 +{ + fn nodes(&'h self) where [Node<'h>]:ToOwned>> + { loop { } } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-issue-22110.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-issue-22110.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-issue-22110.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-issue-22110.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test an issue where we reported ambiguity between the where-clause +// and the blanket impl. The only important thing is that compilation +// succeeds here. Issue #22110. + +// pretty-expanded FIXME #23616 + +#![allow(dead_code)] + +trait Foo { + fn foo(&self, a: A); +} + +impl Foo for F { + fn foo(&self, _: A) { } +} + +fn baz Foo<(&'a A,)>>(_: F) { } + +fn components(t: fn(&A)) + where fn(&A) : for<'a> Foo<(&'a A,)>, +{ + baz(t) +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-issue-22655.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-issue-22655.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-issue-22655.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-issue-22655.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Regression test for issue #22655: This test should not lead to +// infinite recursion. + +// pretty-expanded FIXME #23616 + +unsafe impl Send for Unique { } + +pub struct Unique { + pointer: *const T, +} + +pub struct Node { + vals: V, + edges: Unique>, +} + +fn is_send() {} + +fn main() { + is_send::>(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-issue-23003.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-issue-23003.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-issue-23003.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-issue-23003.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test stack overflow triggered by evaluating the implications. To be +// WF, the type `Receipt` would require that `::Cancel` be WF. This normalizes to `Receipt` +// again, leading to an infinite cycle. Issue #23003. + +// pretty-expanded FIXME #23616 + +#![allow(dead_code)] +#![allow(unused_variables)] + +use std::marker::PhantomData; + +trait Async { + type Cancel; +} + +struct Receipt { + marker: PhantomData, +} + +struct Complete { + core: Option<()>, +} + +impl Async for Complete { + type Cancel = Receipt; +} + +fn foo(r: Receipt) { } + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-issue-26339.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-issue-26339.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-issue-26339.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-issue-26339.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that the right implementation is called through a trait +// object when supertraits include multiple references to the +// same trait, with different type parameters. + +trait A: PartialEq + PartialEq { } + +struct Foo; +struct Bar; + +struct Aimpl; + +impl PartialEq for Aimpl { + fn eq(&self, _rhs: &Foo) -> bool { + true + } +} + +impl PartialEq for Aimpl { + fn eq(&self, _rhs: &Bar) -> bool { + false + } +} + +impl A for Aimpl { } + +fn main() { + let a = &Aimpl as &A; + + assert!(*a == Foo); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-multidispatch-infer-convert-target.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-multidispatch-infer-convert-target.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-multidispatch-infer-convert-target.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-multidispatch-infer-convert-target.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we can infer the Target based on the Self or vice versa. + + +use std::mem; + +trait Convert { + fn convert(&self) -> Target; +} + +impl Convert for i16 { + fn convert(&self) -> u32 { + *self as u32 + } +} + +impl Convert for u32 { + fn convert(&self) -> i16 { + *self as i16 + } +} + +fn test(_: T, _: U, t_size: usize, u_size: usize) +where T : Convert +{ + assert_eq!(mem::size_of::(), t_size); + assert_eq!(mem::size_of::(), u_size); +} + +fn main() { + use std::default::Default; + // T = i16, U = u32 + test(22_i16, Default::default(), 2, 4); + + // T = u32, U = i16 + test(22_u32, Default::default(), 4, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-negative-impls.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-negative-impls.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-negative-impls.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-negative-impls.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +#![feature(optin_builtin_traits)] + +use std::marker::Send; + +pub struct WaitToken; +impl !Send for WaitToken {} + +pub struct Test(T); +unsafe impl Send for Test {} + +pub fn spawn(_: F) -> () where F: FnOnce(), F: Send + 'static {} + +fn main() { + let wt = Test(WaitToken); + spawn(move || { + let x = wt; + println!("Hello, World!"); + }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-repeated-supertrait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-repeated-supertrait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/traits-repeated-supertrait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/traits-repeated-supertrait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,58 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test a case of a trait which extends the same supertrait twice, but +// with difference type parameters. Test that we can invoke the +// various methods in various ways successfully. +// See also `compile-fail/trait-repeated-supertrait-ambig.rs`. + + +trait CompareTo { + fn same_as(&self, t: T) -> bool; +} + +trait CompareToInts : CompareTo + CompareTo { +} + +impl CompareTo for i64 { + fn same_as(&self, t: i64) -> bool { *self == t } +} + +impl CompareTo for i64 { + fn same_as(&self, t: u64) -> bool { *self == (t as i64) } +} + +impl CompareToInts for i64 { } + +fn with_obj(c: &CompareToInts) -> bool { + c.same_as(22_i64) && c.same_as(22_u64) +} + +fn with_trait(c: &C) -> bool { + c.same_as(22_i64) && c.same_as(22_u64) +} + +fn with_ufcs1(c: &C) -> bool { + CompareToInts::same_as(c, 22_i64) && CompareToInts::same_as(c, 22_u64) +} + +fn with_ufcs2(c: &C) -> bool { + CompareTo::same_as(c, 22_i64) && CompareTo::same_as(c, 22_u64) +} + +fn main() { + assert_eq!(22_i64.same_as(22_i64), true); + assert_eq!(22_i64.same_as(22_u64), true); + assert_eq!(with_trait(&22), true); + assert_eq!(with_obj(&22), true); + assert_eq!(with_ufcs1(&22), true); + assert_eq!(with_ufcs2(&22), true); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-static-method-overwriting.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-static-method-overwriting.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-static-method-overwriting.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-static-method-overwriting.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +mod base { + pub trait HasNew { + fn new() -> Self; + } + + pub struct Foo { + dummy: (), + } + + impl ::base::HasNew for Foo { + fn new() -> Foo { + println!("Foo"); + Foo { dummy: () } + } + } + + pub struct Bar { + dummy: (), + } + + impl ::base::HasNew for Bar { + fn new() -> Bar { + println!("Bar"); + Bar { dummy: () } + } + } +} + +pub fn main() { + let _f: base::Foo = base::HasNew::new(); + let _b: base::Bar = base::HasNew::new(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-to-str.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-to-str.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-to-str.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-to-str.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + + +trait to_str { + fn to_string_(&self) -> String; +} + +impl to_str for isize { + fn to_string_(&self) -> String { self.to_string() } +} + +impl to_str for Vec { + fn to_string_(&self) -> String { + format!("[{}]", + self.iter() + .map(|e| e.to_string_()) + .collect::>() + .join(", ")) + } +} + +pub fn main() { + assert_eq!(1.to_string_(), "1".to_string()); + assert_eq!((vec![2, 3, 4]).to_string_(), "[2, 3, 4]".to_string()); + + fn indirect(x: T) -> String { + format!("{}!", x.to_string_()) + } + assert_eq!(indirect(vec![10, 20]), "[10, 20]!".to_string()); + + fn indirect2(x: T) -> String { + indirect(x) + } + assert_eq!(indirect2(vec![1]), "[1]!".to_string()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-where-clause-vs-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-where-clause-vs-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-where-clause-vs-impl.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-where-clause-vs-impl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,55 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// Test that when there is a conditional (but blanket) impl and a +// where clause, we don't get confused in trait resolution. +// +// Issue #18453. + +// pretty-expanded FIXME #23616 + +use std::rc::Rc; + +pub trait Foo { + fn foo(&mut self, msg: M); +} + +pub trait Bar { + fn dummy(&self) -> M; +} + +impl> Foo for F { + fn foo(&mut self, msg: M) { + } +} + +pub struct Both { + inner: Rc<(M, F)>, +} + +impl> Clone for Both { + fn clone(&self) -> Both { + Both { inner: self.inner.clone() } + } +} + +fn repro1>(_both: Both) { +} + +fn repro2>(msg: M, foo: F) { + let both = Both { inner: Rc::new((msg, foo)) }; + repro1(both.clone()); // <--- This clone causes problem +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-with-bounds-default.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-with-bounds-default.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/trait-with-bounds-default.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/trait-with-bounds-default.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +pub trait Clone2 { + /// Returns a copy of the value. The contents of boxes + /// are copied to maintain uniqueness, while the contents of + /// managed pointers are not copied. + fn clone(&self) -> Self; +} + +trait Getter { + fn do_get(&self) -> T; + + fn do_get2(&self) -> (T, T) { + let x = self.do_get(); + (x.clone(), x.clone()) + } + +} + +impl Getter for isize { + fn do_get(&self) -> isize { *self } +} + +impl Getter for Option { + fn do_get(&self) -> T { self.as_ref().unwrap().clone() } +} + + +pub fn main() { + assert_eq!(3.do_get2(), (3, 3)); + assert_eq!(Some("hi".to_string()).do_get2(), ("hi".to_string(), "hi".to_string())); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/ufcs-trait-object.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/ufcs-trait-object.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/ufcs-trait-object.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/ufcs-trait-object.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that when you use ufcs form to invoke a trait method (on a +// trait object) everything works fine. + + +trait Foo { + fn test(&self) -> i32; +} + +impl Foo for i32 { + fn test(&self) -> i32 { *self } +} + +fn main() { + let a: &Foo = &22; + assert_eq!(Foo::test(a), 22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/use-trait-before-def.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/use-trait-before-def.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/traits/use-trait-before-def.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/traits/use-trait-before-def.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +// Issue #1761 + +// pretty-expanded FIXME #23616 + +impl foo for isize { fn foo(&self) -> isize { 10 } } +trait foo { fn foo(&self) -> isize; } +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/trivial-message.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/trivial-message.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/trivial-message.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/trivial-message.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_must_use)] /* This is about the simplest program that can successfully send a message. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/try-block.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/try-block.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/try-block.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/try-block.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(dead_code)] // compile-flags: --edition 2018 #![feature(try_blocks)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/try-is-identifier-edition2015.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/try-is-identifier-edition2015.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/try-is-identifier-edition2015.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/try-is-identifier-edition2015.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] // compile-flags: --edition 2015 fn main() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/try-operator-hygiene.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/try-operator-hygiene.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/try-operator-hygiene.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/try-operator-hygiene.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_upper_case_globals)] +#![allow(dead_code)] // `expr?` expands to: // // match expr { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/try-operator.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/try-operator.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/try-operator.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/try-operator.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // ignore-cloudabi no std::fs use std::fs::File; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/try-wait.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/try-wait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/try-wait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/try-wait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(stable_features)] // ignore-cloudabi no processes // ignore-emscripten no processes diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/tup.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/tup.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/tup.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/tup.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] type point = (isize, isize); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/tydesc-name.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/tydesc-name.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/tydesc-name.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/tydesc-name.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] #![feature(core_intrinsics)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/type-ascription.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/type-ascription.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/type-ascription.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/type-ascription.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] +#![allow(unused_variables)] // Type ascription doesn't lead to unsoundness #![feature(type_ascription)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/typeck_type_placeholder_1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/typeck_type_placeholder_1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/typeck_type_placeholder_1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/typeck_type_placeholder_1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // This test checks that the `_` type placeholder works // correctly for enabling type inference. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/typeclasses-eq-example.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/typeclasses-eq-example.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/typeclasses-eq-example.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/typeclasses-eq-example.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(dead_code)] #![feature(box_syntax)] // Example from lkuper's intern talk, August 2012. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/typeclasses-eq-example-static.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/typeclasses-eq-example-static.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/typeclasses-eq-example-static.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/typeclasses-eq-example-static.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +#![allow(dead_code)] #![feature(box_syntax)] // Example from lkuper's intern talk, August 2012 -- now with static diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/typeid-intrinsic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/typeid-intrinsic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/typeid-intrinsic.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/typeid-intrinsic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(deprecated)] // aux-build:typeid-intrinsic-aux1.rs // aux-build:typeid-intrinsic-aux2.rs diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/type-infer-generalize-ty-var.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/type-infer-generalize-ty-var.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/type-infer-generalize-ty-var.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/type-infer-generalize-ty-var.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_upper_case_globals)] +#![allow(dead_code)] +#![allow(unused_assignments)] +#![allow(unused_variables)] // Test a scenario where we generate a constraint like `?1 <: &?2`. // In such a case, it is important that we instantiate `?1` with `&?3` // where `?3 <: ?2`, and not with `&?2`. This is a regression test for diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/type-in-nested-module.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/type-in-nested-module.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/type-in-nested-module.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/type-in-nested-module.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(dead_code)] // pretty-expanded FIXME #23616 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/type-param-constraints.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/type-param-constraints.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/type-param-constraints.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/type-param-constraints.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(dead_code)] // pretty-expanded FIXME #23616 #![feature(box_syntax)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/type-param.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/type-param.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/type-param.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/type-param.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(dead_code)] // pretty-expanded FIXME #23616 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/type-params-in-for-each.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/type-params-in-for-each.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/type-params-in-for-each.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/type-params-in-for-each.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // pretty-expanded FIXME #23616 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/type-ptr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/type-ptr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/type-ptr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/type-ptr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // pretty-expanded FIXME #23616 fn f(a: *const isize) -> *const isize { return a; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/type-sizes.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/type-sizes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/type-sizes.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/type-sizes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(dead_code)] #![feature(never_type)] use std::mem::size_of; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/typestate-cfg-nesting.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/typestate-cfg-nesting.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/typestate-cfg-nesting.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/typestate-cfg-nesting.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] +#![allow(unused_assignments)] +#![allow(unknown_lints)] // pretty-expanded FIXME #23616 #![allow(dead_assignment)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/auxiliary/unboxed-closures-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/auxiliary/unboxed-closures-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/auxiliary/unboxed-closures-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/auxiliary/unboxed-closures-cross-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::ops::Add; + +#[inline] +pub fn has_closures() -> usize { + let x = 1; + let mut f = move || x; + let y = 1; + let g = || y; + f() + g() +} + +pub fn has_generic_closures + Copy>(x: T, y: T) -> T { + let mut f = move || x; + let g = || y; + f() + g() +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-all-traits.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-all-traits.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-all-traits.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-all-traits.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(lang_items)] + +fn a isize>(f: F) -> isize { + f(1, 2) +} + +fn b isize>(mut f: F) -> isize { + f(3, 4) +} + +fn c isize>(f: F) -> isize { + f(5, 6) +} + +fn main() { + let z: isize = 7; + assert_eq!(a(move |x: isize, y| x + y + z), 10); + assert_eq!(b(move |x: isize, y| x + y + z), 14); + assert_eq!(c(move |x: isize, y| x + y + z), 18); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn-mut.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn-mut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn-mut.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn-mut.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// Test that you can supply `&F` where `F: FnMut()`. + +#![feature(lang_items)] + +fn a i32>(mut f: F) -> i32 { + f() +} + +fn b(f: &mut FnMut() -> i32) -> i32 { + a(f) +} + +fn c i32>(f: &mut F) -> i32 { + a(f) +} + +fn main() { + let z: isize = 7; + + let x = b(&mut || 22); + assert_eq!(x, 22); + + let x = c(&mut || 22); + assert_eq!(x, 22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-blanket-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// Test that you can supply `&F` where `F: Fn()`. + +#![feature(lang_items)] + +fn a i32>(f: F) -> i32 { + f() +} + +fn b(f: &Fn() -> i32) -> i32 { + a(f) +} + +fn c i32>(f: &F) -> i32 { + a(f) +} + +fn main() { + let z: isize = 7; + + let x = b(&|| 22); + assert_eq!(x, 22); + + let x = c(&|| 22); + assert_eq!(x, 22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-boxed.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-boxed.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-boxed.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-boxed.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +use std::ops::FnMut; + + fn make_adder(x: i32) -> Boxi32+'static> { + (box move |y: i32| -> i32 { x + y }) as + Boxi32+'static> +} + +pub fn main() { + let mut adder = make_adder(3); + let z = adder(2); + println!("{}", z); + assert_eq!(z, 5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-by-ref.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-by-ref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-by-ref.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-by-ref.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test by-ref capture of environment in unboxed closure types + +fn call_fn(f: F) { + f() +} + +fn call_fn_mut(mut f: F) { + f() +} + +fn call_fn_once(f: F) { + f() +} + +fn main() { + let mut x = 0_usize; + let y = 2_usize; + + call_fn(|| assert_eq!(x, 0)); + call_fn_mut(|| x += y); + call_fn_once(|| x += y); + assert_eq!(x, y * 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-call-fn-autoderef.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-call-fn-autoderef.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-call-fn-autoderef.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-call-fn-autoderef.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +// Test that the call operator autoderefs when calling a bounded type parameter. + +use std::ops::FnMut; + +fn call_with_2(x: &fn(isize) -> isize) -> isize +{ + x(2) // look ma, no `*` +} + +fn subtract_22(x: isize) -> isize { x - 22 } + +pub fn main() { + let subtract_22: fn(isize) -> isize = subtract_22; + let z = call_with_2(&subtract_22); + assert_eq!(z, -20); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-autoderef.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-autoderef.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-autoderef.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-autoderef.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that the call operator autoderefs when calling a bounded type parameter. + +use std::ops::FnMut; + +fn call_with_2(x: &mut F) -> isize + where F : FnMut(isize) -> isize +{ + x(2) // look ma, no `*` +} + +pub fn main() { + let z = call_with_2(&mut |x| x - 22); + assert_eq!(z, -20); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object-autoderef.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object-autoderef.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object-autoderef.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object-autoderef.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that the call operator autoderefs when calling to an object type. + +use std::ops::FnMut; + +fn make_adder(x: isize) -> Boxisize + 'static> { + Box::new(move |y| { x + y }) +} + +pub fn main() { + let mut adder = make_adder(3); + let z = adder(2); + println!("{}", z); + assert_eq!(z, 5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-call-sugar-object.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::ops::FnMut; + +fn make_adder(x: isize) -> Boxisize + 'static> { + Box::new(move |y| { x + y }) +} + +pub fn main() { + let mut adder = make_adder(3); + let z = (*adder)(2); + println!("{}", z); + assert_eq!(z, 5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-counter-not-moved.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-counter-not-moved.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-counter-not-moved.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-counter-not-moved.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// Test that we mutate a counter on the stack only when we expect to. + +fn call(f: F) where F : FnOnce() { + f(); +} + +fn main() { + let y = vec![format!("Hello"), format!("World")]; + let mut counter = 22_u32; + + call(|| { + // Move `y`, but do not move `counter`, even though it is read + // by value (note that it is also mutated). + for item in y { + let v = counter; + counter += v; + } + }); + assert_eq!(counter, 88); + + call(move || { + // this mutates a moved copy, and hence doesn't affect original + counter += 1; + }); + assert_eq!(counter, 88); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-cross-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +// Test that unboxed closures work with cross-crate inlining +// Acts as a regression test for #16790, #18378 and #18543 + +// aux-build:unboxed-closures-cross-crate.rs + +extern crate unboxed_closures_cross_crate as ubcc; + +fn main() { + assert_eq!(ubcc::has_closures(), 2_usize); + assert_eq!(ubcc::has_generic_closures(2_usize, 3_usize), 5_usize); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-direct-sugary-call.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-direct-sugary-call.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-direct-sugary-call.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-direct-sugary-call.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +// pretty-expanded FIXME #23616 + +fn main() { + let mut unboxed = || {}; + unboxed(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-drop.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-drop.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-drop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,127 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(path_statements)] +#![allow(dead_code)] +// A battery of tests to ensure destructors of unboxed closure environments +// run at the right times. + +static mut DROP_COUNT: usize = 0; + +fn drop_count() -> usize { + unsafe { + DROP_COUNT + } +} + +struct Droppable { + x: isize, +} + +impl Droppable { + fn new() -> Droppable { + Droppable { + x: 1 + } + } +} + +impl Drop for Droppable { + fn drop(&mut self) { + unsafe { + DROP_COUNT += 1 + } + } +} + +fn a isize>(f: F) -> isize { + f(1, 2) +} + +fn b isize>(mut f: F) -> isize { + f(3, 4) +} + +fn c isize>(f: F) -> isize { + f(5, 6) +} + +fn test_fn() { + { + a(move |a: isize, b| { a + b }); + } + assert_eq!(drop_count(), 0); + + { + let z = &Droppable::new(); + a(move |a: isize, b| { z; a + b }); + assert_eq!(drop_count(), 0); + } + assert_eq!(drop_count(), 1); + + { + let z = &Droppable::new(); + let zz = &Droppable::new(); + a(move |a: isize, b| { z; zz; a + b }); + assert_eq!(drop_count(), 1); + } + assert_eq!(drop_count(), 3); +} + +fn test_fn_mut() { + { + b(move |a: isize, b| { a + b }); + } + assert_eq!(drop_count(), 3); + + { + let z = &Droppable::new(); + b(move |a: isize, b| { z; a + b }); + assert_eq!(drop_count(), 3); + } + assert_eq!(drop_count(), 4); + + { + let z = &Droppable::new(); + let zz = &Droppable::new(); + b(move |a: isize, b| { z; zz; a + b }); + assert_eq!(drop_count(), 4); + } + assert_eq!(drop_count(), 6); +} + +fn test_fn_once() { + { + c(move |a: isize, b| { a + b }); + } + assert_eq!(drop_count(), 6); + + { + let z = Droppable::new(); + c(move |a: isize, b| { z; a + b }); + assert_eq!(drop_count(), 7); + } + assert_eq!(drop_count(), 7); + + { + let z = Droppable::new(); + let zz = Droppable::new(); + c(move |a: isize, b| { z; zz; a + b }); + assert_eq!(drop_count(), 9); + } + assert_eq!(drop_count(), 9); +} + +fn main() { + test_fn(); + test_fn_mut(); + test_fn_once(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-extern-fn-hr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-extern-fn-hr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-extern-fn-hr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-extern-fn-hr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Checks that higher-ranked extern fn pointers implement the full range of Fn traits. + +fn square(x: &isize) -> isize { (*x) * (*x) } + +fn call_itisize>(f: &F, x: isize) -> isize { + (*f)(&x) +} + +fn call_it_boxed(f: &Fn(&isize) -> isize, x: isize) -> isize { + f(&x) +} + +fn call_it_mutisize>(f: &mut F, x: isize) -> isize { + (*f)(&x) +} + +fn call_it_onceisize>(f: F, x: isize) -> isize { + f(&x) +} + +fn main() { + let x = call_it(&square, 22); + let x1 = call_it_boxed(&square, 22); + let y = call_it_mut(&mut square, 22); + let z = call_it_once(square, 22); + assert_eq!(x, square(&22)); + assert_eq!(x1, square(&22)); + assert_eq!(y, square(&22)); + assert_eq!(z, square(&22)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-extern-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-extern-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-extern-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-extern-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Checks that extern fn pointers implement the full range of Fn traits. + +use std::ops::{Fn,FnMut,FnOnce}; + +fn square(x: isize) -> isize { x * x } + +fn call_itisize>(f: &F, x: isize) -> isize { + f(x) +} + +fn call_it_mutisize>(f: &mut F, x: isize) -> isize { + f(x) +} + +fn call_it_onceisize>(f: F, x: isize) -> isize { + f(x) +} + +fn main() { + let x = call_it(&square, 22); + let y = call_it_mut(&mut square, 22); + let z = call_it_once(square, 22); + assert_eq!(x, square(22)); + assert_eq!(y, square(22)); + assert_eq!(z, square(22)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-fn-as-fnmut-and-fnonce.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-fn-as-fnmut-and-fnonce.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-fn-as-fnmut-and-fnonce.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-fn-as-fnmut-and-fnonce.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,54 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Checks that the Fn trait hierarchy rules permit +// any Fn trait to be used where Fn is implemented. + +#![feature(unboxed_closures, fn_traits)] + +use std::ops::{Fn,FnMut,FnOnce}; + +struct S; + +impl Fn<(i32,)> for S { + extern "rust-call" fn call(&self, (x,): (i32,)) -> i32 { + x * x + } +} + +impl FnMut<(i32,)> for S { + extern "rust-call" fn call_mut(&mut self, args: (i32,)) -> i32 { self.call(args) } +} + +impl FnOnce<(i32,)> for S { + type Output = i32; + extern "rust-call" fn call_once(self, args: (i32,)) -> i32 { self.call(args) } +} + +fn call_iti32>(f: &F, x: i32) -> i32 { + f(x) +} + +fn call_it_muti32>(f: &mut F, x: i32) -> i32 { + f(x) +} + +fn call_it_oncei32>(f: F, x: i32) -> i32 { + f(x) +} + +fn main() { + let x = call_it(&S, 22); + let y = call_it_mut(&mut S, 22); + let z = call_it_once(S, 22); + assert_eq!(x, y); + assert_eq!(y, z); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-fnmut-as-fnonce.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-fnmut-as-fnonce.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-fnmut-as-fnonce.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-fnmut-as-fnonce.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Checks that the Fn trait hierarchy rules permit +// FnMut or FnOnce to be used where FnMut is implemented. + +#![feature(unboxed_closures, fn_traits)] + +struct S; + +impl FnMut<(i32,)> for S { + extern "rust-call" fn call_mut(&mut self, (x,): (i32,)) -> i32 { + x * x + } +} + +impl FnOnce<(i32,)> for S { + type Output = i32; + + extern "rust-call" fn call_once(mut self, args: (i32,)) -> i32 { self.call_mut(args) } +} + +fn call_it_muti32>(f: &mut F, x: i32) -> i32 { + f(x) +} + +fn call_it_oncei32>(f: F, x: i32) -> i32 { + f(x) +} + +fn main() { + let y = call_it_mut(&mut S, 22); + let z = call_it_once(S, 22); + assert_eq!(y, z); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-generic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-generic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-generic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-generic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::ops::FnMut; + +fn call_iti32>(y: i32, mut f: F) -> i32 { + f(2, y) +} + +pub fn main() { + let f = |x: i32, y: i32| -> i32 { x + y }; + let z = call_it(3, f); + println!("{}", z); + assert_eq!(z, 5); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-bound.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-bound.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we are able to infer that the type of `x` is `isize` based +// on the expected type from the object. + +// pretty-expanded FIXME #23616 + +pub trait ToPrimitive { + fn to_int(&self) {} +} + +impl ToPrimitive for isize {} +impl ToPrimitive for i32 {} +impl ToPrimitive for usize {} + +fn doit(val: T, f: &F) + where F : Fn(T) +{ + f(val) +} + +pub fn main() { + doit(0, &|x /*: isize*/ | { x.to_int(); }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we are able to infer that the type of `x` is `isize` based +// on the expected type from the object. + +// pretty-expanded FIXME #23616 + +pub trait ToPrimitive { + fn to_int(&self) {} +} + +impl ToPrimitive for isize {} +impl ToPrimitive for i32 {} +impl ToPrimitive for usize {} + +fn doit(val: T, f: &Fn(T)) { f(val) } + +pub fn main() { + doit(0, &|x /*: isize*/ | { x.to_int(); }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-w-bound-regs-from-expected-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-w-bound-regs-from-expected-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-w-bound-regs-from-expected-bound.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-w-bound-regs-from-expected-bound.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we are able to infer that the type of `x` is `isize` based +// on the expected type from the object. + +// pretty-expanded FIXME #23616 + +pub trait ToPrimitive { + fn to_int(&self) {} +} + +impl ToPrimitive for isize {} +impl ToPrimitive for i32 {} +impl ToPrimitive for usize {} + +fn doit(val: T, f: &F) + where F : Fn(&T) +{ + f(&val) +} + +pub fn main() { + doit(0, &|x /*: isize*/ | { x.to_int(); }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-explicit-call-early.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-explicit-call-early.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-explicit-call-early.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-explicit-call-early.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(fn_traits)] + +fn main() { + let mut zero = || 0; + let x = zero.call_mut(()); + assert_eq!(x, 0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we are able to infer a suitable kind for this closure +// that is just called (`FnMut`). + +fn main() { + let mut counter = 0; + + { + // Here this must be inferred to FnMut so that it can mutate counter: + let mut tick1 = || counter += 1; + + // In turn, tick2 must be inferred to FnMut so that it can call tick1: + let mut tick2 = || { tick1(); tick1(); }; + + tick2(); + } + + assert_eq!(counter, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-fnmut-move.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-fnmut-move.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-fnmut-move.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-fnmut-move.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we are able to infer a suitable kind for this `move` +// closure that is just called (`FnMut`). + +fn main() { + let mut counter = 0; + + let v = { + let mut tick = move || { counter += 1; counter }; + tick(); + tick() + }; + + assert_eq!(counter, 0); + assert_eq!(v, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-fnmut.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-fnmut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-fnmut.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-fnmut.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we are able to infer a suitable kind for this closure +// that is just called (`FnMut`). + +fn main() { + let mut counter = 0; + + { + let mut tick = || counter += 1; + tick(); + tick(); + } + + assert_eq!(counter, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-fnonce-move.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-fnonce-move.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-fnonce-move.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-fnonce-move.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we are able to infer a suitable kind for this `move` +// closure that is just called (`FnOnce`). + +use std::mem; + +struct DropMe<'a>(&'a mut i32); + +impl<'a> Drop for DropMe<'a> { + fn drop(&mut self) { + *self.0 += 1; + } +} + +fn main() { + let mut counter = 0; + + { + let drop_me = DropMe(&mut counter); + let tick = move || mem::drop(drop_me); + tick(); + } + + assert_eq!(counter, 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-fnonce.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-fnonce.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-fnonce.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-fnonce.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we are able to infer a suitable kind for this closure +// that is just called (`FnOnce`). + +use std::mem; + +struct DropMe<'a>(&'a mut i32); + +impl<'a> Drop for DropMe<'a> { + fn drop(&mut self) { + *self.0 += 1; + } +} + +fn main() { + let mut counter = 0; + + { + let drop_me = DropMe(&mut counter); + let tick = || mem::drop(drop_me); + tick(); + } + + assert_eq!(counter, 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-kind.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-kind.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-kind.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-kind.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that we can infer the "kind" of an unboxed closure based on +// the expected type. + +// Test by-ref capture of environment in unboxed closure types + +fn call_fn(f: F) { + f() +} + +fn call_fn_mut(mut f: F) { + f() +} + +fn call_fn_once(f: F) { + f() +} + +fn main() { + let mut x = 0_usize; + let y = 2_usize; + + call_fn(|| assert_eq!(x, 0)); + call_fn_mut(|| x += y); + call_fn_once(|| x += y); + assert_eq!(x, y * 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-recursive-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-recursive-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-recursive-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-recursive-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,55 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(fn_traits, unboxed_closures)] + +use std::marker::PhantomData; + +// Test that we are able to infer a suitable kind for a "recursive" +// closure. As far as I can tell, coding up a recursive closure +// requires the good ol' [Y Combinator]. +// +// [Y Combinator]: http://en.wikipedia.org/wiki/Fixed-point_combinator#Y_combinator + +struct YCombinator { + func: F, + marker: PhantomData<(A,R)>, +} + +impl YCombinator { + fn new(f: F) -> YCombinator { + YCombinator { func: f, marker: PhantomData } + } +} + +impl R, A) -> R> Fn<(A,)> for YCombinator { + extern "rust-call" fn call(&self, (arg,): (A,)) -> R { + (self.func)(self, arg) + } +} + +impl R, A) -> R> FnMut<(A,)> for YCombinator { + extern "rust-call" fn call_mut(&mut self, args: (A,)) -> R { self.call(args) } +} + +impl R, A) -> R> FnOnce<(A,)> for YCombinator { + type Output = R; + extern "rust-call" fn call_once(self, args: (A,)) -> R { self.call(args) } +} + +fn main() { + let factorial = |recur: &Fn(u32) -> u32, arg: u32| -> u32 { + if arg == 0 {1} else {arg * recur(arg-1)} + }; + let factorial: YCombinator<_,u32,u32> = YCombinator::new(factorial); + let r = factorial(10); + assert_eq!(3628800, r); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-upvar.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-upvar.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-upvar.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-infer-upvar.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that the type variable in the type(`Vec<_>`) of a closed over +// variable does not interfere with type inference. + +fn f(mut f: F) { + f(); +} + +fn main() { + let mut v: Vec<_> = vec![]; + f(|| v.push(0)); + assert_eq!(v, [0]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-manual-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-manual-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-manual-impl.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-manual-impl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(unboxed_closures, fn_traits)] + +struct S; + +impl FnMut<(i32,)> for S { + extern "rust-call" fn call_mut(&mut self, (x,): (i32,)) -> i32 { + x * x + } +} + +impl FnOnce<(i32,)> for S { + type Output = i32; + + extern "rust-call" fn call_once(mut self, args: (i32,)) -> i32 { self.call_mut(args) } +} + +fn call_iti32>(mut f: F, x: i32) -> i32 { + f(x) + 3 +} + +fn call_box(f: &mut FnMut(i32) -> i32, x: i32) -> i32 { + f(x) + 3 +} + +fn main() { + let x = call_it(S, 1); + let y = call_box(&mut S, 1); + assert_eq!(x, 4); + assert_eq!(y, 4); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-monomorphization.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-monomorphization.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-monomorphization.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-monomorphization.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that unboxed closures in contexts with free type parameters +// monomorphize correctly (issue #16791) + +fn main(){ + fn bar<'a, T:Clone+'a> (t: T) -> BoxT + 'a> { + Box::new(move || t.clone()) + } + + let mut f = bar(42_u32); + assert_eq!(f(), 42); + + let mut f = bar("forty-two"); + assert_eq!(f(), "forty-two"); + + let x = 42_u32; + let mut f = bar(&x); + assert_eq!(f(), &x); + + #[derive(Clone, Copy, Debug, PartialEq)] + struct Foo(usize, &'static str); + + let x = Foo(42, "forty-two"); + let mut f = bar(x); + assert_eq!(f(), x); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-move-from-projection-issue-30046.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-move-from-projection-issue-30046.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-move-from-projection-issue-30046.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-move-from-projection-issue-30046.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused)] + +fn foo(f: F) + where F: FnOnce() +{ +} + +fn main() { + // Test that this closure is inferred to `FnOnce` + // because it moves from `y.as.0`: + let x = Some(vec![1, 2, 3]); + foo(|| { + match x { + Some(y) => { } + None => { } + } + }); + + // Test that this closure is inferred to `FnOnce` + // because it moves from `y.0`: + let y = (vec![1, 2, 3], 0); + foo(|| { + let x = y.0; + }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-move-mutable.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-move-mutable.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-move-mutable.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-move-mutable.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#![deny(unused_mut)] + +// Test that mutating a mutable upvar in a capture-by-value unboxed +// closure does not ice (issue #18238) and marks the upvar as used +// mutably so we do not get a spurious warning about it not needing to +// be declared mutable (issue #18336 and #18769) + +fn set(x: &mut usize) { *x = 42; } + +fn main() { + { + let mut x = 0_usize; + move || x += 1; + } + { + let mut x = 0_usize; + move || x += 1; + } + { + let mut x = 0_usize; + move || set(&mut x); + } + { + let mut x = 0_usize; + move || set(&mut x); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-move-some-upvars-in-by-ref-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-move-some-upvars-in-by-ref-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-move-some-upvars-in-by-ref-closure.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-move-some-upvars-in-by-ref-closure.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that in a by-ref once closure we move some variables even as +// we capture others by mutable reference. + +fn call(f: F) where F : FnOnce() { + f(); +} + +fn main() { + let mut x = vec![format!("Hello")]; + let y = vec![format!("World")]; + call(|| { + // Here: `x` must be captured with a mutable reference in + // order for us to append on it, and `y` must be captured by + // value. + for item in y { + x.push(item); + } + }); + assert_eq!(x.len(), 2); + assert_eq!(&*x[0], "Hello"); + assert_eq!(&*x[1], "World"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-prelude.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-prelude.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-prelude.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-prelude.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Tests that the re-exports of `FnOnce` et al from the prelude work. + +// pretty-expanded FIXME #23616 + +fn main() { + let task: Box isize> = Box::new(|x| x); + task(0); + + let mut task: Box isize> = Box::new(|x| x); + task(0); + + call(|x| x, 22); +} + +fn call isize>(f: F, x: isize) -> isize { + f(x) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-simple.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-simple.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-simple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +#![allow(unused_imports)] +use std::ops::FnMut; + +pub fn main() { + let mut f = |x: isize, y: isize| -> isize { x + y }; + let z = f(1, 2); + assert_eq!(z, 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-single-word-env.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-single-word-env.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-single-word-env.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-single-word-env.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Ensures that single-word environments work right in unboxed closures. +// These take a different path in codegen. + +fn a isize>(f: F) -> isize { + f(1, 2) +} + +fn b isize>(mut f: F) -> isize { + f(3, 4) +} + +fn c isize>(f: F) -> isize { + f(5, 6) +} + +fn main() { + let z = 10; + assert_eq!(a(move |x: isize, y| x + y + z), 13); + assert_eq!(b(move |x: isize, y| x + y + z), 17); + assert_eq!(c(move |x: isize, y| x + y + z), 21); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-static-call-fn-once.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-static-call-fn-once.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-static-call-fn-once.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-static-call-fn-once.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +fn main() { + let onetime = |x| x; + onetime(0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-sugar-object.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-sugar-object.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-sugar-object.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-sugar-object.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test unboxed closure sugar used in object types. + +#![allow(dead_code)] + +struct Foo { + t: T, u: U +} + +trait Getter { + fn get(&self, arg: A) -> R; +} + +struct Identity; +impl Getter for Identity { + fn get(&self, arg: X) -> X { + arg + } +} + +fn main() { + let x: &Getter<(i32,), (i32,)> = &Identity; + let (y,) = x.get((22,)); + assert_eq!(y, 22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-unique-type-id.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-unique-type-id.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-unique-type-id.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-unique-type-id.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// This code used to produce the following ICE: +// +// error: internal compiler error: get_unique_type_id_of_type() - +// unexpected type: closure, +// Closure(syntax::ast::DefId{krate: 0, node: 66}, +// ReScope(63)) +// +// This is a regression test for issue #17021. +// +// compile-flags: -g + +use std::ptr; + +pub fn replace_map<'a, T, F>(src: &mut T, prod: F) where F: FnOnce(T) -> T { + unsafe { *src = prod(ptr::read(src as *mut T as *const T)); } +} + +pub fn main() { + let mut a = 7; + let b = &mut a; + replace_map(b, |x: usize| x * 2); + assert_eq!(*b, 14); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-zero-args.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-zero-args.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-zero-args.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unboxed-closures/unboxed-closures-zero-args.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +// pretty-expanded FIXME #23616 + +fn main() { + let mut zero = || {}; + let () = zero(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/underscore-lifetimes.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/underscore-lifetimes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/underscore-lifetimes.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/underscore-lifetimes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] struct Foo<'a>(&'a u8); fn foo(x: &u8) -> Foo<'_> { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/uniform-paths/basic-nested.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/uniform-paths/basic-nested.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/uniform-paths/basic-nested.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/uniform-paths/basic-nested.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,71 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +#![allow(non_camel_case_types)] + +// edition:2018 + +#![feature(decl_macro, uniform_paths)] + +// This test is similar to `basic.rs`, but nested in modules. + +mod foo { + // Test that ambiguity errors are not emitted between `self::test` and + // `::test`, assuming the latter (crate) is not in `extern_prelude`. + mod test { + pub struct Foo(pub ()); + } + pub use test::Foo; + + // Test that qualified paths can refer to both the external crate and local item. + mod std { + pub struct io(pub ()); + } + pub use ::std::io as std_io; + pub use self::std::io as local_io; +} + +// Test that we can refer to the external crate unqualified +// (when there isn't a local item with the same name). +use std::io; + +mod bar { + // Also test the unqualified external crate import in a nested module, + // to show that the above import doesn't resolve through a local `std` + // item, e.g. the automatically injected `extern crate std;`, which in + // the Rust 2018 should no longer be visible through `crate::std`. + pub use std::io; + + // Also test that items named `std` in other namespaces don't + // cause ambiguity errors for the import from `std` above. + pub fn std() {} + pub macro std() {} +} + + +fn main() { + foo::Foo(()); + foo::std_io::stdout(); + foo::local_io(()); + io::stdout(); + bar::io::stdout(); + bar::std(); + bar::std!(); + + { + // Test that having `io` in a module scope and a non-module + // scope is allowed, when both resolve to the same definition. + use std::io; + use io::stdout; + stdout(); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/uniform-paths/basic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/uniform-paths/basic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/uniform-paths/basic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/uniform-paths/basic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +#![allow(non_camel_case_types)] + +// edition:2018 + +#![feature(uniform_paths)] + +// Test that ambiguity errors are not emitted between `self::test` and +// `::test`, assuming the latter (crate) is not in `extern_prelude`. +mod test { + pub struct Foo(pub ()); +} +use test::Foo; + +// Test that qualified paths can refer to both the external crate and local item. +mod std { + pub struct io(pub ()); +} +use ::std::io as std_io; +use self::std::io as local_io; + +fn main() { + Foo(()); + std_io::stdout(); + local_io(()); + + { + // Test that having `std_io` in a module scope and a non-module + // scope is allowed, when both resolve to the same definition. + use ::std::io as std_io; + use std_io::stdout; + stdout(); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/uniform-paths/macros-nested.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/uniform-paths/macros-nested.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/uniform-paths/macros-nested.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/uniform-paths/macros-nested.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,65 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +// edition:2018 + +#![feature(uniform_paths)] + +// This test is similar to `macros.rs`, but nested in modules. + +mod foo { + // Test that ambiguity errors are not emitted between `self::test` and + // `::test`, assuming the latter (crate) is not in `extern_prelude`. + macro_rules! m1 { + () => { + mod test { + pub struct Foo(pub ()); + } + } + } + pub use test::Foo; + m1!(); + + // Test that qualified paths can refer to both the external crate and local item. + macro_rules! m2 { + () => { + mod std { + pub struct io(pub ()); + } + } + } + pub use ::std::io as std_io; + pub use self::std::io as local_io; + m2!(); +} + +// Test that we can refer to the external crate unqualified +// (when there isn't a local item with the same name). +use std::io; + +mod bar { + // Also test the unqualified external crate import in a nested module, + // to show that the above import doesn't resolve through a local `std` + // item, e.g. the automatically injected `extern crate std;`, which in + // the Rust 2018 should no longer be visible through `crate::std`. + pub use std::io; +} + + +fn main() { + foo::Foo(()); + foo::std_io::stdout(); + foo::local_io(()); + io::stdout(); + bar::io::stdout(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/uniform-paths/macros.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/uniform-paths/macros.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/uniform-paths/macros.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/uniform-paths/macros.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,48 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_camel_case_types)] + +// edition:2018 + +#![feature(uniform_paths)] + +// This test is similar to `basic.rs`, but with macros defining local items. + +// Test that ambiguity errors are not emitted between `self::test` and +// `::test`, assuming the latter (crate) is not in `extern_prelude`. +macro_rules! m1 { + () => { + mod test { + pub struct Foo(pub ()); + } + } +} +use test::Foo; +m1!(); + +// Test that qualified paths can refer to both the external crate and local item. +macro_rules! m2 { + () => { + mod std { + pub struct io(pub ()); + } + } +} +use ::std::io as std_io; +use self::std::io as local_io; +m2!(); + +fn main() { + Foo(()); + std_io::stdout(); + local_io(()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/uniform-paths/same-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/uniform-paths/same-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/uniform-paths/same-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/uniform-paths/same-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,111 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +// edition:2018 + +#![feature(uniform_paths)] + +pub const A: usize = 0; + +pub mod foo { + pub const B: usize = 1; + + pub mod bar { + pub const C: usize = 2; + + pub enum E { + V1(usize), + V2(String), + } + + pub fn test() -> String { + format!("{} {} {}", crate::A, crate::foo::B, C) + } + + pub fn test_use() -> String { + use crate::A; + use crate::foo::B; + + format!("{} {} {}", A, B, C) + } + + pub fn test_enum() -> String { + use E::*; + match E::V1(10) { + V1(i) => { format!("V1: {}", i) } + V2(s) => { format!("V2: {}", s) } + } + } + } + + pub fn test() -> String { + format!("{} {} {}", crate::A, B, bar::C) + } + + pub fn test_use() -> String { + use crate::A; + use bar::C; + + format!("{} {} {}", A, B, C) + } + + pub fn test_enum() -> String { + use bar::E::*; + match bar::E::V1(10) { + V1(i) => { format!("V1: {}", i) } + V2(s) => { format!("V2: {}", s) } + } + } +} + +pub fn test() -> String { + format!("{} {} {}", A, foo::B, foo::bar::C) +} + +pub fn test_use() -> String { + use foo::B; + use foo::bar::C; + + format!("{} {} {}", A, B, C) +} + +pub fn test_enum() -> String { + use foo::bar::E::*; + match foo::bar::E::V1(10) { + V1(i) => { format!("V1: {}", i) } + V2(s) => { format!("V2: {}", s) } + } +} + +fn main() { + let output = [ + test(), + foo::test(), + foo::bar::test(), + test_use(), + foo::test_use(), + foo::bar::test_use(), + test_enum(), + foo::test_enum(), + foo::bar::test_enum(), + ].join("\n"); + assert_eq!(output, "\ +0 1 2 +0 1 2 +0 1 2 +0 1 2 +0 1 2 +0 1 2 +V1: 10 +V1: 10 +V1: 10"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/auxiliary/union.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/auxiliary/union.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/auxiliary/union.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/auxiliary/union.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub union U { + pub a: u8, + pub b: u16, +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-align.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-align.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-align.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-align.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,73 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + +#![feature(untagged_unions)] + +use std::mem::{size_of, size_of_val, align_of, align_of_val}; + +#[repr(align(16))] +pub union U16 { + a: u8, + b: u32 +} + +fn main() { + assert_eq!(align_of::(), 16); + assert_eq!(size_of::(), 16); + let u = U16 { a: 10 }; + unsafe { + assert_eq!(align_of_val(&u.a), 1); + assert_eq!(size_of_val(&u.a), 1); + assert_eq!(u.a, 10); + } + + let u = U16 { b: 11 }; + unsafe { + assert_eq!(align_of_val(&u.b), 4); + assert_eq!(size_of_val(&u.b), 4); + assert_eq!(u.b, 11); + } + + hybrid::check_hybrid(); +} + +mod hybrid { + use std::mem::{size_of, align_of}; + + #[repr(align(16))] + struct S1 { + a: u16, + b: u8, + } + + #[repr(align(32))] + union U { + s: S1, + c: u16, + } + + #[repr(align(64))] + struct S2 { + d: u8, + u: U, + } + + pub fn check_hybrid() { + assert_eq!(align_of::(), 16); + assert_eq!(size_of::(), 16); + assert_eq!(align_of::(), 32); + assert_eq!(size_of::(), 32); + assert_eq!(align_of::(), 64); + assert_eq!(size_of::(), 64); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-backcomp.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-backcomp.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-backcomp.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-backcomp.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(path_statements)] +#![allow(dead_code)] + +macro_rules! union { + () => (struct S;) +} + +union!(); + +fn union() {} + +fn main() { + union(); + + let union = 10; + + union; + + union as u8; + + union U { + a: u8, + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-basic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-basic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-basic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-basic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,69 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] + +// aux-build:union.rs + +extern crate union; +use std::mem::{size_of, align_of, zeroed}; + +union U { + a: u8, + b: u16 +} + +fn local() { + assert_eq!(size_of::(), 2); + assert_eq!(align_of::(), 2); + + let u = U { a: 10 }; + unsafe { + assert_eq!(u.a, 10); + let U { a } = u; + assert_eq!(a, 10); + } + + let mut w = U { b: 0 }; + unsafe { + assert_eq!(w.a, 0); + assert_eq!(w.b, 0); + w.a = 1; + assert_eq!(w.a, 1); + assert_eq!(w.b.to_le(), 1); + } +} + +fn xcrate() { + assert_eq!(size_of::(), 2); + assert_eq!(align_of::(), 2); + + let u = union::U { a: 10 }; + unsafe { + assert_eq!(u.a, 10); + let union::U { a } = u; + assert_eq!(a, 10); + } + + let mut w = union::U { b: 0 }; + unsafe { + assert_eq!(w.a, 0); + assert_eq!(w.b, 0); + w.a = 1; + assert_eq!(w.a, 1); + assert_eq!(w.b.to_le(), 1); + } +} + +fn main() { + local(); + xcrate(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-c-interop.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-c-interop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-c-interop.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-c-interop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_snake_case)] + +// ignore-wasm32-bare no libc to test ffi with + +#[derive(Clone, Copy)] +#[repr(C)] +struct LARGE_INTEGER_U { + LowPart: u32, + HighPart: u32, +} + +#[derive(Clone, Copy)] +#[repr(C)] +union LARGE_INTEGER { + __unnamed__: LARGE_INTEGER_U, + u: LARGE_INTEGER_U, + QuadPart: u64, +} + +#[link(name = "rust_test_helpers", kind = "static")] +extern "C" { + fn increment_all_parts(_: LARGE_INTEGER) -> LARGE_INTEGER; +} + +fn main() { + unsafe { + let mut li = LARGE_INTEGER { QuadPart: 0 }; + let li_c = increment_all_parts(li); + li.__unnamed__.LowPart += 1; + li.__unnamed__.HighPart += 1; + li.u.LowPart += 1; + li.u.HighPart += 1; + li.QuadPart += 1; + assert_eq!(li.QuadPart, li_c.QuadPart); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-const-codegen.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-const-codegen.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-const-codegen.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-const-codegen.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +union U { + a: u64, + b: u64, +} + +const C: U = U { b: 10 }; + +fn main() { + unsafe { + let a = C.a; + let b = C.b; + assert_eq!(a, 10); + assert_eq!(b, 10); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-const-eval-field.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-const-eval-field.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-const-eval-field.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-const-eval-field.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,55 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(const_fn)] + +type Field1 = (i32, u32); +type Field2 = f32; +type Field3 = i64; + +union DummyUnion { + field1: Field1, + field2: Field2, + field3: Field3, +} + +const FLOAT1_AS_I32: i32 = 1065353216; +const UNION: DummyUnion = DummyUnion { field1: (FLOAT1_AS_I32, 0) }; + +const fn read_field1() -> Field1 { + const FIELD1: Field1 = unsafe { UNION.field1 }; + FIELD1 +} + +const fn read_field2() -> Field2 { + const FIELD2: Field2 = unsafe { UNION.field2 }; + FIELD2 +} + +const fn read_field3() -> Field3 { + const FIELD3: Field3 = unsafe { UNION.field3 }; + FIELD3 +} + +fn main() { + let foo = FLOAT1_AS_I32; + assert_eq!(read_field1().0, foo); + assert_eq!(read_field1().0, FLOAT1_AS_I32); + + let foo = 1.0; + assert_eq!(read_field2(), foo); + assert_eq!(read_field2(), 1.0); + + assert_eq!(read_field3(), unsafe { UNION.field3 }); + let foo = unsafe { UNION.field3 }; + assert_eq!(read_field3(), foo); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-derive.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-derive.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-derive.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-derive.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,52 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(unions_with_drop_fields)] + +// Some traits can be derived for unions. + +#![feature(untagged_unions)] + +#[derive( + Copy, + Clone, + Eq, +)] +union U { + a: u8, + b: u16, +} + +impl PartialEq for U { fn eq(&self, rhs: &Self) -> bool { true } } + +#[derive( + Clone, + Copy, + Eq +)] +union W { + a: T, +} + +impl PartialEq for W { fn eq(&self, rhs: &Self) -> bool { true } } + +fn main() { + let u = U { b: 0 }; + let u1 = u; + let u2 = u.clone(); + assert!(u1 == u2); + + let w = W { a: 0 }; + let w1 = w.clone(); + assert!(w == w1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-drop-assign.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-drop-assign.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-drop-assign.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-drop-assign.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,48 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_assignments)] +#![allow(unions_with_drop_fields)] + +// Drop works for union itself. + +#![feature(untagged_unions)] + +struct S; + +union U { + a: S +} + +impl Drop for S { + fn drop(&mut self) { + unsafe { CHECK += 10; } + } +} + +impl Drop for U { + fn drop(&mut self) { + unsafe { CHECK += 1; } + } +} + +static mut CHECK: u8 = 0; + +fn main() { + unsafe { + let mut u = U { a: S }; + assert_eq!(CHECK, 0); + u = U { a: S }; + assert_eq!(CHECK, 1); // union itself is assigned, union is dropped, field is not dropped + u.a = S; + assert_eq!(CHECK, 11); // union field is assigned, field is dropped + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-drop.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-drop.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-drop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,70 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(unions_with_drop_fields)] + +// Drop works for union itself. + +#![feature(untagged_unions)] + +struct S; + +union U { + a: u8 +} + +union W { + a: S, +} + +union Y { + a: S, +} + +impl Drop for S { + fn drop(&mut self) { + unsafe { CHECK += 10; } + } +} + +impl Drop for U { + fn drop(&mut self) { + unsafe { CHECK += 1; } + } +} + +impl Drop for W { + fn drop(&mut self) { + unsafe { CHECK += 1; } + } +} + +static mut CHECK: u8 = 0; + +fn main() { + unsafe { + assert_eq!(CHECK, 0); + { + let u = U { a: 1 }; + } + assert_eq!(CHECK, 1); // 1, dtor of U is called + { + let w = W { a: S }; + } + assert_eq!(CHECK, 2); // 2, not 11, dtor of S is not called + { + let y = Y { a: S }; + } + assert_eq!(CHECK, 2); // 2, not 12, dtor of S is not called + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-generic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-generic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-generic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-generic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unions_with_drop_fields)] + +#![feature(untagged_unions)] + +union MaybeItem { + elem: T::Item, + none: (), +} + +union U { + a: A, + b: B, +} + +unsafe fn union_transmute(a: A) -> B { + U { a: a }.b +} + +fn main() { + unsafe { + let u = U::> { a: String::from("abcd") }; + + assert_eq!(u.b.len(), 4); + assert_eq!(u.b[0], b'a'); + + let b = union_transmute::<(u8, u8), u16>((1, 1)); + assert_eq!(b, (1 << 8) + 1); + + let v: Vec = vec![1, 2, 3]; + let mut i = v.iter(); + i.next(); + let mi = MaybeItem::> { elem: i.next().unwrap() }; + assert_eq!(*mi.elem, 2); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-inherent-method.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-inherent-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-inherent-method.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-inherent-method.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +union U { + a: u8, +} + +impl U { + fn method(&self) -> u8 { unsafe { self.a } } +} + +fn main() { + let u = U { a: 10 }; + assert_eq!(u.method(), 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-macro.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] + +macro_rules! duplicate { + ($i: item) => { + mod m1 { + $i + } + mod m2 { + $i + } + } +} + +duplicate! { + pub union U { + pub a: u8 + } +} + +fn main() { + let u1 = m1::U { a: 0 }; + let u2 = m2::U { a: 0 }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-nodrop.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-nodrop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-nodrop.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-nodrop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,69 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(core_intrinsics)] +#![feature(untagged_unions)] + +#![allow(unions_with_drop_fields)] +#![allow(dead_code)] + +use std::intrinsics::needs_drop; + +struct NeedDrop; + +impl Drop for NeedDrop { + fn drop(&mut self) {} +} + +// Constant expressios allow `NoDrop` to go out of scope, +// unlike a value of the interior type implementing `Drop`. +static X: () = (NoDrop { inner: NeedDrop }, ()).1; + +// A union that scrubs the drop glue from its inner type +union NoDrop {inner: T} + +// Copy currently can't be implemented on drop-containing unions, +// this may change later +// https://github.com/rust-lang/rust/pull/38934#issuecomment-271219289 + +// // We should be able to implement Copy for NoDrop +// impl Copy for NoDrop {} +// impl Clone for NoDrop {fn clone(&self) -> Self { *self }} + +// // We should be able to implement Copy for things using NoDrop +// #[derive(Copy, Clone)] +struct Foo { + x: NoDrop> +} + +struct Baz { + x: NoDrop>, + y: Box, +} + +union ActuallyDrop {inner: T} + +impl Drop for ActuallyDrop { + fn drop(&mut self) {} +} + +fn main() { + // NoDrop should not make needs_drop true + assert!(!needs_drop::()); + assert!(!needs_drop::>()); + assert!(!needs_drop::>>()); + // presence of other drop types should still work + assert!(needs_drop::()); + // drop impl on union itself should work + assert!(needs_drop::>()); + assert!(needs_drop::>>()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-overwrite.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-overwrite.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-overwrite.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-overwrite.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,83 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unions_with_drop_fields)] + +#![feature(untagged_unions)] + +#[repr(C)] +struct Pair(T, U); +#[repr(C)] +struct Triple(T, T, T); + +#[repr(C)] +union U { + a: Pair, + b: B, +} + +#[repr(C)] +union W { + a: A, + b: B, +} + +#[cfg(target_endian = "little")] +unsafe fn check() { + let mut u = U:: { b: 0xDE_DE }; + u.a.0 = 0xBE; + assert_eq!(u.b, 0xDE_BE); + + let mut u = U:: { b: 0xDEAD_DEAD }; + u.a.0 = 0xBEEF; + assert_eq!(u.b, 0xDEAD_BEEF); + + let mut u = U:: { b: 0xDEADBEEF_DEADBEEF }; + u.a.0 = 0xBAADF00D; + assert_eq!(u.b, 0xDEADBEEF_BAADF00D); + + let mut w = W::, u8>, u32> { b: 0xDEAD_DEAD }; + w.a.0 = Triple(0, 0, 0); + assert_eq!(w.b, 0xDE00_0000); + + let mut w = W::>, u32> { b: 0xDEAD_DEAD }; + w.a.1 = Triple(0, 0, 0); + assert_eq!(w.b, 0x0000_00AD); +} + +#[cfg(target_endian = "big")] +unsafe fn check() { + let mut u = U:: { b: 0xDE_DE }; + u.a.0 = 0xBE; + assert_eq!(u.b, 0xBE_DE); + + let mut u = U:: { b: 0xDEAD_DEAD }; + u.a.0 = 0xBEEF; + assert_eq!(u.b, 0xBEEF_DEAD); + + let mut u = U:: { b: 0xDEADBEEF_DEADBEEF }; + u.a.0 = 0xBAADF00D; + assert_eq!(u.b, 0xBAADF00D_DEADBEEF); + + let mut w = W::, u8>, u32> { b: 0xDEAD_DEAD }; + w.a.0 = Triple(0, 0, 0); + assert_eq!(w.b, 0x0000_00AD); + + let mut w = W::>, u32> { b: 0xDEAD_DEAD }; + w.a.1 = Triple(0, 0, 0); + assert_eq!(w.b, 0xDE00_0000); +} + +fn main() { + unsafe { + check(); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-packed.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-packed.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-packed.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-packed.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,182 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_snake_case)] + +#![feature(untagged_unions)] +#![feature(repr_packed)] + +use std::mem::{size_of, size_of_val, align_of, align_of_val}; + +struct S { + a: u16, + b: [u8; 3], +} + +#[repr(packed)] +struct Sp1 { + a: u16, + b: [u8; 3], +} + +#[repr(packed(2))] +struct Sp2 { + a: u16, + b: [u8; 3], +} + +union U { + a: u16, + b: [u8; 3], +} + +#[repr(packed)] +union Up1 { + a: u16, + b: [u8; 3], +} + +#[repr(packed(2))] +union Up2 { + a: u16, + b: [u8; 3], +} + +#[repr(C, packed(4))] +union Up4c { + a: u16, + b: [u8; 3], +} + +const CS: S = S { a: 0, b: [0, 0, 0] }; +const CSP1: Sp1 = Sp1 { a: 0, b: [0, 0, 0] }; +const CSP2: Sp2 = Sp2 { a: 0, b: [0, 0, 0] }; +const CU: U = U { b: [0, 0, 0] }; +const CUP1: Up1 = Up1 { b: [0, 0, 0] }; +const CUP2: Up2 = Up2 { b: [0, 0, 0] }; +const CUP4C: Up4c = Up4c { b: [0, 0, 0] }; + +fn main() { + let s = S { a: 0, b: [0, 0, 0] }; + assert_eq!(size_of::(), 6); + assert_eq!(size_of_val(&s), 6); + assert_eq!(size_of_val(&CS), 6); + assert_eq!(align_of::(), 2); + assert_eq!(align_of_val(&s), 2); + assert_eq!(align_of_val(&CS), 2); + + let sp1 = Sp1 { a: 0, b: [0, 0, 0] }; + assert_eq!(size_of::(), 5); + assert_eq!(size_of_val(&sp1), 5); + assert_eq!(size_of_val(&CSP1), 5); + assert_eq!(align_of::(), 1); + assert_eq!(align_of_val(&sp1), 1); + assert_eq!(align_of_val(&CSP1), 1); + + let sp2 = Sp2 { a: 0, b: [0, 0, 0] }; + assert_eq!(size_of::(), 6); + assert_eq!(size_of_val(&sp2), 6); + assert_eq!(size_of_val(&CSP2), 6); + assert_eq!(align_of::(), 2); + assert_eq!(align_of_val(&sp2), 2); + assert_eq!(align_of_val(&CSP2), 2); + + let u = U { b: [0, 0, 0] }; + assert_eq!(size_of::(), 4); + assert_eq!(size_of_val(&u), 4); + assert_eq!(size_of_val(&CU), 4); + assert_eq!(align_of::(), 2); + assert_eq!(align_of_val(&u), 2); + assert_eq!(align_of_val(&CU), 2); + + let Up1 = Up1 { b: [0, 0, 0] }; + assert_eq!(size_of::(), 3); + assert_eq!(size_of_val(&Up1), 3); + assert_eq!(size_of_val(&CUP1), 3); + assert_eq!(align_of::(), 1); + assert_eq!(align_of_val(&Up1), 1); + assert_eq!(align_of_val(&CUP1), 1); + + let up2 = Up2 { b: [0, 0, 0] }; + assert_eq!(size_of::(), 4); + assert_eq!(size_of_val(&up2), 4); + assert_eq!(size_of_val(&CUP2), 4); + assert_eq!(align_of::(), 2); + assert_eq!(align_of_val(&up2), 2); + assert_eq!(align_of_val(&CUP2), 2); + + let up4c = Up4c { b: [0, 0, 0] }; + assert_eq!(size_of::(), 4); + assert_eq!(size_of_val(&up4c), 4); + assert_eq!(size_of_val(&CUP4C), 4); + assert_eq!(align_of::(), 2); + assert_eq!(align_of_val(&up4c), 2); + assert_eq!(align_of_val(&CUP4C), 2); + + hybrid::check_hybrid(); +} + +mod hybrid { + use std::mem::{size_of, align_of}; + + #[repr(packed)] + struct S1 { + a: u16, + b: u8, + } + + #[repr(packed)] + union U { + s: S1, + c: u16, + } + + #[repr(packed)] + struct S2 { + d: u8, + u: U, + } + + #[repr(C, packed(2))] + struct S1C { + a: u16, + b: u8, + } + + #[repr(C, packed(2))] + union UC { + s: S1, + c: u16, + } + + #[repr(C, packed(2))] + struct S2C { + d: u8, + u: UC, + } + + pub fn check_hybrid() { + assert_eq!(align_of::(), 1); + assert_eq!(size_of::(), 3); + assert_eq!(align_of::(), 1); + assert_eq!(size_of::(), 3); + assert_eq!(align_of::(), 1); + assert_eq!(size_of::(), 4); + + assert_eq!(align_of::(), 2); + assert_eq!(size_of::(), 4); + assert_eq!(align_of::(), 2); + assert_eq!(size_of::(), 4); + assert_eq!(align_of::(), 2); + assert_eq!(size_of::(), 6); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-pat-refutability.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-pat-refutability.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-pat-refutability.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-pat-refutability.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,64 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(illegal_floating_point_literal_pattern)] + +#[repr(u32)] +enum Tag { I, F } + +#[repr(C)] +union U { + i: i32, + f: f32, +} + +#[repr(C)] +struct Value { + tag: Tag, + u: U, +} + +fn is_zero(v: Value) -> bool { + unsafe { + match v { + Value { tag: Tag::I, u: U { i: 0 } } => true, + Value { tag: Tag::F, u: U { f: 0.0 } } => true, + _ => false, + } + } +} + +union W { + a: u8, + b: u8, +} + +fn refut(w: W) { + unsafe { + match w { + W { a: 10 } => { + panic!(); + } + W { b } => { + assert_eq!(b, 11); + } + } + } +} + +fn main() { + let v = Value { tag: Tag::I, u: U { i: 1 } }; + assert_eq!(is_zero(v), false); + + let w = W { a: 11 }; + refut(w); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-trait-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-trait-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-trait-impl.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-trait-impl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +use std::fmt; + +union U { + a: u8 +} + +impl fmt::Display for U { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + unsafe { write!(f, "Oh hai {}", self.a) } + } +} + +fn main() { + assert_eq!(U { a: 2 }.to_string(), "Oh hai 2"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-transmute.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-transmute.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-transmute.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-transmute.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +extern crate core; +use core::f32; + +union U { + a: (u8, u8), + b: u16, +} + +union W { + a: u32, + b: f32, +} + +fn main() { + unsafe { + let mut u = U { a: (1, 1) }; + assert_eq!(u.b, (1 << 8) + 1); + u.b = (2 << 8) + 2; + assert_eq!(u.a, (2, 2)); + + let mut w = W { a: 0b0_11111111_00000000000000000000000 }; + assert_eq!(w.b, f32::INFINITY); + w.b = f32::NEG_INFINITY; + assert_eq!(w.a, 0b1_11111111_00000000000000000000000); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-with-drop-fields-lint.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-with-drop-fields-lint.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/union/union-with-drop-fields-lint.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/union/union-with-drop-fields-lint.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(untagged_unions)] +#![allow(dead_code)] +#![allow(unions_with_drop_fields)] + +union U { + a: u8, // OK +} + +union W { + a: String, // OK + b: String, // OK +} + +struct S(String); + +// `S` doesn't implement `Drop` trait, but still has non-trivial destructor +union Y { + a: S, // OK +} + +// We don't know if `T` is trivially-destructable or not until trans +union J { + a: T, // OK +} + +union H { + a: T, // OK +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-assign-copy.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-assign-copy.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-assign-copy.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-assign-copy.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +pub fn main() { + let mut i: Box<_> = box 1; + // Should be a copy + let mut j; + j = i.clone(); + *i = 2; + *j = 3; + assert_eq!(*i, 2); + assert_eq!(*j, 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-assign-drop.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-assign-drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-assign-drop.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-assign-drop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_assignments)] + +#![feature(box_syntax)] + +pub fn main() { + let i: Box<_> = box 1; + let mut j: Box<_> = box 2; + // Should drop the previous value of j + j = i; + assert_eq!(*j, 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-assign-generic.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-assign-generic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-assign-generic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-assign-generic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +fn f(t: T) -> T { + let t1 = t; + t1 +} + +pub fn main() { + let t = f::>(box 100); + assert_eq!(t, box 100); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-assign.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-assign.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-assign.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-assign.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +#![feature(box_syntax)] + +pub fn main() { + let mut i: Box<_>; + i = box 1; + assert_eq!(*i, 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-autoderef-field.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-autoderef-field.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-autoderef-field.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-autoderef-field.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +struct J { j: isize } + +pub fn main() { + let i: Box<_> = box J { + j: 100 + }; + assert_eq!(i.j, 100); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-autoderef-index.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-autoderef-index.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-autoderef-index.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-autoderef-index.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +pub fn main() { + let i: Box<_> = box vec![100]; + assert_eq!((*i)[0], 100); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-cmp.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-cmp.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-cmp.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-cmp.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_allocation)] +#![feature(box_syntax)] + +pub fn main() { + let i: Box<_> = box 100; + assert_eq!(i, box 100); + assert!(i < box 101); + assert!(i <= box 100); + assert!(i > box 99); + assert!(i >= box 99); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-containing-tag.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-containing-tag.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-containing-tag.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-containing-tag.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + +pub fn main() { + enum t { t1(isize), t2(isize), } + + let _x: Box<_> = box t::t1(10); + + /*alt *x { + t1(a) { + assert_eq!(a, 10); + } + _ { panic!(); } + }*/ + + /*alt x { + box t1(a) { + assert_eq!(a, 10); + } + _ { panic!(); } + }*/ +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-create.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-create.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-create.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-create.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + +pub fn main() { + let _: Box<_> = box 100; +} + +fn vec() { + vec![0]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-decl-init-copy.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-decl-init-copy.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-decl-init-copy.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-decl-init-copy.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +pub fn main() { + let mut i: Box<_> = box 1; + // Should be a copy + let mut j = i.clone(); + *i = 2; + *j = 3; + assert_eq!(*i, 2); + assert_eq!(*j, 3); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-decl-init.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-decl-init.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-decl-init.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-decl-init.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +pub fn main() { + let i: Box<_> = box 1; + let j = i; + assert_eq!(*j, 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-decl-move.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-decl-move.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-decl-move.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-decl-move.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +pub fn main() { + let i: Box<_> = box 100; + let j = i; + assert_eq!(*j, 100); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-decl.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-decl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-decl.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-decl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] + + +pub fn main() { + let _: Box; +} + +fn f(_i: Box) -> Box { + panic!(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-deref.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-deref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-deref.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-deref.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +pub fn main() { + let i: Box<_> = box 100; + assert_eq!(*i, 100); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-destructure.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-destructure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-destructure.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-destructure.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_patterns)] +#![feature(box_syntax)] + +struct Foo { a: isize, b: isize } + +pub fn main() { + let box Foo{a, b} = box Foo{a: 100, b: 200}; + assert_eq!(a + b, 300); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-drop-complex.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-drop-complex.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-drop-complex.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-drop-complex.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + +pub fn main() { + let _x: Box<_> = box vec![0,0,0,0,0]; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-ffi-symbols.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-ffi-symbols.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-ffi-symbols.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-ffi-symbols.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// We used to have a __rust_abi shim that resulted in duplicated symbols +// whenever the item path wasn't enough to disambiguate between them. +fn main() { + let a = { + extern fn good() -> i32 { return 0; } + good as extern fn() -> i32 + }; + let b = { + extern fn good() -> i32 { return 5; } + good as extern fn() -> i32 + }; + + assert!(a != b); + assert_eq!((a(), b()), (0, 5)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-fn-arg-move.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-fn-arg-move.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-fn-arg-move.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-fn-arg-move.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +fn f(i: Box) { + assert_eq!(*i, 100); +} + +pub fn main() { + let i = box 100; + f(i); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-fn-arg-mut.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-fn-arg-mut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-fn-arg-mut.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-fn-arg-mut.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +fn f(i: &mut Box) { + *i = box 200; +} + +pub fn main() { + let mut i = box 100; + f(&mut i); + assert_eq!(*i, 200); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-fn-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-fn-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-fn-arg.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-fn-arg.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +fn f(i: Box) { + assert_eq!(*i, 100); +} + +pub fn main() { + f(box 100); + let i = box 100; + f(i); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-fn-ret.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-fn-ret.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-fn-ret.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-fn-ret.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +fn f() -> Box { + box 100 +} + +pub fn main() { + assert_eq!(f(), box 100); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-generic-assign.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-generic-assign.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-generic-assign.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-generic-assign.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Issue #976 + + +// pretty-expanded FIXME #23616 + +fn f(x: Box) { + let _x2 = x; +} +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-init.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-init.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-init.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-init.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + +pub fn main() { + let _i: Box<_> = box 100; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-in-tag.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-in-tag.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-in-tag.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-in-tag.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +#![feature(box_syntax)] + +fn test1() { + enum bar { u(Box), w(isize), } + + let x = bar::u(box 10); + assert!(match x { + bar::u(a) => { + println!("{}", a); + *a + } + _ => { 66 } + } == 10); +} + +pub fn main() { + test1(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-in-vec-copy.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-in-vec-copy.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-in-vec-copy.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-in-vec-copy.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +pub fn main() { + let mut a: Vec> = vec![box 10]; + let b = a.clone(); + + assert_eq!(*a[0], 10); + assert_eq!(*b[0], 10); + + // This should only modify the value in a, not b + *a[0] = 20; + + assert_eq!(*a[0], 20); + assert_eq!(*b[0], 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-in-vec.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-in-vec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-in-vec.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-in-vec.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +pub fn main() { + let vect : Vec> = vec![box 100]; + assert_eq!(vect[0], box 100); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-kinds.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-kinds.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-kinds.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-kinds.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,75 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +use std::cmp::PartialEq; +use std::fmt::Debug; + +fn sendable() { + + fn f(i: T, j: T) { + assert_eq!(i, j); + } + + fn g(i: T, j: T) { + assert!(i != j); + } + + let i: Box<_> = box 100; + let j: Box<_> = box 100; + f(i, j); + let i: Box<_> = box 100; + let j: Box<_> = box 101; + g(i, j); +} + +fn copyable() { + + fn f(i: T, j: T) { + assert_eq!(i, j); + } + + fn g(i: T, j: T) { + assert!(i != j); + } + + let i: Box<_> = box 100; + let j: Box<_> = box 100; + f(i, j); + let i: Box<_> = box 100; + let j: Box<_> = box 101; + g(i, j); +} + +fn noncopyable() { + + fn f(i: T, j: T) { + assert_eq!(i, j); + } + + fn g(i: T, j: T) { + assert!(i != j); + } + + let i: Box<_> = box 100; + let j: Box<_> = box 100; + f(i, j); + let i: Box<_> = box 100; + let j: Box<_> = box 101; + g(i, j); +} + +pub fn main() { + sendable(); + copyable(); + noncopyable(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-log.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-log.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-log.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-log.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +pub fn main() { + let i: Box<_> = box 100; + println!("{}", i); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-match-discrim.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-match-discrim.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-match-discrim.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-match-discrim.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Issue #961 + +// pretty-expanded FIXME #23616 + +fn altsimple() { + match Box::new(true) { + _ => { } + } +} +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-move-drop.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-move-drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-move-drop.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-move-drop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![allow(unused_variables)] +#![feature(box_syntax)] + +pub fn main() { + let i: Box<_> = box 100; + let j: Box<_> = box 200; + let j = i; + assert_eq!(*j, 100); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-move.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-move.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-move.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-move.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +#![feature(box_syntax)] + +pub fn main() { + let i: Box<_> = box 100; + let mut j; + j = i; + assert_eq!(*j, 100); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-move-temp.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-move-temp.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-move-temp.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-move-temp.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +#![feature(box_syntax)] + +pub fn main() { + let mut i: Box<_>; + i = box 100; + assert_eq!(*i, 100); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-mutable.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-mutable.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-mutable.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-mutable.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +pub fn main() { + let mut i: Box<_> = box 0; + *i = 1; + assert_eq!(*i, 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-object-move.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-object-move.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-object-move.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-object-move.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// Issue #5192 + +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + +pub trait EventLoop { fn foo(&self) {} } + +pub struct UvEventLoop { + uvio: isize +} + +impl EventLoop for UvEventLoop { } + +pub fn main() { + let loop_: Box = box UvEventLoop { uvio: 0 } as Box; + let _loop2_ = loop_; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-pat-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-pat-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-pat-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-pat-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] +#![allow(non_shorthand_field_patterns)] + +#![feature(box_patterns)] +#![feature(box_syntax)] + +struct Foo {a: isize, b: usize} + +enum bar { u(Box), w(isize), } + +pub fn main() { + assert!(match bar::u(box Foo{a: 10, b: 40}) { + bar::u(box Foo{a: a, b: b}) => { a + (b as isize) } + _ => { 66 } + } == 50); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-pat-3.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-pat-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-pat-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-pat-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +#![feature(box_syntax)] + +enum bar { u(Box), w(isize), } + +pub fn main() { + assert!(match bar::u(box 10) { + bar::u(a) => { + println!("{}", a); + *a + } + _ => { 66 } + } == 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-pat.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-pat.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-pat.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-pat.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(box_patterns)] +#![feature(box_syntax)] + +fn simple() { + match box true { + box true => { } + _ => { panic!(); } + } +} + +pub fn main() { + simple(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-rec.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-rec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-rec.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-rec.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +struct X { x: isize } + +pub fn main() { + let x: Box<_> = box X {x: 1}; + let bar = x; + assert_eq!(bar.x, 1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-send-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-send-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-send-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-send-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_must_use)] +// ignore-emscripten no threads support + +#![feature(box_syntax)] + +use std::sync::mpsc::{channel, Sender}; +use std::thread; + +fn child(tx: &Sender>, i: usize) { + tx.send(box i).unwrap(); +} + +pub fn main() { + let (tx, rx) = channel(); + let n = 100; + let mut expected = 0; + let ts = (0..n).map(|i| { + expected += i; + let tx = tx.clone(); + thread::spawn(move|| { + child(&tx, i) + }) + }).collect::>(); + + let mut actual = 0; + for _ in 0..n { + let j = rx.recv().unwrap(); + actual += *j; + } + + assert_eq!(expected, actual); + + for t in ts { t.join(); } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-send.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-send.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-send.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-send.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +use std::sync::mpsc::channel; + +pub fn main() { + let (tx, rx) = channel::>(); + tx.send(box 100).unwrap(); + let v = rx.recv().unwrap(); + assert_eq!(v, box 100); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-swap.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-swap.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unique/unique-swap.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unique/unique-swap.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![feature(box_syntax)] + +use std::mem::swap; + +pub fn main() { + let mut i: Box<_> = box 100; + let mut j: Box<_> = box 200; + swap(&mut i, &mut j); + assert_eq!(i, box 200); + assert_eq!(j, box 100); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unit.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unit.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unit.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_assignments)] +#![allow(unknown_lints)] // pretty-expanded FIXME #23616 #![allow(unused_variables)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unreachable-code-1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unreachable-code-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unreachable-code-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unreachable-code-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_must_use)] +#![allow(unreachable_code)] #![allow(unused_variables)] #![allow(dead_code)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unreachable-code.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unreachable-code.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unreachable-code.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unreachable-code.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_must_use)] +#![allow(dead_code)] #![allow(path_statements)] #![allow(unreachable_code)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unsafe-fn-called-from-unsafe-blk.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unsafe-fn-called-from-unsafe-blk.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unsafe-fn-called-from-unsafe-blk.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unsafe-fn-called-from-unsafe-blk.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // // See also: compile-fail/unsafe-fn-called-from-safe.rs diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unsafe-fn-called-from-unsafe-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unsafe-fn-called-from-unsafe-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unsafe-fn-called-from-unsafe-fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unsafe-fn-called-from-unsafe-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // // See also: compile-fail/unsafe-fn-called-from-safe.rs diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unsized2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unsized2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unsized2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unsized2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unconditional_recursion)] +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(unused_imports)] #![feature(box_syntax)] // Test sized-ness checking in substitution. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unsized-locals/reference-unsized-locals.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unsized-locals/reference-unsized-locals.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unsized-locals/reference-unsized-locals.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unsized-locals/reference-unsized-locals.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(unsized_locals)] + +fn main() { + let foo: Box<[u8]> = Box::new(*b"foo"); + let foo: [u8] = *foo; + assert_eq!(&foo, b"foo" as &[u8]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unsized-locals/simple-unsized-locals.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unsized-locals/simple-unsized-locals.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unsized-locals/simple-unsized-locals.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unsized-locals/simple-unsized-locals.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(unsized_locals)] + +fn main() { + let foo: Box<[u8]> = Box::new(*b"foo"); + let _foo: [u8] = *foo; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unsized-locals/unsized-exprs.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unsized-locals/unsized-exprs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unsized-locals/unsized-exprs.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unsized-locals/unsized-exprs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(unsized_tuple_coercion, unsized_locals)] + +struct A(X); + +fn udrop(_x: T) {} +fn foo() -> Box<[u8]> { + Box::new(*b"foo") +} +fn tfoo() -> Box<(i32, [u8])> { + Box::new((42, *b"foo")) +} +fn afoo() -> Box> { + Box::new(A(*b"foo")) +} + +impl std::ops::Add for A<[u8]> { + type Output = (); + fn add(self, _rhs: i32) -> Self::Output {} +} + +fn main() { + udrop::<[u8]>(loop { + break *foo(); + }); + udrop::<[u8]>(if true { + *foo() + } else { + *foo() + }); + udrop::<[u8]>({*foo()}); + #[allow(unused_parens)] + udrop::<[u8]>((*foo())); + udrop::<[u8]>((*tfoo()).1); + *afoo() + 42; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unsized-locals/unsized-parameters.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unsized-locals/unsized-parameters.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unsized-locals/unsized-parameters.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unsized-locals/unsized-parameters.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![feature(unsized_locals)] + +pub fn f0(_f: dyn FnOnce()) {} +pub fn f1(_s: str) {} +pub fn f2((_x, _y): (i32, [i32])) {} + +fn main() { + let foo = "foo".to_string().into_boxed_str(); + f1(*foo); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unsized.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unsized.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unsized.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unsized.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(type_alias_bounds)] +#![allow(dead_code)] // Test syntax checks for `?Sized` syntax. use std::marker::PhantomData; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unwind-resource.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unwind-resource.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/unwind-resource.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/unwind-resource.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] // ignore-emscripten no threads support use std::sync::mpsc::{channel, Sender}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/use-keyword-2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/use-keyword-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/use-keyword-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/use-keyword-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_variables)] pub struct A; mod test { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/use-mod.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/use-mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/use-mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/use-mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_imports)] // pretty-expanded FIXME #23616 pub use foo::bar::{self, First}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/use.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/use.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/use.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/use.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(stable_features)] // pretty-expanded FIXME #23616 #![allow(unused_imports)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/utf8_idents.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/utf8_idents.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/utf8_idents.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/utf8_idents.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. // +#![allow(non_snake_case)] #![feature(non_ascii_idents)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/variant-attributes.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/variant-attributes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/variant-attributes.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/variant-attributes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_attributes)] +#![allow(non_camel_case_types)] +#![allow(dead_code)] // pp-exact - Make sure we actually print the attributes // pretty-expanded FIXME #23616 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/volatile-fat-ptr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/volatile-fat-ptr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/volatile-fat-ptr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/volatile-fat-ptr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(stable_features)] #![feature(volatile)] use std::ptr::{read_volatile, write_volatile}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/warn-ctypes-inhibit.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/warn-ctypes-inhibit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/warn-ctypes-inhibit.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/warn-ctypes-inhibit.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // compile-flags:-D improper-ctypes // pretty-expanded FIXME #23616 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/weird-exprs.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/weird-exprs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/weird-exprs.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/weird-exprs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(dead_code)] +#![allow(unreachable_code)] +#![allow(unused_parens)] // compile-flags: -Z borrowck=compare #![recursion_limit = "128"] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/wf-bound-region-in-object-type.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/wf-bound-region-in-object-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/wf-bound-region-in-object-type.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/wf-bound-region-in-object-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] +#![allow(unused_variables)] // Test that the `wf` checker properly handles bound regions in object // types. Compiling this code used to trigger an ICE. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/where-clauses/auxiliary/where_clauses_xc.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/where-clauses/auxiliary/where_clauses_xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/where-clauses/auxiliary/where_clauses_xc.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/where-clauses/auxiliary/where_clauses_xc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait Equal { + fn equal(&self, other: &Self) -> bool; + fn equals(&self, this: &T, that: &T, x: &U, y: &U) -> bool + where T: Eq, U: Eq; +} + +impl Equal for T where T: Eq { + fn equal(&self, other: &T) -> bool { + self == other + } + fn equals(&self, this: &U, other: &U, x: &X, y: &X) -> bool + where U: Eq, X: Eq { + this == other && x == y + } +} + +pub fn equal(x: &T, y: &T) -> bool where T: Eq { + x == y +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clause-bounds-inconsistency.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clause-bounds-inconsistency.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clause-bounds-inconsistency.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clause-bounds-inconsistency.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// pretty-expanded FIXME #23616 + +trait Bound { + fn dummy(&self) { } +} + +trait Trait { + fn a(&self, _: T) where T: Bound; + fn b(&self, _: T) where T: Bound; + fn c(&self, _: T); + fn d(&self, _: T); +} + +impl Trait for bool { + fn a(&self, _: T) {} + //^~ This gets rejected but should be accepted + fn b(&self, _: T) where T: Bound {} + fn c(&self, _: T) {} + fn d(&self, _: T) where T: Bound {} +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clause-early-bound-lifetimes.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clause-early-bound-lifetimes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clause-early-bound-lifetimes.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clause-early-bound-lifetimes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_upper_case_globals)] + +// pretty-expanded FIXME #23616 + +trait TheTrait { fn dummy(&self) { } } + +impl TheTrait for &'static isize { } + +fn foo<'a,T>(_: &'a T) where &'a T : TheTrait { } + +fn bar(_: &'static T) where &'static T : TheTrait { } + +fn main() { + static x: isize = 1; + foo(&x); + bar(&x); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clause-method-substituion.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clause-method-substituion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clause-method-substituion.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clause-method-substituion.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// pretty-expanded FIXME #23616 + +trait Foo { fn dummy(&self, arg: T) { } } + +trait Bar { + fn method(&self) where A: Foo; +} + +struct S; +struct X; + +impl Foo for X {} + +impl Bar for i32 { + fn method(&self) where X: Foo { + } +} + +fn main() { + 1.method::(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clause-region-outlives.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clause-region-outlives.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clause-region-outlives.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clause-region-outlives.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// pretty-expanded FIXME #23616 + +struct A<'a, 'b> where 'a : 'b { x: &'a isize, y: &'b isize } + +fn main() { + let x = 1; + let y = 1; + let a = A { x: &x, y: &y }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clauses-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clauses-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clauses-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clauses-cross-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// aux-build:where_clauses_xc.rs + +extern crate where_clauses_xc; + +use where_clauses_xc::{Equal, equal}; + +fn main() { + println!("{}", equal(&1, &2)); + println!("{}", equal(&1, &1)); + println!("{}", "hello".equal(&"hello")); + println!("{}", "hello".equals::(&1, &1, &"foo", &"bar")); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clauses-lifetimes.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clauses-lifetimes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clauses-lifetimes.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clauses-lifetimes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_mut)] +#![allow(unused_variables)] +// pretty-expanded FIXME #23616 + +fn foo<'a, I>(mut it: I) where I: Iterator {} + +fn main() { + foo([1, 2].iter()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clauses-method.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clauses-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clauses-method.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clauses-method.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that a where clause attached to a method allows us to add +// additional constraints to a parameter out of scope. + +struct Foo { + value: T +} + +impl Foo { + fn equals(&self, u: &Foo) -> bool where T : Eq { + self.value == u.value + } +} + +fn main() { + let x = Foo { value: 1 }; + let y = Foo { value: 2 }; + println!("{}", x.equals(&x)); + println!("{}", x.equals(&y)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clauses.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clauses.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clauses.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clauses.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +trait Equal { + fn equal(&self, other: &Self) -> bool; + fn equals(&self, this: &T, that: &T, x: &U, y: &U) -> bool + where T: Eq, U: Eq; +} + +impl Equal for T where T: Eq { + fn equal(&self, other: &T) -> bool { + self == other + } + fn equals(&self, this: &U, other: &U, x: &X, y: &X) -> bool + where U: Eq, X: Eq { + this == other && x == y + } +} + +fn equal(x: &T, y: &T) -> bool where T: Eq { + x == y +} + +fn main() { + println!("{}", equal(&1, &2)); + println!("{}", equal(&1, &1)); + println!("{}", "hello".equal(&"hello")); + println!("{}", "hello".equals::(&1, &1, &"foo", &"bar")); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clauses-unboxed-closures.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clauses-unboxed-closures.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clauses-unboxed-closures.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/where-clauses/where-clauses-unboxed-closures.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// pretty-expanded FIXME #23616 + +struct Bencher; + +// ICE +fn warm_up<'a, F>(f: F) where F: Fn(&'a mut Bencher) { +} + +fn main() { + // ICE trigger + warm_up(|b: &mut Bencher| () ); + + // OK + warm_up(|b| () ); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/writealias.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/writealias.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/writealias.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/writealias.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] use std::sync::Mutex; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/wrong-hashset-issue-42918.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/wrong-hashset-issue-42918.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/wrong-hashset-issue-42918.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/wrong-hashset-issue-42918.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. // +#![allow(dead_code)] // compile-flags: -O use std::collections::HashSet; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/x86stdcall2.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/x86stdcall2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/x86stdcall2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/x86stdcall2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] pub type HANDLE = usize; pub type DWORD = u32; pub type SIZE_T = u32; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/yield1.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/yield1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/yield1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/yield1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_must_use)] +#![allow(unused_mut)] // ignore-emscripten no threads support use std::thread; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/yield.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/yield.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/yield.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/yield.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_must_use)] +#![allow(unused_mut)] // ignore-emscripten no threads support use std::thread; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-binary-heap-push.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-binary-heap-push.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-binary-heap-push.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-binary-heap-push.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +use std::collections::BinaryHeap; +use std::iter::Iterator; + +fn main() { + const N: usize = 8; + + for len in 0..N { + let mut tester = BinaryHeap::with_capacity(len); + assert_eq!(tester.len(), 0); + assert!(tester.capacity() >= len); + for bit in 0..len { + tester.push(()); + } + assert_eq!(tester.len(), len); + assert_eq!(tester.iter().count(), len); + tester.clear(); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-btreemap-insert.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-btreemap-insert.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-btreemap-insert.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-btreemap-insert.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +#![allow(unused_imports)] +use std::cmp::{Ord, Ordering, PartialOrd}; +use std::collections::BTreeMap; +use std::iter::Iterator; + +#[derive(Eq, Hash, Debug, Ord, PartialEq, PartialOrd)] +struct Zst; + +fn main() { + const N: usize = 8; + + for len in 0..N { + let mut tester = BTreeMap::new(); + assert_eq!(tester.len(), 0); + for bit in 0..len { + tester.insert(Zst, ()); + } + assert_eq!(tester.len(), if len == 0 { 0 } else { 1 }); + assert_eq!(tester.iter().count(), if len == 0 { 0 } else { 1 }); + assert_eq!(tester.get(&Zst).is_some(), len > 0); + tester.clear(); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-linkedlist-push.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-linkedlist-push.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-linkedlist-push.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-linkedlist-push.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::collections::LinkedList; +use std::iter::Iterator; + +fn main() { + const N: usize = 8; + + // Test that for all possible sequences of push_front / push_back, + // we end up with a LinkedList of the correct size + + for len in 0..N { + let mut tester = LinkedList::new(); + assert_eq!(tester.len(), 0); + assert_eq!(tester.front(), None); + for case in 0..(1 << len) { + assert_eq!(tester.len(), 0); + for bit in 0..len { + if case & (1 << bit) != 0 { + tester.push_front(()); + } else { + tester.push_back(()); + } + } + assert_eq!(tester.len(), len); + assert_eq!(tester.iter().count(), len); + tester.clear(); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-tuple-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-tuple-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-tuple-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-tuple-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_assignments)] + +// Make sure that the constructor args are codegened for zero-sized tuple structs + +struct Foo(()); + +fn main() { + let mut a = 1; + Foo({ a = 2 }); + assert_eq!(a, 2); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-vec-deque-push.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-vec-deque-push.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-vec-deque-push.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-vec-deque-push.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +use std::collections::VecDeque; +use std::iter::Iterator; + +fn main() { + const N: usize = 8; + + // Zero sized type + struct Zst; + + // Test that for all possible sequences of push_front / push_back, + // we end up with a deque of the correct size + + for len in 0..N { + let mut tester = VecDeque::with_capacity(len); + assert_eq!(tester.len(), 0); + assert!(tester.capacity() >= len); + for case in 0..(1 << len) { + assert_eq!(tester.len(), 0); + for bit in 0..len { + if case & (1 << bit) != 0 { + tester.push_front(Zst); + } else { + tester.push_back(Zst); + } + } + assert_eq!(tester.len(), len); + assert_eq!(tester.iter().count(), len); + tester.clear(); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-vec-push.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-vec-push.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-vec-push.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-sized-vec-push.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +use std::iter::Iterator; +use std::vec::Vec; + +fn main() { + const N: usize = 8; + + for len in 0..N { + let mut tester = Vec::with_capacity(len); + assert_eq!(tester.len(), 0); + assert!(tester.capacity() >= len); + for bit in 0..len { + tester.push(()); + } + assert_eq!(tester.len(), len); + assert_eq!(tester.iter().count(), len); + tester.clear(); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-size-type-destructors.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-size-type-destructors.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-size-type-destructors.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/zero-sized/zero-size-type-destructors.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(non_upper_case_globals)] + +static mut destructions : isize = 3; + +pub fn foo() { + struct Foo; + + impl Drop for Foo { + fn drop(&mut self) { + unsafe { destructions -= 1 }; + } + }; + + let _x = [Foo, Foo, Foo]; +} + +pub fn main() { + foo(); + assert_eq!(unsafe { destructions }, 0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/ast_stmt_expr_attr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/ast_stmt_expr_attr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/ast_stmt_expr_attr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/ast_stmt_expr_attr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_imports)] // ignore-cross-compile #![feature(rustc_private)] @@ -283,9 +284,7 @@ reject_stmt_parse("#[attr] #![attr] foo!{}"); // FIXME: Allow attributes in pattern constexprs? - // would require parens in patterns to allow disambiguation... - // —which is now available under the `pattern_parentheses` feature gate - // (tracking issue #51087) + // note: requires parens in patterns to allow disambiguation reject_expr_parse("match 0 { 0..=#[attr] 10 => () diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ // no-prefer-dynamic #![crate_type = "proc-macro"] -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate proc_macro; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/hello_macro.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/hello_macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/hello_macro.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/hello_macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ // no-prefer-dynamic #![crate_type = "proc-macro"] -#![feature(proc_macro_non_items, proc_macro_quote)] +#![feature(proc_macro_hygiene, proc_macro_quote)] extern crate proc_macro; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/issue-16723.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/issue-16723.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/issue-16723.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/issue-16723.rs 2018-12-04 23:41:40.000000000 +0000 @@ -17,9 +17,10 @@ extern crate rustc; extern crate rustc_data_structures; extern crate rustc_plugin; +#[macro_use] extern crate smallvec; extern crate syntax_pos; -use rustc_data_structures::small_vec::OneVector; +use smallvec::SmallVec; use syntax::ext::base::{ExtCtxt, MacResult, MacEager}; use syntax::tokenstream; use rustc_plugin::Registry; @@ -31,8 +32,8 @@ fn expand(cx: &mut ExtCtxt, _: syntax_pos::Span, _: &[tokenstream::TokenTree]) -> Box { - MacEager::items(OneVector::from_vec(vec![ + MacEager::items(smallvec![ quote_item!(cx, struct Struct1;).unwrap(), quote_item!(cx, struct Struct2;).unwrap() - ])) + ]) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/linkage-visibility.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/linkage-visibility.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/linkage-visibility.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/linkage-visibility.rs 2018-12-04 23:41:40.000000000 +0000 @@ -39,7 +39,7 @@ let lib = DynamicLibrary::open(None).unwrap(); unsafe { assert!(lib.symbol::("foo").is_ok()); - assert!(lib.symbol::("baz").is_err()); - assert!(lib.symbol::("bar").is_err()); + assert!(lib.symbol::("baz").is_ok()); + assert!(lib.symbol::("bar").is_ok()); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/lint_for_crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/lint_for_crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/lint_for_crate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/lint_for_crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,7 +12,6 @@ #![feature(plugin_registrar, rustc_private)] #![feature(box_syntax)] -#![cfg_attr(stage0, feature(macro_vis_matcher))] #![feature(macro_at_most_once_rep)] #[macro_use] extern crate rustc; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ // no-prefer-dynamic #![crate_type = "proc-macro"] -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate proc_macro; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/custom-derive-partial-eq.stderr rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/custom-derive-partial-eq.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/custom-derive-partial-eq.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/custom-derive-partial-eq.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,6 @@ +warning: `#[derive]` for custom traits is deprecated and will be removed in the future. Prefer using procedural macro custom derive. + --> $DIR/custom-derive-partial-eq.rs:17:10 + | +LL | #[derive(CustomPartialEq)] // Check that this is not a stability error. + | ^^^^^^^^^^^^^^^ + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/derive-no-std-not-supported.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/derive-no-std-not-supported.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/derive-no-std-not-supported.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/derive-no-std-not-supported.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] #![feature(rustc_private)] #![no_std] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/deriving-encodable-decodable-box.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/deriving-encodable-decodable-box.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/deriving-encodable-decodable-box.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/deriving-encodable-decodable-box.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,16 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_imports)] #![feature(box_syntax)] #![feature(rustc_private)] extern crate serialize; +use serialize as rustc_serialize; use serialize::{Encodable, Decodable}; use serialize::json; -#[derive(Encodable, Decodable)] +#[derive(RustcEncodable, RustcDecodable)] struct A { foo: Box<[bool]>, } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/deriving-encodable-decodable-cell-refcell.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/deriving-encodable-decodable-cell-refcell.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/deriving-encodable-decodable-cell-refcell.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/deriving-encodable-decodable-cell-refcell.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_imports)] // This briefly tests the capability of `Cell` and `RefCell` to implement the // `Encodable` and `Decodable` traits via `#[derive(Encodable, Decodable)]` @@ -15,17 +16,18 @@ #![feature(rustc_private)] extern crate serialize; +use serialize as rustc_serialize; use std::cell::{Cell, RefCell}; use serialize::{Encodable, Decodable}; use serialize::json; -#[derive(Encodable, Decodable)] +#[derive(RustcEncodable, RustcDecodable)] struct A { baz: isize } -#[derive(Encodable, Decodable)] +#[derive(RustcEncodable, RustcDecodable)] struct B { foo: Cell, bar: RefCell, diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/deriving-global.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/deriving-global.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/deriving-global.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/deriving-global.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,6 +11,7 @@ #![feature(rustc_private)] extern crate serialize; +use serialize as rustc_serialize; mod submod { // if any of these are implemented without global calls for any @@ -20,21 +21,21 @@ Hash, Clone, Debug, - Encodable, Decodable)] + RustcEncodable, RustcDecodable)] enum A { A1(usize), A2(isize) } #[derive(PartialEq, PartialOrd, Eq, Ord, Hash, Clone, Debug, - Encodable, Decodable)] + RustcEncodable, RustcDecodable)] struct B { x: usize, y: isize } #[derive(PartialEq, PartialOrd, Eq, Ord, Hash, Clone, Debug, - Encodable, Decodable)] + RustcEncodable, RustcDecodable)] struct C(usize, isize); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/deriving-hygiene.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/deriving-hygiene.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/deriving-hygiene.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/deriving-hygiene.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_upper_case_globals)] #![feature(rustc_private)] extern crate serialize; +use serialize as rustc_serialize; pub const other: u8 = 1; pub const f: u8 = 1; @@ -18,7 +20,7 @@ pub const state: u8 = 1; pub const cmp: u8 = 1; -#[derive(Ord,Eq,PartialOrd,PartialEq,Debug,Decodable,Encodable,Hash)] +#[derive(Ord,Eq,PartialOrd,PartialEq,Debug,RustcDecodable,RustcEncodable,Hash)] struct Foo {} fn main() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/dropck_tarena_sound_drop.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/dropck_tarena_sound_drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/dropck_tarena_sound_drop.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/dropck_tarena_sound_drop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unknown_lints)] // Check that an arena (TypedArena) can carry elements whose drop // methods might access borrowed data, as long as the borrowed data // has lifetime that strictly outlives the arena itself. @@ -45,6 +46,6 @@ fn f<'a, 'b>(_arena: &'a TypedArena>) {} fn main() { - let arena: TypedArena = TypedArena::new(); + let arena: TypedArena = TypedArena::default(); f(&arena); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-11881.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-11881.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-11881.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-11881.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,10 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_must_use)] +#![allow(dead_code)] +#![allow(unused_imports)] #![feature(rustc_private)] extern crate serialize; +use serialize as rustc_serialize; use std::io::Cursor; use std::io::prelude::*; @@ -22,12 +26,12 @@ use serialize::json; use serialize::opaque; -#[derive(Encodable)] +#[derive(RustcEncodable)] struct Foo { baz: bool, } -#[derive(Encodable)] +#[derive(RustcEncodable)] struct Bar { froboz: usize, } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-14021.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-14021.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-14021.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-14021.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,14 +8,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_mut)] +#![allow(unused_imports)] #![feature(rustc_private)] extern crate serialize; +extern crate serialize as rustc_serialize; use serialize::{Encodable, Decodable}; use serialize::json; -#[derive(Encodable, Decodable, PartialEq, Debug)] +#[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] struct UnitLikeStruct; pub fn main() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-15149.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-15149.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-15149.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-15149.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_variables)] // no-prefer-dynamic // ignore-cross-compile diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-15924.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-15924.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-15924.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-15924.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_imports)] +#![allow(unused_must_use)] // pretty-expanded FIXME #23616 #![feature(rustc_private)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-18763-quote-token-tree.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-18763-quote-token-tree.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-18763-quote-token-tree.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-18763-quote-token-tree.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] +#![allow(unused_imports)] // ignore-cross-compile #![feature(quote, rustc_private)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-24972.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-24972.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-24972.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-24972.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] #![feature(rustc_private)] extern crate serialize; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-2804.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-2804.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-2804.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-2804.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(non_camel_case_types)] +#![allow(dead_code)] #![feature(rustc_private)] extern crate serialize; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-4016.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-4016.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-4016.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-4016.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] #![feature(rustc_private)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-40663.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-40663.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-40663.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/issue-40663.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // aux-build:custom_derive_plugin.rs // ignore-stage1 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/macro-crate-multi-decorator-literals.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/macro-crate-multi-decorator-literals.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/macro-crate-multi-decorator-literals.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/macro-crate-multi-decorator-literals.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(plugin_as_library)] +#![allow(unused_imports)] // aux-build:macro_crate_test.rs // ignore-stage1 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/macro-crate-multi-decorator.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/macro-crate-multi-decorator.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/macro-crate-multi-decorator.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/macro-crate-multi-decorator.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(plugin_as_library)] +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(unused_imports)] // aux-build:macro_crate_test.rs // ignore-stage1 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/macro-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/macro-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/macro-crate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/macro-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(plugin_as_library)] +#![allow(dead_code)] // aux-build:macro_crate_test.rs // ignore-stage1 @@ -17,8 +19,8 @@ #[macro_use] #[no_link] extern crate macro_crate_test; -#[derive(PartialEq, Clone, Debug)] #[rustc_into_multi_foo] +#[derive(PartialEq, Clone, Debug)] fn foo() -> AnotherFakeTypeThatHadBetterGoAway {} // Check that the `#[into_multi_foo]`-generated `foo2` is configured away diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/macro-quote-cond.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/macro-quote-cond.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/macro-quote-cond.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/macro-quote-cond.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,10 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_parens)] // aux-build:cond_plugin.rs // ignore-stage1 -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate cond_plugin; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/macro-quote-test.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/macro-quote-test.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/macro-quote-test.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/macro-quote-test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,7 +13,7 @@ // aux-build:hello_macro.rs // ignore-stage1 -#![feature(proc_macro_non_items, proc_macro_gen)] +#![feature(proc_macro_hygiene)] extern crate hello_macro; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/newtype_index.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/newtype_index.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/newtype_index.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/newtype_index.rs 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ -#![feature(min_const_fn, rustc_attrs, rustc_private, step_trait)] +#![feature(rustc_attrs, rustc_private, step_trait)] #[macro_use] extern crate rustc_data_structures; extern crate rustc_serialize; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ // aux-build:attr-stmt-expr.rs // ignore-stage1 -#![feature(stmt_expr_attributes, proc_macro_expr)] +#![feature(stmt_expr_attributes, proc_macro_hygiene)] extern crate attr_stmt_expr; use attr_stmt_expr::{expect_let, expect_print_stmt, expect_expr, expect_print_expr, diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/auxiliary/count_compound_ops.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/auxiliary/count_compound_ops.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/auxiliary/count_compound_ops.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/auxiliary/count_compound_ops.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,7 @@ // no-prefer-dynamic -#![feature(proc_macro_non_items, proc_macro_quote)] +#![feature(proc_macro_hygiene, proc_macro_quote)] #![crate_type = "proc-macro"] extern crate proc_macro; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/auxiliary/hygiene_example_codegen.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/auxiliary/hygiene_example_codegen.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/auxiliary/hygiene_example_codegen.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/auxiliary/hygiene_example_codegen.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,7 @@ // no-prefer-dynamic -#![feature(proc_macro_quote, proc_macro_non_items)] +#![feature(proc_macro_quote, proc_macro_hygiene)] #![crate_type = "proc-macro"] extern crate proc_macro as proc_macro_renamed; // This does not break `quote!` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-40001-plugin.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-40001-plugin.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-40001-plugin.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-40001-plugin.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,7 +9,6 @@ // except according to those terms. #![feature(box_syntax, plugin, plugin_registrar, rustc_private)] -#![cfg_attr(stage0, feature(macro_vis_matcher))] #![feature(macro_at_most_once_rep)] #![crate_type = "dylib"] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/bang-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/bang-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/bang-macro.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/bang-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ // aux-build:bang-macro.rs // ignore-stage1 -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate bang_macro; use bang_macro::rewrite; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/call-site.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/call-site.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/call-site.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/call-site.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,10 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_variables)] +#![allow(unused_imports)] // aux-build:call-site.rs // ignore-stage1 -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate call_site; use call_site::*; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/count_compound_ops.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/count_compound_ops.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/count_compound_ops.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/count_compound_ops.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ // aux-build:count_compound_ops.rs // ignore-stage1 -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate count_compound_ops; use count_compound_ops::count_compound_ops; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/derive-attr-cfg.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/derive-attr-cfg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/derive-attr-cfg.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/derive-attr-cfg.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // aux-build:derive-attr-cfg.rs // ignore-stage1 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(path_statements)] +#![allow(dead_code)] // aux-build:derive-same-struct.rs // ignore-stage1 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.stdout rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.stdout --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.stdout 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.stdout 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1 @@ +input1: "struct A;" diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/derive-two-attrs.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/derive-two-attrs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/derive-two-attrs.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/derive-two-attrs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // aux-build:derive-two-attrs.rs extern crate derive_two_attrs as foo; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/derive-union.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/derive-union.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/derive-union.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/derive-union.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_variables)] // aux-build:derive-union.rs // ignore-stage1 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/empty-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/empty-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/empty-crate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/empty-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_imports)] // aux-build:empty-crate.rs // ignore-stage1 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,11 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_macros)] // aux-build:hygiene_example_codegen.rs // aux-build:hygiene_example.rs // ignore-stage1 -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate hygiene_example; use hygiene_example::hello; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/issue-39889.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/issue-39889.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/issue-39889.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/issue-39889.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // aux-build:issue-39889.rs // ignore-stage1 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/issue-50061.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/issue-50061.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/issue-50061.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/issue-50061.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(path_statements)] // aux-build:issue-50061.rs // ignore-stage1 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/lifetimes.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/lifetimes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/lifetimes.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/lifetimes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_variables)] // aux-build:lifetimes.rs // ignore-stage1 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/load-two.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/load-two.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/load-two.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/load-two.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(path_statements)] +#![allow(dead_code)] // aux-build:derive-atob.rs // aux-build:derive-ctod.rs // ignore-stage1 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/negative-token.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/negative-token.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/negative-token.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/negative-token.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ // aux-build:negative-token.rs // ignore-stage1 -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate negative_token; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/smoke.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/smoke.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/smoke.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/smoke.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_must_use)] +#![allow(path_statements)] // aux-build:derive-a.rs // ignore-stage1 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/struct-field-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/struct-field-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/struct-field-macro.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc-macro/struct-field-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // aux-build:derive-nothing.rs // ignore-stage1 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc_macro.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc_macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc_macro.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/proc_macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,7 +12,7 @@ // ignore-stage1 // ignore-cross-compile -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate proc_macro_def; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/qquote.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/qquote.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/qquote.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/qquote.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_imports)] // ignore-cross-compile #![feature(quote, rustc_private)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/quote-tokens.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/quote-tokens.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/quote-tokens.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/quote-tokens.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(unused_imports)] // ignore-cross-compile #![feature(quote, rustc_private)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/quote-unused-sp-no-warning.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] // ignore-cross-compile #![feature(quote, rustc_private)] #![deny(unused_variables)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/regions-mock-tcx.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/regions-mock-tcx.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/regions-mock-tcx.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/regions-mock-tcx.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(dead_code)] +#![allow(unused_imports)] // Test a sample usage pattern for regions. Makes use of the // following features: @@ -131,8 +133,8 @@ } pub fn main() { - let ty_arena = TypedArena::new(); - let ast_arena = TypedArena::new(); + let ty_arena = TypedArena::default(); + let ast_arena = TypedArena::default(); let mut tcx = TypeContext::new(&ty_arena, &ast_arena); let ast = tcx.ast(ExprInt); let ty = compute_types(&mut tcx, ast); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/rename-directory.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/rename-directory.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass-fulldeps/rename-directory.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass-fulldeps/rename-directory.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(unused_must_use)] +#![allow(unused_imports)] // This test can't be a unit test in std, // because it needs TempDir, which is in extra diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/assoc-consts.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/assoc-consts.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/assoc-consts.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/assoc-consts.rs 2018-12-04 23:41:40.000000000 +0000 @@ -52,7 +52,7 @@ impl Bar { // @has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.F"]' \ - // "const F: fn(_: &(ToString + 'static))" + // "const F: fn(_: &(dyn ToString + 'static))" pub const F: fn(_: &(ToString + 'static)) = f; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/auxiliary/issue-27362.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/auxiliary/issue-27362.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/auxiliary/issue-27362.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/auxiliary/issue-27362.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,8 +10,6 @@ // compile-flags: -Cmetadata=aux -#![feature(min_const_fn)] - pub const fn foo() {} pub const unsafe fn bar() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/const-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/const-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/const-fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/const-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(min_const_fn)] #![crate_name = "foo"] // @has foo/fn.bar.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/const.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/const.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/const.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,8 +10,6 @@ #![crate_type="lib"] -#![feature(min_const_fn)] - pub struct Foo; impl Foo { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/doc-proc-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/doc-proc-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/doc-proc-macro.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/doc-proc-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-stage1 + // Issue #52129: ICE when trying to document the `quote` proc-macro from proc_macro // As of this writing, we don't currently attempt to document proc-macros. However, we shouldn't diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/edition-doctest.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/edition-doctest.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/edition-doctest.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/edition-doctest.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,54 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:--test + +/// ```rust,edition2018 +/// #![feature(try_blocks)] +/// +/// use std::num::ParseIntError; +/// +/// let result: Result = try { +/// "1".parse::()? +/// + "2".parse::()? +/// + "3".parse::()? +/// }; +/// assert_eq!(result, Ok(6)); +/// +/// let result: Result = try { +/// "1".parse::()? +/// + "foo".parse::()? +/// + "3".parse::()? +/// }; +/// assert!(result.is_err()); +/// ``` + + +/// ```rust,edition2015,compile_fail,E0574 +/// #![feature(try_blocks)] +/// +/// use std::num::ParseIntError; +/// +/// let result: Result = try { +/// "1".parse::()? +/// + "2".parse::()? +/// + "3".parse::()? +/// }; +/// assert_eq!(result, Ok(6)); +/// +/// let result: Result = try { +/// "1".parse::()? +/// + "foo".parse::()? +/// + "3".parse::()? +/// }; +/// assert!(result.is_err()); +/// ``` + +pub fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/inline_cross/auxiliary/proc_macro.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/inline_cross/auxiliary/proc_macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/inline_cross/auxiliary/proc_macro.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/inline_cross/auxiliary/proc_macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type="proc-macro"] +#![crate_name="some_macros"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +/// a proc-macro that swallows its input and does nothing. +#[proc_macro] +pub fn some_proc_macro(_input: TokenStream) -> TokenStream { + TokenStream::new() +} + +/// a proc-macro attribute that passes its item through verbatim. +#[proc_macro_attribute] +pub fn some_proc_attr(_attr: TokenStream, item: TokenStream) -> TokenStream { + item +} + +/// a derive attribute that adds nothing to its input. +#[proc_macro_derive(SomeDerive)] +pub fn some_derive(_item: TokenStream) -> TokenStream { + TokenStream::new() +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/inline_cross/auxiliary/trait-vis.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/inline_cross/auxiliary/trait-vis.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/inline_cross/auxiliary/trait-vis.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/inline_cross/auxiliary/trait-vis.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "inner"] + +pub struct SomeStruct; + +fn asdf() { + const _FOO: () = { + impl Clone for SomeStruct { + fn clone(&self) -> Self { + SomeStruct + } + } + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/inline_cross/auxiliary/use_crate_2.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/inline_cross/auxiliary/use_crate_2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/inline_cross/auxiliary/use_crate_2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/inline_cross/auxiliary/use_crate_2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct SomethingElse; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/inline_cross/auxiliary/use_crate.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/inline_cross/auxiliary/use_crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/inline_cross/auxiliary/use_crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/inline_cross/auxiliary/use_crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod asdf { + pub struct SomeStruct; +} + +pub trait SomeTrait {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/inline_cross/issue-31948-1.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/inline_cross/issue-31948-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/inline_cross/issue-31948-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/inline_cross/issue-31948-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -22,13 +22,13 @@ pub use rustdoc_nonreachable_impls::hidden::Wobble; // @has issue_31948_1/trait.Bark.html -// FIXME(33025): has - '//code' 'for Foo' +// @has - '//code' 'for Foo' // @has - '//code' 'for Wobble' // @!has - '//code' 'for Wibble' pub use rustdoc_nonreachable_impls::Bark; // @has issue_31948_1/trait.Woof.html -// FIXME(33025): has - '//code' 'for Foo' +// @has - '//code' 'for Foo' // @has - '//code' 'for Wobble' // @!has - '//code' 'for Wibble' pub use rustdoc_nonreachable_impls::Woof; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/inline_cross/issue-31948-2.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/inline_cross/issue-31948-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/inline_cross/issue-31948-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/inline_cross/issue-31948-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -22,7 +22,7 @@ pub use rustdoc_nonreachable_impls::hidden::Wobble; // @has issue_31948_2/trait.Qux.html -// FIXME(33025): has - '//code' 'for Foo' +// @has - '//code' 'for Foo' // @has - '//code' 'for Wobble' pub use rustdoc_nonreachable_impls::hidden::Qux; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/inline_cross/issue-32881.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/inline_cross/issue-32881.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/inline_cross/issue-32881.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/inline_cross/issue-32881.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,8 +15,8 @@ extern crate rustdoc_trait_object_impl; // @has issue_32881/trait.Bar.html -// @has - '//code' "impl<'a> Bar" -// @has - '//code' "impl<'a> Debug for Bar" +// @has - '//code' "impl<'a> dyn Bar" +// @has - '//code' "impl<'a> Debug for dyn Bar" pub use rustdoc_trait_object_impl::Bar; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/inline_cross/proc_macro.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/inline_cross/proc_macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/inline_cross/proc_macro.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/inline_cross/proc_macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-stage1 +// aux-build:proc_macro.rs +// build-aux-docs + +// FIXME: if/when proc-macros start exporting their doc attributes across crates, we can turn on +// cross-crate inlining for them + +extern crate some_macros; + +// @has proc_macro/index.html +// @has - '//a/@href' '../some_macros/macro.some_proc_macro.html' +// @has - '//a/@href' '../some_macros/attr.some_proc_attr.html' +// @has - '//a/@href' '../some_macros/derive.SomeDerive.html' +// @!has proc_macro/macro.some_proc_macro.html +// @!has proc_macro/attr.some_proc_attr.html +// @!has proc_macro/derive.SomeDerive.html +pub use some_macros::{some_proc_macro, some_proc_attr, SomeDerive}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/inline_cross/trait-vis.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/inline_cross/trait-vis.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/inline_cross/trait-vis.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/inline_cross/trait-vis.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:trait-vis.rs + +extern crate inner; + +// @has trait_vis/struct.SomeStruct.html +// @has - '//code' 'impl Clone for SomeStruct' +pub use inner::SomeStruct; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/inline_cross/use_crate.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/inline_cross/use_crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/inline_cross/use_crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/inline_cross/use_crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:use_crate.rs +// aux-build:use_crate_2.rs +// build-aux-docs +// edition:2018 +// compile-flags:--extern use_crate --extern use_crate_2 -Z unstable-options + +// During the buildup to Rust 2018, rustdoc would eagerly inline `pub use some_crate;` as if it +// were a module, so we changed it to make `pub use`ing crate roots remain as a `pub use` statement +// in docs... unless you added `#[doc(inline)]`. + +#![crate_name = "local"] + +// @!has-dir local/use_crate +// @has local/index.html +// @has - '//code' 'pub use use_crate' +pub use use_crate; + +// @has-dir local/asdf +// @has local/asdf/index.html +// @has local/index.html '//a/@href' 'asdf/index.html' +pub use use_crate::asdf; + +// @has-dir local/use_crate_2 +// @has local/use_crate_2/index.html +// @has local/index.html '//a/@href' 'use_crate_2/index.html' +#[doc(inline)] +pub use use_crate_2; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/inline_local/trait-vis.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/inline_local/trait-vis.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/inline_local/trait-vis.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/inline_local/trait-vis.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait ThisTrait {} + +mod asdf { + use ThisTrait; + + pub struct SomeStruct; + + impl ThisTrait for SomeStruct {} + + trait PrivateTrait {} + + impl PrivateTrait for SomeStruct {} +} + +// @has trait_vis/struct.SomeStruct.html +// @has - '//code' 'impl ThisTrait for SomeStruct' +// !@has - '//code' 'impl PrivateTrait for SomeStruct' +pub use asdf::SomeStruct; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/intra-link-in-bodies.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/intra-link-in-bodies.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/intra-link-in-bodies.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/intra-link-in-bodies.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// we need to make sure that intra-doc links on trait impls get resolved in the right scope + +#![deny(intra_doc_link_resolution_failure)] + +pub mod inner { + pub struct SomethingOutOfScope; +} + +pub mod other { + use inner::SomethingOutOfScope; + use SomeTrait; + + pub struct OtherStruct; + + /// Let's link to [SomethingOutOfScope] while we're at it. + impl SomeTrait for OtherStruct {} +} + +pub trait SomeTrait {} + +pub struct SomeStruct; + +fn __implementation_details() { + use inner::SomethingOutOfScope; + + // FIXME: intra-links resolve in their nearest module scope, not their actual scope in cases + // like this + // Let's link to [SomethingOutOfScope] while we're at it. + impl SomeTrait for SomeStruct {} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/issue-52873.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/issue-52873.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/issue-52873.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/issue-52873.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,171 @@ +// Regression test for #52873. We used to ICE due to unexpected +// overflows when checking for "blanket impl inclusion". + +use std::marker::PhantomData; +use std::cmp::Ordering; +use std::ops::{Add, Mul}; + +pub type True = B1; +pub type False = B0; +pub type U0 = UTerm; +pub type U1 = UInt; + +pub trait NonZero {} + +pub trait Bit { +} + +pub trait Unsigned { +} + +#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)] +pub struct B0; + +impl B0 { + #[inline] + pub fn new() -> B0 { + B0 + } +} + +#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)] +pub struct B1; + +impl B1 { + #[inline] + pub fn new() -> B1 { + B1 + } +} + +impl Bit for B0 { +} + +impl Bit for B1 { +} + +impl NonZero for B1 {} + +pub trait PrivatePow { + type Output; +} +pub type PrivatePowOut = >::Output; + +pub type Add1 = >::Output; +pub type Prod = >::Output; +pub type Square = ::Output; +pub type Sum = >::Output; + +#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)] +pub struct UTerm; + +impl UTerm { + #[inline] + pub fn new() -> UTerm { + UTerm + } +} + +impl Unsigned for UTerm { +} + +#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)] +pub struct UInt { + _marker: PhantomData<(U, B)>, +} + +impl UInt { + #[inline] + pub fn new() -> UInt { + UInt { + _marker: PhantomData, + } + } +} + +impl Unsigned for UInt { +} + +impl NonZero for UInt {} + +impl Add for UTerm { + type Output = UTerm; + fn add(self, _: B0) -> Self::Output { + UTerm + } +} + +impl Add for UInt { + type Output = UInt; + fn add(self, _: B0) -> Self::Output { + UInt::new() + } +} + +impl Add for UTerm { + type Output = U; + fn add(self, _: U) -> Self::Output { + unsafe { ::std::mem::uninitialized() } + } +} + +impl Mul for UInt { + type Output = UTerm; + fn mul(self, _: B0) -> Self::Output { + UTerm + } +} + +impl Mul for UInt { + type Output = UInt; + fn mul(self, _: B1) -> Self::Output { + UInt::new() + } +} + +impl Mul for UTerm { + type Output = UTerm; + fn mul(self, _: U) -> Self::Output { + UTerm + } +} + +impl Mul> for UInt +where + Ul: Mul>, +{ + type Output = UInt>, B0>; + fn mul(self, _: UInt) -> Self::Output { + unsafe { ::std::mem::uninitialized() } + } +} + +pub trait Pow { + type Output; +} + +impl Pow for X +where + X: PrivatePow, +{ + type Output = PrivatePowOut; +} + +impl PrivatePow for X { + type Output = Y; +} + +impl PrivatePow for X +where + X: Mul, +{ + type Output = Prod; +} + +impl PrivatePow, B0>> for X +where + X: Mul, + Square: PrivatePow>, +{ + type Output = PrivatePowOut, Y, UInt>; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/issue-54478-demo-allocator.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/issue-54478-demo-allocator.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/issue-54478-demo-allocator.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/issue-54478-demo-allocator.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// Issue #54478: regression test showing that we can demonstrate +// `#[global_allocator]` in code blocks built by `rustdoc`. +// +// ## Background +// +// Changes in lang-item visibility injected failures that were only +// exposed when compiling with `-C prefer-dynamic`. But `rustdoc` used +// `-C prefer-dynamic` (and had done so for years, for reasons we did +// not document at that time). +// +// Rather than try to revise the visbility semanics, we instead +// decided to change `rustdoc` to behave more like the compiler's +// default setting, by leaving off `-C prefer-dynamic`. + +// compile-flags:--test + +//! This is a doc comment +//! +//! ```rust +//! use std::alloc::*; +//! +//! #[global_allocator] +//! static ALLOC: A = A; +//! +//! static mut HIT: bool = false; +//! +//! struct A; +//! +//! unsafe impl GlobalAlloc for A { +//! unsafe fn alloc(&self, layout: Layout) -> *mut u8 { +//! HIT = true; +//! System.alloc(layout) +//! } +//! unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { +//! System.dealloc(ptr, layout); +//! } +//! } +//! +//! fn main() { +//! assert!(unsafe { HIT }); +//! } +//! ``` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/issue-55001.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/issue-55001.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/issue-55001.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/issue-55001.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// Regression test for issue #55001. Previously, we would incorrectly +// cache certain trait selection results when checking for blanket impls, +// resulting in an ICE when we tried to confirm the cached ParamCandidate +// against an obligation. + +pub struct DefaultAllocator; +pub struct Standard; +pub struct Inner; + +pub trait Rand {} + +pub trait Distribution {} +pub trait Allocator {} + +impl Rand for T where Standard: Distribution {} + +impl Distribution> for Standard +where +DefaultAllocator: Allocator, +Standard: Distribution {} + +impl Distribution for Standard {} + + +pub struct Point +where DefaultAllocator: Allocator +{ + field: N +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/keyword.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/keyword.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/keyword.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/keyword.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,6 +15,7 @@ // @has foo/index.html '//h2[@id="keywords"]' 'Keywords' // @has foo/index.html '//a[@href="keyword.match.html"]' 'match' // @has foo/keyword.match.html '//a[@class="keyword"]' 'match' +// @has foo/keyword.match.html '//span[@class="in-band"]' 'Keyword match' // @has foo/keyword.match.html '//section[@id="main"]//div[@class="docblock"]//p' 'this is a test!' // @!has foo/index.html '//a/@href' 'foo/index.html' // @!has foo/foo/index.html diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/primitive-generic-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/primitive-generic-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/primitive-generic-impl.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/primitive-generic-impl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,9 +10,6 @@ #![crate_name = "foo"] -// we need to reexport something from libstd so that `all_trait_implementations` is called. -pub use std::string::String; - include!("primitive/primitive-generic-impl.rs"); // @has foo/primitive.i32.html '//h3[@id="impl-ToString"]//code' 'impl ToString for T' diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/proc-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/proc-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/proc-macro.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/proc-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,62 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-stage1 + +#![crate_type="proc-macro"] +#![crate_name="some_macros"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +// @has some_macros/index.html +// @has - '//h2' 'Macros' +// @has - '//h2' 'Attribute Macros' +// @has - '//h2' 'Derive Macros' +// @!has - '//h2' 'Functions' + +// @has some_macros/all.html +// @has - '//a[@href="macro.some_proc_macro.html"]' 'some_proc_macro' +// @has - '//a[@href="attr.some_proc_attr.html"]' 'some_proc_attr' +// @has - '//a[@href="derive.SomeDerive.html"]' 'SomeDerive' +// @!has - '//a/@href' 'fn.some_proc_macro.html' +// @!has - '//a/@href' 'fn.some_proc_attr.html' +// @!has - '//a/@href' 'fn.some_derive.html' + +// @has some_macros/index.html '//a/@href' 'macro.some_proc_macro.html' +// @!has - '//a/@href' 'fn.some_proc_macro.html' +// @has some_macros/macro.some_proc_macro.html +// @!has some_macros/fn.some_proc_macro.html +/// a proc-macro that swallows its input and does nothing. +#[proc_macro] +pub fn some_proc_macro(_input: TokenStream) -> TokenStream { + TokenStream::new() +} + +// @has some_macros/index.html '//a/@href' 'attr.some_proc_attr.html' +// @!has - '//a/@href' 'fn.some_proc_attr.html' +// @has some_macros/attr.some_proc_attr.html +// @!has some_macros/fn.some_proc_attr.html +/// a proc-macro attribute that passes its item through verbatim. +#[proc_macro_attribute] +pub fn some_proc_attr(_attr: TokenStream, item: TokenStream) -> TokenStream { + item +} + +// @has some_macros/index.html '//a/@href' 'derive.SomeDerive.html' +// @!has - '//a/@href' 'fn.some_derive.html' +// @has some_macros/derive.SomeDerive.html +// @!has some_macros/fn.some_derive.html +/// a derive attribute that adds nothing to its input. +#[proc_macro_derive(SomeDerive)] +pub fn some_derive(_item: TokenStream) -> TokenStream { + TokenStream::new() +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/src-links-external.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/src-links-external.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/src-links-external.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/src-links-external.rs 2018-12-04 23:41:40.000000000 +0000 @@ -18,6 +18,7 @@ extern crate src_links_external; // @has foo/bar/index.html '//a/@href' '../../src/src_links_external/src-links-external.rs.html#11' +#[doc(inline)] pub use src_links_external as bar; // @has foo/bar/struct.Foo.html '//a/@href' '../../src/src_links_external/src-links-external.rs.html#11' diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/test-parens.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/test-parens.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/test-parens.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/test-parens.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,5 +11,5 @@ #![crate_name = "foo"] // @has foo/fn.foo.html -// @has - '//*[@class="rust fn"]' "_: &(ToString + 'static)" +// @has - '//*[@class="rust fn"]' "_: &(dyn ToString + 'static)" pub fn foo(_: &(ToString + 'static)) {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/traits-in-bodies-private.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/traits-in-bodies-private.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/traits-in-bodies-private.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/traits-in-bodies-private.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// when implementing the fix for traits-in-bodies, there was an ICE when documenting private items +// and a trait was defined in non-module scope + +// compile-flags:--document-private-items + +// @has traits_in_bodies_private/struct.SomeStruct.html +// @!has - '//code' 'impl HiddenTrait for SomeStruct' +pub struct SomeStruct; + +fn __implementation_details() { + trait HiddenTrait {} + impl HiddenTrait for SomeStruct {} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/traits-in-bodies.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/traits-in-bodies.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc/traits-in-bodies.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc/traits-in-bodies.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,11 +11,10 @@ //prior to fixing `everybody_loops` to preserve items, rustdoc would crash on this file, as it //didn't see that `SomeStruct` implemented `Clone` -//FIXME(misdreavus): whenever rustdoc shows traits impl'd inside bodies, make sure this test -//reflects that - pub struct Bounded(T); +// @has traits_in_bodies/struct.SomeStruct.html +// @has - '//code' 'impl Clone for SomeStruct' pub struct SomeStruct; fn asdf() -> Bounded { @@ -27,3 +26,37 @@ Bounded(SomeStruct) } + +// @has traits_in_bodies/struct.Point.html +// @has - '//code' 'impl Copy for Point' +#[derive(Clone)] +pub struct Point { + x: i32, + y: i32, +} + +const _FOO: () = { + impl Copy for Point {} + () +}; + +// @has traits_in_bodies/struct.Inception.html +// @has - '//code' 'impl Clone for Inception' +pub struct Inception; + +static _BAR: usize = { + trait HiddenTrait { + fn hidden_fn(&self) { + for _ in 0..5 { + impl Clone for Inception { + fn clone(&self) -> Self { + // we need to go deeper + Inception + } + } + } + } + } + + 5 +}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-js/pinbox-new.js rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-js/pinbox-new.js --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-js/pinbox-new.js 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-js/pinbox-new.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// exact-check - -const QUERY = 'pinbox::new'; - -const EXPECTED = { - 'others': [ - { 'path': 'std::pin::PinBox', 'name': 'new' }, - { 'path': 'alloc::pin::PinBox', 'name': 'new' }, - ], -}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-js/vec-new.js rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-js/vec-new.js --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-js/vec-new.js 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-js/vec-new.js 2018-12-04 23:41:40.000000000 +0000 @@ -14,6 +14,5 @@ 'others': [ { 'path': 'std::vec::Vec', 'name': 'new' }, { 'path': 'std::vec::Vec', 'name': 'ne' }, - { 'path': 'std::pin::PinBox', 'name': 'new' }, ], }; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,13 +1,13 @@ error: `[v2]` cannot be resolved, ignoring it... --> $DIR/deny-intra-link-resolution-failure.rs:13:6 | -13 | /// [v2] //~ ERROR +LL | /// [v2] //~ ERROR | ^^ cannot be resolved, ignoring | note: lint level defined here --> $DIR/deny-intra-link-resolution-failure.rs:11:9 | -11 | #![deny(intra_doc_link_resolution_failure)] +LL | #![deny(intra_doc_link_resolution_failure)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-ui/deprecated-attrs.stderr rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-ui/deprecated-attrs.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-ui/deprecated-attrs.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-ui/deprecated-attrs.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,9 +1,9 @@ warning: the `#![doc(no_default_passes)]` attribute is considered deprecated - | - = warning: please see https://github.com/rust-lang/rust/issues/44136 - = help: you may want to use `#![doc(document_private_items)]` + | + = warning: please see https://github.com/rust-lang/rust/issues/44136 + = help: you may want to use `#![doc(document_private_items)]` warning: the `#![doc(passes = "...")]` attribute is considered deprecated - | - = warning: please see https://github.com/rust-lang/rust/issues/44136 + | + = warning: please see https://github.com/rust-lang/rust/issues/44136 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-ui/doc-without-codeblock.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-ui/doc-without-codeblock.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-ui/doc-without-codeblock.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-ui/doc-without-codeblock.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(missing_doc_code_examples)] + +/// Some docs. +pub struct Foo; + +/// And then, the princess died. +pub mod foo { + /// Or maybe not because she saved herself! + pub fn bar() {} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-ui/doc-without-codeblock.stderr rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-ui/doc-without-codeblock.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-ui/doc-without-codeblock.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-ui/doc-without-codeblock.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +error: Missing code example in this documentation + | +note: lint level defined here + --> $DIR/doc-without-codeblock.rs:11:9 + | +LL | #![deny(missing_doc_code_examples)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: Missing code example in this documentation + --> $DIR/doc-without-codeblock.rs:13:1 + | +LL | /// Some docs. + | ^^^^^^^^^^^^^^ + +error: Missing code example in this documentation + --> $DIR/doc-without-codeblock.rs:16:1 + | +LL | /// And then, the princess died. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: Missing code example in this documentation + --> $DIR/doc-without-codeblock.rs:18:5 + | +LL | /// Or maybe not because she saved herself! + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-ui/failed-doctest-output.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-ui/failed-doctest-output.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-ui/failed-doctest-output.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-ui/failed-doctest-output.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,6 +15,7 @@ // compile-flags:--test // normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR" // failure-status: 101 +// rustc-env:RUST_BACKTRACE=0 // doctest fails at runtime /// ``` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-ui/failed-doctest-output.stdout rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-ui/failed-doctest-output.stdout --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-ui/failed-doctest-output.stdout 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-ui/failed-doctest-output.stdout 2018-12-04 23:41:40.000000000 +0000 @@ -1,22 +1,22 @@ running 2 tests -test $DIR/failed-doctest-output.rs - OtherStruct (line 26) ... FAILED -test $DIR/failed-doctest-output.rs - SomeStruct (line 20) ... FAILED +test $DIR/failed-doctest-output.rs - OtherStruct (line 27) ... FAILED +test $DIR/failed-doctest-output.rs - SomeStruct (line 21) ... FAILED failures: ----- $DIR/failed-doctest-output.rs - OtherStruct (line 26) stdout ---- +---- $DIR/failed-doctest-output.rs - OtherStruct (line 27) stdout ---- error[E0425]: cannot find value `no` in this scope - --> $DIR/failed-doctest-output.rs:27:1 + --> $DIR/failed-doctest-output.rs:28:1 | 3 | no | ^^ not found in this scope -thread '$DIR/failed-doctest-output.rs - OtherStruct (line 26)' panicked at 'couldn't compile the test', librustdoc/test.rs:332:13 +thread '$DIR/failed-doctest-output.rs - OtherStruct (line 27)' panicked at 'couldn't compile the test', librustdoc/test.rs:332:13 note: Run with `RUST_BACKTRACE=1` for a backtrace. ----- $DIR/failed-doctest-output.rs - SomeStruct (line 20) stdout ---- -thread '$DIR/failed-doctest-output.rs - SomeStruct (line 20)' panicked at 'test executable failed: +---- $DIR/failed-doctest-output.rs - SomeStruct (line 21) stdout ---- +thread '$DIR/failed-doctest-output.rs - SomeStruct (line 21)' panicked at 'test executable failed: thread 'main' panicked at 'oh no', $DIR/failed-doctest-output.rs:3:1 note: Run with `RUST_BACKTRACE=1` for a backtrace. @@ -25,8 +25,8 @@ failures: - $DIR/failed-doctest-output.rs - OtherStruct (line 26) - $DIR/failed-doctest-output.rs - SomeStruct (line 20) + $DIR/failed-doctest-output.rs - OtherStruct (line 27) + $DIR/failed-doctest-output.rs - SomeStruct (line 21) test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-ui/intra-doc-alias-ice.stderr rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-ui/intra-doc-alias-ice.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-ui/intra-doc-alias-ice.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-ui/intra-doc-alias-ice.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,13 +1,13 @@ error: `[TypeAlias::hoge]` cannot be resolved, ignoring it... --> $DIR/intra-doc-alias-ice.rs:15:30 | -15 | /// [broken cross-reference](TypeAlias::hoge) //~ ERROR +LL | /// [broken cross-reference](TypeAlias::hoge) //~ ERROR | ^^^^^^^^^^^^^^^ cannot be resolved, ignoring | note: lint level defined here --> $DIR/intra-doc-alias-ice.rs:11:9 | -11 | #![deny(intra_doc_link_resolution_failure)] +LL | #![deny(intra_doc_link_resolution_failure)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-ui/intra-links-warning.stderr rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-ui/intra-links-warning.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-ui/intra-links-warning.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-ui/intra-links-warning.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,7 +1,7 @@ warning: `[Foo::baz]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:13:23 | -13 | //! Test with [Foo::baz], [Bar::foo], ... +LL | //! Test with [Foo::baz], [Bar::foo], ... | ^^^^^^^^ cannot be resolved, ignoring | = note: #[warn(intra_doc_link_resolution_failure)] on by default @@ -10,7 +10,7 @@ warning: `[Bar::foo]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:13:35 | -13 | //! Test with [Foo::baz], [Bar::foo], ... +LL | //! Test with [Foo::baz], [Bar::foo], ... | ^^^^^^^^ cannot be resolved, ignoring | = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` @@ -18,7 +18,7 @@ warning: `[Uniooon::X]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:14:13 | -14 | //! , [Uniooon::X] and [Qux::Z]. +LL | //! , [Uniooon::X] and [Qux::Z]. | ^^^^^^^^^^ cannot be resolved, ignoring | = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` @@ -26,7 +26,7 @@ warning: `[Qux::Z]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:14:30 | -14 | //! , [Uniooon::X] and [Qux::Z]. +LL | //! , [Uniooon::X] and [Qux::Z]. | ^^^^^^ cannot be resolved, ignoring | = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` @@ -34,7 +34,7 @@ warning: `[Uniooon::X]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:16:14 | -16 | //! , [Uniooon::X] and [Qux::Z]. +LL | //! , [Uniooon::X] and [Qux::Z]. | ^^^^^^^^^^ cannot be resolved, ignoring | = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` @@ -42,7 +42,7 @@ warning: `[Qux::Z]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:16:31 | -16 | //! , [Uniooon::X] and [Qux::Z]. +LL | //! , [Uniooon::X] and [Qux::Z]. | ^^^^^^ cannot be resolved, ignoring | = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` @@ -50,7 +50,7 @@ warning: `[Qux:Y]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:18:13 | -18 | /// [Qux:Y] +LL | /// [Qux:Y] | ^^^^^ cannot be resolved, ignoring | = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` @@ -58,7 +58,7 @@ warning: `[BarA]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:24:10 | -24 | /// bar [BarA] bar +LL | /// bar [BarA] bar | ^^^^ cannot be resolved, ignoring | = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` @@ -66,11 +66,11 @@ warning: `[BarB]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:28:1 | -28 | / /** -29 | | * Foo -30 | | * bar [BarB] bar -31 | | * baz -32 | | */ +LL | / /** +LL | | * Foo +LL | | * bar [BarB] bar +LL | | * baz +LL | | */ | |___^ | = note: the link appears in this line: @@ -82,13 +82,13 @@ warning: `[BarC]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:35:1 | -35 | / /** Foo -36 | | -37 | | bar [BarC] bar -38 | | baz +LL | / /** Foo +LL | | +LL | | bar [BarC] bar +LL | | baz ... | -44 | | -45 | | */ +LL | | +LL | | */ | |__^ | = note: the link appears in this line: @@ -100,7 +100,7 @@ warning: `[BarD]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:48:1 | -48 | #[doc = "Foo/nbar [BarD] bar/nbaz"] +LL | #[doc = "Foo/nbar [BarD] bar/nbaz"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the link appears in this line: @@ -112,10 +112,10 @@ warning: `[BarF]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:53:9 | -53 | #[doc = $f] +LL | #[doc = $f] | ^^^^^^^^^^^ ... -57 | f!("Foo/nbar [BarF] bar/nbaz"); +LL | f!("Foo/nbar [BarF] bar/nbaz"); | ------------------------------- in this macro invocation | = note: the link appears in this line: diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-ui/invalid-syntax.rs rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-ui/invalid-syntax.rs --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-ui/invalid-syntax.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-ui/invalid-syntax.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// compile-flags: --error-format=human + +/// ``` +/// \__________pkt->size___________/ \_result->size_/ \__pkt->size__/ +/// ``` +pub fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-ui/invalid-syntax.stderr rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-ui/invalid-syntax.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/rustdoc-ui/invalid-syntax.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/rustdoc-ui/invalid-syntax.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +Output from rustc: +error: unknown start of token: / + --> :1:1 + | +1 | /__________pkt->size___________/ /_result->size_/ /__pkt->size__/ + | ^ + +warning: Invalid doc comment starting with: `/__________pkt->size___________/ /_result->size_/ /__pkt->size__/` +(Ignoring this codeblock) + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/absolute-paths-in-nested-use-groups.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/absolute-paths-in-nested-use-groups.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/absolute-paths-in-nested-use-groups.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/absolute-paths-in-nested-use-groups.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,16 +1,16 @@ -error[E0433]: failed to resolve. crate root in paths can only be used in start position +error[E0433]: failed to resolve: crate root in paths can only be used in start position --> $DIR/absolute-paths-in-nested-use-groups.rs:16:5 | LL | ::bar, //~ ERROR crate root in paths can only be used in start position | ^ crate root in paths can only be used in start position -error[E0433]: failed to resolve. `super` in paths can only be used in start position +error[E0433]: failed to resolve: `super` in paths can only be used in start position --> $DIR/absolute-paths-in-nested-use-groups.rs:17:5 | LL | super::bar, //~ ERROR `super` in paths can only be used in start position | ^^^^^ `super` in paths can only be used in start position -error[E0433]: failed to resolve. `self` in paths can only be used in start position +error[E0433]: failed to resolve: `self` in paths can only be used in start position --> $DIR/absolute-paths-in-nested-use-groups.rs:18:5 | LL | self::bar, //~ ERROR `self` in paths can only be used in start position diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/access-mode-in-closures.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/access-mode-in-closures.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/access-mode-in-closures.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/access-mode-in-closures.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -13,6 +13,18 @@ LL | match *s { sty(v) => v } //~ ERROR cannot move out | ^ -error: aborting due to previous error +error[E0507]: cannot move out of `s.0` which is behind a `&` reference + --> $DIR/access-mode-in-closures.rs:19:24 + | +LL | let _foo = unpack(|s| { + | - help: consider changing this to be a mutable reference: `&mut sty` +LL | // Test that `s` is moved here. +LL | match *s { sty(v) => v } //~ ERROR cannot move out + | ^ + | | + | cannot move out of `s.0` which is behind a `&` reference + | `s` is a `&` reference, so the data it refers to cannot be moved + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/asm/asm-out-assign-imm.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/asm/asm-out-assign-imm.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/asm/asm-out-assign-imm.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/asm/asm-out-assign-imm.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/asm-out-assign-imm.rs:34:9 + --> $DIR/asm-out-assign-imm.rs:34:34 | LL | let x: isize; | - help: make this binding mutable: `mut x` @@ -7,7 +7,7 @@ | ----- first assignment to `x` ... LL | asm!("mov $1, $0" : "=r"(x) : "r"(5)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable + | ^ cannot assign twice to immutable variable error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/asm/asm-out-assign-imm.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/asm/asm-out-assign-imm.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/asm/asm-out-assign-imm.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/asm/asm-out-assign-imm.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,11 +1,11 @@ error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/asm-out-assign-imm.rs:34:9 + --> $DIR/asm-out-assign-imm.rs:34:34 | LL | x = 1; | ----- first assignment to `x` ... LL | asm!("mov $1, $0" : "=r"(x) : "r"(5)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable + | ^ cannot assign twice to immutable variable error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/associated-types/associated-types-in-ambiguous-context.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/associated-types/associated-types-in-ambiguous-context.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/associated-types/associated-types-in-ambiguous-context.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/associated-types/associated-types-in-ambiguous-context.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,25 +2,19 @@ --> $DIR/associated-types-in-ambiguous-context.rs:16:36 | LL | fn get(x: T, y: U) -> Get::Value {} - | ^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `::Value` + | ^^^^^^^^^^ help: use fully-qualified syntax: `::Value` error[E0223]: ambiguous associated type --> $DIR/associated-types-in-ambiguous-context.rs:25:10 | LL | type X = std::ops::Deref::Target; - | ^^^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `::Target` + | ^^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `::Target` error[E0223]: ambiguous associated type --> $DIR/associated-types-in-ambiguous-context.rs:21:23 | LL | fn grab(&self) -> Grab::Value; - | ^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `::Value` + | ^^^^^^^^^^^ help: use fully-qualified syntax: `::Value` error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:32:29 - | -LL | fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>( - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -... -LL | let z: I::A = if cond { x } else { y }; - | ^ assignment requires that `'a` must outlive `'b` - -error: unsatisfied lifetime constraints - --> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:32:40 - | -LL | fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>( - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -... -LL | let z: I::A = if cond { x } else { y }; - | ^ assignment requires that `'b` must outlive `'a` - -error: aborting due to 2 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/associated-types/associated-types-subtyping-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/associated-types/associated-types-subtyping-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/associated-types/associated-types-subtyping-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/associated-types/associated-types-subtyping-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - #![allow(unused_variables)] +fn make_any() -> T { loop {} } + trait Trait<'a> { type Type; @@ -22,8 +22,8 @@ where T : for<'z> Trait<'z>, 'a : 'b { // Note that &'static T <: &'a T. - let a: >::Type = loop { }; - let b: >::Type = loop { }; + let a: >::Type = make_any(); + let b: >::Type = make_any(); let _c: >::Type = a; } @@ -31,8 +31,8 @@ where T : for<'z> Trait<'z>, 'a : 'b { // Note that &'static T <: &'a T. - let a: >::Type = loop { }; - let b: >::Type = loop { }; + let a: >::Type = make_any(); + let b: >::Type = make_any(); let _c: >::Type = a; //~ ERROR E0623 } @@ -40,8 +40,8 @@ where T : for<'z> Trait<'z>, 'a : 'b { // Note that &'static T <: &'a T. - let a: >::Type = loop { }; - let b: >::Type = loop { }; + let a: >::Type = make_any(); + let b: >::Type = make_any(); let _c: >::Type = b; //~ ERROR E0623 } @@ -49,8 +49,8 @@ where T : for<'z> Trait<'z>, 'a : 'b { // Note that &'static T <: &'a T. - let a: >::Type = loop { }; - let b: >::Type = loop { }; + let a: >::Type = make_any(); + let b: >::Type = make_any(); let _c: >::Type = b; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/associated-types/bound-lifetime-in-binding-only.elision.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/associated-types/bound-lifetime-in-binding-only.elision.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/associated-types/bound-lifetime-in-binding-only.elision.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/associated-types/bound-lifetime-in-binding-only.elision.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,10 +2,9 @@ --> $DIR/bound-lifetime-in-binding-only.rs:62:23 | LL | fn elision &i32>() { - | ^ expected lifetime parameter + | ^ help: consider giving it a 'static lifetime: `&'static` | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from - = help: consider giving it a 'static lifetime error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/associated-types/bound-lifetime-in-return-only.elision.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/associated-types/bound-lifetime-in-return-only.elision.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/associated-types/bound-lifetime-in-return-only.elision.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/associated-types/bound-lifetime-in-return-only.elision.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,10 +2,9 @@ --> $DIR/bound-lifetime-in-return-only.rs:44:23 | LL | fn elision(_: fn() -> &i32) { - | ^ expected lifetime parameter + | ^ help: consider giving it a 'static lifetime: `&'static` | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from - = help: consider giving it a 'static lifetime error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/project-fn-ret-contravariant.rs:53:12 - | -LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | let a = bar(foo, y); - | ^^^^^^^^^^^ assignment requires that `'b` must outlive `'a` - -error: unsatisfied lifetime constraints - --> $DIR/project-fn-ret-contravariant.rs:54:12 - | -LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | let a = bar(foo, y); -LL | let b = bar(foo, x); - | ^^^^^^^^^^^ assignment requires that `'a` must outlive `'b` - -error: aborting due to 2 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/associated-types/cache/project-fn-ret-contravariant.transmute.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/project-fn-ret-contravariant.rs:48:4 - | -LL | fn baz<'a,'b>(x: &'a u32) -> &'static u32 { - | -- lifetime `'a` defined here -LL | bar(foo, x) //[transmute]~ ERROR E0495 - | ^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` - -error: unsatisfied lifetime constraints - --> $DIR/project-fn-ret-contravariant.rs:48:4 - | -LL | fn baz<'a,'b>(x: &'a u32) -> &'static u32 { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | bar(foo, x) //[transmute]~ ERROR E0495 - | ^^^^^^^^^^^ requires that `'a` must outlive `'b` - -error: aborting due to 2 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/associated-types/cache/project-fn-ret-invariant.krisskross.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/project-fn-ret-invariant.rs:63:12 - | -LL | fn transmute<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | let a = bar(foo, y); //[krisskross]~ ERROR E0623 - | ^^^^^^^^^^^ assignment requires that `'b` must outlive `'a` - -error: unsatisfied lifetime constraints - --> $DIR/project-fn-ret-invariant.rs:64:12 - | -LL | fn transmute<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | let a = bar(foo, y); //[krisskross]~ ERROR E0623 -LL | let b = bar(foo, x); - | ^^^^^^^^^^^ assignment requires that `'a` must outlive `'b` - -error: aborting due to 2 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/associated-types/cache/project-fn-ret-invariant.oneuse.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/project-fn-ret-invariant.rs:48:12 - | -LL | fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | let f = foo; // <-- No consistent type can be inferred for `f` here. -LL | let a = bar(f, x); - | ^^^^^^^^^ argument requires that `'a` must outlive `'b` - -error: unsatisfied lifetime constraints - --> $DIR/project-fn-ret-invariant.rs:49:12 - | -LL | fn baz<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -... -LL | let b = bar(f, y); //[oneuse]~ ERROR 49:19: 49:20: lifetime mismatch [E0623] - | ^^^^^^^^^ argument requires that `'b` must outlive `'a` - -error: aborting due to 2 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/associated-types/cache/project-fn-ret-invariant.transmute.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/project-fn-ret-invariant.rs:58:4 - | -LL | fn baz<'a,'b>(x: Type<'a>) -> Type<'static> { - | -- lifetime `'a` defined here -... -LL | bar(foo, x) //[transmute]~ ERROR E0495 - | ^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` - -error: unsatisfied lifetime constraints - --> $DIR/project-fn-ret-invariant.rs:58:13 - | -LL | fn baz<'a,'b>(x: Type<'a>) -> Type<'static> { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -... -LL | bar(foo, x) //[transmute]~ ERROR E0495 - | ^ requires that `'a` must outlive `'b` - -error: aborting due to 2 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/auxiliary/namespaced_enums.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/auxiliary/namespaced_enums.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/auxiliary/namespaced_enums.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/auxiliary/namespaced_enums.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub enum Foo { - A, - B(isize), - C { a: isize }, -} - -impl Foo { - pub fn foo() {} - pub fn bar(&self) {} -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/await-keyword/2015-edition-no-warnings-with-feature-gate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/await-keyword/2015-edition-no-warnings-with-feature-gate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/await-keyword/2015-edition-no-warnings-with-feature-gate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/await-keyword/2015-edition-no-warnings-with-feature-gate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// compile-pass + +#![feature(async_await)] +#![allow(non_camel_case_types)] +#![deny(keyword_idents)] + +mod outer_mod { + pub mod await { + pub struct await; + } +} +use outer_mod::await::await; + +fn main() { + match await { await => {} } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/await-keyword/2015-edition-warning.fixed rustc-1.31.0+dfsg1+llvm/src/test/ui/await-keyword/2015-edition-warning.fixed --- rustc-1.30.0+dfsg1+llvm/src/test/ui/await-keyword/2015-edition-warning.fixed 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/await-keyword/2015-edition-warning.fixed 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// run-rustfix + +#![allow(non_camel_case_types)] +#![deny(keyword_idents)] + +mod outer_mod { + pub mod r#await { + pub struct r#await; + } +} +use outer_mod::r#await::r#await; + +fn main() { + match r#await { r#await => {} } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/await-keyword/2015-edition-warning.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/await-keyword/2015-edition-warning.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/await-keyword/2015-edition-warning.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/await-keyword/2015-edition-warning.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// run-rustfix + +#![allow(non_camel_case_types)] +#![deny(keyword_idents)] + +mod outer_mod { + pub mod await { + pub struct await; + } +} +use outer_mod::await::await; + +fn main() { + match await { await => {} } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/await-keyword/2015-edition-warning.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/await-keyword/2015-edition-warning.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/await-keyword/2015-edition-warning.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/await-keyword/2015-edition-warning.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,61 @@ +error: `await` is a keyword in the 2018 edition + --> $DIR/2015-edition-warning.rs:7:13 + | +LL | pub mod await { + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + | +note: lint level defined here + --> $DIR/2015-edition-warning.rs:4:9 + | +LL | #![deny(keyword_idents)] + | ^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! + = note: for more information, see issue #49716 + +error: `await` is a keyword in the 2018 edition + --> $DIR/2015-edition-warning.rs:8:20 + | +LL | pub struct await; + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! + = note: for more information, see issue #49716 + +error: `await` is a keyword in the 2018 edition + --> $DIR/2015-edition-warning.rs:11:16 + | +LL | use outer_mod::await::await; + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! + = note: for more information, see issue #49716 + +error: `await` is a keyword in the 2018 edition + --> $DIR/2015-edition-warning.rs:11:23 + | +LL | use outer_mod::await::await; + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! + = note: for more information, see issue #49716 + +error: `await` is a keyword in the 2018 edition + --> $DIR/2015-edition-warning.rs:14:11 + | +LL | match await { await => {} } + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! + = note: for more information, see issue #49716 + +error: `await` is a keyword in the 2018 edition + --> $DIR/2015-edition-warning.rs:14:19 + | +LL | match await { await => {} } + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! + = note: for more information, see issue #49716 + +error: aborting due to 6 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/await-keyword/2018-edition-error.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/await-keyword/2018-edition-error.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/await-keyword/2018-edition-error.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/await-keyword/2018-edition-error.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// edition:2018 +#![allow(non_camel_case_types)] + +mod outer_mod { + pub mod await { + pub struct await; + } +} +use self::outer_mod::await::await; + +fn main() { + match await { await => () } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/await-keyword/2018-edition-error.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/await-keyword/2018-edition-error.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/await-keyword/2018-edition-error.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/await-keyword/2018-edition-error.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +error[E0721]: `await` is a keyword in the 2018 edition + --> $DIR/2018-edition-error.rs:5:13 + | +LL | pub mod await { + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + +error[E0721]: `await` is a keyword in the 2018 edition + --> $DIR/2018-edition-error.rs:6:20 + | +LL | pub struct await; + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + +error[E0721]: `await` is a keyword in the 2018 edition + --> $DIR/2018-edition-error.rs:9:22 + | +LL | use self::outer_mod::await::await; + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + +error[E0721]: `await` is a keyword in the 2018 edition + --> $DIR/2018-edition-error.rs:9:29 + | +LL | use self::outer_mod::await::await; + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + +error[E0721]: `await` is a keyword in the 2018 edition + --> $DIR/2018-edition-error.rs:12:11 + | +LL | match await { await => () } + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + +error[E0721]: `await` is a keyword in the 2018 edition + --> $DIR/2018-edition-error.rs:12:19 + | +LL | match await { await => () } + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0721`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/await-keyword/2018-edition-no-error-with-feature-gate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/await-keyword/2018-edition-no-error-with-feature-gate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/await-keyword/2018-edition-no-error-with-feature-gate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/await-keyword/2018-edition-no-error-with-feature-gate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// compile-pass +// edition:2018 + +#![allow(non_camel_case_types)] +#![feature(async_await)] + +mod outer_mod { + pub mod await { + pub struct await; + } +} +use self::outer_mod::await::await; + +fn main() { + match await { await => () } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/await-keyword/post_expansion_error.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/await-keyword/post_expansion_error.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/await-keyword/post_expansion_error.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/await-keyword/post_expansion_error.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +// edition:2018 + +macro_rules! r#await { + () => { println!("Hello, world!") } +} + +fn main() { + await!() +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/await-keyword/post_expansion_error.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/await-keyword/post_expansion_error.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/await-keyword/post_expansion_error.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/await-keyword/post_expansion_error.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0721]: `await` is a keyword in the 2018 edition + --> $DIR/post_expansion_error.rs:8:5 + | +LL | await!() + | ^^^^^ help: you can use a raw identifier to stay compatible: `r#await` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0721`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/bad/bad-module.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/bad/bad-module.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/bad/bad-module.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/bad/bad-module.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,8 +10,8 @@ fn main() { let foo = thing::len(Vec::new()); - //~^ ERROR failed to resolve. Use of undeclared type or module `thing` + //~^ ERROR failed to resolve: use of undeclared type or module `thing` let foo = foo::bar::baz(); - //~^ ERROR failed to resolve. Use of undeclared type or module `foo` + //~^ ERROR failed to resolve: use of undeclared type or module `foo` } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/bad/bad-module.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/bad/bad-module.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/bad/bad-module.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/bad/bad-module.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,14 +1,14 @@ -error[E0433]: failed to resolve. Use of undeclared type or module `thing` +error[E0433]: failed to resolve: use of undeclared type or module `thing` --> $DIR/bad-module.rs:12:15 | LL | let foo = thing::len(Vec::new()); - | ^^^^^ Use of undeclared type or module `thing` + | ^^^^^ use of undeclared type or module `thing` -error[E0433]: failed to resolve. Use of undeclared type or module `foo` +error[E0433]: failed to resolve: use of undeclared type or module `foo` --> $DIR/bad-module.rs:15:15 | LL | let foo = foo::bar::baz(); - | ^^^ Use of undeclared type or module `foo` + | ^^^ use of undeclared type or module `foo` error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/bind-by-move/bind-by-move-no-guards.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/bind-by-move/bind-by-move-no-guards.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/bind-by-move/bind-by-move-no-guards.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/bind-by-move/bind-by-move-no-guards.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0008]: cannot bind by-move into a pattern guard + --> $DIR/bind-by-move-no-guards.rs:8:14 + | +LL | Some(z) if z.recv().unwrap() => { panic!() }, + | ^ moves value into pattern guard + | + = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0008`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/bind-by-move/bind-by-move-no-guards.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/bind-by-move/bind-by-move-no-guards.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/bind-by-move/bind-by-move-no-guards.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/bind-by-move/bind-by-move-no-guards.rs 2018-12-04 23:41:40.000000000 +0000 @@ -1,13 +1,3 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - use std::sync::mpsc::channel; fn main() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/bind-by-move/bind-by-move-no-guards.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/bind-by-move/bind-by-move-no-guards.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/bind-by-move/bind-by-move-no-guards.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/bind-by-move/bind-by-move-no-guards.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error[E0008]: cannot bind by-move into a pattern guard - --> $DIR/bind-by-move-no-guards.rs:18:14 + --> $DIR/bind-by-move-no-guards.rs:8:14 | LL | Some(z) if z.recv().unwrap() => { panic!() }, | ^ moves value into pattern guard diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/binop/binop-move-semantics.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/binop/binop-move-semantics.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/binop/binop-move-semantics.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/binop/binop-move-semantics.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -32,6 +32,18 @@ LL | *n; //~ ERROR: cannot move out of borrowed content | ^^ cannot move out of borrowed content +error[E0507]: cannot move out of `*n` which is behind a `&` reference + --> $DIR/binop-move-semantics.rs:42:5 + | +LL | let n = &y; + | -- help: consider changing this to be a mutable reference: `&mut y` +... +LL | *n; //~ ERROR: cannot move out of borrowed content + | ^^ + | | + | cannot move out of `*n` which is behind a `&` reference + | `n` is a `&` reference, so the data it refers to cannot be moved + error[E0502]: cannot borrow `f` as immutable because it is also borrowed as mutable --> $DIR/binop-move-semantics.rs:64:5 | @@ -44,7 +56,7 @@ LL | | &f; //~ ERROR: cannot borrow `f` as immutable because it is also borrowed as mutable | | ^- | |_____|| - | |borrow later used here + | |mutable borrow later used here | immutable borrow occurs here error[E0502]: cannot borrow `f` as mutable because it is also borrowed as immutable @@ -59,10 +71,10 @@ LL | | &mut f; //~ ERROR: cannot borrow `f` as mutable because it is also borrowed as immutable | | ^^^^^- | |_____|____| - | | borrow later used here + | | immutable borrow later used here | mutable borrow occurs here -error: aborting due to 6 previous errors +error: aborting due to 7 previous errors Some errors occurred: E0382, E0502, E0507. For more information about an error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/blind/blind-item-block-item-shadow.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/blind/blind-item-block-item-shadow.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/blind/blind-item-block-item-shadow.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/blind/blind-item-block-item-shadow.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^^^^^^^ `Bar` reimported here | = note: `Bar` must be defined only once in the type namespace of this block -help: You can use `as` to change the binding name of the import +help: you can use `as` to change the binding name of the import | LL | use foo::Bar as OtherBar; | ^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/blind/blind-item-item-shadow.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/blind/blind-item-item-shadow.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/blind/blind-item-item-shadow.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/blind/blind-item-item-shadow.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | ^^^^^^^^ `foo` reimported here | = note: `foo` 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 +help: you can use `as` to change the binding name of the import | LL | use foo::foo as other_foo; | ^^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/block-result/unexpected-return-on-unit.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/block-result/unexpected-return-on-unit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/block-result/unexpected-return-on-unit.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/block-result/unexpected-return-on-unit.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Test that we do some basic error correcton in the tokeniser (and don't spew +// Test that we do some basic error correction in the tokeniser (and don't spew // too many bogus errors). fn foo() -> usize { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/assign_mutable_fields.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/assign_mutable_fields.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/assign_mutable_fields.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/assign_mutable_fields.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,9 +1,15 @@ -error[E0381]: use of possibly uninitialized variable: `x` - --> $DIR/assign_mutable_fields.rs:29:10 +error[E0381]: assign to part of possibly uninitialized variable: `x` + --> $DIR/assign_mutable_fields.rs:19:5 | -LL | drop(x); //~ ERROR - | ^ use of possibly uninitialized `x` +LL | x.0 = 1; + | ^^^^^^^ use of possibly uninitialized `x` -error: aborting due to previous error +error[E0381]: assign to part of possibly uninitialized variable: `x` + --> $DIR/assign_mutable_fields.rs:27:5 + | +LL | x.0 = 1; + | ^^^^^^^ use of possibly uninitialized `x` + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0381`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-anon-fields-struct.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-anon-fields-struct.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-anon-fields-struct.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-anon-fields-struct.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,27 +1,3 @@ -error[E0502]: cannot borrow `y` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-anon-fields-struct.rs:23:19 - | -LL | Y(ref mut a, _) => a - | --------- mutable borrow occurs here -... -LL | let b = match y { - | ^ immutable borrow occurs here -... -LL | *a += 1; - | ------- borrow later used here - -error[E0502]: cannot borrow `y` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-anon-fields-struct.rs:38:19 - | -LL | Y(ref mut a, _) => a - | --------- mutable borrow occurs here -... -LL | let b = match y { - | ^ immutable borrow occurs here -... -LL | *a += 1; - | ------- borrow later used here - error[E0499]: cannot borrow `y.0` as mutable more than once at a time --> $DIR/borrowck-anon-fields-struct.rs:39:11 | @@ -32,9 +8,8 @@ | ^^^^^^^^^ second mutable borrow occurs here ... LL | *a += 1; - | ------- borrow later used here + | ------- first borrow later used here -error: aborting due to 3 previous errors +error: aborting due to previous error -Some errors occurred: E0499, E0502. -For more information about an error, try `rustc --explain E0499`. +For more information about this error, try `rustc --explain E0499`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-anon-fields-tuple.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-anon-fields-tuple.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-anon-fields-tuple.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-anon-fields-tuple.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,27 +1,3 @@ -error[E0502]: cannot borrow `y` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-anon-fields-tuple.rs:21:19 - | -LL | (ref mut a, _) => a - | --------- mutable borrow occurs here -... -LL | let b = match y { - | ^ immutable borrow occurs here -... -LL | *a += 1; - | ------- borrow later used here - -error[E0502]: cannot borrow `y` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-anon-fields-tuple.rs:36:19 - | -LL | (ref mut a, _) => a - | --------- mutable borrow occurs here -... -LL | let b = match y { - | ^ immutable borrow occurs here -... -LL | *a += 1; - | ------- borrow later used here - error[E0499]: cannot borrow `y.0` as mutable more than once at a time --> $DIR/borrowck-anon-fields-tuple.rs:37:10 | @@ -32,9 +8,8 @@ | ^^^^^^^^^ second mutable borrow occurs here ... LL | *a += 1; - | ------- borrow later used here + | ------- first borrow later used here -error: aborting due to 3 previous errors +error: aborting due to previous error -Some errors occurred: E0499, E0502. -For more information about an error, try `rustc --explain E0499`. +For more information about this error, try `rustc --explain E0499`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-anon-fields-variant.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-anon-fields-variant.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-anon-fields-variant.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-anon-fields-variant.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,27 +1,3 @@ -error[E0502]: cannot borrow `y` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-anon-fields-variant.rs:26:19 - | -LL | Foo::Y(ref mut a, _) => a, - | --------- mutable borrow occurs here -... -LL | let b = match y { - | ^ immutable borrow occurs here -... -LL | *a += 1; - | ------- borrow later used here - -error[E0502]: cannot borrow `y` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-anon-fields-variant.rs:43:19 - | -LL | Foo::Y(ref mut a, _) => a, - | --------- mutable borrow occurs here -... -LL | let b = match y { - | ^ immutable borrow occurs here -... -LL | *a += 1; - | ------- borrow later used here - error[E0499]: cannot borrow `y.0` as mutable more than once at a time --> $DIR/borrowck-anon-fields-variant.rs:44:14 | @@ -32,9 +8,8 @@ | ^^^^^^^^^ second mutable borrow occurs here ... LL | *a += 1; - | ------- borrow later used here + | ------- first borrow later used here -error: aborting due to 3 previous errors +error: aborting due to previous error -Some errors occurred: E0499, E0502. -For more information about an error, try `rustc --explain E0499`. +For more information about this error, try `rustc --explain E0499`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-asm.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-asm.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-asm.ast.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-asm.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -22,7 +22,7 @@ | - borrow later used here error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-asm.rs:54:13 + --> $DIR/borrowck-asm.rs:54:31 | LL | let x = 3; | - @@ -31,10 +31,10 @@ | help: make this binding mutable: `mut x` LL | unsafe { LL | asm!("nop" : "=r"(x)); //[ast]~ ERROR cannot assign twice - | ^^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable + | ^ cannot assign twice to immutable variable error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-asm.rs:70:13 + --> $DIR/borrowck-asm.rs:70:31 | LL | let x = 3; | - @@ -43,22 +43,22 @@ | help: make this binding mutable: `mut x` LL | unsafe { LL | asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign twice - | ^^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable + | ^ cannot assign twice to immutable variable error[E0381]: use of possibly uninitialized variable: `x` - --> $DIR/borrowck-asm.rs:78:13 + --> $DIR/borrowck-asm.rs:78:32 | LL | asm!("nop" : "=*r"(x)); //[ast]~ ERROR use of possibly uninitialized variable - | ^^^^^^^^^^^^^^^^^^^^^^^ use of possibly uninitialized `x` + | ^ use of possibly uninitialized `x` error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-asm.rs:87:13 + --> $DIR/borrowck-asm.rs:87:31 | LL | let y = &*x; | --- borrow of `x` occurs here LL | unsafe { LL | asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign to `x` because it is borrowed - | ^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `x` occurs here + | ^ assignment to borrowed `x` occurs here ... LL | let z = y; | - borrow later used here diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-asm.ast.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-asm.ast.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-asm.ast.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-asm.ast.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -19,31 +19,31 @@ | ^ use of borrowed `x` error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-asm.rs:54:13 + --> $DIR/borrowck-asm.rs:54:31 | LL | let x = 3; | - first assignment to `x` LL | unsafe { LL | asm!("nop" : "=r"(x)); //[ast]~ ERROR cannot assign twice - | ^^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable + | ^ cannot assign twice to immutable variable error[E0506]: cannot assign to `a` because it is borrowed - --> $DIR/borrowck-asm.rs:60:13 + --> $DIR/borrowck-asm.rs:60:31 | LL | let b = &*a; | -- borrow of `a` occurs here LL | unsafe { LL | asm!("nop" : "=r"(a)); //[ast]~ ERROR cannot assign to `a` because it is borrowed - | ^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `a` occurs here + | ^ assignment to borrowed `a` occurs here error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-asm.rs:70:13 + --> $DIR/borrowck-asm.rs:70:31 | LL | let x = 3; | - first assignment to `x` LL | unsafe { LL | asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign twice - | ^^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable + | ^ cannot assign twice to immutable variable error[E0381]: use of possibly uninitialized variable: `x` --> $DIR/borrowck-asm.rs:78:32 @@ -52,13 +52,13 @@ | ^ use of possibly uninitialized `x` error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-asm.rs:87:13 + --> $DIR/borrowck-asm.rs:87:31 | LL | let y = &*x; | -- borrow of `x` occurs here LL | unsafe { LL | asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign to `x` because it is borrowed - | ^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `x` occurs here + | ^ assignment to borrowed `x` occurs here error[E0382]: use of moved value: `x` --> $DIR/borrowck-asm.rs:96:40 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-asm.mir.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-asm.mir.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-asm.mir.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-asm.mir.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -22,7 +22,7 @@ | - borrow later used here error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-asm.rs:54:13 + --> $DIR/borrowck-asm.rs:54:31 | LL | let x = 3; | - @@ -31,10 +31,10 @@ | help: make this binding mutable: `mut x` LL | unsafe { LL | asm!("nop" : "=r"(x)); //[ast]~ ERROR cannot assign twice - | ^^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable + | ^ cannot assign twice to immutable variable error[E0384]: cannot assign twice to immutable variable `x` - --> $DIR/borrowck-asm.rs:70:13 + --> $DIR/borrowck-asm.rs:70:31 | LL | let x = 3; | - @@ -43,22 +43,22 @@ | help: make this binding mutable: `mut x` LL | unsafe { LL | asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign twice - | ^^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable + | ^ cannot assign twice to immutable variable error[E0381]: use of possibly uninitialized variable: `x` - --> $DIR/borrowck-asm.rs:78:13 + --> $DIR/borrowck-asm.rs:78:32 | LL | asm!("nop" : "=*r"(x)); //[ast]~ ERROR use of possibly uninitialized variable - | ^^^^^^^^^^^^^^^^^^^^^^^ use of possibly uninitialized `x` + | ^ use of possibly uninitialized `x` error[E0506]: cannot assign to `x` because it is borrowed - --> $DIR/borrowck-asm.rs:87:13 + --> $DIR/borrowck-asm.rs:87:31 | LL | let y = &*x; | --- borrow of `x` occurs here LL | unsafe { LL | asm!("nop" : "+r"(x)); //[ast]~ ERROR cannot assign to `x` because it is borrowed - | ^^^^^^^^^^^^^^^^^^^^^^ assignment to borrowed `x` occurs here + | ^ assignment to borrowed `x` occurs here ... LL | let z = y; | - borrow later used here diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-assign-comp-idx.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-assign-comp-idx.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-assign-comp-idx.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-assign-comp-idx.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,19 +8,19 @@ | ^ mutable borrow occurs here LL | LL | println!("{}", *q); - | -- borrow later used here + | -- immutable borrow later used here error[E0502]: cannot borrow `p` as mutable because it is also borrowed as immutable --> $DIR/borrowck-assign-comp-idx.rs:37:9 | -LL | / borrow( -LL | | &p, - | | -- immutable borrow occurs here -LL | | || p[0] = 5); //~ ERROR cannot borrow `p` as mutable - | |_________^^_-_______- borrow later used here - | | | - | | second borrow occurs due to use of `p` in closure - | mutable borrow occurs here +LL | borrow( + | ------ immutable borrow later used by call +LL | &p, + | -- immutable borrow occurs here +LL | || p[0] = 5); //~ ERROR cannot borrow `p` as mutable + | ^^ - second borrow occurs due to use of `p` in closure + | | + | mutable borrow occurs here error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-autoref-3261.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-autoref-3261.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-autoref-3261.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-autoref-3261.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,21 +1,15 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-autoref-3261.rs:25:9 | -LL | (&mut x).with( - | -------- - | | - | _____first mutable borrow occurs here - | | -LL | | |opt| { //~ ERROR cannot borrow `x` as mutable more than once at a time - | | ^^^^^ second mutable borrow occurs here -LL | | match opt { -LL | | &Either::Right(ref f) => { -LL | | x = X(Either::Left((0, 0))); - | | - second borrow occurs due to use of `x` in closure -... | -LL | | } -LL | | }) - | |__________- borrow later used here +LL | (&mut x).with( + | -------- ---- first borrow later used by call + | | + | first mutable borrow occurs here +LL | |opt| { //~ ERROR cannot borrow `x` as mutable more than once at a time + | ^^^^^ second mutable borrow occurs here +... +LL | x = X(Either::Left((0, 0))); + | - second borrow occurs due to use of `x` in closure error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-bad-nested-calls-free.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-bad-nested-calls-free.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-bad-nested-calls-free.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-bad-nested-calls-free.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,24 +1,22 @@ error[E0502]: cannot borrow `a` as mutable because it is also borrowed as immutable --> $DIR/borrowck-bad-nested-calls-free.rs:35:17 | -LL | / add( -LL | | &*a, - | | --- immutable borrow occurs here -LL | | rewrite(&mut a)); //~ ERROR cannot borrow - | |_________________^^^^^^_- borrow later used here - | | - | mutable borrow occurs here +LL | add( + | --- immutable borrow later used by call +LL | &*a, + | --- immutable borrow occurs here +LL | rewrite(&mut a)); //~ ERROR cannot borrow + | ^^^^^^ mutable borrow occurs here error[E0502]: cannot borrow `a` as mutable because it is also borrowed as immutable --> $DIR/borrowck-bad-nested-calls-free.rs:42:17 | -LL | / add( -LL | | &*a, - | | --- immutable borrow occurs here -LL | | rewrite(&mut a)); //~ ERROR cannot borrow - | |_________________^^^^^^_- borrow later used here - | | - | mutable borrow occurs here +LL | add( + | --- immutable borrow later used by call +LL | &*a, + | --- immutable borrow occurs here +LL | rewrite(&mut a)); //~ ERROR cannot borrow + | ^^^^^^ mutable borrow occurs here error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-bad-nested-calls-move.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-bad-nested-calls-move.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-bad-nested-calls-move.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-bad-nested-calls-move.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,24 +1,22 @@ error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/borrowck-bad-nested-calls-move.rs:35:9 | -LL | / add( -LL | | &*a, - | | --- borrow of `*a` occurs here -LL | | a); //~ ERROR cannot move - | |_________^- borrow later used here - | | - | move out of `a` occurs here +LL | add( + | --- borrow later used by call +LL | &*a, + | --- borrow of `*a` occurs here +LL | a); //~ ERROR cannot move + | ^ move out of `a` occurs here error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/borrowck-bad-nested-calls-move.rs:42:9 | -LL | / add( -LL | | &*a, - | | --- borrow of `*a` occurs here -LL | | a); //~ ERROR cannot move - | |_________^- borrow later used here - | | - | move out of `a` occurs here +LL | add( + | --- borrow later used by call +LL | &*a, + | --- borrow of `*a` occurs here +LL | a); //~ ERROR cannot move + | ^ move out of `a` occurs here error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,10 +1,10 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/borrowck-borrowed-uniq-rvalue-2.rs:32:20 | LL | let x = defer(&vec!["Goodbye", "world!"]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - temporary value only lives until here + | ^^^^^^^^^^^^^^^^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | temporary value does not live long enough + | creates a temporary which is freed while still in use LL | x.x[0]; | ------ borrow later used here | @@ -13,4 +13,4 @@ error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,10 +1,10 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/borrowck-borrowed-uniq-rvalue.rs:20:28 | LL | buggy_map.insert(42, &*Box::new(1)); //~ ERROR borrowed value does not live long enough - | ^^^^^^^^^^^ - temporary value only lives until here + | ^^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | temporary value does not live long enough + | creates a temporary which is freed while still in use ... LL | buggy_map.insert(43, &*tmp); | --------- borrow later used here @@ -13,4 +13,4 @@ error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrow-from-owned-ptr.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -6,7 +6,7 @@ LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^^^^^ second mutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- first borrow later used here error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable --> $DIR/borrowck-borrow-from-owned-ptr.rs:36:17 @@ -16,7 +16,7 @@ LL | let _bar2 = &foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^ immutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- mutable borrow later used here error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable --> $DIR/borrowck-borrow-from-owned-ptr.rs:43:17 @@ -26,18 +26,7 @@ LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^^^^^ mutable borrow occurs here LL | *bar1; - | ----- borrow later used here - -error[E0502]: cannot borrow `*foo` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-borrow-from-owned-ptr.rs:72:11 - | -LL | let bar1 = &mut foo.bar1; - | ------------- mutable borrow occurs here -LL | match *foo { - | ^^^^ immutable borrow occurs here -... -LL | *bar1; - | ----- borrow later used here + | ----- immutable borrow later used here error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time --> $DIR/borrowck-borrow-from-owned-ptr.rs:73:21 @@ -49,7 +38,7 @@ | ^^^^^^^^^^^^^ second mutable borrow occurs here ... LL | *bar1; - | ----- borrow later used here + | ----- first borrow later used here error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable --> $DIR/borrowck-borrow-from-owned-ptr.rs:82:17 @@ -60,7 +49,7 @@ | ^^^^^^^^^ immutable borrow occurs here LL | let _foo2 = &*foo; //~ ERROR cannot borrow LL | *bar1; - | ----- borrow later used here + | ----- mutable borrow later used here error[E0502]: cannot borrow `*foo` as immutable because it is also borrowed as mutable --> $DIR/borrowck-borrow-from-owned-ptr.rs:83:17 @@ -71,7 +60,7 @@ LL | let _foo2 = &*foo; //~ ERROR cannot borrow | ^^^^^ immutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- mutable borrow later used here error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time --> $DIR/borrowck-borrow-from-owned-ptr.rs:90:17 @@ -81,7 +70,7 @@ LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^^^^^ second mutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- first borrow later used here error[E0499]: cannot borrow `*foo` as mutable more than once at a time --> $DIR/borrowck-borrow-from-owned-ptr.rs:97:17 @@ -91,7 +80,7 @@ LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow | ^^^^^^^^^ second mutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- first borrow later used here error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable --> $DIR/borrowck-borrow-from-owned-ptr.rs:104:17 @@ -101,7 +90,7 @@ LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^^^^^ mutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- immutable borrow later used here error[E0502]: cannot borrow `*foo` as mutable because it is also borrowed as immutable --> $DIR/borrowck-borrow-from-owned-ptr.rs:111:17 @@ -111,7 +100,7 @@ LL | let _foo2 = &mut *foo; //~ ERROR cannot borrow | ^^^^^^^^^ mutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- immutable borrow later used here error[E0596]: cannot borrow `foo.bar1` as mutable, as `foo` is not declared as mutable --> $DIR/borrowck-borrow-from-owned-ptr.rs:132:16 @@ -121,7 +110,7 @@ LL | let bar1 = &mut foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^^^^^ cannot borrow as mutable -error: aborting due to 12 previous errors +error: aborting due to 11 previous errors Some errors occurred: E0499, E0502, E0596. For more information about an error, try `rustc --explain E0499`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrow-from-stack-variable.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrow-from-stack-variable.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrow-from-stack-variable.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrow-from-stack-variable.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -6,7 +6,7 @@ LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^^^^^ second mutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- first borrow later used here error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable --> $DIR/borrowck-borrow-from-stack-variable.rs:35:17 @@ -16,7 +16,7 @@ LL | let _bar2 = &foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^ immutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- mutable borrow later used here error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable --> $DIR/borrowck-borrow-from-stack-variable.rs:42:17 @@ -26,18 +26,7 @@ LL | let _bar2 = &mut foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^^^^^ mutable borrow occurs here LL | *bar1; - | ----- borrow later used here - -error[E0502]: cannot borrow `foo` as immutable because it is also borrowed as mutable - --> $DIR/borrowck-borrow-from-stack-variable.rs:70:11 - | -LL | let bar1 = &mut foo.bar1; - | ------------- mutable borrow occurs here -LL | match foo { - | ^^^ immutable borrow occurs here -... -LL | *bar1; - | ----- borrow later used here + | ----- immutable borrow later used here error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time --> $DIR/borrowck-borrow-from-stack-variable.rs:71:21 @@ -49,7 +38,7 @@ | ^^^^^^^^^^^^^ second mutable borrow occurs here ... LL | *bar1; - | ----- borrow later used here + | ----- first borrow later used here error[E0502]: cannot borrow `foo.bar1` as immutable because it is also borrowed as mutable --> $DIR/borrowck-borrow-from-stack-variable.rs:80:17 @@ -60,7 +49,7 @@ | ^^^^^^^^^ immutable borrow occurs here LL | let _foo2 = &foo; //~ ERROR cannot borrow LL | *bar1; - | ----- borrow later used here + | ----- mutable borrow later used here error[E0502]: cannot borrow `foo` as immutable because it is also borrowed as mutable --> $DIR/borrowck-borrow-from-stack-variable.rs:81:17 @@ -71,7 +60,7 @@ LL | let _foo2 = &foo; //~ ERROR cannot borrow | ^^^^ immutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- mutable borrow later used here error[E0499]: cannot borrow `foo.bar1` as mutable more than once at a time --> $DIR/borrowck-borrow-from-stack-variable.rs:88:17 @@ -81,7 +70,7 @@ LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^^^^^ second mutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- first borrow later used here error[E0499]: cannot borrow `foo` as mutable more than once at a time --> $DIR/borrowck-borrow-from-stack-variable.rs:95:17 @@ -91,7 +80,7 @@ LL | let _foo2 = &mut foo; //~ ERROR cannot borrow | ^^^^^^^^ second mutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- first borrow later used here error[E0502]: cannot borrow `foo.bar1` as mutable because it is also borrowed as immutable --> $DIR/borrowck-borrow-from-stack-variable.rs:102:17 @@ -101,7 +90,7 @@ LL | let _foo1 = &mut foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^^^^^ mutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- immutable borrow later used here error[E0502]: cannot borrow `foo` as mutable because it is also borrowed as immutable --> $DIR/borrowck-borrow-from-stack-variable.rs:109:17 @@ -111,7 +100,7 @@ LL | let _foo2 = &mut foo; //~ ERROR cannot borrow | ^^^^^^^^ mutable borrow occurs here LL | *bar1; - | ----- borrow later used here + | ----- immutable borrow later used here error[E0596]: cannot borrow `foo.bar1` as mutable, as `foo` is not declared as mutable --> $DIR/borrowck-borrow-from-stack-variable.rs:130:16 @@ -121,7 +110,7 @@ LL | let bar1 = &mut foo.bar1; //~ ERROR cannot borrow | ^^^^^^^^^^^^^ cannot borrow as mutable -error: aborting due to 12 previous errors +error: aborting due to 11 previous errors Some errors occurred: E0499, E0502, E0596. For more information about an error, try `rustc --explain E0499`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrow-from-temporary.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrow-from-temporary.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrow-from-temporary.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrow-from-temporary.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0515]: cannot return value referencing temporary value + --> $DIR/borrowck-borrow-from-temporary.rs:20:5 + | +LL | let &Foo(ref x) = &id(Foo(3)); //~ ERROR borrowed value does not live long enough + | ---------- temporary value created here +LL | x + | ^ returns a value referencing data owned by the current function + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrow-mut-base-ptr-in-aliasable-loc.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -15,7 +15,7 @@ LL | let p: &isize = &**t0; //~ ERROR cannot borrow | ^^^^^ immutable borrow occurs here LL | **t1 = 22; - | --------- borrow later used here + | --------- mutable borrow later used here error[E0596]: cannot borrow `**t0` as mutable, as it is behind a `&` reference --> $DIR/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs:29:26 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-borrow-mut-object-twice.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -6,7 +6,7 @@ LL | x.f2(); //~ ERROR cannot borrow `*x` as mutable | ^ second mutable borrow occurs here LL | y.use_ref(); - | - borrow later used here + | - first borrow later used here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-mut-and-imm.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-mut-and-imm.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-mut-and-imm.ast.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-mut-and-imm.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ | immutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable LL | drop(c1); - | -- borrow later used here + | -- mutable borrow later used here error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable --> $DIR/borrowck-closures-mut-and-imm.rs:39:14 @@ -26,7 +26,7 @@ | immutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable LL | drop(c1); - | -- borrow later used here + | -- mutable borrow later used here error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable --> $DIR/borrowck-closures-mut-and-imm.rs:47:14 @@ -41,7 +41,7 @@ | immutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable LL | drop(c1); - | -- borrow later used here + | -- mutable borrow later used here error[E0506]: cannot assign to `x` because it is borrowed --> $DIR/borrowck-closures-mut-and-imm.rs:55:5 @@ -108,7 +108,7 @@ | mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable LL | drop(c1); - | -- borrow later used here + | -- immutable borrow later used here error: aborting due to 8 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-mut-and-imm.mir.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-mut-and-imm.mir.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-mut-and-imm.mir.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-mut-and-imm.mir.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ | immutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable LL | drop(c1); - | -- borrow later used here + | -- mutable borrow later used here error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable --> $DIR/borrowck-closures-mut-and-imm.rs:39:14 @@ -26,7 +26,7 @@ | immutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable LL | drop(c1); - | -- borrow later used here + | -- mutable borrow later used here error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable --> $DIR/borrowck-closures-mut-and-imm.rs:47:14 @@ -41,7 +41,7 @@ | immutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable LL | drop(c1); - | -- borrow later used here + | -- mutable borrow later used here error[E0506]: cannot assign to `x` because it is borrowed --> $DIR/borrowck-closures-mut-and-imm.rs:55:5 @@ -108,7 +108,7 @@ | mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable LL | drop(c1); - | -- borrow later used here + | -- immutable borrow later used here error: aborting due to 8 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-two-mut-fail.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-two-mut-fail.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-two-mut-fail.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-two-mut-fail.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,7 @@ | | | second mutable borrow occurs here LL | c1; - | -- borrow later used here + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-closures-two-mut-fail.rs:37:24 @@ -24,7 +24,7 @@ | | | second mutable borrow occurs here LL | c1; - | -- borrow later used here + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-closures-two-mut-fail.rs:44:24 @@ -38,7 +38,7 @@ | | | second mutable borrow occurs here LL | c1; - | -- borrow later used here + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-closures-two-mut-fail.rs:51:24 @@ -53,7 +53,7 @@ | second mutable borrow occurs here LL | //~^ ERROR cannot borrow `x` as mutable more than once LL | c1; - | -- borrow later used here + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-closures-two-mut-fail.rs:63:24 @@ -68,7 +68,7 @@ | second mutable borrow occurs here LL | //~^ ERROR cannot borrow `x` as mutable more than once LL | c1; - | -- borrow later used here + | -- first borrow later used here error: aborting due to 5 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-two-mut.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-two-mut.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-two-mut.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-two-mut.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -86,7 +86,7 @@ | second mutable borrow occurs here LL | //~| ERROR cannot borrow `x` as mutable more than once LL | drop((c1, c2)); - | -- borrow later used here + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir) --> $DIR/borrowck-closures-two-mut.rs:36:24 @@ -101,7 +101,7 @@ | second mutable borrow occurs here LL | //~| ERROR cannot borrow `x` as mutable more than once LL | drop((c1, c2)); - | -- borrow later used here + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir) --> $DIR/borrowck-closures-two-mut.rs:44:24 @@ -116,7 +116,7 @@ | second mutable borrow occurs here LL | //~| ERROR cannot borrow `x` as mutable more than once LL | drop((c1, c2)); - | -- borrow later used here + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir) --> $DIR/borrowck-closures-two-mut.rs:52:24 @@ -131,7 +131,7 @@ | second mutable borrow occurs here ... LL | drop((c1, c2)); - | -- borrow later used here + | -- first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time (Mir) --> $DIR/borrowck-closures-two-mut.rs:65:24 @@ -146,7 +146,7 @@ | second mutable borrow occurs here ... LL | drop((c1, c2)); - | -- borrow later used here + | -- first borrow later used here error: aborting due to 10 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-unique-imm.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-unique-imm.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-unique-imm.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-unique-imm.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -6,7 +6,7 @@ LL | &mut this.x; //~ ERROR cannot borrow | ^^^^^^^^^^^ mutable borrow occurs here LL | p.use_ref(); - | - borrow later used here + | - immutable borrow later used here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-unique.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-unique.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-unique.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-unique.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,7 @@ | | | closure construction occurs here LL | c1; - | -- borrow later used here + | -- first borrow later used here error[E0500]: closure requires unique access to `x` but it is already borrowed --> $DIR/borrowck-closures-unique.rs:42:14 @@ -24,7 +24,7 @@ | | | closure construction occurs here LL | c1; - | -- borrow later used here + | -- first borrow later used here error[E0524]: two closures require unique access to `x` at the same time --> $DIR/borrowck-closures-unique.rs:48:14 @@ -38,7 +38,7 @@ | | | second closure is constructed here LL | c1; - | -- borrow later used here + | -- first borrow later used here error[E0594]: cannot assign to `x`, as it is not declared as mutable --> $DIR/borrowck-closures-unique.rs:57:38 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-use-after-free.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-use-after-free.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-use-after-free.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-closures-use-after-free.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,10 +7,9 @@ | --- first borrow occurs due to use of `ptr` in closure LL | }; LL | test(&*ptr); //~ ERROR cannot borrow `*ptr` - | -----^^^^^- - | | | - | | immutable borrow occurs here - | borrow later used here + | ---- ^^^^^ immutable borrow occurs here + | | + | mutable borrow later used by call error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-describe-lvalue.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-describe-lvalue.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-describe-lvalue.ast.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-describe-lvalue.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^^^^^ second mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time LL | *y = 1; - | ------ borrow later used here + | ------ first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-describe-lvalue.rs:307:20 @@ -18,26 +18,24 @@ | ^^^^^^ second mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time LL | *y = 1; - | ------ borrow later used here + | ------ first borrow later used here -error: unsatisfied lifetime constraints +error: captured variable cannot escape `FnMut` closure body --> $DIR/borrowck-describe-lvalue.rs:305:16 | LL | || { - | -- - | || - | |return type of closure is [closure@$DIR/borrowck-describe-lvalue.rs:305:16: 311:18 x:&'2 mut i32] - | lifetime `'1` represents this closure's body -LL | / || { //[mir]~ ERROR unsatisfied lifetime constraints + | - inferred to be a `FnMut` closure +LL | / || { //[mir]~ ERROR captured variable cannot escape `FnMut` closure body LL | | let y = &mut x; LL | | &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time LL | | //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time LL | | *y = 1; LL | | drop(y); LL | | } - | |_________________^ returning this value requires that `'1` must outlive `'2` + | |_________________^ returns a closure that contains a reference to a captured variable, which then escapes the closure body | - = note: closure implements `FnMut`, so references to captured variables can't escape the closure + = note: `FnMut` closures only have access to their captured variables while they are executing... + = note: ...therefore, they cannot allow references to captured variables to escape error[E0503]: cannot use `f.x` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:53:9 @@ -72,23 +70,12 @@ LL | drop(x); | - borrow later used here -error[E0503]: cannot use `e` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:77:15 - | -LL | let x = e.x(); - | - borrow of `e` occurs here -LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed - | ^ use of borrowed `e` -... -LL | drop(x); - | - borrow later used here - error[E0503]: cannot use `e.0` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:78:20 | LL | let x = e.x(); | - borrow of `e` occurs here -LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed +LL | match e { LL | Baz::X(value) => value | ^^^^^ use of borrowed `e` ... @@ -139,23 +126,12 @@ LL | drop(x); | - borrow later used here -error[E0503]: cannot use `*e` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:120:15 - | -LL | let x = e.x(); - | - borrow of `*e` occurs here -LL | match *e { //[mir]~ ERROR cannot use `*e` because it was mutably borrowed - | ^^ use of borrowed `*e` -... -LL | drop(x); - | - borrow later used here - error[E0503]: cannot use `e.0` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:121:20 | LL | let x = e.x(); | - borrow of `*e` occurs here -LL | match *e { //[mir]~ ERROR cannot use `*e` because it was mutably borrowed +LL | match *e { LL | Baz::X(value) => value | ^^^^^ use of borrowed `*e` ... @@ -173,41 +149,18 @@ LL | drop(x); | - borrow later used here -error[E0503]: cannot use `v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:139:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:140:15 | LL | let x = &mut v; | ------ borrow of `v` occurs here -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed +LL | match v { LL | &[x, _, .., _, _] => println!("{}", x), | ^ use of borrowed `v` ... LL | drop(x); | - borrow later used here -error[E0503]: cannot use `v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:145:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:146:18 | @@ -220,18 +173,6 @@ LL | drop(x); | - borrow later used here -error[E0503]: cannot use `v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:151:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:152:25 | @@ -244,18 +185,6 @@ LL | drop(x); | - borrow later used here -error[E0503]: cannot use `v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:157:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:158:28 | @@ -268,41 +197,18 @@ LL | drop(x); | - borrow later used here -error[E0503]: cannot use `v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:169:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:170:15 | LL | let x = &mut v; | ------ borrow of `v` occurs here -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed +LL | match v { LL | &[x..] => println!("{:?}", x), | ^ use of borrowed `v` ... LL | drop(x); | - borrow later used here -error[E0503]: cannot use `v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:175:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:176:18 | @@ -315,18 +221,6 @@ LL | drop(x); | - borrow later used here -error[E0503]: cannot use `v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:181:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:182:15 | @@ -339,18 +233,6 @@ LL | drop(x); | - borrow later used here -error[E0503]: cannot use `v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:187:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:188:18 | @@ -364,22 +246,11 @@ | - borrow later used here error[E0503]: cannot use `e` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:201:15 - | -LL | let x = &mut e; - | ------ borrow of `e` occurs here -LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed - | ^ use of borrowed `e` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `e` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:202:13 | LL | let x = &mut e; | ------ borrow of `e` occurs here -LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed +LL | match e { LL | E::A(ref ax) => | ^^^^^^^^^^^^ use of borrowed `e` ... @@ -391,12 +262,12 @@ | LL | let x = &mut e; | ------ mutable borrow occurs here -LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed +LL | match e { LL | E::A(ref ax) => | ^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `e.x` as immutable because it is also borrowed as mutable --> $DIR/borrowck-describe-lvalue.rs:207:23 @@ -408,42 +279,19 @@ | ^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `s` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:220:15 - | -LL | let x = &mut s; - | ------ borrow of `s` occurs here -LL | match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed - | ^ use of borrowed `s` -... -LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `s.y.0` as immutable because it is also borrowed as mutable --> $DIR/borrowck-describe-lvalue.rs:221:22 | LL | let x = &mut s; | ------ mutable borrow occurs here -LL | match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed +LL | match s { LL | S { y: (ref y0, _), .. } => | ^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `s` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:227:15 - | -LL | let x = &mut s; - | ------ borrow of `s` occurs here -... -LL | match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed - | ^ use of borrowed `s` -... -LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `s.x.y` as immutable because it is also borrowed as mutable --> $DIR/borrowck-describe-lvalue.rs:228:28 @@ -455,7 +303,7 @@ | ^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0503]: cannot use `*v` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:271:9 @@ -479,30 +327,19 @@ LL | drop(x); | - borrow later used here -error[E0503]: cannot use `v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:282:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - error[E0502]: cannot borrow `v[..].x` as immutable because it is also borrowed as mutable --> $DIR/borrowck-describe-lvalue.rs:283:24 | LL | let x = &mut v; | ------ mutable borrow occurs here -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed +LL | match v { LL | &[_, F {x: ref xf, ..}] => println!("{}", xf), | ^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here -error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable +warning[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable --> $DIR/borrowck-describe-lvalue.rs:245:29 | LL | let x = &mut block; @@ -511,9 +348,13 @@ | ^^^^^^^^^^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here + | + = warning: This error has been downgraded to a warning for backwards compatibility with previous releases. + It represents potential unsoundness in your code. + This warning will become a hard error in the future. -error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable +warning[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable --> $DIR/borrowck-describe-lvalue.rs:260:33 | LL | let x = &mut block; @@ -522,7 +363,11 @@ | ^^^^^^^^^^^^^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here + | + = warning: This error has been downgraded to a warning for backwards compatibility with previous releases. + It represents potential unsoundness in your code. + This warning will become a hard error in the future. error[E0382]: use of moved value: `x` --> $DIR/borrowck-describe-lvalue.rs:318:22 @@ -534,7 +379,7 @@ | = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait -error: aborting due to 46 previous errors +error: aborting due to 30 previous errors Some errors occurred: E0382, E0499, E0502, E0503. For more information about an error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-describe-lvalue.ast.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-describe-lvalue.ast.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-describe-lvalue.ast.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-describe-lvalue.ast.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -27,7 +27,7 @@ | LL | let x = e.x(); | - borrow of `e` occurs here -LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed +LL | match e { LL | Baz::X(value) => value | ^^^^^ use of borrowed `e` @@ -68,7 +68,7 @@ | LL | let x = e.x(); | - borrow of `*e` occurs here -LL | match *e { //[mir]~ ERROR cannot use `*e` because it was mutably borrowed +LL | match *e { LL | Baz::X(value) => value | ^^^^^ use of borrowed `*e` @@ -85,7 +85,7 @@ | LL | let x = &mut v; | - borrow of `v` occurs here -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed +LL | match v { LL | &[x, _, .., _, _] => println!("{}", x), | ^ use of borrowed `v` @@ -121,7 +121,7 @@ | LL | let x = &mut v; | - borrow of `v` occurs here -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed +LL | match v { LL | &[x..] => println!("{:?}", x), | ^ use of borrowed `v` @@ -157,7 +157,7 @@ | LL | let x = &mut e; | - mutable borrow occurs here -LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed +LL | match e { LL | E::A(ref ax) => | ^^^^^^ immutable borrow occurs here ... @@ -181,7 +181,7 @@ | LL | let x = &mut s; | - mutable borrow occurs here -LL | match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed +LL | match s { LL | S { y: (ref y0, _), .. } => | ^^^^^^ immutable borrow occurs here ... diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-describe-lvalue.mir.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-describe-lvalue.mir.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-describe-lvalue.mir.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-describe-lvalue.mir.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^^^^^ second mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time LL | *y = 1; - | ------ borrow later used here + | ------ first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-describe-lvalue.rs:307:20 @@ -18,26 +18,24 @@ | ^^^^^^ second mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time LL | *y = 1; - | ------ borrow later used here + | ------ first borrow later used here -error: unsatisfied lifetime constraints +error: captured variable cannot escape `FnMut` closure body --> $DIR/borrowck-describe-lvalue.rs:305:16 | LL | || { - | -- - | || - | |return type of closure is [closure@$DIR/borrowck-describe-lvalue.rs:305:16: 311:18 x:&'2 mut i32] - | lifetime `'1` represents this closure's body -LL | / || { //[mir]~ ERROR unsatisfied lifetime constraints + | - inferred to be a `FnMut` closure +LL | / || { //[mir]~ ERROR captured variable cannot escape `FnMut` closure body LL | | let y = &mut x; LL | | &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time LL | | //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time LL | | *y = 1; LL | | drop(y); LL | | } - | |_________________^ returning this value requires that `'1` must outlive `'2` + | |_________________^ returns a closure that contains a reference to a captured variable, which then escapes the closure body | - = note: closure implements `FnMut`, so references to captured variables can't escape the closure + = note: `FnMut` closures only have access to their captured variables while they are executing... + = note: ...therefore, they cannot allow references to captured variables to escape error[E0503]: cannot use `f.x` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:53:9 @@ -72,23 +70,12 @@ LL | drop(x); | - borrow later used here -error[E0503]: cannot use `e` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:77:15 - | -LL | let x = e.x(); - | - borrow of `e` occurs here -LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed - | ^ use of borrowed `e` -... -LL | drop(x); - | - borrow later used here - error[E0503]: cannot use `e.0` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:78:20 | LL | let x = e.x(); | - borrow of `e` occurs here -LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed +LL | match e { LL | Baz::X(value) => value | ^^^^^ use of borrowed `e` ... @@ -139,23 +126,12 @@ LL | drop(x); | - borrow later used here -error[E0503]: cannot use `*e` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:120:15 - | -LL | let x = e.x(); - | - borrow of `*e` occurs here -LL | match *e { //[mir]~ ERROR cannot use `*e` because it was mutably borrowed - | ^^ use of borrowed `*e` -... -LL | drop(x); - | - borrow later used here - error[E0503]: cannot use `e.0` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:121:20 | LL | let x = e.x(); | - borrow of `*e` occurs here -LL | match *e { //[mir]~ ERROR cannot use `*e` because it was mutably borrowed +LL | match *e { LL | Baz::X(value) => value | ^^^^^ use of borrowed `*e` ... @@ -173,41 +149,18 @@ LL | drop(x); | - borrow later used here -error[E0503]: cannot use `v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:139:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:140:15 | LL | let x = &mut v; | ------ borrow of `v` occurs here -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed +LL | match v { LL | &[x, _, .., _, _] => println!("{}", x), | ^ use of borrowed `v` ... LL | drop(x); | - borrow later used here -error[E0503]: cannot use `v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:145:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:146:18 | @@ -220,18 +173,6 @@ LL | drop(x); | - borrow later used here -error[E0503]: cannot use `v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:151:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:152:25 | @@ -244,18 +185,6 @@ LL | drop(x); | - borrow later used here -error[E0503]: cannot use `v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:157:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:158:28 | @@ -268,41 +197,18 @@ LL | drop(x); | - borrow later used here -error[E0503]: cannot use `v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:169:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:170:15 | LL | let x = &mut v; | ------ borrow of `v` occurs here -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed +LL | match v { LL | &[x..] => println!("{:?}", x), | ^ use of borrowed `v` ... LL | drop(x); | - borrow later used here -error[E0503]: cannot use `v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:175:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:176:18 | @@ -315,18 +221,6 @@ LL | drop(x); | - borrow later used here -error[E0503]: cannot use `v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:181:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:182:15 | @@ -339,18 +233,6 @@ LL | drop(x); | - borrow later used here -error[E0503]: cannot use `v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:187:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -... -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - error[E0503]: cannot use `v[..]` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:188:18 | @@ -364,22 +246,11 @@ | - borrow later used here error[E0503]: cannot use `e` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:201:15 - | -LL | let x = &mut e; - | ------ borrow of `e` occurs here -LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed - | ^ use of borrowed `e` -... -LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `e` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:202:13 | LL | let x = &mut e; | ------ borrow of `e` occurs here -LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed +LL | match e { LL | E::A(ref ax) => | ^^^^^^^^^^^^ use of borrowed `e` ... @@ -391,12 +262,12 @@ | LL | let x = &mut e; | ------ mutable borrow occurs here -LL | match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed +LL | match e { LL | E::A(ref ax) => | ^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `e.x` as immutable because it is also borrowed as mutable --> $DIR/borrowck-describe-lvalue.rs:207:23 @@ -408,42 +279,19 @@ | ^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `s` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:220:15 - | -LL | let x = &mut s; - | ------ borrow of `s` occurs here -LL | match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed - | ^ use of borrowed `s` -... -LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `s.y.0` as immutable because it is also borrowed as mutable --> $DIR/borrowck-describe-lvalue.rs:221:22 | LL | let x = &mut s; | ------ mutable borrow occurs here -LL | match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed +LL | match s { LL | S { y: (ref y0, _), .. } => | ^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here - -error[E0503]: cannot use `s` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:227:15 - | -LL | let x = &mut s; - | ------ borrow of `s` occurs here -... -LL | match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed - | ^ use of borrowed `s` -... -LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `s.x.y` as immutable because it is also borrowed as mutable --> $DIR/borrowck-describe-lvalue.rs:228:28 @@ -455,7 +303,7 @@ | ^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0503]: cannot use `*v` because it was mutably borrowed --> $DIR/borrowck-describe-lvalue.rs:271:9 @@ -479,28 +327,17 @@ LL | drop(x); | - borrow later used here -error[E0503]: cannot use `v` because it was mutably borrowed - --> $DIR/borrowck-describe-lvalue.rs:282:15 - | -LL | let x = &mut v; - | ------ borrow of `v` occurs here -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed - | ^ use of borrowed `v` -... -LL | drop(x); - | - borrow later used here - error[E0502]: cannot borrow `v[..].x` as immutable because it is also borrowed as mutable --> $DIR/borrowck-describe-lvalue.rs:283:24 | LL | let x = &mut v; | ------ mutable borrow occurs here -LL | match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed +LL | match v { LL | &[_, F {x: ref xf, ..}] => println!("{}", xf), | ^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable --> $DIR/borrowck-describe-lvalue.rs:245:29 @@ -511,7 +348,7 @@ | ^^^^^^^^^^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable --> $DIR/borrowck-describe-lvalue.rs:260:33 @@ -522,7 +359,7 @@ | ^^^^^^^^^^^^^^^^^^ immutable borrow occurs here ... LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error[E0382]: use of moved value: `x` --> $DIR/borrowck-describe-lvalue.rs:318:22 @@ -534,7 +371,7 @@ | = note: move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait -error: aborting due to 46 previous errors +error: aborting due to 32 previous errors Some errors occurred: E0382, E0499, E0502, E0503. For more information about an error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-describe-lvalue.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-describe-lvalue.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-describe-lvalue.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-describe-lvalue.rs 2018-12-04 23:41:40.000000000 +0000 @@ -74,7 +74,7 @@ { let mut e = Baz::X(2); let x = e.x(); - match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed + match e { 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 @@ -117,7 +117,7 @@ { let mut e = Box::new(Baz::X(3)); let x = e.x(); - match *e { //[mir]~ ERROR cannot use `*e` because it was mutably borrowed + match *e { 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 @@ -136,25 +136,25 @@ { let mut v = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let x = &mut v; - match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + match v { &[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 { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + match v { &[_, 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 { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + match v { &[_, _, .., 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 { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + match v { &[_, _, .., _, x] => println!("{}", x), //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed @@ -166,25 +166,25 @@ { let mut v = &[1, 2, 3, 4, 5]; let x = &mut v; - match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + match v { &[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 { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + match v { &[_, 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 { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + match v { &[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 { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + match v { &[_, x.., _] => println!("{:?}", x), //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed @@ -198,7 +198,7 @@ let mut e = E::A(3); let x = &mut e; - match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed + match e { 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 @@ -217,14 +217,14 @@ struct S { x: F, y: (u32, u32), }; let mut s = S { x: F { x: 1, y: 2}, y: (999, 998) }; let x = &mut s; - match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed + match s { 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 { //[mir]~ ERROR cannot use `s` because it was mutably borrowed + match s { 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 @@ -279,7 +279,7 @@ struct F {x: u32, y: u32}; let mut v = &[F{x: 1, y: 2}, F{x: 3, y: 4}]; let x = &mut v; - match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + match v { &[_, 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 @@ -302,7 +302,7 @@ // FIXME(#49824) -- the free region error below should probably not be there let mut x = 0; || { - || { //[mir]~ ERROR unsatisfied lifetime constraints + || { //[mir]~ ERROR captured variable cannot escape `FnMut` closure body let y = &mut x; &mut x; //[ast]~ ERROR cannot borrow `**x` as mutable more than once at a time //[mir]~^ ERROR cannot borrow `x` as mutable more than once at a time diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-escaping-closure-error-1.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-escaping-closure-error-1.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-escaping-closure-error-1.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-escaping-closure-error-1.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,16 +1,21 @@ -error[E0597]: `books` does not live long enough - --> $DIR/borrowck-escaping-closure-error-1.rs:23:14 +error[E0373]: closure may outlive the current function, but it borrows `books`, which is owned by the current function + --> $DIR/borrowck-escaping-closure-error-1.rs:23:11 | LL | spawn(|| books.push(4)); - | -- ^^^^^ borrowed value does not live long enough + | ^^ ----- `books` is borrowed here | | - | value captured here -LL | //~^ ERROR E0373 -LL | } - | - `books` dropped here while still borrowed + | may outlive borrowed value `books` | - = note: borrowed value must be valid for the static lifetime... +note: function requires argument type to outlive `'static` + --> $DIR/borrowck-escaping-closure-error-1.rs:23:5 + | +LL | spawn(|| books.push(4)); + | ^^^^^^^^^^^^^^^^^^^^^^^ +help: to force the closure to take ownership of `books` (and any other referenced variables), use the `move` keyword + | +LL | spawn(move || books.push(4)); + | ^^^^^^^ error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0373`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-escaping-closure-error-2.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-escaping-closure-error-2.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-escaping-closure-error-2.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-escaping-closure-error-2.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,20 +1,21 @@ -error[E0597]: `books` does not live long enough - --> $DIR/borrowck-escaping-closure-error-2.rs:21:17 +error[E0373]: closure may outlive the current function, but it borrows `books`, which is owned by the current function + --> $DIR/borrowck-escaping-closure-error-2.rs:21:14 | LL | Box::new(|| books.push(4)) - | -- ^^^^^ borrowed value does not live long enough + | ^^ ----- `books` is borrowed here | | - | value captured here -LL | //~^ ERROR E0373 -LL | } - | - `books` dropped here while still borrowed + | may outlive borrowed value `books` | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 19:8... - --> $DIR/borrowck-escaping-closure-error-2.rs:19:8 +note: closure is returned here + --> $DIR/borrowck-escaping-closure-error-2.rs:21:5 | -LL | fn foo<'a>(x: &'a i32) -> Box { - | ^^ +LL | Box::new(|| books.push(4)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: to force the closure to take ownership of `books` (and any other referenced variables), use the `move` keyword + | +LL | Box::new(move || books.push(4)) + | ^^^^^^^ error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0373`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-field-sensitivity.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-field-sensitivity.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-field-sensitivity.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-field-sensitivity.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ -error[E0382]: use of moved value: `*x.b` +error[E0382]: use of moved value: `x.b` --> $DIR/borrowck-field-sensitivity.rs:18:10 | LL | drop(x.b); @@ -6,7 +6,7 @@ LL | drop(*x.b); //~ ERROR use of moved value: `*x.b` | ^^^^ value used here after move -error[E0382]: use of moved value: `*x.b` +error[E0382]: use of moved value: `x.b` --> $DIR/borrowck-field-sensitivity.rs:24:10 | LL | let y = A { a: 3, .. x }; @@ -62,7 +62,7 @@ LL | let q = &mut x.a; //~ ERROR cannot borrow `x.a` as mutable more than once at a time | ^^^^^^^^ second mutable borrow occurs here LL | drop(*p); - | -- borrow later used here + | -- first borrow later used here error[E0382]: use of moved value: `x.b` --> $DIR/borrowck-field-sensitivity.rs:66:10 @@ -104,7 +104,25 @@ | = note: move occurs because `x.b` has type `std::boxed::Box`, which does not implement the `Copy` trait -error: aborting due to 11 previous errors +error[E0381]: assign to part of possibly uninitialized variable: `x` + --> $DIR/borrowck-field-sensitivity.rs:91:5 + | +LL | x.a = 1; + | ^^^^^^^ use of possibly uninitialized `x` + +error[E0381]: assign to part of possibly uninitialized variable: `x` + --> $DIR/borrowck-field-sensitivity.rs:97:5 + | +LL | x.a = 1; + | ^^^^^^^ use of possibly uninitialized `x` + +error[E0381]: assign to part of possibly uninitialized variable: `x` + --> $DIR/borrowck-field-sensitivity.rs:104:5 + | +LL | x.b = box 1; + | ^^^ use of possibly uninitialized `x` + +error: aborting due to 14 previous errors -Some errors occurred: E0382, E0499, E0505. -For more information about an error, try `rustc --explain E0382`. +Some errors occurred: E0381, E0382, E0499, E0505. +For more information about an error, try `rustc --explain E0381`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-fn-in-const-a.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-fn-in-const-a.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-fn-in-const-a.ast.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-fn-in-const-a.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/borrowck-fn-in-const-a.rs:19:16 + | +LL | return *x //[ast]~ ERROR cannot move out of borrowed content [E0507] + | ^^ cannot move out of borrowed content + +error[E0507]: cannot move out of `*x` which is behind a `&` reference + --> $DIR/borrowck-fn-in-const-a.rs:19:16 + | +LL | fn broken(x: &String) -> String { + | ------- help: consider changing this to be a mutable reference: `&mut std::string::String` +LL | return *x //[ast]~ ERROR cannot move out of borrowed content [E0507] + | ^^ + | | + | cannot move out of `*x` which is behind a `&` reference + | `x` is a `&` reference, so the data it refers to cannot be moved + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-fn-in-const-c.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-fn-in-const-c.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-fn-in-const-c.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-fn-in-const-c.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,13 +1,11 @@ -error[E0597]: `local.inner` does not live long enough +error[E0713]: borrow may still be in use when destructor runs --> $DIR/borrowck-fn-in-const-c.rs:27:16 | LL | return &local.inner; //~ ERROR does not live long enough - | ^^^^^^^^^^^^ borrowed value does not live long enough + | ^^^^^^^^^^^^ returning this value requires that `local.inner` is borrowed for `'static` LL | } - | - `local.inner` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... + | - here, drop of `local` needs exclusive access to `local.inner`, because the type `DropString` implements the `Drop` trait error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0713`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-for-loop-correct-cmt-for-pattern.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-for-loop-correct-cmt-for-pattern.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-for-loop-correct-cmt-for-pattern.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-for-loop-correct-cmt-for-pattern.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,3 +1,13 @@ +error[E0507]: cannot move out of `*__next` which is behind a `&` reference + --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:22:10 + | +LL | for &a in x.iter() { //~ ERROR cannot move out + | -^ + | || + | |cannot move out of `*__next` which is behind a `&` reference + | |`__next` is a `&` reference, so the data it refers to cannot be moved + | help: consider changing this to be a mutable reference: `&mut a` + error[E0507]: cannot move out of borrowed content --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:22:15 | @@ -13,6 +23,16 @@ LL | for &a in x.iter() { //~ ERROR cannot move out | ^ +error[E0507]: cannot move out of `*__next` which is behind a `&` reference + --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:28:10 + | +LL | for &a in &f.a { //~ ERROR cannot move out + | -^ + | || + | |cannot move out of `*__next` which is behind a `&` reference + | |`__next` is a `&` reference, so the data it refers to cannot be moved + | help: consider changing this to be a mutable reference: `&mut a` + error[E0507]: cannot move out of borrowed content --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:28:15 | @@ -28,6 +48,16 @@ LL | for &a in &f.a { //~ ERROR cannot move out | ^ +error[E0507]: cannot move out of `*__next` which is behind a `&` reference + --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:32:10 + | +LL | for &a in x.iter() { //~ ERROR cannot move out + | -^ + | || + | |cannot move out of `*__next` which is behind a `&` reference + | |`__next` is a `&` reference, so the data it refers to cannot be moved + | help: consider changing this to be a mutable reference: `&mut a` + error[E0507]: cannot move out of borrowed content --> $DIR/borrowck-for-loop-correct-cmt-for-pattern.rs:32:15 | @@ -43,6 +73,6 @@ LL | for &a in x.iter() { //~ ERROR cannot move out | ^ -error: aborting due to 3 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-for-loop-head-linkage.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-for-loop-head-linkage.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-for-loop-head-linkage.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-for-loop-head-linkage.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -5,7 +5,7 @@ | ------- | | | immutable borrow occurs here - | borrow used here in later iteration of loop + | immutable borrow used here, in later iteration of loop LL | let cap = vector.capacity(); LL | vector.extend(repeat(0)); //~ ERROR cannot borrow | ^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here @@ -17,7 +17,7 @@ | ------- | | | immutable borrow occurs here - | borrow used here in later iteration of loop + | immutable borrow used here, in later iteration of loop ... LL | vector[1] = 5; //~ ERROR cannot borrow | ^^^^^^ mutable borrow occurs here diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-init-in-fru.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-init-in-fru.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-init-in-fru.ast.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-init-in-fru.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ -error[E0381]: use of possibly uninitialized variable: `origin.y` +error[E0381]: use of possibly uninitialized variable: `origin` --> $DIR/borrowck-init-in-fru.rs:22:5 | LL | origin = point {x: 10,.. origin}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-init-in-fru.mir.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-init-in-fru.mir.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-init-in-fru.mir.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-init-in-fru.mir.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ -error[E0381]: use of possibly uninitialized variable: `origin.y` +error[E0381]: use of possibly uninitialized variable: `origin` --> $DIR/borrowck-init-in-fru.rs:22:5 | LL | origin = point {x: 10,.. origin}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-insert-during-each.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-insert-during-each.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-insert-during-each.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-insert-during-each.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,34 +1,28 @@ error[E0501]: cannot borrow `*f` as mutable because previous closure requires unique access --> $DIR/borrowck-insert-during-each.rs:26:3 | -LL | f.foo( - | ___^ - | |___| - | || -LL | || |a| { //~ ERROR closure requires unique access to `f` - | || --- closure construction occurs here -LL | || f.n.insert(*a); - | || - first borrow occurs due to use of `f` in closure -LL | || }) - | || ^ - | ||__________| - | |___________borrow occurs here - | borrow later used here - -error[E0500]: closure requires unique access to `f` but it is already borrowed - --> $DIR/borrowck-insert-during-each.rs:27:9 - | LL | f.foo( - | - - | | - | ___borrow occurs here + | ^ --- first borrow later used by call + | ___| | | LL | | |a| { //~ ERROR closure requires unique access to `f` - | | ^^^ closure construction occurs here + | | --- closure construction occurs here LL | | f.n.insert(*a); - | | - second borrow occurs due to use of `f` in closure + | | - first borrow occurs due to use of `f` in closure LL | | }) - | |__________- borrow later used here + | |__________^ borrow occurs here + +error[E0500]: closure requires unique access to `f` but it is already borrowed + --> $DIR/borrowck-insert-during-each.rs:27:9 + | +LL | f.foo( + | - --- first borrow later used by call + | | + | borrow occurs here +LL | |a| { //~ ERROR closure requires unique access to `f` + | ^^^ closure construction occurs here +LL | f.n.insert(*a); + | - second borrow occurs due to use of `f` in closure error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-in-static.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-in-static.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-in-static.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-in-static.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -6,6 +6,21 @@ LL | Box::new(|| x) //~ ERROR cannot move out of captured outer variable | ^ cannot move out of captured variable in an `Fn` closure -error: aborting due to previous error +error[E0507]: cannot move out of `x`, as it is a captured variable in a `Fn` closure + --> $DIR/borrowck-in-static.rs:15:17 + | +LL | Box::new(|| x) //~ ERROR cannot move out of captured outer variable + | ^ + | | + | cannot move out of `x`, as it is a captured variable in a `Fn` closure + | cannot move + | +help: consider changing this to accept closures that implement `FnMut` + --> $DIR/borrowck-in-static.rs:15:14 + | +LL | Box::new(|| x) //~ ERROR cannot move out of captured outer variable + | ^^^^ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-issue-2657-2.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-issue-2657-2.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-issue-2657-2.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-issue-2657-2.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,6 +7,17 @@ | cannot move out of borrowed content | help: consider removing the `*`: `y` -error: aborting due to previous error +error[E0507]: cannot move out of `*y` which is behind a `&` reference + --> $DIR/borrowck-issue-2657-2.rs:17:18 + | +LL | Some(ref y) => { + | ----- help: consider changing this to be a mutable reference: `ref mut y` +LL | let _b = *y; //~ ERROR cannot move out + | ^^ + | | + | cannot move out of `*y` which is behind a `&` reference + | `y` is a `&` reference, so the data it refers to cannot be moved + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow-if.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow-if.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow-if.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow-if.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error[E0502]: cannot borrow `*v` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-lend-flow-if.rs:39:16 + | +LL | _w = &v; + | -- immutable borrow occurs here +LL | } +LL | borrow_mut(&mut *v); //~ ERROR cannot borrow + | ^^^^^^^ mutable borrow occurs here +LL | _w.use_ref(); + | -- immutable borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0502`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow-if.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow-if.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow-if.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow-if.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - // Note: the borrowck analysis is currently flow-insensitive. // Therefore, some of these errors are marked as spurious and could be // corrected by a simple change to the analysis. The others are @@ -32,25 +30,32 @@ // In this instance, the freeze is conditional and starts before // the mut borrow. + let u = box 0; let mut v: Box<_> = box 3; - let _w; + let mut _w = &u; if cond() { _w = &v; } borrow_mut(&mut *v); //~ ERROR cannot borrow + _w.use_ref(); } fn pre_freeze_else() { // In this instance, the freeze and mut borrow are on separate sides // of the if. + let u = box 0; let mut v: Box<_> = box 3; - let _w; + let mut _w = &u; if cond() { _w = &v; } else { borrow_mut(&mut *v); } + _w.use_ref(); } fn main() {} + +trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } } +impl Fake for T { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow-if.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow-if.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow-if.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow-if.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,11 +1,12 @@ error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable - --> $DIR/borrowck-lend-flow-if.rs:40:21 + --> $DIR/borrowck-lend-flow-if.rs:39:21 | LL | _w = &v; | - immutable borrow occurs here LL | } LL | borrow_mut(&mut *v); //~ ERROR cannot borrow | ^^ mutable borrow occurs here +LL | _w.use_ref(); LL | } | - immutable borrow ends here diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow-loop.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow-loop.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow-loop.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow-loop.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,13 +8,13 @@ | ^^^ immutable borrow occurs here LL | } LL | *x = box 5; - | -- borrow used here in later iteration of loop + | -- mutable borrow used here, in later iteration of loop error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable --> $DIR/borrowck-lend-flow-loop.rs:109:16 | LL | **x += 1; - | -------- borrow used here in later iteration of loop + | -------- mutable borrow used here, in later iteration of loop LL | borrow(&*v); //~ ERROR cannot borrow | ^^^ immutable borrow occurs here LL | if cond2 { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +error[E0502]: cannot borrow `*v` as mutable because it is also borrowed as immutable + --> $DIR/borrowck-lend-flow.rs:34:16 + | +LL | let _w = &v; + | -- immutable borrow occurs here +LL | borrow_mut(&mut *v); //~ ERROR cannot borrow + | ^^^^^^^ mutable borrow occurs here +LL | _w.use_ref(); + | -- immutable borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0502`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - // Note: the borrowck analysis is currently flow-insensitive. // Therefore, some of these errors are marked as spurious and could be // corrected by a simple change to the analysis. The others are @@ -34,6 +32,7 @@ let mut v: Box<_> = box 3; let _w = &v; borrow_mut(&mut *v); //~ ERROR cannot borrow + _w.use_ref(); } fn post_freeze() { @@ -45,3 +44,6 @@ } fn main() {} + +trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } } +impl Fake for T { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-lend-flow.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,10 +1,11 @@ error[E0502]: cannot borrow `*v` as mutable because `v` is also borrowed as immutable - --> $DIR/borrowck-lend-flow.rs:36:21 + --> $DIR/borrowck-lend-flow.rs:34:21 | LL | let _w = &v; | - immutable borrow occurs here LL | borrow_mut(&mut *v); //~ ERROR cannot borrow | ^^ mutable borrow occurs here +LL | _w.use_ref(); LL | } | - immutable borrow ends here diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-loan-blocks-mut-uniq.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-loan-blocks-mut-uniq.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-loan-blocks-mut-uniq.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-loan-blocks-mut-uniq.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,18 +1,14 @@ error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable --> $DIR/borrowck-loan-blocks-mut-uniq.rs:20:12 | -LL | borrow(&*v, - | - --- immutable borrow occurs here - | _____| - | | -LL | | |w| { //~ ERROR cannot borrow `v` as mutable - | | ^^^ mutable borrow occurs here -LL | | v = box 4; - | | - second borrow occurs due to use of `v` in closure -LL | | assert_eq!(*v, 3); -LL | | assert_eq!(*w, 4); -LL | | }) - | |__________- borrow later used here +LL | borrow(&*v, + | ------ --- immutable borrow occurs here + | | + | immutable borrow later used by call +LL | |w| { //~ ERROR cannot borrow `v` as mutable + | ^^^ mutable borrow occurs here +LL | v = box 4; + | - second borrow occurs due to use of `v` in closure error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-loan-of-static-data-issue-27616.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-loan-of-static-data-issue-27616.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-loan-of-static-data-issue-27616.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-loan-of-static-data-issue-27616.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,12 +2,12 @@ --> $DIR/borrowck-loan-of-static-data-issue-27616.rs:26:5 | LL | let alias: &'static mut String = s; - | - borrow of `*s` occurs here + | ------------------- - borrow of `*s` occurs here + | | + | type annotation requires that `*s` is borrowed for `'static` ... LL | *s = String::new(); //~ ERROR cannot assign | ^^ assignment to borrowed `*s` occurs here - | - = note: borrowed value must be valid for the static lifetime... error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-loan-rcvr.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-loan-rcvr.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-loan-rcvr.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-loan-rcvr.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,15 +1,13 @@ error[E0502]: cannot borrow `p` as mutable because it is also borrowed as immutable --> $DIR/borrowck-loan-rcvr.rs:34:14 | -LL | p.blockm(|| { //~ ERROR cannot borrow `p` as mutable - | - ^^ mutable borrow occurs here - | | - | _____immutable borrow occurs here - | | -LL | | p.x = 10; - | | - second borrow occurs due to use of `p` in closure -LL | | }) - | |______- borrow later used here +LL | p.blockm(|| { //~ ERROR cannot borrow `p` as mutable + | - ------ ^^ mutable borrow occurs here + | | | + | | immutable borrow later used by call + | immutable borrow occurs here +LL | p.x = 10; + | - second borrow occurs due to use of `p` in closure error[E0502]: cannot borrow `p` as immutable because it is also borrowed as mutable --> $DIR/borrowck-loan-rcvr.rs:45:5 @@ -20,7 +18,7 @@ | ^ immutable borrow occurs here LL | LL | l.x += 1; - | -------- borrow later used here + | -------- mutable borrow later used here error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-loan-rcvr-overloaded-op.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-loan-rcvr-overloaded-op.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-loan-rcvr-overloaded-op.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-loan-rcvr-overloaded-op.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -20,7 +20,7 @@ | ^ immutable borrow occurs here LL | LL | *q + 3; // OK to use the new alias `q` - | -- borrow later used here + | -- mutable borrow later used here error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-loan-vec-content.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-loan-vec-content.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-loan-vec-content.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-loan-vec-content.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,15 +1,14 @@ error[E0502]: cannot borrow `v` as mutable because it is also borrowed as immutable --> $DIR/borrowck-loan-vec-content.rs:28:9 | -LL | / takes_imm_elt( -LL | | &v[0], - | | - immutable borrow occurs here -LL | | || { //~ ERROR cannot borrow `v` as mutable - | | ^^ mutable borrow occurs here -LL | | v[1] = 4; - | | - second borrow occurs due to use of `v` in closure -LL | | }) - | |__________- borrow later used here +LL | takes_imm_elt( + | ------------- immutable borrow later used by call +LL | &v[0], + | - immutable borrow occurs here +LL | || { //~ ERROR cannot borrow `v` as mutable + | ^^ mutable borrow occurs here +LL | v[1] = 4; + | - second borrow occurs due to use of `v` in closure error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.ast.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,14 +1,9 @@ -error[E0597]: `x` does not live long enough +error[E0515]: cannot return reference to function parameter `x` --> $DIR/borrowck-local-borrow-outlives-fn.rs:15:5 | LL | &x - | ^^ borrowed value does not live long enough -... -LL | } - | - `x` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... + | ^^ returns a reference to data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.mir.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.mir.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.mir.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.mir.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,14 +1,9 @@ -error[E0597]: `x` does not live long enough +error[E0515]: cannot return reference to function parameter `x` --> $DIR/borrowck-local-borrow-outlives-fn.rs:15:5 | LL | &x - | ^^ borrowed value does not live long enough -... -LL | } - | - `x` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... + | ^^ returns a reference to data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-local-borrow-outlives-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,7 +14,7 @@ fn cplusplus_mode(x: isize) -> &'static isize { &x //[ast]~^ ERROR `x` does not live long enough [E0597] - //[mir]~^^ ERROR `x` does not live long enough [E0597] + //[mir]~^^ ERROR cannot return reference to function parameter `x` [E0515] } fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,12 +2,13 @@ --> $DIR/borrowck-local-borrow-with-panic-outlives-fn.rs:16:15 | LL | *x = Some(&mut z.1); - | ^^^^^^^^ borrowed value does not live long enough + | ----------^^^^^^^^- + | | | + | | borrowed value does not live long enough + | assignment requires that `z.1` is borrowed for `'static` ... LL | } | - `z.1` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.mir.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.mir.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.mir.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-local-borrow-with-panic-outlives-fn.mir.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,12 +2,13 @@ --> $DIR/borrowck-local-borrow-with-panic-outlives-fn.rs:16:15 | LL | *x = Some(&mut z.1); - | ^^^^^^^^ borrowed value does not live long enough + | ----------^^^^^^^^- + | | | + | | borrowed value does not live long enough + | assignment requires that `z.1` is borrowed for `'static` ... LL | } | - `z.1` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-match-already-borrowed.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-match-already-borrowed.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-match-already-borrowed.ast.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-match-already-borrowed.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,20 +1,9 @@ error[E0503]: cannot use `foo` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:22:19 - | -LL | let p = &mut foo; - | -------- borrow of `foo` occurs here -LL | let _ = match foo { //[mir]~ ERROR [E0503] - | ^^^ use of borrowed `foo` -... -LL | drop(p); - | - borrow later used here - -error[E0503]: cannot use `foo` because it was mutably borrowed --> $DIR/borrowck-match-already-borrowed.rs:23:9 | LL | let p = &mut foo; | -------- borrow of `foo` occurs here -LL | let _ = match foo { //[mir]~ ERROR [E0503] +LL | let _ = match foo { LL | Foo::B => 1, //[mir]~ ERROR [E0503] | ^^^^^^ use of borrowed `foo` ... @@ -34,22 +23,11 @@ | - borrow later used here error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:35:19 - | -LL | let r = &mut x; - | ------ borrow of `x` occurs here -LL | let _ = match x { //[mir]~ ERROR [E0503] - | ^ use of borrowed `x` -... -LL | drop(r); - | - borrow later used here - -error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/borrowck-match-already-borrowed.rs:36:9 | LL | let r = &mut x; | ------ borrow of `x` occurs here -LL | let _ = match x { //[mir]~ ERROR [E0503] +LL | let _ = match x { LL | x => x + 1, //[ast]~ ERROR [E0503] | ^ use of borrowed `x` ... @@ -68,6 +46,6 @@ LL | drop(r); | - borrow later used here -error: aborting due to 6 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0503`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-match-already-borrowed.ast.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-match-already-borrowed.ast.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-match-already-borrowed.ast.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-match-already-borrowed.ast.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -12,7 +12,7 @@ | LL | let r = &mut x; | - borrow of `x` occurs here -LL | let _ = match x { //[mir]~ ERROR [E0503] +LL | let _ = match x { LL | x => x + 1, //[ast]~ ERROR [E0503] | ^ use of borrowed `x` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-match-already-borrowed.mir.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-match-already-borrowed.mir.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-match-already-borrowed.mir.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-match-already-borrowed.mir.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,20 +1,9 @@ error[E0503]: cannot use `foo` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:22:19 - | -LL | let p = &mut foo; - | -------- borrow of `foo` occurs here -LL | let _ = match foo { //[mir]~ ERROR [E0503] - | ^^^ use of borrowed `foo` -... -LL | drop(p); - | - borrow later used here - -error[E0503]: cannot use `foo` because it was mutably borrowed --> $DIR/borrowck-match-already-borrowed.rs:23:9 | LL | let p = &mut foo; | -------- borrow of `foo` occurs here -LL | let _ = match foo { //[mir]~ ERROR [E0503] +LL | let _ = match foo { LL | Foo::B => 1, //[mir]~ ERROR [E0503] | ^^^^^^ use of borrowed `foo` ... @@ -34,22 +23,11 @@ | - borrow later used here error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/borrowck-match-already-borrowed.rs:35:19 - | -LL | let r = &mut x; - | ------ borrow of `x` occurs here -LL | let _ = match x { //[mir]~ ERROR [E0503] - | ^ use of borrowed `x` -... -LL | drop(r); - | - borrow later used here - -error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/borrowck-match-already-borrowed.rs:36:9 | LL | let r = &mut x; | ------ borrow of `x` occurs here -LL | let _ = match x { //[mir]~ ERROR [E0503] +LL | let _ = match x { LL | x => x + 1, //[ast]~ ERROR [E0503] | ^ use of borrowed `x` ... @@ -68,6 +46,6 @@ LL | drop(r); | - borrow later used here -error: aborting due to 6 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0503`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-match-already-borrowed.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-match-already-borrowed.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-match-already-borrowed.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-match-already-borrowed.rs 2018-12-04 23:41:40.000000000 +0000 @@ -19,7 +19,7 @@ fn match_enum() { let mut foo = Foo::B; let p = &mut foo; - let _ = match foo { //[mir]~ ERROR [E0503] + let _ = match foo { Foo::B => 1, //[mir]~ ERROR [E0503] _ => 2, Foo::A(x) => x //[ast]~ ERROR [E0503] @@ -32,7 +32,7 @@ fn main() { let mut x = 1; let r = &mut x; - let _ = match x { //[mir]~ ERROR [E0503] + let _ = match x { x => x + 1, //[ast]~ ERROR [E0503] //[mir]~^ ERROR [E0503] y => y + 2, //[ast]~ ERROR [E0503] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-error-with-note.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-error-with-note.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-error-with-note.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-error-with-note.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -24,6 +24,42 @@ LL | Foo::Foo2(num) => (), | ^^^ +error[E0507]: cannot move out of `f.0` which is behind a `&` reference + --> $DIR/borrowck-move-error-with-note.rs:23:19 + | +LL | let f = &Foo::Foo1(box 1, box 2); + | ------------------------ help: consider changing this to be a mutable reference: `&mut Foo::Foo1(box 1, box 2)` +... +LL | Foo::Foo1(num1, + | ^^^^ + | | + | cannot move out of `f.0` which is behind a `&` reference + | `f` is a `&` reference, so the data it refers to cannot be moved + +error[E0507]: cannot move out of `f.1` which is behind a `&` reference + --> $DIR/borrowck-move-error-with-note.rs:24:19 + | +LL | let f = &Foo::Foo1(box 1, box 2); + | ------------------------ help: consider changing this to be a mutable reference: `&mut Foo::Foo1(box 1, box 2)` +... +LL | num2) => (), + | ^^^^ + | | + | cannot move out of `f.1` which is behind a `&` reference + | `f` is a `&` reference, so the data it refers to cannot be moved + +error[E0507]: cannot move out of `f.0` which is behind a `&` reference + --> $DIR/borrowck-move-error-with-note.rs:25:19 + | +LL | let f = &Foo::Foo1(box 1, box 2); + | ------------------------ help: consider changing this to be a mutable reference: `&mut Foo::Foo1(box 1, box 2)` +... +LL | Foo::Foo2(num) => (), + | ^^^ + | | + | cannot move out of `f.0` which is behind a `&` reference + | `f` is a `&` reference, so the data it refers to cannot be moved + error[E0509]: cannot move out of type `S`, which implements the `Drop` trait --> $DIR/borrowck-move-error-with-note.rs:39:11 | @@ -61,7 +97,19 @@ LL | n => { | ^ -error: aborting due to 3 previous errors +error[E0507]: cannot move out of `a.a` which is behind a `&` reference + --> $DIR/borrowck-move-error-with-note.rs:59:9 + | +LL | let a = &A { a: box 1 }; + | --------------- help: consider changing this to be a mutable reference: `&mut A { a: box 1 }` +... +LL | n => { + | ^ + | | + | cannot move out of `a.a` which is behind a `&` reference + | `a` is a `&` reference, so the data it refers to cannot be moved + +error: aborting due to 7 previous errors Some errors occurred: E0507, E0509. For more information about an error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-from-unsafe-ptr.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,12 +1,23 @@ -error[E0507]: cannot move out of borrowed content +error[E0507]: cannot move out of dereference of raw pointer --> $DIR/borrowck-move-from-unsafe-ptr.rs:13:13 | LL | let y = *x; //~ ERROR cannot move out of dereference of raw pointer | ^^ | | - | cannot move out of borrowed content + | cannot move out of dereference of raw pointer | help: consider removing the `*`: `x` -error: aborting due to previous error +error[E0507]: cannot move out of `*x` which is behind a `*const` pointer + --> $DIR/borrowck-move-from-unsafe-ptr.rs:13:13 + | +LL | unsafe fn foo(x: *const Box) -> Box { + | ----------------- help: consider changing this to be a mutable pointer: `*mut std::boxed::Box` +LL | let y = *x; //~ ERROR cannot move out of dereference of raw pointer + | ^^ + | | + | cannot move out of `*x` which is behind a `*const` pointer + | `x` is a `*const` pointer, so the data it refers to cannot be moved + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -14,6 +14,15 @@ LL | fn arg_item(&_x: &String) {} | ^^ +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/borrowck-move-in-irrefut-pat.rs:16:14 + | +LL | fn arg_item(&_x: &String) {} + | ^^ + | | + | cannot move out of data in a `&` reference + | cannot move + error[E0507]: cannot move out of borrowed content --> $DIR/borrowck-move-in-irrefut-pat.rs:21:11 | @@ -30,6 +39,24 @@ LL | with(|&_x| ()) | ^^ +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/borrowck-move-in-irrefut-pat.rs:21:12 + | +LL | with(|&_x| ()) + | ^^ + | | + | cannot move out of data in a `&` reference + | cannot move + +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/borrowck-move-in-irrefut-pat.rs:27:10 + | +LL | let &_x = &"hi".to_string(); + | ^^ + | | + | cannot move out of data in a `&` reference + | cannot move + error[E0507]: cannot move out of borrowed content --> $DIR/borrowck-move-in-irrefut-pat.rs:27:15 | @@ -45,6 +72,6 @@ LL | let &_x = &"hi".to_string(); | ^^ -error: aborting due to 3 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +error[E0507]: cannot move out of an `Rc` + --> $DIR/borrowck-move-out-of-overloaded-auto-deref.rs:17:14 + | +LL | let _x = Rc::new(vec![1, 2]).into_iter(); + | ^^^^^^^^^^^^^^^^^^^ cannot move out of an `Rc` + +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/borrowck-move-out-of-overloaded-auto-deref.rs:17:14 + | +LL | let _x = Rc::new(vec![1, 2]).into_iter(); + | ^^^^^^^^^^^^^^^^^^^ + | | + | cannot move out of data in a `&` reference + | cannot move + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.mir.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.mir.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.mir.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-out-of-overloaded-auto-deref.mir.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ -error[E0507]: cannot move out of borrowed content +error[E0507]: cannot move out of an `Rc` --> $DIR/borrowck-move-out-of-overloaded-auto-deref.rs:17:14 | LL | let _x = Rc::new(vec![1, 2]).into_iter(); - | ^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content + | ^^^^^^^^^^^^^^^^^^^ cannot move out of an `Rc` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-out-of-overloaded-deref.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,12 +1,21 @@ -error[E0507]: cannot move out of borrowed content +error[E0507]: cannot move out of an `Rc` --> $DIR/borrowck-move-out-of-overloaded-deref.rs:14:14 | LL | let _x = *Rc::new("hi".to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | cannot move out of borrowed content + | cannot move out of an `Rc` | help: consider removing the `*`: `Rc::new("hi".to_string())` -error: aborting due to previous error +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/borrowck-move-out-of-overloaded-deref.rs:14:14 + | +LL | let _x = *Rc::new("hi".to_string()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | cannot move out of data in a `&` reference + | cannot move + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-out-of-static-item.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-out-of-static-item.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-out-of-static-item.ast.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-out-of-static-item.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +error[E0507]: cannot move out of static item + --> $DIR/borrowck-move-out-of-static-item.rs:28:10 + | +LL | test(BAR); //[ast]~ ERROR cannot move out of static item [E0507] + | ^^^ cannot move out of static item + +error[E0507]: cannot move out of immutable static item `BAR` + --> $DIR/borrowck-move-out-of-static-item.rs:28:10 + | +LL | test(BAR); //[ast]~ ERROR cannot move out of static item [E0507] + | ^^^ + | | + | cannot move out of immutable static item `BAR` + | cannot move + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-move-out-of-vec-tail.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -26,6 +26,31 @@ LL | Foo { string: b }] => { | -error: aborting due to previous error +error[E0507]: cannot move out of `tail[..].string` which is behind a `&` reference + --> $DIR/borrowck-move-out-of-vec-tail.rs:30:33 + | +LL | [_, ref tail..] => { + | -------- help: consider changing this to be a mutable reference: `ref mut tail` +LL | match tail { +LL | &[Foo { string: a }, + | ^ + | | + | cannot move out of `tail[..].string` which is behind a `&` reference + | `tail` is a `&` reference, so the data it refers to cannot be moved + +error[E0507]: cannot move out of `tail[..].string` which is behind a `&` reference + --> $DIR/borrowck-move-out-of-vec-tail.rs:34:33 + | +LL | [_, ref tail..] => { + | -------- help: consider changing this to be a mutable reference: `ref mut tail` +... +LL | Foo { string: b }] => { + | ^ + | | + | cannot move out of `tail[..].string` which is behind a `&` reference + | `tail` is a `&` reference, so the data it refers to cannot be moved + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0508`. +Some errors occurred: E0507, E0508. +For more information about an error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-mutate-in-guard.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-mutate-in-guard.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-mutate-in-guard.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-mutate-in-guard.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +error[E0302]: cannot assign in a pattern guard + --> $DIR/borrowck-mutate-in-guard.rs:20:25 + | +LL | Enum::A(_) if { x = Enum::B(false); false } => 1, + | ^^^^^^^^^^^^^^^^^^ assignment in pattern guard + +error[E0301]: cannot mutably borrow in a pattern guard + --> $DIR/borrowck-mutate-in-guard.rs:22:38 + | +LL | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1, + | ^ borrowed mutably in pattern guard + | + = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable + +error[E0302]: cannot assign in a pattern guard + --> $DIR/borrowck-mutate-in-guard.rs:22:41 + | +LL | Enum::A(_) if { let y = &mut x; *y = Enum::B(false); false } => 1, + | ^^^^^^^^^^^^^^^^^^^ assignment in pattern guard + +error: aborting due to 3 previous errors + +Some errors occurred: E0301, E0302. +For more information about an error, try `rustc --explain E0301`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -4,7 +4,7 @@ LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] | ---- ^^^^^^ second mutable borrow occurs here | | - | borrow used here in later iteration of loop + | first borrow used here, in later iteration of loop ... LL | _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499] | ------ first mutable borrow occurs here @@ -13,7 +13,7 @@ --> $DIR/borrowck-mut-borrow-linear-errors.rs:25:30 | LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - | ---- borrow used here in later iteration of loop + | ---- first borrow used here, in later iteration of loop LL | //[mir]~^ ERROR [E0499] LL | 2 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] | ^^^^^^ second mutable borrow occurs here diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.mir.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.mir.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.mir.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.mir.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -4,7 +4,7 @@ LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] | ---- ^^^^^^ second mutable borrow occurs here | | - | borrow used here in later iteration of loop + | first borrow used here, in later iteration of loop ... LL | _ => { addr.push(&mut x); } //[ast]~ ERROR [E0499] | ------ first mutable borrow occurs here @@ -13,7 +13,7 @@ --> $DIR/borrowck-mut-borrow-linear-errors.rs:25:30 | LL | 1 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] - | ---- borrow used here in later iteration of loop + | ---- first borrow used here, in later iteration of loop LL | //[mir]~^ ERROR [E0499] LL | 2 => { addr.push(&mut x); } //[ast]~ ERROR [E0499] | ^^^^^^ second mutable borrow occurs here diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-mut-borrow-of-mut-base-ptr.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^^^^^^ mutable borrow occurs here LL | **t2 += 1; // Mutates `*t0` LL | p.use_ref(); - | - borrow later used here + | - immutable borrow later used here error[E0499]: cannot borrow `t0` as mutable more than once at a time --> $DIR/borrowck-mut-borrow-of-mut-base-ptr.rs:29:18 @@ -18,7 +18,7 @@ | ^^^^^^^ second mutable borrow occurs here LL | **t2 += 1; // Mutates `*t0` but not through `*p` LL | p.use_mut(); - | - borrow later used here + | - first borrow later used here error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-object-lifetime.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-object-lifetime.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-object-lifetime.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-object-lifetime.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -6,7 +6,7 @@ LL | let z = x.mut_borrowed(); //~ ERROR cannot borrow | ^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | y.use_ref(); - | - borrow later used here + | - immutable borrow later used here error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable --> $DIR/borrowck-object-lifetime.rs:36:13 @@ -16,7 +16,7 @@ LL | let z = &mut x; //~ ERROR cannot borrow | ^^^^^^ mutable borrow occurs here LL | y.use_ref(); - | - borrow later used here + | - immutable borrow later used here error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-overloaded-index-autoderef.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-overloaded-index-autoderef.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-overloaded-index-autoderef.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-overloaded-index-autoderef.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -6,7 +6,7 @@ LL | let q = &f[&s]; //~ ERROR cannot borrow | ^ immutable borrow occurs here LL | p.use_mut(); - | - borrow later used here + | - mutable borrow later used here error[E0499]: cannot borrow `*f` as mutable more than once at a time --> $DIR/borrowck-overloaded-index-autoderef.rs:53:18 @@ -16,7 +16,7 @@ LL | let q = &mut f[&s]; //~ ERROR cannot borrow | ^ second mutable borrow occurs here LL | p.use_mut(); - | - borrow later used here + | - first borrow later used here error[E0499]: cannot borrow `f.foo` as mutable more than once at a time --> $DIR/borrowck-overloaded-index-autoderef.rs:63:18 @@ -26,7 +26,7 @@ LL | let q = &mut f.foo[&s]; //~ ERROR cannot borrow | ^^^^^ second mutable borrow occurs here LL | p.use_mut(); - | - borrow later used here + | - first borrow later used here error[E0502]: cannot borrow `f.foo` as mutable because it is also borrowed as immutable --> $DIR/borrowck-overloaded-index-autoderef.rs:75:18 @@ -36,7 +36,7 @@ LL | let q = &mut f.foo[&s]; //~ ERROR cannot borrow | ^^^^^ mutable borrow occurs here LL | p.use_ref(); - | - borrow later used here + | - immutable borrow later used here error[E0506]: cannot assign to `f.foo` because it is borrowed --> $DIR/borrowck-overloaded-index-autoderef.rs:81:5 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-overloaded-index-move-from-vec.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,6 +7,15 @@ | cannot move out of borrowed content | help: consider borrowing here: `&v[0]` -error: aborting due to previous error +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/borrowck-overloaded-index-move-from-vec.rs:30:15 + | +LL | let bad = v[0]; + | ^^^^ + | | + | cannot move out of data in a `&` reference + | cannot move + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.ast.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^ immutable borrow occurs here ... LL | drop(rs); - | -- borrow later used here + | -- mutable borrow later used here error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable --> $DIR/borrowck-overloaded-index-ref-index.rs:65:7 @@ -19,7 +19,7 @@ | ^^ immutable borrow occurs here ... LL | drop(rs); - | -- borrow later used here + | -- mutable borrow later used here error[E0594]: cannot assign to data in a `&` reference --> $DIR/borrowck-overloaded-index-ref-index.rs:71:5 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.mir.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.mir.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.mir.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-overloaded-index-ref-index.mir.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^ immutable borrow occurs here ... LL | drop(rs); - | -- borrow later used here + | -- mutable borrow later used here error[E0502]: cannot borrow `s` as immutable because it is also borrowed as mutable --> $DIR/borrowck-overloaded-index-ref-index.rs:65:7 @@ -19,7 +19,7 @@ | ^^ immutable borrow occurs here ... LL | drop(rs); - | -- borrow later used here + | -- mutable borrow later used here error[E0594]: cannot assign to data in a `&` reference --> $DIR/borrowck-overloaded-index-ref-index.rs:71:5 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-reborrow-from-shorter-lived-andmut.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:19:5 - | -LL | fn copy_borrowed_ptr<'a,'b>(p: &'a mut S<'b>) -> S<'b> { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | S { pointer: &mut *p.pointer } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | ^^ immutable borrow occurs here ... LL | y.use_mut(); - | - borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable --> $DIR/borrowck-report-with-custom-diagnostic.rs:30:21 @@ -20,7 +20,7 @@ | ^^^^^^ mutable borrow occurs here ... LL | y.use_ref(); - | - borrow later used here + | - immutable borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-report-with-custom-diagnostic.rs:45:17 @@ -32,7 +32,7 @@ | ^^^^^^ second mutable borrow occurs here ... LL | y.use_mut(); - | - borrow later used here + | - first borrow later used here error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-return-variable-on-stack-via-clone.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,17 +1,12 @@ -error[E0597]: `x` does not live long enough +error[E0515]: cannot return value referencing function parameter `x` --> $DIR/borrowck-return-variable-on-stack-via-clone.rs:17:5 | LL | (&x).clone() //~ ERROR `x` does not live long enough - | ^^^^ borrowed value does not live long enough -LL | } - | - `x` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 16:9... - --> $DIR/borrowck-return-variable-on-stack-via-clone.rs:16:9 - | -LL | fn leak<'a, T>(x: T) -> &'a T { - | ^^ + | ----^^^^^^^^ + | | + | returns a value referencing data owned by the current function + | `x` is borrowed here error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-slice-pattern-element-loan.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -6,7 +6,7 @@ LL | if let [_, ref mut second2, ref mut third, ..] = *s { //~ERROR | ^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[first, second, second2, third]); - | ------ borrow later used here + | ------ immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan.rs:44:21 @@ -16,7 +16,7 @@ LL | if let [.., ref mut third2, _, _] = *s { //~ERROR | ^^^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[first, third, third2, fourth]); - | ----- borrow later used here + | ----- immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan.rs:55:20 @@ -27,7 +27,7 @@ LL | if let [_, ref mut from_begin1, ..] = *s { //~ERROR | ^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[from_begin1, from_end1, from_end3, from_end4]); - | --------- borrow later used here + | --------- immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan.rs:58:23 @@ -38,7 +38,7 @@ LL | if let [_, _, ref mut from_begin2, ..] = *s { //~ERROR | ^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[from_begin2, from_end1, from_end3, from_end4]); - | --------- borrow later used here + | --------- immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan.rs:61:26 @@ -49,7 +49,7 @@ LL | if let [_, _, _, ref mut from_begin3, ..] = *s { //~ERROR | ^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[from_begin3, from_end1, from_end3, from_end4]); - | --------- borrow later used here + | --------- immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan.rs:69:21 @@ -60,7 +60,7 @@ LL | if let [.., ref mut from_end2, _] = *s { //~ERROR | ^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[from_begin0, from_begin1, from_begin3, from_end2]); - | ----------- borrow later used here + | ----------- immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan.rs:72:21 @@ -71,7 +71,7 @@ LL | if let [.., ref mut from_end3, _, _] = *s { //~ERROR | ^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[from_begin0, from_begin1, from_begin3, from_end3]); - | ----------- borrow later used here + | ----------- immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan.rs:75:21 @@ -82,7 +82,7 @@ LL | if let [.., ref mut from_end4, _, _, _] = *s { //~ERROR | ^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[from_begin0, from_begin1, from_begin3, from_end4]); - | ----------- borrow later used here + | ----------- immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan.rs:92:20 @@ -92,7 +92,7 @@ LL | if let [_, ref mut tail..] = *s { //~ERROR | ^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[first, second]); - | ------ borrow later used here + | ------ immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan.rs:110:17 @@ -102,7 +102,7 @@ LL | if let [ref mut tail.., _] = *s { //~ERROR | ^^^^^^^^^^^^ mutable borrow occurs here LL | nop(&[first, second]); - | ------ borrow later used here + | ------ immutable borrow later used here error[E0502]: cannot borrow `s[..]` as mutable because it is also borrowed as immutable --> $DIR/borrowck-slice-pattern-element-loan.rs:119:17 @@ -112,7 +112,7 @@ LL | if let [ref mut s2.., _, _, _] = *s { //~ERROR | ^^^^^^^^^^ mutable borrow occurs here LL | nop_subslice(s1); - | -- borrow later used here + | -- immutable borrow later used here error: aborting due to 11 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-swap-mut-base-ptr.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-swap-mut-base-ptr.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-swap-mut-base-ptr.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-swap-mut-base-ptr.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^^^^^^ mutable borrow occurs here LL | *t1 = 22; LL | p.use_ref(); - | - borrow later used here + | - immutable borrow later used here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uninit-field-access.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uninit-field-access.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uninit-field-access.ast.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uninit-field-access.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,10 +1,10 @@ -error[E0381]: use of possibly uninitialized variable: `a.x` +error[E0381]: use of possibly uninitialized variable: `a` --> $DIR/borrowck-uninit-field-access.rs:34:13 | LL | let _ = a.x + 1; //[ast]~ ERROR use of possibly uninitialized variable: `a.x` | ^^^ use of possibly uninitialized `a.x` -error[E0382]: use of moved value: `line1.origin.x` +error[E0382]: use of moved value: `line1.origin` --> $DIR/borrowck-uninit-field-access.rs:39:13 | LL | let _moved = line1.origin; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uninit-field-access.mir.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uninit-field-access.mir.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uninit-field-access.mir.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uninit-field-access.mir.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,10 +1,10 @@ -error[E0381]: use of possibly uninitialized variable: `a.x` +error[E0381]: use of possibly uninitialized variable: `a` --> $DIR/borrowck-uninit-field-access.rs:34:13 | LL | let _ = a.x + 1; //[ast]~ ERROR use of possibly uninitialized variable: `a.x` | ^^^ use of possibly uninitialized `a.x` -error[E0382]: use of moved value: `line1.origin.x` +error[E0382]: use of moved value: `line1.origin` --> $DIR/borrowck-uninit-field-access.rs:39:13 | LL | let _moved = line1.origin; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uninit-ref-chain.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uninit-ref-chain.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uninit-ref-chain.ast.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uninit-ref-chain.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,33 +1,45 @@ -error[E0381]: borrow of possibly uninitialized variable: `**x` +error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/borrowck-uninit-ref-chain.rs:21:14 | LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] | ^^^^ use of possibly uninitialized `**x` -error[E0381]: borrow of possibly uninitialized variable: `**x` +error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/borrowck-uninit-ref-chain.rs:25:14 | LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] | ^^^^ use of possibly uninitialized `**x` -error[E0381]: borrow of possibly uninitialized variable: `**x` +error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/borrowck-uninit-ref-chain.rs:29:14 | LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] | ^^^^ use of possibly uninitialized `**x` -error[E0381]: borrow of possibly uninitialized variable: `a.y` - --> $DIR/borrowck-uninit-ref-chain.rs:46:14 +error[E0381]: assign to part of possibly uninitialized variable: `a` + --> $DIR/borrowck-uninit-ref-chain.rs:34:5 | -LL | let _b = &a.y; //[ast]~ ERROR use of possibly uninitialized variable: `a.y` [E0381] - | ^^^^ use of possibly uninitialized `a.y` +LL | a.x = 0; //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] + | ^^^^^^^ use of possibly uninitialized `a` -error[E0381]: borrow of possibly uninitialized variable: `**a.y` - --> $DIR/borrowck-uninit-ref-chain.rs:51:14 +error[E0381]: assign to part of possibly uninitialized variable: `a` + --> $DIR/borrowck-uninit-ref-chain.rs:39:5 | -LL | let _b = &**a.y; //[ast]~ ERROR use of possibly uninitialized variable: `**a.y` [E0381] - | ^^^^^^ use of possibly uninitialized `**a.y` +LL | a.x = &&0; //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] + | ^^^^^^^^^ use of possibly uninitialized `a` -error: aborting due to 5 previous errors +error[E0381]: assign to part of possibly uninitialized variable: `a` + --> $DIR/borrowck-uninit-ref-chain.rs:45:5 + | +LL | a.x = 0; //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] + | ^^^^^^^ use of possibly uninitialized `a` + +error[E0381]: assign to part of possibly uninitialized variable: `a` + --> $DIR/borrowck-uninit-ref-chain.rs:50:5 + | +LL | a.x = &&0; //[mir]~ assign to part of possibly uninitialized variable: `a` [E0381] + | ^^^^^^^^^ use of possibly uninitialized `a` + +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0381`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uninit-ref-chain.mir.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uninit-ref-chain.mir.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uninit-ref-chain.mir.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uninit-ref-chain.mir.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,33 +1,45 @@ -error[E0381]: borrow of possibly uninitialized variable: `**x` +error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/borrowck-uninit-ref-chain.rs:21:14 | LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] | ^^^^ use of possibly uninitialized `**x` -error[E0381]: borrow of possibly uninitialized variable: `**x` +error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/borrowck-uninit-ref-chain.rs:25:14 | LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] | ^^^^ use of possibly uninitialized `**x` -error[E0381]: borrow of possibly uninitialized variable: `**x` +error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/borrowck-uninit-ref-chain.rs:29:14 | LL | let _y = &**x; //[ast]~ ERROR use of possibly uninitialized variable: `**x` [E0381] | ^^^^ use of possibly uninitialized `**x` -error[E0381]: borrow of possibly uninitialized variable: `a.y` - --> $DIR/borrowck-uninit-ref-chain.rs:46:14 +error[E0381]: assign to part of possibly uninitialized variable: `a` + --> $DIR/borrowck-uninit-ref-chain.rs:34:5 | -LL | let _b = &a.y; //[ast]~ ERROR use of possibly uninitialized variable: `a.y` [E0381] - | ^^^^ use of possibly uninitialized `a.y` +LL | a.x = 0; //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] + | ^^^^^^^ use of possibly uninitialized `a` -error[E0381]: borrow of possibly uninitialized variable: `**a.y` - --> $DIR/borrowck-uninit-ref-chain.rs:51:14 +error[E0381]: assign to part of possibly uninitialized variable: `a` + --> $DIR/borrowck-uninit-ref-chain.rs:39:5 | -LL | let _b = &**a.y; //[ast]~ ERROR use of possibly uninitialized variable: `**a.y` [E0381] - | ^^^^^^ use of possibly uninitialized `**a.y` +LL | a.x = &&0; //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] + | ^^^^^^^^^ use of possibly uninitialized `a` -error: aborting due to 5 previous errors +error[E0381]: assign to part of possibly uninitialized variable: `a` + --> $DIR/borrowck-uninit-ref-chain.rs:45:5 + | +LL | a.x = 0; //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] + | ^^^^^^^ use of possibly uninitialized `a` + +error[E0381]: assign to part of possibly uninitialized variable: `a` + --> $DIR/borrowck-uninit-ref-chain.rs:50:5 + | +LL | a.x = &&0; //[mir]~ assign to part of possibly uninitialized variable: `a` [E0381] + | ^^^^^^^^^ use of possibly uninitialized `a` + +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0381`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uninit-ref-chain.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uninit-ref-chain.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uninit-ref-chain.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uninit-ref-chain.rs 2018-12-04 23:41:40.000000000 +0000 @@ -31,23 +31,23 @@ let mut a: S; - a.x = 0; + a.x = 0; //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] let _b = &a.x; //[ast]~ ERROR use of possibly uninitialized variable: `a.x` [E0381] - // (deliberately *not* an error under MIR-borrowck) + let mut a: S<&&i32, &&i32>; - a.x = &&0; + a.x = &&0; //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] let _b = &**a.x; //[ast]~ ERROR use of possibly uninitialized variable: `**a.x` [E0381] - // (deliberately *not* an error under MIR-borrowck) + let mut a: S; - a.x = 0; + a.x = 0; //[mir]~ ERROR assign to part of possibly uninitialized variable: `a` [E0381] let _b = &a.y; //[ast]~ ERROR use of possibly uninitialized variable: `a.y` [E0381] - //[mir]~^ ERROR [E0381] + let mut a: S<&&i32, &&i32>; - a.x = &&0; + a.x = &&0; //[mir]~ assign to part of possibly uninitialized variable: `a` [E0381] let _b = &**a.y; //[ast]~ ERROR use of possibly uninitialized variable: `**a.y` [E0381] - //[mir]~^ ERROR [E0381] + } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-union-borrow.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-union-borrow.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-union-borrow.ast.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-union-borrow.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^^^^^^^ mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable LL | drop(ra); - | -- borrow later used here + | -- immutable borrow later used here error[E0506]: cannot assign to `u.a` because it is borrowed --> $DIR/borrowck-union-borrow.rs:43:13 @@ -29,7 +29,7 @@ | ^^^^^^^^ mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.b` as mutable because it is also borrowed as immutable LL | drop(ra); - | -- borrow later used here + | -- immutable borrow later used here error[E0506]: cannot assign to `u.b` because it is borrowed --> $DIR/borrowck-union-borrow.rs:66:13 @@ -51,7 +51,7 @@ | ^^^^ immutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable LL | drop(rma); - | --- borrow later used here + | --- mutable borrow later used here error[E0503]: cannot use `u.a` because it was mutably borrowed --> $DIR/borrowck-union-borrow.rs:79:21 @@ -73,7 +73,7 @@ | ^^^^^^^^ second mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.a` as mutable more than once at a time LL | drop(rma); - | --- borrow later used here + | --- first borrow later used here error[E0506]: cannot assign to `u.a` because it is borrowed --> $DIR/borrowck-union-borrow.rs:91:13 @@ -95,7 +95,7 @@ | ^^^^ immutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.b` as immutable because it is also borrowed as mutable LL | drop(rma); - | --- borrow later used here + | --- mutable borrow later used here error[E0503]: cannot use `u.b` because it was mutably borrowed --> $DIR/borrowck-union-borrow.rs:104:21 @@ -117,7 +117,7 @@ | ^^^^^^^^ second mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.b` as mutable more than once at a time LL | drop(rma); - | --- borrow later used here + | --- first borrow later used here error[E0506]: cannot assign to `u.b` because it is borrowed --> $DIR/borrowck-union-borrow.rs:117:13 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-union-borrow.mir.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-union-borrow.mir.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-union-borrow.mir.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-union-borrow.mir.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^^^^^^^ mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.a` as mutable because it is also borrowed as immutable LL | drop(ra); - | -- borrow later used here + | -- immutable borrow later used here error[E0506]: cannot assign to `u.a` because it is borrowed --> $DIR/borrowck-union-borrow.rs:43:13 @@ -29,7 +29,7 @@ | ^^^^^^^^ mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.b` as mutable because it is also borrowed as immutable LL | drop(ra); - | -- borrow later used here + | -- immutable borrow later used here error[E0506]: cannot assign to `u.b` because it is borrowed --> $DIR/borrowck-union-borrow.rs:66:13 @@ -51,7 +51,7 @@ | ^^^^ immutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.a` as immutable because it is also borrowed as mutable LL | drop(rma); - | --- borrow later used here + | --- mutable borrow later used here error[E0503]: cannot use `u.a` because it was mutably borrowed --> $DIR/borrowck-union-borrow.rs:79:21 @@ -73,7 +73,7 @@ | ^^^^^^^^ second mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.a` as mutable more than once at a time LL | drop(rma); - | --- borrow later used here + | --- first borrow later used here error[E0506]: cannot assign to `u.a` because it is borrowed --> $DIR/borrowck-union-borrow.rs:91:13 @@ -95,7 +95,7 @@ | ^^^^ immutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.b` as immutable because it is also borrowed as mutable LL | drop(rma); - | --- borrow later used here + | --- mutable borrow later used here error[E0503]: cannot use `u.b` because it was mutably borrowed --> $DIR/borrowck-union-borrow.rs:104:21 @@ -117,7 +117,7 @@ | ^^^^^^^^ second mutable borrow occurs here LL | //[mir]~^ ERROR cannot borrow `u.b` as mutable more than once at a time LL | drop(rma); - | --- borrow later used here + | --- first borrow later used here error[E0506]: cannot assign to `u.b` because it is borrowed --> $DIR/borrowck-union-borrow.rs:117:13 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-union-move-assign.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-union-move-assign.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-union-move-assign.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-union-move-assign.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ -error[E0382]: use of moved value: `u.a` +error[E0382]: use of moved value: `u` --> $DIR/borrowck-union-move-assign.rs:27:21 | LL | let a = u.a; @@ -8,7 +8,7 @@ | = note: move occurs because `u` has type `U`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `u.a` +error[E0382]: use of moved value: `u` --> $DIR/borrowck-union-move-assign.rs:33:21 | LL | let a = u.a; @@ -19,7 +19,7 @@ | = note: move occurs because `u` has type `U`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `u.a` +error[E0382]: use of moved value: `u` --> $DIR/borrowck-union-move-assign.rs:39:21 | LL | let a = u.a; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-union-move.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-union-move.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-union-move.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-union-move.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ -error[E0382]: use of moved value: `u.n1` +error[E0382]: use of moved value: `u` --> $DIR/borrowck-union-move.rs:36:21 | LL | let a = u.n1; @@ -18,7 +18,7 @@ | = note: move occurs because `u` has type `Unn`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `u.n2` +error[E0382]: use of moved value: `u` --> $DIR/borrowck-union-move.rs:46:21 | LL | let a = u.n1; @@ -28,7 +28,7 @@ | = note: move occurs because `u` has type `Unn`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `u.n` +error[E0382]: use of moved value: `u` --> $DIR/borrowck-union-move.rs:73:21 | LL | let a = u.n; @@ -38,7 +38,7 @@ | = note: move occurs because `u` has type `Ucn`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `u.c` +error[E0382]: use of moved value: `u` --> $DIR/borrowck-union-move.rs:78:21 | LL | let a = u.n; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-union-uninitialized.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-union-uninitialized.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-union-uninitialized.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-union-uninitialized.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,9 +1,15 @@ -error[E0381]: use of possibly uninitialized variable: `u.a` - --> $DIR/borrowck-union-uninitialized.rs:26:18 +error[E0381]: assign to part of possibly uninitialized variable: `s` + --> $DIR/borrowck-union-uninitialized.rs:23:9 | -LL | let ua = u.a; //~ ERROR use of possibly uninitialized variable: `u.a` - | ^^^ use of possibly uninitialized `u.a` +LL | s.a = 0; + | ^^^^^^^ use of possibly uninitialized `s` -error: aborting due to previous error +error[E0381]: assign to part of possibly uninitialized variable: `u` + --> $DIR/borrowck-union-uninitialized.rs:24:9 + | +LL | u.a = 0; + | ^^^^^^^ use of possibly uninitialized `u` + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0381`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uniq-via-lend.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uniq-via-lend.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uniq-via-lend.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-uniq-via-lend.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -6,7 +6,7 @@ LL | borrow(&*v); //~ ERROR cannot borrow `*v` | ^^^ immutable borrow occurs here LL | w.use_mut(); - | - borrow later used here + | - mutable borrow later used here error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable --> $DIR/borrowck-uniq-via-lend.rs:63:12 @@ -16,7 +16,7 @@ LL | borrow(&*v); //~ ERROR cannot borrow `*v` | ^^^ immutable borrow occurs here LL | x.use_mut(); - | - borrow later used here + | - mutable borrow later used here error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-in-index-lvalue.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-in-index-lvalue.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-in-index-lvalue.ast.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-in-index-lvalue.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,10 +1,10 @@ -error[E0381]: use of possibly uninitialized variable: `*w` +error[E0381]: use of possibly uninitialized variable: `w` --> $DIR/borrowck-use-in-index-lvalue.rs:16:5 | LL | w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] | ^^^^ use of possibly uninitialized `*w` -error[E0381]: use of possibly uninitialized variable: `*w` +error[E0381]: use of possibly uninitialized variable: `w` --> $DIR/borrowck-use-in-index-lvalue.rs:20:5 | LL | w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-in-index-lvalue.mir.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-in-index-lvalue.mir.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-in-index-lvalue.mir.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-in-index-lvalue.mir.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,10 +1,10 @@ -error[E0381]: use of possibly uninitialized variable: `*w` +error[E0381]: use of possibly uninitialized variable: `w` --> $DIR/borrowck-use-in-index-lvalue.rs:16:5 | LL | w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] | ^^^^ use of possibly uninitialized `*w` -error[E0381]: use of possibly uninitialized variable: `*w` +error[E0381]: use of possibly uninitialized variable: `w` --> $DIR/borrowck-use-in-index-lvalue.rs:20:5 | LL | w[5] = 0; //[ast]~ ERROR use of possibly uninitialized variable: `*w` [E0381] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.ast.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ -error[E0381]: borrow of possibly uninitialized variable: `*x` +error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/borrowck-use-uninitialized-in-cast.rs:20:13 | LL | let y = x as *const i32; //[ast]~ ERROR use of possibly uninitialized variable: `*x` [E0381] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.mir.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.mir.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.mir.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast.mir.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ -error[E0381]: borrow of possibly uninitialized variable: `*x` +error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/borrowck-use-uninitialized-in-cast.rs:20:13 | LL | let y = x as *const i32; //[ast]~ ERROR use of possibly uninitialized variable: `*x` [E0381] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ -error[E0381]: borrow of possibly uninitialized variable: `*x` +error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/borrowck-use-uninitialized-in-cast-trait.rs:22:13 | LL | let y = x as *const Foo; //[ast]~ ERROR use of possibly uninitialized variable: `*x` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.mir.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.mir.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.mir.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-use-uninitialized-in-cast-trait.mir.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ -error[E0381]: borrow of possibly uninitialized variable: `*x` +error[E0381]: borrow of possibly uninitialized variable: `x` --> $DIR/borrowck-use-uninitialized-in-cast-trait.rs:22:13 | LL | let y = x as *const Foo; //[ast]~ ERROR use of possibly uninitialized variable: `*x` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-vec-pattern-element-loan.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,48 +1,30 @@ -error[E0597]: `vec` does not live long enough - --> $DIR/borrowck-vec-pattern-element-loan.rs:15:25 +error[E0515]: cannot return value referencing local variable `vec` + --> $DIR/borrowck-vec-pattern-element-loan.rs:20:5 | LL | let vec: &[isize] = &vec; //~ ERROR does not live long enough - | ^^^^ borrowed value does not live long enough + | ---- `vec` is borrowed here ... -LL | } - | - `vec` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:6... - --> $DIR/borrowck-vec-pattern-element-loan.rs:13:6 - | -LL | fn a<'a>() -> &'a [isize] { - | ^^ +LL | tail + | ^^^^ returns a value referencing data owned by the current function -error[E0597]: `vec` does not live long enough - --> $DIR/borrowck-vec-pattern-element-loan.rs:25:25 +error[E0515]: cannot return value referencing local variable `vec` + --> $DIR/borrowck-vec-pattern-element-loan.rs:30:5 | LL | let vec: &[isize] = &vec; //~ ERROR does not live long enough - | ^^^^ borrowed value does not live long enough + | ---- `vec` is borrowed here ... -LL | } - | - `vec` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 23:6... - --> $DIR/borrowck-vec-pattern-element-loan.rs:23:6 - | -LL | fn b<'a>() -> &'a [isize] { - | ^^ +LL | init + | ^^^^ returns a value referencing data owned by the current function -error[E0597]: `vec` does not live long enough - --> $DIR/borrowck-vec-pattern-element-loan.rs:35:25 +error[E0515]: cannot return value referencing local variable `vec` + --> $DIR/borrowck-vec-pattern-element-loan.rs:40:5 | LL | let vec: &[isize] = &vec; //~ ERROR does not live long enough - | ^^^^ borrowed value does not live long enough + | ---- `vec` is borrowed here ... -LL | } - | - `vec` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 33:6... - --> $DIR/borrowck-vec-pattern-element-loan.rs:33:6 - | -LL | fn c<'a>() -> &'a [isize] { - | ^^ +LL | slice + | ^^^^^ returns a value referencing data owned by the current function error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-vec-pattern-loan-from-mut.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-vec-pattern-loan-from-mut.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-vec-pattern-loan-from-mut.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-vec-pattern-loan-from-mut.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -5,7 +5,7 @@ | ------ first mutable borrow occurs here ... LL | v.push(tail[0] + tail[1]); //~ ERROR cannot borrow - | ^ ------- borrow later used here + | ^ ------- first borrow later used here | | | second mutable borrow occurs here diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrowck-vec-pattern-tail-element-loan.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,18 +1,12 @@ -error[E0597]: `vec` does not live long enough - --> $DIR/borrowck-vec-pattern-tail-element-loan.rs:15:25 +error[E0515]: cannot return value referencing local variable `vec` + --> $DIR/borrowck-vec-pattern-tail-element-loan.rs:20:5 | LL | let vec: &[isize] = &vec; //~ ERROR `vec` does not live long enough - | ^^^^ borrowed value does not live long enough + | ---- `vec` is borrowed here ... -LL | } - | - `vec` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:6... - --> $DIR/borrowck-vec-pattern-tail-element-loan.rs:13:6 - | -LL | fn a<'a>() -> &'a isize { - | ^^ +LL | tail + | ^^^^ returns a value referencing data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrow-tuple-fields.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrow-tuple-fields.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/borrow-tuple-fields.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/borrow-tuple-fields.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -17,7 +17,7 @@ LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable because it is also borrowed as | ^^^^^^^^ mutable borrow occurs here LL | a.use_ref(); - | - borrow later used here + | - immutable borrow later used here error[E0499]: cannot borrow `x.0` as mutable more than once at a time --> $DIR/borrow-tuple-fields.rs:33:13 @@ -27,7 +27,7 @@ LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time | ^^^^^^^^ second mutable borrow occurs here LL | a.use_ref(); - | - borrow later used here + | - first borrow later used here error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/borrow-tuple-fields.rs:38:13 @@ -47,7 +47,7 @@ LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable because it is also borrowed as | ^^^^^^^^ mutable borrow occurs here LL | a.use_ref(); - | - borrow later used here + | - immutable borrow later used here error[E0499]: cannot borrow `x.0` as mutable more than once at a time --> $DIR/borrow-tuple-fields.rs:48:13 @@ -57,7 +57,7 @@ LL | let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time | ^^^^^^^^ second mutable borrow occurs here LL | a.use_mut(); - | - borrow later used here + | - first borrow later used here error: aborting due to 6 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-41962.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-41962.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-41962.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-41962.rs 2018-12-04 23:41:40.000000000 +0000 @@ -18,9 +18,6 @@ } //~^^ 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 (Mir) [E0382] - //~| ERROR borrow of moved value: `maybe` (Mir) [E0382] } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-41962.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-41962.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-41962.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-41962.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -16,45 +16,14 @@ | = note: move occurs because the value has type `std::vec::Vec`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `maybe` (Mir) - --> $DIR/issue-41962.rs:17:16 - | -LL | if let Some(thing) = maybe { - | ^^^^^-----^ - | | | - | | value moved here - | value used here after move - | - = note: move occurs because value has type `std::vec::Vec`, which does not implement the `Copy` trait - error[E0382]: use of moved value (Mir) --> $DIR/issue-41962.rs:17:21 | LL | if let Some(thing) = maybe { - | ^^^^^ value moved here in previous iteration of loop - | - = note: move occurs because value has type `std::vec::Vec`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `maybe` (Mir) - --> $DIR/issue-41962.rs:17:30 - | -LL | if let Some(thing) = maybe { - | ----- ^^^^^ value used here after move - | | - | value moved here - | - = note: move occurs because value has type `std::vec::Vec`, which does not implement the `Copy` trait - -error[E0382]: borrow of moved value: `maybe` (Mir) - --> $DIR/issue-41962.rs:17:30 - | -LL | if let Some(thing) = maybe { - | ----- ^^^^^ value borrowed here after move - | | - | value moved here + | ^^^^^ value moved here, in previous iteration of loop | = note: move occurs because value has type `std::vec::Vec`, which does not implement the `Copy` trait -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-45983.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-45983.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-45983.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-45983.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ -error: borrowed data escapes outside of closure +error[E0521]: borrowed data escapes outside of closure --> $DIR/issue-45983.rs:36:18 | LL | let x = None; @@ -18,4 +18,5 @@ error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0594`. +Some errors occurred: E0521, E0594. +For more information about an error, try `rustc --explain E0521`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-51117.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-51117.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-51117.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-51117.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -6,7 +6,7 @@ LL | bar.take(); //~ ERROR cannot borrow | ^^^ second mutable borrow occurs here LL | drop(baz); - | --- borrow later used here + | --- first borrow later used here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-51415.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-51415.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-51415.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-51415.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -13,6 +13,15 @@ LL | let opt = a.iter().enumerate().find(|(_, &s)| { | ^ -error: aborting due to previous error +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/issue-51415.rs:16:47 + | +LL | let opt = a.iter().enumerate().find(|(_, &s)| { + | ^ + | | + | cannot move out of data in a `&` reference + | cannot move + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.ast.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.ast.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.ast.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.ast.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +error[E0381]: use of possibly uninitialized variable: `t.0` + --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:25:31 + | +LL | println!("{:?} {:?}", t.0, t.1); + | ^^^ use of possibly uninitialized `t.0` + +error[E0381]: use of possibly uninitialized variable: `t.1` + --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:25:36 + | +LL | println!("{:?} {:?}", t.0, t.1); + | ^^^ use of possibly uninitialized `t.1` + +error[E0381]: use of possibly uninitialized variable: `u.0` + --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:35:31 + | +LL | println!("{:?} {:?}", u.0, u.1); + | ^^^ use of possibly uninitialized `u.0` + +error[E0381]: use of possibly uninitialized variable: `u.1` + --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:35:36 + | +LL | println!("{:?} {:?}", u.0, u.1); + | ^^^ use of possibly uninitialized `u.1` + +error[E0381]: use of possibly uninitialized variable: `v.x` + --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:45:31 + | +LL | println!("{:?} {:?}", v.x, v.y); + | ^^^ use of possibly uninitialized `v.x` + +error[E0381]: use of possibly uninitialized variable: `v.y` + --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:45:36 + | +LL | println!("{:?} {:?}", v.x, v.y); + | ^^^ use of possibly uninitialized `v.y` + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0381`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +error[E0381]: assign to part of possibly uninitialized variable: `t` + --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:22:9 + | +LL | t.0 = S(1); + | ^^^^^^^^^^ use of possibly uninitialized `t` + +error[E0381]: assign to part of possibly uninitialized variable: `u` + --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:32:9 + | +LL | u.0 = S(1); + | ^^^^^^^^^^ use of possibly uninitialized `u` + +error[E0381]: assign to part of possibly uninitialized variable: `v` + --> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:42:9 + | +LL | v.x = S(1); + | ^^^^^^^^^^ use of possibly uninitialized `v` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0381`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-marks-mut-as-used.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,49 @@ +// revisions: ast nll + +// Since we are testing nll migration explicitly as a separate +// revision, don't worry about the --compare-mode=nll on this test. + +// ignore-compare-mode-nll + +//[ast]compile-flags: -Z borrowck=ast +//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows + +#![warn(unused)] +#[derive(Debug)] +struct S(i32); + +type Tuple = (S, i32); +struct Tpair(S, i32); +struct Spair { x: S, y: i32 } + +fn main() { + { + let mut t: Tuple; + t.0 = S(1); + //[nll]~^ ERROR assign to part of possibly uninitialized variable: `t` [E0381] + t.1 = 2; + println!("{:?} {:?}", t.0, t.1); + //[ast]~^ ERROR use of possibly uninitialized variable: `t.0` [E0381] + //[ast]~| ERROR use of possibly uninitialized variable: `t.1` [E0381] + } + + { + let mut u: Tpair; + u.0 = S(1); + //[nll]~^ ERROR assign to part of possibly uninitialized variable: `u` [E0381] + u.1 = 2; + println!("{:?} {:?}", u.0, u.1); + //[ast]~^ ERROR use of possibly uninitialized variable: `u.0` [E0381] + //[ast]~| ERROR use of possibly uninitialized variable: `u.1` [E0381] + } + + { + let mut v: Spair; + v.x = S(1); + //[nll]~^ ERROR assign to part of possibly uninitialized variable: `v` [E0381] + v.y = 2; + println!("{:?} {:?}", v.x, v.y); + //[ast]~^ ERROR use of possibly uninitialized variable: `v.x` [E0381] + //[ast]~| ERROR use of possibly uninitialized variable: `v.y` [E0381] + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.ast.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.ast.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.ast.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.ast.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,124 @@ +error[E0594]: cannot assign to field `t.0` of immutable binding + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:23:9 + | +LL | let t: Tuple = (S(0), 0); + | - help: make this binding mutable: `mut t` +LL | drop(t); +LL | t.0 = S(1); + | ^^^^^^^^^^ cannot mutably borrow field of immutable binding + +error[E0594]: cannot assign to field `t.1` of immutable binding + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:27:9 + | +LL | let t: Tuple = (S(0), 0); + | - help: make this binding mutable: `mut t` +... +LL | t.1 = 2; + | ^^^^^^^ cannot mutably borrow field of immutable binding + +error[E0594]: cannot assign to field `u.0` of immutable binding + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:38:9 + | +LL | let u: Tpair = Tpair(S(0), 0); + | - help: make this binding mutable: `mut u` +LL | drop(u); +LL | u.0 = S(1); + | ^^^^^^^^^^ cannot mutably borrow field of immutable binding + +error[E0594]: cannot assign to field `u.1` of immutable binding + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:42:9 + | +LL | let u: Tpair = Tpair(S(0), 0); + | - help: make this binding mutable: `mut u` +... +LL | u.1 = 2; + | ^^^^^^^ cannot mutably borrow field of immutable binding + +error[E0594]: cannot assign to field `v.x` of immutable binding + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:53:9 + | +LL | let v: Spair = Spair { x: S(0), y: 0 }; + | - help: make this binding mutable: `mut v` +LL | drop(v); +LL | v.x = S(1); + | ^^^^^^^^^^ cannot mutably borrow field of immutable binding + +error[E0594]: cannot assign to field `v.y` of immutable binding + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:57:9 + | +LL | let v: Spair = Spair { x: S(0), y: 0 }; + | - help: make this binding mutable: `mut v` +... +LL | v.y = 2; + | ^^^^^^^ cannot mutably borrow field of immutable binding + +error[E0382]: use of moved value: `t.0` + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:30:31 + | +LL | drop(t); + | - value moved here +... +LL | println!("{:?} {:?}", t.0, t.1); + | ^^^ value used here after move + | + = note: move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `t.1` + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:30:36 + | +LL | drop(t); + | - value moved here +... +LL | println!("{:?} {:?}", t.0, t.1); + | ^^^ value used here after move + | + = note: move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `u.0` + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:45:31 + | +LL | drop(u); + | - value moved here +... +LL | println!("{:?} {:?}", u.0, u.1); + | ^^^ value used here after move + | + = note: move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `u.1` + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:45:36 + | +LL | drop(u); + | - value moved here +... +LL | println!("{:?} {:?}", u.0, u.1); + | ^^^ value used here after move + | + = note: move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `v.x` + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:60:31 + | +LL | drop(v); + | - value moved here +... +LL | println!("{:?} {:?}", v.x, v.y); + | ^^^ value used here after move + | + = note: move occurs because `v` has type `Spair`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `v.y` + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:60:36 + | +LL | drop(v); + | - value moved here +... +LL | println!("{:?} {:?}", v.x, v.y); + | ^^^ value used here after move + | + = note: move occurs because `v` has type `Spair`, which does not implement the `Copy` trait + +error: aborting due to 12 previous errors + +Some errors occurred: E0382, E0594. +For more information about an error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,88 @@ +error[E0594]: cannot assign to `t.0`, as `t` is not declared as mutable + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:23:9 + | +LL | let t: Tuple = (S(0), 0); + | - help: consider changing this to be mutable: `mut t` +LL | drop(t); +LL | t.0 = S(1); + | ^^^^^^^^^^ cannot assign + +error[E0382]: assign to part of moved value: `t` + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:23:9 + | +LL | drop(t); + | - value moved here +LL | t.0 = S(1); + | ^^^^^^^^^^ value partially assigned here after move + | + = note: move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait + +error[E0594]: cannot assign to `t.1`, as `t` is not declared as mutable + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:27:9 + | +LL | let t: Tuple = (S(0), 0); + | - help: consider changing this to be mutable: `mut t` +... +LL | t.1 = 2; + | ^^^^^^^ cannot assign + +error[E0594]: cannot assign to `u.0`, as `u` is not declared as mutable + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:38:9 + | +LL | let u: Tpair = Tpair(S(0), 0); + | - help: consider changing this to be mutable: `mut u` +LL | drop(u); +LL | u.0 = S(1); + | ^^^^^^^^^^ cannot assign + +error[E0382]: assign to part of moved value: `u` + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:38:9 + | +LL | drop(u); + | - value moved here +LL | u.0 = S(1); + | ^^^^^^^^^^ value partially assigned here after move + | + = note: move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait + +error[E0594]: cannot assign to `u.1`, as `u` is not declared as mutable + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:42:9 + | +LL | let u: Tpair = Tpair(S(0), 0); + | - help: consider changing this to be mutable: `mut u` +... +LL | u.1 = 2; + | ^^^^^^^ cannot assign + +error[E0594]: cannot assign to `v.x`, as `v` is not declared as mutable + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:53:9 + | +LL | let v: Spair = Spair { x: S(0), y: 0 }; + | - help: consider changing this to be mutable: `mut v` +LL | drop(v); +LL | v.x = S(1); + | ^^^^^^^^^^ cannot assign + +error[E0382]: assign to part of moved value: `v` + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:53:9 + | +LL | drop(v); + | - value moved here +LL | v.x = S(1); + | ^^^^^^^^^^ value partially assigned here after move + | + = note: move occurs because `v` has type `Spair`, which does not implement the `Copy` trait + +error[E0594]: cannot assign to `v.y`, as `v` is not declared as mutable + --> $DIR/issue-54499-field-mutation-of-moved-out.rs:57:9 + | +LL | let v: Spair = Spair { x: S(0), y: 0 }; + | - help: consider changing this to be mutable: `mut v` +... +LL | v.y = 2; + | ^^^^^^^ cannot assign + +error: aborting due to 9 previous errors + +Some errors occurred: E0382, E0594. +For more information about an error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,64 @@ +// revisions: ast nll + +// Since we are testing nll migration explicitly as a separate +// revision, don't worry about the --compare-mode=nll on this test. + +// ignore-compare-mode-nll + +//[ast]compile-flags: -Z borrowck=ast +//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows + +#![warn(unused)] +#[derive(Debug)] +struct S(i32); + +type Tuple = (S, i32); +struct Tpair(S, i32); +struct Spair { x: S, y: i32 } + +fn main() { + { + let t: Tuple = (S(0), 0); + drop(t); + t.0 = S(1); + //[ast]~^ ERROR cannot assign to field `t.0` of immutable binding [E0594] + //[nll]~^^ ERROR assign to part of moved value: `t` [E0382] + //[nll]~| ERROR cannot assign to `t.0`, as `t` is not declared as mutable [E0594] + t.1 = 2; + //[ast]~^ ERROR cannot assign to field `t.1` of immutable binding [E0594] + //[nll]~^^ ERROR cannot assign to `t.1`, as `t` is not declared as mutable [E0594] + println!("{:?} {:?}", t.0, t.1); + //[ast]~^ ERROR use of moved value: `t.0` [E0382] + //[ast]~| ERROR use of moved value: `t.1` [E0382] + } + + { + let u: Tpair = Tpair(S(0), 0); + drop(u); + u.0 = S(1); + //[ast]~^ ERROR cannot assign to field `u.0` of immutable binding [E0594] + //[nll]~^^ ERROR assign to part of moved value: `u` [E0382] + //[nll]~| ERROR cannot assign to `u.0`, as `u` is not declared as mutable [E0594] + u.1 = 2; + //[ast]~^ ERROR cannot assign to field `u.1` of immutable binding [E0594] + //[nll]~^^ ERROR cannot assign to `u.1`, as `u` is not declared as mutable [E0594] + println!("{:?} {:?}", u.0, u.1); + //[ast]~^ ERROR use of moved value: `u.0` [E0382] + //[ast]~| ERROR use of moved value: `u.1` [E0382] + } + + { + let v: Spair = Spair { x: S(0), y: 0 }; + drop(v); + v.x = S(1); + //[ast]~^ ERROR cannot assign to field `v.x` of immutable binding [E0594] + //[nll]~^^ ERROR assign to part of moved value: `v` [E0382] + //[nll]~| ERROR cannot assign to `v.x`, as `v` is not declared as mutable [E0594] + v.y = 2; + //[ast]~^ ERROR cannot assign to field `v.y` of immutable binding [E0594] + //[nll]~^^ ERROR cannot assign to `v.y`, as `v` is not declared as mutable [E0594] + println!("{:?} {:?}", v.x, v.y); + //[ast]~^ ERROR use of moved value: `v.x` [E0382] + //[ast]~| ERROR use of moved value: `v.y` [E0382] + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.ast.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.ast.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.ast.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.ast.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,69 @@ +error[E0382]: use of moved value: `t.0` + --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:25:31 + | +LL | drop(t); + | - value moved here +... +LL | println!("{:?} {:?}", t.0, t.1); + | ^^^ value used here after move + | + = note: move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `t.1` + --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:25:36 + | +LL | drop(t); + | - value moved here +... +LL | println!("{:?} {:?}", t.0, t.1); + | ^^^ value used here after move + | + = note: move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `u.0` + --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:33:31 + | +LL | drop(u); + | - value moved here +... +LL | println!("{:?} {:?}", u.0, u.1); + | ^^^ value used here after move + | + = note: move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `u.1` + --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:33:36 + | +LL | drop(u); + | - value moved here +... +LL | println!("{:?} {:?}", u.0, u.1); + | ^^^ value used here after move + | + = note: move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `v.x` + --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:41:31 + | +LL | drop(v); + | - value moved here +... +LL | println!("{:?} {:?}", v.x, v.y); + | ^^^ value used here after move + | + = note: move occurs because `v` has type `Spair`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `v.y` + --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:41:36 + | +LL | drop(v); + | - value moved here +... +LL | println!("{:?} {:?}", v.x, v.y); + | ^^^ value used here after move + | + = note: move occurs because `v` has type `Spair`, which does not implement the `Copy` trait + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +error[E0382]: assign to part of moved value: `t` + --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:23:9 + | +LL | drop(t); + | - value moved here +LL | t.0 = S(1); + | ^^^^^^^^^^ value partially assigned here after move + | + = note: move occurs because `t` has type `(S, i32)`, which does not implement the `Copy` trait + +error[E0382]: assign to part of moved value: `u` + --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:31:9 + | +LL | drop(u); + | - value moved here +LL | u.0 = S(1); + | ^^^^^^^^^^ value partially assigned here after move + | + = note: move occurs because `u` has type `Tpair`, which does not implement the `Copy` trait + +error[E0382]: assign to part of moved value: `v` + --> $DIR/issue-54499-field-mutation-of-moved-out-with-mut.rs:39:9 + | +LL | drop(v); + | - value moved here +LL | v.x = S(1); + | ^^^^^^^^^^ value partially assigned here after move + | + = note: move occurs because `v` has type `Spair`, which does not implement the `Copy` trait + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-moved-out-with-mut.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// revisions: ast nll + +// Since we are testing nll migration explicitly as a separate +// revision, don't worry about the --compare-mode=nll on this test. + +// ignore-compare-mode-nll + +//[ast]compile-flags: -Z borrowck=ast +//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows + +#![warn(unused)] +#[derive(Debug)] +struct S(i32); + +type Tuple = (S, i32); +struct Tpair(S, i32); +struct Spair { x: S, y: i32 } + +fn main() { + { + let mut t: Tuple = (S(0), 0); + drop(t); + t.0 = S(1); + t.1 = 2; + println!("{:?} {:?}", t.0, t.1); + } + + { + let mut u: Tpair = Tpair(S(0), 0); + drop(u); + u.0 = S(1); + u.1 = 2; + println!("{:?} {:?}", u.0, u.1); + } + + { + let mut v: Spair = Spair { x: S(0), y: 0 }; + drop(v); + v.x = S(1); + v.y = 2; + println!("{:?} {:?}", v.x, v.y); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.ast.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.ast.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.ast.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.ast.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,91 @@ +error[E0594]: cannot assign to field `t.0` of immutable binding + --> $DIR/issue-54499-field-mutation-of-never-init.rs:22:9 + | +LL | let t: Tuple; + | - help: make this binding mutable: `mut t` +LL | t.0 = S(1); + | ^^^^^^^^^^ cannot mutably borrow field of immutable binding + +error[E0594]: cannot assign to field `t.1` of immutable binding + --> $DIR/issue-54499-field-mutation-of-never-init.rs:25:9 + | +LL | let t: Tuple; + | - help: make this binding mutable: `mut t` +... +LL | t.1 = 2; + | ^^^^^^^ cannot mutably borrow field of immutable binding + +error[E0594]: cannot assign to field `u.0` of immutable binding + --> $DIR/issue-54499-field-mutation-of-never-init.rs:34:9 + | +LL | let u: Tpair; + | - help: make this binding mutable: `mut u` +LL | u.0 = S(1); + | ^^^^^^^^^^ cannot mutably borrow field of immutable binding + +error[E0594]: cannot assign to field `u.1` of immutable binding + --> $DIR/issue-54499-field-mutation-of-never-init.rs:37:9 + | +LL | let u: Tpair; + | - help: make this binding mutable: `mut u` +... +LL | u.1 = 2; + | ^^^^^^^ cannot mutably borrow field of immutable binding + +error[E0594]: cannot assign to field `v.x` of immutable binding + --> $DIR/issue-54499-field-mutation-of-never-init.rs:46:9 + | +LL | let v: Spair; + | - help: make this binding mutable: `mut v` +LL | v.x = S(1); + | ^^^^^^^^^^ cannot mutably borrow field of immutable binding + +error[E0594]: cannot assign to field `v.y` of immutable binding + --> $DIR/issue-54499-field-mutation-of-never-init.rs:49:9 + | +LL | let v: Spair; + | - help: make this binding mutable: `mut v` +... +LL | v.y = 2; + | ^^^^^^^ cannot mutably borrow field of immutable binding + +error[E0381]: use of possibly uninitialized variable: `t.0` + --> $DIR/issue-54499-field-mutation-of-never-init.rs:27:31 + | +LL | println!("{:?} {:?}", t.0, t.1); + | ^^^ use of possibly uninitialized `t.0` + +error[E0381]: use of possibly uninitialized variable: `t.1` + --> $DIR/issue-54499-field-mutation-of-never-init.rs:27:36 + | +LL | println!("{:?} {:?}", t.0, t.1); + | ^^^ use of possibly uninitialized `t.1` + +error[E0381]: use of possibly uninitialized variable: `u.0` + --> $DIR/issue-54499-field-mutation-of-never-init.rs:39:31 + | +LL | println!("{:?} {:?}", u.0, u.1); + | ^^^ use of possibly uninitialized `u.0` + +error[E0381]: use of possibly uninitialized variable: `u.1` + --> $DIR/issue-54499-field-mutation-of-never-init.rs:39:36 + | +LL | println!("{:?} {:?}", u.0, u.1); + | ^^^ use of possibly uninitialized `u.1` + +error[E0381]: use of possibly uninitialized variable: `v.x` + --> $DIR/issue-54499-field-mutation-of-never-init.rs:51:31 + | +LL | println!("{:?} {:?}", v.x, v.y); + | ^^^ use of possibly uninitialized `v.x` + +error[E0381]: use of possibly uninitialized variable: `v.y` + --> $DIR/issue-54499-field-mutation-of-never-init.rs:51:36 + | +LL | println!("{:?} {:?}", v.x, v.y); + | ^^^ use of possibly uninitialized `v.y` + +error: aborting due to 12 previous errors + +Some errors occurred: E0381, E0594. +For more information about an error, try `rustc --explain E0381`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +error[E0381]: assign to part of possibly uninitialized variable: `t` + --> $DIR/issue-54499-field-mutation-of-never-init.rs:22:9 + | +LL | t.0 = S(1); + | ^^^^^^^^^^ use of possibly uninitialized `t` + +error[E0381]: assign to part of possibly uninitialized variable: `u` + --> $DIR/issue-54499-field-mutation-of-never-init.rs:34:9 + | +LL | u.0 = S(1); + | ^^^^^^^^^^ use of possibly uninitialized `u` + +error[E0381]: assign to part of possibly uninitialized variable: `v` + --> $DIR/issue-54499-field-mutation-of-never-init.rs:46:9 + | +LL | v.x = S(1); + | ^^^^^^^^^^ use of possibly uninitialized `v` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0381`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54499-field-mutation-of-never-init.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,55 @@ +// revisions: ast nll + +// Since we are testing nll migration explicitly as a separate +// revision, don't worry about the --compare-mode=nll on this test. + +// ignore-compare-mode-nll + +//[ast]compile-flags: -Z borrowck=ast +//[nll]compile-flags: -Z borrowck=migrate -Z two-phase-borrows + +#![warn(unused)] +#[derive(Debug)] +struct S(i32); + +type Tuple = (S, i32); +struct Tpair(S, i32); +struct Spair { x: S, y: i32 } + +fn main() { + { + let t: Tuple; + t.0 = S(1); + //[ast]~^ ERROR cannot assign to field `t.0` of immutable binding [E0594] + //[nll]~^^ ERROR assign to part of possibly uninitialized variable: `t` [E0381] + t.1 = 2; + //[ast]~^ ERROR cannot assign to field `t.1` of immutable binding [E0594] + println!("{:?} {:?}", t.0, t.1); + //[ast]~^ ERROR use of possibly uninitialized variable: `t.0` [E0381] + //[ast]~| ERROR use of possibly uninitialized variable: `t.1` [E0381] + } + + { + let u: Tpair; + u.0 = S(1); + //[ast]~^ ERROR cannot assign to field `u.0` of immutable binding [E0594] + //[nll]~^^ ERROR assign to part of possibly uninitialized variable: `u` [E0381] + u.1 = 2; + //[ast]~^ ERROR cannot assign to field `u.1` of immutable binding [E0594] + println!("{:?} {:?}", u.0, u.1); + //[ast]~^ ERROR use of possibly uninitialized variable: `u.0` [E0381] + //[ast]~| ERROR use of possibly uninitialized variable: `u.1` [E0381] + } + + { + let v: Spair; + v.x = S(1); + //[ast]~^ ERROR cannot assign to field `v.x` of immutable binding [E0594] + //[nll]~^^ ERROR assign to part of possibly uninitialized variable: `v` [E0381] + v.y = 2; + //[ast]~^ ERROR cannot assign to field `v.y` of immutable binding [E0594] + println!("{:?} {:?}", v.x, v.y); + //[ast]~^ ERROR use of possibly uninitialized variable: `v.x` [E0381] + //[ast]~| ERROR use of possibly uninitialized variable: `v.y` [E0381] + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +#![feature(nll)] + +#![allow(dead_code)] + +#[derive(Debug)] +struct Value; +impl Value { + fn as_array(&self) -> Option<&Vec> { + None + } +} + +fn foo(val: Value) { + let _reviewers_original: Vec = match val.as_array() { + Some(array) => { + *array + } + None => vec![] + }; +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-54597-reject-move-out-of-borrow-via-pat.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/issue-54597-reject-move-out-of-borrow-via-pat.rs:16:13 + | +LL | *array + | ^^^^^^ + | | + | cannot move out of borrowed content + | help: consider removing the `*`: `array` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.ast.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.ast.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.ast.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.ast.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,55 @@ +error[E0595]: closure cannot assign to immutable argument `x` + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:21:22 + | +LL | let mut c1 = |y: &'static mut isize| x = y; + | ^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow mutably +help: consider removing the `&mut`, as it is an immutable binding to a mutable reference + | +LL | x + | + +error[E0595]: closure cannot assign to immutable argument `x` + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:29:22 + | +LL | let mut c1 = |z: &'static mut isize| { + | ^^^^^^^^^^^^^^^^^^^^^^^ cannot borrow mutably +help: consider removing the `&mut`, as it is an immutable binding to a mutable reference + | +LL | x + | + +error[E0595]: closure cannot assign to immutable argument `x` + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:40:9 + | +LL | pub fn capture_assign_whole(x: (i32,)) { + | - help: make this binding mutable: `mut x` +LL | || { x = (1,); }; + | ^^ cannot borrow mutably + +error[E0595]: closure cannot assign to immutable argument `x` + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:43:9 + | +LL | pub fn capture_assign_part(x: (i32,)) { + | - help: make this binding mutable: `mut x` +LL | || { x.0 = 1; }; + | ^^ cannot borrow mutably + +error[E0595]: closure cannot assign to immutable argument `x` + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:46:9 + | +LL | pub fn capture_reborrow_whole(x: (i32,)) { + | - help: make this binding mutable: `mut x` +LL | || { &mut x; }; + | ^^ cannot borrow mutably + +error[E0595]: closure cannot assign to immutable argument `x` + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:49:9 + | +LL | pub fn capture_reborrow_part(x: (i32,)) { + | - help: make this binding mutable: `mut x` +LL | || { &mut x.0; }; + | ^^ cannot borrow mutably + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0595`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.migrate.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.migrate.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.migrate.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.migrate.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,54 @@ +error[E0594]: cannot assign to `x`, as it is not declared as mutable + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:21:46 + | +LL | pub fn e(x: &'static mut isize) { + | - help: consider changing this to be mutable: `mut x` +LL | static mut Y: isize = 3; +LL | let mut c1 = |y: &'static mut isize| x = y; + | ^^^^^ cannot assign + +error[E0594]: cannot assign to `x`, as it is not declared as mutable + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:30:50 + | +LL | pub fn ee(x: &'static mut isize) { + | - help: consider changing this to be mutable: `mut x` +... +LL | let mut c2 = |y: &'static mut isize| x = y; + | ^^^^^ cannot assign + +error[E0594]: cannot assign to `x`, as it is not declared as mutable + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:40:14 + | +LL | pub fn capture_assign_whole(x: (i32,)) { + | - help: consider changing this to be mutable: `mut x` +LL | || { x = (1,); }; + | ^^^^^^^^ cannot assign + +error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:43:14 + | +LL | pub fn capture_assign_part(x: (i32,)) { + | - help: consider changing this to be mutable: `mut x` +LL | || { x.0 = 1; }; + | ^^^^^^^ cannot assign + +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:46:14 + | +LL | pub fn capture_reborrow_whole(x: (i32,)) { + | - help: consider changing this to be mutable: `mut x` +LL | || { &mut x; }; + | ^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:49:14 + | +LL | pub fn capture_reborrow_part(x: (i32,)) { + | - help: consider changing this to be mutable: `mut x` +LL | || { &mut x.0; }; + | ^^^^^^^^ cannot borrow as mutable + +error: aborting due to 6 previous errors + +Some errors occurred: E0594, E0596. +For more information about an error, try `rustc --explain E0594`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,54 @@ +error[E0594]: cannot assign to `x`, as it is not declared as mutable + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:21:46 + | +LL | pub fn e(x: &'static mut isize) { + | - help: consider changing this to be mutable: `mut x` +LL | static mut Y: isize = 3; +LL | let mut c1 = |y: &'static mut isize| x = y; + | ^^^^^ cannot assign + +error[E0594]: cannot assign to `x`, as it is not declared as mutable + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:30:50 + | +LL | pub fn ee(x: &'static mut isize) { + | - help: consider changing this to be mutable: `mut x` +... +LL | let mut c2 = |y: &'static mut isize| x = y; + | ^^^^^ cannot assign + +error[E0594]: cannot assign to `x`, as it is not declared as mutable + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:40:14 + | +LL | pub fn capture_assign_whole(x: (i32,)) { + | - help: consider changing this to be mutable: `mut x` +LL | || { x = (1,); }; + | ^^^^^^^^ cannot assign + +error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:43:14 + | +LL | pub fn capture_assign_part(x: (i32,)) { + | - help: consider changing this to be mutable: `mut x` +LL | || { x.0 = 1; }; + | ^^^^^^^ cannot assign + +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:46:14 + | +LL | pub fn capture_reborrow_whole(x: (i32,)) { + | - help: consider changing this to be mutable: `mut x` +LL | || { &mut x; }; + | ^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow `x.0` as mutable, as `x` is not declared as mutable + --> $DIR/issue-55492-borrowck-migrate-scans-parents.rs:49:14 + | +LL | pub fn capture_reborrow_part(x: (i32,)) { + | - help: consider changing this to be mutable: `mut x` +LL | || { &mut x.0; }; + | ^^^^^^^^ cannot borrow as mutable + +error: aborting due to 6 previous errors + +Some errors occurred: E0594, E0596. +For more information about an error, try `rustc --explain E0594`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-55492-borrowck-migrate-scans-parents.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,61 @@ +// rust-lang/rust#55492: errors detected during MIR-borrowck's +// analysis of a closure body may only be caught when AST-borrowck +// looks at some parent. + +// revisions: ast migrate nll + +// Since we are testing nll (and migration) explicitly as a separate +// revisions, don't worry about the --compare-mode=nll on this test. + +// ignore-compare-mode-nll + +//[ast]compile-flags: -Z borrowck=ast +//[migrate]compile-flags: -Z borrowck=migrate -Z two-phase-borrows +//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows + + +// transcribed from borrowck-closures-unique.rs +mod borrowck_closures_unique { + pub fn e(x: &'static mut isize) { + static mut Y: isize = 3; + let mut c1 = |y: &'static mut isize| x = y; + unsafe { c1(&mut Y); } + } +} + +mod borrowck_closures_unique_grandparent { + pub fn ee(x: &'static mut isize) { + static mut Z: isize = 3; + let mut c1 = |z: &'static mut isize| { + let mut c2 = |y: &'static mut isize| x = y; + c2(z); + }; + unsafe { c1(&mut Z); } + } +} + +// adapted from mutability_errors.rs +mod mutability_errors { + pub fn capture_assign_whole(x: (i32,)) { + || { x = (1,); }; + } + pub fn capture_assign_part(x: (i32,)) { + || { x.0 = 1; }; + } + pub fn capture_reborrow_whole(x: (i32,)) { + || { &mut x; }; + } + pub fn capture_reborrow_part(x: (i32,)) { + || { &mut x.0; }; + } +} + +fn main() { + static mut X: isize = 2; + unsafe { borrowck_closures_unique::e(&mut X); } + + mutability_errors::capture_assign_whole((1000,)); + mutability_errors::capture_assign_part((2000,)); + mutability_errors::capture_reborrow_whole((3000,)); + mutability_errors::capture_reborrow_part((4000,)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-55552-ascribe-wildcard-to-structured-pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-55552-ascribe-wildcard-to-structured-pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-55552-ascribe-wildcard-to-structured-pattern.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-55552-ascribe-wildcard-to-structured-pattern.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// compile-pass + +// rust-lang/rust#55552: The strategy pnkfelix landed in PR #55274 +// (for ensuring that NLL respects user-provided lifetime annotations) +// did not handle the case where the ascribed type has some expliit +// wildcards (`_`) mixed in, and it caused an internal compiler error +// (ICE). +// +// This test is just checking that we do not ICE when such things +// occur. + +struct X; +struct Y; +struct Z; + +struct Pair { x: X, y: Y } + +pub fn join(oper_a: A, oper_b: B) -> (RA, RB) +where A: FnOnce() -> RA + Send, + B: FnOnce() -> RB + Send, + RA: Send, + RB: Send +{ + (oper_a(), oper_b()) +} + +fn main() { + let ((_x, _y), _z): (_, Z) = join(|| (X, Y), || Z); + + let (Pair { x: _x, y: _y }, Z): (_, Z) = join(|| Pair { x: X, y: Y }, || Z); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-7573.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-7573.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/issue-7573.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/issue-7573.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -error: borrowed data escapes outside of closure - --> $DIR/issue-7573.rs:32:9 - | -LL | let mut lines_to_use: Vec<&CrateId> = Vec::new(); - | ---------------- `lines_to_use` is declared here, outside of the closure body -LL | //~^ NOTE cannot infer an appropriate lifetime -LL | let push_id = |installed_id: &CrateId| { - | ------------ `installed_id` is a reference that is only valid in the closure body -... -LL | lines_to_use.push(installed_id); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `installed_id` escapes the closure body here - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/move-in-static-initializer-issue-38520.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/move-in-static-initializer-issue-38520.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/move-in-static-initializer-issue-38520.ast.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/move-in-static-initializer-issue-38520.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/move-in-static-initializer-issue-38520.rs:25:23 + | +LL | static Y: usize = get(*&X); //[ast]~ ERROR E0507 + | ^^^ cannot move out of borrowed content + +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/move-in-static-initializer-issue-38520.rs:25:23 + | +LL | static Y: usize = get(*&X); //[ast]~ ERROR E0507 + | ^^^ + | | + | cannot move out of data in a `&` reference + | cannot move + +error[E0507]: cannot move out of borrowed content + --> $DIR/move-in-static-initializer-issue-38520.rs:27:22 + | +LL | const Z: usize = get(*&X); //[ast]~ ERROR E0507 + | ^^^ cannot move out of borrowed content + +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/move-in-static-initializer-issue-38520.rs:27:22 + | +LL | const Z: usize = get(*&X); //[ast]~ ERROR E0507 + | ^^^ + | | + | cannot move out of data in a `&` reference + | cannot move + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/move-in-static-initializer-issue-38520.ast.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/move-in-static-initializer-issue-38520.ast.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/move-in-static-initializer-issue-38520.ast.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/move-in-static-initializer-issue-38520.ast.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,11 +1,11 @@ error[E0507]: cannot move out of borrowed content - --> $DIR/move-in-static-initializer-issue-38520.rs:27:23 + --> $DIR/move-in-static-initializer-issue-38520.rs:25:23 | LL | static Y: usize = get(*&X); //[ast]~ ERROR E0507 | ^^^ cannot move out of borrowed content error[E0507]: cannot move out of borrowed content - --> $DIR/move-in-static-initializer-issue-38520.rs:29:22 + --> $DIR/move-in-static-initializer-issue-38520.rs:27:22 | LL | const Z: usize = get(*&X); //[ast]~ ERROR E0507 | ^^^ cannot move out of borrowed content diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/move-in-static-initializer-issue-38520.mir.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/move-in-static-initializer-issue-38520.mir.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/move-in-static-initializer-issue-38520.mir.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/move-in-static-initializer-issue-38520.mir.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,11 +1,11 @@ error[E0507]: cannot move out of borrowed content - --> $DIR/move-in-static-initializer-issue-38520.rs:27:23 + --> $DIR/move-in-static-initializer-issue-38520.rs:25:23 | LL | static Y: usize = get(*&X); //[ast]~ ERROR E0507 | ^^^ cannot move out of borrowed content error[E0507]: cannot move out of borrowed content - --> $DIR/move-in-static-initializer-issue-38520.rs:29:22 + --> $DIR/move-in-static-initializer-issue-38520.rs:27:22 | LL | const Z: usize = get(*&X); //[ast]~ ERROR E0507 | ^^^ cannot move out of borrowed content diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/move-in-static-initializer-issue-38520.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/move-in-static-initializer-issue-38520.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/move-in-static-initializer-issue-38520.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/move-in-static-initializer-issue-38520.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,8 +15,6 @@ // permitted as `Foo` is not copy (even in a static/const // initializer). -#![feature(min_const_fn)] - struct Foo(usize); const fn get(x: Foo) -> usize { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/mut-borrow-in-loop.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/mut-borrow-in-loop.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/mut-borrow-in-loop.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/mut-borrow-in-loop.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,38 +1,38 @@ error[E0499]: cannot borrow `*arg` as mutable more than once at a time --> $DIR/mut-borrow-in-loop.rs:20:25 | -LL | (self.func)(arg) //~ ERROR cannot borrow - | ^^^ mutable borrow starts here in previous iteration of loop - | -note: borrowed value must be valid for the lifetime 'a as defined on the impl at 17:6... - --> $DIR/mut-borrow-in-loop.rs:17:6 - | LL | impl<'a, T : 'a> FuncWrapper<'a, T> { - | ^^ + | -- lifetime `'a` defined here +... +LL | (self.func)(arg) //~ ERROR cannot borrow + | ------------^^^- + | | | + | | mutable borrow starts here in previous iteration of loop + | argument requires that `*arg` is borrowed for `'a` error[E0499]: cannot borrow `*arg` as mutable more than once at a time --> $DIR/mut-borrow-in-loop.rs:26:25 | -LL | (self.func)(arg) //~ ERROR cannot borrow - | ^^^ mutable borrow starts here in previous iteration of loop - | -note: borrowed value must be valid for the lifetime 'a as defined on the impl at 17:6... - --> $DIR/mut-borrow-in-loop.rs:17:6 - | LL | impl<'a, T : 'a> FuncWrapper<'a, T> { - | ^^ + | -- lifetime `'a` defined here +... +LL | (self.func)(arg) //~ ERROR cannot borrow + | ------------^^^- + | | | + | | mutable borrow starts here in previous iteration of loop + | argument requires that `*arg` is borrowed for `'a` error[E0499]: cannot borrow `*arg` as mutable more than once at a time --> $DIR/mut-borrow-in-loop.rs:33:25 | -LL | (self.func)(arg) //~ ERROR cannot borrow - | ^^^ mutable borrow starts here in previous iteration of loop - | -note: borrowed value must be valid for the lifetime 'a as defined on the impl at 17:6... - --> $DIR/mut-borrow-in-loop.rs:17:6 - | LL | impl<'a, T : 'a> FuncWrapper<'a, T> { - | ^^ + | -- lifetime `'a` defined here +... +LL | (self.func)(arg) //~ ERROR cannot borrow + | ------------^^^- + | | | + | | mutable borrow starts here in previous iteration of loop + | argument requires that `*arg` is borrowed for `'a` error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/mut-borrow-outside-loop.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/mut-borrow-outside-loop.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/mut-borrow-outside-loop.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/mut-borrow-outside-loop.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -6,7 +6,7 @@ LL | let second = &mut void; //~ ERROR cannot borrow | ^^^^^^^^^ second mutable borrow occurs here LL | first.use_mut(); - | ----- borrow later used here + | ----- first borrow later used here error[E0499]: cannot borrow `inner_void` as mutable more than once at a time --> $DIR/mut-borrow-outside-loop.rs:25:28 @@ -17,7 +17,7 @@ | ^^^^^^^^^^^^^^^ second mutable borrow occurs here LL | inner_second.use_mut(); LL | inner_first.use_mut(); - | ----------- borrow used here in later iteration of loop + | ----------- first borrow used here, in later iteration of loop error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,57 +1,50 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:15:21 +error[E0515]: cannot return value referencing temporary value + --> $DIR/promote-ref-mut-in-let-issue-46557.rs:16:5 | LL | let ref mut x = 1234543; //~ ERROR - | ^^^^^^^ temporary value does not live long enough + | ------- temporary value created here LL | x -LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | ^ returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:20:25 +error[E0515]: cannot return value referencing temporary value + --> $DIR/promote-ref-mut-in-let-issue-46557.rs:21:5 | LL | let (ref mut x, ) = (1234543, ); //~ ERROR - | ^^^^^^^^^^^ temporary value does not live long enough + | ----------- temporary value created here LL | x -LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | ^ returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:25:11 +error[E0515]: cannot return value referencing temporary value + --> $DIR/promote-ref-mut-in-let-issue-46557.rs:25:5 | -LL | match 1234543 { - | ^^^^^^^ temporary value does not live long enough -... -LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... +LL | match 1234543 { + | ^ ------- temporary value created here + | _____| + | | +LL | | ref mut x => x //~ ERROR +LL | | } + | |_____^ returns a value referencing data owned by the current function + +error[E0515]: cannot return value referencing temporary value + --> $DIR/promote-ref-mut-in-let-issue-46557.rs:31:5 + | +LL | match (123443,) { + | ^ --------- temporary value created here + | _____| + | | +LL | | (ref mut x,) => x, //~ ERROR +LL | | } + | |_____^ returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:31:11 - | -LL | match (123443,) { - | ^^^^^^^^^ temporary value does not live long enough -... -LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... - -error[E0597]: borrowed value does not live long enough - --> $DIR/promote-ref-mut-in-let-issue-46557.rs:37:10 +error[E0515]: cannot return reference to temporary value + --> $DIR/promote-ref-mut-in-let-issue-46557.rs:37:5 | LL | &mut 1234543 //~ ERROR - | ^^^^^^^ temporary value does not live long enough -LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | ^^^^^------- + | | | + | | temporary value created here + | returns a reference to data owned by the current function error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/reassignment_immutable_fields.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/reassignment_immutable_fields.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/reassignment_immutable_fields.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/reassignment_immutable_fields.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,44 +1,15 @@ -error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable +error[E0381]: assign to part of possibly uninitialized variable: `x` --> $DIR/reassignment_immutable_fields.rs:17:5 | -LL | let x: (u32, u32); - | - help: consider changing this to be mutable: `mut x` LL | x.0 = 1; //~ ERROR - | ^^^^^^^ cannot assign + | ^^^^^^^ use of possibly uninitialized `x` -error[E0594]: cannot assign to `x.1`, as `x` is not declared as mutable - --> $DIR/reassignment_immutable_fields.rs:18:5 - | -LL | let x: (u32, u32); - | - help: consider changing this to be mutable: `mut x` -LL | x.0 = 1; //~ ERROR -LL | x.1 = 22; //~ ERROR - | ^^^^^^^^ cannot assign - -error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable +error[E0381]: assign to part of possibly uninitialized variable: `x` --> $DIR/reassignment_immutable_fields.rs:25:5 | -LL | let x: (u32, u32); - | - help: consider changing this to be mutable: `mut x` -LL | x.0 = 1; //~ ERROR - | ^^^^^^^ cannot assign - -error[E0594]: cannot assign to `x.1`, as `x` is not declared as mutable - --> $DIR/reassignment_immutable_fields.rs:26:5 - | -LL | let x: (u32, u32); - | - help: consider changing this to be mutable: `mut x` LL | x.0 = 1; //~ ERROR -LL | x.1 = 22; //~ ERROR - | ^^^^^^^^ cannot assign - -error[E0381]: use of possibly uninitialized variable: `x` - --> $DIR/reassignment_immutable_fields.rs:27:10 - | -LL | drop(x); //~ ERROR - | ^ use of possibly uninitialized `x` + | ^^^^^^^ use of possibly uninitialized `x` -error: aborting due to 5 previous errors +error: aborting due to 2 previous errors -Some errors occurred: E0381, E0594. -For more information about an error, try `rustc --explain E0381`. +For more information about this error, try `rustc --explain E0381`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/reassignment_immutable_fields_overlapping.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/reassignment_immutable_fields_overlapping.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/reassignment_immutable_fields_overlapping.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/reassignment_immutable_fields_overlapping.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,20 +1,9 @@ -error[E0594]: cannot assign to `x.a`, as `x` is not declared as mutable +error[E0381]: assign to part of possibly uninitialized variable: `x` --> $DIR/reassignment_immutable_fields_overlapping.rs:22:5 | -LL | let x: Foo; - | - help: consider changing this to be mutable: `mut x` LL | x.a = 1; //~ ERROR - | ^^^^^^^ cannot assign + | ^^^^^^^ use of possibly uninitialized `x` -error[E0594]: cannot assign to `x.b`, as `x` is not declared as mutable - --> $DIR/reassignment_immutable_fields_overlapping.rs:23:5 - | -LL | let x: Foo; - | - help: consider changing this to be mutable: `mut x` -LL | x.a = 1; //~ ERROR -LL | x.b = 22; //~ ERROR - | ^^^^^^^^ cannot assign - -error: aborting due to 2 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0594`. +For more information about this error, try `rustc --explain E0381`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/reassignment_immutable_fields_twice.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/reassignment_immutable_fields_twice.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/reassignment_immutable_fields_twice.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/reassignment_immutable_fields_twice.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,32 +7,13 @@ LL | x.0 = 1; //~ ERROR | ^^^^^^^ cannot assign -error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable +error[E0381]: assign to part of possibly uninitialized variable: `x` --> $DIR/reassignment_immutable_fields_twice.rs:22:5 | -LL | let x: (u32, u32); - | - help: consider changing this to be mutable: `mut x` LL | x.0 = 1; //~ ERROR - | ^^^^^^^ cannot assign - -error[E0594]: cannot assign to `x.0`, as `x` is not declared as mutable - --> $DIR/reassignment_immutable_fields_twice.rs:23:5 - | -LL | let x: (u32, u32); - | - help: consider changing this to be mutable: `mut x` -LL | x.0 = 1; //~ ERROR -LL | x.0 = 22; //~ ERROR - | ^^^^^^^^ cannot assign - -error[E0594]: cannot assign to `x.1`, as `x` is not declared as mutable - --> $DIR/reassignment_immutable_fields_twice.rs:24:5 - | -LL | let x: (u32, u32); - | - help: consider changing this to be mutable: `mut x` -... -LL | x.1 = 44; //~ ERROR - | ^^^^^^^^ cannot assign + | ^^^^^^^ use of possibly uninitialized `x` -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0594`. +Some errors occurred: E0381, E0594. +For more information about an error, try `rustc --explain E0381`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/regions-escape-bound-fn-2.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/regions-escape-bound-fn-2.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/regions-escape-bound-fn-2.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/regions-escape-bound-fn-2.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: borrowed data escapes outside of closure - --> $DIR/regions-escape-bound-fn-2.rs:18:18 - | -LL | let mut x = None; - | ----- `x` is declared here, outside of the closure body -LL | with_int(|y| x = Some(y)); - | - ^^^^^^^^^^^ `y` escapes the closure body here - | | - | `y` is a reference that is only valid in the closure body - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/regions-escape-bound-fn.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/regions-escape-bound-fn.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/regions-escape-bound-fn.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/regions-escape-bound-fn.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: borrowed data escapes outside of closure - --> $DIR/regions-escape-bound-fn.rs:18:18 - | -LL | let mut x: Option<&isize> = None; - | ----- `x` is declared here, outside of the closure body -LL | with_int(|y| x = Some(y)); - | - ^^^^^^^^^^^ `y` escapes the closure body here - | | - | `y` is a reference that is only valid in the closure body - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/regions-escape-unboxed-closure.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/regions-escape-unboxed-closure.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/regions-escape-unboxed-closure.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/regions-escape-unboxed-closure.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: borrowed data escapes outside of closure - --> $DIR/regions-escape-unboxed-closure.rs:16:23 - | -LL | let mut x: Option<&isize> = None; - | ----- `x` is declared here, outside of the closure body -LL | with_int(&mut |y| x = Some(y)); - | - ^^^^^^^^^^^ `y` escapes the closure body here - | | - | `y` is a reference that is only valid in the closure body - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-activation-sharing-interference.nll_target.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-activation-sharing-interference.nll_target.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-activation-sharing-interference.nll_target.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-activation-sharing-interference.nll_target.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^ immutable borrow occurs here LL | //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable LL | *y += 1; - | ------- borrow later used here + | ------- mutable borrow later used here error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable --> $DIR/two-phase-activation-sharing-interference.rs:50:13 @@ -18,7 +18,7 @@ | ^^ immutable borrow occurs here LL | //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable LL | *y += 1; - | ------- borrow later used here + | ------- mutable borrow later used here error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable --> $DIR/two-phase-activation-sharing-interference.rs:61:13 @@ -29,7 +29,7 @@ | ^^ immutable borrow occurs here ... LL | *y += 1; - | ------- borrow later used here + | ------- mutable borrow later used here error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable --> $DIR/two-phase-activation-sharing-interference.rs:72:14 @@ -40,7 +40,7 @@ | ^^ immutable borrow occurs here LL | //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable LL | *y += 1; - | ------- borrow later used here + | ------- mutable borrow later used here error: aborting due to 4 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-cannot-nest-mut-self-calls.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,19 +1,13 @@ error[E0502]: cannot borrow `vec` as mutable because it is also borrowed as immutable --> $DIR/two-phase-cannot-nest-mut-self-calls.rs:26:9 | -LL | vec.get({ - | --- - | | - | _____immutable borrow occurs here - | | -LL | | -LL | | vec.push(2); - | | ^^^^^^^^^^^ mutable borrow occurs here -LL | | //~^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable -LL | | -LL | | 0 -LL | | }); - | |______- borrow later used here +LL | vec.get({ + | --- --- immutable borrow later used by call + | | + | immutable borrow occurs here +LL | +LL | vec.push(2); + | ^^^^^^^^^^^ mutable borrow occurs here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-multi-mut.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-multi-mut.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-multi-mut.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-multi-mut.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,21 +2,20 @@ --> $DIR/two-phase-multi-mut.rs:23:5 | LL | foo.method(&mut foo); - | ^^^^^^^^^^^--------^ - | | | - | | first mutable borrow occurs here + | ^^^^------^--------^ + | | | | + | | | first mutable borrow occurs here + | | first borrow later used by call | second mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `foo` as mutable more than once at a time --> $DIR/two-phase-multi-mut.rs:23:16 | LL | foo.method(&mut foo); - | -----------^^^^^^^^- - | | | - | | second mutable borrow occurs here + | --- ------ ^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-nonrecv-autoref.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,11 +2,10 @@ --> $DIR/two-phase-nonrecv-autoref.rs:70:11 | LL | f(f(10)); - | --^----- - | | | - | | second mutable borrow occurs here + | - ^ second mutable borrow occurs here + | | | first mutable borrow occurs here - | borrow later used here + | first borrow later used by call error[E0382]: use of moved value: `*f` --> $DIR/two-phase-nonrecv-autoref.rs:79:11 @@ -20,11 +19,10 @@ --> $DIR/two-phase-nonrecv-autoref.rs:86:11 | LL | f(f(10)); - | --^----- - | | | - | | second mutable borrow occurs here + | - ^ second mutable borrow occurs here + | | | first mutable borrow occurs here - | borrow later used here + | first borrow later used by call error[E0161]: cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined --> $DIR/two-phase-nonrecv-autoref.rs:95:9 @@ -50,11 +48,10 @@ --> $DIR/two-phase-nonrecv-autoref.rs:139:27 | LL | double_access(&mut a, &a); - | ----------------------^^- - | | | | - | | | immutable borrow occurs here + | ------------- ------ ^^ immutable borrow occurs here + | | | | | mutable borrow occurs here - | borrow later used here + | mutable borrow later used by call error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable --> $DIR/two-phase-nonrecv-autoref.rs:167:7 @@ -64,7 +61,7 @@ | | | | | immutable borrow occurs here | mutable borrow occurs here - | borrow later used here + | mutable borrow later used here error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable --> $DIR/two-phase-nonrecv-autoref.rs:173:7 @@ -74,7 +71,7 @@ | | | | | immutable borrow occurs here | mutable borrow occurs here - | borrow later used here + | mutable borrow later used here error: aborting due to 9 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-nonrecv-autoref.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,11 +2,10 @@ --> $DIR/two-phase-nonrecv-autoref.rs:70:11 | LL | f(f(10)); - | --^----- - | | | - | | second mutable borrow occurs here + | - ^ second mutable borrow occurs here + | | | first mutable borrow occurs here - | borrow later used here + | first borrow later used by call error[E0382]: use of moved value: `*f` --> $DIR/two-phase-nonrecv-autoref.rs:79:11 @@ -20,11 +19,10 @@ --> $DIR/two-phase-nonrecv-autoref.rs:86:11 | LL | f(f(10)); - | --^----- - | | | - | | second mutable borrow occurs here + | - ^ second mutable borrow occurs here + | | | first mutable borrow occurs here - | borrow later used here + | first borrow later used by call error[E0161]: cannot move a value of type dyn std::ops::FnOnce(i32) -> i32: the size of dyn std::ops::FnOnce(i32) -> i32 cannot be statically determined --> $DIR/two-phase-nonrecv-autoref.rs:95:9 @@ -50,11 +48,10 @@ --> $DIR/two-phase-nonrecv-autoref.rs:139:27 | LL | double_access(&mut a, &a); - | ----------------------^^- - | | | | - | | | immutable borrow occurs here + | ------------- ------ ^^ immutable borrow occurs here + | | | | | mutable borrow occurs here - | borrow later used here + | mutable borrow later used by call error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable --> $DIR/two-phase-nonrecv-autoref.rs:167:7 @@ -64,7 +61,7 @@ | | | | | immutable borrow occurs here | mutable borrow occurs here - | borrow later used here + | mutable borrow later used here error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable --> $DIR/two-phase-nonrecv-autoref.rs:173:7 @@ -74,7 +71,7 @@ | | | | | immutable borrow occurs here | mutable borrow occurs here - | borrow later used here + | mutable borrow later used here error: aborting due to 9 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-reservation-sharing-interference.nll_target.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-reservation-sharing-interference.nll_target.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-reservation-sharing-interference.nll_target.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-reservation-sharing-interference.nll_target.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | ^^^^^^^^ mutable borrow occurs here ... LL | shared[0]; - | ------ borrow later used here + | ------ immutable borrow later used here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-sneaky.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-sneaky.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-sneaky.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-sneaky.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,19 +1,13 @@ error[E0499]: cannot borrow `v` as mutable more than once at a time --> $DIR/two-phase-sneaky.rs:22:9 | -LL | v[0].push_str({ - | - - | | - | _____first mutable borrow occurs here - | | -LL | | -LL | | v.push(format!("foo")); - | | ^ second mutable borrow occurs here -LL | | //~^ ERROR cannot borrow `v` as mutable more than once at a time [E0499] -LL | | -LL | | "World!" -LL | | }); - | |______- borrow later used here +LL | v[0].push_str({ + | - -------- first borrow later used by call + | | + | first mutable borrow occurs here +LL | +LL | v.push(format!("foo")); + | ^ second mutable borrow occurs here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-surprise-no-conflict.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-surprise-no-conflict.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-surprise-no-conflict.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-surprise-no-conflict.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -13,151 +13,140 @@ --> $DIR/two-phase-surprise-no-conflict.rs:79:17 | LL | self.hash_expr(&self.cx_mut.body(eid).value); - | ^^^^^^^^^^^^^^^^-----------^^^^^^^^^^^^^^^^^ - | | | - | | immutable borrow occurs here + | ^^^^^---------^^-----------^^^^^^^^^^^^^^^^^ + | | | | + | | | immutable borrow occurs here + | | immutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:151:51 | LL | reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut))); - | ----------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | - | | second mutable borrow occurs here + | --- --------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:156:54 | LL | reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); - | -------------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | - | | second mutable borrow occurs here + | --- -------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:161:53 | LL | reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); - | ------------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | - | | second mutable borrow occurs here + | --- ------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:166:44 | LL | reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut)); - | ---------------------------------------^^^^^^^^^^^^^^^^^-- - | | | - | | second mutable borrow occurs here + | --- ------------ ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0502]: cannot borrow `*reg` as mutable because it is also borrowed as immutable --> $DIR/two-phase-surprise-no-conflict.rs:178:5 | LL | reg.register_bound(Box::new(CapturePass::new(®.sess_mut))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------^^^ - | | | - | | immutable borrow occurs here + | ^^^^--------------^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------^^^ + | | | | + | | | immutable borrow occurs here + | | immutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0502]: cannot borrow `*reg` as mutable because it is also borrowed as immutable --> $DIR/two-phase-surprise-no-conflict.rs:183:5 | +LL | fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) { + | -- lifetime `'a` defined here +... LL | reg.register_univ(Box::new(CapturePass::new(®.sess_mut))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------^^^ - | | | - | | immutable borrow occurs here + | ^^^^^^^^^^^^^^^^^^-----------------------------------------^ + | | | | + | | | immutable borrow occurs here + | | cast requires that `reg.sess_mut` is borrowed for `'a` | mutable borrow occurs here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 122:21... - --> $DIR/two-phase-surprise-no-conflict.rs:122:21 - | -LL | fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) { - | ^^ error[E0502]: cannot borrow `*reg` as mutable because it is also borrowed as immutable --> $DIR/two-phase-surprise-no-conflict.rs:188:5 | LL | reg.register_ref(&CapturePass::new(®.sess_mut)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------^^ - | | | - | | immutable borrow occurs here + | ^^^^------------^^^^^^^^^^^^^^^^^^^-------------^^ + | | | | + | | | immutable borrow occurs here + | | immutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `*reg` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:200:5 | LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------^^^ - | | | - | | first mutable borrow occurs here + | ^^^^--------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------^^^ + | | | | + | | | first mutable borrow occurs here + | | first borrow later used by call | second mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:200:54 | LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - | -------------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | - | | second mutable borrow occurs here + | --- -------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `*reg` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:206:5 | +LL | fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) { + | -- lifetime `'a` defined here +... LL | reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------^^^ - | | | - | | first mutable borrow occurs here + | ^^^^^^^^^^^^^^^^^^-------------------------------------------------^ + | | | | + | | | first mutable borrow occurs here + | | cast requires that `reg.sess_mut` is borrowed for `'a` | second mutable borrow occurs here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 122:21... - --> $DIR/two-phase-surprise-no-conflict.rs:122:21 - | -LL | fn register_plugins<'a>(mk_reg: impl Fn() -> &'a mut Registry<'a>) { - | ^^ error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:206:53 | LL | reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - | ------------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | - | | second mutable borrow occurs here + | --- ------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `*reg` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:212:5 | LL | reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------^^ - | | | - | | first mutable borrow occurs here + | ^^^^------------^^^^^^^^^^^^^^^^^^^^^^^-----------------^^ + | | | | + | | | first mutable borrow occurs here + | | first borrow later used by call | second mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:212:44 | LL | reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut)); - | ---------------------------------------^^^^^^^^^^^^^^^^^-- - | | | - | | second mutable borrow occurs here + | --- ------------ ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error: aborting due to 15 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-surprise-no-conflict.no2pb.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-surprise-no-conflict.no2pb.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-surprise-no-conflict.no2pb.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/two-phase-surprise-no-conflict.no2pb.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -13,161 +13,145 @@ --> $DIR/two-phase-surprise-no-conflict.rs:64:33 | LL | self.hash_expr(&self.cx.body(eid).value); - | ----------------^^^^^^^----------------- - | | | - | | immutable borrow occurs here + | ---- --------- ^^^^^^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0502]: cannot borrow `*self.cx_mut` as immutable because it is also borrowed as mutable --> $DIR/two-phase-surprise-no-conflict.rs:79:33 | LL | self.hash_expr(&self.cx_mut.body(eid).value); - | ----------------^^^^^^^^^^^----------------- - | | | - | | immutable borrow occurs here + | ---- --------- ^^^^^^^^^^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable --> $DIR/two-phase-surprise-no-conflict.rs:131:51 | LL | reg.register_static(Box::new(TrivialPass::new(®.sess_mut))); - | ----------------------------------------------^^^^^^^^^^^^^--- - | | | - | | immutable borrow occurs here + | --- --------------- ^^^^^^^^^^^^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable --> $DIR/two-phase-surprise-no-conflict.rs:135:50 | LL | reg.register_bound(Box::new(TrivialPass::new(®.sess_mut))); - | ---------------------------------------------^^^^^^^^^^^^^--- - | | | - | | immutable borrow occurs here + | --- -------------- ^^^^^^^^^^^^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable --> $DIR/two-phase-surprise-no-conflict.rs:139:49 | LL | reg.register_univ(Box::new(TrivialPass::new(®.sess_mut))); - | --------------------------------------------^^^^^^^^^^^^^--- - | | | - | | immutable borrow occurs here + | --- ------------- ^^^^^^^^^^^^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable --> $DIR/two-phase-surprise-no-conflict.rs:143:40 | LL | reg.register_ref(&TrivialPass::new(®.sess_mut)); - | -----------------------------------^^^^^^^^^^^^^-- - | | | - | | immutable borrow occurs here + | --- ------------ ^^^^^^^^^^^^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:151:51 | LL | reg.register_static(Box::new(TrivialPass::new(&mut reg.sess_mut))); - | ----------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | - | | second mutable borrow occurs here + | --- --------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:156:54 | LL | reg.register_bound(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); - | -------------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | - | | second mutable borrow occurs here + | --- -------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:161:53 | LL | reg.register_univ(Box::new(TrivialPass::new_mut(&mut reg.sess_mut))); - | ------------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | - | | second mutable borrow occurs here + | --- ------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:166:44 | LL | reg.register_ref(&TrivialPass::new_mut(&mut reg.sess_mut)); - | ---------------------------------------^^^^^^^^^^^^^^^^^-- - | | | - | | second mutable borrow occurs here + | --- ------------ ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable --> $DIR/two-phase-surprise-no-conflict.rs:178:50 | LL | reg.register_bound(Box::new(CapturePass::new(®.sess_mut))); - | ---------------------------------------------^^^^^^^^^^^^^--- - | | | - | | immutable borrow occurs here + | --- -------------- ^^^^^^^^^^^^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable --> $DIR/two-phase-surprise-no-conflict.rs:183:49 | LL | reg.register_univ(Box::new(CapturePass::new(®.sess_mut))); - | --------------------------------------------^^^^^^^^^^^^^--- - | | | - | | immutable borrow occurs here + | --- ------------- ^^^^^^^^^^^^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0502]: cannot borrow `reg.sess_mut` as immutable because it is also borrowed as mutable --> $DIR/two-phase-surprise-no-conflict.rs:188:40 | LL | reg.register_ref(&CapturePass::new(®.sess_mut)); - | -----------------------------------^^^^^^^^^^^^^-- - | | | - | | immutable borrow occurs here + | --- ------------ ^^^^^^^^^^^^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:200:54 | LL | reg.register_bound(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - | -------------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | - | | second mutable borrow occurs here + | --- -------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:206:53 | LL | reg.register_univ(Box::new(CapturePass::new_mut(&mut reg.sess_mut))); - | ------------------------------------------------^^^^^^^^^^^^^^^^^--- - | | | - | | second mutable borrow occurs here + | --- ------------- ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error[E0499]: cannot borrow `reg.sess_mut` as mutable more than once at a time --> $DIR/two-phase-surprise-no-conflict.rs:212:44 | LL | reg.register_ref(&CapturePass::new_mut(&mut reg.sess_mut)); - | ---------------------------------------^^^^^^^^^^^^^^^^^-- - | | | - | | second mutable borrow occurs here + | --- ------------ ^^^^^^^^^^^^^^^^^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error: aborting due to 17 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/borrowck/unboxed-closures-move-upvar-from-non-once-ref-closure.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,6 +7,25 @@ LL | y.into_iter(); | ^ cannot move out of captured variable in an `Fn` closure -error: aborting due to previous error +error[E0507]: cannot move out of `y`, as it is a captured variable in a `Fn` closure + --> $DIR/unboxed-closures-move-upvar-from-non-once-ref-closure.rs:21:9 + | +LL | y.into_iter(); + | ^ + | | + | cannot move out of `y`, as it is a captured variable in a `Fn` closure + | cannot move + | +help: consider changing this to accept closures that implement `FnMut` + --> $DIR/unboxed-closures-move-upvar-from-non-once-ref-closure.rs:20:10 + | +LL | call(|| { + | __________^ +LL | | y.into_iter(); +LL | | //~^ ERROR cannot move out of captured outer variable in an `Fn` closure +LL | | }); + | |_____^ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/by-move-pattern-binding.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/by-move-pattern-binding.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/by-move-pattern-binding.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/by-move-pattern-binding.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -16,6 +16,15 @@ LL | &E::Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move | ^^^^^^^^^^ -error: aborting due to previous error +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/by-move-pattern-binding.rs:26:17 + | +LL | &E::Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move + | ^^^^^^^^^^ + | | + | cannot move out of data in a `&` reference + | cannot move + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-arg-invalid-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-arg-invalid-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-arg-invalid-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-arg-invalid-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -// compile-flags: --cfg a(b=c) -// error-pattern: invalid `--cfg` argument: `a(b=c)` (expected `key` or `key="value"`) -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-arg-invalid-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-arg-invalid-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-arg-invalid-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-arg-invalid-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -// compile-flags: --cfg a{b} -// error-pattern: invalid `--cfg` argument: `a{b}` (expected `key` or `key="value"`) -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-arg-invalid-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-arg-invalid-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-arg-invalid-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-arg-invalid-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -// compile-flags: --cfg a::b -// error-pattern: invalid `--cfg` argument: `a::b` (argument key must be an identifier) -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-arg-invalid-4.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-arg-invalid-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-arg-invalid-4.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-arg-invalid-4.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -// compile-flags: --cfg a(b) -// error-pattern: invalid `--cfg` argument: `a(b)` (expected `key` or `key="value"`) -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-arg-invalid-5.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-arg-invalid-5.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-arg-invalid-5.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-arg-invalid-5.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -// compile-flags: --cfg a=10 -// error-pattern: invalid `--cfg` argument: `a=10` (argument value must be a string) -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-cfg-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-cfg-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-cfg-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-cfg-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// -// error-pattern: `main` function not found -// compile-flags: --cfg foo - -// main is conditionally compiled, but the conditional compilation -// is conditional too! - -#[cfg_attr(foo, cfg(bar))] -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-cfg-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-cfg-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-cfg-2.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-cfg-2.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -error[E0601]: `main` function not found in crate `cfg_attr_cfg_2` - | - = note: consider adding a `main` function to `$DIR/cfg-attr-cfg-2.rs` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0601`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-crate-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-crate-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-crate-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-crate-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// -// compile-flags: --cfg broken - -// https://github.com/rust-lang/rust/issues/21833#issuecomment-72353044 - -#![cfg_attr(broken, no_core)] //~ ERROR no_core is experimental - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-crate-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-crate-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-crate-2.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-crate-2.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error[E0658]: no_core is experimental (see issue #29639) - --> $DIR/cfg-attr-crate-2.rs:15:21 - | -LL | #![cfg_attr(broken, no_core)] //~ ERROR no_core is experimental - | ^^^^^^^^ - | - = help: add #![feature(no_core)] to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-invalid-predicate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-invalid-predicate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-invalid-predicate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-invalid-predicate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[cfg(foo(bar))] //~ ERROR invalid predicate `foo` -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-invalid-predicate.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-invalid-predicate.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-invalid-predicate.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-invalid-predicate.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -error[E0537]: invalid predicate `foo` - --> $DIR/cfg-attr-invalid-predicate.rs:11:7 - | -LL | #[cfg(foo(bar))] //~ ERROR invalid predicate `foo` - | ^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0537`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg_attr_path.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg_attr_path.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg_attr_path.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg_attr_path.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] -#![allow(dead_code)] -#![deny(unused_attributes)] // c.f #35584 - -mod auxiliary { - #[cfg_attr(any(), path = "nonexistent_file.rs")] pub mod namespaced_enums; - #[cfg_attr(all(), path = "namespaced_enums.rs")] pub mod nonexistent_file; -} - -#[rustc_error] -fn main() { //~ ERROR compilation successful - let _ = auxiliary::namespaced_enums::Foo::A; - let _ = auxiliary::nonexistent_file::Foo::A; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg_attr_path.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg_attr_path.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg_attr_path.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg_attr_path.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error: compilation successful - --> $DIR/cfg_attr_path.rs:21:1 - | -LL | / fn main() { //~ ERROR compilation successful -LL | | let _ = auxiliary::namespaced_enums::Foo::A; -LL | | let _ = auxiliary::nonexistent_file::Foo::A; -LL | | } - | |_^ - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-syntax-validation.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-syntax-validation.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-syntax-validation.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-syntax-validation.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -#[cfg] //~ ERROR `cfg` is not followed by parentheses -struct S1; - -#[cfg = 10] //~ ERROR `cfg` is not followed by parentheses -struct S2; - -#[cfg()] //~ ERROR `cfg` predicate is not specified -struct S3; - -#[cfg(a, b)] //~ ERROR multiple `cfg` predicates are specified -struct S4; - -#[cfg("str")] //~ ERROR `cfg` predicate key cannot be a literal -struct S5; - -#[cfg(a::b)] //~ ERROR `cfg` predicate key must be an identifier -struct S6; - -#[cfg(a())] //~ ERROR invalid predicate `a` -struct S7; - -#[cfg(a = 10)] //~ ERROR literal in `cfg` predicate value must be a string -struct S8; - -macro_rules! generate_s9 { - ($expr: expr) => { - #[cfg(feature = $expr)] //~ ERROR `cfg` is not a well-formed meta-item - struct S9; - } -} - -generate_s9!(concat!("nonexistent")); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-syntax-validation.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-syntax-validation.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-syntax-validation.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-syntax-validation.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -error: `cfg` is not followed by parentheses - --> $DIR/cfg-attr-syntax-validation.rs:1:1 - | -LL | #[cfg] //~ ERROR `cfg` is not followed by parentheses - | ^^^^^^ help: expected syntax is: `cfg(/* predicate */)` - -error: `cfg` is not followed by parentheses - --> $DIR/cfg-attr-syntax-validation.rs:4:1 - | -LL | #[cfg = 10] //~ ERROR `cfg` is not followed by parentheses - | ^^^^^^^^^^^ help: expected syntax is: `cfg(/* predicate */)` - -error: `cfg` predicate is not specified - --> $DIR/cfg-attr-syntax-validation.rs:7:1 - | -LL | #[cfg()] //~ ERROR `cfg` predicate is not specified - | ^^^^^^^^ - -error: multiple `cfg` predicates are specified - --> $DIR/cfg-attr-syntax-validation.rs:10:10 - | -LL | #[cfg(a, b)] //~ ERROR multiple `cfg` predicates are specified - | ^ - -error: `cfg` predicate key cannot be a literal - --> $DIR/cfg-attr-syntax-validation.rs:13:7 - | -LL | #[cfg("str")] //~ ERROR `cfg` predicate key cannot be a literal - | ^^^^^ - -error: `cfg` predicate key must be an identifier - --> $DIR/cfg-attr-syntax-validation.rs:16:7 - | -LL | #[cfg(a::b)] //~ ERROR `cfg` predicate key must be an identifier - | ^^^^ - -error[E0537]: invalid predicate `a` - --> $DIR/cfg-attr-syntax-validation.rs:19:7 - | -LL | #[cfg(a())] //~ ERROR invalid predicate `a` - | ^^^ - -error: literal in `cfg` predicate value must be a string - --> $DIR/cfg-attr-syntax-validation.rs:22:11 - | -LL | #[cfg(a = 10)] //~ ERROR literal in `cfg` predicate value must be a string - | ^^ - -error: `cfg` is not a well-formed meta-item - --> $DIR/cfg-attr-syntax-validation.rs:27:9 - | -LL | #[cfg(feature = $expr)] //~ ERROR `cfg` is not a well-formed meta-item - | ^^^^^^^^^^^^^^^^^^^^^^^ help: expected syntax is: `#[cfg(/* predicate */)]` -... -LL | generate_s9!(concat!("nonexistent")); - | ------------------------------------- in this macro invocation - -error: aborting due to 9 previous errors - -For more information about this error, try `rustc --explain E0537`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-trailing-comma.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-trailing-comma.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-trailing-comma.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-trailing-comma.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// compile-flags: --cfg TRUE - -#[cfg_attr(TRUE, inline,)] // OK -fn f() {} - -#[cfg_attr(FALSE, inline,)] // OK -fn g() {} - -#[cfg_attr(TRUE, inline,,)] //~ ERROR expected `)`, found `,` -fn h() {} - -#[cfg_attr(FALSE, inline,,)] //~ ERROR expected `)`, found `,` -fn i() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-trailing-comma.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-trailing-comma.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-trailing-comma.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-trailing-comma.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -error: expected `)`, found `,` - --> $DIR/cfg-attr-trailing-comma.rs:9:25 - | -LL | #[cfg_attr(TRUE, inline,,)] //~ ERROR expected `)`, found `,` - | ^ expected `)` - -error: expected `)`, found `,` - --> $DIR/cfg-attr-trailing-comma.rs:12:26 - | -LL | #[cfg_attr(FALSE, inline,,)] //~ ERROR expected `)`, found `,` - | ^ expected `)` - -error: aborting due to 2 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-unknown-attribute-macro-expansion.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-unknown-attribute-macro-expansion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-unknown-attribute-macro-expansion.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-unknown-attribute-macro-expansion.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! foo { - () => { - #[cfg_attr(all(), unknown)] //~ ERROR `unknown` is currently unknown - fn foo() {} - } -} - -foo!(); - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-unknown-attribute-macro-expansion.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-unknown-attribute-macro-expansion.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-attr-unknown-attribute-macro-expansion.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-attr-unknown-attribute-macro-expansion.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -error[E0658]: The attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) - --> $DIR/cfg-attr-unknown-attribute-macro-expansion.rs:13:27 - | -LL | #[cfg_attr(all(), unknown)] //~ ERROR `unknown` is currently unknown - | ^^^^^^^ -... -LL | foo!(); - | ------- in this macro invocation - | - = help: add #![feature(custom_attribute)] to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-empty-codemap.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-empty-codemap.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-empty-codemap.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-empty-codemap.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that empty source_maps don't ICE (#23301) - -// compile-flags: --cfg "" - -// error-pattern: invalid `--cfg` argument: `""` (expected `key` or `key="value"`) - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-in-crate-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-in-crate-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-in-crate-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-in-crate-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: `main` function not found - -#![cfg(bar)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-in-crate-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-in-crate-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-in-crate-1.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-in-crate-1.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -error[E0601]: `main` function not found in crate `cfg_in_crate_1` - | - = note: consider adding a `main` function to `$DIR/cfg-in-crate-1.rs` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0601`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-non-opt-expr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-non-opt-expr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-non-opt-expr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-non-opt-expr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(stmt_expr_attributes)] -#![feature(custom_test_frameworks)] - -fn main() { - let _ = #[cfg(unset)] (); - //~^ ERROR removing an expression is not supported in this position - let _ = 1 + 2 + #[cfg(unset)] 3; - //~^ ERROR removing an expression is not supported in this position - let _ = [1, 2, 3][#[cfg(unset)] 1]; - //~^ ERROR removing an expression is not supported in this position -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-non-opt-expr.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-non-opt-expr.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cfg-non-opt-expr.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cfg-non-opt-expr.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -error: removing an expression is not supported in this position - --> $DIR/cfg-non-opt-expr.rs:15:13 - | -LL | let _ = #[cfg(unset)] (); - | ^^^^^^^^^^^^^ - -error: removing an expression is not supported in this position - --> $DIR/cfg-non-opt-expr.rs:17:21 - | -LL | let _ = 1 + 2 + #[cfg(unset)] 3; - | ^^^^^^^^^^^^^ - -error: removing an expression is not supported in this position - --> $DIR/cfg-non-opt-expr.rs:19:23 - | -LL | let _ = [1, 2, 3][#[cfg(unset)] 1]; - | ^^^^^^^^^^^^^ - -error: aborting due to 3 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/chalkify/lower_env1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/chalkify/lower_env1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/chalkify/lower_env1.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/chalkify/lower_env1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -5,9 +5,8 @@ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: FromEnv(Self: Foo) :- FromEnv(Self: Bar). - = note: FromEnv(Self: Foo) :- FromEnv(Self: Bar). = note: Implemented(Self: Bar) :- FromEnv(Self: Bar). - = note: WellFormed(Self: Bar) :- Implemented(Self: Bar), WellFormed(Self: Foo), WellFormed(Self: Foo). + = note: WellFormed(Self: Bar) :- Implemented(Self: Bar), WellFormed(Self: Foo). error: program clause dump --> $DIR/lower_env1.rs:19:1 @@ -16,13 +15,9 @@ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: FromEnv(Self: Foo) :- FromEnv(Self: Bar). - = note: FromEnv(Self: Foo) :- FromEnv(Self: Bar). = note: Implemented(Self: Bar) :- FromEnv(Self: Bar). = note: Implemented(Self: Foo) :- FromEnv(Self: Foo). = note: Implemented(Self: std::marker::Sized) :- FromEnv(Self: std::marker::Sized). - = note: WellFormed(Self: Bar) :- Implemented(Self: Bar), WellFormed(Self: Foo), WellFormed(Self: Foo). - = note: WellFormed(Self: Foo) :- Implemented(Self: Foo). - = note: WellFormed(Self: std::marker::Sized) :- Implemented(Self: std::marker::Sized). error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/chalkify/lower_env2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/chalkify/lower_env2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/chalkify/lower_env2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/chalkify/lower_env2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +trait Foo { } + +#[rustc_dump_program_clauses] //~ ERROR program clause dump +struct S<'a, T> where T: Foo { + data: &'a T, +} + +#[rustc_dump_env_program_clauses] //~ ERROR program clause dump +fn bar<'a, T: Foo>(x: S) { +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/chalkify/lower_env2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/chalkify/lower_env2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/chalkify/lower_env2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/chalkify/lower_env2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +error: program clause dump + --> $DIR/lower_env2.rs:16:1 + | +LL | #[rustc_dump_program_clauses] //~ ERROR program clause dump + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: FromEnv(T: Foo) :- FromEnv(S<'a, T>). + = note: FromEnv(T: std::marker::Sized) :- FromEnv(S<'a, T>). + = note: TypeOutlives(T : 'a) :- FromEnv(S<'a, T>). + = note: WellFormed(S<'a, T>) :- Implemented(T: std::marker::Sized), Implemented(T: Foo), TypeOutlives(T : 'a). + +error: program clause dump + --> $DIR/lower_env2.rs:21:1 + | +LL | #[rustc_dump_env_program_clauses] //~ ERROR program clause dump + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: FromEnv(T: Foo) :- FromEnv(S<'a, T>). + = note: FromEnv(T: std::marker::Sized) :- FromEnv(S<'a, T>). + = note: Implemented(Self: Foo) :- FromEnv(Self: Foo). + = note: Implemented(Self: std::marker::Sized) :- FromEnv(Self: std::marker::Sized). + = note: TypeOutlives(T : 'a) :- FromEnv(S<'a, T>). + +error: aborting due to 2 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/chalkify/lower_env3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/chalkify/lower_env3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/chalkify/lower_env3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/chalkify/lower_env3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +trait Foo { + #[rustc_dump_env_program_clauses] //~ ERROR program clause dump + fn foo(&self); +} + +impl Foo for T where T: Clone { + #[rustc_dump_env_program_clauses] //~ ERROR program clause dump + fn foo(&self) { + } +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/chalkify/lower_env3.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/chalkify/lower_env3.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/chalkify/lower_env3.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/chalkify/lower_env3.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +error: program clause dump + --> $DIR/lower_env3.rs:15:5 + | +LL | #[rustc_dump_env_program_clauses] //~ ERROR program clause dump + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: Implemented(Self: Foo) :- FromEnv(Self: Foo). + +error: program clause dump + --> $DIR/lower_env3.rs:20:5 + | +LL | #[rustc_dump_env_program_clauses] //~ ERROR program clause dump + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: FromEnv(Self: std::marker::Sized) :- FromEnv(Self: std::clone::Clone). + = note: Implemented(Self: std::clone::Clone) :- FromEnv(Self: std::clone::Clone). + = note: Implemented(Self: std::marker::Sized) :- FromEnv(Self: std::marker::Sized). + +error: aborting due to 2 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/chalkify/lower_trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/chalkify/lower_trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/chalkify/lower_trait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/chalkify/lower_trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,11 +10,12 @@ #![feature(rustc_attrs)] +trait Bar { } + #[rustc_dump_program_clauses] //~ ERROR program clause dump -trait Foo { - fn s(_: S) -> S; - fn t(_: T) -> T; - fn u(_: U) -> U; +trait Foo { + #[rustc_dump_program_clauses] //~ ERROR program clause dump + type Assoc: Bar + ?Sized; } fn main() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/chalkify/lower_trait.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/chalkify/lower_trait.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/chalkify/lower_trait.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/chalkify/lower_trait.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,14 +1,23 @@ error: program clause dump - --> $DIR/lower_trait.rs:13:1 + --> $DIR/lower_trait.rs:15:1 | LL | #[rustc_dump_program_clauses] //~ ERROR program clause dump | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: FromEnv(S: std::marker::Sized) :- FromEnv(Self: Foo). - = note: FromEnv(T: std::marker::Sized) :- FromEnv(Self: Foo). - = note: FromEnv(U: std::marker::Sized) :- FromEnv(Self: Foo). - = note: Implemented(Self: Foo) :- FromEnv(Self: Foo). - = note: WellFormed(Self: Foo) :- Implemented(Self: Foo), WellFormed(S: std::marker::Sized), WellFormed(T: std::marker::Sized), WellFormed(U: std::marker::Sized). + = note: FromEnv(>::Assoc: Bar) :- FromEnv(Self: Foo). + = note: FromEnv(S: std::marker::Sized) :- FromEnv(Self: Foo). + = note: Implemented(Self: Foo) :- FromEnv(Self: Foo). + = note: WellFormed(Self: Foo) :- Implemented(Self: Foo), WellFormed(S: std::marker::Sized), WellFormed(>::Assoc: Bar). -error: aborting due to previous error +error: program clause dump + --> $DIR/lower_trait.rs:17:5 + | +LL | #[rustc_dump_program_clauses] //~ ERROR program clause dump + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: FromEnv(Self: Foo) :- FromEnv(Unnormalized(>::Assoc)). + = note: ProjectionEq(>::Assoc == Unnormalized(>::Assoc)). + = note: WellFormed(Unnormalized(>::Assoc)) :- Implemented(Self: Foo). + +error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/check-static-values-constraints.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/check-static-values-constraints.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/check-static-values-constraints.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/check-static-values-constraints.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -58,13 +58,22 @@ | cannot move out of static item | help: consider borrowing here: `&x` +error[E0507]: cannot move out of immutable static item `x` + --> $DIR/check-static-values-constraints.rs:120:45 + | +LL | let y = { static x: Box = box 3; x }; + | ^ + | | + | cannot move out of immutable static item `x` + | cannot move + error[E0010]: allocations are not allowed in statics --> $DIR/check-static-values-constraints.rs:120:38 | LL | let y = { static x: Box = box 3; x }; | ^^^^^ allocation not allowed in statics -error: aborting due to 10 previous errors +error: aborting due to 11 previous errors Some errors occurred: E0010, E0015, E0493, E0507. For more information about an error, try `rustc --explain E0010`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/closure_context/issue-42065.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/closure_context/issue-42065.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/closure_context/issue-42065.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/closure_context/issue-42065.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error[E0382]: use of moved value: `debug_dump_dict` - --> $DIR/issue-42065.rs:21:5 - | -LL | debug_dump_dict(); - | --------------- value moved here -LL | debug_dump_dict(); - | ^^^^^^^^^^^^^^^ value used here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/closure-expected-type/expect-fn-supply-fn.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -error[E0631]: type mismatch in closure arguments - --> $DIR/expect-fn-supply-fn.rs:40:5 - | -LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {}); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------------- found signature of `fn(for<'r> fn(&'r u32), _) -> _` - | | - | expected signature of `for<'a, 'r> fn(fn(&'a u32), &'r i32) -> _` - | -note: required by `with_closure_expecting_fn_with_free_region` - --> $DIR/expect-fn-supply-fn.rs:11:1 - | -LL | / fn with_closure_expecting_fn_with_free_region(_: F) -LL | | where F: for<'a> FnOnce(fn(&'a u32), &i32) -LL | | { -LL | | } - | |_^ - -error[E0631]: type mismatch in closure arguments - --> $DIR/expect-fn-supply-fn.rs:47:5 - | -LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {}); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------------------- found signature of `fn(fn(&'x u32), _) -> _` - | | - | expected signature of `for<'r> fn(for<'s> fn(&'s u32), &'r i32) -> _` - | -note: required by `with_closure_expecting_fn_with_bound_region` - --> $DIR/expect-fn-supply-fn.rs:16:1 - | -LL | / fn with_closure_expecting_fn_with_bound_region(_: F) -LL | | where F: FnOnce(fn(&u32), &i32) -LL | | { -LL | | } - | |_^ - -error[E0631]: type mismatch in closure arguments - --> $DIR/expect-fn-supply-fn.rs:56:5 - | -LL | with_closure_expecting_fn_with_bound_region(|_x: Foo<'_>, y| {}); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------------- found signature of `for<'r> fn(fn(&'r u32), _) -> _` - | | - | expected signature of `for<'r> fn(for<'s> fn(&'s u32), &'r i32) -> _` - | -note: required by `with_closure_expecting_fn_with_bound_region` - --> $DIR/expect-fn-supply-fn.rs:16:1 - | -LL | / fn with_closure_expecting_fn_with_bound_region(_: F) -LL | | where F: FnOnce(fn(&u32), &i32) -LL | | { -LL | | } - | |_^ - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0631`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/closure-expected-type/issue-24421.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/closure-expected-type/issue-24421.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/closure-expected-type/issue-24421.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/closure-expected-type/issue-24421.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass + +fn test(f: F) {} + +fn main() { + test(|x, y | {}); + test(|x:&u64, y:&u64| {}); + test(|x:&u64, y | {}); + test(|x, y:&u64| {}); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/closure-expected-type/README.md rustc-1.31.0+dfsg1+llvm/src/test/ui/closure-expected-type/README.md --- rustc-1.30.0+dfsg1+llvm/src/test/ui/closure-expected-type/README.md 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/closure-expected-type/README.md 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -See `src/test/run-pass/closure-expected-type`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/closure_promotion.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/closure_promotion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/closure_promotion.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/closure_promotion.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,8 +12,7 @@ #![allow(const_err)] -// nll successfully compiles this. It is a bug. -// See https://github.com/rust-lang/rust/issues/52384 +// nll successfully compiles this. fn main() { let x: &'static _ = &|| { let z = 3; z }; //~ ERROR does not live long enough } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/closure_promotion.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/closure_promotion.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/closure_promotion.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/closure_promotion.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error[E0597]: borrowed value does not live long enough - --> $DIR/closure_promotion.rs:18:26 + --> $DIR/closure_promotion.rs:17:26 | LL | let x: &'static _ = &|| { let z = 3; z }; //~ ERROR does not live long enough | ^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -error[E0621]: explicit lifetime required in the type of `x` - --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:15:5 - | -LL | fn foo(x: &()) { - | --- help: add explicit lifetime `'static` to the type of `x`: `&'static ()` -LL | / bar(|| { -LL | | //~^ ERROR explicit lifetime required in the type of `x` [E0621] -LL | | let _ = x; -LL | | }) - | |______^ lifetime `'static` required - -error[E0597]: `x` does not live long enough - --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:17:17 - | -LL | bar(|| { - | -- value captured here -LL | //~^ ERROR explicit lifetime required in the type of `x` [E0621] -LL | let _ = x; - | ^ borrowed value does not live long enough -LL | }) -LL | } - | - `x` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... - -error: aborting due to 2 previous errors - -Some errors occurred: E0597, E0621. -For more information about an error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/closures/closure-expected-type/expect-region-supply-region.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/closures/closure-expected-type/expect-region-supply-region.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/closures/closure-expected-type/expect-region-supply-region.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/closures/closure-expected-type/expect-region-supply-region.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -error: borrowed data escapes outside of closure - --> $DIR/expect-region-supply-region.rs:28:9 - | -LL | let mut f: Option<&u32> = None; - | ----- `f` is declared here, outside of the closure body -LL | closure_expecting_bound(|x| { - | - `x` is a reference that is only valid in the closure body -LL | f = Some(x); //~ ERROR borrowed data cannot be stored outside of its closure - | ^^^^^^^^^^^ `x` escapes the closure body here - -error: borrowed data escapes outside of closure - --> $DIR/expect-region-supply-region.rs:38:9 - | -LL | let mut f: Option<&u32> = None; - | ----- `f` is declared here, outside of the closure body -LL | closure_expecting_bound(|x: &u32| { - | - `x` is a reference that is only valid in the closure body -LL | f = Some(x); //~ ERROR borrowed data cannot be stored outside of its closure - | ^^^^^^^^^^^ `x` escapes the closure body here - -error: borrowed data escapes outside of closure - --> $DIR/expect-region-supply-region.rs:52:9 - | -LL | let mut f: Option<&u32> = None; - | ----- `f` is declared here, outside of the closure body -... -LL | closure_expecting_bound(|x: &'x u32| { - | - `x` is a reference that is only valid in the closure body -... -LL | f = Some(x); - | ^^^^^^^^^^^ `x` escapes the closure body here - -error: aborting due to 3 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/codemap_tests/issue-11715.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/codemap_tests/issue-11715.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/codemap_tests/issue-11715.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/codemap_tests/issue-11715.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^^^^^ second mutable borrow occurs here LL | z.use_mut(); LL | y.use_mut(); - | - borrow later used here + | - first borrow later used here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/codemap_tests/one_line.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/codemap_tests/one_line.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/codemap_tests/one_line.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/codemap_tests/one_line.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,11 +2,10 @@ --> $DIR/one_line.rs:13:12 | LL | v.push(v.pop().unwrap()); //~ ERROR cannot borrow - | -------^---------------- - | | | - | | second mutable borrow occurs here + | - ---- ^ second mutable borrow occurs here + | | | + | | first borrow later used by call | first mutable borrow occurs here - | borrow later used here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/coercion/coerce-overloaded-autoderef.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/coercion/coerce-overloaded-autoderef.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/coercion/coerce-overloaded-autoderef.ast.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/coercion/coerce-overloaded-autoderef.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^ second mutable borrow occurs here ... LL | drop((y, z)); - | - borrow later used here + | - first borrow later used here error[E0506]: cannot assign to `**x` because it is borrowed --> $DIR/coerce-overloaded-autoderef.rs:31:5 @@ -25,21 +25,20 @@ --> $DIR/coerce-overloaded-autoderef.rs:38:20 | LL | borrow_mut2(x, x); - | ---------------^- - | | | | - | | | second mutable borrow occurs here + | ----------- - ^ second mutable borrow occurs here + | | | | | first mutable borrow occurs here - | borrow later used here + | first borrow later used by call error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immutable --> $DIR/coerce-overloaded-autoderef.rs:44:5 | LL | borrow2(x, x); - | ^^^^^^^^^^^-^ + | -------^^^^-^ | | | | | immutable borrow occurs here | mutable borrow occurs here - | borrow later used here + | immutable borrow later used by call error: aborting due to 4 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/coercion/coerce-overloaded-autoderef.mir.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/coercion/coerce-overloaded-autoderef.mir.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/coercion/coerce-overloaded-autoderef.mir.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/coercion/coerce-overloaded-autoderef.mir.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^ second mutable borrow occurs here ... LL | drop((y, z)); - | - borrow later used here + | - first borrow later used here error[E0506]: cannot assign to `**x` because it is borrowed --> $DIR/coerce-overloaded-autoderef.rs:31:5 @@ -25,21 +25,20 @@ --> $DIR/coerce-overloaded-autoderef.rs:38:20 | LL | borrow_mut2(x, x); - | ---------------^- - | | | | - | | | second mutable borrow occurs here + | ----------- - ^ second mutable borrow occurs here + | | | | | first mutable borrow occurs here - | borrow later used here + | first borrow later used by call error[E0502]: cannot borrow `*x` as mutable because it is also borrowed as immutable --> $DIR/coerce-overloaded-autoderef.rs:44:5 | LL | borrow2(x, x); - | ^^^^^^^^^^^-^ + | -------^^^^-^ | | | | | immutable borrow occurs here | mutable borrow occurs here - | borrow later used here + | immutable borrow later used by call error: aborting due to 4 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/coercion/coerce-overloaded-autoderef.mir.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/coercion/coerce-overloaded-autoderef.mir.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/coercion/coerce-overloaded-autoderef.mir.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/coercion/coerce-overloaded-autoderef.mir.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^ second mutable borrow occurs here ... LL | drop((y, z)); - | - borrow later used here + | - first borrow later used here error[E0506]: cannot assign to `**x` because it is borrowed --> $DIR/coerce-overloaded-autoderef.rs:31:5 @@ -25,21 +25,19 @@ --> $DIR/coerce-overloaded-autoderef.rs:38:20 | LL | borrow_mut2(x, x); - | ---------------^- - | | | | - | | | second mutable borrow occurs here + | ----------- - ^ second mutable borrow occurs here + | | | | | first mutable borrow occurs here - | borrow later used here + | first borrow later used by call error[E0502]: cannot borrow `*x` as immutable because it is also borrowed as mutable --> $DIR/coerce-overloaded-autoderef.rs:44:16 | LL | borrow2(x, x); - | -----------^- - | | | | - | | | immutable borrow occurs here + | ------- - ^ immutable borrow occurs here + | | | | | mutable borrow occurs here - | borrow later used here + | mutable borrow later used by call error: aborting due to 4 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/coherence/coherence-impls-copy.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/coherence/coherence-impls-copy.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/coherence/coherence-impls-copy.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/coherence/coherence-impls-copy.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -14,7 +14,7 @@ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: conflicting implementation in crate `core`: - - impl<'a, T> std::marker::Copy for &'a T + - impl<'_, T> std::marker::Copy for &T where T: ?Sized; error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `&[NotSync]`: @@ -24,7 +24,7 @@ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: conflicting implementation in crate `core`: - - impl<'a, T> std::marker::Copy for &'a T + - impl<'_, T> std::marker::Copy for &T where T: ?Sized; error[E0206]: the trait `Copy` may not be implemented for this type diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/auxiliary/namespaced_enums.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/auxiliary/namespaced_enums.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/auxiliary/namespaced_enums.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/auxiliary/namespaced_enums.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub enum Foo { + A, + B(isize), + C { a: isize }, +} + +impl Foo { + pub fn foo() {} + pub fn bar(&self) {} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-arg-invalid-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-arg-invalid-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-arg-invalid-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-arg-invalid-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,3 @@ +// compile-flags: --cfg a(b=c) +// error-pattern: invalid `--cfg` argument: `a(b=c)` (expected `key` or `key="value"`) +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-arg-invalid-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-arg-invalid-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-arg-invalid-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-arg-invalid-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,3 @@ +// compile-flags: --cfg a{b} +// error-pattern: invalid `--cfg` argument: `a{b}` (expected `key` or `key="value"`) +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-arg-invalid-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-arg-invalid-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-arg-invalid-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-arg-invalid-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,3 @@ +// compile-flags: --cfg a::b +// error-pattern: invalid `--cfg` argument: `a::b` (argument key must be an identifier) +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-arg-invalid-4.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-arg-invalid-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-arg-invalid-4.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-arg-invalid-4.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,3 @@ +// compile-flags: --cfg a(b) +// error-pattern: invalid `--cfg` argument: `a(b)` (expected `key` or `key="value"`) +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-arg-invalid-5.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-arg-invalid-5.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-arg-invalid-5.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-arg-invalid-5.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,3 @@ +// compile-flags: --cfg a=10 +// error-pattern: invalid `--cfg` argument: `a=10` (argument value must be a string) +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-cfg-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-cfg-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-cfg-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-cfg-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// error-pattern: `main` function not found +// compile-flags: --cfg foo + +// main is conditionally compiled, but the conditional compilation +// is conditional too! + +#[cfg_attr(foo, cfg(bar))] +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-cfg-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-cfg-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-cfg-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-cfg-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,7 @@ +error[E0601]: `main` function not found in crate `cfg_attr_cfg_2` + | + = note: consider adding a `main` function to `$DIR/cfg-attr-cfg-2.rs` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0601`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-crate-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-crate-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-crate-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-crate-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// compile-flags: --cfg broken + +// https://github.com/rust-lang/rust/issues/21833#issuecomment-72353044 + +#![cfg_attr(broken, no_core)] //~ ERROR no_core is experimental + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-crate-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-crate-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-crate-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-crate-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0658]: no_core is experimental (see issue #29639) + --> $DIR/cfg-attr-crate-2.rs:15:21 + | +LL | #![cfg_attr(broken, no_core)] //~ ERROR no_core is experimental + | ^^^^^^^ + | + = help: add #![feature(no_core)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-invalid-predicate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-invalid-predicate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-invalid-predicate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-invalid-predicate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[cfg(foo(bar))] //~ ERROR invalid predicate `foo` +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-invalid-predicate.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-invalid-predicate.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-invalid-predicate.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-invalid-predicate.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0537]: invalid predicate `foo` + --> $DIR/cfg-attr-invalid-predicate.rs:11:7 + | +LL | #[cfg(foo(bar))] //~ ERROR invalid predicate `foo` + | ^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0537`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-false.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-false.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-false.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-false.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Test that cfg_attr doesn't emit any attributes when the +// configuration variable is false. This mirrors `cfg-attr-multi-true.rs` + +// compile-pass + +#![warn(unused_must_use)] +#![feature(cfg_attr_multi)] + +#[cfg_attr(any(), deprecated, must_use)] +struct Struct {} + +impl Struct { + fn new() -> Struct { + Struct {} + } +} + +fn main() { + Struct::new(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// compile-flags: --cfg broken + +#![feature(cfg_attr_multi)] +#![cfg_attr(broken, no_core, no_std)] //~ ERROR no_core is experimental + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-1.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0658]: no_core is experimental (see issue #29639) + --> $DIR/cfg-attr-multi-invalid-1.rs:14:21 + | +LL | #![cfg_attr(broken, no_core, no_std)] //~ ERROR no_core is experimental + | ^^^^^^^ + | + = help: add #![feature(no_core)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// compile-flags: --cfg broken + +#![feature(cfg_attr_multi)] +#![cfg_attr(broken, no_std, no_core)] //~ ERROR no_core is experimental + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0658]: no_core is experimental (see issue #29639) + --> $DIR/cfg-attr-multi-invalid-2.rs:14:29 + | +LL | #![cfg_attr(broken, no_std, no_core)] //~ ERROR no_core is experimental + | ^^^^^^^ + | + = help: add #![feature(no_core)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-true.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-true.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-true.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-true.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Test that cfg_attr with multiple attributes actually emits both attributes. +// This is done by emitting two attributes that cause new warnings, and then +// triggering those warnings. + +// compile-pass + +#![warn(unused_must_use)] +#![feature(cfg_attr_multi)] + +#[cfg_attr(all(), deprecated, must_use)] +struct MustUseDeprecated {} + +impl MustUseDeprecated { //~ warning: use of deprecated item + fn new() -> MustUseDeprecated { //~ warning: use of deprecated item + MustUseDeprecated {} //~ warning: use of deprecated item + } +} + +fn main() { + MustUseDeprecated::new(); //~ warning: use of deprecated item + //| warning: unused `MustUseDeprecated` that must be used +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-true.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-true.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-true.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-multi-true.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +warning: use of deprecated item 'MustUseDeprecated' + --> $DIR/cfg-attr-multi-true.rs:13:6 + | +LL | impl MustUseDeprecated { //~ warning: use of deprecated item + | ^^^^^^^^^^^^^^^^^ + | + = note: #[warn(deprecated)] on by default + +warning: use of deprecated item 'MustUseDeprecated' + --> $DIR/cfg-attr-multi-true.rs:20:5 + | +LL | MustUseDeprecated::new(); //~ warning: use of deprecated item + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'MustUseDeprecated' + --> $DIR/cfg-attr-multi-true.rs:14:17 + | +LL | fn new() -> MustUseDeprecated { //~ warning: use of deprecated item + | ^^^^^^^^^^^^^^^^^ + +warning: use of deprecated item 'MustUseDeprecated' + --> $DIR/cfg-attr-multi-true.rs:15:9 + | +LL | MustUseDeprecated {} //~ warning: use of deprecated item + | ^^^^^^^^^^^^^^^^^ + +warning: unused `MustUseDeprecated` that must be used + --> $DIR/cfg-attr-multi-true.rs:20:5 + | +LL | MustUseDeprecated::new(); //~ warning: use of deprecated item + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/cfg-attr-multi-true.rs:7:9 + | +LL | #![warn(unused_must_use)] + | ^^^^^^^^^^^^^^^ + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-parse.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-parse.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-parse.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-parse.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// Parse `cfg_attr` with varying numbers of attributes and trailing commas + +#![feature(cfg_attr_multi)] + +// Completely empty `cfg_attr` input +#[cfg_attr()] //~ error: expected identifier, found `)` +struct NoConfigurationPredicate; + +// Zero attributes, zero trailing comma (comma manatory here) +#[cfg_attr(all())] //~ error: expected `,`, found `)` +struct A0C0; + +// Zero attributes, one trailing comma +#[cfg_attr(all(),)] // Ok +struct A0C1; + +// Zero attributes, two trailing commas +#[cfg_attr(all(),,)] //~ ERROR expected identifier +struct A0C2; + +// One attribute, no trailing comma +#[cfg_attr(all(), must_use)] // Ok +struct A1C0; + +// One attribute, one trailing comma +#[cfg_attr(all(), must_use,)] // Ok +struct A1C1; + +// One attribute, two trailing commas +#[cfg_attr(all(), must_use,,)] //~ ERROR expected identifier +struct A1C2; + +// Two attributes, no trailing comma +#[cfg_attr(all(), must_use, deprecated)] // Ok +struct A2C0; + +// Two attributes, one trailing comma +#[cfg_attr(all(), must_use, deprecated,)] // Ok +struct A2C1; + +// Two attributes, two trailing commas +#[cfg_attr(all(), must_use, deprecated,,)] //~ ERROR expected identifier +struct A2C2; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-parse.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-parse.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-parse.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-parse.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +error: expected identifier, found `)` + --> $DIR/cfg-attr-parse.rs:6:12 + | +LL | #[cfg_attr()] //~ error: expected identifier, found `)` + | ^ expected identifier + +error: expected `,`, found `)` + --> $DIR/cfg-attr-parse.rs:10:17 + | +LL | #[cfg_attr(all())] //~ error: expected `,`, found `)` + | ^ expected `,` + +error: expected identifier, found `,` + --> $DIR/cfg-attr-parse.rs:18:18 + | +LL | #[cfg_attr(all(),,)] //~ ERROR expected identifier + | ^ expected identifier + +error: expected identifier, found `,` + --> $DIR/cfg-attr-parse.rs:30:28 + | +LL | #[cfg_attr(all(), must_use,,)] //~ ERROR expected identifier + | ^ expected identifier + +error: expected identifier, found `,` + --> $DIR/cfg-attr-parse.rs:42:40 + | +LL | #[cfg_attr(all(), must_use, deprecated,,)] //~ ERROR expected identifier + | ^ expected identifier + +error: aborting due to 5 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg_attr_path.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg_attr_path.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg_attr_path.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg_attr_path.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] +#![allow(dead_code)] +#![deny(unused_attributes)] // c.f #35584 + +mod auxiliary { + #[cfg_attr(any(), path = "nonexistent_file.rs")] pub mod namespaced_enums; + #[cfg_attr(all(), path = "namespaced_enums.rs")] pub mod nonexistent_file; +} + +#[rustc_error] +fn main() { //~ ERROR compilation successful + let _ = auxiliary::namespaced_enums::Foo::A; + let _ = auxiliary::nonexistent_file::Foo::A; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg_attr_path.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg_attr_path.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg_attr_path.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg_attr_path.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error: compilation successful + --> $DIR/cfg_attr_path.rs:21:1 + | +LL | / fn main() { //~ ERROR compilation successful +LL | | let _ = auxiliary::namespaced_enums::Foo::A; +LL | | let _ = auxiliary::nonexistent_file::Foo::A; +LL | | } + | |_^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-syntax-validation.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-syntax-validation.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-syntax-validation.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-syntax-validation.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +#[cfg] //~ ERROR `cfg` is not followed by parentheses +struct S1; + +#[cfg = 10] //~ ERROR `cfg` is not followed by parentheses +struct S2; + +#[cfg()] //~ ERROR `cfg` predicate is not specified +struct S3; + +#[cfg(a, b)] //~ ERROR multiple `cfg` predicates are specified +struct S4; + +#[cfg("str")] //~ ERROR `cfg` predicate key cannot be a literal +struct S5; + +#[cfg(a::b)] //~ ERROR `cfg` predicate key must be an identifier +struct S6; + +#[cfg(a())] //~ ERROR invalid predicate `a` +struct S7; + +#[cfg(a = 10)] //~ ERROR literal in `cfg` predicate value must be a string +struct S8; + +macro_rules! generate_s9 { + ($expr: expr) => { + #[cfg(feature = $expr)] //~ ERROR `cfg` is not a well-formed meta-item + struct S9; + } +} + +generate_s9!(concat!("nonexistent")); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-syntax-validation.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-syntax-validation.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-syntax-validation.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-syntax-validation.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,60 @@ +error: `cfg` is not followed by parentheses + --> $DIR/cfg-attr-syntax-validation.rs:1:1 + | +LL | #[cfg] //~ ERROR `cfg` is not followed by parentheses + | ^^^^^^ help: expected syntax is: `cfg(/* predicate */)` + +error: `cfg` is not followed by parentheses + --> $DIR/cfg-attr-syntax-validation.rs:4:1 + | +LL | #[cfg = 10] //~ ERROR `cfg` is not followed by parentheses + | ^^^^^^^^^^^ help: expected syntax is: `cfg(/* predicate */)` + +error: `cfg` predicate is not specified + --> $DIR/cfg-attr-syntax-validation.rs:7:1 + | +LL | #[cfg()] //~ ERROR `cfg` predicate is not specified + | ^^^^^^^^ + +error: multiple `cfg` predicates are specified + --> $DIR/cfg-attr-syntax-validation.rs:10:10 + | +LL | #[cfg(a, b)] //~ ERROR multiple `cfg` predicates are specified + | ^ + +error: `cfg` predicate key cannot be a literal + --> $DIR/cfg-attr-syntax-validation.rs:13:7 + | +LL | #[cfg("str")] //~ ERROR `cfg` predicate key cannot be a literal + | ^^^^^ + +error: `cfg` predicate key must be an identifier + --> $DIR/cfg-attr-syntax-validation.rs:16:7 + | +LL | #[cfg(a::b)] //~ ERROR `cfg` predicate key must be an identifier + | ^^^^ + +error[E0537]: invalid predicate `a` + --> $DIR/cfg-attr-syntax-validation.rs:19:7 + | +LL | #[cfg(a())] //~ ERROR invalid predicate `a` + | ^^^ + +error: literal in `cfg` predicate value must be a string + --> $DIR/cfg-attr-syntax-validation.rs:22:11 + | +LL | #[cfg(a = 10)] //~ ERROR literal in `cfg` predicate value must be a string + | ^^ + +error: `cfg` is not a well-formed meta-item + --> $DIR/cfg-attr-syntax-validation.rs:27:9 + | +LL | #[cfg(feature = $expr)] //~ ERROR `cfg` is not a well-formed meta-item + | ^^^^^^^^^^^^^^^^^^^^^^^ help: expected syntax is: `#[cfg(/* predicate */)]` +... +LL | generate_s9!(concat!("nonexistent")); + | ------------------------------------- in this macro invocation + +error: aborting due to 9 previous errors + +For more information about this error, try `rustc --explain E0537`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-unknown-attribute-macro-expansion.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-unknown-attribute-macro-expansion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-unknown-attribute-macro-expansion.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-unknown-attribute-macro-expansion.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! foo { + () => { + #[cfg_attr(all(), unknown)] //~ ERROR `unknown` is currently unknown + fn foo() {} + } +} + +foo!(); + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-unknown-attribute-macro-expansion.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-unknown-attribute-macro-expansion.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-unknown-attribute-macro-expansion.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-attr-unknown-attribute-macro-expansion.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error[E0658]: The attribute `unknown` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) + --> $DIR/cfg-attr-unknown-attribute-macro-expansion.rs:13:27 + | +LL | #[cfg_attr(all(), unknown)] //~ ERROR `unknown` is currently unknown + | ^^^^^^^ +... +LL | foo!(); + | ------- in this macro invocation + | + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-empty-codemap.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-empty-codemap.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-empty-codemap.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-empty-codemap.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that empty source_maps don't ICE (#23301) + +// compile-flags: --cfg "" + +// error-pattern: invalid `--cfg` argument: `""` (expected `key` or `key="value"`) + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-in-crate-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-in-crate-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-in-crate-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-in-crate-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: `main` function not found + +#![cfg(bar)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-in-crate-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-in-crate-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-in-crate-1.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-in-crate-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,7 @@ +error[E0601]: `main` function not found in crate `cfg_in_crate_1` + | + = note: consider adding a `main` function to `$DIR/cfg-in-crate-1.rs` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0601`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-non-opt-expr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-non-opt-expr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-non-opt-expr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-non-opt-expr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(stmt_expr_attributes)] +#![feature(custom_test_frameworks)] + +fn main() { + let _ = #[cfg(unset)] (); + //~^ ERROR removing an expression is not supported in this position + let _ = 1 + 2 + #[cfg(unset)] 3; + //~^ ERROR removing an expression is not supported in this position + let _ = [1, 2, 3][#[cfg(unset)] 1]; + //~^ ERROR removing an expression is not supported in this position +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-non-opt-expr.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-non-opt-expr.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-non-opt-expr.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conditional-compilation/cfg-non-opt-expr.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +error: removing an expression is not supported in this position + --> $DIR/cfg-non-opt-expr.rs:15:13 + | +LL | let _ = #[cfg(unset)] (); + | ^^^^^^^^^^^^^ + +error: removing an expression is not supported in this position + --> $DIR/cfg-non-opt-expr.rs:17:21 + | +LL | let _ = 1 + 2 + #[cfg(unset)] 3; + | ^^^^^^^^^^^^^ + +error: removing an expression is not supported in this position + --> $DIR/cfg-non-opt-expr.rs:19:23 + | +LL | let _ = [1, 2, 3][#[cfg(unset)] 1]; + | ^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conservative_impl_trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/conservative_impl_trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conservative_impl_trait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conservative_impl_trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ // #39872, #39553 fn will_ice(something: &u32) -> impl Iterator { - //~^ ERROR the trait bound `(): std::iter::Iterator` is not satisfied [E0277] + //~^ ERROR `()` is not an iterator } fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/conservative_impl_trait.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/conservative_impl_trait.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/conservative_impl_trait.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/conservative_impl_trait.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `(): std::iter::Iterator` is not satisfied +error[E0277]: `()` is not an iterator --> $DIR/conservative_impl_trait.rs:13:33 | LL | fn will_ice(something: &u32) -> impl Iterator { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator; maybe try calling `.iter()` or a similar method + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `()` = note: the return type of a function must have a statically known size diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/auxiliary/const_fn_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/auxiliary/const_fn_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/auxiliary/const_fn_lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/auxiliary/const_fn_lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,6 +11,5 @@ // Crate that exports a const fn. Used for testing cross-crate. #![crate_type="rlib"] -#![feature(min_const_fn)] pub const fn foo() -> usize { 22 } //~ ERROR const fn is unstable diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/auxiliary/promotable_const_fn_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/auxiliary/promotable_const_fn_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/auxiliary/promotable_const_fn_lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/auxiliary/promotable_const_fn_lib.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Crate that exports a const fn. Used for testing cross-crate. + +#![feature(staged_api, rustc_attrs)] +#![stable(since="1.0.0", feature = "mep")] + +#![crate_type="rlib"] + +#[rustc_promotable] +#[stable(since="1.0.0", feature = "mep")] +#[inline] +pub const fn foo() -> usize { 22 } + +#[stable(since="1.0.0", feature = "mep")] +pub struct Foo(usize); + +impl Foo { + #[stable(since="1.0.0", feature = "mep")] + #[inline] + #[rustc_promotable] + pub const fn foo() -> usize { 22 } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-array-oob.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-array-oob.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-array-oob.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-array-oob.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,10 +7,10 @@ = note: #[deny(const_err)] on by default error[E0080]: could not evaluate constant expression - --> $DIR/const-array-oob.rs:18:1 + --> $DIR/const-array-oob.rs:18:13 | LL | const BLUB: [u32; FOO[4]] = [5, 6]; - | ^^^^^^^^^^^^^^^^^^------^^^^^^^^^^^ + | ^^^^^^------^ | | | index out of bounds: the len is 3 but the index is 4 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-call.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-call.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-call.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-call.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,5 +15,4 @@ fn main() { let _ = [0; f(2)]; //~^ ERROR calls in constants are limited to constant functions - //~| E0080 } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-call.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-call.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-call.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-call.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -4,13 +4,6 @@ LL | let _ = [0; f(2)]; | ^^^^ -error[E0080]: could not evaluate repeat length - --> $DIR/const-call.rs:16:17 - | -LL | let _ = [0; f(2)]; - | ^^^^ calling non-const fn `f` - -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors occurred: E0015, E0080. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/conditional_array_execution.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/conditional_array_execution.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/conditional_array_execution.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/conditional_array_execution.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -warning: this constant cannot be used - --> $DIR/conditional_array_execution.rs:15:1 - | -LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; - | ^^^^^^^^^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | attempt to subtract with overflow - | -note: lint level defined here - --> $DIR/conditional_array_execution.rs:11:9 - | -LL | #![warn(const_err)] - | ^^^^^^^^^ - -error[E0080]: referenced constant has errors - --> $DIR/conditional_array_execution.rs:19:14 - | -LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; - | ----- attempt to subtract with overflow -... -LL | println!("{}", FOO); - | ^^^^ - -error[E0080]: erroneous constant used - --> $DIR/conditional_array_execution.rs:19:14 - | -LL | println!("{}", FOO); - | ^^^^ --- referenced constant has errors - -error[E0080]: referenced constant has errors - --> $DIR/conditional_array_execution.rs:19:20 - | -LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; - | ----- attempt to subtract with overflow -... -LL | println!("{}", FOO); - | ^^^ - -error[E0080]: erroneous constant used - --> $DIR/conditional_array_execution.rs:19:20 - | -LL | println!("{}", FOO); - | ^^^ referenced constant has errors - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0080`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/conditional_array_execution.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/conditional_array_execution.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/conditional_array_execution.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/conditional_array_execution.rs 2018-12-04 23:41:40.000000000 +0000 @@ -17,6 +17,6 @@ fn main() { println!("{}", FOO); - //~^ ERROR erroneous constant used - //~| E0080 + //~^ ERROR + //~| ERROR } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/const-eval-overflow-4.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/const-eval-overflow-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/const-eval-overflow-4.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/const-eval-overflow-4.rs 2018-12-04 23:41:40.000000000 +0000 @@ -20,9 +20,9 @@ use std::{u8, u16, u32, u64, usize}; const A_I8_T - //~^ ERROR could not evaluate constant expression : [u32; (i8::MAX as i8 + 1i8) as usize] //~^ ERROR attempt to add with overflow + //~| ERROR could not evaluate constant expression = [0; (i8::MAX as usize) + 1]; fn main() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/const-eval-overflow-4.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/const-eval-overflow-4.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/const-eval-overflow-4.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/const-eval-overflow-4.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error: attempt to add with overflow - --> $DIR/const-eval-overflow-4.rs:24:13 + --> $DIR/const-eval-overflow-4.rs:23:13 | LL | : [u32; (i8::MAX as i8 + 1i8) as usize] | ^^^^^^^^^^^^^^^^^^^^^ @@ -7,15 +7,12 @@ = note: #[deny(const_err)] on by default error[E0080]: could not evaluate constant expression - --> $DIR/const-eval-overflow-4.rs:22:1 + --> $DIR/const-eval-overflow-4.rs:23:7 | -LL | / const A_I8_T -LL | | //~^ ERROR could not evaluate constant expression -LL | | : [u32; (i8::MAX as i8 + 1i8) as usize] - | | --------------------- attempt to add with overflow -LL | | //~^ ERROR attempt to add with overflow -LL | | = [0; (i8::MAX as usize) + 1]; - | |__________________________________^ +LL | : [u32; (i8::MAX as i8 + 1i8) as usize] + | ^^^^^^---------------------^^^^^^^^^^ + | | + | attempt to add with overflow error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/const-pointer-values-in-various-types.rs:24:5 | LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected the type usize + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected initialized plain bits | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior @@ -36,7 +36,7 @@ --> $DIR/const-pointer-values-in-various-types.rs:36:5 | LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected the type u64 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected initialized plain bits | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior @@ -74,7 +74,7 @@ --> $DIR/const-pointer-values-in-various-types.rs:51:5 | LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected the type i64 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected initialized plain bits | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior @@ -96,7 +96,7 @@ --> $DIR/const-pointer-values-in-various-types.rs:60:5 | LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected the type f64 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected initialized plain bits | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior @@ -144,7 +144,7 @@ --> $DIR/const-pointer-values-in-various-types.rs:78:5 | LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected the type u64 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected initialized plain bits | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior @@ -184,7 +184,7 @@ --> $DIR/const-pointer-values-in-various-types.rs:93:5 | LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected the type i64 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected initialized plain bits | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior @@ -208,7 +208,7 @@ --> $DIR/const-pointer-values-in-various-types.rs:102:5 | LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected the type f64 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected initialized plain bits | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +error[E0716]: temporary value dropped while borrowed + --> $DIR/dont_promote_unstable_const_fn_cross_crate.rs:18:28 + | +LL | let _: &'static u32 = &foo(); //~ ERROR does not live long enough + | ------------ ^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | let _x: &'static u32 = &foo(); //~ ERROR does not live long enough +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/dont_promote_unstable_const_fn_cross_crate.rs:19:29 + | +LL | let _x: &'static u32 = &foo(); //~ ERROR does not live long enough + | ------------ ^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | } + | - temporary value is freed at the end of this statement + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +error: `foo` is not yet stable as a const fn + --> $DIR/dont_promote_unstable_const_fn.rs:25:25 + | +LL | const fn bar() -> u32 { foo() } //~ ERROR `foo` is not yet stable as a const fn + | ^^^^^ + | + = help: in Nightly builds, add `#![feature(foo)]` to the crate attributes to enable + +error[E0716]: temporary value dropped while borrowed + --> $DIR/dont_promote_unstable_const_fn.rs:28:28 + | +LL | let _: &'static u32 = &foo(); //~ ERROR does not live long enough + | ------------ ^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/dont_promote_unstable_const_fn.rs:32:28 + | +LL | let _: &'static u32 = &meh(); //~ ERROR does not live long enough + | ------------ ^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/dont_promote_unstable_const_fn.rs:33:26 + | +LL | let x: &'static _ = &std::time::Duration::from_millis(42).subsec_millis(); + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | //~^ ERROR does not live long enough +LL | } + | - temporary value is freed at the end of this statement + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -31,5 +31,5 @@ fn main() { let _: &'static u32 = &meh(); //~ ERROR does not live long enough let x: &'static _ = &std::time::Duration::from_millis(42).subsec_millis(); - //~^ does not live long enough + //~^ ERROR does not live long enough } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -32,7 +32,7 @@ | LL | let x: &'static _ = &std::time::Duration::from_millis(42).subsec_millis(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -LL | //~^ does not live long enough +LL | //~^ ERROR does not live long enough LL | } | - temporary value only lives until here | diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-43197.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-43197.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-43197.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-43197.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -warning: this constant cannot be used - --> $DIR/issue-43197.rs:20:5 - | -LL | const X: u32 = 0-1; - | ^^^^^^^^^^^^^^^---^ - | | - | attempt to subtract with overflow - | -note: lint level defined here - --> $DIR/issue-43197.rs:11:9 - | -LL | #![warn(const_err)] - | ^^^^^^^^^ - -warning: this constant cannot be used - --> $DIR/issue-43197.rs:22:5 - | -LL | const Y: u32 = foo(0-1); - | ^^^^^^^^^^^^^^^^^^^---^^ - | | - | attempt to subtract with overflow - -error[E0080]: referenced constant has errors - --> $DIR/issue-43197.rs:24:14 - | -LL | const X: u32 = 0-1; - | --- attempt to subtract with overflow -... -LL | println!("{} {}", X, Y); - | ^^^^^^^ - -error[E0080]: erroneous constant used - --> $DIR/issue-43197.rs:24:14 - | -LL | println!("{} {}", X, Y); - | ^^^^^^^ - referenced constant has errors - -error[E0080]: referenced constant has errors - --> $DIR/issue-43197.rs:24:26 - | -LL | const Y: u32 = foo(0-1); - | --- attempt to subtract with overflow -LL | //~^ WARN this constant cannot be used -LL | println!("{} {}", X, Y); - | ^ - -error[E0080]: erroneous constant used - --> $DIR/issue-43197.rs:24:26 - | -LL | println!("{} {}", X, Y); - | ^ referenced constant has errors - -error[E0080]: referenced constant has errors - --> $DIR/issue-43197.rs:24:23 - | -LL | const X: u32 = 0-1; - | --- attempt to subtract with overflow -... -LL | println!("{} {}", X, Y); - | ^ - -error[E0080]: erroneous constant used - --> $DIR/issue-43197.rs:24:23 - | -LL | println!("{} {}", X, Y); - | ^ referenced constant has errors - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0080`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-43197.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-43197.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-43197.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-43197.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,8 +10,6 @@ #![warn(const_err)] -#![feature(min_const_fn)] - const fn foo(x: u32) -> u32 { x } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-43197.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-43197.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-43197.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-43197.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ warning: this constant cannot be used - --> $DIR/issue-43197.rs:20:5 + --> $DIR/issue-43197.rs:18:5 | LL | const X: u32 = 0-1; | ^^^^^^^^^^^^^^^---^ @@ -13,7 +13,7 @@ | ^^^^^^^^^ warning: this constant cannot be used - --> $DIR/issue-43197.rs:22:5 + --> $DIR/issue-43197.rs:20:5 | LL | const Y: u32 = foo(0-1); | ^^^^^^^^^^^^^^^^^^^---^^ @@ -21,7 +21,7 @@ | attempt to subtract with overflow error[E0080]: referenced constant has errors - --> $DIR/issue-43197.rs:24:26 + --> $DIR/issue-43197.rs:22:26 | LL | const Y: u32 = foo(0-1); | --- attempt to subtract with overflow @@ -30,13 +30,13 @@ | ^ error[E0080]: erroneous constant used - --> $DIR/issue-43197.rs:24:26 + --> $DIR/issue-43197.rs:22:26 | LL | println!("{} {}", X, Y); | ^ referenced constant has errors error[E0080]: referenced constant has errors - --> $DIR/issue-43197.rs:24:23 + --> $DIR/issue-43197.rs:22:23 | LL | const X: u32 = 0-1; | --- attempt to subtract with overflow @@ -45,7 +45,7 @@ | ^ error[E0080]: erroneous constant used - --> $DIR/issue-43197.rs:24:23 + --> $DIR/issue-43197.rs:22:23 | LL | println!("{} {}", X, Y); | ^ referenced constant has errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-44578.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-44578.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-44578.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-44578.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -error[E0080]: referenced constant has errors - --> $DIR/issue-44578.rs:35:14 - | -LL | const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; - | ------------------------------------ index out of bounds: the len is 1 but the index is 1 -... -LL | println!("{}", as Foo>::AMT); - | ^^^^ - -error[E0080]: erroneous constant used - --> $DIR/issue-44578.rs:35:14 - | -LL | println!("{}", as Foo>::AMT); - | ^^^^ -------------------------- referenced constant has errors - -error[E0080]: referenced constant has errors - --> $DIR/issue-44578.rs:35:20 - | -LL | const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; - | ------------------------------------ index out of bounds: the len is 1 but the index is 1 -... -LL | println!("{}", as Foo>::AMT); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0080]: erroneous constant used - --> $DIR/issue-44578.rs:35:20 - | -LL | println!("{}", as Foo>::AMT); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0080`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-47971.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-47971.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-47971.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-47971.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,8 +10,6 @@ // compile-pass -#![feature(min_const_fn)] - struct S(pub &'static u32, pub u32); const fn g(ss: &S) -> &u32 { &ss.1 } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-52443.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-52443.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-52443.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-52443.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - [(); & { loop { continue } } ]; //~ ERROR mismatched types - [(); loop { break }]; //~ ERROR mismatched types - [(); {while true {break}; 0}]; //~ ERROR constant contains unimplemented expression type - [(); { for _ in 0usize.. {}; 0}]; //~ ERROR calls in constants are limited to constant functions - //~^ ERROR constant contains unimplemented expression type - //~| ERROR could not evaluate repeat length -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-52443.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-52443.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-52443.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/issue-52443.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-52443.rs:12:10 - | -LL | [(); & { loop { continue } } ]; //~ ERROR mismatched types - | ^^^^^^^^^^^^^^^^^^^^^^^ - | | - | expected usize, found reference - | help: consider removing the borrow: `{ loop { continue } }` - | - = note: expected type `usize` - found type `&_` - -error[E0308]: mismatched types - --> $DIR/issue-52443.rs:13:17 - | -LL | [(); loop { break }]; //~ ERROR mismatched types - | ^^^^^ expected (), found usize - | - = note: expected type `()` - found type `usize` - -error[E0019]: constant contains unimplemented expression type - --> $DIR/issue-52443.rs:14:11 - | -LL | [(); {while true {break}; 0}]; //~ ERROR constant contains unimplemented expression type - | ^^^^^^^^^^^^^^^^^^ - -error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants - --> $DIR/issue-52443.rs:15:21 - | -LL | [(); { for _ in 0usize.. {}; 0}]; //~ ERROR calls in constants are limited to constant functions - | ^^^^^^^^ - -error[E0019]: constant contains unimplemented expression type - --> $DIR/issue-52443.rs:15:21 - | -LL | [(); { for _ in 0usize.. {}; 0}]; //~ ERROR calls in constants are limited to constant functions - | ^^^^^^^^ - -error[E0080]: could not evaluate repeat length - --> $DIR/issue-52443.rs:15:10 - | -LL | [(); { for _ in 0usize.. {}; 0}]; //~ ERROR calls in constants are limited to constant functions - | ^^^^^^^^^^^--------^^^^^^^ - | | - | calling non-const fn `>::into_iter` - -error: aborting due to 6 previous errors - -Some errors occurred: E0015, E0019, E0080, E0308. -For more information about an error, try `rustc --explain E0015`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_const_fn_fail.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_const_fn_fail.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_const_fn_fail.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_const_fn_fail.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error[E0716]: temporary value dropped while borrowed + --> $DIR/promoted_const_fn_fail.rs:30:27 + | +LL | let x: &'static u8 = &(bar() + 1); //~ ERROR does not live long enough + | ----------- ^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_const_fn_fail.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_const_fn_fail.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_const_fn_fail.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_const_fn_fail.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// compile-pass - #![feature(const_fn, const_fn_union)] #![deny(const_err)] @@ -29,10 +27,7 @@ } fn main() { - // FIXME(oli-obk): this should panic at runtime - // this will actually compile, but then - // abort at runtime (not panic, hard abort). - let x: &'static u8 = &(bar() + 1); + let x: &'static u8 = &(bar() + 1); //~ ERROR does not live long enough let y = *x; unreachable!(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_const_fn_fail.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/promoted_const_fn_fail.rs:30:27 + | +LL | let x: &'static u8 = &(bar() + 1); //~ ERROR does not live long enough + | ^^^^^^^^^^^ temporary value does not live long enough +... +LL | } + | - temporary value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +error[E0716]: temporary value dropped while borrowed + --> $DIR/promoted_raw_ptr_ops.rs:14:29 + | +LL | let x: &'static bool = &(42 as *const i32 == 43 as *const i32); + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/promoted_raw_ptr_ops.rs:16:30 + | +LL | let y: &'static usize = &(&1 as *const i32 as usize + 1); //~ ERROR does not live long enough + | -------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/promoted_raw_ptr_ops.rs:17:28 + | +LL | let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | let a: &'static bool = &(main as fn() == main as fn()); //~ ERROR does not live long enough +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/promoted_raw_ptr_ops.rs:18:29 + | +LL | let a: &'static bool = &(main as fn() == main as fn()); //~ ERROR does not live long enough + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | } + | - temporary value is freed at the end of this statement + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,4 +15,5 @@ //~^ ERROR does not live long enough let y: &'static usize = &(&1 as *const i32 as usize + 1); //~ ERROR does not live long enough let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough + let a: &'static bool = &(main as fn() == main as fn()); //~ ERROR does not live long enough } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/promoted_raw_ptr_ops.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -14,7 +14,7 @@ | LL | let y: &'static usize = &(&1 as *const i32 as usize + 1); //~ ERROR does not live long enough | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -LL | let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough +... LL | } | - temporary value only lives until here | @@ -25,11 +25,22 @@ | LL | let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough +LL | let a: &'static bool = &(main as fn() == main as fn()); //~ ERROR does not live long enough +LL | } + | - temporary value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error[E0597]: borrowed value does not live long enough + --> $DIR/promoted_raw_ptr_ops.rs:18:29 + | +LL | let a: &'static bool = &(main as fn() == main as fn()); //~ ERROR does not live long enough + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough LL | } | - temporary value only lives until here | = note: borrowed value must be valid for the static lifetime... -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/transmute-const-promotion.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/transmute-const-promotion.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/transmute-const-promotion.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/transmute-const-promotion.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error[E0716]: temporary value dropped while borrowed + --> $DIR/transmute-const-promotion.rs:16:37 + | +LL | let x: &'static u32 = unsafe { &mem::transmute(3.0f32) }; + | ------------ ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | //~^ ERROR value does not live long enough +LL | } + | - temporary value is freed at the end of this statement + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/transmute-const.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/transmute-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/transmute-const.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/transmute-const.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,6 +14,5 @@ static FOO: bool = unsafe { mem::transmute(3u8) }; //~^ ERROR this static likely exhibits undefined behavior -//~^^ type validation failed: encountered 3, but expected something in the range 0..=1 fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-enum.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-enum.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-enum.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-enum.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -18,7 +18,7 @@ --> $DIR/ub-enum.rs:45:1 | LL | const BAD_ENUM_CHAR : Option<(char, char)> = Some(('x', unsafe { TransmuteChar { a: !0 }.b })); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered character at .Some.0.1, but expected a valid unicode codepoint + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 4294967295 at .Some.0.1, but expected something in the range 0..=1114111 | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-nonnull.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-nonnull.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-nonnull.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-nonnull.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(const_transmute)] + +use std::mem; +use std::ptr::NonNull; +use std::num::{NonZeroU8, NonZeroUsize}; + +const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; +//~^ ERROR this constant likely exhibits undefined behavior + +const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; +//~^ ERROR this constant likely exhibits undefined behavior +const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; +//~^ ERROR this constant likely exhibits undefined behavior + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-nonnull.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-nonnull.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-nonnull.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-nonnull.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/ub-nonnull.rs:17:1 + | +LL | const NULL_PTR: NonNull = unsafe { mem::transmute(0usize) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0, but expected something greater or equal to 1 + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/ub-nonnull.rs:20:1 + | +LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0, but expected something greater or equal to 1 + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/ub-nonnull.rs:22:1 + | +LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0, but expected something greater or equal to 1 + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0080`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-ref.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-ref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-ref.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-ref.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(const_transmute)] + +use std::mem; + +const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; +//~^ ERROR this constant likely exhibits undefined behavior + +const NULL: &u16 = unsafe { mem::transmute(0usize) }; +//~^ ERROR this constant likely exhibits undefined behavior + +const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; +//~^ ERROR this constant likely exhibits undefined behavior + +const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; +//~^ ERROR this constant likely exhibits undefined behavior + +const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; +//~^ ERROR this constant likely exhibits undefined behavior + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-ref.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-ref.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-ref.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-ref.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/ub-ref.rs:15:1 + | +LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered unaligned reference + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/ub-ref.rs:18:1 + | +LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0, but expected something greater or equal to 1 + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/ub-ref.rs:21:1 + | +LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected initialized plain bits + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/ub-ref.rs:24:1 + | +LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ a raw memory access tried to access part of a pointer value as raw bytes + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/ub-ref.rs:27:1 + | +LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered integer pointer in non-ZST reference + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0080`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-uninhabit.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-uninhabit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-uninhabit.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-uninhabit.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,15 +8,20 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -union Foo { - a: u8, - b: Bar, -} +#![feature(const_transmute)] + +use std::mem; #[derive(Copy, Clone)] enum Bar {} -const BAD_BAD_BAD: Bar = unsafe { Foo { a: 1 }.b}; +const BAD_BAD_BAD: Bar = unsafe { mem::transmute(()) }; +//~^ ERROR this constant likely exhibits undefined behavior + +const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; +//~^ ERROR this constant likely exhibits undefined behavior + +const BAD_BAD_ARRAY: [Bar; 1] = unsafe { mem::transmute(()) }; //~^ ERROR this constant likely exhibits undefined behavior fn main() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-uninhabit.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-uninhabit.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-uninhabit.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-uninhabit.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,11 +1,27 @@ error[E0080]: this constant likely exhibits undefined behavior - --> $DIR/ub-uninhabit.rs:19:1 + --> $DIR/ub-uninhabit.rs:18:1 | -LL | const BAD_BAD_BAD: Bar = unsafe { Foo { a: 1 }.b}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of an uninhabited type +LL | const BAD_BAD_BAD: Bar = unsafe { mem::transmute(()) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of an uninhabited type | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior -error: aborting due to previous error +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/ub-uninhabit.rs:21:1 + | +LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of an uninhabited type at . + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/ub-uninhabit.rs:24:1 + | +LL | const BAD_BAD_ARRAY: [Bar; 1] = unsafe { mem::transmute(()) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of an uninhabited type at [0] + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0080`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-upvars.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-upvars.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-upvars.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-upvars.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(const_transmute,const_let)] + +use std::mem; + +const BAD_UPVAR: &FnOnce() = &{ //~ ERROR this constant likely exhibits undefined behavior + let bad_ref: &'static u16 = unsafe { mem::transmute(0usize) }; + let another_var = 13; + move || { let _ = bad_ref; let _ = another_var; } +}; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-upvars.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-upvars.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-upvars.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-upvars.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/ub-upvars.rs:15:1 + | +LL | / const BAD_UPVAR: &FnOnce() = &{ //~ ERROR this constant likely exhibits undefined behavior +LL | | let bad_ref: &'static u16 = unsafe { mem::transmute(0usize) }; +LL | | let another_var = 13; +LL | | move || { let _ = bad_ref; let _ = another_var; } +LL | | }; + | |__^ type validation failed: encountered 0 at .., but expected something greater or equal to 1 + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-usize-in-ref.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-usize-in-ref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-usize-in-ref.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/ub-usize-in-ref.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-pass - -union Foo { - a: &'static u8, - b: usize, -} - -// This might point to an invalid address, but that's the user's problem -const USIZE_AS_STATIC_REF: &'static u8 = unsafe { Foo { b: 1337 }.a}; - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/union-ice.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/union-ice.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/union-ice.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/union-ice.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -13,7 +13,7 @@ LL | | a: 42, LL | | b: unsafe { UNION.field3 }, LL | | }; - | |__^ type validation failed: encountered undefined bytes at .b + | |__^ type validation failed: encountered uninitialized bytes at .b, but expected initialized plain bits | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/union_promotion.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/union_promotion.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/union_promotion.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/union_promotion.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +error[E0716]: temporary value dropped while borrowed + --> $DIR/union_promotion.rs:19:29 + | +LL | let x: &'static bool = &unsafe { //~ borrowed value does not live long enough + | ____________-------------____^ + | | | + | | type annotation requires that borrow lasts for `'static` +LL | | Foo { a: &1 }.b == Foo { a: &2 }.b +LL | | }; + | |_____^ creates a temporary which is freed while still in use +LL | } + | - temporary value is freed at the end of this statement + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/union-ub-fat-ptr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/union-ub-fat-ptr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/union-ub-fat-ptr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/union-ub-fat-ptr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,139 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused)] + +// normalize-stderr-test "alignment \d+" -> "alignment N" +// normalize-stderr-test "offset \d+" -> "offset N" +// normalize-stderr-test "allocation \d+" -> "allocation N" +// normalize-stderr-test "size \d+" -> "size N" + +union BoolTransmute { + val: u8, + bl: bool, +} + +#[repr(C)] +#[derive(Copy, Clone)] +struct SliceRepr { + ptr: *const u8, + len: usize, +} + +#[repr(C)] +#[derive(Copy, Clone)] +struct BadSliceRepr { + ptr: *const u8, + len: &'static u8, +} + +union SliceTransmute { + repr: SliceRepr, + bad: BadSliceRepr, + slice: &'static [u8], + str: &'static str, + my_str: &'static MyStr, + my_slice: &'static MySliceBool, +} + +#[repr(C)] +#[derive(Copy, Clone)] +struct DynRepr { + ptr: *const u8, + vtable: *const u8, +} + +#[repr(C)] +#[derive(Copy, Clone)] +struct DynRepr2 { + ptr: *const u8, + vtable: *const u64, +} + +#[repr(C)] +#[derive(Copy, Clone)] +struct BadDynRepr { + ptr: *const u8, + vtable: usize, +} + +union DynTransmute { + repr: DynRepr, + repr2: DynRepr2, + bad: BadDynRepr, + rust: &'static Trait, +} + +trait Trait {} +impl Trait for bool {} + +// custom unsized type +struct MyStr(str); + +// custom unsized type with sized fields +struct MySlice(bool, T); +type MySliceBool = MySlice<[bool]>; + +// OK +const A: &str = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 1 } }.str}; +// bad str +const B: &str = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.str}; +//~^ ERROR this constant likely exhibits undefined behavior +// bad str +const C: &str = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.str}; +//~^ ERROR this constant likely exhibits undefined behavior +// bad str in user-defined unsized type +const C2: &MyStr = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.my_str}; +//~^ ERROR this constant likely exhibits undefined behavior + +// OK +const A2: &[u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 1 } }.slice}; +// bad slice +const B2: &[u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.slice}; +//~^ ERROR this constant likely exhibits undefined behavior +// bad slice +const C3: &[u8] = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.slice}; +//~^ ERROR this constant likely exhibits undefined behavior + +// bad trait object +const D: &Trait = unsafe { DynTransmute { repr: DynRepr { ptr: &92, vtable: &3 } }.rust}; +//~^ ERROR this constant likely exhibits undefined behavior +// bad trait object +const E: &Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.rust}; +//~^ ERROR this constant likely exhibits undefined behavior +// bad trait object +const F: &Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 3 } }.rust}; +//~^ ERROR this constant likely exhibits undefined behavior + +// bad data *inside* the trait object +const G: &Trait = &unsafe { BoolTransmute { val: 3 }.bl }; +//~^ ERROR this constant likely exhibits undefined behavior +// bad data *inside* the slice +const H: &[bool] = &[unsafe { BoolTransmute { val: 3 }.bl }]; +//~^ ERROR this constant likely exhibits undefined behavior + +// good MySliceBool +const I1: &MySliceBool = &MySlice(true, [false]); +// bad: sized field is not okay +const I2: &MySliceBool = &MySlice(unsafe { BoolTransmute { val: 3 }.bl }, [false]); +//~^ ERROR this constant likely exhibits undefined behavior +// bad: unsized part is not okay +const I3: &MySliceBool = &MySlice(true, [unsafe { BoolTransmute { val: 3 }.bl }]); +//~^ ERROR this constant likely exhibits undefined behavior + +// invalid UTF-8 +const J1: &str = unsafe { SliceTransmute { slice: &[0xFF] }.str }; +//~^ ERROR this constant likely exhibits undefined behavior +// invalid UTF-8 in user-defined str-like +const J2: &MyStr = unsafe { SliceTransmute { slice: &[0xFF] }.my_str }; +//~^ ERROR this constant likely exhibits undefined behavior + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/union-ub-fat-ptr.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/union-ub-fat-ptr.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/union-ub-fat-ptr.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/union-ub-fat-ptr.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,115 @@ +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/union-ub-fat-ptr.rs:87:1 + | +LL | const B: &str = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.str}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling (not entirely in bounds) reference + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/union-ub-fat-ptr.rs:90:1 + | +LL | const C: &str = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.str}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in fat pointer + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/union-ub-fat-ptr.rs:93:1 + | +LL | const C2: &MyStr = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.my_str}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in fat pointer + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/union-ub-fat-ptr.rs:99:1 + | +LL | const B2: &[u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.slice}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered dangling (not entirely in bounds) reference + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/union-ub-fat-ptr.rs:102:1 + | +LL | const C3: &[u8] = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.slice}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in fat pointer + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/union-ub-fat-ptr.rs:106:1 + | +LL | const D: &Trait = unsafe { DynTransmute { repr: DynRepr { ptr: &92, vtable: &3 } }.rust}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop fn in vtable + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/union-ub-fat-ptr.rs:109:1 + | +LL | const E: &Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.rust}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid drop fn in vtable + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/union-ub-fat-ptr.rs:112:1 + | +LL | const F: &Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 3 } }.rust}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-pointer vtable in fat pointer + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/union-ub-fat-ptr.rs:116:1 + | +LL | const G: &Trait = &unsafe { BoolTransmute { val: 3 }.bl }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at ., but expected something in the range 0..=1 + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/union-ub-fat-ptr.rs:119:1 + | +LL | const H: &[bool] = &[unsafe { BoolTransmute { val: 3 }.bl }]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at .[0], but expected something in the range 0..=1 + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/union-ub-fat-ptr.rs:125:1 + | +LL | const I2: &MySliceBool = &MySlice(unsafe { BoolTransmute { val: 3 }.bl }, [false]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at ..0, but expected something in the range 0..=1 + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/union-ub-fat-ptr.rs:128:1 + | +LL | const I3: &MySliceBool = &MySlice(true, [unsafe { BoolTransmute { val: 3 }.bl }]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at ..1[0], but expected something in the range 0..=1 + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/union-ub-fat-ptr.rs:132:1 + | +LL | const J1: &str = unsafe { SliceTransmute { slice: &[0xFF] }.str }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized or non-UTF-8 data in str at . + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error[E0080]: this constant likely exhibits undefined behavior + --> $DIR/union-ub-fat-ptr.rs:135:1 + | +LL | const J2: &MyStr = unsafe { SliceTransmute { slice: &[0xFF] }.my_str }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized or non-UTF-8 data in str at ..0 + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior + +error: aborting due to 14 previous errors + +For more information about this error, try `rustc --explain E0080`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/union-ub.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/union-ub.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/union-ub.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/union-ub.rs 2018-12-04 23:41:40.000000000 +0000 @@ -41,5 +41,4 @@ const BAD_UNION: Foo = unsafe { Bar { u8: 42 }.foo }; -fn main() { -} +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/valid-const.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/valid-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-eval/valid-const.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-eval/valid-const.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// compile-pass + +// Some constants that *are* valid +#![feature(const_transmute)] + +use std::mem; +use std::ptr::NonNull; +use std::num::{NonZeroU8, NonZeroUsize}; + +const NON_NULL_PTR1: NonNull = unsafe { mem::transmute(1usize) }; +const NON_NULL_PTR2: NonNull = unsafe { mem::transmute(&0) }; + +const NON_NULL_U8: NonZeroU8 = unsafe { mem::transmute(1u8) }; +const NON_NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(1usize) }; + +const UNIT: () = (); + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-fn-error.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-fn-error.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-fn-error.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-fn-error.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(const_fn)] - -const X : usize = 2; - -const fn f(x: usize) -> usize { - let mut sum = 0; - //~^ let bindings in constant functions are unstable - //~| statements in constant functions are unstable - for i in 0..x { - //~^ ERROR E0015 - //~| ERROR E0019 - sum += i; - } - sum -} - -#[allow(unused_variables)] -fn main() { - let a : [i32; f(X)]; //~ ERROR E0080 -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-fn-error.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-fn-error.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-fn-error.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-fn-error.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -error[E0658]: let bindings in constant functions are unstable (see issue #48821) - --> $DIR/const-fn-error.rs:16:19 - | -LL | let mut sum = 0; - | ^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in constant functions are unstable (see issue #48821) - --> $DIR/const-fn-error.rs:16:19 - | -LL | let mut sum = 0; - | ^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants - --> $DIR/const-fn-error.rs:19:14 - | -LL | for i in 0..x { - | ^^^^ - -error[E0019]: constant function contains unimplemented expression type - --> $DIR/const-fn-error.rs:19:14 - | -LL | for i in 0..x { - | ^^^^ - -error[E0080]: could not evaluate constant expression - --> $DIR/const-fn-error.rs:29:13 - | -LL | for i in 0..x { - | ---- calling non-const fn `>::into_iter` -... -LL | let a : [i32; f(X)]; //~ ERROR E0080 - | ^^^^^^----^ - | | - | inside call to `f` - -error: aborting due to 5 previous errors - -Some errors occurred: E0015, E0019, E0080, E0658. -For more information about an error, try `rustc --explain E0015`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-int-conversion.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-int-conversion.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-int-conversion.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-int-conversion.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,80 @@ +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-conversion.rs:14:28 + | +LL | let x: &'static i32 = &(5_i32.reverse_bits()); + | ------------ ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-conversion.rs:16:28 + | +LL | let y: &'static i32 = &(i32::from_be_bytes([0x12, 0x34, 0x56, 0x78])); + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-conversion.rs:18:28 + | +LL | let z: &'static i32 = &(i32::from_le_bytes([0x12, 0x34, 0x56, 0x78])); + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-conversion.rs:20:28 + | +LL | let a: &'static i32 = &(i32::from_be(i32::from_ne_bytes([0x80, 0, 0, 0]))); + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-conversion.rs:22:29 + | +LL | let b: &'static [u8] = &(0x12_34_56_78_i32.to_be_bytes()); + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-conversion.rs:24:29 + | +LL | let c: &'static [u8] = &(0x12_34_56_78_i32.to_le_bytes()); + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-conversion.rs:26:29 + | +LL | let d: &'static [u8] = &(i32::min_value().to_be().to_ne_bytes()); + | ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | //~^ ERROR does not live long enough +LL | } + | - temporary value is freed at the end of this statement + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-int-overflowing.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-int-overflowing.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-int-overflowing.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-int-overflowing.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-overflowing.rs:12:36 + | +LL | let x: &'static (i32, bool) = &(5_i32.overflowing_add(3)); //~ ERROR does not live long enough + | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-overflowing.rs:13:36 + | +LL | let y: &'static (i32, bool) = &(5_i32.overflowing_sub(3)); //~ ERROR does not live long enough + | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); //~ ERROR does not live long enough +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-overflowing.rs:14:36 + | +LL | let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); //~ ERROR does not live long enough + | -------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | } + | - temporary value is freed at the end of this statement + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-int-rotate.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-int-rotate.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-int-rotate.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-int-rotate.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-rotate.rs:12:28 + | +LL | let x: &'static i32 = &(5_i32.rotate_left(3)); //~ ERROR does not live long enough + | ------------ ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | let y: &'static i32 = &(5_i32.rotate_right(3)); //~ ERROR does not live long enough +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-rotate.rs:13:28 + | +LL | let y: &'static i32 = &(5_i32.rotate_right(3)); //~ ERROR does not live long enough + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | } + | - temporary value is freed at the end of this statement + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-int-sign.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-int-sign.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-int-sign.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-int-sign.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-sign.rs:12:29 + | +LL | let x: &'static bool = &(5_i32.is_negative()); //~ ERROR does not live long enough + | ------------- ^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | let y: &'static bool = &(5_i32.is_positive()); //~ ERROR does not live long enough +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-sign.rs:13:29 + | +LL | let y: &'static bool = &(5_i32.is_positive()); //~ ERROR does not live long enough + | ------------- ^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | } + | - temporary value is freed at the end of this statement + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-int-wrapping.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-int-wrapping.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-int-wrapping.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-int-wrapping.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,57 @@ +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-wrapping.rs:12:28 + | +LL | let x: &'static i32 = &(5_i32.wrapping_add(3)); //~ ERROR does not live long enough + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-wrapping.rs:13:28 + | +LL | let y: &'static i32 = &(5_i32.wrapping_sub(3)); //~ ERROR does not live long enough + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-wrapping.rs:14:28 + | +LL | let z: &'static i32 = &(5_i32.wrapping_mul(3)); //~ ERROR does not live long enough + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-wrapping.rs:15:28 + | +LL | let a: &'static i32 = &(5_i32.wrapping_shl(3)); //~ ERROR does not live long enough + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | let b: &'static i32 = &(5_i32.wrapping_shr(3)); //~ ERROR does not live long enough +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/const-int-wrapping.rs:16:28 + | +LL | let b: &'static i32 = &(5_i32.wrapping_shr(3)); //~ ERROR does not live long enough + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | } + | - temporary value is freed at the end of this statement + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-pattern-not-const-evaluable.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-pattern-not-const-evaluable.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-pattern-not-const-evaluable.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-pattern-not-const-evaluable.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,8 +10,6 @@ // compile-pass -#![feature(min_const_fn)] - #[derive(PartialEq, Eq)] enum Cake { BlackForest, diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-unsized.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-unsized.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-unsized.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-unsized.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,42 +1,38 @@ error[E0277]: the size for values of type `(dyn std::fmt::Debug + std::marker::Sync + 'static)` cannot be known at compilation time - --> $DIR/const-unsized.rs:13:29 + --> $DIR/const-unsized.rs:13:16 | LL | const CONST_0: Debug+Sync = *(&0 as &(Debug+Sync)); - | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::fmt::Debug + std::marker::Sync + 'static)` = note: to learn more, visit - = note: constant expressions must have a statically known size error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/const-unsized.rs:16:24 + --> $DIR/const-unsized.rs:16:18 | LL | const CONST_FOO: str = *"foo"; - | ^^^^^^ doesn't have a size known at compile-time + | ^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` = note: to learn more, visit - = note: constant expressions must have a statically known size error[E0277]: the size for values of type `(dyn std::fmt::Debug + std::marker::Sync + 'static)` cannot be known at compilation time - --> $DIR/const-unsized.rs:19:31 + --> $DIR/const-unsized.rs:19:18 | LL | static STATIC_1: Debug+Sync = *(&1 as &(Debug+Sync)); - | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::fmt::Debug + std::marker::Sync + 'static)` = note: to learn more, visit - = note: constant expressions must have a statically known size error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/const-unsized.rs:22:26 + --> $DIR/const-unsized.rs:22:20 | LL | static STATIC_BAR: str = *"bar"; - | ^^^^^^ doesn't have a size known at compile-time + | ^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` = note: to learn more, visit - = note: constant expressions must have a statically known size error: aborting due to 4 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-validation-fail-55455.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-validation-fail-55455.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/const-validation-fail-55455.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/const-validation-fail-55455.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +// https://github.com/rust-lang/rust/issues/55454 +// compile-pass + +struct This(T); + +const C: This> = This(Some(&1)); + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/issue-54224.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/issue-54224.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/issue-54224.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/issue-54224.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +#![feature(nll)] + +const FOO: Option<&[[u8; 3]]> = Some(&[*b"foo"]); //~ ERROR temporary value dropped while borrowed + +use std::borrow::Cow; + +pub const X: [u8; 3] = *b"ABC"; +pub const Y: Cow<'static, [ [u8; 3] ]> = Cow::Borrowed(&[X]); + + +pub const Z: Cow<'static, [ [u8; 3] ]> = Cow::Borrowed(&[*b"ABC"]); +//~^ ERROR temporary value dropped while borrowed + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/issue-54224.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/issue-54224.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/issue-54224.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/issue-54224.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +error[E0716]: temporary value dropped while borrowed + --> $DIR/issue-54224.rs:3:39 + | +LL | const FOO: Option<&[[u8; 3]]> = Some(&[*b"foo"]); //~ ERROR temporary value dropped while borrowed + | ------^^^^^^^^^- + | | | | + | | | temporary value is freed at the end of this statement + | | creates a temporary which is freed while still in use + | using this value as a constant requires that borrow lasts for `'static` + +error[E0716]: temporary value dropped while borrowed + --> $DIR/issue-54224.rs:11:57 + | +LL | pub const Z: Cow<'static, [ [u8; 3] ]> = Cow::Borrowed(&[*b"ABC"]); + | ---------------^^^^^^^^^- + | | | | + | | | temporary value is freed at the end of this statement + | | creates a temporary which is freed while still in use + | using this value as a constant requires that borrow lasts for `'static` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/bad_const_fn_body_ice.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/bad_const_fn_body_ice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/bad_const_fn_body_ice.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/bad_const_fn_body_ice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,5 @@ +const fn foo(a: i32) -> Vec { + vec![1, 2, 3] //~ ERROR heap allocations are not allowed in const fn +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: heap allocations are not allowed in const fn + --> $DIR/bad_const_fn_body_ice.rs:2:5 + | +LL | vec![1, 2, 3] //~ ERROR heap allocations are not allowed in const fn + | ^^^^^^^^^^^^^ + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/cast_errors.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/cast_errors.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/cast_errors.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/cast_errors.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +fn main() {} + +const fn unsize(x: &[u8; 3]) -> &[u8] { x } +//~^ ERROR unsizing casts are not allowed in const fn +const fn closure() -> fn() { || {} } +//~^ ERROR function pointers in const fn are unstable +const fn closure2() { + (|| {}) as fn(); +//~^ ERROR function pointers in const fn are unstable +} +const fn reify(f: fn()) -> unsafe fn() { f } +//~^ ERROR function pointers in const fn are unstable +const fn reify2() { main as unsafe fn(); } +//~^ ERROR function pointers in const fn are unstable diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/cast_errors.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/cast_errors.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/cast_errors.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/cast_errors.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +error: unsizing casts are not allowed in const fn + --> $DIR/cast_errors.rs:3:41 + | +LL | const fn unsize(x: &[u8; 3]) -> &[u8] { x } + | ^ + +error: function pointers in const fn are unstable + --> $DIR/cast_errors.rs:5:23 + | +LL | const fn closure() -> fn() { || {} } + | ^^^^ + +error: function pointers in const fn are unstable + --> $DIR/cast_errors.rs:8:5 + | +LL | (|| {}) as fn(); + | ^^^^^^^^^^^^^^^ + +error: function pointers in const fn are unstable + --> $DIR/cast_errors.rs:11:28 + | +LL | const fn reify(f: fn()) -> unsafe fn() { f } + | ^^^^^^^^^^^ + +error: function pointers in const fn are unstable + --> $DIR/cast_errors.rs:13:21 + | +LL | const fn reify2() { main as unsafe fn(); } + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 5 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/cmp_fn_pointers.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/cmp_fn_pointers.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/cmp_fn_pointers.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/cmp_fn_pointers.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,5 @@ +const fn cmp(x: fn(), y: fn()) -> bool { //~ ERROR function pointers in const fn are unstable + x == y +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/cmp_fn_pointers.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/cmp_fn_pointers.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/cmp_fn_pointers.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/cmp_fn_pointers.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: function pointers in const fn are unstable + --> $DIR/cmp_fn_pointers.rs:1:14 + | +LL | const fn cmp(x: fn(), y: fn()) -> bool { //~ ERROR function pointers in const fn are unstable + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/loop_ice.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/loop_ice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/loop_ice.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/loop_ice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,5 @@ +const fn foo() { + loop {} //~ ERROR loops are not allowed in const fn +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/loop_ice.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/loop_ice.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/loop_ice.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/loop_ice.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: loops are not allowed in const fn + --> $DIR/loop_ice.rs:2:5 + | +LL | loop {} //~ ERROR loops are not allowed in const fn + | ^^^^^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_dyn.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_dyn.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_dyn.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_dyn.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,25 +1,28 @@ error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn_dyn.rs:21:5 + --> $DIR/min_const_fn_dyn.rs:19:5 | LL | x.0.field; | ^^^^^^^^^ error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn_dyn.rs:24:66 + --> $DIR/min_const_fn_dyn.rs:22:66 | LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) } | ^^ -error[E0597]: borrowed value does not live long enough - --> $DIR/min_const_fn_dyn.rs:24:67 +warning[E0716]: temporary value dropped while borrowed + --> $DIR/min_const_fn_dyn.rs:22:67 | LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) } - | ^ - temporary value only lives until here - | | - | temporary value does not live long enough + | -^ - temporary value is freed at the end of this statement + | || + | |creates a temporary which is freed while still in use + | cast requires that borrow lasts for `'static` | - = note: borrowed value must be valid for the static lifetime... + = warning: This error has been downgraded to a warning for backwards compatibility with previous releases. + It represents potential unsoundness in your code. + This warning will become a hard error in the future. -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_dyn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_dyn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_dyn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_dyn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(min_const_fn)] - struct HasDyn { field: &'static dyn std::fmt::Debug, } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_dyn.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_dyn.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_dyn.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_dyn.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,11 +1,11 @@ error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn_dyn.rs:21:5 + --> $DIR/min_const_fn_dyn.rs:19:5 | LL | x.0.field; | ^^^^^^^^^ error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn_dyn.rs:24:66 + --> $DIR/min_const_fn_dyn.rs:22:66 | LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) } | ^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_fn_ptr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_fn_ptr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_fn_ptr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_fn_ptr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(min_const_fn)] - struct HasPtr { field: fn(), } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_fn_ptr.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_fn_ptr.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_fn_ptr.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_fn_ptr.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,11 +1,11 @@ error: function pointers in const fn are unstable - --> $DIR/min_const_fn_fn_ptr.rs:23:5 + --> $DIR/min_const_fn_fn_ptr.rs:21:5 | LL | x.0.field; | ^^^^^^^^^ error: function pointers in const fn are unstable - --> $DIR/min_const_fn_fn_ptr.rs:26:59 + --> $DIR/min_const_fn_fn_ptr.rs:24:59 | LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasPtr { field }) } | ^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_libstd.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_libstd.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_libstd.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_libstd.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(integer_atomics, min_const_fn)] +#![feature(integer_atomics)] // compile-pass diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,224 +1,227 @@ error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/min_const_fn.rs:49:25 + --> $DIR/min_const_fn.rs:47:25 | LL | const fn into_inner(self) -> T { self.0 } //~ destructors cannot be evaluated | ^^^^ constant functions cannot evaluate destructors error: mutable references in const fn are unstable - --> $DIR/min_const_fn.rs:51:5 + --> $DIR/min_const_fn.rs:49:36 | LL | const fn get_mut(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^ error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/min_const_fn.rs:56:28 + --> $DIR/min_const_fn.rs:54:28 | LL | const fn into_inner_lt(self) -> T { self.0 } //~ destructors cannot be evaluated | ^^^^ constant functions cannot evaluate destructors error: mutable references in const fn are unstable - --> $DIR/min_const_fn.rs:58:5 + --> $DIR/min_const_fn.rs:56:42 | LL | const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^ error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/min_const_fn.rs:63:27 + --> $DIR/min_const_fn.rs:61:27 | LL | const fn into_inner_s(self) -> T { self.0 } //~ ERROR destructors | ^^^^ constant functions cannot evaluate destructors error: mutable references in const fn are unstable - --> $DIR/min_const_fn.rs:65:5 + --> $DIR/min_const_fn.rs:63:38 | LL | const fn get_mut_s(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^ error: mutable references in const fn are unstable - --> $DIR/min_const_fn.rs:70:5 + --> $DIR/min_const_fn.rs:68:39 | LL | const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^ error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:88:16 + --> $DIR/min_const_fn.rs:86:16 | LL | const fn foo11(t: T) -> T { t } | ^ error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:90:18 + --> $DIR/min_const_fn.rs:88:18 | LL | const fn foo11_2(t: T) -> T { t } | ^ error: only int, `bool` and `char` operations are stable in const fn - --> $DIR/min_const_fn.rs:92:33 + --> $DIR/min_const_fn.rs:90:33 | LL | const fn foo19(f: f32) -> f32 { f * 2.0 } | ^^^^^^^ error: only int, `bool` and `char` operations are stable in const fn - --> $DIR/min_const_fn.rs:94:35 + --> $DIR/min_const_fn.rs:92:35 | LL | const fn foo19_2(f: f32) -> f32 { 2.0 - f } | ^^^^^^^ error: only int and `bool` operations are stable in const fn - --> $DIR/min_const_fn.rs:96:35 + --> $DIR/min_const_fn.rs:94:35 | LL | const fn foo19_3(f: f32) -> f32 { -f } | ^^ error: only int, `bool` and `char` operations are stable in const fn - --> $DIR/min_const_fn.rs:98:43 + --> $DIR/min_const_fn.rs:96:43 | LL | const fn foo19_4(f: f32, g: f32) -> f32 { f / g } | ^^^^^ error: cannot access `static` items in const fn - --> $DIR/min_const_fn.rs:102:27 + --> $DIR/min_const_fn.rs:100:27 | LL | const fn foo25() -> u32 { BAR } //~ ERROR cannot access `static` items in const fn | ^^^ error: cannot access `static` items in const fn - --> $DIR/min_const_fn.rs:103:36 + --> $DIR/min_const_fn.rs:101:36 | LL | const fn foo26() -> &'static u32 { &BAR } //~ ERROR cannot access `static` items | ^^^^ error: casting pointers to ints is unstable in const fn - --> $DIR/min_const_fn.rs:104:42 + --> $DIR/min_const_fn.rs:102:42 | LL | const fn foo30(x: *const u32) -> usize { x as usize } | ^^^^^^^^^^ error: casting pointers to ints is unstable in const fn - --> $DIR/min_const_fn.rs:106:42 + --> $DIR/min_const_fn.rs:104:42 | LL | const fn foo30_2(x: *mut u32) -> usize { x as usize } | ^^^^^^^^^^ error: `if`, `match`, `&&` and `||` are not stable in const fn - --> $DIR/min_const_fn.rs:108:38 + --> $DIR/min_const_fn.rs:106:38 | LL | const fn foo30_4(b: bool) -> usize { if b { 1 } else { 42 } } | ^^^^^^^^^^^^^^^^^^^^^^ error: `if`, `match`, `&&` and `||` are not stable in const fn - --> $DIR/min_const_fn.rs:110:29 + --> $DIR/min_const_fn.rs:108:29 | LL | const fn foo30_5(b: bool) { while b { } } //~ ERROR not stable in const fn | ^^^^^^^^^^^ error: local variables in const fn are unstable - --> $DIR/min_const_fn.rs:111:34 + --> $DIR/min_const_fn.rs:109:34 | LL | const fn foo30_6() -> bool { let x = true; x } //~ ERROR local variables in const fn are unstable | ^ error: `if`, `match`, `&&` and `||` are not stable in const fn - --> $DIR/min_const_fn.rs:112:44 + --> $DIR/min_const_fn.rs:110:44 | LL | const fn foo36(a: bool, b: bool) -> bool { a && b } | ^^^^^^ error: `if`, `match`, `&&` and `||` are not stable in const fn - --> $DIR/min_const_fn.rs:114:44 + --> $DIR/min_const_fn.rs:112:44 | LL | const fn foo37(a: bool, b: bool) -> bool { a || b } | ^^^^^^ error: mutable references in const fn are unstable - --> $DIR/min_const_fn.rs:116:14 + --> $DIR/min_const_fn.rs:114:14 | LL | const fn inc(x: &mut i32) { *x += 1 } | ^ error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:121:6 + --> $DIR/min_const_fn.rs:119:6 | LL | impl Foo { | ^ error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:126:6 + --> $DIR/min_const_fn.rs:124:6 | LL | impl Foo { | ^ error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:131:6 + --> $DIR/min_const_fn.rs:129:6 | LL | impl Foo { | ^ error: `impl Trait` in const fn is unstable - --> $DIR/min_const_fn.rs:137:1 + --> $DIR/min_const_fn.rs:135:24 | LL | const fn no_rpit2() -> AlanTuring { AlanTuring(0) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:139:34 + --> $DIR/min_const_fn.rs:137:34 | LL | const fn no_apit2(_x: AlanTuring) {} | ^^^^^^^^^^^^^^^^^^^^ error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:141:22 + --> $DIR/min_const_fn.rs:139:22 | LL | const fn no_apit(_x: impl std::fmt::Debug) {} //~ ERROR trait bounds other than `Sized` | ^^^^^^^^^^^^^^^^^^^^ error: `impl Trait` in const fn is unstable - --> $DIR/min_const_fn.rs:142:1 + --> $DIR/min_const_fn.rs:140:23 | LL | const fn no_rpit() -> impl std::fmt::Debug {} //~ ERROR `impl Trait` in const fn is unstable - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:143:23 + --> $DIR/min_const_fn.rs:141:23 | LL | const fn no_dyn_trait(_x: &dyn std::fmt::Debug) {} //~ ERROR trait bounds other than `Sized` | ^^ error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:144:1 + --> $DIR/min_const_fn.rs:142:32 | LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0597]: borrowed value does not live long enough - --> $DIR/min_const_fn.rs:144:64 +warning[E0515]: cannot return reference to temporary value + --> $DIR/min_const_fn.rs:142:63 | LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } - | ^^ - temporary value only lives until here - | | - | temporary value does not live long enough + | ^-- + | || + | |temporary value created here + | returns a reference to data owned by the current function | - = note: borrowed value must be valid for the static lifetime... + = warning: This error has been downgraded to a warning for backwards compatibility with previous releases. + It represents potential unsoundness in your code. + This warning will become a hard error in the future. error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:149:41 + --> $DIR/min_const_fn.rs:147:41 | LL | const fn really_no_traits_i_mean_it() { (&() as &std::fmt::Debug, ()).1 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: function pointers in const fn are unstable - --> $DIR/min_const_fn.rs:152:21 + --> $DIR/min_const_fn.rs:150:21 | LL | const fn no_fn_ptrs(_x: fn()) {} | ^^ error: function pointers in const fn are unstable - --> $DIR/min_const_fn.rs:154:1 + --> $DIR/min_const_fn.rs:152:27 | LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^ -error: aborting due to 36 previous errors +error: aborting due to 35 previous errors -Some errors occurred: E0493, E0597. +Some errors occurred: E0493, E0515. For more information about an error, try `rustc --explain E0493`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(min_const_fn)] - // ok const fn foo1() {} const fn foo2(x: i32) -> i32 { x } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,212 +1,212 @@ error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/min_const_fn.rs:49:25 + --> $DIR/min_const_fn.rs:47:25 | LL | const fn into_inner(self) -> T { self.0 } //~ destructors cannot be evaluated | ^^^^ constant functions cannot evaluate destructors error: mutable references in const fn are unstable - --> $DIR/min_const_fn.rs:51:5 + --> $DIR/min_const_fn.rs:49:36 | LL | const fn get_mut(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^ error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/min_const_fn.rs:56:28 + --> $DIR/min_const_fn.rs:54:28 | LL | const fn into_inner_lt(self) -> T { self.0 } //~ destructors cannot be evaluated | ^^^^ constant functions cannot evaluate destructors error: mutable references in const fn are unstable - --> $DIR/min_const_fn.rs:58:5 + --> $DIR/min_const_fn.rs:56:42 | LL | const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^ error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/min_const_fn.rs:63:27 + --> $DIR/min_const_fn.rs:61:27 | LL | const fn into_inner_s(self) -> T { self.0 } //~ ERROR destructors | ^^^^ constant functions cannot evaluate destructors error: mutable references in const fn are unstable - --> $DIR/min_const_fn.rs:65:5 + --> $DIR/min_const_fn.rs:63:38 | LL | const fn get_mut_s(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^ error: mutable references in const fn are unstable - --> $DIR/min_const_fn.rs:70:5 + --> $DIR/min_const_fn.rs:68:39 | LL | const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^ error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:88:16 + --> $DIR/min_const_fn.rs:86:16 | LL | const fn foo11(t: T) -> T { t } | ^ error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:90:18 + --> $DIR/min_const_fn.rs:88:18 | LL | const fn foo11_2(t: T) -> T { t } | ^ error: only int, `bool` and `char` operations are stable in const fn - --> $DIR/min_const_fn.rs:92:33 + --> $DIR/min_const_fn.rs:90:33 | LL | const fn foo19(f: f32) -> f32 { f * 2.0 } | ^^^^^^^ error: only int, `bool` and `char` operations are stable in const fn - --> $DIR/min_const_fn.rs:94:35 + --> $DIR/min_const_fn.rs:92:35 | LL | const fn foo19_2(f: f32) -> f32 { 2.0 - f } | ^^^^^^^ error: only int and `bool` operations are stable in const fn - --> $DIR/min_const_fn.rs:96:35 + --> $DIR/min_const_fn.rs:94:35 | LL | const fn foo19_3(f: f32) -> f32 { -f } | ^^ error: only int, `bool` and `char` operations are stable in const fn - --> $DIR/min_const_fn.rs:98:43 + --> $DIR/min_const_fn.rs:96:43 | LL | const fn foo19_4(f: f32, g: f32) -> f32 { f / g } | ^^^^^ error: cannot access `static` items in const fn - --> $DIR/min_const_fn.rs:102:27 + --> $DIR/min_const_fn.rs:100:27 | LL | const fn foo25() -> u32 { BAR } //~ ERROR cannot access `static` items in const fn | ^^^ error: cannot access `static` items in const fn - --> $DIR/min_const_fn.rs:103:36 + --> $DIR/min_const_fn.rs:101:36 | LL | const fn foo26() -> &'static u32 { &BAR } //~ ERROR cannot access `static` items | ^^^^ error: casting pointers to ints is unstable in const fn - --> $DIR/min_const_fn.rs:104:42 + --> $DIR/min_const_fn.rs:102:42 | LL | const fn foo30(x: *const u32) -> usize { x as usize } | ^^^^^^^^^^ error: casting pointers to ints is unstable in const fn - --> $DIR/min_const_fn.rs:106:42 + --> $DIR/min_const_fn.rs:104:42 | LL | const fn foo30_2(x: *mut u32) -> usize { x as usize } | ^^^^^^^^^^ error: `if`, `match`, `&&` and `||` are not stable in const fn - --> $DIR/min_const_fn.rs:108:38 + --> $DIR/min_const_fn.rs:106:38 | LL | const fn foo30_4(b: bool) -> usize { if b { 1 } else { 42 } } | ^^^^^^^^^^^^^^^^^^^^^^ error: `if`, `match`, `&&` and `||` are not stable in const fn - --> $DIR/min_const_fn.rs:110:29 + --> $DIR/min_const_fn.rs:108:29 | LL | const fn foo30_5(b: bool) { while b { } } //~ ERROR not stable in const fn | ^^^^^^^^^^^ error: local variables in const fn are unstable - --> $DIR/min_const_fn.rs:111:34 + --> $DIR/min_const_fn.rs:109:34 | LL | const fn foo30_6() -> bool { let x = true; x } //~ ERROR local variables in const fn are unstable | ^ error: `if`, `match`, `&&` and `||` are not stable in const fn - --> $DIR/min_const_fn.rs:112:44 + --> $DIR/min_const_fn.rs:110:44 | LL | const fn foo36(a: bool, b: bool) -> bool { a && b } | ^^^^^^ error: `if`, `match`, `&&` and `||` are not stable in const fn - --> $DIR/min_const_fn.rs:114:44 + --> $DIR/min_const_fn.rs:112:44 | LL | const fn foo37(a: bool, b: bool) -> bool { a || b } | ^^^^^^ error: mutable references in const fn are unstable - --> $DIR/min_const_fn.rs:116:14 + --> $DIR/min_const_fn.rs:114:14 | LL | const fn inc(x: &mut i32) { *x += 1 } | ^ error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:121:6 + --> $DIR/min_const_fn.rs:119:6 | LL | impl Foo { | ^ error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:126:6 + --> $DIR/min_const_fn.rs:124:6 | LL | impl Foo { | ^ error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:131:6 + --> $DIR/min_const_fn.rs:129:6 | LL | impl Foo { | ^ error: `impl Trait` in const fn is unstable - --> $DIR/min_const_fn.rs:137:1 + --> $DIR/min_const_fn.rs:135:24 | LL | const fn no_rpit2() -> AlanTuring { AlanTuring(0) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:139:34 + --> $DIR/min_const_fn.rs:137:34 | LL | const fn no_apit2(_x: AlanTuring) {} | ^^^^^^^^^^^^^^^^^^^^ error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:141:22 + --> $DIR/min_const_fn.rs:139:22 | LL | const fn no_apit(_x: impl std::fmt::Debug) {} //~ ERROR trait bounds other than `Sized` | ^^^^^^^^^^^^^^^^^^^^ error: `impl Trait` in const fn is unstable - --> $DIR/min_const_fn.rs:142:1 + --> $DIR/min_const_fn.rs:140:23 | LL | const fn no_rpit() -> impl std::fmt::Debug {} //~ ERROR `impl Trait` in const fn is unstable - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:143:23 + --> $DIR/min_const_fn.rs:141:23 | LL | const fn no_dyn_trait(_x: &dyn std::fmt::Debug) {} //~ ERROR trait bounds other than `Sized` | ^^ error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:144:1 + --> $DIR/min_const_fn.rs:142:32 | LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:149:41 + --> $DIR/min_const_fn.rs:147:41 | LL | const fn really_no_traits_i_mean_it() { (&() as &std::fmt::Debug, ()).1 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: function pointers in const fn are unstable - --> $DIR/min_const_fn.rs:152:21 + --> $DIR/min_const_fn.rs:150:21 | LL | const fn no_fn_ptrs(_x: fn()) {} | ^^ error: function pointers in const fn are unstable - --> $DIR/min_const_fn.rs:154:1 + --> $DIR/min_const_fn.rs:152:27 | LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^ error: aborting due to 35 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_unsafe.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_unsafe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_unsafe.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_unsafe.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(min_const_fn)] - // ok const unsafe fn foo4() -> i32 { 42 } const unsafe fn foo5() -> *const T { 0 as *const T } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_unsafe.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_unsafe.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_unsafe.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/min_const_fn_unsafe.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error[E0658]: dereferencing raw pointers in constant functions is unstable (see issue #51911) - --> $DIR/min_const_fn_unsafe.rs:29:51 + --> $DIR/min_const_fn_unsafe.rs:27:51 | LL | const unsafe fn foo30_3(x: *mut usize) -> usize { *x } //~ ERROR not allowed in const fn | ^^ @@ -7,7 +7,7 @@ = help: add #![feature(const_raw_ptr_deref)] to the crate attributes to enable error[E0658]: unions in const fn are unstable (see issue #51909) - --> $DIR/min_const_fn_unsafe.rs:36:5 + --> $DIR/min_const_fn_unsafe.rs:34:5 | LL | Foo { x: () }.y //~ ERROR not allowed in const fn | ^^^^^^^^^^^^^^^ @@ -15,7 +15,7 @@ = help: add #![feature(const_fn_union)] to the crate attributes to enable error: call to unsafe function is unsafe and unsafe operations are not allowed in const fn - --> $DIR/min_const_fn_unsafe.rs:21:14 + --> $DIR/min_const_fn_unsafe.rs:19:14 | LL | unsafe { foo4() } //~ ERROR unsafe operations are not allowed in const fn | ^^^^^^ call to unsafe function @@ -23,7 +23,7 @@ = note: consult the function's documentation for information on how to avoid undefined behavior error: call to unsafe function is unsafe and unsafe operations are not allowed in const fn - --> $DIR/min_const_fn_unsafe.rs:24:14 + --> $DIR/min_const_fn_unsafe.rs:22:14 | LL | unsafe { foo5::() } //~ ERROR unsafe operations are not allowed in const fn | ^^^^^^^^^^^^^^^^ call to unsafe function @@ -31,7 +31,7 @@ = note: consult the function's documentation for information on how to avoid undefined behavior error: call to unsafe function is unsafe and unsafe operations are not allowed in const fn - --> $DIR/min_const_fn_unsafe.rs:27:14 + --> $DIR/min_const_fn_unsafe.rs:25:14 | LL | unsafe { foo6::>>() } //~ ERROR not allowed in const fn | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function @@ -39,7 +39,7 @@ = note: consult the function's documentation for information on how to avoid undefined behavior error: dereference of raw pointer is unsafe and unsafe operations are not allowed in const fn - --> $DIR/min_const_fn_unsafe.rs:29:51 + --> $DIR/min_const_fn_unsafe.rs:27:51 | LL | const unsafe fn foo30_3(x: *mut usize) -> usize { *x } //~ ERROR not allowed in const fn | ^^ dereference of raw pointer @@ -47,7 +47,7 @@ = note: raw pointers may be NULL, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior error: access to union field is unsafe and unsafe operations are not allowed in const fn - --> $DIR/min_const_fn_unsafe.rs:36:5 + --> $DIR/min_const_fn_unsafe.rs:34:5 | LL | Foo { x: () }.y //~ ERROR not allowed in const fn | ^^^^^^^^^^^^^^^ access to union field diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/promotion.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/promotion.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/promotion.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/promotion.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,68 @@ +error[E0716]: temporary value dropped while borrowed + --> $DIR/promotion.rs:11:27 + | +LL | let x: &'static () = &foo1(); //~ ERROR does not live long enough + | ----------- ^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/promotion.rs:12:28 + | +LL | let y: &'static i32 = &foo2(42); //~ ERROR does not live long enough + | ------------ ^^^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/promotion.rs:13:28 + | +LL | let z: &'static i32 = &foo3(); //~ ERROR does not live long enough + | ------------ ^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/promotion.rs:14:34 + | +LL | let a: &'static Cell = &foo4(); //~ ERROR does not live long enough + | ------------------ ^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/promotion.rs:15:42 + | +LL | let a: &'static Option> = &foo5(); //~ ERROR does not live long enough + | -------------------------- ^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | let a: &'static Option> = &foo6(); //~ ERROR does not live long enough +LL | } + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/promotion.rs:16:42 + | +LL | let a: &'static Option> = &foo6(); //~ ERROR does not live long enough + | -------------------------- ^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | } + | - temporary value is freed at the end of this statement + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/promotion.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/promotion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/promotion.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/promotion.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +use std::cell::Cell; + +const fn foo1() {} +const fn foo2(x: i32) -> i32 { x } +const fn foo3() -> i32 { 42 } +const fn foo4() -> Cell { Cell::new(42) } +const fn foo5() -> Option> { Some(Cell::new(42)) } +const fn foo6() -> Option> { None } + +fn main() { + let x: &'static () = &foo1(); //~ ERROR does not live long enough + let y: &'static i32 = &foo2(42); //~ ERROR does not live long enough + let z: &'static i32 = &foo3(); //~ ERROR does not live long enough + let a: &'static Cell = &foo4(); //~ ERROR does not live long enough + let a: &'static Option> = &foo5(); //~ ERROR does not live long enough + let a: &'static Option> = &foo6(); //~ ERROR does not live long enough +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/promotion.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/promotion.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/promotion.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/min_const_fn/promotion.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,68 @@ +error[E0597]: borrowed value does not live long enough + --> $DIR/promotion.rs:11:27 + | +LL | let x: &'static () = &foo1(); //~ ERROR does not live long enough + | ^^^^^^ temporary value does not live long enough +... +LL | } + | - temporary value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error[E0597]: borrowed value does not live long enough + --> $DIR/promotion.rs:12:28 + | +LL | let y: &'static i32 = &foo2(42); //~ ERROR does not live long enough + | ^^^^^^^^ temporary value does not live long enough +... +LL | } + | - temporary value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error[E0597]: borrowed value does not live long enough + --> $DIR/promotion.rs:13:28 + | +LL | let z: &'static i32 = &foo3(); //~ ERROR does not live long enough + | ^^^^^^ temporary value does not live long enough +... +LL | } + | - temporary value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error[E0597]: borrowed value does not live long enough + --> $DIR/promotion.rs:14:34 + | +LL | let a: &'static Cell = &foo4(); //~ ERROR does not live long enough + | ^^^^^^ temporary value does not live long enough +... +LL | } + | - temporary value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error[E0597]: borrowed value does not live long enough + --> $DIR/promotion.rs:15:42 + | +LL | let a: &'static Option> = &foo5(); //~ ERROR does not live long enough + | ^^^^^^ temporary value does not live long enough +LL | let a: &'static Option> = &foo6(); //~ ERROR does not live long enough +LL | } + | - temporary value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error[E0597]: borrowed value does not live long enough + --> $DIR/promotion.rs:16:42 + | +LL | let a: &'static Option> = &foo6(); //~ ERROR does not live long enough + | ^^^^^^ temporary value does not live long enough +LL | } + | - temporary value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/promoted-validation-55454.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/promoted-validation-55454.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/promoted-validation-55454.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/promoted-validation-55454.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +// https://github.com/rust-lang/rust/issues/55454 +// compile-pass + +#[derive(PartialEq)] +struct This(T); + +fn main() { + This(Some(&1)) == This(Some(&1)); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/promote_fn_calls.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/promote_fn_calls.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/promote_fn_calls.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/promote_fn_calls.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// compile-pass +// aux-build:promotable_const_fn_lib.rs + +#![feature(nll)] + +extern crate promotable_const_fn_lib; + +use promotable_const_fn_lib::{foo, Foo}; + +fn main() { + let x: &'static usize = &foo(); + let x: &'static usize = &Foo::foo(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/promote_fn_calls_std.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/promote_fn_calls_std.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/promote_fn_calls_std.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/promote_fn_calls_std.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// compile-pass + +#![feature(nll)] + +fn main() { + let x: &'static u8 = &u8::max_value(); + let x: &'static u16 = &u16::max_value(); + let x: &'static u32 = &u32::max_value(); + let x: &'static u64 = &u64::max_value(); + let x: &'static u128 = &u128::max_value(); + let x: &'static usize = &usize::max_value(); + let x: &'static u8 = &u8::min_value(); + let x: &'static u16 = &u16::min_value(); + let x: &'static u32 = &u32::min_value(); + let x: &'static u64 = &u64::min_value(); + let x: &'static u128 = &u128::min_value(); + let x: &'static usize = &usize::min_value(); + let x: &'static i8 = &i8::max_value(); + let x: &'static i16 = &i16::max_value(); + let x: &'static i32 = &i32::max_value(); + let x: &'static i64 = &i64::max_value(); + let x: &'static i128 = &i128::max_value(); + let x: &'static isize = &isize::max_value(); + let x: &'static i8 = &i8::min_value(); + let x: &'static i16 = &i16::min_value(); + let x: &'static i32 = &i32::min_value(); + let x: &'static i64 = &i64::min_value(); + let x: &'static i128 = &i128::min_value(); + let x: &'static isize = &isize::min_value(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/single_variant_match_ice.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/single_variant_match_ice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/single_variant_match_ice.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/single_variant_match_ice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +enum Foo { + Prob, +} + +impl Foo { + pub const fn as_val(&self) -> u8 { + use self::Foo::*; + + match *self { + Prob => 0x1, //~ ERROR `if`, `match`, `&&` and `||` are not stable in const fn + } + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/single_variant_match_ice.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/single_variant_match_ice.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/consts/single_variant_match_ice.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/consts/single_variant_match_ice.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: `if`, `match`, `&&` and `||` are not stable in const fn + --> $DIR/single_variant_match_ice.rs:10:13 + | +LL | Prob => 0x1, //~ ERROR `if`, `match`, `&&` and `||` are not stable in const fn + | ^^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/custom-attribute-multisegment.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/custom-attribute-multisegment.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/custom-attribute-multisegment.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/custom-attribute-multisegment.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,5 +14,5 @@ mod existent {} -#[existent::nonexistent] //~ ERROR failed to resolve. Could not find `nonexistent` in `existent` +#[existent::nonexistent] //~ ERROR failed to resolve: could not find `nonexistent` in `existent` fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/custom-attribute-multisegment.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/custom-attribute-multisegment.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/custom-attribute-multisegment.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/custom-attribute-multisegment.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ -error[E0433]: failed to resolve. Could not find `nonexistent` in `existent` +error[E0433]: failed to resolve: could not find `nonexistent` in `existent` --> $DIR/custom-attribute-multisegment.rs:17:13 | -LL | #[existent::nonexistent] //~ ERROR failed to resolve. Could not find `nonexistent` in `existent` - | ^^^^^^^^^^^ Could not find `nonexistent` in `existent` +LL | #[existent::nonexistent] //~ ERROR failed to resolve: could not find `nonexistent` in `existent` + | ^^^^^^^^^^^ could not find `nonexistent` in `existent` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cycle-trait/cycle-trait-supertrait-direct.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/cycle-trait/cycle-trait-supertrait-direct.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cycle-trait/cycle-trait-supertrait-direct.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cycle-trait/cycle-trait-supertrait-direct.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ error[E0391]: cycle detected when computing the supertraits of `Chromosome` - --> $DIR/cycle-trait-supertrait-direct.rs:13:1 + --> $DIR/cycle-trait-supertrait-direct.rs:13:19 | LL | trait Chromosome: Chromosome { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ | = note: ...which again requires computing the supertraits of `Chromosome`, completing the cycle diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,20 +1,20 @@ error[E0391]: cycle detected when computing the supertraits of `B` - --> $DIR/cycle-trait-supertrait-indirect.rs:17:1 + --> $DIR/cycle-trait-supertrait-indirect.rs:17:10 | LL | trait B: C { - | ^^^^^^^^^^ + | ^ | note: ...which requires computing the supertraits of `C`... - --> $DIR/cycle-trait-supertrait-indirect.rs:21:1 + --> $DIR/cycle-trait-supertrait-indirect.rs:21:10 | LL | trait C: B { } - | ^^^^^^^^^^ + | ^ = note: ...which again requires computing the supertraits of `B`, completing the cycle note: cycle used when computing the supertraits of `A` - --> $DIR/cycle-trait-supertrait-indirect.rs:14:1 + --> $DIR/cycle-trait-supertrait-indirect.rs:14:10 | LL | trait A: B { - | ^^^^^^^^^^ + | ^ error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/dep-graph/dep-graph-struct-signature.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/dep-graph/dep-graph-struct-signature.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/dep-graph/dep-graph-struct-signature.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/dep-graph/dep-graph-struct-signature.rs 2018-12-04 23:41:40.000000000 +0000 @@ -88,7 +88,6 @@ } #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path - #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path fn b(x: WontChange) { } #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path from `WillChange` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/dep-graph/dep-graph-struct-signature.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/dep-graph/dep-graph-struct-signature.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/dep-graph/dep-graph-struct-signature.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/dep-graph/dep-graph-struct-signature.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -82,20 +82,14 @@ LL | #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: no path from `WillChange` to `TypeckTables` - --> $DIR/dep-graph-struct-signature.rs:91:5 - | -LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: no path from `WillChange` to `FnSignature` - --> $DIR/dep-graph-struct-signature.rs:94:5 + --> $DIR/dep-graph-struct-signature.rs:93:5 | LL | #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path from `WillChange` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: no path from `WillChange` to `TypeckTables` - --> $DIR/dep-graph-struct-signature.rs:95:5 + --> $DIR/dep-graph-struct-signature.rs:94:5 | LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path from `WillChange` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -136,5 +130,5 @@ LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 23 previous errors +error: aborting due to 22 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/derived-errors/issue-31997-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/derived-errors/issue-31997-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/derived-errors/issue-31997-1.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/derived-errors/issue-31997-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ -error[E0433]: failed to resolve. Use of undeclared type or module `HashMap` +error[E0433]: failed to resolve: use of undeclared type or module `HashMap` --> $DIR/issue-31997-1.rs:30:19 | LL | let mut map = HashMap::new(); - | ^^^^^^^ Use of undeclared type or module `HashMap` + | ^^^^^^^ use of undeclared type or module `HashMap` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/bad-assoc-ty.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/bad-assoc-ty.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/bad-assoc-ty.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/bad-assoc-ty.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -44,33 +44,25 @@ --> $DIR/bad-assoc-ty.rs:11:10 | LL | type A = [u8; 4]::AssocTy; - | ^^^^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<[u8; _] as Trait>::AssocTy` + | ^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<[u8; _] as Trait>::AssocTy` error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:15:10 | LL | type B = [u8]::AssocTy; - | ^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<[u8] as Trait>::AssocTy` + | ^^^^^^^^^^^^^ help: use fully-qualified syntax: `<[u8] as Trait>::AssocTy` error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:19:10 | LL | type C = (u8)::AssocTy; - | ^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `::AssocTy` + | ^^^^^^^^^^^^^ help: use fully-qualified syntax: `::AssocTy` error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:23:10 | LL | type D = (u8, u8)::AssocTy; - | ^^^^^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<(u8, u8) as Trait>::AssocTy` + | ^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(u8, u8) as Trait>::AssocTy` error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/bad-assoc-ty.rs:27:10 @@ -82,25 +74,19 @@ --> $DIR/bad-assoc-ty.rs:31:19 | LL | type F = &'static (u8)::AssocTy; - | ^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `::AssocTy` + | ^^^^^^^^^^^^^ help: use fully-qualified syntax: `::AssocTy` error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:37:10 | LL | type G = 'static + (Send)::AssocTy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<(dyn std::marker::Send + 'static) as Trait>::AssocTy` + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(dyn std::marker::Send + 'static) as Trait>::AssocTy` error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:43:10 | LL | type H = Fn(u8) -> (u8)::Output; - | ^^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<(dyn std::ops::Fn(u8) -> u8 + 'static) as Trait>::Output` + | ^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(dyn std::ops::Fn(u8) -> u8 + 'static) as Trait>::Output` error: aborting due to 15 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-31424.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-31424.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-31424.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-31424.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,15 +2,31 @@ --> $DIR/issue-31424.rs:17:9 | LL | (&mut self).bar(); //~ ERROR cannot borrow - | ^^^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^^^ + | | + | cannot borrow as mutable + | try removing `&mut` here -error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable - --> $DIR/issue-31424.rs:23:9 +warning: function cannot return without recursing + --> $DIR/issue-31424.rs:22:5 | LL | fn bar(self: &mut Self) { - | ---- help: consider changing this to be mutable: `mut self` + | ^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing +LL | //~^ WARN function cannot return without recursing +LL | (&mut self).bar(); //~ ERROR cannot borrow + | ----------------- recursive call site + | + = note: #[warn(unconditional_recursion)] on by default + = help: a `loop` may express intention better if this is on purpose + +error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable + --> $DIR/issue-31424.rs:24:9 + | LL | (&mut self).bar(); //~ ERROR cannot borrow - | ^^^^^^^^^^^ cannot borrow as mutable + | ^^^^^^^^^^^ + | | + | cannot borrow as mutable + | try removing `&mut` here error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-31424.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-31424.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-31424.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-31424.rs 2018-12-04 23:41:40.000000000 +0000 @@ -20,6 +20,7 @@ // In this case we could keep the suggestion, but to distinguish the // two cases is pretty hard. It's an obscure case anyway. fn bar(self: &mut Self) { + //~^ WARN function cannot return without recursing (&mut self).bar(); //~ ERROR cannot borrow } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-31424.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-31424.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-31424.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-31424.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,8 +7,20 @@ | cannot reborrow mutably | try removing `&mut` here +warning: function cannot return without recursing + --> $DIR/issue-31424.rs:22:5 + | +LL | fn bar(self: &mut Self) { + | ^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing +LL | //~^ WARN function cannot return without recursing +LL | (&mut self).bar(); //~ ERROR cannot borrow + | ----------------- recursive call site + | + = note: #[warn(unconditional_recursion)] on by default + = help: a `loop` may express intention better if this is on purpose + error[E0596]: cannot borrow immutable argument `self` as mutable - --> $DIR/issue-31424.rs:23:15 + --> $DIR/issue-31424.rs:24:15 | LL | (&mut self).bar(); //~ ERROR cannot borrow | ^^^^ cannot borrow mutably diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-34126.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-34126.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-34126.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-34126.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -11,11 +11,10 @@ --> $DIR/issue-34126.rs:16:18 | LL | self.run(&mut self); //~ ERROR cannot borrow - | ---------^^^^^^^^^- - | | | - | | mutable borrow occurs here + | ---- --- ^^^^^^^^^ mutable borrow occurs here + | | | + | | immutable borrow later used by call | immutable borrow occurs here - | borrow later used here error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-38147-2.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-38147-2.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-38147-2.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-38147-2.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,6 +1,9 @@ error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` reference --> $DIR/issue-38147-2.rs:17:9 | +LL | s: &'a String + | ---------- help: consider changing this to be mutable: `&'a mut String` +... LL | self.s.push('x'); | ^^^^^^ cannot borrow as mutable diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-38147-3.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-38147-3.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-38147-3.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-38147-3.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,6 +1,9 @@ error[E0596]: cannot borrow `*self.s` as mutable, as it is behind a `&` reference --> $DIR/issue-38147-3.rs:17:9 | +LL | s: &'a String + | ---------- help: consider changing this to be mutable: `&'a mut String` +... LL | self.s.push('x'); | ^^^^^^ cannot borrow as mutable diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-42764.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-42764.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-42764.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-42764.rs 2018-12-04 23:41:40.000000000 +0000 @@ -20,4 +20,20 @@ let n: usize = 42; this_function_expects_a_double_option(n); //~^ ERROR mismatched types + //~| HELP try using a variant of the expected type +} + + +// But don't issue the "try using a variant" help if the one-"variant" ADT is +// actually a one-field struct. + +struct Payload; + +struct Wrapper { payload: Payload } + +struct Context { wrapper: Wrapper } + +fn overton() { + let _c = Context { wrapper: Payload{} }; + //~^ ERROR mismatched types } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-42764.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-42764.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-42764.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-42764.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -13,6 +13,15 @@ LL | this_function_expects_a_double_option(DoubleOption::AlternativeSome(n)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +error[E0308]: mismatched types + --> $DIR/issue-42764.rs:37:33 + | +LL | let _c = Context { wrapper: Payload{} }; + | ^^^^^^^^^ expected struct `Wrapper`, found struct `Payload` + | + = note: expected type `Wrapper` + found type `Payload` + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0308`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-54109-and_instead_of_ampersands.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-54109-and_instead_of_ampersands.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-54109-and_instead_of_ampersands.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/issue-54109-and_instead_of_ampersands.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,16 +2,20 @@ --> $DIR/issue-54109-and_instead_of_ampersands.rs:14:10 | LL | if a and b { - | -- ^^^ help: use `&&` instead of `and` for the boolean operator - | | + | -- ^^^ + | | | + | | expected `{` + | | help: use `&&` instead of `and` for the boolean operator | this `if` statement has a condition, but no block error: expected `{`, found `or` --> $DIR/issue-54109-and_instead_of_ampersands.rs:23:10 | LL | if a or b { - | -- ^^ help: use `||` instead of `or` for the boolean operator - | | + | -- ^^ + | | | + | | expected `{` + | | help: use `||` instead of `or` for the boolean operator | this `if` statement has a condition, but no block error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an operator, found `and` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/match-refactor-to-expr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/match-refactor-to-expr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/match-refactor-to-expr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/match-refactor-to-expr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn main() { - let foo = - match - Some(4).unwrap_or_else(5) - //~^ NOTE expected one of `.`, `?`, `{`, or an operator here - ; //~ NOTE unexpected token - //~^ ERROR expected one of `.`, `?`, `{`, or an operator, found `;` - - println!("{}", foo) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/match-refactor-to-expr.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/match-refactor-to-expr.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/did_you_mean/match-refactor-to-expr.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/did_you_mean/match-refactor-to-expr.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -error: expected one of `.`, `?`, `{`, or an operator, found `;` - --> $DIR/match-refactor-to-expr.rs:18:9 - | -LL | match - | ----- help: try removing this `match` -LL | Some(4).unwrap_or_else(5) - | - expected one of `.`, `?`, `{`, or an operator here -LL | //~^ NOTE expected one of `.`, `?`, `{`, or an operator here -LL | ; //~ NOTE unexpected token - | ^ unexpected token - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/directory_ownership/mod_file_not_owning.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/directory_ownership/mod_file_not_owning.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/directory_ownership/mod_file_not_owning.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/directory_ownership/mod_file_not_owning.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: mod statements in non-mod.rs files are unstable - -mod mod_file_not_owning_aux1; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/directory_ownership/mod_file_not_owning.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/directory_ownership/mod_file_not_owning.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/directory_ownership/mod_file_not_owning.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/directory_ownership/mod_file_not_owning.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -error[E0658]: mod statements in non-mod.rs files are unstable (see issue #44660) - --> $DIR/mod_file_not_owning_aux1.rs:14:17 - | -LL | () => { mod mod_file_not_owning_aux2; } - | ^^^^^^^^^^^^^^^^^^^^^^^^ -LL | } -LL | m!(); - | ----- in this macro invocation - | - = help: add #![feature(non_modrs_mods)] to the crate attributes to enable - = help: on stable builds, rename this file to mod_file_not_owning_aux1/mod.rs - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/directory_ownership/unowned_mod_with_path.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/directory_ownership/unowned_mod_with_path.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/directory_ownership/unowned_mod_with_path.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/directory_ownership/unowned_mod_with_path.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: mod statements in non-mod.rs files are unstable - -// This is not a directory owner since the file name is not "mod.rs". -#[path = "mod_file_not_owning_aux1.rs"] -mod foo; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/directory_ownership/unowned_mod_with_path.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/directory_ownership/unowned_mod_with_path.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/directory_ownership/unowned_mod_with_path.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/directory_ownership/unowned_mod_with_path.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -error[E0658]: mod statements in non-mod.rs files are unstable (see issue #44660) - --> $DIR/mod_file_not_owning_aux1.rs:14:17 - | -LL | () => { mod mod_file_not_owning_aux2; } - | ^^^^^^^^^^^^^^^^^^^^^^^^ -LL | } -LL | m!(); - | ----- in this macro invocation - | - = help: add #![feature(non_modrs_mods)] to the crate attributes to enable - = help: on stable builds, rename this file to foo/mod.rs - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/dollar-crate/dollar-crate-is-keyword-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/dollar-crate/dollar-crate-is-keyword-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/dollar-crate/dollar-crate-is-keyword-2.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/dollar-crate/dollar-crate-is-keyword-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ -error[E0433]: failed to resolve. `$crate` in paths can only be used in start position +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position --> $DIR/dollar-crate-is-keyword-2.rs:16:16 | LL | use a::$crate::b; //~ ERROR `$crate` in paths can only be used in start position @@ -16,7 +16,7 @@ LL | m!(); | ----- in this macro invocation -error[E0433]: failed to resolve. `$crate` in paths can only be used in start position +error[E0433]: failed to resolve: `$crate` in paths can only be used in start position --> $DIR/dollar-crate-is-keyword-2.rs:17:21 | LL | type A = a::$crate; //~ ERROR `$crate` in paths can only be used in start position diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/double-import.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/double-import.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/double-import.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/double-import.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^^^^^^^^ `foo` reimported 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 +help: you can use `as` to change the binding name of the import | LL | use sub2::foo as other_foo; //~ ERROR the name `foo` is defined multiple times | ^^^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/double-type-import.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/double-type-import.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/double-type-import.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/double-type-import.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^^^^^^^^^^^ `X` reimported here | = note: `X` 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 +help: you can use `as` to change the binding name of the import | LL | use self::bar::X as OtherX; | ^^^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/dropck/dropck-eyepatch-extern-crate.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/dropck/dropck-eyepatch-extern-crate.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/dropck/dropck-eyepatch-extern-crate.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/dropck/dropck-eyepatch-extern-crate.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | - | | | `c_shortest` dropped here while still borrowed - | borrow later used here, when `dt` is dropped + | borrow might be used here, when `dt` is dropped and runs the `Drop` code for type `other::Dt` | = note: values in a scope are dropped in the opposite order they are defined diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/dropck/dropck-eyepatch.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/dropck/dropck-eyepatch.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/dropck/dropck-eyepatch.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/dropck/dropck-eyepatch.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | - | | | `c_shortest` dropped here while still borrowed - | borrow later used here, when `dt` is dropped + | borrow might be used here, when `dt` is dropped and runs the `Drop` code for type `Dt` | = note: values in a scope are dropped in the opposite order they are defined diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/dropck/dropck-eyepatch-reorder.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/dropck/dropck-eyepatch-reorder.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/dropck/dropck-eyepatch-reorder.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/dropck/dropck-eyepatch-reorder.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | - | | | `c_shortest` dropped here while still borrowed - | borrow later used here, when `dt` is dropped + | borrow might be used here, when `dt` is dropped and runs the `Drop` code for type `Dt` | = note: values in a scope are dropped in the opposite order they are defined diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/dropck/dropck_trait_cycle_checked.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/dropck/dropck_trait_cycle_checked.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/dropck/dropck_trait_cycle_checked.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/dropck/dropck_trait_cycle_checked.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,67 +1,72 @@ error[E0597]: `o2` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:121:13 | +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o2` is borrowed for `'static` LL | o1.set0(&o2); //~ ERROR `o2` does not live long enough | ^^^ borrowed value does not live long enough ... LL | } | - `o2` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error[E0597]: `o3` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:122:13 | +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o3` is borrowed for `'static` +LL | o1.set0(&o2); //~ ERROR `o2` does not live long enough LL | o1.set1(&o3); //~ ERROR `o3` does not live long enough | ^^^ borrowed value does not live long enough ... LL | } | - `o3` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error[E0597]: `o2` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:123:13 | +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o2` is borrowed for `'static` +... LL | o2.set0(&o2); //~ ERROR `o2` does not live long enough | ^^^ borrowed value does not live long enough ... LL | } | - `o2` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error[E0597]: `o3` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:124:13 | +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o3` is borrowed for `'static` +... LL | o2.set1(&o3); //~ ERROR `o3` does not live long enough | ^^^ borrowed value does not live long enough ... LL | } | - `o3` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error[E0597]: `o1` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:125:13 | +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o1` is borrowed for `'static` +... LL | o3.set0(&o1); //~ ERROR `o1` does not live long enough | ^^^ borrowed value does not live long enough LL | o3.set1(&o2); //~ ERROR `o2` does not live long enough LL | } | - `o1` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error[E0597]: `o2` does not live long enough --> $DIR/dropck_trait_cycle_checked.rs:126:13 | +LL | let (o1, o2, o3): (Box, Box, Box) = (O::new(), O::new(), O::new()); + | -------- cast requires that `o2` is borrowed for `'static` +... LL | o3.set1(&o2); //~ ERROR `o2` does not live long enough | ^^^ borrowed value does not live long enough LL | } | - `o2` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error: aborting due to 6 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/dropck/dropck-union.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/dropck/dropck-union.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/dropck/dropck-union.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/dropck/dropck-union.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,9 +7,7 @@ | - | | | `v` dropped here while still borrowed - | borrow later used here, when `v` is dropped - | - = note: values in a scope are dropped in the opposite order they are defined + | borrow might be used here, when `v` is dropped and runs the `Drop` code for type `Wrap` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/dropck/drop-with-active-borrows-2.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/dropck/drop-with-active-borrows-2.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/dropck/drop-with-active-borrows-2.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/dropck/drop-with-active-borrows-2.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,18 +1,12 @@ -error[E0597]: `raw_lines` does not live long enough +error[E0515]: cannot return value referencing local variable `raw_lines` --> $DIR/drop-with-active-borrows-2.rs:13:5 | LL | raw_lines.iter().map(|l| l.trim()).collect() - | ^^^^^^^^^ borrowed value does not live long enough -LL | //~^ ERROR `raw_lines` does not live long enough -LL | } - | - `raw_lines` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 11:24... - --> $DIR/drop-with-active-borrows-2.rs:11:24 - | -LL | fn read_lines_borrowed<'a>() -> Vec<&'a str> { - | ^^ + | ---------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | returns a value referencing data owned by the current function + | `raw_lines` is borrowed here error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/dst/dst-bad-coerce3.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/dst/dst-bad-coerce3.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/dst/dst-bad-coerce3.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/dst/dst-bad-coerce3.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,62 +1,57 @@ error[E0597]: `f1` does not live long enough --> $DIR/dst-bad-coerce3.rs:26:32 | +LL | fn baz<'a>() { + | -- lifetime `'a` defined here +... LL | let f2: &Fat<[isize; 3]> = &f1; //~ ERROR `f1` does not live long enough | ^^^ borrowed value does not live long enough +LL | let f3: &'a Fat<[isize]> = f2; + | ---------------- type annotation requires that `f1` is borrowed for `'a` ... LL | } | - `f1` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 23:8... - --> $DIR/dst-bad-coerce3.rs:23:8 - | -LL | fn baz<'a>() { - | ^^ error[E0597]: `f1` does not live long enough --> $DIR/dst-bad-coerce3.rs:31:25 | +LL | fn baz<'a>() { + | -- lifetime `'a` defined here +... LL | let f2: &Fat = &f1; //~ ERROR `f1` does not live long enough | ^^^ borrowed value does not live long enough +LL | let f3: &'a Fat = f2; + | ------------ type annotation requires that `f1` is borrowed for `'a` ... LL | } | - `f1` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 23:8... - --> $DIR/dst-bad-coerce3.rs:23:8 - | -LL | fn baz<'a>() { - | ^^ error[E0597]: `f1` does not live long enough --> $DIR/dst-bad-coerce3.rs:36:30 | +LL | fn baz<'a>() { + | -- lifetime `'a` defined here +... LL | let f2: &([isize; 3],) = &f1; //~ ERROR `f1` does not live long enough | ^^^ borrowed value does not live long enough +LL | let f3: &'a ([isize],) = f2; + | -------------- type annotation requires that `f1` is borrowed for `'a` ... LL | } | - `f1` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 23:8... - --> $DIR/dst-bad-coerce3.rs:23:8 - | -LL | fn baz<'a>() { - | ^^ error[E0597]: `f1` does not live long enough --> $DIR/dst-bad-coerce3.rs:41:23 | +LL | fn baz<'a>() { + | -- lifetime `'a` defined here +... LL | let f2: &(Foo,) = &f1; //~ ERROR `f1` does not live long enough | ^^^ borrowed value does not live long enough LL | let f3: &'a (Bar,) = f2; + | ---------- type annotation requires that `f1` is borrowed for `'a` LL | } | - `f1` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 23:8... - --> $DIR/dst-bad-coerce3.rs:23:8 - | -LL | fn baz<'a>() { - | ^^ error: aborting due to 4 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/dst/dst-index.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/dst/dst-index.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/dst/dst-index.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/dst/dst-index.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -16,13 +16,31 @@ LL | S[0]; | ^^^^ cannot move out of borrowed content +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/dst-index.rs:41:5 + | +LL | S[0]; + | ^^^^ + | | + | cannot move out of data in a `&` reference + | cannot move + error[E0507]: cannot move out of borrowed content --> $DIR/dst-index.rs:44:5 | LL | T[0]; | ^^^^ cannot move out of borrowed content -error: aborting due to 4 previous errors +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/dst-index.rs:44:5 + | +LL | T[0]; + | ^^^^ + | | + | cannot move out of data in a `&` reference + | cannot move + +error: aborting due to 6 previous errors Some errors occurred: E0161, E0507. For more information about an error, try `rustc --explain E0161`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/dst/dst-rvalue.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/dst/dst-rvalue.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/dst/dst-rvalue.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/dst/dst-rvalue.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -16,13 +16,33 @@ LL | let _x: Box = box *"hello world"; | ^^^^^^^^^^^^^^ cannot move out of borrowed content +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/dst-rvalue.rs:16:28 + | +LL | let _x: Box = box *"hello world"; + | ^^^^^^^^^^^^^^ + | | + | cannot move out of data in a `&` reference + | cannot move + error[E0508]: cannot move out of type `[isize]`, a non-copy slice --> $DIR/dst-rvalue.rs:21:32 | LL | let _x: Box<[isize]> = box *array; | ^^^^^^ cannot move out of here -error: aborting due to 4 previous errors +error[E0507]: cannot move out of `*array` which is behind a `&` reference + --> $DIR/dst-rvalue.rs:21:32 + | +LL | let array: &[isize] = &[1, 2, 3]; + | ---------- help: consider changing this to be a mutable reference: `&mut [1, 2, 3]` +LL | let _x: Box<[isize]> = box *array; + | ^^^^^^ + | | + | cannot move out of `*array` which is behind a `&` reference + | `array` is a `&` reference, so the data it refers to cannot be moved + +error: aborting due to 6 previous errors Some errors occurred: E0161, E0507, E0508. For more information about an error, try `rustc --explain E0161`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/duplicate/duplicate-check-macro-exports.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/duplicate/duplicate-check-macro-exports.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/duplicate/duplicate-check-macro-exports.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/duplicate/duplicate-check-macro-exports.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | ^^^^^^^^^^^^^^^^^^ `panic` redefined here | = note: `panic` must be defined only once in the macro namespace of this module -help: You can use `as` to change the binding name of the import +help: you can use `as` to change the binding name of the import | LL | pub use std::panic as other_panic; | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/dyn-trait-compatibility.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/dyn-trait-compatibility.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/dyn-trait-compatibility.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/dyn-trait-compatibility.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ type A0 = dyn; //~^ ERROR cannot find type `dyn` in this scope type A1 = dyn::dyn; -//~^ ERROR Use of undeclared type or module `dyn` +//~^ ERROR use of undeclared type or module `dyn` type A2 = dyn; //~^ ERROR cannot find type `dyn` in this scope //~| ERROR cannot find type `dyn` in this scope @@ -19,6 +19,6 @@ type A3 = dyn<::dyn>; //~^ ERROR cannot find type `dyn` in this scope //~| ERROR cannot find type `dyn` in this scope -//~| ERROR Use of undeclared type or module `dyn` +//~| ERROR use of undeclared type or module `dyn` fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/dyn-trait-compatibility.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/dyn-trait-compatibility.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/dyn-trait-compatibility.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/dyn-trait-compatibility.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,14 +1,14 @@ -error[E0433]: failed to resolve. Use of undeclared type or module `dyn` +error[E0433]: failed to resolve: use of undeclared type or module `dyn` --> $DIR/dyn-trait-compatibility.rs:13:11 | LL | type A1 = dyn::dyn; - | ^^^ Use of undeclared type or module `dyn` + | ^^^ use of undeclared type or module `dyn` -error[E0433]: failed to resolve. Use of undeclared type or module `dyn` +error[E0433]: failed to resolve: use of undeclared type or module `dyn` --> $DIR/dyn-trait-compatibility.rs:19:23 | LL | type A3 = dyn<::dyn>; - | ^^^ Use of undeclared type or module `dyn` + | ^^^ use of undeclared type or module `dyn` error[E0412]: cannot find type `dyn` in this scope --> $DIR/dyn-trait-compatibility.rs:11:11 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/e0119/issue-28981.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/e0119/issue-28981.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/e0119/issue-28981.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/e0119/issue-28981.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -5,7 +5,7 @@ | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: conflicting implementation in crate `core`: - - impl<'a, T> std::ops::Deref for &'a T + - impl<'_, T> std::ops::Deref for &T where T: ?Sized; error[E0210]: type parameter `Foo` must be used as the type parameter for some local type (e.g. `MyStruct`) diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/E0501.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/E0501.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/E0501.ast.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/E0501.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,7 @@ | ^ borrow occurs here ... LL | drop(bar); - | --- borrow later used here + | --- first borrow later used here error[E0501]: cannot borrow `*a` as immutable because previous closure requires unique access --> $DIR/E0501.rs:31:23 @@ -24,7 +24,7 @@ | ^ borrow occurs here ... LL | drop(bar); - | --- borrow later used here + | --- first borrow later used here error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/E0501.mir.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/E0501.mir.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/E0501.mir.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/E0501.mir.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,7 @@ | ^ borrow occurs here ... LL | drop(bar); - | --- borrow later used here + | --- first borrow later used here error[E0501]: cannot borrow `*a` as immutable because previous closure requires unique access --> $DIR/E0501.rs:31:23 @@ -24,7 +24,7 @@ | ^ borrow occurs here ... LL | drop(bar); - | --- borrow later used here + | --- first borrow later used here error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/E0705.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/E0705.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/E0705.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/E0705.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,8 +10,11 @@ // compile-pass -#![feature(impl_header_lifetime_elision)] -//~^ WARN the feature `impl_header_lifetime_elision` is included in the Rust 2018 edition +// This is a stub feature that doesn't control anything, so to make tidy happy, +// gate-test-test_2018_feature + +#![feature(test_2018_feature)] +//~^ WARN the feature `test_2018_feature` is included in the Rust 2018 edition #![feature(rust_2018_preview)] fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/E0705.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/E0705.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/E0705.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/E0705.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,6 +1,6 @@ -warning[E0705]: the feature `impl_header_lifetime_elision` is included in the Rust 2018 edition - --> $DIR/E0705.rs:13:12 +warning[E0705]: the feature `test_2018_feature` is included in the Rust 2018 edition + --> $DIR/E0705.rs:16:12 | -LL | #![feature(impl_header_lifetime_elision)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![feature(test_2018_feature)] + | ^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/auxiliary/absolute.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/auxiliary/absolute.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/auxiliary/absolute.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/auxiliary/absolute.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1 @@ +pub struct Path; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/auxiliary/edition-imports-2015.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/auxiliary/edition-imports-2015.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/auxiliary/edition-imports-2015.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/auxiliary/edition-imports-2015.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// edition:2015 + +#[macro_export] +macro_rules! gen_imports { () => { + use import::Path; + use std::collections::LinkedList; + + fn check_absolute() { + ::absolute::Path; + ::std::collections::LinkedList::::new(); + } +}} + +#[macro_export] +macro_rules! gen_glob { () => { + use *; +}} + +#[macro_export] +macro_rules! gen_gated { () => { + fn check_gated() { + enum E { A } + use E::*; + } +}} + +#[macro_export] +macro_rules! gen_ambiguous { () => { + use Ambiguous; + type A = ::edition_imports_2015::Path; +}} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/auxiliary/edition-imports-2018.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/auxiliary/edition-imports-2018.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/auxiliary/edition-imports-2018.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/auxiliary/edition-imports-2018.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// edition:2018 + +#[macro_export] +macro_rules! gen_imports { () => { + use import::Path; + use std::collections::LinkedList; + + fn check_absolute() { + ::absolute::Path; + ::std::collections::LinkedList::::new(); + } +}} + +#[macro_export] +macro_rules! gen_glob { () => { + use *; +}} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/edition-deny-overflowing-literals-2018.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/edition-deny-overflowing-literals-2018.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/edition-deny-overflowing-literals-2018.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/edition-deny-overflowing-literals-2018.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// edition:2018 + +fn main() { + let x: u8 = 256; + //~^ error: literal out of range for u8 +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/edition-deny-overflowing-literals-2018.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/edition-deny-overflowing-literals-2018.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/edition-deny-overflowing-literals-2018.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/edition-deny-overflowing-literals-2018.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: literal out of range for u8 + --> $DIR/edition-deny-overflowing-literals-2018.rs:14:17 + | +LL | let x: u8 = 256; + | ^^^ + | + = note: #[deny(overflowing_literals)] on by default + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/edition-imports-2015.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/edition-imports-2015.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/edition-imports-2015.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/edition-imports-2015.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// edition:2015 +// compile-flags:--extern absolute +// aux-build:edition-imports-2018.rs +// aux-build:absolute.rs + +#![feature(uniform_paths)] + +#[macro_use] +extern crate edition_imports_2018; + +mod check { + mod import { + pub struct Path; + } + + gen_imports!(); // OK + + fn check() { + Path; + LinkedList::::new(); + } +} + +mod check_glob { + gen_glob!(); //~ ERROR cannot glob-import all possible crates +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/edition-imports-2015.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/edition-imports-2015.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/edition-imports-2015.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/edition-imports-2015.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: cannot glob-import all possible crates + --> $DIR/edition-imports-2015.rs:25:5 + | +LL | gen_glob!(); //~ ERROR cannot glob-import all possible crates + | ^^^^^^^^^^^^ + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/edition-imports-2018.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/edition-imports-2018.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/edition-imports-2018.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/edition-imports-2018.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// edition:2018 +// aux-build:edition-imports-2015.rs + +#[macro_use] +extern crate edition_imports_2015; + +mod import { + pub struct Path; +} +mod absolute { + pub struct Path; +} + +mod check { + gen_imports!(); // OK + + fn check() { + Path; + LinkedList::::new(); + } +} + +mod check_glob { + gen_glob!(); //~ ERROR cannot glob-import all possible crates +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/edition-imports-2018.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/edition-imports-2018.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/edition-imports-2018.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/edition-imports-2018.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: cannot glob-import all possible crates + --> $DIR/edition-imports-2018.rs:24:5 + | +LL | gen_glob!(); //~ ERROR cannot glob-import all possible crates + | ^^^^^^^^^^^^ + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/edition-imports-virtual-2015-ambiguity.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/edition-imports-virtual-2015-ambiguity.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/edition-imports-virtual-2015-ambiguity.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/edition-imports-virtual-2015-ambiguity.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// edition:2018 +// compile-flags:--extern edition_imports_2015 +// aux-build:edition-imports-2015.rs + +mod edition_imports_2015 { + pub struct Path; +} + +pub struct Ambiguous {} + +mod check { + pub struct Ambiguous {} + + fn check() { + edition_imports_2015::gen_ambiguous!(); //~ ERROR `Ambiguous` is ambiguous + //~| ERROR `edition_imports_2015` is ambiguous + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/edition-imports-virtual-2015-ambiguity.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/edition-imports-virtual-2015-ambiguity.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/edition-imports-virtual-2015-ambiguity.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/edition-imports-virtual-2015-ambiguity.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +error[E0659]: `Ambiguous` is ambiguous (name vs any other name during import resolution) + --> $DIR/edition-imports-virtual-2015-ambiguity.rs:15:9 + | +LL | edition_imports_2015::gen_ambiguous!(); //~ ERROR `Ambiguous` is ambiguous + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ambiguous name + | +note: `Ambiguous` could refer to the struct defined here + --> $DIR/edition-imports-virtual-2015-ambiguity.rs:9:1 + | +LL | pub struct Ambiguous {} + | ^^^^^^^^^^^^^^^^^^^^^^^ + = help: use `crate::Ambiguous` to refer to this struct unambiguously +note: `Ambiguous` could also refer to the struct defined here + --> $DIR/edition-imports-virtual-2015-ambiguity.rs:12:5 + | +LL | pub struct Ambiguous {} + | ^^^^^^^^^^^^^^^^^^^^^^^ + = help: use `self::Ambiguous` to refer to this struct unambiguously + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error[E0659]: `edition_imports_2015` is ambiguous (name in the crate root vs extern crate during absolute path resolution) + --> $DIR/edition-imports-virtual-2015-ambiguity.rs:15:9 + | +LL | edition_imports_2015::gen_ambiguous!(); //~ ERROR `Ambiguous` is ambiguous + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ambiguous name + | + = note: `edition_imports_2015` could refer to an extern crate passed with `--extern` +note: `edition_imports_2015` could also refer to the module defined here + --> $DIR/edition-imports-virtual-2015-ambiguity.rs:5:1 + | +LL | / mod edition_imports_2015 { +LL | | pub struct Path; +LL | | } + | |_^ + = help: use `crate::edition_imports_2015` to refer to this module unambiguously + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0659`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/edition-imports-virtual-2015-gated.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/edition-imports-virtual-2015-gated.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/edition-imports-virtual-2015-gated.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/edition-imports-virtual-2015-gated.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +// edition:2018 +// aux-build:edition-imports-2015.rs +// error-pattern: imports can only refer to extern crate names passed with `--extern` + +#[macro_use] +extern crate edition_imports_2015; + +mod check { + gen_gated!(); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/edition-imports-virtual-2015-gated.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/edition-imports-virtual-2015-gated.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/editions/edition-imports-virtual-2015-gated.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/editions/edition-imports-virtual-2015-gated.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +error[E0658]: imports can only refer to extern crate names passed with `--extern` on stable channel (see issue #53130) + --> <::edition_imports_2015::gen_gated macros>:1:50 + | +LL | ( ) => { fn check_gated ( ) { enum E { A } use E :: * ; } } + | ^ + | + ::: $DIR/edition-imports-virtual-2015-gated.rs:9:5 + | +LL | gen_gated!(); + | ------------- not an extern crate passed with `--extern` + | + = help: add #![feature(uniform_paths)] to the crate attributes to enable +note: this import refers to the enum defined here + --> $DIR/edition-imports-virtual-2015-gated.rs:9:5 + | +LL | gen_gated!(); + | ^^^^^^^^^^^^^ + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/empty/empty-struct-tuple-pat.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/empty/empty-struct-tuple-pat.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/empty/empty-struct-tuple-pat.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/empty/empty-struct-tuple-pat.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/empty-struct-tuple-pat.rs:32:9 | LL | struct Empty2(); - | ---------------- a tuple struct `Empty2` is defined here + | ---------------- the tuple struct `Empty2` is defined here ... LL | Empty2 => () //~ ERROR match bindings cannot shadow tuple structs | ^^^^^^ cannot be named the same as a tuple struct @@ -11,7 +11,7 @@ --> $DIR/empty-struct-tuple-pat.rs:35:9 | LL | use empty_struct::*; - | --------------- a tuple struct `XEmpty6` is imported here + | --------------- the tuple struct `XEmpty6` is imported here ... LL | XEmpty6 => () //~ ERROR match bindings cannot shadow tuple structs | ^^^^^^^ cannot be named the same as a tuple struct diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/enum/enum-in-scope.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/enum/enum-in-scope.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/enum/enum-in-scope.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/enum/enum-in-scope.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/enum-in-scope.rs:14:9 | LL | struct hello(isize); - | -------------------- a tuple struct `hello` is defined here + | -------------------- the tuple struct `hello` is defined here ... LL | let hello = 0; //~ERROR let bindings cannot shadow tuple structs | ^^^^^ cannot be named the same as a tuple struct diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0008.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0008.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0008.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0008.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0008]: cannot bind by-move into a pattern guard + --> $DIR/E0008.rs:13:14 + | +LL | Some(s) if s.len() == 0 => {}, + | ^ moves value into pattern guard + | + = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0008`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0152.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0152.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0152.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0152.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,7 @@ #![feature(lang_items)] -#[lang = "panic_impl"] +#[lang = "arc"] struct Foo; //~ ERROR E0152 fn main() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0152.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0152.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0152.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0152.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,10 +1,10 @@ -error[E0152]: duplicate lang item found: `panic_impl`. +error[E0152]: duplicate lang item found: `arc`. --> $DIR/E0152.rs:14:1 | LL | struct Foo; //~ ERROR E0152 | ^^^^^^^^^^^ | - = note: first defined in crate `std`. + = note: first defined in crate `alloc`. error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0223.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0223.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0223.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0223.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,9 +2,7 @@ --> $DIR/E0223.rs:14:14 | LL | let foo: MyTrait::X; - | ^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `::X` + | ^^^^^^^^^^ help: use fully-qualified syntax: `::X` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0252.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0252.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0252.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0252.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^^^^^^^ `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 +help: you can use `as` to change the binding name of the import | LL | use bar::baz as other_baz; //~ ERROR E0252 | ^^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0254.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0254.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0254.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0254.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | ^^^^^^^^^^ `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 +help: you can use `as` to change the binding name of the import | LL | use foo::alloc as other_alloc; | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0255.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0255.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0255.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0255.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | ^^^^^^^^ `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 +help: you can use `as` to change the binding name of the import | LL | use bar::foo as other_foo; | ^^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0259.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0259.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0259.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0259.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -5,12 +5,13 @@ | ------------------- previous import of the extern crate `alloc` here LL | LL | extern crate libc as alloc; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | `alloc` reimported here - | You can use `as` to change the binding name of the import + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `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 + | +LL | extern crate libc as other_alloc; + | error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0260.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0260.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0260.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0260.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | ^^^^^^^^^ `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 +help: you can use `as` to change the binding name of the import | LL | extern crate alloc as other_alloc; | diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0277.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0277.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0277.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0277.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/E0277.rs:23:6 | LL | fn f(p: Path) { } - | ^ doesn't have a size known at compile-time + | ^ borrow the `Path` instead | = help: within `std::path::Path`, the trait `std::marker::Sized` is not implemented for `[u8]` = note: to learn more, visit diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0301.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0301.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0301.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0301.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0301]: cannot mutably borrow in a pattern guard + --> $DIR/E0301.rs:14:19 + | +LL | option if option.take().is_none() => {}, //~ ERROR E0301 + | ^^^^^^ borrowed mutably in pattern guard + | + = help: add #![feature(bind_by_move_pattern_guards)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0301`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0424.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0424.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0424.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0424.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/E0424.rs:17:9 | LL | self.bar(); //~ ERROR E0424 - | ^^^^ `self` value is only available in methods with `self` parameter + | ^^^^ `self` value is a keyword only available in methods with `self` parameter error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0430.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0430.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0430.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0430.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -15,7 +15,7 @@ | 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 +help: you can use `as` to change the binding name of the import | LL | use std::fmt::{self, self as other_fmt}; //~ ERROR E0430 | ^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0432.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0432.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0432.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0432.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/E0432.rs:11:5 | LL | use something::Foo; //~ ERROR E0432 - | ^^^^^^^^^ Maybe a missing `extern crate something;`? + | ^^^^^^^^^ maybe a missing `extern crate something;`? error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0433.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0433.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0433.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0433.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ -error[E0433]: failed to resolve. Use of undeclared type or module `HashMap` +error[E0433]: failed to resolve: use of undeclared type or module `HashMap` --> $DIR/E0433.rs:12:15 | LL | let map = HashMap::new(); //~ ERROR E0433 - | ^^^^^^^ Use of undeclared type or module `HashMap` + | ^^^^^^^ use of undeclared type or module `HashMap` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0499.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0499.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0499.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0499.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^^^^^ second mutable borrow occurs here LL | a.use_mut(); LL | x.use_mut(); - | - borrow later used here + | - first borrow later used here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0502.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0502.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0502.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0502.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -6,7 +6,7 @@ LL | bar(a); //~ ERROR E0502 | ^^^^^^ mutable borrow occurs here LL | y.use_ref(); - | - borrow later used here + | - immutable borrow later used here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0507.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0507.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0507.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0507.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/E0507.rs:22:5 + | +LL | x.borrow().nothing_is_true(); //~ ERROR E0507 + | ^^^^^^^^^^ cannot move out of borrowed content + +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/E0507.rs:22:5 + | +LL | x.borrow().nothing_is_true(); //~ ERROR E0507 + | ^^^^^^^^^^ + | | + | cannot move out of data in a `&` reference + | cannot move + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0530.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0530.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0530.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0530.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/E0530.rs:16:9 | LL | static TEST: i32 = 0; - | --------------------- a static `TEST` is defined here + | --------------------- the static `TEST` is defined here ... LL | TEST => {} //~ ERROR E0530 | ^^^^ cannot be named the same as a static diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0597.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0597.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0597.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0597.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | - | | | `y` dropped here while still borrowed - | borrow later used here, when `x` is dropped + | borrow might be used here, when `x` is dropped and runs the `Drop` code for type `Foo` | = note: values in a scope are dropped in the opposite order they are defined diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0603.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0603.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0603.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0603.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ error[E0603]: constant `PRIVATE` is private - --> $DIR/E0603.rs:16:5 + --> $DIR/E0603.rs:16:17 | LL | SomeModule::PRIVATE; //~ ERROR E0603 - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^ error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/E0621-does-not-trigger-for-closures.rs:25:45 - | -LL | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495 - | -- ^ returning this value requires that `'1` must outlive `'2` - | || - | |return type of closure is &'2 i32 - | has type `&'1 i32` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0637.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0637.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0637.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0637.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,11 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct Foo<'a: '_>(&'a u8); //~ ERROR invalid lifetime bound name: `'_` -fn foo<'a: '_>(_: &'a u8) {} //~ ERROR invalid lifetime bound name: `'_` +struct Foo<'a: '_>(&'a u8); //~ ERROR cannot be used here +fn foo<'a: '_>(_: &'a u8) {} //~ ERROR cannot be used here struct Bar<'a>(&'a u8); -impl<'a: '_> Bar<'a> { //~ ERROR invalid lifetime bound name: `'_` +impl<'a: '_> Bar<'a> { //~ ERROR cannot be used here fn bar() {} } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0637.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0637.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0637.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0637.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,19 +1,19 @@ -error[E0637]: invalid lifetime bound name: `'_` +error[E0637]: `'_` cannot be used here --> $DIR/E0637.rs:11:16 | -LL | struct Foo<'a: '_>(&'a u8); //~ ERROR invalid lifetime bound name: `'_` +LL | struct Foo<'a: '_>(&'a u8); //~ ERROR cannot be used here | ^^ `'_` is a reserved lifetime name -error[E0637]: invalid lifetime bound name: `'_` +error[E0637]: `'_` cannot be used here --> $DIR/E0637.rs:12:12 | -LL | fn foo<'a: '_>(_: &'a u8) {} //~ ERROR invalid lifetime bound name: `'_` +LL | fn foo<'a: '_>(_: &'a u8) {} //~ ERROR cannot be used here | ^^ `'_` is a reserved lifetime name -error[E0637]: invalid lifetime bound name: `'_` +error[E0637]: `'_` cannot be used here --> $DIR/E0637.rs:15:10 | -LL | impl<'a: '_> Bar<'a> { //~ ERROR invalid lifetime bound name: `'_` +LL | impl<'a: '_> Bar<'a> { //~ ERROR cannot be used here | ^^ `'_` is a reserved lifetime name error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0659.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0659.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0659.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0659.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,20 +1,21 @@ -error[E0659]: `foo` is ambiguous +error[E0659]: `foo` is ambiguous (glob import vs glob import in the same module) --> $DIR/E0659.rs:25:15 | LL | collider::foo(); //~ ERROR E0659 | ^^^ ambiguous name | -note: `foo` could refer to the name imported here +note: `foo` could refer to the function imported here --> $DIR/E0659.rs:20:13 | LL | pub use moon::*; | ^^^^^^^ -note: `foo` could also refer to the name imported here + = help: consider adding an explicit import of `foo` to disambiguate +note: `foo` could also refer to the function imported here --> $DIR/E0659.rs:21:13 | LL | pub use earth::*; | ^^^^^^^^ - = note: consider adding an explicit import of `foo` to disambiguate + = help: consider adding an explicit import of `foo` to disambiguate error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0718.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0718.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0718.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0718.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(lang_items)] + +// Arc is expected to be a struct, so this will error. +#[lang = "arc"] +static X: u32 = 42; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0718.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0718.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-codes/E0718.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-codes/E0718.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0718]: `arc` language item must be applied to a struct + --> $DIR/E0718.rs:14:1 + | +LL | #[lang = "arc"] + | ^^^^^^^^^^^^^^^ attribute should be applied to a struct, not a static item + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0718`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/error-festival.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/error-festival.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/error-festival.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/error-festival.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -5,10 +5,10 @@ | ^ did you mean `x`? error[E0603]: constant `FOO` is private - --> $DIR/error-festival.rs:32:5 + --> $DIR/error-festival.rs:32:10 | LL | foo::FOO; - | ^^^^^^^^ + | ^^^ error[E0368]: binary assignment operation `+=` cannot be applied to type `&str` --> $DIR/error-festival.rs:22:5 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/existential_types/generic_type_does_not_live_long_enough.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/existential_types/generic_type_does_not_live_long_enough.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/existential_types/generic_type_does_not_live_long_enough.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/existential_types/generic_type_does_not_live_long_enough.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/generic_type_does_not_live_long_enough.rs:16:18 - | -LL | let z: i32 = x; //~ ERROR mismatched types - | ^ expected i32, found opaque type - | - = note: expected type `i32` - found type `WrongGeneric::<&{integer}>` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/export2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/export2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/export2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/export2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,7 +9,7 @@ // except according to those terms. mod foo { - pub fn x() { bar::x(); } //~ ERROR failed to resolve. Use of undeclared type or module `bar` + pub fn x() { bar::x(); } //~ ERROR failed to resolve: use of undeclared type or module `bar` } mod bar { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/export2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/export2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/export2.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/export2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ -error[E0433]: failed to resolve. Use of undeclared type or module `bar` +error[E0433]: failed to resolve: use of undeclared type or module `bar` --> $DIR/export2.rs:12:18 | -LL | pub fn x() { bar::x(); } //~ ERROR failed to resolve. Use of undeclared type or module `bar` - | ^^^ Use of undeclared type or module `bar` +LL | pub fn x() { bar::x(); } //~ ERROR failed to resolve: use of undeclared type or module `bar` + | ^^^ use of undeclared type or module `bar` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/export-fully-qualified.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/export-fully-qualified.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/export-fully-qualified.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/export-fully-qualified.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,7 +13,7 @@ // want to change eventually. mod foo { - pub fn bar() { foo::baz(); } //~ ERROR failed to resolve. Use of undeclared type or module `foo` + pub fn bar() { foo::baz(); } //~ ERROR failed to resolve: use of undeclared type or module `foo` fn baz() { } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/export-fully-qualified.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/export-fully-qualified.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/export-fully-qualified.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/export-fully-qualified.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ -error[E0433]: failed to resolve. Use of undeclared type or module `foo` +error[E0433]: failed to resolve: use of undeclared type or module `foo` --> $DIR/export-fully-qualified.rs:16:20 | -LL | pub fn bar() { foo::baz(); } //~ ERROR failed to resolve. Use of undeclared type or module `foo` - | ^^^ Use of undeclared type or module `foo` +LL | pub fn bar() { foo::baz(); } //~ ERROR failed to resolve: use of undeclared type or module `foo` + | ^^^ use of undeclared type or module `foo` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/export-import.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/export-import.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/export-import.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/export-import.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ error[E0603]: function `unexported` is private - --> $DIR/export-import.rs:11:5 + --> $DIR/export-import.rs:11:8 | LL | use m::unexported; - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^ error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/export.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/export.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/export.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/export.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -23,10 +23,10 @@ | ^^^^^ not found in this scope error[E0603]: function `z` is private - --> $DIR/export.rs:20:13 + --> $DIR/export.rs:20:18 | LL | fn main() { foo::z(10); } //~ ERROR function `z` is private - | ^^^^^^ + | ^ error: aborting due to 5 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/export-tag-variant.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/export-tag-variant.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/export-tag-variant.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/export-tag-variant.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ error[E0603]: enum `y` is private - --> $DIR/export-tag-variant.rs:17:21 + --> $DIR/export-tag-variant.rs:17:26 | LL | fn main() { let z = foo::y::y1; } //~ ERROR: enum `y` is private - | ^^^^^^^^^^ + | ^ error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/extern/external-doc-error.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/extern/external-doc-error.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/extern/external-doc-error.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/extern/external-doc-error.rs 2018-12-04 23:41:40.000000000 +0000 @@ -1,15 +1,4 @@ -// Copyright 2012-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// normalize-stderr-test: "The system cannot find the file specified\." -> "No such file or directory" -// ignore-tidy-linelength +// normalize-stderr-test: "not-a-file.md:.*\(" -> "not-a-file.md: $$FILE_NOT_FOUND_MSG (" #![feature(external_doc)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/extern/external-doc-error.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/extern/external-doc-error.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/extern/external-doc-error.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/extern/external-doc-error.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ -error: couldn't read $DIR/not-a-file.md: No such file or directory (os error 2) - --> $DIR/external-doc-error.rs:16:1 +error: couldn't read $DIR/not-a-file.md: $FILE_NOT_FOUND_MSG (os error 2) + --> $DIR/external-doc-error.rs:5:1 | LL | #[doc(include = "not-a-file.md")] //~ ERROR: couldn't read | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/extern/extern-const.fixed rustc-1.31.0+dfsg1+llvm/src/test/ui/extern/extern-const.fixed --- rustc-1.30.0+dfsg1+llvm/src/test/ui/extern/extern-const.fixed 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/extern/extern-const.fixed 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-rustfix -// compile-flags: -Z continue-parse-after-error - -extern "C" { - static C: u8; //~ ERROR extern items cannot be `const` -} - -fn main() { - // We suggest turning the (illegal) extern `const` into an extern `static`, - // but this also requires `unsafe` (a deny-by-default lint at comment time, - // future error; Issue #36247) - unsafe { - let _x = C; - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/extern/extern-const.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/extern/extern-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/extern/extern-const.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/extern/extern-const.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// run-rustfix +// FIXME(#54388): re-enable rustfix later, when this test has consistent output across targets // compile-flags: -Z continue-parse-after-error extern "C" { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/extern/extern-crate-rename.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/extern/extern-crate-rename.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/extern/extern-crate-rename.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/extern/extern-crate-rename.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -4,12 +4,13 @@ LL | extern crate m1; | ---------------- previous import of the extern crate `m1` here LL | extern crate m2 as m1; //~ ERROR is defined multiple times - | ^^^^^^^^^^^^^^^^^^^^^^ - | | - | `m1` reimported here - | You can use `as` to change the binding name of the import + | ^^^^^^^^^^^^^^^^^^^^^^ `m1` reimported here | = note: `m1` 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 + | +LL | extern crate m2 as other_m1; //~ ERROR is defined multiple times + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/extern/extern-crate-visibility.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/extern/extern-crate-visibility.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/extern/extern-crate-visibility.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/extern/extern-crate-visibility.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,14 +1,14 @@ error[E0603]: extern crate `core` is private - --> $DIR/extern-crate-visibility.rs:16:5 + --> $DIR/extern-crate-visibility.rs:16:10 | LL | use foo::core::cell; //~ ERROR extern crate `core` is private - | ^^^^^^^^^^^^^^^ + | ^^^^ error[E0603]: extern crate `core` is private - --> $DIR/extern-crate-visibility.rs:19:5 + --> $DIR/extern-crate-visibility.rs:19:10 | LL | foo::core::cell::Cell::new(0); //~ ERROR extern crate `core` is private - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^ error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/extern/extern-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/extern/extern-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/extern/extern-macro.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/extern/extern-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,5 +12,5 @@ fn main() { enum Foo {} - let _ = Foo::bar!(); //~ ERROR fail to resolve non-ident macro path + let _ = Foo::bar!(); //~ ERROR failed to resolve: partially resolved path in a macro } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/extern/extern-macro.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/extern/extern-macro.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/extern/extern-macro.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/extern/extern-macro.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,9 @@ -error: fail to resolve non-ident macro path +error[E0433]: failed to resolve: partially resolved path in a macro --> $DIR/extern-macro.rs:15:13 | -LL | let _ = Foo::bar!(); //~ ERROR fail to resolve non-ident macro path - | ^^^^^^^^ +LL | let _ = Foo::bar!(); //~ ERROR failed to resolve: partially resolved path in a macro + | ^^^^^^^^ partially resolved path in a macro error: aborting due to previous error +For more information about this error, try `rustc --explain E0433`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -393,7 +393,6 @@ mod inner { #![no_mangle="3500"] } #[no_mangle = "3500"] fn f() { } - //~^ WARN function is marked #[no_mangle], but not exported #[no_mangle = "3500"] struct S; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -173,13 +173,13 @@ | ^^^^^ warning: macro_escape is a deprecated synonym for macro_use - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:501:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:500:1 | LL | #[macro_escape] | ^^^^^^^^^^^^^^^ warning: macro_escape is a deprecated synonym for macro_use - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:504:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:503:17 | LL | mod inner { #![macro_escape] } | ^^^^^^^^^^^^^^^^ @@ -523,720 +523,710 @@ LL | #[automatically_derived = "3600"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: function is marked #[no_mangle], but not exported - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:395:27 - | -LL | #[no_mangle = "3500"] fn f() { } - | -^^^^^^^^^ - | | - | help: try making it public: `pub` - | - = note: #[warn(private_no_mangle_fns)] on by default - warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:408:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:407:17 | LL | mod inner { #![no_link="3400"] } | ^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:411:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:410:5 | LL | #[no_link = "3400"] fn f() { } | ^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:414:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:413:5 | LL | #[no_link = "3400"] struct S; | ^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:417:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:416:5 | LL | #[no_link = "3400"]type T = S; | ^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:420:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:419:5 | LL | #[no_link = "3400"] impl S { } | ^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:405:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:404:1 | LL | #[no_link = "3400"] | ^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:427:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:426:17 | LL | mod inner { #![should_panic="3200"] } | ^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:430:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:429:5 | LL | #[should_panic = "3200"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:433:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:432:5 | LL | #[should_panic = "3200"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:436:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:435:5 | LL | #[should_panic = "3200"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:439:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:438:5 | LL | #[should_panic = "3200"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:424:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:423:1 | LL | #[should_panic = "3200"] | ^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:446:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:445:17 | LL | mod inner { #![ignore="3100"] } | ^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:449:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:448:5 | LL | #[ignore = "3100"] fn f() { } | ^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:452:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:451:5 | LL | #[ignore = "3100"] struct S; | ^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:455:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:454:5 | LL | #[ignore = "3100"] type T = S; | ^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:458:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:457:5 | LL | #[ignore = "3100"] impl S { } | ^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:443:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:442:1 | LL | #[ignore = "3100"] | ^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:465:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:464:17 | LL | mod inner { #![no_implicit_prelude="3000"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:468:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:467:5 | LL | #[no_implicit_prelude = "3000"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:471:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:470:5 | LL | #[no_implicit_prelude = "3000"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:474:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:473:5 | LL | #[no_implicit_prelude = "3000"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:477:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:476:5 | LL | #[no_implicit_prelude = "3000"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:462:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:461:1 | LL | #[no_implicit_prelude = "3000"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:484:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:483:17 | LL | mod inner { #![reexport_test_harness_main="2900"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:487:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:486:5 | LL | #[reexport_test_harness_main = "2900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:490:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:489:5 | LL | #[reexport_test_harness_main = "2900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:493:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:492:5 | LL | #[reexport_test_harness_main = "2900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:496:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:495:5 | LL | #[reexport_test_harness_main = "2900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:481:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:480:1 | LL | #[reexport_test_harness_main = "2900"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:507:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:506:5 | LL | #[macro_escape] fn f() { } | ^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:510:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:509:5 | LL | #[macro_escape] struct S; | ^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:513:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:512:5 | LL | #[macro_escape] type T = S; | ^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:516:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:515:5 | LL | #[macro_escape] impl S { } | ^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:524:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:523:17 | LL | mod inner { #![no_std="2600"] } | ^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:524:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:523:17 | LL | mod inner { #![no_std="2600"] } | ^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:528:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:527:5 | LL | #[no_std = "2600"] fn f() { } | ^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:528:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:527:5 | LL | #[no_std = "2600"] fn f() { } | ^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:532:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:531:5 | LL | #[no_std = "2600"] struct S; | ^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:532:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:531:5 | LL | #[no_std = "2600"] struct S; | ^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:536:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:535:5 | LL | #[no_std = "2600"] type T = S; | ^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:536:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:535:5 | LL | #[no_std = "2600"] type T = S; | ^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:540:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:539:5 | LL | #[no_std = "2600"] impl S { } | ^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:540:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:539:5 | LL | #[no_std = "2600"] impl S { } | ^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:520:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:519:1 | LL | #[no_std = "2600"] | ^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:520:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:519:1 | LL | #[no_std = "2600"] | ^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:679:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:678:17 | LL | mod inner { #![crate_name="0900"] } | ^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:679:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:678:17 | LL | mod inner { #![crate_name="0900"] } | ^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:683:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:682:5 | LL | #[crate_name = "0900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:683:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:682:5 | LL | #[crate_name = "0900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:687:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:686:5 | LL | #[crate_name = "0900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:687:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:686:5 | LL | #[crate_name = "0900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:691:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:690:5 | LL | #[crate_name = "0900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:691:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:690:5 | LL | #[crate_name = "0900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:695:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:694:5 | LL | #[crate_name = "0900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:695:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:694:5 | LL | #[crate_name = "0900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:675:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:674:1 | LL | #[crate_name = "0900"] | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:675:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:674:1 | LL | #[crate_name = "0900"] | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:704:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:703:17 | LL | mod inner { #![crate_type="0800"] } | ^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:704:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:703:17 | LL | mod inner { #![crate_type="0800"] } | ^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:708:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:707:5 | LL | #[crate_type = "0800"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:708:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:707:5 | LL | #[crate_type = "0800"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:712:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:711:5 | LL | #[crate_type = "0800"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:712:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:711:5 | LL | #[crate_type = "0800"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:716:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:715:5 | LL | #[crate_type = "0800"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:716:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:715:5 | LL | #[crate_type = "0800"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:720:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:719:5 | LL | #[crate_type = "0800"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:720:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:719:5 | LL | #[crate_type = "0800"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:700:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:699:1 | LL | #[crate_type = "0800"] | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:700:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:699:1 | LL | #[crate_type = "0800"] | ^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:729:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:728:17 | LL | mod inner { #![feature(x0600)] } | ^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:729:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:728:17 | LL | mod inner { #![feature(x0600)] } | ^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:733:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:732:5 | LL | #[feature(x0600)] fn f() { } | ^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:733:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:732:5 | LL | #[feature(x0600)] fn f() { } | ^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:737:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:736:5 | LL | #[feature(x0600)] struct S; | ^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:737:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:736:5 | LL | #[feature(x0600)] struct S; | ^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:741:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:740:5 | LL | #[feature(x0600)] type T = S; | ^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:741:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:740:5 | LL | #[feature(x0600)] type T = S; | ^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:745:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:744:5 | LL | #[feature(x0600)] impl S { } | ^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:745:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:744:5 | LL | #[feature(x0600)] impl S { } | ^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:725:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:724:1 | LL | #[feature(x0600)] | ^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:725:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:724:1 | LL | #[feature(x0600)] | ^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:755:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:754:17 | LL | mod inner { #![no_main="0400"] } | ^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:755:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:754:17 | LL | mod inner { #![no_main="0400"] } | ^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:759:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:758:5 | LL | #[no_main = "0400"] fn f() { } | ^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:759:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:758:5 | LL | #[no_main = "0400"] fn f() { } | ^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:763:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:762:5 | LL | #[no_main = "0400"] struct S; | ^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:763:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:762:5 | LL | #[no_main = "0400"] struct S; | ^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:767:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:766:5 | LL | #[no_main = "0400"] type T = S; | ^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:767:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:766:5 | LL | #[no_main = "0400"] type T = S; | ^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:771:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:770:5 | LL | #[no_main = "0400"] impl S { } | ^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:771:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:770:5 | LL | #[no_main = "0400"] impl S { } | ^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:751:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:750:1 | LL | #[no_main = "0400"] | ^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:751:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:750:1 | LL | #[no_main = "0400"] | ^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:793:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:792:17 | LL | mod inner { #![recursion_limit="0200"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:793:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:792:17 | LL | mod inner { #![recursion_limit="0200"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:797:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:796:5 | LL | #[recursion_limit="0200"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:797:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:796:5 | LL | #[recursion_limit="0200"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:801:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:800:5 | LL | #[recursion_limit="0200"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:801:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:800:5 | LL | #[recursion_limit="0200"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:805:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:804:5 | LL | #[recursion_limit="0200"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:805:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:804:5 | LL | #[recursion_limit="0200"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:809:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:808:5 | LL | #[recursion_limit="0200"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:809:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:808:5 | LL | #[recursion_limit="0200"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:789:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:788:1 | LL | #[recursion_limit="0200"] | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:789:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:788:1 | LL | #[recursion_limit="0200"] | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:818:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:817:17 | LL | mod inner { #![type_length_limit="0100"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:818:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:817:17 | LL | mod inner { #![type_length_limit="0100"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:822:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:821:5 | LL | #[type_length_limit="0100"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:822:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:821:5 | LL | #[type_length_limit="0100"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:826:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:825:5 | LL | #[type_length_limit="0100"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:826:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:825:5 | LL | #[type_length_limit="0100"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:830:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:829:5 | LL | #[type_length_limit="0100"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:830:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:829:5 | LL | #[type_length_limit="0100"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:834:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:833:5 | LL | #[type_length_limit="0100"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:834:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:833:5 | LL | #[type_length_limit="0100"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused attribute - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:814:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:813:1 | LL | #[type_length_limit="0100"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: #![foo] - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:814:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:813:1 | LL | #[type_length_limit="0100"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1314,7 +1304,7 @@ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: compilation successful - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:845:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:844:1 | LL | / fn main() { //~ ERROR compilation successful LL | | println!("Hello World"); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,5 @@ +// gate-test-cfg_attr_multi + +#![cfg_attr(all(), warn(nonstandard_style), allow(unused_attributes))] +//~^ ERROR cfg_attr with zero or more than one attributes is experimental +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-1.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0658]: cfg_attr with zero or more than one attributes is experimental (see issue #54881) + --> $DIR/feature-gate-cfg-attr-multi-1.rs:3:1 + | +LL | #![cfg_attr(all(), warn(nonstandard_style), allow(unused_attributes))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(cfg_attr_multi)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,3 @@ +#![cfg_attr(all(),)] +//~^ ERROR cfg_attr with zero or more than one attributes is experimental +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0658]: cfg_attr with zero or more than one attributes is experimental (see issue #54881) + --> $DIR/feature-gate-cfg-attr-multi-2.rs:1:1 + | +LL | #![cfg_attr(all(),)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(cfg_attr_multi)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-bootstrap-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-bootstrap-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-bootstrap-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-bootstrap-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,7 @@ +// Test that settingt the featute gate while using its functionality doesn't error. + +// compile-pass + +#![cfg_attr(all(), feature(cfg_attr_multi), crate_type="bin")] + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-bootstrap-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-bootstrap-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-bootstrap-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-cfg-attr-multi-bootstrap-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +// Test that settingt the featute gate while using its functionality doesn't error. +// Specifically, if there's a cfg-attr *before* the feature gate. + +// compile-pass + +#![cfg_attr(all(),)] +#![cfg_attr(all(), feature(cfg_attr_multi), crate_type="bin")] + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-const_fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-const_fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-const_fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-const_fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,9 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Test use of const fn without the `const_fn` feature gate. -// `min_const_fn` is checked in its own file -#![feature(min_const_fn)] +// Test use of advanced const fn without the `const_fn` feature gate. const fn foo() -> usize { 0 } // ok diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-const_fn.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-const_fn.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-const_fn.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-const_fn.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,23 +1,23 @@ error[E0379]: trait fns cannot be declared const - --> $DIR/feature-gate-const_fn.rs:18:5 + --> $DIR/feature-gate-const_fn.rs:16:5 | LL | const fn foo() -> u32; //~ ERROR const fn is unstable | ^^^^^ trait fns cannot be const error[E0379]: trait fns cannot be declared const - --> $DIR/feature-gate-const_fn.rs:20:5 + --> $DIR/feature-gate-const_fn.rs:18:5 | LL | const fn bar() -> u32 { 0 } //~ ERROR const fn is unstable | ^^^^^ trait fns cannot be const error[E0379]: trait fns cannot be declared const - --> $DIR/feature-gate-const_fn.rs:29:5 + --> $DIR/feature-gate-const_fn.rs:27:5 | LL | const fn foo() -> u32 { 0 } //~ ERROR trait fns cannot be declared const | ^^^^^ trait fns cannot be const error[E0658]: const fn is unstable (see issue #24111) - --> $DIR/feature-gate-const_fn.rs:18:5 + --> $DIR/feature-gate-const_fn.rs:16:5 | LL | const fn foo() -> u32; //~ ERROR const fn is unstable | ^^^^^^^^^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ = help: add #![feature(const_fn)] to the crate attributes to enable error[E0658]: const fn is unstable (see issue #24111) - --> $DIR/feature-gate-const_fn.rs:20:5 + --> $DIR/feature-gate-const_fn.rs:18:5 | LL | const fn bar() -> u32 { 0 } //~ ERROR const fn is unstable | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-dropck-ugeh-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-dropck-ugeh-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-dropck-ugeh-2.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-dropck-ugeh-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/feature-gate-dropck-ugeh-2.rs:17:5 | LL | #[unsafe_destructor_blind_to_params] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this attribute with `#[may_dangle]` | note: lint level defined here --> $DIR/feature-gate-dropck-ugeh-2.rs:11:9 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-extern_absolute_paths.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-extern_absolute_paths.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-extern_absolute_paths.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-extern_absolute_paths.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,13 +2,13 @@ --> $DIR/feature-gate-extern_absolute_paths.rs:11:5 | LL | use core::default; //~ ERROR unresolved import `core` - | ^^^^ Maybe a missing `extern crate core;`? + | ^^^^ maybe a missing `extern crate core;`? -error[E0433]: failed to resolve. Maybe a missing `extern crate core;`? +error[E0433]: failed to resolve: maybe a missing `extern crate core;`? --> $DIR/feature-gate-extern_absolute_paths.rs:14:19 | LL | let _: u8 = ::core::default::Default(); //~ ERROR failed to resolve - | ^^^^ Maybe a missing `extern crate core;`? + | ^^^^ maybe a missing `extern crate core;`? error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_header_lifetime_elision.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_header_lifetime_elision.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_header_lifetime_elision.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_header_lifetime_elision.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(warnings)] - -trait MyTrait<'a> { } - -impl<'a> MyTrait<'a> for &u32 { } -//~^ ERROR missing lifetime specifier - -impl<'a> MyTrait<'_> for &'a f32 { } -//~^ ERROR missing lifetime specifier - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_header_lifetime_elision.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_header_lifetime_elision.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_header_lifetime_elision.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_header_lifetime_elision.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/feature-gate-impl_header_lifetime_elision.rs:15:26 - | -LL | impl<'a> MyTrait<'a> for &u32 { } - | ^ expected lifetime parameter - -error[E0106]: missing lifetime specifier - --> $DIR/feature-gate-impl_header_lifetime_elision.rs:18:18 - | -LL | impl<'a> MyTrait<'_> for &'a f32 { } - | ^^ expected lifetime parameter - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0106`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_header_lifetime_elision-with-in_band.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_header_lifetime_elision-with-in_band.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_header_lifetime_elision-with-in_band.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_header_lifetime_elision-with-in_band.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(warnings)] - -// Make sure this related feature didn't accidentally enable this -#![feature(in_band_lifetimes)] - -trait MyTrait<'a> { } - -impl MyTrait<'a> for &u32 { } -//~^ ERROR missing lifetime specifier - -struct MyStruct; -trait MarkerTrait {} - -impl MarkerTrait for &'_ MyStruct { } -//~^ ERROR missing lifetime specifier - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_header_lifetime_elision-with-in_band.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_header_lifetime_elision-with-in_band.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_header_lifetime_elision-with-in_band.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_header_lifetime_elision-with-in_band.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/feature-gate-impl_header_lifetime_elision-with-in_band.rs:18:22 - | -LL | impl MyTrait<'a> for &u32 { } - | ^ expected lifetime parameter - -error[E0106]: missing lifetime specifier - --> $DIR/feature-gate-impl_header_lifetime_elision-with-in_band.rs:24:23 - | -LL | impl MarkerTrait for &'_ MyStruct { } - | ^^ expected lifetime parameter - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0106`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_trait_in_bindings.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_trait_in_bindings.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_trait_in_bindings.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_trait_in_bindings.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const FOO: impl Copy = 42; + +static BAR: impl Copy = 42; + +fn main() { + let foo = impl Copy = 42; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_trait_in_bindings.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_trait_in_bindings.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_trait_in_bindings.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-impl_trait_in_bindings.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +error: expected expression, found keyword `impl` + --> $DIR/feature-gate-impl_trait_in_bindings.rs:16:15 + | +LL | let foo = impl Copy = 42; + | ^^^^ expected expression + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/feature-gate-impl_trait_in_bindings.rs:11:12 + | +LL | const FOO: impl Copy = 42; + | ^^^^^^^^^ + | + = help: add #![feature(impl_trait_in_bindings)] to the crate attributes to enable + +error[E0562]: `impl Trait` not allowed outside of function and inherent method return types + --> $DIR/feature-gate-impl_trait_in_bindings.rs:13:13 + | +LL | static BAR: impl Copy = 42; + | ^^^^^^^^^ + | + = help: add #![feature(impl_trait_in_bindings)] to the crate attributes to enable + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0562`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-in_band_lifetimes.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-in_band_lifetimes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-in_band_lifetimes.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-in_band_lifetimes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,9 +10,6 @@ #![allow(warnings)] -// Make sure this related feature didn't accidentally enable this -#![feature(impl_header_lifetime_elision)] - fn foo(x: &'x u8) -> &'x u8 { x } //~^ ERROR use of undeclared lifetime name //~^^ ERROR use of undeclared lifetime name diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-in_band_lifetimes.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-in_band_lifetimes.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-in_band_lifetimes.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-in_band_lifetimes.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,101 +1,101 @@ error[E0261]: use of undeclared lifetime name `'x` - --> $DIR/feature-gate-in_band_lifetimes.rs:16:12 + --> $DIR/feature-gate-in_band_lifetimes.rs:13:12 | LL | fn foo(x: &'x u8) -> &'x u8 { x } | ^^ undeclared lifetime error[E0261]: use of undeclared lifetime name `'x` - --> $DIR/feature-gate-in_band_lifetimes.rs:16:23 + --> $DIR/feature-gate-in_band_lifetimes.rs:13:23 | LL | fn foo(x: &'x u8) -> &'x u8 { x } | ^^ undeclared lifetime error[E0261]: use of undeclared lifetime name `'b` - --> $DIR/feature-gate-in_band_lifetimes.rs:28:12 + --> $DIR/feature-gate-in_band_lifetimes.rs:25:12 | LL | impl<'a> X<'b> { | ^^ undeclared lifetime error[E0261]: use of undeclared lifetime name `'b` - --> $DIR/feature-gate-in_band_lifetimes.rs:30:27 + --> $DIR/feature-gate-in_band_lifetimes.rs:27:27 | LL | fn inner_2(&self) -> &'b u8 { | ^^ undeclared lifetime error[E0261]: use of undeclared lifetime name `'b` - --> $DIR/feature-gate-in_band_lifetimes.rs:36:8 + --> $DIR/feature-gate-in_band_lifetimes.rs:33:8 | LL | impl X<'b> { | ^^ undeclared lifetime error[E0261]: use of undeclared lifetime name `'b` - --> $DIR/feature-gate-in_band_lifetimes.rs:38:27 + --> $DIR/feature-gate-in_band_lifetimes.rs:35:27 | LL | fn inner_3(&self) -> &'b u8 { | ^^ undeclared lifetime error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/feature-gate-in_band_lifetimes.rs:46:9 + --> $DIR/feature-gate-in_band_lifetimes.rs:43:9 | LL | impl Y<&'a u8> { | ^^ undeclared lifetime error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/feature-gate-in_band_lifetimes.rs:48:25 + --> $DIR/feature-gate-in_band_lifetimes.rs:45:25 | LL | fn inner(&self) -> &'a u8 { | ^^ undeclared lifetime error[E0261]: use of undeclared lifetime name `'b` - --> $DIR/feature-gate-in_band_lifetimes.rs:56:27 + --> $DIR/feature-gate-in_band_lifetimes.rs:53:27 | LL | fn any_lifetime() -> &'b u8; | ^^ undeclared lifetime error[E0261]: use of undeclared lifetime name `'b` - --> $DIR/feature-gate-in_band_lifetimes.rs:58:27 + --> $DIR/feature-gate-in_band_lifetimes.rs:55:27 | LL | fn borrowed_lifetime(&'b self) -> &'b u8; | ^^ undeclared lifetime error[E0261]: use of undeclared lifetime name `'b` - --> $DIR/feature-gate-in_band_lifetimes.rs:58:40 + --> $DIR/feature-gate-in_band_lifetimes.rs:55:40 | LL | fn borrowed_lifetime(&'b self) -> &'b u8; | ^^ undeclared lifetime error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/feature-gate-in_band_lifetimes.rs:63:14 + --> $DIR/feature-gate-in_band_lifetimes.rs:60:14 | LL | impl MyTrait<'a> for Y<&'a u8> { | ^^ undeclared lifetime error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/feature-gate-in_band_lifetimes.rs:63:25 + --> $DIR/feature-gate-in_band_lifetimes.rs:60:25 | LL | impl MyTrait<'a> for Y<&'a u8> { | ^^ undeclared lifetime error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/feature-gate-in_band_lifetimes.rs:66:31 + --> $DIR/feature-gate-in_band_lifetimes.rs:63:31 | LL | fn my_lifetime(&self) -> &'a u8 { self.0 } | ^^ undeclared lifetime error[E0261]: use of undeclared lifetime name `'b` - --> $DIR/feature-gate-in_band_lifetimes.rs:68:27 + --> $DIR/feature-gate-in_band_lifetimes.rs:65:27 | LL | fn any_lifetime() -> &'b u8 { &0 } | ^^ undeclared lifetime error[E0261]: use of undeclared lifetime name `'b` - --> $DIR/feature-gate-in_band_lifetimes.rs:70:27 + --> $DIR/feature-gate-in_band_lifetimes.rs:67:27 | LL | fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 } | ^^ undeclared lifetime error[E0261]: use of undeclared lifetime name `'b` - --> $DIR/feature-gate-in_band_lifetimes.rs:70:40 + --> $DIR/feature-gate-in_band_lifetimes.rs:67:40 | LL | fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 } | ^^ undeclared lifetime diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-infer_outlives_requirements.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-infer_outlives_requirements.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-infer_outlives_requirements.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-infer_outlives_requirements.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Needs an explicit where clause stating outlives condition. (RFC 2093) - -// Type T needs to outlive lifetime 'a. -struct Foo<'a, T> { - bar: &'a [T] //~ ERROR the parameter type `T` may not live long enough [E0309] -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-infer_outlives_requirements.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-infer_outlives_requirements.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-infer_outlives_requirements.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-infer_outlives_requirements.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/feature-gate-infer_outlives_requirements.rs:15:5 - | -LL | struct Foo<'a, T> { - | - help: consider adding an explicit lifetime bound `T: 'a`... -LL | bar: &'a [T] //~ ERROR the parameter type `T` may not live long enough [E0309] - | ^^^^^^^^^^^^ - | -note: ...so that the reference type `&'a [T]` does not outlive the data it points at - --> $DIR/feature-gate-infer_outlives_requirements.rs:15:5 - | -LL | bar: &'a [T] //~ ERROR the parameter type `T` may not live long enough [E0309] - | ^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0309`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-marker_trait_attr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-marker_trait_attr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-marker_trait_attr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-marker_trait_attr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::fmt::{Debug, Display}; + +#[marker] trait ExplicitMarker {} +//~^ ERROR marker traits is an experimental feature (see issue #29864) + +impl ExplicitMarker for T {} +impl ExplicitMarker for T {} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-marker_trait_attr.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-marker_trait_attr.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-marker_trait_attr.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-marker_trait_attr.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0658]: marker traits is an experimental feature (see issue #29864) + --> $DIR/feature-gate-marker_trait_attr.rs:13:1 + | +LL | #[marker] trait ExplicitMarker {} + | ^^^^^^^^^ + | + = help: add #![feature(marker_trait_attr)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-min_const_fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-min_const_fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-min_const_fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-min_const_fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,7 @@ // Test use of min_const_fn without feature gate. -const fn foo() -> usize { 0 } //~ ERROR const fn is unstable +const fn foo() -> usize { 0 } // stabilized trait Foo { const fn foo() -> u32; //~ ERROR const fn is unstable @@ -20,12 +20,11 @@ } impl Foo { - const fn baz() -> u32 { 0 } //~ ERROR const fn is unstable + const fn baz() -> u32 { 0 } // stabilized } impl Foo for u32 { - const fn foo() -> u32 { 0 } //~ ERROR const fn is unstable - //~| ERROR trait fns cannot be declared const + const fn foo() -> u32 { 0 } //~ ERROR trait fns cannot be declared const } static FOO: usize = foo(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-min_const_fn.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-min_const_fn.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-min_const_fn.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-min_const_fn.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -13,17 +13,9 @@ error[E0379]: trait fns cannot be declared const --> $DIR/feature-gate-min_const_fn.rs:27:5 | -LL | const fn foo() -> u32 { 0 } //~ ERROR const fn is unstable +LL | const fn foo() -> u32 { 0 } //~ ERROR trait fns cannot be declared const | ^^^^^ trait fns cannot be const -error[E0658]: const fn is unstable (see issue #53555) - --> $DIR/feature-gate-min_const_fn.rs:13:1 - | -LL | const fn foo() -> usize { 0 } //~ ERROR const fn is unstable - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(min_const_fn)] to the crate attributes to enable - error[E0658]: const fn is unstable (see issue #24111) --> $DIR/feature-gate-min_const_fn.rs:16:5 | @@ -40,23 +32,7 @@ | = help: add #![feature(const_fn)] to the crate attributes to enable -error[E0658]: const fn is unstable (see issue #53555) - --> $DIR/feature-gate-min_const_fn.rs:23:5 - | -LL | const fn baz() -> u32 { 0 } //~ ERROR const fn is unstable - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(min_const_fn)] to the crate attributes to enable - -error[E0658]: const fn is unstable (see issue #53555) - --> $DIR/feature-gate-min_const_fn.rs:27:5 - | -LL | const fn foo() -> u32 { 0 } //~ ERROR const fn is unstable - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(min_const_fn)] to the crate attributes to enable - -error: aborting due to 8 previous errors +error: aborting due to 5 previous errors Some errors occurred: E0379, E0658. For more information about an error, try `rustc --explain E0379`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-panic-implementation.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-panic-implementation.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-panic-implementation.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-panic-implementation.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,7 +15,7 @@ use core::panic::PanicInfo; -#[panic_implementation] //~ ERROR This attribute was renamed to `panic_handler` (see issue #44489) +#[panic_implementation] //~ ERROR this attribute was renamed to `panic_handler` (see issue #44489) fn panic(info: &PanicInfo) -> ! { loop {} } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-panic-implementation.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-panic-implementation.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-panic-implementation.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-panic-implementation.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,7 +1,7 @@ -error[E0658]: This attribute was renamed to `panic_handler` (see issue #44489) +error[E0658]: this attribute was renamed to `panic_handler` (see issue #44489) --> $DIR/feature-gate-panic-implementation.rs:18:1 | -LL | #[panic_implementation] //~ ERROR This attribute was renamed to `panic_handler` (see issue #44489) +LL | #[panic_implementation] //~ ERROR this attribute was renamed to `panic_handler` (see issue #44489) | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(panic_implementation)] to the crate attributes to enable diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-pattern_parentheses.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-pattern_parentheses.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-pattern_parentheses.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-pattern_parentheses.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - match 0 { - (pat) => {} //~ ERROR parentheses in patterns are unstable - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-pattern_parentheses.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-pattern_parentheses.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-pattern_parentheses.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-pattern_parentheses.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error[E0658]: parentheses in patterns are unstable (see issue #51087) - --> $DIR/feature-gate-pattern_parentheses.rs:13:9 - | -LL | (pat) => {} //~ ERROR parentheses in patterns are unstable - | ^^^^^ - | - = help: add #![feature(pattern_parentheses)] to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-self_in_typedefs.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-self_in_typedefs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-self_in_typedefs.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-self_in_typedefs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum StackList<'a, T: 'a> { + Nil, + Cons(T, &'a Self) + //~^ ERROR cannot find type `Self` in this scope + //~| `Self` is only available in traits and impls +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-self-in-typedefs.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-self-in-typedefs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-self-in-typedefs.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-self-in-typedefs.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum StackList<'a, T: 'a> { - Nil, - Cons(T, &'a Self) - //~^ ERROR cannot find type `Self` in this scope - //~| `Self` is only available in traits and impls -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-self_in_typedefs.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-self_in_typedefs.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-self_in_typedefs.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-self_in_typedefs.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0411]: cannot find type `Self` in this scope + --> $DIR/feature-gate-self_in_typedefs.rs:13:17 + | +LL | Cons(T, &'a Self) + | ^^^^ `Self` is only available in traits and impls + | + = help: add #![feature(self_in_typedefs)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0411`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-self-in-typedefs.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-self-in-typedefs.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-self-in-typedefs.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-self-in-typedefs.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -error[E0411]: cannot find type `Self` in this scope - --> $DIR/feature-gate-self-in-typedefs.rs:13:17 - | -LL | Cons(T, &'a Self) - | ^^^^ `Self` is only available in traits and impls - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0411`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-tool_lints-fail.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-tool_lints-fail.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-tool_lints-fail.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-tool_lints-fail.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[warn(clippy::assign_ops)] //~ ERROR scoped lint `clippy::assign_ops` is experimental -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-tool_lints-fail.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-tool_lints-fail.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-tool_lints-fail.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-tool_lints-fail.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error[E0658]: scoped lint `clippy::assign_ops` is experimental (see issue #44690) - --> $DIR/feature-gate-tool_lints-fail.rs:11:8 - | -LL | #[warn(clippy::assign_ops)] //~ ERROR scoped lint `clippy::assign_ops` is experimental - | ^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(tool_lints)] to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-tool_lints.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-tool_lints.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-tool_lints.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-tool_lints.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[warn(clippy::decimal_literal_representation)] -//~^ ERROR scoped lint `clippy::decimal_literal_representation` is experimental -fn main() { - let a = 65_535; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-tool_lints.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-tool_lints.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-tool_lints.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-tool_lints.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error[E0658]: scoped lint `clippy::decimal_literal_representation` is experimental (see issue #44690) - --> $DIR/feature-gate-tool_lints.rs:11:8 - | -LL | #[warn(clippy::decimal_literal_representation)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(tool_lints)] to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -75,15 +75,16 @@ = help: see issue #48214 = help: add #![feature(trivial_bounds)] to the crate attributes to enable -error[E0277]: the trait bound `i32: std::iter::Iterator` is not satisfied +error[E0277]: `i32` is not an iterator --> $DIR/feature-gate-trivial_bounds.rs:50:1 | LL | / fn use_for() where i32: Iterator { //~ ERROR LL | | for _ in 2i32 {} LL | | } - | |_^ `i32` is not an iterator; maybe try calling `.iter()` or a similar method + | |_^ `i32` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `i32` + = note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end` = help: see issue #48214 = help: add #![feature(trivial_bounds)] to the crate attributes to enable diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-uniform-paths.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-uniform-paths.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-uniform-paths.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-uniform-paths.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,15 +8,22 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// edition:2018 + pub mod foo { - pub use bar::Bar; - //~^ ERROR unresolved import `bar` + pub use bar::Bar; //~ ERROR imports can only refer to extern crate names pub mod bar { pub struct Bar; } } +use inline; //~ ERROR imports can only refer to extern crate names + +use Vec; //~ ERROR imports can only refer to extern crate names + +use vec; //~ ERROR imports can only refer to extern crate names + fn main() { let _ = foo::Bar; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-uniform-paths.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-uniform-paths.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-uniform-paths.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gates/feature-gate-uniform-paths.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,9 +1,62 @@ -error[E0432]: unresolved import `bar` - --> $DIR/feature-gate-uniform-paths.rs:12:13 +error[E0658]: imports can only refer to extern crate names passed with `--extern` on stable channel (see issue #53130) + --> $DIR/feature-gate-uniform-paths.rs:14:13 | -LL | pub use bar::Bar; - | ^^^ Did you mean `self::bar`? +LL | pub use bar::Bar; //~ ERROR imports can only refer to extern crate names + | ^^^ +LL | +LL | / pub mod bar { +LL | | pub struct Bar; +LL | | } + | |_____- not an extern crate passed with `--extern` + | + = help: add #![feature(uniform_paths)] to the crate attributes to enable +note: this import refers to the module defined here + --> $DIR/feature-gate-uniform-paths.rs:16:5 + | +LL | / pub mod bar { +LL | | pub struct Bar; +LL | | } + | |_____^ + +error[E0658]: imports can only refer to extern crate names passed with `--extern` on stable channel (see issue #53130) + --> $DIR/feature-gate-uniform-paths.rs:21:5 + | +LL | use inline; //~ ERROR imports can only refer to extern crate names + | ^^^^^^ not an extern crate passed with `--extern` + | + = help: add #![feature(uniform_paths)] to the crate attributes to enable +note: this import refers to the built-in attribute imported here + --> $DIR/feature-gate-uniform-paths.rs:21:5 + | +LL | use inline; //~ ERROR imports can only refer to extern crate names + | ^^^^^^ + +error[E0658]: imports can only refer to extern crate names passed with `--extern` on stable channel (see issue #53130) + --> $DIR/feature-gate-uniform-paths.rs:23:5 + | +LL | use Vec; //~ ERROR imports can only refer to extern crate names + | ^^^ not an extern crate passed with `--extern` + | + = help: add #![feature(uniform_paths)] to the crate attributes to enable +note: this import refers to the struct imported here + --> $DIR/feature-gate-uniform-paths.rs:23:5 + | +LL | use Vec; //~ ERROR imports can only refer to extern crate names + | ^^^ + +error[E0658]: imports can only refer to extern crate names passed with `--extern` on stable channel (see issue #53130) + --> $DIR/feature-gate-uniform-paths.rs:25:5 + | +LL | use vec; //~ ERROR imports can only refer to extern crate names + | ^^^ not an extern crate passed with `--extern` + | + = help: add #![feature(uniform_paths)] to the crate attributes to enable +note: this import refers to the macro imported here + --> $DIR/feature-gate-uniform-paths.rs:25:5 + | +LL | use vec; //~ ERROR imports can only refer to extern crate names + | ^^^ -error: aborting due to previous error +error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0432`. +For more information about this error, try `rustc --explain E0658`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gate-underscore_const_names.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gate-underscore_const_names.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gate-underscore_const_names.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gate-underscore_const_names.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +#![feature(const_let)] + +trait Trt {} +struct Str {} + +impl Trt for Str {} + +const _ : () = { + use std::marker::PhantomData; + struct ImplementsTrait(PhantomData); + let _ = ImplementsTrait::(PhantomData); + () +}; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gate-underscore_const_names.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gate-underscore_const_names.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/feature-gate-underscore_const_names.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/feature-gate-underscore_const_names.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +error[E0658]: naming constants with `_` is unstable (see issue #54912) + --> $DIR/feature-gate-underscore_const_names.rs:17:1 + | +LL | / const _ : () = { +LL | | use std::marker::PhantomData; +LL | | struct ImplementsTrait(PhantomData); +LL | | let _ = ImplementsTrait::(PhantomData); +LL | | () +LL | | }; + | |__^ + | + = help: add #![feature(underscore_const_names)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/fn_must_use.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/fn_must_use.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/fn_must_use.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/fn_must_use.rs 2018-12-04 23:41:40.000000000 +0000 @@ -22,6 +22,11 @@ fn need_to_use_this_method_value(&self) -> usize { self.n } + + #[must_use] + fn need_to_use_this_associated_function_value() -> isize { + -1 + } } trait EvenNature { @@ -66,6 +71,9 @@ m.is_even(); // trait method! //~^ WARN unused return value + MyStruct::need_to_use_this_associated_function_value(); + //~^ WARN unused return value + m.replace(3); // won't warn (annotation needs to be in trait definition) // comparison methods are `must_use` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/fn_must_use.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/fn_must_use.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/fn_must_use.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/fn_must_use.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ -warning: unused return value of `need_to_use_this_value` which must be used - --> $DIR/fn_must_use.rs:60:5 +warning: unused return value of `need_to_use_this_value` that must be used + --> $DIR/fn_must_use.rs:65:5 | LL | need_to_use_this_value(); //~ WARN unused return value | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -11,40 +11,46 @@ | ^^^^^^^^^^^^^^^ = note: it's important -warning: unused return value of `MyStruct::need_to_use_this_method_value` which must be used - --> $DIR/fn_must_use.rs:65:5 +warning: unused return value of `MyStruct::need_to_use_this_method_value` that must be used + --> $DIR/fn_must_use.rs:70:5 | LL | m.need_to_use_this_method_value(); //~ WARN unused return value | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: unused return value of `EvenNature::is_even` which must be used - --> $DIR/fn_must_use.rs:66:5 +warning: unused return value of `EvenNature::is_even` that must be used + --> $DIR/fn_must_use.rs:71:5 | LL | m.is_even(); // trait method! | ^^^^^^^^^^^^ | = note: no side effects -warning: unused return value of `std::cmp::PartialEq::eq` which must be used - --> $DIR/fn_must_use.rs:72:5 +warning: unused return value of `MyStruct::need_to_use_this_associated_function_value` that must be used + --> $DIR/fn_must_use.rs:74:5 + | +LL | MyStruct::need_to_use_this_associated_function_value(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: unused return value of `std::cmp::PartialEq::eq` that must be used + --> $DIR/fn_must_use.rs:80:5 | LL | 2.eq(&3); //~ WARN unused return value | ^^^^^^^^^ -warning: unused return value of `std::cmp::PartialEq::eq` which must be used - --> $DIR/fn_must_use.rs:73:5 +warning: unused return value of `std::cmp::PartialEq::eq` that must be used + --> $DIR/fn_must_use.rs:81:5 | LL | m.eq(&n); //~ WARN unused return value | ^^^^^^^^^ -warning: unused comparison which must be used - --> $DIR/fn_must_use.rs:76:5 +warning: unused comparison that must be used + --> $DIR/fn_must_use.rs:84:5 | LL | 2 == 3; //~ WARN unused comparison | ^^^^^^ -warning: unused comparison which must be used - --> $DIR/fn_must_use.rs:77:5 +warning: unused comparison that must be used + --> $DIR/fn_must_use.rs:85:5 | LL | m == n; //~ WARN unused comparison | ^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/for/for-c-in-str.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/for/for-c-in-str.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/for/for-c-in-str.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/for/for-c-in-str.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,7 +12,7 @@ fn main() { for c in "asdf" { - //~^ ERROR the trait bound `&str: std::iter::Iterator` is not satisfied + //~^ ERROR `&str` is not an iterator //~| NOTE `&str` is not an iterator //~| HELP the trait `std::iter::Iterator` is not implemented for `&str` //~| NOTE required by `std::iter::IntoIterator::into_iter` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/for/for-c-in-str.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/for/for-c-in-str.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/for/for-c-in-str.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/for/for-c-in-str.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `&str: std::iter::Iterator` is not satisfied +error[E0277]: `&str` is not an iterator --> $DIR/for-c-in-str.rs:14:14 | LL | for c in "asdf" { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/for/for-loop-bogosity.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/for/for-loop-bogosity.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/for/for-loop-bogosity.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/for/for-loop-bogosity.rs 2018-12-04 23:41:40.000000000 +0000 @@ -24,7 +24,8 @@ x: 1, y: 2, }; - for x in bogus { //~ ERROR `MyStruct: std::iter::Iterator` is not satisfied + for x in bogus { + //~^ ERROR `MyStruct` is not an iterator drop(x); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/for/for-loop-bogosity.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/for/for-loop-bogosity.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/for/for-loop-bogosity.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/for/for-loop-bogosity.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `MyStruct: std::iter::Iterator` is not satisfied +error[E0277]: `MyStruct` is not an iterator --> $DIR/for-loop-bogosity.rs:27:14 | -LL | for x in bogus { //~ ERROR `MyStruct: std::iter::Iterator` is not satisfied - | ^^^^^ `MyStruct` is not an iterator; maybe try calling `.iter()` or a similar method +LL | for x in bogus { + | ^^^^^ `MyStruct` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `MyStruct` = note: required by `std::iter::IntoIterator::into_iter` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/foreign-fn-return-lifetime.fixed rustc-1.31.0+dfsg1+llvm/src/test/ui/foreign-fn-return-lifetime.fixed --- rustc-1.30.0+dfsg1+llvm/src/test/ui/foreign-fn-return-lifetime.fixed 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/foreign-fn-return-lifetime.fixed 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-rustfix + +extern "C" { + pub fn g(_: &u8) -> &u8; // OK + pub fn f() -> &'static u8; //~ ERROR missing lifetime specifier +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/foreign-fn-return-lifetime.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/foreign-fn-return-lifetime.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/foreign-fn-return-lifetime.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/foreign-fn-return-lifetime.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,9 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// run-rustfix + extern "C" { - fn g(_: &u8) -> &u8; // OK - fn f() -> &u8; //~ ERROR missing lifetime specifier + pub fn g(_: &u8) -> &u8; // OK + pub fn f() -> &u8; //~ ERROR missing lifetime specifier } fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/foreign-fn-return-lifetime.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/foreign-fn-return-lifetime.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/foreign-fn-return-lifetime.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/foreign-fn-return-lifetime.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,11 +1,10 @@ error[E0106]: missing lifetime specifier - --> $DIR/foreign-fn-return-lifetime.rs:13:15 + --> $DIR/foreign-fn-return-lifetime.rs:15:19 | -LL | fn f() -> &u8; //~ ERROR missing lifetime specifier - | ^ expected lifetime parameter +LL | pub fn f() -> &u8; //~ ERROR missing lifetime specifier + | ^ help: consider giving it a 'static lifetime: `&'static` | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from - = help: consider giving it a 'static lifetime error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/generator/borrowing.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/generator/borrowing.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/generator/borrowing.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/generator/borrowing.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,24 +1,33 @@ error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:18:18 + --> $DIR/borrowing.rs:18:29 | LL | unsafe { (|| yield &a).resume() } - | ^^^^^^^^^^^^^ borrowed value does not live long enough + | -----------^- + | || | + | || borrowed value does not live long enough + | |value captured here by generator + | a temporary with access to the borrow is created here ... LL | //~^ ERROR: `a` does not live long enough LL | }; - | - `a` dropped here while still borrowed + | -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for generator + | | + | `a` dropped here while still borrowed + | + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. error[E0597]: `a` does not live long enough - --> $DIR/borrowing.rs:24:9 + --> $DIR/borrowing.rs:25:20 | -LL | / || { -LL | | yield &a -LL | | //~^ ERROR: `a` does not live long enough -LL | | } - | |_________^ borrowed value does not live long enough -LL | }; - | - `a` dropped here while still borrowed -LL | } - | - borrow later used here, when `_b` is dropped +LL | let _b = { + | -- borrow later stored here +LL | let a = 3; +LL | || { + | -- value captured here by generator +LL | yield &a + | ^ borrowed value does not live long enough +... +LL | }; + | - `a` dropped here while still borrowed error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/generator/dropck.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/generator/dropck.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/generator/dropck.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/generator/dropck.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,24 +8,24 @@ | - | | | `*cell` dropped here while still borrowed - | borrow later used here, when `gen` is dropped + | borrow might be used here, when `gen` is dropped and runs the destructor for generator + | + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `ref_` does not live long enough - --> $DIR/dropck.rs:22:11 + --> $DIR/dropck.rs:24:18 | -LL | gen = || { - | ___________^ -LL | | // but the generator can use it to drop a `Ref<'a, i32>`. -LL | | let _d = ref_.take(); //~ ERROR `ref_` does not live long enough -LL | | yield; -LL | | }; - | |_____^ borrowed value does not live long enough +LL | gen = || { + | -- value captured here by generator +LL | // but the generator can use it to drop a `Ref<'a, i32>`. +LL | let _d = ref_.take(); //~ ERROR `ref_` does not live long enough + | ^^^^ borrowed value does not live long enough ... -LL | } - | - - | | - | `ref_` dropped here while still borrowed - | borrow later used here, when `gen` is dropped +LL | } + | - + | | + | `ref_` dropped here while still borrowed + | borrow might be used here, when `gen` is dropped and runs the destructor for generator | = note: values in a scope are dropped in the opposite order they are defined diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/generator/generator-region-requirements.ast.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/generator/generator-region-requirements.ast.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/generator/generator-region-requirements.ast.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/generator/generator-region-requirements.ast.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +error[E0621]: explicit lifetime required in the type of `x` + --> $DIR/generator-region-requirements.rs:15:51 + | +LL | fn dangle(x: &mut i32) -> &'static mut i32 { + | -------- help: add explicit lifetime `'static` to the type of `x`: `&'static mut i32` +... +LL | GeneratorState::Complete(c) => return c, + | ^ lifetime `'static` required + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0621`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/generator/generator-region-requirements.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/generator/generator-region-requirements.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/generator/generator-region-requirements.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/generator/generator-region-requirements.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +error[E0621]: explicit lifetime required in the type of `x` + --> $DIR/generator-region-requirements.rs:15:51 + | +LL | fn dangle(x: &mut i32) -> &'static mut i32 { + | -------- help: add explicit lifetime `'static` to the type of `x`: `&'static mut i32` +... +LL | GeneratorState::Complete(c) => return c, + | ^ lifetime `'static` required + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0621`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/generator/generator-region-requirements.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/generator/generator-region-requirements.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/generator/generator-region-requirements.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/generator/generator-region-requirements.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// revisions: ast nll +// ignore-compare-mode-nll + +#![feature(generators, generator_trait)] +#![cfg_attr(nll, feature(nll))] +use std::ops::{Generator, GeneratorState}; + +fn dangle(x: &mut i32) -> &'static mut i32 { + let mut g = || { + yield; + x + }; + loop { + match unsafe { g.resume() } { + GeneratorState::Complete(c) => return c, + GeneratorState::Yielded(_) => (), + } + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/generator/ref-escapes-but-not-over-yield.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/generator/ref-escapes-but-not-over-yield.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/generator/ref-escapes-but-not-over-yield.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/generator/ref-escapes-but-not-over-yield.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,12 +1,15 @@ -error[E0597]: `b` does not live long enough - --> $DIR/ref-escapes-but-not-over-yield.rs:24:13 +error[E0521]: borrowed data escapes outside of generator + --> $DIR/ref-escapes-but-not-over-yield.rs:24:9 | +LL | let mut a = &3; + | ----- `a` is declared here, outside of the generator body +... LL | a = &b; - | ^^ borrowed value does not live long enough -LL | //~^ ERROR `b` does not live long enough -LL | }; - | - `b` dropped here while still borrowed + | ^^^^-- + | | | + | | borrow is only valid in the generator body + | reference to `b` escapes the generator body here error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0521`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/generator/yield-while-iterating.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/generator/yield-while-iterating.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/generator/yield-while-iterating.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/generator/yield-while-iterating.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -9,17 +9,15 @@ error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable --> $DIR/yield-while-iterating.rs:67:20 | -LL | let mut b = || { - | _________________- -LL | | for p in &mut x { -LL | | yield p; -LL | | } -LL | | }; - | |_____- mutable borrow occurs here -LL | println!("{}", x[0]); //~ ERROR - | ^ immutable borrow occurs here -LL | b.resume(); - | - borrow later used here +LL | let mut b = || { + | -- mutable borrow occurs here +LL | for p in &mut x { + | - first borrow occurs due to use of `x` in generator +... +LL | println!("{}", x[0]); //~ ERROR + | ^ immutable borrow occurs here +LL | b.resume(); + | - mutable borrow later used here error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/generator/yield-while-ref-reborrowed.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/generator/yield-while-ref-reborrowed.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/generator/yield-while-ref-reborrowed.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/generator/yield-while-ref-reborrowed.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,17 +1,15 @@ error[E0501]: cannot borrow `x` as immutable because previous closure requires unique access --> $DIR/yield-while-ref-reborrowed.rs:45:20 | -LL | let mut b = || { - | _________________- -LL | | let a = &mut *x; -LL | | yield(); -LL | | println!("{}", a); -LL | | }; - | |_____- closure construction occurs here -LL | println!("{}", x); //~ ERROR - | ^ borrow occurs here -LL | b.resume(); - | - borrow later used here +LL | let mut b = || { + | -- generator construction occurs here +LL | let a = &mut *x; + | - first borrow occurs due to use of `x` in generator +... +LL | println!("{}", x); //~ ERROR + | ^ borrow occurs here +LL | b.resume(); + | - first borrow later used here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/hashmap-iter-value-lifetime.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/hashmap-iter-value-lifetime.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/hashmap-iter-value-lifetime.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/hashmap-iter-value-lifetime.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | ^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | LL | println!("{}", *thing); - | ------ borrow later used here + | ------ immutable borrow later used here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/hashmap-lifetimes.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/hashmap-lifetimes.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/hashmap-lifetimes.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/hashmap-lifetimes.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -6,7 +6,7 @@ LL | my_stuff.insert(1, 43); //~ ERROR cannot borrow | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | it; - | -- borrow later used here + | -- immutable borrow later used here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/hr-subtype.rs:43:13 - | -LL | fn subtype<'x,'y:'x,'z:'y>() { - | -- -- lifetime `'y` defined here - | | - | lifetime `'x` defined here -LL | gimme::<$t2>(None::<$t1>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'x` must outlive `'y` -... -LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), -LL | | fn(Inv<'y>)) } - | |__________________________________________________- in this macro invocation - -error: unsatisfied lifetime constraints - --> $DIR/hr-subtype.rs:49:13 - | -LL | fn supertype<'x,'y:'x,'z:'y>() { - | -- -- lifetime `'y` defined here - | | - | lifetime `'x` defined here -LL | gimme::<$t1>(None::<$t2>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'x` must outlive `'y` -... -LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>), -LL | | fn(Inv<'y>)) } - | |__________________________________________________- in this macro invocation - -error: aborting due to 2 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/hr-subtype.rs:49:13 - | -LL | fn supertype<'x,'y:'x,'z:'y>() { - | -- -- lifetime `'y` defined here - | | - | lifetime `'x` defined here -LL | gimme::<$t1>(None::<$t2>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'x` must outlive `'y` -... -LL | / check! { free_x_vs_free_y: (fn(&'x u32), -LL | | fn(&'y u32)) } - | |__________________________________________- in this macro invocation - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/hrtb/hrtb-debruijn-in-receiver.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/hrtb/hrtb-debruijn-in-receiver.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/hrtb/hrtb-debruijn-in-receiver.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/hrtb/hrtb-debruijn-in-receiver.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^^ | | | second mutable borrow occurs here - | borrow later used here + | first borrow later used here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/hygiene/fields-numeric-borrowck.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/hygiene/fields-numeric-borrowck.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/hygiene/fields-numeric-borrowck.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/hygiene/fields-numeric-borrowck.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^^^^^^^^^^^^^^ second mutable borrow occurs here ... LL | borrow1.use_mut(); - | ------- borrow later used here + | ------- first borrow later used here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/hygiene/no_implicit_prelude-2018.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/hygiene/no_implicit_prelude-2018.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/hygiene/no_implicit_prelude-2018.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/hygiene/no_implicit_prelude-2018.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// edition:2018 + +#[no_implicit_prelude] +mod bar { + fn f() { + ::std::print!(""); // OK + print!(); //~ ERROR cannot find macro `print!` in this scope + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/hygiene/no_implicit_prelude-2018.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/hygiene/no_implicit_prelude-2018.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/hygiene/no_implicit_prelude-2018.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/hygiene/no_implicit_prelude-2018.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: cannot find macro `print!` in this scope + --> $DIR/no_implicit_prelude-2018.rs:7:9 + | +LL | print!(); //~ ERROR cannot find macro `print!` in this scope + | ^^^^^ + | + = help: have you added the `#[macro_use]` on the module/import? + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/hygiene/no_implicit_prelude.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/hygiene/no_implicit_prelude.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/hygiene/no_implicit_prelude.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/hygiene/no_implicit_prelude.rs 2018-12-04 23:41:40.000000000 +0000 @@ -21,7 +21,10 @@ Vec::new(); //~ ERROR failed to resolve ().clone() //~ ERROR no method named `clone` found } - fn f() { ::foo::m!(); } + fn f() { + ::foo::m!(); + println!(); // OK on 2015 edition (at least for now) + } } fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/hygiene/no_implicit_prelude.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/hygiene/no_implicit_prelude.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/hygiene/no_implicit_prelude.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/hygiene/no_implicit_prelude.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,11 +1,11 @@ -error[E0433]: failed to resolve. Use of undeclared type or module `Vec` +error[E0433]: failed to resolve: use of undeclared type or module `Vec` --> $DIR/no_implicit_prelude.rs:21:9 | LL | fn f() { ::bar::m!(); } | ------------ in this macro invocation ... LL | Vec::new(); //~ ERROR failed to resolve - | ^^^ Use of undeclared type or module `Vec` + | ^^^ use of undeclared type or module `Vec` error[E0599]: no method named `clone` found for type `()` in the current scope --> $DIR/no_implicit_prelude.rs:22:12 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/hygiene/privacy.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/hygiene/privacy.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/hygiene/privacy.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/hygiene/privacy.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ error[E0603]: function `f` is private - --> $DIR/privacy.rs:26:9 + --> $DIR/privacy.rs:26:14 | LL | foo::f() //~ ERROR `f` is private - | ^^^^^^ + | ^ error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/if/ifmt-bad-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/if/ifmt-bad-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/if/ifmt-bad-arg.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/if/ifmt-bad-arg.rs 2018-12-04 23:41:40.000000000 +0000 @@ -71,4 +71,18 @@ "##); //~^^^ ERROR: there is no argument named `foo` + + // bad syntax in format string with multiple newlines, #53836 + format!("first number: {} +second number: {} +third number: {} +fourth number: {} +fifth number: {} +sixth number: {} +seventh number: {} +eighth number: {} +ninth number: { +tenth number: {}", + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + //~^^ ERROR: invalid format string } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/if/ifmt-bad-arg.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/if/ifmt-bad-arg.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/if/ifmt-bad-arg.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/if/ifmt-bad-arg.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -204,5 +204,11 @@ LL | {foo} | ^^^^^ -error: aborting due to 27 previous errors +error: invalid format string: expected `'}'`, found `'t'` + --> $DIR/ifmt-bad-arg.rs:85:1 + | +LL | tenth number: {}", + | ^ expected `}` in format string + +error: aborting due to 28 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/assoc-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/assoc-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/assoc-type.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/assoc-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,8 +13,6 @@ #![allow(warnings)] -#![feature(impl_header_lifetime_elision)] - trait MyTrait { type Output; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/assoc-type.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/assoc-type.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/assoc-type.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/assoc-type.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,11 +1,11 @@ error[E0106]: missing lifetime specifier - --> $DIR/assoc-type.rs:23:19 + --> $DIR/assoc-type.rs:21:19 | LL | type Output = &i32; | ^ expected lifetime parameter error[E0106]: missing lifetime specifier - --> $DIR/assoc-type.rs:28:20 + --> $DIR/assoc-type.rs:26:20 | LL | type Output = &'_ i32; | ^^ expected lifetime parameter diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/dyn-trait.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/dyn-trait.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/dyn-trait.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/dyn-trait.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -error: borrowed data escapes outside of function - --> $DIR/dyn-trait.rs:32:5 - | -LL | fn with_dyn_debug_static<'a>(x: Box) { - | - `x` is a reference that is only valid in the function body -LL | static_val(x); //~ ERROR cannot infer - | ^^^^^^^^^^^^^ `x` escapes the function body here - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/dyn-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/dyn-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/dyn-trait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/dyn-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,8 +13,6 @@ #![allow(warnings)] -#![feature(impl_header_lifetime_elision)] - use std::fmt::Debug; // Equivalent to `Box`: diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,11 +1,11 @@ error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements - --> $DIR/dyn-trait.rs:32:16 + --> $DIR/dyn-trait.rs:30:16 | LL | static_val(x); //~ ERROR cannot infer | ^ | -note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 31:26... - --> $DIR/dyn-trait.rs:31:26 +note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 29:26... + --> $DIR/dyn-trait.rs:29:26 | LL | fn with_dyn_debug_static<'a>(x: Box) { | ^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/explicit-and-elided-same-header.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/explicit-and-elided-same-header.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/explicit-and-elided-same-header.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/explicit-and-elided-same-header.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +#![allow(warnings)] + +// This works for functions... +fn foo<'a>(x: &str, y: &'a str) {} + +// ...so this should work for impls +impl<'a> Foo<&str> for &'a str {} +trait Foo {} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/inherent-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/inherent-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/inherent-impl.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/inherent-impl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass + +struct Foo<'a>(&'a u8); + +impl Foo<'_> { + fn x() {} +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/path-elided.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/path-elided.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/path-elided.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/path-elided.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,8 +9,6 @@ // except according to those terms. #![allow(warnings)] -#![feature(impl_header_lifetime_elision)] - trait MyTrait { } struct Foo<'a> { x: &'a u32 } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/path-elided.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/path-elided.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/path-elided.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/path-elided.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error[E0106]: missing lifetime specifier - --> $DIR/path-elided.rs:18:18 + --> $DIR/path-elided.rs:16:18 | LL | impl MyTrait for Foo { | ^^^ expected lifetime parameter diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/path-underscore.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/path-underscore.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/path-underscore.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/path-underscore.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,8 +14,6 @@ #![allow(warnings)] -#![feature(impl_header_lifetime_elision)] - trait MyTrait { } struct Foo<'a> { x: &'a u32 } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/ref-underscore.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/ref-underscore.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/ref-underscore.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/ref-underscore.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,8 +14,6 @@ #![allow(warnings)] -#![feature(impl_header_lifetime_elision)] - trait MyTrait { } impl MyTrait for &i32 { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/trait-elided.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/trait-elided.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/trait-elided.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/trait-elided.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,8 +9,6 @@ // except according to those terms. #![allow(warnings)] -#![feature(impl_header_lifetime_elision)] - trait MyTrait<'a> { } impl MyTrait for u32 { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/trait-elided.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/trait-elided.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/trait-elided.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/trait-elided.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error[E0106]: missing lifetime specifier - --> $DIR/trait-elided.rs:16:6 + --> $DIR/trait-elided.rs:14:6 | LL | impl MyTrait for u32 { | ^^^^^^^ expected lifetime parameter diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/trait-underscore.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/trait-underscore.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/trait-underscore.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-header-lifetime-elision/trait-underscore.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,8 +15,6 @@ #![allow(warnings)] -#![feature(impl_header_lifetime_elision)] - trait MyTrait<'a> { } // This is equivalent to `MyTrait<'a> for &'b i32`, which is proven by diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/bindings-opaque.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/bindings-opaque.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/bindings-opaque.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/bindings-opaque.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(impl_trait_in_bindings)] + +const FOO: impl Copy = 42; + +static BAR: impl Copy = 42; + +fn main() { + let foo: impl Copy = 42; + + let _ = FOO.count_ones(); + let _ = BAR.count_ones(); + let _ = foo.count_ones(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/bindings-opaque.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/bindings-opaque.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/bindings-opaque.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/bindings-opaque.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +error[E0599]: no method named `count_ones` found for type `impl std::marker::Copy` in the current scope + --> $DIR/bindings-opaque.rs:20:17 + | +LL | let _ = FOO.count_ones(); + | ^^^^^^^^^^ + +error[E0599]: no method named `count_ones` found for type `impl std::marker::Copy` in the current scope + --> $DIR/bindings-opaque.rs:21:17 + | +LL | let _ = BAR.count_ones(); + | ^^^^^^^^^^ + +error[E0599]: no method named `count_ones` found for type `impl std::marker::Copy` in the current scope + --> $DIR/bindings-opaque.rs:22:17 + | +LL | let _ = foo.count_ones(); + | ^^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0599`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/bindings.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/bindings.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/bindings.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/bindings.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(impl_trait_in_bindings)] + +fn a(x: T) { + const foo: impl Clone = x; +} + +fn b(x: T) { + let _ = move || { + const foo: impl Clone = x; + }; +} + +trait Foo { + fn a(x: T) { + const foo: impl Clone = x; + } +} + +impl Foo for i32 { + fn a(x: T) { + const foo: impl Clone = x; + } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/bindings.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/bindings.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/bindings.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/bindings.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +error[E0434]: can't capture dynamic environment in a fn item + --> $DIR/bindings.rs:14:29 + | +LL | const foo: impl Clone = x; + | ^ + | + = help: use the `|| { ... }` closure form instead + +error[E0434]: can't capture dynamic environment in a fn item + --> $DIR/bindings.rs:19:33 + | +LL | const foo: impl Clone = x; + | ^ + | + = help: use the `|| { ... }` closure form instead + +error[E0434]: can't capture dynamic environment in a fn item + --> $DIR/bindings.rs:25:33 + | +LL | const foo: impl Clone = x; + | ^ + | + = help: use the `|| { ... }` closure form instead + +error[E0434]: can't capture dynamic environment in a fn item + --> $DIR/bindings.rs:31:33 + | +LL | const foo: impl Clone = x; + | ^ + | + = help: use the `|| { ... }` closure form instead + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0434`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/closure-calling-parent-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/closure-calling-parent-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/closure-calling-parent-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/closure-calling-parent-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +#![feature(nll)] + +// Regression test for #54593: the MIR type checker was going wrong +// when a closure returns the `impl Copy` from its parent fn. It was +// (incorrectly) replacing the `impl Copy` in its return type with the +// hidden type (`()`) but that type resulted from a recursive call to +// `foo` and hence is treated opaquely within the closure body. This +// resulted in a failed subtype relationship. +// +// run-pass + +fn foo() -> impl Copy { || foo(); } +fn bar() -> impl Copy { || bar(); } +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/deprecated_annotation.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/deprecated_annotation.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/deprecated_annotation.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/deprecated_annotation.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// compile-pass + +#![deny(warnings)] + +#[deprecated] +trait Deprecated {} + +#[deprecated] +struct DeprecatedTy; + +#[allow(deprecated)] +impl Deprecated for DeprecatedTy {} + +#[allow(deprecated)] +fn foo() -> impl Deprecated { DeprecatedTy } + +fn main() { + foo(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/existential-minimal.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/existential-minimal.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/existential-minimal.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/existential-minimal.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass + +fn main() {} + +fn foo() -> impl std::fmt::Debug { "cake" } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/impl_trait_projections.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/impl_trait_projections.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/impl_trait_projections.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/impl_trait_projections.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -26,9 +26,7 @@ --> $DIR/impl_trait_projections.rs:21:50 | LL | fn projection_is_disallowed(x: impl Iterator) -> ::Item { - | ^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `::Item` + | ^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `::Item` error: aborting due to 5 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/issue-42479.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/issue-42479.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/issue-42479.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/issue-42479.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass + +use std::iter::once; + +struct Foo { + x: i32, +} + +impl Foo { + fn inside(&self) -> impl Iterator { + once(&self.x) + } +} + +fn main() { + println!("hi"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/issue-49376.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/issue-49376.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/issue-49376.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/issue-49376.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass + +// Tests for nested self-reference which caused a stack overflow. + +use std::fmt::Debug; +use std::ops::*; + +fn gen() -> impl PartialOrd + PartialEq + Debug { } + +struct Bar {} +trait Foo {} +impl Foo for Bar {} + +fn foo() -> impl Foo { + Bar {} +} + +fn test_impl_ops() -> impl Add + Sub + Mul + Div { 1 } +fn test_impl_assign_ops() -> impl AddAssign + SubAssign + MulAssign + DivAssign { 1 } + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/must_outlive_least_region_or_bound.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -error[E0621]: explicit lifetime required in the type of `x` - --> $DIR/must_outlive_least_region_or_bound.rs:13:35 - | -LL | fn elided(x: &i32) -> impl Copy { x } - | ---- ^ lifetime `'static` required - | | - | help: add explicit lifetime `'static` to the type of `x`: `&'static i32` - -error: unsatisfied lifetime constraints - --> $DIR/must_outlive_least_region_or_bound.rs:16:44 - | -LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x } - | -- lifetime `'a` defined here ^ returning this value requires that `'a` must outlive `'static` - -error: unsatisfied lifetime constraints - --> $DIR/must_outlive_least_region_or_bound.rs:22:69 - | -LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x } - | -- lifetime `'a` defined here ^ returning this value requires that `'a` must outlive `'static` - -error: unsatisfied lifetime constraints - --> $DIR/must_outlive_least_region_or_bound.rs:29:5 - | -LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32) { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | //~^ ERROR lifetime mismatch -LL | move |_| println!("{}", y) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` - -error[E0310]: the parameter type `T` may not live long enough - --> $DIR/must_outlive_least_region_or_bound.rs:34:5 - | -LL | x - | ^ - | - = help: consider adding an explicit lifetime bound `T: 'static`... - -error: aborting due to 5 previous errors - -Some errors occurred: E0310, E0621. -For more information about an error, try `rustc --explain E0310`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/static-return-lifetime-infered.rs:17:9 - | -LL | fn iter_values_anon(&self) -> impl Iterator { - | - let's call the lifetime of this reference `'1` -LL | self.x.iter().map(|a| a.0) - | ^^^^^^ cast requires that `'1` must outlive `'static` - -error: unsatisfied lifetime constraints - --> $DIR/static-return-lifetime-infered.rs:21:9 - | -LL | fn iter_values<'a>(&'a self) -> impl Iterator { - | -- lifetime `'a` defined here -LL | self.x.iter().map(|a| a.0) - | ^^^^^^ cast requires that `'a` must outlive `'static` - -error: aborting due to 2 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/type_parameters_captured.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/type_parameters_captured.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/type_parameters_captured.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/type_parameters_captured.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error[E0310]: the parameter type `T` may not live long enough - --> $DIR/type_parameters_captured.rs:19:5 - | -LL | x - | ^ - | - = help: consider adding an explicit lifetime bound `T: 'static`... - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0310`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/where-allowed.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/where-allowed.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/where-allowed.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/where-allowed.rs 2018-12-04 23:41:40.000000000 +0000 @@ -232,4 +232,3 @@ let _in_return_in_local_variable = || -> impl Fn() { || {} }; //~^ ERROR `impl Trait` not allowed outside of function and inherent method return types } - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/where-allowed.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/where-allowed.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/impl-trait/where-allowed.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/impl-trait/where-allowed.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -231,6 +231,8 @@ | LL | let _in_local_variable: impl Fn() = || {}; | ^^^^^^^^^ + | + = help: add #![feature(impl_trait_in_bindings)] to the crate attributes to enable error[E0562]: `impl Trait` not allowed outside of function and inherent method return types --> $DIR/where-allowed.rs:232:46 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/import2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/import2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/import2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/import2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,7 +9,7 @@ // except according to those terms. use baz::zed::bar; //~ ERROR unresolved import `baz::zed` [E0432] - //~^ Could not find `zed` in `baz` + //~^ could not find `zed` in `baz` mod baz {} mod zed { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/import2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/import2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/import2.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/import2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/import2.rs:11:10 | LL | use baz::zed::bar; //~ ERROR unresolved import `baz::zed` [E0432] - | ^^^ Could not find `zed` in `baz` + | ^^^ could not find `zed` in `baz` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/import3.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/import3.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/import3.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/import3.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/import3.rs:12:5 | LL | use main::bar; - | ^^^^ Maybe a missing `extern crate main;`? + | ^^^^ maybe a missing `extern crate main;`? error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/auxiliary/glob-conflict.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/auxiliary/glob-conflict.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/auxiliary/glob-conflict.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/auxiliary/glob-conflict.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +mod m1 { + pub fn f() {} +} +mod m2 { + pub fn f(_: u8) {} +} + +pub use m1::*; +pub use m2::*; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/auxiliary/issue-55811.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/auxiliary/issue-55811.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/auxiliary/issue-55811.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/auxiliary/issue-55811.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,5 @@ +mod m {} + +// These two imports should not conflict when this crate is loaded from some other crate. +use m::{}; +use m::{}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/auxiliary/issue-56125.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/auxiliary/issue-56125.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/auxiliary/issue-56125.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/auxiliary/issue-56125.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +pub mod issue_56125 {} + +pub mod last_segment { + pub mod issue_56125 {} +} + +pub mod non_last_segment { + pub mod non_last_segment { + pub mod issue_56125 {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/duplicate.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/duplicate.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/duplicate.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/duplicate.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,82 +7,86 @@ | ^^^^^^ `foo` reimported 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 +help: you can use `as` to change the binding name of the import | LL | use a::foo as other_foo; //~ ERROR the name `foo` is defined multiple times | ^^^^^^^^^^^^^^^^^^^ -error[E0659]: `foo` is ambiguous +error[E0659]: `foo` is ambiguous (glob import vs glob import in the same module) --> $DIR/duplicate.rs:56:15 | LL | use self::foo::bar; //~ ERROR `foo` is ambiguous | ^^^ ambiguous name | -note: `foo` could refer to the name imported here +note: `foo` could refer to the module imported here --> $DIR/duplicate.rs:53:9 | LL | use self::m1::*; | ^^^^^^^^^^^ -note: `foo` could also refer to the name imported here + = help: consider adding an explicit import of `foo` to disambiguate +note: `foo` could also refer to the module imported here --> $DIR/duplicate.rs:54:9 | LL | use self::m2::*; | ^^^^^^^^^^^ - = note: consider adding an explicit import of `foo` to disambiguate + = help: consider adding an explicit import of `foo` to disambiguate -error[E0659]: `foo` is ambiguous +error[E0659]: `foo` is ambiguous (glob import vs glob import in the same module) --> $DIR/duplicate.rs:45:8 | LL | f::foo(); //~ ERROR `foo` is ambiguous | ^^^ ambiguous name | -note: `foo` could refer to the name imported here +note: `foo` could refer to the function imported here --> $DIR/duplicate.rs:34:13 | LL | pub use a::*; | ^^^^ -note: `foo` could also refer to the name imported here + = help: consider adding an explicit import of `foo` to disambiguate +note: `foo` could also refer to the function imported here --> $DIR/duplicate.rs:35:13 | LL | pub use b::*; | ^^^^ - = note: consider adding an explicit import of `foo` to disambiguate + = help: consider adding an explicit import of `foo` to disambiguate -error[E0659]: `foo` is ambiguous +error[E0659]: `foo` is ambiguous (glob import vs glob import in the same module) --> $DIR/duplicate.rs:46:8 | LL | g::foo(); //~ ERROR `foo` is ambiguous | ^^^ ambiguous name | -note: `foo` could refer to the name imported here +note: `foo` could refer to the function imported here --> $DIR/duplicate.rs:39:13 | LL | pub use a::*; | ^^^^ -note: `foo` could also refer to the name imported here + = help: consider adding an explicit import of `foo` to disambiguate +note: `foo` could also refer to the unresolved item imported here --> $DIR/duplicate.rs:40:13 | LL | pub use f::*; | ^^^^ - = note: consider adding an explicit import of `foo` to disambiguate + = help: consider adding an explicit import of `foo` to disambiguate -error[E0659]: `foo` is ambiguous +error[E0659]: `foo` is ambiguous (glob import vs glob import in the same module) --> $DIR/duplicate.rs:59:9 | LL | foo::bar(); //~ ERROR `foo` is ambiguous | ^^^ ambiguous name | -note: `foo` could refer to the name imported here +note: `foo` could refer to the module imported here --> $DIR/duplicate.rs:53:9 | LL | use self::m1::*; | ^^^^^^^^^^^ -note: `foo` could also refer to the name imported here + = help: consider adding an explicit import of `foo` to disambiguate +note: `foo` could also refer to the module imported here --> $DIR/duplicate.rs:54:9 | LL | use self::m2::*; | ^^^^^^^^^^^ - = note: consider adding an explicit import of `foo` to disambiguate + = help: consider adding an explicit import of `foo` to disambiguate error: aborting due to 5 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-absolute-expanded.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-absolute-expanded.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-absolute-expanded.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-absolute-expanded.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// compile-pass +// edition:2018 + +macro_rules! define_iso { () => { + extern crate std as iso; +}} + +::iso::thread_local! { + static S: u8 = 0; +} + +define_iso!(); + +fn main() { + let s = S; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-cfg.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-cfg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-cfg.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-cfg.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// compile-pass +// compile-flags:--cfg my_feature + +#![no_std] + +#[cfg(my_feature)] +extern crate std; + +mod m { + #[cfg(my_feature)] + fn conditional() { + std::vec::Vec::::new(); // OK + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-fail.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-fail.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-fail.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-fail.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// aux-build:two_macros.rs +// compile-flags:--extern non_existent + +mod n { + extern crate two_macros; +} + +mod m { + fn check() { + two_macros::m!(); //~ ERROR failed to resolve: use of undeclared type or module `two_macros` + } +} + +macro_rules! define_std_as_non_existent { + () => { + extern crate std as non_existent; + //~^ ERROR `extern crate` items cannot shadow names passed with `--extern` + } +} +define_std_as_non_existent!(); + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-fail.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-fail.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-fail.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-fail.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +error: macro-expanded `extern crate` items cannot shadow names passed with `--extern` + --> $DIR/extern-prelude-extern-crate-fail.rs:16:9 + | +LL | extern crate std as non_existent; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | define_std_as_non_existent!(); + | ------------------------------ in this macro invocation + +error[E0433]: failed to resolve: use of undeclared type or module `two_macros` + --> $DIR/extern-prelude-extern-crate-fail.rs:10:9 + | +LL | two_macros::m!(); //~ ERROR failed to resolve: use of undeclared type or module `two_macros` + | ^^^^^^^^^^ use of undeclared type or module `two_macros` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0433`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-pass.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-pass.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-pass.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-pass.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +// compile-pass +// aux-build:two_macros.rs + +extern crate two_macros; + +mod m { + fn check() { + two_macros::m!(); // OK + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// aux-build:two_macros.rs + +macro_rules! define_vec { + () => { + extern crate std as Vec; + } +} + +define_vec!(); + +mod m { + fn check() { + Vec::panic!(); //~ ERROR `Vec` is ambiguous + } +} + +macro_rules! define_other_core { + () => { + extern crate std as core; + //~^ ERROR macro-expanded `extern crate` items cannot shadow names passed with `--extern` + } +} + +define_other_core!(); + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +error: macro-expanded `extern crate` items cannot shadow names passed with `--extern` + --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:19:9 + | +LL | extern crate std as core; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | define_other_core!(); + | --------------------- in this macro invocation + +error[E0659]: `Vec` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) + --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:13:9 + | +LL | Vec::panic!(); //~ ERROR `Vec` is ambiguous + | ^^^ ambiguous name + | + = note: `Vec` could refer to a struct from prelude +note: `Vec` could also refer to the extern crate imported here + --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:5:9 + | +LL | extern crate std as Vec; + | ^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | define_vec!(); + | -------------- in this macro invocation + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0659`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-shadowing.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-shadowing.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-shadowing.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/extern-prelude-extern-crate-shadowing.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +// compile-pass +// aux-build:two_macros.rs + +extern crate two_macros as core; + +mod m { + fn check() { + core::m!(); // OK + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/glob-conflict-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/glob-conflict-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/glob-conflict-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/glob-conflict-cross-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,7 @@ +// aux-build:glob-conflict.rs + +extern crate glob_conflict; + +fn main() { + glob_conflict::f(); //~ ERROR cannot find function `f` in module `glob_conflict` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/glob-conflict-cross-crate.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/glob-conflict-cross-crate.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/glob-conflict-cross-crate.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/glob-conflict-cross-crate.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0425]: cannot find function `f` in module `glob_conflict` + --> $DIR/glob-conflict-cross-crate.rs:6:20 + | +LL | glob_conflict::f(); //~ ERROR cannot find function `f` in module `glob_conflict` + | ^ not found in `glob_conflict` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/glob-shadowing.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/glob-shadowing.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/glob-shadowing.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/glob-shadowing.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,48 +1,50 @@ -error[E0659]: `env` is ambiguous +error[E0659]: `env` is ambiguous (glob import vs any other name from outer scope during import/macro resolution) --> $DIR/glob-shadowing.rs:21:17 | LL | let x = env!("PATH"); //~ ERROR `env` is ambiguous | ^^^ ambiguous name | -note: `env` could refer to the name imported here + = note: `env` could refer to a built-in macro +note: `env` could also refer to the macro imported here --> $DIR/glob-shadowing.rs:19:9 | LL | use m::*; | ^^^^ - = note: `env` is also a builtin macro - = note: consider adding an explicit import of `env` to disambiguate + = help: consider adding an explicit import of `env` to disambiguate + = help: or use `self::env` to refer to this macro unambiguously -error[E0659]: `env` is ambiguous +error[E0659]: `env` is ambiguous (glob import vs any other name from outer scope during import/macro resolution) --> $DIR/glob-shadowing.rs:29:21 | LL | let x = env!("PATH"); //~ ERROR `env` is ambiguous | ^^^ ambiguous name | -note: `env` could refer to the name imported here + = note: `env` could refer to a built-in macro +note: `env` could also refer to the macro imported here --> $DIR/glob-shadowing.rs:27:13 | LL | use m::*; | ^^^^ - = note: `env` is also a builtin macro - = note: consider adding an explicit import of `env` to disambiguate + = help: consider adding an explicit import of `env` to disambiguate -error[E0659]: `fenv` is ambiguous +error[E0659]: `fenv` is ambiguous (glob import vs any other name from outer scope during import/macro resolution) --> $DIR/glob-shadowing.rs:39:21 | LL | let x = fenv!(); //~ ERROR `fenv` is ambiguous | ^^^^ ambiguous name | -note: `fenv` could refer to the name imported here +note: `fenv` could refer to the macro imported here --> $DIR/glob-shadowing.rs:37:13 | LL | use m::*; | ^^^^ -note: `fenv` could also refer to the name defined here + = help: consider adding an explicit import of `fenv` to disambiguate +note: `fenv` could also refer to the macro defined here --> $DIR/glob-shadowing.rs:35:5 | LL | pub macro fenv($e: expr) { $e } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: consider adding an explicit import of `fenv` to disambiguate + = help: use `self::fenv` to refer to this macro unambiguously error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/issue-53269.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/issue-53269.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/issue-53269.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/issue-53269.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,24 +2,25 @@ --> $DIR/issue-53269.rs:16:9 | LL | use nonexistent_module::mac; //~ ERROR unresolved import `nonexistent_module` - | ^^^^^^^^^^^^^^^^^^ Maybe a missing `extern crate nonexistent_module;`? + | ^^^^^^^^^^^^^^^^^^ maybe a missing `extern crate nonexistent_module;`? -error[E0659]: `mac` is ambiguous +error[E0659]: `mac` is ambiguous (`macro_rules` vs non-`macro_rules` from other module) --> $DIR/issue-53269.rs:18:5 | LL | mac!(); //~ ERROR `mac` is ambiguous | ^^^ ambiguous name | -note: `mac` could refer to the name defined here +note: `mac` could refer to the macro defined here --> $DIR/issue-53269.rs:13:1 | LL | macro_rules! mac { () => () } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: `mac` could also refer to the name imported here +note: `mac` could also refer to the unresolved item imported here --> $DIR/issue-53269.rs:16:9 | LL | use nonexistent_module::mac; //~ ERROR unresolved import `nonexistent_module` | ^^^^^^^^^^^^^^^^^^^^^^^ + = help: use `self::mac` to refer to this unresolved item unambiguously error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/issue-55811.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/issue-55811.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/issue-55811.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/issue-55811.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,6 @@ +// compile-pass +// aux-build:issue-55811.rs + +extern crate issue_55811; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/issue-55884-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/issue-55884-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/issue-55884-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/issue-55884-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +mod m { + mod m1 { + pub struct S {} + } + mod m2 { + // Note this derive, it makes this struct macro-expanded, + // so it doesn't appear in time to participate in the initial resolution of `use m::S`, + // only in the later validation pass. + #[derive(Default)] + pub struct S {} + } + + // Create a glob vs glob ambiguity + pub use self::m1::*; + pub use self::m2::*; +} + +fn main() { + use m::S; //~ ERROR `S` is ambiguous + let s = S {}; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/issue-55884-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/issue-55884-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/issue-55884-1.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/issue-55884-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +error[E0659]: `S` is ambiguous (glob import vs glob import in the same module) + --> $DIR/issue-55884-1.rs:19:12 + | +LL | use m::S; //~ ERROR `S` is ambiguous + | ^ ambiguous name + | +note: `S` could refer to the struct imported here + --> $DIR/issue-55884-1.rs:14:13 + | +LL | pub use self::m1::*; + | ^^^^^^^^^^^ + = help: consider adding an explicit import of `S` to disambiguate +note: `S` could also refer to the struct imported here + --> $DIR/issue-55884-1.rs:15:13 + | +LL | pub use self::m2::*; + | ^^^^^^^^^^^ + = help: consider adding an explicit import of `S` to disambiguate + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0659`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/issue-55884-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/issue-55884-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/issue-55884-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/issue-55884-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +mod options { + pub struct ParseOptions {} +} + +mod parser { + pub use options::*; + // Private single import shadows public glob import, but arrives too late for initial + // resolution of `use parser::ParseOptions` because it depends on that resolution itself. + use ParseOptions; +} + +pub use parser::ParseOptions; //~ ERROR struct `ParseOptions` is private + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/issue-55884-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/issue-55884-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/issue-55884-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/issue-55884-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0603]: struct `ParseOptions` is private + --> $DIR/issue-55884-2.rs:12:17 + | +LL | pub use parser::ParseOptions; //~ ERROR struct `ParseOptions` is private + | ^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0603`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/issue-56125.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/issue-56125.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/issue-56125.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/issue-56125.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// edition:2018 +// compile-flags:--extern issue_56125 +// aux-build:issue-56125.rs + +#![feature(uniform_paths)] + +mod m1 { + use issue_56125::last_segment::*; + //~^ ERROR `issue_56125` is ambiguous + //~| ERROR unresolved import `issue_56125::last_segment` +} + +mod m2 { + use issue_56125::non_last_segment::non_last_segment::*; + //~^ ERROR `issue_56125` is ambiguous + //~| ERROR failed to resolve: could not find `non_last_segment` in `issue_56125` +} + +mod m3 { + mod empty {} + use empty::issue_56125; //~ ERROR unresolved import `empty::issue_56125` + use issue_56125::*; //~ ERROR `issue_56125` is ambiguous +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/issue-56125.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/issue-56125.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/issue-56125.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/issue-56125.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,67 @@ +error[E0433]: failed to resolve: could not find `non_last_segment` in `issue_56125` + --> $DIR/issue-56125.rs:14:22 + | +LL | use issue_56125::non_last_segment::non_last_segment::*; + | ^^^^^^^^^^^^^^^^ could not find `non_last_segment` in `issue_56125` + +error[E0432]: unresolved import `issue_56125::last_segment` + --> $DIR/issue-56125.rs:8:22 + | +LL | use issue_56125::last_segment::*; + | ^^^^^^^^^^^^ could not find `last_segment` in `issue_56125` + +error[E0432]: unresolved import `empty::issue_56125` + --> $DIR/issue-56125.rs:21:9 + | +LL | use empty::issue_56125; //~ ERROR unresolved import `empty::issue_56125` + | ^^^^^^^^^^^^^^^^^^ no `issue_56125` in `m3::empty` + +error[E0659]: `issue_56125` is ambiguous (name vs any other name during import resolution) + --> $DIR/issue-56125.rs:8:9 + | +LL | use issue_56125::last_segment::*; + | ^^^^^^^^^^^ ambiguous name + | + = note: `issue_56125` could refer to an extern crate passed with `--extern` + = help: use `::issue_56125` to refer to this extern crate unambiguously +note: `issue_56125` could also refer to the module imported here + --> $DIR/issue-56125.rs:8:9 + | +LL | use issue_56125::last_segment::*; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: use `self::issue_56125` to refer to this module unambiguously + +error[E0659]: `issue_56125` is ambiguous (name vs any other name during import resolution) + --> $DIR/issue-56125.rs:14:9 + | +LL | use issue_56125::non_last_segment::non_last_segment::*; + | ^^^^^^^^^^^ ambiguous name + | + = note: `issue_56125` could refer to an extern crate passed with `--extern` + = help: use `::issue_56125` to refer to this extern crate unambiguously +note: `issue_56125` could also refer to the module imported here + --> $DIR/issue-56125.rs:14:9 + | +LL | use issue_56125::non_last_segment::non_last_segment::*; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: use `self::issue_56125` to refer to this module unambiguously + +error[E0659]: `issue_56125` is ambiguous (name vs any other name during import resolution) + --> $DIR/issue-56125.rs:22:9 + | +LL | use issue_56125::*; //~ ERROR `issue_56125` is ambiguous + | ^^^^^^^^^^^ ambiguous name + | + = note: `issue_56125` could refer to an extern crate passed with `--extern` + = help: use `::issue_56125` to refer to this extern crate unambiguously +note: `issue_56125` could also refer to the unresolved item imported here + --> $DIR/issue-56125.rs:21:9 + | +LL | use empty::issue_56125; //~ ERROR unresolved import `empty::issue_56125` + | ^^^^^^^^^^^^^^^^^^ + = help: use `self::issue_56125` to refer to this unresolved item unambiguously + +error: aborting due to 6 previous errors + +Some errors occurred: E0432, E0433, E0659. +For more information about an error, try `rustc --explain E0432`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/issue-56263.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/issue-56263.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/issue-56263.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/issue-56263.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +// compile-pass +// edition:2018 + +use ::std; + +fn main() { + let std = 10; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/local-modularized-tricky-fail-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/local-modularized-tricky-fail-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/local-modularized-tricky-fail-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/local-modularized-tricky-fail-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -43,6 +43,7 @@ fn main() { panic!(); //~ ERROR `panic` is ambiguous + //~| ERROR `panic` is ambiguous } mod inner3 { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/local-modularized-tricky-fail-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/local-modularized-tricky-fail-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/local-modularized-tricky-fail-1.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/local-modularized-tricky-fail-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,10 +1,10 @@ -error[E0659]: `exported` is ambiguous +error[E0659]: `exported` is ambiguous (glob import vs macro-expanded name in the same module during import/macro resolution) --> $DIR/local-modularized-tricky-fail-1.rs:38:1 | LL | exported!(); //~ ERROR `exported` is ambiguous | ^^^^^^^^ ambiguous name | -note: `exported` could refer to the name defined here +note: `exported` could refer to the macro defined here --> $DIR/local-modularized-tricky-fail-1.rs:15:5 | LL | / macro_rules! exported { @@ -14,20 +14,21 @@ ... LL | define_exported!(); | ------------------- in this macro invocation -note: `exported` could also refer to the name imported here +note: `exported` could also refer to the macro imported here --> $DIR/local-modularized-tricky-fail-1.rs:32:5 | LL | use inner1::*; | ^^^^^^^^^ - = note: macro-expanded macros do not shadow + = help: consider adding an explicit import of `exported` to disambiguate -error[E0659]: `include` is ambiguous - --> $DIR/local-modularized-tricky-fail-1.rs:56:1 +error[E0659]: `include` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) + --> $DIR/local-modularized-tricky-fail-1.rs:57:1 | LL | include!(); //~ ERROR `include` is ambiguous | ^^^^^^^ ambiguous name | -note: `include` could refer to the name defined here + = note: `include` could refer to a built-in macro +note: `include` could also refer to the macro defined here --> $DIR/local-modularized-tricky-fail-1.rs:27:5 | LL | / macro_rules! include { @@ -37,16 +38,16 @@ ... LL | define_include!(); | ------------------ in this macro invocation - = note: `include` is also a builtin macro - = note: macro-expanded macros do not shadow + = help: use `crate::include` to refer to this macro unambiguously -error[E0659]: `panic` is ambiguous +error[E0659]: `panic` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) --> $DIR/local-modularized-tricky-fail-1.rs:45:5 | LL | panic!(); //~ ERROR `panic` is ambiguous | ^^^^^ ambiguous name | -note: `panic` could refer to the name defined here + = note: `panic` could refer to a macro from prelude +note: `panic` could also refer to the macro defined here --> $DIR/local-modularized-tricky-fail-1.rs:21:5 | LL | / macro_rules! panic { @@ -56,16 +57,16 @@ ... LL | define_panic!(); | ---------------- in this macro invocation - = note: `panic` is also a builtin macro - = note: macro-expanded macros do not shadow + = help: use `crate::panic` to refer to this macro unambiguously -error[E0659]: `panic` is ambiguous - --> <::std::macros::panic macros>:1:13 +error[E0659]: `panic` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) + --> $DIR/local-modularized-tricky-fail-1.rs:45:5 | -LL | ( ) => ( { panic ! ( "explicit panic" ) } ) ; ( $ msg : expr ) => ( - | ^^^^^ ambiguous name +LL | panic!(); //~ ERROR `panic` is ambiguous + | ^^^^^^^^^ ambiguous name | -note: `panic` could refer to the name defined here + = note: `panic` could refer to a macro from prelude +note: `panic` could also refer to the macro defined here --> $DIR/local-modularized-tricky-fail-1.rs:21:5 | LL | / macro_rules! panic { @@ -75,8 +76,8 @@ ... LL | define_panic!(); | ---------------- in this macro invocation - = note: `panic` is also a builtin macro - = note: macro-expanded macros do not shadow + = help: use `crate::panic` to refer to this macro unambiguously + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: aborting due to 4 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/macro-paths.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/macro-paths.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/macro-paths.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/macro-paths.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,40 +1,40 @@ -error[E0659]: `bar` is ambiguous +error[E0659]: `bar` is ambiguous (glob import vs macro-expanded name in the same module during import/macro resolution) --> $DIR/macro-paths.rs:23:5 | LL | bar::m! { //~ ERROR ambiguous | ^^^ ambiguous name | -note: `bar` could refer to the name defined here +note: `bar` could refer to the module defined here --> $DIR/macro-paths.rs:24:9 | LL | mod bar { pub use two_macros::m; } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: `bar` could also refer to the name imported here +note: `bar` could also refer to the module imported here --> $DIR/macro-paths.rs:22:9 | LL | use foo::*; | ^^^^^^ - = note: macro-expanded items do not shadow when used in a macro invocation path + = help: consider adding an explicit import of `bar` to disambiguate -error[E0659]: `baz` is ambiguous +error[E0659]: `baz` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) --> $DIR/macro-paths.rs:33:5 | LL | baz::m! { //~ ERROR ambiguous | ^^^ ambiguous name | -note: `baz` could refer to the name defined here +note: `baz` could refer to the module defined here --> $DIR/macro-paths.rs:34:9 | LL | mod baz { pub use two_macros::m; } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: `baz` could also refer to the name defined here +note: `baz` could also refer to the module defined here --> $DIR/macro-paths.rs:28:1 | LL | / pub mod baz { LL | | pub use two_macros::m; LL | | } | |_^ - = note: macro-expanded items do not shadow when used in a macro invocation path + = help: use `crate::baz` to refer to this module unambiguously error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/macros.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/macros.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/macros.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/macros.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,38 +1,38 @@ -error[E0659]: `m` is ambiguous +error[E0659]: `m` is ambiguous (glob import vs macro-expanded name in the same module during import/macro resolution) --> $DIR/macros.rs:26:5 | LL | m! { //~ ERROR ambiguous | ^ ambiguous name | -note: `m` could refer to the name imported here +note: `m` could refer to the macro imported here --> $DIR/macros.rs:27:13 | LL | use foo::m; | ^^^^^^ -note: `m` could also refer to the name imported here +note: `m` could also refer to the macro imported here --> $DIR/macros.rs:25:9 | LL | use two_macros::*; | ^^^^^^^^^^^^^ - = note: macro-expanded macro imports do not shadow + = help: consider adding an explicit import of `m` to disambiguate -error[E0659]: `m` is ambiguous +error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) --> $DIR/macros.rs:39:9 | LL | m! { //~ ERROR ambiguous | ^ ambiguous name | -note: `m` could refer to the name imported here +note: `m` could refer to the macro imported here --> $DIR/macros.rs:40:17 | LL | use two_macros::n as m; | ^^^^^^^^^^^^^^^^^^ -note: `m` could also refer to the name imported here +note: `m` could also refer to the macro imported here --> $DIR/macros.rs:32:9 | LL | use two_macros::m; | ^^^^^^^^^^^^^ - = note: macro-expanded macro imports do not shadow + = help: use `self::m` to refer to this macro unambiguously error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/reexports.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/reexports.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/reexports.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/reexports.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -17,16 +17,16 @@ | ^^^^^^^^ error[E0603]: module `foo` is private - --> $DIR/reexports.rs:38:9 + --> $DIR/reexports.rs:38:15 | LL | use b::a::foo::S; //~ ERROR `foo` - | ^^^^^^^^^^^^ + | ^^^ error[E0603]: module `foo` is private - --> $DIR/reexports.rs:39:9 + --> $DIR/reexports.rs:39:15 | LL | use b::b::foo::S as T; //~ ERROR `foo` - | ^^^^^^^^^^^^^^^^^ + | ^^^ error: aborting due to 4 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/rfc-1560-warning-cycle.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/rfc-1560-warning-cycle.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/rfc-1560-warning-cycle.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/rfc-1560-warning-cycle.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,20 +1,21 @@ -error[E0659]: `Foo` is ambiguous +error[E0659]: `Foo` is ambiguous (glob import vs glob import in the same module) --> $DIR/rfc-1560-warning-cycle.rs:19:17 | LL | fn f(_: Foo) {} //~ ERROR `Foo` is ambiguous | ^^^ ambiguous name | -note: `Foo` could refer to the name imported here +note: `Foo` could refer to the struct imported here --> $DIR/rfc-1560-warning-cycle.rs:17:13 | LL | use *; | ^ -note: `Foo` could also refer to the name imported here + = help: consider adding an explicit import of `Foo` to disambiguate +note: `Foo` could also refer to the struct imported here --> $DIR/rfc-1560-warning-cycle.rs:18:13 | LL | use bar::*; | ^^^^^^ - = note: consider adding an explicit import of `Foo` to disambiguate + = help: consider adding an explicit import of `Foo` to disambiguate error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/shadow_builtin_macros.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/shadow_builtin_macros.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/imports/shadow_builtin_macros.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/imports/shadow_builtin_macros.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,65 +1,66 @@ -error[E0659]: `panic` is ambiguous - --> $DIR/shadow_builtin_macros.rs:43:5 - | -LL | panic!(); //~ ERROR `panic` is ambiguous - | ^^^^^ ambiguous name - | -note: `panic` could refer to the name defined here - --> $DIR/shadow_builtin_macros.rs:40:9 - | -LL | macro_rules! panic { () => {} } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -LL | } } -LL | m!(); - | ----- in this macro invocation - = note: `panic` is also a builtin macro - = note: macro-expanded macros do not shadow - -error[E0659]: `panic` is ambiguous +error[E0659]: `panic` is ambiguous (glob import vs any other name from outer scope during import/macro resolution) --> $DIR/shadow_builtin_macros.rs:25:14 | LL | fn f() { panic!(); } //~ ERROR ambiguous | ^^^^^ ambiguous name | -note: `panic` could refer to the name imported here + = note: `panic` could refer to a macro from prelude +note: `panic` could also refer to the macro imported here --> $DIR/shadow_builtin_macros.rs:24:9 | LL | use foo::*; | ^^^^^^ - = note: `panic` is also a builtin macro - = note: consider adding an explicit import of `panic` to disambiguate + = help: consider adding an explicit import of `panic` to disambiguate + = help: or use `self::panic` to refer to this macro unambiguously -error[E0659]: `panic` is ambiguous +error[E0659]: `panic` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) --> $DIR/shadow_builtin_macros.rs:30:14 | LL | fn f() { panic!(); } //~ ERROR ambiguous | ^^^^^ ambiguous name | -note: `panic` could refer to the name imported here + = note: `panic` could refer to a macro from prelude +note: `panic` could also refer to the macro imported here --> $DIR/shadow_builtin_macros.rs:29:26 | LL | ::two_macros::m!(use foo::panic;); | ^^^^^^^^^^ - = note: `panic` is also a builtin macro - = note: macro-expanded macro imports do not shadow + = help: use `self::panic` to refer to this macro unambiguously + +error[E0659]: `panic` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) + --> $DIR/shadow_builtin_macros.rs:43:5 + | +LL | panic!(); //~ ERROR `panic` is ambiguous + | ^^^^^ ambiguous name + | + = note: `panic` could refer to a macro from prelude +note: `panic` could also refer to the macro defined here + --> $DIR/shadow_builtin_macros.rs:40:9 + | +LL | macro_rules! panic { () => {} } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | } } +LL | m!(); + | ----- in this macro invocation -error[E0659]: `n` is ambiguous +error[E0659]: `n` is ambiguous (glob import vs any other name from outer scope during import/macro resolution) --> $DIR/shadow_builtin_macros.rs:59:5 | LL | n!(); //~ ERROR ambiguous | ^ ambiguous name | -note: `n` could refer to the name imported here +note: `n` could refer to the macro imported here --> $DIR/shadow_builtin_macros.rs:58:9 | LL | use bar::*; | ^^^^^^ -note: `n` could also refer to the name imported here + = help: consider adding an explicit import of `n` to disambiguate + = help: or use `self::n` to refer to this macro unambiguously +note: `n` could also refer to the macro imported here --> $DIR/shadow_builtin_macros.rs:46:13 | LL | #[macro_use(n)] | ^ - = note: consider adding an explicit import of `n` to disambiguate error: aborting due to 4 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/import.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/import.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/import.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/import.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -11,10 +11,10 @@ | ^^^ no `foo` in the root error[E0603]: unresolved item `foo` is private - --> $DIR/import.rs:23:5 + --> $DIR/import.rs:23:10 | LL | zed::foo(); //~ ERROR `foo` is private - | ^^^^^^^^ + | ^^^ error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/in-band-lifetimes/mismatched.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/in-band-lifetimes/mismatched.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/in-band-lifetimes/mismatched.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/in-band-lifetimes/mismatched.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -error[E0621]: explicit lifetime required in the type of `y` - --> $DIR/mismatched.rs:14:42 - | -LL | fn foo(x: &'a u32, y: &u32) -> &'a u32 { y } //~ ERROR explicit lifetime required - | ---- ^ lifetime `'a` required - | | - | help: add explicit lifetime `'a` to the type of `y`: `&'a u32` - -error: unsatisfied lifetime constraints - --> $DIR/mismatched.rs:16:46 - | -LL | fn foo2(x: &'a u32, y: &'b u32) -> &'a u32 { y } //~ ERROR lifetime mismatch - | -- -- ^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` - | | | - | | lifetime `'b` defined here - | lifetime `'a` defined here - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0621`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/inference/inference_unstable.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/inference/inference_unstable.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/inference/inference_unstable.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/inference/inference_unstable.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,5 +8,5 @@ = warning: once this method is added to the standard library, the ambiguity may cause an error or change in behavior! = note: for more information, see issue #48919 = help: call with fully qualified syntax `inference_unstable_itertools::IpuItertools::ipu_flatten(...)` to keep using the current method - = note: add #![feature(ipu_flatten)] to the crate attributes to enable `inference_unstable_iterator::IpuIterator::ipu_flatten` + = help: add #![feature(ipu_flatten)] to the crate attributes to enable `inference_unstable_iterator::IpuIterator::ipu_flatten` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/infinite/infinite-recursion-const-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/infinite/infinite-recursion-const-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/infinite/infinite-recursion-const-fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/infinite/infinite-recursion-const-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,6 @@ //https://github.com/rust-lang/rust/issues/31364 -#![feature(min_const_fn)] const fn a() -> usize { b() } const fn b() -> usize { a() } const ARR: [i32; a()] = [5; 6]; //~ ERROR could not evaluate constant expression diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/infinite/infinite-recursion-const-fn.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/infinite/infinite-recursion-const-fn.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/infinite/infinite-recursion-const-fn.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/infinite/infinite-recursion-const-fn.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error[E0080]: could not evaluate constant expression - --> $DIR/infinite-recursion-const-fn.rs:16:1 + --> $DIR/infinite-recursion-const-fn.rs:15:12 | LL | const fn a() -> usize { b() } | --- @@ -59,7 +59,7 @@ | inside call to `a` | inside call to `a` LL | const ARR: [i32; a()] = [5; 6]; //~ ERROR could not evaluate constant expression - | ^^^^^^^^^^^^^^^^^---^^^^^^^^^^^ + | ^^^^^^---^ | | | inside call to `a` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/inline-asm-bad-constraint.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/inline-asm-bad-constraint.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/inline-asm-bad-constraint.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/inline-asm-bad-constraint.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that the compiler will catch invalid inline assembly constraints. + +#![feature(asm)] + +extern "C" { + fn foo(a: usize); +} + +fn main() { + bad_register_constraint(); + bad_input(); + wrong_size_output(); +} + +// Issue #54130 +fn bad_register_constraint() { + let rax: u64; + unsafe { + asm!("" :"={rax"(rax)) //~ ERROR E0668 + }; + println!("Accumulator is: {}", rax); +} + +// Issue #54376 +fn bad_input() { + unsafe { + asm!("callq $0" : : "0"(foo)) //~ ERROR E0668 + }; +} + +fn wrong_size_output() { + let rax: u64 = 0; + unsafe { + asm!("addb $1, $0" : "={rax}"((0i32, rax))); //~ ERROR E0668 + } + println!("rax: {}", rax); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/inline-asm-bad-constraint.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/inline-asm-bad-constraint.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/inline-asm-bad-constraint.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/inline-asm-bad-constraint.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +error[E0668]: malformed inline assembly + --> $DIR/inline-asm-bad-constraint.rs:29:9 + | +LL | asm!("" :"={rax"(rax)) //~ ERROR E0668 + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0668]: malformed inline assembly + --> $DIR/inline-asm-bad-constraint.rs:37:9 + | +LL | asm!("callq $0" : : "0"(foo)) //~ ERROR E0668 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0668]: malformed inline assembly + --> $DIR/inline-asm-bad-constraint.rs:44:9 + | +LL | asm!("addb $1, $0" : "={rax}"((0i32, rax))); //~ ERROR E0668 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0668`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/inline-asm-bad-operand.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/inline-asm-bad-operand.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/inline-asm-bad-operand.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/inline-asm-bad-operand.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,57 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that the compiler will catch passing invalid values to inline assembly +// operands. + +#![feature(asm)] + +#[repr(C)] +struct MyPtr(usize); + +fn main() { + issue_37433(); + issue_37437(); + issue_40187(); + issue_54067(); +} + +fn issue_37433() { + unsafe { + asm!("" :: "r"("")); //~ ERROR E0669 + } + + unsafe { + let target = MyPtr(0); + asm!("ret" : : "{rdi}"(target)); //~ ERROR E0669 + } +} + +fn issue_37437() { + let hello: &str = "hello"; + // this should fail... + unsafe { asm!("" :: "i"(hello)) }; //~ ERROR E0669 + // but this should succeed. + unsafe { asm!("" :: "r"(hello.as_ptr())) }; +} + +fn issue_40187() { + let arr: [u8; 1] = [0; 1]; + unsafe { + asm!("movups $1, %xmm0"::"m"(arr)); //~ ERROR E0669 + } +} + +fn issue_54067() { + let addr: Option = Some(123); + unsafe { + asm!("mov sp, $0"::"r"(addr)); //~ ERROR E0669 + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/inline-asm-bad-operand.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/inline-asm-bad-operand.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/inline-asm-bad-operand.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/inline-asm-bad-operand.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +error[E0669]: invalid value for constraint in inline assembly + --> $DIR/inline-asm-bad-operand.rs:28:9 + | +LL | asm!("" :: "r"("")); //~ ERROR E0669 + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0669]: invalid value for constraint in inline assembly + --> $DIR/inline-asm-bad-operand.rs:33:9 + | +LL | asm!("ret" : : "{rdi}"(target)); //~ ERROR E0669 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0669]: invalid value for constraint in inline assembly + --> $DIR/inline-asm-bad-operand.rs:40:14 + | +LL | unsafe { asm!("" :: "i"(hello)) }; //~ ERROR E0669 + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0669]: invalid value for constraint in inline assembly + --> $DIR/inline-asm-bad-operand.rs:48:9 + | +LL | asm!("movups $1, %xmm0"::"m"(arr)); //~ ERROR E0669 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0669]: invalid value for constraint in inline assembly + --> $DIR/inline-asm-bad-operand.rs:55:9 + | +LL | asm!("mov sp, $0"::"r"(addr)); //~ ERROR E0669 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0669`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-10636-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-10636-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-10636-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-10636-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -struct Obj { - //~^ NOTE: un-closed delimiter - member: usize -) -//~^ ERROR incorrect close delimiter -//~| NOTE incorrect close delimiter - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-10636-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-10636-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-10636-1.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-10636-1.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error: incorrect close delimiter: `)` - --> $DIR/issue-10636-1.rs:16:1 - | -LL | struct Obj { - | - un-closed delimiter -... -LL | ) - | ^ incorrect close delimiter - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-2354.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-2354.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-2354.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-2354.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn foo() { //~ NOTE un-closed delimiter - match Some(x) { - //~^ NOTE this delimiter might not be properly closed... - Some(y) => { panic!(); } - None => { panic!(); } -} -//~^ NOTE ...as it matches this but it has different indentation - -fn bar() { - let mut i = 0; - while (i < 1000) {} -} - -fn main() {} //~ ERROR this file contains an un-closed delimiter diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-2354.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-2354.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-2354.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-2354.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -error: this file contains an un-closed delimiter - --> $DIR/issue-2354.rs:26:66 - | -LL | fn foo() { //~ NOTE un-closed delimiter - | - un-closed delimiter -LL | match Some(x) { - | - this delimiter might not be properly closed... -... -LL | } - | - ...as it matches this but it has different indentation -... -LL | fn main() {} //~ ERROR this file contains an un-closed delimiter - | ^ - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-40827.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-40827.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-40827.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-40827.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::rc::Rc; +use std::sync::Arc; + +struct Foo(Arc); + +enum Bar { + A(Rc), + B(Option), +} + +fn f(_: T) {} + +fn main() { + f(Foo(Arc::new(Bar::B(None)))); + //~^ ERROR E0277 + //~| ERROR E0277 +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-40827.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-40827.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-40827.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-40827.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +error[E0277]: `std::rc::Rc` cannot be sent between threads safely + --> $DIR/issue-40827.rs:24:5 + | +LL | f(Foo(Arc::new(Bar::B(None)))); + | ^ `std::rc::Rc` cannot be sent between threads safely + | + = help: within `Bar`, the trait `std::marker::Send` is not implemented for `std::rc::Rc` + = note: required because it appears within the type `Bar` + = note: required because of the requirements on the impl of `std::marker::Send` for `std::sync::Arc` + = note: required because it appears within the type `Foo` +note: required by `f` + --> $DIR/issue-40827.rs:21:1 + | +LL | fn f(_: T) {} + | ^^^^^^^^^^^^^^^^^^^ + +error[E0277]: `std::rc::Rc` cannot be shared between threads safely + --> $DIR/issue-40827.rs:24:5 + | +LL | f(Foo(Arc::new(Bar::B(None)))); + | ^ `std::rc::Rc` cannot be shared between threads safely + | + = help: within `Bar`, the trait `std::marker::Sync` is not implemented for `std::rc::Rc` + = note: required because it appears within the type `Bar` + = note: required because of the requirements on the impl of `std::marker::Send` for `std::sync::Arc` + = note: required because it appears within the type `Foo` +note: required by `f` + --> $DIR/issue-40827.rs:21:1 + | +LL | fn f(_: T) {} + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-49556.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-49556.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-49556.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-49556.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +fn iter<'a>(data: &'a [usize]) -> impl Iterator + 'a { + data.iter() + .map( + |x| x // fn(&'a usize) -> &'(ReScope) usize + ) + .map( + |x| *x // fn(&'(ReScope) usize) -> usize + ) +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-52717.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-52717.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-52717.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-52717.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +enum A { + A { + foo: usize, + } +} + +fn main() { + let x = A::A { foo: 3 }; + match x { + A::A { fob } => { println!("{}", fob); } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-52717.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-52717.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-52717.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-52717.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +error[E0026]: variant `A::A` does not have a field named `fob` + --> $DIR/issue-52717.rs:19:12 + | +LL | A::A { fob } => { println!("{}", fob); } + | ^^^ + | | + | variant `A::A` does not have this field + | help: did you mean: `foo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0026`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-53419.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-53419.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-53419.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-53419.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,8 +10,6 @@ //compile-pass -#![feature(infer_outlives_requirements)] - struct Foo { bar: for<'r> Fn(usize, &'r FnMut()) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-53840.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-53840.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-53840.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-53840.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +enum E { + Foo(String, String, String), +} + +struct Bar { + a: String, + b: String, +} + +fn main() { + let bar = Bar { a: "1".to_string(), b: "2".to_string() }; + match E::Foo("".into(), "".into(), "".into()) { + E::Foo(a, b, ref c) => {} + } + match bar { + Bar {a, ref b} => {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-53840.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-53840.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-53840.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-53840.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +error[E0009]: cannot bind by-move and by-ref in the same pattern + --> $DIR/issue-53840.rs:22:16 + | +LL | E::Foo(a, b, ref c) => {} + | ^ ^ ----- both by-ref and by-move used + | | | + | | by-move pattern here + | by-move pattern here + +error[E0009]: cannot bind by-move and by-ref in the same pattern + --> $DIR/issue-53840.rs:25:14 + | +LL | Bar {a, ref b} => {} + | ^ ----- both by-ref and by-move used + | | + | by-move pattern here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0009`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-54302-cases.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-54302-cases.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-54302-cases.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-54302-cases.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,95 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Mirror { + type Image; + fn coerce(self) -> Self::Image; +} + +impl Mirror for T { + type Image = T; + fn coerce(self) -> Self { self } +} + +trait Foo<'x, T> { + fn foo(self) -> &'x T; +} + +impl<'s, 'x, T: 'x> Foo<'x, T> for &'s T where &'s T: Foo2<'x, T> { + fn foo(self) -> &'x T { self.foo2() } +} + +trait Foo2<'x, T> { + fn foo2(self) -> &'x T; +} + +// example 1 - fails leak check +impl<'x> Foo2<'x, u32> for &'x u32 +{ + fn foo2(self) -> &'x u32 { self } +} + +// example 2 - OK with this issue +impl<'x, 'a: 'x> Foo2<'x, i32> for &'a i32 +{ + fn foo2(self) -> &'x i32 { self } +} + +// example 3 - fails due to issue #XYZ + Leak-check +impl<'x, T> Foo2<'x, u64> for T + where T: Mirror +{ + fn foo2(self) -> &'x u64 { self.coerce() } +} + +// example 4 - fails due to issue #XYZ +impl<'x, 'a: 'x, T> Foo2<'x, i64> for T + where T: Mirror +{ + fn foo2(self) -> &'x i64 { self.coerce() } +} + + +trait RefFoo { + fn ref_foo(&self) -> &'static T; +} + +impl RefFoo for T where for<'a> &'a T: Foo<'static, T> { + fn ref_foo(&self) -> &'static T { + self.foo() + } +} + + +fn coerce_lifetime1(a: &u32) -> &'static u32 +{ + >::ref_foo(a) + //~^ ERROR the trait bound `for<'a> &'a u32: Foo2<'_, u32>` is not satisfied +} + +fn coerce_lifetime2(a: &i32) -> &'static i32 +{ + >::ref_foo(a) + //~^ ERROR the requirement `for<'a> 'a : ` is not satisfied +} + +fn coerce_lifetime3(a: &u64) -> &'static u64 +{ + >::ref_foo(a) + //~^ ERROR type mismatch resolving `for<'a> <&'a u64 as Mirror>::Image == &u64` +} + +fn coerce_lifetime4(a: &i64) -> &'static i64 +{ + >::ref_foo(a) + //~^ ERROR type mismatch resolving `for<'a> <&'a i64 as Mirror>::Image == &i64` +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-54302-cases.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-54302-cases.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-54302-cases.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-54302-cases.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,65 @@ +error[E0277]: the trait bound `for<'a> &'a u32: Foo2<'_, u32>` is not satisfied + --> $DIR/issue-54302-cases.rs:73:5 + | +LL | >::ref_foo(a) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Foo2<'_, u32>` is not implemented for `&'a u32` + | + = help: the following implementations were found: + <&'x u32 as Foo2<'x, u32>> + = note: required because of the requirements on the impl of `for<'a> Foo<'static, u32>` for `&'a u32` + = note: required because of the requirements on the impl of `RefFoo` for `u32` +note: required by `RefFoo::ref_foo` + --> $DIR/issue-54302-cases.rs:61:5 + | +LL | fn ref_foo(&self) -> &'static T; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0279]: the requirement `for<'a> 'a : ` is not satisfied (`expected bound lifetime parameter 'a, found concrete lifetime`) + --> $DIR/issue-54302-cases.rs:79:5 + | +LL | >::ref_foo(a) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: required because of the requirements on the impl of `for<'a> Foo2<'_, i32>` for `&'a i32` + = note: required because of the requirements on the impl of `for<'a> Foo<'static, i32>` for `&'a i32` + = note: required because of the requirements on the impl of `RefFoo` for `i32` +note: required by `RefFoo::ref_foo` + --> $DIR/issue-54302-cases.rs:61:5 + | +LL | fn ref_foo(&self) -> &'static T; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0271]: type mismatch resolving `for<'a> <&'a u64 as Mirror>::Image == &u64` + --> $DIR/issue-54302-cases.rs:85:5 + | +LL | >::ref_foo(a) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'a, found concrete lifetime + | + = note: required because of the requirements on the impl of `for<'a> Foo2<'_, u64>` for `&'a u64` + = note: required because of the requirements on the impl of `for<'a> Foo<'static, u64>` for `&'a u64` + = note: required because of the requirements on the impl of `RefFoo` for `u64` +note: required by `RefFoo::ref_foo` + --> $DIR/issue-54302-cases.rs:61:5 + | +LL | fn ref_foo(&self) -> &'static T; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0271]: type mismatch resolving `for<'a> <&'a i64 as Mirror>::Image == &i64` + --> $DIR/issue-54302-cases.rs:91:5 + | +LL | >::ref_foo(a) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'a, found concrete lifetime + | + = note: required because of the requirements on the impl of `for<'a> Foo2<'_, i64>` for `&'a i64` + = note: required because of the requirements on the impl of `for<'a> Foo<'static, i64>` for `&'a i64` + = note: required because of the requirements on the impl of `RefFoo` for `i64` +note: required by `RefFoo::ref_foo` + --> $DIR/issue-54302-cases.rs:61:5 + | +LL | fn ref_foo(&self) -> &'static T; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +Some errors occurred: E0271, E0277, E0279. +For more information about an error, try `rustc --explain E0271`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-54302.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-54302.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-54302.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-54302.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Deserialize<'de> {} + +trait DeserializeOwned: for<'de> Deserialize<'de> {} +impl DeserializeOwned for T where T: for<'de> Deserialize<'de> {} + +// Based on this impl, `&'static str` only implements Deserialize<'static>. +// It does not implement for<'de> Deserialize<'de>. +impl<'de: 'a, 'a> Deserialize<'de> for &'a str {} + +fn main() { + // Then why does it implement DeserializeOwned? This compiles. + fn assert_deserialize_owned() {} + assert_deserialize_owned::<&'static str>(); + //~^ ERROR the requirement `for<'de> 'de : ` is not satisfied + + // It correctly does not implement for<'de> Deserialize<'de>. + //fn assert_hrtb Deserialize<'de>>() {} + //assert_hrtb::<&'static str>(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-54302.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-54302.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issue-54302.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issue-54302.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +error[E0279]: the requirement `for<'de> 'de : ` is not satisfied (`expected bound lifetime parameter 'de, found concrete lifetime`) + --> $DIR/issue-54302.rs:23:5 + | +LL | assert_deserialize_owned::<&'static str>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: required because of the requirements on the impl of `for<'de> Deserialize<'de>` for `&'static str` + = note: required because of the requirements on the impl of `DeserializeOwned` for `&'static str` +note: required by `main::assert_deserialize_owned` + --> $DIR/issue-54302.rs:22:5 + | +LL | fn assert_deserialize_owned() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0279`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-10291.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-10291.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-10291.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-10291.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/issue-10291.rs:12:5 - | -LL | fn test<'x>(x: &'x isize) { - | -- lifetime `'x` defined here -LL | drop:: FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'x` must outlive `'static` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-10396.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-10396.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-10396.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-10396.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#[derive(Debug)] +enum Foo<'s> { + V(&'s str) +} + +fn f(arr: &[&Foo]) { + for &f in arr { + println!("{:?}", f); + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-10456.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-10456.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-10456.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-10456.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// pretty-expanded FIXME #23616 + +pub struct Foo; + +pub trait Bar { + fn bar(&self); +} + +pub trait Baz { + fn baz(&self) { } +} + +impl Bar for T { + fn bar(&self) {} +} + +impl Baz for Foo {} + +pub fn foo(t: Box) { + t.bar(); // ~Foo doesn't implement Baz + (*t).bar(); // ok b/c Foo implements Baz +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-10545.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-10545.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-10545.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-10545.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ error[E0603]: struct `S` is private - --> $DIR/issue-10545.rs:17:11 + --> $DIR/issue-10545.rs:17:14 | LL | fn foo(_: a::S) { //~ ERROR: struct `S` is private - | ^^^^ + | ^ error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-10763.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-10763.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-10763.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-10763.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +extern "Rust" fn foo() {} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-10853.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-10853.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-10853.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-10853.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// pretty-expanded FIXME #23616 + +#![deny(missing_docs)] +#![doc="module"] + +#[doc="struct"] +pub struct Foo; + +pub fn foo() { + #![doc="fn"] +} + +#[doc="main"] +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-10902.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-10902.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-10902.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-10902.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +pub mod two_tuple { + pub trait T { fn dummy(&self) { } } + pub struct P<'a>(&'a (T + 'a), &'a (T + 'a)); + pub fn f<'a>(car: &'a T, cdr: &'a T) -> P<'a> { + P(car, cdr) + } +} + +pub mod two_fields { + pub trait T { fn dummy(&self) { } } + pub struct P<'a> { car: &'a (T + 'a), cdr: &'a (T + 'a) } + pub fn f<'a>(car: &'a T, cdr: &'a T) -> P<'a> { + P{ car: car, cdr: cdr } + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-11192.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-11192.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-11192.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-11192.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,10 +8,9 @@ | --- first borrow occurs due to use of `ptr` in closure ... LL | test(&*ptr); - | -----^^^^^- - | | | - | | immutable borrow occurs here - | borrow later used here + | ---- ^^^^^ immutable borrow occurs here + | | + | mutable borrow later used by call error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-11384.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-11384.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-11384.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-11384.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// pretty-expanded FIXME #23616 + +trait Common { fn dummy(&self) { } } + +impl<'t, T> Common for (T, &'t T) {} + +impl<'t, T> Common for (&'t T, T) {} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-11592.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-11592.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-11592.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-11592.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +//! Ensure the private trait Bar isn't complained about. + +#![deny(missing_docs)] + +mod foo { + trait Bar { fn bar(&self) { } } + impl Bar for i8 { fn bar(&self) { } } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-11593.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-11593.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-11593.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-11593.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ error[E0603]: trait `Foo` is private - --> $DIR/issue-11593.rs:17:6 + --> $DIR/issue-11593.rs:17:24 | LL | impl private_trait_xc::Foo for Bar {} - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^ error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-11612.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-11612.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-11612.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-11612.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// #11612 +// We weren't updating the auto adjustments with all the resolved +// type information after type check. + +// pretty-expanded FIXME #23616 + +trait A { fn dummy(&self) { } } + +struct B<'a, T:'a> { + f: &'a T +} + +impl<'a, T> A for B<'a, T> {} + +fn foo(_: &A) {} + +fn bar(b: &B) { + foo(b); // Coercion should work + foo(b as &A); // Explicit cast should work as well +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-11680.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-11680.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-11680.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-11680.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,14 +1,14 @@ error[E0603]: enum `Foo` is private - --> $DIR/issue-11680.rs:16:14 + --> $DIR/issue-11680.rs:16:21 | LL | let _b = other::Foo::Bar(1); - | ^^^^^^^^^^^^^^^ + | ^^^ error[E0603]: enum `Foo` is private - --> $DIR/issue-11680.rs:19:14 + --> $DIR/issue-11680.rs:19:27 | LL | let _b = other::test::Foo::Bar(1); - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^ error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-11681.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-11681.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-11681.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-11681.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0515]: cannot return value referencing temporary value + --> $DIR/issue-11681.rs:23:10 + | +LL | let testValue = &Test; //~ ERROR borrowed value does not live long enough + | ---- temporary value created here +LL | return testValue; + | ^^^^^^^^^ returns a value referencing data owned by the current function + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-11869.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-11869.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-11869.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-11869.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +struct A { + a: String +} + +fn borrow<'a>(binding: &'a A) -> &'a str { + match &*binding.a { + "in" => "in_", + "ref" => "ref_", + ident => ident + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-12041.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-12041.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-12041.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-12041.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/issue-12041.rs:18:22 | LL | let tx = tx; - | ^^ value moved here in previous iteration of loop + | ^^ value moved here, in previous iteration of loop | = note: move occurs because `tx` has type `std::sync::mpsc::Sender`, which does not implement the `Copy` trait diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-12470.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-12470.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-12470.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-12470.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,18 +1,11 @@ -error[E0597]: `*b` does not live long enough - --> $DIR/issue-12470.rs:38:18 +error[E0515]: cannot return value referencing local data `*b` + --> $DIR/issue-12470.rs:39:5 | LL | let bb: &B = &*b; //~ ERROR does not live long enough - | ^^^ borrowed value does not live long enough + | --- `*b` is borrowed here LL | make_a(bb) -LL | } - | - `*b` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 36:16... - --> $DIR/issue-12470.rs:36:16 - | -LL | fn make_make_a<'a>() -> A<'a> { - | ^^ + | ^^^^^^^^^^ returns a value referencing data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-12511.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-12511.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-12511.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-12511.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,14 +1,14 @@ error[E0391]: cycle detected when computing the supertraits of `t1` - --> $DIR/issue-12511.rs:11:1 + --> $DIR/issue-12511.rs:11:12 | LL | trait t1 : t2 { - | ^^^^^^^^^^^^^ + | ^^ | note: ...which requires computing the supertraits of `t2`... - --> $DIR/issue-12511.rs:15:1 + --> $DIR/issue-12511.rs:15:12 | LL | trait t2 : t1 { - | ^^^^^^^^^^^^^ + | ^^ = note: ...which again requires computing the supertraits of `t1`, completing the cycle error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-1251.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-1251.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-1251.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-1251.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(unused_attributes)] +#![allow(dead_code)] +// pretty-expanded FIXME #23616 +// ignore-wasm32-bare no libc to test ffi with + +#![feature(libc)] + +#![crate_id="rust_get_test_int"] + +mod rustrt { + extern crate libc; + + extern { + pub fn rust_get_test_int() -> libc::intptr_t; + } +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-12567.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-12567.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-12567.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-12567.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -40,6 +40,43 @@ LL | (&[hd1, ..], &[hd2, ..]) | ^^^ -error: aborting due to 2 previous errors +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/issue-12567.rs:16:17 + | +LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) + | ^^ + | | + | cannot move out of data in a `&` reference + | cannot move -For more information about this error, try `rustc --explain E0508`. +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/issue-12567.rs:16:31 + | +LL | (&[], &[hd, ..]) | (&[hd, ..], &[]) + | ^^ + | | + | cannot move out of data in a `&` reference + | cannot move + +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/issue-12567.rs:20:12 + | +LL | (&[hd1, ..], &[hd2, ..]) + | ^^^ + | | + | cannot move out of data in a `&` reference + | cannot move + +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/issue-12567.rs:20:24 + | +LL | (&[hd1, ..], &[hd2, ..]) + | ^^^ + | | + | cannot move out of data in a `&` reference + | cannot move + +error: aborting due to 6 previous errors + +Some errors occurred: E0507, E0508. +For more information about an error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-12729.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-12729.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-12729.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-12729.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +pub struct Foo; + +mod bar { + use Foo; + + impl Foo { + fn baz(&self) {} + } +} +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13058.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13058.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13058.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13058.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/issue-13058.rs:36:11 - | -LL | check((3, 5)); - | ^^^^^^ - | | - | expected reference, found tuple - | help: consider borrowing here: `&(3, 5)` - | - = note: expected type `&_` - found type `({integer}, {integer})` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13058.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13058.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13058.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13058.rs 2018-12-04 23:41:40.000000000 +0000 @@ -33,6 +33,5 @@ } fn main() { - check((3, 5)); -//~^ ERROR mismatched types + check(&(3, 5)); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13058.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13058.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13058.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13058.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,19 +7,6 @@ LL | let cont_iter = cont.iter(); | ^^^^ lifetime `'r` required -error[E0308]: mismatched types - --> $DIR/issue-13058.rs:36:11 - | -LL | check((3, 5)); - | ^^^^^^ - | | - | expected reference, found tuple - | help: consider borrowing here: `&(3, 5)` - | - = note: expected type `&_` - found type `({integer}, {integer})` +error: aborting due to previous error -error: aborting due to 2 previous errors - -Some errors occurred: E0308, E0621. -For more information about an error, try `rustc --explain E0308`. +For more information about this error, try `rustc --explain E0621`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13105.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13105.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13105.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13105.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// pretty-expanded FIXME #23616 + +trait Foo { + #[allow(anonymous_parameters)] + fn quux(u8) {} +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13167.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13167.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13167.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13167.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// pretty-expanded FIXME #23616 + +use std::slice; + +pub struct PhfMapEntries<'a, T: 'a> { + iter: slice::Iter<'a, (&'static str, T)>, +} + +impl<'a, T> Iterator for PhfMapEntries<'a, T> { + type Item = (&'static str, &'a T); + + fn next(&mut self) -> Option<(&'static str, &'a T)> { + self.iter.by_ref().map(|&(key, ref value)| (key, value)).next() + } + + fn size_hint(&self) -> (usize, Option) { + self.iter.size_hint() + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13214.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13214.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13214.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13214.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// defining static with struct that contains enum +// with &'static str variant used to cause ICE + +// pretty-expanded FIXME #23616 + +pub enum Foo { + Bar, + Baz(&'static str), +} + +pub static TEST: Test = Test { + foo: Foo::Bar, + c: 'a' +}; + +pub struct Test { + foo: Foo, + c: char, +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13405.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13405.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13405.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13405.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(unused_variables)] +// pretty-expanded FIXME #23616 + +struct Foo<'a> { + i: &'a bool, + j: Option<&'a isize>, +} + +impl<'a> Foo<'a> { + fn bar(&mut self, j: &isize) { + let child = Foo { + i: self.i, + j: Some(j) + }; + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13407.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13407.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13407.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13407.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ error[E0603]: unit struct `C` is private - --> $DIR/issue-13407.rs:16:5 + --> $DIR/issue-13407.rs:16:8 | LL | A::C = 1; - | ^^^^ + | ^ error[E0308]: mismatched types --> $DIR/issue-13407.rs:16:12 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13497-2.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13497-2.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13497-2.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13497-2.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,18 +1,14 @@ -error[E0597]: `rawLines` does not live long enough +error[E0515]: cannot return value referencing local variable `rawLines` --> $DIR/issue-13497-2.rs:13:5 | -LL | rawLines //~ ERROR `rawLines` does not live long enough - | ^^^^^^^^ borrowed value does not live long enough -LL | .iter().map(|l| l.trim()).collect() -LL | } - | - `rawLines` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 11:24... - --> $DIR/issue-13497-2.rs:11:24 - | -LL | fn read_lines_borrowed<'a>() -> Vec<&'a str> { - | ^^ +LL | rawLines //~ ERROR `rawLines` does not live long enough + | ^------- + | | + | _____`rawLines` is borrowed here + | | +LL | | .iter().map(|l| l.trim()).collect() + | |___________________________________________^ returns a value referencing data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13497.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13497.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13497.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13497.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,10 +2,9 @@ --> $DIR/issue-13497.rs:12:5 | LL | &str //~ ERROR missing lifetime specifier - | ^ expected lifetime parameter + | ^ help: consider giving it a 'static lifetime: `&'static` | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from - = help: consider giving it a 'static lifetime error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13641.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13641.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13641.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13641.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,14 +1,14 @@ error[E0603]: struct `Foo` is private - --> $DIR/issue-13641.rs:19:5 + --> $DIR/issue-13641.rs:19:8 | LL | a::Foo::new(); - | ^^^^^^^^^^^ + | ^^^ error[E0603]: enum `Bar` is private - --> $DIR/issue-13641.rs:21:5 + --> $DIR/issue-13641.rs:21:8 | LL | a::Bar::new(); - | ^^^^^^^^^^^ + | ^^^ error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13703.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13703.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13703.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13703.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// pretty-expanded FIXME #23616 + +pub struct Foo<'a, 'b: 'a> { foo: &'a &'b isize } +pub fn foo<'a, 'b>(x: Foo<'a, 'b>, _o: Option<& & ()>) { let _y = x.foo; } +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13775.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13775.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13775.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13775.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// pretty-expanded FIXME #23616 + +trait Foo { + #[allow(anonymous_parameters)] + fn bar(&self, isize) {} +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13837.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13837.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-13837.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-13837.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +struct TestStruct { + x: *const [isize; 2] +} + +unsafe impl Sync for TestStruct {} + +static TEST_VALUE : TestStruct = TestStruct{x: 0x1234 as *const [isize; 2]}; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-14082.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-14082.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-14082.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-14082.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// pretty-expanded FIXME #23616 + +#![allow(unused_imports, dead_code)] + +use foo::Foo; + +mod foo { + pub use m::Foo; // this should shadow d::Foo +} + +mod m { + pub struct Foo; +} + +mod d { + pub struct Foo; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-14227.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-14227.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-14227.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-14227.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,9 +11,9 @@ #![allow(safe_extern_statics, warnings)] extern { - pub static symbol: (); + pub static symbol: u32; } -static CRASH: () = symbol; +static CRASH: u32 = symbol; //~^ ERROR could not evaluate static initializer //~| tried to read from foreign (extern) static diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-14227.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-14227.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-14227.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-14227.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ error[E0080]: could not evaluate static initializer - --> $DIR/issue-14227.rs:16:20 + --> $DIR/issue-14227.rs:16:21 | -LL | static CRASH: () = symbol; - | ^^^^^^ tried to read from foreign (extern) static +LL | static CRASH: u32 = symbol; + | ^^^^^^ tried to read from foreign (extern) static error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-14254.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-14254.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-14254.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-14254.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,103 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// pretty-expanded FIXME #23616 + +trait Foo: Sized { + fn bar(&self); + fn baz(&self) { } + fn bah(_: Option) { } +} + +struct BarTy { + x : isize, + y : f64, +} + +impl BarTy { + fn a() {} + fn b(&self) {} +} + +// If these fail, it's necessary to update rustc_resolve and the cfail tests. +impl Foo for *const BarTy { + fn bar(&self) { + self.baz(); + BarTy::a(); + Foo::bah(None::<*const BarTy>); + } +} + +// If these fail, it's necessary to update rustc_resolve and the cfail tests. +impl<'a> Foo for &'a BarTy { + fn bar(&self) { + self.baz(); + self.x; + self.y; + BarTy::a(); + Foo::bah(None::<&BarTy>); + self.b(); + } +} + +// If these fail, it's necessary to update rustc_resolve and the cfail tests. +impl<'a> Foo for &'a mut BarTy { + fn bar(&self) { + self.baz(); + self.x; + self.y; + BarTy::a(); + Foo::bah(None::<&mut BarTy>); + self.b(); + } +} + +// If these fail, it's necessary to update rustc_resolve and the cfail tests. +impl Foo for Box { + fn bar(&self) { + self.baz(); + Foo::bah(None::>); + } +} + +// If these fail, it's necessary to update rustc_resolve and the cfail tests. +impl Foo for *const isize { + fn bar(&self) { + self.baz(); + Foo::bah(None::<*const isize>); + } +} + +// If these fail, it's necessary to update rustc_resolve and the cfail tests. +impl<'a> Foo for &'a isize { + fn bar(&self) { + self.baz(); + Foo::bah(None::<&isize>); + } +} + +// If these fail, it's necessary to update rustc_resolve and the cfail tests. +impl<'a> Foo for &'a mut isize { + fn bar(&self) { + self.baz(); + Foo::bah(None::<&mut isize>); + } +} + +// If these fail, it's necessary to update rustc_resolve and the cfail tests. +impl Foo for Box { + fn bar(&self) { + self.baz(); + Foo::bah(None::>); + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-14330.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-14330.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-14330.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-14330.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(unused_imports)] +// pretty-expanded FIXME #23616 + +#[macro_use] extern crate std as std2; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-14837.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-14837.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-14837.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-14837.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// pretty-expanded FIXME #23616 + +#[deny(dead_code)] +pub enum Foo { + Bar { + baz: isize + } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-14901.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-14901.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-14901.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-14901.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +pub trait Reader {} + +enum Wrapper<'a> { + WrapReader(&'a (Reader + 'a)) +} + +trait Wrap<'a> { + fn wrap(self) -> Wrapper<'a>; +} + +impl<'a, R: Reader> Wrap<'a> for &'a mut R { + fn wrap(self) -> Wrapper<'a> { + Wrapper::WrapReader(self as &'a mut Reader) + } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-14933.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-14933.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-14933.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-14933.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// pretty-expanded FIXME #23616 + +pub type BigRat = T; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-14936.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-14936.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-14936.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-14936.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,58 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(unused_macros)] +#![allow(dead_code)] +#![feature(asm)] + +type History = Vec<&'static str>; + +fn wrap(x:A, which: &'static str, history: &mut History) -> A { + history.push(which); + x +} + +macro_rules! demo { + ( $output_constraint:tt ) => { + { + let mut x: isize = 0; + let y: isize = 1; + + let mut history: History = vec![]; + unsafe { + asm!("mov ($1), $0" + : $output_constraint (*wrap(&mut x, "out", &mut history)) + : "r"(&wrap(y, "in", &mut history)) + :: "volatile"); + } + assert_eq!((x,y), (1,1)); + let b: &[_] = &["out", "in"]; + assert_eq!(history, b); + } + } +} + +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +fn main() { + fn out_write_only_expr_then_in_expr() { + demo!("=r") + } + + fn out_read_write_expr_then_in_expr() { + demo!("+r") + } + + out_write_only_expr_then_in_expr(); + out_read_write_expr_then_in_expr(); +} + +#[cfg(all(not(target_arch = "x86"), not(target_arch = "x86_64")))] +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-14959.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-14959.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-14959.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-14959.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,65 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// pretty-expanded FIXME #23616 + +#![feature(fn_traits, unboxed_closures)] + +use std::ops::Fn; + +trait Response { fn dummy(&self) { } } +trait Request { fn dummy(&self) { } } +trait Ingot { + fn enter(&mut self, _: &mut R, _: &mut S, a: &mut Alloy) -> Status; +} + +#[allow(dead_code)] +struct HelloWorld; + +struct SendFile; +struct Alloy; +enum Status { + Continue +} + +impl Alloy { + fn find(&self) -> Option { + None + } +} + +impl<'b> Fn<(&'b mut (Response+'b),)> for SendFile { + extern "rust-call" fn call(&self, (_res,): (&'b mut (Response+'b),)) {} +} + +impl<'b> FnMut<(&'b mut (Response+'b),)> for SendFile { + extern "rust-call" fn call_mut(&mut self, (_res,): (&'b mut (Response+'b),)) { + self.call((_res,)) + } +} + +impl<'b> FnOnce<(&'b mut (Response+'b),)> for SendFile { + type Output = (); + + extern "rust-call" fn call_once(self, (_res,): (&'b mut (Response+'b),)) { + self.call((_res,)) + } +} + +impl Ingot for HelloWorld { + fn enter(&mut self, _req: &mut Rq, res: &mut Rs, alloy: &mut Alloy) -> Status { + let send_file = alloy.find::().unwrap(); + send_file(res); + Status::Continue + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-15034.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-15034.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-15034.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-15034.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error[E0621]: explicit lifetime required in the type of `lexer` - --> $DIR/issue-15034.rs:27:9 - | -LL | pub fn new(lexer: &'a mut Lexer) -> Parser<'a> { - | ------------- help: add explicit lifetime `'a` to the type of `lexer`: `&'a mut Lexer<'a>` -LL | Parser { lexer: lexer } - | ^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0621`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-15108.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-15108.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-15108.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-15108.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// pretty-expanded FIXME #23616 + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-15261.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-15261.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-15261.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-15261.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(non_upper_case_globals)] + +// pretty-expanded FIXME #23616 + +static mut n_mut: usize = 0; + +static n: &'static usize = unsafe{ &n_mut }; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-15689-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-15689-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-15689-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-15689-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +#[derive(Clone)] +enum Test<'a> { + Slice(&'a isize) +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-15735.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-15735.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-15735.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-15735.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +struct A<'a> { + a: &'a i32, + b: &'a i32, +} + +impl <'a> A<'a> { + fn foo<'b>(&'b self) { + A { + a: self.a, + b: self.b, + }; + } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-16149.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-16149.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-16149.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-16149.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/issue-16149.rs:17:9 | LL | static externalValue: isize; - | ---------------------------- a static `externalValue` is defined here + | ---------------------------- the static `externalValue` is defined here ... LL | externalValue => true, | ^^^^^^^^^^^^^ cannot be named the same as a static diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-16596.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-16596.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-16596.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-16596.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] + +trait MatrixRow { fn dummy(&self) { }} + +struct Mat; + +impl<'a> MatrixRow for &'a Mat {} + +struct Rows { + mat: M, +} + +impl<'a> Iterator for Rows<&'a Mat> { + type Item = (); + + fn next(&mut self) -> Option<()> { + unimplemented!() + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-16668.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-16668.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-16668.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-16668.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +struct Parser<'a, I, O> { + parse: Box Result + 'a> +} + +impl<'a, I: 'a, O: 'a> Parser<'a, I, O> { + fn compose(mut self, mut rhs: Parser<'a, O, K>) -> Parser<'a, I, K> { + Parser { + parse: Box::new(move |x: I| { + match (self.parse)(x) { + Ok(r) => (rhs.parse)(r), + Err(e) => Err(e) + } + }) + } + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-16683.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-16683.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-16683.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-16683.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -error: borrowed data escapes outside of function - --> $DIR/issue-16683.rs:14:9 - | -LL | fn b(&self) { - | ----- `self` is a reference that is only valid in the function body -LL | self.a(); //~ ERROR cannot infer - | ^^^^^^^^ `self` escapes the function body here - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-16725.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-16725.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-16725.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-16725.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ error[E0603]: function `bar` is private - --> $DIR/issue-16725.rs:16:14 + --> $DIR/issue-16725.rs:16:19 | LL | unsafe { foo::bar(); } - | ^^^^^^^^ + | ^^^ error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-16922.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-16922.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-16922.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-16922.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error[E0621]: explicit lifetime required in the type of `value` - --> $DIR/issue-16922.rs:14:5 - | -LL | fn foo(value: &T) -> Box { - | -- help: add explicit lifetime `'static` to the type of `value`: `&'static T` -LL | Box::new(value) as Box - | ^^^^^^^^^^^^^^^ lifetime `'static` required - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0621`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-16922.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-16922.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-16922.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-16922.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -4,7 +4,7 @@ LL | fn foo(value: &T) -> Box { | -- help: add explicit lifetime `'static` to the type of `value`: `&'static T` LL | Box::new(value) as Box - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'static` required + | ^^^^^^^^^^^^^^^ lifetime `'static` required error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-1697.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-1697.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-1697.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-1697.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,6 +11,6 @@ // Testing that we don't fail abnormally after hitting the errors use unresolved::*; //~ ERROR unresolved import `unresolved` [E0432] - //~^ Maybe a missing `extern crate unresolved;`? + //~^ maybe a missing `extern crate unresolved;`? fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-1697.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-1697.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-1697.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-1697.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/issue-1697.rs:13:5 | LL | use unresolved::*; //~ ERROR unresolved import `unresolved` [E0432] - | ^^^^^^^^^^ Maybe a missing `extern crate unresolved;`? + | ^^^^^^^^^^ maybe a missing `extern crate unresolved;`? error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17121.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17121.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17121.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17121.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 +// ignore-cloudabi no std::fs + +use std::fs::File; +use std::io::{self, BufReader, Read}; + +struct Lexer +{ + reader: BufReader, +} + +impl Lexer +{ + pub fn new_from_reader(r: R) -> Lexer + { + Lexer{reader: BufReader::new(r)} + } + + pub fn new_from_file(p: &str) -> io::Result> + { + Ok(Lexer::new_from_reader(File::open(p)?)) + } + + pub fn new_from_str<'a>(s: &'a str) -> Lexer<&'a [u8]> + { + Lexer::new_from_reader(s.as_bytes()) + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17336.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17336.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17336.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17336.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(unused_must_use)] +#[allow(dead_code)] +fn check(a: &str) { + let x = a as *const str; + x == x; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17385.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17385.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17385.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17385.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,24 +1,4 @@ error[E0382]: use of moved value: `foo` - --> $DIR/issue-17385.rs:28:11 - | -LL | drop(foo); - | --- value moved here -LL | match foo { //~ ERROR use of moved value - | ^^^ value used here after move - | - = note: move occurs because `foo` has type `X`, which does not implement the `Copy` trait - -error[E0382]: borrow of moved value: `foo` - --> $DIR/issue-17385.rs:28:11 - | -LL | drop(foo); - | --- value moved here -LL | match foo { //~ ERROR use of moved value - | ^^^ value borrowed here after move - | - = note: move occurs because `foo` has type `X`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `foo.0` --> $DIR/issue-17385.rs:29:11 | LL | drop(foo); @@ -39,27 +19,6 @@ | = note: move occurs because `e` has type `Enum`, which does not implement the `Copy` trait -error[E0382]: borrow of moved value: `e` - --> $DIR/issue-17385.rs:35:11 - | -LL | drop(e); - | - value moved here -LL | match e { //~ ERROR use of moved value - | ^ value borrowed here after move - | - = note: move occurs because `e` has type `Enum`, which does not implement the `Copy` trait - -error[E0382]: use of moved value: `e` - --> $DIR/issue-17385.rs:36:9 - | -LL | drop(e); - | - value moved here -LL | match e { //~ ERROR use of moved value -LL | Enum::Variant1 => unreachable!(), - | ^^^^^^^^^^^^^^ value used here after move - | - = note: move occurs because `e` has type `Enum`, which does not implement the `Copy` trait - -error: aborting due to 6 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17450.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17450.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17450.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17450.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code, warnings)] + +static mut x: isize = 3; +static mut y: isize = unsafe { x }; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17545.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17545.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17545.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17545.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,17 +1,16 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/issue-17545.rs:17:10 | -LL | &id(()), //~ ERROR borrowed value does not live long enough - | ^^^^^^ temporary value does not live long enough -LL | )); - | - temporary value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 15:12... - --> $DIR/issue-17545.rs:15:12 - | -LL | pub fn foo<'a, F: Fn(&'a ())>(bar: F) { - | ^^ +LL | pub fn foo<'a, F: Fn(&'a ())>(bar: F) { + | -- lifetime `'a` defined here +LL | / bar.call(( +LL | | &id(()), //~ ERROR borrowed value does not live long enough + | | ^^^^^^ creates a temporary which is freed while still in use +LL | | )); + | | -- temporary value is freed at the end of this statement + | |______| + | argument requires that borrow lasts for `'a` error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17718-constants-not-static.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17718-constants-not-static.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17718-constants-not-static.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17718-constants-not-static.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +error[E0515]: cannot return reference to temporary value + --> $DIR/issue-17718-constants-not-static.rs:15:30 + | +LL | fn foo() -> &'static usize { &id(FOO) } + | ^------- + | || + | |temporary value created here + | returns a reference to data owned by the current function + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17718-const-destructors.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17718-const-destructors.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17718-const-destructors.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17718-const-destructors.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +struct A; +impl Drop for A { + fn drop(&mut self) {} +} + +const FOO: A = A; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17718-const-privacy.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17718-const-privacy.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17718-const-privacy.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17718-const-privacy.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ error[E0603]: constant `B` is private - --> $DIR/issue-17718-const-privacy.rs:15:5 + --> $DIR/issue-17718-const-privacy.rs:15:8 | LL | use a::B; //~ ERROR: constant `B` is private - | ^^^^ + | ^ error[E0603]: constant `BAR` is private --> $DIR/issue-17718-const-privacy.rs:18:5 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17718-patterns.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17718-patterns.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17718-patterns.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17718-patterns.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/issue-17718-patterns.rs:17:9 | LL | static A1: usize = 1; - | --------------------- a static `A1` is defined here + | --------------------- the static `A1` is defined here ... LL | A1 => {} //~ ERROR: match bindings cannot shadow statics | ^^ cannot be named the same as a static @@ -11,7 +11,7 @@ --> $DIR/issue-17718-patterns.rs:18:9 | LL | static mut A2: usize = 1; - | ------------------------- a static `A2` is defined here + | ------------------------- the static `A2` is defined here ... LL | A2 => {} //~ ERROR: match bindings cannot shadow statics | ^^ cannot be named the same as a static diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17718-static-move.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17718-static-move.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17718-static-move.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17718-static-move.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,6 +7,15 @@ | cannot move out of static item | help: consider borrowing here: `&FOO` -error: aborting due to previous error +error[E0507]: cannot move out of immutable static item `FOO` + --> $DIR/issue-17718-static-move.rs:16:14 + | +LL | let _a = FOO; //~ ERROR: cannot move out of static item + | ^^^ + | | + | cannot move out of immutable static item `FOO` + | cannot move + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17728.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17728.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17728.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17728.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -error[E0308]: match arms have incompatible types - --> $DIR/issue-17728.rs:110:5 - | -LL | / match to_parse { //~ ERROR match arms have incompatible types -LL | | "w" | "west" => RoomDirection::West, -LL | | "e" | "east" => RoomDirection::East, -LL | | "n" | "north" => RoomDirection::North, -... | -LL | | _ => None - | | ---- match arm with an incompatible type -LL | | } - | |_____^ expected enum `RoomDirection`, found enum `std::option::Option` - | - = note: expected type `RoomDirection` - found type `std::option::Option<_>` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17732.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17732.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17732.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17732.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +trait Person { + type string; + fn dummy(&self) { } +} + +struct Someone(std::marker::PhantomData

); + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17746.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17746.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17746.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17746.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// Regression test for #17746 + +fn main() {} + +struct A; + +impl A { + fn b(&mut self) { + self.a() + } +} + +trait Foo { + fn dummy(&self) {} +} +trait Bar { + fn a(&self); +} + +impl Foo for A {} +impl Bar for T where T: Foo { + fn a(&self) {} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17758.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17758.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17758.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17758.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -error: borrowed data escapes outside of function - --> $DIR/issue-17758.rs:17:9 - | -LL | fn bar(&self) { - | ----- `self` is a reference that is only valid in the function body -LL | self.foo(); - | ^^^^^^^^^^ `self` escapes the function body here - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17800.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17800.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17800.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17800.rs 2018-12-04 23:41:40.000000000 +0000 @@ -17,7 +17,6 @@ match MyOption::MySome(42) { MyOption::MySome { x: 42 } => (), //~^ ERROR variant `MyOption::MySome` does not have a field named `x` - //~| ERROR pattern does not mention field `0` _ => (), } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17800.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17800.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17800.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17800.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,17 +2,11 @@ --> $DIR/issue-17800.rs:18:28 | LL | MyOption::MySome { x: 42 } => (), - | ^^^^^ variant `MyOption::MySome` does not have this field + | ^^^^^ + | | + | variant `MyOption::MySome` does not have this field + | help: did you mean: `0` -error[E0027]: pattern does not mention field `0` - --> $DIR/issue-17800.rs:18:9 - | -LL | MyOption::MySome { x: 42 } => (), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ missing field `0` - | - = note: trying to match a tuple variant with a struct variant pattern - -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors occurred: E0026, E0027. -For more information about an error, try `rustc --explain E0026`. +For more information about this error, try `rustc --explain E0026`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17904.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17904.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17904.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17904.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// Test that we can parse where clauses on various forms of tuple +// structs. + +// pretty-expanded FIXME #23616 + +struct Bar(T) where T: Copy; +struct Bleh(T, U) where T: Copy, U: Sized; +struct Baz where T: Copy { + field: T +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17905-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17905-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17905-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17905-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[derive(Debug)] +struct Pair (T, V); + +impl Pair< + &str, + isize +> { + fn say(self: &Pair<&str, isize>) { + println!("{:?}", self); + } +} + +fn main() { + let result = &Pair("shane", 1); + result.say(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17905-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17905-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17905-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17905-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +error[E0308]: mismatched method receiver + --> $DIR/issue-17905-2.rs:18:18 + | +LL | fn say(self: &Pair<&str, isize>) { + | ^^^^^^^^^^^^^^^^^^ lifetime mismatch + | + = note: expected type `Pair<&'_ str, _>` + found type `Pair<&str, _>` +note: the anonymous lifetime #2 defined on the method body at 18:5... + --> $DIR/issue-17905-2.rs:18:5 + | +LL | / fn say(self: &Pair<&str, isize>) { +LL | | println!("{:?}", self); +LL | | } + | |_____^ +note: ...does not necessarily outlive the lifetime '_ as defined on the impl at 15:5 + --> $DIR/issue-17905-2.rs:15:5 + | +LL | &str, + | ^ + +error[E0308]: mismatched method receiver + --> $DIR/issue-17905-2.rs:18:18 + | +LL | fn say(self: &Pair<&str, isize>) { + | ^^^^^^^^^^^^^^^^^^ lifetime mismatch + | + = note: expected type `Pair<&'_ str, _>` + found type `Pair<&str, _>` +note: the lifetime '_ as defined on the impl at 15:5... + --> $DIR/issue-17905-2.rs:15:5 + | +LL | &str, + | ^ +note: ...does not necessarily outlive the anonymous lifetime #2 defined on the method body at 18:5 + --> $DIR/issue-17905-2.rs:18:5 + | +LL | / fn say(self: &Pair<&str, isize>) { +LL | | println!("{:?}", self); +LL | | } + | |_____^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17905.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17905.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17905.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17905.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,15 +8,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// run-pass + #[derive(Debug)] struct Pair (T, V); impl Pair< - &str, //~ ERROR missing lifetime specifier + &str, isize > { - fn say(self: &Pair<&str, isize>) { - println!("{}", self); + fn say(&self) { + println!("{:?}", self); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17905.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17905.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-17905.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-17905.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/issue-17905.rs:15:5 - | -LL | &str, //~ ERROR missing lifetime specifier - | ^ expected lifetime parameter - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0106`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-18083.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-18083.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-18083.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-18083.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(unused_imports)] +// These crossed imports should resolve fine, and not block on +// each other and be reported as unresolved. + +mod a { + use b::{B}; + pub use self::inner::A; + + mod inner { + pub struct A; + } +} + +mod b { + use a::{A}; + pub use self::inner::B; + + mod inner { + pub struct B; + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-18088.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-18088.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-18088.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-18088.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass + +pub trait Indexable: std::ops::Index { + fn index2(&self, i: usize) -> &T { + &self[i] + } +} +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-18118.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-18118.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-18118.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-18118.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -54,12 +54,13 @@ --> $DIR/issue-18118.rs:18:9 | LL | &p //~ ERROR `p` does not live long enough - | ^^ borrowed value does not live long enough + | ^^ + | | + | borrowed value does not live long enough + | using this value as a constant requires that `p` is borrowed for `'static` LL | //~^ ERROR let bindings in constants are unstable LL | }; | - `p` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error: aborting due to 6 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-18188.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-18188.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-18188.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-18188.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// pretty-expanded FIXME #23616 + +pub trait Promisable: Send + Sync {} +impl Promisable for T {} + +pub fn propagate<'a, T, E, F, G>(mut action: F) + -> Box) -> Result + 'a> + where + T: Promisable + Clone + 'a, + E: Promisable + Clone + 'a, + F: FnMut(&T) -> Result + Send + 'a, + G: FnMut(Result) -> Result + 'a { + Box::new(move |result: Result| { + match result { + Ok(ref t) => action(t), + Err(ref e) => Err(e.clone()), + } + }) +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-1821.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-1821.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-1821.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-1821.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// Issue #1821 - Don't recurse trying to typecheck this + + +// pretty-expanded FIXME #23616 + +enum t { + foo(Vec) +} +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-18446-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-18446-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-18446-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-18446-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// Test that methods in trait impls should override default methods. + +trait T { + fn foo(&self) -> i32 { 0 } +} + +impl<'a> T + 'a { + fn foo(&self) -> i32 { 1 } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-18566.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-18566.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-18566.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-18566.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,11 +2,10 @@ --> $DIR/issue-18566.rs:33:19 | LL | MyPtr(s).poke(s); - | --------------^- - | | | | - | | | second mutable borrow occurs here - | | first mutable borrow occurs here - | borrow later used here + | - ---- ^ second mutable borrow occurs here + | | | + | | first borrow later used by call + | first mutable borrow occurs here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-1866.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-1866.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-1866.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-1866.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +mod a { + pub type rust_task = usize; + pub mod rustrt { + use super::rust_task; + extern { + pub fn rust_task_is_unwinding(rt: *const rust_task) -> bool; + } + } +} + +mod b { + pub type rust_task = bool; + pub mod rustrt { + use super::rust_task; + extern { + pub fn rust_task_is_unwinding(rt: *const rust_task) -> bool; + } + } +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-18738.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-18738.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-18738.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-18738.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#[derive(Eq, PartialEq, PartialOrd, Ord)] +enum Test<'a> { + Int(&'a isize), + Slice(&'a [u8]), +} + +#[derive(Eq, PartialEq, PartialOrd, Ord)] +struct Version { + vendor_info: &'static str +} + +#[derive(Eq, PartialEq, PartialOrd, Ord)] +struct Foo(&'static str); + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-18783.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-18783.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-18783.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-18783.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ | second mutable borrow occurs here LL | //~^ ERROR cannot borrow `y` as mutable more than once at a time LL | } - | - borrow later used here, when `c` is dropped + | - first borrow might be used here, when `c` is dropped and runs the destructor for type `std::cell::RefCell>>` error[E0499]: cannot borrow `y` as mutable more than once at a time --> $DIR/issue-18783.rs:26:29 @@ -26,7 +26,7 @@ | second mutable borrow occurs here LL | //~^ ERROR cannot borrow `y` as mutable more than once at a time LL | } - | - borrow later used here, when `c` is dropped + | - first borrow might be used here, when `c` is dropped and runs the destructor for type `std::cell::RefCell>>` error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-18809.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-18809.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-18809.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-18809.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +trait Tup { + type T0; + type T1; +} + +impl Tup for isize { + type T0 = f32; + type T1 = (); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-18906.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-18906.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-18906.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-18906.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +pub trait Borrow { + fn borrow(&self) -> &Borrowed; +} + +impl Borrow for T { + fn borrow(&self) -> &T { self } +} + +trait Foo { + fn foo(&self, other: &Self); +} + +fn bar(k: &K, q: &Q) where K: Borrow, Q: Foo { + q.foo(k.borrow()) +} + +struct MyTree(K); + +impl MyTree { + // This caused a failure in #18906 + fn bar(k: &K, q: &Q) where K: Borrow, Q: Foo { + q.foo(k.borrow()) + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-18988.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-18988.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-18988.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-18988.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +pub trait Foo : Send { } + +pub struct MyFoo { + children: Vec>, +} + +impl Foo for MyFoo { } + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19037.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19037.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19037.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19037.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +struct Str([u8]); + +#[derive(Clone)] +struct CharSplits<'a, Sep> { + string: &'a Str, + sep: Sep, + allow_trailing_empty: bool, + only_ascii: bool, + finished: bool, +} + +fn clone(s: &Str) -> &Str { + Clone::clone(&s) +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19081.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19081.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19081.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19081.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +pub trait Hasher { + type State; + + fn hash::State + >>(&self, value: &T) -> u64; +} + +pub trait Hash { + fn hash(&self, state: &mut S); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19097.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19097.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19097.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19097.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// regression test for #19097 + +struct Foo(T); + +impl<'a, T> Foo<&'a T> { + fn foo(&self) {} +} +impl<'a, T> Foo<&'a mut T> { + fn foo(&self) {} +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19098.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19098.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19098.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19098.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +pub trait Handler { + fn handle(&self, _: &mut String); +} + +impl Handler for F where F: for<'a, 'b> Fn(&'a mut String) { + fn handle(&self, st: &mut String) { + self(st) + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19102.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19102.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19102.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19102.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(unused_imports)] +#![deny(unused_qualifications)] + +use self::A::B; + +#[derive(PartialEq)] +pub enum A { + B, +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19129-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19129-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19129-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19129-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// pretty-expanded FIXME #23616 + +trait Trait { + type Output; + + fn method() -> >::Output; +} + +impl Trait for () { + type Output = (); + + fn method() {} +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19129-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19129-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19129-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19129-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(unused_variables)] +// pretty-expanded FIXME #23616 + +trait Trait { + type Output; + + fn method(&self, i: Input) -> bool { false } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19398.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19398.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19398.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19398.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// pretty-expanded FIXME #23616 + +trait T { + unsafe extern "Rust" fn foo(&self); +} + +impl T for () { + unsafe extern "Rust" fn foo(&self) {} +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19404.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19404.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19404.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19404.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(unused_variables)] +use std::any::TypeId; +use std::rc::Rc; + +type Fp = Rc; + +struct Engine; + +trait Component: 'static {} +impl Component for Engine {} + +trait Env { + fn get_component_type_id(&self, type_id: TypeId) -> Option>; +} + +impl<'a> Env+'a { + fn get_component(&self) -> Option> { + let x = self.get_component_type_id(TypeId::of::()); + None + } +} + +trait Figment { + fn init(&mut self, env: &Env); +} + +struct MyFigment; + +impl Figment for MyFigment { + fn init(&mut self, env: &Env) { + let engine = env.get_component::(); + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19479.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19479.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19479.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19479.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// pretty-expanded FIXME #23616 + +trait Base { + fn dummy(&self) { } +} +trait AssocA { + type X: Base; + fn dummy(&self) { } +} +trait AssocB { + type Y: Base; + fn dummy(&self) { } +} +impl AssocB for T { + type Y = ::X; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19498.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19498.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19498.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19498.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | ^^^^^ `A` redefined here | = note: `A` 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 +help: you can use `as` to change the binding name of the import | LL | use self::A as OtherA; | ^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ | ^^^^^^^^^ `B` redefined here | = note: `B` 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 +help: you can use `as` to change the binding name of the import | LL | use self::B as OtherB; | ^^^^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ | ^^^^^ `D` redefined here | = note: `D` 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 +help: you can use `as` to change the binding name of the import | LL | use C::D as OtherD; | ^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19631.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19631.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19631.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19631.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +trait PoolManager { + type C; + fn dummy(&self) { } +} + +struct InnerPool { + manager: M, +} + +impl InnerPool where M: PoolManager {} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19632.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19632.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19632.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19632.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +trait PoolManager { + type C; + fn dummy(&self) { } +} + +struct InnerPool { + manager: M, +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19850.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19850.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19850.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19850.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(unused_variables)] +// Test that `::Output` and `Self::Output` are accepted as type annotations in let +// bindings + +// pretty-expanded FIXME #23616 + +trait Int { + fn one() -> Self; + fn leading_zeros(self) -> usize; +} + +trait Foo { + type T : Int; + + fn test(&self) { + let r: ::T = Int::one(); + let r: Self::T = Int::one(); + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19982.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19982.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19982.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19982.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,10 +8,25 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(unboxed_closures)] +// compile-pass +#![feature(fn_traits, unboxed_closures)] + +#[allow(dead_code)] struct Foo; -impl Fn<(&(),)> for Foo { } //~ ERROR missing lifetime specifier +impl Fn<(&(),)> for Foo { + extern "rust-call" fn call(&self, (_,): (&(),)) {} +} + +impl FnMut<(&(),)> for Foo { + extern "rust-call" fn call_mut(&mut self, (_,): (&(),)) {} +} + +impl FnOnce<(&(),)> for Foo { + type Output = (); + + extern "rust-call" fn call_once(self, (_,): (&(),)) {} +} fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19982.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19982.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-19982.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-19982.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/issue-19982.rs:15:10 - | -LL | impl Fn<(&(),)> for Foo { } //~ ERROR missing lifetime specifier - | ^ expected lifetime parameter - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0106`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20009.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20009.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20009.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20009.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// Check that associated types are `Sized` + +// pretty-expanded FIXME #23616 + +trait Trait { + type Output; + + fn is_sized(&self) -> Self::Output; + fn wasnt_sized(&self) -> Self::Output { loop {} } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20091.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20091.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20091.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20091.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(stable_features)] + +// ignore-cloudabi no processes +// ignore-emscripten no processes + +#![feature(os)] + +#[cfg(unix)] +fn main() { + use std::process::Command; + use std::env; + use std::os::unix::prelude::*; + use std::ffi::OsStr; + + if env::args().len() == 1 { + assert!(Command::new(&env::current_exe().unwrap()) + .arg(::from_bytes(b"\xff")) + .status().unwrap().success()) + } +} + +#[cfg(windows)] +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20186.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20186.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20186.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20186.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(unused_variables)] +struct Foo; + +impl Foo { + fn putc(&self, b: u8) { } + + fn puts(&self, s: &str) { + for byte in s.bytes() { + self.putc(byte) + } + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20396.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20396.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20396.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20396.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// pretty-expanded FIXME #23616 + +#![allow(dead_code)] + +trait Foo { + fn noop(&self, _: T); +} + +enum Bar { Bla(T) } + +struct Baz<'a> { + inner: for<'b> Foo> + 'a, +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20414.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20414.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20414.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20414.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +trait Trait { + fn method(self) -> isize; +} + +struct Wrapper { + field: T +} + +impl<'a, T> Trait for &'a Wrapper where &'a T: Trait { + fn method(self) -> isize { + let r: &'a T = &self.field; + Trait::method(r); // these should both work + r.method() + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20454.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20454.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20454.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20454.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(unused_must_use)] +use std::thread; + +fn _foo() { + thread::spawn(move || { // no need for -> () + loop { + println!("hello"); + } + }).join(); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-2063-resource.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-2063-resource.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-2063-resource.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-2063-resource.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// test that autoderef of a type like this does not +// cause compiler to loop. Note that no instances +// of such a type could ever be constructed. + +struct S { + x: X, + to_str: (), +} + +struct X(Box); + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20644.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20644.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20644.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20644.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(unused_imports)] +#![allow(stable_features)] + +// A reduced version of the rustbook ice. The problem this encountered +// had to do with codegen ignoring binders. + +// pretty-expanded FIXME #23616 +// ignore-cloudabi no std::fs + +#![feature(os)] + +use std::iter; +use std::os; +use std::fs::File; +use std::io::prelude::*; +use std::env; +use std::path::Path; + +pub fn parse_summary(_: R, _: &Path) { + let path_from_root = Path::new(""); + Path::new(&iter::repeat("../") + .take(path_from_root.components().count() - 1) + .collect::()); + } + +fn foo() { + let cwd = env::current_dir().unwrap(); + let src = cwd.clone(); + let summary = File::open(&src.join("SUMMARY.md")).unwrap(); + let _ = parse_summary(summary, &src); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20763-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20763-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20763-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20763-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +trait T0 { + type O; + fn dummy(&self) { } +} + +struct S(A); +impl T0 for S { type O = A; } + +trait T1: T0 { + // this looks okay but as we see below, `f` is unusable + fn m0::O) -> bool>(self, f: F) -> bool; +} + +// complains about the bounds on F here not being required by the trait +impl T1 for S { + fn m0 bool>(self, f: F) -> bool { f(self.0) } +} + +// // complains about mismatched types: as T0>::O vs. A +// impl T1 for S +// { +// fn m0::O) -> bool>(self, f: F) -> bool { f(self.0) } +// } + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20763-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20763-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20763-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20763-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +trait T0 { + type O; + fn dummy(&self) { } +} + +struct S(A); +impl T0 for S { type O = A; } + +trait T1: T0 { + // this looks okay but as we see below, `f` is unusable + fn m0::O) -> bool>(self, f: F) -> bool; +} + +// complains about mismatched types: as T0>::O vs. A +impl T1 for S +{ + fn m0::O) -> bool>(self, f: F) -> bool { f(self.0) } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20797.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20797.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20797.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20797.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,104 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// ignore-cloudabi no std::fs + +// Regression test for #20797. + +use std::default::Default; +use std::io; +use std::fs; +use std::path::PathBuf; + +pub trait PathExtensions { + fn is_dir(&self) -> bool { false } +} + +impl PathExtensions for PathBuf {} + +/// A strategy for acquiring more subpaths to walk. +pub trait Strategy { + type P: PathExtensions; + /// Get additional subpaths from a given path. + fn get_more(&self, item: &Self::P) -> io::Result>; + /// Determine whether a path should be walked further. + /// This is run against each item from `get_more()`. + fn prune(&self, p: &Self::P) -> bool; +} + +/// The basic fully-recursive strategy. Nothing is pruned. +#[derive(Copy, Clone, Default)] +pub struct Recursive; + +impl Strategy for Recursive { + type P = PathBuf; + fn get_more(&self, p: &PathBuf) -> io::Result> { + Ok(fs::read_dir(p).unwrap().map(|s| s.unwrap().path()).collect()) + } + + fn prune(&self, _: &PathBuf) -> bool { false } +} + +/// A directory walker of `P` using strategy `S`. +pub struct Subpaths { + stack: Vec, + strategy: S, +} + +impl Subpaths { + /// Create a directory walker with a root path and strategy. + pub fn new(p: &S::P, strategy: S) -> io::Result> { + let stack = strategy.get_more(p)?; + Ok(Subpaths { stack: stack, strategy: strategy }) + } +} + +impl Subpaths { + /// Create a directory walker with a root path and a default strategy. + pub fn walk(p: &S::P) -> io::Result> { + Subpaths::new(p, Default::default()) + } +} + +impl Default for Subpaths { + fn default() -> Subpaths { + Subpaths { stack: Vec::new(), strategy: Default::default() } + } +} + +impl Iterator for Subpaths { + type Item = S::P; + fn next (&mut self) -> Option { + let mut opt_path = self.stack.pop(); + while opt_path.is_some() && self.strategy.prune(opt_path.as_ref().unwrap()) { + opt_path = self.stack.pop(); + } + match opt_path { + Some(path) => { + if path.is_dir() { + let result = self.strategy.get_more(&path); + match result { + Ok(dirs) => { self.stack.extend(dirs); }, + Err(..) => { } + } + } + Some(path) + } + None => None, + } + } +} + +fn _foo() { + let _walker: Subpaths = Subpaths::walk(&PathBuf::from("/home")).unwrap(); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20801.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20801.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20801.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20801.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -16,24 +16,42 @@ | cannot move out of borrowed content | help: consider removing the `*`: `imm_ref()` -error[E0507]: cannot move out of borrowed content +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/issue-20801.rs:39:22 + | +LL | let b = unsafe { *imm_ref() }; + | ^^^^^^^^^^ + | | + | cannot move out of data in a `&` reference + | cannot move + +error[E0507]: cannot move out of dereference of raw pointer --> $DIR/issue-20801.rs:42:22 | LL | let c = unsafe { *mut_ptr() }; | ^^^^^^^^^^ | | - | cannot move out of borrowed content + | cannot move out of dereference of raw pointer | help: consider removing the `*`: `mut_ptr()` -error[E0507]: cannot move out of borrowed content +error[E0507]: cannot move out of dereference of raw pointer --> $DIR/issue-20801.rs:45:22 | LL | let d = unsafe { *const_ptr() }; | ^^^^^^^^^^^^ | | - | cannot move out of borrowed content + | cannot move out of dereference of raw pointer | help: consider removing the `*`: `const_ptr()` -error: aborting due to 4 previous errors +error[E0507]: cannot move out of data in a `*const` pointer + --> $DIR/issue-20801.rs:45:22 + | +LL | let d = unsafe { *const_ptr() }; + | ^^^^^^^^^^^^ + | | + | cannot move out of data in a `*const` pointer + | cannot move + +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20825-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20825-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-20825-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-20825-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +pub trait Subscriber { + type Input; +} + +pub trait Processor: Subscriber::Input> { + type Input; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21140.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21140.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21140.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21140.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +pub trait Trait where Self::Out: std::fmt::Display { + type Out; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21174-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21174-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21174-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21174-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(unused_variables)] +trait Trait<'a> { + type A; + type B; +} + +fn foo<'a, T: Trait<'a>>(value: T::A) { + let new: T::B = unsafe { std::mem::transmute_copy(&value) }; +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21245.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21245.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21245.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21245.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,66 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// Regression test for issue #21245. Check that we are able to infer +// the types in these examples correctly. It used to be that +// insufficient type propagation caused the type of the iterator to be +// incorrectly unified with the `*const` type to which it is coerced. + +// pretty-expanded FIXME #23616 + +use std::ptr; + +trait IntoIterator { + type Iter: Iterator; + + fn into_iter2(self) -> Self::Iter; +} + +impl IntoIterator for I where I: Iterator { + type Iter = I; + + fn into_iter2(self) -> I { + self + } +} + +fn desugared_for_loop_bad(v: Vec) { + match IntoIterator::into_iter2(v.iter()) { + mut iter => { + loop { + match ::std::iter::Iterator::next(&mut iter) { + ::std::option::Option::Some(x) => { + unsafe { ptr::read(x); } + }, + ::std::option::Option::None => break + } + } + } + } +} + +fn desugared_for_loop_good(v: Vec) { + match v.iter().into_iter() { + mut iter => { + loop { + match ::std::iter::Iterator::next(&mut iter) { + ::std::option::Option::Some(x) => { + unsafe { ptr::read(x); } + }, + ::std::option::Option::None => break + } + } + } + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21356.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21356.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21356.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21356.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -4,7 +4,7 @@ LL | macro_rules! test { ($wrong:t_ty ..) => () } | ^^^^^^^^^^^ | - = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `literal`, `path`, `meta`, `tt`, `item` and `vis` + = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21363.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21363.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21363.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21363.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// pretty-expanded FIXME #23616 + +#![no_implicit_prelude] + +trait Iterator { + type Item; + fn dummy(&self) { } +} + +impl<'a, T> Iterator for &'a mut (Iterator + 'a) { + type Item = T; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21402.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21402.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21402.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21402.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +#[derive(Hash)] +struct Foo { + a: Vec, + b: (bool, bool), + c: [bool; 2], +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21520.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21520.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21520.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21520.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// Test that the requirement (in `Bar`) that `T::Bar : 'static` does +// not wind up propagating to `T`. + +// pretty-expanded FIXME #23616 + +pub trait Foo { + type Bar; + + fn foo(&self) -> Self; +} + +pub struct Static(T); + +struct Bar + where T::Bar : 'static +{ + x: Static> +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21562.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21562.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21562.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21562.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(non_upper_case_globals)] + +extern crate core; +use core::marker::Sync; + +static SARRAY: [i32; 1] = [11]; + +struct MyStruct { + pub arr: *const [i32], +} +unsafe impl Sync for MyStruct {} + +static mystruct: MyStruct = MyStruct { + arr: &SARRAY +}; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21622.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21622.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21622.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21622.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(unused_variables)] + +struct Index; + +impl Index { + fn new() -> Self { Index } +} + +fn user() { + let new = Index::new; + + fn inner() { + let index = Index::new(); + } + + let index2 = new(); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21634.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21634.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21634.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21634.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(stable_features)] + +#![feature(cfg_target_feature)] + +#[cfg(any(not(target_arch = "x86"), target_feature = "sse2"))] +fn main() { + if let Ok(x) = "3.1415".parse::() { + assert_eq!(false, x <= 0.0); + } + if let Ok(x) = "3.1415".parse::() { + assert_eq!(3.1415, x + 0.0); + } + if let Ok(mut x) = "3.1415".parse::() { + assert_eq!(8.1415, { x += 5.0; x }); + } +} + +#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))] +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21726.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21726.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21726.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21726.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,48 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// Regression test for #21726: an issue arose around the rules for +// subtyping of projection types that resulted in an unconstrained +// region, yielding region inference failures. + +// pretty-expanded FIXME #23616 + +fn main() { } + +fn foo<'a>(s: &'a str) { + let b: B<()> = B::new(s, ()); + b.get_short(); +} + +trait IntoRef<'a> { + type T: Clone; + fn into_ref(self, _: &'a str) -> Self::T; +} + +impl<'a> IntoRef<'a> for () { + type T = &'a str; + fn into_ref(self, s: &'a str) -> &'a str { + s + } +} + +struct B<'a, P: IntoRef<'a>>(P::T); + +impl<'a, P: IntoRef<'a>> B<'a, P> { + fn new(s: &'a str, i: P) -> B<'a, P> { + B(i.into_ref(s)) + } + + fn get_short(&self) -> P::T { + self.0.clone() + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21891.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21891.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-21891.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-21891.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(non_upper_case_globals)] + +// pretty-expanded FIXME #23616 + +static foo: [usize; 3] = [1, 2, 3]; + +static slice_1: &'static [usize] = &foo; +static slice_2: &'static [usize] = &foo; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-22066.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-22066.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-22066.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-22066.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +pub trait LineFormatter<'a> { + type Iter: Iterator + 'a; + fn iter(&'a self, line: &'a str) -> Self::Iter; + + fn dimensions(&'a self, line: &'a str) { + let iter: Self::Iter = self.iter(line); + <_ as IntoIterator>::into_iter(iter); + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-22356.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-22356.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-22356.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-22356.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(type_alias_bounds)] + +// pretty-expanded FIXME #23616 + +use std::marker::PhantomData; + +pub struct Handle(T, I); + +impl Handle { + pub fn get_info(&self) -> &I { + let Handle(_, ref info) = *self; + info + } +} + +pub struct BufferHandle { + raw: RawBufferHandle, + _marker: PhantomData, +} + +impl BufferHandle { + pub fn get_info(&self) -> &String { + self.raw.get_info() + } +} + +pub type RawBufferHandle = Handle<::Buffer, String>; + +pub trait Device { + type Buffer; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-22375.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-22375.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-22375.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-22375.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +trait A> {} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-22471.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-22471.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-22471.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-22471.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(type_alias_bounds)] + +type Foo where T: Copy = Box; + +fn main(){} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-22777.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-22777.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-22777.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-22777.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,58 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// This test is reduced from libsyntax. It is just checking that we +// can successfully deal with a "deep" structure, which the drop-check +// was hitting a recursion limit on at one point. + +// pretty-expanded FIXME #23616 + +#![allow(non_camel_case_types)] + +pub fn noop_fold_impl_item() -> SmallVector { + loop { } +} + +pub struct SmallVector(P); +pub struct ImplItem(P); + +struct P(Box); + +struct S01_Method(P); +struct S02_Generics(P); +struct S03_TyParam(P); +struct S04_TyParamBound(S05_PolyTraitRef); +struct S05_PolyTraitRef(S06_TraitRef); +struct S06_TraitRef(S07_Path); +struct S07_Path(Vec); +struct S08_PathSegment(S09_GenericArgs); +struct S09_GenericArgs(P); +struct S10_ParenthesizedParameterData(Option>); +struct S11_Ty(P); +struct S12_Expr(P); +struct S13_Block(Vec>); +struct S14_Stmt(P); +struct S15_Decl(P); +struct S16_Local(P); +struct S17_Pat(P); +struct S18_Mac(Vec>); +struct S19_TokenTree(P); +struct S20_Token(P); +struct S21_Nonterminal(P); +struct S22_Item(P); +struct S23_EnumDef(Vec>); +struct S24_Variant(P); +struct S25_VariantKind(P); +struct S26_StructDef(Vec>); +struct S27_StructField(P); +struct S28_StructFieldKind; + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-22781.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-22781.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-22781.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-22781.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(unused_variables)] +use std::collections::HashMap; +use std::collections::hash_map::Entry::Vacant; + +pub fn foo() { + type F = Box; + let mut map: HashMap<(), F> = HashMap::new(); + let x: &mut F = match map.entry(()) { + Vacant(_) => unimplemented!(), + _ => unimplemented!() + }; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-22814.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-22814.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-22814.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-22814.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +trait Test {} + +macro_rules! test { +( $($name:ident)+) => ( + impl<$($name: Test),*> Test for ($($name,)*) { + } +) +} + +test!(A B C); + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-22872.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-22872.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-22872.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-22872.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +trait Wrap<'b> { + fn foo(&'b mut self); +} + +struct Wrapper

(P); + +impl<'b, P> Wrap<'b> for Wrapper

+where P: Process<'b>, +

>::Item: Iterator { + fn foo(&mut self) {} +} + + +pub trait Process<'a> { + type Item; + fn bar(&'a self); +} + +fn push_process

(process: P) where P: Process<'static> { + let _: Box Wrap<'b>> = Box::new(Wrapper(process)); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-22872.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-22872.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-22872.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-22872.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +error[E0277]: the trait bound `for<'b> P: Process<'b>` is not satisfied + --> $DIR/issue-22872.rs:20:36 + | +LL | let _: Box Wrap<'b>> = Box::new(Wrapper(process)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'b> Process<'b>` is not implemented for `P` + | + = help: consider adding a `where for<'b> P: Process<'b>` bound + = note: required because of the requirements on the impl of `for<'b> Wrap<'b>` for `Wrapper

` + = note: required for the cast to the object type `dyn for<'b> Wrap<'b>` + +error[E0277]: `

>::Item` is not an iterator + --> $DIR/issue-22872.rs:20:36 + | +LL | let _: Box Wrap<'b>> = Box::new(Wrapper(process)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `

>::Item` is not an iterator + | + = help: the trait `for<'b> std::iter::Iterator` is not implemented for `

>::Item` + = note: required because of the requirements on the impl of `for<'b> Wrap<'b>` for `Wrapper

` + = note: required for the cast to the object type `dyn for<'b> Wrap<'b>` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-22894.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-22894.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-22894.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-22894.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#[allow(dead_code)] +static X: &'static str = &*""; +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-23073.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-23073.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-23073.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-23073.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,9 +2,7 @@ --> $DIR/issue-23073.rs:16:17 | LL | type FooT = <::Foo>::T; //~ ERROR ambiguous associated type - | ^^^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<::Foo as Trait>::T` + | ^^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<::Foo as Trait>::T` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-2311-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-2311-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-2311-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-2311-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + + +trait clam { + fn get(self) -> A; +} + +struct foo { + x: A, +} + +impl foo { + pub fn bar>(&self, _c: C) -> B { + panic!(); + } +} + +fn foo(b: A) -> foo { + foo { + x: b + } +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-2311.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-2311.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-2311.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-2311.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +trait clam { fn get(self) -> A; } +trait foo { + fn bar>(&self, c: C) -> B; +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-23122-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-23122-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-23122-2.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-23122-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,10 +1,11 @@ -error[E0275]: overflow evaluating the requirement `<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next` +error[E0275]: overflow evaluating the requirement `<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next: std::marker::Sized` --> $DIR/issue-23122-2.rs:17:15 | LL | impl Next for GetNext { | ^^^^ | = help: consider adding a `#![recursion_limit="128"]` attribute to your crate + = note: required because of the requirements on the impl of `Next` for `GetNext<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next as Next>::Next>` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-2312.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-2312.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-2312.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-2312.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// Testing that the B's are resolved + + +trait clam { fn get(self) -> A; } + +struct foo(isize); + +impl foo { + pub fn bar>(&self, _c: C) -> B { panic!(); } +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-23189.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-23189.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-23189.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-23189.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod module {} + +fn main() { + let _ = module { x: 0 }; //~ERROR expected struct +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-23189.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-23189.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-23189.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-23189.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0574]: expected struct, variant or union type, found module `module` + --> $DIR/issue-23189.rs:14:13 + | +LL | let _ = module { x: 0 }; //~ERROR expected struct + | ^^^^^^ not a struct, variant or union type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0574`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-23406.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-23406.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-23406.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-23406.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +trait Inner { + type T; +} + +impl<'a> Inner for &'a i32 { + type T = i32; +} + +fn f<'a>(x: &'a i32) -> <&'a i32 as Inner>::T { + *x +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-23442.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-23442.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-23442.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-23442.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +use std::marker::PhantomData; + +pub struct UnionedKeys<'a,K> + where K: UnifyKey + 'a +{ + table: &'a mut UnificationTable, + root_key: K, + stack: Vec, +} + +pub trait UnifyKey { + type Value; +} + +pub struct UnificationTable { + values: Delegate, +} + +pub struct Delegate(PhantomData); + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-23477.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-23477.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-23477.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-23477.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// compiler-flags: -g + +pub struct Dst { + pub a: (), + pub b: (), + pub data: [u8], +} + +pub unsafe fn borrow(bytes: &[u8]) -> &Dst { + let dst: &Dst = std::mem::transmute((bytes.as_ptr(), bytes.len())); + dst +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-23550.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-23550.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-23550.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-23550.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![feature(core_intrinsics)] +#![allow(warnings)] + +use std::intrinsics; + +#[derive(Copy, Clone)] +struct Wrap(i64); + +// These volatile intrinsics used to cause an ICE + +unsafe fn test_bool(p: &mut bool, v: bool) { + intrinsics::volatile_load(p); + intrinsics::volatile_store(p, v); +} + +unsafe fn test_immediate_fca(p: &mut Wrap, v: Wrap) { + intrinsics::volatile_load(p); + intrinsics::volatile_store(p, v); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-23649-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-23649-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-23649-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-23649-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#[derive(PartialEq)] +struct Slice { slice: [u8] } + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-23716.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-23716.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-23716.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-23716.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/issue-23716.rs:13:8 | LL | static foo: i32 = 0; - | -------------------- a static `foo` is defined here + | -------------------- the static `foo` is defined here LL | LL | fn bar(foo: i32) {} | ^^^ cannot be named the same as a static @@ -11,7 +11,7 @@ --> $DIR/issue-23716.rs:23:13 | LL | use self::submod::answer; - | -------------------- a static `answer` is imported here + | -------------------- the static `answer` is imported here LL | LL | fn question(answer: i32) {} | ^^^^^^ cannot be named the same as a static diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-24081.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-24081.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-24081.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-24081.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | ^^^^^^^^^^^^^^^^ `Add` redefined here | = note: `Add` 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 +help: you can use `as` to change the binding name of the import | LL | use std::ops::Add as OtherAdd; | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ | ^^^^^^^^^^ `Sub` redefined here | = note: `Sub` 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 +help: you can use `as` to change the binding name of the import | LL | use std::ops::Sub as OtherSub; | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -38,7 +38,7 @@ | ^^^^^^^^ `Mul` redefined here | = note: `Mul` 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 +help: you can use `as` to change the binding name of the import | LL | use std::ops::Mul as OtherMul; | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -53,7 +53,7 @@ | ^^^^^^^ `Div` redefined here | = note: `Div` 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 +help: you can use `as` to change the binding name of the import | LL | use std::ops::Div as OtherDiv; | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -68,7 +68,7 @@ | ^^^^^^^^^ `Rem` redefined here | = note: `Rem` 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 +help: you can use `as` to change the binding name of the import | LL | use std::ops::Rem as OtherRem; | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-24085.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-24085.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-24085.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-24085.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// Regression test for #24085. Errors were occurring in region +// inference due to the requirement that `'a:b'`, which was getting +// incorrectly codegened in connection with the closure below. + +#[derive(Copy,Clone)] +struct Path<'a:'b, 'b> { + x: &'a i32, + tail: Option<&'b Path<'a, 'b>> +} + +#[allow(dead_code, unconditional_recursion)] +fn foo<'a,'b,F>(p: Path<'a, 'b>, mut f: F) + where F: for<'c> FnMut(Path<'a, 'c>) { + foo(p, |x| f(x)) +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-24161.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-24161.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-24161.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-24161.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#[derive(Copy,Clone)] +struct Functions { + a: fn(u32) -> u32, + b: extern "C" fn(u32) -> u32, + c: unsafe fn(u32) -> u32, + d: unsafe extern "C" fn(u32) -> u32 +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-24227.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-24227.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-24227.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-24227.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// This resulted in an ICE. Test for future-proofing +// Issue #24227 + +#![allow(unused)] + +struct Foo<'a> { + x: &'a u8 +} + +impl<'a> Foo<'a> { + fn foo() { + let mut tmp: Self; + } + +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-24338.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-24338.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-24338.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-24338.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// compile-pass + +trait DictLike<'a> { + type ItemsIterator: Iterator; + fn get(c: Self::ItemsIterator) { + c.into_iter(); + } +} + +trait DictLike2<'a> { + type ItemsIterator: Iterator; + + fn items(&self) -> Self::ItemsIterator; + + fn get(&self) { + for _ in self.items() {} + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-24389.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-24389.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-24389.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-24389.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] + +struct Foo; + +impl Foo { + fn new() -> Self { Foo } + fn bar() { Self::new(); } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-24434.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-24434.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-24434.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-24434.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(unused_attributes)] +// compile-flags:--cfg set1 + +#![cfg_attr(set1, feature(custom_attribute))] + +#![foobar] +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-24446.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-24446.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-24446.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-24446.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,8 +10,7 @@ fn main() { static foo: Fn() -> u32 = || -> u32 { - //~^ ERROR mismatched types - //~| ERROR the size for values of type + //~^ ERROR the size for values of type 0 }; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-24446.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-24446.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-24446.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-24446.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,33 +1,12 @@ -error[E0308]: mismatched types - --> $DIR/issue-24446.rs:12:31 - | -LL | static foo: Fn() -> u32 = || -> u32 { - | _______________________________^ -LL | | //~^ ERROR mismatched types -LL | | //~| ERROR the size for values of type -LL | | 0 -LL | | }; - | |_____^ expected trait std::ops::Fn, found closure - | - = note: expected type `(dyn std::ops::Fn() -> u32 + 'static)` - found type `[closure@$DIR/issue-24446.rs:12:31: 16:6]` - error[E0277]: the size for values of type `(dyn std::ops::Fn() -> u32 + 'static)` cannot be known at compilation time - --> $DIR/issue-24446.rs:12:31 + --> $DIR/issue-24446.rs:12:17 | -LL | static foo: Fn() -> u32 = || -> u32 { - | _______________________________^ -LL | | //~^ ERROR mismatched types -LL | | //~| ERROR the size for values of type -LL | | 0 -LL | | }; - | |_____^ doesn't have a size known at compile-time +LL | static foo: Fn() -> u32 = || -> u32 { + | ^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::ops::Fn() -> u32 + 'static)` = note: to learn more, visit - = note: constant expressions must have a statically known size -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors occurred: E0277, E0308. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0277`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-2487-a.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-2487-a.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-2487-a.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-2487-a.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +// pretty-expanded FIXME #23616 + +struct socket { + sock: isize, + +} + +impl Drop for socket { + fn drop(&mut self) {} +} + +impl socket { + pub fn set_identity(&self) { + closure(|| setsockopt_bytes(self.sock.clone())) + } +} + +fn socket() -> socket { + socket { + sock: 1 + } +} + +fn closure(f: F) where F: FnOnce() { f() } + +fn setsockopt_bytes(_sock: isize) { } + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-2502.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-2502.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-2502.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-2502.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + + +// pretty-expanded FIXME #23616 + +struct font<'a> { + fontbuf: &'a Vec , +} + +impl<'a> font<'a> { + pub fn buf(&self) -> &'a Vec { + self.fontbuf + } +} + +fn font(fontbuf: &Vec ) -> font { + font { + fontbuf: fontbuf + } +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-25180.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-25180.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-25180.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-25180.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(non_upper_case_globals)] + +const x: &'static Fn() = &|| println!("ICE here"); + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-25394.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-25394.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-25394.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-25394.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#[derive(Debug)] +struct Row([T]); + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-25396.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-25396.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-25396.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-25396.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^^^^^^^ `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 +help: you can use `as` to change the binding name of the import | LL | use bar::baz as other_baz; //~ ERROR the name `baz` is defined multiple times | ^^^^^^^^^^^^^^^^^^^^^ @@ -21,7 +21,7 @@ | ^^^^^^^^^ `Quux` reimported here | = note: `Quux` 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 +help: you can use `as` to change the binding name of the import | LL | use bar::Quux as OtherQuux; //~ ERROR the name `Quux` is defined multiple times | ^^^^^^^^^^^^^^^^^^^^^^ @@ -35,7 +35,7 @@ | ^^^^^^^^^ `blah` reimported here | = note: `blah` 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 +help: you can use `as` to change the binding name of the import | LL | use bar::blah as other_blah; //~ ERROR the name `blah` is defined multiple times | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ | ^^^^^^^^^ `WOMP` reimported here | = note: `WOMP` 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 +help: you can use `as` to change the binding name of the import | LL | use bar::WOMP as OtherWOMP; //~ ERROR the name `WOMP` is defined multiple times | ^^^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-25793.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-25793.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-25793.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-25793.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,10 +7,9 @@ LL | let r = &mut *self; | ---------- borrow of `*self` occurs here LL | r.get_size(width!(self)) - | ------------------------ - | | | - | | in this macro invocation - | borrow later used here + | -------- ------------ in this macro invocation + | | + | borrow later used by call error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-2590.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-2590.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-2590.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-2590.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -4,6 +4,17 @@ LL | self.tokens //~ ERROR cannot move out of borrowed content | ^^^^^^^^^^^ cannot move out of borrowed content -error: aborting due to previous error +error[E0507]: cannot move out of `self.tokens` which is behind a `&` reference + --> $DIR/issue-2590.rs:22:9 + | +LL | fn parse(&self) -> Vec { + | ----- help: consider changing this to be a mutable reference: `&mut self` +LL | self.tokens //~ ERROR cannot move out of borrowed content + | ^^^^^^^^^^^ + | | + | cannot move out of `self.tokens` which is behind a `&` reference + | `self` is a `&` reference, so the data it refers to cannot be moved + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-26095.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-26095.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-26095.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-26095.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(non_upper_case_globals)] + + +trait HasNumber { + const Number: usize; +} + +enum One {} +enum Two {} + +enum Foo {} + +impl HasNumber for One { + const Number: usize = 1; +} + +impl HasNumber for Two { + const Number: usize = 2; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-2611-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-2611-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-2611-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-2611-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// Tests that impls are allowed to have looser, more permissive bounds +// than the traits require. + + +trait A { + fn b(&self, x: C) -> C; +} + +struct E { + f: isize +} + +impl A for E { + fn b(&self, _x: F) -> F { panic!() } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-26205.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-26205.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-26205.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-26205.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +use std::ops::{Deref, DerefMut}; + +struct Foo; + +impl Foo { + fn foo_mut(&mut self) {} +} + +struct Bar(Foo); + +impl Deref for Bar { + type Target = Foo; + + fn deref(&self) -> &Foo { + &self.0 + } +} + +impl DerefMut for Bar { + fn deref_mut(&mut self) -> &mut Foo { + &mut self.0 + } +} + +fn test(mut bar: Box) { + bar.foo_mut(); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-26217.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-26217.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-26217.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-26217.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -error[E0131]: `main` function is not allowed to have generic parameters - --> $DIR/issue-26217.rs:13:8 - | -LL | fn main<'a>() { - | ^^^^ `main` cannot have generic parameters - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0131`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-26638.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-26638.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-26638.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-26638.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -10,19 +10,17 @@ --> $DIR/issue-26638.rs:14:40 | LL | fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() } - | ^ expected lifetime parameter + | ^ help: consider giving it an explicit bounded or 'static lifetime: `&'static` | = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments - = help: consider giving it an explicit bounded or 'static lifetime error[E0106]: missing lifetime specifier --> $DIR/issue-26638.rs:17:22 | LL | fn parse_type_3() -> &str { unimplemented!() } - | ^ expected lifetime parameter + | ^ help: consider giving it a 'static lifetime: `&'static` | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from - = help: consider giving it a 'static lifetime error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-26646.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-26646.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-26646.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-26646.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![deny(unused_attributes)] + +#[repr(C)] +#[repr(packed)] +pub struct Foo; + +#[repr(packed)] +#[repr(C)] +pub struct Bar; + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-26886.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-26886.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-26886.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-26886.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^^^^^^^^^^^^^ `Arc` reimported here | = note: `Arc` 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 +help: you can use `as` to change the binding name of the import | LL | use std::sync::Arc as OtherArc; //~ ERROR the name `Arc` is defined multiple times | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -22,7 +22,7 @@ | ^^^^^^^^^ `sync` reimported here | = note: `sync` 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 +help: you can use `as` to change the binding name of the import | LL | use std::sync as other_sync; //~ ERROR the name `sync` is defined multiple times | ^^^^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-26997.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-26997.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-26997.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-26997.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +pub struct Foo { + x: isize, + y: isize +} + +impl Foo { + pub extern fn foo_new() -> Foo { + Foo { x: 21, y: 33 } + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27033.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27033.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27033.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27033.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ --> $DIR/issue-27033.rs:17:9 | LL | const C: u8 = 1; - | ---------------- a constant `C` is defined here + | ---------------- the constant `C` is defined here LL | match 1 { LL | C @ 2 => { //~ ERROR match bindings cannot shadow constant | ^ cannot be named the same as a constant diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27105.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27105.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27105.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27105.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +use std::cell::RefCell; +use std::rc::Rc; + +pub struct Callbacks { + callbacks: Vec>>, +} + +impl Callbacks { + pub fn register(&mut self, callback: F) { + self.callbacks.push(Rc::new(RefCell::new(callback))); + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27281.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27281.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27281.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27281.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +pub trait Trait<'a> { + type T; + type U; + fn foo(&self, s: &'a ()) -> &'a (); +} + +impl<'a> Trait<'a> for () { + type T = &'a (); + type U = Self::T; + + fn foo(&self, s: &'a ()) -> &'a () { + let t: Self::T = s; t + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27282-move-match-input-into-guard.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27282-move-match-input-into-guard.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27282-move-match-input-into-guard.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27282-move-match-input-into-guard.rs 2018-12-04 23:41:40.000000000 +0000 @@ -24,10 +24,9 @@ match b { &mut false => {}, _ if { (|| { let bar = b; *bar = false; })(); - //~^ ERROR cannot move out of `b` because it is borrowed [E0505] false } => { }, &mut true => { println!("You might think we should get here"); }, - //~^ ERROR use of moved value: `*b` [E0382] + //~^ ERROR use of moved value: `b` [E0382] _ => panic!("surely we could never get here, since rustc warns it is unreachable."), } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27282-move-match-input-into-guard.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27282-move-match-input-into-guard.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27282-move-match-input-into-guard.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27282-move-match-input-into-guard.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,29 +1,14 @@ -error[E0505]: cannot move out of `b` because it is borrowed - --> $DIR/issue-27282-move-match-input-into-guard.rs:26:17 - | -LL | match b { - | - borrow of `b` occurs here -LL | &mut false => {}, -LL | _ if { (|| { let bar = b; *bar = false; })(); - | ^^ - move occurs due to use in closure - | | - | move out of `b` occurs here -... -LL | &mut true => { println!("You might think we should get here"); }, - | --------- borrow later used here - -error[E0382]: use of moved value: `*b` - --> $DIR/issue-27282-move-match-input-into-guard.rs:29:14 +error[E0382]: use of moved value: `b` + --> $DIR/issue-27282-move-match-input-into-guard.rs:28:14 | LL | _ if { (|| { let bar = b; *bar = false; })(); | -- - variable moved due to use in closure | | | value moved into closure here -... +LL | false } => { }, LL | &mut true => { println!("You might think we should get here"); }, | ^^^^ value used here after move -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors occurred: E0382, E0505. -For more information about an error, try `rustc --explain E0382`. +For more information about this error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -31,7 +31,7 @@ &mut Some(&_) if { // ForceFnOnce needed to exploit #27282 (|| { *x = None; drop(force_fn_once); })(); - //~^ ERROR closure requires unique access to `x` but it is already borrowed [E0500] + //~^ ERROR cannot mutably borrow `x` in match guard [E0510] false } => {} &mut Some(&a) if { // this binds to garbage if we've corrupted discriminant diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-1.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,17 +1,14 @@ -error[E0500]: closure requires unique access to `x` but it is already borrowed +error[E0510]: cannot mutably borrow `x` in match guard --> $DIR/issue-27282-mutate-before-diverging-arm-1.rs:33:14 | LL | match x { - | - borrow occurs here + | - value is immutable in match guard ... LL | (|| { *x = None; drop(force_fn_once); })(); - | ^^ - second borrow occurs due to use of `x` in closure + | ^^ - borrow occurs due to use of `x` in closure | | - | closure construction occurs here -... -LL | &mut Some(&a) if { // this binds to garbage if we've corrupted discriminant - | ------------- borrow later used here + | cannot mutably borrow error: aborting due to previous error -For more information about this error, try `rustc --explain E0500`. +For more information about this error, try `rustc --explain E0510`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -36,7 +36,7 @@ if { // ForceFnOnce needed to exploit #27282 (|| { *x = None; drop(force_fn_once); })(); - //~^ ERROR closure requires unique access to `x` but it is already borrowed [E0500] + //~^ ERROR cannot mutably borrow `x` in match guard [E0510] false } => {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-2.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,17 +1,14 @@ -error[E0500]: closure requires unique access to `x` but it is already borrowed +error[E0510]: cannot mutably borrow `x` in match guard --> $DIR/issue-27282-mutate-before-diverging-arm-2.rs:38:18 | LL | match x { - | - borrow occurs here + | - value is immutable in match guard ... LL | (|| { *x = None; drop(force_fn_once); })(); - | ^^ - second borrow occurs due to use of `x` in closure + | ^^ - borrow occurs due to use of `x` in closure | | - | closure construction occurs here -... -LL | &mut Some(&2) - | ------------- borrow later used here + | cannot mutably borrow error: aborting due to previous error -For more information about this error, try `rustc --explain E0500`. +For more information about this error, try `rustc --explain E0510`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// This is testing an attempt to corrupt the discriminant of the match +// arm in a guard, followed by an attempt to continue matching on that +// corrupted discriminant in the remaining match arms. +// +// Basically this is testing that our new NLL feature of emitting a +// fake read on each match arm is catching cases like this. +// +// This case is interesting because a borrow of **x is untracked, because **x is +// immutable. However, for matches we care that **x refers to the same value +// until we have chosen a match arm. +#![feature(nll)] +struct ForceFnOnce; +fn main() { + let mut x = &mut &Some(&2); + let force_fn_once = ForceFnOnce; + match **x { + None => panic!("unreachable"), + Some(&_) if { + // ForceFnOnce needed to exploit #27282 + (|| { *x = &None; drop(force_fn_once); })(); + //~^ ERROR cannot mutably borrow `x` in match guard [E0510] + false + } => {} + Some(&a) if { // this binds to garbage if we've corrupted discriminant + println!("{}", a); + panic!() + } => {} + _ => panic!("unreachable"), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-3.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-3.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-3.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27282-mutate-before-diverging-arm-3.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error[E0510]: cannot mutably borrow `x` in match guard + --> $DIR/issue-27282-mutate-before-diverging-arm-3.rs:20:14 + | +LL | match **x { + | --- value is immutable in match guard +... +LL | (|| { *x = &None; drop(force_fn_once); })(); + | ^^ - borrow occurs due to use of `x` in closure + | | + | cannot mutably borrow + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0510`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27282-reborrow-ref-mut-in-guard.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27282-reborrow-ref-mut-in-guard.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27282-reborrow-ref-mut-in-guard.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27282-reborrow-ref-mut-in-guard.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,8 +15,8 @@ // reject it. But I want to make sure that we continue to reject it // (under NLL) even when that conservaive check goes away. -// compile-flags: -Z disable-ast-check-for-mutation-in-guard +#![feature(bind_by_move_pattern_guards)] #![feature(nll)] fn main() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-2748-a.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-2748-a.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-2748-a.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-2748-a.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(non_snake_case)] + +// pretty-expanded FIXME #23616 + +struct CMap<'a> { + buf: &'a [u8], +} + +fn CMap(buf: &[u8]) -> CMap { + CMap { + buf: buf + } +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27583.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27583.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27583.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27583.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,57 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// Regression test for issue #27583. Unclear how useful this will be +// going forward, since the issue in question was EXTREMELY sensitive +// to compiler internals (like the precise numbering of nodes), but +// what the hey. + +#![allow(warnings)] + +use std::cell::Cell; +use std::marker::PhantomData; + +pub trait Delegate<'tcx> { } + +pub struct InferCtxt<'a, 'tcx: 'a> { + x: PhantomData<&'a Cell<&'tcx ()>> +} + +pub struct MemCategorizationContext<'t, 'a: 't, 'tcx : 'a> { + x: &'t InferCtxt<'a, 'tcx>, +} + +pub struct ExprUseVisitor<'d, 't, 'a: 't, 'tcx:'a+'d> { + typer: &'t InferCtxt<'a, 'tcx>, + mc: MemCategorizationContext<'t, 'a, 'tcx>, + delegate: &'d mut (Delegate<'tcx>+'d), +} + +impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> { + pub fn new(delegate: &'d mut Delegate<'tcx>, + typer: &'t InferCtxt<'a, 'tcx>) + -> ExprUseVisitor<'d,'t,'a,'tcx> + { + ExprUseVisitor { + typer: typer, + mc: MemCategorizationContext::new(typer), + delegate: delegate, + } + } +} + +impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> { + pub fn new(typer: &'t InferCtxt<'a, 'tcx>) -> MemCategorizationContext<'t, 'a, 'tcx> { + MemCategorizationContext { x: typer } + } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27592.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27592.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27592.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27592.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,19 +1,21 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/issue-27592.rs:26:27 +error[E0515]: cannot return value referencing temporary value + --> $DIR/issue-27592.rs:26:14 | LL | write(|| format_args!("{}", String::from("Hello world"))); - | ^^^^ - temporary value only lives until here - | | - | temporary value does not live long enough + | ^^^^^^^^^^^^^^^^^^^---------------------------^ + | | | + | | temporary value created here + | returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/issue-27592.rs:26:33 +error[E0515]: cannot return value referencing temporary value + --> $DIR/issue-27592.rs:26:14 | LL | write(|| format_args!("{}", String::from("Hello world"))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough + | ^^^^^^^^^^^^^----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | | + | | temporary value created here + | returns a value referencing data owned by the current function error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27889.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27889.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-27889.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-27889.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(unused_assignments)] +#![allow(unused_variables)] +// Test that a field can have the same name in different variants +// of an enum + +pub enum Foo { + X { foo: u32 }, + Y { foo: u32 } +} + +pub fn foo(mut x: Foo) { + let mut y = None; + let mut z = None; + if let Foo::X { ref foo } = x { + z = Some(foo); + } + if let Foo::Y { ref mut foo } = x { + y = Some(foo); + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-2804-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-2804-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-2804-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-2804-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// Minimized version of issue-2804.rs. Both check that callee IDs don't +// clobber the previous node ID in a macro expr + +use std::collections::HashMap; + +fn add_interfaces(managed_ip: String, device: HashMap) { + println!("{}, {}", managed_ip, device["interfaces"]); +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28098.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28098.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28098.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28098.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,13 +10,13 @@ fn main() { let _ = Iterator::next(&mut ()); - //~^ ERROR `(): std::iter::Iterator` is not satisfied + //~^ ERROR `()` is not an iterator for _ in false {} - //~^ ERROR `bool: std::iter::Iterator` is not satisfied + //~^ ERROR `bool` is not an iterator let _ = Iterator::next(&mut ()); - //~^ ERROR `(): std::iter::Iterator` is not satisfied + //~^ ERROR `()` is not an iterator other() } @@ -25,11 +25,11 @@ // check errors are still reported globally let _ = Iterator::next(&mut ()); - //~^ ERROR `(): std::iter::Iterator` is not satisfied + //~^ ERROR `()` is not an iterator let _ = Iterator::next(&mut ()); - //~^ ERROR `(): std::iter::Iterator` is not satisfied + //~^ ERROR `()` is not an iterator for _ in false {} - //~^ ERROR `bool: std::iter::Iterator` is not satisfied + //~^ ERROR `bool` is not an iterator } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28098.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28098.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28098.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28098.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,53 +1,53 @@ -error[E0277]: the trait bound `(): std::iter::Iterator` is not satisfied +error[E0277]: `()` is not an iterator --> $DIR/issue-28098.rs:12:13 | LL | let _ = Iterator::next(&mut ()); - | ^^^^^^^^^^^^^^ `()` is not an iterator; maybe try calling `.iter()` or a similar method + | ^^^^^^^^^^^^^^ `()` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `()` = note: required by `std::iter::Iterator::next` -error[E0277]: the trait bound `bool: std::iter::Iterator` is not satisfied +error[E0277]: `bool` is not an iterator --> $DIR/issue-28098.rs:15:14 | LL | for _ in false {} - | ^^^^^ `bool` is not an iterator; maybe try calling `.iter()` or a similar method + | ^^^^^ `bool` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `bool` = note: required by `std::iter::IntoIterator::into_iter` -error[E0277]: the trait bound `(): std::iter::Iterator` is not satisfied +error[E0277]: `()` is not an iterator --> $DIR/issue-28098.rs:18:13 | LL | let _ = Iterator::next(&mut ()); - | ^^^^^^^^^^^^^^ `()` is not an iterator; maybe try calling `.iter()` or a similar method + | ^^^^^^^^^^^^^^ `()` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `()` = note: required by `std::iter::Iterator::next` -error[E0277]: the trait bound `(): std::iter::Iterator` is not satisfied +error[E0277]: `()` is not an iterator --> $DIR/issue-28098.rs:27:13 | LL | let _ = Iterator::next(&mut ()); - | ^^^^^^^^^^^^^^ `()` is not an iterator; maybe try calling `.iter()` or a similar method + | ^^^^^^^^^^^^^^ `()` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `()` = note: required by `std::iter::Iterator::next` -error[E0277]: the trait bound `(): std::iter::Iterator` is not satisfied +error[E0277]: `()` is not an iterator --> $DIR/issue-28098.rs:30:13 | LL | let _ = Iterator::next(&mut ()); - | ^^^^^^^^^^^^^^ `()` is not an iterator; maybe try calling `.iter()` or a similar method + | ^^^^^^^^^^^^^^ `()` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `()` = note: required by `std::iter::Iterator::next` -error[E0277]: the trait bound `bool: std::iter::Iterator` is not satisfied +error[E0277]: `bool` is not an iterator --> $DIR/issue-28098.rs:33:14 | LL | for _ in false {} - | ^^^^^ `bool` is not an iterator; maybe try calling `.iter()` or a similar method + | ^^^^^ `bool` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `bool` = note: required by `std::iter::IntoIterator::into_iter` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28134.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28134.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28134.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28134.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --test + +#![test] //~ ERROR only functions may be used as tests diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28134.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28134.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28134.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28134.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: only functions may be used as tests + --> $DIR/issue-28134.rs:13:1 + | +LL | #![test] //~ ERROR only functions may be used as tests + | ^^^^^^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28279.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28279.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28279.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28279.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +use std::rc::Rc; + +fn test1() -> Rc Fn(&'a usize) + 'static> { + if let Some(_) = Some(1) { + loop{} + } else { + loop{} + } +} + +fn test2() -> *mut (for<'a> Fn(&'a usize) + 'static) { + if let Some(_) = Some(1) { + loop{} + } else { + loop{} + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28388-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28388-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28388-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28388-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,6 +10,6 @@ // Prefix in imports with empty braces should be resolved and checked privacy, stability, etc. -use foo::{}; //~ ERROR cannot find module or enum `foo` in the crate root +use foo::{}; //~ ERROR unresolved import `foo` fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28388-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28388-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28388-1.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28388-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,9 +1,9 @@ -error[E0578]: cannot find module or enum `foo` in the crate root +error[E0432]: unresolved import `foo` --> $DIR/issue-28388-1.rs:13:5 | -LL | use foo::{}; //~ ERROR cannot find module or enum `foo` in the crate root - | ^^^ not found in the crate root +LL | use foo::{}; //~ ERROR unresolved import `foo` + | ^^^^^^^ no `foo` in the root error: aborting due to previous error -For more information about this error, try `rustc --explain E0578`. +For more information about this error, try `rustc --explain E0432`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28388-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28388-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28388-2.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28388-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ error[E0603]: module `n` is private - --> $DIR/issue-28388-2.rs:17:5 + --> $DIR/issue-28388-2.rs:17:8 | LL | use m::n::{}; - | ^^^^^^^^ + | ^ error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28561.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28561.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28561.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28561.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,121 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#[derive(Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] +struct Array { + f00: [T; 00], + f01: [T; 01], + f02: [T; 02], + f03: [T; 03], + f04: [T; 04], + f05: [T; 05], + f06: [T; 06], + f07: [T; 07], + f08: [T; 08], + f09: [T; 09], + f10: [T; 10], + f11: [T; 11], + f12: [T; 12], + f13: [T; 13], + f14: [T; 14], + f15: [T; 15], + f16: [T; 16], + f17: [T; 17], + f18: [T; 18], + f19: [T; 19], + f20: [T; 20], + f21: [T; 21], + f22: [T; 22], + f23: [T; 23], + f24: [T; 24], + f25: [T; 25], + f26: [T; 26], + f27: [T; 27], + f28: [T; 28], + f29: [T; 29], + f30: [T; 30], + f31: [T; 31], + f32: [T; 32], +} + +// FIXME(#44580): merge with `Array` once `[T; N]: Clone` where `T: Clone` +#[derive(Clone, Copy)] +struct CopyArray { + f00: [T; 00], + f01: [T; 01], + f02: [T; 02], + f03: [T; 03], + f04: [T; 04], + f05: [T; 05], + f06: [T; 06], + f07: [T; 07], + f08: [T; 08], + f09: [T; 09], + f10: [T; 10], + f11: [T; 11], + f12: [T; 12], + f13: [T; 13], + f14: [T; 14], + f15: [T; 15], + f16: [T; 16], + f17: [T; 17], + f18: [T; 18], + f19: [T; 19], + f20: [T; 20], + f21: [T; 21], + f22: [T; 22], + f23: [T; 23], + f24: [T; 24], + f25: [T; 25], + f26: [T; 26], + f27: [T; 27], + f28: [T; 28], + f29: [T; 29], + f30: [T; 30], + f31: [T; 31], + f32: [T; 32], +} + +#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +struct Fn { + f00: fn(), + f01: fn(A), + f02: fn(A, B), + f03: fn(A, B, C), + f04: fn(A, B, C, D), + f05: fn(A, B, C, D, E), + f06: fn(A, B, C, D, E, F), + f07: fn(A, B, C, D, E, F, G), + f08: fn(A, B, C, D, E, F, G, H), + f09: fn(A, B, C, D, E, F, G, H, I), + f10: fn(A, B, C, D, E, F, G, H, I, J), + f11: fn(A, B, C, D, E, F, G, H, I, J, K), + f12: fn(A, B, C, D, E, F, G, H, I, J, K, L), +} + +#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] +struct Tuple { + f00: (), + f01: (A), + f02: (A, B), + f03: (A, B, C), + f04: (A, B, C, D), + f05: (A, B, C, D, E), + f06: (A, B, C, D, E, F), + f07: (A, B, C, D, E, F, G), + f08: (A, B, C, D, E, F, G, H), + f09: (A, B, C, D, E, F, G, H, I), + f10: (A, B, C, D, E, F, G, H, I, J), + f11: (A, B, C, D, E, F, G, H, I, J, K), + f12: (A, B, C, D, E, F, G, H, I, J, K, L), +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28600.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28600.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28600.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28600.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// #28600 ICE: pub extern fn with parameter type &str inside struct impl + +struct Test; + +impl Test { + #[allow(dead_code)] + #[allow(unused_variables)] + pub extern fn test(val: &str) { + + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28822.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28822.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28822.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28822.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] + +fn main() {} + +const fn size_ofs(_: usize) {} +const fn size_ofs2(_foo: usize) {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28848.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28848.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28848.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28848.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - struct Foo<'a, 'b: 'a>(&'a &'b ()); impl<'a, 'b> Foo<'a, 'b> { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28848.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28848.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28848.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28848.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,16 +1,16 @@ error[E0478]: lifetime bound not satisfied - --> $DIR/issue-28848.rs:22:5 + --> $DIR/issue-28848.rs:20:5 | LL | Foo::<'a, 'b>::xmute(u) //~ ERROR lifetime bound not satisfied | ^^^^^^^^^^^^^^^^^^^^ | -note: lifetime parameter instantiated with the lifetime 'b as defined on the function body at 21:16 - --> $DIR/issue-28848.rs:21:16 +note: lifetime parameter instantiated with the lifetime 'b as defined on the function body at 19:16 + --> $DIR/issue-28848.rs:19:16 | LL | pub fn foo<'a, 'b>(u: &'b ()) -> &'a () { | ^^ -note: but lifetime parameter must outlive the lifetime 'a as defined on the function body at 21:12 - --> $DIR/issue-28848.rs:21:12 +note: but lifetime parameter must outlive the lifetime 'a as defined on the function body at 19:12 + --> $DIR/issue-28848.rs:19:12 | LL | pub fn foo<'a, 'b>(u: &'b ()) -> &'a () { | ^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28871.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28871.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28871.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28871.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// Regression test for #28871. The problem is that rustc encountered +// two ways to project, one from a where clause and one from the where +// clauses on the trait definition. (In fact, in this case, the where +// clauses originated from the trait definition as well.) The true +// cause of the error is that the trait definition where clauses are +// not being normalized, and hence the two sources are considered in +// conflict, and not a duplicate. Hacky solution is to prefer where +// clauses over the data found in the trait definition. + +trait T { + type T; +} + +struct S; +impl T for S { + type T = S; +} + +trait T2 { + type T: Iterator::T>; +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28936.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28936.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28936.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28936.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +pub type Session = i32; +pub struct StreamParser<'a, T> { + _tokens: T, + _session: &'a mut Session, +} + +impl<'a, T> StreamParser<'a, T> { + pub fn thing(&mut self) -> bool { true } +} + +pub fn parse_stream, U, F>( + _session: &mut Session, _tokens: T, _f: F) -> U + where F: Fn(&mut StreamParser) -> U { panic!(); } + +pub fn thing(session: &mut Session) { + let mut stream = vec![1, 2, 3].into_iter(); + + let _b = parse_stream(session, + stream.by_ref(), + // replacing the above with the following fixes it + //&mut stream, + |p| p.thing()); + +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28999.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28999.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-28999.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-28999.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +pub struct Xyz<'a, V> { + pub v: (V, &'a u32), +} + +pub fn eq<'a, 's, 't, V>(this: &'s Xyz<'a, V>, other: &'t Xyz<'a, V>) -> bool + where V: PartialEq { + this.v == other.v +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-29030.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-29030.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-29030.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-29030.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#[derive(Debug)] +struct Message<'a, P: 'a = &'a [u8]> { + header: &'a [u8], + payload: P, +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-29037.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-29037.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-29037.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-29037.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// This test ensures that each pointer type `P` is covariant in `X`. + +use std::rc::Rc; +use std::sync::Arc; + +fn a<'r>(x: Box<&'static str>) -> Box<&'r str> { + x +} + +fn b<'r, 'w>(x: &'w &'static str) -> &'w &'r str { + x +} + +fn c<'r>(x: Arc<&'static str>) -> Arc<&'r str> { + x +} + +fn d<'r>(x: Rc<&'static str>) -> Rc<&'r str> { + x +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-29048.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-29048.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-29048.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-29048.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +pub struct Chan; +pub struct ChanSelect<'c, T> { + chans: Vec<(&'c Chan, T)>, +} +impl<'c, T> ChanSelect<'c, T> { + pub fn add_recv_ret(&mut self, chan: &'c Chan, ret: T) + { + self.chans.push((chan, ret)); + } +} +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-2904.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-2904.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-2904.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-2904.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,89 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(unused_must_use)] +#![allow(dead_code)] +#![allow(unused_mut)] +#![allow(non_camel_case_types)] + +// Map representation + +use std::fmt; +use std::io::prelude::*; +use square::{bot, wall, rock, lambda, closed_lift, open_lift, earth, empty}; + +enum square { + bot, + wall, + rock, + lambda, + closed_lift, + open_lift, + earth, + empty +} + +impl fmt::Debug for square { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", match *self { + bot => { "R".to_string() } + wall => { "#".to_string() } + rock => { "*".to_string() } + lambda => { "\\".to_string() } + closed_lift => { "L".to_string() } + open_lift => { "O".to_string() } + earth => { ".".to_string() } + empty => { " ".to_string() } + }) + } +} + +fn square_from_char(c: char) -> square { + match c { + 'R' => { bot } + '#' => { wall } + '*' => { rock } + '\\' => { lambda } + 'L' => { closed_lift } + 'O' => { open_lift } + '.' => { earth } + ' ' => { empty } + _ => { + println!("invalid square: {}", c); + panic!() + } + } +} + +fn read_board_grid(mut input: rdr) + -> Vec> { + let mut input: &mut Read = &mut input; + let mut grid = Vec::new(); + let mut line = [0; 10]; + input.read(&mut line); + let mut row = Vec::new(); + for c in &line { + row.push(square_from_char(*c as char)) + } + grid.push(row); + let width = grid[0].len(); + for row in &grid { assert_eq!(row.len(), width) } + grid +} + +mod test { + #[test] + pub fn trivial_to_string() { + assert_eq!(lambda.to_string(), "\\") + } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-29071.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-29071.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-29071.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-29071.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(non_upper_case_globals)] + +fn ret() -> u32 { + static x: u32 = 10; + x & if true { 10u32 } else { 20u32 } & x +} + +fn ret2() -> &'static u32 { + static x: u32 = 10; + if true { 10u32; } else { 20u32; } + &x +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-29161.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-29161.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-29161.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-29161.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -5,10 +5,10 @@ | ^^^ `pub` not permitted here because it's implied error[E0603]: struct `A` is private - --> $DIR/issue-29161.rs:23:5 + --> $DIR/issue-29161.rs:23:8 | LL | a::A::default(); - | ^^^^^^^^^^^^^ + | ^ error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-29276.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-29276.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-29276.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-29276.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +struct S([u8; { struct Z; 0 }]); + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-29516.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-29516.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-29516.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-29516.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![feature(optin_builtin_traits)] + +auto trait NotSame {} + +impl !NotSame for (A, A) {} + +trait OneOfEach {} + +impl OneOfEach for (A,) {} + +impl OneOfEach for (A, B) +where + (B,): OneOfEach, + (A, B): NotSame, +{ +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-29540.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-29540.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-29540.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-29540.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,502 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#[derive(Debug)] +pub struct Config { + pub name: String, + pub cluster: String, + pub debug_none: String, + pub debug_lockdep: String, + pub debug_context: String, + pub debug_crush: String, + pub debug_mds: String, + pub debug_mds_balancer: String, + pub debug_mds_locker: String, + pub debug_mds_log: String, + pub debug_mds_log_expire: String, + pub debug_mds_migrator: String, + pub debug_buffer: String, + pub debug_timer: String, + pub debug_filer: String, + pub debug_striper: String, + pub debug_objecter: String, + pub debug_rados: String, + pub debug_rbd: String, + pub debug_journaler: String, + pub debug_objectcacher: String, + pub debug_client: String, + pub debug_osd: String, + pub debug_optracker: String, + pub debug_objclass: String, + pub debug_filestore: String, + pub debug_keyvaluestore: String, + pub debug_journal: String, + pub debug_ms: String, + pub debug_mon: String, + pub debug_monc: String, + pub debug_paxos: String, + pub debug_tp: String, + pub debug_auth: String, + pub debug_crypto: String, + pub debug_finisher: String, + pub debug_heartbeatmap: String, + pub debug_perfcounter: String, + pub debug_rgw: String, + pub debug_civetweb: String, + pub debug_javaclient: String, + pub debug_asok: String, + pub debug_throttle: String, + pub host: String, + pub fsid: String, + pub public_addr: String, + pub cluster_addr: String, + pub public_network: String, + pub cluster_network: String, + pub num_client: String, + pub monmap: String, + pub mon_host: String, + pub lockdep: String, + pub run_dir: String, + pub admin_socket: String, + pub daemonize: String, + pub pid_file: String, + pub chdir: String, + pub max_open_files: String, + pub restapi_log_level: String, + pub restapi_base_url: String, + pub fatal_signal_handlers: String, + pub log_file: String, + pub log_max_new: String, + pub log_max_recent: String, + pub log_to_stderr: String, + pub err_to_stderr: String, + pub log_to_syslog: String, + pub err_to_syslog: String, + pub log_flush_on_exit: String, + pub log_stop_at_utilization: String, + pub clog_to_monitors: String, + pub clog_to_syslog: String, + pub clog_to_syslog_level: String, + pub clog_to_syslog_facility: String, + pub mon_cluster_log_to_syslog: String, + pub mon_cluster_log_to_syslog_level: String, + pub mon_cluster_log_to_syslog_facility: String, + pub mon_cluster_log_file: String, + pub mon_cluster_log_file_level: String, + pub key: String, + pub keyfile: String, + pub keyring: String, + pub heartbeat_interval: String, + pub heartbeat_file: String, + pub heartbeat_inject_failure: String, + pub perf: String, + pub ms_tcp_nodelay: String, + pub ms_tcp_rcvbuf: String, + pub ms_initial_backoff: String, + pub ms_max_backoff: String, + pub ms_nocrc: String, + pub ms_die_on_bad_msg: String, + pub ms_die_on_unhandled_msg: String, + pub ms_die_on_old_message: String, + pub ms_dispatch_throttle_bytes: String, + pub ms_bind_ipv6: String, + pub ms_bind_port_min: String, + pub ms_bind_port_max: String, + pub ms_rwthread_stack_bytes: String, + pub ms_tcp_read_timeout: String, + pub ms_pq_max_tokens_per_priority: String, + pub ms_pq_min_cost: String, + pub ms_inject_socket_failures: String, + pub ms_inject_delay_type: String, + pub ms_inject_delay_msg_type: String, + pub ms_inject_delay_max: String, + pub ms_inject_delay_probability: String, + pub ms_inject_internal_delays: String, + pub ms_dump_on_send: String, + pub inject_early_sigterm: String, + pub mon_data: String, + pub mon_initial_members: String, + pub mon_sync_fs_threshold: String, + pub mon_compact_on_start: String, + pub mon_compact_on_bootstrap: String, + pub mon_compact_on_trim: String, + pub mon_tick_interval: String, + pub mon_subscribe_interval: String, + pub mon_delta_reset_interval: String, + pub mon_osd_laggy_halflife: String, + pub mon_osd_laggy_weight: String, + pub mon_osd_adjust_heartbeat_grace: String, + pub mon_osd_adjust_down_out_interval: String, + pub mon_osd_auto_mark_in: String, + pub mon_osd_auto_mark_auto_out_in: String, + pub mon_osd_auto_mark_new_in: String, + pub mon_osd_down_out_interval: String, + pub mon_osd_down_out_subtree_limit: String, + pub mon_osd_min_up_ratio: String, + pub mon_osd_min_in_ratio: String, + pub mon_osd_max_op_age: String, + pub mon_osd_max_split_count: String, + pub mon_osd_allow_primary_temp: String, + pub mon_osd_allow_primary_affinity: String, + pub mon_stat_smooth_intervals: String, + pub mon_lease: String, + pub mon_lease_renew_interval: String, + pub mon_lease_ack_timeout: String, + pub mon_clock_drift_allowed: String, + pub mon_clock_drift_warn_backoff: String, + pub mon_timecheck_interval: String, + pub mon_accept_timeout: String, + pub mon_pg_create_interval: String, + pub mon_pg_stuck_threshold: String, + pub mon_pg_warn_min_per_osd: String, + pub mon_pg_warn_max_object_skew: String, + pub mon_pg_warn_min_objects: String, + pub mon_pg_warn_min_pool_objects: String, + pub mon_cache_target_full_warn_ratio: String, + pub mon_osd_full_ratio: String, + pub mon_osd_nearfull_ratio: String, + pub mon_globalid_prealloc: String, + pub mon_osd_report_timeout: String, + pub mon_force_standby_active: String, + pub mon_warn_on_old_mons: String, + pub mon_warn_on_legacy_crush_tunables: String, + pub mon_warn_on_osd_down_out_interval_zero: String, + pub mon_warn_on_cache_pools_without_hit_sets: String, + pub mon_min_osdmap_epochs: String, + pub mon_max_pgmap_epochs: String, + pub mon_max_log_epochs: String, + pub mon_max_mdsmap_epochs: String, + pub mon_max_osd: String, + pub mon_probe_timeout: String, + pub mon_slurp_timeout: String, + pub mon_slurp_bytes: String, + pub mon_client_bytes: String, + pub mon_daemon_bytes: String, + pub mon_max_log_entries_per_event: String, + pub mon_health_data_update_interval: String, + pub mon_data_avail_crit: String, + pub mon_data_avail_warn: String, + pub mon_config_key_max_entry_size: String, + pub mon_sync_timeout: String, + pub mon_sync_max_payload_size: String, + pub mon_sync_debug: String, + pub mon_sync_debug_leader: String, + pub mon_sync_debug_provider: String, + pub mon_sync_debug_provider_fallback: String, + pub mon_inject_sync_get_chunk_delay: String, + pub mon_osd_min_down_reporters: String, + pub mon_osd_min_down_reports: String, + pub mon_osd_force_trim_to: String, + pub mon_mds_force_trim_to: String, + pub mon_advanced_debug_mode: String, + pub mon_debug_dump_transactions: String, + pub mon_debug_dump_location: String, + pub mon_sync_provider_kill_at: String, + pub mon_sync_requester_kill_at: String, + pub mon_leveldb_write_buffer_size: String, + pub mon_leveldb_cache_size: String, + pub mon_leveldb_block_size: String, + pub mon_leveldb_bloom_size: String, + pub mon_leveldb_max_open_files: String, + pub mon_leveldb_compression: String, + pub mon_leveldb_paranoid: String, + pub mon_leveldb_log: String, + pub mon_leveldb_size_warn: String, + pub mon_force_quorum_join: String, + pub paxos_stash_full_interval: String, + pub paxos_max_join_drift: String, + pub paxos_propose_interval: String, + pub paxos_min_wait: String, + pub paxos_min: String, + pub paxos_trim_min: String, + pub paxos_trim_max: String, + pub paxos_service_trim_min: String, + pub paxos_service_trim_max: String, + pub paxos_kill_at: String, + pub clock_offset: String, + pub auth_cluster_required: String, + pub auth_service_required: String, + pub auth_client_required: String, + pub auth_supported: String, + pub cephx_require_signatures: String, + pub cephx_cluster_require_signatures: String, + pub cephx_service_require_signatures: String, + pub cephx_sign_messages: String, + pub auth_mon_ticket_ttl: String, + pub auth_service_ticket_ttl: String, + pub auth_debug: String, + pub mon_client_hunt_interval: String, + pub mon_client_ping_interval: String, + pub mon_client_ping_timeout: String, + pub mon_client_hunt_interval_backoff: String, + pub mon_client_hunt_interval_max_multiple: String, + pub mon_client_max_log_entries_per_message: String, + pub mon_max_pool_pg_num: String, + pub mon_pool_quota_warn_threshold: String, + pub mon_pool_quota_crit_threshold: String, + pub client_cache_size: String, + pub client_cache_mid: String, + pub client_use_random_mds: String, + pub client_mount_timeout: String, + pub client_tick_interval: String, + pub client_trace: String, + pub client_readahead_min: String, + pub client_readahead_max_bytes: String, + pub client_readahead_max_periods: String, + pub client_snapdir: String, + pub client_mountpoint: String, + pub client_notify_timeout: String, + pub osd_client_watch_timeout: String, + pub client_caps_release_delay: String, + pub client_oc: String, + pub client_oc_size: String, + pub client_oc_max_dirty: String, + pub client_oc_target_dirty: String, + pub client_oc_max_dirty_age: String, + pub client_oc_max_objects: String, + pub client_debug_force_sync_read: String, + pub client_debug_inject_tick_delay: String, + pub client_max_inline_size: String, + pub fuse_use_invalidate_cb: String, + pub fuse_allow_other: String, + pub fuse_default_permissions: String, + pub fuse_big_writes: String, + pub fuse_atomic_o_trunc: String, + pub fuse_debug: String, + pub fuse_multithreaded: String, + pub crush_location: String, + pub objecter_tick_interval: String, + pub objecter_timeout: String, + pub objecter_inflight_op_bytes: String, + pub objecter_inflight_ops: String, + pub journaler_allow_split_entries: String, + pub journaler_write_head_interval: String, + pub journaler_prefetch_periods: String, + pub journaler_prezero_periods: String, + pub journaler_batch_interval: String, + pub journaler_batch_max: String, + pub mds_data: String, + pub mds_max_file_size: String, + pub mds_cache_size: String, + pub mds_cache_mid: String, + pub mds_mem_max: String, + pub mds_dir_max_commit_size: String, + pub mds_decay_halflife: String, + pub mds_beacon_interval: String, + pub mds_beacon_grace: String, + pub mds_enforce_unique_name: String, + pub mds_blacklist_interval: String, + pub mds_session_timeout: String, + pub mds_freeze_tree_timeout: String, + pub mds_session_autoclose: String, + pub mds_reconnect_timeout: String, + pub mds_tick_interval: String, + pub mds_dirstat_min_interval: String, + pub mds_scatter_nudge_interval: String, + pub mds_client_prealloc_inos: String, + pub mds_early_reply: String, + pub mds_default_dir_hash: String, + pub mds_log: String, + pub mds_log_skip_corrupt_events: String, + pub mds_log_max_events: String, + pub mds_log_segment_size: String, + pub mds_log_max_segments: String, + pub mds_log_max_expiring: String, + pub mds_bal_sample_interval: String, + pub mds_bal_replicate_threshold: String, + pub mds_bal_unreplicate_threshold: String, + pub mds_bal_frag: String, + pub mds_bal_split_size: String, + pub mds_bal_split_rd: String, + pub mds_bal_split_wr: String, + pub mds_bal_split_bits: String, + pub mds_bal_merge_size: String, + pub mds_bal_merge_rd: String, + pub mds_bal_merge_wr: String, + pub mds_bal_interval: String, + pub mds_bal_fragment_interval: String, + pub mds_bal_idle_threshold: String, + pub mds_bal_max: String, + pub mds_bal_max_until: String, + pub mds_bal_mode: String, + pub mds_bal_min_rebalance: String, + pub mds_bal_min_start: String, + pub mds_bal_need_min: String, + pub mds_bal_need_max: String, + pub mds_bal_midchunk: String, + pub mds_bal_minchunk: String, + pub mds_bal_target_removal_min: String, + pub mds_bal_target_removal_max: String, + pub mds_replay_interval: String, + pub mds_shutdown_check: String, + pub mds_thrash_exports: String, + pub mds_thrash_fragments: String, + pub mds_dump_cache_on_map: String, + pub mds_dump_cache_after_rejoin: String, + pub mds_verify_scatter: String, + pub mds_debug_scatterstat: String, + pub mds_debug_frag: String, + pub mds_debug_auth_pins: String, + pub mds_debug_subtrees: String, + pub mds_kill_mdstable_at: String, + pub mds_kill_export_at: String, + pub mds_kill_import_at: String, + pub mds_kill_link_at: String, + pub mds_kill_rename_at: String, + pub mds_kill_openc_at: String, + pub mds_kill_journal_at: String, + pub mds_kill_journal_expire_at: String, + pub mds_kill_journal_replay_at: String, + pub mds_kill_create_at: String, + pub mds_open_remote_link_mode: String, + pub mds_inject_traceless_reply_probability: String, + pub mds_wipe_sessions: String, + pub mds_wipe_ino_prealloc: String, + pub mds_skip_ino: String, + pub max_mds: String, + pub mds_standby_for_name: String, + pub mds_standby_for_rank: String, + pub mds_standby_replay: String, + pub osd_compact_leveldb_on_mount: String, + pub osd_max_backfills: String, + pub osd_backfill_full_ratio: String, + pub osd_backfill_retry_interval: String, + pub osd_agent_max_ops: String, + pub osd_agent_min_evict_effort: String, + pub osd_agent_quantize_effort: String, + pub osd_agent_delay_time: String, + pub osd_agent_hist_halflife: String, + pub osd_agent_slop: String, + pub osd_uuid: String, + pub osd_data: String, + pub osd_journal: String, + pub osd_journal_size: String, + pub osd_max_write_size: String, + pub osd_max_pgls: String, + pub osd_client_message_size_cap: String, + pub osd_client_message_cap: String, + pub osd_pg_bits: String, + pub osd_pgp_bits: String, + pub osd_crush_chooseleaf_type: String, + pub osd_pool_default_crush_rule: String, + pub osd_pool_default_crush_replicated_ruleset: String, + pub osd_pool_erasure_code_stripe_width: String, + pub osd_pool_default_size: String, + pub osd_pool_default_min_size: String, + pub osd_pool_default_pg_num: String, + pub osd_pool_default_pgp_num: String, + pub osd_pool_default_erasure_code_directory: String, + pub osd_pool_default_erasure_code_profile: String, + pub osd_erasure_code_plugins: String, + pub osd_pool_default_flags: String, + pub osd_pool_default_flag_hashpspool: String, + pub osd_pool_default_hit_set_bloom_fpp: String, + pub osd_pool_default_cache_target_dirty_ratio: String, + pub osd_pool_default_cache_target_full_ratio: String, + pub osd_pool_default_cache_min_flush_age: String, + pub osd_pool_default_cache_min_evict_age: String, + pub osd_hit_set_min_size: String, + pub osd_hit_set_max_size: String, + pub osd_hit_set_namespace: String, + pub osd_tier_default_cache_mode: String, + pub osd_tier_default_cache_hit_set_count: String, + pub osd_tier_default_cache_hit_set_period: String, + pub osd_tier_default_cache_hit_set_type: String, + pub osd_map_dedup: String, + pub osd_map_max_advance: String, + pub osd_map_cache_size: String, + pub osd_map_message_max: String, + pub osd_map_share_max_epochs: String, + pub osd_op_threads: String, + pub osd_peering_wq_batch_size: String, + pub osd_op_pq_max_tokens_per_priority: String, + pub osd_op_pq_min_cost: String, + pub osd_disk_threads: String, + pub osd_disk_thread_ioprio_class: String, + pub osd_disk_thread_ioprio_priority: String, + pub osd_recovery_threads: String, + pub osd_recover_clone_overlap: String, + pub osd_recover_clone_overlap_limit: String, + pub osd_backfill_scan_min: String, + pub osd_backfill_scan_max: String, + pub osd_op_thread_timeout: String, + pub osd_recovery_thread_timeout: String, + pub osd_snap_trim_thread_timeout: String, + pub osd_snap_trim_sleep: String, + pub osd_scrub_thread_timeout: String, + pub osd_scrub_finalize_thread_timeout: String, + pub osd_scrub_invalid_stats: String, + pub osd_remove_thread_timeout: String, + pub osd_command_thread_timeout: String, + pub osd_age: String, + pub osd_age_time: String, + pub osd_heartbeat_addr: String, + pub osd_heartbeat_interval: String, + pub osd_heartbeat_grace: String, + pub osd_heartbeat_min_peers: String, + pub osd_pg_max_concurrent_snap_trims: String, + pub osd_heartbeat_min_healthy_ratio: String, + pub osd_mon_heartbeat_interval: String, + pub osd_mon_report_interval_max: String, + pub osd_mon_report_interval_min: String, + pub osd_pg_stat_report_interval_max: String, + pub osd_mon_ack_timeout: String, + pub osd_default_data_pool_replay_window: String, + pub osd_preserve_trimmed_log: String, + pub osd_auto_mark_unfound_lost: String, + pub osd_recovery_delay_start: String, + pub osd_recovery_max_active: String, + pub osd_recovery_max_single_start: String, + pub osd_recovery_max_chunk: String, + pub osd_copyfrom_max_chunk: String, + pub osd_push_per_object_cost: String, + pub osd_max_push_cost: String, + pub osd_max_push_objects: String, + pub osd_recovery_forget_lost_objects: String, + pub osd_max_scrubs: String, + pub osd_scrub_load_threshold: String, + pub osd_scrub_min_interval: String, + pub osd_scrub_max_interval: String, + pub osd_scrub_chunk_min: String, + pub osd_scrub_chunk_max: String, + pub osd_scrub_sleep: String, + pub osd_deep_scrub_interval: String, + pub osd_deep_scrub_stride: String, + pub osd_scan_list_ping_tp_interval: String, + pub osd_auto_weight: String, + pub osd_class_dir: String, + pub osd_open_classes_on_start: String, + pub osd_check_for_log_corruption: String, + pub osd_use_stale_snap: String, + pub osd_rollback_to_cluster_snap: String, + pub osd_default_notify_timeout: String, + pub osd_kill_backfill_at: String, + pub osd_pg_epoch_persisted_max_stale: String, + pub osd_min_pg_log_entries: String, + pub osd_max_pg_log_entries: String, + pub osd_op_complaint_time: String, + pub osd_command_max_records: String, + pub osd_op_log_threshold: String, + pub osd_verify_sparse_read_holes: String, + pub osd_debug_drop_ping_probability: String, + pub osd_debug_drop_ping_duration: String, + pub osd_debug_drop_pg_create_probability: String, + pub osd_debug_drop_pg_create_duration: String, + pub osd_debug_drop_op_probability: String, + pub osd_debug_op_order: String, + pub osd_debug_verify_snaps_on_info: String, + pub osd_debug_verify_stray_on_activate: String, + pub osd_debug_skip_full_check_in_backfill_reservation: String, + pub osd_debug_reject_backfill_probability: String, + pub osd_enable_op_tracker: String, +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-29710.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-29710.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-29710.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-29710.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![deny(unused_results)] +#![allow(dead_code)] + +#[derive(Debug)] +struct A(usize); + +#[derive(Debug)] +struct B { a: usize } + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-29740.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-29740.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-29740.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-29740.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,327 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// Regression test for #29740. Inefficient MIR matching algorithms +// generated way too much code for this sort of case, leading to OOM. +#![allow(non_snake_case)] + +pub mod KeyboardEventConstants { + pub const DOM_KEY_LOCATION_STANDARD: u32 = 0; + pub const DOM_KEY_LOCATION_LEFT: u32 = 1; + pub const DOM_KEY_LOCATION_RIGHT: u32 = 2; + pub const DOM_KEY_LOCATION_NUMPAD: u32 = 3; +} // mod KeyboardEventConstants + +pub enum Key { + Space, + Apostrophe, + Comma, + Minus, + Period, + Slash, + Num0, + Num1, + Num2, + Num3, + Num4, + Num5, + Num6, + Num7, + Num8, + Num9, + Semicolon, + Equal, + A, + B, + C, + D, + E, + F, + G, + H, + I, + J, + K, + L, + M, + N, + O, + P, + Q, + R, + S, + T, + U, + V, + W, + X, + Y, + Z, + LeftBracket, + Backslash, + RightBracket, + GraveAccent, + World1, + World2, + + Escape, + Enter, + Tab, + Backspace, + Insert, + Delete, + Right, + Left, + Down, + Up, + PageUp, + PageDown, + Home, + End, + CapsLock, + ScrollLock, + NumLock, + PrintScreen, + Pause, + F1, + F2, + F3, + F4, + F5, + F6, + F7, + F8, + F9, + F10, + F11, + F12, + F13, + F14, + F15, + F16, + F17, + F18, + F19, + F20, + F21, + F22, + F23, + F24, + F25, + Kp0, + Kp1, + Kp2, + Kp3, + Kp4, + Kp5, + Kp6, + Kp7, + Kp8, + Kp9, + KpDecimal, + KpDivide, + KpMultiply, + KpSubtract, + KpAdd, + KpEnter, + KpEqual, + LeftShift, + LeftControl, + LeftAlt, + LeftSuper, + RightShift, + RightControl, + RightAlt, + RightSuper, + Menu, +} + +fn key_from_string(key_string: &str, location: u32) -> Option { + match key_string { + " " => Some(Key::Space), + "\"" => Some(Key::Apostrophe), + "'" => Some(Key::Apostrophe), + "<" => Some(Key::Comma), + "," => Some(Key::Comma), + "_" => Some(Key::Minus), + "-" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Minus), + ">" => Some(Key::Period), + "." if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Period), + "?" => Some(Key::Slash), + "/" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Slash), + "~" => Some(Key::GraveAccent), + "`" => Some(Key::GraveAccent), + ")" => Some(Key::Num0), + "0" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num0), + "!" => Some(Key::Num1), + "1" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num1), + "@" => Some(Key::Num2), + "2" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num2), + "#" => Some(Key::Num3), + "3" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num3), + "$" => Some(Key::Num4), + "4" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num4), + "%" => Some(Key::Num5), + "5" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num5), + "^" => Some(Key::Num6), + "6" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num6), + "&" => Some(Key::Num7), + "7" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num7), + "*" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num8), + "8" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num8), + "(" => Some(Key::Num9), + "9" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num9), + ":" => Some(Key::Semicolon), + ";" => Some(Key::Semicolon), + "+" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Equal), + "=" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Equal), + "A" => Some(Key::A), + "a" => Some(Key::A), + "B" => Some(Key::B), + "b" => Some(Key::B), + "C" => Some(Key::C), + "c" => Some(Key::C), + "D" => Some(Key::D), + "d" => Some(Key::D), + "E" => Some(Key::E), + "e" => Some(Key::E), + "F" => Some(Key::F), + "f" => Some(Key::F), + "G" => Some(Key::G), + "g" => Some(Key::G), + "H" => Some(Key::H), + "h" => Some(Key::H), + "I" => Some(Key::I), + "i" => Some(Key::I), + "J" => Some(Key::J), + "j" => Some(Key::J), + "K" => Some(Key::K), + "k" => Some(Key::K), + "L" => Some(Key::L), + "l" => Some(Key::L), + "M" => Some(Key::M), + "m" => Some(Key::M), + "N" => Some(Key::N), + "n" => Some(Key::N), + "O" => Some(Key::O), + "o" => Some(Key::O), + "P" => Some(Key::P), + "p" => Some(Key::P), + "Q" => Some(Key::Q), + "q" => Some(Key::Q), + "R" => Some(Key::R), + "r" => Some(Key::R), + "S" => Some(Key::S), + "s" => Some(Key::S), + "T" => Some(Key::T), + "t" => Some(Key::T), + "U" => Some(Key::U), + "u" => Some(Key::U), + "V" => Some(Key::V), + "v" => Some(Key::V), + "W" => Some(Key::W), + "w" => Some(Key::W), + "X" => Some(Key::X), + "x" => Some(Key::X), + "Y" => Some(Key::Y), + "y" => Some(Key::Y), + "Z" => Some(Key::Z), + "z" => Some(Key::Z), + "{" => Some(Key::LeftBracket), + "[" => Some(Key::LeftBracket), + "|" => Some(Key::Backslash), + "\\" => Some(Key::Backslash), + "}" => Some(Key::RightBracket), + "]" => Some(Key::RightBracket), + "Escape" => Some(Key::Escape), + "Enter" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD + => Some(Key::Enter), + "Tab" => Some(Key::Tab), + "Backspace" => Some(Key::Backspace), + "Insert" => Some(Key::Insert), + "Delete" => Some(Key::Delete), + "ArrowRight" => Some(Key::Right), + "ArrowLeft" => Some(Key::Left), + "ArrowDown" => Some(Key::Down), + "ArrowUp" => Some(Key::Up), + "PageUp" => Some(Key::PageUp), + "PageDown" => Some(Key::PageDown), + "Home" => Some(Key::Home), + "End" => Some(Key::End), + "CapsLock" => Some(Key::CapsLock), + "ScrollLock" => Some(Key::ScrollLock), + "NumLock" => Some(Key::NumLock), + "PrintScreen" => Some(Key::PrintScreen), + "Pause" => Some(Key::Pause), + "F1" => Some(Key::F1), + "F2" => Some(Key::F2), + "F3" => Some(Key::F3), + "F4" => Some(Key::F4), + "F5" => Some(Key::F5), + "F6" => Some(Key::F6), + "F7" => Some(Key::F7), + "F8" => Some(Key::F8), + "F9" => Some(Key::F9), + "F10" => Some(Key::F10), + "F11" => Some(Key::F11), + "F12" => Some(Key::F12), + "F13" => Some(Key::F13), + "F14" => Some(Key::F14), + "F15" => Some(Key::F15), + "F16" => Some(Key::F16), + "F17" => Some(Key::F17), + "F18" => Some(Key::F18), + "F19" => Some(Key::F19), + "F20" => Some(Key::F20), + "F21" => Some(Key::F21), + "F22" => Some(Key::F22), + "F23" => Some(Key::F23), + "F24" => Some(Key::F24), + "F25" => Some(Key::F25), + "0" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp0), + "1" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp1), + "2" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp2), + "3" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp3), + "4" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp4), + "5" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp5), + "6" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp6), + "7" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp7), + "8" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp8), + "9" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp9), + "." if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpDecimal), + "/" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpDivide), + "*" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpMultiply), + "-" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpSubtract), + "+" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpAdd), + "Enter" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD + => Some(Key::KpEnter), + "=" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpEqual), + "Shift" if location == KeyboardEventConstants::DOM_KEY_LOCATION_LEFT + => Some(Key::LeftShift), + "Control" if location == KeyboardEventConstants::DOM_KEY_LOCATION_LEFT + => Some(Key::LeftControl), + "Alt" if location == KeyboardEventConstants::DOM_KEY_LOCATION_LEFT => Some(Key::LeftAlt), + "Super" if location == KeyboardEventConstants::DOM_KEY_LOCATION_LEFT + => Some(Key::LeftSuper), + "Shift" if location == KeyboardEventConstants::DOM_KEY_LOCATION_RIGHT + => Some(Key::RightShift), + "Control" if location == KeyboardEventConstants::DOM_KEY_LOCATION_RIGHT + => Some(Key::RightControl), + "Alt" if location == KeyboardEventConstants::DOM_KEY_LOCATION_RIGHT => Some(Key::RightAlt), + "Super" if location == KeyboardEventConstants::DOM_KEY_LOCATION_RIGHT + => Some(Key::RightSuper), + "ContextMenu" => Some(Key::Menu), + _ => None + } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-29743.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-29743.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-29743.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-29743.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// compile-pass + +fn main() { + let mut i = [1, 2, 3]; + i[i[0]] = 0; + i[i[0] - 1] = 0; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-30355.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-30355.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-30355.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-30355.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -16,7 +16,16 @@ LL | &X(*Y) | ^^ cannot move out of here -error: aborting due to 3 previous errors +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/issue-30355.rs:15:8 + | +LL | &X(*Y) + | ^^ + | | + | cannot move out of data in a `&` reference + | cannot move + +error: aborting due to 4 previous errors -Some errors occurred: E0161, E0508. +Some errors occurred: E0161, E0507, E0508. For more information about an error, try `rustc --explain E0161`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-30438-a.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-30438-a.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-30438-a.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-30438-a.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,20 +1,12 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/issue-30438-a.rs:22:17 +error[E0515]: cannot return reference to temporary value + --> $DIR/issue-30438-a.rs:22:16 | LL | return &Test { s: &self.s}; - | ^^^^^^^^^^^^^^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the method body at 21:5... - --> $DIR/issue-30438-a.rs:21:5 - | -LL | / fn index(&self, _: usize) -> &Self::Output { -LL | | return &Test { s: &self.s}; -LL | | //~^ ERROR: borrowed value does not live long enough -LL | | } - | |_____^ + | ^------------------ + | || + | |temporary value created here + | returns a reference to data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-30438-b.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-30438-b.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-30438-b.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-30438-b.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +error[E0515]: cannot return reference to temporary value + --> $DIR/issue-30438-b.rs:23:9 + | +LL | &Test { s: &self.s} + | ^------------------ + | || + | |temporary value created here + | returns a reference to data owned by the current function + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-30438-c.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-30438-c.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-30438-c.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-30438-c.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,18 +1,9 @@ -error[E0597]: `x` does not live long enough +error[E0515]: cannot return reference to local variable `x` --> $DIR/issue-30438-c.rs:19:5 | LL | &x - | ^^ borrowed value does not live long enough -LL | //~^ ERROR: `x` does not live long enough -LL | } - | - `x` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'y as defined on the function body at 17:10... - --> $DIR/issue-30438-c.rs:17:10 - | -LL | fn silly<'y, 'z>(_s: &'y Test<'z>) -> &'y as Trait>::Out where 'z: 'static { - | ^^ + | ^^ returns a reference to data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-30560.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-30560.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-30560.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-30560.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,10 +11,10 @@ type Alias = (); use Alias::*; //~^ ERROR unresolved import `Alias` [E0432] -//~| Not a module `Alias` +//~| not a module `Alias` use std::io::Result::*; //~^ ERROR unresolved import `std::io::Result` [E0432] -//~| Not a module `Result` +//~| not a module `Result` trait T {} use T::*; //~ ERROR items in traits are not importable diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-30560.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-30560.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-30560.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-30560.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,13 +8,13 @@ --> $DIR/issue-30560.rs:12:5 | LL | use Alias::*; - | ^^^^^ Not a module `Alias` + | ^^^^^ not a module `Alias` error[E0432]: unresolved import `std::io::Result` --> $DIR/issue-30560.rs:15:14 | LL | use std::io::Result::*; - | ^^^^^^ Not a module `Result` + | ^^^^^^ not a module `Result` error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-31260.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-31260.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-31260.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-31260.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +pub struct Struct { + pub field: K, +} + +static STRUCT: Struct<&'static [u8]> = Struct { + field: {&[1]} +}; + +static STRUCT2: Struct<&'static [u8]> = Struct { + field: &[1] +}; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-3149.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-3149.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-3149.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-3149.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(non_snake_case)] +// pretty-expanded FIXME #23616 + +fn Matrix4(m11: T, m12: T, m13: T, m14: T, + m21: T, m22: T, m23: T, m24: T, + m31: T, m32: T, m33: T, m34: T, + m41: T, m42: T, m43: T, m44: T) + -> Matrix4 { + Matrix4 { + m11: m11, m12: m12, m13: m13, m14: m14, + m21: m21, m22: m22, m23: m23, m24: m24, + m31: m31, m32: m32, m33: m33, m34: m34, + m41: m41, m42: m42, m43: m43, m44: m44 + } +} + +struct Matrix4 { + m11: T, m12: T, m13: T, m14: T, + m21: T, m22: T, m23: T, m24: T, + m31: T, m32: T, m33: T, m34: T, + m41: T, m42: T, m43: T, m44: T, +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-31597.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-31597.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-31597.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-31597.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +trait Make { + type Out; + + fn make() -> Self::Out; +} + +impl Make for () { + type Out = (); + + fn make() -> Self::Out {} +} + +// Also make sure we don't hit an ICE when the projection can't be known +fn f() -> ::Out { loop {} } + +// ...and that it works with a blanket impl +trait Tr { + type Assoc; +} + +impl Tr for T { + type Assoc = (); +} + +fn g() -> ::Assoc { } + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-32324.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-32324.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-32324.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-32324.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] + +trait Resources { + type Buffer: Copy; +} + +#[derive(Copy, Clone)] +struct ConstantBufferSet( + pub R::Buffer +); + +#[derive(Copy, Clone)] +enum It {} +impl Resources for It { + type Buffer = u8; +} + +#[derive(Copy, Clone)] +enum Command { + BindConstantBuffers(ConstantBufferSet) +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-32354-suggest-import-rename.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-32354-suggest-import-rename.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-32354-suggest-import-rename.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-32354-suggest-import-rename.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ConstructorExtension` reimported here | = note: `ConstructorExtension` 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 +help: you can use `as` to change the binding name of the import | LL | use extension2::ConstructorExtension as OtherConstructorExtension; //~ ERROR is defined multiple times | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-33264.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-33264.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-33264.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-33264.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// only-x86_64 + +#![allow(dead_code, non_upper_case_globals)] +#![feature(asm)] + +#[repr(C)] +pub struct D32x4(f32,f32,f32,f32); + +impl D32x4 { + fn add(&self, vec: Self) -> Self { + unsafe { + let ret: Self; + asm!(" + movaps $1, %xmm1 + movaps $2, %xmm2 + addps %xmm1, %xmm2 + movaps $xmm1, $0 + " + : "=r"(ret) + : "1"(self), "2"(vec) + : "xmm1", "xmm2" + ); + ret + } + } +} + +fn main() { } + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-33287.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-33287.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-33287.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-33287.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(unused_variables)] +const A: [u32; 1] = [0]; + +fn test() { + let range = A[1]..; +} + +fn main() { } + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-33293.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-33293.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-33293.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-33293.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,6 +11,6 @@ fn main() { match 0 { aaa::bbb(_) => () - //~^ ERROR failed to resolve. Use of undeclared type or module `aaa` + //~^ ERROR failed to resolve: use of undeclared type or module `aaa` }; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-33293.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-33293.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-33293.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-33293.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ -error[E0433]: failed to resolve. Use of undeclared type or module `aaa` +error[E0433]: failed to resolve: use of undeclared type or module `aaa` --> $DIR/issue-33293.rs:13:9 | LL | aaa::bbb(_) => () - | ^^^ Use of undeclared type or module `aaa` + | ^^^ use of undeclared type or module `aaa` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-33464.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-33464.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-33464.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-33464.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,19 +2,19 @@ --> $DIR/issue-33464.rs:13:5 | LL | use abc::one_el; - | ^^^ Maybe a missing `extern crate abc;`? + | ^^^ maybe a missing `extern crate abc;`? error[E0432]: unresolved import `abc` --> $DIR/issue-33464.rs:15:5 | LL | use abc::{a, bbb, cccccc}; - | ^^^ Maybe a missing `extern crate abc;`? + | ^^^ maybe a missing `extern crate abc;`? error[E0432]: unresolved import `a_very_long_name` --> $DIR/issue-33464.rs:17:5 | LL | use a_very_long_name::{el, el2}; - | ^^^^^^^^^^^^^^^^ Maybe a missing `extern crate a_very_long_name;`? + | ^^^^^^^^^^^^^^^^ maybe a missing `extern crate a_very_long_name;`? error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-33903.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-33903.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-33903.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-33903.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// Issue 33903: +// Built-in indexing should be used even when the index is not +// trivially an integer +// Only built-in indexing can be used in constant expressions + +const FOO: i32 = [12, 34][0 + 1]; + +fn main() {} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-34047.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-34047.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-34047.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-34047.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/issue-34047.rs:15:13 | LL | const C: u8 = 0; - | ---------------- a constant `C` is defined here + | ---------------- the constant `C` is defined here ... LL | mut C => {} //~ ERROR match bindings cannot shadow constants | ^ cannot be named the same as a constant diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-34194.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-34194.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-34194.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-34194.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] + +struct A { + a: &'static (), +} + +static B: &'static A = &A { a: &() }; +static C: &'static A = &B; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-34209.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-34209.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-34209.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-34209.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,9 +2,7 @@ --> $DIR/issue-34209.rs:17:9 | LL | S::B{ } => { }, - | ^^^^ ambiguous associated type - | - = note: specify the type using the syntax `::B` + | ^^^^ help: use fully-qualified syntax: `::B` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-34229.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-34229.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-34229.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-34229.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,4 @@ +#[derive(PartialEq)] struct Comparable; +#[derive(PartialEq, PartialOrd)] struct Nope(Comparable); + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-34229.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-34229.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-34229.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-34229.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +error[E0277]: can't compare `Comparable` with `Comparable` + --> $DIR/issue-34229.rs:2:46 + | +LL | #[derive(PartialEq, PartialOrd)] struct Nope(Comparable); + | ^^^^^^^^^^ no implementation for `Comparable < Comparable` and `Comparable > Comparable` + | + = help: the trait `std::cmp::PartialOrd` is not implemented for `Comparable` + = note: required by `std::cmp::PartialOrd::partial_cmp` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-3424.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-3424.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-3424.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-3424.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] +// rustc --test ignores2.rs && ./ignores2 + +pub struct Path; + +type rsrc_loader = Box Result>; + +fn tester() +{ + let mut loader: rsrc_loader = Box::new(move |_path| { + Ok("more blah".to_string()) + }); + + let path = Path; + assert!(loader(&path).is_ok()); +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-34751.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-34751.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-34751.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-34751.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// #34751 ICE: 'rustc' panicked at 'assertion failed: !substs.has_regions_escaping_depth(0)' + +#[allow(dead_code)] + +use std::marker::PhantomData; + +fn f<'a>(PhantomData::<&'a u8>: PhantomData<&'a u8>) {} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-34780.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-34780.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-34780.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-34780.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(stable_features)] +#![feature(associated_consts)] + +use std::marker::PhantomData; + +trait Tr<'a> { + const C: PhantomData<&'a u8> = PhantomData::<&'a u8>; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-35376.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-35376.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-35376.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-35376.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,52 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![feature(specialization)] + +fn main() {} + +pub trait Alpha { } + +pub trait Beta { + type Event; +} + +pub trait Delta { + type Handle; + fn process(&self); +} + +pub struct Parent(A, T); + +impl Delta for Parent +where A: Alpha, + T: Delta, + T::Handle: Beta::Event> { + type Handle = Handle; + default fn process(&self) { + unimplemented!() + } +} + +impl Delta for Parent +where A: Alpha + Alpha, + T: Delta, + T::Handle: Beta::Event> { + fn process(&self) { + unimplemented!() + } +} + +pub struct Handle; + +impl Beta for Handle { + type Event = (); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-35546.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-35546.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-35546.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-35546.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// Regression test for #35546. Check that we are able to codegen +// this. Before we had problems because of the drop glue signature +// around dropping a trait object (specifically, when dropping the +// `value` field of `Node`). + +struct Node { + next: Option>>, + value: T, +} + +fn clear(head: &mut Option>>) { + match head.take() { + Some(node) => *head = node.next, + None => (), + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-3563-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-3563-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-3563-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-3563-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// pretty-expanded FIXME #23616 + +trait Canvas { + fn add_point(&self, point: &isize); + fn add_points(&self, shapes: &[isize]) { + for pt in shapes { + self.add_point(pt) + } + } + +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-36075.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-36075.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-36075.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-36075.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +trait DeclarationParser { + type Declaration; +} + +struct DeclarationListParser<'i, I, P> + where P: DeclarationParser +{ + input: &'i (), + parser: P +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-36082.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-36082.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-36082.ast.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-36082.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,10 +1,10 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/issue-36082.rs:23:19 | LL | let val: &_ = x.borrow().0; - | ^^^^^^^^^^ - temporary value only lives until here + | ^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | temporary value does not live long enough + | creates a temporary which is freed while still in use ... LL | println!("{}", val); | --- borrow later used here @@ -13,4 +13,4 @@ error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-36082.mir.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-36082.mir.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-36082.mir.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-36082.mir.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,10 +1,10 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/issue-36082.rs:23:19 | LL | let val: &_ = x.borrow().0; - | ^^^^^^^^^^ - temporary value only lives until here + | ^^^^^^^^^^ - temporary value is freed at the end of this statement | | - | temporary value does not live long enough + | creates a temporary which is freed while still in use ... LL | println!("{}", val); | --- borrow later used here @@ -13,4 +13,4 @@ error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-36082.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-36082.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-36082.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-36082.rs 2018-12-04 23:41:40.000000000 +0000 @@ -25,9 +25,9 @@ //[ast]~| NOTE temporary value dropped here while still borrowed //[ast]~| NOTE temporary value does not live long enough //[ast]~| NOTE consider using a `let` binding to increase its lifetime - //[mir]~^^^^^ ERROR borrowed value does not live long enough [E0597] - //[mir]~| NOTE temporary value does not live long enough - //[mir]~| NOTE temporary value only lives until here + //[mir]~^^^^^ ERROR temporary value dropped while borrowed [E0716] + //[mir]~| NOTE temporary value is freed at the end of this statement + //[mir]~| NOTE creates a temporary which is freed while still in use //[mir]~| NOTE consider using a `let` binding to create a longer lived value println!("{}", val); //[mir]~^ borrow later used here diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-3609.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-3609.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-3609.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-3609.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(unused_must_use)] +#![allow(dead_code)] +#![allow(unused_mut)] +use std::thread; +use std::sync::mpsc::Sender; + +type RingBuffer = Vec ; +type SamplesFn = Box; + +enum Msg +{ + GetSamples(String, SamplesFn), // sample set name, callback which receives samples +} + +fn foo(name: String, samples_chan: Sender) { + thread::spawn(move|| { + let mut samples_chan = samples_chan; + + let callback: SamplesFn = Box::new(move |buffer| { + for i in 0..buffer.len() { + println!("{}: {}", i, buffer[i]) + } + }); + + samples_chan.send(Msg::GetSamples(name.clone(), callback)); + }).join(); +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-36744-without-calls.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-36744-without-calls.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-36744-without-calls.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-36744-without-calls.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// Tests for an LLVM abort when storing a lifetime-parametric fn into +// context that is expecting one that is not lifetime-parametric +// (i.e. has no `for <'_>`). + +pub struct A<'a>(&'a ()); +pub struct S(T); + +pub fn bad<'s>(v: &mut S)>, y: S fn(A<'b>)>) { + *v = y; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-36881.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-36881.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-36881.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-36881.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/issue-36881.rs:16:9 | LL | use issue_36881_aux::Foo; //~ ERROR unresolved import - | ^^^^^^^^^^^^^^^ Maybe a missing `extern crate issue_36881_aux;`? + | ^^^^^^^^^^^^^^^ maybe a missing `extern crate issue_36881_aux;`? error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-37323.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-37323.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-37323.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-37323.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-pass + #![feature(rustc_attrs)] #![allow(warnings)] @@ -17,7 +19,6 @@ struct NestedA<'a, 'b> { x: &'a NestedB<'b> - //~^ ERROR E0491 } struct NestedB<'a> { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-37323.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-37323.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-37323.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-37323.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a NestedB<'b>`, reference has a longer lifetime than the data it references - --> $DIR/issue-37323.rs:19:5 - | -LL | x: &'a NestedB<'b> - | ^^^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the struct at 18:16 - --> $DIR/issue-37323.rs:18:16 - | -LL | struct NestedA<'a, 'b> { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 18:20 - --> $DIR/issue-37323.rs:18:20 - | -LL | struct NestedA<'a, 'b> { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-37598.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-37598.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-37598.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-37598.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![feature(slice_patterns)] + +fn check(list: &[u8]) { + match list { + &[] => {}, + &[_u1, _u2, ref _next..] => {}, + &[_u1] => {}, + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-37655.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-37655.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-37655.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-37655.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// Regression test for #37655. The problem was a false edge created by +// coercion that wound up requiring that `'a` (in `split()`) outlive +// `'b`, which shouldn't be necessary. + +#![allow(warnings)] + +trait SliceExt { + type Item; + + fn get_me(&self, index: I) -> &I::Output + where I: SliceIndex; +} + +impl SliceExt for [T] { + type Item = T; + + fn get_me(&self, index: I) -> &I::Output + where I: SliceIndex + { + panic!() + } +} + +pub trait SliceIndex { + type Output: ?Sized; +} + +impl SliceIndex for usize { + type Output = T; +} + +fn foo<'a, 'b>(split: &'b [&'a [u8]]) -> &'a [u8] { + split.get_me(0) +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-37725.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-37725.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-37725.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-37725.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +trait Foo { + fn foo(&self); +} + +fn foo<'a>(s: &'a mut ()) where &'a mut (): Foo { + s.foo(); +} +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-37733.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-37733.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-37733.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-37733.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +type A = for<> fn(); + +type B = for<'a,> fn(); + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-37887.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-37887.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-37887.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-37887.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/issue-37887.rs:13:9 | LL | use libc::*; //~ ERROR unresolved import - | ^^^^ Maybe a missing `extern crate libc;`? + | ^^^^ maybe a missing `extern crate libc;`? error[E0658]: use of unstable library feature 'libc': use `libc` from crates.io (see issue #27783) --> $DIR/issue-37887.rs:12:5 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-38727.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-38727.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-38727.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-38727.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#[repr(u64)] +enum A { + A = 0u64, + B = !0u64, +} + +fn cmp() -> A { + A::B +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-3874.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-3874.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-3874.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-3874.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +enum PureCounter { PureCounterVariant(usize) } + +fn each(thing: PureCounter, blk: F) where F: FnOnce(&usize) { + let PureCounter::PureCounterVariant(ref x) = thing; + blk(x); +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-38857.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-38857.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-38857.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-38857.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,6 +10,6 @@ fn main() { let a = std::sys::imp::process::process_common::StdioPipes { ..panic!() }; - //~^ ERROR failed to resolve. Could not find `imp` in `sys` [E0433] + //~^ ERROR failed to resolve: could not find `imp` in `sys` [E0433] //~^^ ERROR module `sys` is private [E0603] } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-38857.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-38857.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-38857.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-38857.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,14 +1,14 @@ -error[E0433]: failed to resolve. Could not find `imp` in `sys` +error[E0433]: failed to resolve: could not find `imp` in `sys` --> $DIR/issue-38857.rs:12:23 | LL | let a = std::sys::imp::process::process_common::StdioPipes { ..panic!() }; - | ^^^ Could not find `imp` in `sys` + | ^^^ could not find `imp` in `sys` error[E0603]: module `sys` is private - --> $DIR/issue-38857.rs:12:13 + --> $DIR/issue-38857.rs:12:18 | LL | let a = std::sys::imp::process::process_common::StdioPipes { ..panic!() }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-3888-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-3888-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-3888-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-3888-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +fn vec_peek<'r, T>(v: &'r [T]) -> &'r [T] { + &v[1..5] +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-38940.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-38940.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-38940.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-38940.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,46 @@ +// issue-38940: error printed twice for deref recursion limit exceeded +// Test that the recursion limit can be changed. In this case, we have +// deeply nested types that will fail the `Send` check by overflow +// when the recursion limit is set very low. +#![allow(dead_code)] +#![recursion_limit="10"] +macro_rules! link { + ($outer:ident, $inner:ident) => { + struct $outer($inner); + impl $outer { + fn new() -> $outer { + $outer($inner::new()) + } + } + impl std::ops::Deref for $outer { + type Target = $inner; + fn deref(&self) -> &$inner { + &self.0 + } + } + } +} +struct Bottom; +impl Bottom { + fn new() -> Bottom { + Bottom + } +} +link!(Top, A); +link!(A, B); +link!(B, C); +link!(C, D); +link!(D, E); +link!(E, F); +link!(F, G); +link!(G, H); +link!(H, I); +link!(I, J); +link!(J, K); +link!(K, Bottom); +fn main() { + let t = Top::new(); + let x: &Bottom = &t; + //~^ ERROR mismatched types + //~| ERROR reached the recursion limit while auto-dereferencing I +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-38940.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-38940.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-38940.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-38940.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +error[E0055]: reached the recursion limit while auto-dereferencing I + --> $DIR/issue-38940.rs:43:22 + | +LL | let x: &Bottom = &t; + | ^^ deref recursion limit reached + | + = help: consider adding a `#![recursion_limit="20"]` attribute to your crate + +error[E0308]: mismatched types + --> $DIR/issue-38940.rs:43:22 + | +LL | let x: &Bottom = &t; + | ^^ expected struct `Bottom`, found struct `Top` + | + = note: expected type `&Bottom` + found type `&Top` + +error: aborting due to 2 previous errors + +Some errors occurred: E0055, E0308. +For more information about an error, try `rustc --explain E0055`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-39089.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-39089.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-39089.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-39089.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +fn f Sized>() {} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-39175.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-39175.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-39175.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-39175.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This test ignores some platforms as the particular extension trait used +// to demonstrate the issue is only available on unix. This is fine as +// the fix to suggested paths is not platform-dependent and will apply on +// these platforms also. + +// ignore-windows +// ignore-cloudabi +// ignore-emscripten + +use std::process::Command; +// use std::os::unix::process::CommandExt; + +fn main() { + Command::new("echo").arg("hello").exec(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-39175.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-39175.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-39175.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-39175.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +error[E0599]: no method named `exec` found for type `&mut std::process::Command` in the current scope + --> $DIR/issue-39175.rs:24:39 + | +LL | Command::new("echo").arg("hello").exec(); + | ^^^^ + | + = help: items from traits can only be used if the trait is in scope +help: the following trait is implemented but not in scope, perhaps add a `use` for it: + | +LL | use std::os::unix::process::CommandExt; + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-39467.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-39467.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-39467.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-39467.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +macro_rules! expr { () => { () } } + +enum A {} + +impl A { + const A: () = expr!(); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-39559-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-39559-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-39559-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-39559-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -23,8 +23,6 @@ fn main() { let array: [usize; Dim3::dim()] //~^ ERROR E0015 - //~| ERROR E0080 = [0; Dim3::dim()]; //~^ ERROR E0015 - //~| ERROR E0080 } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-39559-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-39559-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-39559-2.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-39559-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -5,26 +5,11 @@ | ^^^^^^^^^^^ error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants - --> $DIR/issue-39559-2.rs:27:15 + --> $DIR/issue-39559-2.rs:26:15 | LL | = [0; Dim3::dim()]; | ^^^^^^^^^^^ -error[E0080]: could not evaluate repeat length - --> $DIR/issue-39559-2.rs:27:15 - | -LL | = [0; Dim3::dim()]; - | ^^^^^^^^^^^ calling non-const fn `::dim` - -error[E0080]: could not evaluate constant expression - --> $DIR/issue-39559-2.rs:24:16 - | -LL | let array: [usize; Dim3::dim()] - | ^^^^^^^^-----------^ - | | - | calling non-const fn `::dim` - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors -Some errors occurred: E0015, E0080. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-3979-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-3979-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-3979-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-3979-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// pretty-expanded FIXME #23616 + +trait A { + fn a_method(&self); +} + +trait B: A { + fn b_method(&self); +} + +trait C: B { + fn c_method(&self) { + self.a_method(); + } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-3991.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-3991.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-3991.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-3991.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] + +// pretty-expanded FIXME #23616 + +struct HasNested { + nest: Vec > , +} + +impl HasNested { + fn method_push_local(&mut self) { + self.nest[0].push(0); + } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-3993.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-3993.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-3993.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-3993.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ error[E0603]: function `fly` is private - --> $DIR/issue-3993.rs:11:5 + --> $DIR/issue-3993.rs:11:10 | LL | use zoo::fly; //~ ERROR: function `fly` is private - | ^^^^^^^^ + | ^^^ error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-39984.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-39984.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-39984.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-39984.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(unreachable_code)] +// Regression test for issue #39984. +// +// The key here is that the error type of the `Ok` call ought to be +// constrained to `String`, even though it is dead-code. + +fn main() {} + +fn t() -> Result<(), String> { + return Err("".into()); + Ok(()) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-40136.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-40136.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-40136.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-40136.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] + +macro_rules! m { () => { 0 } } + +trait T { + const C: i32 = m!(); +} + +struct S; +impl S { + const C: i32 = m!(); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-4025.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-4025.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-4025.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-4025.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(unused_mut)] +/* +# if b { x } else { y } requires identical types for x and y +*/ + +fn print1(b: bool, s1: &str, s2: &str) { + println!("{}", if b { s1 } else { s2 }); +} +fn print2<'a, 'b>(b: bool, s1: &'a str, s2: &'b str) { + println!("{}", if b { s1 } else { s2 }); +} +fn print3(b: bool, s1: &str, s2: &str) { + let mut s: &str; + if b { s = s1; } else { s = s2; } + println!("{}", s); +} +fn print4<'a, 'b>(b: bool, s1: &'a str, s2: &'b str) { + let mut s: &str; + if b { s = s1; } else { s = s2; } + println!("{}", s); +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-40288-2.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-40288-2.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-40288-2.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-40288-2.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -error[E0621]: explicit lifetime required in the type of `y` - --> $DIR/issue-40288-2.rs:17:9 - | -LL | fn lifetime_transmute_slice<'a, T: ?Sized>(x: &'a T, y: &T) -> &'a T { - | -- help: add explicit lifetime `'a` to the type of `y`: `&'a T` -... -LL | slice[0] = y; - | ^^^^^^^^^^^^ lifetime `'a` required - -error[E0621]: explicit lifetime required in the type of `y` - --> $DIR/issue-40288-2.rs:32:9 - | -LL | fn lifetime_transmute_struct<'a, T: ?Sized>(x: &'a T, y: &T) -> &'a T { - | -- help: add explicit lifetime `'a` to the type of `y`: `&'a T` -... -LL | dst.head = y; - | ^^^^^^^^^^^^ lifetime `'a` required - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0621`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-40402-ref-hints/issue-40402-1.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,6 +7,15 @@ | cannot move out of borrowed content | help: consider borrowing here: `&f.v[0]` -error: aborting due to previous error +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/issue-40402-1.rs:19:13 + | +LL | let e = f.v[0]; //~ ERROR cannot move out of indexed content + | ^^^^^^ + | | + | cannot move out of data in a `&` reference + | cannot move + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-40402-ref-hints/issue-40402-2.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,3 +1,21 @@ +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/issue-40402-2.rs:15:10 + | +LL | let (a, b) = x[0]; //~ ERROR cannot move out of indexed content + | ^ + | | + | cannot move out of data in a `&` reference + | cannot move + +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/issue-40402-2.rs:15:13 + | +LL | let (a, b) = x[0]; //~ ERROR cannot move out of indexed content + | ^ + | | + | cannot move out of data in a `&` reference + | cannot move + error[E0507]: cannot move out of borrowed content --> $DIR/issue-40402-2.rs:15:18 | @@ -15,6 +33,6 @@ LL | let (a, b) = x[0]; //~ ERROR cannot move out of indexed content | ^ ^ -error: aborting due to previous error +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-40510-1.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-40510-1.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-40510-1.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-40510-1.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,15 +1,22 @@ -error: unsatisfied lifetime constraints +warning: captured variable cannot escape `FnMut` closure body --> $DIR/issue-40510-1.rs:18:9 | LL | || { - | -- - | || - | |return type of closure is &'2 mut std::boxed::Box<()> - | lifetime `'1` represents this closure's body + | - inferred to be a `FnMut` closure LL | &mut x - | ^^^^^^ returning this value requires that `'1` must outlive `'2` + | ^^^^^^ returns a reference to a captured variable which escapes the closure body | - = note: closure implements `FnMut`, so references to captured variables can't escape the closure + = note: `FnMut` closures only have access to their captured variables while they are executing... + = note: ...therefore, they cannot allow references to captured variables to escape + = warning: This error has been downgraded to a warning for backwards compatibility with previous releases. + It represents potential unsoundness in your code. + This warning will become a hard error in the future. + +error: compilation successful + --> $DIR/issue-40510-1.rs:23:1 + | +LL | fn main() {} //~ ERROR compilation successful + | ^^^^^^^^^^^^ error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-40510-3.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-40510-3.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-40510-3.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-40510-3.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,17 +1,24 @@ -error: unsatisfied lifetime constraints +warning: captured variable cannot escape `FnMut` closure body --> $DIR/issue-40510-3.rs:18:9 | LL | || { - | -- - | || - | |return type of closure is [closure@$DIR/issue-40510-3.rs:18:9: 20:10 x:&'2 mut std::vec::Vec<()>] - | lifetime `'1` represents this closure's body + | - inferred to be a `FnMut` closure LL | / || { LL | | x.push(()) LL | | } - | |_________^ returning this value requires that `'1` must outlive `'2` + | |_________^ returns a closure that contains a reference to a captured variable, which then escapes the closure body | - = note: closure implements `FnMut`, so references to captured variables can't escape the closure + = note: `FnMut` closures only have access to their captured variables while they are executing... + = note: ...therefore, they cannot allow references to captured variables to escape + = warning: This error has been downgraded to a warning for backwards compatibility with previous releases. + It represents potential unsoundness in your code. + This warning will become a hard error in the future. + +error: compilation successful + --> $DIR/issue-40510-3.rs:25:1 + | +LL | fn main() {} //~ ERROR compilation successful + | ^^^^^^^^^^^^ error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-40962.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-40962.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-40962.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-40962.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +macro_rules! m { + ($i:meta) => { + #[derive($i)] + struct S; + } +} + +m!(Clone); + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-41272.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-41272.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-41272.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-41272.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +struct Foo; + +impl Foo { + fn bar(&mut self) -> bool { true } +} + +fn error(foo: &mut Foo) { + if let Some(_) = Some(true) { + } else if foo.bar() {} +} + +fn ok(foo: &mut Foo) { + if let Some(_) = Some(true) { + } else { + if foo.bar() {} + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-41298.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-41298.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-41298.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-41298.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +struct Function { t: T, f: F } + +impl Function R> { fn foo() { } } +impl Function R> { fn bar() { } } + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-41628.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-41628.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-41628.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-41628.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![deny(dead_code)] + +#[used] +static FOO: u32 = 0; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-41936-variance-coerce-unsized-cycle.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-41936-variance-coerce-unsized-cycle.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-41936-variance-coerce-unsized-cycle.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-41936-variance-coerce-unsized-cycle.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// Regression test for #41936. The coerce-unsized trait check in +// coherence was using subtyping, which triggered variance +// computation, which failed because it required type info for fields +// that had not (yet) been computed. + +#![feature(unsize)] +#![feature(coerce_unsized)] + +use std::{marker,ops}; + +// Change the array to a non-array, and error disappears +// Adding a new field to the end keeps the error +struct LogDataBuf([u8;8]); + +struct Aref +{ + // Inner structure triggers the error, removing the inner removes the message. + ptr: Box>, +} +impl, U: ?Sized> ops::CoerceUnsized> for Aref {} + +struct ArefInner +{ + // Even with this field commented out, the error is raised. + data: T, +} + +fn main(){} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-42106.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-42106.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-42106.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-42106.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -6,7 +6,7 @@ LL | collection.swap(1, 2); //~ ERROR also borrowed as immutable | ^^^^^^^^^^ mutable borrow occurs here LL | _a.use_ref(); - | -- borrow later used here + | -- immutable borrow later used here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-42467.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-42467.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-42467.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-42467.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +struct Foo(T); + +struct IntoIter(T); + +impl<'a, T: 'a> Iterator for IntoIter { + type Item = (); + + fn next(&mut self) -> Option<()> { + None + } +} + +impl IntoIterator for Foo { + type Item = (); + type IntoIter = IntoIter; + + fn into_iter(self) -> IntoIter { + IntoIter(self.0) + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-42755.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-42755.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-42755.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-42755.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![cfg_attr(stage0, feature(macro_vis_matcher))] macro_rules! foo { ($($p:vis)*) => {} //~ ERROR repetition matches empty token tree diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-42755.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-42755.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-42755.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-42755.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error: repetition matches empty token tree - --> $DIR/issue-42755.rs:14:7 + --> $DIR/issue-42755.rs:13:7 | LL | ($($p:vis)*) => {} //~ ERROR repetition matches empty token tree | ^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-42956.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-42956.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-42956.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-42956.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(stable_features)] +#![feature(associated_consts)] + +impl A for i32 { + type Foo = u32; +} +impl B for u32 { + const BAR: i32 = 0; +} + +trait A { + type Foo: B; +} + +trait B { + const BAR: i32; +} + +fn generic() { + // This panics if the universal function call syntax is used as well + println!("{}", T::Foo::BAR); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-43057.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-43057.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-43057.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-43057.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(unused)] + +macro_rules! column { + ($i:ident) => { + $i + }; +} + +fn foo() -> ! { + panic!(); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-43105.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-43105.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-43105.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-43105.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,7 +16,6 @@ fn main() { match 1 { NUM => unimplemented!(), - //~^ ERROR could not evaluate constant pattern _ => unimplemented!(), } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-43105.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-43105.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-43105.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-43105.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -4,16 +4,6 @@ LL | const NUM: u8 = xyz(); | ^^^^^ -error[E0080]: could not evaluate constant pattern - --> $DIR/issue-43105.rs:18:9 - | -LL | const NUM: u8 = xyz(); - | ----- calling non-const fn `xyz` -... -LL | NUM => unimplemented!(), - | ^^^ - -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors occurred: E0015, E0080. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-43357.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-43357.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-43357.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-43357.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +trait Trait { + type Output; +} + +fn f() { + std::mem::size_of::(); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-4335.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-4335.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-4335.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-4335.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -6,24 +6,34 @@ LL | id(Box::new(|| *v)) | ^^ cannot move out of captured variable in an `FnMut` closure -error[E0597]: `v` does not live long enough - --> $DIR/issue-4335.rs:16:21 +error[E0507]: cannot move out of `*v` which is behind a `&` reference + --> $DIR/issue-4335.rs:16:20 | LL | id(Box::new(|| *v)) - | -- ^ borrowed value does not live long enough + | ^^ + | | + | cannot move out of `*v` which is behind a `&` reference + | cannot move + +error[E0373]: closure may outlive the current function, but it borrows `v`, which is owned by the current function + --> $DIR/issue-4335.rs:16:17 + | +LL | id(Box::new(|| *v)) + | ^^ - `v` is borrowed here | | - | value captured here -... -LL | } - | - `v` dropped here while still borrowed + | may outlive borrowed value `v` | -note: borrowed value must be valid for the lifetime 'r as defined on the function body at 15:6... - --> $DIR/issue-4335.rs:15:6 +note: closure is returned here + --> $DIR/issue-4335.rs:16:5 + | +LL | id(Box::new(|| *v)) + | ^^^^^^^^^^^^^^^^^^^ +help: to force the closure to take ownership of `v` (and any other referenced variables), use the `move` keyword | -LL | fn f<'r, T>(v: &'r T) -> Box T + 'r> { - | ^^ +LL | id(Box::new(move || *v)) + | ^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors -Some errors occurred: E0507, E0597. -For more information about an error, try `rustc --explain E0507`. +Some errors occurred: E0373, E0507. +For more information about an error, try `rustc --explain E0373`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-43483.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-43483.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-43483.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-43483.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(unused_variables)] +trait VecN { + const DIM: usize; +} + +trait Mat { + type Row: VecN; +} + +fn m() { + let x = M::Row::DIM; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-44005.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-44005.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-44005.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-44005.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +pub trait Foo<'a> { + type Bar; + fn foo(&'a self) -> Self::Bar; +} + +impl<'a, 'b, T: 'a> Foo<'a> for &'b T { + type Bar = &'a T; + fn foo(&'a self) -> &'a T { + self + } +} + +pub fn uncallable(x: T, f: F) + where T: for<'a> Foo<'a>, + F: for<'a> Fn(>::Bar) +{ + f(x.foo()); +} + +pub fn catalyst(x: &i32) { + broken(x, |_| {}) +} + +pub fn broken(x: &i32, f: F) { + uncallable(x, |y| f(y)); +} + +fn main() { } + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-44056.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-44056.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-44056.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-44056.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// only-x86_64 +// no-prefer-dynamic +// compile-flags: -Ctarget-feature=+avx -Clto + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-44247.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-44247.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-44247.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-44247.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +trait T { + type X; + const X: Self::X; +} +fn foo() { + let _: X::X = X::X; +} + +trait S { + const X: Self::X; + type X; +} +fn bar() { + let _: X::X = X::X; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-44373-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-44373-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-44373-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-44373-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// compile-flags: -Z borrowck=compare + +struct Foo(bool); + +struct Container(&'static [&'static Foo]); + +static FOO: Foo = Foo(true); +static CONTAINER: Container = Container(&[&FOO]); + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-44373.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-44373.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-44373.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-44373.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +error[E0716]: temporary value dropped while borrowed + --> $DIR/issue-44373.rs:15:42 + | +LL | let _val: &'static [&'static u32] = &[&FOO]; //~ ERROR borrowed value does not live long enough + | ----------------------- ^^^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | } + | - temporary value is freed at the end of this statement + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-44402.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-44402.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-44402.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-44402.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![feature(never_type)] +#![feature(exhaustive_patterns)] + +// Regression test for inhabitedness check. The old +// cache used to cause us to incorrectly decide +// that `test_b` was invalid. + +struct Foo { + field1: !, + field2: Option<&'static Bar>, +} + +struct Bar { + field1: &'static Foo +} + +fn test_a() { + let x: Option = None; + match x { None => () } +} + +fn test_b() { + let x: Option = None; + match x { None => () } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-4464.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-4464.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-4464.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-4464.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +fn broken(v: &[u8], i: usize, j: usize) -> &[u8] { &v[i..j] } + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-44730.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-44730.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-44730.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-44730.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +//! dox + +#![deny(missing_docs)] + +macro_rules! doc { + ($e:expr) => ( + #[doc = $e] + pub struct Foo; + ) +} + +doc!("a"); + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-44851.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-44851.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-44851.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-44851.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +macro_rules! a { + () => { "a" } +} + +macro_rules! b { + ($doc:expr) => { + #[doc = $doc] + pub struct B; + } +} + +b!(a!()); + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45157.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45157.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45157.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45157.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | ^^^^^^ immutable borrow occurs here LL | //~^ ERROR cannot borrow `u.z.c` as immutable because it is also borrowed as mutable [E0502] LL | println!("{} {}", mref, nref) - | ---- borrow later used here + | ---- mutable borrow later used here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45425.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45425.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45425.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45425.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +use std::ops::Add; + +fn ref_add(a: &T, b: &T) -> T +where + for<'x> &'x T: Add<&'x T, Output = T>, +{ + a + b +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.migrate.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,53 +1,44 @@ -warning[E0597]: `*s.0` does not live long enough +warning[E0713]: borrow may still be in use when destructor runs --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:63:5 | -LL | &mut *s.0 //[nll]~ ERROR `*s.0` does not live long enough [E0597] - | ^^^^^^^^^ borrowed value does not live long enough +LL | fn scribbled<'a>(s: Scribble<'a>) -> &'a mut u32 { + | -- lifetime `'a` defined here +LL | &mut *s.0 //[nll]~ ERROR borrow may still be in use when destructor runs [E0713] + | ^^^^^^^^^ returning this value requires that `*s.0` is borrowed for `'a` ... LL | } - | - `*s.0` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 62:14... - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:62:14 + | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait | -LL | fn scribbled<'a>(s: Scribble<'a>) -> &'a mut u32 { - | ^^ = warning: This error has been downgraded to a warning for backwards compatibility with previous releases. It represents potential unsoundness in your code. This warning will become a hard error in the future. -warning[E0597]: `*s.0` does not live long enough +warning[E0713]: borrow may still be in use when destructor runs --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:73:5 | -LL | &mut *(*s).0 //[nll]~ ERROR `*s.0` does not live long enough [E0597] - | ^^^^^^^^^^^^ borrowed value does not live long enough +LL | fn boxed_scribbled<'a>(s: Box>) -> &'a mut u32 { + | -- lifetime `'a` defined here +LL | &mut *(*s).0 //[nll]~ ERROR borrow may still be in use when destructor runs [E0713] + | ^^^^^^^^^^^^ returning this value requires that `*s.0` is borrowed for `'a` ... LL | } - | - `*s.0` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 72:20... - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:72:20 + | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait | -LL | fn boxed_scribbled<'a>(s: Box>) -> &'a mut u32 { - | ^^ = warning: This error has been downgraded to a warning for backwards compatibility with previous releases. It represents potential unsoundness in your code. This warning will become a hard error in the future. -warning[E0597]: `*s.0` does not live long enough +warning[E0713]: borrow may still be in use when destructor runs --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:83:5 | -LL | &mut *(**s).0 //[nll]~ ERROR `*s.0` does not live long enough [E0597] - | ^^^^^^^^^^^^^ borrowed value does not live long enough +LL | fn boxed_boxed_scribbled<'a>(s: Box>>) -> &'a mut u32 { + | -- lifetime `'a` defined here +LL | &mut *(**s).0 //[nll]~ ERROR borrow may still be in use when destructor runs [E0713] + | ^^^^^^^^^^^^^ returning this value requires that `*s.0` is borrowed for `'a` ... LL | } - | - `*s.0` dropped here while still borrowed + | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 82:26... - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:82:26 - | -LL | fn boxed_boxed_scribbled<'a>(s: Box>>) -> &'a mut u32 { - | ^^ = warning: This error has been downgraded to a warning for backwards compatibility with previous releases. It represents potential unsoundness in your code. This warning will become a hard error in the future. @@ -66,4 +57,4 @@ error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0713`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,48 +1,36 @@ -error[E0597]: `*s.0` does not live long enough +error[E0713]: borrow may still be in use when destructor runs --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:63:5 | -LL | &mut *s.0 //[nll]~ ERROR `*s.0` does not live long enough [E0597] - | ^^^^^^^^^ borrowed value does not live long enough +LL | fn scribbled<'a>(s: Scribble<'a>) -> &'a mut u32 { + | -- lifetime `'a` defined here +LL | &mut *s.0 //[nll]~ ERROR borrow may still be in use when destructor runs [E0713] + | ^^^^^^^^^ returning this value requires that `*s.0` is borrowed for `'a` ... LL | } - | - `*s.0` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 62:14... - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:62:14 - | -LL | fn scribbled<'a>(s: Scribble<'a>) -> &'a mut u32 { - | ^^ + | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait -error[E0597]: `*s.0` does not live long enough +error[E0713]: borrow may still be in use when destructor runs --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:73:5 | -LL | &mut *(*s).0 //[nll]~ ERROR `*s.0` does not live long enough [E0597] - | ^^^^^^^^^^^^ borrowed value does not live long enough +LL | fn boxed_scribbled<'a>(s: Box>) -> &'a mut u32 { + | -- lifetime `'a` defined here +LL | &mut *(*s).0 //[nll]~ ERROR borrow may still be in use when destructor runs [E0713] + | ^^^^^^^^^^^^ returning this value requires that `*s.0` is borrowed for `'a` ... LL | } - | - `*s.0` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 72:20... - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:72:20 - | -LL | fn boxed_scribbled<'a>(s: Box>) -> &'a mut u32 { - | ^^ + | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait -error[E0597]: `*s.0` does not live long enough +error[E0713]: borrow may still be in use when destructor runs --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:83:5 | -LL | &mut *(**s).0 //[nll]~ ERROR `*s.0` does not live long enough [E0597] - | ^^^^^^^^^^^^^ borrowed value does not live long enough +LL | fn boxed_boxed_scribbled<'a>(s: Box>>) -> &'a mut u32 { + | -- lifetime `'a` defined here +LL | &mut *(**s).0 //[nll]~ ERROR borrow may still be in use when destructor runs [E0713] + | ^^^^^^^^^^^^^ returning this value requires that `*s.0` is borrowed for `'a` ... LL | } - | - `*s.0` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 82:26... - --> $DIR/issue-45696-scribble-on-boxed-borrow.rs:82:26 - | -LL | fn boxed_boxed_scribbled<'a>(s: Box>>) -> &'a mut u32 { - | ^^ + | - here, drop of `s` needs exclusive access to `*s.0`, because the type `Scribble<'_>` implements the `Drop` trait error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0713`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs 2018-12-04 23:41:40.000000000 +0000 @@ -60,8 +60,8 @@ // this should be an error. (Which is perhaps the essence of why // rust-lang/rust#45696 arose in the first place.) fn scribbled<'a>(s: Scribble<'a>) -> &'a mut u32 { - &mut *s.0 //[nll]~ ERROR `*s.0` does not live long enough [E0597] - //[migrate]~^ WARNING `*s.0` does not live long enough [E0597] + &mut *s.0 //[nll]~ ERROR borrow may still be in use when destructor runs [E0713] + //[migrate]~^ WARNING borrow may still be in use when destructor runs [E0713] //[migrate]~| WARNING This error has been downgraded to a warning for backwards compatibility } @@ -70,8 +70,8 @@ // (But again, AST-borrowck was not smart enogh to know that this // should be an error.) fn boxed_scribbled<'a>(s: Box>) -> &'a mut u32 { - &mut *(*s).0 //[nll]~ ERROR `*s.0` does not live long enough [E0597] - //[migrate]~^ WARNING `*s.0` does not live long enough [E0597] + &mut *(*s).0 //[nll]~ ERROR borrow may still be in use when destructor runs [E0713] + //[migrate]~^ WARNING borrow may still be in use when destructor runs [E0713] //[migrate]~| WARNING This error has been downgraded to a warning for backwards compatibility } @@ -80,8 +80,8 @@ // (But again, AST-borrowck was not smart enogh to know that this // should be an error.) fn boxed_boxed_scribbled<'a>(s: Box>>) -> &'a mut u32 { - &mut *(**s).0 //[nll]~ ERROR `*s.0` does not live long enough [E0597] - //[migrate]~^ WARNING `*s.0` does not live long enough [E0597] + &mut *(**s).0 //[nll]~ ERROR borrow may still be in use when destructor runs [E0713] + //[migrate]~^ WARNING borrow may still be in use when destructor runs [E0713] //[migrate]~| WARNING This error has been downgraded to a warning for backwards compatibility } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -5,7 +5,7 @@ | ^^^^^^^^^^^^^^^^^ `std` reimported here | = note: `std` 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 +help: you can use `as` to change the binding name of the import | LL | extern crate std as other_std; | diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/auxiliary/issue_45829_a.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/auxiliary/issue_45829_a.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/auxiliary/issue_45829_a.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/auxiliary/issue_45829_a.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub const FOO: usize = *&0; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/auxiliary/issue_45829_b.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/auxiliary/issue_45829_b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/auxiliary/issue_45829_b.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/auxiliary/issue_45829_b.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub const FOO: usize = *&0; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/import-self.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/import-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/import-self.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/import-self.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod foo { + pub struct A; + pub struct B; +} + +use foo::{self}; + +use foo as self; + +use foo::self; + +use foo::A; +use foo::{self as A}; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/import-self.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/import-self.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/import-self.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/import-self.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +error: expected identifier, found keyword `self` + --> $DIR/import-self.rs:18:12 + | +LL | use foo as self; + | ^^^^ expected identifier, found keyword + +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/import-self.rs:20:5 + | +LL | use foo::self; + | ^^^^^^^^^ + +error[E0255]: the name `foo` is defined multiple times + --> $DIR/import-self.rs:16:11 + | +LL | mod foo { + | ------- previous definition of the module `foo` here +... +LL | use foo::{self}; + | ^^^^ `foo` reimported here + | + = note: `foo` 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 + | +LL | use foo::{self as other_foo}; + | ^^^^^^^^^^^^^^^^^ + +error[E0252]: the name `A` is defined multiple times + --> $DIR/import-self.rs:23:11 + | +LL | use foo::A; + | ------ previous import of the type `A` here +LL | use foo::{self as A}; + | ^^^^^^^^^ `A` reimported here + | + = note: `A` 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 + | +LL | use foo::{self as OtherA}; + | ^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +Some errors occurred: E0252, E0255, E0429. +For more information about an error, try `rustc --explain E0252`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/import-twice.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/import-twice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/import-twice.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/import-twice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod foo { + pub struct A; + pub struct B; +} + +use foo::{A, A}; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/import-twice.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/import-twice.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/import-twice.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/import-twice.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +error[E0252]: the name `A` is defined multiple times + --> $DIR/import-twice.rs:16:14 + | +LL | use foo::{A, A}; + | - ^ `A` reimported here + | | + | previous import of the type `A` here + | + = note: `A` 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 + | +LL | use foo::{A, A as OtherA}; + | ^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0252`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/issue-45829.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/issue-45829.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/issue-45829.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/issue-45829.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod foo { + pub struct A; + pub struct B; +} + +use foo::{A, B as A}; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/issue-45829.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/issue-45829.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/issue-45829.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/issue-45829.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +error[E0252]: the name `A` is defined multiple times + --> $DIR/issue-45829.rs:16:14 + | +LL | use foo::{A, B as A}; + | - ^^^^^^ `A` reimported here + | | + | previous import of the type `A` here + | + = note: `A` 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 + | +LL | use foo::{A, B as OtherA}; + | ^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0252`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue_45829_a.rs +// aux-build:issue_45829_b.rs + +extern crate issue_45829_a; +extern crate issue_45829_b as issue_45829_a; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +error[E0259]: the name `issue_45829_a` is defined multiple times + --> $DIR/rename-extern.rs:15:1 + | +LL | extern crate issue_45829_a; + | --------------------------- previous import of the extern crate `issue_45829_a` here +LL | extern crate issue_45829_b as issue_45829_a; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `issue_45829_a` reimported here + | + = note: `issue_45829_a` 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 + | +LL | extern crate issue_45829_b as other_issue_45829_a; + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0259`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern-vs-use.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern-vs-use.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern-vs-use.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern-vs-use.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue_45829_b.rs + +mod foo { + pub mod bar {} +} + +use foo::bar; +extern crate issue_45829_b as bar; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern-vs-use.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern-vs-use.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern-vs-use.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern-vs-use.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +error[E0254]: the name `bar` is defined multiple times + --> $DIR/rename-extern-vs-use.rs:18:1 + | +LL | use foo::bar; + | -------- previous import of the module `bar` here +LL | extern crate issue_45829_b as bar; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `bar` reimported here + | + = note: `bar` 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 + | +LL | extern crate issue_45829_b as other_bar; + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0254`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern-with-tab.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern-with-tab.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern-with-tab.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern-with-tab.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue_45829_a.rs +// aux-build:issue_45829_b.rs + +extern crate issue_45829_a; +extern crate issue_45829_b as issue_45829_a; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern-with-tab.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern-with-tab.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern-with-tab.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-extern-with-tab.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +error[E0259]: the name `issue_45829_a` is defined multiple times + --> $DIR/rename-extern-with-tab.rs:15:1 + | +LL | extern crate issue_45829_a; + | --------------------------- previous import of the extern crate `issue_45829_a` here +LL | extern crate issue_45829_b as issue_45829_a; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `issue_45829_a` reimported here + | + = note: `issue_45829_a` 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 + | +LL | extern crate issue_45829_b as other_issue_45829_a; + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0259`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use core; +use std as core; + +fn main() { + 1 + 1; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +error[E0252]: the name `core` is defined multiple times + --> $DIR/rename.rs:12:5 + | +LL | use core; + | ---- previous import of the module `core` here +LL | use std as core; + | ^^^^^^^^^^^ `core` reimported here + | + = note: `core` 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 + | +LL | use std as other_core; + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0252`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-use-vs-extern.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-use-vs-extern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-use-vs-extern.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-use-vs-extern.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue_45829_b.rs + +extern crate issue_45829_b; +use std as issue_45829_b; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-use-vs-extern.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-use-vs-extern.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-use-vs-extern.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-use-vs-extern.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +error[E0254]: the name `issue_45829_b` is defined multiple times + --> $DIR/rename-use-vs-extern.rs:14:5 + | +LL | extern crate issue_45829_b; + | --------------------------- previous import of the extern crate `issue_45829_b` here +LL | use std as issue_45829_b; + | ^^^^^^^^^^^^^^^^^^^^ `issue_45829_b` reimported here + | + = note: `issue_45829_b` 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 + | +LL | use std as other_issue_45829_b; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0254`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-use-with-tabs.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-use-with-tabs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-use-with-tabs.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-use-with-tabs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod foo { + pub struct A; + + pub mod bar { + pub struct B; + } +} + +use foo::{A, bar::B as A}; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-use-with-tabs.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-use-with-tabs.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-use-with-tabs.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-use-with-tabs.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +error[E0252]: the name `A` is defined multiple times + --> $DIR/rename-use-with-tabs.rs:19:14 + | +LL | use foo::{A, bar::B as A}; + | - ^^^^^^^^^^^^^^^^^ `A` reimported here + | | + | previous import of the type `A` here + | + = note: `A` 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 + | +LL | use foo::{A, bar::B as OtherA}; + | ^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0252`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-with-path.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-with-path.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-with-path.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-with-path.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::{collections::HashMap as A, sync::Arc as A}; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-with-path.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-with-path.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-with-path.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-45829/rename-with-path.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +error[E0252]: the name `A` is defined multiple times + --> $DIR/rename-with-path.rs:11:38 + | +LL | use std::{collections::HashMap as A, sync::Arc as A}; + | ------------------------- ^^^^^^^^^^^^^^ `A` reimported here + | | + | previous import of the type `A` here + | + = note: `A` 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 + | +LL | use std::{collections::HashMap as A, sync::Arc as OtherA}; + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0252`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-46036.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-46036.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-46036.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-46036.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,12 +2,13 @@ --> $DIR/issue-46036.rs:19:24 | LL | let foo = Foo { x: &a }; //~ ERROR E0597 - | ^^ borrowed value does not live long enough + | ^^ + | | + | borrowed value does not live long enough + | requires that `a` is borrowed for `'static` LL | loop { } LL | } | - `a` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-46471.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-46471.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-46471.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-46471.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,7 +14,7 @@ let x = 0; &x //~^ ERROR `x` does not live long enough (Ast) [E0597] - //~| ERROR `x` does not live long enough (Mir) [E0597] + //~| ERROR cannot return reference to local variable `x` (Mir) [E0515] } fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-46471.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-46471.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-46471.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-46471.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -9,17 +9,13 @@ | = note: borrowed value must be valid for the static lifetime... -error[E0597]: `x` does not live long enough (Mir) +error[E0515]: cannot return reference to local variable `x` (Mir) --> $DIR/issue-46471.rs:15:5 | LL | &x - | ^^ borrowed value does not live long enough -... -LL | } - | - `x` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... + | ^^ returns a reference to data owned by the current function error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +Some errors occurred: E0515, E0597. +For more information about an error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-46472.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-46472.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-46472.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-46472.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,7 +13,7 @@ fn bar<'a>() -> &'a mut u32 { &mut 4 //~^ ERROR borrowed value does not live long enough (Ast) [E0597] - //~| ERROR borrowed value does not live long enough (Mir) [E0597] + //~| ERROR cannot return reference to temporary value (Mir) [E0515] } fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-46472.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-46472.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-46472.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-46472.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -13,21 +13,16 @@ LL | fn bar<'a>() -> &'a mut u32 { | ^^ -error[E0597]: borrowed value does not live long enough (Mir) - --> $DIR/issue-46472.rs:14:10 +error[E0515]: cannot return reference to temporary value (Mir) + --> $DIR/issue-46472.rs:14:5 | LL | &mut 4 - | ^ temporary value does not live long enough -... -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:8... - --> $DIR/issue-46472.rs:13:8 - | -LL | fn bar<'a>() -> &'a mut u32 { - | ^^ + | ^^^^^- + | | | + | | temporary value created here + | returns a reference to data owned by the current function error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +Some errors occurred: E0515, E0597. +For more information about an error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-46959.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-46959.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-46959.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-46959.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![deny(non_camel_case_types)] + +#[allow(dead_code)] +fn qqq(lol: impl Iterator) -> impl Iterator { + lol.map(|x|x as u64) +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-46964.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-46964.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-46964.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-46964.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +mod my_mod { + #[derive(Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Hash)] + pub struct Name<'a> { + source: &'a str, + } + + pub const JSON: Name = Name { source: "JSON" }; +} + +pub fn crash() -> bool { + match (my_mod::JSON, None) { + (_, Some(my_mod::JSON)) => true, + (my_mod::JSON, None) => true, + _ => false, + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-47184.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-47184.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-47184.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-47184.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,5 +12,5 @@ fn main() { let _vec: Vec<&'static String> = vec![&String::new()]; - //~^ ERROR borrowed value does not live long enough [E0597] + //~^ ERROR temporary value dropped while borrowed [E0716] } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-47184.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-47184.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-47184.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-47184.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,13 +1,12 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/issue-47184.rs:14:44 | LL | let _vec: Vec<&'static String> = vec![&String::new()]; - | ^^^^^^^^^^^^^ - temporary value only lives until here - | | - | temporary value does not live long enough - | - = note: borrowed value must be valid for the static lifetime... + | -------------------- ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement + | | | + | | creates a temporary which is freed while still in use + | type annotation requires that borrow lasts for `'static` error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-47646.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-47646.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-47646.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-47646.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -3,9 +3,15 @@ | LL | let borrow = heap.peek_mut(); | ---- mutable borrow occurs here -... +LL | +LL | match (borrow, ()) { + | ------------ a temporary with access to the mutable borrow is created here ... +LL | (Some(_), ()) => { LL | println!("{:?}", heap); //~ ERROR cannot borrow `heap` as immutable | ^^^^ immutable borrow occurs here +... +LL | }; + | - ... and the mutable borrow might be used here, when that temporary is dropped and runs the destructor for type `(std::option::Option>, ())` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-47673.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-47673.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-47673.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-47673.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(unused_imports)] + +use {{}, {}}; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-47703-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-47703-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-47703-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-47703-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![feature(nll)] + +struct AtomicRefMut<'a> { + value: &'a mut i32, + borrow: AtomicBorrowRefMut, +} + +struct AtomicBorrowRefMut { +} + +impl Drop for AtomicBorrowRefMut { + fn drop(&mut self) { + } +} + +fn map(orig: AtomicRefMut) -> AtomicRefMut { + AtomicRefMut { + value: orig.value, + borrow: orig.borrow, + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-47703.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-47703.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-47703.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-47703.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![feature(nll)] + +struct MyStruct<'a> { + field: &'a mut (), + field2: WithDrop +} + +struct WithDrop; + +impl Drop for WithDrop { + fn drop(&mut self) {} +} + +impl<'a> MyStruct<'a> { + fn consume(self) -> &'a mut () { self.field } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-47703-tuple.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-47703-tuple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-47703-tuple.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-47703-tuple.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![feature(nll)] + +struct WithDrop; + +impl Drop for WithDrop { + fn drop(&mut self) {} +} + +fn consume(x: (&mut (), WithDrop)) -> &mut () { x.0 } + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-47722.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-47722.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-47722.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-47722.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] + +// 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() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-47789.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-47789.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-47789.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-47789.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(non_upper_case_globals)] + +#![feature(nll)] + +static mut x: &'static u32 = &0; + +fn foo() { + unsafe { x = &1; } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-4830.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-4830.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-4830.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-4830.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] + +// pretty-expanded FIXME #23616 + +pub struct Scheduler { + /// The event loop used to drive the scheduler and perform I/O + event_loop: Box +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-48551.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-48551.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-48551.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-48551.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// Regression test for #48551. Covers a case where duplicate candidates +// arose during associated type projection. + +use std::ops::{Mul, MulAssign}; + +pub trait ClosedMul: Sized + Mul + MulAssign {} +impl ClosedMul for T +where + T: Mul + MulAssign, +{ +} + +pub trait InnerSpace: ClosedMul<::Real> { + type Real; +} + +pub trait FiniteDimVectorSpace: ClosedMul<::Field> { + type Field; +} + +pub trait FiniteDimInnerSpace + : InnerSpace + FiniteDimVectorSpace::Real> { +} + +pub trait EuclideanSpace: ClosedMul<::Real> { + type Coordinates: FiniteDimInnerSpace + + Mul + + MulAssign; + + type Real; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-49824.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-49824.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-49824.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-49824.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,17 +1,30 @@ -error: unsatisfied lifetime constraints +warning: captured variable cannot escape `FnMut` closure body --> $DIR/issue-49824.rs:22:9 | LL | || { - | -- - | || - | |return type of closure is [closure@$DIR/issue-49824.rs:22:9: 24:10 x:&'2 mut i32] - | lifetime `'1` represents this closure's body + | - inferred to be a `FnMut` closure LL | / || { LL | | let _y = &mut x; LL | | } - | |_________^ returning this value requires that `'1` must outlive `'2` + | |_________^ returns a closure that contains a reference to a captured variable, which then escapes the closure body | - = note: closure implements `FnMut`, so references to captured variables can't escape the closure + = note: `FnMut` closures only have access to their captured variables while they are executing... + = note: ...therefore, they cannot allow references to captured variables to escape + = warning: This error has been downgraded to a warning for backwards compatibility with previous releases. + It represents potential unsoundness in your code. + This warning will become a hard error in the future. + +error: compilation successful + --> $DIR/issue-49824.rs:18:1 + | +LL | / fn main() { +LL | | //~^ compilation successful +LL | | let mut x = 0; +LL | | || { +... | +LL | | }; +LL | | } + | |_^ error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-50480.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-50480.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-50480.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-50480.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,6 +12,6 @@ //~^ ERROR the trait `Copy` may not be implemented for this type struct Foo(NotDefined, ::Item, Vec, String); //~^ ERROR cannot find type `NotDefined` in this scope -//~| ERROR the trait bound `i32: std::iter::Iterator` is not satisfied +//~| ERROR `i32` is not an iterator fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-50480.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-50480.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-50480.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-50480.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -4,13 +4,14 @@ LL | struct Foo(NotDefined, ::Item, Vec, String); | ^^^^^^^^^^ not found in this scope -error[E0277]: the trait bound `i32: std::iter::Iterator` is not satisfied +error[E0277]: `i32` is not an iterator --> $DIR/issue-50480.rs:13:24 | LL | struct Foo(NotDefined, ::Item, Vec, String); - | ^^^^^^^^^^^^^^^^^^^^^^^ `i32` is not an iterator; maybe try calling `.iter()` or a similar method + | ^^^^^^^^^^^^^^^^^^^^^^^ `i32` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `i32` + = note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end` error[E0204]: the trait `Copy` may not be implemented for this type --> $DIR/issue-50480.rs:11:17 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-51632-try-desugar-incompatible-types.fixed rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-51632-try-desugar-incompatible-types.fixed --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-51632-try-desugar-incompatible-types.fixed 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-51632-try-desugar-incompatible-types.fixed 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-rustfix - -#![allow(dead_code)] - -fn missing_discourses() -> Result { - Ok(1) -} - -fn forbidden_narratives() -> Result { - Ok(missing_discourses()?) - //~^ ERROR try expression alternatives have incompatible types - //~| HELP try wrapping with a success variant -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-51632-try-desugar-incompatible-types.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-51632-try-desugar-incompatible-types.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-51632-try-desugar-incompatible-types.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-51632-try-desugar-incompatible-types.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// run-rustfix - #![allow(dead_code)] fn missing_discourses() -> Result { @@ -19,7 +17,6 @@ fn forbidden_narratives() -> Result { missing_discourses()? //~^ ERROR try expression alternatives have incompatible types - //~| HELP try wrapping with a success variant } fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-51632-try-desugar-incompatible-types.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-51632-try-desugar-incompatible-types.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-51632-try-desugar-incompatible-types.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-51632-try-desugar-incompatible-types.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,11 +1,8 @@ error[E0308]: try expression alternatives have incompatible types - --> $DIR/issue-51632-try-desugar-incompatible-types.rs:20:5 + --> $DIR/issue-51632-try-desugar-incompatible-types.rs:18:5 | LL | missing_discourses()? - | ^^^^^^^^^^^^^^^^^^^^^ - | | - | expected enum `std::result::Result`, found isize - | help: try wrapping with a success variant: `Ok(missing_discourses()?)` + | ^^^^^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found isize | = note: expected type `std::result::Result` found type `isize` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-51655.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-51655.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-51655.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-51655.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] + +const PATH_DOT: &[u8] = &[b'.']; + +fn match_slice(element: &[u8]) { + match element { + &[] => {} + PATH_DOT => {} + _ => {} + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-52049.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-52049.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-52049.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-52049.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,13 +1,14 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/issue-52049.rs:16:10 | LL | foo(&unpromotable(5u32)); - | ^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | -----^^^^^^^^^^^^^^^^^^- + | | | + | | creates a temporary which is freed while still in use + | argument requires that borrow lasts for `'static` LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | - temporary value is freed at the end of this statement error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-52126-assign-op-invariance.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-52126-assign-op-invariance.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-52126-assign-op-invariance.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-52126-assign-op-invariance.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -5,7 +5,7 @@ | ^^^^ borrowed value does not live long enough LL | //~^ ERROR `line` does not live long enough LL | println!("accumulator before add_assign {:?}", acc.map); - | ------- borrow used here in later iteration of loop + | ------- borrow used here, in later iteration of loop ... LL | } | - `line` dropped here while still borrowed diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-52213.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-52213.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-52213.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-52213.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/issue-52213.rs:13:20 - | -LL | fn transmute_lifetime<'a, 'b, T>(t: &'a (T,)) -> &'b T { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | match (&t,) { //~ ERROR cannot infer an appropriate lifetime -LL | ((u,),) => u, - | ^ returning this value requires that `'a` must outlive `'b` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-52240.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-52240.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-52240.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-52240.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/issue-52240.rs:9:27 + | +LL | if let (Some(Foo::Bar(ref mut val)), _) = (&arr.get(0), 0) { + | ^^^^^^^^^^^ cannot borrow as mutable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-52240.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-52240.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-52240.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-52240.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// issue-52240: Can turn immutable into mut with `ref mut` + +enum Foo { + Bar(i32), +} + +fn main() { + let arr = vec!(Foo::Bar(0)); + if let (Some(Foo::Bar(ref mut val)), _) = (&arr.get(0), 0) { + //~^ ERROR cannot borrow field of immutable binding as mutable + *val = 9001; + } + match arr[0] { + Foo::Bar(ref s) => println!("{}", s) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-52240.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-52240.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-52240.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-52240.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0596]: cannot borrow field of immutable binding as mutable + --> $DIR/issue-52240.rs:9:27 + | +LL | if let (Some(Foo::Bar(ref mut val)), _) = (&arr.get(0), 0) { + | ^^^^^^^^^^^ cannot mutably borrow field of immutable binding + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-52533-1.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-52533-1.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-52533-1.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-52533-1.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/issue-52533-1.rs:19:18 - | -LL | gimme(|x, y| y) - | - - ^ closure was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` - | | | - | | has type `&Foo<'_, '1, u32>` - | has type `&Foo<'_, '2, u32>` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-52533.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-52533.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-52533.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-52533.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/issue-52533.rs:15:16 - | -LL | foo(|a, b| b) - | - - ^ closure was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` - | | | - | | has type `&'1 u32` - | has type `&'2 u32` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-5353.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-5353.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-5353.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-5353.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +const INVALID_ENUM : u32 = 0; +const INVALID_VALUE : u32 = 1; + +fn gl_err_str(err: u32) -> String +{ + match err + { + INVALID_ENUM => { "Invalid enum".to_string() }, + INVALID_VALUE => { "Invalid value".to_string() }, + _ => { "Unknown error".to_string() } + } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-53675-a-test-called-panic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-53675-a-test-called-panic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-53675-a-test-called-panic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-53675-a-test-called-panic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// rust-lang/rust#53675: At one point the compiler errored when a test +// named `panic` used the `assert!` macro in expression position. + +// compile-pass +// compile-flags: --test + +mod in_expression_position { + #[test] + fn panic() { + assert!(true) + } +} + +mod in_statement_position { + #[test] + fn panic() { + assert!(true); + } +} + +mod what_if_we_use_panic_directly_in_expr { + #[test] + #[should_panic] + fn panic() { + panic!("in expr") + } +} + + +mod what_if_we_use_panic_directly_in_stmt { + #[test] + #[should_panic] + fn panic() { + panic!("in stmt"); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-53712.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-53712.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-53712.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-53712.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +// issue #53712: make the error generated by using tuple indexing on an array more specific + +fn main() { + let arr = [10, 20, 30, 40, 50]; + arr.0; + //~^ ERROR no field `0` on type `[{integer}; 5]` [E0609] + //~| HELP instead of using tuple indexing, use array indexing + //~| SUGGESTION arr[0] +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-53712.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-53712.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-53712.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-53712.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0609]: no field `0` on type `[{integer}; 5]` + --> $DIR/issue-53712.rs:5:9 + | +LL | arr.0; + | ----^ + | | + | help: instead of using tuple indexing, use array indexing: `arr[0]` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0609`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-54410.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-54410.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-54410.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-54410.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +extern "C" { + pub static mut symbol: [i8]; + //~^ ERROR the size for values of type `[i8]` cannot be known at compilation time +} + +fn main() { + println!("{:p}", unsafe { &symbol }); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-54410.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-54410.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-54410.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-54410.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +error[E0277]: the size for values of type `[i8]` cannot be known at compilation time + --> $DIR/issue-54410.rs:2:28 + | +LL | pub static mut symbol: [i8]; + | ^^^^ doesn't have a size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `[i8]` + = note: to learn more, visit + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-54966.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-54966.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-54966.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-54966.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,6 @@ +// issue-54966: ICE returning an unknown type with impl FnMut + +fn generate_duration() -> Oper {} +//~^ ERROR cannot find type `Oper` in this scope + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-54966.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-54966.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-54966.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-54966.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `Oper` in this scope + --> $DIR/issue-54966.rs:3:27 + | +LL | fn generate_duration() -> Oper {} + | ^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-5572.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-5572.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-5572.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-5572.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +fn foo(_t: T) { } + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-55796.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-55796.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-55796.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-55796.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +pub trait EdgeTrait { + fn target(&self) -> N; +} + +pub trait Graph<'a> { + type Node; + type Edge: EdgeTrait; + type NodesIter: Iterator + 'a; + type EdgesIter: Iterator + 'a; + + fn nodes(&'a self) -> Self::NodesIter; + fn out_edges(&'a self, u: &Self::Node) -> Self::EdgesIter; + fn in_edges(&'a self, u: &Self::Node) -> Self::EdgesIter; + + fn out_neighbors(&'a self, u: &Self::Node) -> Box> { + Box::new(self.out_edges(u).map(|e| e.target())) + } + + fn in_neighbors(&'a self, u: &Self::Node) -> Box> { + Box::new(self.in_edges(u).map(|e| e.target())) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-55796.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-55796.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-55796.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-55796.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,50 @@ +error[E0601]: `main` function not found in crate `issue_55796` + | + = note: consider adding a `main` function to `$DIR/issue-55796.rs` + +error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements + --> $DIR/issue-55796.rs:16:9 + | +LL | Box::new(self.out_edges(u).map(|e| e.target())) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: first, the lifetime cannot outlive the lifetime 'a as defined on the trait at 5:17... + --> $DIR/issue-55796.rs:5:17 + | +LL | pub trait Graph<'a> { + | ^^ +note: ...so that the type `std::iter::Map<>::EdgesIter, [closure@$DIR/issue-55796.rs:16:40: 16:54]>` will meet its required lifetime bounds + --> $DIR/issue-55796.rs:16:9 + | +LL | Box::new(self.out_edges(u).map(|e| e.target())) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: but, the lifetime must be valid for the static lifetime... + = note: ...so that the expression is assignable: + expected std::boxed::Box<(dyn std::iter::Iterator>::Node> + 'static)> + found std::boxed::Box>::Node>> + +error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements + --> $DIR/issue-55796.rs:20:9 + | +LL | Box::new(self.in_edges(u).map(|e| e.target())) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: first, the lifetime cannot outlive the lifetime 'a as defined on the trait at 5:17... + --> $DIR/issue-55796.rs:5:17 + | +LL | pub trait Graph<'a> { + | ^^ +note: ...so that the type `std::iter::Map<>::EdgesIter, [closure@$DIR/issue-55796.rs:20:39: 20:53]>` will meet its required lifetime bounds + --> $DIR/issue-55796.rs:20:9 + | +LL | Box::new(self.in_edges(u).map(|e| e.target())) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: but, the lifetime must be valid for the static lifetime... + = note: ...so that the expression is assignable: + expected std::boxed::Box<(dyn std::iter::Iterator>::Node> + 'static)> + found std::boxed::Box>::Node>> + +error: aborting due to 3 previous errors + +Some errors occurred: E0495, E0601. +For more information about an error, try `rustc --explain E0495`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-56128.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-56128.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-56128.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-56128.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Regression test for #56128. When this `pub(super) use...` gets +// exploded in the HIR, we were not handling ids correctly. +// +// compile-pass + +mod bar { + pub(super) use self::baz::{x, y}; + + mod baz { + pub fn x() { } + pub fn y() { } + } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-5754.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-5754.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-5754.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-5754.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(improper_ctypes)] + +// pretty-expanded FIXME #23616 + +struct TwoDoubles { + r: f64, + i: f64 +} + +extern "C" { + fn rust_dbg_extern_identity_TwoDoubles(arg1: TwoDoubles) -> TwoDoubles; +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-5884.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-5884.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-5884.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-5884.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +#![feature(box_syntax)] + +pub struct Foo { + a: isize, +} + +struct Bar<'a> { + a: Box>, + b: &'a Foo, +} + +fn check(a: Box) { + let _ic = Bar{ b: &*a, a: box None }; +} + +pub fn main(){} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-5900.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-5900.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-5900.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-5900.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +pub mod foo { + use super::Bar; + + pub struct FooStruct { bar : Bar } +} + +pub enum Bar { + Bar0 = 0 as isize +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-5950.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-5950.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-5950.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-5950.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass + +// pretty-expanded FIXME #23616 + +pub use local as local_alias; + +pub mod local { } + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-6341.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-6341.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-6341.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-6341.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// pretty-expanded FIXME #23616 + +#[derive(PartialEq)] +struct A { x: usize } + +impl Drop for A { + fn drop(&mut self) {} +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-6470.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-6470.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-6470.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-6470.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(improper_ctypes)] + +// pretty-expanded FIXME #23616 +#![allow(non_snake_case)] + +pub mod Bar { + pub struct Foo { + v: isize, + } + + extern { + pub fn foo(v: *const Foo) -> Foo; + } +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-6557.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-6557.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-6557.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-6557.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +#![feature(box_patterns)] +#![feature(box_syntax)] + +fn foo(box (_x, _y): Box<(isize, isize)>) {} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-6898.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-6898.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-6898.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-6898.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// pretty-expanded FIXME #23616 + +use std::mem; + +/// Returns the size of a type +pub fn size_of() -> usize { + TypeInfo::size_of(None::) +} + +/// Returns the size of the type that `val` points to +pub fn size_of_val(val: &T) -> usize { + val.size_of_val() +} + +pub trait TypeInfo: Sized { + fn size_of(_lame_type_hint: Option) -> usize; + fn size_of_val(&self) -> usize; +} + +impl TypeInfo for T { + /// The size of the type in bytes. + fn size_of(_lame_type_hint: Option) -> usize { + mem::size_of::() + } + + /// Returns the size of the type of `self` in bytes. + fn size_of_val(&self) -> usize { + TypeInfo::size_of(None::) + } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-6991.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-6991.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-6991.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-6991.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(non_upper_case_globals)] + +static x: &'static usize = &1; +static y: usize = *x; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-7268.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-7268.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-7268.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-7268.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +fn foo(_: T) {} + +fn bar(x: &'static T) { + foo(x); +} +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-7607-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-7607-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-7607-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-7607-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +pub mod a { + pub struct Foo { a: usize } +} + +pub mod b { + use a::Foo; + impl Foo { + fn bar(&self) { } + } +} + +pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-7673-cast-generically-implemented-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-7673-cast-generically-implemented-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-7673-cast-generically-implemented-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-7673-cast-generically-implemented-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +/* + +#7673 Polymorphically creating traits barely works + +*/ + +#![feature(box_syntax)] + +pub fn main() {} + +trait A { + fn dummy(&self) { } +} + +impl A for T {} + +fn owned2(a: Box) { a as Box; } +fn owned3(a: Box) { box a as Box; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-8171-default-method-self-inherit-builtin-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-8171-default-method-self-inherit-builtin-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-8171-default-method-self-inherit-builtin-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-8171-default-method-self-inherit-builtin-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +/* + +#8171 Self is not recognised as implementing kinds in default method implementations + +*/ + +fn require_send(_: T){} + +trait TragicallySelfIsNotSend: Send + Sized { + fn x(self) { + require_send(self); + } +} + +pub fn main(){} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-8398.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-8398.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-8398.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-8398.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +pub trait Writer { + fn write(&mut self, b: &[u8]) -> Result<(), ()>; +} + +fn foo(a: &mut Writer) { + a.write(&[]).unwrap(); +} + +pub fn main(){} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-8521.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-8521.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-8521.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-8521.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +trait Foo1 {} + +trait A {} + +macro_rules! foo1(($t:path) => { + impl Foo1 for T {} +}); + +foo1!(A); + +trait Foo2 {} + +trait B {} + +#[allow(unused)] +struct C {} + +macro_rules! foo2(($t:path) => { + impl Foo2 for T {} +}); + +foo2!(B); + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-8578.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-8578.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-8578.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-8578.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] +#![allow(non_upper_case_globals)] +// pretty-expanded FIXME #23616 + +pub struct UninterpretedOption_NamePart { + name_part: Option, +} + +impl<'a> UninterpretedOption_NamePart { + pub fn default_instance() -> &'static UninterpretedOption_NamePart { + static instance: UninterpretedOption_NamePart = UninterpretedOption_NamePart { + name_part: None, + }; + &instance + } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-8640.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-8640.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-8640.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-8640.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^^^^^^ `bar` redefined here | = note: `bar` 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 +help: you can use `as` to change the binding name of the import | LL | use baz::bar as other_bar; | ^^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-9110.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-9110.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-9110.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-9110.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 +#![allow(non_snake_case)] + +macro_rules! silly_macro { + () => ( + pub mod Qux { + pub struct Foo { x : u8 } + pub fn bar(_foo : Foo) {} + } + ); +} + +silly_macro!(); + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-9243.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-9243.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-9243.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-9243.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// Regression test for issue 9243 +#![allow(non_upper_case_globals)] + +pub struct Test { + mem: isize, +} + +pub static g_test: Test = Test {mem: 0}; + +impl Drop for Test { + fn drop(&mut self) {} +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-9249.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-9249.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-9249.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-9249.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +static DATA:&'static [&'static str] = &["my string"]; +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-9719.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-9719.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/issues/issue-9719.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/issues/issue-9719.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,51 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +mod a { + pub enum Enum { + A(T), + } + + pub trait X { + fn dummy(&self) { } + } + impl X for isize {} + + pub struct Z<'a>(Enum<&'a (X+'a)>); + fn foo() { let x: isize = 42; let z = Z(Enum::A(&x as &X)); let _ = z; } +} + +mod b { + trait X { + fn dummy(&self) { } + } + impl X for isize {} + struct Y<'a>{ + x:Option<&'a (X+'a)>, + } + + fn bar() { + let x: isize = 42; + let _y = Y { x: Some(&x as &X) }; + } +} + +mod c { + pub trait X { fn f(&self); } + impl X for isize { fn f(&self) {} } + pub struct Z<'a>(Option<&'a (X+'a)>); + fn main() { let x: isize = 42; let z = Z(Some(&x as &X)); let _ = z; } +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/array-of-ranges.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/array-of-ranges.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/array-of-ranges.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/array-of-ranges.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +fn main() { + for _ in [0..1] {} + for _ in [0..=1] {} + for _ in [0..] {} + for _ in [..1] {} + for _ in [..=1] {} + let start = 0; + let end = 0; + for _ in [start..end] {} + let array_of_range = [start..end]; + for _ in array_of_range {} + for _ in [0..1, 2..3] {} + for _ in [0..=1] {} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/array-of-ranges.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/array-of-ranges.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/array-of-ranges.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/array-of-ranges.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,93 @@ +error[E0277]: `[std::ops::Range<{integer}>; 1]` is not an iterator + --> $DIR/array-of-ranges.rs:2:14 + | +LL | for _ in [0..1] {} + | ^^^^^^ if you meant to iterate between two values, remove the square brackets + | + = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::Range<{integer}>; 1]` + = note: `[start..end]` is an array of one `Range`; you might have meant to have a `Range` without the brackets: `start..end` + = note: required by `std::iter::IntoIterator::into_iter` + +error[E0277]: `[std::ops::RangeInclusive<{integer}>; 1]` is not an iterator + --> $DIR/array-of-ranges.rs:3:14 + | +LL | for _ in [0..=1] {} + | ^^^^^^^ if you meant to iterate between two values, remove the square brackets + | + = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::RangeInclusive<{integer}>; 1]` + = note: `[start..=end]` is an array of one `RangeInclusive`; you might have meant to have a `RangeInclusive` without the brackets: `start..=end` + = note: required by `std::iter::IntoIterator::into_iter` + +error[E0277]: `[std::ops::RangeFrom<{integer}>; 1]` is not an iterator + --> $DIR/array-of-ranges.rs:4:14 + | +LL | for _ in [0..] {} + | ^^^^^ if you meant to iterate from a value onwards, remove the square brackets + | + = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::RangeFrom<{integer}>; 1]` + = note: `[start..]` is an array of one `RangeFrom`; you might have meant to have a `RangeFrom` without the brackets: `start..`, keeping in mind that iterating over an unbounded iterator will run forever unless you `break` or `return` from within the loop + = note: required by `std::iter::IntoIterator::into_iter` + +error[E0277]: `[std::ops::RangeTo<{integer}>; 1]` is not an iterator + --> $DIR/array-of-ranges.rs:5:14 + | +LL | for _ in [..1] {} + | ^^^^^ if you meant to iterate until a value, remove the square brackets and add a starting value + | + = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::RangeTo<{integer}>; 1]` + = note: `[..end]` is an array of one `RangeTo`; you might have meant to have a bounded `Range` without the brackets: `0..end` + = note: required by `std::iter::IntoIterator::into_iter` + +error[E0277]: `[std::ops::RangeToInclusive<{integer}>; 1]` is not an iterator + --> $DIR/array-of-ranges.rs:6:14 + | +LL | for _ in [..=1] {} + | ^^^^^^ if you meant to iterate until a value (including it), remove the square brackets and add a starting value + | + = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::RangeToInclusive<{integer}>; 1]` + = note: `[..=end]` is an array of one `RangeToInclusive`; you might have meant to have a bounded `RangeInclusive` without the brackets: `0..=end` + = note: required by `std::iter::IntoIterator::into_iter` + +error[E0277]: `[std::ops::Range<{integer}>; 1]` is not an iterator + --> $DIR/array-of-ranges.rs:9:14 + | +LL | for _ in [start..end] {} + | ^^^^^^^^^^^^ if you meant to iterate between two values, remove the square brackets + | + = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::Range<{integer}>; 1]` + = note: `[start..end]` is an array of one `Range`; you might have meant to have a `Range` without the brackets: `start..end` + = note: required by `std::iter::IntoIterator::into_iter` + +error[E0277]: `[std::ops::Range<{integer}>; 1]` is not an iterator + --> $DIR/array-of-ranges.rs:11:14 + | +LL | for _ in array_of_range {} + | ^^^^^^^^^^^^^^ if you meant to iterate between two values, remove the square brackets + | + = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::Range<{integer}>; 1]` + = note: `[start..end]` is an array of one `Range`; you might have meant to have a `Range` without the brackets: `start..end` + = note: required by `std::iter::IntoIterator::into_iter` + +error[E0277]: `[std::ops::Range<{integer}>; 2]` is not an iterator + --> $DIR/array-of-ranges.rs:12:14 + | +LL | for _ in [0..1, 2..3] {} + | ^^^^^^^^^^^^ borrow the array with `&` or call `.iter()` on it to iterate over it + | + = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::Range<{integer}>; 2]` + = note: arrays are not an iterators, but slices like the following are: `&[1, 2, 3]` + = note: required by `std::iter::IntoIterator::into_iter` + +error[E0277]: `[std::ops::RangeInclusive<{integer}>; 1]` is not an iterator + --> $DIR/array-of-ranges.rs:13:14 + | +LL | for _ in [0..=1] {} + | ^^^^^^^ if you meant to iterate between two values, remove the square brackets + | + = help: the trait `std::iter::Iterator` is not implemented for `[std::ops::RangeInclusive<{integer}>; 1]` + = note: `[start..=end]` is an array of one `RangeInclusive`; you might have meant to have a `RangeInclusive` without the brackets: `start..=end` + = note: required by `std::iter::IntoIterator::into_iter` + +error: aborting due to 9 previous errors + +For more information about this error, try `rustc --explain E0277`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/array.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/array.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/array.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/array.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,6 @@ +fn main() { + for _ in [1, 2] {} + let x = [1, 2]; + for _ in x {} + for _ in [1.0, 2.0] {} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/array.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/array.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/array.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/array.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +error[E0277]: `[{integer}; 2]` is not an iterator + --> $DIR/array.rs:2:14 + | +LL | for _ in [1, 2] {} + | ^^^^^^ borrow the array with `&` or call `.iter()` on it to iterate over it + | + = help: the trait `std::iter::Iterator` is not implemented for `[{integer}; 2]` + = note: arrays are not an iterators, but slices like the following are: `&[1, 2, 3]` + = note: required by `std::iter::IntoIterator::into_iter` + +error[E0277]: `[{integer}; 2]` is not an iterator + --> $DIR/array.rs:4:14 + | +LL | for _ in x {} + | ^ borrow the array with `&` or call `.iter()` on it to iterate over it + | + = help: the trait `std::iter::Iterator` is not implemented for `[{integer}; 2]` + = note: arrays are not an iterators, but slices like the following are: `&[1, 2, 3]` + = note: required by `std::iter::IntoIterator::into_iter` + +error[E0277]: `[{float}; 2]` is not an iterator + --> $DIR/array.rs:5:14 + | +LL | for _ in [1.0, 2.0] {} + | ^^^^^^^^^^ borrow the array with `&` or call `.iter()` on it to iterate over it + | + = help: the trait `std::iter::Iterator` is not implemented for `[{float}; 2]` + = note: arrays are not an iterators, but slices like the following are: `&[1, 2, 3]` + = note: required by `std::iter::IntoIterator::into_iter` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/bound.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/bound.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/bound.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,3 @@ +struct S(I); +struct T(S); +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/bound.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/bound.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/bound.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/bound.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +error[E0277]: `u8` is not an iterator + --> $DIR/bound.rs:2:10 + | +LL | struct T(S); + | ^^^^^ `u8` is not an iterator + | + = help: the trait `std::iter::Iterator` is not implemented for `u8` + = note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end` +note: required by `S` + --> $DIR/bound.rs:1:1 + | +LL | struct S(I); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/integral.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/integral.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/integral.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/integral.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +fn main() { + for _ in 42 {} + //~^ ERROR `{integer}` is not an iterator + for _ in 42 as u8 {} + //~^ ERROR `u8` is not an iterator + for _ in 42 as i8 {} + //~^ ERROR `i8` is not an iterator + for _ in 42 as u16 {} + //~^ ERROR `u16` is not an iterator + for _ in 42 as i16 {} + //~^ ERROR `i16` is not an iterator + for _ in 42 as u32 {} + //~^ ERROR `u32` is not an iterator + for _ in 42 as i32 {} + //~^ ERROR `i32` is not an iterator + for _ in 42 as u64 {} + //~^ ERROR `u64` is not an iterator + for _ in 42 as i64 {} + //~^ ERROR `i64` is not an iterator + for _ in 42 as usize {} + //~^ ERROR `usize` is not an iterator + for _ in 42 as isize {} + //~^ ERROR `isize` is not an iterator + for _ in 42.0 {} + //~^ ERROR `{float}` is not an iterator +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/integral.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/integral.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/integral.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/integral.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,122 @@ +error[E0277]: `{integer}` is not an iterator + --> $DIR/integral.rs:2:14 + | +LL | for _ in 42 {} + | ^^ `{integer}` is not an iterator + | + = help: the trait `std::iter::Iterator` is not implemented for `{integer}` + = note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end` + = note: required by `std::iter::IntoIterator::into_iter` + +error[E0277]: `u8` is not an iterator + --> $DIR/integral.rs:4:14 + | +LL | for _ in 42 as u8 {} + | ^^^^^^^^ `u8` is not an iterator + | + = help: the trait `std::iter::Iterator` is not implemented for `u8` + = note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end` + = note: required by `std::iter::IntoIterator::into_iter` + +error[E0277]: `i8` is not an iterator + --> $DIR/integral.rs:6:14 + | +LL | for _ in 42 as i8 {} + | ^^^^^^^^ `i8` is not an iterator + | + = help: the trait `std::iter::Iterator` is not implemented for `i8` + = note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end` + = note: required by `std::iter::IntoIterator::into_iter` + +error[E0277]: `u16` is not an iterator + --> $DIR/integral.rs:8:14 + | +LL | for _ in 42 as u16 {} + | ^^^^^^^^^ `u16` is not an iterator + | + = help: the trait `std::iter::Iterator` is not implemented for `u16` + = note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end` + = note: required by `std::iter::IntoIterator::into_iter` + +error[E0277]: `i16` is not an iterator + --> $DIR/integral.rs:10:14 + | +LL | for _ in 42 as i16 {} + | ^^^^^^^^^ `i16` is not an iterator + | + = help: the trait `std::iter::Iterator` is not implemented for `i16` + = note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end` + = note: required by `std::iter::IntoIterator::into_iter` + +error[E0277]: `u32` is not an iterator + --> $DIR/integral.rs:12:14 + | +LL | for _ in 42 as u32 {} + | ^^^^^^^^^ `u32` is not an iterator + | + = help: the trait `std::iter::Iterator` is not implemented for `u32` + = note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end` + = note: required by `std::iter::IntoIterator::into_iter` + +error[E0277]: `i32` is not an iterator + --> $DIR/integral.rs:14:14 + | +LL | for _ in 42 as i32 {} + | ^^^^^^^^^ `i32` is not an iterator + | + = help: the trait `std::iter::Iterator` is not implemented for `i32` + = note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end` + = note: required by `std::iter::IntoIterator::into_iter` + +error[E0277]: `u64` is not an iterator + --> $DIR/integral.rs:16:14 + | +LL | for _ in 42 as u64 {} + | ^^^^^^^^^ `u64` is not an iterator + | + = help: the trait `std::iter::Iterator` is not implemented for `u64` + = note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end` + = note: required by `std::iter::IntoIterator::into_iter` + +error[E0277]: `i64` is not an iterator + --> $DIR/integral.rs:18:14 + | +LL | for _ in 42 as i64 {} + | ^^^^^^^^^ `i64` is not an iterator + | + = help: the trait `std::iter::Iterator` is not implemented for `i64` + = note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end` + = note: required by `std::iter::IntoIterator::into_iter` + +error[E0277]: `usize` is not an iterator + --> $DIR/integral.rs:20:14 + | +LL | for _ in 42 as usize {} + | ^^^^^^^^^^^ `usize` is not an iterator + | + = help: the trait `std::iter::Iterator` is not implemented for `usize` + = note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end` + = note: required by `std::iter::IntoIterator::into_iter` + +error[E0277]: `isize` is not an iterator + --> $DIR/integral.rs:22:14 + | +LL | for _ in 42 as isize {} + | ^^^^^^^^^^^ `isize` is not an iterator + | + = help: the trait `std::iter::Iterator` is not implemented for `isize` + = note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end` + = note: required by `std::iter::IntoIterator::into_iter` + +error[E0277]: `{float}` is not an iterator + --> $DIR/integral.rs:24:14 + | +LL | for _ in 42.0 {} + | ^^^^ `{float}` is not an iterator + | + = help: the trait `std::iter::Iterator` is not implemented for `{float}` + = note: required by `std::iter::IntoIterator::into_iter` + +error: aborting due to 12 previous errors + +For more information about this error, try `rustc --explain E0277`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/ranges.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/ranges.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/ranges.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/ranges.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +fn main() { + for _ in ..10 {} + //~^ ERROR E0277 + for _ in ..=10 {} + //~^ ERROR E0277 + for _ in 0..10 {} + for _ in 0..=10 {} + for _ in 0.. {} +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/ranges.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/ranges.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/ranges.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/ranges.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +error[E0277]: `std::ops::RangeTo<{integer}>` is not an iterator + --> $DIR/ranges.rs:2:14 + | +LL | for _ in ..10 {} + | ^^^^ if you meant to iterate until a value, add a starting value + | + = help: the trait `std::iter::Iterator` is not implemented for `std::ops::RangeTo<{integer}>` + = note: `..end` is a `RangeTo`, which cannot be iterated on; you might have meant to have a bounded `Range`: `0..end` + = note: required by `std::iter::IntoIterator::into_iter` + +error[E0277]: `std::ops::RangeToInclusive<{integer}>` is not an iterator + --> $DIR/ranges.rs:4:14 + | +LL | for _ in ..=10 {} + | ^^^^^ if you meant to iterate until a value (including it), add a starting value + | + = help: the trait `std::iter::Iterator` is not implemented for `std::ops::RangeToInclusive<{integer}>` + = note: `..=end` is a `RangeToInclusive`, which cannot be iterated on; you might have meant to have a bounded `RangeInclusive`: `0..=end` + = note: required by `std::iter::IntoIterator::into_iter` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/string.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/string.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/string.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/string.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,6 @@ +fn main() { + for _ in "".to_owned() {} + //~^ ERROR `std::string::String` is not an iterator + for _ in "" {} + //~^ ERROR `&str` is not an iterator +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/string.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/string.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/iterators/string.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/iterators/string.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +error[E0277]: `std::string::String` is not an iterator + --> $DIR/string.rs:2:14 + | +LL | for _ in "".to_owned() {} + | ^^^^^^^^^^^^^ `std::string::String` is not an iterator; try calling `.chars()` or `.bytes()` + | + = help: the trait `std::iter::Iterator` is not implemented for `std::string::String` + = note: required by `std::iter::IntoIterator::into_iter` + +error[E0277]: `&str` is not an iterator + --> $DIR/string.rs:4:14 + | +LL | for _ in "" {} + | ^^ `&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` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/keyword/keyword-super-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/keyword/keyword-super-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/keyword/keyword-super-as-identifier.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/keyword/keyword-super-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,5 +9,5 @@ // except according to those terms. fn main() { - let super = 22; //~ ERROR failed to resolve. There are too many initial `super`s + let super = 22; //~ ERROR failed to resolve: there are too many initial `super`s } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/keyword/keyword-super-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/keyword/keyword-super-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/keyword/keyword-super-as-identifier.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/keyword/keyword-super-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ -error[E0433]: failed to resolve. There are too many initial `super`s. +error[E0433]: failed to resolve: there are too many initial `super`s. --> $DIR/keyword-super-as-identifier.rs:12:9 | -LL | let super = 22; //~ ERROR failed to resolve. There are too many initial `super`s - | ^^^^^ There are too many initial `super`s. +LL | let super = 22; //~ ERROR failed to resolve: there are too many initial `super`s + | ^^^^^ there are too many initial `super`s. error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/keyword/keyword-super.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/keyword/keyword-super.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/keyword/keyword-super.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/keyword/keyword-super.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,5 +9,5 @@ // except according to those terms. fn main() { - let super: isize; //~ ERROR failed to resolve. There are too many initial `super`s + let super: isize; //~ ERROR failed to resolve: there are too many initial `super`s } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/keyword/keyword-super.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/keyword/keyword-super.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/keyword/keyword-super.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/keyword/keyword-super.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ -error[E0433]: failed to resolve. There are too many initial `super`s. +error[E0433]: failed to resolve: there are too many initial `super`s. --> $DIR/keyword-super.rs:12:9 | -LL | let super: isize; //~ ERROR failed to resolve. There are too many initial `super`s - | ^^^^^ There are too many initial `super`s. +LL | let super: isize; //~ ERROR failed to resolve: there are too many initial `super`s + | ^^^^^ there are too many initial `super`s. error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/kindck/kindck-impl-type-params.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/kindck/kindck-impl-type-params.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/kindck/kindck-impl-type-params.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/kindck/kindck-impl-type-params.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -error[E0277]: `T` cannot be sent between threads safely - --> $DIR/kindck-impl-type-params.rs:28:13 - | -LL | let a = &t as &Gettable; - | ^^ `T` cannot be sent between threads safely - | - = help: the trait `std::marker::Send` is not implemented for `T` - = help: consider adding a `where T: std::marker::Send` bound - = note: required because of the requirements on the impl of `Gettable` for `S` - = note: required for the cast to the object type `dyn Gettable` - -error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:28:13 - | -LL | let a = &t as &Gettable; - | ^^ the trait `std::marker::Copy` is not implemented for `T` - | - = help: consider adding a `where T: std::marker::Copy` bound - = note: required because of the requirements on the impl of `Gettable` for `S` - = note: required for the cast to the object type `dyn Gettable` - -error[E0277]: `T` cannot be sent between threads safely - --> $DIR/kindck-impl-type-params.rs:35:27 - | -LL | let a: &Gettable = &t; - | ^^ `T` cannot be sent between threads safely - | - = help: the trait `std::marker::Send` is not implemented for `T` - = help: consider adding a `where T: std::marker::Send` bound - = note: required because of the requirements on the impl of `Gettable` for `S` - = note: required for the cast to the object type `dyn Gettable` - -error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:35:27 - | -LL | let a: &Gettable = &t; - | ^^ the trait `std::marker::Copy` is not implemented for `T` - | - = help: consider adding a `where T: std::marker::Copy` bound - = note: required because of the requirements on the impl of `Gettable` for `S` - = note: required for the cast to the object type `dyn Gettable` - -error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:48:13 - | -LL | let a = t as Box>; - | ^ the trait `std::marker::Copy` is not implemented for `std::string::String` - | - = note: required because of the requirements on the impl of `Gettable` for `S` - = note: required for the cast to the object type `dyn Gettable` - -error[E0277]: the trait bound `foo3::Foo: std::marker::Copy` is not satisfied - --> $DIR/kindck-impl-type-params.rs:56:33 - | -LL | let a: Box> = t; - | ^ the trait `std::marker::Copy` is not implemented for `foo3::Foo` - | - = note: required because of the requirements on the impl of `Gettable` for `S` - = note: required for the cast to the object type `dyn Gettable` - -error: aborting due to 6 previous errors - -For more information about this error, try `rustc --explain E0277`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/kindck/kindck-send-object1.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/kindck/kindck-send-object1.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/kindck/kindck-send-object1.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/kindck/kindck-send-object1.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -error[E0277]: `(dyn Dummy + 'a)` cannot be shared between threads safely - --> $DIR/kindck-send-object1.rs:20:5 - | -LL | assert_send::<&'a Dummy>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be shared between threads safely - | - = help: the trait `std::marker::Sync` is not implemented for `(dyn Dummy + 'a)` - = note: required because of the requirements on the impl of `std::marker::Send` for `&'a (dyn Dummy + 'a)` -note: required by `assert_send` - --> $DIR/kindck-send-object1.rs:15:1 - | -LL | fn assert_send() { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0277]: `(dyn Dummy + 'a)` cannot be sent between threads safely - --> $DIR/kindck-send-object1.rs:39:5 - | -LL | assert_send::>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be sent between threads safely - | - = help: the trait `std::marker::Send` is not implemented for `(dyn Dummy + 'a)` - = note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<(dyn Dummy + 'a)>` - = note: required because it appears within the type `std::boxed::Box<(dyn Dummy + 'a)>` -note: required by `assert_send` - --> $DIR/kindck-send-object1.rs:15:1 - | -LL | fn assert_send() { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/borrowck-let-suggestion.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/borrowck-let-suggestion.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/borrowck-let-suggestion.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/borrowck-let-suggestion.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,10 +1,10 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/borrowck-let-suggestion.rs:12:17 | LL | let mut x = vec![1].iter(); - | ^^^^^^^ - temporary value only lives until here + | ^^^^^^^ - temporary value is freed at the end of this statement | | - | temporary value does not live long enough + | creates a temporary which is freed while still in use LL | //~^ ERROR borrowed value does not live long enough LL | x.use_mut(); | - borrow later used here @@ -14,4 +14,4 @@ error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -error: borrowed data escapes outside of function - --> $DIR/lifetime-bound-will-change-warning.rs:44:5 - | -LL | fn test2<'a>(x: &'a Box) { - | - `x` is a reference that is only valid in the function body -LL | // but ref_obj will not, so warn. -LL | ref_obj(x) //~ ERROR mismatched types - | ^^^^^^^^^^ `x` escapes the function body here - -error: borrowed data escapes outside of function - --> $DIR/lifetime-bound-will-change-warning.rs:49:5 - | -LL | fn test2cc<'a>(x: &'a Box) { - | - `x` is a reference that is only valid in the function body -LL | // same as test2, but cross crate -LL | lib::ref_obj(x) //~ ERROR mismatched types - | ^^^^^^^^^^^^^^^ `x` escapes the function body here - -error: aborting due to 2 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,9 +14,9 @@ trait Collection { fn len(&self) -> usize; } +// is now well formed. RFC 2093 struct List<'a, T: ListItem<'a>> { slice: &'a [T] - //~^ ERROR may not live long enough } impl<'a, T: ListItem<'a>> Collection for List<'a, T> { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,17 +1,3 @@ -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/lifetime-doesnt-live-long-enough.rs:18:5 - | -LL | struct List<'a, T: ListItem<'a>> { - | -- help: consider adding an explicit lifetime bound `T: 'a`... -LL | slice: &'a [T] - | ^^^^^^^^^^^^^^ - | -note: ...so that the reference type `&'a [T]` does not outlive the data it points at - --> $DIR/lifetime-doesnt-live-long-enough.rs:18:5 - | -LL | slice: &'a [T] - | ^^^^^^^^^^^^^^ - error[E0310]: the parameter type `T` may not live long enough --> $DIR/lifetime-doesnt-live-long-enough.rs:29:5 | @@ -109,7 +95,7 @@ LL | | } | |_____^ -error: aborting due to 7 previous errors +error: aborting due to 6 previous errors Some errors occurred: E0309, E0310. For more information about an error, try `rustc --explain E0309`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,10 +2,9 @@ --> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:12:11 | LL | fn f() -> &isize { //~ ERROR missing lifetime specifier - | ^ expected lifetime parameter + | ^ help: consider giving it a 'static lifetime: `&'static` | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from - = help: consider giving it a 'static lifetime error[E0106]: missing lifetime specifier --> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:17:33 @@ -27,28 +26,25 @@ --> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:31:20 | LL | fn i(_x: isize) -> &isize { //~ ERROR missing lifetime specifier - | ^ expected lifetime parameter + | ^ help: consider giving it an explicit bounded or 'static lifetime: `&'static` | = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments - = help: consider giving it an explicit bounded or 'static lifetime error[E0106]: missing lifetime specifier --> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:44:24 | LL | fn j(_x: StaticStr) -> &isize { //~ ERROR missing lifetime specifier - | ^ expected lifetime parameter + | ^ help: consider giving it an explicit bounded or 'static lifetime: `&'static` | = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments - = help: consider giving it an explicit bounded or 'static lifetime error[E0106]: missing lifetime specifier --> $DIR/lifetime-elision-return-type-requires-explicit-lifetime.rs:50:49 | LL | fn k<'a, T: WithLifetime<'a>>(_x: T::Output) -> &isize { - | ^ expected lifetime parameter + | ^ help: consider giving it an explicit bounded or 'static lifetime: `&'static` | = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments - = help: consider giving it an explicit bounded or 'static lifetime error: aborting due to 6 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-elision-return-type-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +trait Future { + type Item; + type Error; +} + +use std::error::Error; + +fn foo() -> impl Future> { + Ok(()) +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0106]: missing lifetime specifier + --> $DIR/lifetime-elision-return-type-trait.rs:8:44 + | +LL | fn foo() -> impl Future> { + | ^^^^^ help: consider giving it a 'static lifetime: `Error + 'static` + | + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0106`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex1-return-one-existing-name-if-else-using-impl.rs:21:20 - | -LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 { - | -- - let's call the lifetime of this reference `'1` - | | - | lifetime `'a` defined here -LL | -LL | if x > y { x } else { y } //~ ERROR lifetime mismatch - | ^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:18:5 - | -LL | fn foo<'a>(&self, x: &'a i32) -> &i32 { - | -- - let's call the lifetime of this reference `'1` - | | - | lifetime `'a` defined here -LL | -LL | x //~ ERROR lifetime mismatch - | ^ function was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-self-is-anon.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex1-return-one-existing-name-self-is-anon.rs:18:30 - | -LL | fn foo<'a>(&self, x: &'a Foo) -> &'a Foo { - | -- - let's call the lifetime of this reference `'1` - | | - | lifetime `'a` defined here -LL | -LL | if true { x } else { self } //~ ERROR lifetime mismatch - | ^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error[E0621]: explicit lifetime required in the type of `x` - --> $DIR/ex2a-push-one-existing-name-2.rs:16:5 - | -LL | fn foo<'a>(x: Ref, y: &mut Vec>) { - | -------- help: add explicit lifetime `'a` to the type of `x`: `Ref<'a, i32>` -LL | y.push(x); //~ ERROR explicit lifetime - | ^^^^^^^^^ lifetime `'a` required - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0621`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error[E0621]: explicit lifetime required in the type of `y` - --> $DIR/ex2a-push-one-existing-name-early-bound.rs:17:5 - | -LL | fn baz<'a, 'b, T>(x: &mut Vec<&'a T>, y: &T) - | -- help: add explicit lifetime `'a` to the type of `y`: `&'a T` -... -LL | x.push(y); //~ ERROR explicit lifetime required - | ^^^^^^^^^ lifetime `'a` required - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0621`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error[E0621]: explicit lifetime required in the type of `y` - --> $DIR/ex2a-push-one-existing-name.rs:16:5 - | -LL | fn foo<'a>(x: &mut Vec>, y: Ref) { - | -------- help: add explicit lifetime `'a` to the type of `y`: `Ref<'a, i32>` -LL | x.push(y); //~ ERROR explicit lifetime - | ^^^^^^^^^ lifetime `'a` required - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0621`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2b-push-no-existing-names.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex2b-push-no-existing-names.rs:16:5 - | -LL | fn foo(x: &mut Vec>, y: Ref) { - | - - has type `Ref<'1, i32>` - | | - | has type `&mut std::vec::Vec>` -LL | x.push(y); //~ ERROR lifetime mismatch - | ^^^^^^^^^ argument requires that `'1` must outlive `'2` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2c-push-inference-variable.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex2c-push-inference-variable.rs:17:5 - | -LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec>, y: Ref<'c, i32>) { - | -- -- lifetime `'c` defined here - | | - | lifetime `'b` defined here -LL | let z = Ref { data: y.data }; -LL | x.push(z); //~ ERROR lifetime mismatch - | ^^^^^^^^^ argument requires that `'c` must outlive `'b` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2d-push-inference-variable-2.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex2d-push-inference-variable-2.rs:18:5 - | -LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec>, y: Ref<'c, i32>) { - | -- -- lifetime `'c` defined here - | | - | lifetime `'b` defined here -... -LL | a.push(b); - | ^^^^^^^^^ argument requires that `'c` must outlive `'b` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex2e-push-inference-variable-3.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex2e-push-inference-variable-3.rs:18:5 - | -LL | fn foo<'a, 'b, 'c>(x: &'a mut Vec>, y: Ref<'c, i32>) { - | -- -- lifetime `'c` defined here - | | - | lifetime `'b` defined here -... -LL | Vec::push(a, b); - | ^^^^^^^^^^^^^^^ argument requires that `'c` must outlive `'b` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex3-both-anon-regions-2.rs:12:5 - | -LL | fn foo(&mut (ref mut v, w): &mut (&u8, &u8), x: &u8) { - | - - let's call the lifetime of this reference `'1` - | | - | let's call the lifetime of this reference `'2` -LL | *v = x; //~ ERROR lifetime mismatch - | ^^^^^^ requires that `'1` must outlive `'2` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-3.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex3-both-anon-regions-3.rs:12:5 - | -LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) { - | - - let's call the lifetime of this reference `'1` - | | - | let's call the lifetime of this reference `'2` -LL | z.push((x,y)); //~ ERROR lifetime mismatch - | ^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` - -error: unsatisfied lifetime constraints - --> $DIR/ex3-both-anon-regions-3.rs:12:5 - | -LL | fn foo(z: &mut Vec<(&u8,&u8)>, (x, y): (&u8, &u8)) { - | - - let's call the lifetime of this reference `'1` - | | - | let's call the lifetime of this reference `'2` -LL | z.push((x,y)); //~ ERROR lifetime mismatch - | ^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` - -error: aborting due to 2 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-2.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex3-both-anon-regions-both-are-structs-2.rs:16:5 - | -LL | fn foo(mut x: Ref, y: Ref) { - | ----- - has type `Ref<'_, '1>` - | | - | has type `Ref<'_, '2>` -LL | x.b = y.b; //~ ERROR lifetime mismatch - | ^^^^^^^^^ requires that `'1` must outlive `'2` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex3-both-anon-regions-both-are-structs-3.rs:16:5 - | -LL | fn foo(mut x: Ref) { - | ----- - | | - | has type `Ref<'_, '1>` - | has type `Ref<'2, '_>` -LL | x.a = x.b; //~ ERROR lifetime mismatch - | ^^^^^^^^^ requires that `'1` must outlive `'2` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex3-both-anon-regions-both-are-structs-4.rs:16:5 - | -LL | fn foo(mut x: Ref) { - | ----- - | | - | has type `Ref<'_, '1>` - | has type `Ref<'2, '_>` -LL | x.a = x.b; //~ ERROR lifetime mismatch - | ^^^^^^^^^ requires that `'1` must outlive `'2` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -struct Ref<'a, 'b> { - a: &'a u32, - b: &'b u32, -} - -fn foo(mut x: Ref) { - x.a = x.b; //~ ERROR lifetime mismatch -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-4.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -error[E0623]: lifetime mismatch - --> $DIR/ex3-both-anon-regions-both-are-structs-4.rs:16:11 - | -LL | fn foo(mut x: Ref) { - | --- - | | - | this type is declared with multiple lifetimes... -LL | x.a = x.b; //~ ERROR lifetime mismatch - | ^^^ ...but data with one lifetime flows into the other here - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0623`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-earlybound-regions.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex3-both-anon-regions-both-are-structs-earlybound-regions.rs:18:5 - | -LL | fn foo<'a, 'b>(mut x: Vec>, y: Ref<'b>) - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -... -LL | x.push(y); //~ ERROR lifetime mismatch - | ^^^^^^^^^ argument requires that `'b` must outlive `'a` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-latebound-regions.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex3-both-anon-regions-both-are-structs-latebound-regions.rs:15:5 - | -LL | fn foo<'a, 'b>(mut x: Vec>, y: Ref<'b>) { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | x.push(y); //~ ERROR lifetime mismatch - | ^^^^^^^^^ argument requires that `'b` must outlive `'a` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex3-both-anon-regions-both-are-structs.rs:15:5 - | -LL | fn foo(mut x: Vec, y: Ref) { - | ----- - has type `Ref<'1>` - | | - | has type `std::vec::Vec>` -LL | x.push(y); //~ ERROR lifetime mismatch - | ^^^^^^^^^ argument requires that `'1` must outlive `'2` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-latebound-regions.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex3-both-anon-regions-latebound-regions.rs:12:5 - | -LL | fn foo<'a,'b>(x: &mut Vec<&'a u8>, y: &'b u8) { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | x.push(y); //~ ERROR lifetime mismatch - | ^^^^^^^^^ argument requires that `'b` must outlive `'a` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex3-both-anon-regions.rs:12:5 - | -LL | fn foo(x: &mut Vec<&u8>, y: &u8) { - | - - let's call the lifetime of this reference `'1` - | | - | let's call the lifetime of this reference `'2` -LL | x.push(y); //~ ERROR lifetime mismatch - | ^^^^^^^^^ argument requires that `'1` must outlive `'2` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-2.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:14:5 - | -LL | fn foo(mut x: Ref, y: &u32) { - | ----- - let's call the lifetime of this reference `'2` - | | - | has type `Ref<'_, '1>` -LL | y = x.b; //~ ERROR lifetime mismatch - | ^^^^^^^ requires that `'1` must outlive `'2` - -error[E0384]: cannot assign to immutable argument `y` - --> $DIR/ex3-both-anon-regions-one-is-struct-2.rs:14:5 - | -LL | fn foo(mut x: Ref, y: &u32) { - | - help: make this binding mutable: `mut y` -LL | y = x.b; //~ ERROR lifetime mismatch - | ^^^^^^^ cannot assign to immutable argument - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0384`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-3.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex3-both-anon-regions-one-is-struct-3.rs:14:5 - | -LL | fn foo(mut y: Ref, x: &u32) { - | ----- - let's call the lifetime of this reference `'1` - | | - | has type `Ref<'_, '2>` -LL | y.b = x; //~ ERROR lifetime mismatch - | ^^^^^^^ requires that `'1` must outlive `'2` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct-4.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex3-both-anon-regions-one-is-struct-4.rs:14:5 - | -LL | fn foo(mut y: Ref, x: &u32) { - | ----- - let's call the lifetime of this reference `'1` - | | - | has type `Ref<'_, '2>` -LL | y.b = x; //~ ERROR lifetime mismatch - | ^^^^^^^ requires that `'1` must outlive `'2` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-one-is-struct.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex3-both-anon-regions-one-is-struct.rs:17:5 - | -LL | fn foo(mut x: Ref, y: &u32) { - | ----- - let's call the lifetime of this reference `'1` - | | - | has type `Ref<'_, '2>` -LL | x.b = y; //~ ERROR lifetime mismatch - | ^^^^^^^ requires that `'1` must outlive `'2` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-return-type-is-anon.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:17:5 - | -LL | fn foo<'a>(&self, x: &i32) -> &i32 { - | - - let's call the lifetime of this reference `'1` - | | - | let's call the lifetime of this reference `'2` -LL | x //~ ERROR lifetime mismatch - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-self-is-anon.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex3-both-anon-regions-self-is-anon.rs:17:19 - | -LL | fn foo<'a>(&self, x: &Foo) -> &Foo { - | - - let's call the lifetime of this reference `'1` - | | - | let's call the lifetime of this reference `'2` -LL | if true { x } else { self } //~ ERROR lifetime mismatch - | ^ function was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-fn-items.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable - --> $DIR/ex3-both-anon-regions-using-fn-items.rs:11:3 - | -LL | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) { - | - help: consider changing this to be mutable: `mut y` -LL | y.push(z); //~ ERROR lifetime mismatch - | ^ cannot borrow as mutable - -error: unsatisfied lifetime constraints - --> $DIR/ex3-both-anon-regions-using-fn-items.rs:11:3 - | -LL | fn foo(x:fn(&u8, &u8), y: Vec<&u8>, z: &u8) { - | - - let's call the lifetime of this reference `'1` - | | - | let's call the lifetime of this reference `'2` -LL | y.push(z); //~ ERROR lifetime mismatch - | ^^^^^^^^^ argument requires that `'1` must outlive `'2` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0596`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-impl-items.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/ex3-both-anon-regions-using-impl-items.rs:15:9 - | -LL | fn foo(x: &mut Vec<&u8>, y: &u8) { - | - - let's call the lifetime of this reference `'1` - | | - | let's call the lifetime of this reference `'2` -LL | x.push(y); //~ ERROR lifetime mismatch - | ^^^^^^^^^ argument requires that `'1` must outlive `'2` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-using-trait-objects.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -error[E0596]: cannot borrow `y` as mutable, as it is not declared as mutable - --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:11:3 - | -LL | fn foo(x:Box , y: Vec<&u8>, z: &u8) { - | - help: consider changing this to be mutable: `mut y` -LL | y.push(z); //~ ERROR lifetime mismatch - | ^ cannot borrow as mutable - -error: unsatisfied lifetime constraints - --> $DIR/ex3-both-anon-regions-using-trait-objects.rs:11:3 - | -LL | fn foo(x:Box , y: Vec<&u8>, z: &u8) { - | - - let's call the lifetime of this reference `'1` - | | - | let's call the lifetime of this reference `'2` -LL | y.push(z); //~ ERROR lifetime mismatch - | ^^^^^^^^^ argument requires that `'1` must outlive `'2` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0596`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/inclusive-range-pattern-syntax.fixed rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/inclusive-range-pattern-syntax.fixed --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/inclusive-range-pattern-syntax.fixed 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/inclusive-range-pattern-syntax.fixed 2018-12-04 23:41:40.000000000 +0000 @@ -20,4 +20,10 @@ //~^ WARN `...` range patterns are deprecated _ => {} } + + match &despondency { + &(1..=2) => {} + //~^ WARN `...` range patterns are deprecated + _ => {} + } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/inclusive-range-pattern-syntax.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/inclusive-range-pattern-syntax.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/inclusive-range-pattern-syntax.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/inclusive-range-pattern-syntax.rs 2018-12-04 23:41:40.000000000 +0000 @@ -20,4 +20,10 @@ //~^ WARN `...` range patterns are deprecated _ => {} } + + match &despondency { + &1...2 => {} + //~^ WARN `...` range patterns are deprecated + _ => {} + } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/inclusive-range-pattern-syntax.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/inclusive-range-pattern-syntax.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/inclusive-range-pattern-syntax.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/inclusive-range-pattern-syntax.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -10,3 +10,9 @@ LL | #![warn(ellipsis_inclusive_range_patterns)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +warning: `...` range patterns are deprecated + --> $DIR/inclusive-range-pattern-syntax.rs:25:9 + | +LL | &1...2 => {} + | ^^^^^^ help: use `..=` for an inclusive range: `&(1..=2)` + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/issue-54099-camel-case-underscore-types.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/issue-54099-camel-case-underscore-types.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/issue-54099-camel-case-underscore-types.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/issue-54099-camel-case-underscore-types.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// compile-pass + +#![forbid(non_camel_case_types)] +#![allow(dead_code)] + +// None of the following types should generate a warning +struct _X {} +struct __X {} +struct __ {} +struct X_ {} +struct X__ {} +struct X___ {} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/issue-54538-unused-parens-lint.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/issue-54538-unused-parens-lint.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/issue-54538-unused-parens-lint.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/issue-54538-unused-parens-lint.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass + +#![allow(unreachable_patterns)] +#![allow(unused_variables)] +#![warn(unused_parens)] + +fn main() { + match 1 { + (_) => {} //~ WARNING: unnecessary parentheses around pattern + (y) => {} //~ WARNING: unnecessary parentheses around pattern + (ref r) => {} //~ WARNING: unnecessary parentheses around pattern + (e @ 1..=2) => {} //~ WARNING: unnecessary parentheses around outer pattern + (1..=2) => {} // Non ambiguous range pattern should not warn + e @ (3..=4) => {} // Non ambiguous range pattern should not warn + } + + match &1 { + (e @ &(1...2)) => {} //~ WARNING: unnecessary parentheses around outer pattern + &(_) => {} //~ WARNING: unnecessary parentheses around pattern + e @ &(1...2) => {} // Ambiguous range pattern should not warn + &(1..=2) => {} // Ambiguous range pattern should not warn + } + + match &1 { + e @ &(1...2) | e @ &(3..=4) => {} // Complex ambiguous pattern should not warn + &_ => {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/issue-54538-unused-parens-lint.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/issue-54538-unused-parens-lint.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/issue-54538-unused-parens-lint.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/issue-54538-unused-parens-lint.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +warning: unnecessary parentheses around pattern + --> $DIR/issue-54538-unused-parens-lint.rs:19:9 + | +LL | (_) => {} //~ WARNING: unnecessary parentheses around pattern + | ^^^ help: remove these parentheses + | +note: lint level defined here + --> $DIR/issue-54538-unused-parens-lint.rs:15:9 + | +LL | #![warn(unused_parens)] + | ^^^^^^^^^^^^^ + +warning: unnecessary parentheses around pattern + --> $DIR/issue-54538-unused-parens-lint.rs:20:9 + | +LL | (y) => {} //~ WARNING: unnecessary parentheses around pattern + | ^^^ help: remove these parentheses + +warning: unnecessary parentheses around pattern + --> $DIR/issue-54538-unused-parens-lint.rs:21:9 + | +LL | (ref r) => {} //~ WARNING: unnecessary parentheses around pattern + | ^^^^^^^ help: remove these parentheses + +warning: unnecessary parentheses around pattern + --> $DIR/issue-54538-unused-parens-lint.rs:22:9 + | +LL | (e @ 1..=2) => {} //~ WARNING: unnecessary parentheses around outer pattern + | ^^^^^^^^^^^ help: remove these parentheses + +warning: unnecessary parentheses around pattern + --> $DIR/issue-54538-unused-parens-lint.rs:28:9 + | +LL | (e @ &(1...2)) => {} //~ WARNING: unnecessary parentheses around outer pattern + | ^^^^^^^^^^^^^^ help: remove these parentheses + +warning: unnecessary parentheses around pattern + --> $DIR/issue-54538-unused-parens-lint.rs:29:10 + | +LL | &(_) => {} //~ WARNING: unnecessary parentheses around pattern + | ^^^ help: remove these parentheses + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/lint-ctypes.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/lint-ctypes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/lint-ctypes.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/lint-ctypes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,6 +11,8 @@ #![deny(improper_ctypes)] #![feature(libc)] +#![allow(private_in_public)] + extern crate libc; use std::marker::PhantomData; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/lint-ctypes.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/lint-ctypes.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/lint-ctypes.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/lint-ctypes.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error: `extern` block uses type `Foo` which is not FFI-safe: this struct has unspecified layout - --> $DIR/lint-ctypes.rs:54:28 + --> $DIR/lint-ctypes.rs:56:28 | LL | pub fn ptr_type1(size: *const Foo); //~ ERROR: uses type `Foo` | ^^^^^^^^^^ @@ -11,26 +11,26 @@ | ^^^^^^^^^^^^^^^ = help: consider adding a #[repr(C)] or #[repr(transparent)] attribute to this struct note: type defined here - --> $DIR/lint-ctypes.rs:32:1 + --> $DIR/lint-ctypes.rs:34:1 | LL | pub struct Foo; | ^^^^^^^^^^^^^^^ error: `extern` block uses type `Foo` which is not FFI-safe: this struct has unspecified layout - --> $DIR/lint-ctypes.rs:55:28 + --> $DIR/lint-ctypes.rs:57:28 | LL | pub fn ptr_type2(size: *const Foo); //~ ERROR: uses type `Foo` | ^^^^^^^^^^ | = help: consider adding a #[repr(C)] or #[repr(transparent)] attribute to this struct note: type defined here - --> $DIR/lint-ctypes.rs:32:1 + --> $DIR/lint-ctypes.rs:34:1 | LL | pub struct Foo; | ^^^^^^^^^^^^^^^ error: `extern` block uses type `[u32]` which is not FFI-safe: slices have no C equivalent - --> $DIR/lint-ctypes.rs:56:26 + --> $DIR/lint-ctypes.rs:58:26 | LL | pub fn slice_type(p: &[u32]); //~ ERROR: uses type `[u32]` | ^^^^^^ @@ -38,7 +38,7 @@ = help: consider using a raw pointer instead error: `extern` block uses type `str` which is not FFI-safe: string slices have no C equivalent - --> $DIR/lint-ctypes.rs:57:24 + --> $DIR/lint-ctypes.rs:59:24 | LL | pub fn str_type(p: &str); //~ ERROR: uses type `str` | ^^^^ @@ -46,7 +46,7 @@ = help: consider using `*const u8` and a length instead error: `extern` block uses type `std::boxed::Box` which is not FFI-safe: this struct has unspecified layout - --> $DIR/lint-ctypes.rs:58:24 + --> $DIR/lint-ctypes.rs:60:24 | LL | pub fn box_type(p: Box); //~ ERROR uses type `std::boxed::Box` | ^^^^^^^^ @@ -54,7 +54,7 @@ = help: consider adding a #[repr(C)] or #[repr(transparent)] attribute to this struct error: `extern` block uses type `char` which is not FFI-safe: the `char` type has no C equivalent - --> $DIR/lint-ctypes.rs:59:25 + --> $DIR/lint-ctypes.rs:61:25 | LL | pub fn char_type(p: char); //~ ERROR uses type `char` | ^^^^ @@ -62,25 +62,25 @@ = help: consider using `u32` or `libc::wchar_t` instead error: `extern` block uses type `i128` which is not FFI-safe: 128-bit integers don't currently have a known stable ABI - --> $DIR/lint-ctypes.rs:60:25 + --> $DIR/lint-ctypes.rs:62:25 | LL | pub fn i128_type(p: i128); //~ ERROR uses type `i128` | ^^^^ error: `extern` block uses type `u128` which is not FFI-safe: 128-bit integers don't currently have a known stable ABI - --> $DIR/lint-ctypes.rs:61:25 + --> $DIR/lint-ctypes.rs:63:25 | LL | pub fn u128_type(p: u128); //~ ERROR uses type `u128` | ^^^^ error: `extern` block uses type `dyn std::clone::Clone` which is not FFI-safe: trait objects have no C equivalent - --> $DIR/lint-ctypes.rs:62:26 + --> $DIR/lint-ctypes.rs:64:26 | LL | pub fn trait_type(p: &Clone); //~ ERROR uses type `dyn std::clone::Clone` | ^^^^^^ error: `extern` block uses type `(i32, i32)` which is not FFI-safe: tuples have unspecified layout - --> $DIR/lint-ctypes.rs:63:26 + --> $DIR/lint-ctypes.rs:65:26 | LL | pub fn tuple_type(p: (i32, i32)); //~ ERROR uses type `(i32, i32)` | ^^^^^^^^^^ @@ -88,7 +88,7 @@ = help: consider using a struct instead error: `extern` block uses type `(i32, i32)` which is not FFI-safe: tuples have unspecified layout - --> $DIR/lint-ctypes.rs:64:27 + --> $DIR/lint-ctypes.rs:66:27 | LL | pub fn tuple_type2(p: I32Pair); //~ ERROR uses type `(i32, i32)` | ^^^^^^^ @@ -96,32 +96,32 @@ = help: consider using a struct instead error: `extern` block uses type `ZeroSize` which is not FFI-safe: this struct has no fields - --> $DIR/lint-ctypes.rs:65:25 + --> $DIR/lint-ctypes.rs:67:25 | LL | pub fn zero_size(p: ZeroSize); //~ ERROR struct has no fields | ^^^^^^^^ | = help: consider adding a member to this struct note: type defined here - --> $DIR/lint-ctypes.rs:28:1 + --> $DIR/lint-ctypes.rs:30:1 | LL | pub struct ZeroSize; | ^^^^^^^^^^^^^^^^^^^^ error: `extern` block uses type `ZeroSizeWithPhantomData` which is not FFI-safe: composed only of PhantomData - --> $DIR/lint-ctypes.rs:66:33 + --> $DIR/lint-ctypes.rs:68:33 | LL | pub fn zero_size_phantom(p: ZeroSizeWithPhantomData); //~ ERROR composed only of PhantomData | ^^^^^^^^^^^^^^^^^^^^^^^ error: `extern` block uses type `std::marker::PhantomData` which is not FFI-safe: composed only of PhantomData - --> $DIR/lint-ctypes.rs:68:12 + --> $DIR/lint-ctypes.rs:70:12 | LL | -> ::std::marker::PhantomData; //~ ERROR: composed only of PhantomData | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `extern` block uses type `fn()` which is not FFI-safe: this function pointer has Rust-specific calling convention - --> $DIR/lint-ctypes.rs:69:23 + --> $DIR/lint-ctypes.rs:71:23 | LL | pub fn fn_type(p: RustFn); //~ ERROR function pointer has Rust-specific | ^^^^^^ @@ -129,7 +129,7 @@ = help: consider using an `extern fn(...) -> ...` function pointer instead error: `extern` block uses type `fn()` which is not FFI-safe: this function pointer has Rust-specific calling convention - --> $DIR/lint-ctypes.rs:70:24 + --> $DIR/lint-ctypes.rs:72:24 | LL | pub fn fn_type2(p: fn()); //~ ERROR function pointer has Rust-specific | ^^^^ @@ -137,7 +137,7 @@ = help: consider using an `extern fn(...) -> ...` function pointer instead error: `extern` block uses type `std::boxed::Box` which is not FFI-safe: this struct has unspecified layout - --> $DIR/lint-ctypes.rs:71:28 + --> $DIR/lint-ctypes.rs:73:28 | LL | pub fn fn_contained(p: RustBadRet); //~ ERROR: uses type `std::boxed::Box` | ^^^^^^^^^^ @@ -145,13 +145,13 @@ = help: consider adding a #[repr(C)] or #[repr(transparent)] attribute to this struct error: `extern` block uses type `i128` which is not FFI-safe: 128-bit integers don't currently have a known stable ABI - --> $DIR/lint-ctypes.rs:72:32 + --> $DIR/lint-ctypes.rs:74:32 | LL | pub fn transparent_i128(p: TransparentI128); //~ ERROR: uses type `i128` | ^^^^^^^^^^^^^^^ error: `extern` block uses type `str` which is not FFI-safe: string slices have no C equivalent - --> $DIR/lint-ctypes.rs:73:31 + --> $DIR/lint-ctypes.rs:75:31 | LL | pub fn transparent_str(p: TransparentStr); //~ ERROR: uses type `str` | ^^^^^^^^^^^^^^ @@ -159,7 +159,7 @@ = help: consider using `*const u8` and a length instead error: `extern` block uses type `std::boxed::Box` which is not FFI-safe: this struct has unspecified layout - --> $DIR/lint-ctypes.rs:74:30 + --> $DIR/lint-ctypes.rs:76:30 | LL | pub fn transparent_fn(p: TransparentBadFn); //~ ERROR: uses type `std::boxed::Box` | ^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/lint-group-style.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/lint-group-style.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/lint-group-style.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/lint-group-style.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2014–2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(nonstandard_style)] -#![allow(dead_code)] - -fn CamelCase() {} //~ ERROR should have a snake - -#[allow(nonstandard_style)] -mod test { - fn CamelCase() {} - - #[forbid(nonstandard_style)] - mod bad { - fn CamelCase() {} //~ ERROR should have a snake - - static bad: isize = 1; //~ ERROR should have an upper - } - - mod warn { - #![warn(nonstandard_style)] - - fn CamelCase() {} //~ WARN should have a snake - - struct snake_case; //~ WARN should have a camel - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/lint-group-style.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/lint-group-style.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/lint-group-style.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/lint-group-style.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -error: function `CamelCase` should have a snake case name such as `camel_case` - --> $DIR/lint-group-style.rs:14:1 - | -LL | fn CamelCase() {} //~ ERROR should have a snake - | ^^^^^^^^^^^^^^^^^ - | -note: lint level defined here - --> $DIR/lint-group-style.rs:11:9 - | -LL | #![deny(nonstandard_style)] - | ^^^^^^^^^^^^^^^^^ - = note: #[deny(non_snake_case)] implied by #[deny(nonstandard_style)] - -error: function `CamelCase` should have a snake case name such as `camel_case` - --> $DIR/lint-group-style.rs:22:9 - | -LL | fn CamelCase() {} //~ ERROR should have a snake - | ^^^^^^^^^^^^^^^^^ - | -note: lint level defined here - --> $DIR/lint-group-style.rs:20:14 - | -LL | #[forbid(nonstandard_style)] - | ^^^^^^^^^^^^^^^^^ - = note: #[forbid(non_snake_case)] implied by #[forbid(nonstandard_style)] - -error: static variable `bad` should have an upper case name such as `BAD` - --> $DIR/lint-group-style.rs:24:9 - | -LL | static bad: isize = 1; //~ ERROR should have an upper - | ^^^^^^^^^^^^^^^^^^^^^^ - | -note: lint level defined here - --> $DIR/lint-group-style.rs:20:14 - | -LL | #[forbid(nonstandard_style)] - | ^^^^^^^^^^^^^^^^^ - = note: #[forbid(non_upper_case_globals)] implied by #[forbid(nonstandard_style)] - -warning: function `CamelCase` should have a snake case name such as `camel_case` - --> $DIR/lint-group-style.rs:30:9 - | -LL | fn CamelCase() {} //~ WARN should have a snake - | ^^^^^^^^^^^^^^^^^ - | -note: lint level defined here - --> $DIR/lint-group-style.rs:28:17 - | -LL | #![warn(nonstandard_style)] - | ^^^^^^^^^^^^^^^^^ - = note: #[warn(non_snake_case)] implied by #[warn(nonstandard_style)] - -warning: type `snake_case` should have a camel case name such as `SnakeCase` - --> $DIR/lint-group-style.rs:32:9 - | -LL | struct snake_case; //~ WARN should have a camel - | ^^^^^^^^^^^^^^^^^^ - | -note: lint level defined here - --> $DIR/lint-group-style.rs:28:17 - | -LL | #![warn(nonstandard_style)] - | ^^^^^^^^^^^^^^^^^ - = note: #[warn(non_camel_case_types)] implied by #[warn(nonstandard_style)] - -error: aborting due to 3 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/lint-non-camel-case-types.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/lint-non-camel-case-types.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/lint-non-camel-case-types.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/lint-non-camel-case-types.rs 2018-12-04 23:41:40.000000000 +0000 @@ -43,8 +43,6 @@ bar: isize, } -type __ = isize; //~ ERROR type `__` should have a camel case name such as `CamelCase` - struct X86_64; struct X86__64; //~ ERROR type `X86__64` should have a camel case name such as `X86_64` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/lint-non-camel-case-types.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/lint-non-camel-case-types.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/lint-non-camel-case-types.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/lint-non-camel-case-types.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -60,29 +60,23 @@ LL | fn f(_: ty) {} //~ ERROR type parameter `ty` should have a camel case name such as `Ty` | ^^ -error: type `__` should have a camel case name such as `CamelCase` - --> $DIR/lint-non-camel-case-types.rs:46:1 - | -LL | type __ = isize; //~ ERROR type `__` should have a camel case name such as `CamelCase` - | ^^^^^^^^^^^^^^^^ - error: type `X86__64` should have a camel case name such as `X86_64` - --> $DIR/lint-non-camel-case-types.rs:50:1 + --> $DIR/lint-non-camel-case-types.rs:48:1 | LL | struct X86__64; //~ ERROR type `X86__64` should have a camel case name such as `X86_64` | ^^^^^^^^^^^^^^^ error: type `Abc_123` should have a camel case name such as `Abc123` - --> $DIR/lint-non-camel-case-types.rs:52:1 + --> $DIR/lint-non-camel-case-types.rs:50:1 | LL | struct Abc_123; //~ ERROR type `Abc_123` should have a camel case name such as `Abc123` | ^^^^^^^^^^^^^^^ error: type `A1_b2_c3` should have a camel case name such as `A1B2C3` - --> $DIR/lint-non-camel-case-types.rs:54:1 + --> $DIR/lint-non-camel-case-types.rs:52:1 | LL | struct A1_b2_c3; //~ ERROR type `A1_b2_c3` should have a camel case name such as `A1B2C3` | ^^^^^^^^^^^^^^^^ -error: aborting due to 12 previous errors +error: aborting due to 11 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/lint-unexported-no-mangle.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/lint-unexported-no-mangle.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/lint-unexported-no-mangle.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/lint-unexported-no-mangle.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ // compile-flags:-F private_no_mangle_fns -F no_mangle_const_items -F private_no_mangle_statics #[no_mangle] -fn foo() { //~ ERROR function is marked #[no_mangle], but not exported +fn foo() { } #[allow(dead_code)] @@ -30,7 +30,7 @@ #[allow(dead_code)] #[no_mangle] -static PRIVATE_BAR: u64 = 1; //~ ERROR static is marked #[no_mangle], but not exported +static PRIVATE_BAR: u64 = 1; fn main() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/lint-unexported-no-mangle.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/lint-unexported-no-mangle.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/lint-unexported-no-mangle.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/lint-unexported-no-mangle.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,15 +1,10 @@ -error: function is marked #[no_mangle], but not exported - --> $DIR/lint-unexported-no-mangle.rs:14:1 +warning: lint `private_no_mangle_fns` has been removed: `no longer an warning, #[no_mangle] functions always exported` | -LL | fn foo() { //~ ERROR function is marked #[no_mangle], but not exported - | ^ - | | - | _help: try making it public: `pub` - | | -LL | | } - | |_^ + = note: requested on the command line with `-F private_no_mangle_fns` + +warning: lint `private_no_mangle_statics` has been removed: `no longer an warning, #[no_mangle] statics always exported` | - = note: requested on the command line with `-F private-no-mangle-fns` + = note: requested on the command line with `-F private_no_mangle_statics` error: const items should never be #[no_mangle] --> $DIR/lint-unexported-no-mangle.rs:19:1 @@ -29,15 +24,5 @@ | | | help: try a static value: `pub static` -error: static is marked #[no_mangle], but not exported - --> $DIR/lint-unexported-no-mangle.rs:33:1 - | -LL | static PRIVATE_BAR: u64 = 1; //~ ERROR static is marked #[no_mangle], but not exported - | -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | help: try making it public: `pub` - | - = note: requested on the command line with `-F private-no-mangle-statics` - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/must-use-ops.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/must-use-ops.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/must-use-ops.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/must-use-ops.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ -warning: unused comparison which must be used +warning: unused comparison that must be used --> $DIR/must-use-ops.rs:22:5 | LL | val == 1; @@ -10,121 +10,121 @@ LL | #![warn(unused_must_use)] | ^^^^^^^^^^^^^^^ -warning: unused comparison which must be used +warning: unused comparison that must be used --> $DIR/must-use-ops.rs:23:5 | LL | val < 1; | ^^^^^^^ -warning: unused comparison which must be used +warning: unused comparison that must be used --> $DIR/must-use-ops.rs:24:5 | LL | val <= 1; | ^^^^^^^^ -warning: unused comparison which must be used +warning: unused comparison that must be used --> $DIR/must-use-ops.rs:25:5 | LL | val != 1; | ^^^^^^^^ -warning: unused comparison which must be used +warning: unused comparison that must be used --> $DIR/must-use-ops.rs:26:5 | LL | val >= 1; | ^^^^^^^^ -warning: unused comparison which must be used +warning: unused comparison that must be used --> $DIR/must-use-ops.rs:27:5 | LL | val > 1; | ^^^^^^^ -warning: unused arithmetic operation which must be used +warning: unused arithmetic operation that must be used --> $DIR/must-use-ops.rs:30:5 | LL | val + 2; | ^^^^^^^ -warning: unused arithmetic operation which must be used +warning: unused arithmetic operation that must be used --> $DIR/must-use-ops.rs:31:5 | LL | val - 2; | ^^^^^^^ -warning: unused arithmetic operation which must be used +warning: unused arithmetic operation that must be used --> $DIR/must-use-ops.rs:32:5 | LL | val / 2; | ^^^^^^^ -warning: unused arithmetic operation which must be used +warning: unused arithmetic operation that must be used --> $DIR/must-use-ops.rs:33:5 | LL | val * 2; | ^^^^^^^ -warning: unused arithmetic operation which must be used +warning: unused arithmetic operation that must be used --> $DIR/must-use-ops.rs:34:5 | LL | val % 2; | ^^^^^^^ -warning: unused logical operation which must be used +warning: unused logical operation that must be used --> $DIR/must-use-ops.rs:37:5 | LL | true && true; | ^^^^^^^^^^^^ -warning: unused logical operation which must be used +warning: unused logical operation that must be used --> $DIR/must-use-ops.rs:38:5 | LL | false || true; | ^^^^^^^^^^^^^ -warning: unused bitwise operation which must be used +warning: unused bitwise operation that must be used --> $DIR/must-use-ops.rs:41:5 | LL | 5 ^ val; | ^^^^^^^ -warning: unused bitwise operation which must be used +warning: unused bitwise operation that must be used --> $DIR/must-use-ops.rs:42:5 | LL | 5 & val; | ^^^^^^^ -warning: unused bitwise operation which must be used +warning: unused bitwise operation that must be used --> $DIR/must-use-ops.rs:43:5 | LL | 5 | val; | ^^^^^^^ -warning: unused bitwise operation which must be used +warning: unused bitwise operation that must be used --> $DIR/must-use-ops.rs:44:5 | LL | 5 << val; | ^^^^^^^^ -warning: unused bitwise operation which must be used +warning: unused bitwise operation that must be used --> $DIR/must-use-ops.rs:45:5 | LL | 5 >> val; | ^^^^^^^^ -warning: unused unary operation which must be used +warning: unused unary operation that must be used --> $DIR/must-use-ops.rs:48:5 | LL | !val; | ^^^^ -warning: unused unary operation which must be used +warning: unused unary operation that must be used --> $DIR/must-use-ops.rs:49:5 | LL | -val; | ^^^^ -warning: unused unary operation which must be used +warning: unused unary operation that must be used --> $DIR/must-use-ops.rs:50:5 | LL | *val_pointer; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/must_use-unit.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/must_use-unit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/must_use-unit.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/must_use-unit.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +#![feature(never_type)] + +#![deny(unused_must_use)] + +#[must_use] +fn foo() {} + +#[must_use] +fn bar() -> ! { + unimplemented!() +} + +fn main() { + foo(); //~ unused return value of `foo` + + bar(); //~ unused return value of `bar` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/must_use-unit.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/must_use-unit.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/must_use-unit.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/must_use-unit.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +error: unused return value of `foo` that must be used + --> $DIR/must_use-unit.rs:14:5 + | +LL | foo(); //~ unused return value of `foo` + | ^^^^^^ + | +note: lint level defined here + --> $DIR/must_use-unit.rs:3:9 + | +LL | #![deny(unused_must_use)] + | ^^^^^^^^^^^^^^^ + +error: unused return value of `bar` that must be used + --> $DIR/must_use-unit.rs:16:5 + | +LL | bar(); //~ unused return value of `bar` + | ^^^^^^ + +error: aborting due to 2 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/no-unused-parens-return-block.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/no-unused-parens-return-block.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/no-unused-parens-return-block.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/no-unused-parens-return-block.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +// run-pass + +#![deny(unused_parens)] +#![allow(unreachable_code)] + +fn main() { + match (return) {} // ok + if (return) {} // ok +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/suggestions.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/suggestions.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/suggestions.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/suggestions.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,9 +13,6 @@ #![warn(unused_mut, unused_parens)] // UI tests pass `-A unused`—see Issue #43896 #![feature(no_debug)] -#[no_mangle] static SHENZHOU: usize = 1; -//~^ WARN static is marked #[no_mangle] -//~| HELP try making it public #[no_mangle] const DISCOVERY: usize = 1; //~^ ERROR const items should never be #[no_mangle] //~| HELP try a static value @@ -27,27 +24,25 @@ #[no_mangle] fn rio_grande() {} -//~^ WARN function is marked -//~| HELP try making it public mod badlands { // The private-no-mangle lints shouldn't suggest inserting `pub` when the // item is already `pub` (but triggered the lint because, e.g., it's in a // private module). (Issue #47383) - #[no_mangle] pub static DAUNTLESS: bool = true; - //~^ WARN static is marked - //~| HELP try exporting the item with a `pub use` statement - #[no_mangle] pub fn val_jean() {} - //~^ WARN function is marked - //~| HELP try exporting the item with a `pub use` statement + #[no_mangle] pub const DAUNTLESS: bool = true; + //~^ ERROR const items should never be #[no_mangle] + //~| HELP try a static value + #[no_mangle] pub fn val_jean() {} + //~^ WARN functions generic over types must be mangled + //~| HELP remove this attribute // ... but we can suggest just-`pub` instead of restricted - #[no_mangle] pub(crate) static VETAR: bool = true; - //~^ WARN static is marked - //~| HELP try making it public - #[no_mangle] pub(crate) fn crossfield() {} - //~^ WARN function is marked - //~| HELP try making it public + #[no_mangle] pub(crate) const VETAR: bool = true; + //~^ ERROR const items should never be #[no_mangle] + //~| HELP try a static value + #[no_mangle] pub(crate) fn crossfield() {} + //~^ WARN functions generic over types must be mangled + //~| HELP remove this attribute } struct Equinox { @@ -61,7 +56,7 @@ while true { //~^ WARN denote infinite loops //~| HELP use `loop` - let mut a = (1); + let mut registry_no = (format!("NX-{}", 74205)); //~^ WARN does not need to be mutable //~| HELP remove this `mut` //~| WARN unnecessary parentheses @@ -77,6 +72,6 @@ //~^ WARN this pattern is redundant //~| HELP remove this } - println!("{} {}", a, b); + println!("{} {}", registry_no, b); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/suggestions.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/suggestions.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/suggestions.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/suggestions.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ warning: unnecessary parentheses around assigned value - --> $DIR/suggestions.rs:64:21 + --> $DIR/suggestions.rs:59:31 | -LL | let mut a = (1); - | ^^^ help: remove these parentheses +LL | let mut registry_no = (format!("NX-{}", 74205)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove these parentheses | note: lint level defined here --> $DIR/suggestions.rs:13:21 @@ -11,7 +11,7 @@ | ^^^^^^^^^^^^^ warning: use of deprecated attribute `no_debug`: the `#[no_debug]` attribute was an experimental feature that has been deprecated due to lack of demand. See https://github.com/rust-lang/rust/issues/29721 - --> $DIR/suggestions.rs:57:1 + --> $DIR/suggestions.rs:52:1 | LL | #[no_debug] // should suggest removal of deprecated attribute | ^^^^^^^^^^^ help: remove this attribute @@ -19,10 +19,10 @@ = note: #[warn(deprecated)] on by default warning: variable does not need to be mutable - --> $DIR/suggestions.rs:64:13 + --> $DIR/suggestions.rs:59:13 | -LL | let mut a = (1); - | ----^ +LL | let mut registry_no = (format!("NX-{}", 74205)); + | ----^^^^^^^^^^^ | | | help: remove this `mut` | @@ -33,7 +33,7 @@ | ^^^^^^^^^^ warning: variable does not need to be mutable - --> $DIR/suggestions.rs:70:13 + --> $DIR/suggestions.rs:65:13 | LL | let mut | _____________^ @@ -44,18 +44,8 @@ | |____________| | help: remove this `mut` -warning: static is marked #[no_mangle], but not exported - --> $DIR/suggestions.rs:16:14 - | -LL | #[no_mangle] static SHENZHOU: usize = 1; - | -^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | help: try making it public: `pub` - | - = note: #[warn(private_no_mangle_statics)] on by default - error: const items should never be #[no_mangle] - --> $DIR/suggestions.rs:19:14 + --> $DIR/suggestions.rs:16:14 | LL | #[no_mangle] const DISCOVERY: usize = 1; | -----^^^^^^^^^^^^^^^^^^^^^^ @@ -65,7 +55,7 @@ = note: #[deny(no_mangle_const_items)] on by default warning: functions generic over types must be mangled - --> $DIR/suggestions.rs:25:1 + --> $DIR/suggestions.rs:22:1 | LL | #[no_mangle] | ------------ help: remove this attribute @@ -75,50 +65,40 @@ | = note: #[warn(no_mangle_generic_items)] on by default -warning: function is marked #[no_mangle], but not exported - --> $DIR/suggestions.rs:29:1 - | -LL | fn rio_grande() {} - | -^^^^^^^^^^^^^^^^^ - | | - | help: try making it public: `pub` +error: const items should never be #[no_mangle] + --> $DIR/suggestions.rs:32:18 | - = note: #[warn(private_no_mangle_fns)] on by default +LL | #[no_mangle] pub const DAUNTLESS: bool = true; + | ---------^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | help: try a static value: `pub static` -warning: static is marked #[no_mangle], but not exported - --> $DIR/suggestions.rs:37:18 - | -LL | #[no_mangle] pub static DAUNTLESS: bool = true; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +warning: functions generic over types must be mangled + --> $DIR/suggestions.rs:35:18 | - = help: try exporting the item with a `pub use` statement +LL | #[no_mangle] pub fn val_jean() {} + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ + | | + | help: remove this attribute -warning: function is marked #[no_mangle], but not exported +error: const items should never be #[no_mangle] --> $DIR/suggestions.rs:40:18 | -LL | #[no_mangle] pub fn val_jean() {} - | ^^^^^^^^^^^^^^^^^^^^ - | - = help: try exporting the item with a `pub use` statement - -warning: static is marked #[no_mangle], but not exported - --> $DIR/suggestions.rs:45:18 - | -LL | #[no_mangle] pub(crate) static VETAR: bool = true; - | ----------^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[no_mangle] pub(crate) const VETAR: bool = true; + | ----------------^^^^^^^^^^^^^^^^^^^^ | | - | help: try making it public: `pub` + | help: try a static value: `pub static` -warning: function is marked #[no_mangle], but not exported - --> $DIR/suggestions.rs:48:18 +warning: functions generic over types must be mangled + --> $DIR/suggestions.rs:43:18 | -LL | #[no_mangle] pub(crate) fn crossfield() {} - | ----------^^^^^^^^^^^^^^^^^^^ - | | - | help: try making it public: `pub` +LL | #[no_mangle] pub(crate) fn crossfield() {} + | ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | help: remove this attribute warning: denote infinite loops with `loop { ... }` - --> $DIR/suggestions.rs:61:5 + --> $DIR/suggestions.rs:56:5 | LL | while true { | ^^^^^^^^^^ help: use `loop` @@ -126,7 +106,7 @@ = note: #[warn(while_true)] on by default warning: the `warp_factor:` in this pattern is redundant - --> $DIR/suggestions.rs:76:23 + --> $DIR/suggestions.rs:71:23 | LL | Equinox { warp_factor: warp_factor } => {} | ------------^^^^^^^^^^^^ @@ -135,5 +115,5 @@ | = note: #[warn(non_shorthand_field_patterns)] on by default -error: aborting due to previous error +error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/unreachable_pub-pub_crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/unreachable_pub-pub_crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/unreachable_pub-pub_crate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/unreachable_pub-pub_crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,7 +16,6 @@ // compile-pass -#![cfg_attr(stage0, feature(macro_vis_matcher))] #![allow(unused)] #![warn(unreachable_pub)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/unreachable_pub-pub_crate.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/unreachable_pub-pub_crate.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/unreachable_pub-pub_crate.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/unreachable_pub-pub_crate.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ warning: unreachable `pub` item - --> $DIR/unreachable_pub-pub_crate.rs:26:5 + --> $DIR/unreachable_pub-pub_crate.rs:25:5 | LL | pub use std::fmt; | ---^^^^^^^^^^^^^^ @@ -7,14 +7,14 @@ | help: consider restricting its visibility: `pub(crate)` | note: lint level defined here - --> $DIR/unreachable_pub-pub_crate.rs:22:9 + --> $DIR/unreachable_pub-pub_crate.rs:21:9 | LL | #![warn(unreachable_pub)] | ^^^^^^^^^^^^^^^ = help: or consider exporting it for use by other crates warning: unreachable `pub` item - --> $DIR/unreachable_pub-pub_crate.rs:27:24 + --> $DIR/unreachable_pub-pub_crate.rs:26:24 | LL | pub use std::env::{Args}; // braced-use has different item spans than unbraced | --- ^^^^ @@ -24,7 +24,7 @@ = help: or consider exporting it for use by other crates warning: unreachable `pub` item - --> $DIR/unreachable_pub-pub_crate.rs:29:5 + --> $DIR/unreachable_pub-pub_crate.rs:28:5 | LL | pub struct Hydrogen { | ---^^^^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ = help: or consider exporting it for use by other crates warning: unreachable `pub` field - --> $DIR/unreachable_pub-pub_crate.rs:31:9 + --> $DIR/unreachable_pub-pub_crate.rs:30:9 | LL | pub neutrons: usize, | ---^^^^^^^^^^^^^^^^ @@ -42,7 +42,7 @@ | help: consider restricting its visibility: `pub(crate)` warning: unreachable `pub` item - --> $DIR/unreachable_pub-pub_crate.rs:37:9 + --> $DIR/unreachable_pub-pub_crate.rs:36:9 | LL | pub fn count_neutrons(&self) -> usize { self.neutrons } | ---^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -50,7 +50,7 @@ | help: consider restricting its visibility: `pub(crate)` warning: unreachable `pub` item - --> $DIR/unreachable_pub-pub_crate.rs:41:5 + --> $DIR/unreachable_pub-pub_crate.rs:40:5 | LL | pub enum Helium {} | ---^^^^^^^^^^^^ @@ -60,7 +60,7 @@ = help: or consider exporting it for use by other crates warning: unreachable `pub` item - --> $DIR/unreachable_pub-pub_crate.rs:42:5 + --> $DIR/unreachable_pub-pub_crate.rs:41:5 | LL | pub union Lithium { c1: usize, c2: u8 } | ---^^^^^^^^^^^^^^ @@ -70,7 +70,7 @@ = help: or consider exporting it for use by other crates warning: unreachable `pub` item - --> $DIR/unreachable_pub-pub_crate.rs:43:5 + --> $DIR/unreachable_pub-pub_crate.rs:42:5 | LL | pub fn beryllium() {} | ---^^^^^^^^^^^^^^^ @@ -80,7 +80,7 @@ = help: or consider exporting it for use by other crates warning: unreachable `pub` item - --> $DIR/unreachable_pub-pub_crate.rs:44:5 + --> $DIR/unreachable_pub-pub_crate.rs:43:5 | LL | pub trait Boron {} | ---^^^^^^^^^^^^ @@ -90,7 +90,7 @@ = help: or consider exporting it for use by other crates warning: unreachable `pub` item - --> $DIR/unreachable_pub-pub_crate.rs:45:5 + --> $DIR/unreachable_pub-pub_crate.rs:44:5 | LL | pub const CARBON: usize = 1; | ---^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -100,7 +100,7 @@ = help: or consider exporting it for use by other crates warning: unreachable `pub` item - --> $DIR/unreachable_pub-pub_crate.rs:46:5 + --> $DIR/unreachable_pub-pub_crate.rs:45:5 | LL | pub static NITROGEN: usize = 2; | ---^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -110,7 +110,7 @@ = help: or consider exporting it for use by other crates warning: unreachable `pub` item - --> $DIR/unreachable_pub-pub_crate.rs:47:5 + --> $DIR/unreachable_pub-pub_crate.rs:46:5 | LL | pub type Oxygen = bool; | ---^^^^^^^^^^^^^^^^^^^^ @@ -120,7 +120,7 @@ = help: or consider exporting it for use by other crates warning: unreachable `pub` item - --> $DIR/unreachable_pub-pub_crate.rs:50:47 + --> $DIR/unreachable_pub-pub_crate.rs:49:47 | LL | ($visibility: vis, $name: ident) => { $visibility struct $name {} } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -134,7 +134,7 @@ = help: or consider exporting it for use by other crates warning: unreachable `pub` item - --> $DIR/unreachable_pub-pub_crate.rs:55:9 + --> $DIR/unreachable_pub-pub_crate.rs:54:9 | LL | pub fn catalyze() -> bool; | ---^^^^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/unreachable_pub.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/unreachable_pub.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/unreachable_pub.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/unreachable_pub.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,6 @@ // compile-pass #![feature(crate_visibility_modifier)] -#![cfg_attr(stage0, feature(macro_vis_matcher))] #![allow(unused)] #![warn(unreachable_pub)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/unreachable_pub.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/unreachable_pub.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lint/unreachable_pub.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lint/unreachable_pub.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ warning: unreachable `pub` item - --> $DIR/unreachable_pub.rs:21:5 + --> $DIR/unreachable_pub.rs:20:5 | LL | pub use std::fmt; | ---^^^^^^^^^^^^^^ @@ -7,14 +7,14 @@ | help: consider restricting its visibility: `crate` | note: lint level defined here - --> $DIR/unreachable_pub.rs:17:9 + --> $DIR/unreachable_pub.rs:16:9 | LL | #![warn(unreachable_pub)] | ^^^^^^^^^^^^^^^ = help: or consider exporting it for use by other crates warning: unreachable `pub` item - --> $DIR/unreachable_pub.rs:22:24 + --> $DIR/unreachable_pub.rs:21:24 | LL | pub use std::env::{Args}; // braced-use has different item spans than unbraced | --- ^^^^ @@ -24,7 +24,7 @@ = help: or consider exporting it for use by other crates warning: unreachable `pub` item - --> $DIR/unreachable_pub.rs:24:5 + --> $DIR/unreachable_pub.rs:23:5 | LL | pub struct Hydrogen { | ---^^^^^^^^^^^^^^^^ @@ -34,7 +34,7 @@ = help: or consider exporting it for use by other crates warning: unreachable `pub` field - --> $DIR/unreachable_pub.rs:26:9 + --> $DIR/unreachable_pub.rs:25:9 | LL | pub neutrons: usize, | ---^^^^^^^^^^^^^^^^ @@ -42,7 +42,7 @@ | help: consider restricting its visibility: `crate` warning: unreachable `pub` item - --> $DIR/unreachable_pub.rs:32:9 + --> $DIR/unreachable_pub.rs:31:9 | LL | pub fn count_neutrons(&self) -> usize { self.neutrons } | ---^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -50,7 +50,7 @@ | help: consider restricting its visibility: `crate` warning: unreachable `pub` item - --> $DIR/unreachable_pub.rs:36:5 + --> $DIR/unreachable_pub.rs:35:5 | LL | pub enum Helium {} | ---^^^^^^^^^^^^ @@ -60,7 +60,7 @@ = help: or consider exporting it for use by other crates warning: unreachable `pub` item - --> $DIR/unreachable_pub.rs:37:5 + --> $DIR/unreachable_pub.rs:36:5 | LL | pub union Lithium { c1: usize, c2: u8 } | ---^^^^^^^^^^^^^^ @@ -70,7 +70,7 @@ = help: or consider exporting it for use by other crates warning: unreachable `pub` item - --> $DIR/unreachable_pub.rs:38:5 + --> $DIR/unreachable_pub.rs:37:5 | LL | pub fn beryllium() {} | ---^^^^^^^^^^^^^^^ @@ -80,7 +80,7 @@ = help: or consider exporting it for use by other crates warning: unreachable `pub` item - --> $DIR/unreachable_pub.rs:39:5 + --> $DIR/unreachable_pub.rs:38:5 | LL | pub trait Boron {} | ---^^^^^^^^^^^^ @@ -90,7 +90,7 @@ = help: or consider exporting it for use by other crates warning: unreachable `pub` item - --> $DIR/unreachable_pub.rs:40:5 + --> $DIR/unreachable_pub.rs:39:5 | LL | pub const CARBON: usize = 1; | ---^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -100,7 +100,7 @@ = help: or consider exporting it for use by other crates warning: unreachable `pub` item - --> $DIR/unreachable_pub.rs:41:5 + --> $DIR/unreachable_pub.rs:40:5 | LL | pub static NITROGEN: usize = 2; | ---^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -110,7 +110,7 @@ = help: or consider exporting it for use by other crates warning: unreachable `pub` item - --> $DIR/unreachable_pub.rs:42:5 + --> $DIR/unreachable_pub.rs:41:5 | LL | pub type Oxygen = bool; | ---^^^^^^^^^^^^^^^^^^^^ @@ -120,7 +120,7 @@ = help: or consider exporting it for use by other crates warning: unreachable `pub` item - --> $DIR/unreachable_pub.rs:45:47 + --> $DIR/unreachable_pub.rs:44:47 | LL | ($visibility: vis, $name: ident) => { $visibility struct $name {} } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -134,7 +134,7 @@ = help: or consider exporting it for use by other crates warning: unreachable `pub` item - --> $DIR/unreachable_pub.rs:50:9 + --> $DIR/unreachable_pub.rs:49:9 | LL | pub fn catalyze() -> bool; | ---^^^^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/liveness/liveness-move-call-arg.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/liveness/liveness-move-call-arg.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/liveness/liveness-move-call-arg.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/liveness/liveness-move-call-arg.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0382]: use of moved value: `x` + --> $DIR/liveness-move-call-arg.rs:19:14 + | +LL | take(x); //~ ERROR use of moved value: `x` + | ^ value moved here, in previous iteration of loop + | + = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/liveness/liveness-move-in-loop.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/liveness/liveness-move-in-loop.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/liveness/liveness-move-in-loop.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/liveness/liveness-move-in-loop.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0382]: use of moved value: `y` + --> $DIR/liveness-move-in-loop.rs:21:25 + | +LL | x = y; //~ ERROR use of moved value + | ^ value moved here, in previous iteration of loop + | + = note: move occurs because `y` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/liveness/liveness-move-in-while.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/liveness/liveness-move-in-while.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/liveness/liveness-move-in-while.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/liveness/liveness-move-in-while.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -4,18 +4,10 @@ LL | println!("{}", y); //~ ERROR use of moved value: `y` | ^ value borrowed here after move LL | while true { while true { while true { x = y; x.clone(); } } } - | - value moved here + | - value moved here, in previous iteration of loop | = note: move occurs because `y` has type `std::boxed::Box`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `y` - --> $DIR/liveness-move-in-while.rs:18:52 - | -LL | while true { while true { while true { x = y; x.clone(); } } } - | ^ value moved here in previous iteration of loop - | - = note: move occurs because `y` has type `std::boxed::Box`, which does not implement the `Copy` trait - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/liveness/liveness-use-after-move.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/liveness/liveness-use-after-move.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/liveness/liveness-use-after-move.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/liveness/liveness-use-after-move.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ -error[E0382]: borrow of moved value: `*x` +error[E0382]: borrow of moved value: `x` --> $DIR/liveness-use-after-move.rs:16:20 | LL | let y = x; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lub-if.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lub-if.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lub-if.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lub-if.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/lub-if.rs:38:9 - | -LL | pub fn opt_str2<'a>(maybestr: &'a Option) -> &'static str { - | -- lifetime `'a` defined here -... -LL | s //~ ERROR E0312 - | ^ returning this value requires that `'a` must outlive `'static` - -error: unsatisfied lifetime constraints - --> $DIR/lub-if.rs:45:9 - | -LL | pub fn opt_str3<'a>(maybestr: &'a Option) -> &'static str { - | -- lifetime `'a` defined here -... -LL | s //~ ERROR E0312 - | ^ returning this value requires that `'a` must outlive `'static` - -error: aborting due to 2 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/lub-match.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/lub-match.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/lub-match.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/lub-match.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/lub-match.rs:40:13 - | -LL | pub fn opt_str2<'a>(maybestr: &'a Option) -> &'static str { - | -- lifetime `'a` defined here -... -LL | s //~ ERROR E0312 - | ^ returning this value requires that `'a` must outlive `'static` - -error: unsatisfied lifetime constraints - --> $DIR/lub-match.rs:49:13 - | -LL | pub fn opt_str3<'a>(maybestr: &'a Option) -> &'static str { - | -- lifetime `'a` defined here -... -LL | s //~ ERROR E0312 - | ^ returning this value requires that `'a` must outlive `'static` - -error: aborting due to 2 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/ambiguity-legacy-vs-modern.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/ambiguity-legacy-vs-modern.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/ambiguity-legacy-vs-modern.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/ambiguity-legacy-vs-modern.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,32 +1,32 @@ -error[E0659]: `m` is ambiguous +error[E0659]: `m` is ambiguous (`macro_rules` vs non-`macro_rules` from other module) --> $DIR/ambiguity-legacy-vs-modern.rs:31:9 | LL | m!() //~ ERROR `m` is ambiguous | ^ ambiguous name | -note: `m` could refer to the name defined here +note: `m` could refer to the macro defined here --> $DIR/ambiguity-legacy-vs-modern.rs:26:5 | LL | macro_rules! m { () => (()) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: `m` could also refer to the name defined here +note: `m` could also refer to the macro defined here --> $DIR/ambiguity-legacy-vs-modern.rs:29:9 | LL | macro m() { 0 } | ^^^^^^^^^^^^^^^ -error[E0659]: `m` is ambiguous +error[E0659]: `m` is ambiguous (`macro_rules` vs non-`macro_rules` from other module) --> $DIR/ambiguity-legacy-vs-modern.rs:43:5 | LL | m!() //~ ERROR `m` is ambiguous | ^ ambiguous name | -note: `m` could refer to the name defined here +note: `m` could refer to the macro defined here --> $DIR/ambiguity-legacy-vs-modern.rs:40:9 | LL | macro_rules! m { () => (()) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: `m` could also refer to the name defined here +note: `m` could also refer to the macro defined here --> $DIR/ambiguity-legacy-vs-modern.rs:36:5 | LL | macro m() { 0 } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/issue-54441.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/issue-54441.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/issue-54441.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/issue-54441.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +#![feature(macros_in_extern)] + +macro_rules! m { + () => { + let //~ ERROR expected + }; +} + +extern "C" { + m!(); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/issue-54441.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/issue-54441.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/issue-54441.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/issue-54441.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error: expected one of `crate`, `fn`, `pub`, `static`, or `type`, found `let` + --> $DIR/issue-54441.rs:5:9 + | +LL | let //~ ERROR expected + | ^^^ unexpected token +... +LL | m!(); + | ----- in this macro invocation + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macro-inner-attributes.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macro-inner-attributes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macro-inner-attributes.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macro-inner-attributes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -25,6 +25,6 @@ #[qux] fn main() { a::bar(); - //~^ ERROR failed to resolve. Use of undeclared type or module `a` + //~^ ERROR failed to resolve: use of undeclared type or module `a` b::bar(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macro-inner-attributes.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macro-inner-attributes.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macro-inner-attributes.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macro-inner-attributes.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ -error[E0433]: failed to resolve. Use of undeclared type or module `a` +error[E0433]: failed to resolve: use of undeclared type or module `a` --> $DIR/macro-inner-attributes.rs:27:5 | LL | a::bar(); - | ^ Use of undeclared type or module `a` + | ^ use of undeclared type or module `a` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macro-invalid-fragment-spec.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macro-invalid-fragment-spec.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macro-invalid-fragment-spec.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macro-invalid-fragment-spec.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -4,7 +4,7 @@ LL | ($x:foo) => () | ^^^^^^ | - = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `literal`, `path`, `meta`, `tt`, `item` and `vis` + = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macro-local-data-key-priv.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macro-local-data-key-priv.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macro-local-data-key-priv.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macro-local-data-key-priv.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ error[E0603]: constant `baz` is private - --> $DIR/macro-local-data-key-priv.rs:18:5 + --> $DIR/macro-local-data-key-priv.rs:18:10 | LL | bar::baz.with(|_| ()); - | ^^^^^^^^ + | ^^^ error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macro_path_as_generic_bound.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macro_path_as_generic_bound.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macro_path_as_generic_bound.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macro_path_as_generic_bound.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ -error[E0433]: failed to resolve. Use of undeclared type or module `m` +error[E0433]: failed to resolve: use of undeclared type or module `m` --> $DIR/macro_path_as_generic_bound.rs:17:6 | LL | foo!(m::m2::A); //~ ERROR failed to resolve - | ^ Use of undeclared type or module `m` + | ^ use of undeclared type or module `m` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macro-path-prelude-fail-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macro-path-prelude-fail-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macro-path-prelude-fail-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macro-path-prelude-fail-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,8 +12,8 @@ mod m { fn check() { - Vec::clone!(); //~ ERROR failed to resolve. Not a module `Vec` - u8::clone!(); //~ ERROR failed to resolve. Not a module `u8` + Vec::clone!(); //~ ERROR failed to resolve: not a module `Vec` + u8::clone!(); //~ ERROR failed to resolve: not a module `u8` } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macro-path-prelude-fail-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macro-path-prelude-fail-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macro-path-prelude-fail-1.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macro-path-prelude-fail-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,14 +1,14 @@ -error[E0433]: failed to resolve. Not a module `Vec` +error[E0433]: failed to resolve: not a module `Vec` --> $DIR/macro-path-prelude-fail-1.rs:15:9 | -LL | Vec::clone!(); //~ ERROR failed to resolve. Not a module `Vec` - | ^^^ Not a module `Vec` +LL | Vec::clone!(); //~ ERROR failed to resolve: not a module `Vec` + | ^^^ not a module `Vec` -error[E0433]: failed to resolve. Not a module `u8` +error[E0433]: failed to resolve: not a module `u8` --> $DIR/macro-path-prelude-fail-1.rs:16:9 | -LL | u8::clone!(); //~ ERROR failed to resolve. Not a module `u8` - | ^^ Not a module `u8` +LL | u8::clone!(); //~ ERROR failed to resolve: not a module `u8` + | ^^ not a module `u8` error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macro-path-prelude-fail-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macro-path-prelude-fail-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macro-path-prelude-fail-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macro-path-prelude-fail-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,7 @@ mod m { fn check() { - Result::Ok!(); //~ ERROR fail to resolve non-ident macro path + Result::Ok!(); //~ ERROR failed to resolve: partially resolved path in a macro } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macro-path-prelude-fail-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macro-path-prelude-fail-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macro-path-prelude-fail-2.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macro-path-prelude-fail-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,9 @@ -error: fail to resolve non-ident macro path +error[E0433]: failed to resolve: partially resolved path in a macro --> $DIR/macro-path-prelude-fail-2.rs:13:9 | -LL | Result::Ok!(); //~ ERROR fail to resolve non-ident macro path - | ^^^^^^^^^^ +LL | Result::Ok!(); //~ ERROR failed to resolve: partially resolved path in a macro + | ^^^^^^^^^^ partially resolved path in a macro error: aborting due to previous error +For more information about this error, try `rustc --explain E0433`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macro-path-prelude-shadowing.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macro-path-prelude-shadowing.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macro-path-prelude-shadowing.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macro-path-prelude-shadowing.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,20 +1,17 @@ -error[E0659]: `std` is ambiguous +error[E0659]: `std` is ambiguous (glob import vs any other name from outer scope during import/macro resolution) --> $DIR/macro-path-prelude-shadowing.rs:39:9 | LL | std::panic!(); //~ ERROR `std` is ambiguous | ^^^ ambiguous name | -note: `std` could refer to the name imported here + = note: `std` could refer to a built-in extern crate +note: `std` could also refer to the module imported here --> $DIR/macro-path-prelude-shadowing.rs:37:9 | LL | use m2::*; // glob-import user-defined `std` | ^^^^^ -note: `std` could also refer to the name defined here - --> $DIR/macro-path-prelude-shadowing.rs:39:9 - | -LL | std::panic!(); //~ ERROR `std` is ambiguous - | ^^^ - = note: consider adding an explicit import of `std` to disambiguate + = help: consider adding an explicit import of `std` to disambiguate + = help: or use `self::std` to refer to this module unambiguously error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macro-shadowing.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macro-shadowing.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macro-shadowing.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macro-shadowing.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -9,13 +9,13 @@ | = note: macro-expanded `#[macro_use]`s may not shadow existing macros (see RFC 1560) -error[E0659]: `foo` is ambiguous +error[E0659]: `foo` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) --> $DIR/macro-shadowing.rs:27:1 | LL | foo!(); //~ ERROR `foo` is ambiguous | ^^^ ambiguous name | -note: `foo` could refer to the name defined here +note: `foo` could refer to the macro defined here --> $DIR/macro-shadowing.rs:20:5 | LL | macro_rules! foo { () => {} } @@ -23,12 +23,11 @@ ... LL | m1!(); | ------ in this macro invocation -note: `foo` could also refer to the name defined here +note: `foo` could also refer to the macro defined here --> $DIR/macro-shadowing.rs:15:1 | LL | macro_rules! foo { () => {} } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: macro-expanded macros do not shadow error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macros-nonfatal-errors.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macros-nonfatal-errors.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macros-nonfatal-errors.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macros-nonfatal-errors.rs 2018-12-04 23:41:40.000000000 +0000 @@ -1,15 +1,4 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// normalize-stderr-test: "The system cannot find the file specified\." -> "No such file or directory" -// ignore-tidy-linelength +// normalize-stderr-test: "existed:.*\(" -> "existed: $$FILE_NOT_FOUND_MSG (" // test that errors in a (selection) of macros don't kill compilation // immediately, so that we get more errors listed at a time. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macros-nonfatal-errors.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macros-nonfatal-errors.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/macros-nonfatal-errors.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/macros-nonfatal-errors.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,47 +1,47 @@ error[E0665]: `Default` cannot be derived for enums, only structs - --> $DIR/macros-nonfatal-errors.rs:20:10 + --> $DIR/macros-nonfatal-errors.rs:9:10 | LL | #[derive(Default)] //~ ERROR | ^^^^^^^ error: inline assembly must be a string literal - --> $DIR/macros-nonfatal-errors.rs:24:10 + --> $DIR/macros-nonfatal-errors.rs:13:10 | LL | asm!(invalid); //~ ERROR | ^^^^^^^ error: concat_idents! requires ident args. - --> $DIR/macros-nonfatal-errors.rs:26:5 + --> $DIR/macros-nonfatal-errors.rs:15:5 | LL | concat_idents!("not", "idents"); //~ ERROR | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: argument must be a string literal - --> $DIR/macros-nonfatal-errors.rs:28:17 + --> $DIR/macros-nonfatal-errors.rs:17:17 | LL | option_env!(invalid); //~ ERROR | ^^^^^^^ error: expected string literal - --> $DIR/macros-nonfatal-errors.rs:29:10 + --> $DIR/macros-nonfatal-errors.rs:18:10 | LL | env!(invalid); //~ ERROR | ^^^^^^^ error: expected string literal - --> $DIR/macros-nonfatal-errors.rs:30:10 + --> $DIR/macros-nonfatal-errors.rs:19:10 | LL | env!(foo, abr, baz); //~ ERROR | ^^^ error: environment variable `RUST_HOPEFULLY_THIS_DOESNT_EXIST` not defined - --> $DIR/macros-nonfatal-errors.rs:31:5 + --> $DIR/macros-nonfatal-errors.rs:20:5 | LL | env!("RUST_HOPEFULLY_THIS_DOESNT_EXIST"); //~ ERROR | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: format argument must be a string literal - --> $DIR/macros-nonfatal-errors.rs:33:13 + --> $DIR/macros-nonfatal-errors.rs:22:13 | LL | format!(invalid); //~ ERROR | ^^^^^^^ @@ -51,37 +51,37 @@ | ^^^^^ error: argument must be a string literal - --> $DIR/macros-nonfatal-errors.rs:35:14 + --> $DIR/macros-nonfatal-errors.rs:24:14 | LL | include!(invalid); //~ ERROR | ^^^^^^^ error: argument must be a string literal - --> $DIR/macros-nonfatal-errors.rs:37:18 + --> $DIR/macros-nonfatal-errors.rs:26:18 | LL | include_str!(invalid); //~ ERROR | ^^^^^^^ -error: couldn't read $DIR/i'd be quite surprised if a file with this name existed: No such file or directory (os error 2) - --> $DIR/macros-nonfatal-errors.rs:38:5 +error: couldn't read $DIR/i'd be quite surprised if a file with this name existed: $FILE_NOT_FOUND_MSG (os error 2) + --> $DIR/macros-nonfatal-errors.rs:27:5 | LL | include_str!("i'd be quite surprised if a file with this name existed"); //~ ERROR | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: argument must be a string literal - --> $DIR/macros-nonfatal-errors.rs:39:20 + --> $DIR/macros-nonfatal-errors.rs:28:20 | LL | include_bytes!(invalid); //~ ERROR | ^^^^^^^ -error: couldn't read $DIR/i'd be quite surprised if a file with this name existed: No such file or directory (os error 2) - --> $DIR/macros-nonfatal-errors.rs:40:5 +error: couldn't read $DIR/i'd be quite surprised if a file with this name existed: $FILE_NOT_FOUND_MSG (os error 2) + --> $DIR/macros-nonfatal-errors.rs:29:5 | LL | include_bytes!("i'd be quite surprised if a file with this name existed"); //~ ERROR | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: trace_macros! accepts only `true` or `false` - --> $DIR/macros-nonfatal-errors.rs:42:5 + --> $DIR/macros-nonfatal-errors.rs:31:5 | LL | trace_macros!(invalid); //~ ERROR | ^^^^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/must-use-in-macro-55516.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/must-use-in-macro-55516.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/must-use-in-macro-55516.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/must-use-in-macro-55516.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// compile-flags: -Wunused + +// make sure write!() can't hide its unused Result + +fn main() { + use std::fmt::Write; + let mut example = String::new(); + write!(&mut example, "{}", 42); //~WARN must be used +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/must-use-in-macro-55516.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/must-use-in-macro-55516.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/must-use-in-macro-55516.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/must-use-in-macro-55516.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +warning: unused `std::result::Result` that must be used + --> $DIR/must-use-in-macro-55516.rs:19:5 + | +LL | write!(&mut example, "{}", 42); //~WARN must be used + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `-W unused-must-use` implied by `-W unused` + = note: this `Result` may be an `Err` variant, which should be handled + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/restricted-shadowing-legacy.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/restricted-shadowing-legacy.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/restricted-shadowing-legacy.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/restricted-shadowing-legacy.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,10 +1,13 @@ -error[E0659]: `m` is ambiguous +error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) --> $DIR/restricted-shadowing-legacy.rs:101:13 | LL | m!(); //~ ERROR `m` is ambiguous | ^ ambiguous name +... +LL | include!(); + | ----------- in this macro invocation | -note: `m` could refer to the name defined here +note: `m` could refer to the macro defined here --> $DIR/restricted-shadowing-legacy.rs:88:9 | LL | macro_rules! m { () => { Right } } @@ -12,7 +15,7 @@ ... LL | include!(); | ----------- in this macro invocation -note: `m` could also refer to the name defined here +note: `m` could also refer to the macro defined here --> $DIR/restricted-shadowing-legacy.rs:97:9 | LL | macro_rules! m { () => {} } @@ -20,15 +23,17 @@ ... LL | include!(); | ----------- in this macro invocation - = note: macro-expanded macros do not shadow -error[E0659]: `m` is ambiguous +error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) --> $DIR/restricted-shadowing-legacy.rs:139:42 | LL | macro_rules! gen_invoc { () => { m!() } } //~ ERROR `m` is ambiguous | ^ ambiguous name +... +LL | include!(); + | ----------- in this macro invocation | -note: `m` could refer to the name defined here +note: `m` could refer to the macro defined here --> $DIR/restricted-shadowing-legacy.rs:88:9 | LL | macro_rules! m { () => { Right } } @@ -36,7 +41,7 @@ ... LL | include!(); | ----------- in this macro invocation -note: `m` could also refer to the name defined here +note: `m` could also refer to the macro defined here --> $DIR/restricted-shadowing-legacy.rs:135:9 | LL | macro_rules! m { () => {} } @@ -44,15 +49,17 @@ ... LL | include!(); | ----------- in this macro invocation - = note: macro-expanded macros do not shadow -error[E0659]: `m` is ambiguous +error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) --> $DIR/restricted-shadowing-legacy.rs:148:9 | LL | m!(); //~ ERROR `m` is ambiguous | ^ ambiguous name +... +LL | include!(); + | ----------- in this macro invocation | -note: `m` could refer to the name defined here +note: `m` could refer to the macro defined here --> $DIR/restricted-shadowing-legacy.rs:88:9 | LL | macro_rules! m { () => { Right } } @@ -60,7 +67,7 @@ ... LL | include!(); | ----------- in this macro invocation -note: `m` could also refer to the name defined here +note: `m` could also refer to the macro defined here --> $DIR/restricted-shadowing-legacy.rs:144:9 | LL | macro_rules! m { () => {} } @@ -68,15 +75,17 @@ ... LL | include!(); | ----------- in this macro invocation - = note: macro-expanded macros do not shadow -error[E0659]: `m` is ambiguous +error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) --> $DIR/restricted-shadowing-legacy.rs:164:9 | LL | m!(); //~ ERROR `m` is ambiguous | ^ ambiguous name +... +LL | include!(); + | ----------- in this macro invocation | -note: `m` could refer to the name defined here +note: `m` could refer to the macro defined here --> $DIR/restricted-shadowing-legacy.rs:88:9 | LL | macro_rules! m { () => { Right } } @@ -84,7 +93,7 @@ ... LL | include!(); | ----------- in this macro invocation -note: `m` could also refer to the name defined here +note: `m` could also refer to the macro defined here --> $DIR/restricted-shadowing-legacy.rs:85:9 | LL | macro_rules! m { () => { Wrong } } @@ -92,15 +101,17 @@ ... LL | include!(); | ----------- in this macro invocation - = note: macro-expanded macros do not shadow -error[E0659]: `m` is ambiguous +error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) --> $DIR/restricted-shadowing-legacy.rs:180:13 | LL | m!(); //~ ERROR `m` is ambiguous | ^ ambiguous name +... +LL | include!(); + | ----------- in this macro invocation | -note: `m` could refer to the name defined here +note: `m` could refer to the macro defined here --> $DIR/restricted-shadowing-legacy.rs:88:9 | LL | macro_rules! m { () => { Right } } @@ -108,7 +119,7 @@ ... LL | include!(); | ----------- in this macro invocation -note: `m` could also refer to the name defined here +note: `m` could also refer to the macro defined here --> $DIR/restricted-shadowing-legacy.rs:85:9 | LL | macro_rules! m { () => { Wrong } } @@ -116,15 +127,17 @@ ... LL | include!(); | ----------- in this macro invocation - = note: macro-expanded macros do not shadow -error[E0659]: `m` is ambiguous +error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) --> $DIR/restricted-shadowing-legacy.rs:218:42 | LL | macro_rules! gen_invoc { () => { m!() } } //~ ERROR `m` is ambiguous | ^ ambiguous name +... +LL | include!(); + | ----------- in this macro invocation | -note: `m` could refer to the name defined here +note: `m` could refer to the macro defined here --> $DIR/restricted-shadowing-legacy.rs:88:9 | LL | macro_rules! m { () => { Right } } @@ -132,7 +145,7 @@ ... LL | include!(); | ----------- in this macro invocation -note: `m` could also refer to the name defined here +note: `m` could also refer to the macro defined here --> $DIR/restricted-shadowing-legacy.rs:85:9 | LL | macro_rules! m { () => { Wrong } } @@ -140,15 +153,17 @@ ... LL | include!(); | ----------- in this macro invocation - = note: macro-expanded macros do not shadow -error[E0659]: `m` is ambiguous +error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) --> $DIR/restricted-shadowing-legacy.rs:232:9 | LL | m!(); //~ ERROR `m` is ambiguous | ^ ambiguous name +... +LL | include!(); + | ----------- in this macro invocation | -note: `m` could refer to the name defined here +note: `m` could refer to the macro defined here --> $DIR/restricted-shadowing-legacy.rs:88:9 | LL | macro_rules! m { () => { Right } } @@ -156,7 +171,7 @@ ... LL | include!(); | ----------- in this macro invocation -note: `m` could also refer to the name defined here +note: `m` could also refer to the macro defined here --> $DIR/restricted-shadowing-legacy.rs:227:13 | LL | macro_rules! m { () => {} } @@ -164,15 +179,17 @@ ... LL | include!(); | ----------- in this macro invocation - = note: macro-expanded macros do not shadow -error[E0659]: `m` is ambiguous +error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) --> $DIR/restricted-shadowing-legacy.rs:262:42 | LL | macro_rules! gen_invoc { () => { m!() } } //~ ERROR `m` is ambiguous | ^ ambiguous name +... +LL | include!(); + | ----------- in this macro invocation | -note: `m` could refer to the name defined here +note: `m` could refer to the macro defined here --> $DIR/restricted-shadowing-legacy.rs:88:9 | LL | macro_rules! m { () => { Right } } @@ -180,7 +197,7 @@ ... LL | include!(); | ----------- in this macro invocation -note: `m` could also refer to the name defined here +note: `m` could also refer to the macro defined here --> $DIR/restricted-shadowing-legacy.rs:257:13 | LL | macro_rules! m { () => {} } @@ -188,7 +205,6 @@ ... LL | include!(); | ----------- in this macro invocation - = note: macro-expanded macros do not shadow error: aborting due to 8 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/restricted-shadowing-modern.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/restricted-shadowing-modern.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/macros/restricted-shadowing-modern.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/macros/restricted-shadowing-modern.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,10 +1,13 @@ -error[E0659]: `m` is ambiguous +error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) --> $DIR/restricted-shadowing-modern.rs:106:17 | LL | m!(); //~ ERROR `m` is ambiguous | ^ ambiguous name +... +LL | include!(); + | ----------- in this macro invocation | -note: `m` could refer to the name defined here +note: `m` could refer to the macro defined here --> $DIR/restricted-shadowing-modern.rs:91:9 | LL | macro m() { Right } @@ -12,7 +15,7 @@ ... LL | include!(); | ----------- in this macro invocation -note: `m` could also refer to the name defined here +note: `m` could also refer to the macro defined here --> $DIR/restricted-shadowing-modern.rs:101:9 | LL | macro m() {} @@ -20,15 +23,17 @@ ... LL | include!(); | ----------- in this macro invocation - = note: macro-expanded macros do not shadow -error[E0659]: `m` is ambiguous +error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) --> $DIR/restricted-shadowing-modern.rs:149:33 | LL | macro gen_invoc() { m!() } //~ ERROR `m` is ambiguous | ^ ambiguous name +... +LL | include!(); + | ----------- in this macro invocation | -note: `m` could refer to the name defined here +note: `m` could refer to the macro defined here --> $DIR/restricted-shadowing-modern.rs:91:9 | LL | macro m() { Right } @@ -36,7 +41,7 @@ ... LL | include!(); | ----------- in this macro invocation -note: `m` could also refer to the name defined here +note: `m` could also refer to the macro defined here --> $DIR/restricted-shadowing-modern.rs:145:9 | LL | macro m() {} @@ -44,15 +49,17 @@ ... LL | include!(); | ----------- in this macro invocation - = note: macro-expanded macros do not shadow -error[E0659]: `m` is ambiguous +error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) --> $DIR/restricted-shadowing-modern.rs:158:13 | LL | m!(); //~ ERROR `m` is ambiguous | ^ ambiguous name +... +LL | include!(); + | ----------- in this macro invocation | -note: `m` could refer to the name defined here +note: `m` could refer to the macro defined here --> $DIR/restricted-shadowing-modern.rs:91:9 | LL | macro m() { Right } @@ -60,7 +67,7 @@ ... LL | include!(); | ----------- in this macro invocation -note: `m` could also refer to the name defined here +note: `m` could also refer to the macro defined here --> $DIR/restricted-shadowing-modern.rs:155:9 | LL | macro m() {} @@ -68,15 +75,17 @@ ... LL | include!(); | ----------- in this macro invocation - = note: macro-expanded macros do not shadow -error[E0659]: `m` is ambiguous +error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) --> $DIR/restricted-shadowing-modern.rs:174:13 | LL | m!(); //~ ERROR `m` is ambiguous | ^ ambiguous name +... +LL | include!(); + | ----------- in this macro invocation | -note: `m` could refer to the name defined here +note: `m` could refer to the macro defined here --> $DIR/restricted-shadowing-modern.rs:91:9 | LL | macro m() { Right } @@ -84,7 +93,7 @@ ... LL | include!(); | ----------- in this macro invocation -note: `m` could also refer to the name defined here +note: `m` could also refer to the macro defined here --> $DIR/restricted-shadowing-modern.rs:87:9 | LL | macro m() { Wrong } @@ -92,15 +101,17 @@ ... LL | include!(); | ----------- in this macro invocation - = note: macro-expanded macros do not shadow -error[E0659]: `m` is ambiguous +error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) --> $DIR/restricted-shadowing-modern.rs:192:17 | LL | m!(); //~ ERROR `m` is ambiguous | ^ ambiguous name +... +LL | include!(); + | ----------- in this macro invocation | -note: `m` could refer to the name defined here +note: `m` could refer to the macro defined here --> $DIR/restricted-shadowing-modern.rs:91:9 | LL | macro m() { Right } @@ -108,7 +119,7 @@ ... LL | include!(); | ----------- in this macro invocation -note: `m` could also refer to the name defined here +note: `m` could also refer to the macro defined here --> $DIR/restricted-shadowing-modern.rs:87:9 | LL | macro m() { Wrong } @@ -116,15 +127,17 @@ ... LL | include!(); | ----------- in this macro invocation - = note: macro-expanded macros do not shadow -error[E0659]: `m` is ambiguous +error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) --> $DIR/restricted-shadowing-modern.rs:235:33 | LL | macro gen_invoc() { m!() } //~ ERROR `m` is ambiguous | ^ ambiguous name +... +LL | include!(); + | ----------- in this macro invocation | -note: `m` could refer to the name defined here +note: `m` could refer to the macro defined here --> $DIR/restricted-shadowing-modern.rs:91:9 | LL | macro m() { Right } @@ -132,7 +145,7 @@ ... LL | include!(); | ----------- in this macro invocation -note: `m` could also refer to the name defined here +note: `m` could also refer to the macro defined here --> $DIR/restricted-shadowing-modern.rs:87:9 | LL | macro m() { Wrong } @@ -140,7 +153,6 @@ ... LL | include!(); | ----------- in this macro invocation - = note: macro-expanded macros do not shadow error: aborting due to 6 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-attribute-on-non-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-attribute-on-non-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-attribute-on-non-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-attribute-on-non-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(marker_trait_attr)] + +#[marker] //~ ERROR attribute can only be applied to a trait +struct Struct {} + +#[marker] //~ ERROR attribute can only be applied to a trait +impl Struct {} + +#[marker] //~ ERROR attribute can only be applied to a trait +union Union { + x: i32, +} + +#[marker] //~ ERROR attribute can only be applied to a trait +const CONST: usize = 10; + +#[marker] //~ ERROR attribute can only be applied to a trait +fn function() {} + +#[marker] //~ ERROR attribute can only be applied to a trait +type Type = (); + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-attribute-on-non-trait.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-attribute-on-non-trait.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-attribute-on-non-trait.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-attribute-on-non-trait.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,52 @@ +error: attribute can only be applied to a trait + --> $DIR/marker-attribute-on-non-trait.rs:13:1 + | +LL | #[marker] //~ ERROR attribute can only be applied to a trait + | ^^^^^^^^^ +LL | struct Struct {} + | ---------------- not a trait + +error: attribute can only be applied to a trait + --> $DIR/marker-attribute-on-non-trait.rs:16:1 + | +LL | #[marker] //~ ERROR attribute can only be applied to a trait + | ^^^^^^^^^ +LL | impl Struct {} + | -------------- not a trait + +error: attribute can only be applied to a trait + --> $DIR/marker-attribute-on-non-trait.rs:19:1 + | +LL | #[marker] //~ ERROR attribute can only be applied to a trait + | ^^^^^^^^^ +LL | / union Union { +LL | | x: i32, +LL | | } + | |_- not a trait + +error: attribute can only be applied to a trait + --> $DIR/marker-attribute-on-non-trait.rs:24:1 + | +LL | #[marker] //~ ERROR attribute can only be applied to a trait + | ^^^^^^^^^ +LL | const CONST: usize = 10; + | ------------------------ not a trait + +error: attribute can only be applied to a trait + --> $DIR/marker-attribute-on-non-trait.rs:27:1 + | +LL | #[marker] //~ ERROR attribute can only be applied to a trait + | ^^^^^^^^^ +LL | fn function() {} + | ---------------- not a trait + +error: attribute can only be applied to a trait + --> $DIR/marker-attribute-on-non-trait.rs:30:1 + | +LL | #[marker] //~ ERROR attribute can only be applied to a trait + | ^^^^^^^^^ +LL | type Type = (); + | --------------- not a trait + +error: aborting due to 6 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-attribute-with-values.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-attribute-with-values.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-attribute-with-values.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-attribute-with-values.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(marker_trait_attr)] +#![feature(unrestricted_attribute_tokens)] + +#[marker(always)] +trait Marker1 {} +//~^^ ERROR attribute should be empty + +#[marker("never")] +trait Marker2 {} +//~^^ ERROR attribute should be empty + +#[marker(key = value)] +trait Marker3 {} +//~^^ ERROR attribute should be empty + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-attribute-with-values.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-attribute-with-values.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-attribute-with-values.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-attribute-with-values.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +error: attribute should be empty + --> $DIR/marker-attribute-with-values.rs:14:1 + | +LL | #[marker(always)] + | ^^^^^^^^^^^^^^^^^ + +error: attribute should be empty + --> $DIR/marker-attribute-with-values.rs:18:1 + | +LL | #[marker("never")] + | ^^^^^^^^^^^^^^^^^^ + +error: attribute should be empty + --> $DIR/marker-attribute-with-values.rs:22:1 + | +LL | #[marker(key = value)] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-trait-with-associated-items.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-trait-with-associated-items.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-trait-with-associated-items.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-trait-with-associated-items.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,50 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(marker_trait_attr)] +#![feature(associated_type_defaults)] + +#[marker] +trait MarkerConst { + const N: usize; + //~^ ERROR marker traits cannot have associated items +} + +#[marker] +trait MarkerType { + type Output; + //~^ ERROR marker traits cannot have associated items +} + +#[marker] +trait MarkerFn { + fn foo(); + //~^ ERROR marker traits cannot have associated items +} + +#[marker] +trait MarkerConstWithDefault { + const N: usize = 43; + //~^ ERROR marker traits cannot have associated items +} + +#[marker] +trait MarkerTypeWithDefault { + type Output = (); + //~^ ERROR marker traits cannot have associated items +} + +#[marker] +trait MarkerFnWithDefault { + fn foo() {} + //~^ ERROR marker traits cannot have associated items +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-trait-with-associated-items.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-trait-with-associated-items.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-trait-with-associated-items.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/marker_trait_attr/marker-trait-with-associated-items.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +error[E0714]: marker traits cannot have associated items + --> $DIR/marker-trait-with-associated-items.rs:16:5 + | +LL | const N: usize; + | ^^^^^^^^^^^^^^^ + +error[E0714]: marker traits cannot have associated items + --> $DIR/marker-trait-with-associated-items.rs:22:5 + | +LL | type Output; + | ^^^^^^^^^^^^ + +error[E0714]: marker traits cannot have associated items + --> $DIR/marker-trait-with-associated-items.rs:28:5 + | +LL | fn foo(); + | ^^^^^^^^^ + +error[E0714]: marker traits cannot have associated items + --> $DIR/marker-trait-with-associated-items.rs:34:5 + | +LL | const N: usize = 43; + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0714]: marker traits cannot have associated items + --> $DIR/marker-trait-with-associated-items.rs:40:5 + | +LL | type Output = (); + | ^^^^^^^^^^^^^^^^^ + +error[E0714]: marker traits cannot have associated items + --> $DIR/marker-trait-with-associated-items.rs:46:5 + | +LL | fn foo() {} + | ^^^^^^^^^^^ + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0714`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/marker_trait_attr/overlap-marker-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/marker_trait_attr/overlap-marker-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/marker_trait_attr/overlap-marker-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/marker_trait_attr/overlap-marker-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test for RFC 1268: we allow overlapping impls of marker traits, +// that is, traits with #[marker]. In this case, a type `T` is +// `MyMarker` if it is either `Debug` or `Display`. This test just +// checks that we don't consider **all** types to be `MyMarker`. + +#![feature(marker_trait_attr)] + +use std::fmt::{Debug, Display}; + +#[marker] trait Marker {} + +impl Marker for T {} +impl Marker for T {} + +fn is_marker() { } + +struct NotDebugOrDisplay; + +fn main() { + // Debug && Display: + is_marker::(); + + // Debug && !Display: + is_marker::>(); + + // !Debug && !Display + is_marker::(); //~ ERROR +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/marker_trait_attr/overlap-marker-trait.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/marker_trait_attr/overlap-marker-trait.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/marker_trait_attr/overlap-marker-trait.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/marker_trait_attr/overlap-marker-trait.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `NotDebugOrDisplay: Marker` is not satisfied + --> $DIR/overlap-marker-trait.rs:37:5 + | +LL | is_marker::(); //~ ERROR + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Marker` is not implemented for `NotDebugOrDisplay` + | +note: required by `is_marker` + --> $DIR/overlap-marker-trait.rs:25:1 + | +LL | fn is_marker() { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/marker_trait_attr/override-item-on-marker-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/marker_trait_attr/override-item-on-marker-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/marker_trait_attr/override-item-on-marker-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/marker_trait_attr/override-item-on-marker-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(marker_trait_attr)] + +#[marker] +trait Marker { + const N: usize = 0; + fn do_something() {} +} + +struct OverrideConst; +impl Marker for OverrideConst { +//~^ ERROR impls for marker traits cannot contain items + const N: usize = 1; +} + +struct OverrideFn; +impl Marker for OverrideFn { +//~^ ERROR impls for marker traits cannot contain items + fn do_something() { + println!("Hello world!"); + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/marker_trait_attr/override-item-on-marker-trait.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/marker_trait_attr/override-item-on-marker-trait.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/marker_trait_attr/override-item-on-marker-trait.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/marker_trait_attr/override-item-on-marker-trait.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +error[E0715]: impls for marker traits cannot contain items + --> $DIR/override-item-on-marker-trait.rs:20:1 + | +LL | impl Marker for OverrideConst { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0715]: impls for marker traits cannot contain items + --> $DIR/override-item-on-marker-trait.rs:26:1 + | +LL | impl Marker for OverrideFn { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0715`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/match/match-fn-call.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/match/match-fn-call.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/match/match-fn-call.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/match/match-fn-call.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +use std::path::Path; + +fn main() { + let path = Path::new("foo"); + match path { + Path::new("foo") => println!("foo"), + //~^ ERROR expected tuple struct/variant + Path::new("bar") => println!("bar"), + //~^ ERROR expected tuple struct/variant + _ => (), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/match/match-fn-call.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/match/match-fn-call.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/match/match-fn-call.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/match/match-fn-call.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +error[E0164]: expected tuple struct/variant, found method `::new` + --> $DIR/match-fn-call.rs:6:9 + | +LL | Path::new("foo") => println!("foo"), + | ^^^^^^^^^^^^^^^^ not a tuple variant or struct + +error[E0164]: expected tuple struct/variant, found method `::new` + --> $DIR/match-fn-call.rs:8:9 + | +LL | Path::new("bar") => println!("bar"), + | ^^^^^^^^^^^^^^^^ not a tuple variant or struct + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0164`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/match/match-ref-mut-invariance.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/match/match-ref-mut-invariance.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/match/match-ref-mut-invariance.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/match/match-ref-mut-invariance.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/match-ref-mut-invariance.rs:20:9 - | -LL | impl<'b> S<'b> { - | -- lifetime `'b` defined here -LL | fn bar<'a>(&'a mut self) -> &'a mut &'a i32 { - | -- lifetime `'a` defined here -LL | match self.0 { ref mut x => x } //~ ERROR mismatched types - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'b` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/match/match-ref-mut-let-invariance.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/match/match-ref-mut-let-invariance.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/match/match-ref-mut-let-invariance.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/match/match-ref-mut-let-invariance.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/match-ref-mut-let-invariance.rs:21:9 - | -LL | impl<'b> S<'b> { - | -- lifetime `'b` defined here -LL | fn bar<'a>(&'a mut self) -> &'a mut &'a i32 { - | -- lifetime `'a` defined here -LL | let ref mut x = self.0; -LL | x //~ ERROR mismatched types - | ^ returning this value requires that `'a` must outlive `'b` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/match/match-unreachable-warning-with-diverging-discrim.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/match/match-unreachable-warning-with-diverging-discrim.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/match/match-unreachable-warning-with-diverging-discrim.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/match/match-unreachable-warning-with-diverging-discrim.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_parens)] -#![deny(unreachable_code)] - -fn main() { - match (return) { } //~ ERROR unreachable expression -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/match/match-unreachable-warning-with-diverging-discrim.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/match/match-unreachable-warning-with-diverging-discrim.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/match/match-unreachable-warning-with-diverging-discrim.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/match/match-unreachable-warning-with-diverging-discrim.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -error: unreachable expression - --> $DIR/match-unreachable-warning-with-diverging-discrim.rs:15:5 - | -LL | match (return) { } //~ ERROR unreachable expression - | ^^^^^^^^^^^^^^^^^^ - | -note: lint level defined here - --> $DIR/match-unreachable-warning-with-diverging-discrim.rs:12:9 - | -LL | #![deny(unreachable_code)] - | ^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/methods/method-self-arg-2.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/methods/method-self-arg-2.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/methods/method-self-arg-2.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/methods/method-self-arg-2.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -6,7 +6,7 @@ LL | Foo::bar(&x); //~ERROR cannot borrow `x` | ^^ immutable borrow occurs here LL | y.use_mut(); - | - borrow later used here + | - mutable borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/method-self-arg-2.rs:30:14 @@ -16,7 +16,7 @@ LL | Foo::baz(&mut x); //~ERROR cannot borrow `x` | ^^^^^^ second mutable borrow occurs here LL | y.use_mut(); - | - borrow later used here + | - first borrow later used here error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/mismatched_types/numeric-literal-cast.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/mismatched_types/numeric-literal-cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/mismatched_types/numeric-literal-cast.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/mismatched_types/numeric-literal-cast.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo(_: u16) {} +fn foo1(_: f64) {} +fn foo2(_: i32) {} + +fn main() { + foo(1u8); + foo1(2f32); + foo2(3i16); +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/mismatched_types/numeric-literal-cast.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/mismatched_types/numeric-literal-cast.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/mismatched_types/numeric-literal-cast.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/mismatched_types/numeric-literal-cast.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +error[E0308]: mismatched types + --> $DIR/numeric-literal-cast.rs:16:9 + | +LL | foo(1u8); + | ^^^ expected u16, found u8 +help: change the type of the numeric literal from `u8` to `u16` + | +LL | foo(1u16); + | ^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-literal-cast.rs:17:10 + | +LL | foo1(2f32); + | ^^^^ expected f64, found f32 +help: change the type of the numeric literal from `f32` to `f64` + | +LL | foo1(2f64); + | ^^^^ + +error[E0308]: mismatched types + --> $DIR/numeric-literal-cast.rs:18:10 + | +LL | foo2(3i16); + | ^^^^ expected i32, found i16 +help: change the type of the numeric literal from `i16` to `i32` + | +LL | foo2(3i32); + | ^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/moves/move-in-guard-2.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/moves/move-in-guard-2.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/moves/move-in-guard-2.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/moves/move-in-guard-2.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0382]: use of moved value: `x` + --> $DIR/move-in-guard-2.rs:20:24 + | +LL | (_, 2) if take(x) => (), //~ ERROR use of moved value: `x` + | ^ value moved here, in previous iteration of loop + | + = note: move occurs because `x` has type `std::boxed::Box`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/moves/moves-based-on-type-block-bad.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/moves/moves-based-on-type-block-bad.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/moves/moves-based-on-type-block-bad.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/moves/moves-based-on-type-block-bad.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -16,6 +16,18 @@ LL | box E::Bar(x) => println!("{}", x.to_string()), | ^ -error: aborting due to previous error +error[E0507]: cannot move out of `hellothere.x.0` which is behind a `&` reference + --> $DIR/moves-based-on-type-block-bad.rs:37:28 + | +LL | f(&s, |hellothere| { + | ---------- help: consider changing this to be a mutable reference: `&mut S` +... +LL | box E::Bar(x) => println!("{}", x.to_string()), + | ^ + | | + | cannot move out of `hellothere.x.0` which is behind a `&` reference + | `hellothere` is a `&` reference, so the data it refers to cannot be moved + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -6,6 +6,21 @@ LL | let _f = to_fn(|| test(i)); //~ ERROR cannot move out | ^ cannot move out of captured variable in an `Fn` closure -error: aborting due to previous error +error[E0507]: cannot move out of `i`, as it is a captured variable in a `Fn` closure + --> $DIR/moves-based-on-type-move-out-of-closure-env-issue-1965.rs:21:28 + | +LL | let _f = to_fn(|| test(i)); //~ ERROR cannot move out + | ^ + | | + | cannot move out of `i`, as it is a captured variable in a `Fn` closure + | cannot move + | +help: consider changing this to accept closures that implement `FnMut` + --> $DIR/moves-based-on-type-move-out-of-closure-env-issue-1965.rs:21:20 + | +LL | let _f = to_fn(|| test(i)); //~ ERROR cannot move out + | ^^^^^^^^^^ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/moves/moves-based-on-type-no-recursive-stack-closure.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,11 +2,10 @@ --> $DIR/moves-based-on-type-no-recursive-stack-closure.rs:30:27 | LL | (f.c)(f, true); - | ------^------- - | | | - | | second mutable borrow occurs here + | ----- ^ second mutable borrow occurs here + | | | first mutable borrow occurs here - | borrow later used here + | first borrow later used by call error[E0382]: borrow of moved value: `f` --> $DIR/moves-based-on-type-no-recursive-stack-closure.rs:42:5 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/mut/mut-cant-alias.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/mut/mut-cant-alias.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/mut/mut-cant-alias.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/mut/mut-cant-alias.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -6,7 +6,7 @@ LL | let b2 = &mut *b; //~ ERROR cannot borrow | ^ second mutable borrow occurs here LL | b1.use_mut(); - | -- borrow later used here + | -- first borrow later used here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/mut/no-mut-lint-for-desugared-mut.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/mut/no-mut-lint-for-desugared-mut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/mut/no-mut-lint-for-desugared-mut.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/mut/no-mut-lint-for-desugared-mut.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +// run-pass + +#![deny(unused_mut)] +#![allow(unreachable_code)] + +fn main() { + for _ in { return (); 0..3 } {} // ok +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// run-pass +// +// FIXME(#54366) - We probably shouldn't allow #[thread_local] static mut to get a 'static lifetime. + +#![feature(nll)] +#![feature(thread_local)] + +#[thread_local] +static mut X1: u64 = 0; + +struct S1 { + a: &'static mut u64, +} + +impl S1 { + fn new(_x: u64) -> S1 { + S1 { + a: unsafe { &mut X1 }, + } + } +} + +fn main() { + S1::new(0).a; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/borrowed-local-error.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/borrowed-local-error.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/borrowed-local-error.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/borrowed-local-error.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,16 +1,14 @@ error[E0597]: `v` does not live long enough --> $DIR/borrowed-local-error.rs:20:9 | -LL | let x = gimme({ - | _____________- -LL | | let v = (22,); -LL | | &v - | | ^^ borrowed value does not live long enough -LL | | //~^ ERROR `v` does not live long enough [E0597] -LL | | }); - | |_____-- borrow later used here - | | - | `v` dropped here while still borrowed +LL | let x = gimme({ + | ----- borrow later used by call +LL | let v = (22,); +LL | &v + | ^^ borrowed value does not live long enough +LL | //~^ ERROR `v` does not live long enough [E0597] +LL | }); + | - `v` dropped here while still borrowed error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/borrowed-match-issue-45045.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/borrowed-match-issue-45045.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/borrowed-match-issue-45045.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/borrowed-match-issue-45045.rs 2018-12-04 23:41:40.000000000 +0000 @@ -21,7 +21,7 @@ let mut e = Xyz::A; let f = &mut e; let g = f; - match e { //~ cannot use `e` because it was mutably borrowed [E0503] + match e { Xyz::A => println!("a"), //~^ cannot use `e` because it was mutably borrowed [E0503] Xyz::B => println!("b"), diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/borrowed-match-issue-45045.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/borrowed-match-issue-45045.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/borrowed-match-issue-45045.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/borrowed-match-issue-45045.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,16 +1,4 @@ error[E0503]: cannot use `e` because it was mutably borrowed - --> $DIR/borrowed-match-issue-45045.rs:24:11 - | -LL | let f = &mut e; - | ------ borrow of `e` occurs here -LL | let g = f; -LL | match e { //~ cannot use `e` because it was mutably borrowed [E0503] - | ^ use of borrowed `e` -... -LL | *g = Xyz::B; - | ----------- borrow later used here - -error[E0503]: cannot use `e` because it was mutably borrowed --> $DIR/borrowed-match-issue-45045.rs:25:9 | LL | let f = &mut e; @@ -22,6 +10,6 @@ LL | *g = Xyz::B; | ----------- borrow later used here -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0503`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/borrowed-referent-issue-38899.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/borrowed-referent-issue-38899.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/borrowed-referent-issue-38899.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/borrowed-referent-issue-38899.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | ^^^^^^^^^^^^^^^ immutable borrow occurs here LL | //~^ ERROR cannot borrow `*block.current` as immutable because it is also borrowed as mutable LL | drop(x); - | - borrow later used here + | - mutable borrow later used here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/borrowed-temporary-error.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/borrowed-temporary-error.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/borrowed-temporary-error.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/borrowed-temporary-error.rs 2018-12-04 23:41:40.000000000 +0000 @@ -18,7 +18,7 @@ let x = gimme({ let v = 22; &(v,) - //~^ ERROR borrowed value does not live long enough [E0597] + //~^ ERROR temporary value dropped while borrowed [E0716] }); println!("{:?}", x); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/borrowed-temporary-error.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/borrowed-temporary-error.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/borrowed-temporary-error.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/borrowed-temporary-error.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,11 +1,11 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/borrowed-temporary-error.rs:20:10 | LL | &(v,) - | ^^^^ temporary value does not live long enough -LL | //~^ ERROR borrowed value does not live long enough [E0597] + | ^^^^ creates a temporary which is freed while still in use +LL | //~^ ERROR temporary value dropped while borrowed [E0716] LL | }); - | - temporary value only lives until here + | - temporary value is freed at the end of this statement LL | println!("{:?}", x); | - borrow later used here | @@ -13,4 +13,4 @@ error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/borrowed-universal-error-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/borrowed-universal-error-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/borrowed-universal-error-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/borrowed-universal-error-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,7 +14,7 @@ fn foo<'a>(x: &'a (u32,)) -> &'a u32 { let v = 22; &v - //~^ ERROR `v` does not live long enough [E0597] + //~^ ERROR cannot return reference to local variable `v` [E0515] } fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/borrowed-universal-error-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/borrowed-universal-error-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/borrowed-universal-error-2.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/borrowed-universal-error-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,18 +1,9 @@ -error[E0597]: `v` does not live long enough +error[E0515]: cannot return reference to local variable `v` --> $DIR/borrowed-universal-error-2.rs:16:5 | LL | &v - | ^^ borrowed value does not live long enough -LL | //~^ ERROR `v` does not live long enough [E0597] -LL | } - | - `v` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 14:8... - --> $DIR/borrowed-universal-error-2.rs:14:8 - | -LL | fn foo<'a>(x: &'a (u32,)) -> &'a u32 { - | ^^ + | ^^ returns a reference to data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/borrowed-universal-error.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/borrowed-universal-error.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/borrowed-universal-error.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/borrowed-universal-error.rs 2018-12-04 23:41:40.000000000 +0000 @@ -18,7 +18,7 @@ fn foo<'a>(x: &'a (u32,)) -> &'a u32 { let v = 22; gimme(&(v,)) - //~^ ERROR borrowed value does not live long enough [E0597] + //~^ ERROR cannot return value referencing temporary value [E0515] } fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/borrowed-universal-error.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/borrowed-universal-error.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/borrowed-universal-error.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/borrowed-universal-error.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,18 +1,12 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/borrowed-universal-error.rs:20:12 +error[E0515]: cannot return value referencing temporary value + --> $DIR/borrowed-universal-error.rs:20:5 | LL | gimme(&(v,)) - | ^^^^ temporary value does not live long enough -LL | //~^ ERROR borrowed value does not live long enough [E0597] -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 18:8... - --> $DIR/borrowed-universal-error.rs:18:8 - | -LL | fn foo<'a>(x: &'a (u32,)) -> &'a u32 { - | ^^ + | ^^^^^^^----^ + | | | + | | temporary value created here + | returns a value referencing data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/cannot-move-block-spans.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/cannot-move-block-spans.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/cannot-move-block-spans.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/cannot-move-block-spans.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,6 +7,17 @@ | cannot move out of borrowed content | help: consider removing the `*`: `r` +error[E0507]: cannot move out of `*r` which is behind a `&` reference + --> $DIR/cannot-move-block-spans.rs:15:15 + | +LL | pub fn deref(r: &String) { + | ------- help: consider changing this to be a mutable reference: `&mut std::string::String` +LL | let x = { *r }; //~ ERROR + | ^^ + | | + | cannot move out of `*r` which is behind a `&` reference + | `r` is a `&` reference, so the data it refers to cannot be moved + error[E0507]: cannot move out of borrowed content --> $DIR/cannot-move-block-spans.rs:16:22 | @@ -16,6 +27,18 @@ | cannot move out of borrowed content | help: consider removing the `*`: `r` +error[E0507]: cannot move out of `*r` which is behind a `&` reference + --> $DIR/cannot-move-block-spans.rs:16:22 + | +LL | pub fn deref(r: &String) { + | ------- help: consider changing this to be a mutable reference: `&mut std::string::String` +LL | let x = { *r }; //~ ERROR +LL | let y = unsafe { *r }; //~ ERROR + | ^^ + | | + | cannot move out of `*r` which is behind a `&` reference + | `r` is a `&` reference, so the data it refers to cannot be moved + error[E0507]: cannot move out of borrowed content --> $DIR/cannot-move-block-spans.rs:17:26 | @@ -25,6 +48,18 @@ | cannot move out of borrowed content | help: consider removing the `*`: `r` +error[E0507]: cannot move out of `*r` which is behind a `&` reference + --> $DIR/cannot-move-block-spans.rs:17:26 + | +LL | pub fn deref(r: &String) { + | ------- help: consider changing this to be a mutable reference: `&mut std::string::String` +... +LL | let z = loop { break *r; }; //~ ERROR + | ^^ + | | + | cannot move out of `*r` which is behind a `&` reference + | `r` is a `&` reference, so the data it refers to cannot be moved + error[E0508]: cannot move out of type `[std::string::String; 2]`, a non-copy array --> $DIR/cannot-move-block-spans.rs:21:15 | @@ -61,6 +96,17 @@ | cannot move out of borrowed content | help: consider removing the `*`: `r` +error[E0507]: cannot move out of `*r` which is behind a `&` reference + --> $DIR/cannot-move-block-spans.rs:27:38 + | +LL | pub fn additional_statement_cases(r: &String) { + | ------- help: consider changing this to be a mutable reference: `&mut std::string::String` +LL | let x = { let mut u = 0; u += 1; *r }; //~ ERROR + | ^^ + | | + | cannot move out of `*r` which is behind a `&` reference + | `r` is a `&` reference, so the data it refers to cannot be moved + error[E0507]: cannot move out of borrowed content --> $DIR/cannot-move-block-spans.rs:28:45 | @@ -70,6 +116,18 @@ | cannot move out of borrowed content | help: consider removing the `*`: `r` +error[E0507]: cannot move out of `*r` which is behind a `&` reference + --> $DIR/cannot-move-block-spans.rs:28:45 + | +LL | pub fn additional_statement_cases(r: &String) { + | ------- help: consider changing this to be a mutable reference: `&mut std::string::String` +LL | let x = { let mut u = 0; u += 1; *r }; //~ ERROR +LL | let y = unsafe { let mut u = 0; u += 1; *r }; //~ ERROR + | ^^ + | | + | cannot move out of `*r` which is behind a `&` reference + | `r` is a `&` reference, so the data it refers to cannot be moved + error[E0507]: cannot move out of borrowed content --> $DIR/cannot-move-block-spans.rs:29:49 | @@ -79,7 +137,19 @@ | cannot move out of borrowed content | help: consider removing the `*`: `r` -error: aborting due to 9 previous errors +error[E0507]: cannot move out of `*r` which is behind a `&` reference + --> $DIR/cannot-move-block-spans.rs:29:49 + | +LL | pub fn additional_statement_cases(r: &String) { + | ------- help: consider changing this to be a mutable reference: `&mut std::string::String` +... +LL | let z = loop { let mut u = 0; u += 1; break *r; u += 2; }; //~ ERROR + | ^^ + | | + | cannot move out of `*r` which is behind a `&` reference + | `r` is a `&` reference, so the data it refers to cannot be moved + +error: aborting due to 15 previous errors Some errors occurred: E0507, E0508. For more information about an error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-access-spans.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-access-spans.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-access-spans.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-access-spans.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | | | immutable borrow occurs here LL | r.use_mut(); - | - borrow later used here + | - mutable borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/closure-access-spans.rs:23:5 @@ -20,7 +20,7 @@ | | | second mutable borrow occurs here LL | r.use_mut(); - | - borrow later used here + | - first borrow later used here error[E0500]: closure requires unique access to `x` but it is already borrowed --> $DIR/closure-access-spans.rs:29:5 @@ -32,7 +32,7 @@ | | | closure construction occurs here LL | r.use_mut(); - | - borrow later used here + | - first borrow later used here error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/closure-access-spans.rs:35:13 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-borrow-spans.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-borrow-spans.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-borrow-spans.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-borrow-spans.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -20,7 +20,7 @@ LL | let y = &mut x; //~ ERROR | ^^^^^^ mutable borrow occurs here LL | f.use_ref(); - | - borrow later used here + | - immutable borrow later used here error[E0597]: `x` does not live long enough --> $DIR/closure-borrow-spans.rs:31:16 @@ -68,7 +68,7 @@ LL | let y = &x; //~ ERROR | ^^ immutable borrow occurs here LL | f.use_ref(); - | - borrow later used here + | - mutable borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/closure-borrow-spans.rs:56:13 @@ -80,7 +80,7 @@ LL | let y = &mut x; //~ ERROR | ^^^^^^ second mutable borrow occurs here LL | f.use_ref(); - | - borrow later used here + | - first borrow later used here error[E0597]: `x` does not live long enough --> $DIR/closure-borrow-spans.rs:64:16 @@ -128,7 +128,7 @@ LL | let y = &x; //~ ERROR | ^^ borrow occurs here LL | f.use_ref(); - | - borrow later used here + | - first borrow later used here error[E0501]: cannot borrow `x` as mutable because previous closure requires unique access --> $DIR/closure-borrow-spans.rs:89:13 @@ -140,7 +140,7 @@ LL | let y = &mut x; //~ ERROR | ^^^^^^ borrow occurs here LL | f.use_ref(); - | - borrow later used here + | - first borrow later used here error[E0597]: `x` does not live long enough --> $DIR/closure-borrow-spans.rs:98:17 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/escape-argument-callee.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -13,7 +13,7 @@ --> $DIR/escape-argument-callee.rs:36:45 | LL | let mut closure = expect_sig(|p, y| *p = y); - | - - ^^^^^^ requires that `'1` must outlive `'2` + | - - ^^^^^^ assignment requires that `'1` must outlive `'2` | | | | | has type `&'1 i32` | has type `&mut &'2 i32` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-ref.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-ref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-ref.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-ref.rs 2018-12-04 23:41:40.000000000 +0000 @@ -51,10 +51,10 @@ #[rustc_regions] fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { - //~^ ERROR unsatisfied lifetime constraints // Only works if 'x: 'y: demand_y(x, y, x.get()) + //~^ ERROR unsatisfied lifetime constraints }); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-ref.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -3,10 +3,10 @@ | LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { | _______________________________________________^ -LL | | //~^ ERROR unsatisfied lifetime constraints LL | | LL | | // Only works if 'x: 'y: LL | | demand_y(x, y, x.get()) +LL | | //~^ ERROR unsatisfied lifetime constraints LL | | }); | |_____^ | @@ -24,8 +24,8 @@ | LL | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { LL | | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { -LL | | //~^ ERROR unsatisfied lifetime constraints LL | | +LL | | // Only works if 'x: 'y: ... | LL | | }); LL | | } @@ -34,19 +34,15 @@ = note: defining type: DefId(0/0:6 ~ propagate_approximated_ref[317d]::supply[0]) with substs [] error: unsatisfied lifetime constraints - --> $DIR/propagate-approximated-ref.rs:53:5 + --> $DIR/propagate-approximated-ref.rs:56:9 | -LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | / establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { -LL | | //~^ ERROR unsatisfied lifetime constraints -LL | | -LL | | // Only works if 'x: 'y: -LL | | demand_y(x, y, x.get()) -LL | | }); - | |______^ argument requires that `'a` must outlive `'b` +LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +... +LL | demand_y(x, y, x.get()) + | ^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'a` must outlive `'b` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -13,7 +13,7 @@ for<'r> extern "rust-call" fn((std::cell::Cell<&'_#1r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BrNamed(crate0:DefIndex(0:0), 'r)) u32>)) ] -error: borrowed data escapes outside of closure +error[E0521]: borrowed data escapes outside of closure --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:32:9 | LL | foo(cell, |cell_a, cell_x| { @@ -71,13 +71,15 @@ --> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:40:26 | LL | let cell = Cell::new(&a); - | ^^ borrowed value does not live long enough + | ----------^^- + | | | + | | borrowed value does not live long enough + | argument requires that `a` is borrowed for `'static` ... LL | } | - `a` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +Some errors occurred: E0521, E0597. +For more information about an error, try `rustc --explain E0521`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.rs 2018-12-04 23:41:40.000000000 +0000 @@ -44,7 +44,6 @@ fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { //~^ ERROR borrowed data escapes outside of function - //~| ERROR unsatisfied lifetime constraints // Only works if 'x: 'y: demand_y(x, y, x.get()) diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -4,7 +4,6 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { | _______________________________________________^ LL | | //~^ ERROR borrowed data escapes outside of function -LL | | //~| ERROR unsatisfied lifetime constraints LL | | LL | | // Only works if 'x: 'y: LL | | demand_y(x, y, x.get()) @@ -26,7 +25,7 @@ LL | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { LL | | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { LL | | //~^ ERROR borrowed data escapes outside of function -LL | | //~| ERROR unsatisfied lifetime constraints +LL | | ... | LL | | }); LL | | } @@ -34,29 +33,19 @@ | = note: defining type: DefId(0/0:6 ~ propagate_approximated_shorter_to_static_no_bound[317d]::supply[0]) with substs [] -error: borrowed data escapes outside of function +error[E0521]: borrowed data escapes outside of function --> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:45:5 | LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { | ------ `cell_a` is a reference that is only valid in the function body LL | / establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { LL | | //~^ ERROR borrowed data escapes outside of function -LL | | //~| ERROR unsatisfied lifetime constraints LL | | LL | | // Only works if 'x: 'y: LL | | demand_y(x, y, x.get()) LL | | }); | |______^ `cell_a` escapes the function body here -error: unsatisfied lifetime constraints - --> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:45:29 - | -LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { - | ^^^^^^^ requires that `'a` must outlive `'b` - -error: aborting due to 2 previous errors +error: aborting due to previous error +For more information about this error, try `rustc --explain E0521`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.rs 2018-12-04 23:41:40.000000000 +0000 @@ -47,7 +47,7 @@ fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { //~^ ERROR borrowed data escapes outside of function - //~| ERROR unsatisfied lifetime constraints + // Only works if 'x: 'y: demand_y(x, y, x.get()) }); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -4,7 +4,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { | _______________________________________________^ LL | | //~^ ERROR borrowed data escapes outside of function -LL | | //~| ERROR unsatisfied lifetime constraints +LL | | LL | | // Only works if 'x: 'y: LL | | demand_y(x, y, x.get()) LL | | }); @@ -25,7 +25,7 @@ LL | / fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { LL | | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { LL | | //~^ ERROR borrowed data escapes outside of function -LL | | //~| ERROR unsatisfied lifetime constraints +LL | | ... | LL | | }); LL | | } @@ -33,28 +33,19 @@ | = note: defining type: DefId(0/0:6 ~ propagate_approximated_shorter_to_static_wrong_bound[317d]::supply[0]) with substs [] -error: borrowed data escapes outside of function +error[E0521]: borrowed data escapes outside of function --> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:48:5 | LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { | ------ `cell_a` is a reference that is only valid in the function body LL | / establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { LL | | //~^ ERROR borrowed data escapes outside of function -LL | | //~| ERROR unsatisfied lifetime constraints +LL | | LL | | // Only works if 'x: 'y: LL | | demand_y(x, y, x.get()) LL | | }); | |______^ `cell_a` escapes the function body here -error: unsatisfied lifetime constraints - --> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:48:29 - | -LL | fn supply<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { - | ^^^^^^^ requires that `'a` must outlive `'b` - -error: aborting due to 2 previous errors +error: aborting due to previous error +For more information about this error, try `rustc --explain E0521`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-val.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-val.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-val.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-val.rs 2018-12-04 23:41:40.000000000 +0000 @@ -44,10 +44,10 @@ #[rustc_regions] fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| { - //~^ ERROR unsatisfied lifetime constraints // Only works if 'x: 'y: demand_y(outlives1, outlives2, x.get()) + //~^ ERROR unsatisfied lifetime constraints }); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-approximated-val.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -3,10 +3,10 @@ | LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| { | _____________________________________________^ -LL | | //~^ ERROR unsatisfied lifetime constraints LL | | LL | | // Only works if 'x: 'y: LL | | demand_y(outlives1, outlives2, x.get()) +LL | | //~^ ERROR unsatisfied lifetime constraints LL | | }); | |_____^ | @@ -24,8 +24,8 @@ | LL | / fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { LL | | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| { -LL | | //~^ ERROR unsatisfied lifetime constraints LL | | +LL | | // Only works if 'x: 'y: ... | LL | | }); LL | | } @@ -34,19 +34,15 @@ = note: defining type: DefId(0/0:6 ~ propagate_approximated_val[317d]::test[0]) with substs [] error: unsatisfied lifetime constraints - --> $DIR/propagate-approximated-val.rs:46:5 + --> $DIR/propagate-approximated-val.rs:49:9 | -LL | fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | / establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| { -LL | | //~^ ERROR unsatisfied lifetime constraints -LL | | -LL | | // Only works if 'x: 'y: -LL | | demand_y(outlives1, outlives2, x.get()) -LL | | }); - | |______^ argument requires that `'a` must outlive `'b` +LL | fn test<'a, 'b>(cell_a: Cell<&'a u32>, cell_b: Cell<&'b u32>) { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +... +LL | demand_y(outlives1, outlives2, x.get()) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'a` must outlive `'b` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-multiple-requirements.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-multiple-requirements.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-multiple-requirements.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-multiple-requirements.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Test that we propagate *all* requirements to the caller, not just the first +// one. + +#![feature(nll)] + +fn once U>(f: F, s: S, t: T) -> U { + f(s, t) +} + +pub fn dangle() -> &'static [i32] { + let other_local_arr = [0, 2, 4]; + let local_arr = other_local_arr; + let mut out: &mut &'static [i32] = &mut (&[1] as _); + once(|mut z: &[i32], mut out_val: &mut &[i32]| { + // We unfortunately point to the first use in the closure in the error + // message + z = &local_arr; //~ ERROR + *out_val = &local_arr; + }, &[] as &[_], &mut *out); + *out +} + +fn main() { + println!("{:?}", dangle()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-multiple-requirements.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-multiple-requirements.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-multiple-requirements.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closure-requirements/propagate-multiple-requirements.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +error[E0597]: `local_arr` does not live long enough + --> $DIR/propagate-multiple-requirements.rs:17:14 + | +LL | let mut out: &mut &'static [i32] = &mut (&[1] as _); + | ------------------- type annotation requires that `local_arr` is borrowed for `'static` +LL | once(|mut z: &[i32], mut out_val: &mut &[i32]| { + | ----------------------------------------- value captured here +... +LL | z = &local_arr; //~ ERROR + | ^^^^^^^^^ borrowed value does not live long enough +... +LL | } + | - `local_arr` dropped here while still borrowed + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closures-in-loops.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closures-in-loops.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/closures-in-loops.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/closures-in-loops.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -4,7 +4,7 @@ LL | || x; //~ ERROR | ^^ - use occurs due to use in closure | | - | value moved into closure here in previous iteration of loop + | value moved into closure here, in previous iteration of loop | = note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/do-not-ignore-lifetime-bounds-in-copy.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/do-not-ignore-lifetime-bounds-in-copy.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/do-not-ignore-lifetime-bounds-in-copy.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/do-not-ignore-lifetime-bounds-in-copy.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -3,11 +3,11 @@ | LL | let a = Foo(&s); //~ ERROR `s` does not live long enough [E0597] | ^^ borrowed value does not live long enough -... +LL | drop(a); + | - copying this value requires that `s` is borrowed for `'static` +LL | drop(a); LL | } | - `s` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/drop-no-may-dangle.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/drop-no-may-dangle.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/drop-no-may-dangle.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/drop-no-may-dangle.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | ^^^^^^^^^ assignment to borrowed `v[..]` occurs here ... LL | } - | - borrow later used here, when `p` is dropped + | - borrow might be used here, when `p` is dropped and runs the `Drop` code for type `WrapMayNotDangle` error[E0506]: cannot assign to `v[..]` because it is borrowed --> $DIR/drop-no-may-dangle.rs:33:5 @@ -19,7 +19,7 @@ LL | v[0] += 1; //~ ERROR cannot assign to `v[..]` because it is borrowed | ^^^^^^^^^ assignment to borrowed `v[..]` occurs here LL | } - | - borrow later used here, when `p` is dropped + | - borrow might be used here, when `p` is dropped and runs the `Drop` code for type `WrapMayNotDangle` error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/enum-drop-access.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/enum-drop-access.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/enum-drop-access.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/enum-drop-access.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,51 @@ +#![feature(nll)] + +enum DropOption { + Some(T), + None, +} + +impl Drop for DropOption { + fn drop(&mut self) {} +} + +// Dropping opt could access the value behind the reference, +fn drop_enum(opt: DropOption<&mut i32>) -> Option<&mut i32> { + match opt { + DropOption::Some(&mut ref mut r) => { //~ ERROR + Some(r) + }, + DropOption::None => None, + } +} + +fn optional_drop_enum(opt: Option>) -> Option<&mut i32> { + match opt { + Some(DropOption::Some(&mut ref mut r)) => { //~ ERROR + Some(r) + }, + Some(DropOption::None) | None => None, + } +} + +// Ok, dropping opt doesn't access the reference +fn optional_tuple(opt: Option<(&mut i32, String)>) -> Option<&mut i32> { + match opt { + Some((&mut ref mut r, _)) => { + Some(r) + }, + None => None, + } +} + +// Ok, dropping res doesn't access the Ok case. +fn different_variants(res: Result<&mut i32, String>) -> Option<&mut i32> { + match res { + Ok(&mut ref mut r) => { + Some(r) + }, + Err(_) => None, + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/enum-drop-access.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/enum-drop-access.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/enum-drop-access.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/enum-drop-access.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +error[E0713]: borrow may still be in use when destructor runs + --> $DIR/enum-drop-access.rs:15:31 + | +LL | fn drop_enum(opt: DropOption<&mut i32>) -> Option<&mut i32> { + | - let's call the lifetime of this reference `'1` +LL | match opt { +LL | DropOption::Some(&mut ref mut r) => { //~ ERROR + | ^^^^^^^^^ +LL | Some(r) + | ------- returning this value requires that `*opt.0` is borrowed for `'1` +... +LL | } + | - here, drop of `opt` needs exclusive access to `*opt.0`, because the type `DropOption<&mut i32>` implements the `Drop` trait + +error[E0713]: borrow may still be in use when destructor runs + --> $DIR/enum-drop-access.rs:24:36 + | +LL | fn optional_drop_enum(opt: Option>) -> Option<&mut i32> { + | - let's call the lifetime of this reference `'1` +LL | match opt { +LL | Some(DropOption::Some(&mut ref mut r)) => { //~ ERROR + | ^^^^^^^^^ +LL | Some(r) + | ------- returning this value requires that `*opt.0.0` is borrowed for `'1` +... +LL | } + | - here, drop of `opt` needs exclusive access to `*opt.0.0`, because the type `DropOption<&mut i32>` implements the `Drop` trait + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0713`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/get_default.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/get_default.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/get_default.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/get_default.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -37,65 +37,47 @@ error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir) --> $DIR/get_default.rs:33:17 | +LL | fn ok(map: &mut Map) -> &String { + | - let's call the lifetime of this reference `'1` +LL | loop { LL | match map.get() { | --- immutable borrow occurs here +LL | Some(v) => { +LL | return v; + | - returning this value requires that `*map` is borrowed for `'1` ... LL | map.set(String::new()); // Ideally, this would not error. | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 26:1... - --> $DIR/get_default.rs:26:1 - | -LL | / fn ok(map: &mut Map) -> &String { -LL | | loop { -LL | | match map.get() { -LL | | Some(v) => { -... | -LL | | } -LL | | } - | |_^ error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir) --> $DIR/get_default.rs:45:17 | +LL | fn err(map: &mut Map) -> &String { + | - let's call the lifetime of this reference `'1` +LL | loop { LL | match map.get() { | --- immutable borrow occurs here LL | Some(v) => { LL | map.set(String::new()); // Both AST and MIR error here | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 41:1... - --> $DIR/get_default.rs:41:1 - | -LL | / fn err(map: &mut Map) -> &String { -LL | | loop { -LL | | match map.get() { -LL | | Some(v) => { -... | -LL | | } -LL | | } - | |_^ +... +LL | return v; + | - returning this value requires that `*map` is borrowed for `'1` error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir) --> $DIR/get_default.rs:51:17 | +LL | fn err(map: &mut Map) -> &String { + | - let's call the lifetime of this reference `'1` +LL | loop { LL | match map.get() { | --- immutable borrow occurs here ... +LL | return v; + | - returning this value requires that `*map` is borrowed for `'1` +... LL | map.set(String::new()); // Ideally, just AST would error here | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 41:1... - --> $DIR/get_default.rs:41:1 - | -LL | / fn err(map: &mut Map) -> &String { -LL | | loop { -LL | | match map.get() { -LL | | Some(v) => { -... | -LL | | } -LL | | } - | |_^ error: aborting due to 6 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/get_default.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/get_default.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/get_default.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/get_default.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -37,65 +37,47 @@ error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir) --> $DIR/get_default.rs:33:17 | +LL | fn ok(map: &mut Map) -> &String { + | - let's call the lifetime of this reference `'1` +LL | loop { LL | match map.get() { | --- immutable borrow occurs here +LL | Some(v) => { +LL | return v; + | - returning this value requires that `*map` is borrowed for `'1` ... LL | map.set(String::new()); // Ideally, this would not error. | ^^^ mutable borrow occurs here - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 26:1... - --> $DIR/get_default.rs:26:1 - | -LL | / fn ok(map: &mut Map) -> &String { -LL | | loop { -LL | | match map.get() { -LL | | Some(v) => { -... | -LL | | } -LL | | } - | |_^ error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir) --> $DIR/get_default.rs:45:17 | +LL | fn err(map: &mut Map) -> &String { + | - let's call the lifetime of this reference `'1` +LL | loop { LL | match map.get() { | --- immutable borrow occurs here LL | Some(v) => { LL | map.set(String::new()); // Both AST and MIR error here | ^^^ mutable borrow occurs here - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 41:1... - --> $DIR/get_default.rs:41:1 - | -LL | / fn err(map: &mut Map) -> &String { -LL | | loop { -LL | | match map.get() { -LL | | Some(v) => { -... | -LL | | } -LL | | } - | |_^ +... +LL | return v; + | - returning this value requires that `*map` is borrowed for `'1` error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable (Mir) --> $DIR/get_default.rs:51:17 | +LL | fn err(map: &mut Map) -> &String { + | - let's call the lifetime of this reference `'1` +LL | loop { LL | match map.get() { | --- immutable borrow occurs here ... +LL | return v; + | - returning this value requires that `*map` is borrowed for `'1` +... LL | map.set(String::new()); // Ideally, just AST would error here | ^^^ mutable borrow occurs here - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 41:1... - --> $DIR/get_default.rs:41:1 - | -LL | / fn err(map: &mut Map) -> &String { -LL | | loop { -LL | | match map.get() { -LL | | Some(v) => { -... | -LL | | } -LL | | } - | |_^ error: aborting due to 6 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-21114-ebfull.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-21114-ebfull.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-21114-ebfull.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-21114-ebfull.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// (this works, but only in NLL) +// compile-pass +#![feature(nll)] + +use std::collections::HashMap; +use std::sync::Mutex; + +fn i_used_to_be_able_to(foo: &Mutex>) -> Vec<(usize, usize)> { + let mut foo = foo.lock().unwrap(); + + foo.drain().collect() +} + +fn but_after_nightly_update_now_i_gotta(foo: &Mutex>) -> Vec<(usize, usize)> { + let mut foo = foo.lock().unwrap(); + + return foo.drain().collect(); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-21114-kixunil.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-21114-kixunil.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-21114-kixunil.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-21114-kixunil.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// (this works, but only in NLL) +// compile-pass +#![feature(nll)] + +fn from_stdin(min: u64) -> Vec { + use std::io::BufRead; + + let stdin = std::io::stdin(); + let stdin = stdin.lock(); + + stdin.lines() + .map(Result::unwrap) + .map(|val| val.parse()) + .map(Result::unwrap) + .filter(|val| *val >= min) + .collect() +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-21232-partial-init-and-erroneous-use.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-21232-partial-init-and-erroneous-use.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-21232-partial-init-and-erroneous-use.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-21232-partial-init-and-erroneous-use.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,66 @@ +// This test enumerates various cases of interest where a ADT or tuple is +// partially initialized and then used in some way that is wrong *even* +// after rust-lang/rust#54987 is implemented. +// +// See rust-lang/rust#21232, rust-lang/rust#54986, and rust-lang/rust#54987. +// +// See issue-21232-partial-init-and-use.rs for cases of tests that are +// meant to compile and run successfully once rust-lang/rust#54987 is +// implemented. + +#![feature(nll)] + +struct D { + x: u32, + s: S, +} + +struct S { + y: u32, + z: u32, +} + + +impl Drop for D { + fn drop(&mut self) { } +} + +fn cannot_partially_init_adt_with_drop() { + let d: D; + d.x = 10; + //~^ ERROR assign of possibly uninitialized variable: `d` [E0381] +} + +fn cannot_partially_init_mutable_adt_with_drop() { + let mut d: D; + d.x = 10; + //~^ ERROR assign of possibly uninitialized variable: `d` [E0381] +} + +fn cannot_partially_reinit_adt_with_drop() { + let mut d = D { x: 0, s: S{ y: 0, z: 0 } }; + drop(d); + d.x = 10; + //~^ ERROR assign of moved value: `d` [E0382] +} + +fn cannot_partially_init_inner_adt_via_outer_with_drop() { + let d: D; + d.s.y = 20; + //~^ ERROR assign to part of possibly uninitialized variable: `d` [E0381] +} + +fn cannot_partially_init_inner_adt_via_mutable_outer_with_drop() { + let mut d: D; + d.s.y = 20; + //~^ ERROR assign to part of possibly uninitialized variable: `d` [E0381] +} + +fn cannot_partially_reinit_inner_adt_via_outer_with_drop() { + let mut d = D { x: 0, s: S{ y: 0, z: 0} }; + drop(d); + d.s.y = 20; + //~^ ERROR assign to part of moved value: `d` [E0382] +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-21232-partial-init-and-erroneous-use.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-21232-partial-init-and-erroneous-use.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-21232-partial-init-and-erroneous-use.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-21232-partial-init-and-erroneous-use.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,48 @@ +error[E0381]: assign of possibly uninitialized variable: `d` + --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:30:5 + | +LL | d.x = 10; + | ^^^^^^^^ use of possibly uninitialized `d` + +error[E0381]: assign of possibly uninitialized variable: `d` + --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:36:5 + | +LL | d.x = 10; + | ^^^^^^^^ use of possibly uninitialized `d` + +error[E0382]: assign of moved value: `d` + --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:43:5 + | +LL | drop(d); + | - value moved here +LL | d.x = 10; + | ^^^^^^^^ value assigned here after move + | + = note: move occurs because `d` has type `D`, which does not implement the `Copy` trait + +error[E0381]: assign to part of possibly uninitialized variable: `d` + --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:49:5 + | +LL | d.s.y = 20; + | ^^^^^^^^^^ use of possibly uninitialized `d.s` + +error[E0381]: assign to part of possibly uninitialized variable: `d` + --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:55:5 + | +LL | d.s.y = 20; + | ^^^^^^^^^^ use of possibly uninitialized `d.s` + +error[E0382]: assign to part of moved value: `d` + --> $DIR/issue-21232-partial-init-and-erroneous-use.rs:62:5 + | +LL | drop(d); + | - value moved here +LL | d.s.y = 20; + | ^^^^^^^^^^ value partially assigned here after move + | + = note: move occurs because `d` has type `D`, which does not implement the `Copy` trait + +error: aborting due to 6 previous errors + +Some errors occurred: E0381, E0382. +For more information about an error, try `rustc --explain E0381`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-21232-partial-init-and-use.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-21232-partial-init-and-use.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-21232-partial-init-and-use.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-21232-partial-init-and-use.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,311 @@ +// This test enumerates various cases of interest for partial +// [re]initialization of ADTs and tuples. +// +// See rust-lang/rust#21232, rust-lang/rust#54986, and rust-lang/rust#54987. +// +// All of tests in this file are expected to change from being +// rejected, at least under NLL (by rust-lang/rust#54986) to being +// **accepted** when rust-lang/rust#54987 is implemented. +// (That's why there are assertions in the code.) +// +// See issue-21232-partial-init-and-erroneous-use.rs for cases of +// tests that are meant to continue failing to compile once +// rust-lang/rust#54987 is implemented. + +#![feature(nll)] + +struct S { + x: u32, + + // Note that even though `y` may implement `Drop`, under #54987 we + // will still allow partial initialization of `S` itself. + y: Y, +} + +enum Void { } + +type B = Box; + +impl S { fn new() -> Self { S { x: 0, y: Box::new(0) } } } + +fn borrow_s(s: &S) { assert_eq!(s.x, 10); assert_eq!(*s.y, 20); } +fn move_s(s: S) { assert_eq!(s.x, 10); assert_eq!(*s.y, 20); } +fn borrow_field(x: &u32) { assert_eq!(*x, 10); } + +type T = (u32, B); +type Tvoid = (u32, Void); + +fn borrow_t(t: &T) { assert_eq!(t.0, 10); assert_eq!(*t.1, 20); } +fn move_t(t: T) { assert_eq!(t.0, 10); assert_eq!(*t.1, 20); } + +struct Q { + v: u32, + r: R, +} + +struct R { + w: u32, + f: F, +} + +impl Q { fn new(f: F) -> Self { Q { v: 0, r: R::new(f) } } } +impl R { fn new(f: F) -> Self { R { w: 0, f } } } + +// Axes to cover: +// * local/field: Is the structure in a local or a field +// * fully/partial/void: Are we fully initializing it before using any part? +// Is whole type empty due to a void component? +// * init/reinit: First initialization, or did we previously inititalize and then move out? +// * struct/tuple: Is this a struct or a (X, Y). +// +// As a shorthand for the cases above, adding a numeric summary to +// each test's fn name to denote each point on each axis. +// +// E.g. 1000 = field fully init struct; 0211 = local void reinit tuple + +// It got pretty monotonous writing the same code over and over, and I +// feared I would forget details. So I abstracted some desiderata into +// macros. But I left the initialization code inline, because that's +// where the errors for #54986 will be emitted. + +macro_rules! use_fully { + (struct $s:expr) => { { + borrow_field(& $s.x ); + borrow_s(& $s ); + move_s( $s ); + } }; + + (tuple $t:expr) => { { + borrow_field(& $t.0 ); + borrow_t(& $t ); + move_t( $t ); + } } +} + +macro_rules! use_part { + (struct $s:expr) => { { + borrow_field(& $s.x ); + match $s { S { ref x, y: _ } => { borrow_field(x); } } + } }; + + (tuple $t:expr) => { { + borrow_field(& $t.0 ); + match $t { (ref x, _) => { borrow_field(x); } } + } } +} + +fn test_0000_local_fully_init_and_use_struct() { + let s: S; + s.x = 10; s.y = Box::new(20); + //~^ ERROR assign to part of possibly uninitialized variable: `s` [E0381] + use_fully!(struct s); +} + +fn test_0001_local_fully_init_and_use_tuple() { + let t: T; + t.0 = 10; t.1 = Box::new(20); + //~^ ERROR assign to part of possibly uninitialized variable: `t` [E0381] + use_fully!(tuple t); +} + +fn test_0010_local_fully_reinit_and_use_struct() { + let mut s: S = S::new(); drop(s); + s.x = 10; s.y = Box::new(20); + //~^ ERROR assign to part of moved value: `s` [E0382] + use_fully!(struct s); +} + +fn test_0011_local_fully_reinit_and_use_tuple() { + let mut t: T = (0, Box::new(0)); drop(t); + t.0 = 10; t.1 = Box::new(20); + //~^ ERROR assign to part of moved value: `t` [E0382] + use_fully!(tuple t); +} + +fn test_0100_local_partial_init_and_use_struct() { + let s: S; + s.x = 10; + //~^ ERROR assign to part of possibly uninitialized variable: `s` [E0381] + use_part!(struct s); +} + +fn test_0101_local_partial_init_and_use_tuple() { + let t: T; + t.0 = 10; + //~^ ERROR assign to part of possibly uninitialized variable: `t` [E0381] + use_part!(tuple t); +} + +fn test_0110_local_partial_reinit_and_use_struct() { + let mut s: S = S::new(); drop(s); + s.x = 10; + //~^ ERROR assign to part of moved value: `s` [E0382] + use_part!(struct s); +} + +fn test_0111_local_partial_reinit_and_use_tuple() { + let mut t: T = (0, Box::new(0)); drop(t); + t.0 = 10; + //~^ ERROR assign to part of moved value: `t` [E0382] + use_part!(tuple t); +} + +fn test_0200_local_void_init_and_use_struct() { + let s: S; + s.x = 10; + //~^ ERROR assign to part of possibly uninitialized variable: `s` [E0381] + use_part!(struct s); +} + +fn test_0201_local_void_init_and_use_tuple() { + let t: Tvoid; + t.0 = 10; + //~^ ERROR assign to part of possibly uninitialized variable: `t` [E0381] + use_part!(tuple t); +} + +// NOTE: uniform structure of tests here makes n21n (aka combining +// Void with Reinit) an (even more) senseless case, as we cannot +// safely create initial instance containing Void to move out of and +// then reinitialize. While I was tempted to sidestep this via some +// unsafe code (eek), lets just instead not encode such tests. + +// fn test_0210_local_void_reinit_and_use_struct() { unimplemented!() } +// fn test_0211_local_void_reinit_and_use_tuple() { unimplemented!() } + +fn test_1000_field_fully_init_and_use_struct() { + let q: Q>; + q.r.f.x = 10; q.r.f.y = Box::new(20); + //~^ ERROR assign to part of possibly uninitialized variable: `q` [E0381] + use_fully!(struct q.r.f); +} + +fn test_1001_field_fully_init_and_use_tuple() { + let q: Q; + q.r.f.0 = 10; q.r.f.1 = Box::new(20); + //~^ ERROR assign to part of possibly uninitialized variable: `q` [E0381] + use_fully!(tuple q.r.f); +} + +fn test_1010_field_fully_reinit_and_use_struct() { + let mut q: Q> = Q::new(S::new()); drop(q.r); + q.r.f.x = 10; q.r.f.y = Box::new(20); + //~^ ERROR assign to part of moved value: `q.r` [E0382] + use_fully!(struct q.r.f); +} + +fn test_1011_field_fully_reinit_and_use_tuple() { + let mut q: Q = Q::new((0, Box::new(0))); drop(q.r); + q.r.f.0 = 10; q.r.f.1 = Box::new(20); + //~^ ERROR assign to part of moved value: `q.r` [E0382] + use_fully!(tuple q.r.f); +} + +fn test_1100_field_partial_init_and_use_struct() { + let q: Q>; + q.r.f.x = 10; + //~^ ERROR assign to part of possibly uninitialized variable: `q` [E0381] + use_part!(struct q.r.f); +} + +fn test_1101_field_partial_init_and_use_tuple() { + let q: Q; + q.r.f.0 = 10; + //~^ ERROR assign to part of possibly uninitialized variable: `q` [E0381] + use_part!(tuple q.r.f); +} + +fn test_1110_field_partial_reinit_and_use_struct() { + let mut q: Q> = Q::new(S::new()); drop(q.r); + q.r.f.x = 10; + //~^ ERROR assign to part of moved value: `q.r` [E0382] + use_part!(struct q.r.f); +} + +fn test_1111_field_partial_reinit_and_use_tuple() { + let mut q: Q = Q::new((0, Box::new(0))); drop(q.r); + q.r.f.0 = 10; + //~^ ERROR assign to part of moved value: `q.r` [E0382] + use_part!(tuple q.r.f); +} + +fn test_1200_field_void_init_and_use_struct() { + let mut q: Q>; + q.r.f.x = 10; + //~^ ERROR assign to part of possibly uninitialized variable: `q` [E0381] + use_part!(struct q.r.f); +} + +fn test_1201_field_void_init_and_use_tuple() { + let mut q: Q; + q.r.f.0 = 10; + //~^ ERROR assign to part of possibly uninitialized variable: `q` [E0381] + use_part!(tuple q.r.f); +} + +// See NOTE abve. + +// fn test_1210_field_void_reinit_and_use_struct() { unimplemented!() } +// fn test_1211_field_void_reinit_and_use_tuple() { unimplemented!() } + +// The below are some additional cases of interest that have been +// transcribed from other bugs based on old erroneous codegen when we +// encountered partial writes. + +fn issue_26996() { + let mut c = (1, "".to_owned()); + match c { + c2 => { + c.0 = 2; //~ ERROR assign to part of moved value + assert_eq!(c2.0, 1); + } + } +} + +fn issue_27021() { + let mut c = (1, (1, "".to_owned())); + match c { + c2 => { + (c.1).0 = 2; //~ ERROR assign to part of moved value + assert_eq!((c2.1).0, 1); + } + } + + let mut c = (1, (1, (1, "".to_owned()))); + match c.1 { + c2 => { + ((c.1).1).0 = 3; //~ ERROR assign to part of moved value + assert_eq!((c2.1).0, 1); + } + } +} + +fn main() { + test_0000_local_fully_init_and_use_struct(); + test_0001_local_fully_init_and_use_tuple(); + test_0010_local_fully_reinit_and_use_struct(); + test_0011_local_fully_reinit_and_use_tuple(); + test_0100_local_partial_init_and_use_struct(); + test_0101_local_partial_init_and_use_tuple(); + test_0110_local_partial_reinit_and_use_struct(); + test_0111_local_partial_reinit_and_use_tuple(); + test_0200_local_void_init_and_use_struct(); + test_0201_local_void_init_and_use_tuple(); + // test_0210_local_void_reinit_and_use_struct(); + // test_0211_local_void_reinit_and_use_tuple(); + test_1000_field_fully_init_and_use_struct(); + test_1001_field_fully_init_and_use_tuple(); + test_1010_field_fully_reinit_and_use_struct(); + test_1011_field_fully_reinit_and_use_tuple(); + test_1100_field_partial_init_and_use_struct(); + test_1101_field_partial_init_and_use_tuple(); + test_1110_field_partial_reinit_and_use_struct(); + test_1111_field_partial_reinit_and_use_tuple(); + test_1200_field_void_init_and_use_struct(); + test_1201_field_void_init_and_use_tuple(); + // test_1210_field_void_reinit_and_use_struct(); + // test_1211_field_void_reinit_and_use_tuple(); + + issue_26996(); + issue_27021(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-21232-partial-init-and-use.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-21232-partial-init-and-use.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-21232-partial-init-and-use.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-21232-partial-init-and-use.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,186 @@ +error[E0381]: assign to part of possibly uninitialized variable: `s` + --> $DIR/issue-21232-partial-init-and-use.rs:99:5 + | +LL | s.x = 10; s.y = Box::new(20); + | ^^^^^^^^ use of possibly uninitialized `s` + +error[E0381]: assign to part of possibly uninitialized variable: `t` + --> $DIR/issue-21232-partial-init-and-use.rs:106:5 + | +LL | t.0 = 10; t.1 = Box::new(20); + | ^^^^^^^^ use of possibly uninitialized `t` + +error[E0382]: assign to part of moved value: `s` + --> $DIR/issue-21232-partial-init-and-use.rs:113:5 + | +LL | let mut s: S = S::new(); drop(s); + | - value moved here +LL | s.x = 10; s.y = Box::new(20); + | ^^^^^^^^ value partially assigned here after move + | + = note: move occurs because `s` has type `S>`, which does not implement the `Copy` trait + +error[E0382]: assign to part of moved value: `t` + --> $DIR/issue-21232-partial-init-and-use.rs:120:5 + | +LL | let mut t: T = (0, Box::new(0)); drop(t); + | - value moved here +LL | t.0 = 10; t.1 = Box::new(20); + | ^^^^^^^^ value partially assigned here after move + | + = note: move occurs because `t` has type `(u32, std::boxed::Box)`, which does not implement the `Copy` trait + +error[E0381]: assign to part of possibly uninitialized variable: `s` + --> $DIR/issue-21232-partial-init-and-use.rs:127:5 + | +LL | s.x = 10; + | ^^^^^^^^ use of possibly uninitialized `s` + +error[E0381]: assign to part of possibly uninitialized variable: `t` + --> $DIR/issue-21232-partial-init-and-use.rs:134:5 + | +LL | t.0 = 10; + | ^^^^^^^^ use of possibly uninitialized `t` + +error[E0382]: assign to part of moved value: `s` + --> $DIR/issue-21232-partial-init-and-use.rs:141:5 + | +LL | let mut s: S = S::new(); drop(s); + | - value moved here +LL | s.x = 10; + | ^^^^^^^^ value partially assigned here after move + | + = note: move occurs because `s` has type `S>`, which does not implement the `Copy` trait + +error[E0382]: assign to part of moved value: `t` + --> $DIR/issue-21232-partial-init-and-use.rs:148:5 + | +LL | let mut t: T = (0, Box::new(0)); drop(t); + | - value moved here +LL | t.0 = 10; + | ^^^^^^^^ value partially assigned here after move + | + = note: move occurs because `t` has type `(u32, std::boxed::Box)`, which does not implement the `Copy` trait + +error[E0381]: assign to part of possibly uninitialized variable: `s` + --> $DIR/issue-21232-partial-init-and-use.rs:155:5 + | +LL | s.x = 10; + | ^^^^^^^^ use of possibly uninitialized `s` + +error[E0381]: assign to part of possibly uninitialized variable: `t` + --> $DIR/issue-21232-partial-init-and-use.rs:162:5 + | +LL | t.0 = 10; + | ^^^^^^^^ use of possibly uninitialized `t` + +error[E0381]: assign to part of possibly uninitialized variable: `q` + --> $DIR/issue-21232-partial-init-and-use.rs:178:5 + | +LL | q.r.f.x = 10; q.r.f.y = Box::new(20); + | ^^^^^^^^^^^^ use of possibly uninitialized `q.r.f` + +error[E0381]: assign to part of possibly uninitialized variable: `q` + --> $DIR/issue-21232-partial-init-and-use.rs:185:5 + | +LL | q.r.f.0 = 10; q.r.f.1 = Box::new(20); + | ^^^^^^^^^^^^ use of possibly uninitialized `q.r.f` + +error[E0382]: assign to part of moved value: `q.r` + --> $DIR/issue-21232-partial-init-and-use.rs:192:5 + | +LL | let mut q: Q> = Q::new(S::new()); drop(q.r); + | --- value moved here +LL | q.r.f.x = 10; q.r.f.y = Box::new(20); + | ^^^^^^^^^^^^ value partially assigned here after move + | + = note: move occurs because `q.r` has type `R>>`, which does not implement the `Copy` trait + +error[E0382]: assign to part of moved value: `q.r` + --> $DIR/issue-21232-partial-init-and-use.rs:199:5 + | +LL | let mut q: Q = Q::new((0, Box::new(0))); drop(q.r); + | --- value moved here +LL | q.r.f.0 = 10; q.r.f.1 = Box::new(20); + | ^^^^^^^^^^^^ value partially assigned here after move + | + = note: move occurs because `q.r` has type `R<(u32, std::boxed::Box)>`, which does not implement the `Copy` trait + +error[E0381]: assign to part of possibly uninitialized variable: `q` + --> $DIR/issue-21232-partial-init-and-use.rs:206:5 + | +LL | q.r.f.x = 10; + | ^^^^^^^^^^^^ use of possibly uninitialized `q.r.f` + +error[E0381]: assign to part of possibly uninitialized variable: `q` + --> $DIR/issue-21232-partial-init-and-use.rs:213:5 + | +LL | q.r.f.0 = 10; + | ^^^^^^^^^^^^ use of possibly uninitialized `q.r.f` + +error[E0382]: assign to part of moved value: `q.r` + --> $DIR/issue-21232-partial-init-and-use.rs:220:5 + | +LL | let mut q: Q> = Q::new(S::new()); drop(q.r); + | --- value moved here +LL | q.r.f.x = 10; + | ^^^^^^^^^^^^ value partially assigned here after move + | + = note: move occurs because `q.r` has type `R>>`, which does not implement the `Copy` trait + +error[E0382]: assign to part of moved value: `q.r` + --> $DIR/issue-21232-partial-init-and-use.rs:227:5 + | +LL | let mut q: Q = Q::new((0, Box::new(0))); drop(q.r); + | --- value moved here +LL | q.r.f.0 = 10; + | ^^^^^^^^^^^^ value partially assigned here after move + | + = note: move occurs because `q.r` has type `R<(u32, std::boxed::Box)>`, which does not implement the `Copy` trait + +error[E0381]: assign to part of possibly uninitialized variable: `q` + --> $DIR/issue-21232-partial-init-and-use.rs:234:5 + | +LL | q.r.f.x = 10; + | ^^^^^^^^^^^^ use of possibly uninitialized `q.r.f` + +error[E0381]: assign to part of possibly uninitialized variable: `q` + --> $DIR/issue-21232-partial-init-and-use.rs:241:5 + | +LL | q.r.f.0 = 10; + | ^^^^^^^^^^^^ use of possibly uninitialized `q.r.f` + +error[E0382]: assign to part of moved value: `c` + --> $DIR/issue-21232-partial-init-and-use.rs:259:13 + | +LL | c2 => { + | -- value moved here +LL | c.0 = 2; //~ ERROR assign to part of moved value + | ^^^^^^^ value partially assigned here after move + | + = note: move occurs because `c` has type `(i32, std::string::String)`, which does not implement the `Copy` trait + +error[E0382]: assign to part of moved value: `c` + --> $DIR/issue-21232-partial-init-and-use.rs:269:13 + | +LL | c2 => { + | -- value moved here +LL | (c.1).0 = 2; //~ ERROR assign to part of moved value + | ^^^^^^^^^^^ value partially assigned here after move + | + = note: move occurs because `c` has type `(i32, (i32, std::string::String))`, which does not implement the `Copy` trait + +error[E0382]: assign to part of moved value: `c.1` + --> $DIR/issue-21232-partial-init-and-use.rs:277:13 + | +LL | c2 => { + | -- value moved here +LL | ((c.1).1).0 = 3; //~ ERROR assign to part of moved value + | ^^^^^^^^^^^^^^^ value partially assigned here after move + | + = note: move occurs because `c.1` has type `(i32, (i32, std::string::String))`, which does not implement the `Copy` trait + +error: aborting due to 23 previous errors + +Some errors occurred: E0381, E0382. +For more information about an error, try `rustc --explain E0381`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-22323-temp-destruction.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-22323-temp-destruction.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-22323-temp-destruction.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-22323-temp-destruction.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// rust-lang/rust#22323: regression test demonstrating that NLL +// precisely tracks temporary destruction order. + +// compile-pass + +#![feature(nll)] + +fn main() { + let _s = construct().borrow().consume_borrowed(); +} + +fn construct() -> Value { Value } + +pub struct Value; + +impl Value { + fn borrow<'a>(&'a self) -> Borrowed<'a> { unimplemented!() } +} + +pub struct Borrowed<'a> { + _inner: Guard<'a, Value>, +} + +impl<'a> Borrowed<'a> { + fn consume_borrowed(self) -> String { unimplemented!() } +} + +pub struct Guard<'a, T: ?Sized + 'a> { + _lock: &'a T, +} + +impl<'a, T: ?Sized> Drop for Guard<'a, T> { fn drop(&mut self) {} } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-31567.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-31567.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-31567.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-31567.rs 2018-12-04 23:41:40.000000000 +0000 @@ -19,7 +19,7 @@ struct S(Box); fn get_dangling<'a>(v: VecWrapper<'a>) -> &'a u32 { - let s_inner: &'a S = &*v.0; //~ ERROR `*v.0` does not live long enough + let s_inner: &'a S = &*v.0; //~ ERROR borrow may still be in use when destructor runs [E0713] &s_inner.0 } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-31567.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-31567.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-31567.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-31567.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,18 +1,16 @@ -error[E0597]: `*v.0` does not live long enough +error[E0713]: borrow may still be in use when destructor runs --> $DIR/issue-31567.rs:22:26 | -LL | let s_inner: &'a S = &*v.0; //~ ERROR `*v.0` does not live long enough - | ^^^^^ borrowed value does not live long enough +LL | fn get_dangling<'a>(v: VecWrapper<'a>) -> &'a u32 { + | -- lifetime `'a` defined here +LL | let s_inner: &'a S = &*v.0; //~ ERROR borrow may still be in use when destructor runs [E0713] + | ----- ^^^^^ + | | + | type annotation requires that `*v.0` is borrowed for `'a` LL | &s_inner.0 LL | } - | - `*v.0` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 21:17... - --> $DIR/issue-31567.rs:21:17 - | -LL | fn get_dangling<'a>(v: VecWrapper<'a>) -> &'a u32 { - | ^^ + | - here, drop of `v` needs exclusive access to `*v.0`, because the type `VecWrapper<'_>` implements the `Drop` trait error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0713`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-32382-index-assoc-type-with-lifetime.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-32382-index-assoc-type-with-lifetime.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-32382-index-assoc-type-with-lifetime.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-32382-index-assoc-type-with-lifetime.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,42 @@ +#![feature(nll)] +// compile-pass + +// rust-lang/rust#32382: Borrow checker used to complain about +// `foobar_3` in the `impl` below, presumably due to some interaction +// between the use of a lifetime in the associated type and the use of +// the overloaded operator[]. This regression test ensures that we do +// not resume complaining about it in the future. + + +use std::marker::PhantomData; +use std::ops::Index; + +pub trait Context: Clone { + type Container: ?Sized; + fn foobar_1( container: &Self::Container ) -> &str; + fn foobar_2( container: &Self::Container ) -> &str; + fn foobar_3( container: &Self::Container ) -> &str; +} + +#[derive(Clone)] +struct Foobar<'a> { + phantom: PhantomData<&'a ()> +} + +impl<'a> Context for Foobar<'a> { + type Container = [&'a str]; + + fn foobar_1<'r>( container: &'r [&'a str] ) -> &'r str { + container[0] + } + + fn foobar_2<'r>( container: &'r Self::Container ) -> &'r str { + container.index( 0 ) + } + + fn foobar_3<'r>( container: &'r Self::Container ) -> &'r str { + container[0] + } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-47470.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-47470.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-47470.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-47470.rs 2018-12-04 23:41:40.000000000 +0000 @@ -24,7 +24,7 @@ type Assoc = &'a u32; fn get(self) -> Self::Assoc { let local = 42; - &local //~ ERROR `local` does not live long enough + &local //~ ERROR cannot return reference to local variable `local` } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-47470.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-47470.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-47470.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-47470.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,17 +1,9 @@ -error[E0597]: `local` does not live long enough +error[E0515]: cannot return reference to local variable `local` --> $DIR/issue-47470.rs:27:9 | -LL | &local //~ ERROR `local` does not live long enough - | ^^^^^^ borrowed value does not live long enough -LL | } - | - `local` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the impl at 23:6... - --> $DIR/issue-47470.rs:23:6 - | -LL | impl<'a> Bar for Foo<'a> { - | ^^ +LL | &local //~ ERROR cannot return reference to local variable `local` + | ^^^^^^ returns a reference to data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-50716.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-50716.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-50716.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-50716.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,11 +1,11 @@ -error: borrowed data escapes outside of function +error: unsatisfied lifetime constraints --> $DIR/issue-50716.rs:25:14 | LL | fn foo<'a, T: 'static>(s: Box<<&'a T as A>::X>) - | - `s` is a reference that is only valid in the function body + | -- lifetime `'a` defined here ... LL | let _x = *s; //~ ERROR - | ^^ `s` escapes the function body here + | ^^ proving this value is `Sized` requires that `'a` must outlive `'static` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-51191.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-51191.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-51191.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-51191.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(nll)] + +struct Struct; + +impl Struct { + fn bar(self: &mut Self) { + //~^ WARN function cannot return without recursing + (&mut self).bar(); + //~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable [E0596] + } + + fn imm(self) { + (&mut self).bar(); + //~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable [E0596] + } + + fn mtbl(mut self) { + (&mut self).bar(); + } + + fn immref(&self) { + (&mut self).bar(); + //~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable [E0596] + //~^^ ERROR cannot borrow data in a `&` reference as mutable [E0596] + } + + fn mtblref(&mut self) { + (&mut self).bar(); + //~^ ERROR cannot borrow `self` as mutable, as it is not declared as mutable [E0596] + } +} + +fn main () {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-51191.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-51191.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-51191.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-51191.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,53 @@ +warning: function cannot return without recursing + --> $DIR/issue-51191.rs:16:5 + | +LL | fn bar(self: &mut Self) { + | ^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing +LL | //~^ WARN function cannot return without recursing +LL | (&mut self).bar(); + | ----------------- recursive call site + | + = note: #[warn(unconditional_recursion)] on by default + = help: a `loop` may express intention better if this is on purpose + +error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable + --> $DIR/issue-51191.rs:18:9 + | +LL | (&mut self).bar(); + | ^^^^^^^^^^^ + | | + | cannot borrow as mutable + | try removing `&mut` here + +error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable + --> $DIR/issue-51191.rs:23:9 + | +LL | fn imm(self) { + | ---- help: consider changing this to be mutable: `mut self` +LL | (&mut self).bar(); + | ^^^^^^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable + --> $DIR/issue-51191.rs:32:9 + | +LL | (&mut self).bar(); + | ^^^^^^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow data in a `&` reference as mutable + --> $DIR/issue-51191.rs:32:9 + | +LL | (&mut self).bar(); + | ^^^^^^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable + --> $DIR/issue-51191.rs:38:9 + | +LL | (&mut self).bar(); + | ^^^^^^^^^^^ + | | + | cannot borrow as mutable + | try removing `&mut` here + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0596`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-51268.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-51268.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-51268.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-51268.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,19 +1,16 @@ error[E0502]: cannot borrow `self.thing` as mutable because it is also borrowed as immutable --> $DIR/issue-51268.rs:28:9 | -LL | self.thing.bar(|| { - | ^ -- immutable borrow occurs here - | _________| - | |_________| - | || -LL | || //~^ ERROR cannot borrow `self.thing` as mutable because it is also borrowed as immutable [E0502] -LL | || &self.number; - | || ---- first borrow occurs due to use of `self` in closure -LL | || }); - | || ^ - | ||__________| - | |___________mutable borrow occurs here - | borrow later used here +LL | self.thing.bar(|| { + | ^ --- -- immutable borrow occurs here + | | | + | _________| immutable borrow later used by call + | | +LL | | //~^ ERROR cannot borrow `self.thing` as mutable because it is also borrowed as immutable [E0502] +LL | | &self.number; + | | ---- first borrow occurs due to use of `self` in closure +LL | | }); + | |__________^ mutable borrow occurs here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-51512.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-51512.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-51512.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-51512.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,5 +15,5 @@ let range = 0..1; let r = range; let x = range.start; - //~^ ERROR use of moved value: `range.start` [E0382] + //~^ ERROR use of moved value: `range` [E0382] } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-51512.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-51512.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-51512.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-51512.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ -error[E0382]: use of moved value: `range.start` +error[E0382]: use of moved value: `range` --> $DIR/issue-51512.rs:17:13 | LL | let r = range; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// rust-lang/rust#52059: Regardless of whether you are moving out of a +// Drop type or just introducing an inadvertent alias via a borrow of +// one of its fields, it is useful to be reminded of the significance +// of the fact that the type implements Drop. + +#![feature(nll)] +#![allow(dead_code)] + +pub struct S<'a> { url: &'a mut String } + +impl<'a> Drop for S<'a> { fn drop(&mut self) { } } + +fn finish_1(s: S) -> &mut String { + s.url +} +//~^^ ERROR borrow may still be in use when destructor runs + +fn finish_2(s: S) -> &mut String { + let p = &mut *s.url; p +} +//~^^ ERROR borrow may still be in use when destructor runs + +fn finish_3(s: S) -> &mut String { + let p: &mut _ = s.url; p +} +//~^^ ERROR borrow may still be in use when destructor runs + +fn finish_4(s: S) -> &mut String { + let p = s.url; p +} +//~^^ ERROR cannot move out of type `S<'_>`, which implements the `Drop` trait + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52059-report-when-borrow-and-drop-conflict.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +error[E0713]: borrow may still be in use when destructor runs + --> $DIR/issue-52059-report-when-borrow-and-drop-conflict.rs:14:5 + | +LL | fn finish_1(s: S) -> &mut String { + | - has type `S<'1>` +LL | s.url + | ^^^^^ returning this value requires that `*s.url` is borrowed for `'1` +LL | } + | - here, drop of `s` needs exclusive access to `*s.url`, because the type `S<'_>` implements the `Drop` trait + +error[E0713]: borrow may still be in use when destructor runs + --> $DIR/issue-52059-report-when-borrow-and-drop-conflict.rs:19:13 + | +LL | fn finish_2(s: S) -> &mut String { + | - has type `S<'1>` +LL | let p = &mut *s.url; p + | ^^^^^^^^^^^ - returning this value requires that `*s.url` is borrowed for `'1` +LL | } + | - here, drop of `s` needs exclusive access to `*s.url`, because the type `S<'_>` implements the `Drop` trait + +error[E0713]: borrow may still be in use when destructor runs + --> $DIR/issue-52059-report-when-borrow-and-drop-conflict.rs:24:21 + | +LL | fn finish_3(s: S) -> &mut String { + | - has type `S<'1>` +LL | let p: &mut _ = s.url; p + | ^^^^^ - returning this value requires that `*s.url` is borrowed for `'1` +LL | } + | - here, drop of `s` needs exclusive access to `*s.url`, because the type `S<'_>` implements the `Drop` trait + +error[E0509]: cannot move out of type `S<'_>`, which implements the `Drop` trait + --> $DIR/issue-52059-report-when-borrow-and-drop-conflict.rs:29:13 + | +LL | let p = s.url; p + | ^^^^^ + | | + | cannot move out of here + | help: consider borrowing here: `&s.url` + +error: aborting due to 4 previous errors + +Some errors occurred: E0509, E0713. +For more information about an error, try `rustc --explain E0509`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52086.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52086.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52086.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52086.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(nll)] + +use std::rc::Rc; +use std::sync::Arc; + +struct Bar { field: Vec } + +fn main() { + let x = Rc::new(Bar { field: vec![] }); + drop(x.field); + + let y = Arc::new(Bar { field: vec![] }); + drop(y.field); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52086.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52086.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52086.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52086.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +error[E0507]: cannot move out of an `Rc` + --> $DIR/issue-52086.rs:20:10 + | +LL | drop(x.field); + | ^^^^^^^ cannot move out of an `Rc` + +error[E0507]: cannot move out of an `Arc` + --> $DIR/issue-52086.rs:23:10 + | +LL | drop(y.field); + | ^^^^^^^ cannot move out of an `Arc` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52113.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52113.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52113.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52113.rs 2018-12-04 23:41:40.000000000 +0000 @@ -40,11 +40,11 @@ } fn produce_err<'a, 'b: 'a>(data: &'b mut Vec<&'b u32>, value: &'a u32) -> impl Bazinga + 'b { - let x = move || { //~ ERROR unsatisfied lifetime constraints + let x = move || { let value: &'a u32 = value; data.push(value); }; - x + x //~ ERROR unsatisfied lifetime constraints } fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52113.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52113.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52113.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52113.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,12 +1,13 @@ error: unsatisfied lifetime constraints - --> $DIR/issue-52113.rs:43:9 + --> $DIR/issue-52113.rs:47:5 | LL | fn produce_err<'a, 'b: 'a>(data: &'b mut Vec<&'b u32>, value: &'a u32) -> impl Bazinga + 'b { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here -LL | let x = move || { //~ ERROR unsatisfied lifetime constraints - | ^ requires that `'a` must outlive `'b` +... +LL | x //~ ERROR unsatisfied lifetime constraints + | ^ returning this value requires that `'a` must outlive `'b` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52534-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52534-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52534-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52534-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,53 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(nll)] +#![allow(warnings)] + +struct Test; + +impl Test { + fn bar(&self, x: &u32) -> &u32 { + let x = 22; + &x + } +} + +fn foo(x: &u32) -> &u32 { + let x = 22; + &x +} + +fn baz(x: &u32) -> &&u32 { + let x = 22; + &&x +} + +fn foobazbar<'a>(x: u32, y: &'a u32) -> &'a u32 { + let x = 22; + &x +} + +fn foobar<'a>(x: &'a u32) -> &'a u32 { + let x = 22; + &x +} + +fn foobaz<'a, 'b>(x: &'a u32, y: &'b u32) -> &'a u32 { + let x = 22; + &x +} + +fn foobarbaz<'a, 'b>(x: &'a u32, y: &'b u32, z: &'a u32) -> &'a u32 { + let x = 22; + &x +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52534-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52534-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52534-1.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52534-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,57 @@ +error[E0515]: cannot return reference to local variable `x` + --> $DIR/issue-52534-1.rs:19:9 + | +LL | &x + | ^^ returns a reference to data owned by the current function + +error[E0515]: cannot return reference to local variable `x` + --> $DIR/issue-52534-1.rs:25:5 + | +LL | &x + | ^^ returns a reference to data owned by the current function + +error[E0515]: cannot return value referencing local variable `x` + --> $DIR/issue-52534-1.rs:30:5 + | +LL | &&x + | ^-- + | || + | |`x` is borrowed here + | returns a value referencing data owned by the current function + +error[E0515]: cannot return reference to temporary value + --> $DIR/issue-52534-1.rs:30:5 + | +LL | &&x + | ^-- + | || + | |temporary value created here + | returns a reference to data owned by the current function + +error[E0515]: cannot return reference to local variable `x` + --> $DIR/issue-52534-1.rs:35:5 + | +LL | &x + | ^^ returns a reference to data owned by the current function + +error[E0515]: cannot return reference to local variable `x` + --> $DIR/issue-52534-1.rs:40:5 + | +LL | &x + | ^^ returns a reference to data owned by the current function + +error[E0515]: cannot return reference to local variable `x` + --> $DIR/issue-52534-1.rs:45:5 + | +LL | &x + | ^^ returns a reference to data owned by the current function + +error[E0515]: cannot return reference to local variable `x` + --> $DIR/issue-52534-1.rs:50:5 + | +LL | &x + | ^^ returns a reference to data owned by the current function + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52534-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52534-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52534-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52534-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(nll)] +#![allow(warnings)] + +fn foo(x: &u32) -> &u32 { + let y; + + { + let x = 32; + y = &x + } + + println!("{}", y); + x +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52534-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52534-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52534-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52534-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error[E0597]: `x` does not live long enough + --> $DIR/issue-52534-2.rs:19:9 + | +LL | y = &x + | ^^^^^^ borrowed value does not live long enough +LL | } + | - `x` dropped here while still borrowed +LL | +LL | println!("{}", y); + | - borrow later used here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52534.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52534.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52534.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52534.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(nll)] +#![allow(warnings)] + +fn foo(_: impl FnOnce(&u32) -> &u32) { +} + +fn baz(_: impl FnOnce(&u32, u32) -> &u32) { +} + +fn bar() { + let x = 22; + foo(|a| &x) +} + +fn foobar() { + let y = 22; + baz(|first, second| &y) +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52534.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52534.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52534.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52534.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +error[E0597]: `x` does not live long enough + --> $DIR/issue-52534.rs:22:14 + | +LL | foo(|a| &x) + | - ^ `x` would have to be valid for `'0`... + | | + | has type `&'0 u32` +LL | } + | - ...but `x` will be dropped here, when the function `bar` returns + | + = note: functions cannot return a borrow to data owned within the function's scope, functions can only return borrows to data passed as arguments + = note: to learn more, visit + +error[E0597]: `y` does not live long enough + --> $DIR/issue-52534.rs:27:26 + | +LL | baz(|first, second| &y) + | ----- ^ `y` would have to be valid for `'0`... + | | + | has type `&'0 u32` +LL | } + | - ...but `y` will be dropped here, when the function `foobar` returns + | + = note: functions cannot return a borrow to data owned within the function's scope, functions can only return borrows to data passed as arguments + = note: to learn more, visit + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52663-trait-object.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52663-trait-object.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52663-trait-object.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52663-trait-object.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax)] +#![feature(nll)] + +trait Foo { fn get(&self); } + +impl Foo for A { + fn get(&self) { } +} + +fn main() { + let _ = { + let tmp0 = 3; + let tmp1 = &tmp0; + box tmp1 as Box + }; + //~^^^ ERROR `tmp0` does not live long enough +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52663-trait-object.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52663-trait-object.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52663-trait-object.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52663-trait-object.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +error[E0597]: `tmp0` does not live long enough + --> $DIR/issue-52663-trait-object.rs:23:20 + | +LL | let tmp1 = &tmp0; + | ^^^^^ borrowed value does not live long enough +LL | box tmp1 as Box + | ------------------------- borrow later captured here by trait object +LL | }; + | - `tmp0` dropped here while still borrowed + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52669.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52669.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52669.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52669.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(nll)] + +struct A { + b: B, +} + +#[derive(Clone)] +struct B; + +fn foo(_: A) {} + +fn bar(mut a: A) -> B { + a.b = B; + foo(a); + a.b.clone() +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52669.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52669.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52669.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52669.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +error[E0382]: borrow of moved value: `a.b` + --> $DIR/issue-52669.rs:25:5 + | +LL | foo(a); + | - value moved here +LL | a.b.clone() + | ^^^ value borrowed here after move + | + = note: move occurs because `a` has type `A`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52742.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52742.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52742.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52742.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,6 @@ #![feature(nll)] #![feature(in_band_lifetimes)] -#![feature(impl_header_lifetime_elision)] struct Foo<'a, 'b> { x: &'a u32, diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52742.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52742.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-52742.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-52742.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,12 +1,12 @@ error: unsatisfied lifetime constraints - --> $DIR/issue-52742.rs:26:9 + --> $DIR/issue-52742.rs:25:9 | LL | fn take_bar(&mut self, b: Bar<'_>) { | --------- -- let's call this `'1` | | | has type `&mut Foo<'_, '2>` LL | self.y = b.z - | ^^^^^^^^^^^^ requires that `'1` must outlive `'2` + | ^^^^^^^^^^^^ assignment requires that `'1` must outlive `'2` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-53040.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-53040.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-53040.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-53040.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(nll)] + +fn main() { + let mut v: Vec<()> = Vec::new(); + || &mut v; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-53040.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-53040.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-53040.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-53040.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +error: captured variable cannot escape `FnMut` closure body + --> $DIR/issue-53040.rs:15:8 + | +LL | || &mut v; + | - ^^^^^^ returns a reference to a captured variable which escapes the closure body + | | + | inferred to be a `FnMut` closure + | + = note: `FnMut` closures only have access to their captured variables while they are executing... + = note: ...therefore, they cannot allow references to captured variables to escape + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-53807.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-53807.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-53807.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-53807.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0382]: use of moved value + --> $DIR/issue-53807.rs:14:21 + | +LL | if let Some(thing) = maybe { + | ^^^^^ value moved here, in previous iteration of loop + | + = note: move occurs because value has type `std::vec::Vec`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-53807.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-53807.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-53807.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-53807.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn main(){ + let maybe = Some(vec![true, true]); + loop { + if let Some(thing) = maybe { + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-53807.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-53807.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-53807.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-53807.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +error[E0382]: use of partially moved value: `maybe` + --> $DIR/issue-53807.rs:14:30 + | +LL | if let Some(thing) = maybe { + | ----- ^^^^^ value used here after move + | | + | value moved here + | + = note: move occurs because the value has type `std::vec::Vec`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `(maybe as std::prelude::v1::Some).0` + --> $DIR/issue-53807.rs:14:21 + | +LL | if let Some(thing) = maybe { + | ^^^^^ value moved here in previous iteration of loop + | + = note: move occurs because the value has type `std::vec::Vec`, which does not implement the `Copy` trait + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-niconii.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-niconii.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-niconii.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-niconii.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +error[E0597]: `counter` does not live long enough + --> $DIR/issue-54556-niconii.rs:22:20 + | +LL | if let Ok(_) = counter.lock() { } + | ^^^^^^^------- + | | + | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... +... +LL | } + | - + | | + | `counter` dropped here while still borrowed + | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::result::Result, ()>` + | + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-niconii.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-niconii.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-niconii.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-niconii.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// This is a reduction of a concrete test illustrating a case that was +// annoying to Rust developer niconii (see comment thread on #21114). +// +// With resolving issue #54556, pnkfelix hopes that the new diagnostic +// output produced by NLL helps to *explain* the semantic significance +// of temp drop order, and thus why inserting a semi-colon after the +// `if let` expression in `main` works. + +struct Mutex; +struct MutexGuard<'a>(&'a Mutex); + +impl Drop for Mutex { fn drop(&mut self) { println!("Mutex::drop"); } } +impl<'a> Drop for MutexGuard<'a> { fn drop(&mut self) { println!("MutexGuard::drop"); } } + +impl Mutex { + fn lock(&self) -> Result { Ok(MutexGuard(self)) } +} + +fn main() { + let counter = Mutex; + + if let Ok(_) = counter.lock() { } + + // With this code as written, the dynamic semantics here implies + // that `Mutex::drop` for `counter` runs *before* + // `MutexGuard::drop`, which would be unsound since `MutexGuard` + // still has a reference to `counter`. + // + // The goal of #54556 is to explain that within a compiler + // diagnostic. +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-niconii.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-niconii.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-niconii.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-niconii.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error[E0597]: `counter` does not live long enough + --> $DIR/issue-54556-niconii.rs:22:20 + | +LL | if let Ok(_) = counter.lock() { } + | ^^^^^^^ borrowed value does not live long enough +... +LL | } + | - `counter` 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 + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-stephaneyfx.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-stephaneyfx.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-stephaneyfx.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-stephaneyfx.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +error[E0597]: `stmt` does not live long enough + --> $DIR/issue-54556-stephaneyfx.rs:27:21 + | +LL | let rows = Rows(&stmt); + | ^^^^^ borrowed value does not live long enough +LL | rows.map(|row| row).next() + | ------------------- a temporary with access to the borrow is created here ... +... +LL | } + | - + | | + | `stmt` dropped here while still borrowed + | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::iter::Map, [closure@$DIR/issue-54556-stephaneyfx.rs:28:14: 28:23]>` + | + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-stephaneyfx.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-stephaneyfx.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-stephaneyfx.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-stephaneyfx.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// This is a reduction of a concrete test illustrating a case that was +// annoying to Rust developer stephaneyfx (see issue #46413). +// +// With resolving issue #54556, pnkfelix hopes that the new diagnostic +// output produced by NLL helps to *explain* the semantic significance +// of temp drop order, and thus why storing the result in `x` and then +// returning `x` works. + +pub struct Statement; + +pub struct Rows<'stmt>(&'stmt Statement); + +impl<'stmt> Drop for Rows<'stmt> { + fn drop(&mut self) {} +} + +impl<'stmt> Iterator for Rows<'stmt> { + type Item = String; + + fn next(&mut self) -> Option { + None + } +} + +fn get_names() -> Option { + let stmt = Statement; + let rows = Rows(&stmt); + rows.map(|row| row).next() + // let x = rows.map(|row| row).next(); + // x + // + // Removing the map works too as does removing the Drop impl. +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-stephaneyfx.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-stephaneyfx.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-stephaneyfx.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-stephaneyfx.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error[E0597]: `stmt` does not live long enough + --> $DIR/issue-54556-stephaneyfx.rs:27:22 + | +LL | let rows = Rows(&stmt); + | ^^^^ borrowed value does not live long enough +... +LL | } + | - `stmt` 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 + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +error[E0597]: `_thing1` does not live long enough + --> $DIR/issue-54556-temps-in-tail-diagnostic.rs:5:11 + | +LL | D(&_thing1).end() + | --^^^^^^^^- + | | | + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... +LL | } + | - `_thing1` dropped here while still borrowed +LL | +LL | ; + | - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +fn main() { + { + let mut _thing1 = D(Box::new("thing1")); + // D("other").next(&_thing1).end() + D(&_thing1).end() + } + + ; +} + +#[derive(Debug)] +struct D(T); + +impl Drop for D { + fn drop(&mut self) { + println!("dropping {:?})", self); + } +} + +impl D { + fn next(&self, _other: U) -> D { D(_other) } + fn end(&self) { } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-temps-in-tail-diagnostic.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error[E0597]: `_thing1` does not live long enough + --> $DIR/issue-54556-temps-in-tail-diagnostic.rs:5:12 + | +LL | D(&_thing1).end() + | ^^^^^^^ borrowed value does not live long enough +LL | } + | - `_thing1` dropped here while still borrowed +LL | +LL | ; + | - borrowed value needs to live until here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-used-vs-unused-tails.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-used-vs-unused-tails.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-used-vs-unused-tails.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-used-vs-unused-tails.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,113 @@ +error[E0597]: `_t1` does not live long enough + --> $DIR/issue-54556-used-vs-unused-tails.rs:10:55 + | +LL | { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // suggest `;` + | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | + | | | `_t1` dropped here while still borrowed + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... + | + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. + +error[E0597]: `_t1` does not live long enough + --> $DIR/issue-54556-used-vs-unused-tails.rs:12:55 + | +LL | { { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } } ; // suggest `;` + | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | + | | | `_t1` dropped here while still borrowed + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... + | + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. + +error[E0597]: `_t1` does not live long enough + --> $DIR/issue-54556-used-vs-unused-tails.rs:14:55 + | +LL | { { let mut _t1 = D(Box::new("t1")); D(&_t1).end() }; } // suggest `;` + | --^^^^- -- ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | + | | | `_t1` dropped here while still borrowed + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... + | + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. + +error[E0597]: `_t1` does not live long enough + --> $DIR/issue-54556-used-vs-unused-tails.rs:16:55 + | +LL | let _ = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // suggest `;` + | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | + | | | `_t1` dropped here while still borrowed + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... + | + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. + +error[E0597]: `_t1` does not live long enough + --> $DIR/issue-54556-used-vs-unused-tails.rs:18:55 + | +LL | let _u = { let mut _t1 = D(Box::new("t1")); D(&_t1).unit() } ; // suggest `;` + | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | + | | | `_t1` dropped here while still borrowed + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... + | + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. + +error[E0597]: `_t1` does not live long enough + --> $DIR/issue-54556-used-vs-unused-tails.rs:20:55 + | +LL | let _x = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // `let x = ...; x` + | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | + | | | `_t1` dropped here while still borrowed + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... + | + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. + +error[E0597]: `_t1` does not live long enough + --> $DIR/issue-54556-used-vs-unused-tails.rs:24:55 + | +LL | _y = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // `let x = ...; x` + | --^^^^- - - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | | | + | | | `_t1` dropped here while still borrowed + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... + | + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. + +error[E0597]: `_t1` does not live long enough + --> $DIR/issue-54556-used-vs-unused-tails.rs:30:55 + | +LL | fn f_local_ref() { let mut _t1 = D(Box::new("t1")); D(&_t1).unit() } // suggest `;` + | --^^^^- - + | | | | + | | | `_t1` dropped here while still borrowed + | | | ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... + | + = note: The temporary is part of an expression at the end of a block. Consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped. + +error[E0597]: `_t1` does not live long enough + --> $DIR/issue-54556-used-vs-unused-tails.rs:32:55 + | +LL | fn f() -> String { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } // `let x = ...; x` + | --^^^^- - + | | | | + | | | `_t1` dropped here while still borrowed + | | | ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `D` + | | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... + | + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. + +error: aborting due to 9 previous errors + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-used-vs-unused-tails.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-used-vs-unused-tails.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-used-vs-unused-tails.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-used-vs-unused-tails.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,48 @@ +// Ths test case is exploring the space of how blocs with tail +// expressions and statements can be composed, trying to keep each +// case on one line so that we can compare them via a vertical scan +// with the human eye. + +// Each comment on the right side of the line is summarizing the +// expected suggestion from the diagnostic for issue #54556. + +fn main() { + { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // suggest `;` + + { { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } } ; // suggest `;` + + { { let mut _t1 = D(Box::new("t1")); D(&_t1).end() }; } // suggest `;` + + let _ = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // suggest `;` + + let _u = { let mut _t1 = D(Box::new("t1")); D(&_t1).unit() } ; // suggest `;` + + let _x = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // `let x = ...; x` + let _x = { let mut _t1 = D(Box::new("t1")); let x = D(&_t1).end(); x } ; // no error + + let mut _y; + _y = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // `let x = ...; x` + _y = { let mut _t1 = D(Box::new("t1")); let x = D(&_t1).end(); x } ; // no error +} + +fn f_param_ref(_t1: D>) { D(&_t1).unit() } // no error + +fn f_local_ref() { let mut _t1 = D(Box::new("t1")); D(&_t1).unit() } // suggest `;` + +fn f() -> String { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } // `let x = ...; x` + + +#[derive(Debug)] +struct D(T); + +impl Drop for D { + fn drop(&mut self) { + println!("dropping {:?})", self); + } +} + +impl D { + fn next(&self, _other: U) -> D { D(_other) } + fn end(&self) -> String { format!("End({:?})", self.0) } + fn unit(&self) { } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-used-vs-unused-tails.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-used-vs-unused-tails.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-used-vs-unused-tails.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-used-vs-unused-tails.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,86 @@ +error[E0597]: `_t1` does not live long enough + --> $DIR/issue-54556-used-vs-unused-tails.rs:10:56 + | +LL | { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // suggest `;` + | ^^^ - - borrowed value needs to live until here + | | | + | | `_t1` dropped here while still borrowed + | borrowed value does not live long enough + +error[E0597]: `_t1` does not live long enough + --> $DIR/issue-54556-used-vs-unused-tails.rs:12:56 + | +LL | { { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } } ; // suggest `;` + | ^^^ - - borrowed value needs to live until here + | | | + | | `_t1` dropped here while still borrowed + | borrowed value does not live long enough + +error[E0597]: `_t1` does not live long enough + --> $DIR/issue-54556-used-vs-unused-tails.rs:14:56 + | +LL | { { let mut _t1 = D(Box::new("t1")); D(&_t1).end() }; } // suggest `;` + | ^^^ -- borrowed value needs to live until here + | | | + | | `_t1` dropped here while still borrowed + | borrowed value does not live long enough + +error[E0597]: `_t1` does not live long enough + --> $DIR/issue-54556-used-vs-unused-tails.rs:16:56 + | +LL | let _ = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // suggest `;` + | ^^^ - - borrowed value needs to live until here + | | | + | | `_t1` dropped here while still borrowed + | borrowed value does not live long enough + +error[E0597]: `_t1` does not live long enough + --> $DIR/issue-54556-used-vs-unused-tails.rs:18:56 + | +LL | let _u = { let mut _t1 = D(Box::new("t1")); D(&_t1).unit() } ; // suggest `;` + | ^^^ - - borrowed value needs to live until here + | | | + | | `_t1` dropped here while still borrowed + | borrowed value does not live long enough + +error[E0597]: `_t1` does not live long enough + --> $DIR/issue-54556-used-vs-unused-tails.rs:20:56 + | +LL | let _x = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // `let x = ...; x` + | ^^^ - - borrowed value needs to live until here + | | | + | | `_t1` dropped here while still borrowed + | borrowed value does not live long enough + +error[E0597]: `_t1` does not live long enough + --> $DIR/issue-54556-used-vs-unused-tails.rs:24:56 + | +LL | _y = { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } ; // `let x = ...; x` + | ^^^ - - borrowed value needs to live until here + | | | + | | `_t1` dropped here while still borrowed + | borrowed value does not live long enough + +error[E0597]: `_t1` does not live long enough + --> $DIR/issue-54556-used-vs-unused-tails.rs:30:56 + | +LL | fn f_local_ref() { let mut _t1 = D(Box::new("t1")); D(&_t1).unit() } // suggest `;` + | ^^^ - `_t1` dropped here while still borrowed + | | + | borrowed value does not live long enough + | + = note: values in a scope are dropped in the opposite order they are created + +error[E0597]: `_t1` does not live long enough + --> $DIR/issue-54556-used-vs-unused-tails.rs:32:56 + | +LL | fn f() -> String { let mut _t1 = D(Box::new("t1")); D(&_t1).end() } // `let x = ...; x` + | ^^^ - `_t1` dropped here while still borrowed + | | + | borrowed value does not live long enough + | + = note: values in a scope are dropped in the opposite order they are created + +error: aborting due to 9 previous errors + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-wrap-it-up.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-wrap-it-up.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-wrap-it-up.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-wrap-it-up.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error[E0506]: cannot assign to `x` because it is borrowed + --> $DIR/issue-54556-wrap-it-up.rs:27:5 + | +LL | let wrap = Wrap { p: &mut x }; + | ------ borrow of `x` occurs here +... +LL | x = 1; //~ ERROR cannot assign to `x` because it is borrowed [E0506] + | ^^^^^ assignment to borrowed `x` occurs here +LL | } + | - borrow might be used here, when `foo` is dropped and runs the destructor for type `Foo<'_>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-wrap-it-up.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-wrap-it-up.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-wrap-it-up.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-wrap-it-up.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// This is testing how the diagnostic from issue #54556 behaves when +// the destructor code is attached to a place held in a field of the +// temporary being dropped. +// +// Eventually it would be nice if the diagnostic would actually report +// that specific place and its type that implements the `Drop` trait. +// But for the short term, it is acceptable to just print out the +// whole type of the temporary. + +#![allow(warnings)] + +struct Wrap<'p> { p: &'p mut i32 } + +impl<'p> Drop for Wrap<'p> { + fn drop(&mut self) { + *self.p += 1; + } +} + +struct Foo<'p> { a: String, b: Wrap<'p> } + +fn main() { + let mut x = 0; + let wrap = Wrap { p: &mut x }; + let s = String::from("str"); + let foo = Foo { a: s, b: wrap }; + x = 1; //~ ERROR cannot assign to `x` because it is borrowed [E0506] +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-wrap-it-up.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-wrap-it-up.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-54556-wrap-it-up.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-54556-wrap-it-up.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +error[E0506]: cannot assign to `x` because it is borrowed + --> $DIR/issue-54556-wrap-it-up.rs:27:5 + | +LL | let wrap = Wrap { p: &mut x }; + | - borrow of `x` occurs here +... +LL | x = 1; //~ ERROR cannot assign to `x` because it is borrowed [E0506] + | ^^^^^ assignment to borrowed `x` occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-55288.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-55288.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/issue-55288.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/issue-55288.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(nll)] + +// run-pass + +struct Slice(&'static [&'static [u8]]); + +static MAP: Slice = Slice(&[ + b"CloseEvent" as &'static [u8], +]); + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/loan_ends_mid_block_vec.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/loan_ends_mid_block_vec.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/loan_ends_mid_block_vec.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/loan_ends_mid_block_vec.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -80,7 +80,7 @@ | ^^^^ second mutable borrow occurs here ... LL | capitalize(slice); - | ----- borrow later used here + | ----- first borrow later used here error[E0499]: cannot borrow `data` as mutable more than once at a time (Mir) --> $DIR/loan_ends_mid_block_vec.rs:27:5 @@ -92,7 +92,7 @@ | ^^^^ second mutable borrow occurs here ... LL | capitalize(slice); - | ----- borrow later used here + | ----- first borrow later used here error[E0499]: cannot borrow `data` as mutable more than once at a time (Mir) --> $DIR/loan_ends_mid_block_vec.rs:30:5 @@ -104,7 +104,7 @@ | ^^^^ second mutable borrow occurs here ... LL | capitalize(slice); - | ----- borrow later used here + | ----- first borrow later used here error: aborting due to 9 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/match-guards-always-borrow.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/match-guards-always-borrow.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/match-guards-always-borrow.ast.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/match-guards-always-borrow.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,36 @@ -error[E0507]: cannot move out of borrowed content +warning[E0507]: cannot move out of borrowed content --> $DIR/match-guards-always-borrow.rs:23:13 | LL | (|| { let bar = foo; bar.take() })(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content + | + = warning: This error has been downgraded to a warning for backwards compatibility with previous releases. + It represents potential unsoundness in your code. + This warning will become a hard error in the future. + +warning[E0507]: cannot move out of `foo`, as it is immutable for the pattern guard + --> $DIR/match-guards-always-borrow.rs:23:13 + | +LL | (|| { let bar = foo; bar.take() })(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | cannot move out of `foo`, as it is immutable for the pattern guard + | cannot move + | + = note: variables bound in patterns are immutable until the end of the pattern guard + = warning: This error has been downgraded to a warning for backwards compatibility with previous releases. + It represents potential unsoundness in your code. + This warning will become a hard error in the future. + +error: compilation successful + --> $DIR/match-guards-always-borrow.rs:57:1 + | +LL | / fn main() { //[ast]~ ERROR compilation successful +LL | | should_reject_destructive_mutate_in_guard(); +LL | | allow_mutate_in_arm_body(); +LL | | allow_move_into_arm_body(); +LL | | } + | |_^ error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/match-guards-partially-borrow.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/match-guards-partially-borrow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/match-guards-partially-borrow.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/match-guards-partially-borrow.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,164 @@ +// Test that a (partially) mutably borrowed place can be matched on, so long as +// we don't have to read any values that are mutably borrowed to determine +// which arm to take. +// +// Test that we don't allow mutating the value being matched on in a way that +// changes which patterns it matches, until we have chosen an arm. + + +#![feature(bind_by_move_pattern_guards)] +#![feature(nll)] + +fn ok_mutation_in_guard(mut q: i32) { + match q { + // OK, mutation doesn't change which patterns g matches + _ if { q = 1; false } => (), + _ => (), + } +} + +fn ok_indirect_mutation_in_guard(mut p: &bool) { + match *p { + // OK, mutation doesn't change which patterns s matches + _ if { + p = &true; + false + } => (), + _ => (), + } +} + +fn mutation_invalidates_pattern_in_guard(mut q: bool) { + match q { + // s doesn't match the pattern with the guard by the end of the guard. + false if { + q = true; //~ ERROR + true + } => (), + _ => (), + } +} + +fn mutation_invalidates_previous_pattern_in_guard(mut r: bool) { + match r { + // s matches a previous pattern by the end of the guard. + true => (), + _ if { + r = true; //~ ERROR + true + } => (), + _ => (), + } +} + +fn match_on_borrowed_early_end(mut s: bool) { + let h = &mut s; + match s { //~ ERROR + // s changes value between the start of the match and when its value is checked. + _ if { + *h = !*h; + false + } => (), + true => (), + false => (), + } +} + +fn bad_mutation_in_guard(mut t: bool) { + match t { + true => (), + false if { + t = true; //~ ERROR + false + } => (), + false => (), + } +} + +fn bad_mutation_in_guard2(mut u: bool) { + match u { + // Guard changes the value bound in the last pattern. + _ => (), + _ if { + u = true; //~ ERROR + false + } => (), + x => (), + } +} + +pub fn bad_mutation_in_guard3(mut x: Option>) { + // Check that nested patterns are checked. + match x { + None => (), + Some(None) => (), + _ if { + match x { + Some(ref mut r) => *r = None, //~ ERROR + _ => return, + }; + false + } => (), + Some(Some(r)) => println!("{}", r), + } +} + + +fn bad_mutation_in_guard4(mut w: (&mut bool,)) { + match w { + // Guard changes the value bound in the last pattern. + _ => (), + _ if { + *w.0 = true; //~ ERROR + false + } => (), + x => (), + } +} + +fn bad_indirect_mutation_in_guard(mut y: &bool) { + match *y { + true => (), + false if { + y = &true; //~ ERROR + false + } => (), + false => (), + } +} + +fn bad_indirect_mutation_in_guard2(mut z: &bool) { + match z { + &true => (), + &false if { + z = &true; //~ ERROR + false + } => (), + &false => (), + } +} + +fn bad_indirect_mutation_in_guard3(mut a: &bool) { + // Same as bad_indirect_mutation_in_guard2, but using match ergonomics + match a { + true => (), + false if { + a = &true; //~ ERROR + false + } => (), + false => (), + } +} + +fn bad_indirect_mutation_in_guard4(mut b: &bool) { + match b { + &_ => (), + &_ if { + b = &true; //~ ERROR + false + } => (), + &b => (), + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/match-guards-partially-borrow.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/match-guards-partially-borrow.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/match-guards-partially-borrow.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/match-guards-partially-borrow.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,132 @@ +error[E0510]: cannot assign `q` in match guard + --> $DIR/match-guards-partially-borrow.rs:35:13 + | +LL | match q { + | - value is immutable in match guard +... +LL | q = true; //~ ERROR + | ^^^^^^^^ cannot assign +... +LL | _ => (), + | - borrow later used here + +error[E0510]: cannot assign `r` in match guard + --> $DIR/match-guards-partially-borrow.rs:47:13 + | +LL | match r { + | - value is immutable in match guard +... +LL | r = true; //~ ERROR + | ^^^^^^^^ cannot assign +... +LL | _ => (), + | - borrow later used here + +error[E0503]: cannot use `s` because it was mutably borrowed + --> $DIR/match-guards-partially-borrow.rs:56:11 + | +LL | let h = &mut s; + | ------ borrow of `s` occurs here +LL | match s { //~ ERROR + | ^ use of borrowed `s` +... +LL | *h = !*h; + | -- borrow later used here + +error[E0510]: cannot assign `t` in match guard + --> $DIR/match-guards-partially-borrow.rs:71:13 + | +LL | match t { + | - value is immutable in match guard +... +LL | t = true; //~ ERROR + | ^^^^^^^^ cannot assign +... +LL | false => (), + | ----- borrow later used here + +error[E0506]: cannot assign to `u` because it is borrowed + --> $DIR/match-guards-partially-borrow.rs:83:13 + | +LL | match u { + | - borrow of `u` occurs here +... +LL | u = true; //~ ERROR + | ^^^^^^^^ assignment to borrowed `u` occurs here +... +LL | x => (), + | - borrow later used here + +error[E0510]: cannot mutably borrow `x.0` in match guard + --> $DIR/match-guards-partially-borrow.rs:97:22 + | +LL | match x { + | - value is immutable in match guard +... +LL | Some(ref mut r) => *r = None, //~ ERROR + | ^^^^^^^^^ cannot mutably borrow + +error[E0506]: cannot assign to `*w.0` because it is borrowed + --> $DIR/match-guards-partially-borrow.rs:112:13 + | +LL | match w { + | - borrow of `*w.0` occurs here +... +LL | *w.0 = true; //~ ERROR + | ^^^^^^^^^^^ assignment to borrowed `*w.0` occurs here +... +LL | x => (), + | - borrow later used here + +error[E0510]: cannot assign `y` in match guard + --> $DIR/match-guards-partially-borrow.rs:123:13 + | +LL | match *y { + | -- value is immutable in match guard +... +LL | y = &true; //~ ERROR + | ^^^^^^^^^ cannot assign +... +LL | false => (), + | ----- borrow later used here + +error[E0510]: cannot assign `z` in match guard + --> $DIR/match-guards-partially-borrow.rs:134:13 + | +LL | match z { + | - value is immutable in match guard +... +LL | z = &true; //~ ERROR + | ^^^^^^^^^ cannot assign +... +LL | &false => (), + | ------ borrow later used here + +error[E0510]: cannot assign `a` in match guard + --> $DIR/match-guards-partially-borrow.rs:146:13 + | +LL | match a { + | - value is immutable in match guard +... +LL | a = &true; //~ ERROR + | ^^^^^^^^^ cannot assign +... +LL | false => (), + | ----- borrow later used here + +error[E0510]: cannot assign `b` in match guard + --> $DIR/match-guards-partially-borrow.rs:157:13 + | +LL | match b { + | - value is immutable in match guard +... +LL | b = &true; //~ ERROR + | ^^^^^^^^^ cannot assign +... +LL | &b => (), + | -- borrow later used here + +error: aborting due to 11 previous errors + +Some errors occurred: E0503, E0506, E0510. +For more information about an error, try `rustc --explain E0503`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/match-on-borrowed.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/match-on-borrowed.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/match-on-borrowed.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/match-on-borrowed.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,95 @@ +// Test that a (partially) mutably borrowed place can be matched on, so long as +// we don't have to read any values that are mutably borrowed to determine +// which arm to take. +// +// Test that we don't allow mutating the value being matched on in a way that +// changes which patterns it matches, until we have chosen an arm. + +#![feature(nll)] + +struct A(i32, i32); + +fn struct_example(mut a: A) { + let x = &mut a.0; + match a { // OK, no access of borrowed data + _ if false => (), + A(_, r) => (), + } + x; +} + +fn indirect_struct_example(mut b: &mut A) { + let x = &mut b.0; + match *b { // OK, no access of borrowed data + _ if false => (), + A(_, r) => (), + } + x; +} + +fn underscore_example(mut c: i32) { + let r = &mut c; + match c { // OK, no access of borrowed data (or any data at all) + _ if false => (), + _ => (), + } + r; +} + +enum E { + V(i32, i32), + W, +} + +fn enum_example(mut e: E) { + let x = match e { + E::V(ref mut x, _) => x, + E::W => panic!(), + }; + match e { // OK, no access of borrowed data + _ if false => (), + E::V(_, r) => (), + E::W => (), + } + x; +} + +fn indirect_enum_example(mut f: &mut E) { + let x = match *f { + E::V(ref mut x, _) => x, + E::W => panic!(), + }; + match f { // OK, no access of borrowed data + _ if false => (), + E::V(_, r) => (), + E::W => (), + } + x; +} + +fn match_on_muatbly_borrowed_ref(mut p: &bool) { + let r = &mut p; + match *p { // OK, no access at all + _ if false => (), + _ => (), + } + r; +} + +fn match_on_borrowed(mut t: bool) { + let x = &mut t; + match t { + true => (), //~ ERROR + false => (), + } + x; +} + +enum Never {} + +fn never_init() { + let n: Never; + match n {} //~ ERROR +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/match-on-borrowed.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/match-on-borrowed.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/match-on-borrowed.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/match-on-borrowed.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +error[E0503]: cannot use `t` because it was mutably borrowed + --> $DIR/match-on-borrowed.rs:82:9 + | +LL | let x = &mut t; + | ------ borrow of `t` occurs here +LL | match t { +LL | true => (), //~ ERROR + | ^^^^ use of borrowed `t` +... +LL | x; + | - borrow later used here + +error[E0381]: use of possibly uninitialized variable: `n` + --> $DIR/match-on-borrowed.rs:92:11 + | +LL | match n {} //~ ERROR + | ^ use of possibly uninitialized `n` + +error: aborting due to 2 previous errors + +Some errors occurred: E0381, E0503. +For more information about an error, try `rustc --explain E0381`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/maybe-initialized-drop-implicit-fragment-drop.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/maybe-initialized-drop-implicit-fragment-drop.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/maybe-initialized-drop-implicit-fragment-drop.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/maybe-initialized-drop-implicit-fragment-drop.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | ^^^^^ assignment to borrowed `x` occurs here LL | // FIXME ^ Should not error in the future with implicit dtors, only manually implemented ones LL | } - | - borrow later used here, when `foo` is dropped + | - borrow might be used here, when `foo` is dropped and runs the destructor for type `Foo<'_>` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/maybe-initialized-drop.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/maybe-initialized-drop.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/maybe-initialized-drop.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/maybe-initialized-drop.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -6,7 +6,7 @@ LL | x = 1; //~ ERROR cannot assign to `x` because it is borrowed [E0506] | ^^^^^ assignment to borrowed `x` occurs here LL | } - | - borrow later used here, when `wrap` is dropped + | - borrow might be used here, when `wrap` is dropped and runs the `Drop` code for type `Wrap` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/maybe-initialized-drop-with-fragment.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/maybe-initialized-drop-with-fragment.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/maybe-initialized-drop-with-fragment.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/maybe-initialized-drop-with-fragment.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ LL | x = 1; //~ ERROR cannot assign to `x` because it is borrowed [E0506] | ^^^^^ assignment to borrowed `x` occurs here LL | } - | - borrow later used here, when `foo` is dropped + | - borrow might be used here, when `foo` is dropped and runs the destructor for type `Foo<'_>` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/maybe-initialized-drop-with-uninitialized-fragments.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/maybe-initialized-drop-with-uninitialized-fragments.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/maybe-initialized-drop-with-uninitialized-fragments.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/maybe-initialized-drop-with-uninitialized-fragments.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | ^^^^^ assignment to borrowed `x` occurs here LL | // FIXME ^ This currently errors and it should not. LL | } - | - borrow later used here, when `foo` is dropped + | - borrow might be used here, when `foo` is dropped and runs the destructor for type `Foo<'_>` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/mir_check_cast_reify.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/mir_check_cast_reify.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/mir_check_cast_reify.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/mir_check_cast_reify.rs 2018-12-04 23:41:40.000000000 +0000 @@ -44,8 +44,8 @@ // The MIR type checker must therefore relate `'?0` to `'?1` and `'?2` // as part of checking the `ReifyFnPointer`. let f: fn(_) -> _ = foo; - //~^ ERROR unsatisfied lifetime constraints f(x) + //~^ ERROR unsatisfied lifetime constraints } fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/mir_check_cast_reify.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/mir_check_cast_reify.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/mir_check_cast_reify.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/mir_check_cast_reify.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,11 +1,11 @@ error: unsatisfied lifetime constraints - --> $DIR/mir_check_cast_reify.rs:46:25 + --> $DIR/mir_check_cast_reify.rs:47:5 | LL | fn bar<'a>(x: &'a u32) -> &'static u32 { | -- lifetime `'a` defined here ... -LL | let f: fn(_) -> _ = foo; - | ^^^ cast requires that `'a` must outlive `'static` +LL | f(x) + | ^^^^ returning this value requires that `'a` must outlive `'static` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/mir_check_cast_unsafe_fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/mir_check_cast_unsafe_fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/mir_check_cast_unsafe_fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/mir_check_cast_unsafe_fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -16,8 +16,8 @@ // Here the NLL checker must relate the types in `f` to the types // in `g`. These are related via the `UnsafeFnPointer` cast. let g: unsafe fn(_) -> _ = f; - //~^ ERROR unsatisfied lifetime constraints unsafe { g(input) } + //~^ ERROR unsatisfied lifetime constraints } fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/mir_check_cast_unsafe_fn.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/mir_check_cast_unsafe_fn.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/mir_check_cast_unsafe_fn.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/mir_check_cast_unsafe_fn.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,11 +1,11 @@ error: unsatisfied lifetime constraints - --> $DIR/mir_check_cast_unsafe_fn.rs:18:32 + --> $DIR/mir_check_cast_unsafe_fn.rs:19:14 | LL | fn bar<'a>(input: &'a u32, f: fn(&'a u32) -> &'a u32) -> &'static u32 { | -- lifetime `'a` defined here ... -LL | let g: unsafe fn(_) -> _ = f; - | ^ cast requires that `'a` must outlive `'static` +LL | unsafe { g(input) } + | ^^^^^^^^ returning this value requires that `'a` must outlive `'static` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/mir_check_cast_unsize.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/mir_check_cast_unsize.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/mir_check_cast_unsize.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/mir_check_cast_unsize.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -4,7 +4,7 @@ LL | fn bar<'a>(x: &'a u32) -> &'static dyn Debug { | -- lifetime `'a` defined here LL | x - | ^ cast requires that `'a` must outlive `'static` + | ^ returning this value requires that `'a` must outlive `'static` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/move-errors.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/move-errors.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/move-errors.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/move-errors.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -25,13 +25,13 @@ | cannot move out of borrowed content | help: consider removing the `*`: `*r` -error[E0507]: cannot move out of borrowed content +error[E0507]: cannot move out of an `Rc` --> $DIR/move-errors.rs:40:13 | LL | let s = *r; | ^^ | | - | cannot move out of borrowed content + | cannot move out of an `Rc` | help: consider removing the `*`: `r` error[E0508]: cannot move out of type `[A; 1]`, a non-copy array diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/move-subpaths-moves-root.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/move-subpaths-moves-root.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/move-subpaths-moves-root.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/move-subpaths-moves-root.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(nll)] + +fn main() { + let x = (vec![1, 2, 3], ); + drop(x.0); + drop(x); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/move-subpaths-moves-root.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/move-subpaths-moves-root.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/move-subpaths-moves-root.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/move-subpaths-moves-root.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `x` + --> $DIR/move-subpaths-moves-root.rs:16:10 + | +LL | drop(x.0); + | --- value moved here +LL | drop(x); + | ^ value used here after move + | + = note: move occurs because `x.0` has type `std::vec::Vec`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/polonius-smoke-test.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/polonius-smoke-test.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/polonius-smoke-test.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/polonius-smoke-test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// Check that Polonius borrow check works for simple cases. +// ignore-compare-mode-nll +// compile-flags: -Z borrowck=mir -Zpolonius + +pub fn return_ref_to_local() -> &'static i32 { + let x = 0; + &x //~ ERROR +} + +pub fn use_while_mut() { + let mut x = 0; + let y = &mut x; + let z = x; //~ ERROR + let w = y; +} + +pub fn use_while_mut_fr(x: &mut i32) -> &mut i32 { + let y = &mut *x; + let z = x; //~ ERROR + y +} + +// Cases like this are why we have Polonius. +pub fn position_dependent_outlives(x: &mut i32, cond: bool) -> &mut i32 { + let y = &mut *x; + if cond { + return y; + } else { + *x = 0; + return x; + } +} + +fn foo<'a, 'b>(p: &'b &'a mut usize) -> &'b usize { + p +} + +// Check that we create constraints for well-formedness of function arguments +fn well_formed_function_inputs() { + let s = &mut 1; + let r = &mut *s; + let tmp = foo(&r); + s; //~ ERROR + tmp; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/polonius-smoke-test.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/polonius-smoke-test.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/polonius-smoke-test.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/polonius-smoke-test.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +error[E0515]: cannot return reference to local variable `x` + --> $DIR/polonius-smoke-test.rs:7:5 + | +LL | &x //~ ERROR + | ^^ returns a reference to data owned by the current function + +error[E0503]: cannot use `x` because it was mutably borrowed + --> $DIR/polonius-smoke-test.rs:13:13 + | +LL | let y = &mut x; + | ------ borrow of `x` occurs here +LL | let z = x; //~ ERROR + | ^ use of borrowed `x` +LL | let w = y; + | - borrow later used here + +error[E0505]: cannot move out of `x` because it is borrowed + --> $DIR/polonius-smoke-test.rs:19:13 + | +LL | let y = &mut *x; + | ------- borrow of `*x` occurs here +LL | let z = x; //~ ERROR + | ^ move out of `x` occurs here +LL | y + | - borrow later used here + +error[E0505]: cannot move out of `s` because it is borrowed + --> $DIR/polonius-smoke-test.rs:43:5 + | +LL | let r = &mut *s; + | ------- borrow of `*s` occurs here +LL | let tmp = foo(&r); +LL | s; //~ ERROR + | ^ move out of `s` occurs here +LL | tmp; + | --- borrow later used here + +error: aborting due to 4 previous errors + +Some errors occurred: E0503, E0505, E0515. +For more information about an error, try `rustc --explain E0503`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/region-ends-after-if-condition.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/region-ends-after-if-condition.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/region-ends-after-if-condition.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/region-ends-after-if-condition.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -32,7 +32,7 @@ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here ... LL | drop(value); - | ----- borrow later used here + | ----- immutable borrow later used here error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/region-ends-after-if-condition.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/region-ends-after-if-condition.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/region-ends-after-if-condition.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/region-ends-after-if-condition.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -32,7 +32,7 @@ | ^^^^^^^^^^^^^^^ mutable borrow occurs here ... LL | drop(value); - | ----- borrow later used here + | ----- immutable borrow later used here error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/relate_tys/hr-fn-aaa-as-aba.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/relate_tys/hr-fn-aaa-as-aba.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/relate_tys/hr-fn-aaa-as-aba.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/relate_tys/hr-fn-aaa-as-aba.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -5,10 +5,10 @@ | ^^^^^^^^^ error: higher-ranked subtype error - --> $DIR/hr-fn-aaa-as-aba.rs:32:58 + --> $DIR/hr-fn-aaa-as-aba.rs:32:12 | LL | let _: for<'a, 'b> fn(&'a u32, &'b u32) -> &'a u32 = make_it(); - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/relate_tys/var-appears-twice.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/relate_tys/var-appears-twice.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/relate_tys/var-appears-twice.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/relate_tys/var-appears-twice.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,12 +2,12 @@ --> $DIR/var-appears-twice.rs:33:38 | LL | let x: DoubleCell<_> = make_cell(&b); //~ ERROR - | ^^ borrowed value does not live long enough + | ------------- ^^ borrowed value does not live long enough + | | + | type annotation requires that `b` is borrowed for `'static` ... LL | } | - `b` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/return_from_loop.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/return_from_loop.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/return_from_loop.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/return_from_loop.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -32,7 +32,7 @@ | ^^^^^^^^^^^^^^^ second mutable borrow occurs here ... LL | value.len(); - | ----- borrow later used here + | ----- first borrow later used here error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/return-ref-mut-issue-46557.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/return-ref-mut-issue-46557.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/return-ref-mut-issue-46557.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/return-ref-mut-issue-46557.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,8 +14,8 @@ #![allow(dead_code)] fn gimme_static_mut() -> &'static mut u32 { - let ref mut x = 1234543; //~ ERROR borrowed value does not live long enough [E0597] - x + let ref mut x = 1234543; + x //~ ERROR cannot return value referencing temporary value [E0515] } fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/return-ref-mut-issue-46557.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/return-ref-mut-issue-46557.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/return-ref-mut-issue-46557.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/return-ref-mut-issue-46557.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,14 +1,11 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/return-ref-mut-issue-46557.rs:17:21 +error[E0515]: cannot return value referencing temporary value + --> $DIR/return-ref-mut-issue-46557.rs:18:5 | -LL | let ref mut x = 1234543; //~ ERROR borrowed value does not live long enough [E0597] - | ^^^^^^^ temporary value does not live long enough -LL | x -LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... +LL | let ref mut x = 1234543; + | ------- temporary value created here +LL | x //~ ERROR cannot return value referencing temporary value [E0515] + | ^ returns a value referencing data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/impl-trait-outlives.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/impl-trait-outlives.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/impl-trait-outlives.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/impl-trait-outlives.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,11 +15,11 @@ use std::fmt::Debug; fn no_region<'a, T>(x: Box) -> impl Debug + 'a + //~^ ERROR the parameter type `T` may not live long enough [E0309] where T: Debug, { x - //~^ ERROR the parameter type `T` may not live long enough [E0309] } fn correct_region<'a, T>(x: Box) -> impl Debug + 'a @@ -30,11 +30,11 @@ } fn wrong_region<'a, 'b, T>(x: Box) -> impl Debug + 'a + //~^ ERROR the parameter type `T` may not live long enough [E0309] where T: 'b + Debug, { x - //~^ ERROR the parameter type `T` may not live long enough [E0309] } fn outlives_region<'a, 'b, T>(x: Box) -> impl Debug + 'a diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/impl-trait-outlives.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/impl-trait-outlives.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/impl-trait-outlives.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/impl-trait-outlives.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,16 +1,16 @@ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/impl-trait-outlives.rs:21:5 + --> $DIR/impl-trait-outlives.rs:17:35 | -LL | x - | ^ +LL | fn no_region<'a, T>(x: Box) -> impl Debug + 'a + | ^^^^^^^^^^^^^^^ | = help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`... error[E0309]: the parameter type `T` may not live long enough - --> $DIR/impl-trait-outlives.rs:36:5 + --> $DIR/impl-trait-outlives.rs:32:42 | -LL | x - | ^ +LL | fn wrong_region<'a, 'b, T>(x: Box) -> impl Debug + 'a + | ^^^^^^^^^^^^^^^ | = help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`... diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/issue-53789-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/issue-53789-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/issue-53789-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/issue-53789-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,91 @@ +// Regression test for #53789. +// +// compile-pass + +#![feature(nll)] +#![allow(unused_variables)] + +use std::collections::BTreeMap; + +trait ValueTree { + type Value; +} + +trait Strategy { + type Value: ValueTree; +} + +type StrategyFor = StrategyType<'static, A>; +type StrategyType<'a, A> = >::Strategy; + +impl Strategy for (K, V) { + type Value = TupleValueTree<(K, V)>; +} + +impl ValueTree for TupleValueTree<(K, V)> { + type Value = BTreeMapValueTree; +} + +struct TupleValueTree { + tree: T, +} + +struct BTreeMapStrategy(std::marker::PhantomData<(K, V)>) +where + K: Strategy, + V: Strategy; + +struct BTreeMapValueTree(std::marker::PhantomData<(K, V)>) +where + K: ValueTree, + V: ValueTree; + +impl Strategy for BTreeMapStrategy +where + K: Strategy, + V: Strategy, +{ + type Value = BTreeMapValueTree; +} + +impl ValueTree for BTreeMapValueTree +where + K: ValueTree, + V: ValueTree, +{ + type Value = BTreeMap; +} + +trait Arbitrary<'a>: Sized { + fn arbitrary_with(args: Self::Parameters) -> Self::Strategy; + type Parameters; + type Strategy: Strategy; + type ValueTree: ValueTree; +} + +impl<'a, A, B> Arbitrary<'a> for BTreeMap +where + A: Arbitrary<'static>, + B: Arbitrary<'static>, + StrategyFor: 'static, + StrategyFor: 'static, +{ + type ValueTree = ::Value; + type Parameters = (A::Parameters, B::Parameters); + type Strategy = BTreeMapStrategy; + fn arbitrary_with(args: Self::Parameters) -> BTreeMapStrategy { + let (a, b) = args; + btree_map(any_with::(a), any_with::(b)) + } +} + +fn btree_map(key: K, value: V) -> BTreeMapStrategy { + unimplemented!() +} + +fn any_with<'a, A: Arbitrary<'a>>(args: A::Parameters) -> StrategyType<'a, A> { + unimplemented!() +} + +fn main() { } + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/issue-53789-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/issue-53789-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/issue-53789-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/issue-53789-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,251 @@ +// Regression test for #53789. +// +// compile-pass + +#![feature(nll)] +#![allow(unused_variables)] + +use std::collections::BTreeMap; +use std::ops::Range; +use std::cmp::Ord; + +macro_rules! valuetree { + () => { + type ValueTree = + ::Value; + }; +} + +macro_rules! product_unpack { + ($factor: pat) => { + ($factor,) + }; + ($($factor: pat),*) => { + ( $( $factor ),* ) + }; + ($($factor: pat),*,) => { + ( $( $factor ),* ) + }; +} + +macro_rules! product_type { + ($factor: ty) => { + ($factor,) + }; + ($($factor: ty),*) => { + ( $( $factor, )* ) + }; + ($($factor: ty),*,) => { + ( $( $factor, )* ) + }; +} + +macro_rules! default { + ($type: ty, $val: expr) => { + impl Default for $type { + fn default() -> Self { $val.into() } + } + }; +} + +// Pervasive internal sugar +macro_rules! mapfn { + ($(#[$meta:meta])* [$($vis:tt)*] + fn $name:ident[$($gen:tt)*]($parm:ident: $input:ty) -> $output:ty { + $($body:tt)* + }) => { + $(#[$meta])* + #[derive(Clone, Copy)] + $($vis)* struct $name; + impl $($gen)* statics::MapFn<$input> for $name { + type Output = $output; + } + } +} + +macro_rules! opaque_strategy_wrapper { + ($(#[$smeta:meta])* pub struct $stratname:ident + [$($sgen:tt)*][$($swhere:tt)*] + ($innerstrat:ty) -> $stratvtty:ty; + + $(#[$vmeta:meta])* pub struct $vtname:ident + [$($vgen:tt)*][$($vwhere:tt)*] + ($innervt:ty) -> $actualty:ty; + ) => { + $(#[$smeta])* struct $stratname $($sgen)* (std::marker::PhantomData<(K, V)>) + $($swhere)*; + + $(#[$vmeta])* struct $vtname $($vgen)* ($innervt) $($vwhere)*; + + impl $($sgen)* Strategy for $stratname $($sgen)* $($swhere)* { + type Value = $stratvtty; + } + + impl $($vgen)* ValueTree for $vtname $($vgen)* $($vwhere)* { + type Value = $actualty; + } + } +} + +trait ValueTree { + type Value; +} + +trait Strategy { + type Value : ValueTree; +} + +#[derive(Clone)] +struct VecStrategy { + element: T, + size: Range, +} + +fn vec(element: T, size: Range) + -> VecStrategy { + VecStrategy { + element: element, + size: size, + } +} + +type ValueFor = <::Value as ValueTree>::Value; + +trait Arbitrary<'a>: Sized { + fn arbitrary_with(args: Self::Parameters) -> Self::Strategy; + + type Parameters: Default; + type Strategy: Strategy; + type ValueTree: ValueTree; +} + +type StrategyFor = StrategyType<'static, A>; +type StrategyType<'a, A> = >::Strategy; + +//#[derive(Clone, PartialEq, Eq, Hash, Debug, From, Into)] +struct SizeBounds(Range); +default!(SizeBounds, 0..100); + + +impl From> for SizeBounds { + fn from(high: Range) -> Self { + unimplemented!() + } +} + +impl From for Range { + fn from(high: SizeBounds) -> Self { + unimplemented!() + } +} + + +fn any_with<'a, A: Arbitrary<'a>>(args: A::Parameters) + -> StrategyType<'a, A> { + unimplemented!() +} + +impl Strategy for (K, V) where + ::Value: Ord { + type Value = TupleValueTree<(K, V)>; +} + +impl ValueTree for TupleValueTree<(K, V)> where + ::Value: Ord { + type Value = BTreeMapValueTree; +} + +#[derive(Clone)] +struct VecValueTree { + elements: Vec, +} + +#[derive(Clone, Copy)] +struct TupleValueTree { + tree: T, +} + +opaque_strategy_wrapper! { + #[derive(Clone)] + pub struct BTreeMapStrategy[] + [where K : Strategy, V : Strategy, ValueFor : Ord]( + statics::Filter, + VecToBTreeMap>, MinSize>) + -> BTreeMapValueTree; + + #[derive(Clone)] + pub struct BTreeMapValueTree[] + [where K : ValueTree, V : ValueTree, K::Value : Ord]( + statics::Filter>, + VecToBTreeMap>, MinSize>) + -> BTreeMap; +} + +type RangedParams2 = product_type![SizeBounds, A, B]; + +impl<'a, A, B> Arbitrary<'a> for BTreeMap +where + A: Arbitrary<'static> + Ord, + B: Arbitrary<'static>, +StrategyFor: 'static, +StrategyFor: 'static, +{ + valuetree!(); + type Parameters = RangedParams2; + type Strategy = BTreeMapStrategy; + fn arbitrary_with(args: Self::Parameters) -> Self::Strategy { + let product_unpack![range, a, b] = args; + btree_map(any_with::(a), any_with::(b), range.into()) + } +} + +#[derive(Clone, Copy)] +struct MinSize(usize); + +mapfn! { + [] fn VecToBTreeMap[] + (vec: Vec<(K, V)>) -> BTreeMap + { + vec.into_iter().collect() + } +} + +fn btree_map + (key: K, value: V, size: Range) + -> BTreeMapStrategy +where ValueFor : Ord { + unimplemented!() +} + +mod statics { + pub(super) trait MapFn { + type Output; + } + + #[derive(Clone)] + pub struct Filter { + source: S, + fun: F, + } + + impl Filter { + pub fn new(source: S, whence: String, filter: F) -> Self { + unimplemented!() + } + } + + #[derive(Clone)] + pub struct Map { + source: S, + fun: F, + } + + impl Map { + pub fn new(source: S, fun: F) -> Self { + unimplemented!() + } + } +} + +fn main() { } + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/issue-55756.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/issue-55756.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/issue-55756.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/issue-55756.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// Regression test for #55756. +// +// In this test, the result of `self.callee` is a projection `>::Guard`. As it may contain a destructor, the dropck +// rules require that this type outlivess the scope of `state`. Unfortunately, +// our region inference is not smart enough to figure out how to +// translate a requirement like +// +// >::guard: 'r +// +// into a requirement that `'0: 'r` -- in particular, it fails to do +// so because it *also* knows that `>::Guard: 'a` +// from the trait definition. Faced with so many choices, the current +// solver opts to do nothing. +// +// Fixed by tweaking the solver to recognize that the constraint from +// the environment duplicates one from the trait. +// +// compile-pass + +#![crate_type="lib"] + +pub trait Database<'a> { + type Guard: 'a; +} + +pub struct Stateful<'a, D: 'a>(&'a D); + +impl<'b, D: for <'a> Database<'a>> Stateful<'b, D> { + pub fn callee<'a>(&'a self) -> >::Guard { + unimplemented!() + } + pub fn caller<'a>(&'a self) -> >::Guard { + let state = self.callee(); + unimplemented!() + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-body.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-body.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-body.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-body.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Test that when we infer the lifetime to a subset of the fn body, it +// works out. +// +// compile-pass + +trait MyTrait<'a> { + type Output; +} + +fn foo1() +where + for<'x> T: MyTrait<'x>, +{ + // Here the region `'c` in `>::Output` will be + // inferred to a subset of the fn body. + let x = bar::(); + drop(x); +} + +fn bar<'a, T>() -> &'a () +where + T: 'a, +{ + &() +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-one-region-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-one-region-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-one-region-closure.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-one-region-closure.rs 2018-12-04 23:41:40.000000000 +0000 @@ -74,19 +74,10 @@ T: Anything<'b>, T::AssocType: 'a, { - // This error is unfortunate. This code ought to type-check: we - // are projecting `>::AssocType`, and we know - // that this outlives `'a` because of the where-clause. However, - // the way the region checker works, we don't register this - // outlives obligation, and hence we get an error: this is because - // what we see is a projection like `>::AssocType`, and we don't yet know if `?0` will - // equal `'b` or not, so we ignore the where-clause. Obviously we - // can do better here with a more involved verification step. + // We are projecting `>::AssocType`, and we know + // that this outlives `'a` because of the where-clause. with_signature(cell, t, |cell, t| require(cell, t)); - //~^ ERROR the parameter type `T` may not live long enough - //~| ERROR } #[rustc_regions] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-one-region-closure.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -32,8 +32,16 @@ T ] +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/projection-one-region-closure.rs:55:29 + | +LL | with_signature(cell, t, |cell, t| require(cell, t)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `T: ReFree(DefId(0/0:8 ~ projection_one_region_closure[317d]::no_relationships_late[0]), BrNamed(crate0:DefIndex(1:16), 'a))`... + error: unsatisfied lifetime constraints - --> $DIR/projection-one-region-closure.rs:55:5 + --> $DIR/projection-one-region-closure.rs:55:39 | LL | fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T) | -- -- lifetime `'b` defined here @@ -41,15 +49,7 @@ | lifetime `'a` defined here ... LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` - -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/projection-one-region-closure.rs:55:29 - | -LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `T: ReFree(DefId(0/0:8 ~ projection_one_region_closure[317d]::no_relationships_late[0]), BrNamed(crate0:DefIndex(1:16), 'a))`... + | ^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` note: External requirements --> $DIR/projection-one-region-closure.rs:66:29 @@ -86,8 +86,16 @@ T ] +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/projection-one-region-closure.rs:66:29 + | +LL | with_signature(cell, t, |cell, t| require(cell, t)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`... + error: unsatisfied lifetime constraints - --> $DIR/projection-one-region-closure.rs:66:5 + --> $DIR/projection-one-region-closure.rs:66:39 | LL | fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T) | -- -- lifetime `'b` defined here @@ -95,18 +103,10 @@ | lifetime `'a` defined here ... LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` - -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/projection-one-region-closure.rs:66:29 - | -LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`... + | ^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` note: External requirements - --> $DIR/projection-one-region-closure.rs:87:29 + --> $DIR/projection-one-region-closure.rs:80:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -119,8 +119,7 @@ extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T)) ] = note: number of external vids: 4 - = note: where T: '_#3r - = note: where '_#2r: '_#3r + = note: where >::AssocType: '_#3r note: No external requirements --> $DIR/projection-one-region-closure.rs:72:1 @@ -130,7 +129,7 @@ LL | | T: Anything<'b>, LL | | T::AssocType: 'a, ... | -LL | | //~| ERROR +LL | | with_signature(cell, t, |cell, t| require(cell, t)); LL | | } | |_^ | @@ -140,27 +139,8 @@ T ] -error: unsatisfied lifetime constraints - --> $DIR/projection-one-region-closure.rs:87:5 - | -LL | fn projection_outlives<'a, 'b, T>(cell: Cell<&'a ()>, t: T) - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -... -LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` - -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/projection-one-region-closure.rs:87:29 - | -LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `T: ReEarlyBound(0, 'a)`... - note: External requirements - --> $DIR/projection-one-region-closure.rs:99:29 + --> $DIR/projection-one-region-closure.rs:90:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -177,7 +157,7 @@ = note: where '_#2r: '_#3r note: No external requirements - --> $DIR/projection-one-region-closure.rs:93:1 + --> $DIR/projection-one-region-closure.rs:84:1 | LL | / fn elements_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | | where @@ -194,6 +174,6 @@ T ] -error: aborting due to 6 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0309`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.rs 2018-12-04 23:41:40.000000000 +0000 @@ -64,18 +64,10 @@ T: Anything<'b>, T::AssocType: 'a, { - // This error is unfortunate. This code ought to type-check: we - // are projecting `>::AssocType`, and we know - // that this outlives `'a` because of the where-clause. However, - // the way the region checker works, we don't register this - // outlives obligation, and hence we get an error: this is because - // what we see is a projection like `>::AssocType`, and we don't yet know if `?0` will - // equal `'b` or not, so we ignore the where-clause. Obviously we - // can do better here with a more involved verification step. + // We are projecting `>::AssocType`, and we know + // that this outlives `'a` because of the where-clause. with_signature(cell, t, |cell, t| require(cell, t)); - //~^ ERROR } #[rustc_regions] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-one-region-trait-bound-closure.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -32,7 +32,7 @@ ] error: unsatisfied lifetime constraints - --> $DIR/projection-one-region-trait-bound-closure.rs:47:5 + --> $DIR/projection-one-region-trait-bound-closure.rs:47:39 | LL | fn no_relationships_late<'a, 'b, T>(cell: Cell<&'a ()>, t: T) | -- -- lifetime `'b` defined here @@ -40,7 +40,7 @@ | lifetime `'a` defined here ... LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` + | ^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` note: External requirements --> $DIR/projection-one-region-trait-bound-closure.rs:57:29 @@ -77,7 +77,7 @@ ] error: unsatisfied lifetime constraints - --> $DIR/projection-one-region-trait-bound-closure.rs:57:5 + --> $DIR/projection-one-region-trait-bound-closure.rs:57:39 | LL | fn no_relationships_early<'a, 'b, T>(cell: Cell<&'a ()>, t: T) | -- -- lifetime `'b` defined here @@ -85,10 +85,10 @@ | lifetime `'a` defined here ... LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` + | ^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` note: External requirements - --> $DIR/projection-one-region-trait-bound-closure.rs:77:29 + --> $DIR/projection-one-region-trait-bound-closure.rs:70:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -101,7 +101,7 @@ extern "rust-call" fn((std::cell::Cell<&'_#3r ()>, T)) ] = note: number of external vids: 4 - = note: where '_#2r: '_#3r + = note: where >::AssocType: '_#3r note: No external requirements --> $DIR/projection-one-region-trait-bound-closure.rs:62:1 @@ -111,7 +111,7 @@ LL | | T: Anything<'b>, LL | | T::AssocType: 'a, ... | -LL | | //~^ ERROR +LL | | with_signature(cell, t, |cell, t| require(cell, t)); LL | | } | |_^ | @@ -121,19 +121,8 @@ T ] -error: unsatisfied lifetime constraints - --> $DIR/projection-one-region-trait-bound-closure.rs:77:5 - | -LL | fn projection_outlives<'a, 'b, T>(cell: Cell<&'a ()>, t: T) - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -... -LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` - note: External requirements - --> $DIR/projection-one-region-trait-bound-closure.rs:87:29 + --> $DIR/projection-one-region-trait-bound-closure.rs:79:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -149,7 +138,7 @@ = note: where '_#2r: '_#3r note: No external requirements - --> $DIR/projection-one-region-trait-bound-closure.rs:82:1 + --> $DIR/projection-one-region-trait-bound-closure.rs:74:1 | LL | / fn elements_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | | where @@ -167,7 +156,7 @@ ] note: External requirements - --> $DIR/projection-one-region-trait-bound-closure.rs:99:29 + --> $DIR/projection-one-region-trait-bound-closure.rs:91:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -182,7 +171,7 @@ = note: where '_#1r: '_#2r note: No external requirements - --> $DIR/projection-one-region-trait-bound-closure.rs:91:1 + --> $DIR/projection-one-region-trait-bound-closure.rs:83:1 | LL | / fn one_region<'a, T>(cell: Cell<&'a ()>, t: T) LL | | where @@ -198,5 +187,5 @@ T ] -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.rs 2018-12-04 23:41:40.000000000 +0000 @@ -65,18 +65,10 @@ T: Anything<'b, 'c>, T::AssocType: 'a, { - // This error is unfortunate. This code ought to type-check: we - // are projecting `>::AssocType`, and we know - // that this outlives `'a` because of the where-clause. However, - // the way the region checker works, we don't register this - // outlives obligation, and hence we get an error: this is because - // what we see is a projection like `>::AssocType`, and we don't yet know if `?0` will - // equal `'b` or not, so we ignore the where-clause. Obviously we - // can do better here with a more involved verification step. + // We are projecting `>::AssocType`, and we know + // that this outlives `'a` because of the where-clause. with_signature(cell, t, |cell, t| require(cell, t)); - //~^ ERROR associated type `>::AssocType` may not live long enough } #[rustc_regions] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-two-region-trait-bound-closure.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -86,7 +86,7 @@ = help: consider adding an explicit lifetime bound `>::AssocType: ReEarlyBound(0, 'a)`... note: External requirements - --> $DIR/projection-two-region-trait-bound-closure.rs:78:29 + --> $DIR/projection-two-region-trait-bound-closure.rs:71:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -110,7 +110,7 @@ LL | | T: Anything<'b, 'c>, LL | | T::AssocType: 'a, ... | -LL | | //~^ ERROR associated type `>::AssocType` may not live long enough +LL | | with_signature(cell, t, |cell, t| require(cell, t)); LL | | } | |_^ | @@ -121,16 +121,8 @@ T ] -error[E0309]: the associated type `>::AssocType` may not live long enough - --> $DIR/projection-two-region-trait-bound-closure.rs:78:29 - | -LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `>::AssocType: ReEarlyBound(0, 'a)`... - note: External requirements - --> $DIR/projection-two-region-trait-bound-closure.rs:88:29 + --> $DIR/projection-two-region-trait-bound-closure.rs:80:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -147,7 +139,7 @@ = note: where >::AssocType: '_#4r note: No external requirements - --> $DIR/projection-two-region-trait-bound-closure.rs:83:1 + --> $DIR/projection-two-region-trait-bound-closure.rs:75:1 | LL | / fn elements_outlive1<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T) LL | | where @@ -166,7 +158,7 @@ ] note: External requirements - --> $DIR/projection-two-region-trait-bound-closure.rs:97:29 + --> $DIR/projection-two-region-trait-bound-closure.rs:89:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -183,7 +175,7 @@ = note: where >::AssocType: '_#4r note: No external requirements - --> $DIR/projection-two-region-trait-bound-closure.rs:92:1 + --> $DIR/projection-two-region-trait-bound-closure.rs:84:1 | LL | / fn elements_outlive2<'a, 'b, 'c, T>(cell: Cell<&'a ()>, t: T) LL | | where @@ -202,7 +194,7 @@ ] note: External requirements - --> $DIR/projection-two-region-trait-bound-closure.rs:105:29 + --> $DIR/projection-two-region-trait-bound-closure.rs:97:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -218,7 +210,7 @@ = note: where >::AssocType: '_#2r note: No external requirements - --> $DIR/projection-two-region-trait-bound-closure.rs:101:1 + --> $DIR/projection-two-region-trait-bound-closure.rs:93:1 | LL | / fn two_regions<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | | where @@ -235,7 +227,7 @@ ] error: unsatisfied lifetime constraints - --> $DIR/projection-two-region-trait-bound-closure.rs:105:5 + --> $DIR/projection-two-region-trait-bound-closure.rs:97:29 | LL | fn two_regions<'a, 'b, T>(cell: Cell<&'a ()>, t: T) | -- -- lifetime `'b` defined here @@ -243,10 +235,10 @@ | lifetime `'a` defined here ... LL | with_signature(cell, t, |cell, t| require(cell, t)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ closure body requires that `'b` must outlive `'a` note: External requirements - --> $DIR/projection-two-region-trait-bound-closure.rs:115:29 + --> $DIR/projection-two-region-trait-bound-closure.rs:107:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -262,7 +254,7 @@ = note: where >::AssocType: '_#3r note: No external requirements - --> $DIR/projection-two-region-trait-bound-closure.rs:110:1 + --> $DIR/projection-two-region-trait-bound-closure.rs:102:1 | LL | / fn two_regions_outlive<'a, 'b, T>(cell: Cell<&'a ()>, t: T) LL | | where @@ -280,7 +272,7 @@ ] note: External requirements - --> $DIR/projection-two-region-trait-bound-closure.rs:127:29 + --> $DIR/projection-two-region-trait-bound-closure.rs:119:29 | LL | with_signature(cell, t, |cell, t| require(cell, t)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -295,7 +287,7 @@ = note: where >::AssocType: '_#2r note: No external requirements - --> $DIR/projection-two-region-trait-bound-closure.rs:119:1 + --> $DIR/projection-two-region-trait-bound-closure.rs:111:1 | LL | / fn one_region<'a, T>(cell: Cell<&'a ()>, t: T) LL | | where @@ -311,6 +303,6 @@ T ] -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0309`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-env.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-env.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-env.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-env.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +#![feature(nll)] + +// Test that when we have a `>::Output: 'a` +// relationship in the environment we take advantage of it. In this +// case, that means we **don't** have to prove that `T: 'a`. +// +// Regression test for #53121. +// +// compile-pass + +trait MyTrait<'a> { + type Output; +} + +fn foo<'a, T>() -> &'a () +where + T: MyTrait<'a>, + >::Output: 'a, +{ + bar::() +} + +fn bar<'a, T>() -> &'a () +where + T: 'a, +{ + &() +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +#![feature(nll)] + +// Test that we are able to establish that `>::Output` outlives `'b` here. We need to prove however +// that `>::Output` outlives `'a`, so we also have to +// prove that `'b: 'a`. + +trait MyTrait<'a> { + type Output; +} + +fn foo1<'a, 'b, T>() -> &'a () +where + T: MyTrait<'a>, + >::Output: 'b, +{ + bar::() //~ ERROR may not live long enough +} + +fn foo2<'a, 'b, T>() -> &'a () +where + T: MyTrait<'a>, + >::Output: 'b, + 'b: 'a, +{ + bar::() // OK +} + +fn bar<'a, T>() -> &'a () +where + T: 'a, +{ + &() +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-bound.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0309]: the associated type `>::Output` may not live long enough + --> $DIR/projection-where-clause-env-wrong-bound.rs:17:5 + | +LL | bar::() //~ ERROR may not live long enough + | ^^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `>::Output: 'a`... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0309`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Test that if we need to prove that `>::Output: +// 'a`, but we only know that `>::Output: 'a`, that +// doesn't suffice. + +trait MyTrait<'a> { + type Output; +} + +fn foo1<'a, 'b, T>() -> &'a () +where + for<'x> T: MyTrait<'x>, + >::Output: 'a, +{ + bar::<>::Output>() + //~^ ERROR the associated type `>::Output` may not live long enough +} + +fn bar<'a, T>() -> &'a () +where + T: 'a, +{ + &() +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-env-wrong-lifetime.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +error[E0309]: the associated type `>::Output` may not live long enough + --> $DIR/projection-where-clause-env-wrong-lifetime.rs:14:5 + | +LL | bar::<>::Output>() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `>::Output: 'a`... +note: ...so that the type `>::Output` will meet its required lifetime bounds + --> $DIR/projection-where-clause-env-wrong-lifetime.rs:14:5 + | +LL | bar::<>::Output>() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0309`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-none.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-none.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-none.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-none.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +#![feature(nll)] + +// Test that we are NOT able to establish that `>::Output: 'a` outlives `'a` here -- we have only one +// recourse, which is to prove that `T: 'a` and `'a: 'a`, but we don't +// know that `T: 'a`. + +trait MyTrait<'a> { + type Output; +} + +fn foo<'a, T>() -> &'a () +where + T: MyTrait<'a>, +{ + bar::() //~ ERROR the parameter type `T` may not live long enough +} + +fn bar<'a, T>() -> &'a () +where + T: 'a, +{ + &() +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-none.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-none.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-none.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-none.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/projection-where-clause-none.rs:16:5 + | +LL | bar::() //~ ERROR the parameter type `T` may not live long enough + | ^^^^^^^^^^^^^^^^^^ + | + = help: consider adding an explicit lifetime bound `T: 'a`... + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0309`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/ty-outlives/projection-where-clause-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +#![feature(nll)] + +// Test that we are able to establish that `>::Output: 'a` outlives `'a` (because the trait says +// so). +// +// compile-pass + +trait MyTrait<'a> { + type Output: 'a; +} + +fn foo<'a, T>() -> &'a () +where + T: MyTrait<'a>, +{ + bar::() +} + +fn bar<'a, T>() -> &'a () +where + T: 'a, +{ + &() +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/type-alias-free-regions.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/type-alias-free-regions.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/type-alias-free-regions.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/type-alias-free-regions.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// Test that we don't assume that type aliases have the same type parameters +// as the type they alias and then panic when we see this. + +#![feature(nll)] + +type a<'a> = &'a isize; +type b<'a> = Box>; + +struct c<'a> { + f: Box> +} + +trait FromBox<'a> { + fn from_box(b: Box) -> Self; +} + +impl<'a> FromBox<'a> for c<'a> { + fn from_box(b: Box) -> Self { + c { f: b } //~ ERROR + } +} + +trait FromTuple<'a> { + fn from_tuple( b: (b,)) -> Self; +} + +impl<'a> FromTuple<'a> for c<'a> { + fn from_tuple(b: (b,)) -> Self { + c { f: Box::new(b.0) } //~ ERROR + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/type-alias-free-regions.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/type-alias-free-regions.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/type-alias-free-regions.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/type-alias-free-regions.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +error: unsatisfied lifetime constraints + --> $DIR/type-alias-free-regions.rs:19:9 + | +LL | impl<'a> FromBox<'a> for c<'a> { + | -- lifetime `'a` defined here +LL | fn from_box(b: Box) -> Self { + | - has type `std::boxed::Box>` +LL | c { f: b } //~ ERROR + | ^^^^^^^^^^ returning this value requires that `'1` must outlive `'a` + +error: unsatisfied lifetime constraints + --> $DIR/type-alias-free-regions.rs:29:9 + | +LL | impl<'a> FromTuple<'a> for c<'a> { + | -- lifetime `'a` defined here +LL | fn from_tuple(b: (b,)) -> Self { + | - has type `(std::boxed::Box<&'1 isize>,)` +LL | c { f: Box::new(b.0) } //~ ERROR + | ^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'a` + +error: aborting due to 2 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/adt-brace-enums.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/adt-brace-enums.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/adt-brace-enums.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/adt-brace-enums.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,39 +2,40 @@ --> $DIR/adt-brace-enums.rs:37:48 | LL | SomeEnum::SomeVariant::<&'static u32> { t: &c }; //~ ERROR - | ^^ borrowed value does not live long enough + | ^^ + | | + | borrowed value does not live long enough + | requires that `c` is borrowed for `'static` LL | } | - `c` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error[E0597]: `c` does not live long enough --> $DIR/adt-brace-enums.rs:42:43 | +LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { + | -- lifetime `'a` defined here +LL | let c = 66; LL | SomeEnum::SomeVariant::<&'a u32> { t: &c }; //~ ERROR - | ^^ borrowed value does not live long enough + | ^^ + | | + | borrowed value does not live long enough + | requires that `c` is borrowed for `'a` LL | } | - `c` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 40:35... - --> $DIR/adt-brace-enums.rs:40:35 - | -LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { - | ^^ error[E0597]: `c` does not live long enough --> $DIR/adt-brace-enums.rs:52:47 | +LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { + | -- lifetime `'a` defined here +... LL | SomeEnum::SomeVariant::<&'a u32> { t: &c }; //~ ERROR - | ^^ borrowed value does not live long enough + | ^^ + | | + | borrowed value does not live long enough + | requires that `c` is borrowed for `'a` LL | }; | - `c` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 49:46... - --> $DIR/adt-brace-enums.rs:49:46 - | -LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { - | ^^ error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/adt-brace-structs.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/adt-brace-structs.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/adt-brace-structs.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/adt-brace-structs.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,39 +2,40 @@ --> $DIR/adt-brace-structs.rs:35:37 | LL | SomeStruct::<&'static u32> { t: &c }; //~ ERROR - | ^^ borrowed value does not live long enough + | ^^ + | | + | borrowed value does not live long enough + | requires that `c` is borrowed for `'static` LL | } | - `c` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error[E0597]: `c` does not live long enough --> $DIR/adt-brace-structs.rs:40:32 | +LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { + | -- lifetime `'a` defined here +LL | let c = 66; LL | SomeStruct::<&'a u32> { t: &c }; //~ ERROR - | ^^ borrowed value does not live long enough + | ^^ + | | + | borrowed value does not live long enough + | requires that `c` is borrowed for `'a` LL | } | - `c` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 38:35... - --> $DIR/adt-brace-structs.rs:38:35 - | -LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { - | ^^ error[E0597]: `c` does not live long enough --> $DIR/adt-brace-structs.rs:50:36 | +LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { + | -- lifetime `'a` defined here +... LL | SomeStruct::<&'a u32> { t: &c }; //~ ERROR - | ^^ borrowed value does not live long enough + | ^^ + | | + | borrowed value does not live long enough + | requires that `c` is borrowed for `'a` LL | }; | - `c` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 47:46... - --> $DIR/adt-brace-structs.rs:47:46 - | -LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { - | ^^ error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/adt-nullary-enums.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/adt-nullary-enums.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/adt-nullary-enums.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/adt-nullary-enums.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,42 +2,43 @@ --> $DIR/adt-nullary-enums.rs:44:41 | LL | SomeEnum::SomeVariant(Cell::new(&c)), //~ ERROR - | ^^ borrowed value does not live long enough + | ----------^^- + | | | + | | borrowed value does not live long enough + | argument requires that `c` is borrowed for `'static` ... LL | } | - `c` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error[E0597]: `c` does not live long enough --> $DIR/adt-nullary-enums.rs:52:41 | +LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { + | -- lifetime `'a` defined here +... LL | SomeEnum::SomeVariant(Cell::new(&c)), //~ ERROR - | ^^ borrowed value does not live long enough + | ----------^^- + | | | + | | borrowed value does not live long enough + | argument requires that `c` is borrowed for `'a` ... LL | } | - `c` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 49:35... - --> $DIR/adt-nullary-enums.rs:49:35 - | -LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { - | ^^ error[E0597]: `c` does not live long enough --> $DIR/adt-nullary-enums.rs:65:45 | +LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { + | -- lifetime `'a` defined here +... LL | SomeEnum::SomeVariant(Cell::new(&c)), //~ ERROR - | ^^ borrowed value does not live long enough + | ----------^^- + | | | + | | borrowed value does not live long enough + | argument requires that `c` is borrowed for `'a` ... LL | }; | - `c` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 61:46... - --> $DIR/adt-nullary-enums.rs:61:46 - | -LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { - | ^^ error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/adt-tuple-enums.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/adt-tuple-enums.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/adt-tuple-enums.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/adt-tuple-enums.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,39 +2,40 @@ --> $DIR/adt-tuple-enums.rs:39:43 | LL | SomeEnum::SomeVariant::<&'static u32>(&c); //~ ERROR - | ^^ borrowed value does not live long enough + | ^^ + | | + | borrowed value does not live long enough + | requires that `c` is borrowed for `'static` LL | } | - `c` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error[E0597]: `c` does not live long enough --> $DIR/adt-tuple-enums.rs:44:38 | +LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { + | -- lifetime `'a` defined here +LL | let c = 66; LL | SomeEnum::SomeVariant::<&'a u32>(&c); //~ ERROR - | ^^ borrowed value does not live long enough + | ^^ + | | + | borrowed value does not live long enough + | requires that `c` is borrowed for `'a` LL | } | - `c` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 42:35... - --> $DIR/adt-tuple-enums.rs:42:35 - | -LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { - | ^^ error[E0597]: `c` does not live long enough --> $DIR/adt-tuple-enums.rs:54:42 | +LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { + | -- lifetime `'a` defined here +... LL | SomeEnum::SomeVariant::<&'a u32>(&c); //~ ERROR - | ^^ borrowed value does not live long enough + | ^^ + | | + | borrowed value does not live long enough + | requires that `c` is borrowed for `'a` LL | }; | - `c` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 51:46... - --> $DIR/adt-tuple-enums.rs:51:46 - | -LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { - | ^^ error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/adt-tuple-struct.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/adt-tuple-struct.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/adt-tuple-struct.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/adt-tuple-struct.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,39 +2,40 @@ --> $DIR/adt-tuple-struct.rs:35:32 | LL | SomeStruct::<&'static u32>(&c); //~ ERROR - | ^^ borrowed value does not live long enough + | ^^ + | | + | borrowed value does not live long enough + | requires that `c` is borrowed for `'static` LL | } | - `c` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error[E0597]: `c` does not live long enough --> $DIR/adt-tuple-struct.rs:40:27 | +LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { + | -- lifetime `'a` defined here +LL | let c = 66; LL | SomeStruct::<&'a u32>(&c); //~ ERROR - | ^^ borrowed value does not live long enough + | ^^ + | | + | borrowed value does not live long enough + | requires that `c` is borrowed for `'a` LL | } | - `c` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 38:35... - --> $DIR/adt-tuple-struct.rs:38:35 - | -LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { - | ^^ error[E0597]: `c` does not live long enough --> $DIR/adt-tuple-struct.rs:50:31 | +LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { + | -- lifetime `'a` defined here +... LL | SomeStruct::<&'a u32>(&c); //~ ERROR - | ^^ borrowed value does not live long enough + | ^^ + | | + | borrowed value does not live long enough + | requires that `c` is borrowed for `'a` LL | }; | - `c` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 47:46... - --> $DIR/adt-tuple-struct.rs:47:46 - | -LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { - | ^^ error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/cast_static_lifetime.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/cast_static_lifetime.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/cast_static_lifetime.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/cast_static_lifetime.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(warnings)] +#![feature(nll)] + +fn main() { + let x = 22_u32; + let y: &u32 = (&x) as &'static u32; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/cast_static_lifetime.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/cast_static_lifetime.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/cast_static_lifetime.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/cast_static_lifetime.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error[E0597]: `x` does not live long enough + --> $DIR/cast_static_lifetime.rs:16:19 + | +LL | let y: &u32 = (&x) as &'static u32; + | ^^^^---------------- + | | + | borrowed value does not live long enough + | type annotation requires that `x` is borrowed for `'static` +LL | } + | - `x` dropped here while still borrowed + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/closure-substs.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/closure-substs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/closure-substs.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/closure-substs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(nll)] + +// Test that we enforce user-provided type annotations on closures. + +fn foo<'a>() { + // Here `x` is free in the closure sig: + |x: &'a i32| -> &'static i32 { + return x; //~ ERROR unsatisfied lifetime constraints + }; +} + +fn foo1() { + // Here `x` is bound in the closure sig: + |x: &i32| -> &'static i32 { + return x; //~ ERROR unsatisfied lifetime constraints + }; +} + +fn bar<'a>() { + // Here `x` is free in the closure sig: + |x: &'a i32, b: fn(&'static i32)| { + b(x); //~ ERROR unsatisfied lifetime constraints + }; +} + +fn bar1() { + // Here `x` is bound in the closure sig: + |x: &i32, b: fn(&'static i32)| { + b(x); //~ ERROR borrowed data escapes outside of closure + }; +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/closure-substs.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/closure-substs.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/closure-substs.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/closure-substs.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +error: unsatisfied lifetime constraints + --> $DIR/closure-substs.rs:18:16 + | +LL | fn foo<'a>() { + | -- lifetime `'a` defined here +... +LL | return x; //~ ERROR unsatisfied lifetime constraints + | ^ returning this value requires that `'a` must outlive `'static` + +error: unsatisfied lifetime constraints + --> $DIR/closure-substs.rs:25:16 + | +LL | |x: &i32| -> &'static i32 { + | - let's call the lifetime of this reference `'1` +LL | return x; //~ ERROR unsatisfied lifetime constraints + | ^ returning this value requires that `'1` must outlive `'static` + +error: unsatisfied lifetime constraints + --> $DIR/closure-substs.rs:32:9 + | +LL | fn bar<'a>() { + | -- lifetime `'a` defined here +... +LL | b(x); //~ ERROR unsatisfied lifetime constraints + | ^^^^ argument requires that `'a` must outlive `'static` + +error[E0521]: borrowed data escapes outside of closure + --> $DIR/closure-substs.rs:39:9 + | +LL | |x: &i32, b: fn(&'static i32)| { + | - `x` is a reference that is only valid in the closure body +LL | b(x); //~ ERROR borrowed data escapes outside of closure + | ^^^^ `x` escapes the closure body here + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0521`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +#![feature(nll)] + +struct Foo<'a> { x: &'a u32 } + +impl<'a> Foo<'a> { + const C: &'a u32 = &22; +} + +fn foo<'a>(_: &'a u32) -> &'static u32 { + >::C //~ ERROR +} + +fn main() { +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-inherent-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: unsatisfied lifetime constraints + --> $DIR/constant-in-expr-inherent-1.rs:10:5 + | +LL | fn foo<'a>(_: &'a u32) -> &'static u32 { + | -- lifetime `'a` defined here +LL | >::C //~ ERROR + | ^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-normalize.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-normalize.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-normalize.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-normalize.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +#![feature(nll)] + +trait Mirror { + type Me; +} + +impl Mirror for T { + type Me = T; +} + +trait Foo<'a> { + const C: <&'a u32 as Mirror>::Me; +} + +impl<'a, T> Foo<'a> for T { + const C: &'a u32 = &22; +} + +fn foo<'a>(_: &'a u32) -> &'static u32 { + <() as Foo<'a>>::C //~ ERROR +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-normalize.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-normalize.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-normalize.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-normalize.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: unsatisfied lifetime constraints + --> $DIR/constant-in-expr-normalize.rs:20:5 + | +LL | fn foo<'a>(_: &'a u32) -> &'static u32 { + | -- lifetime `'a` defined here +LL | <() as Foo<'a>>::C //~ ERROR + | ^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +#![feature(nll)] + +trait Foo<'a> { + const C: &'a u32; +} + +impl<'a, T> Foo<'a> for T { + const C: &'a u32 = &22; +} + +fn foo<'a>(_: &'a u32) -> &'static u32 { + <() as Foo<'a>>::C //~ ERROR +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-1.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: unsatisfied lifetime constraints + --> $DIR/constant-in-expr-trait-item-1.rs:12:5 + | +LL | fn foo<'a>(_: &'a u32) -> &'static u32 { + | -- lifetime `'a` defined here +LL | <() as Foo<'a>>::C //~ ERROR + | ^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +#![feature(nll)] + +trait Foo<'a> { + const C: &'a u32; +} + +impl<'a, T> Foo<'a> for T { + const C: &'a u32 = &22; +} + +fn foo<'a, T: Foo<'a>>() -> &'static u32 { + >::C //~ ERROR +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: unsatisfied lifetime constraints + --> $DIR/constant-in-expr-trait-item-2.rs:12:5 + | +LL | fn foo<'a, T: Foo<'a>>() -> &'static u32 { + | -- lifetime `'a` defined here +LL | >::C //~ ERROR + | ^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +#![feature(nll)] + +trait Foo<'a> { + const C: &'a u32; +} + +impl<'a, T> Foo<'a> for T { + const C: &'a u32 = &22; +} + +fn foo<'a, T: Foo<'a>>() -> &'static u32 { + T::C //~ ERROR +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-3.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-3.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-3.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/constant-in-expr-trait-item-3.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: unsatisfied lifetime constraints + --> $DIR/constant-in-expr-trait-item-3.rs:12:5 + | +LL | fn foo<'a, T: Foo<'a>>() -> &'static u32 { + | -- lifetime `'a` defined here +LL | T::C //~ ERROR + | ^^^^ returning this value requires that `'a` must outlive `'static` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/dump-adt-brace-struct.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/dump-adt-brace-struct.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/dump-adt-brace-struct.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/dump-adt-brace-struct.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ -error: user substs: Canonical { variables: [], value: [u32] } +error: user substs: Canonical { variables: [], value: UserSubsts { substs: [u32], user_self_ty: None } } --> $DIR/dump-adt-brace-struct.rs:28:5 | LL | SomeStruct:: { t: 22 }; //~ ERROR [u32] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/dump-fn-method.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/dump-fn-method.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/dump-fn-method.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/dump-fn-method.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,22 +1,22 @@ -error: user substs: Canonical { variables: [], value: [u32] } +error: user substs: Canonical { variables: [], value: UserSubsts { substs: [u32], user_self_ty: None } } --> $DIR/dump-fn-method.rs:36:13 | LL | let x = foo::; //~ ERROR [u32] | ^^^^^^^^^^ -error: user substs: Canonical { variables: [CanonicalVarInfo { kind: Ty(General) }, CanonicalVarInfo { kind: Ty(General) }], value: [?0, u32, ?1] } +error: user substs: Canonical { variables: [CanonicalVarInfo { kind: Ty(General) }, CanonicalVarInfo { kind: Ty(General) }], value: UserSubsts { substs: [?0, u32, ?1], user_self_ty: None } } --> $DIR/dump-fn-method.rs:42:13 | LL | let x = <_ as Bazoom>::method::<_>; //~ ERROR [?0, u32, ?1] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: user substs: Canonical { variables: [], value: [u8, u16, u32] } +error: user substs: Canonical { variables: [], value: UserSubsts { substs: [u8, u16, u32], user_self_ty: None } } --> $DIR/dump-fn-method.rs:46:13 | LL | let x = >::method::; //~ ERROR [u8, u16, u32] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: user substs: Canonical { variables: [CanonicalVarInfo { kind: Ty(General) }, CanonicalVarInfo { kind: Ty(General) }], value: [?0, ?1, u32] } +error: user substs: Canonical { variables: [CanonicalVarInfo { kind: Ty(General) }, CanonicalVarInfo { kind: Ty(General) }], value: UserSubsts { substs: [?0, ?1, u32], user_self_ty: None } } --> $DIR/dump-fn-method.rs:54:5 | LL | y.method::(44, 66); //~ ERROR [?0, ?1, u32] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/fns.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/fns.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/fns.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/fns.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,39 +2,40 @@ --> $DIR/fns.rs:35:29 | LL | some_fn::<&'static u32>(&c); //~ ERROR - | ^^ borrowed value does not live long enough + | ------------------------^^- + | | | + | | borrowed value does not live long enough + | argument requires that `c` is borrowed for `'static` LL | } | - `c` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error[E0597]: `c` does not live long enough --> $DIR/fns.rs:40:24 | +LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { + | -- lifetime `'a` defined here +LL | let c = 66; LL | some_fn::<&'a u32>(&c); //~ ERROR - | ^^ borrowed value does not live long enough + | -------------------^^- + | | | + | | borrowed value does not live long enough + | argument requires that `c` is borrowed for `'a` LL | } | - `c` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 38:35... - --> $DIR/fns.rs:38:35 - | -LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { - | ^^ error[E0597]: `c` does not live long enough --> $DIR/fns.rs:50:28 | +LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { + | -- lifetime `'a` defined here +... LL | some_fn::<&'a u32>(&c); //~ ERROR - | ^^ borrowed value does not live long enough + | -------------------^^- + | | | + | | borrowed value does not live long enough + | argument requires that `c` is borrowed for `'a` LL | }; | - `c` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 47:46... - --> $DIR/fns.rs:47:46 - | -LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { - | ^^ error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/issue-54124.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/issue-54124.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/issue-54124.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/issue-54124.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +#![feature(nll)] + +fn test<'a>() { + let _:fn(&()) = |_:&'a ()| {}; +} + +fn main() { + test(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/issue-54124.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/issue-54124.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/issue-54124.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/issue-54124.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +error: unsatisfied lifetime constraints + --> $DIR/issue-54124.rs:4:22 + | +LL | fn test<'a>() { + | -- lifetime `'a` defined here +LL | let _:fn(&()) = |_:&'a ()| {}; + | ^ - let's call the lifetime of this reference `'1` + | | + | requires that `'1` must outlive `'a` + +error: unsatisfied lifetime constraints + --> $DIR/issue-54124.rs:4:22 + | +LL | fn test<'a>() { + | -- lifetime `'a` defined here +LL | let _:fn(&()) = |_:&'a ()| {}; + | ^ requires that `'a` must outlive `'static` + +error: aborting due to 2 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/issue-54570-bootstrapping.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/issue-54570-bootstrapping.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/issue-54570-bootstrapping.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/issue-54570-bootstrapping.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// compile-pass +#![feature(nll)] + +// This test is reduced from a scenario pnkfelix encountered while +// bootstrapping the compiler. + +#[derive(Copy, Clone)] +pub struct Spanned { + pub node: T, + pub span: Span, +} + +pub type Variant = Spanned; +// #[derive(Clone)] pub struct Variant { pub node: VariantKind, pub span: Span, } + +#[derive(Clone)] +pub struct VariantKind { } + +#[derive(Copy, Clone)] +pub struct Span; + +pub fn variant_to_span(variant: Variant) { + match variant { + Variant { + span: _span, + .. + } => { } + }; +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/issue-55219.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/issue-55219.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/issue-55219.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/issue-55219.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Regression test for #55219: +// +// The `Self::HASH_LEN` here expands to a "self-type" where `T` is not +// known. This unbound inference variable was causing an ICE. +// +// run-pass + +#![feature(nll)] + +pub struct Foo(T); + +impl Foo { + const HASH_LEN: usize = 20; + + fn stuff() { + let _ = Self::HASH_LEN; + } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/issue-55241.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/issue-55241.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/issue-55241.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/issue-55241.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// Regression test for #55241: +// +// The reference to `C::HASHED_NULL_NODE` resulted in a type like `>::Out`; normalizing this type requires knowing the +// value of `_`; solving that requires having normalized, so we can +// test against `C: NodeCodec` in the environment. +// +// run-pass + +#![feature(nll)] + +pub trait Hasher { + type Out: Eq; +} + +pub trait NodeCodec { + const HASHED_NULL_NODE: H::Out; +} + +pub trait Trie> { + /// Return the root of the trie. + fn root(&self) -> &H::Out; + + /// Is the trie empty? + fn is_empty(&self) -> bool { *self.root() == C::HASHED_NULL_NODE } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-call.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-call.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-call.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-call.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,39 +2,40 @@ --> $DIR/method-call.rs:48:34 | LL | a.method::<&'static u32>(b, &c); //~ ERROR - | ^^ borrowed value does not live long enough + | -----------------------------^^- + | | | + | | borrowed value does not live long enough + | argument requires that `c` is borrowed for `'static` LL | } | - `c` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error[E0597]: `c` does not live long enough --> $DIR/method-call.rs:55:29 | +LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { + | -- lifetime `'a` defined here +... LL | a.method::<&'a u32>(b, &c); //~ ERROR - | ^^ borrowed value does not live long enough + | ------------------------^^- + | | | + | | borrowed value does not live long enough + | argument requires that `c` is borrowed for `'a` LL | } | - `c` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 51:35... - --> $DIR/method-call.rs:51:35 - | -LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { - | ^^ error[E0597]: `c` does not live long enough --> $DIR/method-call.rs:69:33 | +LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { + | -- lifetime `'a` defined here +... LL | a.method::<&'a u32>(b, &c); //~ ERROR - | ^^ borrowed value does not live long enough + | ------------------------^^- + | | | + | | borrowed value does not live long enough + | argument requires that `c` is borrowed for `'a` LL | }; | - `c` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 64:46... - --> $DIR/method-call.rs:64:46 - | -LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { - | ^^ error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-1.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,43 +2,44 @@ --> $DIR/method-ufcs-1.rs:42:7 | LL | x(&a, b, c); //~ ERROR - | ^^ borrowed value does not live long enough + | --^^------- + | | | + | | borrowed value does not live long enough + | argument requires that `a` is borrowed for `'static` LL | } | - `a` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error[E0597]: `a` does not live long enough --> $DIR/method-ufcs-1.rs:49:36 | +LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { + | -- lifetime `'a` defined here +... LL | <&'a u32 as Bazoom<_>>::method(&a, b, c); //~ ERROR - | ^^ borrowed value does not live long enough + | -------------------------------^^------- + | | | + | | borrowed value does not live long enough + | argument requires that `a` is borrowed for `'a` LL | } | - `a` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 45:35... - --> $DIR/method-ufcs-1.rs:45:35 - | -LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { - | ^^ error[E0597]: `a` does not live long enough --> $DIR/method-ufcs-1.rs:63:41 | +LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { + | -- lifetime `'a` defined here +... LL | let _closure = || { | -- value captured here LL | let c = 66; LL | <&'a u32 as Bazoom<_>>::method(&a, b, c); //~ ERROR - | ^ borrowed value does not live long enough + | --------------------------------^------- + | | | + | | borrowed value does not live long enough + | argument requires that `a` is borrowed for `'a` LL | }; LL | } | - `a` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 58:46... - --> $DIR/method-ufcs-1.rs:58:46 - | -LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { - | ^^ error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-2.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,43 +2,44 @@ --> $DIR/method-ufcs-2.rs:42:7 | LL | x(&a, b, c); //~ ERROR - | ^^ borrowed value does not live long enough + | --^^------- + | | | + | | borrowed value does not live long enough + | argument requires that `a` is borrowed for `'static` LL | } | - `a` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error[E0597]: `b` does not live long enough --> $DIR/method-ufcs-2.rs:49:39 | +LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { + | -- lifetime `'a` defined here +... LL | <_ as Bazoom<&'a u32>>::method(a, &b, c); //~ ERROR - | ^^ borrowed value does not live long enough + | ----------------------------------^^---- + | | | + | | borrowed value does not live long enough + | argument requires that `b` is borrowed for `'a` LL | } | - `b` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 45:35... - --> $DIR/method-ufcs-2.rs:45:35 - | -LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { - | ^^ error[E0597]: `b` does not live long enough --> $DIR/method-ufcs-2.rs:63:44 | +LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { + | -- lifetime `'a` defined here +... LL | let _closure = || { | -- value captured here LL | let c = 66; LL | <_ as Bazoom<&'a u32>>::method(a, &b, c); //~ ERROR - | ^ borrowed value does not live long enough + | -----------------------------------^---- + | | | + | | borrowed value does not live long enough + | argument requires that `b` is borrowed for `'a` LL | }; LL | } | - `b` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 58:46... - --> $DIR/method-ufcs-2.rs:58:46 - | -LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { - | ^^ error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-3.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-3.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-3.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-3.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,39 +2,40 @@ --> $DIR/method-ufcs-3.rs:48:53 | LL | <_ as Bazoom<_>>::method::<&'static u32>(&a, b, &c); //~ ERROR - | ^^ borrowed value does not live long enough + | ------------------------------------------------^^- + | | | + | | borrowed value does not live long enough + | argument requires that `c` is borrowed for `'static` LL | } | - `c` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error[E0597]: `c` does not live long enough --> $DIR/method-ufcs-3.rs:55:48 | +LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { + | -- lifetime `'a` defined here +... LL | <_ as Bazoom<_>>::method::<&'a u32>(&a, b, &c); //~ ERROR - | ^^ borrowed value does not live long enough + | -------------------------------------------^^- + | | | + | | borrowed value does not live long enough + | argument requires that `c` is borrowed for `'a` LL | } | - `c` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 51:35... - --> $DIR/method-ufcs-3.rs:51:35 - | -LL | fn annot_reference_named_lifetime<'a>(_d: &'a u32) { - | ^^ error[E0597]: `c` does not live long enough --> $DIR/method-ufcs-3.rs:69:52 | +LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { + | -- lifetime `'a` defined here +... LL | <_ as Bazoom<_>>::method::<&'a u32>(&a, b, &c); //~ ERROR - | ^^ borrowed value does not live long enough + | -------------------------------------------^^- + | | | + | | borrowed value does not live long enough + | argument requires that `c` is borrowed for `'a` LL | }; | - `c` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 64:46... - --> $DIR/method-ufcs-3.rs:64:46 - | -LL | fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { - | ^^ error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +#![feature(nll)] + +// Check that substitutions given on the self type (here, `A`) carry +// through to NLL. + +struct A<'a> { x: &'a u32 } + +impl<'a> A<'a> { + fn new<'b, T>(x: &'a u32, y: T) -> Self { + Self { x } + } +} + +fn foo<'a>() { + let v = 22; + let x = A::<'a>::new(&v, 22); + //~^ ERROR +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-1.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +error[E0597]: `v` does not live long enough + --> $DIR/method-ufcs-inherent-1.rs:16:26 + | +LL | fn foo<'a>() { + | -- lifetime `'a` defined here +LL | let v = 22; +LL | let x = A::<'a>::new(&v, 22); + | -------------^^----- + | | | + | | borrowed value does not live long enough + | argument requires that `v` is borrowed for `'a` +LL | //~^ ERROR +LL | } + | - `v` dropped here while still borrowed + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +#![feature(nll)] + +// Check that substitutions given on the self type (here, `A`) can be +// used in combination with annotations given for method arguments. + +struct A<'a> { x: &'a u32 } + +impl<'a> A<'a> { + fn new<'b, T>(x: &'a u32, y: T) -> Self { + Self { x } + } +} + +fn foo<'a>() { + let v = 22; + let x = A::<'a>::new::<&'a u32>(&v, &v); + //~^ ERROR + //~| ERROR +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +error[E0597]: `v` does not live long enough + --> $DIR/method-ufcs-inherent-2.rs:16:37 + | +LL | fn foo<'a>() { + | -- lifetime `'a` defined here +LL | let v = 22; +LL | let x = A::<'a>::new::<&'a u32>(&v, &v); + | ------------------------^^----- + | | | + | | borrowed value does not live long enough + | argument requires that `v` is borrowed for `'a` +... +LL | } + | - `v` dropped here while still borrowed + +error[E0597]: `v` does not live long enough + --> $DIR/method-ufcs-inherent-2.rs:16:41 + | +LL | fn foo<'a>() { + | -- lifetime `'a` defined here +LL | let v = 22; +LL | let x = A::<'a>::new::<&'a u32>(&v, &v); + | ----------------------------^^- + | | | + | | borrowed value does not live long enough + | argument requires that `v` is borrowed for `'a` +... +LL | } + | - `v` dropped here while still borrowed + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +#![feature(nll)] + +// Check that inherent methods invoked with `::new` style +// carry their annotations through to NLL. + +struct A<'a> { x: &'a u32 } + +impl<'a> A<'a> { + fn new<'b, T>(x: &'a u32, y: T) -> Self { + Self { x } + } +} + +fn foo<'a>() { + let v = 22; + let x = >::new(&v, 22); + //~^ ERROR +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-3.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-3.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-3.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-3.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +error[E0597]: `v` does not live long enough + --> $DIR/method-ufcs-inherent-3.rs:16:26 + | +LL | fn foo<'a>() { + | -- lifetime `'a` defined here +LL | let v = 22; +LL | let x = >::new(&v, 22); + | -------------^^----- + | | | + | | borrowed value does not live long enough + | argument requires that `v` is borrowed for `'a` +LL | //~^ ERROR +LL | } + | - `v` dropped here while still borrowed + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-4.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-4.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-4.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +#![feature(nll)] + +// Check that inherent methods invoked with `::new` style +// carry their annotations through to NLL in connection with +// method type parameters. + +struct A<'a> { x: &'a u32 } + +impl<'a> A<'a> { + fn new<'b, T>(x: &'a u32, y: T) -> Self { + Self { x } + } +} + +fn foo<'a>() { + let v = 22; + let x = >::new::<&'a u32>(&v, &v); + //~^ ERROR + //~| ERROR +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-4.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-4.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-4.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/method-ufcs-inherent-4.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +error[E0597]: `v` does not live long enough + --> $DIR/method-ufcs-inherent-4.rs:17:37 + | +LL | fn foo<'a>() { + | -- lifetime `'a` defined here +LL | let v = 22; +LL | let x = >::new::<&'a u32>(&v, &v); + | ------------------------^^----- + | | | + | | borrowed value does not live long enough + | argument requires that `v` is borrowed for `'a` +... +LL | } + | - `v` dropped here while still borrowed + +error[E0597]: `v` does not live long enough + --> $DIR/method-ufcs-inherent-4.rs:17:41 + | +LL | fn foo<'a>() { + | -- lifetime `'a` defined here +LL | let v = 22; +LL | let x = >::new::<&'a u32>(&v, &v); + | ----------------------------^^- + | | | + | | borrowed value does not live long enough + | argument requires that `v` is borrowed for `'a` +... +LL | } + | - `v` dropped here while still borrowed + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/normalization.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/normalization.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/normalization.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/normalization.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// Test that we enforce a `&'static` requirement that is only visible +// after normalization. + +#![feature(nll)] +#![ignore(unused)] + +trait Foo { type Out; } +impl Foo for () { type Out = &'static u32; } + +fn main() { + let a = 22; + let b: <() as Foo>::Out = &a; //~ ERROR +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/normalization.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/normalization.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/normalization.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/normalization.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +error[E0597]: `a` does not live long enough + --> $DIR/normalization.rs:12:31 + | +LL | let b: <() as Foo>::Out = &a; //~ ERROR + | ---------------- ^^ borrowed value does not live long enough + | | + | type annotation requires that `a` is borrowed for `'static` +LL | } + | - `a` dropped here while still borrowed + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/normalize-self-ty.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/normalize-self-ty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/normalize-self-ty.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/normalize-self-ty.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Regression test for #55183: check a case where the self type from +// the inherent impl requires normalization to be equal to the +// user-provided type. +// +// run-pass + +#![feature(nll)] + +trait Mirror { + type Me; +} + +impl Mirror for T { + type Me = T; +} + +struct Foo(A, B); + +impl Foo::Me> { + fn m(b: A) { } +} + +fn main() { + >::m(&22); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/patterns.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/patterns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/patterns.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/patterns.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,11 +9,11 @@ } fn tuple_no_initializer() { - // FIXME(#47187): We are not propagating ascribed type through tuples. + let x = 22; let (y, z): (&'static u32, &'static u32); - y = &x; + y = &x; //~ ERROR } fn ref_with_ascribed_static_type() -> u32 { @@ -34,11 +34,23 @@ struct Single { value: T } fn struct_no_initializer() { - // FIXME(#47187): We are not propagating ascribed type through patterns. + let x = 22; let Single { value: y }: Single<&'static u32>; - y = &x; + y = &x; //~ ERROR +} + + +fn struct_no_initializer_must_normalize() { + trait Indirect { type Assoc; } + struct StaticU32; + impl Indirect for StaticU32 { type Assoc = &'static u32; } + struct Single2 { value: ::Assoc } + + let x = 22; + let Single2 { value: mut _y }: Single2; + _y = &x; //~ ERROR } fn variable_with_initializer() { @@ -51,13 +63,13 @@ let _: &'static u32 = &x; //~ ERROR let _: Vec<&'static String> = vec![&String::new()]; - //~^ ERROR borrowed value does not live long enough [E0597] + //~^ ERROR temporary value dropped while borrowed [E0716] let (_, a): (Vec<&'static String>, _) = (vec![&String::new()], 44); - //~^ ERROR borrowed value does not live long enough [E0597] + //~^ ERROR temporary value dropped while borrowed [E0716] let (_a, b): (Vec<&'static String>, _) = (vec![&String::new()], 44); - //~^ ERROR borrowed value does not live long enough [E0597] + //~^ ERROR temporary value dropped while borrowed [E0716] } fn pair_underscores_with_initializer() { @@ -91,26 +103,31 @@ } fn static_to_a_to_static_through_variable<'a>(x: &'a u32) -> &'static u32 { - // The error in this test is inconsistency with - // `static_to_a_to_static_through_tuple`, but "feels right" to - // me. It occurs because we special case the single binding case - // and force the type of `y` to be `&'a u32`, even though the - // right-hand side has type `&'static u32`. + + + + + let y: &'a u32 = &22; y //~ ERROR } fn static_to_a_to_static_through_tuple<'a>(x: &'a u32) -> &'static u32 { - // FIXME(#47187): The fact that this type-checks is perhaps surprising. - // What happens is that the right-hand side is constrained to have - // type `&'a u32`, which is possible, because it has type - // `&'static u32`. The variable `y` is then forced to have type - // `&'static u32`, but it is constrained only by the right-hand - // side, not the ascribed type, and hence it passes. + + + + + + let (y, _z): (&'a u32, u32) = (&22, 44); - y + y //~ ERROR +} + +fn static_to_a_to_static_through_struct<'a>(_x: &'a u32) -> &'static u32 { + let Single { value: y }: Single<&'a u32> = Single { value: &22 }; + y //~ ERROR } fn a_to_static_then_static<'a>(x: &'a u32) -> &'static u32 { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/patterns.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/patterns.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/patterns.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/patterns.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,128 +1,155 @@ error[E0597]: `x` does not live long enough --> $DIR/patterns.rs:8:9 | +LL | let y: &'static u32; + | ------------ type annotation requires that `x` is borrowed for `'static` LL | y = &x; //~ ERROR | ^^ borrowed value does not live long enough LL | } | - `x` dropped here while still borrowed + +error[E0597]: `x` does not live long enough + --> $DIR/patterns.rs:16:9 | - = note: borrowed value must be valid for the static lifetime... +LL | let (y, z): (&'static u32, &'static u32); + | ---------------------------- type annotation requires that `x` is borrowed for `'static` +LL | y = &x; //~ ERROR + | ^^ borrowed value does not live long enough +LL | } + | - `x` dropped here while still borrowed error[E0597]: `x` does not live long enough --> $DIR/patterns.rs:22:13 | LL | let y = &x; //~ ERROR | ^^ borrowed value does not live long enough -... +LL | let ref z: &'static u32 = y; + | ------------ type annotation requires that `x` is borrowed for `'static` +LL | **z +LL | } + | - `x` dropped here while still borrowed + +error[E0597]: `x` does not live long enough + --> $DIR/patterns.rs:41:9 + | +LL | let Single { value: y }: Single<&'static u32>; + | -------------------- type annotation requires that `x` is borrowed for `'static` +LL | y = &x; //~ ERROR + | ^^ borrowed value does not live long enough LL | } | - `x` dropped here while still borrowed + +error[E0597]: `x` does not live long enough + --> $DIR/patterns.rs:53:10 | - = note: borrowed value must be valid for the static lifetime... +LL | let Single2 { value: mut _y }: Single2; + | ------------------ type annotation requires that `x` is borrowed for `'static` +LL | _y = &x; //~ ERROR + | ^^ borrowed value does not live long enough +LL | } + | - `x` dropped here while still borrowed error[E0597]: `x` does not live long enough - --> $DIR/patterns.rs:46:27 + --> $DIR/patterns.rs:58:27 | LL | let y: &'static u32 = &x; //~ ERROR - | ^^ borrowed value does not live long enough + | ------------ ^^ borrowed value does not live long enough + | | + | type annotation requires that `x` is borrowed for `'static` LL | } | - `x` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error[E0597]: `x` does not live long enough - --> $DIR/patterns.rs:51:27 + --> $DIR/patterns.rs:63:27 | LL | let _: &'static u32 = &x; //~ ERROR - | ^^ borrowed value does not live long enough + | ------------ ^^ borrowed value does not live long enough + | | + | type annotation requires that `x` is borrowed for `'static` ... LL | } | - `x` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... -error[E0597]: borrowed value does not live long enough - --> $DIR/patterns.rs:53:41 +error[E0716]: temporary value dropped while borrowed + --> $DIR/patterns.rs:65:41 | LL | let _: Vec<&'static String> = vec![&String::new()]; - | ^^^^^^^^^^^^^ - temporary value only lives until here - | | - | temporary value does not live long enough - | - = note: borrowed value must be valid for the static lifetime... + | -------------------- ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement + | | | + | | creates a temporary which is freed while still in use + | type annotation requires that borrow lasts for `'static` -error[E0597]: borrowed value does not live long enough - --> $DIR/patterns.rs:56:52 +error[E0716]: temporary value dropped while borrowed + --> $DIR/patterns.rs:68:52 | LL | let (_, a): (Vec<&'static String>, _) = (vec![&String::new()], 44); - | ^^^^^^^^^^^^^ - temporary value only lives until here - | | - | temporary value does not live long enough - | - = note: borrowed value must be valid for the static lifetime... + | ------------------------- ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement + | | | + | | creates a temporary which is freed while still in use + | type annotation requires that borrow lasts for `'static` -error[E0597]: borrowed value does not live long enough - --> $DIR/patterns.rs:59:53 +error[E0716]: temporary value dropped while borrowed + --> $DIR/patterns.rs:71:53 | LL | let (_a, b): (Vec<&'static String>, _) = (vec![&String::new()], 44); - | ^^^^^^^^^^^^^ - temporary value only lives until here - | | - | temporary value does not live long enough - | - = note: borrowed value must be valid for the static lifetime... + | ------------------------- ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement + | | | + | | creates a temporary which is freed while still in use + | type annotation requires that borrow lasts for `'static` error[E0597]: `x` does not live long enough - --> $DIR/patterns.rs:65:40 + --> $DIR/patterns.rs:77:40 | LL | let (_, _): (&'static u32, u32) = (&x, 44); //~ ERROR - | ^^ borrowed value does not live long enough + | ------------------- ^^ borrowed value does not live long enough + | | + | type annotation requires that `x` is borrowed for `'static` LL | } | - `x` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error[E0597]: `x` does not live long enough - --> $DIR/patterns.rs:70:40 + --> $DIR/patterns.rs:82:40 | LL | let (y, _): (&'static u32, u32) = (&x, 44); //~ ERROR - | ^^ borrowed value does not live long enough + | ------------------- ^^ borrowed value does not live long enough + | | + | type annotation requires that `x` is borrowed for `'static` LL | } | - `x` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error[E0597]: `x` does not live long enough - --> $DIR/patterns.rs:75:69 + --> $DIR/patterns.rs:87:69 | LL | let Single { value: y }: Single<&'static u32> = Single { value: &x }; //~ ERROR - | ^^ borrowed value does not live long enough + | -------------------- ^^ borrowed value does not live long enough + | | + | type annotation requires that `x` is borrowed for `'static` LL | } | - `x` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error[E0597]: `x` does not live long enough - --> $DIR/patterns.rs:80:69 + --> $DIR/patterns.rs:92:69 | LL | let Single { value: _ }: Single<&'static u32> = Single { value: &x }; //~ ERROR - | ^^ borrowed value does not live long enough + | -------------------- ^^ borrowed value does not live long enough + | | + | type annotation requires that `x` is borrowed for `'static` LL | } | - `x` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error[E0597]: `x` does not live long enough - --> $DIR/patterns.rs:88:17 + --> $DIR/patterns.rs:100:17 | +LL | let Double { value1: _, value2: _ }: Double<&'static u32> = Double { + | -------------------- type annotation requires that `x` is borrowed for `'static` LL | value1: &x, //~ ERROR | ^^ borrowed value does not live long enough ... LL | } | - `x` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error: unsatisfied lifetime constraints - --> $DIR/patterns.rs:101:5 + --> $DIR/patterns.rs:113:5 | LL | fn static_to_a_to_static_through_variable<'a>(x: &'a u32) -> &'static u32 { | -- lifetime `'a` defined here @@ -131,13 +158,32 @@ | ^ returning this value requires that `'a` must outlive `'static` error: unsatisfied lifetime constraints - --> $DIR/patterns.rs:117:40 + --> $DIR/patterns.rs:125:5 + | +LL | fn static_to_a_to_static_through_tuple<'a>(x: &'a u32) -> &'static u32 { + | -- lifetime `'a` defined here +... +LL | y //~ ERROR + | ^ returning this value requires that `'a` must outlive `'static` + +error: unsatisfied lifetime constraints + --> $DIR/patterns.rs:130:5 + | +LL | fn static_to_a_to_static_through_struct<'a>(_x: &'a u32) -> &'static u32 { + | -- lifetime `'a` defined here +LL | let Single { value: y }: Single<&'a u32> = Single { value: &22 }; +LL | y //~ ERROR + | ^ returning this value requires that `'a` must outlive `'static` + +error: unsatisfied lifetime constraints + --> $DIR/patterns.rs:134:18 | LL | fn a_to_static_then_static<'a>(x: &'a u32) -> &'static u32 { | -- lifetime `'a` defined here LL | let (y, _z): (&'static u32, u32) = (x, 44); //~ ERROR - | ^^^^^^^ requires that `'a` must outlive `'static` + | ^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` -error: aborting due to 14 previous errors +error: aborting due to 19 previous errors -For more information about this error, try `rustc --explain E0597`. +Some errors occurred: E0597, E0716. +For more information about an error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_brace_enum_variant.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_brace_enum_variant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_brace_enum_variant.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_brace_enum_variant.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +#![feature(nll)] + +enum Foo<'a> { + Bar { field: &'a u32 } +} + +fn in_let() { + let y = 22; + let foo = Foo::Bar { field: &y }; + //~^ ERROR `y` does not live long enough + let Foo::Bar::<'static> { field: _z } = foo; +} + +fn in_match() { + let y = 22; + let foo = Foo::Bar { field: &y }; + //~^ ERROR `y` does not live long enough + match foo { + Foo::Bar::<'static> { field: _z } => { + } + } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_brace_enum_variant.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_brace_enum_variant.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_brace_enum_variant.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_brace_enum_variant.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +error[E0597]: `y` does not live long enough + --> $DIR/pattern_substs_on_brace_enum_variant.rs:9:33 + | +LL | let foo = Foo::Bar { field: &y }; + | ^^ borrowed value does not live long enough +LL | //~^ ERROR `y` does not live long enough +LL | let Foo::Bar::<'static> { field: _z } = foo; + | --------------------------------- type annotation requires that `y` is borrowed for `'static` +LL | } + | - `y` dropped here while still borrowed + +error[E0597]: `y` does not live long enough + --> $DIR/pattern_substs_on_brace_enum_variant.rs:16:33 + | +LL | let foo = Foo::Bar { field: &y }; + | ^^ borrowed value does not live long enough +... +LL | Foo::Bar::<'static> { field: _z } => { + | --------------------------------- type annotation requires that `y` is borrowed for `'static` +... +LL | } + | - `y` dropped here while still borrowed + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_brace_struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_brace_struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_brace_struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_brace_struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +#![feature(nll)] + +struct Foo<'a> { field: &'a u32 } + +fn in_let() { + let y = 22; + let foo = Foo { field: &y }; + //~^ ERROR `y` does not live long enough + let Foo::<'static> { field: _z } = foo; +} + +fn in_main() { + let y = 22; + let foo = Foo { field: &y }; + //~^ ERROR `y` does not live long enough + match foo { + Foo::<'static> { field: _z } => { + } + } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_brace_struct.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_brace_struct.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_brace_struct.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_brace_struct.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +error[E0597]: `y` does not live long enough + --> $DIR/pattern_substs_on_brace_struct.rs:7:28 + | +LL | let foo = Foo { field: &y }; + | ^^ borrowed value does not live long enough +LL | //~^ ERROR `y` does not live long enough +LL | let Foo::<'static> { field: _z } = foo; + | ---------------------------- type annotation requires that `y` is borrowed for `'static` +LL | } + | - `y` dropped here while still borrowed + +error[E0597]: `y` does not live long enough + --> $DIR/pattern_substs_on_brace_struct.rs:14:28 + | +LL | let foo = Foo { field: &y }; + | ^^ borrowed value does not live long enough +... +LL | Foo::<'static> { field: _z } => { + | ---------------------------- type annotation requires that `y` is borrowed for `'static` +... +LL | } + | - `y` dropped here while still borrowed + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_tuple_enum_variant.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_tuple_enum_variant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_tuple_enum_variant.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_tuple_enum_variant.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +#![feature(nll)] + +enum Foo<'a> { + Bar(&'a u32) +} + +fn in_let() { + let y = 22; + let foo = Foo::Bar(&y); + //~^ ERROR `y` does not live long enough + let Foo::Bar::<'static>(_z) = foo; +} + +fn in_match() { + let y = 22; + let foo = Foo::Bar(&y); + //~^ ERROR `y` does not live long enough + match foo { + Foo::Bar::<'static>(_z) => { + } + } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_tuple_enum_variant.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_tuple_enum_variant.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_tuple_enum_variant.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_tuple_enum_variant.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +error[E0597]: `y` does not live long enough + --> $DIR/pattern_substs_on_tuple_enum_variant.rs:9:24 + | +LL | let foo = Foo::Bar(&y); + | ^^ borrowed value does not live long enough +LL | //~^ ERROR `y` does not live long enough +LL | let Foo::Bar::<'static>(_z) = foo; + | ----------------------- type annotation requires that `y` is borrowed for `'static` +LL | } + | - `y` dropped here while still borrowed + +error[E0597]: `y` does not live long enough + --> $DIR/pattern_substs_on_tuple_enum_variant.rs:16:24 + | +LL | let foo = Foo::Bar(&y); + | ^^ borrowed value does not live long enough +... +LL | Foo::Bar::<'static>(_z) => { + | ----------------------- type annotation requires that `y` is borrowed for `'static` +... +LL | } + | - `y` dropped here while still borrowed + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_tuple_struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_tuple_struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_tuple_struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_tuple_struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +#![feature(nll)] + +struct Foo<'a>(&'a u32); + +fn in_let() { + let y = 22; + let foo = Foo(&y); + //~^ ERROR `y` does not live long enough + let Foo::<'static>(_z) = foo; +} + +fn in_match() { + let y = 22; + let foo = Foo(&y); + //~^ ERROR `y` does not live long enough + match foo { + Foo::<'static>(_z) => { + } + } +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_tuple_struct.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_tuple_struct.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_tuple_struct.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/pattern_substs_on_tuple_struct.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +error[E0597]: `y` does not live long enough + --> $DIR/pattern_substs_on_tuple_struct.rs:7:19 + | +LL | let foo = Foo(&y); + | ^^ borrowed value does not live long enough +LL | //~^ ERROR `y` does not live long enough +LL | let Foo::<'static>(_z) = foo; + | ------------------ type annotation requires that `y` is borrowed for `'static` +LL | } + | - `y` dropped here while still borrowed + +error[E0597]: `y` does not live long enough + --> $DIR/pattern_substs_on_tuple_struct.rs:14:19 + | +LL | let foo = Foo(&y); + | ^^ borrowed value does not live long enough +... +LL | Foo::<'static>(_z) => { + | ------------------ type annotation requires that `y` is borrowed for `'static` +... +LL | } + | - `y` dropped here while still borrowed + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/type_ascription_static_lifetime.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/type_ascription_static_lifetime.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/type_ascription_static_lifetime.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/type_ascription_static_lifetime.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +#![allow(warnings)] +#![feature(nll)] +#![feature(type_ascription)] + +fn main() { + let x = 22_u32; + let y: &u32 = &x: &'static u32; //~ ERROR E0597 +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/type_ascription_static_lifetime.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/type_ascription_static_lifetime.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/type_ascription_static_lifetime.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/type_ascription_static_lifetime.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error[E0597]: `x` does not live long enough + --> $DIR/type_ascription_static_lifetime.rs:18:19 + | +LL | let y: &u32 = &x: &'static u32; //~ ERROR E0597 + | ^^-------------- + | | + | borrowed value does not live long enough + | type annotation requires that `x` is borrowed for `'static` +LL | } + | - `x` dropped here while still borrowed + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/wf-self-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/wf-self-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/wf-self-type.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/wf-self-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(nll)] + +struct Foo<'a, 'b: 'a>(&'a &'b ()); + +impl<'a, 'b> Foo<'a, 'b> { + fn xmute(a: &'b ()) -> &'a () { + unreachable!() + } +} + +pub fn foo<'a, 'b>(u: &'b ()) -> &'a () { + Foo::xmute(u) //~ ERROR unsatisfied lifetime constraints +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/wf-self-type.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/wf-self-type.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/user-annotations/wf-self-type.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/user-annotations/wf-self-type.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +error: unsatisfied lifetime constraints + --> $DIR/wf-self-type.rs:22:5 + | +LL | pub fn foo<'a, 'b>(u: &'b ()) -> &'a () { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | Foo::xmute(u) //~ ERROR unsatisfied lifetime constraints + | ^^^^^^^^^^^^^ returning this value requires that `'b` must outlive `'a` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/where_clauses_in_functions.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/where_clauses_in_functions.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/nll/where_clauses_in_functions.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/nll/where_clauses_in_functions.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -6,7 +6,7 @@ | | | lifetime `'a` defined here LL | foo(x, y) - | ^^^^^^^^^ argument requires that `'a` must outlive `'b` + | ^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/no-capture-arc.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/no-capture-arc.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/no-capture-arc.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/no-capture-arc.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -11,19 +11,6 @@ | = note: move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait -error[E0382]: borrow of moved value: `arc_v` - --> $DIR/no-capture-arc.rs:26:23 - | -LL | thread::spawn(move|| { - | ------ value moved into closure here -LL | assert_eq!((*arc_v)[3], 4); - | ----- variable moved due to use in closure -... -LL | println!("{:?}", *arc_v); - | ^^^^^ value borrowed here after move - | - = note: move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/non_modrs_mods/non_modrs_mods.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/non_modrs_mods/non_modrs_mods.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/non_modrs_mods/non_modrs_mods.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/non_modrs_mods/non_modrs_mods.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// -// Tests the formatting of the feature-gate errors for non_modrs_mods -// -// gate-test-non_modrs_mods -// ignore-windows -// ignore-pretty issue #37195 -pub mod modrs_mod; -pub mod foors_mod; - -#[path = "some_crazy_attr_mod_dir/arbitrary_name.rs"] -pub mod attr_mod; - -pub fn main() { - modrs_mod::inner_modrs_mod::innest::foo(); - modrs_mod::inner_foors_mod::innest::foo(); - foors_mod::inner_modrs_mod::innest::foo(); - foors_mod::inner_foors_mod::innest::foo(); - attr_mod::inner_modrs_mod::innest::foo(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/non_modrs_mods/non_modrs_mods.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/non_modrs_mods/non_modrs_mods.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/non_modrs_mods/non_modrs_mods.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/non_modrs_mods/non_modrs_mods.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -error[E0658]: mod statements in non-mod.rs files are unstable (see issue #44660) - --> $DIR/modrs_mod/inner_foors_mod.rs:11:9 - | -LL | pub mod innest; - | ^^^^^^ - | - = help: add #![feature(non_modrs_mods)] to the crate attributes to enable - = help: on stable builds, rename this file to inner_foors_mod/mod.rs - -error[E0658]: mod statements in non-mod.rs files are unstable (see issue #44660) - --> $DIR/foors_mod.rs:13:9 - | -LL | pub mod inner_modrs_mod; - | ^^^^^^^^^^^^^^^ - | - = help: add #![feature(non_modrs_mods)] to the crate attributes to enable - = help: on stable builds, rename this file to foors_mod/mod.rs - -error[E0658]: mod statements in non-mod.rs files are unstable (see issue #44660) - --> $DIR/foors_mod.rs:14:9 - | -LL | pub mod inner_foors_mod; - | ^^^^^^^^^^^^^^^ - | - = help: add #![feature(non_modrs_mods)] to the crate attributes to enable - = help: on stable builds, rename this file to foors_mod/mod.rs - -error[E0658]: mod statements in non-mod.rs files are unstable (see issue #44660) - --> $DIR/foors_mod/inner_foors_mod.rs:11:9 - | -LL | pub mod innest; - | ^^^^^^ - | - = help: add #![feature(non_modrs_mods)] to the crate attributes to enable - = help: on stable builds, rename this file to inner_foors_mod/mod.rs - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0658`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/non_modrs_mods_and_inline_mods/non_modrs_mods_and_inline_mods.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/non_modrs_mods_and_inline_mods/non_modrs_mods_and_inline_mods.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/non_modrs_mods_and_inline_mods/non_modrs_mods_and_inline_mods.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/non_modrs_mods_and_inline_mods/non_modrs_mods_and_inline_mods.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,5 @@ +// compile-pass + +mod x; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/non_modrs_mods_and_inline_mods/x/y/z/mod.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/non_modrs_mods_and_inline_mods/x/y/z/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/non_modrs_mods_and_inline_mods/x/y/z/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/non_modrs_mods_and_inline_mods/x/y/z/mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1 @@ +// ignore-test: not a test diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/non_modrs_mods_and_inline_mods/x.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/non_modrs_mods_and_inline_mods/x.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/non_modrs_mods_and_inline_mods/x.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/non_modrs_mods_and_inline_mods/x.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,5 @@ +// ignore-test: not a test + +pub mod y { + pub mod z; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/no_owned_box_lang_item.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/no_owned_box_lang_item.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/no_owned_box_lang_item.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/no_owned_box_lang_item.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,10 +15,12 @@ #![feature(lang_items, box_syntax)] #![no_std] +use core::panic::PanicInfo; + fn main() { let x = box 1i32; } #[lang = "eh_personality"] extern fn eh_personality() {} #[lang = "eh_unwind_resume"] extern fn eh_unwind_resume() {} -#[lang = "panic_impl"] fn panic_impl() -> ! { loop {} } +#[lang = "panic_impl"] fn panic_impl(panic: &PanicInfo) -> ! { loop {} } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/no-reuse-move-arc.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/no-reuse-move-arc.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/no-reuse-move-arc.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/no-reuse-move-arc.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -11,19 +11,6 @@ | = note: move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait -error[E0382]: borrow of moved value: `arc_v` - --> $DIR/no-reuse-move-arc.rs:24:23 - | -LL | thread::spawn(move|| { - | ------ value moved into closure here -LL | assert_eq!((*arc_v)[3], 4); - | ----- variable moved due to use in closure -... -LL | println!("{:?}", *arc_v); //~ ERROR use of moved value: `arc_v` - | ^^^^^ value borrowed here after move - | - = note: move occurs because `arc_v` has type `std::sync::Arc>`, which does not implement the `Copy` trait - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/no-std-inject.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/no-std-inject.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/no-std-inject.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/no-std-inject.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -5,7 +5,7 @@ | ^^^^^^^^^^^^^^^^^^ `core` reimported here | = note: `core` 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 +help: you can use `as` to change the binding name of the import | LL | extern crate core as other_core; //~ ERROR: the name `core` is defined multiple times | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-elision.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/object-lifetime-default-elision.rs:81:5 - | -LL | fn load3<'a,'b>(ss: &'a SomeTrait) -> &'b SomeTrait { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -... -LL | ss - | ^^ returning this value requires that `'a` must outlive `'b` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-elision.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -9,7 +9,7 @@ | LL | fn load3<'a,'b>(ss: &'a SomeTrait) -> &'b SomeTrait { | ^^ -note: ...so that the type `(dyn SomeTrait + 'a)` is not borrowed for too long +note: ...so that reference does not outlive borrowed content --> $DIR/object-lifetime-default-elision.rs:81:5 | LL | ss diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-from-box-error.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -error[E0621]: explicit lifetime required in the type of `ss` - --> $DIR/object-lifetime-default-from-box-error.rs:28:5 - | -LL | fn load(ss: &mut SomeStruct) -> Box { - | --------------- help: add explicit lifetime `'static` to the type of `ss`: `&mut SomeStruct<'static>` -... -LL | ss.r //~ ERROR explicit lifetime required in the type of `ss` [E0621] - | ^^^^ lifetime `'static` required - -error[E0507]: cannot move out of borrowed content - --> $DIR/object-lifetime-default-from-box-error.rs:28:5 - | -LL | ss.r //~ ERROR explicit lifetime required in the type of `ss` [E0621] - | ^^^^ cannot move out of borrowed content - -error[E0621]: explicit lifetime required in the type of `ss` - --> $DIR/object-lifetime-default-from-box-error.rs:41:5 - | -LL | fn store1<'b>(ss: &mut SomeStruct, b: Box) { - | --------------- help: add explicit lifetime `'b` to the type of `ss`: `&mut SomeStruct<'b>` -... -LL | ss.r = b; //~ ERROR 41:12: 41:13: explicit lifetime required in the type of `ss` [E0621] - | ^^^^ lifetime `'b` required - -error: aborting due to 3 previous errors - -Some errors occurred: E0507, E0621. -For more information about an error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-box-error.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -error: borrowed data escapes outside of function - --> $DIR/object-lifetime-default-from-rptr-box-error.rs:25:5 - | -LL | fn c<'a>(t: &'a Box, mut ss: SomeStruct<'a>) { - | - `t` is a reference that is only valid in the function body -LL | ss.t = t; //~ ERROR mismatched types - | ^^^^^^^^ `t` escapes the function body here - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-from-rptr-struct-error.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -error: borrowed data escapes outside of function - --> $DIR/object-lifetime-default-from-rptr-struct-error.rs:31:5 - | -LL | fn c<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { - | - `t` is a reference that is only valid in the function body -LL | ss.t = t; //~ ERROR mismatched types - | ^^^^^^^^ `t` escapes the function body here - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/object-lifetime-default-mybox.rs:37:5 - | -LL | fn load1<'a,'b>(a: &'a MyBox, - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -... -LL | a //~ ERROR lifetime mismatch - | ^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` - -error: borrowed data escapes outside of function - --> $DIR/object-lifetime-default-mybox.rs:41:5 - | -LL | fn load2<'a>(ss: &MyBox) -> MyBox { - | -- `ss` is a reference that is only valid in the function body -LL | load0(ss) //~ ERROR mismatched types - | ^^^^^^^^^ `ss` escapes the function body here - -error: aborting due to 2 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/on-unimplemented/expected-comma-found-token.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/on-unimplemented/expected-comma-found-token.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/on-unimplemented/expected-comma-found-token.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/on-unimplemented/expected-comma-found-token.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Tests that two closures cannot simultaneously have mutable +// access to the variable, whether that mutable access be used +// for direct assignment or for taking mutable ref. Issue #6801. + +#![feature(on_unimplemented)] + +#[rustc_on_unimplemented( + message="the message" + label="the label" +)] +trait T {} +//~^^^ ERROR expected one of `)` or `,`, found `label` + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/on-unimplemented/expected-comma-found-token.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/on-unimplemented/expected-comma-found-token.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/on-unimplemented/expected-comma-found-token.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/on-unimplemented/expected-comma-found-token.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: expected one of `)` or `,`, found `label` + --> $DIR/expected-comma-found-token.rs:19:5 + | +LL | message="the message" + | - expected one of `)` or `,` here +LL | label="the label" + | ^^^^^ unexpected token + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/out-of-order-shadowing.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/out-of-order-shadowing.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/out-of-order-shadowing.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/out-of-order-shadowing.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,20 +1,19 @@ -error[E0659]: `bar` is ambiguous +error[E0659]: `bar` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution) --> $DIR/out-of-order-shadowing.rs:15:1 | LL | bar!(); //~ ERROR `bar` is ambiguous | ^^^ ambiguous name | -note: `bar` could refer to the name defined here +note: `bar` could refer to the macro defined here --> $DIR/out-of-order-shadowing.rs:14:1 | LL | define_macro!(bar); | ^^^^^^^^^^^^^^^^^^^ -note: `bar` could also refer to the name defined here +note: `bar` could also refer to the macro defined here --> $DIR/out-of-order-shadowing.rs:13:1 | LL | macro_rules! bar { () => {} } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: macro-expanded macros do not shadow = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/panic-handler/panic-handler-wrong-location.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/panic-handler/panic-handler-wrong-location.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/panic-handler/panic-handler-wrong-location.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/panic-handler/panic-handler-wrong-location.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-C panic=abort + +#![no_std] +#![no_main] + +#[panic_handler] +#[no_mangle] +static X: u32 = 42; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/panic-handler/panic-handler-wrong-location.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/panic-handler/panic-handler-wrong-location.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/panic-handler/panic-handler-wrong-location.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/panic-handler/panic-handler-wrong-location.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0718]: `panic_impl` language item must be applied to a function + --> $DIR/panic-handler-wrong-location.rs:16:1 + | +LL | #[panic_handler] + | ^^^^^^^^^^^^^^^^ attribute should be applied to a function, not a static item + +error: `#[panic_handler]` function required, but not found + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0718`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/panic-implementation/panic-implementation-deprecated.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/panic-implementation/panic-implementation-deprecated.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/panic-implementation/panic-implementation-deprecated.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/panic-implementation/panic-implementation-deprecated.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ -error: use of deprecated attribute `panic_implementation`: This attribute was renamed to `panic_handler`. See https://github.com/rust-lang/rust/issues/44489#issuecomment-415140224 +error: use of deprecated attribute `panic_implementation`: this attribute was renamed to `panic_handler`. See https://github.com/rust-lang/rust/issues/44489#issuecomment-415140224 --> $DIR/panic-implementation-deprecated.rs:19:1 | LL | #[panic_implementation] - | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | ^^^^^^^^^^^^^^^^^^^^^^^ help: replace this attribute with `#[panic_handler]` | note: lint level defined here --> $DIR/panic-implementation-deprecated.rs:13:9 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/ascii-only-character-escape.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/ascii-only-character-escape.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/ascii-only-character-escape.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/ascii-only-character-escape.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +fn main() { + let x = "\x80"; //~ ERROR may only be used + let y = "\xff"; //~ ERROR may only be used + let z = "\xe2"; //~ ERROR may only be used + let a = b"\x00e2"; // ok because byte literal +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/ascii-only-character-escape.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/ascii-only-character-escape.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/ascii-only-character-escape.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/ascii-only-character-escape.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +error: this form of character escape may only be used with characters in the range [/x00-/x7f] + --> $DIR/ascii-only-character-escape.rs:14:16 + | +LL | let x = "/x80"; //~ ERROR may only be used + | ^^ + +error: this form of character escape may only be used with characters in the range [/x00-/x7f] + --> $DIR/ascii-only-character-escape.rs:15:16 + | +LL | let y = "/xff"; //~ ERROR may only be used + | ^^ + +error: this form of character escape may only be used with characters in the range [/x00-/x7f] + --> $DIR/ascii-only-character-escape.rs:16:16 + | +LL | let z = "/xe2"; //~ ERROR may only be used + | ^^ + +error: aborting due to 3 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/associated-types-project-from-hrtb-explicit.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/associated-types-project-from-hrtb-explicit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/associated-types-project-from-hrtb-explicit.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/associated-types-project-from-hrtb-explicit.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +// Test you can't use a higher-ranked trait bound inside of a qualified +// path (just won't parse). + +pub trait Foo { + type A; + + fn get(&self, t: T) -> Self::A; +} + +fn foo2(x: Foo<&'x isize>>::A) + //~^ ERROR expected identifier, found keyword `for` + //~| ERROR expected one of `::` or `>` +{ +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/associated-types-project-from-hrtb-explicit.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/associated-types-project-from-hrtb-explicit.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/associated-types-project-from-hrtb-explicit.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/associated-types-project-from-hrtb-explicit.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error: expected identifier, found keyword `for` + --> $DIR/associated-types-project-from-hrtb-explicit.rs:22:21 + | +LL | fn foo2(x: Foo<&'x isize>>::A) + | ^^^ expected identifier, found keyword + +error: expected one of `::` or `>`, found `Foo` + --> $DIR/associated-types-project-from-hrtb-explicit.rs:22:29 + | +LL | fn foo2(x: Foo<&'x isize>>::A) + | ^^^ expected one of `::` or `>` here + +error: aborting due to 2 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/assoc-oddities-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/assoc-oddities-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/assoc-oddities-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/assoc-oddities-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn that_odd_parse() { + // following lines below parse and must not fail + x = if c { a } else { b }(); + x = if true { 1 } else { 0 } as *mut _; + // however this does not parse and probably should fail to retain compat? + // NB: `..` here is arbitrary, failure happens/should happen ∀ops that aren’t `=` + // see assoc-oddities-2 and assoc-oddities-3 + ..if c { a } else { b }[n]; //~ ERROR expected one of +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/assoc-oddities-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/assoc-oddities-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/assoc-oddities-1.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/assoc-oddities-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `.`, `;`, `?`, or `}`, found `[` + --> $DIR/assoc-oddities-1.rs:20:28 + | +LL | ..if c { a } else { b }[n]; //~ ERROR expected one of + | ^ expected one of `.`, `;`, `?`, or `}` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/assoc-oddities-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/assoc-oddities-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/assoc-oddities-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/assoc-oddities-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn that_odd_parse() { + // see assoc-oddities-1 for explanation + x..if c { a } else { b }[n]; //~ ERROR expected one of +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/assoc-oddities-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/assoc-oddities-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/assoc-oddities-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/assoc-oddities-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `.`, `;`, `?`, or `}`, found `[` + --> $DIR/assoc-oddities-2.rs:15:29 + | +LL | x..if c { a } else { b }[n]; //~ ERROR expected one of + | ^ expected one of `.`, `;`, `?`, or `}` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +#[path =] //~ ERROR unexpected token: `]` +mod m {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: unexpected token: `]` + --> $DIR/attr-bad-meta-2.rs:13:9 + | +LL | #[path =] //~ ERROR unexpected token: `]` + | ^ unexpected token after this + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +#[path() token] //~ ERROR expected `]`, found `token` +mod m {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta-3.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta-3.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta-3.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta-3.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected `]`, found `token` + --> $DIR/attr-bad-meta-3.rs:13:10 + | +LL | #[path() token] //~ ERROR expected `]`, found `token` + | ^^^^^ expected `]` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +#![feature(unrestricted_attribute_tokens)] + +#[path*] //~ ERROR expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `*` +mod m {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-bad-meta.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `*` + --> $DIR/attr-bad-meta.rs:15:7 + | +LL | #[path*] //~ ERROR expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `*` + | ^ expected one of `(`, `::`, `=`, `[`, `]`, or `{` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-before-eof.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-before-eof.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-before-eof.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-before-eof.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +#[derive(Debug)] //~ERROR expected item after attributes diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-before-eof.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-before-eof.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-before-eof.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-before-eof.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected item after attributes + --> $DIR/attr-before-eof.rs:13:16 + | +LL | #[derive(Debug)] //~ERROR expected item after attributes + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-dangling-in-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-dangling-in-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-dangling-in-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-dangling-in-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// error-pattern:expected statement + +fn f() { + #[foo = "bar"] +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-dangling-in-fn.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-dangling-in-fn.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-dangling-in-fn.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-dangling-in-fn.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected statement after outer attribute + --> $DIR/attr-dangling-in-fn.rs:17:1 + | +LL | } + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-dangling-in-mod.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-dangling-in-mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-dangling-in-mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-dangling-in-mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// error-pattern:expected item + +fn main() { +} + +#[foo = "bar"] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-dangling-in-mod.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-dangling-in-mod.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr-dangling-in-mod.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr-dangling-in-mod.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected item after attributes + --> $DIR/attr-dangling-in-mod.rs:18:14 + | +LL | #[foo = "bar"] + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +#![feature(lang_items)] + +fn main() {} + +#![lang(foo)] //~ ERROR an inner attribute is not permitted in this context +fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attrs-after-extern-mod.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attrs-after-extern-mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attrs-after-extern-mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attrs-after-extern-mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// Constants (static variables) can be used to match in patterns, but mutable +// statics cannot. This ensures that there's some form of error if this is +// attempted. + +extern crate libc; + +extern { + static mut rust_dbg_static_mut: libc::c_int; + pub fn rust_dbg_static_mut_check_four(); + #[cfg(stage37)] //~ ERROR expected item after attributes +} + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attrs-after-extern-mod.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attrs-after-extern-mod.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attrs-after-extern-mod.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attrs-after-extern-mod.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected item after attributes + --> $DIR/attrs-after-extern-mod.rs:22:19 + | +LL | #[cfg(stage37)] //~ ERROR expected item after attributes + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/attr.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/attr.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: an inner attribute is not permitted in this context + --> $DIR/attr.rs:17:3 + | +LL | #![lang(foo)] //~ ERROR an inner attribute is not permitted in this context + | ^ + | + = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them. + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-char-literals.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-char-literals.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-char-literals.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-char-literals.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,31 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +// ignore-tidy-cr +// ignore-tidy-tab +fn main() { + // these literals are just silly. + '''; + //~^ ERROR: character constant must be escaped: ' + + // note that this is a literal "\n" byte + ' +'; + //~^^ ERROR: character constant must be escaped: \n + + // note that this is a literal "\r" byte + ' '; //~ ERROR: character constant must be escaped: \r + + // note that this is a literal tab character here + ' '; + //~^ ERROR: character constant must be escaped: \t +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-char-literals.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-char-literals.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-char-literals.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-char-literals.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +error: character constant must be escaped: ' + --> $DIR/bad-char-literals.rs:17:6 + | +LL | '''; + | ^ + +error: character constant must be escaped: /n + --> $DIR/bad-char-literals.rs:21:6 + | +LL | ' + | ______^ +LL | | '; + | |_ + +error: character constant must be escaped: /r + --> $DIR/bad-char-literals.rs:26:6 + | +LL | ' '; //~ ERROR: character constant must be escaped: /r + | ^ + +error: character constant must be escaped: /t + --> $DIR/bad-char-literals.rs:29:6 + | +LL | ' '; + | ^^^^ + +error: aborting due to 4 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-lit-suffixes.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-lit-suffixes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-lit-suffixes.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-lit-suffixes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + + +extern + "C"suffix //~ ERROR ABI spec with a suffix is invalid + fn foo() {} + +extern + "C"suffix //~ ERROR ABI spec with a suffix is invalid +{} + +fn main() { + ""suffix; //~ ERROR string literal with a suffix is invalid + b""suffix; //~ ERROR byte string literal with a suffix is invalid + r#""#suffix; //~ ERROR string literal with a suffix is invalid + br#""#suffix; //~ ERROR byte string literal with a suffix is invalid + 'a'suffix; //~ ERROR char literal with a suffix is invalid + b'a'suffix; //~ ERROR byte literal with a suffix is invalid + + 1234u1024; //~ ERROR invalid width `1024` for integer literal + 1234i1024; //~ ERROR invalid width `1024` for integer literal + 1234f1024; //~ ERROR invalid width `1024` for float literal + 1234.5f1024; //~ ERROR invalid width `1024` for float literal + + 1234suffix; //~ ERROR invalid suffix `suffix` for numeric literal + 0b101suffix; //~ ERROR invalid suffix `suffix` for numeric literal + 1.0suffix; //~ ERROR invalid suffix `suffix` for float literal + 1.0e10suffix; //~ ERROR invalid suffix `suffix` for float literal +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-lit-suffixes.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-lit-suffixes.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-lit-suffixes.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-lit-suffixes.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,114 @@ +error: ABI spec with a suffix is invalid + --> $DIR/bad-lit-suffixes.rs:15:5 + | +LL | "C"suffix //~ ERROR ABI spec with a suffix is invalid + | ^^^^^^^^^ + +error: ABI spec with a suffix is invalid + --> $DIR/bad-lit-suffixes.rs:19:5 + | +LL | "C"suffix //~ ERROR ABI spec with a suffix is invalid + | ^^^^^^^^^ + +error: string literal with a suffix is invalid + --> $DIR/bad-lit-suffixes.rs:23:5 + | +LL | ""suffix; //~ ERROR string literal with a suffix is invalid + | ^^^^^^^^ + +error: byte string literal with a suffix is invalid + --> $DIR/bad-lit-suffixes.rs:24:5 + | +LL | b""suffix; //~ ERROR byte string literal with a suffix is invalid + | ^^^^^^^^^ + +error: string literal with a suffix is invalid + --> $DIR/bad-lit-suffixes.rs:25:5 + | +LL | r#""#suffix; //~ ERROR string literal with a suffix is invalid + | ^^^^^^^^^^^ + +error: byte string literal with a suffix is invalid + --> $DIR/bad-lit-suffixes.rs:26:5 + | +LL | br#""#suffix; //~ ERROR byte string literal with a suffix is invalid + | ^^^^^^^^^^^^ + +error: char literal with a suffix is invalid + --> $DIR/bad-lit-suffixes.rs:27:5 + | +LL | 'a'suffix; //~ ERROR char literal with a suffix is invalid + | ^^^^^^^^^ + +error: byte literal with a suffix is invalid + --> $DIR/bad-lit-suffixes.rs:28:5 + | +LL | b'a'suffix; //~ ERROR byte literal with a suffix is invalid + | ^^^^^^^^^^ + +error: invalid width `1024` for integer literal + --> $DIR/bad-lit-suffixes.rs:30:5 + | +LL | 1234u1024; //~ ERROR invalid width `1024` for integer literal + | ^^^^^^^^^ + | + = help: valid widths are 8, 16, 32, 64 and 128 + +error: invalid width `1024` for integer literal + --> $DIR/bad-lit-suffixes.rs:31:5 + | +LL | 1234i1024; //~ ERROR invalid width `1024` for integer literal + | ^^^^^^^^^ + | + = help: valid widths are 8, 16, 32, 64 and 128 + +error: invalid width `1024` for float literal + --> $DIR/bad-lit-suffixes.rs:32:5 + | +LL | 1234f1024; //~ ERROR invalid width `1024` for float literal + | ^^^^^^^^^ + | + = help: valid widths are 32 and 64 + +error: invalid width `1024` for float literal + --> $DIR/bad-lit-suffixes.rs:33:5 + | +LL | 1234.5f1024; //~ ERROR invalid width `1024` for float literal + | ^^^^^^^^^^^ + | + = help: valid widths are 32 and 64 + +error: invalid suffix `suffix` for numeric literal + --> $DIR/bad-lit-suffixes.rs:35:5 + | +LL | 1234suffix; //~ ERROR invalid suffix `suffix` for numeric literal + | ^^^^^^^^^^ + | + = help: the suffix must be one of the integral types (`u32`, `isize`, etc) + +error: invalid suffix `suffix` for numeric literal + --> $DIR/bad-lit-suffixes.rs:36:5 + | +LL | 0b101suffix; //~ ERROR invalid suffix `suffix` for numeric literal + | ^^^^^^^^^^^ + | + = help: the suffix must be one of the integral types (`u32`, `isize`, etc) + +error: invalid suffix `suffix` for float literal + --> $DIR/bad-lit-suffixes.rs:37:5 + | +LL | 1.0suffix; //~ ERROR invalid suffix `suffix` for float literal + | ^^^^^^^^^ + | + = help: valid suffixes are `f32` and `f64` + +error: invalid suffix `suffix` for float literal + --> $DIR/bad-lit-suffixes.rs:38:5 + | +LL | 1.0e10suffix; //~ ERROR invalid suffix `suffix` for float literal + | ^^^^^^^^^^^^ + | + = help: valid suffixes are `f32` and `f64` + +error: aborting due to 16 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-match.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// error-pattern: expected + +fn main() { + let isize x = 5; + match x; +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-match.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-match.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-match.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-match.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `:`, `;`, `=`, or `@`, found `x` + --> $DIR/bad-match.rs:16:13 + | +LL | let isize x = 5; + | ^ expected one of `:`, `;`, `=`, or `@` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-name.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-name.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-name.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-name.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// error-pattern: expected + +fn main() { + let x.y::.z foo; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-name.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-name.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-name.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-name.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `:`, `;`, `=`, or `@`, found `.` + --> $DIR/bad-name.rs:16:8 + | +LL | let x.y::.z foo; + | ^ expected one of `:`, `;`, `=`, or `@` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-pointer-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-pointer-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-pointer-type.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-pointer-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn foo(_: *()) { + //~^ expected mut or const in raw pointer type (use `*mut T` or `*const T` as appropriate) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-pointer-type.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-pointer-type.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-pointer-type.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-pointer-type.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected mut or const in raw pointer type (use `*mut T` or `*const T` as appropriate) + --> $DIR/bad-pointer-type.rs:13:11 + | +LL | fn foo(_: *()) { + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-value-ident-false.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-value-ident-false.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-value-ident-false.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-value-ident-false.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn false() { } //~ ERROR expected identifier, found keyword `false` +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-value-ident-false.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-value-ident-false.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-value-ident-false.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-value-ident-false.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected identifier, found keyword `false` + --> $DIR/bad-value-ident-false.rs:13:4 + | +LL | fn false() { } //~ ERROR expected identifier, found keyword `false` + | ^^^^^ expected identifier, found keyword + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-value-ident-true.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-value-ident-true.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-value-ident-true.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-value-ident-true.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn true() { } //~ ERROR expected identifier, found keyword `true` +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-value-ident-true.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-value-ident-true.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bad-value-ident-true.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bad-value-ident-true.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected identifier, found keyword `true` + --> $DIR/bad-value-ident-true.rs:13:4 + | +LL | fn true() { } //~ ERROR expected identifier, found keyword `true` + | ^^^^ expected identifier, found keyword + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/better-expected.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/better-expected.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/better-expected.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/better-expected.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + let x: [isize 3]; //~ ERROR expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `3` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/better-expected.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/better-expected.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/better-expected.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/better-expected.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `3` + --> $DIR/better-expected.rs:14:19 + | +LL | let x: [isize 3]; //~ ERROR expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `3` + | - ^ expected one of 7 possible tokens here + | | + | while parsing the type for `x` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bind-struct-early-modifiers.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bind-struct-early-modifiers.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bind-struct-early-modifiers.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bind-struct-early-modifiers.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + struct Foo { x: isize } + match (Foo { x: 10 }) { + Foo { ref x: ref x } => {}, //~ ERROR expected `,` + _ => {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bind-struct-early-modifiers.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bind-struct-early-modifiers.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bind-struct-early-modifiers.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bind-struct-early-modifiers.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected `,` + --> $DIR/bind-struct-early-modifiers.rs:16:19 + | +LL | Foo { ref x: ref x } => {}, //~ ERROR expected `,` + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bound-single-question-mark.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bound-single-question-mark.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bound-single-question-mark.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bound-single-question-mark.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn f() {} //~ ERROR expected identifier, found `>` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bound-single-question-mark.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bound-single-question-mark.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bound-single-question-mark.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bound-single-question-mark.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected identifier, found `>` + --> $DIR/bound-single-question-mark.rs:13:10 + | +LL | fn f() {} //~ ERROR expected identifier, found `>` + | ^ expected identifier + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +type A = for<'a 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `'b` + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-1.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `,`, `:`, or `>`, found `'b` + --> $DIR/bounds-lifetime-1.rs:13:17 + | +LL | type A = for<'a 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `'b` + | ^^ expected one of `,`, `:`, or `>` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +type A = for<'a + 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `+` + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `,`, `:`, or `>`, found `+` + --> $DIR/bounds-lifetime-2.rs:13:17 + | +LL | type A = for<'a + 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `+` + | ^ expected one of `,`, `:`, or `>` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +type A = for<'a:> fn(); // OK +type A = for<'a:,> fn(); // OK +type A = for<'a> fn(); // OK +type A = for<> fn(); // OK +type A = for<'a: 'b + 'c> fn(); // OK (rejected later by ast_validation) +type A = for<'a: 'b,> fn(); // OK(rejected later by ast_validation) +type A = for<'a: 'b +> fn(); // OK (rejected later by ast_validation) +type A = for<'a, T> fn(); // OK (rejected later by ast_validation) +type A = for<,> fn(); //~ ERROR expected one of `>`, identifier, or lifetime, found `,` + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `>`, identifier, or lifetime, found `,` + --> $DIR/bounds-lifetime.rs:21:14 + | +LL | type A = for<,> fn(); //~ ERROR expected one of `>`, identifier, or lifetime, found `,` + | ^ expected one of `>`, identifier, or lifetime here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-where-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-where-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-where-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-where-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +type A where 'a; //~ ERROR expected `:`, found `;` + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-where-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-where-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-where-1.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-where-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected `:`, found `;` + --> $DIR/bounds-lifetime-where-1.rs:13:16 + | +LL | type A where 'a; //~ ERROR expected `:`, found `;` + | ^ expected `:` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-where.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-where.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-where.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-where.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +type A where 'a: 'b + 'c = u8; // OK +type A where 'a: 'b, = u8; // OK +type A where 'a: = u8; // OK +type A where 'a:, = u8; // OK +type A where 'a: 'b + 'c = u8; // OK +type A where = u8; // OK +type A where 'a: 'b + = u8; // OK +type A where , = u8; //~ ERROR expected one of `=`, lifetime, or type, found `,` + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-where.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-where.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-where.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-lifetime-where.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `=`, lifetime, or type, found `,` + --> $DIR/bounds-lifetime-where.rs:20:14 + | +LL | type A where , = u8; //~ ERROR expected one of `=`, lifetime, or type, found `,` + | ^ expected one of `=`, lifetime, or type here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-obj-parens.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-obj-parens.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-obj-parens.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-obj-parens.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// compile-flags: -Z parse-only + +type A = Box<(Fn(D::Error) -> E) + 'static + Send + Sync>; // OK (but see #39318) diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-type.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +struct S< + T: 'a + Tr, // OK + T: Tr + 'a, // OK + T: 'a, // OK + T:, // OK + T: ?for<'a> Trait, // OK + T: Tr +, // OK + T: ?'a, //~ ERROR `?` may only modify trait bounds, not lifetime bounds +>; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-type.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-type.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-type.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-type.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: `?` may only modify trait bounds, not lifetime bounds + --> $DIR/bounds-type.rs:20:8 + | +LL | T: ?'a, //~ ERROR `?` may only modify trait bounds, not lifetime bounds + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-type-where.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-type-where.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-type-where.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-type-where.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +type A where for<'a> for<'b> Trait1 + ?Trait2: 'a + Trait = u8; // OK +type A where T: Trait, = u8; // OK +type A where T: = u8; // OK +type A where T:, = u8; // OK +type A where T: Trait + Trait = u8; // OK +type A where = u8; // OK +type A where T: Trait + = u8; // OK +type A where T, = u8; +//~^ ERROR expected one of `!`, `(`, `+`, `::`, `:`, `<`, `==`, or `=`, found `,` + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-type-where.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-type-where.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/bounds-type-where.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/bounds-type-where.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `!`, `(`, `+`, `::`, `:`, `<`, `==`, or `=`, found `,` + --> $DIR/bounds-type-where.rs:20:15 + | +LL | type A where T, = u8; + | ^ expected one of 8 possible tokens here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/brace-after-qualified-path-in-match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/brace-after-qualified-path-in-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/brace-after-qualified-path-in-match.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/brace-after-qualified-path-in-match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn foo() { + match x { + ::Type{key: value} => (), + //~^ ERROR unexpected `{` after qualified path + _ => (), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/brace-after-qualified-path-in-match.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/brace-after-qualified-path-in-match.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/brace-after-qualified-path-in-match.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/brace-after-qualified-path-in-match.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: unexpected `{` after qualified path + --> $DIR/brace-after-qualified-path-in-match.rs:15:27 + | +LL | ::Type{key: value} => (), + | ^ unexpected `{` after qualified path + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/byte-literals.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/byte-literals.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/byte-literals.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/byte-literals.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + + +// ignore-tidy-tab + +static FOO: u8 = b'\f'; //~ ERROR unknown byte escape + +pub fn main() { + b'\f'; //~ ERROR unknown byte escape + b'\x0Z'; //~ ERROR invalid character in numeric character escape: Z + b' '; //~ ERROR byte constant must be escaped + b'''; //~ ERROR byte constant must be escaped + b'é'; //~ ERROR byte constant must be ASCII + b'a //~ ERROR unterminated byte constant +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/byte-literals.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/byte-literals.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/byte-literals.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/byte-literals.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +error: unknown byte escape: f + --> $DIR/byte-literals.rs:16:21 + | +LL | static FOO: u8 = b'/f'; //~ ERROR unknown byte escape + | ^ + +error: unknown byte escape: f + --> $DIR/byte-literals.rs:19:8 + | +LL | b'/f'; //~ ERROR unknown byte escape + | ^ + +error: invalid character in numeric character escape: Z + --> $DIR/byte-literals.rs:20:10 + | +LL | b'/x0Z'; //~ ERROR invalid character in numeric character escape: Z + | ^ + +error: byte constant must be escaped: /t + --> $DIR/byte-literals.rs:21:7 + | +LL | b' '; //~ ERROR byte constant must be escaped + | ^^^^ + +error: byte constant must be escaped: ' + --> $DIR/byte-literals.rs:22:7 + | +LL | b'''; //~ ERROR byte constant must be escaped + | ^ + +error: byte constant must be ASCII. Use a /xHH escape for a non-ASCII byte + --> $DIR/byte-literals.rs:23:7 + | +LL | b'é'; //~ ERROR byte constant must be ASCII + | ^ + +error: unterminated byte constant: b'a + --> $DIR/byte-literals.rs:24:5 + | +LL | b'a //~ ERROR unterminated byte constant + | ^^^ + +error: aborting due to 7 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/byte-string-literals.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/byte-string-literals.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/byte-string-literals.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/byte-string-literals.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + + +// ignore-tidy-tab + +static FOO: &'static [u8] = b"\f"; //~ ERROR unknown byte escape + +pub fn main() { + b"\f"; //~ ERROR unknown byte escape + b"\x0Z"; //~ ERROR invalid character in numeric character escape: Z + b"é"; //~ ERROR byte constant must be ASCII + b"a //~ ERROR unterminated double quote byte string +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/byte-string-literals.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/byte-string-literals.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/byte-string-literals.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/byte-string-literals.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +error: unknown byte escape: f + --> $DIR/byte-string-literals.rs:16:32 + | +LL | static FOO: &'static [u8] = b"/f"; //~ ERROR unknown byte escape + | ^ + +error: unknown byte escape: f + --> $DIR/byte-string-literals.rs:19:8 + | +LL | b"/f"; //~ ERROR unknown byte escape + | ^ + +error: invalid character in numeric character escape: Z + --> $DIR/byte-string-literals.rs:20:10 + | +LL | b"/x0Z"; //~ ERROR invalid character in numeric character escape: Z + | ^ + +error: byte constant must be ASCII. Use a /xHH escape for a non-ASCII byte + --> $DIR/byte-string-literals.rs:21:7 + | +LL | b"é"; //~ ERROR byte constant must be ASCII + | ^ + +error: unterminated double quote byte string + --> $DIR/byte-string-literals.rs:22:7 + | +LL | b"a //~ ERROR unterminated double quote byte string + | _______^ +LL | | } + | |__^ + +error: aborting due to 5 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/circular_modules_hello.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/circular_modules_hello.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/circular_modules_hello.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/circular_modules_hello.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2013-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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// ignore-test: this is an auxiliary file for circular-modules-main.rs + +#[path = "circular_modules_main.rs"] +mod circular_modules_main; + +pub fn say_hello() { + println!("{}", circular_modules_main::hi_str()); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/circular_modules_main.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/circular_modules_main.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/circular_modules_main.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/circular_modules_main.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +#[path = "circular_modules_hello.rs"] +mod circular_modules_hello; //~ ERROR: circular modules + +pub fn hi_str() -> String { + "Hi!".to_string() +} + +fn main() { + circular_modules_hello::say_hello(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/circular_modules_main.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/circular_modules_main.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/circular_modules_main.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/circular_modules_main.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: circular modules: $DIR/circular_modules_hello.rs -> $DIR/circular_modules_main.rs -> $DIR/circular_modules_hello.rs + --> $DIR/circular_modules_main.rs:14:5 + | +LL | mod circular_modules_hello; //~ ERROR: circular modules + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/class-implements-bad-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/class-implements-bad-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/class-implements-bad-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/class-implements-bad-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// error-pattern:nonexistent +class cat : nonexistent { + let meows: usize; + new(in_x : usize) { self.meows = in_x; } +} + +fn main() { + let nyan = cat(0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/class-implements-bad-trait.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/class-implements-bad-trait.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/class-implements-bad-trait.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/class-implements-bad-trait.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `!` or `::`, found `cat` + --> $DIR/class-implements-bad-trait.rs:14:7 + | +LL | class cat : nonexistent { + | ^^^ expected one of `!` or `::` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/closure-return-syntax.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/closure-return-syntax.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/closure-return-syntax.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/closure-return-syntax.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we cannot parse a closure with an explicit return type +// unless it uses braces. + +// compile-flags: -Z parse-only + +fn main() { + let x = || -> i32 22; + //~^ ERROR expected one of `!`, `(`, `+`, `::`, `<`, or `{`, found `22` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/closure-return-syntax.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/closure-return-syntax.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/closure-return-syntax.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/closure-return-syntax.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `!`, `(`, `+`, `::`, `<`, or `{`, found `22` + --> $DIR/closure-return-syntax.rs:17:23 + | +LL | let x = || -> i32 22; + | ^^ expected one of `!`, `(`, `+`, `::`, `<`, or `{` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/column-offset-1-based.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/column-offset-1-based.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/column-offset-1-based.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/column-offset-1-based.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +# //~ ERROR 13:1: 13:2: expected `[`, found `` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/column-offset-1-based.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/column-offset-1-based.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/column-offset-1-based.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/column-offset-1-based.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected `[`, found `` + --> $DIR/column-offset-1-based.rs:13:1 + | +LL | # //~ ERROR 13:1: 13:2: expected `[`, found `` + | ^ expected `[` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/default.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/default.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/default.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/default.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// Test successful and unsuccessful parsing of the `default` contextual keyword + +trait Foo { + fn foo() -> T; +} + +impl Foo for u8 { + default fn foo() -> T { + T::default() + } +} + +impl Foo for u16 { + pub default fn foo() -> T { + T::default() + } +} + +impl Foo for u32 { + default pub fn foo() -> T { T::default() } //~ ERROR expected one of +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/default.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/default.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/default.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/default.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `async`, `const`, `existential`, `extern`, `fn`, `type`, or `unsafe`, found `pub` + --> $DIR/default.rs:32:13 + | +LL | default pub fn foo() -> T { T::default() } //~ ERROR expected one of + | ^^^ expected one of 7 possible tokens here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-after-struct-field.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-after-struct-field.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-after-struct-field.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-after-struct-field.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +struct X { + a: u8 /** document a */, + //~^ ERROR found a documentation comment that doesn't document anything + //~| HELP maybe a comment was intended +} + +struct Y { + a: u8 /// document a + //~^ ERROR found a documentation comment that doesn't document anything + //~| HELP maybe a comment was intended +} + +fn main() { + let x = X { a: 1 }; + let y = Y { a: 1 }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-after-struct-field.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-after-struct-field.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-after-struct-field.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-after-struct-field.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +error[E0585]: found a documentation comment that doesn't document anything + --> $DIR/doc-after-struct-field.rs:14:11 + | +LL | a: u8 /** document a */, + | ^^^^^^^^^^^^^^^^^ + | + = help: doc comments must come before what they document, maybe a comment was intended with `//`? + +error[E0585]: found a documentation comment that doesn't document anything + --> $DIR/doc-after-struct-field.rs:20:11 + | +LL | a: u8 /// document a + | ^^^^^^^^^^^^^^ + | + = help: doc comments must come before what they document, maybe a comment was intended with `//`? + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0585`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/do-catch-suggests-try.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/do-catch-suggests-try.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/do-catch-suggests-try.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/do-catch-suggests-try.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + let _: Option<()> = do catch {}; + //~^ ERROR found removed `do catch` syntax + //~^^ HELP Following RFC #2388, the new non-placeholder syntax is `try` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/do-catch-suggests-try.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/do-catch-suggests-try.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/do-catch-suggests-try.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/do-catch-suggests-try.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: found removed `do catch` syntax + --> $DIR/do-catch-suggests-try.rs:14:25 + | +LL | let _: Option<()> = do catch {}; + | ^^ + | + = help: Following RFC #2388, the new non-placeholder syntax is `try` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-attr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-attr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-attr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-attr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +/// hi +#[derive(Debug)] //~ERROR expected item after attributes diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-attr.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-attr.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-attr.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-attr.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected item after attributes + --> $DIR/doc-before-attr.rs:14:16 + | +LL | #[derive(Debug)] //~ERROR expected item after attributes + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-eof.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-eof.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-eof.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-eof.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +/// hi //~ERROR expected item after doc comment diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-eof.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-eof.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-eof.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-eof.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected item after doc comment + --> $DIR/doc-before-eof.rs:13:1 + | +LL | /// hi //~ERROR expected item after doc comment + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-extern-rbrace.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-extern-rbrace.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-extern-rbrace.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-extern-rbrace.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +extern { + /// hi + //~^ ERROR expected item after doc comment +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-extern-rbrace.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-extern-rbrace.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-extern-rbrace.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-extern-rbrace.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected item after doc comment + --> $DIR/doc-before-extern-rbrace.rs:14:5 + | +LL | /// hi + | ^^^^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-fn-rbrace.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-fn-rbrace.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-fn-rbrace.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-fn-rbrace.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +fn main() { + /// document + //~^ ERROR found a documentation comment that doesn't document anything + //~| HELP maybe a comment was intended +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-fn-rbrace.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-fn-rbrace.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-fn-rbrace.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-fn-rbrace.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0585]: found a documentation comment that doesn't document anything + --> $DIR/doc-before-fn-rbrace.rs:14:5 + | +LL | /// document + | ^^^^^^^^^^^^ + | + = help: doc comments must come before what they document, maybe a comment was intended with `//`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0585`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +fn /// document +foo() {} +//~^^ ERROR expected identifier, found `/// document` + +fn main() { + foo(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected identifier, found `/// document` + --> $DIR/doc-before-identifier.rs:13:4 + | +LL | fn /// document + | ^^^^^^^^^^^^ expected identifier + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-mod-rbrace.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-mod-rbrace.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-mod-rbrace.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-mod-rbrace.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +mod Foo { + /// document + //~^ ERROR expected item after doc comment +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-mod-rbrace.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-mod-rbrace.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-mod-rbrace.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-mod-rbrace.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected item after doc comment + --> $DIR/doc-before-mod-rbrace.rs:14:5 + | +LL | /// document + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-rbrace.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-rbrace.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-rbrace.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-rbrace.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + println!("Hi"); /// hi + //~^ ERROR found a documentation comment that doesn't document anything + //~| HELP maybe a comment was intended +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-rbrace.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-rbrace.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-rbrace.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-rbrace.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0585]: found a documentation comment that doesn't document anything + --> $DIR/doc-before-rbrace.rs:14:21 + | +LL | println!("Hi"); /// hi + | ^^^^^^ + | + = help: doc comments must come before what they document, maybe a comment was intended with `//`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0585`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-semi.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-semi.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-semi.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-semi.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + /// hi + //~^ ERROR found a documentation comment that doesn't document anything + //~| HELP maybe a comment was intended + ; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-semi.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-semi.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-semi.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-semi.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0585]: found a documentation comment that doesn't document anything + --> $DIR/doc-before-semi.rs:14:5 + | +LL | /// hi + | ^^^^^^ + | + = help: doc comments must come before what they document, maybe a comment was intended with `//`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0585`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-struct-rbrace-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-struct-rbrace-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-struct-rbrace-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-struct-rbrace-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +struct X { + a: u8, + /// document + //~^ ERROR found a documentation comment that doesn't document anything + //~| HELP maybe a comment was intended +} + +fn main() { + let y = X {a: 1}; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-struct-rbrace-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-struct-rbrace-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-struct-rbrace-1.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-struct-rbrace-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0585]: found a documentation comment that doesn't document anything + --> $DIR/doc-before-struct-rbrace-1.rs:15:5 + | +LL | /// document + | ^^^^^^^^^^^^ + | + = help: doc comments must come before what they document, maybe a comment was intended with `//`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0585`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-struct-rbrace-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-struct-rbrace-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-struct-rbrace-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-struct-rbrace-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +struct X { + a: u8 /// document + //~^ ERROR found a documentation comment that doesn't document anything + //~| HELP maybe a comment was intended +} + +fn main() { + let y = X {a: 1}; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-struct-rbrace-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-struct-rbrace-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/doc-before-struct-rbrace-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/doc-before-struct-rbrace-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0585]: found a documentation comment that doesn't document anything + --> $DIR/doc-before-struct-rbrace-2.rs:14:11 + | +LL | a: u8 /// document + | ^^^^^^^^^^^^ + | + = help: doc comments must come before what they document, maybe a comment was intended with `//`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0585`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/duplicate-visibility.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/duplicate-visibility.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/duplicate-visibility.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/duplicate-visibility.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// error-pattern:expected one of `(`, `fn`, `static`, or `type` +extern { + pub pub fn foo(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/duplicate-visibility.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/duplicate-visibility.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/duplicate-visibility.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/duplicate-visibility.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `(`, `fn`, `static`, or `type`, found `pub` + --> $DIR/duplicate-visibility.rs:15:9 + | +LL | pub pub fn foo(); + | ^^^ expected one of `(`, `fn`, `static`, or `type` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/empty-impl-semicolon.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/empty-impl-semicolon.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/empty-impl-semicolon.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/empty-impl-semicolon.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +impl Foo; //~ ERROR expected one of `!`, `(`, `+`, `::`, `<`, `for`, `where`, or `{`, found `;` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/empty-impl-semicolon.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/empty-impl-semicolon.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/empty-impl-semicolon.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/empty-impl-semicolon.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `!`, `(`, `+`, `::`, `<`, `for`, `where`, or `{`, found `;` + --> $DIR/empty-impl-semicolon.rs:13:9 + | +LL | impl Foo; //~ ERROR expected one of `!`, `(`, `+`, `::`, `<`, `for`, `where`, or `{`, found `;` + | ^ expected one of 8 possible tokens here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/expected-comma-found-token.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/expected-comma-found-token.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/expected-comma-found-token.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/expected-comma-found-token.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tests that two closures cannot simultaneously have mutable -// access to the variable, whether that mutable access be used -// for direct assignment or for taking mutable ref. Issue #6801. - -#![feature(on_unimplemented)] - -#[rustc_on_unimplemented( - message="the message" - label="the label" -)] -trait T {} -//~^^^ ERROR expected one of `)` or `,`, found `label` - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/expected-comma-found-token.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/expected-comma-found-token.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/expected-comma-found-token.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/expected-comma-found-token.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -error: expected one of `)` or `,`, found `label` - --> $DIR/expected-comma-found-token.rs:19:5 - | -LL | message="the message" - | - expected one of `)` or `,` here -LL | label="the label" - | ^^^^^ unexpected token - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/extern-crate-unexpected-token.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/extern-crate-unexpected-token.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/extern-crate-unexpected-token.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/extern-crate-unexpected-token.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +extern crte foo; //~ ERROR expected one of `crate`, `fn`, or `{`, found `crte` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/extern-crate-unexpected-token.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/extern-crate-unexpected-token.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/extern-crate-unexpected-token.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/extern-crate-unexpected-token.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `crate`, `fn`, or `{`, found `crte` + --> $DIR/extern-crate-unexpected-token.rs:13:8 + | +LL | extern crte foo; //~ ERROR expected one of `crate`, `fn`, or `{`, found `crte` + | ^^^^ expected one of `crate`, `fn`, or `{` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/extern-expected-fn-or-brace.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/extern-expected-fn-or-brace.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/extern-expected-fn-or-brace.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/extern-expected-fn-or-brace.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// Verifies that the expected token errors for `extern crate` are +// raised + +extern "C" mod foo; //~ERROR expected one of `fn` or `{`, found `mod` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/extern-expected-fn-or-brace.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/extern-expected-fn-or-brace.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/extern-expected-fn-or-brace.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/extern-expected-fn-or-brace.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `fn` or `{`, found `mod` + --> $DIR/extern-expected-fn-or-brace.rs:16:12 + | +LL | extern "C" mod foo; //~ERROR expected one of `fn` or `{`, found `mod` + | ^^^ expected one of `fn` or `{` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/extern-foreign-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/extern-foreign-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/extern-foreign-crate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/extern-foreign-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// Verifies that the expected token errors for `extern crate` are +// raised + +extern crate foo {} //~ERROR expected one of `;` or `as`, found `{` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/extern-foreign-crate.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/extern-foreign-crate.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/extern-foreign-crate.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/extern-foreign-crate.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `;` or `as`, found `{` + --> $DIR/extern-foreign-crate.rs:16:18 + | +LL | extern crate foo {} //~ERROR expected one of `;` or `as`, found `{` + | ^ expected one of `;` or `as` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/extern-no-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/extern-no-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/extern-no-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/extern-no-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +extern { //~ ERROR missing `fn`, `type`, or `static` for extern-item declaration + f(); +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/extern-no-fn.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/extern-no-fn.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/extern-no-fn.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/extern-no-fn.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: missing `fn`, `type`, or `static` for extern-item declaration + --> $DIR/extern-no-fn.rs:13:9 + | +LL | extern { //~ ERROR missing `fn`, `type`, or `static` for extern-item declaration + | _________^ +LL | | f(); + | |____^ missing `fn`, `type`, or `static` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/if-in-in.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/if-in-in.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/if-in-in.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/if-in-in.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,7 @@ +// compile-flags: -Z parse-only + +fn main() { + for i in in 1..2 { + println!("{}", i); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/if-in-in.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/if-in-in.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/if-in-in.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/if-in-in.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +error: expected iterable, found keyword `in` + --> $DIR/if-in-in.rs:4:14 + | +LL | for i in in 1..2 { + | ---^^ + | | + | help: remove the duplicated `in` + | + = note: if you meant to use emplacement syntax, it is obsolete (for now, anyway) + = note: for more information on the status of emplacement syntax, see + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/impl-parsing.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/impl-parsing.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/impl-parsing.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/impl-parsing.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +impl ! {} // OK +impl ! where u8: Copy {} // OK + +impl Trait Type {} //~ ERROR missing `for` in a trait impl +impl Trait .. {} //~ ERROR missing `for` in a trait impl +impl ?Sized for Type {} //~ ERROR expected a trait, found type +impl ?Sized for .. {} //~ ERROR expected a trait, found type + +default unsafe FAIL //~ ERROR expected `impl`, found `FAIL` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/impl-parsing.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/impl-parsing.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/impl-parsing.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/impl-parsing.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +error: missing `for` in a trait impl + --> $DIR/impl-parsing.rs:16:11 + | +LL | impl Trait Type {} //~ ERROR missing `for` in a trait impl + | ^ + +error: missing `for` in a trait impl + --> $DIR/impl-parsing.rs:17:11 + | +LL | impl Trait .. {} //~ ERROR missing `for` in a trait impl + | ^ + +error: expected a trait, found type + --> $DIR/impl-parsing.rs:18:6 + | +LL | impl ?Sized for Type {} //~ ERROR expected a trait, found type + | ^^^^^^ + +error: expected a trait, found type + --> $DIR/impl-parsing.rs:19:6 + | +LL | impl ?Sized for .. {} //~ ERROR expected a trait, found type + | ^^^^^^ + +error: expected `impl`, found `FAIL` + --> $DIR/impl-parsing.rs:21:16 + | +LL | default unsafe FAIL //~ ERROR expected `impl`, found `FAIL` + | ^^^^ expected `impl` here + +error: aborting due to 5 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/impl-qpath.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/impl-qpath.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/impl-qpath.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/impl-qpath.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// compile-flags: -Z parse-only + +impl <*const u8>::AssocTy {} // OK +impl ::AssocTy {} // OK +impl <'a + Trait>::AssocTy {} // OK +impl <::AssocTy>::AssocTy {} // OK diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/import-from-path.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/import-from-path.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/import-from-path.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/import-from-path.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// error-pattern:expected +use foo::{bar}::baz diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/import-from-path.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/import-from-path.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/import-from-path.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/import-from-path.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected `;`, found `::` + --> $DIR/import-from-path.rs:14:15 + | +LL | use foo::{bar}::baz + | ^^ expected `;` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/import-from-rename.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/import-from-rename.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/import-from-rename.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/import-from-rename.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// error-pattern:expected + +use foo::{bar} as baz; + +mod foo { + pub fn bar() {} +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/import-from-rename.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/import-from-rename.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/import-from-rename.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/import-from-rename.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected `;`, found `as` + --> $DIR/import-from-rename.rs:15:16 + | +LL | use foo::{bar} as baz; + | ^^ expected `;` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/import-glob-path.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/import-glob-path.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/import-glob-path.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/import-glob-path.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// error-pattern:expected +use foo::*::bar diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/import-glob-path.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/import-glob-path.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/import-glob-path.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/import-glob-path.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected `;`, found `::` + --> $DIR/import-glob-path.rs:14:11 + | +LL | use foo::*::bar + | ^^ expected `;` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/import-glob-rename.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/import-glob-rename.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/import-glob-rename.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/import-glob-rename.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// error-pattern:expected + +use foo::* as baz; + +mod foo { + pub fn bar() {} +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/import-glob-rename.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/import-glob-rename.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/import-glob-rename.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/import-glob-rename.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected `;`, found `as` + --> $DIR/import-glob-rename.rs:15:12 + | +LL | use foo::* as baz; + | ^^ expected `;` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/inner-attr-after-doc-comment.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/inner-attr-after-doc-comment.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/inner-attr-after-doc-comment.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/inner-attr-after-doc-comment.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +#![feature(lang_items)] +/** + * My module + */ + +#![recursion_limit="100"] +//~^ ERROR an inner attribute is not permitted following an outer doc comment +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/inner-attr-after-doc-comment.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/inner-attr-after-doc-comment.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/inner-attr-after-doc-comment.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/inner-attr-after-doc-comment.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: an inner attribute is not permitted following an outer doc comment + --> $DIR/inner-attr-after-doc-comment.rs:18:3 + | +LL | #![recursion_limit="100"] + | ^ + | + = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them. + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/inner-attr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/inner-attr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/inner-attr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/inner-attr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +#[feature(lang_items)] + +#![recursion_limit="100"] //~ ERROR an inner attribute is not permitted following an outer attribute +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/inner-attr.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/inner-attr.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/inner-attr.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/inner-attr.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: an inner attribute is not permitted following an outer attribute + --> $DIR/inner-attr.rs:15:3 + | +LL | #![recursion_limit="100"] //~ ERROR an inner attribute is not permitted following an outer attribute + | ^ + | + = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them. + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/int-literal-too-large-span.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/int-literal-too-large-span.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/int-literal-too-large-span.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/int-literal-too-large-span.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// issue #17123 + +fn main() { + 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 + //~^ ERROR int literal is too large + ; // the span shouldn't point to this. +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/int-literal-too-large-span.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/int-literal-too-large-span.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/int-literal-too-large-span.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/int-literal-too-large-span.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: int literal is too large + --> $DIR/int-literal-too-large-span.rs:16:5 + | +LL | 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/inverted-parameters.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/inverted-parameters.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/inverted-parameters.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/inverted-parameters.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +struct S; + +impl S { + fn foo(&self, &str bar) {} + //~^ ERROR expected one of `:` or `@` + //~| HELP declare the type after the parameter binding + //~| SUGGESTION : +} + +fn baz(S quux, xyzzy: i32) {} +//~^ ERROR expected one of `:` or `@` +//~| HELP declare the type after the parameter binding +//~| SUGGESTION : + +fn one(i32 a b) {} +//~^ ERROR expected one of `:` or `@` + +fn pattern((i32, i32) (a, b)) {} +//~^ ERROR expected `:` + +fn fizz(i32) {} +//~^ ERROR expected one of `:` or `@` + +fn missing_colon(quux S) {} +//~^ ERROR expected one of `:` or `@` +//~| HELP declare the type after the parameter binding +//~| SUGGESTION : + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/inverted-parameters.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/inverted-parameters.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/inverted-parameters.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/inverted-parameters.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +error: expected one of `:` or `@`, found `bar` + --> $DIR/inverted-parameters.rs:16:24 + | +LL | fn foo(&self, &str bar) {} + | -----^^^ + | | | + | | expected one of `:` or `@` here + | help: declare the type after the parameter binding: `: ` + +error: expected one of `:` or `@`, found `quux` + --> $DIR/inverted-parameters.rs:22:10 + | +LL | fn baz(S quux, xyzzy: i32) {} + | --^^^^ + | | | + | | expected one of `:` or `@` here + | help: declare the type after the parameter binding: `: ` + +error: expected one of `:` or `@`, found `a` + --> $DIR/inverted-parameters.rs:27:12 + | +LL | fn one(i32 a b) {} + | ^ expected one of `:` or `@` here + +error: expected `:`, found `(` + --> $DIR/inverted-parameters.rs:30:23 + | +LL | fn pattern((i32, i32) (a, b)) {} + | ^ expected `:` + +error: expected one of `:` or `@`, found `)` + --> $DIR/inverted-parameters.rs:33:12 + | +LL | fn fizz(i32) {} + | ^ expected one of `:` or `@` here + +error: expected one of `:` or `@`, found `S` + --> $DIR/inverted-parameters.rs:36:23 + | +LL | fn missing_colon(quux S) {} + | -----^ + | | | + | | expected one of `:` or `@` here + | help: declare the type after the parameter binding: `: ` + +error: aborting due to 6 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-10392-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-10392-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-10392-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-10392-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +struct A { foo: isize } + +fn a() -> A { panic!() } + +fn main() { + let A { .., } = a(); //~ ERROR: expected `}` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-10392-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-10392-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-10392-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-10392-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +error: expected `}`, found `,` + --> $DIR/issue-10392-2.rs:18:15 + | +LL | let A { .., } = a(); //~ ERROR: expected `}` + | --^ + | | | + | | expected `}` + | | help: remove this comma + | `..` must be at the end and cannot have a trailing comma + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-10392.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-10392.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-10392.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-10392.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +struct A { foo: isize } + +fn a() -> A { panic!() } + +fn main() { + let A { , } = a(); //~ ERROR: expected ident +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-10392.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-10392.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-10392.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-10392.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected identifier, found `,` + --> $DIR/issue-10392.rs:18:13 + | +LL | let A { , } = a(); //~ ERROR: expected ident + | ^ expected identifier + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-10636-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-10636-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-10636-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-10636-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +struct Obj { + //~^ NOTE: un-closed delimiter + member: usize +) +//~^ ERROR incorrect close delimiter +//~| NOTE incorrect close delimiter + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-10636-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-10636-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-10636-1.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-10636-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error: incorrect close delimiter: `)` + --> $DIR/issue-10636-1.rs:16:1 + | +LL | struct Obj { + | - un-closed delimiter +... +LL | ) + | ^ incorrect close delimiter + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-10636-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-10636-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-10636-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-10636-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// Copyright 2013-2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// FIXME(31528) we emit a bunch of silly errors here due to continuing past the +// first one. This would be easy-ish to address by better recovery in tokenisation. + +// compile-flags: -Z parse-only + +pub fn trace_option(option: Option) { + option.map(|some| 42; + //~^ ERROR: expected one of + +} //~ ERROR: incorrect close delimiter +//~^ ERROR: expected expression, found `)` + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-10636-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-10636-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-10636-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-10636-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +error: incorrect close delimiter: `}` + --> $DIR/issue-10636-2.rs:20:1 + | +LL | pub fn trace_option(option: Option) { + | - close delimiter possibly meant for this +LL | option.map(|some| 42; + | - un-closed delimiter +... +LL | } //~ ERROR: incorrect close delimiter + | ^ incorrect close delimiter + +error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;` + --> $DIR/issue-10636-2.rs:17:25 + | +LL | option.map(|some| 42; + | ^ expected one of `)`, `,`, `.`, `?`, or an operator here + +error: expected expression, found `)` + --> $DIR/issue-10636-2.rs:20:1 + | +LL | } //~ ERROR: incorrect close delimiter + | ^ expected expression + +error: aborting due to 3 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-enum.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +enum X<'a, T, 'b> { +//~^ ERROR lifetime parameters must be declared prior to type parameters + A(&'a T) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-enum.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-enum.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-enum.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-enum.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: lifetime parameters must be declared prior to type parameters + --> $DIR/issue-14303-enum.rs:13:15 + | +LL | enum X<'a, T, 'b> { + | ^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-fncall.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-fncall.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-fncall.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-fncall.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + (0..4) + .map(|x| x * 2) + .collect::>() + //~^ ERROR lifetime parameters must be declared prior to type parameters +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-fncall.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-fncall.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-fncall.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-fncall.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: lifetime parameters must be declared prior to type parameters + --> $DIR/issue-14303-fncall.rs:16:31 + | +LL | .collect::>() + | ^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-fn-def.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-fn-def.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-fn-def.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-fn-def.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn foo<'a, T, 'b>(x: &'a T) {} +//~^ ERROR lifetime parameters must be declared prior to type parameters diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-fn-def.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-fn-def.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-fn-def.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-fn-def.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: lifetime parameters must be declared prior to type parameters + --> $DIR/issue-14303-fn-def.rs:13:15 + | +LL | fn foo<'a, T, 'b>(x: &'a T) {} + | ^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-impl.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-impl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +struct X { x: isize } + +impl<'a, T, 'b> X {} +//~^ ERROR lifetime parameters must be declared prior to type parameters diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-impl.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-impl.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-impl.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-impl.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: lifetime parameters must be declared prior to type parameters + --> $DIR/issue-14303-impl.rs:15:13 + | +LL | impl<'a, T, 'b> X {} + | ^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-path.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-path.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-path.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-path.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn bar<'a, T>(x: mymodule::X<'a, T, 'b, 'c>) {} +//~^ ERROR lifetime parameters must be declared prior to type parameters diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-path.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-path.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-path.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-path.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: lifetime parameters must be declared prior to type parameters + --> $DIR/issue-14303-path.rs:13:37 + | +LL | fn bar<'a, T>(x: mymodule::X<'a, T, 'b, 'c>) {} + | ^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +struct X<'a, T, 'b> { +//~^ ERROR lifetime parameters must be declared prior to type parameters + x: &'a T +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-struct.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-struct.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-struct.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-struct.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: lifetime parameters must be declared prior to type parameters + --> $DIR/issue-14303-struct.rs:13:17 + | +LL | struct X<'a, T, 'b> { + | ^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +trait Foo<'a, T, 'b> {} +//~^ ERROR lifetime parameters must be declared prior to type parameters diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-trait.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-trait.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-14303-trait.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-14303-trait.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: lifetime parameters must be declared prior to type parameters + --> $DIR/issue-14303-trait.rs:13:18 + | +LL | trait Foo<'a, T, 'b> {} + | ^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-15914.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-15914.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-15914.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-15914.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + let ref + (); //~ ERROR expected identifier, found `(` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-15914.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-15914.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-15914.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-15914.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected identifier, found `(` + --> $DIR/issue-15914.rs:15:9 + | +LL | (); //~ ERROR expected identifier, found `(` + | ^ expected identifier + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-15980.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-15980.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-15980.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-15980.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +use std::io; + +fn main(){ + let x: io::IoResult<()> = Ok(()); + match x { + Err(ref e) if e.kind == io::EndOfFile { + //~^ NOTE while parsing this struct + return + //~^ ERROR expected identifier, found keyword `return` + //~| NOTE expected identifier, found keyword + } + //~^ NOTE expected one of `.`, `=>`, `?`, or an operator here + _ => {} + //~^ ERROR expected one of `.`, `=>`, `?`, or an operator, found `_` + //~| NOTE unexpected token + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-15980.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-15980.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-15980.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-15980.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +error: expected identifier, found keyword `return` + --> $DIR/issue-15980.rs:20:13 + | +LL | Err(ref e) if e.kind == io::EndOfFile { + | ------------- while parsing this struct +LL | //~^ NOTE while parsing this struct +LL | return + | ^^^^^^ expected identifier, found keyword + +error: expected one of `.`, `=>`, `?`, or an operator, found `_` + --> $DIR/issue-15980.rs:25:9 + | +LL | } + | - expected one of `.`, `=>`, `?`, or an operator here +LL | //~^ NOTE expected one of `.`, `=>`, `?`, or an operator here +LL | _ => {} + | ^ unexpected token + +error: aborting due to 2 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-1655.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-1655.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-1655.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-1655.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// error-pattern:expected `[`, found `vec` +mod blade_runner { + #vec[doc( + brief = "Blade Runner is probably the best movie ever", + desc = "I like that in the world of Blade Runner it is always + raining, and that it's always night time. And Aliens + was also a really good movie. + + Alien 3 was crap though." + )] +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-1655.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-1655.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-1655.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-1655.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected `[`, found `vec` + --> $DIR/issue-1655.rs:15:6 + | +LL | #vec[doc( + | ^^^ expected `[` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-17383.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-17383.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-17383.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-17383.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +enum X { + A = + b'a' //~ ERROR discriminator values can only be used with a field-less enum + , + B(isize) +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-17383.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-17383.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-17383.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-17383.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: discriminator values can only be used with a field-less enum + --> $DIR/issue-17383.rs:15:9 + | +LL | b'a' //~ ERROR discriminator values can only be used with a field-less enum + | ^^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-17718-const-mut.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-17718-const-mut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-17718-const-mut.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-17718-const-mut.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +const +mut //~ ERROR: const globals cannot be mutable +//~^ HELP did you mean to declare a static? +FOO: usize = 3; + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-17718-const-mut.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-17718-const-mut.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-17718-const-mut.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-17718-const-mut.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: const globals cannot be mutable + --> $DIR/issue-17718-const-mut.rs:14:1 + | +LL | mut //~ ERROR: const globals cannot be mutable + | ^^^ + | + = help: did you mean to declare a static? + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-17904-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-17904-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-17904-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-17904-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +struct Bar { x: T } where T: Copy //~ ERROR expected item, found `where` + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-17904-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-17904-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-17904-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-17904-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected item, found `where` + --> $DIR/issue-17904-2.rs:13:24 + | +LL | struct Bar { x: T } where T: Copy //~ ERROR expected item, found `where` + | ^^^^^ expected item + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-17904.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-17904.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-17904.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-17904.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +struct Baz where U: Eq(U); //This is parsed as the new Fn* style parenthesis syntax. +struct Baz where U: Eq(U) -> R; // Notice this parses as well. +struct Baz(U) where U: Eq; // This rightfully signals no error as well. +struct Foo where T: Copy, (T); //~ ERROR expected one of `:`, `==`, or `=`, found `;` + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-17904.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-17904.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-17904.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-17904.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `:`, `==`, or `=`, found `;` + --> $DIR/issue-17904.rs:16:33 + | +LL | struct Foo where T: Copy, (T); //~ ERROR expected one of `:`, `==`, or `=`, found `;` + | ^ expected one of `:`, `==`, or `=` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-1802-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-1802-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-1802-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-1802-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// error-pattern:no valid digits found for number +fn main() { + log(error, 0b); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-1802-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-1802-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-1802-1.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-1802-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: no valid digits found for number + --> $DIR/issue-1802-1.rs:15:16 + | +LL | log(error, 0b); + | ^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-1802-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-1802-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-1802-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-1802-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// error-pattern:no valid digits found for number +fn main() { + log(error, 0b_usize); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-1802-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-1802-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-1802-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-1802-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: no valid digits found for number + --> $DIR/issue-1802-2.rs:15:16 + | +LL | log(error, 0b_usize); + | ^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-19096.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-19096.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-19096.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-19096.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + let t = (42, 42); + t.0::; //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `::` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-19096.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-19096.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-19096.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-19096.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `::` + --> $DIR/issue-19096.rs:15:8 + | +LL | t.0::; //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `::` + | ^^ expected one of `.`, `;`, `?`, `}`, or an operator here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-19398.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-19398.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-19398.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-19398.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +trait T { + extern "Rust" unsafe fn foo(); //~ ERROR expected `fn`, found `unsafe` +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-19398.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-19398.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-19398.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-19398.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected `fn`, found `unsafe` + --> $DIR/issue-19398.rs:14:19 + | +LL | extern "Rust" unsafe fn foo(); //~ ERROR expected `fn`, found `unsafe` + | ^^^^^^ expected `fn` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-20711-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-20711-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-20711-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-20711-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only +// ignore-tidy-linelength + +struct Foo; + +impl Foo { + fn foo() {} + + #[stable(feature = "rust1", since = "1.0.0")] +} //~ ERROR expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, or + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-20711-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-20711-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-20711-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-20711-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, or `unsafe`, found `}` + --> $DIR/issue-20711-2.rs:20:1 + | +LL | #[stable(feature = "rust1", since = "1.0.0")] + | - expected one of 10 possible tokens here +LL | } //~ ERROR expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, or + | ^ unexpected token + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-20711.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-20711.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-20711.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-20711.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only +// ignore-tidy-linelength + +struct Foo; + +impl Foo { + #[stable(feature = "rust1", since = "1.0.0")] +} //~ ERROR expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, or + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-20711.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-20711.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-20711.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-20711.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, or `unsafe`, found `}` + --> $DIR/issue-20711.rs:18:1 + | +LL | #[stable(feature = "rust1", since = "1.0.0")] + | - expected one of 10 possible tokens here +LL | } //~ ERROR expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, or + | ^ unexpected token + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-21153.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-21153.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-21153.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-21153.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +trait MyTrait: Iterator { //~ ERROR missing `fn`, `type`, or `const` + Item = T; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-21153.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-21153.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-21153.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-21153.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: missing `fn`, `type`, or `const` for trait-item declaration + --> $DIR/issue-21153.rs:13:29 + | +LL | trait MyTrait: Iterator { //~ ERROR missing `fn`, `type`, or `const` + | _____________________________^ +LL | | Item = T; + | |____^ missing `fn`, `type`, or `const` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-22647.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-22647.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-22647.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-22647.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + let caller = |f: F| //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `<` + where F: Fn() -> i32 + { + let x = f(); + println!("Y {}",x); + return x; + }; + + caller(bar_handler); +} + +fn bar_handler() -> i32 { + 5 +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-22647.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-22647.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-22647.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-22647.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `:`, `;`, `=`, or `@`, found `<` + --> $DIR/issue-22647.rs:14:15 + | +LL | let caller = |f: F| //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `<` + | ^ expected one of `:`, `;`, `=`, or `@` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-22712.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-22712.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-22712.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-22712.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +struct Foo { + buffer: B +} + +fn bar() { + let Foo> //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `<` +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-22712.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-22712.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-22712.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-22712.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `:`, `;`, `=`, or `@`, found `<` + --> $DIR/issue-22712.rs:18:12 + | +LL | let Foo> //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `<` + | ^ expected one of `:`, `;`, `=`, or `@` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-2354-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-2354-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-2354-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-2354-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +static foo: isize = 2; } //~ ERROR unexpected close delimiter: diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-2354-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-2354-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-2354-1.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-2354-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: unexpected close delimiter: `}` + --> $DIR/issue-2354-1.rs:13:24 + | +LL | static foo: isize = 2; } //~ ERROR unexpected close delimiter: + | ^ unexpected close delimiter + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-2354.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-2354.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-2354.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-2354.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn foo() { //~ NOTE un-closed delimiter + match Some(x) { + //~^ NOTE this delimiter might not be properly closed... + Some(y) => { panic!(); } + None => { panic!(); } +} +//~^ NOTE ...as it matches this but it has different indentation + +fn bar() { + let mut i = 0; + while (i < 1000) {} +} + +fn main() {} //~ ERROR this file contains an un-closed delimiter diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-2354.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-2354.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-2354.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-2354.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +error: this file contains an un-closed delimiter + --> $DIR/issue-2354.rs:26:66 + | +LL | fn foo() { //~ NOTE un-closed delimiter + | - un-closed delimiter +LL | match Some(x) { + | - this delimiter might not be properly closed... +... +LL | } + | - ...as it matches this but it has different indentation +... +LL | fn main() {} //~ ERROR this file contains an un-closed delimiter + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-23620-invalid-escapes.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-23620-invalid-escapes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-23620-invalid-escapes.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-23620-invalid-escapes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,48 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +fn main() { + let _ = b"\u{a66e}"; + //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string + + let _ = b'\u{a66e}'; + //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string + + let _ = b'\u'; + //~^ ERROR incorrect unicode escape sequence + //~^^ ERROR unicode escape sequences cannot be used as a byte or in a byte string + + let _ = b'\x5'; + //~^ ERROR numeric character escape is too short + + let _ = b'\xxy'; + //~^ ERROR invalid character in numeric character escape: x + //~^^ ERROR invalid character in numeric character escape: y + + let _ = '\x5'; + //~^ ERROR numeric character escape is too short + + let _ = '\xxy'; + //~^ ERROR invalid character in numeric character escape: x + //~^^ ERROR invalid character in numeric character escape: y + + let _ = b"\u{a4a4} \xf \u"; + //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string + //~^^ ERROR invalid character in numeric character escape: + //~^^^ ERROR incorrect unicode escape sequence + //~^^^^ ERROR unicode escape sequences cannot be used as a byte or in a byte string + + let _ = "\xf \u"; + //~^ ERROR invalid character in numeric character escape: + //~^^ ERROR form of character escape may only be used with characters in the range [\x00-\x7f] + //~^^^ ERROR incorrect unicode escape sequence +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-23620-invalid-escapes.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-23620-invalid-escapes.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-23620-invalid-escapes.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-23620-invalid-escapes.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,122 @@ +error: unicode escape sequences cannot be used as a byte or in a byte string + --> $DIR/issue-23620-invalid-escapes.rs:14:15 + | +LL | let _ = b"/u{a66e}"; + | ^^^^^^^^ + +error: unicode escape sequences cannot be used as a byte or in a byte string + --> $DIR/issue-23620-invalid-escapes.rs:17:15 + | +LL | let _ = b'/u{a66e}'; + | ^^^^^^^^ + +error: incorrect unicode escape sequence + --> $DIR/issue-23620-invalid-escapes.rs:20:15 + | +LL | let _ = b'/u'; + | ^^ + | +help: format of unicode escape sequences is `/u{…}` + --> $DIR/issue-23620-invalid-escapes.rs:20:15 + | +LL | let _ = b'/u'; + | ^^ + +error: unicode escape sequences cannot be used as a byte or in a byte string + --> $DIR/issue-23620-invalid-escapes.rs:20:15 + | +LL | let _ = b'/u'; + | ^^ + +error: numeric character escape is too short + --> $DIR/issue-23620-invalid-escapes.rs:24:17 + | +LL | let _ = b'/x5'; + | ^ + +error: invalid character in numeric character escape: x + --> $DIR/issue-23620-invalid-escapes.rs:27:17 + | +LL | let _ = b'/xxy'; + | ^ + +error: invalid character in numeric character escape: y + --> $DIR/issue-23620-invalid-escapes.rs:27:18 + | +LL | let _ = b'/xxy'; + | ^ + +error: numeric character escape is too short + --> $DIR/issue-23620-invalid-escapes.rs:31:16 + | +LL | let _ = '/x5'; + | ^ + +error: invalid character in numeric character escape: x + --> $DIR/issue-23620-invalid-escapes.rs:34:16 + | +LL | let _ = '/xxy'; + | ^ + +error: invalid character in numeric character escape: y + --> $DIR/issue-23620-invalid-escapes.rs:34:17 + | +LL | let _ = '/xxy'; + | ^ + +error: unicode escape sequences cannot be used as a byte or in a byte string + --> $DIR/issue-23620-invalid-escapes.rs:38:15 + | +LL | let _ = b"/u{a4a4} /xf /u"; + | ^^^^^^^^ + +error: invalid character in numeric character escape: + --> $DIR/issue-23620-invalid-escapes.rs:38:27 + | +LL | let _ = b"/u{a4a4} /xf /u"; + | ^ + +error: incorrect unicode escape sequence + --> $DIR/issue-23620-invalid-escapes.rs:38:28 + | +LL | let _ = b"/u{a4a4} /xf /u"; + | ^^ + | +help: format of unicode escape sequences is `/u{…}` + --> $DIR/issue-23620-invalid-escapes.rs:38:28 + | +LL | let _ = b"/u{a4a4} /xf /u"; + | ^^ + +error: unicode escape sequences cannot be used as a byte or in a byte string + --> $DIR/issue-23620-invalid-escapes.rs:38:28 + | +LL | let _ = b"/u{a4a4} /xf /u"; + | ^^ + +error: invalid character in numeric character escape: + --> $DIR/issue-23620-invalid-escapes.rs:44:17 + | +LL | let _ = "/xf /u"; + | ^ + +error: this form of character escape may only be used with characters in the range [/x00-/x7f] + --> $DIR/issue-23620-invalid-escapes.rs:44:16 + | +LL | let _ = "/xf /u"; + | ^^ + +error: incorrect unicode escape sequence + --> $DIR/issue-23620-invalid-escapes.rs:44:18 + | +LL | let _ = "/xf /u"; + | ^^ + | +help: format of unicode escape sequences is `/u{…}` + --> $DIR/issue-23620-invalid-escapes.rs:44:18 + | +LL | let _ = "/xf /u"; + | ^^ + +error: aborting due to 17 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-24197.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-24197.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-24197.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-24197.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + let buf[0] = 0; //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `[` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-24197.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-24197.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-24197.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-24197.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `:`, `;`, `=`, or `@`, found `[` + --> $DIR/issue-24197.rs:14:12 + | +LL | let buf[0] = 0; //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `[` + | ^ expected one of `:`, `;`, `=`, or `@` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-24375.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-24375.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-24375.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-24375.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +static tmp : [&'static str; 2] = ["hello", "he"]; + +fn main() { + let z = "hello"; + match z { + tmp[0] => {} //~ ERROR expected one of `=>`, `@`, `if`, or `|`, found `[` + _ => {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-24375.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-24375.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-24375.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-24375.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `=>`, `@`, `if`, or `|`, found `[` + --> $DIR/issue-24375.rs:18:12 + | +LL | tmp[0] => {} //~ ERROR expected one of `=>`, `@`, `if`, or `|`, found `[` + | ^ expected one of `=>`, `@`, `if`, or `|` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-24780.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-24780.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-24780.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-24780.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Verify that '>' is not both expected and found at the same time, as it used +// to happen in #24780. For example, following should be an error: +// expected one of ..., `>`, ... found `>` +// +// compile-flags: -Z parse-only + +fn foo() -> Vec> { + //~^ ERROR expected one of `!`, `+`, `::`, `where`, or `{`, found `>` + Vec::new() +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-24780.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-24780.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-24780.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-24780.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `!`, `+`, `::`, `where`, or `{`, found `>` + --> $DIR/issue-24780.rs:17:23 + | +LL | fn foo() -> Vec> { + | ^ expected one of `!`, `+`, `::`, `where`, or `{` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-27255.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-27255.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-27255.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-27255.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +impl A .. {} //~ ERROR + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-27255.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-27255.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-27255.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-27255.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: missing `for` in a trait impl + --> $DIR/issue-27255.rs:13:7 + | +LL | impl A .. {} //~ ERROR + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-30318.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-30318.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-30318.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-30318.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn foo() { } + +//! Misplaced comment... +//~^ ERROR expected outer doc comment +//~| NOTE inner doc comments like this (starting with `//!` or `/*!`) can only appear before items + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-30318.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-30318.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-30318.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-30318.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: expected outer doc comment + --> $DIR/issue-30318.rs:15:1 + | +LL | //! Misplaced comment... + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: inner doc comments like this (starting with `//!` or `/*!`) can only appear before items + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-3036.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-3036.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-3036.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-3036.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// Testing that semicolon tokens are printed correctly in errors + +fn main() +{ + let x = 3 +} //~ ERROR: expected one of `.`, `;`, `?`, or an operator, found `}` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-3036.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-3036.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-3036.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-3036.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: expected one of `.`, `;`, `?`, or an operator, found `}` + --> $DIR/issue-3036.rs:18:1 + | +LL | let x = 3 + | - expected one of `.`, `;`, `?`, or an operator here +LL | } //~ ERROR: expected one of `.`, `;`, `?`, or an operator, found `}` + | ^ unexpected token + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-32214.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-32214.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-32214.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-32214.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +pub fn test >() {} +//~^ ERROR type parameters must be declared prior to associated type bindings + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-32214.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-32214.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-32214.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-32214.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: type parameters must be declared prior to associated type bindings + --> $DIR/issue-32214.rs:13:37 + | +LL | pub fn test >() {} + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-32446.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-32446.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-32446.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-32446.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() {} + +// This used to end up in an infite loop trying to bump past EOF. +trait T { ... } //~ ERROR diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-32446.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-32446.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-32446.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-32446.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `...` + --> $DIR/issue-32446.rs:16:11 + | +LL | trait T { ... } //~ ERROR + | ^^^ expected one of 7 possible tokens here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-32501.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-32501.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-32501.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-32501.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + let a = 0; + let _b = 0; + let _ = 0; + let mut b = 0; + let mut _b = 0; + let mut _ = 0; //~ ERROR expected identifier, found reserved identifier `_` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-32501.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-32501.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-32501.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-32501.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected identifier, found reserved identifier `_` + --> $DIR/issue-32501.rs:19:13 + | +LL | let mut _ = 0; //~ ERROR expected identifier, found reserved identifier `_` + | ^ expected identifier, found reserved identifier + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-32505.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-32505.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-32505.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-32505.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +pub fn test() { + foo(|_|) //~ ERROR expected expression, found `)` +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-32505.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-32505.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-32505.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-32505.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected expression, found `)` + --> $DIR/issue-32505.rs:14:12 + | +LL | foo(|_|) //~ ERROR expected expression, found `)` + | ^ expected expression + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-33262.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-33262.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-33262.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-33262.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// Issue #33262 + +pub fn main() { + for i in 0..a as { } + //~^ ERROR expected type, found `{` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-33262.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-33262.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-33262.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-33262.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected type, found `{` + --> $DIR/issue-33262.rs:16:22 + | +LL | for i in 0..a as { } + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-33413.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-33413.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-33413.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-33413.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +impl S { + fn f(*, a: u8) -> u8 {} //~ ERROR expected pattern, found `*` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-33413.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-33413.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-33413.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-33413.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found `*` + --> $DIR/issue-33413.rs:14:10 + | +LL | fn f(*, a: u8) -> u8 {} //~ ERROR expected pattern, found `*` + | ^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-33455.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-33455.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-33455.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-33455.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +use foo.bar; //~ ERROR expected one of `::`, `;`, or `as`, found `.` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-33455.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-33455.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-33455.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-33455.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `::`, `;`, or `as`, found `.` + --> $DIR/issue-33455.rs:13:8 + | +LL | use foo.bar; //~ ERROR expected one of `::`, `;`, or `as`, found `.` + | ^ expected one of `::`, `;`, or `as` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-41155.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-41155.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-41155.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-41155.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +impl S { + pub +} //~ ERROR expected one of + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-41155.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-41155.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-41155.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-41155.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: expected one of `(`, `async`, `const`, `default`, `existential`, `extern`, `fn`, `type`, or `unsafe`, found `}` + --> $DIR/issue-41155.rs:15:1 + | +LL | pub + | - expected one of 9 possible tokens here +LL | } //~ ERROR expected one of + | ^ unexpected token + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-43692.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-43692.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-43692.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-43692.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + '\u{_10FFFF}'; //~ ERROR invalid start of unicode escape +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-43692.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-43692.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-43692.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-43692.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: invalid start of unicode escape + --> $DIR/issue-43692.rs:14:9 + | +LL | '/u{_10FFFF}'; //~ ERROR invalid start of unicode escape + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-5544-a.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-5544-a.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-5544-a.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-5544-a.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + let __isize = 340282366920938463463374607431768211456; // 2^128 + //~^ ERROR int literal is too large +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-5544-a.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-5544-a.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-5544-a.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-5544-a.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: int literal is too large + --> $DIR/issue-5544-a.rs:14:19 + | +LL | let __isize = 340282366920938463463374607431768211456; // 2^128 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-5544-b.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-5544-b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-5544-b.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-5544-b.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + let __isize = 0xffff_ffff_ffff_ffff_ffff_ffff_ffff_ffff_ff; + //~^ ERROR int literal is too large +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-5544-b.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-5544-b.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-5544-b.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-5544-b.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: int literal is too large + --> $DIR/issue-5544-b.rs:14:19 + | +LL | let __isize = 0xffff_ffff_ffff_ffff_ffff_ffff_ffff_ffff_ff; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-5806.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-5806.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-5806.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-5806.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only +// normalize-stderr-test: "parser:.*\(" -> "parser: $$ACCESS_DENIED_MSG (" +// normalize-stderr-test: "os error \d+" -> "os error $$ACCESS_DENIED_CODE" + +#[path = "../parser"] +mod foo; //~ ERROR couldn't read + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-5806.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-5806.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-5806.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-5806.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: couldn't read $DIR/../parser: $ACCESS_DENIED_MSG (os error $ACCESS_DENIED_CODE) + --> $DIR/issue-5806.rs:16:5 + | +LL | mod foo; //~ ERROR couldn't read + | ^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-6610.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-6610.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-6610.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-6610.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +trait Foo { fn a() } //~ ERROR expected `;` or `{`, found `}` + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-6610.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-6610.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-6610.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-6610.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected `;` or `{`, found `}` + --> $DIR/issue-6610.rs:13:20 + | +LL | trait Foo { fn a() } //~ ERROR expected `;` or `{`, found `}` + | ^ expected `;` or `{` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-8537.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-8537.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-8537.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-8537.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +pub extern + "invalid-ab_isize" //~ ERROR invalid ABI +fn foo() {} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-8537.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-8537.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/issue-8537.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/issue-8537.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0703]: invalid ABI: found `invalid-ab_isize` + --> $DIR/issue-8537.rs:14:3 + | +LL | "invalid-ab_isize" //~ ERROR invalid ABI + | ^^^^^^^^^^^^^^^^^^ invalid ABI + | + = help: valid ABIs: cdecl, stdcall, fastcall, vectorcall, thiscall, aapcs, win64, sysv64, ptx-kernel, msp430-interrupt, x86-interrupt, amdgpu-kernel, Rust, C, system, rust-intrinsic, rust-call, platform-intrinsic, unadjusted + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0703`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-abstract.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-abstract.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-abstract.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-abstract.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + let abstract = (); //~ ERROR expected pattern, found reserved keyword `abstract` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-abstract.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-abstract.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-abstract.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-abstract.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found reserved keyword `abstract` + --> $DIR/keyword-abstract.rs:14:9 + | +LL | let abstract = (); //~ ERROR expected pattern, found reserved keyword `abstract` + | ^^^^^^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-as-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-as-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-as-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-as-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py as' + +fn main() { + let as = "foo"; //~ error: expected pattern, found keyword `as` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-as-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-as-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-as-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-as-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `as` + --> $DIR/keyword-as-as-identifier.rs:16:9 + | +LL | let as = "foo"; //~ error: expected pattern, found keyword `as` + | ^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-box-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-box-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-box-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-box-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + let box = "foo"; //~ error: expected pattern, found `=` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-box-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-box-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-box-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-box-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found `=` + --> $DIR/keyword-box-as-identifier.rs:14:13 + | +LL | let box = "foo"; //~ error: expected pattern, found `=` + | ^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-break-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-break-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-break-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-break-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py break' + +fn main() { + let break = "foo"; //~ error: expected pattern, found keyword `break` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-break-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-break-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-break-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-break-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `break` + --> $DIR/keyword-break-as-identifier.rs:16:9 + | +LL | let break = "foo"; //~ error: expected pattern, found keyword `break` + | ^^^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-const-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-const-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-const-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-const-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py const' + +fn main() { + let const = "foo"; //~ error: expected pattern, found keyword `const` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-const-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-const-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-const-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-const-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `const` + --> $DIR/keyword-const-as-identifier.rs:16:9 + | +LL | let const = "foo"; //~ error: expected pattern, found keyword `const` + | ^^^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-continue-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-continue-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-continue-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-continue-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py continue' + +fn main() { + let continue = "foo"; //~ error: expected pattern, found keyword `continue` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-continue-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-continue-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-continue-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-continue-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `continue` + --> $DIR/keyword-continue-as-identifier.rs:16:9 + | +LL | let continue = "foo"; //~ error: expected pattern, found keyword `continue` + | ^^^^^^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-else-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-else-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-else-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-else-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py else' + +fn main() { + let else = "foo"; //~ error: expected pattern, found keyword `else` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-else-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-else-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-else-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-else-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `else` + --> $DIR/keyword-else-as-identifier.rs:16:9 + | +LL | let else = "foo"; //~ error: expected pattern, found keyword `else` + | ^^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-enum-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-enum-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-enum-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-enum-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py enum' + +fn main() { + let enum = "foo"; //~ error: expected pattern, found keyword `enum` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-enum-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-enum-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-enum-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-enum-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `enum` + --> $DIR/keyword-enum-as-identifier.rs:16:9 + | +LL | let enum = "foo"; //~ error: expected pattern, found keyword `enum` + | ^^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-final.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-final.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-final.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-final.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + let final = (); //~ ERROR expected pattern, found reserved keyword `final` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-final.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-final.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-final.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-final.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found reserved keyword `final` + --> $DIR/keyword-final.rs:14:9 + | +LL | let final = (); //~ ERROR expected pattern, found reserved keyword `final` + | ^^^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-fn-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-fn-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-fn-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-fn-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py fn' + +fn main() { + let fn = "foo"; //~ error: expected pattern, found keyword `fn` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-fn-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-fn-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-fn-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-fn-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `fn` + --> $DIR/keyword-fn-as-identifier.rs:16:9 + | +LL | let fn = "foo"; //~ error: expected pattern, found keyword `fn` + | ^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-for-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-for-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-for-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-for-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py for' + +fn main() { + let for = "foo"; //~ error: expected pattern, found keyword `for` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-for-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-for-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-for-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-for-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `for` + --> $DIR/keyword-for-as-identifier.rs:16:9 + | +LL | let for = "foo"; //~ error: expected pattern, found keyword `for` + | ^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-if-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-if-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-if-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-if-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py if' + +fn main() { + let if = "foo"; //~ error: expected pattern, found keyword `if` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-if-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-if-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-if-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-if-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `if` + --> $DIR/keyword-if-as-identifier.rs:16:9 + | +LL | let if = "foo"; //~ error: expected pattern, found keyword `if` + | ^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-impl-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-impl-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-impl-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-impl-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py impl' + +fn main() { + let impl = "foo"; //~ error: expected pattern, found keyword `impl` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-impl-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-impl-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-impl-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-impl-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `impl` + --> $DIR/keyword-impl-as-identifier.rs:16:9 + | +LL | let impl = "foo"; //~ error: expected pattern, found keyword `impl` + | ^^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-in-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-in-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-in-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-in-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py in' + +fn main() { + let in = "foo"; //~ error: expected pattern, found keyword `in` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-in-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-in-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-in-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-in-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `in` + --> $DIR/keyword-in-as-identifier.rs:16:9 + | +LL | let in = "foo"; //~ error: expected pattern, found keyword `in` + | ^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-let-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-let-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-let-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-let-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py let' + +fn main() { + let let = "foo"; //~ error: expected pattern, found keyword `let` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-let-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-let-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-let-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-let-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `let` + --> $DIR/keyword-let-as-identifier.rs:16:9 + | +LL | let let = "foo"; //~ error: expected pattern, found keyword `let` + | ^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-loop-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-loop-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-loop-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-loop-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py loop' + +fn main() { + let loop = "foo"; //~ error: expected pattern, found keyword `loop` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-loop-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-loop-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-loop-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-loop-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `loop` + --> $DIR/keyword-loop-as-identifier.rs:16:9 + | +LL | let loop = "foo"; //~ error: expected pattern, found keyword `loop` + | ^^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-match-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-match-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-match-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-match-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py match' + +fn main() { + let match = "foo"; //~ error: expected pattern, found keyword `match` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-match-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-match-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-match-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-match-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `match` + --> $DIR/keyword-match-as-identifier.rs:16:9 + | +LL | let match = "foo"; //~ error: expected pattern, found keyword `match` + | ^^^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-mod-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-mod-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-mod-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-mod-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py mod' + +fn main() { + let mod = "foo"; //~ error: expected pattern, found keyword `mod` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-mod-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-mod-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-mod-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-mod-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `mod` + --> $DIR/keyword-mod-as-identifier.rs:16:9 + | +LL | let mod = "foo"; //~ error: expected pattern, found keyword `mod` + | ^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-move-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-move-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-move-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-move-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py move' + +fn main() { + let move = "foo"; //~ error: expected pattern, found keyword `move` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-move-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-move-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-move-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-move-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `move` + --> $DIR/keyword-move-as-identifier.rs:16:9 + | +LL | let move = "foo"; //~ error: expected pattern, found keyword `move` + | ^^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-mut-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-mut-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-mut-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-mut-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + let mut = "foo"; //~ error: expected identifier, found `=` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-mut-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-mut-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-mut-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-mut-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected identifier, found `=` + --> $DIR/keyword-mut-as-identifier.rs:14:13 + | +LL | let mut = "foo"; //~ error: expected identifier, found `=` + | ^ expected identifier + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-override.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-override.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-override.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-override.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + let override = (); //~ ERROR expected pattern, found reserved keyword `override` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-override.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-override.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-override.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-override.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found reserved keyword `override` + --> $DIR/keyword-override.rs:14:9 + | +LL | let override = (); //~ ERROR expected pattern, found reserved keyword `override` + | ^^^^^^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-pub-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-pub-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-pub-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-pub-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py pub' + +fn main() { + let pub = "foo"; //~ error: expected pattern, found keyword `pub` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-pub-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-pub-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-pub-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-pub-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `pub` + --> $DIR/keyword-pub-as-identifier.rs:16:9 + | +LL | let pub = "foo"; //~ error: expected pattern, found keyword `pub` + | ^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-ref-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-ref-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-ref-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-ref-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + let ref = "foo"; //~ error: expected identifier, found `=` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-ref-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-ref-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-ref-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-ref-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected identifier, found `=` + --> $DIR/keyword-ref-as-identifier.rs:14:13 + | +LL | let ref = "foo"; //~ error: expected identifier, found `=` + | ^ expected identifier + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-return-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-return-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-return-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-return-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py return' + +fn main() { + let return = "foo"; //~ error: expected pattern, found keyword `return` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-return-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-return-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-return-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-return-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `return` + --> $DIR/keyword-return-as-identifier.rs:16:9 + | +LL | let return = "foo"; //~ error: expected pattern, found keyword `return` + | ^^^^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +pub mod break { + //~^ ERROR expected identifier, found keyword `break` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keywords-followed-by-double-colon.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keywords-followed-by-double-colon.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keywords-followed-by-double-colon.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keywords-followed-by-double-colon.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + struct::foo(); + //~^ ERROR expected identifier +} +fn bar() { + mut::baz(); + //~^ ERROR expected expression, found keyword `mut` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keywords-followed-by-double-colon.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keywords-followed-by-double-colon.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keywords-followed-by-double-colon.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keywords-followed-by-double-colon.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error: expected identifier, found `::` + --> $DIR/keywords-followed-by-double-colon.rs:14:11 + | +LL | struct::foo(); + | ^^ expected identifier + +error: expected expression, found keyword `mut` + --> $DIR/keywords-followed-by-double-colon.rs:18:5 + | +LL | mut::baz(); + | ^^^ expected expression + +error: aborting due to 2 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-static-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-static-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-static-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-static-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py static' + +fn main() { + let static = "foo"; //~ error: expected pattern, found keyword `static` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-static-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-static-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-static-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-static-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `static` + --> $DIR/keyword-static-as-identifier.rs:16:9 + | +LL | let static = "foo"; //~ error: expected pattern, found keyword `static` + | ^^^^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected identifier, found keyword `break` + --> $DIR/keyword.rs:13:9 + | +LL | pub mod break { + | ^^^^^ expected identifier, found keyword + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-struct-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-struct-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-struct-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-struct-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py struct' + +fn main() { + let struct = "foo"; //~ error: expected pattern, found keyword `struct` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-struct-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-struct-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-struct-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-struct-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `struct` + --> $DIR/keyword-struct-as-identifier.rs:16:9 + | +LL | let struct = "foo"; //~ error: expected pattern, found keyword `struct` + | ^^^^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-trait-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-trait-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-trait-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-trait-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py trait' + +fn main() { + let trait = "foo"; //~ error: expected pattern, found keyword `trait` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-trait-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-trait-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-trait-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-trait-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `trait` + --> $DIR/keyword-trait-as-identifier.rs:16:9 + | +LL | let trait = "foo"; //~ error: expected pattern, found keyword `trait` + | ^^^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-try-as-identifier-edition2018.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-try-as-identifier-edition2018.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-try-as-identifier-edition2018.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-try-as-identifier-edition2018.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only --edition 2018 + +fn main() { + let try = "foo"; //~ error: expected pattern, found reserved keyword `try` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-try-as-identifier-edition2018.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-try-as-identifier-edition2018.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-try-as-identifier-edition2018.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-try-as-identifier-edition2018.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found reserved keyword `try` + --> $DIR/keyword-try-as-identifier-edition2018.rs:14:9 + | +LL | let try = "foo"; //~ error: expected pattern, found reserved keyword `try` + | ^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-type-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-type-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-type-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-type-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py type' + +fn main() { + let type = "foo"; //~ error: expected pattern, found keyword `type` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-type-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-type-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-type-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-type-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `type` + --> $DIR/keyword-type-as-identifier.rs:16:9 + | +LL | let type = "foo"; //~ error: expected pattern, found keyword `type` + | ^^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-typeof.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-typeof.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-typeof.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-typeof.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + let typeof = (); //~ ERROR expected pattern, found reserved keyword `typeof` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-typeof.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-typeof.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-typeof.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-typeof.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found reserved keyword `typeof` + --> $DIR/keyword-typeof.rs:14:9 + | +LL | let typeof = (); //~ ERROR expected pattern, found reserved keyword `typeof` + | ^^^^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-unsafe-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-unsafe-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-unsafe-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-unsafe-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py unsafe' + +fn main() { + let unsafe = "foo"; //~ error: expected pattern, found keyword `unsafe` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-unsafe-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-unsafe-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-unsafe-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-unsafe-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `unsafe` + --> $DIR/keyword-unsafe-as-identifier.rs:16:9 + | +LL | let unsafe = "foo"; //~ error: expected pattern, found keyword `unsafe` + | ^^^^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-use-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-use-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-use-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-use-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py use' + +fn main() { + let use = "foo"; //~ error: expected pattern, found keyword `use` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-use-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-use-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-use-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-use-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `use` + --> $DIR/keyword-use-as-identifier.rs:16:9 + | +LL | let use = "foo"; //~ error: expected pattern, found keyword `use` + | ^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-where-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-where-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-where-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-where-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py where' + +fn main() { + let where = "foo"; //~ error: expected pattern, found keyword `where` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-where-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-where-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-where-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-where-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `where` + --> $DIR/keyword-where-as-identifier.rs:16:9 + | +LL | let where = "foo"; //~ error: expected pattern, found keyword `where` + | ^^^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-while-as-identifier.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-while-as-identifier.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-while-as-identifier.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-while-as-identifier.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This file was auto-generated using 'src/etc/generate-keyword-tests.py while' + +fn main() { + let while = "foo"; //~ error: expected pattern, found keyword `while` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-while-as-identifier.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-while-as-identifier.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/keyword-while-as-identifier.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/keyword-while-as-identifier.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found keyword `while` + --> $DIR/keyword-while-as-identifier.rs:16:9 + | +LL | let while = "foo"; //~ error: expected pattern, found keyword `while` + | ^^^^^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-binary-literal.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-binary-literal.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-binary-literal.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-binary-literal.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +fn main() { + 0b121; //~ ERROR invalid digit for a base 2 literal + 0b10_10301; //~ ERROR invalid digit for a base 2 literal + 0b30; //~ ERROR invalid digit for a base 2 literal + 0b41; //~ ERROR invalid digit for a base 2 literal + 0b5; //~ ERROR invalid digit for a base 2 literal + 0b6; //~ ERROR invalid digit for a base 2 literal + 0b7; //~ ERROR invalid digit for a base 2 literal + 0b8; //~ ERROR invalid digit for a base 2 literal + 0b9; //~ ERROR invalid digit for a base 2 literal +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-binary-literal.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-binary-literal.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-binary-literal.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-binary-literal.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,56 @@ +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:14:8 + | +LL | 0b121; //~ ERROR invalid digit for a base 2 literal + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:15:12 + | +LL | 0b10_10301; //~ ERROR invalid digit for a base 2 literal + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:16:7 + | +LL | 0b30; //~ ERROR invalid digit for a base 2 literal + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:17:7 + | +LL | 0b41; //~ ERROR invalid digit for a base 2 literal + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:18:7 + | +LL | 0b5; //~ ERROR invalid digit for a base 2 literal + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:19:7 + | +LL | 0b6; //~ ERROR invalid digit for a base 2 literal + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:20:7 + | +LL | 0b7; //~ ERROR invalid digit for a base 2 literal + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:21:7 + | +LL | 0b8; //~ ERROR invalid digit for a base 2 literal + | ^ + +error: invalid digit for a base 2 literal + --> $DIR/lex-bad-binary-literal.rs:22:7 + | +LL | 0b9; //~ ERROR invalid digit for a base 2 literal + | ^ + +error: aborting due to 9 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error +static c3: char = + '\x1' //~ ERROR: numeric character escape is too short +; + +static s: &'static str = + "\x1" //~ ERROR: numeric character escape is too short +; + +static c: char = + '\●' //~ ERROR: unknown character escape +; + +static s: &'static str = + "\●" //~ ERROR: unknown character escape +; + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-1.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +error: numeric character escape is too short + --> $DIR/lex-bad-char-literals-1.rs:13:8 + | +LL | '/x1' //~ ERROR: numeric character escape is too short + | ^ + +error: numeric character escape is too short + --> $DIR/lex-bad-char-literals-1.rs:17:8 + | +LL | "/x1" //~ ERROR: numeric character escape is too short + | ^ + +error: unknown character escape: /u{25cf} + --> $DIR/lex-bad-char-literals-1.rs:21:7 + | +LL | '/●' //~ ERROR: unknown character escape + | ^ + +error: unknown character escape: /u{25cf} + --> $DIR/lex-bad-char-literals-1.rs:25:7 + | +LL | "/●" //~ ERROR: unknown character escape + | ^ + +error: aborting due to 4 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This test needs to the last one appearing in this file as it kills the parser +static c: char = + 'nope' //~ ERROR: character literal may only contain one codepoint: 'nope' +; + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: character literal may only contain one codepoint: 'nope' + --> $DIR/lex-bad-char-literals-2.rs:15:5 + | +LL | 'nope' //~ ERROR: character literal may only contain one codepoint: 'nope' + | ^^^^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// This test needs to the last one appearing in this file as it kills the parser +static c: char = + '●●' //~ ERROR: character literal may only contain one codepoint +; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-3.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-3.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-3.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-3.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +error: character literal may only contain one codepoint + --> $DIR/lex-bad-char-literals-3.rs:15:5 + | +LL | '●●' //~ ERROR: character literal may only contain one codepoint + | ^^^^ +help: if you meant to write a `str` literal, use double quotes + | +LL | "●●" //~ ERROR: character literal may only contain one codepoint + | ^^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-4.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-4.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-4.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only +// +// This test needs to the last one appearing in this file as it kills the parser +static c: char = + '● //~ ERROR: character literal may only contain one codepoint: '● +; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-4.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-4.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-4.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-4.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: character literal may only contain one codepoint: '● + --> $DIR/lex-bad-char-literals-4.rs:15:5 + | +LL | '● //~ ERROR: character literal may only contain one codepoint: '● + | ^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-5.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-5.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-5.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-5.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only +// +// This test needs to the last one appearing in this file as it kills the parser +static c: char = + '\x10\x10' //~ ERROR: character literal may only contain one codepoint +; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-5.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-5.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-5.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-char-literals-5.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +error: character literal may only contain one codepoint + --> $DIR/lex-bad-char-literals-5.rs:15:5 + | +LL | '/x10/x10' //~ ERROR: character literal may only contain one codepoint + | ^^^^^^^^^^ +help: if you meant to write a `str` literal, use double quotes + | +LL | "/x10/x10" //~ ERROR: character literal may only contain one codepoint + | ^^^^^^^^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-numeric-literals.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-numeric-literals.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-numeric-literals.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-numeric-literals.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +fn main() { + 0o1.0; //~ ERROR: octal float literal is not supported + 0o2f32; //~ ERROR: octal float literal is not supported + 0o3.0f32; //~ ERROR: octal float literal is not supported + 0o4e4; //~ ERROR: octal float literal is not supported + 0o5.0e5; //~ ERROR: octal float literal is not supported + 0o6e6f32; //~ ERROR: octal float literal is not supported + 0o7.0e7f64; //~ ERROR: octal float literal is not supported + 0x8.0e+9; //~ ERROR: hexadecimal float literal is not supported + 0x9.0e-9; //~ ERROR: hexadecimal float literal is not supported + 0o; //~ ERROR: no valid digits + 1e+; //~ ERROR: expected at least one digit in exponent + 0x539.0; //~ ERROR: hexadecimal float literal is not supported + 9900000000000000000000000000999999999999999999999999999999; //~ ERROR: int literal is too large + 9900000000000000000000000000999999999999999999999999999999; //~ ERROR: int literal is too large + 0x; //~ ERROR: no valid digits + 0xu32; //~ ERROR: no valid digits + 0ou32; //~ ERROR: no valid digits + 0bu32; //~ ERROR: no valid digits + 0b; //~ ERROR: no valid digits + 0o123f64; //~ ERROR: octal float literal is not supported + 0o123.456; //~ ERROR: octal float literal is not supported + 0b101f64; //~ ERROR: binary float literal is not supported + 0b111.101; //~ ERROR: binary float literal is not supported +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-numeric-literals.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-numeric-literals.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-numeric-literals.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-numeric-literals.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,140 @@ +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:14:5 + | +LL | 0o1.0; //~ ERROR: octal float literal is not supported + | ^^^^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:16:5 + | +LL | 0o3.0f32; //~ ERROR: octal float literal is not supported + | ^^^^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:17:5 + | +LL | 0o4e4; //~ ERROR: octal float literal is not supported + | ^^^^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:18:5 + | +LL | 0o5.0e5; //~ ERROR: octal float literal is not supported + | ^^^^^^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:19:5 + | +LL | 0o6e6f32; //~ ERROR: octal float literal is not supported + | ^^^^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:20:5 + | +LL | 0o7.0e7f64; //~ ERROR: octal float literal is not supported + | ^^^^^^^ + +error: hexadecimal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:21:5 + | +LL | 0x8.0e+9; //~ ERROR: hexadecimal float literal is not supported + | ^^^^^^^^ + +error: hexadecimal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:22:5 + | +LL | 0x9.0e-9; //~ ERROR: hexadecimal float literal is not supported + | ^^^^^^^^ + +error: no valid digits found for number + --> $DIR/lex-bad-numeric-literals.rs:23:5 + | +LL | 0o; //~ ERROR: no valid digits + | ^^ + +error: expected at least one digit in exponent + --> $DIR/lex-bad-numeric-literals.rs:24:8 + | +LL | 1e+; //~ ERROR: expected at least one digit in exponent + | ^ + +error: hexadecimal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:25:5 + | +LL | 0x539.0; //~ ERROR: hexadecimal float literal is not supported + | ^^^^^^^ + +error: no valid digits found for number + --> $DIR/lex-bad-numeric-literals.rs:28:5 + | +LL | 0x; //~ ERROR: no valid digits + | ^^ + +error: no valid digits found for number + --> $DIR/lex-bad-numeric-literals.rs:29:5 + | +LL | 0xu32; //~ ERROR: no valid digits + | ^^ + +error: no valid digits found for number + --> $DIR/lex-bad-numeric-literals.rs:30:5 + | +LL | 0ou32; //~ ERROR: no valid digits + | ^^ + +error: no valid digits found for number + --> $DIR/lex-bad-numeric-literals.rs:31:5 + | +LL | 0bu32; //~ ERROR: no valid digits + | ^^ + +error: no valid digits found for number + --> $DIR/lex-bad-numeric-literals.rs:32:5 + | +LL | 0b; //~ ERROR: no valid digits + | ^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:34:5 + | +LL | 0o123.456; //~ ERROR: octal float literal is not supported + | ^^^^^^^^^ + +error: binary float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:36:5 + | +LL | 0b111.101; //~ ERROR: binary float literal is not supported + | ^^^^^^^^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:15:5 + | +LL | 0o2f32; //~ ERROR: octal float literal is not supported + | ^^^^^^ + +error: int literal is too large + --> $DIR/lex-bad-numeric-literals.rs:26:5 + | +LL | 9900000000000000000000000000999999999999999999999999999999; //~ ERROR: int literal is too large + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: int literal is too large + --> $DIR/lex-bad-numeric-literals.rs:27:5 + | +LL | 9900000000000000000000000000999999999999999999999999999999; //~ ERROR: int literal is too large + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: octal float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:33:5 + | +LL | 0o123f64; //~ ERROR: octal float literal is not supported + | ^^^^^^^^ + +error: binary float literal is not supported + --> $DIR/lex-bad-numeric-literals.rs:35:5 + | +LL | 0b101f64; //~ ERROR: binary float literal is not supported + | ^^^^^^^^ + +error: aborting due to 23 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-octal-literal.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-octal-literal.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-octal-literal.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-octal-literal.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +fn main() { + 0o18; //~ ERROR invalid digit for a base 8 literal + 0o1234_9_5670; //~ ERROR invalid digit for a base 8 literal +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-octal-literal.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-octal-literal.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-octal-literal.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-octal-literal.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error: invalid digit for a base 8 literal + --> $DIR/lex-bad-octal-literal.rs:14:8 + | +LL | 0o18; //~ ERROR invalid digit for a base 8 literal + | ^ + +error: invalid digit for a base 8 literal + --> $DIR/lex-bad-octal-literal.rs:15:12 + | +LL | 0o1234_9_5670; //~ ERROR invalid digit for a base 8 literal + | ^ + +error: aborting due to 2 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-token.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-token.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-token.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-token.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +● //~ ERROR: unknown start of token diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-token.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-token.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bad-token.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bad-token.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: unknown start of token: /u{25cf} + --> $DIR/lex-bad-token.rs:13:1 + | +LL | ● //~ ERROR: unknown start of token + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +// ignore-tidy-cr + +/// doc comment with bare CR: ' ' +pub fn foo() {} +//~^^ ERROR: bare CR not allowed in doc-comment + +/** block doc comment with bare CR: ' ' */ +pub fn bar() {} +//~^^ ERROR: bare CR not allowed in block doc-comment + +fn main() { + //! doc comment with bare CR: ' ' + //~^ ERROR: bare CR not allowed in doc-comment + + /*! block doc comment with bare CR: ' ' */ + //~^ ERROR: bare CR not allowed in block doc-comment + + // the following string literal has a bare CR in it + let _s = "foo bar"; //~ ERROR: bare CR not allowed in string + + // the following string literal has a bare CR in it + let _s = r"bar foo"; //~ ERROR: bare CR not allowed in raw string + + // the following string literal has a bare CR in it + let _s = "foo\ bar"; //~ ERROR: unknown character escape: \r +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,50 @@ +error: bare CR not allowed in doc-comment + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:15:32 + | +LL | /// doc comment with bare CR: ' ' + | ^ + +error: bare CR not allowed in block doc-comment + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:19:38 + | +LL | /** block doc comment with bare CR: ' ' */ + | ^ + +error: bare CR not allowed in doc-comment + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:24:36 + | +LL | //! doc comment with bare CR: ' ' + | ^ + +error: bare CR not allowed in block doc-comment + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:27:42 + | +LL | /*! block doc comment with bare CR: ' ' */ + | ^ + +error: bare CR not allowed in string, use /r instead + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:31:18 + | +LL | let _s = "foo bar"; //~ ERROR: bare CR not allowed in string + | ^ + +error: bare CR not allowed in raw string, use /r instead + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:34:14 + | +LL | let _s = r"bar foo"; //~ ERROR: bare CR not allowed in raw string + | ^^^^^ + +error: unknown character escape: /r + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:37:19 + | +LL | let _s = "foo/ bar"; //~ ERROR: unknown character escape: /r + | ^ + | +help: this is an isolated carriage return; consider checking your editor and version control settings + --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:37:19 + | +LL | let _s = "foo/ bar"; //~ ERROR: unknown character escape: /r + | ^ + +error: aborting due to 7 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-stray-backslash.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-stray-backslash.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-stray-backslash.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-stray-backslash.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +\ //~ ERROR: unknown start of token: \ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-stray-backslash.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-stray-backslash.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lex-stray-backslash.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lex-stray-backslash.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: unknown start of token: / + --> $DIR/lex-stray-backslash.rs:13:1 + | +LL | / //~ ERROR: unknown start of token: / + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lifetime-in-pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lifetime-in-pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lifetime-in-pattern.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lifetime-in-pattern.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn test(&'a str) { + //~^ ERROR unexpected lifetime `'a` in pattern +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lifetime-in-pattern.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lifetime-in-pattern.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lifetime-in-pattern.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lifetime-in-pattern.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: unexpected lifetime `'a` in pattern + --> $DIR/lifetime-in-pattern.rs:13:10 + | +LL | fn test(&'a str) { + | ^^ unexpected lifetime + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lifetime-semicolon.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lifetime-semicolon.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lifetime-semicolon.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lifetime-semicolon.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +struct Foo<'a, 'b> { + a: &'a &'b i32 +} + +fn foo<'a, 'b>(x: &mut Foo<'a; 'b>) {} +//~^ ERROR expected one of `,` or `>`, found `;` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lifetime-semicolon.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lifetime-semicolon.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/lifetime-semicolon.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/lifetime-semicolon.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `,` or `>`, found `;` + --> $DIR/lifetime-semicolon.rs:17:30 + | +LL | fn foo<'a, 'b>(x: &mut Foo<'a; 'b>) {} + | ^ expected one of `,` or `>` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/issue-33569.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/issue-33569.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/issue-33569.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/issue-33569.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! foo { + { $+ } => { //~ ERROR expected identifier, found `+` + //~^ ERROR missing fragment specifier + $(x)(y) //~ ERROR expected `*` or `+` + } +} + +foo!(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/issue-33569.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/issue-33569.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/issue-33569.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/issue-33569.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +error: expected identifier, found `+` + --> $DIR/issue-33569.rs:12:8 + | +LL | { $+ } => { //~ ERROR expected identifier, found `+` + | ^ + +error: expected `*` or `+` + --> $DIR/issue-33569.rs:14:13 + | +LL | $(x)(y) //~ ERROR expected `*` or `+` + | ^^^ + +error: missing fragment specifier + --> $DIR/issue-33569.rs:12:8 + | +LL | { $+ } => { //~ ERROR expected identifier, found `+` + | ^ + +error: aborting due to 3 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/issue-37113.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/issue-37113.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/issue-37113.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/issue-37113.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! test_macro { + ( $( $t:ty ),* $(),*) => { + enum SomeEnum { + $( $t, )* //~ ERROR expected identifier, found `String` + }; + }; +} + +fn main() { + test_macro!(String,); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/issue-37113.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/issue-37113.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/issue-37113.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/issue-37113.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error: expected identifier, found `String` + --> $DIR/issue-37113.rs:14:16 + | +LL | $( $t, )* //~ ERROR expected identifier, found `String` + | ^^ expected identifier +... +LL | test_macro!(String,); + | --------------------- in this macro invocation + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/issue-37234.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/issue-37234.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/issue-37234.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/issue-37234.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! failed { + () => {{ + let x = 5 ""; //~ ERROR found `""` + }} +} + +fn main() { + failed!(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/issue-37234.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/issue-37234.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/issue-37234.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/issue-37234.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error: expected one of `.`, `;`, `?`, or an operator, found `""` + --> $DIR/issue-37234.rs:13:19 + | +LL | let x = 5 ""; //~ ERROR found `""` + | ^^ expected one of `.`, `;`, `?`, or an operator here +... +LL | failed!(); + | ---------- in this macro invocation + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/macro-doc-comments-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/macro-doc-comments-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/macro-doc-comments-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/macro-doc-comments-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! outer { + (#[$outer:meta]) => () +} + +outer! { + //! Inner +} //~^ ERROR no rules expected the token `!` + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/macro-doc-comments-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/macro-doc-comments-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/macro-doc-comments-1.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/macro-doc-comments-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: no rules expected the token `!` + --> $DIR/macro-doc-comments-1.rs:16:5 + | +LL | //! Inner + | ^^^^^^^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/macro-doc-comments-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/macro-doc-comments-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/macro-doc-comments-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/macro-doc-comments-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! inner { + (#![$inner:meta]) => () +} + +inner! { + /// Outer +} //~^ ERROR no rules expected the token `[` + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/macro-doc-comments-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/macro-doc-comments-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/macro-doc-comments-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/macro-doc-comments-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: no rules expected the token `[` + --> $DIR/macro-doc-comments-2.rs:16:5 + | +LL | /// Outer + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/macro-incomplete-parse.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/macro-incomplete-parse.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/macro-incomplete-parse.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/macro-incomplete-parse.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z continue-parse-after-error + +macro_rules! ignored_item { + () => { + fn foo() {} + fn bar() {} + , //~ ERROR macro expansion ignores token `,` + } +} + +macro_rules! ignored_expr { + () => ( 1, //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `,` + + 2 ) +} + +macro_rules! ignored_pat { + () => ( 1, 2 ) //~ ERROR macro expansion ignores token `,` +} + +ignored_item!(); + +fn main() { + ignored_expr!(); + match 1 { + ignored_pat!() => (), + _ => (), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/macro-incomplete-parse.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/macro-incomplete-parse.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/macro-incomplete-parse.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/macro-incomplete-parse.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +error: macro expansion ignores token `,` and any following + --> $DIR/macro-incomplete-parse.rs:17:9 + | +LL | , //~ ERROR macro expansion ignores token `,` + | ^ + | +note: caused by the macro expansion here; the usage of `ignored_item!` is likely invalid in item context + --> $DIR/macro-incomplete-parse.rs:31:1 + | +LL | ignored_item!(); + | ^^^^^^^^^^^^^^^^ + +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `,` + --> $DIR/macro-incomplete-parse.rs:22:14 + | +LL | () => ( 1, //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `,` + | ^ expected one of `.`, `;`, `?`, `}`, or an operator here +... +LL | ignored_expr!(); + | ---------------- in this macro invocation + +error: macro expansion ignores token `,` and any following + --> $DIR/macro-incomplete-parse.rs:28:14 + | +LL | () => ( 1, 2 ) //~ ERROR macro expansion ignores token `,` + | ^ + | +note: caused by the macro expansion here; the usage of `ignored_pat!` is likely invalid in pattern context + --> $DIR/macro-incomplete-parse.rs:36:9 + | +LL | ignored_pat!() => (), + | ^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/macro-repeat.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/macro-repeat.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/macro-repeat.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/macro-repeat.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! mac { + ( $($v:tt)* ) => ( + $v //~ ERROR still repeating at this depth + ) +} + +fn main() { + mac!(0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/macro-repeat.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/macro-repeat.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/macro-repeat.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/macro-repeat.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: variable 'v' is still repeating at this depth + --> $DIR/macro-repeat.rs:13:9 + | +LL | $v //~ ERROR still repeating at this depth + | ^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/pub-item-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/pub-item-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/pub-item-macro.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/pub-item-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue #14660 + +macro_rules! priv_x { () => { + static x: u32 = 0; +}} + +macro_rules! pub_x { () => { + pub priv_x!(); //~ ERROR can't qualify macro invocation with `pub` + //~^ HELP try adjusting the macro to put `pub` inside the invocation +}} + +mod foo { + pub_x!(); +} + +fn main() { + let y: u32 = foo::x; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/pub-item-macro.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/pub-item-macro.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/pub-item-macro.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/pub-item-macro.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +error: can't qualify macro invocation with `pub` + --> $DIR/pub-item-macro.rs:18:5 + | +LL | pub priv_x!(); //~ ERROR can't qualify macro invocation with `pub` + | ^^^ +... +LL | pub_x!(); + | --------- in this macro invocation + | + = help: try adjusting the macro to put `pub` inside the invocation + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/trait-non-item-macros.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/trait-non-item-macros.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/trait-non-item-macros.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/trait-non-item-macros.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! bah { + ($a:expr) => ($a) + //~^ ERROR expected one of `async`, `const`, `extern`, `fn`, `type`, or `unsafe`, found `2` +} + +trait bar { + bah!(2); +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/trait-non-item-macros.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/trait-non-item-macros.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/trait-non-item-macros.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/trait-non-item-macros.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error: expected one of `async`, `const`, `extern`, `fn`, `type`, or `unsafe`, found `2` + --> $DIR/trait-non-item-macros.rs:12:19 + | +LL | ($a:expr) => ($a) + | ^^ unexpected token +... +LL | bah!(2); + | -------- in this macro invocation + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/trait-object-macro-matcher.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/trait-object-macro-matcher.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/trait-object-macro-matcher.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/trait-object-macro-matcher.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// A single lifetime is not parsed as a type. +// `ty` matcher in particular doesn't accept a single lifetime + +macro_rules! m { + ($t: ty) => ( let _: $t; ) +} + +fn main() { + m!('static); //~ ERROR expected type, found `'static` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/trait-object-macro-matcher.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/trait-object-macro-matcher.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro/trait-object-macro-matcher.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro/trait-object-macro-matcher.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected type, found `'static` + --> $DIR/trait-object-macro-matcher.rs:19:8 + | +LL | m!('static); //~ ERROR expected type, found `'static` + | ^^^^^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro-bad-delimiter-ident.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro-bad-delimiter-ident.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro-bad-delimiter-ident.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro-bad-delimiter-ident.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + foo! bar < //~ ERROR expected `(` or `{`, found `<` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro-bad-delimiter-ident.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro-bad-delimiter-ident.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro-bad-delimiter-ident.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro-bad-delimiter-ident.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected `(` or `{`, found `<` + --> $DIR/macro-bad-delimiter-ident.rs:14:14 + | +LL | foo! bar < //~ ERROR expected `(` or `{`, found `<` + | ^ expected `(` or `{` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro-keyword.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro-keyword.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro-keyword.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro-keyword.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn macro() { //~ ERROR expected identifier, found reserved keyword `macro` +} + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro-keyword.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro-keyword.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro-keyword.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro-keyword.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected identifier, found reserved keyword `macro` + --> $DIR/macro-keyword.rs:13:4 + | +LL | fn macro() { //~ ERROR expected identifier, found reserved keyword `macro` + | ^^^^^ expected identifier, found reserved keyword + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro-mismatched-delim-brace-paren.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro-mismatched-delim-brace-paren.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro-mismatched-delim-brace-paren.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro-mismatched-delim-brace-paren.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + foo! { + bar, "baz", 1, 2.0 + ) //~ ERROR incorrect close delimiter +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro-mismatched-delim-brace-paren.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro-mismatched-delim-brace-paren.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro-mismatched-delim-brace-paren.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro-mismatched-delim-brace-paren.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error: incorrect close delimiter: `)` + --> $DIR/macro-mismatched-delim-brace-paren.rs:16:5 + | +LL | foo! { + | - un-closed delimiter +LL | bar, "baz", 1, 2.0 +LL | ) //~ ERROR incorrect close delimiter + | ^ incorrect close delimiter + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro-mismatched-delim-paren-brace.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro-mismatched-delim-paren-brace.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro-mismatched-delim-paren-brace.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro-mismatched-delim-paren-brace.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + foo! ( + bar, "baz", 1, 2.0 + } //~ ERROR incorrect close delimiter +} //~ ERROR unexpected close delimiter: `}` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro-mismatched-delim-paren-brace.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro-mismatched-delim-paren-brace.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macro-mismatched-delim-paren-brace.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macro-mismatched-delim-paren-brace.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +error: incorrect close delimiter: `}` + --> $DIR/macro-mismatched-delim-paren-brace.rs:16:5 + | +LL | foo! ( + | - un-closed delimiter +LL | bar, "baz", 1, 2.0 +LL | } //~ ERROR incorrect close delimiter + | ^ incorrect close delimiter + +error: unexpected close delimiter: `}` + --> $DIR/macro-mismatched-delim-paren-brace.rs:17:1 + | +LL | } //~ ERROR unexpected close delimiter: `}` + | ^ unexpected close delimiter + +error: aborting due to 2 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macros-no-semicolon-items.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macros-no-semicolon-items.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macros-no-semicolon-items.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macros-no-semicolon-items.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +macro_rules! foo() //~ ERROR semicolon + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macros-no-semicolon-items.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macros-no-semicolon-items.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macros-no-semicolon-items.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macros-no-semicolon-items.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: macros that expand to items must either be surrounded with braces or followed by a semicolon + --> $DIR/macros-no-semicolon-items.rs:13:17 + | +LL | macro_rules! foo() //~ ERROR semicolon + | ^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macros-no-semicolon.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macros-no-semicolon.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macros-no-semicolon.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macros-no-semicolon.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + assert_eq!(1, 2) + assert_eq!(3, 4) //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `assert_eq` + println!("hello"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macros-no-semicolon.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macros-no-semicolon.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/macros-no-semicolon.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/macros-no-semicolon.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `assert_eq` + --> $DIR/macros-no-semicolon.rs:15:5 + | +LL | assert_eq!(1, 2) + | - expected one of `.`, `;`, `?`, `}`, or an operator here +LL | assert_eq!(3, 4) //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `assert_eq` + | ^^^^^^^^^ unexpected token + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/match-arrows-block-then-binop.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/match-arrows-block-then-binop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/match-arrows-block-then-binop.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/match-arrows-block-then-binop.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + + match 0 { + 0 => { + } + 5 //~ ERROR expected pattern, found `+` + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/match-arrows-block-then-binop.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/match-arrows-block-then-binop.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/match-arrows-block-then-binop.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/match-arrows-block-then-binop.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found `+` + --> $DIR/match-arrows-block-then-binop.rs:17:9 + | +LL | } + 5 //~ ERROR expected pattern, found `+` + | ^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/match-refactor-to-expr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/match-refactor-to-expr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/match-refactor-to-expr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/match-refactor-to-expr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + let foo = + match + Some(4).unwrap_or_else(5) + //~^ NOTE expected one of `.`, `?`, `{`, or an operator here + ; //~ NOTE unexpected token + //~^ ERROR expected one of `.`, `?`, `{`, or an operator, found `;` + + println!("{}", foo) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/match-refactor-to-expr.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/match-refactor-to-expr.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/match-refactor-to-expr.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/match-refactor-to-expr.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +error: expected one of `.`, `?`, `{`, or an operator, found `;` + --> $DIR/match-refactor-to-expr.rs:18:9 + | +LL | match + | ----- help: try removing this `match` +LL | Some(4).unwrap_or_else(5) + | - expected one of `.`, `?`, `{`, or an operator here +LL | //~^ NOTE expected one of `.`, `?`, `{`, or an operator here +LL | ; //~ NOTE unexpected token + | ^ unexpected token + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/match-vec-invalid.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/match-vec-invalid.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/match-vec-invalid.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/match-vec-invalid.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + let a = Vec::new(); + match a { + [1, tail.., tail..] => {}, //~ ERROR: expected one of `,` or `@`, found `..` + _ => () + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/match-vec-invalid.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/match-vec-invalid.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/match-vec-invalid.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/match-vec-invalid.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `,` or `@`, found `..` + --> $DIR/match-vec-invalid.rs:16:25 + | +LL | [1, tail.., tail..] => {}, //~ ERROR: expected one of `,` or `@`, found `..` + | ^^ expected one of `,` or `@` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/mod_file_not_exist.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/mod_file_not_exist.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/mod_file_not_exist.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/mod_file_not_exist.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-windows +// compile-flags: -Z parse-only + +mod not_a_real_file; //~ ERROR file not found for module `not_a_real_file` +//~^ HELP name the file either not_a_real_file.rs or not_a_real_file/mod.rs inside the directory + +fn main() { + assert_eq!(mod_file_aux::bar(), 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/mod_file_not_exist.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/mod_file_not_exist.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/mod_file_not_exist.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/mod_file_not_exist.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0583]: file not found for module `not_a_real_file` + --> $DIR/mod_file_not_exist.rs:14:5 + | +LL | mod not_a_real_file; //~ ERROR file not found for module `not_a_real_file` + | ^^^^^^^^^^^^^^^ + | + = help: name the file either not_a_real_file.rs or not_a_real_file/mod.rs inside the directory "$DIR" + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0583`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/mod_file_not_exist_windows.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/mod_file_not_exist_windows.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/mod_file_not_exist_windows.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/mod_file_not_exist_windows.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// only-windows +// compile-flags: -Z parse-only + +mod not_a_real_file; //~ ERROR file not found for module `not_a_real_file` +//~^ HELP name the file either not_a_real_file.rs or not_a_real_file\mod.rs inside the directory + +fn main() { + assert_eq!(mod_file_aux::bar(), 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/mod_file_not_exist_windows.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/mod_file_not_exist_windows.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/mod_file_not_exist_windows.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/mod_file_not_exist_windows.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0583]: file not found for module `not_a_real_file` + --> $DIR/mod_file_not_exist_windows.rs:14:5 + | +LL | mod not_a_real_file; //~ ERROR file not found for module `not_a_real_file` + | ^^^^^^^^^^^^^^^ + | + = help: name the file either not_a_real_file.rs or not_a_real_file/mod.rs inside the directory "$DIR" + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0583`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/mod_file_with_path_attr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/mod_file_with_path_attr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/mod_file_with_path_attr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/mod_file_with_path_attr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only +// normalize-stderr-test: "not_a_real_file.rs:.*\(" -> "not_a_real_file.rs: $$FILE_NOT_FOUND_MSG (" + +#[path = "not_a_real_file.rs"] +mod m; //~ ERROR not_a_real_file.rs + +fn main() { + assert_eq!(m::foo(), 10); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/mod_file_with_path_attr.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/mod_file_with_path_attr.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/mod_file_with_path_attr.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/mod_file_with_path_attr.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: couldn't read $DIR/not_a_real_file.rs: $FILE_NOT_FOUND_MSG (os error 2) + --> $DIR/mod_file_with_path_attr.rs:15:5 + | +LL | mod m; //~ ERROR not_a_real_file.rs + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/multiline-comment-line-tracking.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/multiline-comment-line-tracking.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/multiline-comment-line-tracking.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/multiline-comment-line-tracking.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only +// error-pattern:19:3 + +/* 1 + * 2 + * 3 + */ +fn main() { + %; // parse error on line 19, but is reported on line 6 instead. +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/multiline-comment-line-tracking.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/multiline-comment-line-tracking.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/multiline-comment-line-tracking.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/multiline-comment-line-tracking.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected expression, found `%` + --> $DIR/multiline-comment-line-tracking.rs:19:3 + | +LL | %; // parse error on line 19, but is reported on line 6 instead. + | ^ expected expression + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/multitrait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/multitrait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/multitrait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/multitrait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +struct S { + y: isize +} + +impl Cmp, ToString for S { +//~^ ERROR: expected one of `!`, `(`, `+`, `::`, `<`, `for`, `where`, or `{`, found `,` + fn eq(&&other: S) { false } + fn to_string(&self) -> String { "hi".to_string() } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/multitrait.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/multitrait.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/multitrait.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/multitrait.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `!`, `(`, `+`, `::`, `<`, `for`, `where`, or `{`, found `,` + --> $DIR/multitrait.rs:17:9 + | +LL | impl Cmp, ToString for S { + | ^ expected one of 8 possible tokens here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/mut-patterns.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/mut-patterns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/mut-patterns.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/mut-patterns.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// Can't put mut in non-ident pattern + +pub fn main() { + struct Foo { x: isize } + let mut Foo { x: x } = Foo { x: 3 }; //~ ERROR: expected one of `:`, `;`, `=`, or `@`, found `{` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/mut-patterns.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/mut-patterns.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/mut-patterns.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/mut-patterns.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `:`, `;`, `=`, or `@`, found `{` + --> $DIR/mut-patterns.rs:17:17 + | +LL | let mut Foo { x: x } = Foo { x: 3 }; //~ ERROR: expected one of `:`, `;`, `=`, or `@`, found `{` + | ^ expected one of `:`, `;`, `=`, or `@` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +pub fn main() { + let s = "\u{2603"; //~ ERROR unterminated unicode escape (needed a `}`) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-1.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: unterminated unicode escape (needed a `}`) + --> $DIR/new-unicode-escapes-1.rs:14:21 + | +LL | let s = "/u{2603"; //~ ERROR unterminated unicode escape (needed a `}`) + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +pub fn main() { + let s = "\u{260311111111}"; //~ ERROR overlong unicode escape (must have at most 6 hex digits) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: overlong unicode escape (must have at most 6 hex digits) + --> $DIR/new-unicode-escapes-2.rs:14:17 + | +LL | let s = "/u{260311111111}"; //~ ERROR overlong unicode escape (must have at most 6 hex digits) + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +pub fn main() { + let s1 = "\u{d805}"; //~ ERROR invalid unicode character escape + let s2 = "\u{ffffff}"; //~ ERROR invalid unicode character escape +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-3.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-3.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-3.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-3.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +error: invalid unicode character escape + --> $DIR/new-unicode-escapes-3.rs:14:14 + | +LL | let s1 = "/u{d805}"; //~ ERROR invalid unicode character escape + | ^^^^^^^^^^ + | + = help: unicode escape must not be a surrogate + +error: invalid unicode character escape + --> $DIR/new-unicode-escapes-3.rs:15:14 + | +LL | let s2 = "/u{ffffff}"; //~ ERROR invalid unicode character escape + | ^^^^^^^^^^^^ + | + = help: unicode escape must be at most 10FFFF + +error: aborting due to 2 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-4.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-4.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-4.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +pub fn main() { + let s = "\u{lol}"; + //~^ ERROR invalid character in unicode escape: l +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-4.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-4.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-4.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/new-unicode-escapes-4.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: invalid character in unicode escape: l + --> $DIR/new-unicode-escapes-4.rs:14:17 + | +LL | let s = "/u{lol}"; + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/no-binary-float-literal.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/no-binary-float-literal.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/no-binary-float-literal.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/no-binary-float-literal.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// error-pattern:binary float literal is not supported + +fn main() { + 0b101010f64; + 0b101.010; + 0b101p4f64; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/no-binary-float-literal.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/no-binary-float-literal.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/no-binary-float-literal.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/no-binary-float-literal.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: binary float literal is not supported + --> $DIR/no-binary-float-literal.rs:17:5 + | +LL | 0b101.010; + | ^^^^^^^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/no-hex-float-literal.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/no-hex-float-literal.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/no-hex-float-literal.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/no-hex-float-literal.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// error-pattern:hexadecimal float literal is not supported + +fn main() { + 0xABC.Df; + 0x567.89; + 0xDEAD.BEEFp-2f; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/no-hex-float-literal.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/no-hex-float-literal.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/no-hex-float-literal.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/no-hex-float-literal.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: hexadecimal float literal is not supported + --> $DIR/no-hex-float-literal.rs:17:5 + | +LL | 0x567.89; + | ^^^^^^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/not-a-pred.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/not-a-pred.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/not-a-pred.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/not-a-pred.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// error-pattern: lt + +fn f(a: isize, b: isize) : lt(a, b) { } + +fn lt(a: isize, b: isize) { } + +fn main() { let a: isize = 10; let b: isize = 23; check (lt(a, b)); f(a, b); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/not-a-pred.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/not-a-pred.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/not-a-pred.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/not-a-pred.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `->`, `where`, or `{`, found `:` + --> $DIR/not-a-pred.rs:15:26 + | +LL | fn f(a: isize, b: isize) : lt(a, b) { } + | ^ expected one of `->`, `where`, or `{` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/no-unsafe-self.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/no-unsafe-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/no-unsafe-self.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/no-unsafe-self.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +trait A { + fn foo(*mut self); //~ ERROR cannot pass `self` by raw pointer + fn baz(*const self); //~ ERROR cannot pass `self` by raw pointer + fn bar(*self); //~ ERROR cannot pass `self` by raw pointer +} + +struct X; +impl A for X { + fn foo(*mut self) { } //~ ERROR cannot pass `self` by raw pointer + fn baz(*const self) { } //~ ERROR cannot pass `self` by raw pointer + fn bar(*self) { } //~ ERROR cannot pass `self` by raw pointer +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/no-unsafe-self.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/no-unsafe-self.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/no-unsafe-self.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/no-unsafe-self.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +error: cannot pass `self` by raw pointer + --> $DIR/no-unsafe-self.rs:14:17 + | +LL | fn foo(*mut self); //~ ERROR cannot pass `self` by raw pointer + | ^^^^ + +error: cannot pass `self` by raw pointer + --> $DIR/no-unsafe-self.rs:15:19 + | +LL | fn baz(*const self); //~ ERROR cannot pass `self` by raw pointer + | ^^^^ + +error: cannot pass `self` by raw pointer + --> $DIR/no-unsafe-self.rs:16:13 + | +LL | fn bar(*self); //~ ERROR cannot pass `self` by raw pointer + | ^^^^ + +error: cannot pass `self` by raw pointer + --> $DIR/no-unsafe-self.rs:21:17 + | +LL | fn foo(*mut self) { } //~ ERROR cannot pass `self` by raw pointer + | ^^^^ + +error: cannot pass `self` by raw pointer + --> $DIR/no-unsafe-self.rs:22:19 + | +LL | fn baz(*const self) { } //~ ERROR cannot pass `self` by raw pointer + | ^^^^ + +error: cannot pass `self` by raw pointer + --> $DIR/no-unsafe-self.rs:23:13 + | +LL | fn bar(*self) { } //~ ERROR cannot pass `self` by raw pointer + | ^^^^ + +error: aborting due to 6 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/omitted-arg-in-item-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/omitted-arg-in-item-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/omitted-arg-in-item-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/omitted-arg-in-item-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn foo(x) { //~ ERROR expected one of `:` or `@`, found `)` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/omitted-arg-in-item-fn.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/omitted-arg-in-item-fn.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/omitted-arg-in-item-fn.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/omitted-arg-in-item-fn.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `:` or `@`, found `)` + --> $DIR/omitted-arg-in-item-fn.rs:13:9 + | +LL | fn foo(x) { //~ ERROR expected one of `:` or `@`, found `)` + | ^ expected one of `:` or `@` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/paamayim-nekudotayim.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/paamayim-nekudotayim.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/paamayim-nekudotayim.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/paamayim-nekudotayim.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// http://phpsadness.com/sad/1 + +fn main() { + ::; //~ ERROR expected identifier, found `;` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/paamayim-nekudotayim.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/paamayim-nekudotayim.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/paamayim-nekudotayim.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/paamayim-nekudotayim.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected identifier, found `;` + --> $DIR/paamayim-nekudotayim.rs:16:7 + | +LL | ::; //~ ERROR expected identifier, found `;` + | ^ expected identifier + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/paren-after-qualified-path-in-match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/paren-after-qualified-path-in-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/paren-after-qualified-path-in-match.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/paren-after-qualified-path-in-match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn foo() { + match x { + ::Type(2) => (), + //~^ ERROR unexpected `(` after qualified path + _ => (), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/paren-after-qualified-path-in-match.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/paren-after-qualified-path-in-match.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/paren-after-qualified-path-in-match.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/paren-after-qualified-path-in-match.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: unexpected `(` after qualified path + --> $DIR/paren-after-qualified-path-in-match.rs:15:27 + | +LL | ::Type(2) => (), + | ^ unexpected `(` after qualified path + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + match 42 { + x < 7 => (), + //~^ error: expected one of `=>`, `@`, `if`, or `|`, found `<` + _ => () + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-1.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `=>`, `@`, `if`, or `|`, found `<` + --> $DIR/pat-lt-bracket-1.rs:15:7 + | +LL | x < 7 => (), + | ^ expected one of `=>`, `@`, `if`, or `|` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn a(B<) {} + //~^ error: expected one of `:` or `@`, found `<` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `:` or `@`, found `<` + --> $DIR/pat-lt-bracket-2.rs:13:7 + | +LL | fn a(B<) {} + | ^ expected one of `:` or `@` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +struct Foo(T, T); + +impl Foo { + fn foo(&self) { + match *self { + Foo(x, y) => { + //~^ error: expected one of `=>`, `@`, `if`, or `|`, found `<` + println!("Goodbye, World!") + } + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-3.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-3.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-3.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-3.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `=>`, `@`, `if`, or `|`, found `<` + --> $DIR/pat-lt-bracket-3.rs:18:16 + | +LL | Foo(x, y) => { + | ^ expected one of `=>`, `@`, `if`, or `|` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-4.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-4.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-4.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +enum BtNode { + Node(u32,Box,Box), + Leaf(u32), +} + +fn main() { + let y = match x { + Foo::A(value) => value, //~ error: expected one of `=>`, `@`, `if`, or `|`, found `<` + Foo::B => 7, + }; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-4.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-4.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-4.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-4.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `=>`, `@`, `if`, or `|`, found `<` + --> $DIR/pat-lt-bracket-4.rs:20:12 + | +LL | Foo::A(value) => value, //~ error: expected one of `=>`, `@`, `if`, or `|`, found `<` + | ^ expected one of `=>`, `@`, `if`, or `|` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-5.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-5.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-5.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-5.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + let v[0] = v[1]; //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `[` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-5.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-5.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-5.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-5.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `:`, `;`, `=`, or `@`, found `[` + --> $DIR/pat-lt-bracket-5.rs:14:10 + | +LL | let v[0] = v[1]; //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `[` + | ^ expected one of `:`, `;`, `=`, or `@` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-6.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-6.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-6.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-6.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + let Test(&desc[..]) = x; //~ ERROR: expected one of `)`, `,`, or `@`, found `[` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-6.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-6.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-6.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-6.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `)`, `,`, or `@`, found `[` + --> $DIR/pat-lt-bracket-6.rs:14:19 + | +LL | let Test(&desc[..]) = x; //~ ERROR: expected one of `)`, `,`, or `@`, found `[` + | ^ expected one of `)`, `,`, or `@` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-7.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-7.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-7.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-7.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + for thing(x[]) in foo {} //~ ERROR: expected one of `)`, `,`, or `@`, found `[` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-7.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-7.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-7.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-lt-bracket-7.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `)`, `,`, or `@`, found `[` + --> $DIR/pat-lt-bracket-7.rs:14:16 + | +LL | for thing(x[]) in foo {} //~ ERROR: expected one of `)`, `,`, or `@`, found `[` + | ^ expected one of `)`, `,`, or `@` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Parsing of range patterns + +// compile-flags: -Z parse-only + +fn main() { + let macropus!() ..= 11 = 12; //~ error: expected one of `:`, `;`, or `=`, found `..=` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-1.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `:`, `;`, or `=`, found `..=` + --> $DIR/pat-ranges-1.rs:16:21 + | +LL | let macropus!() ..= 11 = 12; //~ error: expected one of `:`, `;`, or `=`, found `..=` + | ^^^ expected one of `:`, `;`, or `=` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Parsing of range patterns + +// compile-flags: -Z parse-only + +fn main() { + let 10 ..= makropulos!() = 12; //~ error: expected one of `::`, `:`, `;`, or `=`, found `!` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `::`, `:`, `;`, or `=`, found `!` + --> $DIR/pat-ranges-2.rs:16:26 + | +LL | let 10 ..= makropulos!() = 12; //~ error: expected one of `::`, `:`, `;`, or `=`, found `!` + | ^ expected one of `::`, `:`, `;`, or `=` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Parsing of range patterns + +// compile-flags: -Z parse-only + +fn main() { + let 10 ..= 10 + 3 = 12; //~ expected one of `:`, `;`, or `=`, found `+` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-3.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-3.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-3.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-3.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `:`, `;`, or `=`, found `+` + --> $DIR/pat-ranges-3.rs:16:19 + | +LL | let 10 ..= 10 + 3 = 12; //~ expected one of `:`, `;`, or `=`, found `+` + | ^ expected one of `:`, `;`, or `=` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-4.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-4.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-4.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Parsing of range patterns + +// compile-flags: -Z parse-only + +fn main() { + let 10 - 3 ..= 10 = 8; + //~^ error: expected one of `...`, `..=`, `..`, `:`, `;`, or `=`, found `-` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-4.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-4.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-4.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-ranges-4.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `...`, `..=`, `..`, `:`, `;`, or `=`, found `-` + --> $DIR/pat-ranges-4.rs:16:12 + | +LL | let 10 - 3 ..= 10 = 8; + | ^ expected one of `...`, `..=`, `..`, `:`, `;`, or `=` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-ref-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-ref-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-ref-enum.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-ref-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn matcher(x: Option) { + match x { + ref Some(i) => {} //~ ERROR expected identifier, found enum pattern + None => {} + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-ref-enum.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-ref-enum.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-ref-enum.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-ref-enum.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected identifier, found enum pattern + --> $DIR/pat-ref-enum.rs:15:11 + | +LL | ref Some(i) => {} //~ ERROR expected identifier, found enum pattern + | ^^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + match 0 { + (, ..) => {} //~ ERROR expected pattern, found `,` + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-1.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found `,` + --> $DIR/pat-tuple-1.rs:15:10 + | +LL | (, ..) => {} //~ ERROR expected pattern, found `,` + | ^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + match 0 { + (pat, ..,) => {} //~ ERROR trailing comma is not permitted after `..` + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: trailing comma is not permitted after `..` + --> $DIR/pat-tuple-2.rs:15:17 + | +LL | (pat, ..,) => {} //~ ERROR trailing comma is not permitted after `..` + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + match 0 { + (.., pat, ..) => {} //~ ERROR `..` can only be used once per tuple or tuple struct pattern + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-3.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-3.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-3.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-3.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: `..` can only be used once per tuple or tuple struct pattern + --> $DIR/pat-tuple-3.rs:15:19 + | +LL | (.., pat, ..) => {} //~ ERROR `..` can only be used once per tuple or tuple struct pattern + | ^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-4.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-4.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-4.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + match 0 { + (.. pat) => {} //~ ERROR expected one of `)` or `,`, found `pat` + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-4.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-4.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-4.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-4.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `)` or `,`, found `pat` + --> $DIR/pat-tuple-4.rs:15:13 + | +LL | (.. pat) => {} //~ ERROR expected one of `)` or `,`, found `pat` + | ^^^ expected one of `)` or `,` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-5.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-5.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-5.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-5.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + match 0 { + (pat ..) => {} //~ ERROR unexpected token: `)` + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-5.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-5.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-5.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pat-tuple-5.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: unexpected token: `)` + --> $DIR/pat-tuple-5.rs:15:14 + | +LL | (pat ..) => {} //~ ERROR unexpected token: `)` + | ^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pub-method-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pub-method-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pub-method-macro.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pub-method-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,34 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue #18317 + +// compile-flags: -Z parse-only + +mod bleh { + macro_rules! defn { + ($n:ident) => ( + fn $n (&self) -> i32 { + println!("{}", stringify!($n)); + 1 + } + ) + } + + #[derive(Copy, Clone)] + pub struct S; + + impl S { + pub defn!(f); //~ ERROR can't qualify macro invocation with `pub` + //~^ HELP try adjusting the macro to put `pub` inside the invocation + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pub-method-macro.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pub-method-macro.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/pub-method-macro.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/pub-method-macro.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: can't qualify macro invocation with `pub` + --> $DIR/pub-method-macro.rs:29:9 + | +LL | pub defn!(f); //~ ERROR can't qualify macro invocation with `pub` + | ^^^ + | + = help: try adjusting the macro to put `pub` inside the invocation + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/range-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/range-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/range-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/range-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// Test range syntax - syntax errors. + +pub fn main() { + let r = 1..2..3; + //~^ ERROR expected one of `.`, `;`, `?`, or an operator, found `..` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/range-3.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/range-3.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/range-3.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/range-3.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `.`, `;`, `?`, or an operator, found `..` + --> $DIR/range-3.rs:16:17 + | +LL | let r = 1..2..3; + | ^^ expected one of `.`, `;`, `?`, or an operator here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/range-4.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/range-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/range-4.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/range-4.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// Test range syntax - syntax errors. + +pub fn main() { + let r = ..1..2; + //~^ ERROR expected one of `.`, `;`, `?`, or an operator, found `..` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/range-4.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/range-4.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/range-4.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/range-4.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `.`, `;`, `?`, or an operator, found `..` + --> $DIR/range-4.rs:16:16 + | +LL | let r = ..1..2; + | ^^ expected one of `.`, `;`, `?`, or an operator here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/range_inclusive_dotdotdot.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/range_inclusive_dotdotdot.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/range_inclusive_dotdotdot.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/range_inclusive_dotdotdot.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +// Make sure that inclusive ranges with `...` syntax don't parse. + +use std::ops::RangeToInclusive; + +fn return_range_to() -> RangeToInclusive { + return ...1; //~ERROR unexpected token: `...` + //~^HELP use `..` for an exclusive range + //~^^HELP or `..=` for an inclusive range +} + +pub fn main() { + let x = ...0; //~ERROR unexpected token: `...` + //~^HELP use `..` for an exclusive range + //~^^HELP or `..=` for an inclusive range + + let x = 5...5; //~ERROR unexpected token: `...` + //~^HELP use `..` for an exclusive range + //~^^HELP or `..=` for an inclusive range + + for _ in 0...1 {} //~ERROR unexpected token: `...` + //~^HELP use `..` for an exclusive range + //~^^HELP or `..=` for an inclusive range +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/range_inclusive_dotdotdot.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/range_inclusive_dotdotdot.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/range_inclusive_dotdotdot.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/range_inclusive_dotdotdot.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,58 @@ +error: unexpected token: `...` + --> $DIR/range_inclusive_dotdotdot.rs:18:12 + | +LL | return ...1; //~ERROR unexpected token: `...` + | ^^^ +help: use `..` for an exclusive range + | +LL | return ..1; //~ERROR unexpected token: `...` + | ^^ +help: or `..=` for an inclusive range + | +LL | return ..=1; //~ERROR unexpected token: `...` + | ^^^ + +error: unexpected token: `...` + --> $DIR/range_inclusive_dotdotdot.rs:24:13 + | +LL | let x = ...0; //~ERROR unexpected token: `...` + | ^^^ +help: use `..` for an exclusive range + | +LL | let x = ..0; //~ERROR unexpected token: `...` + | ^^ +help: or `..=` for an inclusive range + | +LL | let x = ..=0; //~ERROR unexpected token: `...` + | ^^^ + +error: unexpected token: `...` + --> $DIR/range_inclusive_dotdotdot.rs:28:14 + | +LL | let x = 5...5; //~ERROR unexpected token: `...` + | ^^^ +help: use `..` for an exclusive range + | +LL | let x = 5..5; //~ERROR unexpected token: `...` + | ^^ +help: or `..=` for an inclusive range + | +LL | let x = 5..=5; //~ERROR unexpected token: `...` + | ^^^ + +error: unexpected token: `...` + --> $DIR/range_inclusive_dotdotdot.rs:32:15 + | +LL | for _ in 0...1 {} //~ERROR unexpected token: `...` + | ^^^ +help: use `..` for an exclusive range + | +LL | for _ in 0..1 {} //~ERROR unexpected token: `...` + | ^^ +help: or `..=` for an inclusive range + | +LL | for _ in 0..=1 {} //~ERROR unexpected token: `...` + | ^^^ + +error: aborting due to 4 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/range_inclusive.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/range_inclusive.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/range_inclusive.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/range_inclusive.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Make sure that inclusive ranges with no end point don't parse. + +// compile-flags: -Z parse-only + +pub fn main() { + for _ in 1..= {} //~ERROR inclusive range with no end + //~^HELP bounded at the end +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/range_inclusive.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/range_inclusive.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/range_inclusive.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/range_inclusive.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0586]: inclusive range with no end + --> $DIR/range_inclusive.rs:16:19 + | +LL | for _ in 1..= {} //~ERROR inclusive range with no end + | ^ + | + = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0586`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-keywords.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-keywords.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-keywords.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-keywords.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn test_if() { + r#if true { } //~ ERROR found `true` +} + +fn test_struct() { + r#struct Test; //~ ERROR found `Test` +} + +fn test_union() { + r#union Test; //~ ERROR found `Test` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-keywords.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-keywords.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-keywords.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-keywords.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `true` + --> $DIR/raw-literal-keywords.rs:14:10 + | +LL | r#if true { } //~ ERROR found `true` + | ^^^^ expected one of 8 possible tokens here + +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `Test` + --> $DIR/raw-literal-keywords.rs:18:14 + | +LL | r#struct Test; //~ ERROR found `Test` + | ^^^^ expected one of 8 possible tokens here + +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `Test` + --> $DIR/raw-literal-keywords.rs:22:13 + | +LL | r#union Test; //~ ERROR found `Test` + | ^^^^ expected one of 8 possible tokens here + +error: aborting due to 3 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-self.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-self.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-self.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn self_test(r#self: u32) { + //~^ ERROR `r#self` is not currently supported. +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-self.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-self.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-self.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-self.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: `r#self` is not currently supported. + --> $DIR/raw-literal-self.rs:13:14 + | +LL | fn self_test(r#self: u32) { + | ^^^^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-underscore.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-underscore.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-underscore.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-underscore.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn underscore_test(r#_: u32) { + //~^ ERROR `r#_` is not currently supported. +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-underscore.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-underscore.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-underscore.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw/raw-literal-underscore.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: `r#_` is not currently supported. + --> $DIR/raw-literal-underscore.rs:13:20 + | +LL | fn underscore_test(r#_: u32) { + | ^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw/raw_string.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw/raw_string.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw/raw_string.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw/raw_string.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + let x = r##"lol"#; + //~^ ERROR unterminated raw string +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw/raw_string.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw/raw_string.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw/raw_string.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw/raw_string.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: unterminated raw string + --> $DIR/raw_string.rs:14:13 + | +LL | let x = r##"lol"#; + | ^ unterminated raw string + | + = note: this raw string should be terminated with `"##` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw-byte-string-eof.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw-byte-string-eof.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw-byte-string-eof.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw-byte-string-eof.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + + +pub fn main() { + br##"a"#; //~ unterminated raw string +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw-byte-string-eof.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw-byte-string-eof.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw-byte-string-eof.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw-byte-string-eof.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: unterminated raw string + --> $DIR/raw-byte-string-eof.rs:15:6 + | +LL | br##"a"#; //~ unterminated raw string + | ^ unterminated raw string + | + = note: this raw string should be terminated with `"##` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw-byte-string-literals.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw-byte-string-literals.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw-byte-string-literals.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw-byte-string-literals.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + + +pub fn main() { + br"é"; //~ ERROR raw byte string must be ASCII + br##~"a"~##; //~ ERROR only `#` is allowed in raw string delimitation +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw-byte-string-literals.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw-byte-string-literals.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw-byte-string-literals.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw-byte-string-literals.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error: raw byte string must be ASCII: /u{e9} + --> $DIR/raw-byte-string-literals.rs:15:8 + | +LL | br"é"; //~ ERROR raw byte string must be ASCII + | ^ + +error: found invalid character; only `#` is allowed in raw string delimitation: ~ + --> $DIR/raw-byte-string-literals.rs:16:6 + | +LL | br##~"a"~##; //~ ERROR only `#` is allowed in raw string delimitation + | ^^^ + +error: aborting due to 2 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw-str-delim.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw-str-delim.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw-str-delim.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw-str-delim.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +static s: &'static str = + r#~"#"~# //~ ERROR found invalid character; only `#` is allowed in raw string delimitation +; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw-str-delim.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw-str-delim.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw-str-delim.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw-str-delim.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: found invalid character; only `#` is allowed in raw string delimitation: ~ + --> $DIR/raw-str-delim.rs:14:5 + | +LL | r#~"#"~# //~ ERROR found invalid character; only `#` is allowed in raw string delimitation + | ^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw-str-unbalanced.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw-str-unbalanced.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw-str-unbalanced.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw-str-unbalanced.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +static s: &'static str = + r#" + "## //~ ERROR expected one of `.`, `;`, `?`, or an operator, found `#` +; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw-str-unbalanced.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw-str-unbalanced.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw-str-unbalanced.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw-str-unbalanced.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `.`, `;`, `?`, or an operator, found `#` + --> $DIR/raw-str-unbalanced.rs:15:9 + | +LL | "## //~ ERROR expected one of `.`, `;`, `?`, or an operator, found `#` + | ^ expected one of `.`, `;`, `?`, or an operator here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw-str-unterminated.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw-str-unterminated.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw-str-unterminated.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw-str-unterminated.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +static s: &'static str = + r#" string literal goes on + and on + //~^^ ERROR unterminated raw string diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw-str-unterminated.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw-str-unterminated.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/raw-str-unterminated.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/raw-str-unterminated.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: unterminated raw string + --> $DIR/raw-str-unterminated.rs:14:5 + | +LL | r#" string literal goes on + | ^ unterminated raw string + | + = note: this raw string should be terminated with `"#` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/recover-enum2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/recover-enum2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/recover-enum2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/recover-enum2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +fn main() { + enum Test { + Var1, + Var2(String), + Var3 { + abc: {}, //~ ERROR: expected type, found `{` + }, + } + + // recover... + let a = 1; + enum Test2 { + Fine, + } + + enum Test3 { + StillFine { + def: i32, + }, + } + + { + // fail again + enum Test4 { + Nope(i32 {}) //~ ERROR: found `{` + //~^ ERROR: found `{` + } + } + // still recover later + let bad_syntax = _; //~ ERROR: expected expression, found reserved identifier `_` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/recover-enum2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/recover-enum2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/recover-enum2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/recover-enum2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +error: expected type, found `{` + --> $DIR/recover-enum2.rs:18:18 + | +LL | abc: {}, //~ ERROR: expected type, found `{` + | ^ + +error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `{` + --> $DIR/recover-enum2.rs:37:22 + | +LL | Nope(i32 {}) //~ ERROR: found `{` + | ^ expected one of 7 possible tokens here + +error: expected one of `!`, `&&`, `&`, `(`, `)`, `*`, `+`, `,`, `::`, `<`, `?`, `[`, `_`, `crate`, `dyn`, `extern`, `fn`, `for`, `impl`, `pub`, `unsafe`, `}`, or lifetime, found `{` + --> $DIR/recover-enum2.rs:37:22 + | +LL | Nope(i32 {}) //~ ERROR: found `{` + | ^ expected one of 23 possible tokens here + +error: expected expression, found reserved identifier `_` + --> $DIR/recover-enum2.rs:42:22 + | +LL | let bad_syntax = _; //~ ERROR: expected expression, found reserved identifier `_` + | ^ expected expression + +error: aborting due to 4 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/recover-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/recover-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/recover-enum.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/recover-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +fn main() { + enum Test { + Very + Bad //~ ERROR found `Bad` + Stuff + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/recover-enum.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/recover-enum.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/recover-enum.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/recover-enum.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: expected one of `(`, `,`, `=`, `{`, or `}`, found `Bad` + --> $DIR/recover-enum.rs:16:9 + | +LL | Very + | - expected one of `(`, `,`, `=`, `{`, or `}` here +LL | Bad //~ ERROR found `Bad` + | ^^^ unexpected token + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/recover-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/recover-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/recover-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/recover-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +fn main() { + struct Test { + Very + Bad //~ ERROR found `Bad` + Stuff + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/recover-struct.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/recover-struct.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/recover-struct.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/recover-struct.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: expected `:`, found `Bad` + --> $DIR/recover-struct.rs:16:9 + | +LL | Very + | - expected `:` +LL | Bad //~ ERROR found `Bad` + | ^^^ unexpected token + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/regions-out-of-scope-slice.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/regions-out-of-scope-slice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/regions-out-of-scope-slice.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/regions-out-of-scope-slice.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// blk region isn't supported in the front-end + +// compile-flags: -Z parse-only + +fn foo(cond: bool) { + // Here we will infer a type that uses the + // region of the if stmt then block, but in the scope: + let mut x; + + if cond { + x = &'blk [1,2,3]; //~ ERROR expected `:`, found `[` + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/regions-out-of-scope-slice.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/regions-out-of-scope-slice.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/regions-out-of-scope-slice.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/regions-out-of-scope-slice.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected `:`, found `[` + --> $DIR/regions-out-of-scope-slice.rs:21:19 + | +LL | x = &'blk [1,2,3]; //~ ERROR expected `:`, found `[` + | ^ expected `:` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-closure-lifetime.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-closure-lifetime.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-closure-lifetime.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-closure-lifetime.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +type closure = Box; +//~^ ERROR expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `/` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-closure-lifetime.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-closure-lifetime.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-closure-lifetime.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-closure-lifetime.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `/` + --> $DIR/removed-syntax-closure-lifetime.rs:13:22 + | +LL | type closure = Box; + | ^ expected one of 7 possible tokens here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-enum-newtype.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-enum-newtype.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-enum-newtype.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-enum-newtype.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +enum e = isize; //~ ERROR expected one of `<`, `where`, or `{`, found `=` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-enum-newtype.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-enum-newtype.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-enum-newtype.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-enum-newtype.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `<`, `where`, or `{`, found `=` + --> $DIR/removed-syntax-enum-newtype.rs:13:8 + | +LL | enum e = isize; //~ ERROR expected one of `<`, `where`, or `{`, found `=` + | ^ expected one of `<`, `where`, or `{` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-extern-const.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-extern-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-extern-const.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-extern-const.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +extern { + const i: isize; + //~^ ERROR extern items cannot be `const` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-extern-const.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-extern-const.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-extern-const.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-extern-const.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: extern items cannot be `const` + --> $DIR/removed-syntax-extern-const.rs:14:5 + | +LL | const i: isize; + | ^^^^^ help: try using a static value: `static` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-field-let.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-field-let.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-field-let.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-field-let.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +struct s { + let foo: (), + //~^ ERROR expected identifier, found keyword `let` + //~^^ ERROR expected `:`, found `foo` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-field-let.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-field-let.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-field-let.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-field-let.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error: expected identifier, found keyword `let` + --> $DIR/removed-syntax-field-let.rs:14:5 + | +LL | let foo: (), + | ^^^ expected identifier, found keyword + +error: expected `:`, found `foo` + --> $DIR/removed-syntax-field-let.rs:14:9 + | +LL | let foo: (), + | ^^^ expected `:` + +error: aborting due to 2 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-field-semicolon.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-field-semicolon.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-field-semicolon.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-field-semicolon.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +struct s { + bar: (); + //~^ ERROR expected `,`, or `}`, found `;` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-field-semicolon.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-field-semicolon.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-field-semicolon.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-field-semicolon.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected `,`, or `}`, found `;` + --> $DIR/removed-syntax-field-semicolon.rs:14:12 + | +LL | bar: (); + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-fixed-vec.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-fixed-vec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-fixed-vec.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-fixed-vec.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +type v = [isize * 3]; //~ ERROR expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `*` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-fixed-vec.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-fixed-vec.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-fixed-vec.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-fixed-vec.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `*` + --> $DIR/removed-syntax-fixed-vec.rs:13:17 + | +LL | type v = [isize * 3]; //~ ERROR expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `*` + | ^ expected one of 7 possible tokens here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-fn-sigil.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-fn-sigil.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-fn-sigil.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-fn-sigil.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn f() { + let x: fn~() = || (); //~ ERROR expected `(`, found `~` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-fn-sigil.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-fn-sigil.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-fn-sigil.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-fn-sigil.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: expected `(`, found `~` + --> $DIR/removed-syntax-fn-sigil.rs:14:14 + | +LL | let x: fn~() = || (); //~ ERROR expected `(`, found `~` + | - ^ expected `(` + | | + | while parsing the type for `x` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mode.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mode.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mode.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mode.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn f(+x: isize) {} //~ ERROR expected pattern, found `+` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mode.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mode.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mode.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mode.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected pattern, found `+` + --> $DIR/removed-syntax-mode.rs:13:6 + | +LL | fn f(+x: isize) {} //~ ERROR expected pattern, found `+` + | ^ expected pattern + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mut-vec-expr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mut-vec-expr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mut-vec-expr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mut-vec-expr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn f() { + let v = [mut 1, 2, 3, 4]; //~ ERROR expected expression, found keyword `mut` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mut-vec-expr.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mut-vec-expr.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mut-vec-expr.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mut-vec-expr.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected expression, found keyword `mut` + --> $DIR/removed-syntax-mut-vec-expr.rs:14:14 + | +LL | let v = [mut 1, 2, 3, 4]; //~ ERROR expected expression, found keyword `mut` + | ^^^ expected expression + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mut-vec-ty.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mut-vec-ty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mut-vec-ty.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mut-vec-ty.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +type v = [mut isize]; //~ ERROR expected type, found keyword `mut` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mut-vec-ty.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mut-vec-ty.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mut-vec-ty.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-mut-vec-ty.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected type, found keyword `mut` + --> $DIR/removed-syntax-mut-vec-ty.rs:13:11 + | +LL | type v = [mut isize]; //~ ERROR expected type, found keyword `mut` + | ^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-ptr-lifetime.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-ptr-lifetime.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-ptr-lifetime.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-ptr-lifetime.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +type bptr = &lifetime/isize; //~ ERROR expected one of `!`, `(`, `::`, `;`, or `<`, found `/` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-ptr-lifetime.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-ptr-lifetime.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-ptr-lifetime.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-ptr-lifetime.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `!`, `(`, `::`, `;`, or `<`, found `/` + --> $DIR/removed-syntax-ptr-lifetime.rs:13:22 + | +LL | type bptr = &lifetime/isize; //~ ERROR expected one of `!`, `(`, `::`, `;`, or `<`, found `/` + | ^ expected one of `!`, `(`, `::`, `;`, or `<` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-record.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-record.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-record.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-record.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +type t = { f: () }; //~ ERROR expected type, found `{` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-record.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-record.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-record.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-record.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected type, found `{` + --> $DIR/removed-syntax-record.rs:13:10 + | +LL | type t = { f: () }; //~ ERROR expected type, found `{` + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-static-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-static-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-static-fn.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-static-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only +// ignore-tidy-linelength + +struct S; + +impl S { + static fn f() {} +} +//~^^ ERROR expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-static-fn.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-static-fn.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-static-fn.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-static-fn.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `static` + --> $DIR/removed-syntax-static-fn.rs:17:5 + | +LL | impl S { + | - expected one of 11 possible tokens here +LL | static fn f() {} + | ^^^^^^ unexpected token + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-uniq-mut-expr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-uniq-mut-expr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-uniq-mut-expr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-uniq-mut-expr.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn f() { + let a_box = box mut 42; //~ ERROR expected expression, found keyword `mut` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-uniq-mut-expr.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-uniq-mut-expr.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-uniq-mut-expr.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-uniq-mut-expr.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected expression, found keyword `mut` + --> $DIR/removed-syntax-uniq-mut-expr.rs:14:21 + | +LL | let a_box = box mut 42; //~ ERROR expected expression, found keyword `mut` + | ^^^ expected expression + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-uniq-mut-ty.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-uniq-mut-ty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-uniq-mut-ty.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-uniq-mut-ty.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +type mut_box = Box; //~ ERROR expected one of `>`, lifetime, or type, found `mut` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-uniq-mut-ty.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-uniq-mut-ty.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-uniq-mut-ty.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-uniq-mut-ty.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `>`, lifetime, or type, found `mut` + --> $DIR/removed-syntax-uniq-mut-ty.rs:13:20 + | +LL | type mut_box = Box; //~ ERROR expected one of `>`, lifetime, or type, found `mut` + | ^^^ expected one of `>`, lifetime, or type here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-with-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-with-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-with-1.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-with-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn removed_with() { + struct S { + foo: (), + bar: (), + } + + let a = S { foo: (), bar: () }; + let b = S { foo: () with a }; + //~^ ERROR expected one of `,`, `.`, `?`, `}`, or an operator, found `with` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-with-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-with-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-with-1.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-with-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `,`, `.`, `?`, `}`, or an operator, found `with` + --> $DIR/removed-syntax-with-1.rs:20:25 + | +LL | let b = S { foo: () with a }; + | ^^^^ expected one of `,`, `.`, `?`, `}`, or an operator here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-with-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-with-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-with-2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-with-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn removed_with() { + struct S { + foo: (), + bar: (), + } + + let a = S { foo: (), bar: () }; + let b = S { foo: (), with a }; + //~^ ERROR expected one of `,` or `}`, found `a` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-with-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-with-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-with-2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/removed-syntax-with-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected one of `,` or `}`, found `a` + --> $DIR/removed-syntax-with-2.rs:20:31 + | +LL | let b = S { foo: (), with a }; + | ^ expected one of `,` or `}` here + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/require-parens-for-chained-comparison.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/require-parens-for-chained-comparison.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/require-parens-for-chained-comparison.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/require-parens-for-chained-comparison.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn f() {} + +fn main() { + false == false == false; + //~^ ERROR: chained comparison operators require parentheses + + false == 0 < 2; + //~^ ERROR: chained comparison operators require parentheses + + f(); + //~^ ERROR: chained comparison operators require parentheses + //~| HELP: use `::<...>` instead of `<...>` + //~| HELP: or use `(...)` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/require-parens-for-chained-comparison.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/require-parens-for-chained-comparison.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/require-parens-for-chained-comparison.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/require-parens-for-chained-comparison.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +error: chained comparison operators require parentheses + --> $DIR/require-parens-for-chained-comparison.rs:16:11 + | +LL | false == false == false; + | ^^^^^^^^^^^^^^^^^ + +error: chained comparison operators require parentheses + --> $DIR/require-parens-for-chained-comparison.rs:19:11 + | +LL | false == 0 < 2; + | ^^^^^^^^ + +error: chained comparison operators require parentheses + --> $DIR/require-parens-for-chained-comparison.rs:22:6 + | +LL | f(); + | ^^^^ + | + = help: use `::<...>` instead of `<...>` if you meant to specify type arguments + = help: or use `(...)` if you meant to specify fn arguments + +error: aborting due to 3 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-field-numeric-shorthand.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-field-numeric-shorthand.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-field-numeric-shorthand.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-field-numeric-shorthand.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +struct Rgb(u8, u8, u8); + +fn main() { + let _ = Rgb { 0, 1, 2 }; //~ ERROR expected identifier, found `0` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-field-numeric-shorthand.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-field-numeric-shorthand.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-field-numeric-shorthand.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-field-numeric-shorthand.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: expected identifier, found `0` + --> $DIR/struct-field-numeric-shorthand.rs:16:19 + | +LL | let _ = Rgb { 0, 1, 2 }; //~ ERROR expected identifier, found `0` + | --- ^ expected identifier + | | + | while parsing this struct + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-for.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-for.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-for.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-for.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +struct Foo { + x: isize, +} + +impl Foo { + fn hi(&self) -> bool { + true + } +} + +fn main() { + for x in Foo { + x: 3 //~ ERROR expected type, found `3` + }.hi() { //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + println!("yo"); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-for.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-for.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-for.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-for.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error: expected type, found `3` + --> $DIR/struct-literal-in-for.rs:25:12 + | +LL | x: 3 //~ ERROR expected type, found `3` + | ^ expecting a type here because of type ascription + +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + --> $DIR/struct-literal-in-for.rs:26:12 + | +LL | }.hi() { //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + | ^ expected one of `.`, `;`, `?`, `}`, or an operator here + +error: aborting due to 2 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-if.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-if.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-if.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-if.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +struct Foo { + x: isize, +} + +impl Foo { + fn hi(&self) -> bool { + true + } +} + +fn main() { + if Foo { + x: 3 //~ ERROR expected type, found `3` + }.hi() { //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + println!("yo"); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-if.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-if.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-if.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-if.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error: expected type, found `3` + --> $DIR/struct-literal-in-if.rs:25:12 + | +LL | x: 3 //~ ERROR expected type, found `3` + | ^ expecting a type here because of type ascription + +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + --> $DIR/struct-literal-in-if.rs:26:12 + | +LL | }.hi() { //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + | ^ expected one of `.`, `;`, `?`, `}`, or an operator here + +error: aborting due to 2 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-match-discriminant.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-match-discriminant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-match-discriminant.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-match-discriminant.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +struct Foo { + x: isize, +} + +fn main() { + match Foo { + x: 3 //~ ERROR expected one of `=>`, `@`, `if`, or `|`, found `:` + } { + Foo { + x: x + } => {} //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `=>` + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-match-discriminant.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-match-discriminant.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-match-discriminant.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-match-discriminant.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error: expected one of `=>`, `@`, `if`, or `|`, found `:` + --> $DIR/struct-literal-in-match-discriminant.rs:19:10 + | +LL | x: 3 //~ ERROR expected one of `=>`, `@`, `if`, or `|`, found `:` + | ^ expected one of `=>`, `@`, `if`, or `|` here + +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `=>` + --> $DIR/struct-literal-in-match-discriminant.rs:23:11 + | +LL | } => {} //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `=>` + | ^^ expected one of `.`, `;`, `?`, `}`, or an operator here + +error: aborting due to 2 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-while.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-while.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-while.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-while.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +struct Foo { + x: isize, +} + +impl Foo { + fn hi(&self) -> bool { + true + } +} + +fn main() { + while Foo { + x: 3 //~ ERROR expected type, found `3` + }.hi() { //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + println!("yo"); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-while.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-while.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-while.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-literal-in-while.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error: expected type, found `3` + --> $DIR/struct-literal-in-while.rs:25:12 + | +LL | x: 3 //~ ERROR expected type, found `3` + | ^ expecting a type here because of type ascription + +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + --> $DIR/struct-literal-in-while.rs:26:12 + | +LL | }.hi() { //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + | ^ expected one of `.`, `;`, `?`, `}`, or an operator here + +error: aborting due to 2 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-literal-restrictions-in-lamda.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-literal-restrictions-in-lamda.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-literal-restrictions-in-lamda.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-literal-restrictions-in-lamda.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +struct Foo { + x: isize, +} + +impl Foo { + fn hi(&self) -> bool { + true + } +} + +fn main() { + while || Foo { + x: 3 //~ ERROR expected type, found `3` + }.hi() { //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + println!("yo"); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-literal-restrictions-in-lamda.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-literal-restrictions-in-lamda.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/struct-literal-restrictions-in-lamda.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/struct-literal-restrictions-in-lamda.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error: expected type, found `3` + --> $DIR/struct-literal-restrictions-in-lamda.rs:25:12 + | +LL | x: 3 //~ ERROR expected type, found `3` + | ^ expecting a type here because of type ascription + +error: expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + --> $DIR/struct-literal-restrictions-in-lamda.rs:26:12 + | +LL | }.hi() { //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `{` + | ^ expected one of `.`, `;`, `?`, `}`, or an operator here + +error: aborting due to 2 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/tag-variant-disr-non-nullary.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/tag-variant-disr-non-nullary.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/tag-variant-disr-non-nullary.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/tag-variant-disr-non-nullary.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +//error-pattern: discriminator values can only be used with a field-less enum + +enum color { + red = 0xff0000, + green = 0x00ff00, + blue = 0x0000ff, + black = 0x000000, + white = 0xffffff, + other (str), +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/tag-variant-disr-non-nullary.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/tag-variant-disr-non-nullary.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/tag-variant-disr-non-nullary.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/tag-variant-disr-non-nullary.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: discriminator values can only be used with a field-less enum + --> $DIR/tag-variant-disr-non-nullary.rs:20:13 + | +LL | white = 0xffffff, + | ^^^^^^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trailing-carriage-return-in-string.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trailing-carriage-return-in-string.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trailing-carriage-return-in-string.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trailing-carriage-return-in-string.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// ignore-tidy-cr +// Issue #11669 + +fn main() { + // \r\n + let ok = "This is \ + a test"; + // \r only + let bad = "This is \ a test"; + //~^ ERROR unknown character escape: \r + //~^^ HELP this is an isolated carriage return + +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trailing-carriage-return-in-string.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trailing-carriage-return-in-string.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trailing-carriage-return-in-string.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trailing-carriage-return-in-string.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error: unknown character escape: /r + --> $DIR/trailing-carriage-return-in-string.rs:21:25 + | +LL | let bad = "This is / a test"; + | ^ + | +help: this is an isolated carriage return; consider checking your editor and version control settings + --> $DIR/trailing-carriage-return-in-string.rs:21:25 + | +LL | let bad = "This is / a test"; + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trailing-plus-in-bounds.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trailing-plus-in-bounds.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trailing-plus-in-bounds.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trailing-plus-in-bounds.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// compile-flags: -Z parse-only -Z continue-parse-after-error + +use std::fmt::Debug; + +fn main() { + let x: Box = box 3 as Box; // Trailing `+` is OK +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-bounds-not-on-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-bounds-not-on-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-bounds-not-on-impl.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-bounds-not-on-impl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +trait Foo { +} + +struct Bar; + +impl Foo + Owned for Bar { //~ ERROR expected a trait, found type +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-bounds-not-on-impl.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-bounds-not-on-impl.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-bounds-not-on-impl.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-bounds-not-on-impl.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected a trait, found type + --> $DIR/trait-bounds-not-on-impl.rs:18:6 + | +LL | impl Foo + Owned for Bar { //~ ERROR expected a trait, found type + | ^^^^^^^^^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-object-bad-parens.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-object-bad-parens.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-object-bad-parens.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-object-bad-parens.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +fn main() { + let _: Box<((Copy)) + Copy>; + //~^ ERROR expected a path on the left-hand side of `+`, not `((Copy))` + let _: Box<(Copy + Copy) + Copy>; + //~^ ERROR expected a path on the left-hand side of `+`, not `(Copy + Copy)` + let _: Box<(Copy +) + Copy>; + //~^ ERROR expected a path on the left-hand side of `+`, not `(Copy)` + let _: Box<(dyn Copy) + Copy>; + //~^ ERROR expected a path on the left-hand side of `+`, not `(dyn Copy)` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-object-bad-parens.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-object-bad-parens.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-object-bad-parens.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-object-bad-parens.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +error[E0178]: expected a path on the left-hand side of `+`, not `((Copy))` + --> $DIR/trait-object-bad-parens.rs:14:16 + | +LL | let _: Box<((Copy)) + Copy>; + | ^^^^^^^^^^^^^^^ expected a path + +error[E0178]: expected a path on the left-hand side of `+`, not `(Copy + Copy)` + --> $DIR/trait-object-bad-parens.rs:16:16 + | +LL | let _: Box<(Copy + Copy) + Copy>; + | ^^^^^^^^^^^^^^^^^^^^ expected a path + +error[E0178]: expected a path on the left-hand side of `+`, not `(Copy)` + --> $DIR/trait-object-bad-parens.rs:18:16 + | +LL | let _: Box<(Copy +) + Copy>; + | ^^^^^^^^^^^^^^^ expected a path + +error[E0178]: expected a path on the left-hand side of `+`, not `(dyn Copy)` + --> $DIR/trait-object-bad-parens.rs:20:16 + | +LL | let _: Box<(dyn Copy) + Copy>; + | ^^^^^^^^^^^^^^^^^ expected a path + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0178`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-object-lifetime-parens.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-object-lifetime-parens.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-object-lifetime-parens.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-object-lifetime-parens.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +fn f() {} //~ ERROR parenthesized lifetime bounds are not supported + +fn main() { + let _: Box; //~ ERROR parenthesized lifetime bounds are not supported + let _: Box<('a) + Copy>; //~ ERROR expected type, found `'a` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-object-lifetime-parens.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-object-lifetime-parens.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-object-lifetime-parens.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-object-lifetime-parens.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +error: parenthesized lifetime bounds are not supported + --> $DIR/trait-object-lifetime-parens.rs:13:19 + | +LL | fn f() {} //~ ERROR parenthesized lifetime bounds are not supported + | ^ + +error: parenthesized lifetime bounds are not supported + --> $DIR/trait-object-lifetime-parens.rs:16:26 + | +LL | let _: Box; //~ ERROR parenthesized lifetime bounds are not supported + | ^ + +error: expected type, found `'a` + --> $DIR/trait-object-lifetime-parens.rs:17:17 + | +LL | let _: Box<('a) + Copy>; //~ ERROR expected type, found `'a` + | - ^^ + | | + | while parsing the type for `_` + +error: aborting due to 3 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-object-polytrait-priority.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-object-polytrait-priority.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-object-polytrait-priority.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-object-polytrait-priority.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +trait Trait<'a> {} + +fn main() { + let _: &for<'a> Trait<'a> + 'static; + //~^ ERROR expected a path on the left-hand side of `+`, not `&for<'a> Trait<'a>` + //~| HELP try adding parentheses + //~| SUGGESTION &(for<'a> Trait<'a> + 'static) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-object-polytrait-priority.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-object-polytrait-priority.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-object-polytrait-priority.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-object-polytrait-priority.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0178]: expected a path on the left-hand side of `+`, not `&for<'a> Trait<'a>` + --> $DIR/trait-object-polytrait-priority.rs:16:12 + | +LL | let _: &for<'a> Trait<'a> + 'static; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try adding parentheses: `&(for<'a> Trait<'a> + 'static)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0178`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-object-trait-parens.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-object-trait-parens.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-object-trait-parens.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-object-trait-parens.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// compile-flags: -Z parse-only + +fn f Trait<'a>)>() {} + +fn main() { + let _: Box<(Copy) + (?Sized) + (for<'a> Trait<'a>)>; + let _: Box<(?Sized) + (for<'a> Trait<'a>) + (Copy)>; + let _: Box<(for<'a> Trait<'a>) + (Copy) + (?Sized)>; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-plusequal-splitting.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-plusequal-splitting.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-plusequal-splitting.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-plusequal-splitting.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Fixes issue where `+` in generics weren't parsed if they were part of a `+=`. + +// compile-pass +// compile-flags: -Z parse-only + +struct Whitespace { t: T } +struct TokenSplit { t: T } + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-pub-assoc-const.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-pub-assoc-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-pub-assoc-const.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-pub-assoc-const.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +trait Foo { + pub const Foo: u32; + //~^ ERROR expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-pub-assoc-const.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-pub-assoc-const.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-pub-assoc-const.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-pub-assoc-const.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `pub` + --> $DIR/trait-pub-assoc-const.rs:14:5 + | +LL | trait Foo { + | - expected one of 7 possible tokens here +LL | pub const Foo: u32; + | ^^^ unexpected token + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-pub-assoc-ty.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-pub-assoc-ty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-pub-assoc-ty.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-pub-assoc-ty.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +trait Foo { + pub type Foo; + //~^ ERROR expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-pub-assoc-ty.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-pub-assoc-ty.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-pub-assoc-ty.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-pub-assoc-ty.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `pub` + --> $DIR/trait-pub-assoc-ty.rs:14:5 + | +LL | trait Foo { + | - expected one of 7 possible tokens here +LL | pub type Foo; + | ^^^ unexpected token + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-pub-method.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-pub-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-pub-method.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-pub-method.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +trait Foo { + pub fn foo(); + //~^ ERROR expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-pub-method.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-pub-method.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/trait-pub-method.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/trait-pub-method.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: expected one of `async`, `const`, `extern`, `fn`, `type`, `unsafe`, or `}`, found `pub` + --> $DIR/trait-pub-method.rs:14:5 + | +LL | trait Foo { + | - expected one of 7 possible tokens here +LL | pub fn foo(); + | ^^^ unexpected token + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/type-parameters-in-field-exprs.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/type-parameters-in-field-exprs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/type-parameters-in-field-exprs.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/type-parameters-in-field-exprs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +struct Foo { + x: isize, + y: isize, +} + +fn main() { + let f = Foo { + x: 1, + y: 2, + }; + f.x::; + //~^ ERROR field expressions may not have generic arguments + f.x::<>; + //~^ ERROR field expressions may not have generic arguments + f.x::(); + //~^ ERROR field expressions may not have generic arguments +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/type-parameters-in-field-exprs.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/type-parameters-in-field-exprs.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/type-parameters-in-field-exprs.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/type-parameters-in-field-exprs.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +error: field expressions may not have generic arguments + --> $DIR/type-parameters-in-field-exprs.rs:23:8 + | +LL | f.x::; + | ^^^^^^^^^ + +error: field expressions may not have generic arguments + --> $DIR/type-parameters-in-field-exprs.rs:25:8 + | +LL | f.x::<>; + | ^^^^ + +error: field expressions may not have generic arguments + --> $DIR/type-parameters-in-field-exprs.rs:27:8 + | +LL | f.x::(); + | ^^^^ + +error: aborting due to 3 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/unbalanced-doublequote.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/unbalanced-doublequote.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/unbalanced-doublequote.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/unbalanced-doublequote.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + + +// error-pattern: unterminated double quote string + + +fn main() { + " +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/unbalanced-doublequote.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/unbalanced-doublequote.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/unbalanced-doublequote.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/unbalanced-doublequote.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error: unterminated double quote string + --> $DIR/unbalanced-doublequote.rs:18:5 + | +LL | / " +LL | | } + | |__^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/unclosed-braces.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/unclosed-braces.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/unclosed-braces.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/unclosed-braces.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Z parse-only + struct S { x: [usize; 3], } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/unclosed-braces.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/unclosed-braces.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/unclosed-braces.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/unclosed-braces.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error: this file contains an un-closed delimiter - --> $DIR/unclosed-braces.rs:32:53 + --> $DIR/unclosed-braces.rs:34:53 | LL | fn main() { | - un-closed delimiter diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/underscore-suffix-for-float.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/underscore-suffix-for-float.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/underscore-suffix-for-float.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/underscore-suffix-for-float.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + let a = 42._; //~ ERROR expected identifier, found reserved identifier `_` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/underscore-suffix-for-float.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/underscore-suffix-for-float.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/underscore-suffix-for-float.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/underscore-suffix-for-float.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected identifier, found reserved identifier `_` + --> $DIR/underscore-suffix-for-float.rs:14:16 + | +LL | let a = 42._; //~ ERROR expected identifier, found reserved identifier `_` + | ^ expected identifier, found reserved identifier + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/underscore-suffix-for-string.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/underscore-suffix-for-string.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/underscore-suffix-for-string.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/underscore-suffix-for-string.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// compile-flags: -Z parse-only + +fn main() { + let _ = "Foo"_; + //~^ WARNING underscore literal suffix is not allowed + //~| WARNING this was previously accepted + //~| NOTE issue #42326 +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/underscore-suffix-for-string.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/underscore-suffix-for-string.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/underscore-suffix-for-string.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/underscore-suffix-for-string.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +warning: underscore literal suffix is not allowed + --> $DIR/underscore-suffix-for-string.rs:15:18 + | +LL | let _ = "Foo"_; + | ^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #42326 + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/unicode-chars.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/unicode-chars.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/unicode-chars.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/unicode-chars.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn main() { + let y = 0; + //~^ ERROR unknown start of token: \u{37e} + //~^^ HELP Unicode character ';' (Greek Question Mark) looks like ';' (Semicolon), but it is not +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/unicode-chars.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/unicode-chars.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/unicode-chars.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/unicode-chars.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +error: unknown start of token: /u{37e} + --> $DIR/unicode-chars.rs:14:14 + | +LL | let y = 0; + | ^ +help: Unicode character ';' (Greek Question Mark) looks like ';' (Semicolon), but it is not + | +LL | let y = 0; + | ^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/unsized2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/unsized2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/unsized2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/unsized2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// Test syntax checks for `type` keyword. + +fn f() {} + +pub fn main() { + f(); //~ ERROR expected expression, found keyword `type` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/unsized2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/unsized2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/unsized2.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/unsized2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected expression, found keyword `type` + --> $DIR/unsized2.rs:18:7 + | +LL | f(); //~ ERROR expected expression, found keyword `type` + | ^^^^ expected expression + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/unsized.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/unsized.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/unsized.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/unsized.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// Test syntax checks for `type` keyword. + +struct S1 for type; //~ ERROR expected `where`, `{`, `(`, or `;` after struct name, found `for` + +pub fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/unsized.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/unsized.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/unsized.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/unsized.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected `where`, `{`, `(`, or `;` after struct name, found `for` + --> $DIR/unsized.rs:15:11 + | +LL | struct S1 for type; //~ ERROR expected `where`, `{`, `(`, or `;` after struct name, found `for` + | ^^^ expected `where`, `{`, `(`, or `;` after struct name + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/use-as-where-use-ends-with-mod-sep.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/use-as-where-use-ends-with-mod-sep.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/use-as-where-use-ends-with-mod-sep.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/use-as-where-use-ends-with-mod-sep.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +use std::any:: as foo; //~ ERROR expected identifier, found keyword `as` +//~^ ERROR: expected one of `::`, `;`, or `as`, found `foo` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/use-as-where-use-ends-with-mod-sep.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/use-as-where-use-ends-with-mod-sep.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/use-as-where-use-ends-with-mod-sep.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/use-as-where-use-ends-with-mod-sep.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error: expected identifier, found keyword `as` + --> $DIR/use-as-where-use-ends-with-mod-sep.rs:13:16 + | +LL | use std::any:: as foo; //~ ERROR expected identifier, found keyword `as` + | ^^ expected identifier, found keyword + +error: expected one of `::`, `;`, or `as`, found `foo` + --> $DIR/use-as-where-use-ends-with-mod-sep.rs:13:19 + | +LL | use std::any:: as foo; //~ ERROR expected identifier, found keyword `as` + | ^^^ expected one of `::`, `;`, or `as` here + +error: aborting due to 2 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/use-ends-with-mod-sep.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/use-ends-with-mod-sep.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/use-ends-with-mod-sep.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/use-ends-with-mod-sep.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +use std::any::; //~ ERROR expected identifier, found `;` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/use-ends-with-mod-sep.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/use-ends-with-mod-sep.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/use-ends-with-mod-sep.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/use-ends-with-mod-sep.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected identifier, found `;` + --> $DIR/use-ends-with-mod-sep.rs:13:15 + | +LL | use std::any::; //~ ERROR expected identifier, found `;` + | ^ expected identifier + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/variadic-ffi-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/variadic-ffi-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/variadic-ffi-3.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/variadic-ffi-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn foo(x: isize, ...) { + //~^ ERROR: only foreign functions are allowed to be variadic +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/variadic-ffi-3.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/variadic-ffi-3.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/variadic-ffi-3.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/variadic-ffi-3.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: only foreign functions are allowed to be variadic + --> $DIR/variadic-ffi-3.rs:13:18 + | +LL | fn foo(x: isize, ...) { + | ^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/variadic-ffi-4.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/variadic-ffi-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/variadic-ffi-4.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/variadic-ffi-4.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +extern "C" fn foo(x: isize, ...) { + //~^ ERROR: only foreign functions are allowed to be variadic +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/variadic-ffi-4.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/variadic-ffi-4.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/variadic-ffi-4.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/variadic-ffi-4.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: only foreign functions are allowed to be variadic + --> $DIR/variadic-ffi-4.rs:13:29 + | +LL | extern "C" fn foo(x: isize, ...) { + | ^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/virtual-structs.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/virtual-structs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/virtual-structs.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/virtual-structs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +// Test diagnostics for the removed struct inheritance feature. + +virtual struct SuperStruct { //~ ERROR expected item, found `virtual` + f1: isize, +} + +struct Struct : SuperStruct; + +pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/virtual-structs.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/virtual-structs.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/virtual-structs.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/virtual-structs.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected item, found `virtual` + --> $DIR/virtual-structs.rs:15:1 + | +LL | virtual struct SuperStruct { //~ ERROR expected item, found `virtual` + | ^^^^^^^ expected item + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/where-clauses-no-bounds-or-predicates.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/where-clauses-no-bounds-or-predicates.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/where-clauses-no-bounds-or-predicates.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/where-clauses-no-bounds-or-predicates.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only -Z continue-parse-after-error + +// Empty predicate list is OK +fn equal1(_: &T, _: &T) -> bool where { + true +} + +// Empty bound list is OK +fn equal2(_: &T, _: &T) -> bool where T: { + true +} + +fn foo<'a>() where 'a {} +//~^ ERROR expected `:`, found `{` + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/where-clauses-no-bounds-or-predicates.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/where-clauses-no-bounds-or-predicates.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/where-clauses-no-bounds-or-predicates.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/where-clauses-no-bounds-or-predicates.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: expected `:`, found `{` + --> $DIR/where-clauses-no-bounds-or-predicates.rs:23:23 + | +LL | fn foo<'a>() where 'a {} + | ^ expected `:` + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/where_with_bound.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/where_with_bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/where_with_bound.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/where_with_bound.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn foo() where ::Item: ToString, T: Iterator { } +//~^ ERROR generic parameters on `where` clauses are reserved for future use + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/where_with_bound.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/where_with_bound.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/where_with_bound.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/where_with_bound.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +error: generic parameters on `where` clauses are reserved for future use + --> $DIR/where_with_bound.rs:13:19 + | +LL | fn foo() where ::Item: ToString, T: Iterator { } + | ^^^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/wrong-escape-of-curly-braces.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/wrong-escape-of-curly-braces.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/wrong-escape-of-curly-braces.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/wrong-escape-of-curly-braces.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn f() { + let ok = "{{everything fine}}"; + let bad = "\{it is wrong\}"; + //~^ ERROR unknown character escape: { + //~^^ HELP if used in a formatting string, curly braces are escaped with `{{` and `}}` + //~^^^ ERROR unknown character escape: } + //~^^^^ HELP if used in a formatting string, curly braces are escaped with `{{` and `}}` +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/wrong-escape-of-curly-braces.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/wrong-escape-of-curly-braces.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/parser/wrong-escape-of-curly-braces.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/parser/wrong-escape-of-curly-braces.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,26 @@ +error: unknown character escape: { + --> $DIR/wrong-escape-of-curly-braces.rs:15:17 + | +LL | let bad = "/{it is wrong/}"; + | ^ + | +help: if used in a formatting string, curly braces are escaped with `{{` and `}}` + --> $DIR/wrong-escape-of-curly-braces.rs:15:17 + | +LL | let bad = "/{it is wrong/}"; + | ^ + +error: unknown character escape: } + --> $DIR/wrong-escape-of-curly-braces.rs:15:30 + | +LL | let bad = "/{it is wrong/}"; + | ^ + | +help: if used in a formatting string, curly braces are escaped with `{{` and `}}` + --> $DIR/wrong-escape-of-curly-braces.rs:15:30 + | +LL | let bad = "/{it is wrong/}"; + | ^ + +error: aborting due to 2 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/pattern/pat-shadow-in-nested-binding.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/pattern/pat-shadow-in-nested-binding.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/pattern/pat-shadow-in-nested-binding.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/pattern/pat-shadow-in-nested-binding.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/pat-shadow-in-nested-binding.rs:14:10 | LL | struct foo(usize); - | ------------------ a tuple struct `foo` is defined here + | ------------------ the tuple struct `foo` is defined here ... LL | let (foo, _) = (2, 3); //~ ERROR let bindings cannot shadow tuple structs | ^^^ cannot be named the same as a tuple struct diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/pattern/pattern-binding-disambiguation.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/pattern/pattern-binding-disambiguation.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/pattern/pattern-binding-disambiguation.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/pattern/pattern-binding-disambiguation.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/pattern-binding-disambiguation.rs:34:9 | LL | struct TupleStruct(); - | --------------------- a tuple struct `TupleStruct` is defined here + | --------------------- the tuple struct `TupleStruct` is defined here ... LL | TupleStruct => {} //~ ERROR match bindings cannot shadow tuple structs | ^^^^^^^^^^^ cannot be named the same as a tuple struct @@ -11,7 +11,7 @@ --> $DIR/pattern-binding-disambiguation.rs:43:9 | LL | use E::*; - | ---- a tuple variant `TupleVariant` is imported here + | ---- the tuple variant `TupleVariant` is imported here ... LL | TupleVariant => {} //~ ERROR match bindings cannot shadow tuple variants | ^^^^^^^^^^^^ cannot be named the same as a tuple variant @@ -20,7 +20,7 @@ --> $DIR/pattern-binding-disambiguation.rs:46:9 | LL | use E::*; - | ---- a struct variant `BracedVariant` is imported here + | ---- the struct variant `BracedVariant` is imported here ... LL | BracedVariant => {} //~ ERROR match bindings cannot shadow struct variants | ^^^^^^^^^^^^^ cannot be named the same as a struct variant @@ -29,7 +29,7 @@ --> $DIR/pattern-binding-disambiguation.rs:52:9 | LL | static STATIC: () = (); - | ----------------------- a static `STATIC` is defined here + | ----------------------- the static `STATIC` is defined here ... LL | STATIC => {} //~ ERROR match bindings cannot shadow statics | ^^^^^^ cannot be named the same as a static @@ -38,7 +38,7 @@ --> $DIR/pattern-binding-disambiguation.rs:59:9 | LL | struct TupleStruct(); - | --------------------- a tuple struct `TupleStruct` is defined here + | --------------------- the tuple struct `TupleStruct` is defined here ... LL | let TupleStruct = doesnt_matter; //~ ERROR let bindings cannot shadow tuple structs | ^^^^^^^^^^^ cannot be named the same as a tuple struct @@ -47,7 +47,7 @@ --> $DIR/pattern-binding-disambiguation.rs:62:9 | LL | use E::*; - | ---- a tuple variant `TupleVariant` is imported here + | ---- the tuple variant `TupleVariant` is imported here ... LL | let TupleVariant = doesnt_matter; //~ ERROR let bindings cannot shadow tuple variants | ^^^^^^^^^^^^ cannot be named the same as a tuple variant @@ -56,7 +56,7 @@ --> $DIR/pattern-binding-disambiguation.rs:63:9 | LL | use E::*; - | ---- a struct variant `BracedVariant` is imported here + | ---- the struct variant `BracedVariant` is imported here ... LL | let BracedVariant = doesnt_matter; //~ ERROR let bindings cannot shadow struct variants | ^^^^^^^^^^^^^ cannot be named the same as a struct variant @@ -65,7 +65,7 @@ --> $DIR/pattern-binding-disambiguation.rs:65:9 | LL | static STATIC: () = (); - | ----------------------- a static `STATIC` is defined here + | ----------------------- the static `STATIC` is defined here ... LL | let STATIC = doesnt_matter; //~ ERROR let bindings cannot shadow statics | ^^^^^^ cannot be named the same as a static diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/pattern/pattern-error-continue.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/pattern/pattern-error-continue.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/pattern/pattern-error-continue.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/pattern/pattern-error-continue.rs 2018-12-04 23:41:40.000000000 +0000 @@ -42,6 +42,6 @@ //~| expected char, found bool match () { - E::V => {} //~ ERROR failed to resolve. Use of undeclared type or module `E` + E::V => {} //~ ERROR failed to resolve: use of undeclared type or module `E` } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/pattern/pattern-error-continue.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/pattern/pattern-error-continue.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/pattern/pattern-error-continue.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/pattern/pattern-error-continue.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ -error[E0433]: failed to resolve. Use of undeclared type or module `E` +error[E0433]: failed to resolve: use of undeclared type or module `E` --> $DIR/pattern-error-continue.rs:45:9 | -LL | E::V => {} //~ ERROR failed to resolve. Use of undeclared type or module `E` - | ^ Use of undeclared type or module `E` +LL | E::V => {} //~ ERROR failed to resolve: use of undeclared type or module `E` + | ^ use of undeclared type or module `E` error[E0532]: expected tuple struct/variant, found unit variant `A::D` --> $DIR/pattern-error-continue.rs:28:9 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/decl-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/decl-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/decl-macro.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/decl-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +#![feature(decl_macro)] + +mod m { + macro mac() {} +} + +fn main() { + m::mac!(); //~ ERROR macro `mac` is private +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/decl-macro.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/decl-macro.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/decl-macro.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/decl-macro.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0603]: macro `mac` is private + --> $DIR/decl-macro.rs:8:8 + | +LL | m::mac!(); //~ ERROR macro `mac` is private + | ^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0603`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/privacy1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/privacy1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/privacy1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/privacy1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -127,7 +127,6 @@ fn test2() { use bar::baz::{foo, bar}; //~^ ERROR: module `baz` is private - //~| ERROR: module `baz` is private foo(); bar(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/privacy1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/privacy1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/privacy1.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/privacy1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,80 +1,74 @@ error[E0603]: module `baz` is private - --> $DIR/privacy1.rs:128:24 + --> $DIR/privacy1.rs:128:18 | LL | use bar::baz::{foo, bar}; - | ^^^ + | ^^^ error[E0603]: module `baz` is private - --> $DIR/privacy1.rs:128:29 - | -LL | use bar::baz::{foo, bar}; - | ^^^ - -error[E0603]: module `baz` is private - --> $DIR/privacy1.rs:137:13 + --> $DIR/privacy1.rs:136:18 | LL | use bar::baz; - | ^^^^^^^^ + | ^^^ error[E0603]: module `i` is private - --> $DIR/privacy1.rs:161:9 + --> $DIR/privacy1.rs:160:20 | LL | use self::foo::i::A; //~ ERROR: module `i` is private - | ^^^^^^^^^^^^^^^ + | ^ error[E0603]: module `baz` is private - --> $DIR/privacy1.rs:100:9 + --> $DIR/privacy1.rs:100:16 | LL | ::bar::baz::A::foo(); //~ ERROR: module `baz` is private - | ^^^^^^^^^^^^^^^^^^ + | ^^^ error[E0603]: module `baz` is private - --> $DIR/privacy1.rs:101:9 + --> $DIR/privacy1.rs:101:16 | LL | ::bar::baz::A::bar(); //~ ERROR: module `baz` is private - | ^^^^^^^^^^^^^^^^^^ + | ^^^ error[E0603]: module `baz` is private - --> $DIR/privacy1.rs:103:9 + --> $DIR/privacy1.rs:103:16 | LL | ::bar::baz::A.foo2(); //~ ERROR: module `baz` is private - | ^^^^^^^^^^^^^ + | ^^^ error[E0603]: module `baz` is private - --> $DIR/privacy1.rs:104:9 + --> $DIR/privacy1.rs:104:16 | LL | ::bar::baz::A.bar2(); //~ ERROR: module `baz` is private - | ^^^^^^^^^^^^^ + | ^^^ error[E0603]: trait `B` is private - --> $DIR/privacy1.rs:108:9 + --> $DIR/privacy1.rs:108:16 | LL | ::bar::B::foo(); //~ ERROR: trait `B` is private - | ^^^^^^^^^^^^^ + | ^ error[E0603]: function `epriv` is private - --> $DIR/privacy1.rs:114:13 + --> $DIR/privacy1.rs:114:20 | LL | ::bar::epriv(); //~ ERROR: function `epriv` is private - | ^^^^^^^^^^^^ + | ^^^^^ error[E0603]: module `baz` is private - --> $DIR/privacy1.rs:123:9 + --> $DIR/privacy1.rs:123:16 | LL | ::bar::baz::foo(); //~ ERROR: module `baz` is private - | ^^^^^^^^^^^^^^^ + | ^^^ error[E0603]: module `baz` is private - --> $DIR/privacy1.rs:124:9 + --> $DIR/privacy1.rs:124:16 | LL | ::bar::baz::bar(); //~ ERROR: module `baz` is private - | ^^^^^^^^^^^^^^^ + | ^^^ error[E0603]: trait `B` is private - --> $DIR/privacy1.rs:153:10 + --> $DIR/privacy1.rs:152:17 | LL | impl ::bar::B for f32 { fn foo() -> f32 { 1.0 } } - | ^^^^^^^^ + | ^ error[E0624]: method `bar` is private --> $DIR/privacy1.rs:73:9 @@ -106,7 +100,7 @@ LL | ::bar::baz::A.bar2(); //~ ERROR: module `baz` is private | ^^^^ -error: aborting due to 18 previous errors +error: aborting due to 17 previous errors Some errors occurred: E0603, E0624. For more information about an error, try `rustc --explain E0603`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/privacy2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/privacy2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/privacy2.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/privacy2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -5,10 +5,10 @@ | ^^^^^^^^ no `foo` in `bar` error[E0603]: function `foo` is private - --> $DIR/privacy2.rs:33:9 + --> $DIR/privacy2.rs:33:20 | LL | use bar::glob::foo; - | ^^^^^^^^^^^^^^ + | ^^^ error: requires `sized` lang_item diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/privacy4.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/privacy4.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/privacy4.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/privacy4.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ error[E0603]: module `glob` is private - --> $DIR/privacy4.rs:31:9 + --> $DIR/privacy4.rs:31:14 | LL | use bar::glob::gpriv; //~ ERROR: module `glob` is private - | ^^^^^^^^^^^^^^^^ + | ^^^^ error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/privacy5.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/privacy5.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/privacy5.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/privacy5.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,290 +1,290 @@ error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:61:13 + --> $DIR/privacy5.rs:61:16 | LL | let a = a::A(()); //~ ERROR tuple struct `A` is private - | ^^^^ + | ^ error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:62:13 + --> $DIR/privacy5.rs:62:16 | LL | let b = a::B(2); //~ ERROR tuple struct `B` is private - | ^^^^ + | ^ error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:63:13 + --> $DIR/privacy5.rs:63:16 | LL | let c = a::C(2, 3); //~ ERROR tuple struct `C` is private - | ^^^^ + | ^ error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:66:9 + --> $DIR/privacy5.rs:66:12 | LL | let a::A(()) = a; //~ ERROR tuple struct `A` is private - | ^^^^ + | ^ error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:67:9 + --> $DIR/privacy5.rs:67:12 | LL | let a::A(_) = a; //~ ERROR tuple struct `A` is private - | ^^^^ + | ^ error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:68:15 + --> $DIR/privacy5.rs:68:18 | LL | match a { a::A(()) => {} } //~ ERROR tuple struct `A` is private - | ^^^^ + | ^ error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:69:15 + --> $DIR/privacy5.rs:69:18 | LL | match a { a::A(_) => {} } //~ ERROR tuple struct `A` is private - | ^^^^ + | ^ error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:71:9 + --> $DIR/privacy5.rs:71:12 | LL | let a::B(_) = b; //~ ERROR tuple struct `B` is private - | ^^^^ + | ^ error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:72:9 + --> $DIR/privacy5.rs:72:12 | LL | let a::B(_b) = b; //~ ERROR tuple struct `B` is private - | ^^^^ + | ^ error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:73:15 + --> $DIR/privacy5.rs:73:18 | LL | match b { a::B(_) => {} } //~ ERROR tuple struct `B` is private - | ^^^^ + | ^ error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:74:15 + --> $DIR/privacy5.rs:74:18 | LL | match b { a::B(_b) => {} } //~ ERROR tuple struct `B` is private - | ^^^^ + | ^ error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:75:15 + --> $DIR/privacy5.rs:75:18 | LL | match b { a::B(1) => {} a::B(_) => {} } //~ ERROR tuple struct `B` is private - | ^^^^ + | ^ error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:75:29 + --> $DIR/privacy5.rs:75:32 | LL | match b { a::B(1) => {} a::B(_) => {} } //~ ERROR tuple struct `B` is private - | ^^^^ + | ^ error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:78:9 + --> $DIR/privacy5.rs:78:12 | LL | let a::C(_, _) = c; //~ ERROR tuple struct `C` is private - | ^^^^ + | ^ error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:79:9 + --> $DIR/privacy5.rs:79:12 | LL | let a::C(_a, _) = c; //~ ERROR tuple struct `C` is private - | ^^^^ + | ^ error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:80:9 + --> $DIR/privacy5.rs:80:12 | LL | let a::C(_, _b) = c; //~ ERROR tuple struct `C` is private - | ^^^^ + | ^ error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:81:9 + --> $DIR/privacy5.rs:81:12 | LL | let a::C(_a, _b) = c; //~ ERROR tuple struct `C` is private - | ^^^^ + | ^ error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:82:15 + --> $DIR/privacy5.rs:82:18 | LL | match c { a::C(_, _) => {} } //~ ERROR tuple struct `C` is private - | ^^^^ + | ^ error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:83:15 + --> $DIR/privacy5.rs:83:18 | LL | match c { a::C(_a, _) => {} } //~ ERROR tuple struct `C` is private - | ^^^^ + | ^ error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:84:15 + --> $DIR/privacy5.rs:84:18 | LL | match c { a::C(_, _b) => {} } //~ ERROR tuple struct `C` is private - | ^^^^ + | ^ error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:85:15 + --> $DIR/privacy5.rs:85:18 | LL | match c { a::C(_a, _b) => {} } //~ ERROR tuple struct `C` is private - | ^^^^ + | ^ error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:93:14 + --> $DIR/privacy5.rs:93:17 | LL | let a2 = a::A; //~ ERROR tuple struct `A` is private - | ^^^^ + | ^ error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:94:14 + --> $DIR/privacy5.rs:94:17 | LL | let b2 = a::B; //~ ERROR tuple struct `B` is private - | ^^^^ + | ^ error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:95:14 + --> $DIR/privacy5.rs:95:17 | LL | let c2 = a::C; //~ ERROR tuple struct `C` is private - | ^^^^ + | ^ error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:100:13 + --> $DIR/privacy5.rs:100:20 | LL | let a = other::A(()); //~ ERROR tuple struct `A` is private - | ^^^^^^^^ + | ^ error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:101:13 + --> $DIR/privacy5.rs:101:20 | LL | let b = other::B(2); //~ ERROR tuple struct `B` is private - | ^^^^^^^^ + | ^ error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:102:13 + --> $DIR/privacy5.rs:102:20 | LL | let c = other::C(2, 3); //~ ERROR tuple struct `C` is private - | ^^^^^^^^ + | ^ error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:105:9 + --> $DIR/privacy5.rs:105:16 | LL | let other::A(()) = a; //~ ERROR tuple struct `A` is private - | ^^^^^^^^ + | ^ error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:106:9 + --> $DIR/privacy5.rs:106:16 | LL | let other::A(_) = a; //~ ERROR tuple struct `A` is private - | ^^^^^^^^ + | ^ error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:107:15 + --> $DIR/privacy5.rs:107:22 | LL | match a { other::A(()) => {} } //~ ERROR tuple struct `A` is private - | ^^^^^^^^ + | ^ error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:108:15 + --> $DIR/privacy5.rs:108:22 | LL | match a { other::A(_) => {} } //~ ERROR tuple struct `A` is private - | ^^^^^^^^ + | ^ error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:110:9 + --> $DIR/privacy5.rs:110:16 | LL | let other::B(_) = b; //~ ERROR tuple struct `B` is private - | ^^^^^^^^ + | ^ error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:111:9 + --> $DIR/privacy5.rs:111:16 | LL | let other::B(_b) = b; //~ ERROR tuple struct `B` is private - | ^^^^^^^^ + | ^ error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:112:15 + --> $DIR/privacy5.rs:112:22 | LL | match b { other::B(_) => {} } //~ ERROR tuple struct `B` is private - | ^^^^^^^^ + | ^ error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:113:15 + --> $DIR/privacy5.rs:113:22 | LL | match b { other::B(_b) => {} } //~ ERROR tuple struct `B` is private - | ^^^^^^^^ + | ^ error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:114:15 + --> $DIR/privacy5.rs:114:22 | LL | match b { other::B(1) => {} other::B(_) => {} } //~ ERROR tuple struct `B` is private - | ^^^^^^^^ + | ^ error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:114:33 + --> $DIR/privacy5.rs:114:40 | LL | match b { other::B(1) => {} other::B(_) => {} } //~ ERROR tuple struct `B` is private - | ^^^^^^^^ + | ^ error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:117:9 + --> $DIR/privacy5.rs:117:16 | LL | let other::C(_, _) = c; //~ ERROR tuple struct `C` is private - | ^^^^^^^^ + | ^ error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:118:9 + --> $DIR/privacy5.rs:118:16 | LL | let other::C(_a, _) = c; //~ ERROR tuple struct `C` is private - | ^^^^^^^^ + | ^ error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:119:9 + --> $DIR/privacy5.rs:119:16 | LL | let other::C(_, _b) = c; //~ ERROR tuple struct `C` is private - | ^^^^^^^^ + | ^ error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:120:9 + --> $DIR/privacy5.rs:120:16 | LL | let other::C(_a, _b) = c; //~ ERROR tuple struct `C` is private - | ^^^^^^^^ + | ^ error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:121:15 + --> $DIR/privacy5.rs:121:22 | LL | match c { other::C(_, _) => {} } //~ ERROR tuple struct `C` is private - | ^^^^^^^^ + | ^ error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:122:15 + --> $DIR/privacy5.rs:122:22 | LL | match c { other::C(_a, _) => {} } //~ ERROR tuple struct `C` is private - | ^^^^^^^^ + | ^ error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:123:15 + --> $DIR/privacy5.rs:123:22 | LL | match c { other::C(_, _b) => {} } //~ ERROR tuple struct `C` is private - | ^^^^^^^^ + | ^ error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:124:15 + --> $DIR/privacy5.rs:124:22 | LL | match c { other::C(_a, _b) => {} } //~ ERROR tuple struct `C` is private - | ^^^^^^^^ + | ^ error[E0603]: tuple struct `A` is private - --> $DIR/privacy5.rs:132:14 + --> $DIR/privacy5.rs:132:21 | LL | let a2 = other::A; //~ ERROR tuple struct `A` is private - | ^^^^^^^^ + | ^ error[E0603]: tuple struct `B` is private - --> $DIR/privacy5.rs:133:14 + --> $DIR/privacy5.rs:133:21 | LL | let b2 = other::B; //~ ERROR tuple struct `B` is private - | ^^^^^^^^ + | ^ error[E0603]: tuple struct `C` is private - --> $DIR/privacy5.rs:134:14 + --> $DIR/privacy5.rs:134:21 | LL | let c2 = other::C; //~ ERROR tuple struct `C` is private - | ^^^^^^^^ + | ^ error: aborting due to 48 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/privacy-in-paths.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/privacy-in-paths.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/privacy-in-paths.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/privacy-in-paths.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,20 +1,20 @@ error[E0603]: module `bar` is private - --> $DIR/privacy-in-paths.rs:34:9 + --> $DIR/privacy-in-paths.rs:34:16 | LL | ::foo::bar::baz::f(); //~ERROR module `bar` is private - | ^^^^^^^^^^^^^^^^^^ + | ^^^ error[E0603]: module `bar` is private - --> $DIR/privacy-in-paths.rs:35:9 + --> $DIR/privacy-in-paths.rs:35:16 | LL | ::foo::bar::S::f(); //~ERROR module `bar` is private - | ^^^^^^^^^^^^^^^^ + | ^^^ error[E0603]: trait `T` is private - --> $DIR/privacy-in-paths.rs:36:9 + --> $DIR/privacy-in-paths.rs:36:23 | LL | <() as ::foo::T>::Assoc::f(); //~ERROR trait `T` is private - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/privacy-ns2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/privacy-ns2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/privacy-ns2.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/privacy-ns2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -55,16 +55,16 @@ | error[E0603]: trait `Bar` is private - --> $DIR/privacy-ns2.rs:70:9 + --> $DIR/privacy-ns2.rs:70:15 | LL | use foo3::Bar; //~ ERROR `Bar` is private - | ^^^^^^^^^ + | ^^^ error[E0603]: trait `Bar` is private - --> $DIR/privacy-ns2.rs:74:9 + --> $DIR/privacy-ns2.rs:74:15 | LL | use foo3::Bar; //~ ERROR `Bar` is private - | ^^^^^^^^^ + | ^^^ error[E0603]: trait `Bar` is private --> $DIR/privacy-ns2.rs:81:16 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/privacy-ufcs.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/privacy-ufcs.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/privacy-ufcs.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/privacy-ufcs.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ error[E0603]: trait `Bar` is private - --> $DIR/privacy-ufcs.rs:22:5 + --> $DIR/privacy-ufcs.rs:22:20 | LL | ::baz(); //~ERROR trait `Bar` is private - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/private-item-simple.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/private-item-simple.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/private-item-simple.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/private-item-simple.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ error[E0603]: function `f` is private - --> $DIR/private-item-simple.rs:16:5 + --> $DIR/private-item-simple.rs:16:8 | LL | a::f(); //~ ERROR function `f` is private - | ^^^^ + | ^ error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/private-type-in-interface.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/private-type-in-interface.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/private-type-in-interface.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/private-type-in-interface.rs 2018-12-04 23:41:40.000000000 +0000 @@ -35,8 +35,6 @@ trait Tr2 {} impl Tr2 for u8 {} fn g() -> impl Tr2 { 0 } //~ ERROR type `m::Priv` is private -//~^ ERROR type `m::Priv` is private fn g_ext() -> impl Tr2 { 0 } //~ ERROR type `ext::Priv` is private -//~^ ERROR type `ext::Priv` is private fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/private-type-in-interface.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/private-type-in-interface.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/private-type-in-interface.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/private-type-in-interface.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -46,23 +46,11 @@ LL | fn g() -> impl Tr2 { 0 } //~ ERROR type `m::Priv` is private | ^^^^^^^^^^^^^^^^^^ -error: type `m::Priv` is private - --> $DIR/private-type-in-interface.rs:37:16 - | -LL | fn g() -> impl Tr2 { 0 } //~ ERROR type `m::Priv` is private - | ^^^^^^^^^^^^^ - error: type `ext::Priv` is private - --> $DIR/private-type-in-interface.rs:39:15 + --> $DIR/private-type-in-interface.rs:38:15 | LL | fn g_ext() -> impl Tr2 { 0 } //~ ERROR type `ext::Priv` is private | ^^^^^^^^^^^^^^^^^^^^ -error: type `ext::Priv` is private - --> $DIR/private-type-in-interface.rs:39:20 - | -LL | fn g_ext() -> impl Tr2 { 0 } //~ ERROR type `ext::Priv` is private - | ^^^^^^^^^^^^^^^ - -error: aborting due to 11 previous errors +error: aborting due to 9 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/restricted/relative-2018.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/restricted/relative-2018.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/restricted/relative-2018.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/restricted/relative-2018.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// edition:2018 + +mod m { + pub(in crate) struct S1; // OK + pub(in super) struct S2; // OK + pub(in self) struct S3; // OK + pub(in ::core) struct S4; + //~^ ERROR visibilities can only be restricted to ancestor modules + pub(in a::b) struct S5; + //~^ ERROR relative paths are not supported in visibilities on 2018 edition +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/restricted/relative-2018.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/restricted/relative-2018.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/restricted/relative-2018.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/restricted/relative-2018.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +error: visibilities can only be restricted to ancestor modules + --> $DIR/relative-2018.rs:7:12 + | +LL | pub(in ::core) struct S4; + | ^^^^^^ + +error: relative paths are not supported in visibilities on 2018 edition + --> $DIR/relative-2018.rs:9:12 + | +LL | pub(in a::b) struct S5; + | ^--- + | | + | help: try: `crate::a::b` + +error: aborting due to 2 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/restricted/test.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/restricted/test.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/restricted/test.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/restricted/test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -57,6 +57,6 @@ } mod pathological { - pub(in bad::path) mod m1 {} //~ ERROR failed to resolve. Maybe a missing `extern crate bad;`? + pub(in bad::path) mod m1 {} //~ ERROR failed to resolve: maybe a missing `extern crate bad;`? pub(in foo) mod m2 {} //~ ERROR visibilities can only be restricted to ancestor modules } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/restricted/test.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/restricted/test.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/privacy/restricted/test.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/privacy/restricted/test.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ -error[E0433]: failed to resolve. Maybe a missing `extern crate bad;`? +error[E0433]: failed to resolve: maybe a missing `extern crate bad;`? --> $DIR/test.rs:60:12 | -LL | pub(in bad::path) mod m1 {} //~ ERROR failed to resolve. Maybe a missing `extern crate bad;`? - | ^^^ Maybe a missing `extern crate bad;`? +LL | pub(in bad::path) mod m1 {} //~ ERROR failed to resolve: maybe a missing `extern crate bad;`? + | ^^^ maybe a missing `extern crate bad;`? error: visibilities can only be restricted to ancestor modules --> $DIR/test.rs:61:12 @@ -23,16 +23,16 @@ | ^^^^^^^^^^^^^^^^ error[E0603]: struct `Crate` is private - --> $DIR/test.rs:48:9 + --> $DIR/test.rs:48:25 | LL | use pub_restricted::Crate; //~ ERROR private - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ error[E0603]: function `f` is private - --> $DIR/test.rs:40:9 + --> $DIR/test.rs:40:19 | LL | use foo::bar::f; //~ ERROR private - | ^^^^^^^^^^^ + | ^ error[E0616]: field `x` of struct `foo::bar::S` is private --> $DIR/test.rs:41:5 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/qualified/qualified-path-params-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/qualified/qualified-path-params-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/qualified/qualified-path-params-2.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/qualified/qualified-path-params-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,9 +8,7 @@ --> $DIR/qualified-path-params-2.rs:28:10 | LL | type A = ::A::f; - | ^^^^^^^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<::A as Trait>::f` + | ^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<::A as Trait>::f` error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/range/issue-54505.fixed rustc-1.31.0+dfsg1+llvm/src/test/ui/range/issue-54505.fixed --- rustc-1.30.0+dfsg1+llvm/src/test/ui/range/issue-54505.fixed 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/range/issue-54505.fixed 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// run-rustfix + +// Regression test for #54505 - range borrowing suggestion had +// incorrect syntax (missing parentheses). + +use std::ops::RangeBounds; + + +// take a reference to any built-in range +fn take_range(_r: &impl RangeBounds) {} + + +fn main() { + take_range(&(0..1)); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &(0..1) + + take_range(&(1..)); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &(1..) + + take_range(&(..)); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &(..) + + take_range(&(0..=1)); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &(0..=1) + + take_range(&(..5)); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &(..5) + + take_range(&(..=42)); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &(..=42) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/range/issue-54505-no-literals.fixed rustc-1.31.0+dfsg1+llvm/src/test/ui/range/issue-54505-no-literals.fixed --- rustc-1.30.0+dfsg1+llvm/src/test/ui/range/issue-54505-no-literals.fixed 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/range/issue-54505-no-literals.fixed 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,75 @@ +// run-rustfix + +// Regression test for changes introduced while fixing #54505 + +// This test uses non-literals for Ranges +// (expecting no parens with borrow suggestion) + +use std::ops::RangeBounds; + + +// take a reference to any built-in range +fn take_range(_r: &impl RangeBounds) {} + + +fn main() { + take_range(&std::ops::Range { start: 0, end: 1 }); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &std::ops::Range { start: 0, end: 1 } + + take_range(&::std::ops::Range { start: 0, end: 1 }); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &::std::ops::Range { start: 0, end: 1 } + + take_range(&std::ops::RangeFrom { start: 1 }); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &std::ops::RangeFrom { start: 1 } + + take_range(&::std::ops::RangeFrom { start: 1 }); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &::std::ops::RangeFrom { start: 1 } + + take_range(&std::ops::RangeFull {}); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &std::ops::RangeFull {} + + take_range(&::std::ops::RangeFull {}); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &::std::ops::RangeFull {} + + take_range(&std::ops::RangeInclusive::new(0, 1)); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &std::ops::RangeInclusive::new(0, 1) + + take_range(&::std::ops::RangeInclusive::new(0, 1)); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &::std::ops::RangeInclusive::new(0, 1) + + take_range(&std::ops::RangeTo { end: 5 }); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &std::ops::RangeTo { end: 5 } + + take_range(&::std::ops::RangeTo { end: 5 }); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &::std::ops::RangeTo { end: 5 } + + take_range(&std::ops::RangeToInclusive { end: 5 }); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &std::ops::RangeToInclusive { end: 5 } + + take_range(&::std::ops::RangeToInclusive { end: 5 }); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &::std::ops::RangeToInclusive { end: 5 } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/range/issue-54505-no-literals.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/range/issue-54505-no-literals.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/range/issue-54505-no-literals.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/range/issue-54505-no-literals.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,75 @@ +// run-rustfix + +// Regression test for changes introduced while fixing #54505 + +// This test uses non-literals for Ranges +// (expecting no parens with borrow suggestion) + +use std::ops::RangeBounds; + + +// take a reference to any built-in range +fn take_range(_r: &impl RangeBounds) {} + + +fn main() { + take_range(std::ops::Range { start: 0, end: 1 }); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &std::ops::Range { start: 0, end: 1 } + + take_range(::std::ops::Range { start: 0, end: 1 }); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &::std::ops::Range { start: 0, end: 1 } + + take_range(std::ops::RangeFrom { start: 1 }); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &std::ops::RangeFrom { start: 1 } + + take_range(::std::ops::RangeFrom { start: 1 }); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &::std::ops::RangeFrom { start: 1 } + + take_range(std::ops::RangeFull {}); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &std::ops::RangeFull {} + + take_range(::std::ops::RangeFull {}); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &::std::ops::RangeFull {} + + take_range(std::ops::RangeInclusive::new(0, 1)); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &std::ops::RangeInclusive::new(0, 1) + + take_range(::std::ops::RangeInclusive::new(0, 1)); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &::std::ops::RangeInclusive::new(0, 1) + + take_range(std::ops::RangeTo { end: 5 }); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &std::ops::RangeTo { end: 5 } + + take_range(::std::ops::RangeTo { end: 5 }); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &::std::ops::RangeTo { end: 5 } + + take_range(std::ops::RangeToInclusive { end: 5 }); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &std::ops::RangeToInclusive { end: 5 } + + take_range(::std::ops::RangeToInclusive { end: 5 }); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &::std::ops::RangeToInclusive { end: 5 } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/range/issue-54505-no-literals.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/range/issue-54505-no-literals.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/range/issue-54505-no-literals.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/range/issue-54505-no-literals.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,147 @@ +error[E0308]: mismatched types + --> $DIR/issue-54505-no-literals.rs:16:16 + | +LL | take_range(std::ops::Range { start: 0, end: 1 }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected reference, found struct `std::ops::Range` + | help: consider borrowing here: `&std::ops::Range { start: 0, end: 1 }` + | + = note: expected type `&_` + found type `std::ops::Range<{integer}>` + +error[E0308]: mismatched types + --> $DIR/issue-54505-no-literals.rs:21:16 + | +LL | take_range(::std::ops::Range { start: 0, end: 1 }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected reference, found struct `std::ops::Range` + | help: consider borrowing here: `&::std::ops::Range { start: 0, end: 1 }` + | + = note: expected type `&_` + found type `std::ops::Range<{integer}>` + +error[E0308]: mismatched types + --> $DIR/issue-54505-no-literals.rs:26:16 + | +LL | take_range(std::ops::RangeFrom { start: 1 }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected reference, found struct `std::ops::RangeFrom` + | help: consider borrowing here: `&std::ops::RangeFrom { start: 1 }` + | + = note: expected type `&_` + found type `std::ops::RangeFrom<{integer}>` + +error[E0308]: mismatched types + --> $DIR/issue-54505-no-literals.rs:31:16 + | +LL | take_range(::std::ops::RangeFrom { start: 1 }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected reference, found struct `std::ops::RangeFrom` + | help: consider borrowing here: `&::std::ops::RangeFrom { start: 1 }` + | + = note: expected type `&_` + found type `std::ops::RangeFrom<{integer}>` + +error[E0308]: mismatched types + --> $DIR/issue-54505-no-literals.rs:36:16 + | +LL | take_range(std::ops::RangeFull {}); + | ^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected reference, found struct `std::ops::RangeFull` + | help: consider borrowing here: `&std::ops::RangeFull {}` + | + = note: expected type `&_` + found type `std::ops::RangeFull` + +error[E0308]: mismatched types + --> $DIR/issue-54505-no-literals.rs:41:16 + | +LL | take_range(::std::ops::RangeFull {}); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected reference, found struct `std::ops::RangeFull` + | help: consider borrowing here: `&::std::ops::RangeFull {}` + | + = note: expected type `&_` + found type `std::ops::RangeFull` + +error[E0308]: mismatched types + --> $DIR/issue-54505-no-literals.rs:46:16 + | +LL | take_range(std::ops::RangeInclusive::new(0, 1)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected reference, found struct `std::ops::RangeInclusive` + | help: consider borrowing here: `&std::ops::RangeInclusive::new(0, 1)` + | + = note: expected type `&_` + found type `std::ops::RangeInclusive<{integer}>` + +error[E0308]: mismatched types + --> $DIR/issue-54505-no-literals.rs:51:16 + | +LL | take_range(::std::ops::RangeInclusive::new(0, 1)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected reference, found struct `std::ops::RangeInclusive` + | help: consider borrowing here: `&::std::ops::RangeInclusive::new(0, 1)` + | + = note: expected type `&_` + found type `std::ops::RangeInclusive<{integer}>` + +error[E0308]: mismatched types + --> $DIR/issue-54505-no-literals.rs:56:16 + | +LL | take_range(std::ops::RangeTo { end: 5 }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected reference, found struct `std::ops::RangeTo` + | help: consider borrowing here: `&std::ops::RangeTo { end: 5 }` + | + = note: expected type `&_` + found type `std::ops::RangeTo<{integer}>` + +error[E0308]: mismatched types + --> $DIR/issue-54505-no-literals.rs:61:16 + | +LL | take_range(::std::ops::RangeTo { end: 5 }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected reference, found struct `std::ops::RangeTo` + | help: consider borrowing here: `&::std::ops::RangeTo { end: 5 }` + | + = note: expected type `&_` + found type `std::ops::RangeTo<{integer}>` + +error[E0308]: mismatched types + --> $DIR/issue-54505-no-literals.rs:66:16 + | +LL | take_range(std::ops::RangeToInclusive { end: 5 }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected reference, found struct `std::ops::RangeToInclusive` + | help: consider borrowing here: `&std::ops::RangeToInclusive { end: 5 }` + | + = note: expected type `&_` + found type `std::ops::RangeToInclusive<{integer}>` + +error[E0308]: mismatched types + --> $DIR/issue-54505-no-literals.rs:71:16 + | +LL | take_range(::std::ops::RangeToInclusive { end: 5 }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected reference, found struct `std::ops::RangeToInclusive` + | help: consider borrowing here: `&::std::ops::RangeToInclusive { end: 5 }` + | + = note: expected type `&_` + found type `std::ops::RangeToInclusive<{integer}>` + +error: aborting due to 12 previous errors + +For more information about this error, try `rustc --explain E0308`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/range/issue-54505-no-std.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/range/issue-54505-no-std.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/range/issue-54505-no-std.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/range/issue-54505-no-std.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,57 @@ +// error-pattern: `#[panic_handler]` function required, but not found + +// Regression test for #54505 - range borrowing suggestion had +// incorrect syntax (missing parentheses). + +// This test doesn't use std +// (so all Ranges resolve to core::ops::Range...) + +#![no_std] +#![feature(lang_items)] + +use core::ops::RangeBounds; + +#[cfg(not(target_arch = "wasm32"))] +#[lang = "eh_personality"] +extern fn eh_personality() {} + +#[cfg(target_os = "windows")] +#[lang = "eh_unwind_resume"] +extern fn eh_unwind_resume() {} + + +// take a reference to any built-in range +fn take_range(_r: &impl RangeBounds) {} + + +fn main() { + take_range(0..1); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &(0..1) + + take_range(1..); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &(1..) + + take_range(..); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &(..) + + take_range(0..=1); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &(0..=1) + + take_range(..5); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &(..5) + + take_range(..=42); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &(..=42) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/range/issue-54505-no-std.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/range/issue-54505-no-std.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/range/issue-54505-no-std.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/range/issue-54505-no-std.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,77 @@ +error: `#[panic_handler]` function required, but not found + +error[E0308]: mismatched types + --> $DIR/issue-54505-no-std.rs:28:16 + | +LL | take_range(0..1); + | ^^^^ + | | + | expected reference, found struct `core::ops::Range` + | help: consider borrowing here: `&(0..1)` + | + = note: expected type `&_` + found type `core::ops::Range<{integer}>` + +error[E0308]: mismatched types + --> $DIR/issue-54505-no-std.rs:33:16 + | +LL | take_range(1..); + | ^^^ + | | + | expected reference, found struct `core::ops::RangeFrom` + | help: consider borrowing here: `&(1..)` + | + = note: expected type `&_` + found type `core::ops::RangeFrom<{integer}>` + +error[E0308]: mismatched types + --> $DIR/issue-54505-no-std.rs:38:16 + | +LL | take_range(..); + | ^^ + | | + | expected reference, found struct `core::ops::RangeFull` + | help: consider borrowing here: `&(..)` + | + = note: expected type `&_` + found type `core::ops::RangeFull` + +error[E0308]: mismatched types + --> $DIR/issue-54505-no-std.rs:43:16 + | +LL | take_range(0..=1); + | ^^^^^ + | | + | expected reference, found struct `core::ops::RangeInclusive` + | help: consider borrowing here: `&(0..=1)` + | + = note: expected type `&_` + found type `core::ops::RangeInclusive<{integer}>` + +error[E0308]: mismatched types + --> $DIR/issue-54505-no-std.rs:48:16 + | +LL | take_range(..5); + | ^^^ + | | + | expected reference, found struct `core::ops::RangeTo` + | help: consider borrowing here: `&(..5)` + | + = note: expected type `&_` + found type `core::ops::RangeTo<{integer}>` + +error[E0308]: mismatched types + --> $DIR/issue-54505-no-std.rs:53:16 + | +LL | take_range(..=42); + | ^^^^^ + | | + | expected reference, found struct `core::ops::RangeToInclusive` + | help: consider borrowing here: `&(..=42)` + | + = note: expected type `&_` + found type `core::ops::RangeToInclusive<{integer}>` + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0308`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/range/issue-54505.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/range/issue-54505.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/range/issue-54505.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/range/issue-54505.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// run-rustfix + +// Regression test for #54505 - range borrowing suggestion had +// incorrect syntax (missing parentheses). + +use std::ops::RangeBounds; + + +// take a reference to any built-in range +fn take_range(_r: &impl RangeBounds) {} + + +fn main() { + take_range(0..1); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &(0..1) + + take_range(1..); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &(1..) + + take_range(..); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &(..) + + take_range(0..=1); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &(0..=1) + + take_range(..5); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &(..5) + + take_range(..=42); + //~^ ERROR mismatched types [E0308] + //~| HELP consider borrowing here + //~| SUGGESTION &(..=42) +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/range/issue-54505.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/range/issue-54505.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/range/issue-54505.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/range/issue-54505.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,75 @@ +error[E0308]: mismatched types + --> $DIR/issue-54505.rs:14:16 + | +LL | take_range(0..1); + | ^^^^ + | | + | expected reference, found struct `std::ops::Range` + | help: consider borrowing here: `&(0..1)` + | + = note: expected type `&_` + found type `std::ops::Range<{integer}>` + +error[E0308]: mismatched types + --> $DIR/issue-54505.rs:19:16 + | +LL | take_range(1..); + | ^^^ + | | + | expected reference, found struct `std::ops::RangeFrom` + | help: consider borrowing here: `&(1..)` + | + = note: expected type `&_` + found type `std::ops::RangeFrom<{integer}>` + +error[E0308]: mismatched types + --> $DIR/issue-54505.rs:24:16 + | +LL | take_range(..); + | ^^ + | | + | expected reference, found struct `std::ops::RangeFull` + | help: consider borrowing here: `&(..)` + | + = note: expected type `&_` + found type `std::ops::RangeFull` + +error[E0308]: mismatched types + --> $DIR/issue-54505.rs:29:16 + | +LL | take_range(0..=1); + | ^^^^^ + | | + | expected reference, found struct `std::ops::RangeInclusive` + | help: consider borrowing here: `&(0..=1)` + | + = note: expected type `&_` + found type `std::ops::RangeInclusive<{integer}>` + +error[E0308]: mismatched types + --> $DIR/issue-54505.rs:34:16 + | +LL | take_range(..5); + | ^^^ + | | + | expected reference, found struct `std::ops::RangeTo` + | help: consider borrowing here: `&(..5)` + | + = note: expected type `&_` + found type `std::ops::RangeTo<{integer}>` + +error[E0308]: mismatched types + --> $DIR/issue-54505.rs:39:16 + | +LL | take_range(..=42); + | ^^^^^ + | | + | expected reference, found struct `std::ops::RangeToInclusive` + | help: consider borrowing here: `&(..=42)` + | + = note: expected type `&_` + found type `std::ops::RangeToInclusive<{integer}>` + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0308`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/range/range-inclusive-pattern-precedence.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/range/range-inclusive-pattern-precedence.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/range/range-inclusive-pattern-precedence.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/range/range-inclusive-pattern-precedence.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -11,10 +11,10 @@ | ^^^^^^^ help: add parentheses to clarify the precedence: `(10 ..=15)` warning: `...` range patterns are deprecated - --> $DIR/range-inclusive-pattern-precedence.rs:24:11 + --> $DIR/range-inclusive-pattern-precedence.rs:24:9 | LL | &0...9 => {} - | ^^^ help: use `..=` for an inclusive range + | ^^^^^^ help: use `..=` for an inclusive range: `&(0..=9)` | note: lint level defined here --> $DIR/range-inclusive-pattern-precedence.rs:19:9 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/raw/raw-literal-keywords.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/raw/raw-literal-keywords.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/raw/raw-literal-keywords.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/raw/raw-literal-keywords.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn test_if() { - r#if true { } //~ ERROR found `true` -} - -fn test_struct() { - r#struct Test; //~ ERROR found `Test` -} - -fn test_union() { - r#union Test; //~ ERROR found `Test` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/raw/raw-literal-keywords.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/raw/raw-literal-keywords.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/raw/raw-literal-keywords.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/raw/raw-literal-keywords.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `true` - --> $DIR/raw-literal-keywords.rs:14:10 - | -LL | r#if true { } //~ ERROR found `true` - | ^^^^ expected one of 8 possible tokens here - -error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `Test` - --> $DIR/raw-literal-keywords.rs:18:14 - | -LL | r#struct Test; //~ ERROR found `Test` - | ^^^^ expected one of 8 possible tokens here - -error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `Test` - --> $DIR/raw-literal-keywords.rs:22:13 - | -LL | r#union Test; //~ ERROR found `Test` - | ^^^^ expected one of 8 possible tokens here - -error: aborting due to 3 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/raw/raw-literal-self.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/raw/raw-literal-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/raw/raw-literal-self.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/raw/raw-literal-self.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn self_test(r#self: u32) { - //~^ ERROR `r#self` is not currently supported. -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/raw/raw-literal-self.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/raw/raw-literal-self.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/raw/raw-literal-self.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/raw/raw-literal-self.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -error: `r#self` is not currently supported. - --> $DIR/raw-literal-self.rs:13:14 - | -LL | fn self_test(r#self: u32) { - | ^^^^^^ - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/raw/raw-literal-underscore.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/raw/raw-literal-underscore.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/raw/raw-literal-underscore.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/raw/raw-literal-underscore.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -fn underscore_test(r#_: u32) { - //~^ ERROR `r#_` is not currently supported. -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/raw/raw-literal-underscore.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/raw/raw-literal-underscore.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/raw/raw-literal-underscore.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/raw/raw-literal-underscore.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -error: `r#_` is not currently supported. - --> $DIR/raw-literal-underscore.rs:13:20 - | -LL | fn underscore_test(r#_: u32) { - | ^^^ - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/raw/raw_string.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/raw/raw_string.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/raw/raw_string.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/raw/raw_string.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let x = r##"lol"#; - //~^ ERROR unterminated raw string -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/raw/raw_string.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/raw/raw_string.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/raw/raw_string.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/raw/raw_string.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -error: unterminated raw string - --> $DIR/raw_string.rs:12:13 - | -LL | let x = r##"lol"#; - | ^ unterminated raw string - | - = note: this raw string should be terminated with `"##` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/reachable/expr_match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/reachable/expr_match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/reachable/expr_match.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/reachable/expr_match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,12 +13,6 @@ #![allow(dead_code)] #![deny(unreachable_code)] -fn a() { - // The match is considered unreachable here, because the `return` - // diverges: - match {return} { } //~ ERROR unreachable -} - fn b() { match () { () => return } println!("I am dead"); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/reachable/expr_match.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/reachable/expr_match.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/reachable/expr_match.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/reachable/expr_match.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,30 +1,23 @@ -error: unreachable expression - --> $DIR/expr_match.rs:19:5 +error: unreachable statement + --> $DIR/expr_match.rs:18:5 | -LL | match {return} { } //~ ERROR unreachable - | ^^^^^^^^^^^^^^^^^^ +LL | println!("I am dead"); + | ^^^^^^^^^^^^^^^^^^^^^^ | note: lint level defined here --> $DIR/expr_match.rs:14:9 | LL | #![deny(unreachable_code)] | ^^^^^^^^^^^^^^^^ - -error: unreachable statement - --> $DIR/expr_match.rs:24:5 - | -LL | println!("I am dead"); - | ^^^^^^^^^^^^^^^^^^^^^^ - | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: unreachable statement - --> $DIR/expr_match.rs:35:5 + --> $DIR/expr_match.rs:29:5 | LL | println!("I am dead"); | ^^^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/recursion/recursive-requirements.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/recursion/recursive-requirements.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/recursion/recursive-requirements.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/recursion/recursive-requirements.rs 2018-12-04 23:41:40.000000000 +0000 @@ -23,5 +23,7 @@ } fn main() { - let _: AssertSync = unimplemented!(); //~ ERROR E0275 + let _: AssertSync = unimplemented!(); + //~^ ERROR E0277 + //~| ERROR E0277 } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/recursion/recursive-requirements.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/recursion/recursive-requirements.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/recursion/recursive-requirements.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/recursion/recursive-requirements.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,15 +1,33 @@ -error[E0275]: overflow evaluating the requirement `Foo: std::marker::Sync` +error[E0277]: `*const Bar` cannot be shared between threads safely --> $DIR/recursive-requirements.rs:26:12 | -LL | let _: AssertSync = unimplemented!(); //~ ERROR E0275 - | ^^^^^^^^^^^^^^^ +LL | let _: AssertSync = unimplemented!(); + | ^^^^^^^^^^^^^^^ `*const Bar` cannot be shared between threads safely | - = help: consider adding a `#![recursion_limit="128"]` attribute to your crate - = note: required because it appears within the type `std::marker::PhantomData` + = help: within `Foo`, the trait `std::marker::Sync` is not implemented for `*const Bar` + = note: required because it appears within the type `Foo` +note: required by `AssertSync` + --> $DIR/recursive-requirements.rs:13:1 + | +LL | struct AssertSync(PhantomData); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: `*const Foo` cannot be shared between threads safely + --> $DIR/recursive-requirements.rs:26:12 + | +LL | let _: AssertSync = unimplemented!(); + | ^^^^^^^^^^^^^^^ `*const Foo` cannot be shared between threads safely + | + = help: within `Foo`, the trait `std::marker::Sync` is not implemented for `*const Foo` = note: required because it appears within the type `Bar` = note: required because it appears within the type `std::marker::PhantomData` = note: required because it appears within the type `Foo` +note: required by `AssertSync` + --> $DIR/recursive-requirements.rs:13:1 + | +LL | struct AssertSync(PhantomData); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0275`. +For more information about this error, try `rustc --explain E0277`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-borrow-params-issue-29793-big.ast.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-borrow-params-issue-29793-big.ast.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-borrow-params-issue-29793-big.ast.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-borrow-params-issue-29793-big.ast.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,25 +1,39 @@ -error[E0597]: `x` does not live long enough - --> $DIR/region-borrow-params-issue-29793-big.rs:81:43 +error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-big.rs:81:26 | LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `x` is borrowed here | | - | value captured here -... -LL | }); - | - `x` dropped here while still borrowed + | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-big.rs:81:9 + | +LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword + | +LL | WrapB::new().set(move |t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `y` does not live long enough - --> $DIR/region-borrow-params-issue-29793-big.rs:81:54 +error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-big.rs:81:26 | LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `y` is borrowed here | | - | value captured here -... -LL | }); - | - `y` dropped here while still borrowed + | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-big.rs:81:9 + | +LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword + | +LL | WrapB::new().set(move |t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0373`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-borrow-params-issue-29793-big.mir.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-borrow-params-issue-29793-big.mir.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-borrow-params-issue-29793-big.mir.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-borrow-params-issue-29793-big.mir.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,25 +1,39 @@ -error[E0597]: `x` does not live long enough - --> $DIR/region-borrow-params-issue-29793-big.rs:81:43 +error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-big.rs:81:26 | LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `x` is borrowed here | | - | value captured here -... -LL | }); - | - `x` dropped here while still borrowed + | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-big.rs:81:9 + | +LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword + | +LL | WrapB::new().set(move |t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `y` does not live long enough - --> $DIR/region-borrow-params-issue-29793-big.rs:81:54 +error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-big.rs:81:26 | LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `y` is borrowed here | | - | value captured here -... -LL | }); - | - `y` dropped here while still borrowed + | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-big.rs:81:9 + | +LL | WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword + | +LL | WrapB::new().set(move |t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0373`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-borrow-params-issue-29793-big.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-borrow-params-issue-29793-big.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-borrow-params-issue-29793-big.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-borrow-params-issue-29793-big.rs 2018-12-04 23:41:40.000000000 +0000 @@ -81,8 +81,8 @@ WrapB::new().set(|t: bool| if t { x } else { y }) // (separate errors for `x` vs `y`) //[ast]~^ ERROR `x` does not live long enough //[ast]~| ERROR `y` does not live long enough - //[mir]~^^^ ERROR `x` does not live long enough - //[mir]~| ERROR `y` does not live long enough + //[mir]~^^^ ERROR closure may outlive the current function + //[mir]~| ERROR closure may outlive the current function }); w.handle(); // This works diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-borrow-params-issue-29793-small.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-borrow-params-issue-29793-small.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-borrow-params-issue-29793-small.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-borrow-params-issue-29793-small.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,319 +1,363 @@ -error[E0597]: `x` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:19:34 +error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:19:17 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `x` is borrowed here | | - | value captured here -... -LL | }; - | - `x` dropped here while still borrowed + | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:22:16 + | +LL | return f; + | ^ +help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword + | +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `y` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:19:45 +error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:19:17 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `y` is borrowed here | | - | value captured here -... -LL | }; - | - `y` dropped here while still borrowed + | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:22:16 + | +LL | return f; + | ^ +help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword + | +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `x` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:34:34 +error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:34:17 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `x` is borrowed here | | - | value captured here -... -LL | }; - | - `x` dropped here while still borrowed + | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:37:9 + | +LL | f + | ^ +help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword + | +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `y` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:34:45 +error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:34:17 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `y` is borrowed here | | - | value captured here -... -LL | }; - | - `y` dropped here while still borrowed + | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:37:9 + | +LL | f + | ^ +help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword + | +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `x` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:65:34 +error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:65:17 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `x` is borrowed here | | - | value captured here -... -LL | }; - | - `x` dropped here while still borrowed + | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:68:16 | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 64:10... - --> $DIR/region-borrow-params-issue-29793-small.rs:64:10 +LL | return Box::new(f); + | ^^^^^^^^^^^ +help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword | -LL | fn g<'a>(x: usize, y:usize) -> Box usize + 'a> { - | ^^ +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `y` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:65:45 +error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:65:17 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `y` is borrowed here | | - | value captured here -... -LL | }; - | - `y` dropped here while still borrowed + | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:68:16 | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 64:10... - --> $DIR/region-borrow-params-issue-29793-small.rs:64:10 +LL | return Box::new(f); + | ^^^^^^^^^^^ +help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword | -LL | fn g<'a>(x: usize, y:usize) -> Box usize + 'a> { - | ^^ +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `x` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:76:34 +error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:76:17 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `x` is borrowed here | | - | value captured here -... -LL | }; - | - `x` dropped here while still borrowed + | may outlive borrowed value `x` | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 75:10... - --> $DIR/region-borrow-params-issue-29793-small.rs:75:10 +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:79:9 | -LL | fn g<'a>(x: usize, y:usize) -> Box usize + 'a> { - | ^^ +LL | Box::new(f) + | ^^^^^^^^^^^ +help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword + | +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `y` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:76:45 +error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:76:17 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `y` is borrowed here | | - | value captured here -... -LL | }; - | - `y` dropped here while still borrowed + | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:79:9 | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 75:10... - --> $DIR/region-borrow-params-issue-29793-small.rs:75:10 +LL | Box::new(f) + | ^^^^^^^^^^^ +help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword | -LL | fn g<'a>(x: usize, y:usize) -> Box usize + 'a> { - | ^^ +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `x` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:100:38 +error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:100:21 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `x` is borrowed here | | - | value captured here -... -LL | } - | - `x` dropped here while still borrowed + | may outlive borrowed value `x` | -note: borrowed value must be valid for the lifetime 'a as defined on the method body at 99:14... - --> $DIR/region-borrow-params-issue-29793-small.rs:99:14 +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:103:20 | -LL | fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { - | ^^ +LL | return Box::new(f); + | ^^^^^^^^^^^ +help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword + | +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `y` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:100:49 +error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:100:21 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `y` is borrowed here | | - | value captured here -... -LL | } - | - `y` dropped here while still borrowed + | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:103:20 | -note: borrowed value must be valid for the lifetime 'a as defined on the method body at 99:14... - --> $DIR/region-borrow-params-issue-29793-small.rs:99:14 +LL | return Box::new(f); + | ^^^^^^^^^^^ +help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword | -LL | fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { - | ^^ +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `x` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:114:38 +error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:114:21 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `x` is borrowed here | | - | value captured here -... -LL | } - | - `x` dropped here while still borrowed + | may outlive borrowed value `x` | -note: borrowed value must be valid for the lifetime 'a as defined on the method body at 113:14... - --> $DIR/region-borrow-params-issue-29793-small.rs:113:14 +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:117:13 | -LL | fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { - | ^^ +LL | Box::new(f) + | ^^^^^^^^^^^ +help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword + | +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `y` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:114:49 +error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:114:21 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `y` is borrowed here | | - | value captured here -... -LL | } - | - `y` dropped here while still borrowed + | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:117:13 | -note: borrowed value must be valid for the lifetime 'a as defined on the method body at 113:14... - --> $DIR/region-borrow-params-issue-29793-small.rs:113:14 +LL | Box::new(f) + | ^^^^^^^^^^^ +help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword | -LL | fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { - | ^^ +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `x` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:142:38 +error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:142:21 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `x` is borrowed here | | - | value captured here -... -LL | } - | - `x` dropped here while still borrowed + | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:145:20 | -note: borrowed value must be valid for the lifetime 'a as defined on the method body at 141:14... - --> $DIR/region-borrow-params-issue-29793-small.rs:141:14 +LL | return Box::new(f); + | ^^^^^^^^^^^ +help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword | -LL | fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { - | ^^ +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `y` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:142:49 +error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:142:21 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `y` is borrowed here | | - | value captured here -... -LL | } - | - `y` dropped here while still borrowed + | may outlive borrowed value `y` | -note: borrowed value must be valid for the lifetime 'a as defined on the method body at 141:14... - --> $DIR/region-borrow-params-issue-29793-small.rs:141:14 +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:145:20 | -LL | fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { - | ^^ +LL | return Box::new(f); + | ^^^^^^^^^^^ +help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword + | +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `x` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:157:38 +error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:157:21 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `x` is borrowed here | | - | value captured here -... -LL | } - | - `x` dropped here while still borrowed + | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:160:13 | -note: borrowed value must be valid for the lifetime 'a as defined on the method body at 156:14... - --> $DIR/region-borrow-params-issue-29793-small.rs:156:14 +LL | Box::new(f) + | ^^^^^^^^^^^ +help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword | -LL | fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { - | ^^ +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `y` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:157:49 +error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:157:21 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `y` is borrowed here | | - | value captured here -... -LL | } - | - `y` dropped here while still borrowed + | may outlive borrowed value `y` | -note: borrowed value must be valid for the lifetime 'a as defined on the method body at 156:14... - --> $DIR/region-borrow-params-issue-29793-small.rs:156:14 +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:160:13 | -LL | fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { - | ^^ +LL | Box::new(f) + | ^^^^^^^^^^^ +help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword + | +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `x` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:185:38 +error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:185:21 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `x` is borrowed here | | - | value captured here -... -LL | } - | - `x` dropped here while still borrowed + | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:188:20 | -note: borrowed value must be valid for the lifetime 'a as defined on the method body at 184:14... - --> $DIR/region-borrow-params-issue-29793-small.rs:184:14 +LL | return Box::new(f); + | ^^^^^^^^^^^ +help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword | -LL | fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { - | ^^ +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `y` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:185:49 +error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:185:21 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `y` is borrowed here | | - | value captured here -... -LL | } - | - `y` dropped here while still borrowed + | may outlive borrowed value `y` | -note: borrowed value must be valid for the lifetime 'a as defined on the method body at 184:14... - --> $DIR/region-borrow-params-issue-29793-small.rs:184:14 +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:188:20 | -LL | fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { - | ^^ +LL | return Box::new(f); + | ^^^^^^^^^^^ +help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword + | +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `x` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:199:38 +error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:199:21 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `x` is borrowed here | | - | value captured here -... -LL | } - | - `x` dropped here while still borrowed + | may outlive borrowed value `x` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:202:13 | -note: borrowed value must be valid for the lifetime 'a as defined on the method body at 198:14... - --> $DIR/region-borrow-params-issue-29793-small.rs:198:14 +LL | Box::new(f) + | ^^^^^^^^^^^ +help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword | -LL | fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { - | ^^ +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ -error[E0597]: `y` does not live long enough - --> $DIR/region-borrow-params-issue-29793-small.rs:199:49 +error[E0373]: closure may outlive the current function, but it borrows `y`, which is owned by the current function + --> $DIR/region-borrow-params-issue-29793-small.rs:199:21 | LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) - | --------- ^ borrowed value does not live long enough + | ^^^^^^^^^ - `y` is borrowed here | | - | value captured here -... -LL | } - | - `y` dropped here while still borrowed + | may outlive borrowed value `y` + | +note: closure is returned here + --> $DIR/region-borrow-params-issue-29793-small.rs:202:13 | -note: borrowed value must be valid for the lifetime 'a as defined on the method body at 198:14... - --> $DIR/region-borrow-params-issue-29793-small.rs:198:14 +LL | Box::new(f) + | ^^^^^^^^^^^ +help: to force the closure to take ownership of `y` (and any other referenced variables), use the `move` keyword | -LL | fn g<'a>(&self, x: usize, y:usize) -> Box usize + 'a> { - | ^^ +LL | let f = move |t: bool| if t { x } else { y }; // (separate errors for `x` vs `y`) + | ^^^^^^^^^^^^^^ error: aborting due to 20 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0373`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-bound-on-closure-outlives-call.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-bound-on-closure-outlives-call.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-bound-on-closure-outlives-call.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-bound-on-closure-outlives-call.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,13 +1,24 @@ +warning: function cannot return without recursing + --> $DIR/region-bound-on-closure-outlives-call.rs:11:1 + | +LL | fn call_rec(mut f: F) -> usize where F: FnMut(usize) -> usize { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing +LL | //~^ WARN function cannot return without recursing +LL | (|x| f(x))(call_rec(f)) //~ ERROR cannot move out of `f` + | ----------- recursive call site + | + = note: #[warn(unconditional_recursion)] on by default + = help: a `loop` may express intention better if this is on purpose + error[E0505]: cannot move out of `f` because it is borrowed - --> $DIR/region-bound-on-closure-outlives-call.rs:12:25 + --> $DIR/region-bound-on-closure-outlives-call.rs:13:25 | LL | (|x| f(x))(call_rec(f)) //~ ERROR cannot move out of `f` - | --------------------^-- - | || | | - | || | move out of `f` occurs here + | ---------- ^ move out of `f` occurs here + | || | | || borrow occurs due to use in closure | |borrow of `f` occurs here - | borrow later used here + | borrow later used by call error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-bound-on-closure-outlives-call.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-bound-on-closure-outlives-call.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-bound-on-closure-outlives-call.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-bound-on-closure-outlives-call.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,6 +9,7 @@ // except according to those terms. fn call_rec(mut f: F) -> usize where F: FnMut(usize) -> usize { + //~^ WARN function cannot return without recursing (|x| f(x))(call_rec(f)) //~ ERROR cannot move out of `f` } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-bound-on-closure-outlives-call.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-bound-on-closure-outlives-call.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-bound-on-closure-outlives-call.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-bound-on-closure-outlives-call.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,17 @@ +warning: function cannot return without recursing + --> $DIR/region-bound-on-closure-outlives-call.rs:11:1 + | +LL | fn call_rec(mut f: F) -> usize where F: FnMut(usize) -> usize { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing +LL | //~^ WARN function cannot return without recursing +LL | (|x| f(x))(call_rec(f)) //~ ERROR cannot move out of `f` + | ----------- recursive call site + | + = note: #[warn(unconditional_recursion)] on by default + = help: a `loop` may express intention better if this is on purpose + error[E0505]: cannot move out of `f` because it is borrowed - --> $DIR/region-bound-on-closure-outlives-call.rs:12:25 + --> $DIR/region-bound-on-closure-outlives-call.rs:13:25 | LL | (|x| f(x))(call_rec(f)) //~ ERROR cannot move out of `f` | --- ^ move out of `f` occurs here diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-invariant-static-error-reporting.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-invariant-static-error-reporting.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-invariant-static-error-reporting.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-invariant-static-error-reporting.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error: borrowed data escapes outside of function - --> $DIR/region-invariant-static-error-reporting.rs:25:9 - | -LL | fn unify<'a>(x: Option>, f: fn(Invariant<'a>)) { - | - `x` is a reference that is only valid in the function body -LL | let bad = if x.is_some() { -LL | x.unwrap() - | ^^^^^^^^^^ `x` escapes the function body here - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:30:43 - | -LL | let _: fn(&mut &isize, &mut &isize) = a; //~ ERROR mismatched types - | ^ expected concrete lifetime, found bound lifetime parameter - | - = note: expected type `for<'r, 's, 't0, 't1> fn(&'r mut &'s isize, &'t0 mut &'t1 isize)` - found type `for<'r, 's> fn(&'r mut &isize, &'s mut &isize) {a::<'_, '_>}` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:32:56 - | -LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; //~ ERROR mismatched types - | ^ expected concrete lifetime, found bound lifetime parameter - | - = note: expected type `for<'r, 's, 't0, 't1, 't2, 't3> fn(&'r mut &'s isize, &'t0 mut &'t1 isize, &'t2 mut &'t3 isize)` - found type `for<'r, 's, 't0> fn(&'r mut &isize, &'s mut &isize, &'t0 mut &isize) {a::<'_, '_, '_>}` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-object-lifetime-2.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-object-lifetime-2.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-object-lifetime-2.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-object-lifetime-2.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/region-object-lifetime-2.rs:20:5 - | -LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a Foo) -> &'b () { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | x.borrowed() //~ ERROR cannot infer - | ^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'b` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-object-lifetime-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-object-lifetime-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-object-lifetime-2.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-object-lifetime-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -9,7 +9,7 @@ | LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a Foo) -> &'b () { | ^^ -note: ...so that the type `(dyn Foo + 'a)` is not borrowed for too long +note: ...so that reference does not outlive borrowed content --> $DIR/region-object-lifetime-2.rs:20:5 | LL | x.borrowed() //~ ERROR cannot infer diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-object-lifetime-4.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-object-lifetime-4.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-object-lifetime-4.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-object-lifetime-4.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/region-object-lifetime-4.rs:22:5 - | -LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (Foo+'b)) -> &'b () { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | x.borrowed() //~ ERROR cannot infer - | ^^^^^^^^^^^^ argument requires that `'a` must outlive `'b` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-object-lifetime-5.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-object-lifetime-5.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-object-lifetime-5.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-object-lifetime-5.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,13 +1,12 @@ -error[E0597]: `*x` does not live long enough +error[E0515]: cannot return value referencing local data `*x` --> $DIR/region-object-lifetime-5.rs:21:5 | LL | x.borrowed() //~ ERROR `*x` does not live long enough - | ^ borrowed value does not live long enough -LL | } - | - `*x` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... + | -^^^^^^^^^^^ + | | + | returns a value referencing data owned by the current function + | `*x` is borrowed here error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/region-object-lifetime-in-coercion.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -error[E0621]: explicit lifetime required in the type of `v` - --> $DIR/region-object-lifetime-in-coercion.rs:18:33 - | -LL | fn a(v: &[u8]) -> Box { - | ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` -LL | let x: Box = Box::new(v); - | ^^^^^^^^^^^ lifetime `'static` required - -error[E0621]: explicit lifetime required in the type of `v` - --> $DIR/region-object-lifetime-in-coercion.rs:24:5 - | -LL | fn b(v: &[u8]) -> Box { - | ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` -LL | Box::new(v) - | ^^^^^^^^^^^ lifetime `'static` required - -error[E0621]: explicit lifetime required in the type of `v` - --> $DIR/region-object-lifetime-in-coercion.rs:31:5 - | -LL | fn c(v: &[u8]) -> Box { - | ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]` -... -LL | Box::new(v) - | ^^^^^^^^^^^ lifetime `'static` required - -error: unsatisfied lifetime constraints - --> $DIR/region-object-lifetime-in-coercion.rs:36:5 - | -LL | fn d<'a,'b>(v: &'a [u8]) -> Box { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | Box::new(v) - | ^^^^^^^^^^^ returning this value requires that `'a` must outlive `'b` - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0621`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-addr-of-arg.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-addr-of-arg.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-addr-of-arg.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-addr-of-arg.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,26 +2,19 @@ --> $DIR/regions-addr-of-arg.rs:15:30 | LL | let _p: &'static isize = &a; //~ ERROR `a` does not live long enough - | ^^ borrowed value does not live long enough + | -------------- ^^ borrowed value does not live long enough + | | + | type annotation requires that `a` is borrowed for `'static` LL | } | - `a` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... -error[E0597]: `a` does not live long enough +error[E0515]: cannot return reference to function parameter `a` --> $DIR/regions-addr-of-arg.rs:23:5 | LL | &a //~ ERROR `a` does not live long enough - | ^^ borrowed value does not live long enough -LL | } - | - `a` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 22:8... - --> $DIR/regions-addr-of-arg.rs:22:8 - | -LL | fn zed<'a>(a: isize) -> &'a isize { - | ^^ + | ^^ returns a reference to data owned by the current function error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +Some errors occurred: E0515, E0597. +For more information about an error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-addr-of-self.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-addr-of-self.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-addr-of-self.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-addr-of-self.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-addr-of-self.rs:17:13 - | -LL | pub fn chase_cat(&mut self) { - | - let's call the lifetime of this reference `'1` -LL | let p: &'static mut usize = &mut self.cats_chased; //~ ERROR cannot infer - | ^ requires that `'1` must outlive `'static` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-addr-of-upvar-self.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-addr-of-upvar-self.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-addr-of-upvar-self.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-addr-of-upvar-self.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-addr-of-upvar-self.rs:20:17 - | -LL | let _f = || { - | -- lifetime `'1` represents this closure's body -LL | let p: &'static mut usize = &mut self.food; //~ ERROR cannot infer - | ^ requires that `'1` must outlive `'static` - | - = note: closure implements `FnMut`, so references to captured variables can't escape the closure - -error: unsatisfied lifetime constraints - --> $DIR/regions-addr-of-upvar-self.rs:20:17 - | -LL | pub fn chase_cat(&mut self) { - | --------- lifetime `'2` appears in the type of `self` -LL | let _f = || { - | -- lifetime `'1` represents this closure's body -LL | let p: &'static mut usize = &mut self.food; //~ ERROR cannot infer - | ^ requires that `'1` must outlive `'2` - | - = note: closure implements `FnMut`, so references to captured variables can't escape the closure - -error: unsatisfied lifetime constraints - --> $DIR/regions-addr-of-upvar-self.rs:19:13 - | -LL | pub fn chase_cat(&mut self) { - | - let's call the lifetime of this reference `'1` -LL | let _f = || { - | ^^ requires that `'1` must outlive `'static` - -error[E0597]: `self` does not live long enough - --> $DIR/regions-addr-of-upvar-self.rs:20:46 - | -LL | let _f = || { - | -- value captured here -LL | let p: &'static mut usize = &mut self.food; //~ ERROR cannot infer - | ^^^^ borrowed value does not live long enough -... -LL | } - | - `self` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-adjusted-lvalue-op.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-adjusted-lvalue-op.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-adjusted-lvalue-op.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-adjusted-lvalue-op.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,21 +2,19 @@ --> $DIR/regions-adjusted-lvalue-op.rs:24:16 | LL | v[0].oh_no(&v); //~ ERROR cannot borrow `v` as immutable because - | -----------^^- - | | | - | | immutable borrow occurs here + | - ----- ^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call | mutable borrow occurs here - | borrow later used here error[E0502]: cannot borrow `v` as immutable because it is also borrowed as mutable --> $DIR/regions-adjusted-lvalue-op.rs:25:16 | LL | (*v).oh_no(&v); //~ ERROR cannot borrow `v` as immutable because - | -----------^^- - | | | | - | | | immutable borrow occurs here - | | mutable borrow occurs here - | borrow later used here + | - ----- ^^ immutable borrow occurs here + | | | + | | mutable borrow later used by call + | mutable borrow occurs here error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - // Test that we are imposing the requirement that every associated // type of a bound that appears in the where clause on a struct must // outlive the location in which the type appears, even when the @@ -49,7 +47,10 @@ // outlive 'a. In this case, that means TheType<'b>::TheAssocType, // which is &'b (), must outlive 'a. - let _: &'a WithAssoc> = loop { }; //~ ERROR reference has a longer lifetime + // FIXME (#54943) NLL doesn't enforce WF condition in unreachable code if + // `_x` is changed to `_` + let _x: &'a WithAssoc> = loop { }; + //~^ ERROR reference has a longer lifetime } fn main() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-assoc-type-in-supertrait-outlives-container.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,16 +1,16 @@ error[E0491]: in type `&'a WithAssoc>`, reference has a longer lifetime than the data it references - --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:52:12 + --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:52:13 | -LL | let _: &'a WithAssoc> = loop { }; //~ ERROR reference has a longer lifetime - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let _x: &'a WithAssoc> = loop { }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | -note: the pointer is valid for the lifetime 'a as defined on the function body at 46:15 - --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:46:15 +note: the pointer is valid for the lifetime 'a as defined on the function body at 44:15 + --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:44:15 | LL | fn with_assoc<'a,'b>() { | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 46:18 - --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:46:18 +note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 44:18 + --> $DIR/regions-assoc-type-in-supertrait-outlives-container.rs:44:18 | LL | fn with_assoc<'a,'b>() { | ^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-by-trait-requiring-static.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-by-trait-requiring-static.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-by-trait-requiring-static.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-by-trait-requiring-static.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - // Test which of the builtin types are considered sendable. The tests // in this file all test region bound and lifetime violations that are // detected during type check. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-by-trait-requiring-static.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-by-trait-requiring-static.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-by-trait-requiring-static.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-by-trait-requiring-static.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error[E0477]: the type `&'a isize` does not fulfill the required lifetime - --> $DIR/regions-bounded-by-trait-requiring-static.rs:34:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:32:5 | LL | assert_send::<&'a isize>(); //~ ERROR does not fulfill the required lifetime | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ = note: type must satisfy the static lifetime error[E0477]: the type `&'a str` does not fulfill the required lifetime - --> $DIR/regions-bounded-by-trait-requiring-static.rs:38:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:36:5 | LL | assert_send::<&'a str>(); //~ ERROR does not fulfill the required lifetime | ^^^^^^^^^^^^^^^^^^^^^^ @@ -15,7 +15,7 @@ = note: type must satisfy the static lifetime error[E0477]: the type `&'a [isize]` does not fulfill the required lifetime - --> $DIR/regions-bounded-by-trait-requiring-static.rs:42:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:40:5 | LL | assert_send::<&'a [isize]>(); //~ ERROR does not fulfill the required lifetime | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ = note: type must satisfy the static lifetime error[E0477]: the type `std::boxed::Box<&'a isize>` does not fulfill the required lifetime - --> $DIR/regions-bounded-by-trait-requiring-static.rs:56:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:54:5 | LL | assert_send::>(); //~ ERROR does not fulfill the required lifetime | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -31,7 +31,7 @@ = note: type must satisfy the static lifetime error[E0477]: the type `*const &'a isize` does not fulfill the required lifetime - --> $DIR/regions-bounded-by-trait-requiring-static.rs:67:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:65:5 | LL | assert_send::<*const &'a isize>(); //~ ERROR does not fulfill the required lifetime | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -39,7 +39,7 @@ = note: type must satisfy the static lifetime error[E0477]: the type `*mut &'a isize` does not fulfill the required lifetime - --> $DIR/regions-bounded-by-trait-requiring-static.rs:71:5 + --> $DIR/regions-bounded-by-trait-requiring-static.rs:69:5 | LL | assert_send::<*mut &'a isize>(); //~ ERROR does not fulfill the required lifetime | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-method-type-parameters-cross-crate.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-bounded-method-type-parameters-cross-crate.rs:30:5 - | -LL | fn call_bigger_region<'x, 'y>(a: Inv<'x>, b: Inv<'y>) { - | -- -- lifetime `'y` defined here - | | - | lifetime `'x` defined here -LL | // Here the value provided for 'y is 'y, and hence 'y:'x does not hold. -LL | a.bigger_region(b) //~ ERROR 30:7: 30:20: lifetime mismatch [E0623] - | ^^^^^^^^^^^^^^^^^^ argument requires that `'y` must outlive `'x` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-method-type-parameters.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-method-type-parameters.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-method-type-parameters.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-method-type-parameters.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - // Check that explicit region bounds are allowed on the various // nominal types (but not on other types) and that they are type // checked. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-method-type-parameters.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-method-type-parameters.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-method-type-parameters.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-method-type-parameters.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error[E0477]: the type `&'a isize` does not fulfill the required lifetime - --> $DIR/regions-bounded-method-type-parameters.rs:24:9 + --> $DIR/regions-bounded-method-type-parameters.rs:22:9 | LL | Foo.some_method::<&'a isize>(); | ^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -error: borrowed data escapes outside of function - --> $DIR/regions-bounded-method-type-parameters-trait-bound.rs:30:5 - | -LL | fn caller2<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) { - | - - `b` is a reference that is only valid in the function body - | | - | `a` is declared here, outside of the function body -LL | // Here the value provided for 'y is 'b, and hence 'b:'a does not hold. -LL | f.method(b); //~ ERROR 30:7: 30:13: lifetime mismatch [E0623] - | ^^^^^^^^^^^ `b` escapes the function body here - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-bounds.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-bounds.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-bounds.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-bounds.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-bounds.rs:19:12 - | -LL | fn a_fn1<'a,'b>(e: an_enum<'a>) -> an_enum<'b> { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | return e; //~ ERROR mismatched types - | ^ returning this value requires that `'a` must outlive `'b` - -error: unsatisfied lifetime constraints - --> $DIR/regions-bounds.rs:23:12 - | -LL | fn a_fn3<'a,'b>(e: a_class<'a>) -> a_class<'b> { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | return e; //~ ERROR mismatched types - | ^ returning this value requires that `'a` must outlive `'b` - -error: aborting due to 2 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-close-associated-type-into-object.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-close-associated-type-into-object.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-close-associated-type-into-object.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-close-associated-type-into-object.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -error[E0310]: the associated type `::Item` may not live long enough - --> $DIR/regions-close-associated-type-into-object.rs:25:5 - | -LL | Box::new(item) //~ ERROR associated type `::Item` may not live long enough - | ^^^^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `::Item: 'static`... - -error[E0310]: the associated type `::Item` may not live long enough - --> $DIR/regions-close-associated-type-into-object.rs:32:5 - | -LL | Box::new(item) //~ ERROR associated type `::Item` may not live long enough - | ^^^^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `::Item: 'static`... - -error[E0309]: the associated type `::Item` may not live long enough - --> $DIR/regions-close-associated-type-into-object.rs:38:5 - | -LL | Box::new(item) //~ ERROR associated type `::Item` may not live long enough - | ^^^^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `::Item: 'a`... - -error[E0309]: the associated type `::Item` may not live long enough - --> $DIR/regions-close-associated-type-into-object.rs:45:5 - | -LL | Box::new(item) //~ ERROR associated type `::Item` may not live long enough - | ^^^^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `::Item: 'a`... - -error: aborting due to 4 previous errors - -Some errors occurred: E0309, E0310. -For more information about an error, try `rustc --explain E0309`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-close-object-into-object-1.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-close-object-into-object-1.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-close-object-into-object-1.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-close-object-into-object-1.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,13 +1,12 @@ -error[E0597]: `*v` does not live long enough - --> $DIR/regions-close-object-into-object-1.rs:22:11 +error[E0515]: cannot return value referencing local data `*v` + --> $DIR/regions-close-object-into-object-1.rs:22:5 | LL | box B(&*v) as Box //~ ERROR `*v` does not live long enough - | ^^^ borrowed value does not live long enough -LL | } - | - `*v` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... + | ^^^^^^---^^^^^^^^^^^ + | | | + | | `*v` is borrowed here + | returns a value referencing data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-close-object-into-object-2.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-close-object-into-object-2.rs:20:11 - | -LL | fn g<'a, T: 'static>(v: Box+'a>) -> Box { - | -- lifetime `'a` defined here -LL | box B(&*v) as Box //~ ERROR cannot infer - | ^^^ cast requires that `'a` must outlive `'static` - -error[E0597]: `*v` does not live long enough - --> $DIR/regions-close-object-into-object-2.rs:20:11 - | -LL | box B(&*v) as Box //~ ERROR cannot infer - | ^^^ borrowed value does not live long enough -LL | } - | - `*v` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-close-object-into-object-3.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-close-object-into-object-3.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-close-object-into-object-3.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-close-object-into-object-3.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,13 +1,12 @@ -error[E0597]: `*v` does not live long enough - --> $DIR/regions-close-object-into-object-3.rs:21:11 +error[E0515]: cannot return value referencing local data `*v` + --> $DIR/regions-close-object-into-object-3.rs:21:5 | LL | box B(&*v) as Box //~ ERROR `*v` does not live long enough - | ^^^ borrowed value does not live long enough -LL | } - | - `*v` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... + | ^^^^^^---^^^^^^^^^^^ + | | | + | | `*v` is borrowed here + | returns a value referencing data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-close-object-into-object-4.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -error[E0310]: the parameter type `U` may not live long enough - --> $DIR/regions-close-object-into-object-4.rs:20:5 - | -LL | box B(&*v) as Box //~ ERROR cannot infer - | ^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `U: 'static`... - -error[E0310]: the parameter type `U` may not live long enough - --> $DIR/regions-close-object-into-object-4.rs:20:9 - | -LL | box B(&*v) as Box //~ ERROR cannot infer - | ^^^^^^ - | - = help: consider adding an explicit lifetime bound `U: 'static`... - -error: unsatisfied lifetime constraints - --> $DIR/regions-close-object-into-object-4.rs:20:11 - | -LL | fn i<'a, T, U>(v: Box+'a>) -> Box { - | -- lifetime `'a` defined here -LL | box B(&*v) as Box //~ ERROR cannot infer - | ^^^ cast requires that `'a` must outlive `'static` - -error[E0597]: `*v` does not live long enough - --> $DIR/regions-close-object-into-object-4.rs:20:11 - | -LL | box B(&*v) as Box //~ ERROR cannot infer - | ^^^ borrowed value does not live long enough -LL | } - | - `*v` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... - -error: aborting due to 4 previous errors - -Some errors occurred: E0310, E0597. -For more information about an error, try `rustc --explain E0310`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-close-object-into-object-5.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-close-object-into-object-5.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-close-object-into-object-5.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-close-object-into-object-5.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:27:5 - | -LL | box B(&*v) as Box - | ^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `T: 'static`... - -error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-object-into-object-5.rs:27:9 - | -LL | box B(&*v) as Box - | ^^^^^^ - | - = help: consider adding an explicit lifetime bound `T: 'static`... - -error[E0597]: `*v` does not live long enough - --> $DIR/regions-close-object-into-object-5.rs:27:11 - | -LL | box B(&*v) as Box - | ^^^ borrowed value does not live long enough -... -LL | } - | - `*v` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... - -error: aborting due to 3 previous errors - -Some errors occurred: E0310, E0597. -For more information about an error, try `rustc --explain E0310`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-close-over-type-parameter-1.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -error[E0310]: the parameter type `A` may not live long enough - --> $DIR/regions-close-over-type-parameter-1.rs:20:5 - | -LL | box v as Box - | ^^^^^ - | - = help: consider adding an explicit lifetime bound `A: 'static`... - -error[E0309]: the parameter type `A` may not live long enough - --> $DIR/regions-close-over-type-parameter-1.rs:30:5 - | -LL | box v as Box - | ^^^^^ - | - = help: consider adding an explicit lifetime bound `A: 'b`... - -error: aborting due to 2 previous errors - -Some errors occurred: E0309, E0310. -For more information about an error, try `rustc --explain E0309`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-close-over-type-parameter-multiple.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error[E0309]: the parameter type `A` may not live long enough - --> $DIR/regions-close-over-type-parameter-multiple.rs:30:5 - | -LL | box v as Box //~ ERROR cannot infer an appropriate lifetime - | ^^^^^ - | - = help: consider adding an explicit lifetime bound `A: 'c`... - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0309`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-close-param-into-object.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-close-param-into-object.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-close-param-into-object.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-close-param-into-object.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-param-into-object.rs:16:5 - | -LL | Box::new(v) //~ ERROR parameter type `T` may not live long enough - | ^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `T: 'static`... - -error[E0310]: the parameter type `T` may not live long enough - --> $DIR/regions-close-param-into-object.rs:22:5 - | -LL | Box::new(v) //~ ERROR parameter type `T` may not live long enough - | ^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `T: 'static`... - -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-close-param-into-object.rs:28:5 - | -LL | Box::new(v) //~ ERROR parameter type `T` may not live long enough - | ^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `T: 'a`... - -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-close-param-into-object.rs:34:5 - | -LL | Box::new(v) //~ ERROR parameter type `T` may not live long enough - | ^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `T: 'a`... - -error: aborting due to 4 previous errors - -Some errors occurred: E0309, E0310. -For more information about an error, try `rustc --explain E0309`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-creating-enums3.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-creating-enums3.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-creating-enums3.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-creating-enums3.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-creating-enums3.rs:17:5 - | -LL | fn mk_add_bad1<'a,'b>(x: &'a ast<'a>, y: &'b ast<'b>) -> ast<'a> { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | ast::add(x, y) //~ ERROR 17:5: 17:19: lifetime mismatch [E0623] - | ^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-creating-enums4.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-creating-enums4.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-creating-enums4.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-creating-enums4.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-creating-enums4.rs:17:5 - | -LL | fn mk_add_bad2<'a,'b>(x: &'a ast<'a>, y: &'a ast<'a>, z: &ast) -> ast<'b> { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | ast::add(x, y) //~ ERROR cannot infer - | ^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'b` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-creating-enums.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-creating-enums.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-creating-enums.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-creating-enums.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,31 +1,21 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/regions-creating-enums.rs:33:17 +error[E0515]: cannot return reference to temporary value + --> $DIR/regions-creating-enums.rs:33:16 | LL | return &ast::num((*f)(x)); //~ ERROR borrowed value does not live long enough - | ^^^^^^^^^^^^^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 30:13... - --> $DIR/regions-creating-enums.rs:30:13 - | -LL | fn map_nums<'a,'b, F>(x: &ast, f: &mut F) -> &'a ast<'b> where F: FnMut(usize) -> usize { - | ^^ + | ^----------------- + | || + | |temporary value created here + | returns a reference to data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/regions-creating-enums.rs:38:17 +error[E0515]: cannot return reference to temporary value + --> $DIR/regions-creating-enums.rs:38:16 | LL | return &ast::add(m_x, m_y); //~ ERROR borrowed value does not live long enough - | ^^^^^^^^^^^^^^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 30:13... - --> $DIR/regions-creating-enums.rs:30:13 - | -LL | fn map_nums<'a,'b, F>(x: &ast, f: &mut F) -> &'a ast<'b> where F: FnMut(usize) -> usize { - | ^^ + | ^------------------ + | || + | |temporary value created here + | returns a reference to data owned by the current function error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-early-bound-error-method.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-early-bound-error-method.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-early-bound-error-method.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-early-bound-error-method.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-early-bound-error-method.rs:30:9 - | -LL | impl<'a> Box<'a> { - | -- lifetime `'a` defined here -LL | fn or<'b,G:GetRef<'b>>(&self, g2: G) -> &'a isize { - | -- lifetime `'b` defined here -LL | g2.get() - | ^^^^^^^^ returning this value requires that `'b` must outlive `'a` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-early-bound-error.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-early-bound-error.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-early-bound-error.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-early-bound-error.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-early-bound-error.rs:29:5 - | -LL | fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | g1.get() - | ^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-enum-not-wf.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-enum-not-wf.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-enum-not-wf.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-enum-not-wf.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,31 +8,43 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-tidy-linelength + // Various examples of structs whose fields are not well-formed. #![allow(dead_code)] +trait Dummy<'a> { + type Out; +} +impl<'a, T> Dummy<'a> for T +where T: 'a +{ + type Out = (); +} +type RequireOutlives<'a, T> = >::Out; + enum Ref1<'a, T> { - Ref1Variant1(&'a T) //~ ERROR the parameter type `T` may not live long enough + Ref1Variant1(RequireOutlives<'a, T>) //~ ERROR the parameter type `T` may not live long enough } enum Ref2<'a, T> { Ref2Variant1, - Ref2Variant2(isize, &'a T), //~ ERROR the parameter type `T` may not live long enough + Ref2Variant2(isize, RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough } enum RefOk<'a, T:'a> { RefOkVariant1(&'a T) } +// This is now well formed. RFC 2093 enum RefIndirect<'a, T> { RefIndirectVariant1(isize, RefOk<'a,T>) - //~^ ERROR the parameter type `T` may not live long enough } -enum RefDouble<'a, 'b, T> { - RefDoubleVariant1(&'a &'b T) - //~^ ERROR reference has a longer lifetime than the data +enum RefDouble<'a, 'b, T> { //~ ERROR 45:1: 48:2: the parameter type `T` may not live long enough [E0309] + RefDoubleVariant1(&'a RequireOutlives<'b, T>) + //~^ 46:23: 46:49: the parameter type `T` may not live long enough [E0309] } fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-enum-not-wf.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-enum-not-wf.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-enum-not-wf.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-enum-not-wf.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,64 +1,67 @@ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-enum-not-wf.rs:16:18 + --> $DIR/regions-enum-not-wf.rs:28:18 | LL | enum Ref1<'a, T> { | - help: consider adding an explicit lifetime bound `T: 'a`... -LL | Ref1Variant1(&'a T) //~ ERROR the parameter type `T` may not live long enough - | ^^^^^ +LL | Ref1Variant1(RequireOutlives<'a, T>) //~ ERROR the parameter type `T` may not live long enough + | ^^^^^^^^^^^^^^^^^^^^^^ | -note: ...so that the reference type `&'a T` does not outlive the data it points at - --> $DIR/regions-enum-not-wf.rs:16:18 +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-enum-not-wf.rs:28:18 | -LL | Ref1Variant1(&'a T) //~ ERROR the parameter type `T` may not live long enough - | ^^^^^ +LL | Ref1Variant1(RequireOutlives<'a, T>) //~ ERROR the parameter type `T` may not live long enough + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-enum-not-wf.rs:21:25 + --> $DIR/regions-enum-not-wf.rs:33:25 | LL | enum Ref2<'a, T> { | - help: consider adding an explicit lifetime bound `T: 'a`... LL | Ref2Variant1, -LL | Ref2Variant2(isize, &'a T), //~ ERROR the parameter type `T` may not live long enough - | ^^^^^ +LL | Ref2Variant2(isize, RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough + | ^^^^^^^^^^^^^^^^^^^^^^ | -note: ...so that the reference type `&'a T` does not outlive the data it points at - --> $DIR/regions-enum-not-wf.rs:21:25 +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-enum-not-wf.rs:33:25 | -LL | Ref2Variant2(isize, &'a T), //~ ERROR the parameter type `T` may not live long enough - | ^^^^^ +LL | Ref2Variant2(isize, RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-enum-not-wf.rs:29:32 + --> $DIR/regions-enum-not-wf.rs:45:1 | -LL | enum RefIndirect<'a, T> { - | - help: consider adding an explicit lifetime bound `T: 'a`... -LL | RefIndirectVariant1(isize, RefOk<'a,T>) - | ^^^^^^^^^^^ +LL | enum RefDouble<'a, 'b, T> { //~ ERROR 45:1: 48:2: the parameter type `T` may not live long enough [E0309] + | ^ - help: consider adding an explicit lifetime bound `T: 'b`... + | _| + | | +LL | | RefDoubleVariant1(&'a RequireOutlives<'b, T>) +LL | | //~^ 46:23: 46:49: the parameter type `T` may not live long enough [E0309] +LL | | } + | |_^ | note: ...so that the type `T` will meet its required lifetime bounds - --> $DIR/regions-enum-not-wf.rs:29:32 + --> $DIR/regions-enum-not-wf.rs:45:1 | -LL | RefIndirectVariant1(isize, RefOk<'a,T>) - | ^^^^^^^^^^^ +LL | / enum RefDouble<'a, 'b, T> { //~ ERROR 45:1: 48:2: the parameter type `T` may not live long enough [E0309] +LL | | RefDoubleVariant1(&'a RequireOutlives<'b, T>) +LL | | //~^ 46:23: 46:49: the parameter type `T` may not live long enough [E0309] +LL | | } + | |_^ -error[E0491]: in type `&'a &'b T`, reference has a longer lifetime than the data it references - --> $DIR/regions-enum-not-wf.rs:34:23 - | -LL | RefDoubleVariant1(&'a &'b T) - | ^^^^^^^^^ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-enum-not-wf.rs:46:23 | -note: the pointer is valid for the lifetime 'a as defined on the enum at 33:16 - --> $DIR/regions-enum-not-wf.rs:33:16 +LL | enum RefDouble<'a, 'b, T> { //~ ERROR 45:1: 48:2: the parameter type `T` may not live long enough [E0309] + | - help: consider adding an explicit lifetime bound `T: 'b`... +LL | RefDoubleVariant1(&'a RequireOutlives<'b, T>) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | -LL | enum RefDouble<'a, 'b, T> { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the enum at 33:20 - --> $DIR/regions-enum-not-wf.rs:33:20 +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-enum-not-wf.rs:46:23 | -LL | enum RefDouble<'a, 'b, T> { - | ^^ +LL | RefDoubleVariant1(&'a RequireOutlives<'b, T>) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors -Some errors occurred: E0309, E0491. -For more information about an error, try `rustc --explain E0309`. +For more information about this error, try `rustc --explain E0309`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-escape-method.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-escape-method.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-escape-method.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-escape-method.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-escape-method.rs:25:13 - | -LL | s.f(|p| p) //~ ERROR cannot infer - | -- ^ returning this value requires that `'1` must outlive `'2` - | || - | |return type of closure is &'2 i32 - | has type `&'1 i32` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-escape-via-trait-or-not.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-escape-via-trait-or-not.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-escape-via-trait-or-not.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-escape-via-trait-or-not.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-escape-via-trait-or-not.rs:28:14 - | -LL | with(|o| o) //~ ERROR cannot infer - | -- ^ returning this value requires that `'1` must outlive `'2` - | || - | |return type of closure is &'2 isize - | has type `&'1 isize` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-free-region-ordering-callee.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-free-region-ordering-callee.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-free-region-ordering-callee.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-free-region-ordering-callee.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-free-region-ordering-callee.rs:23:5 - | -LL | fn ordering2<'a, 'b>(x: &'a &'b usize, y: &'a usize) -> &'b usize { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | // However, it is not safe to assume that 'b <= 'a -LL | &*y //~ ERROR 23:5: 23:8: lifetime mismatch [E0623] - | ^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` - -error: unsatisfied lifetime constraints - --> $DIR/regions-free-region-ordering-callee.rs:28:24 - | -LL | fn ordering3<'a, 'b>(x: &'a usize, y: &'b usize) -> &'a &'b usize { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | // Do not infer an ordering from the return value. -LL | let z: &'b usize = &*x; - | ^^^ requires that `'a` must outlive `'b` - -error: aborting due to 2 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-free-region-ordering-caller1.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-free-region-ordering-caller1.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-free-region-ordering-caller1.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-free-region-ordering-caller1.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,18 +1,17 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/regions-free-region-ordering-caller1.rs:19:27 | +LL | fn call1<'a>(x: &'a usize) { + | -- lifetime `'a` defined here +... LL | let z: &'a & usize = &(&y); - | ^^^^ temporary value does not live long enough + | ----------- ^^^^ creates a temporary which is freed while still in use + | | + | type annotation requires that borrow lasts for `'a` ... LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 15:10... - --> $DIR/regions-free-region-ordering-caller1.rs:15:10 - | -LL | fn call1<'a>(x: &'a usize) { - | ^^ + | - temporary value is freed at the end of this statement error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-free-region-ordering-caller.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-free-region-ordering-caller.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-free-region-ordering-caller.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-free-region-ordering-caller.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - // Test various ways to construct a pointer with a longer lifetime // than the thing it points at and ensure that they result in // errors. See also regions-free-region-ordering-callee.rs diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-free-region-ordering-caller.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-free-region-ordering-caller.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-free-region-ordering-caller.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-free-region-ordering-caller.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/regions-free-region-ordering-caller.rs:20:12 + --> $DIR/regions-free-region-ordering-caller.rs:18:12 | LL | fn call2<'a, 'b>(a: &'a usize, b: &'b usize) { | --------- --------- @@ -9,7 +9,7 @@ | ^^^^^^^^^^^^^^^^^^^^^ ...but data from `a` flows into `b` here error[E0623]: lifetime mismatch - --> $DIR/regions-free-region-ordering-caller.rs:25:12 + --> $DIR/regions-free-region-ordering-caller.rs:23:12 | LL | fn call3<'a, 'b>(a: &'a usize, b: &'b usize) { | --------- --------- @@ -20,7 +20,7 @@ | ^^^^^^^^^^^^^^^^^^^^^^ ...but data from `a` flows into `b` here error[E0623]: lifetime mismatch - --> $DIR/regions-free-region-ordering-caller.rs:29:12 + --> $DIR/regions-free-region-ordering-caller.rs:27:12 | LL | fn call4<'a, 'b>(a: &'a usize, b: &'b usize) { | --------- --------- these two types are declared with different lifetimes... diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-free-region-ordering-incorrect.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-free-region-ordering-incorrect.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-free-region-ordering-incorrect.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-free-region-ordering-incorrect.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-free-region-ordering-incorrect.rs:25:5 - | -LL | impl<'b, T> Node<'b, T> { - | -- lifetime `'b` defined here -LL | fn get<'a>(&'a self) -> &'b T { - | -- lifetime `'a` defined here -LL | / match self.next { -LL | | Some(ref next) => next.get(), -LL | | None => &self.val //~ ERROR cannot infer -LL | | } - | |_____^ returning this value requires that `'a` must outlive `'b` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-implied-bounds-projection-gap-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-implied-bounds-projection-gap-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-implied-bounds-projection-gap-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-implied-bounds-projection-gap-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - // Illustrates the "projection gap": in this test, even though we know // that `T::Foo: 'x`, that does not tell us that `T: 'x`, because // there might be other ways for the caller of `func` to show that diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-implied-bounds-projection-gap-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-implied-bounds-projection-gap-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-implied-bounds-projection-gap-1.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-implied-bounds-projection-gap-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-implied-bounds-projection-gap-1.rs:28:10 + --> $DIR/regions-implied-bounds-projection-gap-1.rs:26:10 | LL | fn func<'x, T:Trait1<'x>>(t: &'x T::Foo) | -- help: consider adding an explicit lifetime bound `T: 'x`... @@ -8,7 +8,7 @@ | ^^^^^ | note: ...so that the reference type `&'x T` does not outlive the data it points at - --> $DIR/regions-implied-bounds-projection-gap-1.rs:28:10 + --> $DIR/regions-implied-bounds-projection-gap-1.rs:26:10 | LL | wf::<&'x T>(); | ^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-borrow-scope-too-big.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-borrow-scope-too-big.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-borrow-scope-too-big.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-borrow-scope-too-big.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,18 +1,12 @@ -error[E0597]: `*p` does not live long enough - --> $DIR/regions-infer-borrow-scope-too-big.rs:22:22 +error[E0515]: cannot return value referencing local data `*p` + --> $DIR/regions-infer-borrow-scope-too-big.rs:24:12 | LL | let xc = x_coord(&*p); //~ ERROR `*p` does not live long enough - | ^^^ borrowed value does not live long enough -... -LL | } - | - `*p` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 21:8... - --> $DIR/regions-infer-borrow-scope-too-big.rs:21:8 - | -LL | fn foo<'a>(p: Box) -> &'a isize { - | ^^ + | --- `*p` is borrowed here +LL | assert_eq!(*xc, 3); +LL | return xc; + | ^^ returns a value referencing data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-bound-from-trait.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-bound-from-trait.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-bound-from-trait.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-bound-from-trait.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -error[E0309]: the parameter type `A` may not live long enough - --> $DIR/regions-infer-bound-from-trait.rs:43:5 - | -LL | check_bound(x, a) //~ ERROR parameter type `A` may not live long enough - | ^^^^^^^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `A: 'a`... - -error[E0309]: the parameter type `A` may not live long enough - --> $DIR/regions-infer-bound-from-trait.rs:47:5 - | -LL | check_bound(x, a) //~ ERROR parameter type `A` may not live long enough - | ^^^^^^^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `A: 'a`... - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0309`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-bound-from-trait-self.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-bound-from-trait-self.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-bound-from-trait-self.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-bound-from-trait-self.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error[E0309]: the parameter type `Self` may not live long enough - --> $DIR/regions-infer-bound-from-trait-self.rs:56:9 - | -LL | check_bound(x, self) - | ^^^^^^^^^^^^^^^^^^^^ - | - = help: consider adding an explicit lifetime bound `Self: 'a`... - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0309`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-call-3.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-call-3.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-call-3.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-call-3.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-infer-call-3.rs:18:24 - | -LL | let z = with(|y| { select(x, y) }); - | -- ^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'2` - | || - | |return type of closure is &'2 isize - | has type `&'1 isize` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-contravariance-due-to-decl.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-contravariance-due-to-decl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-contravariance-due-to-decl.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-contravariance-due-to-decl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - // Test that a type which is contravariant with respect to its region // parameter yields an error when used in a covariant way. // diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-contravariance-due-to-decl.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-contravariance-due-to-decl.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-contravariance-due-to-decl.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-contravariance-due-to-decl.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/regions-infer-contravariance-due-to-decl.rs:37:35 + --> $DIR/regions-infer-contravariance-due-to-decl.rs:35:35 | LL | fn use_<'short,'long>(c: Contravariant<'short>, | --------------------- these two types are declared with different lifetimes... diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-covariance-due-to-decl.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-covariance-due-to-decl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-covariance-due-to-decl.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-covariance-due-to-decl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - // Test that a type which is covariant with respect to its region // parameter yields an error when used in a contravariant way. // diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-covariance-due-to-decl.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-covariance-due-to-decl.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-covariance-due-to-decl.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-covariance-due-to-decl.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/regions-infer-covariance-due-to-decl.rs:34:32 + --> $DIR/regions-infer-covariance-due-to-decl.rs:32:32 | LL | fn use_<'short,'long>(c: Covariant<'long>, | ---------------- diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-invariance-due-to-decl.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-invariance-due-to-decl.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-invariance-due-to-decl.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-invariance-due-to-decl.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-infer-invariance-due-to-decl.rs:22:5 - | -LL | fn to_longer_lifetime<'r>(b_isize: invariant<'r>) -> invariant<'static> { - | -- lifetime `'r` defined here -LL | b_isize //~ ERROR mismatched types - | ^^^^^^^ returning this value requires that `'r` must outlive `'static` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-invariance-due-to-mutability-3.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-infer-invariance-due-to-mutability-3.rs:21:5 - | -LL | fn to_longer_lifetime<'r>(b_isize: invariant<'r>) -> invariant<'static> { - | -- lifetime `'r` defined here -LL | b_isize //~ ERROR mismatched types - | ^^^^^^^ returning this value requires that `'r` must outlive `'static` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-invariance-due-to-mutability-4.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-infer-invariance-due-to-mutability-4.rs:21:5 - | -LL | fn to_longer_lifetime<'r>(b_isize: Invariant<'r>) -> Invariant<'static> { - | -- lifetime `'r` defined here -LL | b_isize //~ ERROR mismatched types - | ^^^^^^^ returning this value requires that `'r` must outlive `'static` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-not-param.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-not-param.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-not-param.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-not-param.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-infer-not-param.rs:25:54 - | -LL | fn take_direct<'a,'b>(p: direct<'a>) -> direct<'b> { p } //~ ERROR mismatched types - | -- -- lifetime `'b` defined here ^ returning this value requires that `'a` must outlive `'b` - | | - | lifetime `'a` defined here - -error: unsatisfied lifetime constraints - --> $DIR/regions-infer-not-param.rs:29:63 - | -LL | fn take_indirect2<'a,'b>(p: indirect2<'a>) -> indirect2<'b> { p } //~ ERROR mismatched types - | -- -- lifetime `'b` defined here ^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` - | | - | lifetime `'a` defined here - -error: unsatisfied lifetime constraints - --> $DIR/regions-infer-not-param.rs:29:63 - | -LL | fn take_indirect2<'a,'b>(p: indirect2<'a>) -> indirect2<'b> { p } //~ ERROR mismatched types - | -- -- lifetime `'b` defined here ^ returning this value requires that `'a` must outlive `'b` - | | - | lifetime `'a` defined here - -error: aborting due to 3 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-paramd-indirect.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-paramd-indirect.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-paramd-indirect.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-paramd-indirect.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: borrowed data escapes outside of function - --> $DIR/regions-infer-paramd-indirect.rs:33:9 - | -LL | fn set_f_bad(&mut self, b: Box) { - | --------- - `b` is a reference that is only valid in the function body - | | - | `self` is declared here, outside of the function body -LL | self.f = b; - | ^^^^^^ `b` escapes the function body here - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-proc-static-upvar.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-proc-static-upvar.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-infer-proc-static-upvar.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-infer-proc-static-upvar.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,13 +1,14 @@ error[E0597]: `x` does not live long enough --> $DIR/regions-infer-proc-static-upvar.rs:20:13 | -LL | let y = &x; //~ ERROR `x` does not live long enough - | ^^ borrowed value does not live long enough -... -LL | } - | - `x` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... +LL | let y = &x; //~ ERROR `x` does not live long enough + | ^^ borrowed value does not live long enough +LL | / foo(move|| { +LL | | let _a = *y; +LL | | }); + | |______- argument requires that `x` is borrowed for `'static` +LL | } + | - `x` dropped here while still borrowed error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-lifetime-bounds-on-fns.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-lifetime-bounds-on-fns.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-lifetime-bounds-on-fns.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-lifetime-bounds-on-fns.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/regions-lifetime-bounds-on-fns.rs:30:43 - | -LL | let _: fn(&mut &isize, &mut &isize) = a; //~ ERROR mismatched types - | ^ expected concrete lifetime, found bound lifetime parameter - | - = note: expected type `for<'r, 's, 't0, 't1> fn(&'r mut &'s isize, &'t0 mut &'t1 isize)` - found type `for<'r, 's> fn(&'r mut &isize, &'s mut &isize) {a::<'_, '_>}` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-lifetime-of-struct-or-enum-variant.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +error[E0515]: cannot return value referencing temporary value + --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:26:3 + | +LL | let testValue = &id(Test); + | -------- temporary value created here +LL | //~^ ERROR borrowed value does not live long enough +LL | testValue + | ^^^^^^^^^ returns a value referencing data owned by the current function + +error[E0515]: cannot return value referencing temporary value + --> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:32:3 + | +LL | let testValue = &id(MyEnum::Variant1); + | -------------------- temporary value created here +LL | //~^ ERROR borrowed value does not live long enough +LL | testValue + | ^^^^^^^^^ returns a value referencing data owned by the current function + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-nested-fns-2.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-nested-fns-2.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-nested-fns-2.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-nested-fns-2.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -5,12 +5,13 @@ | --- value captured here LL | //~^ ERROR E0373 LL | if false { &y } else { z } - | ^ borrowed value does not live long enough + | -^ + | || + | |borrowed value does not live long enough + | returning this value requires that `y` is borrowed for `'static` LL | }); LL | } | - `y` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-nested-fns.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-nested-fns.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-nested-fns.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-nested-fns.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-nested-fns.rs:20:9 - | -LL | let mut ay = &y; //~ ERROR E0495 - | ------ lifetime `'2` appears in the type of `ay` -LL | -LL | ignore:: FnMut(&'z isize)>>(Box::new(|z| { - | - has type `&'1 isize` -... -LL | ay = z; - | ^^^^^^ requires that `'1` must outlive `'2` - -error: unsatisfied lifetime constraints - --> $DIR/regions-nested-fns.rs:14:9 - | -LL | fn nested<'x>(x: &'x isize) { - | -- lifetime `'x` defined here -LL | let y = 3; - | ^ requires that `'x` must outlive `'static` - -error[E0597]: `y` does not live long enough - --> $DIR/regions-nested-fns.rs:15:18 - | -LL | let mut ay = &y; //~ ERROR E0495 - | ^^ borrowed value does not live long enough -... -LL | } - | - `y` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... - -error[E0597]: `y` does not live long enough - --> $DIR/regions-nested-fns.rs:19:15 - | -LL | ignore:: FnMut(&'z isize)>>(Box::new(|z| { - | --- value captured here -LL | ay = x; -LL | ay = &y; - | ^ borrowed value does not live long enough -... -LL | } - | - `y` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0597`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-region-rev.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-region-rev.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-region-rev.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-region-rev.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,6 +13,8 @@ // // Rule OutlivesNominalType from RFC 1214. +// compile-pass + #![feature(rustc_attrs)] #![allow(dead_code)] @@ -21,9 +23,8 @@ x: fn(&'a i32), } enum Bar<'a,'b> { - V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime + V(&'a Foo<'b>) } } -#[rustc_error] fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-region-rev.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-region-rev.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-region-rev.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-region-rev.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a rev_variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-enum-region-rev.rs:24:11 - | -LL | V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime - | ^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the enum at 23:14 - --> $DIR/regions-outlives-nominal-type-enum-region-rev.rs:23:14 - | -LL | enum Bar<'a,'b> { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the enum at 23:17 - --> $DIR/regions-outlives-nominal-type-enum-region-rev.rs:23:17 - | -LL | enum Bar<'a,'b> { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-region.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-region.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-region.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-region.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,6 +13,8 @@ // // Rule OutlivesNominalType from RFC 1214. +// compile-pass + #![feature(rustc_attrs)] #![allow(dead_code)] @@ -21,9 +23,8 @@ x: &'a i32, } enum Bar<'a,'b> { - V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime + V(&'a Foo<'b>) } } -#[rustc_error] fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-region.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-region.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-region.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-region.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-enum-region.rs:24:11 - | -LL | V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime - | ^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the enum at 23:14 - --> $DIR/regions-outlives-nominal-type-enum-region.rs:23:14 - | -LL | enum Bar<'a,'b> { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the enum at 23:17 - --> $DIR/regions-outlives-nominal-type-enum-region.rs:23:17 - | -LL | enum Bar<'a,'b> { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,17 +13,18 @@ // // Rule OutlivesNominalType from RFC 1214. +//compile-pass + #![feature(rustc_attrs)] #![allow(dead_code)] -mod rev_variant_struct_type { +mod variant_struct_type { struct Foo { x: fn(T) } enum Bar<'a,'b> { - V(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime + V(&'a Foo<&'b i32>) } } -#[rustc_error] fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a rev_variant_struct_type::Foo<&'b i32>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-enum-type-rev.rs:24:11 - | -LL | V(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime - | ^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the enum at 23:14 - --> $DIR/regions-outlives-nominal-type-enum-type-rev.rs:23:14 - | -LL | enum Bar<'a,'b> { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the enum at 23:17 - --> $DIR/regions-outlives-nominal-type-enum-type-rev.rs:23:17 - | -LL | enum Bar<'a,'b> { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-type.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,6 +13,8 @@ // // Rule OutlivesNominalType from RFC 1214. +// compile-pass + #![feature(rustc_attrs)] #![allow(dead_code)] @@ -21,9 +23,8 @@ x: T } enum Bar<'a,'b> { - F(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime + V(&'a Foo<&'b i32>) } } -#[rustc_error] fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-type.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-type.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-type.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-enum-type.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a variant_struct_type::Foo<&'b i32>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-enum-type.rs:24:11 - | -LL | F(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime - | ^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the enum at 23:14 - --> $DIR/regions-outlives-nominal-type-enum-type.rs:23:14 - | -LL | enum Bar<'a,'b> { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the enum at 23:17 - --> $DIR/regions-outlives-nominal-type-enum-type.rs:23:17 - | -LL | enum Bar<'a,'b> { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-region-rev.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-region-rev.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-region-rev.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-region-rev.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,6 +13,8 @@ // // Rule OutlivesNominalType from RFC 1214. +// compile-pass + #![feature(rustc_attrs)] #![allow(dead_code)] @@ -21,9 +23,8 @@ x: fn(&'a i32), } struct Bar<'a,'b> { - f: &'a Foo<'b> //~ ERROR reference has a longer lifetime + f: &'a Foo<'b> } } -#[rustc_error] fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-region-rev.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-region-rev.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-region-rev.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-region-rev.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a rev_variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-struct-region-rev.rs:24:9 - | -LL | f: &'a Foo<'b> //~ ERROR reference has a longer lifetime - | ^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the struct at 23:16 - --> $DIR/regions-outlives-nominal-type-struct-region-rev.rs:23:16 - | -LL | struct Bar<'a,'b> { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 23:19 - --> $DIR/regions-outlives-nominal-type-struct-region-rev.rs:23:19 - | -LL | struct Bar<'a,'b> { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-region.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-region.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-region.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-region.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,6 +13,8 @@ // // Rule OutlivesNominalType from RFC 1214. +// compile-pass + #![feature(rustc_attrs)] #![allow(dead_code)] @@ -25,5 +27,4 @@ } } -#[rustc_error] fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-region.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-region.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-region.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-region.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-struct-region.rs:24:9 - | -LL | f: &'a Foo<'b> //~ ERROR reference has a longer lifetime - | ^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the struct at 23:16 - --> $DIR/regions-outlives-nominal-type-struct-region.rs:23:16 - | -LL | struct Bar<'a,'b> { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 23:19 - --> $DIR/regions-outlives-nominal-type-struct-region.rs:23:19 - | -LL | struct Bar<'a,'b> { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-type-rev.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-type-rev.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-type-rev.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-type-rev.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,6 +13,8 @@ // // Rule OutlivesNominalType from RFC 1214. +// compile-pass + #![feature(rustc_attrs)] #![allow(dead_code)] @@ -25,5 +27,4 @@ } } -#[rustc_error] fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-type-rev.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-type-rev.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-type-rev.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-type-rev.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a rev_variant_struct_type::Foo<&'b i32>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-struct-type-rev.rs:24:9 - | -LL | f: &'a Foo<&'b i32> //~ ERROR reference has a longer lifetime - | ^^^^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the struct at 23:16 - --> $DIR/regions-outlives-nominal-type-struct-type-rev.rs:23:16 - | -LL | struct Bar<'a,'b> { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 23:19 - --> $DIR/regions-outlives-nominal-type-struct-type-rev.rs:23:19 - | -LL | struct Bar<'a,'b> { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-type.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -13,6 +13,8 @@ // // Rule OutlivesNominalType from RFC 1214. +// compile-pass + #![feature(rustc_attrs)] #![allow(dead_code)] @@ -25,5 +27,4 @@ } } -#[rustc_error] fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-type.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-type.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-type.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-nominal-type-struct-type.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a variant_struct_type::Foo<&'b i32>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-struct-type.rs:24:9 - | -LL | f: &'a Foo<&'b i32> //~ ERROR reference has a longer lifetime - | ^^^^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the struct at 23:16 - --> $DIR/regions-outlives-nominal-type-struct-type.rs:23:16 - | -LL | struct Bar<'a,'b> { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 23:19 - --> $DIR/regions-outlives-nominal-type-struct-type.rs:23:19 - | -LL | struct Bar<'a,'b> { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-projection-container-hrtb.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-projection-container-hrtb.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-projection-container-hrtb.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-projection-container-hrtb.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -error: compilation successful - --> $DIR/regions-outlives-projection-container-hrtb.rs:68:1 - | -LL | / fn main() { -LL | | } - | |_^ - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-projection-container.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-projection-container.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-projection-container.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-projection-container.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,14 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - // Test that we are imposing the requirement that every associated // type of a bound that appears in the where clause on a struct must // outlive the location in which the type appears. Issue #22246. -// ignore-compare-mode-nll - #![allow(dead_code)] #![feature(rustc_attrs)] @@ -49,7 +45,10 @@ // outlive 'a. In this case, that means TheType<'b>::TheAssocType, // which is &'b (), must outlive 'a. - let _: &'a WithAssoc> = loop { }; //~ ERROR reference has a longer lifetime + // FIXME (#54943) NLL doesn't enforce WF condition in unreachable code if + // `_x` is changed to `_` + let _x: &'a WithAssoc> = loop { }; + //~^ ERROR reference has a longer lifetime } fn with_assoc1<'a,'b>() where 'b : 'a { @@ -59,14 +58,15 @@ // which is &'b (), must outlive 'a, so 'b : 'a must hold, and // that is in the where clauses, so we're fine. - let _: &'a WithAssoc> = loop { }; + let _x: &'a WithAssoc> = loop { }; } fn without_assoc<'a,'b>() { // Here there are no associated types but there is a requirement // that `'b:'a` holds because the `'b` appears in `TheType<'b>`. - let _: &'a WithoutAssoc> = loop { }; //~ ERROR reference has a longer lifetime + let _x: &'a WithoutAssoc> = loop { }; + //~^ ERROR reference has a longer lifetime } fn call_with_assoc<'a,'b>() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-projection-container.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-projection-container.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-projection-container.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-projection-container.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,33 +1,33 @@ error[E0491]: in type `&'a WithAssoc>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-projection-container.rs:52:12 + --> $DIR/regions-outlives-projection-container.rs:50:13 | -LL | let _: &'a WithAssoc> = loop { }; //~ ERROR reference has a longer lifetime - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let _x: &'a WithAssoc> = loop { }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | -note: the pointer is valid for the lifetime 'a as defined on the function body at 46:15 - --> $DIR/regions-outlives-projection-container.rs:46:15 +note: the pointer is valid for the lifetime 'a as defined on the function body at 42:15 + --> $DIR/regions-outlives-projection-container.rs:42:15 | LL | fn with_assoc<'a,'b>() { | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 46:18 - --> $DIR/regions-outlives-projection-container.rs:46:18 +note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 42:18 + --> $DIR/regions-outlives-projection-container.rs:42:18 | LL | fn with_assoc<'a,'b>() { | ^^ error[E0491]: in type `&'a WithoutAssoc>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-projection-container.rs:69:12 + --> $DIR/regions-outlives-projection-container.rs:68:13 | -LL | let _: &'a WithoutAssoc> = loop { }; //~ ERROR reference has a longer lifetime - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let _x: &'a WithoutAssoc> = loop { }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -note: the pointer is valid for the lifetime 'a as defined on the function body at 65:18 - --> $DIR/regions-outlives-projection-container.rs:65:18 +note: the pointer is valid for the lifetime 'a as defined on the function body at 64:18 + --> $DIR/regions-outlives-projection-container.rs:64:18 | LL | fn without_assoc<'a,'b>() { | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 65:21 - --> $DIR/regions-outlives-projection-container.rs:65:21 +note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 64:21 + --> $DIR/regions-outlives-projection-container.rs:64:21 | LL | fn without_assoc<'a,'b>() { | ^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-projection-container-wc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-projection-container-wc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-projection-container-wc.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-projection-container-wc.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - // Test that we are imposing the requirement that every associated // type of a bound that appears in the where clause on a struct must // outlive the location in which the type appears, even when the @@ -43,7 +41,9 @@ // outlive 'a. In this case, that means TheType<'b>::TheAssocType, // which is &'b (), must outlive 'a. - let _: &'a WithAssoc> = loop { }; + // FIXME (#54943) NLL doesn't enforce WF condition in unreachable code if + // `_x` is changed to `_` + let _x: &'a WithAssoc> = loop { }; //~^ ERROR reference has a longer lifetime } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-projection-container-wc.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-projection-container-wc.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-projection-container-wc.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-outlives-projection-container-wc.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,16 +1,16 @@ error[E0491]: in type `&'a WithAssoc>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-projection-container-wc.rs:46:12 + --> $DIR/regions-outlives-projection-container-wc.rs:46:13 | -LL | let _: &'a WithAssoc> = loop { }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let _x: &'a WithAssoc> = loop { }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | -note: the pointer is valid for the lifetime 'a as defined on the function body at 40:15 - --> $DIR/regions-outlives-projection-container-wc.rs:40:15 +note: the pointer is valid for the lifetime 'a as defined on the function body at 38:15 + --> $DIR/regions-outlives-projection-container-wc.rs:38:15 | LL | fn with_assoc<'a,'b>() { | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 40:18 - --> $DIR/regions-outlives-projection-container-wc.rs:40:18 +note: but the referenced data is only valid for the lifetime 'b as defined on the function body at 38:18 + --> $DIR/regions-outlives-projection-container-wc.rs:38:18 | LL | fn with_assoc<'a,'b>() { | ^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-pattern-typing-issue-19552.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-pattern-typing-issue-19552.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-pattern-typing-issue-19552.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-pattern-typing-issue-19552.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -3,11 +3,11 @@ | LL | match [&*line] { //~ ERROR `line` does not live long enough | ^^^^ borrowed value does not live long enough -... +LL | [ word ] => { assert_static(word); } + | ------------------- argument requires that `line` is borrowed for `'static` +LL | } LL | } | - `line` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref-mut-ref.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-reborrow-from-shorter-mut-ref-mut-ref.rs:14:5 - | -LL | fn copy_borrowed_ptr<'a, 'b, 'c>(p: &'a mut &'b mut &'c mut isize) -> &'b mut isize { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | &mut ***p //~ ERROR 14:5: 14:14: lifetime mismatch [E0623] - | ^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-reborrow-from-shorter-mut-ref.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-reborrow-from-shorter-mut-ref.rs:16:5 - | -LL | fn copy_borrowed_ptr<'a, 'b>(p: &'a mut &'b mut isize) -> &'b mut isize { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | &mut **p //~ ERROR 16:5: 16:13: lifetime mismatch [E0623] - | ^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-ref-in-fn-arg.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-ref-in-fn-arg.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-ref-in-fn-arg.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-ref-in-fn-arg.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,22 +1,19 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/regions-ref-in-fn-arg.rs:14:13 +error[E0515]: cannot return value referencing function parameter + --> $DIR/regions-ref-in-fn-arg.rs:15:5 | LL | fn arg_item(box ref x: Box) -> &'static isize { - | ^^^^^^^^^ temporary value does not live long enough + | --------- function parameter borrowed here LL | x //~^ ERROR borrowed value does not live long enough -LL | } - | - temporary value only lives until here - | - = note: borrowed value must be valid for the static lifetime... + | ^ returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/regions-ref-in-fn-arg.rs:21:11 +error[E0515]: cannot return value referencing function parameter + --> $DIR/regions-ref-in-fn-arg.rs:21:22 | LL | with(|box ref x| x) //~ ERROR borrowed value does not live long enough - | ^^^^^^^^^ - temporary value only lives until here + | --------- ^ returns a value referencing data owned by the current function | | - | temporary value does not live long enough + | function parameter borrowed here error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-ret-borrowed-1.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-ret-borrowed-1.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-ret-borrowed-1.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-ret-borrowed-1.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-ret-borrowed-1.rs:20:14 - | -LL | with(|o| o) - | -- ^ returning this value requires that `'1` must outlive `'2` - | || - | |return type of closure is &'2 isize - | has type `&'1 isize` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-ret-borrowed.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-ret-borrowed.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-ret-borrowed.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-ret-borrowed.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-ret-borrowed.rs:23:14 - | -LL | with(|o| o) - | -- ^ returning this value requires that `'1` must outlive `'2` - | || - | |return type of closure is &'2 isize - | has type `&'1 isize` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-ret.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-ret.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-ret.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-ret.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,19 +1,12 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/regions-ret.rs:14:13 +error[E0515]: cannot return reference to temporary value + --> $DIR/regions-ret.rs:14:12 | LL | return &id(3); //~ ERROR borrowed value does not live long enough - | ^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 13:1... - --> $DIR/regions-ret.rs:13:1 - | -LL | / fn f(_x: &isize) -> &isize { -LL | | return &id(3); //~ ERROR borrowed value does not live long enough -LL | | } - | |_^ + | ^----- + | || + | |temporary value created here + | returns a reference to data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-return-ref-to-upvar-issue-17403.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-return-ref-to-upvar-issue-17403.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-return-ref-to-upvar-issue-17403.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-return-ref-to-upvar-issue-17403.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-return-ref-to-upvar-issue-17403.rs:17:24 - | -LL | let mut f = || &mut x; //~ ERROR cannot infer - | -- ^^^^^^ returning this value requires that `'1` must outlive `'2` - | || - | |return type of closure is &'2 mut i32 - | lifetime `'1` represents this closure's body - | - = note: closure implements `FnMut`, so references to captured variables can't escape the closure - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-return-stack-allocated-vec.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-return-stack-allocated-vec.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-return-stack-allocated-vec.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-return-stack-allocated-vec.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +error[E0515]: cannot return reference to temporary value + --> $DIR/regions-return-stack-allocated-vec.rs:14:5 + | +LL | &[x] //~ ERROR borrowed value does not live long enough + | ^--- + | || + | |temporary value created here + | returns a reference to data owned by the current function + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-static-bound.ll.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-static-bound.ll.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-static-bound.ll.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-static-bound.ll.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-static-bound.rs:19:5 - | -LL | fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a { - | -- lifetime `'a` defined here -LL | t //[ll]~ ERROR E0312 - | ^ returning this value requires that `'a` must outlive `'static` - -error[E0621]: explicit lifetime required in the type of `u` - --> $DIR/regions-static-bound.rs:24:5 - | -LL | fn error(u: &(), v: &()) { - | --- help: add explicit lifetime `'static` to the type of `u`: `&'static ()` -LL | static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of `u` [E0621] - | ^^^^^^^^^^^^^ lifetime `'static` required - -error[E0621]: explicit lifetime required in the type of `v` - --> $DIR/regions-static-bound.rs:27:5 - | -LL | fn error(u: &(), v: &()) { - | --- help: add explicit lifetime `'static` to the type of `v`: `&'static ()` -... -LL | static_id_indirect(&v); //[ll]~ ERROR explicit lifetime required in the type of `v` [E0621] - | ^^^^^^^^^^^^^^^^^^^^^^ lifetime `'static` required - -error: unsatisfied lifetime constraints - --> $DIR/regions-static-bound.rs:24:5 - | -LL | fn error(u: &(), v: &()) { - | - - let's call the lifetime of this reference `'2` - | | - | let's call the lifetime of this reference `'1` -LL | static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of `u` [E0621] - | ^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` - -error: unsatisfied lifetime constraints - --> $DIR/regions-static-bound.rs:27:5 - | -LL | fn error(u: &(), v: &()) { - | - - let's call the lifetime of this reference `'1` - | | - | let's call the lifetime of this reference `'2` -... -LL | static_id_indirect(&v); //[ll]~ ERROR explicit lifetime required in the type of `v` [E0621] - | ^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0621`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-static-bound.ll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-static-bound.ll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-static-bound.ll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-static-bound.ll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -20,7 +20,7 @@ | ^^^^^^^^^ lifetime `'static` required error[E0621]: explicit lifetime required in the type of `v` - --> $DIR/regions-static-bound.rs:27:5 + --> $DIR/regions-static-bound.rs:26:5 | LL | fn error(u: &(), v: &()) { | --- help: add explicit lifetime `'static` to the type of `v`: `&'static ()` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-static-bound.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-static-bound.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-static-bound.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-static-bound.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -15,7 +15,7 @@ | ^^^^^^^^^^^^^ lifetime `'static` required error[E0621]: explicit lifetime required in the type of `v` - --> $DIR/regions-static-bound.rs:27:5 + --> $DIR/regions-static-bound.rs:26:5 | LL | fn error(u: &(), v: &()) { | --- help: add explicit lifetime `'static` to the type of `v`: `&'static ()` @@ -23,27 +23,6 @@ LL | static_id_indirect(&v); //[ll]~ ERROR explicit lifetime required in the type of `v` [E0621] | ^^^^^^^^^^^^^^^^^^^^^^ lifetime `'static` required -error: unsatisfied lifetime constraints - --> $DIR/regions-static-bound.rs:24:5 - | -LL | fn error(u: &(), v: &()) { - | - - let's call the lifetime of this reference `'2` - | | - | let's call the lifetime of this reference `'1` -LL | static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of `u` [E0621] - | ^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` - -error: unsatisfied lifetime constraints - --> $DIR/regions-static-bound.rs:27:5 - | -LL | fn error(u: &(), v: &()) { - | - - let's call the lifetime of this reference `'1` - | | - | let's call the lifetime of this reference `'2` -... -LL | static_id_indirect(&v); //[ll]~ ERROR explicit lifetime required in the type of `v` [E0621] - | ^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` - -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0621`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-static-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-static-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-static-bound.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-static-bound.rs 2018-12-04 23:41:40.000000000 +0000 @@ -23,10 +23,8 @@ fn error(u: &(), v: &()) { static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of `u` [E0621] //[nll]~^ ERROR explicit lifetime required in the type of `u` [E0621] - //[nll]~| ERROR unsatisfied lifetime constraints static_id_indirect(&v); //[ll]~ ERROR explicit lifetime required in the type of `v` [E0621] //[nll]~^ ERROR explicit lifetime required in the type of `v` [E0621] - //[nll]~| ERROR unsatisfied lifetime constraints } fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-steal-closure.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-steal-closure.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-steal-closure.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-steal-closure.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,14 +1,15 @@ error[E0597]: `i` does not live long enough --> $DIR/regions-steal-closure.rs:24:28 | +LL | let mut cl_box = { + | ---------- borrow later stored here +LL | let mut i = 3; LL | box_it(Box::new(|| i += 1)) //~ ERROR `i` does not live long enough | -- ^ borrowed value does not live long enough | | | value captured here LL | }; | - `i` dropped here while still borrowed -LL | cl_box.cl.call_mut(()); - | --------- borrow later used here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-struct-not-wf.lexical.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-struct-not-wf.lexical.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-struct-not-wf.lexical.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-struct-not-wf.lexical.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-struct-not-wf.rs:19:5 - | -LL | struct Ref<'a, T> { - | - help: consider adding an explicit lifetime bound `T: 'a`... -LL | field: &'a T - | ^^^^^^^^^^^^ - | -note: ...so that the reference type `&'a T` does not outlive the data it points at - --> $DIR/regions-struct-not-wf.rs:19:5 - | -LL | field: &'a T - | ^^^^^^^^^^^^ - -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-struct-not-wf.rs:29:5 - | -LL | struct RefIndirect<'a, T> { - | - help: consider adding an explicit lifetime bound `T: 'a`... -LL | field: RefOk<'a, T> - | ^^^^^^^^^^^^^^^^^^^ - | -note: ...so that the type `T` will meet its required lifetime bounds - --> $DIR/regions-struct-not-wf.rs:29:5 - | -LL | field: RefOk<'a, T> - | ^^^^^^^^^^^^^^^^^^^ - -error[E0491]: in type `&'a &'b T`, reference has a longer lifetime than the data it references - --> $DIR/regions-struct-not-wf.rs:35:5 - | -LL | field: &'a &'b T - | ^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the struct at 34:18 - --> $DIR/regions-struct-not-wf.rs:34:18 - | -LL | struct DoubleRef<'a, 'b, T> { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 34:22 - --> $DIR/regions-struct-not-wf.rs:34:22 - | -LL | struct DoubleRef<'a, 'b, T> { - | ^^ - -error: aborting due to 3 previous errors - -Some errors occurred: E0309, E0491. -For more information about an error, try `rustc --explain E0309`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-struct-not-wf.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-struct-not-wf.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-struct-not-wf.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-struct-not-wf.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-struct-not-wf.rs:19:5 - | -LL | struct Ref<'a, T> { - | - help: consider adding an explicit lifetime bound `T: 'a`... -LL | field: &'a T - | ^^^^^^^^^^^^ - | -note: ...so that the reference type `&'a T` does not outlive the data it points at - --> $DIR/regions-struct-not-wf.rs:19:5 - | -LL | field: &'a T - | ^^^^^^^^^^^^ - -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-struct-not-wf.rs:29:5 - | -LL | struct RefIndirect<'a, T> { - | - help: consider adding an explicit lifetime bound `T: 'a`... -LL | field: RefOk<'a, T> - | ^^^^^^^^^^^^^^^^^^^ - | -note: ...so that the type `T` will meet its required lifetime bounds - --> $DIR/regions-struct-not-wf.rs:29:5 - | -LL | field: RefOk<'a, T> - | ^^^^^^^^^^^^^^^^^^^ - -error[E0491]: in type `&'a &'b T`, reference has a longer lifetime than the data it references - --> $DIR/regions-struct-not-wf.rs:35:5 - | -LL | field: &'a &'b T - | ^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the struct at 34:18 - --> $DIR/regions-struct-not-wf.rs:34:18 - | -LL | struct DoubleRef<'a, 'b, T> { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 34:22 - --> $DIR/regions-struct-not-wf.rs:34:22 - | -LL | struct DoubleRef<'a, 'b, T> { - | ^^ - -error: aborting due to 3 previous errors - -Some errors occurred: E0309, E0491. -For more information about an error, try `rustc --explain E0309`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-struct-not-wf.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-struct-not-wf.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-struct-not-wf.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-struct-not-wf.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,31 +10,29 @@ // Various examples of structs whose fields are not well-formed. -// revisions:lexical nll - #![allow(dead_code)] -#![cfg_attr(nll, feature(nll))] -struct Ref<'a, T> { - field: &'a T - //[lexical]~^ ERROR the parameter type `T` may not live long enough - //[nll]~^^ ERROR the parameter type `T` may not live long enough +trait Trait<'a, T> { + type Out; +} +trait Trait1<'a, 'b, T> { + type Out; +} + +impl<'a, T> Trait<'a, T> for usize { + type Out = &'a T; } struct RefOk<'a, T:'a> { field: &'a T } -struct RefIndirect<'a, T> { - field: RefOk<'a, T> - //[lexical]~^ ERROR the parameter type `T` may not live long enough - //[nll]~^^ ERROR the parameter type `T` may not live long enough +impl<'a, T> Trait<'a, T> for u32 { + type Out = RefOk<'a, T>; } -struct DoubleRef<'a, 'b, T> { - field: &'a &'b T - //[lexical]~^ ERROR reference has a longer lifetime than the data it references - //[nll]~^^ ERROR reference has a longer lifetime than the data it references +impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 { + type Out = &'a &'b T; } fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-struct-not-wf.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-struct-not-wf.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-struct-not-wf.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-struct-not-wf.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,49 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-struct-not-wf.rs:23:5 + | +LL | impl<'a, T> Trait<'a, T> for usize { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | type Out = &'a T; + | ^^^^^^^^^^^^^^^^^ + | +note: ...so that the reference type `&'a T` does not outlive the data it points at + --> $DIR/regions-struct-not-wf.rs:23:5 + | +LL | type Out = &'a T; + | ^^^^^^^^^^^^^^^^^ + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-struct-not-wf.rs:31:5 + | +LL | impl<'a, T> Trait<'a, T> for u32 { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | type Out = RefOk<'a, T>; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-struct-not-wf.rs:31:5 + | +LL | type Out = RefOk<'a, T>; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0491]: in type `&'a &'b T`, reference has a longer lifetime than the data it references + --> $DIR/regions-struct-not-wf.rs:35:5 + | +LL | type Out = &'a &'b T; + | ^^^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the impl at 34:6 + --> $DIR/regions-struct-not-wf.rs:34:6 + | +LL | impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the impl at 34:10 + --> $DIR/regions-struct-not-wf.rs:34:10 + | +LL | impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 { + | ^^ + +error: aborting due to 3 previous errors + +Some errors occurred: E0309, E0491. +For more information about an error, try `rustc --explain E0309`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-trait-object-subtyping.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/regions-trait-object-subtyping.rs:25:5 - | -LL | fn foo3<'a,'b>(x: &'a mut Dummy) -> &'b mut Dummy { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | // Without knowing 'a:'b, we can't coerce -LL | x //~ ERROR lifetime bound not satisfied - | ^ returning this value requires that `'a` must outlive `'b` - -error: unsatisfied lifetime constraints - --> $DIR/regions-trait-object-subtyping.rs:32:5 - | -LL | fn foo4<'a:'b,'b>(x: Wrapper<&'a mut Dummy>) -> Wrapper<&'b mut Dummy> { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | // We can't coerce because it is packed in `Wrapper` -LL | x //~ ERROR mismatched types - | ^ returning this value requires that `'b` must outlive `'a` - -error: aborting due to 2 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-trait-object-subtyping.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-trait-object-subtyping.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-trait-object-subtyping.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-trait-object-subtyping.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -26,7 +26,7 @@ | LL | fn foo3<'a,'b>(x: &'a mut Dummy) -> &'b mut Dummy { | ^^ -note: ...so that the type `(dyn Dummy + 'a)` is not borrowed for too long +note: ...so that reference does not outlive borrowed content --> $DIR/regions-trait-object-subtyping.rs:25:5 | LL | x //~ ERROR lifetime bound not satisfied diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-trait-variance.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-trait-variance.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-trait-variance.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-trait-variance.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,18 +1,11 @@ -error[E0597]: `*b` does not live long enough - --> $DIR/regions-trait-variance.rs:47:18 +error[E0515]: cannot return value referencing local data `*b` + --> $DIR/regions-trait-variance.rs:48:5 | LL | let bb: &B = &*b; //~ ERROR `*b` does not live long enough - | ^^^ borrowed value does not live long enough + | --- `*b` is borrowed here LL | make_a(bb) -LL | } - | - `*b` dropped here while still borrowed - | -note: borrowed value must be valid for the lifetime 'a as defined on the function body at 43:16... - --> $DIR/regions-trait-variance.rs:43:16 - | -LL | fn make_make_a<'a>() -> A<'a> { - | ^^ + | ^^^^^^^^^^ returns a value referencing data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - // Test that a type which is covariant with respect to its region // parameter yields an error when used in a contravariant way. // diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/regions-variance-contravariant-use-covariant-in-second-position.rs:37:30 + --> $DIR/regions-variance-contravariant-use-covariant-in-second-position.rs:35:30 | LL | fn use_<'short,'long>(c: S<'long, 'short>, | ---------------- diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-variance-contravariant-use-covariant.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-variance-contravariant-use-covariant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-variance-contravariant-use-covariant.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-variance-contravariant-use-covariant.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - // Test that a type which is covariant with respect to its region // parameter yields an error when used in a contravariant way. // diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-variance-contravariant-use-covariant.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-variance-contravariant-use-covariant.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-variance-contravariant-use-covariant.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-variance-contravariant-use-covariant.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/regions-variance-contravariant-use-covariant.rs:35:35 + --> $DIR/regions-variance-contravariant-use-covariant.rs:33:35 | LL | fn use_<'short,'long>(c: Contravariant<'short>, | --------------------- these two types are declared with different lifetimes... diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-variance-covariant-use-contravariant.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-variance-covariant-use-contravariant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-variance-covariant-use-contravariant.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-variance-covariant-use-contravariant.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - // Test that a type which is covariant with respect to its region // parameter yields an error when used in a contravariant way. // diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-variance-covariant-use-contravariant.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-variance-covariant-use-contravariant.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-variance-covariant-use-contravariant.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-variance-covariant-use-contravariant.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/regions-variance-covariant-use-contravariant.rs:35:32 + --> $DIR/regions-variance-covariant-use-contravariant.rs:33:32 | LL | fn use_<'short,'long>(c: Covariant<'long>, | ---------------- diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-variance-invariant-use-contravariant.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-variance-invariant-use-contravariant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-variance-invariant-use-contravariant.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-variance-invariant-use-contravariant.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - // Test that an invariant region parameter used in a contravariant way // yields an error. // diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-variance-invariant-use-contravariant.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-variance-invariant-use-contravariant.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-variance-invariant-use-contravariant.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-variance-invariant-use-contravariant.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/regions-variance-invariant-use-contravariant.rs:32:32 + --> $DIR/regions-variance-invariant-use-contravariant.rs:30:32 | LL | fn use_<'short,'long>(c: Invariant<'long>, | ---------------- diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-variance-invariant-use-covariant.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-variance-invariant-use-covariant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-variance-invariant-use-covariant.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-variance-invariant-use-covariant.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - // Test that a type which is invariant with respect to its region // parameter used in a covariant way yields an error. // diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-variance-invariant-use-covariant.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-variance-invariant-use-covariant.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-variance-invariant-use-covariant.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-variance-invariant-use-covariant.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,13 +1,13 @@ error[E0308]: mismatched types - --> $DIR/regions-variance-invariant-use-covariant.rs:29:33 + --> $DIR/regions-variance-invariant-use-covariant.rs:27:33 | LL | let _: Invariant<'static> = c; //~ ERROR mismatched types | ^ lifetime mismatch | = note: expected type `Invariant<'static>` found type `Invariant<'b>` -note: the lifetime 'b as defined on the function body at 23:9... - --> $DIR/regions-variance-invariant-use-covariant.rs:23:9 +note: the lifetime 'b as defined on the function body at 21:9... + --> $DIR/regions-variance-invariant-use-covariant.rs:21:9 | LL | fn use_<'b>(c: Invariant<'b>) { | ^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-var-type-out-of-scope.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-var-type-out-of-scope.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/regions/regions-var-type-out-of-scope.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/regions/regions-var-type-out-of-scope.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,10 +1,10 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/regions-var-type-out-of-scope.rs:19:14 | LL | x = &id(3); //~ ERROR borrowed value does not live long enough - | ^^^^^- temporary value only lives until here + | ^^^^^- temporary value is freed at the end of this statement | | - | temporary value does not live long enough + | creates a temporary which is freed while still in use LL | assert_eq!(*x, 3); | ------------------ borrow later used here | @@ -13,4 +13,4 @@ error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/issue-22692.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/issue-22692.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/issue-22692.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/issue-22692.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let _ = String.new(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/issue-22692.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/issue-22692.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/issue-22692.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/issue-22692.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0423]: expected value, found struct `String` + --> $DIR/issue-22692.rs:12:13 + | +LL | let _ = String.new(); + | ^^^^^^---- + | | + | help: use `::` to access an associated function: `String::new` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0423`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/issue-2356.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/issue-2356.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/issue-2356.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/issue-2356.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -22,7 +22,7 @@ LL | whiskers -= other; | ^^^^^^^^ | | - | `self` value is only available in methods with `self` parameter + | `self` value is a keyword only available in methods with `self` parameter | help: try: `self.whiskers` error[E0425]: cannot find function `shave` in this scope @@ -65,7 +65,7 @@ --> $DIR/issue-2356.rs:75:8 | LL | if self.whiskers > 3 { - | ^^^^ `self` value is only available in methods with `self` parameter + | ^^^^ `self` value is a keyword only available in methods with `self` parameter error[E0425]: cannot find function `grow_older` in this scope --> $DIR/issue-2356.rs:82:5 @@ -91,7 +91,7 @@ LL | whiskers = 4; | ^^^^^^^^ | | - | `self` value is only available in methods with `self` parameter + | `self` value is a keyword only available in methods with `self` parameter | help: try: `self.whiskers` error[E0425]: cannot find function `purr_louder` in this scope @@ -104,7 +104,7 @@ --> $DIR/issue-2356.rs:102:5 | LL | self += 1; - | ^^^^ `self` value is only available in methods with `self` parameter + | ^^^^ `self` value is a keyword only available in methods with `self` parameter error: aborting due to 17 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/issue-54379.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/issue-54379.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/issue-54379.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/issue-54379.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +struct MyStruct { + pub s1: Option, +} + +fn main() { + let thing = MyStruct { s1: None }; + + match thing { + MyStruct { .., Some(_) } => {}, + _ => {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/issue-54379.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/issue-54379.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/issue-54379.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/issue-54379.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +error: expected `}`, found `,` + --> $DIR/issue-54379.rs:18:22 + | +LL | MyStruct { .., Some(_) } => {}, + | --^ + | | | + | | expected `}` + | `..` must be at the end and cannot have a trailing comma + +error: expected `,` + --> $DIR/issue-54379.rs:18:24 + | +LL | MyStruct { .., Some(_) } => {}, + | ^^^^ + +error[E0027]: pattern does not mention field `s1` + --> $DIR/issue-54379.rs:18:9 + | +LL | MyStruct { .., Some(_) } => {}, + | ^^^^^^^^^^^^^^^^^^^^^^^^ missing field `s1` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0027`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/privacy-enum-ctor.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/privacy-enum-ctor.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/privacy-enum-ctor.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/privacy-enum-ctor.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -132,28 +132,28 @@ | error[E0603]: enum `Z` is private - --> $DIR/privacy-enum-ctor.rs:67:16 + --> $DIR/privacy-enum-ctor.rs:67:22 | LL | let _: Z = m::n::Z; - | ^^^^^^^ + | ^ error[E0603]: enum `Z` is private - --> $DIR/privacy-enum-ctor.rs:71:16 + --> $DIR/privacy-enum-ctor.rs:71:22 | LL | let _: Z = m::n::Z::Fn; - | ^^^^^^^^^^^ + | ^ error[E0603]: enum `Z` is private - --> $DIR/privacy-enum-ctor.rs:74:16 + --> $DIR/privacy-enum-ctor.rs:74:22 | LL | let _: Z = m::n::Z::Struct; - | ^^^^^^^^^^^^^^^ + | ^ error[E0603]: enum `Z` is private - --> $DIR/privacy-enum-ctor.rs:78:16 + --> $DIR/privacy-enum-ctor.rs:78:22 | LL | let _: Z = m::n::Z::Unit {}; - | ^^^^^^^^^^^^^ + | ^ error[E0308]: mismatched types --> $DIR/privacy-enum-ctor.rs:37:20 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/privacy-struct-ctor.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/privacy-struct-ctor.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/privacy-struct-ctor.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/privacy-struct-ctor.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -38,40 +38,40 @@ | error[E0603]: tuple struct `Z` is private - --> $DIR/privacy-struct-ctor.rs:28:9 + --> $DIR/privacy-struct-ctor.rs:28:12 | LL | n::Z; - | ^^^^ + | ^ error[E0603]: tuple struct `S` is private - --> $DIR/privacy-struct-ctor.rs:39:5 + --> $DIR/privacy-struct-ctor.rs:39:8 | LL | m::S; - | ^^^^ + | ^ error[E0603]: tuple struct `S` is private - --> $DIR/privacy-struct-ctor.rs:41:16 + --> $DIR/privacy-struct-ctor.rs:41:19 | LL | let _: S = m::S(2); - | ^^^^ + | ^ error[E0603]: tuple struct `Z` is private - --> $DIR/privacy-struct-ctor.rs:45:5 + --> $DIR/privacy-struct-ctor.rs:45:11 | LL | m::n::Z; - | ^^^^^^^ + | ^ error[E0603]: tuple struct `S` is private - --> $DIR/privacy-struct-ctor.rs:51:5 + --> $DIR/privacy-struct-ctor.rs:51:16 | LL | xcrate::m::S; - | ^^^^^^^^^^^^ + | ^ error[E0603]: tuple struct `Z` is private - --> $DIR/privacy-struct-ctor.rs:55:5 + --> $DIR/privacy-struct-ctor.rs:55:19 | LL | xcrate::m::n::Z; - | ^^^^^^^^^^^^^^^ + | ^ error: aborting due to 10 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/resolve-bad-import-prefix.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/resolve-bad-import-prefix.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/resolve-bad-import-prefix.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/resolve-bad-import-prefix.rs 2018-12-04 23:41:40.000000000 +0000 @@ -17,8 +17,8 @@ use ::{}; // OK use m::{}; // OK use E::{}; // OK -use S::{}; //~ ERROR expected module or enum, found struct `S` -use Tr::{}; //~ ERROR expected module or enum, found trait `Tr` -use Nonexistent::{}; //~ ERROR cannot find module or enum `Nonexistent` in the crate root +use S::{}; // FIXME, this and `use S::{self};` should be an error +use Tr::{}; // FIXME, this and `use Tr::{self};` should be an error +use Nonexistent::{}; //~ ERROR unresolved import `Nonexistent` fn main () {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/resolve-bad-import-prefix.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/resolve-bad-import-prefix.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/resolve-bad-import-prefix.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/resolve-bad-import-prefix.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,24 +1,9 @@ -error[E0577]: expected module or enum, found struct `S` - --> $DIR/resolve-bad-import-prefix.rs:20:5 - | -LL | use S::{}; //~ ERROR expected module or enum, found struct `S` - | -^^^^ - | | - | did you mean `E`? - -error[E0577]: expected module or enum, found trait `Tr` - --> $DIR/resolve-bad-import-prefix.rs:21:5 - | -LL | use Tr::{}; //~ ERROR expected module or enum, found trait `Tr` - | ^^^^^^ not a module or enum - -error[E0578]: cannot find module or enum `Nonexistent` in the crate root +error[E0432]: unresolved import `Nonexistent` --> $DIR/resolve-bad-import-prefix.rs:22:5 | -LL | use Nonexistent::{}; //~ ERROR cannot find module or enum `Nonexistent` in the crate root - | ^^^^^^^^^^^ not found in the crate root +LL | use Nonexistent::{}; //~ ERROR unresolved import `Nonexistent` + | ^^^^^^^^^^^^^^^ no `Nonexistent` in the root -error: aborting due to 3 previous errors +error: aborting due to previous error -Some errors occurred: E0577, E0578. -For more information about an error, try `rustc --explain E0577`. +For more information about this error, try `rustc --explain E0432`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -5,7 +5,7 @@ | ^^^^^^^^^^^^^^^^^ `std` reimported here | = note: `std` 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 +help: you can use `as` to change the binding name of the import | LL | extern crate std as other_std; | diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-import-vs-extern-crate.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-import-vs-extern-crate.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-import-vs-extern-crate.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-import-vs-extern-crate.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -5,10 +5,10 @@ | ^^^^^^^^^^^^^^^^^ `std` reimported here | = note: `std` 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 +help: you can use `as` to change the binding name of the import | -LL | use std::slice as std as other_std; //~ ERROR the name `std` is defined multiple times - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | use std::slice as other_std; //~ ERROR the name `std` is defined multiple times + | ^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-import-vs-import.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-import-vs-import.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-import-vs-import.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-import-vs-import.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^^^^^^^^^^^^^^^^^^ `transmute` reimported here | = note: `transmute` 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 +help: you can use `as` to change the binding name of the import | LL | use std::mem::transmute as other_transmute; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-item-vs-extern-crate.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-item-vs-extern-crate.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-item-vs-extern-crate.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-item-vs-extern-crate.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -5,10 +5,6 @@ | ^^^^^^^ `std` redefined here | = note: `std` 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 - | -LL | as other_std// Copyright 2014 The Rust Project Developers. See the COPYRIGHT - | ^^^^^^^^^^^^ error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-item-vs-import.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-item-vs-import.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-item-vs-import.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-item-vs-import.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | ^^^^^^^^^^^^^^ `transmute` redefined here | = note: `transmute` 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 +help: you can use `as` to change the binding name of the import | LL | use std::mem::transmute as other_transmute; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-type-vs-import.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-type-vs-import.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-type-vs-import.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/resolve-conflict-type-vs-import.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | ^^^^^^^^^^^^ `Iter` redefined here | = note: `Iter` 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 +help: you can use `as` to change the binding name of the import | LL | use std::slice::Iter as OtherIter; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/resolve-variant-assoc-item.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/resolve-variant-assoc-item.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/resolve-variant-assoc-item.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/resolve-variant-assoc-item.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,6 +12,6 @@ use E::V; fn main() { - E::V::associated_item; //~ ERROR failed to resolve. Not a module `V` - V::associated_item; //~ ERROR failed to resolve. Not a module `V` + E::V::associated_item; //~ ERROR failed to resolve: not a module `V` + V::associated_item; //~ ERROR failed to resolve: not a module `V` } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/resolve-variant-assoc-item.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/resolve-variant-assoc-item.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/resolve-variant-assoc-item.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/resolve-variant-assoc-item.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,14 +1,14 @@ -error[E0433]: failed to resolve. Not a module `V` +error[E0433]: failed to resolve: not a module `V` --> $DIR/resolve-variant-assoc-item.rs:15:8 | -LL | E::V::associated_item; //~ ERROR failed to resolve. Not a module `V` - | ^ Not a module `V` +LL | E::V::associated_item; //~ ERROR failed to resolve: not a module `V` + | ^ not a module `V` -error[E0433]: failed to resolve. Not a module `V` +error[E0433]: failed to resolve: not a module `V` --> $DIR/resolve-variant-assoc-item.rs:16:5 | -LL | V::associated_item; //~ ERROR failed to resolve. Not a module `V` - | ^ Not a module `V` +LL | V::associated_item; //~ ERROR failed to resolve: not a module `V` + | ^ not a module `V` error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/token-error-correct-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/token-error-correct-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/token-error-correct-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/token-error-correct-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Test that we do some basic error correcton in the tokeniser (and don't ICE). +// Test that we do some basic error correction in the tokeniser (and don't ICE). fn main() { if foo { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/token-error-correct-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/token-error-correct-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/token-error-correct-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/token-error-correct-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,7 @@ // ignore-cloudabi no std::fs support -// Test that we do some basic error correcton in the tokeniser (and don't spew +// Test that we do some basic error correction in the tokeniser (and don't spew // too many bogus errors). pub mod raw { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/token-error-correct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/token-error-correct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/token-error-correct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/token-error-correct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Test that we do some basic error correcton in the tokeniser. +// Test that we do some basic error correction in the tokeniser. fn main() { foo(bar(; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/unresolved_static_type_field.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/unresolved_static_type_field.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve/unresolved_static_type_field.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve/unresolved_static_type_field.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -4,7 +4,7 @@ LL | f(cx); | ^^ | | - | `self` value is only available in methods with `self` parameter + | `self` value is a keyword only available in methods with `self` parameter | help: try: `self.cx` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve_self_super_hint.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve_self_super_hint.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve_self_super_hint.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve_self_super_hint.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,19 +15,19 @@ extern crate alloc; use alloc::HashMap; //~^ ERROR unresolved import `alloc` [E0432] - //~| Did you mean `self::alloc`? + //~| did you mean `self::alloc`? mod b { use alloc::HashMap; //~^ ERROR unresolved import `alloc` [E0432] - //~| Did you mean `a::alloc`? + //~| did you mean `super::alloc`? mod c { use alloc::HashMap; //~^ ERROR unresolved import `alloc` [E0432] - //~| Did you mean `a::alloc`? + //~| did you mean `a::alloc`? mod d { use alloc::HashMap; //~^ ERROR unresolved import `alloc` [E0432] - //~| Did you mean `a::alloc`? + //~| did you mean `a::alloc`? } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve_self_super_hint.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve_self_super_hint.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/resolve_self_super_hint.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/resolve_self_super_hint.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,25 +2,25 @@ --> $DIR/resolve_self_super_hint.rs:16:9 | LL | use alloc::HashMap; - | ^^^^^ Did you mean `self::alloc`? + | ^^^^^ did you mean `self::alloc`? error[E0432]: unresolved import `alloc` --> $DIR/resolve_self_super_hint.rs:20:13 | LL | use alloc::HashMap; - | ^^^^^ Did you mean `a::alloc`? + | ^^^^^ did you mean `super::alloc`? error[E0432]: unresolved import `alloc` --> $DIR/resolve_self_super_hint.rs:24:17 | LL | use alloc::HashMap; - | ^^^^^ Did you mean `a::alloc`? + | ^^^^^ did you mean `a::alloc`? error[E0432]: unresolved import `alloc` --> $DIR/resolve_self_super_hint.rs:28:21 | LL | use alloc::HashMap; - | ^^^^^ Did you mean `a::alloc`? + | ^^^^^ did you mean `a::alloc`? error: aborting due to 4 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/bind-by-move-no-guards.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/bind-by-move-no-guards.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/bind-by-move-no-guards.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/bind-by-move-no-guards.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,21 @@ +// Adaptation of existing ui test (from way back in +// rust-lang/rust#2329), that starts passing with this feature in +// place. + +// compile-pass + +#![feature(nll)] +#![feature(bind_by_move_pattern_guards)] + +use std::sync::mpsc::channel; + +fn main() { + let (tx, rx) = channel(); + let x = Some(rx); + tx.send(false); + match x { + Some(z) if z.recv().unwrap() => { panic!() }, + Some(z) => { assert!(!z.recv().unwrap()); }, + None => panic!() + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2015.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2015.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2015.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2015.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0008]: cannot bind by-move into a pattern guard + --> $DIR/feature-gate.rs:33:16 + | +LL | A { a: v } if *v == 42 => v, + | ^ moves value into pattern guard + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0008`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2018.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2018.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2018.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_2018.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: compilation successful + --> $DIR/feature-gate.rs:42:1 + | +LL | / fn main() { +LL | | foo(107) +LL | | } + | |_^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_feature_nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_feature_nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_feature_nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_feature_nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: compilation successful + --> $DIR/feature-gate.rs:42:1 + | +LL | / fn main() { +LL | | foo(107) +LL | | } + | |_^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_znll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_znll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_znll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.gate_and_znll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +error: compilation successful + --> $DIR/feature-gate.rs:42:1 + | +LL | / fn main() { +LL | | foo(107) +LL | | } + | |_^ + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.no_gate.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.no_gate.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.no_gate.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.no_gate.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0008]: cannot bind by-move into a pattern guard + --> $DIR/feature-gate.rs:33:16 + | +LL | A { a: v } if *v == 42 => v, + | ^ moves value into pattern guard + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0008`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/feature-gate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,47 @@ +// Check that pattern-guards with move-bound variables is only allowed +// with the appropriate set of feature gates. (Note that we require +// the code to opt into MIR-borrowck in *some* way before the feature +// will work; we use the revision system here to enumerate a number of +// ways that opt-in could occur.) + +// gate-test-bind_by_move_pattern_guards + +// revisions: no_gate gate_and_2015 gate_and_2018 gate_and_znll gate_and_feature_nll + +// (We're already testing NLL behavior quite explicitly, no need for compare-mode=nll.) +// ignore-compare-mode-nll + +#![feature(rustc_attrs)] + +#![cfg_attr(gate_and_2015, feature(bind_by_move_pattern_guards))] +#![cfg_attr(gate_and_2018, feature(bind_by_move_pattern_guards))] +#![cfg_attr(gate_and_znll, feature(bind_by_move_pattern_guards))] +#![cfg_attr(gate_and_feature_nll, feature(bind_by_move_pattern_guards))] + +#![cfg_attr(gate_and_feature_nll, feature(nll))] + +//[gate_and_2015] edition:2015 +//[gate_and_2018] edition:2018 +//[gate_and_znll] compile-flags: -Z borrowck=mir + +struct A { a: Box } + +fn foo(n: i32) { + let x = A { a: Box::new(n) }; + let _y = match x { + + A { a: v } if *v == 42 => v, + //[no_gate]~^ ERROR cannot bind by-move into a pattern guard + //[gate_and_2015]~^^ ERROR cannot bind by-move into a pattern guard + + _ => Box::new(0) + }; +} + +#[rustc_error] +fn main() { + foo(107) +} +//[gate_and_2018]~^^^ ERROR compilation successful +//[gate_and_znll]~^^^^ ERROR compilation successful +//[gate_and_feature_nll]~^^^^^ ERROR compilation successful diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-basic-examples.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-basic-examples.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-basic-examples.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-basic-examples.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +#![feature(nll)] +#![feature(bind_by_move_pattern_guards)] + +// compile-pass + +struct A { a: Box } + +impl A { + fn get(&self) -> i32 { *self.a } +} + +fn foo(n: i32) { + let x = A { a: Box::new(n) }; + let y = match x { + A { a: v } if *v == 42 => v, + _ => Box::new(0), + }; +} + +fn bar(n: i32) { + let x = A { a: Box::new(n) }; + let y = match x { + A { a: v } if x.get() == 42 => v, + _ => Box::new(0), + }; +} + +fn baz(n: i32) { + let x = A { a: Box::new(n) }; + let y = match x { + A { a: v } if *v.clone() == 42 => v, + _ => Box::new(0), + }; +} + +fn main() { + foo(107); + bar(107); + baz(107); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +#![feature(nll)] +#![feature(bind_by_move_pattern_guards)] + +enum VecWrapper { A(Vec) } + +fn foo(x: VecWrapper) -> usize { + match x { + VecWrapper::A(v) if { drop(v); false } => 1, + //~^ ERROR cannot move out of borrowed content + VecWrapper::A(v) => v.len() + } +} + +fn main() { + foo(VecWrapper::A(vec![107])); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/rfc-reject-double-move-across-arms.rs:8:36 + | +LL | VecWrapper::A(v) if { drop(v); false } => 1, + | ^ cannot move out of borrowed content + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +#![feature(nll)] +#![feature(bind_by_move_pattern_guards)] + +struct A { a: Box } + +fn foo(n: i32) { + let x = A { a: Box::new(n) }; + let _y = match x { + A { a: v } if { drop(v); true } => v, + //~^ ERROR cannot move out of borrowed content + _ => Box::new(0), + }; +} + +fn main() { + foo(107); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/rfc-reject-double-move-in-first-arm.rs:9:30 + | +LL | A { a: v } if { drop(v); true } => v, + | ^ cannot move out of borrowed content + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.nll.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2005-default-binding-mode/borrowck-issue-49631.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^^^^^^^^^^^ mutable borrow occurs here LL | //~^ ERROR cannot borrow `foo` as mutable LL | println!("foo={:?}", *string); - | ------- borrow used here in later iteration of loop + | ------- immutable borrow used here, in later iteration of loop error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2008-non-exhaustive/structs.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2008-non-exhaustive/structs.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2008-non-exhaustive/structs.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2008-non-exhaustive/structs.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -11,16 +11,16 @@ | ^^^^^^^^^^ constructor is not visible here due to private fields error[E0603]: tuple struct `TupleStruct` is private - --> $DIR/structs.rs:33:23 + --> $DIR/structs.rs:33:32 | LL | let ts_explicit = structs::TupleStruct(640, 480); - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^ error[E0603]: unit struct `UnitStruct` is private - --> $DIR/structs.rs:42:23 + --> $DIR/structs.rs:42:32 | LL | let us_explicit = structs::UnitStruct; - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ error[E0639]: cannot create non-exhaustive struct using struct expression --> $DIR/structs.rs:17:14 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/cross-crate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/cross-crate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,10 +9,9 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] #[rustc_outlives] -struct Foo<'a, T> { //~ ERROR 15:1: 17:2: rustc_outlives +struct Foo<'a, T> { //~ ERROR 14:1: 16:2: rustc_outlives bar: std::slice::IterMut<'a, T> } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/cross-crate.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/cross-crate.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/cross-crate.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/cross-crate.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/cross-crate.rs:15:1 + --> $DIR/cross-crate.rs:14:1 | -LL | / struct Foo<'a, T> { //~ ERROR 15:1: 17:2: rustc_outlives +LL | / struct Foo<'a, T> { //~ ERROR 14:1: 16:2: rustc_outlives LL | | bar: std::slice::IterMut<'a, T> LL | | } | |_^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,8 +10,6 @@ // ignore-tidy-linelength -#![feature(infer_outlives_requirements)] - /* * We don't infer `T: 'static` outlives relationships by default. * Instead an additional feature gate `infer_static_outlives_requirements` @@ -19,7 +17,7 @@ */ struct Foo { - bar: Bar //~ ERROR 22:5: 22:16: the parameter type `U` may not live long enough [E0310] + bar: Bar //~ ERROR 20:5: 20:16: the parameter type `U` may not live long enough [E0310] } struct Bar { x: T, diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,15 +1,15 @@ error[E0310]: the parameter type `U` may not live long enough - --> $DIR/dont-infer-static.rs:22:5 + --> $DIR/dont-infer-static.rs:20:5 | LL | struct Foo { | - help: consider adding an explicit lifetime bound `U: 'static`... -LL | bar: Bar //~ ERROR 22:5: 22:16: the parameter type `U` may not live long enough [E0310] +LL | bar: Bar //~ ERROR 20:5: 20:16: the parameter type `U` may not live long enough [E0310] | ^^^^^^^^^^^ | note: ...so that the type `U` will meet its required lifetime bounds - --> $DIR/dont-infer-static.rs:22:5 + --> $DIR/dont-infer-static.rs:20:5 | -LL | bar: Bar //~ ERROR 22:5: 22:16: the parameter type `U` may not live long enough [E0310] +LL | bar: Bar //~ ERROR 20:5: 20:16: the parameter type `U` may not live long enough [E0310] | ^^^^^^^^^^^ error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,24 +10,26 @@ // ignore-tidy-linelength +#![feature(rustc_attrs)] + // Needs an explicit where clause stating outlives condition. (RFC 2093) // Type T needs to outlive lifetime 'a. -enum Foo<'a, T> { - +#[rustc_outlives] +enum Foo<'a, T> { //~ ERROR rustc_outlives One(Bar<'a, T>) } // Type U needs to outlive lifetime 'b -struct Bar<'b, U> { - field2: &'b U //~ ERROR the parameter type `U` may not live long enough [E0309] +#[rustc_outlives] +struct Bar<'b, U> { //~ ERROR rustc_outlives + field2: &'b U } - - // Type K needs to outlive lifetime 'c. -enum Ying<'c, K> { - One(&'c Yang) //~ ERROR the parameter type `K` may not live long enough [E0309] +#[rustc_outlives] +enum Ying<'c, K> { //~ ERROR rustc_outlives + One(&'c Yang) } struct Yang { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/enum.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/enum.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/enum.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/enum.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,31 +1,32 @@ -error[E0309]: the parameter type `U` may not live long enough - --> $DIR/enum.rs:23:5 +error: rustc_outlives + --> $DIR/enum.rs:19:1 | -LL | struct Bar<'b, U> { - | - help: consider adding an explicit lifetime bound `U: 'b`... -LL | field2: &'b U //~ ERROR the parameter type `U` may not live long enough [E0309] - | ^^^^^^^^^^^^^ +LL | / enum Foo<'a, T> { //~ ERROR rustc_outlives +LL | | One(Bar<'a, T>) +LL | | } + | |_^ | -note: ...so that the reference type `&'b U` does not outlive the data it points at - --> $DIR/enum.rs:23:5 - | -LL | field2: &'b U //~ ERROR the parameter type `U` may not live long enough [E0309] - | ^^^^^^^^^^^^^ + = note: T : 'a -error[E0309]: the parameter type `K` may not live long enough - --> $DIR/enum.rs:30:9 +error: rustc_outlives + --> $DIR/enum.rs:25:1 + | +LL | / struct Bar<'b, U> { //~ ERROR rustc_outlives +LL | | field2: &'b U +LL | | } + | |_^ | -LL | enum Ying<'c, K> { - | - help: consider adding an explicit lifetime bound `K: 'c`... -LL | One(&'c Yang) //~ ERROR the parameter type `K` may not live long enough [E0309] - | ^^^^^^^^^^^ + = note: U : 'b + +error: rustc_outlives + --> $DIR/enum.rs:31:1 | -note: ...so that the reference type `&'c Yang` does not outlive the data it points at - --> $DIR/enum.rs:30:9 +LL | / enum Ying<'c, K> { //~ ERROR rustc_outlives +LL | | One(&'c Yang) +LL | | } + | |_^ | -LL | One(&'c Yang) //~ ERROR the parameter type `K` may not live long enough [E0309] - | ^^^^^^^^^^^ + = note: K : 'c -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0309`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,13 +10,12 @@ #![feature(dyn_trait)] #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] trait Trait<'x, T> where T: 'x { } #[rustc_outlives] -struct Foo<'a, A> //~ ERROR 19:1: 22:2: rustc_outlives +struct Foo<'a, A> //~ ERROR 18:1: 21:2: rustc_outlives { foo: Box> } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/explicit-dyn.rs:19:1 + --> $DIR/explicit-dyn.rs:18:1 | -LL | / struct Foo<'a, A> //~ ERROR 19:1: 22:2: rustc_outlives +LL | / struct Foo<'a, A> //~ ERROR 18:1: 21:2: rustc_outlives LL | | { LL | | foo: Box> LL | | } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,10 +9,9 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] #[rustc_outlives] -enum Foo<'a, U> { //~ ERROR 15:1: 17:2: rustc_outlives +enum Foo<'a, U> { //~ ERROR 14:1: 16:2: rustc_outlives One(Bar<'a, U>) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-enum.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-enum.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-enum.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-enum.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/explicit-enum.rs:15:1 + --> $DIR/explicit-enum.rs:14:1 | -LL | / enum Foo<'a, U> { //~ ERROR 15:1: 17:2: rustc_outlives +LL | / enum Foo<'a, U> { //~ ERROR 14:1: 16:2: rustc_outlives LL | | One(Bar<'a, U>) LL | | } | |_^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-projection.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-projection.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-projection.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-projection.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,7 +9,6 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] trait Trait<'x, T> where T: 'x { type Type; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-projection.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-projection.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-projection.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-projection.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error: rustc_outlives - --> $DIR/explicit-projection.rs:19:1 + --> $DIR/explicit-projection.rs:18:1 | LL | / struct Foo<'a, A, B> where A: Trait<'a, B> //~ ERROR rustc_outlives LL | | { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,10 +9,9 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] #[rustc_outlives] -struct Foo<'b, U> { //~ ERROR 15:1: 17:2: rustc_outlives +struct Foo<'b, U> { //~ ERROR 14:1: 16:2: rustc_outlives bar: Bar<'b, U> } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-struct.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-struct.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-struct.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-struct.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/explicit-struct.rs:15:1 + --> $DIR/explicit-struct.rs:14:1 | -LL | / struct Foo<'b, U> { //~ ERROR 15:1: 17:2: rustc_outlives +LL | / struct Foo<'b, U> { //~ ERROR 14:1: 16:2: rustc_outlives LL | | bar: Bar<'b, U> LL | | } | |_^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-union.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-union.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-union.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-union.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,13 +9,11 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] #![feature(untagged_unions)] #![allow(unions_with_drop_fields)] - #[rustc_outlives] -union Foo<'b, U> { //~ ERROR 18:1: 20:2: rustc_outlives +union Foo<'b, U> { //~ ERROR 16:1: 18:2: rustc_outlives bar: Bar<'b, U> } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-union.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-union.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-union.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/explicit-union.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/explicit-union.rs:18:1 + --> $DIR/explicit-union.rs:16:1 | -LL | / union Foo<'b, U> { //~ ERROR 18:1: 20:2: rustc_outlives +LL | / union Foo<'b, U> { //~ ERROR 16:1: 18:2: rustc_outlives LL | | bar: Bar<'b, U> LL | | } | |_^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/infer-static.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/infer-static.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/infer-static.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/infer-static.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,11 +9,10 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] #![feature(infer_static_outlives_requirements)] #[rustc_outlives] -struct Foo { //~ ERROR 16:1: 18:2: rustc_outlives +struct Foo { //~ ERROR 15:1: 17:2: rustc_outlives bar: Bar } struct Bar { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/infer-static.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/infer-static.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/infer-static.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/infer-static.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/infer-static.rs:16:1 + --> $DIR/infer-static.rs:15:1 | -LL | / struct Foo { //~ ERROR 16:1: 18:2: rustc_outlives +LL | / struct Foo { //~ ERROR 15:1: 17:2: rustc_outlives LL | | bar: Bar LL | | } | |_^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/issue-54467.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/issue-54467.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/issue-54467.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/issue-54467.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// Regression test for #54467: +// +// Here, the trait object has an "inferred outlives" requirement that +// `>::Item: 'a`; but since we don't know what +// `Self` is, we were (incorrectly) messing things up, leading to +// strange errors. This test ensures that we do not give compilation +// errors. +// +// compile-pass + +trait MyIterator<'a>: Iterator where Self::Item: 'a { } + +struct MyStruct<'a, A> { + item: Box> +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,11 +9,9 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] - #[rustc_outlives] -enum Foo<'a, T> { //~ ERROR 16:1: 19:2: rustc_outlives +enum Foo<'a, T> { //~ ERROR 14:1: 17:2: rustc_outlives One(Bar<'a, T>) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-enum.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-enum.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-enum.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-enum.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/nested-enum.rs:16:1 + --> $DIR/nested-enum.rs:14:1 | -LL | / enum Foo<'a, T> { //~ ERROR 16:1: 19:2: rustc_outlives +LL | / enum Foo<'a, T> { //~ ERROR 14:1: 17:2: rustc_outlives LL | | LL | | One(Bar<'a, T>) LL | | } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-regions.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-regions.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-regions.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-regions.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,10 +9,9 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] #[rustc_outlives] -struct Foo<'a, 'b, T> { //~ ERROR 15:1: 17:2: rustc_outlives +struct Foo<'a, 'b, T> { //~ ERROR 14:1: 16:2: rustc_outlives x: &'a &'b T } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-regions.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-regions.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-regions.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-regions.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/nested-regions.rs:15:1 + --> $DIR/nested-regions.rs:14:1 | -LL | / struct Foo<'a, 'b, T> { //~ ERROR 15:1: 17:2: rustc_outlives +LL | / struct Foo<'a, 'b, T> { //~ ERROR 14:1: 16:2: rustc_outlives LL | | x: &'a &'b T LL | | } | |_^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-structs.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-structs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-structs.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-structs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,10 +9,9 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] #[rustc_outlives] -struct Foo<'a, T> { //~ ERROR 15:1: 17:2: rustc_outlives +struct Foo<'a, T> { //~ ERROR 14:1: 16:2: rustc_outlives field1: Bar<'a, T> } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-structs.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-structs.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-structs.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-structs.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/nested-structs.rs:15:1 + --> $DIR/nested-structs.rs:14:1 | -LL | / struct Foo<'a, T> { //~ ERROR 15:1: 17:2: rustc_outlives +LL | / struct Foo<'a, T> { //~ ERROR 14:1: 16:2: rustc_outlives LL | | field1: Bar<'a, T> LL | | } | |_^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-union.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-union.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-union.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-union.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,13 +9,11 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] #![feature(untagged_unions)] #![allow(unions_with_drop_fields)] - #[rustc_outlives] -union Foo<'a, T> { //~ ERROR 18:1: 20:2: rustc_outlives +union Foo<'a, T> { //~ ERROR 16:1: 18:2: rustc_outlives field1: Bar<'a, T> } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-union.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-union.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-union.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/nested-union.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/nested-union.rs:18:1 + --> $DIR/nested-union.rs:16:1 | -LL | / union Foo<'a, T> { //~ ERROR 18:1: 20:2: rustc_outlives +LL | / union Foo<'a, T> { //~ ERROR 16:1: 18:2: rustc_outlives LL | | field1: Bar<'a, T> LL | | } | |_^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/privacy.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/privacy.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/privacy.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/privacy.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +// Test that we do not get a privacy error here. Initially, we did, +// because we inferred an outlives predciate of ` as +// Private>::Out: 'a`, but the private trait is -- well -- private, +// and hence it was not something that a pub trait could refer to. +// +// run-pass + +#![allow(dead_code)] + +pub struct Foo<'a> { + field: Option<&'a as Private>::Out> +} + +trait Private { + type Out: ?Sized; +} + +impl Private for T { type Out = Self; } + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/projection.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/projection.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/projection.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/projection.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,7 +9,6 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] #[rustc_outlives] struct Foo<'a, T: Iterator> { //~ ERROR rustc_outlives diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/projection.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/projection.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/projection.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/projection.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error: rustc_outlives - --> $DIR/projection.rs:15:1 + --> $DIR/projection.rs:14:1 | LL | / struct Foo<'a, T: Iterator> { //~ ERROR rustc_outlives LL | | bar: &'a T::Item diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/reference.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/reference.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/reference.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/reference.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,7 +9,6 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] #[rustc_outlives] struct Foo<'a, T> { //~ ERROR rustc_outlives diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/reference.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/reference.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/reference.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/reference.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error: rustc_outlives - --> $DIR/reference.rs:15:1 + --> $DIR/reference.rs:14:1 | LL | / struct Foo<'a, T> { //~ ERROR rustc_outlives LL | | bar: &'a T, diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,50 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength + +// Various examples of structs whose fields are not well-formed. + +#![allow(dead_code)] + +trait Dummy<'a> { + type Out; +} +impl<'a, T> Dummy<'a> for T +where T: 'a +{ + type Out = (); +} +type RequireOutlives<'a, T> = >::Out; + +enum Ref1<'a, T> { + Ref1Variant1(RequireOutlives<'a, T>) //~ ERROR the parameter type `T` may not live long enough +} + +enum Ref2<'a, T> { + Ref2Variant1, + Ref2Variant2(isize, RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough +} + +enum RefOk<'a, T:'a> { + RefOkVariant1(&'a T) +} + +// This is now well formed. RFC 2093 +enum RefIndirect<'a, T> { + RefIndirectVariant1(isize, RefOk<'a,T>) +} + +enum RefDouble<'a, 'b, T> { //~ ERROR 45:1: 48:2: the parameter type `T` may not live long enough [E0309] + RefDoubleVariant1(&'a RequireOutlives<'b, T>) + //~^ 46:23: 46:49: the parameter type `T` may not live long enough [E0309] +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,67 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-enum-not-wf.rs:28:18 + | +LL | enum Ref1<'a, T> { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | Ref1Variant1(RequireOutlives<'a, T>) //~ ERROR the parameter type `T` may not live long enough + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-enum-not-wf.rs:28:18 + | +LL | Ref1Variant1(RequireOutlives<'a, T>) //~ ERROR the parameter type `T` may not live long enough + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-enum-not-wf.rs:33:25 + | +LL | enum Ref2<'a, T> { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | Ref2Variant1, +LL | Ref2Variant2(isize, RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-enum-not-wf.rs:33:25 + | +LL | Ref2Variant2(isize, RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-enum-not-wf.rs:45:1 + | +LL | enum RefDouble<'a, 'b, T> { //~ ERROR 45:1: 48:2: the parameter type `T` may not live long enough [E0309] + | ^ - help: consider adding an explicit lifetime bound `T: 'b`... + | _| + | | +LL | | RefDoubleVariant1(&'a RequireOutlives<'b, T>) +LL | | //~^ 46:23: 46:49: the parameter type `T` may not live long enough [E0309] +LL | | } + | |_^ + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-enum-not-wf.rs:45:1 + | +LL | / enum RefDouble<'a, 'b, T> { //~ ERROR 45:1: 48:2: the parameter type `T` may not live long enough [E0309] +LL | | RefDoubleVariant1(&'a RequireOutlives<'b, T>) +LL | | //~^ 46:23: 46:49: the parameter type `T` may not live long enough [E0309] +LL | | } + | |_^ + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-enum-not-wf.rs:46:23 + | +LL | enum RefDouble<'a, 'b, T> { //~ ERROR 45:1: 48:2: the parameter type `T` may not live long enough [E0309] + | - help: consider adding an explicit lifetime bound `T: 'b`... +LL | RefDoubleVariant1(&'a RequireOutlives<'b, T>) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-enum-not-wf.rs:46:23 + | +LL | RefDoubleVariant1(&'a RequireOutlives<'b, T>) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0309`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod rev_variant_struct_region { + struct Foo<'a> { + x: fn(&'a i32), + } + trait Trait<'a, 'b> { + type Out; + } + impl<'a, 'b> Trait<'a, 'b> for usize { + type Out = &'a Foo<'b>; //~ ERROR reference has a longer lifetime + } +} + +#[rustc_error] +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a rev_variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-region-rev.rs:27:9 + | +LL | type Out = &'a Foo<'b>; //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the impl at 26:10 + --> $DIR/regions-outlives-nominal-type-region-rev.rs:26:10 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the impl at 26:14 + --> $DIR/regions-outlives-nominal-type-region-rev.rs:26:14 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod variant_struct_region { + struct Foo<'a> { + x: &'a i32, + } + trait Trait<'a, 'b> { + type Out; + } + impl<'a, 'b> Trait<'a, 'b> for usize { + type Out = &'a Foo<'b>; //~ ERROR reference has a longer lifetime + } +} + +#[rustc_error] +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-region.rs:27:9 + | +LL | type Out = &'a Foo<'b>; //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the impl at 26:10 + --> $DIR/regions-outlives-nominal-type-region.rs:26:10 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the impl at 26:14 + --> $DIR/regions-outlives-nominal-type-region.rs:26:14 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod variant_struct_type { + struct Foo { + x: fn(T) + } + trait Trait<'a, 'b> { + type Out; + } + impl<'a, 'b> Trait<'a, 'b> for usize { + type Out = &'a Foo<&'b i32>; //~ ERROR reference has a longer lifetime + } +} + +#[rustc_error] +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a variant_struct_type::Foo<&'b i32>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-type-rev.rs:27:9 + | +LL | type Out = &'a Foo<&'b i32>; //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the impl at 26:10 + --> $DIR/regions-outlives-nominal-type-type-rev.rs:26:10 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the impl at 26:14 + --> $DIR/regions-outlives-nominal-type-type-rev.rs:26:14 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod variant_struct_type { + struct Foo { + x: T + } + trait Trait<'a, 'b> { + type Out; + } + impl<'a, 'b> Trait<'a, 'b> for usize { + type Out = &'a Foo<&'b i32>; //~ ERROR reference has a longer lifetime + } +} + +#[rustc_error] +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a variant_struct_type::Foo<&'b i32>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-type.rs:27:9 + | +LL | type Out = &'a Foo<&'b i32>; //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the impl at 26:10 + --> $DIR/regions-outlives-nominal-type-type.rs:26:10 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the impl at 26:14 + --> $DIR/regions-outlives-nominal-type-type.rs:26:14 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,38 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Various examples of structs whose fields are not well-formed. + +#![allow(dead_code)] + +trait Trait<'a, T> { + type Out; +} +trait Trait1<'a, 'b, T> { + type Out; +} + +impl<'a, T> Trait<'a, T> for usize { + type Out = &'a T; +} + +struct RefOk<'a, T:'a> { + field: &'a T +} + +impl<'a, T> Trait<'a, T> for u32 { + type Out = RefOk<'a, T>; +} + +impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 { + type Out = &'a &'b T; +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,49 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-struct-not-wf.rs:23:5 + | +LL | impl<'a, T> Trait<'a, T> for usize { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | type Out = &'a T; + | ^^^^^^^^^^^^^^^^^ + | +note: ...so that the reference type `&'a T` does not outlive the data it points at + --> $DIR/regions-struct-not-wf.rs:23:5 + | +LL | type Out = &'a T; + | ^^^^^^^^^^^^^^^^^ + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-struct-not-wf.rs:31:5 + | +LL | impl<'a, T> Trait<'a, T> for u32 { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | type Out = RefOk<'a, T>; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-struct-not-wf.rs:31:5 + | +LL | type Out = RefOk<'a, T>; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0491]: in type `&'a &'b T`, reference has a longer lifetime than the data it references + --> $DIR/regions-struct-not-wf.rs:35:5 + | +LL | type Out = &'a &'b T; + | ^^^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the impl at 34:6 + --> $DIR/regions-struct-not-wf.rs:34:6 + | +LL | impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the impl at 34:10 + --> $DIR/regions-struct-not-wf.rs:34:10 + | +LL | impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 { + | ^^ + +error: aborting due to 3 previous errors + +Some errors occurred: E0309, E0491. +For more information about an error, try `rustc --explain E0309`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/self-dyn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/self-dyn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/self-dyn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/self-dyn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,14 +10,13 @@ #![feature(dyn_trait)] #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] trait Trait<'x, 's, T> where T: 'x, 's: { } #[rustc_outlives] -struct Foo<'a, 'b, A> //~ ERROR 20:1: 23:2: rustc_outlives +struct Foo<'a, 'b, A> //~ ERROR 19:1: 22:2: rustc_outlives { foo: Box> } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/self-dyn.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/self-dyn.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/self-dyn.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/self-dyn.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/self-dyn.rs:20:1 + --> $DIR/self-dyn.rs:19:1 | -LL | / struct Foo<'a, 'b, A> //~ ERROR 20:1: 23:2: rustc_outlives +LL | / struct Foo<'a, 'b, A> //~ ERROR 19:1: 22:2: rustc_outlives LL | | { LL | | foo: Box> LL | | } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/self-structs.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/self-structs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/self-structs.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/self-structs.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,10 +9,9 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] #[rustc_outlives] -struct Foo<'a, 'b, T> { //~ ERROR 15:1: 17:2: rustc_outlives +struct Foo<'a, 'b, T> { //~ ERROR 14:1: 16:2: rustc_outlives field1: Bar<'a, 'b, T> } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/self-structs.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/self-structs.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/self-structs.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2093-infer-outlives/self-structs.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/self-structs.rs:15:1 + --> $DIR/self-structs.rs:14:1 | -LL | / struct Foo<'a, 'b, T> { //~ ERROR 15:1: 17:2: rustc_outlives +LL | / struct Foo<'a, 'b, T> { //~ ERROR 14:1: 16:2: rustc_outlives LL | | field1: Bar<'a, 'b, T> LL | | } | |_^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2126-crate-paths/crate-path-non-absolute.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2126-crate-paths/crate-path-non-absolute.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2126-crate-paths/crate-path-non-absolute.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2126-crate-paths/crate-path-non-absolute.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,10 +1,10 @@ -error[E0433]: failed to resolve. `crate` in paths can only be used in start position +error[E0433]: failed to resolve: `crate` in paths can only be used in start position --> $DIR/crate-path-non-absolute.rs:17:22 | LL | let s = ::m::crate::S; //~ ERROR failed to resolve | ^^^^^ `crate` in paths can only be used in start position -error[E0433]: failed to resolve. global paths cannot start with `crate` +error[E0433]: failed to resolve: global paths cannot start with `crate` --> $DIR/crate-path-non-absolute.rs:18:20 | LL | let s1 = ::crate::S; //~ ERROR failed to resolve diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-absolute-paths/non-existent-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-absolute-paths/non-existent-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-absolute-paths/non-existent-1.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-absolute-paths/non-existent-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/non-existent-1.rs:13:5 | LL | use xcrate::S; //~ ERROR unresolved import `xcrate` - | ^^^^^^ Could not find `xcrate` in `{{root}}` + | ^^^^^^ use of undeclared type or module `xcrate` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-absolute-paths/non-existent-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-absolute-paths/non-existent-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-absolute-paths/non-existent-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-absolute-paths/non-existent-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,5 +12,5 @@ fn main() { let s = ::xcrate::S; - //~^ ERROR failed to resolve. Could not find `xcrate` in `{{root}}` + //~^ ERROR failed to resolve: could not find `xcrate` in `{{root}}` } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-absolute-paths/non-existent-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-absolute-paths/non-existent-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-absolute-paths/non-existent-2.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-absolute-paths/non-existent-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ -error[E0433]: failed to resolve. Could not find `xcrate` in `{{root}}` +error[E0433]: failed to resolve: could not find `xcrate` in `{{root}}` --> $DIR/non-existent-2.rs:14:15 | LL | let s = ::xcrate::S; - | ^^^^^^ Could not find `xcrate` in `{{root}}` + | ^^^^^^ could not find `xcrate` in `{{root}}` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-absolute-paths/not-whitelisted.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-absolute-paths/not-whitelisted.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-absolute-paths/not-whitelisted.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-absolute-paths/not-whitelisted.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,10 +10,12 @@ // edition:2018 +#![feature(uniform_paths)] + // Tests that arbitrary crates (other than `core`, `std` and `meta`) // aren't allowed without `--extern`, even if they're in the sysroot. use alloc; //~ ERROR unresolved import `alloc` -use test; //~ ERROR unresolved import `test` -use proc_macro; //~ ERROR unresolved import `proc_macro` +use test; //~ ERROR cannot import a built-in macro +use proc_macro; // OK, imports the built-in `proc_macro` attribute, but not the `proc_macro` crate. fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-absolute-paths/not-whitelisted.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-absolute-paths/not-whitelisted.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-absolute-paths/not-whitelisted.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-absolute-paths/not-whitelisted.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,21 +1,15 @@ -error[E0432]: unresolved import `alloc` - --> $DIR/not-whitelisted.rs:15:5 - | -LL | use alloc; //~ ERROR unresolved import `alloc` - | ^^^^^ no `alloc` external crate - -error[E0432]: unresolved import `test` - --> $DIR/not-whitelisted.rs:16:5 +error: cannot import a built-in macro + --> $DIR/not-whitelisted.rs:18:5 | -LL | use test; //~ ERROR unresolved import `test` - | ^^^^ no `test` external crate +LL | use test; //~ ERROR cannot import a built-in macro + | ^^^^ -error[E0432]: unresolved import `proc_macro` +error[E0432]: unresolved import `alloc` --> $DIR/not-whitelisted.rs:17:5 | -LL | use proc_macro; //~ ERROR unresolved import `proc_macro` - | ^^^^^^^^^^ no `proc_macro` external crate +LL | use alloc; //~ ERROR unresolved import `alloc` + | ^^^^^ no `alloc` external crate -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0432`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-in-paths/non-existent-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-in-paths/non-existent-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-in-paths/non-existent-1.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-in-paths/non-existent-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/non-existent-1.rs:13:13 | LL | use extern::xcrate::S; //~ ERROR unresolved import `extern::xcrate` - | ^^^^^^ Could not find `xcrate` in `extern` + | ^^^^^^ could not find `xcrate` in `extern` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-in-paths/non-existent-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-in-paths/non-existent-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-in-paths/non-existent-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-in-paths/non-existent-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,5 +12,5 @@ fn main() { let s = extern::xcrate::S; - //~^ ERROR failed to resolve. Could not find `xcrate` in `extern` + //~^ ERROR failed to resolve: could not find `xcrate` in `extern` } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-in-paths/non-existent-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-in-paths/non-existent-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-in-paths/non-existent-2.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2126-extern-in-paths/non-existent-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ -error[E0433]: failed to resolve. Could not find `xcrate` in `extern` +error[E0433]: failed to resolve: could not find `xcrate` in `extern` --> $DIR/non-existent-2.rs:14:21 | LL | let s = extern::xcrate::S; - | ^^^^^^ Could not find `xcrate` in `extern` + | ^^^^^^ could not find `xcrate` in `extern` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,121 @@ +// run-pass +// ignore-cloudabi no processes +// ignore-emscripten no processes + +// Tests ensuring that `dbg!(expr)` has the expected run-time behavior. +// as well as some compile time properties we expect. + +#![feature(dbg_macro)] + +#[derive(Copy, Clone, Debug)] +struct Unit; + +#[derive(Copy, Clone, Debug, PartialEq)] +struct Point { + x: T, + y: T, +} + +#[derive(Debug, PartialEq)] +struct NoCopy(usize); + +fn test() { + let a: Unit = dbg!(Unit); + let _: Unit = dbg!(a); + // We can move `a` because it's Copy. + drop(a); + + // `Point` will be faithfully formatted according to `{:#?}`. + let a = Point { x: 42, y: 24 }; + let b: Point = dbg!(Point { x: 42, y: 24 }); // test stringify!(..) + let c: Point = dbg!(b); + // Identity conversion: + assert_eq!(a, b); + assert_eq!(a, c); + // We can move `b` because it's Copy. + drop(b); + + // Test that we can borrow and that successive applications is still identity. + let a = NoCopy(1337); + let b: &NoCopy = dbg!(dbg!(&a)); + assert_eq!(&a, b); + + // Test involving lifetimes of temporaries: + fn f<'a>(x: &'a u8) -> &'a u8 { x } + let a: &u8 = dbg!(f(&42)); + assert_eq!(a, &42); + + // Test side effects: + let mut foo = 41; + assert_eq!(7331, dbg!({ + foo += 1; + eprintln!("before"); + 7331 + })); + assert_eq!(foo, 42); +} + +fn validate_stderr(stderr: Vec) { + assert_eq!(stderr, &[ + ":23] Unit = Unit", + + ":24] a = Unit", + + ":30] Point{x: 42, y: 24,} = Point {", + " x: 42,", + " y: 24", + "}", + + ":31] b = Point {", + " x: 42,", + " y: 24", + "}", + + ":40] &a = NoCopy(", + " 1337", + ")", + + ":40] dbg!(& a) = NoCopy(", + " 1337", + ")", + ":45] f(&42) = 42", + + "before", + ":50] { foo += 1; eprintln!(\"before\"); 7331 } = 7331", + ]); +} + +fn main() { + // The following is a hack to deal with compiletest's inability + // to check the output (to stdout) of run-pass tests. + use std::env; + use std::process::Command; + + let mut args = env::args(); + let prog = args.next().unwrap(); + let child = args.next(); + if let Some("child") = child.as_ref().map(|s| &**s) { + // Only run the test if we've been spawned as 'child' + test() + } else { + // This essentially spawns as 'child' to run the tests + // and then it collects output of stderr and checks the output + // against what we expect. + let out = Command::new(&prog).arg("child").output().unwrap(); + assert!(out.status.success()); + assert!(out.stdout.is_empty()); + + let stderr = String::from_utf8(out.stderr).unwrap(); + let stderr = stderr.lines().map(|mut s| { + if s.starts_with("[") { + // Strip `[` and file path: + s = s.trim_start_matches("["); + assert!(s.starts_with(file!())); + s = s.trim_start_matches(file!()); + } + s.to_owned() + }).collect(); + + validate_stderr(stderr); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,5 @@ +// Feature gate test for `dbg!(..)`. + +fn main() { + dbg!(1); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0658]: macro dbg! is unstable (see issue #54306) + --> $DIR/dbg-macro-feature-gate.rs:4:5 + | +LL | dbg!(1); + | ^^^^^^^^ + | + = help: add #![feature(dbg_macro)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error[E0382]: use of moved value: `a` + --> $DIR/dbg-macro-move-semantics.rs:11:18 + | +LL | let _ = dbg!(a); + | ------- value moved here +LL | let _ = dbg!(a); + | ^ value used here after move + | + = note: move occurs because `a` has type `NoCopy`, which does not implement the `Copy` trait + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +// Test ensuring that `dbg!(expr)` will take ownership of the argument. + +#![feature(dbg_macro)] + +#[derive(Debug)] +struct NoCopy(usize); + +fn main() { + let a = NoCopy(0); + let _ = dbg!(a); + let _ = dbg!(a); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +error[E0382]: use of moved value: `a` + --> $DIR/dbg-macro-move-semantics.rs:11:18 + | +LL | let _ = dbg!(a); + | ------- value moved here +LL | let _ = dbg!(a); + | ^ value used here after move + | + = note: move occurs because `a` has type `NoCopy`, which does not implement the `Copy` trait + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error[E0382]: use of moved value: `a` + --> $DIR/dbg-macro-move-semantics.rs:11:13 + | +LL | let _ = dbg!(a); + | ------- value moved here +LL | let _ = dbg!(a); + | ^^^^^^^ value used here after move + | + = note: move occurs because `a` has type `NoCopy`, which does not implement the `Copy` trait + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +// Test ensuring that `dbg!(expr)` requires the passed type to implement `Debug`. + +#![feature(dbg_macro)] + +struct NotDebug; + +fn main() { + let _: NotDebug = dbg!(NotDebug); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +error[E0277]: `NotDebug` doesn't implement `std::fmt::Debug` + --> $DIR/dbg-macro-requires-debug.rs:8:23 + | +LL | let _: NotDebug = dbg!(NotDebug); + | ^^^^^^^^^^^^^^ `NotDebug` cannot be formatted using `{:?}` + | + = help: the trait `std::fmt::Debug` is not implemented for `NotDebug` + = note: add `#[derive(Debug)]` or manually implement `std::fmt::Debug` + = note: required because of the requirements on the impl of `std::fmt::Debug` for `&NotDebug` + = note: required by `std::fmt::Debug::fmt` + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2015.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2015.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2015.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2015.rs 2018-12-04 23:41:40.000000000 +0000 @@ -19,22 +19,22 @@ use std::ops::Range; if let Range { start: _, end: _ } = true..true && false { } - //~^ ERROR ambigious use of `&&` + //~^ ERROR ambiguous use of `&&` if let Range { start: _, end: _ } = true..true || false { } - //~^ ERROR ambigious use of `||` + //~^ ERROR ambiguous use of `||` while let Range { start: _, end: _ } = true..true && false { } - //~^ ERROR ambigious use of `&&` + //~^ ERROR ambiguous use of `&&` while let Range { start: _, end: _ } = true..true || false { } - //~^ ERROR ambigious use of `||` + //~^ ERROR ambiguous use of `||` if let true = false && false { } - //~^ ERROR ambigious use of `&&` + //~^ ERROR ambiguous use of `&&` while let true = (1 == 2) && false { } - //~^ ERROR ambigious use of `&&` + //~^ ERROR ambiguous use of `&&` // The following cases are not an error as parenthesis are used to // clarify intent: diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2015.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2015.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2015.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2015.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ -error: ambigious use of `&&` +error: ambiguous use of `&&` --> $DIR/syntax-ambiguity-2015.rs:21:47 | LL | if let Range { start: _, end: _ } = true..true && false { } @@ -7,7 +7,7 @@ = note: this will be a error until the `let_chains` feature is stabilized = note: see rust-lang/rust#53668 for more information -error: ambigious use of `||` +error: ambiguous use of `||` --> $DIR/syntax-ambiguity-2015.rs:24:47 | LL | if let Range { start: _, end: _ } = true..true || false { } @@ -16,7 +16,7 @@ = note: this will be a error until the `let_chains` feature is stabilized = note: see rust-lang/rust#53668 for more information -error: ambigious use of `&&` +error: ambiguous use of `&&` --> $DIR/syntax-ambiguity-2015.rs:27:50 | LL | while let Range { start: _, end: _ } = true..true && false { } @@ -25,7 +25,7 @@ = note: this will be a error until the `let_chains` feature is stabilized = note: see rust-lang/rust#53668 for more information -error: ambigious use of `||` +error: ambiguous use of `||` --> $DIR/syntax-ambiguity-2015.rs:30:50 | LL | while let Range { start: _, end: _ } = true..true || false { } @@ -34,7 +34,7 @@ = note: this will be a error until the `let_chains` feature is stabilized = note: see rust-lang/rust#53668 for more information -error: ambigious use of `&&` +error: ambiguous use of `&&` --> $DIR/syntax-ambiguity-2015.rs:33:19 | LL | if let true = false && false { } @@ -43,7 +43,7 @@ = note: this will be a error until the `let_chains` feature is stabilized = note: see rust-lang/rust#53668 for more information -error: ambigious use of `&&` +error: ambiguous use of `&&` --> $DIR/syntax-ambiguity-2015.rs:36:22 | LL | while let true = (1 == 2) && false { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2018.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2018.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2018.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2018.rs 2018-12-04 23:41:40.000000000 +0000 @@ -19,22 +19,22 @@ use std::ops::Range; if let Range { start: _, end: _ } = true..true && false { } - //~^ ERROR ambigious use of `&&` + //~^ ERROR ambiguous use of `&&` if let Range { start: _, end: _ } = true..true || false { } - //~^ ERROR ambigious use of `||` + //~^ ERROR ambiguous use of `||` while let Range { start: _, end: _ } = true..true && false { } - //~^ ERROR ambigious use of `&&` + //~^ ERROR ambiguous use of `&&` while let Range { start: _, end: _ } = true..true || false { } - //~^ ERROR ambigious use of `||` + //~^ ERROR ambiguous use of `||` if let true = false && false { } - //~^ ERROR ambigious use of `&&` + //~^ ERROR ambiguous use of `&&` while let true = (1 == 2) && false { } - //~^ ERROR ambigious use of `&&` + //~^ ERROR ambiguous use of `&&` // The following cases are not an error as parenthesis are used to // clarify intent: diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2018.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2018.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2018.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2018.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ -error: ambigious use of `&&` +error: ambiguous use of `&&` --> $DIR/syntax-ambiguity-2018.rs:21:47 | LL | if let Range { start: _, end: _ } = true..true && false { } @@ -7,7 +7,7 @@ = note: this will be a error until the `let_chains` feature is stabilized = note: see rust-lang/rust#53668 for more information -error: ambigious use of `||` +error: ambiguous use of `||` --> $DIR/syntax-ambiguity-2018.rs:24:47 | LL | if let Range { start: _, end: _ } = true..true || false { } @@ -16,7 +16,7 @@ = note: this will be a error until the `let_chains` feature is stabilized = note: see rust-lang/rust#53668 for more information -error: ambigious use of `&&` +error: ambiguous use of `&&` --> $DIR/syntax-ambiguity-2018.rs:27:50 | LL | while let Range { start: _, end: _ } = true..true && false { } @@ -25,7 +25,7 @@ = note: this will be a error until the `let_chains` feature is stabilized = note: see rust-lang/rust#53668 for more information -error: ambigious use of `||` +error: ambiguous use of `||` --> $DIR/syntax-ambiguity-2018.rs:30:50 | LL | while let Range { start: _, end: _ } = true..true || false { } @@ -34,7 +34,7 @@ = note: this will be a error until the `let_chains` feature is stabilized = note: see rust-lang/rust#53668 for more information -error: ambigious use of `&&` +error: ambiguous use of `&&` --> $DIR/syntax-ambiguity-2018.rs:33:19 | LL | if let true = false && false { } @@ -43,7 +43,7 @@ = note: this will be a error until the `let_chains` feature is stabilized = note: see rust-lang/rust#53668 for more information -error: ambigious use of `&&` +error: ambiguous use of `&&` --> $DIR/syntax-ambiguity-2018.rs:36:22 | LL | while let true = (1 == 2) && false { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/allocator/auxiliary/custom-as-global.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/allocator/auxiliary/custom-as-global.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/allocator/auxiliary/custom-as-global.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/allocator/auxiliary/custom-as-global.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "rlib"] - -extern crate custom; - -use std::sync::atomic::{ATOMIC_USIZE_INIT, Ordering}; - -use custom::A; - -#[global_allocator] -static ALLOCATOR: A = A(ATOMIC_USIZE_INIT); - -pub fn get() -> usize { - ALLOCATOR.0.load(Ordering::SeqCst) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/allocator/auxiliary/custom.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/allocator/auxiliary/custom.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/allocator/auxiliary/custom.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/allocator/auxiliary/custom.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![feature(allocator_api)] -#![crate_type = "rlib"] - -use std::alloc::{GlobalAlloc, System, Layout}; -use std::sync::atomic::{AtomicUsize, Ordering}; - -pub struct A(pub AtomicUsize); - -unsafe impl GlobalAlloc for A { - unsafe fn alloc(&self, layout: Layout) -> *mut u8 { - self.0.fetch_add(1, Ordering::SeqCst); - System.alloc(layout) - } - - unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { - self.0.fetch_add(1, Ordering::SeqCst); - System.dealloc(ptr, layout) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/allocator/auxiliary/helper.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/allocator/auxiliary/helper.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/allocator/auxiliary/helper.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/allocator/auxiliary/helper.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "rlib"] - -use std::fmt; - -pub fn work_with(p: &fmt::Debug) { - drop(p); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/allocator/custom.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/allocator/custom.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/allocator/custom.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/allocator/custom.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// aux-build:helper.rs -// no-prefer-dynamic - -#![feature(allocator_api)] - -extern crate helper; - -use std::alloc::{self, Global, Alloc, System, Layout}; -use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; - -static HITS: AtomicUsize = ATOMIC_USIZE_INIT; - -struct A; - -unsafe impl alloc::GlobalAlloc for A { - unsafe fn alloc(&self, layout: Layout) -> *mut u8 { - HITS.fetch_add(1, Ordering::SeqCst); - System.alloc(layout) - } - - unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { - HITS.fetch_add(1, Ordering::SeqCst); - System.dealloc(ptr, layout) - } -} - -#[global_allocator] -static GLOBAL: A = A; - -fn main() { - println!("hello!"); - - let n = HITS.load(Ordering::SeqCst); - assert!(n > 0); - unsafe { - let layout = Layout::from_size_align(4, 2).unwrap(); - - let ptr = Global.alloc(layout.clone()).unwrap(); - helper::work_with(&ptr); - assert_eq!(HITS.load(Ordering::SeqCst), n + 1); - Global.dealloc(ptr, layout.clone()); - assert_eq!(HITS.load(Ordering::SeqCst), n + 2); - - let s = String::with_capacity(10); - helper::work_with(&s); - assert_eq!(HITS.load(Ordering::SeqCst), n + 3); - drop(s); - assert_eq!(HITS.load(Ordering::SeqCst), n + 4); - - let ptr = System.alloc(layout.clone()).unwrap(); - assert_eq!(HITS.load(Ordering::SeqCst), n + 4); - helper::work_with(&ptr); - System.dealloc(ptr, layout); - assert_eq!(HITS.load(Ordering::SeqCst), n + 4); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/allocator/xcrate-use2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/allocator/xcrate-use2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/allocator/xcrate-use2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/allocator/xcrate-use2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// aux-build:custom.rs -// aux-build:custom-as-global.rs -// aux-build:helper.rs -// no-prefer-dynamic - -#![feature(allocator_api)] - -extern crate custom; -extern crate custom_as_global; -extern crate helper; - -use std::alloc::{alloc, dealloc, GlobalAlloc, System, Layout}; -use std::sync::atomic::{Ordering, ATOMIC_USIZE_INIT}; - -static GLOBAL: custom::A = custom::A(ATOMIC_USIZE_INIT); - -fn main() { - unsafe { - let n = custom_as_global::get(); - let layout = Layout::from_size_align(4, 2).unwrap(); - - // Global allocator routes to the `custom_as_global` global - let ptr = alloc(layout.clone()); - helper::work_with(&ptr); - assert_eq!(custom_as_global::get(), n + 1); - dealloc(ptr, layout.clone()); - assert_eq!(custom_as_global::get(), n + 2); - - // Usage of the system allocator avoids all globals - let ptr = System.alloc(layout.clone()); - helper::work_with(&ptr); - assert_eq!(custom_as_global::get(), n + 2); - System.dealloc(ptr, layout.clone()); - assert_eq!(custom_as_global::get(), n + 2); - - // Usage of our personal allocator doesn't affect other instances - let ptr = GLOBAL.alloc(layout.clone()); - helper::work_with(&ptr); - assert_eq!(custom_as_global::get(), n + 2); - assert_eq!(GLOBAL.0.load(Ordering::SeqCst), 1); - GLOBAL.dealloc(ptr, layout); - assert_eq!(custom_as_global::get(), n + 2); - assert_eq!(GLOBAL.0.load(Ordering::SeqCst), 2); - } -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/allocator/xcrate-use.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/allocator/xcrate-use.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/allocator/xcrate-use.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/allocator/xcrate-use.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// aux-build:custom.rs -// aux-build:helper.rs -// no-prefer-dynamic - -#![feature(allocator_api)] - -extern crate custom; -extern crate helper; - -use std::alloc::{Global, Alloc, System, Layout}; -use std::sync::atomic::{Ordering, ATOMIC_USIZE_INIT}; - -#[global_allocator] -static GLOBAL: custom::A = custom::A(ATOMIC_USIZE_INIT); - -fn main() { - unsafe { - let n = GLOBAL.0.load(Ordering::SeqCst); - let layout = Layout::from_size_align(4, 2).unwrap(); - - let ptr = Global.alloc(layout.clone()).unwrap(); - helper::work_with(&ptr); - assert_eq!(GLOBAL.0.load(Ordering::SeqCst), n + 1); - Global.dealloc(ptr, layout.clone()); - assert_eq!(GLOBAL.0.load(Ordering::SeqCst), n + 2); - - let ptr = System.alloc(layout.clone()).unwrap(); - assert_eq!(GLOBAL.0.load(Ordering::SeqCst), n + 2); - helper::work_with(&ptr); - System.dealloc(ptr, layout); - assert_eq!(GLOBAL.0.load(Ordering::SeqCst), n + 2); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/array_const_index-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/array_const_index-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/array_const_index-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/array_const_index-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -#![feature(const_indexing)] - -fn main() { - const ARR: [i32; 6] = [42, 43, 44, 45, 46, 47]; - const IDX: usize = 3; - const VAL: i32 = ARR[IDX]; - const BLUB: [i32; (ARR[0] - 41) as usize] = [5]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/arr_cycle.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/arr_cycle.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/arr_cycle.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/arr_cycle.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::cell::Cell; - -#[derive(Debug)] -struct B<'a> { - a: [Cell>>; 2] -} - -impl<'a> B<'a> { - fn new() -> B<'a> { - B { a: [Cell::new(None), Cell::new(None)] } - } -} - -fn f() { - let (b1, b2, b3); - b1 = B::new(); - b2 = B::new(); - b3 = B::new(); - b1.a[0].set(Some(&b2)); - b1.a[1].set(Some(&b3)); - b2.a[0].set(Some(&b2)); - b2.a[1].set(Some(&b3)); - b3.a[0].set(Some(&b1)); - b3.a[1].set(Some(&b2)); -} - -fn main() { - f(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/box-of-array-of-drop-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/box-of-array-of-drop-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/box-of-array-of-drop-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/box-of-array-of-drop-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(overflowing_literals)] - -// Test that we cleanup a fixed size Box<[D; k]> properly when D has a -// destructor. - -// ignore-emscripten no threads support - -use std::thread; -use std::sync::atomic::{AtomicUsize, Ordering}; - -static LOG: AtomicUsize = AtomicUsize::new(0); - -struct D(u8); - -impl Drop for D { - fn drop(&mut self) { - println!("Dropping {}", self.0); - let old = LOG.load(Ordering::SeqCst); - LOG.compare_and_swap(old, old << 4 | self.0 as usize, Ordering::SeqCst); - } -} - -fn main() { - fn die() -> D { panic!("Oh no"); } - let g = thread::spawn(|| { - let _b1: Box<[D; 4]> = Box::new([D( 1), D( 2), D( 3), D( 4)]); - let _b2: Box<[D; 4]> = Box::new([D( 5), D( 6), D( 7), D( 8)]); - let _b3: Box<[D; 4]> = Box::new([D( 9), D(10), die(), D(12)]); - let _b4: Box<[D; 4]> = Box::new([D(13), D(14), D(15), D(16)]); - }); - assert!(g.join().is_err()); - - // When the panic occurs, we will be in the midst of constructing - // the input to `_b3`. Therefore, we drop the elements of the - // partially filled array first, before we get around to dropping - // the elements of `_b1` and _b2`. - - // Issue 23222: The order in which the elements actually get - // dropped is a little funky. See similar notes in nested-vec-3; - // in essence, I would not be surprised if we change the ordering - // given in `expect` in the future. - - let expect = 0x__A_9__5_6_7_8__1_2_3_4; - let actual = LOG.load(Ordering::SeqCst); - assert!(actual == expect, "expect: 0x{:x} actual: 0x{:x}", expect, actual); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/box-of-array-of-drop-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/box-of-array-of-drop-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/box-of-array-of-drop-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/box-of-array-of-drop-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(overflowing_literals)] - -// Test that we cleanup dynamic sized Box<[D]> properly when D has a -// destructor. - -// ignore-emscripten no threads support - -use std::thread; -use std::sync::atomic::{AtomicUsize, Ordering}; - -static LOG: AtomicUsize = AtomicUsize::new(0); - -struct D(u8); - -impl Drop for D { - fn drop(&mut self) { - println!("Dropping {}", self.0); - let old = LOG.load(Ordering::SeqCst); - LOG.compare_and_swap(old, old << 4 | self.0 as usize, Ordering::SeqCst); - } -} - -fn main() { - fn die() -> D { panic!("Oh no"); } - let g = thread::spawn(|| { - let _b1: Box<[D; 4]> = Box::new([D( 1), D( 2), D( 3), D( 4)]); - let _b2: Box<[D; 4]> = Box::new([D( 5), D( 6), D( 7), D( 8)]); - let _b3: Box<[D; 4]> = Box::new([D( 9), D(10), die(), D(12)]); - let _b4: Box<[D; 4]> = Box::new([D(13), D(14), D(15), D(16)]); - }); - assert!(g.join().is_err()); - - // When the panic occurs, we will be in the midst of constructing - // the input to `_b3`. Therefore, we drop the elements of the - // partially filled array first, before we get around to dropping - // the elements of `_b1` and _b2`. - - // Issue 23222: The order in which the elements actually get - // dropped is a little funky. See similar notes in nested-vec-3; - // in essence, I would not be surprised if we change the ordering - // given in `expect` in the future. - - let expect = 0x__A_9__5_6_7_8__1_2_3_4; - let actual = LOG.load(Ordering::SeqCst); - assert!(actual == expect, "expect: 0x{:x} actual: 0x{:x}", expect, actual); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/cast-in-array-size.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/cast-in-array-size.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/cast-in-array-size.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/cast-in-array-size.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -// issues #10618 and #16382 -// pretty-expanded FIXME #23616 - -const SIZE: isize = 25; - -fn main() { - let _a: [bool; 1 as usize]; - let _b: [isize; SIZE as usize] = [1; SIZE as usize]; - let _c: [bool; '\n' as usize] = [true; '\n' as usize]; - let _d: [bool; true as usize] = [true; true as usize]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/check-static-mut-slices.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/check-static-mut-slices.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/check-static-mut-slices.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/check-static-mut-slices.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Checks that mutable static items can have mutable slices - - -static mut TEST: &'static mut [isize] = &mut [1]; -static mut EMPTY: &'static mut [isize] = &mut []; - -pub fn main() { - unsafe { - TEST[0] += 1; - assert_eq!(TEST[0], 2); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/check-static-slice.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/check-static-slice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/check-static-slice.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/check-static-slice.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Check that the various ways of getting to a reference to a vec (both sized -// and unsized) work properly. - - -const AA: [isize; 3] = [1, 2, 3]; -const AB: &'static [isize; 3] = &AA; -const AC: &'static [isize] = AB; -const AD: &'static [isize] = &AA; -const AE: &'static [isize; 3] = &[1, 2, 3]; -const AF: &'static [isize] = &[1, 2, 3]; - -static CA: isize = AA[0]; -static CB: isize = AB[1]; -static CC: isize = AC[2]; -static CD: isize = AD[0]; -static CE: isize = AE[1]; -static CF: isize = AF[2]; - -static AG: &'static isize = &AA[2]; - -fn main () { - let b: &[isize] = &[1, 2, 3]; - assert_eq!(AC, b); - assert_eq!(AD, b); - assert_eq!(AF, b); - assert_eq!(*AG, 3); - - assert_eq!(CA, 1); - assert_eq!(CB, 2); - assert_eq!(CC, 3); - assert_eq!(CD, 1); - assert_eq!(CE, 2); - assert_eq!(CF, 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/copy-out-of-array-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/copy-out-of-array-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/copy-out-of-array-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/copy-out-of-array-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Ensure that we can copy out of a fixed-size array. -// -// (Compare with compile-fail/move-out-of-array-1.rs) - -#[derive(Copy, Clone)] -struct C { _x: u8 } - -fn main() { - fn d() -> C { C { _x: 0 } } - - let _d1 = foo([d(), d(), d(), d()], 1); - let _d3 = foo([d(), d(), d(), d()], 3); -} - -fn foo(a: [C; 4], i: usize) -> C { - a[i] -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/destructure-array-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/destructure-array-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/destructure-array-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/destructure-array-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Ensure that we can do a destructuring bind of a fixed-size array, -// even when the element type has a destructor. - -struct D { x: u8 } - -impl Drop for D { fn drop(&mut self) { } } - -fn main() { - fn d(x: u8) -> D { D { x: x } } - - let d1 = foo([d(1), d(2), d(3), d(4)], 1); - let d3 = foo([d(5), d(6), d(7), d(8)], 3); - assert_eq!(d1.x, 2); - assert_eq!(d3.x, 8); -} - -fn foo([a, b, c, d]: [D; 4], i: usize) -> D { - match i { - 0 => a, - 1 => b, - 2 => c, - 3 => d, - _ => panic!("unmatched"), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/empty-mutable-vec.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/empty-mutable-vec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/empty-mutable-vec.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/empty-mutable-vec.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// pretty-expanded FIXME #23616 - -#![allow(unused_mut)] - - -pub fn main() { let mut _v: Vec = Vec::new(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/estr-slice.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/estr-slice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/estr-slice.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/estr-slice.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -pub fn main() { - let x = "hello"; - let v = "hello"; - let y : &str = "there"; - - println!("{}", x); - println!("{}", y); - - assert_eq!(x.as_bytes()[0], 'h' as u8); - assert_eq!(x.as_bytes()[4], 'o' as u8); - - let z : &str = "thing"; - assert_eq!(v, x); - assert!(x != z); - - let a = "aaaa"; - let b = "bbbb"; - - let c = "cccc"; - let cc = "ccccc"; - - println!("{}", a); - - assert!(a < b); - assert!(a <= b); - assert!(a != b); - assert!(b >= a); - assert!(b > a); - - println!("{}", b); - - assert!(a < c); - assert!(a <= c); - assert!(a != c); - assert!(c >= a); - assert!(c > a); - - println!("{}", c); - - assert!(c < cc); - assert!(c <= cc); - assert!(c != cc); - assert!(cc >= c); - assert!(cc > c); - - println!("{}", cc); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/evec-slice.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/evec-slice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/evec-slice.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/evec-slice.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let x : &[isize] = &[1,2,3,4,5]; - let mut z : &[isize] = &[1,2,3,4,5]; - z = x; - assert_eq!(z[0], 1); - assert_eq!(z[4], 5); - - let a : &[isize] = &[1,1,1,1,1]; - let b : &[isize] = &[2,2,2,2,2]; - let c : &[isize] = &[2,2,2,2,3]; - let cc : &[isize] = &[2,2,2,2,2,2]; - - println!("{:?}", a); - - assert!(a < b); - assert!(a <= b); - assert!(a != b); - assert!(b >= a); - assert!(b > a); - - println!("{:?}", b); - - assert!(b < c); - assert!(b <= c); - assert!(b != c); - assert!(c >= b); - assert!(c > b); - - assert!(a < c); - assert!(a <= c); - assert!(a != c); - assert!(c >= a); - assert!(c > a); - - println!("{:?}", c); - - assert!(a < cc); - assert!(a <= cc); - assert!(a != cc); - assert!(cc >= a); - assert!(cc > a); - - println!("{:?}", cc); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/fixed_length_copy.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/fixed_length_copy.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/fixed_length_copy.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/fixed_length_copy.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -pub fn main() { - let arr = [1,2,3]; - let arr2 = arr; - assert_eq!(arr[1], 2); - assert_eq!(arr2[2], 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/huge-largest-array.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/huge-largest-array.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/huge-largest-array.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/huge-largest-array.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -use std::mem::size_of; - -#[cfg(target_pointer_width = "32")] -pub fn main() { - assert_eq!(size_of::<[u8; (1 << 31) - 1]>(), (1 << 31) - 1); -} - -#[cfg(target_pointer_width = "64")] -pub fn main() { - assert_eq!(size_of::<[u8; (1 << 47) - 1]>(), (1 << 47) - 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/ivec-pass-by-value.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/ivec-pass-by-value.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/ivec-pass-by-value.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/ivec-pass-by-value.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn f(_a: Vec ) { } -pub fn main() { f(vec![1, 2, 3, 4, 5]); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/mutability-inherits-through-fixed-length-vec.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/mutability-inherits-through-fixed-length-vec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/mutability-inherits-through-fixed-length-vec.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/mutability-inherits-through-fixed-length-vec.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -fn test1() { - let mut ints = [0; 32]; - ints[0] += 1; - assert_eq!(ints[0], 1); -} - -fn test2() { - let mut ints = [0; 32]; - for i in &mut ints { *i += 22; } - for i in &ints { assert_eq!(*i, 22); } -} - -pub fn main() { - test1(); - test2(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/mutable-alias-vec.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/mutable-alias-vec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/mutable-alias-vec.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/mutable-alias-vec.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn grow(v: &mut Vec ) { - v.push(1); -} - -pub fn main() { - let mut v: Vec = Vec::new(); - grow(&mut v); - grow(&mut v); - grow(&mut v); - let len = v.len(); - println!("{}", len); - assert_eq!(len, 3 as usize); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/nested-vec-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/nested-vec-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/nested-vec-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/nested-vec-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Test that using the `vec!` macro nested within itself works - -fn main() { - let nested = vec![vec![1u32, 2u32, 3u32]]; - assert_eq!(nested[0][1], 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/nested-vec-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/nested-vec-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/nested-vec-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/nested-vec-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Test that using the `vec!` macro nested within itself works -// when the contents implement Drop - -struct D(u32); - -impl Drop for D { - fn drop(&mut self) { println!("Dropping {}", self.0); } -} - -fn main() { - let nested = vec![vec![D(1u32), D(2u32), D(3u32)]]; - assert_eq!(nested[0][1].0, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/nested-vec-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/nested-vec-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/nested-vec-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/nested-vec-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(overflowing_literals)] - -// ignore-emscripten no threads support - -// Test that using the `vec!` macro nested within itself works when -// the contents implement Drop and we hit a panic in the middle of -// construction. - -use std::thread; -use std::sync::atomic::{AtomicUsize, Ordering}; - -static LOG: AtomicUsize = AtomicUsize::new(0); - -struct D(u8); - -impl Drop for D { - fn drop(&mut self) { - println!("Dropping {}", self.0); - let old = LOG.load(Ordering::SeqCst); - LOG.compare_and_swap(old, old << 4 | self.0 as usize, Ordering::SeqCst); - } -} - -fn main() { - fn die() -> D { panic!("Oh no"); } - let g = thread::spawn(|| { - let _nested = vec![vec![D( 1), D( 2), D( 3), D( 4)], - vec![D( 5), D( 6), D( 7), D( 8)], - vec![D( 9), D(10), die(), D(12)], - vec![D(13), D(14), D(15), D(16)]]; - }); - assert!(g.join().is_err()); - - // When the panic occurs, we will be in the midst of constructing the - // second inner vector. Therefore, we drop the elements of the - // partially filled vector first, before we get around to dropping - // the elements of the filled vector. - - // Issue 23222: The order in which the elements actually get - // dropped is a little funky: as noted above, we'll drop the 9+10 - // first, but due to #23222, they get dropped in reverse - // order. Likewise, again due to #23222, we will drop the second - // filled vec before the first filled vec. - // - // If Issue 23222 is "fixed", then presumably the corrected - // expected order of events will be 0x__9_A__1_2_3_4__5_6_7_8; - // that is, we would still drop 9+10 first, since they belong to - // the more deeply nested expression when the panic occurs. - - let expect = 0x__A_9__5_6_7_8__1_2_3_4; - let actual = LOG.load(Ordering::SeqCst); - assert!(actual == expect, "expect: 0x{:x} actual: 0x{:x}", expect, actual); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/new-style-fixed-length-vec.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/new-style-fixed-length-vec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/new-style-fixed-length-vec.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/new-style-fixed-length-vec.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -static FOO: [isize; 3] = [1, 2, 3]; - -pub fn main() { - println!("{} {} {}", FOO[0], FOO[1], FOO[2]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/rcvr-borrowed-to-slice.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/rcvr-borrowed-to-slice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/rcvr-borrowed-to-slice.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/rcvr-borrowed-to-slice.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![allow(non_camel_case_types)] - -trait sum { - fn sum_(self) -> isize; -} - -// Note: impl on a slice -impl<'a> sum for &'a [isize] { - fn sum_(self) -> isize { - self.iter().fold(0, |a, &b| a + b) - } -} - -fn call_sum(x: &[isize]) -> isize { x.sum_() } - -pub fn main() { - let x = vec![1, 2, 3]; - let y = call_sum(&x); - println!("y=={}", y); - assert_eq!(y, 6); - - let x = vec![1, 2, 3]; - let y = x.sum_(); - println!("y=={}", y); - assert_eq!(y, 6); - - let x = vec![1, 2, 3]; - let y = x.sum_(); - println!("y=={}", y); - assert_eq!(y, 6); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/repeated-vector-syntax.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/repeated-vector-syntax.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/repeated-vector-syntax.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/repeated-vector-syntax.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let x = [ [true]; 512 ]; - let y = [ 0; 1 ]; - - print!("["); - for xi in &x[..] { - print!("{:?}, ", &xi[..]); - } - println!("]"); - println!("{:?}", &y[..]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/show-boxed-slice.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/show-boxed-slice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/show-boxed-slice.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/show-boxed-slice.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#[derive(Debug)] -struct Foo(Box<[u8]>); - -pub fn main() { - println!("{:?}", Foo(Box::new([0, 1, 2]))); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Test slicing expressions on slices and Vecs. - - -fn main() { - let x: &[isize] = &[1, 2, 3, 4, 5]; - let cmp: &[isize] = &[1, 2, 3, 4, 5]; - assert_eq!(&x[..], cmp); - let cmp: &[isize] = &[3, 4, 5]; - assert_eq!(&x[2..], cmp); - let cmp: &[isize] = &[1, 2, 3]; - assert_eq!(&x[..3], cmp); - let cmp: &[isize] = &[2, 3, 4]; - assert_eq!(&x[1..4], cmp); - - let x: Vec = vec![1, 2, 3, 4, 5]; - let cmp: &[isize] = &[1, 2, 3, 4, 5]; - assert_eq!(&x[..], cmp); - let cmp: &[isize] = &[3, 4, 5]; - assert_eq!(&x[2..], cmp); - let cmp: &[isize] = &[1, 2, 3]; - assert_eq!(&x[..3], cmp); - let cmp: &[isize] = &[2, 3, 4]; - assert_eq!(&x[1..4], cmp); - - let x: &mut [isize] = &mut [1, 2, 3, 4, 5]; - { - let cmp: &mut [isize] = &mut [1, 2, 3, 4, 5]; - assert_eq!(&mut x[..], cmp); - } - { - let cmp: &mut [isize] = &mut [3, 4, 5]; - assert_eq!(&mut x[2..], cmp); - } - { - let cmp: &mut [isize] = &mut [1, 2, 3]; - assert_eq!(&mut x[..3], cmp); - } - { - let cmp: &mut [isize] = &mut [2, 3, 4]; - assert_eq!(&mut x[1..4], cmp); - } - - let mut x: Vec = vec![1, 2, 3, 4, 5]; - { - let cmp: &mut [isize] = &mut [1, 2, 3, 4, 5]; - assert_eq!(&mut x[..], cmp); - } - { - let cmp: &mut [isize] = &mut [3, 4, 5]; - assert_eq!(&mut x[2..], cmp); - } - { - let cmp: &mut [isize] = &mut [1, 2, 3]; - assert_eq!(&mut x[..3], cmp); - } - { - let cmp: &mut [isize] = &mut [2, 3, 4]; - assert_eq!(&mut x[1..4], cmp); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice_binary_search.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice_binary_search.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice_binary_search.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice_binary_search.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Test binary_search_by_key lifetime. Issue #34683 - -#[derive(Debug)] -struct Assignment { - topic: String, - partition: i32, -} - -fn main() { - let xs = vec![ - Assignment { topic: "abc".into(), partition: 1 }, - Assignment { topic: "def".into(), partition: 2 }, - Assignment { topic: "ghi".into(), partition: 3 }, - ]; - - let key: &str = "def"; - let r = xs.binary_search_by_key(&key, |e| &e.topic); - assert_eq!(Ok(1), r.map(|i| i)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice-of-zero-size-elements.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice-of-zero-size-elements.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice-of-zero-size-elements.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice-of-zero-size-elements.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -// compile-flags: -C debug-assertions - -#![feature(iter_to_slice)] - -use std::slice; - -fn foo(v: &[T]) -> Option<&[T]> { - let mut it = v.iter(); - for _ in 0..5 { - let _ = it.next(); - } - Some(it.as_slice()) -} - -fn foo_mut(v: &mut [T]) -> Option<&mut [T]> { - let mut it = v.iter_mut(); - for _ in 0..5 { - let _ = it.next(); - } - Some(it.into_slice()) -} - -pub fn main() { - // In a slice of zero-size elements the pointer is meaningless. - // Ensure iteration still works even if the pointer is at the end of the address space. - let slice: &[()] = unsafe { slice::from_raw_parts(-5isize as *const (), 10) }; - assert_eq!(slice.len(), 10); - assert_eq!(slice.iter().count(), 10); - - // .nth() on the iterator should also behave correctly - let mut it = slice.iter(); - assert!(it.nth(5).is_some()); - assert_eq!(it.count(), 4); - - // Converting Iter to a slice should never have a null pointer - assert!(foo(slice).is_some()); - - // Test mutable iterators as well - let slice: &mut [()] = unsafe { slice::from_raw_parts_mut(-5isize as *mut (), 10) }; - assert_eq!(slice.len(), 10); - assert_eq!(slice.iter_mut().count(), 10); - - { - let mut it = slice.iter_mut(); - assert!(it.nth(5).is_some()); - assert_eq!(it.count(), 4); - } - - assert!(foo_mut(slice).is_some()) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice-panic-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice-panic-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice-panic-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice-panic-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// ignore-emscripten no threads support - -// Test that if a slicing expr[..] fails, the correct cleanups happen. - - -use std::thread; - -struct Foo; - -static mut DTOR_COUNT: isize = 0; - -impl Drop for Foo { - fn drop(&mut self) { unsafe { DTOR_COUNT += 1; } } -} - -fn foo() { - let x: &[_] = &[Foo, Foo]; - &x[3..4]; -} - -fn main() { - let _ = thread::spawn(move|| foo()).join(); - unsafe { assert_eq!(DTOR_COUNT, 2); } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice-panic-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice-panic-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice-panic-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice-panic-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// ignore-emscripten no threads support - -// Test that if a slicing expr[..] fails, the correct cleanups happen. - - -use std::thread; - -struct Foo; - -static mut DTOR_COUNT: isize = 0; - -impl Drop for Foo { - fn drop(&mut self) { unsafe { DTOR_COUNT += 1; } } -} - -fn bar() -> usize { - panic!(); -} - -fn foo() { - let x: &[_] = &[Foo, Foo]; - &x[3..bar()]; -} - -fn main() { - let _ = thread::spawn(move|| foo()).join(); - unsafe { assert_eq!(DTOR_COUNT, 2); } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/slice.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,90 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Test slicing sugar. - -extern crate core; -use core::ops::{Index, IndexMut, Range, RangeTo, RangeFrom, RangeFull}; - -static mut COUNT: usize = 0; - -struct Foo; - -impl Index> for Foo { - type Output = Foo; - fn index(&self, index: Range) -> &Foo { - unsafe { COUNT += 1; } - self - } -} -impl Index> for Foo { - type Output = Foo; - fn index(&self, index: RangeTo) -> &Foo { - unsafe { COUNT += 1; } - self - } -} -impl Index> for Foo { - type Output = Foo; - fn index(&self, index: RangeFrom) -> &Foo { - unsafe { COUNT += 1; } - self - } -} -impl Index for Foo { - type Output = Foo; - fn index(&self, _index: RangeFull) -> &Foo { - unsafe { COUNT += 1; } - self - } -} - -impl IndexMut> for Foo { - fn index_mut(&mut self, index: Range) -> &mut Foo { - unsafe { COUNT += 1; } - self - } -} -impl IndexMut> for Foo { - fn index_mut(&mut self, index: RangeTo) -> &mut Foo { - unsafe { COUNT += 1; } - self - } -} -impl IndexMut> for Foo { - fn index_mut(&mut self, index: RangeFrom) -> &mut Foo { - unsafe { COUNT += 1; } - self - } -} -impl IndexMut for Foo { - fn index_mut(&mut self, _index: RangeFull) -> &mut Foo { - unsafe { COUNT += 1; } - self - } -} - - -fn main() { - let mut x = Foo; - &x[..]; - &x[Foo..]; - &x[..Foo]; - &x[Foo..Foo]; - &mut x[..]; - &mut x[Foo..]; - &mut x[..Foo]; - &mut x[Foo..Foo]; - unsafe { - assert_eq!(COUNT, 8); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/variance-vec-covariant.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/variance-vec-covariant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/variance-vec-covariant.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/variance-vec-covariant.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Test that vec is now covariant in its argument type. - -#![allow(dead_code)] - -fn foo<'a,'b>(v1: Vec<&'a i32>, v2: Vec<&'b i32>) -> i32 { - bar(v1, v2).cloned().unwrap_or(0) // only type checks if we can intersect 'a and 'b -} - -fn bar<'c>(v1: Vec<&'c i32>, v2: Vec<&'c i32>) -> Option<&'c i32> { - v1.get(0).cloned().or_else(|| v2.get(0).cloned()) -} - -fn main() { - let x = 22; - let y = 44; - assert_eq!(foo(vec![&x], vec![&y]), 22); - assert_eq!(foo(vec![&y], vec![&x]), 44); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-concat.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-concat.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-concat.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-concat.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::vec; - -pub fn main() { - let a: Vec = vec![1, 2, 3, 4, 5]; - let b: Vec = vec![6, 7, 8, 9, 0]; - let mut v: Vec = a; - v.extend_from_slice(&b); - println!("{}", v[9]); - assert_eq!(v[0], 1); - assert_eq!(v[7], 8); - assert_eq!(v[9], 0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec_cycle.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec_cycle.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec_cycle.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec_cycle.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::cell::Cell; - -#[derive(Debug)] -struct C<'a> { - v: Vec>>>, -} - -impl<'a> C<'a> { - fn new() -> C<'a> { - C { v: Vec::new() } - } -} - -fn f() { - let (mut c1, mut c2, mut c3); - c1 = C::new(); - c2 = C::new(); - c3 = C::new(); - - c1.v.push(Cell::new(None)); - c1.v.push(Cell::new(None)); - c2.v.push(Cell::new(None)); - c2.v.push(Cell::new(None)); - c3.v.push(Cell::new(None)); - c3.v.push(Cell::new(None)); - - c1.v[0].set(Some(&c2)); - c1.v[1].set(Some(&c3)); - c2.v[0].set(Some(&c2)); - c2.v[1].set(Some(&c3)); - c3.v[0].set(Some(&c1)); - c3.v[1].set(Some(&c2)); -} - -fn main() { - f(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec_cycle_wrapped.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec_cycle_wrapped.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec_cycle_wrapped.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec_cycle_wrapped.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::cell::Cell; - -#[derive(Debug)] -struct Refs<'a> { - v: Vec>>>, -} - -#[derive(Debug)] -struct C<'a> { - refs: Refs<'a>, -} - -impl<'a> Refs<'a> { - fn new() -> Refs<'a> { - Refs { v: Vec::new() } - } -} - -impl<'a> C<'a> { - fn new() -> C<'a> { - C { refs: Refs::new() } - } -} - -fn f() { - let (mut c1, mut c2, mut c3); - c1 = C::new(); - c2 = C::new(); - c3 = C::new(); - - c1.refs.v.push(Cell::new(None)); - c1.refs.v.push(Cell::new(None)); - c2.refs.v.push(Cell::new(None)); - c2.refs.v.push(Cell::new(None)); - c3.refs.v.push(Cell::new(None)); - c3.refs.v.push(Cell::new(None)); - - c1.refs.v[0].set(Some(&c2)); - c1.refs.v[1].set(Some(&c3)); - c2.refs.v[0].set(Some(&c2)); - c2.refs.v[1].set(Some(&c3)); - c3.refs.v[0].set(Some(&c1)); - c3.refs.v[1].set(Some(&c2)); -} - -fn main() { - f(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-dst.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-dst.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-dst.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-dst.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(box_syntax)] - -pub fn main() { - // Tests for indexing into box/& [T; n] - let x: [isize; 3] = [1, 2, 3]; - let mut x: Box<[isize; 3]> = box x; - assert_eq!(x[0], 1); - assert_eq!(x[1], 2); - assert_eq!(x[2], 3); - x[1] = 45; - assert_eq!(x[0], 1); - assert_eq!(x[1], 45); - assert_eq!(x[2], 3); - - let mut x: [isize; 3] = [1, 2, 3]; - let x: &mut [isize; 3] = &mut x; - assert_eq!(x[0], 1); - assert_eq!(x[1], 2); - assert_eq!(x[2], 3); - x[1] = 45; - assert_eq!(x[0], 1); - assert_eq!(x[1], 45); - assert_eq!(x[2], 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-fixed-length.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-fixed-length.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-fixed-length.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-fixed-length.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -use std::mem::size_of; - -#[cfg(not(target_pointer_width = "64"))] -fn test_big_vec() {} - -#[cfg(target_pointer_width = "64")] -fn test_big_vec() -{ - assert_eq!(size_of::<[u8; (1 << 32)]>(), (1 << 32)); -} - -fn main() { - let x: [isize; 4] = [1, 2, 3, 4]; - assert_eq!(x[0], 1); - assert_eq!(x[1], 2); - assert_eq!(x[2], 3); - assert_eq!(x[3], 4); - - assert_eq!(size_of::<[u8; 4]>(), 4); - test_big_vec(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-growth.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-growth.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-growth.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-growth.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - -pub fn main() { - let mut v = vec![1]; - v.push(2); - v.push(3); - v.push(4); - v.push(5); - assert_eq!(v[0], 1); - assert_eq!(v[1], 2); - assert_eq!(v[2], 3); - assert_eq!(v[3], 4); - assert_eq!(v[4], 5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-late-init.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-late-init.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-late-init.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-late-init.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -pub fn main() { - let mut later: Vec ; - if true { later = vec![1]; } else { later = vec![2]; } - println!("{}", later[0]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-macro-no-std.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-macro-no-std.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-macro-no-std.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-macro-no-std.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// ignore-emscripten no no_std executables - -#![feature(lang_items, start, libc, alloc)] -#![no_std] - -extern crate std as other; - -extern crate libc; - -#[macro_use] -extern crate alloc; - -use alloc::vec::Vec; - -// Issue #16806 - -#[start] -fn start(_argc: isize, _argv: *const *const u8) -> isize { - let x: Vec = vec![0, 1, 2]; - match x.last() { - Some(&2) => (), - _ => panic!(), - } - 0 -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-macro-repeat.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-macro-repeat.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-macro-repeat.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-macro-repeat.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - -pub fn main() { - assert_eq!(vec![1; 3], vec![1, 1, 1]); - assert_eq!(vec![1; 2], vec![1, 1]); - assert_eq!(vec![1; 1], vec![1]); - assert_eq!(vec![1; 0], vec![]); - - // from_elem syntax (see RFC 832) - let el = Box::new(1); - let n = 3; - assert_eq!(vec![el; n], vec![Box::new(1), Box::new(1), Box::new(1)]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-macro-rvalue-scope.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-macro-rvalue-scope.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-macro-rvalue-scope.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-macro-rvalue-scope.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -fn one() -> i32 { 1 } - -// Make sure the vec![...] macro doesn't introduce hidden rvalue -// scopes (such as blocks) around the element expressions. -pub fn main() { - assert_eq!(vec![&one(), &one(), &2], vec![&1, &1, &(one()+one())]); - assert_eq!(vec![&one(); 2], vec![&1, &one()]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-macro-with-brackets.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-macro-with-brackets.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-macro-with-brackets.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-macro-with-brackets.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// pretty-expanded FIXME #23616 - -macro_rules! vec [ - ($($e:expr),*) => ({ - let mut _temp = ::std::vec::Vec::new(); - $(_temp.push($e);)* - _temp - }) -]; - -pub fn main() { - let my_vec = vec![1, 2, 3, 4, 5]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-macro-with-trailing-comma.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-macro-with-trailing-comma.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-macro-with-trailing-comma.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-macro-with-trailing-comma.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - -pub fn main() { - assert_eq!(vec![1], vec![1,]); - assert_eq!(vec![1, 2, 3], vec![1, 2, 3,]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-matching-autoslice.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-matching-autoslice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-matching-autoslice.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-matching-autoslice.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(illegal_floating_point_literal_pattern)] // FIXME #41620 - -pub fn main() { - let x = [1, 2, 3]; - match x { - [2, _, _] => panic!(), - [1, a, b] => { - assert_eq!([a, b], [2, 3]); - } - [_, _, _] => panic!(), - } - - let y = ([(1, true), (2, false)], 0.5f64); - match y { - ([(1, a), (b, false)], _) => { - assert_eq!(a, true); - assert_eq!(b, 2); - } - ([_, _], 0.5) => panic!(), - ([_, _], _) => panic!(), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-matching-fixed.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-matching-fixed.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-matching-fixed.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-matching-fixed.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(slice_patterns)] - -fn a() { - let x = [1, 2, 3]; - match x { - [1, 2, 4] => unreachable!(), - [0, 2, 3, ..] => unreachable!(), - [0, .., 3] => unreachable!(), - [0, ..] => unreachable!(), - [1, 2, 3] => (), - [_, _, _] => unreachable!(), - } - match x { - [..] => (), - } - match x { - [_, _, _, ..] => (), - } - match x { - [a, b, c] => { - assert_eq!(1, a); - assert_eq!(2, b); - assert_eq!(3, c); - } - } -} - -pub fn main() { - a(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-matching-fold.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-matching-fold.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-matching-fold.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-matching-fold.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(slice_patterns)] - -use std::fmt::Debug; - -fn foldl(values: &[T], - initial: U, - mut function: F) - -> U where - U: Clone+Debug, T:Debug, - F: FnMut(U, &T) -> U, -{ match values { - &[ref head, ref tail..] => - foldl(tail, function(initial, head), function), - &[] => { - // FIXME: call guards - let res = initial.clone(); res - } - } -} - -fn foldr(values: &[T], - initial: U, - mut function: F) - -> U where - U: Clone, - F: FnMut(&T, U) -> U, -{ - match values { - &[ref head.., ref tail] => - foldr(head, function(tail, initial), function), - &[] => { - // FIXME: call guards - let res = initial.clone(); res - } - } -} - -pub fn main() { - let x = &[1, 2, 3, 4, 5]; - - let product = foldl(x, 1, |a, b| a * *b); - assert_eq!(product, 120); - - let sum = foldr(x, 0, |a, b| *a + b); - assert_eq!(sum, 15); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-matching-legal-tail-element-borrow.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-matching-legal-tail-element-borrow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-matching-legal-tail-element-borrow.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-matching-legal-tail-element-borrow.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(slice_patterns)] - -pub fn main() { - let x = &[1, 2, 3, 4, 5]; - let x: &[isize] = &[1, 2, 3, 4, 5]; - if !x.is_empty() { - let el = match x { - &[1, ref tail..] => &tail[0], - _ => unreachable!() - }; - println!("{}", *el); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-matching.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-matching.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-matching.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-matching.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,169 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(slice_patterns)] - -fn a() { - let x = [1]; - match x { - [a] => { - assert_eq!(a, 1); - } - } -} - -fn b() { - let x = [1, 2, 3]; - match x { - [a, b, c..] => { - assert_eq!(a, 1); - assert_eq!(b, 2); - let expected: &[_] = &[3]; - assert_eq!(c, expected); - } - } - match x { - [a.., b, c] => { - let expected: &[_] = &[1]; - assert_eq!(a, expected); - assert_eq!(b, 2); - assert_eq!(c, 3); - } - } - match x { - [a, b.., c] => { - assert_eq!(a, 1); - let expected: &[_] = &[2]; - assert_eq!(b, expected); - assert_eq!(c, 3); - } - } - match x { - [a, b, c] => { - assert_eq!(a, 1); - assert_eq!(b, 2); - assert_eq!(c, 3); - } - } -} - - -fn b_slice() { - let x : &[_] = &[1, 2, 3]; - match x { - &[a, b, ref c..] => { - assert_eq!(a, 1); - assert_eq!(b, 2); - let expected: &[_] = &[3]; - assert_eq!(c, expected); - } - _ => unreachable!() - } - match x { - &[ref a.., b, c] => { - let expected: &[_] = &[1]; - assert_eq!(a, expected); - assert_eq!(b, 2); - assert_eq!(c, 3); - } - _ => unreachable!() - } - match x { - &[a, ref b.., c] => { - assert_eq!(a, 1); - let expected: &[_] = &[2]; - assert_eq!(b, expected); - assert_eq!(c, 3); - } - _ => unreachable!() - } - match x { - &[a, b, c] => { - assert_eq!(a, 1); - assert_eq!(b, 2); - assert_eq!(c, 3); - } - _ => unreachable!() - } -} - -fn c() { - let x = [1]; - match x { - [2, ..] => panic!(), - [..] => () - } -} - -fn d() { - let x = [1, 2, 3]; - let branch = match x { - [1, 1, ..] => 0, - [1, 2, 3, ..] => 1, - [1, 2, ..] => 2, - _ => 3 - }; - assert_eq!(branch, 1); -} - -fn e() { - let x: &[isize] = &[1, 2, 3]; - let a = match *x { - [1, 2] => 0, - [..] => 1, - }; - - assert_eq!(a, 1); - - let b = match *x { - [2, ..] => 0, - [1, 2, ..] => 1, - [_] => 2, - [..] => 3 - }; - - assert_eq!(b, 1); - - - let c = match *x { - [_, _, _, _, ..] => 0, - [1, 2, ..] => 1, - [_] => 2, - [..] => 3 - }; - - assert_eq!(c, 1); -} - -fn f() { - let x = &[1, 2, 3, 4, 5]; - let [a, [b, [c, ..].., d].., e] = *x; - assert_eq!((a, b, c, d, e), (1, 2, 3, 4, 5)); - - let x: &[isize] = x; - let (a, b, c, d, e) = match *x { - [a, [b, [c, ..].., d].., e] => (a, b, c, d, e), - _ => unimplemented!() - }; - - assert_eq!((a, b, c, d, e), (1, 2, 3, 4, 5)); -} - -pub fn main() { - a(); - b(); - b_slice(); - c(); - d(); - e(); - f(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-push.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-push.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-push.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-push.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { let mut v = vec![1, 2, 3]; v.push(1); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-repeat-with-cast.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-repeat-with-cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-repeat-with-cast.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-repeat-with-cast.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// pretty-expanded FIXME #23616 - -pub fn main() { let _a = [0; 1 as usize]; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - -pub fn main() { - let v: Vec = vec![10, 20]; - assert_eq!(v[0], 10); - assert_eq!(v[1], 20); - let mut x: usize = 0; - assert_eq!(v[x], 10); - assert_eq!(v[x + 1], 20); - x = x + 1; - assert_eq!(v[x], 20); - assert_eq!(v[x - 1], 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-slice-drop.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-slice-drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-slice-drop.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-slice-drop.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![allow(non_camel_case_types)] - -use std::cell::Cell; - -// Make sure that destructors get run on slice literals -struct foo<'a> { - x: &'a Cell, -} - -impl<'a> Drop for foo<'a> { - fn drop(&mut self) { - self.x.set(self.x.get() + 1); - } -} - -fn foo(x: &Cell) -> foo { - foo { - x: x - } -} - -pub fn main() { - let x = &Cell::new(0); - { - let l = &[foo(x)]; - assert_eq!(l[0].x.get(), 0); - } - assert_eq!(x.get(), 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-slice.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-slice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-slice.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-slice.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -pub fn main() { - let v = vec![1,2,3,4,5]; - let v2 = &v[1..3]; - assert_eq!(v2[0], 2); - assert_eq!(v2[1], 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-tail-matching.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-tail-matching.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-tail-matching.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-tail-matching.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(slice_patterns)] - -struct Foo { - string: &'static str -} - -pub fn main() { - let x = [ - Foo { string: "foo" }, - Foo { string: "bar" }, - Foo { string: "baz" } - ]; - match x { - [ref first, ref tail..] => { - assert_eq!(first.string, "foo"); - assert_eq!(tail.len(), 2); - assert_eq!(tail[0].string, "bar"); - assert_eq!(tail[1].string, "baz"); - - match *(tail as &[_]) { - [Foo { .. }, _, Foo { .. }, ref _tail..] => { - unreachable!(); - } - [Foo { string: ref a }, Foo { string: ref b }] => { - assert_eq!("bar", &a[0..a.len()]); - assert_eq!("baz", &b[0..b.len()]); - } - _ => { - unreachable!(); - } - } - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vector-no-ann-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vector-no-ann-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vector-no-ann-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vector-no-ann-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - -pub fn main() { let _quux: Box> = box Vec::new(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-to_str.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-to_str.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-to_str.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/array-slice-vec/vec-to_str.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -pub fn main() { - assert_eq!(format!("{:?}", vec![0, 1]), "[0, 1]".to_string()); - - let foo = vec![3, 4]; - let bar: &[isize] = &[4, 5]; - - assert_eq!(format!("{:?}", foo), "[3, 4]"); - assert_eq!(format!("{:?}", bar), "[4, 5]"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-const-eval.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-const-eval.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-const-eval.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-const-eval.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait Foo { - const NUM: usize; -} - -impl Foo for i32 { - const NUM: usize = 1; -} - -const FOO: usize = ::NUM; - -fn main() { - assert_eq!(1, FOO); - - match 1 { - ::NUM => {}, - _ => assert!(false) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-cross-crate-const-eval.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-cross-crate-const-eval.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-cross-crate-const-eval.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-cross-crate-const-eval.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:associated-const-cc-lib.rs - - -extern crate associated_const_cc_lib as foolib; - -pub struct LocalFoo; - -impl foolib::Foo for LocalFoo { - const BAR: usize = 1; -} - -const FOO_1: usize = ::BAR; -const FOO_2: usize = ::BAR; -const FOO_3: usize = foolib::InherentBar::BAR; - -fn main() { - assert_eq!(0, FOO_1); - assert_eq!(1, FOO_2); - assert_eq!(3, FOO_3); - - match 0 { - ::BAR => {}, - ::BAR => assert!(false), - foolib::InherentBar::BAR => assert!(false), - _ => assert!(false) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-cross-crate-defaults.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-cross-crate-defaults.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-cross-crate-defaults.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-cross-crate-defaults.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:associated-const-cc-lib.rs - - -extern crate associated_const_cc_lib as foolib; - -pub struct LocalFooUseDefault; - -impl foolib::FooDefault for LocalFooUseDefault {} - -pub struct LocalFooOverwriteDefault; - -impl foolib::FooDefault for LocalFooOverwriteDefault { - const BAR: usize = 4; -} - -fn main() { - assert_eq!(1, ::BAR); - assert_eq!(2, ::BAR); - assert_eq!(1, ::BAR); - assert_eq!(4, ::BAR); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-cross-crate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:associated-const-cc-lib.rs - - -extern crate associated_const_cc_lib as foolib; - -pub struct LocalFoo; - -impl foolib::Foo for LocalFoo { - const BAR: usize = 1; -} - -fn main() { - assert_eq!(0, ::BAR); - assert_eq!(1, ::BAR); - assert_eq!(3, foolib::InherentBar::BAR); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-in-global-const.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-in-global-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-in-global-const.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-in-global-const.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct Foo; - -impl Foo { - const BAR: f32 = 1.5; -} - -const FOOBAR: f32 = ::BAR; - -fn main() { - assert_eq!(1.5f32, FOOBAR); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-inherent-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-inherent-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-inherent-impl.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-inherent-impl.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct Foo; - -impl Foo { - const ID: i32 = 1; -} - -fn main() { - assert_eq!(1, Foo::ID); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-marks-live-code.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-marks-live-code.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-marks-live-code.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-marks-live-code.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![deny(dead_code)] - -const GLOBAL_BAR: u32 = 1; - -struct Foo; - -impl Foo { - const BAR: u32 = GLOBAL_BAR; -} - -pub fn main() { - let _: u32 = Foo::BAR; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-match-patterns.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-match-patterns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-match-patterns.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-match-patterns.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:empty-struct.rs - - -extern crate empty_struct; -use empty_struct::XEmpty2 as XFoo; - -struct Foo; - -#[derive(PartialEq, Eq)] -enum Bar { - Var1, - Var2, -} - -// Use inherent and trait impls to test UFCS syntax. -impl Foo { - const MYBAR: Bar = Bar::Var2; -} - -trait HasBar { - const THEBAR: Bar; -} - -impl HasBar for Foo { - const THEBAR: Bar = Bar::Var1; -} - -impl HasBar for XFoo { - const THEBAR: Bar = Bar::Var1; -} - -fn main() { - // Inherent impl - assert!(match Bar::Var2 { - Foo::MYBAR => true, - _ => false, - }); - assert!(match Bar::Var2 { - ::MYBAR => true, - _ => false, - }); - // Trait impl - assert!(match Bar::Var1 { - Foo::THEBAR => true, - _ => false, - }); - assert!(match Bar::Var1 { - ::THEBAR => true, - _ => false, - }); - assert!(match Bar::Var1 { - ::THEBAR => true, - _ => false, - }); - assert!(match Bar::Var1 { - XFoo::THEBAR => true, - _ => false, - }); - assert!(match Bar::Var1 { - ::THEBAR => true, - _ => false, - }); - assert!(match Bar::Var1 { - ::THEBAR => true, - _ => false, - }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-outer-ty-refs.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-outer-ty-refs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-outer-ty-refs.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-outer-ty-refs.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Lattice { - const BOTTOM: Self; -} - -impl Lattice for Option { - const BOTTOM: Option = None; -} - -fn main(){} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-overwrite-default.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-overwrite-default.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-overwrite-default.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-overwrite-default.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait Foo { - const ID: i32 = 2; -} - -impl Foo for i32 { - const ID: i32 = 1; -} - -fn main() { - assert_eq!(1, ::ID); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-public-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-public-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-public-impl.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-public-impl.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -mod bar1 { - pub use self::bar2::Foo; - mod bar2 { - pub struct Foo; - - impl Foo { - pub const ID: i32 = 1; - } - } -} - -fn main() { - assert_eq!(1, bar1::Foo::ID); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-range-match-patterns.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-range-match-patterns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-range-match-patterns.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-range-match-patterns.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct Foo; - -trait HasNum { - const NUM: isize; -} -impl HasNum for Foo { - const NUM: isize = 1; -} - -fn main() { - assert!(match 2 { - Foo::NUM ... 3 => true, - _ => false, - }); - assert!(match 0 { - -1 ... ::NUM => true, - _ => false, - }); - assert!(match 1 { - ::NUM ... ::NUM => true, - _ => false, - }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-resolution-order.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-resolution-order.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-resolution-order.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-resolution-order.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct MyType; - -impl MyType { - const IMPL_IS_INHERENT: bool = true; -} - -trait MyTrait { - const IMPL_IS_INHERENT: bool; - const IMPL_IS_ON_TRAIT: bool; -} - -impl MyTrait for MyType { - const IMPL_IS_INHERENT: bool = false; - const IMPL_IS_ON_TRAIT: bool = true; -} - -fn main() { - // Check that the inherent impl is used before the trait, but that the trait - // can still be accessed. - assert!(::IMPL_IS_INHERENT); - assert!(!::IMPL_IS_INHERENT); - assert!(::IMPL_IS_ON_TRAIT); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait Foo { - const ID: i32; -} - -impl Foo for i32 { - const ID: i32 = 1; -} - -fn main() { - assert_eq!(1, ::ID); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-self-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-self-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-self-type.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-self-type.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait MyInt { - const ONE: Self; -} - -impl MyInt for i32 { - const ONE: i32 = 1; -} - -fn main() { - assert_eq!(1, ::ONE); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-type-parameters.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-type-parameters.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-type-parameters.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-type-parameters.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait Foo { - const X: i32; - fn get_x() -> i32 { - Self::X - } -} - -struct Abc; -impl Foo for Abc { - const X: i32 = 11; -} - -struct Def; -impl Foo for Def { - const X: i32 = 97; -} - -struct Proxy(T); - -impl Foo for Proxy { - const X: i32 = T::X; -} - -fn sub() -> i32 { - A::X - B::X -} - -trait Bar: Foo { - const Y: i32 = Self::X; -} - -fn main() { - assert_eq!(11, Abc::X); - assert_eq!(97, Def::X); - assert_eq!(11, Abc::get_x()); - assert_eq!(97, Def::get_x()); - assert_eq!(-86, sub::()); - assert_eq!(86, sub::()); - assert_eq!(-86, sub::, Def>()); - assert_eq!(-86, sub::>()); - assert_eq!(86, sub::, Proxy>()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-ufcs-infer-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-ufcs-infer-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-ufcs-infer-trait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-ufcs-infer-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait Foo { - const ID: i32; -} - -impl Foo for i32 { - const ID: i32 = 1; -} - -fn main() { - assert_eq!(1, ::ID); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-use-default.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-use-default.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-use-default.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-use-default.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait Foo { - const ID: i32 = 1; -} - -impl Foo for i32 {} - -fn main() { - assert_eq!(1, ::ID); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-use-impl-of-same-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-use-impl-of-same-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-use-impl-of-same-trait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/associated-const-use-impl-of-same-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// The main purpose of this test is to ensure that different impls of the same -// trait can refer to each other without setting off the static recursion check -// (as long as there's no actual recursion). - -trait Foo { - const BAR: u32; -} - -struct IsFoo1; - -impl Foo for IsFoo1 { - const BAR: u32 = 1; -} - -struct IsFoo2; - -impl Foo for IsFoo2 { - const BAR: u32 = ::BAR; -} - -fn main() { - assert_eq!(::BAR, ::BAR); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/auxiliary/associated-const-cc-lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/auxiliary/associated-const-cc-lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/auxiliary/associated-const-cc-lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/auxiliary/associated-const-cc-lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -#![crate_type="lib"] - -// These items are for testing that associated consts work cross-crate. -pub trait Foo { - const BAR: usize; -} - -pub struct FooNoDefault; - -impl Foo for FooNoDefault { - const BAR: usize = 0; -} - -// These test that defaults and default resolution work cross-crate. -pub trait FooDefault { - const BAR: usize = 1; -} - -pub struct FooOverwriteDefault; - -impl FooDefault for FooOverwriteDefault { - const BAR: usize = 2; -} - -pub struct FooUseDefault; - -impl FooDefault for FooUseDefault {} - -// Test inherent impls. -pub struct InherentBar; - -impl InherentBar { - pub const BAR: usize = 3; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/auxiliary/empty-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/auxiliary/empty-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/auxiliary/empty-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-consts/auxiliary/empty-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct XEmpty1 {} -pub struct XEmpty2; -pub struct XEmpty7(); - -pub enum XE { - XEmpty3 {}, - XEmpty4, - XEmpty6(), -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-basic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-basic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-basic.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-basic.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Foo { - type T; -} - -impl Foo for i32 { - type T = isize; -} - -fn main() { - let x: ::T = 22; - let y: isize = 44; - assert_eq!(x * 2, y); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-binding-in-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-binding-in-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-binding-in-trait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-binding-in-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test a case where the associated type binding (to `bool`, in this -// case) is derived from the trait definition. Issue #21636. - - -use std::vec; - -pub trait BitIter { - type Iter: Iterator; - fn bit_iter(self) -> ::Iter; -} - -impl BitIter for Vec { - type Iter = vec::IntoIter; - fn bit_iter(self) -> ::Iter { - self.into_iter() - } -} - -fn count(arg: T) -> usize - where T: BitIter -{ - let mut sum = 0; - for i in arg.bit_iter() { - if i { - sum += 1; - } - } - sum -} - -fn main() { - let v = vec![true, false, true]; - let c = count(v); - assert_eq!(c, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-binding-in-where-clause.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-binding-in-where-clause.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-binding-in-where-clause.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-binding-in-where-clause.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test equality constraints on associated types in a where clause. - -// pretty-expanded FIXME #23616 - -pub trait Foo { - type A; - fn boo(&self) -> ::A; -} - -#[derive(PartialEq)] -pub struct Bar; - -impl Foo for isize { - type A = usize; - fn boo(&self) -> usize { 42 } -} - -impl Foo for char { - type A = Bar; - fn boo(&self) -> Bar { Bar } -} - -fn foo_bar>(x: I) -> Bar { - x.boo() -} - -fn foo_uint>(x: I) -> usize { - x.boo() -} - -pub fn main() { - let a = 42; - foo_uint(a); - - let a = 'a'; - foo_bar(a); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-bound.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-bound.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test equality constrai32s on associated types in a where clause. - - -pub trait ToI32 { - fn to_i32(&self) -> i32; -} - -impl ToI32 for i32 { - fn to_i32(&self) -> i32 { *self } -} - -impl ToI32 for u32 { - fn to_i32(&self) -> i32 { *self as i32 } -} - -pub trait GetToI32 -{ - type R : ToI32; - - fn get(&self) -> ::R; -} - -impl GetToI32 for i32 { - type R = i32; - fn get(&self) -> i32 { *self } -} - -impl GetToI32 for u32 { - type R = u32; - fn get(&self) -> u32 { *self } -} - -fn foo(g: G) -> i32 - where G : GetToI32 -{ - ToI32::to_i32(&g.get()) -} - -pub fn main() { - assert_eq!(foo(22i32), 22); - assert_eq!(foo(22u32), 22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-cc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-cc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-cc.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-cc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:associated-types-cc-lib.rs - -// Test that we are able to reference cross-crate traits that employ -// associated types. - -extern crate associated_types_cc_lib as bar; - -use bar::Bar; - -fn foo(b: B) -> ::T { - Bar::get(None::) -} - -fn main() { - println!("{}", foo(3)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-conditional-dispatch.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-conditional-dispatch.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-conditional-dispatch.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-conditional-dispatch.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we evaluate projection predicates to winnow out -// candidates during trait selection and method resolution (#20296). -// If we don't properly winnow out candidates based on the output type -// `Target=[A]`, then the impl marked with `(*)` is seen to conflict -// with all the others. - -// pretty-expanded FIXME #23616 - -use std::marker::PhantomData; -use std::ops::Deref; - -pub trait MyEq { - fn eq(&self, u: &U) -> bool; -} - -impl MyEq<[B]> for [A] - where A : MyEq -{ - fn eq(&self, other: &[B]) -> bool { - self.len() == other.len() && - self.iter().zip(other).all(|(a, b)| MyEq::eq(a, b)) - } -} - -// (*) This impl conflicts with everything unless the `Target=[A]` -// constraint is considered. -impl<'a, A, B, Lhs> MyEq<[B; 0]> for Lhs - where A: MyEq, Lhs: Deref -{ - fn eq(&self, other: &[B; 0]) -> bool { - MyEq::eq(&**self, other) - } -} - -struct DerefWithHelper { - pub helper: H, - pub marker: PhantomData, -} - -trait Helper { - fn helper_borrow(&self) -> &T; -} - -impl Helper for Option { - fn helper_borrow(&self) -> &T { - self.as_ref().unwrap() - } -} - -impl> Deref for DerefWithHelper { - type Target = T; - - fn deref(&self) -> &T { - self.helper.helper_borrow() - } -} - -pub fn check(x: T, y: T) -> bool { - let d: DerefWithHelper, T> = DerefWithHelper { helper: Some(x), - marker: PhantomData }; - d.eq(&y) -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-constant-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-constant-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-constant-type.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-constant-type.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait SignedUnsigned { - type Opposite; - fn convert(self) -> Self::Opposite; -} - -impl SignedUnsigned for isize { - type Opposite = usize; - - fn convert(self) -> usize { - self as usize - } -} - -impl SignedUnsigned for usize { - type Opposite = isize; - - fn convert(self) -> isize { - self as isize - } -} - -fn get(x: isize) -> ::Opposite { - x.convert() -} - -fn main() { - let x = get(22); - assert_eq!(22, x); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-doubleendediterator-object.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-doubleendediterator-object.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-doubleendediterator-object.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-doubleendediterator-object.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -fn pairwise_sub(mut t: Box>) -> isize { - let mut result = 0; - loop { - let front = t.next(); - let back = t.next_back(); - match (front, back) { - (Some(f), Some(b)) => { result += b - f; } - _ => { return result; } - } - } -} - -fn main() { - let v = vec![1, 2, 3, 4, 5, 6]; - let r = pairwise_sub(Box::new(v.into_iter())); - assert_eq!(r, 9); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-duplicate-binding-in-env-hrtb.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-duplicate-binding-in-env-hrtb.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-duplicate-binding-in-env-hrtb.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-duplicate-binding-in-env-hrtb.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check that we do not report ambiguities when equivalent predicates -// (modulo bound lifetime names) appears in the environment -// twice. Issue #21965. - -// pretty-expanded FIXME #23616 - -fn foo(t: T) -> i32 - where T : for<'a> Fn(&'a u8) -> i32, - T : for<'b> Fn(&'b u8) -> i32, -{ - t(&3) -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-duplicate-binding-in-env.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-duplicate-binding-in-env.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-duplicate-binding-in-env.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-duplicate-binding-in-env.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check that we do not report ambiguities when the same predicate -// appears in the environment twice. Issue #21965. - -// pretty-expanded FIXME #23616 - -trait Foo { - type B; - - fn get() -> Self::B; -} - -fn foo() -> () - where T : Foo, T : Foo -{ - ::get() -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-enum-field-named.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-enum-field-named.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-enum-field-named.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-enum-field-named.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test associated types appearing in struct-like enum variants. - - -use self::VarValue::*; - -pub trait UnifyKey { - type Value; - fn to_index(&self) -> usize; -} - -pub enum VarValue { - Redirect { to: K }, - Root { value: K::Value, rank: usize }, -} - -fn get<'a,K:UnifyKey>,V>(table: &'a Vec>, key: &K) -> &'a Option { - match table[key.to_index()] { - VarValue::Redirect { to: ref k } => get(table, k), - VarValue::Root { value: ref v, rank: _ } => v, - } -} - -impl UnifyKey for usize { - type Value = Option; - fn to_index(&self) -> usize { *self } -} - -fn main() { - let table = vec![/* 0 */ Redirect { to: 1 }, - /* 1 */ Redirect { to: 3 }, - /* 2 */ Root { value: Some('x'), rank: 0 }, - /* 3 */ Redirect { to: 2 }]; - assert_eq!(get(&table, &0), &Some('x')); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-enum-field-numbered.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-enum-field-numbered.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-enum-field-numbered.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-enum-field-numbered.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test associated types appearing in tuple-like enum variants. - - -use self::VarValue::*; - -pub trait UnifyKey { - type Value; - fn to_index(&self) -> usize; -} - -pub enum VarValue { - Redirect(K), - Root(K::Value, usize), -} - -fn get<'a,K:UnifyKey>,V>(table: &'a Vec>, key: &K) -> &'a Option { - match table[key.to_index()] { - VarValue::Redirect(ref k) => get(table, k), - VarValue::Root(ref v, _) => v, - } -} - -impl UnifyKey for usize { - type Value = Option; - fn to_index(&self) -> usize { *self } -} - -fn main() { - let table = vec![/* 0 */ Redirect(1), - /* 1 */ Redirect(3), - /* 2 */ Root(Some('x'), 0), - /* 3 */ Redirect(2)]; - assert_eq!(get(&table, &0), &Some('x')); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-eq-obj.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-eq-obj.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-eq-obj.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-eq-obj.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test equality constraints on associated types inside of an object type - -// pretty-expanded FIXME #23616 - -pub trait Foo { - type A; - fn boo(&self) -> ::A; -} - -pub struct Bar; - -impl Foo for char { - type A = Bar; - fn boo(&self) -> Bar { Bar } -} - -fn baz(x: &Foo) -> Bar { - x.boo() -} - -pub fn main() { - let a = 'a'; - baz(&a); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-impl-redirect.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-impl-redirect.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-impl-redirect.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-impl-redirect.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test how resolving a projection interacts with inference. In this -// case, we were eagerly unifying the type variable for the iterator -// type with `I` from the where clause, ignoring the in-scope `impl` -// for `ByRef`. The right answer was to consider the result ambiguous -// until more type information was available. - -#![feature(lang_items)] -#![no_implicit_prelude] - -use std::marker::Sized; -use std::option::Option::{None, Some, self}; - -trait Iterator { - type Item; - - fn next(&mut self) -> Option; -} - -trait IteratorExt: Iterator + Sized { - fn by_ref(&mut self) -> ByRef { - ByRef(self) - } -} - -impl IteratorExt for I where I: Iterator {} - -struct ByRef<'a, I: 'a + Iterator>(&'a mut I); - -impl<'a, I: Iterator> Iterator for ByRef<'a, I> { - type Item = I::Item; - - fn next(&mut self) -> Option< ::Item > { - self.0.next() - } -} - -fn is_iterator_of>(_: &I) {} - -fn test>(mut it: I) { - is_iterator_of::(&it.by_ref()); -} - -fn test2, I2: Iterator>(mut it: I2) { - is_iterator_of::(&it) -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-in-bound-type-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-in-bound-type-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-in-bound-type-arg.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-in-bound-type-arg.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test the case where we resolve `C::Result` and the trait bound -// itself includes a `Self::Item` shorthand. -// -// Regression test for issue #33425. - -trait ParallelIterator { - type Item; - fn drive_unindexed(self, consumer: C) -> C::Result - where C: Consumer; -} - -pub trait Consumer { - type Result; -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-in-default-method.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-in-default-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-in-default-method.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-in-default-method.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait Get { - type Value; - fn get(&self) -> &::Value; - fn grab(&self) -> &::Value { - self.get() - } -} - -struct Struct { - x: isize, -} - -impl Get for Struct { - type Value = isize; - fn get(&self) -> &isize { - &self.x - } -} - -fn main() { - let s = Struct { - x: 100, - }; - assert_eq!(*s.grab(), 100); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-in-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-in-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-in-fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-in-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait Get { - type Value; - fn get(&self) -> &::Value; -} - -struct Struct { - x: isize, -} - -impl Get for Struct { - type Value = isize; - fn get(&self) -> &isize { - &self.x - } -} - -fn grab(x: &T) -> &::Value { - x.get() -} - -fn main() { - let s = Struct { - x: 100, - }; - assert_eq!(*grab(&s), 100); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-in-impl-generics.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-in-impl-generics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-in-impl-generics.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-in-impl-generics.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait Get { - type Value; - fn get(&self) -> &::Value; -} - -struct Struct { - x: isize, -} - -impl Get for Struct { - type Value = isize; - fn get(&self) -> &isize { - &self.x - } -} - -trait Grab { - type U; - fn grab(&self) -> &::U; -} - -impl Grab for T { - type U = ::Value; - fn grab(&self) -> &::Value { - self.get() - } -} - -fn main() { - let s = Struct { - x: 100, - }; - assert_eq!(*s.grab(), 100); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-in-inherent-method.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-in-inherent-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-in-inherent-method.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-in-inherent-method.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait Get { - type Value; - fn get(&self) -> &::Value; -} - -struct Struct { - x: isize, -} - -impl Get for Struct { - type Value = isize; - fn get(&self) -> &isize { - &self.x - } -} - -impl Struct { - fn grab(x: &T) -> &::Value { - x.get() - } -} - -fn main() { - let s = Struct { - x: 100, - }; - assert_eq!(*Struct::grab(&s), 100); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-issue-20220.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-issue-20220.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-issue-20220.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-issue-20220.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test references to `Self::Item` in the trait. Issue #20220. - - -use std::vec; - -trait IntoIteratorX { - type Item; - type IntoIter: Iterator; - - fn into_iter_x(self) -> Self::IntoIter; -} - -impl IntoIteratorX for Vec { - type Item = T; - type IntoIter = vec::IntoIter; - - fn into_iter_x(self) -> vec::IntoIter { - self.into_iter() - } -} - -fn main() { - let vec = vec![1, 2, 3]; - for (i, e) in vec.into_iter().enumerate() { - assert_eq!(i+1, e); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-issue-20371.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-issue-20371.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-issue-20371.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-issue-20371.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we are able to have an impl that defines an associated type -// before the actual trait. - -// pretty-expanded FIXME #23616 - -impl X for f64 { type Y = isize; } -trait X { type Y; } -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-issue-21212.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-issue-21212.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-issue-21212.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-issue-21212.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #21212: an overflow occurred during trait -// checking where normalizing `Self::Input` led to normalizing the -// where clauses in the environment which in turn required normalizing -// `Self::Input`. - - -pub trait Parser { - type Input; - - fn parse(input: ::Input) { - panic!() - } -} - -impl

Parser for P { - type Input = (); -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-iterator-binding.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-iterator-binding.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-iterator-binding.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-iterator-binding.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn pairwise_sub>(mut t: T) -> isize { - let mut result = 0; - loop { - let front = t.next(); - let back = t.next_back(); - match (front, back) { - (Some(f), Some(b)) => { result += b - f; } - _ => { return result; } - } - } -} - -fn main() { - let v = vec![1, 2, 3, 4, 5, 6]; - let r = pairwise_sub(v.into_iter()); - assert_eq!(r, 9); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-method.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-method.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-method.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that methods whose impl-trait-ref contains associated types -// are supported. - -trait Device { - type Resources; -} -struct Foo(D, R); - -trait Tr { - fn present(&self) {} -} - -impl Tr for Foo { - fn present(&self) {} -} - -struct Res; -struct Dev; -impl Device for Dev { - type Resources = Res; -} - -fn main() { - let foo = Foo(Dev, Res); - foo.present(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-nested-projections.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-nested-projections.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-nested-projections.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-nested-projections.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we can resolve nested projection types. Issue #20666. - -// pretty-expanded FIXME #23616 - -use std::slice; - -trait Bound {} - -impl<'a> Bound for &'a i32 {} - -trait IntoIterator { - type Iter: Iterator; - - fn into_iter(self) -> Self::Iter; -} - -impl<'a, T> IntoIterator for &'a [T; 3] { - type Iter = slice::Iter<'a, T>; - - fn into_iter(self) -> slice::Iter<'a, T> { - self.iter() - } -} - -fn foo(x: X) where - X: IntoIterator, - <::Iter as Iterator>::Item: Bound, -{ -} - -fn bar(x: X) where - T: Bound, - I: Iterator, - X: IntoIterator, -{ - -} - -fn main() { - foo(&[0, 1, 2]); - bar(&[0, 1, 2]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-normalize-in-bounds-binding.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-normalize-in-bounds-binding.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-normalize-in-bounds-binding.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-normalize-in-bounds-binding.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we normalize associated types that appear in a bound that -// contains a binding. Issue #21664. - -// pretty-expanded FIXME #23616 - -#![allow(dead_code)] - -pub trait Integral { - type Opposite; -} - -impl Integral for i32 { - type Opposite = u32; -} - -impl Integral for u32 { - type Opposite = i32; -} - -pub trait FnLike { - type R; - - fn dummy(&self, a: A) -> Self::R { loop { } } -} - -fn foo() - where T : FnLike<::Opposite, R=bool> -{ - bar::(); -} - -fn bar() - where T : FnLike -{} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-normalize-in-bounds.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-normalize-in-bounds.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-normalize-in-bounds.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-normalize-in-bounds.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we normalize associated types that appear in bounds; if -// we didn't, the call to `self.split2()` fails to type check. - -// pretty-expanded FIXME #23616 - -use std::marker::PhantomData; - -struct Splits<'a, T, P>(PhantomData<(&'a(),T,P)>); -struct SplitsN(PhantomData); - -trait SliceExt2 { - type Item; - - fn split2<'a, P>(&'a self, pred: P) -> Splits<'a, Self::Item, P> - where P: FnMut(&Self::Item) -> bool; - fn splitn2<'a, P>(&'a self, n: usize, pred: P) -> SplitsN> - where P: FnMut(&Self::Item) -> bool; -} - -impl SliceExt2 for [T] { - type Item = T; - - fn split2

(&self, pred: P) -> Splits where P: FnMut(&T) -> bool { - loop {} - } - - fn splitn2

(&self, n: usize, pred: P) -> SplitsN> where P: FnMut(&T) -> bool { - self.split2(pred); - loop {} - } -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-normalize-in-bounds-ufcs.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-normalize-in-bounds-ufcs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-normalize-in-bounds-ufcs.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-normalize-in-bounds-ufcs.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we normalize associated types that appear in bounds; if -// we didn't, the call to `self.split2()` fails to type check. - -// pretty-expanded FIXME #23616 - -use std::marker::PhantomData; - -struct Splits<'a, T:'a, P>(PhantomData<(&'a T, P)>); -struct SplitsN(PhantomData); - -trait SliceExt2 { - type Item; - - fn split2<'a, P>(&'a self, pred: P) -> Splits<'a, Self::Item, P> - where P: FnMut(&Self::Item) -> bool; - fn splitn2<'a, P>(&'a self, n: u32, pred: P) -> SplitsN> - where P: FnMut(&Self::Item) -> bool; -} - -impl SliceExt2 for [T] { - type Item = T; - - fn split2

(&self, pred: P) -> Splits where P: FnMut(&T) -> bool { - loop {} - } - - fn splitn2

(&self, n: u32, pred: P) -> SplitsN> where P: FnMut(&T) -> bool { - SliceExt2::split2(self, pred); - loop {} - } -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-normalize-unifield-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-normalize-unifield-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-normalize-unifield-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-normalize-unifield-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for issue #21010: Normalize associated types in -// various special paths in the `type_is_immediate` function. - -pub trait OffsetState: Sized {} -pub trait Offset { - type State: OffsetState; - fn dummy(&self) { } -} - -#[derive(Copy, Clone)] pub struct X; -impl Offset for X { type State = Y; } - -#[derive(Copy, Clone)] pub struct Y; -impl OffsetState for Y {} - -pub fn now() -> DateTime { from_utc(Y) } - -pub struct DateTime { pub offset: Off::State } -pub fn from_utc(offset: Off::State) -> DateTime { DateTime { offset: offset } } - -pub fn main() { - let _x = now(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-project-from-type-param-via-bound-in-where.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-project-from-type-param-via-bound-in-where.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-project-from-type-param-via-bound-in-where.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-project-from-type-param-via-bound-in-where.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Various uses of `T::Item` syntax where the bound that supplies -// `Item` originates in a where-clause, not the declaration of -// `T`. Issue #20300. - -use std::marker::{PhantomData}; -use std::sync::atomic::{AtomicUsize}; -use std::sync::atomic::Ordering::SeqCst; - -static COUNTER: AtomicUsize = AtomicUsize::new(0); - -// Preamble. -trait Trait { type Item; } -struct Struct; -impl Trait for Struct { - type Item = u32; -} - -// Where-clause attached on the method which declares `T`. -struct A; -impl A { - fn foo(_x: T::Item) where T: Trait { - COUNTER.fetch_add(1, SeqCst); - } -} - -// Where-clause attached on the method to a parameter from the struct. -struct B(PhantomData); -impl B { - fn foo(_x: T::Item) where T: Trait { - COUNTER.fetch_add(10, SeqCst); - } -} - -// Where-clause attached to free fn. -fn c(_: T::Item) where T : Trait { - COUNTER.fetch_add(100, SeqCst); -} - -// Where-clause attached to defaulted and non-defaulted trait method. -trait AnotherTrait { - fn method(&self, _: T::Item) where T: Trait; - fn default_method(&self, _: T::Item) where T: Trait { - COUNTER.fetch_add(1000, SeqCst); - } -} -struct D; -impl AnotherTrait for D { - fn method(&self, _: T::Item) where T: Trait { - COUNTER.fetch_add(10000, SeqCst); - } -} - -// Where-clause attached to trait and impl containing the method. -trait YetAnotherTrait - where T : Trait -{ - fn method(&self, _: T::Item); - fn default_method(&self, _: T::Item) { - COUNTER.fetch_add(100000, SeqCst); - } -} -struct E(PhantomData); -impl YetAnotherTrait for E - where T : Trait -{ - fn method(&self, _: T::Item) { - COUNTER.fetch_add(1000000, SeqCst); - } -} - -// Where-clause attached to inherent impl containing the method. -struct F(PhantomData); -impl F where T : Trait { - fn method(&self, _: T::Item) { - COUNTER.fetch_add(10000000, SeqCst); - } -} - -// Where-clause attached to struct. -#[allow(dead_code)] -struct G where T : Trait { - data: T::Item, - phantom: PhantomData, -} - -fn main() { - A::foo::(22); - B::::foo(22); - c::(22); - D.method::(22); - D.default_method::(22); - E(PhantomData::).method(22); - E(PhantomData::).default_method(22); - F(PhantomData::).method(22); - G:: { data: 22, phantom: PhantomData }; - assert_eq!(COUNTER.load(SeqCst), 11111111); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-bound-in-supertraits.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-bound-in-supertraits.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-bound-in-supertraits.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-bound-in-supertraits.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we correctly handle projection bounds appearing in the -// supertrait list (and in conjunction with overloaded operators). In -// this case, the `Result=Self` binding in the supertrait listing of -// `Int` was being ignored. - -trait Not { - type Result; - - fn not(self) -> Self::Result; -} - -trait Int: Not + Sized { - fn count_ones(self) -> usize; - fn count_zeros(self) -> usize { - // neither works - let x: Self = self.not(); - 0 - } -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-from-known-type-in-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-from-known-type-in-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-from-known-type-in-impl.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-from-known-type-in-impl.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test where the impl self type uses a projection from a constant type. - - -trait Int -{ - type T; - - fn dummy(&self) { } -} - -trait NonZero -{ - fn non_zero(self) -> bool; -} - -impl Int for i32 { type T = i32; } -impl Int for i64 { type T = i64; } -impl Int for u32 { type T = u32; } -impl Int for u64 { type T = u64; } - -impl NonZero for ::T { fn non_zero(self) -> bool { self != 0 } } -impl NonZero for ::T { fn non_zero(self) -> bool { self != 0 } } -impl NonZero for ::T { fn non_zero(self) -> bool { self != 0 } } -impl NonZero for ::T { fn non_zero(self) -> bool { self != 0 } } - -fn main () -{ - assert!(NonZero::non_zero(22_i32)); - assert!(NonZero::non_zero(22_i64)); - assert!(NonZero::non_zero(22_u32)); - assert!(NonZero::non_zero(22_u64)); - - assert!(!NonZero::non_zero(0_i32)); - assert!(!NonZero::non_zero(0_i64)); - assert!(!NonZero::non_zero(0_u32)); - assert!(!NonZero::non_zero(0_u64)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-in-object-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-in-object-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-in-object-type.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-in-object-type.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Corrected regression test for #20831. The original did not compile. -// When fixed, it revealed another problem concerning projections that -// appear in associated type bindings in object types, which were not -// being properly flagged. - -// pretty-expanded FIXME #23616 - -use std::ops::{Shl, Shr}; -use std::cell::RefCell; - -pub trait Subscriber { - type Input; - - fn dummy(&self) { } -} - -pub trait Publisher<'a> { - type Output; - fn subscribe(&mut self, _: Box + 'a>); -} - -pub trait Processor<'a> : Subscriber + Publisher<'a> { } - -impl<'a, P> Processor<'a> for P where P : Subscriber + Publisher<'a> { } - -struct MyStruct<'a> { - sub: Box + 'a> -} - -impl<'a> Publisher<'a> for MyStruct<'a> { - type Output = u64; - fn subscribe(&mut self, t : Box + 'a>) { - self.sub = t; - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-in-supertrait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-in-supertrait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-in-supertrait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-in-supertrait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we are handle to correctly handle a projection type -// that appears in a supertrait bound. Issue #20559. - - -trait A -{ - type TA; - - fn dummy(&self) { } -} - -trait B -{ - fn foo (&self, t : TB) -> String; -} - -trait C : B<::TA> { } - -struct X; - -impl A for X -{ - type TA = i32; -} - -struct Y; - -impl C for Y { } - -// Both of these impls are required for successful compilation -impl B for Y -{ - fn foo (&self, t : i32) -> String - { - format!("First {}", t) - } -} - -fn main () -{ - let y = Y; - assert_eq!(y.foo(5), format!("First 5")); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-in-where-clause.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-in-where-clause.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-in-where-clause.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-in-where-clause.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test a where clause that uses a non-normalized projection type. - -// pretty-expanded FIXME #23616 - -trait Int -{ - type T; - - fn dummy(&self) { } -} - -trait NonZero -{ - fn non_zero(self) -> bool; -} - -fn foo,J>(t: I) -> bool - where ::T : NonZero - // ^~~~~~~~~~~~~ canonical form is just J -{ - bar::() -} - -fn bar() -> bool { true } - -fn main () -{ -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-to-unrelated-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-to-unrelated-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-to-unrelated-trait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-projection-to-unrelated-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check that we do not get an error when you use `::Value` in -// the trait definition if there is no default method and for every impl, -// `Self` does implement `Get`. -// -// See also compile-fail tests associated-types-no-suitable-supertrait -// and associated-types-no-suitable-supertrait-2, which show how small -// variants of the code below can fail. - -trait Get { - type Value; -} - -trait Other { - fn okay(&self, foo: U, bar: ::Value) - where Self: Get; -} - -impl Get for () { - type Value = f32; -} - -impl Get for f64 { - type Value = u32; -} - -impl Other for () { - fn okay(&self, _foo: U, _bar: ::Value) { } -} - -impl Other for f64 { - fn okay(&self, _foo: U, _bar: ::Value) { } -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-qualified-path-with-trait-with-type-parameters.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-qualified-path-with-trait-with-type-parameters.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-qualified-path-with-trait-with-type-parameters.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-qualified-path-with-trait-with-type-parameters.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait Foo { - type Bar; - fn get_bar() -> >::Bar; -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-ref-from-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-ref-from-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-ref-from-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-ref-from-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test associated type references in structure fields. - -// pretty-expanded FIXME #23616 - -trait Test { - type V; - - fn test(&self, value: &Self::V) -> bool; -} - -/////////////////////////////////////////////////////////////////////////// - -struct TesterPair { - tester: T, - value: T::V, -} - -impl TesterPair { - fn new(tester: T, value: T::V) -> TesterPair { - TesterPair { tester: tester, value: value } - } - - fn test(&self) -> bool { - self.tester.test(&self.value) - } -} - -/////////////////////////////////////////////////////////////////////////// - -struct EqU32(u32); -impl Test for EqU32 { - type V = u32; - - fn test(&self, value: &u32) -> bool { - self.0 == *value - } -} - -struct EqI32(i32); -impl Test for EqI32 { - type V = i32; - - fn test(&self, value: &i32) -> bool { - self.0 == *value - } -} - -fn main() { - let tester = TesterPair::new(EqU32(22), 23); - tester.test(); - - let tester = TesterPair::new(EqI32(22), 23); - tester.test(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-ref-in-struct-literal.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-ref-in-struct-literal.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-ref-in-struct-literal.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-ref-in-struct-literal.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test associated type references in a struct literal. Issue #20535. - - -pub trait Foo { - type Bar; - - fn dummy(&self) { } -} - -impl Foo for isize { - type Bar = isize; -} - -struct Thing { - a: F, - b: F::Bar, -} - -fn main() { - let thing = Thing{a: 1, b: 2}; - assert_eq!(thing.a + 1, thing.b); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-region-erasure-issue-20582.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-region-erasure-issue-20582.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-region-erasure-issue-20582.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-region-erasure-issue-20582.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #20582. This test caused an ICE related to -// inconsistent region erasure in codegen. - -// pretty-expanded FIXME #23616 - -struct Foo<'a> { - buf: &'a[u8] -} - -impl<'a> Iterator for Foo<'a> { - type Item = &'a[u8]; - - fn next(&mut self) -> Option<::Item> { - Some(self.buf) - } -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-resolve-lifetime.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-resolve-lifetime.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-resolve-lifetime.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-resolve-lifetime.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait Get { - fn get(&self) -> T; -} - -trait Trait<'a> { - type T: 'static; - type U: Get<&'a isize>; - - fn dummy(&'a self) { } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-return.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-return.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-return.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-return.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test equality constraints on associated types in a where clause. - - -pub trait Foo { - type A; - fn boo(&self) -> ::A; -} - -#[derive(PartialEq, Debug)] -pub struct Bar; - -impl Foo for isize { - type A = usize; - fn boo(&self) -> usize { 42 } -} - -impl Foo for Bar { - type A = isize; - fn boo(&self) -> isize { 43 } -} - -impl Foo for char { - type A = Bar; - fn boo(&self) -> Bar { Bar } -} - -fn foo1>(x: I) -> Bar { - x.boo() -} - -fn foo2(x: I) -> ::A { - x.boo() -} - -pub fn main() { - let a = 42; - assert_eq!(foo2(a), 42); - - let a = Bar; - assert_eq!(foo2(a), 43); - - let a = 'a'; - foo1(a); - assert_eq!(foo2(a), Bar); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-simple.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-simple.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-simple.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait Get { - type Value; - fn get(&self) -> &::Value; -} - -struct Struct { - x: isize, -} - -impl Get for Struct { - type Value = isize; - fn get(&self) -> &isize { - &self.x - } -} - -fn main() { - let s = Struct { - x: 100, - }; - assert_eq!(*s.get(), 100); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-stream.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-stream.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-stream.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-stream.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test references to the trait `Stream` in the bounds for associated -// types defined on `Stream`. Issue #20551. - - -trait Stream { - type Car; - type Cdr: Stream; - - fn car(&self) -> Self::Car; - fn cdr(self) -> Self::Cdr; -} - -impl Stream for () { - type Car = (); - type Cdr = (); - fn car(&self) -> () { () } - fn cdr(self) -> () { self } -} - -impl Stream for (T, U) - where T : Clone, U : Stream -{ - type Car = T; - type Cdr = U; - fn car(&self) -> T { self.0.clone() } - fn cdr(self) -> U { self.1 } -} - -fn main() { - let p = (22, (44, (66, ()))); - assert_eq!(p.car(), 22); - - let p = p.cdr(); - assert_eq!(p.car(), 44); - - let p = p.cdr(); - assert_eq!(p.car(), 66); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-struct-field-named.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-struct-field-named.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-struct-field-named.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-struct-field-named.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we correctly normalize the type of a struct field -// which has an associated type. - - -pub trait UnifyKey { - type Value; - - fn dummy(&self) { } -} - -pub struct Node { - pub key: K, - pub value: K::Value, -} - -fn foo>,V : Clone>(node: &Node) -> Option { - node.value.clone() -} - -impl UnifyKey for i32 { - type Value = Option; -} - -impl UnifyKey for u32 { - type Value = Option; -} - -pub fn main() { - let node: Node = Node { key: 1, value: Some(22) }; - assert_eq!(foo(&node), Some(22)); - - let node: Node = Node { key: 1, value: Some(22) }; - assert_eq!(foo(&node), Some(22)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-struct-field-numbered.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-struct-field-numbered.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-struct-field-numbered.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-struct-field-numbered.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we correctly normalize the type of a struct field -// which has an associated type. - - -pub trait UnifyKey { - type Value; - - fn dummy(&self) { } -} - -pub struct Node(K, K::Value); - -fn foo>,V : Clone>(node: &Node) -> Option { - node.1.clone() -} - -impl UnifyKey for i32 { - type Value = Option; -} - -impl UnifyKey for u32 { - type Value = Option; -} - -pub fn main() { - let node: Node = Node(1, Some(22)); - assert_eq!(foo(&node), Some(22)); - - let node: Node = Node(1, Some(22)); - assert_eq!(foo(&node), Some(22)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-sugar-path.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-sugar-path.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-sugar-path.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-sugar-path.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test paths to associated types using the type-parameter-only sugar. - -use std::ops::Deref; - -pub trait Foo { - type A; - fn boo(&self) -> Self::A; -} - -impl Foo for isize { - type A = usize; - fn boo(&self) -> usize { - 5 - } -} - -// Using a type via a function. -pub fn bar(a: T, x: T::A) -> T::A { - let _: T::A = a.boo(); - x -} - -// Using a type via an impl. -trait C { - fn f(); - fn g(&self) { } -} -struct B(X); -impl C for B { - fn f() { - let x: T::A = panic!(); - } -} - -pub fn main() { - let z: usize = bar(2, 4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-where-clause-impl-ambiguity.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-where-clause-impl-ambiguity.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-where-clause-impl-ambiguity.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/associated-types-where-clause-impl-ambiguity.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test how resolving a projection interacts with inference. In this -// case, we were eagerly unifying the type variable for the iterator -// type with `I` from the where clause, ignoring the in-scope `impl` -// for `ByRef`. The right answer was to consider the result ambiguous -// until more type information was available. - -#![feature(lang_items)] -#![no_implicit_prelude] - -use std::marker::Sized; -use std::option::Option::{None, Some, self}; - -trait Iterator { - type Item; - - fn next(&mut self) -> Option; -} - -trait IteratorExt: Iterator + Sized { - fn by_ref(&mut self) -> ByRef { - ByRef(self) - } -} - -impl IteratorExt for I where I: Iterator {} - -struct ByRef<'a, I: 'a + Iterator>(&'a mut I); - -impl<'a, A, I> Iterator for ByRef<'a, I> where I: Iterator { - type Item = A; - - fn next(&mut self) -> Option< ::Item > { - self.0.next() - } -} - -fn is_iterator_of>(_: &I) {} - -fn test>(mut it: I) { - is_iterator_of::(&it.by_ref()); -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/auxiliary/associated-types-cc-lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/auxiliary/associated-types-cc-lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/auxiliary/associated-types-cc-lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/associated-types/auxiliary/associated-types-cc-lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Helper for test issue-18048, which tests associated types in a -// cross-crate scenario. - -#![crate_type="lib"] - -pub trait Bar: Sized { - type T; - - fn get(x: Option) -> ::T; -} - -impl Bar for isize { - type T = usize; - - fn get(_: Option) -> usize { 22 } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-and-borrow-method-receiver.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-and-borrow-method-receiver.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-and-borrow-method-receiver.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-and-borrow-method-receiver.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -struct Foo { - x: isize, -} - -impl Foo { - pub fn f(&self) {} -} - -fn g(x: &mut Foo) { - x.f(); -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-method-on-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-method-on-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-method-on-trait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-method-on-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -#![feature(box_syntax)] - -trait double { - fn double(self: Box) -> usize; -} - -impl double for usize { - fn double(self: Box) -> usize { *self * 2 } -} - -pub fn main() { - let x: Box<_> = box (box 3usize as Box); - assert_eq!(x.double(), 6); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-method-priority.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-method-priority.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-method-priority.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-method-priority.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -#![feature(box_syntax)] - -trait double { - fn double(self) -> usize; -} - -impl double for usize { - fn double(self) -> usize { self } -} - -impl double for Box { - fn double(self) -> usize { *self * 2 } -} - -pub fn main() { - let x: Box<_> = box 3; - assert_eq!(x.double(), 6); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-method.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-method.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-method.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -#![feature(box_syntax)] - -trait double { - fn double(self: Box) -> usize; -} - -impl double for usize { - fn double(self: Box) -> usize { *self * 2 } -} - -pub fn main() { - let x: Box<_> = box 3; - assert_eq!(x.double(), 6); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-method-twice-but-not-thrice.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-method-twice-but-not-thrice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-method-twice-but-not-thrice.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-method-twice-but-not-thrice.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -#![feature(box_syntax)] - -trait double { - fn double(self: Box) -> usize; -} - -impl double for Box { - fn double(self: Box>) -> usize { **self * 2 } -} - -pub fn main() { - let x: Box>>>> = box box box box box 3; - assert_eq!(x.double(), 6); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-method-twice.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-method-twice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-method-twice.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-method-twice.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -#![feature(box_syntax)] - -trait double { - fn double(self: Box) -> usize; -} - -impl double for usize { - fn double(self: Box) -> usize { *self * 2 } -} - -pub fn main() { - let x: Box> = box box 3; - assert_eq!(x.double(), 6); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-privacy.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-privacy.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-privacy.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoderef-privacy.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check we do not select a private method or field when computing autoderefs - -#![allow(unused)] - -#[derive(Default)] -pub struct Bar2 { i: i32 } -#[derive(Default)] -pub struct Baz2(i32); - -impl Bar2 { - fn f(&self) -> bool { true } -} - -mod foo { - #[derive(Default)] - pub struct Bar { i: ::Bar2 } - #[derive(Default)] - pub struct Baz(::Baz2); - - impl Bar { - fn f(&self) -> bool { false } - } - - impl ::std::ops::Deref for Bar { - type Target = ::Bar2; - fn deref(&self) -> &::Bar2 { &self.i } - } - - impl ::std::ops::Deref for Baz { - type Target = ::Baz2; - fn deref(&self) -> &::Baz2 { &self.0 } - } - - pub fn f(bar: &Bar, baz: &Baz) { - // Since the private fields and methods are visible here, there should be no autoderefs. - let _: &::Bar2 = &bar.i; - let _: &::Baz2 = &baz.0; - assert!(!bar.f()); - } -} - -fn main() { - let bar = foo::Bar::default(); - let baz = foo::Baz::default(); - foo::f(&bar, &baz); - - let _: i32 = bar.i; - let _: i32 = baz.0; - assert!(bar.f()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/auto-ref-bounded-ty-param.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/auto-ref-bounded-ty-param.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/auto-ref-bounded-ty-param.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/auto-ref-bounded-ty-param.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Foo { - fn f(&self); -} - -struct Bar { - x: isize -} - -trait Baz { - fn g(&self); -} - -impl Foo for T { - fn f(&self) { - self.g(); - } -} - -impl Baz for Bar { - fn g(&self) { - println!("{}", self.x); - } -} - -pub fn main() { - let y = Bar { x: 42 }; - y.f(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoref-intermediate-types-issue-3585.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoref-intermediate-types-issue-3585.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoref-intermediate-types-issue-3585.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/autoref-intermediate-types-issue-3585.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -trait Foo { - fn foo(&self) -> String; -} - -impl Foo for Box { - fn foo(&self) -> String { - format!("box {}", (**self).foo()) - } -} - -impl Foo for usize { - fn foo(&self) -> String { - format!("{}", *self) - } -} - -pub fn main() { - let x: Box<_> = box 3; - assert_eq!(x.foo(), "box 3".to_string()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/auto-ref.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/auto-ref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/auto-ref.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/auto-ref.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct Foo { - x: isize, -} - -trait Stuff { - fn printme(&self); -} - -impl Stuff for Foo { - fn printme(&self) { - println!("{}", self.x); - } -} - -pub fn main() { - let x = Foo { x: 3 }; - x.printme(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/auto-ref-sliceable.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/auto-ref-sliceable.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/auto-ref-sliceable.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/autoref-autoderef/auto-ref-sliceable.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -trait Pushable { - fn push_val(&mut self, t: T); -} - -impl Pushable for Vec { - fn push_val(&mut self, t: T) { - self.push(t); - } -} - -pub fn main() { - let mut v = vec![1]; - v.push_val(2); - v.push_val(3); - assert_eq!(v, [1, 2, 3]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/bench/issue-32062.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/bench/issue-32062.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/bench/issue-32062.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/bench/issue-32062.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// pretty-expanded FIXME #23616 - -fn main() { - let _ = test(Some(0).into_iter()); -} - -trait Parser { - type Input: Iterator; - type Output; - fn parse(self, input: Self::Input) -> Result<(Self::Output, Self::Input), ()>; - fn chain

(self, p: P) -> Chain where Self: Sized { - Chain(self, p) - } -} - -struct Token(T::Item) where T: Iterator; - -impl Parser for Token where T: Iterator { - type Input = T; - type Output = T::Item; - fn parse(self, _input: Self::Input) -> Result<(Self::Output, Self::Input), ()> { - Err(()) - } -} - -struct Chain(L, R); - -impl Parser for Chain where L: Parser, R: Parser { - type Input = L::Input; - type Output = (L::Output, R::Output); - fn parse(self, _input: Self::Input) -> Result<(Self::Output, Self::Input), ()> { - Err(()) - } -} - -fn test(i: I) -> Result<((), I), ()> where I: Iterator { - Chain(Token(0), Token(1)) - .chain(Chain(Token(0), Token(1))) - .chain(Chain(Token(0), Token(1))) - .chain(Chain(Token(0), Token(1))) - .chain(Chain(Token(0), Token(1))) - .chain(Chain(Token(0), Token(1))) - .chain(Chain(Token(0), Token(1))) - .chain(Chain(Token(0), Token(1))) - .chain(Chain(Token(0), Token(1))) - .parse(i) - .map(|(_, i)| ((), i)) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/allow_irrefutable_let_patterns.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/allow_irrefutable_let_patterns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/allow_irrefutable_let_patterns.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/allow_irrefutable_let_patterns.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(irrefutable_let_patterns)] - -// must-compile-successfully-irrefutable_let_patterns_with_gate -#[allow(irrefutable_let_patterns)] -fn main() { - if let _ = 5 {} - - while let _ = 5 { - break; - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/bind-field-short-with-modifiers.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/bind-field-short-with-modifiers.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/bind-field-short-with-modifiers.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/bind-field-short-with-modifiers.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_shorthand_field_patterns)] - -pub fn main() { - struct Foo { x: isize, y: isize } - let mut f = Foo { x: 10, y: 0 }; - match f { - Foo { ref mut x, .. } => *x = 11, - } - match f { - Foo { ref x, ref y } => { - assert_eq!(f.x, 11); - assert_eq!(f.y, 0); - } - } - match f { - Foo { mut x, y: ref mut y } => { - x = 12; - *y = 1; - } - } - assert_eq!(f.x, 11); - assert_eq!(f.y, 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/borrowed-ptr-pattern-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/borrowed-ptr-pattern-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/borrowed-ptr-pattern-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/borrowed-ptr-pattern-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn foo(s: &String) -> bool { - match &**s { - "kitty" => true, - _ => false - } -} - -pub fn main() { - assert!(foo(&"kitty".to_string())); - assert!(!foo(&"gata".to_string())); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/borrowed-ptr-pattern-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/borrowed-ptr-pattern-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/borrowed-ptr-pattern-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/borrowed-ptr-pattern-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn foo<'r>(s: &'r usize) -> bool { - match s { - &3 => true, - _ => false - } -} - -pub fn main() { - assert!(foo(&3)); - assert!(!foo(&4)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/borrowed-ptr-pattern-infallible.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/borrowed-ptr-pattern-infallible.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/borrowed-ptr-pattern-infallible.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/borrowed-ptr-pattern-infallible.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -pub fn main() { - let (&x, &y) = (&3, &'a'); - assert_eq!(x, 3); - assert_eq!(y, 'a'); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/borrowed-ptr-pattern-option.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/borrowed-ptr-pattern-option.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/borrowed-ptr-pattern-option.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/borrowed-ptr-pattern-option.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn select<'r>(x: &'r Option, y: &'r Option) -> &'r Option { - match (x, y) { - (&None, &None) => x, - (&Some(_), _) => x, - (&None, &Some(_)) => y - } -} - -pub fn main() { - let x = None; - let y = Some(3); - assert_eq!(select(&x, &y).unwrap(), 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/borrowed-ptr-pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/borrowed-ptr-pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/borrowed-ptr-pattern.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/borrowed-ptr-pattern.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn foo(x: &T) -> T{ - match x { - &ref a => (*a).clone() - } -} - -pub fn main() { - assert_eq!(foo(&3), 3); - assert_eq!(foo(&'a'), 'a'); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/empty-types-in-patterns.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/empty-types-in-patterns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/empty-types-in-patterns.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/empty-types-in-patterns.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(never_type)] -#![feature(exhaustive_patterns)] -#![feature(slice_patterns)] -#![allow(unreachable_patterns)] -#![allow(unreachable_code)] - -#[allow(dead_code)] -fn foo(z: !) { - let x: Result = Ok(z); - - let Ok(_y) = x; - let Err(_y) = x; - - let x = [z; 1]; - - match x {}; - match x { - [q] => q, - }; -} - -fn bar(nevers: &[!]) { - match nevers { - &[] => (), - }; - - match nevers { - &[] => (), - &[_] => (), - &[_, _, _, ..] => (), - }; -} - -fn main() { - let x: Result = Ok(123); - let Ok(y) = x; - - assert_eq!(123, y); - - match x { - Ok(y) => y, - }; - - match x { - Ok(y) => y, - Err(e) => match e {}, - }; - - let x: Result = Ok(123); - match x { - Ok(y) => y, - }; - - bar(&[]); -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/exhaustive-bool-match-sanity.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/exhaustive-bool-match-sanity.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/exhaustive-bool-match-sanity.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/exhaustive-bool-match-sanity.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #33540 -// We previously used to generate a 3-armed boolean `SwitchInt` in the -// MIR of the function `foo` below. #33583 changed rustc to -// generate an `If` terminator instead. This test is to just ensure -// sanity in that we generate an if-else chain giving the correct -// results. - -fn foo(x: bool, y: bool) -> u32 { - match (x, y) { - (false, _) => 0, - (_, false) => 1, - (true, true) => 2 - } -} - -fn main() { - assert_eq!(foo(false, true), 0); - assert_eq!(foo(false, false), 0); - assert_eq!(foo(true, false), 1); - assert_eq!(foo(true, true), 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-generic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-generic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-generic.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-generic.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -type compare = extern "Rust" fn(T, T) -> bool; - -fn test_generic(expected: T, eq: compare) { - let actual: T = match true { true => { expected.clone() }, _ => panic!("wat") }; - assert!((eq(expected, actual))); -} - -fn test_bool() { - fn compare_bool(b1: bool, b2: bool) -> bool { return b1 == b2; } - test_generic::(true, compare_bool); -} - -#[derive(Clone)] -struct Pair { - a: isize, - b: isize, -} - -fn test_rec() { - fn compare_rec(t1: Pair, t2: Pair) -> bool { - t1.a == t2.a && t1.b == t2.b - } - test_generic::(Pair {a: 1, b: 2}, compare_rec); -} - -pub fn main() { test_bool(); test_rec(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-generic-unique1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-generic-unique1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-generic-unique1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-generic-unique1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -fn test_generic(expected: Box, eq: F) where F: FnOnce(Box, Box) -> bool { - let actual: Box = match true { - true => { expected.clone() }, - _ => panic!("wat") - }; - assert!(eq(expected, actual)); -} - -fn test_box() { - fn compare_box(b1: Box, b2: Box) -> bool { - return *b1 == *b2; - } - test_generic::(box true, compare_box); -} - -pub fn main() { test_box(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-generic-unique2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-generic-unique2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-generic-unique2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-generic-unique2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -fn test_generic(expected: T, eq: F) where F: FnOnce(T, T) -> bool { - let actual: T = match true { - true => expected.clone(), - _ => panic!("wat") - }; - assert!(eq(expected, actual)); -} - -fn test_vec() { - fn compare_box(v1: Box, v2: Box) -> bool { return v1 == v2; } - test_generic::, _>(box 1, compare_box); -} - -pub fn main() { test_vec(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-panic-all.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-panic-all.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-panic-all.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-panic-all.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - -// When all branches of a match expression result in panic, the entire -// match expression results in panic. - -pub fn main() { - let _x = - match true { - true => { 10 } - false => { match true { true => { panic!() } false => { panic!() } } } - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-panic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-panic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-panic.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-panic.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -fn test_simple() { - let r = match true { true => { true } false => { panic!() } }; - assert_eq!(r, true); -} - -fn test_box() { - let r = match true { true => { vec![10] } false => { panic!() } }; - assert_eq!(r[0], 10); -} - -pub fn main() { test_simple(); test_box(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - - -// Tests for using match as an expression - -fn test_basic() { - let mut rs: bool = match true { true => { true } false => { false } }; - assert!((rs)); - rs = match false { true => { false } false => { true } }; - assert!((rs)); -} - -fn test_inferrence() { - let rs = match true { true => { true } false => { false } }; - assert!((rs)); -} - -fn test_alt_as_alt_head() { - // Yeah, this is kind of confusing ... - - let rs = - match match false { true => { true } false => { false } } { - true => { false } - false => { true } - }; - assert!((rs)); -} - -fn test_alt_as_block_result() { - let rs = - match false { - true => { false } - false => { match true { true => { true } false => { false } } } - }; - assert!((rs)); -} - -pub fn main() { - test_basic(); - test_inferrence(); - test_alt_as_alt_head(); - test_alt_as_block_result(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-unique.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-unique.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-unique.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/expr-match-unique.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -// Tests for match as expressions resulting in boxed types -fn test_box() { - let res: Box<_> = match true { true => { box 100 }, _ => panic!() }; - assert_eq!(*res, 100); -} - -pub fn main() { test_box(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/fat-arrow-match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/fat-arrow-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/fat-arrow-match.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/fat-arrow-match.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -enum color { - red, - green, - blue -} - -pub fn main() { - println!("{}", match color::red { - color::red => { 1 } - color::green => { 2 } - color::blue => { 3 } - }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/fn-pattern-expected-type-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/fn-pattern-expected-type-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/fn-pattern-expected-type-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/fn-pattern-expected-type-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn main() { - let v : &[(isize,isize)] = &[ (1, 2), (3, 4), (5, 6) ]; - for &(x, y) in v { - println!("{}", y); - println!("{}", x); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/fn-pattern-expected-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/fn-pattern-expected-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/fn-pattern-expected-type.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/fn-pattern-expected-type.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let f = |(x, y): (isize, isize)| { - assert_eq!(x, 1); - assert_eq!(y, 2); - }; - f((1, 2)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/func-arg-incomplete-pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/func-arg-incomplete-pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/func-arg-incomplete-pattern.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/func-arg-incomplete-pattern.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we do not leak when the arg pattern must drop part of the -// argument (in this case, the `y` field). - -#![feature(box_syntax)] - -struct Foo { - x: Box, - y: Box, -} - -fn foo(Foo {x, ..}: Foo) -> *const usize { - let addr: *const usize = &*x; - addr -} - -pub fn main() { - let obj: Box<_> = box 1; - let objptr: *const usize = &*obj; - let f = Foo {x: obj, y: box 2}; - let xptr = foo(f); - assert_eq!(objptr, xptr); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/func-arg-ref-pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/func-arg-ref-pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/func-arg-ref-pattern.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/func-arg-ref-pattern.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// exec-env:RUST_POISON_ON_FREE=1 - -// Test argument patterns where we create refs to the inside of -// boxes. Make sure that we don't free the box as we match the -// pattern. - -#![feature(box_patterns)] -#![feature(box_syntax)] - -fn getaddr(box ref x: Box) -> *const usize { - let addr: *const usize = &*x; - addr -} - -fn checkval(box ref x: Box) -> usize { - *x -} - -pub fn main() { - let obj: Box<_> = box 1; - let objptr: *const usize = &*obj; - let xptr = getaddr(obj); - assert_eq!(objptr, xptr); - - let obj = box 22; - assert_eq!(checkval(obj), 22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/func-arg-wild-pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/func-arg-wild-pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/func-arg-wild-pattern.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/func-arg-wild-pattern.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we can compile code that uses a `_` in function argument -// patterns. - - -fn foo((x, _): (isize, isize)) -> isize { - x -} - -pub fn main() { - assert_eq!(foo((22, 23)), 22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/if-let.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/if-let.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/if-let.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/if-let.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let x = Some(3); - if let Some(y) = x { - assert_eq!(y, 3); - } else { - panic!("if-let panicked"); - } - let mut worked = false; - if let Some(_) = x { - worked = true; - } - assert!(worked); - let clause: usize; - if let None = Some("test") { - clause = 1; - } else if 4_usize > 5 { - clause = 2; - } else if let Ok(()) = Err::<(),&'static str>("test") { - clause = 3; - } else { - clause = 4; - } - assert_eq!(clause, 4_usize); - - if 3 > 4 { - panic!("bad math"); - } else if let 1 = 2 { - panic!("bad pattern match"); - } - - enum Foo { - One, - Two(usize), - Three(String, isize) - } - - let foo = Foo::Three("three".to_string(), 42); - if let Foo::One = foo { - panic!("bad pattern match"); - } else if let Foo::Two(_x) = foo { - panic!("bad pattern match"); - } else if let Foo::Three(s, _) = foo { - assert_eq!(s, "three"); - } else { - panic!("bad else"); - } - - if false { - panic!("wat"); - } else if let a@Foo::Two(_) = Foo::Two(42_usize) { - if let Foo::Two(b) = a { - assert_eq!(b, 42_usize); - } else { - panic!("panic in nested if-let"); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/inconsistent-lifetime-mismatch.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/inconsistent-lifetime-mismatch.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/inconsistent-lifetime-mismatch.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/inconsistent-lifetime-mismatch.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn foo(_: &[&str]) {} - -fn bad(a: &str, b: &str) { - foo(&[a, b]); -} - -fn good(a: &str, b: &str) { - foo(&[a, b]); -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/inferred-suffix-in-pattern-range.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/inferred-suffix-in-pattern-range.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/inferred-suffix-in-pattern-range.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/inferred-suffix-in-pattern-range.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let x = 2; - let x_message = match x { - 0 ..= 1 => { "not many".to_string() } - _ => { "lots".to_string() } - }; - assert_eq!(x_message, "lots".to_string()); - - let y = 2; - let y_message = match y { - 0 ..= 1 => { "not many".to_string() } - _ => { "lots".to_string() } - }; - assert_eq!(y_message, "lots".to_string()); - - let z = 1u64; - let z_message = match z { - 0 ..= 1 => { "not many".to_string() } - _ => { "lots".to_string() } - }; - assert_eq!(z_message, "not many".to_string()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/irrefutable-slice-patterns.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/irrefutable-slice-patterns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/irrefutable-slice-patterns.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/irrefutable-slice-patterns.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// #47096 - -#![feature(slice_patterns)] - -fn foo(s: &[i32]) -> &[i32] { - let &[ref xs..] = s; - xs -} - -fn main() { - let x = [1, 2, 3]; - let y = foo(&x); - assert_eq!(x, y); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/let-assignability.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/let-assignability.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/let-assignability.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/let-assignability.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -fn f() { - let a: Box<_> = box 1; - let b: &isize = &*a; - println!("{}", b); -} - -pub fn main() { - f(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/let-destruct-ref.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/let-destruct-ref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/let-destruct-ref.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/let-destruct-ref.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let x = 3_usize; - let ref y = x; - assert_eq!(x, *y); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/let-var-hygiene.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/let-var-hygiene.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/let-var-hygiene.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/let-var-hygiene.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// shouldn't affect evaluation of $ex: - -macro_rules! bad_macro { - ($ex:expr) => ({let _x = 9; $ex}) -} - -pub fn main() { - let _x = 8; - assert_eq!(bad_macro!(_x),8) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-arm-statics.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-arm-statics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-arm-statics.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-arm-statics.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,175 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: -g - -#[derive(PartialEq, Eq)] -struct NewBool(bool); - -#[derive(PartialEq, Eq)] -enum Direction { - North, - East, - South, - West -} - -#[derive(PartialEq, Eq)] -struct Foo { - bar: Option, - baz: NewBool -} - -#[derive(PartialEq, Eq)] -enum EnumWithStructVariants { - Variant1(bool), - Variant2 { - dir: Direction - } -} - -const TRUE_TRUE: (bool, bool) = (true, true); -const NONE: Option = None; -const EAST: Direction = Direction::East; -const NEW_FALSE: NewBool = NewBool(false); -const STATIC_FOO: Foo = Foo { bar: Some(Direction::South), baz: NEW_FALSE }; -const VARIANT2_NORTH: EnumWithStructVariants = EnumWithStructVariants::Variant2 { - dir: Direction::North }; - -pub mod glfw { - #[derive(Copy, Clone, PartialEq, Eq)] - pub struct InputState(usize); - - pub const RELEASE : InputState = InputState(0); - pub const PRESS : InputState = InputState(1); - pub const REPEAT : InputState = InputState(2); -} - -fn issue_6533() { - use glfw; - - fn action_to_str(state: glfw::InputState) -> &'static str { - use glfw::{RELEASE, PRESS, REPEAT}; - match state { - RELEASE => { "Released" } - PRESS => { "Pressed" } - REPEAT => { "Repeated" } - _ => { "Unknown" } - } - } - - assert_eq!(action_to_str(glfw::RELEASE), "Released"); - assert_eq!(action_to_str(glfw::PRESS), "Pressed"); - assert_eq!(action_to_str(glfw::REPEAT), "Repeated"); -} - -fn issue_13626() { - const VAL: [u8; 1] = [0]; - match [1] { - VAL => unreachable!(), - _ => () - } -} - -fn issue_14576() { - type Foo = (i32, i32); - const ON: Foo = (1, 1); - const OFF: Foo = (0, 0); - - match (1, 1) { - OFF => unreachable!(), - ON => (), - _ => unreachable!() - } - - #[derive(PartialEq, Eq)] - enum C { D = 3, E = 4 } - const F : C = C::D; - - assert_eq!(match C::D { F => 1, _ => 2, }, 1); - - // test gaps - #[derive(PartialEq, Eq)] - enum G { H = 3, I = 5 } - const K : G = G::I; - - assert_eq!(match G::I { K => 1, _ => 2, }, 1); -} - -fn issue_13731() { - #[derive(PartialEq, Eq)] - enum A { AA(()) } - const B: A = A::AA(()); - - match A::AA(()) { - B => () - } -} - -fn issue_15393() { - #![allow(dead_code)] - #[derive(PartialEq, Eq)] - struct Flags { - bits: usize - } - - const FOO: Flags = Flags { bits: 0x01 }; - const BAR: Flags = Flags { bits: 0x02 }; - match (Flags { bits: 0x02 }) { - FOO => unreachable!(), - BAR => (), - _ => unreachable!() - } -} - -fn main() { - assert_eq!(match (true, false) { - TRUE_TRUE => 1, - (false, false) => 2, - (false, true) => 3, - (true, false) => 4 - }, 4); - - assert_eq!(match Some(Some(Direction::North)) { - Some(NONE) => 1, - Some(Some(Direction::North)) => 2, - Some(Some(EAST)) => 3, - Some(Some(Direction::South)) => 4, - Some(Some(Direction::West)) => 5, - None => 6 - }, 2); - - assert_eq!(match (Foo { bar: Some(Direction::West), baz: NewBool(true) }) { - Foo { bar: None, baz: NewBool(true) } => 1, - Foo { bar: NONE, baz: NEW_FALSE } => 2, - STATIC_FOO => 3, - Foo { bar: _, baz: NEW_FALSE } => 4, - Foo { bar: Some(Direction::West), baz: NewBool(true) } => 5, - Foo { bar: Some(Direction::South), baz: NewBool(true) } => 6, - Foo { bar: Some(EAST), .. } => 7, - Foo { bar: Some(Direction::North), baz: NewBool(true) } => 8 - }, 5); - - assert_eq!(match (EnumWithStructVariants::Variant2 { dir: Direction::North }) { - EnumWithStructVariants::Variant1(true) => 1, - EnumWithStructVariants::Variant1(false) => 2, - EnumWithStructVariants::Variant2 { dir: Direction::West } => 3, - VARIANT2_NORTH => 4, - EnumWithStructVariants::Variant2 { dir: Direction::South } => 5, - EnumWithStructVariants::Variant2 { dir: Direction::East } => 6 - }, 4); - - issue_6533(); - issue_13626(); - issue_13731(); - issue_14576(); - issue_15393(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-beginning-vert.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-beginning-vert.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-beginning-vert.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-beginning-vert.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -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!"), - | _ => {}, - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-borrowed_str.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-borrowed_str.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-borrowed_str.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-borrowed_str.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn f1(ref_string: &str) -> String { - match ref_string { - "a" => "found a".to_string(), - "b" => "found b".to_string(), - _ => "not found".to_string() - } -} - -fn f2(ref_string: &str) -> String { - match ref_string { - "a" => "found a".to_string(), - "b" => "found b".to_string(), - s => format!("not found ({})", s) - } -} - -fn g1(ref_1: &str, ref_2: &str) -> String { - match (ref_1, ref_2) { - ("a", "b") => "found a,b".to_string(), - ("b", "c") => "found b,c".to_string(), - _ => "not found".to_string() - } -} - -fn g2(ref_1: &str, ref_2: &str) -> String { - match (ref_1, ref_2) { - ("a", "b") => "found a,b".to_string(), - ("b", "c") => "found b,c".to_string(), - (s1, s2) => format!("not found ({}, {})", s1, s2) - } -} - -pub fn main() { - assert_eq!(f1("b"), "found b".to_string()); - assert_eq!(f1("c"), "not found".to_string()); - assert_eq!(f1("d"), "not found".to_string()); - assert_eq!(f2("b"), "found b".to_string()); - assert_eq!(f2("c"), "not found (c)".to_string()); - assert_eq!(f2("d"), "not found (d)".to_string()); - assert_eq!(g1("b", "c"), "found b,c".to_string()); - assert_eq!(g1("c", "d"), "not found".to_string()); - assert_eq!(g1("d", "e"), "not found".to_string()); - assert_eq!(g2("b", "c"), "found b,c".to_string()); - assert_eq!(g2("c", "d"), "not found (c, d)".to_string()); - assert_eq!(g2("d", "e"), "not found (d, e)".to_string()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-bot-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-bot-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-bot-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-bot-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// n.b. This was only ever failing with optimization disabled. - -fn a() -> isize { match return 1 { 2 => 3, _ => panic!() } } -pub fn main() { a(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-bot.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-bot.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-bot.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-bot.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let i: isize = - match Some::(3) { None:: => { panic!() } Some::(_) => { 5 } }; - println!("{}", i); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-byte-array-patterns.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-byte-array-patterns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-byte-array-patterns.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-byte-array-patterns.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(slice_patterns)] - -fn main() { - let buf = &[0u8; 4]; - match buf { - &[0, 1, 0, 0] => unimplemented!(), - b"true" => unimplemented!(), - _ => {} - } - - match buf { - b"true" => unimplemented!(), - &[0, 1, 0, 0] => unimplemented!(), - _ => {} - } - - match buf { - b"true" => unimplemented!(), - &[0, x, 0, 0] => assert_eq!(x, 0), - _ => unimplemented!(), - } - - let buf: &[u8] = buf; - - match buf { - &[0, 1, 0, 0] => unimplemented!(), - &[_] => unimplemented!(), - &[_, _, _, _, _, ..] => unimplemented!(), - b"true" => unimplemented!(), - _ => {} - } - - match buf { - b"true" => unimplemented!(), - &[0, 1, 0, 0] => unimplemented!(), - _ => {} - } - - match buf { - b"true" => unimplemented!(), - &[0, x, 0, 0] => assert_eq!(x, 0), - _ => unimplemented!(), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-enum-struct-0.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-enum-struct-0.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-enum-struct-0.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-enum-struct-0.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// regression test for issue #5625 - - -enum E { - Foo{f : isize}, - Bar -} - -pub fn main() { - let e = E::Bar; - match e { - E::Foo{f: _f} => panic!(), - _ => (), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-enum-struct-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-enum-struct-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-enum-struct-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-enum-struct-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum E { - Foo{f : isize}, - Bar -} - -pub fn main() { - let e = E::Foo{f: 1}; - match e { - E::Foo{..} => (), - _ => panic!(), - } - match e { - E::Foo{f: _f} => (), - _ => panic!(), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-implicit-copy-unique.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-implicit-copy-unique.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-implicit-copy-unique.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-implicit-copy-unique.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_shorthand_field_patterns)] -#![feature(box_syntax)] - -struct Pair { a: Box, b: Box } - -pub fn main() { - let mut x: Box<_> = box Pair {a: box 10, b: box 20}; - let x_internal = &mut *x; - match *x_internal { - Pair {a: ref mut a, b: ref mut _b} => { - assert_eq!(**a, 10); - *a = box 30; - assert_eq!(**a, 30); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-in-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-in-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-in-macro.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-in-macro.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum Foo { - B { b1: isize, bb1: isize}, -} - -macro_rules! match_inside_expansion { - () => ( - match (Foo::B { b1:29 , bb1: 100}) { - Foo::B { b1:b2 , bb1:bb2 } => b2+bb2 - } - ) -} - -pub fn main() { - assert_eq!(match_inside_expansion!(),129); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-join.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-join.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-join.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-join.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn foo(y: Option) { - let mut x: isize; - let mut rs: Vec = Vec::new(); - /* tests that x doesn't get put in the precondition for the - entire if expression */ - - if true { - } else { - match y { - None:: => x = 17, - _ => x = 42 - } - rs.push(x); - } - return; -} - -pub fn main() { println!("hello"); foo::(Some::(5)); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-larger-const.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-larger-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-larger-const.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-larger-const.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Eq, PartialEq)] -pub struct Data([u8; 4]); - -const DATA: Data = Data([1, 2, 3, 4]); - -fn main() { - match DATA { - DATA => (), - _ => (), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-naked-record-expr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-naked-record-expr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-naked-record-expr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-naked-record-expr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -struct X { x: isize } - -pub fn main() { - let _x = match 0 { - _ => X { - x: 0 - }.x - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-naked-record.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-naked-record.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-naked-record.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-naked-record.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -struct X { x: isize } - -pub fn main() { - let _x = match 0 { - _ => X { - x: 0 - } - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-path.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-path.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-path.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-path.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - -// pretty-expanded FIXME #23616 - -mod m1 { - pub enum foo { foo1, foo2, } -} - -fn bar(x: m1::foo) { match x { m1::foo::foo1 => { } m1::foo::foo2 => { } } } - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-pattern-bindings.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-pattern-bindings.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-pattern-bindings.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-pattern-bindings.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn main() { - let value = Some(1); - assert_eq!(match value { - ref a @ Some(_) => a, - ref b @ None => b - }, &Some(1)); - assert_eq!(match value { - ref c @ Some(_) => c, - ref b @ None => b - }, &Some(1)); - assert_eq!(match "foobarbaz" { - b @ _ => b - }, "foobarbaz"); - let a @ _ = "foobarbaz"; - assert_eq!(a, "foobarbaz"); - let value = Some(true); - let ref a @ _ = value; - assert_eq!(a, &Some(true)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-pattern-lit.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-pattern-lit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-pattern-lit.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-pattern-lit.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -fn altlit(f: isize) -> isize { - match f { - 10 => { println!("case 10"); return 20; } - 11 => { println!("case 11"); return 22; } - _ => panic!("the impossible happened") - } -} - -pub fn main() { - assert_eq!(altlit(10), 20); - assert_eq!(altlit(11), 22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-pattern-no-type-params.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-pattern-no-type-params.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-pattern-no-type-params.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-pattern-no-type-params.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -enum maybe { nothing, just(T), } - -fn foo(x: maybe) { - match x { - maybe::nothing => { println!("A"); } - maybe::just(_a) => { println!("B"); } - } -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-pattern-simple.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-pattern-simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-pattern-simple.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-pattern-simple.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -// pretty-expanded FIXME #23616 - -fn altsimple(f: isize) { match f { _x => () } } - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-phi.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-phi.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-phi.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-phi.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 -#![allow(non_camel_case_types)] -#![allow(unused_variables)] - -enum thing { a, b, c, } - -fn foo(it: F) where F: FnOnce(isize) { it(10); } - -pub fn main() { - let mut x = true; - match thing::a { - thing::a => { x = true; foo(|_i| { } ) } - thing::b => { x = false; } - thing::c => { x = false; } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-pipe-binding.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-pipe-binding.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-pipe-binding.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-pipe-binding.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: -Z borrowck=compare - -fn test1() { - // from issue 6338 - match ((1, "a".to_string()), (2, "b".to_string())) { - ((1, a), (2, b)) | ((2, b), (1, a)) => { - assert_eq!(a, "a".to_string()); - assert_eq!(b, "b".to_string()); - }, - _ => panic!(), - } -} - -fn test2() { - match (1, 2, 3) { - (1, a, b) | (2, b, a) => { - assert_eq!(a, 2); - assert_eq!(b, 3); - }, - _ => panic!(), - } -} - -fn test3() { - match (1, 2, 3) { - (1, ref a, ref b) | (2, ref b, ref a) => { - assert_eq!(*a, 2); - assert_eq!(*b, 3); - }, - _ => panic!(), - } -} - -fn test4() { - match (1, 2, 3) { - (1, a, b) | (2, b, a) if a == 2 => { - assert_eq!(a, 2); - assert_eq!(b, 3); - }, - _ => panic!(), - } -} - -fn test5() { - match (1, 2, 3) { - (1, ref a, ref b) | (2, ref b, ref a) if *a == 2 => { - assert_eq!(*a, 2); - assert_eq!(*b, 3); - }, - _ => panic!(), - } -} - -pub fn main() { - test1(); - test2(); - test3(); - test4(); - test5(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-range-infer.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-range-infer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-range-infer.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-range-infer.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that type inference for range patterns works correctly (is bi-directional). - -pub fn main() { - match 1 { - 1 ..= 3 => {} - _ => panic!("should match range") - } - match 1 { - 1 ..= 3u16 => {} - _ => panic!("should match range with inferred start type") - } - match 1 { - 1u16 ..= 3 => {} - _ => panic!("should match range with inferred end type") - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-range.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-range.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-range.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-range.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(illegal_floating_point_literal_pattern)] // FIXME #41620 -#![feature(exclusive_range_pattern)] - -pub fn main() { - match 5_usize { - 1_usize..=5_usize => {} - _ => panic!("should match range"), - } - match 1_usize { - 1_usize..5_usize => {} - _ => panic!("should match range start"), - } - match 5_usize { - 6_usize..=7_usize => panic!("shouldn't match range"), - _ => {} - } - match 7_usize { - 6_usize..7_usize => panic!("shouldn't match range end"), - _ => {}, - } - match 5_usize { - 1_usize => panic!("should match non-first range"), - 2_usize..=6_usize => {} - _ => panic!("math is broken") - } - match 'c' { - 'a'..='z' => {} - _ => panic!("should support char ranges") - } - match -3 { - -7..=5 => {} - _ => panic!("should match signed range") - } - match 3.0f64 { - 1.0..=5.0 => {} - _ => panic!("should match float range") - } - match -1.5f64 { - -3.6..=3.6 => {} - _ => panic!("should match negative float range") - } - match 3.5 { - 0.0..3.5 => panic!("should not match the range end"), - _ => {}, - } - match 0.0 { - 0.0..3.5 => {}, - _ => panic!("should match the range start"), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-range-static.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-range-static.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-range-static.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-range-static.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 -#![allow(non_upper_case_globals)] - -const s: isize = 1; -const e: isize = 42; - -pub fn main() { - match 7 { - s..=e => (), - _ => (), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-reassign.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-reassign.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-reassign.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-reassign.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #23698: The reassignment checker only cared -// about the last assignment in a match arm body - -// Use an extra function to make sure no extra assignments -// are introduced by macros in the match statement -fn check_eq(x: i32, y: i32) { - assert_eq!(x, y); -} - -#[allow(unused_assignments)] -fn main() { - let mut x = Box::new(1); - match x { - y => { - x = Box::new(2); - let _tmp = 1; // This assignment used to throw off the reassignment checker - check_eq(*y, 1); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-ref-binding-in-guard-3256.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-ref-binding-in-guard-3256.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-ref-binding-in-guard-3256.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-ref-binding-in-guard-3256.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::sync::Mutex; - -pub fn main() { - let x = Some(Mutex::new(true)); - match x { - Some(ref z) if *z.lock().unwrap() => { - assert!(*z.lock().unwrap()); - }, - _ => panic!() - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-ref-binding-mut-option.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-ref-binding-mut-option.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-ref-binding-mut-option.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-ref-binding-mut-option.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let mut v = Some(22); - match v { - None => {} - Some(ref mut p) => { *p += 1; } - } - assert_eq!(v, Some(23)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-ref-binding-mut.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-ref-binding-mut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-ref-binding-mut.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-ref-binding-mut.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_shorthand_field_patterns)] - -struct Rec { - f: isize -} - -fn destructure(x: &mut Rec) { - match *x { - Rec {f: ref mut f} => *f += 1 - } -} - -pub fn main() { - let mut v = Rec {f: 22}; - destructure(&mut v); - assert_eq!(v.f, 23); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-ref-binding.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-ref-binding.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-ref-binding.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-ref-binding.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn destructure(x: Option) -> isize { - match x { - None => 0, - Some(ref v) => *v - } -} - -pub fn main() { - assert_eq!(destructure(Some(22)), 22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-ref-unsized.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-ref-unsized.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-ref-unsized.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-ref-unsized.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Binding unsized expressions to ref patterns - -pub fn main() { - let ref a = *"abcdef"; - assert_eq!(a, "abcdef"); - - match *"12345" { - ref b => { assert_eq!(b, "12345") } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-static-const-rename.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-static-const-rename.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-static-const-rename.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-static-const-rename.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #7526: lowercase static constants in patterns look like bindings - -// This is similar to compile-fail/match-static-const-lc, except it -// shows the expected usual workaround (choosing a different name for -// the static definition) and also demonstrates that one can work -// around this problem locally by renaming the constant in the `use` -// form to an uppercase identifier that placates the lint. - - -#![deny(non_upper_case_globals)] - -pub const A : isize = 97; - -fn f() { - let r = match (0,0) { - (0, A) => 0, - (x, y) => 1 + x + y, - }; - assert_eq!(r, 1); - let r = match (0,97) { - (0, A) => 0, - (x, y) => 1 + x + y, - }; - assert_eq!(r, 0); -} - -mod m { - #[allow(non_upper_case_globals)] - pub const aha : isize = 7; -} - -fn g() { - use self::m::aha as AHA; - let r = match (0,0) { - (0, AHA) => 0, - (x, y) => 1 + x + y, - }; - assert_eq!(r, 1); - let r = match (0,7) { - (0, AHA) => 0, - (x, y) => 1 + x + y, - }; - assert_eq!(r, 0); -} - -fn h() { - let r = match (0,0) { - (0, self::m::aha) => 0, - (x, y) => 1 + x + y, - }; - assert_eq!(r, 1); - let r = match (0,7) { - (0, self::m::aha) => 0, - (x, y) => 1 + x + y, - }; - assert_eq!(r, 0); -} - -pub fn main () { - f(); - g(); - h(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-str.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-str.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-str.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-str.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #53 -#![allow(non_camel_case_types)] - - -pub fn main() { - match "test" { "not-test" => panic!(), "test" => (), _ => panic!() } - - enum t { tag1(String), tag2, } - - - match t::tag1("test".to_string()) { - t::tag2 => panic!(), - t::tag1(ref s) if "test" != &**s => panic!(), - t::tag1(ref s) if "test" == &**s => (), - _ => panic!() - } - - let x = match "a" { "a" => 1, "b" => 2, _ => panic!() }; - assert_eq!(x, 1); - - match "a" { "a" => { } "b" => { }, _ => panic!() } - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-struct-0.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-struct-0.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-struct-0.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-struct-0.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct Foo{ - f : isize, -} - -pub fn main() { - let f = Foo{f: 1}; - match f { - Foo{f: 0} => panic!(), - Foo{..} => (), - } - match f { - Foo{f: 0} => panic!(), - Foo{f: _f} => (), - } - match f { - Foo{f: 0} => panic!(), - _ => (), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-tag.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-tag.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-tag.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-tag.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - - -enum color { - rgb(isize, isize, isize), - rgba(isize, isize, isize, isize), - hsl(isize, isize, isize), -} - -fn process(c: color) -> isize { - let mut x: isize; - match c { - color::rgb(r, _, _) => { x = r; } - color::rgba(_, _, _, a) => { x = a; } - color::hsl(_, s, _) => { x = s; } - } - return x; -} - -pub fn main() { - let gray: color = color::rgb(127, 127, 127); - let clear: color = color::rgba(50, 150, 250, 0); - let red: color = color::hsl(0, 255, 255); - assert_eq!(process(gray), 127); - assert_eq!(process(clear), 0); - assert_eq!(process(red), 255); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-unique-bind.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-unique-bind.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-unique-bind.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-unique-bind.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_patterns)] -#![feature(box_syntax)] - -pub fn main() { - match box 100 { - box x => { - println!("{}", x); - assert_eq!(x, 100); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-unsized.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-unsized.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-unsized.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-unsized.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - let data: &'static str = "Hello, World!"; - match data { - &ref xs => { - assert_eq!(data, xs); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-value-binding-in-guard-3291.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-value-binding-in-guard-3291.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-value-binding-in-guard-3291.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-value-binding-in-guard-3291.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - -fn foo(x: Option>, b: bool) -> isize { - match x { - None => { 1 } - Some(ref x) if b => { *x.clone() } - Some(_) => { 0 } - } -} - -pub fn main() { - foo(Some(box 22), true); - foo(Some(box 22), false); - foo(None, true); - foo(None, false); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-var-hygiene.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-var-hygiene.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-var-hygiene.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-var-hygiene.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// shouldn't affect evaluation of $ex. -macro_rules! bad_macro { ($ex:expr) => ( - {match 9 {_x => $ex}} -)} - -fn main() { - match 8 { - _x => assert_eq!(bad_macro!(_x),8) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-vec-alternatives.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-vec-alternatives.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-vec-alternatives.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-vec-alternatives.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(slice_patterns)] - -fn match_vecs<'a, T>(l1: &'a [T], l2: &'a [T]) -> &'static str { - match (l1, l2) { - (&[], &[]) => "both empty", - (&[], &[..]) | (&[..], &[]) => "one empty", - (&[..], &[..]) => "both non-empty" - } -} - -fn match_vecs_cons<'a, T>(l1: &'a [T], l2: &'a [T]) -> &'static str { - match (l1, l2) { - (&[], &[]) => "both empty", - (&[], &[_, ..]) | (&[_, ..], &[]) => "one empty", - (&[_, ..], &[_, ..]) => "both non-empty" - } -} - -fn match_vecs_snoc<'a, T>(l1: &'a [T], l2: &'a [T]) -> &'static str { - match (l1, l2) { - (&[], &[]) => "both empty", - (&[], &[.., _]) | (&[.., _], &[]) => "one empty", - (&[.., _], &[.., _]) => "both non-empty" - } -} - -fn match_nested_vecs_cons<'a, T>(l1: Option<&'a [T]>, l2: Result<&'a [T], ()>) -> &'static str { - match (l1, l2) { - (Some(&[]), Ok(&[])) => "Some(empty), Ok(empty)", - (Some(&[_, ..]), Ok(_)) | (Some(&[_, ..]), Err(())) => "Some(non-empty), any", - (None, Ok(&[])) | (None, Err(())) | (None, Ok(&[_])) => "None, Ok(less than one element)", - (None, Ok(&[_, _, ..])) => "None, Ok(at least two elements)", - _ => "other" - } -} - -fn match_nested_vecs_snoc<'a, T>(l1: Option<&'a [T]>, l2: Result<&'a [T], ()>) -> &'static str { - match (l1, l2) { - (Some(&[]), Ok(&[])) => "Some(empty), Ok(empty)", - (Some(&[.., _]), Ok(_)) | (Some(&[.., _]), Err(())) => "Some(non-empty), any", - (None, Ok(&[])) | (None, Err(())) | (None, Ok(&[_])) => "None, Ok(less than one element)", - (None, Ok(&[.., _, _])) => "None, Ok(at least two elements)", - _ => "other" - } -} - -fn main() { - assert_eq!(match_vecs(&[1, 2], &[2, 3]), "both non-empty"); - assert_eq!(match_vecs(&[], &[1, 2, 3, 4]), "one empty"); - assert_eq!(match_vecs::(&[], &[]), "both empty"); - assert_eq!(match_vecs(&[1, 2, 3], &[]), "one empty"); - - assert_eq!(match_vecs_cons(&[1, 2], &[2, 3]), "both non-empty"); - assert_eq!(match_vecs_cons(&[], &[1, 2, 3, 4]), "one empty"); - assert_eq!(match_vecs_cons::(&[], &[]), "both empty"); - assert_eq!(match_vecs_cons(&[1, 2, 3], &[]), "one empty"); - - assert_eq!(match_vecs_snoc(&[1, 2], &[2, 3]), "both non-empty"); - assert_eq!(match_vecs_snoc(&[], &[1, 2, 3, 4]), "one empty"); - assert_eq!(match_vecs_snoc::(&[], &[]), "both empty"); - assert_eq!(match_vecs_snoc(&[1, 2, 3], &[]), "one empty"); - - assert_eq!(match_nested_vecs_cons(None, Ok::<&[_], ()>(&[4_usize, 2_usize])), - "None, Ok(at least two elements)"); - assert_eq!(match_nested_vecs_cons::(None, Err(())), "None, Ok(less than one element)"); - assert_eq!(match_nested_vecs_cons::(Some::<&[_]>(&[]), Ok::<&[_], ()>(&[])), - "Some(empty), Ok(empty)"); - assert_eq!(match_nested_vecs_cons(Some::<&[_]>(&[1]), Err(())), "Some(non-empty), any"); - assert_eq!(match_nested_vecs_cons(Some::<&[_]>(&[(42, ())]), Ok::<&[_], ()>(&[(1, ())])), - "Some(non-empty), any"); - - assert_eq!(match_nested_vecs_snoc(None, Ok::<&[_], ()>(&[4_usize, 2_usize])), - "None, Ok(at least two elements)"); - assert_eq!(match_nested_vecs_snoc::(None, Err(())), "None, Ok(less than one element)"); - assert_eq!(match_nested_vecs_snoc::(Some::<&[_]>(&[]), Ok::<&[_], ()>(&[])), - "Some(empty), Ok(empty)"); - assert_eq!(match_nested_vecs_snoc(Some::<&[_]>(&[1]), Err(())), "Some(non-empty), any"); - assert_eq!(match_nested_vecs_snoc(Some::<&[_]>(&[(42, ())]), Ok::<&[_], ()>(&[(1, ())])), - "Some(non-empty), any"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-vec-rvalue.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-vec-rvalue.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-vec-rvalue.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-vec-rvalue.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests that matching rvalues with drops does not crash. - - - -pub fn main() { - match vec![1, 2, 3] { - x => { - assert_eq!(x.len(), 3); - assert_eq!(x[0], 1); - assert_eq!(x[1], 2); - assert_eq!(x[2], 3); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-with-ret-arm.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-with-ret-arm.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-with-ret-arm.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/match-with-ret-arm.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn main() { - // sometimes we have had trouble finding - // the right type for f, as we unified - // bot and u32 here - let f = match "1234".parse::().ok() { - None => return (), - Some(num) => num as u32 - }; - assert_eq!(f, 1234); - println!("{}", f) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/multi-let.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/multi-let.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/multi-let.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/multi-let.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let x = 10; - let y = x; - assert_eq!(y, 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/mut-in-ident-patterns.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/mut-in-ident-patterns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/mut-in-ident-patterns.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/mut-in-ident-patterns.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -#![allow(non_shorthand_field_patterns)] - -trait Foo { - fn foo(&self, mut x: isize) -> isize { - let val = x; - x = 37 * x; - val + x - } -} - -struct X; -impl Foo for X {} - -pub fn main() { - let (a, mut b) = (23, 4); - assert_eq!(a, 23); - assert_eq!(b, 4); - b = a + b; - assert_eq!(b, 27); - - - assert_eq!(X.foo(2), 76); - - enum Bar { - Foo(isize), - Baz(f32, u8) - } - - let (x, mut y) = (32, Bar::Foo(21)); - - match x { - mut z @ 32 => { - assert_eq!(z, 32); - z = 34; - assert_eq!(z, 34); - } - _ => {} - } - - check_bar(&y); - y = Bar::Baz(10.0, 3); - check_bar(&y); - - fn check_bar(y: &Bar) { - match y { - &Bar::Foo(a) => { - assert_eq!(a, 21); - } - &Bar::Baz(a, b) => { - assert_eq!(a, 10.0); - assert_eq!(b, 3); - } - } - } - - fn foo1((x, mut y): (f64, isize), mut z: isize) -> isize { - y = 2 * 6; - z = y + (x as isize); - y - z - } - - struct A { - x: isize - } - let A { x: mut x } = A { x: 10 }; - assert_eq!(x, 10); - x = 30; - assert_eq!(x, 30); - - (|A { x: mut t }: A| { t = t+1; t })(A { x: 34 }); - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/nested-exhaustive-match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/nested-exhaustive-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/nested-exhaustive-match.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/nested-exhaustive-match.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -struct Foo { foo: bool, bar: Option, baz: isize } - -pub fn main() { - match (Foo{foo: true, bar: Some(10), baz: 20}) { - Foo{foo: true, bar: Some(_), ..} => {} - Foo{foo: false, bar: None, ..} => {} - Foo{foo: true, bar: None, ..} => {} - Foo{foo: false, bar: Some(_), ..} => {} - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/nested-matchs.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/nested-matchs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/nested-matchs.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/nested-matchs.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn baz() -> ! { panic!(); } - -fn foo() { - match Some::(5) { - Some::(_x) => { - let mut bar; - match None:: { None:: => { bar = 5; } _ => { baz(); } } - println!("{}", bar); - } - None:: => { println!("hello"); } - } -} - -pub fn main() { foo(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/nested-pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/nested-pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/nested-pattern.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/nested-pattern.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// a bug was causing this to complain about leaked memory on exit - -enum t { foo(isize, usize), bar(isize, Option), } - -fn nested(o: t) { - match o { - t::bar(_i, Some::(_)) => { println!("wrong pattern matched"); panic!(); } - _ => { println!("succeeded"); } - } -} - -pub fn main() { nested(t::bar(1, None::)); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/nil-pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/nil-pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/nil-pattern.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/nil-pattern.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub fn main() { let x = (); match x { () => { } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/nullary-or-pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/nullary-or-pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/nullary-or-pattern.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/nullary-or-pattern.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -enum blah { a, b, } - -fn or_alt(q: blah) -> isize { - match q { blah::a | blah::b => { 42 } } -} - -pub fn main() { - assert_eq!(or_alt(blah::a), 42); - assert_eq!(or_alt(blah::b), 42); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/optional_comma_in_match_arm.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/optional_comma_in_match_arm.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/optional_comma_in_match_arm.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/optional_comma_in_match_arm.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty issue #37199 -#![allow(while_true)] - -fn main() { - let x = 1; - - match x { - 1 => loop { break; }, - 2 => while true { break; }, - 3 => if true { () }, - 4 => if true { () } else { () }, - 5 => match () { () => () }, - 6 => { () }, - 7 => unsafe { () }, - _ => (), - } - - match x { - 1 => loop { break; } - 2 => while true { break; } - 3 => if true { () } - 4 => if true { () } else { () } - 5 => match () { () => () } - 6 => { () } - 7 => unsafe { () } - _ => () - } - - let r: &i32 = &x; - - match r { - // Absence of comma should not cause confusion between a pattern - // and a bitwise and. - &1 => if true { () } else { () } - &2 => (), - _ =>() - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/order-drop-with-match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/order-drop-with-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/order-drop-with-match.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/order-drop-with-match.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Test to make sure the destructors run in the right order. -// Each destructor sets it's tag in the corresponding entry -// in ORDER matching up to when it ran. -// Correct order is: matched, inner, outer - - -static mut ORDER: [usize; 3] = [0, 0, 0]; -static mut INDEX: usize = 0; - -struct A; -impl Drop for A { - fn drop(&mut self) { - unsafe { - ORDER[INDEX] = 1; - INDEX = INDEX + 1; - } - } -} - -struct B; -impl Drop for B { - fn drop(&mut self) { - unsafe { - ORDER[INDEX] = 2; - INDEX = INDEX + 1; - } - } -} - -struct C; -impl Drop for C { - fn drop(&mut self) { - unsafe { - ORDER[INDEX] = 3; - INDEX = INDEX + 1; - } - } -} - -fn main() { - { - let matched = A; - let _outer = C; - { - match matched { - _s => {} - } - let _inner = B; - } - } - unsafe { - let expected: &[_] = &[1, 2, 3]; - assert_eq!(expected, ORDER); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/or-pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/or-pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/or-pattern.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/or-pattern.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -enum blah { a(isize, isize, usize), b(isize, isize), c, } - -fn or_alt(q: blah) -> isize { - match q { blah::a(x, y, _) | blah::b(x, y) => { return x + y; } blah::c => { return 0; } } -} - -pub fn main() { - assert_eq!(or_alt(blah::c), 0); - assert_eq!(or_alt(blah::a(10, 100, 0)), 110); - assert_eq!(or_alt(blah::b(20, 200)), 220); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-ranges.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-ranges.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-ranges.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-ranges.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Parsing of range patterns - -const NUM1: i32 = 10; - -mod m { - pub const NUM2: i32 = 16; -} - -fn main() { - if let NUM1 ... m::NUM2 = 10 {} else { panic!() } - if let ::NUM1 ... ::m::NUM2 = 11 {} else { panic!() } - if let -13 ... -10 = 12 { panic!() } else {} -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/pattern-bound-var-in-for-each.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/pattern-bound-var-in-for-each.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/pattern-bound-var-in-for-each.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/pattern-bound-var-in-for-each.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests that codegen_path checks whether a -// pattern-bound var is an upvar (when codegenning -// the for-each body) - - -fn foo(src: usize) { - - match Some(src) { - Some(src_id) => { - for _i in 0_usize..10_usize { - let yyy = src_id; - assert_eq!(yyy, 0_usize); - } - } - _ => { } - } -} - -pub fn main() { foo(0_usize); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/pattern-in-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/pattern-in-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/pattern-in-closure.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/pattern-in-closure.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_shorthand_field_patterns)] - -struct Foo { - x: isize, - y: isize -} - -pub fn main() { - let f = |(x, _): (isize, isize)| println!("{}", x + 1); - let g = |Foo { x: x, y: _y }: Foo| println!("{}", x + 1); - f((2, 3)); - g(Foo { x: 1, y: 2 }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn tuple() { - let x = (1, 2, 3); - match x { - (a, b, ..) => { - assert_eq!(a, 1); - assert_eq!(b, 2); - } - } - match x { - (.., b, c) => { - assert_eq!(b, 2); - assert_eq!(c, 3); - } - } - match x { - (a, .., c) => { - assert_eq!(a, 1); - assert_eq!(c, 3); - } - } - match x { - (a, b, c) => { - assert_eq!(a, 1); - assert_eq!(b, 2); - assert_eq!(c, 3); - } - } - match x { - (a, b, c, ..) => { - assert_eq!(a, 1); - assert_eq!(b, 2); - assert_eq!(c, 3); - } - } - match x { - (.., a, b, c) => { - assert_eq!(a, 1); - assert_eq!(b, 2); - assert_eq!(c, 3); - } - } -} - -fn tuple_struct() { - struct S(u8, u8, u8); - - let x = S(1, 2, 3); - match x { - S(a, b, ..) => { - assert_eq!(a, 1); - assert_eq!(b, 2); - } - } - match x { - S(.., b, c) => { - assert_eq!(b, 2); - assert_eq!(c, 3); - } - } - match x { - S(a, .., c) => { - assert_eq!(a, 1); - assert_eq!(c, 3); - } - } - match x { - S(a, b, c) => { - assert_eq!(a, 1); - assert_eq!(b, 2); - assert_eq!(c, 3); - } - } - match x { - S(a, b, c, ..) => { - assert_eq!(a, 1); - assert_eq!(b, 2); - assert_eq!(c, 3); - } - } - match x { - S(.., a, b, c) => { - assert_eq!(a, 1); - assert_eq!(b, 2); - assert_eq!(c, 3); - } - } -} - -fn main() { - tuple(); - tuple_struct(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn tuple() { - let x = (1,); - match x { - (2, ..) => panic!(), - (..) => () - } -} - -fn tuple_struct() { - struct S(u8); - - let x = S(1); - match x { - S(2, ..) => panic!(), - S(..) => () - } -} - -fn main() { - tuple(); - tuple_struct(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn tuple() { - let x = (1, 2, 3); - let branch = match x { - (1, 1, ..) => 0, - (1, 2, 3, ..) => 1, - (1, 2, ..) => 2, - _ => 3 - }; - assert_eq!(branch, 1); -} - -fn tuple_struct() { - struct S(u8, u8, u8); - - let x = S(1, 2, 3); - let branch = match x { - S(1, 1, ..) => 0, - S(1, 2, 3, ..) => 1, - S(1, 2, ..) => 2, - _ => 3 - }; - assert_eq!(branch, 1); -} - -fn main() { - tuple(); - tuple_struct(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-4.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-4.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-4.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn tuple() { - let x = (1, 2, 3); - match x { - (1, 2, 4) => unreachable!(), - (0, 2, 3, ..) => unreachable!(), - (0, .., 3) => unreachable!(), - (0, ..) => unreachable!(), - (1, 2, 3) => (), - (_, _, _) => unreachable!(), - } - match x { - (..) => (), - } - match x { - (_, _, _, ..) => (), - } - match x { - (a, b, c) => { - assert_eq!(1, a); - assert_eq!(2, b); - assert_eq!(3, c); - } - } -} - -fn tuple_struct() { - struct S(u8, u8, u8); - - let x = S(1, 2, 3); - match x { - S(1, 2, 4) => unreachable!(), - S(0, 2, 3, ..) => unreachable!(), - S(0, .., 3) => unreachable!(), - S(0, ..) => unreachable!(), - S(1, 2, 3) => (), - S(_, _, _) => unreachable!(), - } - match x { - S(..) => (), - } - match x { - S(_, _, _, ..) => (), - } - match x { - S(a, b, c) => { - assert_eq!(1, a); - assert_eq!(2, b); - assert_eq!(3, c); - } - } -} - -fn main() { - tuple(); - tuple_struct(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-5.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-5.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-5.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-5.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn tuple() { - struct S; - struct Z; - struct W; - let x = (S, Z, W); - match x { (S, ..) => {} } - match x { (.., W) => {} } - match x { (S, .., W) => {} } - match x { (.., Z, _) => {} } -} - -fn tuple_struct() { - struct SS(S, Z, W); - - struct S; - struct Z; - struct W; - let x = SS(S, Z, W); - match x { SS(S, ..) => {} } - match x { SS(.., W) => {} } - match x { SS(S, .., W) => {} } - match x { SS(.., Z, _) => {} } -} - -fn main() { - tuple(); - tuple_struct(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-6.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-6.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-6.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-6.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn tuple() { - let x = (1, 2, 3, 4, 5); - match x { - (a, .., b, c) => { - assert_eq!(a, 1); - assert_eq!(b, 4); - assert_eq!(c, 5); - } - } - match x { - (a, b, c, .., d) => { - assert_eq!(a, 1); - assert_eq!(b, 2); - assert_eq!(c, 3); - assert_eq!(d, 5); - } - } -} - -fn tuple_struct() { - struct S(u8, u8, u8, u8, u8); - - let x = S(1, 2, 3, 4, 5); - match x { - S(a, .., b, c) => { - assert_eq!(a, 1); - assert_eq!(b, 4); - assert_eq!(c, 5); - } - } - match x { - S(a, b, c, .., d) => { - assert_eq!(a, 1); - assert_eq!(b, 2); - assert_eq!(c, 3); - assert_eq!(d, 5); - } - } -} - -fn main() { - tuple(); - tuple_struct(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-7.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-7.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-7.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/pat-tuple-7.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(pattern_parentheses)] - -fn main() { - match 0 { - (pat) => assert_eq!(pat, 0) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/range-inclusive-pattern-precedence.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/range-inclusive-pattern-precedence.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/range-inclusive-pattern-precedence.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/range-inclusive-pattern-precedence.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_patterns, pattern_parentheses)] - -const VALUE: usize = 21; - -pub fn main() { - match &18 { - &(18..=18) => {} - _ => { unreachable!(); } - } - match &21 { - &(VALUE..=VALUE) => {} - _ => { unreachable!(); } - } - match Box::new(18) { - box (18..=18) => {} - _ => { unreachable!(); } - } - match Box::new(21) { - box (VALUE..=VALUE) => {} - _ => { unreachable!(); } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/simple-generic-match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/simple-generic-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/simple-generic-match.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/simple-generic-match.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -enum clam { a(T), } - -pub fn main() { let c = clam::a(2); match c { clam::a::(_) => { } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/use-uninit-match2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/use-uninit-match2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/use-uninit-match2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/use-uninit-match2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - -fn foo(o: myoption) -> isize { - let mut x: isize; - match o { - myoption::none:: => { panic!(); } - myoption::some::(_t) => { x = 5; } - } - return x; -} - -enum myoption { none, some(T), } - -pub fn main() { println!("{}", 5); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/use-uninit-match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/use-uninit-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/use-uninit-match.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/use-uninit-match.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - -fn foo(o: myoption) -> isize { - let mut x: isize = 5; - match o { - myoption::none:: => { } - myoption::some::(_t) => { x += 1; } - } - return x; -} - -enum myoption { none, some(T), } - -pub fn main() { println!("{}", 5); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/zero_sized_subslice_match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/zero_sized_subslice_match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/binding/zero_sized_subslice_match.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/binding/zero_sized_subslice_match.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(slice_patterns)] - -fn main() { - let x = [(), ()]; - - // The subslice used to go out of bounds for zero-sized array items, check that this doesn't - // happen anymore - match x { - [_, ref y..] => assert_eq!(&x[1] as *const (), &y[0] as *const ()) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-assignment-to-static-mut.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-assignment-to-static-mut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-assignment-to-static-mut.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-assignment-to-static-mut.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test taken from #45641 (https://github.com/rust-lang/rust/issues/45641) - -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -static mut Y: u32 = 0; - -unsafe fn should_ok() { - Y = 1; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-assign-to-subfield.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-assign-to-subfield.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-assign-to-subfield.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-assign-to-subfield.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub fn main() { - struct A { - a: isize, - w: B, - } - struct B { - a: isize - } - let mut p = A { - a: 1, - w: B {a: 1}, - }; - - // even though `x` is not declared as a mutable field, - // `p` as a whole is mutable, so it can be modified. - p.a = 2; - - // this is true for an interior field too - p.w.a = 2; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-binding-mutbl.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-binding-mutbl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-binding-mutbl.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-binding-mutbl.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct F { f: Vec } - -fn impure(_v: &[isize]) { -} - -pub fn main() { - let mut x = F {f: vec![3]}; - - match x { - F {f: ref mut v} => { - impure(v); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-borrow-from-expr-block.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-borrow-from-expr-block.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-borrow-from-expr-block.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-borrow-from-expr-block.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -fn borrow(x: &isize, f: F) where F: FnOnce(&isize) { - f(x) -} - -fn test1(x: &Box) { - borrow(&*(*x).clone(), |p| { - let x_a = &**x as *const isize; - assert!((x_a as usize) != (p as *const isize as usize)); - assert_eq!(unsafe{*x_a}, *p); - }) -} - -pub fn main() { - test1(&box 22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-borrow-of-mut-base-ptr-safe.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-borrow-of-mut-base-ptr-safe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-borrow-of-mut-base-ptr-safe.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-borrow-of-mut-base-ptr-safe.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that freezing an `&mut` pointer while referent is -// frozen is legal. -// -// Example from src/librustc_borrowck/borrowck/README.md - -// pretty-expanded FIXME #23616 - -fn foo<'a>(mut t0: &'a mut isize, - mut t1: &'a mut isize) { - let p: &isize = &*t0; // Freezes `*t0` - let mut t2 = &t0; - let q: &isize = &**t2; // Freezes `*t0`, but that's ok... - let r: &isize = &*t0; // ...after all, could do same thing directly. -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-closures-two-imm.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-closures-two-imm.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-closures-two-imm.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-closures-two-imm.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests that two closures can simultaneously have immutable -// access to the variable, whether that immutable access be used -// for direct reads or for taking immutable ref. Also check -// that the main function can read the variable too while -// the closures are in scope. Issue #6801. - - -fn a() -> i32 { - let mut x = 3; - x += 1; - let c1 = || x * 4; - let c2 = || x * 5; - c1() * c2() * x -} - -fn get(x: &i32) -> i32 { - *x * 4 -} - -fn b() -> i32 { - let mut x = 3; - x += 1; - let c1 = || get(&x); - let c2 = || get(&x); - c1() * c2() * x -} - -fn c() -> i32 { - let mut x = 3; - x += 1; - let c1 = || x * 5; - let c2 = || get(&x); - c1() * c2() * x -} - -pub fn main() { - assert_eq!(a(), 1280); - assert_eq!(b(), 1024); - assert_eq!(c(), 1280); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-field-sensitivity.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-field-sensitivity.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-field-sensitivity.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-field-sensitivity.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,274 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - -struct A { a: isize, b: Box } -struct B { a: Box, b: Box } - -fn move_after_copy() { - let x = A { a: 1, b: box 2 }; - drop(x.a); - drop(x.b); -} - -fn move_after_fu_copy() { - let x = A { a: 1, b: box 2 }; - let _y = A { b: box 3, .. x }; - drop(x.b); -} - -fn fu_move_after_copy() { - let x = A { a: 1, b: box 2 }; - drop(x.a); - let _y = A { a: 3, .. x }; -} - -fn fu_move_after_fu_copy() { - let x = A { a: 1, b: box 2 }; - let _y = A { b: box 3, .. x }; - let _z = A { a: 4, .. x }; -} - -fn copy_after_move() { - let x = A { a: 1, b: box 2 }; - drop(x.b); - drop(x.a); -} - -fn copy_after_fu_move() { - let x = A { a: 1, b: box 2 }; - let y = A { a: 3, .. x }; - drop(x.a); -} - -fn fu_copy_after_move() { - let x = A { a: 1, b: box 2 }; - drop(x.b); - let _y = A { b: box 3, .. x }; -} - -fn fu_copy_after_fu_move() { - let x = A { a: 1, b: box 2 }; - let _y = A { a: 3, .. x }; - let _z = A { b: box 3, .. x }; -} - -fn borrow_after_move() { - let x = A { a: 1, b: box 2 }; - drop(x.b); - let p = &x.a; - drop(*p); -} - -fn borrow_after_fu_move() { - let x = A { a: 1, b: box 2 }; - let _y = A { a: 3, .. x }; - let p = &x.a; - drop(*p); -} - -fn move_after_borrow() { - let x = A { a: 1, b: box 2 }; - let p = &x.a; - drop(x.b); - drop(*p); -} - -fn fu_move_after_borrow() { - let x = A { a: 1, b: box 2 }; - let p = &x.a; - let _y = A { a: 3, .. x }; - drop(*p); -} - -fn mut_borrow_after_mut_borrow() { - let mut x = A { a: 1, b: box 2 }; - let p = &mut x.a; - let q = &mut x.b; - drop(*p); - drop(**q); -} - -fn move_after_move() { - let x = B { a: box 1, b: box 2 }; - drop(x.a); - drop(x.b); -} - -fn move_after_fu_move() { - let x = B { a: box 1, b: box 2 }; - let y = B { a: box 3, .. x }; - drop(x.a); -} - -fn fu_move_after_move() { - let x = B { a: box 1, b: box 2 }; - drop(x.a); - let z = B { a: box 3, .. x }; - drop(z.b); -} - -fn fu_move_after_fu_move() { - let x = B { a: box 1, b: box 2 }; - let _y = B { b: box 3, .. x }; - let _z = B { a: box 4, .. x }; -} - -fn copy_after_assign_after_move() { - let mut x = A { a: 1, b: box 2 }; - drop(x.b); - x = A { a: 3, b: box 4 }; - drop(*x.b); -} - -fn copy_after_assign_after_fu_move() { - let mut x = A { a: 1, b: box 2 }; - let _y = A { a: 3, .. x }; - x = A { a: 3, b: box 4 }; - drop(*x.b); -} - -fn copy_after_field_assign_after_move() { - let mut x = A { a: 1, b: box 2 }; - drop(x.b); - x.b = box 3; - drop(*x.b); -} - -fn copy_after_field_assign_after_fu_move() { - let mut x = A { a: 1, b: box 2 }; - let _y = A { a: 3, .. x }; - x.b = box 3; - drop(*x.b); -} - -fn borrow_after_assign_after_move() { - let mut x = A { a: 1, b: box 2 }; - drop(x.b); - x = A { a: 3, b: box 4 }; - let p = &x.b; - drop(**p); -} - -fn borrow_after_assign_after_fu_move() { - let mut x = A { a: 1, b: box 2 }; - let _y = A { a: 3, .. x }; - x = A { a: 3, b: box 4 }; - let p = &x.b; - drop(**p); -} - -fn borrow_after_field_assign_after_move() { - let mut x = A { a: 1, b: box 2 }; - drop(x.b); - x.b = box 3; - let p = &x.b; - drop(**p); -} - -fn borrow_after_field_assign_after_fu_move() { - let mut x = A { a: 1, b: box 2 }; - let _y = A { a: 3, .. x }; - x.b = box 3; - let p = &x.b; - drop(**p); -} - -fn move_after_assign_after_move() { - let mut x = A { a: 1, b: box 2 }; - let _y = x.b; - x = A { a: 3, b: box 4 }; - drop(x.b); -} - -fn move_after_assign_after_fu_move() { - let mut x = A { a: 1, b: box 2 }; - let _y = A { a: 3, .. x }; - x = A { a: 3, b: box 4 }; - drop(x.b); -} - -fn move_after_field_assign_after_move() { - let mut x = A { a: 1, b: box 2 }; - drop(x.b); - x.b = box 3; - drop(x.b); -} - -fn move_after_field_assign_after_fu_move() { - let mut x = A { a: 1, b: box 2 }; - let _y = A { a: 3, .. x }; - x.b = box 3; - drop(x.b); -} - -fn copy_after_assign_after_uninit() { - let mut x: A; - x = A { a: 1, b: box 2 }; - drop(x.a); -} - -fn borrow_after_assign_after_uninit() { - let mut x: A; - x = A { a: 1, b: box 2 }; - let p = &x.a; - drop(*p); -} - -fn move_after_assign_after_uninit() { - let mut x: A; - x = A { a: 1, b: box 2 }; - drop(x.b); -} - -fn main() { - move_after_copy(); - move_after_fu_copy(); - fu_move_after_copy(); - fu_move_after_fu_copy(); - copy_after_move(); - copy_after_fu_move(); - fu_copy_after_move(); - fu_copy_after_fu_move(); - - borrow_after_move(); - borrow_after_fu_move(); - move_after_borrow(); - fu_move_after_borrow(); - mut_borrow_after_mut_borrow(); - - move_after_move(); - move_after_fu_move(); - fu_move_after_move(); - fu_move_after_fu_move(); - - copy_after_assign_after_move(); - copy_after_assign_after_fu_move(); - copy_after_field_assign_after_move(); - copy_after_field_assign_after_fu_move(); - - borrow_after_assign_after_move(); - borrow_after_assign_after_fu_move(); - borrow_after_field_assign_after_move(); - borrow_after_field_assign_after_fu_move(); - - move_after_assign_after_move(); - move_after_assign_after_fu_move(); - move_after_field_assign_after_move(); - move_after_field_assign_after_fu_move(); - - copy_after_assign_after_uninit(); - borrow_after_assign_after_uninit(); - move_after_assign_after_uninit(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-fixed-length-vecs.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-fixed-length-vecs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-fixed-length-vecs.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-fixed-length-vecs.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let x = [22]; - let y = &x[0]; - assert_eq!(*y, 22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-freeze-frozen-mut.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-freeze-frozen-mut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-freeze-frozen-mut.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-freeze-frozen-mut.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that a `&mut` inside of an `&` is freezable. - - -struct MutSlice<'a, T:'a> { - data: &'a mut [T] -} - -fn get<'a, T>(ms: &'a MutSlice<'a, T>, index: usize) -> &'a T { - &ms.data[index] -} - -pub fn main() { - let mut data = [1, 2, 3]; - { - let slice = MutSlice { data: &mut data }; - slice.data[0] += 4; - let index0 = get(&slice, 0); - let index1 = get(&slice, 1); - let index2 = get(&slice, 2); - assert_eq!(*index0, 5); - assert_eq!(*index1, 2); - assert_eq!(*index2, 3); - } - assert_eq!(data[0], 5); - assert_eq!(data[1], 2); - assert_eq!(data[2], 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-lend-args.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-lend-args.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-lend-args.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-lend-args.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// pretty-expanded FIXME #23616 - -fn borrow(_v: &isize) {} - -fn borrow_from_arg_imm_ref(v: Box) { - borrow(&*v); -} - -fn borrow_from_arg_mut_ref(v: &mut Box) { - borrow(&**v); -} - -fn borrow_from_arg_copy(v: Box) { - borrow(&*v); -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-macro-interaction-issue-6304.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-macro-interaction-issue-6304.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-macro-interaction-issue-6304.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-macro-interaction-issue-6304.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(unconditional_recursion)] - -// Check that we do not ICE when compiling this -// macro, which reuses the expression `$id` - - -#![feature(box_patterns)] -#![feature(box_syntax)] - -struct Foo { - a: isize -} - -pub enum Bar { - Bar1, Bar2(isize, Box), -} - -impl Foo { - fn elaborate_stm(&mut self, s: Box) -> Box { - macro_rules! declare { - ($id:expr, $rest:expr) => ({ - self.check_id($id); - box Bar::Bar2($id, $rest) - }) - } - match s { - box Bar::Bar2(id, rest) => declare!(id, self.elaborate_stm(rest)), - _ => panic!() - } - } - - fn check_id(&mut self, s: isize) { panic!() } -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-move-by-capture-ok.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-move-by-capture-ok.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-move-by-capture-ok.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-move-by-capture-ok.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -pub fn main() { - let bar: Box<_> = box 3; - let h = || -> isize { *bar }; - assert_eq!(h(), 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-multiple-borrows-interior-boxes.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-multiple-borrows-interior-boxes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-multiple-borrows-interior-boxes.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-multiple-borrows-interior-boxes.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test case from #39963. - -#![feature(nll)] - -#[derive(Clone)] -struct Foo(Option>, Option>); - -fn test(f: &mut Foo) { - match *f { - Foo(Some(ref mut left), Some(ref mut right)) => match **left { - Foo(Some(ref mut left), Some(ref mut right)) => panic!(), - _ => panic!(), - }, - _ => panic!(), - } -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-mut-uniq.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-mut-uniq.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-mut-uniq.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-mut-uniq.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -use std::mem::swap; - -#[derive(Debug)] -struct Ints {sum: Box, values: Vec } - -fn add_int(x: &mut Ints, v: isize) { - *x.sum += v; - let mut values = Vec::new(); - swap(&mut values, &mut x.values); - values.push(v); - swap(&mut values, &mut x.values); -} - -fn iter_ints(x: &Ints, mut f: F) -> bool where F: FnMut(&isize) -> bool { - let l = x.values.len(); - (0..l).all(|i| f(&x.values[i])) -} - -pub fn main() { - let mut ints: Box<_> = box Ints {sum: box 0, values: Vec::new()}; - add_int(&mut *ints, 22); - add_int(&mut *ints, 44); - - iter_ints(&*ints, |i| { - println!("isize = {:?}", *i); - true - }); - - println!("ints={:?}", ints); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-mut-vec-as-imm-slice.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-mut-vec-as-imm-slice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-mut-vec-as-imm-slice.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-mut-vec-as-imm-slice.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -fn want_slice(v: &[isize]) -> isize { - let mut sum = 0; - for i in v { sum += *i; } - sum -} - -fn has_mut_vec(v: Vec ) -> isize { - want_slice(&v) -} - -pub fn main() { - assert_eq!(has_mut_vec(vec![1, 2, 3]), 6); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-pat-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-pat-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-pat-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-pat-enum.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty issue #37199 - -fn match_ref(v: Option) -> isize { - match v { - Some(ref i) => { - *i - } - None => {0} - } -} - -fn match_ref_unused(v: Option) { - match v { - Some(_) => {} - None => {} - } -} - -fn impure(_i: isize) { -} - -fn match_imm_reg(v: &Option) { - match *v { - Some(ref i) => {impure(*i)} // OK because immutable - None => {} - } -} - -fn match_mut_reg(v: &mut Option) { - match *v { - Some(ref i) => {impure(*i)} // OK, frozen - None => {} - } -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-pat-reassign-no-binding.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-pat-reassign-no-binding.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-pat-reassign-no-binding.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-pat-reassign-no-binding.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let mut x = None; - match x { - None => { - // It is ok to reassign x here, because there is in - // fact no outstanding loan of x! - x = Some(0); - } - Some(_) => { } - } - assert_eq!(x, Some(0)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-rvalues-mutable.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-rvalues-mutable.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-rvalues-mutable.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-rvalues-mutable.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct Counter { - value: usize -} - -impl Counter { - fn new(v: usize) -> Counter { - Counter {value: v} - } - - fn inc<'a>(&'a mut self) -> &'a mut Counter { - self.value += 1; - self - } - - fn get(&self) -> usize { - self.value - } - - fn get_and_inc(&mut self) -> usize { - let v = self.value; - self.value += 1; - v - } -} - -pub fn main() { - let v = Counter::new(22).get_and_inc(); - assert_eq!(v, 22); - - let v = Counter::new(22).inc().inc().get(); - assert_eq!(v, 24); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-scope-of-deref-issue-4666.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-scope-of-deref-issue-4666.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-scope-of-deref-issue-4666.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-scope-of-deref-issue-4666.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests that the scope of the pointer returned from `get()` is -// limited to the deref operation itself, and does not infect the -// block as a whole. - - -struct Box { - x: usize -} - -impl Box { - fn get(&self) -> &usize { - &self.x - } - fn set(&mut self, x: usize) { - self.x = x; - } -} - -fn fun1() { - // in the past, borrow checker behaved differently when - // init and decl of `v` were distinct - let v; - let mut a_box = Box {x: 0}; - a_box.set(22); - v = *a_box.get(); - a_box.set(v+1); - assert_eq!(23, *a_box.get()); -} - -fn fun2() { - let mut a_box = Box {x: 0}; - a_box.set(22); - let v = *a_box.get(); - a_box.set(v+1); - assert_eq!(23, *a_box.get()); -} - -pub fn main() { - fun1(); - fun2(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-slice-pattern-element-loan.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-slice-pattern-element-loan.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-slice-pattern-element-loan.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-slice-pattern-element-loan.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -//compile-flags: -Z borrowck=mir - -#![feature(slice_patterns)] - -fn mut_head_tail<'a, A>(v: &'a mut [A]) -> Option<(&'a mut A, &'a mut [A])> { - match *v { - [ref mut head, ref mut tail..] => { - Some((head, tail)) - } - [] => None - } -} - -fn main() { - let mut v = [1,2,3,4]; - match mut_head_tail(&mut v) { - None => {}, - Some((h,t)) => { - *h = 1000; - t.reverse(); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-static-item-in-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-static-item-in-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-static-item-in-fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-static-item-in-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for issue #7740 - -// pretty-expanded FIXME #23616 - -pub fn main() { - static A: &'static char = &'A'; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-trait-lifetime.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-trait-lifetime.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-trait-lifetime.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-trait-lifetime.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This test verifies that casting from the same lifetime on a value -// to the same lifetime on a trait succeeds. See issue #10766. - -// pretty-expanded FIXME #23616 - -#![allow(dead_code)] - -use std::marker; - -fn main() { - trait T { fn foo(&self) {} } - - fn f<'a, V: T>(v: &'a V) -> &'a T { - v as &'a T - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-uniq-via-ref.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-uniq-via-ref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-uniq-via-ref.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-uniq-via-ref.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// pretty-expanded FIXME #23616 - -struct Rec { - f: Box, -} - -struct Outer { - f: Inner -} - -struct Inner { - g: Innermost -} - -struct Innermost { - h: Box, -} - -fn borrow(_v: &isize) {} - -fn box_mut(v: &mut Box) { - borrow(&**v); // OK: &mut -> &imm -} - -fn box_mut_rec(v: &mut Rec) { - borrow(&*v.f); // OK: &mut -> &imm -} - -fn box_mut_recs(v: &mut Outer) { - borrow(&*v.f.g.h); // OK: &mut -> &imm -} - -fn box_imm(v: &Box) { - borrow(&**v); // OK -} - -fn box_imm_rec(v: &Rec) { - borrow(&*v.f); // OK -} - -fn box_imm_recs(v: &Outer) { - borrow(&*v.f.g.h); // OK -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-univariant-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-univariant-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-univariant-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-univariant-enum.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -use std::cell::Cell; - -#[derive(Copy, Clone)] -enum newtype { - newvar(isize) -} - -pub fn main() { - - // Test that borrowck treats enums with a single variant - // specially. - - let x = &Cell::new(5); - let y = &Cell::new(newtype::newvar(3)); - let z = match y.get() { - newtype::newvar(b) => { - x.set(x.get() + 1); - x.get() * b - } - }; - assert_eq!(z, 18); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-unsafe-static-mutable-borrows.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-unsafe-static-mutable-borrows.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-unsafe-static-mutable-borrows.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-unsafe-static-mutable-borrows.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// revisions: ast mir -//[mir]compile-flags: -Z borrowck=mir - -// Test file taken from issue 45129 (https://github.com/rust-lang/rust/issues/45129) - -struct Foo { x: [usize; 2] } - -static mut SFOO: Foo = Foo { x: [23, 32] }; - -impl Foo { - fn x(&mut self) -> &mut usize { &mut self.x[0] } -} - -fn main() { - unsafe { - let sfoo: *mut Foo = &mut SFOO; - let x = (*sfoo).x(); - (*sfoo).x[1] += 1; - *x += 1; - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-unused-mut-locals.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-unused-mut-locals.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-unused-mut-locals.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-unused-mut-locals.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(nll)] -#![deny(unused_mut)] - -#[derive(Debug)] -struct A {} - -fn init_a() -> A { - A {} -} - -#[derive(Debug)] -struct B<'a> { - ed: &'a mut A, -} - -fn init_b<'a>(ed: &'a mut A) -> B<'a> { - B { ed } -} - -#[derive(Debug)] -struct C<'a> { - pd: &'a mut B<'a>, -} - -fn init_c<'a>(pd: &'a mut B<'a>) -> C<'a> { - C { pd } -} - -#[derive(Debug)] -struct D<'a> { - sd: &'a mut C<'a>, -} - -fn init_d<'a>(sd: &'a mut C<'a>) -> D<'a> { - D { sd } -} - -fn main() { - let mut a = init_a(); - let mut b = init_b(&mut a); - let mut c = init_c(&mut b); - - let d = init_d(&mut c); - - println!("{:?}", d) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-use-mut-borrow.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-use-mut-borrow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-use-mut-borrow.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/borrowck-use-mut-borrow.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - -struct A { a: isize, b: Box } - -fn field_copy_after_field_borrow() { - let mut x = A { a: 1, b: box 2 }; - let p = &mut x.b; - drop(x.a); - **p = 3; -} - -fn fu_field_copy_after_field_borrow() { - let mut x = A { a: 1, b: box 2 }; - let p = &mut x.b; - let y = A { b: box 3, .. x }; - drop(y); - **p = 4; -} - -fn field_deref_after_field_borrow() { - let mut x = A { a: 1, b: box 2 }; - let p = &mut x.a; - drop(*x.b); - *p = 3; -} - -fn field_move_after_field_borrow() { - let mut x = A { a: 1, b: box 2 }; - let p = &mut x.a; - drop(x.b); - *p = 3; -} - -fn fu_field_move_after_field_borrow() { - let mut x = A { a: 1, b: box 2 }; - let p = &mut x.a; - let y = A { a: 3, .. x }; - drop(y); - *p = 4; -} - -fn main() { - field_copy_after_field_borrow(); - fu_field_copy_after_field_borrow(); - field_deref_after_field_borrow(); - field_move_after_field_borrow(); - fu_field_move_after_field_borrow(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/two-phase-baseline.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/two-phase-baseline.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/two-phase-baseline.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/two-phase-baseline.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: -Z borrowck=mir -Z two-phase-borrows - -// This is the "goto example" for why we want two phase borrows. - -fn main() { - let mut v = vec![0, 1, 2]; - v.push(v.len()); - assert_eq!(v, [0, 1, 2, 3]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/two-phase-bin-ops.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/two-phase-bin-ops.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/two-phase-bin-ops.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/two-phase-bin-ops.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// revisions: lxl nll - -#![cfg_attr(nll, feature(nll))] - -use std::ops::{AddAssign, SubAssign, MulAssign, DivAssign, RemAssign}; -use std::ops::{BitAndAssign, BitOrAssign, BitXorAssign, ShlAssign, ShrAssign}; - -struct A(i32); - -macro_rules! trivial_binop { - ($Trait:ident, $m:ident) => { - impl $Trait 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 main() { - let mut a = A(10); - a += a.0; - a -= a.0; - a *= a.0; - a /= a.0; - a &= a.0; - a |= a.0; - a ^= a.0; - a <<= a.0; - a >>= a.0; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/two-phase-control-flow-split-before-activation.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/two-phase-control-flow-split-before-activation.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/two-phase-control-flow-split-before-activation.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/borrowck/two-phase-control-flow-split-before-activation.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// revisions: lxl nll -//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows - -#![cfg_attr(nll, feature(nll))] - -fn main() { - let mut a = 0; - let mut b = 0; - let p = if maybe() { - &mut a - } else { - &mut b - }; - use_(p); -} - -fn maybe() -> bool { false } -fn use_(_: T) { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/auxiliary/cfg_inner_static.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/auxiliary/cfg_inner_static.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/auxiliary/cfg_inner_static.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/auxiliary/cfg_inner_static.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// this used to just ICE on compiling -pub fn foo() { - if cfg!(foo) { - static a: isize = 3; - a - } else { 3 }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/auxiliary/crate-attributes-using-cfg_attr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/auxiliary/crate-attributes-using-cfg_attr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/auxiliary/crate-attributes-using-cfg_attr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/auxiliary/crate-attributes-using-cfg_attr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic -// compile-flags: --cfg foo - -#![cfg_attr(foo, crate_type="lib")] - -pub fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-attr-cfg.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-attr-cfg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-attr-cfg.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-attr-cfg.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// main is conditionally compiled, but the conditional compilation -// is conditional too! - -// pretty-expanded FIXME #23616 - -#[cfg_attr(foo, cfg(bar))] -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-attr-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-attr-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-attr-crate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-attr-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// https://github.com/rust-lang/rust/issues/21833#issuecomment-72353044 - -// pretty-expanded FIXME #23616 - -#![cfg_attr(not_used, no_core)] - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg_attr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg_attr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg_attr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg_attr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags:--cfg set1 --cfg set2 -#![allow(dead_code)] -use std::fmt::Debug; - -struct NotDebugable; - -#[cfg_attr(set1, derive(Debug))] -struct Set1; - -#[cfg_attr(notset, derive(Debug))] -struct Notset(NotDebugable); - -#[cfg_attr(not(notset), derive(Debug))] -struct NotNotset; - -#[cfg_attr(not(set1), derive(Debug))] -struct NotSet1(NotDebugable); - -#[cfg_attr(all(set1, set2), derive(Debug))] -struct AllSet1Set2; - -#[cfg_attr(all(set1, notset), derive(Debug))] -struct AllSet1Notset(NotDebugable); - -#[cfg_attr(any(set1, notset), derive(Debug))] -struct AnySet1Notset; - -#[cfg_attr(any(notset, notset2), derive(Debug))] -struct AnyNotsetNotset2(NotDebugable); - -#[cfg_attr(all(not(notset), any(set1, notset)), derive(Debug))] -struct Complex; - -#[cfg_attr(any(notset, not(any(set1, notset))), derive(Debug))] -struct ComplexNot(NotDebugable); - -#[cfg_attr(any(target_endian = "little", target_endian = "big"), derive(Debug))] -struct KeyValue; - -fn is_show() {} - -fn main() { - is_show::(); - is_show::(); - is_show::(); - is_show::(); - is_show::(); - is_show::(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-family.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-family.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-family.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-family.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 -// ignore-cloudabi no target_family -// ignore-wasm32-bare no target_family - -#[cfg(windows)] -pub fn main() { -} - -#[cfg(unix)] -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-in-crate-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-in-crate-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-in-crate-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-in-crate-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: --cfg bar -D warnings -#![cfg(bar)] - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg_inner_static.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg_inner_static.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg_inner_static.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg_inner_static.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:cfg_inner_static.rs - -// pretty-expanded FIXME #23616 - -extern crate cfg_inner_static; - -pub fn main() { - cfg_inner_static::foo(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-macros-foo.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-macros-foo.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-macros-foo.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-macros-foo.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: --cfg foo - -// check that cfg correctly chooses between the macro impls (see also -// cfg-macros-notfoo.rs) - - -#[cfg(foo)] -#[macro_use] -mod foo { - macro_rules! bar { - () => { true } - } -} - -#[cfg(not(foo))] -#[macro_use] -mod foo { - macro_rules! bar { - () => { false } - } -} - -pub fn main() { - assert!(bar!()) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-macros-notfoo.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-macros-notfoo.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-macros-notfoo.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-macros-notfoo.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: - -// check that cfg correctly chooses between the macro impls (see also -// cfg-macros-foo.rs) - - -#[cfg(foo)] -#[macro_use] -mod foo { - macro_rules! bar { - () => { true } - } -} - -#[cfg(not(foo))] -#[macro_use] -mod foo { - macro_rules! bar { - () => { false } - } -} - -pub fn main() { - assert!(!bar!()) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-match-arm.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-match-arm.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-match-arm.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-match-arm.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -enum Foo { - Bar, - Baz, -} - -fn foo(f: Foo) { - match f { - Foo::Bar => {}, - #[cfg(not(asdfa))] - Foo::Baz => {}, - #[cfg(afsd)] - Basdfwe => {} - } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfgs-on-items.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfgs-on-items.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfgs-on-items.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfgs-on-items.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: --cfg fooA --cfg fooB - -// fooA AND !bar - -#[cfg(all(fooA, not(bar)))] -fn foo1() -> isize { 1 } - -// !fooA AND !bar -#[cfg(all(not(fooA), not(bar)))] -fn foo2() -> isize { 2 } - -// fooC OR (fooB AND !bar) -#[cfg(any(fooC, all(fooB, not(bar))))] -fn foo2() -> isize { 3 } - -// fooA AND bar -#[cfg(all(fooA, bar))] -fn foo3() -> isize { 2 } - -// !(fooA AND bar) -#[cfg(not(all(fooA, bar)))] -fn foo3() -> isize { 3 } - -pub fn main() { - assert_eq!(1, foo1()); - assert_eq!(3, foo2()); - assert_eq!(3, foo3()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg_stmt_expr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg_stmt_expr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg_stmt_expr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg_stmt_expr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![deny(non_snake_case)] -#![feature(stmt_expr_attributes)] - -fn main() { - let a = 413; - #[cfg(unset)] - let a = (); - assert_eq!(a, 413); - - let mut b = 612; - #[cfg(unset)] - { - b = 1111; - } - assert_eq!(b, 612); - - #[cfg(unset)] - undefined_fn(); - - #[cfg(unset)] - undefined_macro!(); - #[cfg(unset)] - undefined_macro![]; - #[cfg(unset)] - undefined_macro!{}; - - // pretty printer bug... - // #[cfg(unset)] - // undefined_macro!{} - - let () = (#[cfg(unset)] 341,); // Should this also work on parens? - let t = (1, #[cfg(unset)] 3, 4); - assert_eq!(t, (1, 4)); - - let f = |_: u32, _: u32| (); - f(2, 1, #[cfg(unset)] 6); - - let _: u32 = a.clone(#[cfg(unset)] undefined); - - let _: [(); 0] = [#[cfg(unset)] 126]; - let t = [#[cfg(unset)] 1, 2, 6]; - assert_eq!(t, [2, 6]); - - { - let r; - #[cfg(unset)] - (r = 5); - #[cfg(not(unset))] - (r = 10); - assert_eq!(r, 10); - } - - // check that macro expanded code works - - macro_rules! if_cfg { - ($cfg:meta $ib:block else $eb:block) => { - { - let r; - #[cfg($cfg)] - (r = $ib); - #[cfg(not($cfg))] - (r = $eb); - r - } - } - } - - let n = if_cfg!(unset { - 413 - } else { - 612 - }); - - assert_eq!((#[cfg(unset)] 1, #[cfg(not(unset))] 2), (2,)); - assert_eq!(n, 612); - - // check that lints work - - #[allow(non_snake_case)] - let FOOBAR = { - fn SYLADEX() {} - }; - - #[allow(non_snake_case)] - { - fn CRUXTRUDER() {} - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-target-family.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-target-family.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-target-family.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-target-family.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-cloudabi no target_family -// ignore-wasm32-bare no target_family - -// pretty-expanded FIXME #23616 - -#[cfg(target_family = "windows")] -pub fn main() { -} - -#[cfg(target_family = "unix")] -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-target-vendor.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-target-vendor.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-target-vendor.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/cfg-target-vendor.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(cfg_target_vendor)] - -#[cfg(target_vendor = "unknown")] -pub fn main() { -} - -#[cfg(not(target_vendor = "unknown"))] -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/conditional-compile-arch.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/conditional-compile-arch.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/conditional-compile-arch.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/conditional-compile-arch.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// Copyright 2012-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#[cfg(target_arch = "x86")] -pub fn main() { } - -#[cfg(target_arch = "x86_64")] -pub fn main() { } - -#[cfg(target_arch = "arm")] -pub fn main() { } - -#[cfg(target_arch = "aarch64")] -pub fn main() { } - -#[cfg(target_arch = "mips")] -pub fn main() { } - -#[cfg(target_arch = "mips64")] -pub fn main() { } - -#[cfg(target_arch = "powerpc")] -pub fn main() { } - -#[cfg(target_arch = "powerpc64")] -pub fn main() { } - -#[cfg(target_arch = "s390x")] -pub fn main() { } - -#[cfg(target_arch = "asmjs")] -pub fn main() { } - -#[cfg(target_arch = "wasm32")] -pub fn main() { } - -#[cfg(target_arch = "sparc64")] -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/conditional-compile.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/conditional-compile.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/conditional-compile.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/conditional-compile.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,158 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] -#![allow(non_camel_case_types)] -#![allow(improper_ctypes)] - -// Crate use statements - -#[cfg(bogus)] -use flippity; - -#[cfg(bogus)] -static b: bool = false; - -static b: bool = true; - -mod rustrt { - #[cfg(bogus)] - extern { - // This symbol doesn't exist and would be a link error if this - // module was codegened - pub fn bogus(); - } - - extern {} -} - -#[cfg(bogus)] -type t = isize; - -type t = bool; - -#[cfg(bogus)] -enum tg { foo, } - -enum tg { bar, } - -#[cfg(bogus)] -struct r { - i: isize, -} - -#[cfg(bogus)] -fn r(i:isize) -> r { - r { - i: i - } -} - -struct r { - i: isize, -} - -fn r(i:isize) -> r { - r { - i: i - } -} - -#[cfg(bogus)] -mod m { - // This needs to parse but would fail in typeck. Since it's not in - // the current config it should not be typechecked. - pub fn bogus() { return 0; } -} - -mod m { - // Submodules have slightly different code paths than the top-level - // module, so let's make sure this jazz works here as well - #[cfg(bogus)] - pub fn f() { } - - pub fn f() { } -} - -// Since the bogus configuration isn't defined main will just be -// parsed, but nothing further will be done with it -#[cfg(bogus)] -pub fn main() { panic!() } - -pub fn main() { - // Exercise some of the configured items in ways that wouldn't be possible - // if they had the bogus definition - assert!((b)); - let _x: t = true; - let _y: tg = tg::bar; - - test_in_fn_ctxt(); -} - -fn test_in_fn_ctxt() { - #[cfg(bogus)] - fn f() { panic!() } - fn f() { } - f(); - - #[cfg(bogus)] - static i: isize = 0; - static i: isize = 1; - assert_eq!(i, 1); -} - -mod test_foreign_items { - pub mod rustrt { - extern { - #[cfg(bogus)] - pub fn write() -> String; - pub fn write() -> String; - } - } -} - -mod test_use_statements { - #[cfg(bogus)] - use flippity_foo; -} - -mod test_methods { - struct Foo { - bar: usize - } - - impl Fooable for Foo { - #[cfg(bogus)] - fn what(&self) { } - - fn what(&self) { } - - #[cfg(bogus)] - fn the(&self) { } - - fn the(&self) { } - } - - trait Fooable { - #[cfg(bogus)] - fn what(&self); - - fn what(&self); - - #[cfg(bogus)] - fn the(&self); - - fn the(&self); - } -} - -#[cfg(any())] -mod nonexistent_file; // Check that unconfigured non-inline modules are not loaded or parsed. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/crate-attributes-using-cfg_attr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/crate-attributes-using-cfg_attr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cfg/crate-attributes-using-cfg_attr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cfg/crate-attributes-using-cfg_attr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:crate-attributes-using-cfg_attr.rs - -extern crate crate_attributes_using_cfg_attr; - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-expect-unsized.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-expect-unsized.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-expect-unsized.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-expect-unsized.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -use std::cell::RefCell; -use std::fmt::Debug; -use std::rc::Rc; - -// Check that coercions apply at the pointer level and don't cause -// rvalue expressions to be unsized. See #20169 for more information. - -pub fn main() { - let _: Box<[isize]> = Box::new({ [1, 2, 3] }); - let _: Box<[isize]> = Box::new(if true { [1, 2, 3] } else { [1, 3, 4] }); - let _: Box<[isize]> = Box::new(match true { true => [1, 2, 3], false => [1, 3, 4] }); - let _: Box _> = Box::new({ |x| (x as u8) }); - let _: Box = Box::new(if true { false } else { true }); - let _: Box = Box::new(match true { true => 'a', false => 'b' }); - - let _: &[isize] = &{ [1, 2, 3] }; - let _: &[isize] = &if true { [1, 2, 3] } else { [1, 3, 4] }; - let _: &[isize] = &match true { true => [1, 2, 3], false => [1, 3, 4] }; - let _: &Fn(isize) -> _ = &{ |x| (x as u8) }; - let _: &Debug = &if true { false } else { true }; - let _: &Debug = &match true { true => 'a', false => 'b' }; - - let _: &str = &{ String::new() }; - let _: &str = &if true { String::from("...") } else { 5.to_string() }; - let _: &str = &match true { - true => format!("{}", false), - false => ["x", "y"].join("+") - }; - - let _: Box<[isize]> = Box::new([1, 2, 3]); - let _: Box _> = Box::new(|x| (x as u8)); - - let _: Rc> = Rc::new(RefCell::new([1, 2, 3])); - let _: Rc _>> = Rc::new(RefCell::new(|x| (x as u8))); - - let _: Vec _>> = vec![ - Box::new(|x| (x as u8)), - Box::new(|x| (x as i16 as u8)), - ]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-overloaded-autoderef.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-overloaded-autoderef.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-overloaded-autoderef.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-overloaded-autoderef.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -use std::rc::Rc; - -// Examples from the "deref coercions" RFC, at rust-lang/rfcs#241. - -fn use_ref(_: &T) {} -fn use_mut(_: &mut T) {} - -fn use_rc(t: Rc) { - use_ref(&*t); // what you have to write today - use_ref(&t); // what you'd be able to write - use_ref(&&&&&&t); - use_ref(&mut &&&&&t); - use_ref(&&&mut &&&t); -} - -fn use_mut_box(mut t: &mut Box) { - use_mut(&mut *t); // what you have to write today - use_mut(t); // what you'd be able to write - use_mut(&mut &mut &mut t); - - use_ref(&*t); // what you have to write today - use_ref(t); // what you'd be able to write - use_ref(&&&&&&t); - use_ref(&mut &&&&&t); - use_ref(&&&mut &&&t); -} - -fn use_nested(t: &Box) { - use_ref(&**t); // what you have to write today - use_ref(t); // what you'd be able to write (note: recursive deref) - use_ref(&&&&&&t); - use_ref(&mut &&&&&t); - use_ref(&&&mut &&&t); -} - -fn use_slice(_: &[u8]) {} -fn use_slice_mut(_: &mut [u8]) {} - -fn use_vec(mut v: Vec) { - use_slice_mut(&mut v[..]); // what you have to write today - use_slice_mut(&mut v); // what you'd be able to write - use_slice_mut(&mut &mut &mut v); - - use_slice(&v[..]); // what you have to write today - use_slice(&v); // what you'd be able to write - use_slice(&&&&&&v); - use_slice(&mut &&&&&v); - use_slice(&&&mut &&&v); -} - -fn use_vec_ref(v: &Vec) { - use_slice(&v[..]); // what you have to write today - use_slice(v); // what you'd be able to write - use_slice(&&&&&&v); - use_slice(&mut &&&&&v); - use_slice(&&&mut &&&v); -} - -fn use_op_rhs(s: &mut String) { - *s += {&String::from(" ")}; -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-imm-ptr-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-imm-ptr-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-imm-ptr-arg.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-imm-ptr-arg.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn negate(x: &isize) -> isize { - -*x -} - -fn negate_mut(y: &mut isize) -> isize { - negate(y) -} - -fn negate_imm(y: &isize) -> isize { - negate(y) -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-imm-ptr-rcvr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-imm-ptr-rcvr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-imm-ptr-rcvr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-imm-ptr-rcvr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct SpeechMaker { - speeches: usize -} - -impl SpeechMaker { - pub fn how_many(&self) -> usize { self.speeches } -} - -fn foo(speaker: &SpeechMaker) -> usize { - speaker.how_many() + 33 -} - -pub fn main() { - let lincoln = SpeechMaker {speeches: 22}; - assert_eq!(foo(&lincoln), 55); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-imm-vec-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-imm-vec-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-imm-vec-arg.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-imm-vec-arg.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn sum(x: &[isize]) -> isize { - let mut sum = 0; - for y in x { sum += *y; } - return sum; -} - -fn sum_mut(y: &mut [isize]) -> isize { - sum(y) -} - -fn sum_imm(y: &[isize]) -> isize { - sum(y) -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-imm-vec-rcvr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-imm-vec-rcvr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-imm-vec-rcvr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-imm-vec-rcvr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -fn bar(v: &mut [usize]) -> Vec { - v.to_vec() -} - -fn bip(v: &[usize]) -> Vec { - v.to_vec() -} - -pub fn main() { - let mut the_vec = vec![1, 2, 3, 100]; - assert_eq!(the_vec.clone(), bar(&mut the_vec)); - assert_eq!(the_vec.clone(), bip(&the_vec)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-mut-ptr-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-mut-ptr-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-mut-ptr-arg.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-mut-ptr-arg.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -struct SpeechMaker { - speeches: usize -} - -fn talk(x: &mut SpeechMaker) { - x.speeches += 1; -} - -fn give_a_few_speeches(speaker: &mut SpeechMaker) { - - // Here speaker is reborrowed for each call, so we don't get errors - // about speaker being moved. - - talk(speaker); - talk(speaker); - talk(speaker); -} - -pub fn main() { - let mut lincoln = SpeechMaker {speeches: 22}; - give_a_few_speeches(&mut lincoln); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-mut-ptr-rcvr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-mut-ptr-rcvr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-mut-ptr-rcvr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-mut-ptr-rcvr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -struct SpeechMaker { - speeches: usize -} - -impl SpeechMaker { - pub fn talk(&mut self) { - self.speeches += 1; - } -} - -fn give_a_few_speeches(speaker: &mut SpeechMaker) { - - // Here speaker is reborrowed for each call, so we don't get errors - // about speaker being moved. - - speaker.talk(); - speaker.talk(); - speaker.talk(); -} - -pub fn main() { - let mut lincoln = SpeechMaker {speeches: 22}; - give_a_few_speeches(&mut lincoln); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-mut-vec-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-mut-vec-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-mut-vec-arg.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-mut-vec-arg.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -fn reverse(v: &mut [usize]) { - v.reverse(); -} - -fn bar(v: &mut [usize]) { - reverse(v); - reverse(v); - reverse(v); -} - -pub fn main() { - let mut the_vec = vec![1, 2, 3, 100]; - bar(&mut the_vec); - assert_eq!(the_vec, [100, 3, 2, 1]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-mut-vec-rcvr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-mut-vec-rcvr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-mut-vec-rcvr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-reborrow-mut-vec-rcvr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -fn bar(v: &mut [usize]) { - v.reverse(); - v.reverse(); - v.reverse(); -} - -pub fn main() { - let mut the_vec = vec![1, 2, 3, 100]; - bar(&mut the_vec); - assert_eq!(the_vec, [100, 3, 2, 1]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-unify-return.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-unify-return.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-unify-return.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-unify-return.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check that coercions unify the expected return type of a polymorphic -// function call, instead of leaving the type variables as they were. - -// pretty-expanded FIXME #23616 - -struct Foo; -impl Foo { - fn foo(self, x: T) -> Option { Some(x) } -} - -pub fn main() { - let _: Option = Some(main); - let _: Option = Foo.foo(main); - - // The same two cases, with implicit type variables made explicit. - let _: Option = Some::<_>(main); - let _: Option = Foo.foo::<_>(main); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-unify.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-unify.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-unify.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-unify.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check that coercions can unify if-else, match arms and array elements. - -// Try to construct if-else chains, matches and arrays out of given expressions. -macro_rules! check { - ($last:expr $(, $rest:expr)+) => { - // Last expression comes first because of whacky ifs and matches. - let _ = $(if false { $rest })else+ else { $last }; - - let _ = match 0 { $(_ if false => $rest,)+ _ => $last }; - - let _ = [$($rest,)+ $last]; - } -} - -// Check all non-uniform cases of 2 and 3 expressions of 2 types. -macro_rules! check2 { - ($a:expr, $b:expr) => { - check!($a, $b); - check!($b, $a); - - check!($a, $a, $b); - check!($a, $b, $a); - check!($a, $b, $b); - - check!($b, $a, $a); - check!($b, $a, $b); - check!($b, $b, $a); - } -} - -// Check all non-uniform cases of 2 and 3 expressions of 3 types. -macro_rules! check3 { - ($a:expr, $b:expr, $c:expr) => { - // Delegate to check2 for cases where a type repeats. - check2!($a, $b); - check2!($b, $c); - check2!($a, $c); - - // Check the remaining cases, i.e. permutations of ($a, $b, $c). - check!($a, $b, $c); - check!($a, $c, $b); - check!($b, $a, $c); - check!($b, $c, $a); - check!($c, $a, $b); - check!($c, $b, $a); - } -} - -use std::mem::size_of; - -fn foo() {} -fn bar() {} - -pub fn main() { - check3!(foo, bar, foo as fn()); - check3!(size_of::, size_of::, size_of:: as fn() -> usize); - - let s = String::from("bar"); - check2!("foo", &s); - - let a = [1, 2, 3]; - let v = vec![1, 2, 3]; - check2!(&a[..], &v); - - // Make sure in-array coercion still works. - let _ = [("a", Default::default()), (Default::default(), "b"), (&s, &s)]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-unsize-subtype.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-unsize-subtype.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-unsize-subtype.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coerce/coerce-unsize-subtype.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -use std::rc::Rc; - -fn lub_short<'a, T>(_: &[&'a T], _: &[&'a T]) {} - -// The two arguments are a subtype of their LUB, after coercion. -fn long_and_short<'a, T>(xs: &[&'static T; 1], ys: &[&'a T; 1]) { - lub_short(xs, ys); -} - -// The argument coerces to a subtype of the return type. -fn long_to_short<'a, 'b, T>(xs: &'b [&'static T; 1]) -> &'b [&'a T] { - xs -} - -// Rc is covariant over T just like &T. -fn long_to_short_rc<'a, T>(xs: Rc<[&'static T; 1]>) -> Rc<[&'a T]> { - xs -} - -// LUB-coercion (if-else/match/array) coerces `xs: &'b [&'static T: N]` -// to a subtype of the LUB of `xs` and `ys` (i.e. `&'b [&'a T]`), -// regardless of the order they appear (in if-else/match/array). -fn long_and_short_lub1<'a, 'b, T>(xs: &'b [&'static T; 1], ys: &'b [&'a T]) { - let _order1 = [xs, ys]; - let _order2 = [ys, xs]; -} - -// LUB-coercion should also have the exact same effect when `&'b [&'a T; N]` -// needs to be coerced, i.e. the resulting type is not &'b [&'static T], but -// rather the `&'b [&'a T]` LUB. -fn long_and_short_lub2<'a, 'b, T>(xs: &'b [&'static T], ys: &'b [&'a T; 1]) { - let _order1 = [xs, ys]; - let _order2 = [ys, xs]; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/auxiliary/coherence_copy_like_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/auxiliary/coherence_copy_like_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/auxiliary/coherence_copy_like_lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/auxiliary/coherence_copy_like_lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -#![feature(fundamental)] - -pub trait MyCopy { } -impl MyCopy for i32 { } - -pub struct MyStruct(T); - -#[fundamental] -pub struct MyFundamentalStruct(T); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/auxiliary/coherence_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/auxiliary/coherence_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/auxiliary/coherence_lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/auxiliary/coherence_lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] - -pub trait Remote { - fn foo(&self) { } -} - -pub trait Remote1 { - fn foo(&self, t: T) { } -} - -pub trait Remote2 { - fn foo(&self, t: T, u: U) { } -} - -pub struct Pair(T,U); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-bigint-int.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-bigint-int.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-bigint-int.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-bigint-int.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:coherence_lib.rs - -// pretty-expanded FIXME #23616 - -extern crate coherence_lib as lib; -use lib::Remote1; - -pub struct BigInt; - -impl Remote1 for isize { } - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-bigint-vecint.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-bigint-vecint.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-bigint-vecint.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-bigint-vecint.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:coherence_lib.rs - -// pretty-expanded FIXME #23616 - -extern crate coherence_lib as lib; -use lib::Remote1; - -pub struct BigInt; - -impl Remote1 for Vec { } - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-blanket.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-blanket.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-blanket.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-blanket.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:coherence_lib.rs - -// pretty-expanded FIXME #23616 - -extern crate coherence_lib as lib; -use lib::Remote1; - -pub trait Local { - fn foo(&self) { } -} - -impl Local for T { } - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence_copy_like.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence_copy_like.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence_copy_like.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence_copy_like.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we are able to introduce a negative constraint that -// `MyType: !MyTrait` along with other "fundamental" wrappers. - -// aux-build:coherence_copy_like_lib.rs - -extern crate coherence_copy_like_lib as lib; - -struct MyType { x: i32 } - -trait MyTrait { } -impl MyTrait for T { } -impl MyTrait for MyType { } -impl<'a> MyTrait for &'a MyType { } -impl MyTrait for Box { } -impl<'a> MyTrait for &'a Box { } - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-covered-type-parameter.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-covered-type-parameter.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-covered-type-parameter.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-covered-type-parameter.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:coherence_lib.rs - -// pretty-expanded FIXME #23616 - -extern crate coherence_lib as lib; -use lib::Remote; - -struct Foo(T); - -impl Remote for Foo { } - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-impl-in-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-impl-in-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-impl-in-fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-impl-in-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -pub fn main() { - #[derive(Copy, Clone)] - enum x { foo } - impl ::std::cmp::PartialEq for x { - fn eq(&self, other: &x) -> bool { - (*self) as isize == (*other) as isize - } - fn ne(&self, other: &x) -> bool { !(*self).eq(other) } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-iterator-vec-any-elem.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-iterator-vec-any-elem.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-iterator-vec-any-elem.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-iterator-vec-any-elem.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:coherence_lib.rs - -// pretty-expanded FIXME #23616 - -extern crate coherence_lib as lib; -use lib::Remote1; - -struct Foo(T); - -impl Remote1 for Foo { } - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-iterator-vec.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-iterator-vec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-iterator-vec.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-iterator-vec.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:coherence_lib.rs - -// pretty-expanded FIXME #23616 - -extern crate coherence_lib as lib; -use lib::Remote1; - -struct Foo(T); - -impl Remote1 for Foo { } - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-multidispatch-tuple.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-multidispatch-tuple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-multidispatch-tuple.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-multidispatch-tuple.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -use std::fmt::Debug; -use std::default::Default; - -// Test that an impl for homogeneous pairs does not conflict with a -// heterogeneous pair. - -trait MyTrait { - fn get(&self) -> usize; -} - -impl MyTrait for (T,T) { - fn get(&self) -> usize { 0 } -} - -impl MyTrait for (usize,isize) { - fn get(&self) -> usize { 0 } -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-negative-impls-safe.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-negative-impls-safe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-negative-impls-safe.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-negative-impls-safe.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(optin_builtin_traits)] - -use std::marker::Send; - -struct TestType; - -impl !Send for TestType {} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-rfc447-constrained.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-rfc447-constrained.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-rfc447-constrained.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-rfc447-constrained.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// check that trait matching can handle impls whose types are only -// constrained by a projection. - -trait IsU32 {} -impl IsU32 for u32 {} - -trait Mirror { type Image: ?Sized; } -impl Mirror for T { type Image = T; } - -trait Bar {} -impl, L: Mirror> Bar for V - where U::Image: IsU32 {} - -trait Foo { fn name() -> &'static str; } -impl Foo for u64 { fn name() -> &'static str { "u64" } } -impl Foo for T { fn name() -> &'static str { "Bar" }} - -fn main() { - assert_eq!(::name(), "u64"); - assert_eq!(::name(), "Bar"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-subtyping.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-subtyping.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-subtyping.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-subtyping.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that two distinct impls which match subtypes of one another -// yield coherence errors (or not) depending on the variance. - -trait Contravariant { - fn foo(&self) { } -} - -impl Contravariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 { -} - -impl Contravariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 { -} - -/////////////////////////////////////////////////////////////////////////// - -trait Covariant { - fn foo(&self) { } -} - -impl Covariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 { -} - -impl Covariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 { -} - -/////////////////////////////////////////////////////////////////////////// - -trait Invariant { - fn foo(&self) { } -} - -impl Invariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 { -} - -impl Invariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 { -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-where-clause.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-where-clause.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-where-clause.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/coherence/coherence-where-clause.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::fmt::Debug; -use std::default::Default; - -trait MyTrait { - fn get(&self) -> Self; -} - -impl MyTrait for T - where T : Default -{ - fn get(&self) -> T { - Default::default() - } -} - -#[derive(Clone, Copy, Debug, PartialEq)] -struct MyType { - dummy: usize -} - -impl MyTrait for MyType { - fn get(&self) -> MyType { (*self).clone() } -} - -fn test_eq(m: M, n: M) -where M : MyTrait + Debug + PartialEq -{ - assert_eq!(m.get(), n); -} - -pub fn main() { - test_eq(0_usize, 0_usize); - - let value = MyType { dummy: 256 + 22 }; - test_eq(value, value); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/auxiliary/anon-extern-mod-cross-crate-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/auxiliary/anon-extern-mod-cross-crate-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/auxiliary/anon-extern-mod-cross-crate-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/auxiliary/anon-extern-mod-cross-crate-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="anonexternmod"] -#![feature(libc)] - -extern crate libc; - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - pub fn rust_get_test_int() -> libc::intptr_t; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/auxiliary/cci_borrow_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/auxiliary/cci_borrow_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/auxiliary/cci_borrow_lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/auxiliary/cci_borrow_lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo(x: &usize) -> usize { - *x -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/auxiliary/cci_const_block.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/auxiliary/cci_const_block.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/auxiliary/cci_const_block.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/auxiliary/cci_const_block.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub static BLOCK_FN_DEF: fn(usize) -> usize = { - fn foo(a: usize) -> usize { - a + 10 - } - foo -}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/auxiliary/cci_const.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/auxiliary/cci_const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/auxiliary/cci_const.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/auxiliary/cci_const.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub extern fn bar() { -} - -pub const foopy: &'static str = "hi there"; -pub const uint_val: usize = 12; -pub const uint_expr: usize = (1 << uint_val) - 1; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/auxiliary/const_fn_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/auxiliary/const_fn_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/auxiliary/const_fn_lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/auxiliary/const_fn_lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Crate that exports a const fn. Used for testing cross-crate. - -#![crate_type="rlib"] -#![feature(min_const_fn)] - -pub const fn foo() -> usize { 22 } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-adt-align-mismatch.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-adt-align-mismatch.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-adt-align-mismatch.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-adt-align-mismatch.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(deprecated)] - -use std::mem; - -#[derive(PartialEq, Debug)] -enum Foo { - A(u32), - Bar([u16; 4]), - C -} - -// NOTE(eddyb) Don't make this a const, needs to be a static -// so it is always instantiated as a LLVM constant value. -static FOO: Foo = Foo::C; - -fn main() { - assert_eq!(FOO, Foo::C); - assert_eq!(mem::size_of::(), 12); - assert_eq!(mem::min_align_of::(), 4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-autoderef.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-autoderef.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-autoderef.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-autoderef.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -const A: [u8; 1] = ['h' as u8]; -const B: u8 = (&A)[0]; -const C: &'static &'static &'static &'static [u8; 1] = & & & &A; -const D: u8 = (&C)[0]; - -pub fn main() { - assert_eq!(B, A[0]); - assert_eq!(D, A[0]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-big-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-big-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-big-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-big-enum.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum Foo { - Bar(u32), - Baz, - Quux(u64, u16) -} - -static X: Foo = Foo::Baz; - -pub fn main() { - match X { - Foo::Baz => {} - _ => panic!() - } - match Y { - Foo::Bar(s) => assert_eq!(s, 2654435769), - _ => panic!() - } - match Z { - Foo::Quux(d,h) => { - assert_eq!(d, 0x123456789abcdef0); - assert_eq!(h, 0x1234); - } - _ => panic!() - } -} - -static Y: Foo = Foo::Bar(2654435769); -static Z: Foo = Foo::Quux(0x123456789abcdef0, 0x1234); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-binops.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-binops.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-binops.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-binops.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,136 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -macro_rules! assert_approx_eq { - ($a:expr, $b:expr) => ({ - let (a, b) = (&$a, &$b); - assert!((*a - *b).abs() < 1.0e-6, - "{} is not approximately equal to {}", *a, *b); - }) -} - -static A: isize = -4 + 3; -static A2: usize = 3 + 3; -static B: f64 = 3.0 + 2.7; - -static C: isize = 3 - 4; -static D: usize = 3 - 3; -static E: f64 = 3.0 - 2.7; - -static E2: isize = -3 * 3; -static F: usize = 3 * 3; -static G: f64 = 3.3 * 3.3; - -static H: isize = 3 / -1; -static I: usize = 3 / 3; -static J: f64 = 3.3 / 3.3; - -static N: bool = true && false; - -static O: bool = true || false; - -static P: isize = 3 & 1; -static Q: usize = 1 & 3; - -static R: isize = 3 | 1; -static S: usize = 1 | 3; - -static T: isize = 3 ^ 1; -static U: usize = 1 ^ 3; - -static V: isize = 1 << 3; - -// NOTE: better shr coverage -static W: isize = 1024 >> 4; -static X: usize = 1024 >> 4; - -static Y: bool = 1 == 1; -static Z: bool = 1.0f64 == 1.0; - -static AA: bool = 1 <= 2; -static AB: bool = -1 <= 2; -static AC: bool = 1.0f64 <= 2.0; - -static AD: bool = 1 < 2; -static AE: bool = -1 < 2; -static AF: bool = 1.0f64 < 2.0; - -static AG: bool = 1 != 2; -static AH: bool = -1 != 2; -static AI: bool = 1.0f64 != 2.0; - -static AJ: bool = 2 >= 1; -static AK: bool = 2 >= -2; -static AL: bool = 1.0f64 >= -2.0; - -static AM: bool = 2 > 1; -static AN: bool = 2 > -2; -static AO: bool = 1.0f64 > -2.0; - -pub fn main() { - assert_eq!(A, -1); - assert_eq!(A2, 6); - assert_approx_eq!(B, 5.7); - - assert_eq!(C, -1); - assert_eq!(D, 0); - assert_approx_eq!(E, 0.3); - - assert_eq!(E2, -9); - assert_eq!(F, 9); - assert_approx_eq!(G, 10.89); - - assert_eq!(H, -3); - assert_eq!(I, 1); - assert_approx_eq!(J, 1.0); - - assert_eq!(N, false); - - assert_eq!(O, true); - - assert_eq!(P, 1); - assert_eq!(Q, 1); - - assert_eq!(R, 3); - assert_eq!(S, 3); - - assert_eq!(T, 2); - assert_eq!(U, 2); - - assert_eq!(V, 8); - - assert_eq!(W, 64); - assert_eq!(X, 64); - - assert_eq!(Y, true); - assert_eq!(Z, true); - - assert_eq!(AA, true); - assert_eq!(AB, true); - assert_eq!(AC, true); - - assert_eq!(AD, true); - assert_eq!(AE, true); - assert_eq!(AF, true); - - assert_eq!(AG, true); - assert_eq!(AH, true); - assert_eq!(AI, true); - - assert_eq!(AJ, true); - assert_eq!(AK, true); - assert_eq!(AL, true); - - assert_eq!(AM, true); - assert_eq!(AN, true); - assert_eq!(AO, true); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-bitshift-rhs-inference.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-bitshift-rhs-inference.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-bitshift-rhs-inference.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-bitshift-rhs-inference.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -const RHS: u8 = 8; -const IRHS: i8 = 8; -const RHS16: u16 = 8; -const IRHS16: i16 = 8; -const RHS32: u32 = 8; -const IRHS32: i32 = 8; -const RHS64: u64 = 8; -const IRHS64: i64 = 8; -const RHSUS: usize = 8; -const IRHSIS: isize = 8; - -fn main() { - let _: [&'static str; 1 << RHS] = [""; 256]; - let _: [&'static str; 1 << IRHS] = [""; 256]; - let _: [&'static str; 1 << RHS16] = [""; 256]; - let _: [&'static str; 1 << IRHS16] = [""; 256]; - let _: [&'static str; 1 << RHS32] = [""; 256]; - let _: [&'static str; 1 << IRHS32] = [""; 256]; - let _: [&'static str; 1 << RHS64] = [""; 256]; - let _: [&'static str; 1 << IRHS64] = [""; 256]; - let _: [&'static str; 1 << RHSUS] = [""; 256]; - let _: [&'static str; 1 << IRHSIS] = [""; 256]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-block-cross-crate-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-block-cross-crate-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-block-cross-crate-fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-block-cross-crate-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:cci_const_block.rs - - -extern crate cci_const_block; - -pub fn main() { - assert_eq!(cci_const_block::BLOCK_FN_DEF(390), 400); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-block-item-macro-codegen.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-block-item-macro-codegen.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-block-item-macro-codegen.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-block-item-macro-codegen.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// General test that function items in static blocks -// can be generated with a macro. - - -struct MyType { - desc: &'static str, - data: usize, - code: fn(usize, usize) -> usize -} - -impl MyType { - fn eval(&self, a: usize) -> usize { - (self.code)(self.data, a) - } -} - -macro_rules! codegen { - ($e:expr, $v:expr) => { - { - fn generated(a: usize, b: usize) -> usize { - a - ($e * b) - } - MyType { - desc: "test", - data: $v, - code: generated - } - } - } -} - -static GENERATED_CODE_1: MyType = codegen!(2, 100); -static GENERATED_CODE_2: MyType = codegen!(5, 1000); - -pub fn main() { - assert_eq!(GENERATED_CODE_1.eval(10), 80); - assert_eq!(GENERATED_CODE_2.eval(100), 500); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-block-item.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-block-item.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-block-item.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-block-item.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -mod foo { - pub trait Value { - fn value(&self) -> usize; - } -} - -static BLOCK_USE: usize = { - use foo::Value; - 100 -}; - -static BLOCK_STRUCT_DEF: usize = { - struct Foo { - a: usize - } - Foo{ a: 300 }.a -}; - -static BLOCK_FN_DEF: fn(usize) -> usize = { - fn foo(a: usize) -> usize { - a + 10 - } - foo -}; - -static BLOCK_MACRO_RULES: usize = { - macro_rules! baz { - () => (412) - } - baz!() -}; - -pub fn main() { - assert_eq!(BLOCK_USE, 100); - assert_eq!(BLOCK_STRUCT_DEF, 300); - assert_eq!(BLOCK_FN_DEF(390), 400); - assert_eq!(BLOCK_MACRO_RULES, 412); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-block.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-block.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-block.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-block.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![allow(dead_code)] -#![allow(unused_unsafe)] - -use std::marker::Sync; - -struct Foo { - a: usize, - b: *const () -} - -unsafe impl Sync for Foo {} - -fn foo(a: T) -> T { - a -} - -static BLOCK_INTEGRAL: usize = { 1 }; -static BLOCK_EXPLICIT_UNIT: () = { () }; -static BLOCK_IMPLICIT_UNIT: () = { }; -static BLOCK_FLOAT: f64 = { 1.0 }; -static BLOCK_ENUM: Option = { Some(100) }; -static BLOCK_STRUCT: Foo = { Foo { a: 12, b: 0 as *const () } }; -static BLOCK_UNSAFE: usize = unsafe { 1000 }; - -static BLOCK_FN_INFERRED: fn(usize) -> usize = { foo }; - -static BLOCK_FN: fn(usize) -> usize = { foo:: }; - -static BLOCK_ENUM_CONSTRUCTOR: fn(usize) -> Option = { Some }; - -pub fn main() { - assert_eq!(BLOCK_INTEGRAL, 1); - assert_eq!(BLOCK_EXPLICIT_UNIT, ()); - assert_eq!(BLOCK_IMPLICIT_UNIT, ()); - assert_eq!(BLOCK_FLOAT, 1.0_f64); - assert_eq!(BLOCK_STRUCT.a, 12); - assert_eq!(BLOCK_STRUCT.b, 0 as *const ()); - assert_eq!(BLOCK_ENUM, Some(100)); - assert_eq!(BLOCK_UNSAFE, 1000); - assert_eq!(BLOCK_FN_INFERRED(300), 300); - assert_eq!(BLOCK_FN(300), 300); - assert_eq!(BLOCK_ENUM_CONSTRUCTOR(200), Some(200)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-bound.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-bound.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Make sure const bounds work on things, and test that a few types -// are const. - -// pretty-expanded FIXME #23616 - -fn foo(x: T) -> T { x } - -struct F { field: isize } - -pub fn main() { - /*foo(1); - foo("hi".to_string()); - foo(vec![1, 2, 3]); - foo(F{field: 42}); - foo((1, 2)); - foo(@1);*/ - foo(Box::new(1)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-byte-str-cast.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-byte-str-cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-byte-str-cast.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-byte-str-cast.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[deny(warnings)] - -pub fn main() { - let _ = b"x" as &[u8]; - let _ = b"y" as &[u8; 1]; - let _ = b"z" as *const u8; - let _ = "ä" as *const str; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-cast-ptr-int.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-cast-ptr-int.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-cast-ptr-int.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-cast-ptr-int.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -use std::ptr; - -struct TestStruct { - x: *const u8 -} - -unsafe impl Sync for TestStruct {} - -static a: TestStruct = TestStruct{x: 0 as *const u8}; - -pub fn main() { - assert_eq!(a.x, ptr::null()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-cast.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-cast.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-cast.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -struct TestStruct { - x: *const u8, -} - -unsafe impl Sync for TestStruct {} - -extern fn foo() {} -const x: extern "C" fn() = foo; -static y: TestStruct = TestStruct { x: x as *const u8 }; - -pub fn main() { - assert_eq!(x as *const u8, y.x); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-const.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-const.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-const.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -const a: isize = 1; -const b: isize = a + 2; - -pub fn main() { - assert_eq!(b, 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-contents.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-contents.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-contents.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-contents.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #570 -#![allow(non_upper_case_globals)] - -static lsl : isize = 1 << 2; -static add : isize = 1 + 2; -static addf : f64 = 1.0 + 2.0; -static not : isize = !0; -static notb : bool = !true; -static neg : isize = -(1); - -pub fn main() { - assert_eq!(lsl, 4); - assert_eq!(add, 3); - assert_eq!(addf, 3.0); - assert_eq!(not, -1); - assert_eq!(notb, false); - assert_eq!(neg, -1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-cross-crate-const.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-cross-crate-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-cross-crate-const.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-cross-crate-const.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:cci_const.rs -#![allow(non_upper_case_globals)] - -extern crate cci_const; -static foo: &'static str = cci_const::foopy; -static a: usize = cci_const::uint_val; -static b: usize = cci_const::uint_expr + 5; - -pub fn main() { - assert_eq!(a, 12); - let foo2 = a; - assert_eq!(foo2, cci_const::uint_val); - assert_eq!(b, cci_const::uint_expr + 5); - assert_eq!(foo, cci_const::foopy); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-cross-crate-extern.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-cross-crate-extern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-cross-crate-extern.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-cross-crate-extern.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:cci_const.rs -#![allow(non_upper_case_globals)] - -extern crate cci_const; -use cci_const::bar; -static foo: extern "C" fn() = bar; - -pub fn main() { - assert!(foo == bar); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-deref.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-deref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-deref.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-deref.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -const C: &'static isize = &1000; -static D: isize = *C; - -pub fn main() { - assert_eq!(D, 1000); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-endianess.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-endianess.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-endianess.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-endianess.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(const_int_ops)] -#![feature(test)] - -extern crate test; -use test::black_box as b; - -const BE_U32: u32 = 55u32.to_be(); -const LE_U32: u32 = 55u32.to_le(); - - -fn main() { - assert_eq!(BE_U32, b(55u32).to_be()); - assert_eq!(LE_U32, b(55u32).to_le()); - - #[cfg(not(target_arch = "asmjs"))] - { - const BE_U128: u128 = 999999u128.to_be(); - const LE_I128: i128 = (-999999i128).to_le(); - assert_eq!(BE_U128, b(999999u128).to_be()); - assert_eq!(LE_I128, b(-999999i128).to_le()); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-byref.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-byref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-byref.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-byref.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum E { V, VV(isize) } -static C: E = E::V; - -fn f(a: &E) { - match *a { - E::V => {} - E::VV(..) => panic!() - } -} - -pub fn main() { - f(&C) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-byref-self.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-byref-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-byref-self.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-byref-self.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum E { V, VV(isize) } -static C: E = E::V; - -impl E { - pub fn method(&self) { - match *self { - E::V => {} - E::VV(..) => panic!() - } - } -} - -pub fn main() { - C.method() -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-cast.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-cast.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-cast.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -enum A { A1, A2 } -enum B { B1=0, B2=2 } - -pub fn main () { - static c1: isize = A::A2 as isize; - static c2: isize = B::B2 as isize; - let a1 = A::A2 as isize; - let a2 = B::B2 as isize; - assert_eq!(c1, 1); - assert_eq!(c2, 2); - assert_eq!(a1, 1); - assert_eq!(a2, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-ptr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-ptr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-ptr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-ptr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum E { V0, V1(isize) } -static C: &'static E = &E::V0; - -pub fn main() { - match *C { - E::V0 => (), - _ => panic!() - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-struct2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-struct2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-struct2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-struct2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum E { V0, V16(u16) } -struct S { a: E, b: u16, c: u16 } -static C: S = S { a: E::V0, b: 0x600D, c: 0xBAD }; - -pub fn main() { - let n = C.b; - assert!(n != 0xBAD); - assert_eq!(n, 0x600D); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-structlike.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-structlike.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-structlike.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-structlike.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum E { - S0 { s: String }, - S1 { u: usize } -} - -static C: E = E::S1 { u: 23 }; - -pub fn main() { - match C { - E::S0 { .. } => panic!(), - E::S1 { u } => assert_eq!(u, 23) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum E { V16(u16), V32(u32) } -struct S { a: E, b: u16, c: u16 } -static C: S = S { a: E::V16(0xDEAD), b: 0x600D, c: 0xBAD }; - -pub fn main() { - let n = C.b; - assert!(n != 0xBAD); - assert_eq!(n, 0x600D); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-tuple2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-tuple2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-tuple2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-tuple2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum E { V0, V16(u16) } -static C: (E, u16, u16) = (E::V0, 0x600D, 0xBAD); - -pub fn main() { - let (_, n, _) = C; - assert!(n != 0xBAD); - assert_eq!(n, 0x600D); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-tuple.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-tuple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-tuple.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-tuple.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum E { V16(u16), V32(u32) } -static C: (E, u16, u16) = (E::V16(0xDEAD), 0x600D, 0xBAD); - -pub fn main() { - let (_, n, _) = C; - assert!(n != 0xBAD); - assert_eq!(n, 0x600D); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-tuplestruct2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-tuplestruct2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-tuplestruct2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-tuplestruct2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum E { V0, V16(u16) } -struct S(E, u16, u16); -static C: S = S(E::V0, 0x600D, 0xBAD); - -pub fn main() { - let S(_, n, _) = C; - assert!(n != 0xBAD); - assert_eq!(n, 0x600D); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-tuplestruct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-tuplestruct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-tuplestruct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-tuplestruct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum E { V16(u16), V32(u32) } -struct S(E, u16, u16); -static C: S = S(E::V16(0xDEAD), 0x600D, 0xBAD); - -pub fn main() { - let S(_, n, _) = C; - assert!(n != 0xBAD); - assert_eq!(n, 0x600D); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-vec-index.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-vec-index.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-vec-index.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-vec-index.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Copy, Clone)] -enum E { V1(isize), V0 } - -const C: &'static [E] = &[E::V0, E::V1(0xDEADBEE)]; -static C0: E = C[0]; -static C1: E = C[1]; -const D: &'static [E; 2] = &[E::V0, E::V1(0xDEAFBEE)]; -static D0: E = D[0]; -static D1: E = D[1]; - -pub fn main() { - match C0 { - E::V0 => (), - _ => panic!() - } - match C1 { - E::V1(n) => assert_eq!(n, 0xDEADBEE), - _ => panic!() - } - - match D0 { - E::V0 => (), - _ => panic!() - } - match D1 { - E::V1(n) => assert_eq!(n, 0xDEAFBEE), - _ => panic!() - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-vec-ptr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-vec-ptr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-vec-ptr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-vec-ptr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum E { V1(isize), V0 } -static C: &'static [E] = &[E::V0, E::V1(0xDEADBEE), E::V0]; - -pub fn main() { - match C[1] { - E::V1(n) => assert_eq!(n, 0xDEADBEE), - _ => panic!() - } - match C[2] { - E::V0 => (), - _ => panic!() - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-vector.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-vector.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-vector.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-enum-vector.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum E { V1(isize), V0 } -static C: [E; 3] = [E::V0, E::V1(0xDEADBEE), E::V0]; - -pub fn main() { - match C[1] { - E::V1(n) => assert_eq!(n, 0xDEADBEE), - _ => panic!() - } - match C[2] { - E::V0 => (), - _ => panic!() - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-err.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-err.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-err.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-err.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// check for const_err regressions - -#![deny(const_err)] - -const X: *const u8 = b"" as _; -const Y: bool = 'A' == 'B'; -const Z: char = 'A'; -const W: bool = Z <= 'B'; - - -fn main() { - let _ = ((-1 as i8) << 8 - 1) as f32; - let _ = 0u8 as char; - let _ = true > false; - let _ = true >= false; - let _ = true < false; - let _ = true >= false; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-expr-in-fixed-length-vec.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-expr-in-fixed-length-vec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-expr-in-fixed-length-vec.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-expr-in-fixed-length-vec.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check that constant expressions can be used for declaring the -// type of a fixed length vector. - -// pretty-expanded FIXME #23616 - -pub fn main() { - - const FOO: usize = 2; - let _v: [isize; FOO*3]; - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-expr-in-vec-repeat.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-expr-in-vec-repeat.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-expr-in-vec-repeat.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-expr-in-vec-repeat.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check that constant expressions can be used in vec repeat syntax. - -// pretty-expanded FIXME #23616 - -pub fn main() { - - const FOO: usize = 2; - let _v = [0; FOO*3*2/2]; - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-extern-function.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-extern-function.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-extern-function.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-extern-function.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -extern fn foopy() {} - -static f: extern "C" fn() = foopy; -static s: S = S { f: foopy }; - -struct S { - f: extern "C" fn() -} - -pub fn main() { - assert!(foopy as extern "C" fn() == f); - assert!(f == s.f); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fields-and-indexing.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fields-and-indexing.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fields-and-indexing.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fields-and-indexing.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -const x : [isize; 4] = [1,2,3,4]; -static p : isize = x[2]; -const y : &'static [isize] = &[1,2,3,4]; -static q : isize = y[2]; - -struct S {a: isize, b: isize} - -const s : S = S {a: 10, b: 20}; -static t : isize = s.b; - -struct K {a: isize, b: isize, c: D} -struct D { d: isize, e: isize } - -const k : K = K {a: 10, b: 20, c: D {d: 30, e: 40}}; -static m : isize = k.c.e; - -pub fn main() { - println!("{}", p); - println!("{}", q); - println!("{}", t); - assert_eq!(p, 3); - assert_eq!(q, 3); - assert_eq!(t, 20); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-const-eval.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-const-eval.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-const-eval.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-const-eval.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(min_const_fn)] - -const fn add(x: usize, y: usize) -> usize { - x + y -} - -const ARR: [i32; add(1, 2)] = [5, 6, 7]; - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-feature-flags.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-feature-flags.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-feature-flags.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-feature-flags.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test use of stabilized const fns in std formerly using individual feature gates. - -use std::cell::Cell; - -const CELL: Cell = Cell::new(42); - -fn main() { - let v = CELL.get(); - CELL.set(v+1); - - assert_eq!(CELL.get(), v); -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-method.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-method.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-method.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(min_const_fn)] - -struct Foo { value: u32 } - -impl Foo { - const fn new() -> Foo { - Foo { value: 22 } - } -} - -const FOO: Foo = Foo::new(); - -pub fn main() { - assert_eq!(FOO.value, 22); - let _: [&'static str; Foo::new().value as usize] = ["hey"; 22]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-nested.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-nested.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-nested.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-nested.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test a call whose argument is the result of another call. - -#![feature(min_const_fn)] - -const fn sub(x: u32, y: u32) -> u32 { - x - y -} - -const X: u32 = sub(sub(88, 44), 22); - -fn main() { - assert_eq!(X, 22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -// A very basic test of const fn functionality. - -#![feature(const_fn, const_indexing)] - -const fn add(x: u32, y: u32) -> u32 { - x + y -} - -const fn sub(x: u32, y: u32) -> u32 { - x - y -} - -const unsafe fn div(x: u32, y: u32) -> u32 { - x / y -} - -const fn generic(t: T) -> T { - t -} - -const fn generic_arr(t: [T; 1]) -> T { - t[0] -} - -const SUM: u32 = add(44, 22); -const DIFF: u32 = sub(44, 22); -const DIV: u32 = unsafe{div(44, 22)}; - -fn main() { - assert_eq!(SUM, 66); - assert!(SUM != 88); - - assert_eq!(DIFF, 22); - assert_eq!(DIV, 2); - - let _: [&'static str; sub(100, 99) as usize] = ["hi"]; - let _: [&'static str; generic(1)] = ["hi"]; - let _: [&'static str; generic_arr([1])] = ["hi"]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-stability-calls.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-stability-calls.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-stability-calls.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-stability-calls.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test use of const fn from another crate without a feature gate. - -// aux-build:const_fn_lib.rs - -extern crate const_fn_lib; - -use const_fn_lib::foo; - -static FOO: usize = foo(); -const BAR: usize = foo(); - -macro_rules! constant { - ($n:ident: $t:ty = $v:expr) => { - const $n: $t = $v; - } -} - -constant! { - BAZ: usize = foo() -} - -fn main() { - let x: [usize; foo()] = [42; foo()]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-val.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-val.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-val.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-fn-val.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] -#![allow(overflowing_literals)] - -fn foo() -> isize { - return 0xca7f000d; -} - -struct Bar where F: FnMut() -> isize { f: F } - -static mut b : Bar isize> = Bar { f: foo as fn() -> isize}; - -pub fn main() { - unsafe { assert_eq!((b.f)(), 0xca7f000d); } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-index-feature-gate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-index-feature-gate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-index-feature-gate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-index-feature-gate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -const ARR: [usize; 1] = [2]; -const ARR2: [i32; ARR[0]] = [5, 6]; - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-meth-pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-meth-pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-meth-pattern.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-meth-pattern.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(min_const_fn)] - -struct A; - -impl A { - const fn banana() -> bool { - true - } -} - -const ABANANA: bool = A::banana(); - -fn main() { - match true { - ABANANA => {}, - _ => panic!("what?") - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-negation.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-negation.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-negation.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-negation.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(overflowing_literals)] - -#[deny(const_err)] - -fn main() { - #[cfg(target_pointer_width = "32")] - const I: isize = -2147483648isize; - #[cfg(target_pointer_width = "64")] - const I: isize = -9223372036854775808isize; - assert_eq!(::std::i32::MIN as u64, 0xffffffff80000000); - assert_eq!(-2147483648isize as u64, 0xffffffff80000000); - assert_eq!(-2147483648i32 as u64, 0xffffffff80000000); - assert_eq!(::std::i64::MIN as u64, 0x8000000000000000); - #[cfg(target_pointer_width = "64")] - assert_eq!(-9223372036854775808isize as u64, 0x8000000000000000); - #[cfg(target_pointer_width = "32")] - assert_eq!(-9223372036854775808isize as u64, 0); - assert_eq!(-9223372036854775808i32 as u64, 0); - const J: usize = ::std::i32::MAX as usize; - const K: usize = -1i32 as u32 as usize; - const L: usize = ::std::i32::MIN as usize; - const M: usize = ::std::i64::MIN as usize; - match 5 { - J => {}, - K => {}, - L => {}, - M => {}, - _ => {} - } - match 5 { - I => {}, - _ => {} - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-negative.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-negative.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-negative.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-negative.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #358 -#![allow(non_upper_case_globals)] - -static toplevel_mod: isize = -1; - -pub fn main() { - assert_eq!(toplevel_mod, -1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-nullary-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-nullary-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-nullary-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-nullary-enum.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum Foo { - Bar, - Baz, - Boo, -} - -static X: Foo = Foo::Bar; - -pub fn main() { - match X { - Foo::Bar => {} - Foo::Baz | Foo::Boo => panic!() - } - match Y { - Foo::Baz => {} - Foo::Bar | Foo::Boo => panic!() - } -} - -static Y: Foo = Foo::Baz; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-nullary-univariant-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-nullary-univariant-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-nullary-univariant-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-nullary-univariant-enum.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#[derive(Copy, Clone)] -enum Foo { - Bar = 0xDEADBEE -} - -static X: Foo = Foo::Bar; - -pub fn main() { - assert_eq!((X as usize), 0xDEADBEE); - assert_eq!((Y as usize), 0xDEADBEE); -} - -static Y: Foo = Foo::Bar; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-pattern-variant.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-pattern-variant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-pattern-variant.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-pattern-variant.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(min_const_fn)] - -#[derive(PartialEq, Eq)] -enum Cake { - BlackForest, - Marmor, -} -use Cake::*; - -const BOO: (Cake, Cake) = (Marmor, BlackForest); -const FOO: Cake = BOO.1; - -const fn foo() -> Cake { - Marmor -} - -const WORKS: Cake = Marmor; - -const GOO: Cake = foo(); - -fn main() { - match BlackForest { - FOO => println!("hi"), - GOO => println!("meh"), - WORKS => println!("möp"), - _ => println!("bye"), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-rec-and-tup.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-rec-and-tup.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-rec-and-tup.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-rec-and-tup.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] -#![allow(overflowing_literals)] - -struct Pair { a: f64, b: f64 } - -struct AnotherPair { x: (i64, i64), y: Pair } - -static x : (i32,i32) = (0xfeedf00dd,0xca11ab1e); -static y : AnotherPair = AnotherPair{ x: (0xf0f0f0f0_f0f0f0f0, - 0xabababab_abababab), - y: Pair { a: 3.14159265358979323846, - b: 2.7182818284590452354 }}; - -pub fn main() { - let (p, _) = y.x; - assert_eq!(p, - 1085102592571150096); - println!("{:#x}", p); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-region-ptrs-noncopy.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-region-ptrs-noncopy.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-region-ptrs-noncopy.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-region-ptrs-noncopy.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -type Big = [u64; 8]; -struct Pair<'a> { a: isize, b: &'a Big } -const x: &'static Big = &([13, 14, 10, 13, 11, 14, 14, 15]); -const y: &'static Pair<'static> = &Pair {a: 15, b: x}; - -pub fn main() { - assert_eq!(x as *const Big, y.b as *const Big); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-region-ptrs.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-region-ptrs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-region-ptrs.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-region-ptrs.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -struct Pair<'a> { a: isize, b: &'a isize } - -const x: &'static isize = &10; - -const y: &'static Pair<'static> = &Pair {a: 15, b: x}; - -pub fn main() { - println!("x = {}", *x); - println!("y = {{a: {}, b: {}}}", y.a, *(y.b)); - assert_eq!(*x, 10); - assert_eq!(*(y.b), 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-repeated-values.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-repeated-values.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-repeated-values.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-repeated-values.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -const FOO: isize = 42; - -enum Bar { - Boo = *[&FOO; 4][3], -} - -fn main() { - assert_eq!(Bar::Boo as isize, 42); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -static i: isize = 10; - -pub fn main() { println!("{}", i); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/consts-in-patterns.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/consts-in-patterns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/consts-in-patterns.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/consts-in-patterns.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(min_const_fn)] - -const FOO: isize = 10; -const BAR: isize = 3; - -const fn foo() -> isize { 4 } -const BOO: isize = foo(); - -pub fn main() { - let x: isize = 3; - let y = match x { - FOO => 1, - BAR => 2, - BOO => 4, - _ => 3 - }; - assert_eq!(y, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-size_of-align_of.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-size_of-align_of.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-size_of-align_of.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-size_of-align_of.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(min_const_fn)] - -use std::mem; - -// Get around the limitations of CTFE in today's Rust. -const fn choice_u64(c: bool, a: u64, b: u64) -> u64 { - (-(c as i64) as u64) & a | (-(!c as i64) as u64) & b -} - -const fn max_usize(a: usize, b: usize) -> usize { - choice_u64(a > b, a as u64, b as u64) as usize -} - -const fn align_to(size: usize, align: usize) -> usize { - (size + (align - 1)) & !(align - 1) -} - -const fn packed_union_size_of() -> usize { - max_usize(mem::size_of::(), mem::size_of::()) -} - -const fn union_align_of() -> usize { - max_usize(mem::align_of::(), mem::align_of::()) -} - -const fn union_size_of() -> usize { - align_to(packed_union_size_of::(), union_align_of::()) -} - -macro_rules! fake_union { - ($name:ident { $a:ty, $b:ty }) => ( - struct $name { - _align: ([$a; 0], [$b; 0]), - _bytes: [u8; union_size_of::<$a, $b>()] - } - ) -} - -// Check that we can (poorly) emulate unions by -// calling size_of and align_of at compile-time. -fake_union!(U { u16, [u8; 3] }); - -fn test(u: U) { - assert_eq!(mem::size_of_val(&u._bytes), 4); -} - -fn main() { - assert_eq!(mem::size_of::(), 4); - assert_eq!(mem::align_of::(), 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-str-ptr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-str-ptr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-str-ptr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-str-ptr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::{str, string}; - -const A: [u8; 2] = ['h' as u8, 'i' as u8]; -const B: &'static [u8; 2] = &A; -const C: *const u8 = B as *const u8; - -pub fn main() { - unsafe { - let foo = &A as *const u8; - assert_eq!(foo, C); - assert_eq!(str::from_utf8_unchecked(&A), "hi"); - assert_eq!(*C, A[0]); - assert_eq!(*(&B[0] as *const u8), A[0]); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-struct-offsets.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-struct-offsets.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-struct-offsets.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-struct-offsets.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 -#![allow(non_upper_case_globals)] - -enum Foo { - IntVal(i32), - Int64Val(i64) -} - -struct Bar { - i: i32, - v: Foo -} - -static bar: Bar = Bar { i: 0, v: Foo::IntVal(0) }; - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -#![allow(non_upper_case_globals)] - -use std::cmp; - -#[derive(Debug)] -struct foo { a: isize, b: isize, c: isize } - -impl cmp::PartialEq for foo { - fn eq(&self, other: &foo) -> bool { - (*self).a == (*other).a && - (*self).b == (*other).b && - (*self).c == (*other).c - } - fn ne(&self, other: &foo) -> bool { !(*self).eq(other) } -} - -const x : foo = foo { a:1, b:2, c: 3 }; -const y : foo = foo { b:2, c:3, a: 1 }; -const z : &'static foo = &foo { a: 10, b: 22, c: 12 }; -const w : foo = foo { a:5, ..x }; - -pub fn main() { - assert_eq!(x.b, 2); - assert_eq!(x, y); - assert_eq!(z.b, 22); - assert_eq!(w.a, 5); - assert_eq!(w.c, 3); - println!("{:#x}", x.b); - println!("{:#x}", z.c); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-trait-to-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-trait-to-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-trait-to-trait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-trait-to-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #24644 - block causes a &Trait -> &Trait coercion: -trait Trait {} - -struct Bar; -impl Trait for Bar {} - -fn main() { - let x: &[&Trait] = &[{ &Bar }]; -} - -// Issue #25748 - the cast causes an &Encoding -> &Encoding coercion: -pub struct UTF8Encoding; -pub const UTF_8: &'static UTF8Encoding = &UTF8Encoding; -pub trait Encoding {} -impl Encoding for UTF8Encoding {} -pub fn f() -> &'static Encoding { UTF_8 as &'static Encoding } - -// Root of the problem: &Trait -> &Trait coercions: -const FOO: &'static Trait = &Bar; -const BAR: &'static Trait = FOO; -fn foo() { let _x = BAR; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-tuple-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-tuple-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-tuple-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-tuple-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct Bar(isize, isize); - -static X: Bar = Bar(1, 2); - -pub fn main() { - match X { - Bar(x, y) => { - assert_eq!(x, 1); - assert_eq!(y, 2); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-typeid-of.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-typeid-of.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-typeid-of.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-typeid-of.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(core_intrinsics)] -#![feature(const_type_id)] - -use std::any::TypeId; - -struct A; - -static ID_ISIZE: TypeId = TypeId::of::(); - -pub fn main() { - assert_eq!(ID_ISIZE, TypeId::of::()); - - // sanity test of TypeId - const T: (TypeId, TypeId, TypeId) = (TypeId::of::(), - TypeId::of::<&'static str>(), - TypeId::of::()); - let (d, e, f) = (TypeId::of::(), TypeId::of::<&'static str>(), - TypeId::of::()); - - 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:: A) -> A>(), - TypeId::of:: A, A) -> A>()); - - assert!(F.0 != F.1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-unit-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-unit-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-unit-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-unit-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -struct Foo; - -static X: Foo = Foo; - -pub fn main() { - match X { - Foo => {} - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-unsafe-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-unsafe-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-unsafe-fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-unsafe-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// A quick test of 'unsafe const fn' functionality - -#![feature(min_const_fn)] - -const unsafe fn dummy(v: u32) -> u32 { - !v -} - -struct Type; -impl Type { - const unsafe fn new() -> Type { - Type - } -} - -const VAL: u32 = unsafe { dummy(0xFFFF) }; -const TYPE_INST: Type = unsafe { Type::new() }; - -fn main() { - assert_eq!(VAL, 0xFFFF0000); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-vec-of-fns.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-vec-of-fns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-vec-of-fns.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-vec-of-fns.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 -#![allow(non_upper_case_globals)] - -/*! - * Try to double-check that static fns have the right size (with or - * without dummy env ptr, as appropriate) by iterating a size-2 array. - * If the static size differs from the runtime size, the second element - * should be read as a null or otherwise wrong pointer and crash. - */ - -fn f() { } -static bare_fns: &'static [fn()] = &[f, f]; -struct S(F); -static mut closures: &'static mut [S] = &mut [S(f as fn()), S(f as fn())]; - -pub fn main() { - unsafe { - for &bare_fn in bare_fns { bare_fn() } - for closure in &mut *closures { - let S(ref mut closure) = *closure; - (*closure)() - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-vecs-and-slices.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-vecs-and-slices.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-vecs-and-slices.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-vecs-and-slices.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -static x : [isize; 4] = [1,2,3,4]; -static y : &'static [isize] = &[1,2,3,4]; -static z : &'static [isize; 4] = &[1,2,3,4]; -static zz : &'static [isize] = &[1,2,3,4]; - -pub fn main() { - println!("{}", x[1]); - println!("{}", y[1]); - println!("{}", z[1]); - println!("{}", zz[1]); - assert_eq!(x[1], 2); - assert_eq!(x[3], 4); - assert_eq!(x[3], y[3]); - assert_eq!(z[1], 2); - assert_eq!(z[3], 4); - assert_eq!(z[3], y[3]); - assert_eq!(zz[1], 2); - assert_eq!(zz[3], 4); - assert_eq!(zz[3], y[3]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-vec-syntax.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-vec-syntax.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-vec-syntax.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/consts/const-vec-syntax.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn f(_: &[isize]) {} - -pub fn main() { - let v = [ 1, 2, 3 ]; - f(&v); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/anon-extern-mod-cross-crate-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/anon-extern-mod-cross-crate-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/anon-extern-mod-cross-crate-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/anon-extern-mod-cross-crate-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:anon-extern-mod-cross-crate-1.rs -// pretty-expanded FIXME #23616 -// ignore-wasm32-bare no libc to test ffi with - -extern crate anonexternmod; - -use anonexternmod::rust_get_test_int; - -pub fn main() { - unsafe { - rust_get_test_int(); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="anonexternmod"] -#![feature(libc)] - -extern crate libc; - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - pub fn rust_get_test_int() -> libc::intptr_t; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/anon_trait_static_method_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/anon_trait_static_method_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/anon_trait_static_method_lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/anon_trait_static_method_lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct Foo { - pub x: isize -} - -impl Foo { - pub fn new() -> Foo { - Foo { x: 3 } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_borrow_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_borrow_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_borrow_lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_borrow_lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo(x: &usize) -> usize { - *x -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_capture_clause.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_capture_clause.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_capture_clause.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_capture_clause.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::thread; -use std::sync::mpsc::{Receiver, channel}; - -pub fn foo(x: T) -> Receiver { - let (tx, rx) = channel(); - thread::spawn(move|| { - tx.send(x.clone()); - }); - rx -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_const.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_const.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_const.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub extern fn bar() { -} - -pub const foopy: &'static str = "hi there"; -pub const uint_val: usize = 12; -pub const uint_expr: usize = (1 << uint_val) - 1; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_impl_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_impl_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_impl_lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_impl_lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="cci_impl_lib"] - -pub trait uint_helpers { - fn to(&self, v: usize, f: F) where F: FnMut(usize); -} - -impl uint_helpers for usize { - #[inline] - fn to(&self, v: usize, mut f: F) where F: FnMut(usize) { - let mut i = *self; - while i < v { - f(i); - i += 1; - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_iter_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_iter_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_iter_lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_iter_lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="cci_iter_lib"] - -#[inline] -pub fn iter(v: &[T], mut f: F) where F: FnMut(&T) { - let mut i = 0; - let n = v.len(); - while i < n { - f(&v[i]); - i += 1; - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_nested_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_nested_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_nested_lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_nested_lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax)] - -use std::cell::RefCell; - -pub struct Entry { - key: A, - value: B -} - -pub struct alist { - eq_fn: extern "Rust" fn(A,A) -> bool, - data: Box>>>, -} - -pub fn alist_add(lst: &alist, k: A, v: B) { - let mut data = lst.data.borrow_mut(); - (*data).push(Entry{key:k, value:v}); -} - -pub fn alist_get( - lst: &alist, - k: A) - -> B { - let eq_fn = lst.eq_fn; - let data = lst.data.borrow(); - for entry in &(*data) { - if eq_fn(entry.key.clone(), k.clone()) { - return entry.value.clone(); - } - } - panic!(); -} - -#[inline] -pub fn new_int_alist() -> alist { - fn eq_int(a: isize, b: isize) -> bool { a == b } - return alist { - eq_fn: eq_int, - data: box RefCell::new(Vec::new()), - }; -} - -#[inline] -pub fn new_int_alist_2() -> alist { - #[inline] - fn eq_int(a: isize, b: isize) -> bool { a == b } - return alist { - eq_fn: eq_int, - data: box RefCell::new(Vec::new()), - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_no_inline_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_no_inline_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_no_inline_lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/cci_no_inline_lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="cci_no_inline_lib"] - - -// same as cci_iter_lib, more-or-less, but not marked inline -pub fn iter(v: Vec , mut f: F) where F: FnMut(usize) { - let mut i = 0; - let n = v.len(); - while i < n { - f(v[i]); - i += 1; - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/moves_based_on_type_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/moves_based_on_type_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/moves_based_on_type_lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/moves_based_on_type_lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] - -pub struct S { - x: isize, -} - -impl Drop for S { - fn drop(&mut self) { - println!("goodbye"); - } -} - -pub fn f() { - let x = S { x: 1 }; - let y = x; - let _z = y; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/newtype_struct_xc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/newtype_struct_xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/newtype_struct_xc.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/newtype_struct_xc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] - -pub struct Au(pub isize); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/pub_static_array.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/pub_static_array.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/pub_static_array.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/pub_static_array.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub static ARRAY: [u8; 1] = [1]; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/reexported_static_methods.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/reexported_static_methods.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/reexported_static_methods.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/reexported_static_methods.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub use sub_foo::Foo; -pub use self::Bar as Baz; -pub use sub_foo::Boz; -pub use sub_foo::Bort; - -pub trait Bar { - fn bar() -> Self; -} - -impl Bar for isize { - fn bar() -> isize { 84 } -} - -pub mod sub_foo { - pub trait Foo { - fn foo() -> Self; - } - - impl Foo for isize { - fn foo() -> isize { 42 } - } - - pub struct Boz { - unused_str: String - } - - impl Boz { - pub fn boz(i: isize) -> bool { - i > 0 - } - } - - pub enum Bort { - Bort1, - Bort2 - } - - impl Bort { - pub fn bort() -> String { - "bort()".to_string() - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate_address_insignificant.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate_address_insignificant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate_address_insignificant.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate_address_insignificant.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo() -> isize { - static a: isize = 3; - a -} - -pub fn bar() -> isize { - foo::() -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate_associated_type_defaults.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate_associated_type_defaults.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate_associated_type_defaults.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate_associated_type_defaults.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(associated_type_defaults)] - -pub trait Foo { - type Out: Default + ToString = T; -} - -impl Foo for () { -} - -impl Foo for () { - type Out = bool; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate_generic_fn_nested_return.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate_generic_fn_nested_return.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate_generic_fn_nested_return.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate_generic_fn_nested_return.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct Request { - pub id: String, - pub arg: String, -} - -pub fn decode() -> Result { - (|| { - Ok(Request { - id: "hi".to_owned(), - arg: match Err(()) { - Ok(v) => v, - Err(e) => return Err(e) - }, - }) - })() -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate_static_addresses.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate_static_addresses.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate_static_addresses.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate_static_addresses.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub static global: isize = 3; - -static global0: isize = 4; - -pub static global2: &'static isize = &global0; - -pub fn verify_same(a: &'static isize) { - let a = a as *const isize as usize; - let b = &global as *const isize as usize; - assert_eq!(a, b); -} - -pub fn verify_same2(a: &'static isize) { - let a = a as *const isize as usize; - let b = global2 as *const isize as usize; - assert_eq!(a, b); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate-trait-lifetime-param.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate-trait-lifetime-param.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate-trait-lifetime-param.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate-trait-lifetime-param.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub trait FromBuf<'a> { - fn from_buf(_: &'a [u8]) -> Self; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate_unit_struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate_unit_struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate_unit_struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/auxiliary/xcrate_unit_struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -// used by the rpass test - -#[derive(Copy, Clone)] -pub struct Struct; - -#[derive(Copy, Clone)] -pub enum Unit { - UnitVariant, - Argument(Struct) -} - -#[derive(Copy, Clone)] -pub struct TupleStruct(pub usize, pub &'static str); - -// used by the cfail test - -#[derive(Copy, Clone)] -pub struct StructWithFields { - foo: isize, -} - -#[derive(Copy, Clone)] -pub enum EnumWithVariants { - EnumVariant, - EnumVariantArg(isize) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_borrow.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_borrow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_borrow.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_borrow.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:cci_borrow_lib.rs - -#![feature(box_syntax)] - -extern crate cci_borrow_lib; -use cci_borrow_lib::foo; - -pub fn main() { - let p: Box<_> = box 22; - let r = foo(&*p); - println!("r={}", r); - assert_eq!(r, 22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_capture_clause.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_capture_clause.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_capture_clause.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_capture_clause.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:cci_capture_clause.rs - -// This test makes sure we can do cross-crate inlining on functions -// that use capture clauses. - -// pretty-expanded FIXME #23616 -// ignore-emscripten no threads support - -extern crate cci_capture_clause; - -pub fn main() { - cci_capture_clause::foo(()).recv().unwrap(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_impl_exe.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_impl_exe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_impl_exe.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_impl_exe.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:cci_impl_lib.rs - -extern crate cci_impl_lib; -use cci_impl_lib::uint_helpers; - -pub fn main() { - //let bt0 = sys::frame_address(); - //println!("%?", bt0); - - 3.to(10, |i| { - println!("{}", i); - - //let bt1 = sys::frame_address(); - //println!("%?", bt1); - //assert_eq!(bt0, bt1); - }) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_iter_exe.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_iter_exe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_iter_exe.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_iter_exe.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:cci_iter_lib.rs - -extern crate cci_iter_lib; - -pub fn main() { - //let bt0 = sys::rusti::frame_address(1); - //println!("%?", bt0); - cci_iter_lib::iter(&[1, 2, 3], |i| { - println!("{}", *i); - //assert_eq!(bt0, sys::rusti::frame_address(2)); - }) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_nested_exe.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_nested_exe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_nested_exe.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_nested_exe.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:cci_nested_lib.rs - - -extern crate cci_nested_lib; -use cci_nested_lib::*; - -pub fn main() { - let lst = new_int_alist(); - alist_add(&lst, 22, "hi".to_string()); - alist_add(&lst, 44, "ho".to_string()); - assert_eq!(alist_get(&lst, 22), "hi".to_string()); - assert_eq!(alist_get(&lst, 44), "ho".to_string()); - - let lst = new_int_alist_2(); - alist_add(&lst, 22, "hi".to_string()); - alist_add(&lst, 44, "ho".to_string()); - assert_eq!(alist_get(&lst, 22), "hi".to_string()); - assert_eq!(alist_get(&lst, 44), "ho".to_string()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_no_inline_exe.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_no_inline_exe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_no_inline_exe.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cci_no_inline_exe.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:cci_no_inline_lib.rs - -extern crate cci_no_inline_lib; -use cci_no_inline_lib::iter; - -pub fn main() { - // Check that a cross-crate call function not marked as inline - // does not, in fact, get inlined. Also, perhaps more - // importantly, checks that our scheme of using - // sys::frame_address() to determine if we are inlining is - // actually working. - //let bt0 = sys::frame_address(); - //println!("%?", bt0); - iter(vec![1, 2, 3], |i| { - println!("{}", i); - - //let bt1 = sys::frame_address(); - //println!("%?", bt1); - - //assert!(bt0 != bt1); - }) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cross-crate-const-pat.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cross-crate-const-pat.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cross-crate-const-pat.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cross-crate-const-pat.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:cci_const.rs - -// pretty-expanded FIXME #23616 - -extern crate cci_const; - -pub fn main() { - let x = cci_const::uint_val; - match x { - cci_const::uint_val => {} - _ => {} - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cross-crate-newtype-struct-pat.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cross-crate-newtype-struct-pat.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cross-crate-newtype-struct-pat.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/cross-crate-newtype-struct-pat.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:newtype_struct_xc.rs - - -extern crate newtype_struct_xc; - -pub fn main() { - let x = newtype_struct_xc::Au(21); - match x { - newtype_struct_xc::Au(n) => assert_eq!(n, 21) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/moves-based-on-type-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/moves-based-on-type-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/moves-based-on-type-cross-crate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/moves-based-on-type-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:moves_based_on_type_lib.rs - -// pretty-expanded FIXME #23616 - -extern crate moves_based_on_type_lib; -use moves_based_on_type_lib::f; - -pub fn main() { - f(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/reexported-static-methods-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/reexported-static-methods-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/reexported-static-methods-cross-crate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/reexported-static-methods-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:reexported_static_methods.rs - -extern crate reexported_static_methods; - -use reexported_static_methods::Foo; -use reexported_static_methods::Baz; -use reexported_static_methods::Boz; -use reexported_static_methods::Bort; - -pub fn main() { - assert_eq!(42_isize, Foo::foo()); - assert_eq!(84_isize, Baz::bar()); - assert!(Boz::boz(1)); - assert_eq!("bort()".to_string(), Bort::bort()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/static-array-across-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/static-array-across-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/static-array-across-crate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/static-array-across-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:pub_static_array.rs - -extern crate pub_static_array as array; - -use array::ARRAY; - -static X: &'static u8 = &ARRAY[0]; -static Y: &'static u8 = &(&ARRAY)[0]; -static Z: u8 = (&ARRAY)[0]; - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate-address-insignificant.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate-address-insignificant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate-address-insignificant.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate-address-insignificant.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:xcrate_address_insignificant.rs - - -extern crate xcrate_address_insignificant as foo; - -pub fn main() { - assert_eq!(foo::foo::(), foo::bar()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate-associated-type-defaults.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate-associated-type-defaults.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate-associated-type-defaults.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate-associated-type-defaults.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:xcrate_associated_type_defaults.rs - -extern crate xcrate_associated_type_defaults; -use xcrate_associated_type_defaults::Foo; - -struct LocalDefault; -impl Foo for LocalDefault {} - -struct LocalOverride; -impl Foo for LocalOverride { - type Out = bool; -} - -fn main() { - assert_eq!( - <() as Foo>::Out::default().to_string(), - "0"); - assert_eq!( - <() as Foo>::Out::default().to_string(), - "false"); - - assert_eq!( - >::Out::default().to_string(), - "0"); - assert_eq!( - >::Out::default().to_string(), - "false"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate_generic_fn_nested_return.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate_generic_fn_nested_return.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate_generic_fn_nested_return.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate_generic_fn_nested_return.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:xcrate_generic_fn_nested_return.rs - -extern crate xcrate_generic_fn_nested_return as test; - -pub fn main() { - assert!(test::decode::<()>().is_err()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate-static-addresses.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate-static-addresses.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate-static-addresses.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate-static-addresses.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:xcrate_static_addresses.rs - -// pretty-expanded FIXME #23616 - -extern crate xcrate_static_addresses; - -use xcrate_static_addresses as other; - -pub fn main() { - other::verify_same(&other::global); - other::verify_same2(other::global2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate-trait-lifetime-param.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate-trait-lifetime-param.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate-trait-lifetime-param.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate-trait-lifetime-param.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:xcrate-trait-lifetime-param.rs - -// pretty-expanded FIXME #23616 - -extern crate xcrate_trait_lifetime_param as other; - -struct Reader<'a> { - b : &'a [u8] -} - -impl <'a> other::FromBuf<'a> for Reader<'a> { - fn from_buf(b : &'a [u8]) -> Reader<'a> { - Reader { b : b } - } -} - -pub fn main () {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate-unit-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate-unit-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate-unit-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/cross-crate/xcrate-unit-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:xcrate_unit_struct.rs -// pretty-expanded FIXME #23616 -#![allow(non_upper_case_globals)] - -extern crate xcrate_unit_struct; - -const s1: xcrate_unit_struct::Struct = xcrate_unit_struct::Struct; -static s2: xcrate_unit_struct::Unit = xcrate_unit_struct::Unit::UnitVariant; -static s3: xcrate_unit_struct::Unit = - xcrate_unit_struct::Unit::Argument(xcrate_unit_struct::Struct); -static s4: xcrate_unit_struct::Unit = xcrate_unit_struct::Unit::Argument(s1); -static s5: xcrate_unit_struct::TupleStruct = xcrate_unit_struct::TupleStruct(20, "foo"); - -fn f1(_: xcrate_unit_struct::Struct) {} -fn f2(_: xcrate_unit_struct::Unit) {} -fn f3(_: xcrate_unit_struct::TupleStruct) {} - -pub fn main() { - f1(xcrate_unit_struct::Struct); - f2(xcrate_unit_struct::Unit::UnitVariant); - f2(xcrate_unit_struct::Unit::Argument(xcrate_unit_struct::Struct)); - f3(xcrate_unit_struct::TupleStruct(10, "bar")); - - f1(s1); - f2(s2); - f2(s3); - f2(s4); - f3(s5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/assoc-const.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/assoc-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/assoc-const.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/assoc-const.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait Nat { - const VALUE: usize; -} - -struct Zero; -struct Succ(N); - -impl Nat for Zero { - const VALUE: usize = 0; -} - -impl Nat for Succ { - const VALUE: usize = N::VALUE + 1; -} - -fn main() { - let x: [i32; >>>>::VALUE] = [1, 2, 3, 4]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/bswap-const.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/bswap-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/bswap-const.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/bswap-const.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(core_intrinsics)] - -use std::intrinsics; - -const SWAPPED_U8: u8 = unsafe { intrinsics::bswap(0x12_u8) }; -const SWAPPED_U16: u16 = unsafe { intrinsics::bswap(0x12_34_u16) }; -const SWAPPED_I32: i32 = unsafe { intrinsics::bswap(0x12_34_56_78_i32) }; - -fn main() { - assert_eq!(SWAPPED_U8, 0x12); - assert_eq!(SWAPPED_U16, 0x34_12); - assert_eq!(SWAPPED_I32, 0x78_56_34_12); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/chained-constants-stackoverflow.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/chained-constants-stackoverflow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/chained-constants-stackoverflow.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/chained-constants-stackoverflow.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,366 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// https://github.com/rust-lang/rust/issues/34997 - -pub const CST_1: u32 = 0; -pub const CST_2: u32 = CST_1+1; -pub const CST_3: u32 = CST_2+1; -pub const CST_4: u32 = CST_3+1; -pub const CST_5: u32 = CST_4+1; -pub const CST_6: u32 = CST_5+1; -pub const CST_7: u32 = CST_6+1; -pub const CST_8: u32 = CST_7+1; -pub const CST_9: u32 = CST_8+1; -pub const CST_10: u32 = CST_9+1; -pub const CST_11: u32 = CST_10+1; -pub const CST_12: u32 = CST_11+1; -pub const CST_13: u32 = CST_12+1; -pub const CST_14: u32 = CST_13+1; -pub const CST_15: u32 = CST_14+1; -pub const CST_16: u32 = CST_15+1; -pub const CST_17: u32 = CST_16+1; -pub const CST_18: u32 = CST_17+1; -pub const CST_19: u32 = CST_18+1; -pub const CST_20: u32 = CST_19+1; -pub const CST_21: u32 = CST_20+1; -pub const CST_22: u32 = CST_21+1; -pub const CST_23: u32 = CST_22+1; -pub const CST_24: u32 = CST_23+1; -pub const CST_25: u32 = CST_24+1; -pub const CST_26: u32 = CST_25+1; -pub const CST_27: u32 = CST_26+1; -pub const CST_28: u32 = CST_27+1; -pub const CST_29: u32 = CST_28+1; -pub const CST_30: u32 = CST_29+1; -pub const CST_31: u32 = CST_30+1; -pub const CST_32: u32 = CST_31+1; -pub const CST_33: u32 = CST_32+1; -pub const CST_34: u32 = CST_33+1; -pub const CST_35: u32 = CST_34+1; -pub const CST_36: u32 = CST_35+1; -pub const CST_37: u32 = CST_36+1; -pub const CST_38: u32 = CST_37+1; -pub const CST_39: u32 = CST_38+1; -pub const CST_40: u32 = CST_39+1; -pub const CST_41: u32 = CST_40+1; -pub const CST_42: u32 = CST_41+1; -pub const CST_43: u32 = CST_42+1; -pub const CST_44: u32 = CST_43+1; -pub const CST_45: u32 = CST_44+1; -pub const CST_46: u32 = CST_45+1; -pub const CST_47: u32 = CST_46+1; -pub const CST_48: u32 = CST_47+1; -pub const CST_49: u32 = CST_48+1; -pub const CST_50: u32 = CST_49+1; -pub const CST_51: u32 = CST_50+1; -pub const CST_52: u32 = CST_51+1; -pub const CST_53: u32 = CST_52+1; -pub const CST_54: u32 = CST_53+1; -pub const CST_55: u32 = CST_54+1; -pub const CST_56: u32 = CST_55+1; -pub const CST_57: u32 = CST_56+1; -pub const CST_58: u32 = CST_57+1; -pub const CST_59: u32 = CST_58+1; -pub const CST_60: u32 = CST_59+1; -pub const CST_61: u32 = CST_60+1; -pub const CST_62: u32 = CST_61+1; -pub const CST_63: u32 = CST_62+1; -pub const CST_64: u32 = CST_63+1; -pub const CST_65: u32 = CST_64+1; -pub const CST_66: u32 = CST_65+1; -pub const CST_67: u32 = CST_66+1; -pub const CST_68: u32 = CST_67+1; -pub const CST_69: u32 = CST_68+1; -pub const CST_70: u32 = CST_69+1; -pub const CST_71: u32 = CST_70+1; -pub const CST_72: u32 = CST_71+1; -pub const CST_73: u32 = CST_72+1; -pub const CST_74: u32 = CST_73+1; -pub const CST_75: u32 = CST_74+1; -pub const CST_76: u32 = CST_75+1; -pub const CST_77: u32 = CST_76+1; -pub const CST_78: u32 = CST_77+1; -pub const CST_79: u32 = CST_78+1; -pub const CST_80: u32 = CST_79+1; -pub const CST_81: u32 = CST_80+1; -pub const CST_82: u32 = CST_81+1; -pub const CST_83: u32 = CST_82+1; -pub const CST_84: u32 = CST_83+1; -pub const CST_85: u32 = CST_84+1; -pub const CST_86: u32 = CST_85+1; -pub const CST_87: u32 = CST_86+1; -pub const CST_88: u32 = CST_87+1; -pub const CST_89: u32 = CST_88+1; -pub const CST_90: u32 = CST_89+1; -pub const CST_91: u32 = CST_90+1; -pub const CST_92: u32 = CST_91+1; -pub const CST_93: u32 = CST_92+1; -pub const CST_94: u32 = CST_93+1; -pub const CST_95: u32 = CST_94+1; -pub const CST_96: u32 = CST_95+1; -pub const CST_97: u32 = CST_96+1; -pub const CST_98: u32 = CST_97+1; -pub const CST_99: u32 = CST_98+1; -pub const CST_100: u32 = CST_99+1; -pub const CST_101: u32 = CST_100+1; -pub const CST_102: u32 = CST_101+1; -pub const CST_103: u32 = CST_102+1; -pub const CST_104: u32 = CST_103+1; -pub const CST_105: u32 = CST_104+1; -pub const CST_106: u32 = CST_105+1; -pub const CST_107: u32 = CST_106+1; -pub const CST_108: u32 = CST_107+1; -pub const CST_109: u32 = CST_108+1; -pub const CST_110: u32 = CST_109+1; -pub const CST_111: u32 = CST_110+1; -pub const CST_112: u32 = CST_111+1; -pub const CST_113: u32 = CST_112+1; -pub const CST_114: u32 = CST_113+1; -pub const CST_115: u32 = CST_114+1; -pub const CST_116: u32 = CST_115+1; -pub const CST_117: u32 = CST_116+1; -pub const CST_118: u32 = CST_117+1; -pub const CST_119: u32 = CST_118+1; -pub const CST_120: u32 = CST_119+1; -pub const CST_121: u32 = CST_120+1; -pub const CST_122: u32 = CST_121+1; -pub const CST_123: u32 = CST_122+1; -pub const CST_124: u32 = CST_123+1; -pub const CST_125: u32 = CST_124+1; -pub const CST_126: u32 = CST_125+1; -pub const CST_127: u32 = CST_126+1; -pub const CST_128: u32 = CST_127+1; -pub const CST_129: u32 = CST_128+1; -pub const CST_130: u32 = CST_129+1; -pub const CST_131: u32 = CST_130+1; -pub const CST_132: u32 = CST_131+1; -pub const CST_133: u32 = CST_132+1; -pub const CST_134: u32 = CST_133+1; -pub const CST_135: u32 = CST_134+1; -pub const CST_136: u32 = CST_135+1; -pub const CST_137: u32 = CST_136+1; -pub const CST_138: u32 = CST_137+1; -pub const CST_139: u32 = CST_138+1; -pub const CST_140: u32 = CST_139+1; -pub const CST_141: u32 = CST_140+1; -pub const CST_142: u32 = CST_141+1; -pub const CST_143: u32 = CST_142+1; -pub const CST_144: u32 = CST_143+1; -pub const CST_145: u32 = CST_144+1; -pub const CST_146: u32 = CST_145+1; -pub const CST_147: u32 = CST_146+1; -pub const CST_148: u32 = CST_147+1; -pub const CST_149: u32 = CST_148+1; -pub const CST_150: u32 = CST_149+1; -pub const CST_151: u32 = CST_150+1; -pub const CST_152: u32 = CST_151+1; -pub const CST_153: u32 = CST_152+1; -pub const CST_154: u32 = CST_153+1; -pub const CST_155: u32 = CST_154+1; -pub const CST_156: u32 = CST_155+1; -pub const CST_157: u32 = CST_156+1; -pub const CST_158: u32 = CST_157+1; -pub const CST_159: u32 = CST_158+1; -pub const CST_160: u32 = CST_159+1; -pub const CST_161: u32 = CST_160+1; -pub const CST_162: u32 = CST_161+1; -pub const CST_163: u32 = CST_162+1; -pub const CST_164: u32 = CST_163+1; -pub const CST_165: u32 = CST_164+1; -pub const CST_166: u32 = CST_165+1; -pub const CST_167: u32 = CST_166+1; -pub const CST_168: u32 = CST_167+1; -pub const CST_169: u32 = CST_168+1; -pub const CST_170: u32 = CST_169+1; -pub const CST_171: u32 = CST_170+1; -pub const CST_172: u32 = CST_171+1; -pub const CST_173: u32 = CST_172+1; -pub const CST_174: u32 = CST_173+1; -pub const CST_175: u32 = CST_174+1; -pub const CST_176: u32 = CST_175+1; -pub const CST_177: u32 = CST_176+1; -pub const CST_178: u32 = CST_177+1; -pub const CST_179: u32 = CST_178+1; -pub const CST_180: u32 = CST_179+1; -pub const CST_181: u32 = CST_180+1; -pub const CST_182: u32 = CST_181+1; -pub const CST_183: u32 = CST_182+1; -pub const CST_184: u32 = CST_183+1; -pub const CST_185: u32 = CST_184+1; -pub const CST_186: u32 = CST_185+1; -pub const CST_187: u32 = CST_186+1; -pub const CST_188: u32 = CST_187+1; -pub const CST_189: u32 = CST_188+1; -pub const CST_190: u32 = CST_189+1; -pub const CST_191: u32 = CST_190+1; -pub const CST_192: u32 = CST_191+1; -pub const CST_193: u32 = CST_192+1; -pub const CST_194: u32 = CST_193+1; -pub const CST_195: u32 = CST_194+1; -pub const CST_196: u32 = CST_195+1; -pub const CST_197: u32 = CST_196+1; -pub const CST_198: u32 = CST_197+1; -pub const CST_199: u32 = CST_198+1; -pub const CST_200: u32 = CST_199+1; -pub const CST_201: u32 = CST_200+1; -pub const CST_202: u32 = CST_201+1; -pub const CST_203: u32 = CST_202+1; -pub const CST_204: u32 = CST_203+1; -pub const CST_205: u32 = CST_204+1; -pub const CST_206: u32 = CST_205+1; -pub const CST_207: u32 = CST_206+1; -pub const CST_208: u32 = CST_207+1; -pub const CST_209: u32 = CST_208+1; -pub const CST_210: u32 = CST_209+1; -pub const CST_211: u32 = CST_210+1; -pub const CST_212: u32 = CST_211+1; -pub const CST_213: u32 = CST_212+1; -pub const CST_214: u32 = CST_213+1; -pub const CST_215: u32 = CST_214+1; -pub const CST_216: u32 = CST_215+1; -pub const CST_217: u32 = CST_216+1; -pub const CST_218: u32 = CST_217+1; -pub const CST_219: u32 = CST_218+1; -pub const CST_220: u32 = CST_219+1; -pub const CST_221: u32 = CST_220+1; -pub const CST_222: u32 = CST_221+1; -pub const CST_223: u32 = CST_222+1; -pub const CST_224: u32 = CST_223+1; -pub const CST_225: u32 = CST_224+1; -pub const CST_226: u32 = CST_225+1; -pub const CST_227: u32 = CST_226+1; -pub const CST_228: u32 = CST_227+1; -pub const CST_229: u32 = CST_228+1; -pub const CST_230: u32 = CST_229+1; -pub const CST_231: u32 = CST_230+1; -pub const CST_232: u32 = CST_231+1; -pub const CST_233: u32 = CST_232+1; -pub const CST_234: u32 = CST_233+1; -pub const CST_235: u32 = CST_234+1; -pub const CST_236: u32 = CST_235+1; -pub const CST_237: u32 = CST_236+1; -pub const CST_238: u32 = CST_237+1; -pub const CST_239: u32 = CST_238+1; -pub const CST_240: u32 = CST_239+1; -pub const CST_241: u32 = CST_240+1; -pub const CST_242: u32 = CST_241+1; -pub const CST_243: u32 = CST_242+1; -pub const CST_244: u32 = CST_243+1; -pub const CST_245: u32 = CST_244+1; -pub const CST_246: u32 = CST_245+1; -pub const CST_247: u32 = CST_246+1; -pub const CST_248: u32 = CST_247+1; -pub const CST_249: u32 = CST_248+1; -pub const CST_250: u32 = CST_249+1; -pub const CST_251: u32 = CST_250+1; -pub const CST_252: u32 = CST_251+1; -pub const CST_253: u32 = CST_252+1; -pub const CST_254: u32 = CST_253+1; -pub const CST_255: u32 = CST_254+1; -pub const CST_256: u32 = CST_255+1; -pub const CST_257: u32 = CST_256+1; -pub const CST_258: u32 = CST_257+1; -pub const CST_259: u32 = CST_258+1; -pub const CST_260: u32 = CST_259+1; -pub const CST_261: u32 = CST_260+1; -pub const CST_262: u32 = CST_261+1; -pub const CST_263: u32 = CST_262+1; -pub const CST_264: u32 = CST_263+1; -pub const CST_265: u32 = CST_264+1; -pub const CST_266: u32 = CST_265+1; -pub const CST_267: u32 = CST_266+1; -pub const CST_268: u32 = CST_267+1; -pub const CST_269: u32 = CST_268+1; -pub const CST_270: u32 = CST_269+1; -pub const CST_271: u32 = CST_270+1; -pub const CST_272: u32 = CST_271+1; -pub const CST_273: u32 = CST_272+1; -pub const CST_274: u32 = CST_273+1; -pub const CST_275: u32 = CST_274+1; -pub const CST_276: u32 = CST_275+1; -pub const CST_277: u32 = CST_276+1; -pub const CST_278: u32 = CST_277+1; -pub const CST_279: u32 = CST_278+1; -pub const CST_280: u32 = CST_279+1; -pub const CST_281: u32 = CST_280+1; -pub const CST_282: u32 = CST_281+1; -pub const CST_283: u32 = CST_282+1; -pub const CST_284: u32 = CST_283+1; -pub const CST_285: u32 = CST_284+1; -pub const CST_286: u32 = CST_285+1; -pub const CST_287: u32 = CST_286+1; -pub const CST_288: u32 = CST_287+1; -pub const CST_289: u32 = CST_288+1; -pub const CST_290: u32 = CST_289+1; -pub const CST_291: u32 = CST_290+1; -pub const CST_292: u32 = CST_291+1; -pub const CST_293: u32 = CST_292+1; -pub const CST_294: u32 = CST_293+1; -pub const CST_295: u32 = CST_294+1; -pub const CST_296: u32 = CST_295+1; -pub const CST_297: u32 = CST_296+1; -pub const CST_298: u32 = CST_297+1; -pub const CST_299: u32 = CST_298+1; -pub const CST_300: u32 = CST_299+1; -pub const CST_301: u32 = CST_300+1; -pub const CST_302: u32 = CST_301+1; -pub const CST_303: u32 = CST_302+1; -pub const CST_304: u32 = CST_303+1; -pub const CST_305: u32 = CST_304+1; -pub const CST_306: u32 = CST_305+1; -pub const CST_307: u32 = CST_306+1; -pub const CST_308: u32 = CST_307+1; -pub const CST_309: u32 = CST_308+1; -pub const CST_310: u32 = CST_309+1; -pub const CST_311: u32 = CST_310+1; -pub const CST_312: u32 = CST_311+1; -pub const CST_313: u32 = CST_312+1; -pub const CST_314: u32 = CST_313+1; -pub const CST_315: u32 = CST_314+1; -pub const CST_316: u32 = CST_315+1; -pub const CST_317: u32 = CST_316+1; -pub const CST_318: u32 = CST_317+1; -pub const CST_319: u32 = CST_318+1; -pub const CST_320: u32 = CST_319+1; -pub const CST_321: u32 = CST_320+1; -pub const CST_322: u32 = CST_321+1; -pub const CST_323: u32 = CST_322+1; -pub const CST_324: u32 = CST_323+1; -pub const CST_325: u32 = CST_324+1; -pub const CST_326: u32 = CST_325+1; -pub const CST_327: u32 = CST_326+1; -pub const CST_328: u32 = CST_327+1; -pub const CST_329: u32 = CST_328+1; -pub const CST_330: u32 = CST_329+1; -pub const CST_331: u32 = CST_330+1; -pub const CST_332: u32 = CST_331+1; -pub const CST_333: u32 = CST_332+1; -pub const CST_334: u32 = CST_333+1; -pub const CST_335: u32 = CST_334+1; -pub const CST_336: u32 = CST_335+1; -pub const CST_337: u32 = CST_336+1; -pub const CST_338: u32 = CST_337+1; -pub const CST_339: u32 = CST_338+1; -pub const CST_340: u32 = CST_339+1; -pub const CST_341: u32 = CST_340+1; -pub const CST_342: u32 = CST_341+1; -pub const CST_343: u32 = CST_342+1; -pub const CST_344: u32 = CST_343+1; -pub const CST_345: u32 = CST_344+1; -pub const CST_346: u32 = CST_345+1; -pub const CST_347: u32 = CST_346+1; -pub const CST_348: u32 = CST_347+1; -pub const CST_349: u32 = CST_348+1; -pub const CST_350: u32 = CST_349+1; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/const-block-non-item-statement-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/const-block-non-item-statement-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/const-block-non-item-statement-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/const-block-non-item-statement-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(const_let)] - -type Array = [u32; { let x = 2; 5 }]; - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/const-block-non-item-statement.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/const-block-non-item-statement.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/const-block-non-item-statement.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/const-block-non-item-statement.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(const_let)] - -enum Foo { - Bar = { let x = 1; 3 } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/const-fn-destructuring-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/const-fn-destructuring-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/const-fn-destructuring-arg.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/const-fn-destructuring-arg.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// test that certain things are disallowed in constant functions - -#![feature(const_fn, const_let)] - -// no destructuring -const fn i(( - a, - b - ): (u32, u32)) -> u32 { - a + b -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/deref_in_pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/deref_in_pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/deref_in_pattern.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/deref_in_pattern.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// https://github.com/rust-lang/rust/issues/25574 - -const A: [u8; 4] = *b"fooo"; - -fn main() { - match *b"xxxx" { - A => {}, - _ => {} - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/ice-48279.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/ice-48279.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/ice-48279.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/ice-48279.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// https://github.com/rust-lang/rust/issues/48279 - -#![feature(min_const_fn)] - -#[derive(PartialEq, Eq)] -pub struct NonZeroU32 { - value: u32 -} - -impl NonZeroU32 { - const unsafe fn new_unchecked(value: u32) -> Self { - NonZeroU32 { value } - } -} - -//pub const FOO_ATOM: NonZeroU32 = unsafe { NonZeroU32::new_unchecked(7) }; -pub const FOO_ATOM: NonZeroU32 = unsafe { NonZeroU32 { value: 7 } }; - -fn main() { - match None { - Some(FOO_ATOM) => {} - _ => {} - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/issue-37550.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/issue-37550.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/issue-37550.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/issue-37550.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(const_fn, const_let)] - -const fn x() { - let t = true; - let x = || t; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/issue-broken-mir.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/issue-broken-mir.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/issue-broken-mir.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/issue-broken-mir.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// https://github.com/rust-lang/rust/issues/27918 - -fn main() { - match b" " { - b"1234" => {}, - _ => {}, - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/locals-in-const-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/locals-in-const-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/locals-in-const-fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/locals-in-const-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// https://github.com/rust-lang/rust/issues/48821 - -#![feature(const_fn, const_let)] - -const fn foo(i: usize) -> usize { - let x = i; - x -} - -static FOO: usize = foo(42); - -const fn bar(mut i: usize) -> usize { - i += 8; - let x = &i; - *x -} - -static BAR: usize = bar(42); - -const fn boo(mut i: usize) -> usize { - { - let mut x = i; - x += 10; - i = x; - } - i -} - -static BOO: usize = boo(42); - -fn main() { - assert!(FOO == 42); - assert!(BAR == 50); - assert!(BOO == 52); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/match-const-fn-structs.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/match-const-fn-structs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/match-const-fn-structs.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/match-const-fn-structs.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// https://github.com/rust-lang/rust/issues/46114 - -#![feature(min_const_fn)] - -#[derive(Eq, PartialEq)] -struct A { value: u32 } - -const fn new(value: u32) -> A { - A { value } -} - -const A_1: A = new(1); -const A_2: A = new(2); - -fn main() { - let a_str = match new(42) { - A_1 => "A 1", - A_2 => "A 2", - _ => "Unknown A", - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/mozjs-error.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/mozjs-error.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/mozjs-error.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/mozjs-error.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -struct CustomAutoRooterVFTable { - trace: unsafe extern "C" fn(this: *mut i32, trc: *mut u32), -} - -unsafe trait CustomAutoTraceable: Sized { - const vftable: CustomAutoRooterVFTable = CustomAutoRooterVFTable { - trace: Self::trace, - }; - - unsafe extern "C" fn trace(this: *mut i32, trc: *mut u32) { - let this = this as *const Self; - let this = this.as_ref().unwrap(); - Self::do_trace(this, trc); - } - - fn do_trace(&self, trc: *mut u32); -} - -unsafe impl CustomAutoTraceable for () { - fn do_trace(&self, _: *mut u32) { - // nop - } -} - -fn main() { - let _ = <()>::vftable; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/non-scalar-cast.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/non-scalar-cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/non-scalar-cast.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/non-scalar-cast.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// https://github.com/rust-lang/rust/issues/37448 - -fn main() { - struct A; - const FOO: &A = &(A as A); - let _x = FOO; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/promotion.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/promotion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/promotion.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/promotion.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// compile-flags: -O - -fn foo(_: &'static [&'static str]) {} -fn bar(_: &'static [&'static str; 3]) {} -fn baz_i32(_: &'static i32) {} -fn baz_u32(_: &'static u32) {} - -fn main() { - foo(&["a", "b", "c"]); - bar(&["d", "e", "f"]); - - // make sure that these do not cause trouble despite overflowing - baz_u32(&(0-1)); - baz_i32(&-std::i32::MIN); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/references.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/references.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/references.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/references.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -const FOO: &[u8] = b"foo"; -const BAR: &[u8] = &[1, 2, 3]; - -const BOO: &i32 = &42; - -fn main() { - match &[1u8, 2, 3] as &[u8] { - FOO => panic!("a"), - BAR => println!("b"), - _ => panic!("c"), - } - - match b"foo" as &[u8] { - FOO => println!("a"), - BAR => panic!("b"), - _ => panic!("c"), - } - - match &43 { - &42 => panic!(), - BOO => panic!(), - _ => println!("d"), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/repeat_match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/repeat_match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/repeat_match.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/repeat_match.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// https://github.com/rust-lang/rust/issues/45044 - -const X: [u8; 1] = [0; 1]; - -fn main() { - match &X { - &X => println!("a"), - _ => println!("b"), - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/return-in-const-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/return-in-const-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/return-in-const-fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/return-in-const-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// https://github.com/rust-lang/rust/issues/43754 - -#![feature(min_const_fn)] -const fn foo(x: usize) -> usize { - return x; -} -fn main() { - [0; foo(2)]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/signed_enum_discr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/signed_enum_discr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/signed_enum_discr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/signed_enum_discr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// https://github.com/rust-lang/rust/issues/49181 - -#[derive(Eq, PartialEq)] -#[repr(i8)] -pub enum A { - B = -1, - C = 1, -} - -pub const D: A = A::B; - -fn main() { - match A::C { - D => {}, - _ => {} - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/transmute-const.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/transmute-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/transmute-const.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/transmute-const.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(const_transmute)] - -use std::mem; - -#[repr(transparent)] -struct Foo(u32); - -const TRANSMUTED_U32: u32 = unsafe { mem::transmute(Foo(3)) }; - -fn main() { - assert_eq!(TRANSMUTED_U32, 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/tuple-struct-constructors.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/tuple-struct-constructors.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/tuple-struct-constructors.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/ctfe/tuple-struct-constructors.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// https://github.com/rust-lang/rust/issues/41898 - -use std::num::NonZeroU64; - -fn main() { - const FOO: NonZeroU64 = unsafe { NonZeroU64::new_unchecked(2) }; - if let FOO = FOO {} -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/auxiliary/derive-no-std.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/auxiliary/derive-no-std.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/auxiliary/derive-no-std.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/auxiliary/derive-no-std.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "rlib"] -#![no_std] - -// Issue #16803 - -#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord, - Debug, Default, Copy)] -pub struct Foo { - pub x: u32, -} - -#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord, - Debug, Copy)] -pub enum Bar { - Qux, - Quux(u32), -} - -#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord, - Debug, Copy)] -pub enum Void {} -#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord, - Debug, Copy)] -pub struct Empty; -#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord, - Debug, Copy)] -pub struct AlsoEmpty {} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/derive-no-std.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/derive-no-std.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/derive-no-std.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/derive-no-std.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:derive-no-std.rs - -extern crate derive_no_std; -use derive_no_std::*; - -fn main() { - let f = Foo { x: 0 }; - assert_eq!(f.clone(), Foo::default()); - - assert!(Bar::Qux < Bar::Quux(42)); -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/derive-partialord-correctness.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/derive-partialord-correctness.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/derive-partialord-correctness.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/derive-partialord-correctness.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Original issue: #49650 - -#[derive(PartialOrd, PartialEq)] -struct FloatWrapper(f64); - -fn main() { - assert!((0.0 / 0.0 >= 0.0) == (FloatWrapper(0.0 / 0.0) >= FloatWrapper(0.0))) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-associated-types.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-associated-types.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-associated-types.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-associated-types.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,209 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub trait DeclaredTrait { - type Type; -} - -impl DeclaredTrait for i32 { - type Type = i32; -} - -pub trait WhereTrait { - type Type; -} - -impl WhereTrait for i32 { - type Type = i32; -} - -// Make sure we don't add a bound that just shares a name with an associated -// type. -pub mod module { - pub type Type = i32; -} - -#[derive(PartialEq, Debug)] -struct PrivateStruct(T); - -#[derive(PartialEq, Debug)] -struct TupleStruct( - module::Type, - Option, - A, - PrivateStruct, - B, - B::Type, - Option, - ::Type, - Option<::Type>, - C, - C::Type, - Option, - ::Type, - Option<::Type>, - ::Type, -) where C: WhereTrait; - -#[derive(PartialEq, Debug)] -pub struct Struct where C: WhereTrait { - m1: module::Type, - m2: Option, - a1: A, - a2: PrivateStruct, - b: B, - b1: B::Type, - b2: Option, - b3: ::Type, - b4: Option<::Type>, - c: C, - c1: C::Type, - c2: Option, - c3: ::Type, - c4: Option<::Type>, - d: ::Type, -} - -#[derive(PartialEq, Debug)] -enum Enum where C: WhereTrait { - Unit, - Seq( - module::Type, - Option, - A, - PrivateStruct, - B, - B::Type, - Option, - ::Type, - Option<::Type>, - C, - C::Type, - Option, - ::Type, - Option<::Type>, - ::Type, - ), - Map { - m1: module::Type, - m2: Option, - a1: A, - a2: PrivateStruct, - b: B, - b1: B::Type, - b2: Option, - b3: ::Type, - b4: Option<::Type>, - c: C, - c1: C::Type, - c2: Option, - c3: ::Type, - c4: Option<::Type>, - d: ::Type, - }, -} - -fn main() { - let e: TupleStruct< - i32, - i32, - i32, - > = TupleStruct( - 0, - None, - 0, - PrivateStruct(0), - 0, - 0, - None, - 0, - None, - 0, - 0, - None, - 0, - None, - 0, - ); - assert_eq!(e, e); - - let e: Struct< - i32, - i32, - i32, - > = Struct { - m1: 0, - m2: None, - a1: 0, - a2: PrivateStruct(0), - b: 0, - b1: 0, - b2: None, - b3: 0, - b4: None, - c: 0, - c1: 0, - c2: None, - c3: 0, - c4: None, - d: 0, - }; - assert_eq!(e, e); - - let e = Enum::Unit::; - assert_eq!(e, e); - - let e: Enum< - i32, - i32, - i32, - > = Enum::Seq( - 0, - None, - 0, - PrivateStruct(0), - 0, - 0, - None, - 0, - None, - 0, - 0, - None, - 0, - None, - 0, - ); - assert_eq!(e, e); - - let e: Enum< - i32, - i32, - i32, - > = Enum::Map { - m1: 0, - m2: None, - a1: 0, - a2: PrivateStruct(0), - b: 0, - b1: 0, - b2: None, - b3: 0, - b4: None, - c: 0, - c1: 0, - c2: None, - c3: 0, - c4: None, - d: 0, - }; - assert_eq!(e, e); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-bounds.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-bounds.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-bounds.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-bounds.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Copy, Clone)] -struct Test; - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-array.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-array.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-array.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-array.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// test for issue #30244 - -#[derive(Copy, Clone)] -struct Array { - arr: [[u8; 256]; 4] -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-enum.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#[derive(Clone)] -enum E { - A, - B(()), - C -} - -pub fn main() { - let _ = E::A.clone(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-generic-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-generic-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-generic-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-generic-enum.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#[derive(Clone)] -enum E { - A(T), - B(T,U), - C -} - -pub fn main() { - let _ = E::A::(1).clone(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-generic-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-generic-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-generic-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-generic-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#[derive(Clone)] -struct S { - foo: (), - bar: (), - baz: T, -} - -pub fn main() { - let _ = S { foo: (), bar: (), baz: 1 }.clone(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-generic-tuple-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-generic-tuple-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-generic-tuple-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-generic-tuple-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#[derive(Clone)] -struct S(T, ()); - -pub fn main() { - let _ = S(1, ()).clone(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#[derive(Clone)] -struct S { - _int: isize, - _i8: i8, - _i16: i16, - _i32: i32, - _i64: i64, - - _uint: usize, - _u8: u8, - _u16: u16, - _u32: u32, - _u64: u64, - - _f32: f32, - _f64: f64, - - _bool: bool, - _char: char, - _nil: () -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-tuple-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-tuple-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-tuple-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-clone-tuple-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#[derive(Clone)] -struct S((), ()); - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-cmp-generic-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-cmp-generic-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-cmp-generic-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-cmp-generic-enum.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(PartialEq, Eq, PartialOrd, Ord)] -enum E { - E0, - E1(T), - E2(T,T) -} - -pub fn main() { - let e0 = E::E0; - let e11 = E::E1(1); - let e12 = E::E1(2); - let e21 = E::E2(1, 1); - let e22 = E::E2(1, 2); - - // in order for both PartialOrd and Ord - let es = [e0, e11, e12, e21, e22]; - - for (i, e1) in es.iter().enumerate() { - for (j, e2) in es.iter().enumerate() { - let ord = i.cmp(&j); - - let eq = i == j; - let lt = i < j; - let le = i <= j; - let gt = i > j; - let ge = i >= j; - - // PartialEq - assert_eq!(*e1 == *e2, eq); - assert_eq!(*e1 != *e2, !eq); - - // PartialOrd - assert_eq!(*e1 < *e2, lt); - assert_eq!(*e1 > *e2, gt); - - assert_eq!(*e1 <= *e2, le); - assert_eq!(*e1 >= *e2, ge); - - // Ord - assert_eq!(e1.cmp(e2), ord); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-cmp-generic-struct-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-cmp-generic-struct-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-cmp-generic-struct-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-cmp-generic-struct-enum.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(PartialEq, Eq, PartialOrd, Ord)] -enum ES { - ES1 { x: T }, - ES2 { x: T, y: T } -} - - -pub fn main() { - let (es11, es12, es21, es22) = (ES::ES1 { - x: 1 - }, ES::ES1 { - x: 2 - }, ES::ES2 { - x: 1, - y: 1 - }, ES::ES2 { - x: 1, - y: 2 - }); - - // in order for both PartialOrd and Ord - let ess = [es11, es12, es21, es22]; - - for (i, es1) in ess.iter().enumerate() { - for (j, es2) in ess.iter().enumerate() { - let ord = i.cmp(&j); - - let eq = i == j; - let (lt, le) = (i < j, i <= j); - let (gt, ge) = (i > j, i >= j); - - // PartialEq - assert_eq!(*es1 == *es2, eq); - assert_eq!(*es1 != *es2, !eq); - - // PartialOrd - assert_eq!(*es1 < *es2, lt); - assert_eq!(*es1 > *es2, gt); - - assert_eq!(*es1 <= *es2, le); - assert_eq!(*es1 >= *es2, ge); - - // Ord - assert_eq!(es1.cmp(es2), ord); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-cmp-generic-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-cmp-generic-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-cmp-generic-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-cmp-generic-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(PartialEq, Eq, PartialOrd, Ord)] -struct S { - x: T, - y: T -} - -pub fn main() { - let s1 = S {x: 1, y: 1}; - let s2 = S {x: 1, y: 2}; - - // in order for both PartialOrd and Ord - let ss = [s1, s2]; - - for (i, s1) in ss.iter().enumerate() { - for (j, s2) in ss.iter().enumerate() { - let ord = i.cmp(&j); - - let eq = i == j; - let lt = i < j; - let le = i <= j; - let gt = i > j; - let ge = i >= j; - - // PartialEq - assert_eq!(*s1 == *s2, eq); - assert_eq!(*s1 != *s2, !eq); - - // PartialOrd - assert_eq!(*s1 < *s2, lt); - assert_eq!(*s1 > *s2, gt); - - assert_eq!(*s1 <= *s2, le); - assert_eq!(*s1 >= *s2, ge); - - // Ord - assert_eq!(s1.cmp(s2), ord); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-cmp-generic-tuple-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-cmp-generic-tuple-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-cmp-generic-tuple-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-cmp-generic-tuple-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(PartialEq, Eq, PartialOrd, Ord)] -struct TS(T,T); - - -pub fn main() { - let ts1 = TS(1, 1); - let ts2 = TS(1, 2); - - // in order for both PartialOrd and Ord - let tss = [ts1, ts2]; - - for (i, ts1) in tss.iter().enumerate() { - for (j, ts2) in tss.iter().enumerate() { - let ord = i.cmp(&j); - - let eq = i == j; - let lt = i < j; - let le = i <= j; - let gt = i > j; - let ge = i >= j; - - // PartialEq - assert_eq!(*ts1 == *ts2, eq); - assert_eq!(*ts1 != *ts2, !eq); - - // PartialOrd - assert_eq!(*ts1 < *ts2, lt); - assert_eq!(*ts1 > *ts2, gt); - - assert_eq!(*ts1 <= *ts2, le); - assert_eq!(*ts1 >= *ts2, ge); - - // Ord - assert_eq!(ts1.cmp(ts2), ord); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-cmp-shortcircuit.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-cmp-shortcircuit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-cmp-shortcircuit.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-cmp-shortcircuit.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// check that the derived impls for the comparison traits shortcircuit -// where possible, by having a type that panics when compared as the -// second element, so this passes iff the instances shortcircuit. - - -use std::cmp::Ordering; - -pub struct FailCmp; -impl PartialEq for FailCmp { - fn eq(&self, _: &FailCmp) -> bool { panic!("eq") } -} - -impl PartialOrd for FailCmp { - fn partial_cmp(&self, _: &FailCmp) -> Option { panic!("partial_cmp") } -} - -impl Eq for FailCmp {} - -impl Ord for FailCmp { - fn cmp(&self, _: &FailCmp) -> Ordering { panic!("cmp") } -} - -#[derive(PartialEq,PartialOrd,Eq,Ord)] -struct ShortCircuit { - x: isize, - y: FailCmp -} - -pub fn main() { - let a = ShortCircuit { x: 1, y: FailCmp }; - let b = ShortCircuit { x: 2, y: FailCmp }; - - assert!(a != b); - assert!(a < b); - assert_eq!(a.cmp(&b), ::std::cmp::Ordering::Less); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-copyclone.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-copyclone.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-copyclone.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-copyclone.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -//! Test that #[derive(Copy, Clone)] produces a shallow copy -//! even when a member violates RFC 1521 - -use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering}; - -/// A struct that pretends to be Copy, but actually does something -/// in its Clone impl -#[derive(Copy)] -struct Liar; - -/// Static cooperating with the rogue Clone impl -static CLONED: AtomicBool = ATOMIC_BOOL_INIT; - -impl Clone for Liar { - fn clone(&self) -> Self { - // this makes Clone vs Copy observable - CLONED.store(true, Ordering::SeqCst); - - *self - } -} - -/// This struct is actually Copy... at least, it thinks it is! -#[derive(Copy, Clone)] -struct Innocent(Liar); - -impl Innocent { - fn new() -> Self { - Innocent(Liar) - } -} - -fn main() { - let _ = Innocent::new().clone(); - // if Innocent was byte-for-byte copied, CLONED will still be false - assert!(!CLONED.load(Ordering::SeqCst)); -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-default-box.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-default-box.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-default-box.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-default-box.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -use std::default::Default; - -#[derive(Default)] -struct A { - foo: Box<[bool]>, -} - -pub fn main() { - let a: A = Default::default(); - let b: Box<[_]> = Box::<[bool; 0]>::new([]); - assert_eq!(a.foo, b); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-enum-single-variant.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-enum-single-variant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-enum-single-variant.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-enum-single-variant.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 -#![allow(non_camel_case_types)] - -pub type task_id = isize; - -#[derive(PartialEq)] -pub enum Task { - TaskHandle(task_id) -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-eq-ord-boxed-slice.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-eq-ord-boxed-slice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-eq-ord-boxed-slice.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-eq-ord-boxed-slice.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(PartialEq, PartialOrd, Eq, Ord, Debug)] -struct Foo(Box<[u8]>); - -pub fn main() { - let a = Foo(Box::new([0, 1, 2])); - let b = Foo(Box::new([0, 1, 2])); - assert_eq!(a, b); - println!("{}", a != b); - println!("{}", a < b); - println!("{}", a <= b); - println!("{}", a == b); - println!("{}", a > b); - println!("{}", a >= b); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-hash.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-hash.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-hash.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-hash.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(deprecated)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -#![allow(overflowing_literals)] - -use std::hash::{Hash, SipHasher, Hasher}; -use std::mem::size_of; - -#[derive(Hash)] -struct Person { - id: usize, - name: String, - phone: usize, -} - -// test for hygiene name collisions -#[derive(Hash)] struct __H__H; -#[derive(Hash)] enum Collision<__H> { __H { __H__H: __H } } - -#[derive(Hash)] -enum E { A=1, B } - -fn hash(t: &T) -> u64 { - let mut s = SipHasher::new_with_keys(0, 0); - t.hash(&mut s); - s.finish() -} - -struct FakeHasher<'a>(&'a mut Vec); -impl<'a> Hasher for FakeHasher<'a> { - fn finish(&self) -> u64 { - unimplemented!() - } - - fn write(&mut self, bytes: &[u8]) { - self.0.extend(bytes); - } -} - -fn fake_hash(v: &mut Vec, a: A) { - a.hash(&mut FakeHasher(v)); -} - -fn main() { - let person1 = Person { - id: 5, - name: "Janet".to_string(), - phone: 555_666_7777 - }; - let person2 = Person { - id: 5, - name: "Bob".to_string(), - phone: 555_666_7777 - }; - assert_eq!(hash(&person1), hash(&person1)); - assert!(hash(&person1) != hash(&person2)); - - // test #21714 - let mut va = vec![]; - let mut vb = vec![]; - fake_hash(&mut va, E::A); - fake_hash(&mut vb, E::B); - assert!(va != vb); - - // issue #39137: single variant enum hash should not hash discriminant - #[derive(Hash)] - enum SingleVariantEnum { - A(u8), - } - let mut v = vec![]; - fake_hash(&mut v, SingleVariantEnum::A(17)); - assert_eq!(vec![17], v); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-in-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-in-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-in-fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-in-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn main() { - #[derive(Debug)] - struct Foo { - foo: isize, - } - - let f = Foo { foo: 10 }; - format!("{:?}", f); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-in-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-in-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-in-macro.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-in-macro.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 -#![allow(non_camel_case_types)] - -macro_rules! define_vec { - () => ( - mod foo { - #[derive(PartialEq)] - pub struct bar; - } - ) -} - -define_vec![]; - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-meta-multiple.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-meta-multiple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-meta-multiple.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-meta-multiple.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 -#![allow(deprecated)] - -use std::hash::{Hash, SipHasher}; - -// testing multiple separate deriving attributes -#[derive(PartialEq)] -#[derive(Clone)] -#[derive(Hash)] -struct Foo { - bar: usize, - baz: isize -} - -fn hash(_t: &T) {} - -pub fn main() { - let a = Foo {bar: 4, baz: -3}; - - a == a; // check for PartialEq impl w/o testing its correctness - a.clone(); // check for Clone impl w/o testing its correctness - hash(&a); // check for Hash impl w/o testing its correctness -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-meta.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-meta.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-meta.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-meta.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 -#![allow(deprecated)] - -use std::hash::{Hash, SipHasher}; - -#[derive(PartialEq, Clone, Hash)] -struct Foo { - bar: usize, - baz: isize -} - -fn hash(_t: &T) {} - -pub fn main() { - let a = Foo {bar: 4, baz: -3}; - - a == a; // check for PartialEq impl w/o testing its correctness - a.clone(); // check for Clone impl w/o testing its correctness - hash(&a); // check for Hash impl w/o testing its correctness -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-self-lifetime-totalord-totaleq.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-self-lifetime-totalord-totaleq.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-self-lifetime-totalord-totaleq.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-self-lifetime-totalord-totaleq.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::cmp::Ordering::{Less,Equal,Greater}; - -#[derive(PartialEq, Eq, PartialOrd, Ord)] -struct A<'a> { - x: &'a isize -} -pub fn main() { - let (a, b) = (A { x: &1 }, A { x: &2 }); - - assert_eq!(a.cmp(&a), Equal); - assert_eq!(b.cmp(&b), Equal); - - assert_eq!(a.cmp(&b), Less); - assert_eq!(b.cmp(&a), Greater); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-show-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-show-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-show-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-show-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::fmt; - -#[derive(Debug)] -enum A {} -#[derive(Debug)] -enum B { B1, B2, B3 } -#[derive(Debug)] -enum C { C1(isize), C2(B), C3(String) } -#[derive(Debug)] -enum D { D1{ a: isize } } -#[derive(Debug)] -struct E; -#[derive(Debug)] -struct F(isize); -#[derive(Debug)] -struct G(isize, isize); -#[derive(Debug)] -struct H { a: isize } -#[derive(Debug)] -struct I { a: isize, b: isize } -#[derive(Debug)] -struct J(Custom); - -struct Custom; -impl fmt::Debug for Custom { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "yay") - } -} - -trait ToDebug { - fn to_show(&self) -> String; -} - -impl ToDebug for T { - fn to_show(&self) -> String { - format!("{:?}", self) - } -} - -pub fn main() { - assert_eq!(B::B1.to_show(), "B1".to_string()); - assert_eq!(B::B2.to_show(), "B2".to_string()); - assert_eq!(C::C1(3).to_show(), "C1(3)".to_string()); - assert_eq!(C::C2(B::B2).to_show(), "C2(B2)".to_string()); - assert_eq!(D::D1{ a: 2 }.to_show(), "D1 { a: 2 }".to_string()); - assert_eq!(E.to_show(), "E".to_string()); - assert_eq!(F(3).to_show(), "F(3)".to_string()); - assert_eq!(G(3, 4).to_show(), "G(3, 4)".to_string()); - assert_eq!(I{ a: 2, b: 4 }.to_show(), "I { a: 2, b: 4 }".to_string()); - assert_eq!(J(Custom).to_show(), "J(yay)".to_string()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-show.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-show.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-show.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-show.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Debug)] -struct Unit; - -#[derive(Debug)] -struct Tuple(isize, usize); - -#[derive(Debug)] -struct Struct { x: isize, y: usize } - -#[derive(Debug)] -enum Enum { - Nullary, - Variant(isize, usize), - StructVariant { x: isize, y : usize } -} - -#[derive(Debug)] -struct Pointers(*const Send, *mut Sync); - -macro_rules! t { - ($x:expr, $expected:expr) => { - assert_eq!(format!("{:?}", $x), $expected.to_string()) - } -} - -pub fn main() { - t!(Unit, "Unit"); - t!(Tuple(1, 2), "Tuple(1, 2)"); - t!(Struct { x: 1, y: 2 }, "Struct { x: 1, y: 2 }"); - t!(Enum::Nullary, "Nullary"); - t!(Enum::Variant(1, 2), "Variant(1, 2)"); - t!(Enum::StructVariant { x: 1, y: 2 }, "StructVariant { x: 1, y: 2 }"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-c-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-c-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-c-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-c-enum.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(PartialEq, Debug)] -enum Foo { - Bar, - Baz, - Boo -} - -pub fn main() { - let a = Foo::Bar; - let b = Foo::Bar; - assert_eq!(a, b); - assert!(!(a != b)); - assert!(a.eq(&b)); - assert!(!a.ne(&b)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-enum.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(PartialEq, Debug)] -enum Foo { - Bar(isize, isize), - Baz(f64, f64) -} - -pub fn main() { - let a = Foo::Bar(1, 2); - let b = Foo::Bar(1, 2); - assert_eq!(a, b); - assert!(!(a != b)); - assert!(a.eq(&b)); - assert!(!a.ne(&b)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-hash-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-hash-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-hash-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-hash-enum.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Hash)] -enum Foo { - Bar(isize, char), - Baz(char, isize) -} - -#[derive(Hash)] -enum A { - B, - C, - D, - E -} - -pub fn main(){} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-hash-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-hash-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-hash-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-hash-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#[derive(Hash)] -struct Foo { - x: isize, - y: isize, - z: isize -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-struct-empty.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-struct-empty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-struct-empty.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-struct-empty.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(PartialEq, Debug)] -struct Foo; - -pub fn main() { - assert_eq!(Foo, Foo); - assert!(!(Foo != Foo)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-struct-like-enum-variant.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-struct-like-enum-variant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-struct-like-enum-variant.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-struct-like-enum-variant.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(PartialEq, Debug)] -enum S { - X { x: isize, y: isize }, - Y -} - -pub fn main() { - let x = S::X { x: 1, y: 2 }; - assert_eq!(x, x); - assert!(!(x != x)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(PartialEq, Debug)] -struct Foo { - x: isize, - y: isize, - z: isize, -} - -pub fn main() { - let a = Foo { x: 1, y: 2, z: 3 }; - let b = Foo { x: 1, y: 2, z: 3 }; - assert_eq!(a, b); - assert!(!(a != b)); - assert!(a.eq(&b)); - assert!(!a.ne(&b)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-struct-tuple.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-struct-tuple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-struct-tuple.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-struct-tuple.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(PartialEq, Debug)] -struct Foo(isize, isize, String); - -pub fn main() { - let a1 = Foo(5, 6, "abc".to_string()); - let a2 = Foo(5, 6, "abc".to_string()); - let b = Foo(5, 7, "def".to_string()); - - assert_eq!(a1, a1); - assert_eq!(a2, a1); - assert!(!(a1 == b)); - - assert!(a1 != b); - assert!(!(a1 != a1)); - assert!(!(a2 != a1)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-type-params.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-type-params.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-type-params.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-via-extension-type-params.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(PartialEq, Hash, Debug)] -struct Foo { - x: isize, - y: T, - z: isize -} - -pub fn main() { - let a = Foo { x: 1, y: 2.0f64, z: 3 }; - let b = Foo { x: 1, y: 2.0f64, z: 3 }; - assert_eq!(a, b); - assert!(!(a != b)); - assert!(a.eq(&b)); - assert!(!a.ne(&b)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-with-repr-packed.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-with-repr-packed.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-with-repr-packed.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/deriving/deriving-with-repr-packed.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// check that derive on a packed struct does not call field -// methods with a misaligned field. - -use std::mem; - -#[derive(Copy, Clone)] -struct Aligned(usize); - -#[inline(never)] -fn check_align(ptr: *const Aligned) { - assert_eq!(ptr as usize % mem::align_of::(), - 0); -} - -impl PartialEq for Aligned { - fn eq(&self, other: &Self) -> bool { - check_align(self); - check_align(other); - self.0 == other.0 - } -} - -#[repr(packed)] -#[derive(Copy, Clone, PartialEq)] -struct Packed(Aligned, Aligned); - -#[derive(PartialEq)] -#[repr(C)] -struct Dealigned(u8, T); - -fn main() { - let d1 = Dealigned(0, Packed(Aligned(1), Aligned(2))); - let ck = d1 == d1; - assert!(ck); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/auxiliary/dropck_eyepatch_extern_crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/auxiliary/dropck_eyepatch_extern_crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/auxiliary/dropck_eyepatch_extern_crate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/auxiliary/dropck_eyepatch_extern_crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(dropck_eyepatch)] - -// The point of this test is to illustrate that the `#[may_dangle]` -// attribute specifically allows, in the context of a type -// implementing `Drop`, a generic parameter to be instantiated with a -// lifetime that does not strictly outlive the owning type itself, -// and that this attributes effects are preserved when importing -// the type from another crate. -// -// See also dropck-eyepatch.rs for more information about the general -// structure of the test. - -use std::cell::RefCell; - -pub trait Foo { fn foo(&self, _: &str); } - -pub struct Dt(pub &'static str, pub A); -pub struct Dr<'a, B:'a+Foo>(pub &'static str, pub &'a B); -pub struct Pt(pub &'static str, pub A, pub B); -pub struct Pr<'a, 'b, B:'a+'b+Foo>(pub &'static str, pub &'a B, pub &'b B); -pub struct St(pub &'static str, pub A); -pub struct Sr<'a, B:'a+Foo>(pub &'static str, pub &'a B); - -impl Drop for Dt { - fn drop(&mut self) { println!("drop {}", self.0); self.1.foo(self.0); } -} -impl<'a, B: Foo> Drop for Dr<'a, B> { - fn drop(&mut self) { println!("drop {}", self.0); self.1.foo(self.0); } -} -unsafe impl<#[may_dangle] A, B: Foo> Drop for Pt { - // (unsafe to access self.1 due to #[may_dangle] on A) - fn drop(&mut self) { println!("drop {}", self.0); self.2.foo(self.0); } -} -unsafe impl<#[may_dangle] 'a, 'b, B: Foo> Drop for Pr<'a, 'b, B> { - // (unsafe to access self.1 due to #[may_dangle] on 'a) - fn drop(&mut self) { println!("drop {}", self.0); self.2.foo(self.0); } -} - -impl Foo for RefCell { - fn foo(&self, s: &str) { - let s2 = format!("{}|{}", *self.borrow(), s); - *self.borrow_mut() = s2; - } -} - -impl<'a, T:Foo> Foo for &'a T { - fn foo(&self, s: &str) { - (*self).foo(s); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/dropck-eyepatch-extern-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/dropck-eyepatch-extern-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/dropck-eyepatch-extern-crate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/dropck-eyepatch-extern-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:dropck_eyepatch_extern_crate.rs - -extern crate dropck_eyepatch_extern_crate as other; - -use other::{Dt,Dr,Pt,Pr,St,Sr}; - -fn main() { - use std::cell::RefCell; - - struct CheckOnDrop(RefCell, &'static str); - impl Drop for CheckOnDrop { - fn drop(&mut self) { assert_eq!(*self.0.borrow(), self.1); } - } - - let c_long; - let (c, dt, dr, pt, pr, st, sr) - : (CheckOnDrop, Dt<_>, Dr<_>, Pt<_, _>, Pr<_>, St<_>, Sr<_>); - c_long = CheckOnDrop(RefCell::new("c_long".to_string()), - "c_long|pr|pt|dr|dt"); - c = CheckOnDrop(RefCell::new("c".to_string()), - "c"); - - // No error: sufficiently long-lived state can be referenced in dtors - dt = Dt("dt", &c_long.0); - dr = Dr("dr", &c_long.0); - - // No error: Drop impl asserts .1 (A and &'a _) are not accessed - pt = Pt("pt", &c.0, &c_long.0); - pr = Pr("pr", &c.0, &c_long.0); - - // No error: St and Sr have no destructor. - st = St("st", &c.0); - sr = Sr("sr", &c.0); - - println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0)); - assert_eq!(*c_long.0.borrow(), "c_long"); - assert_eq!(*c.0.borrow(), "c"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/dropck-eyepatch-reorder.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/dropck-eyepatch-reorder.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/dropck-eyepatch-reorder.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/dropck-eyepatch-reorder.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(dropck_eyepatch)] - -// The point of this test is to test uses of `#[may_dangle]` attribute -// where the formal declaration order (in the impl generics) does not -// match the actual usage order (in the type instantiation). -// -// See also dropck-eyepatch.rs for more information about the general -// structure of the test. - -trait Foo { fn foo(&self, _: &str); } - -struct Dt(&'static str, A); -struct Dr<'a, B:'a+Foo>(&'static str, &'a B); -struct Pt(&'static str, A, B); -struct Pr<'a, 'b, B:'a+'b+Foo>(&'static str, &'a B, &'b B); -struct St(&'static str, A); -struct Sr<'a, B:'a+Foo>(&'static str, &'a B); - -impl Drop for Dt { - fn drop(&mut self) { println!("drop {}", self.0); self.1.foo(self.0); } -} -impl<'a, B: Foo> Drop for Dr<'a, B> { - fn drop(&mut self) { println!("drop {}", self.0); self.1.foo(self.0); } -} -unsafe impl Drop for Pt { - // (unsafe to access self.1 due to #[may_dangle] on A) - fn drop(&mut self) { println!("drop {}", self.0); self.2.foo(self.0); } -} -unsafe impl<'b, #[may_dangle] 'a, B: Foo> Drop for Pr<'a, 'b, B> { - // (unsafe to access self.1 due to #[may_dangle] on 'a) - fn drop(&mut self) { println!("drop {}", self.0); self.2.foo(self.0); } -} - -fn main() { - use std::cell::RefCell; - - impl Foo for RefCell { - fn foo(&self, s: &str) { - let s2 = format!("{}|{}", *self.borrow(), s); - *self.borrow_mut() = s2; - } - } - - impl<'a, T:Foo> Foo for &'a T { - fn foo(&self, s: &str) { - (*self).foo(s); - } - } - - struct CheckOnDrop(RefCell, &'static str); - impl Drop for CheckOnDrop { - fn drop(&mut self) { assert_eq!(*self.0.borrow(), self.1); } - } - - let c_long; - let (c, dt, dr, pt, pr, st, sr) - : (CheckOnDrop, Dt<_>, Dr<_>, Pt<_, _>, Pr<_>, St<_>, Sr<_>); - c_long = CheckOnDrop(RefCell::new("c_long".to_string()), - "c_long|pr|pt|dr|dt"); - c = CheckOnDrop(RefCell::new("c".to_string()), - "c"); - - // No error: sufficiently long-lived state can be referenced in dtors - dt = Dt("dt", &c_long.0); - dr = Dr("dr", &c_long.0); - - // No error: Drop impl asserts .1 (A and &'a _) are not accessed - pt = Pt("pt", &c.0, &c_long.0); - pr = Pr("pr", &c.0, &c_long.0); - - // No error: St and Sr have no destructor. - st = St("st", &c.0); - sr = Sr("sr", &c.0); - - println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0)); - assert_eq!(*c_long.0.borrow(), "c_long"); - assert_eq!(*c.0.borrow(), "c"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/dropck-eyepatch.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/dropck-eyepatch.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/dropck-eyepatch.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/dropck-eyepatch.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,112 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(dropck_eyepatch)] - -// The point of this test is to illustrate that the `#[may_dangle]` -// attribute specifically allows, in the context of a type -// implementing `Drop`, a generic parameter to be instantiated with a -// lifetime that does not strictly outlive the owning type itself. -// -// Here we test that a model use of `#[may_dangle]` will compile and run. -// -// The illustration is made concrete by comparison with two variations -// on the type with `#[may_dangle]`: -// -// 1. an analogous type that does not implement `Drop` (and thus -// should exhibit maximal flexibility with respect to dropck), and -// -// 2. an analogous type that does not use `#[may_dangle]` (and thus -// should exhibit the standard limitations imposed by dropck. -// -// The types in this file follow a pattern, {D,P,S}{t,r}, where: -// -// - D means "I implement Drop" -// -// - P means "I implement Drop but guarantee my (first) parameter is -// pure, i.e. not accessed from the destructor"; no other parameters -// are pure. -// -// - S means "I do not implement Drop" -// -// - t suffix is used when the first generic is a type -// -// - r suffix is used when the first generic is a lifetime. - -trait Foo { fn foo(&self, _: &str); } - -struct Dt(&'static str, A); -struct Dr<'a, B:'a+Foo>(&'static str, &'a B); -struct Pt(&'static str, A, B); -struct Pr<'a, 'b, B:'a+'b+Foo>(&'static str, &'a B, &'b B); -struct St(&'static str, A); -struct Sr<'a, B:'a+Foo>(&'static str, &'a B); - -impl Drop for Dt { - fn drop(&mut self) { println!("drop {}", self.0); self.1.foo(self.0); } -} -impl<'a, B: Foo> Drop for Dr<'a, B> { - fn drop(&mut self) { println!("drop {}", self.0); self.1.foo(self.0); } -} -unsafe impl<#[may_dangle] A, B: Foo> Drop for Pt { - // (unsafe to access self.1 due to #[may_dangle] on A) - fn drop(&mut self) { println!("drop {}", self.0); self.2.foo(self.0); } -} -unsafe impl<#[may_dangle] 'a, 'b, B: Foo> Drop for Pr<'a, 'b, B> { - // (unsafe to access self.1 due to #[may_dangle] on 'a) - fn drop(&mut self) { println!("drop {}", self.0); self.2.foo(self.0); } -} - -fn main() { - use std::cell::RefCell; - - impl Foo for RefCell { - fn foo(&self, s: &str) { - let s2 = format!("{}|{}", *self.borrow(), s); - *self.borrow_mut() = s2; - } - } - - impl<'a, T:Foo> Foo for &'a T { - fn foo(&self, s: &str) { - (*self).foo(s); - } - } - - struct CheckOnDrop(RefCell, &'static str); - impl Drop for CheckOnDrop { - fn drop(&mut self) { assert_eq!(*self.0.borrow(), self.1); } - } - - let c_long; - let (c, dt, dr, pt, pr, st, sr) - : (CheckOnDrop, Dt<_>, Dr<_>, Pt<_, _>, Pr<_>, St<_>, Sr<_>); - c_long = CheckOnDrop(RefCell::new("c_long".to_string()), - "c_long|pr|pt|dr|dt"); - c = CheckOnDrop(RefCell::new("c".to_string()), - "c"); - - // No error: sufficiently long-lived state can be referenced in dtors - dt = Dt("dt", &c_long.0); - dr = Dr("dr", &c_long.0); - - // No error: Drop impl asserts .1 (A and &'a _) are not accessed - pt = Pt("pt", &c.0, &c_long.0); - pr = Pr("pr", &c.0, &c_long.0); - - // No error: St and Sr have no destructor. - st = St("st", &c.0); - sr = Sr("sr", &c.0); - - println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0)); - assert_eq!(*c_long.0.borrow(), "c_long"); - assert_eq!(*c.0.borrow(), "c"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/dropck_legal_cycles.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/dropck_legal_cycles.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/dropck_legal_cycles.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/dropck_legal_cycles.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,1193 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This test exercises cases where cyclic structure is legal, -// including when the cycles go through data-structures such -// as `Vec` or `TypedArena`. -// -// The intent is to cover as many such cases as possible, ensuring -// that if the compiler did not complain circa Rust 1.x (1.2 as of -// this writing), then it will continue to not complain in the future. -// -// Note that while some of the tests are only exercising using the -// given collection as a "backing store" for a set of nodes that hold -// the actual cycle (and thus the cycle does not go through the -// collection itself in such cases), in general we *do* want to make -// sure to have at least one example exercising a cycle that goes -// through the collection, for every collection type that supports -// this. - -// HIGH LEVEL DESCRIPTION OF THE TEST ARCHITECTURE -// ----------------------------------------------- -// -// We pick a data structure and want to make a cyclic construction -// from it. Each test of interest is labelled starting with "Cycle N: -// { ... }" where N is the test number and the "..."`is filled in with -// a graphviz-style description of the graph structure that the -// author believes is being made. So "{ a -> b, b -> (c,d), (c,d) -> e }" -// describes a line connected to a diamond: -// -// c -// / \ -// a - b e -// \ / -// d -// -// (Note that the above directed graph is actually acyclic.) -// -// The different graph structures are often composed of different data -// types. Some may be built atop `Vec`, others atop `HashMap`, etc. -// -// For each graph structure, we actually *confirm* that a cycle exists -// (as a safe-guard against a test author accidentally leaving it out) -// by traversing each graph and "proving" that a cycle exists within it. -// -// To do this, while trying to keep the code uniform (despite working -// with different underlying collection and smart-pointer types), we -// have a standard traversal API: -// -// 1. every node in the graph carries a `mark` (a u32, init'ed to 0). -// -// 2. every node provides a method to visit its children -// -// 3. a traversal attmepts to visit the nodes of the graph and prove that -// it sees the same node twice. It does this by setting the mark of each -// node to a fresh non-zero value, and if it sees the current mark, it -// "knows" that it must have found a cycle, and stops attempting further -// traversal. -// -// 4. each traversal is controlled by a bit-string that tells it which child -// it visit when it can take different paths. As a simple example, -// in a binary tree, 0 could mean "left" (and 1, "right"), so that -// "00010" means "left, left, left, right, left". (In general it will -// read as many bits as it needs to choose one child.) -// -// The graphs in this test are all meant to be very small, and thus -// short bitstrings of less than 64 bits should always suffice. -// -// (An earlier version of this test infrastructure simply had any -// given traversal visit all children it encountered, in a -// depth-first manner; one problem with this approach is that an -// acyclic graph can still have sharing, which would then be treated -// as a repeat mark and reported as a detected cycle.) -// -// The travseral code is a little more complicated because it has been -// programmed in a somewhat defensive manner. For example it also has -// a max threshold for the number of nodes it will visit, to guard -// against scenarios where the nodes are not correctly setting their -// mark when asked. There are various other methods not discussed here -// that are for aiding debugging the test when it runs, such as the -// `name` method that all nodes provide. -// -// So each test: -// -// 1. allocates the nodes in the graph, -// -// 2. sets up the links in the graph, -// -// 3. clones the "ContextData" -// -// 4. chooses a new current mark value for this test -// -// 5. initiates a traversal, potentially from multiple starting points -// (aka "roots"), with a given control-string (potentially a -// different string for each root). if it does start from a -// distinct root, then such a test should also increment the -// current mark value, so that this traversal is considered -// distinct from the prior one on this graph structure. -// -// Note that most of the tests work with the default control string -// of all-zeroes. -// -// 6. assert that the context confirms that it actually saw a cycle (since a traversal -// might have terminated, e.g. on a tree structure that contained no cycles). - -use std::cell::{Cell, RefCell}; -use std::cmp::Ordering; -use std::collections::BinaryHeap; -use std::collections::HashMap; -use std::collections::LinkedList; -use std::collections::VecDeque; -use std::collections::btree_map::BTreeMap; -use std::collections::btree_set::BTreeSet; -use std::hash::{Hash, Hasher}; -use std::rc::Rc; -use std::sync::{Arc, RwLock, Mutex}; - -const PRINT: bool = false; - -pub fn main() { - let c_orig = ContextData { - curr_depth: 0, - max_depth: 3, - visited: 0, - max_visits: 1000, - skipped: 0, - curr_mark: 0, - saw_prev_marked: false, - control_bits: 0, - }; - - // SANITY CHECK FOR TEST SUITE (thus unnumbered) - // Not a cycle: { v[0] -> (v[1], v[2]), v[1] -> v[3], v[2] -> v[3] }; - let v: Vec = vec![Named::new("s0"), - Named::new("s1"), - Named::new("s2"), - Named::new("s3")]; - v[0].next.set((Some(&v[1]), Some(&v[2]))); - v[1].next.set((Some(&v[3]), None)); - v[2].next.set((Some(&v[3]), None)); - v[3].next.set((None, None)); - - let mut c = c_orig.clone(); - c.curr_mark = 10; - assert!(!c.saw_prev_marked); - v[0].descend_into_self(&mut c); - assert!(!c.saw_prev_marked); // <-- different from below, b/c acyclic above - - if PRINT { println!(""); } - - // Cycle 1: { v[0] -> v[1], v[1] -> v[0] }; - // does not exercise `v` itself - let v: Vec = vec![Named::new("s0"), - Named::new("s1")]; - v[0].next.set(Some(&v[1])); - v[1].next.set(Some(&v[0])); - - let mut c = c_orig.clone(); - c.curr_mark = 10; - assert!(!c.saw_prev_marked); - v[0].descend_into_self(&mut c); - assert!(c.saw_prev_marked); - - if PRINT { println!(""); } - - // Cycle 2: { v[0] -> v, v[1] -> v } - let v: V = Named::new("v"); - v.contents[0].set(Some(&v)); - v.contents[1].set(Some(&v)); - - let mut c = c_orig.clone(); - c.curr_mark = 20; - assert!(!c.saw_prev_marked); - v.descend_into_self(&mut c); - assert!(c.saw_prev_marked); - - if PRINT { println!(""); } - - // Cycle 3: { hk0 -> hv0, hv0 -> hk0, hk1 -> hv1, hv1 -> hk1 }; - // does not exercise `h` itself - - let mut h: HashMap = HashMap::new(); - h.insert(Named::new("hk0"), Named::new("hv0")); - h.insert(Named::new("hk1"), Named::new("hv1")); - for (key, val) in h.iter() { - val.next.set(Some(key)); - key.next.set(Some(val)); - } - - let mut c = c_orig.clone(); - c.curr_mark = 30; - for (key, _) in h.iter() { - c.curr_mark += 1; - c.saw_prev_marked = false; - key.descend_into_self(&mut c); - assert!(c.saw_prev_marked); - } - - if PRINT { println!(""); } - - // Cycle 4: { h -> (hmk0,hmv0,hmk1,hmv1), {hmk0,hmv0,hmk1,hmv1} -> h } - - let mut h: HashMap = HashMap::new(); - h.insert(Named::new("hmk0"), Named::new("hmv0")); - h.insert(Named::new("hmk0"), Named::new("hmv0")); - for (key, val) in h.iter() { - val.contents.set(Some(&h)); - key.contents.set(Some(&h)); - } - - let mut c = c_orig.clone(); - c.max_depth = 2; - c.curr_mark = 40; - for (key, _) in h.iter() { - c.curr_mark += 1; - c.saw_prev_marked = false; - key.descend_into_self(&mut c); - assert!(c.saw_prev_marked); - // break; - } - - if PRINT { println!(""); } - - // Cycle 5: { vd[0] -> vd[1], vd[1] -> vd[0] }; - // does not exercise vd itself - let mut vd: VecDeque = VecDeque::new(); - vd.push_back(Named::new("d0")); - vd.push_back(Named::new("d1")); - vd[0].next.set(Some(&vd[1])); - vd[1].next.set(Some(&vd[0])); - - let mut c = c_orig.clone(); - c.curr_mark = 50; - assert!(!c.saw_prev_marked); - vd[0].descend_into_self(&mut c); - assert!(c.saw_prev_marked); - - if PRINT { println!(""); } - - // Cycle 6: { vd -> (vd0, vd1), {vd0, vd1} -> vd } - let mut vd: VecDeque = VecDeque::new(); - vd.push_back(Named::new("vd0")); - vd.push_back(Named::new("vd1")); - vd[0].contents.set(Some(&vd)); - vd[1].contents.set(Some(&vd)); - - let mut c = c_orig.clone(); - c.curr_mark = 60; - assert!(!c.saw_prev_marked); - vd[0].descend_into_self(&mut c); - assert!(c.saw_prev_marked); - - if PRINT { println!(""); } - - // Cycle 7: { vm -> (vm0, vm1), {vm0, vm1} -> vm } - let mut vm: HashMap = HashMap::new(); - vm.insert(0, Named::new("vm0")); - vm.insert(1, Named::new("vm1")); - vm[&0].contents.set(Some(&vm)); - vm[&1].contents.set(Some(&vm)); - - let mut c = c_orig.clone(); - c.curr_mark = 70; - assert!(!c.saw_prev_marked); - vm[&0].descend_into_self(&mut c); - assert!(c.saw_prev_marked); - - if PRINT { println!(""); } - - // Cycle 8: { ll -> (ll0, ll1), {ll0, ll1} -> ll } - let mut ll: LinkedList = LinkedList::new(); - ll.push_back(Named::new("ll0")); - ll.push_back(Named::new("ll1")); - for e in &ll { - e.contents.set(Some(&ll)); - } - - let mut c = c_orig.clone(); - c.curr_mark = 80; - for e in &ll { - c.curr_mark += 1; - c.saw_prev_marked = false; - e.descend_into_self(&mut c); - assert!(c.saw_prev_marked); - // break; - } - - if PRINT { println!(""); } - - // Cycle 9: { bh -> (bh0, bh1), {bh0, bh1} -> bh } - let mut bh: BinaryHeap = BinaryHeap::new(); - bh.push(Named::new("bh0")); - bh.push(Named::new("bh1")); - for b in bh.iter() { - b.contents.set(Some(&bh)); - } - - let mut c = c_orig.clone(); - c.curr_mark = 90; - for b in &bh { - c.curr_mark += 1; - c.saw_prev_marked = false; - b.descend_into_self(&mut c); - assert!(c.saw_prev_marked); - // break; - } - - if PRINT { println!(""); } - - // Cycle 10: { btm -> (btk0, btv1), {bt0, bt1} -> btm } - let mut btm: BTreeMap = BTreeMap::new(); - btm.insert(Named::new("btk0"), Named::new("btv0")); - btm.insert(Named::new("btk1"), Named::new("btv1")); - for (k, v) in btm.iter() { - k.contents.set(Some(&btm)); - v.contents.set(Some(&btm)); - } - - let mut c = c_orig.clone(); - c.curr_mark = 100; - for (k, _) in &btm { - c.curr_mark += 1; - c.saw_prev_marked = false; - k.descend_into_self(&mut c); - assert!(c.saw_prev_marked); - // break; - } - - if PRINT { println!(""); } - - // Cycle 10: { bts -> (bts0, bts1), {bts0, bts1} -> btm } - let mut bts: BTreeSet = BTreeSet::new(); - bts.insert(Named::new("bts0")); - bts.insert(Named::new("bts1")); - for v in bts.iter() { - v.contents.set(Some(&bts)); - } - - let mut c = c_orig.clone(); - c.curr_mark = 100; - for b in &bts { - c.curr_mark += 1; - c.saw_prev_marked = false; - b.descend_into_self(&mut c); - assert!(c.saw_prev_marked); - // break; - } - - if PRINT { println!(""); } - - // Cycle 11: { rc0 -> (rc1, rc2), rc1 -> (), rc2 -> rc0 } - let (rc0, rc1, rc2): (RCRC, RCRC, RCRC); - rc0 = RCRC::new("rcrc0"); - rc1 = RCRC::new("rcrc1"); - rc2 = RCRC::new("rcrc2"); - rc0.0.borrow_mut().children.0 = Some(&rc1); - rc0.0.borrow_mut().children.1 = Some(&rc2); - rc2.0.borrow_mut().children.0 = Some(&rc0); - - let mut c = c_orig.clone(); - c.control_bits = 0b1; - c.curr_mark = 110; - assert!(!c.saw_prev_marked); - rc0.descend_into_self(&mut c); - assert!(c.saw_prev_marked); - - if PRINT { println!(""); } - - // We want to take the previous Rc case and generalize it to Arc. - // - // We can use refcells if we're single-threaded (as this test is). - // If one were to generalize these constructions to a - // multi-threaded context, then it might seem like we could choose - // between either a RwLock or a Mutex to hold the owned arcs on - // each node. - // - // Part of the point of this test is to actually confirm that the - // cycle exists by traversing it. We can do that just fine with an - // RwLock (since we can grab the child pointers in read-only - // mode), but we cannot lock a std::sync::Mutex to guard reading - // from each node via the same pattern, since once you hit the - // cycle, you'll be trying to acquiring the same lock twice. - // (We deal with this by exiting the traversal early if try_lock fails.) - - // Cycle 12: { arc0 -> (arc1, arc2), arc1 -> (), arc2 -> arc0 }, refcells - let (arc0, arc1, arc2): (ARCRC, ARCRC, ARCRC); - arc0 = ARCRC::new("arcrc0"); - arc1 = ARCRC::new("arcrc1"); - arc2 = ARCRC::new("arcrc2"); - arc0.0.borrow_mut().children.0 = Some(&arc1); - arc0.0.borrow_mut().children.1 = Some(&arc2); - arc2.0.borrow_mut().children.0 = Some(&arc0); - - let mut c = c_orig.clone(); - c.control_bits = 0b1; - c.curr_mark = 110; - assert!(!c.saw_prev_marked); - arc0.descend_into_self(&mut c); - assert!(c.saw_prev_marked); - - if PRINT { println!(""); } - - // Cycle 13: { arc0 -> (arc1, arc2), arc1 -> (), arc2 -> arc0 }, rwlocks - let (arc0, arc1, arc2): (ARCRW, ARCRW, ARCRW); - arc0 = ARCRW::new("arcrw0"); - arc1 = ARCRW::new("arcrw1"); - arc2 = ARCRW::new("arcrw2"); - arc0.0.write().unwrap().children.0 = Some(&arc1); - arc0.0.write().unwrap().children.1 = Some(&arc2); - arc2.0.write().unwrap().children.0 = Some(&arc0); - - let mut c = c_orig.clone(); - c.control_bits = 0b1; - c.curr_mark = 110; - assert!(!c.saw_prev_marked); - arc0.descend_into_self(&mut c); - assert!(c.saw_prev_marked); - - if PRINT { println!(""); } - - // Cycle 14: { arc0 -> (arc1, arc2), arc1 -> (), arc2 -> arc0 }, mutexs - let (arc0, arc1, arc2): (ARCM, ARCM, ARCM); - arc0 = ARCM::new("arcm0"); - arc1 = ARCM::new("arcm1"); - arc2 = ARCM::new("arcm2"); - arc0.1.lock().unwrap().children.0 = Some(&arc1); - arc0.1.lock().unwrap().children.1 = Some(&arc2); - arc2.1.lock().unwrap().children.0 = Some(&arc0); - - let mut c = c_orig.clone(); - c.control_bits = 0b1; - c.curr_mark = 110; - assert!(!c.saw_prev_marked); - arc0.descend_into_self(&mut c); - assert!(c.saw_prev_marked); -} - -trait Named { - fn new(_: &'static str) -> Self; - fn name(&self) -> &str; -} - -trait Marked { - fn mark(&self) -> M; - fn set_mark(&self, mark: M); -} - -struct S<'a> { - name: &'static str, - mark: Cell, - next: Cell>>, -} - -impl<'a> Named for S<'a> { - fn new(name: &'static str) -> S<'a> { - S { name: name, mark: Cell::new(0), next: Cell::new(None) } - } - fn name(&self) -> &str { self.name } -} - -impl<'a> Marked for S<'a> { - fn mark(&self) -> u32 { self.mark.get() } - fn set_mark(&self, mark: u32) { self.mark.set(mark); } -} - -struct S2<'a> { - name: &'static str, - mark: Cell, - next: Cell<(Option<&'a S2<'a>>, Option<&'a S2<'a>>)>, -} - -impl<'a> Named for S2<'a> { - fn new(name: &'static str) -> S2<'a> { - S2 { name: name, mark: Cell::new(0), next: Cell::new((None, None)) } - } - fn name(&self) -> &str { self.name } -} - -impl<'a> Marked for S2<'a> { - fn mark(&self) -> u32 { self.mark.get() } - fn set_mark(&self, mark: u32) { - self.mark.set(mark); - } -} - -struct V<'a> { - name: &'static str, - mark: Cell, - contents: Vec>>>, -} - -impl<'a> Named for V<'a> { - fn new(name: &'static str) -> V<'a> { - V { name: name, - mark: Cell::new(0), - contents: vec![Cell::new(None), Cell::new(None)] - } - } - fn name(&self) -> &str { self.name } -} - -impl<'a> Marked for V<'a> { - fn mark(&self) -> u32 { self.mark.get() } - fn set_mark(&self, mark: u32) { self.mark.set(mark); } -} - -#[derive(Eq)] -struct H<'a> { - name: &'static str, - mark: Cell, - next: Cell>>, -} - -impl<'a> Named for H<'a> { - fn new(name: &'static str) -> H<'a> { - H { name: name, mark: Cell::new(0), next: Cell::new(None) } - } - fn name(&self) -> &str { self.name } -} - -impl<'a> Marked for H<'a> { - fn mark(&self) -> u32 { self.mark.get() } - fn set_mark(&self, mark: u32) { self.mark.set(mark); } -} - -impl<'a> PartialEq for H<'a> { - fn eq(&self, rhs: &H<'a>) -> bool { - self.name == rhs.name - } -} - -impl<'a> Hash for H<'a> { - fn hash(&self, state: &mut H) { - self.name.hash(state) - } -} - -#[derive(Eq)] -struct HM<'a> { - name: &'static str, - mark: Cell, - contents: Cell, HM<'a>>>>, -} - -impl<'a> Named for HM<'a> { - fn new(name: &'static str) -> HM<'a> { - HM { name: name, - mark: Cell::new(0), - contents: Cell::new(None) - } - } - fn name(&self) -> &str { self.name } -} - -impl<'a> Marked for HM<'a> { - fn mark(&self) -> u32 { self.mark.get() } - fn set_mark(&self, mark: u32) { self.mark.set(mark); } -} - -impl<'a> PartialEq for HM<'a> { - fn eq(&self, rhs: &HM<'a>) -> bool { - self.name == rhs.name - } -} - -impl<'a> Hash for HM<'a> { - fn hash(&self, state: &mut H) { - self.name.hash(state) - } -} - - -struct VD<'a> { - name: &'static str, - mark: Cell, - contents: Cell>>>, -} - -impl<'a> Named for VD<'a> { - fn new(name: &'static str) -> VD<'a> { - VD { name: name, - mark: Cell::new(0), - contents: Cell::new(None) - } - } - fn name(&self) -> &str { self.name } -} - -impl<'a> Marked for VD<'a> { - fn mark(&self) -> u32 { self.mark.get() } - fn set_mark(&self, mark: u32) { self.mark.set(mark); } -} - -struct VM<'a> { - name: &'static str, - mark: Cell, - contents: Cell>>>, -} - -impl<'a> Named for VM<'a> { - fn new(name: &'static str) -> VM<'a> { - VM { name: name, - mark: Cell::new(0), - contents: Cell::new(None) - } - } - fn name(&self) -> &str { self.name } -} - -impl<'a> Marked for VM<'a> { - fn mark(&self) -> u32 { self.mark.get() } - fn set_mark(&self, mark: u32) { self.mark.set(mark); } -} - -struct LL<'a> { - name: &'static str, - mark: Cell, - contents: Cell>>>, -} - -impl<'a> Named for LL<'a> { - fn new(name: &'static str) -> LL<'a> { - LL { name: name, - mark: Cell::new(0), - contents: Cell::new(None) - } - } - fn name(&self) -> &str { self.name } -} - -impl<'a> Marked for LL<'a> { - fn mark(&self) -> u32 { self.mark.get() } - fn set_mark(&self, mark: u32) { self.mark.set(mark); } -} - -struct BH<'a> { - name: &'static str, - mark: Cell, - contents: Cell>>>, -} - -impl<'a> Named for BH<'a> { - fn new(name: &'static str) -> BH<'a> { - BH { name: name, - mark: Cell::new(0), - contents: Cell::new(None) - } - } - fn name(&self) -> &str { self.name } -} - -impl<'a> Marked for BH<'a> { - fn mark(&self) -> u32 { self.mark.get() } - fn set_mark(&self, mark: u32) { self.mark.set(mark); } -} - -impl<'a> Eq for BH<'a> { } - -impl<'a> PartialEq for BH<'a> { - fn eq(&self, rhs: &BH<'a>) -> bool { - self.name == rhs.name - } -} - -impl<'a> PartialOrd for BH<'a> { - fn partial_cmp(&self, rhs: &BH<'a>) -> Option { - Some(self.cmp(rhs)) - } -} - -impl<'a> Ord for BH<'a> { - fn cmp(&self, rhs: &BH<'a>) -> Ordering { - self.name.cmp(rhs.name) - } -} - -struct BTM<'a> { - name: &'static str, - mark: Cell, - contents: Cell, BTM<'a>>>>, -} - -impl<'a> Named for BTM<'a> { - fn new(name: &'static str) -> BTM<'a> { - BTM { name: name, - mark: Cell::new(0), - contents: Cell::new(None) - } - } - fn name(&self) -> &str { self.name } -} - -impl<'a> Marked for BTM<'a> { - fn mark(&self) -> u32 { self.mark.get() } - fn set_mark(&self, mark: u32) { self.mark.set(mark); } -} - -impl<'a> Eq for BTM<'a> { } - -impl<'a> PartialEq for BTM<'a> { - fn eq(&self, rhs: &BTM<'a>) -> bool { - self.name == rhs.name - } -} - -impl<'a> PartialOrd for BTM<'a> { - fn partial_cmp(&self, rhs: &BTM<'a>) -> Option { - Some(self.cmp(rhs)) - } -} - -impl<'a> Ord for BTM<'a> { - fn cmp(&self, rhs: &BTM<'a>) -> Ordering { - self.name.cmp(rhs.name) - } -} - -struct BTS<'a> { - name: &'static str, - mark: Cell, - contents: Cell>>>, -} - -impl<'a> Named for BTS<'a> { - fn new(name: &'static str) -> BTS<'a> { - BTS { name: name, - mark: Cell::new(0), - contents: Cell::new(None) - } - } - fn name(&self) -> &str { self.name } -} - -impl<'a> Marked for BTS<'a> { - fn mark(&self) -> u32 { self.mark.get() } - fn set_mark(&self, mark: u32) { self.mark.set(mark); } -} - -impl<'a> Eq for BTS<'a> { } - -impl<'a> PartialEq for BTS<'a> { - fn eq(&self, rhs: &BTS<'a>) -> bool { - self.name == rhs.name - } -} - -impl<'a> PartialOrd for BTS<'a> { - fn partial_cmp(&self, rhs: &BTS<'a>) -> Option { - Some(self.cmp(rhs)) - } -} - -impl<'a> Ord for BTS<'a> { - fn cmp(&self, rhs: &BTS<'a>) -> Ordering { - self.name.cmp(rhs.name) - } -} - -#[derive(Clone)] -struct RCRCData<'a> { - name: &'static str, - mark: Cell, - children: (Option<&'a RCRC<'a>>, Option<&'a RCRC<'a>>), -} -#[derive(Clone)] -struct RCRC<'a>(Rc>>); - -impl<'a> Named for RCRC<'a> { - fn new(name: &'static str) -> Self { - RCRC(Rc::new(RefCell::new(RCRCData { - name: name, mark: Cell::new(0), children: (None, None), }))) - } - fn name(&self) -> &str { self.0.borrow().name } -} - -impl<'a> Marked for RCRC<'a> { - fn mark(&self) -> u32 { self.0.borrow().mark.get() } - fn set_mark(&self, mark: u32) { self.0.borrow().mark.set(mark); } -} - -impl<'a> Children<'a> for RCRC<'a> { - fn count_children(&self) -> usize { 2 } - fn descend_one_child(&self, context: &mut C, index: usize) - where C: Context + PrePost, Self: Sized - { - let children = &self.0.borrow().children; - let child = match index { - 0 => if let Some(child) = children.0 { child } else { return; }, - 1 => if let Some(child) = children.1 { child } else { return; }, - _ => panic!("bad children"), - }; - // println!("S2 {} descending into child {} at index {}", self.name, child.name, index); - child.descend_into_self(context); - } -} -#[derive(Clone)] -struct ARCRCData<'a> { - name: &'static str, - mark: Cell, - children: (Option<&'a ARCRC<'a>>, Option<&'a ARCRC<'a>>), -} -#[derive(Clone)] -struct ARCRC<'a>(Arc>>); - -impl<'a> Named for ARCRC<'a> { - fn new(name: &'static str) -> Self { - ARCRC(Arc::new(RefCell::new(ARCRCData { - name: name, mark: Cell::new(0), children: (None, None), }))) - } - fn name(&self) -> &str { self.0.borrow().name } -} - -impl<'a> Marked for ARCRC<'a> { - fn mark(&self) -> u32 { self.0.borrow().mark.get() } - fn set_mark(&self, mark: u32) { self.0.borrow().mark.set(mark); } -} - -impl<'a> Children<'a> for ARCRC<'a> { - fn count_children(&self) -> usize { 2 } - fn descend_one_child(&self, context: &mut C, index: usize) - where C: Context + PrePost, Self: Sized - { - let children = &self.0.borrow().children; - match index { - 0 => if let Some(ref child) = children.0 { - child.descend_into_self(context); - }, - 1 => if let Some(ref child) = children.1 { - child.descend_into_self(context); - }, - _ => panic!("bad children!"), - } - } -} - -#[derive(Clone)] -struct ARCMData<'a> { - mark: Cell, - children: (Option<&'a ARCM<'a>>, Option<&'a ARCM<'a>>), -} - -#[derive(Clone)] -struct ARCM<'a>(&'static str, Arc>>); - -impl<'a> Named for ARCM<'a> { - fn new(name: &'static str) -> Self { - ARCM(name, Arc::new(Mutex::new(ARCMData { - mark: Cell::new(0), children: (None, None), }))) - } - fn name(&self) -> &str { self.0 } -} - -impl<'a> Marked for ARCM<'a> { - fn mark(&self) -> u32 { self.1.lock().unwrap().mark.get() } - fn set_mark(&self, mark: u32) { self.1.lock().unwrap().mark.set(mark); } -} - -impl<'a> Children<'a> for ARCM<'a> { - fn count_children(&self) -> usize { 2 } - fn descend_one_child(&self, context: &mut C, index: usize) - where C: Context + PrePost, Self: Sized - { - let ref children = if let Ok(data) = self.1.try_lock() { - data.children - } else { return; }; - match index { - 0 => if let Some(ref child) = children.0 { - child.descend_into_self(context); - }, - 1 => if let Some(ref child) = children.1 { - child.descend_into_self(context); - }, - _ => panic!("bad children!"), - } - } -} - -#[derive(Clone)] -struct ARCRWData<'a> { - name: &'static str, - mark: Cell, - children: (Option<&'a ARCRW<'a>>, Option<&'a ARCRW<'a>>), -} - -#[derive(Clone)] -struct ARCRW<'a>(Arc>>); - -impl<'a> Named for ARCRW<'a> { - fn new(name: &'static str) -> Self { - ARCRW(Arc::new(RwLock::new(ARCRWData { - name: name, mark: Cell::new(0), children: (None, None), }))) - } - fn name(&self) -> &str { self.0.read().unwrap().name } -} - -impl<'a> Marked for ARCRW<'a> { - fn mark(&self) -> u32 { self.0.read().unwrap().mark.get() } - fn set_mark(&self, mark: u32) { self.0.read().unwrap().mark.set(mark); } -} - -impl<'a> Children<'a> for ARCRW<'a> { - fn count_children(&self) -> usize { 2 } - fn descend_one_child(&self, context: &mut C, index: usize) - where C: Context + PrePost, Self: Sized - { - let children = &self.0.read().unwrap().children; - match index { - 0 => if let Some(ref child) = children.0 { - child.descend_into_self(context); - }, - 1 => if let Some(ref child) = children.1 { - child.descend_into_self(context); - }, - _ => panic!("bad children!"), - } - } -} - -trait Context { - fn next_index(&mut self, len: usize) -> usize; - fn should_act(&self) -> bool; - fn increase_visited(&mut self); - fn increase_skipped(&mut self); - fn increase_depth(&mut self); - fn decrease_depth(&mut self); -} - -trait PrePost { - fn pre(&mut self, _: &T); - fn post(&mut self, _: &T); - fn hit_limit(&mut self, _: &T); -} - -trait Children<'a> { - fn count_children(&self) -> usize; - fn descend_one_child(&self, context: &mut C, index: usize) - where C: Context + PrePost, Self: Sized; - - fn next_child(&self, context: &mut C) - where C: Context + PrePost, Self: Sized - { - let index = context.next_index(self.count_children()); - self.descend_one_child(context, index); - } - - fn descend_into_self(&self, context: &mut C) - where C: Context + PrePost, Self: Sized - { - context.pre(self); - if context.should_act() { - context.increase_visited(); - context.increase_depth(); - self.next_child(context); - context.decrease_depth(); - } else { - context.hit_limit(self); - context.increase_skipped(); - } - context.post(self); - } - - fn descend<'b, C>(&self, c: &Cell>, context: &mut C) - where C: Context + PrePost, Self: Sized - { - if let Some(r) = c.get() { - r.descend_into_self(context); - } - } -} - -impl<'a> Children<'a> for S<'a> { - fn count_children(&self) -> usize { 1 } - fn descend_one_child(&self, context: &mut C, _: usize) - where C: Context + PrePost, Self: Sized { - self.descend(&self.next, context); - } -} - -impl<'a> Children<'a> for S2<'a> { - fn count_children(&self) -> usize { 2 } - fn descend_one_child(&self, context: &mut C, index: usize) - where C: Context + PrePost, Self: Sized - { - let children = self.next.get(); - let child = match index { - 0 => if let Some(child) = children.0 { child } else { return; }, - 1 => if let Some(child) = children.1 { child } else { return; }, - _ => panic!("bad children"), - }; - // println!("S2 {} descending into child {} at index {}", self.name, child.name, index); - child.descend_into_self(context); - } -} - -impl<'a> Children<'a> for V<'a> { - fn count_children(&self) -> usize { self.contents.len() } - fn descend_one_child(&self, context: &mut C, index: usize) - where C: Context + PrePost, Self: Sized - { - if let Some(child) = self.contents[index].get() { - child.descend_into_self(context); - } - } -} - -impl<'a> Children<'a> for H<'a> { - fn count_children(&self) -> usize { 1 } - fn descend_one_child(&self, context: &mut C, _: usize) - where C: Context + PrePost, Self: Sized - { - self.descend(&self.next, context); - } -} - -impl<'a> Children<'a> for HM<'a> { - fn count_children(&self) -> usize { - if let Some(m) = self.contents.get() { 2 * m.iter().count() } else { 0 } - } - fn descend_one_child(&self, context: &mut C, index: usize) - where C: Context + PrePost, Self: Sized - { - if let Some(ref hm) = self.contents.get() { - for (k, v) in hm.iter().nth(index / 2) { - [k, v][index % 2].descend_into_self(context); - } - } - } -} - -impl<'a> Children<'a> for VD<'a> { - fn count_children(&self) -> usize { - if let Some(d) = self.contents.get() { d.iter().count() } else { 0 } - } - fn descend_one_child(&self, context: &mut C, index: usize) - where C: Context + PrePost, Self: Sized - { - if let Some(ref vd) = self.contents.get() { - for r in vd.iter().nth(index) { - r.descend_into_self(context); - } - } - } -} - -impl<'a> Children<'a> for VM<'a> { - fn count_children(&self) -> usize { - if let Some(m) = self.contents.get() { m.iter().count() } else { 0 } - } - fn descend_one_child(&self, context: &mut C, index: usize) - where C: Context + PrePost> - { - if let Some(ref vd) = self.contents.get() { - for (_idx, r) in vd.iter().nth(index) { - r.descend_into_self(context); - } - } - } -} - -impl<'a> Children<'a> for LL<'a> { - fn count_children(&self) -> usize { - if let Some(l) = self.contents.get() { l.iter().count() } else { 0 } - } - fn descend_one_child(&self, context: &mut C, index: usize) - where C: Context + PrePost> - { - if let Some(ref ll) = self.contents.get() { - for r in ll.iter().nth(index) { - r.descend_into_self(context); - } - } - } -} - -impl<'a> Children<'a> for BH<'a> { - fn count_children(&self) -> usize { - if let Some(h) = self.contents.get() { h.iter().count() } else { 0 } - } - fn descend_one_child(&self, context: &mut C, index: usize) - where C: Context + PrePost> - { - if let Some(ref bh) = self.contents.get() { - for r in bh.iter().nth(index) { - r.descend_into_self(context); - } - } - } -} - -impl<'a> Children<'a> for BTM<'a> { - fn count_children(&self) -> usize { - if let Some(m) = self.contents.get() { 2 * m.iter().count() } else { 0 } - } - fn descend_one_child(&self, context: &mut C, index: usize) - where C: Context + PrePost> - { - if let Some(ref bh) = self.contents.get() { - for (k, v) in bh.iter().nth(index / 2) { - [k, v][index % 2].descend_into_self(context); - } - } - } -} - -impl<'a> Children<'a> for BTS<'a> { - fn count_children(&self) -> usize { - if let Some(s) = self.contents.get() { s.iter().count() } else { 0 } - } - fn descend_one_child(&self, context: &mut C, index: usize) - where C: Context + PrePost> - { - if let Some(ref bh) = self.contents.get() { - for r in bh.iter().nth(index) { - r.descend_into_self(context); - } - } - } -} - -#[derive(Copy, Clone)] -struct ContextData { - curr_depth: usize, - max_depth: usize, - visited: usize, - max_visits: usize, - skipped: usize, - curr_mark: u32, - saw_prev_marked: bool, - control_bits: u64, -} - -impl Context for ContextData { - fn next_index(&mut self, len: usize) -> usize { - if len < 2 { return 0; } - let mut pow2 = len.next_power_of_two(); - let _pow2_orig = pow2; - let mut idx = 0; - let mut bits = self.control_bits; - while pow2 > 1 { - idx = (idx << 1) | (bits & 1) as usize; - bits = bits >> 1; - pow2 = pow2 >> 1; - } - idx = idx % len; - // println!("next_index({} [{:b}]) says {}, pre(bits): {:b} post(bits): {:b}", - // len, _pow2_orig, idx, self.control_bits, bits); - self.control_bits = bits; - return idx; - } - fn should_act(&self) -> bool { - self.curr_depth < self.max_depth && self.visited < self.max_visits - } - fn increase_visited(&mut self) { self.visited += 1; } - fn increase_skipped(&mut self) { self.skipped += 1; } - fn increase_depth(&mut self) { self.curr_depth += 1; } - fn decrease_depth(&mut self) { self.curr_depth -= 1; } -} - -impl> PrePost for ContextData { - fn pre(&mut self, t: &T) { - for _ in 0..self.curr_depth { - if PRINT { print!(" "); } - } - if PRINT { println!("prev {}", t.name()); } - if t.mark() == self.curr_mark { - for _ in 0..self.curr_depth { - if PRINT { print!(" "); } - } - if PRINT { println!("(probably previously marked)"); } - self.saw_prev_marked = true; - } - t.set_mark(self.curr_mark); - } - fn post(&mut self, t: &T) { - for _ in 0..self.curr_depth { - if PRINT { print!(" "); } - } - if PRINT { println!("post {}", t.name()); } - } - fn hit_limit(&mut self, t: &T) { - for _ in 0..self.curr_depth { - if PRINT { print!(" "); } - } - if PRINT { println!("LIMIT {}", t.name()); } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-on-empty-block-exit.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-on-empty-block-exit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-on-empty-block-exit.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-on-empty-block-exit.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 -#![allow(non_camel_case_types)] - -#![feature(box_syntax)] - -enum t { foo(Box), } - -pub fn main() { - let tt = t::foo(box 10); - match tt { t::foo(_z) => { } } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-on-ret.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-on-ret.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-on-ret.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-on-ret.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - -// pretty-expanded FIXME #23616 - -fn f() -> isize { - if true { - let _s: String = "should not leak".to_string(); - return 1; - } - return 0; -} - -pub fn main() { f(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-struct-as-object.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-struct-as-object.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-struct-as-object.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-struct-as-object.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -// Test that destructor on a struct runs successfully after the struct -// is boxed and converted to an object. - -#![feature(box_syntax)] - -static mut value: usize = 0; - -struct Cat { - name : usize, -} - -trait Dummy { - fn get(&self) -> usize; -} - -impl Dummy for Cat { - fn get(&self) -> usize { self.name } -} - -impl Drop for Cat { - fn drop(&mut self) { - unsafe { value = self.name; } - } -} - -pub fn main() { - { - let x = box Cat {name: 22}; - let nyan: Box = x as Box; - } - unsafe { - assert_eq!(value, 22); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-trait-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-trait-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-trait-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-trait-enum.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -#![feature(box_syntax)] - -use std::thread; -use std::sync::mpsc::{channel, Sender}; - -#[derive(PartialEq, Debug)] -enum Message { - Dropped, - DestructorRan -} - -struct SendOnDrop { - sender: Sender -} - -impl Drop for SendOnDrop { - fn drop(&mut self) { - self.sender.send(Message::Dropped).unwrap(); - } -} - -enum Foo { - SimpleVariant(Sender), - NestedVariant(Box, SendOnDrop, Sender), - FailingVariant { on_drop: SendOnDrop } -} - -impl Drop for Foo { - fn drop(&mut self) { - match self { - &mut Foo::SimpleVariant(ref mut sender) => { - sender.send(Message::DestructorRan).unwrap(); - } - &mut Foo::NestedVariant(_, _, ref mut sender) => { - sender.send(Message::DestructorRan).unwrap(); - } - &mut Foo::FailingVariant { .. } => { - panic!("Failed"); - } - } - } -} - -pub fn main() { - let (sender, receiver) = channel(); - { - let v = Foo::SimpleVariant(sender); - } - assert_eq!(receiver.recv().unwrap(), Message::DestructorRan); - assert_eq!(receiver.recv().ok(), None); - - let (sender, receiver) = channel(); - { - let v = Foo::NestedVariant(box 42, SendOnDrop { sender: sender.clone() }, sender); - } - assert_eq!(receiver.recv().unwrap(), Message::DestructorRan); - assert_eq!(receiver.recv().unwrap(), Message::Dropped); - assert_eq!(receiver.recv().ok(), None); - - let (sender, receiver) = channel(); - let t = thread::spawn(move|| { - let v = Foo::FailingVariant { on_drop: SendOnDrop { sender: sender } }; - }); - assert_eq!(receiver.recv().unwrap(), Message::Dropped); - assert_eq!(receiver.recv().ok(), None); - drop(t.join()); - - let (sender, receiver) = channel(); - let t = { - thread::spawn(move|| { - let mut v = Foo::NestedVariant(box 42, SendOnDrop { - sender: sender.clone() - }, sender.clone()); - v = Foo::NestedVariant(box 42, - SendOnDrop { sender: sender.clone() }, - sender.clone()); - v = Foo::SimpleVariant(sender.clone()); - v = Foo::FailingVariant { on_drop: SendOnDrop { sender: sender } }; - }) - }; - assert_eq!(receiver.recv().unwrap(), Message::DestructorRan); - assert_eq!(receiver.recv().unwrap(), Message::Dropped); - assert_eq!(receiver.recv().unwrap(), Message::DestructorRan); - assert_eq!(receiver.recv().unwrap(), Message::Dropped); - assert_eq!(receiver.recv().unwrap(), Message::DestructorRan); - assert_eq!(receiver.recv().unwrap(), Message::Dropped); - assert_eq!(receiver.recv().ok(), None); - drop(t.join()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-trait-generic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-trait-generic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-trait-generic.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-trait-generic.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct S { - x: T -} - -impl ::std::ops::Drop for S { - fn drop(&mut self) { - println!("bye"); - } -} - -pub fn main() { - let _x = S { x: 1 }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-trait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct Foo { - x: isize -} - -impl Drop for Foo { - fn drop(&mut self) { - println!("bye"); - } -} - -pub fn main() { - let _x: Foo = Foo { x: 3 }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-uninhabited-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-uninhabited-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-uninhabited-enum.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-uninhabited-enum.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -enum Foo { } - -impl Drop for Foo { - fn drop(&mut self) { } -} - -fn foo(x: Foo) { } - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-with-type-ascription-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-with-type-ascription-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-with-type-ascription-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-with-type-ascription-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn main() { - let foo = "hello".to_string(); - let foo: Vec<&str> = foo.split_whitespace().collect(); - let invalid_string = &foo[0]; - assert_eq!(*invalid_string, "hello"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-with-type-ascription-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-with-type-ascription-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-with-type-ascription-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/drop-with-type-ascription-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn main() { - let args = vec!["foobie", "asdf::asdf"]; - let arr: Vec<&str> = args[1].split("::").collect(); - assert_eq!(arr[0], "asdf"); - assert_eq!(arr[0], "asdf"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/dynamic-drop.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/dynamic-drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/dynamic-drop.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/dynamic-drop.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,355 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// revisions:lexical nll -#![cfg_attr(nll, feature(nll))] - -// ignore-wasm32-bare compiled with panic=abort by default - -#![feature(generators, generator_trait, untagged_unions)] -#![feature(slice_patterns)] - -use std::cell::{Cell, RefCell}; -use std::ops::Generator; -use std::panic; -use std::usize; - -struct InjectedFailure; - -struct Allocator { - data: RefCell>, - failing_op: usize, - cur_ops: Cell, -} - -impl panic::UnwindSafe for Allocator {} -impl panic::RefUnwindSafe for Allocator {} - -impl Drop for Allocator { - fn drop(&mut self) { - let data = self.data.borrow(); - if data.iter().any(|d| *d) { - panic!("missing free: {:?}", data); - } - } -} - -impl Allocator { - fn new(failing_op: usize) -> Self { - Allocator { - failing_op: failing_op, - cur_ops: Cell::new(0), - data: RefCell::new(vec![]) - } - } - fn alloc(&self) -> Ptr { - self.cur_ops.set(self.cur_ops.get() + 1); - - if self.cur_ops.get() == self.failing_op { - panic!(InjectedFailure); - } - - let mut data = self.data.borrow_mut(); - let addr = data.len(); - data.push(true); - Ptr(addr, self) - } -} - -struct Ptr<'a>(usize, &'a Allocator); -impl<'a> Drop for Ptr<'a> { - fn drop(&mut self) { - match self.1.data.borrow_mut()[self.0] { - false => { - panic!("double free at index {:?}", self.0) - } - ref mut d => *d = false - } - - self.1.cur_ops.set(self.1.cur_ops.get()+1); - - if self.1.cur_ops.get() == self.1.failing_op { - panic!(InjectedFailure); - } - } -} - -fn dynamic_init(a: &Allocator, c: bool) { - let _x; - if c { - _x = Some(a.alloc()); - } -} - -fn dynamic_drop(a: &Allocator, c: bool) { - let x = a.alloc(); - if c { - Some(x) - } else { - None - }; -} - -struct TwoPtrs<'a>(Ptr<'a>, Ptr<'a>); -fn struct_dynamic_drop(a: &Allocator, c0: bool, c1: bool, c: bool) { - for i in 0..2 { - let x; - let y; - if (c0 && i == 0) || (c1 && i == 1) { - x = (a.alloc(), a.alloc(), a.alloc()); - y = TwoPtrs(a.alloc(), a.alloc()); - if c { - drop(x.1); - drop(y.0); - } - } - } -} - -fn field_assignment(a: &Allocator, c0: bool) { - let mut x = (TwoPtrs(a.alloc(), a.alloc()), a.alloc()); - - x.1 = a.alloc(); - x.1 = a.alloc(); - - let f = (x.0).0; - if c0 { - (x.0).0 = f; - } -} - -fn assignment2(a: &Allocator, c0: bool, c1: bool) { - let mut _v = a.alloc(); - let mut _w = a.alloc(); - if c0 { - drop(_v); - } - _v = _w; - if c1 { - _w = a.alloc(); - } -} - -fn assignment1(a: &Allocator, c0: bool) { - let mut _v = a.alloc(); - let mut _w = a.alloc(); - if c0 { - drop(_v); - } - _v = _w; -} - -#[allow(unions_with_drop_fields)] -union Boxy { - a: T, - b: T, -} - -fn union1(a: &Allocator) { - unsafe { - let mut u = Boxy { a: a.alloc() }; - u.b = a.alloc(); - drop(u.a); - } -} - -fn array_simple(a: &Allocator) { - let _x = [a.alloc(), a.alloc(), a.alloc(), a.alloc()]; -} - -fn vec_simple(a: &Allocator) { - let _x = vec![a.alloc(), a.alloc(), a.alloc(), a.alloc()]; -} - -fn generator(a: &Allocator, run_count: usize) { - assert!(run_count < 4); - - let mut gen = || { - (a.alloc(), - yield a.alloc(), - a.alloc(), - yield a.alloc() - ); - }; - for _ in 0..run_count { - unsafe { gen.resume(); } - } -} - -fn mixed_drop_and_nondrop(a: &Allocator) { - // check that destructor panics handle drop - // and non-drop blocks in the same scope correctly. - // - // Surprisingly enough, this used to not work. - let (x, y, z); - x = a.alloc(); - y = 5; - z = a.alloc(); -} - -#[allow(unreachable_code)] -fn vec_unreachable(a: &Allocator) { - let _x = vec![a.alloc(), a.alloc(), a.alloc(), return]; -} - -fn slice_pattern_first(a: &Allocator) { - let[_x, ..] = [a.alloc(), a.alloc(), a.alloc()]; -} - -fn slice_pattern_middle(a: &Allocator) { - let[_, _x, _] = [a.alloc(), a.alloc(), a.alloc()]; -} - -fn slice_pattern_two(a: &Allocator) { - let[_x, _, _y, _] = [a.alloc(), a.alloc(), a.alloc(), a.alloc()]; -} - -fn slice_pattern_last(a: &Allocator) { - let[.., _y] = [a.alloc(), a.alloc(), a.alloc(), a.alloc()]; -} - -fn slice_pattern_one_of(a: &Allocator, i: usize) { - let array = [a.alloc(), a.alloc(), a.alloc(), a.alloc()]; - let _x = match i { - 0 => { let [a, ..] = array; a } - 1 => { let [_, a, ..] = array; a } - 2 => { let [_, _, a, _] = array; a } - 3 => { let [_, _, _, a] = array; a } - _ => panic!("unmatched"), - }; -} - -fn subslice_pattern_from_end(a: &Allocator, arg: bool) { - let a = [a.alloc(), a.alloc(), a.alloc()]; - if arg { - let[.., _x, _] = a; - } else { - let[_, _y..] = a; - } -} - -fn subslice_pattern_from_end_with_drop(a: &Allocator, arg: bool, arg2: bool) { - let a = [a.alloc(), a.alloc(), a.alloc(), a.alloc(), a.alloc()]; - if arg2 { - drop(a); - return; - } - - if arg { - let[.., _x, _] = a; - } else { - let[_, _y..] = a; - } -} - -fn slice_pattern_reassign(a: &Allocator) { - let mut ar = [a.alloc(), a.alloc()]; - let[_, _x] = ar; - ar = [a.alloc(), a.alloc()]; - let[.., _y] = ar; -} - -fn subslice_pattern_reassign(a: &Allocator) { - let mut ar = [a.alloc(), a.alloc(), a.alloc()]; - let[_, _, _x] = ar; - ar = [a.alloc(), a.alloc(), a.alloc()]; - let[_, _y..] = ar; -} - -fn run_test(mut f: F) - where F: FnMut(&Allocator) -{ - let first_alloc = Allocator::new(usize::MAX); - f(&first_alloc); - - for failing_op in 1..first_alloc.cur_ops.get()+1 { - let alloc = Allocator::new(failing_op); - let alloc = &alloc; - let f = panic::AssertUnwindSafe(&mut f); - let result = panic::catch_unwind(move || { - f.0(alloc); - }); - match result { - Ok(..) => panic!("test executed {} ops but now {}", - first_alloc.cur_ops.get(), alloc.cur_ops.get()), - Err(e) => { - if e.downcast_ref::().is_none() { - panic::resume_unwind(e); - } - } - } - } -} - -fn run_test_nopanic(mut f: F) - where F: FnMut(&Allocator) -{ - let first_alloc = Allocator::new(usize::MAX); - f(&first_alloc); -} - -fn main() { - run_test(|a| dynamic_init(a, false)); - run_test(|a| dynamic_init(a, true)); - run_test(|a| dynamic_drop(a, false)); - run_test(|a| dynamic_drop(a, true)); - - run_test(|a| assignment2(a, false, false)); - run_test(|a| assignment2(a, false, true)); - run_test(|a| assignment2(a, true, false)); - run_test(|a| assignment2(a, true, true)); - - run_test(|a| assignment1(a, false)); - run_test(|a| assignment1(a, true)); - - run_test(|a| array_simple(a)); - run_test(|a| vec_simple(a)); - run_test(|a| vec_unreachable(a)); - - run_test(|a| struct_dynamic_drop(a, false, false, false)); - run_test(|a| struct_dynamic_drop(a, false, false, true)); - run_test(|a| struct_dynamic_drop(a, false, true, false)); - run_test(|a| struct_dynamic_drop(a, false, true, true)); - run_test(|a| struct_dynamic_drop(a, true, false, false)); - run_test(|a| struct_dynamic_drop(a, true, false, true)); - run_test(|a| struct_dynamic_drop(a, true, true, false)); - run_test(|a| struct_dynamic_drop(a, true, true, true)); - - run_test(|a| field_assignment(a, false)); - run_test(|a| field_assignment(a, true)); - - run_test(|a| generator(a, 0)); - run_test(|a| generator(a, 1)); - run_test(|a| generator(a, 2)); - run_test(|a| generator(a, 3)); - - run_test(|a| mixed_drop_and_nondrop(a)); - - run_test(|a| slice_pattern_first(a)); - run_test(|a| slice_pattern_middle(a)); - run_test(|a| slice_pattern_two(a)); - run_test(|a| slice_pattern_last(a)); - run_test(|a| slice_pattern_one_of(a, 0)); - run_test(|a| slice_pattern_one_of(a, 1)); - run_test(|a| slice_pattern_one_of(a, 2)); - run_test(|a| slice_pattern_one_of(a, 3)); - - run_test(|a| subslice_pattern_from_end(a, true)); - run_test(|a| subslice_pattern_from_end(a, false)); - run_test(|a| subslice_pattern_from_end_with_drop(a, true, true)); - run_test(|a| subslice_pattern_from_end_with_drop(a, true, false)); - run_test(|a| subslice_pattern_from_end_with_drop(a, false, true)); - run_test(|a| subslice_pattern_from_end_with_drop(a, false, false)); - run_test(|a| slice_pattern_reassign(a)); - run_test(|a| subslice_pattern_reassign(a)); - - run_test_nopanic(|a| union1(a)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/no-drop-flag-size.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/no-drop-flag-size.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/no-drop-flag-size.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/no-drop-flag-size.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::mem::size_of; - -struct Test { - a: T -} - -impl Drop for Test { - fn drop(&mut self) { } -} - -pub fn main() { - assert_eq!(size_of::(), size_of::>()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/nondrop-cycle.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/nondrop-cycle.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/drop/nondrop-cycle.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/drop/nondrop-cycle.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -use std::cell::Cell; - -struct C<'a> { - p: Cell>>, -} - -impl<'a> C<'a> { - fn new() -> C<'a> { C { p: Cell::new(None) } } -} - -fn f1() { - let (c1, c2) = (C::new(), C::new()); - c1.p.set(Some(&c2)); - c2.p.set(Some(&c1)); -} - -fn f2() { - let (c1, c2); - c1 = C::new(); - c2 = C::new(); - c1.p.set(Some(&c2)); - c2.p.set(Some(&c1)); -} - -fn main() { - f1(); - f2(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-coerce-custom.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-coerce-custom.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-coerce-custom.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-coerce-custom.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test a very simple custom DST coercion. - -#![feature(unsize, coerce_unsized)] - -use std::ops::CoerceUnsized; -use std::marker::Unsize; - -struct Bar { - x: *const T, -} - -impl, U: ?Sized> CoerceUnsized> for Bar {} - -trait Baz { - fn get(&self) -> i32; -} - -impl Baz for i32 { - fn get(&self) -> i32 { - *self - } -} - -fn main() { - // Arrays. - let a: Bar<[i32; 3]> = Bar { x: &[1, 2, 3] }; - // This is the actual coercion. - let b: Bar<[i32]> = a; - - unsafe { - assert_eq!((*b.x)[0], 1); - assert_eq!((*b.x)[1], 2); - assert_eq!((*b.x)[2], 3); - } - - // Trait objects. - let a: Bar = Bar { x: &42 }; - let b: Bar = a; - unsafe { - assert_eq!((*b.x).get(), 42); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-coerce-rc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-coerce-rc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-coerce-rc.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-coerce-rc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] -// Test a very simple custom DST coercion. - -#![feature(core, rc_weak)] - -use std::cell::RefCell; -use std::rc::{Rc, Weak}; - -trait Baz { - fn get(&self) -> i32; -} - -impl Baz for i32 { - fn get(&self) -> i32 { - *self - } -} - -fn main() { - let a: Rc<[i32; 3]> = Rc::new([1, 2, 3]); - let b: Rc<[i32]> = a; - assert_eq!(b[0], 1); - assert_eq!(b[1], 2); - assert_eq!(b[2], 3); - - let a: Rc = Rc::new(42); - let b: Rc = a.clone(); - assert_eq!(b.get(), 42); - - let c: Weak = Rc::downgrade(&a); - let d: Weak = c.clone(); - - let _c = b.clone(); - - let a: Rc> = Rc::new(RefCell::new(42)); - let b: Rc> = a.clone(); - assert_eq!(b.borrow().get(), 42); - // FIXME - let c: Weak> = Rc::downgrade(&a) as Weak<_>; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-coercions.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-coercions.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-coercions.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-coercions.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test coercions involving DST and/or raw pointers - -// pretty-expanded FIXME #23616 - -struct S; -trait T { fn dummy(&self) { } } -impl T for S {} - -pub fn main() { - let x: &T = &S; - // Test we can convert from &-ptr to *-ptr of trait objects - let x: *const T = &S; - - // Test we can convert from &-ptr to *-ptr of struct pointer (not DST) - let x: *const S = &S; - - // As above, but mut - let x: &mut T = &mut S; - let x: *mut T = &mut S; - - let x: *mut S = &mut S; - - // Test we can change the mutability from mut to const. - let x: &T = &mut S; - let x: *const T = &mut S; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-deref-mut.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-deref-mut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-deref-mut.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-deref-mut.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that a custom deref with a fat pointer return type does not ICE - - -use std::ops::{Deref, DerefMut}; - -pub struct Arr { - ptr: Box<[usize]> -} - -impl Deref for Arr { - type Target = [usize]; - - fn deref(&self) -> &[usize] { - panic!(); - } -} - -impl DerefMut for Arr { - fn deref_mut(&mut self) -> &mut [usize] { - &mut *self.ptr - } -} - -pub fn foo(arr: &mut Arr) { - let x: &mut [usize] = &mut **arr; - assert_eq!(x[0], 1); - assert_eq!(x[1], 2); - assert_eq!(x[2], 3); -} - -fn main() { - let mut a = Arr { ptr: Box::new([1, 2, 3]) }; - foo(&mut a); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-deref.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-deref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-deref.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-deref.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that a custom deref with a fat pointer return type does not ICE - - -use std::ops::Deref; - -pub struct Arr { - ptr: Box<[usize]> -} - -impl Deref for Arr { - type Target = [usize]; - - fn deref(&self) -> &[usize] { - &*self.ptr - } -} - -pub fn foo(arr: &Arr) { - assert_eq!(arr.len(), 3); - let x: &[usize] = &**arr; - assert_eq!(x[0], 1); - assert_eq!(x[1], 2); - assert_eq!(x[2], 3); -} - -fn main() { - let a = Arr { ptr: Box::new([1, 2, 3]) }; - foo(&a); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-field-align.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-field-align.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-field-align.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-field-align.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct Foo { - a: u16, - b: T -} - -trait Bar { - fn get(&self) -> usize; -} - -impl Bar for usize { - fn get(&self) -> usize { *self } -} - -struct Baz { - a: T -} - -struct HasDrop { - ptr: Box, - data: T -} - -fn main() { - // Test that zero-offset works properly - let b : Baz = Baz { a: 7 }; - assert_eq!(b.a.get(), 7); - let b : &Baz = &b; - assert_eq!(b.a.get(), 7); - - // Test that the field is aligned properly - let f : Foo = Foo { a: 0, b: 11 }; - assert_eq!(f.b.get(), 11); - let ptr1 : *const u8 = &f.b as *const _ as *const u8; - - let f : &Foo = &f; - let ptr2 : *const u8 = &f.b as *const _ as *const u8; - assert_eq!(f.b.get(), 11); - - // The pointers should be the same - assert_eq!(ptr1, ptr2); - - // Test that nested DSTs work properly - let f : Foo> = Foo { a: 0, b: Foo { a: 1, b: 17 }}; - assert_eq!(f.b.b.get(), 17); - let f : &Foo> = &f; - assert_eq!(f.b.b.get(), 17); - - // Test that get the pointer via destructuring works - - let f : Foo = Foo { a: 0, b: 11 }; - let f : &Foo = &f; - let &Foo { a: _, b: ref bar } = f; - assert_eq!(bar.get(), 11); - - // Make sure that drop flags don't screw things up - - let d : HasDrop> = HasDrop { - ptr: Box::new(0), - data: Baz { a: [1,2,3,4] } - }; - assert_eq!([1,2,3,4], d.data.a); - - let d : &HasDrop> = &d; - assert_eq!(&[1,2,3,4], &d.data.a); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-index.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-index.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-index.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-index.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that overloaded index expressions with DST result types -// work and don't ICE. - -use std::ops::Index; -use std::fmt::Debug; - -struct S; - -impl Index for S { - type Output = str; - - fn index<'a>(&'a self, _: usize) -> &'a str { - "hello" - } -} - -struct T; - -impl Index for T { - type Output = Debug + 'static; - - fn index<'a>(&'a self, idx: usize) -> &'a (Debug + 'static) { - static X: usize = 42; - &X as &(Debug + 'static) - } -} - -fn main() { - assert_eq!(&S[0], "hello"); - &T[0]; - // let x = &x as &Debug; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-irrefutable-bind.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-irrefutable-bind.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-irrefutable-bind.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-irrefutable-bind.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(unsized_tuple_coercion)] - -struct Test(T); - -fn main() { - let x = Test([1,2,3]); - let x : &Test<[i32]> = &x; - - let & ref _y = x; - - // Make sure binding to a fat pointer behind a reference - // still works - let slice = &[1,2,3]; - let x = Test(&slice); - let Test(&_slice) = x; - - - let x = (10, [1,2,3]); - let x : &(i32, [i32]) = &x; - - let & ref _y = x; - - let slice = &[1,2,3]; - let x = (10, &slice); - let (_, &_slice) = x; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-raw.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-raw.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-raw.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-raw.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,148 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test DST raw pointers - - -#![feature(unsized_tuple_coercion)] - -trait Trait { - fn foo(&self) -> isize; -} - -struct A { - f: isize -} -impl Trait for A { - fn foo(&self) -> isize { - self.f - } -} - -struct Foo { - f: T -} - -pub fn main() { - // raw trait object - let x = A { f: 42 }; - let z: *const Trait = &x; - let r = unsafe { - (&*z).foo() - }; - assert_eq!(r, 42); - - // raw DST struct - let p = Foo {f: A { f: 42 }}; - let o: *const Foo = &p; - let r = unsafe { - (&*o).f.foo() - }; - assert_eq!(r, 42); - - // raw DST tuple - let p = (A { f: 42 },); - let o: *const (Trait,) = &p; - let r = unsafe { - (&*o).0.foo() - }; - assert_eq!(r, 42); - - // raw slice - let a: *const [_] = &[1, 2, 3]; - unsafe { - let b = (*a)[2]; - assert_eq!(b, 3); - let len = (*a).len(); - assert_eq!(len, 3); - } - - // raw slice with explicit cast - let a = &[1, 2, 3] as *const [i32]; - unsafe { - let b = (*a)[2]; - assert_eq!(b, 3); - let len = (*a).len(); - assert_eq!(len, 3); - } - - // raw DST struct with slice - let c: *const Foo<[_]> = &Foo {f: [1, 2, 3]}; - unsafe { - let b = (&*c).f[0]; - assert_eq!(b, 1); - let len = (&*c).f.len(); - assert_eq!(len, 3); - } - - // raw DST tuple with slice - let c: *const ([_],) = &([1, 2, 3],); - unsafe { - let b = (&*c).0[0]; - assert_eq!(b, 1); - let len = (&*c).0.len(); - assert_eq!(len, 3); - } - - // all of the above with *mut - let mut x = A { f: 42 }; - let z: *mut Trait = &mut x; - let r = unsafe { - (&*z).foo() - }; - assert_eq!(r, 42); - - let mut p = Foo {f: A { f: 42 }}; - let o: *mut Foo = &mut p; - let r = unsafe { - (&*o).f.foo() - }; - assert_eq!(r, 42); - - let mut p = (A { f: 42 },); - let o: *mut (Trait,) = &mut p; - let r = unsafe { - (&*o).0.foo() - }; - assert_eq!(r, 42); - - let a: *mut [_] = &mut [1, 2, 3]; - unsafe { - let b = (*a)[2]; - assert_eq!(b, 3); - let len = (*a).len(); - assert_eq!(len, 3); - } - - let a = &mut [1, 2, 3] as *mut [i32]; - unsafe { - let b = (*a)[2]; - assert_eq!(b, 3); - let len = (*a).len(); - assert_eq!(len, 3); - } - - let c: *mut Foo<[_]> = &mut Foo {f: [1, 2, 3]}; - unsafe { - let b = (&*c).f[0]; - assert_eq!(b, 1); - let len = (&*c).f.len(); - assert_eq!(len, 3); - } - - let c: *mut ([_],) = &mut ([1, 2, 3],); - unsafe { - let b = (&*c).0[0]; - assert_eq!(b, 1); - let len = (&*c).0.len(); - assert_eq!(len, 3); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,132 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -struct Fat { - f1: isize, - f2: &'static str, - ptr: T -} - -// x is a fat pointer -fn foo(x: &Fat<[isize]>) { - let y = &x.ptr; - assert_eq!(x.ptr.len(), 3); - assert_eq!(y[0], 1); - assert_eq!(x.ptr[1], 2); - assert_eq!(x.f1, 5); - assert_eq!(x.f2, "some str"); -} - -fn foo2(x: &Fat<[T]>) { - let y = &x.ptr; - let bar = Bar; - assert_eq!(x.ptr.len(), 3); - assert_eq!(y[0].to_bar(), bar); - assert_eq!(x.ptr[1].to_bar(), bar); - assert_eq!(x.f1, 5); - assert_eq!(x.f2, "some str"); -} - -fn foo3(x: &Fat>) { - let y = &x.ptr.ptr; - assert_eq!(x.f1, 5); - assert_eq!(x.f2, "some str"); - assert_eq!(x.ptr.f1, 8); - assert_eq!(x.ptr.f2, "deep str"); - assert_eq!(x.ptr.ptr.len(), 3); - assert_eq!(y[0], 1); - assert_eq!(x.ptr.ptr[1], 2); -} - - -#[derive(Copy, Clone, PartialEq, Eq, Debug)] -struct Bar; - -trait ToBar { - fn to_bar(&self) -> Bar; -} - -impl ToBar for Bar { - fn to_bar(&self) -> Bar { - *self - } -} - -pub fn main() { - // With a vec of ints. - let f1 = Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] }; - foo(&f1); - let f2 = &f1; - foo(f2); - let f3: &Fat<[isize]> = f2; - foo(f3); - let f4: &Fat<[isize]> = &f1; - foo(f4); - let f5: &Fat<[isize]> = &Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] }; - foo(f5); - - // With a vec of Bars. - let bar = Bar; - let f1 = Fat { f1: 5, f2: "some str", ptr: [bar, bar, bar] }; - foo2(&f1); - let f2 = &f1; - foo2(f2); - let f3: &Fat<[Bar]> = f2; - foo2(f3); - let f4: &Fat<[Bar]> = &f1; - foo2(f4); - let f5: &Fat<[Bar]> = &Fat { f1: 5, f2: "some str", ptr: [bar, bar, bar] }; - foo2(f5); - - // Assignment. - let f5: &mut Fat<[isize]> = &mut Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] }; - f5.ptr[1] = 34; - assert_eq!(f5.ptr[0], 1); - assert_eq!(f5.ptr[1], 34); - assert_eq!(f5.ptr[2], 3); - - // Zero size vec. - let f5: &Fat<[isize]> = &Fat { f1: 5, f2: "some str", ptr: [] }; - assert!(f5.ptr.is_empty()); - let f5: &Fat<[Bar]> = &Fat { f1: 5, f2: "some str", ptr: [] }; - assert!(f5.ptr.is_empty()); - - // Deeply nested. - let f1 = Fat { f1: 5, f2: "some str", ptr: Fat { f1: 8, f2: "deep str", ptr: [1, 2, 3]} }; - foo3(&f1); - let f2 = &f1; - foo3(f2); - let f3: &Fat> = f2; - foo3(f3); - let f4: &Fat> = &f1; - foo3(f4); - let f5: &Fat> = - &Fat { f1: 5, f2: "some str", ptr: Fat { f1: 8, f2: "deep str", ptr: [1, 2, 3]} }; - foo3(f5); - - // Box. - let f1 = Box::new([1, 2, 3]); - assert_eq!((*f1)[1], 2); - let f2: Box<[isize]> = f1; - assert_eq!((*f2)[1], 2); - - // Nested Box. - let f1 : Box> = box Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] }; - foo(&*f1); - let f2 : Box> = f1; - foo(&*f2); - - let f3 : Box> = - Box::>::new(Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] }); - foo(&*f3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-struct-sole.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-struct-sole.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-struct-sole.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-struct-sole.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// As dst-struct.rs, but the unsized field is the only field in the struct. - - -struct Fat { - ptr: T -} - -// x is a fat pointer -fn foo(x: &Fat<[isize]>) { - let y = &x.ptr; - assert_eq!(x.ptr.len(), 3); - assert_eq!(y[0], 1); - assert_eq!(x.ptr[1], 2); -} - -fn foo2(x: &Fat<[T]>) { - let y = &x.ptr; - let bar = Bar; - assert_eq!(x.ptr.len(), 3); - assert_eq!(y[0].to_bar(), bar); - assert_eq!(x.ptr[1].to_bar(), bar); -} - -#[derive(Copy, Clone, PartialEq, Eq, Debug)] -struct Bar; - -trait ToBar { - fn to_bar(&self) -> Bar; -} - -impl ToBar for Bar { - fn to_bar(&self) -> Bar { - *self - } -} - -pub fn main() { - // With a vec of ints. - let f1 = Fat { ptr: [1, 2, 3] }; - foo(&f1); - let f2 = &f1; - foo(f2); - let f3: &Fat<[isize]> = f2; - foo(f3); - let f4: &Fat<[isize]> = &f1; - foo(f4); - let f5: &Fat<[isize]> = &Fat { ptr: [1, 2, 3] }; - foo(f5); - - // With a vec of Bars. - let bar = Bar; - let f1 = Fat { ptr: [bar, bar, bar] }; - foo2(&f1); - let f2 = &f1; - foo2(f2); - let f3: &Fat<[Bar]> = f2; - foo2(f3); - let f4: &Fat<[Bar]> = &f1; - foo2(f4); - let f5: &Fat<[Bar]> = &Fat { ptr: [bar, bar, bar] }; - foo2(f5); - - // Assignment. - let f5: &mut Fat<[isize]> = &mut Fat { ptr: [1, 2, 3] }; - f5.ptr[1] = 34; - assert_eq!(f5.ptr[0], 1); - assert_eq!(f5.ptr[1], 34); - assert_eq!(f5.ptr[2], 3); - - // Zero size vec. - let f5: &Fat<[isize]> = &Fat { ptr: [] }; - assert!(f5.ptr.is_empty()); - let f5: &Fat<[Bar]> = &Fat { ptr: [] }; - assert!(f5.ptr.is_empty()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-trait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,115 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -struct Fat { - f1: isize, - f2: &'static str, - ptr: T -} - -#[derive(Copy, Clone, PartialEq, Eq, Debug)] -struct Bar; - -#[derive(Copy, Clone, PartialEq, Eq)] -struct Bar1 { - f: isize -} - -trait ToBar { - fn to_bar(&self) -> Bar; - fn to_val(&self) -> isize; -} - -impl ToBar for Bar { - fn to_bar(&self) -> Bar { - *self - } - fn to_val(&self) -> isize { - 0 - } -} -impl ToBar for Bar1 { - fn to_bar(&self) -> Bar { - Bar - } - fn to_val(&self) -> isize { - self.f - } -} - -// x is a fat pointer -fn foo(x: &Fat) { - assert_eq!(x.f1, 5); - assert_eq!(x.f2, "some str"); - assert_eq!(x.ptr.to_bar(), Bar); - assert_eq!(x.ptr.to_val(), 42); - - let y = &x.ptr; - assert_eq!(y.to_bar(), Bar); - assert_eq!(y.to_val(), 42); -} - -fn bar(x: &ToBar) { - assert_eq!(x.to_bar(), Bar); - assert_eq!(x.to_val(), 42); -} - -fn baz(x: &Fat>) { - assert_eq!(x.f1, 5); - assert_eq!(x.f2, "some str"); - assert_eq!(x.ptr.f1, 8); - assert_eq!(x.ptr.f2, "deep str"); - assert_eq!(x.ptr.ptr.to_bar(), Bar); - assert_eq!(x.ptr.ptr.to_val(), 42); - - let y = &x.ptr.ptr; - assert_eq!(y.to_bar(), Bar); - assert_eq!(y.to_val(), 42); - -} - -pub fn main() { - let f1 = Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; - foo(&f1); - let f2 = &f1; - foo(f2); - let f3: &Fat = f2; - foo(f3); - let f4: &Fat = &f1; - foo(f4); - let f5: &Fat = &Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; - foo(f5); - - // Zero size object. - let f6: &Fat = &Fat { f1: 5, f2: "some str", ptr: Bar }; - assert_eq!(f6.ptr.to_bar(), Bar); - - // &* - // - let f7: Box = Box::new(Bar1 {f :42}); - bar(&*f7); - - // Deep nesting - let f1 = - Fat { f1: 5, f2: "some str", ptr: Fat { f1: 8, f2: "deep str", ptr: Bar1 {f :42}} }; - baz(&f1); - let f2 = &f1; - baz(f2); - let f3: &Fat> = f2; - baz(f3); - let f4: &Fat> = &f1; - baz(f4); - let f5: &Fat> = - &Fat { f1: 5, f2: "some str", ptr: Fat { f1: 8, f2: "deep str", ptr: Bar1 {f :42}} }; - baz(f5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-trait-tuple.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-trait-tuple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-trait-tuple.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-trait-tuple.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(type_alias_bounds)] - -#![allow(unused_features)] -#![feature(box_syntax)] -#![feature(unsized_tuple_coercion)] - -type Fat = (isize, &'static str, T); - -#[derive(Copy, Clone, PartialEq, Eq, Debug)] -struct Bar; - -#[derive(Copy, Clone, PartialEq, Eq)] -struct Bar1 { - f: isize -} - -trait ToBar { - fn to_bar(&self) -> Bar; - fn to_val(&self) -> isize; -} - -impl ToBar for Bar { - fn to_bar(&self) -> Bar { - *self - } - fn to_val(&self) -> isize { - 0 - } -} -impl ToBar for Bar1 { - fn to_bar(&self) -> Bar { - Bar - } - fn to_val(&self) -> isize { - self.f - } -} - -// x is a fat pointer -fn foo(x: &Fat) { - assert_eq!(x.0, 5); - assert_eq!(x.1, "some str"); - assert_eq!(x.2.to_bar(), Bar); - assert_eq!(x.2.to_val(), 42); - - let y = &x.2; - assert_eq!(y.to_bar(), Bar); - assert_eq!(y.to_val(), 42); -} - -fn bar(x: &ToBar) { - assert_eq!(x.to_bar(), Bar); - assert_eq!(x.to_val(), 42); -} - -fn baz(x: &Fat>) { - assert_eq!(x.0, 5); - assert_eq!(x.1, "some str"); - assert_eq!((x.2).0, 8); - assert_eq!((x.2).1, "deep str"); - assert_eq!((x.2).2.to_bar(), Bar); - assert_eq!((x.2).2.to_val(), 42); - - let y = &(x.2).2; - assert_eq!(y.to_bar(), Bar); - assert_eq!(y.to_val(), 42); - -} - -pub fn main() { - let f1 = (5, "some str", Bar1 {f :42}); - foo(&f1); - let f2 = &f1; - foo(f2); - let f3: &Fat = f2; - foo(f3); - let f4: &Fat = &f1; - foo(f4); - let f5: &Fat = &(5, "some str", Bar1 {f :42}); - foo(f5); - - // Zero size object. - let f6: &Fat = &(5, "some str", Bar); - assert_eq!(f6.2.to_bar(), Bar); - - // &* - // - let f7: Box = Box::new(Bar1 {f :42}); - bar(&*f7); - - // Deep nesting - let f1 = (5, "some str", (8, "deep str", Bar1 {f :42})); - baz(&f1); - let f2 = &f1; - baz(f2); - let f3: &Fat> = f2; - baz(f3); - let f4: &Fat> = &f1; - baz(f4); - let f5: &Fat> = &(5, "some str", (8, "deep str", Bar1 {f :42})); - baz(f5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-tuple.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-tuple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-tuple.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-tuple.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,130 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(type_alias_bounds)] - -#![feature(box_syntax)] -#![feature(unsized_tuple_coercion)] - -type Fat = (isize, &'static str, T); - -// x is a fat pointer -fn foo(x: &Fat<[isize]>) { - let y = &x.2; - assert_eq!(x.2.len(), 3); - assert_eq!(y[0], 1); - assert_eq!(x.2[1], 2); - assert_eq!(x.0, 5); - assert_eq!(x.1, "some str"); -} - -fn foo2(x: &Fat<[T]>) { - let y = &x.2; - let bar = Bar; - assert_eq!(x.2.len(), 3); - assert_eq!(y[0].to_bar(), bar); - assert_eq!(x.2[1].to_bar(), bar); - assert_eq!(x.0, 5); - assert_eq!(x.1, "some str"); -} - -fn foo3(x: &Fat>) { - let y = &(x.2).2; - assert_eq!(x.0, 5); - assert_eq!(x.1, "some str"); - assert_eq!((x.2).0, 8); - assert_eq!((x.2).1, "deep str"); - assert_eq!((x.2).2.len(), 3); - assert_eq!(y[0], 1); - assert_eq!((x.2).2[1], 2); -} - - -#[derive(Copy, Clone, PartialEq, Eq, Debug)] -struct Bar; - -trait ToBar { - fn to_bar(&self) -> Bar; -} - -impl ToBar for Bar { - fn to_bar(&self) -> Bar { - *self - } -} - -pub fn main() { - // With a vec of ints. - let f1 = (5, "some str", [1, 2, 3]); - foo(&f1); - let f2 = &f1; - foo(f2); - let f3: &Fat<[isize]> = f2; - foo(f3); - let f4: &Fat<[isize]> = &f1; - foo(f4); - let f5: &Fat<[isize]> = &(5, "some str", [1, 2, 3]); - foo(f5); - - // With a vec of Bars. - let bar = Bar; - let f1 = (5, "some str", [bar, bar, bar]); - foo2(&f1); - let f2 = &f1; - foo2(f2); - let f3: &Fat<[Bar]> = f2; - foo2(f3); - let f4: &Fat<[Bar]> = &f1; - foo2(f4); - let f5: &Fat<[Bar]> = &(5, "some str", [bar, bar, bar]); - foo2(f5); - - // Assignment. - let f5: &mut Fat<[isize]> = &mut (5, "some str", [1, 2, 3]); - f5.2[1] = 34; - assert_eq!(f5.2[0], 1); - assert_eq!(f5.2[1], 34); - assert_eq!(f5.2[2], 3); - - // Zero size vec. - let f5: &Fat<[isize]> = &(5, "some str", []); - assert!(f5.2.is_empty()); - let f5: &Fat<[Bar]> = &(5, "some str", []); - assert!(f5.2.is_empty()); - - // Deeply nested. - let f1 = (5, "some str", (8, "deep str", [1, 2, 3])); - foo3(&f1); - let f2 = &f1; - foo3(f2); - let f3: &Fat> = f2; - foo3(f3); - let f4: &Fat> = &f1; - foo3(f4); - let f5: &Fat> = &(5, "some str", (8, "deep str", [1, 2, 3])); - foo3(f5); - - // Box. - let f1 = Box::new([1, 2, 3]); - assert_eq!((*f1)[1], 2); - let f2: Box<[isize]> = f1; - assert_eq!((*f2)[1], 2); - - // Nested Box. - let f1 : Box> = box (5, "some str", [1, 2, 3]); - foo(&*f1); - let f2 : Box> = f1; - foo(&*f2); - - let f3 : Box> = - Box::>::new((5, "some str", [1, 2, 3])); - foo(&*f3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-tuple-sole.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-tuple-sole.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-tuple-sole.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/dynamically-sized-types/dst-tuple-sole.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] -#![allow(type_alias_bounds)] - -// As dst-tuple.rs, but the unsized field is the only field in the tuple. - - -#![feature(unsized_tuple_coercion)] - -type Fat = (T,); - -// x is a fat pointer -fn foo(x: &Fat<[isize]>) { - let y = &x.0; - assert_eq!(x.0.len(), 3); - assert_eq!(y[0], 1); - assert_eq!(x.0[1], 2); -} - -fn foo2(x: &Fat<[T]>) { - let y = &x.0; - let bar = Bar; - assert_eq!(x.0.len(), 3); - assert_eq!(y[0].to_bar(), bar); - assert_eq!(x.0[1].to_bar(), bar); -} - -#[derive(Copy, Clone, PartialEq, Eq, Debug)] -struct Bar; - -trait ToBar { - fn to_bar(&self) -> Bar; -} - -impl ToBar for Bar { - fn to_bar(&self) -> Bar { - *self - } -} - -pub fn main() { - // With a vec of ints. - let f1 = ([1, 2, 3],); - foo(&f1); - let f2 = &f1; - foo(f2); - let f3: &Fat<[isize]> = f2; - foo(f3); - let f4: &Fat<[isize]> = &f1; - foo(f4); - let f5: &Fat<[isize]> = &([1, 2, 3],); - foo(f5); - - // With a vec of Bars. - let bar = Bar; - let f1 = ([bar, bar, bar],); - foo2(&f1); - let f2 = &f1; - foo2(f2); - let f3: &Fat<[Bar]> = f2; - foo2(f3); - let f4: &Fat<[Bar]> = &f1; - foo2(f4); - let f5: &Fat<[Bar]> = &([bar, bar, bar],); - foo2(f5); - - // Assignment. - let f5: &mut Fat<[isize]> = &mut ([1, 2, 3],); - f5.0[1] = 34; - assert_eq!(f5.0[0], 1); - assert_eq!(f5.0[1], 34); - assert_eq!(f5.0[2], 3); - - // Zero size vec. - let f5: &Fat<[isize]> = &([],); - assert!(f5.0.is_empty()); - let f5: &Fat<[Bar]> = &([],); - assert!(f5.0.is_empty()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/auxiliary/extern_calling_convention.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/auxiliary/extern_calling_convention.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/auxiliary/extern_calling_convention.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/auxiliary/extern_calling_convention.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Make sure Rust generates the correct calling convention for extern -// functions. - -#[inline(never)] -#[cfg(target_arch = "x86_64")] -pub extern "win64" fn foo(a: isize, b: isize, c: isize, d: isize) { - assert_eq!(a, 1); - assert_eq!(b, 2); - assert_eq!(c, 3); - assert_eq!(d, 4); - - println!("a: {}, b: {}, c: {}, d: {}", - a, b, c, d) -} - -#[inline(never)] -#[cfg(not(target_arch = "x86_64"))] -pub extern fn foo(a: isize, b: isize, c: isize, d: isize) { - assert_eq!(a, 1); - assert_eq!(b, 2); - assert_eq!(c, 3); - assert_eq!(d, 4); - - println!("a: {}, b: {}, c: {}, d: {}", - a, b, c, d) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/auxiliary/extern-crosscrate-source.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/auxiliary/extern-crosscrate-source.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/auxiliary/extern-crosscrate-source.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/auxiliary/extern-crosscrate-source.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="externcallback"] -#![crate_type = "lib"] -#![feature(libc)] - -extern crate libc; - -pub mod rustrt { - extern crate libc; - - #[link(name = "rust_test_helpers", kind = "static")] - extern { - pub fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t, - data: libc::uintptr_t) - -> libc::uintptr_t; - } -} - -pub fn fact(n: libc::uintptr_t) -> libc::uintptr_t { - unsafe { - println!("n = {}", n); - rustrt::rust_dbg_call(cb, n) - } -} - -pub extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t { - if data == 1 { - data - } else { - fact(data - 1) * data - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/auxiliary/extern_mod_ordering_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/auxiliary/extern_mod_ordering_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/auxiliary/extern_mod_ordering_lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/auxiliary/extern_mod_ordering_lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] - -pub mod extern_mod_ordering_lib { - pub fn f() {} -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/auxiliary/extern-take-value.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/auxiliary/extern-take-value.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/auxiliary/extern-take-value.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/auxiliary/extern-take-value.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub extern fn f() -> i32 { 1 } -pub extern fn g() -> i32 { 2 } - -pub fn get_f() -> extern fn() -> i32 { f } -pub fn get_g() -> extern fn() -> i32 { g } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/auxiliary/fat_drop.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/auxiliary/fat_drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/auxiliary/fat_drop.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/auxiliary/fat_drop.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub static mut DROPPED: bool = false; - -pub struct S { - _unsized: [u8] -} - -impl Drop for S { - fn drop(&mut self) { - unsafe { - DROPPED = true; - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -extern fn f() { -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-call-deep2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-call-deep2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-call-deep2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-call-deep2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -#![feature(libc)] - -extern crate libc; -use std::thread; - -mod rustrt { - extern crate libc; - - #[link(name = "rust_test_helpers", kind = "static")] - extern { - pub fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t, - data: libc::uintptr_t) - -> libc::uintptr_t; - } -} - -extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t { - if data == 1 { - data - } else { - count(data - 1) + 1 - } -} - -fn count(n: libc::uintptr_t) -> libc::uintptr_t { - unsafe { - println!("n = {}", n); - rustrt::rust_dbg_call(cb, n) - } -} - -pub fn main() { - // Make sure we're on a thread with small Rust stacks (main currently - // has a large stack) - thread::spawn(move|| { - let result = count(1000); - println!("result = {}", result); - assert_eq!(result, 1000); - }).join(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-call-deep.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-call-deep.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-call-deep.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-call-deep.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare no libc to test ffi with - -#![feature(libc)] - -extern crate libc; - -mod rustrt { - extern crate libc; - - #[link(name = "rust_test_helpers", kind = "static")] - extern { - pub fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t, - data: libc::uintptr_t) - -> libc::uintptr_t; - } -} - -extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t { - if data == 1 { - data - } else { - count(data - 1) + 1 - } -} - -fn count(n: libc::uintptr_t) -> libc::uintptr_t { - unsafe { - println!("n = {}", n); - rustrt::rust_dbg_call(cb, n) - } -} - -pub fn main() { - let result = count(1000); - println!("result = {}", result); - assert_eq!(result, 1000); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-call-direct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-call-direct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-call-direct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-call-direct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test direct calls to extern fns. - - -extern fn f(x: usize) -> usize { x * 2 } - -pub fn main() { - let x = f(22); - assert_eq!(x, 44); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-call-indirect.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-call-indirect.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-call-indirect.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-call-indirect.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare no libc to test ffi with - -#![feature(libc)] - -extern crate libc; - -mod rustrt { - extern crate libc; - - #[link(name = "rust_test_helpers", kind = "static")] - extern { - pub fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t, - data: libc::uintptr_t) - -> libc::uintptr_t; - } -} - -extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t { - if data == 1 { - data - } else { - fact(data - 1) * data - } -} - -fn fact(n: libc::uintptr_t) -> libc::uintptr_t { - unsafe { - println!("n = {}", n); - rustrt::rust_dbg_call(cb, n) - } -} - -pub fn main() { - let result = fact(10); - println!("result = {}", result); - assert_eq!(result, 3628800); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-calling-convention-test.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-calling-convention-test.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-calling-convention-test.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-calling-convention-test.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:extern_calling_convention.rs - -// pretty-expanded FIXME #23616 - -extern crate extern_calling_convention; - -use extern_calling_convention::foo; - -pub fn main() { - foo(1, 2, 3, 4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-call-scrub.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-call-scrub.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-call-scrub.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-call-scrub.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This time we're testing repeatedly going up and down both stacks to -// make sure the stack pointers are maintained properly in both -// directions - -// ignore-emscripten no threads support - -#![feature(libc)] - -extern crate libc; -use std::thread; - -mod rustrt { - extern crate libc; - - #[link(name = "rust_test_helpers", kind = "static")] - extern { - pub fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t) -> libc::uintptr_t, - data: libc::uintptr_t) - -> libc::uintptr_t; - } -} - -extern fn cb(data: libc::uintptr_t) -> libc::uintptr_t { - if data == 1 { - data - } else { - count(data - 1) + count(data - 1) - } -} - -fn count(n: libc::uintptr_t) -> libc::uintptr_t { - unsafe { - println!("n = {}", n); - rustrt::rust_dbg_call(cb, n) - } -} - -pub fn main() { - // Make sure we're on a thread with small Rust stacks (main currently - // has a large stack) - thread::spawn(move|| { - let result = count(12); - println!("result = {}", result); - assert_eq!(result, 2048); - }).join(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-compare-with-return-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-compare-with-return-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-compare-with-return-type.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-compare-with-return-type.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests that we can compare various kinds of extern fn signatures. -#![allow(non_camel_case_types)] - -extern fn voidret1() {} -extern fn voidret2() {} - -extern fn uintret() -> usize { 22 } - -extern fn uintvoidret(_x: usize) {} - -extern fn uintuintuintuintret(x: usize, y: usize, z: usize) -> usize { x+y+z } -type uintuintuintuintret = extern fn(usize,usize,usize) -> usize; - -pub fn main() { - assert!(voidret1 as extern fn() == voidret1 as extern fn()); - assert!(voidret1 as extern fn() != voidret2 as extern fn()); - - assert!(uintret as extern fn() -> usize == uintret as extern fn() -> usize); - - assert!(uintvoidret as extern fn(usize) == uintvoidret as extern fn(usize)); - - assert!(uintuintuintuintret as uintuintuintuintret == - uintuintuintuintret as uintuintuintuintret); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-crosscrate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-crosscrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-crosscrate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-crosscrate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:extern-crosscrate-source.rs -// ignore-wasm32-bare no libc to test ffi with - -#![feature(libc)] - -extern crate externcallback; -extern crate libc; - -fn fact(n: libc::uintptr_t) -> libc::uintptr_t { - unsafe { - println!("n = {}", n); - externcallback::rustrt::rust_dbg_call(externcallback::cb, n) - } -} - -pub fn main() { - let result = fact(10); - println!("result = {}", result); - assert_eq!(result, 3628800); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern_fat_drop.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern_fat_drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern_fat_drop.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern_fat_drop.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:fat_drop.rs - -extern crate fat_drop; - -fn main() { - unsafe { - let data: &mut [u8] = &mut [0]; - let s: &mut fat_drop::S = std::mem::transmute::<&mut [u8], _>(data); - std::ptr::drop_in_place(s); - assert!(fat_drop::DROPPED); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-foreign-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-foreign-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-foreign-crate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-foreign-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -extern crate std as mystd; - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-methods.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-methods.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-methods.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-methods.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-arm -// ignore-aarch64 - -trait A { - extern "fastcall" fn test1(i: i32); - extern fn test2(i: i32); -} - -struct S; -impl S { - extern "stdcall" fn test3(i: i32) { - assert_eq!(i, 3); - } -} - -impl A for S { - extern "fastcall" fn test1(i: i32) { - assert_eq!(i, 1); - } - extern fn test2(i: i32) { - assert_eq!(i, 2); - } -} - -fn main() { - ::test1(1); - ::test2(2); - S::test3(3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-mod-abi.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-mod-abi.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-mod-abi.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-mod-abi.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -extern "C" { - fn pow(x: f64, y: f64) -> f64; -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-mod-ordering-exe.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-mod-ordering-exe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-mod-ordering-exe.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-mod-ordering-exe.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:extern_mod_ordering_lib.rs - -// pretty-expanded FIXME #23616 - -extern crate extern_mod_ordering_lib; - -use extern_mod_ordering_lib::extern_mod_ordering_lib as the_lib; - -pub fn main() { - the_lib::f(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-char.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-char.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-char.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-char.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare no libc for ffi testing - -// Test a function that takes/returns a u8. - - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - pub fn rust_dbg_extern_identity_u8(v: u8) -> u8; -} - -pub fn main() { - unsafe { - assert_eq!(22, rust_dbg_extern_identity_u8(22)); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-double.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-double.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-double.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-double.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare no libc for ffi testing - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - pub fn rust_dbg_extern_identity_double(v: f64) -> f64; -} - -pub fn main() { - unsafe { - assert_eq!(22.0_f64, rust_dbg_extern_identity_double(22.0_f64)); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-empty.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-empty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-empty.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-empty.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(improper_ctypes)] // FIXME: this test is inherently not FFI-safe. - -// Test a foreign function that accepts empty struct. - -// pretty-expanded FIXME #23616 -// ignore-msvc -// ignore-emscripten emcc asserts on an empty struct as an argument - -#[repr(C)] -struct TwoU8s { - one: u8, - two: u8, -} - -#[repr(C)] -struct ManyInts { - arg1: i8, - arg2: i16, - arg3: i32, - arg4: i16, - arg5: i8, - arg6: TwoU8s, -} - -#[repr(C)] -struct Empty; - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - fn rust_dbg_extern_empty_struct(v1: ManyInts, e: Empty, v2: ManyInts); -} - -pub fn main() { - unsafe { - let x = ManyInts { - arg1: 2, - arg2: 3, - arg3: 4, - arg4: 5, - arg5: 6, - arg6: TwoU8s { one: 7, two: 8, } - }; - let y = ManyInts { - arg1: 1, - arg2: 2, - arg3: 3, - arg4: 4, - arg5: 5, - arg6: TwoU8s { one: 6, two: 7, } - }; - let empty = Empty; - rust_dbg_extern_empty_struct(x, empty, y); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-TwoU16s.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-TwoU16s.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-TwoU16s.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-TwoU16s.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(improper_ctypes)] - -// ignore-wasm32-bare no libc for ffi testing - -// Test a foreign function that accepts and returns a struct -// by value. - -#[derive(Copy, Clone, PartialEq, Debug)] -pub struct TwoU16s { - one: u16, two: u16 -} - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - pub fn rust_dbg_extern_identity_TwoU16s(v: TwoU16s) -> TwoU16s; -} - -pub fn main() { - unsafe { - let x = TwoU16s {one: 22, two: 23}; - let y = rust_dbg_extern_identity_TwoU16s(x); - assert_eq!(x, y); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-TwoU32s.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-TwoU32s.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-TwoU32s.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-TwoU32s.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(improper_ctypes)] - -// ignore-wasm32-bare no libc for ffi testing - -// Test a foreign function that accepts and returns a struct -// by value. - -#[derive(Copy, Clone, PartialEq, Debug)] -pub struct TwoU32s { - one: u32, two: u32 -} - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - pub fn rust_dbg_extern_identity_TwoU32s(v: TwoU32s) -> TwoU32s; -} - -pub fn main() { - unsafe { - let x = TwoU32s {one: 22, two: 23}; - let y = rust_dbg_extern_identity_TwoU32s(x); - assert_eq!(x, y); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-TwoU64s.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-TwoU64s.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-TwoU64s.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-TwoU64s.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(improper_ctypes)] - -// ignore-wasm32-bare no libc for ffi testing - -// Test a foreign function that accepts and returns a struct -// by value. - -#[derive(Copy, Clone, PartialEq, Debug)] -pub struct TwoU64s { - one: u64, two: u64 -} - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - pub fn rust_dbg_extern_identity_TwoU64s(v: TwoU64s) -> TwoU64s; -} - -pub fn main() { - unsafe { - let x = TwoU64s {one: 22, two: 23}; - let y = rust_dbg_extern_identity_TwoU64s(x); - assert_eq!(x, y); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-TwoU8s.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-TwoU8s.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-TwoU8s.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-TwoU8s.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(improper_ctypes)] - -// ignore-wasm32-bare no libc for ffi testing - -// Test a foreign function that accepts and returns a struct -// by value. - -#[derive(Copy, Clone, PartialEq, Debug)] -pub struct TwoU8s { - one: u8, two: u8 -} - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - pub fn rust_dbg_extern_identity_TwoU8s(v: TwoU8s) -> TwoU8s; -} - -pub fn main() { - unsafe { - let x = TwoU8s {one: 22, two: 23}; - let y = rust_dbg_extern_identity_TwoU8s(x); - assert_eq!(x, y); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-u32.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-u32.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-u32.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-u32.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare no libc for ffi testing - -// Test a function that takes/returns a u32. - - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - pub fn rust_dbg_extern_identity_u32(v: u32) -> u32; -} - -pub fn main() { - unsafe { - assert_eq!(22, rust_dbg_extern_identity_u32(22)); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-u64.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-u64.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-u64.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pass-u64.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare no libc for ffi testing - -// Test a call to a function that takes/returns a u64. - - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - pub fn rust_dbg_extern_identity_u64(v: u64) -> u64; -} - -pub fn main() { - unsafe { - assert_eq!(22, rust_dbg_extern_identity_u64(22)); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-prelude-core.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-prelude-core.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-prelude-core.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-prelude-core.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(extern_prelude, lang_items, start, alloc)] -#![no_std] - -extern crate std as other; - -mod foo { - pub fn test() { - let x = core::cmp::min(2, 3); - assert_eq!(x, 2); - } -} - -#[start] -fn start(_argc: isize, _argv: *const *const u8) -> isize { - foo::test(); - 0 -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-prelude-core.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-prelude-core.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-prelude-core.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-prelude-core.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -warning: the feature `extern_prelude` has been stable since 1.30.0 and no longer requires an attribute to enable - --> $DIR/extern-prelude-core.rs:12:12 - | -LL | #![feature(extern_prelude, lang_items, start, alloc)] - | ^^^^^^^^^^^^^^ - | - = note: #[warn(stable_features)] on by default - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-prelude-no-speculative.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-prelude-no-speculative.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-prelude-no-speculative.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-prelude-no-speculative.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: --extern LooksLikeExternCrate - -mod m { - pub struct LooksLikeExternCrate; -} - -fn main() { - // OK, speculative resolution for `unused_qualifications` doesn't try - // to resolve this as an extern crate and load that crate - let s = m::LooksLikeExternCrate {}; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-prelude-std.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-prelude-std.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-prelude-std.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-prelude-std.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(extern_prelude)] - -mod foo { - pub fn test() { - let x = std::cmp::min(2, 3); - assert_eq!(x, 2); - } -} - -fn main() { - foo::test(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-prelude-std.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-prelude-std.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-prelude-std.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-prelude-std.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -warning: the feature `extern_prelude` has been stable since 1.30.0 and no longer requires an attribute to enable - --> $DIR/extern-prelude-std.rs:12:12 - | -LL | #![feature(extern_prelude)] - | ^^^^^^^^^^^^^^ - | - = note: #[warn(stable_features)] on by default - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pub.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pub.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pub.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-pub.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -extern { - pub fn free(p: *const u8); -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-return-TwoU16s.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-return-TwoU16s.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-return-TwoU16s.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-return-TwoU16s.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(improper_ctypes)] - -// ignore-wasm32-bare no libc to test ffi with - -pub struct TwoU16s { - one: u16, two: u16 -} - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - pub fn rust_dbg_extern_return_TwoU16s() -> TwoU16s; -} - -pub fn main() { - unsafe { - let y = rust_dbg_extern_return_TwoU16s(); - assert_eq!(y.one, 10); - assert_eq!(y.two, 20); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-return-TwoU32s.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-return-TwoU32s.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-return-TwoU32s.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-return-TwoU32s.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(improper_ctypes)] - -// ignore-wasm32-bare no libc to test ffi with - -pub struct TwoU32s { - one: u32, two: u32 -} - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - pub fn rust_dbg_extern_return_TwoU32s() -> TwoU32s; -} - -pub fn main() { - unsafe { - let y = rust_dbg_extern_return_TwoU32s(); - assert_eq!(y.one, 10); - assert_eq!(y.two, 20); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-return-TwoU64s.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-return-TwoU64s.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-return-TwoU64s.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-return-TwoU64s.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(improper_ctypes)] - -// ignore-wasm32-bare no libc to test ffi with - -pub struct TwoU64s { - one: u64, two: u64 -} - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - pub fn rust_dbg_extern_return_TwoU64s() -> TwoU64s; -} - -pub fn main() { - unsafe { - let y = rust_dbg_extern_return_TwoU64s(); - assert_eq!(y.one, 10); - assert_eq!(y.two, 20); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-return-TwoU8s.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-return-TwoU8s.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-return-TwoU8s.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-return-TwoU8s.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(improper_ctypes)] - -// ignore-wasm32-bare no libc to test ffi with - -pub struct TwoU8s { - one: u8, two: u8 -} - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - pub fn rust_dbg_extern_return_TwoU8s() -> TwoU8s; -} - -pub fn main() { - unsafe { - let y = rust_dbg_extern_return_TwoU8s(); - assert_eq!(y.one, 10); - assert_eq!(y.two, 20); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-rust.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-rust.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-rust.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-rust.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#[repr(C)] -pub struct Foo(u32); - -// ICE trigger, bad handling of differing types between rust and external ABIs -pub extern fn bar() -> Foo { - Foo(0) -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-take-value.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-take-value.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-take-value.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-take-value.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:extern-take-value.rs - -extern crate extern_take_value; - -pub fn main() { - let a: extern "C" fn() -> i32 = extern_take_value::get_f(); - let b: extern "C" fn() -> i32 = extern_take_value::get_f(); - let c: extern "C" fn() -> i32 = extern_take_value::get_g(); - - assert!(a == b); - assert!(a != c); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-thiscall.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-thiscall.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-thiscall.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-thiscall.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-arm -// ignore-aarch64 - -#![feature(abi_thiscall)] - -trait A { - extern "thiscall" fn test1(i: i32); -} - -struct S; - -impl A for S { - extern "thiscall" fn test1(i: i32) { - assert_eq!(i, 1); - } -} - -extern "thiscall" fn test2(i: i32) { - assert_eq!(i, 2); -} - -fn main() { - ::test1(1); - test2(2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-inherent-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-inherent-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-inherent-impl.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-inherent-impl.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that inherent impls can be defined for extern types. - -#![feature(extern_types)] - -extern { - type A; -} - -impl A { - fn foo(&self) { } -} - -fn use_foo(x: &A) { - x.foo(); -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-manual-sync-send.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-manual-sync-send.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-manual-sync-send.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-manual-sync-send.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that unsafe impl for Sync/Send can be provided for extern types. - -#![feature(extern_types)] - -extern { - type A; -} - -unsafe impl Sync for A { } -unsafe impl Send for A { } - -fn assert_sync() { } -fn assert_send() { } - -fn main() { - assert_sync::(); - assert_send::(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-pointer-cast.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-pointer-cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-pointer-cast.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-pointer-cast.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that pointers to extern types can be cast from/to usize, -// despite being !Sized. - -#![feature(extern_types)] - -extern { - type A; -} - -struct Foo { - x: u8, - tail: A, -} - -struct Bar { - x: u8, - tail: T, -} - -#[cfg(target_pointer_width = "32")] -const MAGIC: usize = 0xdeadbeef; -#[cfg(target_pointer_width = "64")] -const MAGIC: usize = 0x12345678deadbeef; - -fn main() { - assert_eq!((MAGIC as *const A) as usize, MAGIC); - assert_eq!((MAGIC as *const Foo) as usize, MAGIC); - assert_eq!((MAGIC as *const Bar) as usize, MAGIC); - assert_eq!((MAGIC as *const Bar>) as usize, MAGIC); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-size_of_val.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-size_of_val.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-size_of_val.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-size_of_val.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(extern_types)] - -use std::mem::{size_of_val, align_of_val}; - -extern { - type A; -} - -fn main() { - let x: &A = unsafe { - &*(1usize as *const A) - }; - - assert_eq!(size_of_val(x), 0); - assert_eq!(align_of_val(x), 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-thin-pointer.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-thin-pointer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-thin-pointer.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-thin-pointer.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that pointers and references to extern types are thin, ie they have the same size and -// alignment as a pointer to (). - -#![feature(extern_types)] - -use std::mem::{align_of, size_of}; - -extern { - type A; -} - -struct Foo { - x: u8, - tail: A, -} - -struct Bar { - x: u8, - tail: T, -} - -fn assert_thin() { - assert_eq!(size_of::<*const T>(), size_of::<*const ()>()); - assert_eq!(align_of::<*const T>(), align_of::<*const ()>()); - - assert_eq!(size_of::<*mut T>(), size_of::<*mut ()>()); - assert_eq!(align_of::<*mut T>(), align_of::<*mut ()>()); - - assert_eq!(size_of::<&T>(), size_of::<&()>()); - assert_eq!(align_of::<&T>(), align_of::<&()>()); - - assert_eq!(size_of::<&mut T>(), size_of::<&mut ()>()); - assert_eq!(align_of::<&mut T>(), align_of::<&mut ()>()); -} - -fn main() { - assert_thin::(); - assert_thin::(); - assert_thin::>(); - assert_thin::>>(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-trait-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-trait-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-trait-impl.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-types-trait-impl.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that traits can be implemented for extern types. - -#![feature(extern_types)] - -extern { - type A; -} - -trait Foo { - fn foo(&self) { } -} - -impl Foo for A { - fn foo(&self) { } -} - -fn assert_foo() { } - -fn use_foo(x: &Foo) { - x.foo(); -} - -fn main() { - assert_foo::(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-vectorcall.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-vectorcall.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-vectorcall.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/extern/extern-vectorcall.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-arm -// ignore-aarch64 - -#![feature(abi_vectorcall)] - -trait A { - extern "vectorcall" fn test1(i: i32); -} - -struct S; - -impl A for S { - extern "vectorcall" fn test1(i: i32) { - assert_eq!(i, 1); - } -} - -extern "vectorcall" fn test2(i: i32) { - assert_eq!(i, 2); -} - -fn main() { - ::test1(1); - test2(2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/auxiliary/fn-abi.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/auxiliary/fn-abi.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/auxiliary/fn-abi.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/auxiliary/fn-abi.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[no_mangle] -pub extern fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/auxiliary/foreign_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/auxiliary/foreign_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/auxiliary/foreign_lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/auxiliary/foreign_lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="foreign_lib"] - -#![feature(libc)] - -pub mod rustrt { - extern crate libc; - - #[link(name = "rust_test_helpers", kind = "static")] - extern { - pub fn rust_get_test_int() -> libc::intptr_t; - } -} - -pub mod rustrt2 { - extern crate libc; - - extern { - pub fn rust_get_test_int() -> libc::intptr_t; - } -} - -pub mod rustrt3 { - // Different type, but same ABI (on all supported platforms). - // Ensures that we don't ICE or trigger LLVM asserts when - // importing the same symbol under different types. - // See https://github.com/rust-lang/rust/issues/32740. - extern { - pub fn rust_get_test_int() -> *const u8; - } -} - -pub fn local_uses() { - unsafe { - let x = rustrt::rust_get_test_int(); - assert_eq!(x, rustrt2::rust_get_test_int()); - assert_eq!(x as *const _, rustrt3::rust_get_test_int()); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare no libc to test ffi with -// pretty-expanded FIXME #23616 - -#![feature(libc)] - -extern crate libc; - -mod bar { - extern {} -} - -mod zed { - extern {} -} - -mod mlibc { - use libc::{c_int, c_void, size_t, ssize_t}; - - extern { - pub fn write(fd: c_int, buf: *const c_void, count: size_t) -> ssize_t; - } -} - -mod baz { - extern {} -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-call-no-runtime.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-call-no-runtime.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-call-no-runtime.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-call-no-runtime.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -#![feature(libc)] - -extern crate libc; - -use std::mem; -use std::thread; - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t), - data: libc::uintptr_t) -> libc::uintptr_t; -} - -pub fn main() { - unsafe { - thread::spawn(move|| { - let i: isize = 100; - rust_dbg_call(callback_isize, mem::transmute(&i)); - }).join().unwrap(); - - thread::spawn(move|| { - let i: i32 = 100; - rust_dbg_call(callback_i32, mem::transmute(&i)); - }).join().unwrap(); - - thread::spawn(move|| { - let i: i64 = 100; - rust_dbg_call(callback_i64, mem::transmute(&i)); - }).join().unwrap(); - } -} - -extern fn callback_isize(data: libc::uintptr_t) { - unsafe { - let data: *const isize = mem::transmute(data); - assert_eq!(*data, 100); - } -} - -extern fn callback_i64(data: libc::uintptr_t) { - unsafe { - let data: *const i64 = mem::transmute(data); - assert_eq!(*data, 100); - } -} - -extern fn callback_i32(data: libc::uintptr_t) { - unsafe { - let data: *const i32 = mem::transmute(data); - assert_eq!(*data, 100); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-dupe.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-dupe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-dupe.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-dupe.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:foreign_lib.rs -// ignore-wasm32-bare no libc to test ffi with - -// Check that we can still call duplicated extern (imported) functions -// which were declared in another crate. See issues #32740 and #32783. - - -extern crate foreign_lib; - -pub fn main() { - unsafe { - let x = foreign_lib::rustrt::rust_get_test_int(); - assert_eq!(x, foreign_lib::rustrt2::rust_get_test_int()); - assert_eq!(x as *const _, foreign_lib::rustrt3::rust_get_test_int()); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-fn-linkname.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-fn-linkname.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-fn-linkname.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-fn-linkname.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare no libc to test ffi with - -#![feature(libc)] - -extern crate libc; -use std::ffi::CString; - -mod mlibc { - use libc::{c_char, size_t}; - - extern { - #[link_name = "strlen"] - pub fn my_strlen(str: *const c_char) -> size_t; - } -} - -fn strlen(str: String) -> usize { - // C string is terminated with a zero - let s = CString::new(str).unwrap(); - unsafe { - mlibc::my_strlen(s.as_ptr()) as usize - } -} - -pub fn main() { - let len = strlen("Rust".to_string()); - assert_eq!(len, 4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-fn-with-byval.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-fn-with-byval.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-fn-with-byval.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-fn-with-byval.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(improper_ctypes)] - -// ignore-wasm32-bare no libc to test ffi with - -#[derive(Copy, Clone)] -pub struct S { - x: u64, - y: u64, - z: u64, -} - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - pub fn get_x(x: S) -> u64; - pub fn get_y(x: S) -> u64; - pub fn get_z(x: S) -> u64; -} - -#[inline(never)] -fn indirect_call(func: unsafe extern fn(s: S) -> u64, s: S) -> u64 { - unsafe { - func(s) - } -} - -fn main() { - let s = S { x: 1, y: 2, z: 3 }; - assert_eq!(s.x, indirect_call(get_x, s)); - assert_eq!(s.y, indirect_call(get_y, s)); - assert_eq!(s.z, indirect_call(get_z, s)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-int-types.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-int-types.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-int-types.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-int-types.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![forbid(improper_ctypes)] -#![allow(dead_code)] - -mod xx { - extern { - pub fn strlen(str: *const u8) -> usize; - pub fn foo(x: isize, y: usize); - } -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-mod-src/inner.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-mod-src/inner.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-mod-src/inner.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-mod-src/inner.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - -pub fn main() { - let f = "Makefile"; - let s = rustrt.str_buf(f); - let buf = libc.malloc(1024); - let fd = libc.open(s, 0, 0); - libc.read(fd, buf, 1024); - libc.write(1, buf, 1024); - libc.close(fd); - libc.free(buf); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-mod-unused-const.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-mod-unused-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-mod-unused-const.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-mod-unused-const.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -mod foo { - extern { - pub static errno: u32; - } -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-no-abi.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-no-abi.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-no-abi.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-no-abi.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ABI is cdecl by default - -// ignore-wasm32-bare no libc to test ffi with -// pretty-expanded FIXME #23616 - -#![feature(libc)] - -mod rustrt { - extern crate libc; - - #[link(name = "rust_test_helpers", kind = "static")] - extern { - pub fn rust_get_test_int() -> libc::intptr_t; - } -} - -pub fn main() { - unsafe { - rustrt::rust_get_test_int(); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-src/foreign.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-src/foreign.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-src/foreign.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-src/foreign.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - -pub fn main() { - libc.puts(rustrt.str_buf("hello, extern world 1")); - libc.puts(rustrt.str_buf("hello, extern world 2")); - libc.puts(rustrt.str_buf("hello, extern world 3")); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-truncated-arguments.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-truncated-arguments.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-truncated-arguments.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/foreign/foreign-truncated-arguments.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: -O -// Regression test for https://github.com/rust-lang/rust/issues/33868 - -#[repr(C)] -pub struct S { - a: u32, - b: f32, - c: u32 -} - -#[no_mangle] -#[inline(never)] -pub extern "C" fn test(s: S) -> u32 { - s.c -} - -fn main() { - assert_eq!(test(S{a: 0, b: 0.0, c: 42}), 42); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/auto-loop.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/auto-loop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/auto-loop.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/auto-loop.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let mut sum = 0; - let xs = vec![1, 2, 3, 4, 5]; - for x in &xs { - sum += *x; - } - assert_eq!(sum, 15); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/break.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/break.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/break.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/break.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let mut i = 0; - while i < 20 { i += 1; if i == 10 { break; } } - assert_eq!(i, 10); - loop { i += 1; if i == 20 { break; } } - assert_eq!(i, 20); - let xs = [1, 2, 3, 4, 5, 6]; - for x in &xs { - if *x == 3 { break; } assert!((*x <= 3)); - } - i = 0; - while i < 10 { i += 1; if i % 2 == 0 { continue; } assert!((i % 2 != 0)); } - i = 0; - loop { - i += 1; if i % 2 == 0 { continue; } assert!((i % 2 != 0)); - if i >= 10 { break; } - } - let ys = vec![1, 2, 3, 4, 5, 6]; - for x in &ys { - if *x % 2 == 0 { continue; } - assert!((*x % 2 != 0)); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/break-value.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/break-value.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/break-value.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/break-value.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn int_id(x: isize) -> isize { return x; } - -pub fn main() { loop { int_id(break); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-destruct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-destruct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-destruct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-destruct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct Pair { x: isize, y: isize } - -pub fn main() { - for elt in &(vec![Pair {x: 10, y: 20}, Pair {x: 30, y: 0}]) { - assert_eq!(elt.x + elt.y, 30); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators-break.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators-break.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators-break.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators-break.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let x = [1; 100]; - let mut y = 0; - for i in &x[..] { - if y > 10 { - break; - } - y += *i; - } - assert_eq!(y, 11); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators-hashmap-break-restart.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators-hashmap-break-restart.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators-hashmap-break-restart.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators-hashmap-break-restart.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::collections::HashMap; - -// This is a fancy one: it uses an external iterator established -// outside the loop, breaks, then _picks back up_ and continues -// iterating with it. - -pub fn main() { - let mut h = HashMap::new(); - let kvs = [(1, 10), (2, 20), (3, 30)]; - for &(k,v) in &kvs { - h.insert(k,v); - } - let mut x = 0; - let mut y = 0; - - let mut i = h.iter(); - - for (&k,&v) in i.by_ref() { - x += k; - y += v; - break; - } - - for (&k,&v) in i { - x += k; - y += v; - } - - assert_eq!(x, 6); - assert_eq!(y, 60); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators-hashmap.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators-hashmap.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators-hashmap.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators-hashmap.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::collections::HashMap; - -pub fn main() { - let mut h = HashMap::new(); - let kvs = [(1, 10), (2, 20), (3, 30)]; - for &(k,v) in &kvs { - h.insert(k,v); - } - let mut x = 0; - let mut y = 0; - for (&k,&v) in &h { - x += k; - y += v; - } - assert_eq!(x, 6); - assert_eq!(y, 60); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators-loop.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators-loop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators-loop.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators-loop.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let x = [1; 100]; - let mut y = 0; - for (n,i) in x.iter().enumerate() { - if n < 10 { - continue; - } - y += *i; - } - assert_eq!(y, 90); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators-nested.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators-nested.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators-nested.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators-nested.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let x = [1; 100]; - let y = [2; 100]; - let mut p = 0; - let mut q = 0; - for i in &x[..] { - for j in &y[..] { - p += *j; - } - q += *i + p; - } - assert_eq!(q, 1010100); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-external-iterators.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let x = [1; 100]; - let mut y = 0; - for i in &x[..] { - y += *i - } - assert_eq!(y, 100); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-nested.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-nested.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-nested.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-nested.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -fn two(mut it: F) where F: FnMut(isize) { it(0); it(1); } - -pub fn main() { - let mut a: Vec = vec![-1, -1, -1, -1]; - let mut p: isize = 0; - two(|i| { - two(|j| { a[p as usize] = 10 * i + j; p += 1; }) - }); - assert_eq!(a[0], 0); - assert_eq!(a[1], 1); - assert_eq!(a[2], 10); - assert_eq!(a[3], 11); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-put-structured.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-put-structured.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-put-structured.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-put-structured.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -fn pairs(mut it: F) where F: FnMut((isize, isize)) { - let mut i: isize = 0; - let mut j: isize = 0; - while i < 10 { it((i, j)); i += 1; j += i; } -} - -pub fn main() { - let mut i: isize = 10; - let mut j: isize = 0; - pairs(|p| { - let (_0, _1) = p; - println!("{}", _0); - println!("{}", _1); - assert_eq!(_0 + 10, i); - i += 1; - j = _1; - }); - assert_eq!(j, 45); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-simple-outer-slot.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-simple-outer-slot.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-simple-outer-slot.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/foreach-simple-outer-slot.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - -pub fn main() { - let mut sum: isize = 0; - first_ten(|i| { println!("main"); println!("{}", i); sum = sum + i; }); - println!("sum"); - println!("{}", sum); - assert_eq!(sum, 45); -} - -fn first_ten(mut it: F) where F: FnMut(isize) { - let mut i: isize = 0; - while i < 10 { println!("first_ten"); it(i); i = i + 1; } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-goofiness.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-goofiness.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-goofiness.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-goofiness.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum BogusOption { - None, - Some(T), -} - -type Iterator = isize; - -pub fn main() { - let x = [ 3, 3, 3 ]; - for i in &x { - assert_eq!(*i, 3); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-has-unit-body.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-has-unit-body.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-has-unit-body.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-has-unit-body.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - // Check that the tail statement in the body unifies with something - for _ in 0..3 { - unsafe { std::mem::uninitialized() } - } - - // Check that the tail statement in the body can be unit - for _ in 0..3 { - () - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-into-iterator.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-into-iterator.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-into-iterator.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-into-iterator.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that for loops can do what RFC #235 claims - - -fn main() { - let mut v = vec![1]; - - for x in &v { - assert_eq!(x, &1); - } - - for x in &mut v { - assert_eq!(x, &mut 1); - } - - for x in v { - assert_eq!(x, 1); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-lifetime-of-unbound-values.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-lifetime-of-unbound-values.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-lifetime-of-unbound-values.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-lifetime-of-unbound-values.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test when destructors run in a for loop. The intention is -// that the value for each iteration is dropped *after* the loop -// body has executed. This is true even when the value is assigned -// to a `_` pattern (and hence ignored). - -use std::cell::Cell; - -struct Flag<'a>(&'a Cell); - -impl<'a> Drop for Flag<'a> { - fn drop(&mut self) { - self.0.set(false) - } -} - -fn main() { - let alive2 = Cell::new(true); - for _i in std::iter::once(Flag(&alive2)) { - // The Flag value should be alive in the for loop body - assert_eq!(alive2.get(), true); - } - // The Flag value should be dead outside of the loop - assert_eq!(alive2.get(), false); - - let alive = Cell::new(true); - for _ in std::iter::once(Flag(&alive)) { - // The Flag value should be alive in the for loop body even if it wasn't - // bound by the for loop - assert_eq!(alive.get(), true); - } - // The Flag value should be dead outside of the loop - assert_eq!(alive.get(), false); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-macro.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-macro.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! var { - ( $name:ident ) => ( $name ); -} - -pub fn main() { - let x = [ 3, 3, 3 ]; - for var!(i) in &x { - assert_eq!(*i, 3); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-mut-ref-element.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-mut-ref-element.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-mut-ref-element.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-mut-ref-element.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests that for loops can bind elements as mutable references - -fn main() { - for ref mut _a in std::iter::once(true) {} -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-no-std.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-no-std.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-no-std.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-no-std.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(lang_items, start, alloc)] -#![no_std] - -extern crate std as other; - -#[macro_use] extern crate alloc; - -#[start] -fn start(_argc: isize, _argv: *const *const u8) -> isize { - for _ in [1,2,3].iter() { } - 0 -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-panic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-panic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-panic.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-panic.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -pub fn main() { let x: Vec = Vec::new(); for _ in &x { panic!("moop"); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-unconstrained-element-type-i32-fallback.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-unconstrained-element-type-i32-fallback.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-unconstrained-element-type-i32-fallback.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/for-loop-unconstrained-element-type-i32-fallback.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that the type of `sum` falls back to `i32` here, -// and that the for loop desugaring doesn't interfere with -// that. - -fn main() { - let mut sum = 0; - for i in Vec::new() { - sum += &i; - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/label_break_value.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/label_break_value.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/label_break_value.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/label_break_value.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,124 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(label_break_value)] - -// Test control flow to follow label_break_value semantics -fn label_break(a: bool, b: bool) -> u32 { - let mut v = 0; - 'b: { - v = 1; - if a { - break 'b; - } - v = 2; - if b { - break 'b; - } - v = 3; - } - return v; -} - -// Test that values can be returned -fn break_value(a: bool, b: bool) -> u32 { - let result = 'block: { - if a { break 'block 1; } - if b { break 'block 2; } - 3 - }; - result -} - -// Test nesting of labeled blocks -// here we only check that it compiles -fn label_break_nested() { - 'b: { - println!("hi"); - if false { - break 'b; - } - 'c: { - if false { - break 'b; - } - break 'c; - } - println!("hello"); - if true { - break 'b; - } - } -} - -// Tests for mixing labeled blocks with loop constructs -// This function should be the identity function -fn label_break_mixed(v: u32) -> u32 { - let mut r = 0; - 'b: { - // Unlabeled break still works - // (only crossing boundaries is an error) - loop { - break; - } - if v == 0 { - break 'b; - } - // Labeled breaking an inner loop still works - 'c: loop { - if r == 1 { - break 'c; - } - r += 1; - } - assert_eq!(r, 1); - if v == 1 { - break 'b; - } - // Labeled breaking an outer loop still works - 'd: loop { - 'e: { - if v == r { - break 'b; - } - if r == 5 { - break 'd; - } - r += 1; - } - } - assert_eq!(r, 5); - assert!(v > r); - // Here we test return from inside a labeled block - return v; - } - r -} - -pub fn main() { - assert_eq!(label_break(true, false), 1); - assert_eq!(label_break(false, true), 2); - assert_eq!(label_break(false, false), 3); - - assert_eq!(break_value(true, false), 1); - assert_eq!(break_value(false, true), 2); - assert_eq!(break_value(false, false), 3); - - assert_eq!(label_break_mixed(0), 0); - assert_eq!(label_break_mixed(1), 1); - assert_eq!(label_break_mixed(2), 2); - assert_eq!(label_break_mixed(3), 3); - assert_eq!(label_break_mixed(4), 4); - assert_eq!(label_break_mixed(5), 5); - assert_eq!(label_break_mixed(6), 6); - - // FIXME: ensure that labeled blocks work if produced by macros and in match arms -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/labeled-break.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/labeled-break.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/labeled-break.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/labeled-break.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub fn main() { - 'foo: loop { - loop { - break 'foo; - } - } - - 'bar: for _ in 0..100 { - loop { - break 'bar; - } - } - - 'foobar: while 1 + 1 == 2 { - loop { - break 'foobar; - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/linear-for-loop.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/linear-for-loop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/linear-for-loop.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/linear-for-loop.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn main() { - let x = vec![1, 2, 3]; - let mut y = 0; - for i in &x { println!("{}", *i); y += *i; } - println!("{}", y); - assert_eq!(y, 6); - let s = "hello there".to_string(); - let mut i: isize = 0; - for c in s.bytes() { - if i == 0 { assert_eq!(c, 'h' as u8); } - if i == 1 { assert_eq!(c, 'e' as u8); } - if i == 2 { assert_eq!(c, 'l' as u8); } - if i == 3 { assert_eq!(c, 'l' as u8); } - if i == 4 { assert_eq!(c, 'o' as u8); } - // ... - - i += 1; - println!("{}", i); - println!("{}", c); - } - assert_eq!(i, 11); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/liveness-assign-imm-local-after-loop.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/liveness-assign-imm-local-after-loop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/liveness-assign-imm-local-after-loop.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/liveness-assign-imm-local-after-loop.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![allow(unreachable_code)] -#![allow(unused_variables)] - -fn test(_cond: bool) { - let v: isize; - v = 1; - loop { } // loop never terminates, so no error is reported - v = 2; -} - -pub fn main() { - // note: don't call test()... :) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/liveness-loop-break.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/liveness-loop-break.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/liveness-loop-break.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/liveness-loop-break.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn test() { - let v; - loop { - v = 3; - break; - } - println!("{}", v); -} - -pub fn main() { - test(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/liveness-move-in-loop.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/liveness-move-in-loop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/liveness-move-in-loop.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/liveness-move-in-loop.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// pretty-expanded FIXME #23616 - -fn take(x: isize) -> isize {x} - -fn the_loop() { - let mut list = Vec::new(); - loop { - let x = 5; - if x > 3 { - list.push(take(x)); - } else { - break; - } - } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-break-cont-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-break-cont-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-break-cont-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-break-cont-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let _i = 0_usize; - loop { - break; - } - assert!(true); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-break-cont.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-break-cont.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-break-cont.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-break-cont.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn main() { - let mut i = 0_usize; - loop { - println!("a"); - i += 1_usize; - if i == 10_usize { - break; - } - } - assert_eq!(i, 10_usize); - let mut is_even = false; - loop { - if i == 21_usize { - break; - } - println!("b"); - is_even = false; - i += 1_usize; - if i % 2_usize != 0_usize { - continue; - } - is_even = true; - } - assert!(!is_even); - loop { - println!("c"); - if i == 22_usize { - break; - } - is_even = false; - i += 1_usize; - if i % 2_usize != 0_usize { - continue; - } - is_even = true; - } - assert!(is_even); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-break-value.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-break-value.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-break-value.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-break-value.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,147 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(never_type)] - -#[allow(unused)] -fn never_returns() { - loop { - break loop {}; - } -} - -pub fn main() { - let value = 'outer: loop { - if 1 == 1 { - break 13; - } else { - let _never: ! = loop { - break loop { - break 'outer panic!(); - } - }; - } - }; - assert_eq!(value, 13); - - let x = [1, 3u32, 5]; - let y = [17]; - let z = []; - let coerced: &[_] = loop { - match 2 { - 1 => break &x, - 2 => break &y, - 3 => break &z, - _ => (), - } - }; - assert_eq!(coerced, &[17u32]); - - let trait_unified = loop { - break if true { - break Default::default() - } else { - break [13, 14] - }; - }; - assert_eq!(trait_unified, [0, 0]); - - let trait_unified_2 = loop { - if false { - break [String::from("Hello")] - } else { - break Default::default() - }; - }; - assert_eq!(trait_unified_2, [""]); - - let trait_unified_3 = loop { - break if false { - break [String::from("Hello")] - } else { - ["Yes".into()] - }; - }; - assert_eq!(trait_unified_3, ["Yes"]); - - let regular_break = loop { - if true { - break; - } else { - break break Default::default(); - } - }; - assert_eq!(regular_break, ()); - - let regular_break_2 = loop { - if true { - break Default::default(); - } else { - break; - } - }; - assert_eq!(regular_break_2, ()); - - let regular_break_3 = loop { - break if true { - Default::default() - } else { - break; - } - }; - assert_eq!(regular_break_3, ()); - - let regular_break_4 = loop { - break (); - break; - }; - assert_eq!(regular_break_4, ()); - - let regular_break_5 = loop { - break; - break (); - }; - assert_eq!(regular_break_5, ()); - - let nested_break_value = 'outer2: loop { - let _a: u32 = 'inner: loop { - if true { - break 'outer2 "hello"; - } else { - break 'inner 17; - } - }; - panic!(); - }; - assert_eq!(nested_break_value, "hello"); - - let break_from_while_cond = loop { - 'inner_loop: while break 'inner_loop { - panic!(); - } - break 123; - }; - assert_eq!(break_from_while_cond, 123); - - let break_from_while_to_outer = 'outer_loop: loop { - while break 'outer_loop 567 { - panic!("from_inner"); - } - panic!("from outer"); - }; - assert_eq!(break_from_while_to_outer, 567); - - let rust = true; - let value = loop { - break rust; - }; - assert!(value); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-diverges.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-diverges.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-diverges.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-diverges.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -/* Make sure a loop{} can be the tailexpr in the body -of a diverging function */ - -fn forever() -> ! { - loop{} -} - -pub fn main() { - if (1 == 2) { forever(); } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-labeled-break-value.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-labeled-break-value.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-labeled-break-value.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-labeled-break-value.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn main() { - 'outer: loop { - let _: i32 = loop { break 'outer }; - } - 'outer2: loop { - let _: i32 = loop { loop { break 'outer2 } }; - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-label-shadowing.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-label-shadowing.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-label-shadowing.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-label-shadowing.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #12512. - -// pretty-expanded FIXME #23616 - -fn main() { - let mut foo = Vec::new(); - 'foo: for i in &[1, 2, 3] { - foo.push(*i); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-no-reinit-needed-post-bot.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-no-reinit-needed-post-bot.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-no-reinit-needed-post-bot.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-no-reinit-needed-post-bot.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -struct S; -// Ensure S is moved, not copied, on assignment. -impl Drop for S { fn drop(&mut self) { } } - -// user-defined function "returning" bottom (i.e. no return at all). -fn my_panic() -> ! { loop {} } - -pub fn step(f: bool) { - let mut g = S; - let mut i = 0; - loop - { - if i > 10 { break; } else { i += 1; } - - let _g = g; - - if f { - // re-initialize g, but only before restarting loop. - g = S; - continue; - } - - my_panic(); - - // we never get here, so we do not need to re-initialize g. - } -} - -pub fn main() { - step(true); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-scope.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-scope.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-scope.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/loop-scope.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let x = vec![10, 20, 30]; - let mut sum = 0; - for x in &x { sum += *x; } - assert_eq!(sum, 60); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-cont.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-cont.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-cont.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-cont.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #825: Should recheck the loop condition after continuing -pub fn main() { - let mut i = 1; - while i > 0 { - assert!((i > 0)); - println!("{}", i); - i -= 1; - continue; - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-flow-graph.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-flow-graph.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-flow-graph.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-flow-graph.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -// pretty-expanded FIXME #23616 - -pub fn main() { let x: isize = 10; while x == 10 && x == 11 { let _y = 0xf00_usize; } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-label.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-label.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-label.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-label.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -pub fn main() { - let mut i = 100; - 'w: while 1 + 1 == 2 { - i -= 1; - if i == 95 { - break 'w; - panic!("Should have broken out of loop"); - } - } - assert_eq!(i, 95); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-let.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-let.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-let.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-let.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::collections::BinaryHeap; - -fn make_pq() -> BinaryHeap { - BinaryHeap::from(vec![1,2,3]) -} - -pub fn main() { - let mut pq = make_pq(); - let mut sum = 0; - while let Some(x) = pq.pop() { - sum += x; - } - assert_eq!(sum, 6); - - pq = make_pq(); - sum = 0; - 'a: while let Some(x) = pq.pop() { - sum += x; - if x == 2 { - break 'a; - } - } - assert_eq!(sum, 5); - - pq = make_pq(); - sum = 0; - 'a2: while let Some(x) = pq.pop() { - if x == 3 { - continue 'a2; - } - sum += x; - } - assert_eq!(sum, 3); - - let mut pq1 = make_pq(); - sum = 0; - while let Some(x) = pq1.pop() { - let mut pq2 = make_pq(); - while let Some(y) = pq2.pop() { - sum += x * y; - } - } - assert_eq!(sum, 6 + 12 + 18); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-loop-constraints-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-loop-constraints-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-loop-constraints-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-loop-constraints-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(unused_variables)] - -pub fn main() { - let mut y: isize = 42; - let mut z: isize = 42; - let mut x: isize; - while z < 50 { - z += 1; - while false { x = y; y = z; } - println!("{}", y); - } - assert!((y == 42 && z == 50)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-prelude-drop.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-prelude-drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-prelude-drop.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-prelude-drop.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -use std::string::String; - -#[derive(PartialEq)] -enum t { a, b(String), } - -fn make(i: isize) -> t { - if i > 10 { return t::a; } - let mut s = String::from("hello"); - // Ensure s is non-const. - - s.push_str("there"); - return t::b(s); -} - -pub fn main() { - let mut i = 0; - - - // The auto slot for the result of make(i) should not leak. - while make(i) != t::a { i += 1; } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -pub fn main() { - let mut x: isize = 10; - let mut y: isize = 0; - while y < x { println!("{}", y); println!("hello"); y = y + 1; } - while x > 0 { - println!("goodbye"); - x = x - 1; - println!("{}", x); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-with-break.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-with-break.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-with-break.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/for-loop-while/while-with-break.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let mut i: isize = 90; - while i < 100 { - println!("{}", i); - i = i + 1; - if i == 95 { - let _v: Vec = - vec![1, 2, 3, 4, 5]; // we check that it is freed by break - - println!("breaking"); - break; - } - } - assert_eq!(i, 95); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/auxiliary/fn-abi.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/auxiliary/fn-abi.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/auxiliary/fn-abi.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/auxiliary/fn-abi.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[no_mangle] -pub extern fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/call-closure-from-overloaded-op.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/call-closure-from-overloaded-op.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/call-closure-from-overloaded-op.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/call-closure-from-overloaded-op.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn foo() -> isize { 22 } - -pub fn main() { - let mut x: Vec isize> = Vec::new(); - x.push(foo); - assert_eq!((x[0])(), 22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/capture-clauses-boxed-closures.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/capture-clauses-boxed-closures.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/capture-clauses-boxed-closures.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/capture-clauses-boxed-closures.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn each(x: &[T], mut f: F) where F: FnMut(&T) { - for val in x { - f(val) - } -} - -fn main() { - let mut sum = 0_usize; - let elems = [ 1_usize, 2, 3, 4, 5 ]; - each(&elems, |val| sum += *val); - assert_eq!(sum, 15); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/capture-clauses-unboxed-closures.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/capture-clauses-unboxed-closures.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/capture-clauses-unboxed-closures.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/capture-clauses-unboxed-closures.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn each<'a,T,F:FnMut(&'a T)>(x: &'a [T], mut f: F) { - for val in x { - f(val) - } -} - -fn main() { - let mut sum = 0; - let elems = [ 1, 2, 3, 4, 5 ]; - each(&elems, |val: &usize| sum += *val); - assert_eq!(sum, 15); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/clone-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/clone-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/clone-closure.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/clone-closure.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check that closures implement `Clone`. - -#[derive(Clone)] -struct S(i32); - -fn main() { - let mut a = S(5); - let mut hello = move || { - a.0 += 1; - println!("Hello {}", a.0); - a.0 - }; - - let mut hello2 = hello.clone(); - assert_eq!(6, hello2()); - assert_eq!(6, hello()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-bounds-can-capture-chan.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-bounds-can-capture-chan.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-bounds-can-capture-chan.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-bounds-can-capture-chan.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -use std::sync::mpsc::channel; - -fn foo(blk: F) { - blk(); -} - -pub fn main() { - let (tx, rx) = channel(); - foo(move || { - tx.send(()).unwrap(); - }); - rx.recv().unwrap(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-expected-type/expect-infer-supply-two-infers.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-expected-type/expect-infer-supply-two-infers.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-expected-type/expect-infer-supply-two-infers.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-expected-type/expect-infer-supply-two-infers.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn with_closure(_: F) - where F: FnOnce(Vec, A) -{ -} - -fn expect_free_supply_free<'x>(x: &'x u32) { - with_closure(|mut x: Vec<_>, y| { - // Shows that the call to `x.push()` is influencing type of `y`... - x.push(22_u32); - - // ...since we now know the type of `y` and can resolve the method call. - y.wrapping_add(1); - }); -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-expected-type/issue-38714.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-expected-type/issue-38714.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-expected-type/issue-38714.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-expected-type/issue-38714.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct UsizeRef<'a> { - a: &'a usize -} - -type RefTo = Box Fn(&'r Vec) -> UsizeRef<'r>>; - -fn ref_to<'a>(vec: &'a Vec) -> UsizeRef<'a> { - UsizeRef{ a: &vec[0]} -} - -fn main() { - // Regression test: this was causing ICEs; it should compile. - let a: RefTo = Box::new(|vec: &Vec| { - UsizeRef{ a: &vec[0] } - }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-expected-type/README.md rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-expected-type/README.md --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-expected-type/README.md 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-expected-type/README.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -Some tests targeted at how we deduce the types of closure arguments. -This process is a result of some heuristics aimed at combining the -*expected type* we have with the *actual types* that we get from -inputs. This investigation was kicked off by #38714, which revealed -some pretty deep flaws in the ad-hoc way that we were doing things -before. - -See also `src/test/compile-fail/closure-expected-type`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-expected-type/supply-just-return-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-expected-type/supply-just-return-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-expected-type/supply-just-return-type.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-expected-type/supply-just-return-type.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn with_closure(f: F) -> Result - where F: FnOnce(&char) -> Result, -{ - f(&'a') -} - -fn main() { - // Test that supplying the `-> Result` manually here - // (which is needed to constrain `R`) still allows us to figure - // out that the type of `x` is `&'a char` where `'a` is bound in - // the closure (if we didn't, we'd get a type-error because - // `with_closure` requires a bound region). - // - // This pattern was found in the wild. - let z = with_closure(|x| -> Result { Ok(*x) }); - assert_eq!(z.unwrap(), 'a'); - - // It also works with `_`: - let z = with_closure(|x: _| -> Result { Ok(*x) }); - assert_eq!(z.unwrap(), 'a'); - - // It also works with `&_`: - let z = with_closure(|x: &_| -> Result { Ok(*x) }); - assert_eq!(z.unwrap(), 'a'); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-expected-type/supply-nothing.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-expected-type/supply-nothing.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-expected-type/supply-nothing.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-expected-type/supply-nothing.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn with_closure(f: F) -> u32 - where F: FnOnce(&u32, &u32) -> u32 -{ - f(&22, &44) -} - -fn main() { - let z = with_closure(|x, y| x + y).wrapping_add(1); - assert_eq!(z, 22 + 44 + 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-immediate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-immediate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-immediate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-immediate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// After the work to reoptimize structs, it became possible for immediate logic to fail. -// This test verifies that it actually works. - -fn main() { - let c = |a: u8, b: u16, c: u8| { - assert_eq!(a, 1); - assert_eq!(b, 2); - assert_eq!(c, 3); - }; - c(1, 2, 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-inference2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-inference2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-inference2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-inference2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test a rather underspecified example: - - -pub fn main() { - let f = {|i| i}; - assert_eq!(f(2), 2); - assert_eq!(f(5), 5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-inference.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-inference.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-inference.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-inference.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -fn foo(i: isize) -> isize { i + 1 } - -fn apply(f: F, v: A) -> A where F: FnOnce(A) -> A { f(v) } - -pub fn main() { - let f = {|i| foo(i)}; - assert_eq!(apply(f, 2), 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-reform.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-reform.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-reform.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-reform.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -fn call_it(f: F) - where F : FnOnce(String) -> String -{ - println!("{}", f("Fred".to_string())) -} - -fn call_a_thunk(f: F) where F: FnOnce() { - f(); -} - -fn call_this(f: F) where F: FnOnce(&str) + Send { - f("Hello!"); -} - -fn call_bare(f: fn(&str)) { - f("Hello world!") -} - -fn call_bare_again(f: extern "Rust" fn(&str)) { - f("Goodbye world!") -} - -pub fn main() { - // Procs - - let greeting = "Hello ".to_string(); - call_it(|s| { - format!("{}{}", greeting, s) - }); - - let greeting = "Goodbye ".to_string(); - call_it(|s| format!("{}{}", greeting, s)); - - let greeting = "How's life, ".to_string(); - call_it(|s: String| -> String { - format!("{}{}", greeting, s) - }); - - // Closures - - call_a_thunk(|| println!("Hello world!")); - - call_this(|s| println!("{}", s)); - - // External functions - - fn foo(s: &str) {} - call_bare(foo); - - call_bare_again(foo); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-returning-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-returning-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-returning-closure.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-returning-closure.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - let f = |_||x, y| x+y; - assert_eq!(f(())(1, 2), 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure_to_fn_coercion-expected-types.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure_to_fn_coercion-expected-types.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure_to_fn_coercion-expected-types.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure_to_fn_coercion-expected-types.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Ensure that we deduce expected argument types when a `fn()` type is expected (#41755) - -fn foo(f: fn(Vec) -> usize) { } - -fn main() { - foo(|x| x.len()) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-to-fn-coercion.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-to-fn-coercion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-to-fn-coercion.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/closure-to-fn-coercion.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::mem; - -const FOO: fn(u8) -> u8 = |v: u8| { v }; - -const BAR: [fn(&mut u32); 5] = [ - |_: &mut u32| {}, - |v: &mut u32| *v += 1, - |v: &mut u32| *v += 2, - |v: &mut u32| *v += 3, - |v: &mut u32| *v += 4, -]; -fn func_specific() -> (fn() -> u32) { - || return 42 -} - -fn generic(_: T) -> fn() -> usize { - || mem::size_of::() -} - -fn main() { - // Items - assert_eq!(func_specific()(), 42); - let foo: fn(u8) -> u8 = |v: u8| { v }; - assert_eq!(foo(31), 31); - // Constants - assert_eq!(FOO(31), 31); - let mut a: u32 = 0; - assert_eq!({ BAR[0](&mut a); a }, 0); - assert_eq!({ BAR[1](&mut a); a }, 1); - assert_eq!({ BAR[2](&mut a); a }, 3); - assert_eq!({ BAR[3](&mut a); a }, 6); - assert_eq!({ BAR[4](&mut a); a }, 10); - assert_eq!(generic(0i8)(), 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/copy-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/copy-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/copy-closure.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/copy-closure.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check that closures implement `Copy`. - -fn call T>(f: F) -> T { f() } - -fn main() { - let a = 5; - let hello = || { - println!("Hello {}", a); - a - }; - - assert_eq!(5, call(hello.clone())); - assert_eq!(5, call(hello)); - assert_eq!(5, call(hello)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-abi.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-abi.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-abi.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-abi.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Ensure that declarations and types which use `extern fn` both have the same -// ABI (#9309). - -// pretty-expanded FIXME #23616 -// aux-build:fn-abi.rs - -extern crate fn_abi; - -extern { - fn foo(); -} - -pub fn main() { - // Will only type check if the type of _p and the decl of foo use the - // same ABI - let _p: unsafe extern fn() = foo; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-bare-assign.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-bare-assign.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-bare-assign.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-bare-assign.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn f(i: isize, called: &mut bool) { - assert_eq!(i, 10); - *called = true; -} - -fn g(f: fn(isize, v: &mut bool), called: &mut bool) { - f(10, called); -} - -pub fn main() { - let mut called = false; - let h = f; - g(h, &mut called); - assert_eq!(called, true); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-bare-coerce-to-block.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-bare-coerce-to-block.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-bare-coerce-to-block.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-bare-coerce-to-block.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn bare() {} - -fn likes_block(f: F) where F: FnOnce() { f() } - -pub fn main() { - likes_block(bare); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-bare-item.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-bare-item.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-bare-item.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-bare-item.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn f() { - println!("This is a bare function"); -} - -pub fn main() { - f(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-bare-size.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-bare-size.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-bare-size.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-bare-size.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::mem; - -pub fn main() { - // Bare functions should just be a pointer - assert_eq!(mem::size_of::(), mem::size_of::()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-bare-spawn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-bare-spawn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-bare-spawn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-bare-spawn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This is what the signature to spawn should look like with bare functions - - -fn spawn(val: T, f: fn(T)) { - f(val); -} - -fn f(i: isize) { - assert_eq!(i, 100); -} - -pub fn main() { - spawn(100, f); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-coerce-field.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-coerce-field.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-coerce-field.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-coerce-field.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 -#![allow(non_camel_case_types)] - -struct r where F: FnOnce() { - field: F, -} - -pub fn main() { - fn f() {} - let _i: r = r {field: f as fn()}; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-item-type-cast.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-item-type-cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-item-type-cast.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-item-type-cast.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test explicit coercions from a fn item type to a fn pointer type. - - -fn foo(x: isize) -> isize { x * 2 } -fn bar(x: isize) -> isize { x * 4 } -type IntMap = fn(isize) -> isize; - -fn eq(x: T, y: T) { } - -static TEST: Option = Some(foo as IntMap); - -fn main() { - let f = foo as IntMap; - - let f = if true { foo as IntMap } else { bar as IntMap }; - assert_eq!(f(4), 8); - - eq(foo as IntMap, bar as IntMap); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-item-type-coerce.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-item-type-coerce.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-item-type-coerce.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-item-type-coerce.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test implicit coercions from a fn item type to a fn pointer type. - -// pretty-expanded FIXME #23616 - -fn foo(x: isize) -> isize { x * 2 } -fn bar(x: isize) -> isize { x * 4 } -type IntMap = fn(isize) -> isize; - -fn eq(x: T, y: T) { } - -fn main() { - let f: IntMap = foo; - - eq::(foo, bar); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-item-type-zero-sized.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-item-type-zero-sized.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-item-type-zero-sized.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-item-type-zero-sized.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that fn item types are zero-sized. - -use std::mem::{size_of, size_of_val}; - -fn main() { - assert_eq!(size_of_val(&main), 0); - - let (a, b) = (size_of::, size_of::); - assert_eq!(size_of_val(&a), 0); - assert_eq!(size_of_val(&b), 0); - assert_eq!((a(), b()), (1, 2)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-lval.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-lval.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-lval.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-lval.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - -// pretty-expanded FIXME #23616 - -fn foo(_f: fn(isize) -> isize) { } - -fn id(x: isize) -> isize { return x; } - -pub fn main() { foo(id); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-type-infer.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-type-infer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-type-infer.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/fn-type-infer.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![allow(unused_variables)] - -pub fn main() { - // We should be able to type infer inside of ||s. - let _f = || { - let i = 10; - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/implied-bounds-closure-arg-outlives.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/implied-bounds-closure-arg-outlives.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/implied-bounds-closure-arg-outlives.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/implied-bounds-closure-arg-outlives.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we are able to handle the relationships between free -// regions bound in a closure callback. - -#[derive(Copy, Clone)] -struct MyCx<'short, 'long: 'short> { - short: &'short u32, - long: &'long u32, -} - -impl<'short, 'long> MyCx<'short, 'long> { - fn short(self) -> &'short u32 { self.short } - fn long(self) -> &'long u32 { self.long } - fn set_short(&mut self, v: &'short u32) { self.short = v; } -} - -fn with(op: F) -> R -where - F: for<'short, 'long> FnOnce(MyCx<'short, 'long>) -> R, -{ - op(MyCx { - short: &22, - long: &22, - }) -} - -fn main() { - with(|mut cx| { - // For this to type-check, we need to be able to deduce that - // the lifetime of `l` can be `'short`, even though it has - // input from `'long`. - let l = if true { cx.long() } else { cx.short() }; - cx.set_short(l); - }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/nullable-pointer-opt-closures.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/nullable-pointer-opt-closures.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/nullable-pointer-opt-closures.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/nullable-pointer-opt-closures.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::mem; - -pub fn main() { - // By Ref Capture - let a = 10i32; - let b = Some(|| println!("{}", a)); - // When we capture by reference we can use any of the - // captures as the discriminant since they're all - // behind a pointer. - assert_eq!(mem::size_of_val(&b), mem::size_of::()); - - // By Value Capture - let a = Box::new(12i32); - let b = Some(move || println!("{}", a)); - // We captured `a` by value and since it's a `Box` we can use it - // as the discriminant. - assert_eq!(mem::size_of_val(&b), mem::size_of::>()); - - // By Value Capture - Transitive case - let a = "Hello".to_string(); // String -> Vec -> Unique -> NonZero - let b = Some(move || println!("{}", a)); - // We captured `a` by value and since down the chain it contains - // a `NonZero` field, we can use it as the discriminant. - assert_eq!(mem::size_of_val(&b), mem::size_of::()); - - // By Value - No Optimization - let a = 14i32; - let b = Some(move || println!("{}", a)); - // We captured `a` by value but we can't use it as the discriminant - // thus we end up with an extra field for the discriminant - assert_eq!(mem::size_of_val(&b), mem::size_of::<(i32, i32)>()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/parallel-codegen-closures.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/parallel-codegen-closures.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/parallel-codegen-closures.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/parallel-codegen-closures.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -// Tests parallel codegen - this can fail if the symbol for the anonymous -// closure in `sum` pollutes the second codegen unit from the first. - -// ignore-bitrig -// compile-flags: -C codegen_units=2 - -#![feature(iter_arith)] - -mod a { - fn foo() { - let x = ["a", "bob", "c"]; - let len: usize = x.iter().map(|s| s.len()).sum(); - } -} - -mod b { - fn bar() { - let x = ["a", "bob", "c"]; - let len: usize = x.iter().map(|s| s.len()).sum(); - } -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/return-from-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/return-from-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/return-from-closure.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/functions-closures/return-from-closure.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] -// just to make sure that `return` is only returning from the closure, -// not the surrounding function. - -static mut calls: usize = 0; - -fn surrounding() { - let return_works = |n: isize| { - unsafe { calls += 1 } - - if n >= 0 { return; } - panic!() - }; - - return_works(10); - return_works(20); - - let return_works_proc = |n: isize| { - unsafe { calls += 1 } - - if n >= 0 { return; } - panic!() - }; - - return_works_proc(10); -} - -pub fn main() { - surrounding(); - - assert_eq!(unsafe {calls}, 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/auxiliary/xcrate-reachable.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/auxiliary/xcrate-reachable.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/auxiliary/xcrate-reachable.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/auxiliary/xcrate-reachable.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -fn msg() -> u32 { - 0 -} - -pub fn foo() -> impl Generator { - || { - yield; - return msg(); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/auxiliary/xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/auxiliary/xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/auxiliary/xcrate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/auxiliary/xcrate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -pub fn foo() -> impl Generator { - || { - if false { - yield; - } - } -} - -pub fn bar(t: T) -> Box> { - Box::new(|| { - yield t; - }) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/borrow-in-tail-expr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/borrow-in-tail-expr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/borrow-in-tail-expr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/borrow-in-tail-expr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(generators)] - -fn main() { - let _a = || { - yield; - let a = String::new(); - a.len() - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/conditional-drop.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/conditional-drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/conditional-drop.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/conditional-drop.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; - -static A: AtomicUsize = ATOMIC_USIZE_INIT; - -struct B; - -impl Drop for B { - fn drop(&mut self) { - A.fetch_add(1, Ordering::SeqCst); - } -} - - -fn test() -> bool { true } -fn test2() -> bool { false } - -fn main() { - t1(); - t2(); -} - -fn t1() { - let mut a = || { - let b = B; - if test() { - drop(b); - } - yield; - }; - - let n = A.load(Ordering::SeqCst); - unsafe { a.resume() }; - assert_eq!(A.load(Ordering::SeqCst), n + 1); - unsafe { a.resume() }; - assert_eq!(A.load(Ordering::SeqCst), n + 1); -} - -fn t2() { - let mut a = || { - let b = B; - if test2() { - drop(b); - } - yield; - }; - - let n = A.load(Ordering::SeqCst); - unsafe { a.resume() }; - assert_eq!(A.load(Ordering::SeqCst), n); - unsafe { a.resume() }; - assert_eq!(A.load(Ordering::SeqCst), n + 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/control-flow.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/control-flow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/control-flow.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/control-flow.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(generators, generator_trait)] - -use std::ops::{GeneratorState, Generator}; - -fn finish(mut amt: usize, mut t: T) -> T::Return - where T: Generator -{ - loop { - match unsafe { t.resume() } { - GeneratorState::Yielded(()) => amt = amt.checked_sub(1).unwrap(), - GeneratorState::Complete(ret) => { - assert_eq!(amt, 0); - return ret - } - } - } - -} - -fn main() { - finish(1, || yield); - finish(8, || { - for _ in 0..8 { - yield; - } - }); - finish(1, || { - if true { - yield; - } else { - } - }); - finish(1, || { - if false { - } else { - yield; - } - }); - finish(2, || { - if { yield; false } { - yield; - panic!() - } - yield - }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/drop-env.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/drop-env.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/drop-env.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/drop-env.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; - -static A: AtomicUsize = ATOMIC_USIZE_INIT; - -struct B; - -impl Drop for B { - fn drop(&mut self) { - A.fetch_add(1, Ordering::SeqCst); - } -} - -fn main() { - t1(); - t2(); - t3(); -} - -fn t1() { - let b = B; - let mut foo = || { - yield; - drop(b); - }; - - let n = A.load(Ordering::SeqCst); - drop(unsafe { foo.resume() }); - assert_eq!(A.load(Ordering::SeqCst), n); - drop(foo); - assert_eq!(A.load(Ordering::SeqCst), n + 1); -} - -fn t2() { - let b = B; - let mut foo = || { - yield b; - }; - - let n = A.load(Ordering::SeqCst); - drop(unsafe { foo.resume() }); - assert_eq!(A.load(Ordering::SeqCst), n + 1); - drop(foo); - assert_eq!(A.load(Ordering::SeqCst), n + 1); -} - -fn t3() { - let b = B; - let foo = || { - yield; - drop(b); - }; - - let n = A.load(Ordering::SeqCst); - assert_eq!(A.load(Ordering::SeqCst), n); - drop(foo); - assert_eq!(A.load(Ordering::SeqCst), n + 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/issue-44197.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/issue-44197.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/issue-44197.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/issue-44197.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(generators, generator_trait)] - -use std::ops::{ Generator, GeneratorState }; - -fn foo(_: &str) -> String { - String::new() -} - -fn bar(baz: String) -> impl Generator { - move || { - yield foo(&baz); - } -} - -fn foo2(_: &str) -> Result { - Err(()) -} - -fn bar2(baz: String) -> impl Generator { - move || { - if let Ok(quux) = foo2(&baz) { - yield quux; - } - } -} - -fn main() { - unsafe { - assert_eq!(bar(String::new()).resume(), GeneratorState::Yielded(String::new())); - assert_eq!(bar2(String::new()).resume(), GeneratorState::Complete(())); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/issue-52398.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/issue-52398.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/issue-52398.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/issue-52398.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(generators)] - -use std::cell::RefCell; - -struct A; - -impl A { - fn test(&self, a: ()) {} -} - -fn main() { - // Test that the MIR local with type &A created for the auto-borrow adjustment - // is caught by typeck - move || { - A.test(yield); - }; - - // Test that the std::cell::Ref temporary returned from the `borrow` call - // is caught by typeck - let y = RefCell::new(true); - static move || { - yield *y.borrow(); - return "Done"; - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/iterator-count.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/iterator-count.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/iterator-count.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/iterator-count.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(generators, generator_trait)] - -use std::ops::{GeneratorState, Generator}; - -struct W(T); - -// This impl isn't safe in general, but the generator used in this test is movable -// so it won't cause problems. -impl> Iterator for W { - type Item = T::Yield; - - fn next(&mut self) -> Option { - match unsafe { self.0.resume() } { - GeneratorState::Complete(..) => None, - GeneratorState::Yielded(v) => Some(v), - } - } -} - -fn test() -> impl Generator { - || { - for i in 1..6 { - yield i - } - } -} - -fn main() { - let end = 11; - - let closure_test = |start| { - move || { - for i in start..end { - yield i - } - } - }; - - assert!(W(test()).chain(W(closure_test(6))).eq(1..11)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/live-upvar-across-yield.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/live-upvar-across-yield.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/live-upvar-across-yield.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/live-upvar-across-yield.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -fn main() { - let b = |_| 3; - let mut a = || { - b(yield); - }; - unsafe { a.resume() }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/match-bindings.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/match-bindings.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/match-bindings.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/match-bindings.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(generators)] - -enum Enum { - A(String), - B -} - -fn main() { - || { - loop { - if let true = true { - match Enum::A(String::new()) { - Enum::A(_var) => {} - Enum::B => {} - } - } - yield; - } - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/nested_generators.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/nested_generators.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/nested_generators.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/nested_generators.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(generators)] -#![feature(generator_trait)] - -use std::ops::Generator; -use std::ops::GeneratorState; - -fn main() { - let _generator = || { - let mut sub_generator = || { - yield 2; - }; - - match unsafe { sub_generator.resume() } { - GeneratorState::Yielded(x) => { - yield x; - } - _ => panic!(), - }; - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/panic-drops.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/panic-drops.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/panic-drops.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/panic-drops.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// ignore-wasm32-bare compiled as panic=abort by default - -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::panic; -use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; - -static A: AtomicUsize = ATOMIC_USIZE_INIT; - -struct B; - -impl Drop for B { - fn drop(&mut self) { - A.fetch_add(1, Ordering::SeqCst); - } -} - -fn bool_true() -> bool { - true -} - -fn main() { - let b = B; - let mut foo = || { - if bool_true() { - panic!(); - } - drop(b); - yield; - }; - - assert_eq!(A.load(Ordering::SeqCst), 0); - let res = panic::catch_unwind(panic::AssertUnwindSafe(|| { - unsafe { foo.resume() } - })); - assert!(res.is_err()); - assert_eq!(A.load(Ordering::SeqCst), 1); - - let mut foo = || { - if bool_true() { - panic!(); - } - drop(B); - yield; - }; - - assert_eq!(A.load(Ordering::SeqCst), 1); - let res = panic::catch_unwind(panic::AssertUnwindSafe(|| { - unsafe { foo.resume() } - })); - assert!(res.is_err()); - assert_eq!(A.load(Ordering::SeqCst), 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/panic-safe.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/panic-safe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/panic-safe.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/panic-safe.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// ignore-wasm32-bare compiled with panic=abort by default - -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::panic; - -fn main() { - let mut foo = || { - if true { - panic!(); - } - yield; - }; - - let res = panic::catch_unwind(panic::AssertUnwindSafe(|| { - unsafe { foo.resume() } - })); - assert!(res.is_err()); - - for _ in 0..10 { - let res = panic::catch_unwind(panic::AssertUnwindSafe(|| { - unsafe { foo.resume() } - })); - assert!(res.is_err()); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/reborrow-mut-upvar.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/reborrow-mut-upvar.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/reborrow-mut-upvar.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/reborrow-mut-upvar.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(generators)] - -fn _run(bar: &mut i32) { - || { - { - let _baz = &*bar; - yield; - } - - *bar = 2; - }; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/resume-after-return.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/resume-after-return.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/resume-after-return.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/resume-after-return.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// ignore-wasm32-bare compiled with panic=abort by default - -#![feature(generators, generator_trait)] - -use std::ops::{GeneratorState, Generator}; -use std::panic; - -fn main() { - let mut foo = || { - if true { - return - } - yield; - }; - - match unsafe { foo.resume() } { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } - - match panic::catch_unwind(move || unsafe { foo.resume() }) { - Ok(_) => panic!("generator successfully resumed"), - Err(_) => {} - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/smoke.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/smoke.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/smoke.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/smoke.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,183 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// ignore-emscripten no threads support -// compile-flags: --test - -#![feature(generators, generator_trait)] - -use std::ops::{GeneratorState, Generator}; -use std::thread; - -#[test] -fn simple() { - let mut foo = || { - if false { - yield; - } - }; - - match unsafe { foo.resume() } { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } -} - -#[test] -fn return_capture() { - let a = String::from("foo"); - let mut foo = || { - if false { - yield; - } - a - }; - - match unsafe { foo.resume() } { - GeneratorState::Complete(ref s) if *s == "foo" => {} - s => panic!("bad state: {:?}", s), - } -} - -#[test] -fn simple_yield() { - let mut foo = || { - yield; - }; - - match unsafe { foo.resume() } { - GeneratorState::Yielded(()) => {} - s => panic!("bad state: {:?}", s), - } - match unsafe { foo.resume() } { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } -} - -#[test] -fn yield_capture() { - let b = String::from("foo"); - let mut foo = || { - yield b; - }; - - match unsafe { foo.resume() } { - GeneratorState::Yielded(ref s) if *s == "foo" => {} - s => panic!("bad state: {:?}", s), - } - match unsafe { foo.resume() } { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } -} - -#[test] -fn simple_yield_value() { - let mut foo = || { - yield String::from("bar"); - return String::from("foo") - }; - - match unsafe { foo.resume() } { - GeneratorState::Yielded(ref s) if *s == "bar" => {} - s => panic!("bad state: {:?}", s), - } - match unsafe { foo.resume() } { - GeneratorState::Complete(ref s) if *s == "foo" => {} - s => panic!("bad state: {:?}", s), - } -} - -#[test] -fn return_after_yield() { - let a = String::from("foo"); - let mut foo = || { - yield; - return a - }; - - match unsafe { foo.resume() } { - GeneratorState::Yielded(()) => {} - s => panic!("bad state: {:?}", s), - } - match unsafe { foo.resume() } { - GeneratorState::Complete(ref s) if *s == "foo" => {} - s => panic!("bad state: {:?}", s), - } -} - -#[test] -fn send_and_sync() { - assert_send_sync(|| { - yield - }); - assert_send_sync(|| { - yield String::from("foo"); - }); - assert_send_sync(|| { - yield; - return String::from("foo"); - }); - let a = 3; - assert_send_sync(|| { - yield a; - return - }); - let a = 3; - assert_send_sync(move || { - yield a; - return - }); - let a = String::from("a"); - assert_send_sync(|| { - yield ; - drop(a); - return - }); - let a = String::from("a"); - assert_send_sync(move || { - yield ; - drop(a); - return - }); - - fn assert_send_sync(_: T) {} -} - -#[test] -fn send_over_threads() { - let mut foo = || { yield }; - thread::spawn(move || { - match unsafe { foo.resume() } { - GeneratorState::Yielded(()) => {} - s => panic!("bad state: {:?}", s), - } - match unsafe { foo.resume() } { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } - }).join().unwrap(); - - let a = String::from("a"); - let mut foo = || { yield a }; - thread::spawn(move || { - match unsafe { foo.resume() } { - GeneratorState::Yielded(ref s) if *s == "a" => {} - s => panic!("bad state: {:?}", s), - } - match unsafe { foo.resume() } { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } - }).join().unwrap(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/static-generators.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/static-generators.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/static-generators.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/static-generators.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(generators, generator_trait)] - -use std::ops::{Generator, GeneratorState}; - -fn main() { - let mut generator = static || { - let a = true; - let b = &a; - yield; - assert_eq!(b as *const _, &a as *const _); - }; - unsafe { - assert_eq!(generator.resume(), GeneratorState::Yielded(())); - assert_eq!(generator.resume(), GeneratorState::Complete(())); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/too-live-local-in-immovable-gen.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/too-live-local-in-immovable-gen.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/too-live-local-in-immovable-gen.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/too-live-local-in-immovable-gen.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(generators)] - -fn main() { - unsafe { - static move || { - // Tests that the generator transformation finds out that `a` is not live - // during the yield expression. Type checking will also compute liveness - // and it should also find out that `a` is not live. - // The compiler will panic if the generator transformation finds that - // `a` is live and type checking finds it dead. - let a = { - yield (); - 4i32 - }; - &a; - }; - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/xcrate-reachable.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/xcrate-reachable.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/xcrate-reachable.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/xcrate-reachable.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// aux-build:xcrate-reachable.rs - -#![feature(generator_trait)] - -extern crate xcrate_reachable as foo; - -use std::ops::Generator; - -fn main() { - unsafe { foo::foo().resume(); } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/xcrate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/xcrate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// aux-build:xcrate.rs - -#![feature(generators, generator_trait)] - -extern crate xcrate; - -use std::ops::{GeneratorState, Generator}; - -fn main() { - let mut foo = xcrate::foo(); - - match unsafe { foo.resume() } { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } - - let mut foo = xcrate::bar(3); - - match unsafe { foo.resume() } { - GeneratorState::Yielded(3) => {} - s => panic!("bad state: {:?}", s), - } - match unsafe { foo.resume() } { - GeneratorState::Complete(()) => {} - s => panic!("bad state: {:?}", s), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/yield-in-args-rev.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/yield-in-args-rev.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/yield-in-args-rev.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/yield-in-args-rev.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Test that a borrow that occurs after a yield in the same -// argument list is not treated as live across the yield by -// type-checking. - -#![feature(generators)] - -fn foo(_a: (), _b: &bool) {} - -fn bar() { - || { - let b = true; - foo(yield, &b); - }; -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/yield-in-box.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/yield-in-box.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/yield-in-box.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/yield-in-box.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Test that box-statements with yields in them work. - -#![feature(generators, box_syntax)] - -fn main() { - let x = 0i32; - || { - let y = 2u32; - { - let _t = box (&x, yield 0, &y); - } - match box (&x, yield 0, &y) { - _t => {} - } - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/yield-in-initializer.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/yield-in-initializer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/yield-in-initializer.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/yield-in-initializer.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(generators)] - -fn main() { - static || { - loop { - // Test that `opt` is not live across the yield, even when borrowed in a loop - // See https://github.com/rust-lang/rust/issues/52792 - let opt = { - yield; - true - }; - &opt; - } - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/yield-subtype.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/yield-subtype.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generator/yield-subtype.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generator/yield-subtype.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// revisions:lexical nll -//[nll]compile-flags: -Z disable-nll-user-type-assert -#![cfg_attr(nll, feature(nll))] - -#![feature(generators)] - -fn bar<'a>() { - let a: &'static str = "hi"; - let b: &'a str = a; - - || { - yield a; - yield b; - }; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/auxiliary/default_type_params_xc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/auxiliary/default_type_params_xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/auxiliary/default_type_params_xc.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/auxiliary/default_type_params_xc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct Heap; - -pub struct FakeHeap; - -pub struct FakeVec { pub f: Option<(T,A)> } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-alias-unique.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-alias-unique.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-alias-unique.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-alias-unique.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -fn id(t: T) -> T { return t; } - -pub fn main() { - let expected: Box<_> = box 100; - let actual = id::>(expected.clone()); - println!("{}", *actual); - assert_eq!(*expected, *actual); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-default-type-params-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-default-type-params-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-default-type-params-cross-crate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-default-type-params-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:default_type_params_xc.rs - -// pretty-expanded FIXME #23616 - -extern crate default_type_params_xc; - -struct Vec(Option<(T,A)>); - -struct Foo; - -fn main() { - let _a = Vec::(None); - let _b = Vec::(None); - let _c = default_type_params_xc::FakeVec:: { f: None }; - let _d = default_type_params_xc::FakeVec:: { f: None }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-default-type-params.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-default-type-params.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-default-type-params.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-default-type-params.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct Foo { - a: A -} - -impl Foo { - fn bar_int(&self) -> isize { - self.a - } -} - -impl Foo { - fn bar_char(&self) -> char { - self.a - } -} - -impl Foo { - fn bar(&self) { - let (i, c): (isize, char) = self.a; - assert_eq!(Foo { a: i }.bar_int(), i); - assert_eq!(Foo { a: c }.bar_char(), c); - } -} - -impl Foo { - fn baz(&self) -> A { - self.a.clone() - } -} - -fn default_foo(x: Foo) { - let (i, c): (isize, char) = x.a; - assert_eq!(i, 1); - assert_eq!(c, 'a'); - - x.bar(); - assert_eq!(x.baz(), (1, 'a')); -} - -#[derive(PartialEq, Debug)] -struct BazHelper(T); - -#[derive(PartialEq, Debug)] -// Ensure that we can use previous type parameters in defaults. -struct Baz, V = Option>(T, U, V); - -fn main() { - default_foo(Foo { a: (1, 'a') }); - - let x: Baz = Baz(true, BazHelper(false), Some(BazHelper(true))); - assert_eq!(x, Baz(true, BazHelper(false), Some(BazHelper(true)))); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-derived-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-derived-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-derived-type.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-derived-type.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn g(x: X) -> X { return x; } - -#[derive(Clone)] -struct Pair { - a: T, - b: T -} - -fn f(t: T) -> Pair { - let x: Pair = Pair {a: t.clone(), b: t}; - return g::>(x); -} - -pub fn main() { - let b = f::(10); - println!("{}" ,b.a); - println!("{}", b.b); - assert_eq!(b.a, 10); - assert_eq!(b.b, 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-exterior-unique.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-exterior-unique.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-exterior-unique.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-exterior-unique.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -struct Recbox {x: Box} - -fn reclift(t: T) -> Recbox { return Recbox {x: box t}; } - -pub fn main() { - let foo: isize = 17; - let rbfoo: Recbox = reclift::(foo); - assert_eq!(*rbfoo.x, foo); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-extern-mangle.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-extern-mangle.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-extern-mangle.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-extern-mangle.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::ops::Add; - -extern "C" fn foo(a: T, b: T) -> T::Output { a + b } - -fn main() { - assert_eq!(100u8, foo(0u8, 100u8)); - assert_eq!(100u16, foo(0u16, 100u16)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-fn-infer.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-fn-infer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-fn-infer.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-fn-infer.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - - -// Issue #45: infer type parameters in function applications - -fn id(x: T) -> T { return x; } - -pub fn main() { let x: isize = 42; let y: isize = id(x); assert_eq!(x, y); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn id(x: T) -> T { return x; } - -#[derive(Copy, Clone)] -struct Triple {x: isize, y: isize, z: isize} - -pub fn main() { - let mut x = 62; - let mut y = 63; - let a = 'a'; - let mut b = 'b'; - let p: Triple = Triple {x: 65, y: 66, z: 67}; - let mut q: Triple = Triple {x: 68, y: 69, z: 70}; - y = id::(x); - println!("{}", y); - assert_eq!(x, y); - b = id::(a); - println!("{}", b); - assert_eq!(a, b); - q = id::(p); - x = p.z; - y = q.z; - println!("{}", y); - assert_eq!(x, y); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-fn-twice.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-fn-twice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-fn-twice.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-fn-twice.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - -// pretty-expanded FIXME #23616 - -mod foomod { - pub fn foo() { } -} - -pub fn main() { foomod::foo::(); foomod::foo::(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-fn-unique.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-fn-unique.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-fn-unique.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-fn-unique.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -fn f(x: Box) -> Box { return x; } - -pub fn main() { let x = f(box 3); println!("{}", *x); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-ivec-leak.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-ivec-leak.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-ivec-leak.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-ivec-leak.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -enum wrapper { wrapped(T), } - -pub fn main() { let _w = wrapper::wrapped(vec![1, 2, 3, 4, 5]); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-newtype-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-newtype-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-newtype-struct.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-newtype-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -struct S(T); - -pub fn main() { - let _s = S(2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-object.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-object.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-object.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-object.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -trait Foo { - fn get(&self) -> T; -} - -struct S { - x: isize -} - -impl Foo for S { - fn get(&self) -> isize { - self.x - } -} - -pub fn main() { - let x = box S { x: 1 }; - let y = x as Box>; - assert_eq!(y.get(), 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-recursive-tag.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-recursive-tag.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-recursive-tag.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-recursive-tag.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -#![feature(box_syntax)] - -enum list { cons(Box, Box>), nil, } - -pub fn main() { - let _a: list = - list::cons::(box 10, - box list::cons::(box 12, - box list::cons::(box 13, - box list::nil::))); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-static-methods.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-static-methods.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-static-methods.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-static-methods.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - -trait vec_utils { - fn map_(x: &Self, f: F) -> Vec where F: FnMut(&T) -> U; -} - -impl vec_utils for Vec { - fn map_(x: &Vec , mut f: F) -> Vec where F: FnMut(&T) -> U { - let mut r = Vec::new(); - for elt in x { - r.push(f(elt)); - } - r - } -} - -pub fn main() { - assert_eq!(vec_utils::map_(&vec![1,2,3], |&x| x+1), [2,3,4]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tag-corruption.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tag-corruption.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tag-corruption.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tag-corruption.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - -// This used to cause memory corruption in stage 0. -// pretty-expanded FIXME #23616 - -enum thing { some(K), } - -pub fn main() { let _x = thing::some("hi".to_string()); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tag-local.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tag-local.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tag-local.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tag-local.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -enum clam { a(T), } - -pub fn main() { let _c = clam::a(3); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tag-match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tag-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tag-match.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tag-match.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -enum foo { arm(T), } - -fn altfoo(f: foo) { - let mut hit = false; - match f { foo::arm::(_x) => { println!("in arm"); hit = true; } } - assert!((hit)); -} - -pub fn main() { altfoo::(foo::arm::(10)); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tag.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tag.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tag.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tag.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -#![allow(unused_variables)] -#![feature(box_syntax)] - -enum option { some(Box), none, } - -pub fn main() { - let mut a: option = option::some::(box 10); - a = option::none::; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tag-values.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tag-values.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tag-values.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tag-values.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -enum noption { some(T), } - -struct Pair { x: isize, y: isize } - -pub fn main() { - let nop: noption = noption::some::(5); - match nop { noption::some::(n) => { println!("{}", n); assert_eq!(n, 5); } } - let nop2: noption = noption::some(Pair{x: 17, y: 42}); - match nop2 { - noption::some(t) => { - println!("{}", t.x); - println!("{}", t.y); - assert_eq!(t.x, 17); - assert_eq!(t.y, 42); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-temporary.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-temporary.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-temporary.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-temporary.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn mk() -> isize { return 1; } - -fn chk(a: isize) { println!("{}", a); assert_eq!(a, 1); } - -fn apply(produce: fn() -> T, - consume: fn(T)) { - consume(produce()); -} - -pub fn main() { - let produce: fn() -> isize = mk; - let consume: fn(v: isize) = chk; - apply::(produce, consume); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tup.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tup.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tup.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-tup.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn get_third(t: (T, T, T)) -> T { let (_, _, x) = t; return x; } - -pub fn main() { - println!("{}", get_third((1, 2, 3))); - assert_eq!(get_third((1, 2, 3)), 3); - assert_eq!(get_third((5u8, 6u8, 7u8)), 7u8); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-type.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-type.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - -struct Pair {x: T, y: T} - -pub fn main() { - let x: Pair = Pair {x: 10, y: 12}; - assert_eq!(x.x, 10); - assert_eq!(x.y, 12); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-type-synonym.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-type-synonym.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-type-synonym.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-type-synonym.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -// pretty-expanded FIXME #23616 - -struct Foo { - a: T -} - -type Bar = Foo; - -fn takebar(_b: Bar) { } - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-unique.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-unique.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-unique.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/generics/generic-unique.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -struct Triple { x: T, y: T, z: T } - -fn box_it(x: Triple) -> Box> { return box x; } - -pub fn main() { - let x: Box> = box_it::(Triple{x: 1, y: 2, z: 3}); - assert_eq!(x.y, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-binder-levels-in-object-types.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we handle binder levels in object types correctly. -// Initially, the reference to `'tcx` in the object type -// `&Typer<'tcx>` was getting an incorrect binder level, yielding -// weird compilation ICEs and so forth. - -// pretty-expanded FIXME #23616 - -trait Typer<'tcx> { - fn method(&self, data: &'tcx isize) -> &'tcx isize { data } -} - -struct Tcx<'tcx> { - fields: &'tcx isize -} - -impl<'tcx> Typer<'tcx> for Tcx<'tcx> { -} - -fn g<'tcx>(typer: &Typer<'tcx>) { -} - -fn check_static_type<'x>(tcx: &Tcx<'x>) { - g(tcx) -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-debruijn-object-types-in-closures.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait Typer<'tcx> { - fn method(&self, data: &'tcx isize) -> &'tcx isize { data } - fn dummy(&self) { } -} - -fn g(_: F) where F: FnOnce(&Typer) {} - -fn h() { - g(|typer| typer.dummy()) -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait-object.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait-object.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait-object.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait-object.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// A basic test of using a higher-ranked trait bound. - - -trait FnLike { - fn call(&self, arg: A) -> R; -} - -type FnObject<'b> = for<'a> FnLike<&'a isize, &'a isize> + 'b; - -struct Identity; - -impl<'a, T> FnLike<&'a T, &'a T> for Identity { - fn call(&self, arg: &'a T) -> &'a T { - arg - } -} - -fn call_repeatedly(f: &FnObject) { - let x = 3; - let y = f.call(&x); - assert_eq!(3, *y); -} - -fn main() { - call_repeatedly(&Identity); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-fn-like-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// A basic test of using a higher-ranked trait bound. - - -trait FnLike { - fn call(&self, arg: A) -> R; -} - -struct Identity; - -impl<'a, T> FnLike<&'a T, &'a T> for Identity { - fn call(&self, arg: &'a T) -> &'a T { - arg - } -} - -fn call_repeatedly(f: F) - where F : for<'a> FnLike<&'a isize, &'a isize> -{ - let x = 3; - let y = f.call(&x); - assert_eq!(3, *y); -} - -fn main() { - call_repeatedly(Identity); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-opt-in-copy.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-opt-in-copy.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-opt-in-copy.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-opt-in-copy.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we handle binder levels correctly when checking whether a -// type can implement `Copy`. In particular, we had a bug where we failed to -// liberate the late-bound regions from the impl, and thus wound up -// searching for an impl of `for<'tcx> Foo<&'tcx T>`. The impl that -// exists however is `impl Copy for Foo` and the current rules -// did not consider that a match (something I would like to revise in -// a later PR). - -#![allow(dead_code)] - -use std::marker::PhantomData; - -#[derive(Copy, Clone)] -struct Foo { x: T } - -type Ty<'tcx> = &'tcx TyS<'tcx>; - -enum TyS<'tcx> { - Boop(PhantomData<*mut &'tcx ()>) -} - -#[derive(Copy, Clone)] -enum Bar<'tcx> { - Baz(Foo>) -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-parse.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-parse.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-parse.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-parse.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we can parse all the various places that a `for` keyword -// can appear representing universal quantification. - -// pretty-expanded FIXME #23616 - -#![allow(unused_variables)] -#![allow(dead_code)] - -trait Get { - fn get(&self, arg: A) -> R; -} - -// Parse HRTB with explicit `for` in a where-clause: - -fn foo00(t: T) - where T : for<'a> Get<&'a i32, &'a i32> -{ -} - -fn foo01 Get<&'a i32, &'a i32>>(t: T) -{ -} - -// Parse HRTB with explicit `for` in various sorts of types: - -fn foo10(t: Box Get>) { } -fn foo11(t: Box Fn(i32) -> i32>) { } - -fn foo20(t: for<'a> fn(i32) -> i32) { } -fn foo21(t: for<'a> unsafe fn(i32) -> i32) { } -fn foo22(t: for<'a> extern "C" fn(i32) -> i32) { } -fn foo23(t: for<'a> unsafe extern "C" fn(i32) -> i32) { } - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -// Test that `Fn(isize) -> isize + 'static` parses as `(Fn(isize) -> isize) + -// 'static` and not `Fn(isize) -> (isize + 'static)`. The latter would -// cause a compilation error. Issue #18772. - -fn adder(y: isize) -> Box isize + 'static> { - Box::new(move |x| y + x) -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus-where-clause.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus-where-clause.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus-where-clause.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-precedence-of-plus-where-clause.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -// Test that `F : Fn(isize) -> isize + Send` is interpreted as two -// distinct bounds on `F`. - -fn foo1(f: F) - where F : FnOnce(isize) -> isize + Send -{ - bar(f); -} - -fn foo2(f: F) - where F : FnOnce(isize) -> isize + Send -{ - baz(f); -} - -fn bar(f: F) { } - -fn baz isize>(f: F) { } - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-resolve-lifetime.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// A basic test of using a higher-ranked trait bound. - -// pretty-expanded FIXME #23616 - -trait FnLike { - fn call(&self, arg: A) -> R; -} - -type FnObject<'b> = for<'a> FnLike<&'a isize, &'a isize> + 'b; - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-trait-object-paren-notation.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-trait-object-paren-notation.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-trait-object-paren-notation.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-trait-object-paren-notation.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// A basic test of using a higher-ranked trait bound. - -trait FnLike { - fn call(&self, arg: A) -> R; -} - -type FnObject<'b> = for<'a> FnLike<(&'a i32,), &'a i32> + 'b; - -struct Identity; - -impl<'a, T> FnLike<(&'a T,), &'a T> for Identity { - fn call(&self, (arg,): (&'a T,)) -> &'a T { - arg - } -} - -fn call_repeatedly(f: &FnObject) { - let x = 3; - let y = f.call((&x,)); - assert_eq!(3, *y); -} - -fn main() { - call_repeatedly(&Identity); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-trait-object-passed-to-closure.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that `&PrinterSupport`, which is really short for `&'a -// PrinterSupport<'b>`, gets properly expanded when it appears in a -// closure type. This used to result in messed up De Bruijn indices. - -// pretty-expanded FIXME #23616 - -trait PrinterSupport<'ast> { - fn ast_map(&self) -> Option<&'ast usize> { None } -} - -struct NoAnn<'ast> { - f: Option<&'ast usize> -} - -impl<'ast> PrinterSupport<'ast> for NoAnn<'ast> { -} - -fn foo<'ast, G>(f: Option<&'ast usize>, g: G) where G: FnOnce(&PrinterSupport) { - let annotation = NoAnn { f: f }; - g(&annotation) -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-type-outlives.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-type-outlives.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-type-outlives.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-type-outlives.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test what happens when a HR obligation is applied to an impl with -// "outlives" bounds. Currently we're pretty conservative here; this -// will probably improve in time. - -trait Foo { - fn foo(&self, x: X) { } -} - -fn want_foo() - where T : for<'a> Foo<&'a isize> -{ -} - -/////////////////////////////////////////////////////////////////////////// -// Expressed as a where clause - -struct SomeStruct { - x: X -} - -impl<'a,X> Foo<&'a isize> for SomeStruct - where X : 'a -{ -} - -fn one() { - want_foo::>(); -} - -/////////////////////////////////////////////////////////////////////////// -// Expressed as shorthand - -struct AnotherStruct { - x: X -} - -impl<'a,X:'a> Foo<&'a isize> for AnotherStruct -{ -} - -fn two() { - want_foo::>(); -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-unboxed-closure-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-unboxed-closure-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-unboxed-closure-trait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/higher-rank-trait-bounds/hrtb-unboxed-closure-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test HRTB used with the `Fn` trait. - -fn foo(f: F) { - let x = 22; - f(&x); -} - -fn main() { - foo(|x: &isize| println!("{}", *x)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/auxiliary/legacy_interaction.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/auxiliary/legacy_interaction.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/auxiliary/legacy_interaction.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/auxiliary/legacy_interaction.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty pretty-printing is unhygienic - -#[macro_export] -macro_rules! m { - () => { - fn f() {} // (2) - g(); // (1) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/auxiliary/my_crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/auxiliary/my_crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/auxiliary/my_crate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/auxiliary/my_crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn f() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/auxiliary/unhygienic_example.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/auxiliary/unhygienic_example.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/auxiliary/unhygienic_example.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/auxiliary/unhygienic_example.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![crate_type = "lib"] - -extern crate my_crate; - -pub fn g() {} // (a) - -#[macro_export] -macro_rules! unhygienic_macro { - () => { - // (1) unhygienic: depends on `my_crate` in the crate root at the invocation site. - ::my_crate::f(); - - // (2) unhygienic: defines `f` at the invocation site (in addition to the above point). - use my_crate::f; - f(); - - g(); // (3) unhygienic: `g` needs to be in scope at use site. - - $crate::g(); // (4) hygienic: this always resolves to (a) - } -} - -#[allow(unused)] -fn test_unhygienic() { - unhygienic_macro!(); - f(); // `f` was defined at the use site -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/auxiliary/xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/auxiliary/xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/auxiliary/xcrate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/auxiliary/xcrate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(decl_macro)] -#![allow(unused)] - -pub use bar::test; - -extern crate std as foo; - -pub fn f() {} -use f as f2; - -mod bar { - pub fn g() {} - use baz::h; - - pub macro test() { - use std::mem; - use foo::cell; - ::f(); - ::f2(); - g(); - h(); - ::bar::h(); - } -} - -mod baz { - pub fn h() {} -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygiene-dodging-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygiene-dodging-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygiene-dodging-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygiene-dodging-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -mod x { - pub fn g() -> usize {14} -} - -pub fn main(){ - // should *not* shadow the module x: - let x = 9; - // use it to avoid warnings: - x+3; - assert_eq!(x::g(),14); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygiene.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygiene.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygiene.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygiene.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,124 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(unused)] - -fn f() { - let x = 0; - macro_rules! foo { () => { - assert_eq!(x, 0); - } } - - let x = 1; - foo!(); -} - -fn g() { - let x = 0; - macro_rules! m { ($m1:ident, $m2:ident, $x:ident) => { - macro_rules! $m1 { () => { ($x, x) } } - let x = 1; - macro_rules! $m2 { () => { ($x, x) } } - } } - - let x = 2; - m!(m2, m3, x); - - let x = 3; - assert_eq!(m2!(), (2, 0)); - assert_eq!(m3!(), (2, 1)); - - let x = 4; - m!(m4, m5, x); - assert_eq!(m4!(), (4, 0)); - assert_eq!(m5!(), (4, 1)); -} - -mod foo { - macro_rules! m { - ($f:ident : |$x:ident| $e:expr) => { - pub fn $f() -> (i32, i32) { - let x = 0; - let $x = 1; - (x, $e) - } - } - } - - m!(f: |x| x + 10); -} - -fn interpolated_pattern() { - let x = 0; - macro_rules! m { - ($p:pat, $e:expr) => { - let $p = 1; - assert_eq!((x, $e), (0, 1)); - } - } - - m!(x, x); -} - -fn patterns_in_macro_generated_macros() { - let x = 0; - macro_rules! m { - ($a:expr, $b:expr) => { - assert_eq!(x, 0); - let x = $a; - macro_rules! n { - () => { - (x, $b) - } - } - } - } - - let x = 1; - m!(2, x); - - let x = 3; - assert_eq!(n!(), (2, 1)); -} - -fn match_hygiene() { - let x = 0; - - macro_rules! m { - ($p:pat, $e:expr) => { - for result in &[Ok(1), Err(1)] { - match *result { - $p => { assert_eq!(($e, x), (1, 0)); } - Err(x) => { assert_eq!(($e, x), (2, 1)); } - } - } - } - } - - let x = 2; - m!(Ok(x), x); -} - -fn label_hygiene() { - 'a: loop { - macro_rules! m { () => { break 'a; } } - m!(); - } -} - -fn main() { - f(); - g(); - assert_eq!(foo::f(), (0, 11)); - interpolated_pattern(); - patterns_in_macro_generated_macros(); - match_hygiene(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygienic-labels-in-let.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygienic-labels-in-let.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygienic-labels-in-let.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygienic-labels-in-let.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that labels injected by macros do not break hygiene. This -// checks cases where the macros invocations are under the rhs of a -// let statement. - -// Issue #24278: The label/lifetime shadowing checker from #24162 -// conservatively ignores hygiene, and thus issues warnings that are -// both true- and false-positives for this test. - -macro_rules! loop_x { - ($e: expr) => { - // $e shouldn't be able to interact with this 'x - 'x: loop { $e } - } -} - -macro_rules! while_true { - ($e: expr) => { - // $e shouldn't be able to interact with this 'x - 'x: while 1 + 1 == 2 { $e } - } -} - -macro_rules! run_once { - ($e: expr) => { - // ditto - 'x: for _ in 0..1 { $e } - } -} - -pub fn main() { - let mut i = 0; - - let j: isize = { - 'x: loop { - // this 'x should refer to the outer loop, lexically - loop_x!(break 'x); - i += 1; - } - i + 1 - }; - assert_eq!(j, 1); - - let k: isize = { - 'x: for _ in 0..1 { - // ditto - loop_x!(break 'x); - i += 1; - } - i + 1 - }; - assert_eq!(k, 1); - - let l: isize = { - 'x: for _ in 0..1 { - // ditto - while_true!(break 'x); - i += 1; - } - i + 1 - }; - assert_eq!(l, 1); - - let n: isize = { - 'x: for _ in 0..1 { - // ditto - run_once!(continue 'x); - i += 1; - } - i + 1 - }; - assert_eq!(n, 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygienic-labels-in-let.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygienic-labels-in-let.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygienic-labels-in-let.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygienic-labels-in-let.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,300 +0,0 @@ -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:23:9 - | -LL | 'x: loop { $e } - | ^^ lifetime 'x already in scope -... -LL | 'x: loop { - | -- first declared here -LL | // this 'x should refer to the outer loop, lexically -LL | loop_x!(break 'x); - | ------------------ in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:55:9 - | -LL | 'x: loop { - | -- first declared here -... -LL | 'x: for _ in 0..1 { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:55:9 - | -LL | 'x: loop { $e } - | -- first declared here -... -LL | 'x: for _ in 0..1 { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:23:9 - | -LL | 'x: loop { $e } - | ^^ lifetime 'x already in scope -... -LL | 'x: loop { - | -- first declared here -... -LL | loop_x!(break 'x); - | ------------------ in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:23:9 - | -LL | 'x: loop { $e } - | ^^ - | | - | first declared here - | lifetime 'x already in scope -... -LL | loop_x!(break 'x); - | ------------------ in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:23:9 - | -LL | 'x: loop { $e } - | ^^ lifetime 'x already in scope -... -LL | 'x: for _ in 0..1 { - | -- first declared here -LL | // ditto -LL | loop_x!(break 'x); - | ------------------ in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:65:9 - | -LL | 'x: loop { - | -- first declared here -... -LL | 'x: for _ in 0..1 { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:65:9 - | -LL | 'x: loop { $e } - | -- first declared here -... -LL | 'x: for _ in 0..1 { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:65:9 - | -LL | 'x: for _ in 0..1 { - | -- first declared here -... -LL | 'x: for _ in 0..1 { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:65:9 - | -LL | 'x: loop { $e } - | -- first declared here -... -LL | 'x: for _ in 0..1 { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:30:9 - | -LL | 'x: while 1 + 1 == 2 { $e } - | ^^ lifetime 'x already in scope -... -LL | 'x: loop { - | -- first declared here -... -LL | while_true!(break 'x); - | ---------------------- in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:30:9 - | -LL | 'x: loop { $e } - | -- first declared here -... -LL | 'x: while 1 + 1 == 2 { $e } - | ^^ lifetime 'x already in scope -... -LL | while_true!(break 'x); - | ---------------------- in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:30:9 - | -LL | 'x: while 1 + 1 == 2 { $e } - | ^^ lifetime 'x already in scope -... -LL | 'x: for _ in 0..1 { - | -- first declared here -... -LL | while_true!(break 'x); - | ---------------------- in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:30:9 - | -LL | 'x: loop { $e } - | -- first declared here -... -LL | 'x: while 1 + 1 == 2 { $e } - | ^^ lifetime 'x already in scope -... -LL | while_true!(break 'x); - | ---------------------- in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:30:9 - | -LL | 'x: while 1 + 1 == 2 { $e } - | ^^ lifetime 'x already in scope -... -LL | 'x: for _ in 0..1 { - | -- first declared here -LL | // ditto -LL | while_true!(break 'x); - | ---------------------- in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:75:9 - | -LL | 'x: loop { - | -- first declared here -... -LL | 'x: for _ in 0..1 { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:75:9 - | -LL | 'x: loop { $e } - | -- first declared here -... -LL | 'x: for _ in 0..1 { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:75:9 - | -LL | 'x: for _ in 0..1 { - | -- first declared here -... -LL | 'x: for _ in 0..1 { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:75:9 - | -LL | 'x: loop { $e } - | -- first declared here -... -LL | 'x: for _ in 0..1 { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:75:9 - | -LL | 'x: for _ in 0..1 { - | -- first declared here -... -LL | 'x: for _ in 0..1 { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:75:9 - | -LL | 'x: while 1 + 1 == 2 { $e } - | -- first declared here -... -LL | 'x: for _ in 0..1 { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:37:9 - | -LL | 'x: for _ in 0..1 { $e } - | ^^ lifetime 'x already in scope -... -LL | 'x: loop { - | -- first declared here -... -LL | run_once!(continue 'x); - | ----------------------- in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:37:9 - | -LL | 'x: loop { $e } - | -- first declared here -... -LL | 'x: for _ in 0..1 { $e } - | ^^ lifetime 'x already in scope -... -LL | run_once!(continue 'x); - | ----------------------- in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:37:9 - | -LL | 'x: for _ in 0..1 { $e } - | ^^ lifetime 'x already in scope -... -LL | 'x: for _ in 0..1 { - | -- first declared here -... -LL | run_once!(continue 'x); - | ----------------------- in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:37:9 - | -LL | 'x: loop { $e } - | -- first declared here -... -LL | 'x: for _ in 0..1 { $e } - | ^^ lifetime 'x already in scope -... -LL | run_once!(continue 'x); - | ----------------------- in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:37:9 - | -LL | 'x: for _ in 0..1 { $e } - | ^^ lifetime 'x already in scope -... -LL | 'x: for _ in 0..1 { - | -- first declared here -... -LL | run_once!(continue 'x); - | ----------------------- in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:37:9 - | -LL | 'x: while 1 + 1 == 2 { $e } - | -- first declared here -... -LL | 'x: for _ in 0..1 { $e } - | ^^ lifetime 'x already in scope -... -LL | run_once!(continue 'x); - | ----------------------- in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:37:9 - | -LL | 'x: for _ in 0..1 { $e } - | ^^ lifetime 'x already in scope -... -LL | 'x: for _ in 0..1 { - | -- first declared here -LL | // ditto -LL | run_once!(continue 'x); - | ----------------------- in this macro invocation - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygienic-labels.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygienic-labels.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygienic-labels.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygienic-labels.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that labels injected by macros do not break hygiene. - -// Issue #24278: The label/lifetime shadowing checker from #24162 -// conservatively ignores hygiene, and thus issues warnings that are -// both true- and false-positives for this test. - -macro_rules! loop_x { - ($e: expr) => { - // $e shouldn't be able to interact with this 'x - 'x: loop { $e } - } -} - -macro_rules! run_once { - ($e: expr) => { - // ditto - 'x: for _ in 0..1 { $e } - } -} - -macro_rules! while_x { - ($e: expr) => { - // ditto - 'x: while 1 + 1 == 2 { $e } - } -} - -pub fn main() { - 'x: for _ in 0..1 { - // this 'x should refer to the outer loop, lexically - loop_x!(break 'x); - panic!("break doesn't act hygienically inside for loop"); - } - - 'x: loop { - // ditto - loop_x!(break 'x); - panic!("break doesn't act hygienically inside infinite loop"); - } - - 'x: while 1 + 1 == 2 { - while_x!(break 'x); - panic!("break doesn't act hygienically inside infinite while loop"); - } - - 'x: for _ in 0..1 { - // ditto - run_once!(continue 'x); - panic!("continue doesn't act hygienically inside for loop"); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygienic-labels.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygienic-labels.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygienic-labels.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/hygienic-labels.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,299 +0,0 @@ -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:21:9 - | -LL | 'x: loop { $e } - | ^^ lifetime 'x already in scope -... -LL | 'x: for _ in 0..1 { - | -- first declared here -LL | // this 'x should refer to the outer loop, lexically -LL | loop_x!(break 'x); - | ------------------ in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:46:5 - | -LL | 'x: for _ in 0..1 { - | -- first declared here -... -LL | 'x: loop { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:46:5 - | -LL | 'x: loop { $e } - | -- first declared here -... -LL | 'x: loop { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:21:9 - | -LL | 'x: loop { $e } - | ^^ lifetime 'x already in scope -... -LL | 'x: for _ in 0..1 { - | -- first declared here -... -LL | loop_x!(break 'x); - | ------------------ in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:21:9 - | -LL | 'x: loop { $e } - | ^^ - | | - | first declared here - | lifetime 'x already in scope -... -LL | loop_x!(break 'x); - | ------------------ in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:21:9 - | -LL | 'x: loop { $e } - | ^^ lifetime 'x already in scope -... -LL | 'x: loop { - | -- first declared here -LL | // ditto -LL | loop_x!(break 'x); - | ------------------ in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:52:5 - | -LL | 'x: for _ in 0..1 { - | -- first declared here -... -LL | 'x: while 1 + 1 == 2 { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:52:5 - | -LL | 'x: loop { $e } - | -- first declared here -... -LL | 'x: while 1 + 1 == 2 { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:52:5 - | -LL | 'x: loop { - | -- first declared here -... -LL | 'x: while 1 + 1 == 2 { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:52:5 - | -LL | 'x: loop { $e } - | -- first declared here -... -LL | 'x: while 1 + 1 == 2 { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:35:9 - | -LL | 'x: while 1 + 1 == 2 { $e } - | ^^ lifetime 'x already in scope -... -LL | 'x: for _ in 0..1 { - | -- first declared here -... -LL | while_x!(break 'x); - | ------------------- in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:35:9 - | -LL | 'x: loop { $e } - | -- first declared here -... -LL | 'x: while 1 + 1 == 2 { $e } - | ^^ lifetime 'x already in scope -... -LL | while_x!(break 'x); - | ------------------- in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:35:9 - | -LL | 'x: while 1 + 1 == 2 { $e } - | ^^ lifetime 'x already in scope -... -LL | 'x: loop { - | -- first declared here -... -LL | while_x!(break 'x); - | ------------------- in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:35:9 - | -LL | 'x: loop { $e } - | -- first declared here -... -LL | 'x: while 1 + 1 == 2 { $e } - | ^^ lifetime 'x already in scope -... -LL | while_x!(break 'x); - | ------------------- in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:35:9 - | -LL | 'x: while 1 + 1 == 2 { $e } - | ^^ lifetime 'x already in scope -... -LL | 'x: while 1 + 1 == 2 { - | -- first declared here -LL | while_x!(break 'x); - | ------------------- in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:57:5 - | -LL | 'x: for _ in 0..1 { - | -- first declared here -... -LL | 'x: for _ in 0..1 { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:57:5 - | -LL | 'x: loop { $e } - | -- first declared here -... -LL | 'x: for _ in 0..1 { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:57:5 - | -LL | 'x: loop { - | -- first declared here -... -LL | 'x: for _ in 0..1 { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:57:5 - | -LL | 'x: loop { $e } - | -- first declared here -... -LL | 'x: for _ in 0..1 { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:57:5 - | -LL | 'x: while 1 + 1 == 2 { - | -- first declared here -... -LL | 'x: for _ in 0..1 { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:57:5 - | -LL | 'x: while 1 + 1 == 2 { $e } - | -- first declared here -... -LL | 'x: for _ in 0..1 { - | ^^ lifetime 'x already in scope - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:28:9 - | -LL | 'x: for _ in 0..1 { $e } - | ^^ lifetime 'x already in scope -... -LL | 'x: for _ in 0..1 { - | -- first declared here -... -LL | run_once!(continue 'x); - | ----------------------- in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:28:9 - | -LL | 'x: loop { $e } - | -- first declared here -... -LL | 'x: for _ in 0..1 { $e } - | ^^ lifetime 'x already in scope -... -LL | run_once!(continue 'x); - | ----------------------- in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:28:9 - | -LL | 'x: for _ in 0..1 { $e } - | ^^ lifetime 'x already in scope -... -LL | 'x: loop { - | -- first declared here -... -LL | run_once!(continue 'x); - | ----------------------- in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:28:9 - | -LL | 'x: loop { $e } - | -- first declared here -... -LL | 'x: for _ in 0..1 { $e } - | ^^ lifetime 'x already in scope -... -LL | run_once!(continue 'x); - | ----------------------- in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:28:9 - | -LL | 'x: for _ in 0..1 { $e } - | ^^ lifetime 'x already in scope -... -LL | 'x: while 1 + 1 == 2 { - | -- first declared here -... -LL | run_once!(continue 'x); - | ----------------------- in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:28:9 - | -LL | 'x: for _ in 0..1 { $e } - | ^^ lifetime 'x already in scope -... -LL | 'x: while 1 + 1 == 2 { $e } - | -- first declared here -... -LL | run_once!(continue 'x); - | ----------------------- in this macro invocation - -warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:28:9 - | -LL | 'x: for _ in 0..1 { $e } - | ^^ lifetime 'x already in scope -... -LL | 'x: for _ in 0..1 { - | -- first declared here -LL | // ditto -LL | run_once!(continue 'x); - | ----------------------- in this macro invocation - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/issue-44128.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/issue-44128.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/issue-44128.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/issue-44128.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(decl_macro)] - -pub macro create_struct($a:ident) { - struct $a; - impl Clone for $a { - fn clone(&self) -> Self { - $a - } - } -} - -fn main() { - create_struct!(Test); - Test.clone(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/issue-47311.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/issue-47311.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/issue-47311.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/issue-47311.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty pretty-printing is unhygienic - -#![feature(decl_macro)] -#![allow(unused)] - -macro m($S:ident, $x:ident) { - $S { $x: 0 } -} - -mod foo { - struct S { x: i32 } - - fn f() { ::m!(S, x); } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/issue-47312.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/issue-47312.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/issue-47312.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/issue-47312.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty pretty-printing is unhygienic - -#![feature(decl_macro)] -#![allow(unused)] - -mod foo { - pub macro m($s:tt, $i:tt) { - $s.$i - } -} - -mod bar { - struct S(i32); - fn f() { - let s = S(0); - ::foo::m!(s, 0); - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/items.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/items.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/items.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/items.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty pretty-printing is unhygienic - -#![feature(decl_macro)] - -pub macro m($foo:ident, $f:ident, $e:expr) { - mod foo { - pub fn f() -> u32 { 0 } - pub fn $f() -> u64 { 0 } - } - - mod $foo { - pub fn f() -> i32 { 0 } - pub fn $f() -> i64 { 0 } - } - - let _: u32 = foo::f(); - let _: u64 = foo::$f(); - let _: i32 = $foo::f(); - let _: i64 = $foo::$f(); - let _: i64 = $e; -} - -fn main() { - m!(foo, f, foo::f()); - let _: i64 = foo::f(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/legacy_interaction.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/legacy_interaction.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/legacy_interaction.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/legacy_interaction.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty pretty-printing is unhygienic - -// aux-build:legacy_interaction.rs - -#![feature(decl_macro)] -#[allow(unused)] - -extern crate legacy_interaction; -// ^ defines -// ```rust -// macro_rules! m { -// () => { -// fn f() // (1) -// g() // (2) -// } -// } -// ```rust - -mod def_site { - // Unless this macro opts out of hygiene, it should resolve the same wherever it is invoked. - pub macro m2() { - ::legacy_interaction::m!(); - f(); // This should resolve to (1) - fn g() {} // We want (2) resolve to this, not to (4) - } -} - -mod use_site { - fn test() { - fn f() -> bool { true } // (3) - fn g() -> bool { true } // (4) - - ::def_site::m2!(); - - let _: bool = f(); // This should resolve to (3) - let _: bool = g(); // This should resolve to (4) - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/lexical.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/lexical.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/lexical.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/lexical.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty pretty-printing is unhygienic - -#![feature(decl_macro)] - -mod bar { - mod baz { - pub fn f() {} - } - - pub macro m($f:ident) { - baz::f(); - let _: i32 = $f(); - { - fn $f() -> u32 { 0 } - let _: u32 = $f(); - } - } -} - -fn main() { - fn f() -> i32 { 0 } - bar::m!(f); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/specialization.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/specialization.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/specialization.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/specialization.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty pretty-printing is unhygienic - -#![feature(decl_macro)] - -trait Tr { - fn f(&self) -> &'static str { - "This shouldn't happen" - } -} - -pub macro m($t:ty) { - impl Tr for $t { - fn f(&self) -> &'static str { - "Run me" - } - } -} - -struct S; -m!(S); - -fn main() { - assert_eq!(S.f(), "Run me"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/trait_items.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/trait_items.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/trait_items.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/trait_items.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty pretty-printing is unhygienic - -#![feature(decl_macro)] - -macro m($T:ident, $f:ident) { - pub trait $T { - fn f(&self) -> u32 { 0 } - fn $f(&self) -> i32 { 0 } - } - impl $T for () {} - - let _: u32 = ().f(); - let _: i32 = ().$f(); -} - -fn main() { - m!(T, f); - let _: i32 = ().f(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/ty_params.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/ty_params.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/ty_params.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/ty_params.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty pretty-printing is unhygienic - -#![feature(decl_macro)] - -macro m($T:ident) { - fn f(t: T, t2: $T) -> (T, $T) { - (t, t2) - } -} - -m!(T); - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/wrap_unhygienic_example.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/wrap_unhygienic_example.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/wrap_unhygienic_example.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/wrap_unhygienic_example.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty pretty-printing is unhygienic - -// aux-build:my_crate.rs -// aux-build:unhygienic_example.rs - -#![feature(decl_macro)] - -extern crate unhygienic_example; -extern crate my_crate; // (b) - -// Hygienic version of `unhygienic_macro`. -pub macro hygienic_macro() { - fn g() {} // (c) - ::unhygienic_example::unhygienic_macro!(); - // ^ Even though we invoke an unhygienic macro, `hygienic_macro` remains hygienic. - // In the above expansion: - // (1) `my_crate` always resolves to (b) regardless of invocation site. - // (2) The defined function `f` is only usable inside this macro definition. - // (3) `g` always resolves to (c) regardless of invocation site. - // (4) `$crate::g` remains hygienic and continues to resolve to (a). - - f(); -} - -#[allow(unused)] -fn test_hygienic_macro() { - hygienic_macro!(); - - fn f() {} // (d) no conflict - f(); // resolves to (d) -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/xcrate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/hygiene/xcrate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty pretty-printing is unhygienic - -// aux-build:xcrate.rs - -#![feature(decl_macro)] - -extern crate xcrate; - -fn main() { - xcrate::test!(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/auto-trait-leak.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/auto-trait-leak.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/auto-trait-leak.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/auto-trait-leak.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Fast path, main can see the concrete type returned. -fn before() -> impl FnMut(i32) { - let mut p = Box::new(0); - move |x| *p = x -} - -fn send(_: T) {} - -fn main() { - send(before()); - send(after()); -} - -// Deferred path, main has to wait until typeck finishes, -// to check if the return type of after is Send. -fn after() -> impl FnMut(i32) { - let mut p = Box::new(0); - move |x| *p = x -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/auxiliary/xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/auxiliary/xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/auxiliary/xcrate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/auxiliary/xcrate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// NOTE commented out due to issue #45994 -//pub fn fourway_add(a: i32) -> impl Fn(i32) -> impl Fn(i32) -> impl Fn(i32) -> i32 { -// move |b| move |c| move |d| a + b + c + d -//} - -fn some_internal_fn() -> u32 { - 1 -} - -fn other_internal_fn() -> u32 { - 1 -} - -// See #40839 -pub fn return_closure_accessing_internal_fn() -> impl Fn() -> u32 { - || { - some_internal_fn() + 1 - } -} - -pub fn return_internal_fn() -> impl Fn() -> u32 { - other_internal_fn -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/bounds_regression.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/bounds_regression.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/bounds_regression.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/bounds_regression.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub trait FakeGenerator { - type Yield; - type Return; -} - -pub trait FakeFuture { - type Output; -} - -pub fn future_from_generator< - T: FakeGenerator ->(x: T) -> impl FakeFuture { - GenFuture(x) -} - -struct GenFuture>(T); - -impl> FakeFuture for GenFuture { - type Output = T::Return; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/equality.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/equality.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/equality.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/equality.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(specialization)] - -trait Foo: std::fmt::Debug + Eq {} - -impl Foo for T {} - -fn hide(x: T) -> impl Foo { - x -} - -trait Leak: Sized { - fn leak(self) -> T; -} -impl Leak for U { - default fn leak(self) -> T { panic!("type mismatch") } -} -impl Leak for T { - fn leak(self) -> T { self } -} - -trait CheckIfSend: Sized { - type T: Default; - fn check(self) -> Self::T { Default::default() } -} -impl CheckIfSend for T { - default type T = (); -} -impl CheckIfSend for T { - type T = bool; -} - -fn lucky_seven() -> impl Fn(usize) -> u8 { - let a = [1, 2, 3, 4, 5, 6, 7]; - move |i| a[i] -} - -fn main() { - assert_eq!(hide(42), hide(42)); - - assert_eq!(std::mem::size_of_val(&hide([0_u8; 5])), 5); - assert_eq!(std::mem::size_of_val(&lucky_seven()), 7); - - assert_eq!(Leak::::leak(hide(5_i32)), 5_i32); - - assert_eq!(CheckIfSend::check(hide(0_i32)), false); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/example-calendar.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/example-calendar.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/example-calendar.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/example-calendar.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,894 +0,0 @@ -// Copyright 2016-2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// revisions: normal nll -//[nll] compile-flags:-Zborrowck=mir - -#![feature(fn_traits, - step_trait, - unboxed_closures, -)] - -//! Derived from: . -//! -//! Originally converted to Rust by [Daniel Keep](https://github.com/DanielKeep). - -use std::fmt::Write; -use std::mem; - -/// Date representation. -#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] -struct NaiveDate(i32, u32, u32); - -impl NaiveDate { - pub fn from_ymd(y: i32, m: u32, d: u32) -> NaiveDate { - assert!(1 <= m && m <= 12, "m = {:?}", m); - assert!(1 <= d && d <= NaiveDate(y, m, 1).days_in_month(), "d = {:?}", d); - NaiveDate(y, m, d) - } - - pub fn year(&self) -> i32 { - self.0 - } - - pub fn month(&self) -> u32 { - self.1 - } - - pub fn day(&self) -> u32 { - self.2 - } - - pub fn succ(&self) -> NaiveDate { - let (mut y, mut m, mut d, n) = ( - self.year(), self.month(), self.day()+1, self.days_in_month()); - if d > n { - d = 1; - m += 1; - } - if m > 12 { - m = 1; - y += 1; - } - NaiveDate::from_ymd(y, m, d) - } - - pub fn weekday(&self) -> Weekday { - use Weekday::*; - - // 0 = Sunday - let year = self.year(); - let dow_jan_1 = (year*365 + ((year-1) / 4) - ((year-1) / 100) + ((year-1) / 400)) % 7; - let dow = (dow_jan_1 + (self.day_of_year() as i32 - 1)) % 7; - [Sun, Mon, Tue, Wed, Thu, Fri, Sat][dow as usize] - } - - pub fn isoweekdate(&self) -> (i32, u32, Weekday) { - let first_dow_mon_0 = self.year_first_day_of_week().num_days_from_monday(); - - // Work out this date's DOtY and week number, not including year adjustment. - let doy_0 = self.day_of_year() - 1; - let mut week_mon_0: i32 = ((first_dow_mon_0 + doy_0) / 7) as i32; - - if self.first_week_in_prev_year() { - week_mon_0 -= 1; - } - - let weeks_in_year = self.last_week_number(); - - // Work out the final result. - // If the week is -1 or >= weeks_in_year, we will need to adjust the year. - let year = self.year(); - let wd = self.weekday(); - - if week_mon_0 < 0 { - (year - 1, NaiveDate::from_ymd(year - 1, 1, 1).last_week_number(), wd) - } else if week_mon_0 >= weeks_in_year as i32 { - (year + 1, (week_mon_0 + 1 - weeks_in_year as i32) as u32, wd) - } else { - (year, (week_mon_0 + 1) as u32, wd) - } - } - - fn first_week_in_prev_year(&self) -> bool { - let first_dow_mon_0 = self.year_first_day_of_week().num_days_from_monday(); - - // Any day in the year *before* the first Monday of that year - // is considered to be in the last week of the previous year, - // assuming the first week has *less* than four days in it. - // Adjust the week appropriately. - ((7 - first_dow_mon_0) % 7) < 4 - } - - fn year_first_day_of_week(&self) -> Weekday { - NaiveDate::from_ymd(self.year(), 1, 1).weekday() - } - - fn weeks_in_year(&self) -> u32 { - let days_in_last_week = self.year_first_day_of_week().num_days_from_monday() + 1; - if days_in_last_week >= 4 { 53 } else { 52 } - } - - fn last_week_number(&self) -> u32 { - let wiy = self.weeks_in_year(); - if self.first_week_in_prev_year() { wiy - 1 } else { wiy } - } - - fn day_of_year(&self) -> u32 { - (1..self.1).map(|m| NaiveDate::from_ymd(self.year(), m, 1).days_in_month()) - .fold(0, |a,b| a+b) + self.day() - } - - fn is_leap_year(&self) -> bool { - let year = self.year(); - if year % 4 != 0 { - return false - } else if year % 100 != 0 { - return true - } else if year % 400 != 0 { - return false - } else { - return true - } - } - - fn days_in_month(&self) -> u32 { - match self.month() { - /* Jan */ 1 => 31, - /* Feb */ 2 => if self.is_leap_year() { 29 } else { 28 }, - /* Mar */ 3 => 31, - /* Apr */ 4 => 30, - /* May */ 5 => 31, - /* Jun */ 6 => 30, - /* Jul */ 7 => 31, - /* Aug */ 8 => 31, - /* Sep */ 9 => 30, - /* Oct */ 10 => 31, - /* Nov */ 11 => 30, - /* Dec */ 12 => 31, - _ => unreachable!() - } - } -} - -impl<'a, 'b> std::ops::Add<&'b NaiveDate> for &'a NaiveDate { - type Output = NaiveDate; - - fn add(self, other: &'b NaiveDate) -> NaiveDate { - assert_eq!(*other, NaiveDate(0, 0, 1)); - self.succ() - } -} - -impl std::iter::Step for NaiveDate { - fn steps_between(_: &Self, _: &Self) -> Option { - unimplemented!() - } - - fn replace_one(&mut self) -> Self { - mem::replace(self, NaiveDate(0, 0, 1)) - } - - fn replace_zero(&mut self) -> Self { - mem::replace(self, NaiveDate(0, 0, 0)) - } - - fn add_one(&self) -> Self { - self.succ() - } - - fn sub_one(&self) -> Self { - unimplemented!() - } - - fn add_usize(&self, _: usize) -> Option { - unimplemented!() - } -} - -#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] -pub enum Weekday { - Mon, - Tue, - Wed, - Thu, - Fri, - Sat, - Sun, -} - -impl Weekday { - pub fn num_days_from_monday(&self) -> u32 { - use Weekday::*; - match *self { - Mon => 0, - Tue => 1, - Wed => 2, - Thu => 3, - Fri => 4, - Sat => 5, - Sun => 6, - } - } - - pub fn num_days_from_sunday(&self) -> u32 { - use Weekday::*; - match *self { - Sun => 0, - Mon => 1, - Tue => 2, - Wed => 3, - Thu => 4, - Fri => 5, - Sat => 6, - } - } -} - -/// GroupBy implementation. -struct GroupBy { - it: std::iter::Peekable, - f: F, -} - -impl Clone for GroupBy -where - It: Iterator + Clone, - It::Item: Clone, - F: Clone, -{ - fn clone(&self) -> Self { - GroupBy { - it: self.it.clone(), - f: self.f.clone(), - } - } -} - -impl<'a, G, It: 'a, F: 'a> Iterator for GroupBy -where It: Iterator + Clone, - It::Item: Clone, - F: Clone + FnMut(&It::Item) -> G, - G: Eq + Clone -{ - type Item = (G, InGroup, F, G>); - - fn next(&mut self) -> Option { - self.it.peek().map(&mut self.f).map(|key| { - let start = self.it.clone(); - while let Some(k) = self.it.peek().map(&mut self.f) { - if key != k { - break; - } - self.it.next(); - } - - (key.clone(), InGroup { - it: start, - f: self.f.clone(), - g: key - }) - }) - } -} - -#[derive(Copy, Clone)] -struct InGroup { - it: It, - f: F, - g: G -} - -impl G, G: Eq> Iterator for InGroup { - type Item = It::Item; - - fn next(&mut self) -> Option { - self.it.next().and_then(|x| { - if (self.f)(&x) == self.g { Some(x) } else { None } - }) - } -} - -trait IteratorExt: Iterator + Sized { - fn group_by(self, f: F) -> GroupBy - where F: Clone + FnMut(&Self::Item) -> G, - G: Eq - { - GroupBy { it: self.peekable(), f } - } - - fn join(mut self, sep: &str) -> String - where Self::Item: std::fmt::Display { - let mut s = String::new(); - if let Some(e) = self.next() { - write!(s, "{}", e); - for e in self { - s.push_str(sep); - write!(s, "{}", e); - } - } - s - } - - // HACK(eddyb) Only needed because `impl Trait` can't be - // used with trait methods: `.foo()` becomes `.__(foo)`. - fn __(self, f: F) -> R - where F: FnOnce(Self) -> R { - f(self) - } -} - -impl IteratorExt for It where It: Iterator {} - -/// -/// Generates an iterator that yields exactly n spaces. -/// -fn spaces(n: usize) -> std::iter::Take> { - std::iter::repeat(' ').take(n) -} - -fn test_spaces() { - assert_eq!(spaces(0).collect::(), ""); - assert_eq!(spaces(10).collect::(), " ") -} - -/// -/// Returns an iterator of dates in a given year. -/// -fn dates_in_year(year: i32) -> impl Iterator+Clone { - InGroup { - it: NaiveDate::from_ymd(year, 1, 1).., - f: |d: &NaiveDate| d.year(), - g: year - } -} - -fn test_dates_in_year() { - { - let mut dates = dates_in_year(2013); - assert_eq!(dates.next(), Some(NaiveDate::from_ymd(2013, 1, 1))); - - // Check increment - assert_eq!(dates.next(), Some(NaiveDate::from_ymd(2013, 1, 2))); - - // Check monthly rollover - for _ in 3..31 { - assert!(dates.next() != None); - } - - assert_eq!(dates.next(), Some(NaiveDate::from_ymd(2013, 1, 31))); - assert_eq!(dates.next(), Some(NaiveDate::from_ymd(2013, 2, 1))); - } - - { - // Check length of year - let mut dates = dates_in_year(2013); - for _ in 0..365 { - assert!(dates.next() != None); - } - assert_eq!(dates.next(), None); - } - - { - // Check length of leap year - let mut dates = dates_in_year(1984); - for _ in 0..366 { - assert!(dates.next() != None); - } - assert_eq!(dates.next(), None); - } -} - -/// -/// Convenience trait for verifying that a given type iterates over -/// `NaiveDate`s. -/// -trait DateIterator: Iterator + Clone {} -impl DateIterator for It where It: Iterator + Clone {} - -fn test_group_by() { - let input = [ - [1, 1], - [1, 1], - [1, 2], - [2, 2], - [2, 3], - [2, 3], - [3, 3] - ]; - - let by_x = input.iter().cloned().group_by(|a| a[0]); - let expected_1: &[&[[i32; 2]]] = &[ - &[[1, 1], [1, 1], [1, 2]], - &[[2, 2], [2, 3], [2, 3]], - &[[3, 3]] - ]; - for ((_, a), b) in by_x.zip(expected_1.iter().cloned()) { - assert_eq!(&a.collect::>()[..], b); - } - - let by_y = input.iter().cloned().group_by(|a| a[1]); - let expected_2: &[&[[i32; 2]]] = &[ - &[[1, 1], [1, 1]], - &[[1, 2], [2, 2]], - &[[2, 3], [2, 3], [3, 3]] - ]; - for ((_, a), b) in by_y.zip(expected_2.iter().cloned()) { - assert_eq!(&a.collect::>()[..], b); - } -} - -/// -/// Groups an iterator of dates by month. -/// -fn by_month(it: impl Iterator + Clone) - -> impl Iterator + Clone)> + Clone -{ - it.group_by(|d| d.month()) -} - -fn test_by_month() { - let mut months = dates_in_year(2013).__(by_month); - for (month, (_, mut date)) in (1..13).zip(&mut months) { - assert_eq!(date.nth(0).unwrap(), NaiveDate::from_ymd(2013, month, 1)); - } - assert!(months.next().is_none()); -} - -/// -/// Groups an iterator of dates by week. -/// -fn by_week(it: impl DateIterator) - -> impl Iterator + Clone -{ - // We go forward one day because `isoweekdate` considers the week to start on a Monday. - it.group_by(|d| d.succ().isoweekdate().1) -} - -fn test_isoweekdate() { - fn weeks_uniq(year: i32) -> Vec<((i32, u32), u32)> { - let mut weeks = dates_in_year(year).map(|d| d.isoweekdate()) - .map(|(y,w,_)| (y,w)); - let mut result = vec![]; - let mut accum = (weeks.next().unwrap(), 1); - for yw in weeks { - if accum.0 == yw { - accum.1 += 1; - } else { - result.push(accum); - accum = (yw, 1); - } - } - result.push(accum); - result - } - - let wu_1984 = weeks_uniq(1984); - assert_eq!(&wu_1984[..2], &[((1983, 52), 1), ((1984, 1), 7)]); - assert_eq!(&wu_1984[wu_1984.len()-2..], &[((1984, 52), 7), ((1985, 1), 1)]); - - let wu_2013 = weeks_uniq(2013); - assert_eq!(&wu_2013[..2], &[((2013, 1), 6), ((2013, 2), 7)]); - assert_eq!(&wu_2013[wu_2013.len()-2..], &[((2013, 52), 7), ((2014, 1), 2)]); - - let wu_2015 = weeks_uniq(2015); - assert_eq!(&wu_2015[..2], &[((2015, 1), 4), ((2015, 2), 7)]); - assert_eq!(&wu_2015[wu_2015.len()-2..], &[((2015, 52), 7), ((2015, 53), 4)]); -} - -fn test_by_week() { - let mut weeks = dates_in_year(2013).__(by_week); - assert_eq!( - &*weeks.next().unwrap().1.collect::>(), - &[ - NaiveDate::from_ymd(2013, 1, 1), - NaiveDate::from_ymd(2013, 1, 2), - NaiveDate::from_ymd(2013, 1, 3), - NaiveDate::from_ymd(2013, 1, 4), - NaiveDate::from_ymd(2013, 1, 5), - ] - ); - assert_eq!( - &*weeks.next().unwrap().1.collect::>(), - &[ - NaiveDate::from_ymd(2013, 1, 6), - NaiveDate::from_ymd(2013, 1, 7), - NaiveDate::from_ymd(2013, 1, 8), - NaiveDate::from_ymd(2013, 1, 9), - NaiveDate::from_ymd(2013, 1, 10), - NaiveDate::from_ymd(2013, 1, 11), - NaiveDate::from_ymd(2013, 1, 12), - ] - ); - assert_eq!(weeks.next().unwrap().1.nth(0).unwrap(), NaiveDate::from_ymd(2013, 1, 13)); -} - -/// The number of columns per day in the formatted output. -const COLS_PER_DAY: u32 = 3; - -/// The number of columns per week in the formatted output. -const COLS_PER_WEEK: u32 = 7 * COLS_PER_DAY; - -/// -/// Formats an iterator of weeks into an iterator of strings. -/// -fn format_weeks(it: impl Iterator) -> impl Iterator { - it.map(|week| { - let mut buf = String::with_capacity((COLS_PER_DAY * COLS_PER_WEEK + 2) as usize); - - // Format each day into its own cell and append to target string. - let mut last_day = 0; - let mut first = true; - for d in week { - last_day = d.weekday().num_days_from_sunday(); - - // Insert enough filler to align the first day with its respective day-of-week. - if first { - buf.extend(spaces((COLS_PER_DAY * last_day) as usize)); - first = false; - } - - write!(buf, " {:>2}", d.day()); - } - - // Insert more filler at the end to fill up the remainder of the week, - // if its a short week (e.g. at the end of the month). - buf.extend(spaces((COLS_PER_DAY * (6 - last_day)) as usize)); - buf - }) -} - -fn test_format_weeks() { - let jan_2013 = dates_in_year(2013) - .__(by_month).next() // pick January 2013 for testing purposes - // NOTE: This `map` is because `next` returns an `Option<_>`. - .map(|(_, month)| - month.__(by_week) - .map(|(_, weeks)| weeks) - .__(format_weeks) - .join("\n")); - - assert_eq!( - jan_2013.as_ref().map(|s| &**s), - Some(" 1 2 3 4 5\n\ - \x20 6 7 8 9 10 11 12\n\ - \x2013 14 15 16 17 18 19\n\ - \x2020 21 22 23 24 25 26\n\ - \x2027 28 29 30 31 ") - ); -} - -/// -/// Formats the name of a month, centered on COLS_PER_WEEK. -/// -fn month_title(month: u32) -> String { - const MONTH_NAMES: &'static [&'static str] = &[ - "January", "February", "March", "April", "May", "June", - "July", "August", "September", "October", "November", "December" - ]; - assert_eq!(MONTH_NAMES.len(), 12); - - // Determine how many spaces before and after the month name - // we need to center it over the formatted weeks in the month. - let name = MONTH_NAMES[(month - 1) as usize]; - assert!(name.len() < COLS_PER_WEEK as usize); - let before = (COLS_PER_WEEK as usize - name.len()) / 2; - let after = COLS_PER_WEEK as usize - name.len() - before; - - // NOTE: Being slightly more verbose to avoid extra allocations. - let mut result = String::with_capacity(COLS_PER_WEEK as usize); - result.extend(spaces(before)); - result.push_str(name); - result.extend(spaces(after)); - result -} - -fn test_month_title() { - assert_eq!(month_title(1).len(), COLS_PER_WEEK as usize); -} - -/// -/// Formats a month. -/// -fn format_month(it: impl DateIterator) -> impl Iterator { - let mut month_days = it.peekable(); - let title = month_title(month_days.peek().unwrap().month()); - - Some(title).into_iter() - .chain(month_days.__(by_week) - .map(|(_, week)| week) - .__(format_weeks)) -} - -fn test_format_month() { - let month_fmt = dates_in_year(2013) - .__(by_month).next() // Pick January as a test case - .map(|(_, days)| days.into_iter() - .__(format_month) - .join("\n")); - - assert_eq!( - month_fmt.as_ref().map(|s| &**s), - Some(" January \n\ - \x20 1 2 3 4 5\n\ - \x20 6 7 8 9 10 11 12\n\ - \x2013 14 15 16 17 18 19\n\ - \x2020 21 22 23 24 25 26\n\ - \x2027 28 29 30 31 ") - ); -} - - -/// -/// Formats an iterator of months. -/// -fn format_months(it: impl Iterator) - -> impl Iterator> -{ - it.map(format_month) -} - -/// -/// Takes an iterator of iterators of strings; the sub-iterators are consumed -/// in lock-step, with their elements joined together. -/// -trait PasteBlocks: Iterator + Sized -where Self::Item: Iterator { - fn paste_blocks(self, sep_width: usize) -> PasteBlocksIter { - PasteBlocksIter { - iters: self.collect(), - cache: vec![], - col_widths: None, - sep_width: sep_width, - } - } -} - -impl PasteBlocks for It where It: Iterator, It::Item: Iterator {} - -struct PasteBlocksIter -where StrIt: Iterator { - iters: Vec, - cache: Vec>, - col_widths: Option>, - sep_width: usize, -} - -impl Iterator for PasteBlocksIter -where StrIt: Iterator { - type Item = String; - - fn next(&mut self) -> Option { - self.cache.clear(); - - // `cache` is now the next line from each iterator. - self.cache.extend(self.iters.iter_mut().map(|it| it.next())); - - // If every line in `cache` is `None`, we have nothing further to do. - if self.cache.iter().all(|e| e.is_none()) { return None } - - // Get the column widths if we haven't already. - let col_widths = match self.col_widths { - Some(ref v) => &**v, - None => { - self.col_widths = Some(self.cache.iter() - .map(|ms| ms.as_ref().map(|s| s.len()).unwrap_or(0)) - .collect()); - &**self.col_widths.as_ref().unwrap() - } - }; - - // Fill in any `None`s with spaces. - let mut parts = col_widths.iter().cloned().zip(self.cache.iter_mut()) - .map(|(w,ms)| ms.take().unwrap_or_else(|| spaces(w).collect())); - - // Join them all together. - let first = parts.next().unwrap_or(String::new()); - let sep_width = self.sep_width; - Some(parts.fold(first, |mut accum, next| { - accum.extend(spaces(sep_width)); - accum.push_str(&next); - accum - })) - } -} - -fn test_paste_blocks() { - let row = dates_in_year(2013) - .__(by_month).map(|(_, days)| days) - .take(3) - .__(format_months) - .paste_blocks(1) - .join("\n"); - assert_eq!( - &*row, - " January February March \n\ - \x20 1 2 3 4 5 1 2 1 2\n\ - \x20 6 7 8 9 10 11 12 3 4 5 6 7 8 9 3 4 5 6 7 8 9\n\ - \x2013 14 15 16 17 18 19 10 11 12 13 14 15 16 10 11 12 13 14 15 16\n\ - \x2020 21 22 23 24 25 26 17 18 19 20 21 22 23 17 18 19 20 21 22 23\n\ - \x2027 28 29 30 31 24 25 26 27 28 24 25 26 27 28 29 30\n\ - \x20 31 " - ); -} - -/// -/// Produces an iterator that yields `n` elements at a time. -/// -trait Chunks: Iterator + Sized { - fn chunks(self, n: usize) -> ChunksIter { - assert!(n > 0); - ChunksIter { - it: self, - n: n, - } - } -} - -impl Chunks for It where It: Iterator {} - -struct ChunksIter -where It: Iterator { - it: It, - n: usize, -} - -// NOTE: `chunks` in Rust is more-or-less impossible without overhead of some kind. -// Aliasing rules mean you need to add dynamic borrow checking, and the design of -// `Iterator` means that you need to have the iterator's state kept in an allocation -// that is jointly owned by the iterator itself and the sub-iterator. -// As such, I've chosen to cop-out and just heap-allocate each chunk. - -impl Iterator for ChunksIter -where It: Iterator { - type Item = Vec; - - fn next(&mut self) -> Option> { - let first = match self.it.next() { - Some(e) => e, - None => return None - }; - - let mut result = Vec::with_capacity(self.n); - result.push(first); - - Some((&mut self.it).take(self.n-1) - .fold(result, |mut acc, next| { acc.push(next); acc })) - } -} - -fn test_chunks() { - let r = &[1, 2, 3, 4, 5, 6, 7]; - let c = r.iter().cloned().chunks(3).collect::>(); - assert_eq!(&*c, &[vec![1, 2, 3], vec![4, 5, 6], vec![7]]); -} - -/// -/// Formats a year. -/// -fn format_year(year: i32, months_per_row: usize) -> String { - const COL_SPACING: usize = 1; - - // Start by generating all dates for the given year. - dates_in_year(year) - - // Group them by month and throw away month number. - .__(by_month).map(|(_, days)| days) - - // Group the months into horizontal rows. - .chunks(months_per_row) - - // Format each row - .map(|r| r.into_iter() - // By formatting each month - .__(format_months) - - // Horizontally pasting each respective month's lines together. - .paste_blocks(COL_SPACING) - .join("\n") - ) - - // Insert a blank line between each row - .join("\n\n") -} - -fn test_format_year() { - const MONTHS_PER_ROW: usize = 3; - - macro_rules! assert_eq_cal { - ($lhs:expr, $rhs:expr) => { - if $lhs != $rhs { - println!("got:\n```\n{}\n```\n", $lhs.replace(" ", ".")); - println!("expected:\n```\n{}\n```", $rhs.replace(" ", ".")); - panic!("calendars didn't match!"); - } - } - } - - assert_eq_cal!(&format_year(1984, MONTHS_PER_ROW), "\ -\x20 January February March \n\ -\x20 1 2 3 4 5 6 7 1 2 3 4 1 2 3\n\ -\x20 8 9 10 11 12 13 14 5 6 7 8 9 10 11 4 5 6 7 8 9 10\n\ -\x2015 16 17 18 19 20 21 12 13 14 15 16 17 18 11 12 13 14 15 16 17\n\ -\x2022 23 24 25 26 27 28 19 20 21 22 23 24 25 18 19 20 21 22 23 24\n\ -\x2029 30 31 26 27 28 29 25 26 27 28 29 30 31\n\ -\n\ -\x20 April May June \n\ -\x20 1 2 3 4 5 6 7 1 2 3 4 5 1 2\n\ -\x20 8 9 10 11 12 13 14 6 7 8 9 10 11 12 3 4 5 6 7 8 9\n\ -\x2015 16 17 18 19 20 21 13 14 15 16 17 18 19 10 11 12 13 14 15 16\n\ -\x2022 23 24 25 26 27 28 20 21 22 23 24 25 26 17 18 19 20 21 22 23\n\ -\x2029 30 27 28 29 30 31 24 25 26 27 28 29 30\n\ -\n\ -\x20 July August September \n\ -\x20 1 2 3 4 5 6 7 1 2 3 4 1\n\ -\x20 8 9 10 11 12 13 14 5 6 7 8 9 10 11 2 3 4 5 6 7 8\n\ -\x2015 16 17 18 19 20 21 12 13 14 15 16 17 18 9 10 11 12 13 14 15\n\ -\x2022 23 24 25 26 27 28 19 20 21 22 23 24 25 16 17 18 19 20 21 22\n\ -\x2029 30 31 26 27 28 29 30 31 23 24 25 26 27 28 29\n\ -\x20 30 \n\ -\n\ -\x20 October November December \n\ -\x20 1 2 3 4 5 6 1 2 3 1\n\ -\x20 7 8 9 10 11 12 13 4 5 6 7 8 9 10 2 3 4 5 6 7 8\n\ -\x2014 15 16 17 18 19 20 11 12 13 14 15 16 17 9 10 11 12 13 14 15\n\ -\x2021 22 23 24 25 26 27 18 19 20 21 22 23 24 16 17 18 19 20 21 22\n\ -\x2028 29 30 31 25 26 27 28 29 30 23 24 25 26 27 28 29\n\ -\x20 30 31 "); - - assert_eq_cal!(&format_year(2015, MONTHS_PER_ROW), "\ -\x20 January February March \n\ -\x20 1 2 3 1 2 3 4 5 6 7 1 2 3 4 5 6 7\n\ -\x20 4 5 6 7 8 9 10 8 9 10 11 12 13 14 8 9 10 11 12 13 14\n\ -\x2011 12 13 14 15 16 17 15 16 17 18 19 20 21 15 16 17 18 19 20 21\n\ -\x2018 19 20 21 22 23 24 22 23 24 25 26 27 28 22 23 24 25 26 27 28\n\ -\x2025 26 27 28 29 30 31 29 30 31 \n\ -\n\ -\x20 April May June \n\ -\x20 1 2 3 4 1 2 1 2 3 4 5 6\n\ -\x20 5 6 7 8 9 10 11 3 4 5 6 7 8 9 7 8 9 10 11 12 13\n\ -\x2012 13 14 15 16 17 18 10 11 12 13 14 15 16 14 15 16 17 18 19 20\n\ -\x2019 20 21 22 23 24 25 17 18 19 20 21 22 23 21 22 23 24 25 26 27\n\ -\x2026 27 28 29 30 24 25 26 27 28 29 30 28 29 30 \n\ -\x20 31 \n\ -\n\ -\x20 July August September \n\ -\x20 1 2 3 4 1 1 2 3 4 5\n\ -\x20 5 6 7 8 9 10 11 2 3 4 5 6 7 8 6 7 8 9 10 11 12\n\ -\x2012 13 14 15 16 17 18 9 10 11 12 13 14 15 13 14 15 16 17 18 19\n\ -\x2019 20 21 22 23 24 25 16 17 18 19 20 21 22 20 21 22 23 24 25 26\n\ -\x2026 27 28 29 30 31 23 24 25 26 27 28 29 27 28 29 30 \n\ -\x20 30 31 \n\ -\n\ -\x20 October November December \n\ -\x20 1 2 3 1 2 3 4 5 6 7 1 2 3 4 5\n\ -\x20 4 5 6 7 8 9 10 8 9 10 11 12 13 14 6 7 8 9 10 11 12\n\ -\x2011 12 13 14 15 16 17 15 16 17 18 19 20 21 13 14 15 16 17 18 19\n\ -\x2018 19 20 21 22 23 24 22 23 24 25 26 27 28 20 21 22 23 24 25 26\n\ -\x2025 26 27 28 29 30 31 29 30 27 28 29 30 31 "); -} - -fn main() { - // Run tests. - test_spaces(); - test_dates_in_year(); - test_group_by(); - test_by_month(); - test_isoweekdate(); - test_by_week(); - test_format_weeks(); - test_month_title(); - test_format_month(); - test_paste_blocks(); - test_chunks(); - test_format_year(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/example-st.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/example-st.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/example-st.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/example-st.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct State; -type Error = (); - -trait Bind { - type Output; - fn bind(self, f: F) -> Self::Output; -} - -fn bind(mut a: A, mut f: F) - -> impl FnMut(&mut State) -> Result -where F: FnMut(T) -> B, - A: FnMut(&mut State) -> Result, - B: FnMut(&mut State) -> Result -{ - move |state | { - let r = a(state)?; - f(r)(state) - } -} - -fn atom(x: T) -> impl FnMut(&mut State) -> Result { - let mut x = Some(x); - move |_| x.take().map_or(Err(()), Ok) -} - -fn main() { - assert_eq!(bind(atom(5), |x| atom(x > 4))(&mut State), Ok(true)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/existential-minimal.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/existential-minimal.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/existential-minimal.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/existential-minimal.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn main() {} - -fn foo() -> impl std::fmt::Debug { "cake" } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/issue-42479.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/issue-42479.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/issue-42479.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/issue-42479.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::iter::once; - -struct Foo { - x: i32, -} - -impl Foo { - fn inside(&self) -> impl Iterator { - once(&self.x) - } -} - -fn main() { - println!("hi"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/issue-49376.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/issue-49376.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/issue-49376.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/issue-49376.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Tests for nested self-reference which caused a stack overflow. - -use std::fmt::Debug; -use std::ops::*; - -fn gen() -> impl PartialOrd + PartialEq + Debug { } - -struct Bar {} -trait Foo {} -impl Foo for Bar {} - -fn foo() -> impl Foo { - Bar {} -} - -fn test_impl_ops() -> impl Add + Sub + Mul + Div { 1 } -fn test_impl_assign_ops() -> impl AddAssign + SubAssign + MulAssign + DivAssign { 1 } - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/lifetimes.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/lifetimes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/lifetimes.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/lifetimes.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,128 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![allow(warnings)] - -use std::fmt::Debug; - -fn any_lifetime<'a>() -> &'a u32 { &5 } - -fn static_lifetime() -> &'static u32 { &5 } - -fn any_lifetime_as_static_impl_trait() -> impl Debug { - any_lifetime() -} - -fn lifetimes_as_static_impl_trait() -> impl Debug { - static_lifetime() -} - -fn no_params_or_lifetimes_is_static() -> impl Debug + 'static { - lifetimes_as_static_impl_trait() -} - -fn static_input_type_is_static(x: T) -> impl Debug + 'static { x } - -fn type_outlives_reference_lifetime<'a, T: Debug>(x: &'a T) -> impl Debug + 'a { x } -fn type_outlives_reference_lifetime_elided(x: &T) -> impl Debug + '_ { x } - -trait SingleRegionTrait<'a> {} -impl<'a> SingleRegionTrait<'a> for u32 {} -impl<'a> SingleRegionTrait<'a> for &'a u32 {} -struct SingleRegionStruct<'a>(&'a u32); - -fn simple_type_hrtb<'b>() -> impl for<'a> SingleRegionTrait<'a> { 5 } -// FIXME(cramertj) add test after #45992 lands to ensure lint is triggered -fn elision_single_region_trait(x: &u32) -> impl SingleRegionTrait { x } -fn elision_single_region_struct(x: SingleRegionStruct) -> impl Into { x } - -fn closure_hrtb() -> impl for<'a> Fn(&'a u32) { |_| () } -fn closure_hr_elided() -> impl Fn(&u32) { |_| () } -fn closure_hr_elided_return() -> impl Fn(&u32) -> &u32 { |x| x } -fn closure_pass_through_elided_return(x: impl Fn(&u32) -> &u32) -> impl Fn(&u32) -> &u32 { x } -fn closure_pass_through_reference_elided(x: &impl Fn(&u32) -> &u32) -> &impl Fn(&u32) -> &u32 { x } - -fn nested_lifetime<'a>(input: &'a str) - -> impl Iterator + 'a> + 'a -{ - input.lines().map(|line| { - line.split_whitespace().map(|cell| cell.parse().unwrap()) - }) -} - -fn pass_through_elision(x: &u32) -> impl Into<&u32> { x } -fn pass_through_elision_with_fn_ptr(x: &fn(&u32) -> &u32) -> impl Into<&fn(&u32) -> &u32> { x } - -fn pass_through_elision_with_fn_path &u32>( - x: &T -) -> &impl Fn(&u32) -> &u32 { x } - -fn foo(x: &impl Debug) -> &impl Debug { x } -fn foo_explicit_lifetime<'a>(x: &'a impl Debug) -> &'a impl Debug { x } -fn foo_explicit_arg(x: &T) -> &impl Debug { x } - -fn mixed_lifetimes<'a>() -> impl for<'b> Fn(&'b &'a u32) { |_| () } -fn mixed_as_static() -> impl Fn(&'static &'static u32) { mixed_lifetimes() } - -trait MultiRegionTrait<'a, 'b>: Debug {} - -#[derive(Debug)] -struct MultiRegionStruct<'a, 'b>(&'a u32, &'b u32); -impl<'a, 'b> MultiRegionTrait<'a, 'b> for MultiRegionStruct<'a, 'b> {} - -#[derive(Debug)] -struct NoRegionStruct; -impl<'a, 'b> MultiRegionTrait<'a, 'b> for NoRegionStruct {} - -fn finds_least_region<'a: 'b, 'b>(x: &'a u32, y: &'b u32) -> impl MultiRegionTrait<'a, 'b> { - MultiRegionStruct(x, y) -} - -fn finds_explicit_bound<'a: 'b, 'b> - (x: &'a u32, y: &'b u32) -> impl MultiRegionTrait<'a, 'b> + 'b -{ - MultiRegionStruct(x, y) -} - -fn finds_explicit_bound_even_without_least_region<'a, 'b> - (x: &'a u32, y: &'b u32) -> impl MultiRegionTrait<'a, 'b> + 'b -{ - NoRegionStruct -} - -/* FIXME: `impl Trait<'a> + 'b` should live as long as 'b, even if 'b outlives 'a -fn outlives_bounds_even_with_contained_regions<'a, 'b> - (x: &'a u32, y: &'b u32) -> impl Debug + 'b -{ - finds_explicit_bound_even_without_least_region(x, y) -} -*/ - -fn unnamed_lifetimes_arent_contained_in_impl_trait_and_will_unify<'a, 'b> - (x: &'a u32, y: &'b u32) -> impl Debug -{ - fn deref<'lt>(x: &'lt u32) -> impl Debug { *x } - - if true { deref(x) } else { deref(y) } -} - -fn can_add_region_bound_to_static_type<'a, 'b>(_: &'a u32) -> impl Debug + 'a { 5 } - -struct MyVec(Vec>); - -impl<'unnecessary_lifetime> MyVec { - fn iter_doesnt_capture_unnecessary_lifetime<'s>(&'s self) -> impl Iterator { - self.0.iter().flat_map(|inner_vec| inner_vec.iter()) - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/nesting.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/nesting.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/nesting.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/nesting.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn foo(t: T) -> impl Into<[T; { const FOO: usize = 1; FOO }]> { - [t] -} - -fn bar() -> impl Into<[u8; { const FOO: usize = 1; FOO }]> { - [99] -} - -fn main() { - println!("{:?}", foo(42).into()); - println!("{:?}", bar().into()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_hrtb_anon.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_hrtb_anon.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_hrtb_anon.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_hrtb_anon.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn hrtb(f: impl Fn(&u32) -> u32) -> u32 { - f(&22) + f(&44) -} - -fn main() { - let sum = hrtb(|x| x * 2); - assert_eq!(sum, 22*2 + 44*2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_hrtb_named.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_hrtb_named.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_hrtb_named.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_hrtb_named.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn hrtb(f: impl for<'a> Fn(&'a u32) -> &'a u32) -> u32 { - f(&22) + f(&44) -} - -fn main() { - let sum = hrtb(|x| x); - assert_eq!(sum, 22 + 44); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_in_adt_in_parameters.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_in_adt_in_parameters.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_in_adt_in_parameters.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_in_adt_in_parameters.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::fmt::Display; - -fn check_display_eq(iter: &Vec) { - let mut collected = String::new(); - for it in iter { - let disp = format!("{} ", it); - collected.push_str(&disp); - } - assert_eq!("0 3 27 823 4891 1 0", collected.trim()); -} - -fn main() { - let i32_list_vec = vec![0i32, 3, 27, 823, 4891, 1, 0]; - let u32_list_vec = vec![0u32, 3, 27, 823, 4891, 1, 0]; - let str_list_vec = vec!["0", "3", "27", "823", "4891", "1", "0"]; - - check_display_eq(&i32_list_vec); - check_display_eq(&u32_list_vec); - check_display_eq(&str_list_vec); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_in_impl_trait_in_parameters.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_in_impl_trait_in_parameters.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_in_impl_trait_in_parameters.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_in_impl_trait_in_parameters.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::fmt::Display; - -fn check_display_eq(iter: impl IntoIterator) { - let mut collected = String::new(); - for it in iter { - let disp = format!("{} ", it); - collected.push_str(&disp); - } - assert_eq!("0 3 27 823 4891 1 0", collected.trim()); -} - -fn main() { - let i32_list = [0i32, 3, 27, 823, 4891, 1, 0]; - let i32_list_vec = vec![0i32, 3, 27, 823, 4891, 1, 0]; - let u32_list = [0u32, 3, 27, 823, 4891, 1, 0]; - let u32_list_vec = vec![0u32, 3, 27, 823, 4891, 1, 0]; - let u16_list = [0u16, 3, 27, 823, 4891, 1, 0]; - let str_list = ["0", "3", "27", "823", "4891", "1", "0"]; - let str_list_vec = vec!["0", "3", "27", "823", "4891", "1", "0"]; - - check_display_eq(&i32_list); - check_display_eq(i32_list_vec); - check_display_eq(&u32_list); - check_display_eq(u32_list_vec); - check_display_eq(&u16_list); - check_display_eq(&str_list); - check_display_eq(str_list_vec); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_in_trait_defn_parameters.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_in_trait_defn_parameters.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_in_trait_defn_parameters.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_in_trait_defn_parameters.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::fmt::Debug; - -trait InTraitDefnParameters { - fn in_parameters(_: impl Debug) -> String; -} - -impl InTraitDefnParameters for () { - fn in_parameters(v: impl Debug) -> String { - format!("() + {:?}", v) - } -} - -fn main() { - let s = <() as InTraitDefnParameters>::in_parameters(22); - assert_eq!(s, "() + 22"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_multiple_bounds.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_multiple_bounds.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_multiple_bounds.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/universal_multiple_bounds.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::fmt::Display; - -fn foo(f: impl Display + Clone) -> String { - let g = f.clone(); - format!("{} + {}", f, g) -} - -fn main() { - let sum = foo(format!("22")); - assert_eq!(sum, r"22 + 22"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/xcrate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/xcrate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// aux-build:xcrate.rs - -extern crate xcrate; - -fn main() { -// NOTE line below commeted out due to issue #45994 -// assert_eq!(xcrate::fourway_add(1)(2)(3)(4), 10); - xcrate::return_closure_accessing_internal_fn()(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/xcrate_simple.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/xcrate_simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/xcrate_simple.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/impl-trait/xcrate_simple.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// aux-build:xcrate.rs - -extern crate xcrate; - -fn main() { - xcrate::return_internal_fn()(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use zed::bar; - -mod zed { - pub fn bar() { println!("bar"); } -} - -pub fn main() { bar(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(unused_imports)] - -use baz::zed; -use baz::zed::bar; - -mod baz { - pub mod zed { - pub fn bar() { println!("bar2"); } - } -} - -pub fn main() { bar(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import4.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import4.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import4.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use zed::bar; - -mod zed { - pub fn bar() { println!("bar"); } -} - -pub fn main() { let _zed = 42; bar(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import5.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import5.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import5.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import5.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use foo::bar; -mod foo { - pub use foo::zed::bar; - pub mod zed { - pub fn bar() { println!("foo"); } - } -} - -pub fn main() { bar(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import6.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import6.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import6.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import6.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(unused_imports)] - -use foo::zed; -use bar::baz; - -mod foo { - pub mod zed { - pub fn baz() { println!("baz"); } - } -} -mod bar { - pub use foo::zed::baz; -} -pub fn main() { baz(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import7.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import7.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import7.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import7.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(unused_imports)] - -use foo::zed; -use bar::baz; - -mod foo { - pub mod zed { - pub fn baz() { println!("baz"); } - } -} -mod bar { - pub use foo::zed::baz; - pub mod foo { - pub mod zed {} - } -} -pub fn main() { baz(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import8.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import8.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import8.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import8.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use foo::x; -use foo::x as z; - -mod foo { - pub fn x(y: isize) { println!("{}", y); } -} - -pub fn main() { x(10); z(10); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans_macros.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans_macros.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans_macros.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans_macros.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! add1 { - ($e:expr) => ({ - let a = 1 + $e; - let b = $e + 1; - a + b - 1 - }) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -// no-prefer-dynamic - -// compile-flags: -g - -#[macro_use] -mod crate_with_invalid_spans_macros; - -pub fn exported_generic(x: T, y: u32) -> (T, u32) { - // Using the add1 macro will produce an invalid span, because the `y` passed - // to the macro will have a span from this file, but the rest of the code - // generated from the macro will have spans from the macro-defining file. - // The AST node for the (1 + y) expression generated by the macro will then - // take it's `lo` span bound from the `1` literal in the macro-defining file - // and it's `hi` bound from `y` in this file, which should be lower than the - // `lo` and even lower than the lower bound of the FileMap it is supposedly - // contained in because the FileMap for this file was allocated earlier than - // the FileMap of the macro-defining file. - return (x, add1!(y)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-crate-with-invalid-spans/main.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-crate-with-invalid-spans/main.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-crate-with-invalid-spans/main.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-crate-with-invalid-spans/main.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:crate_with_invalid_spans.rs - -// pretty-expanded FIXME #23616 - -extern crate crate_with_invalid_spans; - -fn main() { - // The AST of `exported_generic` stored in crate_with_invalid_spans's - // metadata should contain an invalid span where span.lo() > span.hi(). - // Let's make sure the compiler doesn't crash when encountering this. - let _ = crate_with_invalid_spans::exported_generic(32u32, 7u32); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-from.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-from.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-from.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-from.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -use spam::{ham, eggs}; - -mod spam { - pub fn ham() { } - pub fn eggs() { } -} - -pub fn main() { ham(); eggs(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-glob-0.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-glob-0.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-glob-0.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-glob-0.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use module_of_many_things::*; -use dug::too::greedily::and::too::deep::*; - -mod module_of_many_things { - pub fn f1() { println!("f1"); } - pub fn f2() { println!("f2"); } - fn f3() { println!("f3"); } - pub fn f4() { println!("f4"); } -} - -mod dug { - pub mod too { - pub mod greedily { - pub mod and { - pub mod too { - pub mod deep { - pub fn nameless_fear() { println!("Boo!"); } - pub fn also_redstone() { println!("Whatever."); } - } - } - } - } - } -} - - -pub fn main() { f1(); f2(); f4(); nameless_fear(); also_redstone(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-glob-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-glob-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-glob-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-glob-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This should resolve fine. Prior to fix, the last import -// was being tried too early, and marked as unrsolved before -// the glob import had a chance to be resolved. - -mod bar { - pub use self::middle::*; - - mod middle { - pub use self::baz::Baz; - - mod baz { - pub enum Baz { - Baz1, - Baz2 - } - } - } -} - -mod foo { - use bar::Baz::{Baz1, Baz2}; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-glob-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-glob-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-glob-crate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-glob-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::mem::*; - -pub fn main() { - assert_eq!(size_of::(), 1); - let (mut x, mut y) = (1, 2); - swap(&mut x, &mut y); - assert_eq!(x, 2); - assert_eq!(y, 1); -} - -#[allow(unused)] -fn f() { - mod foo { pub use *; } - mod bar { pub use ::*; } - - foo::main(); - bar::main(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-in-block.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-in-block.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-in-block.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-in-block.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub fn main() { - use std::mem::replace; - let mut x = 5; - replace(&mut x, 6); - { - use std::mem::*; - let mut y = 6; - swap(&mut x, &mut y); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-prefix-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-prefix-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-prefix-macro.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-prefix-macro.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -mod a { - pub mod b { - pub mod c { - pub struct S; - pub struct Z; - } - pub struct W; - } -} - -macro_rules! import { - (1 $p: path) => (use $p;); - (2 $p: path) => (use $p::{Z};); - (3 $p: path) => (use $p::*;); -} - -import! { 1 a::b::c::S } -import! { 2 a::b::c } -import! { 3 a::b } - -fn main() { - let s = S; - let z = Z; - let w = W; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-rename.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-rename.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-rename.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-rename.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use foo::{x, y as fooy}; -use Maybe::{Yes as MaybeYes}; - -pub enum Maybe { Yes, No } -mod foo { - use super::Maybe::{self as MaybeFoo}; - pub fn x(a: MaybeFoo) {} - pub fn y(a: i32) { println!("{}", a); } -} - -pub fn main() { x(MaybeYes); fooy(10); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -mod foo { - pub fn x(y: isize) { println!("{}", y); } -} - -mod bar { - use foo::x; - use foo::x as z; - pub fn thing() { x(10); z(10); } -} - -pub fn main() { bar::thing(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/imports.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/imports.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/imports.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/imports.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(unused)] - -// Like other items, private imports can be imported and used non-lexically in paths. -mod a { - use a as foo; - use self::foo::foo as bar; - - mod b { - use super::bar; - } -} - -mod foo { pub fn f() {} } -mod bar { pub fn f() {} } - -pub fn f() -> bool { true } - -// Items and explicit imports shadow globs. -fn g() { - use foo::*; - use bar::*; - fn f() -> bool { true } - let _: bool = f(); -} - -fn h() { - use foo::*; - use bar::*; - use f; - let _: bool = f(); -} - -// Here, there appears to be shadowing but isn't because of namespaces. -mod b { - use foo::*; // This imports `f` in the value namespace. - use super::b as f; // This imports `f` only in the type namespace, - fn test() { self::f(); } // so the glob isn't shadowed. -} - -// Here, there is shadowing in one namespace, but not the other. -mod c { - mod test { - pub fn f() {} - pub mod f {} - } - use self::test::*; // This glob-imports `f` in both namespaces. - mod f { pub fn f() {} } // This shadows the glob only in the value namespace. - - fn test() { - self::f(); // Check that the glob-imported value isn't shadowed. - self::f::f(); // Check that the glob-imported module is shadowed. - } -} - -// Unused names can be ambiguous. -mod d { - pub use foo::*; // This imports `f` in the value namespace. - pub use bar::*; // This also imports `f` in the value namespace. -} - -mod e { - pub use d::*; // n.b. Since `e::f` is not used, this is not considered to be a use of `d::f`. -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-trailing-comma.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-trailing-comma.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-trailing-comma.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/imports/import-trailing-comma.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -use foo::bar::{baz, quux,}; - -mod foo { - pub mod bar { - pub fn baz() { } - pub fn quux() { } - } -} - -pub fn main() { baz(); quux(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/auxiliary/cci_intrinsic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/auxiliary/cci_intrinsic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/auxiliary/cci_intrinsic.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/auxiliary/cci_intrinsic.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(intrinsics)] - -pub mod rusti { - extern "rust-intrinsic" { - pub fn atomic_xchg(dst: *mut T, src: T) -> T; - } -} - -#[inline(always)] -pub fn atomic_xchg(dst: *mut isize, src: isize) -> isize { - unsafe { - rusti::atomic_xchg(dst, src) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-alignment.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-alignment.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-alignment.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-alignment.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -// Copyright 2012-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare seems not important to test here - -#![feature(intrinsics, main)] - -mod rusti { - extern "rust-intrinsic" { - pub fn pref_align_of() -> usize; - pub fn min_align_of() -> usize; - } -} - -#[cfg(any(target_os = "android", - target_os = "cloudabi", - target_os = "dragonfly", - target_os = "emscripten", - target_os = "freebsd", - target_os = "linux", - target_os = "macos", - target_os = "netbsd", - target_os = "openbsd", - target_os = "solaris"))] -mod m { - #[main] - #[cfg(target_arch = "x86")] - pub fn main() { - unsafe { - assert_eq!(::rusti::pref_align_of::(), 8); - assert_eq!(::rusti::min_align_of::(), 4); - } - } - - #[main] - #[cfg(not(target_arch = "x86"))] - pub fn main() { - unsafe { - assert_eq!(::rusti::pref_align_of::(), 8); - assert_eq!(::rusti::min_align_of::(), 8); - } - } -} - -#[cfg(target_os = "bitrig")] -mod m { - #[main] - #[cfg(target_arch = "x86_64")] - pub fn main() { - unsafe { - assert_eq!(::rusti::pref_align_of::(), 8); - assert_eq!(::rusti::min_align_of::(), 8); - } - } -} - -#[cfg(target_os = "windows")] -mod m { - #[main] - #[cfg(target_arch = "x86")] - pub fn main() { - unsafe { - assert_eq!(::rusti::pref_align_of::(), 8); - assert_eq!(::rusti::min_align_of::(), 8); - } - } - - #[main] - #[cfg(target_arch = "x86_64")] - pub fn main() { - unsafe { - assert_eq!(::rusti::pref_align_of::(), 8); - assert_eq!(::rusti::min_align_of::(), 8); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-assume.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-assume.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-assume.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-assume.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(core_intrinsics)] - -use std::intrinsics::assume; - -unsafe fn f(x: i32) -> i32 { - assume(x == 34); - match x { - 34 => 42, - _ => 30 - } -} - -fn main() { - let x = unsafe { f(34) }; - assert_eq!(x, 42); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-atomics-cc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-atomics-cc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-atomics-cc.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-atomics-cc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:cci_intrinsic.rs - - -extern crate cci_intrinsic; -use cci_intrinsic::atomic_xchg; - -pub fn main() { - let mut x = 1; - atomic_xchg(&mut x, 5); - assert_eq!(x, 5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-atomics.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-atomics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-atomics.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-atomics.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] -#![feature(intrinsics)] - -mod rusti { - extern "rust-intrinsic" { - pub fn atomic_cxchg(dst: *mut T, old: T, src: T) -> (T, bool); - pub fn atomic_cxchg_acq(dst: *mut T, old: T, src: T) -> (T, bool); - pub fn atomic_cxchg_rel(dst: *mut T, old: T, src: T) -> (T, bool); - - pub fn atomic_cxchgweak(dst: *mut T, old: T, src: T) -> (T, bool); - pub fn atomic_cxchgweak_acq(dst: *mut T, old: T, src: T) -> (T, bool); - pub fn atomic_cxchgweak_rel(dst: *mut T, old: T, src: T) -> (T, bool); - - pub fn atomic_load(src: *const T) -> T; - pub fn atomic_load_acq(src: *const T) -> T; - - pub fn atomic_store(dst: *mut T, val: T); - pub fn atomic_store_rel(dst: *mut T, val: T); - - pub fn atomic_xchg(dst: *mut T, src: T) -> T; - pub fn atomic_xchg_acq(dst: *mut T, src: T) -> T; - pub fn atomic_xchg_rel(dst: *mut T, src: T) -> T; - - pub fn atomic_xadd(dst: *mut T, src: T) -> T; - pub fn atomic_xadd_acq(dst: *mut T, src: T) -> T; - pub fn atomic_xadd_rel(dst: *mut T, src: T) -> T; - - pub fn atomic_xsub(dst: *mut T, src: T) -> T; - pub fn atomic_xsub_acq(dst: *mut T, src: T) -> T; - pub fn atomic_xsub_rel(dst: *mut T, src: T) -> T; - } -} - -pub fn main() { - unsafe { - let mut x: Box<_> = box 1; - - assert_eq!(rusti::atomic_load(&*x), 1); - *x = 5; - assert_eq!(rusti::atomic_load_acq(&*x), 5); - - rusti::atomic_store(&mut *x,3); - assert_eq!(*x, 3); - rusti::atomic_store_rel(&mut *x,1); - assert_eq!(*x, 1); - - assert_eq!(rusti::atomic_cxchg(&mut *x, 1, 2), (1, true)); - assert_eq!(*x, 2); - - assert_eq!(rusti::atomic_cxchg_acq(&mut *x, 1, 3), (2, false)); - assert_eq!(*x, 2); - - assert_eq!(rusti::atomic_cxchg_rel(&mut *x, 2, 1), (2, true)); - assert_eq!(*x, 1); - - assert_eq!(rusti::atomic_xchg(&mut *x, 0), 1); - assert_eq!(*x, 0); - - assert_eq!(rusti::atomic_xchg_acq(&mut *x, 1), 0); - assert_eq!(*x, 1); - - assert_eq!(rusti::atomic_xchg_rel(&mut *x, 0), 1); - assert_eq!(*x, 0); - - assert_eq!(rusti::atomic_xadd(&mut *x, 1), 0); - assert_eq!(rusti::atomic_xadd_acq(&mut *x, 1), 1); - assert_eq!(rusti::atomic_xadd_rel(&mut *x, 1), 2); - assert_eq!(*x, 3); - - assert_eq!(rusti::atomic_xsub(&mut *x, 1), 3); - assert_eq!(rusti::atomic_xsub_acq(&mut *x, 1), 2); - assert_eq!(rusti::atomic_xsub_rel(&mut *x, 1), 1); - assert_eq!(*x, 0); - - loop { - let res = rusti::atomic_cxchgweak(&mut *x, 0, 1); - assert_eq!(res.0, 0); - if res.1 { - break; - } - } - assert_eq!(*x, 1); - - loop { - let res = rusti::atomic_cxchgweak_acq(&mut *x, 1, 2); - assert_eq!(res.0, 1); - if res.1 { - break; - } - } - assert_eq!(*x, 2); - - loop { - let res = rusti::atomic_cxchgweak_rel(&mut *x, 2, 3); - assert_eq!(res.0, 2); - if res.1 { - break; - } - } - assert_eq!(*x, 3); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-move-val-cleanups.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-move-val-cleanups.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-move-val-cleanups.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-move-val-cleanups.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,198 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support -#![allow(stable_features)] - -// This test is checking that the move_val_init intrinsic is -// respecting cleanups for both of its argument expressions. -// -// In other words, if either DEST or SOURCE in -// -// `intrinsics::move_val_init(DEST, SOURCE) -// -// introduce temporaries that require cleanup, and SOURCE panics, then -// make sure the cleanups still occur. - -#![feature(core_intrinsics, sync_poison)] - -use std::cell::RefCell; -use std::intrinsics; -use std::sync::{Arc, LockResult, Mutex, MutexGuard}; -use std::thread; - -type LogEntry = (&'static str, i32); -type Guarded = RefCell>; -#[derive(Clone)] -struct Log(Arc>); -struct Acquired<'a>(MutexGuard<'a, Guarded>); -type LogState = (MutexWas, &'static [LogEntry]); - -#[derive(Copy, Clone, PartialEq, Eq, Debug)] -enum MutexWas { Poisoned, NotPoisoned } - -impl Log { - fn lock(&self) -> LockResult>>> { self.0.lock() } - fn acquire(&self) -> Acquired { Acquired(self.0.lock().unwrap()) } -} - -impl<'a> Acquired<'a> { - fn log(&self, s: &'static str, i: i32) { self.0.borrow_mut().push((s, i)); } -} - -const TEST1_EXPECT: LogState = (MutexWas::NotPoisoned, - &[("double-check non-poisoning path", 1) - ]); - -fn test1(log: Log) { - { - let acq = log.acquire(); - acq.log("double-check non-poisoning path", 1); - } - panic!("every test ends in a panic"); -} - -const TEST2_EXPECT: LogState = (MutexWas::Poisoned, - &[("double-check poisoning path", 1), - ("and multiple log entries", 2), - ]); -fn test2(log: Log) { - let acq = log.acquire(); - acq.log("double-check poisoning path", 1); - acq.log("and multiple log entries", 2); - panic!("every test ends in a panic"); -} - -struct LogOnDrop<'a>(&'a Acquired<'a>, &'static str, i32); -impl<'a> Drop for LogOnDrop<'a> { - fn drop(&mut self) { - self.0.log(self.1, self.2); - } -} - -const TEST3_EXPECT: LogState = (MutexWas::Poisoned, - &[("double-check destructors can log", 1), - ("drop d2", 2), - ("drop d1", 3), - ]); -fn test3(log: Log) { - let acq = log.acquire(); - acq.log("double-check destructors can log", 1); - let _d1 = LogOnDrop(&acq, "drop d1", 3); - let _d2 = LogOnDrop(&acq, "drop d2", 2); - panic!("every test ends in a panic"); -} - -// The *real* tests of panic-handling for move_val_init intrinsic -// start here. - -const TEST4_EXPECT: LogState = (MutexWas::Poisoned, - &[("neither arg panics", 1), - ("drop temp LOD", 2), - ("drop temp LOD", 3), - ("drop dest_b", 4), - ("drop dest_a", 5), - ]); -fn test4(log: Log) { - let acq = log.acquire(); - acq.log("neither arg panics", 1); - let mut dest_a = LogOnDrop(&acq, "a will be overwritten, not dropped", 0); - let mut dest_b = LogOnDrop(&acq, "b will be overwritten, not dropped", 0); - unsafe { - intrinsics::move_val_init({ LogOnDrop(&acq, "drop temp LOD", 2); &mut dest_a }, - LogOnDrop(&acq, "drop dest_a", 5)); - intrinsics::move_val_init(&mut dest_b, { LogOnDrop(&acq, "drop temp LOD", 3); - LogOnDrop(&acq, "drop dest_b", 4) }); - } - panic!("every test ends in a panic"); -} - - -// Check that move_val_init(PANIC, SOURCE_EXPR) never evaluates SOURCE_EXPR -const TEST5_EXPECT: LogState = (MutexWas::Poisoned, - &[("first arg panics", 1), - ("drop orig dest_a", 2), - ]); -fn test5(log: Log) { - let acq = log.acquire(); - acq.log("first arg panics", 1); - let mut _dest_a = LogOnDrop(&acq, "drop orig dest_a", 2); - unsafe { - intrinsics::move_val_init({ panic!("every test ends in a panic") }, - LogOnDrop(&acq, "we never get here", 0)); - } -} - -// Check that move_val_init(DEST_EXPR, PANIC) cleans up temps from DEST_EXPR. -const TEST6_EXPECT: LogState = (MutexWas::Poisoned, - &[("second arg panics", 1), - ("drop temp LOD", 2), - ("drop orig dest_a", 3), - ]); -fn test6(log: Log) { - let acq = log.acquire(); - acq.log("second arg panics", 1); - let mut dest_a = LogOnDrop(&acq, "drop orig dest_a", 3); - unsafe { - intrinsics::move_val_init({ LogOnDrop(&acq, "drop temp LOD", 2); &mut dest_a }, - { panic!("every test ends in a panic"); }); - } -} - -// Check that move_val_init(DEST_EXPR, COMPLEX_PANIC) cleans up temps from COMPLEX_PANIC. -const TEST7_EXPECT: LogState = (MutexWas::Poisoned, - &[("second arg panics", 1), - ("drop temp LOD", 2), - ("drop temp LOD", 3), - ("drop orig dest_a", 4), - ]); -fn test7(log: Log) { - let acq = log.acquire(); - acq.log("second arg panics", 1); - let mut dest_a = LogOnDrop(&acq, "drop orig dest_a", 4); - unsafe { - intrinsics::move_val_init({ LogOnDrop(&acq, "drop temp LOD", 2); &mut dest_a }, - { LogOnDrop(&acq, "drop temp LOD", 3); - panic!("every test ends in a panic"); }); - } -} - -const TEST_SUITE: &'static [(&'static str, fn (Log), LogState)] = - &[("test1", test1, TEST1_EXPECT), - ("test2", test2, TEST2_EXPECT), - ("test3", test3, TEST3_EXPECT), - ("test4", test4, TEST4_EXPECT), - ("test5", test5, TEST5_EXPECT), - ("test6", test6, TEST6_EXPECT), - ("test7", test7, TEST7_EXPECT), - ]; - -fn main() { - for &(name, test, expect) in TEST_SUITE { - let log = Log(Arc::new(Mutex::new(RefCell::new(Vec::new())))); - let ret = { let log = log.clone(); thread::spawn(move || test(log)).join() }; - assert!(ret.is_err(), "{} must end with panic", name); - { - let l = log.lock(); - match l { - Ok(acq) => { - assert_eq!((MutexWas::NotPoisoned, &acq.borrow()[..]), expect); - println!("{} (unpoisoned) log: {:?}", name, *acq); - } - Err(e) => { - let acq = e.into_inner(); - assert_eq!((MutexWas::Poisoned, &acq.borrow()[..]), expect); - println!("{} (poisoned) log: {:?}", name, *acq); - } - } - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-move-val.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-move-val.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-move-val.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-move-val.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(box_syntax)] -#![feature(intrinsics)] - -mod rusti { - extern "rust-intrinsic" { - pub fn init() -> T; - pub fn move_val_init(dst: *mut T, src: T); - } -} - -pub fn main() { - unsafe { - // sanity check - check_drops_state(0, None); - - let mut x: Box = box D(1); - assert_eq!(x.0, 1); - - // A normal overwrite, to demonstrate `check_drops_state`. - x = box D(2); - - // At this point, one destructor has run, because the - // overwrite of `x` drops its initial value. - check_drops_state(1, Some(1)); - - let mut y: Box = rusti::init(); - - // An initial binding does not overwrite anything. - check_drops_state(1, Some(1)); - - // Since `y` has been initialized via the `init` intrinsic, it - // would be unsound to directly overwrite its value via normal - // assignment. - // - // The code currently generated by the compiler is overly - // accepting, however, in that it will check if `y` is itself - // null and thus avoid the unsound action of attempting to - // free null. In other words, if we were to do a normal - // assignment like `y = box D(4);` here, it probably would not - // crash today. But the plan is that it may well crash in the - // future, (I believe). - - // `x` is moved here; the manner in which this is tracked by the - // compiler is hidden. - rusti::move_val_init(&mut y, x); - - // But what we *can* observe is how many times the destructor - // for `D` is invoked, and what the last value we saw was - // during such a destructor call. We do so after the end of - // this scope. - - assert_eq!(y.0, 2); - y.0 = 3; - assert_eq!(y.0, 3); - - check_drops_state(1, Some(1)); - } - - check_drops_state(2, Some(3)); -} - -static mut NUM_DROPS: i32 = 0; -static mut LAST_DROPPED: Option = None; - -fn check_drops_state(num_drops: i32, last_dropped: Option) { - unsafe { - assert_eq!(NUM_DROPS, num_drops); - assert_eq!(LAST_DROPPED, last_dropped); - } -} - -struct D(i32); -impl Drop for D { - fn drop(&mut self) { - unsafe { - NUM_DROPS += 1; - LAST_DROPPED = Some(self.0); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsics-integer.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsics-integer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsics-integer.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsics-integer.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,180 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no i128 support - -#![feature(intrinsics)] - -mod rusti { - extern "rust-intrinsic" { - pub fn ctpop(x: T) -> T; - pub fn ctlz(x: T) -> T; - pub fn ctlz_nonzero(x: T) -> T; - pub fn cttz(x: T) -> T; - pub fn cttz_nonzero(x: T) -> T; - pub fn bswap(x: T) -> T; - pub fn bitreverse(x: T) -> T; - } -} - -pub fn main() { - unsafe { - use rusti::*; - - assert_eq!(ctpop(0u8), 0); assert_eq!(ctpop(0i8), 0); - assert_eq!(ctpop(0u16), 0); assert_eq!(ctpop(0i16), 0); - assert_eq!(ctpop(0u32), 0); assert_eq!(ctpop(0i32), 0); - assert_eq!(ctpop(0u64), 0); assert_eq!(ctpop(0i64), 0); - assert_eq!(ctpop(0u128), 0); assert_eq!(ctpop(0i128), 0); - - assert_eq!(ctpop(1u8), 1); assert_eq!(ctpop(1i8), 1); - assert_eq!(ctpop(1u16), 1); assert_eq!(ctpop(1i16), 1); - assert_eq!(ctpop(1u32), 1); assert_eq!(ctpop(1i32), 1); - assert_eq!(ctpop(1u64), 1); assert_eq!(ctpop(1i64), 1); - assert_eq!(ctpop(1u128), 1); assert_eq!(ctpop(1i128), 1); - - assert_eq!(ctpop(10u8), 2); assert_eq!(ctpop(10i8), 2); - assert_eq!(ctpop(10u16), 2); assert_eq!(ctpop(10i16), 2); - assert_eq!(ctpop(10u32), 2); assert_eq!(ctpop(10i32), 2); - assert_eq!(ctpop(10u64), 2); assert_eq!(ctpop(10i64), 2); - assert_eq!(ctpop(10u128), 2); assert_eq!(ctpop(10i128), 2); - - assert_eq!(ctpop(100u8), 3); assert_eq!(ctpop(100i8), 3); - assert_eq!(ctpop(100u16), 3); assert_eq!(ctpop(100i16), 3); - assert_eq!(ctpop(100u32), 3); assert_eq!(ctpop(100i32), 3); - assert_eq!(ctpop(100u64), 3); assert_eq!(ctpop(100i64), 3); - assert_eq!(ctpop(100u128), 3); assert_eq!(ctpop(100i128), 3); - - assert_eq!(ctpop(-1i8 as u8), 8); assert_eq!(ctpop(-1i8), 8); - assert_eq!(ctpop(-1i16 as u16), 16); assert_eq!(ctpop(-1i16), 16); - assert_eq!(ctpop(-1i32 as u32), 32); assert_eq!(ctpop(-1i32), 32); - assert_eq!(ctpop(-1i64 as u64), 64); assert_eq!(ctpop(-1i64), 64); - assert_eq!(ctpop(-1i128 as u128), 128); assert_eq!(ctpop(-1i128), 128); - - assert_eq!(ctlz(0u8), 8); assert_eq!(ctlz(0i8), 8); - assert_eq!(ctlz(0u16), 16); assert_eq!(ctlz(0i16), 16); - assert_eq!(ctlz(0u32), 32); assert_eq!(ctlz(0i32), 32); - assert_eq!(ctlz(0u64), 64); assert_eq!(ctlz(0i64), 64); - assert_eq!(ctlz(0u128), 128); assert_eq!(ctlz(0i128), 128); - - assert_eq!(ctlz(1u8), 7); assert_eq!(ctlz(1i8), 7); - assert_eq!(ctlz(1u16), 15); assert_eq!(ctlz(1i16), 15); - assert_eq!(ctlz(1u32), 31); assert_eq!(ctlz(1i32), 31); - assert_eq!(ctlz(1u64), 63); assert_eq!(ctlz(1i64), 63); - assert_eq!(ctlz(1u128), 127); assert_eq!(ctlz(1i128), 127); - - assert_eq!(ctlz(10u8), 4); assert_eq!(ctlz(10i8), 4); - assert_eq!(ctlz(10u16), 12); assert_eq!(ctlz(10i16), 12); - assert_eq!(ctlz(10u32), 28); assert_eq!(ctlz(10i32), 28); - assert_eq!(ctlz(10u64), 60); assert_eq!(ctlz(10i64), 60); - assert_eq!(ctlz(10u128), 124); assert_eq!(ctlz(10i128), 124); - - assert_eq!(ctlz(100u8), 1); assert_eq!(ctlz(100i8), 1); - assert_eq!(ctlz(100u16), 9); assert_eq!(ctlz(100i16), 9); - assert_eq!(ctlz(100u32), 25); assert_eq!(ctlz(100i32), 25); - assert_eq!(ctlz(100u64), 57); assert_eq!(ctlz(100i64), 57); - assert_eq!(ctlz(100u128), 121); assert_eq!(ctlz(100i128), 121); - - assert_eq!(ctlz_nonzero(1u8), 7); assert_eq!(ctlz_nonzero(1i8), 7); - assert_eq!(ctlz_nonzero(1u16), 15); assert_eq!(ctlz_nonzero(1i16), 15); - assert_eq!(ctlz_nonzero(1u32), 31); assert_eq!(ctlz_nonzero(1i32), 31); - assert_eq!(ctlz_nonzero(1u64), 63); assert_eq!(ctlz_nonzero(1i64), 63); - assert_eq!(ctlz_nonzero(1u128), 127); assert_eq!(ctlz_nonzero(1i128), 127); - - assert_eq!(ctlz_nonzero(10u8), 4); assert_eq!(ctlz_nonzero(10i8), 4); - assert_eq!(ctlz_nonzero(10u16), 12); assert_eq!(ctlz_nonzero(10i16), 12); - assert_eq!(ctlz_nonzero(10u32), 28); assert_eq!(ctlz_nonzero(10i32), 28); - assert_eq!(ctlz_nonzero(10u64), 60); assert_eq!(ctlz_nonzero(10i64), 60); - assert_eq!(ctlz_nonzero(10u128), 124); assert_eq!(ctlz_nonzero(10i128), 124); - - assert_eq!(ctlz_nonzero(100u8), 1); assert_eq!(ctlz_nonzero(100i8), 1); - assert_eq!(ctlz_nonzero(100u16), 9); assert_eq!(ctlz_nonzero(100i16), 9); - assert_eq!(ctlz_nonzero(100u32), 25); assert_eq!(ctlz_nonzero(100i32), 25); - assert_eq!(ctlz_nonzero(100u64), 57); assert_eq!(ctlz_nonzero(100i64), 57); - assert_eq!(ctlz_nonzero(100u128), 121); assert_eq!(ctlz_nonzero(100i128), 121); - - assert_eq!(cttz(-1i8 as u8), 0); assert_eq!(cttz(-1i8), 0); - assert_eq!(cttz(-1i16 as u16), 0); assert_eq!(cttz(-1i16), 0); - assert_eq!(cttz(-1i32 as u32), 0); assert_eq!(cttz(-1i32), 0); - assert_eq!(cttz(-1i64 as u64), 0); assert_eq!(cttz(-1i64), 0); - assert_eq!(cttz(-1i128 as u128), 0); assert_eq!(cttz(-1i128), 0); - - assert_eq!(cttz(0u8), 8); assert_eq!(cttz(0i8), 8); - assert_eq!(cttz(0u16), 16); assert_eq!(cttz(0i16), 16); - assert_eq!(cttz(0u32), 32); assert_eq!(cttz(0i32), 32); - assert_eq!(cttz(0u64), 64); assert_eq!(cttz(0i64), 64); - assert_eq!(cttz(0u128), 128); assert_eq!(cttz(0i128), 128); - - assert_eq!(cttz(1u8), 0); assert_eq!(cttz(1i8), 0); - assert_eq!(cttz(1u16), 0); assert_eq!(cttz(1i16), 0); - assert_eq!(cttz(1u32), 0); assert_eq!(cttz(1i32), 0); - assert_eq!(cttz(1u64), 0); assert_eq!(cttz(1i64), 0); - assert_eq!(cttz(1u128), 0); assert_eq!(cttz(1i128), 0); - - assert_eq!(cttz(10u8), 1); assert_eq!(cttz(10i8), 1); - assert_eq!(cttz(10u16), 1); assert_eq!(cttz(10i16), 1); - assert_eq!(cttz(10u32), 1); assert_eq!(cttz(10i32), 1); - assert_eq!(cttz(10u64), 1); assert_eq!(cttz(10i64), 1); - assert_eq!(cttz(10u128), 1); assert_eq!(cttz(10i128), 1); - - assert_eq!(cttz(100u8), 2); assert_eq!(cttz(100i8), 2); - assert_eq!(cttz(100u16), 2); assert_eq!(cttz(100i16), 2); - assert_eq!(cttz(100u32), 2); assert_eq!(cttz(100i32), 2); - assert_eq!(cttz(100u64), 2); assert_eq!(cttz(100i64), 2); - assert_eq!(cttz(100u128), 2); assert_eq!(cttz(100i128), 2); - - assert_eq!(cttz_nonzero(-1i8 as u8), 0); assert_eq!(cttz_nonzero(-1i8), 0); - assert_eq!(cttz_nonzero(-1i16 as u16), 0); assert_eq!(cttz_nonzero(-1i16), 0); - assert_eq!(cttz_nonzero(-1i32 as u32), 0); assert_eq!(cttz_nonzero(-1i32), 0); - assert_eq!(cttz_nonzero(-1i64 as u64), 0); assert_eq!(cttz_nonzero(-1i64), 0); - assert_eq!(cttz_nonzero(-1i128 as u128), 0); assert_eq!(cttz_nonzero(-1i128), 0); - - assert_eq!(cttz_nonzero(1u8), 0); assert_eq!(cttz_nonzero(1i8), 0); - assert_eq!(cttz_nonzero(1u16), 0); assert_eq!(cttz_nonzero(1i16), 0); - assert_eq!(cttz_nonzero(1u32), 0); assert_eq!(cttz_nonzero(1i32), 0); - assert_eq!(cttz_nonzero(1u64), 0); assert_eq!(cttz_nonzero(1i64), 0); - assert_eq!(cttz_nonzero(1u128), 0); assert_eq!(cttz_nonzero(1i128), 0); - - assert_eq!(cttz_nonzero(10u8), 1); assert_eq!(cttz_nonzero(10i8), 1); - assert_eq!(cttz_nonzero(10u16), 1); assert_eq!(cttz_nonzero(10i16), 1); - assert_eq!(cttz_nonzero(10u32), 1); assert_eq!(cttz_nonzero(10i32), 1); - assert_eq!(cttz_nonzero(10u64), 1); assert_eq!(cttz_nonzero(10i64), 1); - assert_eq!(cttz_nonzero(10u128), 1); assert_eq!(cttz_nonzero(10i128), 1); - - assert_eq!(cttz_nonzero(100u8), 2); assert_eq!(cttz_nonzero(100i8), 2); - assert_eq!(cttz_nonzero(100u16), 2); assert_eq!(cttz_nonzero(100i16), 2); - assert_eq!(cttz_nonzero(100u32), 2); assert_eq!(cttz_nonzero(100i32), 2); - assert_eq!(cttz_nonzero(100u64), 2); assert_eq!(cttz_nonzero(100i64), 2); - assert_eq!(cttz_nonzero(100u128), 2); assert_eq!(cttz_nonzero(100i128), 2); - - assert_eq!(bswap(0x0Au8), 0x0A); // no-op - assert_eq!(bswap(0x0Ai8), 0x0A); // no-op - assert_eq!(bswap(0x0A0Bu16), 0x0B0A); - assert_eq!(bswap(0x0A0Bi16), 0x0B0A); - assert_eq!(bswap(0x0ABBCC0Du32), 0x0DCCBB0A); - assert_eq!(bswap(0x0ABBCC0Di32), 0x0DCCBB0A); - assert_eq!(bswap(0x0122334455667708u64), 0x0877665544332201); - assert_eq!(bswap(0x0122334455667708i64), 0x0877665544332201); - assert_eq!(bswap(0x0122334455667708u128), 0x08776655443322010000000000000000); - assert_eq!(bswap(0x0122334455667708i128), 0x08776655443322010000000000000000); - - assert_eq!(bitreverse(0x0Au8), 0x50); - assert_eq!(bitreverse(0x0Ai8), 0x50); - assert_eq!(bitreverse(0x0A0Cu16), 0x3050); - assert_eq!(bitreverse(0x0A0Ci16), 0x3050); - assert_eq!(bitreverse(0x0ABBCC0Eu32), 0x7033DD50); - assert_eq!(bitreverse(0x0ABBCC0Ei32), 0x7033DD50); - assert_eq!(bitreverse(0x0122334455667708u64), 0x10EE66AA22CC4480); - assert_eq!(bitreverse(0x0122334455667708i64), 0x10EE66AA22CC4480); - assert_eq!(bitreverse(0x0122334455667708u128), 0x10EE66AA22CC44800000000000000000); - assert_eq!(bitreverse(0x0122334455667708i128), 0x10EE66AA22CC44800000000000000000); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsics-math.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsics-math.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsics-math.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsics-math.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten fma not implemented in emscripten - -macro_rules! assert_approx_eq { - ($a:expr, $b:expr) => ({ - let (a, b) = (&$a, &$b); - assert!((*a - *b).abs() < 1.0e-6, - "{} is not approximately equal to {}", *a, *b); - }) -} - -pub fn main() { - use std::f32; - use std::f64; - - assert_approx_eq!(64f32.sqrt(), 8f32); - assert_approx_eq!(64f64.sqrt(), 8f64); - - assert_approx_eq!(25f32.powi(-2), 0.0016f32); - assert_approx_eq!(23.2f64.powi(2), 538.24f64); - - assert_approx_eq!(0f32.sin(), 0f32); - assert_approx_eq!((f64::consts::PI / 2f64).sin(), 1f64); - - assert_approx_eq!(0f32.cos(), 1f32); - assert_approx_eq!((f64::consts::PI * 2f64).cos(), 1f64); - - assert_approx_eq!(25f32.powf(-2f32), 0.0016f32); - assert_approx_eq!(400f64.powf(0.5f64), 20f64); - - assert_approx_eq!((1f32.exp() - f32::consts::E).abs(), 0f32); - assert_approx_eq!(1f64.exp(), f64::consts::E); - - assert_approx_eq!(10f32.exp2(), 1024f32); - assert_approx_eq!(50f64.exp2(), 1125899906842624f64); - - assert_approx_eq!((f32::consts::E.ln() - 1f32).abs(), 0f32); - assert_approx_eq!(1f64.ln(), 0f64); - - assert_approx_eq!(10f32.log10(), 1f32); - assert_approx_eq!(f64::consts::E.log10(), f64::consts::LOG10_E); - - assert_approx_eq!(8f32.log2(), 3f32); - assert_approx_eq!(f64::consts::E.log2(), f64::consts::LOG2_E); - - assert_approx_eq!(1.0f32.mul_add(2.0f32, 5.0f32), 7.0f32); - assert_approx_eq!(0.0f64.mul_add(-2.0f64, f64::consts::E), f64::consts::E); - - assert_approx_eq!((-1.0f32).abs(), 1.0f32); - assert_approx_eq!(34.2f64.abs(), 34.2f64); - - assert_approx_eq!(3.8f32.floor(), 3.0f32); - assert_approx_eq!((-1.1f64).floor(), -2.0f64); - - assert_approx_eq!((-2.3f32).ceil(), -2.0f32); - assert_approx_eq!(3.8f64.ceil(), 4.0f64); - - assert_approx_eq!(0.1f32.trunc(), 0.0f32); - assert_approx_eq!((-0.1f64).trunc(), 0.0f64); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-uninit.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-uninit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-uninit.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-uninit.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(intrinsics)] - -mod rusti { - extern "rust-intrinsic" { - pub fn uninit() -> T; - } -} -pub fn main() { - let _a : isize = unsafe {rusti::uninit()}; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-unreachable.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-unreachable.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-unreachable.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/intrinsics/intrinsic-unreachable.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(core_intrinsics)] - -use std::intrinsics; - -// See also src/test/run-make/intrinsic-unreachable. - -unsafe fn f(x: usize) -> usize { - match x { - 17 => 23, - _ => intrinsics::unreachable(), - } -} - -fn main() { - assert_eq!(unsafe { f(17) }, 23); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/cgu_test_a.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/cgu_test_a.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/cgu_test_a.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/cgu_test_a.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic -// compile-flags: -Ccodegen-units=2 --crate-type=lib - -extern crate cgu_test; - -pub mod a { - pub fn a() { - ::cgu_test::id(0); - } -} -pub mod b { - pub fn a() { - ::cgu_test::id(0); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/cgu_test_b.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/cgu_test_b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/cgu_test_b.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/cgu_test_b.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic -// compile-flags: -Ccodegen-units=2 --crate-type=lib - -extern crate cgu_test; - -pub mod a { - pub fn a() { - ::cgu_test::id(0); - } -} -pub mod b { - pub fn a() { - ::cgu_test::id(0); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/cgu_test.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/cgu_test.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/cgu_test.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/cgu_test.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic -// compile-flags: --crate-type=lib - -pub fn id(t: T) -> T { - t -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/i8.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/i8.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/i8.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/i8.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// A crate named after a built-in type. - -pub struct Test; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/iss.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/iss.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/iss.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/iss.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="issue6919_3"] - -// part of issue-6919.rs - -pub struct C where K: FnOnce() { - pub k: K, -} - -fn no_op() { } -pub const D : C = C { - k: no_op as fn() -}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-10028.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-10028.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-10028.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-10028.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct ZeroLengthThingWithDestructor; -impl Drop for ZeroLengthThingWithDestructor { - fn drop(&mut self) {} -} -impl ZeroLengthThingWithDestructor { - pub fn new() -> ZeroLengthThingWithDestructor { - ZeroLengthThingWithDestructor - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_10031_aux.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_10031_aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_10031_aux.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_10031_aux.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct Wrap(pub A); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11224.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11224.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11224.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11224.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![deny(dead_code)] - -mod inner { - pub trait Trait { - fn f(&self) { f(); } - } - - impl Trait for isize {} - - fn f() {} -} - -pub fn foo() { - let a = &1isize as &inner::Trait; - a.f(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11225-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11225-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11225-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11225-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod inner { - pub trait Trait { - fn f(&self) { f(); } - fn f_ufcs(&self) { f_ufcs(); } - } - - impl Trait for isize {} - - fn f() {} - fn f_ufcs() {} -} - -pub fn foo(t: T) { - t.f(); -} -pub fn foo_ufcs(t: T) { - T::f_ufcs(&t); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11225-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11225-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11225-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11225-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use inner::Trait; - -mod inner { - pub struct Foo; - pub trait Trait { - fn f(&self); - fn f_ufcs(&self); - } - - impl Trait for Foo { - fn f(&self) { } - fn f_ufcs(&self) { } - } -} - -pub trait Outer { - fn foo(&self, t: T) { t.f(); } - fn foo_ufcs(&self, t: T) { T::f(&t); } -} - -impl Outer for isize {} - -pub fn foo(t: T) { - t.foo(inner::Foo); -} -pub fn foo_ufcs(t: T) { - T::foo_ufcs(&t, inner::Foo) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11225-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11225-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11225-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11225-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait PrivateTrait { - fn private_trait_method(&self); - fn private_trait_method_ufcs(&self); -} - -struct PrivateStruct; - -impl PrivateStruct { - fn private_inherent_method(&self) { } - fn private_inherent_method_ufcs(&self) { } -} - -impl PrivateTrait for PrivateStruct { - fn private_trait_method(&self) { } - fn private_trait_method_ufcs(&self) { } -} - -#[inline] -pub fn public_inlinable_function() { - PrivateStruct.private_trait_method(); - PrivateStruct.private_inherent_method(); -} - -#[inline] -pub fn public_inlinable_function_ufcs() { - PrivateStruct::private_trait_method(&PrivateStruct); - PrivateStruct::private_inherent_method(&PrivateStruct); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11508.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11508.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11508.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11508.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct Closed01(pub F); - -pub trait Bar { fn new() -> Self; } - -impl Bar for Closed01 { - fn new() -> Closed01 { Closed01(Bar::new()) } -} -impl Bar for f32 { fn new() -> f32 { 1.0 } } - -pub fn random() -> T { Bar::new() } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11529.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11529.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11529.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-11529.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct A<'a>(pub &'a isize); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-12133-dylib2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-12133-dylib2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-12133-dylib2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-12133-dylib2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "dylib"] - -extern crate issue_12133_rlib as a; -extern crate issue_12133_dylib as b; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-12133-dylib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-12133-dylib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-12133-dylib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-12133-dylib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-12133-rlib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-12133-rlib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-12133-rlib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-12133-rlib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "rlib"] diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_12612_1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_12612_1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_12612_1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_12612_1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod bar { - pub fn foo() {} -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_12612_2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_12612_2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_12612_2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_12612_2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn baz() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-12660-aux.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-12660-aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-12660-aux.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-12660-aux.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] -#![crate_name="issue12660aux"] - -pub use my_mod::{MyStruct, my_fn}; - -mod my_mod { - pub struct MyStruct; - - pub fn my_fn(my_struct: MyStruct) { - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue13507.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue13507.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue13507.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue13507.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod testtypes { - use std::any::TypeId; - - pub fn type_ids() -> Vec { - vec![ - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::() - ] - } - - // Tests Bool - pub type FooBool = bool; - - // Tests Char - pub type FooChar = char; - - // Tests Int (does not test all variants of IntTy) - pub type FooInt = isize; - - // Tests Uint (does not test all variants of UintTy) - pub type FooUint = usize; - - // Tests Float (does not test all variants of FloatTy) - pub type FooFloat = f64; - - // Tests Str - pub type FooStr = str; - - // Tests Array - pub type FooArray = [u8; 1]; - - // Tests Slice - pub type FooSlice = [u8]; - - // Tests Box (of u8) - pub type FooBox = Box; - - // Tests RawPtr - pub type FooPtr = *const u8; - - // Tests Ref - pub type FooRef = &'static u8; - - // Tests FnPtr - pub type FooFnPtr = fn(u8) -> bool; - - // Tests Dynamic - pub trait FooTrait { - fn foo_method(&self) -> usize; - } - - // Tests struct - pub struct FooStruct { - pub pub_foo_field: usize, - foo_field: usize - } - - // Tests enum - pub enum FooEnum { - VarA(usize), - VarB(usize, usize) - } - - // Tests Tuple - pub type FooNil = (); - pub type FooTuple = (u8, i8, bool); - - // Skipping Param - - // Skipping Infer - - // Skipping Error -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-13620-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-13620-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-13620-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-13620-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct Foo { - pub foo: extern fn() -} - -extern fn the_foo() {} - -pub const FOO: Foo = Foo { - foo: the_foo -}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-13620-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-13620-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-13620-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-13620-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate issue_13620_1 as crate1; - -pub static FOO2: crate1::Foo = crate1::FOO; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-13872-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-13872-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-13872-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-13872-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub enum A { B } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-13872-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-13872-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-13872-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-13872-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate issue_13872_1 as foo; - -pub use foo::A::B; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-13872-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-13872-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-13872-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-13872-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate issue_13872_2 as bar; - -use bar::B; - -pub fn foo() { - match B { - B => {} - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-14344-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-14344-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-14344-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-14344-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "rlib"] - -pub fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-14344-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-14344-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-14344-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-14344-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate issue_14344_1; - -pub fn bar() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-14421.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-14421.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-14421.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-14421.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] -#![deny(warnings)] -#![allow(dead_code)] - -pub use src::aliases::B; -pub use src::hidden_core::make; - -mod src { - pub mod aliases { - use super::hidden_core::A; - pub type B = A; - } - - pub mod hidden_core { - use super::aliases::B; - - pub struct A { t: T } - - pub fn make() -> B { A { t: 1.0 } } - - impl A { - pub fn foo(&mut self) { println!("called foo"); } - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-14422.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-14422.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-14422.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-14422.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] -#![deny(warnings)] - -pub use src::aliases::B; -pub use src::hidden_core::make; - -mod src { - pub mod aliases { - use super::hidden_core::A; - pub type B = A; - } - - pub mod hidden_core { - use super::aliases::B; - - #[derive(Copy, Clone)] - pub struct A; - - pub fn make() -> B { A } - - impl A { - pub fn foo(&mut self) { println!("called foo"); } - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-15562.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-15562.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-15562.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-15562.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -extern { - pub fn transmute(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-16643.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-16643.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-16643.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-16643.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -pub struct TreeBuilder { pub h: H } - -impl TreeBuilder { - pub fn process_token(&mut self) { - match self { - _ => for _y in self.by_ref() {} - } - } -} - -impl Iterator for TreeBuilder { - type Item = H; - - fn next(&mut self) -> Option { - None - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-17662.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-17662.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-17662.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-17662.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -pub trait Foo<'a, T> { - fn foo(&'a self) -> T; -} - -pub fn foo<'a, T>(x: &'a Foo<'a, T>) -> T { - let x: &'a Foo = x; - // ^ the lifetime parameter of Foo is left to be inferred. - x.foo() - // ^ encoding this method call in metadata triggers an ICE. -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-17718-aux.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-17718-aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-17718-aux.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-17718-aux.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::sync::atomic; - -pub const C1: usize = 1; -pub const C2: atomic::AtomicUsize = atomic::AtomicUsize::new(0); -pub const C3: fn() = { fn foo() {} foo }; -pub const C4: usize = C1 * C1 + C1 / C1; -pub const C5: &'static usize = &C4; - -pub static S1: usize = 3; -pub static S2: atomic::AtomicUsize = atomic::AtomicUsize::new(0); - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-18501.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-18501.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-18501.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-18501.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -struct Foo; - -trait Tr { - fn tr(&self); -} - -impl Tr for Foo { - fn tr(&self) {} -} - -fn take_method(f: fn(&T), t: &T) {} - -#[inline] -pub fn pass_method() { - take_method(Tr::tr, &Foo); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-18514.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-18514.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-18514.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-18514.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -pub trait Tr { - fn tr(&self); -} - -pub struct St(pub Vec); - -impl Tr for St { - fn tr(&self) { - match self { - &St(ref v) => { - v.iter(); - } - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-18711.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-18711.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-18711.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-18711.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -pub fn inner(f: F) -> F { - (move || f)() -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-18913-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-18913-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-18913-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-18913-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "rlib"] -#![crate_name = "foo"] - -pub fn foo() -> i32 { 0 } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-18913-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-18913-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-18913-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-18913-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "rlib"] -#![crate_name = "foo"] - -pub fn foo() -> i32 { 1 } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_19293.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_19293.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_19293.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_19293.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct Foo (pub isize); -pub enum MyEnum { - Foo(Foo), -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-19340-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-19340-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-19340-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-19340-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub enum Homura { - Madoka { name: String }, -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_20389.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_20389.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_20389.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_20389.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub trait T { - type C; - fn dummy(&self) { } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue2170lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue2170lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue2170lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue2170lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn foo(_x: i32) { -} - -pub struct rsrc { - x: i32, -} - -impl Drop for rsrc { - fn drop(&mut self) { - foo(self.x); - } -} - -pub fn rsrc(x: i32) -> rsrc { - rsrc { - x: x - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_2316_a.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_2316_a.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_2316_a.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_2316_a.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum cat { - tabby, calico, tortoiseshell -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_2316_b.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_2316_b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_2316_b.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_2316_b.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_imports)] - -extern crate issue_2316_a; - -pub mod cloth { - use issue_2316_a::*; - - pub enum fabric { - gingham, flannel, calico - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-2380.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-2380.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-2380.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-2380.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="a"] -#![crate_type = "lib"] - -#![feature(box_syntax)] - -pub trait i -{ - fn dummy(&self, t: T) -> T { panic!() } -} - -pub fn f() -> Box+'static> { - impl i for () { } - - box () as Box+'static> -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-2414-a.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-2414-a.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-2414-a.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-2414-a.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="a"] -#![crate_type = "lib"] - -type t1 = usize; - -trait foo { - fn foo(&self); -} - -impl foo for String { - fn foo(&self) {} -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-2414-b.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-2414-b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-2414-b.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-2414-b.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -#![crate_name="b"] -#![crate_type = "lib"] - -extern crate a; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_2472_b.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_2472_b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_2472_b.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_2472_b.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -pub struct S(pub ()); - -impl S { - pub fn foo(&self) { } -} - -pub trait T { - fn bar(&self); -} - -impl T for S { - fn bar(&self) { } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-25185-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-25185-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-25185-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-25185-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "rlib"] - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - pub fn rust_dbg_extern_identity_u32(u: u32) -> u32; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-25185-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-25185-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-25185-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-25185-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate issue_25185_1; - -pub use issue_25185_1::rust_dbg_extern_identity_u32; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-2526.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-2526.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-2526.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-2526.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="issue_2526"] -#![crate_type = "lib"] - -use std::marker; - -pub struct arc_destruct { - _data: isize, - _marker: marker::PhantomData -} - -impl Drop for arc_destruct { - fn drop(&mut self) {} -} - -fn arc_destruct(data: isize) -> arc_destruct { - arc_destruct { - _data: data, - _marker: marker::PhantomData - } -} - -fn arc(_data: T) -> arc_destruct { - arc_destruct(0) -} - -fn init() -> arc_destruct { - arc(context_res()) -} - -pub struct context_res { - ctx : isize, -} - -impl Drop for context_res { - fn drop(&mut self) {} -} - -fn context_res() -> context_res { - context_res { - ctx: 0 - } -} - -pub type context = arc_destruct; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-25467.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-25467.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-25467.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-25467.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] - -pub trait Trait { - // the issue is sensitive to interning order - so use names - // unlikely to appear in libstd. - type Issue25467FooT; - type Issue25467BarT; -} - -pub type Object = Option>>; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-2631-a.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-2631-a.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-2631-a.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-2631-a.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="req"] -#![crate_type = "lib"] - -use std::cell::RefCell; -use std::collections::HashMap; -use std::rc::Rc; - -pub type header_map = HashMap>>>>; - -// the unused ty param is necessary so this gets monomorphized -pub fn request(req: &header_map) { - let data = req[&"METHOD".to_string()].clone(); - let _x = data.borrow().clone()[0].clone(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_2723_a.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_2723_a.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_2723_a.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_2723_a.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -pub unsafe fn f(xs: Vec ) { - xs.iter().map(|_x| { unsafe fn q() { panic!(); } }).collect::>(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-29485.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-29485.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-29485.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-29485.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="a"] -#![crate_type = "lib"] - -pub struct X(pub u8); - -impl Drop for X { - fn drop(&mut self) { - assert_eq!(self.0, 1) - } -} - -pub fn f(x: &mut X, g: fn()) { - x.0 = 1; - g(); - x.0 = 0; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-3012-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-3012-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-3012-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-3012-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="socketlib"] -#![crate_type = "lib"] - -pub mod socket { - pub struct socket_handle { - sockfd: u32, - } - - impl Drop for socket_handle { - fn drop(&mut self) { - /* c::close(self.sockfd); */ - } - } - - pub fn socket_handle(x: u32) -> socket_handle { - socket_handle { - sockfd: x - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_3136_a.rc rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_3136_a.rc --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_3136_a.rc 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_3136_a.rc 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -pub mod issue_3136_a; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_3136_a.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_3136_a.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_3136_a.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_3136_a.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait x { - fn use_x(&self); -} -struct y(()); -impl x for y { - fn use_x(&self) { - struct foo { //~ ERROR quux - i: () - } - fn new_foo(i: ()) -> foo { - foo { i: i } - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue34796aux.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue34796aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue34796aux.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue34796aux.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -pub trait Future { - type Item; - type Error; -} - -impl Future for u32 { - type Item = (); - type Error = Box<()>; -} - -fn foo() -> Box>> { - Box::new(0u32) -} - -pub fn bar(_s: F) - where F: Fn(A) -> B, -{ - foo(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-36954.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-36954.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-36954.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-36954.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(min_const_fn)] -#![crate_type = "lib"] - -const fn foo(i: i32) -> i32 { - i -} - -pub const FOO: i32 = foo(1); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_38190.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_38190.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_38190.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_38190.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[macro_export] -macro_rules! m { ([$i:item]) => {} } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_38226_aux.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_38226_aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_38226_aux.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_38226_aux.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="rlib"] - -#[inline(never)] -pub fn foo() { - let _: Box = Box::new(SomeTraitImpl); -} - -pub fn bar() { - SomeTraitImpl.bar(); -} - -mod submod { - pub trait SomeTrait { - fn bar(&self) { - panic!("NO") - } - } -} - -use self::submod::SomeTrait; - -pub struct SomeTraitImpl; -impl SomeTrait for SomeTraitImpl {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_38715-modern.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_38715-modern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_38715-modern.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_38715-modern.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(duplicate_macro_exports)] - -#[macro_export] -macro_rules! foo_modern { ($i:ident) => {} } - -#[macro_export] -macro_rules! foo_modern { () => {} } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_38715.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_38715.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_38715.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_38715.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(duplicate_macro_exports)] - -#[macro_export] -macro_rules! foo { ($i:ident) => {} } - -#[macro_export] -macro_rules! foo { () => {} } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_3979_traits.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_3979_traits.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_3979_traits.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_3979_traits.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="issue_3979_traits"] - -#![crate_type = "lib"] - -pub trait Positioned { - fn SetX(&mut self, _: isize); - fn X(&self) -> isize; -} - -pub trait Movable: Positioned { - fn translate(&mut self, dx: isize) { - let x = self.X() + dx; - self.SetX(x); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_39823.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_39823.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_39823.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_39823.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="rlib"] - -#[derive(Debug, PartialEq)] -pub struct RemoteC(pub u32); - -#[derive(Debug, PartialEq)] -pub struct RemoteG(pub T); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_40469.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_40469.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_40469.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_40469.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! m { () => { $crate::main(); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_41053.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_41053.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_41053.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_41053.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct Test; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-41394.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-41394.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-41394.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-41394.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -#[repr(u32)] -pub enum Foo { - Foo = Private::Variant as u32 -} - -#[repr(u8)] -enum Private { - Variant = 42 -} - -#[inline(always)] -pub fn foo() -> Foo { - Foo::Foo -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_42007_s.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_42007_s.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_42007_s.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_42007_s.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[repr(u8)] -pub enum E { - B = 1 as u8, -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-4208-cc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-4208-cc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-4208-cc.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-4208-cc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="numeric"] -#![crate_type = "lib"] - -pub trait Trig { - fn sin(&self) -> T; -} - -pub fn sin, R>(theta: &T) -> R { theta.sin() } - -pub trait Angle: Trig {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-4545.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-4545.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-4545.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-4545.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct S(Option); -pub fn mk() -> S { S(None) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-48984-aux.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-48984-aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-48984-aux.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-48984-aux.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -#![crate_name = "issue48984aux"] - -pub trait Foo { type Item; } - -pub trait Bar: Foo { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-5518.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-5518.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-5518.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-5518.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait A<'a, T> { - fn f(&mut self) -> &'a mut T; - fn p() -> T; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-5521.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-5521.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-5521.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-5521.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::collections::HashMap; - -pub type map = Box>; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-7178.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-7178.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-7178.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-7178.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct Foo<'a, A:'a>(&'a A); - -impl<'a, A> Foo<'a, A> { - pub fn new(a: &'a A) -> Foo<'a, A> { - Foo(a) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-7899.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-7899.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-7899.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-7899.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct V2(pub T, pub T); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-8044.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-8044.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-8044.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-8044.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct BTree { - pub node: TreeItem, -} - -pub enum TreeItem { - TreeLeaf { value: V }, -} - -pub fn leaf(value: V) -> TreeItem { - TreeItem::TreeLeaf { value: value } -} - -fn main() { - BTree:: { node: leaf(1) }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-8259.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-8259.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-8259.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-8259.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -pub enum Foo<'a> { - A, - B(&'a str), -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_8401.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_8401.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_8401.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_8401.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// for this issue, this code must be built in a library - -use std::mem; - -trait A { - fn dummy(&self) { } -} -struct B; -impl A for B {} - -fn bar(_: &mut A, _: &T) {} - -fn foo(t: &T) { - let mut b = B; - bar(&mut b as &mut A, t) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_9123.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_9123.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_9123.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_9123.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -pub trait X { - fn x() { - fn f() { } - f(); - } - fn dummy(&self) { } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_9155.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_9155.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_9155.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_9155.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct Foo(T); - -impl Foo { - pub fn new(t: T) -> Foo { - Foo(t) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_9188.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_9188.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_9188.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue_9188.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo() -> &'static isize { - if false { - static a: isize = 4; - return &a; - } else { - static a: isize = 5; - return &a; - } -} - -pub fn bar() -> &'static isize { - foo::() -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-9906.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-9906.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-9906.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-9906.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub use other::FooBar; -pub use other::foo; - -mod other { - pub struct FooBar{value: isize} - impl FooBar{ - pub fn new(val: isize) -> FooBar { - FooBar{value: val} - } - } - - pub fn foo(){ - 1+1; - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-9968.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-9968.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-9968.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/auxiliary/issue-9968.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub use internal::core::{Trait, Struct}; - -mod internal { - pub mod core { - pub struct Struct; - impl Struct { - pub fn init() -> Struct { - Struct - } - } - - pub trait Trait { - fn test(&self) { - private(); - } - } - - impl Trait for Struct {} - - fn private() { } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10025.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10025.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10025.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10025.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -unsafe extern fn foo() {} -unsafe extern "C" fn bar() {} - -fn main() { - let _a: unsafe extern fn() = foo; - let _a: unsafe extern "C" fn() = foo; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10028.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10028.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10028.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10028.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-10028.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_10028 as issue10028; - -use issue10028::ZeroLengthThingWithDestructor; - -struct Foo { - zero_length_thing: ZeroLengthThingWithDestructor -} - -fn make_foo() -> Foo { - Foo { zero_length_thing: ZeroLengthThingWithDestructor::new() } -} - -fn main() { - let _f:Foo = make_foo(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10031.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10031.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10031.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10031.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue_10031_aux.rs -// pretty-expanded FIXME #23616 - -extern crate issue_10031_aux; - -pub fn main() { - let _ = issue_10031_aux::Wrap(()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10228.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10228.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10228.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10228.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -enum StdioContainer { - CreatePipe(bool) -} - -struct Test<'a> { - args: &'a [String], - io: &'a [StdioContainer] -} - -pub fn main() { - let test = Test { - args: &[], - io: &[StdioContainer::CreatePipe(true)] - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10392.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10392.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10392.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10392.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct A { foo: isize } -struct B { a: isize, b: isize, c: isize } - -fn mka() -> A { panic!() } -fn mkb() -> B { panic!() } - -fn test() { - let A { foo, } = mka(); - let A { - foo, - } = mka(); - - let B { a, b, c, } = mkb(); - - match mka() { - A { foo: _foo, } => {} - } - - match Some(mka()) { - Some(A { foo: _foo, }) => {} - None => {} - } -} - -pub fn main() { - if false { test() } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10396.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10396.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10396.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10396.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Debug)] -enum Foo<'s> { - V(&'s str) -} - -fn f(arr: &[&Foo]) { - for &f in arr { - println!("{:?}", f); - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10436.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10436.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10436.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10436.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn works(x: T) -> Vec { vec![x] } - -fn also_works(x: T) -> Vec { vec![x] } - -fn main() { - let _: Vec = works(0); - let _: Vec = also_works(0); - let _ = works(0); - let _ = also_works(0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10456.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10456.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10456.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10456.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub struct Foo; - -pub trait Bar { - fn bar(&self); -} - -pub trait Baz { - fn baz(&self) { } -} - -impl Bar for T { - fn bar(&self) {} -} - -impl Baz for Foo {} - -pub fn foo(t: Box) { - t.bar(); // ~Foo doesn't implement Baz - (*t).bar(); // ok b/c Foo implements Baz -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10626.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10626.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10626.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10626.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-cloudabi no processes -// ignore-emscripten no processes - -// Make sure that if a process doesn't have its stdio/stderr descriptors set up -// that we don't die in a large ball of fire - -use std::env; -use std::process::{Command, Stdio}; - -pub fn main () { - let args: Vec = env::args().collect(); - if args.len() > 1 && args[1] == "child" { - for _ in 0..1000 { - println!("hello?"); - } - for _ in 0..1000 { - println!("hello?"); - } - return; - } - - let mut p = Command::new(&args[0]); - p.arg("child").stdout(Stdio::null()).stderr(Stdio::null()); - println!("{:?}", p.spawn().unwrap().wait()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10638.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10638.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10638.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10638.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub fn main() { - //// I am not a doc comment! - ////////////////// still not a doc comment - /////**** nope, me neither */ - /*** And neither am I! */ - 5; - /*****! certainly not I */ -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10682.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10682.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10682.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10682.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for issue #10682 -// Nested `proc` usage can't use outer owned data - -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - -fn work(_: Box) {} -fn foo(_: F) {} - -pub fn main() { - let a = box 1; - foo(move|| { foo(move|| { work(a) }) }) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10683.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10683.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10683.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10683.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -static NAME: &'static str = "hello world"; - -fn main() { - match &*NAME.to_ascii_lowercase() { - "foo" => {} - _ => {} - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10718.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10718.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10718.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10718.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn f(p: F) { - p(); -} - -pub fn main() { - let p = || (); - f(p); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10734.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10734.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10734.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10734.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -static mut drop_count: usize = 0; - -struct Foo { - dropped: bool -} - -impl Drop for Foo { - fn drop(&mut self) { - // Test to make sure we haven't dropped already - assert!(!self.dropped); - self.dropped = true; - // And record the fact that we dropped for verification later - unsafe { drop_count += 1; } - } -} - -pub fn main() { - // An `if true { expr }` statement should compile the same as `{ expr }`. - if true { - let _a = Foo{ dropped: false }; - } - // Check that we dropped already (as expected from a `{ expr }`). - unsafe { assert_eq!(drop_count, 1); } - - // An `if false {} else { expr }` statement should compile the same as `{ expr }`. - if false { - panic!(); - } else { - let _a = Foo{ dropped: false }; - } - // Check that we dropped already (as expected from a `{ expr }`). - unsafe { assert_eq!(drop_count, 2); } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10763.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10763.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10763.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10763.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -extern "Rust" fn foo() {} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10764.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10764.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10764.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10764.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -extern "Rust" fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10767.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10767.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10767.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10767.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - -pub fn main() { - fn f() { - }; - let _: Box = box (f as fn()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10802.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10802.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10802.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10802.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -struct DroppableStruct; -enum DroppableEnum { - DroppableVariant1, DroppableVariant2 -} - -static mut DROPPED: bool = false; - -impl Drop for DroppableStruct { - fn drop(&mut self) { - unsafe { DROPPED = true; } - } -} -impl Drop for DroppableEnum { - fn drop(&mut self) { - unsafe { DROPPED = true; } - } -} - -trait MyTrait { fn dummy(&self) { } } -impl MyTrait for Box {} -impl MyTrait for Box {} - -struct Whatever { w: Box } -impl Whatever { - fn new(w: Box) -> Whatever { - Whatever { w: w } - } -} - -fn main() { - { - let f: Box<_> = box DroppableStruct; - let _a = Whatever::new(box f as Box); - } - assert!(unsafe { DROPPED }); - unsafe { DROPPED = false; } - { - let f: Box<_> = box DroppableEnum::DroppableVariant1; - let _a = Whatever::new(box f as Box); - } - assert!(unsafe { DROPPED }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10806.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10806.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10806.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10806.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// pretty-expanded FIXME #23616 - -pub fn foo() -> isize { - 3 -} -pub fn bar() -> isize { - 4 -} - -pub mod baz { - use {foo, bar}; - pub fn quux() -> isize { - foo() + bar() - } -} - -pub mod grault { - use {foo}; - pub fn garply() -> isize { - foo() - } -} - -pub mod waldo { - use {}; - pub fn plugh() -> isize { - 0 - } -} - -pub fn main() { - let _x = baz::quux(); - let _y = grault::garply(); - let _z = waldo::plugh(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10853.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10853.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10853.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10853.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![deny(missing_docs)] -#![doc="module"] - -#[doc="struct"] -pub struct Foo; - -pub fn foo() { - #![doc="fn"] -} - -#[doc="main"] -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10902.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10902.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10902.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-10902.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub mod two_tuple { - pub trait T { fn dummy(&self) { } } - pub struct P<'a>(&'a (T + 'a), &'a (T + 'a)); - pub fn f<'a>(car: &'a T, cdr: &'a T) -> P<'a> { - P(car, cdr) - } -} - -pub mod two_fields { - pub trait T { fn dummy(&self) { } } - pub struct P<'a> { car: &'a (T + 'a), cdr: &'a (T + 'a) } - pub fn f<'a>(car: &'a T, cdr: &'a T) -> P<'a> { - P{ car: car, cdr: cdr } - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11047.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11047.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11047.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11047.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that static methods can be invoked on `type` aliases - -#![allow(unused_variables)] - -pub mod foo { - pub mod bar { - pub mod baz { - pub struct Qux; - - impl Qux { - pub fn new() {} - } - } - } -} - -fn main() { - - type Ham = foo::bar::baz::Qux; - let foo = foo::bar::baz::Qux::new(); // invoke directly - let bar = Ham::new(); // invoke via type alias - - type StringVec = Vec; - let sv = StringVec::new(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11085.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11085.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11085.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11085.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -// Copyright 2012-2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: --cfg foo - -// pretty-expanded FIXME #23616 - -struct Foo { - #[cfg(fail)] - bar: baz, - foo: isize, -} - -struct Foo2 { - #[cfg(foo)] - foo: isize, -} - -enum Bar1 { - Bar1_1, - #[cfg(fail)] - Bar1_2(NotAType), -} - -enum Bar2 { - #[cfg(fail)] - Bar2_1(NotAType), -} - -enum Bar3 { - Bar3_1 { - #[cfg(fail)] - foo: isize, - bar: isize, - } -} - -pub fn main() { - let _f = Foo { foo: 3 }; - let _f = Foo2 { foo: 3 }; - - match Bar1::Bar1_1 { - Bar1::Bar1_1 => {} - } - - let _f = Bar3::Bar3_1 { bar: 3 }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1112.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1112.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1112.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1112.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #1112 -// Alignment of interior pointers to dynamic-size types - - -struct X { - a: T, - b: u8, - c: bool, - d: u8, - e: u16, - f: u8, - g: u8 -} - -pub fn main() { - let x: X = X { - a: 12345678, - b: 9, - c: true, - d: 10, - e: 11, - f: 12, - g: 13 - }; - bar(x); -} - -fn bar(x: X) { - assert_eq!(x.b, 9); - assert_eq!(x.c, true); - assert_eq!(x.d, 10); - assert_eq!(x.e, 11); - assert_eq!(x.f, 12); - assert_eq!(x.g, 13); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11205.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11205.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11205.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11205.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,95 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![allow(dead_code)] - -trait Foo { fn dummy(&self) { } } -impl Foo for isize {} -fn foo(_: [&Foo; 2]) {} -fn foos(_: &[&Foo]) {} -fn foog(_: &[T], _: &[T]) {} - -fn bar(_: [Box; 2]) {} -fn bars(_: &[Box]) {} - -fn main() { - let x: [&Foo; 2] = [&1, &2]; - foo(x); - foo([&1, &2]); - - let r = &1; - let x: [&Foo; 2] = [r; 2]; - foo(x); - foo([&1; 2]); - - let x: &[&Foo] = &[&1, &2]; - foos(x); - foos(&[&1, &2]); - - let x: &[&Foo] = &[&1, &2]; - let r = &1; - foog(x, &[r]); - - let x: [Box; 2] = [Box::new(1), Box::new(2)]; - bar(x); - bar([Box::new(1), Box::new(2)]); - - let x: &[Box] = &[Box::new(1), Box::new(2)]; - bars(x); - bars(&[Box::new(1), Box::new(2)]); - - let x: &[Box] = &[Box::new(1), Box::new(2)]; - foog(x, &[Box::new(1)]); - - struct T<'a> { - t: [&'a (Foo+'a); 2] - } - let _n = T { - t: [&1, &2] - }; - let r = &1; - let _n = T { - t: [r; 2] - }; - let x: [&Foo; 2] = [&1, &2]; - let _n = T { - t: x - }; - - struct F<'b> { - t: &'b [&'b (Foo+'b)] - } - let _n = F { - t: &[&1, &2] - }; - let r = &1; - let r: [&Foo; 2] = [r; 2]; - let _n = F { - t: &r - }; - let x: [&Foo; 2] = [&1, &2]; - let _n = F { - t: &x - }; - - struct M<'a> { - t: &'a [Box] - } - let _n = M { - t: &[Box::new(1), Box::new(2)] - }; - let x: [Box; 2] = [Box::new(1), Box::new(2)]; - let _n = M { - t: &x - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11224.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11224.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11224.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11224.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-11224.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_11224 as unused; - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11225-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11225-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11225-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11225-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-11225-1.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_11225_1 as foo; - -pub fn main() { - foo::foo(1); - foo::foo_ufcs(1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11225-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11225-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11225-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11225-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-11225-2.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_11225_2 as foo; - -pub fn main() { - foo::foo(1); - foo::foo_ufcs(1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11225-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11225-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11225-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11225-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-11225-3.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_11225_3; - -pub fn main() { - issue_11225_3::public_inlinable_function(); - issue_11225_3::public_inlinable_function_ufcs(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11267.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11267.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11267.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11267.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests that unary structs can be mutably borrowed. - -struct Empty; - -trait T { - fn next(&mut self) -> Option; -} -impl T for Empty { - fn next(&mut self) -> Option { None } -} - -fn do_something_with(a : &mut T) { - println!("{:?}", a.next()) -} - -pub fn main() { - do_something_with(&mut Empty); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11382.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11382.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11382.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11382.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - println!("{}", 1.2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11384.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11384.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11384.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11384.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait Common { fn dummy(&self) { } } - -impl<'t, T> Common for (T, &'t T) {} - -impl<'t, T> Common for (&'t T, T) {} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11508.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11508.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11508.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11508.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-11508.rs - -extern crate issue_11508 as rand; - -use rand::{Closed01, random}; - -fn main() { - let Closed01(val) = random::>(); - println!("{}", val); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11529.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11529.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11529.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11529.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-11529.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_11529 as a; - -fn main() { - let one = 1; - let _a = a::A(&one); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11552.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11552.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11552.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11552.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_patterns)] -#![feature(box_syntax)] - -#[derive(Clone)] -enum Noun -{ - Atom(isize), - Cell(Box, Box) -} - -fn fas(n: &Noun) -> Noun -{ - match n { - &Noun::Cell(box Noun::Atom(2), box Noun::Cell(ref a, _)) => (**a).clone(), - _ => panic!("Invalid fas pattern") - } -} - -pub fn main() { - fas(&Noun::Cell(box Noun::Atom(2), box Noun::Cell(box Noun::Atom(2), box Noun::Atom(3)))); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11577.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11577.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11577.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11577.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Destructuring struct variants would ICE where regular structs wouldn't - -enum Foo { - VBar { num: isize } -} - -struct SBar { num: isize } - -pub fn main() { - let vbar = Foo::VBar { num: 1 }; - let Foo::VBar { num } = vbar; - assert_eq!(num, 1); - - let sbar = SBar { num: 2 }; - let SBar { num } = sbar; - assert_eq!(num, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11592.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11592.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11592.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11592.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -//! Ensure the private trait Bar isn't complained about. - -#![deny(missing_docs)] - -mod foo { - trait Bar { fn bar(&self) { } } - impl Bar for i8 { fn bar(&self) { } } -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11612.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11612.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11612.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11612.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// #11612 -// We weren't updating the auto adjustments with all the resolved -// type information after type check. - -// pretty-expanded FIXME #23616 - -trait A { fn dummy(&self) { } } - -struct B<'a, T:'a> { - f: &'a T -} - -impl<'a, T> A for B<'a, T> {} - -fn foo(_: &A) {} - -fn bar(b: &B) { - foo(b); // Coercion should work - foo(b as &A); // Explicit cast should work as well -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11677.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11677.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11677.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11677.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![allow(dead_code)] - -// this code used to cause an ICE - -use std::marker; - -trait X { - fn dummy(&self) -> T { panic!() } -} - -struct S {f: Box+'static>, - g: Box+'static>} - -struct F; -impl X for F { -} - -fn main() { - S {f: Box::new(F), g: Box::new(F) }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11709.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11709.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11709.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11709.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty issue #37199 - -// Don't panic on blocks without results -// There are several tests in this run-pass that raised -// when this bug was opened. The cases where the compiler -// panics before the fix have a comment. - -struct S {x:()} - -fn test(slot: &mut Option Box>>) -> () { - let a = slot.take(); - let _a = match a { - // `{let .. a(); }` would break - Some(mut a) => { let _a = a(); }, - None => (), - }; -} - -fn not(b: bool) -> bool { - if b { - !b - } else { - // `panic!(...)` would break - panic!("Break the compiler"); - } -} - -pub fn main() { - // {} would break - let _r = {}; - let mut slot = None; - // `{ test(...); }` would break - let _s : S = S{ x: { test(&mut slot); } }; - - let _b = not(true); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11820.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11820.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11820.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11820.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -struct NoClone; - -fn main() { - let rnc = &NoClone; - let rsnc = &Some(NoClone); - - let _: &NoClone = rnc.clone(); - let _: &Option = rsnc.clone(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11869.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11869.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11869.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11869.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -struct A { - a: String -} - -fn borrow<'a>(binding: &'a A) -> &'a str { - match &*binding.a { - "in" => "in_", - "ref" => "ref_", - ident => ident - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11940.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11940.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11940.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11940.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -const TEST_STR: &'static str = "abcd"; - -fn main() { - let s = "abcd"; - match s { - TEST_STR => (), - _ => unreachable!() - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11958.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11958.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11958.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-11958.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![forbid(warnings)] - -// We shouldn't need to rebind a moved upvar as mut if it's already -// marked as mut - -pub fn main() { - let mut x = 1; - let _thunk = Box::new(move|| { x = 2; }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12033.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12033.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12033.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12033.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::cell::RefCell; - -fn main() { - let x = RefCell::new(0); - if *x.borrow() == 0 {} else {} -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12133-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12133-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12133-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12133-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-12133-rlib.rs -// aux-build:issue-12133-dylib.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_12133_rlib as a; -extern crate issue_12133_dylib as b; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12133-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12133-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12133-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12133-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-12133-rlib.rs -// aux-build:issue-12133-dylib.rs -// no-prefer-dynamic - -// pretty-expanded FIXME #23616 - -extern crate issue_12133_rlib as a; -extern crate issue_12133_dylib as b; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12133-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12133-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12133-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12133-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-12133-rlib.rs -// aux-build:issue-12133-dylib.rs -// aux-build:issue-12133-dylib2.rs -// ignore-cloudabi no dylib support -// ignore-emscripten no dylib support -// ignore-musl - -// pretty-expanded FIXME #23616 - -extern crate issue_12133_dylib2 as other; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12285.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12285.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12285.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12285.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct S; - -fn main() { - match Some(&S) { - Some(&S) => {}, - _x => unreachable!() - } - match Some(&S) { - Some(&S) => {}, - None => unreachable!() - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1251.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1251.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1251.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1251.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 -// ignore-wasm32-bare no libc to test ffi with - -#![feature(libc)] - -#![crate_id="rust_get_test_int"] - -mod rustrt { - extern crate libc; - - extern { - pub fn rust_get_test_int() -> libc::intptr_t; - } -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1257.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1257.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1257.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1257.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub fn main () { - let mut line = "".to_string(); - let mut i = 0; - while line != "exit".to_string() { - line = if i == 9 { "exit".to_string() } else { "notexit".to_string() }; - i += 1; - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12582.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12582.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12582.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12582.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let x = 1; - let y = 2; - - assert_eq!(3, match (x, y) { - (1, 1) => 1, - (2, 2) => 2, - (1..=2, 2) => 3, - _ => 4, - }); - - // nested tuple - assert_eq!(3, match ((x, y),) { - ((1, 1),) => 1, - ((2, 2),) => 2, - ((1..=2, 2),) => 3, - _ => 4, - }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12612.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12612.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12612.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12612.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue_12612_1.rs -// aux-build:issue_12612_2.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_12612_1 as foo; -extern crate issue_12612_2 as bar; - -mod test { - use bar::baz; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12660.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12660.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12660.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12660.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-12660-aux.rs - -// pretty-expanded FIXME #23616 - -extern crate issue12660aux; - -use issue12660aux::{my_fn, MyStruct}; - -#[allow(path_statements)] -fn main() { - my_fn(MyStruct); - MyStruct; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12677.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12677.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12677.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12677.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn main() { - let s = "Hello"; - let first = s.bytes(); - let second = first.clone(); - - assert_eq!(first.collect::>(), second.collect::>()) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12699.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12699.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12699.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12699.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare can't block the thread -#![allow(deprecated)] - -use std::thread; - -fn main() { - thread::sleep_ms(250); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12729.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12729.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12729.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12729.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub struct Foo; - -mod bar { - use Foo; - - impl Foo { - fn baz(&self) {} - } -} -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12744.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12744.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12744.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12744.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - fn test() -> Box { Box::new(1) } - println!("{:?}", test()) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12860.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12860.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12860.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12860.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::collections::HashSet; - -#[derive(Copy, Clone, PartialEq, Eq, Hash)] -struct XYZ { - x: isize, - y: isize, - z: isize -} - -fn main() { - let mut connected = HashSet::new(); - let mut border = HashSet::new(); - - let middle = XYZ{x: 0, y: 0, z: 0}; - border.insert(middle); - - while !border.is_empty() && connected.len() < 10000 { - let choice = *(border.iter().next().unwrap()); - border.remove(&choice); - connected.insert(choice); - - let cxp = XYZ{x: choice.x + 1, y: choice.y, z: choice.z}; - let cxm = XYZ{x: choice.x - 1, y: choice.y, z: choice.z}; - let cyp = XYZ{x: choice.x, y: choice.y + 1, z: choice.z}; - let cym = XYZ{x: choice.x, y: choice.y - 1, z: choice.z}; - let czp = XYZ{x: choice.x, y: choice.y, z: choice.z + 1}; - let czm = XYZ{x: choice.x, y: choice.y, z: choice.z - 1}; - - if !connected.contains(&cxp) { - border.insert(cxp); - } - if !connected.contains(&cxm){ - border.insert(cxm); - } - if !connected.contains(&cyp){ - border.insert(cyp); - } - if !connected.contains(&cym) { - border.insert(cym); - } - if !connected.contains(&czp){ - border.insert(czp); - } - if !connected.contains(&czm) { - border.insert(czm); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12909.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12909.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12909.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-12909.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -use std::collections::HashMap; - -fn copy(&x: &T) -> T { - x -} - -fn main() { - let arr = [(1, 1), (2, 2), (3, 3)]; - - let v1: Vec<&_> = arr.iter().collect(); - let v2: Vec<_> = arr.iter().map(copy).collect(); - - let m1: HashMap<_, _> = arr.iter().map(copy).collect(); - let m2: HashMap = arr.iter().map(copy).collect(); - let m3: HashMap<_, usize> = arr.iter().map(copy).collect(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13027.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13027.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13027.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13027.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,188 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Tests that match expression handles overlapped literal and range -// properly in the presence of guard function. - -fn val() -> usize { 1 } - -static CONST: usize = 1; - -pub fn main() { - lit_shadow_range(); - range_shadow_lit(); - range_shadow_range(); - multi_pats_shadow_lit(); - multi_pats_shadow_range(); - lit_shadow_multi_pats(); - range_shadow_multi_pats(); - misc(); -} - -fn lit_shadow_range() { - assert_eq!(2, match 1 { - 1 if false => 1, - 1..=2 => 2, - _ => 3 - }); - - let x = 0; - assert_eq!(2, match x+1 { - 0 => 0, - 1 if false => 1, - 1..=2 => 2, - _ => 3 - }); - - assert_eq!(2, match val() { - 1 if false => 1, - 1..=2 => 2, - _ => 3 - }); - - assert_eq!(2, match CONST { - 0 => 0, - 1 if false => 1, - 1..=2 => 2, - _ => 3 - }); - - // value is out of the range of second arm, should match wildcard pattern - assert_eq!(3, match 3 { - 1 if false => 1, - 1..=2 => 2, - _ => 3 - }); -} - -fn range_shadow_lit() { - assert_eq!(2, match 1 { - 1..=2 if false => 1, - 1 => 2, - _ => 3 - }); - - let x = 0; - assert_eq!(2, match x+1 { - 0 => 0, - 1..=2 if false => 1, - 1 => 2, - _ => 3 - }); - - assert_eq!(2, match val() { - 1..=2 if false => 1, - 1 => 2, - _ => 3 - }); - - assert_eq!(2, match CONST { - 0 => 0, - 1..=2 if false => 1, - 1 => 2, - _ => 3 - }); - - // ditto - assert_eq!(3, match 3 { - 1..=2 if false => 1, - 1 => 2, - _ => 3 - }); -} - -fn range_shadow_range() { - assert_eq!(2, match 1 { - 0..=2 if false => 1, - 1..=3 => 2, - _ => 3, - }); - - let x = 0; - assert_eq!(2, match x+1 { - 100 => 0, - 0..=2 if false => 1, - 1..=3 => 2, - _ => 3, - }); - - assert_eq!(2, match val() { - 0..=2 if false => 1, - 1..=3 => 2, - _ => 3, - }); - - assert_eq!(2, match CONST { - 100 => 0, - 0..=2 if false => 1, - 1..=3 => 2, - _ => 3, - }); - - // ditto - assert_eq!(3, match 5 { - 0..=2 if false => 1, - 1..=3 => 2, - _ => 3, - }); -} - -fn multi_pats_shadow_lit() { - assert_eq!(2, match 1 { - 100 => 0, - 0 | 1..=10 if false => 1, - 1 => 2, - _ => 3, - }); -} - -fn multi_pats_shadow_range() { - assert_eq!(2, match 1 { - 100 => 0, - 0 | 1..=10 if false => 1, - 1..=3 => 2, - _ => 3, - }); -} - -fn lit_shadow_multi_pats() { - assert_eq!(2, match 1 { - 100 => 0, - 1 if false => 1, - 0 | 1..=10 => 2, - _ => 3, - }); -} - -fn range_shadow_multi_pats() { - assert_eq!(2, match 1 { - 100 => 0, - 1..=3 if false => 1, - 0 | 1..=10 => 2, - _ => 3, - }); -} - -fn misc() { - enum Foo { - Bar(usize, bool) - } - // This test basically mimics how trace_macros! macro is implemented, - // which is a rare combination of vector patterns, multiple wild-card - // patterns and guard functions. - let r = match [Foo::Bar(0, false)] { - [Foo::Bar(_, pred)] if pred => 1, - [Foo::Bar(_, pred)] if !pred => 2, - _ => 0, - }; - assert_eq!(2, r); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13105.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13105.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13105.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13105.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait Foo { - #[allow(anonymous_parameters)] - fn quux(u8) {} -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13167.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13167.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13167.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13167.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -use std::slice; - -pub struct PhfMapEntries<'a, T: 'a> { - iter: slice::Iter<'a, (&'static str, T)>, -} - -impl<'a, T> Iterator for PhfMapEntries<'a, T> { - type Item = (&'static str, &'a T); - - fn next(&mut self) -> Option<(&'static str, &'a T)> { - self.iter.by_ref().map(|&(key, ref value)| (key, value)).next() - } - - fn size_hint(&self) -> (usize, Option) { - self.iter.size_hint() - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13204.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13204.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13204.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13204.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that when instantiating trait default methods, typeck handles -// lifetime parameters defined on the method bound correctly. - - -pub trait Foo { - fn bar<'a, I: Iterator>(&self, it: I) -> usize { - let mut xs = it.filter(|_| true); - xs.count() - } -} - -pub struct Baz; - -impl Foo for Baz { - // When instantiating `Foo::bar` for `Baz` here, typeck used to - // ICE due to the lifetime parameter of `bar`. -} - -fn main() { - let x = Baz; - let y = vec![(), (), ()]; - assert_eq!(x.bar(y.iter()), 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13214.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13214.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13214.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13214.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// defining static with struct that contains enum -// with &'static str variant used to cause ICE - -// pretty-expanded FIXME #23616 - -pub enum Foo { - Bar, - Baz(&'static str), -} - -pub static TEST: Test = Test { - foo: Foo::Bar, - c: 'a' -}; - -pub struct Test { - foo: Foo, - c: char, -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13259-windows-tcb-trash.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13259-windows-tcb-trash.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13259-windows-tcb-trash.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13259-windows-tcb-trash.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(libc)] - -extern crate libc; - -#[cfg(windows)] -mod imp { - type LPVOID = *mut u8; - type DWORD = u32; - type LPWSTR = *mut u16; - - extern "system" { - fn FormatMessageW(flags: DWORD, - lpSrc: LPVOID, - msgId: DWORD, - langId: DWORD, - buf: LPWSTR, - nsize: DWORD, - args: *const u8) - -> DWORD; - } - - pub fn test() { - let mut buf: [u16; 50] = [0; 50]; - let ret = unsafe { - FormatMessageW(0x1000, 0 as *mut _, 1, 0x400, - buf.as_mut_ptr(), buf.len() as u32, 0 as *const _) - }; - // On some 32-bit Windowses (Win7-8 at least) this will panic with segmented - // stacks taking control of pvArbitrary - assert!(ret != 0); - } -} - -#[cfg(not(windows))] -mod imp { - pub fn test() { } -} - -fn main() { - imp::test() -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13264.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13264.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13264.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13264.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] - -use std::ops::Deref; - -struct Root { - jsref: JSRef -} - -impl Deref for Root { - type Target = JSRef; - - fn deref<'a>(&'a self) -> &'a JSRef { - &self.jsref - } -} - -#[derive(Copy, Clone)] -struct JSRef { - node: *const Node -} - -impl Deref for JSRef { - type Target = Node; - - fn deref<'a>(&'a self) -> &'a Node { - self.get() - } -} - -trait INode { - fn RemoveChild(&self); -} - -impl INode for JSRef { - fn RemoveChild(&self) { - self.get().RemoveChild(0) - } -} - -impl JSRef { - fn AddChild(&self) { - self.get().AddChild(0); - } - - fn get<'a>(&'a self) -> &'a Node { - unsafe { - &*self.node - } - } -} - -struct Node; - -impl Node { - fn RemoveChild(&self, _a: usize) { - } - - fn AddChild(&self, _a: usize) { - } -} - -fn main() { - let n = Node; - let jsref = JSRef { node: &n }; - let root = Root { jsref: jsref }; - - root.AddChild(); - jsref.AddChild(); - - root.RemoveChild(); - jsref.RemoveChild(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13304.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13304.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13304.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13304.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-cloudabi no processes -// ignore-emscripten no processes - -use std::env; -use std::io::prelude::*; -use std::io; -use std::process::{Command, Stdio}; -use std::str; - -fn main() { - let args: Vec = env::args().collect(); - if args.len() > 1 && args[1] == "child" { - child(); - } else { - parent(); - } -} - -fn parent() { - let args: Vec = env::args().collect(); - let mut p = Command::new(&args[0]).arg("child") - .stdout(Stdio::piped()) - .stdin(Stdio::piped()) - .spawn().unwrap(); - p.stdin.as_mut().unwrap().write_all(b"test1\ntest2\ntest3").unwrap(); - let out = p.wait_with_output().unwrap(); - assert!(out.status.success()); - let s = str::from_utf8(&out.stdout).unwrap(); - assert_eq!(s, "test1\ntest2\ntest3\n"); -} - -fn child() { - let mut stdin = io::stdin(); - for line in stdin.lock().lines() { - println!("{}", line.unwrap()); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13323.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13323.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13323.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13323.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -struct StrWrap { - s: String -} - -impl StrWrap { - fn new(s: &str) -> StrWrap { - StrWrap { s: s.to_string() } - } - - fn get_s<'a>(&'a self) -> &'a str { - &self.s - } -} - -struct MyStruct { - s: StrWrap -} - -impl MyStruct { - fn new(s: &str) -> MyStruct { - MyStruct { s: StrWrap::new(s) } - } - - fn get_str_wrap<'a>(&'a self) -> &'a StrWrap { - &self.s - } -} - -trait Matcher { - fn matches(&self, actual: T) -> bool; -} - -fn assert_that>(actual: T, matcher: &U) { - assert!(matcher.matches(actual)); -} - -struct EqualTo { - expected: T -} - -impl Matcher for EqualTo { - fn matches(&self, actual: T) -> bool { - self.expected.eq(&actual) - } -} - -fn equal_to(expected: T) -> Box> { - box EqualTo { expected: expected } -} - -pub fn main() { - let my_struct = MyStruct::new("zomg"); - let s = my_struct.get_str_wrap(); - - assert_that(s.get_s(), &*equal_to("zomg")); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13405.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13405.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13405.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13405.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -struct Foo<'a> { - i: &'a bool, - j: Option<&'a isize>, -} - -impl<'a> Foo<'a> { - fn bar(&mut self, j: &isize) { - let child = Foo { - i: self.i, - j: Some(j) - }; - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13434.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13434.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13434.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13434.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Debug)] -struct MyStruct; - -trait Repro { - fn repro(self, s: MyStruct) -> String; -} - -impl Repro for F where F: FnOnce(MyStruct) -> String { - fn repro(self, s: MyStruct) -> String { - self(s) - } -} - -fn do_stuff(r: R) -> String { - r.repro(MyStruct) -} - -pub fn main() { - assert_eq!("MyStruct".to_string(), do_stuff(|s: MyStruct| format!("{:?}", s))); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13494.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13494.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13494.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13494.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -// This test may not always fail, but it can be flaky if the race it used to -// expose is still present. - -#![feature(mpsc_select)] - -use std::sync::mpsc::{channel, Sender, Receiver}; -use std::thread; - -fn helper(rx: Receiver>) { - for tx in rx.iter() { - let _ = tx.send(()); - } -} - -fn main() { - let (tx, rx) = channel(); - let t = thread::spawn(move|| { helper(rx) }); - let (snd, rcv) = channel::(); - for _ in 1..100000 { - snd.send(1).unwrap(); - let (tx2, rx2) = channel(); - tx.send(tx2).unwrap(); - select! { - _ = rx2.recv() => (), - _ = rcv.recv() => () - } - } - drop(tx); - t.join(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13507-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13507-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13507-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13507-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue13507.rs - -extern crate issue13507; -use issue13507::testtypes; - -use std::any::TypeId; - -pub fn type_ids() -> Vec { - use issue13507::testtypes::*; - vec![ - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::(), - TypeId::of::() - ] -} - -pub fn main() { - let othercrate = issue13507::testtypes::type_ids(); - let thiscrate = type_ids(); - assert_eq!(thiscrate, othercrate); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13620.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13620.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13620.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13620.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-13620-1.rs -// aux-build:issue-13620-2.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_13620_2 as crate2; - -fn main() { - (crate2::FOO2.foo)(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13655.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13655.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13655.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13655.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(fn_traits, unboxed_closures)] -use std::ops::Fn; - -struct Foo(T); - -impl Fn<()> for Foo { - extern "rust-call" fn call(&self, _: ()) -> T { - match *self { - Foo(t) => t - } - } -} - -impl FnMut<()> for Foo { - extern "rust-call" fn call_mut(&mut self, _: ()) -> T { - self.call(()) - } -} - -impl FnOnce<()> for Foo { - type Output = T; - - extern "rust-call" fn call_once(self, _: ()) -> T { - self.call(()) - } -} - -fn main() { - let t: u8 = 1; - println!("{}", Foo(t)()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13665.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13665.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13665.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13665.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn foo<'r>() { - let maybe_value_ref: Option<&'r u8> = None; - - let _ = maybe_value_ref.map(|& ref v| v); - let _ = maybe_value_ref.map(|& ref v| -> &'r u8 {v}); - let _ = maybe_value_ref.map(|& ref v: &'r u8| -> &'r u8 {v}); - let _ = maybe_value_ref.map(|& ref v: &'r u8| {v}); -} - -fn main() { - foo(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13703.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13703.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13703.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13703.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub struct Foo<'a, 'b: 'a> { foo: &'a &'b isize } -pub fn foo<'a, 'b>(x: Foo<'a, 'b>, _o: Option<& & ()>) { let _y = x.foo; } -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13763.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13763.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13763.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13763.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -mod u8 { - pub const BITS: usize = 8; -} - -const NUM: usize = u8::BITS; - -struct MyStruct { nums: [usize; 8] } - -fn main() { - let _s = MyStruct { nums: [0; NUM] }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13775.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13775.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13775.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13775.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait Foo { - #[allow(anonymous_parameters)] - fn bar(&self, isize) {} -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13808.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13808.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13808.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13808.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -struct Foo<'a> { - listener: Box, -} - -impl<'a> Foo<'a> { - fn new(listener: F) -> Foo<'a> where F: FnMut() + 'a { - Foo { listener: Box::new(listener) } - } -} - -fn main() { - let a = Foo::new(|| {}); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13837.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13837.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13837.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13837.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -struct TestStruct { - x: *const [isize; 2] -} - -unsafe impl Sync for TestStruct {} - -static TEST_VALUE : TestStruct = TestStruct{x: 0x1234 as *const [isize; 2]}; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13867.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13867.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13867.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13867.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that codegen works correctly when there are multiple refutable -// patterns in match expression. - - -enum Foo { - FooUint(usize), - FooNullary, -} - -fn main() { - let r = match (Foo::FooNullary, 'a') { - (Foo::FooUint(..), 'a'..='z') => 1, - (Foo::FooNullary, 'x') => 2, - _ => 0 - }; - assert_eq!(r, 0); - - let r = match (Foo::FooUint(0), 'a') { - (Foo::FooUint(1), 'a'..='z') => 1, - (Foo::FooUint(..), 'x') => 2, - (Foo::FooNullary, 'a') => 3, - _ => 0 - }; - assert_eq!(r, 0); - - let r = match ('a', Foo::FooUint(0)) { - ('a'..='z', Foo::FooUint(1)) => 1, - ('x', Foo::FooUint(..)) => 2, - ('a', Foo::FooNullary) => 3, - _ => 0 - }; - assert_eq!(r, 0); - - let r = match ('a', 'a') { - ('a'..='z', 'b') => 1, - ('x', 'a'..='z') => 2, - _ => 0 - }; - assert_eq!(r, 0); - - let r = match ('a', 'a') { - ('a'..='z', 'b') => 1, - ('x', 'a'..='z') => 2, - ('a', 'a') => 3, - _ => 0 - }; - assert_eq!(r, 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13872.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13872.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13872.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13872.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-13872-1.rs -// aux-build:issue-13872-2.rs -// aux-build:issue-13872-3.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_13872_3 as other; - -fn main() { - other::foo(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13902.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13902.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13902.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-13902.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -const JSVAL_TAG_CLEAR: u32 = 0xFFFFFF80; -const JSVAL_TYPE_INT32: u8 = 0x01; -const JSVAL_TYPE_UNDEFINED: u8 = 0x02; -#[repr(u32)] -enum ValueTag { - JSVAL_TAG_INT32 = JSVAL_TAG_CLEAR | (JSVAL_TYPE_INT32 as u32), - JSVAL_TAG_UNDEFINED = JSVAL_TAG_CLEAR | (JSVAL_TYPE_UNDEFINED as u32), -} - -fn main() { - let _ = ValueTag::JSVAL_TAG_INT32; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14082.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14082.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14082.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14082.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![allow(unused_imports, dead_code)] - -use foo::Foo; - -mod foo { - pub use m::Foo; // this should shadow d::Foo -} - -mod m { - pub struct Foo; -} - -mod d { - pub struct Foo; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14229.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14229.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14229.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14229.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Foo: Sized { - fn foo(self) {} -} - -trait Bar: Sized { - fn bar(self) {} -} - -struct S; - -impl<'l> Foo for &'l S {} - -impl Bar for T {} - -fn main() { - let s = S; - s.foo(); - (&s).bar(); - s.bar(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14254.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14254.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14254.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14254.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait Foo: Sized { - fn bar(&self); - fn baz(&self) { } - fn bah(_: Option) { } -} - -struct BarTy { - x : isize, - y : f64, -} - -impl BarTy { - fn a() {} - fn b(&self) {} -} - -// If these fail, it's necessary to update rustc_resolve and the cfail tests. -impl Foo for *const BarTy { - fn bar(&self) { - self.baz(); - BarTy::a(); - Foo::bah(None::<*const BarTy>); - } -} - -// If these fail, it's necessary to update rustc_resolve and the cfail tests. -impl<'a> Foo for &'a BarTy { - fn bar(&self) { - self.baz(); - self.x; - self.y; - BarTy::a(); - Foo::bah(None::<&BarTy>); - self.b(); - } -} - -// If these fail, it's necessary to update rustc_resolve and the cfail tests. -impl<'a> Foo for &'a mut BarTy { - fn bar(&self) { - self.baz(); - self.x; - self.y; - BarTy::a(); - Foo::bah(None::<&mut BarTy>); - self.b(); - } -} - -// If these fail, it's necessary to update rustc_resolve and the cfail tests. -impl Foo for Box { - fn bar(&self) { - self.baz(); - Foo::bah(None::>); - } -} - -// If these fail, it's necessary to update rustc_resolve and the cfail tests. -impl Foo for *const isize { - fn bar(&self) { - self.baz(); - Foo::bah(None::<*const isize>); - } -} - -// If these fail, it's necessary to update rustc_resolve and the cfail tests. -impl<'a> Foo for &'a isize { - fn bar(&self) { - self.baz(); - Foo::bah(None::<&isize>); - } -} - -// If these fail, it's necessary to update rustc_resolve and the cfail tests. -impl<'a> Foo for &'a mut isize { - fn bar(&self) { - self.baz(); - Foo::bah(None::<&mut isize>); - } -} - -// If these fail, it's necessary to update rustc_resolve and the cfail tests. -impl Foo for Box { - fn bar(&self) { - self.baz(); - Foo::bah(None::>); - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14308.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14308.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14308.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14308.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct A(isize); - -fn main() { - let x = match A(3) { - A(..) => 1 - }; - assert_eq!(x, 1); - let x = match A(4) { - A(1) => 1, - A(..) => 2 - }; - assert_eq!(x, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14330.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14330.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14330.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14330.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#[macro_use] extern crate std as std2; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14344.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14344.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14344.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14344.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-14344-1.rs -// aux-build:issue-14344-2.rs - -extern crate issue_14344_1; -extern crate issue_14344_2; - -fn main() { - issue_14344_1::foo(); - issue_14344_2::bar(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14382.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14382.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14382.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14382.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Debug)] -struct Matrix4(S); -trait POrd {} - -fn translate>(s: S) -> Matrix4 { Matrix4(s) } - -impl POrd for f32 {} -impl POrd for f64 {} - -fn main() { - let x = 1.0; - let m : Matrix4 = translate(x); - println!("m: {:?}", m); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14393.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14393.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14393.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14393.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn main() { - match ("", 1_usize) { - (_, 42_usize) => (), - ("", _) => (), - _ => () - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14399.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14399.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14399.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14399.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// #14399 -// We'd previously ICE if we had a method call whose return -// value was coerced to a trait object. (v.clone() returns Box -// which is coerced to Box). - -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - -#[derive(Clone)] -struct B1; - -trait A { fn foo(&self) {} } -impl A for B1 {} - -fn main() { - let v: Box<_> = box B1; - let _c: Box = v.clone(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14421.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14421.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14421.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14421.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_snake_case)] - -// aux-build:issue-14421.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_14421 as bug_lib; - -use bug_lib::B; -use bug_lib::make; - -pub fn main() { - let mut an_A: B = make(); - an_A.foo(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14422.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14422.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14422.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14422.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_snake_case)] - -// aux-build:issue-14422.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_14422 as bug_lib; - -use bug_lib::B; -use bug_lib::make; - -pub fn main() { - let mut an_A: B = make(); - an_A.foo(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14456.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14456.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14456.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14456.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-cloudabi no processes -// ignore-emscripten no processes - -use std::env; -use std::io::prelude::*; -use std::io; -use std::process::{Command, Stdio}; - -fn main() { - let args: Vec = env::args().collect(); - if args.len() > 1 && args[1] == "child" { - return child() - } - - test(); -} - -fn child() { - writeln!(&mut io::stdout(), "foo").unwrap(); - writeln!(&mut io::stderr(), "bar").unwrap(); - let mut stdin = io::stdin(); - let mut s = String::new(); - stdin.lock().read_line(&mut s).unwrap(); - assert_eq!(s.len(), 0); -} - -fn test() { - let args: Vec = env::args().collect(); - let mut p = Command::new(&args[0]).arg("child") - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .spawn().unwrap(); - assert!(p.wait().unwrap().success()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1451.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1451.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1451.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1451.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 -#![allow(non_snake_case)] -#![allow(unused_variables)] - -struct T { f: extern "Rust" fn() } -struct S { f: extern "Rust" fn() } - -fn fooS(t: S) { -} - -fn fooT(t: T) { -} - -fn bar() { -} - -pub fn main() { - let x: extern "Rust" fn() = bar; - fooS(S {f: x}); - fooS(S {f: bar}); - - let x: extern "Rust" fn() = bar; - fooT(T {f: x}); - fooT(T {f: bar}); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14589.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14589.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14589.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14589.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// All 3 expressions should work in that the argument gets -// coerced to a trait object - -// pretty-expanded FIXME #23616 - -fn main() { - send::>(Box::new(Output(0))); - Test::>::foo(Box::new(Output(0))); - Test::>::new().send(Box::new(Output(0))); -} - -fn send(_: T) {} - -struct Test { marker: std::marker::PhantomData } -impl Test { - fn new() -> Test { Test { marker: ::std::marker::PhantomData } } - fn foo(_: T) {} - fn send(&self, _: T) {} -} - -trait Foo { fn dummy(&self) { }} -struct Output(isize); -impl Foo for Output {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1460.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1460.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1460.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1460.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// pretty-expanded FIXME #23616 - -pub fn main() { - {|i: u32| if 1 == i { }}; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14821.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14821.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14821.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14821.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait SomeTrait {} -struct Meow; -impl SomeTrait for Meow {} - -struct Foo<'a> { - x: &'a SomeTrait, - y: &'a SomeTrait, -} - -impl<'a> Foo<'a> { - pub fn new<'b>(x: &'b SomeTrait, y: &'b SomeTrait) -> Foo<'b> { Foo { x: x, y: y } } -} - -fn main() { - let r = Meow; - let s = Meow; - let q = Foo::new(&r as &SomeTrait, &s as &SomeTrait); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14837.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14837.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14837.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14837.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#[deny(dead_code)] -pub enum Foo { - Bar { - baz: isize - } -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14865.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14865.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14865.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14865.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum X { - Foo(usize), - Bar(bool) -} - -fn main() { - let x = match X::Foo(42) { - X::Foo(..) => 1, - _ if true => 0, - X::Bar(..) => panic!("Oh dear") - }; - assert_eq!(x, 1); - - let x = match X::Foo(42) { - _ if true => 0, - X::Foo(..) => 1, - X::Bar(..) => panic!("Oh dear") - }; - assert_eq!(x, 0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14875.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14875.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14875.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14875.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare always compiled as panic=abort right now - -// Check that values are not leaked when a dtor panics (#14875) - -use std::panic::{self, UnwindSafe}; - -struct SetInnerOnDrop<'a>(&'a mut bool); - -impl<'a> UnwindSafe for SetInnerOnDrop<'a> {} - -impl<'a> Drop for SetInnerOnDrop<'a> { - fn drop(&mut self) { - *self.0 = true; - } -} - -struct PanicOnDrop; -impl Drop for PanicOnDrop { - fn drop(&mut self) { - panic!("test panic"); - } -} - -fn main() { - let mut set_on_drop = false; - { - let set_inner_on_drop = SetInnerOnDrop(&mut set_on_drop); - let _ = panic::catch_unwind(|| { - let _set_inner_on_drop = set_inner_on_drop; - let _panic_on_drop = PanicOnDrop; - }); - } - assert!(set_on_drop); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14901.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14901.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14901.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14901.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub trait Reader {} - -enum Wrapper<'a> { - WrapReader(&'a (Reader + 'a)) -} - -trait Wrap<'a> { - fn wrap(self) -> Wrapper<'a>; -} - -impl<'a, R: Reader> Wrap<'a> for &'a mut R { - fn wrap(self) -> Wrapper<'a> { - Wrapper::WrapReader(self as &'a mut Reader) - } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14919.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14919.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14919.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14919.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait Matcher { - fn next_match(&mut self) -> Option<(usize, usize)>; -} - -struct CharPredMatcher<'a, 'b> { - str: &'a str, - pred: Box bool + 'b>, -} - -impl<'a, 'b> Matcher for CharPredMatcher<'a, 'b> { - fn next_match(&mut self) -> Option<(usize, usize)> { - None - } -} - -trait IntoMatcher<'a, T> { - fn into_matcher(self, _: &'a str) -> T; -} - -impl<'a, 'b, F> IntoMatcher<'a, CharPredMatcher<'a, 'b>> for F where F: FnMut(char) -> bool + 'b { - fn into_matcher(self, s: &'a str) -> CharPredMatcher<'a, 'b> { - CharPredMatcher { - str: s, - pred: Box::new(self), - } - } -} - -struct MatchIndices { - matcher: M -} - -impl Iterator for MatchIndices { - type Item = (usize, usize); - - fn next(&mut self) -> Option<(usize, usize)> { - self.matcher.next_match() - } -} - -fn match_indices<'a, M, T: IntoMatcher<'a, M>>(s: &'a str, from: T) -> MatchIndices { - let string_matcher = from.into_matcher(s); - MatchIndices { matcher: string_matcher } -} - -fn main() { - let s = "abcbdef"; - match_indices(s, |c: char| c == 'b') - .collect::>(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14933.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14933.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14933.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14933.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub type BigRat = T; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14936.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14936.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14936.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14936.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(asm)] - -type History = Vec<&'static str>; - -fn wrap(x:A, which: &'static str, history: &mut History) -> A { - history.push(which); - x -} - -macro_rules! demo { - ( $output_constraint:tt ) => { - { - let mut x: isize = 0; - let y: isize = 1; - - let mut history: History = vec![]; - unsafe { - asm!("mov ($1), $0" - : $output_constraint (*wrap(&mut x, "out", &mut history)) - : "r"(&wrap(y, "in", &mut history)) - :: "volatile"); - } - assert_eq!((x,y), (1,1)); - let b: &[_] = &["out", "in"]; - assert_eq!(history, b); - } - } -} - -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -fn main() { - fn out_write_only_expr_then_in_expr() { - demo!("=r") - } - - fn out_read_write_expr_then_in_expr() { - demo!("+r") - } - - out_write_only_expr_then_in_expr(); - out_read_write_expr_then_in_expr(); -} - -#[cfg(all(not(target_arch = "x86"), not(target_arch = "x86_64")))] -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14940.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14940.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14940.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14940.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-cloudabi no processes -// ignore-emscripten no processes - -use std::env; -use std::process::Command; -use std::io::{self, Write}; - -fn main() { - let mut args = env::args(); - if args.len() > 1 { - let mut out = io::stdout(); - out.write(&['a' as u8; 128 * 1024]).unwrap(); - } else { - let out = Command::new(&args.next().unwrap()).arg("child").output(); - let out = out.unwrap(); - assert!(out.status.success()); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14958.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14958.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14958.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14958.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(fn_traits, unboxed_closures)] - -trait Foo { fn dummy(&self) { }} - -struct Bar; - -impl<'a> std::ops::Fn<(&'a (Foo+'a),)> for Bar { - extern "rust-call" fn call(&self, _: (&'a Foo,)) {} -} - -impl<'a> std::ops::FnMut<(&'a (Foo+'a),)> for Bar { - extern "rust-call" fn call_mut(&mut self, a: (&'a Foo,)) { self.call(a) } -} - -impl<'a> std::ops::FnOnce<(&'a (Foo+'a),)> for Bar { - type Output = (); - extern "rust-call" fn call_once(self, a: (&'a Foo,)) { self.call(a) } -} - -struct Baz; - -impl Foo for Baz {} - -fn main() { - let bar = Bar; - let baz = &Baz; - bar(baz); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14959.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14959.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14959.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-14959.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(fn_traits, unboxed_closures)] - -use std::ops::Fn; - -trait Response { fn dummy(&self) { } } -trait Request { fn dummy(&self) { } } -trait Ingot { - fn enter(&mut self, _: &mut R, _: &mut S, a: &mut Alloy) -> Status; -} - -#[allow(dead_code)] -struct HelloWorld; - -struct SendFile; -struct Alloy; -enum Status { - Continue -} - -impl Alloy { - fn find(&self) -> Option { - None - } -} - -impl<'b> Fn<(&'b mut (Response+'b),)> for SendFile { - extern "rust-call" fn call(&self, (_res,): (&'b mut (Response+'b),)) {} -} - -impl<'b> FnMut<(&'b mut (Response+'b),)> for SendFile { - extern "rust-call" fn call_mut(&mut self, (_res,): (&'b mut (Response+'b),)) { - self.call((_res,)) - } -} - -impl<'b> FnOnce<(&'b mut (Response+'b),)> for SendFile { - type Output = (); - - extern "rust-call" fn call_once(self, (_res,): (&'b mut (Response+'b),)) { - self.call((_res,)) - } -} - -impl Ingot for HelloWorld { - fn enter(&mut self, _req: &mut Rq, res: &mut Rs, alloy: &mut Alloy) -> Status { - let send_file = alloy.find::().unwrap(); - send_file(res); - Status::Continue - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15043.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15043.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15043.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15043.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![allow(warnings)] - -struct S(T); - -static s1: S>=S(S(0)); -static s2: S=S(0); - -fn main() { - let foo: S>=S(S(0)); - let foo: S=S(0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15063.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15063.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15063.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15063.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -enum Two { A, B} -impl Drop for Two { - fn drop(&mut self) { - println!("Dropping!"); - } -} -fn main() { - let k = Two::A; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15080.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15080.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15080.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15080.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(slice_patterns)] - -fn main() { - let mut x: &[_] = &[1, 2, 3, 4]; - - let mut result = vec![]; - loop { - x = match *x { - [1, n, 3, ref rest..] => { - result.push(n); - rest - } - [n, ref rest..] => { - result.push(n); - rest - } - [] => - break - } - } - assert_eq!(result, [2, 4]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15104.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15104.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15104.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15104.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(slice_patterns)] - -fn main() { - assert_eq!(count_members(&[1, 2, 3, 4]), 4); -} - -fn count_members(v: &[usize]) -> usize { - match *v { - [] => 0, - [_] => 1, - [_, ref xs..] => 1 + count_members(xs) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15108.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15108.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15108.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15108.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15129.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15129.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15129.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15129.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub enum T { - T1(()), - T2(()) -} - -pub enum V { - V1(isize), - V2(bool) -} - -fn foo(x: (T, V)) -> String { - match x { - (T::T1(()), V::V1(i)) => format!("T1(()), V1({})", i), - (T::T2(()), V::V2(b)) => format!("T2(()), V2({})", b), - _ => String::new() - } -} - - -fn main() { - assert_eq!(foo((T::T1(()), V::V1(99))), "T1(()), V1(99)".to_string()); - assert_eq!(foo((T::T2(()), V::V2(true))), "T2(()), V2(true)".to_string()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15155.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15155.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15155.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15155.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait TraitWithSend: Send {} -trait IndirectTraitWithSend: TraitWithSend {} - -// Check struct instantiation (Box will only have Send if TraitWithSend has Send) -#[allow(dead_code)] -struct Blah { x: Box } -impl TraitWithSend for Blah {} - -// Struct instantiation 2-levels deep -#[allow(dead_code)] -struct IndirectBlah { x: Box } -impl TraitWithSend for IndirectBlah {} -impl IndirectTraitWithSend for IndirectBlah {} - -fn test_trait() { println!("got here!") } - -fn main() { - test_trait::(); - test_trait::(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15189.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15189.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15189.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15189.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! third { - ($e:expr) => ({let x = 2; $e[x]}) -} - -fn main() { - let x = vec![10_usize,11_usize,12_usize,13_usize]; - let t = third!(x); - assert_eq!(t,12_usize); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15221.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15221.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15221.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15221.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -macro_rules! inner { - ($e:pat ) => ($e) -} - -macro_rules! outer { - ($e:pat ) => (inner!($e)) -} - -fn main() { - let outer!(g1) = 13; - g1; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15261.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15261.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15261.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15261.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -// pretty-expanded FIXME #23616 - -static mut n_mut: usize = 0; - -static n: &'static usize = unsafe{ &n_mut }; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15444.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15444.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15444.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15444.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait MyTrait { - fn foo(&self); -} - -impl MyTrait for fn(A, B) -> C { - fn foo(&self) {} -} - -fn bar(t: &T) { - t.foo() -} - -fn thing(a: isize, b: isize) -> isize { - a + b -} - -fn main() { - let thing: fn(isize, isize) -> isize = thing; // coerce to fn type - bar(&thing); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15487.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15487.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15487.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15487.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-windows -// ignore-wasm32-bare no libs to link - -#![feature(link_args)] - -#[link_args="-lc -lm"] -#[link_args=" -lc"] -#[link_args="-lc "] -extern {} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15523-big.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15523-big.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15523-big.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15523-big.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue 15523: derive(PartialOrd) should use the provided -// discriminant values for the derived ordering. -// -// This test is checking corner cases that arise when you have -// 64-bit values in the variants. - -#[derive(PartialEq, PartialOrd)] -#[repr(u64)] -enum Eu64 { - Pos2 = 2, - PosMax = !0, - Pos1 = 1, -} - -#[derive(PartialEq, PartialOrd)] -#[repr(i64)] -enum Ei64 { - Pos2 = 2, - Neg1 = -1, - NegMin = 1 << 63, - PosMax = !(1 << 63), - Pos1 = 1, -} - -fn main() { - assert!(Eu64::Pos2 > Eu64::Pos1); - assert!(Eu64::Pos2 < Eu64::PosMax); - assert!(Eu64::Pos1 < Eu64::PosMax); - - - assert!(Ei64::Pos2 > Ei64::Pos1); - assert!(Ei64::Pos2 > Ei64::Neg1); - assert!(Ei64::Pos1 > Ei64::Neg1); - assert!(Ei64::Pos2 > Ei64::NegMin); - assert!(Ei64::Pos1 > Ei64::NegMin); - assert!(Ei64::Pos2 < Ei64::PosMax); - assert!(Ei64::Pos1 < Ei64::PosMax); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15523.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15523.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15523.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15523.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue 15523: derive(PartialOrd) should use the provided -// discriminant values for the derived ordering. -// -// This is checking the basic functionality. - -#[derive(PartialEq, PartialOrd)] -enum E1 { - Pos2 = 2, - Neg1 = -1, - Pos1 = 1, -} - -#[derive(PartialEq, PartialOrd)] -#[repr(u8)] -enum E2 { - Pos2 = 2, - PosMax = !0 as u8, - Pos1 = 1, -} - -#[derive(PartialEq, PartialOrd)] -#[repr(i8)] -enum E3 { - Pos2 = 2, - Neg1 = -1_i8, - Pos1 = 1, -} - -fn main() { - assert!(E1::Pos2 > E1::Pos1); - assert!(E1::Pos1 > E1::Neg1); - assert!(E1::Pos2 > E1::Neg1); - - assert!(E2::Pos2 > E2::Pos1); - assert!(E2::Pos1 < E2::PosMax); - assert!(E2::Pos2 < E2::PosMax); - - assert!(E3::Pos2 > E3::Pos1); - assert!(E3::Pos1 > E3::Neg1); - assert!(E3::Pos2 > E3::Neg1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15562.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15562.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15562.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15562.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-15562.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_15562 as i; - -pub fn main() { - unsafe { - transmute(); - i::transmute(); - } -} - -// We declare this so we don't run into unresolved symbol errors -// The above extern is NOT `extern "rust-intrinsic"` and thus -// means it'll try to find a corresponding symbol to link to. -#[no_mangle] -pub extern fn transmute() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15571.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15571.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15571.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15571.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -fn match_on_local() { - let mut foo: Option> = Some(box 5); - match foo { - None => {}, - Some(x) => { - foo = Some(x); - } - } - println!("'{}'", foo.unwrap()); -} - -fn match_on_arg(mut foo: Option>) { - match foo { - None => {} - Some(x) => { - foo = Some(x); - } - } - println!("'{}'", foo.unwrap()); -} - -fn match_on_binding() { - match Some(Box::new(7)) { - mut foo => { - match foo { - None => {}, - Some(x) => { - foo = Some(x); - } - } - println!("'{}'", foo.unwrap()); - } - } -} - -fn match_on_upvar() { - let mut foo: Option> = Some(box 8); - let f = move|| { - match foo { - None => {}, - Some(x) => { - foo = Some(x); - } - } - println!("'{}'", foo.unwrap()); - }; - f(); -} - -fn main() { - match_on_local(); - match_on_arg(Some(box 6)); - match_on_binding(); - match_on_upvar(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15673.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15673.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15673.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15673.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -#![feature(iter_arith)] - -fn main() { - let x: [u64; 3] = [1, 2, 3]; - assert_eq!(6, (0..3).map(|i| x[i]).sum::()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15689-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15689-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15689-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15689-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#[derive(PartialEq, Debug)] -enum Test<'a> { - Slice(&'a isize) -} - -fn main() { - assert_eq!(Test::Slice(&1), Test::Slice(&1)) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15689-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15689-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15689-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15689-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#[derive(Clone)] -enum Test<'a> { - Slice(&'a isize) -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15730.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15730.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15730.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15730.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn main() { - let mut array = [1, 2, 3]; - let pie_slice = &array[1..2]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15734.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15734.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15734.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15734.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// If `Index` used an associated type for its output, this test would -// work more smoothly. - -use std::ops::Index; - -struct Mat { data: Vec, cols: usize, } - -impl Mat { - fn new(data: Vec, cols: usize) -> Mat { - Mat { data: data, cols: cols } - } - fn row<'a>(&'a self, row: usize) -> Row<&'a Mat> { - Row { mat: self, row: row, } - } -} - -impl Index<(usize, usize)> for Mat { - type Output = T; - - fn index<'a>(&'a self, (row, col): (usize, usize)) -> &'a T { - &self.data[row * self.cols + col] - } -} - -impl<'a, T> Index<(usize, usize)> for &'a Mat { - type Output = T; - - fn index<'b>(&'b self, index: (usize, usize)) -> &'b T { - (*self).index(index) - } -} - -struct Row { mat: M, row: usize, } - -impl> Index for Row { - type Output = T; - - fn index<'a>(&'a self, col: usize) -> &'a T { - &self.mat[(self.row, col)] - } -} - -fn main() { - let m = Mat::new(vec![1, 2, 3, 4, 5, 6], 3); - let r = m.row(1); - - assert_eq!(r.index(2), &6); - assert_eq!(r[2], 6); - assert_eq!(r[2], 6); - assert_eq!(6, r[2]); - - let e = r[2]; - assert_eq!(e, 6); - - let e: usize = r[2]; - assert_eq!(e, 6); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15735.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15735.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15735.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15735.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct A<'a> { - a: &'a i32, - b: &'a i32, -} - -impl <'a> A<'a> { - fn foo<'b>(&'b self) { - A { - a: self.a, - b: self.b, - }; - } -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15763.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15763.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15763.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15763.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -#[derive(PartialEq, Debug)] -struct Bar { - x: isize -} -impl Drop for Bar { - fn drop(&mut self) { - assert_eq!(self.x, 22); - } -} - -#[derive(PartialEq, Debug)] -struct Foo { - x: Bar, - a: isize -} - -fn foo() -> Result { - return Ok(Foo { - x: Bar { x: 22 }, - a: return Err(32) - }); -} - -fn baz() -> Result { - Ok(Foo { - x: Bar { x: 22 }, - a: return Err(32) - }) -} - -// explicit immediate return -fn aa() -> isize { - return 3; -} - -// implicit immediate return -fn bb() -> isize { - 3 -} - -// implicit outptr return -fn cc() -> Result { - Ok(3) -} - -// explicit outptr return -fn dd() -> Result { - return Ok(3); -} - -trait A { - fn aaa(&self) -> isize { - 3 - } - fn bbb(&self) -> isize { - return 3; - } - fn ccc(&self) -> Result { - Ok(3) - } - fn ddd(&self) -> Result { - return Ok(3); - } -} - -impl A for isize {} - -fn main() { - assert_eq!(foo(), Err(32)); - assert_eq!(baz(), Err(32)); - - assert_eq!(aa(), 3); - assert_eq!(bb(), 3); - assert_eq!(cc().unwrap(), 3); - assert_eq!(dd().unwrap(), 3); - - let i = box 32isize as Box; - assert_eq!(i.aaa(), 3); - let i = box 32isize as Box; - assert_eq!(i.bbb(), 3); - let i = box 32isize as Box; - assert_eq!(i.ccc().unwrap(), 3); - let i = box 32isize as Box; - assert_eq!(i.ddd().unwrap(), 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15774.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15774.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15774.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15774.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![deny(warnings)] -#![allow(unused_imports)] - -pub enum Foo { A } -mod bar { - pub fn normal(x: ::Foo) { - use Foo::A; - match x { - A => {} - } - } - pub fn wrong(x: ::Foo) { - match x { - ::Foo::A => {} - } - } -} - -pub fn main() { - bar::normal(Foo::A); - bar::wrong(Foo::A); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15793.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15793.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15793.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15793.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum NestedEnum { - First, - Second, - Third -} -enum Enum { - Variant1(bool), - Variant2(NestedEnum) -} - -#[inline(never)] -fn foo(x: Enum) -> isize { - match x { - Enum::Variant1(true) => 1, - Enum::Variant1(false) => 2, - Enum::Variant2(NestedEnum::Second) => 3, - Enum::Variant2(NestedEnum::Third) => 4, - Enum::Variant2(NestedEnum::First) => 5 - } -} - -fn main() { - assert_eq!(foo(Enum::Variant2(NestedEnum::Third)), 4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15858.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15858.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15858.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15858.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -static mut DROP_RAN: bool = false; - -trait Bar { - fn do_something(&mut self); -} - -struct BarImpl; - -impl Bar for BarImpl { - fn do_something(&mut self) {} -} - - -struct Foo(B); - -impl Drop for Foo { - fn drop(&mut self) { - unsafe { - DROP_RAN = true; - } - } -} - - -fn main() { - { - let _x: Foo = Foo(BarImpl); - } - unsafe { - assert_eq!(DROP_RAN, true); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15881-model-lexer-dotdotdot.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15881-model-lexer-dotdotdot.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15881-model-lexer-dotdotdot.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-15881-model-lexer-dotdotdot.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(illegal_floating_point_literal_pattern)] // FIXME #41620 - -// regression test for the model lexer handling the DOTDOTDOT syntax (#15877) - - -pub fn main() { - match 5_usize { - 1_usize...5_usize => {} - _ => panic!("should match range"), - } - match 5_usize { - 6_usize...7_usize => panic!("shouldn't match range"), - _ => {} - } - match 5_usize { - 1_usize => panic!("should match non-first range"), - 2_usize...6_usize => {} - _ => panic!("math is broken") - } - match 'c' { - 'a'...'z' => {} - _ => panic!("should support char ranges") - } - match -3_isize { - -7...5 => {} - _ => panic!("should match signed range") - } - match 3.0f64 { - 1.0...5.0 => {} - _ => panic!("should match float range") - } - match -1.5f64 { - -3.6...3.6 => {} - _ => panic!("should match negative float range") - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16151.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16151.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16151.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16151.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::mem; - -static mut DROP_COUNT: usize = 0; - -struct Fragment; - -impl Drop for Fragment { - fn drop(&mut self) { - unsafe { - DROP_COUNT += 1; - } - } -} - -fn main() { - { - let mut fragments = vec![Fragment, Fragment, Fragment]; - let _new_fragments: Vec = mem::replace(&mut fragments, vec![]) - .into_iter() - .skip_while(|_fragment| { - true - }).collect(); - } - unsafe { - assert_eq!(DROP_COUNT, 3); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16256.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16256.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16256.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16256.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn main() { - let mut buf = Vec::new(); - |c: u8| buf.push(c); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16272.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16272.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16272.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16272.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-cloudabi no processes -// ignore-emscripten no processes - -use std::process::Command; -use std::env; - -fn main() { - let len = env::args().len(); - - if len == 1 { - test(); - } else { - assert_eq!(len, 3); - } -} - -fn test() { - let status = Command::new(&env::current_exe().unwrap()) - .arg("foo").arg("") - .status().unwrap(); - assert!(status.success()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16278.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16278.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16278.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16278.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-tidy-cr - -// this file has some special \r\n endings (use xxd to see them) - -fn main() {assert_eq!(b"", b"\ - "); -assert_eq!(b"\n", b" -"); -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16441.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16441.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16441.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16441.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -struct Empty; - -// This used to cause an ICE -extern "C" fn ice(_a: Empty) {} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16452.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16452.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16452.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16452.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn main() { - if true { return } - match () { - () => { static MAGIC: usize = 0; } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16492.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16492.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16492.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16492.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_snake_case)] - -use std::rc::Rc; -use std::cell::Cell; - -struct Field { - number: usize, - state: Rc> -} - -impl Field { - fn new(number: usize, state: Rc>) -> Field { - Field { - number: number, - state: state - } - } -} - -impl Drop for Field { - fn drop(&mut self) { - println!("Dropping field {}", self.number); - assert_eq!(self.state.get(), self.number); - self.state.set(self.state.get()+1); - } -} - -struct NoDropImpl { - _one: Field, - _two: Field, - _three: Field -} - -struct HasDropImpl { - _one: Field, - _two: Field, - _three: Field -} - -impl Drop for HasDropImpl { - fn drop(&mut self) { - println!("HasDropImpl.drop()"); - assert_eq!(self._one.state.get(), 0); - self._one.state.set(1); - } -} - -pub fn main() { - let state = Rc::new(Cell::new(1)); - let noImpl = NoDropImpl { - _one: Field::new(1, state.clone()), - _two: Field::new(2, state.clone()), - _three: Field::new(3, state.clone()) - }; - drop(noImpl); - assert_eq!(state.get(), 4); - - state.set(0); - let hasImpl = HasDropImpl { - _one: Field::new(1, state.clone()), - _two: Field::new(2, state.clone()), - _three: Field::new(3, state.clone()) - }; - drop(hasImpl); - assert_eq!(state.get(), 4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16530.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16530.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16530.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16530.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(deprecated)] - -use std::hash::{SipHasher, Hasher, Hash}; - -#[derive(Hash)] -struct Empty; - -pub fn main() { - let mut s1 = SipHasher::new_with_keys(0, 0); - Empty.hash(&mut s1); - let mut s2 = SipHasher::new_with_keys(0, 0); - Empty.hash(&mut s2); - assert_eq!(s1.finish(), s2.finish()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16560.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16560.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16560.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16560.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::thread; -use std::mem; - -fn main() { - let y = 0u8; - let closure = move |x: u8| y + x; - - // Check that both closures are capturing by value - assert_eq!(1, mem::size_of_val(&closure)); - - thread::spawn(move|| { - let ok = closure; - }).join().ok().unwrap(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16596.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16596.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16596.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16596.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait MatrixRow { fn dummy(&self) { }} - -struct Mat; - -impl<'a> MatrixRow for &'a Mat {} - -struct Rows { - mat: M, -} - -impl<'a> Iterator for Rows<&'a Mat> { - type Item = (); - - fn next(&mut self) -> Option<()> { - unimplemented!() - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16597-empty.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16597-empty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16597-empty.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16597-empty.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags:--test - -// This verifies that the test generation doesn't crash when we have -// no tests - for more information, see PR #16892. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16597.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16597.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16597.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16597.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags:--test - -mod tests { - use super::*; - - #[test] - pub fn test(){} -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16602-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16602-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16602-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16602-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - let mut t = [1; 2]; - t = [t[1] * 2, t[0] * 2]; - assert_eq!(&t[..], &[2, 2]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16602-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16602-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16602-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16602-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct A { - pub x: u32, - pub y: u32, -} - -fn main() { - let mut a = A { x: 1, y: 1 }; - a = A { x: a.y * 2, y: a.x * 2 }; - assert_eq!(a.x, 2); - assert_eq!(a.y, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16602-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16602-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16602-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16602-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Debug)] -enum Foo { - Bar(u32, u32), - Baz(&'static u32, &'static u32) -} - -static NUM: u32 = 100; - -fn main () { - let mut b = Foo::Baz(&NUM, &NUM); - b = Foo::Bar(f(&b), g(&b)); -} - -static FNUM: u32 = 1; - -fn f (b: &Foo) -> u32 { - FNUM -} - -static GNUM: u32 = 2; - -fn g (b: &Foo) -> u32 { - GNUM -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1660.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1660.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1660.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1660.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -// pretty-expanded FIXME #23616 - -pub fn main() { - static _x: isize = 1<<2; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16643.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16643.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16643.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16643.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-16643.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_16643 as i; - -pub fn main() { - i::TreeBuilder { h: 3 }.process_token(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16648.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16648.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16648.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16648.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - let x: (isize, &[isize]) = (2, &[1, 2]); - assert_eq!(match x { - (0, &[_, _]) => 0, - (1, _) => 1, - (2, &[_, _]) => 2, - (2, _) => 3, - _ => 4 - }, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16668.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16668.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16668.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16668.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct Parser<'a, I, O> { - parse: Box Result + 'a> -} - -impl<'a, I: 'a, O: 'a> Parser<'a, I, O> { - fn compose(mut self, mut rhs: Parser<'a, O, K>) -> Parser<'a, I, K> { - Parser { - parse: Box::new(move |x: I| { - match (self.parse)(x) { - Ok(r) => (rhs.parse)(r), - Err(e) => Err(e) - } - }) - } - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16671.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16671.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16671.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16671.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -//compile-flags: -Z borrowck=compare -Z emit-end-regions - -#![deny(warnings)] - -fn foo(_f: F) { } - -fn main() { - let mut var = Vec::new(); - foo(move|| { - var.push(1); - }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16739.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16739.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16739.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16739.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] -#![feature(unboxed_closures, fn_traits)] - -// Test that unboxing shim for calling rust-call ABI methods through a -// trait box works and does not cause an ICE. - -struct Foo { foo: u32 } - -impl FnMut<()> for Foo { - extern "rust-call" fn call_mut(&mut self, _: ()) -> u32 { self.foo } -} - -impl FnOnce<()> for Foo { - type Output = u32; - extern "rust-call" fn call_once(mut self, _: ()) -> u32 { self.call_mut(()) } -} - -///////////////////////////////////////////////////////////////////////// - -impl FnMut<(u32,)> for Foo { - extern "rust-call" fn call_mut(&mut self, (x,): (u32,)) -> u32 { self.foo + x } -} - -impl FnOnce<(u32,)> for Foo { - type Output = u32; - extern "rust-call" fn call_once(mut self, args: (u32,)) -> u32 { self.call_mut(args) } -} - -///////////////////////////////////////////////////////////////////////// - -impl FnMut<(u32,u32)> for Foo { - extern "rust-call" fn call_mut(&mut self, (x, y): (u32, u32)) -> u32 { self.foo + x + y } -} - -impl FnOnce<(u32,u32)> for Foo { - type Output = u32; - extern "rust-call" fn call_once(mut self, args: (u32,u32)) -> u32 { self.call_mut(args) } -} - -fn main() { - let mut f = box Foo { foo: 42 } as Box u32>; - assert_eq!(f.call_mut(()), 42); - - let mut f = box Foo { foo: 40 } as Box u32>; - assert_eq!(f.call_mut((2,)), 42); - - let mut f = box Foo { foo: 40 } as Box u32>; - assert_eq!(f.call_mut((1, 1)), 42); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16745.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16745.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16745.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16745.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - const X: u8 = 0; - let out: u8 = match 0u8 { - X => 99, - b'\t' => 1, - 1u8 => 2, - _ => 3, - }; - assert_eq!(out, 99); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16774.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16774.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16774.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16774.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] -#![feature(box_patterns)] - -use std::ops::{Deref, DerefMut}; - -struct X(Box); - -static mut DESTRUCTOR_RAN: bool = false; - -impl Drop for X { - fn drop(&mut self) { - unsafe { - assert!(!DESTRUCTOR_RAN); - DESTRUCTOR_RAN = true; - } - } -} - -impl Deref for X { - type Target = isize; - - fn deref(&self) -> &isize { - let &X(box ref x) = self; - x - } -} - -impl DerefMut for X { - fn deref_mut(&mut self) -> &mut isize { - let &mut X(box ref mut x) = self; - x - } -} - -fn main() { - { - let mut test = X(box 5); - { - let mut change = || { *test = 10 }; - change(); - } - assert_eq!(*test, 10); - } - assert!(unsafe { DESTRUCTOR_RAN }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16783.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16783.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16783.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16783.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub fn main() { - let x = [1, 2, 3]; - let y = x; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16819.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16819.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16819.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16819.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// `#[cfg]` on struct field permits empty unusable struct - -struct S { - #[cfg(untrue)] - a: int, -} - -fn main() { - let s = S {}; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16922.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16922.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16922.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-16922.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -use std::any::Any; - -fn foo(_: &u8) { -} - -fn main() { - let _ = &foo as &Any; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1696.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1696.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1696.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1696.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::collections::HashMap; - -pub fn main() { - let mut m = HashMap::new(); - m.insert(b"foo".to_vec(), b"bar".to_vec()); - println!("{:?}", m); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1701.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1701.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1701.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1701.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - -enum pattern { tabby, tortoiseshell, calico } -enum breed { beagle, rottweiler, pug } -type name = String; -enum ear_kind { lop, upright } -enum animal { cat(pattern), dog(breed), rabbit(name, ear_kind), tiger } - -fn noise(a: animal) -> Option { - match a { - animal::cat(..) => { Some("meow".to_string()) } - animal::dog(..) => { Some("woof".to_string()) } - animal::rabbit(..) => { None } - animal::tiger => { Some("roar".to_string()) } - } -} - -pub fn main() { - assert_eq!(noise(animal::cat(pattern::tabby)), Some("meow".to_string())); - assert_eq!(noise(animal::dog(breed::pug)), Some("woof".to_string())); - assert_eq!(noise(animal::rabbit("Hilbert".to_string(), ear_kind::upright)), None); - assert_eq!(noise(animal::tiger), Some("roar".to_string())); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17068.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17068.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17068.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17068.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that regionck creates the right region links in the pattern -// binding of a for loop - -fn foo<'a>(v: &'a [usize]) -> &'a usize { - for &ref x in v { return x; } - unreachable!() -} - -fn main() { - assert_eq!(foo(&[0]), &0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17074.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17074.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17074.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17074.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -static X2: u64 = !0 as u16 as u64; -static Y2: u64 = !0 as u32 as u64; -const X: u64 = !0 as u16 as u64; -const Y: u64 = !0 as u32 as u64; - -fn main() { - assert_eq!(match 1 { - X => unreachable!(), - Y => unreachable!(), - _ => 1 - }, 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17121.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17121.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17121.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17121.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 -// ignore-cloudabi no std::fs - -use std::fs::File; -use std::io::{self, BufReader, Read}; - -struct Lexer -{ - reader: BufReader, -} - -impl Lexer -{ - pub fn new_from_reader(r: R) -> Lexer - { - Lexer{reader: BufReader::new(r)} - } - - pub fn new_from_file(p: &str) -> io::Result> - { - Ok(Lexer::new_from_reader(File::open(p)?)) - } - - pub fn new_from_str<'a>(s: &'a str) -> Lexer<&'a [u8]> - { - Lexer::new_from_reader(s.as_bytes()) - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17170.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17170.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17170.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17170.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(repr_simd)] - -#[repr(simd)] -struct T(f64, f64, f64); - -static X: T = T(0.0, 0.0, 0.0); - -fn main() { - let _ = X; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17216.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17216.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17216.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17216.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct Leak<'a> { - dropped: &'a mut bool -} - -impl<'a> Drop for Leak<'a> { - fn drop(&mut self) { - *self.dropped = true; - } -} - -fn main() { - let mut dropped = false; - { - let leak = Leak { dropped: &mut dropped }; - for ((), leaked) in Some(((), leak)).into_iter() {} - } - - assert!(dropped); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17233.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17233.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17233.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17233.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -const X1: &'static [u8] = &[b'1']; -const X2: &'static [u8] = b"1"; -const X3: &'static [u8; 1] = &[b'1']; -const X4: &'static [u8; 1] = b"1"; - -static Y1: u8 = X1[0]; -static Y2: u8 = X2[0]; -static Y3: u8 = X3[0]; -static Y4: u8 = X4[0]; - -fn main() { - assert_eq!(Y1, Y2); - assert_eq!(Y1, Y3); - assert_eq!(Y1, Y4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17302.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17302.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17302.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17302.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -static mut DROPPED: [bool; 2] = [false, false]; - -struct A(usize); -struct Foo { _a: A, _b: isize } - -impl Drop for A { - fn drop(&mut self) { - let A(i) = *self; - unsafe { DROPPED[i] = true; } - } -} - -fn main() { - { - Foo { - _a: A(0), - ..Foo { _a: A(1), _b: 2 } - }; - } - unsafe { - assert!(DROPPED[0]); - assert!(DROPPED[1]); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17322.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17322.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17322.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17322.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - -use std::io::{self, Write}; - -fn f(wr: &mut Write) { - wr.write_all(b"hello").ok().expect("failed"); -} - -fn main() { - let mut wr = box io::stdout() as Box; - f(&mut wr); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17336.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17336.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17336.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17336.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[allow(dead_code)] -fn check(a: &str) { - let x = a as *const str; - x == x; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17351.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17351.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17351.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17351.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait Str { fn foo(&self) {} } -impl Str for str {} -impl<'a, S: ?Sized> Str for &'a S where S: Str {} - -fn main() { - let _: &Str = &"x"; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17361.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17361.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17361.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17361.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that astconv doesn't forget about mutability of &mut str - -// pretty-expanded FIXME #23616 - -fn main() { - fn foo(_: &mut T) {} - let _f: fn(&mut str) = foo; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17450.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17450.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17450.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17450.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(dead_code, warnings)] - -static mut x: isize = 3; -static mut y: isize = unsafe { x }; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17503.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17503.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17503.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17503.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - let s: &[isize] = &[0, 1, 2, 3, 4]; - let ss: &&[isize] = &s; - let sss: &&&[isize] = &ss; - - println!("{:?}", &s[..3]); - println!("{:?}", &ss[3..]); - println!("{:?}", &sss[2..4]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17662.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17662.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17662.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17662.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-17662.rs - - -extern crate issue_17662 as i; - -use std::marker; - -struct Bar<'a> { m: marker::PhantomData<&'a ()> } - -impl<'a> i::Foo<'a, usize> for Bar<'a> { - fn foo(&self) -> usize { 5 } -} - -pub fn main() { - assert_eq!(i::foo(&Bar { m: marker::PhantomData }), 5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17718-borrow-interior.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17718-borrow-interior.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17718-borrow-interior.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17718-borrow-interior.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct S { a: usize } - -static A: S = S { a: 3 }; -static B: &'static usize = &A.a; -static C: &'static usize = &(A.a); - -static D: [usize; 1] = [1]; -static E: usize = D[0]; -static F: &'static usize = &D[0]; - -fn main() { - assert_eq!(*B, A.a); - assert_eq!(*B, A.a); - - assert_eq!(E, D[0]); - assert_eq!(*F, D[0]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17718-const-destructors.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17718-const-destructors.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17718-const-destructors.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17718-const-destructors.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct A; -impl Drop for A { - fn drop(&mut self) {} -} - -const FOO: A = A; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17718-parse-const.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17718-parse-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17718-parse-const.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17718-parse-const.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -const FOO: usize = 3; - -fn main() { - assert_eq!(FOO, 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17718.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17718.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17718.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17718.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-17718-aux.rs - -extern crate issue_17718_aux as other; - -use std::sync::atomic::{AtomicUsize, Ordering}; - -const C1: usize = 1; -const C2: AtomicUsize = AtomicUsize::new(0); -const C3: fn() = foo; -const C4: usize = C1 * C1 + C1 / C1; -const C5: &'static usize = &C4; -const C6: usize = { - const C: usize = 3; - C -}; - -static S1: usize = 3; -static S2: AtomicUsize = AtomicUsize::new(0); - -mod test { - static A: usize = 4; - static B: &'static usize = &A; - static C: &'static usize = &(A); -} - -fn foo() {} - -fn main() { - assert_eq!(C1, 1); - assert_eq!(C3(), ()); - assert_eq!(C2.fetch_add(1, Ordering::SeqCst), 0); - assert_eq!(C2.fetch_add(1, Ordering::SeqCst), 0); - assert_eq!(C4, 2); - assert_eq!(*C5, 2); - assert_eq!(C6, 3); - assert_eq!(S1, 3); - assert_eq!(S2.fetch_add(1, Ordering::SeqCst), 0); - assert_eq!(S2.fetch_add(1, Ordering::SeqCst), 1); - - match 1 { - C1 => {} - _ => unreachable!(), - } - - let _a = C1; - let _a = C2; - let _a = C3; - let _a = C4; - let _a = C5; - let _a = C6; - let _a = S1; - - assert_eq!(other::C1, 1); - assert_eq!(other::C3(), ()); - assert_eq!(other::C2.fetch_add(1, Ordering::SeqCst), 0); - assert_eq!(other::C2.fetch_add(1, Ordering::SeqCst), 0); - assert_eq!(other::C4, 2); - assert_eq!(*other::C5, 2); - assert_eq!(other::S1, 3); - assert_eq!(other::S2.fetch_add(1, Ordering::SeqCst), 0); - assert_eq!(other::S2.fetch_add(1, Ordering::SeqCst), 1); - - let _a = other::C1; - let _a = other::C2; - let _a = other::C3; - let _a = other::C4; - let _a = other::C5; - - match 1 { - other::C1 => {} - _ => unreachable!(), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17718-static-unsafe-interior.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17718-static-unsafe-interior.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17718-static-unsafe-interior.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17718-static-unsafe-interior.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -use std::marker; -use std::cell::UnsafeCell; - -struct MyUnsafePack(UnsafeCell); - -unsafe impl Sync for MyUnsafePack {} - -struct MyUnsafe { - value: MyUnsafePack -} - -impl MyUnsafe { - fn forbidden(&self) {} -} - -unsafe impl Sync for MyUnsafe {} - -enum UnsafeEnum { - VariantSafe, - VariantUnsafe(UnsafeCell) -} - -unsafe impl Sync for UnsafeEnum {} - -static STATIC1: UnsafeEnum = UnsafeEnum::VariantSafe; - -static STATIC2: MyUnsafePack = MyUnsafePack(UnsafeCell::new(1)); -const CONST: MyUnsafePack = MyUnsafePack(UnsafeCell::new(1)); -static STATIC3: MyUnsafe = MyUnsafe{value: CONST}; - -static STATIC4: &'static MyUnsafePack = &STATIC2; - -struct Wrap { - value: T -} - -unsafe impl Sync for Wrap {} - -static UNSAFE: MyUnsafePack = MyUnsafePack(UnsafeCell::new(2)); -static WRAPPED_UNSAFE: Wrap<&'static MyUnsafePack> = Wrap { value: &UNSAFE }; - -fn main() { - let a = &STATIC1; - - STATIC3.forbidden() -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17732.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17732.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17732.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17732.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait Person { - type string; - fn dummy(&self) { } -} - -struct Someone(std::marker::PhantomData

); - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17734.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17734.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17734.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17734.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that generating drop glue for Box doesn't ICE - - -fn f(s: Box) -> Box { - s -} - -fn main() { - // There is currently no safe way to construct a `Box`, so improvise - let box_arr: Box<[u8]> = Box::new(['h' as u8, 'e' as u8, 'l' as u8, 'l' as u8, 'o' as u8]); - let box_str: Box = unsafe { std::mem::transmute(box_arr) }; - assert_eq!(&*box_str, "hello"); - f(box_str); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17746.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17746.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17746.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17746.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #17746 - -fn main() {} - -struct A; - -impl A { - fn b(&mut self) { - self.a() - } -} - -trait Foo { - fn dummy(&self) {} -} -trait Bar { - fn a(&self); -} - -impl Foo for A {} -impl Bar for T where T: Foo { - fn a(&self) {} -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17756.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17756.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17756.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17756.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -const count : usize = 2 as usize; -fn main() { - let larger : [usize; count*2]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17771.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17771.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17771.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17771.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait Aaa { fn dummy(&self) { } } - -impl<'a> Aaa for &'a mut (Aaa + 'a) {} - -struct Bar<'a> { - writer: &'a mut (Aaa + 'a), -} - -fn baz(_: &mut Aaa) { -} - -fn foo<'a>(mut bar: Bar<'a>) { - baz(&mut bar.writer); -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17816.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17816.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17816.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17816.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::marker::PhantomData; - -fn main() { - struct Symbol<'a, F: Fn(Vec<&'a str>) -> &'a str> { function: F, marker: PhantomData<&'a ()> } - let f = |x: Vec<&str>| -> &str { "foobar" }; - let sym = Symbol { function: f, marker: PhantomData }; - (sym.function)(vec![]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17877.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17877.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17877.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17877.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(slice_patterns)] - -fn main() { - assert_eq!(match [0u8; 1024] { - _ => 42_usize, - }, 42_usize); - - assert_eq!(match [0u8; 1024] { - [1, _..] => 0_usize, - [0, _..] => 1_usize, - _ => 2_usize - }, 1_usize); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17897.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17897.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17897.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17897.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn action(mut cb: Box usize>) -> usize { - cb(1) -} - -pub fn main() { - println!("num: {}", action(Box::new(move |u| u))); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17904.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17904.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17904.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-17904.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we can parse where clauses on various forms of tuple -// structs. - -// pretty-expanded FIXME #23616 - -struct Bar(T) where T: Copy; -struct Bleh(T, U) where T: Copy, U: Sized; -struct Baz where T: Copy { - field: T -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18060.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18060.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18060.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18060.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #18060: match arms were matching in the wrong order. - -fn main() { - assert_eq!(2, match (1, 3) { (0, 2..=5) => 1, (1, 3) => 2, (_, 2..=5) => 3, (_, _) => 4 }); - assert_eq!(2, match (1, 3) { (1, 3) => 2, (_, 2..=5) => 3, (_, _) => 4 }); - assert_eq!(2, match (1, 7) { (0, 2..=5) => 1, (1, 7) => 2, (_, 2..=5) => 3, (_, _) => 4 }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18075.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18075.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18075.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18075.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// exec-env:RUST_LOG=rustc::middle=debug - -fn main() { - let b = 1isize; - println!("{}", b); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18083.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18083.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18083.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18083.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// These crossed imports should resolve fine, and not block on -// each other and be reported as unresolved. - -mod a { - use b::{B}; - pub use self::inner::A; - - mod inner { - pub struct A; - } -} - -mod b { - use a::{A}; - pub use self::inner::B; - - mod inner { - pub struct B; - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18088.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18088.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18088.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18088.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub trait Indexable: std::ops::Index { - fn index2(&self, i: usize) -> &T { - &self[i] - } -} -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18110.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18110.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18110.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18110.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn main() { - ({return},); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18173.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18173.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18173.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18173.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Foo { - type T; -} - -// should be able to use a trait with an associated type without specifying it as an argument -trait Bar { - fn bar(foo: &F); -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18188.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18188.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18188.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18188.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub trait Promisable: Send + Sync {} -impl Promisable for T {} - -pub fn propagate<'a, T, E, F, G>(mut action: F) - -> Box) -> Result + 'a> - where - T: Promisable + Clone + 'a, - E: Promisable + Clone + 'a, - F: FnMut(&T) -> Result + Send + 'a, - G: FnMut(Result) -> Result + 'a { - Box::new(move |result: Result| { - match result { - Ok(ref t) => action(t), - Err(ref e) => Err(e.clone()), - } - }) -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1821.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1821.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1821.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1821.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// Issue #1821 - Don't recurse trying to typecheck this - - -// pretty-expanded FIXME #23616 - -enum t { - foo(Vec) -} -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18232.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18232.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18232.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18232.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -struct Cursor<'a>(::std::marker::PhantomData<&'a ()>); - -trait CursorNavigator { - fn init_cursor<'a, 'b:'a>(&'a self, cursor: &mut Cursor<'b>) -> bool; -} - -struct SimpleNavigator; - -impl CursorNavigator for SimpleNavigator { - fn init_cursor<'a, 'b: 'a>(&'a self, _cursor: &mut Cursor<'b>) -> bool { - false - } -} - -fn main() { - let mut c = Cursor(::std::marker::PhantomData); - let n = SimpleNavigator; - n.init_cursor(&mut c); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18352.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18352.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18352.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18352.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -const X: &'static str = "12345"; - -fn test(s: String) -> bool { - match &*s { - X => true, - _ => false - } -} - -fn main() { - assert!(test("12345".to_string())); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18353.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18353.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18353.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18353.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that wrapping an unsized struct in an enum which gets optimised does -// not ICE. - -// pretty-expanded FIXME #23616 - -struct Str { - f: [u8] -} - -fn main() { - let str: Option<&Str> = None; - str.is_some(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18412.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18412.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18412.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18412.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that non-static methods can be assigned to local variables as -// function pointers. - - -trait Foo { - fn foo(&self) -> usize; -} - -struct A(usize); - -impl A { - fn bar(&self) -> usize { self.0 } -} - -impl Foo for A { - fn foo(&self) -> usize { self.bar() } -} - -fn main() { - let f = A::bar; - let g = Foo::foo; - let a = A(42); - - assert_eq!(f(&a), g(&a)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18425.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18425.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18425.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18425.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check that codegen doesn't ICE when codegenning an array repeat -// expression with a count of 1 and a non-Copy element type. - -// pretty-expanded FIXME #23616 - -fn main() { - let _ = [Box::new(1_usize); 1]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18446.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18446.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18446.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18446.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that methods in trait impls should override default methods. - -trait T { - fn foo(&self) -> i32 { 0 } -} - -impl<'a> T + 'a { - fn foo(&self) -> i32 { 1 } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18464.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18464.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18464.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18464.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![deny(dead_code)] - -const LOW_RANGE: char = '0'; -const HIGH_RANGE: char = '9'; - -fn main() { - match '5' { - LOW_RANGE..=HIGH_RANGE => (), - _ => () - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18501.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18501.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18501.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18501.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we don't ICE when inlining a function from another -// crate that uses a trait method as a value due to incorrectly -// translating the def ID of the trait during AST decoding. - -// aux-build:issue-18501.rs -// pretty-expanded FIXME #23616 - -extern crate issue_18501 as issue; - -fn main() { - issue::pass_method(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18514.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18514.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18514.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18514.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we don't ICE when codegenning a generic impl method from -// an extern crate that contains a match expression on a local -// variable place where one of the match case bodies contains an -// expression that autoderefs through an overloaded generic deref -// impl. - -// aux-build:issue-18514.rs - -extern crate issue_18514 as ice; -use ice::{Tr, St}; - -fn main() { - let st: St<()> = St(vec![]); - st.tr(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18539.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18539.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18539.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18539.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that coercing bare fn's that return a zero sized type to -// a closure doesn't cause an LLVM ERROR - -// pretty-expanded FIXME #23616 - -struct Foo; - -fn uint_to_foo(_: usize) -> Foo { - Foo -} - -#[allow(unused_must_use)] -fn main() { - (0..10).map(uint_to_foo); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18652.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18652.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18652.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18652.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests multiple free variables being passed by value into an unboxed -// once closure as an optimization by codegen. This used to hit an -// incorrect assert. - -fn main() { - let x = 2u8; - let y = 3u8; - assert_eq!((move || x + y)(), 5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18655.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18655.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18655.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18655.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Factory { - type Product; - fn create(&self) -> ::Product; -} - -impl Factory for f64 { - type Product = f64; - fn create(&self) -> f64 { *self * *self } -} - -impl Factory for (A, B) { - type Product = (::Product, ::Product); - fn create(&self) -> (::Product, ::Product) { - let (ref a, ref b) = *self; - (a.create(), b.create()) - } -} - -fn main() { - assert_eq!((16., 25.), (4., 5.).create()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18661.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18661.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18661.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18661.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that param substitutions from the correct environment are -// used when codegenning unboxed closure calls. - -// pretty-expanded FIXME #23616 - -pub fn inside(c: F) { - c(); -} - -// Use different number of type parameters and closure type to trigger -// an obvious ICE when param environments are mixed up -pub fn outside() { - inside(|| {}); -} - -fn main() { - outside::<(),()>(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1866.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1866.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1866.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1866.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -mod a { - pub type rust_task = usize; - pub mod rustrt { - use super::rust_task; - extern { - pub fn rust_task_is_unwinding(rt: *const rust_task) -> bool; - } - } -} - -mod b { - pub type rust_task = bool; - pub mod rustrt { - use super::rust_task; - extern { - pub fn rust_task_is_unwinding(rt: *const rust_task) -> bool; - } - } -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18685.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18685.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18685.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18685.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that the self param space is not used in a conflicting -// manner by unboxed closures within a default method on a trait - -// pretty-expanded FIXME #23616 - -trait Tr { - fn foo(&self); - - fn bar(&self) { - (|| { self.foo() })() - } -} - -impl Tr for () { - fn foo(&self) {} -} - -fn main() { - ().bar(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18711.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18711.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18711.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18711.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we don't panic on a RefCell borrow conflict in certain -// code paths involving unboxed closures. - -// pretty-expanded FIXME #23616 - -// aux-build:issue-18711.rs -extern crate issue_18711 as issue; - -fn main() { - (|| issue::inner(()))(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18738.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18738.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18738.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18738.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Eq, PartialEq, PartialOrd, Ord)] -enum Test<'a> { - Int(&'a isize), - Slice(&'a [u8]), -} - -#[derive(Eq, PartialEq, PartialOrd, Ord)] -struct Version { - vendor_info: &'static str -} - -#[derive(Eq, PartialEq, PartialOrd, Ord)] -struct Foo(&'static str); - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18767.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18767.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18767.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18767.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that regionck uses the right memcat for patterns in for loops -// and doesn't ICE. - - -fn main() { - for &&x in Some(&0_usize).iter() { - assert_eq!(x, 0) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18804/auxiliary/lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18804/auxiliary/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18804/auxiliary/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18804/auxiliary/lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -#![feature(linkage)] - -pub fn foo() -> *const() { - extern { - #[linkage = "extern_weak"] - static FOO: *const(); - } - unsafe { FOO } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18804/main.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18804/main.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18804/main.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18804/main.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test for issue #18804, #[linkage] does not propagate thorugh generic -// functions. Failure results in a linker error. - -// ignore-asmjs no weak symbol support -// ignore-emscripten no weak symbol support - -// aux-build:lib.rs - -extern crate lib; - -fn main() { - lib::foo::(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18809.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18809.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18809.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18809.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Tup { - type T0; - type T1; -} - -impl Tup for isize { - type T0 = f32; - type T1 = (); -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18845.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18845.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18845.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18845.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This used to generate invalid IR in that even if we took the -// `false` branch we'd still try to free the Box from the other -// arm. This was due to treating `*Box::new(9)` as an rvalue datum -// instead of as a place. - -fn test(foo: bool) -> u8 { - match foo { - true => *Box::new(9), - false => 0 - } -} - -fn main() { - assert_eq!(9, test(true)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18859.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18859.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18859.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18859.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -mod foo { - pub mod bar { - pub mod baz { - pub fn name() -> &'static str { - module_path!() - } - } - } -} - -fn main() { - assert_eq!(module_path!(), "issue_18859"); - assert_eq!(foo::bar::baz::name(), "issue_18859::foo::bar::baz"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18906.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18906.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18906.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18906.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub trait Borrow { - fn borrow(&self) -> &Borrowed; -} - -impl Borrow for T { - fn borrow(&self) -> &T { self } -} - -trait Foo { - fn foo(&self, other: &Self); -} - -fn bar(k: &K, q: &Q) where K: Borrow, Q: Foo { - q.foo(k.borrow()) -} - -struct MyTree(K); - -impl MyTree { - // This caused a failure in #18906 - fn bar(k: &K, q: &Q) where K: Borrow, Q: Foo { - q.foo(k.borrow()) - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18913.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18913.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18913.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18913.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-18913-1.rs -// aux-build:issue-18913-2.rs - -extern crate foo; - -fn main() { - assert_eq!(foo::foo(), 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18937-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18937-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18937-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18937-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we are able to type-check this example. In particular, -// knowing that `T: 'a` allows us to deduce that `[U]: 'a` (because -// when `T=[U]` it implies that `U: 'a`). -// -// Regr. test for live code we found in the wild when fixing #18937. - -pub trait Leak { - fn leak<'a>(self) -> &'a T where T: 'a; -} - -impl Leak<[U]> for Vec { - fn leak<'a>(mut self) -> &'a [U] where [U]: 'a { - let r: *mut [U] = &mut self[..]; - std::mem::forget(self); - unsafe { &mut *r } - } -} -fn main() { - println!("Hello, world!"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18988.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18988.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18988.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-18988.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub trait Foo : Send { } - -pub struct MyFoo { - children: Vec>, -} - -impl Foo for MyFoo { } - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19001.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19001.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19001.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19001.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// check that we handle recursive arrays correctly in `type_of` - -struct Loopy { - ptr: *mut [Loopy; 1] -} - -fn main() { - let _t = Loopy { ptr: 0 as *mut _ }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19037.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19037.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19037.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19037.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -struct Str([u8]); - -#[derive(Clone)] -struct CharSplits<'a, Sep> { - string: &'a Str, - sep: Sep, - allow_trailing_empty: bool, - only_ascii: bool, - finished: bool, -} - -fn clone(s: &Str) -> &Str { - Clone::clone(&s) -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19081.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19081.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19081.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19081.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub trait Hasher { - type State; - - fn hash::State - >>(&self, value: &T) -> u64; -} - -pub trait Hash { - fn hash(&self, state: &mut S); -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19097.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19097.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19097.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19097.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// regression test for #19097 - -struct Foo(T); - -impl<'a, T> Foo<&'a T> { - fn foo(&self) {} -} -impl<'a, T> Foo<&'a mut T> { - fn foo(&self) {} -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19098.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19098.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19098.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19098.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub trait Handler { - fn handle(&self, _: &mut String); -} - -impl Handler for F where F: for<'a, 'b> Fn(&'a mut String) { - fn handle(&self, st: &mut String) { - self(st) - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19102.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19102.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19102.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19102.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![deny(unused_qualifications)] - -use self::A::B; - -#[derive(PartialEq)] -pub enum A { - B, -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19127.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19127.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19127.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19127.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn foo T>(f: F) {} -fn id<'a>(input: &'a u8) -> &'a u8 { input } - -fn main() { - foo(id); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19129-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19129-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19129-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19129-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait Trait { - type Output; - - fn method() -> >::Output; -} - -impl Trait for () { - type Output = (); - - fn method() {} -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19129-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19129-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19129-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19129-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait Trait { - type Output; - - fn method(&self, i: Input) -> bool { false } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19135.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19135.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19135.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19135.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::marker::PhantomData; - -#[derive(Debug)] -struct LifetimeStruct<'a>(PhantomData<&'a ()>); - -fn main() { - takes_hrtb_closure(|lts| println!("{:?}", lts)); -} - -fn takes_hrtb_closureFnMut(LifetimeStruct<'a>)>(mut f: F) { - f(LifetimeStruct(PhantomData)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19244.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19244.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19244.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19244.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct MyStruct { field: usize } -struct Nested { nested: MyStruct } -struct Mix2 { nested: ((usize,),) } - -const STRUCT: MyStruct = MyStruct { field: 42 }; -const TUP: (usize,) = (43,); -const NESTED_S: Nested = Nested { nested: MyStruct { field: 5 } }; -const NESTED_T: ((usize,),) = ((4,),); -const MIX_1: ((Nested,),) = ((Nested { nested: MyStruct { field: 3 } },),); -const MIX_2: Mix2 = Mix2 { nested: ((2,),) }; -const INSTANT_1: usize = (MyStruct { field: 1 }).field; -const INSTANT_2: usize = (0,).0; - -fn main() { - let a = [0; STRUCT.field]; - let b = [0; TUP.0]; - let c = [0; NESTED_S.nested.field]; - let d = [0; (NESTED_T.0).0]; - let e = [0; (MIX_1.0).0.nested.field]; - let f = [0; (MIX_2.nested.0).0]; - let g = [0; INSTANT_1]; - let h = [0; INSTANT_2]; - - assert_eq!(a.len(), 42); - assert_eq!(b.len(), 43); - assert_eq!(c.len(), 5); - assert_eq!(d.len(), 4); - assert_eq!(e.len(), 3); - assert_eq!(f.len(), 2); - assert_eq!(g.len(), 1); - assert_eq!(h.len(), 0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19293.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19293.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19293.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19293.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue_19293.rs -// pretty-expanded FIXME #23616 - -extern crate issue_19293; -use issue_19293::{Foo, MyEnum}; - -fn main() { - MyEnum::Foo(Foo(5)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19340-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19340-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19340-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19340-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-19340-1.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_19340_1 as lib; - -use lib::Homura; - -fn main() { - let homura = Homura::Madoka { name: "Kaname".to_string() }; - - match homura { - Homura::Madoka { name } => (), - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19340-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19340-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19340-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19340-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -enum Homura { - Madoka { - name: String, - age: u32, - }, -} - -fn main() { - let homura = Homura::Madoka { - name: "Akemi".to_string(), - age: 14, - }; - - match homura { - Homura::Madoka { - name, - age, - } => (), - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19358.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19358.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19358.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19358.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Trait { fn dummy(&self) { } } - -#[derive(Debug)] -struct Foo { - foo: T, -} - -#[derive(Debug)] -struct Bar where T: Trait { - bar: T, -} - -impl Trait for isize {} - -fn main() { - let a = Foo { foo: 12 }; - let b = Bar { bar: 12 }; - println!("{:?} {:?}", a, b); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19367.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19367.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19367.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19367.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct S { - o: Option -} - -// Make sure we don't reuse the same alloca when matching -// on field of struct or tuple which we reassign in the match body. - -fn main() { - let mut a = (0, Some("right".to_string())); - let b = match a.1 { - Some(v) => { - a.1 = Some("wrong".to_string()); - v - } - None => String::new() - }; - println!("{}", b); - assert_eq!(b, "right"); - - - let mut s = S{ o: Some("right".to_string()) }; - let b = match s.o { - Some(v) => { - s.o = Some("wrong".to_string()); - v - } - None => String::new(), - }; - println!("{}", b); - assert_eq!(b, "right"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19398.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19398.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19398.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19398.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait T { - unsafe extern "Rust" fn foo(&self); -} - -impl T for () { - unsafe extern "Rust" fn foo(&self) {} -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19404.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19404.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19404.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19404.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::any::TypeId; -use std::rc::Rc; - -type Fp = Rc; - -struct Engine; - -trait Component: 'static {} -impl Component for Engine {} - -trait Env { - fn get_component_type_id(&self, type_id: TypeId) -> Option>; -} - -impl<'a> Env+'a { - fn get_component(&self) -> Option> { - let x = self.get_component_type_id(TypeId::of::()); - None - } -} - -trait Figment { - fn init(&mut self, env: &Env); -} - -struct MyFigment; - -impl Figment for MyFigment { - fn init(&mut self, env: &Env) { - let engine = env.get_component::(); - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19479.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19479.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19479.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19479.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait Base { - fn dummy(&self) { } -} -trait AssocA { - type X: Base; - fn dummy(&self) { } -} -trait AssocB { - type Y: Base; - fn dummy(&self) { } -} -impl AssocB for T { - type Y = ::X; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19499.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19499.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19499.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19499.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for issue #19499. Due to incorrect caching of trait -// results for closures with upvars whose types were not fully -// computed, this rather bizarre little program (along with many more -// reasonable examples) let to ambiguity errors about not being able -// to infer sufficient type information. - -// pretty-expanded FIXME #23616 - -fn main() { - let n = 0; - let it = Some(1_usize).into_iter().inspect(|_| {n;}); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19631.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19631.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19631.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19631.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait PoolManager { - type C; - fn dummy(&self) { } -} - -struct InnerPool { - manager: M, -} - -impl InnerPool where M: PoolManager {} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19632.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19632.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19632.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19632.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait PoolManager { - type C; - fn dummy(&self) { } -} - -struct InnerPool { - manager: M, -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1974.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1974.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1974.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-1974.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue 1974 -// Don't double free the condition allocation -// pretty-expanded FIXME #23616 - -pub fn main() { - let s = "hej".to_string(); - while s != "".to_string() { - return; - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19811-escape-unicode.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19811-escape-unicode.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19811-escape-unicode.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19811-escape-unicode.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn main() { - let mut escaped = String::from(""); - for c in '\u{10401}'.escape_unicode() { - escaped.push(c); - } - assert_eq!("\\u{10401}", escaped); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19850.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19850.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19850.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19850.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that `::Output` and `Self::Output` are accepted as type annotations in let -// bindings - -// pretty-expanded FIXME #23616 - -trait Int { - fn one() -> Self; - fn leading_zeros(self) -> usize; -} - -trait Foo { - type T : Int; - - fn test(&self) { - let r: ::T = Int::one(); - let r: Self::T = Int::one(); - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19982.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19982.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19982.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-19982.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(fn_traits, unboxed_closures)] - -#[allow(dead_code)] -struct Foo; - -impl<'a> Fn<(&'a (),)> for Foo { - extern "rust-call" fn call(&self, (_,): (&(),)) {} -} - -impl<'a> FnMut<(&'a (),)> for Foo { - extern "rust-call" fn call_mut(&mut self, (_,): (&(),)) {} -} - -impl<'a> FnOnce<(&'a (),)> for Foo { - type Output = (); - - extern "rust-call" fn call_once(self, (_,): (&(),)) {} -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20009.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20009.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20009.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20009.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check that associated types are `Sized` - -// pretty-expanded FIXME #23616 - -trait Trait { - type Output; - - fn is_sized(&self) -> Self::Output; - fn wasnt_sized(&self) -> Self::Output { loop {} } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20055-box-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20055-box-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20055-box-trait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20055-box-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// See Issues #20055 and #21695. - -// We are checking here that the temporaries `Box<[i8, k]>`, for `k` -// in 1, 2, 3, 4, that are induced by the match expression are -// properly handled, in that only *one* will be initialized by -// whichever arm is run, and subsequently dropped at the end of the -// statement surrounding the `match`. - -trait Boo { - fn dummy(&self) { } -} - -impl Boo for [i8; 1] { } -impl Boo for [i8; 2] { } -impl Boo for [i8; 3] { } -impl Boo for [i8; 4] { } - -pub fn foo(box_1: fn () -> Box<[i8; 1]>, - box_2: fn () -> Box<[i8; 2]>, - box_3: fn () -> Box<[i8; 3]>, - box_4: fn () -> Box<[i8; 4]>, - ) { - println!("Hello World 1"); - let _: Box = match 3 { - 1 => box_1(), - 2 => box_2(), - 3 => box_3(), - _ => box_4(), - }; - println!("Hello World 2"); -} - -pub fn main() { - fn box_1() -> Box<[i8; 1]> { Box::new( [1; 1] ) } - fn box_2() -> Box<[i8; 2]> { Box::new( [1; 2] ) } - fn box_3() -> Box<[i8; 3]> { Box::new( [1; 3] ) } - fn box_4() -> Box<[i8; 4]> { Box::new( [1; 4] ) } - - foo(box_1, box_2, box_3, box_4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20055-box-unsized-array.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20055-box-unsized-array.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20055-box-unsized-array.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20055-box-unsized-array.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #2005: Check that boxed fixed-size arrays are properly -// accounted for (namely, only deallocated if they were actually -// created) when they appear as temporaries in unused arms of a match -// expression. - -pub fn foo(box_1: fn () -> Box<[i8; 1]>, - box_2: fn () -> Box<[i8; 20]>, - box_3: fn () -> Box<[i8; 300]>, - box_4: fn () -> Box<[i8; 4000]>, - ) { - println!("Hello World 1"); - let _: Box<[i8]> = match 3 { - 1 => box_1(), - 2 => box_2(), - 3 => box_3(), - _ => box_4(), - }; - println!("Hello World 2"); -} - -pub fn main() { - fn box_1() -> Box<[i8; 1]> { Box::new( [1] ) } - fn box_2() -> Box<[i8; 20]> { Box::new( [1; 20] ) } - fn box_3() -> Box<[i8; 300]> { Box::new( [1; 300] ) } - fn box_4() -> Box<[i8; 4000]> { Box::new( [1; 4000] ) } - - foo(box_1, box_2, box_3, box_4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20091.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20091.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20091.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20091.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -// ignore-cloudabi no processes -// ignore-emscripten no processes - -#![feature(os)] - -#[cfg(unix)] -fn main() { - use std::process::Command; - use std::env; - use std::os::unix::prelude::*; - use std::ffi::OsStr; - - if env::args().len() == 1 { - assert!(Command::new(&env::current_exe().unwrap()) - .arg(::from_bytes(b"\xff")) - .status().unwrap().success()) - } -} - -#[cfg(windows)] -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20174.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20174.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20174.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20174.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct GradFn usize>(F); - -fn main() { - let GradFn(x_squared) : GradFn<_> = GradFn(|| -> usize { 2 }); - let _ = x_squared(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20186.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20186.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20186.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20186.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct Foo; - -impl Foo { - fn putc(&self, b: u8) { } - - fn puts(&self, s: &str) { - for byte in s.bytes() { - self.putc(byte) - } - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20313.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20313.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20313.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20313.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(link_llvm_intrinsics)] - -extern { - #[link_name = "llvm.sqrt.f32"] - fn sqrt(x: f32) -> f32; -} - -fn main(){ -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20343.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20343.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20343.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20343.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for Issue #20343. - -// pretty-expanded FIXME #23616 - -#![deny(dead_code)] - -struct B { b: u32 } -struct C; -struct D; - -trait T { fn dummy(&self, a: A) { } } -impl T for () {} - -impl B { - // test for unused code in arguments - fn foo(B { b }: B) -> u32 { b } - - // test for unused code in return type - fn bar() -> C { unsafe { ::std::mem::transmute(()) } } - - // test for unused code in generics - fn baz>() {} -} - -pub fn main() { - let b = B { b: 3 }; - B::foo(b); - B::bar(); - B::baz::<()>(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20389.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20389.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20389.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20389.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue_20389.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_20389; - -struct Foo; - -impl issue_20389::T for Foo { - type C = (); -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20396.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20396.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20396.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20396.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![allow(dead_code)] - -trait Foo { - fn noop(&self, _: T); -} - -enum Bar { Bla(T) } - -struct Baz<'a> { - inner: for<'b> Foo> + 'a, -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20414.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20414.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20414.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20414.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait Trait { - fn method(self) -> isize; -} - -struct Wrapper { - field: T -} - -impl<'a, T> Trait for &'a Wrapper where &'a T: Trait { - fn method(self) -> isize { - let r: &'a T = &self.field; - Trait::method(r); // these should both work - r.method() - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20427.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20427.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20427.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20427.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,95 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] -#![allow(non_camel_case_types)] - -// aux-build:i8.rs -// ignore-pretty issue #37201 - -extern crate i8; -use std::string as i16; -static i32: i32 = 0; -const i64: i64 = 0; -fn u8(f32: f32) {} -fn f(f64: f64) {} -enum u32 {} -struct u64; -trait bool {} - -mod char { - extern crate i8; - static i32_: i32 = 0; - const i64_: i64 = 0; - fn u8_(f32: f32) {} - fn f_(f64: f64_) {} - type u16_ = u16; - enum u32_ {} - struct u64_; - trait bool_ {} - mod char_ {} - - mod str { - use super::i8 as i8; - use super::i32_ as i32; - use super::i64_ as i64; - use super::u8_ as u8; - use super::f_ as f64; - use super::u16_ as u16; - use super::u32_ as u32; - use super::u64_ as u64; - use super::bool_ as bool; - use super::{bool_ as str}; - use super::char_ as char; - } -} - -trait isize_ { - type isize; -} - -fn usize<'usize>(usize: &'usize usize) -> &'usize usize { usize } - -mod reuse { - use std::mem::size_of; - - type u8 = u64; - use std::string::String as i16; - - pub fn check() { - assert_eq!(size_of::(), 8); - assert_eq!(size_of::<::u64>(), 0); - assert_eq!(size_of::(), 3 * size_of::<*const ()>()); - assert_eq!(size_of::(), 0); - } -} - -mod guard { - pub fn check() { - use std::u8; // bring module u8 in scope - fn f() -> u8 { // OK, resolves to primitive u8, not to std::u8 - u8::max_value() // OK, resolves to associated function ::max_value, - // not to non-existent std::u8::max_value - } - assert_eq!(f(), u8::MAX); // OK, resolves to std::u8::MAX - } -} - -fn main() { - let bool = true; - let _ = match bool { - str @ true => if str { i32 as i64 } else { i64 }, - false => i64, - }; - - reuse::check::(); - guard::check(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20454.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20454.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20454.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20454.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::thread; - -fn _foo() { - thread::spawn(move || { // no need for -> () - loop { - println!("hello"); - } - }).join(); -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20544.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20544.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20544.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20544.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(unboxed_closures)] -#![feature(fn_traits)] - -struct Fun(F); - -impl FnOnce<(T,)> for Fun where F: Fn(T) -> T { - type Output = T; - - extern "rust-call" fn call_once(self, (t,): (T,)) -> T { - (self.0)(t) - } -} - -fn main() { - let fun = Fun(|i: isize| i * 2); - println!("{}", fun(3)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20575.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20575.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20575.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20575.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that overloaded calls work with zero arity closures - -// pretty-expanded FIXME #23616 - -fn main() { - let functions: [Box Option<()>>; 1] = [Box::new(|| None)]; - - let _: Option> = functions.iter().map(|f| (*f)()).collect(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20616.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20616.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20616.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20616.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -type MyType<'a, T> = &'a T; - -// combine lifetime bounds and type arguments in usual way -type TypeA<'a> = MyType<'a, ()>; - -// ensure token `>>` works fine -type TypeB = Box>; -type TypeB_ = Box>; - -// trailing comma when combine lifetime bounds and type arguments -type TypeC<'a> = MyType<'a, (),>; - -// normal lifetime bounds -type TypeD = TypeA<'static>; - -// trailing comma on lifetime bounds -type TypeE = TypeA<'static,>; - -// normal type argument -type TypeF = Box; - -// type argument with trailing comma -type TypeG = Box; - -// trailing comma on lifetime defs -type TypeH<'a,> = &'a (); - -// trailing comma on type argument -type TypeI = T; - -static STATIC: () = (); - -fn main() { - - // ensure token `>=` works fine - let _: TypeA<'static>= &STATIC; - let _: TypeA<'static,>= &STATIC; - - // ensure token `>>=` works fine - let _: Box>= Box::new(&STATIC); - let _: Box>= Box::new(&STATIC); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2063-resource.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2063-resource.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2063-resource.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2063-resource.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// test that autoderef of a type like this does not -// cause compiler to loop. Note that no instances -// of such a type could ever be constructed. - -struct S { - x: X, - to_str: (), -} - -struct X(Box); - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2063.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2063.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2063.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2063.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// test that autoderef of a type like this does not -// cause compiler to loop. Note that no instances -// of such a type could ever be constructed. - -struct T(Box); - -trait ToStr2 { - fn my_to_string(&self) -> String; -} - -impl ToStr2 for T { - fn my_to_string(&self) -> String { "t".to_string() } -} - -#[allow(dead_code)] -fn new_t(x: T) { - x.my_to_string(); -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20644.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20644.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20644.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20644.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -// A reduced version of the rustbook ice. The problem this encountered -// had to do with codegen ignoring binders. - -// pretty-expanded FIXME #23616 -// ignore-cloudabi no std::fs - -#![feature(os)] - -use std::iter; -use std::os; -use std::fs::File; -use std::io::prelude::*; -use std::env; -use std::path::Path; - -pub fn parse_summary(_: R, _: &Path) { - let path_from_root = Path::new(""); - Path::new(&iter::repeat("../") - .take(path_from_root.components().count() - 1) - .collect::()); - } - -fn foo() { - let cwd = env::current_dir().unwrap(); - let src = cwd.clone(); - let summary = File::open(&src.join("SUMMARY.md")).unwrap(); - let _ = parse_summary(summary, &src); -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20676.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20676.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20676.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20676.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #20676. Error was that we didn't support -// UFCS-style calls to a method in `Trait` where `Self` was bound to a -// trait object of type `Trait`. See also `ufcs-trait-object.rs`. - - -use std::fmt; - -fn main() { - let a: &fmt::Debug = &1; - format!("{:?}", a); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2074.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2074.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2074.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2074.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![allow(non_camel_case_types)] - -pub fn main() { - let one = || { - enum r { a }; - r::a as usize - }; - let two = || { - enum r { a }; - r::a as usize - }; - one(); two(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20763-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20763-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20763-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20763-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait T0 { - type O; - fn dummy(&self) { } -} - -struct S(A); -impl T0 for S { type O = A; } - -trait T1: T0 { - // this looks okay but as we see below, `f` is unusable - fn m0::O) -> bool>(self, f: F) -> bool; -} - -// complains about the bounds on F here not being required by the trait -impl T1 for S { - fn m0 bool>(self, f: F) -> bool { f(self.0) } -} - -// // complains about mismatched types: as T0>::O vs. A -// impl T1 for S -// { -// fn m0::O) -> bool>(self, f: F) -> bool { f(self.0) } -// } - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20763-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20763-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20763-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20763-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait T0 { - type O; - fn dummy(&self) { } -} - -struct S(A); -impl T0 for S { type O = A; } - -trait T1: T0 { - // this looks okay but as we see below, `f` is unusable - fn m0::O) -> bool>(self, f: F) -> bool; -} - -// complains about mismatched types: as T0>::O vs. A -impl T1 for S -{ - fn m0::O) -> bool>(self, f: F) -> bool { f(self.0) } -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20797.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20797.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20797.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20797.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-cloudabi no std::fs - -// Regression test for #20797. - -use std::default::Default; -use std::io; -use std::fs; -use std::path::PathBuf; - -pub trait PathExtensions { - fn is_dir(&self) -> bool { false } -} - -impl PathExtensions for PathBuf {} - -/// A strategy for acquiring more subpaths to walk. -pub trait Strategy { - type P: PathExtensions; - /// Get additional subpaths from a given path. - fn get_more(&self, item: &Self::P) -> io::Result>; - /// Determine whether a path should be walked further. - /// This is run against each item from `get_more()`. - fn prune(&self, p: &Self::P) -> bool; -} - -/// The basic fully-recursive strategy. Nothing is pruned. -#[derive(Copy, Clone, Default)] -pub struct Recursive; - -impl Strategy for Recursive { - type P = PathBuf; - fn get_more(&self, p: &PathBuf) -> io::Result> { - Ok(fs::read_dir(p).unwrap().map(|s| s.unwrap().path()).collect()) - } - - fn prune(&self, _: &PathBuf) -> bool { false } -} - -/// A directory walker of `P` using strategy `S`. -pub struct Subpaths { - stack: Vec, - strategy: S, -} - -impl Subpaths { - /// Create a directory walker with a root path and strategy. - pub fn new(p: &S::P, strategy: S) -> io::Result> { - let stack = strategy.get_more(p)?; - Ok(Subpaths { stack: stack, strategy: strategy }) - } -} - -impl Subpaths { - /// Create a directory walker with a root path and a default strategy. - pub fn walk(p: &S::P) -> io::Result> { - Subpaths::new(p, Default::default()) - } -} - -impl Default for Subpaths { - fn default() -> Subpaths { - Subpaths { stack: Vec::new(), strategy: Default::default() } - } -} - -impl Iterator for Subpaths { - type Item = S::P; - fn next (&mut self) -> Option { - let mut opt_path = self.stack.pop(); - while opt_path.is_some() && self.strategy.prune(opt_path.as_ref().unwrap()) { - opt_path = self.stack.pop(); - } - match opt_path { - Some(path) => { - if path.is_dir() { - let result = self.strategy.get_more(&path); - match result { - Ok(dirs) => { self.stack.extend(dirs); }, - Err(..) => { } - } - } - Some(path) - } - None => None, - } - } -} - -fn _foo() { - let _walker: Subpaths = Subpaths::walk(&PathBuf::from("/home")).unwrap(); -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20803.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20803.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20803.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20803.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::ops::Add; - -fn foo(x: T) -> >::Output where i32: Add { - 42i32 + x -} - -fn main() { - println!("{}", foo(0i32)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20823.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20823.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20823.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20823.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: --test - -#[test] -pub fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20825.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20825.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20825.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20825.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub trait Subscriber { - type Input; -} - -pub trait Processor: Subscriber::Input> { - type Input; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20847.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20847.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20847.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20847.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(fn_traits)] - -use std::ops::Fn; - -fn say(x: u32, y: u32) { - println!("{} {}", x, y); -} - -fn main() { - Fn::call(&say, (1, 2)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20953.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20953.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20953.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-20953.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - let mut shrinker: Box> = Box::new(vec![1].into_iter()); - println!("{:?}", shrinker.next()); - for v in shrinker { assert!(false); } - - let mut shrinker: &mut Iterator = &mut vec![1].into_iter(); - println!("{:?}", shrinker.next()); - for v in shrinker { assert!(false); } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21033.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21033.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21033.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21033.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(box_patterns)] -#![feature(box_syntax)] - -enum E { - StructVar { boxed: Box } -} - -fn main() { - - // Test matching each shorthand notation for field patterns. - let mut a = E::StructVar { boxed: box 3 }; - match a { - E::StructVar { box boxed } => { } - } - match a { - E::StructVar { box ref boxed } => { } - } - match a { - E::StructVar { box mut boxed } => { } - } - match a { - E::StructVar { box ref mut boxed } => { } - } - match a { - E::StructVar { ref boxed } => { } - } - match a { - E::StructVar { ref mut boxed } => { } - } - match a { - E::StructVar { mut boxed } => { } - } - - // Test matching non shorthand notation. Recreate a since last test - // moved `boxed` - let mut a = E::StructVar { boxed: box 3 }; - match a { - E::StructVar { boxed: box ref mut num } => { } - } - match a { - E::StructVar { boxed: ref mut num } => { } - } - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21058.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21058.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21058.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21058.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(core_intrinsics)] - -struct NT(str); -struct DST { a: u32, b: str } - -fn main() { - // type_name should support unsized types - assert_eq!(unsafe {( - // Slice - std::intrinsics::type_name::<[u8]>(), - // str - std::intrinsics::type_name::(), - // Trait - std::intrinsics::type_name::(), - // Newtype - std::intrinsics::type_name::(), - // DST - std::intrinsics::type_name::() - )}, ("[u8]", "str", "dyn std::marker::Send", "NT", "DST")); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21140.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21140.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21140.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21140.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub trait Trait where Self::Out: std::fmt::Display { - type Out; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21174.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21174.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21174.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21174.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Trait<'a> { - type A; - type B; -} - -fn foo<'a, T: Trait<'a>>(value: T::A) { - let new: T::B = unsafe { std::mem::transmute_copy(&value) }; -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21245.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21245.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21245.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21245.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for issue #21245. Check that we are able to infer -// the types in these examples correctly. It used to be that -// insufficient type propagation caused the type of the iterator to be -// incorrectly unified with the `*const` type to which it is coerced. - -// pretty-expanded FIXME #23616 - -use std::ptr; - -trait IntoIterator { - type Iter: Iterator; - - fn into_iter2(self) -> Self::Iter; -} - -impl IntoIterator for I where I: Iterator { - type Iter = I; - - fn into_iter2(self) -> I { - self - } -} - -fn desugared_for_loop_bad(v: Vec) { - match IntoIterator::into_iter2(v.iter()) { - mut iter => { - loop { - match ::std::iter::Iterator::next(&mut iter) { - ::std::option::Option::Some(x) => { - unsafe { ptr::read(x); } - }, - ::std::option::Option::None => break - } - } - } - } -} - -fn desugared_for_loop_good(v: Vec) { - match v.iter().into_iter() { - mut iter => { - loop { - match ::std::iter::Iterator::next(&mut iter) { - ::std::option::Option::Some(x) => { - unsafe { ptr::read(x); } - }, - ::std::option::Option::None => break - } - } - } - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21291.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21291.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21291.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21291.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -// Regression test for unwrapping the result of `join`, issue #21291 - -use std::thread; - -fn main() { - thread::spawn(|| {}).join().unwrap() -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21306.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21306.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21306.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21306.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::sync::Arc; - -fn main() { - let x = 5; - let command = Arc::new(Box::new(|| { x*2 })); - assert_eq!(command(), 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21361.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21361.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21361.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21361.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn main() { - let v = vec![1, 2, 3]; - let boxed: Box> = Box::new(v.into_iter()); - assert_eq!(boxed.max(), Some(3)); - - let v = vec![1, 2, 3]; - let boxed: &mut Iterator = &mut v.into_iter(); - assert_eq!(boxed.max(), Some(3)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21363.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21363.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21363.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21363.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![no_implicit_prelude] - -trait Iterator { - type Item; - fn dummy(&self) { } -} - -impl<'a, T> Iterator for &'a mut (Iterator + 'a) { - type Item = T; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21384.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21384.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21384.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21384.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use ::std::ops::RangeFull; - -fn test(arg: T) -> T { - arg.clone() -} - -#[derive(PartialEq, Debug)] -struct Test(isize); - -fn main() { - // Check that ranges implement clone - assert_eq!(test(1..5), (1..5)); - assert_eq!(test(..5), (..5)); - assert_eq!(test(1..), (1..)); - assert_eq!(test(RangeFull), (RangeFull)); - - // Check that ranges can still be used with non-clone limits - assert_eq!((Test(1)..Test(5)), (Test(1)..Test(5))); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21400.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21400.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21400.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21400.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #21400 which itself was extracted from -// stackoverflow.com/questions/28031155/is-my-borrow-checker-drunk/28031580 - -fn main() { - let mut t = Test; - assert_eq!(t.method1("one"), Ok(1)); - assert_eq!(t.method2("two"), Ok(2)); - assert_eq!(t.test(), Ok(2)); -} - -struct Test; - -impl Test { - fn method1(&mut self, _arg: &str) -> Result { - Ok(1) - } - - fn method2(self: &mut Test, _arg: &str) -> Result { - Ok(2) - } - - fn test(self: &mut Test) -> Result { - let s = format!("abcde"); - // (Originally, this invocation of method2 was saying that `s` - // does not live long enough.) - let data = match self.method2(&*s) { - Ok(r) => r, - Err(e) => return Err(e) - }; - Ok(data) - } -} - -// Below is a closer match for the original test that was failing to compile - -pub struct GitConnect; - -impl GitConnect { - fn command(self: &mut GitConnect, _s: &str) -> Result>, &str> { - unimplemented!() - } - - pub fn git_upload_pack(self: &mut GitConnect) -> Result { - let c = format!("git-upload-pack"); - - let mut out = String::new(); - let data = self.command(&c)?; - - for line in data.iter() { - out.push_str(&format!("{:?}", line)); - } - - Ok(out) - } -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21402.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21402.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21402.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21402.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#[derive(Hash)] -struct Foo { - a: Vec, - b: (bool, bool), - c: [bool; 2], -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21475.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21475.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21475.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21475.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -use m::{START, END}; - -fn main() { - match 42 { - m::START..=m::END => {}, - 0..=m::END => {}, - m::START..=59 => {}, - _ => {}, - } -} - -mod m { - pub const START: u32 = 4; - pub const END: u32 = 14; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21486.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21486.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21486.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21486.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #21486: Make sure that all structures are dropped, even when -// created via FRU and control-flow breaks in the middle of -// construction. - -use std::sync::atomic::{Ordering, AtomicUsize}; - -#[derive(Debug)] -struct Noisy(u8); -impl Drop for Noisy { - fn drop(&mut self) { - // println!("splat #{}", self.0); - event(self.0); - } -} - -#[allow(dead_code)] -#[derive(Debug)] -struct Foo { n0: Noisy, n1: Noisy } -impl Foo { - fn vals(&self) -> (u8, u8) { (self.n0.0, self.n1.0) } -} - -fn leak_1_ret() -> Foo { - let _old_foo = Foo { n0: Noisy(1), n1: Noisy(2) }; - Foo { n0: { return Foo { n0: Noisy(3), n1: Noisy(4) } }, - .._old_foo - }; -} - -fn leak_2_ret() -> Foo { - let _old_foo = Foo { n0: Noisy(1), n1: Noisy(2) }; - Foo { n1: { return Foo { n0: Noisy(3), n1: Noisy(4) } }, - .._old_foo - }; -} - -// In this case, the control flow break happens *before* we construct -// `Foo(Noisy(1),Noisy(2))`, so there should be no record of it in the -// event log. -fn leak_3_ret() -> Foo { - let _old_foo = || Foo { n0: Noisy(1), n1: Noisy(2) }; - Foo { n1: { return Foo { n0: Noisy(3), n1: Noisy(4) } }, - .._old_foo() - }; -} - -pub fn main() { - reset_log(); - assert_eq!(leak_1_ret().vals(), (3,4)); - assert_eq!(0x01_02_03_04, event_log()); - - reset_log(); - assert_eq!(leak_2_ret().vals(), (3,4)); - assert_eq!(0x01_02_03_04, event_log()); - - reset_log(); - assert_eq!(leak_3_ret().vals(), (3,4)); - assert_eq!(0x03_04, event_log()); -} - -static LOG: AtomicUsize = AtomicUsize::new(0); - -fn reset_log() { - LOG.store(0, Ordering::SeqCst); -} - -fn event_log() -> usize { - LOG.load(Ordering::SeqCst) -} - -fn event(tag: u8) { - let old_log = LOG.load(Ordering::SeqCst); - let new_log = (old_log << 8) + tag as usize; - LOG.store(new_log, Ordering::SeqCst); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21520.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21520.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21520.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21520.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that the requirement (in `Bar`) that `T::Bar : 'static` does -// not wind up propagating to `T`. - -// pretty-expanded FIXME #23616 - -pub trait Foo { - type Bar; - - fn foo(&self) -> Self; -} - -pub struct Static(T); - -struct Bar - where T::Bar : 'static -{ - x: Static> -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21562.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21562.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21562.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21562.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -extern crate core; -use core::marker::Sync; - -static SARRAY: [i32; 1] = [11]; - -struct MyStruct { - pub arr: *const [i32], -} -unsafe impl Sync for MyStruct {} - -static mystruct: MyStruct = MyStruct { - arr: &SARRAY -}; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21622.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21622.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21622.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21622.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct Index; - -impl Index { - fn new() -> Self { Index } -} - -fn user() { - let new = Index::new; - - fn inner() { - let index = Index::new(); - } - - let index2 = new(); -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21634.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21634.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21634.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21634.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -#![feature(cfg_target_feature)] - -#[cfg(any(not(target_arch = "x86"), target_feature = "sse2"))] -fn main() { - if let Ok(x) = "3.1415".parse::() { - assert_eq!(false, x <= 0.0); - } - if let Ok(x) = "3.1415".parse::() { - assert_eq!(3.1415, x + 0.0); - } - if let Ok(mut x) = "3.1415".parse::() { - assert_eq!(8.1415, { x += 5.0; x }); - } -} - -#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))] -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21655.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21655.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21655.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21655.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn test(it: &mut Iterator) { - for x in it { - assert_eq!(x, 1) - } -} - -fn main() { - let v = vec![1]; - test(&mut v.into_iter()) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue2170exe.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue2170exe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue2170exe.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue2170exe.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue2170lib.rs -// pretty-expanded FIXME #23616 - -extern crate issue2170lib; - -pub fn main() { - // let _ = issue2170lib::rsrc(2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21721.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21721.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21721.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21721.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn main() { - static NONE: Option<((), &'static u8)> = None; - let ptr = unsafe { - *(&NONE as *const _ as *const *const u8) - }; - assert!(ptr.is_null()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21726.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21726.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21726.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21726.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #21726: an issue arose around the rules for -// subtyping of projection types that resulted in an unconstrained -// region, yielding region inference failures. - -// pretty-expanded FIXME #23616 - -fn main() { } - -fn foo<'a>(s: &'a str) { - let b: B<()> = B::new(s, ()); - b.get_short(); -} - -trait IntoRef<'a> { - type T: Clone; - fn into_ref(self, _: &'a str) -> Self::T; -} - -impl<'a> IntoRef<'a> for () { - type T = &'a str; - fn into_ref(self, s: &'a str) -> &'a str { - s - } -} - -struct B<'a, P: IntoRef<'a>>(P::T); - -impl<'a, P: IntoRef<'a>> B<'a, P> { - fn new(s: &'a str, i: P) -> B<'a, P> { - B(i.into_ref(s)) - } - - fn get_short(&self) -> P::T { - self.0.clone() - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21891.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21891.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21891.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21891.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -// pretty-expanded FIXME #23616 - -static foo: [usize; 3] = [1, 2, 3]; - -static slice_1: &'static [usize] = &foo; -static slice_2: &'static [usize] = &foo; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2190-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2190-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2190-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2190-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -// pretty-expanded FIXME #23616 -// ignore-emscripten no threads - -use std::thread::Builder; - -static generations: usize = 1024+256+128+49; - -fn spawn(mut f: Box) { - Builder::new().stack_size(32 * 1024).spawn(move|| f()); -} - -fn child_no(x: usize) -> Box { - Box::new(move|| { - if x < generations { - spawn(child_no(x+1)); - } - }) -} - -pub fn main() { - spawn(child_no(0)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21909.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21909.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21909.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21909.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait A { - fn dummy(&self, arg: X); -} - -trait B { - type X; - type Y: A; - - fn dummy(&self); -} - -fn main () { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21922.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21922.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21922.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-21922.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::ops::Add; -fn show(z: i32) { - println!("{}", z) -} -fn main() { - let x = 23; - let y = 42; - show(Add::add( x, y)); - show(Add::add( x, &y)); - show(Add::add(&x, y)); - show(Add::add(&x, &y)); - show( x + y); - show( x + &y); - show(&x + y); - show(&x + &y); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22008.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22008.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22008.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22008.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn main() { - let command = "a"; - - match command { - "foo" => println!("foo"), - _ => println!("{}", command), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22036.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22036.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22036.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22036.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait DigitCollection: Sized { - type Iter: Iterator; - fn digit_iter(self) -> Self::Iter; - - fn digit_sum(self) -> u32 { - self.digit_iter() - .map(|digit: u8| digit as u32) - .fold(0, |sum, digit| sum + digit) - } -} - -impl DigitCollection for I where I: Iterator { - type Iter = I; - - fn digit_iter(self) -> I { - self - } -} - -fn main() { - let xs = vec![1, 2, 3, 4, 5]; - assert_eq!(xs.into_iter().digit_sum(), 15); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22066.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22066.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22066.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22066.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub trait LineFormatter<'a> { - type Iter: Iterator + 'a; - fn iter(&'a self, line: &'a str) -> Self::Iter; - - fn dimensions(&'a self, line: &'a str) { - let iter: Self::Iter = self.iter(line); - <_ as IntoIterator>::into_iter(iter); - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2214.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2214.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2214.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2214.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare no libc to test ffi with - -#![feature(libc)] - -extern crate libc; - -use std::mem; -use libc::{c_double, c_int}; - -fn to_c_int(v: &mut isize) -> &mut c_int { - unsafe { - mem::transmute_copy(&v) - } -} - -fn lgamma(n: c_double, value: &mut isize) -> c_double { - unsafe { - return m::lgamma(n, to_c_int(value)); - } -} - -mod m { - use libc::{c_double, c_int}; - - #[link_name = "m"] - extern { - #[cfg(any(unix, target_os = "cloudabi"))] - #[link_name="lgamma_r"] - pub fn lgamma(n: c_double, sign: &mut c_int) -> c_double; - #[cfg(windows)] - #[link_name="lgamma"] - pub fn lgamma(n: c_double, sign: &mut c_int) -> c_double; - } -} - -pub fn main() { - let mut y: isize = 5; - let x: &mut isize = &mut y; - assert_eq!(lgamma(1.0 as c_double, x), 0.0 as c_double); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2216.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2216.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2216.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2216.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn main() { - let mut x = 0; - - 'foo: loop { - 'bar: loop { - 'quux: loop { - if 1 == 2 { - break 'foo; - } - else { - break 'bar; - } - } - continue 'foo; - } - x = 42; - break; - } - - println!("{}", x); - assert_eq!(x, 42); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22258.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22258.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22258.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22258.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::ops::Add; - -fn f(a: T, b: T) -> ::Output { - a + b -} - -fn main() { - println!("a + b is {}", f::(100f32, 200f32)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22346.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22346.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22346.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22346.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -// This used to cause an ICE because the retslot for the "return" had the wrong type -fn testcase<'a>() -> Box + 'a> { - return Box::new((0..3).map(|i| { return i; })); -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22356.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22356.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22356.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22356.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(type_alias_bounds)] - -// pretty-expanded FIXME #23616 - -use std::marker::PhantomData; - -pub struct Handle(T, I); - -impl Handle { - pub fn get_info(&self) -> &I { - let Handle(_, ref info) = *self; - info - } -} - -pub struct BufferHandle { - raw: RawBufferHandle, - _marker: PhantomData, -} - -impl BufferHandle { - pub fn get_info(&self) -> &String { - self.raw.get_info() - } -} - -pub type RawBufferHandle = Handle<::Buffer, String>; - -pub trait Device { - type Buffer; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22375.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22375.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22375.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22375.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait A> {} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22403.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22403.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22403.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22403.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - let x = Box::new([1, 2, 3]); - let y = x as Box<[i32]>; - println!("y: {:?}", y); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22426.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22426.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22426.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22426.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn main() { - match 42 { - x if x < 7 => (), - _ => () - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22463.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22463.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22463.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22463.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! items { - () => { - type A = (); - fn a() {} - } -} - -trait Foo { - type A; - fn a(); -} - -impl Foo for () { - items!(); -} - -fn main() { - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22471.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22471.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22471.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22471.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(type_alias_bounds)] - -type Foo where T: Copy = Box; - -fn main(){} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22536-copy-mustnt-zero.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22536-copy-mustnt-zero.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22536-copy-mustnt-zero.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22536-copy-mustnt-zero.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for Issue #22536: If a type implements Copy, then -// moving it must not zero the original memory. - - -trait Resources { - type Buffer: Copy; - fn foo(&self) {} -} - -struct BufferHandle { - raw: ::Buffer, -} -impl Copy for BufferHandle {} -impl Clone for BufferHandle { - fn clone(&self) -> BufferHandle { *self } -} - -enum Res {} -impl Resources for Res { - type Buffer = u32; -} - -fn main() { - let b: BufferHandle = BufferHandle { raw: 1 }; - let c = b; - assert_eq!(c.raw, b.raw) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22546.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22546.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22546.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22546.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Parsing patterns with paths with type parameters (issue #22544) - -use std::default::Default; - -#[derive(Default)] -pub struct Foo(T, T); - -impl Foo { - fn foo(&self) { - match *self { - Foo::(ref x, ref y) => println!("Goodbye, World! {} {}", x, y) - } - } -} - -trait Tr { - type U; -} - -impl Tr for Foo { - type U = T; -} - -struct Wrapper { - value: T -} - -fn main() { - let Foo::(a, b) = Default::default(); - - let f = Foo(2,3); - f.foo(); - - let w = Wrapper { value: Foo(10u8, 11u8) }; - match w { - Wrapper::> { value: Foo(10, 11) } => {}, - ::Wrapper::< as Tr>::U> { value: Foo::(11, 16) } => { panic!() }, - _ => { panic!() } - } - - if let None:: = Some(8) { - panic!(); - } - if let None:: { .. } = Some(8) { - panic!(); - } - if let Option::None:: { .. } = Some(8) { - panic!(); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22577.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22577.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22577.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22577.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 -// ignore-cloudabi no std::fs - -use std::{fs, net}; - -fn assert_both() {} -fn assert_send() {} - -fn main() { - assert_both::(); - assert_both::(); - assert_both::(); - assert_both::(); - assert_both::(); - assert_both::(); - - assert_both::(); - assert_both::(); - assert_both::(); - assert_both::(); - assert_both::(); - assert_both::(); - assert_both::(); - assert_both::(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22629.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22629.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22629.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22629.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test transitive analysis for associated types. Collected types -// should be normalized and new obligations generated. - -// pretty-expanded FIXME #23616 - -use std::borrow::{ToOwned, Cow}; - -fn assert_send(_: T) {} - -fn main() { - assert_send(Cow::Borrowed("foo")); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22777.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22777.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22777.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22777.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This test is reduced from libsyntax. It is just checking that we -// can successfully deal with a "deep" structure, which the drop-check -// was hitting a recursion limit on at one point. - -// pretty-expanded FIXME #23616 - -#![allow(non_camel_case_types)] - -pub fn noop_fold_impl_item() -> SmallVector { - loop { } -} - -pub struct SmallVector(P); -pub struct ImplItem(P); - -struct P(Box); - -struct S01_Method(P); -struct S02_Generics(P); -struct S03_TyParam(P); -struct S04_TyParamBound(S05_PolyTraitRef); -struct S05_PolyTraitRef(S06_TraitRef); -struct S06_TraitRef(S07_Path); -struct S07_Path(Vec); -struct S08_PathSegment(S09_GenericArgs); -struct S09_GenericArgs(P); -struct S10_ParenthesizedParameterData(Option>); -struct S11_Ty(P); -struct S12_Expr(P); -struct S13_Block(Vec>); -struct S14_Stmt(P); -struct S15_Decl(P); -struct S16_Local(P); -struct S17_Pat(P); -struct S18_Mac(Vec>); -struct S19_TokenTree(P); -struct S20_Token(P); -struct S21_Nonterminal(P); -struct S22_Item(P); -struct S23_EnumDef(Vec>); -struct S24_Variant(P); -struct S25_VariantKind(P); -struct S26_StructDef(Vec>); -struct S27_StructField(P); -struct S28_StructFieldKind; - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22781.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22781.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22781.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22781.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::collections::HashMap; -use std::collections::hash_map::Entry::Vacant; - -pub fn foo() { - type F = Box; - let mut map: HashMap<(), F> = HashMap::new(); - let x: &mut F = match map.entry(()) { - Vacant(_) => unimplemented!(), - _ => unimplemented!() - }; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22814.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22814.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22814.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22814.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Test {} - -macro_rules! test { -( $($name:ident)+) => ( - impl<$($name: Test),*> Test for ($($name,)*) { - } -) -} - -test!(A B C); - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22828.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22828.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22828.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22828.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test transitive analysis for associated types. Collected types -// should be normalized and new obligations generated. - -// pretty-expanded FIXME #23616 - -trait Foo { - type A; - fn foo(&self) {} -} - -impl Foo for usize { - type A = usize; -} - -struct Bar { inner: T::A } - -fn is_send() {} - -fn main() { - is_send::>(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2284.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2284.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2284.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2284.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait Send { - fn f(&self); -} - -fn f(t: T) { - t.f(); -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22864-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22864-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22864-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22864-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn main() { - struct Fun(F); - let f = Fun(|x| 3*x); - let Fun(g) = f; - println!("{:?}",g(4)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22864-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22864-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22864-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22864-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -pub fn main() { - let f = || || 0; - std::thread::spawn(f()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2288.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2288.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2288.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2288.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -#![feature(box_syntax)] - -trait clam { - fn chowder(&self, y: A); -} - -#[derive(Copy, Clone)] -struct foo { - x: A, -} - -impl clam for foo { - fn chowder(&self, _y: A) { - } -} - -fn foo(b: A) -> foo { - foo { - x: b - } -} - -fn f(x: Box>, a: A) { - x.chowder(a); -} - -pub fn main() { - - let c = foo(42); - let d: Box> = box c as Box>; - f(d, c.x); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22894.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22894.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22894.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22894.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[allow(dead_code)] -static X: &'static str = &*""; -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22992-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22992-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22992-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22992-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct A(B); -struct B; - -use std::ops::Deref; - -impl Deref for A { - type Target = B; - fn deref(&self) -> &B { &self.0 } -} - -impl B { - fn foo(&self) {} -} - -fn main() { - A(B).foo(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22992.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22992.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22992.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-22992.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty issue #37201 - -struct X { val: i32 } -impl std::ops::Deref for X { - type Target = i32; - fn deref(&self) -> &i32 { &self.val } -} - - -trait M { fn m(self); } -impl M for i32 { fn m(self) { println!("i32::m()"); } } -impl M for X { fn m(self) { println!("X::m()"); } } -impl<'a> M for &'a X { fn m(self) { println!("&X::m()"); } } -impl<'a, 'b> M for &'a &'b X { fn m(self) { println!("&&X::m()"); } } -impl<'a, 'b, 'c> M for &'a &'b &'c X { fn m(self) { println!("&&&X::m()"); } } - -trait RefM { fn refm(&self); } -impl RefM for i32 { fn refm(&self) { println!("i32::refm()"); } } -impl RefM for X { fn refm(&self) { println!("X::refm()"); } } -impl<'a> RefM for &'a X { fn refm(&self) { println!("&X::refm()"); } } -impl<'a, 'b> RefM for &'a &'b X { fn refm(&self) { println!("&&X::refm()"); } } -impl<'a, 'b, 'c> RefM for &'a &'b &'c X { fn refm(&self) { println!("&&&X::refm()"); } } - -struct Y { val: i32 } -impl std::ops::Deref for Y { - type Target = i32; - fn deref(&self) -> &i32 { &self.val } -} - -struct Z { val: Y } -impl std::ops::Deref for Z { - type Target = Y; - fn deref(&self) -> &Y { &self.val } -} - -struct A; -impl std::marker::Copy for A {} -impl Clone for A { fn clone(&self) -> Self { *self } } -impl M for A { fn m(self) { println!("A::m()"); } } -impl<'a, 'b, 'c> M for &'a &'b &'c A { fn m(self) { println!("&&&A::m()"); } } -impl RefM for A { fn refm(&self) { println!("A::refm()"); } } -impl<'a, 'b, 'c> RefM for &'a &'b &'c A { fn refm(&self) { println!("&&&A::refm()"); } } - -fn main() { - // I'll use @ to denote left side of the dot operator - (*X{val:42}).m(); // i32::refm() , self == @ - X{val:42}.m(); // X::m() , self == @ - (&X{val:42}).m(); // &X::m() , self == @ - (&&X{val:42}).m(); // &&X::m() , self == @ - (&&&X{val:42}).m(); // &&&X:m() , self == @ - (&&&&X{val:42}).m(); // &&&X::m() , self == *@ - (&&&&&X{val:42}).m(); // &&&X::m() , self == **@ - - (*X{val:42}).refm(); // i32::refm() , self == @ - X{val:42}.refm(); // X::refm() , self == @ - (&X{val:42}).refm(); // X::refm() , self == *@ - (&&X{val:42}).refm(); // &X::refm() , self == *@ - (&&&X{val:42}).refm(); // &&X::refm() , self == *@ - (&&&&X{val:42}).refm(); // &&&X::refm(), self == *@ - (&&&&&X{val:42}).refm(); // &&&X::refm(), self == **@ - - Y{val:42}.refm(); // i32::refm() , self == *@ - Z{val:Y{val:42}}.refm(); // i32::refm() , self == **@ - - A.m(); // A::m() , self == @ - // without the Copy trait, (&A).m() would be a compilation error: - // cannot move out of borrowed content - (&A).m(); // A::m() , self == *@ - (&&A).m(); // &&&A::m() , self == &@ - (&&&A).m(); // &&&A::m() , self == @ - A.refm(); // A::refm() , self == @ - (&A).refm(); // A::refm() , self == *@ - (&&A).refm(); // A::refm() , self == **@ - (&&&A).refm(); // &&&A::refm(), self == @ -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23036.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23036.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23036.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23036.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-cloudabi no std::path - -use std::collections::HashMap; -use std::path::Path; - -fn main() { - let mut map = HashMap::new(); - map.insert(Path::new("a"), 0); - map.get(Path::new("a")); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2311-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2311-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2311-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2311-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - -trait clam { - fn get(self) -> A; -} - -struct foo { - x: A, -} - -impl foo { - pub fn bar>(&self, _c: C) -> B { - panic!(); - } -} - -fn foo(b: A) -> foo { - foo { - x: b - } -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2311.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2311.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2311.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2311.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -trait clam { fn get(self) -> A; } -trait foo { - fn bar>(&self, c: C) -> B; -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2312.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2312.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2312.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2312.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// Testing that the B's are resolved - - -trait clam { fn get(self) -> A; } - -struct foo(isize); - -impl foo { - pub fn bar>(&self, _c: C) -> B { panic!(); } -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2316-c.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2316-c.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2316-c.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2316-c.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue_2316_a.rs -// aux-build:issue_2316_b.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_2316_b; -use issue_2316_b::cloth; - -pub fn main() { - let _c: cloth::fabric = cloth::fabric::calico; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23208.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23208.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23208.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23208.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait TheTrait : TheSuperTrait<::Item> { - type Item; -} - -trait TheSuperTrait { - fn get(&self) -> T; -} - -impl TheTrait for i32 { - type Item = u32; -} - -impl TheSuperTrait for i32 { - fn get(&self) -> u32 { - *self as u32 - } -} - -fn foo>(t: &T) -> u32 { - t.get() -} - -fn main() { - foo::(&22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23261.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23261.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23261.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23261.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Matching on a DST struct should not trigger an LLVM assertion. - -struct Foo { - a: i32, - inner: T -} - -trait Get { - fn get(&self) -> i32; -} - -impl Get for i32 { - fn get(&self) -> i32 { - *self - } -} - -fn check_val(val: &Foo<[u8]>) { - match *val { - Foo { a, .. } => { - assert_eq!(a, 32); - } - } -} - -fn check_dst_val(val: &Foo<[u8]>) { - match *val { - Foo { ref inner, .. } => { - assert_eq!(inner, [1, 2, 3]); - } - } -} - -fn check_both(val: &Foo<[u8]>) { - match *val { - Foo { a, ref inner } => { - assert_eq!(a, 32); - assert_eq!(inner, [1, 2, 3]); - } - } -} - -fn check_trait_obj(val: &Foo) { - match *val { - Foo { a, ref inner } => { - assert_eq!(a, 32); - assert_eq!(inner.get(), 32); - } - } -} - -fn main() { - let foo: &Foo<[u8]> = &Foo { a: 32, inner: [1, 2, 3] }; - check_val(foo); - check_dst_val(foo); - check_both(foo); - - let foo: &Foo = &Foo { a: 32, inner: 32 }; - check_trait_obj(foo); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23304-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23304-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23304-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23304-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(dead_code)] - -#[repr(u8)] -#[allow(dead_code)] -enum ValueType { - DOUBLE = 0x00, - INT32 = 0x01, -} - -#[repr(u32)] -enum ValueTag { - INT32 = 0x1FFF0u32 | (ValueType::INT32 as u32), - X, -} - -#[repr(u64)] -enum ValueShiftedTag { - INT32 = ValueTag::INT32 as u64, - X, -} - -fn main() { - println!("{}", ValueTag::INT32 as u32); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23304-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23304-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23304-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23304-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(dead_code)] - -enum X { A = 42 as isize } - -enum Y { A = X::A as isize } - -fn main() { - let x = X::A; - let x = x as isize; - assert_eq!(x, 42); - assert_eq!(Y::A as isize, 42); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23311.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23311.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23311.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23311.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we do not ICE when pattern matching an array against a slice. - -#![feature(slice_patterns)] - -fn main() { - match "foo".as_bytes() { - b"food" => (), - &[b'f', ..] => (), - _ => () - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23336.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23336.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23336.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23336.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub trait Data { fn doit(&self) {} } -impl Data for T {} -pub trait UnaryLogic { type D: Data; } -impl UnaryLogic for () { type D = i32; } - -pub fn crashes(t: T::D) { - t.doit(); -} - -fn main() { crashes::<()>(0); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23338-ensure-param-drop-order.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23338-ensure-param-drop-order.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23338-ensure-param-drop-order.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23338-ensure-param-drop-order.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,174 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -// ignore-pretty issue #37201 - -// This test is ensuring that parameters are indeed dropped after -// temporaries in a fn body. - -use std::cell::RefCell; - -use self::d::D; - -pub fn main() { - let log = RefCell::new(vec![]); - d::println("created empty log"); - test(&log); - - assert_eq!(&log.borrow()[..], - [ - // created empty log - // +-- Make D(da_0, 0) - // | +-- Make D(de_1, 1) - // | | calling foo - // | | entered foo - // | | +-- Make D(de_2, 2) - // | | | +-- Make D(da_1, 3) - // | | | | +-- Make D(de_3, 4) - // | | | | | +-- Make D(de_4, 5) - 3, // | | | +-- Drop D(da_1, 3) - // | | | | | - 4, // | | | +-- Drop D(de_3, 4) - // | | | | - // | | | | eval tail of foo - // | | | +-- Make D(de_5, 6) - // | | | | +-- Make D(de_6, 7) - 5, // | | | | | +-- Drop D(de_4, 5) - // | | | | | - 2, // | | +-- Drop D(de_2, 2) - // | | | | - 6, // | | +-- Drop D(de_5, 6) - // | | | - 1, // | +-- Drop D(de_1, 1) - // | | - 0, // +-- Drop D(da_0, 0) - // | - // | result D(de_6, 7) - 7 // +-- Drop D(de_6, 7) - - ]); -} - -fn test<'a>(log: d::Log<'a>) { - let da = D::new("da", 0, log); - let de = D::new("de", 1, log); - d::println("calling foo"); - let result = foo(da, de); - d::println(&format!("result {}", result)); -} - -fn foo<'a>(da0: D<'a>, de1: D<'a>) -> D<'a> { - d::println("entered foo"); - let de2 = de1.incr(); // creates D(de_2, 2) - let de4 = { - let _da1 = da0.incr(); // creates D(da_1, 3) - de2.incr().incr() // creates D(de_3, 4) and D(de_4, 5) - }; - d::println("eval tail of foo"); - de4.incr().incr() // creates D(de_5, 6) and D(de_6, 7) -} - -// This module provides simultaneous printouts of the dynamic extents -// of all of the D values, in addition to logging the order that each -// is dropped. - -const PREF_INDENT: u32 = 16; - -pub mod d { - #![allow(unused_parens)] - use std::fmt; - use std::mem; - use std::cell::RefCell; - - static mut counter: u32 = 0; - static mut trails: u64 = 0; - - pub type Log<'a> = &'a RefCell>; - - pub fn current_width() -> u32 { - unsafe { max_width() - trails.leading_zeros() } - } - - pub fn max_width() -> u32 { - unsafe { - (mem::size_of_val(&trails)*8) as u32 - } - } - - pub fn indent_println(my_trails: u32, s: &str) { - let mut indent: String = String::new(); - for i in 0..my_trails { - unsafe { - if trails & (1 << i) != 0 { - indent = indent + "| "; - } else { - indent = indent + " "; - } - } - } - println!("{}{}", indent, s); - } - - pub fn println(s: &str) { - indent_println(super::PREF_INDENT, s); - } - - fn first_avail() -> u32 { - unsafe { - for i in 0..64 { - if trails & (1 << i) == 0 { - return i; - } - } - } - panic!("exhausted trails"); - } - - pub struct D<'a> { - name: &'static str, i: u32, uid: u32, trail: u32, log: Log<'a> - } - - impl<'a> fmt::Display for D<'a> { - fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { - write!(w, "D({}_{}, {})", self.name, self.i, self.uid) - } - } - - impl<'a> D<'a> { - pub fn new(name: &'static str, i: u32, log: Log<'a>) -> D<'a> { - unsafe { - let trail = first_avail(); - let ctr = counter; - counter += 1; - trails |= (1 << trail); - let ret = D { - name: name, i: i, log: log, uid: ctr, trail: trail - }; - indent_println(trail, &format!("+-- Make {}", ret)); - ret - } - } - pub fn incr(&self) -> D<'a> { - D::new(self.name, self.i + 1, self.log) - } - } - - impl<'a> Drop for D<'a> { - fn drop(&mut self) { - unsafe { trails &= !(1 << self.trail); }; - self.log.borrow_mut().push(self.uid); - indent_println(self.trail, &format!("+-- Drop {}", self)); - indent_println(::PREF_INDENT, ""); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23338-params-outlive-temps-of-body.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23338-params-outlive-temps-of-body.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23338-params-outlive-temps-of-body.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23338-params-outlive-temps-of-body.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This is largely checking that we now accept code where temp values -// are borrowing from the input parameters (the `foo` case below). -// -// Compare to run-pass/issue-23338-params-outlive-temps-of-body.rs -// -// (The `foo2` case is just for parity with the above test, which -// shows what happens when you move the `y`-binding to the inside of -// the inner block.) - -use std::cell::RefCell; - -fn foo(x: RefCell) -> String { - x.borrow().clone() -} - -fn foo2(x: RefCell) -> String { - let y = x; - let ret = { - y.borrow().clone() - }; - ret -} - -pub fn main() { - let r = RefCell::new(format!("data")); - assert_eq!(foo(r), "data"); - let r = RefCell::new(format!("data")); - assert_eq!(foo2(r), "data"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23406.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23406.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23406.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23406.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Inner { - type T; -} - -impl<'a> Inner for &'a i32 { - type T = i32; -} - -fn f<'a>(x: &'a i32) -> <&'a i32 as Inner>::T { - *x -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23433.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23433.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23433.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23433.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Don't fail if we encounter a NonNull where T is an unsized type - -use std::ptr::NonNull; - -fn main() { - let mut a = [0u8; 5]; - let b: Option> = Some(NonNull::from(&mut a)); - match b { - Some(_) => println!("Got `Some`"), - None => panic!("Unexpected `None`"), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23442.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23442.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23442.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23442.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::marker::PhantomData; - -pub struct UnionedKeys<'a,K> - where K: UnifyKey + 'a -{ - table: &'a mut UnificationTable, - root_key: K, - stack: Vec, -} - -pub trait UnifyKey { - type Value; -} - -pub struct UnificationTable { - values: Delegate, -} - -pub struct Delegate(PhantomData); - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23477.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23477.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23477.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23477.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compiler-flags: -g - -pub struct Dst { - pub a: (), - pub b: (), - pub data: [u8], -} - -pub unsafe fn borrow(bytes: &[u8]) -> &Dst { - let dst: &Dst = std::mem::transmute((bytes.as_ptr(), bytes.len())); - dst -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23485.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23485.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23485.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23485.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test for an ICE that occurred when a default method implementation -// was applied to a type that did not meet the prerequisites. The -// problem occurred specifically because normalizing -// `Self::Item::Target` was impossible in this case. - -use std::boxed::Box; -use std::marker::Sized; -use std::clone::Clone; -use std::ops::Deref; -use std::option::Option; -use std::option::Option::{Some,None}; - -trait Iterator { - type Item; - - fn next(&mut self) -> Option; - - fn clone_first(mut self) -> Option<::Target> where - Self: Sized, - Self::Item: Deref, - ::Target: Clone, - { - self.next().map(|x| x.clone()) - } -} - -struct Counter { - value: i32 -} - -struct Token { - value: i32 -} - -impl Iterator for Counter { - type Item = Token; - - fn next(&mut self) -> Option { - let x = self.value; - self.value += 1; - Some(Token { value: x }) - } -} - -fn main() { - let mut x: Box> = Box::new(Counter { value: 22 }); - assert_eq!(x.next().unwrap().value, 22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23491.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23491.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23491.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23491.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -struct Node(T); - -fn main() { - let x: Box> = box Node([]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23550.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23550.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23550.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23550.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(core_intrinsics)] -#![allow(warnings)] - -use std::intrinsics; - -#[derive(Copy, Clone)] -struct Wrap(i64); - -// These volatile intrinsics used to cause an ICE - -unsafe fn test_bool(p: &mut bool, v: bool) { - intrinsics::volatile_load(p); - intrinsics::volatile_store(p, v); -} - -unsafe fn test_immediate_fca(p: &mut Wrap, v: Wrap) { - intrinsics::volatile_load(p); - intrinsics::volatile_store(p, v); -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23611-enum-swap-in-drop.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23611-enum-swap-in-drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23611-enum-swap-in-drop.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23611-enum-swap-in-drop.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,268 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -// Issue 23611: this test is ensuring that, for an instance `X` of the -// enum `E`, if you swap in a different variant during the execution -// of the `::drop`, then the appropriate substructure will -// be torn down after the `::drop` method returns. - -use std::cell::RefCell; -use std::mem; - -use self::d::D; - -pub fn main() { - let log = RefCell::new(vec![]); - d::println("created empty log"); - test(&log); - - // println!("log: {:?}", &log.borrow()[..]); - assert_eq!( - &log.borrow()[..], - [ - // created empty log - // +-- Make D(test_1, 10000000) - // | +-- Make D(g_b_5, 50000001) - // | | in g_B(b2b0) from E::drop, b=b4b0 - // | +-- Drop D(g_b_5, 50000001) - 50000001, - // | - // | +-- Make D(drop_6, 60000002) - // | | +-- Make D(g_b_5, 50000003) - // | | | in g_B(b2b0) from E::drop, b=b4b1 - // | | +-- Drop D(g_b_5, 50000003) - 50000003, - // | | - // | | +-- Make D(GaspB::drop_3, 30000004) - // | | | +-- Make D(g_b_5, 50000005) - // | | | | in g_B(b4b2) from GaspB::drop - // | | | +-- Drop D(g_b_5, 50000005) - 50000005, - // | | | - // | | +-- Drop D(GaspB::drop_3, 30000004) - 30000004, - // | | - // +-- Drop D(test_1, 10000000) - 10000000, - // | - // +-- Make D(GaspA::drop_2, 20000006) - // | | +-- Make D(f_a_4, 40000007) - // | | | in f_A(a3a0) from GaspA::drop - // | | +-- Drop D(f_a_4, 40000007) - 40000007, - // | | - // +-- Drop D(GaspA::drop_2, 20000006) - 20000006, - // | - // +-- Drop D(drop_6, 60000002) - 60000002 - // - ]); - - // For reference purposes, the old (incorrect) behavior would produce the following - // output, which you can compare to the above: - // - // created empty log - // +-- Make D(test_1, 10000000) - // | +-- Make D(g_b_5, 50000001) - // | | in g_B(b2b0) from E::drop, b=b4b0 - // | +-- Drop D(g_b_5, 50000001) - // | - // | +-- Make D(drop_6, 60000002) - // | | +-- Make D(g_b_5, 50000003) - // | | | in g_B(b2b0) from E::drop, b=b4b1 - // | | +-- Drop D(g_b_5, 50000003) - // | | - // | | +-- Make D(GaspB::drop_3, 30000004) - // | | | +-- Make D(g_b_5, 50000005) - // | | | | in g_B(b4b2) from GaspB::drop - // | | | +-- Drop D(g_b_5, 50000005) - // | | | - // | | +-- Drop D(GaspB::drop_3, 30000004) - // | | - // +-- Drop D(test_1, 10000000) - // | - // +-- Make D(GaspB::drop_3, 30000006) - // | | +-- Make D(f_a_4, 40000007) - // | | | in f_A(a3a0) from GaspB::drop - // | | +-- Drop D(f_a_4, 40000007) - // | | - // +-- Drop D(GaspB::drop_3, 30000006) - // | - // +-- Drop D(drop_6, 60000002) - - // Note that this calls f_A from GaspB::drop (and thus creates a D - // with a uid incorporating the origin of GaspB's drop that - // surrounds the f_A invocation), but the code as written only - // ever hands f_A off to instances of GaspA, and thus one should - // be able to prove the invariant that f_A is *only* invoked from - // from an instance of GaspA (either via the GaspA drop - // implementation or the E drop implementaton). Yet the old (bad) - // behavior allowed a call to f_A to leak in while we are tearing - // down a value of type GaspB. -} - -fn test<'a>(log: d::Log<'a>) { - let _e = E::B(GaspB(g_b, 0xB4B0, log, D::new("test", 1, log)), true); -} - -struct GaspA<'a>(for <'b> fn(u32, &'b str, d::Log<'a>), u32, d::Log<'a>, d::D<'a>); -struct GaspB<'a>(for <'b> fn(u32, &'b str, d::Log<'a>), u32, d::Log<'a>, d::D<'a>); - -impl<'a> Drop for GaspA<'a> { - fn drop(&mut self) { - let _d = d::D::new("GaspA::drop", 2, self.2); - (self.0)(self.1, "GaspA::drop", self.2); - } -} - -impl<'a> Drop for GaspB<'a> { - fn drop(&mut self) { - let _d = d::D::new("GaspB::drop", 3, self.2); - (self.0)(self.1, "GaspB::drop", self.2); - } -} - -enum E<'a> { - A(GaspA<'a>, bool), B(GaspB<'a>, bool), -} - -fn f_a(x: u32, ctxt: &str, log: d::Log) { - let _d = d::D::new("f_a", 4, log); - d::println(&format!("in f_A({:x}) from {}", x, ctxt)); -} -fn g_b(y: u32, ctxt: &str, log: d::Log) { - let _d = d::D::new("g_b", 5, log); - d::println(&format!("in g_B({:x}) from {}", y, ctxt)); -} - -impl<'a> Drop for E<'a> { - fn drop(&mut self) { - let (do_drop, log) = match *self { - E::A(GaspA(ref f, ref mut val_a, log, ref _d_a), ref mut do_drop) => { - f(0xA1A0, &format!("E::drop, a={:x}", val_a), log); - *val_a += 1; - // swap in do_drop := false to avoid infinite dtor regress - (mem::replace(do_drop, false), log) - } - E::B(GaspB(ref g, ref mut val_b, log, ref _d_b), ref mut do_drop) => { - g(0xB2B0, &format!("E::drop, b={:x}", val_b), log); - *val_b += 1; - // swap in do_drop := false to avoid infinite dtor regress - (mem::replace(do_drop, false), log) - } - }; - - if do_drop { - mem::replace(self, E::A(GaspA(f_a, 0xA3A0, log, D::new("drop", 6, log)), true)); - } - } -} - -// This module provides simultaneous printouts of the dynamic extents -// of all of the D values, in addition to logging the order that each -// is dropped. -// -// This code is similar to a support code module embedded within -// test/run-pass/issue-123338-ensure-param-drop-order.rs; however, -// that (slightly simpler) code only identifies objects in the log via -// (creation) time-stamps; this incorporates both timestamping and the -// point of origin within the source code into the unique ID (uid). - -const PREF_INDENT: u32 = 20; - -pub mod d { - #![allow(unused_parens)] - use std::fmt; - use std::mem; - use std::cell::RefCell; - - static mut counter: u16 = 0; - static mut trails: u64 = 0; - - pub type Log<'a> = &'a RefCell>; - - pub fn current_width() -> u32 { - unsafe { max_width() - trails.leading_zeros() } - } - - pub fn max_width() -> u32 { - unsafe { - (mem::size_of_val(&trails)*8) as u32 - } - } - - pub fn indent_println(my_trails: u32, s: &str) { - let mut indent: String = String::new(); - for i in 0..my_trails { - unsafe { - if trails & (1 << i) != 0 { - indent = indent + "| "; - } else { - indent = indent + " "; - } - } - } - println!("{}{}", indent, s); - } - - pub fn println(s: &str) { - indent_println(super::PREF_INDENT, s); - } - - fn first_avail() -> u32 { - unsafe { - for i in 0..64 { - if trails & (1 << i) == 0 { - return i; - } - } - } - panic!("exhausted trails"); - } - - pub struct D<'a> { - name: &'static str, i: u8, uid: u32, trail: u32, log: Log<'a> - } - - impl<'a> fmt::Display for D<'a> { - fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { - write!(w, "D({}_{}, {})", self.name, self.i, self.uid) - } - } - - impl<'a> D<'a> { - pub fn new(name: &'static str, i: u8, log: Log<'a>) -> D<'a> { - unsafe { - let trail = first_avail(); - let ctr = ((i as u32) * 10_000_000) + (counter as u32); - counter += 1; - trails |= (1 << trail); - let ret = D { - name: name, i: i, log: log, uid: ctr, trail: trail - }; - indent_println(trail, &format!("+-- Make {}", ret)); - ret - } - } - } - - impl<'a> Drop for D<'a> { - fn drop(&mut self) { - unsafe { trails &= !(1 << self.trail); }; - self.log.borrow_mut().push(self.uid); - indent_println(self.trail, &format!("+-- Drop {}", self)); - indent_println(::PREF_INDENT, ""); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23649-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23649-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23649-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23649-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::mem; - -pub struct X([u8]); - -fn _f(x: &X) -> usize { match *x { X(ref x) => { x.len() } } } - -fn main() { - let b: &[u8] = &[11; 42]; - let v: &X = unsafe { mem::transmute(b) }; - assert_eq!(_f(v), 42); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23649-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23649-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23649-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23649-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-cloudabi no std::path - -use std::collections::HashMap; -use std::path::{Path, PathBuf}; - -fn main() { - let m: HashMap = HashMap::new(); - let k = Path::new("foo"); - println!("{:?}", m.get(k)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23649-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23649-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23649-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23649-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(PartialEq)] -struct Slice { slice: [u8] } - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23699.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23699.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23699.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23699.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn gimme_a_raw_pointer(_: *const T) { } - -fn test(t: T) { } - -fn main() { - // Clearly `pointer` must be of type `*const ()`. - let pointer = &() as *const _; - gimme_a_raw_pointer(pointer); - - let t = test as fn (i32); - t(0i32); -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23781.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23781.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23781.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23781.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::fmt; - -struct Foo; -impl fmt::Debug for Foo { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - println!("::fmt()"); - - write!(fmt, "") - } -} - -fn test1() { - let foo_str = format!("{:?}", Foo); - - println!("{}", foo_str); -} - -fn test2() { - println!("{:?}", Foo); -} - -fn main() { - // This works fine - test1(); - - // This fails - test2(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23808.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23808.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23808.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23808.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![deny(dead_code)] - -// use different types / traits to test all combinations - -trait Const { - const C: (); -} - -trait StaticFn { - fn sfn(); -} - -struct ConstStruct; -struct StaticFnStruct; - -enum ConstEnum {} -enum StaticFnEnum {} - -struct AliasedConstStruct; -struct AliasedStaticFnStruct; - -enum AliasedConstEnum {} -enum AliasedStaticFnEnum {} - -type AliasConstStruct = AliasedConstStruct; -type AliasStaticFnStruct = AliasedStaticFnStruct; -type AliasConstEnum = AliasedConstEnum; -type AliasStaticFnEnum = AliasedStaticFnEnum; - -macro_rules! impl_Const {($($T:ident),*) => {$( - impl Const for $T { - const C: () = (); - } -)*}} - -macro_rules! impl_StaticFn {($($T:ident),*) => {$( - impl StaticFn for $T { - fn sfn() {} - } -)*}} - -impl_Const!(ConstStruct, ConstEnum, AliasedConstStruct, AliasedConstEnum); -impl_StaticFn!(StaticFnStruct, StaticFnEnum, AliasedStaticFnStruct, AliasedStaticFnEnum); - -fn main() { - let _ = ConstStruct::C; - let _ = ConstEnum::C; - - StaticFnStruct::sfn(); - StaticFnEnum::sfn(); - - let _ = AliasConstStruct::C; - let _ = AliasConstEnum::C; - - AliasStaticFnStruct::sfn(); - AliasStaticFnEnum::sfn(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2380-b.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2380-b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2380-b.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2380-b.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-2380.rs - -// pretty-expanded FIXME #23616 - -extern crate a; - -pub fn main() { - a::f::<()>(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23825.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23825.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23825.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23825.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Stringify { - fn to_string(&self) -> String; -} - -impl Stringify for u32 { - fn to_string(&self) -> String { format!("u32: {}", *self) } -} - -impl Stringify for f32 { - fn to_string(&self) -> String { format!("f32: {}", *self) } -} - -fn print(x: T) -> String { - x.to_string() -} - -fn main() { - assert_eq!(&print(5), "u32: 5"); - assert_eq!(&print(5.0), "f32: 5"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23833.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23833.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23833.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23833.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::fmt; -use std::{i8, i16, i32, i64, isize}; -use std::{u8, u16, u32, u64, usize}; - -const A_I8_T - : [u32; (i8::MAX as i8 - 1i8) as usize] - = [0; (i8::MAX as usize) - 1]; - -fn main() { - foo(&A_I8_T[..]); -} - -fn foo(x: T) { - println!("{:?}", x); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2383.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2383.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2383.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2383.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -use std::collections::VecDeque; - -pub fn main() { - let mut q = VecDeque::new(); - q.push_front(10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23891.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23891.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23891.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23891.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! id { - ($s: pat) => ($s); -} - -fn main() { - match (Some(123), Some(456)) { - (id!(Some(a)), _) | (_, id!(Some(a))) => println!("{}", a), - _ => (), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23898.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23898.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23898.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23898.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// Note: This test was used to demonstrate #5873 (now #23898). - -enum State { ST_NULL, ST_WHITESPACE } - -fn main() { - [State::ST_NULL; (State::ST_WHITESPACE as usize)]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23958.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23958.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23958.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23958.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Collection where for<'a> &'a Self: IntoIterator { - fn my_iter(&self) -> <&Self as IntoIterator>::IntoIter { - self.into_iter() - } -} - -impl Collection for [T] { } - -fn main() { - let v = [0usize]; - let _ = v.my_iter(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23968-const-not-overflow.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23968-const-not-overflow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23968-const-not-overflow.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23968-const-not-overflow.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -const U8_MAX_HALF: u8 = !0u8 / 2; -const U16_MAX_HALF: u16 = !0u16 / 2; -const U32_MAX_HALF: u32 = !0u32 / 2; -const U64_MAX_HALF: u64 = !0u64 / 2; - -fn main() { - assert_eq!(U8_MAX_HALF, 0x7f); - assert_eq!(U16_MAX_HALF, 0x7fff); - assert_eq!(U32_MAX_HALF, 0x7fff_ffff); - assert_eq!(U64_MAX_HALF, 0x7fff_ffff_ffff_ffff); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23992.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23992.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23992.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-23992.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub struct Outer(T); -pub struct Inner<'a> { value: &'a bool } - -pub trait Trait { - type Error; - fn ready(self) -> Self::Error; -} - -impl<'a> Trait for Inner<'a> { - type Error = Outer>; - fn ready(self) -> Outer> { Outer(self) } -} - -fn main() { - let value = true; - let inner = Inner { value: &value }; - assert_eq!(inner.ready().0.value, &value); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24085.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24085.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24085.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24085.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #24085. Errors were occurring in region -// inference due to the requirement that `'a:b'`, which was getting -// incorrectly codegened in connection with the closure below. - -#[derive(Copy,Clone)] -struct Path<'a:'b, 'b> { - x: &'a i32, - tail: Option<&'b Path<'a, 'b>> -} - -#[allow(dead_code, unconditional_recursion)] -fn foo<'a,'b,F>(p: Path<'a, 'b>, mut f: F) - where F: for<'c> FnMut(Path<'a, 'c>) { - foo(p, |x| f(x)) -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24086.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24086.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24086.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24086.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub struct Registry<'a> { - listener: &'a mut (), -} - -pub struct Listener<'a> { - pub announce: Option>, - pub remove: Option>, -} - -impl<'a> Drop for Registry<'a> { - fn drop(&mut self) {} -} - -fn main() { - let mut registry_listener = Listener { - announce: None, - remove: None, - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2414-c.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2414-c.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2414-c.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2414-c.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-2414-a.rs -// aux-build:issue-2414-b.rs - -// pretty-expanded FIXME #23616 - -extern crate b; - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24161.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24161.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24161.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24161.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Copy,Clone)] -struct Functions { - a: fn(u32) -> u32, - b: extern "C" fn(u32) -> u32, - c: unsafe fn(u32) -> u32, - d: unsafe extern "C" fn(u32) -> u32 -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24227.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24227.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24227.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24227.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This resulted in an ICE. Test for future-proofing -// Issue #24227 - -#![allow(unused)] - -struct Foo<'a> { - x: &'a u8 -} - -impl<'a> Foo<'a> { - fn foo() { - let mut tmp: Self; - } - -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2428.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2428.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2428.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2428.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - - -pub fn main() { - let _foo = 100; - const quux: isize = 5; - - enum Stuff { - Bar = quux - } - - assert_eq!(Stuff::Bar as isize, quux); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24308.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24308.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24308.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24308.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub trait Foo { - fn method1() {} - fn method2(); -} - -struct Slice<'a, T: 'a>(&'a [T]); - -impl<'a, T: 'a> Foo for Slice<'a, T> { - fn method2() { - ::method1(); - } -} - -fn main() { - as Foo>::method2(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24313.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24313.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24313.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24313.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-cloudabi no processes -// ignore-emscripten no threads - -use std::thread; -use std::env; -use std::process::Command; - -struct Handle(i32); - -impl Drop for Handle { - fn drop(&mut self) { panic!(); } -} - -thread_local!(static HANDLE: Handle = Handle(0)); - -fn main() { - let args = env::args().collect::>(); - if args.len() == 1 { - let out = Command::new(&args[0]).arg("test").output().unwrap(); - let stderr = std::str::from_utf8(&out.stderr).unwrap(); - assert!(stderr.contains("panicked at 'explicit panic'"), - "bad failure message:\n{}\n", stderr); - } else { - // TLS dtors are not always run on process exit - thread::spawn(|| { - HANDLE.with(|h| { - println!("{}", h.0); - }); - }).join().unwrap(); - } -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24353.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24353.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24353.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24353.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - return (); - - let x = (); - x -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24389.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24389.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24389.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24389.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(dead_code)] - -struct Foo; - -impl Foo { - fn new() -> Self { Foo } - fn bar() { Self::new(); } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24434.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24434.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24434.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24434.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags:--cfg set1 - -#![cfg_attr(set1, feature(custom_attribute))] - -#![foobar] -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2445-b.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2445-b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2445-b.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2445-b.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -struct c1 { - x: T, -} - -impl c1 { - pub fn f1(&self, _x: isize) { - } -} - -fn c1(x: T) -> c1 { - c1 { - x: x - } -} - -impl c1 { - pub fn f2(&self, _x: isize) { - } -} - - -pub fn main() { - c1::(3).f1(4); - c1::(3).f2(4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2445.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2445.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2445.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2445.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -struct c1 { - x: T, -} - -impl c1 { - pub fn f1(&self, _x: T) {} -} - -fn c1(x: T) -> c1 { - c1 { - x: x - } -} - -impl c1 { - pub fn f2(&self, _x: T) {} -} - - -pub fn main() { - c1::(3).f1(4); - c1::(3).f2(4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24533.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24533.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24533.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24533.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::slice::Iter; -use std::io::{Error, ErrorKind, Result}; -use std::vec::*; - -fn foo(it: &mut Iter) -> Result { - Ok(*it.next().unwrap()) -} - -fn bar() -> Result { - let data: Vec = Vec::new(); - - if true { - return Err(Error::new(ErrorKind::NotFound, "msg")); - } - - let mut it = data.iter(); - foo(&mut it) -} - -fn main() { - bar(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24535-allow-mutable-borrow-in-match-guard.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24535-allow-mutable-borrow-in-match-guard.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24535-allow-mutable-borrow-in-match-guard.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24535-allow-mutable-borrow-in-match-guard.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This test illustrates that under NLL, we can remove our overly -// conservative approach for disallowing mutations of match inputs. - -// See further discussion on rust-lang/rust#24535 and -// rust-lang/rfcs#1006. - -// compile-flags: -Z disable-ast-check-for-mutation-in-guard - -#![feature(nll)] - -fn main() { - rust_issue_24535(); - rfcs_issue_1006_1(); - rfcs_issue_1006_2(); -} - -fn rust_issue_24535() { - fn compare(a: &u8, b: &mut u8) -> bool { - a == b - } - - let a = 3u8; - - match a { - 0 => panic!("nope"), - 3 if compare(&a, &mut 3) => (), - _ => panic!("nope"), - } -} - -fn rfcs_issue_1006_1() { - let v = vec!["1".to_string(), "2".to_string(), "3".to_string()]; - match Some(&v) { - Some(iv) if iv.iter().any(|x| &x[..]=="2") => true, - _ => panic!("nope"), - }; -} - -fn rfcs_issue_1006_2() { - #[inline(always)] - fn check<'a, I: Iterator>(mut i: I) -> bool { - i.any(|&x| x == 2) - } - - let slice = [1, 2, 3]; - - match 42 { - _ if slice.iter().any(|&x| x == 2) => { true }, - _ => { panic!("nope"); } - }; - - // (This match is just illustrating how easy it was to circumvent - // the checking performed for the previous `match`.) - match 42 { - _ if check(slice.iter()) => { true }, - _ => { panic!("nope"); } - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24589.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24589.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24589.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24589.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub struct _X([u8]); - -impl std::ops::Deref for _X { - type Target = [u8]; - - fn deref(&self) -> &[u8] { - &self.0 - } -} - -pub fn _g(x: &_X) -> &[u8] { - x -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2463.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2463.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2463.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2463.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -struct Pair { f: isize, g: isize } - -pub fn main() { - - let x = Pair { - f: 0, - g: 0, - }; - - let _y = Pair { - f: 1, - g: 1, - .. x - }; - - let _z = Pair { - f: 1, - .. x - }; - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue24687-embed-debuginfo/auxiliary/issue24687_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue24687-embed-debuginfo/auxiliary/issue24687_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue24687-embed-debuginfo/auxiliary/issue24687_lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue24687-embed-debuginfo/auxiliary/issue24687_lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] - -// This is a file that pulls in a separate file as a submodule, where -// that separate file has many multi-byte characters, to try to -// encourage the compiler to trip on them. - -mod issue24687_mbcs_in_comments; - -pub use issue24687_mbcs_in_comments::D; - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue24687-embed-debuginfo/auxiliary/issue24687_mbcs_in_comments.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue24687-embed-debuginfo/auxiliary/issue24687_mbcs_in_comments.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue24687-embed-debuginfo/auxiliary/issue24687_mbcs_in_comments.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue24687-embed-debuginfo/auxiliary/issue24687_mbcs_in_comments.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::fmt; - -// This ia file with many multi-byte characters, to try to encourage -// the compiler to trip on them. The Drop implementation below will -// need to have its source location embedded into the debug info for -// the output file. - -// αααααααααααααααααααααααααααααααααααααααααααααααααααααααααααααααααααααα -// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ -// γγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγγ -// δδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδδ -// εεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεεε - -// ζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζζ -// ηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηηη -// θθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθθ -// ιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιιι -// κκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκκ - -pub struct D(pub X); - -impl Drop for D { - fn drop(&mut self) { - // λλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλ - println!("Dropping D({:?})", self.0); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue24687-embed-debuginfo/main.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue24687-embed-debuginfo/main.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue24687-embed-debuginfo/main.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue24687-embed-debuginfo/main.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue24687_lib.rs -// compile-flags:-g - -extern crate issue24687_lib as d; - -fn main() { - // Create a d, which has a destructor whose body will be codegen'ed - // into the generated code here, and thus the local debuginfo will - // need references into the original source locations from - // `importer` above. - let _d = d::D("Hi"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2472.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2472.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2472.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2472.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue_2472_b.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_2472_b; - -use issue_2472_b::{S, T}; - -pub fn main() { - let s = S(()); - s.foo(); - s.bar(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24779.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24779.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24779.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24779.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - assert_eq!((||||42)()(), 42); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24805-dropck-itemless.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24805-dropck-itemless.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24805-dropck-itemless.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24805-dropck-itemless.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(deprecated)] - -// Check that item-less traits do not cause dropck to inject extra -// region constraints. - -#![allow(non_camel_case_types)] - -#![feature(dropck_parametricity)] - -trait UserDefined { } - -impl UserDefined for i32 { } -impl<'a, T> UserDefined for &'a T { } - -// e.g. `impl_drop!(Send, D_Send)` expands to: -// ```rust -// struct D_Send(T); -// impl Drop for D_Send { fn drop(&mut self) { } } -// ``` -macro_rules! impl_drop { - ($Bound:ident, $Id:ident) => { - struct $Id(T); - impl Drop for $Id { - #[unsafe_destructor_blind_to_params] - fn drop(&mut self) { } - } - } -} - -impl_drop!{Send, D_Send} -impl_drop!{Sized, D_Sized} - -// See note below regarding Issue 24895 -// impl_drop!{Copy, D_Copy} - -impl_drop!{Sync, D_Sync} -impl_drop!{UserDefined, D_UserDefined} - -macro_rules! body { - ($id:ident) => { { - // `_d` and `d1` are assigned the *same* lifetime by region inference ... - let (_d, d1); - - d1 = $id(1); - // ... we store a reference to `d1` within `_d` ... - _d = $id(&d1); - - // ... a *conservative* dropck will thus complain, because it - // thinks Drop of _d could access the already dropped `d1`. - } } -} - -fn f_send() { body!(D_Send) } -fn f_sized() { body!(D_Sized) } -fn f_sync() { body!(D_Sync) } - -// Issue 24895: Copy: Clone implies `impl Drop for ...` can -// access a user-defined clone() method, which causes this test case -// to fail. -// -// If 24895 is resolved by removing the `Copy: Clone` relationship, -// then this definition and the call below should be uncommented. If -// it is resolved by deciding to keep the `Copy: Clone` relationship, -// then this comment and the associated bits of code can all be -// removed. - -// fn f_copy() { body!(D_Copy) } - -fn f_userdefined() { body!(D_UserDefined) } - -fn main() { - f_send(); - f_sized(); - // See note above regarding Issue 24895. - // f_copy(); - f_sync(); - f_userdefined(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2487-a.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2487-a.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2487-a.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2487-a.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -struct socket { - sock: isize, - -} - -impl Drop for socket { - fn drop(&mut self) {} -} - -impl socket { - pub fn set_identity(&self) { - closure(|| setsockopt_bytes(self.sock.clone())) - } -} - -fn socket() -> socket { - socket { - sock: 1 - } -} - -fn closure(f: F) where F: FnOnce() { f() } - -fn setsockopt_bytes(_sock: isize) { } - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24945-repeat-dash-opts.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24945-repeat-dash-opts.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24945-repeat-dash-opts.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24945-repeat-dash-opts.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This test is just checking that we continue to accept `-g -g -O -O` -// as options to the compiler. - -// compile-flags:-g -g -O -O - -fn main() { - assert_eq!(1, 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24947.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24947.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24947.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24947.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// #24947 ICE using a trait-associated const in an array size - - -struct Foo; - -impl Foo { - const SIZE: usize = 8; -} - -trait Bar { - const BAR_SIZE: usize; -} - -impl Bar for Foo { - const BAR_SIZE: usize = 12; -} - -#[allow(unused_variables)] -fn main() { - let w: [u8; 12] = [0u8; ::BAR_SIZE]; - let x: [u8; 12] = [0u8; ::BAR_SIZE]; - let y: [u8; 8] = [0u8; ::SIZE]; - let z: [u8; 8] = [0u8; Foo::SIZE]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24954.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24954.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24954.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-24954.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! foo { - ($y:expr) => ({ - $y = 2; - }) -} - -#[allow(unused_variables)] -#[allow(unused_assignments)] -fn main() { - let mut x = 1; - foo!(x); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2502.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2502.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2502.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2502.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - -// pretty-expanded FIXME #23616 - -struct font<'a> { - fontbuf: &'a Vec , -} - -impl<'a> font<'a> { - pub fn buf(&self) -> &'a Vec { - self.fontbuf - } -} - -fn font(fontbuf: &Vec ) -> font { - font { - fontbuf: fontbuf - } -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25089.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25089.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25089.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25089.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::thread; - -struct Foo(i32); - -impl Drop for Foo { - fn drop(&mut self) { - static mut DROPPED: bool = false; - unsafe { - assert!(!DROPPED); - DROPPED = true; - } - } -} - -struct Empty; - -fn empty() -> Empty { Empty } - -fn should_panic(_: Foo, _: Empty) { - panic!("test panic"); -} - -fn test() { - should_panic(Foo(1), empty()); -} - -fn main() { - let ret = thread::spawn(test).join(); - assert!(ret.is_err()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25145.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25145.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25145.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25145.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct S; - -impl S { - const N: usize = 3; -} - -static STUFF: [u8; S::N] = [0; S::N]; - -fn main() { - assert_eq!(STUFF, [0; 3]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25180.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25180.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25180.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25180.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -const x: &'static Fn() = &|| println!("ICE here"); - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25185.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25185.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25185.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25185.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-25185-1.rs -// aux-build:issue-25185-2.rs -// ignore-wasm32-bare no libc for ffi testing - -extern crate issue_25185_2; - -fn main() { - let x = unsafe { - issue_25185_2::rust_dbg_extern_identity_u32(1) - }; - assert_eq!(x, 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2526-a.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2526-a.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2526-a.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2526-a.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-2526.rs - -// pretty-expanded FIXME #23616 - -#![allow(unused_imports)] - -extern crate issue_2526; -use issue_2526::*; - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25279.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25279.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25279.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25279.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct S<'a>(&'a ()); - -impl<'a> S<'a> { - fn foo(self) -> &'a () { - ::bar(self) - } - - fn bar(self) -> &'a () { - self.0 - } -} - -fn main() { - S(&()).foo(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25339.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25339.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25339.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25339.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(associated_type_defaults)] - -use std::marker::PhantomData; - -pub trait Routing { - type Output; - fn resolve(&self, input: I); -} - -pub trait ToRouting { - type Input; - type Routing : ?Sized = Routing; - fn to_routing(self) -> Self::Routing; -} - -pub struct Mount> { - action: R, - _marker: PhantomData -} - -impl> Mount { - pub fn create>(mount: &str, input: T) { - input.to_routing(); - } -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25343.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25343.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25343.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25343.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[allow(unused)] -fn main() { - || { - 'label: loop { - } - }; - - // More cases added from issue 31754 - - 'label2: loop { - break; - } - - let closure = || { - 'label2: loop {} - }; - - fn inner_fn() { - 'label2: loop {} - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25394.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25394.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25394.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25394.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Debug)] -struct Row([T]); - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25467.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25467.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25467.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25467.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-25467.rs - -pub type Issue25467BarT = (); -pub type Issue25467FooT = (); - -extern crate issue_25467 as aux; - -fn main() { - let o: aux::Object = None; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25497.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25497.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25497.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25497.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Clone, Debug, PartialEq)] -enum Expression { - Dummy, - Add(Box), -} - -use Expression::*; - -fn simplify(exp: Expression) -> Expression { - match exp { - Add(n) => *n.clone(), - _ => Dummy - } -} - -fn main() { - assert_eq!(simplify(Add(Box::new(Dummy))), Dummy); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2550.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2550.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2550.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2550.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_snake_case)] - -// pretty-expanded FIXME #23616 - -struct C { - x: usize, -} - -fn C(x: usize) -> C { - C { - x: x - } -} - -fn f(_x: T) { -} - -pub fn main() { - f(C(1)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25515.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25515.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25515.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25515.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::rc::Rc; - -struct Foo<'r>(&'r mut i32); - -impl<'r> Drop for Foo<'r> { - fn drop(&mut self) { - *self.0 += 1; - } -} - -fn main() { - let mut drops = 0; - - { - let _: Rc = Rc::new(Foo(&mut drops)); - } - - assert_eq!(1, drops); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25549-multiple-drop.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25549-multiple-drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25549-multiple-drop.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25549-multiple-drop.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct Foo<'r>(&'r mut i32); - -impl<'r> Drop for Foo<'r> { - fn drop(&mut self) { - *self.0 += 1; - } -} - -trait Trait {} -impl<'r> Trait for Foo<'r> {} - -struct Holder(T); - -fn main() { - let mut drops = 0; - - { - let y = &Holder([Foo(&mut drops)]) as &Holder<[Foo]>; - // this used to cause an extra drop of the Foo instance - let x = &y.0; - } - assert_eq!(1, drops); - - drops = 0; - { - let y = &Holder(Foo(&mut drops)) as &Holder; - // this used to cause an extra drop of the Foo instance - let x = &y.0; - } - assert_eq!(1, drops); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25679.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25679.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25679.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25679.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Device { - type Resources; -} -struct Foo(D, R); - -impl Foo { - fn present(&self) {} -} - -struct Res; -struct Dev; - -impl Device for Dev { type Resources = Res; } - -fn main() { - let foo = Foo(Dev, Res); - foo.present(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25693.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25693.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25693.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25693.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub trait Parameters { type SelfRef; } - -struct RP<'a> { _marker: std::marker::PhantomData<&'a ()> } -struct BP; - -impl<'a> Parameters for RP<'a> { type SelfRef = &'a X>; } -impl Parameters for BP { type SelfRef = Box>; } - -pub struct Y; -pub enum X { - Nothing, - SameAgain(P::SelfRef, Y) -} - -fn main() { - let bnil: Box> = Box::new(X::Nothing); - let bx: Box> = Box::new(X::SameAgain(bnil, Y)); - let rnil: X = X::Nothing; - let rx: X = X::SameAgain(&rnil, Y); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25700-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25700-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25700-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25700-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct S(Option<&'static T>); - -trait Tr { type Out; } -impl Tr for T { type Out = T; } - -impl Copy for S where S: Tr {} -impl Clone for S where S: Tr { - fn clone(&self) -> Self { *self } -} -fn main() { - S::<()>(None); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25700-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25700-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25700-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25700-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub trait Parser { - type Input; -} - -pub struct Iter(P, P::Input); - -pub struct Map(P, F); -impl Parser for Map where F: FnMut(P) { - type Input = u8; -} - -trait AstId { type Untyped; } -impl AstId for u32 { type Untyped = u32; } - -fn record_type(i: Id::Untyped) -> u8 { - Iter(Map(i, |_: Id::Untyped| {}), 42).1 -} - -pub fn main() { - assert_eq!(record_type::(3), 42); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25746-bool-transmute.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25746-bool-transmute.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25746-bool-transmute.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25746-bool-transmute.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::mem::transmute; - -fn main() { - unsafe { - let _: i8 = transmute(false); - let _: i8 = transmute(true); - let _: bool = transmute(0u8); - let _: bool = transmute(1u8); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25757.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25757.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25757.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25757.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct Foo { - a: u32 -} - -impl Foo { - fn x(&mut self) { - self.a = 5; - } -} - -const FUNC: &'static Fn(&mut Foo) -> () = &Foo::x; - -fn main() { - let mut foo = Foo { a: 137 }; - FUNC(&mut foo); - assert_eq!(foo.a, 5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25810.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25810.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25810.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25810.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - let x = X(15); - let y = x.foo(); - println!("{:?}",y); -} - -trait Foo - where for<'a> &'a Self: Bar -{ - fn foo<'a>(&'a self) -> <&'a Self as Bar>::Output; -} - -trait Bar { - type Output; -} - -struct X(i32); - -impl<'a> Bar for &'a X { - type Output = &'a i32; -} - -impl Foo for X { - fn foo<'a>(&'a self) -> <&'a Self as Bar>::Output { - &self.0 - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25916.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25916.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25916.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-25916.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - macro_rules! f { - () => { 0 + 0 } - } - // 16 per line - f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); - f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); - f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); - f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); - - f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); - f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); - f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); - f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); - - f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); - f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); - f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); - f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); - - f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); - f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); - f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); - f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!();f!(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26095.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26095.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26095.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26095.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - - -trait HasNumber { - const Number: usize; -} - -enum One {} -enum Two {} - -enum Foo {} - -impl HasNumber for One { - const Number: usize = 1; -} - -impl HasNumber for Two { - const Number: usize = 2; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2611-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2611-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2611-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2611-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests that impls are allowed to have looser, more permissive bounds -// than the traits require. - - -trait A { - fn b(&self, x: C) -> C; -} - -struct E { - f: isize -} - -impl A for E { - fn b(&self, _x: F) -> F { panic!() } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26127.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26127.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26127.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26127.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Tr { type T; } -impl Tr for u8 { type T=(); } -struct S(I::T); - -fn foo(i: I::T) { - S::(i); -} - -fn main() { - foo::(()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26205.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26205.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26205.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26205.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::ops::{Deref, DerefMut}; - -struct Foo; - -impl Foo { - fn foo_mut(&mut self) {} -} - -struct Bar(Foo); - -impl Deref for Bar { - type Target = Foo; - - fn deref(&self) -> &Foo { - &self.0 - } -} - -impl DerefMut for Bar { - fn deref_mut(&mut self) -> &mut Foo { - &mut self.0 - } -} - -fn test(mut bar: Box) { - bar.foo_mut(); -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26251.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26251.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26251.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26251.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - let x = 'a'; - - let y = match x { - 'a'..='b' if false => "one", - 'a' => "two", - 'a'..='b' => "three", - _ => panic!("what?"), - }; - - assert_eq!(y, "two"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2631-b.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2631-b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2631-b.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2631-b.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// aux-build:issue-2631-a.rs - -extern crate req; - -use req::request; -use std::cell::RefCell; -use std::collections::HashMap; -use std::rc::Rc; - -pub fn main() { - let v = vec![Rc::new("hi".to_string())]; - let mut m: req::header_map = HashMap::new(); - m.insert("METHOD".to_string(), Rc::new(RefCell::new(v))); - request::(&m); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26322.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26322.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26322.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26322.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] - -macro_rules! columnline { - () => ( - (column!(), line!()) - ) -} - -macro_rules! indirectcolumnline { - () => ( - (||{ columnline!() })() - ) -} - -fn main() { - let closure = || { - columnline!() - }; - let iflet = if let Some(_) = Some(0) { - columnline!() - } else { (0, 0) }; - let cl = columnline!(); - assert_eq!(closure(), (9, 29)); - assert_eq!(iflet, (9, 32)); - assert_eq!(cl, (14, 34)); - let indirect = indirectcolumnline!(); - assert_eq!(indirect, (20, 38)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2633-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2633-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2633-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2633-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - - -fn a_val(x: Box, y: Box) -> isize { - *x + *y -} - -pub fn main() { - let z: Box<_> = box 22; - a_val(z.clone(), z.clone()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2633.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2633.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2633.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2633.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -#[derive(Copy, Clone)] -struct cat { - meow: extern "Rust" fn(), -} - -fn meow() { - println!("meow") -} - -fn cat() -> cat { - cat { - meow: meow, - } -} - -#[derive(Copy, Clone)] -struct KittyInfo {kitty: cat} - -// Code compiles and runs successfully if we add a + before the first arg -fn nyan(kitty: cat, _kitty_info: KittyInfo) { - (kitty.meow)(); -} - -pub fn main() { - let kitty = cat(); - nyan(kitty, KittyInfo {kitty: kitty}); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2642.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2642.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2642.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2642.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn f() { - let _x: usize = loop { loop { break; } }; -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26468.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26468.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26468.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26468.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(dead_code)] - -enum FooMode { - Check = 0x1001, -} - -enum BarMode { - Check = 0x2001, -} - -enum Mode { - Foo(FooMode), - Bar(BarMode), -} - -#[inline(never)] -fn broken(mode: &Mode) -> u32 { - for _ in 0..1 { - if let Mode::Foo(FooMode::Check) = *mode { return 17 } - if let Mode::Bar(BarMode::Check) = *mode { return 19 } - } - return 42; -} - -fn main() { - let mode = Mode::Bar(BarMode::Check); - assert_eq!(broken(&mode), 19); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26484.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26484.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26484.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26484.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags:-g - -fn helper bool>(_f: F) { - print!(""); -} - -fn main() { - let cond = 0; - helper(|v| v == cond) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26641.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26641.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26641.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26641.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct Parser<'a>(Box); - -fn main() { - let _x = Parser(Box::new(|_|{})); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26646.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26646.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26646.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26646.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![deny(unused_attributes)] - -#[repr(C)] -#[repr(packed)] -pub struct Foo; - -#[repr(packed)] -#[repr(C)] -pub struct Bar; - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26655.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26655.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26655.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26655.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -// Check that the destructors of simple enums are run on unwinding - -use std::sync::atomic::{Ordering, AtomicUsize}; -use std::thread; - -static LOG: AtomicUsize = AtomicUsize::new(0); - -enum WithDtor { Val } -impl Drop for WithDtor { - fn drop(&mut self) { - LOG.store(LOG.load(Ordering::SeqCst)+1,Ordering::SeqCst); - } -} - -pub fn main() { - thread::spawn(move|| { - let _e: WithDtor = WithDtor::Val; - panic!("fail"); - }).join().unwrap_err(); - - assert_eq!(LOG.load(Ordering::SeqCst), 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26709.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26709.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26709.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26709.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct Wrapper<'a, T: ?Sized>(&'a mut i32, T); - -impl<'a, T: ?Sized> Drop for Wrapper<'a, T> { - fn drop(&mut self) { - *self.0 = 432; - } -} - -fn main() { - let mut x = 0; - { - let wrapper = Box::new(Wrapper(&mut x, 123)); - let _: Box> = wrapper; - } - assert_eq!(432, x) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26802.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26802.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26802.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26802.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Foo<'a> { - fn bar<'b>(&self, x: &'b u8) -> u8 where 'a: 'b { *x+7 } -} - -pub struct FooBar; -impl Foo<'static> for FooBar {} -fn test(foobar: FooBar) -> Box> { - Box::new(foobar) -} - -fn main() { - assert_eq!(test(FooBar).bar(&4), 11); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26805.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26805.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26805.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26805.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct NonOrd; - -fn main() { - let _: Box> = Box::new(vec![NonOrd].into_iter()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_26873_multifile/A/B.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_26873_multifile/A/B.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_26873_multifile/A/B.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_26873_multifile/A/B.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use super::*; - -pub struct S; - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_26873_multifile/A/C.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_26873_multifile/A/C.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_26873_multifile/A/C.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_26873_multifile/A/C.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use super::*; - -use super::B::S; - -pub struct T { i: i32 } - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_26873_multifile/A/mod.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_26873_multifile/A/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_26873_multifile/A/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_26873_multifile/A/mod.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub mod B; -pub mod C; - -pub use self::C::T; - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_26873_multifile/mod.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_26873_multifile/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_26873_multifile/mod.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_26873_multifile/mod.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -mod A; - -use self::A::*; - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26873-multifile.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26873-multifile.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26873-multifile.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26873-multifile.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_snake_case)] - -// ignore-pretty issue #37195 - -mod issue_26873_multifile; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26873-onefile.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26873-onefile.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26873-onefile.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26873-onefile.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_snake_case)] - -mod A { - pub mod B { - use super::*; - - pub struct S; - } - - pub mod C { - use super::*; - use super::B::S; - - pub struct T; - } - - pub use self::C::T; -} - -use A::*; - -fn main() {} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26905.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26905.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26905.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26905.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(unsize, coerce_unsized)] - -// Verfies that PhantomData is ignored for DST coercions - -use std::marker::{Unsize, PhantomData}; -use std::ops::CoerceUnsized; - -struct MyRc { - _ptr: *const T, - _boo: PhantomData, -} - -impl, U: ?Sized> CoerceUnsized> for MyRc{ } - -fn main() { - let data = [1, 2, 3]; - let iter = data.iter(); - let x = MyRc { _ptr: &iter, _boo: PhantomData }; - let _y: MyRc> = x; -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26996.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26996.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26996.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26996.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - let mut c = (1, "".to_owned()); - match c { - c2 => { - c.0 = 2; - assert_eq!(c2.0, 1); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26997.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26997.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26997.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-26997.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub struct Foo { - x: isize, - y: isize -} - -impl Foo { - pub extern fn foo_new() -> Foo { - Foo { x: 21, y: 33 } - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27021.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27021.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27021.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27021.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - let mut c = (1, (1, "".to_owned())); - match c { - c2 => { (c.1).0 = 2; assert_eq!((c2.1).0, 1); } - } - - let mut c = (1, (1, (1, "".to_owned()))); - match c.1 { - c2 => { ((c.1).1).0 = 3; assert_eq!((c2.1).0, 1); } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27054-primitive-binary-ops.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27054-primitive-binary-ops.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27054-primitive-binary-ops.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27054-primitive-binary-ops.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - let x = &mut 1; - assert_eq!(*x + { *x=2; 1 }, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27060.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27060.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27060.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27060.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[repr(packed)] -pub struct Good { - data: &'static u32, - data2: [&'static u32; 2], - aligned: [u8; 32], -} - -#[repr(packed)] -pub struct JustArray { - array: [u32] -} - -// kill this test when that turns to a hard error -#[allow(safe_packed_borrows)] -fn main() { - let good = Good { - data: &0, - data2: [&0, &0], - aligned: [0; 32] - }; - - unsafe { - let _ = &good.data; // ok - let _ = &good.data2[0]; // ok - } - - let _ = &good.data; - let _ = &good.data2[0]; - let _ = &*good.data; // ok, behind a pointer - let _ = &good.aligned; // ok, has align 1 - let _ = &good.aligned[2]; // ok, has align 1 -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2708.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2708.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2708.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2708.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_snake_case)] - -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - -struct Font { - fontbuf: usize, - cairo_font: usize, - font_dtor: usize, - -} - -impl Drop for Font { - fn drop(&mut self) {} -} - -fn Font() -> Font { - Font { - fontbuf: 0, - cairo_font: 0, - font_dtor: 0 - } -} - -pub fn main() { - let _f: Box<_> = box Font(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27105.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27105.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27105.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27105.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::cell::RefCell; -use std::rc::Rc; - -pub struct Callbacks { - callbacks: Vec>>, -} - -impl Callbacks { - pub fn register(&mut self, callback: F) { - self.callbacks.push(Rc::new(RefCell::new(callback))); - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2718.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2718.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2718.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2718.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,334 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -pub type Task = isize; - -// tjc: I don't know why -pub mod pipes { - use self::state::{empty, full, blocked, terminated}; - use super::Task; - use std::mem::{forget, transmute}; - use std::mem::{replace, swap}; - use std::mem; - use std::thread; - use std::marker::Send; - - pub struct Stuff { - state: state, - blocked_task: Option, - payload: Option - } - - #[derive(PartialEq, Debug)] - #[repr(isize)] - pub enum state { - empty, - full, - blocked, - terminated - } - - pub struct packet { - state: state, - blocked_task: Option, - payload: Option - } - - unsafe impl Send for packet {} - - pub fn packet() -> *const packet { - unsafe { - let p: *const packet = mem::transmute(Box::new(Stuff{ - state: empty, - blocked_task: None::, - payload: None:: - })); - p - } - } - - mod rusti { - pub fn atomic_xchg(_dst: &mut isize, _src: isize) -> isize { panic!(); } - pub fn atomic_xchg_acq(_dst: &mut isize, _src: isize) -> isize { panic!(); } - pub fn atomic_xchg_rel(_dst: &mut isize, _src: isize) -> isize { panic!(); } - } - - // We should consider moving this to ::std::unsafe, although I - // suspect graydon would want us to use void pointers instead. - pub unsafe fn uniquify(x: *const T) -> Box { - mem::transmute(x) - } - - pub fn swap_state_acq(dst: &mut state, src: state) -> state { - unsafe { - transmute(rusti::atomic_xchg_acq(transmute(dst), src as isize)) - } - } - - pub fn swap_state_rel(dst: &mut state, src: state) -> state { - unsafe { - transmute(rusti::atomic_xchg_rel(transmute(dst), src as isize)) - } - } - - pub fn send(mut p: send_packet, payload: T) { - let p = p.unwrap(); - let mut p = unsafe { uniquify(p) }; - assert!((*p).payload.is_none()); - (*p).payload = Some(payload); - let old_state = swap_state_rel(&mut (*p).state, full); - match old_state { - empty => { - // Yay, fastpath. - - // The receiver will eventually clean this up. - unsafe { forget(p); } - } - full => { panic!("duplicate send") } - blocked => { - - // The receiver will eventually clean this up. - unsafe { forget(p); } - } - terminated => { - // The receiver will never receive this. Rely on drop_glue - // to clean everything up. - } - } - } - - pub fn recv(mut p: recv_packet) -> Option { - let p = p.unwrap(); - let mut p = unsafe { uniquify(p) }; - loop { - let old_state = swap_state_acq(&mut (*p).state, - blocked); - match old_state { - empty | blocked => { thread::yield_now(); } - full => { - let payload = replace(&mut p.payload, None); - return Some(payload.unwrap()) - } - terminated => { - assert_eq!(old_state, terminated); - return None; - } - } - } - } - - pub fn sender_terminate(p: *const packet) { - let mut p = unsafe { uniquify(p) }; - match swap_state_rel(&mut (*p).state, terminated) { - empty | blocked => { - // The receiver will eventually clean up. - unsafe { forget(p) } - } - full => { - // This is impossible - panic!("you dun goofed") - } - terminated => { - // I have to clean up, use drop_glue - } - } - } - - pub fn receiver_terminate(p: *const packet) { - let mut p = unsafe { uniquify(p) }; - match swap_state_rel(&mut (*p).state, terminated) { - empty => { - // the sender will clean up - unsafe { forget(p) } - } - blocked => { - // this shouldn't happen. - panic!("terminating a blocked packet") - } - terminated | full => { - // I have to clean up, use drop_glue - } - } - } - - pub struct send_packet { - p: Option<*const packet>, - } - - impl Drop for send_packet { - fn drop(&mut self) { - unsafe { - if self.p != None { - let self_p: &mut Option<*const packet> = - mem::transmute(&mut self.p); - let p = replace(self_p, None); - sender_terminate(p.unwrap()) - } - } - } - } - - impl send_packet { - pub fn unwrap(&mut self) -> *const packet { - replace(&mut self.p, None).unwrap() - } - } - - pub fn send_packet(p: *const packet) -> send_packet { - send_packet { - p: Some(p) - } - } - - pub struct recv_packet { - p: Option<*const packet>, - } - - impl Drop for recv_packet { - fn drop(&mut self) { - unsafe { - if self.p != None { - let self_p: &mut Option<*const packet> = - mem::transmute(&mut self.p); - let p = replace(self_p, None); - receiver_terminate(p.unwrap()) - } - } - } - } - - impl recv_packet { - pub fn unwrap(&mut self) -> *const packet { - replace(&mut self.p, None).unwrap() - } - } - - pub fn recv_packet(p: *const packet) -> recv_packet { - recv_packet { - p: Some(p) - } - } - - pub fn entangle() -> (send_packet, recv_packet) { - let p = packet(); - (send_packet(p), recv_packet(p)) - } -} - -pub mod pingpong { - use std::mem; - - pub struct ping(::pipes::send_packet); - - unsafe impl Send for ping {} - - pub struct pong(::pipes::send_packet); - - unsafe impl Send for pong {} - - pub fn liberate_ping(p: ping) -> ::pipes::send_packet { - unsafe { - let _addr : *const ::pipes::send_packet = match &p { - &ping(ref x) => { mem::transmute(x) } - }; - panic!() - } - } - - pub fn liberate_pong(p: pong) -> ::pipes::send_packet { - unsafe { - let _addr : *const ::pipes::send_packet = match &p { - &pong(ref x) => { mem::transmute(x) } - }; - panic!() - } - } - - pub fn init() -> (client::ping, server::ping) { - ::pipes::entangle() - } - - pub mod client { - use pingpong; - - pub type ping = ::pipes::send_packet; - pub type pong = ::pipes::recv_packet; - - pub fn do_ping(c: ping) -> pong { - let (sp, rp) = ::pipes::entangle(); - - ::pipes::send(c, pingpong::ping(sp)); - rp - } - - pub fn do_pong(c: pong) -> (ping, ()) { - let packet = ::pipes::recv(c); - if packet.is_none() { - panic!("sender closed the connection") - } - (pingpong::liberate_pong(packet.unwrap()), ()) - } - } - - pub mod server { - use pingpong; - - pub type ping = ::pipes::recv_packet; - pub type pong = ::pipes::send_packet; - - pub fn do_ping(c: ping) -> (pong, ()) { - let packet = ::pipes::recv(c); - if packet.is_none() { - panic!("sender closed the connection") - } - (pingpong::liberate_ping(packet.unwrap()), ()) - } - - pub fn do_pong(c: pong) -> ping { - let (sp, rp) = ::pipes::entangle(); - ::pipes::send(c, pingpong::pong(sp)); - rp - } - } -} - -fn client(chan: pingpong::client::ping) { - let chan = pingpong::client::do_ping(chan); - println!("Sent ping"); - let (_chan, _data) = pingpong::client::do_pong(chan); - println!("Received pong"); -} - -fn server(chan: pingpong::server::ping) { - let (chan, _data) = pingpong::server::do_ping(chan); - println!("Received ping"); - let _chan = pingpong::server::do_pong(chan); - println!("Sent pong"); -} - -pub fn main() { - /* -// Commented out because of option::get error - - let (client_, server_) = pingpong::init(); - - task::spawn {|client_| - let client__ = client_.take(); - client(client__); - }; - task::spawn {|server_| - let server__ = server_.take(); - server(server_ˊ); - }; - */ -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2723-b.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2723-b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2723-b.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2723-b.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue_2723_a.rs - -extern crate issue_2723_a; -use issue_2723_a::f; - -pub fn main() { - unsafe { - f(vec![2]); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27240.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27240.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27240.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27240.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::fmt; -struct NoisyDrop(T); -impl Drop for NoisyDrop { - fn drop(&mut self) {} -} - -struct Bar([*const NoisyDrop; 2]); - -fn fine() { - let (u,b); - u = vec![43]; - b = Bar([&NoisyDrop(&u), &NoisyDrop(&u)]); -} - -struct Bar2(*const NoisyDrop, *const NoisyDrop); - -fn lolwut() { - let (u,v); - u = vec![43]; - v = Bar2(&NoisyDrop(&u), &NoisyDrop(&u)); -} - -fn main() { fine(); lolwut() } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27268.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27268.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27268.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27268.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - const _C: &'static Fn() = &||{}; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27281.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27281.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27281.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27281.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub trait Trait<'a> { - type T; - type U; - fn foo(&self, s: &'a ()) -> &'a (); -} - -impl<'a> Trait<'a> for () { - type T = &'a (); - type U = Self::T; - - fn foo(&self, s: &'a ()) -> &'a () { - let t: Self::T = s; t - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27320.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27320.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27320.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27320.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(unused_variables)] -#![allow(dead_code)] - -macro_rules! piece( - ($piece:pat) => ($piece); -); - -enum Piece {A, B} - -fn main() { - match Piece::A { - piece!(pt@ Piece::A) | piece!(pt@ Piece::B) => {} - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2734.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2734.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2734.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2734.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - -trait hax { - fn dummy(&self) { } -} -impl hax for A { } - -fn perform_hax(x: Box) -> Box { - box x as Box -} - -fn deadcode() { - perform_hax(box "deadcode".to_string()); -} - -pub fn main() { - let _ = perform_hax(box 42); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2735-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2735-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2735-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2735-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -use std::cell::Cell; - -// This test should behave exactly like issue-2735-3 -struct defer<'a> { - b: &'a Cell, -} - -impl<'a> Drop for defer<'a> { - fn drop(&mut self) { - self.b.set(true); - } -} - -fn defer(b: &Cell) -> defer { - defer { - b: b - } -} - -pub fn main() { - let dtor_ran = &Cell::new(false); - let _ = defer(dtor_ran); - assert!(dtor_ran.get()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2735-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2735-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2735-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2735-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -use std::cell::Cell; - -// This test should behave exactly like issue-2735-2 -struct defer<'a> { - b: &'a Cell, -} - -impl<'a> Drop for defer<'a> { - fn drop(&mut self) { - self.b.set(true); - } -} - -fn defer(b: &Cell) -> defer { - defer { - b: b - } -} - -pub fn main() { - let dtor_ran = &Cell::new(false); - defer(dtor_ran); - assert!(dtor_ran.get()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2735.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2735.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2735.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2735.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - -trait hax { - fn dummy(&self) { } -} -impl hax for A { } - -fn perform_hax(x: Box) -> Box { - box x as Box -} - -fn deadcode() { - perform_hax(box "deadcode".to_string()); -} - -pub fn main() { - perform_hax(box 42); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27401-dropflag-reinit.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27401-dropflag-reinit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27401-dropflag-reinit.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27401-dropflag-reinit.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty issue #37201 - -// Check that when a `let`-binding occurs in a loop, its associated -// drop-flag is reinitialized (to indicate "needs-drop" at the end of -// the owning variable's scope). - -struct A<'a>(&'a mut i32); - -impl<'a> Drop for A<'a> { - fn drop(&mut self) { - *self.0 += 1; - } -} - -fn main() { - let mut cnt = 0; - for i in 0..2 { - let a = A(&mut cnt); - if i == 1 { // Note that - break; // both this break - } // and also - drop(a); // this move of `a` - // are necessary to expose the bug - } - assert_eq!(cnt, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2748-a.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2748-a.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2748-a.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2748-a.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_snake_case)] - -// pretty-expanded FIXME #23616 - -struct CMap<'a> { - buf: &'a [u8], -} - -fn CMap(buf: &[u8]) -> CMap { - CMap { - buf: buf - } -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2748-b.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2748-b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2748-b.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2748-b.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn thing<'r>(x: &'r [isize]) -> &'r [isize] { x } - -pub fn main() { - let x = &[1,2,3]; - let y = x; - let z = thing(x); - assert_eq!(z[2], x[2]); - assert_eq!(z[1], y[1]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27583.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27583.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27583.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27583.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for issue #27583. Unclear how useful this will be -// going forward, since the issue in question was EXTREMELY sensitive -// to compiler internals (like the precise numbering of nodes), but -// what the hey. - -#![allow(warnings)] - -use std::cell::Cell; -use std::marker::PhantomData; - -pub trait Delegate<'tcx> { } - -pub struct InferCtxt<'a, 'tcx: 'a> { - x: PhantomData<&'a Cell<&'tcx ()>> -} - -pub struct MemCategorizationContext<'t, 'a: 't, 'tcx : 'a> { - x: &'t InferCtxt<'a, 'tcx>, -} - -pub struct ExprUseVisitor<'d, 't, 'a: 't, 'tcx:'a+'d> { - typer: &'t InferCtxt<'a, 'tcx>, - mc: MemCategorizationContext<'t, 'a, 'tcx>, - delegate: &'d mut (Delegate<'tcx>+'d), -} - -impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> { - pub fn new(delegate: &'d mut Delegate<'tcx>, - typer: &'t InferCtxt<'a, 'tcx>) - -> ExprUseVisitor<'d,'t,'a,'tcx> - { - ExprUseVisitor { - typer: typer, - mc: MemCategorizationContext::new(typer), - delegate: delegate, - } - } -} - -impl<'t, 'a,'tcx> MemCategorizationContext<'t, 'a, 'tcx> { - pub fn new(typer: &'t InferCtxt<'a, 'tcx>) -> MemCategorizationContext<'t, 'a, 'tcx> { - MemCategorizationContext { x: typer } - } -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27639.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27639.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27639.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27639.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -fn main() { - const iter: i32 = 0; - - for i in 1..10 { - println!("{}", i); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27859.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27859.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27859.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27859.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-cloudabi no std::env -// ignore-wasm32 issue 42629 - -#[inline(never)] -fn foo(a: f32, b: f32) -> f32 { - a % b -} - -#[inline(never)] -fn bar(a: f32, b: f32) -> f32 { - ((a as f64) % (b as f64)) as f32 -} - -fn main() { - let unknown_float = std::env::args().len(); - println!("{}", foo(4.0, unknown_float as f32)); - println!("{}", foo(5.0, (unknown_float as f32) + 1.0)); - println!("{}", bar(6.0, (unknown_float as f32) + 2.0)); - println!("{}", bar(7.0, (unknown_float as f32) + 3.0)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27889.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27889.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27889.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27889.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that a field can have the same name in different variants -// of an enum - -pub enum Foo { - X { foo: u32 }, - Y { foo: u32 } -} - -pub fn foo(mut x: Foo) { - let mut y = None; - let mut z = None; - if let Foo::X { ref foo } = x { - z = Some(foo); - } - if let Foo::Y { ref mut foo } = x { - y = Some(foo); - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27890.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27890.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27890.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27890.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -static PLUS_ONE: &'static (Fn(i32) -> i32 + Sync) = (&|x: i32| { x + 1 }) - as &'static (Fn(i32) -> i32 + Sync); - -fn main() { - assert_eq!(PLUS_ONE(2), 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27901.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27901.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27901.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27901.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Stream { type Item; } -impl<'a> Stream for &'a str { type Item = u8; } -fn f<'s>(s: &'s str) -> (&'s str, <&'s str as Stream>::Item) { - (s, 42) -} - -fn main() { - let fx = f as for<'t> fn(&'t str) -> (&'t str, <&'t str as Stream>::Item); - assert_eq!(fx("hi"), ("hi", 42)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27997.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27997.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27997.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-27997.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::sync::atomic::{Ordering, AtomicUsize}; - -use std::mem; -struct S { - _u: U, - size_of_u: usize, - _v: V, - size_of_v: usize -} - -impl S { - fn new(u: U, v: V) -> Self { - S { - _u: u, - size_of_u: mem::size_of::(), - _v: v, - size_of_v: mem::size_of::() - } - } -} - -static COUNT: AtomicUsize = AtomicUsize::new(0); - -impl Drop for S { - fn drop(&mut self) { - assert_eq!(mem::size_of::(), self.size_of_u); - assert_eq!(mem::size_of::(), self.size_of_v); - COUNT.store(COUNT.load(Ordering::SeqCst)+1, Ordering::SeqCst); - } -} - -fn main() { - assert_eq!(COUNT.load(Ordering::SeqCst), 0); - { S::new(0u8, 1u16); } - assert_eq!(COUNT.load(Ordering::SeqCst), 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2804-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2804-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2804-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2804-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Minimized version of issue-2804.rs. Both check that callee IDs don't -// clobber the previous node ID in a macro expr - -use std::collections::HashMap; - -fn add_interfaces(managed_ip: String, device: HashMap) { - println!("{}, {}", managed_ip, device["interfaces"]); -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28181.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28181.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28181.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28181.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn bar(f: F) -> usize where F: Fn([usize; 1]) -> usize { f([2]) } - -fn main() { - bar(|u| { u[0] }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28279.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28279.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28279.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28279.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::rc::Rc; - -fn test1() -> Rc Fn(&'a usize) + 'static> { - if let Some(_) = Some(1) { - loop{} - } else { - loop{} - } -} - -fn test2() -> *mut (for<'a> Fn(&'a usize) + 'static) { - if let Some(_) = Some(1) { - loop{} - } else { - loop{} - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-must-work-ex1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-must-work-ex1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-must-work-ex1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-must-work-ex1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Example taken from RFC 1238 text - -// https://github.com/rust-lang/rfcs/blob/master/text/1238-nonparametric-dropck.md -// #examples-of-code-that-must-continue-to-work - -use std::cell::Cell; - -struct Concrete<'a>(u32, Cell>>); - -fn main() { - let mut data = Vec::new(); - data.push(Concrete(0, Cell::new(None))); - data.push(Concrete(0, Cell::new(None))); - - data[0].1.set(Some(&data[1])); - data[1].1.set(Some(&data[0])); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-must-work-ex2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-must-work-ex2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-must-work-ex2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-must-work-ex2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Example taken from RFC 1238 text - -// https://github.com/rust-lang/rfcs/blob/master/text/1238-nonparametric-dropck.md -// #examples-of-code-that-must-continue-to-work - -use std::cell::Cell; - -struct Concrete<'a>(u32, Cell>>); - -struct Foo { data: Vec } - -fn main() { - let mut foo = Foo { data: Vec::new() }; - foo.data.push(Concrete(0, Cell::new(None))); - foo.data.push(Concrete(0, Cell::new(None))); - - foo.data[0].1.set(Some(&foo.data[1])); - foo.data[1].1.set(Some(&foo.data[0])); -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-ugeh-ex1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-ugeh-ex1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-ugeh-ex1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-ugeh-ex1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(deprecated)] // FIXME: switch to `#[may_dangle]` below. - -// Example taken from RFC 1238 text - -// https://github.com/rust-lang/rfcs/blob/master/text/1238-nonparametric-dropck.md -// #example-of-the-unguarded-escape-hatch - -#![feature(dropck_parametricity)] -use std::cell::Cell; - -struct Concrete<'a>(u32, Cell>>); - -struct Foo { data: Vec } - -impl Drop for Foo { - // Below is the UGEH attribute - #[unsafe_destructor_blind_to_params] - fn drop(&mut self) { } -} - -fn main() { - let mut foo = Foo { data: Vec::new() }; - foo.data.push(Concrete(0, Cell::new(None))); - foo.data.push(Concrete(0, Cell::new(None))); - - foo.data[0].1.set(Some(&foo.data[1])); - foo.data[1].1.set(Some(&foo.data[0])); -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-ugeh-with-lifetime-param.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-ugeh-with-lifetime-param.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-ugeh-with-lifetime-param.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-ugeh-with-lifetime-param.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(deprecated)] // FIXME: switch to `#[may_dangle]` below. - -// Demonstrate the use of the unguarded escape hatch with a lifetime param -// to assert that destructor will not access any dead data. -// -// Compare with compile-fail/issue28498-reject-lifetime-param.rs - -#![feature(dropck_parametricity)] - -#[derive(Debug)] -struct ScribbleOnDrop(String); - -impl Drop for ScribbleOnDrop { - fn drop(&mut self) { - self.0 = format!("DROPPED"); - } -} - -struct Foo<'a>(u32, &'a ScribbleOnDrop); - -impl<'a> Drop for Foo<'a> { - #[unsafe_destructor_blind_to_params] - fn drop(&mut self) { - // Use of `unsafe_destructor_blind_to_params` is sound, - // because destructor never accesses `self.1`. - println!("Dropping Foo({}, _)", self.0); - } -} - -fn main() { - let (last_dropped, foo0); - let (foo1, first_dropped); - - last_dropped = ScribbleOnDrop(format!("last")); - first_dropped = ScribbleOnDrop(format!("first")); - foo0 = Foo(0, &last_dropped); - foo1 = Foo(1, &first_dropped); - - println!("foo0.1: {:?} foo1.1: {:?}", foo0.1, foo1.1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-ugeh-with-passed-to-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-ugeh-with-passed-to-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-ugeh-with-passed-to-fn.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-ugeh-with-passed-to-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(deprecated)] // FIXME: switch to `#[may_dangle]` below. - -// Demonstrate the use of the unguarded escape hatch with a type param in negative position -// to assert that destructor will not access any dead data. -// -// Compare with compile-fail/issue28498-reject-lifetime-param.rs - -// Demonstrate that a type param in negative position causes dropck to reject code -// that might indirectly access previously dropped value. -// -// Compare with run-pass/issue28498-ugeh-with-passed-to-fn.rs - -#![feature(dropck_parametricity)] - -#[derive(Debug)] -struct ScribbleOnDrop(String); - -impl Drop for ScribbleOnDrop { - fn drop(&mut self) { - self.0 = format!("DROPPED"); - } -} - -struct Foo(u32, T, Box fn(&'r T) -> String>); - -impl Drop for Foo { - #[unsafe_destructor_blind_to_params] - fn drop(&mut self) { - // Use of `unsafe_destructor_blind_to_params` is sound, - // because destructor never passes a `self.1` to the callback - // (in `self.2`) despite having it available. - println!("Dropping Foo({}, _)", self.0); - } -} - -fn callback(s: & &ScribbleOnDrop) -> String { format!("{:?}", s) } - -fn main() { - let (last_dropped, foo0); - let (foo1, first_dropped); - - last_dropped = ScribbleOnDrop(format!("last")); - first_dropped = ScribbleOnDrop(format!("first")); - foo0 = Foo(0, &last_dropped, Box::new(callback)); - foo1 = Foo(1, &first_dropped, Box::new(callback)); - - println!("foo0.1: {:?} foo1.1: {:?}", foo0.1, foo1.1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-ugeh-with-trait-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-ugeh-with-trait-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-ugeh-with-trait-bound.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue28498-ugeh-with-trait-bound.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(deprecated)] // FIXME: switch to `#[may_dangle]` below. - -// Demonstrate the use of the unguarded escape hatch with a trait bound -// to assert that destructor will not access any dead data. -// -// Compare with compile-fail/issue28498-reject-trait-bound.rs - -#![feature(dropck_parametricity)] - -use std::fmt; - -#[derive(Debug)] -struct ScribbleOnDrop(String); - -impl Drop for ScribbleOnDrop { - fn drop(&mut self) { - self.0 = format!("DROPPED"); - } -} - -struct Foo(u32, T); - -impl Drop for Foo { - #[unsafe_destructor_blind_to_params] - fn drop(&mut self) { - // Use of `unsafe_destructor_blind_to_params` is sound, - // because destructor never accesses the `Debug::fmt` method - // of `T`, despite having it available. - println!("Dropping Foo({}, _)", self.0); - } -} - -fn main() { - let (last_dropped, foo0); - let (foo1, first_dropped); - - last_dropped = ScribbleOnDrop(format!("last")); - first_dropped = ScribbleOnDrop(format!("first")); - foo0 = Foo(0, &last_dropped); - foo1 = Foo(1, &first_dropped); - - println!("foo0.1: {:?} foo1.1: {:?}", foo0.1, foo1.1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28550.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28550.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28550.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28550.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct AT,T>(F::Output); -struct BT,T>(A); - -// Removing Option causes it to compile. -fn fooT>(f: F) -> Option> { - Some(B(A(f()))) -} - -fn main() { - let v = (|| foo(||4))(); - match v { - Some(B(A(4))) => {}, - _ => unreachable!() - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28561.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28561.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28561.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28561.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] -struct Array { - f00: [T; 00], - f01: [T; 01], - f02: [T; 02], - f03: [T; 03], - f04: [T; 04], - f05: [T; 05], - f06: [T; 06], - f07: [T; 07], - f08: [T; 08], - f09: [T; 09], - f10: [T; 10], - f11: [T; 11], - f12: [T; 12], - f13: [T; 13], - f14: [T; 14], - f15: [T; 15], - f16: [T; 16], - f17: [T; 17], - f18: [T; 18], - f19: [T; 19], - f20: [T; 20], - f21: [T; 21], - f22: [T; 22], - f23: [T; 23], - f24: [T; 24], - f25: [T; 25], - f26: [T; 26], - f27: [T; 27], - f28: [T; 28], - f29: [T; 29], - f30: [T; 30], - f31: [T; 31], - f32: [T; 32], -} - -// FIXME(#44580): merge with `Array` once `[T; N]: Clone` where `T: Clone` -#[derive(Clone, Copy)] -struct CopyArray { - f00: [T; 00], - f01: [T; 01], - f02: [T; 02], - f03: [T; 03], - f04: [T; 04], - f05: [T; 05], - f06: [T; 06], - f07: [T; 07], - f08: [T; 08], - f09: [T; 09], - f10: [T; 10], - f11: [T; 11], - f12: [T; 12], - f13: [T; 13], - f14: [T; 14], - f15: [T; 15], - f16: [T; 16], - f17: [T; 17], - f18: [T; 18], - f19: [T; 19], - f20: [T; 20], - f21: [T; 21], - f22: [T; 22], - f23: [T; 23], - f24: [T; 24], - f25: [T; 25], - f26: [T; 26], - f27: [T; 27], - f28: [T; 28], - f29: [T; 29], - f30: [T; 30], - f31: [T; 31], - f32: [T; 32], -} - -#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] -struct Fn { - f00: fn(), - f01: fn(A), - f02: fn(A, B), - f03: fn(A, B, C), - f04: fn(A, B, C, D), - f05: fn(A, B, C, D, E), - f06: fn(A, B, C, D, E, F), - f07: fn(A, B, C, D, E, F, G), - f08: fn(A, B, C, D, E, F, G, H), - f09: fn(A, B, C, D, E, F, G, H, I), - f10: fn(A, B, C, D, E, F, G, H, I, J), - f11: fn(A, B, C, D, E, F, G, H, I, J, K), - f12: fn(A, B, C, D, E, F, G, H, I, J, K, L), -} - -#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] -struct Tuple { - f00: (), - f01: (A), - f02: (A, B), - f03: (A, B, C), - f04: (A, B, C, D), - f05: (A, B, C, D, E), - f06: (A, B, C, D, E, F), - f07: (A, B, C, D, E, F, G), - f08: (A, B, C, D, E, F, G, H), - f09: (A, B, C, D, E, F, G, H, I), - f10: (A, B, C, D, E, F, G, H, I, J), - f11: (A, B, C, D, E, F, G, H, I, J, K), - f12: (A, B, C, D, E, F, G, H, I, J, K, L), -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28600.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28600.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28600.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28600.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// #28600 ICE: pub extern fn with parameter type &str inside struct impl - -struct Test; - -impl Test { - #[allow(dead_code)] - #[allow(unused_variables)] - pub extern fn test(val: &str) { - - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28676.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28676.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28676.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28676.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// Copyright 2012-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(improper_ctypes)] - -// ignore-wasm32-bare no libc to test ffi with - -#[derive(Copy, Clone)] -pub struct Quad { a: u64, b: u64, c: u64, d: u64 } - -mod rustrt { - use super::Quad; - - #[link(name = "rust_test_helpers", kind = "static")] - extern { - pub fn get_c_many_params(_: *const (), _: *const (), - _: *const (), _: *const (), f: Quad) -> u64; - } -} - -fn test() { - unsafe { - let null = std::ptr::null(); - let q = Quad { - a: 1, - b: 2, - c: 3, - d: 4 - }; - assert_eq!(rustrt::get_c_many_params(null, null, null, null, q), q.c); - } -} - -pub fn main() { - test(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28777.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28777.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28777.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28777.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - let v1 = { 1 + {2} * {3} }; - let v2 = 1 + {2} * {3} ; - - assert_eq!(7, v1); - assert_eq!(7, v2); - - let v3; - v3 = { 1 + {2} * {3} }; - let v4; - v4 = 1 + {2} * {3}; - assert_eq!(7, v3); - assert_eq!(7, v4); - - let v5 = { 1 + {2} * 3 }; - assert_eq!(7, v5); - - let v9 = { 1 + if 1 > 2 {1} else {2} * {3} }; - assert_eq!(7, v9); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28822.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28822.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28822.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28822.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(min_const_fn)] - -fn main() {} - -const fn size_ofs(_: usize) {} -const fn size_ofs2(_foo: usize) {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28828.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28828.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28828.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28828.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub trait Foo { - type Out; -} - -impl Foo for () { - type Out = bool; -} - -fn main() { - type Bool = <() as Foo>::Out; - - let x: Bool = true; - assert!(x); - - let y: Option = None; - assert_eq!(y, None); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28839.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28839.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28839.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28839.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty issue #37199 - -pub struct Foo; - -pub fn get_foo2<'a>(foo: &'a mut Option<&'a mut Foo>) -> &'a mut Foo { - match foo { - // Ensure that this is not considered a move, but rather a reborrow. - &mut Some(ref mut x) => *x, - &mut None => panic!(), - } -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28871.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28871.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28871.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28871.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #28871. The problem is that rustc encountered -// two ways to project, one from a where clause and one from the where -// clauses on the trait definition. (In fact, in this case, the where -// clauses originated from the trait definition as well.) The true -// cause of the error is that the trait definition where clauses are -// not being normalized, and hence the two sources are considered in -// conflict, and not a duplicate. Hacky solution is to prefer where -// clauses over the data found in the trait definition. - -trait T { - type T; -} - -struct S; -impl T for S { - type T = S; -} - -trait T2 { - type T: Iterator::T>; -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28936.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28936.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28936.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28936.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub type Session = i32; -pub struct StreamParser<'a, T> { - _tokens: T, - _session: &'a mut Session, -} - -impl<'a, T> StreamParser<'a, T> { - pub fn thing(&mut self) -> bool { true } -} - -pub fn parse_stream, U, F>( - _session: &mut Session, _tokens: T, _f: F) -> U - where F: Fn(&mut StreamParser) -> U { panic!(); } - -pub fn thing(session: &mut Session) { - let mut stream = vec![1, 2, 3].into_iter(); - - let _b = parse_stream(session, - stream.by_ref(), - // replacing the above with the following fixes it - //&mut stream, - |p| p.thing()); - -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28950.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28950.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28950.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28950.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads -// compile-flags: -O - -// Tests that the `vec!` macro does not overflow the stack when it is -// given data larger than the stack. - -// FIXME(eddyb) Improve unoptimized codegen to avoid the temporary, -// and thus run successfully even when compiled at -C opt-level=0. - -const LEN: usize = 1 << 15; - -use std::thread::Builder; - -fn main() { - assert!(Builder::new().stack_size(LEN / 2).spawn(|| { - // FIXME(eddyb) this can be vec![[0: LEN]] pending - // https://llvm.org/bugs/show_bug.cgi?id=28987 - let vec = vec![unsafe { std::mem::zeroed::<[u8; LEN]>() }]; - assert_eq!(vec.len(), 1); - }).unwrap().join().is_ok()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2895.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2895.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2895.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2895.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// Copyright 2012-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::mem; - -struct Cat { - x: isize -} - -struct Kitty { - x: isize, -} - -impl Drop for Kitty { - fn drop(&mut self) {} -} - -#[cfg(target_pointer_width = "64")] -pub fn main() { - assert_eq!(mem::size_of::(), 8 as usize); - assert_eq!(mem::size_of::(), 8 as usize); -} - -#[cfg(target_pointer_width = "32")] -pub fn main() { - assert_eq!(mem::size_of::(), 4 as usize); - assert_eq!(mem::size_of::(), 4 as usize); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28983.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28983.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28983.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28983.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub trait Test { type T; } - -impl Test for u32 { - type T = i32; -} - -pub mod export { - #[no_mangle] - pub extern "C" fn issue_28983(t: ::T) -> i32 { t*3 } -} - -// to test both exporting and importing functions, import -// a function from ourselves. -extern "C" { - fn issue_28983(t: ::T) -> i32; -} - -fn main() { - assert_eq!(export::issue_28983(2), 6); - assert_eq!(unsafe { issue_28983(3) }, 9); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28999.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28999.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28999.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-28999.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub struct Xyz<'a, V> { - pub v: (V, &'a u32), -} - -pub fn eq<'a, 's, 't, V>(this: &'s Xyz<'a, V>, other: &'t Xyz<'a, V>) -> bool - where V: PartialEq { - this.v == other.v -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29030.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29030.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29030.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29030.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Debug)] -struct Message<'a, P: 'a = &'a [u8]> { - header: &'a [u8], - payload: P, -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29037.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29037.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29037.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29037.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This test ensures that each pointer type `P` is covariant in `X`. - -use std::rc::Rc; -use std::sync::Arc; - -fn a<'r>(x: Box<&'static str>) -> Box<&'r str> { - x -} - -fn b<'r, 'w>(x: &'w &'static str) -> &'w &'r str { - x -} - -fn c<'r>(x: Arc<&'static str>) -> Arc<&'r str> { - x -} - -fn d<'r>(x: Rc<&'static str>) -> Rc<&'r str> { - x -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29048.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29048.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29048.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29048.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub struct Chan; -pub struct ChanSelect<'c, T> { - chans: Vec<(&'c Chan, T)>, -} -impl<'c, T> ChanSelect<'c, T> { - pub fn add_recv_ret(&mut self, chan: &'c Chan, ret: T) - { - self.chans.push((chan, ret)); - } -} -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2904.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2904.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2904.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2904.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// Map representation - -use std::fmt; -use std::io::prelude::*; -use square::{bot, wall, rock, lambda, closed_lift, open_lift, earth, empty}; - -enum square { - bot, - wall, - rock, - lambda, - closed_lift, - open_lift, - earth, - empty -} - -impl fmt::Debug for square { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", match *self { - bot => { "R".to_string() } - wall => { "#".to_string() } - rock => { "*".to_string() } - lambda => { "\\".to_string() } - closed_lift => { "L".to_string() } - open_lift => { "O".to_string() } - earth => { ".".to_string() } - empty => { " ".to_string() } - }) - } -} - -fn square_from_char(c: char) -> square { - match c { - 'R' => { bot } - '#' => { wall } - '*' => { rock } - '\\' => { lambda } - 'L' => { closed_lift } - 'O' => { open_lift } - '.' => { earth } - ' ' => { empty } - _ => { - println!("invalid square: {}", c); - panic!() - } - } -} - -fn read_board_grid(mut input: rdr) - -> Vec> { - let mut input: &mut Read = &mut input; - let mut grid = Vec::new(); - let mut line = [0; 10]; - input.read(&mut line); - let mut row = Vec::new(); - for c in &line { - row.push(square_from_char(*c as char)) - } - grid.push(row); - let width = grid[0].len(); - for row in &grid { assert_eq!(row.len(), width) } - grid -} - -mod test { - #[test] - pub fn trivial_to_string() { - assert_eq!(lambda.to_string(), "\\") - } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29053.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29053.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29053.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29053.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - let x: &'static str = "x"; - - { - let y = "y".to_string(); - let ref mut x = &*x; - *x = &*y; - } - - assert_eq!(x, "x"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29071-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29071-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29071-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29071-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn t1() -> u32 { - let x; - x = if true { [1, 2, 3] } else { [2, 3, 4] }[0]; - x -} - -fn t2() -> [u32; 1] { - if true { [1, 2, 3]; } else { [2, 3, 4]; } - [0] -} - -fn t3() -> u32 { - let x; - x = if true { i1 as F } else { i2 as F }(); - x -} - -fn t4() -> () { - if true { i1 as F; } else { i2 as F; } - () -} - -type F = fn() -> u32; -fn i1() -> u32 { 1 } -fn i2() -> u32 { 2 } - -fn main() { - assert_eq!(t1(), 1); - assert_eq!(t3(), 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29071.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29071.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29071.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29071.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -fn ret() -> u32 { - static x: u32 = 10; - x & if true { 10u32 } else { 20u32 } & x -} - -fn ret2() -> &'static u32 { - static x: u32 = 10; - if true { 10u32; } else { 20u32; } - &x -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29092.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29092.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29092.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29092.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for Issue #29092. -// -// (Possibly redundant with regression test run-pass/issue-30530.rs) - -use self::Term::*; - -#[derive(Clone)] -pub enum Term { - Dummy, - A(Box), - B(Box), -} - -// a small-step evaluator -pub fn small_eval(v: Term) -> Term { - match v { - A(t) => *t.clone(), - B(t) => *t.clone(), - _ => Dummy, - } -} - -fn main() { - small_eval(Dummy); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29147.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29147.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29147.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29147.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![recursion_limit="1024"] - -use std::mem; - -pub struct S0(T,T); -pub struct S1(Option>>>,Option>>>); -pub struct S2(Option>>>,Option>>>); -pub struct S3(Option>>>,Option>>>); -pub struct S4(Option>>>,Option>>>); -pub struct S5(Option>>>,Option>>>,Option); - -trait Foo { fn xxx(&self); } -/// some local of #[fundamental] trait -trait Bar {} - -impl Foo for T where T: Bar, T: Sync { - fn xxx(&self) {} -} - -impl Foo for S5 { fn xxx(&self) {} } - -fn main() { - let s = S5(None,None,None); - s.xxx(); - assert_eq!(mem::size_of_val(&s.2), mem::size_of::>()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29166.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29166.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29166.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29166.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This test ensures that vec.into_iter does not overconstrain element lifetime. - -pub fn main() { - original_report(); - revision_1(); - revision_2(); -} - -fn original_report() { - drop(vec![&()].into_iter()) -} - -fn revision_1() { - // below is what above `vec!` expands into at time of this writing. - drop(<[_]>::into_vec(::std::boxed::Box::new([&()])).into_iter()) -} - -fn revision_2() { - drop((match (Vec::new(), &()) { (mut v, b) => { v.push(b); v } }).into_iter()) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29227.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29227.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29227.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29227.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,152 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-tidy-linelength - -// Regression test for #29227. The problem here was that MIR -// construction for these gigantic match expressions was very -// inefficient. - -pub trait CharExt : Sized + Copy { - fn is_unicode_uppercase_letter(self) -> bool { false } - fn is_unicode_lowercase_letter(self) -> bool { false } - fn is_unicode_titlecase_letter(self) -> bool { false } - fn is_unicode_modifier_letter(self) -> bool { false } - fn is_unicode_other_letter(self) -> bool { false } - fn is_unicode_letter_number(self) -> bool { false } - fn is_unicode_nonspacing_mark(self) -> bool { false } - fn is_unicode_combining_spacing_mark(self) -> bool { false } - fn is_unicode_decimal_number(self) -> bool{ false } - fn is_unicode_connector_punctiation(self) -> bool { false } - fn is_unicode_space_separator(self) -> bool { false } - - fn is_es_identifier_start(self) -> bool { false } - fn is_es_identifier_part(self) -> bool { false } - fn is_es_whitespace(self) -> bool { false } - fn is_es_line_terminator(self) -> bool { false } - - fn is_unicode_letter(self) -> bool { - self.is_unicode_uppercase_letter() - || self.is_unicode_lowercase_letter() - || self.is_unicode_titlecase_letter() - || self.is_unicode_modifier_letter() - || self.is_unicode_modifier_letter() - || self.is_unicode_letter_number() - } - -} - - -macro_rules! match_char_class { - ($thing:expr, $($c:expr),*) => { - match $thing { - $($c)|* => true, - _ => false - } - } -} - -impl CharExt for char { - fn is_unicode_uppercase_letter(self) -> bool { - match_char_class!(self, - '\u{0041}', '\u{0042}', '\u{0043}', '\u{0044}', '\u{0045}', '\u{0046}', '\u{0047}', '\u{0048}', '\u{0049}', '\u{004A}', '\u{004B}', '\u{004C}', '\u{004D}', '\u{004E}', '\u{004F}', '\u{0050}', '\u{0051}', '\u{0052}', '\u{0053}', '\u{0054}', '\u{0055}', '\u{0056}', '\u{0057}', '\u{0058}', '\u{0059}', '\u{005A}', '\u{00C0}', '\u{00C1}', '\u{00C2}', '\u{00C3}', '\u{00C4}', '\u{00C5}', '\u{00C6}', '\u{00C7}', '\u{00C8}', '\u{00C9}', '\u{00CA}', '\u{00CB}', '\u{00CC}', '\u{00CD}', '\u{00CE}', '\u{00CF}', '\u{00D0}', '\u{00D1}', '\u{00D2}', '\u{00D3}', '\u{00D4}', '\u{00D5}', '\u{00D6}', '\u{00D8}', '\u{00D9}', '\u{00DA}', '\u{00DB}', '\u{00DC}', '\u{00DD}', '\u{00DE}', '\u{0100}', '\u{0102}', '\u{0104}', '\u{0106}', '\u{0108}', '\u{010A}', '\u{010C}', '\u{010E}', '\u{0110}', '\u{0112}', '\u{0114}', '\u{0116}', '\u{0118}', '\u{011A}', '\u{011C}', '\u{011E}', '\u{0120}', '\u{0122}', '\u{0124}', '\u{0126}', '\u{0128}', '\u{012A}', '\u{012C}', '\u{012E}', '\u{0130}', '\u{0132}', '\u{0134}', '\u{0136}', '\u{0139}', '\u{013B}', '\u{013D}', '\u{013F}', '\u{0141}', '\u{0143}', '\u{0145}', '\u{0147}', '\u{014A}', '\u{014C}', '\u{014E}', '\u{0150}', '\u{0152}', '\u{0154}', '\u{0156}', '\u{0158}', '\u{015A}', '\u{015C}', '\u{015E}', '\u{0160}', '\u{0162}', '\u{0164}', '\u{0166}', '\u{0168}', '\u{016A}', '\u{016C}', '\u{016E}', '\u{0170}', '\u{0172}', '\u{0174}', '\u{0176}', '\u{0178}', '\u{0179}', '\u{017B}', '\u{017D}', '\u{0181}', '\u{0182}', '\u{0184}', '\u{0186}', '\u{0187}', '\u{0189}', '\u{018A}', '\u{018B}', '\u{018E}', '\u{018F}', '\u{0190}', '\u{0191}', '\u{0193}', '\u{0194}', '\u{0196}', '\u{0197}', '\u{0198}', '\u{019C}', '\u{019D}', '\u{019F}', '\u{01A0}', '\u{01A2}', '\u{01A4}', '\u{01A6}', '\u{01A7}', '\u{01A9}', '\u{01AC}', '\u{01AE}', '\u{01AF}', '\u{01B1}', '\u{01B2}', '\u{01B3}', '\u{01B5}', '\u{01B7}', '\u{01B8}', '\u{01BC}', '\u{01C4}', '\u{01C7}', '\u{01CA}', '\u{01CD}', '\u{01CF}', '\u{01D1}', '\u{01D3}', '\u{01D5}', '\u{01D7}', '\u{01D9}', '\u{01DB}', '\u{01DE}', '\u{01E0}', '\u{01E2}', '\u{01E4}', '\u{01E6}', '\u{01E8}', '\u{01EA}', '\u{01EC}', '\u{01EE}', '\u{01F1}', '\u{01F4}', '\u{01F6}', '\u{01F7}', '\u{01F8}', '\u{01FA}', '\u{01FC}', '\u{01FE}', '\u{0200}', '\u{0202}', '\u{0204}', '\u{0206}', '\u{0208}', '\u{020A}', '\u{020C}', '\u{020E}', '\u{0210}', '\u{0212}', '\u{0214}', '\u{0216}', '\u{0218}', '\u{021A}', '\u{021C}', '\u{021E}', '\u{0220}', '\u{0222}', '\u{0224}', '\u{0226}', '\u{0228}', '\u{022A}', '\u{022C}', '\u{022E}', '\u{0230}', '\u{0232}', '\u{023A}', '\u{023B}', '\u{023D}', '\u{023E}', '\u{0241}', '\u{0243}', '\u{0244}', '\u{0245}', '\u{0246}', '\u{0248}', '\u{024A}', '\u{024C}', '\u{024E}', '\u{0370}', '\u{0372}', '\u{0376}', '\u{0386}', '\u{0388}', '\u{0389}', '\u{038A}', '\u{038C}', '\u{038E}', '\u{038F}', '\u{0391}', '\u{0392}', '\u{0393}', '\u{0394}', '\u{0395}', '\u{0396}', '\u{0397}', '\u{0398}', '\u{0399}', '\u{039A}', '\u{039B}', '\u{039C}', '\u{039D}', '\u{039E}', '\u{039F}', '\u{03A0}', '\u{03A1}', '\u{03A3}', '\u{03A4}', '\u{03A5}', '\u{03A6}', '\u{03A7}', '\u{03A8}', '\u{03A9}', '\u{03AA}', '\u{03AB}', '\u{03CF}', '\u{03D2}', '\u{03D3}', '\u{03D4}', '\u{03D8}', '\u{03DA}', '\u{03DC}', '\u{03DE}', '\u{03E0}', '\u{03E2}', '\u{03E4}', '\u{03E6}', '\u{03E8}', '\u{03EA}', '\u{03EC}', '\u{03EE}', '\u{03F4}', '\u{03F7}', '\u{03F9}', '\u{03FA}', '\u{03FD}', '\u{03FE}', '\u{03FF}', '\u{0400}', '\u{0401}', '\u{0402}', '\u{0403}', '\u{0404}', '\u{0405}', '\u{0406}', '\u{0407}', '\u{0408}', '\u{0409}', '\u{040A}', '\u{040B}', '\u{040C}', '\u{040D}', '\u{040E}', '\u{040F}', '\u{0410}', '\u{0411}', '\u{0412}', '\u{0413}', '\u{0414}', '\u{0415}', '\u{0416}', '\u{0417}', '\u{0418}', '\u{0419}', '\u{041A}', '\u{041B}', '\u{041C}', '\u{041D}', '\u{041E}', '\u{041F}', '\u{0420}', '\u{0421}', '\u{0422}', '\u{0423}', '\u{0424}', '\u{0425}', '\u{0426}', '\u{0427}', '\u{0428}', '\u{0429}', '\u{042A}', '\u{042B}', '\u{042C}', '\u{042D}', '\u{042E}', '\u{042F}', '\u{0460}', '\u{0462}', '\u{0464}', '\u{0466}', '\u{0468}', '\u{046A}', '\u{046C}', '\u{046E}', '\u{0470}', '\u{0472}', '\u{0474}', '\u{0476}', '\u{0478}', '\u{047A}', '\u{047C}', '\u{047E}', '\u{0480}', '\u{048A}', '\u{048C}', '\u{048E}', '\u{0490}', '\u{0492}', '\u{0494}', '\u{0496}', '\u{0498}', '\u{049A}', '\u{049C}', '\u{049E}', '\u{04A0}', '\u{04A2}', '\u{04A4}', '\u{04A6}', '\u{04A8}', '\u{04AA}', '\u{04AC}', '\u{04AE}', '\u{04B0}', '\u{04B2}', '\u{04B4}', '\u{04B6}', '\u{04B8}', '\u{04BA}', '\u{04BC}', '\u{04BE}', '\u{04C0}', '\u{04C1}', '\u{04C3}', '\u{04C5}', '\u{04C7}', '\u{04C9}', '\u{04CB}', '\u{04CD}', '\u{04D0}', '\u{04D2}', '\u{04D4}', '\u{04D6}', '\u{04D8}', '\u{04DA}', '\u{04DC}', '\u{04DE}', '\u{04E0}', '\u{04E2}', '\u{04E4}', '\u{04E6}', '\u{04E8}', '\u{04EA}', '\u{04EC}', '\u{04EE}', '\u{04F0}', '\u{04F2}', '\u{04F4}', '\u{04F6}', '\u{04F8}', '\u{04FA}', '\u{04FC}', '\u{04FE}', '\u{0500}', '\u{0502}', '\u{0504}', '\u{0506}', '\u{0508}', '\u{050A}', '\u{050C}', '\u{050E}', '\u{0510}', '\u{0512}', '\u{0514}', '\u{0516}', '\u{0518}', '\u{051A}', '\u{051C}', '\u{051E}', '\u{0520}', '\u{0522}', '\u{0531}', '\u{0532}', '\u{0533}', '\u{0534}', '\u{0535}', '\u{0536}', '\u{0537}', '\u{0538}', '\u{0539}', '\u{053A}', '\u{053B}', '\u{053C}', '\u{053D}', '\u{053E}', '\u{053F}', '\u{0540}', '\u{0541}', '\u{0542}', '\u{0543}', '\u{0544}', '\u{0545}', '\u{0546}', '\u{0547}', '\u{0548}', '\u{0549}', '\u{054A}', '\u{054B}', '\u{054C}', '\u{054D}', '\u{054E}', '\u{054F}', '\u{0550}', '\u{0551}', '\u{0552}', '\u{0553}', '\u{0554}', '\u{0555}', '\u{0556}', '\u{10A0}', '\u{10A1}', '\u{10A2}', '\u{10A3}', '\u{10A4}', '\u{10A5}', '\u{10A6}', '\u{10A7}', '\u{10A8}', '\u{10A9}', '\u{10AA}', '\u{10AB}', '\u{10AC}', '\u{10AD}', '\u{10AE}', '\u{10AF}', '\u{10B0}', '\u{10B1}', '\u{10B2}', '\u{10B3}', '\u{10B4}', '\u{10B5}', '\u{10B6}', '\u{10B7}', '\u{10B8}', '\u{10B9}', '\u{10BA}', '\u{10BB}', '\u{10BC}', '\u{10BD}', '\u{10BE}', '\u{10BF}', '\u{10C0}', '\u{10C1}', '\u{10C2}', '\u{10C3}', '\u{10C4}', '\u{10C5}', '\u{1E00}', '\u{1E02}', '\u{1E04}', '\u{1E06}', '\u{1E08}', '\u{1E0A}', '\u{1E0C}', '\u{1E0E}', '\u{1E10}', '\u{1E12}', '\u{1E14}', '\u{1E16}', '\u{1E18}', '\u{1E1A}', '\u{1E1C}', '\u{1E1E}', '\u{1E20}', '\u{1E22}', '\u{1E24}', '\u{1E26}', '\u{1E28}', '\u{1E2A}', '\u{1E2C}', '\u{1E2E}', '\u{1E30}', '\u{1E32}', '\u{1E34}', '\u{1E36}', '\u{1E38}', '\u{1E3A}', '\u{1E3C}', '\u{1E3E}', '\u{1E40}', '\u{1E42}', '\u{1E44}', '\u{1E46}', '\u{1E48}', '\u{1E4A}', '\u{1E4C}', '\u{1E4E}', '\u{1E50}', '\u{1E52}', '\u{1E54}', '\u{1E56}', '\u{1E58}', '\u{1E5A}', '\u{1E5C}', '\u{1E5E}', '\u{1E60}', '\u{1E62}', '\u{1E64}', '\u{1E66}', '\u{1E68}', '\u{1E6A}', '\u{1E6C}', '\u{1E6E}', '\u{1E70}', '\u{1E72}', '\u{1E74}', '\u{1E76}', '\u{1E78}', '\u{1E7A}', '\u{1E7C}', '\u{1E7E}', '\u{1E80}', '\u{1E82}', '\u{1E84}', '\u{1E86}', '\u{1E88}', '\u{1E8A}', '\u{1E8C}', '\u{1E8E}', '\u{1E90}', '\u{1E92}', '\u{1E94}', '\u{1E9E}', '\u{1EA0}', '\u{1EA2}', '\u{1EA4}', '\u{1EA6}', '\u{1EA8}', '\u{1EAA}', '\u{1EAC}', '\u{1EAE}', '\u{1EB0}', '\u{1EB2}', '\u{1EB4}', '\u{1EB6}', '\u{1EB8}', '\u{1EBA}', '\u{1EBC}', '\u{1EBE}', '\u{1EC0}', '\u{1EC2}', '\u{1EC4}', '\u{1EC6}', '\u{1EC8}', '\u{1ECA}', '\u{1ECC}', '\u{1ECE}', '\u{1ED0}', '\u{1ED2}', '\u{1ED4}', '\u{1ED6}', '\u{1ED8}', '\u{1EDA}', '\u{1EDC}', '\u{1EDE}', '\u{1EE0}', '\u{1EE2}', '\u{1EE4}', '\u{1EE6}', '\u{1EE8}', '\u{1EEA}', '\u{1EEC}', '\u{1EEE}', '\u{1EF0}', '\u{1EF2}', '\u{1EF4}', '\u{1EF6}', '\u{1EF8}', '\u{1EFA}', '\u{1EFC}', '\u{1EFE}', '\u{1F08}', '\u{1F09}', '\u{1F0A}', '\u{1F0B}', '\u{1F0C}', '\u{1F0D}', '\u{1F0E}', '\u{1F0F}', '\u{1F18}', '\u{1F19}', '\u{1F1A}', '\u{1F1B}', '\u{1F1C}', '\u{1F1D}', '\u{1F28}', '\u{1F29}', '\u{1F2A}', '\u{1F2B}', '\u{1F2C}', '\u{1F2D}', '\u{1F2E}', '\u{1F2F}', '\u{1F38}', '\u{1F39}', '\u{1F3A}', '\u{1F3B}', '\u{1F3C}', '\u{1F3D}', '\u{1F3E}', '\u{1F3F}', '\u{1F48}', '\u{1F49}', '\u{1F4A}', '\u{1F4B}', '\u{1F4C}', '\u{1F4D}', '\u{1F59}', '\u{1F5B}', '\u{1F5D}', '\u{1F5F}', '\u{1F68}', '\u{1F69}', '\u{1F6A}', '\u{1F6B}', '\u{1F6C}', '\u{1F6D}', '\u{1F6E}', '\u{1F6F}', '\u{1FB8}', '\u{1FB9}', '\u{1FBA}', '\u{1FBB}', '\u{1FC8}', '\u{1FC9}', '\u{1FCA}', '\u{1FCB}', '\u{1FD8}', '\u{1FD9}', '\u{1FDA}', '\u{1FDB}', '\u{1FE8}', '\u{1FE9}', '\u{1FEA}', '\u{1FEB}', '\u{1FEC}', '\u{1FF8}', '\u{1FF9}', '\u{1FFA}', '\u{1FFB}', '\u{2102}', '\u{2107}', '\u{210B}', '\u{210C}', '\u{210D}', '\u{2110}', '\u{2111}', '\u{2112}', '\u{2115}', '\u{2119}', '\u{211A}', '\u{211B}', '\u{211C}', '\u{211D}', '\u{2124}', '\u{2126}', '\u{2128}', '\u{212A}', '\u{212B}', '\u{212C}', '\u{212D}', '\u{2130}', '\u{2131}', '\u{2132}', '\u{2133}', '\u{213E}', '\u{213F}', '\u{2145}', '\u{2183}', '\u{2C00}', '\u{2C01}', '\u{2C02}', '\u{2C03}', '\u{2C04}', '\u{2C05}', '\u{2C06}', '\u{2C07}', '\u{2C08}', '\u{2C09}', '\u{2C0A}', '\u{2C0B}', '\u{2C0C}', '\u{2C0D}', '\u{2C0E}', '\u{2C0F}', '\u{2C10}', '\u{2C11}', '\u{2C12}', '\u{2C13}', '\u{2C14}', '\u{2C15}', '\u{2C16}', '\u{2C17}', '\u{2C18}', '\u{2C19}', '\u{2C1A}', '\u{2C1B}', '\u{2C1C}', '\u{2C1D}', '\u{2C1E}', '\u{2C1F}', '\u{2C20}', '\u{2C21}', '\u{2C22}', '\u{2C23}', '\u{2C24}', '\u{2C25}', '\u{2C26}', '\u{2C27}', '\u{2C28}', '\u{2C29}', '\u{2C2A}', '\u{2C2B}', '\u{2C2C}', '\u{2C2D}', '\u{2C2E}', '\u{2C60}', '\u{2C62}', '\u{2C63}', '\u{2C64}', '\u{2C67}', '\u{2C69}', '\u{2C6B}', '\u{2C6D}', '\u{2C6E}', '\u{2C6F}', '\u{2C72}', '\u{2C75}', '\u{2C80}', '\u{2C82}', '\u{2C84}', '\u{2C86}', '\u{2C88}', '\u{2C8A}', '\u{2C8C}', '\u{2C8E}', '\u{2C90}', '\u{2C92}', '\u{2C94}', '\u{2C96}', '\u{2C98}', '\u{2C9A}', '\u{2C9C}', '\u{2C9E}', '\u{2CA0}', '\u{2CA2}', '\u{2CA4}', '\u{2CA6}', '\u{2CA8}', '\u{2CAA}', '\u{2CAC}', '\u{2CAE}', '\u{2CB0}', '\u{2CB2}', '\u{2CB4}', '\u{2CB6}', '\u{2CB8}', '\u{2CBA}', '\u{2CBC}', '\u{2CBE}', '\u{2CC0}', '\u{2CC2}', '\u{2CC4}', '\u{2CC6}', '\u{2CC8}', '\u{2CCA}', '\u{2CCC}', '\u{2CCE}', '\u{2CD0}', '\u{2CD2}', '\u{2CD4}', '\u{2CD6}', '\u{2CD8}', '\u{2CDA}', '\u{2CDC}', '\u{2CDE}', '\u{2CE0}', '\u{2CE2}', '\u{A640}', '\u{A642}', '\u{A644}', '\u{A646}', '\u{A648}', '\u{A64A}', '\u{A64C}', '\u{A64E}', '\u{A650}', '\u{A652}', '\u{A654}', '\u{A656}', '\u{A658}', '\u{A65A}', '\u{A65C}', '\u{A65E}', '\u{A662}', '\u{A664}', '\u{A666}', '\u{A668}', '\u{A66A}', '\u{A66C}', '\u{A680}', '\u{A682}', '\u{A684}', '\u{A686}', '\u{A688}', '\u{A68A}', '\u{A68C}', '\u{A68E}', '\u{A690}', '\u{A692}', '\u{A694}', '\u{A696}', '\u{A722}', '\u{A724}', '\u{A726}', '\u{A728}', '\u{A72A}', '\u{A72C}', '\u{A72E}', '\u{A732}', '\u{A734}', '\u{A736}', '\u{A738}', '\u{A73A}', '\u{A73C}', '\u{A73E}', '\u{A740}', '\u{A742}', '\u{A744}', '\u{A746}', '\u{A748}', '\u{A74A}', '\u{A74C}', '\u{A74E}', '\u{A750}', '\u{A752}', '\u{A754}', '\u{A756}', '\u{A758}', '\u{A75A}', '\u{A75C}', '\u{A75E}', '\u{A760}', '\u{A762}', '\u{A764}', '\u{A766}', '\u{A768}', '\u{A76A}', '\u{A76C}', '\u{A76E}', '\u{A779}', '\u{A77B}', '\u{A77D}', '\u{A77E}', '\u{A780}', '\u{A782}', '\u{A784}', '\u{A786}', '\u{A78B}', '\u{FF21}', '\u{FF22}', '\u{FF23}', '\u{FF24}', '\u{FF25}', '\u{FF26}', '\u{FF27}', '\u{FF28}', '\u{FF29}', '\u{FF2A}', '\u{FF2B}', '\u{FF2C}', '\u{FF2D}', '\u{FF2E}', '\u{FF2F}', '\u{FF30}', '\u{FF31}', '\u{FF32}', '\u{FF33}', '\u{FF34}', '\u{FF35}', '\u{FF36}', '\u{FF37}', '\u{FF38}', '\u{FF39}', '\u{FF3A}') - } - - fn is_unicode_lowercase_letter(self) -> bool { - match_char_class!(self, - '\u{0061}', '\u{0062}', '\u{0063}', '\u{0064}', '\u{0065}', '\u{0066}', '\u{0067}', '\u{0068}', '\u{0069}', '\u{006A}', '\u{006B}', '\u{006C}', '\u{006D}', '\u{006E}', '\u{006F}', '\u{0070}', '\u{0071}', '\u{0072}', '\u{0073}', '\u{0074}', '\u{0075}', '\u{0076}', '\u{0077}', '\u{0078}', '\u{0079}', '\u{007A}', '\u{00AA}', '\u{00B5}', '\u{00BA}', '\u{00DF}', '\u{00E0}', '\u{00E1}', '\u{00E2}', '\u{00E3}', '\u{00E4}', '\u{00E5}', '\u{00E6}', '\u{00E7}', '\u{00E8}', '\u{00E9}', '\u{00EA}', '\u{00EB}', '\u{00EC}', '\u{00ED}', '\u{00EE}', '\u{00EF}', '\u{00F0}', '\u{00F1}', '\u{00F2}', '\u{00F3}', '\u{00F4}', '\u{00F5}', '\u{00F6}', '\u{00F8}', '\u{00F9}', '\u{00FA}', '\u{00FB}', '\u{00FC}', '\u{00FD}', '\u{00FE}', '\u{00FF}', '\u{0101}', '\u{0103}', '\u{0105}', '\u{0107}', '\u{0109}', '\u{010B}', '\u{010D}', '\u{010F}', '\u{0111}', '\u{0113}', '\u{0115}', '\u{0117}', '\u{0119}', '\u{011B}', '\u{011D}', '\u{011F}', '\u{0121}', '\u{0123}', '\u{0125}', '\u{0127}', '\u{0129}', '\u{012B}', '\u{012D}', '\u{012F}', '\u{0131}', '\u{0133}', '\u{0135}', '\u{0137}', '\u{0138}', '\u{013A}', '\u{013C}', '\u{013E}', '\u{0140}', '\u{0142}', '\u{0144}', '\u{0146}', '\u{0148}', '\u{0149}', '\u{014B}', '\u{014D}', '\u{014F}', '\u{0151}', '\u{0153}', '\u{0155}', '\u{0157}', '\u{0159}', '\u{015B}', '\u{015D}', '\u{015F}', '\u{0161}', '\u{0163}', '\u{0165}', '\u{0167}', '\u{0169}', '\u{016B}', '\u{016D}', '\u{016F}', '\u{0171}', '\u{0173}', '\u{0175}', '\u{0177}', '\u{017A}', '\u{017C}', '\u{017E}', '\u{017F}', '\u{0180}', '\u{0183}', '\u{0185}', '\u{0188}', '\u{018C}', '\u{018D}', '\u{0192}', '\u{0195}', '\u{0199}', '\u{019A}', '\u{019B}', '\u{019E}', '\u{01A1}', '\u{01A3}', '\u{01A5}', '\u{01A8}', '\u{01AA}', '\u{01AB}', '\u{01AD}', '\u{01B0}', '\u{01B4}', '\u{01B6}', '\u{01B9}', '\u{01BA}', '\u{01BD}', '\u{01BE}', '\u{01BF}', '\u{01C6}', '\u{01C9}', '\u{01CC}', '\u{01CE}', '\u{01D0}', '\u{01D2}', '\u{01D4}', '\u{01D6}', '\u{01D8}', '\u{01DA}', '\u{01DC}', '\u{01DD}', '\u{01DF}', '\u{01E1}', '\u{01E3}', '\u{01E5}', '\u{01E7}', '\u{01E9}', '\u{01EB}', '\u{01ED}', '\u{01EF}', '\u{01F0}', '\u{01F3}', '\u{01F5}', '\u{01F9}', '\u{01FB}', '\u{01FD}', '\u{01FF}', '\u{0201}', '\u{0203}', '\u{0205}', '\u{0207}', '\u{0209}', '\u{020B}', '\u{020D}', '\u{020F}', '\u{0211}', '\u{0213}', '\u{0215}', '\u{0217}', '\u{0219}', '\u{021B}', '\u{021D}', '\u{021F}', '\u{0221}', '\u{0223}', '\u{0225}', '\u{0227}', '\u{0229}', '\u{022B}', '\u{022D}', '\u{022F}', '\u{0231}', '\u{0233}', '\u{0234}', '\u{0235}', '\u{0236}', '\u{0237}', '\u{0238}', '\u{0239}', '\u{023C}', '\u{023F}', '\u{0240}', '\u{0242}', '\u{0247}', '\u{0249}', '\u{024B}', '\u{024D}', '\u{024F}', '\u{0250}', '\u{0251}', '\u{0252}', '\u{0253}', '\u{0254}', '\u{0255}', '\u{0256}', '\u{0257}', '\u{0258}', '\u{0259}', '\u{025A}', '\u{025B}', '\u{025C}', '\u{025D}', '\u{025E}', '\u{025F}', '\u{0260}', '\u{0261}', '\u{0262}', '\u{0263}', '\u{0264}', '\u{0265}', '\u{0266}', '\u{0267}', '\u{0268}', '\u{0269}', '\u{026A}', '\u{026B}', '\u{026C}', '\u{026D}', '\u{026E}', '\u{026F}', '\u{0270}', '\u{0271}', '\u{0272}', '\u{0273}', '\u{0274}', '\u{0275}', '\u{0276}', '\u{0277}', '\u{0278}', '\u{0279}', '\u{027A}', '\u{027B}', '\u{027C}', '\u{027D}', '\u{027E}', '\u{027F}', '\u{0280}', '\u{0281}', '\u{0282}', '\u{0283}', '\u{0284}', '\u{0285}', '\u{0286}', '\u{0287}', '\u{0288}', '\u{0289}', '\u{028A}', '\u{028B}', '\u{028C}', '\u{028D}', '\u{028E}', '\u{028F}', '\u{0290}', '\u{0291}', '\u{0292}', '\u{0293}', '\u{0295}', '\u{0296}', '\u{0297}', '\u{0298}', '\u{0299}', '\u{029A}', '\u{029B}', '\u{029C}', '\u{029D}', '\u{029E}', '\u{029F}', '\u{02A0}', '\u{02A1}', '\u{02A2}', '\u{02A3}', '\u{02A4}', '\u{02A5}', '\u{02A6}', '\u{02A7}', '\u{02A8}', '\u{02A9}', '\u{02AA}', '\u{02AB}', '\u{02AC}', '\u{02AD}', '\u{02AE}', '\u{02AF}', '\u{0371}', '\u{0373}', '\u{0377}', '\u{037B}', '\u{037C}', '\u{037D}', '\u{0390}', '\u{03AC}', '\u{03AD}', '\u{03AE}', '\u{03AF}', '\u{03B0}', '\u{03B1}', '\u{03B2}', '\u{03B3}', '\u{03B4}', '\u{03B5}', '\u{03B6}', '\u{03B7}', '\u{03B8}', '\u{03B9}', '\u{03BA}', '\u{03BB}', '\u{03BC}', '\u{03BD}', '\u{03BE}', '\u{03BF}', '\u{03C0}', '\u{03C1}', '\u{03C2}', '\u{03C3}', '\u{03C4}', '\u{03C5}', '\u{03C6}', '\u{03C7}', '\u{03C8}', '\u{03C9}', '\u{03CA}', '\u{03CB}', '\u{03CC}', '\u{03CD}', '\u{03CE}', '\u{03D0}', '\u{03D1}', '\u{03D5}', '\u{03D6}', '\u{03D7}', '\u{03D9}', '\u{03DB}', '\u{03DD}', '\u{03DF}', '\u{03E1}', '\u{03E3}', '\u{03E5}', '\u{03E7}', '\u{03E9}', '\u{03EB}', '\u{03ED}', '\u{03EF}', '\u{03F0}', '\u{03F1}', '\u{03F2}', '\u{03F3}', '\u{03F5}', '\u{03F8}', '\u{03FB}', '\u{03FC}', '\u{0430}', '\u{0431}', '\u{0432}', '\u{0433}', '\u{0434}', '\u{0435}', '\u{0436}', '\u{0437}', '\u{0438}', '\u{0439}', '\u{043A}', '\u{043B}', '\u{043C}', '\u{043D}', '\u{043E}', '\u{043F}', '\u{0440}', '\u{0441}', '\u{0442}', '\u{0443}', '\u{0444}', '\u{0445}', '\u{0446}', '\u{0447}', '\u{0448}', '\u{0449}', '\u{044A}', '\u{044B}', '\u{044C}', '\u{044D}', '\u{044E}', '\u{044F}', '\u{0450}', '\u{0451}', '\u{0452}', '\u{0453}', '\u{0454}', '\u{0455}', '\u{0456}', '\u{0457}', '\u{0458}', '\u{0459}', '\u{045A}', '\u{045B}', '\u{045C}', '\u{045D}', '\u{045E}', '\u{045F}', '\u{0461}', '\u{0463}', '\u{0465}', '\u{0467}', '\u{0469}', '\u{046B}', '\u{046D}', '\u{046F}', '\u{0471}', '\u{0473}', '\u{0475}', '\u{0477}', '\u{0479}', '\u{047B}', '\u{047D}', '\u{047F}', '\u{0481}', '\u{048B}', '\u{048D}', '\u{048F}', '\u{0491}', '\u{0493}', '\u{0495}', '\u{0497}', '\u{0499}', '\u{049B}', '\u{049D}', '\u{049F}', '\u{04A1}', '\u{04A3}', '\u{04A5}', '\u{04A7}', '\u{04A9}', '\u{04AB}', '\u{04AD}', '\u{04AF}', '\u{04B1}', '\u{04B3}', '\u{04B5}', '\u{04B7}', '\u{04B9}', '\u{04BB}', '\u{04BD}', '\u{04BF}', '\u{04C2}', '\u{04C4}', '\u{04C6}', '\u{04C8}', '\u{04CA}', '\u{04CC}', '\u{04CE}', '\u{04CF}', '\u{04D1}', '\u{04D3}', '\u{04D5}', '\u{04D7}', '\u{04D9}', '\u{04DB}', '\u{04DD}', '\u{04DF}', '\u{04E1}', '\u{04E3}', '\u{04E5}', '\u{04E7}', '\u{04E9}', '\u{04EB}', '\u{04ED}', '\u{04EF}', '\u{04F1}', '\u{04F3}', '\u{04F5}', '\u{04F7}', '\u{04F9}', '\u{04FB}', '\u{04FD}', '\u{04FF}', '\u{0501}', '\u{0503}', '\u{0505}', '\u{0507}', '\u{0509}', '\u{050B}', '\u{050D}', '\u{050F}', '\u{0511}', '\u{0513}', '\u{0515}', '\u{0517}', '\u{0519}', '\u{051B}', '\u{051D}', '\u{051F}', '\u{0521}', '\u{0523}', '\u{0561}', '\u{0562}', '\u{0563}', '\u{0564}', '\u{0565}', '\u{0566}', '\u{0567}', '\u{0568}', '\u{0569}', '\u{056A}', '\u{056B}', '\u{056C}', '\u{056D}', '\u{056E}', '\u{056F}', '\u{0570}', '\u{0571}', '\u{0572}', '\u{0573}', '\u{0574}', '\u{0575}', '\u{0576}', '\u{0577}', '\u{0578}', '\u{0579}', '\u{057A}', '\u{057B}', '\u{057C}', '\u{057D}', '\u{057E}', '\u{057F}', '\u{0580}', '\u{0581}', '\u{0582}', '\u{0583}', '\u{0584}', '\u{0585}', '\u{0586}', '\u{0587}', '\u{1D00}', '\u{1D01}', '\u{1D02}', '\u{1D03}', '\u{1D04}', '\u{1D05}', '\u{1D06}', '\u{1D07}', '\u{1D08}', '\u{1D09}', '\u{1D0A}', '\u{1D0B}', '\u{1D0C}', '\u{1D0D}', '\u{1D0E}', '\u{1D0F}', '\u{1D10}', '\u{1D11}', '\u{1D12}', '\u{1D13}', '\u{1D14}', '\u{1D15}', '\u{1D16}', '\u{1D17}', '\u{1D18}', '\u{1D19}', '\u{1D1A}', '\u{1D1B}', '\u{1D1C}', '\u{1D1D}', '\u{1D1E}', '\u{1D1F}', '\u{1D20}', '\u{1D21}', '\u{1D22}', '\u{1D23}', '\u{1D24}', '\u{1D25}', '\u{1D26}', '\u{1D27}', '\u{1D28}', '\u{1D29}', '\u{1D2A}', '\u{1D2B}', '\u{1D62}', '\u{1D63}', '\u{1D64}', '\u{1D65}', '\u{1D66}', '\u{1D67}', '\u{1D68}', '\u{1D69}', '\u{1D6A}', '\u{1D6B}', '\u{1D6C}', '\u{1D6D}', '\u{1D6E}', '\u{1D6F}', '\u{1D70}', '\u{1D71}', '\u{1D72}', '\u{1D73}', '\u{1D74}', '\u{1D75}', '\u{1D76}', '\u{1D77}', '\u{1D79}', '\u{1D7A}', '\u{1D7B}', '\u{1D7C}', '\u{1D7D}', '\u{1D7E}', '\u{1D7F}', '\u{1D80}', '\u{1D81}', '\u{1D82}', '\u{1D83}', '\u{1D84}', '\u{1D85}', '\u{1D86}', '\u{1D87}', '\u{1D88}', '\u{1D89}', '\u{1D8A}', '\u{1D8B}', '\u{1D8C}', '\u{1D8D}', '\u{1D8E}', '\u{1D8F}', '\u{1D90}', '\u{1D91}', '\u{1D92}', '\u{1D93}', '\u{1D94}', '\u{1D95}', '\u{1D96}', '\u{1D97}', '\u{1D98}', '\u{1D99}', '\u{1D9A}', '\u{1E01}', '\u{1E03}', '\u{1E05}', '\u{1E07}', '\u{1E09}', '\u{1E0B}', '\u{1E0D}', '\u{1E0F}', '\u{1E11}', '\u{1E13}', '\u{1E15}', '\u{1E17}', '\u{1E19}', '\u{1E1B}', '\u{1E1D}', '\u{1E1F}', '\u{1E21}', '\u{1E23}', '\u{1E25}', '\u{1E27}', '\u{1E29}', '\u{1E2B}', '\u{1E2D}', '\u{1E2F}', '\u{1E31}', '\u{1E33}', '\u{1E35}', '\u{1E37}', '\u{1E39}', '\u{1E3B}', '\u{1E3D}', '\u{1E3F}', '\u{1E41}', '\u{1E43}', '\u{1E45}', '\u{1E47}', '\u{1E49}', '\u{1E4B}', '\u{1E4D}', '\u{1E4F}', '\u{1E51}', '\u{1E53}', '\u{1E55}', '\u{1E57}', '\u{1E59}', '\u{1E5B}', '\u{1E5D}', '\u{1E5F}', '\u{1E61}', '\u{1E63}', '\u{1E65}', '\u{1E67}', '\u{1E69}', '\u{1E6B}', '\u{1E6D}', '\u{1E6F}', '\u{1E71}', '\u{1E73}', '\u{1E75}', '\u{1E77}', '\u{1E79}', '\u{1E7B}', '\u{1E7D}', '\u{1E7F}', '\u{1E81}', '\u{1E83}', '\u{1E85}', '\u{1E87}', '\u{1E89}', '\u{1E8B}', '\u{1E8D}', '\u{1E8F}', '\u{1E91}', '\u{1E93}', '\u{1E95}', '\u{1E96}', '\u{1E97}', '\u{1E98}', '\u{1E99}', '\u{1E9A}', '\u{1E9B}', '\u{1E9C}', '\u{1E9D}', '\u{1E9F}', '\u{1EA1}', '\u{1EA3}', '\u{1EA5}', '\u{1EA7}', '\u{1EA9}', '\u{1EAB}', '\u{1EAD}', '\u{1EAF}', '\u{1EB1}', '\u{1EB3}', '\u{1EB5}', '\u{1EB7}', '\u{1EB9}', '\u{1EBB}', '\u{1EBD}', '\u{1EBF}', '\u{1EC1}', '\u{1EC3}', '\u{1EC5}', '\u{1EC7}', '\u{1EC9}', '\u{1ECB}', '\u{1ECD}', '\u{1ECF}', '\u{1ED1}', '\u{1ED3}', '\u{1ED5}', '\u{1ED7}', '\u{1ED9}', '\u{1EDB}', '\u{1EDD}', '\u{1EDF}', '\u{1EE1}', '\u{1EE3}', '\u{1EE5}', '\u{1EE7}', '\u{1EE9}', '\u{1EEB}', '\u{1EED}', '\u{1EEF}', '\u{1EF1}', '\u{1EF3}', '\u{1EF5}', '\u{1EF7}', '\u{1EF9}', '\u{1EFB}', '\u{1EFD}', '\u{1EFF}', '\u{1F00}', '\u{1F01}', '\u{1F02}', '\u{1F03}', '\u{1F04}', '\u{1F05}', '\u{1F06}', '\u{1F07}', '\u{1F10}', '\u{1F11}', '\u{1F12}', '\u{1F13}', '\u{1F14}', '\u{1F15}', '\u{1F20}', '\u{1F21}', '\u{1F22}', '\u{1F23}', '\u{1F24}', '\u{1F25}', '\u{1F26}', '\u{1F27}', '\u{1F30}', '\u{1F31}', '\u{1F32}', '\u{1F33}', '\u{1F34}', '\u{1F35}', '\u{1F36}', '\u{1F37}', '\u{1F40}', '\u{1F41}', '\u{1F42}', '\u{1F43}', '\u{1F44}', '\u{1F45}', '\u{1F50}', '\u{1F51}', '\u{1F52}', '\u{1F53}', '\u{1F54}', '\u{1F55}', '\u{1F56}', '\u{1F57}', '\u{1F60}', '\u{1F61}', '\u{1F62}', '\u{1F63}', '\u{1F64}', '\u{1F65}', '\u{1F66}', '\u{1F67}', '\u{1F70}', '\u{1F71}', '\u{1F72}', '\u{1F73}', '\u{1F74}', '\u{1F75}', '\u{1F76}', '\u{1F77}', '\u{1F78}', '\u{1F79}', '\u{1F7A}', '\u{1F7B}', '\u{1F7C}', '\u{1F7D}', '\u{1F80}', '\u{1F81}', '\u{1F82}', '\u{1F83}', '\u{1F84}', '\u{1F85}', '\u{1F86}', '\u{1F87}', '\u{1F90}', '\u{1F91}', '\u{1F92}', '\u{1F93}', '\u{1F94}', '\u{1F95}', '\u{1F96}', '\u{1F97}', '\u{1FA0}', '\u{1FA1}', '\u{1FA2}', '\u{1FA3}', '\u{1FA4}', '\u{1FA5}', '\u{1FA6}', '\u{1FA7}', '\u{1FB0}', '\u{1FB1}', '\u{1FB2}', '\u{1FB3}', '\u{1FB4}', '\u{1FB6}', '\u{1FB7}', '\u{1FBE}', '\u{1FC2}', '\u{1FC3}', '\u{1FC4}', '\u{1FC6}', '\u{1FC7}', '\u{1FD0}', '\u{1FD1}', '\u{1FD2}', '\u{1FD3}', '\u{1FD6}', '\u{1FD7}', '\u{1FE0}', '\u{1FE1}', '\u{1FE2}', '\u{1FE3}', '\u{1FE4}', '\u{1FE5}', '\u{1FE6}', '\u{1FE7}', '\u{1FF2}', '\u{1FF3}', '\u{1FF4}', '\u{1FF6}', '\u{1FF7}', '\u{2071}', '\u{207F}', '\u{210A}', '\u{210E}', '\u{210F}', '\u{2113}', '\u{212F}', '\u{2134}', '\u{2139}', '\u{213C}', '\u{213D}', '\u{2146}', '\u{2147}', '\u{2148}', '\u{2149}', '\u{214E}', '\u{2184}', '\u{2C30}', '\u{2C31}', '\u{2C32}', '\u{2C33}', '\u{2C34}', '\u{2C35}', '\u{2C36}', '\u{2C37}', '\u{2C38}', '\u{2C39}', '\u{2C3A}', '\u{2C3B}', '\u{2C3C}', '\u{2C3D}', '\u{2C3E}', '\u{2C3F}', '\u{2C40}', '\u{2C41}', '\u{2C42}', '\u{2C43}', '\u{2C44}', '\u{2C45}', '\u{2C46}', '\u{2C47}', '\u{2C48}', '\u{2C49}', '\u{2C4A}', '\u{2C4B}', '\u{2C4C}', '\u{2C4D}', '\u{2C4E}', '\u{2C4F}', '\u{2C50}', '\u{2C51}', '\u{2C52}', '\u{2C53}', '\u{2C54}', '\u{2C55}', '\u{2C56}', '\u{2C57}', '\u{2C58}', '\u{2C59}', '\u{2C5A}', '\u{2C5B}', '\u{2C5C}', '\u{2C5D}', '\u{2C5E}', '\u{2C61}', '\u{2C65}', '\u{2C66}', '\u{2C68}', '\u{2C6A}', '\u{2C6C}', '\u{2C71}', '\u{2C73}', '\u{2C74}', '\u{2C76}', '\u{2C77}', '\u{2C78}', '\u{2C79}', '\u{2C7A}', '\u{2C7B}', '\u{2C7C}', '\u{2C81}', '\u{2C83}', '\u{2C85}', '\u{2C87}', '\u{2C89}', '\u{2C8B}', '\u{2C8D}', '\u{2C8F}', '\u{2C91}', '\u{2C93}', '\u{2C95}', '\u{2C97}', '\u{2C99}', '\u{2C9B}', '\u{2C9D}', '\u{2C9F}', '\u{2CA1}', '\u{2CA3}', '\u{2CA5}', '\u{2CA7}', '\u{2CA9}', '\u{2CAB}', '\u{2CAD}', '\u{2CAF}', '\u{2CB1}', '\u{2CB3}', '\u{2CB5}', '\u{2CB7}', '\u{2CB9}', '\u{2CBB}', '\u{2CBD}', '\u{2CBF}', '\u{2CC1}', '\u{2CC3}', '\u{2CC5}', '\u{2CC7}', '\u{2CC9}', '\u{2CCB}', '\u{2CCD}', '\u{2CCF}', '\u{2CD1}', '\u{2CD3}', '\u{2CD5}', '\u{2CD7}', '\u{2CD9}', '\u{2CDB}', '\u{2CDD}', '\u{2CDF}', '\u{2CE1}', '\u{2CE3}', '\u{2CE4}', '\u{2D00}', '\u{2D01}', '\u{2D02}', '\u{2D03}', '\u{2D04}', '\u{2D05}', '\u{2D06}', '\u{2D07}', '\u{2D08}', '\u{2D09}', '\u{2D0A}', '\u{2D0B}', '\u{2D0C}', '\u{2D0D}', '\u{2D0E}', '\u{2D0F}', '\u{2D10}', '\u{2D11}', '\u{2D12}', '\u{2D13}', '\u{2D14}', '\u{2D15}', '\u{2D16}', '\u{2D17}', '\u{2D18}', '\u{2D19}', '\u{2D1A}', '\u{2D1B}', '\u{2D1C}', '\u{2D1D}', '\u{2D1E}', '\u{2D1F}', '\u{2D20}', '\u{2D21}', '\u{2D22}', '\u{2D23}', '\u{2D24}', '\u{2D25}', '\u{A641}', '\u{A643}', '\u{A645}', '\u{A647}', '\u{A649}', '\u{A64B}', '\u{A64D}', '\u{A64F}', '\u{A651}', '\u{A653}', '\u{A655}', '\u{A657}', '\u{A659}', '\u{A65B}', '\u{A65D}', '\u{A65F}', '\u{A663}', '\u{A665}', '\u{A667}', '\u{A669}', '\u{A66B}', '\u{A66D}', '\u{A681}', '\u{A683}', '\u{A685}', '\u{A687}', '\u{A689}', '\u{A68B}', '\u{A68D}', '\u{A68F}', '\u{A691}', '\u{A693}', '\u{A695}', '\u{A697}', '\u{A723}', '\u{A725}', '\u{A727}', '\u{A729}', '\u{A72B}', '\u{A72D}', '\u{A72F}', '\u{A730}', '\u{A731}', '\u{A733}', '\u{A735}', '\u{A737}', '\u{A739}', '\u{A73B}', '\u{A73D}', '\u{A73F}', '\u{A741}', '\u{A743}', '\u{A745}', '\u{A747}', '\u{A749}', '\u{A74B}', '\u{A74D}', '\u{A74F}', '\u{A751}', '\u{A753}', '\u{A755}', '\u{A757}', '\u{A759}', '\u{A75B}', '\u{A75D}', '\u{A75F}', '\u{A761}', '\u{A763}', '\u{A765}', '\u{A767}', '\u{A769}', '\u{A76B}', '\u{A76D}', '\u{A76F}', '\u{A771}', '\u{A772}', '\u{A773}', '\u{A774}', '\u{A775}', '\u{A776}', '\u{A777}', '\u{A778}', '\u{A77A}', '\u{A77C}', '\u{A77F}', '\u{A781}', '\u{A783}', '\u{A785}', '\u{A787}', '\u{A78C}', '\u{FB00}', '\u{FB01}', '\u{FB02}', '\u{FB03}', '\u{FB04}', '\u{FB05}', '\u{FB06}', '\u{FB13}', '\u{FB14}', '\u{FB15}', '\u{FB16}', '\u{FB17}', '\u{FF41}', '\u{FF42}', '\u{FF43}', '\u{FF44}', '\u{FF45}', '\u{FF46}', '\u{FF47}', '\u{FF48}', '\u{FF49}', '\u{FF4A}', '\u{FF4B}', '\u{FF4C}', '\u{FF4D}', '\u{FF4E}', '\u{FF4F}', '\u{FF50}', '\u{FF51}', '\u{FF52}', '\u{FF53}', '\u{FF54}', '\u{FF55}', '\u{FF56}', '\u{FF57}', '\u{FF58}', '\u{FF59}', '\u{FF5A}') - - } - - fn is_unicode_titlecase_letter(self) -> bool { - match_char_class!(self, - '\u{01C5}', '\u{01C8}', '\u{01CB}', '\u{01F2}', '\u{1F88}', '\u{1F89}', '\u{1F8A}', '\u{1F8B}', '\u{1F8C}', '\u{1F8D}', '\u{1F8E}', '\u{1F8F}', '\u{1F98}', '\u{1F99}', '\u{1F9A}', '\u{1F9B}', '\u{1F9C}', '\u{1F9D}', '\u{1F9E}', '\u{1F9F}', '\u{1FA8}', '\u{1FA9}', '\u{1FAA}', '\u{1FAB}', '\u{1FAC}', '\u{1FAD}', '\u{1FAE}', '\u{1FAF}', '\u{1FBC}', '\u{1FCC}') - } - - fn is_unicode_modifier_letter(self) -> bool { - match_char_class!(self, - '\u{02B0}', '\u{02B1}', '\u{02B2}', '\u{02B3}', '\u{02B4}', '\u{02B5}', '\u{02B6}', '\u{02B7}', '\u{02B8}', '\u{02B9}', '\u{02BA}', '\u{02BB}', '\u{02BC}', '\u{02BD}', '\u{02BE}', '\u{02BF}', '\u{02C0}', '\u{02C1}', '\u{02C6}', '\u{02C7}', '\u{02C8}', '\u{02C9}', '\u{02CA}', '\u{02CB}', '\u{02CC}', '\u{02CD}', '\u{02CE}', '\u{02CF}', '\u{02D0}', '\u{02D1}', '\u{02E0}', '\u{02E1}', '\u{02E2}', '\u{02E3}', '\u{02E4}', '\u{02EC}', '\u{02EE}', '\u{0374}', '\u{037A}', '\u{0559}', '\u{0640}', '\u{06E5}', '\u{06E6}', '\u{07F4}', '\u{07F5}', '\u{07FA}', '\u{0971}', '\u{0E46}', '\u{0EC6}', '\u{10FC}', '\u{17D7}', '\u{1843}', '\u{1C78}', '\u{1C79}', '\u{1C7A}', '\u{1C7B}', '\u{1C7C}', '\u{1C7D}', '\u{1D2C}', '\u{1D2D}', '\u{1D2E}', '\u{1D2F}', '\u{1D30}', '\u{1D31}', '\u{1D32}', '\u{1D33}', '\u{1D34}', '\u{1D35}', '\u{1D36}', '\u{1D37}', '\u{1D38}', '\u{1D39}', '\u{1D3A}', '\u{1D3B}', '\u{1D3C}', '\u{1D3D}', '\u{1D3E}', '\u{1D3F}', '\u{1D40}', '\u{1D41}', '\u{1D42}', '\u{1D43}', '\u{1D44}', '\u{1D45}', '\u{1D46}', '\u{1D47}', '\u{1D48}', '\u{1D49}', '\u{1D4A}', '\u{1D4B}', '\u{1D4C}', '\u{1D4D}', '\u{1D4E}', '\u{1D4F}', '\u{1D50}', '\u{1D51}', '\u{1D52}', '\u{1D53}', '\u{1D54}', '\u{1D55}', '\u{1D56}', '\u{1D57}', '\u{1D58}', '\u{1D59}', '\u{1D5A}', '\u{1D5B}', '\u{1D5C}', '\u{1D5D}', '\u{1D5E}', '\u{1D5F}', '\u{1D60}', '\u{1D61}', '\u{1D78}', '\u{1D9B}', '\u{1D9C}', '\u{1D9D}', '\u{1D9E}', '\u{1D9F}', '\u{1DA0}', '\u{1DA1}', '\u{1DA2}', '\u{1DA3}', '\u{1DA4}', '\u{1DA5}', '\u{1DA6}', '\u{1DA7}', '\u{1DA8}', '\u{1DA9}', '\u{1DAA}', '\u{1DAB}', '\u{1DAC}', '\u{1DAD}', '\u{1DAE}', '\u{1DAF}', '\u{1DB0}', '\u{1DB1}', '\u{1DB2}', '\u{1DB3}', '\u{1DB4}', '\u{1DB5}', '\u{1DB6}', '\u{1DB7}', '\u{1DB8}', '\u{1DB9}', '\u{1DBA}', '\u{1DBB}', '\u{1DBC}', '\u{1DBD}', '\u{1DBE}', '\u{1DBF}', '\u{2090}', '\u{2091}', '\u{2092}', '\u{2093}', '\u{2094}', '\u{2C7D}', '\u{2D6F}', '\u{2E2F}', '\u{3005}', '\u{3031}', '\u{3032}', '\u{3033}', '\u{3034}', '\u{3035}', '\u{303B}', '\u{309D}', '\u{309E}', '\u{30FC}', '\u{30FD}', '\u{30FE}', '\u{A015}', '\u{A60C}', '\u{A67F}', '\u{A717}', '\u{A718}', '\u{A719}', '\u{A71A}', '\u{A71B}', '\u{A71C}', '\u{A71D}', '\u{A71E}', '\u{A71F}', '\u{A770}', '\u{A788}', '\u{FF70}', '\u{FF9E}', '\u{FF9F}') - } - - fn is_unicode_other_letter(self) -> bool { - match_char_class!(self, - '\u{01BB}', '\u{01C0}', '\u{01C1}', '\u{01C2}', '\u{01C3}', '\u{0294}', '\u{05D0}', '\u{05D1}', '\u{05D2}', '\u{05D3}', '\u{05D4}', '\u{05D5}', '\u{05D6}', '\u{05D7}', '\u{05D8}', '\u{05D9}', '\u{05DA}', '\u{05DB}', '\u{05DC}', '\u{05DD}', '\u{05DE}', '\u{05DF}', '\u{05E0}', '\u{05E1}', '\u{05E2}', '\u{05E3}', '\u{05E4}', '\u{05E5}', '\u{05E6}', '\u{05E7}', '\u{05E8}', '\u{05E9}', '\u{05EA}', '\u{05F0}', '\u{05F1}', '\u{05F2}', '\u{0621}', '\u{0622}', '\u{0623}', '\u{0624}', '\u{0625}', '\u{0626}', '\u{0627}', '\u{0628}', '\u{0629}', '\u{062A}', '\u{062B}', '\u{062C}', '\u{062D}', '\u{062E}', '\u{062F}', '\u{0630}', '\u{0631}', '\u{0632}', '\u{0633}', '\u{0634}', '\u{0635}', '\u{0636}', '\u{0637}', '\u{0638}', '\u{0639}', '\u{063A}', '\u{063B}', '\u{063C}', '\u{063D}', '\u{063E}', '\u{063F}', '\u{0641}', '\u{0642}', '\u{0643}', '\u{0644}', '\u{0645}', '\u{0646}', '\u{0647}', '\u{0648}', '\u{0649}', '\u{064A}', '\u{066E}', '\u{066F}', '\u{0671}', '\u{0672}', '\u{0673}', '\u{0674}', '\u{0675}', '\u{0676}', '\u{0677}', '\u{0678}', '\u{0679}', '\u{067A}', '\u{067B}', '\u{067C}', '\u{067D}', '\u{067E}', '\u{067F}', '\u{0680}', '\u{0681}', '\u{0682}', '\u{0683}', '\u{0684}', '\u{0685}', '\u{0686}', '\u{0687}', '\u{0688}', '\u{0689}', '\u{068A}', '\u{068B}', '\u{068C}', '\u{068D}', '\u{068E}', '\u{068F}', '\u{0690}', '\u{0691}', '\u{0692}', '\u{0693}', '\u{0694}', '\u{0695}', '\u{0696}', '\u{0697}', '\u{0698}', '\u{0699}', '\u{069A}', '\u{069B}', '\u{069C}', '\u{069D}', '\u{069E}', '\u{069F}', '\u{06A0}', '\u{06A1}', '\u{06A2}', '\u{06A3}', '\u{06A4}', '\u{06A5}', '\u{06A6}', '\u{06A7}', '\u{06A8}', '\u{06A9}', '\u{06AA}', '\u{06AB}', '\u{06AC}', '\u{06AD}', '\u{06AE}', '\u{06AF}', '\u{06B0}', '\u{06B1}', '\u{06B2}', '\u{06B3}', '\u{06B4}', '\u{06B5}', '\u{06B6}', '\u{06B7}', '\u{06B8}', '\u{06B9}', '\u{06BA}', '\u{06BB}', '\u{06BC}', '\u{06BD}', '\u{06BE}', '\u{06BF}', '\u{06C0}', '\u{06C1}', '\u{06C2}', '\u{06C3}', '\u{06C4}', '\u{06C5}', '\u{06C6}', '\u{06C7}', '\u{06C8}', '\u{06C9}', '\u{06CA}', '\u{06CB}', '\u{06CC}', '\u{06CD}', '\u{06CE}', '\u{06CF}', '\u{06D0}', '\u{06D1}', '\u{06D2}', '\u{06D3}', '\u{06D5}', '\u{06EE}', '\u{06EF}', '\u{06FA}', '\u{06FB}', '\u{06FC}', '\u{06FF}', '\u{0710}', '\u{0712}', '\u{0713}', '\u{0714}', '\u{0715}', '\u{0716}', '\u{0717}', '\u{0718}', '\u{0719}', '\u{071A}', '\u{071B}', '\u{071C}', '\u{071D}', '\u{071E}', '\u{071F}', '\u{0720}', '\u{0721}', '\u{0722}', '\u{0723}', '\u{0724}', '\u{0725}', '\u{0726}', '\u{0727}', '\u{0728}', '\u{0729}', '\u{072A}', '\u{072B}', '\u{072C}', '\u{072D}', '\u{072E}', '\u{072F}', '\u{074D}', '\u{074E}', '\u{074F}', '\u{0750}', '\u{0751}', '\u{0752}', '\u{0753}', '\u{0754}', '\u{0755}', '\u{0756}', '\u{0757}', '\u{0758}', '\u{0759}', '\u{075A}', '\u{075B}', '\u{075C}', '\u{075D}', '\u{075E}', '\u{075F}', '\u{0760}', '\u{0761}', '\u{0762}', '\u{0763}', '\u{0764}', '\u{0765}', '\u{0766}', '\u{0767}', '\u{0768}', '\u{0769}', '\u{076A}', '\u{076B}', '\u{076C}', '\u{076D}', '\u{076E}', '\u{076F}', '\u{0770}', '\u{0771}', '\u{0772}', '\u{0773}', '\u{0774}', '\u{0775}', '\u{0776}', '\u{0777}', '\u{0778}', '\u{0779}', '\u{077A}', '\u{077B}', '\u{077C}', '\u{077D}', '\u{077E}', '\u{077F}', '\u{0780}', '\u{0781}', '\u{0782}', '\u{0783}', '\u{0784}', '\u{0785}', '\u{0786}', '\u{0787}', '\u{0788}', '\u{0789}', '\u{078A}', '\u{078B}', '\u{078C}', '\u{078D}', '\u{078E}', '\u{078F}', '\u{0790}', '\u{0791}', '\u{0792}', '\u{0793}', '\u{0794}', '\u{0795}', '\u{0796}', '\u{0797}', '\u{0798}', '\u{0799}', '\u{079A}', '\u{079B}', '\u{079C}', '\u{079D}', '\u{079E}', '\u{079F}', '\u{07A0}', '\u{07A1}', '\u{07A2}', '\u{07A3}', '\u{07A4}', '\u{07A5}', '\u{07B1}', '\u{07CA}', '\u{07CB}', '\u{07CC}', '\u{07CD}', '\u{07CE}', '\u{07CF}', '\u{07D0}', '\u{07D1}', '\u{07D2}', '\u{07D3}', '\u{07D4}', '\u{07D5}', '\u{07D6}', '\u{07D7}', '\u{07D8}', '\u{07D9}', '\u{07DA}', '\u{07DB}', '\u{07DC}', '\u{07DD}', '\u{07DE}', '\u{07DF}', '\u{07E0}', '\u{07E1}', '\u{07E2}', '\u{07E3}', '\u{07E4}', '\u{07E5}', '\u{07E6}', '\u{07E7}', '\u{07E8}', '\u{07E9}', '\u{07EA}', '\u{0904}', '\u{0905}', '\u{0906}', '\u{0907}', '\u{0908}', '\u{0909}', '\u{090A}', '\u{090B}', '\u{090C}', '\u{090D}', '\u{090E}', '\u{090F}', '\u{0910}', '\u{0911}', '\u{0912}', '\u{0913}', '\u{0914}', '\u{0915}', '\u{0916}', '\u{0917}', '\u{0918}', '\u{0919}', '\u{091A}', '\u{091B}', '\u{091C}', '\u{091D}', '\u{091E}', '\u{091F}', '\u{0920}', '\u{0921}', '\u{0922}', '\u{0923}', '\u{0924}', '\u{0925}', '\u{0926}', '\u{0927}', '\u{0928}', '\u{0929}', '\u{092A}', '\u{092B}', '\u{092C}', '\u{092D}', '\u{092E}', '\u{092F}', '\u{0930}', '\u{0931}', '\u{0932}', '\u{0933}', '\u{0934}', '\u{0935}', '\u{0936}', '\u{0937}', '\u{0938}', '\u{0939}', '\u{093D}', '\u{0950}', '\u{0958}', '\u{0959}', '\u{095A}', '\u{095B}', '\u{095C}', '\u{095D}', '\u{095E}', '\u{095F}', '\u{0960}', '\u{0961}', '\u{0972}', '\u{097B}', '\u{097C}', '\u{097D}', '\u{097E}', '\u{097F}', '\u{0985}', '\u{0986}', '\u{0987}', '\u{0988}', '\u{0989}', '\u{098A}', '\u{098B}', '\u{098C}', '\u{098F}', '\u{0990}', '\u{0993}', '\u{0994}', '\u{0995}', '\u{0996}', '\u{0997}', '\u{0998}', '\u{0999}', '\u{099A}', '\u{099B}', '\u{099C}', '\u{099D}', '\u{099E}', '\u{099F}', '\u{09A0}', '\u{09A1}', '\u{09A2}', '\u{09A3}', '\u{09A4}', '\u{09A5}', '\u{09A6}', '\u{09A7}', '\u{09A8}', '\u{09AA}', '\u{09AB}', '\u{09AC}', '\u{09AD}', '\u{09AE}', '\u{09AF}', '\u{09B0}', '\u{09B2}', '\u{09B6}', '\u{09B7}', '\u{09B8}', '\u{09B9}', '\u{09BD}', '\u{09CE}', '\u{09DC}', '\u{09DD}', '\u{09DF}', '\u{09E0}', '\u{09E1}', '\u{09F0}', '\u{09F1}', '\u{0A05}', '\u{0A06}', '\u{0A07}', '\u{0A08}', '\u{0A09}', '\u{0A0A}', '\u{0A0F}', '\u{0A10}', '\u{0A13}', '\u{0A14}', '\u{0A15}', '\u{0A16}', '\u{0A17}', '\u{0A18}', '\u{0A19}', '\u{0A1A}', '\u{0A1B}', '\u{0A1C}', '\u{0A1D}', '\u{0A1E}', '\u{0A1F}', '\u{0A20}', '\u{0A21}', '\u{0A22}', '\u{0A23}', '\u{0A24}', '\u{0A25}', '\u{0A26}', '\u{0A27}', '\u{0A28}', '\u{0A2A}', '\u{0A2B}', '\u{0A2C}', '\u{0A2D}', '\u{0A2E}', '\u{0A2F}', '\u{0A30}', '\u{0A32}', '\u{0A33}', '\u{0A35}', '\u{0A36}', '\u{0A38}', '\u{0A39}', '\u{0A59}', '\u{0A5A}', '\u{0A5B}', '\u{0A5C}', '\u{0A5E}', '\u{0A72}', '\u{0A73}', '\u{0A74}', '\u{0A85}', '\u{0A86}', '\u{0A87}', '\u{0A88}', '\u{0A89}', '\u{0A8A}', '\u{0A8B}', '\u{0A8C}', '\u{0A8D}', '\u{0A8F}', '\u{0A90}', '\u{0A91}', '\u{0A93}', '\u{0A94}', '\u{0A95}', '\u{0A96}', '\u{0A97}', '\u{0A98}', '\u{0A99}', '\u{0A9A}', '\u{0A9B}', '\u{0A9C}', '\u{0A9D}', '\u{0A9E}', '\u{0A9F}', '\u{0AA0}', '\u{0AA1}', '\u{0AA2}', '\u{0AA3}', '\u{0AA4}', '\u{0AA5}', '\u{0AA6}', '\u{0AA7}', '\u{0AA8}', '\u{0AAA}', '\u{0AAB}', '\u{0AAC}', '\u{0AAD}', '\u{0AAE}', '\u{0AAF}', '\u{0AB0}', '\u{0AB2}', '\u{0AB3}', '\u{0AB5}', '\u{0AB6}', '\u{0AB7}', '\u{0AB8}', '\u{0AB9}', '\u{0ABD}', '\u{0AD0}', '\u{0AE0}', '\u{0AE1}', '\u{0B05}', '\u{0B06}', '\u{0B07}', '\u{0B08}', '\u{0B09}', '\u{0B0A}', '\u{0B0B}', '\u{0B0C}', '\u{0B0F}', '\u{0B10}', '\u{0B13}', '\u{0B14}', '\u{0B15}', '\u{0B16}', '\u{0B17}', '\u{0B18}', '\u{0B19}', '\u{0B1A}', '\u{0B1B}', '\u{0B1C}', '\u{0B1D}', '\u{0B1E}', '\u{0B1F}', '\u{0B20}', '\u{0B21}', '\u{0B22}', '\u{0B23}', '\u{0B24}', '\u{0B25}', '\u{0B26}', '\u{0B27}', '\u{0B28}', '\u{0B2A}', '\u{0B2B}', '\u{0B2C}', '\u{0B2D}', '\u{0B2E}', '\u{0B2F}', '\u{0B30}', '\u{0B32}', '\u{0B33}', '\u{0B35}', '\u{0B36}', '\u{0B37}', '\u{0B38}', '\u{0B39}', '\u{0B3D}', '\u{0B5C}', '\u{0B5D}', '\u{0B5F}', '\u{0B60}', '\u{0B61}', '\u{0B71}', '\u{0B83}', '\u{0B85}', '\u{0B86}', '\u{0B87}', '\u{0B88}', '\u{0B89}', '\u{0B8A}', '\u{0B8E}', '\u{0B8F}', '\u{0B90}', '\u{0B92}', '\u{0B93}', '\u{0B94}', '\u{0B95}', '\u{0B99}', '\u{0B9A}', '\u{0B9C}', '\u{0B9E}', '\u{0B9F}', '\u{0BA3}', '\u{0BA4}', '\u{0BA8}', '\u{0BA9}', '\u{0BAA}', '\u{0BAE}', '\u{0BAF}', '\u{0BB0}', '\u{0BB1}', '\u{0BB2}', '\u{0BB3}', '\u{0BB4}', '\u{0BB5}', '\u{0BB6}', '\u{0BB7}', '\u{0BB8}', '\u{0BB9}', '\u{0BD0}', '\u{0C05}', '\u{0C06}', '\u{0C07}', '\u{0C08}', '\u{0C09}', '\u{0C0A}', '\u{0C0B}', '\u{0C0C}', '\u{0C0E}', '\u{0C0F}', '\u{0C10}', '\u{0C12}', '\u{0C13}', '\u{0C14}', '\u{0C15}', '\u{0C16}', '\u{0C17}', '\u{0C18}', '\u{0C19}', '\u{0C1A}', '\u{0C1B}', '\u{0C1C}', '\u{0C1D}', '\u{0C1E}', '\u{0C1F}', '\u{0C20}', '\u{0C21}', '\u{0C22}', '\u{0C23}', '\u{0C24}', '\u{0C25}', '\u{0C26}', '\u{0C27}', '\u{0C28}', '\u{0C2A}', '\u{0C2B}', '\u{0C2C}', '\u{0C2D}', '\u{0C2E}', '\u{0C2F}', '\u{0C30}', '\u{0C31}', '\u{0C32}', '\u{0C33}', '\u{0C35}', '\u{0C36}', '\u{0C37}', '\u{0C38}', '\u{0C39}', '\u{0C3D}', '\u{0C58}', '\u{0C59}', '\u{0C60}', '\u{0C61}', '\u{0C85}', '\u{0C86}', '\u{0C87}', '\u{0C88}', '\u{0C89}', '\u{0C8A}', '\u{0C8B}', '\u{0C8C}', '\u{0C8E}', '\u{0C8F}', '\u{0C90}', '\u{0C92}', '\u{0C93}', '\u{0C94}', '\u{0C95}', '\u{0C96}', '\u{0C97}', '\u{0C98}', '\u{0C99}', '\u{0C9A}', '\u{0C9B}', '\u{0C9C}', '\u{0C9D}', '\u{0C9E}', '\u{0C9F}', '\u{0CA0}', '\u{0CA1}', '\u{0CA2}', '\u{0CA3}', '\u{0CA4}', '\u{0CA5}', '\u{0CA6}', '\u{0CA7}', '\u{0CA8}', '\u{0CAA}', '\u{0CAB}', '\u{0CAC}', '\u{0CAD}', '\u{0CAE}', '\u{0CAF}', '\u{0CB0}', '\u{0CB1}', '\u{0CB2}', '\u{0CB3}', '\u{0CB5}', '\u{0CB6}', '\u{0CB7}', '\u{0CB8}', '\u{0CB9}', '\u{0CBD}', '\u{0CDE}', '\u{0CE0}', '\u{0CE1}', '\u{0D05}', '\u{0D06}', '\u{0D07}', '\u{0D08}', '\u{0D09}', '\u{0D0A}', '\u{0D0B}', '\u{0D0C}', '\u{0D0E}', '\u{0D0F}', '\u{0D10}', '\u{0D12}', '\u{0D13}', '\u{0D14}', '\u{0D15}', '\u{0D16}', '\u{0D17}', '\u{0D18}', '\u{0D19}', '\u{0D1A}', '\u{0D1B}', '\u{0D1C}', '\u{0D1D}', '\u{0D1E}', '\u{0D1F}', '\u{0D20}', '\u{0D21}', '\u{0D22}', '\u{0D23}', '\u{0D24}', '\u{0D25}', '\u{0D26}', '\u{0D27}', '\u{0D28}', '\u{0D2A}', '\u{0D2B}', '\u{0D2C}', '\u{0D2D}', '\u{0D2E}', '\u{0D2F}', '\u{0D30}', '\u{0D31}', '\u{0D32}', '\u{0D33}', '\u{0D34}', '\u{0D35}', '\u{0D36}', '\u{0D37}', '\u{0D38}', '\u{0D39}', '\u{0D3D}', '\u{0D60}', '\u{0D61}', '\u{0D7A}', '\u{0D7B}', '\u{0D7C}', '\u{0D7D}', '\u{0D7E}', '\u{0D7F}', '\u{0D85}', '\u{0D86}', '\u{0D87}', '\u{0D88}', '\u{0D89}', '\u{0D8A}', '\u{0D8B}', '\u{0D8C}', '\u{0D8D}', '\u{0D8E}', '\u{0D8F}', '\u{0D90}', '\u{0D91}', '\u{0D92}', '\u{0D93}', '\u{0D94}', '\u{0D95}', '\u{0D96}', '\u{0D9A}', '\u{0D9B}', '\u{0D9C}', '\u{0D9D}', '\u{0D9E}', '\u{0D9F}', '\u{0DA0}', '\u{0DA1}', '\u{0DA2}', '\u{0DA3}', '\u{0DA4}', '\u{0DA5}', '\u{0DA6}', '\u{0DA7}', '\u{0DA8}', '\u{0DA9}', '\u{0DAA}', '\u{0DAB}', '\u{0DAC}', '\u{0DAD}', '\u{0DAE}', '\u{0DAF}', '\u{0DB0}', '\u{0DB1}', '\u{0DB3}', '\u{0DB4}', '\u{0DB5}', '\u{0DB6}', '\u{0DB7}', '\u{0DB8}', '\u{0DB9}', '\u{0DBA}', '\u{0DBB}', '\u{0DBD}', '\u{0DC0}', '\u{0DC1}', '\u{0DC2}', '\u{0DC3}', '\u{0DC4}', '\u{0DC5}', '\u{0DC6}', '\u{0E01}', '\u{0E02}', '\u{0E03}', '\u{0E04}', '\u{0E05}', '\u{0E06}', '\u{0E07}', '\u{0E08}', '\u{0E09}', '\u{0E0A}', '\u{0E0B}', '\u{0E0C}', '\u{0E0D}', '\u{0E0E}', '\u{0E0F}', '\u{0E10}', '\u{0E11}', '\u{0E12}', '\u{0E13}', '\u{0E14}', '\u{0E15}', '\u{0E16}', '\u{0E17}', '\u{0E18}', '\u{0E19}', '\u{0E1A}', '\u{0E1B}', '\u{0E1C}', '\u{0E1D}', '\u{0E1E}', '\u{0E1F}', '\u{0E20}', '\u{0E21}', '\u{0E22}', '\u{0E23}', '\u{0E24}', '\u{0E25}', '\u{0E26}', '\u{0E27}', '\u{0E28}', '\u{0E29}', '\u{0E2A}', '\u{0E2B}', '\u{0E2C}', '\u{0E2D}', '\u{0E2E}', '\u{0E2F}', '\u{0E30}', '\u{0E32}', '\u{0E33}', '\u{0E40}', '\u{0E41}', '\u{0E42}', '\u{0E43}', '\u{0E44}', '\u{0E45}', '\u{0E81}', '\u{0E82}', '\u{0E84}', '\u{0E87}', '\u{0E88}', '\u{0E8A}', '\u{0E8D}', '\u{0E94}', '\u{0E95}', '\u{0E96}', '\u{0E97}', '\u{0E99}', '\u{0E9A}', '\u{0E9B}', '\u{0E9C}', '\u{0E9D}', '\u{0E9E}', '\u{0E9F}', '\u{0EA1}', '\u{0EA2}', '\u{0EA3}', '\u{0EA5}', '\u{0EA7}', '\u{0EAA}', '\u{0EAB}', '\u{0EAD}', '\u{0EAE}', '\u{0EAF}', '\u{0EB0}', '\u{0EB2}', '\u{0EB3}', '\u{0EBD}', '\u{0EC0}', '\u{0EC1}', '\u{0EC2}', '\u{0EC3}', '\u{0EC4}', '\u{0EDC}', '\u{0EDD}', '\u{0F00}', '\u{0F40}', '\u{0F41}', '\u{0F42}', '\u{0F43}', '\u{0F44}', '\u{0F45}', '\u{0F46}', '\u{0F47}', '\u{0F49}', '\u{0F4A}', '\u{0F4B}', '\u{0F4C}', '\u{0F4D}', '\u{0F4E}', '\u{0F4F}', '\u{0F50}', '\u{0F51}', '\u{0F52}', '\u{0F53}', '\u{0F54}', '\u{0F55}', '\u{0F56}', '\u{0F57}', '\u{0F58}', '\u{0F59}', '\u{0F5A}', '\u{0F5B}', '\u{0F5C}', '\u{0F5D}', '\u{0F5E}', '\u{0F5F}', '\u{0F60}', '\u{0F61}', '\u{0F62}', '\u{0F63}', '\u{0F64}', '\u{0F65}', '\u{0F66}', '\u{0F67}', '\u{0F68}', '\u{0F69}', '\u{0F6A}', '\u{0F6B}', '\u{0F6C}', '\u{0F88}', '\u{0F89}', '\u{0F8A}', '\u{0F8B}', '\u{1000}', '\u{1001}', '\u{1002}', '\u{1003}', '\u{1004}', '\u{1005}', '\u{1006}', '\u{1007}', '\u{1008}', '\u{1009}', '\u{100A}', '\u{100B}', '\u{100C}', '\u{100D}', '\u{100E}', '\u{100F}', '\u{1010}', '\u{1011}', '\u{1012}', '\u{1013}', '\u{1014}', '\u{1015}', '\u{1016}', '\u{1017}', '\u{1018}', '\u{1019}', '\u{101A}', '\u{101B}', '\u{101C}', '\u{101D}', '\u{101E}', '\u{101F}', '\u{1020}', '\u{1021}', '\u{1022}', '\u{1023}', '\u{1024}', '\u{1025}', '\u{1026}', '\u{1027}', '\u{1028}', '\u{1029}', '\u{102A}', '\u{103F}', '\u{1050}', '\u{1051}', '\u{1052}', '\u{1053}', '\u{1054}', '\u{1055}', '\u{105A}', '\u{105B}', '\u{105C}', '\u{105D}', '\u{1061}', '\u{1065}', '\u{1066}', '\u{106E}', '\u{106F}', '\u{1070}', '\u{1075}', '\u{1076}', '\u{1077}', '\u{1078}', '\u{1079}', '\u{107A}', '\u{107B}', '\u{107C}', '\u{107D}', '\u{107E}', '\u{107F}', '\u{1080}', '\u{1081}', '\u{108E}', '\u{10D0}', '\u{10D1}', '\u{10D2}', '\u{10D3}', '\u{10D4}', '\u{10D5}', '\u{10D6}', '\u{10D7}', '\u{10D8}', '\u{10D9}', '\u{10DA}', '\u{10DB}', '\u{10DC}', '\u{10DD}', '\u{10DE}', '\u{10DF}', '\u{10E0}', '\u{10E1}', '\u{10E2}', '\u{10E3}', '\u{10E4}', '\u{10E5}', '\u{10E6}', '\u{10E7}', '\u{10E8}', '\u{10E9}', '\u{10EA}', '\u{10EB}', '\u{10EC}', '\u{10ED}', '\u{10EE}', '\u{10EF}', '\u{10F0}', '\u{10F1}', '\u{10F2}', '\u{10F3}', '\u{10F4}', '\u{10F5}', '\u{10F6}', '\u{10F7}', '\u{10F8}', '\u{10F9}', '\u{10FA}', '\u{1100}', '\u{1101}', '\u{1102}', '\u{1103}', '\u{1104}', '\u{1105}', '\u{1106}', '\u{1107}', '\u{1108}', '\u{1109}', '\u{110A}', '\u{110B}', '\u{110C}', '\u{110D}', '\u{110E}', '\u{110F}', '\u{1110}', '\u{1111}', '\u{1112}', '\u{1113}', '\u{1114}', '\u{1115}', '\u{1116}', '\u{1117}', '\u{1118}', '\u{1119}', '\u{111A}', '\u{111B}', '\u{111C}', '\u{111D}', '\u{111E}', '\u{111F}', '\u{1120}', '\u{1121}', '\u{1122}', '\u{1123}', '\u{1124}', '\u{1125}', '\u{1126}', '\u{1127}', '\u{1128}', '\u{1129}', '\u{112A}', '\u{112B}', '\u{112C}', '\u{112D}', '\u{112E}', '\u{112F}', '\u{1130}', '\u{1131}', '\u{1132}', '\u{1133}', '\u{1134}', '\u{1135}', '\u{1136}', '\u{1137}', '\u{1138}', '\u{1139}', '\u{113A}', '\u{113B}', '\u{113C}', '\u{113D}', '\u{113E}', '\u{113F}', '\u{1140}', '\u{1141}', '\u{1142}', '\u{1143}', '\u{1144}', '\u{1145}', '\u{1146}', '\u{1147}', '\u{1148}', '\u{1149}', '\u{114A}', '\u{114B}', '\u{114C}', '\u{114D}', '\u{114E}', '\u{114F}', '\u{1150}', '\u{1151}', '\u{1152}', '\u{1153}', '\u{1154}', '\u{1155}', '\u{1156}', '\u{1157}', '\u{1158}', '\u{1159}', '\u{115F}', '\u{1160}', '\u{1161}', '\u{1162}', '\u{1163}', '\u{1164}', '\u{1165}', '\u{1166}', '\u{1167}', '\u{1168}', '\u{1169}', '\u{116A}', '\u{116B}', '\u{116C}', '\u{116D}', '\u{116E}', '\u{116F}', '\u{1170}', '\u{1171}', '\u{1172}', '\u{1173}', '\u{1174}', '\u{1175}', '\u{1176}', '\u{1177}', '\u{1178}', '\u{1179}', '\u{117A}', '\u{117B}', '\u{117C}', '\u{117D}', '\u{117E}', '\u{117F}', '\u{1180}', '\u{1181}', '\u{1182}', '\u{1183}', '\u{1184}', '\u{1185}', '\u{1186}', '\u{1187}', '\u{1188}', '\u{1189}', '\u{118A}', '\u{118B}', '\u{118C}', '\u{118D}', '\u{118E}', '\u{118F}', '\u{1190}', '\u{1191}', '\u{1192}', '\u{1193}', '\u{1194}', '\u{1195}', '\u{1196}', '\u{1197}', '\u{1198}', '\u{1199}', '\u{119A}', '\u{119B}', '\u{119C}', '\u{119D}', '\u{119E}', '\u{119F}', '\u{11A0}', '\u{11A1}', '\u{11A2}', '\u{11A8}', '\u{11A9}', '\u{11AA}', '\u{11AB}', '\u{11AC}', '\u{11AD}', '\u{11AE}', '\u{11AF}', '\u{11B0}', '\u{11B1}', '\u{11B2}', '\u{11B3}', '\u{11B4}', '\u{11B5}', '\u{11B6}', '\u{11B7}', '\u{11B8}', '\u{11B9}', '\u{11BA}', '\u{11BB}', '\u{11BC}', '\u{11BD}', '\u{11BE}', '\u{11BF}', '\u{11C0}', '\u{11C1}', '\u{11C2}', '\u{11C3}', '\u{11C4}', '\u{11C5}', '\u{11C6}', '\u{11C7}', '\u{11C8}', '\u{11C9}', '\u{11CA}', '\u{11CB}', '\u{11CC}', '\u{11CD}', '\u{11CE}', '\u{11CF}', '\u{11D0}', '\u{11D1}', '\u{11D2}', '\u{11D3}', '\u{11D4}', '\u{11D5}', '\u{11D6}', '\u{11D7}', '\u{11D8}', '\u{11D9}', '\u{11DA}', '\u{11DB}', '\u{11DC}', '\u{11DD}', '\u{11DE}', '\u{11DF}', '\u{11E0}', '\u{11E1}', '\u{11E2}', '\u{11E3}', '\u{11E4}', '\u{11E5}', '\u{11E6}', '\u{11E7}', '\u{11E8}', '\u{11E9}', '\u{11EA}', '\u{11EB}', '\u{11EC}', '\u{11ED}', '\u{11EE}', '\u{11EF}', '\u{11F0}', '\u{11F1}', '\u{11F2}', '\u{11F3}', '\u{11F4}', '\u{11F5}', '\u{11F6}', '\u{11F7}', '\u{11F8}', '\u{11F9}', '\u{1200}', '\u{1201}', '\u{1202}', '\u{1203}', '\u{1204}', '\u{1205}', '\u{1206}', '\u{1207}', '\u{1208}', '\u{1209}', '\u{120A}', '\u{120B}', '\u{120C}', '\u{120D}', '\u{120E}', '\u{120F}', '\u{1210}', '\u{1211}', '\u{1212}', '\u{1213}', '\u{1214}', '\u{1215}', '\u{1216}', '\u{1217}', '\u{1218}', '\u{1219}', '\u{121A}', '\u{121B}', '\u{121C}', '\u{121D}', '\u{121E}', '\u{121F}', '\u{1220}', '\u{1221}', '\u{1222}', '\u{1223}', '\u{1224}', '\u{1225}', '\u{1226}', '\u{1227}', '\u{1228}', '\u{1229}', '\u{122A}', '\u{122B}', '\u{122C}', '\u{122D}', '\u{122E}', '\u{122F}', '\u{1230}', '\u{1231}', '\u{1232}', '\u{1233}', '\u{1234}', '\u{1235}', '\u{1236}', '\u{1237}', '\u{1238}', '\u{1239}', '\u{123A}', '\u{123B}', '\u{123C}', '\u{123D}', '\u{123E}', '\u{123F}', '\u{1240}', '\u{1241}', '\u{1242}', '\u{1243}', '\u{1244}', '\u{1245}', '\u{1246}', '\u{1247}', '\u{1248}', '\u{124A}', '\u{124B}', '\u{124C}', '\u{124D}', '\u{1250}', '\u{1251}', '\u{1252}', '\u{1253}', '\u{1254}', '\u{1255}', '\u{1256}', '\u{1258}', '\u{125A}', '\u{125B}', '\u{125C}', '\u{125D}', '\u{1260}', '\u{1261}', '\u{1262}', '\u{1263}', '\u{1264}', '\u{1265}', '\u{1266}', '\u{1267}', '\u{1268}', '\u{1269}', '\u{126A}', '\u{126B}', '\u{126C}', '\u{126D}', '\u{126E}', '\u{126F}', '\u{1270}', '\u{1271}', '\u{1272}', '\u{1273}', '\u{1274}', '\u{1275}', '\u{1276}', '\u{1277}', '\u{1278}', '\u{1279}', '\u{127A}', '\u{127B}', '\u{127C}', '\u{127D}', '\u{127E}', '\u{127F}', '\u{1280}', '\u{1281}', '\u{1282}', '\u{1283}', '\u{1284}', '\u{1285}', '\u{1286}', '\u{1287}', '\u{1288}', '\u{128A}', '\u{128B}', '\u{128C}', '\u{128D}', '\u{1290}', '\u{1291}', '\u{1292}', '\u{1293}', '\u{1294}', '\u{1295}', '\u{1296}', '\u{1297}', '\u{1298}', '\u{1299}', '\u{129A}', '\u{129B}', '\u{129C}', '\u{129D}', '\u{129E}', '\u{129F}', '\u{12A0}', '\u{12A1}', '\u{12A2}', '\u{12A3}', '\u{12A4}', '\u{12A5}', '\u{12A6}', '\u{12A7}', '\u{12A8}', '\u{12A9}', '\u{12AA}', '\u{12AB}', '\u{12AC}', '\u{12AD}', '\u{12AE}', '\u{12AF}', '\u{12B0}', '\u{12B2}', '\u{12B3}', '\u{12B4}', '\u{12B5}', '\u{12B8}', '\u{12B9}', '\u{12BA}', '\u{12BB}', '\u{12BC}', '\u{12BD}', '\u{12BE}', '\u{12C0}', '\u{12C2}', '\u{12C3}', '\u{12C4}', '\u{12C5}', '\u{12C8}', '\u{12C9}', '\u{12CA}', '\u{12CB}', '\u{12CC}', '\u{12CD}', '\u{12CE}', '\u{12CF}', '\u{12D0}', '\u{12D1}', '\u{12D2}', '\u{12D3}', '\u{12D4}', '\u{12D5}', '\u{12D6}', '\u{12D8}', '\u{12D9}', '\u{12DA}', '\u{12DB}', '\u{12DC}', '\u{12DD}', '\u{12DE}', '\u{12DF}', '\u{12E0}', '\u{12E1}', '\u{12E2}', '\u{12E3}', '\u{12E4}', '\u{12E5}', '\u{12E6}', '\u{12E7}', '\u{12E8}', '\u{12E9}', '\u{12EA}', '\u{12EB}', '\u{12EC}', '\u{12ED}', '\u{12EE}', '\u{12EF}', '\u{12F0}', '\u{12F1}', '\u{12F2}', '\u{12F3}', '\u{12F4}', '\u{12F5}', '\u{12F6}', '\u{12F7}', '\u{12F8}', '\u{12F9}', '\u{12FA}', '\u{12FB}', '\u{12FC}', '\u{12FD}', '\u{12FE}', '\u{12FF}', '\u{1300}', '\u{1301}', '\u{1302}', '\u{1303}', '\u{1304}', '\u{1305}', '\u{1306}', '\u{1307}', '\u{1308}', '\u{1309}', '\u{130A}', '\u{130B}', '\u{130C}', '\u{130D}', '\u{130E}', '\u{130F}', '\u{1310}', '\u{1312}', '\u{1313}', '\u{1314}', '\u{1315}', '\u{1318}', '\u{1319}', '\u{131A}', '\u{131B}', '\u{131C}', '\u{131D}', '\u{131E}', '\u{131F}', '\u{1320}', '\u{1321}', '\u{1322}', '\u{1323}', '\u{1324}', '\u{1325}', '\u{1326}', '\u{1327}', '\u{1328}', '\u{1329}', '\u{132A}', '\u{132B}', '\u{132C}', '\u{132D}', '\u{132E}', '\u{132F}', '\u{1330}', '\u{1331}', '\u{1332}', '\u{1333}', '\u{1334}', '\u{1335}', '\u{1336}', '\u{1337}', '\u{1338}', '\u{1339}', '\u{133A}', '\u{133B}', '\u{133C}', '\u{133D}', '\u{133E}', '\u{133F}', '\u{1340}', '\u{1341}', '\u{1342}', '\u{1343}', '\u{1344}', '\u{1345}', '\u{1346}', '\u{1347}', '\u{1348}', '\u{1349}', '\u{134A}', '\u{134B}', '\u{134C}', '\u{134D}', '\u{134E}', '\u{134F}', '\u{1350}', '\u{1351}', '\u{1352}', '\u{1353}', '\u{1354}', '\u{1355}', '\u{1356}', '\u{1357}', '\u{1358}', '\u{1359}', '\u{135A}', '\u{1380}', '\u{1381}', '\u{1382}', '\u{1383}', '\u{1384}', '\u{1385}', '\u{1386}', '\u{1387}', '\u{1388}', '\u{1389}', '\u{138A}', '\u{138B}', '\u{138C}', '\u{138D}', '\u{138E}', '\u{138F}', '\u{13A0}', '\u{13A1}', '\u{13A2}', '\u{13A3}', '\u{13A4}', '\u{13A5}', '\u{13A6}', '\u{13A7}', '\u{13A8}', '\u{13A9}', '\u{13AA}', '\u{13AB}', '\u{13AC}', '\u{13AD}', '\u{13AE}', '\u{13AF}', '\u{13B0}', '\u{13B1}', '\u{13B2}', '\u{13B3}', '\u{13B4}', '\u{13B5}', '\u{13B6}', '\u{13B7}', '\u{13B8}', '\u{13B9}', '\u{13BA}', '\u{13BB}', '\u{13BC}', '\u{13BD}', '\u{13BE}', '\u{13BF}', '\u{13C0}', '\u{13C1}', '\u{13C2}', '\u{13C3}', '\u{13C4}', '\u{13C5}', '\u{13C6}', '\u{13C7}', '\u{13C8}', '\u{13C9}', '\u{13CA}', '\u{13CB}', '\u{13CC}', '\u{13CD}', '\u{13CE}', '\u{13CF}', '\u{13D0}', '\u{13D1}', '\u{13D2}', '\u{13D3}', '\u{13D4}', '\u{13D5}', '\u{13D6}', '\u{13D7}', '\u{13D8}', '\u{13D9}', '\u{13DA}', '\u{13DB}', '\u{13DC}', '\u{13DD}', '\u{13DE}', '\u{13DF}', '\u{13E0}', '\u{13E1}', '\u{13E2}', '\u{13E3}', '\u{13E4}', '\u{13E5}', '\u{13E6}', '\u{13E7}', '\u{13E8}', '\u{13E9}', '\u{13EA}', '\u{13EB}', '\u{13EC}', '\u{13ED}', '\u{13EE}', '\u{13EF}', '\u{13F0}', '\u{13F1}', '\u{13F2}', '\u{13F3}', '\u{13F4}', '\u{1401}', '\u{1402}', '\u{1403}', '\u{1404}', '\u{1405}', '\u{1406}', '\u{1407}', '\u{1408}', '\u{1409}', '\u{140A}', '\u{140B}', '\u{140C}', '\u{140D}', '\u{140E}', '\u{140F}', '\u{1410}', '\u{1411}', '\u{1412}', '\u{1413}', '\u{1414}', '\u{1415}', '\u{1416}', '\u{1417}', '\u{1418}', '\u{1419}', '\u{141A}', '\u{141B}', '\u{141C}', '\u{141D}', '\u{141E}', '\u{141F}', '\u{1420}', '\u{1421}', '\u{1422}', '\u{1423}', '\u{1424}', '\u{1425}', '\u{1426}', '\u{1427}', '\u{1428}', '\u{1429}', '\u{142A}', '\u{142B}', '\u{142C}', '\u{142D}', '\u{142E}', '\u{142F}', '\u{1430}', '\u{1431}', '\u{1432}', '\u{1433}', '\u{1434}', '\u{1435}', '\u{1436}', '\u{1437}', '\u{1438}', '\u{1439}', '\u{143A}', '\u{143B}', '\u{143C}', '\u{143D}', '\u{143E}', '\u{143F}', '\u{1440}', '\u{1441}', '\u{1442}', '\u{1443}', '\u{1444}', '\u{1445}', '\u{1446}', '\u{1447}', '\u{1448}', '\u{1449}', '\u{144A}', '\u{144B}', '\u{144C}', '\u{144D}', '\u{144E}', '\u{144F}', '\u{1450}', '\u{1451}', '\u{1452}', '\u{1453}', '\u{1454}', '\u{1455}', '\u{1456}', '\u{1457}', '\u{1458}', '\u{1459}', '\u{145A}', '\u{145B}', '\u{145C}', '\u{145D}', '\u{145E}', '\u{145F}', '\u{1460}', '\u{1461}', '\u{1462}', '\u{1463}', '\u{1464}', '\u{1465}', '\u{1466}', '\u{1467}', '\u{1468}', '\u{1469}', '\u{146A}', '\u{146B}', '\u{146C}', '\u{146D}', '\u{146E}', '\u{146F}', '\u{1470}', '\u{1471}', '\u{1472}', '\u{1473}', '\u{1474}', '\u{1475}', '\u{1476}', '\u{1477}', '\u{1478}', '\u{1479}', '\u{147A}', '\u{147B}', '\u{147C}', '\u{147D}', '\u{147E}', '\u{147F}', '\u{1480}', '\u{1481}', '\u{1482}', '\u{1483}', '\u{1484}', '\u{1485}', '\u{1486}', '\u{1487}', '\u{1488}', '\u{1489}', '\u{148A}', '\u{148B}', '\u{148C}', '\u{148D}', '\u{148E}', '\u{148F}', '\u{1490}', '\u{1491}', '\u{1492}', '\u{1493}', '\u{1494}', '\u{1495}', '\u{1496}', '\u{1497}', '\u{1498}', '\u{1499}', '\u{149A}', '\u{149B}', '\u{149C}', '\u{149D}', '\u{149E}', '\u{149F}', '\u{14A0}', '\u{14A1}', '\u{14A2}', '\u{14A3}', '\u{14A4}', '\u{14A5}', '\u{14A6}', '\u{14A7}', '\u{14A8}', '\u{14A9}', '\u{14AA}', '\u{14AB}', '\u{14AC}', '\u{14AD}', '\u{14AE}', '\u{14AF}', '\u{14B0}', '\u{14B1}', '\u{14B2}', '\u{14B3}', '\u{14B4}', '\u{14B5}', '\u{14B6}', '\u{14B7}', '\u{14B8}', '\u{14B9}', '\u{14BA}', '\u{14BB}', '\u{14BC}', '\u{14BD}', '\u{14BE}', '\u{14BF}', '\u{14C0}', '\u{14C1}', '\u{14C2}', '\u{14C3}', '\u{14C4}', '\u{14C5}', '\u{14C6}', '\u{14C7}', '\u{14C8}', '\u{14C9}', '\u{14CA}', '\u{14CB}', '\u{14CC}', '\u{14CD}', '\u{14CE}', '\u{14CF}', '\u{14D0}', '\u{14D1}', '\u{14D2}', '\u{14D3}', '\u{14D4}', '\u{14D5}', '\u{14D6}', '\u{14D7}', '\u{14D8}', '\u{14D9}', '\u{14DA}', '\u{14DB}', '\u{14DC}', '\u{14DD}', '\u{14DE}', '\u{14DF}', '\u{14E0}', '\u{14E1}', '\u{14E2}', '\u{14E3}', '\u{14E4}', '\u{14E5}', '\u{14E6}', '\u{14E7}', '\u{14E8}', '\u{14E9}', '\u{14EA}', '\u{14EB}', '\u{14EC}', '\u{14ED}', '\u{14EE}', '\u{14EF}', '\u{14F0}', '\u{14F1}', '\u{14F2}', '\u{14F3}', '\u{14F4}', '\u{14F5}', '\u{14F6}', '\u{14F7}', '\u{14F8}', '\u{14F9}', '\u{14FA}', '\u{14FB}', '\u{14FC}', '\u{14FD}', '\u{14FE}', '\u{14FF}', '\u{1500}', '\u{1501}', '\u{1502}', '\u{1503}', '\u{1504}', '\u{1505}', '\u{1506}', '\u{1507}', '\u{1508}', '\u{1509}', '\u{150A}', '\u{150B}', '\u{150C}', '\u{150D}', '\u{150E}', '\u{150F}', '\u{1510}', '\u{1511}', '\u{1512}', '\u{1513}', '\u{1514}', '\u{1515}', '\u{1516}', '\u{1517}', '\u{1518}', '\u{1519}', '\u{151A}', '\u{151B}', '\u{151C}', '\u{151D}', '\u{151E}', '\u{151F}', '\u{1520}', '\u{1521}', '\u{1522}', '\u{1523}', '\u{1524}', '\u{1525}', '\u{1526}', '\u{1527}', '\u{1528}', '\u{1529}', '\u{152A}', '\u{152B}', '\u{152C}', '\u{152D}', '\u{152E}', '\u{152F}', '\u{1530}', '\u{1531}', '\u{1532}', '\u{1533}', '\u{1534}', '\u{1535}', '\u{1536}', '\u{1537}', '\u{1538}', '\u{1539}', '\u{153A}', '\u{153B}', '\u{153C}', '\u{153D}', '\u{153E}', '\u{153F}', '\u{1540}', '\u{1541}', '\u{1542}', '\u{1543}', '\u{1544}', '\u{1545}', '\u{1546}', '\u{1547}', '\u{1548}', '\u{1549}', '\u{154A}', '\u{154B}', '\u{154C}', '\u{154D}', '\u{154E}', '\u{154F}', '\u{1550}', '\u{1551}', '\u{1552}', '\u{1553}', '\u{1554}', '\u{1555}', '\u{1556}', '\u{1557}', '\u{1558}', '\u{1559}', '\u{155A}', '\u{155B}', '\u{155C}', '\u{155D}', '\u{155E}', '\u{155F}', '\u{1560}', '\u{1561}', '\u{1562}', '\u{1563}', '\u{1564}', '\u{1565}', '\u{1566}', '\u{1567}', '\u{1568}', '\u{1569}', '\u{156A}', '\u{156B}', '\u{156C}', '\u{156D}', '\u{156E}', '\u{156F}', '\u{1570}', '\u{1571}', '\u{1572}', '\u{1573}', '\u{1574}', '\u{1575}', '\u{1576}', '\u{1577}', '\u{1578}', '\u{1579}', '\u{157A}', '\u{157B}', '\u{157C}', '\u{157D}', '\u{157E}', '\u{157F}', '\u{1580}', '\u{1581}', '\u{1582}', '\u{1583}', '\u{1584}', '\u{1585}', '\u{1586}', '\u{1587}', '\u{1588}', '\u{1589}', '\u{158A}', '\u{158B}', '\u{158C}', '\u{158D}', '\u{158E}', '\u{158F}', '\u{1590}', '\u{1591}', '\u{1592}', '\u{1593}', '\u{1594}', '\u{1595}', '\u{1596}', '\u{1597}', '\u{1598}', '\u{1599}', '\u{159A}', '\u{159B}', '\u{159C}', '\u{159D}', '\u{159E}', '\u{159F}', '\u{15A0}', '\u{15A1}', '\u{15A2}', '\u{15A3}', '\u{15A4}', '\u{15A5}', '\u{15A6}', '\u{15A7}', '\u{15A8}', '\u{15A9}', '\u{15AA}', '\u{15AB}', '\u{15AC}', '\u{15AD}', '\u{15AE}', '\u{15AF}', '\u{15B0}', '\u{15B1}', '\u{15B2}', '\u{15B3}', '\u{15B4}', '\u{15B5}', '\u{15B6}', '\u{15B7}', '\u{15B8}', '\u{15B9}', '\u{15BA}', '\u{15BB}', '\u{15BC}', '\u{15BD}', '\u{15BE}', '\u{15BF}', '\u{15C0}', '\u{15C1}', '\u{15C2}', '\u{15C3}', '\u{15C4}', '\u{15C5}', '\u{15C6}', '\u{15C7}', '\u{15C8}', '\u{15C9}', '\u{15CA}', '\u{15CB}', '\u{15CC}', '\u{15CD}', '\u{15CE}', '\u{15CF}', '\u{15D0}', '\u{15D1}', '\u{15D2}', '\u{15D3}', '\u{15D4}', '\u{15D5}', '\u{15D6}', '\u{15D7}', '\u{15D8}', '\u{15D9}', '\u{15DA}', '\u{15DB}', '\u{15DC}', '\u{15DD}', '\u{15DE}', '\u{15DF}', '\u{15E0}', '\u{15E1}', '\u{15E2}', '\u{15E3}', '\u{15E4}', '\u{15E5}', '\u{15E6}', '\u{15E7}', '\u{15E8}', '\u{15E9}', '\u{15EA}', '\u{15EB}', '\u{15EC}', '\u{15ED}', '\u{15EE}', '\u{15EF}', '\u{15F0}', '\u{15F1}', '\u{15F2}', '\u{15F3}', '\u{15F4}', '\u{15F5}', '\u{15F6}', '\u{15F7}', '\u{15F8}', '\u{15F9}', '\u{15FA}', '\u{15FB}', '\u{15FC}', '\u{15FD}', '\u{15FE}', '\u{15FF}', '\u{1600}', '\u{1601}', '\u{1602}', '\u{1603}', '\u{1604}', '\u{1605}', '\u{1606}', '\u{1607}', '\u{1608}', '\u{1609}', '\u{160A}', '\u{160B}', '\u{160C}', '\u{160D}', '\u{160E}', '\u{160F}', '\u{1610}', '\u{1611}', '\u{1612}', '\u{1613}', '\u{1614}', '\u{1615}', '\u{1616}', '\u{1617}', '\u{1618}', '\u{1619}', '\u{161A}', '\u{161B}', '\u{161C}', '\u{161D}', '\u{161E}', '\u{161F}', '\u{1620}', '\u{1621}', '\u{1622}', '\u{1623}', '\u{1624}', '\u{1625}', '\u{1626}', '\u{1627}', '\u{1628}', '\u{1629}', '\u{162A}', '\u{162B}', '\u{162C}', '\u{162D}', '\u{162E}', '\u{162F}', '\u{1630}', '\u{1631}', '\u{1632}', '\u{1633}', '\u{1634}', '\u{1635}', '\u{1636}', '\u{1637}', '\u{1638}', '\u{1639}', '\u{163A}', '\u{163B}', '\u{163C}', '\u{163D}', '\u{163E}', '\u{163F}', '\u{1640}', '\u{1641}', '\u{1642}', '\u{1643}', '\u{1644}', '\u{1645}', '\u{1646}', '\u{1647}', '\u{1648}', '\u{1649}', '\u{164A}', '\u{164B}', '\u{164C}', '\u{164D}', '\u{164E}', '\u{164F}', '\u{1650}', '\u{1651}', '\u{1652}', '\u{1653}', '\u{1654}', '\u{1655}', '\u{1656}', '\u{1657}', '\u{1658}', '\u{1659}', '\u{165A}', '\u{165B}', '\u{165C}', '\u{165D}', '\u{165E}', '\u{165F}', '\u{1660}', '\u{1661}', '\u{1662}', '\u{1663}', '\u{1664}', '\u{1665}', '\u{1666}', '\u{1667}', '\u{1668}', '\u{1669}', '\u{166A}', '\u{166B}', '\u{166C}', '\u{166F}', '\u{1670}', '\u{1671}', '\u{1672}', '\u{1673}', '\u{1674}', '\u{1675}', '\u{1676}', '\u{1681}', '\u{1682}', '\u{1683}', '\u{1684}', '\u{1685}', '\u{1686}', '\u{1687}', '\u{1688}', '\u{1689}', '\u{168A}', '\u{168B}', '\u{168C}', '\u{168D}', '\u{168E}', '\u{168F}', '\u{1690}', '\u{1691}', '\u{1692}', '\u{1693}', '\u{1694}', '\u{1695}', '\u{1696}', '\u{1697}', '\u{1698}', '\u{1699}', '\u{169A}', '\u{16A0}', '\u{16A1}', '\u{16A2}', '\u{16A3}', '\u{16A4}', '\u{16A5}', '\u{16A6}', '\u{16A7}', '\u{16A8}', '\u{16A9}', '\u{16AA}', '\u{16AB}', '\u{16AC}', '\u{16AD}', '\u{16AE}', '\u{16AF}', '\u{16B0}', '\u{16B1}', '\u{16B2}', '\u{16B3}', '\u{16B4}', '\u{16B5}', '\u{16B6}', '\u{16B7}', '\u{16B8}', '\u{16B9}', '\u{16BA}', '\u{16BB}', '\u{16BC}', '\u{16BD}', '\u{16BE}', '\u{16BF}', '\u{16C0}', '\u{16C1}', '\u{16C2}', '\u{16C3}', '\u{16C4}', '\u{16C5}', '\u{16C6}', '\u{16C7}', '\u{16C8}', '\u{16C9}', '\u{16CA}', '\u{16CB}', '\u{16CC}', '\u{16CD}', '\u{16CE}', '\u{16CF}', '\u{16D0}', '\u{16D1}', '\u{16D2}', '\u{16D3}', '\u{16D4}', '\u{16D5}', '\u{16D6}', '\u{16D7}', '\u{16D8}', '\u{16D9}', '\u{16DA}', '\u{16DB}', '\u{16DC}', '\u{16DD}', '\u{16DE}', '\u{16DF}', '\u{16E0}', '\u{16E1}', '\u{16E2}', '\u{16E3}', '\u{16E4}', '\u{16E5}', '\u{16E6}', '\u{16E7}', '\u{16E8}', '\u{16E9}', '\u{16EA}', '\u{1700}', '\u{1701}', '\u{1702}', '\u{1703}', '\u{1704}', '\u{1705}', '\u{1706}', '\u{1707}', '\u{1708}', '\u{1709}', '\u{170A}', '\u{170B}', '\u{170C}', '\u{170E}', '\u{170F}', '\u{1710}', '\u{1711}', '\u{1720}', '\u{1721}', '\u{1722}', '\u{1723}', '\u{1724}', '\u{1725}', '\u{1726}', '\u{1727}', '\u{1728}', '\u{1729}', '\u{172A}', '\u{172B}', '\u{172C}', '\u{172D}', '\u{172E}', '\u{172F}', '\u{1730}', '\u{1731}', '\u{1740}', '\u{1741}', '\u{1742}', '\u{1743}', '\u{1744}', '\u{1745}', '\u{1746}', '\u{1747}', '\u{1748}', '\u{1749}', '\u{174A}', '\u{174B}', '\u{174C}', '\u{174D}', '\u{174E}', '\u{174F}', '\u{1750}', '\u{1751}', '\u{1760}', '\u{1761}', '\u{1762}', '\u{1763}', '\u{1764}', '\u{1765}', '\u{1766}', '\u{1767}', '\u{1768}', '\u{1769}', '\u{176A}', '\u{176B}', '\u{176C}', '\u{176E}', '\u{176F}', '\u{1770}', '\u{1780}', '\u{1781}', '\u{1782}', '\u{1783}', '\u{1784}', '\u{1785}', '\u{1786}', '\u{1787}', '\u{1788}', '\u{1789}', '\u{178A}', '\u{178B}', '\u{178C}', '\u{178D}', '\u{178E}', '\u{178F}', '\u{1790}', '\u{1791}', '\u{1792}', '\u{1793}', '\u{1794}', '\u{1795}', '\u{1796}', '\u{1797}', '\u{1798}', '\u{1799}', '\u{179A}', '\u{179B}', '\u{179C}', '\u{179D}', '\u{179E}', '\u{179F}', '\u{17A0}', '\u{17A1}', '\u{17A2}', '\u{17A3}', '\u{17A4}', '\u{17A5}', '\u{17A6}', '\u{17A7}', '\u{17A8}', '\u{17A9}', '\u{17AA}', '\u{17AB}', '\u{17AC}', '\u{17AD}', '\u{17AE}', '\u{17AF}', '\u{17B0}', '\u{17B1}', '\u{17B2}', '\u{17B3}', '\u{17DC}', '\u{1820}', '\u{1821}', '\u{1822}', '\u{1823}', '\u{1824}', '\u{1825}', '\u{1826}', '\u{1827}', '\u{1828}', '\u{1829}', '\u{182A}', '\u{182B}', '\u{182C}', '\u{182D}', '\u{182E}', '\u{182F}', '\u{1830}', '\u{1831}', '\u{1832}', '\u{1833}', '\u{1834}', '\u{1835}', '\u{1836}', '\u{1837}', '\u{1838}', '\u{1839}', '\u{183A}', '\u{183B}', '\u{183C}', '\u{183D}', '\u{183E}', '\u{183F}', '\u{1840}', '\u{1841}', '\u{1842}', '\u{1844}', '\u{1845}', '\u{1846}', '\u{1847}', '\u{1848}', '\u{1849}', '\u{184A}', '\u{184B}', '\u{184C}', '\u{184D}', '\u{184E}', '\u{184F}', '\u{1850}', '\u{1851}', '\u{1852}', '\u{1853}', '\u{1854}', '\u{1855}', '\u{1856}', '\u{1857}', '\u{1858}', '\u{1859}', '\u{185A}', '\u{185B}', '\u{185C}', '\u{185D}', '\u{185E}', '\u{185F}', '\u{1860}', '\u{1861}', '\u{1862}', '\u{1863}', '\u{1864}', '\u{1865}', '\u{1866}', '\u{1867}', '\u{1868}', '\u{1869}', '\u{186A}', '\u{186B}', '\u{186C}', '\u{186D}', '\u{186E}', '\u{186F}', '\u{1870}', '\u{1871}', '\u{1872}', '\u{1873}', '\u{1874}', '\u{1875}', '\u{1876}', '\u{1877}', '\u{1880}', '\u{1881}', '\u{1882}', '\u{1883}', '\u{1884}', '\u{1885}', '\u{1886}', '\u{1887}', '\u{1888}', '\u{1889}', '\u{188A}', '\u{188B}', '\u{188C}', '\u{188D}', '\u{188E}', '\u{188F}', '\u{1890}', '\u{1891}', '\u{1892}', '\u{1893}', '\u{1894}', '\u{1895}', '\u{1896}', '\u{1897}', '\u{1898}', '\u{1899}', '\u{189A}', '\u{189B}', '\u{189C}', '\u{189D}', '\u{189E}', '\u{189F}', '\u{18A0}', '\u{18A1}', '\u{18A2}', '\u{18A3}', '\u{18A4}', '\u{18A5}', '\u{18A6}', '\u{18A7}', '\u{18A8}', '\u{18AA}', '\u{1900}', '\u{1901}', '\u{1902}', '\u{1903}', '\u{1904}', '\u{1905}', '\u{1906}', '\u{1907}', '\u{1908}', '\u{1909}', '\u{190A}', '\u{190B}', '\u{190C}', '\u{190D}', '\u{190E}', '\u{190F}', '\u{1910}', '\u{1911}', '\u{1912}', '\u{1913}', '\u{1914}', '\u{1915}', '\u{1916}', '\u{1917}', '\u{1918}', '\u{1919}', '\u{191A}', '\u{191B}', '\u{191C}', '\u{1950}', '\u{1951}', '\u{1952}', '\u{1953}', '\u{1954}', '\u{1955}', '\u{1956}', '\u{1957}', '\u{1958}', '\u{1959}', '\u{195A}', '\u{195B}', '\u{195C}', '\u{195D}', '\u{195E}', '\u{195F}', '\u{1960}', '\u{1961}', '\u{1962}', '\u{1963}', '\u{1964}', '\u{1965}', '\u{1966}', '\u{1967}', '\u{1968}', '\u{1969}', '\u{196A}', '\u{196B}', '\u{196C}', '\u{196D}', '\u{1970}', '\u{1971}', '\u{1972}', '\u{1973}', '\u{1974}', '\u{1980}', '\u{1981}', '\u{1982}', '\u{1983}', '\u{1984}', '\u{1985}', '\u{1986}', '\u{1987}', '\u{1988}', '\u{1989}', '\u{198A}', '\u{198B}', '\u{198C}', '\u{198D}', '\u{198E}', '\u{198F}', '\u{1990}', '\u{1991}', '\u{1992}', '\u{1993}', '\u{1994}', '\u{1995}', '\u{1996}', '\u{1997}', '\u{1998}', '\u{1999}', '\u{199A}', '\u{199B}', '\u{199C}', '\u{199D}', '\u{199E}', '\u{199F}', '\u{19A0}', '\u{19A1}', '\u{19A2}', '\u{19A3}', '\u{19A4}', '\u{19A5}', '\u{19A6}', '\u{19A7}', '\u{19A8}', '\u{19A9}', '\u{19C1}', '\u{19C2}', '\u{19C3}', '\u{19C4}', '\u{19C5}', '\u{19C6}', '\u{19C7}', '\u{1A00}', '\u{1A01}', '\u{1A02}', '\u{1A03}', '\u{1A04}', '\u{1A05}', '\u{1A06}', '\u{1A07}', '\u{1A08}', '\u{1A09}', '\u{1A0A}', '\u{1A0B}', '\u{1A0C}', '\u{1A0D}', '\u{1A0E}', '\u{1A0F}', '\u{1A10}', '\u{1A11}', '\u{1A12}', '\u{1A13}', '\u{1A14}', '\u{1A15}', '\u{1A16}', '\u{1B05}', '\u{1B06}', '\u{1B07}', '\u{1B08}', '\u{1B09}', '\u{1B0A}', '\u{1B0B}', '\u{1B0C}', '\u{1B0D}', '\u{1B0E}', '\u{1B0F}', '\u{1B10}', '\u{1B11}', '\u{1B12}', '\u{1B13}', '\u{1B14}', '\u{1B15}', '\u{1B16}', '\u{1B17}', '\u{1B18}', '\u{1B19}', '\u{1B1A}', '\u{1B1B}', '\u{1B1C}', '\u{1B1D}', '\u{1B1E}', '\u{1B1F}', '\u{1B20}', '\u{1B21}', '\u{1B22}', '\u{1B23}', '\u{1B24}', '\u{1B25}', '\u{1B26}', '\u{1B27}', '\u{1B28}', '\u{1B29}', '\u{1B2A}', '\u{1B2B}', '\u{1B2C}', '\u{1B2D}', '\u{1B2E}', '\u{1B2F}', '\u{1B30}', '\u{1B31}', '\u{1B32}', '\u{1B33}', '\u{1B45}', '\u{1B46}', '\u{1B47}', '\u{1B48}', '\u{1B49}', '\u{1B4A}', '\u{1B4B}', '\u{1B83}', '\u{1B84}', '\u{1B85}', '\u{1B86}', '\u{1B87}', '\u{1B88}', '\u{1B89}', '\u{1B8A}', '\u{1B8B}', '\u{1B8C}', '\u{1B8D}', '\u{1B8E}', '\u{1B8F}', '\u{1B90}', '\u{1B91}', '\u{1B92}', '\u{1B93}', '\u{1B94}', '\u{1B95}', '\u{1B96}', '\u{1B97}', '\u{1B98}', '\u{1B99}', '\u{1B9A}', '\u{1B9B}', '\u{1B9C}', '\u{1B9D}', '\u{1B9E}', '\u{1B9F}', '\u{1BA0}', '\u{1BAE}', '\u{1BAF}', '\u{1C00}', '\u{1C01}', '\u{1C02}', '\u{1C03}', '\u{1C04}', '\u{1C05}', '\u{1C06}', '\u{1C07}', '\u{1C08}', '\u{1C09}', '\u{1C0A}', '\u{1C0B}', '\u{1C0C}', '\u{1C0D}', '\u{1C0E}', '\u{1C0F}', '\u{1C10}', '\u{1C11}', '\u{1C12}', '\u{1C13}', '\u{1C14}', '\u{1C15}', '\u{1C16}', '\u{1C17}', '\u{1C18}', '\u{1C19}', '\u{1C1A}', '\u{1C1B}', '\u{1C1C}', '\u{1C1D}', '\u{1C1E}', '\u{1C1F}', '\u{1C20}', '\u{1C21}', '\u{1C22}', '\u{1C23}', '\u{1C4D}', '\u{1C4E}', '\u{1C4F}', '\u{1C5A}', '\u{1C5B}', '\u{1C5C}', '\u{1C5D}', '\u{1C5E}', '\u{1C5F}', '\u{1C60}', '\u{1C61}', '\u{1C62}', '\u{1C63}', '\u{1C64}', '\u{1C65}', '\u{1C66}', '\u{1C67}', '\u{1C68}', '\u{1C69}', '\u{1C6A}', '\u{1C6B}', '\u{1C6C}', '\u{1C6D}', '\u{1C6E}', '\u{1C6F}', '\u{1C70}', '\u{1C71}', '\u{1C72}', '\u{1C73}', '\u{1C74}', '\u{1C75}', '\u{1C76}', '\u{1C77}', '\u{2135}', '\u{2136}', '\u{2137}', '\u{2138}', '\u{2D30}', '\u{2D31}', '\u{2D32}', '\u{2D33}', '\u{2D34}', '\u{2D35}', '\u{2D36}', '\u{2D37}', '\u{2D38}', '\u{2D39}', '\u{2D3A}', '\u{2D3B}', '\u{2D3C}', '\u{2D3D}', '\u{2D3E}', '\u{2D3F}', '\u{2D40}', '\u{2D41}', '\u{2D42}', '\u{2D43}', '\u{2D44}', '\u{2D45}', '\u{2D46}', '\u{2D47}', '\u{2D48}', '\u{2D49}', '\u{2D4A}', '\u{2D4B}', '\u{2D4C}', '\u{2D4D}', '\u{2D4E}', '\u{2D4F}', '\u{2D50}', '\u{2D51}', '\u{2D52}', '\u{2D53}', '\u{2D54}', '\u{2D55}', '\u{2D56}', '\u{2D57}', '\u{2D58}', '\u{2D59}', '\u{2D5A}', '\u{2D5B}', '\u{2D5C}', '\u{2D5D}', '\u{2D5E}', '\u{2D5F}', '\u{2D60}', '\u{2D61}', '\u{2D62}', '\u{2D63}', '\u{2D64}', '\u{2D65}', '\u{2D80}', '\u{2D81}', '\u{2D82}', '\u{2D83}', '\u{2D84}', '\u{2D85}', '\u{2D86}', '\u{2D87}', '\u{2D88}', '\u{2D89}', '\u{2D8A}', '\u{2D8B}', '\u{2D8C}', '\u{2D8D}', '\u{2D8E}', '\u{2D8F}', '\u{2D90}', '\u{2D91}', '\u{2D92}', '\u{2D93}', '\u{2D94}', '\u{2D95}', '\u{2D96}', '\u{2DA0}', '\u{2DA1}', '\u{2DA2}', '\u{2DA3}', '\u{2DA4}', '\u{2DA5}', '\u{2DA6}', '\u{2DA8}', '\u{2DA9}', '\u{2DAA}', '\u{2DAB}', '\u{2DAC}', '\u{2DAD}', '\u{2DAE}', '\u{2DB0}', '\u{2DB1}', '\u{2DB2}', '\u{2DB3}', '\u{2DB4}', '\u{2DB5}', '\u{2DB6}', '\u{2DB8}', '\u{2DB9}', '\u{2DBA}', '\u{2DBB}', '\u{2DBC}', '\u{2DBD}', '\u{2DBE}', '\u{2DC0}', '\u{2DC1}', '\u{2DC2}', '\u{2DC3}', '\u{2DC4}', '\u{2DC5}', '\u{2DC6}', '\u{2DC8}', '\u{2DC9}', '\u{2DCA}', '\u{2DCB}', '\u{2DCC}', '\u{2DCD}', '\u{2DCE}', '\u{2DD0}', '\u{2DD1}', '\u{2DD2}', '\u{2DD3}', '\u{2DD4}', '\u{2DD5}', '\u{2DD6}', '\u{2DD8}', '\u{2DD9}', '\u{2DDA}', '\u{2DDB}', '\u{2DDC}', '\u{2DDD}', '\u{2DDE}', '\u{3006}', '\u{303C}', '\u{3041}', '\u{3042}', '\u{3043}', '\u{3044}', '\u{3045}', '\u{3046}', '\u{3047}', '\u{3048}', '\u{3049}', '\u{304A}', '\u{304B}', '\u{304C}', '\u{304D}', '\u{304E}', '\u{304F}', '\u{3050}', '\u{3051}', '\u{3052}', '\u{3053}', '\u{3054}', '\u{3055}', '\u{3056}', '\u{3057}', '\u{3058}', '\u{3059}', '\u{305A}', '\u{305B}', '\u{305C}', '\u{305D}', '\u{305E}', '\u{305F}', '\u{3060}', '\u{3061}', '\u{3062}', '\u{3063}', '\u{3064}', '\u{3065}', '\u{3066}', '\u{3067}', '\u{3068}', '\u{3069}', '\u{306A}', '\u{306B}', '\u{306C}', '\u{306D}', '\u{306E}', '\u{306F}', '\u{3070}', '\u{3071}', '\u{3072}', '\u{3073}', '\u{3074}', '\u{3075}', '\u{3076}', '\u{3077}', '\u{3078}', '\u{3079}', '\u{307A}', '\u{307B}', '\u{307C}', '\u{307D}', '\u{307E}', '\u{307F}', '\u{3080}', '\u{3081}', '\u{3082}', '\u{3083}', '\u{3084}', '\u{3085}', '\u{3086}', '\u{3087}', '\u{3088}', '\u{3089}', '\u{308A}', '\u{308B}', '\u{308C}', '\u{308D}', '\u{308E}', '\u{308F}', '\u{3090}', '\u{3091}', '\u{3092}', '\u{3093}', '\u{3094}', '\u{3095}', '\u{3096}', '\u{309F}', '\u{30A1}', '\u{30A2}', '\u{30A3}', '\u{30A4}', '\u{30A5}', '\u{30A6}', '\u{30A7}', '\u{30A8}', '\u{30A9}', '\u{30AA}', '\u{30AB}', '\u{30AC}', '\u{30AD}', '\u{30AE}', '\u{30AF}', '\u{30B0}', '\u{30B1}', '\u{30B2}', '\u{30B3}', '\u{30B4}', '\u{30B5}', '\u{30B6}', '\u{30B7}', '\u{30B8}', '\u{30B9}', '\u{30BA}', '\u{30BB}', '\u{30BC}', '\u{30BD}', '\u{30BE}', '\u{30BF}', '\u{30C0}', '\u{30C1}', '\u{30C2}', '\u{30C3}', '\u{30C4}', '\u{30C5}', '\u{30C6}', '\u{30C7}', '\u{30C8}', '\u{30C9}', '\u{30CA}', '\u{30CB}', '\u{30CC}', '\u{30CD}', '\u{30CE}', '\u{30CF}', '\u{30D0}', '\u{30D1}', '\u{30D2}', '\u{30D3}', '\u{30D4}', '\u{30D5}', '\u{30D6}', '\u{30D7}', '\u{30D8}', '\u{30D9}', '\u{30DA}', '\u{30DB}', '\u{30DC}', '\u{30DD}', '\u{30DE}', '\u{30DF}', '\u{30E0}', '\u{30E1}', '\u{30E2}', '\u{30E3}', '\u{30E4}', '\u{30E5}', '\u{30E6}', '\u{30E7}', '\u{30E8}', '\u{30E9}', '\u{30EA}', '\u{30EB}', '\u{30EC}', '\u{30ED}', '\u{30EE}', '\u{30EF}', '\u{30F0}', '\u{30F1}', '\u{30F2}', '\u{30F3}', '\u{30F4}', '\u{30F5}', '\u{30F6}', '\u{30F7}', '\u{30F8}', '\u{30F9}', '\u{30FA}', '\u{30FF}', '\u{3105}', '\u{3106}', '\u{3107}', '\u{3108}', '\u{3109}', '\u{310A}', '\u{310B}', '\u{310C}', '\u{310D}', '\u{310E}', '\u{310F}', '\u{3110}', '\u{3111}', '\u{3112}', '\u{3113}', '\u{3114}', '\u{3115}', '\u{3116}', '\u{3117}', '\u{3118}', '\u{3119}', '\u{311A}', '\u{311B}', '\u{311C}', '\u{311D}', '\u{311E}', '\u{311F}', '\u{3120}', '\u{3121}', '\u{3122}', '\u{3123}', '\u{3124}', '\u{3125}', '\u{3126}', '\u{3127}', '\u{3128}', '\u{3129}', '\u{312A}', '\u{312B}', '\u{312C}', '\u{312D}', '\u{3131}', '\u{3132}', '\u{3133}', '\u{3134}', '\u{3135}', '\u{3136}', '\u{3137}', '\u{3138}', '\u{3139}', '\u{313A}', '\u{313B}', '\u{313C}', '\u{313D}', '\u{313E}', '\u{313F}', '\u{3140}', '\u{3141}', '\u{3142}', '\u{3143}', '\u{3144}', '\u{3145}', '\u{3146}', '\u{3147}', '\u{3148}', '\u{3149}', '\u{314A}', '\u{314B}', '\u{314C}', '\u{314D}', '\u{314E}', '\u{314F}', '\u{3150}', '\u{3151}', '\u{3152}', '\u{3153}', '\u{3154}', '\u{3155}', '\u{3156}', '\u{3157}', '\u{3158}', '\u{3159}', '\u{315A}', '\u{315B}', '\u{315C}', '\u{315D}', '\u{315E}', '\u{315F}', '\u{3160}', '\u{3161}', '\u{3162}', '\u{3163}', '\u{3164}', '\u{3165}', '\u{3166}', '\u{3167}', '\u{3168}', '\u{3169}', '\u{316A}', '\u{316B}', '\u{316C}', '\u{316D}', '\u{316E}', '\u{316F}', '\u{3170}', '\u{3171}', '\u{3172}', '\u{3173}', '\u{3174}', '\u{3175}', '\u{3176}', '\u{3177}', '\u{3178}', '\u{3179}', '\u{317A}', '\u{317B}', '\u{317C}', '\u{317D}', '\u{317E}', '\u{317F}', '\u{3180}', '\u{3181}', '\u{3182}', '\u{3183}', '\u{3184}', '\u{3185}', '\u{3186}', '\u{3187}', '\u{3188}', '\u{3189}', '\u{318A}', '\u{318B}', '\u{318C}', '\u{318D}', '\u{318E}', '\u{31A0}', '\u{31A1}', '\u{31A2}', '\u{31A3}', '\u{31A4}', '\u{31A5}', '\u{31A6}', '\u{31A7}', '\u{31A8}', '\u{31A9}', '\u{31AA}', '\u{31AB}', '\u{31AC}', '\u{31AD}', '\u{31AE}', '\u{31AF}', '\u{31B0}', '\u{31B1}', '\u{31B2}', '\u{31B3}', '\u{31B4}', '\u{31B5}', '\u{31B6}', '\u{31B7}', '\u{31F0}', '\u{31F1}', '\u{31F2}', '\u{31F3}', '\u{31F4}', '\u{31F5}', '\u{31F6}', '\u{31F7}', '\u{31F8}', '\u{31F9}', '\u{31FA}', '\u{31FB}', '\u{31FC}', '\u{31FD}', '\u{31FE}', '\u{31FF}', '\u{3400}', '\u{4DB5}', '\u{4E00}', '\u{9FC3}', '\u{A000}', '\u{A001}', '\u{A002}', '\u{A003}', '\u{A004}', '\u{A005}', '\u{A006}', '\u{A007}', '\u{A008}', '\u{A009}', '\u{A00A}', '\u{A00B}', '\u{A00C}', '\u{A00D}', '\u{A00E}', '\u{A00F}', '\u{A010}', '\u{A011}', '\u{A012}', '\u{A013}', '\u{A014}', '\u{A016}', '\u{A017}', '\u{A018}', '\u{A019}', '\u{A01A}', '\u{A01B}', '\u{A01C}', '\u{A01D}', '\u{A01E}', '\u{A01F}', '\u{A020}', '\u{A021}', '\u{A022}', '\u{A023}', '\u{A024}', '\u{A025}', '\u{A026}', '\u{A027}', '\u{A028}', '\u{A029}', '\u{A02A}', '\u{A02B}', '\u{A02C}', '\u{A02D}', '\u{A02E}', '\u{A02F}', '\u{A030}', '\u{A031}', '\u{A032}', '\u{A033}', '\u{A034}', '\u{A035}', '\u{A036}', '\u{A037}', '\u{A038}', '\u{A039}', '\u{A03A}', '\u{A03B}', '\u{A03C}', '\u{A03D}', '\u{A03E}', '\u{A03F}', '\u{A040}', '\u{A041}', '\u{A042}', '\u{A043}', '\u{A044}', '\u{A045}', '\u{A046}', '\u{A047}', '\u{A048}', '\u{A049}', '\u{A04A}', '\u{A04B}', '\u{A04C}', '\u{A04D}', '\u{A04E}', '\u{A04F}', '\u{A050}', '\u{A051}', '\u{A052}', '\u{A053}', '\u{A054}', '\u{A055}', '\u{A056}', '\u{A057}', '\u{A058}', '\u{A059}', '\u{A05A}', '\u{A05B}', '\u{A05C}', '\u{A05D}', '\u{A05E}', '\u{A05F}', '\u{A060}', '\u{A061}', '\u{A062}', '\u{A063}', '\u{A064}', '\u{A065}', '\u{A066}', '\u{A067}', '\u{A068}', '\u{A069}', '\u{A06A}', '\u{A06B}', '\u{A06C}', '\u{A06D}', '\u{A06E}', '\u{A06F}', '\u{A070}', '\u{A071}', '\u{A072}', '\u{A073}', '\u{A074}', '\u{A075}', '\u{A076}', '\u{A077}', '\u{A078}', '\u{A079}', '\u{A07A}', '\u{A07B}', '\u{A07C}', '\u{A07D}', '\u{A07E}', '\u{A07F}', '\u{A080}', '\u{A081}', '\u{A082}', '\u{A083}', '\u{A084}', '\u{A085}', '\u{A086}', '\u{A087}', '\u{A088}', '\u{A089}', '\u{A08A}', '\u{A08B}', '\u{A08C}', '\u{A08D}', '\u{A08E}', '\u{A08F}', '\u{A090}', '\u{A091}', '\u{A092}', '\u{A093}', '\u{A094}', '\u{A095}', '\u{A096}', '\u{A097}', '\u{A098}', '\u{A099}', '\u{A09A}', '\u{A09B}', '\u{A09C}', '\u{A09D}', '\u{A09E}', '\u{A09F}', '\u{A0A0}', '\u{A0A1}', '\u{A0A2}', '\u{A0A3}', '\u{A0A4}', '\u{A0A5}', '\u{A0A6}', '\u{A0A7}', '\u{A0A8}', '\u{A0A9}', '\u{A0AA}', '\u{A0AB}', '\u{A0AC}', '\u{A0AD}', '\u{A0AE}', '\u{A0AF}', '\u{A0B0}', '\u{A0B1}', '\u{A0B2}', '\u{A0B3}', '\u{A0B4}', '\u{A0B5}', '\u{A0B6}', '\u{A0B7}', '\u{A0B8}', '\u{A0B9}', '\u{A0BA}', '\u{A0BB}', '\u{A0BC}', '\u{A0BD}', '\u{A0BE}', '\u{A0BF}', '\u{A0C0}', '\u{A0C1}', '\u{A0C2}', '\u{A0C3}', '\u{A0C4}', '\u{A0C5}', '\u{A0C6}', '\u{A0C7}', '\u{A0C8}', '\u{A0C9}', '\u{A0CA}', '\u{A0CB}', '\u{A0CC}', '\u{A0CD}', '\u{A0CE}', '\u{A0CF}', '\u{A0D0}', '\u{A0D1}', '\u{A0D2}', '\u{A0D3}', '\u{A0D4}', '\u{A0D5}', '\u{A0D6}', '\u{A0D7}', '\u{A0D8}', '\u{A0D9}', '\u{A0DA}', '\u{A0DB}', '\u{A0DC}', '\u{A0DD}', '\u{A0DE}', '\u{A0DF}', '\u{A0E0}', '\u{A0E1}', '\u{A0E2}', '\u{A0E3}', '\u{A0E4}', '\u{A0E5}', '\u{A0E6}', '\u{A0E7}', '\u{A0E8}', '\u{A0E9}', '\u{A0EA}', '\u{A0EB}', '\u{A0EC}', '\u{A0ED}', '\u{A0EE}', '\u{A0EF}', '\u{A0F0}', '\u{A0F1}', '\u{A0F2}', '\u{A0F3}', '\u{A0F4}', '\u{A0F5}', '\u{A0F6}', '\u{A0F7}', '\u{A0F8}', '\u{A0F9}', '\u{A0FA}', '\u{A0FB}', '\u{A0FC}', '\u{A0FD}', '\u{A0FE}', '\u{A0FF}', '\u{A100}', '\u{A101}', '\u{A102}', '\u{A103}', '\u{A104}', '\u{A105}', '\u{A106}', '\u{A107}', '\u{A108}', '\u{A109}', '\u{A10A}', '\u{A10B}', '\u{A10C}', '\u{A10D}', '\u{A10E}', '\u{A10F}', '\u{A110}', '\u{A111}', '\u{A112}', '\u{A113}', '\u{A114}', '\u{A115}', '\u{A116}', '\u{A117}', '\u{A118}', '\u{A119}', '\u{A11A}', '\u{A11B}', '\u{A11C}', '\u{A11D}', '\u{A11E}', '\u{A11F}', '\u{A120}', '\u{A121}', '\u{A122}', '\u{A123}', '\u{A124}', '\u{A125}', '\u{A126}', '\u{A127}', '\u{A128}', '\u{A129}', '\u{A12A}', '\u{A12B}', '\u{A12C}', '\u{A12D}', '\u{A12E}', '\u{A12F}', '\u{A130}', '\u{A131}', '\u{A132}', '\u{A133}', '\u{A134}', '\u{A135}', '\u{A136}', '\u{A137}', '\u{A138}', '\u{A139}', '\u{A13A}', '\u{A13B}', '\u{A13C}', '\u{A13D}', '\u{A13E}', '\u{A13F}', '\u{A140}', '\u{A141}', '\u{A142}', '\u{A143}', '\u{A144}', '\u{A145}', '\u{A146}', '\u{A147}', '\u{A148}', '\u{A149}', '\u{A14A}', '\u{A14B}', '\u{A14C}', '\u{A14D}', '\u{A14E}', '\u{A14F}', '\u{A150}', '\u{A151}', '\u{A152}', '\u{A153}', '\u{A154}', '\u{A155}', '\u{A156}', '\u{A157}', '\u{A158}', '\u{A159}', '\u{A15A}', '\u{A15B}', '\u{A15C}', '\u{A15D}', '\u{A15E}', '\u{A15F}', '\u{A160}', '\u{A161}', '\u{A162}', '\u{A163}', '\u{A164}', '\u{A165}', '\u{A166}', '\u{A167}', '\u{A168}', '\u{A169}', '\u{A16A}', '\u{A16B}', '\u{A16C}', '\u{A16D}', '\u{A16E}', '\u{A16F}', '\u{A170}', '\u{A171}', '\u{A172}', '\u{A173}', '\u{A174}', '\u{A175}', '\u{A176}', '\u{A177}', '\u{A178}', '\u{A179}', '\u{A17A}', '\u{A17B}', '\u{A17C}', '\u{A17D}', '\u{A17E}', '\u{A17F}', '\u{A180}', '\u{A181}', '\u{A182}', '\u{A183}', '\u{A184}', '\u{A185}', '\u{A186}', '\u{A187}', '\u{A188}', '\u{A189}', '\u{A18A}', '\u{A18B}', '\u{A18C}', '\u{A18D}', '\u{A18E}', '\u{A18F}', '\u{A190}', '\u{A191}', '\u{A192}', '\u{A193}', '\u{A194}', '\u{A195}', '\u{A196}', '\u{A197}', '\u{A198}', '\u{A199}', '\u{A19A}', '\u{A19B}', '\u{A19C}', '\u{A19D}', '\u{A19E}', '\u{A19F}', '\u{A1A0}', '\u{A1A1}', '\u{A1A2}', '\u{A1A3}', '\u{A1A4}', '\u{A1A5}', '\u{A1A6}', '\u{A1A7}', '\u{A1A8}', '\u{A1A9}', '\u{A1AA}', '\u{A1AB}', '\u{A1AC}', '\u{A1AD}', '\u{A1AE}', '\u{A1AF}') - } - - fn is_unicode_letter_number(self) -> bool { - match_char_class!(self, - '\u{16EE}', '\u{16EF}', '\u{16F0}', '\u{2160}', '\u{2161}', '\u{2162}', '\u{2163}', '\u{2164}', '\u{2165}', '\u{2166}', '\u{2167}', '\u{2168}', '\u{2169}', '\u{216A}', '\u{216B}', '\u{216C}', '\u{216D}', '\u{216E}', '\u{216F}', '\u{2170}', '\u{2171}', '\u{2172}', '\u{2173}', '\u{2174}', '\u{2175}', '\u{2176}', '\u{2177}', '\u{2178}', '\u{2179}', '\u{217A}', '\u{217B}', '\u{217C}', '\u{217D}', '\u{217E}', '\u{217F}', '\u{2180}', '\u{2181}', '\u{2182}', '\u{2185}', '\u{2186}', '\u{2187}', '\u{2188}', '\u{3007}', '\u{3021}', '\u{3022}', '\u{3023}', '\u{3024}', '\u{3025}', '\u{3026}', '\u{3027}', '\u{3028}', '\u{3029}', '\u{3038}', '\u{3039}', '\u{303A}') - } - - fn is_unicode_nonspacing_mark(self) -> bool { - match_char_class!(self, - '\u{0300}', '\u{0301}', '\u{0302}', '\u{0303}', '\u{0304}', '\u{0305}', '\u{0306}', '\u{0307}', '\u{0308}', '\u{0309}', '\u{030A}', '\u{030B}', '\u{030C}', '\u{030D}', '\u{030E}', '\u{030F}', '\u{0310}', '\u{0311}', '\u{0312}', '\u{0313}', '\u{0314}', '\u{0315}', '\u{0316}', '\u{0317}', '\u{0318}', '\u{0319}', '\u{031A}', '\u{031B}', '\u{031C}', '\u{031D}', '\u{031E}', '\u{031F}', '\u{0320}', '\u{0321}', '\u{0322}', '\u{0323}', '\u{0324}', '\u{0325}', '\u{0326}', '\u{0327}', '\u{0328}', '\u{0329}', '\u{032A}', '\u{032B}', '\u{032C}', '\u{032D}', '\u{032E}', '\u{032F}', '\u{0330}', '\u{0331}', '\u{0332}', '\u{0333}', '\u{0334}', '\u{0335}', '\u{0336}', '\u{0337}', '\u{0338}', '\u{0339}', '\u{033A}', '\u{033B}', '\u{033C}', '\u{033D}', '\u{033E}', '\u{033F}', '\u{0340}', '\u{0341}', '\u{0342}', '\u{0343}', '\u{0344}', '\u{0345}', '\u{0346}', '\u{0347}', '\u{0348}', '\u{0349}', '\u{034A}', '\u{034B}', '\u{034C}', '\u{034D}', '\u{034E}', '\u{034F}', '\u{0350}', '\u{0351}', '\u{0352}', '\u{0353}', '\u{0354}', '\u{0355}', '\u{0356}', '\u{0357}', '\u{0358}', '\u{0359}', '\u{035A}', '\u{035B}', '\u{035C}', '\u{035D}', '\u{035E}', '\u{035F}', '\u{0360}', '\u{0361}', '\u{0362}', '\u{0363}', '\u{0364}', '\u{0365}', '\u{0366}', '\u{0367}', '\u{0368}', '\u{0369}', '\u{036A}', '\u{036B}', '\u{036C}', '\u{036D}', '\u{036E}', '\u{036F}', '\u{0483}', '\u{0484}', '\u{0485}', '\u{0486}', '\u{0487}', '\u{0591}', '\u{0592}', '\u{0593}', '\u{0594}', '\u{0595}', '\u{0596}', '\u{0597}', '\u{0598}', '\u{0599}', '\u{059A}', '\u{059B}', '\u{059C}', '\u{059D}', '\u{059E}', '\u{059F}', '\u{05A0}', '\u{05A1}', '\u{05A2}', '\u{05A3}', '\u{05A4}', '\u{05A5}', '\u{05A6}', '\u{05A7}', '\u{05A8}', '\u{05A9}', '\u{05AA}', '\u{05AB}', '\u{05AC}', '\u{05AD}', '\u{05AE}', '\u{05AF}', '\u{05B0}', '\u{05B1}', '\u{05B2}', '\u{05B3}', '\u{05B4}', '\u{05B5}', '\u{05B6}', '\u{05B7}', '\u{05B8}', '\u{05B9}', '\u{05BA}', '\u{05BB}', '\u{05BC}', '\u{05BD}', '\u{05BF}', '\u{05C1}', '\u{05C2}', '\u{05C4}', '\u{05C5}', '\u{05C7}', '\u{0610}', '\u{0611}', '\u{0612}', '\u{0613}', '\u{0614}', '\u{0615}', '\u{0616}', '\u{0617}', '\u{0618}', '\u{0619}', '\u{061A}', '\u{064B}', '\u{064C}', '\u{064D}', '\u{064E}', '\u{064F}', '\u{0650}', '\u{0651}', '\u{0652}', '\u{0653}', '\u{0654}', '\u{0655}', '\u{0656}', '\u{0657}', '\u{0658}', '\u{0659}', '\u{065A}', '\u{065B}', '\u{065C}', '\u{065D}', '\u{065E}', '\u{0670}', '\u{06D6}', '\u{06D7}', '\u{06D8}', '\u{06D9}', '\u{06DA}', '\u{06DB}', '\u{06DC}', '\u{06DF}', '\u{06E0}', '\u{06E1}', '\u{06E2}', '\u{06E3}', '\u{06E4}', '\u{06E7}', '\u{06E8}', '\u{06EA}', '\u{06EB}', '\u{06EC}', '\u{06ED}', '\u{0711}', '\u{0730}', '\u{0731}', '\u{0732}', '\u{0733}', '\u{0734}', '\u{0735}', '\u{0736}', '\u{0737}', '\u{0738}', '\u{0739}', '\u{073A}', '\u{073B}', '\u{073C}', '\u{073D}', '\u{073E}', '\u{073F}', '\u{0740}', '\u{0741}', '\u{0742}', '\u{0743}', '\u{0744}', '\u{0745}', '\u{0746}', '\u{0747}', '\u{0748}', '\u{0749}', '\u{074A}', '\u{07A6}', '\u{07A7}', '\u{07A8}', '\u{07A9}', '\u{07AA}', '\u{07AB}', '\u{07AC}', '\u{07AD}', '\u{07AE}', '\u{07AF}', '\u{07B0}', '\u{07EB}', '\u{07EC}', '\u{07ED}', '\u{07EE}', '\u{07EF}', '\u{07F0}', '\u{07F1}', '\u{07F2}', '\u{07F3}', '\u{0901}', '\u{0902}', '\u{093C}', '\u{0941}', '\u{0942}', '\u{0943}', '\u{0944}', '\u{0945}', '\u{0946}', '\u{0947}', '\u{0948}', '\u{094D}', '\u{0951}', '\u{0952}', '\u{0953}', '\u{0954}', '\u{0962}', '\u{0963}', '\u{0981}', '\u{09BC}', '\u{09C1}', '\u{09C2}', '\u{09C3}', '\u{09C4}', '\u{09CD}', '\u{09E2}', '\u{09E3}', '\u{0A01}', '\u{0A02}', '\u{0A3C}', '\u{0A41}', '\u{0A42}', '\u{0A47}', '\u{0A48}', '\u{0A4B}', '\u{0A4C}', '\u{0A4D}', '\u{0A51}', '\u{0A70}', '\u{0A71}', '\u{0A75}', '\u{0A81}', '\u{0A82}', '\u{0ABC}', '\u{0AC1}', '\u{0AC2}', '\u{0AC3}', '\u{0AC4}', '\u{0AC5}', '\u{0AC7}', '\u{0AC8}', '\u{0ACD}', '\u{0AE2}', '\u{0AE3}', '\u{0B01}', '\u{0B3C}', '\u{0B3F}', '\u{0B41}', '\u{0B42}', '\u{0B43}', '\u{0B44}', '\u{0B4D}', '\u{0B56}', '\u{0B62}', '\u{0B63}', '\u{0B82}', '\u{0BC0}', '\u{0BCD}', '\u{0C3E}', '\u{0C3F}', '\u{0C40}', '\u{0C46}', '\u{0C47}', '\u{0C48}', '\u{0C4A}', '\u{0C4B}', '\u{0C4C}', '\u{0C4D}', '\u{0C55}', '\u{0C56}', '\u{0C62}', '\u{0C63}', '\u{0CBC}', '\u{0CBF}', '\u{0CC6}', '\u{0CCC}', '\u{0CCD}', '\u{0CE2}', '\u{0CE3}', '\u{0D41}', '\u{0D42}', '\u{0D43}', '\u{0D44}', '\u{0D4D}', '\u{0D62}', '\u{0D63}', '\u{0DCA}', '\u{0DD2}', '\u{0DD3}', '\u{0DD4}', '\u{0DD6}', '\u{0E31}', '\u{0E34}', '\u{0E35}', '\u{0E36}', '\u{0E37}', '\u{0E38}', '\u{0E39}', '\u{0E3A}', '\u{0E47}', '\u{0E48}', '\u{0E49}', '\u{0E4A}', '\u{0E4B}', '\u{0E4C}', '\u{0E4D}', '\u{0E4E}', '\u{0EB1}', '\u{0EB4}', '\u{0EB5}', '\u{0EB6}', '\u{0EB7}', '\u{0EB8}', '\u{0EB9}', '\u{0EBB}', '\u{0EBC}', '\u{0EC8}', '\u{0EC9}', '\u{0ECA}', '\u{0ECB}', '\u{0ECC}', '\u{0ECD}', '\u{0F18}', '\u{0F19}', '\u{0F35}', '\u{0F37}', '\u{0F39}', '\u{0F71}', '\u{0F72}', '\u{0F73}', '\u{0F74}', '\u{0F75}', '\u{0F76}', '\u{0F77}', '\u{0F78}', '\u{0F79}', '\u{0F7A}', '\u{0F7B}', '\u{0F7C}', '\u{0F7D}', '\u{0F7E}', '\u{0F80}', '\u{0F81}', '\u{0F82}', '\u{0F83}', '\u{0F84}', '\u{0F86}', '\u{0F87}', '\u{0F90}', '\u{0F91}', '\u{0F92}', '\u{0F93}', '\u{0F94}', '\u{0F95}', '\u{0F96}', '\u{0F97}', '\u{0F99}', '\u{0F9A}', '\u{0F9B}', '\u{0F9C}', '\u{0F9D}', '\u{0F9E}', '\u{0F9F}', '\u{0FA0}', '\u{0FA1}', '\u{0FA2}', '\u{0FA3}', '\u{0FA4}', '\u{0FA5}', '\u{0FA6}', '\u{0FA7}', '\u{0FA8}', '\u{0FA9}', '\u{0FAA}', '\u{0FAB}', '\u{0FAC}', '\u{0FAD}', '\u{0FAE}', '\u{0FAF}', '\u{0FB0}', '\u{0FB1}', '\u{0FB2}', '\u{0FB3}', '\u{0FB4}', '\u{0FB5}', '\u{0FB6}', '\u{0FB7}', '\u{0FB8}', '\u{0FB9}', '\u{0FBA}', '\u{0FBB}', '\u{0FBC}', '\u{0FC6}', '\u{102D}', '\u{102E}', '\u{102F}', '\u{1030}', '\u{1032}', '\u{1033}', '\u{1034}', '\u{1035}', '\u{1036}', '\u{1037}', '\u{1039}', '\u{103A}', '\u{103D}', '\u{103E}', '\u{1058}', '\u{1059}', '\u{105E}', '\u{105F}', '\u{1060}', '\u{1071}', '\u{1072}', '\u{1073}', '\u{1074}', '\u{1082}', '\u{1085}', '\u{1086}', '\u{108D}', '\u{135F}', '\u{1712}', '\u{1713}', '\u{1714}', '\u{1732}', '\u{1733}', '\u{1734}', '\u{1752}', '\u{1753}', '\u{1772}', '\u{1773}', '\u{17B7}', '\u{17B8}', '\u{17B9}', '\u{17BA}', '\u{17BB}', '\u{17BC}', '\u{17BD}', '\u{17C6}', '\u{17C9}', '\u{17CA}', '\u{17CB}', '\u{17CC}', '\u{17CD}', '\u{17CE}', '\u{17CF}', '\u{17D0}', '\u{17D1}', '\u{17D2}', '\u{17D3}', '\u{17DD}', '\u{180B}', '\u{180C}', '\u{180D}', '\u{18A9}', '\u{1920}', '\u{1921}', '\u{1922}', '\u{1927}', '\u{1928}', '\u{1932}', '\u{1939}', '\u{193A}', '\u{193B}', '\u{1A17}', '\u{1A18}', '\u{1B00}', '\u{1B01}', '\u{1B02}', '\u{1B03}', '\u{1B34}', '\u{1B36}', '\u{1B37}', '\u{1B38}', '\u{1B39}', '\u{1B3A}', '\u{1B3C}', '\u{1B42}', '\u{1B6B}', '\u{1B6C}', '\u{1B6D}', '\u{1B6E}', '\u{1B6F}', '\u{1B70}', '\u{1B71}', '\u{1B72}', '\u{1B73}', '\u{1B80}', '\u{1B81}', '\u{1BA2}', '\u{1BA3}', '\u{1BA4}', '\u{1BA5}', '\u{1BA8}', '\u{1BA9}', '\u{1C2C}', '\u{1C2D}', '\u{1C2E}', '\u{1C2F}', '\u{1C30}', '\u{1C31}', '\u{1C32}', '\u{1C33}', '\u{1C36}', '\u{1C37}', '\u{1DC0}', '\u{1DC1}', '\u{1DC2}', '\u{1DC3}', '\u{1DC4}', '\u{1DC5}', '\u{1DC6}', '\u{1DC7}', '\u{1DC8}', '\u{1DC9}', '\u{1DCA}', '\u{1DCB}', '\u{1DCC}', '\u{1DCD}', '\u{1DCE}', '\u{1DCF}', '\u{1DD0}', '\u{1DD1}', '\u{1DD2}', '\u{1DD3}', '\u{1DD4}', '\u{1DD5}', '\u{1DD6}', '\u{1DD7}', '\u{1DD8}', '\u{1DD9}', '\u{1DDA}', '\u{1DDB}', '\u{1DDC}', '\u{1DDD}', '\u{1DDE}', '\u{1DDF}', '\u{1DE0}', '\u{1DE1}', '\u{1DE2}', '\u{1DE3}', '\u{1DE4}', '\u{1DE5}', '\u{1DE6}', '\u{1DFE}', '\u{1DFF}', '\u{20D0}', '\u{20D1}', '\u{20D2}', '\u{20D3}', '\u{20D4}', '\u{20D5}', '\u{20D6}', '\u{20D7}', '\u{20D8}', '\u{20D9}', '\u{20DA}', '\u{20DB}', '\u{20DC}', '\u{20E1}', '\u{20E5}', '\u{20E6}', '\u{20E7}', '\u{20E8}', '\u{20E9}', '\u{20EA}', '\u{20EB}', '\u{20EC}', '\u{20ED}', '\u{20EE}', '\u{20EF}', '\u{20F0}', '\u{2DE0}', '\u{2DE1}', '\u{2DE2}', '\u{2DE3}', '\u{2DE4}', '\u{2DE5}', '\u{2DE6}', '\u{2DE7}', '\u{2DE8}', '\u{2DE9}', '\u{2DEA}', '\u{2DEB}', '\u{2DEC}', '\u{2DED}', '\u{2DEE}', '\u{2DEF}', '\u{2DF0}', '\u{2DF1}', '\u{2DF2}', '\u{2DF3}', '\u{2DF4}', '\u{2DF5}', '\u{2DF6}', '\u{2DF7}', '\u{2DF8}', '\u{2DF9}', '\u{2DFA}', '\u{2DFB}', '\u{2DFC}', '\u{2DFD}', '\u{2DFE}', '\u{2DFF}', '\u{302A}', '\u{302B}', '\u{302C}', '\u{302D}', '\u{302E}', '\u{302F}', '\u{3099}', '\u{309A}', '\u{A66F}', '\u{A67C}', '\u{A67D}', '\u{A802}', '\u{A806}', '\u{A80B}', '\u{A825}', '\u{A826}', '\u{A8C4}', '\u{A926}', '\u{A927}', '\u{A928}', '\u{A929}', '\u{A92A}', '\u{A92B}', '\u{A92C}', '\u{A92D}', '\u{A947}', '\u{A948}', '\u{A949}', '\u{A94A}', '\u{A94B}', '\u{A94C}', '\u{A94D}', '\u{A94E}', '\u{A94F}', '\u{A950}', '\u{A951}', '\u{AA29}', '\u{AA2A}', '\u{AA2B}', '\u{AA2C}', '\u{AA2D}', '\u{AA2E}', '\u{AA31}', '\u{AA32}', '\u{AA35}', '\u{AA36}', '\u{AA43}', '\u{AA4C}', '\u{FB1E}', '\u{FE00}', '\u{FE01}', '\u{FE02}', '\u{FE03}', '\u{FE04}', '\u{FE05}', '\u{FE06}', '\u{FE07}', '\u{FE08}', '\u{FE09}', '\u{FE0A}', '\u{FE0B}', '\u{FE0C}', '\u{FE0D}', '\u{FE0E}', '\u{FE0F}', '\u{FE20}', '\u{FE21}', '\u{FE22}', '\u{FE23}', '\u{FE24}', '\u{FE25}', '\u{FE26}', '\u{01BB}', '\u{01C0}', '\u{01C1}', '\u{01C2}', '\u{01C3}', '\u{0294}', '\u{05D0}', '\u{05D1}', '\u{05D2}', '\u{05D3}', '\u{05D4}', '\u{05D5}', '\u{05D6}', '\u{05D7}', '\u{05D8}', '\u{05D9}', '\u{05DA}', '\u{05DB}', '\u{05DC}', '\u{05DD}', '\u{05DE}', '\u{05DF}', '\u{05E0}', '\u{05E1}', '\u{05E2}', '\u{05E3}', '\u{05E4}', '\u{05E5}', '\u{05E6}', '\u{05E7}', '\u{05E8}', '\u{05E9}', '\u{05EA}', '\u{05F0}', '\u{05F1}', '\u{05F2}', '\u{0621}', '\u{0622}', '\u{0623}', '\u{0624}', '\u{0625}', '\u{0626}', '\u{0627}', '\u{0628}', '\u{0629}', '\u{062A}', '\u{062B}', '\u{062C}', '\u{062D}', '\u{062E}', '\u{062F}', '\u{0630}', '\u{0631}', '\u{0632}', '\u{0633}', '\u{0634}', '\u{0635}', '\u{0636}', '\u{0637}', '\u{0638}', '\u{0639}', '\u{063A}', '\u{063B}', '\u{063C}', '\u{063D}', '\u{063E}', '\u{063F}', '\u{0641}', '\u{0642}', '\u{0643}', '\u{0644}', '\u{0645}', '\u{0646}', '\u{0647}', '\u{0648}', '\u{0649}', '\u{064A}', '\u{066E}', '\u{066F}', '\u{0671}', '\u{0672}', '\u{0673}', '\u{0674}', '\u{0675}', '\u{0676}', '\u{0677}', '\u{0678}', '\u{0679}', '\u{067A}', '\u{067B}', '\u{067C}', '\u{067D}', '\u{067E}', '\u{067F}', '\u{0680}', '\u{0681}', '\u{0682}', '\u{0683}', '\u{0684}', '\u{0685}', '\u{0686}', '\u{0687}', '\u{0688}', '\u{0689}', '\u{068A}', '\u{068B}', '\u{068C}', '\u{068D}', '\u{068E}', '\u{068F}', '\u{0690}', '\u{0691}', '\u{0692}', '\u{0693}', '\u{0694}', '\u{0695}', '\u{0696}', '\u{0697}', '\u{0698}', '\u{0699}', '\u{069A}', '\u{069B}', '\u{069C}', '\u{069D}', '\u{069E}', '\u{069F}', '\u{06A0}', '\u{06A1}', '\u{06A2}', '\u{06A3}', '\u{06A4}', '\u{06A5}', '\u{06A6}', '\u{06A7}', '\u{06A8}', '\u{06A9}', '\u{06AA}', '\u{06AB}', '\u{06AC}', '\u{06AD}', '\u{06AE}', '\u{06AF}', '\u{06B0}', '\u{06B1}', '\u{06B2}', '\u{06B3}', '\u{06B4}', '\u{06B5}', '\u{06B6}', '\u{06B7}', '\u{06B8}', '\u{06B9}', '\u{06BA}', '\u{06BB}', '\u{06BC}', '\u{06BD}', '\u{06BE}', '\u{06BF}', '\u{06C0}', '\u{06C1}', '\u{06C2}', '\u{06C3}', '\u{06C4}', '\u{06C5}', '\u{06C6}', '\u{06C7}', '\u{06C8}', '\u{06C9}', '\u{06CA}', '\u{06CB}', '\u{06CC}', '\u{06CD}', '\u{06CE}', '\u{06CF}', '\u{06D0}', '\u{06D1}', '\u{06D2}', '\u{06D3}', '\u{06D5}', '\u{06EE}', '\u{06EF}', '\u{06FA}', '\u{06FB}', '\u{06FC}', '\u{06FF}', '\u{0710}', '\u{0712}', '\u{0713}', '\u{0714}', '\u{0715}', '\u{0716}', '\u{0717}', '\u{0718}', '\u{0719}', '\u{071A}', '\u{071B}', '\u{071C}', '\u{071D}', '\u{071E}', '\u{071F}', '\u{0720}', '\u{0721}', '\u{0722}', '\u{0723}', '\u{0724}', '\u{0725}', '\u{0726}', '\u{0727}', '\u{0728}', '\u{0729}', '\u{072A}', '\u{072B}', '\u{072C}', '\u{072D}', '\u{072E}', '\u{072F}', '\u{074D}', '\u{074E}', '\u{074F}', '\u{0750}', '\u{0751}', '\u{0752}', '\u{0753}', '\u{0754}', '\u{0755}', '\u{0756}', '\u{0757}', '\u{0758}', '\u{0759}', '\u{075A}', '\u{075B}', '\u{075C}', '\u{075D}', '\u{075E}', '\u{075F}', '\u{0760}', '\u{0761}', '\u{0762}', '\u{0763}', '\u{0764}', '\u{0765}', '\u{0766}', '\u{0767}', '\u{0768}', '\u{0769}', '\u{076A}', '\u{076B}', '\u{076C}', '\u{076D}', '\u{076E}', '\u{076F}', '\u{0770}', '\u{0771}', '\u{0772}', '\u{0773}', '\u{0774}', '\u{0775}', '\u{0776}', '\u{0777}', '\u{0778}', '\u{0779}', '\u{077A}', '\u{077B}', '\u{077C}', '\u{077D}', '\u{077E}', '\u{077F}', '\u{0780}', '\u{0781}', '\u{0782}', '\u{0783}', '\u{0784}', '\u{0785}', '\u{0786}', '\u{0787}', '\u{0788}', '\u{0789}', '\u{078A}', '\u{078B}', '\u{078C}', '\u{078D}', '\u{078E}', '\u{078F}', '\u{0790}', '\u{0791}', '\u{0792}', '\u{0793}', '\u{0794}', '\u{0795}', '\u{0796}', '\u{0797}', '\u{0798}', '\u{0799}', '\u{079A}', '\u{079B}', '\u{079C}', '\u{079D}', '\u{079E}', '\u{079F}', '\u{07A0}', '\u{07A1}', '\u{07A2}', '\u{07A3}', '\u{07A4}', '\u{07A5}', '\u{07B1}', '\u{07CA}', '\u{07CB}', '\u{07CC}', '\u{07CD}', '\u{07CE}', '\u{07CF}', '\u{07D0}', '\u{07D1}', '\u{07D2}', '\u{07D3}', '\u{07D4}', '\u{07D5}', '\u{07D6}', '\u{07D7}', '\u{07D8}', '\u{07D9}', '\u{07DA}', '\u{07DB}', '\u{07DC}', '\u{07DD}', '\u{07DE}', '\u{07DF}', '\u{07E0}', '\u{07E1}', '\u{07E2}', '\u{07E3}', '\u{07E4}', '\u{07E5}', '\u{07E6}', '\u{07E7}', '\u{07E8}', '\u{07E9}', '\u{07EA}', '\u{0904}', '\u{0905}', '\u{0906}', '\u{0907}', '\u{0908}', '\u{0909}', '\u{090A}', '\u{090B}', '\u{090C}', '\u{090D}', '\u{090E}', '\u{090F}', '\u{0910}', '\u{0911}', '\u{0912}', '\u{0913}', '\u{0914}', '\u{0915}', '\u{0916}', '\u{0917}', '\u{0918}', '\u{0919}', '\u{091A}', '\u{091B}', '\u{091C}', '\u{091D}', '\u{091E}', '\u{091F}', '\u{0920}', '\u{0921}', '\u{0922}', '\u{0923}', '\u{0924}', '\u{0925}', '\u{0926}', '\u{0927}', '\u{0928}', '\u{0929}', '\u{092A}', '\u{092B}', '\u{092C}', '\u{092D}', '\u{092E}', '\u{092F}', '\u{0930}', '\u{0931}', '\u{0932}', '\u{0933}', '\u{0934}', '\u{0935}', '\u{0936}', '\u{0937}', '\u{0938}', '\u{0939}', '\u{093D}', '\u{0950}', '\u{0958}', '\u{0959}', '\u{095A}', '\u{095B}', '\u{095C}', '\u{095D}', '\u{095E}', '\u{095F}', '\u{0960}', '\u{0961}', '\u{0972}', '\u{097B}', '\u{097C}', '\u{097D}', '\u{097E}', '\u{097F}', '\u{0985}', '\u{0986}', '\u{0987}', '\u{0988}', '\u{0989}', '\u{098A}', '\u{098B}', '\u{098C}', '\u{098F}', '\u{0990}', '\u{0993}', '\u{0994}', '\u{0995}', '\u{0996}', '\u{0997}', '\u{0998}', '\u{0999}', '\u{099A}', '\u{099B}', '\u{099C}', '\u{099D}', '\u{099E}', '\u{099F}', '\u{09A0}', '\u{09A1}', '\u{09A2}', '\u{09A3}', '\u{09A4}', '\u{09A5}', '\u{09A6}', '\u{09A7}', '\u{09A8}', '\u{09AA}', '\u{09AB}', '\u{09AC}', '\u{09AD}', '\u{09AE}', '\u{09AF}', '\u{09B0}', '\u{09B2}', '\u{09B6}', '\u{09B7}', '\u{09B8}', '\u{09B9}', '\u{09BD}', '\u{09CE}', '\u{09DC}', '\u{09DD}', '\u{09DF}', '\u{09E0}', '\u{09E1}', '\u{09F0}', '\u{09F1}', '\u{0A05}', '\u{0A06}', '\u{0A07}', '\u{0A08}', '\u{0A09}', '\u{0A0A}', '\u{0A0F}', '\u{0A10}', '\u{0A13}', '\u{0A14}', '\u{0A15}', '\u{0A16}', '\u{0A17}', '\u{0A18}', '\u{0A19}', '\u{0A1A}', '\u{0A1B}', '\u{0A1C}', '\u{0A1D}', '\u{0A1E}', '\u{0A1F}', '\u{0A20}', '\u{0A21}', '\u{0A22}', '\u{0A23}', '\u{0A24}', '\u{0A25}', '\u{0A26}', '\u{0A27}', '\u{0A28}', '\u{0A2A}', '\u{0A2B}', '\u{0A2C}', '\u{0A2D}', '\u{0A2E}', '\u{0A2F}', '\u{0A30}', '\u{0A32}', '\u{0A33}', '\u{0A35}', '\u{0A36}', '\u{0A38}', '\u{0A39}', '\u{0A59}', '\u{0A5A}', '\u{0A5B}', '\u{0A5C}', '\u{0A5E}', '\u{0A72}', '\u{0A73}', '\u{0A74}', '\u{0A85}', '\u{0A86}', '\u{0A87}', '\u{0A88}', '\u{0A89}', '\u{0A8A}', '\u{0A8B}', '\u{0A8C}', '\u{0A8D}', '\u{0A8F}', '\u{0A90}', '\u{0A91}', '\u{0A93}', '\u{0A94}', '\u{0A95}', '\u{0A96}', '\u{0A97}', '\u{0A98}', '\u{0A99}', '\u{0A9A}', '\u{0A9B}', '\u{0A9C}', '\u{0A9D}', '\u{0A9E}', '\u{0A9F}', '\u{0AA0}', '\u{0AA1}', '\u{0AA2}', '\u{0AA3}', '\u{0AA4}', '\u{0AA5}', '\u{0AA6}', '\u{0AA7}', '\u{0AA8}', '\u{0AAA}', '\u{0AAB}', '\u{0AAC}', '\u{0AAD}', '\u{0AAE}', '\u{0AAF}', '\u{0AB0}', '\u{0AB2}', '\u{0AB3}', '\u{0AB5}', '\u{0AB6}', '\u{0AB7}', '\u{0AB8}', '\u{0AB9}', '\u{0ABD}', '\u{0AD0}', '\u{0AE0}', '\u{0AE1}', '\u{0B05}', '\u{0B06}', '\u{0B07}', '\u{0B08}', '\u{0B09}', '\u{0B0A}', '\u{0B0B}', '\u{0B0C}', '\u{0B0F}', '\u{0B10}', '\u{0B13}', '\u{0B14}', '\u{0B15}', '\u{0B16}', '\u{0B17}', '\u{0B18}', '\u{0B19}', '\u{0B1A}', '\u{0B1B}', '\u{0B1C}', '\u{0B1D}', '\u{0B1E}', '\u{0B1F}', '\u{0B20}', '\u{0B21}', '\u{0B22}', '\u{0B23}', '\u{0B24}', '\u{0B25}', '\u{0B26}', '\u{0B27}', '\u{0B28}', '\u{0B2A}', '\u{0B2B}', '\u{0B2C}', '\u{0B2D}', '\u{0B2E}', '\u{0B2F}', '\u{0B30}', '\u{0B32}', '\u{0B33}', '\u{0B35}', '\u{0B36}', '\u{0B37}', '\u{0B38}', '\u{0B39}', '\u{0B3D}', '\u{0B5C}', '\u{0B5D}', '\u{0B5F}', '\u{0B60}', '\u{0B61}', '\u{0B71}', '\u{0B83}', '\u{0B85}', '\u{0B86}', '\u{0B87}', '\u{0B88}', '\u{0B89}', '\u{0B8A}', '\u{0B8E}', '\u{0B8F}', '\u{0B90}', '\u{0B92}', '\u{0B93}', '\u{0B94}', '\u{0B95}', '\u{0B99}', '\u{0B9A}', '\u{0B9C}', '\u{0B9E}', '\u{0B9F}', '\u{0BA3}', '\u{0BA4}', '\u{0BA8}', '\u{0BA9}', '\u{0BAA}', '\u{0BAE}', '\u{0BAF}', '\u{0BB0}', '\u{0BB1}', '\u{0BB2}', '\u{0BB3}', '\u{0BB4}', '\u{0BB5}', '\u{0BB6}', '\u{0BB7}', '\u{0BB8}', '\u{0BB9}', '\u{0BD0}', '\u{0C05}', '\u{0C06}', '\u{0C07}', '\u{0C08}', '\u{0C09}', '\u{0C0A}', '\u{0C0B}', '\u{0C0C}', '\u{0C0E}', '\u{0C0F}', '\u{0C10}', '\u{0C12}', '\u{0C13}', '\u{0C14}', '\u{0C15}', '\u{0C16}', '\u{0C17}', '\u{0C18}', '\u{0C19}', '\u{0C1A}', '\u{0C1B}', '\u{0C1C}', '\u{0C1D}', '\u{0C1E}', '\u{0C1F}', '\u{0C20}', '\u{0C21}', '\u{0C22}', '\u{0C23}', '\u{0C24}', '\u{0C25}', '\u{0C26}', '\u{0C27}', '\u{0C28}', '\u{0C2A}', '\u{0C2B}', '\u{0C2C}', '\u{0C2D}', '\u{0C2E}', '\u{0C2F}', '\u{0C30}', '\u{0C31}', '\u{0C32}', '\u{0C33}', '\u{0C35}', '\u{0C36}', '\u{0C37}', '\u{0C38}', '\u{0C39}', '\u{0C3D}', '\u{0C58}', '\u{0C59}', '\u{0C60}', '\u{0C61}', '\u{0C85}', '\u{0C86}', '\u{0C87}', '\u{0C88}', '\u{0C89}', '\u{0C8A}', '\u{0C8B}', '\u{0C8C}', '\u{0C8E}', '\u{0C8F}', '\u{0C90}', '\u{0C92}', '\u{0C93}', '\u{0C94}', '\u{0C95}', '\u{0C96}', '\u{0C97}', '\u{0C98}', '\u{0C99}', '\u{0C9A}', '\u{0C9B}', '\u{0C9C}', '\u{0C9D}', '\u{0C9E}', '\u{0C9F}', '\u{0CA0}', '\u{0CA1}', '\u{0CA2}', '\u{0CA3}', '\u{0CA4}', '\u{0CA5}', '\u{0CA6}', '\u{0CA7}', '\u{0CA8}', '\u{0CAA}', '\u{0CAB}', '\u{0CAC}', '\u{0CAD}', '\u{0CAE}', '\u{0CAF}', '\u{0CB0}', '\u{0CB1}', '\u{0CB2}', '\u{0CB3}', '\u{0CB5}', '\u{0CB6}', '\u{0CB7}', '\u{0CB8}', '\u{0CB9}', '\u{0CBD}', '\u{0CDE}', '\u{0CE0}', '\u{0CE1}', '\u{0D05}', '\u{0D06}', '\u{0D07}', '\u{0D08}', '\u{0D09}', '\u{0D0A}', '\u{0D0B}', '\u{0D0C}', '\u{0D0E}', '\u{0D0F}', '\u{0D10}', '\u{0D12}', '\u{0D13}', '\u{0D14}', '\u{0D15}', '\u{0D16}', '\u{0D17}', '\u{0D18}', '\u{0D19}', '\u{0D1A}', '\u{0D1B}', '\u{0D1C}', '\u{0D1D}', '\u{0D1E}', '\u{0D1F}', '\u{0D20}', '\u{0D21}', '\u{0D22}', '\u{0D23}', '\u{0D24}', '\u{0D25}', '\u{0D26}', '\u{0D27}', '\u{0D28}', '\u{0D2A}', '\u{0D2B}', '\u{0D2C}', '\u{0D2D}', '\u{0D2E}', '\u{0D2F}', '\u{0D30}', '\u{0D31}', '\u{0D32}', '\u{0D33}', '\u{0D34}', '\u{0D35}', '\u{0D36}', '\u{0D37}', '\u{0D38}', '\u{0D39}', '\u{0D3D}', '\u{0D60}', '\u{0D61}', '\u{0D7A}', '\u{0D7B}', '\u{0D7C}', '\u{0D7D}', '\u{0D7E}', '\u{0D7F}', '\u{0D85}', '\u{0D86}', '\u{0D87}', '\u{0D88}', '\u{0D89}', '\u{0D8A}', '\u{0D8B}', '\u{0D8C}', '\u{0D8D}', '\u{0D8E}', '\u{0D8F}', '\u{0D90}', '\u{0D91}', '\u{0D92}', '\u{0D93}', '\u{0D94}', '\u{0D95}', '\u{0D96}', '\u{0D9A}', '\u{0D9B}', '\u{0D9C}', '\u{0D9D}', '\u{0D9E}', '\u{0D9F}', '\u{0DA0}', '\u{0DA1}', '\u{0DA2}', '\u{0DA3}', '\u{0DA4}', '\u{0DA5}', '\u{0DA6}', '\u{0DA7}', '\u{0DA8}', '\u{0DA9}', '\u{0DAA}', '\u{0DAB}', '\u{0DAC}', '\u{0DAD}', '\u{0DAE}', '\u{0DAF}', '\u{0DB0}', '\u{0DB1}', '\u{0DB3}', '\u{0DB4}', '\u{0DB5}', '\u{0DB6}', '\u{0DB7}', '\u{0DB8}', '\u{0DB9}', '\u{0DBA}', '\u{0DBB}', '\u{0DBD}', '\u{0DC0}', '\u{0DC1}', '\u{0DC2}', '\u{0DC3}', '\u{0DC4}', '\u{0DC5}', '\u{0DC6}', '\u{0E01}', '\u{0E02}', '\u{0E03}', '\u{0E04}', '\u{0E05}', '\u{0E06}', '\u{0E07}', '\u{0E08}', '\u{0E09}', '\u{0E0A}', '\u{0E0B}', '\u{0E0C}', '\u{0E0D}', '\u{0E0E}', '\u{0E0F}', '\u{0E10}', '\u{0E11}', '\u{0E12}', '\u{0E13}', '\u{0E14}', '\u{0E15}', '\u{0E16}', '\u{0E17}', '\u{0E18}', '\u{0E19}', '\u{0E1A}', '\u{0E1B}', '\u{0E1C}', '\u{0E1D}', '\u{0E1E}', '\u{0E1F}', '\u{0E20}', '\u{0E21}', '\u{0E22}', '\u{0E23}', '\u{0E24}', '\u{0E25}', '\u{0E26}', '\u{0E27}', '\u{0E28}', '\u{0E29}', '\u{0E2A}', '\u{0E2B}', '\u{0E2C}', '\u{0E2D}', '\u{0E2E}', '\u{0E2F}', '\u{0E30}', '\u{0E32}', '\u{0E33}', '\u{0E40}', '\u{0E41}', '\u{0E42}', '\u{0E43}', '\u{0E44}', '\u{0E45}', '\u{0E81}', '\u{0E82}', '\u{0E84}', '\u{0E87}', '\u{0E88}', '\u{0E8A}', '\u{0E8D}', '\u{0E94}', '\u{0E95}', '\u{0E96}', '\u{0E97}', '\u{0E99}', '\u{0E9A}', '\u{0E9B}', '\u{0E9C}', '\u{0E9D}', '\u{0E9E}', '\u{0E9F}', '\u{0EA1}', '\u{0EA2}', '\u{0EA3}', '\u{0EA5}', '\u{0EA7}', '\u{0EAA}', '\u{0EAB}', '\u{0EAD}', '\u{0EAE}', '\u{0EAF}', '\u{0EB0}', '\u{0EB2}', '\u{0EB3}', '\u{0EBD}', '\u{0EC0}', '\u{0EC1}', '\u{0EC2}', '\u{0EC3}', '\u{0EC4}', '\u{0EDC}', '\u{0EDD}', '\u{0F00}', '\u{0F40}', '\u{0F41}', '\u{0F42}', '\u{0F43}', '\u{0F44}', '\u{0F45}', '\u{0F46}', '\u{0F47}', '\u{0F49}', '\u{0F4A}', '\u{0F4B}', '\u{0F4C}', '\u{0F4D}', '\u{0F4E}', '\u{0F4F}', '\u{0F50}', '\u{0F51}', '\u{0F52}', '\u{0F53}', '\u{0F54}', '\u{0F55}', '\u{0F56}', '\u{0F57}', '\u{0F58}', '\u{0F59}', '\u{0F5A}', '\u{0F5B}', '\u{0F5C}', '\u{0F5D}', '\u{0F5E}', '\u{0F5F}', '\u{0F60}', '\u{0F61}', '\u{0F62}', '\u{0F63}', '\u{0F64}', '\u{0F65}', '\u{0F66}', '\u{0F67}', '\u{0F68}', '\u{0F69}', '\u{0F6A}', '\u{0F6B}', '\u{0F6C}', '\u{0F88}', '\u{0F89}', '\u{0F8A}', '\u{0F8B}', '\u{1000}', '\u{1001}', '\u{1002}', '\u{1003}', '\u{1004}', '\u{1005}', '\u{1006}', '\u{1007}', '\u{1008}', '\u{1009}', '\u{100A}', '\u{100B}', '\u{100C}', '\u{100D}', '\u{100E}', '\u{100F}', '\u{1010}', '\u{1011}', '\u{1012}', '\u{1013}', '\u{1014}', '\u{1015}', '\u{1016}', '\u{1017}', '\u{1018}', '\u{1019}', '\u{101A}', '\u{101B}', '\u{101C}', '\u{101D}', '\u{101E}', '\u{101F}', '\u{1020}', '\u{1021}', '\u{1022}', '\u{1023}', '\u{1024}', '\u{1025}', '\u{1026}', '\u{1027}', '\u{1028}', '\u{1029}', '\u{102A}', '\u{103F}', '\u{1050}', '\u{1051}', '\u{1052}', '\u{1053}', '\u{1054}', '\u{1055}', '\u{105A}', '\u{105B}', '\u{105C}', '\u{105D}', '\u{1061}', '\u{1065}', '\u{1066}', '\u{106E}', '\u{106F}', '\u{1070}', '\u{1075}', '\u{1076}', '\u{1077}', '\u{1078}', '\u{1079}', '\u{107A}', '\u{107B}', '\u{107C}', '\u{107D}', '\u{107E}', '\u{107F}', '\u{1080}', '\u{1081}', '\u{108E}', '\u{10D0}', '\u{10D1}', '\u{10D2}', '\u{10D3}', '\u{10D4}', '\u{10D5}', '\u{10D6}', '\u{10D7}', '\u{10D8}', '\u{10D9}', '\u{10DA}', '\u{10DB}', '\u{10DC}', '\u{10DD}', '\u{10DE}', '\u{10DF}', '\u{10E0}', '\u{10E1}', '\u{10E2}', '\u{10E3}', '\u{10E4}', '\u{10E5}', '\u{10E6}', '\u{10E7}', '\u{10E8}', '\u{10E9}', '\u{10EA}', '\u{10EB}', '\u{10EC}', '\u{10ED}', '\u{10EE}', '\u{10EF}', '\u{10F0}', '\u{10F1}', '\u{10F2}', '\u{10F3}', '\u{10F4}', '\u{10F5}', '\u{10F6}', '\u{10F7}', '\u{10F8}', '\u{10F9}', '\u{10FA}', '\u{1100}', '\u{1101}', '\u{1102}', '\u{1103}', '\u{1104}', '\u{1105}', '\u{1106}', '\u{1107}', '\u{1108}', '\u{1109}', '\u{110A}', '\u{110B}', '\u{110C}', '\u{110D}', '\u{110E}', '\u{110F}', '\u{1110}', '\u{1111}', '\u{1112}', '\u{1113}', '\u{1114}', '\u{1115}', '\u{1116}', '\u{1117}', '\u{1118}', '\u{1119}', '\u{111A}', '\u{111B}', '\u{111C}', '\u{111D}', '\u{111E}', '\u{111F}', '\u{1120}', '\u{1121}', '\u{1122}', '\u{1123}', '\u{1124}', '\u{1125}', '\u{1126}', '\u{1127}', '\u{1128}', '\u{1129}', '\u{112A}', '\u{112B}', '\u{112C}', '\u{112D}', '\u{112E}', '\u{112F}', '\u{1130}', '\u{1131}', '\u{1132}', '\u{1133}', '\u{1134}', '\u{1135}', '\u{1136}', '\u{1137}', '\u{1138}', '\u{1139}', '\u{113A}', '\u{113B}', '\u{113C}', '\u{113D}', '\u{113E}', '\u{113F}', '\u{1140}', '\u{1141}', '\u{1142}', '\u{1143}', '\u{1144}', '\u{1145}', '\u{1146}', '\u{1147}', '\u{1148}', '\u{1149}', '\u{114A}', '\u{114B}', '\u{114C}', '\u{114D}', '\u{114E}', '\u{114F}', '\u{1150}', '\u{1151}', '\u{1152}', '\u{1153}', '\u{1154}', '\u{1155}', '\u{1156}', '\u{1157}', '\u{1158}', '\u{1159}', '\u{115F}', '\u{1160}', '\u{1161}', '\u{1162}', '\u{1163}', '\u{1164}', '\u{1165}', '\u{1166}', '\u{1167}', '\u{1168}', '\u{1169}', '\u{116A}', '\u{116B}', '\u{116C}', '\u{116D}', '\u{116E}', '\u{116F}', '\u{1170}', '\u{1171}', '\u{1172}', '\u{1173}', '\u{1174}', '\u{1175}', '\u{1176}', '\u{1177}', '\u{1178}', '\u{1179}', '\u{117A}', '\u{117B}', '\u{117C}', '\u{117D}', '\u{117E}', '\u{117F}', '\u{1180}', '\u{1181}', '\u{1182}', '\u{1183}', '\u{1184}', '\u{1185}', '\u{1186}', '\u{1187}', '\u{1188}', '\u{1189}', '\u{118A}', '\u{118B}', '\u{118C}', '\u{118D}', '\u{118E}', '\u{118F}', '\u{1190}', '\u{1191}', '\u{1192}', '\u{1193}', '\u{1194}', '\u{1195}', '\u{1196}', '\u{1197}', '\u{1198}', '\u{1199}', '\u{119A}', '\u{119B}', '\u{119C}', '\u{119D}', '\u{119E}', '\u{119F}', '\u{11A0}', '\u{11A1}', '\u{11A2}', '\u{11A8}', '\u{11A9}', '\u{11AA}', '\u{11AB}', '\u{11AC}', '\u{11AD}', '\u{11AE}', '\u{11AF}', '\u{11B0}', '\u{11B1}', '\u{11B2}', '\u{11B3}', '\u{11B4}', '\u{11B5}', '\u{11B6}', '\u{11B7}', '\u{11B8}', '\u{11B9}', '\u{11BA}', '\u{11BB}', '\u{11BC}', '\u{11BD}', '\u{11BE}', '\u{11BF}', '\u{11C0}', '\u{11C1}', '\u{11C2}', '\u{11C3}', '\u{11C4}', '\u{11C5}', '\u{11C6}', '\u{11C7}', '\u{11C8}', '\u{11C9}', '\u{11CA}', '\u{11CB}', '\u{11CC}', '\u{11CD}', '\u{11CE}', '\u{11CF}', '\u{11D0}', '\u{11D1}', '\u{11D2}', '\u{11D3}', '\u{11D4}', '\u{11D5}', '\u{11D6}', '\u{11D7}', '\u{11D8}', '\u{11D9}', '\u{11DA}', '\u{11DB}', '\u{11DC}', '\u{11DD}', '\u{11DE}', '\u{11DF}', '\u{11E0}', '\u{11E1}', '\u{11E2}', '\u{11E3}', '\u{11E4}', '\u{11E5}', '\u{11E6}', '\u{11E7}', '\u{11E8}', '\u{11E9}', '\u{11EA}', '\u{11EB}', '\u{11EC}', '\u{11ED}', '\u{11EE}', '\u{11EF}', '\u{11F0}', '\u{11F1}', '\u{11F2}', '\u{11F3}', '\u{11F4}', '\u{11F5}', '\u{11F6}', '\u{11F7}', '\u{11F8}', '\u{11F9}', '\u{1200}', '\u{1201}', '\u{1202}', '\u{1203}', '\u{1204}', '\u{1205}', '\u{1206}', '\u{1207}', '\u{1208}', '\u{1209}', '\u{120A}', '\u{120B}', '\u{120C}', '\u{120D}', '\u{120E}', '\u{120F}', '\u{1210}', '\u{1211}', '\u{1212}', '\u{1213}', '\u{1214}', '\u{1215}', '\u{1216}', '\u{1217}', '\u{1218}', '\u{1219}', '\u{121A}', '\u{121B}', '\u{121C}', '\u{121D}', '\u{121E}', '\u{121F}', '\u{1220}', '\u{1221}', '\u{1222}', '\u{1223}', '\u{1224}', '\u{1225}', '\u{1226}', '\u{1227}', '\u{1228}', '\u{1229}', '\u{122A}', '\u{122B}', '\u{122C}', '\u{122D}', '\u{122E}', '\u{122F}', '\u{1230}', '\u{1231}', '\u{1232}', '\u{1233}', '\u{1234}', '\u{1235}', '\u{1236}', '\u{1237}', '\u{1238}', '\u{1239}', '\u{123A}', '\u{123B}', '\u{123C}', '\u{123D}', '\u{123E}', '\u{123F}', '\u{1240}', '\u{1241}', '\u{1242}', '\u{1243}', '\u{1244}', '\u{1245}', '\u{1246}', '\u{1247}', '\u{1248}', '\u{124A}', '\u{124B}', '\u{124C}', '\u{124D}', '\u{1250}', '\u{1251}', '\u{1252}', '\u{1253}', '\u{1254}', '\u{1255}', '\u{1256}', '\u{1258}', '\u{125A}', '\u{125B}', '\u{125C}', '\u{125D}', '\u{1260}', '\u{1261}', '\u{1262}', '\u{1263}', '\u{1264}', '\u{1265}', '\u{1266}', '\u{1267}', '\u{1268}', '\u{1269}', '\u{126A}', '\u{126B}', '\u{126C}', '\u{126D}', '\u{126E}', '\u{126F}', '\u{1270}', '\u{1271}', '\u{1272}', '\u{1273}', '\u{1274}', '\u{1275}', '\u{1276}', '\u{1277}', '\u{1278}', '\u{1279}', '\u{127A}', '\u{127B}', '\u{127C}', '\u{127D}', '\u{127E}', '\u{127F}', '\u{1280}', '\u{1281}', '\u{1282}', '\u{1283}', '\u{1284}', '\u{1285}', '\u{1286}', '\u{1287}', '\u{1288}', '\u{128A}', '\u{128B}', '\u{128C}', '\u{128D}', '\u{1290}', '\u{1291}', '\u{1292}', '\u{1293}', '\u{1294}', '\u{1295}', '\u{1296}', '\u{1297}', '\u{1298}', '\u{1299}', '\u{129A}', '\u{129B}', '\u{129C}', '\u{129D}', '\u{129E}', '\u{129F}', '\u{12A0}', '\u{12A1}', '\u{12A2}', '\u{12A3}', '\u{12A4}', '\u{12A5}', '\u{12A6}', '\u{12A7}', '\u{12A8}', '\u{12A9}', '\u{12AA}', '\u{12AB}', '\u{12AC}', '\u{12AD}', '\u{12AE}', '\u{12AF}', '\u{12B0}', '\u{12B2}', '\u{12B3}', '\u{12B4}', '\u{12B5}', '\u{12B8}', '\u{12B9}', '\u{12BA}', '\u{12BB}', '\u{12BC}', '\u{12BD}', '\u{12BE}', '\u{12C0}', '\u{12C2}', '\u{12C3}', '\u{12C4}', '\u{12C5}', '\u{12C8}', '\u{12C9}', '\u{12CA}', '\u{12CB}', '\u{12CC}', '\u{12CD}', '\u{12CE}', '\u{12CF}', '\u{12D0}', '\u{12D1}', '\u{12D2}', '\u{12D3}', '\u{12D4}', '\u{12D5}', '\u{12D6}', '\u{12D8}', '\u{12D9}', '\u{12DA}', '\u{12DB}', '\u{12DC}', '\u{12DD}', '\u{12DE}', '\u{12DF}', '\u{12E0}', '\u{12E1}', '\u{12E2}', '\u{12E3}', '\u{12E4}', '\u{12E5}', '\u{12E6}', '\u{12E7}', '\u{12E8}', '\u{12E9}', '\u{12EA}', '\u{12EB}', '\u{12EC}', '\u{12ED}', '\u{12EE}', '\u{12EF}', '\u{12F0}', '\u{12F1}', '\u{12F2}', '\u{12F3}', '\u{12F4}', '\u{12F5}', '\u{12F6}', '\u{12F7}', '\u{12F8}', '\u{12F9}', '\u{12FA}', '\u{12FB}', '\u{12FC}', '\u{12FD}', '\u{12FE}', '\u{12FF}', '\u{1300}', '\u{1301}', '\u{1302}', '\u{1303}', '\u{1304}', '\u{1305}', '\u{1306}', '\u{1307}', '\u{1308}', '\u{1309}', '\u{130A}', '\u{130B}', '\u{130C}', '\u{130D}', '\u{130E}', '\u{130F}', '\u{1310}', '\u{1312}', '\u{1313}', '\u{1314}', '\u{1315}', '\u{1318}', '\u{1319}', '\u{131A}', '\u{131B}', '\u{131C}', '\u{131D}', '\u{131E}', '\u{131F}', '\u{1320}', '\u{1321}', '\u{1322}', '\u{1323}', '\u{1324}', '\u{1325}', '\u{1326}', '\u{1327}', '\u{1328}', '\u{1329}', '\u{132A}', '\u{132B}', '\u{132C}', '\u{132D}', '\u{132E}', '\u{132F}', '\u{1330}', '\u{1331}', '\u{1332}', '\u{1333}', '\u{1334}', '\u{1335}', '\u{1336}', '\u{1337}', '\u{1338}', '\u{1339}', '\u{133A}', '\u{133B}', '\u{133C}', '\u{133D}', '\u{133E}', '\u{133F}', '\u{1340}', '\u{1341}', '\u{1342}', '\u{1343}', '\u{1344}', '\u{1345}', '\u{1346}', '\u{1347}', '\u{1348}', '\u{1349}', '\u{134A}', '\u{134B}', '\u{134C}', '\u{134D}', '\u{134E}', '\u{134F}', '\u{1350}', '\u{1351}', '\u{1352}', '\u{1353}', '\u{1354}', '\u{1355}', '\u{1356}', '\u{1357}', '\u{1358}', '\u{1359}', '\u{135A}', '\u{1380}', '\u{1381}', '\u{1382}', '\u{1383}', '\u{1384}', '\u{1385}', '\u{1386}', '\u{1387}', '\u{1388}', '\u{1389}', '\u{138A}', '\u{138B}', '\u{138C}', '\u{138D}', '\u{138E}', '\u{138F}', '\u{13A0}', '\u{13A1}', '\u{13A2}', '\u{13A3}', '\u{13A4}', '\u{13A5}', '\u{13A6}', '\u{13A7}', '\u{13A8}', '\u{13A9}', '\u{13AA}', '\u{13AB}', '\u{13AC}', '\u{13AD}', '\u{13AE}', '\u{13AF}', '\u{13B0}', '\u{13B1}', '\u{13B2}', '\u{13B3}', '\u{13B4}', '\u{13B5}', '\u{13B6}', '\u{13B7}', '\u{13B8}', '\u{13B9}', '\u{13BA}', '\u{13BB}', '\u{13BC}', '\u{13BD}', '\u{13BE}', '\u{13BF}', '\u{13C0}', '\u{13C1}', '\u{13C2}', '\u{13C3}', '\u{13C4}', '\u{13C5}', '\u{13C6}', '\u{13C7}', '\u{13C8}', '\u{13C9}', '\u{13CA}', '\u{13CB}', '\u{13CC}', '\u{13CD}', '\u{13CE}', '\u{13CF}', '\u{13D0}', '\u{13D1}', '\u{13D2}', '\u{13D3}', '\u{13D4}', '\u{13D5}', '\u{13D6}', '\u{13D7}', '\u{13D8}', '\u{13D9}', '\u{13DA}', '\u{13DB}', '\u{13DC}', '\u{13DD}', '\u{13DE}', '\u{13DF}', '\u{13E0}', '\u{13E1}', '\u{13E2}', '\u{13E3}', '\u{13E4}', '\u{13E5}', '\u{13E6}', '\u{13E7}', '\u{13E8}', '\u{13E9}', '\u{13EA}', '\u{13EB}', '\u{13EC}', '\u{13ED}', '\u{13EE}', '\u{13EF}', '\u{13F0}', '\u{13F1}', '\u{13F2}', '\u{13F3}', '\u{13F4}', '\u{1401}', '\u{1402}', '\u{1403}', '\u{1404}', '\u{1405}', '\u{1406}', '\u{1407}', '\u{1408}', '\u{1409}', '\u{140A}', '\u{140B}', '\u{140C}', '\u{140D}', '\u{140E}', '\u{140F}', '\u{1410}', '\u{1411}', '\u{1412}', '\u{1413}', '\u{1414}', '\u{1415}', '\u{1416}', '\u{1417}', '\u{1418}', '\u{1419}', '\u{141A}', '\u{141B}', '\u{141C}', '\u{141D}', '\u{141E}', '\u{141F}', '\u{1420}', '\u{1421}', '\u{1422}', '\u{1423}', '\u{1424}', '\u{1425}', '\u{1426}', '\u{1427}', '\u{1428}', '\u{1429}', '\u{142A}', '\u{142B}', '\u{142C}', '\u{142D}', '\u{142E}', '\u{142F}', '\u{1430}', '\u{1431}', '\u{1432}', '\u{1433}', '\u{1434}', '\u{1435}', '\u{1436}', '\u{1437}', '\u{1438}', '\u{1439}', '\u{143A}', '\u{143B}', '\u{143C}', '\u{143D}', '\u{143E}', '\u{143F}', '\u{1440}', '\u{1441}', '\u{1442}', '\u{1443}', '\u{1444}', '\u{1445}', '\u{1446}', '\u{1447}', '\u{1448}', '\u{1449}', '\u{144A}', '\u{144B}', '\u{144C}', '\u{144D}', '\u{144E}', '\u{144F}', '\u{1450}', '\u{1451}', '\u{1452}', '\u{1453}', '\u{1454}', '\u{1455}', '\u{1456}', '\u{1457}', '\u{1458}', '\u{1459}', '\u{145A}', '\u{145B}', '\u{145C}', '\u{145D}', '\u{145E}', '\u{145F}', '\u{1460}', '\u{1461}', '\u{1462}', '\u{1463}', '\u{1464}', '\u{1465}', '\u{1466}', '\u{1467}', '\u{1468}', '\u{1469}', '\u{146A}', '\u{146B}', '\u{146C}', '\u{146D}', '\u{146E}', '\u{146F}', '\u{1470}', '\u{1471}', '\u{1472}', '\u{1473}', '\u{1474}', '\u{1475}', '\u{1476}', '\u{1477}', '\u{1478}', '\u{1479}', '\u{147A}', '\u{147B}', '\u{147C}', '\u{147D}', '\u{147E}', '\u{147F}', '\u{1480}', '\u{1481}', '\u{1482}', '\u{1483}', '\u{1484}', '\u{1485}', '\u{1486}', '\u{1487}', '\u{1488}', '\u{1489}', '\u{148A}', '\u{148B}', '\u{148C}', '\u{148D}', '\u{148E}', '\u{148F}', '\u{1490}', '\u{1491}', '\u{1492}', '\u{1493}', '\u{1494}', '\u{1495}', '\u{1496}', '\u{1497}', '\u{1498}', '\u{1499}', '\u{149A}', '\u{149B}', '\u{149C}', '\u{149D}', '\u{149E}', '\u{149F}', '\u{14A0}', '\u{14A1}', '\u{14A2}', '\u{14A3}', '\u{14A4}', '\u{14A5}', '\u{14A6}', '\u{14A7}', '\u{14A8}', '\u{14A9}', '\u{14AA}', '\u{14AB}', '\u{14AC}', '\u{14AD}', '\u{14AE}', '\u{14AF}', '\u{14B0}', '\u{14B1}', '\u{14B2}', '\u{14B3}', '\u{14B4}', '\u{14B5}', '\u{14B6}', '\u{14B7}', '\u{14B8}', '\u{14B9}', '\u{14BA}', '\u{14BB}', '\u{14BC}', '\u{14BD}', '\u{14BE}', '\u{14BF}', '\u{14C0}', '\u{14C1}', '\u{14C2}', '\u{14C3}', '\u{14C4}', '\u{14C5}', '\u{14C6}', '\u{14C7}', '\u{14C8}', '\u{14C9}', '\u{14CA}', '\u{14CB}', '\u{14CC}', '\u{14CD}', '\u{14CE}', '\u{14CF}', '\u{14D0}', '\u{14D1}', '\u{14D2}', '\u{14D3}', '\u{14D4}', '\u{14D5}', '\u{14D6}', '\u{14D7}', '\u{14D8}', '\u{14D9}', '\u{14DA}', '\u{14DB}', '\u{14DC}', '\u{14DD}', '\u{14DE}', '\u{14DF}', '\u{14E0}', '\u{14E1}', '\u{14E2}', '\u{14E3}', '\u{14E4}', '\u{14E5}', '\u{14E6}', '\u{14E7}', '\u{14E8}', '\u{14E9}', '\u{14EA}', '\u{14EB}', '\u{14EC}', '\u{14ED}', '\u{14EE}', '\u{14EF}', '\u{14F0}', '\u{14F1}', '\u{14F2}', '\u{14F3}', '\u{14F4}', '\u{14F5}', '\u{14F6}', '\u{14F7}', '\u{14F8}', '\u{14F9}', '\u{14FA}', '\u{14FB}', '\u{14FC}', '\u{14FD}', '\u{14FE}', '\u{14FF}', '\u{1500}', '\u{1501}', '\u{1502}', '\u{1503}', '\u{1504}', '\u{1505}', '\u{1506}', '\u{1507}', '\u{1508}', '\u{1509}', '\u{150A}', '\u{150B}', '\u{150C}', '\u{150D}', '\u{150E}', '\u{150F}', '\u{1510}', '\u{1511}', '\u{1512}', '\u{1513}', '\u{1514}', '\u{1515}', '\u{1516}', '\u{1517}', '\u{1518}', '\u{1519}', '\u{151A}', '\u{151B}', '\u{151C}', '\u{151D}', '\u{151E}', '\u{151F}', '\u{1520}', '\u{1521}', '\u{1522}', '\u{1523}', '\u{1524}', '\u{1525}', '\u{1526}', '\u{1527}', '\u{1528}', '\u{1529}', '\u{152A}', '\u{152B}', '\u{152C}', '\u{152D}', '\u{152E}', '\u{152F}', '\u{1530}', '\u{1531}', '\u{1532}', '\u{1533}', '\u{1534}', '\u{1535}', '\u{1536}', '\u{1537}', '\u{1538}', '\u{1539}', '\u{153A}', '\u{153B}', '\u{153C}', '\u{153D}', '\u{153E}', '\u{153F}', '\u{1540}', '\u{1541}', '\u{1542}', '\u{1543}', '\u{1544}', '\u{1545}', '\u{1546}', '\u{1547}', '\u{1548}', '\u{1549}', '\u{154A}', '\u{154B}', '\u{154C}', '\u{154D}', '\u{154E}', '\u{154F}', '\u{1550}', '\u{1551}', '\u{1552}', '\u{1553}', '\u{1554}', '\u{1555}', '\u{1556}', '\u{1557}', '\u{1558}', '\u{1559}', '\u{155A}', '\u{155B}', '\u{155C}', '\u{155D}', '\u{155E}', '\u{155F}', '\u{1560}', '\u{1561}', '\u{1562}', '\u{1563}', '\u{1564}', '\u{1565}', '\u{1566}', '\u{1567}', '\u{1568}', '\u{1569}', '\u{156A}', '\u{156B}', '\u{156C}', '\u{156D}', '\u{156E}', '\u{156F}', '\u{1570}', '\u{1571}', '\u{1572}', '\u{1573}', '\u{1574}', '\u{1575}', '\u{1576}', '\u{1577}', '\u{1578}', '\u{1579}', '\u{157A}', '\u{157B}', '\u{157C}', '\u{157D}', '\u{157E}', '\u{157F}', '\u{1580}', '\u{1581}', '\u{1582}', '\u{1583}', '\u{1584}', '\u{1585}', '\u{1586}', '\u{1587}', '\u{1588}', '\u{1589}', '\u{158A}', '\u{158B}', '\u{158C}', '\u{158D}', '\u{158E}', '\u{158F}', '\u{1590}', '\u{1591}', '\u{1592}', '\u{1593}', '\u{1594}', '\u{1595}', '\u{1596}', '\u{1597}', '\u{1598}', '\u{1599}', '\u{159A}', '\u{159B}', '\u{159C}', '\u{159D}', '\u{159E}', '\u{159F}', '\u{15A0}', '\u{15A1}', '\u{15A2}', '\u{15A3}', '\u{15A4}', '\u{15A5}', '\u{15A6}', '\u{15A7}', '\u{15A8}', '\u{15A9}', '\u{15AA}', '\u{15AB}', '\u{15AC}', '\u{15AD}', '\u{15AE}', '\u{15AF}', '\u{15B0}', '\u{15B1}', '\u{15B2}', '\u{15B3}', '\u{15B4}', '\u{15B5}', '\u{15B6}', '\u{15B7}', '\u{15B8}', '\u{15B9}', '\u{15BA}', '\u{15BB}', '\u{15BC}', '\u{15BD}', '\u{15BE}', '\u{15BF}', '\u{15C0}', '\u{15C1}', '\u{15C2}', '\u{15C3}', '\u{15C4}', '\u{15C5}', '\u{15C6}', '\u{15C7}', '\u{15C8}', '\u{15C9}', '\u{15CA}', '\u{15CB}', '\u{15CC}', '\u{15CD}', '\u{15CE}', '\u{15CF}', '\u{15D0}', '\u{15D1}', '\u{15D2}', '\u{15D3}', '\u{15D4}', '\u{15D5}', '\u{15D6}', '\u{15D7}', '\u{15D8}', '\u{15D9}', '\u{15DA}', '\u{15DB}', '\u{15DC}', '\u{15DD}', '\u{15DE}', '\u{15DF}', '\u{15E0}', '\u{15E1}', '\u{15E2}', '\u{15E3}', '\u{15E4}', '\u{15E5}', '\u{15E6}', '\u{15E7}', '\u{15E8}', '\u{15E9}', '\u{15EA}', '\u{15EB}', '\u{15EC}', '\u{15ED}', '\u{15EE}', '\u{15EF}', '\u{15F0}', '\u{15F1}', '\u{15F2}', '\u{15F3}', '\u{15F4}', '\u{15F5}', '\u{15F6}', '\u{15F7}', '\u{15F8}', '\u{15F9}', '\u{15FA}', '\u{15FB}', '\u{15FC}', '\u{15FD}', '\u{15FE}', '\u{15FF}', '\u{1600}', '\u{1601}', '\u{1602}', '\u{1603}', '\u{1604}', '\u{1605}', '\u{1606}', '\u{1607}', '\u{1608}', '\u{1609}', '\u{160A}', '\u{160B}', '\u{160C}', '\u{160D}', '\u{160E}', '\u{160F}', '\u{1610}', '\u{1611}', '\u{1612}', '\u{1613}', '\u{1614}', '\u{1615}', '\u{1616}', '\u{1617}', '\u{1618}', '\u{1619}', '\u{161A}', '\u{161B}', '\u{161C}', '\u{161D}', '\u{161E}', '\u{161F}', '\u{1620}', '\u{1621}', '\u{1622}', '\u{1623}', '\u{1624}', '\u{1625}', '\u{1626}', '\u{1627}', '\u{1628}', '\u{1629}', '\u{162A}', '\u{162B}', '\u{162C}', '\u{162D}', '\u{162E}', '\u{162F}', '\u{1630}', '\u{1631}', '\u{1632}', '\u{1633}', '\u{1634}', '\u{1635}', '\u{1636}', '\u{1637}', '\u{1638}', '\u{1639}', '\u{163A}', '\u{163B}', '\u{163C}', '\u{163D}', '\u{163E}', '\u{163F}', '\u{1640}', '\u{1641}', '\u{1642}', '\u{1643}', '\u{1644}', '\u{1645}', '\u{1646}', '\u{1647}', '\u{1648}', '\u{1649}', '\u{164A}', '\u{164B}', '\u{164C}', '\u{164D}', '\u{164E}', '\u{164F}', '\u{1650}', '\u{1651}', '\u{1652}', '\u{1653}', '\u{1654}', '\u{1655}', '\u{1656}', '\u{1657}', '\u{1658}', '\u{1659}', '\u{165A}', '\u{165B}', '\u{165C}', '\u{165D}', '\u{165E}', '\u{165F}', '\u{1660}', '\u{1661}', '\u{1662}', '\u{1663}', '\u{1664}', '\u{1665}', '\u{1666}', '\u{1667}', '\u{1668}', '\u{1669}', '\u{166A}', '\u{166B}', '\u{166C}', '\u{166F}', '\u{1670}', '\u{1671}', '\u{1672}', '\u{1673}', '\u{1674}', '\u{1675}', '\u{1676}', '\u{1681}', '\u{1682}', '\u{1683}', '\u{1684}', '\u{1685}', '\u{1686}', '\u{1687}', '\u{1688}', '\u{1689}', '\u{168A}', '\u{168B}', '\u{168C}', '\u{168D}', '\u{168E}', '\u{168F}', '\u{1690}', '\u{1691}', '\u{1692}', '\u{1693}', '\u{1694}', '\u{1695}', '\u{1696}', '\u{1697}', '\u{1698}', '\u{1699}', '\u{169A}', '\u{16A0}', '\u{16A1}', '\u{16A2}', '\u{16A3}', '\u{16A4}', '\u{16A5}', '\u{16A6}', '\u{16A7}', '\u{16A8}', '\u{16A9}', '\u{16AA}', '\u{16AB}', '\u{16AC}', '\u{16AD}', '\u{16AE}', '\u{16AF}', '\u{16B0}', '\u{16B1}', '\u{16B2}', '\u{16B3}', '\u{16B4}', '\u{16B5}', '\u{16B6}', '\u{16B7}', '\u{16B8}', '\u{16B9}', '\u{16BA}', '\u{16BB}', '\u{16BC}', '\u{16BD}', '\u{16BE}', '\u{16BF}', '\u{16C0}', '\u{16C1}', '\u{16C2}', '\u{16C3}', '\u{16C4}', '\u{16C5}', '\u{16C6}', '\u{16C7}', '\u{16C8}', '\u{16C9}', '\u{16CA}', '\u{16CB}', '\u{16CC}', '\u{16CD}', '\u{16CE}', '\u{16CF}', '\u{16D0}', '\u{16D1}', '\u{16D2}', '\u{16D3}', '\u{16D4}', '\u{16D5}', '\u{16D6}', '\u{16D7}', '\u{16D8}', '\u{16D9}', '\u{16DA}', '\u{16DB}', '\u{16DC}', '\u{16DD}', '\u{16DE}', '\u{16DF}', '\u{16E0}', '\u{16E1}', '\u{16E2}', '\u{16E3}', '\u{16E4}', '\u{16E5}', '\u{16E6}', '\u{16E7}', '\u{16E8}', '\u{16E9}', '\u{16EA}', '\u{1700}', '\u{1701}', '\u{1702}', '\u{1703}', '\u{1704}', '\u{1705}', '\u{1706}', '\u{1707}', '\u{1708}', '\u{1709}', '\u{170A}', '\u{170B}', '\u{170C}', '\u{170E}', '\u{170F}', '\u{1710}', '\u{1711}', '\u{1720}', '\u{1721}', '\u{1722}', '\u{1723}', '\u{1724}', '\u{1725}', '\u{1726}', '\u{1727}', '\u{1728}', '\u{1729}', '\u{172A}', '\u{172B}', '\u{172C}', '\u{172D}', '\u{172E}', '\u{172F}', '\u{1730}', '\u{1731}', '\u{1740}', '\u{1741}', '\u{1742}', '\u{1743}', '\u{1744}', '\u{1745}', '\u{1746}', '\u{1747}', '\u{1748}', '\u{1749}', '\u{174A}', '\u{174B}', '\u{174C}', '\u{174D}', '\u{174E}', '\u{174F}', '\u{1750}', '\u{1751}', '\u{1760}', '\u{1761}', '\u{1762}', '\u{1763}', '\u{1764}', '\u{1765}', '\u{1766}', '\u{1767}', '\u{1768}', '\u{1769}', '\u{176A}', '\u{176B}', '\u{176C}', '\u{176E}', '\u{176F}', '\u{1770}', '\u{1780}', '\u{1781}', '\u{1782}', '\u{1783}', '\u{1784}', '\u{1785}', '\u{1786}', '\u{1787}', '\u{1788}', '\u{1789}', '\u{178A}', '\u{178B}', '\u{178C}', '\u{178D}', '\u{178E}', '\u{178F}', '\u{1790}', '\u{1791}', '\u{1792}', '\u{1793}', '\u{1794}', '\u{1795}', '\u{1796}', '\u{1797}', '\u{1798}', '\u{1799}', '\u{179A}', '\u{179B}', '\u{179C}', '\u{179D}', '\u{179E}', '\u{179F}', '\u{17A0}', '\u{17A1}', '\u{17A2}', '\u{17A3}', '\u{17A4}', '\u{17A5}', '\u{17A6}', '\u{17A7}', '\u{17A8}', '\u{17A9}', '\u{17AA}', '\u{17AB}', '\u{17AC}', '\u{17AD}', '\u{17AE}', '\u{17AF}', '\u{17B0}', '\u{17B1}', '\u{17B2}', '\u{17B3}', '\u{17DC}', '\u{1820}', '\u{1821}', '\u{1822}', '\u{1823}', '\u{1824}', '\u{1825}', '\u{1826}', '\u{1827}', '\u{1828}', '\u{1829}', '\u{182A}', '\u{182B}', '\u{182C}', '\u{182D}', '\u{182E}', '\u{182F}', '\u{1830}', '\u{1831}', '\u{1832}', '\u{1833}', '\u{1834}', '\u{1835}', '\u{1836}', '\u{1837}', '\u{1838}', '\u{1839}', '\u{183A}', '\u{183B}', '\u{183C}', '\u{183D}', '\u{183E}', '\u{183F}', '\u{1840}', '\u{1841}', '\u{1842}', '\u{1844}', '\u{1845}', '\u{1846}', '\u{1847}', '\u{1848}', '\u{1849}', '\u{184A}', '\u{184B}', '\u{184C}', '\u{184D}', '\u{184E}', '\u{184F}', '\u{1850}', '\u{1851}', '\u{1852}', '\u{1853}', '\u{1854}', '\u{1855}', '\u{1856}', '\u{1857}', '\u{1858}', '\u{1859}', '\u{185A}', '\u{185B}', '\u{185C}', '\u{185D}', '\u{185E}', '\u{185F}', '\u{1860}', '\u{1861}', '\u{1862}', '\u{1863}', '\u{1864}', '\u{1865}', '\u{1866}', '\u{1867}', '\u{1868}', '\u{1869}', '\u{186A}', '\u{186B}', '\u{186C}', '\u{186D}', '\u{186E}', '\u{186F}', '\u{1870}', '\u{1871}', '\u{1872}', '\u{1873}', '\u{1874}', '\u{1875}', '\u{1876}', '\u{1877}', '\u{1880}', '\u{1881}', '\u{1882}', '\u{1883}', '\u{1884}', '\u{1885}', '\u{1886}', '\u{1887}', '\u{1888}', '\u{1889}', '\u{188A}', '\u{188B}', '\u{188C}', '\u{188D}', '\u{188E}', '\u{188F}', '\u{1890}', '\u{1891}', '\u{1892}', '\u{1893}', '\u{1894}', '\u{1895}', '\u{1896}', '\u{1897}', '\u{1898}', '\u{1899}', '\u{189A}', '\u{189B}', '\u{189C}', '\u{189D}', '\u{189E}', '\u{189F}', '\u{18A0}', '\u{18A1}', '\u{18A2}', '\u{18A3}', '\u{18A4}', '\u{18A5}', '\u{18A6}', '\u{18A7}', '\u{18A8}', '\u{18AA}', '\u{1900}', '\u{1901}', '\u{1902}', '\u{1903}', '\u{1904}', '\u{1905}', '\u{1906}', '\u{1907}', '\u{1908}', '\u{1909}', '\u{190A}', '\u{190B}', '\u{190C}', '\u{190D}', '\u{190E}', '\u{190F}', '\u{1910}', '\u{1911}', '\u{1912}', '\u{1913}', '\u{1914}', '\u{1915}', '\u{1916}', '\u{1917}', '\u{1918}', '\u{1919}', '\u{191A}', '\u{191B}', '\u{191C}', '\u{1950}', '\u{1951}', '\u{1952}', '\u{1953}', '\u{1954}', '\u{1955}', '\u{1956}', '\u{1957}', '\u{1958}', '\u{1959}', '\u{195A}', '\u{195B}', '\u{195C}', '\u{195D}', '\u{195E}', '\u{195F}', '\u{1960}', '\u{1961}', '\u{1962}', '\u{1963}', '\u{1964}', '\u{1965}', '\u{1966}', '\u{1967}', '\u{1968}', '\u{1969}', '\u{196A}', '\u{196B}', '\u{196C}', '\u{196D}', '\u{1970}', '\u{1971}', '\u{1972}', '\u{1973}', '\u{1974}', '\u{1980}', '\u{1981}', '\u{1982}', '\u{1983}', '\u{1984}', '\u{1985}', '\u{1986}', '\u{1987}', '\u{1988}', '\u{1989}', '\u{198A}', '\u{198B}', '\u{198C}', '\u{198D}', '\u{198E}', '\u{198F}', '\u{1990}', '\u{1991}', '\u{1992}', '\u{1993}', '\u{1994}', '\u{1995}', '\u{1996}', '\u{1997}', '\u{1998}', '\u{1999}', '\u{199A}', '\u{199B}', '\u{199C}', '\u{199D}', '\u{199E}', '\u{199F}', '\u{19A0}', '\u{19A1}', '\u{19A2}', '\u{19A3}', '\u{19A4}', '\u{19A5}', '\u{19A6}', '\u{19A7}', '\u{19A8}', '\u{19A9}', '\u{19C1}', '\u{19C2}', '\u{19C3}', '\u{19C4}', '\u{19C5}', '\u{19C6}', '\u{19C7}', '\u{1A00}', '\u{1A01}', '\u{1A02}', '\u{1A03}', '\u{1A04}', '\u{1A05}', '\u{1A06}', '\u{1A07}', '\u{1A08}', '\u{1A09}', '\u{1A0A}', '\u{1A0B}', '\u{1A0C}', '\u{1A0D}', '\u{1A0E}', '\u{1A0F}', '\u{1A10}', '\u{1A11}', '\u{1A12}', '\u{1A13}', '\u{1A14}', '\u{1A15}', '\u{1A16}', '\u{1B05}', '\u{1B06}', '\u{1B07}', '\u{1B08}', '\u{1B09}', '\u{1B0A}', '\u{1B0B}', '\u{1B0C}', '\u{1B0D}', '\u{1B0E}', '\u{1B0F}', '\u{1B10}', '\u{1B11}', '\u{1B12}', '\u{1B13}', '\u{1B14}', '\u{1B15}', '\u{1B16}', '\u{1B17}', '\u{1B18}', '\u{1B19}', '\u{1B1A}', '\u{1B1B}', '\u{1B1C}', '\u{1B1D}', '\u{1B1E}', '\u{1B1F}', '\u{1B20}', '\u{1B21}', '\u{1B22}', '\u{1B23}', '\u{1B24}', '\u{1B25}', '\u{1B26}', '\u{1B27}', '\u{1B28}', '\u{1B29}', '\u{1B2A}', '\u{1B2B}', '\u{1B2C}', '\u{1B2D}', '\u{1B2E}', '\u{1B2F}', '\u{1B30}', '\u{1B31}', '\u{1B32}', '\u{1B33}', '\u{1B45}', '\u{1B46}', '\u{1B47}', '\u{1B48}', '\u{1B49}', '\u{1B4A}', '\u{1B4B}', '\u{1B83}', '\u{1B84}', '\u{1B85}', '\u{1B86}', '\u{1B87}', '\u{1B88}', '\u{1B89}', '\u{1B8A}', '\u{1B8B}', '\u{1B8C}', '\u{1B8D}', '\u{1B8E}', '\u{1B8F}', '\u{1B90}', '\u{1B91}', '\u{1B92}', '\u{1B93}', '\u{1B94}', '\u{1B95}', '\u{1B96}', '\u{1B97}', '\u{1B98}', '\u{1B99}', '\u{1B9A}', '\u{1B9B}', '\u{1B9C}', '\u{1B9D}', '\u{1B9E}', '\u{1B9F}', '\u{1BA0}', '\u{1BAE}', '\u{1BAF}', '\u{1C00}', '\u{1C01}', '\u{1C02}', '\u{1C03}', '\u{1C04}', '\u{1C05}', '\u{1C06}', '\u{1C07}', '\u{1C08}', '\u{1C09}', '\u{1C0A}', '\u{1C0B}', '\u{1C0C}', '\u{1C0D}', '\u{1C0E}', '\u{1C0F}', '\u{1C10}', '\u{1C11}', '\u{1C12}', '\u{1C13}', '\u{1C14}', '\u{1C15}', '\u{1C16}', '\u{1C17}', '\u{1C18}', '\u{1C19}', '\u{1C1A}', '\u{1C1B}', '\u{1C1C}', '\u{1C1D}', '\u{1C1E}', '\u{1C1F}', '\u{1C20}', '\u{1C21}', '\u{1C22}', '\u{1C23}', '\u{1C4D}', '\u{1C4E}', '\u{1C4F}', '\u{1C5A}', '\u{1C5B}', '\u{1C5C}', '\u{1C5D}', '\u{1C5E}', '\u{1C5F}', '\u{1C60}', '\u{1C61}', '\u{1C62}', '\u{1C63}', '\u{1C64}', '\u{1C65}', '\u{1C66}', '\u{1C67}', '\u{1C68}', '\u{1C69}', '\u{1C6A}', '\u{1C6B}', '\u{1C6C}', '\u{1C6D}', '\u{1C6E}', '\u{1C6F}', '\u{1C70}', '\u{1C71}', '\u{1C72}', '\u{1C73}', '\u{1C74}', '\u{1C75}', '\u{1C76}', '\u{1C77}', '\u{2135}', '\u{2136}', '\u{2137}', '\u{2138}', '\u{2D30}', '\u{2D31}', '\u{2D32}', '\u{2D33}', '\u{2D34}', '\u{2D35}', '\u{2D36}', '\u{2D37}', '\u{2D38}', '\u{2D39}', '\u{2D3A}', '\u{2D3B}', '\u{2D3C}', '\u{2D3D}', '\u{2D3E}', '\u{2D3F}', '\u{2D40}', '\u{2D41}', '\u{2D42}', '\u{2D43}', '\u{2D44}', '\u{2D45}', '\u{2D46}', '\u{2D47}', '\u{2D48}', '\u{2D49}', '\u{2D4A}', '\u{2D4B}', '\u{2D4C}', '\u{2D4D}', '\u{2D4E}', '\u{2D4F}', '\u{2D50}', '\u{2D51}', '\u{2D52}', '\u{2D53}', '\u{2D54}', '\u{2D55}', '\u{2D56}', '\u{2D57}', '\u{2D58}', '\u{2D59}', '\u{2D5A}', '\u{2D5B}', '\u{2D5C}', '\u{2D5D}', '\u{2D5E}', '\u{2D5F}', '\u{2D60}', '\u{2D61}', '\u{2D62}', '\u{2D63}', '\u{2D64}', '\u{2D65}', '\u{2D80}', '\u{2D81}', '\u{2D82}', '\u{2D83}', '\u{2D84}', '\u{2D85}', '\u{2D86}', '\u{2D87}', '\u{2D88}', '\u{2D89}', '\u{2D8A}', '\u{2D8B}', '\u{2D8C}', '\u{2D8D}', '\u{2D8E}', '\u{2D8F}', '\u{2D90}', '\u{2D91}', '\u{2D92}', '\u{2D93}', '\u{2D94}', '\u{2D95}', '\u{2D96}', '\u{2DA0}', '\u{2DA1}', '\u{2DA2}', '\u{2DA3}', '\u{2DA4}', '\u{2DA5}', '\u{2DA6}', '\u{2DA8}', '\u{2DA9}', '\u{2DAA}', '\u{2DAB}', '\u{2DAC}', '\u{2DAD}', '\u{2DAE}', '\u{2DB0}', '\u{2DB1}', '\u{2DB2}', '\u{2DB3}', '\u{2DB4}', '\u{2DB5}', '\u{2DB6}', '\u{2DB8}', '\u{2DB9}', '\u{2DBA}', '\u{2DBB}', '\u{2DBC}', '\u{2DBD}', '\u{2DBE}', '\u{2DC0}', '\u{2DC1}', '\u{2DC2}', '\u{2DC3}', '\u{2DC4}', '\u{2DC5}', '\u{2DC6}', '\u{2DC8}', '\u{2DC9}', '\u{2DCA}', '\u{2DCB}', '\u{2DCC}', '\u{2DCD}', '\u{2DCE}', '\u{2DD0}', '\u{2DD1}', '\u{2DD2}', '\u{2DD3}', '\u{2DD4}', '\u{2DD5}', '\u{2DD6}', '\u{2DD8}', '\u{2DD9}', '\u{2DDA}', '\u{2DDB}', '\u{2DDC}', '\u{2DDD}', '\u{2DDE}', '\u{3006}', '\u{303C}', '\u{3041}', '\u{3042}', '\u{3043}', '\u{3044}', '\u{3045}', '\u{3046}', '\u{3047}', '\u{3048}', '\u{3049}', '\u{304A}', '\u{304B}', '\u{304C}', '\u{304D}', '\u{304E}', '\u{304F}', '\u{3050}', '\u{3051}', '\u{3052}', '\u{3053}', '\u{3054}', '\u{3055}', '\u{3056}', '\u{3057}', '\u{3058}', '\u{3059}', '\u{305A}', '\u{305B}', '\u{305C}', '\u{305D}', '\u{305E}', '\u{305F}', '\u{3060}', '\u{3061}', '\u{3062}', '\u{3063}', '\u{3064}', '\u{3065}', '\u{3066}', '\u{3067}', '\u{3068}', '\u{3069}', '\u{306A}', '\u{306B}', '\u{306C}', '\u{306D}', '\u{306E}', '\u{306F}', '\u{3070}', '\u{3071}', '\u{3072}', '\u{3073}', '\u{3074}', '\u{3075}', '\u{3076}', '\u{3077}', '\u{3078}', '\u{3079}', '\u{307A}', '\u{307B}', '\u{307C}', '\u{307D}', '\u{307E}', '\u{307F}', '\u{3080}', '\u{3081}', '\u{3082}', '\u{3083}', '\u{3084}', '\u{3085}', '\u{3086}', '\u{3087}', '\u{3088}', '\u{3089}', '\u{308A}', '\u{308B}', '\u{308C}', '\u{308D}', '\u{308E}', '\u{308F}', '\u{3090}', '\u{3091}', '\u{3092}', '\u{3093}', '\u{3094}', '\u{3095}', '\u{3096}', '\u{309F}', '\u{30A1}', '\u{30A2}', '\u{30A3}', '\u{30A4}', '\u{30A5}', '\u{30A6}', '\u{30A7}', '\u{30A8}', '\u{30A9}', '\u{30AA}', '\u{30AB}', '\u{30AC}', '\u{30AD}', '\u{30AE}', '\u{30AF}', '\u{30B0}', '\u{30B1}', '\u{30B2}', '\u{30B3}', '\u{30B4}', '\u{30B5}', '\u{30B6}', '\u{30B7}', '\u{30B8}', '\u{30B9}', '\u{30BA}', '\u{30BB}', '\u{30BC}', '\u{30BD}', '\u{30BE}', '\u{30BF}', '\u{30C0}', '\u{30C1}', '\u{30C2}', '\u{30C3}', '\u{30C4}', '\u{30C5}', '\u{30C6}', '\u{30C7}', '\u{30C8}', '\u{30C9}', '\u{30CA}', '\u{30CB}', '\u{30CC}', '\u{30CD}', '\u{30CE}', '\u{30CF}', '\u{30D0}', '\u{30D1}', '\u{30D2}', '\u{30D3}', '\u{30D4}', '\u{30D5}', '\u{30D6}', '\u{30D7}', '\u{30D8}', '\u{30D9}', '\u{30DA}', '\u{30DB}', '\u{30DC}', '\u{30DD}', '\u{30DE}', '\u{30DF}', '\u{30E0}', '\u{30E1}', '\u{30E2}', '\u{30E3}', '\u{30E4}', '\u{30E5}', '\u{30E6}', '\u{30E7}', '\u{30E8}', '\u{30E9}', '\u{30EA}', '\u{30EB}', '\u{30EC}', '\u{30ED}', '\u{30EE}', '\u{30EF}', '\u{30F0}', '\u{30F1}', '\u{30F2}', '\u{30F3}', '\u{30F4}', '\u{30F5}', '\u{30F6}', '\u{30F7}', '\u{30F8}', '\u{30F9}', '\u{30FA}', '\u{30FF}', '\u{3105}', '\u{3106}', '\u{3107}', '\u{3108}', '\u{3109}', '\u{310A}', '\u{310B}', '\u{310C}', '\u{310D}', '\u{310E}', '\u{310F}', '\u{3110}', '\u{3111}', '\u{3112}', '\u{3113}', '\u{3114}', '\u{3115}', '\u{3116}', '\u{3117}', '\u{3118}', '\u{3119}', '\u{311A}', '\u{311B}', '\u{311C}', '\u{311D}', '\u{311E}', '\u{311F}', '\u{3120}', '\u{3121}', '\u{3122}', '\u{3123}', '\u{3124}', '\u{3125}', '\u{3126}', '\u{3127}', '\u{3128}', '\u{3129}', '\u{312A}', '\u{312B}', '\u{312C}', '\u{312D}', '\u{3131}', '\u{3132}', '\u{3133}', '\u{3134}', '\u{3135}', '\u{3136}', '\u{3137}', '\u{3138}', '\u{3139}', '\u{313A}', '\u{313B}', '\u{313C}', '\u{313D}', '\u{313E}', '\u{313F}', '\u{3140}', '\u{3141}', '\u{3142}', '\u{3143}', '\u{3144}', '\u{3145}', '\u{3146}', '\u{3147}', '\u{3148}', '\u{3149}', '\u{314A}', '\u{314B}', '\u{314C}', '\u{314D}', '\u{314E}', '\u{314F}', '\u{3150}', '\u{3151}', '\u{3152}', '\u{3153}', '\u{3154}', '\u{3155}', '\u{3156}', '\u{3157}', '\u{3158}', '\u{3159}', '\u{315A}', '\u{315B}', '\u{315C}', '\u{315D}', '\u{315E}', '\u{315F}', '\u{3160}', '\u{3161}', '\u{3162}', '\u{3163}', '\u{3164}', '\u{3165}', '\u{3166}', '\u{3167}', '\u{3168}', '\u{3169}', '\u{316A}', '\u{316B}', '\u{316C}', '\u{316D}', '\u{316E}', '\u{316F}', '\u{3170}', '\u{3171}', '\u{3172}', '\u{3173}', '\u{3174}', '\u{3175}', '\u{3176}', '\u{3177}', '\u{3178}', '\u{3179}', '\u{317A}', '\u{317B}', '\u{317C}', '\u{317D}', '\u{317E}', '\u{317F}', '\u{3180}', '\u{3181}', '\u{3182}', '\u{3183}', '\u{3184}', '\u{3185}', '\u{3186}', '\u{3187}', '\u{3188}', '\u{3189}', '\u{318A}', '\u{318B}', '\u{318C}', '\u{318D}', '\u{318E}', '\u{31A0}', '\u{31A1}', '\u{31A2}', '\u{31A3}', '\u{31A4}', '\u{31A5}', '\u{31A6}', '\u{31A7}', '\u{31A8}', '\u{31A9}', '\u{31AA}', '\u{31AB}', '\u{31AC}', '\u{31AD}', '\u{31AE}', '\u{31AF}', '\u{31B0}', '\u{31B1}', '\u{31B2}', '\u{31B3}', '\u{31B4}', '\u{31B5}', '\u{31B6}', '\u{31B7}', '\u{31F0}', '\u{31F1}', '\u{31F2}', '\u{31F3}', '\u{31F4}', '\u{31F5}', '\u{31F6}', '\u{31F7}', '\u{31F8}', '\u{31F9}', '\u{31FA}', '\u{31FB}', '\u{31FC}', '\u{31FD}', '\u{31FE}', '\u{31FF}', '\u{3400}', '\u{4DB5}', '\u{4E00}', '\u{9FC3}', '\u{A000}', '\u{A001}', '\u{A002}', '\u{A003}', '\u{A004}', '\u{A005}', '\u{A006}', '\u{A007}', '\u{A008}', '\u{A009}', '\u{A00A}', '\u{A00B}', '\u{A00C}', '\u{A00D}', '\u{A00E}', '\u{A00F}', '\u{A010}', '\u{A011}', '\u{A012}', '\u{A013}', '\u{A014}', '\u{A016}', '\u{A017}', '\u{A018}', '\u{A019}', '\u{A01A}', '\u{A01B}', '\u{A01C}', '\u{A01D}', '\u{A01E}', '\u{A01F}', '\u{A020}', '\u{A021}', '\u{A022}', '\u{A023}', '\u{A024}', '\u{A025}', '\u{A026}', '\u{A027}', '\u{A028}', '\u{A029}', '\u{A02A}', '\u{A02B}', '\u{A02C}', '\u{A02D}', '\u{A02E}', '\u{A02F}', '\u{A030}', '\u{A031}', '\u{A032}', '\u{A033}', '\u{A034}', '\u{A035}', '\u{A036}', '\u{A037}', '\u{A038}', '\u{A039}', '\u{A03A}', '\u{A03B}', '\u{A03C}', '\u{A03D}', '\u{A03E}', '\u{A03F}', '\u{A040}', '\u{A041}', '\u{A042}', '\u{A043}', '\u{A044}', '\u{A045}', '\u{A046}', '\u{A047}', '\u{A048}', '\u{A049}', '\u{A04A}', '\u{A04B}', '\u{A04C}', '\u{A04D}', '\u{A04E}', '\u{A04F}', '\u{A050}', '\u{A051}', '\u{A052}', '\u{A053}', '\u{A054}', '\u{A055}', '\u{A056}', '\u{A057}', '\u{A058}', '\u{A059}', '\u{A05A}', '\u{A05B}', '\u{A05C}', '\u{A05D}', '\u{A05E}', '\u{A05F}', '\u{A060}', '\u{A061}', '\u{A062}', '\u{A063}', '\u{A064}', '\u{A065}', '\u{A066}', '\u{A067}', '\u{A068}', '\u{A069}', '\u{A06A}', '\u{A06B}', '\u{A06C}', '\u{A06D}', '\u{A06E}', '\u{A06F}', '\u{A070}', '\u{A071}', '\u{A072}', '\u{A073}', '\u{A074}', '\u{A075}', '\u{A076}', '\u{A077}', '\u{A078}', '\u{A079}', '\u{A07A}', '\u{A07B}', '\u{A07C}', '\u{A07D}', '\u{A07E}', '\u{A07F}', '\u{A080}', '\u{A081}', '\u{A082}', '\u{A083}', '\u{A084}', '\u{A085}', '\u{A086}', '\u{A087}', '\u{A088}', '\u{A089}', '\u{A08A}', '\u{A08B}', '\u{A08C}', '\u{A08D}', '\u{A08E}', '\u{A08F}', '\u{A090}', '\u{A091}', '\u{A092}', '\u{A093}', '\u{A094}', '\u{A095}', '\u{A096}', '\u{A097}', '\u{A098}', '\u{A099}', '\u{A09A}', '\u{A09B}', '\u{A09C}', '\u{A09D}', '\u{A09E}', '\u{A09F}', '\u{A0A0}', '\u{A0A1}', '\u{A0A2}', '\u{A0A3}', '\u{A0A4}', '\u{A0A5}', '\u{A0A6}', '\u{A0A7}', '\u{A0A8}', '\u{A0A9}', '\u{A0AA}', '\u{A0AB}', '\u{A0AC}', '\u{A0AD}', '\u{A0AE}', '\u{A0AF}', '\u{A0B0}', '\u{A0B1}', '\u{A0B2}', '\u{A0B3}', '\u{A0B4}', '\u{A0B5}', '\u{A0B6}', '\u{A0B7}', '\u{A0B8}', '\u{A0B9}', '\u{A0BA}', '\u{A0BB}', '\u{A0BC}', '\u{A0BD}', '\u{A0BE}', '\u{A0BF}', '\u{A0C0}', '\u{A0C1}', '\u{A0C2}', '\u{A0C3}', '\u{A0C4}', '\u{A0C5}', '\u{A0C6}', '\u{A0C7}', '\u{A0C8}', '\u{A0C9}', '\u{A0CA}', '\u{A0CB}', '\u{A0CC}', '\u{A0CD}', '\u{A0CE}', '\u{A0CF}', '\u{A0D0}', '\u{A0D1}', '\u{A0D2}', '\u{A0D3}', '\u{A0D4}', '\u{A0D5}', '\u{A0D6}', '\u{A0D7}', '\u{A0D8}', '\u{A0D9}', '\u{A0DA}', '\u{A0DB}', '\u{A0DC}', '\u{A0DD}', '\u{A0DE}', '\u{A0DF}', '\u{A0E0}', '\u{A0E1}', '\u{A0E2}', '\u{A0E3}', '\u{A0E4}', '\u{A0E5}', '\u{A0E6}', '\u{A0E7}', '\u{A0E8}', '\u{A0E9}', '\u{A0EA}', '\u{A0EB}', '\u{A0EC}', '\u{A0ED}', '\u{A0EE}', '\u{A0EF}', '\u{A0F0}', '\u{A0F1}', '\u{A0F2}', '\u{A0F3}', '\u{A0F4}', '\u{A0F5}', '\u{A0F6}', '\u{A0F7}', '\u{A0F8}', '\u{A0F9}', '\u{A0FA}', '\u{A0FB}', '\u{A0FC}', '\u{A0FD}', '\u{A0FE}', '\u{A0FF}', '\u{A100}', '\u{A101}', '\u{A102}', '\u{A103}', '\u{A104}', '\u{A105}', '\u{A106}', '\u{A107}', '\u{A108}', '\u{A109}', '\u{A10A}', '\u{A10B}', '\u{A10C}', '\u{A10D}', '\u{A10E}', '\u{A10F}', '\u{A110}', '\u{A111}', '\u{A112}', '\u{A113}', '\u{A114}', '\u{A115}', '\u{A116}', '\u{A117}', '\u{A118}', '\u{A119}', '\u{A11A}', '\u{A11B}', '\u{A11C}', '\u{A11D}', '\u{A11E}', '\u{A11F}', '\u{A120}', '\u{A121}', '\u{A122}', '\u{A123}', '\u{A124}', '\u{A125}', '\u{A126}', '\u{A127}', '\u{A128}', '\u{A129}', '\u{A12A}', '\u{A12B}', '\u{A12C}', '\u{A12D}', '\u{A12E}', '\u{A12F}', '\u{A130}', '\u{A131}', '\u{A132}', '\u{A133}', '\u{A134}', '\u{A135}', '\u{A136}', '\u{A137}', '\u{A138}', '\u{A139}', '\u{A13A}', '\u{A13B}', '\u{A13C}', '\u{A13D}', '\u{A13E}', '\u{A13F}', '\u{A140}', '\u{A141}', '\u{A142}', '\u{A143}', '\u{A144}', '\u{A145}', '\u{A146}', '\u{A147}', '\u{A148}', '\u{A149}', '\u{A14A}', '\u{A14B}', '\u{A14C}', '\u{A14D}', '\u{A14E}', '\u{A14F}', '\u{A150}', '\u{A151}', '\u{A152}', '\u{A153}', '\u{A154}', '\u{A155}', '\u{A156}', '\u{A157}', '\u{A158}', '\u{A159}', '\u{A15A}', '\u{A15B}', '\u{A15C}', '\u{A15D}', '\u{A15E}', '\u{A15F}', '\u{A160}', '\u{A161}', '\u{A162}', '\u{A163}', '\u{A164}', '\u{A165}', '\u{A166}', '\u{A167}', '\u{A168}', '\u{A169}', '\u{A16A}', '\u{A16B}', '\u{A16C}', '\u{A16D}', '\u{A16E}', '\u{A16F}', '\u{A170}', '\u{A171}', '\u{A172}', '\u{A173}', '\u{A174}', '\u{A175}', '\u{A176}', '\u{A177}', '\u{A178}', '\u{A179}', '\u{A17A}', '\u{A17B}', '\u{A17C}', '\u{A17D}', '\u{A17E}', '\u{A17F}', '\u{A180}', '\u{A181}', '\u{A182}', '\u{A183}', '\u{A184}', '\u{A185}', '\u{A186}', '\u{A187}', '\u{A188}', '\u{A189}', '\u{A18A}', '\u{A18B}', '\u{A18C}', '\u{A18D}', '\u{A18E}', '\u{A18F}', '\u{A190}', '\u{A191}', '\u{A192}', '\u{A193}', '\u{A194}', '\u{A195}', '\u{A196}', '\u{A197}', '\u{A198}', '\u{A199}', '\u{A19A}', '\u{A19B}', '\u{A19C}', '\u{A19D}', '\u{A19E}', '\u{A19F}', '\u{A1A0}', '\u{A1A1}', '\u{A1A2}', '\u{A1A3}', '\u{A1A4}', '\u{A1A5}', '\u{A1A6}', '\u{A1A7}', '\u{A1A8}', '\u{A1A9}', '\u{A1AA}', '\u{A1AB}', '\u{A1AC}', '\u{A1AD}', '\u{A1AE}', '\u{A1AF}') - } - - fn is_unicode_combining_spacing_mark(self) -> bool { - match_char_class!(self, - '\u{0903}', '\u{093E}', '\u{093F}', '\u{0940}', '\u{0949}', '\u{094A}', '\u{094B}', '\u{094C}', '\u{0982}', '\u{0983}', '\u{09BE}', '\u{09BF}', '\u{09C0}', '\u{09C7}', '\u{09C8}', '\u{09CB}', '\u{09CC}', '\u{09D7}', '\u{0A03}', '\u{0A3E}', '\u{0A3F}', '\u{0A40}', '\u{0A83}', '\u{0ABE}', '\u{0ABF}', '\u{0AC0}', '\u{0AC9}', '\u{0ACB}', '\u{0ACC}', '\u{0B02}', '\u{0B03}', '\u{0B3E}', '\u{0B40}', '\u{0B47}', '\u{0B48}', '\u{0B4B}', '\u{0B4C}', '\u{0B57}', '\u{0BBE}', '\u{0BBF}', '\u{0BC1}', '\u{0BC2}', '\u{0BC6}', '\u{0BC7}', '\u{0BC8}', '\u{0BCA}', '\u{0BCB}', '\u{0BCC}', '\u{0BD7}', '\u{0C01}', '\u{0C02}', '\u{0C03}', '\u{0C41}', '\u{0C42}', '\u{0C43}', '\u{0C44}', '\u{0C82}', '\u{0C83}', '\u{0CBE}', '\u{0CC0}', '\u{0CC1}', '\u{0CC2}', '\u{0CC3}', '\u{0CC4}', '\u{0CC7}', '\u{0CC8}', '\u{0CCA}', '\u{0CCB}', '\u{0CD5}', '\u{0CD6}', '\u{0D02}', '\u{0D03}', '\u{0D3E}', '\u{0D3F}', '\u{0D40}', '\u{0D46}', '\u{0D47}', '\u{0D48}', '\u{0D4A}', '\u{0D4B}', '\u{0D4C}', '\u{0D57}', '\u{0D82}', '\u{0D83}', '\u{0DCF}', '\u{0DD0}', '\u{0DD1}', '\u{0DD8}', '\u{0DD9}', '\u{0DDA}', '\u{0DDB}', '\u{0DDC}', '\u{0DDD}', '\u{0DDE}', '\u{0DDF}', '\u{0DF2}', '\u{0DF3}', '\u{0F3E}', '\u{0F3F}', '\u{0F7F}', '\u{102B}', '\u{102C}', '\u{1031}', '\u{1038}', '\u{103B}', '\u{103C}', '\u{1056}', '\u{1057}', '\u{1062}', '\u{1063}', '\u{1064}', '\u{1067}', '\u{1068}', '\u{1069}', '\u{106A}', '\u{106B}', '\u{106C}', '\u{106D}', '\u{1083}', '\u{1084}', '\u{1087}', '\u{1088}', '\u{1089}', '\u{108A}', '\u{108B}', '\u{108C}', '\u{108F}', '\u{17B6}', '\u{17BE}', '\u{17BF}', '\u{17C0}', '\u{17C1}', '\u{17C2}', '\u{17C3}', '\u{17C4}', '\u{17C5}', '\u{17C7}', '\u{17C8}', '\u{1923}', '\u{1924}', '\u{1925}', '\u{1926}', '\u{1929}', '\u{192A}', '\u{192B}', '\u{1930}', '\u{1931}', '\u{1933}', '\u{1934}', '\u{1935}', '\u{1936}', '\u{1937}', '\u{1938}', '\u{19B0}', '\u{19B1}', '\u{19B2}', '\u{19B3}', '\u{19B4}', '\u{19B5}', '\u{19B6}', '\u{19B7}', '\u{19B8}', '\u{19B9}', '\u{19BA}', '\u{19BB}', '\u{19BC}', '\u{19BD}', '\u{19BE}', '\u{19BF}', '\u{19C0}', '\u{19C8}', '\u{19C9}', '\u{1A19}', '\u{1A1A}', '\u{1A1B}', '\u{1B04}', '\u{1B35}', '\u{1B3B}', '\u{1B3D}', '\u{1B3E}', '\u{1B3F}', '\u{1B40}', '\u{1B41}', '\u{1B43}', '\u{1B44}', '\u{1B82}', '\u{1BA1}', '\u{1BA6}', '\u{1BA7}', '\u{1BAA}', '\u{1C24}', '\u{1C25}', '\u{1C26}', '\u{1C27}', '\u{1C28}', '\u{1C29}', '\u{1C2A}', '\u{1C2B}', '\u{1C34}', '\u{1C35}', '\u{A823}', '\u{A824}', '\u{A827}', '\u{A880}', '\u{A881}', '\u{A8B4}', '\u{A8B5}', '\u{A8B6}', '\u{A8B7}', '\u{A8B8}', '\u{A8B9}', '\u{A8BA}', '\u{A8BB}', '\u{A8BC}', '\u{A8BD}', '\u{A8BE}', '\u{A8BF}', '\u{A8C0}', '\u{A8C1}', '\u{A8C2}', '\u{A8C3}', '\u{A952}', '\u{A953}', '\u{AA2F}', '\u{AA30}', '\u{AA33}', '\u{AA34}', '\u{AA4D}') - } - - fn is_unicode_decimal_number(self) -> bool { - match_char_class!(self, - '\u{0030}', '\u{0031}', '\u{0032}', '\u{0033}', '\u{0034}', '\u{0035}', '\u{0036}', '\u{0037}', '\u{0038}', '\u{0039}', '\u{0660}', '\u{0661}', '\u{0662}', '\u{0663}', '\u{0664}', '\u{0665}', '\u{0666}', '\u{0667}', '\u{0668}', '\u{0669}', '\u{06F0}', '\u{06F1}', '\u{06F2}', '\u{06F3}', '\u{06F4}', '\u{06F5}', '\u{06F6}', '\u{06F7}', '\u{06F8}', '\u{06F9}', '\u{07C0}', '\u{07C1}', '\u{07C2}', '\u{07C3}', '\u{07C4}', '\u{07C5}', '\u{07C6}', '\u{07C7}', '\u{07C8}', '\u{07C9}', '\u{0966}', '\u{0967}', '\u{0968}', '\u{0969}', '\u{096A}', '\u{096B}', '\u{096C}', '\u{096D}', '\u{096E}', '\u{096F}', '\u{09E6}', '\u{09E7}', '\u{09E8}', '\u{09E9}', '\u{09EA}', '\u{09EB}', '\u{09EC}', '\u{09ED}', '\u{09EE}', '\u{09EF}', '\u{0A66}', '\u{0A67}', '\u{0A68}', '\u{0A69}', '\u{0A6A}', '\u{0A6B}', '\u{0A6C}', '\u{0A6D}', '\u{0A6E}', '\u{0A6F}', '\u{0AE6}', '\u{0AE7}', '\u{0AE8}', '\u{0AE9}', '\u{0AEA}', '\u{0AEB}', '\u{0AEC}', '\u{0AED}', '\u{0AEE}', '\u{0AEF}', '\u{0B66}', '\u{0B67}', '\u{0B68}', '\u{0B69}', '\u{0B6A}', '\u{0B6B}', '\u{0B6C}', '\u{0B6D}', '\u{0B6E}', '\u{0B6F}', '\u{0BE6}', '\u{0BE7}', '\u{0BE8}', '\u{0BE9}', '\u{0BEA}', '\u{0BEB}', '\u{0BEC}', '\u{0BED}', '\u{0BEE}', '\u{0BEF}', '\u{0C66}', '\u{0C67}', '\u{0C68}', '\u{0C69}', '\u{0C6A}', '\u{0C6B}', '\u{0C6C}', '\u{0C6D}', '\u{0C6E}', '\u{0C6F}', '\u{0CE6}', '\u{0CE7}', '\u{0CE8}', '\u{0CE9}', '\u{0CEA}', '\u{0CEB}', '\u{0CEC}', '\u{0CED}', '\u{0CEE}', '\u{0CEF}', '\u{0D66}', '\u{0D67}', '\u{0D68}', '\u{0D69}', '\u{0D6A}', '\u{0D6B}', '\u{0D6C}', '\u{0D6D}', '\u{0D6E}', '\u{0D6F}', '\u{0E50}', '\u{0E51}', '\u{0E52}', '\u{0E53}', '\u{0E54}', '\u{0E55}', '\u{0E56}', '\u{0E57}', '\u{0E58}', '\u{0E59}', '\u{0ED0}', '\u{0ED1}', '\u{0ED2}', '\u{0ED3}', '\u{0ED4}', '\u{0ED5}', '\u{0ED6}', '\u{0ED7}', '\u{0ED8}', '\u{0ED9}', '\u{0F20}', '\u{0F21}', '\u{0F22}', '\u{0F23}', '\u{0F24}', '\u{0F25}', '\u{0F26}', '\u{0F27}', '\u{0F28}', '\u{0F29}', '\u{1040}', '\u{1041}', '\u{1042}', '\u{1043}', '\u{1044}', '\u{1045}', '\u{1046}', '\u{1047}', '\u{1048}', '\u{1049}', '\u{1090}', '\u{1091}', '\u{1092}', '\u{1093}', '\u{1094}', '\u{1095}', '\u{1096}', '\u{1097}', '\u{1098}', '\u{1099}', '\u{17E0}', '\u{17E1}', '\u{17E2}', '\u{17E3}', '\u{17E4}', '\u{17E5}', '\u{17E6}', '\u{17E7}', '\u{17E8}', '\u{17E9}', '\u{1810}', '\u{1811}', '\u{1812}', '\u{1813}', '\u{1814}', '\u{1815}', '\u{1816}', '\u{1817}', '\u{1818}', '\u{1819}', '\u{1946}', '\u{1947}', '\u{1948}', '\u{1949}', '\u{194A}', '\u{194B}', '\u{194C}', '\u{194D}', '\u{194E}', '\u{194F}', '\u{19D0}', '\u{19D1}', '\u{19D2}', '\u{19D3}', '\u{19D4}', '\u{19D5}', '\u{19D6}', '\u{19D7}', '\u{19D8}', '\u{19D9}', '\u{1B50}', '\u{1B51}', '\u{1B52}', '\u{1B53}', '\u{1B54}', '\u{1B55}', '\u{1B56}', '\u{1B57}', '\u{1B58}', '\u{1B59}', '\u{1BB0}', '\u{1BB1}', '\u{1BB2}', '\u{1BB3}', '\u{1BB4}', '\u{1BB5}', '\u{1BB6}', '\u{1BB7}', '\u{1BB8}', '\u{1BB9}', '\u{1C40}', '\u{1C41}', '\u{1C42}', '\u{1C43}', '\u{1C44}', '\u{1C45}', '\u{1C46}', '\u{1C47}', '\u{1C48}', '\u{1C49}', '\u{1C50}', '\u{1C51}', '\u{1C52}', '\u{1C53}', '\u{1C54}', '\u{1C55}', '\u{1C56}', '\u{1C57}', '\u{1C58}', '\u{1C59}', '\u{A620}', '\u{A621}', '\u{A622}', '\u{A623}', '\u{A624}', '\u{A625}', '\u{A626}', '\u{A627}', '\u{A628}', '\u{A629}', '\u{A8D0}', '\u{A8D1}', '\u{A8D2}', '\u{A8D3}', '\u{A8D4}', '\u{A8D5}', '\u{A8D6}', '\u{A8D7}', '\u{A8D8}', '\u{A8D9}', '\u{A900}', '\u{A901}', '\u{A902}', '\u{A903}', '\u{A904}', '\u{A905}', '\u{A906}', '\u{A907}', '\u{A908}', '\u{A909}', '\u{AA50}', '\u{AA51}', '\u{AA52}', '\u{AA53}', '\u{AA54}', '\u{AA55}', '\u{AA56}', '\u{AA57}', '\u{AA58}', '\u{AA59}', '\u{FF10}', '\u{FF11}', '\u{FF12}', '\u{FF13}', '\u{FF14}', '\u{FF15}', '\u{FF16}', '\u{FF17}', '\u{FF18}', '\u{FF19}') - } - - fn is_unicode_connector_punctiation(self) -> bool { - match_char_class!(self, - '\u{005F}', '\u{203F}', '\u{2040}', '\u{2054}', '\u{FE33}', '\u{FE34}', '\u{FE4D}', '\u{FE4E}', '\u{FE4F}', '\u{FF3F}') - } - - fn is_unicode_space_separator(self) -> bool { - match_char_class!(self, - '\u{0020}', '\u{00A0}', '\u{1680}', '\u{2000}', '\u{2001}', '\u{2002}', '\u{2003}', '\u{2004}', '\u{2005}', '\u{2006}', '\u{2007}', '\u{2008}', '\u{2009}', '\u{200A}', '\u{202F}', '\u{205F}', '\u{3000}') - } - - fn is_es_identifier_start(self) -> bool { - match self { - '$' | '_' | '\\' => true, - c if c.is_unicode_letter() => true, - _ => false - } - } - - // see section 7.6 - fn is_es_identifier_part(self) -> bool { - match self { - '\u{200C}' | '\u{200D}' => true, - c if c.is_es_identifier_start() => true, - c if c.is_unicode_combining_spacing_mark() => true, - c if c.is_unicode_nonspacing_mark() => true, - c if c.is_unicode_decimal_number() => true, - c if c.is_unicode_connector_punctiation() => true, - _ => false - } - } - - fn is_es_whitespace(self) -> bool { - match self { - '\t' | '\u{000B}' | '\u{000C}' | '\u{0020}' | '\u{00A0}' | '\u{FEFF}' => true, - c => c.is_unicode_space_separator() - } - } - - fn is_es_line_terminator(self) -> bool { - match self { - '\n' | '\r' | '\u{2028}' | '\u{2029}' => true, - _ => false - } - } -} - -fn main() { - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29276.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29276.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29276.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29276.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct S([u8; { struct Z; 0 }]); - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2935.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2935.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2935.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2935.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -#![feature(box_syntax)] - -//type t = { a: isize }; -// type t = { a: bool }; -type t = bool; - -trait it { - fn f(&self); -} - -impl it for t { - fn f(&self) { } -} - -pub fn main() { - // let x = ({a: 4} as it); - // let y = box ({a: 4}); - // let z = box ({a: 4} as it); - // let z = box ({a: true} as it); - let z: Box<_> = box (box true as Box); - // x.f(); - // y.f(); - // (*z).f(); - println!("ok so far..."); - z.f(); //segfault -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2936.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2936.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2936.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2936.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -trait bar { - fn get_bar(&self) -> T; -} - -fn foo>(b: U) -> T { - b.get_bar() -} - -struct cbar { - x: isize, -} - -impl bar for cbar { - fn get_bar(&self) -> isize { - self.x - } -} - -fn cbar(x: isize) -> cbar { - cbar { - x: x - } -} - -pub fn main() { - let x: isize = foo::(cbar(5)); - assert_eq!(x, 5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29466.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29466.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29466.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29466.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,3608 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! m( - ($e1:expr => $e2:expr) => ({ $e1 }) -); - -fn main() { - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - let x = m!(1 => 2); - - println!("{}", x); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29485.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29485.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29485.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29485.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-29485.rs -// ignore-emscripten no threads - -#[feature(recover)] - -extern crate a; - -fn main() { - let _ = std::thread::spawn(move || { - a::f(&mut a::X(0), g); - }).join(); -} - -fn g() { - panic!(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29488.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29488.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29488.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29488.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::thread; - -struct Foo; - -impl Drop for Foo { - fn drop(&mut self) { - println!("test2"); - } -} - -thread_local!(static FOO: Foo = Foo); - -fn main() { - // Off the main thread due to #28129, be sure to initialize FOO first before - // calling `println!` - thread::spawn(|| { - FOO.with(|_| {}); - println!("test1"); - }).join().unwrap(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29516.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29516.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29516.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29516.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(optin_builtin_traits)] - -auto trait NotSame {} - -impl !NotSame for (A, A) {} - -trait OneOfEach {} - -impl OneOfEach for (A,) {} - -impl OneOfEach for (A, B) -where - (B,): OneOfEach, - (A, B): NotSame, -{ -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29522.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29522.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29522.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29522.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// check that we don't accidentally capture upvars just because their name -// occurs in a path - -fn assert_static(_t: T) {} - -mod foo { - pub fn scope() {} -} - -fn main() { - let scope = &mut 0; - assert_static(|| { - foo::scope(); - }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29540.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29540.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29540.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29540.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,502 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Debug)] -pub struct Config { - pub name: String, - pub cluster: String, - pub debug_none: String, - pub debug_lockdep: String, - pub debug_context: String, - pub debug_crush: String, - pub debug_mds: String, - pub debug_mds_balancer: String, - pub debug_mds_locker: String, - pub debug_mds_log: String, - pub debug_mds_log_expire: String, - pub debug_mds_migrator: String, - pub debug_buffer: String, - pub debug_timer: String, - pub debug_filer: String, - pub debug_striper: String, - pub debug_objecter: String, - pub debug_rados: String, - pub debug_rbd: String, - pub debug_journaler: String, - pub debug_objectcacher: String, - pub debug_client: String, - pub debug_osd: String, - pub debug_optracker: String, - pub debug_objclass: String, - pub debug_filestore: String, - pub debug_keyvaluestore: String, - pub debug_journal: String, - pub debug_ms: String, - pub debug_mon: String, - pub debug_monc: String, - pub debug_paxos: String, - pub debug_tp: String, - pub debug_auth: String, - pub debug_crypto: String, - pub debug_finisher: String, - pub debug_heartbeatmap: String, - pub debug_perfcounter: String, - pub debug_rgw: String, - pub debug_civetweb: String, - pub debug_javaclient: String, - pub debug_asok: String, - pub debug_throttle: String, - pub host: String, - pub fsid: String, - pub public_addr: String, - pub cluster_addr: String, - pub public_network: String, - pub cluster_network: String, - pub num_client: String, - pub monmap: String, - pub mon_host: String, - pub lockdep: String, - pub run_dir: String, - pub admin_socket: String, - pub daemonize: String, - pub pid_file: String, - pub chdir: String, - pub max_open_files: String, - pub restapi_log_level: String, - pub restapi_base_url: String, - pub fatal_signal_handlers: String, - pub log_file: String, - pub log_max_new: String, - pub log_max_recent: String, - pub log_to_stderr: String, - pub err_to_stderr: String, - pub log_to_syslog: String, - pub err_to_syslog: String, - pub log_flush_on_exit: String, - pub log_stop_at_utilization: String, - pub clog_to_monitors: String, - pub clog_to_syslog: String, - pub clog_to_syslog_level: String, - pub clog_to_syslog_facility: String, - pub mon_cluster_log_to_syslog: String, - pub mon_cluster_log_to_syslog_level: String, - pub mon_cluster_log_to_syslog_facility: String, - pub mon_cluster_log_file: String, - pub mon_cluster_log_file_level: String, - pub key: String, - pub keyfile: String, - pub keyring: String, - pub heartbeat_interval: String, - pub heartbeat_file: String, - pub heartbeat_inject_failure: String, - pub perf: String, - pub ms_tcp_nodelay: String, - pub ms_tcp_rcvbuf: String, - pub ms_initial_backoff: String, - pub ms_max_backoff: String, - pub ms_nocrc: String, - pub ms_die_on_bad_msg: String, - pub ms_die_on_unhandled_msg: String, - pub ms_die_on_old_message: String, - pub ms_dispatch_throttle_bytes: String, - pub ms_bind_ipv6: String, - pub ms_bind_port_min: String, - pub ms_bind_port_max: String, - pub ms_rwthread_stack_bytes: String, - pub ms_tcp_read_timeout: String, - pub ms_pq_max_tokens_per_priority: String, - pub ms_pq_min_cost: String, - pub ms_inject_socket_failures: String, - pub ms_inject_delay_type: String, - pub ms_inject_delay_msg_type: String, - pub ms_inject_delay_max: String, - pub ms_inject_delay_probability: String, - pub ms_inject_internal_delays: String, - pub ms_dump_on_send: String, - pub inject_early_sigterm: String, - pub mon_data: String, - pub mon_initial_members: String, - pub mon_sync_fs_threshold: String, - pub mon_compact_on_start: String, - pub mon_compact_on_bootstrap: String, - pub mon_compact_on_trim: String, - pub mon_tick_interval: String, - pub mon_subscribe_interval: String, - pub mon_delta_reset_interval: String, - pub mon_osd_laggy_halflife: String, - pub mon_osd_laggy_weight: String, - pub mon_osd_adjust_heartbeat_grace: String, - pub mon_osd_adjust_down_out_interval: String, - pub mon_osd_auto_mark_in: String, - pub mon_osd_auto_mark_auto_out_in: String, - pub mon_osd_auto_mark_new_in: String, - pub mon_osd_down_out_interval: String, - pub mon_osd_down_out_subtree_limit: String, - pub mon_osd_min_up_ratio: String, - pub mon_osd_min_in_ratio: String, - pub mon_osd_max_op_age: String, - pub mon_osd_max_split_count: String, - pub mon_osd_allow_primary_temp: String, - pub mon_osd_allow_primary_affinity: String, - pub mon_stat_smooth_intervals: String, - pub mon_lease: String, - pub mon_lease_renew_interval: String, - pub mon_lease_ack_timeout: String, - pub mon_clock_drift_allowed: String, - pub mon_clock_drift_warn_backoff: String, - pub mon_timecheck_interval: String, - pub mon_accept_timeout: String, - pub mon_pg_create_interval: String, - pub mon_pg_stuck_threshold: String, - pub mon_pg_warn_min_per_osd: String, - pub mon_pg_warn_max_object_skew: String, - pub mon_pg_warn_min_objects: String, - pub mon_pg_warn_min_pool_objects: String, - pub mon_cache_target_full_warn_ratio: String, - pub mon_osd_full_ratio: String, - pub mon_osd_nearfull_ratio: String, - pub mon_globalid_prealloc: String, - pub mon_osd_report_timeout: String, - pub mon_force_standby_active: String, - pub mon_warn_on_old_mons: String, - pub mon_warn_on_legacy_crush_tunables: String, - pub mon_warn_on_osd_down_out_interval_zero: String, - pub mon_warn_on_cache_pools_without_hit_sets: String, - pub mon_min_osdmap_epochs: String, - pub mon_max_pgmap_epochs: String, - pub mon_max_log_epochs: String, - pub mon_max_mdsmap_epochs: String, - pub mon_max_osd: String, - pub mon_probe_timeout: String, - pub mon_slurp_timeout: String, - pub mon_slurp_bytes: String, - pub mon_client_bytes: String, - pub mon_daemon_bytes: String, - pub mon_max_log_entries_per_event: String, - pub mon_health_data_update_interval: String, - pub mon_data_avail_crit: String, - pub mon_data_avail_warn: String, - pub mon_config_key_max_entry_size: String, - pub mon_sync_timeout: String, - pub mon_sync_max_payload_size: String, - pub mon_sync_debug: String, - pub mon_sync_debug_leader: String, - pub mon_sync_debug_provider: String, - pub mon_sync_debug_provider_fallback: String, - pub mon_inject_sync_get_chunk_delay: String, - pub mon_osd_min_down_reporters: String, - pub mon_osd_min_down_reports: String, - pub mon_osd_force_trim_to: String, - pub mon_mds_force_trim_to: String, - pub mon_advanced_debug_mode: String, - pub mon_debug_dump_transactions: String, - pub mon_debug_dump_location: String, - pub mon_sync_provider_kill_at: String, - pub mon_sync_requester_kill_at: String, - pub mon_leveldb_write_buffer_size: String, - pub mon_leveldb_cache_size: String, - pub mon_leveldb_block_size: String, - pub mon_leveldb_bloom_size: String, - pub mon_leveldb_max_open_files: String, - pub mon_leveldb_compression: String, - pub mon_leveldb_paranoid: String, - pub mon_leveldb_log: String, - pub mon_leveldb_size_warn: String, - pub mon_force_quorum_join: String, - pub paxos_stash_full_interval: String, - pub paxos_max_join_drift: String, - pub paxos_propose_interval: String, - pub paxos_min_wait: String, - pub paxos_min: String, - pub paxos_trim_min: String, - pub paxos_trim_max: String, - pub paxos_service_trim_min: String, - pub paxos_service_trim_max: String, - pub paxos_kill_at: String, - pub clock_offset: String, - pub auth_cluster_required: String, - pub auth_service_required: String, - pub auth_client_required: String, - pub auth_supported: String, - pub cephx_require_signatures: String, - pub cephx_cluster_require_signatures: String, - pub cephx_service_require_signatures: String, - pub cephx_sign_messages: String, - pub auth_mon_ticket_ttl: String, - pub auth_service_ticket_ttl: String, - pub auth_debug: String, - pub mon_client_hunt_interval: String, - pub mon_client_ping_interval: String, - pub mon_client_ping_timeout: String, - pub mon_client_hunt_interval_backoff: String, - pub mon_client_hunt_interval_max_multiple: String, - pub mon_client_max_log_entries_per_message: String, - pub mon_max_pool_pg_num: String, - pub mon_pool_quota_warn_threshold: String, - pub mon_pool_quota_crit_threshold: String, - pub client_cache_size: String, - pub client_cache_mid: String, - pub client_use_random_mds: String, - pub client_mount_timeout: String, - pub client_tick_interval: String, - pub client_trace: String, - pub client_readahead_min: String, - pub client_readahead_max_bytes: String, - pub client_readahead_max_periods: String, - pub client_snapdir: String, - pub client_mountpoint: String, - pub client_notify_timeout: String, - pub osd_client_watch_timeout: String, - pub client_caps_release_delay: String, - pub client_oc: String, - pub client_oc_size: String, - pub client_oc_max_dirty: String, - pub client_oc_target_dirty: String, - pub client_oc_max_dirty_age: String, - pub client_oc_max_objects: String, - pub client_debug_force_sync_read: String, - pub client_debug_inject_tick_delay: String, - pub client_max_inline_size: String, - pub fuse_use_invalidate_cb: String, - pub fuse_allow_other: String, - pub fuse_default_permissions: String, - pub fuse_big_writes: String, - pub fuse_atomic_o_trunc: String, - pub fuse_debug: String, - pub fuse_multithreaded: String, - pub crush_location: String, - pub objecter_tick_interval: String, - pub objecter_timeout: String, - pub objecter_inflight_op_bytes: String, - pub objecter_inflight_ops: String, - pub journaler_allow_split_entries: String, - pub journaler_write_head_interval: String, - pub journaler_prefetch_periods: String, - pub journaler_prezero_periods: String, - pub journaler_batch_interval: String, - pub journaler_batch_max: String, - pub mds_data: String, - pub mds_max_file_size: String, - pub mds_cache_size: String, - pub mds_cache_mid: String, - pub mds_mem_max: String, - pub mds_dir_max_commit_size: String, - pub mds_decay_halflife: String, - pub mds_beacon_interval: String, - pub mds_beacon_grace: String, - pub mds_enforce_unique_name: String, - pub mds_blacklist_interval: String, - pub mds_session_timeout: String, - pub mds_freeze_tree_timeout: String, - pub mds_session_autoclose: String, - pub mds_reconnect_timeout: String, - pub mds_tick_interval: String, - pub mds_dirstat_min_interval: String, - pub mds_scatter_nudge_interval: String, - pub mds_client_prealloc_inos: String, - pub mds_early_reply: String, - pub mds_default_dir_hash: String, - pub mds_log: String, - pub mds_log_skip_corrupt_events: String, - pub mds_log_max_events: String, - pub mds_log_segment_size: String, - pub mds_log_max_segments: String, - pub mds_log_max_expiring: String, - pub mds_bal_sample_interval: String, - pub mds_bal_replicate_threshold: String, - pub mds_bal_unreplicate_threshold: String, - pub mds_bal_frag: String, - pub mds_bal_split_size: String, - pub mds_bal_split_rd: String, - pub mds_bal_split_wr: String, - pub mds_bal_split_bits: String, - pub mds_bal_merge_size: String, - pub mds_bal_merge_rd: String, - pub mds_bal_merge_wr: String, - pub mds_bal_interval: String, - pub mds_bal_fragment_interval: String, - pub mds_bal_idle_threshold: String, - pub mds_bal_max: String, - pub mds_bal_max_until: String, - pub mds_bal_mode: String, - pub mds_bal_min_rebalance: String, - pub mds_bal_min_start: String, - pub mds_bal_need_min: String, - pub mds_bal_need_max: String, - pub mds_bal_midchunk: String, - pub mds_bal_minchunk: String, - pub mds_bal_target_removal_min: String, - pub mds_bal_target_removal_max: String, - pub mds_replay_interval: String, - pub mds_shutdown_check: String, - pub mds_thrash_exports: String, - pub mds_thrash_fragments: String, - pub mds_dump_cache_on_map: String, - pub mds_dump_cache_after_rejoin: String, - pub mds_verify_scatter: String, - pub mds_debug_scatterstat: String, - pub mds_debug_frag: String, - pub mds_debug_auth_pins: String, - pub mds_debug_subtrees: String, - pub mds_kill_mdstable_at: String, - pub mds_kill_export_at: String, - pub mds_kill_import_at: String, - pub mds_kill_link_at: String, - pub mds_kill_rename_at: String, - pub mds_kill_openc_at: String, - pub mds_kill_journal_at: String, - pub mds_kill_journal_expire_at: String, - pub mds_kill_journal_replay_at: String, - pub mds_kill_create_at: String, - pub mds_open_remote_link_mode: String, - pub mds_inject_traceless_reply_probability: String, - pub mds_wipe_sessions: String, - pub mds_wipe_ino_prealloc: String, - pub mds_skip_ino: String, - pub max_mds: String, - pub mds_standby_for_name: String, - pub mds_standby_for_rank: String, - pub mds_standby_replay: String, - pub osd_compact_leveldb_on_mount: String, - pub osd_max_backfills: String, - pub osd_backfill_full_ratio: String, - pub osd_backfill_retry_interval: String, - pub osd_agent_max_ops: String, - pub osd_agent_min_evict_effort: String, - pub osd_agent_quantize_effort: String, - pub osd_agent_delay_time: String, - pub osd_agent_hist_halflife: String, - pub osd_agent_slop: String, - pub osd_uuid: String, - pub osd_data: String, - pub osd_journal: String, - pub osd_journal_size: String, - pub osd_max_write_size: String, - pub osd_max_pgls: String, - pub osd_client_message_size_cap: String, - pub osd_client_message_cap: String, - pub osd_pg_bits: String, - pub osd_pgp_bits: String, - pub osd_crush_chooseleaf_type: String, - pub osd_pool_default_crush_rule: String, - pub osd_pool_default_crush_replicated_ruleset: String, - pub osd_pool_erasure_code_stripe_width: String, - pub osd_pool_default_size: String, - pub osd_pool_default_min_size: String, - pub osd_pool_default_pg_num: String, - pub osd_pool_default_pgp_num: String, - pub osd_pool_default_erasure_code_directory: String, - pub osd_pool_default_erasure_code_profile: String, - pub osd_erasure_code_plugins: String, - pub osd_pool_default_flags: String, - pub osd_pool_default_flag_hashpspool: String, - pub osd_pool_default_hit_set_bloom_fpp: String, - pub osd_pool_default_cache_target_dirty_ratio: String, - pub osd_pool_default_cache_target_full_ratio: String, - pub osd_pool_default_cache_min_flush_age: String, - pub osd_pool_default_cache_min_evict_age: String, - pub osd_hit_set_min_size: String, - pub osd_hit_set_max_size: String, - pub osd_hit_set_namespace: String, - pub osd_tier_default_cache_mode: String, - pub osd_tier_default_cache_hit_set_count: String, - pub osd_tier_default_cache_hit_set_period: String, - pub osd_tier_default_cache_hit_set_type: String, - pub osd_map_dedup: String, - pub osd_map_max_advance: String, - pub osd_map_cache_size: String, - pub osd_map_message_max: String, - pub osd_map_share_max_epochs: String, - pub osd_op_threads: String, - pub osd_peering_wq_batch_size: String, - pub osd_op_pq_max_tokens_per_priority: String, - pub osd_op_pq_min_cost: String, - pub osd_disk_threads: String, - pub osd_disk_thread_ioprio_class: String, - pub osd_disk_thread_ioprio_priority: String, - pub osd_recovery_threads: String, - pub osd_recover_clone_overlap: String, - pub osd_recover_clone_overlap_limit: String, - pub osd_backfill_scan_min: String, - pub osd_backfill_scan_max: String, - pub osd_op_thread_timeout: String, - pub osd_recovery_thread_timeout: String, - pub osd_snap_trim_thread_timeout: String, - pub osd_snap_trim_sleep: String, - pub osd_scrub_thread_timeout: String, - pub osd_scrub_finalize_thread_timeout: String, - pub osd_scrub_invalid_stats: String, - pub osd_remove_thread_timeout: String, - pub osd_command_thread_timeout: String, - pub osd_age: String, - pub osd_age_time: String, - pub osd_heartbeat_addr: String, - pub osd_heartbeat_interval: String, - pub osd_heartbeat_grace: String, - pub osd_heartbeat_min_peers: String, - pub osd_pg_max_concurrent_snap_trims: String, - pub osd_heartbeat_min_healthy_ratio: String, - pub osd_mon_heartbeat_interval: String, - pub osd_mon_report_interval_max: String, - pub osd_mon_report_interval_min: String, - pub osd_pg_stat_report_interval_max: String, - pub osd_mon_ack_timeout: String, - pub osd_default_data_pool_replay_window: String, - pub osd_preserve_trimmed_log: String, - pub osd_auto_mark_unfound_lost: String, - pub osd_recovery_delay_start: String, - pub osd_recovery_max_active: String, - pub osd_recovery_max_single_start: String, - pub osd_recovery_max_chunk: String, - pub osd_copyfrom_max_chunk: String, - pub osd_push_per_object_cost: String, - pub osd_max_push_cost: String, - pub osd_max_push_objects: String, - pub osd_recovery_forget_lost_objects: String, - pub osd_max_scrubs: String, - pub osd_scrub_load_threshold: String, - pub osd_scrub_min_interval: String, - pub osd_scrub_max_interval: String, - pub osd_scrub_chunk_min: String, - pub osd_scrub_chunk_max: String, - pub osd_scrub_sleep: String, - pub osd_deep_scrub_interval: String, - pub osd_deep_scrub_stride: String, - pub osd_scan_list_ping_tp_interval: String, - pub osd_auto_weight: String, - pub osd_class_dir: String, - pub osd_open_classes_on_start: String, - pub osd_check_for_log_corruption: String, - pub osd_use_stale_snap: String, - pub osd_rollback_to_cluster_snap: String, - pub osd_default_notify_timeout: String, - pub osd_kill_backfill_at: String, - pub osd_pg_epoch_persisted_max_stale: String, - pub osd_min_pg_log_entries: String, - pub osd_max_pg_log_entries: String, - pub osd_op_complaint_time: String, - pub osd_command_max_records: String, - pub osd_op_log_threshold: String, - pub osd_verify_sparse_read_holes: String, - pub osd_debug_drop_ping_probability: String, - pub osd_debug_drop_ping_duration: String, - pub osd_debug_drop_pg_create_probability: String, - pub osd_debug_drop_pg_create_duration: String, - pub osd_debug_drop_op_probability: String, - pub osd_debug_op_order: String, - pub osd_debug_verify_snaps_on_info: String, - pub osd_debug_verify_stray_on_activate: String, - pub osd_debug_skip_full_check_in_backfill_reservation: String, - pub osd_debug_reject_backfill_probability: String, - pub osd_enable_op_tracker: String, -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29663.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29663.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29663.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29663.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] -// write_volatile causes an LLVM assert with composite types - -#![feature(volatile)] -use std::ptr::{read_volatile, write_volatile}; - -#[derive(Debug, Eq, PartialEq)] -struct A(u32); -#[derive(Debug, Eq, PartialEq)] -struct B(u64); -#[derive(Debug, Eq, PartialEq)] -struct C(u32, u32); -#[derive(Debug, Eq, PartialEq)] -struct D(u64, u64); -#[derive(Debug, Eq, PartialEq)] -struct E([u64; 32]); - -fn main() { - unsafe { - let mut x: u32 = 0; - write_volatile(&mut x, 1); - assert_eq!(read_volatile(&x), 1); - assert_eq!(x, 1); - - let mut x: u64 = 0; - write_volatile(&mut x, 1); - assert_eq!(read_volatile(&x), 1); - assert_eq!(x, 1); - - let mut x = A(0); - write_volatile(&mut x, A(1)); - assert_eq!(read_volatile(&x), A(1)); - assert_eq!(x, A(1)); - - let mut x = B(0); - write_volatile(&mut x, B(1)); - assert_eq!(read_volatile(&x), B(1)); - assert_eq!(x, B(1)); - - let mut x = C(0, 0); - write_volatile(&mut x, C(1, 1)); - assert_eq!(read_volatile(&x), C(1, 1)); - assert_eq!(x, C(1, 1)); - - let mut x = D(0, 0); - write_volatile(&mut x, D(1, 1)); - assert_eq!(read_volatile(&x), D(1, 1)); - assert_eq!(x, D(1, 1)); - - let mut x = E([0; 32]); - write_volatile(&mut x, E([1; 32])); - assert_eq!(read_volatile(&x), E([1; 32])); - assert_eq!(x, E([1; 32])); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29668.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29668.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29668.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29668.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Functions can return unnameable types - -mod m1 { - mod m2 { - #[derive(Debug)] - pub struct A; - } - use self::m2::A; - pub fn x() -> A { A } -} - -fn main() { - let x = m1::x(); - println!("{:?}", x); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29710.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29710.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29710.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29710.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![deny(unused_results)] -#![allow(dead_code)] - -#[derive(Debug)] -struct A(usize); - -#[derive(Debug)] -struct B { a: usize } - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29740.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29740.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29740.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29740.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,326 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #29740. Inefficient MIR matching algorithms -// generated way too much code for this sort of case, leading to OOM. -#![allow(non_snake_case)] - -pub mod KeyboardEventConstants { - pub const DOM_KEY_LOCATION_STANDARD: u32 = 0; - pub const DOM_KEY_LOCATION_LEFT: u32 = 1; - pub const DOM_KEY_LOCATION_RIGHT: u32 = 2; - pub const DOM_KEY_LOCATION_NUMPAD: u32 = 3; -} // mod KeyboardEventConstants - -pub enum Key { - Space, - Apostrophe, - Comma, - Minus, - Period, - Slash, - Num0, - Num1, - Num2, - Num3, - Num4, - Num5, - Num6, - Num7, - Num8, - Num9, - Semicolon, - Equal, - A, - B, - C, - D, - E, - F, - G, - H, - I, - J, - K, - L, - M, - N, - O, - P, - Q, - R, - S, - T, - U, - V, - W, - X, - Y, - Z, - LeftBracket, - Backslash, - RightBracket, - GraveAccent, - World1, - World2, - - Escape, - Enter, - Tab, - Backspace, - Insert, - Delete, - Right, - Left, - Down, - Up, - PageUp, - PageDown, - Home, - End, - CapsLock, - ScrollLock, - NumLock, - PrintScreen, - Pause, - F1, - F2, - F3, - F4, - F5, - F6, - F7, - F8, - F9, - F10, - F11, - F12, - F13, - F14, - F15, - F16, - F17, - F18, - F19, - F20, - F21, - F22, - F23, - F24, - F25, - Kp0, - Kp1, - Kp2, - Kp3, - Kp4, - Kp5, - Kp6, - Kp7, - Kp8, - Kp9, - KpDecimal, - KpDivide, - KpMultiply, - KpSubtract, - KpAdd, - KpEnter, - KpEqual, - LeftShift, - LeftControl, - LeftAlt, - LeftSuper, - RightShift, - RightControl, - RightAlt, - RightSuper, - Menu, -} - -fn key_from_string(key_string: &str, location: u32) -> Option { - match key_string { - " " => Some(Key::Space), - "\"" => Some(Key::Apostrophe), - "'" => Some(Key::Apostrophe), - "<" => Some(Key::Comma), - "," => Some(Key::Comma), - "_" => Some(Key::Minus), - "-" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Minus), - ">" => Some(Key::Period), - "." if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Period), - "?" => Some(Key::Slash), - "/" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Slash), - "~" => Some(Key::GraveAccent), - "`" => Some(Key::GraveAccent), - ")" => Some(Key::Num0), - "0" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num0), - "!" => Some(Key::Num1), - "1" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num1), - "@" => Some(Key::Num2), - "2" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num2), - "#" => Some(Key::Num3), - "3" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num3), - "$" => Some(Key::Num4), - "4" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num4), - "%" => Some(Key::Num5), - "5" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num5), - "^" => Some(Key::Num6), - "6" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num6), - "&" => Some(Key::Num7), - "7" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num7), - "*" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num8), - "8" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num8), - "(" => Some(Key::Num9), - "9" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Num9), - ":" => Some(Key::Semicolon), - ";" => Some(Key::Semicolon), - "+" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Equal), - "=" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD => Some(Key::Equal), - "A" => Some(Key::A), - "a" => Some(Key::A), - "B" => Some(Key::B), - "b" => Some(Key::B), - "C" => Some(Key::C), - "c" => Some(Key::C), - "D" => Some(Key::D), - "d" => Some(Key::D), - "E" => Some(Key::E), - "e" => Some(Key::E), - "F" => Some(Key::F), - "f" => Some(Key::F), - "G" => Some(Key::G), - "g" => Some(Key::G), - "H" => Some(Key::H), - "h" => Some(Key::H), - "I" => Some(Key::I), - "i" => Some(Key::I), - "J" => Some(Key::J), - "j" => Some(Key::J), - "K" => Some(Key::K), - "k" => Some(Key::K), - "L" => Some(Key::L), - "l" => Some(Key::L), - "M" => Some(Key::M), - "m" => Some(Key::M), - "N" => Some(Key::N), - "n" => Some(Key::N), - "O" => Some(Key::O), - "o" => Some(Key::O), - "P" => Some(Key::P), - "p" => Some(Key::P), - "Q" => Some(Key::Q), - "q" => Some(Key::Q), - "R" => Some(Key::R), - "r" => Some(Key::R), - "S" => Some(Key::S), - "s" => Some(Key::S), - "T" => Some(Key::T), - "t" => Some(Key::T), - "U" => Some(Key::U), - "u" => Some(Key::U), - "V" => Some(Key::V), - "v" => Some(Key::V), - "W" => Some(Key::W), - "w" => Some(Key::W), - "X" => Some(Key::X), - "x" => Some(Key::X), - "Y" => Some(Key::Y), - "y" => Some(Key::Y), - "Z" => Some(Key::Z), - "z" => Some(Key::Z), - "{" => Some(Key::LeftBracket), - "[" => Some(Key::LeftBracket), - "|" => Some(Key::Backslash), - "\\" => Some(Key::Backslash), - "}" => Some(Key::RightBracket), - "]" => Some(Key::RightBracket), - "Escape" => Some(Key::Escape), - "Enter" if location == KeyboardEventConstants::DOM_KEY_LOCATION_STANDARD - => Some(Key::Enter), - "Tab" => Some(Key::Tab), - "Backspace" => Some(Key::Backspace), - "Insert" => Some(Key::Insert), - "Delete" => Some(Key::Delete), - "ArrowRight" => Some(Key::Right), - "ArrowLeft" => Some(Key::Left), - "ArrowDown" => Some(Key::Down), - "ArrowUp" => Some(Key::Up), - "PageUp" => Some(Key::PageUp), - "PageDown" => Some(Key::PageDown), - "Home" => Some(Key::Home), - "End" => Some(Key::End), - "CapsLock" => Some(Key::CapsLock), - "ScrollLock" => Some(Key::ScrollLock), - "NumLock" => Some(Key::NumLock), - "PrintScreen" => Some(Key::PrintScreen), - "Pause" => Some(Key::Pause), - "F1" => Some(Key::F1), - "F2" => Some(Key::F2), - "F3" => Some(Key::F3), - "F4" => Some(Key::F4), - "F5" => Some(Key::F5), - "F6" => Some(Key::F6), - "F7" => Some(Key::F7), - "F8" => Some(Key::F8), - "F9" => Some(Key::F9), - "F10" => Some(Key::F10), - "F11" => Some(Key::F11), - "F12" => Some(Key::F12), - "F13" => Some(Key::F13), - "F14" => Some(Key::F14), - "F15" => Some(Key::F15), - "F16" => Some(Key::F16), - "F17" => Some(Key::F17), - "F18" => Some(Key::F18), - "F19" => Some(Key::F19), - "F20" => Some(Key::F20), - "F21" => Some(Key::F21), - "F22" => Some(Key::F22), - "F23" => Some(Key::F23), - "F24" => Some(Key::F24), - "F25" => Some(Key::F25), - "0" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp0), - "1" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp1), - "2" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp2), - "3" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp3), - "4" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp4), - "5" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp5), - "6" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp6), - "7" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp7), - "8" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp8), - "9" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::Kp9), - "." if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpDecimal), - "/" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpDivide), - "*" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpMultiply), - "-" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpSubtract), - "+" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpAdd), - "Enter" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD - => Some(Key::KpEnter), - "=" if location == KeyboardEventConstants::DOM_KEY_LOCATION_NUMPAD => Some(Key::KpEqual), - "Shift" if location == KeyboardEventConstants::DOM_KEY_LOCATION_LEFT - => Some(Key::LeftShift), - "Control" if location == KeyboardEventConstants::DOM_KEY_LOCATION_LEFT - => Some(Key::LeftControl), - "Alt" if location == KeyboardEventConstants::DOM_KEY_LOCATION_LEFT => Some(Key::LeftAlt), - "Super" if location == KeyboardEventConstants::DOM_KEY_LOCATION_LEFT - => Some(Key::LeftSuper), - "Shift" if location == KeyboardEventConstants::DOM_KEY_LOCATION_RIGHT - => Some(Key::RightShift), - "Control" if location == KeyboardEventConstants::DOM_KEY_LOCATION_RIGHT - => Some(Key::RightControl), - "Alt" if location == KeyboardEventConstants::DOM_KEY_LOCATION_RIGHT => Some(Key::RightAlt), - "Super" if location == KeyboardEventConstants::DOM_KEY_LOCATION_RIGHT - => Some(Key::RightSuper), - "ContextMenu" => Some(Key::Menu), - _ => None - } -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29746.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29746.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29746.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29746.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// zip!(a1,a2,a3,a4) is equivalent to: -// a1.zip(a2).zip(a3).zip(a4).map(|(((x1,x2),x3),x4)| (x1,x2,x3,x4)) -macro_rules! zip { - // Entry point - ([$a:expr, $b:expr, $($rest:expr),*]) => { - zip!([$($rest),*], $a.zip($b), (x,y), [x,y]) - }; - - // Intermediate steps to build the zipped expression, the match pattern, and - // and the output tuple of the closure, using macro hygiene to repeatedly - // introduce new variables named 'x'. - ([$a:expr, $($rest:expr),*], $zip:expr, $pat:pat, [$($flat:expr),*]) => { - zip!([$($rest),*], $zip.zip($a), ($pat,x), [$($flat),*, x]) - }; - - // Final step - ([], $zip:expr, $pat:pat, [$($flat:expr),+]) => { - $zip.map(|$pat| ($($flat),+)) - }; - - // Comma - ([$a:expr], $zip:expr, $pat:pat, [$($flat:expr),*]) => { - zip!([$a,], $zip, $pat, [$($flat),*]) - }; -} - -fn main() { - let p1 = vec![1i32, 2].into_iter(); - let p2 = vec!["10", "20"].into_iter(); - let p3 = vec![100u16, 200].into_iter(); - let p4 = vec![1000i64, 2000].into_iter(); - - let e = zip!([p1,p2,p3,p4]).collect::>(); - assert_eq!(e[0], (1i32,"10",100u16,1000i64)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29844.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29844.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29844.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29844.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::sync::Arc; - -pub struct DescriptorSet<'a> { - pub slots: Vec> -} - -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(Arc) -} - -fn main() { - let _x = DescriptorSet {slots: Vec::new()}; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2989.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2989.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2989.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-2989.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -trait methods { - fn to_bytes(&self) -> Vec ; -} - -impl methods for () { - fn to_bytes(&self) -> Vec { - Vec::new() - } -} - -// the position of this function is significant! - if it comes before methods -// then it works, if it comes after it then it doesn't! -fn to_bools(bitv: Storage) -> Vec { - (0..8).map(|i| { - let w = i / 64; - let b = i % 64; - let x = 1 & (bitv.storage[w] >> b); - x == 1 - }).collect() -} - -struct Storage { storage: Vec } - -pub fn main() { - let bools = vec![false, false, true, false, false, true, true, false]; - let bools2 = to_bools(Storage{storage: vec![0b01100100]}); - - for i in 0..8 { - println!("{} => {} vs {}", i, bools[i], bools2[i]); - } - - assert_eq!(bools, bools2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29914-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29914-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29914-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29914-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -const ARR: [usize; 5] = [5, 4, 3, 2, 1]; - -fn main() { - assert_eq!(3, ARR[ARR[3]]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29914-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29914-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29914-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29914-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -const ARR: [usize; 5] = [5, 4, 3, 2, 1]; -const BLA: usize = ARR[ARR[3]]; - -fn main() { - assert_eq!(3, BLA); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29914.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29914.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29914.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29914.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -#![feature(const_indexing)] - -const ARR: [usize; 5] = [5, 4, 3, 2, 1]; - -fn main() { - assert_eq!(3, ARR[ARR[3]]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue29927-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue29927-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue29927-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue29927-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(min_const_fn)] -const fn f() -> usize { - 5 -} -struct A { - field: usize, -} -fn main() { - let _ = [0; f()]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29927.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29927.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29927.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29927.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(min_const_fn)] -struct A { - field: usize, -} -const fn f() -> usize { - 5 -} -fn main() { - let _ = [0; f()]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29948.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29948.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29948.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-29948.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare compiled with panic=abort by default - -use std::panic; - -impl<'a> panic::UnwindSafe for Foo<'a> {} -impl<'a> panic::RefUnwindSafe for Foo<'a> {} - -struct Foo<'a>(&'a mut bool); - -impl<'a> Drop for Foo<'a> { - fn drop(&mut self) { - *self.0 = true; - } -} - -fn f(t: T) { - t() -} - -fn main() { - let mut ran_drop = false; - { - let x = Foo(&mut ran_drop); - let x = move || { let _ = x; }; - f(x); - } - assert!(ran_drop); - - let mut ran_drop = false; - { - let x = Foo(&mut ran_drop); - let result = panic::catch_unwind(move || { - let x = move || { let _ = x; panic!() }; - f(x); - }); - assert!(result.is_err()); - } - assert!(ran_drop); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30018-nopanic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30018-nopanic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30018-nopanic.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30018-nopanic.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,112 +0,0 @@ -// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// More thorough regression test for Issues #30018 and #30822. This -// attempts to explore different ways that array element construction -// (for both scratch arrays and non-scratch ones) interacts with -// breaks in the control-flow, in terms of the order of evaluation of -// the destructors (which may change; see RFC Issue 744) and the -// number of times that the destructor evaluates for each value (which -// should never exceed 1; this latter case is what #30822 is about). - -use std::cell::RefCell; - -struct D<'a>(&'a RefCell>, i32); - -impl<'a> Drop for D<'a> { - fn drop(&mut self) { - println!("Dropping D({})", self.1); - (self.0).borrow_mut().push(self.1); - } -} - -fn main() { - println!("Start"); - break_during_elem(); - break_after_whole(); - println!("Finis"); -} - -fn break_during_elem() { - let log = &RefCell::new(Vec::new()); - - // CASE 1: Fixed-size array itself is stored in _r slot. - loop { - let _r = [D(log, 10), - D(log, 11), - { D(log, 12); break; }, - D(log, 13)]; - } - assert_eq!(&log.borrow()[..], &[12, 11, 10]); - log.borrow_mut().clear(); - - // CASE 2: Slice (borrow of array) is stored in _r slot. - // This is the case that is actually being reported in #30018. - loop { - let _r = &[D(log, 20), - D(log, 21), - { D(log, 22); break; }, - D(log, 23)]; - } - assert_eq!(&log.borrow()[..], &[22, 21, 20]); - log.borrow_mut().clear(); - - // CASE 3: (Borrow of) slice-index of array is stored in _r slot. - loop { - let _r = &[D(log, 30), - D(log, 31), - { D(log, 32); break; }, - D(log, 33)][..]; - } - assert_eq!(&log.borrow()[..], &[32, 31, 30]); - log.borrow_mut().clear(); -} - -// The purpose of these functions is to test what happens when we -// panic after an array has been constructed in its entirety. -// -// It is meant to act as proof that we still need to continue -// scheduling the destruction of an array even after we've scheduling -// drop for its elements during construction; the latter is tested by -// `fn break_during_elem()`. -fn break_after_whole() { - let log = &RefCell::new(Vec::new()); - - // CASE 1: Fixed-size array itself is stored in _r slot. - loop { - let _r = [D(log, 10), - D(log, 11), - D(log, 12)]; - break; - } - assert_eq!(&log.borrow()[..], &[10, 11, 12]); - log.borrow_mut().clear(); - - // CASE 2: Slice (borrow of array) is stored in _r slot. - loop { - let _r = &[D(log, 20), - D(log, 21), - D(log, 22)]; - break; - } - assert_eq!(&log.borrow()[..], &[20, 21, 22]); - log.borrow_mut().clear(); - - // CASE 3: (Borrow of) slice-index of array is stored in _r slot. - loop { - let _r = &[D(log, 30), - D(log, 31), - D(log, 32)][..]; - break; - } - assert_eq!(&log.borrow()[..], &[30, 31, 32]); - log.borrow_mut().clear(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30018-panic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30018-panic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30018-panic.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30018-panic.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for Issue #30018. This is very similar to the -// original reported test, except that the panic is wrapped in a -// spawned thread to isolate the expected error result from the -// SIGTRAP injected by the drop-flag consistency checking. - -// ignore-emscripten no threads support - -struct Foo; - -impl Drop for Foo { - fn drop(&mut self) {} -} - -fn foo() -> Foo { - panic!(); -} - -fn main() { - use std::thread; - let handle = thread::spawn(|| { - let _ = &[foo()]; - }); - let _ = handle.join(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30081.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30081.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30081.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30081.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2012-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This used to segfault #30081 - -pub enum Instruction { - Increment(i8), - Loop(Box>), -} - -fn main() { - let instrs: Option<(u8, Box)> = None; - instrs.into_iter() - .map(|(_, instr)| instr) - .map(|instr| match *instr { _other => {} }) - .last(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3012-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3012-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3012-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3012-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-3012-1.rs - -// pretty-expanded FIXME #23616 - -extern crate socketlib; - -use socketlib::socket; - -pub fn main() { - let fd: u32 = 1 as u32; - let _sock: Box<_> = Box::new(socket::socket_handle(fd)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30240.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30240.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30240.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30240.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - let &ref a = &[0i32] as &[_]; - assert_eq!(a, &[0i32] as &[_]); - - let &ref a = "hello"; - assert_eq!(a, "hello"); - - match "foo" { - "fool" => unreachable!(), - "foo" => {}, - ref _x => unreachable!() - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3026.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3026.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3026.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3026.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - -use std::collections::HashMap; - -pub fn main() { - let x: Box<_>; - let mut buggy_map: HashMap = HashMap::new(); - x = box 1; - buggy_map.insert(42, &*x); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30371.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30371.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30371.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30371.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![deny(unused_variables)] - -fn main() { - for _ in match return () { - () => Some(0), - } {} -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3037.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3037.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3037.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3037.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 -#![allow(non_camel_case_types)] - -enum what { } - -fn what_to_string(x: what) -> String -{ - match x { - } -} - -pub fn main() -{ -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30490.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30490.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30490.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30490.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-cloudabi no processes -// ignore-emscripten no processes - -// Previously libstd would set stdio descriptors of a child process -// by `dup`ing the requested descriptors to inherit directly into the -// stdio descriptors. This, however, would incorrectly handle cases -// where the descriptors to inherit were already stdio descriptors. -// This test checks to avoid that regression. - -#![cfg_attr(unix, feature(libc))] -#![cfg_attr(windows, allow(unused_imports))] - -#[cfg(unix)] -extern crate libc; - -use std::fs::File; -use std::io::{Read, Write}; -use std::io::{stdout, stderr}; -use std::process::{Command, Stdio}; - -#[cfg(unix)] -use std::os::unix::io::FromRawFd; - -#[cfg(not(unix))] -fn main() { - // Bug not present in Windows -} - -#[cfg(unix)] -fn main() { - let mut args = std::env::args(); - let name = args.next().unwrap(); - let args: Vec = args.collect(); - if let Some("--child") = args.get(0).map(|s| &**s) { - return child(); - } else if !args.is_empty() { - panic!("unknown options"); - } - - let stdout_backup = unsafe { libc::dup(libc::STDOUT_FILENO) }; - let stderr_backup = unsafe { libc::dup(libc::STDERR_FILENO) }; - assert!(stdout_backup > -1); - assert!(stderr_backup > -1); - - let (stdout_reader, stdout_writer) = pipe(); - let (stderr_reader, stderr_writer) = pipe(); - assert!(unsafe { libc::dup2(stdout_writer, libc::STDOUT_FILENO) } > -1); - assert!(unsafe { libc::dup2(stderr_writer, libc::STDERR_FILENO) } > -1); - - // Make sure we close any duplicates of the writer end of the pipe, - // otherwise we can get stuck reading from the pipe which has open - // writers but no one supplying any input - assert_eq!(unsafe { libc::close(stdout_writer) }, 0); - assert_eq!(unsafe { libc::close(stderr_writer) }, 0); - - stdout().write_all("parent stdout\n".as_bytes()).expect("failed to write to stdout"); - stderr().write_all("parent stderr\n".as_bytes()).expect("failed to write to stderr"); - - let child = { - Command::new(name) - .arg("--child") - .stdin(Stdio::inherit()) - .stdout(unsafe { Stdio::from_raw_fd(libc::STDERR_FILENO) }) - .stderr(unsafe { Stdio::from_raw_fd(libc::STDOUT_FILENO) }) - .spawn() - }; - - // The Stdio passed into the Command took over (and closed) std{out, err} - // so we should restore them as they were. - assert!(unsafe { libc::dup2(stdout_backup, libc::STDOUT_FILENO) } > -1); - assert!(unsafe { libc::dup2(stderr_backup, libc::STDERR_FILENO) } > -1); - - // Using File as a shim around the descriptor - let mut read = String::new(); - let mut f: File = unsafe { FromRawFd::from_raw_fd(stdout_reader) }; - f.read_to_string(&mut read).expect("failed to read from stdout file"); - assert_eq!(read, "parent stdout\nchild stderr\n"); - - // Using File as a shim around the descriptor - read.clear(); - let mut f: File = unsafe { FromRawFd::from_raw_fd(stderr_reader) }; - f.read_to_string(&mut read).expect("failed to read from stderr file"); - assert_eq!(read, "parent stderr\nchild stdout\n"); - - assert!(child.expect("failed to execute child process").wait().unwrap().success()); -} - -#[cfg(unix)] -fn child() { - stdout().write_all("child stdout\n".as_bytes()).expect("child failed to write to stdout"); - stderr().write_all("child stderr\n".as_bytes()).expect("child failed to write to stderr"); -} - -#[cfg(unix)] -/// Returns a pipe (reader, writer combo) -fn pipe() -> (i32, i32) { - let mut fds = [0; 2]; - assert_eq!(unsafe { libc::pipe(fds.as_mut_ptr()) }, 0); - (fds[0], fds[1]) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3052.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3052.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3052.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3052.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -type Connection = Box) + 'static>; - -fn f() -> Option { - let mock_connection: Connection = Box::new(|_| {}); - Some(mock_connection) -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30530.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30530.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30530.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30530.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for Issue #30530: alloca's created for storing -// intermediate scratch values during brace-less match arms need to be -// initialized with their drop-flag set to "dropped" (or else we end -// up running the destructors on garbage data at the end of the -// function). - -pub enum Handler { - Default, - #[allow(dead_code)] - Custom(*mut Box), -} - -fn main() { - take(Handler::Default, Box::new(main)); -} - -#[inline(never)] -pub fn take(h: Handler, f: Box) -> Box { - unsafe { - match h { - Handler::Custom(ptr) => *Box::from_raw(ptr), - Handler::Default => f, - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30615.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30615.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30615.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30615.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - &0u8 as *const u8 as *const PartialEq; - &[0u8] as *const [u8; 1] as *const [u8]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30756.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30756.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30756.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30756.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![forbid(unsafe_code)] - -thread_local!(static FOO: u8 = 1); - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30891.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30891.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30891.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-30891.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -const ERROR_CONST: bool = true; - -fn get() -> bool { - false || ERROR_CONST -} - -pub fn main() { - assert_eq!(get(), true); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3091.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3091.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3091.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3091.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let x = 1; - let y = 1; - assert_eq!(&x, &y); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3109.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3109.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3109.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3109.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn main() { - println!("{:?}", ("hi there!", "you")); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3121.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3121.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3121.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3121.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -#![feature(box_syntax)] - -#[derive(Copy, Clone)] -enum side { mayo, catsup, vinegar } -#[derive(Copy, Clone)] -enum order { hamburger, fries(side), shake } -#[derive(Copy, Clone)] -enum meal { to_go(order), for_here(order) } - -fn foo(m: Box, cond: bool) { - match *m { - meal::to_go(_) => { } - meal::for_here(_) if cond => {} - meal::for_here(order::hamburger) => {} - meal::for_here(order::fries(_s)) => {} - meal::for_here(order::shake) => {} - } -} - -pub fn main() { - foo(box meal::for_here(order::hamburger), true) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31260.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31260.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31260.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31260.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub struct Struct { - pub field: K, -} - -static STRUCT: Struct<&'static [u8]> = Struct { - field: {&[1]} -}; - -static STRUCT2: Struct<&'static [u8]> = Struct { - field: &[1] -}; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31267-additional.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31267-additional.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31267-additional.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31267-additional.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#[derive(Clone, Copy, Debug)] -struct Bar; - -const BAZ: Bar = Bar; - -#[derive(Debug)] -struct Foo([Bar; 1]); - -struct Biz; - -impl Biz { - const BAZ: Foo = Foo([BAZ; 1]); -} - -fn main() { - let foo = Biz::BAZ; - println!("{:?}", foo); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31267.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31267.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31267.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31267.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for issue #31267 - - -struct Foo; - -impl Foo { - const FOO: [i32; 3] = [0; 3]; -} - -pub fn main() { - let foo = Foo::FOO; - assert_eq!(foo, [0i32, 0, 0]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31299.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31299.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31299.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31299.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #31299. This was generating an overflow error -// because of eager normalization: -// -// proving `M: Sized` requires -// - proving `PtrBack>: Sized` requires -// - normalizing `Vec< as Front>::Back>>: Sized` requires -// - proving `Vec: Front` requires -// - `M: Sized` <-- cycle! -// -// If we skip the normalization step, though, everything goes fine. -// -// This could be fixed by implementing lazy normalization everywhere. -// -// However, we want this to work before then. For that, when checking -// whether a type is Sized we only check that the tails are Sized. As -// PtrBack does not have a tail, we don't need to normalize anything -// and this compiles - -trait Front { - type Back; -} - -impl Front for Vec { - type Back = Vec; -} - -struct PtrBack(Vec); - -struct M(PtrBack>); - -fn main() { - std::mem::size_of::(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_3136_b.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_3136_b.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_3136_b.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_3136_b.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue_3136_a.rc - -// pretty-expanded FIXME #23616 - -extern crate issue_3136_a; -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3149.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3149.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3149.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3149.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_snake_case)] -// pretty-expanded FIXME #23616 - -fn Matrix4(m11: T, m12: T, m13: T, m14: T, - m21: T, m22: T, m23: T, m24: T, - m31: T, m32: T, m33: T, m34: T, - m41: T, m42: T, m43: T, m44: T) - -> Matrix4 { - Matrix4 { - m11: m11, m12: m12, m13: m13, m14: m14, - m21: m21, m22: m22, m23: m23, m24: m24, - m31: m31, m32: m32, m33: m33, m34: m34, - m41: m41, m42: m42, m43: m43, m44: m44 - } -} - -struct Matrix4 { - m11: T, m12: T, m13: T, m14: T, - m21: T, m22: T, m23: T, m24: T, - m31: T, m32: T, m33: T, m34: T, - m41: T, m42: T, m43: T, m44: T, -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31597.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31597.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31597.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31597.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Make { - type Out; - - fn make() -> Self::Out; -} - -impl Make for () { - type Out = (); - - fn make() -> Self::Out {} -} - -// Also make sure we don't hit an ICE when the projection can't be known -fn f() -> ::Out { loop {} } - -// ...and that it works with a blanket impl -trait Tr { - type Assoc; -} - -impl Tr for T { - type Assoc = (); -} - -fn g() -> ::Assoc { } - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31702.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31702.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31702.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31702.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-31702-1.rs -// aux-build:issue-31702-2.rs -// ignore-test: FIXME(#31702) when this test was added it was thought that the -// accompanying llvm update would fix it, but -// unfortunately it appears that was not the case. In -// the interest of not deleting the test, though, -// this is just tagged with ignore-test - -// this test is actually entirely in the linked library crates - -extern crate issue_31702_1; -extern crate issue_31702_2; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31776.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31776.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31776.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-31776.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Various scenarios in which `pub` is required in blocks - -struct S; - -mod m { - fn f() { - impl ::S { - pub fn s(&self) {} - } - } -} - -// ------------------------------------------------------ - -pub trait Tr { - type A; -} -pub struct S1; - -fn f() { - pub struct Z; - - impl ::Tr for ::S1 { - type A = Z; // Private-in-public error unless `struct Z` is pub - } -} - -// ------------------------------------------------------ - -trait Tr1 { - type A; - fn pull(&self) -> Self::A; -} -struct S2; - -mod m1 { - fn f() { - pub struct Z { - pub field: u8 - } - - impl ::Tr1 for ::S2 { - type A = Z; - fn pull(&self) -> Self::A { Z{field: 10} } - } - } -} - -// ------------------------------------------------------ - -fn main() { - S.s(); // Privacy error, unless `fn s` is pub - let a = S2.pull().field; // Privacy error unless `field: u8` is pub -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32008.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32008.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32008.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32008.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests that binary operators allow subtyping on both the LHS and RHS, -// and as such do not introduce unnecessarily strict lifetime constraints. - -use std::ops::Add; - -struct Foo; - -impl<'a> Add<&'a Foo> for &'a Foo { - type Output = (); - fn add(self, rhs: &'a Foo) {} -} - -fn try_to_add(input: &Foo) { - let local = Foo; - - // Manual reborrow worked even with invariant trait search. - &*input + &local; - - // Direct use of the reference on the LHS requires additional - // subtyping before searching (invariantly) for `LHS: Add`. - input + &local; -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3211.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3211.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3211.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3211.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn main() { - let mut x = 0; - for _ in 0..4096 { x += 1; } - assert_eq!(x, 4096); - println!("x = {}", x); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3220.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3220.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3220.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3220.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 - -struct thing { x: isize, } - -impl Drop for thing { - fn drop(&mut self) {} -} - -fn thing() -> thing { - thing { - x: 0 - } -} - -impl thing { - pub fn f(self) {} -} - -pub fn main() { - let z = thing(); - (z).f(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32292.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32292.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32292.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32292.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![deny(warnings)] - -#[derive(Hash, Ord, PartialOrd, Eq, PartialEq, Debug, Clone, Copy)] -struct Foo; - -fn main() { - let _ = Foo; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32324.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32324.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32324.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32324.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(dead_code)] - -trait Resources { - type Buffer: Copy; -} - -#[derive(Copy, Clone)] -struct ConstantBufferSet( - pub R::Buffer -); - -#[derive(Copy, Clone)] -enum It {} -impl Resources for It { - type Buffer = u8; -} - -#[derive(Copy, Clone)] -enum Command { - BindConstantBuffers(ConstantBufferSet) -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32389.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32389.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32389.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32389.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn foo() -> T { loop {} } - -fn test() { - let ref mut a: &mut FnMut((i8,), i16) = foo(); - a((0,), 0); -} - -fn main() { - let _ = test; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32518.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32518.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32518.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32518.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// no-prefer-dynamic -// aux-build:cgu_test.rs -// aux-build:cgu_test_a.rs -// aux-build:cgu_test_b.rs - -extern crate cgu_test_a; -extern crate cgu_test_b; - -fn main() { - cgu_test_a::a::a(); - cgu_test_b::a::a(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32805.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32805.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32805.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32805.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn const_mir() -> f32 { 9007199791611905.0 } - -fn main() { - let original = "9007199791611905.0"; // (1<<53)+(1<<29)+1 - let expected = "9007200000000000"; - - assert_eq!(const_mir().to_string(), expected); - assert_eq!(original.parse::().unwrap().to_string(), expected); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3290.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3290.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3290.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3290.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -pub fn main() { - let mut x: Box<_> = box 3; - x = x; - assert_eq!(*x, 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32947.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32947.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32947.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-32947.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten FIXME(#45351) - -#![feature(repr_simd, test)] - -extern crate test; - -#[repr(simd)] -pub struct Mu64(pub u64, pub u64, pub u64, pub u64); - -fn main() { - // This ensures an unaligned pointer even in optimized builds, though LLVM - // gets enough type information to actually not mess things up in that case, - // but at the time of writing this, it's enough to trigger the bug in - // non-optimized builds - unsafe { - let memory = &mut [0u64; 8] as *mut _ as *mut u8; - let misaligned_ptr: &mut [u8; 32] = { - std::mem::transmute(memory.offset(1)) - }; - *misaligned_ptr = std::mem::transmute(Mu64(1, 1, 1, 1)); - test::black_box(memory); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33096.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33096.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33096.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33096.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: -g - -use std::ops::Deref; - -trait Foo { - fn foo() {} -} - -impl Foo for u8 {} - -fn bar() where T::Target: Foo { - <::Target as Foo>::foo() -} - -fn main() { - bar::<&u8>(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33185.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33185.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33185.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33185.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(dead_code)] - -#[macro_export] -macro_rules! state { - ( $( $name:ident : $field:ty )* ) => ( - #[derive(Default)] - struct State { - $($name : $field),* - } - ) -} - -state! { x: i64 } - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33187.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33187.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33187.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33187.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct Foo(::Data); - -impl Copy for Foo where ::Data: Copy { } -impl Clone for Foo where ::Data: Clone { - fn clone(&self) -> Self { Foo(self.0.clone()) } -} - -trait Repr { - type Data; -} - -impl Repr for A { - type Data = u32; -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33202.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33202.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33202.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33202.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[repr(C)] -pub enum CPOption { - PSome(T), -} - -fn main() { - println!("sizeof CPOption {}", std::mem::size_of::>()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33264.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33264.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33264.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33264.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// only-x86_64 - -#![allow(dead_code, non_upper_case_globals)] -#![feature(asm)] - -#[repr(C)] -pub struct D32x4(f32,f32,f32,f32); - -impl D32x4 { - fn add(&self, vec: Self) -> Self { - unsafe { - let ret: Self; - asm!(" - movaps $1, %xmm1 - movaps $2, %xmm2 - addps %xmm1, %xmm2 - movaps $xmm1, $0 - " - : "=r"(ret) - : "1"(self), "2"(vec) - : "xmm1", "xmm2" - ); - ret - } - } -} - -fn main() { } - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33287.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33287.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33287.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33287.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -const A: [u32; 1] = [0]; - -fn test() { - let range = A[1]..; -} - -fn main() { } - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33387.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33387.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33387.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33387.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(rustc_attrs)] - -use std::sync::Arc; - -trait Foo { - fn get(&self) -> [u8; 2]; -} - -impl Foo for [u8; 2] { - fn get(&self) -> [u8; 2] { - *self - } -} - -struct Bar(T); - -fn unsize_fat_ptr<'a>(x: &'a Bar) -> &'a Bar { - x -} - -fn unsize_nested_fat_ptr(x: Arc) -> Arc { - x -} - -fn main() { - let x: Box> = Box::new(Bar([1,2])); - assert_eq!(unsize_fat_ptr(&*x).0.get(), [1, 2]); - - let x: Arc = Arc::new([3, 4]); - assert_eq!(unsize_nested_fat_ptr(x).get(), [3, 4]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-333.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-333.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-333.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-333.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn quux(x: T) -> T { let f = id::; return f(x); } - -fn id(x: T) -> T { return x; } - -pub fn main() { assert_eq!(quux(10), 10); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33461.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33461.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33461.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33461.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::marker::PhantomData; - -struct TheType { - t: PhantomData -} - -pub trait TheTrait { - type TheAssociatedType; -} - -impl TheTrait for () { - type TheAssociatedType = (); -} - -pub trait Shape { - fn doit(&self) { - } -} - -impl Shape

for TheType { -} - -fn main() { - let ball = TheType { t: PhantomData }; - let handle: &Shape<()> = &ball; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33498.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33498.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33498.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33498.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn main() { - let x = (0, 2); - - match x { - (0, ref y) => {} - (y, 0) => {} - _ => (), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33537.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33537.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33537.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33537.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(min_const_fn)] - -const fn foo() -> *const i8 { - b"foo" as *const _ as *const i8 -} - -const fn bar() -> i32 { - *&{(1, 2, 3).1} -} - -fn main() { - assert_eq!(foo(), b"foo" as *const _ as *const i8); - assert_eq!(bar(), 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33687.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33687.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33687.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33687.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(unboxed_closures)] -#![feature(fn_traits)] - -struct Test; - -impl FnOnce<(u32, u32)> for Test { - type Output = u32; - - extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 { - a + b - } -} - -fn main() { - assert_eq!(Test(1u32, 2u32), 3u32); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33770.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33770.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33770.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33770.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-cloudabi no processes -// ignore-emscripten no processes - -use std::process::{Command, Stdio}; -use std::env; -use std::sync::{Mutex, RwLock}; -use std::time::Duration; -use std::thread; - -fn test_mutex() { - let m = Mutex::new(0); - let _g = m.lock().unwrap(); - let _g2 = m.lock().unwrap(); -} - -fn test_try_mutex() { - let m = Mutex::new(0); - let _g = m.lock().unwrap(); - let _g2 = m.try_lock().unwrap(); -} - -fn test_rwlock_ww() { - let m = RwLock::new(0); - let _g = m.write().unwrap(); - let _g2 = m.write().unwrap(); -} - -fn test_try_rwlock_ww() { - let m = RwLock::new(0); - let _g = m.write().unwrap(); - let _g2 = m.try_write().unwrap(); -} - -fn test_rwlock_rw() { - let m = RwLock::new(0); - let _g = m.read().unwrap(); - let _g2 = m.write().unwrap(); -} - -fn test_try_rwlock_rw() { - let m = RwLock::new(0); - let _g = m.read().unwrap(); - let _g2 = m.try_write().unwrap(); -} - -fn test_rwlock_wr() { - let m = RwLock::new(0); - let _g = m.write().unwrap(); - let _g2 = m.read().unwrap(); -} - -fn test_try_rwlock_wr() { - let m = RwLock::new(0); - let _g = m.write().unwrap(); - let _g2 = m.try_read().unwrap(); -} - -fn main() { - let args: Vec = env::args().collect(); - if args.len() > 1 { - match &*args[1] { - "mutex" => test_mutex(), - "try_mutex" => test_try_mutex(), - "rwlock_ww" => test_rwlock_ww(), - "try_rwlock_ww" => test_try_rwlock_ww(), - "rwlock_rw" => test_rwlock_rw(), - "try_rwlock_rw" => test_try_rwlock_rw(), - "rwlock_wr" => test_rwlock_wr(), - "try_rwlock_wr" => test_try_rwlock_wr(), - _ => unreachable!(), - } - // If we reach this point then the test failed - println!("TEST FAILED: {}", args[1]); - } else { - let mut v = vec![]; - v.push(Command::new(&args[0]).arg("mutex").stderr(Stdio::null()).spawn().unwrap()); - v.push(Command::new(&args[0]).arg("try_mutex").stderr(Stdio::null()).spawn().unwrap()); - v.push(Command::new(&args[0]).arg("rwlock_ww").stderr(Stdio::null()).spawn().unwrap()); - v.push(Command::new(&args[0]).arg("try_rwlock_ww").stderr(Stdio::null()).spawn().unwrap()); - v.push(Command::new(&args[0]).arg("rwlock_rw").stderr(Stdio::null()).spawn().unwrap()); - v.push(Command::new(&args[0]).arg("try_rwlock_rw").stderr(Stdio::null()).spawn().unwrap()); - v.push(Command::new(&args[0]).arg("rwlock_wr").stderr(Stdio::null()).spawn().unwrap()); - v.push(Command::new(&args[0]).arg("try_rwlock_wr").stderr(Stdio::null()).spawn().unwrap()); - - thread::sleep(Duration::new(1, 0)); - - // Make sure all subprocesses either panicked or were killed because they deadlocked - for mut c in v { - c.kill().ok(); - assert!(!c.wait().unwrap().success()); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3389.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3389.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3389.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3389.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -struct trie_node { - content: Vec , - children: Vec , -} - -fn print_str_vector(vector: Vec ) { - for string in &vector { - println!("{}", *string); - } -} - -pub fn main() { - let mut node: trie_node = trie_node { - content: Vec::new(), - children: Vec::new() - }; - let v = vec!["123".to_string(), "abc".to_string()]; - node.content = vec!["123".to_string(), "abc".to_string()]; - print_str_vector(v); - print_str_vector(node.content.clone()); - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33903.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33903.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33903.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33903.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue 33903: -// Built-in indexing should be used even when the index is not -// trivially an integer -// Only built-in indexing can be used in constant expressions - -const FOO: i32 = [12, 34][0 + 1]; - -fn main() {} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33992.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33992.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33992.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-33992.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-windows -// ignore-macos - -#![feature(linkage)] - -#[linkage = "common"] -pub static mut TEST1: u32 = 0u32; - -#[linkage = "external"] -pub static TEST2: bool = true; - -#[linkage = "internal"] -pub static TEST3: bool = true; - -#[linkage = "linkonce"] -pub static TEST4: bool = true; - -#[linkage = "linkonce_odr"] -pub static TEST5: bool = true; - -#[linkage = "private"] -pub static TEST6: bool = true; - -#[linkage = "weak"] -pub static TEST7: bool = true; - -#[linkage = "weak_odr"] -pub static TEST8: bool = true; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34053.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34053.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34053.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34053.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; - -static DROP_COUNTER: AtomicUsize = ATOMIC_USIZE_INIT; - -struct A(i32); - -impl Drop for A { - fn drop(&mut self) { - // update global drop count - DROP_COUNTER.fetch_add(1, Ordering::SeqCst); - } -} - -static FOO: A = A(123); -const BAR: A = A(456); - -impl A { - const BAZ: A = A(789); -} - -fn main() { - assert_eq!(DROP_COUNTER.load(Ordering::SeqCst), 0); - assert_eq!(&FOO.0, &123); - assert_eq!(DROP_COUNTER.load(Ordering::SeqCst), 0); - assert_eq!(BAR.0, 456); - assert_eq!(DROP_COUNTER.load(Ordering::SeqCst), 1); - assert_eq!(A::BAZ.0, 789); - assert_eq!(DROP_COUNTER.load(Ordering::SeqCst), 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34074.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34074.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34074.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34074.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Make sure several unnamed function parameters don't conflict with each other - -trait Tr { - #[allow(anonymous_parameters)] - fn f(u8, u8) {} -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34194.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34194.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34194.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34194.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(dead_code)] - -struct A { - a: &'static (), -} - -static B: &'static A = &A { a: &() }; -static C: &'static A = &B; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3424.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3424.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3424.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3424.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -// rustc --test ignores2.rs && ./ignores2 - -pub struct Path; - -type rsrc_loader = Box Result>; - -fn tester() -{ - let mut loader: rsrc_loader = Box::new(move |_path| { - Ok("more blah".to_string()) - }); - - let path = Path; - assert!(loader(&path).is_ok()); -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3429.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3429.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3429.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3429.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub fn main() { - let x = 1_usize; - let y = || x; - let _z = y(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34427.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34427.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34427.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34427.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #34427: On ARM, the code in `foo` at one time was generating -// a machine code instruction of the form: `str r0, [r0, rN]!` (for -// some N), which is not legal because the source register and base -// register cannot be identical in the preindexed form signalled by -// the `!`. -// -// See LLVM bug: https://llvm.org/bugs/show_bug.cgi?id=28809 - -#[inline(never)] -fn foo(n: usize) -> Vec> { - (0..n).map(|_| None).collect() -} - -fn main() { - let _ = (foo(10), foo(32)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3447.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3447.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3447.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3447.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_snake_case)] -#![allow(non_camel_case_types)] -#![feature(box_syntax)] - -use std::cell::RefCell; - -static S: &'static str = "str"; - -struct list { - element: T, - next: Option>>> -} - -impl list { - pub fn addEnd(&mut self, element: T) { - let newList = list { - element: element, - next: None - }; - - self.next = Some(box RefCell::new(newList)); - } -} - -pub fn main() { - let ls = list { - element: S, - next: None - }; - println!("{}", ls.element); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34503.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34503.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34503.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34503.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - struct X; - trait Foo { - fn foo(&self) where (T, Option): Ord {} - fn bar(&self, x: &Option) -> bool - where Option: Ord { *x < *x } - } - impl Foo for () {} - let _ = &() as &Foo; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34569.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34569.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34569.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34569.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags:-g - -// In this test we just want to make sure that the code below does not lead to -// a debuginfo verification assertion during compilation. This was caused by the -// closure in the guard being codegened twice due to how match expressions are -// handled. -// -// See https://github.com/rust-lang/rust/issues/34569 for details. - -fn main() { - match 0 { - e if (|| { e == 0 })() => {}, - 1 => {}, - _ => {} - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34571.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34571.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34571.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34571.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[repr(u8)] -enum Foo { - Foo(u8), -} - -fn main() { - match Foo::Foo(1) { - _ => () - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34751.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34751.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34751.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34751.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// #34751 ICE: 'rustc' panicked at 'assertion failed: !substs.has_regions_escaping_depth(0)' - -#[allow(dead_code)] - -use std::marker::PhantomData; - -fn f<'a>(PhantomData::<&'a u8>: PhantomData<&'a u8>) {} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34780.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34780.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34780.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34780.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] -#![feature(associated_consts)] - -use std::marker::PhantomData; - -trait Tr<'a> { - const C: PhantomData<&'a u8> = PhantomData::<&'a u8>; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34784.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34784.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34784.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34784.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -const C: *const u8 = &0; - -fn foo(x: *const u8) { - match x { - C => {} - _ => {} - } -} - -const D: *const [u8; 4] = b"abcd"; - -fn main() { - match D { - D => {} - _ => {} - } -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34796.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34796.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34796.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34796.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This test case exposes conditions where the encoding of a trait object type -// with projection predicates would differ between this crate and the upstream -// crate, because the predicates were encoded in different order within each -// crate. This led to different symbol hashes of functions using these type, -// which in turn led to linker errors because the two crates would not agree on -// the symbol name. -// The fix was to make the order in which predicates get encoded stable. - -// aux-build:issue34796aux.rs -extern crate issue34796aux; - -fn mk() -> T { loop {} } - -struct Data { - data: T, - error: E, -} - -fn main() { - issue34796aux::bar(|()| { - Data::<(), std::io::Error> { - data: mk(), - error: mk(), - } - }) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34798.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34798.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34798.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34798.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![forbid(improper_ctypes)] -#![allow(dead_code)] - -#[repr(C)] -pub struct Foo { - size: u8, - __value: ::std::marker::PhantomData, -} - -#[repr(C)] -pub struct ZeroSizeWithPhantomData(::std::marker::PhantomData); - -#[repr(C)] -pub struct Bar { - size: u8, - baz: ZeroSizeWithPhantomData, -} - -extern "C" { - pub fn bar(_: *mut Foo, _: *mut Bar); -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34932.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34932.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34932.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-34932.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags:--test -// rustc-env:RUSTC_BOOTSTRAP_KEY= -#![cfg(any())] // This test should be configured away -#![feature(rustc_attrs)] // Test that this is allowed on stable/beta -#![feature(iter_arith_traits)] // Test that this is not unused -#![deny(unused_features)] - -#[test] -fn dummy() { - let () = "this should not reach type-checking"; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3500.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3500.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3500.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3500.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub fn main() { - let x = &Some(1); - match x { - &Some(_) => (), - &None => (), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-35376.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-35376.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-35376.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-35376.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(specialization)] - -fn main() {} - -pub trait Alpha { } - -pub trait Beta { - type Event; -} - -pub trait Delta { - type Handle; - fn process(&self); -} - -pub struct Parent(A, T); - -impl Delta for Parent -where A: Alpha, - T: Delta, - T::Handle: Beta::Event> { - type Handle = Handle; - default fn process(&self) { - unimplemented!() - } -} - -impl Delta for Parent -where A: Alpha + Alpha, - T: Delta, - T::Handle: Beta::Event> { - fn process(&self) { - unimplemented!() - } -} - -pub struct Handle; - -impl Beta for Handle { - type Event = (); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-35423.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-35423.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-35423.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-35423.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main () { - let x = 4; - match x { - ref r if *r < 0 => println!("got negative num {} < 0", r), - e @ 1 ..= 100 => println!("got number within range [1,100] {}", e), - _ => println!("no"), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-35546.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-35546.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-35546.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-35546.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #35546. Check that we are able to codegen -// this. Before we had problems because of the drop glue signature -// around dropping a trait object (specifically, when dropping the -// `value` field of `Node`). - -struct Node { - next: Option>>, - value: T, -} - -fn clear(head: &mut Option>>) { - match head.take() { - Some(node) => *head = node.next, - None => (), - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3556.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3556.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3556.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3556.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#[derive(Debug)] -enum Token { - Text(String), - ETag(Vec, String), - UTag(Vec, String), - Section(Vec, bool, Vec, String, - String, String, String, String), - IncompleteSection(Vec, bool, String, bool), - Partial(String, String, String), -} - -fn check_strs(actual: &str, expected: &str) -> bool -{ - if actual != expected - { - println!("Found {}, but expected {}", actual, expected); - return false; - } - return true; -} - -pub fn main() -{ - let t = Token::Text("foo".to_string()); - let u = Token::Section(vec!["alpha".to_string()], - true, - vec![t], - "foo".to_string(), - "foo".to_string(), "foo".to_string(), "foo".to_string(), - "foo".to_string()); - let v = format!("{:?}", u); // this is the line that causes the seg fault - assert!(!v.is_empty()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3559.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3559.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3559.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3559.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::collections::HashMap; - -fn check_strs(actual: &str, expected: &str) -> bool { - if actual != expected { - println!("Found {}, but expected {}", actual, expected); - return false; - } - return true; -} - -pub fn main() { - let mut table = HashMap::new(); - table.insert("one".to_string(), 1); - table.insert("two".to_string(), 2); - assert!(check_strs(&format!("{:?}", table), "{\"one\": 1, \"two\": 2}") || - check_strs(&format!("{:?}", table), "{\"two\": 2, \"one\": 1}")); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-35600.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-35600.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-35600.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-35600.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Foo { - type bar; - fn bar(); -} - -impl Foo for () { - type bar = (); - fn bar() {} -} - -fn main() { - let x: <() as Foo>::bar = (); - <()>::bar(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3563-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3563-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3563-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3563-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait Canvas { - fn add_point(&self, point: &isize); - fn add_points(&self, shapes: &[isize]) { - for pt in shapes { - self.add_point(pt) - } - } - -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3563-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3563-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3563-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3563-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,189 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_snake_case)] - -// ASCII art shape renderer. Demonstrates traits, impls, operator overloading, -// non-copyable struct, unit testing. To run execute: rustc --test shapes.rs && -// ./shapes - -// Rust's std library is tightly bound to the language itself so it is -// automatically linked in. However the extra library is designed to be -// optional (for code that must run on constrained environments like embedded -// devices or special environments like kernel code) so it must be explicitly -// linked in. - -// Extern mod controls linkage. Use controls the visibility of names to modules -// that are already linked in. Using WriterUtil allows us to use the write_line -// method. - -use std::fmt; -use std::iter::repeat; -use std::slice; - -// Represents a position on a canvas. -#[derive(Copy, Clone)] -struct Point { - x: isize, - y: isize, -} - -// Represents an offset on a canvas. (This has the same structure as a Point. -// but different semantics). -#[derive(Copy, Clone)] -struct Size { - width: isize, - height: isize, -} - -#[derive(Copy, Clone)] -struct Rect { - top_left: Point, - size: Size, -} - -// Contains the information needed to do shape rendering via ASCII art. -struct AsciiArt { - width: usize, - height: usize, - fill: char, - lines: Vec > , - - // This struct can be quite large so we'll disable copying: developers need - // to either pass these structs around via references or move them. -} - -impl Drop for AsciiArt { - fn drop(&mut self) {} -} - -// It's common to define a constructor sort of function to create struct instances. -// If there is a canonical constructor it is typically named the same as the type. -// Other constructor sort of functions are typically named from_foo, from_bar, etc. -fn AsciiArt(width: usize, height: usize, fill: char) -> AsciiArt { - // Build a vector of vectors containing blank characters for each position in - // our canvas. - let lines = vec![vec!['.'; width]; height]; - - // Rust code often returns values by omitting the trailing semi-colon - // instead of using an explicit return statement. - AsciiArt {width: width, height: height, fill: fill, lines: lines} -} - -// Methods particular to the AsciiArt struct. -impl AsciiArt { - fn add_pt(&mut self, x: isize, y: isize) { - if x >= 0 && x < self.width as isize { - if y >= 0 && y < self.height as isize { - // Note that numeric types don't implicitly convert to each other. - let v = y as usize; - let h = x as usize; - - // Vector subscripting will normally copy the element, but &v[i] - // will return a reference which is what we need because the - // element is: - // 1) potentially large - // 2) needs to be modified - let row = &mut self.lines[v]; - row[h] = self.fill; - } - } - } -} - -// Allows AsciiArt to be converted to a string using the libcore ToString trait. -// Note that the %s fmt! specifier will not call this automatically. -impl fmt::Display for AsciiArt { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - // Convert each line into a string. - let lines = self.lines.iter() - .map(|line| line.iter().cloned().collect()) - .collect::>(); - - // Concatenate the lines together using a new-line. - write!(f, "{}", lines.join("\n")) - } -} - -// This is similar to an interface in other languages: it defines a protocol which -// developers can implement for arbitrary concrete types. -trait Canvas { - fn add_point(&mut self, shape: Point); - fn add_rect(&mut self, shape: Rect); - - // Unlike interfaces traits support default implementations. - // Got an ICE as soon as I added this method. - fn add_points(&mut self, shapes: &[Point]) { - for pt in shapes {self.add_point(*pt)}; - } -} - -// Here we provide an implementation of the Canvas methods for AsciiArt. -// Other implementations could also be provided (e.g. for PDF or Apple's Quartz) -// and code can use them polymorphically via the Canvas trait. -impl Canvas for AsciiArt { - fn add_point(&mut self, shape: Point) { - self.add_pt(shape.x, shape.y); - } - - fn add_rect(&mut self, shape: Rect) { - // Add the top and bottom lines. - for x in shape.top_left.x..shape.top_left.x + shape.size.width { - self.add_pt(x, shape.top_left.y); - self.add_pt(x, shape.top_left.y + shape.size.height - 1); - } - - // Add the left and right lines. - for y in shape.top_left.y..shape.top_left.y + shape.size.height { - self.add_pt(shape.top_left.x, y); - self.add_pt(shape.top_left.x + shape.size.width - 1, y); - } - } -} - -// Rust's unit testing framework is currently a bit under-developed so we'll use -// this little helper. -pub fn check_strs(actual: &str, expected: &str) -> bool { - if actual != expected { - println!("Found:\n{}\nbut expected\n{}", actual, expected); - return false; - } - return true; -} - - -fn test_ascii_art_ctor() { - let art = AsciiArt(3, 3, '*'); - assert!(check_strs(&art.to_string(), "...\n...\n...")); -} - - -fn test_add_pt() { - let mut art = AsciiArt(3, 3, '*'); - art.add_pt(0, 0); - art.add_pt(0, -10); - art.add_pt(1, 2); - assert!(check_strs(&art.to_string(), "*..\n...\n.*.")); -} - - -fn test_shapes() { - let mut art = AsciiArt(4, 4, '*'); - art.add_rect(Rect {top_left: Point {x: 0, y: 0}, size: Size {width: 4, height: 4}}); - art.add_point(Point {x: 2, y: 2}); - assert!(check_strs(&art.to_string(), "****\n*..*\n*.**\n****")); -} - -pub fn main() { - test_ascii_art_ctor(); - test_add_pt(); - test_shapes(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3574.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3574.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3574.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3574.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// rustc --test match_borrowed_str.rs.rs && ./match_borrowed_str.rs - - -fn compare(x: &str, y: &str) -> bool { - match x { - "foo" => y == "foo", - _ => y == "bar", - } -} - -pub fn main() { - assert!(compare("foo", "foo")); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-35815.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-35815.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-35815.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-35815.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::mem; - -struct Foo { - a: i64, - b: bool, - c: T, -} - -fn main() { - let foo: &Foo = &Foo { a: 1, b: false, c: 2i32 }; - let foo_unsized: &Foo = foo; - assert_eq!(mem::size_of_val(foo), mem::size_of_val(foo_unsized)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36023.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36023.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36023.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36023.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::ops::Deref; - -fn main() { - if env_var("FOOBAR").as_ref().map(Deref::deref).ok() == Some("yes") { - panic!() - } - - let env_home: Result = Ok("foo-bar-baz".to_string()); - let env_home = env_home.as_ref().map(Deref::deref).ok(); - - if env_home == Some("") { panic!() } -} - -#[inline(never)] -fn env_var(s: &str) -> Result { - Err(VarError::NotPresent) -} - -pub enum VarError { - NotPresent, - NotUnicode(String), -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36036-associated-type-layout.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36036-associated-type-layout.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36036-associated-type-layout.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36036-associated-type-layout.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue 36036: computing the layout of a type composed from another -// trait's associated type caused compiler to ICE when the associated -// type was allowed to be unsized, even though the known instantiated -// type is itself sized. - -#![allow(dead_code)] - -trait Context { - type Container: ?Sized; -} - -impl Context for u16 { - type Container = u8; -} - -struct Wrapper { - container: &'static C::Container -} - -fn foobar(_: Wrapper) {} - -static VALUE: u8 = 0; - -fn main() { - foobar(Wrapper { container: &VALUE }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36053.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36053.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36053.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36053.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #36053. ICE was caused due to obligations being -// added to a special, dedicated fulfillment cx during a -// probe. Problem seems to be related to the particular definition of -// `FusedIterator` in std but I was not able to isolate that into an -// external crate. - -use std::iter::FusedIterator; - -struct Thing<'a>(&'a str); -impl<'a> Iterator for Thing<'a> { - type Item = &'a str; - fn next(&mut self) -> Option<&'a str> { - None - } -} - -impl<'a> FusedIterator for Thing<'a> {} - -fn main() { - Thing("test").fuse().filter(|_| true).count(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36075.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36075.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36075.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36075.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait DeclarationParser { - type Declaration; -} - -struct DeclarationListParser<'i, I, P> - where P: DeclarationParser -{ - input: &'i (), - parser: P -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3609.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3609.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3609.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3609.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::thread; -use std::sync::mpsc::Sender; - -type RingBuffer = Vec ; -type SamplesFn = Box; - -enum Msg -{ - GetSamples(String, SamplesFn), // sample set name, callback which receives samples -} - -fn foo(name: String, samples_chan: Sender) { - thread::spawn(move|| { - let mut samples_chan = samples_chan; - - let callback: SamplesFn = Box::new(move |buffer| { - for i in 0..buffer.len() { - println!("{}: {}", i, buffer[i]) - } - }); - - samples_chan.send(Msg::GetSamples(name.clone(), callback)); - }).join(); -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36139-normalize-closure-sig.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36139-normalize-closure-sig.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36139-normalize-closure-sig.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36139-normalize-closure-sig.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Previously the closure's argument would be inferred to -// >::Item, causing an error in MIR type -// checking - -trait ITrait<'a> {type Item;} - -struct S {} - -impl<'a> ITrait<'a> for S { type Item = &'a mut usize; } - -fn m(_: F) - where I: for<'a> ITrait<'a>, - F: for<'a> FnMut(>::Item) { } - - -fn main() { - m::(|x| { *x += 1; }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36260.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36260.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36260.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36260.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2012-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Make sure this compiles without getting a linker error because of missing -// drop-glue because the collector missed adding drop-glue for the closure: - -fn create_fn() -> Box { - let text = String::new(); - - Box::new(move || { let _ = &text; }) -} - -fn main() { - let _ = create_fn(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36278-prefix-nesting.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36278-prefix-nesting.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36278-prefix-nesting.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36278-prefix-nesting.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue 36278: On an unsized struct with >1 level of nontrivial -// nesting, ensure we are computing dynamic size of prefix correctly. - -use std::mem; - -const SZ: usize = 100; -struct P([u8; SZ], T); - -type Ack = P>; - -fn main() { - let size_of_sized; let size_of_unsized; - let x: Box> = Box::new(P([0; SZ], P([0; SZ], [0; 0]))); - size_of_sized = mem::size_of_val::>(&x); - let y: Box> = x; - size_of_unsized = mem::size_of_val::>(&y); - assert_eq!(size_of_sized, size_of_unsized); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36381.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36381.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36381.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36381.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #36381. The monomorphization collector was asserting that -// there are no projection types, but the `<&str as -// StreamOnce>::Position` projection contained a late-bound region, -// and we don't currently normalize in that case until the function is -// actually invoked. - -pub trait StreamOnce { - type Position; -} - -impl<'a> StreamOnce for &'a str { - type Position = usize; -} - -pub fn parser(_: F) { -} - -fn follow(_: &str) -> <&str as StreamOnce>::Position { - panic!() -} - -fn main() { - parser(follow); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36401.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36401.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36401.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36401.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Debug)] -pub enum Event { - Key(u8), - Resize, - Unknown(u16), -} - -static XTERM_SINGLE_BYTES : [(u8, Event); 1] = [(1, Event::Resize)]; - -fn main() { - match XTERM_SINGLE_BYTES[0] { - (1, Event::Resize) => {}, - ref bad => panic!("unexpected {:?}", bad) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36474.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36474.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36474.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36474.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - remove_axis(&3, 0); -} - -trait Dimension { - fn slice(&self) -> &[usize]; -} - -impl Dimension for () { - fn slice(&self) -> &[usize] { &[] } -} - -impl Dimension for usize { - fn slice(&self) -> &[usize] { - unsafe { - ::std::slice::from_raw_parts(self, 1) - } - } -} - -fn remove_axis(value: &usize, axis: usize) -> () { - let tup = (); - let mut it = tup.slice().iter(); - for (i, _) in value.slice().iter().enumerate() { - if i == axis { - continue; - } - it.next(); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3656.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3656.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3656.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3656.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(improper_ctypes)] - -// Issue #3656 -// Incorrect struct size computation in the FFI, because of not taking -// the alignment of elements into account. - -// pretty-expanded FIXME #23616 -// ignore-wasm32-bare no libc to test with - -#![feature(libc)] - -extern crate libc; -use libc::{c_uint, uint32_t, c_void}; - -pub struct KEYGEN { - hash_algorithm: [c_uint; 2], - count: uint32_t, - salt: *const c_void, - salt_size: uint32_t, -} - -extern { - // Bogus signature, just need to test if it compiles. - pub fn malloc(data: KEYGEN); -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36744-bitcast-args-if-needed.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36744-bitcast-args-if-needed.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36744-bitcast-args-if-needed.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36744-bitcast-args-if-needed.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This tests for an ICE (and, if ignored, subsequent LLVM abort) when -// a lifetime-parametric fn is passed into a context whose expected -// type has a differing lifetime parameterization. - -struct A<'a> { - _a: &'a i32, -} - -fn call(s: T, functions: &Vec fn(&'n T)>) { - for function in functions { - function(&s); - } -} - -fn f(a: &A) { println!("a holds {}", a._a); } - -fn main() { - let a = A { _a: &10 }; - - let vec: Vec fn(&'u A<'v>)> = vec![f]; - call(a, &vec); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36744-without-calls.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36744-without-calls.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36744-without-calls.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36744-without-calls.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests for an LLVM abort when storing a lifetime-parametric fn into -// context that is expecting one that is not lifetime-parametric -// (i.e. has no `for <'_>`). - -pub struct A<'a>(&'a ()); -pub struct S(T); - -pub fn bad<'s>(v: &mut S)>, y: S fn(A<'b>)>) { - *v = y; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36768.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36768.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36768.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36768.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags:--test -#![deny(private_in_public)] - -#[test] fn foo() {} -mod foo {} - -#[test] fn core() {} -extern crate core; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36786-resolve-call.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36786-resolve-call.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36786-resolve-call.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36786-resolve-call.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Ensure that types that rely on obligations are autoderefed -// correctly - -fn main() { - let x : Vec> = vec![Box::new(|| ())]; - x[0]() -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36792.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36792.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36792.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36792.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn foo() -> impl Copy { - foo -} -fn main() { - foo(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36816.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36816.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36816.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36816.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! m { () => { 1 } } -macro_rules! n { () => { 1 + m!() } } - -fn main() { - let _: [u32; n!()] = [0, 0]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3683.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3683.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3683.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3683.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait Foo { - fn a(&self) -> isize; - fn b(&self) -> isize { - self.a() + 2 - } -} - -impl Foo for isize { - fn a(&self) -> isize { - 3 - } -} - -pub fn main() { - assert_eq!(3.b(), 5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36856.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36856.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36856.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36856.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #36856. - -// compile-flags:-g - -fn g() -> bool { - false -} - -pub fn main() { - let a = !g(); - if a != !g() { - panic!(); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36936.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36936.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36936.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36936.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// check that casts are not being treated as lexprs. - -fn main() { - let mut a = 0i32; - let b = &(a as i32); - a = 1; - assert_ne!(&a as *const i32, b as *const i32); - assert_eq!(*b, 0); - - assert_eq!(issue_36936(), 1); -} - - -struct A(u32); - -impl Drop for A { - fn drop(&mut self) { - self.0 = 0; - } -} - -fn issue_36936() -> u32 { - let a = &(A(1) as A); - a.0 -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36954.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36954.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36954.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-36954.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-36954.rs - -extern crate issue_36954 as lib; - -fn main() { - let _ = lib::FOO; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3702.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3702.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3702.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3702.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - trait Text { - fn to_string(&self) -> String; - } - - fn to_string(t: Box) { - println!("{}", (*t).to_string()); - } - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37109.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37109.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37109.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37109.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait ToRef<'a> { - type Ref: 'a; -} - -impl<'a, U: 'a> ToRef<'a> for U { - type Ref = &'a U; -} - -fn example<'a, T>(value: &'a T) -> (>::Ref, u32) { - (value, 0) -} - -fn main() { - example(&0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37175.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37175.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37175.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37175.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! m { (<$t:ty>) => { stringify!($t) } } -fn main() { - println!("{}", m!(>)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37222.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37222.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37222.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37222.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Debug, PartialEq)] -enum Bar { - A(i64), - B(i32), - C, -} - -#[derive(Debug, PartialEq)] -struct Foo(Bar, u8); - -static FOO: [Foo; 2] = [Foo(Bar::C, 0), Foo(Bar::C, 0xFF)]; - -fn main() { - assert_eq!(&FOO[1], &Foo(Bar::C, 0xFF)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37291/auxiliary/lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37291/auxiliary/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37291/auxiliary/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37291/auxiliary/lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -use std::ops::Mul; - -pub trait A {} -pub trait B { - type AT: A; -} -pub trait C { - type BT: B; -} - -pub struct AV; -impl A for AV {} - -pub struct BV; -impl B for BV { - type AT = AV; -} - -pub struct CV; -impl C for CV { - type BT = BV; -} - -pub struct WrapperB(pub T); -pub struct WrapperC(pub T); - -impl Mul::AT>> for WrapperC - where C1: C -{ - type Output = u8; - fn mul(self, _: WrapperB<::AT>) -> Self::Output { - loop {} - } -} -impl Mul> for WrapperC { - type Output = u8; - fn mul(self, _: WrapperC) -> Self::Output { - loop {} - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37291/main.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37291/main.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37291/main.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37291/main.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:lib.rs - -// Regression test for #37291. The problem was that the starting -// environment for a specialization check was not including the -// where-clauses from the impl when attempting to normalize the impl's -// trait-ref, so things like `::Item` could not resolve, -// since the `C: Foo` trait bound was not included in the environment. - -extern crate lib; - -use lib::{CV, WrapperB, WrapperC}; - -fn main() { - let a = WrapperC(CV); - let b = WrapperC(CV); - if false { - let _ = a * b; - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3743.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3743.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3743.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3743.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// If `Mul` used an associated type for its output, this test would -// work more smoothly. - -use std::ops::Mul; - -#[derive(Copy, Clone)] -struct Vec2 { - x: f64, - y: f64 -} - -// methods we want to export as methods as well as operators -impl Vec2 { -#[inline(always)] - fn vmul(self, other: f64) -> Vec2 { - Vec2 { x: self.x * other, y: self.y * other } - } -} - -// Right-hand-side operator visitor pattern -trait RhsOfVec2Mul { - type Result; - - fn mul_vec2_by(&self, lhs: &Vec2) -> Self::Result; -} - -// Vec2's implementation of Mul "from the other side" using the above trait -impl> Mul for Vec2 { - type Output = Res; - - fn mul(self, rhs: Rhs) -> Res { rhs.mul_vec2_by(&self) } -} - -// Implementation of 'f64 as right-hand-side of Vec2::Mul' -impl RhsOfVec2Mul for f64 { - type Result = Vec2; - - fn mul_vec2_by(&self, lhs: &Vec2) -> Vec2 { lhs.vmul(*self) } -} - -// Usage with failing inference -pub fn main() { - let a = Vec2 { x: 3.0f64, y: 4.0f64 }; - - // the following compiles and works properly - let v1: Vec2 = a * 3.0f64; - println!("{} {}", v1.x, v1.y); - - // the following compiles but v2 will not be Vec2 yet and - // using it later will cause an error that the type of v2 - // must be known - let v2 = a * 3.0f64; - println!("{} {}", v2.x, v2.y); // error regarding v2's type -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3753.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3753.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3753.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3753.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #3656 -// Issue Name: pub method preceded by attribute can't be parsed -// Abstract: Visibility parsing failed when compiler parsing - -use std::f64; - -#[derive(Copy, Clone)] -pub struct Point { - x: f64, - y: f64 -} - -#[derive(Copy, Clone)] -pub enum Shape { - Circle(Point, f64), - Rectangle(Point, Point) -} - -impl Shape { - pub fn area(&self, sh: Shape) -> f64 { - match sh { - Shape::Circle(_, size) => f64::consts::PI * size * size, - Shape::Rectangle(Point {x, y}, Point {x: x2, y: y2}) => (x2 - x) * (y2 - y) - } - } -} - -pub fn main(){ - let s = Shape::Circle(Point { x: 1.0, y: 2.0 }, 3.0); - println!("{}", s.area(s)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37598.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37598.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37598.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37598.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(slice_patterns)] - -fn check(list: &[u8]) { - match list { - &[] => {}, - &[_u1, _u2, ref _next..] => {}, - &[_u1] => {}, - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37655.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37655.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37655.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37655.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #37655. The problem was a false edge created by -// coercion that wound up requiring that `'a` (in `split()`) outlive -// `'b`, which shouldn't be necessary. - -#![allow(warnings)] - -trait SliceExt { - type Item; - - fn get_me(&self, index: I) -> &I::Output - where I: SliceIndex; -} - -impl SliceExt for [T] { - type Item = T; - - fn get_me(&self, index: I) -> &I::Output - where I: SliceIndex - { - panic!() - } -} - -pub trait SliceIndex { - type Output: ?Sized; -} - -impl SliceIndex for usize { - type Output = T; -} - -fn foo<'a, 'b>(split: &'b [&'a [u8]]) -> &'a [u8] { - split.get_me(0) -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37686.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37686.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37686.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37686.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - match (0, 0) { - (std::usize::MIN, std::usize::MAX) => {} - _ => {} - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37725.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37725.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37725.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37725.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Foo { - fn foo(&self); -} - -fn foo<'a>(s: &'a mut ()) where &'a mut (): Foo { - s.foo(); -} -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37733.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37733.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37733.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37733.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -type A = for<> fn(); - -type B = for<'a,> fn(); - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3794.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3794.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3794.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3794.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -trait T { - fn print(&self); -} - -#[derive(Debug)] -struct S { - s: isize, -} - -impl T for S { - fn print(&self) { - println!("{:?}", self); - } -} - -fn print_t(t: &T) { - t.print(); -} - -fn print_s(s: &S) { - s.print(); -} - -pub fn main() { - let s: Box = box S { s: 5 }; - print_s(&*s); - let t: Box = s as Box; - print_t(&*t); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37991.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37991.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37991.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-37991.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(min_const_fn)] - -const fn foo() -> i64 { - 3 -} - -const fn bar(x: i64) -> i64 { - x*2 -} - -fn main() { - let val = &(foo() % 2); - assert_eq!(*val, 1); - - let val2 = &(bar(1+1) % 3); - assert_eq!(*val2, 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38002.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38002.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38002.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38002.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check that constant ADTs are codegened OK, part k of N. - -enum Bar { - C -} - -enum Foo { - A {}, - B { - y: usize, - z: Bar - }, -} - -const LIST: [(usize, Foo); 2] = [ - (51, Foo::B { y: 42, z: Bar::C }), - (52, Foo::B { y: 45, z: Bar::C }), -]; - -pub fn main() { - match LIST { - [ - (51, Foo::B { y: 42, z: Bar::C }), - (52, Foo::B { y: 45, z: Bar::C }) - ] => {} - _ => { - // I would want to print the enum here, but if - // the discriminant is garbage this causes an - // `unreachable` and silent process exit. - panic!("trivial match failed") - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38033.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38033.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38033.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38033.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::marker; -use std::mem; - -fn main() { - let workers = (0..0).map(|_| result::()); - drop(join_all(workers).poll()); -} - -trait Future { - type Item; - type Error; - - fn poll(&mut self) -> Result; -} - -trait IntoFuture { - type Future: Future; - type Item; - type Error; - - fn into_future(self) -> Self::Future; -} - -impl IntoFuture for F { - type Future = F; - type Item = F::Item; - type Error = F::Error; - - fn into_future(self) -> F { - self - } -} - -struct FutureResult { - _inner: marker::PhantomData<(T, E)>, -} - -fn result() -> FutureResult { - loop {} -} - -impl Future for FutureResult { - type Item = T; - type Error = E; - - fn poll(&mut self) -> Result { - loop {} - } -} - -struct JoinAll - where I: IntoIterator, - I::Item: IntoFuture, -{ - elems: Vec<::Item>, -} - -fn join_all(_: I) -> JoinAll - where I: IntoIterator, - I::Item: IntoFuture, -{ - JoinAll { elems: vec![] } -} - -impl Future for JoinAll - where I: IntoIterator, - I::Item: IntoFuture, -{ - type Item = Vec<::Item>; - type Error = ::Error; - - fn poll(&mut self) -> Result { - let elems = mem::replace(&mut self.elems, Vec::new()); - Ok(elems.into_iter().map(|e| { - e - }).collect::>()) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38074.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38074.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38074.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38074.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten FIXME(#45351) - -#![feature(platform_intrinsics, repr_simd)] - -extern "platform-intrinsic" { - fn simd_shuffle2(x: T, y: T, idx: [u32; 2]) -> U; -} - -#[repr(simd)] -#[derive(Clone, Copy)] -#[allow(non_camel_case_types)] -struct u64x2(u64, u64); - -fn main() { - let a = u64x2(1, 2); - let r: u64x2 = unsafe { simd_shuffle2(a, a, [0-0, 0-0]) }; - assert_eq!(r.0, 1); - assert_eq!(r.1, 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38091.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38091.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38091.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38091.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(specialization)] - -trait Iterate<'a> { - type Ty: Valid; - fn iterate(self); -} -impl<'a, T> Iterate<'a> for T where T: Check { - default type Ty = (); - default fn iterate(self) {} -} - -trait Check {} -impl<'a, T> Check for T where >::Ty: Valid {} - -trait Valid {} - -fn main() { - Iterate::iterate(0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38190.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38190.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38190.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38190.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue_38190.rs -// ignore-pretty issue #37195 - -#[macro_use] -extern crate issue_38190; - -mod auxiliary { - m!([mod issue_38190;]); -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38226.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38226.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38226.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38226.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This test makes sure that we don't run into a linker error because of the -// middle::reachable pass missing trait methods with default impls. - -// aux-build:issue_38226_aux.rs - -// Need -Cno-prepopulate-passes to really disable inlining, otherwise the faulty -// code gets optimized out: -// compile-flags: -Cno-prepopulate-passes -Cpasses=name-anon-globals - -extern crate issue_38226_aux; - -fn main() { - issue_38226_aux::foo::<()>(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38437.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38437.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38437.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38437.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check that drop elaboration clears the "master" discriminant -// drop flag even if it protects no fields. - -struct Good(usize); -impl Drop for Good { - #[inline(never)] - fn drop(&mut self) { - println!("dropping Good({})", self.0); - } -} - -struct Void; -impl Drop for Void { - #[inline(never)] - fn drop(&mut self) { - panic!("Suddenly, a Void appears."); - } -} - -enum E { - Never(Void), - Fine(Good) -} - -fn main() { - let mut go = true; - - loop { - let next; - match go { - true => next = E::Fine(Good(123)), - false => return, - } - - match next { - E::Never(_) => return, - E::Fine(_good) => go = false, - } - - // `next` is dropped and StorageDead'd here. We must reset the - // discriminant's drop flag to avoid random variants being - // dropped. - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3847.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3847.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3847.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3847.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -mod buildings { - pub struct Tower { pub height: usize } -} - -pub fn main() { - let sears = buildings::Tower { height: 1451 }; - let h: usize = match sears { - buildings::Tower { height: h } => { h } - }; - - println!("{}", h); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38556.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38556.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38556.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38556.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub struct Foo; - -macro_rules! reexport { - () => { use Foo as Bar; } -} - -reexport!(); - -fn main() { - use Bar; - fn f(_: Bar) {} -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38715.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38715.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38715.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38715.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue_38715.rs -// aux-build:issue_38715-modern.rs - -// Test that `#[macro_export] macro_rules!` shadow earlier `#[macro_export] macro_rules!` - -#[macro_use] -extern crate issue_38715; -#[macro_use] -extern crate issue_38715_modern; - -fn main() { - foo!(); - foo_modern!(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38727.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38727.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38727.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38727.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[repr(u64)] -enum A { - A = 0u64, - B = !0u64, -} - -fn cmp() -> A { - A::B -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3874.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3874.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3874.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3874.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -enum PureCounter { PureCounterVariant(usize) } - -fn each(thing: PureCounter, blk: F) where F: FnOnce(&usize) { - let PureCounter::PureCounterVariant(ref x) = thing; - blk(x); -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38763.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38763.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38763.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38763.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten - -#[repr(C)] -pub struct Foo(i128); - -#[no_mangle] -pub extern "C" fn foo(x: Foo) -> Foo { x } - -fn main() { - foo(Foo(1)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3878.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3878.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3878.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3878.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![allow(path_statements)] -#![feature(box_syntax)] - -pub fn main() { - let y: Box<_> = box 1; - y; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3888-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3888-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3888-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3888-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn vec_peek<'r, T>(v: &'r [T]) -> &'r [T] { - &v[1..5] -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38942.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38942.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38942.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38942.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// See https://github.com/rust-lang/rust/issues/38942 - -#[repr(u64)] -pub enum NSEventType { - NSEventTypePressure, -} - -pub const A: u64 = NSEventType::NSEventTypePressure as u64; - -fn banana() -> u64 { - A -} - -fn main() { - println!("banana! {}", banana()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3895.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3895.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3895.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3895.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - enum State { BadChar, BadSyntax } - - match State::BadChar { - _ if true => State::BadChar, - State::BadChar | State::BadSyntax => panic!() , - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38987.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38987.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38987.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-38987.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - let _ = -0x8000_0000_0000_0000_0000_0000_0000_0000i128; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3904.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3904.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3904.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3904.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn example_err(prog: &str, arg: &str) { - println!("{}: {}", prog, arg) -} - -fn exit(print: F, prog: &str, arg: &str) where F: FnOnce(&str, &str) { - print(prog, arg); -} - -struct X where F: FnOnce(&str, &str) { - err: F, -} - -impl X where F: FnOnce(&str, &str) { - pub fn boom(self) { - exit(self.err, "prog", "arg"); - } -} - -pub fn main(){ - let val = X { - err: example_err, - }; - val.boom(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39089.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39089.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39089.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39089.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn f Sized>() {} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39292.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39292.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39292.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39292.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for issue #39292. The object vtable was being -// incorrectly left with a null pointer. - -trait Foo { - fn print<'a>(&'a self) where T: 'a { println!("foo"); } -} - -impl<'a> Foo<&'a ()> for () { } - -trait Bar: for<'a> Foo<&'a ()> { } - -impl Bar for () {} - -fn main() { - (&() as &Bar).print(); // Segfault -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3935.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3935.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3935.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3935.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#[derive(PartialEq)] -struct Bike { - name: String, -} - -pub fn main() { - let town_bike = Bike { name: "schwinn".to_string() }; - let my_bike = Bike { name: "surly".to_string() }; - - assert!(town_bike != my_bike); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39367.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39367.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39367.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39367.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::ops::Deref; - -struct ArenaSet::Target>(U, &'static V) - where V: 'static + ?Sized; - -static Z: [u8; 4] = [1,2,3,4]; - -fn arena() -> &'static ArenaSet> { - fn __static_ref_initialize() -> ArenaSet> { - ArenaSet(vec![], &Z) - } - unsafe { - use std::sync::{Once, ONCE_INIT}; - fn require_sync(_: &T) { } - unsafe fn __stability() -> &'static ArenaSet> { - use std::mem::transmute; - use std::boxed::Box; - static mut DATA: *const ArenaSet> = 0 as *const ArenaSet>; - - static mut ONCE: Once = ONCE_INIT; - ONCE.call_once(|| { - DATA = transmute - ::>>, *const ArenaSet>> - (Box::new(__static_ref_initialize())); - }); - - &*DATA - } - let static_ref = __stability(); - require_sync(static_ref); - static_ref - } -} - -fn main() { - let &ArenaSet(ref u, v) = arena(); - assert!(u.is_empty()); - assert_eq!(v, Z); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39467.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39467.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39467.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39467.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! expr { () => { () } } - -enum A {} - -impl A { - const A: () = expr!(); -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39548.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39548.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39548.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39548.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -type Array = [(); ((1 < 2) == false) as usize]; - -fn main() { - let _: Array = []; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39709.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39709.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39709.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39709.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - println!("{}", { macro_rules! x { ($(t:tt)*) => {} } 33 }); -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39720.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39720.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39720.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39720.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_snake_case)] - -// ignore-emscripten FIXME(#45351) - -#![feature(repr_simd, platform_intrinsics)] - -#[repr(C)] -#[repr(simd)] -#[derive(Copy, Clone, Debug)] -pub struct char3(pub i8, pub i8, pub i8); - -#[repr(C)] -#[repr(simd)] -#[derive(Copy, Clone, Debug)] -pub struct short3(pub i16, pub i16, pub i16); - -extern "platform-intrinsic" { - fn simd_cast(x: T) -> U; -} - -fn main() { - let cast: short3 = unsafe { simd_cast(char3(10, -3, -9)) }; - - println!("{:?}", cast); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39720.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39720.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39720.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39720.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -warning[E0566]: conflicting representation hints - --> $DIR/issue-39720.rs:18:8 - | -LL | #[repr(C)] - | ^ -LL | #[repr(simd)] - | ^^^^ - -warning[E0566]: conflicting representation hints - --> $DIR/issue-39720.rs:23:8 - | -LL | #[repr(C)] - | ^ -LL | #[repr(simd)] - | ^^^^ - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3979-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3979-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3979-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3979-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait A { - fn a_method(&self); -} - -trait B: A { - fn b_method(&self); -} - -trait C: B { - fn c_method(&self) { - self.a_method(); - } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3979-generics.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3979-generics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3979-generics.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3979-generics.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_snake_case)] - -use std::ops::Add; - -trait Positioned { - fn SetX(&mut self, _: S); - fn X(&self) -> S; -} - -trait Movable>: Positioned { - fn translate(&mut self, dx: S) { - let x = self.X() + dx; - self.SetX(x); - } -} - -struct Point { x: isize, y: isize } - -impl Positioned for Point { - fn SetX(&mut self, x: isize) { - self.x = x; - } - fn X(&self) -> isize { - self.x - } -} - -impl Movable for Point {} - -pub fn main() { - let mut p = Point{ x: 1, y: 2}; - p.translate(3); - assert_eq!(p.X(), 4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3979.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3979.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3979.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3979.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_snake_case)] - -trait Positioned { - fn SetX(&mut self, _: isize); - fn X(&self) -> isize; -} - -trait Movable: Positioned { - fn translate(&mut self, dx: isize) { - let x = self.X(); - self.SetX(x + dx); - } -} - -struct Point { x: isize, y: isize } - -impl Positioned for Point { - fn SetX(&mut self, x: isize) { - self.x = x; - } - fn X(&self) -> isize { - self.x - } -} - -impl Movable for Point {} - -pub fn main() { - let mut p = Point{ x: 1, y: 2}; - p.translate(3); - assert_eq!(p.X(), 4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3979-xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3979-xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3979-xcrate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3979-xcrate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue_3979_traits.rs - -extern crate issue_3979_traits; -use issue_3979_traits::{Positioned, Movable}; - -struct Point { x: isize, y: isize } - -impl Positioned for Point { - fn SetX(&mut self, x: isize) { - self.x = x; - } - fn X(&self) -> isize { - self.x - } -} - -impl Movable for Point {} - -pub fn main() { - let mut p = Point{ x: 1, y: 2}; - p.translate(3); - assert_eq!(p.X(), 4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39808.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39808.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39808.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39808.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(unreachable_code)] - -// Regression test for #39808. The type parameter of `Owned` was -// considered to be "unconstrained" because the type resulting from -// `format!` (`String`) was not being propagated upward, owing to the -// fact that the expression diverges. - -use std::borrow::Cow; - -fn main() { - let _ = if false { - Cow::Owned(format!("{:?}", panic!())) - } else { - Cow::Borrowed("") - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39823.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39823.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39823.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39823.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue_39823.rs - -extern crate issue_39823; -use issue_39823::{RemoteC, RemoteG}; - -#[derive(Debug, PartialEq)] -struct LocalC(u32); - -#[derive(Debug, PartialEq)] -struct LocalG(T); - -fn main() { - let virtual_localc : &Fn(_) -> LocalC = &LocalC; - assert_eq!(virtual_localc(1), LocalC(1)); - - let virtual_localg : &Fn(_) -> LocalG = &LocalG; - assert_eq!(virtual_localg(1), LocalG(1)); - - let virtual_remotec : &Fn(_) -> RemoteC = &RemoteC; - assert_eq!(virtual_remotec(1), RemoteC(1)); - - let virtual_remoteg : &Fn(_) -> RemoteG = &RemoteG; - assert_eq!(virtual_remoteg(1), RemoteG(1)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39827.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39827.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39827.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39827.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(core_intrinsics)] - -use std::intrinsics::{ volatile_copy_memory, volatile_store, volatile_load, - volatile_copy_nonoverlapping_memory, - volatile_set_memory }; - -// -// This test ensures that volatile intrinsics can be specialised with -// zero-sized types and, in case of copy/set functions, can accept -// number of elements equal to zero. -// -fn main () { - let mut dst_pair = (1, 2); - let src_pair = (3, 4); - let mut dst_empty = (); - let src_empty = (); - - const COUNT_0: usize = 0; - const COUNT_100: usize = 100; - - unsafe { - volatile_copy_memory(&mut dst_pair, &dst_pair, COUNT_0); - volatile_copy_nonoverlapping_memory(&mut dst_pair, &src_pair, 0); - volatile_copy_memory(&mut dst_empty, &dst_empty, 100); - volatile_copy_nonoverlapping_memory(&mut dst_empty, &src_empty, - COUNT_100); - volatile_set_memory(&mut dst_empty, 0, COUNT_100); - volatile_set_memory(&mut dst_pair, 0, COUNT_0); - volatile_store(&mut dst_empty, ()); - volatile_store(&mut dst_empty, src_empty); - volatile_load(&src_empty); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3991.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3991.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3991.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-3991.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// pretty-expanded FIXME #23616 - -struct HasNested { - nest: Vec > , -} - -impl HasNested { - fn method_push_local(&mut self) { - self.nest[0].push(0); - } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39984.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39984.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39984.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-39984.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for issue #39984. -// -// The key here is that the error type of the `Ok` call ought to be -// constrained to `String`, even though it is dead-code. - -fn main() {} - -fn t() -> Result<(), String> { - return Err("".into()); - Ok(()) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40003.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40003.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40003.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40003.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,187 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - if false { test(); } -} - -fn test() { - let rx = Err::, u32>(1).into_future(); - - rx.map(|l: Vec| stream::iter(l.into_iter().map(|i| Ok(i)))) - .flatten_stream() - .chunks(50) - .buffer_unordered(5); -} - -use future::{Future, IntoFuture}; -mod future { - use std::result; - - use {stream, Stream}; - - pub trait Future { - type Item; - type Error; - - fn map(self, _: F) -> Map - where F: FnOnce(Self::Item) -> U, - Self: Sized, - { - panic!() - } - - fn flatten_stream(self) -> FlattenStream - where ::Item: stream::Stream, - Self: Sized - { - panic!() - } - } - - pub trait IntoFuture { - type Future: Future; - type Item; - type Error; - fn into_future(self) -> Self::Future; - } - - impl IntoFuture for F { - type Future = F; - type Item = F::Item; - type Error = F::Error; - - fn into_future(self) -> F { - panic!() - } - } - - impl IntoFuture for result::Result { - type Future = FutureResult; - type Item = T; - type Error = E; - - fn into_future(self) -> FutureResult { - panic!() - } - } - - pub struct Map { - _a: (A, F), - } - - impl Future for Map - where A: Future, - F: FnOnce(A::Item) -> U, - { - type Item = U; - type Error = A::Error; - } - - pub struct FlattenStream { - _f: F, - } - - impl Stream for FlattenStream - where F: Future, - ::Item: Stream, - { - type Item = ::Item; - type Error = ::Error; - } - - pub struct FutureResult { - _inner: (T, E), - } - - impl Future for FutureResult { - type Item = T; - type Error = E; - } -} - -mod stream { - use IntoFuture; - - pub trait Stream { - type Item; - type Error; - - fn buffer_unordered(self, amt: usize) -> BufferUnordered - where Self::Item: IntoFuture::Error>, - Self: Sized - { - new(self, amt) - } - - fn chunks(self, _capacity: usize) -> Chunks - where Self: Sized - { - panic!() - } - } - - pub struct IterStream { - _iter: I, - } - - pub fn iter(_: J) -> IterStream - where J: IntoIterator>, - { - panic!() - } - - impl Stream for IterStream - where I: Iterator>, - { - type Item = T; - type Error = E; - } - - pub struct Chunks { - _stream: S - } - - impl Stream for Chunks - where S: Stream - { - type Item = Result::Item>, u32>; - type Error = ::Error; - } - - pub struct BufferUnordered { - _stream: S, - } - - enum Slot { - Next(usize), - _Data { _a: T }, - } - - fn new(_s: S, _amt: usize) -> BufferUnordered - where S: Stream, - S::Item: IntoFuture::Error>, - { - (0..0).map(|_| { - Slot::Next::<::Future>(1) - }).collect::>(); - panic!() - } - - impl Stream for BufferUnordered - where S: Stream, - S::Item: IntoFuture::Error>, - { - type Item = ::Item; - type Error = ::Error; - } -} -use stream::Stream; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40085.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40085.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40085.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40085.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::ops::Index; -fn bar() {} -static UNIT: () = (); -struct S; -impl Index for S { - type Output = (); - fn index(&self, _: fn()) -> &() { &UNIT } -} -fn main() { - S.index(bar); - S[bar]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40136.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40136.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40136.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40136.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -macro_rules! m { () => { 0 } } - -trait T { - const C: i32 = m!(); -} - -struct S; -impl S { - const C: i32 = m!(); -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40235.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40235.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40235.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40235.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn foo() {} - -fn main() { - while let Some(foo) = Some(1) { break } - foo(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4025.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4025.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4025.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4025.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -/* -# if b { x } else { y } requires identical types for x and y -*/ - -fn print1(b: bool, s1: &str, s2: &str) { - println!("{}", if b { s1 } else { s2 }); -} -fn print2<'a, 'b>(b: bool, s1: &'a str, s2: &'b str) { - println!("{}", if b { s1 } else { s2 }); -} -fn print3(b: bool, s1: &str, s2: &str) { - let mut s: &str; - if b { s = s1; } else { s = s2; } - println!("{}", s); -} -fn print4<'a, 'b>(b: bool, s1: &'a str, s2: &'b str) { - let mut s: &str; - if b { s = s1; } else { s = s2; } - println!("{}", s); -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40408.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40408.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40408.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40408.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - println!("{}", 0E+10); - println!("{}", 0e+10); - println!("{}", 00e+10); - println!("{}", 00E+10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40469.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40469.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40469.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40469.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty issue #37195 - -#![allow(dead_code)] - -include!("auxiliary/issue_40469.rs"); -fn f() { m!(); } - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40770.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40770.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40770.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40770.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! m { - ($e:expr) => { - macro_rules! n { () => { $e } } - } -} - -fn main() { - m!(foo!()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40847.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40847.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40847.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40847.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! gen { - ($name:ident ( $($dol:tt $var:ident)* ) $($body:tt)*) => { - macro_rules! $name { - ($($dol $var:ident)*) => { - $($body)* - } - } - } -} - -gen!(m($var) $var); - -fn main() { - let x = 1; - assert_eq!(m!(x), 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40883.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40883.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40883.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40883.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// check that we don't have linear stack usage with multiple calls to `push` - -#![feature(test)] - -extern crate test; -use std::mem; - -fn meal() -> Big { - if test::black_box(false) { - panic!() - } - Big { drop_me: [ - None, None, None, None, None, None, None, None, - None, None, None, None, None, None, None, None, - None, None, None, None, None, None, None, None, - None, None, None, None, None, None, None, None, - None, None, None, None, None, None, None, None, - None, None, None, None, None, None, None, None, - ]} -} - -pub struct Big { - drop_me: [Option>; 48], -} - -#[inline] -fn push(out: &mut Vec) { - out.push(meal()); -} - -#[inline(never)] -pub fn supersize_me(out: &mut Vec) { - push(out); - push(out); - push(out); - push(out); - push(out); - push(out); - push(out); - push(out); - push(out); - push(out); - push(out); - push(out); - push(out); - push(out); - push(out); - push(out); // 16 calls to `push` - - verify_stack_usage(out); - - push(out); - push(out); - push(out); - push(out); - push(out); - push(out); - push(out); - push(out); - push(out); - push(out); - push(out); - push(out); - push(out); - push(out); - push(out); - push(out); // 16 calls to `push` -} - -#[inline(never)] -fn verify_stack_usage(before_ptr: *mut Vec) { - // to check stack usage, create locals before and after - // and check the difference in addresses between them. - let mut stack_var: Vec = vec![]; - test::black_box(&mut stack_var); - let stack_usage = isize::abs( - (&mut stack_var as *mut _ as isize) - - (before_ptr as isize)) as usize; - // give space for 2 copies of `Big` + 128 "misc" bytes. - if stack_usage > mem::size_of::() * 2 + 128 { - panic!("used {} bytes of stack, but `struct Big` is only {} bytes", - stack_usage, mem::size_of::()); - } - -} - -pub fn main() { - let mut v = vec![]; - test::black_box(&mut v); - supersize_me(&mut v); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40951.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40951.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40951.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40951.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #40951. - -const FOO: [&'static str; 1] = ["foo"]; - -fn find(t: &[T], element: &T) { } - -fn main() { - let x = format!("hi"); - find(&FOO, &&*x); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40962.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40962.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40962.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-40962.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! m { - ($i:meta) => { - #[derive($i)] - struct S; - } -} - -m!(Clone); - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41053.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41053.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41053.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41053.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue_41053.rs - -pub trait Trait { fn foo(&self) {} } - -pub struct Foo; - -impl Iterator for Foo { - type Item = Box; - fn next(&mut self) -> Option> { - extern crate issue_41053; - impl ::Trait for issue_41053::Test { - fn foo(&self) {} - } - Some(Box::new(issue_41053::Test)) - } -} - -fn main() { - Foo.next().unwrap().foo(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4107.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4107.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4107.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4107.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let _id: &Mat2 = &Matrix::identity(1.0); -} - -pub trait Index { fn get(&self, _: Index) -> Result { panic!() } } -pub trait Dimensional: Index { } - -pub struct Mat2 { x: T } -pub struct Vec2 { x: T } - -impl Dimensional> for Mat2 { } -impl Index> for Mat2 { } - -impl Dimensional for Vec2 { } -impl Index for Vec2 { } - -pub trait Matrix: Dimensional { - fn identity(t:T) -> Self; -} - -impl Matrix> for Mat2 { - fn identity(t:T) -> Mat2 { Mat2{ x: t } } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41213.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41213.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41213.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41213.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -enum A { - A1, - A2, - A3, -} - -enum B { - B1(String, String), - B2(String, String), -} - -fn main() { - let a = A::A1; - loop { - let _ctor = match a { - A::A3 => break, - A::A1 => B::B1, - A::A2 => B::B2, - }; - break; - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41272.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41272.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41272.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41272.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct Foo; - -impl Foo { - fn bar(&mut self) -> bool { true } -} - -fn error(foo: &mut Foo) { - if let Some(_) = Some(true) { - } else if foo.bar() {} -} - -fn ok(foo: &mut Foo) { - if let Some(_) = Some(true) { - } else { - if foo.bar() {} - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41298.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41298.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41298.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41298.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct Function { t: T, f: F } - -impl Function R> { fn foo() { } } -impl Function R> { fn bar() { } } - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41394.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41394.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41394.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41394.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-41394.rs - -extern crate issue_41394 as lib; - -fn main() { - assert_eq!(lib::foo() as u32, 42); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41479.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41479.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41479.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41479.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn split(pair: (A, B)) { - let _a = pair.0; - let _b = pair.1; -} - -fn main() { - split(((), ((), ()))); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41498.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41498.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41498.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41498.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// regression test for issue #41498. - -struct S; -impl S { - fn mutate(&mut self) {} -} - -fn call_and_ref T>(x: &mut Option, f: F) -> &mut T { - *x = Some(f()); - x.as_mut().unwrap() -} - -fn main() { - let mut n = None; - call_and_ref(&mut n, || [S])[0].mutate(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41604.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41604.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41604.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41604.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct B; - -impl B { - fn init(&mut self) {} -} - -fn main() { - let mut b = [B]; - b[1-1].init(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41628.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41628.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41628.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41628.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![deny(dead_code)] - -#[used] -static FOO: u32 = 0; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41677.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41677.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41677.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41677.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #41677. The local variable was winding up with -// a type `Receiver` where `?T` was unconstrained, because we -// failed to enforce the WF obligations and `?T` is a bivariant type -// parameter position. - -#![allow(unused_variables, dead_code)] - -use std::marker::PhantomData; - -trait Handle { - type Inner; -} - -struct ResizingHandle(PhantomData); -impl Handle for ResizingHandle { - type Inner = H; -} - -struct Receiver>(PhantomData); - -fn channel(size: usize) -> Receiver> { - let rx = Receiver(PhantomData); - rx -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41696.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41696.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41696.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41696.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// this used to cause exponential code-size blowup during LLVM passes. - -#![feature(test)] - -extern crate test; - -struct MayUnwind; - -impl Drop for MayUnwind { - fn drop(&mut self) { - if test::black_box(false) { - panic!() - } - } -} - -struct DS { - may_unwind: MayUnwind, - name: String, - next: U, -} - -fn add(ds: DS, name: String) -> DS> { - DS { - may_unwind: MayUnwind, - name: "?".to_owned(), - next: ds, - } -} - -fn main() { - let deserializers = DS { may_unwind: MayUnwind, name: "?".to_owned(), next: () }; - let deserializers = add(deserializers, "?".to_owned()); - let deserializers = add(deserializers, "?".to_owned()); - let deserializers = add(deserializers, "?".to_owned()); - let deserializers = add(deserializers, "?".to_owned()); - let deserializers = add(deserializers, "?".to_owned()); - let deserializers = add(deserializers, "?".to_owned()); - let deserializers = add(deserializers, "?".to_owned()); // 0.7s - let deserializers = add(deserializers, "?".to_owned()); // 1.3s - let deserializers = add(deserializers, "?".to_owned()); // 2.4s - let deserializers = add(deserializers, "?".to_owned()); // 6.7s - let deserializers = add(deserializers, "?".to_owned()); // 26.0s - let deserializers = add(deserializers, "?".to_owned()); // 114.0s - let deserializers = add(deserializers, "?".to_owned()); // 228.0s - let deserializers = add(deserializers, "?".to_owned()); // 400.0s - let deserializers = add(deserializers, "?".to_owned()); // 800.0s - let deserializers = add(deserializers, "?".to_owned()); // 1600.0s - let deserializers = add(deserializers, "?".to_owned()); // 3200.0s -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41744.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41744.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41744.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41744.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Tc {} -impl Tc for bool {} - -fn main() { - let _: &[&Tc] = &[&true]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41803.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41803.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41803.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41803.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -/// A compile-time map from identifiers to arbitrary (heterogeneous) expressions -macro_rules! ident_map { - ( $name:ident = { $($key:ident => $e:expr,)* } ) => { - macro_rules! $name { - $( - ( $key ) => { $e }; - )* - // Empty invocation expands to nothing. Needed when the map is empty. - () => {}; - } - }; -} - -ident_map!(my_map = { - main => 0, -}); - -fn main() { - my_map!(main); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41849-variance-req.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41849-variance-req.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41849-variance-req.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41849-variance-req.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #41849. - -use std::ops::Mul; - -const C: usize = 1; -const CAPACITY: usize = 1 * C; - -struct A { - f: [X; CAPACITY], -} - -struct B { - f: T, -} - -impl Mul for B { - type Output = Self; - fn mul(self, _rhs: B) -> Self::Output { - self - } -} - -impl Mul for B { - type Output = Self; - fn mul(self, _rhs: usize) -> Self::Output { - self - } -} - -fn main() { - let a = A { f: [1] }; - let _ = B { f: a }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41888.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41888.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41888.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41888.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { let _ = g(Some(E::F(K))); } - -type R = Result<(), ()>; -struct K; - -enum E { - F(K), // must not be built-in type - #[allow(dead_code)] - G(Box, Box), -} - -fn translate(x: R) -> R { x } - -fn g(mut status: Option) -> R { - loop { - match status { - Some(infix_or_postfix) => match infix_or_postfix { - E::F(_op) => { // <- must be captured by value - match Ok(()) { - Err(err) => return Err(err), - Ok(_) => {}, - }; - } - _ => (), - }, - _ => match translate(Err(())) { - Err(err) => return Err(err), - Ok(_) => {}, - } - } - status = None; - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41936-variance-coerce-unsized-cycle.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41936-variance-coerce-unsized-cycle.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41936-variance-coerce-unsized-cycle.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-41936-variance-coerce-unsized-cycle.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #41936. The coerce-unsized trait check in -// coherence was using subtyping, which triggered variance -// computation, which failed because it required type info for fields -// that had not (yet) been computed. - -#![feature(unsize)] -#![feature(coerce_unsized)] - -use std::{marker,ops}; - -// Change the array to a non-array, and error disappears -// Adding a new field to the end keeps the error -struct LogDataBuf([u8;8]); - -struct Aref -{ - // Inner structure triggers the error, removing the inner removes the message. - ptr: Box>, -} -impl, U: ?Sized> ops::CoerceUnsized> for Aref {} - -struct ArefInner -{ - // Even with this field commented out, the error is raised. - data: T, -} - -fn main(){} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42007.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42007.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42007.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42007.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue_42007_s.rs - -extern crate issue_42007_s; - -enum I { - E(issue_42007_s::E), -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4208.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4208.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4208.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4208.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-4208-cc.rs - -// pretty-expanded FIXME #23616 - -extern crate numeric; -use numeric::{sin, Angle}; - -fn foo>(theta: A) -> T { sin(&theta) } - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42148.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42148.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42148.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42148.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct Zst; - -fn main() { - unsafe { ::std::ptr::write_volatile(1 as *mut Zst, Zst) } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42210.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42210.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42210.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42210.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #42210. - -// compile-flags: -g - -trait Foo { - fn foo() { } -} - -struct Bar; - -trait Baz { -} - -impl Foo for (Bar, Baz) { } - - -fn main() { - <(Bar, Baz) as Foo>::foo() -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4228.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4228.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4228.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4228.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -struct Foo; - -impl Foo { - fn first() {} -} -impl Foo { - fn second() {} -} - -pub fn main() { - Foo::first(); - Foo::second(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42453.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42453.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42453.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42453.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -#[derive(Debug)] -struct builder; - -fn main() { - -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42463.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42463.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42463.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42463.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::ops::{Deref, DerefMut}; - -struct CheckedDeref { - value: T, - check: F -} - -impl bool, T> Deref for CheckedDeref { - type Target = T; - fn deref(&self) -> &T { - assert!((self.check)(&self.value)); - &self.value - } -} - -impl bool, T> DerefMut for CheckedDeref { - fn deref_mut(&mut self) -> &mut T { - assert!((self.check)(&self.value)); - &mut self.value - } -} - - -fn main() { - let mut v = CheckedDeref { - value: vec![0], - check: |v: &Vec<_>| !v.is_empty() - }; - v.push(1); - assert_eq!(*v, vec![0, 1]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42467.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42467.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42467.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42467.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct Foo(T); - -struct IntoIter(T); - -impl<'a, T: 'a> Iterator for IntoIter { - type Item = (); - - fn next(&mut self) -> Option<()> { - None - } -} - -impl IntoIterator for Foo { - type Item = (); - type IntoIter = IntoIter; - - fn into_iter(self) -> IntoIter { - IntoIter(self.0) - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4252.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4252.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4252.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4252.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait X { - fn call(&self, x: &T); - fn default_method(&self, x: &T) { - println!("X::default_method {:?}", x); - } -} - -#[derive(Debug)] -struct Y(isize); - -#[derive(Debug)] -struct Z { - x: T -} - -impl X for Y { - fn call(&self, x: &T) { - println!("X::call {:?} {:?}", self, x); - } -} - -impl Drop for Z { - fn drop(&mut self) { - // These statements used to cause an ICE. - self.x.call(self); - self.x.default_method(self); - } -} - -pub fn main() { - let _z = Z {x: Y(42)}; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42552.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42552.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42552.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42552.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for an obscure issue with the projection cache. - -fn into_iter(a: &I) -> Groups { - Groups { _a: a } -} - -pub struct Groups<'a, I: 'a> { - _a: &'a I, -} - -impl<'a, I: Iterator> Iterator for Groups<'a, I> { - type Item = Group<'a, I>; - fn next(&mut self) -> Option { - None - } -} - -pub struct Group<'a, I: Iterator + 'a> - where I::Item: 'a // <-- needed to trigger ICE! -{ - _phantom: &'a (), - _ice_trigger: I::Item, // <-- needed to trigger ICE! -} - - -fn main() { - let _ = into_iter(&[0].iter().map(|_| 0)).map(|grp| { - let _g = grp; - }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42679.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42679.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42679.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42679.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] -#![feature(box_patterns)] - -#[derive(Debug, PartialEq)] -enum Test { - Foo(usize), - Bar(isize), -} - -fn main() { - let a = box Test::Foo(10); - let b = box Test::Bar(-20); - match (a, b) { - (_, box Test::Foo(_)) => unreachable!(), - (box Test::Foo(x), b) => { - assert_eq!(x, 10); - assert_eq!(b, box Test::Bar(-20)); - }, - _ => unreachable!(), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42747.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42747.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42747.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42747.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! fooN { - ($cur:ident $prev:ty) => { - #[allow(dead_code)] - enum $cur { - Empty, - First($prev), - Second($prev), - Third($prev), - Fourth($prev), - } - } -} - -fooN!(Foo0 ()); -fooN!(Foo1 Foo0); -fooN!(Foo2 Foo1); -fooN!(Foo3 Foo2); -fooN!(Foo4 Foo3); -fooN!(Foo5 Foo4); -fooN!(Foo6 Foo5); -fooN!(Foo7 Foo6); -fooN!(Foo8 Foo7); -fooN!(Foo9 Foo8); -fooN!(Foo10 Foo9); -fooN!(Foo11 Foo10); -fooN!(Foo12 Foo11); -fooN!(Foo13 Foo12); -fooN!(Foo14 Foo13); -fooN!(Foo15 Foo14); -fooN!(Foo16 Foo15); -fooN!(Foo17 Foo16); -fooN!(Foo18 Foo17); -fooN!(Foo19 Foo18); -fooN!(Foo20 Foo19); -fooN!(Foo21 Foo20); -fooN!(Foo22 Foo21); -fooN!(Foo23 Foo22); -fooN!(Foo24 Foo23); -fooN!(Foo25 Foo24); -fooN!(Foo26 Foo25); -fooN!(Foo27 Foo26); - -fn main() { - let _foo = Foo27::Empty; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42956.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42956.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42956.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-42956.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] -#![feature(associated_consts)] - -impl A for i32 { - type Foo = u32; -} -impl B for u32 { - const BAR: i32 = 0; -} - -trait A { - type Foo: B; -} - -trait B { - const BAR: i32; -} - -fn generic() { - // This panics if the universal function call syntax is used as well - println!("{}", T::Foo::BAR); -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43057.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43057.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43057.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43057.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(unused)] - -macro_rules! column { - ($i:ident) => { - $i - }; -} - -fn foo() -> ! { - panic!(); -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43132.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43132.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43132.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43132.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(unused)] - -fn main() { -} - -fn foo() { - let b = mk::< - Forward<(Box>,)>, - >(); - b.map_err(|_| ()).join(); -} - -fn mk() -> T { - loop {} -} - -impl, E> Future for (I,) { - type Error = E; -} - -struct Forward { - _a: T, -} - -impl Future for Forward -where - T::Error: From, -{ - type Error = T::Error; -} - -trait Future { - type Error; - - fn map_err(self, _: F) -> (Self, F) - where - F: FnOnce(Self::Error) -> E, - Self: Sized, - { - loop {} - } - - fn join(self) -> (MaybeDone, ()) - where - Self: Sized, - { - loop {} - } -} - -impl Future for Box { - type Error = S::Error; -} - -enum MaybeDone { - _Done(A::Error), -} - -impl Future for (A, F) -where - F: FnOnce(A::Error) -> U, -{ - type Error = U; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43205.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43205.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43205.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43205.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - &&[()][0]; - println!("{:?}", &[(),()][1]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43291.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43291.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43291.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43291.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn main() { - assert_eq!(!0usize as *const (), foo(0, 1)); - assert_eq!(!0usize as *const (), (0i8 - 1) as *const ()); -} - -pub fn foo(a: i8, b: i8) -> *const () { - (a - b) as *const () -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4333.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4333.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4333.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4333.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -use std::io; - -pub fn main() { - let stdout = &mut io::stdout() as &mut io::Write; - stdout.write(b"Hello!"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43357.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43357.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43357.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43357.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Trait { - type Output; -} - -fn f() { - std::mem::size_of::(); -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43483.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43483.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43483.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43483.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait VecN { - const DIM: usize; -} - -trait Mat { - type Row: VecN; -} - -fn m() { - let x = M::Row::DIM; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43692.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43692.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43692.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43692.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - assert_eq!('\u{10__FFFF}', '\u{10FFFF}'); - assert_eq!("\u{10_F0FF__}foo\u{1_0_0_0__}", "\u{10F0FF}foo\u{1000}"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43853.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43853.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43853.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43853.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare compiled with panic=abort by default - -use std::panic; - -fn test() { - wait(|| panic!()); -} - -fn wait T>(f: F) -> F::Output { - From::from(f()) -} - -fn main() { - let result = panic::catch_unwind(move || test()); - assert!(result.is_err()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4387.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4387.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4387.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4387.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub fn main() { - let _foo = [0; 2*4]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43910.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43910.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43910.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43910.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![deny(unused_variables)] - -fn main() { - #[allow(unused_variables)] - let x = 12; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43923.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43923.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43923.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-43923.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct A { ptr: T } - -fn foo(x: &A<[T]>) {} - -fn main() { - let a = foo; - let b = A { ptr: [a, a, a] }; - a(&A { ptr: [()] }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44005.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44005.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44005.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44005.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub trait Foo<'a> { - type Bar; - fn foo(&'a self) -> Self::Bar; -} - -impl<'a, 'b, T: 'a> Foo<'a> for &'b T { - type Bar = &'a T; - fn foo(&'a self) -> &'a T { - self - } -} - -pub fn uncallable(x: T, f: F) - where T: for<'a> Foo<'a>, - F: for<'a> Fn(>::Bar) -{ - f(x.foo()); -} - -pub fn catalyst(x: &i32) { - broken(x, |_| {}) -} - -pub fn broken(x: &i32, f: F) { - uncallable(x, |y| f(y)); -} - -fn main() { } - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4401.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4401.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4401.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4401.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn main() { - let mut count = 0; - for _ in 0..999_999 { count += 1; } - assert_eq!(count, 999_999); - println!("{}", count); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44056.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44056.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44056.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44056.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// only-x86_64 -// no-prefer-dynamic -// compile-flags: -Ctarget-feature=+avx -Clto - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44247.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44247.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44247.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44247.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait T { - type X; - const X: Self::X; -} -fn foo() { - let _: X::X = X::X; -} - -trait S { - const X: Self::X; - type X; -} -fn bar() { - let _: X::X = X::X; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44333.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44333.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44333.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44333.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -type Func = fn(usize, usize) -> usize; - -fn foo(a: usize, b: usize) -> usize { a + b } -fn bar(a: usize, b: usize) -> usize { a * b } -fn test(x: usize) -> Func { - if x % 2 == 0 { foo } - else { bar } -} - -const FOO: Func = foo; -const BAR: Func = bar; - -fn main() { - match test(std::env::consts::ARCH.len()) { - FOO => println!("foo"), - BAR => println!("bar"), - _ => unreachable!(), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44373.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44373.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44373.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44373.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: -Z borrowck=compare - -struct Foo(bool); - -struct Container(&'static [&'static Foo]); - -static FOO: Foo = Foo(true); -static CONTAINER: Container = Container(&[&FOO]); - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44402.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44402.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44402.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44402.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(never_type)] -#![feature(exhaustive_patterns)] - -// Regression test for inhabitedness check. The old -// cache used to cause us to incorrectly decide -// that `test_b` was invalid. - -struct Foo { - field1: !, - field2: Option<&'static Bar>, -} - -struct Bar { - field1: &'static Foo -} - -fn test_a() { - let x: Option = None; - match x { None => () } -} - -fn test_b() { - let x: Option = None; - match x { None => () } -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4446.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4446.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4446.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4446.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::sync::mpsc::channel; -use std::thread; - -pub fn main() { - let (tx, rx) = channel(); - - tx.send("hello, world").unwrap(); - - thread::spawn(move|| { - println!("{}", rx.recv().unwrap()); - }).join().ok().unwrap(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4448.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4448.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4448.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4448.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::sync::mpsc::channel; -use std::thread; - -pub fn main() { - let (tx, rx) = channel::<&'static str>(); - - let t = thread::spawn(move|| { - assert_eq!(rx.recv().unwrap(), "hello, world"); - }); - - tx.send("hello, world").unwrap(); - t.join().ok().unwrap(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4464.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4464.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4464.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4464.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn broken(v: &[u8], i: usize, j: usize) -> &[u8] { &v[i..j] } - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44730.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44730.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44730.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44730.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -//! dox - -#![deny(missing_docs)] - -macro_rules! doc { - ($e:expr) => ( - #[doc = $e] - pub struct Foo; - ) -} - -doc!("a"); - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44851.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44851.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44851.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-44851.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! a { - () => { "a" } -} - -macro_rules! b { - ($doc:expr) => { - #[doc = $doc] - pub struct B; - } -} - -b!(a!()); - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-45124.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-45124.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-45124.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-45124.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: --edition 2018 - -#![feature(try_blocks)] - -fn main() { - let mut a = 0; - let () = { - let _: Result<(), ()> = try { - let _ = Err(())?; - return - }; - a += 1; - }; - a += 2; - assert_eq!(a, 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-45152.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-45152.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-45152.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-45152.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(unsize, coerce_unsized)] - -#[repr(packed)] -struct UnalignedPtr<'a, T: ?Sized> - where T: 'a, -{ - data: &'a T, -} - -fn main() { - - impl<'a, T, U> std::ops::CoerceUnsized> for UnalignedPtr<'a, T> - where - T: std::marker::Unsize + ?Sized, - U: ?Sized, - { } - - let arr = [1, 2, 3]; - let arr_unaligned: UnalignedPtr<[i32; 3]> = UnalignedPtr { data: &arr }; - let arr_unaligned: UnalignedPtr<[i32]> = arr_unaligned; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4541.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4541.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4541.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4541.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-cloudabi no std::env - -fn parse_args() -> String { - let args: Vec<_> = ::std::env::args().collect(); - let mut n = 0; - - while n < args.len() { - match &*args[n] { - "-v" => (), - s => { - return s.to_string(); - } - } - n += 1; - } - - return "".to_string() -} - -pub fn main() { - println!("{}", parse_args()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-45425.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-45425.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-45425.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-45425.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::ops::Add; - -fn ref_add(a: &T, b: &T) -> T -where - for<'x> &'x T: Add<&'x T, Output = T>, -{ - a + b -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4542.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4542.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4542.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4542.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 -// ignore-cloudabi no std::env - -use std::env; - -pub fn main() { - for arg in env::args() { - match arg.clone() { - _s => { } - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4545.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4545.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4545.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4545.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-4545.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_4545 as somelib; -pub fn main() { somelib::mk::(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-45731.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-45731.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-45731.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-45731.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags:--test -g - -#[cfg(target_os = "macos")] -#[test] -fn simple_test() { - use std::{env, panic, fs}; - - // Find our dSYM and replace the DWARF binary with an empty file - let mut dsym_path = env::current_exe().unwrap(); - let executable_name = dsym_path.file_name().unwrap().to_str().unwrap().to_string(); - assert!(dsym_path.pop()); // Pop executable - dsym_path.push(format!("{}.dSYM/Contents/Resources/DWARF/{0}", executable_name)); - { - let file = fs::OpenOptions::new().read(false).write(true).truncate(true).create(false) - .open(&dsym_path).unwrap(); - } - - env::set_var("RUST_BACKTRACE", "1"); - - // We don't need to die of panic, just trigger a backtrace - let _ = panic::catch_unwind(|| { - assert!(false); - }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46069.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46069.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46069.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46069.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::iter::{Fuse, Cloned}; -use std::slice::Iter; - -struct Foo<'a, T: 'a>(&'a T); -impl<'a, T: 'a> Copy for Foo<'a, T> {} -impl<'a, T: 'a> Clone for Foo<'a, T> { - fn clone(&self) -> Self { *self } -} - -fn copy_ex() { - let s = 2; - let k1 = || s; - let upvar = Foo(&k1); - let k = || upvar; - k(); -} - -fn main() { - let _f = 0 as *mut >> as Iterator>::Item; - - copy_ex(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46095.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46095.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46095.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46095.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct A; - -impl A { - fn take_mutably(&mut self) {} -} - -fn identity(t: T) -> T { - t -} - -// Issue 46095 -// Built-in indexing should be used even when the index is not -// trivially an integer -// Overloaded indexing would cause wrapped to be borrowed mutably - -fn main() { - let mut a1 = A; - let mut a2 = A; - - let wrapped = [&mut a1, &mut a2]; - - { - wrapped[0 + 1 - 1].take_mutably(); - } - - { - wrapped[identity(0)].take_mutably(); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46519.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46519.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46519.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46519.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags:--test -O - -#[test] -#[should_panic(expected = "creating inhabited type")] -fn test() { - FontLanguageOverride::system_font(SystemFont::new()); -} - -pub enum FontLanguageOverride { - Normal, - Override(&'static str), - System(SystemFont) -} - -pub enum SystemFont {} - -impl FontLanguageOverride { - fn system_font(f: SystemFont) -> Self { - FontLanguageOverride::System(f) - } -} - -impl SystemFont { - fn new() -> Self { - panic!("creating inhabited type") - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46553.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46553.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46553.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46553.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(const_fn)] -#![deny(const_err)] - -pub struct Data { - function: fn() -> T, -} - -impl Data { - pub const fn new(function: fn() -> T) -> Data { - Data { - function: function, - } - } -} - -pub static DATA: Data = Data::new(|| { - 413i32 -}); - -fn main() { - print!("{:?}", (DATA.function)()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46845.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46845.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46845.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46845.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// To work around #46855 -// compile-flags: -Z mir-opt-level=0 -// Regression test for the inhabitedness of unions with uninhabited variants, issue #46845 - -use std::mem; - -#[derive(Copy, Clone)] -enum Never { } - -// A single uninhabited variant shouldn't make the whole union uninhabited. -union Foo { - a: u64, - _b: Never -} - -// If all the variants are uninhabited, however, the union should be uninhabited. -// NOTE(#49298) the union being uninhabited shouldn't change its size. -union Bar { - _a: (Never, u64), - _b: (u64, Never) -} - -fn main() { - assert_eq!(mem::size_of::(), 8); - // See the note on `Bar`'s definition for why this isn't `0`. - assert_eq!(mem::size_of::(), 8); - - let f = [Foo { a: 42 }, Foo { a: 10 }]; - println!("{}", unsafe { f[0].a }); - assert_eq!(unsafe { f[1].a }, 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46855.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46855.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46855.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46855.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: -Zmir-opt-level=1 - -use std::mem; - -#[derive(Copy, Clone)] -enum Never {} - -union Foo { - a: u64, - b: Never -} - -fn foo(xs: [(Never, u32); 1]) -> u32 { xs[0].1 } - -fn bar([(_, x)]: [(Never, u32); 1]) -> u32 { x } - -fn main() { - println!("{}", mem::size_of::()); - - let f = [Foo { a: 42 }, Foo { a: 10 }]; - println!("{:?}", unsafe { f[0].a }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46920-byte-array-patterns.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46920-byte-array-patterns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46920-byte-array-patterns.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46920-byte-array-patterns.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -const CURSOR_PARTITION_LABEL: &'static [u8] = b"partition"; -const CURSOR_EVENT_TYPE_LABEL: &'static [u8] = b"event_type"; -const BYTE_PATTERN: &'static [u8; 5] = b"hello"; - -fn match_slice(x: &[u8]) -> u32 { - match x { - CURSOR_PARTITION_LABEL => 0, - CURSOR_EVENT_TYPE_LABEL => 1, - _ => 2, - } -} - -fn match_array(x: &[u8; 5]) -> bool { - match x { - BYTE_PATTERN => true, - _ => false - } -} - -fn main() { - assert_eq!(match_slice(b"abcde"), 2); - assert_eq!(match_slice(b"event_type"), 1); - assert_eq!(match_slice(b"partition"), 0); - - assert_eq!(match_array(b"hello"), true); - assert_eq!(match_array(b"hella"), false); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46959.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46959.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46959.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46959.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![deny(non_camel_case_types)] - -#[allow(dead_code)] -fn qqq(lol: impl Iterator) -> impl Iterator { - lol.map(|x|x as u64) -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46964.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46964.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46964.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-46964.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -mod my_mod { - #[derive(Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Hash)] - pub struct Name<'a> { - source: &'a str, - } - - pub const JSON: Name = Name { source: "JSON" }; -} - -pub fn crash() -> bool { - match (my_mod::JSON, None) { - (_, Some(my_mod::JSON)) => true, - (my_mod::JSON, None) => true, - _ => false, - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47139-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47139-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47139-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47139-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for issue #47139: -// -// Coherence was encountering an (unnecessary) overflow trying to -// decide if the two impls of dummy overlap. -// -// The overflow went something like: -// -// - `&'a ?T: Insertable` ? -// - let ?T = Option ? -// - `Option: Insertable` ? -// - `Option<&'a ?U>: Insertable` ? -// - `&'a ?U: Insertable` ? -// -// While somewhere in the middle, a projection would occur, which -// broke cycle detection. -// -// It turned out that this cycle was being kicked off due to some -// extended diagnostic attempts in coherence, so removing those -// sidestepped the issue for now. - -#![allow(dead_code)] - -pub trait Insertable { - type Values; - - fn values(self) -> Self::Values; -} - -impl Insertable for Option - where - T: Insertable, - T::Values: Default, -{ - type Values = T::Values; - - fn values(self) -> Self::Values { - self.map(Insertable::values).unwrap_or_default() - } -} - -impl<'a, T> Insertable for &'a Option - where - Option<&'a T>: Insertable, -{ - type Values = as Insertable>::Values; - - fn values(self) -> Self::Values { - self.as_ref().values() - } -} - -impl<'a, T> Insertable for &'a [T] -{ - type Values = Self; - - fn values(self) -> Self::Values { - self - } -} - -trait Unimplemented { } - -trait Dummy { } - -struct Foo { t: T } - -impl<'a, U> Dummy for Foo<&'a U> - where &'a U: Insertable -{ -} - -impl Dummy for T - where T: Unimplemented -{ } - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47139-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47139-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47139-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47139-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for issue #47139: -// -// Same as issue-47139-1.rs, but the impls of dummy are in the -// opposite order. This influenced the way that coherence ran and in -// some cases caused the overflow to occur when it wouldn't otherwise. -// In an effort to make the regr test more robust, I am including both -// orderings. - -#![allow(dead_code)] - -pub trait Insertable { - type Values; - - fn values(self) -> Self::Values; -} - -impl Insertable for Option - where - T: Insertable, - T::Values: Default, -{ - type Values = T::Values; - - fn values(self) -> Self::Values { - self.map(Insertable::values).unwrap_or_default() - } -} - -impl<'a, T> Insertable for &'a Option - where - Option<&'a T>: Insertable, -{ - type Values = as Insertable>::Values; - - fn values(self) -> Self::Values { - self.as_ref().values() - } -} - -impl<'a, T> Insertable for &'a [T] -{ - type Values = Self; - - fn values(self) -> Self::Values { - self - } -} - -trait Unimplemented { } - -trait Dummy { } - -struct Foo { t: T } - -impl Dummy for T - where T: Unimplemented -{ } - -impl<'a, U> Dummy for Foo<&'a U> - where &'a U: Insertable -{ -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4734.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4734.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4734.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4734.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Ensures that destructors are run for expressions of the form "e;" where -// `e` is a type which requires a destructor. - - -#![allow(path_statements)] - -struct A { n: isize } -struct B; - -static mut NUM_DROPS: usize = 0; - -impl Drop for A { - fn drop(&mut self) { - unsafe { NUM_DROPS += 1; } - } -} - -impl Drop for B { - fn drop(&mut self) { - unsafe { NUM_DROPS += 1; } - } -} - -fn main() { - assert_eq!(unsafe { NUM_DROPS }, 0); - { let _a = A { n: 1 }; } - assert_eq!(unsafe { NUM_DROPS }, 1); - { A { n: 3 }; } - assert_eq!(unsafe { NUM_DROPS }, 2); - - { let _b = B; } - assert_eq!(unsafe { NUM_DROPS }, 3); - { B; } - assert_eq!(unsafe { NUM_DROPS }, 4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4735.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4735.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4735.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4735.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -use std::mem::transmute; - -struct NonCopyable(*const u8); - -impl Drop for NonCopyable { - fn drop(&mut self) { - let NonCopyable(p) = *self; - let _v = unsafe { transmute::<*const u8, Box>(p) }; - } -} - -pub fn main() { - let t = Box::new(0); - let p = unsafe { transmute::, *const u8>(t) }; - let _z = NonCopyable(p); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47364.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47364.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47364.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47364.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: -C codegen-units=8 -O -#![allow(non_snake_case)] - -fn main() { - nom_sql::selection(b"x "); -} - -pub enum Err

{ - Position(P), - NodePosition(u32), -} - -pub enum IResult { - Done(I,O), - Error(Err), - Incomplete(u32, u64) -} - -pub fn multispace(input: T) -> ::IResult { - ::IResult::Done(0, 0) -} - -mod nom_sql { - fn where_clause(i: &[u8]) -> ::IResult<&[u8], Option> { - let X = match ::multispace(i) { - ::IResult::Done(..) => ::IResult::Done(i, None::), - _ => ::IResult::Error(::Err::NodePosition(0)), - }; - match X { - ::IResult::Done(_, _) => ::IResult::Done(i, None), - _ => X - } - } - - pub fn selection(i: &[u8]) { - let Y = match { - match { - where_clause(i) - } { - ::IResult::Done(_, o) => ::IResult::Done(i, Some(o)), - ::IResult::Error(_) => ::IResult::Done(i, None), - _ => ::IResult::Incomplete(0, 0), - } - } { - ::IResult::Done(z, _) => ::IResult::Done(z, None::), - _ => return () - }; - match Y { - ::IResult::Done(x, _) => { - let bytes = b"; "; - let len = x.len(); - bytes[len]; - } - _ => () - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4759-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4759-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4759-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4759-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait U { fn f(self); } -impl U for isize { fn f(self) {} } -pub fn main() { 4.f(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4759.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4759.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4759.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4759.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 -#![allow(non_shorthand_field_patterns)] - -#![feature(box_syntax)] - -struct T { a: Box } - -trait U { - fn f(self); -} - -impl U for Box { - fn f(self) { } -} - -pub fn main() { - let T { a: a } = T { a: box 0 }; - a.f(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47638.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47638.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47638.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47638.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn id<'c, 'b>(f: &'c &'b Fn(&i32)) -> &'c &'b Fn(&'static i32) { - f -} - -fn main() { - let f: &Fn(&i32) = &|x| {}; - id(&f); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47673.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47673.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47673.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47673.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use {{}, {}}; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47703-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47703-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47703-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47703-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(nll)] - -struct AtomicRefMut<'a> { - value: &'a mut i32, - borrow: AtomicBorrowRefMut, -} - -struct AtomicBorrowRefMut { -} - -impl Drop for AtomicBorrowRefMut { - fn drop(&mut self) { - } -} - -fn map(orig: AtomicRefMut) -> AtomicRefMut { - AtomicRefMut { - value: orig.value, - borrow: orig.borrow, - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47703.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47703.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47703.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47703.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(nll)] - -struct MyStruct<'a> { - field: &'a mut (), - field2: WithDrop -} - -struct WithDrop; - -impl Drop for WithDrop { - fn drop(&mut self) {} -} - -impl<'a> MyStruct<'a> { - fn consume(self) -> &'a mut () { self.field } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47703-tuple.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47703-tuple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47703-tuple.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47703-tuple.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(nll)] - -struct WithDrop; - -impl Drop for WithDrop { - fn drop(&mut self) {} -} - -fn consume(x: (&mut (), WithDrop)) -> &mut () { x.0 } - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47722.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47722.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47722.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47722.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// 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() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47789.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47789.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47789.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-47789.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -#![feature(nll)] - -static mut x: &'static u32 = &0; - -fn foo() { - unsafe { x = &1; } -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48159.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48159.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48159.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48159.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(repr_packed)] -#![allow(non_camel_case_types)] - -use std::mem; - -pub enum c_void {} - -type uintptr_t = usize; -type int16_t = u16; -type uint16_t = int16_t; -type uint32_t = u32; -type intptr_t = uintptr_t; - -#[repr(C)] -#[repr(packed(4))] -pub struct kevent { - pub ident: uintptr_t, - pub filter: int16_t, - pub flags: uint16_t, - pub fflags: uint32_t, - pub data: intptr_t, - pub udata: *mut c_void, -} - -fn main() { - assert_eq!(mem::align_of::(), 4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4830.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4830.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4830.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4830.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// pretty-expanded FIXME #23616 - -pub struct Scheduler { - /// The event loop used to drive the scheduler and perform I/O - event_loop: Box -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48508-aux.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48508-aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48508-aux.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48508-aux.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-test Not a test. Used by issue-48508.rs - -pub fn other() -> f64 { - let µ = 1.0; - µ -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48508.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48508.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48508.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48508.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for issue #48508: -// -// Confusion between global and local file offsets caused incorrect handling of multibyte character -// spans when compiling multiple files. One visible effect was an ICE generating debug information -// when a multibyte character is at the end of a scope. The problematic code is actually in -// issue-48508-aux.rs - -// compile-flags:-g -// ignore-pretty issue #37195 - -#![feature(non_ascii_idents)] - -#[path = "issue-48508-aux.rs"] -mod other_file; - -fn main() { - other_file::other(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48551.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48551.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48551.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48551.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #48551. Covers a case where duplicate candidates -// arose during associated type projection. - -use std::ops::{Mul, MulAssign}; - -pub trait ClosedMul: Sized + Mul + MulAssign {} -impl ClosedMul for T -where - T: Mul + MulAssign, -{ -} - -pub trait InnerSpace: ClosedMul<::Real> { - type Real; -} - -pub trait FiniteDimVectorSpace: ClosedMul<::Field> { - type Field; -} - -pub trait FiniteDimInnerSpace - : InnerSpace + FiniteDimVectorSpace::Real> { -} - -pub trait EuclideanSpace: ClosedMul<::Real> { - type Coordinates: FiniteDimInnerSpace - + Mul - + MulAssign; - - type Real; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4865-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4865-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4865-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4865-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This should resolve fine. -// Prior to fix, the crossed imports between a and b -// would block on the glob import, itself never being resolved -// because these previous imports were not resolved. - -pub mod a { - use b::fn_b; - use c::*; - - pub fn fn_a(){ - } -} - -pub mod b { - use a::fn_a; - use c::*; - - pub fn fn_b(){ - } -} - -pub mod c{ - pub fn fn_c(){ - } -} - -use a::fn_a; -use b::fn_b; - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4865-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4865-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4865-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4865-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Previously, this would have failed to resolve due to the circular -// block between `use say` and `pub use hello::*`. -// -// Now, as `use say` is not `pub`, the glob import can resolve -// without any problem and this resolves fine. - -pub use hello::*; - -pub mod say { - pub fn hello() { println!("hello"); } -} - -pub mod hello { - use say; - - pub fn hello() { - say::hello(); - } -} - -fn main() { - hello(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4865-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4865-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4865-3.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4865-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This should resolve fine even with the circular imports as -// they are not `pub`. - -pub mod a { - use b::*; -} - -pub mod b { - use a::*; -} - -use a::*; - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4875.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4875.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4875.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-4875.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// regression test for issue 4875 - -// pretty-expanded FIXME #23616 - -pub struct Foo { - data: T, -} - -fn foo(Foo{..}: Foo) { -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48962.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48962.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48962.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48962.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we are able to reinitialize box with moved referent -#![feature(nll)] -static mut ORDER: [usize; 3] = [0, 0, 0]; -static mut INDEX: usize = 0; - -struct Dropee (usize); - -impl Drop for Dropee { - fn drop(&mut self) { - unsafe { - ORDER[INDEX] = self.0; - INDEX = INDEX + 1; - } - } -} - -fn add_sentintel() { - unsafe { - ORDER[INDEX] = 2; - INDEX = INDEX + 1; - } -} - -fn main() { - let mut x = Box::new(Dropee(1)); - *x; // move out from `*x` - add_sentintel(); - *x = Dropee(3); // re-initialize `*x` - {x}; // drop value - unsafe { - assert_eq!(ORDER, [1, 2, 3]); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48984.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48984.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48984.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-48984.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-48984-aux.rs -extern crate issue48984aux; -use issue48984aux::Bar; - -fn do_thing() { } - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49298.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49298.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49298.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49298.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(test)] - -extern crate test; - -enum Void {} - -fn main() { - let mut x: (Void, usize); - let mut y = 42; - x.1 = 13; - - // Make sure `y` stays on the stack. - test::black_box(&mut y); - - // Check that the write to `x.1` did not overwrite `y`. - // Note that this doesn't fail with optimizations enabled, - // because we can't keep `x.1` on the stack, like we can `y`, - // as we can't borrow partially initialized variables. - assert_eq!(y.to_string(), "42"); - - // Check that `(Void, usize)` has space for the `usize` field. - assert_eq!(std::mem::size_of::<(Void, usize)>(), - std::mem::size_of::()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49556.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49556.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49556.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49556.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn iter<'a>(data: &'a [usize]) -> impl Iterator + 'a { - data.iter() - .map( - |x| x // fn(&'a usize) -> &'(ReScope) usize - ) - .map( - |x| *x // fn(&'(ReScope) usize) -> usize - ) -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49588-non-shorthand-field-patterns-in-pattern-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49588-non-shorthand-field-patterns-in-pattern-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49588-non-shorthand-field-patterns-in-pattern-macro.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49588-non-shorthand-field-patterns-in-pattern-macro.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![deny(non_shorthand_field_patterns)] - -pub struct Value { pub value: A } - -#[macro_export] -macro_rules! pat { - ($a:pat) => { - Value { value: $a } - }; -} - -fn main() { - let pat!(value) = Value { value: () }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49632.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49632.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49632.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49632.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(stmt_expr_attributes)] - -pub fn main() { - let _x = #[inline(always)] || {}; - let _y = #[inline(never)] || {}; - let _z = #[inline] || {}; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49685.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49685.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49685.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49685.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for #49685: drop elaboration was not revealing the -// value of `impl Trait` returns, leading to an ICE. - -fn main() { - let _ = Some(()) - .into_iter() - .flat_map(|_| Some(()).into_iter().flat_map(func)); -} - -fn func(_: ()) -> impl Iterator { - Some(()).into_iter().flat_map(|_| vec![]) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49854.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49854.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49854.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49854.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::ffi::OsString; - -fn main() { - let os_str = OsString::from("Hello Rust!"); - - assert_eq!(os_str, "Hello Rust!"); - assert_eq!("Hello Rust!", os_str); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49955-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49955-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49955-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49955-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: -Z borrowck=mir - -use std::cell::Cell; - -#[inline(never)] -fn tuple_field() -> &'static u32 { - // This test is MIR-borrowck-only because the old borrowck - // doesn't agree that borrows of "frozen" (i.e. without any - // interior mutability) fields of non-frozen temporaries, - // should be promoted, while MIR promotion does promote them. - &(Cell::new(5), 42).1 -} - -fn main() { - assert_eq!(tuple_field().to_string(), "42"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49955.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49955.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49955.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49955.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: -Z borrowck=compare - -const ALL_THE_NUMS: [u32; 1] = [ - 1 -]; - -#[inline(never)] -fn array(i: usize) -> &'static u32 { - return &ALL_THE_NUMS[i]; -} - -#[inline(never)] -fn tuple_field() -> &'static u32 { - &(42,).0 -} - -fn main() { - assert_eq!(tuple_field().to_string(), "42"); - assert_eq!(array(0).to_string(), "1"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49973.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49973.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49973.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-49973.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Debug)] -#[repr(i32)] -enum E { - Min = -2147483648i32, - _Max = 2147483647i32, -} - -fn main() { - assert_eq!(Some(E::Min).unwrap() as i32, -2147483648i32); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5008-borrowed-traitobject-method-call.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5008-borrowed-traitobject-method-call.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5008-borrowed-traitobject-method-call.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5008-borrowed-traitobject-method-call.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -/* - -#5008 cast to &Trait causes code to segfault on method call - -It fixes itself if the &Trait is changed to @Trait. -*/ - -trait Debuggable { - fn debug_name(&self) -> String; -} - -#[derive(Clone)] -struct Thing { - name: String, -} - -impl Thing { - fn new() -> Thing { Thing { name: "dummy".to_string() } } -} - -impl Debuggable for Thing { - fn debug_name(&self) -> String { self.name.clone() } -} - -fn print_name(x: &Debuggable) -{ - println!("debug_name = {}", x.debug_name()); -} - -pub fn main() { - let thing = Thing::new(); - print_name(&thing as &Debuggable); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50415.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50415.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50415.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50415.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - // -------- Simplified test case -------- - - let _ = || 0..=1; - - // -------- Original test case -------- - - let full_length = 1024; - let range = { - // do some stuff, omit here - None - }; - - let range = range.map(|(s, t)| s..=t).unwrap_or(0..=(full_length-1)); - - assert_eq!(range, 0..=1023); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50442.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50442.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50442.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50442.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -enum Void {} - -enum Foo { - A(i32), - B(Void), - C(i32) -} - -fn main() { - let _foo = Foo::A(0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5060.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5060.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5060.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5060.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! print_hd_tl { - ($field_hd:ident, $($field_tl:ident),+) => ({ - print!("{}", stringify!($field_hd)); - print!("::["); - $( - print!("{}", stringify!($field_tl)); - print!(", "); - )+ - print!("]\n"); - }) -} - -pub fn main() { - print_hd_tl!(x, y, z, w) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50689.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50689.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50689.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50689.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -enum Foo { - Bar = (|x: i32| { }, 42).1, -} - -fn main() { - assert_eq!(Foo::Bar as usize, 42); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50731.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50731.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50731.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50731.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -enum Void {} -fn foo(_: Result<(Void, u32), (Void, String)>) {} -fn main() { - let _: fn(_) = foo; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50811.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50811.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50811.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50811.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(test)] - -extern crate test; - -use std::f64::{NAN, NEG_INFINITY, INFINITY, MAX}; -use std::mem::size_of; -use test::black_box; - -// Ensure the const-eval result and runtime result of float comparison are equivalent. - -macro_rules! compare { - ($op:tt) => { - compare!( - [NEG_INFINITY, -MAX, -1.0, -0.0, 0.0, 1.0, MAX, INFINITY, NAN], - $op - ); - }; - ([$($lhs:expr),+], $op:tt) => { - $(compare!( - $lhs, - $op, - [NEG_INFINITY, -MAX, -1.0, -0.0, 0.0, 1.0, MAX, INFINITY, NAN] - );)+ - }; - ($lhs:expr, $op:tt, [$($rhs:expr),+]) => { - $({ - // Wrap the check in its own function to reduce time needed to borrowck. - fn check() { - static CONST_EVAL: bool = $lhs $op $rhs; - let runtime_eval = black_box($lhs) $op black_box($rhs); - assert_eq!(CONST_EVAL, runtime_eval, stringify!($lhs $op $rhs)); - assert_eq!( - size_of::<[u8; ($lhs $op $rhs) as usize]>(), - runtime_eval as usize, - stringify!($lhs $op $rhs (forced const eval)) - ); - } - check(); - })+ - }; -} - -fn main() { - assert_eq!(0.0/0.0 < 0.0/0.0, false); - assert_eq!(0.0/0.0 > 0.0/0.0, false); - assert_eq!(NAN < NAN, false); - assert_eq!(NAN > NAN, false); - - compare!(==); - compare!(!=); - compare!(<); - compare!(<=); - compare!(>); - compare!(>=); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50865-private-impl-trait/auxiliary/lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50865-private-impl-trait/auxiliary/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50865-private-impl-trait/auxiliary/lib.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50865-private-impl-trait/auxiliary/lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -pub fn bar

( // Error won't happen if "bar" is not generic - _baz: P, -) { - hide_foo()(); -} - -fn hide_foo() -> impl Fn() { // Error won't happen if "iterate" hasn't impl Trait or has generics - foo -} - -fn foo() { // Error won't happen if "foo" isn't used in "iterate" or has generics -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50865-private-impl-trait/main.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50865-private-impl-trait/main.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50865-private-impl-trait/main.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-50865-private-impl-trait/main.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:lib.rs - -// Regression test for #50865. -// When using generics or specifying the type directly, this example -// codegens `foo` internally. However, when using a private `impl Trait` -// function which references another private item, `foo` (in this case) -// wouldn't be codegenned until main.rs used `bar`, as with impl Trait -// it is not cast to `fn()` automatically to satisfy e.g. -// `fn foo() -> fn() { ... }`. - -extern crate lib; - -fn main() { - lib::bar(()); // Error won't happen if bar is called from same crate -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-51185.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-51185.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-51185.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-51185.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn foo() -> impl Into fn(&'a ())> { - (|_| {}) as for<'a> fn(&'a ()) -} - -fn main() { - foo().into()(&()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-51345.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-51345.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-51345.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-51345.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(nll)] - -fn main() { - let mut v = Vec::new(); - - loop { v.push(break) } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-51582.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-51582.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-51582.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-51582.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(core_intrinsics)] - -#[repr(i8)] -pub enum Enum { - VariantA, - VariantB, -} - -fn make_b() -> Enum { Enum::VariantB } - -fn main() { - assert_eq!(1, make_b() as i8); - assert_eq!(1, make_b() as u8); - assert_eq!(1, make_b() as i32); - assert_eq!(1, make_b() as u32); - assert_eq!(1, unsafe { std::intrinsics::discriminant_value(&make_b()) }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-51655.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-51655.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-51655.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-51655.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(dead_code)] - -const PATH_DOT: &[u8] = &[b'.']; - -fn match_slice(element: &[u8]) { - match element { - &[] => {} - PATH_DOT => {} - _ => {} - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-51907.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-51907.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-51907.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-51907.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Foo { - extern fn borrow(&self); - extern fn take(self: Box); -} - -struct Bar; -impl Foo for Bar { - extern fn borrow(&self) {} - extern fn take(self: Box) {} -} - -fn main() { - let foo: Box = Box::new(Bar); - foo.borrow(); - foo.take() -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5192.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5192.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5192.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5192.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - -pub trait EventLoop { - fn dummy(&self) { } -} - -pub struct UvEventLoop { - uvio: isize -} - -impl UvEventLoop { - pub fn new() -> UvEventLoop { - UvEventLoop { - uvio: 0 - } - } -} - -impl EventLoop for UvEventLoop { -} - -pub struct Scheduler { - event_loop: Box, -} - -impl Scheduler { - - pub fn new(event_loop: Box) -> Scheduler { - Scheduler { - event_loop: event_loop, - } - } -} - -pub fn main() { - let _sched = Scheduler::new(box UvEventLoop::new() as Box); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52140/auxiliary/some_crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52140/auxiliary/some_crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52140/auxiliary/some_crate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52140/auxiliary/some_crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -pub fn hello() { - println!("Hello, world!"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52140/main.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52140/main.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52140/main.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52140/main.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:some_crate.rs -// compile-flags:--extern some_crate -// edition:2018 - -mod foo { - pub use some_crate; -} - -fn main() { - ::some_crate::hello(); - foo::some_crate::hello(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52141/auxiliary/some_crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52141/auxiliary/some_crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52141/auxiliary/some_crate.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52141/auxiliary/some_crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -pub fn hello() { - println!("Hello, world!"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52141/main.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52141/main.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52141/main.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52141/main.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:some_crate.rs -// compile-flags:--extern some_crate -// edition:2018 - -use some_crate as some_name; - -mod foo { - pub use crate::some_name::*; -} - -fn main() { - ::some_crate::hello(); - some_name::hello(); - foo::hello(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52169.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52169.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52169.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52169.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(macro_literal_matcher)] - -macro_rules! a { - ($i:literal) => { "right" }; - ($i:tt) => { "wrong" }; -} - -macro_rules! b { - ($i:literal) => { a!($i) }; -} - -fn main() { - assert_eq!(b!(0), "right"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5239-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5239-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5239-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5239-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for issue #5239 - - -pub fn main() { - let _f = |ref x: isize| { *x }; - let foo = 10; - assert_eq!(_f(foo), 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5243.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5243.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5243.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5243.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check that merely having lifetime parameters is not -// enough for codegen to consider this as non-monomorphic, -// which led to various assertions and failures in turn. - -// pretty-expanded FIXME #23616 - -struct S<'a> { - v: &'a isize -} - -fn f<'lt>(_s: &'lt S<'lt>) {} - -pub fn main() { - f(& S { v: &42 }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52557.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52557.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52557.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52557.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This test checks for namespace pollution by private tests. -// Tests used to marked as public causing name conflicts with normal -// functions only in test builds. - -// compile-flags: --test - -mod a { - pub fn foo() -> bool { - true - } -} - -mod b { - #[test] - fn foo() { - local_name(); // ensure the local name still works - } - - #[test] - fn local_name() {} -} - -use a::*; -use b::*; - -pub fn conflict() { - let _: bool = foo(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52705/auxiliary/png2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52705/auxiliary/png2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52705/auxiliary/png2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52705/auxiliary/png2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -pub struct DecodingError; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52705/main.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52705/main.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52705/main.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-52705/main.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:png2.rs -// compile-flags:--extern png2 -// edition:2018 - -mod png { - use png2 as png_ext; - - fn foo() -> png_ext::DecodingError { unimplemented!() } -} - -fn main() { - println!("Hello, world!"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5280.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5280.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5280.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5280.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -type FontTableTag = u32; - -trait FontTableTagConversions { - fn tag_to_string(self); -} - -impl FontTableTagConversions for FontTableTag { - fn tag_to_string(self) { - &self; - } -} - -pub fn main() { - 5.tag_to_string(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5315.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5315.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5315.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5315.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -struct A(bool); - -pub fn main() { - let f = A; - f(true); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5321-immediates-with-bare-self.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5321-immediates-with-bare-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5321-immediates-with-bare-self.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5321-immediates-with-bare-self.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait Fooable { - fn yes(self); -} - -impl Fooable for usize { - fn yes(self) { - for _ in 0..self { println!("yes"); } - } -} - -pub fn main() { - 2.yes(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-53333.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-53333.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-53333.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-53333.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// edition:2018 - -fn main() { - use std; - let std = "std"; - println!("{}", std); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5353.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5353.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5353.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5353.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -const INVALID_ENUM : u32 = 0; -const INVALID_VALUE : u32 = 1; - -fn gl_err_str(err: u32) -> String -{ - match err - { - INVALID_ENUM => { "Invalid enum".to_string() }, - INVALID_VALUE => { "Invalid value".to_string() }, - _ => { "Unknown error".to_string() } - } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5518.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5518.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5518.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5518.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-5518.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_5518 as other; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5521.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5521.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5521.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5521.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-5521.rs - - - -extern crate issue_5521 as foo; - -fn bar(a: foo::map) { - if false { - panic!(); - } else { - let _b = &(*a)[&2]; - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5530.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5530.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5530.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5530.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum Enum { - Foo { foo: usize }, - Bar { bar: usize } -} - -fn fun1(e1: &Enum, e2: &Enum) -> usize { - match (e1, e2) { - (&Enum::Foo { foo: _ }, &Enum::Foo { foo: _ }) => 0, - (&Enum::Foo { foo: _ }, &Enum::Bar { bar: _ }) => 1, - (&Enum::Bar { bar: _ }, &Enum::Bar { bar: _ }) => 2, - (&Enum::Bar { bar: _ }, &Enum::Foo { foo: _ }) => 3, - } -} - -fn fun2(e1: &Enum, e2: &Enum) -> usize { - match (e1, e2) { - (&Enum::Foo { foo: _ }, &Enum::Foo { foo: _ }) => 0, - (&Enum::Foo { foo: _ }, _ ) => 1, - (&Enum::Bar { bar: _ }, &Enum::Bar { bar: _ }) => 2, - (&Enum::Bar { bar: _ }, _ ) => 3, - } -} - -pub fn main() { - let foo = Enum::Foo { foo: 1 }; - let bar = Enum::Bar { bar: 1 }; - - assert_eq!(fun1(&foo, &foo), 0); - assert_eq!(fun1(&foo, &bar), 1); - assert_eq!(fun1(&bar, &bar), 2); - assert_eq!(fun1(&bar, &foo), 3); - - assert_eq!(fun2(&foo, &foo), 0); - assert_eq!(fun2(&foo, &bar), 1); // fun2 returns 0 - assert_eq!(fun2(&bar, &bar), 2); - assert_eq!(fun2(&bar, &foo), 3); // fun2 returns 2 -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5550.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5550.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5550.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5550.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub fn main() { - let s: String = "foobar".to_string(); - let mut t: &str = &s; - t = &t[0..3]; // for master: str::view(t, 0, 3) maybe -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5554.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5554.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5554.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5554.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -use std::default::Default; - -pub struct X { - a: T, -} - -// reordering these bounds stops the ICE -// -// nmatsakis: This test used to have the bounds Default + PartialEq + -// Default, but having duplicate bounds became illegal. -impl Default for X { - fn default() -> X { - X { a: Default::default() } - } -} - -macro_rules! constants { - () => { - let _ : X = Default::default(); - } -} - -pub fn main() { - constants!(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5572.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5572.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5572.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5572.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn foo(_t: T) { } - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5666.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5666.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5666.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5666.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -struct Dog { - name : String -} - -trait Barks { - fn bark(&self) -> String; -} - -impl Barks for Dog { - fn bark(&self) -> String { - return format!("woof! (I'm {})", self.name); - } -} - - -pub fn main() { - let snoopy = box Dog{name: "snoopy".to_string()}; - let bubbles = box Dog{name: "bubbles".to_string()}; - let barker = [snoopy as Box, bubbles as Box]; - - for pup in &barker { - println!("{}", pup.bark()); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5688.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5688.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5688.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5688.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -/* -# Corrupted initialization in the static struct - -...should print &[1, 2, 3] but instead prints something like -&[4492532864, 24]. It is pretty evident that the compiler messed up -with the representation of [isize; n] and [isize] somehow, or at least -failed to typecheck correctly. -*/ - -#[derive(Copy, Clone)] -struct X { vec: &'static [isize] } - -static V: &'static [X] = &[X { vec: &[1, 2, 3] }]; - -pub fn main() { - for &v in V { - println!("{:?}", v.vec); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5708.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5708.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5708.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5708.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -/* -# ICE when returning struct with reference to trait - -A function which takes a reference to a trait and returns a -struct with that reference results in an ICE. - -This does not occur with concrete types, only with references -to traits. -*/ - - -// original -trait Inner { - fn print(&self); -} - -impl Inner for isize { - fn print(&self) { print!("Inner: {}\n", *self); } -} - -struct Outer<'a> { - inner: &'a (Inner+'a) -} - -impl<'a> Outer<'a> { - fn new(inner: &Inner) -> Outer { - Outer { - inner: inner - } - } -} - -pub fn main() { - let inner: isize = 5; - let outer = Outer::new(&inner as &Inner); - outer.inner.print(); -} - - -// minimal -pub trait MyTrait { - fn dummy(&self, t: T) -> T { panic!() } -} - -pub struct MyContainer<'a, T:'a> { - foos: Vec<&'a (MyTrait+'a)> , -} - -impl<'a, T> MyContainer<'a, T> { - pub fn add (&mut self, foo: &'a MyTrait) { - self.foos.push(foo); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5718.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5718.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5718.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5718.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - -struct Element; - -macro_rules! foo { - ($tag: expr, $string: expr) => { - if $tag == $string { - let element: Box<_> = box Element; - unsafe { - return std::mem::transmute::<_, usize>(element); - } - } - } -} - -fn bar() -> usize { - foo!("a", "b"); - 0 -} - -fn main() { - bar(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5741.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5741.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5741.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5741.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 -#![allow(while_true)] -#![allow(unreachable_code)] - -pub fn main() { - return; - while true {}; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5754.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5754.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5754.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5754.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(improper_ctypes)] - -// pretty-expanded FIXME #23616 - -struct TwoDoubles { - r: f64, - i: f64 -} - -extern "C" { - fn rust_dbg_extern_identity_TwoDoubles(arg1: TwoDoubles) -> TwoDoubles; -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5791.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5791.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5791.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5791.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -extern { - #[link_name = "malloc"] - fn malloc1(len: i32) -> *const u8; - #[link_name = "malloc"] - fn malloc2(len: i32, foo: i32) -> *const u8; -} - -pub fn main () {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5884.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5884.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5884.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5884.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - -pub struct Foo { - a: isize, -} - -struct Bar<'a> { - a: Box>, - b: &'a Foo, -} - -fn check(a: Box) { - let _ic = Bar{ b: &*a, a: box None }; -} - -pub fn main(){} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5900.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5900.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5900.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5900.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub mod foo { - use super::Bar; - - pub struct FooStruct { bar : Bar } -} - -pub enum Bar { - Bar0 = 0 as isize -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5917.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5917.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5917.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5917.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -struct T (&'static [isize]); -static t : T = T (&[5, 4, 3]); -pub fn main () { - let T(ref v) = t; - assert_eq!(v[0], 5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5950.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5950.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5950.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5950.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// pretty-expanded FIXME #23616 - -pub use local as local_alias; - -pub mod local { } - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5988.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5988.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5988.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5988.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait B { - fn f(&self); -} - -trait T : B { -} - -struct A; - -impl B for U { - fn f(&self) { } -} - -impl T for A { -} - -fn main() { - let a = A; - let br = &a as &B; - br.f(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5997.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5997.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5997.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-5997.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn f() -> bool { - enum E { V(T) } - - struct S(T); - - true -} - -fn main() { - let b = f::(); - assert!(b); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6117.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6117.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6117.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6117.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -enum Either { Left(T), Right(U) } - -pub fn main() { - match Either::Left(Box::new(17)) { - Either::Right(()) => {} - _ => {} - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6128.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6128.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6128.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6128.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(box_syntax)] - -use std::collections::HashMap; - -trait Graph { - fn f(&self, _: Edge); - fn g(&self, _: Node); -} - -impl Graph for HashMap { - fn f(&self, _e: E) { - panic!(); - } - fn g(&self, _e: isize) { - panic!(); - } -} - -pub fn main() { - let g : Box> = box HashMap::new(); - let _g2 : Box> = g as Box>; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6130.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6130.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6130.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6130.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let i: usize = 0; - assert!(i <= 0xFFFF_FFFF); - - let i: isize = 0; - assert!(i >= -0x8000_0000); - assert!(i <= 0x7FFF_FFFF); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6153.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6153.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6153.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6153.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -fn swap(f: F) -> Vec where F: FnOnce(Vec) -> Vec { - let x = vec![1, 2, 3]; - f(x) -} - -pub fn main() { - let v = swap(|mut x| { x.push(4); x }); - let w = swap(|mut x| { x.push(4); x }); - assert_eq!(v, w); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6157.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6157.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6157.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6157.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub trait OpInt { fn call(&mut self, _: isize, _: isize) -> isize; } - -impl OpInt for F where F: FnMut(isize, isize) -> isize { - fn call(&mut self, a:isize, b:isize) -> isize { - (*self)(a, b) - } -} - -fn squarei<'a>(x: isize, op: &'a mut OpInt) -> isize { op.call(x, x) } - -fn muli(x:isize, y:isize) -> isize { x * y } - -pub fn main() { - let mut f = |x, y| muli(x, y); - { - let g = &mut f; - let h = g as &mut OpInt; - squarei(3, h); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6318.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6318.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6318.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6318.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - -pub enum Thing { - A(Box) -} - -pub trait Foo { - fn dummy(&self) { } -} - -pub struct Struct; - -impl Foo for Struct {} - -pub fn main() { - match Thing::A(box Struct as Box) { - Thing::A(_a) => 0, - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6334.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6334.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6334.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6334.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests that everything still compiles and runs fine even when -// we reorder the bounds. - - -trait A { - fn a(&self) -> usize; -} - -trait B { - fn b(&self) -> usize; -} - -trait C { - fn combine(&self, t: &T) -> usize; -} - -struct Foo; - -impl A for Foo { - fn a(&self) -> usize { 1 } -} - -impl B for Foo { - fn b(&self) -> usize { 2 } -} - -struct Bar; - -impl C for Bar { - // Note below: bounds in impl decl are in reverse order. - fn combine(&self, t: &T) -> usize { - (t.a() * 100) + t.b() - } -} - -fn use_c(s: &S, t: &T) -> usize { - s.combine(t) -} - -pub fn main() { - let foo = Foo; - let bar = Bar; - let r = use_c(&bar, &foo); - assert_eq!(r, 102); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6341.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6341.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6341.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6341.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#[derive(PartialEq)] -struct A { x: usize } - -impl Drop for A { - fn drop(&mut self) {} -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6344-let.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6344-let.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6344-let.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6344-let.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_shorthand_field_patterns)] - -struct A { x: usize } - -impl Drop for A { - fn drop(&mut self) {} -} - -pub fn main() { - let a = A { x: 0 }; - - let A { x: ref x } = a; - println!("{}", x) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6344-match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6344-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6344-match.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6344-match.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_shorthand_field_patterns)] - -struct A { x: usize } - -impl Drop for A { - fn drop(&mut self) {} -} - -pub fn main() { - let a = A { x: 0 }; - - match a { - A { x : ref x } => { - println!("{}", x) - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6449.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6449.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6449.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6449.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum Foo { - Bar(isize), - Baz, -} - -enum Other { - Other1(Foo), - Other2(Foo, Foo), -} - -fn main() { - match Foo::Baz { - ::Foo::Bar(3) => panic!(), - ::Foo::Bar(_) if false => panic!(), - ::Foo::Bar(..) if false => panic!(), - ::Foo::Bar(_n) => panic!(), - ::Foo::Baz => {} - } - match Foo::Bar(3) { - ::Foo::Bar(3) => {} - ::Foo::Bar(_) if false => panic!(), - ::Foo::Bar(..) if false => panic!(), - ::Foo::Bar(_n) => panic!(), - ::Foo::Baz => panic!(), - } - match Foo::Bar(4) { - ::Foo::Bar(3) => panic!(), - ::Foo::Bar(_) if false => panic!(), - ::Foo::Bar(..) if false => panic!(), - ::Foo::Bar(n) => assert_eq!(n, 4), - ::Foo::Baz => panic!(), - } - - match Other::Other1(Foo::Baz) { - ::Other::Other1(::Foo::Baz) => {} - ::Other::Other1(::Foo::Bar(_)) => {} - ::Other::Other2(::Foo::Baz, ::Foo::Bar(_)) => {} - ::Other::Other2(::Foo::Bar(..), ::Foo::Baz) => {} - ::Other::Other2(..) => {} - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6470.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6470.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6470.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6470.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(improper_ctypes)] - -// pretty-expanded FIXME #23616 -#![allow(non_snake_case)] - -pub mod Bar { - pub struct Foo { - v: isize, - } - - extern { - pub fn foo(v: *const Foo) -> Foo; - } -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6557.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6557.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6557.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6557.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(box_patterns)] -#![feature(box_syntax)] - -fn foo(box (_x, _y): Box<(isize, isize)>) {} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6892.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6892.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6892.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6892.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Ensures that destructors are run for expressions of the form "let _ = e;" -// where `e` is a type which requires a destructor. - - -struct Foo; -struct Bar { x: isize } -struct Baz(isize); -enum FooBar { _Foo(Foo), _Bar(usize) } - -static mut NUM_DROPS: usize = 0; - -impl Drop for Foo { - fn drop(&mut self) { - unsafe { NUM_DROPS += 1; } - } -} -impl Drop for Bar { - fn drop(&mut self) { - unsafe { NUM_DROPS += 1; } - } -} -impl Drop for Baz { - fn drop(&mut self) { - unsafe { NUM_DROPS += 1; } - } -} -impl Drop for FooBar { - fn drop(&mut self) { - unsafe { NUM_DROPS += 1; } - } -} - -fn main() { - assert_eq!(unsafe { NUM_DROPS }, 0); - { let _x = Foo; } - assert_eq!(unsafe { NUM_DROPS }, 1); - { let _x = Bar { x: 21 }; } - assert_eq!(unsafe { NUM_DROPS }, 2); - { let _x = Baz(21); } - assert_eq!(unsafe { NUM_DROPS }, 3); - { let _x = FooBar::_Foo(Foo); } - assert_eq!(unsafe { NUM_DROPS }, 5); - { let _x = FooBar::_Bar(42); } - assert_eq!(unsafe { NUM_DROPS }, 6); - - { let _ = Foo; } - assert_eq!(unsafe { NUM_DROPS }, 7); - { let _ = Bar { x: 21 }; } - assert_eq!(unsafe { NUM_DROPS }, 8); - { let _ = Baz(21); } - assert_eq!(unsafe { NUM_DROPS }, 9); - { let _ = FooBar::_Foo(Foo); } - assert_eq!(unsafe { NUM_DROPS }, 11); - { let _ = FooBar::_Bar(42); } - assert_eq!(unsafe { NUM_DROPS }, 12); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6898.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6898.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6898.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6898.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -use std::mem; - -/// Returns the size of a type -pub fn size_of() -> usize { - TypeInfo::size_of(None::) -} - -/// Returns the size of the type that `val` points to -pub fn size_of_val(val: &T) -> usize { - val.size_of_val() -} - -pub trait TypeInfo: Sized { - fn size_of(_lame_type_hint: Option) -> usize; - fn size_of_val(&self) -> usize; -} - -impl TypeInfo for T { - /// The size of the type in bytes. - fn size_of(_lame_type_hint: Option) -> usize { - mem::size_of::() - } - - /// Returns the size of the type of `self` in bytes. - fn size_of_val(&self) -> usize { - TypeInfo::size_of(None::) - } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6919.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6919.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6919.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6919.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:iss.rs - -// pretty-expanded FIXME #23616 - -#![crate_id="issue-6919"] -extern crate issue6919_3; - -pub fn main() { - let _ = issue6919_3::D.k; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6991.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6991.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6991.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-6991.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -static x: &'static usize = &1; -static y: usize = *x; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7012.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7012.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7012.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7012.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -#![allow(non_upper_case_globals)] - -/* -# Comparison of static arrays - -The expected behaviour would be that test==test1, therefore 'true' -would be printed, however the below prints false. -*/ - -struct signature<'a> { pattern : &'a [u32] } - -static test1: signature<'static> = signature { - pattern: &[0x243f6a88,0x85a308d3,0x13198a2e,0x03707344,0xa4093822,0x299f31d0] -}; - -pub fn main() { - let test: &[u32] = &[0x243f6a88,0x85a308d3,0x13198a2e, - 0x03707344,0xa4093822,0x299f31d0]; - println!("{}",test==test1.pattern); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7178.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7178.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7178.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7178.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-7178.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_7178 as cross_crate_self; - -pub fn main() { - let _ = cross_crate_self::Foo::new(&1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7222.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7222.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7222.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7222.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 -#![allow(illegal_floating_point_literal_pattern)] // FIXME #41620 - -pub fn main() { - const FOO: f64 = 10.0; - - match 0.0 { - 0.0 ..= FOO => (), - _ => () - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7268.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7268.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7268.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7268.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn foo(_: T) {} - -fn bar(x: &'static T) { - foo(x); -} -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7344.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7344.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7344.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7344.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![allow(unreachable_code)] - -fn foo() -> bool { false } - -fn bar() { - return; - !foo(); -} - -fn baz() { - return; - if "" == "" {} -} - -pub fn main() { - bar(); - baz(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7519-match-unit-in-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7519-match-unit-in-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7519-match-unit-in-arg.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7519-match-unit-in-arg.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -/* -#7519 ICE pattern matching unit in function argument -*/ - -fn foo(():()) { } - -pub fn main() { - foo(()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7563.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7563.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7563.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7563.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait IDummy { - fn do_nothing(&self); -} - -#[derive(Debug)] -struct A { a: isize } -#[derive(Debug)] -struct B<'a> { b: isize, pa: &'a A } - - impl IDummy for A { - fn do_nothing(&self) { - println!("A::do_nothing() is called"); - } - } - -impl<'a> B<'a> { - fn get_pa(&self) -> &'a IDummy { self.pa as &'a IDummy } -} - -pub fn main() { - let sa = A { a: 100 }; - let sb = B { b: 200, pa: &sa }; - - println!("sa is {:?}", sa); - println!("sb is {:?}", sb); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7575.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7575.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7575.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7575.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait Foo { - fn new() -> bool { false } - fn dummy(&self) { } -} - -trait Bar { - fn new(&self) -> bool { true } -} - -impl Bar for isize {} -impl Foo for isize {} - -fn main() { - assert!(1.new()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7607-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7607-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7607-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7607-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub mod a { - pub struct Foo { a: usize } -} - -pub mod b { - use a::Foo; - impl Foo { - fn bar(&self) { } - } -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7660.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7660.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7660.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7660.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for issue 7660 -// rvalue lifetime too short when equivalent `match` works - -// pretty-expanded FIXME #23616 - -use std::collections::HashMap; - -struct A(isize, isize); - -pub fn main() { - let mut m: HashMap = HashMap::new(); - m.insert(1, A(0, 0)); - - let A(ref _a, ref _b) = m[&1]; - let (a, b) = match m[&1] { A(ref _a, ref _b) => (_a, _b) }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7663.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7663.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7663.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7663.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![allow(unused_imports, dead_code)] - -mod test1 { - - mod foo { pub fn p() -> isize { 1 } } - mod bar { pub fn p() -> isize { 2 } } - - pub mod baz { - use test1::bar::p; - - pub fn my_main() { assert_eq!(p(), 2); } - } -} - -mod test2 { - - mod foo { pub fn p() -> isize { 1 } } - mod bar { pub fn p() -> isize { 2 } } - - pub mod baz { - use test2::bar::p; - - pub fn my_main() { assert_eq!(p(), 2); } - } -} - -fn main() { - test1::baz::my_main(); - test2::baz::my_main(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7673-cast-generically-implemented-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7673-cast-generically-implemented-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7673-cast-generically-implemented-trait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7673-cast-generically-implemented-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -/* - -#7673 Polymorphically creating traits barely works - -*/ - -#![feature(box_syntax)] - -pub fn main() {} - -trait A { - fn dummy(&self) { } -} - -impl A for T {} - -fn owned2(a: Box) { a as Box; } -fn owned3(a: Box) { box a as Box; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7784.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7784.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7784.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7784.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(slice_patterns)] - -use std::ops::Add; - -fn foo + Clone>([x, y, z]: [T; 3]) -> (T, T, T) { - (x.clone(), x.clone() + y.clone(), x + y + z) -} -fn bar(a: &'static str, b: &'static str) -> [&'static str; 4] { - [a, b, b, a] -} - -fn main() { - assert_eq!(foo([1, 2, 3]), (1, 3, 6)); - - let [a, b, c, d] = bar("foo", "bar"); - assert_eq!(a, "foo"); - assert_eq!(b, "bar"); - assert_eq!(c, "bar"); - assert_eq!(d, "foo"); - - let [a, _, _, d] = bar("baz", "foo"); - assert_eq!(a, "baz"); - assert_eq!(d, "baz"); - - let out = bar("baz", "foo"); - let [a, xs.., d] = out; - assert_eq!(a, "baz"); - assert_eq!(xs, ["foo", "foo"]); - assert_eq!(d, "baz"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7899.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7899.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7899.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7899.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-7899.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_7899 as testcrate; - -fn main() { - let f = testcrate::V2(1.0f32, 2.0f32); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7911.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7911.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7911.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-7911.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// (Closes #7911) Test that we can use the same self expression -// with different mutability in macro in two methods - -#![allow(unused_variables)] // unused foobar_immut + foobar_mut -trait FooBar { - fn dummy(&self) { } -} -struct Bar(i32); -struct Foo { bar: Bar } - -impl FooBar for Bar {} - -trait Test { - fn get_immut(&self) -> &FooBar; - fn get_mut(&mut self) -> &mut FooBar; -} - -macro_rules! generate_test { ($type_:path, $slf:ident, $field:expr) => ( - impl Test for $type_ { - fn get_immut(&$slf) -> &FooBar { - &$field as &FooBar - } - - fn get_mut(&mut $slf) -> &mut FooBar { - &mut $field as &mut FooBar - } - } -)} - -generate_test!(Foo, self, self.bar); - -pub fn main() { - let mut foo: Foo = Foo { bar: Bar(42) }; - { let foobar_immut = foo.get_immut(); } - { let foobar_mut = foo.get_mut(); } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8044.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8044.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8044.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8044.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-8044.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_8044 as minimal; -use minimal::{BTree, leaf}; - -pub fn main() { - BTree:: { node: leaf(1) }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8171-default-method-self-inherit-builtin-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8171-default-method-self-inherit-builtin-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8171-default-method-self-inherit-builtin-trait.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8171-default-method-self-inherit-builtin-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -/* - -#8171 Self is not recognised as implementing kinds in default method implementations - -*/ - -fn require_send(_: T){} - -trait TragicallySelfIsNotSend: Send + Sized { - fn x(self) { - require_send(self); - } -} - -pub fn main(){} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8248.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8248.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8248.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8248.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait A { - fn dummy(&self) { } -} -struct B; -impl A for B {} - -fn foo(_: &mut A) {} - -pub fn main() { - let mut b = B; - foo(&mut b as &mut A); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8249.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8249.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8249.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8249.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait A { - fn dummy(&self) { } -} -struct B; -impl A for B {} - -struct C<'a> { - foo: &'a mut (A+'a), -} - -fn foo(a: &mut A) { - C{ foo: a }; -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8259.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8259.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8259.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8259.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -// aux-build:issue-8259.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_8259 as other; -static a: other::Foo<'static> = other::Foo::A; - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8351-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8351-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8351-1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8351-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum E { - Foo{f: isize}, - Bar, -} - -pub fn main() { - let e = E::Foo{f: 0}; - match e { - E::Foo{f: 1} => panic!(), - E::Foo{..} => (), - _ => panic!(), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8351-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8351-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8351-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8351-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum E { - Foo{f: isize, b: bool}, - Bar, -} - -pub fn main() { - let e = E::Foo{f: 0, b: false}; - match e { - E::Foo{f: 1, b: true} => panic!(), - E::Foo{b: false, f: 0} => (), - _ => panic!(), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8391.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8391.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8391.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8391.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn main() { - let x = match Some(1) { - ref _y @ Some(_) => 1, - None => 2, - }; - assert_eq!(x, 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8398.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8398.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8398.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8398.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub trait Writer { - fn write(&mut self, b: &[u8]) -> Result<(), ()>; -} - -fn foo(a: &mut Writer) { - a.write(&[]).unwrap(); -} - -pub fn main(){} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8401.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8401.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8401.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8401.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue_8401.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_8401; - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8460.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8460.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8460.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8460.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support -#![feature(rustc_attrs)] - -use std::thread; - -trait Int { - fn zero() -> Self; - fn one() -> Self; -} -macro_rules! doit { - ($($t:ident)*) => ($(impl Int for $t { - fn zero() -> $t { 0 } - fn one() -> $t { 1 } - })*) -} -doit! { i8 i16 i32 i64 isize } - -macro_rules! check { - ($($e:expr),*) => { - $(assert!(thread::spawn({ - move|| { $e; } - }).join().is_err());)* - } -} - -fn main() { - check![ - isize::min_value() / -isize::one(), - i8::min_value() / -i8::one(), - i16::min_value() / -i16::one(), - i32::min_value() / -i32::one(), - i64::min_value() / -i64::one(), - 1isize / isize::zero(), - 1i8 / i8::zero(), - 1i16 / i16::zero(), - 1i32 / i32::zero(), - 1i64 / i64::zero(), - isize::min_value() % -isize::one(), - i8::min_value() % -i8::one(), - i16::min_value() % -i16::one(), - i32::min_value() % -i32::one(), - i64::min_value() % -i64::one(), - 1isize % isize::zero(), - 1i8 % i8::zero(), - 1i16 % i16::zero(), - 1i32 % i32::zero(), - 1i64 % i64::zero() - ]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8498.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8498.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8498.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8498.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - match &[(Box::new(5),Box::new(7))] { - ps => { - let (ref y, _) = ps[0]; - assert_eq!(**y, 5); - } - } - - match Some(&[(Box::new(5),)]) { - Some(ps) => { - let (ref y,) = ps[0]; - assert_eq!(**y, 5); - } - None => () - } - - match Some(&[(Box::new(5),Box::new(7))]) { - Some(ps) => { - let (ref y, ref z) = ps[0]; - assert_eq!(**y, 5); - assert_eq!(**z, 7); - } - None => () - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8506.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8506.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8506.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8506.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 -#![allow(non_upper_case_globals)] - -#![allow(dead_code)] - -enum Either { - One, - Other(String,String) -} - -static one : Either = Either::One; - -pub fn main () { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8521.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8521.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8521.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8521.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Foo1 {} - -trait A {} - -macro_rules! foo1(($t:path) => { - impl Foo1 for T {} -}); - -foo1!(A); - -trait Foo2 {} - -trait B {} - -#[allow(unused)] -struct C {} - -macro_rules! foo2(($t:path) => { - impl Foo2 for T {} -}); - -foo2!(B); - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8578.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8578.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8578.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8578.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -#![allow(non_upper_case_globals)] -// pretty-expanded FIXME #23616 - -pub struct UninterpretedOption_NamePart { - name_part: Option, -} - -impl<'a> UninterpretedOption_NamePart { - pub fn default_instance() -> &'static UninterpretedOption_NamePart { - static instance: UninterpretedOption_NamePart = UninterpretedOption_NamePart { - name_part: None, - }; - &instance - } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-868.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-868.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-868.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-868.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn f(g: F) -> T where F: FnOnce() -> T { g() } - -pub fn main() { - let _x = f( | | { 10 }); - // used to be: cannot determine a type for this expression - f(| | { }); - // ditto - f( | | { ()}); - // always worked - let _: () = f(| | { }); - // empty block with no type info should compile too - let _ = f(||{}); - let _ = (||{}); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8709.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8709.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8709.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8709.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -macro_rules! sty { - ($t:ty) => (stringify!($t)) -} - -macro_rules! spath { - ($t:path) => (stringify!($t)) -} - -fn main() { - assert_eq!(sty!(isize), "isize"); - assert_eq!(spath!(std::option), "std::option"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8783.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8783.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8783.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8783.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -use std::default::Default; - -struct X { pub x: usize } -impl Default for X { - fn default() -> X { - X { x: 42 } - } -} - -struct Y { pub y: T } -impl Default for Y { - fn default() -> Y { - Y { y: Default::default() } - } -} - -fn main() { - let X { x: _ } = Default::default(); - let Y { y: X { x } } = Default::default(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8827.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8827.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8827.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8827.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::thread; -use std::sync::mpsc::{channel, Receiver}; - -fn periodical(n: isize) -> Receiver { - let (chan, port) = channel(); - thread::spawn(move|| { - loop { - for _ in 1..n { - match chan.send(false) { - Ok(()) => {} - Err(..) => break, - } - } - match chan.send(true) { - Ok(()) => {} - Err(..) => break - } - } - }); - return port; -} - -fn integers() -> Receiver { - let (chan, port) = channel(); - thread::spawn(move|| { - let mut i = 1; - loop { - match chan.send(i) { - Ok(()) => {} - Err(..) => break, - } - i = i + 1; - } - }); - return port; -} - -fn main() { - let ints = integers(); - let threes = periodical(3); - let fives = periodical(5); - for _ in 1..100 { - match (ints.recv().unwrap(), threes.recv().unwrap(), fives.recv().unwrap()) { - (_, true, true) => println!("FizzBuzz"), - (_, true, false) => println!("Fizz"), - (_, false, true) => println!("Buzz"), - (i, false, false) => println!("{}", i) - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8851.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8851.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8851.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8851.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// after fixing #9384 and implementing hygiene for match bindings, -// this now fails because the insertion of the 'y' into the match -// doesn't cause capture. Making this macro hygienic (as I've done) -// could very well make this test case completely pointless.... - -// pretty-expanded FIXME #23616 - -enum T { - A(isize), - B(usize) -} - -macro_rules! test { - ($id:ident, $e:expr) => ( - fn foo(t: T) -> isize { - match t { - T::A($id) => $e, - T::B($id) => $e - } - } - ) -} - -test!(y, 10 + (y as isize)); - -pub fn main() { - foo(T::A(20)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8860.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8860.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8860.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8860.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: -Z borrowck=compare - -static mut DROP: isize = 0; -static mut DROP_S: isize = 0; -static mut DROP_T: isize = 0; - -struct S; -impl Drop for S { - fn drop(&mut self) { - unsafe { - DROP_S += 1; - DROP += 1; - } - } -} -fn f(ref _s: S) {} - -struct T { i: isize } -impl Drop for T { - fn drop(&mut self) { - unsafe { - DROP_T += 1; - DROP += 1; - } - } -} -fn g(ref _t: T) {} - -fn do_test() { - let s = S; - f(s); - unsafe { - assert_eq!(1, DROP); - assert_eq!(1, DROP_S); - } - let t = T { i: 1 }; - g(t); - unsafe { assert_eq!(1, DROP_T); } -} - -fn main() { - do_test(); - unsafe { - assert_eq!(2, DROP); - assert_eq!(1, DROP_S); - assert_eq!(1, DROP_T); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8898.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8898.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8898.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-8898.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn assert_repr_eq(obj : T, expected : String) { - assert_eq!(expected, format!("{:?}", obj)); -} - -pub fn main() { - let abc = [1, 2, 3]; - let tf = [true, false]; - let x = [(), ()]; - let slice = &x[..1]; - - assert_repr_eq(&abc[..], "[1, 2, 3]".to_string()); - assert_repr_eq(&tf[..], "[true, false]".to_string()); - assert_repr_eq(&x[..], "[(), ()]".to_string()); - assert_repr_eq(slice, "[()]".to_string()); - assert_repr_eq(&x[..], "[(), ()]".to_string()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9047.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9047.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9047.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9047.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn decode() -> String { - 'outer: loop { - let mut ch_start: usize; - break 'outer; - } - "".to_string() -} - -pub fn main() { - println!("{}", decode()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9110.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9110.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9110.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9110.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 -#![allow(non_snake_case)] - -macro_rules! silly_macro { - () => ( - pub mod Qux { - pub struct Foo { x : u8 } - pub fn bar(_foo : Foo) {} - } - ); -} - -silly_macro!(); - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9123.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9123.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9123.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9123.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue_9123.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_9123; - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9129.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9129.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9129.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9129.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] -// ignore-pretty unreported - -#![feature(box_syntax)] - -pub trait bomb { fn boom(&self, _: Ident); } -pub struct S; -impl bomb for S { fn boom(&self, _: Ident) { } } - -pub struct Ident { name: usize } - -// macro_rules! int3 { () => ( unsafe { asm!( "int3" ); } ) } -macro_rules! int3 { () => ( { } ) } - -fn Ident_new() -> Ident { - int3!(); - Ident {name: 0x6789ABCD } -} - -pub fn light_fuse(fld: Box) { - int3!(); - let f = || { - int3!(); - fld.boom(Ident_new()); // *** 1 - }; - f(); -} - -pub fn main() { - let b = box S as Box; - light_fuse(b); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_9155.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_9155.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_9155.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue_9155.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue_9155.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_9155; - -struct Baz; - -pub fn main() { - issue_9155::Foo::new(Baz); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9188.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9188.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9188.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9188.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue_9188.rs - - -extern crate issue_9188; - -pub fn main() { - let a = issue_9188::bar(); - let b = issue_9188::foo::(); - assert_eq!(*a, *b); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9243.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9243.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9243.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9243.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for issue 9243 -#![allow(non_upper_case_globals)] - -pub struct Test { - mem: isize, -} - -pub static g_test: Test = Test {mem: 0}; - -impl Drop for Test { - fn drop(&mut self) {} -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9249.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9249.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9249.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9249.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -static DATA:&'static [&'static str] = &["my string"]; -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9259.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9259.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9259.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9259.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct A<'a> { - a: &'a [String], - b: Option<&'a [String]>, -} - -pub fn main() { - let b: &[String] = &["foo".to_string()]; - let a = A { - a: &["test".to_string()], - b: Some(b), - }; - assert_eq!(a.b.as_ref().unwrap()[0], "foo"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9382.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9382.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9382.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9382.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -// pretty-expanded FIXME #23616 - -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -// Tests for a previous bug that occurred due to an interaction -// between struct field initialization and the auto-coercion -// from a vector to a slice. The drop glue was being invoked on -// the temporary slice with a wrong type, triggering an LLVM assert. - - -struct Thing1<'a> { - baz: &'a [Box], - bar: Box, -} - -struct Thing2<'a> { - baz: &'a [Box], - bar: u64, -} - -pub fn main() { - let _t1_fixed = Thing1 { - baz: &[], - bar: box 32, - }; - Thing1 { - baz: &Vec::new(), - bar: box 32, - }; - let _t2_fixed = Thing2 { - baz: &[], - bar: 32, - }; - Thing2 { - baz: &Vec::new(), - bar: 32, - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9394-inherited-trait-calls.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9394-inherited-trait-calls.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9394-inherited-trait-calls.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9394-inherited-trait-calls.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait Base: Base2 + Base3{ - fn foo(&self) -> String; - fn foo1(&self) -> String; - fn foo2(&self) -> String{ - "base foo2".to_string() - } -} - -trait Base2: Base3{ - fn baz(&self) -> String; -} - -trait Base3{ - fn root(&self) -> String; -} - -trait Super: Base{ - fn bar(&self) -> String; -} - -struct X; - -impl Base for X { - fn foo(&self) -> String{ - "base foo".to_string() - } - fn foo1(&self) -> String{ - "base foo1".to_string() - } - -} - -impl Base2 for X { - fn baz(&self) -> String{ - "base2 baz".to_string() - } -} - -impl Base3 for X { - fn root(&self) -> String{ - "base3 root".to_string() - } -} - -impl Super for X { - fn bar(&self) -> String{ - "super bar".to_string() - } -} - -pub fn main() { - let n = X; - let s = &n as &Super; - assert_eq!(s.bar(),"super bar".to_string()); - assert_eq!(s.foo(),"base foo".to_string()); - assert_eq!(s.foo1(),"base foo1".to_string()); - assert_eq!(s.foo2(),"base foo2".to_string()); - assert_eq!(s.baz(),"base2 baz".to_string()); - assert_eq!(s.root(),"base3 root".to_string()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9396.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9396.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9396.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9396.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(deprecated)] -// ignore-emscripten no threads support - -use std::sync::mpsc::{TryRecvError, channel}; -use std::thread; - -pub fn main() { - let (tx, rx) = channel(); - let t = thread::spawn(move||{ - thread::sleep_ms(10); - tx.send(()).unwrap(); - }); - loop { - match rx.try_recv() { - Ok(()) => break, - Err(TryRecvError::Empty) => {} - Err(TryRecvError::Disconnected) => unreachable!() - } - } - t.join(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9446.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9446.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9446.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9446.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct Wrapper(String); - -impl Wrapper { - pub fn new(wrapped: String) -> Wrapper { - Wrapper(wrapped) - } - - pub fn say_hi(&self) { - let Wrapper(ref s) = *self; - println!("hello {}", *s); - } -} - -impl Drop for Wrapper { - fn drop(&mut self) {} -} - -pub fn main() { - { - // This runs without complaint. - let x = Wrapper::new("Bob".to_string()); - x.say_hi(); - } - { - // This fails to compile, circa 0.8-89-gc635fba. - // error: internal compiler error: drop_ty_immediate: non-box ty - Wrapper::new("Bob".to_string()).say_hi(); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9719.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9719.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9719.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9719.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -mod a { - pub enum Enum { - A(T), - } - - pub trait X { - fn dummy(&self) { } - } - impl X for isize {} - - pub struct Z<'a>(Enum<&'a (X+'a)>); - fn foo() { let x: isize = 42; let z = Z(Enum::A(&x as &X)); let _ = z; } -} - -mod b { - trait X { - fn dummy(&self) { } - } - impl X for isize {} - struct Y<'a>{ - x:Option<&'a (X+'a)>, - } - - fn bar() { - let x: isize = 42; - let _y = Y { x: Some(&x as &X) }; - } -} - -mod c { - pub trait X { fn f(&self); } - impl X for isize { fn f(&self) {} } - pub struct Z<'a>(Option<&'a (X+'a)>); - fn main() { let x: isize = 42; let z = Z(Some(&x as &X)); let _ = z; } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9737.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9737.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9737.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9737.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! f { - (v: $x:expr) => ( println!("{}", $x) ) -} - -fn main () { - let v = 5; - f!(v: 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-979.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-979.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-979.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-979.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -use std::cell::Cell; - -struct r<'a> { - b: &'a Cell, -} - -impl<'a> Drop for r<'a> { - fn drop(&mut self) { - self.b.set(self.b.get() + 1); - } -} - -fn r(b: &Cell) -> r { - r { - b: b - } -} - -pub fn main() { - let b = &Cell::new(0); - { - let _p = Some(r(b)); - } - - assert_eq!(b.get(), 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9837.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9837.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9837.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9837.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -const C1: i32 = 0x12345678; -const C2: isize = C1 as i16 as isize; - -enum E { - V = C2 -} - -fn main() { - assert_eq!(C2 as u64, E::V as u64); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9906.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9906.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9906.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9906.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-9906.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_9906 as testmod; - -pub fn main() { - testmod::foo(); - testmod::FooBar::new(1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9918.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9918.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9918.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9918.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - assert_eq!((0 + 0u8) as char, '\0'); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9942.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9942.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9942.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9942.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub fn main() { - const S: usize = 23 as usize; [0; S]; () -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9951.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9951.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9951.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9951.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![allow(unused_variables)] - -trait Bar { - fn noop(&self); -} -impl Bar for u8 { - fn noop(&self) {} -} - -fn main() { - let (a, b) = (&5u8 as &Bar, &9u8 as &Bar); - let (c, d): (&Bar, &Bar) = (a, b); - - let (a, b) = (Box::new(5u8) as Box, Box::new(9u8) as Box); - let (c, d): (&Bar, &Bar) = (&*a, &*b); - - let (c, d): (&Bar, &Bar) = (&5, &9); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9968.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9968.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9968.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/issues/issue-9968.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:issue-9968.rs - -// pretty-expanded FIXME #23616 - -extern crate issue_9968 as lib; - -use lib::{Trait, Struct}; - -pub fn main() -{ - Struct::init().test(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/iterators/into-iterator-type-inference-shift.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/iterators/into-iterator-type-inference-shift.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/iterators/into-iterator-type-inference-shift.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/iterators/into-iterator-type-inference-shift.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for type inference failure around shifting. In this -// case, the iteration yields an isize, but we hadn't run the full type -// propagation yet, and so we just saw a type variable, yielding an -// error. - -// pretty-expanded FIXME #23616 - -trait IntoIterator { - type Iter: Iterator; - - fn into_iter(self) -> Self::Iter; -} - -impl IntoIterator for I where I: Iterator { - type Iter = I; - - fn into_iter(self) -> I { - self - } -} - -fn desugared_for_loop_bad(byte: u8) -> u8 { - let mut result = 0; - let mut x = IntoIterator::into_iter(0..8); - let mut y = Iterator::next(&mut x); - let mut z = y.unwrap(); - byte >> z; - 1 -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-cloned-type-inference.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-cloned-type-inference.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-cloned-type-inference.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-cloned-type-inference.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -// Test to see that the element type of .cloned() can be inferred -// properly. Previously this would fail to deduce the type of `sum`. - -#![feature(iter_arith)] - -fn square_sum(v: &[i64]) -> i64 { - let sum: i64 = v.iter().cloned().sum(); - sum * sum -} - -fn main() { - assert_eq!(36, square_sum(&[1,2,3])); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-range.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-range.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-range.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-range.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -fn range_(a: isize, b: isize, mut it: F) where F: FnMut(isize) { - assert!((a < b)); - let mut i: isize = a; - while i < b { it(i); i += 1; } -} - -pub fn main() { - let mut sum: isize = 0; - range_(0, 100, |x| sum += x ); - println!("{}", sum); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-step-overflow-debug.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-step-overflow-debug.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-step-overflow-debug.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-step-overflow-debug.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare compiled with panic=abort by default -// compile-flags: -C debug_assertions=yes - -use std::panic; - -fn main() { - let r = panic::catch_unwind(|| { - let mut it = u8::max_value()..; - it.next().unwrap(); // 255 - it.next().unwrap(); - }); - assert!(r.is_err()); - - let r = panic::catch_unwind(|| { - let mut it = i8::max_value()..; - it.next().unwrap(); // 127 - it.next().unwrap(); - }); - assert!(r.is_err()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-step-overflow-ndebug.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-step-overflow-ndebug.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-step-overflow-ndebug.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-step-overflow-ndebug.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: -C debug_assertions=no - -fn main() { - let mut it = u8::max_value()..; - assert_eq!(it.next().unwrap(), 255); - assert_eq!(it.next().unwrap(), u8::min_value()); - - let mut it = i8::max_value()..; - assert_eq!(it.next().unwrap(), 127); - assert_eq!(it.next().unwrap(), i8::min_value()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-sum-overflow-debug.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-sum-overflow-debug.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-sum-overflow-debug.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-sum-overflow-debug.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare compiled with panic=abort by default -// compile-flags: -C debug_assertions=yes - -use std::panic; - -fn main() { - let r = panic::catch_unwind(|| { - [1, i32::max_value()].iter().sum::(); - }); - assert!(r.is_err()); - - let r = panic::catch_unwind(|| { - [2, i32::max_value()].iter().product::(); - }); - assert!(r.is_err()); - - let r = panic::catch_unwind(|| { - [1, i32::max_value()].iter().cloned().sum::(); - }); - assert!(r.is_err()); - - let r = panic::catch_unwind(|| { - [2, i32::max_value()].iter().cloned().product::(); - }); - assert!(r.is_err()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-sum-overflow-ndebug.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-sum-overflow-ndebug.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-sum-overflow-ndebug.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-sum-overflow-ndebug.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: -C debug_assertions=no - -fn main() { - assert_eq!([1i32, i32::max_value()].iter().sum::(), - 1i32.wrapping_add(i32::max_value())); - assert_eq!([2i32, i32::max_value()].iter().product::(), - 2i32.wrapping_mul(i32::max_value())); - - assert_eq!([1i32, i32::max_value()].iter().cloned().sum::(), - 1i32.wrapping_add(i32::max_value())); - assert_eq!([2i32, i32::max_value()].iter().cloned().product::(), - 2i32.wrapping_mul(i32::max_value())); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-sum-overflow-overflow-checks.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-sum-overflow-overflow-checks.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-sum-overflow-overflow-checks.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-sum-overflow-overflow-checks.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare compiled with panic=abort by default -// compile-flags: -C overflow-checks - -use std::panic; - -fn main() { - let r = panic::catch_unwind(|| { - [1, i32::max_value()].iter().sum::(); - }); - assert!(r.is_err()); - - let r = panic::catch_unwind(|| { - [2, i32::max_value()].iter().product::(); - }); - assert!(r.is_err()); - - let r = panic::catch_unwind(|| { - [1, i32::max_value()].iter().cloned().sum::(); - }); - assert!(r.is_err()); - - let r = panic::catch_unwind(|| { - [2, i32::max_value()].iter().cloned().product::(); - }); - assert!(r.is_err()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-zip.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-zip.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-zip.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/iterators/iter-zip.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that .zip() specialization preserves side effects -// in sideeffectful iterator adaptors. - -use std::cell::Cell; - -#[derive(Debug)] -struct CountClone(Cell); - -fn count_clone() -> CountClone { CountClone(Cell::new(0)) } - -impl PartialEq for CountClone { - fn eq(&self, rhs: &i32) -> bool { - self.0.get() == *rhs - } -} - -impl Clone for CountClone { - fn clone(&self) -> Self { - let ret = CountClone(self.0.clone()); - let n = self.0.get(); - self.0.set(n + 1); - ret - } -} - -fn test_zip_cloned_sideffectful() { - let xs = [count_clone(), count_clone(), count_clone(), count_clone()]; - let ys = [count_clone(), count_clone()]; - - for _ in xs.iter().cloned().zip(ys.iter().cloned()) { } - - assert_eq!(&xs, &[1, 1, 1, 0][..]); - assert_eq!(&ys, &[1, 1][..]); - - let xs = [count_clone(), count_clone()]; - let ys = [count_clone(), count_clone(), count_clone(), count_clone()]; - - for _ in xs.iter().cloned().zip(ys.iter().cloned()) { } - - assert_eq!(&xs, &[1, 1][..]); - assert_eq!(&ys, &[1, 1, 0, 0][..]); -} - -fn test_zip_map_sideffectful() { - let mut xs = [0; 6]; - let mut ys = [0; 4]; - - for _ in xs.iter_mut().map(|x| *x += 1).zip(ys.iter_mut().map(|y| *y += 1)) { } - - assert_eq!(&xs, &[1, 1, 1, 1, 1, 0]); - assert_eq!(&ys, &[1, 1, 1, 1]); - - let mut xs = [0; 4]; - let mut ys = [0; 6]; - - for _ in xs.iter_mut().map(|x| *x += 1).zip(ys.iter_mut().map(|y| *y += 1)) { } - - assert_eq!(&xs, &[1, 1, 1, 1]); - assert_eq!(&ys, &[1, 1, 1, 1, 0, 0]); -} - -fn test_zip_map_rev_sideffectful() { - let mut xs = [0; 6]; - let mut ys = [0; 4]; - - { - let mut it = xs.iter_mut().map(|x| *x += 1).zip(ys.iter_mut().map(|y| *y += 1)); - it.next_back(); - } - assert_eq!(&xs, &[0, 0, 0, 1, 1, 1]); - assert_eq!(&ys, &[0, 0, 0, 1]); - - let mut xs = [0; 6]; - let mut ys = [0; 4]; - - { - let mut it = xs.iter_mut().map(|x| *x += 1).zip(ys.iter_mut().map(|y| *y += 1)); - (&mut it).take(5).count(); - it.next_back(); - } - assert_eq!(&xs, &[1, 1, 1, 1, 1, 1]); - assert_eq!(&ys, &[1, 1, 1, 1]); -} - -fn test_zip_nested_sideffectful() { - let mut xs = [0; 6]; - let ys = [0; 4]; - - { - // test that it has the side effect nested inside enumerate - let it = xs.iter_mut().map(|x| *x = 1).enumerate().zip(&ys); - it.count(); - } - assert_eq!(&xs, &[1, 1, 1, 1, 1, 0]); -} - -fn main() { - test_zip_cloned_sideffectful(); - test_zip_map_sideffectful(); - test_zip_map_rev_sideffectful(); - test_zip_nested_sideffectful(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/assert-eq-macro-success.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/assert-eq-macro-success.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/assert-eq-macro-success.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/assert-eq-macro-success.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(PartialEq, Debug)] -struct Point { x : isize } - -pub fn main() { - assert_eq!(14,14); - assert_eq!("abc".to_string(),"abc".to_string()); - assert_eq!(Box::new(Point{x:34}),Box::new(Point{x:34})); - assert_eq!(&Point{x:34},&Point{x:34}); - assert_eq!(42, 42, "foo bar"); - assert_eq!(42, 42, "a {} c", "b"); - assert_eq!(42, 42, "{x}, {y}, {z}", x = 1, y = 2, z = 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/assert-eq-macro-unsized.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/assert-eq-macro-unsized.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/assert-eq-macro-unsized.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/assert-eq-macro-unsized.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn main() { - assert_eq!([1, 2, 3][..], vec![1, 2, 3][..]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/assert-ne-macro-success.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/assert-ne-macro-success.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/assert-ne-macro-success.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/assert-ne-macro-success.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(PartialEq, Debug)] -struct Point { x : isize } - -pub fn main() { - assert_ne!(666,14); - assert_ne!("666".to_string(),"abc".to_string()); - assert_ne!(Box::new(Point{x:666}),Box::new(Point{x:34})); - assert_ne!(&Point{x:666},&Point{x:34}); - assert_ne!(666, 42, "no gods no masters"); - assert_ne!(666, 42, "6 {} 6", "6"); - assert_ne!(666, 42, "{x}, {y}, {z}", x = 6, y = 6, z = 6); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/assert-ne-macro-unsized.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/assert-ne-macro-unsized.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/assert-ne-macro-unsized.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/assert-ne-macro-unsized.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn main() { - assert_ne!([6, 6, 6][..], vec![1, 2, 3][..]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro-comma-support.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro-comma-support.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro-comma-support.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro-comma-support.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -() diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro_crate_def_only.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro_crate_def_only.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro_crate_def_only.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro_crate_def_only.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[macro_export] -macro_rules! make_a_5 { - () => (5) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro_crate_nonterminal.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro_crate_nonterminal.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro_crate_nonterminal.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro_crate_nonterminal.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn increment(x: usize) -> usize { - x + 1 -} - -#[macro_export] -macro_rules! increment { - ($x:expr) => ($crate::increment($x)) -} - -pub fn check_local() { - assert_eq!(increment!(3), 4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro_export_inner_module.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro_export_inner_module.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro_export_inner_module.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro_export_inner_module.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod inner { - #[macro_export] - macro_rules! foo { - () => (1) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro-include-items-expr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro-include-items-expr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro-include-items-expr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro-include-items-expr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test: this is not a test - -1 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro-include-items-item.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro-include-items-item.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro-include-items-item.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro-include-items-item.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test: this is not a test - -fn foo() { bar() } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro_with_super_1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro_with_super_1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro_with_super_1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/macro_with_super_1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -#[macro_export] -macro_rules! declare { - () => ( - pub fn aaa() {} - - pub mod bbb { - use super::aaa; - - pub fn ccc() { - aaa(); - } - } - ) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/two_macros.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/two_macros.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/two_macros.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/two_macros.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[macro_export] -macro_rules! macro_one { ($($t:tt)*) => ($($t)*) } - -#[macro_export] -macro_rules! macro_two { ($($t:tt)*) => ($($t)*) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/unstable-macros.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/unstable-macros.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/unstable-macros.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/unstable-macros.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(staged_api)] -#![stable(feature = "unit_test", since = "1.0.0")] - -#[unstable(feature = "unstable_macros", issue = "0")] -#[macro_export] -macro_rules! unstable_macro{ () => () } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/use-macro-self.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/use-macro-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/use-macro-self.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/auxiliary/use-macro-self.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod foobarius {} - -#[macro_export] -macro_rules! foobarius { - () => { () } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/colorful-write-macros.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/colorful-write-macros.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/colorful-write-macros.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/colorful-write-macros.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::io::Write; -use std::fmt; - -struct Foo<'a> { - writer: &'a mut (Write+'a), - other: &'a str, -} - -struct Bar; - -impl fmt::Write for Bar { - fn write_str(&mut self, _: &str) -> fmt::Result { - Ok(()) - } -} - -fn borrowing_writer_from_struct_and_formatting_struct_field(foo: Foo) { - write!(foo.writer, "{}", foo.other); -} - -fn main() { - let mut w = Vec::new(); - write!(&mut w as &mut Write, ""); - write!(&mut w, ""); // should coerce - println!("ok"); - - let mut s = Bar; - { - use std::fmt::Write; - write!(&mut s, "test"); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/conditional-debug-macro-on.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/conditional-debug-macro-on.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/conditional-debug-macro-on.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/conditional-debug-macro-on.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn main() { - // exits early if println! evaluates its arguments, otherwise it - // will hit the panic. - println!("{:?}", { if true { return; } }); - - panic!(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/die-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/die-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/die-macro.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/die-macro.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Just testing that panic!() type checks in statement or expr - - -#![allow(unreachable_code)] - -fn f() { - panic!(); - - let _x: isize = panic!(); -} - -pub fn main() { - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/log_syntax-trace_macros-macro-locations.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/log_syntax-trace_macros-macro-locations.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/log_syntax-trace_macros-macro-locations.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/log_syntax-trace_macros-macro-locations.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(trace_macros, log_syntax)] - -// make sure these macros can be used as in the various places that -// macros can occur. - -// items -trace_macros!(false); -log_syntax!(); - -fn main() { - - // statements - trace_macros!(false); - log_syntax!(); - - // expressions - (trace_macros!(false), - log_syntax!()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/log_syntax-trace_macros-macro-locations.stdout rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/log_syntax-trace_macros-macro-locations.stdout --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/log_syntax-trace_macros-macro-locations.stdout 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/log_syntax-trace_macros-macro-locations.stdout 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ - - - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn main() { - - macro_rules! mylambda_tt { - ($x:ident, $body:expr) => ({ - fn f($x: isize) -> isize { return $body; }; - f - }) - } - - assert_eq!(mylambda_tt!(y, y * 2)(8), 16); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-at-most-once-rep.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-at-most-once-rep.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-at-most-once-rep.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-at-most-once-rep.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// 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. - -// edition:2018 - -#![feature(macro_at_most_once_rep)] - -macro_rules! foo { - ($($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); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-attribute-expansion.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-attribute-expansion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-attribute-expansion.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-attribute-expansion.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! descriptions { - ($name:ident is $desc:expr) => { - // Check that we will correctly expand attributes - #[doc = $desc] - #[allow(dead_code)] - const $name : &'static str = $desc; - } -} - -// item -descriptions! { DOG is "an animal" } -descriptions! { RUST is "a language" } - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-attributes.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-attributes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-attributes.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-attributes.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(custom_attribute)] - -macro_rules! compiles_fine { - (#[$at:meta]) => { - // test that the different types of attributes work - #[attribute] - /// Documentation! - #[$at] - - // check that the attributes are recognised by requiring this - // to be removed to avoid a compile error - #[cfg(always_remove)] - static MISTYPED: () = "foo"; - } -} - -// item -compiles_fine!(#[foo]); - -pub fn main() { - // statement - compiles_fine!(#[bar]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-block-nonterminal.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-block-nonterminal.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-block-nonterminal.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-block-nonterminal.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -macro_rules! do_block{ - ($val:block) => {$val} -} - -fn main() { - let s; - do_block!({ s = "it works!"; }); - assert_eq!(s, "it works!"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-comma-behavior.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-comma-behavior.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-comma-behavior.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-comma-behavior.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Ideally, any macro call with a trailing comma should behave -// identically to a call without the comma. -// -// This checks the behavior of macros with trailing commas in key -// places where regressions in behavior seem highly possible (due -// to it being e.g. a place where the addition of an argument -// causes it to go down a code path with subtly different behavior). -// -// There is a companion test in compile-fail. - -// compile-flags: --test -C debug_assertions=yes -// revisions: std core - -#![cfg_attr(core, no_std)] - -#[cfg(std)] use std::fmt; -#[cfg(core)] use core::fmt; - -// an easy mistake in the implementation of 'assert!' -// would cause this to say "explicit panic" -#[test] -#[should_panic(expected = "assertion failed")] -fn assert_1arg() { - assert!(false,); -} - -// same as 'assert_1arg' -#[test] -#[should_panic(expected = "assertion failed")] -fn debug_assert_1arg() { - debug_assert!(false,); -} - -// make sure we don't accidentally forward to `write!("text")` -#[cfg(std)] -#[test] -fn writeln_1arg() { - use fmt::Write; - - let mut s = String::new(); - writeln!(&mut s,).unwrap(); - assert_eq!(&s, "\n"); -} - -// A number of format_args-like macros have special-case treatment -// for a single message string, which is not formatted. -// -// This test ensures that the addition of a trailing comma does not -// suddenly cause these strings to get formatted when they otherwise -// would not be. This is an easy mistake to make by having such a macro -// accept ", $($tok:tt)*" instead of ", $($tok:tt)+" after its minimal -// set of arguments. -// -// (Example: Issue #48042) -#[test] -fn to_format_or_not_to_format() { - // ("{}" is the easiest string to test because if this gets - // sent to format_args!, it'll simply fail to compile. - // "{{}}" is an example of an input that could compile and - // produce an incorrect program, but testing the panics - // would be burdensome.) - let falsum = || false; - - assert!(true, "{}",); - - // assert_eq!(1, 1, "{}",); // see compile-fail - // assert_ne!(1, 2, "{}",); // see compile-fail - - debug_assert!(true, "{}",); - - // debug_assert_eq!(1, 1, "{}",); // see compile-fail - // debug_assert_ne!(1, 2, "{}",); // see compile-fail - // eprint!("{}",); // see compile-fail - // eprintln!("{}",); // see compile-fail - // format!("{}",); // see compile-fail - // format_args!("{}",); // see compile-fail - - if falsum() { panic!("{}",); } - - // print!("{}",); // see compile-fail - // println!("{}",); // see compile-fail - // unimplemented!("{}",); // see compile-fail - - if falsum() { unreachable!("{}",); } - - // write!(&mut stdout, "{}",); // see compile-fail - // writeln!(&mut stdout, "{}",); // see compile-fail -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-comma-support.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-comma-support.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-comma-support.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-comma-support.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,360 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This is meant to be a comprehensive test of invocations with/without -// trailing commas (or other, similar optionally-trailing separators). -// Every macro is accounted for, even those not tested in this file. -// (There will be a note indicating why). - -// std and core are both tested because they may contain separate -// implementations for some macro_rules! macros as an implementation -// detail. - -// ignore-pretty issue #37195 - -// compile-flags: --test -C debug_assertions=yes -// revisions: std core - -#![cfg_attr(core, no_std)] - -#![feature(concat_idents)] - -#[cfg(std)] use std::fmt; -#[cfg(core)] use core::fmt; - -#[test] -fn assert() { - assert!(true); - assert!(true,); - assert!(true, "hello"); - assert!(true, "hello",); - assert!(true, "hello {}", "world"); - assert!(true, "hello {}", "world",); -} - -#[test] -fn assert_eq() { - assert_eq!(1, 1); - assert_eq!(1, 1,); - assert_eq!(1, 1, "hello"); - assert_eq!(1, 1, "hello",); - assert_eq!(1, 1, "hello {}", "world"); - assert_eq!(1, 1, "hello {}", "world",); -} - -#[test] -fn assert_ne() { - assert_ne!(1, 2); - assert_ne!(1, 2,); - assert_ne!(1, 2, "hello"); - assert_ne!(1, 2, "hello",); - assert_ne!(1, 2, "hello {}", "world"); - assert_ne!(1, 2, "hello {}", "world",); -} - -#[test] -fn cfg() { - let _ = cfg!(pants); - let _ = cfg!(pants,); - let _ = cfg!(pants = "pants"); - let _ = cfg!(pants = "pants",); - let _ = cfg!(all(pants)); - let _ = cfg!(all(pants),); - let _ = cfg!(all(pants,)); - let _ = cfg!(all(pants,),); -} - -#[test] -fn column() { - let _ = column!(); -} - -// compile_error! is in a companion to this test in compile-fail - -#[test] -fn concat() { - let _ = concat!(); - let _ = concat!("hello"); - let _ = concat!("hello",); - let _ = concat!("hello", " world"); - let _ = concat!("hello", " world",); -} - -#[test] -fn concat_idents() { - fn foo() {} - fn foobar() {} - - concat_idents!(foo)(); - concat_idents!(foo,)(); - concat_idents!(foo, bar)(); - concat_idents!(foo, bar,)(); -} - -#[test] -fn debug_assert() { - debug_assert!(true); - debug_assert!(true, ); - debug_assert!(true, "hello"); - debug_assert!(true, "hello",); - debug_assert!(true, "hello {}", "world"); - debug_assert!(true, "hello {}", "world",); -} - -#[test] -fn debug_assert_eq() { - debug_assert_eq!(1, 1); - debug_assert_eq!(1, 1,); - debug_assert_eq!(1, 1, "hello"); - debug_assert_eq!(1, 1, "hello",); - debug_assert_eq!(1, 1, "hello {}", "world"); - debug_assert_eq!(1, 1, "hello {}", "world",); -} - -#[test] -fn debug_assert_ne() { - debug_assert_ne!(1, 2); - debug_assert_ne!(1, 2,); - debug_assert_ne!(1, 2, "hello"); - debug_assert_ne!(1, 2, "hello",); - debug_assert_ne!(1, 2, "hello {}", "world"); - debug_assert_ne!(1, 2, "hello {}", "world",); -} - -#[test] -fn env() { - let _ = env!("PATH"); - let _ = env!("PATH",); - let _ = env!("PATH", "not found"); - let _ = env!("PATH", "not found",); -} - -#[cfg(std)] -#[test] -fn eprint() { - eprint!("hello"); - eprint!("hello",); - eprint!("hello {}", "world"); - eprint!("hello {}", "world",); -} - -#[cfg(std)] -#[test] -fn eprintln() { - eprintln!(); - eprintln!("hello"); - eprintln!("hello",); - eprintln!("hello {}", "world"); - eprintln!("hello {}", "world",); -} - -#[test] -fn file() { - let _ = file!(); -} - -#[cfg(std)] -#[test] -fn format() { - let _ = format!("hello"); - let _ = format!("hello",); - let _ = format!("hello {}", "world"); - let _ = format!("hello {}", "world",); -} - -#[test] -fn format_args() { - let _ = format_args!("hello"); - let _ = format_args!("hello",); - let _ = format_args!("hello {}", "world"); - let _ = format_args!("hello {}", "world",); -} - -#[test] -fn include() { - let _ = include!("auxiliary/macro-comma-support.rs"); - let _ = include!("auxiliary/macro-comma-support.rs",); -} - -#[test] -fn include_bytes() { - let _ = include_bytes!("auxiliary/macro-comma-support.rs"); - let _ = include_bytes!("auxiliary/macro-comma-support.rs",); -} - -#[test] -fn include_str() { - let _ = include_str!("auxiliary/macro-comma-support.rs"); - let _ = include_str!("auxiliary/macro-comma-support.rs",); -} - -#[test] -fn line() { - let _ = line!(); -} - -#[test] -fn module_path() { - let _ = module_path!(); -} - -#[test] -fn option_env() { - let _ = option_env!("PATH"); - let _ = option_env!("PATH",); -} - -#[test] -fn panic() { - // prevent 'unreachable code' warnings - let falsum = || false; - - if falsum() { panic!(); } - if falsum() { panic!("hello"); } - if falsum() { panic!("hello",); } - if falsum() { panic!("hello {}", "world"); } - if falsum() { panic!("hello {}", "world",); } -} - -#[cfg(std)] -#[test] -fn print() { - print!("hello"); - print!("hello",); - print!("hello {}", "world"); - print!("hello {}", "world",); -} - -#[cfg(std)] -#[test] -fn println() { - println!(); - println!("hello"); - println!("hello",); - println!("hello {}", "world"); - println!("hello {}", "world",); -} - -// select! is too troublesome and unlikely to be stabilized - -// stringify! is N/A - -#[cfg(std)] -#[test] -fn thread_local() { - // this has an optional trailing *semicolon* - thread_local! { - #[allow(unused)] pub static A: () = () - } - - thread_local! { - #[allow(unused)] pub static AA: () = (); - } - - thread_local! { - #[allow(unused)] pub static AAA: () = (); - #[allow(unused)] pub static AAAA: () = () - } - - thread_local! { - #[allow(unused)] pub static AAAAG: () = (); - #[allow(unused)] pub static AAAAGH: () = (); - } -} - -#[test] -fn try() { - fn inner() -> Result<(), ()> { - try!(Ok(())); - try!(Ok(()),); - Ok(()) - } - - inner().unwrap(); -} - -#[test] -fn unimplemented() { - // prevent 'unreachable code' warnings - let falsum = || false; - - if falsum() { unimplemented!(); } - if falsum() { unimplemented!("hello"); } - if falsum() { unimplemented!("hello",); } - if falsum() { unimplemented!("hello {}", "world"); } - if falsum() { unimplemented!("hello {}", "world",); } -} - -#[test] -fn unreachable() { - // prevent 'unreachable code' warnings - let falsum = || false; - - if falsum() { unreachable!(); } - if falsum() { unreachable!("hello"); } - if falsum() { unreachable!("hello",); } - if falsum() { unreachable!("hello {}", "world"); } - if falsum() { unreachable!("hello {}", "world",); } -} - -#[cfg(std)] -#[test] -fn vec() { - let _: Vec<()> = vec![]; - let _ = vec![0]; - let _ = vec![0,]; - let _ = vec![0, 1]; - let _ = vec![0, 1,]; -} - -// give a test body access to a fmt::Formatter, which seems -// to be the easiest way to use 'write!' on core. -macro_rules! test_with_formatter { - ( - #[test] - fn $fname:ident($f:ident: &mut fmt::Formatter) $block:block - ) => { - #[test] - fn $fname() { - struct Struct; - impl fmt::Display for Struct { - fn fmt(&self, $f: &mut fmt::Formatter) -> fmt::Result { - Ok($block) - } - } - - // suppress "unused" - assert!(true, "{}", Struct); - } - }; -} - -test_with_formatter! { - #[test] - fn write(f: &mut fmt::Formatter) { - let _ = write!(f, "hello"); - let _ = write!(f, "hello",); - let _ = write!(f, "hello {}", "world"); - let _ = write!(f, "hello {}", "world",); - } -} - -test_with_formatter! { - #[test] - fn writeln(f: &mut fmt::Formatter) { - let _ = writeln!(f); - let _ = writeln!(f,); - let _ = writeln!(f, "hello"); - let _ = writeln!(f, "hello",); - let _ = writeln!(f, "hello {}", "world"); - let _ = writeln!(f, "hello {}", "world",); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-crate-def-only.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-crate-def-only.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-crate-def-only.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-crate-def-only.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:macro_crate_def_only.rs - - -#[macro_use] #[no_link] -extern crate macro_crate_def_only; - -pub fn main() { - assert_eq!(5, make_a_5!()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-crate-nonterminal-renamed.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-crate-nonterminal-renamed.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-crate-nonterminal-renamed.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-crate-nonterminal-renamed.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:macro_crate_nonterminal.rs - -#[macro_use] -extern crate macro_crate_nonterminal as new_name; - -pub fn main() { - new_name::check_local(); - assert_eq!(increment!(5), 6); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-crate-nonterminal.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-crate-nonterminal.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-crate-nonterminal.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-crate-nonterminal.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:macro_crate_nonterminal.rs - -#[macro_use] -extern crate macro_crate_nonterminal; - -pub fn main() { - macro_crate_nonterminal::check_local(); - assert_eq!(increment!(5), 6); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-crate-use.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-crate-use.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-crate-use.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-crate-use.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn increment(x: usize) -> usize { - x + 1 -} - -#[macro_export] -macro_rules! increment { - ($x:expr) => ({ - use $crate::increment; - increment($x) - }) -} - -fn main() { - assert_eq!(increment!(3), 4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-deep_expansion.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-deep_expansion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-deep_expansion.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-deep_expansion.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -macro_rules! foo2 { - () => { - "foo" - } -} - -macro_rules! foo { - () => { - foo2!() - } -} - -fn main() { - assert_eq!(concat!(foo!(), "bar"), "foobar") -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-delimiter-significance.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-delimiter-significance.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-delimiter-significance.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-delimiter-significance.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - vec![1_usize, 2, 3].len(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-doc-comments.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-doc-comments.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-doc-comments.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-doc-comments.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_snake_case)] - -macro_rules! doc { - ( - $(#[$outer:meta])* - mod $i:ident { - $(#![$inner:meta])* - } - ) => - ( - $(#[$outer])* - pub mod $i { - $(#![$inner])* - } - ) -} - -doc! { - /// Outer doc - mod Foo { - //! Inner doc - } -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-doc-escapes.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-doc-escapes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-doc-escapes.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-doc-escapes.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// When expanding a macro, documentation attributes (including documentation comments) must be -// passed "as is" without being parsed. Otherwise, some text will be incorrectly interpreted as -// escape sequences, leading to an ICE. -// -// Related issues: #25929, #25943 - -macro_rules! homura { - (#[$x:meta]) => () -} - -homura! { - /// \madoka \x41 -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-doc-raw-str-hashes.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-doc-raw-str-hashes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-doc-raw-str-hashes.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-doc-raw-str-hashes.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// The number of `#`s used to wrap the documentation comment should differ regarding the content. -// -// Related issue: #27489 - -macro_rules! homura { - ($x:expr, #[$y:meta]) => (assert_eq!($x, stringify!($y))) -} - -fn main() { - homura! { - r#"doc = r" Madoka""#, - /// Madoka - }; - - homura! { - r##"doc = r#" One quote mark: ["]"#"##, - /// One quote mark: ["] - }; - - homura! { - r##"doc = r#" Two quote marks: [""]"#"##, - /// Two quote marks: [""] - }; - - homura! { - r#####"doc = r####" Raw string ending sequences: ["###]"####"#####, - /// Raw string ending sequences: ["###] - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-export-inner-module.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-export-inner-module.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-export-inner-module.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-export-inner-module.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -//aux-build:macro_export_inner_module.rs - -#[macro_use] #[no_link] -extern crate macro_export_inner_module; - -pub fn main() { - assert_eq!(1, foo!()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-first-set.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-first-set.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-first-set.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-first-set.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,289 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![cfg_attr(stage0, feature(macro_vis_matcher))] - -//{{{ issue 40569 ============================================================== - -macro_rules! my_struct { - ($(#[$meta:meta])* $ident:ident) => { - $(#[$meta])* struct $ident; - } -} - -my_struct!(#[derive(Debug, PartialEq)] Foo40569); - -fn test_40569() { - assert_eq!(Foo40569, Foo40569); -} - -//}}} - -//{{{ issue 26444 ============================================================== - -macro_rules! foo_26444 { - ($($beginning:ident),*; $middle:ident; $($end:ident),*) => { - stringify!($($beginning,)* $middle $(,$end)*) - } -} - -fn test_26444() { - assert_eq!("a , b , c , d , e", foo_26444!(a, b; c; d, e)); - assert_eq!("f", foo_26444!(; f ;)); -} - -macro_rules! pat_26444 { - ($fname:ident $($arg:pat)* =) => {} -} - -pat_26444!(foo 1 2 5...7 =); -pat_26444!(bar Some(ref x) Ok(ref mut y) &(w, z) =); - -//}}} - -//{{{ issue 40984 ============================================================== - -macro_rules! thread_local_40984 { - () => {}; - ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr; $($rest:tt)*) => { - thread_local_40984!($($rest)*); - }; - ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr) => {}; -} - -thread_local_40984! { - // no docs - #[allow(unused)] - static FOO: i32 = 42; - /// docs - pub static BAR: String = String::from("bar"); - - // look at these restrictions!! - pub(crate) static BAZ: usize = 0; - pub(in foo) static QUUX: usize = 0; -} - -//}}} - -//{{{ issue 35650 ============================================================== - -macro_rules! size { - ($ty:ty) => { - std::mem::size_of::<$ty>() - }; - ($size:tt) => { - $size - }; -} - -fn test_35650() { - assert_eq!(size!(u64), 8); - assert_eq!(size!(5), 5); -} - -//}}} - -//{{{ issue 27832 ============================================================== - -macro_rules! m { - ( $i:ident ) => (); - ( $t:tt $j:tt ) => (); -} - -m!(c); -m!(t 9); -m!(0 9); -m!(struct); -m!(struct Foo); - -macro_rules! m2 { - ( $b:expr ) => (); - ( $t:tt $u:tt ) => (); -} - -m2!(3); -m2!(1 2); -m2!(_ 1); -m2!(enum Foo); - -//}}} - -//{{{ issue 39964 ============================================================== - -macro_rules! foo_39964 { - ($a:ident) => {}; - (_) => {}; -} - -foo_39964!(_); - -//}}} - -//{{{ issue 34030 ============================================================== - -macro_rules! foo_34030 { - ($($t:ident),* /) => {}; -} - -foo_34030!(a, b/); -foo_34030!(a/); -foo_34030!(/); - -//}}} - -//{{{ issue 24189 ============================================================== - -macro_rules! foo_24189 { - ( - pub enum $name:ident { - $( #[$attr:meta] )* $var:ident - } - ) => { - pub enum $name { - $( #[$attr] )* $var - } - }; -} - -foo_24189! { - pub enum Foo24189 { - #[doc = "Bar"] Baz - } -} - -macro_rules! serializable { - ( - $(#[$struct_meta:meta])* - pub struct $name:ident { - $( - $(#[$field_meta:meta])* - $field:ident: $type_:ty - ),* , - } - ) => { - $(#[$struct_meta])* - pub struct $name { - $( - $(#[$field_meta])* - $field: $type_ - ),* , - } - } -} - -serializable! { - #[allow(dead_code)] - /// This is a test - pub struct Tester { - #[allow(dead_code)] - name: String, - } -} - -macro_rules! foo_24189_c { - ( $( > )* $x:ident ) => { }; -} -foo_24189_c!( > a ); - -fn test_24189() { - let _ = Foo24189::Baz; - let _ = Tester { name: "".to_owned() }; -} - -//}}} - -//{{{ issue 50903 ============================================================== - -macro_rules! foo_50903 { - ($($lif:lifetime ,)* #) => {}; -} - -foo_50903!('a, 'b, #); -foo_50903!('a, #); -foo_50903!(#); - -//}}} - -//{{{ issue 51477 ============================================================== - -macro_rules! foo_51477 { - ($lifetime:lifetime) => { - "last token is lifetime" - }; - ($other:tt) => { - "last token is other" - }; - ($first:tt $($rest:tt)*) => { - foo_51477!($($rest)*) - }; -} - -fn test_51477() { - assert_eq!("last token is lifetime", foo_51477!('a)); - assert_eq!("last token is other", foo_51477!(@)); - assert_eq!("last token is lifetime", foo_51477!(@ {} 'a)); -} - -//}}} - -//{{{ some more tests ========================================================== - -macro_rules! test_block { - (< $($b:block)* >) => {} -} - -test_block!(<>); -test_block!(<{}>); -test_block!(<{1}{2}>); - -macro_rules! test_ty { - ($($t:ty),* $(,)*) => {} -} - -test_ty!(); -test_ty!(,); -test_ty!(u8); -test_ty!(u8,); - -macro_rules! test_path { - ($($t:path),* $(,)*) => {} -} - -test_path!(); -test_path!(,); -test_path!(::std); -test_path!(std::u8,); -test_path!(any, super, super::super::self::path, X::Z<'a, T=U>); - -macro_rules! test_meta_block { - ($($m:meta)* $b:block) => {}; -} - -test_meta_block!(windows {}); - -macro_rules! test_lifetime { - (1. $($l:lifetime)* $($b:block)*) => {}; - (2. $($b:block)* $($l:lifetime)*) => {}; -} - -test_lifetime!(1. 'a 'b {} {}); -test_lifetime!(2. {} {} 'a 'b); - -//}}} - -fn main() { - test_26444(); - test_40569(); - test_35650(); - test_24189(); - test_51477(); -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-followed-by-seq.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-followed-by-seq.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-followed-by-seq.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-followed-by-seq.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for issue #25436: check that things which can be -// followed by any token also permit X* to come afterwards. - -macro_rules! foo { - ( $a:tt $($b:tt)* ) => { }; - ( $a:ident $($b:tt)* ) => { }; - ( $a:item $($b:tt)* ) => { }; - ( $a:block $($b:tt)* ) => { }; - ( $a:meta $($b:tt)* ) => { } -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-follow.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-follow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-follow.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-follow.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,193 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check the macro follow sets (see corresponding cfail test). - -// FOLLOW(pat) = {FatArrow, Comma, Eq, Or, Ident(if), Ident(in)} -macro_rules! follow_pat { - ($p:pat =>) => {}; - ($p:pat ,) => {}; - ($p:pat =) => {}; - ($p:pat |) => {}; - ($p:pat if) => {}; - ($p:pat in) => {}; -} -// FOLLOW(expr) = {FatArrow, Comma, Semicolon} -macro_rules! follow_expr { - ($e:expr =>) => {}; - ($e:expr ,) => {}; - ($e:expr ;) => {}; -} -// FOLLOW(ty) = {OpenDelim(Brace), Comma, FatArrow, Colon, Eq, Gt, Semi, Or, -// Ident(as), Ident(where), OpenDelim(Bracket), Nonterminal(Block)} -macro_rules! follow_ty { - ($t:ty {}) => {}; - ($t:ty ,) => {}; - ($t:ty =>) => {}; - ($t:ty :) => {}; - ($t:ty =) => {}; - ($t:ty >) => {}; - ($t:ty ;) => {}; - ($t:ty |) => {}; - ($t:ty as) => {}; - ($t:ty where) => {}; - ($t:ty []) => {}; - ($t:ty $b:block) => {}; -} -// FOLLOW(stmt) = FOLLOW(expr) -macro_rules! follow_stmt { - ($s:stmt =>) => {}; - ($s:stmt ,) => {}; - ($s:stmt ;) => {}; -} -// FOLLOW(path) = FOLLOW(ty) -macro_rules! follow_path { - ($p:path {}) => {}; - ($p:path ,) => {}; - ($p:path =>) => {}; - ($p:path :) => {}; - ($p:path =) => {}; - ($p:path >) => {}; - ($p:path ;) => {}; - ($p:path |) => {}; - ($p:path as) => {}; - ($p:path where) => {}; - ($p:path []) => {}; - ($p:path $b:block) => {}; -} -// FOLLOW(block) = any token -macro_rules! follow_block { - ($b:block ()) => {}; - ($b:block []) => {}; - ($b:block {}) => {}; - ($b:block ,) => {}; - ($b:block =>) => {}; - ($b:block :) => {}; - ($b:block =) => {}; - ($b:block >) => {}; - ($b:block ;) => {}; - ($b:block |) => {}; - ($b:block +) => {}; - ($b:block ident) => {}; - ($b:block $p:pat) => {}; - ($b:block $e:expr) => {}; - ($b:block $t:ty) => {}; - ($b:block $s:stmt) => {}; - ($b:block $p:path) => {}; - ($b:block $b:block) => {}; - ($b:block $i:ident) => {}; - ($b:block $t:tt) => {}; - ($b:block $i:item) => {}; - ($b:block $m:meta) => {}; -} -// FOLLOW(ident) = any token -macro_rules! follow_ident { - ($i:ident ()) => {}; - ($i:ident []) => {}; - ($i:ident {}) => {}; - ($i:ident ,) => {}; - ($i:ident =>) => {}; - ($i:ident :) => {}; - ($i:ident =) => {}; - ($i:ident >) => {}; - ($i:ident ;) => {}; - ($i:ident |) => {}; - ($i:ident +) => {}; - ($i:ident ident) => {}; - ($i:ident $p:pat) => {}; - ($i:ident $e:expr) => {}; - ($i:ident $t:ty) => {}; - ($i:ident $s:stmt) => {}; - ($i:ident $p:path) => {}; - ($i:ident $b:block) => {}; - ($i:ident $i:ident) => {}; - ($i:ident $t:tt) => {}; - ($i:ident $i:item) => {}; - ($i:ident $m:meta) => {}; -} -// FOLLOW(tt) = any token -macro_rules! follow_tt { - ($t:tt ()) => {}; - ($t:tt []) => {}; - ($t:tt {}) => {}; - ($t:tt ,) => {}; - ($t:tt =>) => {}; - ($t:tt :) => {}; - ($t:tt =) => {}; - ($t:tt >) => {}; - ($t:tt ;) => {}; - ($t:tt |) => {}; - ($t:tt +) => {}; - ($t:tt ident) => {}; - ($t:tt $p:pat) => {}; - ($t:tt $e:expr) => {}; - ($t:tt $t:ty) => {}; - ($t:tt $s:stmt) => {}; - ($t:tt $p:path) => {}; - ($t:tt $b:block) => {}; - ($t:tt $i:ident) => {}; - ($t:tt $t:tt) => {}; - ($t:tt $i:item) => {}; - ($t:tt $m:meta) => {}; -} -// FOLLOW(item) = any token -macro_rules! follow_item { - ($i:item ()) => {}; - ($i:item []) => {}; - ($i:item {}) => {}; - ($i:item ,) => {}; - ($i:item =>) => {}; - ($i:item :) => {}; - ($i:item =) => {}; - ($i:item >) => {}; - ($i:item ;) => {}; - ($i:item |) => {}; - ($i:item +) => {}; - ($i:item ident) => {}; - ($i:item $p:pat) => {}; - ($i:item $e:expr) => {}; - ($i:item $t:ty) => {}; - ($i:item $s:stmt) => {}; - ($i:item $p:path) => {}; - ($i:item $b:block) => {}; - ($i:item $i:ident) => {}; - ($i:item $t:tt) => {}; - ($i:item $i:item) => {}; - ($i:item $m:meta) => {}; -} -// FOLLOW(meta) = any token -macro_rules! follow_meta { - ($m:meta ()) => {}; - ($m:meta []) => {}; - ($m:meta {}) => {}; - ($m:meta ,) => {}; - ($m:meta =>) => {}; - ($m:meta :) => {}; - ($m:meta =) => {}; - ($m:meta >) => {}; - ($m:meta ;) => {}; - ($m:meta |) => {}; - ($m:meta +) => {}; - ($m:meta ident) => {}; - ($m:meta $p:pat) => {}; - ($m:meta $e:expr) => {}; - ($m:meta $t:ty) => {}; - ($m:meta $s:stmt) => {}; - ($m:meta $p:path) => {}; - ($m:meta $b:block) => {}; - ($m:meta $i:ident) => {}; - ($m:meta $t:tt) => {}; - ($m:meta $i:item) => {}; - ($m:meta $m:meta) => {}; -} - -fn main() {} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-include-items.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-include-items.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-include-items.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-include-items.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// ignore-pretty issue #37195 - -fn bar() {} - -include!(concat!("", "", "auxiliary/", "macro-include-items-item.rs")); - -fn main() { - foo(); - assert_eq!(include!(concat!("", "auxiliary/", "macro-include-items-expr.rs")), 1_usize); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-interpolation.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-interpolation.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-interpolation.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-interpolation.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -macro_rules! overly_complicated { - ($fnname:ident, $arg:ident, $ty:ty, $body:block, $val:expr, $pat:pat, $res:path) => - ({ - fn $fnname($arg: $ty) -> Option<$ty> $body - match $fnname($val) { - Some($pat) => { - $res - } - _ => { panic!(); } - } - }) - -} - -pub fn main() { - assert!(overly_complicated!(f, x, Option, { return Some(x); }, - Some(8), Some(y), y) == 8) - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-invocation-in-count-expr-fixed-array-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-invocation-in-count-expr-fixed-array-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-invocation-in-count-expr-fixed-array-type.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-invocation-in-count-expr-fixed-array-type.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -macro_rules! four { - () => (4) -} - -fn main() { - let _x: [u16; four!()]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-lifetime.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-lifetime.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-lifetime.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-lifetime.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! foo { - ($l:lifetime) => { - fn f<$l>(arg: &$l str) -> &$l str { - arg - } - } -} - -pub fn main() { - foo!('a); - let x: &'static str = f("hi"); - assert_eq!("hi", x); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-lifetime-used-with-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-lifetime-used-with-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-lifetime-used-with-bound.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-lifetime-used-with-bound.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! foo { - ($l:lifetime, $l2:lifetime) => { - fn f<$l: $l2, $l2>(arg: &$l str, arg2: &$l2 str) -> &$l str { - arg - } - } -} - -pub fn main() { - foo!('a, 'b); - let x: &'static str = f("hi", "there"); - assert_eq!("hi", x); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-lifetime-used-with-labels.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-lifetime-used-with-labels.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-lifetime-used-with-labels.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-lifetime-used-with-labels.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -#![allow(unreachable_code)] - -macro_rules! x { - ($a:lifetime) => { - $a: loop { - break $a; - panic!("failed"); - } - } -} -macro_rules! br { - ($a:lifetime) => { - break $a; - } -} -macro_rules! br2 { - ($b:lifetime) => { - 'b: loop { - break $b; // this $b should refer to the outer loop. - } - } -} -fn main() { - x!('a); - 'c: loop { - br!('c); - panic!("failed"); - } - 'b: loop { - br2!('b); - panic!("failed"); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-lifetime-used-with-labels.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-lifetime-used-with-labels.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-lifetime-used-with-labels.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-lifetime-used-with-labels.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -warning: label name `'b` shadows a label name that is already in scope - --> $DIR/macro-lifetime-used-with-labels.rs:31:9 - | -LL | 'b: loop { - | ^^ lifetime 'b already in scope -... -LL | 'b: loop { - | -- first declared here -LL | br2!('b); - | --------- in this macro invocation - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-lifetime-used-with-static.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-lifetime-used-with-static.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-lifetime-used-with-static.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-lifetime-used-with-static.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! foo { - ($l:lifetime) => { - fn f(arg: &$l str) -> &$l str { - arg - } - } -} - -pub fn main() { - foo!('static); - let x: &'static str = f("hi"); - assert_eq!("hi", x); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-literal.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-literal.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-literal.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-literal.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,144 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(macro_literal_matcher)] - -macro_rules! mtester { - ($l:literal) => { - &format!("macro caught literal: {}", $l) - }; - ($e:expr) => { - &format!("macro caught expr: {}", $e) - }; -} - -macro_rules! two_negative_literals { - ($l1:literal $l2:literal) => { - &format!("macro caught literals: {}, {}", $l1, $l2) - }; -} - -macro_rules! only_expr { - ($e:expr) => { - &format!("macro caught expr: {}", $e) - }; -} - -macro_rules! mtester_dbg { - ($l:literal) => { - &format!("macro caught literal: {:?}", $l) - }; - ($e:expr) => { - &format!("macro caught expr: {:?}", $e) - }; -} - -macro_rules! catch_range { - ($s:literal ..= $e:literal) => { - &format!("macro caught literal: {} ..= {}", $s, $e) - }; - (($s:expr) ..= ($e:expr)) => { // Must use ')' before '..=' - &format!("macro caught expr: {} ..= {}", $s, $e) - }; -} - -macro_rules! pat_match { - ($s:literal ..= $e:literal) => { - match 3 { - $s ..= $e => "literal, in range", - _ => "literal, other", - } - }; - ($s:pat) => { - match 3 { - $s => "pat, single", - _ => "pat, other", - } - }; -} - -macro_rules! match_attr { - (#[$attr:meta] $e:literal) => { - "attr matched literal" - }; - (#[$attr:meta] $e:expr) => { - "attr matched expr" - }; -} - -macro_rules! match_produced_attr { - ($lit: literal) => { - // Struct with doc comment passed via $literal - #[doc = $lit] - struct LiteralProduced; - }; - ($expr: expr) => { - struct ExprProduced; - }; -} - -macro_rules! test_user { - ($s:literal, $e:literal) => { - { - let mut v = Vec::new(); - for i in $s .. $e { - v.push(i); - } - "literal" - } - }; - ($s:expr, $e: expr) => { - { - let mut v = Vec::new(); - for i in $s .. $e { - v.push(i); - } - "expr" - } - }; -} - -pub fn main() { - // Cases where 'literal' catches - assert_eq!(mtester!("str"), "macro caught literal: str"); - assert_eq!(mtester!(2), "macro caught literal: 2"); - assert_eq!(mtester!(2.2), "macro caught literal: 2.2"); - assert_eq!(mtester!(1u32), "macro caught literal: 1"); - assert_eq!(mtester!(0x32), "macro caught literal: 50"); - assert_eq!(mtester!('c'), "macro caught literal: c"); - assert_eq!(mtester!(-1.2), "macro caught literal: -1.2"); - assert_eq!(two_negative_literals!(-2 -3), "macro caught literals: -2, -3"); - assert_eq!(catch_range!(2 ..= 3), "macro caught literal: 2 ..= 3"); - assert_eq!(match_attr!(#[attr] 1), "attr matched literal"); - assert_eq!(test_user!(10, 20), "literal"); - assert_eq!(mtester!(false), "macro caught literal: false"); - assert_eq!(mtester!(true), "macro caught literal: true"); - match_produced_attr!("a"); - let _a = LiteralProduced; - assert_eq!(pat_match!(1 ..= 3), "literal, in range"); - assert_eq!(pat_match!(4 ..= 6), "literal, other"); - - // Cases where 'expr' catches - assert_eq!(mtester!((-1.2)), "macro caught expr: -1.2"); - assert_eq!(only_expr!(-1.2), "macro caught expr: -1.2"); - assert_eq!(mtester!((1 + 3)), "macro caught expr: 4"); - assert_eq!(mtester_dbg!(()), "macro caught expr: ()"); - assert_eq!(catch_range!((1 + 1) ..= (2 + 2)), "macro caught expr: 2 ..= 4"); - assert_eq!(match_attr!(#[attr] (1 + 2)), "attr matched expr"); - assert_eq!(test_user!(10, (20 + 2)), "expr"); - - match_produced_attr!((3 + 2)); - let _b = ExprProduced; - - // Cases where 'pat' matched - assert_eq!(pat_match!(3), "pat, single"); - assert_eq!(pat_match!(6), "pat, other"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-meta-items.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-meta-items.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-meta-items.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-meta-items.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: --cfg foo - -macro_rules! compiles_fine { - ($at:meta) => { - #[cfg($at)] - static MISTYPED: () = "foo"; - } -} -macro_rules! emit { - ($at:meta) => { - #[cfg($at)] - static MISTYPED: &'static str = "foo"; - } -} - -// item -compiles_fine!(bar); -emit!(foo); - -fn foo() { - println!("{}", MISTYPED); -} - -pub fn main() { - // statement - compiles_fine!(baz); - emit!(baz); - println!("{}", MISTYPED); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-method-issue-4621.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-method-issue-4621.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-method-issue-4621.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-method-issue-4621.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct A; - -macro_rules! make_thirteen_method {() => (fn thirteen(&self)->isize {13})} -impl A { make_thirteen_method!(); } - -fn main() { - assert_eq!(A.thirteen(),13); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-multiple-items.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-multiple-items.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-multiple-items.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-multiple-items.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! make_foo { - () => ( - struct Foo; - - impl Foo { - fn bar(&self) {} - } - ) -} - -make_foo!(); - -pub fn main() { - Foo.bar() -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-named-default.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-named-default.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-named-default.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-named-default.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! default { - ($($x:tt)*) => { $($x)* } -} - -default! { - struct A; -} - -impl A { - default! { - fn foo(&self) {} - } -} - -fn main() { - A.foo(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-nested_definition_issue-31946.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-nested_definition_issue-31946.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-nested_definition_issue-31946.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-nested_definition_issue-31946.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - println!("{}", { - macro_rules! foo { - ($name:expr) => { concat!("hello ", $name) } - } - foo!("rust") - }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-nested_expr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-nested_expr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-nested_expr.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-nested_expr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// #42164 - -#![feature(decl_macro)] -#![allow(dead_code)] - -pub macro m($inner_str:expr) { - #[doc = $inner_str] - struct S; -} - -macro_rules! define_f { - ($name:expr) => { - #[export_name = $name] - fn f() {} - } -} - -fn main() { - define_f!(concat!("exported_", "f")); - m!(stringify!(foo)); -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-nested_stmt_macros.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-nested_stmt_macros.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-nested_stmt_macros.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-nested_stmt_macros.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! foo { - () => { - struct Bar; - struct Baz; - } -} - -macro_rules! grault { - () => { - foo!(); - struct Xyzzy; - } -} - -fn static_assert_exists() { } - -fn main() { - grault!(); - static_assert_exists::(); - static_assert_exists::(); - static_assert_exists::(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-nt-list.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-nt-list.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-nt-list.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-nt-list.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -macro_rules! list { - ( ($($id:ident),*) ) => (()); - ( [$($id:ident),*] ) => (()); - ( {$($id:ident),*} ) => (()); -} - -macro_rules! tt_list { - ( ($($tt:tt),*) ) => (()); -} - -pub fn main() { - list!( () ); - list!( [] ); - list!( {} ); - - tt_list!( (a, b, c) ); - tt_list!( () ); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-of-higher-order.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-of-higher-order.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-of-higher-order.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-of-higher-order.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -macro_rules! higher_order { - (subst $lhs:tt => $rhs:tt) => ({ - macro_rules! anon { $lhs => $rhs } - anon!(1_usize, 2_usize, "foo") - }); -} - -macro_rules! outer { - ($x:expr; $fragment:ident) => { - macro_rules! inner { ($y:$fragment) => { $x + $y } } - } -} - -fn main() { - let val = higher_order!(subst ($x:expr, $y:expr, $foo:expr) => (($x + $y, $foo))); - assert_eq!(val, (3, "foo")); - - outer!(2; expr); - assert_eq!(inner!(3), 5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-pat-follow.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-pat-follow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-pat-follow.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-pat-follow.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! pat_in { - ($p:pat in $e:expr) => {{ - let mut iter = $e.into_iter(); - while let $p = iter.next() {} - }} -} - -macro_rules! pat_if { - ($p:pat if $e:expr) => {{ - match Some(1u8) { - $p if $e => {}, - _ => {} - } - }} -} - -macro_rules! pat_bar { - ($p:pat | $p2:pat) => {{ - match Some(1u8) { - $p | $p2 => {}, - _ => {} - } - }} -} - -fn main() { - pat_in!(Some(_) in 0..10); - pat_if!(Some(x) if x > 0); - pat_bar!(Some(1u8) | None); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-path.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-path.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-path.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-path.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - -mod m { - pub type t = isize; -} - -macro_rules! foo { - ($p:path) => ({ - fn f() -> $p { 10 }; - f() - }) -} - -pub fn main() { - assert_eq!(foo!(m::t), 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-pat-neg-lit.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-pat-neg-lit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-pat-neg-lit.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-pat-neg-lit.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! enum_number { - ($name:ident { $($variant:ident = $value:expr, )* }) => { - enum $name { - $($variant = $value,)* - } - - fn foo(value: i32) -> Option<$name> { - match value { - $( $value => Some($name::$variant), )* - _ => None - } - } - } -} - -enum_number!(Change { - Down = -1, - None = 0, - Up = 1, -}); - -fn main() { - if let Some(Change::Down) = foo(-1) {} else { panic!() } -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-pat.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-pat.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-pat.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-pat.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -macro_rules! mypat { - () => ( - Some('y') - ) -} - -macro_rules! char_x { - () => ( - 'x' - ) -} - -macro_rules! some { - ($x:pat) => ( - Some($x) - ) -} - -macro_rules! indirect { - () => ( - some!(char_x!()) - ) -} - -macro_rules! ident_pat { - ($x:ident) => ( - $x - ) -} - -fn f(c: Option) -> usize { - match c { - Some('x') => 1, - mypat!() => 2, - _ => 3, - } -} - -pub fn main() { - assert_eq!(1, f(Some('x'))); - assert_eq!(2, f(Some('y'))); - assert_eq!(3, f(None)); - - assert_eq!(1, match Some('x') { - Some(char_x!()) => 1, - _ => 2, - }); - - assert_eq!(1, match Some('x') { - some!(char_x!()) => 1, - _ => 2, - }); - - assert_eq!(1, match Some('x') { - indirect!() => 1, - _ => 2, - }); - - assert_eq!(3, { - let ident_pat!(x) = 2; - x+1 - }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-pub-matcher.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-pub-matcher.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-pub-matcher.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-pub-matcher.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,129 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(dead_code, unused_imports)] -#![cfg_attr(stage0, feature(macro_vis_matcher))] -#![feature(crate_visibility_modifier)] - -/** -Ensure that `:vis` matches can be captured in existing positions, and passed -through without the need for reparse tricks. -*/ -macro_rules! vis_passthru { - ($vis:vis const $name:ident: $ty:ty = $e:expr;) => { $vis const $name: $ty = $e; }; - ($vis:vis enum $name:ident {}) => { $vis struct $name {} }; - ($vis:vis extern "C" fn $name:ident() {}) => { $vis extern "C" fn $name() {} }; - ($vis:vis fn $name:ident() {}) => { $vis fn $name() {} }; - ($vis:vis mod $name:ident {}) => { $vis mod $name {} }; - ($vis:vis static $name:ident: $ty:ty = $e:expr;) => { $vis static $name: $ty = $e; }; - ($vis:vis struct $name:ident;) => { $vis struct $name; }; - ($vis:vis trait $name:ident {}) => { $vis trait $name {} }; - ($vis:vis type $name:ident = $ty:ty;) => { $vis type $name = $ty; }; - ($vis:vis use $path:ident as $name:ident;) => { $vis use self::$path as $name; }; -} - -mod with_pub { - vis_passthru! { pub const A: i32 = 0; } - vis_passthru! { pub enum B {} } - vis_passthru! { pub extern "C" fn c() {} } - vis_passthru! { pub mod d {} } - vis_passthru! { pub static E: i32 = 0; } - vis_passthru! { pub struct F; } - vis_passthru! { pub trait G {} } - vis_passthru! { pub type H = i32; } - vis_passthru! { pub use A as I; } -} - -mod without_pub { - vis_passthru! { const A: i32 = 0; } - vis_passthru! { enum B {} } - vis_passthru! { extern "C" fn c() {} } - vis_passthru! { mod d {} } - vis_passthru! { static E: i32 = 0; } - vis_passthru! { struct F; } - vis_passthru! { trait G {} } - vis_passthru! { type H = i32; } - vis_passthru! { use A as I; } -} - -mod with_pub_restricted { - vis_passthru! { pub(crate) const A: i32 = 0; } - vis_passthru! { pub(crate) enum B {} } - vis_passthru! { pub(crate) extern "C" fn c() {} } - vis_passthru! { pub(crate) mod d {} } - vis_passthru! { pub(crate) static E: i32 = 0; } - vis_passthru! { pub(crate) struct F; } - vis_passthru! { pub(crate) trait G {} } - vis_passthru! { pub(crate) type H = i32; } - vis_passthru! { pub(crate) use A as I; } -} - -mod with_crate { - vis_passthru! { crate const A: i32 = 0; } - vis_passthru! { crate enum B {} } - vis_passthru! { crate extern "C" fn c() {} } - vis_passthru! { crate mod d {} } - vis_passthru! { crate static E: i32 = 0; } - vis_passthru! { crate struct F; } - vis_passthru! { crate trait G {} } - vis_passthru! { crate type H = i32; } - vis_passthru! { crate use A as I; } -} - -mod garden { - mod with_pub_restricted_path { - vis_passthru! { pub(in garden) const A: i32 = 0; } - vis_passthru! { pub(in garden) enum B {} } - vis_passthru! { pub(in garden) extern "C" fn c() {} } - vis_passthru! { pub(in garden) mod d {} } - vis_passthru! { pub(in garden) static E: i32 = 0; } - vis_passthru! { pub(in garden) struct F; } - vis_passthru! { pub(in garden) trait G {} } - vis_passthru! { pub(in garden) type H = i32; } - vis_passthru! { pub(in garden) use A as I; } - } -} - -/* -Ensure that the `:vis` matcher works in a more complex situation: parsing a -struct definition. -*/ -macro_rules! vis_parse_struct { - ($(#[$($attrs:tt)*])* $vis:vis struct $name:ident {$($body:tt)*}) => { - vis_parse_struct! { @parse_fields $(#[$($attrs)*])*, $vis, $name, $($body)* } - }; - - ($(#[$($attrs:tt)*])* $vis:vis struct $name:ident ($($body:tt)*);) => { - vis_parse_struct! { @parse_tuple $(#[$($attrs)*])*, $vis, $name, $($body)* } - }; - - (@parse_fields - $(#[$attrs:meta])*, $vis:vis, $name:ident, $($fvis:vis $fname:ident: $fty:ty),* $(,)*) => { - $(#[$attrs])* $vis struct $name { $($fvis $fname: $fty,)* } - }; - - (@parse_tuple - $(#[$attrs:meta])*, $vis:vis, $name:ident, $($fvis:vis $fty:ty),* $(,)*) => { - $(#[$attrs])* $vis struct $name ( $($fvis $fty,)* ); - }; -} - -mod test_struct { - vis_parse_struct! { pub(crate) struct A { pub a: i32, b: i32, pub(crate) c: i32 } } - vis_parse_struct! { pub struct B { a: i32, pub(crate) b: i32, pub c: i32 } } - vis_parse_struct! { struct C { pub(crate) a: i32, pub b: i32, c: i32 } } - - vis_parse_struct! { pub(crate) struct D (pub i32, i32, pub(crate) i32); } - vis_parse_struct! { pub struct E (i32, pub(crate) i32, pub i32); } - vis_parse_struct! { struct F (pub(crate) i32, pub i32, i32); } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-seq-followed-by-seq.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-seq-followed-by-seq.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-seq-followed-by-seq.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-seq-followed-by-seq.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test of allowing two sequences repetitions in a row, -// functionality added as byproduct of RFC amendment #1384 -// https://github.com/rust-lang/rfcs/pull/1384 - -// Old version of Rust would reject this macro definition, even though -// there are no local ambiguities (the initial `banana` and `orange` -// tokens are enough for the expander to distinguish which case is -// intended). -macro_rules! foo { - ( $(banana $a:ident)* $(orange $b:tt)* ) => { }; -} - -fn main() { - foo!( banana id1 banana id2 - orange hi orange (hello world) ); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macros-in-extern.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macros-in-extern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macros-in-extern.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macros-in-extern.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32 - -#![feature(decl_macro, macros_in_extern)] - -macro_rules! returns_isize( - ($ident:ident) => ( - fn $ident() -> isize; - ) -); - -macro takes_u32_returns_u32($ident:ident) { - fn $ident (arg: u32) -> u32; -} - -macro_rules! emits_nothing( - () => () -); - -fn main() { - assert_eq!(unsafe { rust_get_test_int() }, 1isize); - assert_eq!(unsafe { rust_dbg_extern_identity_u32(0xDEADBEEF) }, 0xDEADBEEFu32); -} - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - returns_isize!(rust_get_test_int); - takes_u32_returns_u32!(rust_dbg_extern_identity_u32); - emits_nothing!(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-stability.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-stability.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-stability.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-stability.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:unstable-macros.rs - -#![feature(unstable_macros)] - -#[macro_use] extern crate unstable_macros; - -#[unstable(feature = "local_unstable", issue = "0")] -macro_rules! local_unstable { () => () } - -fn main() { - unstable_macro!(); - local_unstable!(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-stmt_macro_in_expr_macro.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-stmt_macro_in_expr_macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-stmt_macro_in_expr_macro.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-stmt_macro_in_expr_macro.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! foo { - () => { - struct Bar; - struct Baz; - } -} - -macro_rules! grault { - () => {{ - foo!(); - struct Xyzzy; - 0 - }} -} - -fn main() { - let x = grault!(); - assert_eq!(x, 0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-stmt.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-stmt.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-stmt.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-stmt.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! myfn { - ( $f:ident, ( $( $x:ident ),* ), $body:block ) => ( - fn $f( $( $x : isize),* ) -> isize $body - ) -} - -myfn!(add, (a,b), { return a+b; } ); - -pub fn main() { - - macro_rules! mylet { - ($x:ident, $val:expr) => ( - let $x = $val; - ) - } - - mylet!(y, 8*2); - assert_eq!(y, 16); - - myfn!(mult, (a,b), { a*b } ); - - assert_eq!(mult(2, add(4,4)), 16); - - macro_rules! actually_an_expr_macro { - () => ( 16 ) - } - - assert_eq!({ actually_an_expr_macro!() }, 16); - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-tt-followed-by-seq.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-tt-followed-by-seq.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-tt-followed-by-seq.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-tt-followed-by-seq.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for issue #25436: permit token-trees to be followed -// by sequences, enabling more general parsing. - -use self::Join::*; - -#[derive(Debug)] -enum Join { - Keep(A,B), - Skip(A,B), -} - -macro_rules! parse_list { - ( < $a:expr; > $($b:tt)* ) => { Keep(parse_item!($a),parse_list!($($b)*)) }; - ( $a:tt $($b:tt)* ) => { Skip(parse_item!($a), parse_list!($($b)*)) }; - ( ) => { () }; -} - -macro_rules! parse_item { - ( $x:expr ) => { $x } -} - -fn main() { - let list = parse_list!(<1;> 2 <3;> 4); - assert_eq!("Keep(1, Skip(2, Keep(3, Skip(4, ()))))", - format!("{:?}", list)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-use-all-and-none.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-use-all-and-none.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-use-all-and-none.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-use-all-and-none.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:two_macros.rs - -#[macro_use] -#[macro_use()] -extern crate two_macros; - -pub fn main() { - macro_one!(); - macro_two!(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-use-all.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-use-all.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-use-all.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-use-all.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:two_macros.rs - -#[macro_use] -extern crate two_macros; - -pub fn main() { - macro_one!(); - macro_two!(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-use-both.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-use-both.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-use-both.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-use-both.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:two_macros.rs - -#[macro_use(macro_one, macro_two)] -extern crate two_macros; - -pub fn main() { - macro_one!(); - macro_two!(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-use-one.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-use-one.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-use-one.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-use-one.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:two_macros.rs - -#[macro_use(macro_two)] -extern crate two_macros; - -pub fn main() { - macro_two!(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-with-attrs1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-with-attrs1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-with-attrs1.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-with-attrs1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: --cfg foo - - -#[cfg(foo)] -macro_rules! foo { () => (1) } - -#[cfg(not(foo))] -macro_rules! foo { () => (2) } - -pub fn main() { - assert_eq!(foo!(), 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-with-attrs2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-with-attrs2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-with-attrs2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-with-attrs2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#[cfg(foo)] -macro_rules! foo { () => (1) } - -#[cfg(not(foo))] -macro_rules! foo { () => (2) } - -pub fn main() { - assert_eq!(foo!(), 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-with-braces-in-expr-position.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-with-braces-in-expr-position.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-with-braces-in-expr-position.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro-with-braces-in-expr-position.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::thread; - -macro_rules! expr { ($e: expr) => { $e } } - -macro_rules! spawn { - ($($code: tt)*) => { - expr!(thread::spawn(move|| {$($code)*}).join()) - } -} - -pub fn main() { - spawn! { - println!("stmt"); - }; - let _ = spawn! { - println!("expr"); - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro_with_super_2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro_with_super_2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro_with_super_2.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/macro_with_super_2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:macro_with_super_1.rs - -// pretty-expanded FIXME #23616 - -#[macro_use] -extern crate macro_with_super_1; - -declare!(); - -fn main() { - bbb::ccc(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/parse-complex-macro-invoc-op.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/parse-complex-macro-invoc-op.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/parse-complex-macro-invoc-op.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/parse-complex-macro-invoc-op.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -// Test parsing binary operators after macro invocations. - -// pretty-expanded FIXME #23616 - -#![feature(macro_rules)] - -macro_rules! id { - ($e: expr) => { $e } -} - -fn foo() { - id!(1) + 1; - id![1] - 1; - id!(1) * 1; - id![1] / 1; - id!(1) % 1; - - id!(1) & 1; - id![1] | 1; - id!(1) ^ 1; - - let mut x = 1; - id![x] = 2; - id!(x) += 1; - - id!(1f64).clone(); - - id!([1, 2, 3])[1]; - id![drop](1); - - id!(true) && true; - id![true] || true; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/paths-in-macro-invocations.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/paths-in-macro-invocations.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/paths-in-macro-invocations.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/paths-in-macro-invocations.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:two_macros.rs - -extern crate two_macros; - -::two_macros::macro_one!(); -two_macros::macro_one!(); - -mod foo { pub use two_macros::macro_one as bar; } - -trait T { - foo::bar!(); - ::foo::bar!(); -} - -struct S { - x: foo::bar!(i32), - y: ::foo::bar!(i32), -} - -impl S { - foo::bar!(); - ::foo::bar!(); -} - -fn main() { - foo::bar!(); - ::foo::bar!(); - - let _ = foo::bar!(0); - let _ = ::foo::bar!(0); - - let foo::bar!(_) = 0; - let ::foo::bar!(_) = 0; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/pub-item-inside-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/pub-item-inside-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/pub-item-inside-macro.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/pub-item-inside-macro.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #14660 - -// pretty-expanded FIXME #23616 - -mod bleh { - macro_rules! foo { - () => { - pub fn bar() { } - } - } - - foo!(); -} - -fn main() { - bleh::bar(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/pub-method-inside-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/pub-method-inside-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/pub-method-inside-macro.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/pub-method-inside-macro.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #17436 - -// pretty-expanded FIXME #23616 - -mod bleh { - macro_rules! foo { - () => { - pub fn bar(&self) { } - } - } - - pub struct S; - - impl S { - foo!(); - } -} - -fn main() { - bleh::S.bar(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/semi-after-macro-ty.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/semi-after-macro-ty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/semi-after-macro-ty.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/semi-after-macro-ty.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! foo { - ($t:ty; $p:path;) => {} -} - -fn main() { - foo!(i32; i32;); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/stmt_expr_attr_macro_parse.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/stmt_expr_attr_macro_parse.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/stmt_expr_attr_macro_parse.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/stmt_expr_attr_macro_parse.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! m { - ($e:expr) => { - "expr includes attr" - }; - (#[$attr:meta] $e:expr) => { - "expr excludes attr" - } -} - -macro_rules! n { - (#[$attr:meta] $e:expr) => { - "expr excludes attr" - }; - ($e:expr) => { - "expr includes attr" - } -} - -fn main() { - assert_eq!(m!(#[attr] 1), "expr includes attr"); - assert_eq!(n!(#[attr] 1), "expr excludes attr"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/syntax-extension-cfg.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/syntax-extension-cfg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/syntax-extension-cfg.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/syntax-extension-cfg.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: --cfg foo --cfg qux="foo" - - -pub fn main() { - // check - if ! cfg!(foo) { panic!() } - if cfg!(not(foo)) { panic!() } - - if ! cfg!(qux="foo") { panic!() } - if cfg!(not(qux="foo")) { panic!() } - - if ! cfg!(all(foo, qux="foo")) { panic!() } - if cfg!(not(all(foo, qux="foo"))) { panic!() } - if cfg!(all(not(all(foo, qux="foo")))) { panic!() } - - if cfg!(not_a_cfg) { panic!() } - if cfg!(all(not_a_cfg, foo, qux="foo")) { panic!() } - if cfg!(all(not_a_cfg, foo, qux="foo")) { panic!() } - if ! cfg!(any(not_a_cfg, foo)) { panic!() } - - if ! cfg!(not(not_a_cfg)) { panic!() } - if ! cfg!(all(not(not_a_cfg), foo, qux="foo")) { panic!() } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/syntax-extension-source-utils-files/includeme.fragment rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/syntax-extension-source-utils-files/includeme.fragment --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/syntax-extension-source-utils-files/includeme.fragment 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/syntax-extension-source-utils-files/includeme.fragment 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -/* this is for run-pass/syntax-extension-source-utils.rs */ - -{ - assert!(file!().ends_with("includeme.fragment")); - assert_eq!(line!(), 5u32); - format!("victory robot {}", line!()) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/syntax-extension-source-utils.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/syntax-extension-source-utils.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/syntax-extension-source-utils.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/syntax-extension-source-utils.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// Copyright 2012-2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -// ignore-pretty issue #37195 - -pub mod m1 { - pub mod m2 { - pub fn where_am_i() -> String { - (module_path!()).to_string() - } - } -} - -macro_rules! indirect_line { () => ( line!() ) } - -pub fn main() { - assert_eq!(line!(), 27); - assert_eq!(column!(), 16); - assert_eq!(indirect_line!(), 29); - assert!((file!().ends_with("syntax-extension-source-utils.rs"))); - assert_eq!(stringify!((2*3) + 5).to_string(), "( 2 * 3 ) + 5".to_string()); - assert!(include!("syntax-extension-source-utils-files/includeme.\ - fragment").to_string() - == "victory robot 6".to_string()); - - assert!( - include_str!("syntax-extension-source-utils-files/includeme.\ - fragment").to_string() - .starts_with("/* this is for ")); - assert!( - include_bytes!("syntax-extension-source-utils-files/includeme.fragment") - [1] == (42 as u8)); // '*' - // The Windows tests are wrapped in an extra module for some reason - assert!((m1::m2::where_am_i().ends_with("m1::m2"))); - - assert_eq!((46, "( 2 * 3 ) + 5"), (line!(), stringify!((2*3) + 5))); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/try-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/try-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/try-macro.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/try-macro.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::num::{ParseFloatError, ParseIntError}; - -fn main() { - assert_eq!(simple(), Ok(1)); - assert_eq!(nested(), Ok(2)); - assert_eq!(merge_ok(), Ok(3.0)); - assert_eq!(merge_int_err(), Err(Error::Int)); - assert_eq!(merge_float_err(), Err(Error::Float)); -} - -fn simple() -> Result { - Ok(try!("1".parse())) -} - -fn nested() -> Result { - Ok(try!(try!("2".parse::()).to_string().parse::())) -} - -fn merge_ok() -> Result { - Ok(try!("1".parse::()) as f32 + try!("2.0".parse::())) -} - -fn merge_int_err() -> Result { - Ok(try!("a".parse::()) as f32 + try!("2.0".parse::())) -} - -fn merge_float_err() -> Result { - Ok(try!("1".parse::()) as f32 + try!("b".parse::())) -} - -#[derive(Debug, PartialEq)] -enum Error { - Int, - Float, -} - -impl From for Error { - fn from(_: ParseIntError) -> Error { - Error::Int - } -} - -impl From for Error { - fn from(_: ParseFloatError) -> Error { - Error::Float - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/two-macro-use.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/two-macro-use.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/two-macro-use.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/two-macro-use.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:two_macros.rs - -#[macro_use(macro_one)] -#[macro_use(macro_two)] -extern crate two_macros; - -pub fn main() { - macro_one!(); - macro_two!(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/typeck-macro-interaction-issue-8852.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/typeck-macro-interaction-issue-8852.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/typeck-macro-interaction-issue-8852.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/typeck-macro-interaction-issue-8852.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum T { - A(isize), - B(f64) -} - -// after fixing #9384 and implementing hygiene for match bindings, -// this now fails because the insertion of the 'y' into the match -// doesn't cause capture. Making this macro hygienic (as I've done) -// could very well make this test case completely pointless.... - -macro_rules! test { - ($id1:ident, $id2:ident, $e:expr) => ( - fn foo(a:T, b:T) -> T { - match (a, b) { - (T::A($id1), T::A($id2)) => T::A($e), - (T::B($id1), T::B($id2)) => T::B($e), - _ => panic!() - } - } - ) -} - -test!(x,y,x + y); - -pub fn main() { - foo(T::A(1), T::A(2)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/type-macros-hlist.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/type-macros-hlist.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/type-macros-hlist.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/type-macros-hlist.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::ops::*; - -#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] -struct Nil; - // empty HList -#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] -struct Cons(H, T); - // cons cell of HList - - // trait to classify valid HLists -trait HList { } -impl HList for Nil { } -impl HList for Cons { } - -// term-level macro for HLists -macro_rules! hlist({ } => { Nil } ; { $ head : expr } => { - Cons ( $ head , Nil ) } ; { - $ head : expr , $ ( $ tail : expr ) , * } => { - Cons ( $ head , hlist ! ( $ ( $ tail ) , * ) ) } ;); - -// type-level macro for HLists -macro_rules! HList({ } => { Nil } ; { $ head : ty } => { - Cons < $ head , Nil > } ; { - $ head : ty , $ ( $ tail : ty ) , * } => { - Cons < $ head , HList ! ( $ ( $ tail ) , * ) > } ;); - -// nil case for HList append -impl Add for Nil { - type - Output - = - Ys; - - fn add(self, rhs: Ys) -> Ys { rhs } -} - -// cons case for HList append -impl Add for Cons - where Xs: Add { - type - Output - = - Cons; - - fn add(self, rhs: Ys) -> Cons { Cons(self.0, self.1 + rhs) } -} - -// type macro Expr allows us to expand the + operator appropriately -macro_rules! Expr({ ( $ ( $ LHS : tt ) + ) } => { Expr ! ( $ ( $ LHS ) + ) } ; - { HList ! [ $ ( $ LHS : tt ) * ] + $ ( $ RHS : tt ) + } => { - < Expr ! ( HList ! [ $ ( $ LHS ) * ] ) as Add < Expr ! ( - $ ( $ RHS ) + ) >> :: Output } ; { - $ LHS : tt + $ ( $ RHS : tt ) + } => { - < Expr ! ( $ LHS ) as Add < Expr ! ( $ ( $ RHS ) + ) >> :: - Output } ; { $ LHS : ty } => { $ LHS } ;); - -// test demonstrating term level `xs + ys` and type level `Expr!(Xs + Ys)` -fn main() { - fn aux(xs: Xs, ys: Ys) -> Expr!(Xs + Ys) where - Xs: Add { - xs + ys - } - - let xs: HList!(& str , bool , Vec < u64 >) = - hlist!("foo" , false , vec ! [ ]); - let ys: HList!(u64 , [ u8 ; 3 ] , ( )) = - hlist!(0 , [ 0 , 1 , 2 ] , ( )); - - // demonstrate recursive expansion of Expr! - let zs: - Expr!(( - HList ! [ & str ] + HList ! [ bool ] + HList ! [ Vec < u64 > - ] ) + ( HList ! [ u64 ] + HList ! [ [ u8 ; 3 ] , ( ) ] ) + - HList ! [ ]) = aux(xs, ys); - assert_eq!(zs , hlist ! [ - "foo" , false , vec ! [ ] , 0 , [ 0 , 1 , 2 ] , ( ) ]) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/type-macros-simple.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/type-macros-simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/type-macros-simple.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/type-macros-simple.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -macro_rules! Tuple { - { $A:ty,$B:ty } => { ($A, $B) } -} - -fn main() { - let x: Tuple!(i32, i32) = (1, 2); -} - -fn issue_36540() { - let i32 = 0; - macro_rules! m { () => { i32 } } - struct S(m!(), T) where T: Trait; - - let x: m!() = m!(); - std::cell::Cell::::new(m!()); - impl std::ops::Index for Trait<(m!(), T)> - where T: Trait - { - type Output = m!(); - fn index(&self, i: m!()) -> &m!() { - unimplemented!() - } - } -} - -trait Trait {} -impl Trait for i32 {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/use-macro-self.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/use-macro-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/macros/use-macro-self.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/macros/use-macro-self.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:use-macro-self.rs - -#[macro_use] -extern crate use_macro_self; - -use use_macro_self::foobarius::{self}; - -fn main() { - let _: () = foobarius!(); // OK, the macro returns `()` -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/auxiliary/method_self_arg1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/auxiliary/method_self_arg1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/auxiliary/method_self_arg1.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/auxiliary/method_self_arg1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -#![feature(box_syntax)] - -static mut COUNT: u64 = 1; - -pub fn get_count() -> u64 { unsafe { COUNT } } - -#[derive(Copy, Clone)] -pub struct Foo; - -impl Foo { - pub fn foo(self, x: &Foo) { - unsafe { COUNT *= 2; } - // Test internal call. - Foo::bar(&self); - Foo::bar(x); - - Foo::baz(self); - Foo::baz(*x); - - Foo::qux(box self); - Foo::qux(box *x); - } - - pub fn bar(&self) { - unsafe { COUNT *= 3; } - } - - pub fn baz(self) { - unsafe { COUNT *= 5; } - } - - pub fn qux(self: Box) { - unsafe { COUNT *= 7; } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/auxiliary/method_self_arg2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/auxiliary/method_self_arg2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/auxiliary/method_self_arg2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/auxiliary/method_self_arg2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -#![feature(box_syntax)] - -static mut COUNT: u64 = 1; - -pub fn get_count() -> u64 { unsafe { COUNT } } - -#[derive(Copy, Clone)] -pub struct Foo; - -impl Foo { - pub fn run_trait(self) { - unsafe { COUNT *= 17; } - // Test internal call. - Bar::foo1(&self); - Bar::foo2(self); - Bar::foo3(box self); - - Bar::bar1(&self); - Bar::bar2(self); - Bar::bar3(box self); - } -} - -pub trait Bar : Sized { - fn foo1(&self); - fn foo2(self); - fn foo3(self: Box); - - fn bar1(&self) { - unsafe { COUNT *= 7; } - } - fn bar2(self) { - unsafe { COUNT *= 11; } - } - fn bar3(self: Box) { - unsafe { COUNT *= 13; } - } -} - -impl Bar for Foo { - fn foo1(&self) { - unsafe { COUNT *= 2; } - } - - fn foo2(self) { - unsafe { COUNT *= 3; } - } - - fn foo3(self: Box) { - unsafe { COUNT *= 5; } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-argument-inference-associated-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-argument-inference-associated-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-argument-inference-associated-type.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-argument-inference-associated-type.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub struct ClientMap; -pub struct ClientMap2; - -pub trait Service { - type Request; - fn call(&self, _req: Self::Request); -} - -pub struct S(T); - -impl Service for ClientMap { - type Request = S>; - fn call(&self, _req: Self::Request) {} -} - - -impl Service for ClientMap2 { - type Request = (Box,); - fn call(&self, _req: Self::Request) {} -} - - -fn main() { - ClientMap.call(S { 0: Box::new(|_msgid| ()) }); - ClientMap.call(S(Box::new(|_msgid| ()))); - ClientMap2.call((Box::new(|_msgid| ()),)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-attributes.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-attributes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-attributes.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-attributes.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pp-exact - Make sure we print all the attributes -// pretty-expanded FIXME #23616 - -#![feature(custom_attribute)] - -#[frobable] -trait frobable { - #[frob_attr] - fn frob(&self); - #[defrob_attr] - fn defrob(&self); -} - -#[int_frobable] -impl frobable for isize { - #[frob_attr1] - fn frob(&self) { - #![frob_attr2] - } - - #[defrob_attr1] - fn defrob(&self) { - #![defrob_attr2] - } -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-early-bound-lifetimes-on-self.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-early-bound-lifetimes-on-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-early-bound-lifetimes-on-self.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-early-bound-lifetimes-on-self.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check that we successfully handle methods where the `self` type has -// an early-bound lifetime. Issue #18208. - -// pretty-expanded FIXME #23616 - -#![allow(dead_code)] - -use std::marker; - -struct Cursor<'a> { - m: marker::PhantomData<&'a ()> -} - -trait CursorNavigator { - fn init_cursor<'a, 'b:'a>(&'a self, cursor: &mut Cursor<'b>) -> bool; -} - -struct SimpleNavigator; - -impl CursorNavigator for SimpleNavigator { - fn init_cursor<'a, 'b: 'a>(&'a self, _cursor: &mut Cursor<'b>) -> bool { - false - } -} - -fn main() { - let mut c = Cursor { m: marker::PhantomData }; - let n = SimpleNavigator; - n.init_cursor(&mut c); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-mut-self-modifies-mut-slice-lvalue.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-mut-self-modifies-mut-slice-lvalue.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-mut-self-modifies-mut-slice-lvalue.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-mut-self-modifies-mut-slice-lvalue.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that an `&mut self` method, when invoked on a place whose -// type is `&mut [u8]`, passes in a pointer to the place and not a -// temporary. Issue #19147. - -use std::slice; -use std::cmp; - -trait MyWriter { - fn my_write(&mut self, buf: &[u8]) -> Result<(), ()>; -} - -impl<'a> MyWriter for &'a mut [u8] { - fn my_write(&mut self, buf: &[u8]) -> Result<(), ()> { - let amt = cmp::min(self.len(), buf.len()); - self[..amt].clone_from_slice(&buf[..amt]); - - let write_len = buf.len(); - unsafe { - *self = slice::from_raw_parts_mut( - self.as_mut_ptr().add(write_len), - self.len() - write_len - ); - } - - Ok(()) - } -} - -fn main() { - let mut buf = [0; 6]; - - { - let mut writer: &mut [_] = &mut buf; - writer.my_write(&[0, 1, 2]).unwrap(); - writer.my_write(&[3, 4, 5]).unwrap(); - } - - // If `my_write` is not modifying `buf` in place, then we will - // wind up with `[3, 4, 5, 0, 0, 0]` because the first call to - // `my_write()` doesn't update the starting point for the write. - - assert_eq!(buf, [0, 1, 2, 3, 4, 5]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-normalize-bounds-issue-20604.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-normalize-bounds-issue-20604.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-normalize-bounds-issue-20604.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-normalize-bounds-issue-20604.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -// Test that we handle projection types which wind up important for -// resolving methods. This test was reduced from a larger example; the -// call to `foo()` at the end was failing to resolve because the -// winnowing stage of method resolution failed to handle an associated -// type projection. - -// pretty-expanded FIXME #23616 - -#![feature(associated_types)] - -trait Hasher { - type Output; - fn finish(&self) -> Self::Output; -} - -trait Hash { - fn hash(&self, h: &mut H); -} - -trait HashState { - type Wut: Hasher; - fn hasher(&self) -> Self::Wut; -} - -struct SipHasher; -impl Hasher for SipHasher { - type Output = u64; - fn finish(&self) -> u64 { 4 } -} - -impl Hash for isize { - fn hash(&self, h: &mut SipHasher) {} -} - -struct SipState; -impl HashState for SipState { - type Wut = SipHasher; - fn hasher(&self) -> SipHasher { SipHasher } -} - -struct Map { - s: S, -} - -impl Map - where S: HashState, - ::Wut: Hasher, -{ - fn foo(&self, k: K) where K: Hash< ::Wut> {} -} - -fn foo>(map: &Map) { - map.foo(22); -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-projection.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-projection.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-projection.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-projection.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we can use method notation to call methods based on a -// projection bound from a trait. Issue #20469. - -/////////////////////////////////////////////////////////////////////////// - - -trait MakeString { - fn make_string(&self) -> String; -} - -impl MakeString for isize { - fn make_string(&self) -> String { - format!("{}", *self) - } -} - -impl MakeString for usize { - fn make_string(&self) -> String { - format!("{}", *self) - } -} - -/////////////////////////////////////////////////////////////////////////// - -trait Foo { - type F: MakeString; - - fn get(&self) -> &Self::F; -} - -fn foo(f: &F) -> String { - f.get().make_string() -} - -/////////////////////////////////////////////////////////////////////////// - -struct SomeStruct { - field: isize, -} - -impl Foo for SomeStruct { - type F = isize; - - fn get(&self) -> &isize { - &self.field - } -} - -/////////////////////////////////////////////////////////////////////////// - -struct SomeOtherStruct { - field: usize, -} - -impl Foo for SomeOtherStruct { - type F = usize; - - fn get(&self) -> &usize { - &self.field - } -} - -fn main() { - let x = SomeStruct { field: 22 }; - assert_eq!(foo(&x), format!("22")); - - let x = SomeOtherStruct { field: 44 }; - assert_eq!(foo(&x), format!("44")); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-recursive-blanket-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-recursive-blanket-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-recursive-blanket-impl.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-recursive-blanket-impl.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we don't trigger on the blanket impl for all `&'a T` but -// rather keep autoderefing and trigger on the underlying impl. To -// know not to stop at the blanket, we have to recursively evaluate -// the `T:Foo` bound. - -// pretty-expanded FIXME #23616 - -use std::marker::Sized; - -// Note: this must be generic for the problem to show up -trait Foo { - fn foo(&self, a: A); -} - -impl Foo for [u8] { - fn foo(&self, a: u8) {} -} - -impl<'a, A, T> Foo for &'a T where T: Foo { - fn foo(&self, a: A) { - Foo::foo(*self, a) - } -} - -trait Bar { - fn foo(&self); -} - -struct MyType; - -impl Bar for MyType { - fn foo(&self) {} -} - -fn main() { - let mut m = MyType; - (&mut m).foo() -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-self-arg-aux1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-self-arg-aux1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-self-arg-aux1.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-self-arg-aux1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test method calls with self as an argument (cross-crate) - -#![feature(box_syntax)] - -// aux-build:method_self_arg1.rs -extern crate method_self_arg1; -use method_self_arg1::Foo; - -fn main() { - let x = Foo; - // Test external call. - Foo::bar(&x); - Foo::baz(x); - Foo::qux(box x); - - x.foo(&x); - - assert_eq!(method_self_arg1::get_count(), 2*3*3*3*5*5*5*7*7*7); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-self-arg-aux2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-self-arg-aux2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-self-arg-aux2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-self-arg-aux2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test method calls with self as an argument (cross-crate) - -#![feature(box_syntax)] - -// aux-build:method_self_arg2.rs -extern crate method_self_arg2; -use method_self_arg2::{Foo, Bar}; - -fn main() { - let x = Foo; - // Test external call. - Bar::foo1(&x); - Bar::foo2(x); - Bar::foo3(box x); - - Bar::bar1(&x); - Bar::bar2(x); - Bar::bar3(box x); - - x.run_trait(); - - assert_eq!(method_self_arg2::get_count(), 2*2*3*3*5*5*7*7*11*11*13*13*17); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-self-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-self-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-self-arg.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-self-arg.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test method calls with self as an argument - -#![feature(box_syntax)] - -static mut COUNT: usize = 1; - -#[derive(Copy, Clone)] -struct Foo; - -impl Foo { - fn foo(self, x: &Foo) { - unsafe { COUNT *= 2; } - // Test internal call. - Foo::bar(&self); - Foo::bar(x); - - Foo::baz(self); - Foo::baz(*x); - - Foo::qux(box self); - Foo::qux(box *x); - } - - fn bar(&self) { - unsafe { COUNT *= 3; } - } - - fn baz(self) { - unsafe { COUNT *= 5; } - } - - fn qux(self: Box) { - unsafe { COUNT *= 7; } - } -} - -fn main() { - let x = Foo; - // Test external call. - Foo::bar(&x); - Foo::baz(x); - Foo::qux(box x); - - x.foo(&x); - - unsafe { assert_eq!(COUNT, 2*3*3*3*5*5*5*7*7*7); } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-self-arg-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-self-arg-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-self-arg-trait.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-self-arg-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test method calls with self as an argument - -#![feature(box_syntax)] - -static mut COUNT: u64 = 1; - -#[derive(Copy, Clone)] -struct Foo; - -trait Bar : Sized { - fn foo1(&self); - fn foo2(self); - fn foo3(self: Box); - - fn bar1(&self) { - unsafe { COUNT *= 7; } - } - fn bar2(self) { - unsafe { COUNT *= 11; } - } - fn bar3(self: Box) { - unsafe { COUNT *= 13; } - } -} - -impl Bar for Foo { - fn foo1(&self) { - unsafe { COUNT *= 2; } - } - - fn foo2(self) { - unsafe { COUNT *= 3; } - } - - fn foo3(self: Box) { - unsafe { COUNT *= 5; } - } -} - -impl Foo { - fn baz(self) { - unsafe { COUNT *= 17; } - // Test internal call. - Bar::foo1(&self); - Bar::foo2(self); - Bar::foo3(box self); - - Bar::bar1(&self); - Bar::bar2(self); - Bar::bar3(box self); - } -} - -fn main() { - let x = Foo; - // Test external call. - Bar::foo1(&x); - Bar::foo2(x); - Bar::foo3(box x); - - Bar::bar1(&x); - Bar::bar2(x); - Bar::bar3(box x); - - x.baz(); - - unsafe { assert_eq!(COUNT, 2*2*3*3*5*5*7*7*11*11*13*13*17); } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-two-trait-defer-resolution-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-two-trait-defer-resolution-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-two-trait-defer-resolution-1.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-two-trait-defer-resolution-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// Test that we pick which version of `foo` to run based on the -// type that is (ultimately) inferred for `x`. - - -trait foo { - fn foo(&self) -> i32; -} - -impl foo for Vec { - fn foo(&self) -> i32 {1} -} - -impl foo for Vec { - fn foo(&self) -> i32 {2} -} - -fn call_foo_uint() -> i32 { - let mut x = Vec::new(); - let y = x.foo(); - x.push(0u32); - y -} - -fn call_foo_int() -> i32 { - let mut x = Vec::new(); - let y = x.foo(); - x.push(0i32); - y -} - -fn main() { - assert_eq!(call_foo_uint(), 1); - assert_eq!(call_foo_int(), 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-two-trait-defer-resolution-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-two-trait-defer-resolution-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-two-trait-defer-resolution-2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-two-trait-defer-resolution-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that when we write `x.foo()`, we do not have to know the -// complete type of `x` in order to type-check the method call. In -// this case, we know that `x: Vec<_1>`, but we don't know what type -// `_1` is (because the call to `push` comes later). To pick between -// the impls, we would have to know `_1`, since we have to know -// whether `_1: MyCopy` or `_1 == Box`. However (and this is the -// point of the test), we don't have to pick between the two impls -- -// it is enough to know that `foo` comes from the `Foo` trait. We can -// codegen the call as `Foo::foo(&x)` and let the specific impl get -// chosen later. - -#![feature(box_syntax)] - -trait Foo { - fn foo(&self) -> isize; -} - -trait MyCopy { fn foo(&self) { } } -impl MyCopy for i32 { } - -impl Foo for Vec { - fn foo(&self) -> isize {1} -} - -impl Foo for Vec> { - fn foo(&self) -> isize {2} -} - -fn call_foo_copy() -> isize { - let mut x = Vec::new(); - let y = x.foo(); - x.push(0_i32); - y -} - -fn call_foo_other() -> isize { - let mut x: Vec<_> = Vec::new(); - let y = x.foo(); - let z: Box = box 0; - x.push(z); - y -} - -fn main() { - assert_eq!(call_foo_copy(), 1); - assert_eq!(call_foo_other(), 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-two-traits-distinguished-via-where-clause.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-two-traits-distinguished-via-where-clause.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-two-traits-distinguished-via-where-clause.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-two-traits-distinguished-via-where-clause.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we select between traits A and B. To do that, we must -// consider the `Sized` bound. - -// pretty-expanded FIXME #23616 - -trait A { - fn foo(self); -} - -trait B { - fn foo(self); -} - -impl A for *const T { - fn foo(self) {} -} - -impl B for *const [T] { - fn foo(self) {} -} - -fn main() { - let x: [isize; 4] = [1,2,3,4]; - let xptr = &x[..] as *const [isize]; - xptr.foo(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-where-clause.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-where-clause.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-where-clause.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/methods/method-where-clause.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we can use method notation to call methods based on a -// where clause type, and not only type parameters. - - -trait Foo { - fn foo(&self) -> i32; -} - -impl Foo for Option -{ - fn foo(&self) -> i32 { - self.unwrap_or(22) - } -} - -impl Foo for Option -{ - fn foo(&self) -> i32 { - self.unwrap_or(22) as i32 - } -} - -fn check(x: Option) -> (i32, i32) - where Option : Foo -{ - let y: Option = None; - (x.foo(), y.foo()) -} - -fn main() { - assert_eq!(check(Some(23u32)), (23, 22)); - assert_eq!(check(Some(23)), (23, 22)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/auxiliary/mir_external_refs.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/auxiliary/mir_external_refs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/auxiliary/mir_external_refs.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/auxiliary/mir_external_refs.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -pub struct S(pub u8); - -impl S { - pub fn hey() -> u8 { 24 } -} - -pub trait X { - fn hoy(&self) -> u8 { 25 } -} - -impl X for S {} - -pub enum E { - U(u8) -} - -pub fn regular_fn() -> u8 { 12 } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_adt_construction.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_adt_construction.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_adt_construction.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_adt_construction.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::fmt; - -#[repr(C)] -enum CEnum { - Hello = 30, - World = 60 -} - -fn test1(c: CEnum) -> i32 { - let c2 = CEnum::Hello; - match (c, c2) { - (CEnum::Hello, CEnum::Hello) => 42, - (CEnum::World, CEnum::Hello) => 0, - _ => 1 - } -} - -#[repr(packed)] -struct Pakd { - a: u64, - b: u32, - c: u16, - d: u8, - e: () -} - -// It is unsafe to use #[derive(Debug)] on a packed struct because the code generated by the derive -// macro takes references to the fields instead of accessing them directly. -impl fmt::Debug for Pakd { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - // It's important that we load the fields into locals by-value here. This will do safe - // unaligned loads into the locals, then pass references to the properly-aligned locals to - // the formatting code. - let Pakd { a, b, c, d, e } = *self; - f.debug_struct("Pakd") - .field("a", &a) - .field("b", &b) - .field("c", &c) - .field("d", &d) - .field("e", &e) - .finish() - } -} - -// It is unsafe to use #[derive(PartialEq)] on a packed struct because the code generated by the -// derive macro takes references to the fields instead of accessing them directly. -impl PartialEq for Pakd { - fn eq(&self, other: &Pakd) -> bool { - self.a == other.a && - self.b == other.b && - self.c == other.c && - self.d == other.d && - self.e == other.e - } -} - -impl Drop for Pakd { - fn drop(&mut self) {} -} - -fn test2() -> Pakd { - Pakd { a: 42, b: 42, c: 42, d: 42, e: () } -} - -#[derive(PartialEq, Debug)] -struct TupleLike(u64, u32); - -fn test3() -> TupleLike { - TupleLike(42, 42) -} - -fn test4(x: fn(u64, u32) -> TupleLike) -> (TupleLike, TupleLike) { - let y = TupleLike; - (x(42, 84), y(42, 84)) -} - -fn test5(x: fn(u32) -> Option) -> (Option, Option) { - let y = Some; - (x(42), y(42)) -} - -fn main() { - assert_eq!(test1(CEnum::Hello), 42); - assert_eq!(test1(CEnum::World), 0); - assert_eq!(test2(), Pakd { a: 42, b: 42, c: 42, d: 42, e: () }); - assert_eq!(test3(), TupleLike(42, 42)); - let t4 = test4(TupleLike); - assert_eq!(t4.0, t4.1); - let t5 = test5(Some); - assert_eq!(t5.0, t5.1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_ascription_coercion.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_ascription_coercion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_ascription_coercion.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_ascription_coercion.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests that the result of type ascription has adjustments applied - -#![feature(type_ascription)] - -fn main() { - let x = [1, 2, 3]; - // The RHS should coerce to &[i32] - let _y : &[i32] = &x : &[i32; 3]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_augmented_assignments.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_augmented_assignments.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_augmented_assignments.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_augmented_assignments.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,170 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::mem; -use std::ops::{ - AddAssign, BitAndAssign, BitOrAssign, BitXorAssign, DivAssign, MulAssign, RemAssign, - ShlAssign, ShrAssign, SubAssign, -}; - -#[derive(Debug, PartialEq)] -struct Int(i32); - -struct Slice([i32]); - -impl Slice { - fn new(slice: &mut [i32]) -> &mut Slice { - unsafe { - mem::transmute(slice) - } - } -} - -fn main() { - main_mir(); -} - -fn main_mir() { - let mut x = Int(1); - - x += Int(2); - assert_eq!(x, Int(0b11)); - - x &= Int(0b01); - assert_eq!(x, Int(0b01)); - - x |= Int(0b10); - assert_eq!(x, Int(0b11)); - - x ^= Int(0b01); - assert_eq!(x, Int(0b10)); - - x /= Int(2); - assert_eq!(x, Int(1)); - - x *= Int(3); - assert_eq!(x, Int(3)); - - x %= Int(2); - assert_eq!(x, Int(1)); - - // overloaded RHS - x <<= 1u8; - assert_eq!(x, Int(2)); - - x <<= 1u16; - assert_eq!(x, Int(4)); - - x >>= 1u8; - assert_eq!(x, Int(2)); - - x >>= 1u16; - assert_eq!(x, Int(1)); - - x -= Int(1); - assert_eq!(x, Int(0)); - - // indexed LHS - // FIXME(mir-drop): use the vec![..] macro - let mut v = Vec::new(); - v.push(Int(1)); - v.push(Int(2)); - v[0] += Int(2); - assert_eq!(v[0], Int(3)); - - // unsized RHS - let mut array = [0, 1, 2]; - *Slice::new(&mut array) += 1; - assert_eq!(array[0], 1); - assert_eq!(array[1], 2); - assert_eq!(array[2], 3); - -} - -impl AddAssign for Int { - fn add_assign(&mut self, rhs: Int) { - self.0 += rhs.0; - } -} - -impl BitAndAssign for Int { - fn bitand_assign(&mut self, rhs: Int) { - self.0 &= rhs.0; - } -} - -impl BitOrAssign for Int { - fn bitor_assign(&mut self, rhs: Int) { - self.0 |= rhs.0; - } -} - -impl BitXorAssign for Int { - fn bitxor_assign(&mut self, rhs: Int) { - self.0 ^= rhs.0; - } -} - -impl DivAssign for Int { - fn div_assign(&mut self, rhs: Int) { - self.0 /= rhs.0; - } -} - -impl MulAssign for Int { - fn mul_assign(&mut self, rhs: Int) { - self.0 *= rhs.0; - } -} - -impl RemAssign for Int { - fn rem_assign(&mut self, rhs: Int) { - self.0 %= rhs.0; - } -} - -impl ShlAssign for Int { - fn shl_assign(&mut self, rhs: u8) { - self.0 <<= rhs; - } -} - -impl ShlAssign for Int { - fn shl_assign(&mut self, rhs: u16) { - self.0 <<= rhs; - } -} - -impl ShrAssign for Int { - fn shr_assign(&mut self, rhs: u8) { - self.0 >>= rhs; - } -} - -impl ShrAssign for Int { - fn shr_assign(&mut self, rhs: u16) { - self.0 >>= rhs; - } -} - -impl SubAssign for Int { - fn sub_assign(&mut self, rhs: Int) { - self.0 -= rhs.0; - } -} - -impl AddAssign for Slice { - fn add_assign(&mut self, rhs: i32) { - for lhs in &mut self.0 { - *lhs += rhs; - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_autoderef.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_autoderef.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_autoderef.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_autoderef.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::ops::{Deref, DerefMut}; - -pub struct MyRef(u32); - -impl Deref for MyRef { - type Target = u32; - fn deref(&self) -> &u32 { &self.0 } -} - -impl DerefMut for MyRef { - fn deref_mut(&mut self) -> &mut u32 { &mut self.0 } -} - - -fn deref(x: &MyRef) -> &u32 { - x -} - -fn deref_mut(x: &mut MyRef) -> &mut u32 { - x -} - -fn main() { - let mut r = MyRef(2); - assert_eq!(deref(&r) as *const _, &r.0 as *const _); - assert_eq!(deref_mut(&mut r) as *mut _, &mut r.0 as *mut _); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_boxing.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_boxing.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_boxing.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_boxing.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -fn test() -> Box { - box 42 -} - -fn main() { - assert_eq!(*test(), 42); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_build_match_comparisons.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_build_match_comparisons.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_build_match_comparisons.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_build_match_comparisons.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn test1(x: i8) -> i32 { - match x { - 1...10 => 0, - _ => 1, - } -} - -const U: Option = Some(10); -const S: &'static str = "hello"; - -fn test2(x: i8) -> i32 { - match Some(x) { - U => 0, - _ => 1, - } -} - -fn test3(x: &'static str) -> i32 { - match x { - S => 0, - _ => 1, - } -} - -enum Opt { - Some { v: T }, - None -} - -fn test4(x: u64) -> i32 { - let opt = Opt::Some{ v: x }; - match opt { - Opt::Some { v: 10 } => 0, - _ => 1, - } -} - - -fn main() { - assert_eq!(test1(0), 1); - assert_eq!(test1(1), 0); - assert_eq!(test1(2), 0); - assert_eq!(test1(5), 0); - assert_eq!(test1(9), 0); - assert_eq!(test1(10), 0); - assert_eq!(test1(11), 1); - assert_eq!(test1(20), 1); - assert_eq!(test2(10), 0); - assert_eq!(test2(0), 1); - assert_eq!(test2(20), 1); - assert_eq!(test3("hello"), 0); - assert_eq!(test3(""), 1); - assert_eq!(test3("world"), 1); - assert_eq!(test4(10), 0); - assert_eq!(test4(0), 1); - assert_eq!(test4(20), 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_calls_to_shims.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_calls_to_shims.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_calls_to_shims.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_calls_to_shims.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare compiled with panic=abort by default - -#![feature(fn_traits)] -#![feature(never_type)] - -use std::panic; - -fn foo(x: u32, y: u32) -> u32 { x/y } -fn foo_diverges() -> ! { panic!() } - -fn test_fn_ptr(mut t: T) - where T: Fn(u32, u32) -> u32, -{ - let as_fn = >::call; - assert_eq!(as_fn(&t, (9, 3)), 3); - let as_fn_mut = >::call_mut; - assert_eq!(as_fn_mut(&mut t, (18, 3)), 6); - let as_fn_once = >::call_once; - assert_eq!(as_fn_once(t, (24, 3)), 8); -} - -fn assert_panics(f: F) where F: FnOnce() { - let f = panic::AssertUnwindSafe(f); - let result = panic::catch_unwind(move || { - f.0() - }); - if let Ok(..) = result { - panic!("diverging function returned"); - } -} - -fn test_fn_ptr_panic(mut t: T) - where T: Fn() -> ! -{ - let as_fn = >::call; - assert_panics(|| as_fn(&t, ())); - let as_fn_mut = >::call_mut; - assert_panics(|| as_fn_mut(&mut t, ())); - let as_fn_once = >::call_once; - assert_panics(|| as_fn_once(t, ())); -} - -fn main() { - test_fn_ptr(foo); - test_fn_ptr(foo as fn(u32, u32) -> u32); - test_fn_ptr_panic(foo_diverges); - test_fn_ptr_panic(foo_diverges as fn() -> !); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_call_with_associated_type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_call_with_associated_type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_call_with_associated_type.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_call_with_associated_type.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Trait { - type Type; -} - -impl<'a> Trait for &'a () { - type Type = u32; -} - -fn foo<'a>(t: <&'a () as Trait>::Type) -> <&'a () as Trait>::Type { - t -} - -fn main() { - assert_eq!(foo(4), 4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_cast_fn_ret.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_cast_fn_ret.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_cast_fn_ret.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_cast_fn_ret.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub extern "C" fn tuple2() -> (u16, u8) { - (1, 2) -} - -pub extern "C" fn tuple3() -> (u8, u8, u8) { - (1, 2, 3) -} - -pub fn test2() -> u8 { - tuple2().1 -} - -pub fn test3() -> u8 { - tuple3().2 -} - -fn main() { - assert_eq!(test2(), 2); - assert_eq!(test3(), 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_array_2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_array_2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_array_2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_array_2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn into_inner(x: u64) -> [u64; 1024] { - [x; 2*4*8*16] -} - -fn main(){ - let x: &[u64] = &[42; 1024]; - assert_eq!(&into_inner(42)[..], x); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_array.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_array.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_array.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_array.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn into_inner() -> [u64; 1024] { - let mut x = 10 + 20; - [x; 1024] -} - -fn main(){ - let x: &[u64] = &[30; 1024]; - assert_eq!(&into_inner()[..], x); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_call_converging.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_call_converging.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_call_converging.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_call_converging.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn converging_fn() -> u64 { - 43 -} - -fn mir() -> u64 { - let x; - loop { - x = converging_fn(); - break; - } - x -} - -fn main() { - assert_eq!(mir(), 43); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_calls.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_calls.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_calls.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_calls.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,201 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(fn_traits, test)] - -extern crate test; - -fn test1(a: isize, b: (i32, i32), c: &[i32]) -> (isize, (i32, i32), &[i32]) { - // Test passing a number of arguments including a fat pointer. - // Also returning via an out pointer - fn callee(a: isize, b: (i32, i32), c: &[i32]) -> (isize, (i32, i32), &[i32]) { - (a, b, c) - } - callee(a, b, c) -} - -fn test2(a: isize) -> isize { - // Test passing a single argument. - // Not using out pointer. - fn callee(a: isize) -> isize { - a - } - callee(a) -} - -#[derive(PartialEq, Eq, Debug)] -struct Foo; -impl Foo { - fn inherent_method(&self, a: isize) -> isize { a } -} - -fn test3(x: &Foo, a: isize) -> isize { - // Test calling inherent method - x.inherent_method(a) -} - -trait Bar { - fn extension_method(&self, a: isize) -> isize { a } -} -impl Bar for Foo {} - -fn test4(x: &Foo, a: isize) -> isize { - // Test calling extension method - x.extension_method(a) -} - -fn test5(x: &Bar, a: isize) -> isize { - // Test calling method on trait object - x.extension_method(a) -} - -fn test6(x: &T, a: isize) -> isize { - // Test calling extension method on generic callee - x.extension_method(a) -} - -trait One { - fn one() -> T; -} -impl One for isize { - fn one() -> isize { 1 } -} - -fn test7() -> isize { - // Test calling trait static method - ::one() -} - -struct Two; -impl Two { - fn two() -> isize { 2 } -} - -fn test8() -> isize { - // Test calling impl static method - Two::two() -} - -extern fn simple_extern(x: u32, y: (u32, u32)) -> u32 { - x + y.0 * y.1 -} - -fn test9() -> u32 { - simple_extern(41, (42, 43)) -} - -fn test_closure(f: &F, x: i32, y: i32) -> i32 - where F: Fn(i32, i32) -> i32 -{ - f(x, y) -} - -fn test_fn_object(f: &Fn(i32, i32) -> i32, x: i32, y: i32) -> i32 { - f(x, y) -} - -fn test_fn_impl(f: &&Fn(i32, i32) -> i32, x: i32, y: i32) -> i32 { - // This call goes through the Fn implementation for &Fn provided in - // core::ops::impls. It expands to a static Fn::call() that calls the - // Fn::call() implementation of the object shim underneath. - f(x, y) -} - -fn test_fn_direct_call(f: &F, x: i32, y: i32) -> i32 - where F: Fn(i32, i32) -> i32 -{ - f.call((x, y)) -} - -fn test_fn_const_call(f: &F) -> i32 - where F: Fn(i32, i32) -> i32 -{ - f.call((100, -1)) -} - -fn test_fn_nil_call(f: &F) -> i32 - where F: Fn() -> i32 -{ - f() -} - -fn test_fn_transmute_zst(x: ()) -> [(); 1] { - fn id(x: T) -> T {x} - - id(unsafe { - std::mem::transmute(x) - }) -} - -fn test_fn_ignored_pair() -> ((), ()) { - ((), ()) -} - -fn test_fn_ignored_pair_0() { - test_fn_ignored_pair().0 -} - -fn id(x: T) -> T { x } - -fn ignored_pair_named() -> (Foo, Foo) { - (Foo, Foo) -} - -fn test_fn_ignored_pair_named() -> (Foo, Foo) { - id(ignored_pair_named()) -} - -fn test_fn_nested_pair(x: &((f32, f32), u32)) -> (f32, f32) { - let y = *x; - let z = y.0; - (z.0, z.1) -} - -fn test_fn_const_arg_by_ref(mut a: [u64; 4]) -> u64 { - // Mutate the by-reference argument, which won't work with - // a non-immediate constant unless it's copied to the stack. - let a = test::black_box(&mut a); - a[0] += a[1]; - a[0] += a[2]; - a[0] += a[3]; - a[0] -} - -fn main() { - assert_eq!(test1(1, (2, 3), &[4, 5, 6]), (1, (2, 3), &[4, 5, 6][..])); - assert_eq!(test2(98), 98); - assert_eq!(test3(&Foo, 42), 42); - assert_eq!(test4(&Foo, 970), 970); - assert_eq!(test5(&Foo, 8576), 8576); - assert_eq!(test6(&Foo, 12367), 12367); - assert_eq!(test7(), 1); - assert_eq!(test8(), 2); - assert_eq!(test9(), 41 + 42 * 43); - - let r = 3; - let closure = |x: i32, y: i32| { r*(x + (y*2)) }; - assert_eq!(test_fn_const_call(&closure), 294); - assert_eq!(test_closure(&closure, 100, 1), 306); - let function_object = &closure as &Fn(i32, i32) -> i32; - assert_eq!(test_fn_object(function_object, 100, 2), 312); - assert_eq!(test_fn_impl(&function_object, 100, 3), 318); - assert_eq!(test_fn_direct_call(&closure, 100, 4), 324); - - assert_eq!(test_fn_nil_call(&(|| 42)), 42); - assert_eq!(test_fn_transmute_zst(()), [()]); - - assert_eq!(test_fn_ignored_pair_0(), ()); - assert_eq!(test_fn_ignored_pair_named(), (Foo, Foo)); - assert_eq!(test_fn_nested_pair(&((1.0, 2.0), 0)), (1.0, 2.0)); - - const ARRAY: [u64; 4] = [1, 2, 3, 4]; - assert_eq!(test_fn_const_arg_by_ref(ARRAY), 1 + 2 + 3 + 4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_calls_variadic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_calls_variadic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_calls_variadic.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_calls_variadic.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare no libc to test ffi with - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - fn rust_interesting_average(_: i64, ...) -> f64; -} - -fn test(a: i64, b: i64, c: i64, d: i64, e: i64, f: T, g: U) -> i64 { - unsafe { - rust_interesting_average(6, a, a as f64, - b, b as f64, - c, c as f64, - d, d as f64, - e, e as f64, - f, g) as i64 - } -} - -fn main(){ - assert_eq!(test(10, 20, 30, 40, 50, 60_i64, 60.0_f64), 70); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_critical_edge.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_critical_edge.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_critical_edge.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_critical_edge.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This code produces a CFG with critical edges that, if we don't -// handle properly, will cause invalid codegen. - -#![feature(rustc_attrs)] - -enum State { - Both, - Front, - Back -} - -pub struct Foo { - state: State, - a: A, - b: B -} - -impl Foo -where A: Iterator, B: Iterator -{ - // This is the function we care about - fn next(&mut self) -> Option { - match self.state { - State::Both => match self.a.next() { - elt @ Some(..) => elt, - None => { - self.state = State::Back; - self.b.next() - } - }, - State::Front => self.a.next(), - State::Back => self.b.next(), - } - } -} - -// Make sure we actually codegen a version of the function -pub fn do_stuff(mut f: Foo>, Box>>) { - let _x = f.next(); -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_spike1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_spike1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_spike1.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_spike1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// A simple spike test for MIR version of codegen. - -fn sum(x: i32, y: i32) -> i32 { - x + y -} - -fn main() { - let x = sum(22, 44); - assert_eq!(x, 66); - println!("sum()={:?}", x); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_switchint.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_switchint.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_switchint.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_switchint.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn foo(x: i8) -> i32 { - match x { - 1 => 0, - _ => 1, - } -} - -fn main() { - assert_eq!(foo(0), 1); - assert_eq!(foo(1), 0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_switch.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_switch.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_switch.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_codegen_switch.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -enum Abc { - A(u8), - B(i8), - C, - D, -} - -fn foo(x: Abc) -> i32 { - match x { - Abc::C => 3, - Abc::D => 4, - Abc::B(_) => 2, - Abc::A(_) => 1, - } -} - -fn foo2(x: Abc) -> bool { - match x { - Abc::D => true, - _ => false - } -} - -fn main() { - assert_eq!(1, foo(Abc::A(42))); - assert_eq!(2, foo(Abc::B(-100))); - assert_eq!(3, foo(Abc::C)); - assert_eq!(4, foo(Abc::D)); - - assert_eq!(false, foo2(Abc::A(1))); - assert_eq!(false, foo2(Abc::B(2))); - assert_eq!(false, foo2(Abc::C)); - assert_eq!(true, foo2(Abc::D)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_coercion_casts.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_coercion_casts.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_coercion_casts.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_coercion_casts.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests the coercion casts are handled properly - -fn main() { - // This should produce only a reification of f, - // not a fn -> fn cast as well - let _ = f as fn(&()); -} - -fn f<'a>(_: &'a ()) { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_coercions.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_coercions.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_coercions.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_coercions.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(coerce_unsized, unsize)] - -use std::ops::CoerceUnsized; -use std::marker::Unsize; - -fn identity_coercion(x: &(Fn(u32)->u32 + Send)) -> &Fn(u32)->u32 { - x -} -fn fn_coercions(f: &fn(u32) -> u32) -> - (unsafe fn(u32) -> u32, - &(Fn(u32) -> u32+Send)) -{ - (*f, f) -} - -fn simple_array_coercion(x: &[u8; 3]) -> &[u8] { x } - -fn square(a: u32) -> u32 { a * a } - -#[derive(PartialEq,Eq)] -struct PtrWrapper<'a, T: 'a+?Sized>(u32, u32, (), &'a T); -impl<'a, T: ?Sized+Unsize, U: ?Sized> - CoerceUnsized> for PtrWrapper<'a, T> {} - -struct TrivPtrWrapper<'a, T: 'a+?Sized>(&'a T); -impl<'a, T: ?Sized+Unsize, U: ?Sized> - CoerceUnsized> for TrivPtrWrapper<'a, T> {} - -fn coerce_ptr_wrapper(p: PtrWrapper<[u8; 3]>) -> PtrWrapper<[u8]> { - p -} - -fn coerce_triv_ptr_wrapper(p: TrivPtrWrapper<[u8; 3]>) -> TrivPtrWrapper<[u8]> { - p -} - -fn coerce_fat_ptr_wrapper(p: PtrWrapper u32+Send>) - -> PtrWrapper u32> { - p -} - -fn coerce_ptr_wrapper_poly<'a, T, Trait: ?Sized>(p: PtrWrapper<'a, T>) - -> PtrWrapper<'a, Trait> - where PtrWrapper<'a, T>: CoerceUnsized> -{ - p -} - -fn main() { - let a = [0,1,2]; - let square_local : fn(u32) -> u32 = square; - let (f,g) = fn_coercions(&square_local); - assert_eq!(f as usize, square as usize); - assert_eq!(g(4), 16); - assert_eq!(identity_coercion(g)(5), 25); - - assert_eq!(simple_array_coercion(&a), &a); - let w = coerce_ptr_wrapper(PtrWrapper(2,3,(),&a)); - assert!(w == PtrWrapper(2,3,(),&a) as PtrWrapper<[u8]>); - - let w = coerce_triv_ptr_wrapper(TrivPtrWrapper(&a)); - assert_eq!(&w.0, &a); - - let z = coerce_fat_ptr_wrapper(PtrWrapper(2,3,(),&square_local)); - assert_eq!((z.3)(6), 36); - - let z: PtrWrapper u32> = - coerce_ptr_wrapper_poly(PtrWrapper(2,3,(),&square_local)); - assert_eq!((z.3)(6), 36); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_constval_adts.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_constval_adts.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_constval_adts.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_constval_adts.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(PartialEq, Debug)] -struct Point { - _x: i32, - _y: i32, -} - -#[derive(PartialEq, Eq, Debug)] -struct Newtype(T); - -const STRUCT: Point = Point { _x: 42, _y: 42 }; -const TUPLE1: (i32, i32) = (42, 42); -const TUPLE2: (&'static str, &'static str) = ("hello","world"); -const PAIR_NEWTYPE: (Newtype, Newtype) = (Newtype(42), Newtype(42)); - -fn mir() -> (Point, (i32, i32), (&'static str, &'static str), (Newtype, Newtype)) { - let struct1 = STRUCT; - let tuple1 = TUPLE1; - let tuple2 = TUPLE2; - let pair_newtype = PAIR_NEWTYPE; - (struct1, tuple1, tuple2, pair_newtype) -} - -const NEWTYPE: Newtype<&'static str> = Newtype("foobar"); - -fn test_promoted_newtype_str_ref() { - let x = &NEWTYPE; - assert_eq!(x, &Newtype("foobar")); -} - -fn main(){ - assert_eq!(mir(), (STRUCT, TUPLE1, TUPLE2, PAIR_NEWTYPE)); - test_promoted_newtype_str_ref(); -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_drop_order.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_drop_order.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_drop_order.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_drop_order.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare compiled with panic=abort by default - -use std::cell::RefCell; -use std::panic; - -pub struct DropLogger<'a> { - id: usize, - log: &'a panic::AssertUnwindSafe>> -} - -impl<'a> Drop for DropLogger<'a> { - fn drop(&mut self) { - self.log.0.borrow_mut().push(self.id); - } -} - -struct InjectedFailure; - -#[allow(unreachable_code)] -fn main() { - let log = panic::AssertUnwindSafe(RefCell::new(vec![])); - let d = |id| DropLogger { id: id, log: &log }; - let get = || -> Vec<_> { - let mut m = log.0.borrow_mut(); - let n = m.drain(..); - n.collect() - }; - - { - let _x = (d(0), &d(1), d(2), &d(3)); - // all borrows are extended - nothing has been dropped yet - assert_eq!(get(), vec![]); - } - // in a let-statement, extended places are dropped - // *after* the let result (tho they have the same scope - // as far as scope-based borrowck goes). - assert_eq!(get(), vec![0, 2, 3, 1]); - - let _ = std::panic::catch_unwind(|| { - (d(4), &d(5), d(6), &d(7), panic!(InjectedFailure)); - }); - - // here, the temporaries (5/7) live until the end of the - // containing statement, which is destroyed after the operands - // (4/6) on a panic. - assert_eq!(get(), vec![6, 4, 7, 5]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_early_return_scope.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_early_return_scope.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_early_return_scope.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_early_return_scope.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -static mut DROP: bool = false; - -struct ConnWrap(Conn); -impl ::std::ops::Deref for ConnWrap { - type Target=Conn; - fn deref(&self) -> &Conn { &self.0 } -} - -struct Conn; -impl Drop for Conn { - fn drop(&mut self) { unsafe { DROP = true; } } -} - -fn inner() { - let conn = &*match Some(ConnWrap(Conn)) { - Some(val) => val, - None => return, - }; - return; -} - -fn main() { - inner(); - unsafe { - assert_eq!(DROP, true); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_fat_ptr_drop.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_fat_ptr_drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_fat_ptr_drop.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_fat_ptr_drop.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -// test that ordinary fat pointer operations work. - -#![feature(braced_empty_structs)] -#![feature(rustc_attrs)] - -use std::sync::atomic; -use std::sync::atomic::Ordering::SeqCst; - -static COUNTER: atomic::AtomicUsize = atomic::ATOMIC_USIZE_INIT; - -struct DropMe { -} - -impl Drop for DropMe { - fn drop(&mut self) { - COUNTER.fetch_add(1, SeqCst); - } -} - -fn fat_ptr_move_then_drop(a: Box<[DropMe]>) { - let b = a; -} - -fn main() { - let a: Box<[DropMe]> = Box::new([DropMe { }]); - fat_ptr_move_then_drop(a); - assert_eq!(COUNTER.load(SeqCst), 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_fat_ptr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_fat_ptr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_fat_ptr.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_fat_ptr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// test that ordinary fat pointer operations work. - -struct Wrapper(u32, T); - -struct FatPtrContainer<'a> { - ptr: &'a [u8] -} - -fn fat_ptr_project(a: &Wrapper<[u8]>) -> &[u8] { - &a.1 -} - -fn fat_ptr_simple(a: &[u8]) -> &[u8] { - a -} - -fn fat_ptr_via_local(a: &[u8]) -> &[u8] { - let x = a; - x -} - -fn fat_ptr_from_struct(s: FatPtrContainer) -> &[u8] { - s.ptr -} - -fn fat_ptr_to_struct(a: &[u8]) -> FatPtrContainer { - FatPtrContainer { ptr: a } -} - -fn fat_ptr_store_to<'a>(a: &'a [u8], b: &mut &'a [u8]) { - *b = a; -} - -fn fat_ptr_constant() -> &'static str { - "HELLO" -} - -fn main() { - let a = Wrapper(4, [7,6,5]); - - let p = fat_ptr_project(&a); - let p = fat_ptr_simple(p); - let p = fat_ptr_via_local(p); - let p = fat_ptr_from_struct(fat_ptr_to_struct(p)); - - let mut target : &[u8] = &[42]; - fat_ptr_store_to(p, &mut target); - assert_eq!(target, &a.1); - - assert_eq!(fat_ptr_constant(), "HELLO"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_heavy_promoted.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_heavy_promoted.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_heavy_promoted.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_heavy_promoted.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten apparently only works in optimized mode - -const TEST_DATA: [u8; 32 * 1024 * 1024] = [42; 32 * 1024 * 1024]; - -// Check that the promoted copy of TEST_DATA doesn't -// leave an alloca from an unused temp behind, which, -// without optimizations, can still blow the stack. -fn main() { - println!("{}", TEST_DATA.len()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir-inlining/ice-issue-45493.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir-inlining/ice-issue-45493.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir-inlining/ice-issue-45493.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir-inlining/ice-issue-45493.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags:-Zmir-opt-level=2 - -trait Array { - type Item; -} - -fn foo() { - let _: *mut A::Item = std::ptr::null_mut(); -} - -struct Foo; -impl Array for Foo { type Item = i32; } - -fn main() { - foo::(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir-inlining/ice-issue-45885.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir-inlining/ice-issue-45885.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir-inlining/ice-issue-45885.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir-inlining/ice-issue-45885.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags:-Zmir-opt-level=2 - -pub enum Enum { - A, - B, -} - -trait SliceIndex { - type Output; - fn get(&self) -> &Self::Output; -} - -impl SliceIndex for usize { - type Output = Enum; - #[inline(never)] - fn get(&self) -> &Enum { - &Enum::A - } -} - -#[inline(always)] -fn index(t: &T) -> &T::Output { - t.get() -} - -fn main() { - match *index(&0) { Enum::A => true, _ => false }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir-inlining/no-trait-method-issue-40473.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir-inlining/no-trait-method-issue-40473.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir-inlining/no-trait-method-issue-40473.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir-inlining/no-trait-method-issue-40473.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags:-Zmir-opt-level=2 -pub trait Foo { - fn bar(&self) -> usize { 2 } -} - -impl Foo for () { - fn bar(&self) -> usize { 3 } -} - -// Test a case where MIR would inline the default trait method -// instead of bailing out. Issue #40473. -fn main() { - let result = ().bar(); - assert_eq!(result, 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_match_arm_guard.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_match_arm_guard.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_match_arm_guard.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_match_arm_guard.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// #30527 - We were not generating arms with guards in certain cases. - -fn match_with_guard(x: Option) -> i8 { - match x { - Some(xyz) if xyz > 100 => 0, - Some(_) => -1, - None => -2 - } -} - -fn main() { - assert_eq!(match_with_guard(Some(111)), 0); - assert_eq!(match_with_guard(Some(2)), -1); - assert_eq!(match_with_guard(None), -2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_misc_casts.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_misc_casts.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_misc_casts.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_misc_casts.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,330 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn func(){} - -const STR: &'static str = "hello"; -const BSTR: &'static [u8; 5] = b"hello"; - -fn from_ptr() --> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, *const ()) { - let f = 1_usize as *const String; - let c1 = f as isize; - let c2 = f as usize; - let c3 = f as i8; - let c4 = f as i16; - let c5 = f as i32; - let c6 = f as i64; - let c7 = f as u8; - let c8 = f as u16; - let c9 = f as u32; - let c10 = f as u64; - let c11 = f as *const (); - (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11) -} - -fn from_1() --> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, *const String) { - let c1 = 1 as isize; - let c2 = 1 as usize; - let c3 = 1 as i8; - let c4 = 1 as i16; - let c5 = 1 as i32; - let c6 = 1 as i64; - let c7 = 1 as u8; - let c8 = 1 as u16; - let c9 = 1 as u32; - let c10 = 1 as u64; - let c11 = 1 as f32; - let c12 = 1 as f64; - let c13 = 1 as *const String; - (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) -} - -fn from_1usize() --> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, *const String) { - let c1 = 1_usize as isize; - let c2 = 1_usize as usize; - let c3 = 1_usize as i8; - let c4 = 1_usize as i16; - let c5 = 1_usize as i32; - let c6 = 1_usize as i64; - let c7 = 1_usize as u8; - let c8 = 1_usize as u16; - let c9 = 1_usize as u32; - let c10 = 1_usize as u64; - let c11 = 1_usize as f32; - let c12 = 1_usize as f64; - let c13 = 1_usize as *const String; - (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) -} - -fn from_1isize() --> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, *const String) { - let c1 = 1_isize as isize; - let c2 = 1_isize as usize; - let c3 = 1_isize as i8; - let c4 = 1_isize as i16; - let c5 = 1_isize as i32; - let c6 = 1_isize as i64; - let c7 = 1_isize as u8; - let c8 = 1_isize as u16; - let c9 = 1_isize as u32; - let c10 = 1_isize as u64; - let c11 = 1_isize as f32; - let c12 = 1_isize as f64; - let c13 = 1_isize as *const String; - (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) -} - -fn from_1u8() --> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, *const String) { - let c1 = 1_u8 as isize; - let c2 = 1_u8 as usize; - let c3 = 1_u8 as i8; - let c4 = 1_u8 as i16; - let c5 = 1_u8 as i32; - let c6 = 1_u8 as i64; - let c7 = 1_u8 as u8; - let c8 = 1_u8 as u16; - let c9 = 1_u8 as u32; - let c10 = 1_u8 as u64; - let c11 = 1_u8 as f32; - let c12 = 1_u8 as f64; - let c13 = 1_u8 as *const String; - (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) -} - -fn from_1i8() --> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, *const String) { - let c1 = 1_i8 as isize; - let c2 = 1_i8 as usize; - let c3 = 1_i8 as i8; - let c4 = 1_i8 as i16; - let c5 = 1_i8 as i32; - let c6 = 1_i8 as i64; - let c7 = 1_i8 as u8; - let c8 = 1_i8 as u16; - let c9 = 1_i8 as u32; - let c10 = 1_i8 as u64; - let c11 = 1_i8 as f32; - let c12 = 1_i8 as f64; - let c13 = 1_i8 as *const String; - (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) -} - -fn from_1u16() --> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, *const String) { - let c1 = 1_u16 as isize; - let c2 = 1_u16 as usize; - let c3 = 1_u16 as i8; - let c4 = 1_u16 as i16; - let c5 = 1_u16 as i32; - let c6 = 1_u16 as i64; - let c7 = 1_u16 as u8; - let c8 = 1_u16 as u16; - let c9 = 1_u16 as u32; - let c10 = 1_u16 as u64; - let c11 = 1_u16 as f32; - let c12 = 1_u16 as f64; - let c13 = 1_u16 as *const String; - (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) -} - -fn from_1i16() --> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, *const String) { - let c1 = 1_i16 as isize; - let c2 = 1_i16 as usize; - let c3 = 1_i16 as i8; - let c4 = 1_i16 as i16; - let c5 = 1_i16 as i32; - let c6 = 1_i16 as i64; - let c7 = 1_i16 as u8; - let c8 = 1_i16 as u16; - let c9 = 1_i16 as u32; - let c10 = 1_i16 as u64; - let c11 = 1_i16 as f32; - let c12 = 1_i16 as f64; - let c13 = 1_i16 as *const String; - (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) -} - -fn from_1u32() --> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, *const String) { - let c1 = 1_u32 as isize; - let c2 = 1_u32 as usize; - let c3 = 1_u32 as i8; - let c4 = 1_u32 as i16; - let c5 = 1_u32 as i32; - let c6 = 1_u32 as i64; - let c7 = 1_u32 as u8; - let c8 = 1_u32 as u16; - let c9 = 1_u32 as u32; - let c10 = 1_u32 as u64; - let c11 = 1_u32 as f32; - let c12 = 1_u32 as f64; - let c13 = 1_u32 as *const String; - (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) -} - -fn from_1i32() --> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, *const String) { - let c1 = 1_i32 as isize; - let c2 = 1_i32 as usize; - let c3 = 1_i32 as i8; - let c4 = 1_i32 as i16; - let c5 = 1_i32 as i32; - let c6 = 1_i32 as i64; - let c7 = 1_i32 as u8; - let c8 = 1_i32 as u16; - let c9 = 1_i32 as u32; - let c10 = 1_i32 as u64; - let c11 = 1_i32 as f32; - let c12 = 1_i32 as f64; - let c13 = 1_i32 as *const String; - (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) -} - -fn from_1u64() --> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, *const String) { - let c1 = 1_u64 as isize; - let c2 = 1_u64 as usize; - let c3 = 1_u64 as i8; - let c4 = 1_u64 as i16; - let c5 = 1_u64 as i32; - let c6 = 1_u64 as i64; - let c7 = 1_u64 as u8; - let c8 = 1_u64 as u16; - let c9 = 1_u64 as u32; - let c10 = 1_u64 as u64; - let c11 = 1_u64 as f32; - let c12 = 1_u64 as f64; - let c13 = 1_u64 as *const String; - (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) -} - -fn from_1i64() --> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, *const String) { - let c1 = 1_i64 as isize; - let c2 = 1_i64 as usize; - let c3 = 1_i64 as i8; - let c4 = 1_i64 as i16; - let c5 = 1_i64 as i32; - let c6 = 1_i64 as i64; - let c7 = 1_i64 as u8; - let c8 = 1_i64 as u16; - let c9 = 1_i64 as u32; - let c10 = 1_i64 as u64; - let c11 = 1_i64 as f32; - let c12 = 1_i64 as f64; - let c13 = 1_i64 as *const String; - (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13) -} - -fn from_bool() --> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64) { - let c1 = true as isize; - let c2 = true as usize; - let c3 = true as i8; - let c4 = true as i16; - let c5 = true as i32; - let c6 = true as i64; - let c7 = true as u8; - let c8 = true as u16; - let c9 = true as u32; - let c10 = true as u64; - (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10) -} - -fn from_1f32() --> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64) { - let c1 = 1.0_f32 as isize; - let c2 = 1.0_f32 as usize; - let c3 = 1.0_f32 as i8; - let c4 = 1.0_f32 as i16; - let c5 = 1.0_f32 as i32; - let c6 = 1.0_f32 as i64; - let c7 = 1.0_f32 as u8; - let c8 = 1.0_f32 as u16; - let c9 = 1.0_f32 as u32; - let c10 = 1.0_f32 as u64; - let c11 = 1.0_f32 as f32; - let c12 = 1.0_f32 as f64; - (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12) -} - -fn from_1f64() --> (isize, usize, i8, i16, i32, i64, u8, u16, u32, u64, f32, f64) { - let c1 = 1.0f64 as isize; - let c2 = 1.0f64 as usize; - let c3 = 1.0f64 as i8; - let c4 = 1.0f64 as i16; - let c5 = 1.0f64 as i32; - let c6 = 1.0f64 as i64; - let c7 = 1.0f64 as u8; - let c8 = 1.0f64 as u16; - let c9 = 1.0f64 as u32; - let c10 = 1.0f64 as u64; - let c11 = 1.0f64 as f32; - let c12 = 1.0f64 as f64; - (c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12) -} - -fn other_casts() --> (*const u8, *const isize, *const u8, *const u8) { - let c1 = func as *const u8; - let c2 = c1 as *const isize; - - let r = &42u32; - let _ = r as *const u32; - - // fat-ptr -> fat-ptr -> fat-raw-ptr -> thin-ptr - let c3 = STR as &str as *const str as *const u8; - - let c4 = BSTR as *const [u8] as *const [u16] as *const u8; - (c1, c2, c3, c4) -} - -pub fn assert_eq_13(l: (isize, usize, i8, i16, i32, i64, u8, - u16, u32, u64, f32, f64, *const String), - r: (isize, usize, i8, i16, i32, i64, u8, - u16, u32, u64, f32, f64, *const String)) -> bool { - let (l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13) = l; - let (r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13) = r; - l1 == r1 && l2 == r2 && l3 == r3 && l4 == r4 && l5 == r5 && l6 == r6 && l7 == r7 && - l8 == r8 && l9 == r9 && l10 == r10 && l11 == r11 && l12 == r12 && l13 == r13 -} - - -pub fn main() { - let f = 1_usize as *const String; - let t13 = (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.0, 1.0, f); - let t12 = (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.0, 1.0); - assert_eq_13(from_1(), t13); - assert_eq_13(from_1usize(), t13); - assert_eq_13(from_1isize(), t13); - assert_eq_13(from_1u8(), t13); - assert_eq_13(from_1i8(), t13); - assert_eq_13(from_1u16(), t13); - assert_eq_13(from_1i16(), t13); - assert_eq_13(from_1u32(), t13); - assert_eq_13(from_1i32(), t13); - assert_eq_13(from_1u64(), t13); - assert_eq_13(from_1i64(), t13); - assert_eq!(from_1f32(), t12); - assert_eq!(from_1f64(), t12); - - assert_eq!(from_ptr(), (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 as *const ())); - assert_eq!(from_bool(), (1, 1, 1, 1, 1, 1, 1, 1, 1, 1)); - - assert_eq!(other_casts(), (func as *const u8, func as *const isize, - STR as *const str as *const u8, BSTR as *const [u8] as *const u8)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_overflow_off.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_overflow_off.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_overflow_off.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_overflow_off.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: -Z force-overflow-checks=off - -// Test that with MIR codegen, overflow checks can be -// turned off, even when they're from core::ops::*. - -use std::ops::*; - -fn main() { - assert_eq!(i8::neg(-0x80), -0x80); - - assert_eq!(u8::add(0xff, 1), 0_u8); - assert_eq!(u8::sub(0, 1), 0xff_u8); - assert_eq!(u8::mul(0xff, 2), 0xfe_u8); - assert_eq!(u8::shl(1, 9), 2_u8); - assert_eq!(u8::shr(2, 9), 1_u8); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_raw_fat_ptr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_raw_fat_ptr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_raw_fat_ptr.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_raw_fat_ptr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,168 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// check raw fat pointer ops in mir -// FIXME: please improve this when we get monomorphization support - -use std::mem; - -#[derive(Debug, PartialEq, Eq)] -struct ComparisonResults { - lt: bool, - le: bool, - gt: bool, - ge: bool, - eq: bool, - ne: bool -} - -const LT: ComparisonResults = ComparisonResults { - lt: true, - le: true, - gt: false, - ge: false, - eq: false, - ne: true -}; - -const EQ: ComparisonResults = ComparisonResults { - lt: false, - le: true, - gt: false, - ge: true, - eq: true, - ne: false -}; - -const GT: ComparisonResults = ComparisonResults { - lt: false, - le: false, - gt: true, - ge: true, - eq: false, - ne: true -}; - -fn compare_su8(a: *const S<[u8]>, b: *const S<[u8]>) -> ComparisonResults { - ComparisonResults { - lt: a < b, - le: a <= b, - gt: a > b, - ge: a >= b, - eq: a == b, - ne: a != b - } -} - -fn compare_au8(a: *const [u8], b: *const [u8]) -> ComparisonResults { - ComparisonResults { - lt: a < b, - le: a <= b, - gt: a > b, - ge: a >= b, - eq: a == b, - ne: a != b - } -} - -fn compare_foo<'a>(a: *const (Foo+'a), b: *const (Foo+'a)) -> ComparisonResults { - ComparisonResults { - lt: a < b, - le: a <= b, - gt: a > b, - ge: a >= b, - eq: a == b, - ne: a != b - } -} - -fn simple_eq<'a>(a: *const (Foo+'a), b: *const (Foo+'a)) -> bool { - let result = a == b; - result -} - -fn assert_inorder(a: &[T], - compare: fn(T, T) -> ComparisonResults) { - for i in 0..a.len() { - for j in 0..a.len() { - let cres = compare(a[i], a[j]); - if i < j { - assert_eq!(cres, LT); - } else if i == j { - assert_eq!(cres, EQ); - } else { - assert_eq!(cres, GT); - } - } - } -} - -trait Foo { fn foo(&self) -> usize; } -impl Foo for T { - fn foo(&self) -> usize { - mem::size_of::() - } -} - -struct S(u32, T); - -fn main() { - let array = [0,1,2,3,4]; - let array2 = [5,6,7,8,9]; - - // fat ptr comparison: addr then extra - - // check ordering for arrays - let mut ptrs: Vec<*const [u8]> = vec![ - &array[0..0], &array[0..1], &array, &array[1..] - ]; - - let array_addr = &array as *const [u8] as *const u8 as usize; - let array2_addr = &array2 as *const [u8] as *const u8 as usize; - if array2_addr < array_addr { - ptrs.insert(0, &array2); - } else { - ptrs.push(&array2); - } - assert_inorder(&ptrs, compare_au8); - - let u8_ = (0u8, 1u8); - let u32_ = (4u32, 5u32); - - // check ordering for ptrs - let buf: &mut [*const Foo] = &mut [ - &u8_, &u8_.0, - &u32_, &u32_.0, - ]; - buf.sort_by(|u,v| { - let u : [*const (); 2] = unsafe { mem::transmute(*u) }; - let v : [*const (); 2] = unsafe { mem::transmute(*v) }; - u.cmp(&v) - }); - assert_inorder(buf, compare_foo); - - // check ordering for structs containing arrays - let ss: (S<[u8; 2]>, - S<[u8; 3]>, - S<[u8; 2]>) = ( - S(7, [8, 9]), - S(10, [11, 12, 13]), - S(4, [5, 6]) - ); - assert_inorder(&[ - &ss.0 as *const S<[u8]>, - &ss.1 as *const S<[u8]>, - &ss.2 as *const S<[u8]> - ], compare_su8); - - assert!(simple_eq(&0u8 as *const _, &0u8 as *const _)); - assert!(!simple_eq(&0u8 as *const _, &1u8 as *const _)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_refs_correct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_refs_correct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_refs_correct.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_refs_correct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,219 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:mir_external_refs.rs - -extern crate mir_external_refs as ext; - -struct S(u8); -#[derive(Debug, PartialEq, Eq)] -struct Unit; - -impl S { - fn hey() -> u8 { 42 } - fn hey2(&self) -> u8 { 44 } -} - -trait X { - fn hoy(&self) -> u8 { 43 } - fn hoy2() -> u8 { 45 } -} - -trait F { - fn f(self, other: U) -> u64; -} - -impl F for u32 { - fn f(self, other: u32) -> u64 { self as u64 + other as u64 } -} - -impl F for u32 { - fn f(self, other: u64) -> u64 { self as u64 - other } -} - -impl F for u64 { - fn f(self, other: u64) -> u64 { self * other } -} - -impl F for u64 { - fn f(self, other: u32) -> u64 { self ^ other as u64 } -} - -trait T { - fn staticmeth(i: I, o: O) -> (I, O) { (i, o) } -} - -impl T for O {} - -impl X for S {} - -enum E { - U(u8) -} - -#[derive(PartialEq, Debug, Eq)] -enum CEnum { - A = 0x321, - B = 0x123 -} - -const C: u8 = 84; -const C2: [u8; 5] = [42; 5]; -const C3: [u8; 3] = [42, 41, 40]; -const C4: fn(u8) -> S = S; - -fn regular() -> u8 { - 21 -} - -fn parametric(u: T) -> T { - u -} - -fn t1() -> fn()->u8 { - regular -} - -fn t2() -> fn(u8)->E { - E::U -} - -fn t3() -> fn(u8)->S { - S -} - -fn t4() -> fn()->u8 { - S::hey -} - -fn t5() -> fn(&S)-> u8 { - ::hoy -} - - -fn t6() -> fn()->u8{ - ext::regular_fn -} - -fn t7() -> fn(u8)->ext::E { - ext::E::U -} - -fn t8() -> fn(u8)->ext::S { - ext::S -} - -fn t9() -> fn()->u8 { - ext::S::hey -} - -fn t10() -> fn(&ext::S)->u8 { - ::hoy -} - -fn t11() -> fn(u8)->u8 { - parametric -} - -fn t12() -> u8 { - C -} - -fn t13() -> [u8; 5] { - C2 -} - -fn t13_2() -> [u8; 3] { - C3 -} - -fn t14() -> fn()-> u8 { - ::hoy2 -} - -fn t15() -> fn(&S)-> u8 { - S::hey2 -} - -fn t16() -> fn(u32, u32)->u64 { - F::f -} - -fn t17() -> fn(u32, u64)->u64 { - F::f -} - -fn t18() -> fn(u64, u64)->u64 { - F::f -} - -fn t19() -> fn(u64, u32)->u64 { - F::f -} - -fn t20() -> fn(u64, u32)->(u64, u32) { - >::staticmeth -} - -fn t21() -> Unit { - Unit -} - -fn t22() -> Option { - None -} - -fn t23() -> (CEnum, CEnum) { - (CEnum::A, CEnum::B) -} - -fn t24() -> fn(u8) -> S { - C4 -} - -fn main() { - assert_eq!(t1()(), regular()); - - assert_eq!(t2() as *mut (), E::U as *mut ()); - assert_eq!(t3() as *mut (), S as *mut ()); - - assert_eq!(t4()(), S::hey()); - let s = S(42); - assert_eq!(t5()(&s), ::hoy(&s)); - - - assert_eq!(t6()(), ext::regular_fn()); - assert_eq!(t7() as *mut (), ext::E::U as *mut ()); - assert_eq!(t8() as *mut (), ext::S as *mut ()); - - assert_eq!(t9()(), ext::S::hey()); - let sext = ext::S(6); - assert_eq!(t10()(&sext), ::hoy(&sext)); - - let p = parametric::; - assert_eq!(t11() as *mut (), p as *mut ()); - - assert_eq!(t12(), C); - assert_eq!(t13(), C2); - assert_eq!(t13_2(), C3); - - assert_eq!(t14()(), ::hoy2()); - assert_eq!(t15()(&s), S::hey2(&s)); - assert_eq!(t16()(10u32, 20u32), F::f(10u32, 20u32)); - assert_eq!(t17()(30u32, 10u64), F::f(30u32, 10u64)); - assert_eq!(t18()(50u64, 5u64), F::f(50u64, 5u64)); - assert_eq!(t19()(322u64, 2u32), F::f(322u64, 2u32)); - assert_eq!(t20()(123u64, 38u32), >::staticmeth(123, 38)); - assert_eq!(t21(), Unit); - assert_eq!(t22(), None); - assert_eq!(t23(), (CEnum::A, CEnum::B)); - assert_eq!(t24(), C4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_small_agg_arg.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_small_agg_arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_small_agg_arg.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_small_agg_arg.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn foo((x, y): (i8, i8)) { -} - -fn main() { - foo((0, 1)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_struct_with_assoc_ty.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_struct_with_assoc_ty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_struct_with_assoc_ty.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_struct_with_assoc_ty.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::marker::PhantomData; - -pub trait DataBind { - type Data; -} - -impl DataBind for Global { - type Data = T; -} - -pub struct Global(PhantomData); - -pub struct Data { - pub offsets: as DataBind>::Data, -} - -fn create_data() -> Data { - let mut d = Data { offsets: [1, 2] }; - d.offsets[0] = 3; - d -} - - -fn main() { - let d = create_data(); - assert_eq!(d.offsets[0], 3); - assert_eq!(d.offsets[1], 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_temp_promotions.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_temp_promotions.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_temp_promotions.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_temp_promotions.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn test1(f: f32) -> bool { - // test that we properly promote temporaries to allocas when a temporary is assigned to - // multiple times (assignment is still happening once ∀ possible dataflows). - !(f.is_nan() || f.is_infinite()) -} - -fn main() { - assert_eq!(test1(0.0), true); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir-typeck-normalize-fn-sig.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir-typeck-normalize-fn-sig.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir-typeck-normalize-fn-sig.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir-typeck-normalize-fn-sig.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This code was creating an ICE in the MIR type checker. The reason -// is that we are reifying a reference to a function (`foo::<'x>`), -// which involves extracting its signature, but we were not -// normalizing the signature afterwards. As a result, we sometimes got -// errors around the `>::Value`, which can be -// normalized to `f64`. - -#![allow(dead_code)] - -trait Foo<'x> { - type Value; -} - -impl<'x> Foo<'x> for u32 { - type Value = f64; -} - -struct Providers<'x> { - foo: for<'y> fn(x: &'x u32, y: &'y u32) -> >::Value, -} - -fn foo<'y, 'x: 'x>(x: &'x u32, y: &'y u32) -> >::Value { - *x as f64 -} - -fn main() { - Providers { foo }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_void_return_2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_void_return_2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_void_return_2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_void_return_2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn nil() {} - -fn mir(){ - nil() -} - -pub fn main() { - mir(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_void_return.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_void_return.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_void_return.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/mir/mir_void_return.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn mir() -> (){ - let x = 1; - let mut y = 0; - while y < x { - y += 1 - } -} - -pub fn main() { - mir(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/auxiliary/two_macros_2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/auxiliary/two_macros_2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/auxiliary/two_macros_2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/auxiliary/two_macros_2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! macro_one { ($($t:tt)*) => ($($t)*) } - -macro_rules! macro_two { ($($t:tt)*) => ($($t)*) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_implicit_aux/mod.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_implicit_aux/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_implicit_aux/mod.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_implicit_aux/mod.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn foo() -> isize { 10 } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_implicit.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_implicit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_implicit.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_implicit.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty issue #37195 - -mod mod_dir_implicit_aux; - -pub fn main() { - assert_eq!(mod_dir_implicit_aux::foo(), 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_path2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_path2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_path2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_path2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty issue #37195 - -#[path = "mod_dir_simple"] -mod pancakes { - #[path = "test.rs"] - pub mod syrup; -} - -pub fn main() { - assert_eq!(pancakes::syrup::foo(), 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_path3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_path3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_path3.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_path3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty issue #37195 - -#[path = "mod_dir_simple"] -mod pancakes { - pub mod test; -} - -pub fn main() { - assert_eq!(pancakes::test::foo(), 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_path_multi.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_path_multi.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_path_multi.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_path_multi.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty issue #37195 - -#[path = "mod_dir_simple"] -mod biscuits { - pub mod test; -} - -#[path = "mod_dir_simple"] -mod gravy { - pub mod test; -} - -pub fn main() { - assert_eq!(biscuits::test::foo(), 10); - assert_eq!(gravy::test::foo(), 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_path.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_path.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_path.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_path.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty issue #37195 - -mod mod_dir_simple { - #[path = "test.rs"] - pub mod syrup; -} - -pub fn main() { - assert_eq!(mod_dir_simple::syrup::foo(), 10); - - #[path = "auxiliary"] - mod foo { - mod two_macros_2; - } - - #[path = "auxiliary"] - mod bar { - macro_rules! m { () => { mod two_macros_2; } } - m!(); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_recursive.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_recursive.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_recursive.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_recursive.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty issue #37195 - -// Testing that the parser for each file tracks its modules -// and paths independently. The load_another_mod module should -// not try to reuse the 'mod_dir_simple' path. - -mod mod_dir_simple { - pub mod load_another_mod; -} - -pub fn main() { - assert_eq!(mod_dir_simple::load_another_mod::test::foo(), 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_simple/load_another_mod.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_simple/load_another_mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_simple/load_another_mod.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_simple/load_another_mod.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[path = "test.rs"] -pub mod test; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_simple/test.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_simple/test.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_simple/test.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_simple/test.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn foo() -> isize { 10 } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_simple.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_simple.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_dir_simple.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty issue #37195 - -mod mod_dir_simple { - pub mod test; -} - -pub fn main() { - assert_eq!(mod_dir_simple::test::foo(), 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_file_aux.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_file_aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_file_aux.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_file_aux.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-test Not a test. Used by other tests - -pub fn foo() -> isize { 10 } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_file.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_file.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_file.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_file.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty issue #37195 - -// Testing that a plain .rs file can load modules from other source files - -mod mod_file_aux; - -pub fn main() { - assert_eq!(mod_file_aux::foo(), 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_file_with_path_attr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_file_with_path_attr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_file_with_path_attr.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod_file_with_path_attr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty issue #37195 - -// Testing that a plain .rs file can load modules from other source files - -#[path = "mod_file_aux.rs"] -mod m; - -pub fn main() { - assert_eq!(m::foo(), 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod-inside-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod-inside-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod-inside-fn.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod-inside-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn f() -> isize { - mod m { - pub fn g() -> isize { 720 } - } - - m::g() -} - -pub fn main() { - assert_eq!(f(), 720); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/module-polymorphism3-files/float-template/inst_f32.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/module-polymorphism3-files/float-template/inst_f32.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/module-polymorphism3-files/float-template/inst_f32.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/module-polymorphism3-files/float-template/inst_f32.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub type T = f32; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/module-polymorphism3-files/float-template/inst_f64.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/module-polymorphism3-files/float-template/inst_f64.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/module-polymorphism3-files/float-template/inst_f64.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/module-polymorphism3-files/float-template/inst_f64.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub type T = f64; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/module-polymorphism3-files/float-template/inst_float.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/module-polymorphism3-files/float-template/inst_float.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/module-polymorphism3-files/float-template/inst_float.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/module-polymorphism3-files/float-template/inst_float.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub type T = float; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod-view-items.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod-view-items.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod-view-items.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/modules/mod-view-items.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test view items inside non-file-level mods - -// This is a regression test for an issue where we were failing to -// pretty-print such view items. If that happens again, this should -// begin failing. - -// pretty-expanded FIXME #23616 - -mod m { - pub fn f() -> Vec { Vec::new() } -} - -pub fn main() { let _x = m::f(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-1-unique.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-1-unique.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-1-unique.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-1-unique.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -#[derive(Clone)] -struct Triple { - x: isize, - y: isize, - z: isize, -} - -fn test(x: bool, foo: Box) -> isize { - let bar = foo; - let mut y: Box; - if x { y = bar; } else { y = box Triple{x: 4, y: 5, z: 6}; } - return y.y; -} - -pub fn main() { - let x: Box<_> = box Triple{x: 1, y: 2, z: 3}; - assert_eq!(test(true, x.clone()), 2); - assert_eq!(test(true, x.clone()), 2); - assert_eq!(test(true, x.clone()), 2); - assert_eq!(test(false, x), 5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -struct X { x: isize, y: isize, z: isize } - -pub fn main() { let x: Box<_> = box X {x: 1, y: 2, z: 3}; let y = x; assert_eq!(y.y, 2); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-2-unique.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-2-unique.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-2-unique.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-2-unique.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -struct X { x: isize, y: isize, z: isize } - -pub fn main() { - let x: Box<_> = box X{x: 1, y: 2, z: 3}; - let y = x; - assert_eq!(y.y, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-3-unique.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-3-unique.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-3-unique.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-3-unique.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -#[derive(Clone)] -struct Triple { - x: isize, - y: isize, - z: isize, -} - -fn test(x: bool, foo: Box) -> isize { - let bar = foo; - let mut y: Box; - if x { y = bar; } else { y = box Triple {x: 4, y: 5, z: 6}; } - return y.y; -} - -pub fn main() { - let x: Box<_> = box Triple{x: 1, y: 2, z: 3}; - for _ in 0_usize..10000_usize { - assert_eq!(test(true, x.clone()), 2); - } - assert_eq!(test(false, x), 5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-4.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-4.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-4.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -struct Triple { a: isize, b: isize, c: isize } - -fn test(foo: Box) -> Box { - let foo = foo; - let bar = foo; - let baz = bar; - let quux = baz; - return quux; -} - -pub fn main() { - let x = box Triple{a: 1, b: 2, c: 3}; - let y = test(x); - assert_eq!(y.c, 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-4-unique.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-4-unique.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-4-unique.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-4-unique.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -struct Triple {a: isize, b: isize, c: isize} - -fn test(foo: Box) -> Box { - let foo = foo; - let bar = foo; - let baz = bar; - let quux = baz; - return quux; -} - -pub fn main() { - let x = box Triple{a: 1, b: 2, c: 3}; - let y = test(x); - assert_eq!(y.c, 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-arg-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-arg-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-arg-2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-arg-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -fn test(foo: Box>) { assert_eq!((*foo)[0], 10); } - -pub fn main() { - let x = box vec![10]; - // Test forgetting a local by move-in - test(x); - - // Test forgetting a temporary by move-in. - test(box vec![10]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-arg-2-unique.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-arg-2-unique.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-arg-2-unique.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-arg-2-unique.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -fn test(foo: Box> ) { assert_eq!((*foo)[0], 10); } - -pub fn main() { - let x = box vec![10]; - // Test forgetting a local by move-in - test(x); - - // Test forgetting a temporary by move-in. - test(box vec![10]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-arg.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-arg.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn test(foo: isize) { assert_eq!(foo, 10); } - -pub fn main() { let x = 10; test(x); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-nullary-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-nullary-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-nullary-fn.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-nullary-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #922 -// pretty-expanded FIXME #23616 - -fn f2(_thing: F) where F: FnOnce() { } - -fn f(thing: F) where F: FnOnce() { - f2(thing); -} - -pub fn main() { - f(|| {}); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-out-of-field.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-out-of-field.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-out-of-field.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-out-of-field.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::string::String; - -struct StringBuffer { - s: String, -} - -impl StringBuffer { - pub fn append(&mut self, v: &str) { - self.s.push_str(v); - } -} - -fn to_string(sb: StringBuffer) -> String { - sb.s -} - -pub fn main() { - let mut sb = StringBuffer { - s: String::new(), - }; - sb.append("Hello, "); - sb.append("World!"); - let str = to_string(sb); - assert_eq!(str, "Hello, World!"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/moves-based-on-type-capture-clause.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/moves-based-on-type-capture-clause.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/moves-based-on-type-capture-clause.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/moves-based-on-type-capture-clause.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::thread; - -pub fn main() { - let x = "Hello world!".to_string(); - thread::spawn(move|| { - println!("{}", x); - }).join(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-scalar.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-scalar.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-scalar.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/moves/move-scalar.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - - let y: isize = 42; - let mut x: isize; - x = y; - assert_eq!(x, 42); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-47153-generic-const.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-47153-generic-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-47153-generic-const.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-47153-generic-const.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Regression test for #47153: constants in a generic context (such as -// a trait) used to ICE. - -#![feature(nll)] -#![allow(warnings)] - -trait Foo { - const B: bool = true; -} - -struct Bar { x: T } - -impl Bar { - const B: bool = true; -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-47589.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-47589.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-47589.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-47589.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(nll)] - -pub struct DescriptorSet<'a> { - pub slots: Vec> -} - -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) -} - -fn main() { - let _x = DescriptorSet {slots: Vec::new()}; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-48623-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-48623-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-48623-closure.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-48623-closure.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(nll)] - -struct WithDrop; - -impl Drop for WithDrop { - fn drop(&mut self) {} -} - -fn reborrow_from_closure(r: &mut ()) -> &mut () { - let d = WithDrop; - (move || { d; &mut *r })() -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-48623-generator.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-48623-generator.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-48623-generator.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-48623-generator.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(nll)] -#![feature(generators, generator_trait)] - -struct WithDrop; - -impl Drop for WithDrop { - fn drop(&mut self) {} -} - -fn reborrow_from_generator(r: &mut ()) { - let d = WithDrop; - move || { d; yield; &mut *r }; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-50343.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-50343.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-50343.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-50343.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(nll)] -#![deny(unused_mut)] - -fn main() { - vec![42].iter().map(|_| ()).count(); - vec![(42, 22)].iter().map(|(_x, _y)| ()).count(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-50461-used-mut-from-moves.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-50461-used-mut-from-moves.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-50461-used-mut-from-moves.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-50461-used-mut-from-moves.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(nll)] -#![deny(unused_mut)] - -struct Foo { - pub value: i32 -} - -fn use_foo_mut(mut foo: Foo) { - foo = foo; - println!("{}", foo.value); -} - -fn main() { - use_foo_mut(Foo { value: 413 }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-53123-raw-pointer-cast.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-53123-raw-pointer-cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-53123-raw-pointer-cast.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/nll/issue-53123-raw-pointer-cast.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(nll)] -#![allow(unused_variables)] - -pub trait TryTransform { - fn try_transform(self, f: F) - where - Self: Sized, - F: FnOnce(Self); -} - -impl<'a, T> TryTransform for &'a mut T { - fn try_transform(self, f: F) - where - // The bug was that `Self: Sized` caused the lifetime of `this` to "extend" for all - // of 'a instead of only lasting as long as the binding is used (for just that line). - Self: Sized, - F: FnOnce(Self), - { - let this: *mut T = self as *mut T; - f(self); - } -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/nll/mutating_references.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/nll/mutating_references.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/nll/mutating_references.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/nll/mutating_references.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(nll)] - -struct List { - value: T, - next: Option>>, -} - -fn to_refs(mut list: &mut List) -> Vec<&mut T> { - let mut result = vec![]; - loop { - result.push(&mut list.value); - if let Some(n) = list.next.as_mut() { - list = n; - } else { - return result; - } - } -} - -fn main() { - let mut list = List { value: 1, next: None }; - let vec = to_refs(&mut list); - assert_eq!(vec![&mut 1], vec); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/nll/process_or_insert_default.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/nll/process_or_insert_default.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/nll/process_or_insert_default.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/nll/process_or_insert_default.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(nll)] - -use std::collections::HashMap; - -fn process_or_insert_default(map: &mut HashMap, key: usize) { - match map.get_mut(&key) { - Some(value) => { - process(value); - } - None => { - map.insert(key, "".to_string()); - } - } -} - -fn process(x: &str) { - assert_eq!(x, "Hello, world"); -} - -fn main() { - let map = &mut HashMap::new(); - map.insert(22, format!("Hello, world")); - map.insert(44, format!("Goodbye, world")); - process_or_insert_default(map, 22); - process_or_insert_default(map, 66); - assert_eq!(map[&66], ""); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/nll/rc-loop.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/nll/rc-loop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/nll/rc-loop.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/nll/rc-loop.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// A test for something that NLL enables. It sometimes happens that -// the `while let` pattern makes some borrows from a variable (in this -// case, `x`) that you need in order to compute the next value for -// `x`. The lexical checker makes this very painful. The NLL checker -// does not. - -#![feature(nll)] - -use std::rc::Rc; - -#[derive(Debug, PartialEq, Eq)] -enum Foo { - Base(usize), - Next(Rc), -} - -fn find_base(mut x: Rc) -> Rc { - while let Foo::Next(n) = &*x { - x = n.clone(); - } - x -} - -fn main() { - let chain = Rc::new(Foo::Next(Rc::new(Foo::Base(44)))); - let base = find_base(chain); - assert_eq!(&*base, &Foo::Base(44)); -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/foors_mod/inner_foors_mod/innest.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/foors_mod/inner_foors_mod/innest.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/foors_mod/inner_foors_mod/innest.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/foors_mod/inner_foors_mod/innest.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/foors_mod/inner_foors_mod.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/foors_mod/inner_foors_mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/foors_mod/inner_foors_mod.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/foors_mod/inner_foors_mod.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod innest; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/innest.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/innest.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/innest.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/innest.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/mod.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/mod.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/mod.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod innest; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/foors_mod.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/foors_mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/foors_mod.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/foors_mod.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// -// ignore-test: not a test, used by non_modrs_mods.rs - -pub mod inner_modrs_mod; -pub mod inner_foors_mod; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod/innest.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod/innest.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod/innest.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod/innest.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod innest; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/innest.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/innest.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/innest.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/innest.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/mod.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/mod.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/mod.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod innest; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/modrs_mod/mod.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/modrs_mod/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/modrs_mod/mod.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/modrs_mod/mod.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod inner_modrs_mod; -pub mod inner_foors_mod; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/non_modrs_mods.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/non_modrs_mods.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/non_modrs_mods.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/non_modrs_mods.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// -// ignore-pretty issue #37195 -#![feature(non_modrs_mods)] - -pub mod modrs_mod; -pub mod foors_mod; - -#[path = "some_crazy_attr_mod_dir/arbitrary_name.rs"] -pub mod attr_mod; - -pub fn main() { - modrs_mod::inner_modrs_mod::innest::foo(); - modrs_mod::inner_foors_mod::innest::foo(); - foors_mod::inner_modrs_mod::innest::foo(); - foors_mod::inner_foors_mod::innest::foo(); - attr_mod::inner_modrs_mod::innest::foo(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/arbitrary_name.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/arbitrary_name.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/arbitrary_name.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/arbitrary_name.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod inner_modrs_mod; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/innest.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/innest.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/innest.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/innest.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/mod.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/mod.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/inner_modrs_mod/mod.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod innest; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/arith-0.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/arith-0.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/arith-0.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/arith-0.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -pub fn main() { - let a: isize = 10; - println!("{}", a); - assert_eq!(a * (a - 1), 90); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/arith-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/arith-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/arith-1.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/arith-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -pub fn main() { - let i32_a: isize = 10; - assert_eq!(i32_a, 10); - assert_eq!(i32_a - 10, 0); - assert_eq!(i32_a / 10, 1); - assert_eq!(i32_a - 20, -10); - assert_eq!(i32_a << 10, 10240); - assert_eq!(i32_a << 16, 655360); - assert_eq!(i32_a * 16, 160); - assert_eq!(i32_a * i32_a * i32_a, 1000); - assert_eq!(i32_a * i32_a * i32_a * i32_a, 10000); - assert_eq!(i32_a * i32_a / i32_a * i32_a, 100); - assert_eq!(i32_a * (i32_a - 1) << (2 + i32_a as usize), 368640); - let i32_b: isize = 0x10101010; - assert_eq!(i32_b + 1 - 1, i32_b); - assert_eq!(i32_b << 1, i32_b << 1); - assert_eq!(i32_b >> 1, i32_b >> 1); - assert_eq!(i32_b & i32_b << 1, 0); - println!("{}", i32_b | i32_b << 1); - assert_eq!(i32_b | i32_b << 1, 0x30303030); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/arith-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/arith-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/arith-2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/arith-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - -pub fn main() { - let i32_c: isize = 0x10101010; - assert_eq!(i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3), - i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/arith-unsigned.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/arith-unsigned.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/arith-unsigned.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/arith-unsigned.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(unused_comparisons)] - -// Unsigned integer operations -pub fn main() { - assert!((0u8 < 255u8)); - assert!((0u8 <= 255u8)); - assert!((255u8 > 0u8)); - assert!((255u8 >= 0u8)); - assert_eq!(250u8 / 10u8, 25u8); - assert_eq!(255u8 % 10u8, 5u8); - assert!((0u16 < 60000u16)); - assert!((0u16 <= 60000u16)); - assert!((60000u16 > 0u16)); - assert!((60000u16 >= 0u16)); - assert_eq!(60000u16 / 10u16, 6000u16); - assert_eq!(60005u16 % 10u16, 5u16); - assert!((0u32 < 4000000000u32)); - assert!((0u32 <= 4000000000u32)); - assert!((4000000000u32 > 0u32)); - assert!((4000000000u32 >= 0u32)); - assert_eq!(4000000000u32 / 10u32, 400000000u32); - assert_eq!(4000000005u32 % 10u32, 5u32); - // 64-bit numbers have some flakiness yet. Not tested - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/div-mod.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/div-mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/div-mod.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/div-mod.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - - -pub fn main() { - let x: isize = 15; - let y: isize = 5; - assert_eq!(x / 5, 3); - assert_eq!(x / 4, 3); - assert_eq!(x / 3, 5); - assert_eq!(x / y, 3); - assert_eq!(15 / y, 3); - assert_eq!(x % 5, 0); - assert_eq!(x % 4, 3); - assert_eq!(x % 3, 0); - assert_eq!(x % y, 0); - assert_eq!(15 % y, 0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - -pub fn main() { - let a = 1.5e6f64; - let b = 1.5E6f64; - let c = 1e6f64; - let d = 1E6f64; - let e = 3.0f32; - let f = 5.9f64; - let g = 1e6f32; - let h = 1.0e7f64; - let i = 1.0E7f64; - let j = 3.1e+9f64; - let k = 3.2e-10f64; - assert_eq!(a, b); - assert!((c < b)); - assert_eq!(c, d); - assert!((e < g)); - assert!((f < h)); - assert_eq!(g, 1000000.0f32); - assert_eq!(h, i); - assert!((j > k)); - assert!((k < a)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float-int-invalid-const-cast.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float-int-invalid-const-cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float-int-invalid-const-cast.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float-int-invalid-const-cast.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no i128 support - -#![deny(const_err)] - -use std::{f32, f64}; - -// Forces evaluation of constants, triggering hard error -fn force(_: T) {} - -fn main() { - { const X: u16 = -1. as u16; force(X); } - { const X: u128 = -100. as u128; force(X); } - - { const X: i8 = f32::NAN as i8; force(X); } - { const X: i32 = f32::NAN as i32; force(X); } - { const X: u64 = f32::NAN as u64; force(X); } - { const X: u128 = f32::NAN as u128; force(X); } - - { const X: i8 = f32::INFINITY as i8; force(X); } - { const X: u32 = f32::INFINITY as u32; force(X); } - { const X: i128 = f32::INFINITY as i128; force(X); } - { const X: u128 = f32::INFINITY as u128; force(X); } - - { const X: u8 = f32::NEG_INFINITY as u8; force(X); } - { const X: u16 = f32::NEG_INFINITY as u16; force(X); } - { const X: i64 = f32::NEG_INFINITY as i64; force(X); } - { const X: i128 = f32::NEG_INFINITY as i128; force(X); } - - { const X: i8 = f64::NAN as i8; force(X); } - { const X: i32 = f64::NAN as i32; force(X); } - { const X: u64 = f64::NAN as u64; force(X); } - { const X: u128 = f64::NAN as u128; force(X); } - - { const X: i8 = f64::INFINITY as i8; force(X); } - { const X: u32 = f64::INFINITY as u32; force(X); } - { const X: i128 = f64::INFINITY as i128; force(X); } - { const X: u128 = f64::INFINITY as u128; force(X); } - - { const X: u8 = f64::NEG_INFINITY as u8; force(X); } - { const X: u16 = f64::NEG_INFINITY as u16; force(X); } - { const X: i64 = f64::NEG_INFINITY as i64; force(X); } - { const X: i128 = f64::NEG_INFINITY as i128; force(X); } - - { const X: u8 = 256. as u8; force(X); } - { const X: i8 = -129. as i8; force(X); } - { const X: i8 = 128. as i8; force(X); } - { const X: i32 = 2147483648. as i32; force(X); } - { const X: i32 = -2147483904. as i32; force(X); } - { const X: u32 = 4294967296. as u32; force(X); } - { const X: u128 = 1e40 as u128; force(X); } - { const X: i128 = 1e40 as i128; force(X); } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float-literal-inference.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float-literal-inference.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float-literal-inference.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float-literal-inference.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct S { - z: f64 -} - -pub fn main() { - let x: f32 = 4.0; - println!("{}", x); - let y: f64 = 64.0; - println!("{}", y); - let z = S { z: 1.0 }; - println!("{}", z.z); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/floatlits.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/floatlits.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/floatlits.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/floatlits.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - -pub fn main() { - let f = 4.999999999999f64; - assert!((f > 4.90f64)); - assert!((f < 5.0f64)); - let g = 4.90000000001e-10f64; - assert!((g > 5e-11f64)); - assert!((g < 5e-9f64)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float_math.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float_math.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float_math.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float_math.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(core_intrinsics)] - -use std::intrinsics::{fadd_fast, fsub_fast, fmul_fast, fdiv_fast, frem_fast}; - -#[inline(never)] -pub fn test_operations(a: f64, b: f64) { - // make sure they all map to the correct operation - unsafe { - assert_eq!(fadd_fast(a, b), a + b); - assert_eq!(fsub_fast(a, b), a - b); - assert_eq!(fmul_fast(a, b), a * b); - assert_eq!(fdiv_fast(a, b), a / b); - assert_eq!(frem_fast(a, b), a % b); - } -} - -fn main() { - test_operations(1., 2.); - test_operations(10., 5.); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float-nan.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float-nan.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float-nan.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float-nan.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::f64; - -pub fn main() { - let nan: f64 = f64::NAN; - assert!((nan).is_nan()); - - let inf: f64 = f64::INFINITY; - let neg_inf: f64 = -f64::INFINITY; - assert_eq!(-inf, neg_inf); - - assert!( nan != nan); - assert!( nan != -nan); - assert!(-nan != -nan); - assert!(-nan != nan); - - assert!( nan != 1.); - assert!( nan != 0.); - assert!( nan != inf); - assert!( nan != -inf); - - assert!( 1. != nan); - assert!( 0. != nan); - assert!( inf != nan); - assert!(-inf != nan); - - assert!(!( nan == nan)); - assert!(!( nan == -nan)); - assert!(!( nan == 1.)); - assert!(!( nan == 0.)); - assert!(!( nan == inf)); - assert!(!( nan == -inf)); - assert!(!( 1. == nan)); - assert!(!( 0. == nan)); - assert!(!( inf == nan)); - assert!(!(-inf == nan)); - assert!(!(-nan == nan)); - assert!(!(-nan == -nan)); - - assert!(!( nan > nan)); - assert!(!( nan > -nan)); - assert!(!( nan > 0.)); - assert!(!( nan > inf)); - assert!(!( nan > -inf)); - assert!(!( 0. > nan)); - assert!(!( inf > nan)); - assert!(!(-inf > nan)); - assert!(!(-nan > nan)); - - assert!(!(nan < 0.)); - assert!(!(nan < 1.)); - assert!(!(nan < -1.)); - assert!(!(nan < inf)); - assert!(!(nan < -inf)); - assert!(!(nan < nan)); - assert!(!(nan < -nan)); - - assert!(!( 0. < nan)); - assert!(!( 1. < nan)); - assert!(!( -1. < nan)); - assert!(!( inf < nan)); - assert!(!(-inf < nan)); - assert!(!(-nan < nan)); - - assert!((nan + inf).is_nan()); - assert!((nan + -inf).is_nan()); - assert!((nan + 0.).is_nan()); - assert!((nan + 1.).is_nan()); - assert!((nan * 1.).is_nan()); - assert!((nan / 1.).is_nan()); - assert!((nan / 0.).is_nan()); - assert!((0.0/0.0f64).is_nan()); - assert!((-inf + inf).is_nan()); - assert!((inf - inf).is_nan()); - - assert!(!(-1.0f64).is_nan()); - assert!(!(0.0f64).is_nan()); - assert!(!(0.1f64).is_nan()); - assert!(!(1.0f64).is_nan()); - assert!(!(inf).is_nan()); - assert!(!(-inf).is_nan()); - assert!(!(1./-inf).is_nan()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn main() { - let pi = 3.1415927f64; - println!("{}", -pi * (pi + 2.0 / pi) - pi * 5.0); - if pi == 5.0 || pi < 10.0 || pi <= 2.0 || pi != 22.0 / 7.0 || pi >= 10.0 - || pi > 1.0 { - println!("yes"); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float-signature.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float-signature.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float-signature.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/float-signature.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -pub fn main() { - fn foo(n: f64) -> f64 { return n + 0.12345; } - let n: f64 = 0.1; - let m: f64 = foo(n); - println!("{}", m); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/i128-ffi.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/i128-ffi.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/i128-ffi.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/i128-ffi.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(improper_ctypes)] - -// MSVC doesn't support 128 bit integers, and other Windows -// C compilers have very inconsistent views on how the ABI -// should look like. - -// ignore-windows -// ignore-32bit - -#[link(name = "rust_test_helpers", kind = "static")] -extern "C" { - fn identity(f: u128) -> u128; - fn square(f: i128) -> i128; - fn sub(f: i128, f: i128) -> i128; -} - -fn main() { - unsafe { - let a = 0x734C_C2F2_A521; - let b = 0x33EE_0E2A_54E2_59DA_A0E7_8E41; - let b_out = identity(b); - assert_eq!(b, b_out); - let a_square = square(a); - assert_eq!(b, a_square as u128); - let k = 0x1234_5678_9ABC_DEFF_EDCB_A987_6543_210; - let k_d = 0x2468_ACF1_3579_BDFF_DB97_530E_CA86_420; - let k_out = sub(k_d, k); - assert_eq!(k, k_out); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/i128.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/i128.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/i128.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/i128.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(overflowing_literals)] - -// ignore-emscripten i128 doesn't work - -// compile-flags: -Z borrowck=compare - -#![feature(test)] - -extern crate test; -use test::black_box as b; - -fn main() { - let x: i128 = -1; - assert_eq!(0, !x); - let y: i128 = -2; - assert_eq!(!1, y); - let z: i128 = 0xABCD_EF; - assert_eq!(z * z, 0x734C_C2F2_A521); - assert_eq!(z * z * z * z, 0x33EE_0E2A_54E2_59DA_A0E7_8E41); - assert_eq!(-z * -z, 0x734C_C2F2_A521); - assert_eq!(-z * -z * -z * -z, 0x33EE_0E2A_54E2_59DA_A0E7_8E41); - assert_eq!(-z + -z + -z + -z, -0x2AF3_7BC); - let k: i128 = -0x1234_5678_9ABC_DEFF_EDCB_A987_6543_210; - assert_eq!(k + k, -0x2468_ACF1_3579_BDFF_DB97_530E_CA86_420); - assert_eq!(0, k - k); - assert_eq!(-0x1234_5678_9ABC_DEFF_EDCB_A987_5A86_421, k + z); - assert_eq!(-0x1000_0000_0000_0000_0000_0000_0000_000, - k + 0x234_5678_9ABC_DEFF_EDCB_A987_6543_210); - assert_eq!(-0x6EF5_DE4C_D3BC_2AAA_3BB4_CC5D_D6EE_8, k / 42); - assert_eq!(-k, k / -1); - assert_eq!(-0x91A2_B3C4_D5E6_F8, k >> 65); - assert_eq!(-0xFDB9_7530_ECA8_6420_0000_0000_0000_0000, k << 65); - assert!(k < z); - assert!(y > k); - assert!(y < x); - assert_eq!(x as i64, -1); - assert_eq!(z as i64, 0xABCD_EF); - assert_eq!(k as i64, -0xFEDC_BA98_7654_3210); - assert_eq!(k as u128, 0xFEDC_BA98_7654_3210_0123_4567_89AB_CDF0); - assert_eq!(-k as u128, 0x1234_5678_9ABC_DEFF_EDCB_A987_6543_210); - assert_eq!((-z as f64) as i128, -z); - assert_eq!((-z as f32) as i128, -z); - assert_eq!((-z as f64 * 16.0) as i128, -z * 16); - assert_eq!((-z as f32 * 16.0) as i128, -z * 16); - // Same stuff as above, but blackboxed, to force use of intrinsics - let x: i128 = b(-1); - assert_eq!(0, !x); - let y: i128 = b(-2); - assert_eq!(!1, y); - let z: i128 = b(0xABCD_EF); - assert_eq!(z * z, 0x734C_C2F2_A521); - assert_eq!(z * z * z * z, 0x33EE_0E2A_54E2_59DA_A0E7_8E41); - assert_eq!(-z * -z, 0x734C_C2F2_A521); - assert_eq!(-z * -z * -z * -z, 0x33EE_0E2A_54E2_59DA_A0E7_8E41); - assert_eq!(-z + -z + -z + -z, -0x2AF3_7BC); - let k: i128 = b(-0x1234_5678_9ABC_DEFF_EDCB_A987_6543_210); - assert_eq!(k + k, -0x2468_ACF1_3579_BDFF_DB97_530E_CA86_420); - assert_eq!(0, k - k); - assert_eq!(-0x1234_5678_9ABC_DEFF_EDCB_A987_5A86_421, k + z); - assert_eq!(-0x1000_0000_0000_0000_0000_0000_0000_000, - k + 0x234_5678_9ABC_DEFF_EDCB_A987_6543_210); - assert_eq!(-0x6EF5_DE4C_D3BC_2AAA_3BB4_CC5D_D6EE_8, k / 42); - assert_eq!(-k, k / -1); - assert_eq!(-0x91A2_B3C4_D5E6_F8, k >> 65); - assert_eq!(-0xFDB9_7530_ECA8_6420_0000_0000_0000_0000, k << 65); - assert!(k < z); - assert!(y > k); - assert!(y < x); - assert_eq!(x as i64, -1); - assert_eq!(z as i64, 0xABCD_EF); - assert_eq!(k as i64, -0xFEDC_BA98_7654_3210); - assert_eq!(k as u128, 0xFEDC_BA98_7654_3210_0123_4567_89AB_CDF0); - assert_eq!(-k as u128, 0x1234_5678_9ABC_DEFF_EDCB_A987_6543_210); - assert_eq!((-z as f64) as i128, -z); - assert_eq!((-z as f32) as i128, -z); - assert_eq!((-z as f64 * 16.0) as i128, -z * 16); - assert_eq!((-z as f32 * 16.0) as i128, -z * 16); - // formatting - let j: i128 = -(1 << 67); - assert_eq!("-147573952589676412928", format!("{}", j)); - assert_eq!("fffffffffffffff80000000000000000", format!("{:x}", j)); - assert_eq!("3777777777777777777760000000000000000000000", format!("{:o}", j)); - assert_eq!("1111111111111111111111111111111111111111111111111111111111111\ - 0000000000000000000000000000000000000000000000000000000000000000000", - format!("{:b}", j)); - assert_eq!("-147573952589676412928", format!("{:?}", j)); - // common traits - assert_eq!(x, b(x.clone())); - // overflow checks - assert_eq!((-z).checked_mul(-z), Some(0x734C_C2F2_A521)); - assert_eq!((z).checked_mul(z), Some(0x734C_C2F2_A521)); - assert_eq!((k).checked_mul(k), None); - let l: i128 = b(i128::min_value()); - let o: i128 = b(17); - assert_eq!(l.checked_sub(b(2)), None); - assert_eq!(l.checked_add(l), None); - assert_eq!((-(l + 1)).checked_add(2), None); - assert_eq!(l.checked_sub(l), Some(0)); - assert_eq!(b(1u128).checked_shl(b(127)), Some(1 << 127)); - assert_eq!(o.checked_shl(b(128)), None); - - // https://github.com/rust-lang/rust/issues/41228 - assert_eq!(b(-87559967289969187895646876466835277875_i128) / - b(84285771033834995895337664386045050880_i128), - -1i128); - - // iter-arithmetic traits - assert_eq!(10i128, [1i128, 2, 3, 4].iter().sum()); - assert_eq!(24i128, [1i128, 2, 3, 4].iter().product()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/i32-sub.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/i32-sub.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/i32-sub.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/i32-sub.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - - -pub fn main() { let mut x: i32 = -400; x = 0 - x; assert_eq!(x, 400); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/i8-incr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/i8-incr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/i8-incr.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/i8-incr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - - -pub fn main() { - let mut x: i8 = -12; - let y: i8 = -12; - x = x + 1; - x = x - 1; - assert_eq!(x, y); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/int-abs-overflow.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/int-abs-overflow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/int-abs-overflow.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/int-abs-overflow.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: -Z force-overflow-checks=on -// ignore-emscripten no threads support - -use std::thread; - -fn main() { - assert!(thread::spawn(|| i8::min_value().abs()).join().is_err()); - assert!(thread::spawn(|| i16::min_value().abs()).join().is_err()); - assert!(thread::spawn(|| i32::min_value().abs()).join().is_err()); - assert!(thread::spawn(|| i64::min_value().abs()).join().is_err()); - assert!(thread::spawn(|| isize::min_value().abs()).join().is_err()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/integer-literal-radix.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/integer-literal-radix.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/integer-literal-radix.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/integer-literal-radix.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub fn main() { - let a = 0xBEEF_isize; - let b = 0o755_isize; - let c = 0b10101_isize; - let d = -0xBEEF_isize; - let e = -0o755_isize; - let f = -0b10101_isize; - - assert_eq!(a, 48879); - assert_eq!(b, 493); - assert_eq!(c, 21); - assert_eq!(d, -48879); - assert_eq!(e, -493); - assert_eq!(f, -21); - - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/integer-literal-suffix-inference-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/integer-literal-suffix-inference-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/integer-literal-suffix-inference-2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/integer-literal-suffix-inference-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn foo(_: *const ()) {} - -fn main() { - let a = 3; - foo(&a as *const _ as *const ()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/integer-literal-suffix-inference-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/integer-literal-suffix-inference-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/integer-literal-suffix-inference-3.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/integer-literal-suffix-inference-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() { - println!("{}", std::mem::size_of_val(&1)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/integer-literal-suffix-inference.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/integer-literal-suffix-inference.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/integer-literal-suffix-inference.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/integer-literal-suffix-inference.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub fn main() { - fn id_i8(n: i8) -> i8 { n } - fn id_i16(n: i16) -> i16 { n } - fn id_i32(n: i32) -> i32 { n } - fn id_i64(n: i64) -> i64 { n } - - fn id_uint(n: usize) -> usize { n } - fn id_u8(n: u8) -> u8 { n } - fn id_u16(n: u16) -> u16 { n } - fn id_u32(n: u32) -> u32 { n } - fn id_u64(n: u64) -> u64 { n } - - let _i: i8 = -128; - let j = -128; - id_i8(j); - id_i8(-128); - - let _i: i16 = -32_768; - let j = -32_768; - id_i16(j); - id_i16(-32_768); - - let _i: i32 = -2_147_483_648; - let j = -2_147_483_648; - id_i32(j); - id_i32(-2_147_483_648); - - let _i: i64 = -9_223_372_036_854_775_808; - let j = -9_223_372_036_854_775_808; - id_i64(j); - id_i64(-9_223_372_036_854_775_808); - - let _i: usize = 1; - let j = 1; - id_uint(j); - id_uint(1); - - let _i: u8 = 255; - let j = 255; - id_u8(j); - id_u8(255); - - let _i: u16 = 65_535; - let j = 65_535; - id_u16(j); - id_u16(65_535); - - let _i: u32 = 4_294_967_295; - let j = 4_294_967_295; - id_u32(j); - id_u32(4_294_967_295); - - let _i: u64 = 18_446_744_073_709_551_615; - let j = 18_446_744_073_709_551_615; - id_u64(j); - id_u64(18_446_744_073_709_551_615); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/int.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/int.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/int.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/int.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - -// pretty-expanded FIXME #23616 - -pub fn main() { let _x: isize = 10; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/next-power-of-two-overflow-debug.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/next-power-of-two-overflow-debug.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/next-power-of-two-overflow-debug.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/next-power-of-two-overflow-debug.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: -C debug_assertions=yes -// ignore-wasm32-bare compiled with panic=abort by default -// ignore-emscripten dies with an LLVM error - -use std::panic; - -fn main() { - macro_rules! overflow_test { - ($t:ident) => ( - let r = panic::catch_unwind(|| { - ($t::max_value()).next_power_of_two() - }); - assert!(r.is_err()); - - let r = panic::catch_unwind(|| { - (($t::max_value() >> 1) + 2).next_power_of_two() - }); - assert!(r.is_err()); - ) - } - overflow_test!(u8); - overflow_test!(u16); - overflow_test!(u32); - overflow_test!(u64); - overflow_test!(u128); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/next-power-of-two-overflow-ndebug.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/next-power-of-two-overflow-ndebug.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/next-power-of-two-overflow-ndebug.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/next-power-of-two-overflow-ndebug.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: -C debug_assertions=no -// ignore-emscripten dies with an LLVM error - -fn main() { - for i in 129..256 { - assert_eq!((i as u8).next_power_of_two(), 0); - } - - assert_eq!(((1u16 << 15) + 1).next_power_of_two(), 0); - assert_eq!(((1u32 << 31) + 1).next_power_of_two(), 0); - assert_eq!(((1u64 << 63) + 1).next_power_of_two(), 0); - assert_eq!(((1u128 << 127) + 1).next_power_of_two(), 0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/numeric-method-autoexport.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/numeric-method-autoexport.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/numeric-method-autoexport.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/numeric-method-autoexport.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This file is intended to test only that methods are automatically -// reachable for each numeric type, for each exported impl, with no imports -// necessary. Testing the methods of the impls is done within the source -// file for each numeric type. - -use std::ops::Add; - -pub fn main() { -// ints - // num - assert_eq!(15_isize.add(6_isize), 21_isize); - assert_eq!(15_i8.add(6i8), 21_i8); - assert_eq!(15_i16.add(6i16), 21_i16); - assert_eq!(15_i32.add(6i32), 21_i32); - assert_eq!(15_i64.add(6i64), 21_i64); - -// uints - // num - assert_eq!(15_usize.add(6_usize), 21_usize); - assert_eq!(15_u8.add(6u8), 21_u8); - assert_eq!(15_u16.add(6u16), 21_u16); - assert_eq!(15_u32.add(6u32), 21_u32); - assert_eq!(15_u64.add(6u64), 21_u64); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/num-wrapping.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/num-wrapping.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/num-wrapping.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/num-wrapping.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,456 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// compile-flags: -C debug-assertions -// -// Test std::num::Wrapping for {uN, iN, usize, isize} - -#![feature(test)] - -extern crate test; - -use std::num::Wrapping; -use std::ops::{ - Add, Sub, Mul, Div, Rem, BitXor, BitOr, BitAnd, - AddAssign, SubAssign, MulAssign, DivAssign, RemAssign, BitXorAssign, BitOrAssign, BitAndAssign, - Shl, Shr, ShlAssign, ShrAssign -}; -use test::black_box; - -macro_rules! int_modules { - ($(($name:ident, $size:expr),)*) => ($( - mod $name { - pub const BITS: usize = $size; - pub use std::$name::*; - } - )*) -} - -int_modules! { - (i8, 8), - (i16, 16), - (i32, 32), - (i64, 64), - (u8, 8), - (u16, 16), - (u32, 32), - (u64, 64), -} - -#[cfg(target_pointer_width = "32")] -int_modules! { - (isize, 32), - (usize, 32), -} - -#[cfg(target_pointer_width = "64")] -int_modules! { - (isize, 64), - (usize, 64), -} - -fn main() { - test_ops(); - test_op_assigns(); - test_sh_ops(); - test_sh_op_assigns(); -} - -fn test_ops() { - macro_rules! op_test { - ($op:ident ($lhs:expr, $rhs:expr) == $ans:expr) => { - assert_eq!(black_box(Wrapping($lhs).$op(Wrapping($rhs))), Wrapping($ans)); - // FIXME(30524): uncomment this test when it's implemented - // assert_eq!(black_box(Wrapping($lhs).$op($rhs)), Wrapping($ans)); - } - } - - op_test!(add(i8::MAX, 1) == i8::MIN); - op_test!(add(i16::MAX, 1) == i16::MIN); - op_test!(add(i32::MAX, 1) == i32::MIN); - op_test!(add(i64::MAX, 1) == i64::MIN); - op_test!(add(isize::MAX, 1) == isize::MIN); - - op_test!(add(u8::MAX, 1) == 0); - op_test!(add(u16::MAX, 1) == 0); - op_test!(add(u32::MAX, 1) == 0); - op_test!(add(u64::MAX, 1) == 0); - op_test!(add(usize::MAX, 1) == 0); - - - op_test!(sub(i8::MIN, 1) == i8::MAX); - op_test!(sub(i16::MIN, 1) == i16::MAX); - op_test!(sub(i32::MIN, 1) == i32::MAX); - op_test!(sub(i64::MIN, 1) == i64::MAX); - op_test!(sub(isize::MIN, 1) == isize::MAX); - - op_test!(sub(0u8, 1) == u8::MAX); - op_test!(sub(0u16, 1) == u16::MAX); - op_test!(sub(0u32, 1) == u32::MAX); - op_test!(sub(0u64, 1) == u64::MAX); - op_test!(sub(0usize, 1) == usize::MAX); - - - op_test!(mul(i8::MAX, 2) == -2); - op_test!(mul(i16::MAX, 2) == -2); - op_test!(mul(i32::MAX, 2) == -2); - op_test!(mul(i64::MAX, 2) == -2); - op_test!(mul(isize::MAX, 2) == -2); - - op_test!(mul(u8::MAX, 2) == u8::MAX - 1); - op_test!(mul(u16::MAX, 2) == u16::MAX - 1); - op_test!(mul(u32::MAX, 2) == u32::MAX - 1); - op_test!(mul(u64::MAX, 2) == u64::MAX - 1); - op_test!(mul(usize::MAX, 2) == usize::MAX - 1); - - - op_test!(div(i8::MIN, -1) == i8::MIN); - op_test!(div(i16::MIN, -1) == i16::MIN); - op_test!(div(i32::MIN, -1) == i32::MIN); - op_test!(div(i64::MIN, -1) == i64::MIN); - op_test!(div(isize::MIN, -1) == isize::MIN); - - - op_test!(rem(i8::MIN, -1) == 0); - op_test!(rem(i16::MIN, -1) == 0); - op_test!(rem(i32::MIN, -1) == 0); - op_test!(rem(i64::MIN, -1) == 0); - op_test!(rem(isize::MIN, -1) == 0); - - // these are not that interesting, just testing to make sure they are implemented correctly - op_test!(bitxor(0b101010i8, 0b100110) == 0b001100); - op_test!(bitxor(0b101010i16, 0b100110) == 0b001100); - op_test!(bitxor(0b101010i32, 0b100110) == 0b001100); - op_test!(bitxor(0b101010i64, 0b100110) == 0b001100); - op_test!(bitxor(0b101010isize, 0b100110) == 0b001100); - - op_test!(bitxor(0b101010u8, 0b100110) == 0b001100); - op_test!(bitxor(0b101010u16, 0b100110) == 0b001100); - op_test!(bitxor(0b101010u32, 0b100110) == 0b001100); - op_test!(bitxor(0b101010u64, 0b100110) == 0b001100); - op_test!(bitxor(0b101010usize, 0b100110) == 0b001100); - - - op_test!(bitor(0b101010i8, 0b100110) == 0b101110); - op_test!(bitor(0b101010i16, 0b100110) == 0b101110); - op_test!(bitor(0b101010i32, 0b100110) == 0b101110); - op_test!(bitor(0b101010i64, 0b100110) == 0b101110); - op_test!(bitor(0b101010isize, 0b100110) == 0b101110); - - op_test!(bitor(0b101010u8, 0b100110) == 0b101110); - op_test!(bitor(0b101010u16, 0b100110) == 0b101110); - op_test!(bitor(0b101010u32, 0b100110) == 0b101110); - op_test!(bitor(0b101010u64, 0b100110) == 0b101110); - op_test!(bitor(0b101010usize, 0b100110) == 0b101110); - - - op_test!(bitand(0b101010i8, 0b100110) == 0b100010); - op_test!(bitand(0b101010i16, 0b100110) == 0b100010); - op_test!(bitand(0b101010i32, 0b100110) == 0b100010); - op_test!(bitand(0b101010i64, 0b100110) == 0b100010); - op_test!(bitand(0b101010isize, 0b100110) == 0b100010); - - op_test!(bitand(0b101010u8, 0b100110) == 0b100010); - op_test!(bitand(0b101010u16, 0b100110) == 0b100010); - op_test!(bitand(0b101010u32, 0b100110) == 0b100010); - op_test!(bitand(0b101010u64, 0b100110) == 0b100010); - op_test!(bitand(0b101010usize, 0b100110) == 0b100010); -} - -fn test_op_assigns() { - macro_rules! op_assign_test { - ($op:ident ($initial:expr, $rhs:expr) == $ans:expr) => { - { - let mut tmp = Wrapping($initial); - tmp = black_box(tmp); - tmp.$op(Wrapping($rhs)); - assert_eq!(black_box(tmp), Wrapping($ans)); - } - - // also test that a &Wrapping right-hand side is possible - { - let mut tmp = Wrapping($initial); - tmp = black_box(tmp); - tmp.$op(&Wrapping($rhs)); - assert_eq!(black_box(tmp), Wrapping($ans)); - } - - // FIXME(30524): Uncomment this test - /* - { - let mut tmp = Wrapping($initial); - tmp = black_box(tmp); - tmp.$op($rhs); - assert_eq!(black_box(tmp), Wrapping($ans)); - } - */ - } - } - op_assign_test!(add_assign(i8::MAX, 1) == i8::MIN); - op_assign_test!(add_assign(i16::MAX, 1) == i16::MIN); - op_assign_test!(add_assign(i32::MAX, 1) == i32::MIN); - op_assign_test!(add_assign(i64::MAX, 1) == i64::MIN); - op_assign_test!(add_assign(isize::MAX, 1) == isize::MIN); - - op_assign_test!(add_assign(u8::MAX, 1) == u8::MIN); - op_assign_test!(add_assign(u16::MAX, 1) == u16::MIN); - op_assign_test!(add_assign(u32::MAX, 1) == u32::MIN); - op_assign_test!(add_assign(u64::MAX, 1) == u64::MIN); - op_assign_test!(add_assign(usize::MAX, 1) == usize::MIN); - - - op_assign_test!(sub_assign(i8::MIN, 1) == i8::MAX); - op_assign_test!(sub_assign(i16::MIN, 1) == i16::MAX); - op_assign_test!(sub_assign(i32::MIN, 1) == i32::MAX); - op_assign_test!(sub_assign(i64::MIN, 1) == i64::MAX); - op_assign_test!(sub_assign(isize::MIN, 1) == isize::MAX); - - op_assign_test!(sub_assign(u8::MIN, 1) == u8::MAX); - op_assign_test!(sub_assign(u16::MIN, 1) == u16::MAX); - op_assign_test!(sub_assign(u32::MIN, 1) == u32::MAX); - op_assign_test!(sub_assign(u64::MIN, 1) == u64::MAX); - op_assign_test!(sub_assign(usize::MIN, 1) == usize::MAX); - - - op_assign_test!(mul_assign(i8::MAX, 2) == -2); - op_assign_test!(mul_assign(i16::MAX, 2) == -2); - op_assign_test!(mul_assign(i32::MAX, 2) == -2); - op_assign_test!(mul_assign(i64::MAX, 2) == -2); - op_assign_test!(mul_assign(isize::MAX, 2) == -2); - - op_assign_test!(mul_assign(u8::MAX, 2) == u8::MAX - 1); - op_assign_test!(mul_assign(u16::MAX, 2) == u16::MAX - 1); - op_assign_test!(mul_assign(u32::MAX, 2) == u32::MAX - 1); - op_assign_test!(mul_assign(u64::MAX, 2) == u64::MAX - 1); - op_assign_test!(mul_assign(usize::MAX, 2) == usize::MAX - 1); - - - op_assign_test!(div_assign(i8::MIN, -1) == i8::MIN); - op_assign_test!(div_assign(i16::MIN, -1) == i16::MIN); - op_assign_test!(div_assign(i32::MIN, -1) == i32::MIN); - op_assign_test!(div_assign(i64::MIN, -1) == i64::MIN); - op_assign_test!(div_assign(isize::MIN, -1) == isize::MIN); - - - op_assign_test!(rem_assign(i8::MIN, -1) == 0); - op_assign_test!(rem_assign(i16::MIN, -1) == 0); - op_assign_test!(rem_assign(i32::MIN, -1) == 0); - op_assign_test!(rem_assign(i64::MIN, -1) == 0); - op_assign_test!(rem_assign(isize::MIN, -1) == 0); - - - // these are not that interesting, just testing to make sure they are implemented correctly - op_assign_test!(bitxor_assign(0b101010i8, 0b100110) == 0b001100); - op_assign_test!(bitxor_assign(0b101010i16, 0b100110) == 0b001100); - op_assign_test!(bitxor_assign(0b101010i32, 0b100110) == 0b001100); - op_assign_test!(bitxor_assign(0b101010i64, 0b100110) == 0b001100); - op_assign_test!(bitxor_assign(0b101010isize, 0b100110) == 0b001100); - - op_assign_test!(bitxor_assign(0b101010u8, 0b100110) == 0b001100); - op_assign_test!(bitxor_assign(0b101010u16, 0b100110) == 0b001100); - op_assign_test!(bitxor_assign(0b101010u32, 0b100110) == 0b001100); - op_assign_test!(bitxor_assign(0b101010u64, 0b100110) == 0b001100); - op_assign_test!(bitxor_assign(0b101010usize, 0b100110) == 0b001100); - - - op_assign_test!(bitor_assign(0b101010i8, 0b100110) == 0b101110); - op_assign_test!(bitor_assign(0b101010i16, 0b100110) == 0b101110); - op_assign_test!(bitor_assign(0b101010i32, 0b100110) == 0b101110); - op_assign_test!(bitor_assign(0b101010i64, 0b100110) == 0b101110); - op_assign_test!(bitor_assign(0b101010isize, 0b100110) == 0b101110); - - op_assign_test!(bitor_assign(0b101010u8, 0b100110) == 0b101110); - op_assign_test!(bitor_assign(0b101010u16, 0b100110) == 0b101110); - op_assign_test!(bitor_assign(0b101010u32, 0b100110) == 0b101110); - op_assign_test!(bitor_assign(0b101010u64, 0b100110) == 0b101110); - op_assign_test!(bitor_assign(0b101010usize, 0b100110) == 0b101110); - - - op_assign_test!(bitand_assign(0b101010i8, 0b100110) == 0b100010); - op_assign_test!(bitand_assign(0b101010i16, 0b100110) == 0b100010); - op_assign_test!(bitand_assign(0b101010i32, 0b100110) == 0b100010); - op_assign_test!(bitand_assign(0b101010i64, 0b100110) == 0b100010); - op_assign_test!(bitand_assign(0b101010isize, 0b100110) == 0b100010); - - op_assign_test!(bitand_assign(0b101010u8, 0b100110) == 0b100010); - op_assign_test!(bitand_assign(0b101010u16, 0b100110) == 0b100010); - op_assign_test!(bitand_assign(0b101010u32, 0b100110) == 0b100010); - op_assign_test!(bitand_assign(0b101010u64, 0b100110) == 0b100010); - op_assign_test!(bitand_assign(0b101010usize, 0b100110) == 0b100010); -} - -fn test_sh_ops() { - macro_rules! sh_test { - ($op:ident ($lhs:expr, $rhs:expr) == $ans:expr) => { - assert_eq!(black_box(Wrapping($lhs).$op($rhs)), Wrapping($ans)); - } - } - // NOTE: This will break for i8 if we ever get i/u128 - macro_rules! sh_test_all { - ($t:ty) => { - sh_test!(shl(i8::MAX, (i8::BITS + 1) as $t) == -2); - sh_test!(shl(i16::MAX, (i16::BITS + 1) as $t) == -2); - sh_test!(shl(i32::MAX, (i32::BITS + 1) as $t) == -2); - sh_test!(shl(i64::MAX, (i64::BITS + 1) as $t) == -2); - sh_test!(shl(isize::MAX, (isize::BITS + 1) as $t) == -2); - - sh_test!(shl(u8::MAX, (u8::BITS + 1) as $t) == u8::MAX - 1); - sh_test!(shl(u16::MAX, (u16::BITS + 1) as $t) == u16::MAX - 1); - sh_test!(shl(u32::MAX, (u32::BITS + 1) as $t) == u32::MAX - 1); - sh_test!(shl(u64::MAX, (u64::BITS + 1) as $t) == u64::MAX - 1); - sh_test!(shl(usize::MAX, (usize::BITS + 1) as $t) == usize::MAX - 1); - - - sh_test!(shr(i8::MAX, (i8::BITS + 1) as $t) == i8::MAX / 2); - sh_test!(shr(i16::MAX, (i16::BITS + 1) as $t) == i16::MAX / 2); - sh_test!(shr(i32::MAX, (i32::BITS + 1) as $t) == i32::MAX / 2); - sh_test!(shr(i64::MAX, (i64::BITS + 1) as $t) == i64::MAX / 2); - sh_test!(shr(isize::MAX, (isize::BITS + 1) as $t) == isize::MAX / 2); - - sh_test!(shr(u8::MAX, (u8::BITS + 1) as $t) == u8::MAX / 2); - sh_test!(shr(u16::MAX, (u16::BITS + 1) as $t) == u16::MAX / 2); - sh_test!(shr(u32::MAX, (u32::BITS + 1) as $t) == u32::MAX / 2); - sh_test!(shr(u64::MAX, (u64::BITS + 1) as $t) == u64::MAX / 2); - sh_test!(shr(usize::MAX, (usize::BITS + 1) as $t) == usize::MAX / 2); - } - } - macro_rules! sh_test_negative_all { - ($t:ty) => { - sh_test!(shr(i8::MAX, -((i8::BITS + 1) as $t)) == -2); - sh_test!(shr(i16::MAX, -((i16::BITS + 1) as $t)) == -2); - sh_test!(shr(i32::MAX, -((i32::BITS + 1) as $t)) == -2); - sh_test!(shr(i64::MAX, -((i64::BITS + 1) as $t)) == -2); - sh_test!(shr(isize::MAX, -((isize::BITS + 1) as $t)) == -2); - - sh_test!(shr(u8::MAX, -((u8::BITS + 1) as $t)) == u8::MAX - 1); - sh_test!(shr(u16::MAX, -((u16::BITS + 1) as $t)) == u16::MAX - 1); - sh_test!(shr(u32::MAX, -((u32::BITS + 1) as $t)) == u32::MAX - 1); - sh_test!(shr(u64::MAX, -((u64::BITS + 1) as $t)) == u64::MAX - 1); - sh_test!(shr(usize::MAX, -((usize::BITS + 1) as $t)) == usize::MAX - 1); - - - sh_test!(shl(i8::MAX, -((i8::BITS + 1) as $t)) == i8::MAX / 2); - sh_test!(shl(i16::MAX, -((i16::BITS + 1) as $t)) == i16::MAX / 2); - sh_test!(shl(i32::MAX, -((i32::BITS + 1) as $t)) == i32::MAX / 2); - sh_test!(shl(i64::MAX, -((i64::BITS + 1) as $t)) == i64::MAX / 2); - sh_test!(shl(isize::MAX, -((isize::BITS + 1) as $t)) == isize::MAX / 2); - - sh_test!(shl(u8::MAX, -((u8::BITS + 1) as $t)) == u8::MAX / 2); - sh_test!(shl(u16::MAX, -((u16::BITS + 1) as $t)) == u16::MAX / 2); - sh_test!(shl(u32::MAX, -((u32::BITS + 1) as $t)) == u32::MAX / 2); - sh_test!(shl(u64::MAX, -((u64::BITS + 1) as $t)) == u64::MAX / 2); - sh_test!(shl(usize::MAX, -((usize::BITS + 1) as $t)) == usize::MAX / 2); - } - } - // FIXME(#23545): Uncomment the remaining tests - //sh_test_all!(i8); - //sh_test_all!(u8); - //sh_test_all!(i16); - //sh_test_all!(u16); - //sh_test_all!(i32); - //sh_test_all!(u32); - //sh_test_all!(i64); - //sh_test_all!(u64); - //sh_test_all!(isize); - sh_test_all!(usize); - - //sh_test_negative_all!(i8); - //sh_test_negative_all!(i16); - //sh_test_negative_all!(i32); - //sh_test_negative_all!(i64); - //sh_test_negative_all!(isize); -} - -fn test_sh_op_assigns() { - macro_rules! sh_assign_test { - ($op:ident ($initial:expr, $rhs:expr) == $ans:expr) => {{ - let mut tmp = Wrapping($initial); - tmp = black_box(tmp); - tmp.$op($rhs); - assert_eq!(black_box(tmp), Wrapping($ans)); - }} - } - macro_rules! sh_assign_test_all { - ($t:ty) => { - sh_assign_test!(shl_assign(i8::MAX, (i8::BITS + 1) as $t) == -2); - sh_assign_test!(shl_assign(i16::MAX, (i16::BITS + 1) as $t) == -2); - sh_assign_test!(shl_assign(i32::MAX, (i32::BITS + 1) as $t) == -2); - sh_assign_test!(shl_assign(i64::MAX, (i64::BITS + 1) as $t) == -2); - sh_assign_test!(shl_assign(isize::MAX, (isize::BITS + 1) as $t) == -2); - - sh_assign_test!(shl_assign(u8::MAX, (u8::BITS + 1) as $t) == u8::MAX - 1); - sh_assign_test!(shl_assign(u16::MAX, (u16::BITS + 1) as $t) == u16::MAX - 1); - sh_assign_test!(shl_assign(u32::MAX, (u32::BITS + 1) as $t) == u32::MAX - 1); - sh_assign_test!(shl_assign(u64::MAX, (u64::BITS + 1) as $t) == u64::MAX - 1); - sh_assign_test!(shl_assign(usize::MAX, (usize::BITS + 1) as $t) == usize::MAX - 1); - - - sh_assign_test!(shr_assign(i8::MAX, (i8::BITS + 1) as $t) == i8::MAX / 2); - sh_assign_test!(shr_assign(i16::MAX, (i16::BITS + 1) as $t) == i16::MAX / 2); - sh_assign_test!(shr_assign(i32::MAX, (i32::BITS + 1) as $t) == i32::MAX / 2); - sh_assign_test!(shr_assign(i64::MAX, (i64::BITS + 1) as $t) == i64::MAX / 2); - sh_assign_test!(shr_assign(isize::MAX, (isize::BITS + 1) as $t) == isize::MAX / 2); - - sh_assign_test!(shr_assign(u8::MAX, (u8::BITS + 1) as $t) == u8::MAX / 2); - sh_assign_test!(shr_assign(u16::MAX, (u16::BITS + 1) as $t) == u16::MAX / 2); - sh_assign_test!(shr_assign(u32::MAX, (u32::BITS + 1) as $t) == u32::MAX / 2); - sh_assign_test!(shr_assign(u64::MAX, (u64::BITS + 1) as $t) == u64::MAX / 2); - sh_assign_test!(shr_assign(usize::MAX, (usize::BITS + 1) as $t) == usize::MAX / 2); - } - } - macro_rules! sh_assign_test_negative_all { - ($t:ty) => { - sh_assign_test!(shr_assign(i8::MAX, -((i8::BITS + 1) as $t)) == -2); - sh_assign_test!(shr_assign(i16::MAX, -((i16::BITS + 1) as $t)) == -2); - sh_assign_test!(shr_assign(i32::MAX, -((i32::BITS + 1) as $t)) == -2); - sh_assign_test!(shr_assign(i64::MAX, -((i64::BITS + 1) as $t)) == -2); - sh_assign_test!(shr_assign(isize::MAX, -((isize::BITS + 1) as $t)) == -2); - - sh_assign_test!(shr_assign(u8::MAX, -((u8::BITS + 1) as $t)) == u8::MAX - 1); - sh_assign_test!(shr_assign(u16::MAX, -((u16::BITS + 1) as $t)) == u16::MAX - 1); - sh_assign_test!(shr_assign(u32::MAX, -((u32::BITS + 1) as $t)) == u32::MAX - 1); - sh_assign_test!(shr_assign(u64::MAX, -((u64::BITS + 1) as $t)) == u64::MAX - 1); - sh_assign_test!(shr_assign(usize::MAX, -((usize::BITS + 1) as $t)) == usize::MAX - 1); - - - sh_assign_test!(shl_assign(i8::MAX, -((i8::BITS + 1) as $t)) == i8::MAX / 2); - sh_assign_test!(shl_assign(i16::MAX, -((i16::BITS + 1) as $t)) == i16::MAX / 2); - sh_assign_test!(shl_assign(i32::MAX, -((i32::BITS + 1) as $t)) == i32::MAX / 2); - sh_assign_test!(shl_assign(i64::MAX, -((i64::BITS + 1) as $t)) == i64::MAX / 2); - sh_assign_test!(shl_assign(isize::MAX, -((isize::BITS + 1) as $t)) == isize::MAX / 2); - - sh_assign_test!(shl_assign(u8::MAX, -((u8::BITS + 1) as $t)) == u8::MAX / 2); - sh_assign_test!(shl_assign(u16::MAX, -((u16::BITS + 1) as $t)) == u16::MAX / 2); - sh_assign_test!(shl_assign(u32::MAX, -((u32::BITS + 1) as $t)) == u32::MAX / 2); - sh_assign_test!(shl_assign(u64::MAX, -((u64::BITS + 1) as $t)) == u64::MAX / 2); - sh_assign_test!(shl_assign(usize::MAX, -((usize::BITS + 1) as $t)) == usize::MAX / 2); - } - } - - // FIXME(#23545): Uncomment the remaining tests - //sh_assign_test_all!(i8); - //sh_assign_test_all!(u8); - //sh_assign_test_all!(i16); - //sh_assign_test_all!(u16); - //sh_assign_test_all!(i32); - //sh_assign_test_all!(u32); - //sh_assign_test_all!(i64); - //sh_assign_test_all!(u64); - //sh_assign_test_all!(isize); - sh_assign_test_all!(usize); - - //sh_assign_test_negative_all!(i8); - //sh_assign_test_negative_all!(i16); - //sh_assign_test_negative_all!(i32); - //sh_assign_test_negative_all!(i64); - //sh_assign_test_negative_all!(isize); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/promoted_overflow_opt.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/promoted_overflow_opt.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/promoted_overflow_opt.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/promoted_overflow_opt.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(const_err)] - -// compile-flags: -O - -fn main() { - let x = &(0u32 - 1); - assert_eq!(*x, u32::max_value()) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/saturating-float-casts.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/saturating-float-casts.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/saturating-float-casts.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/saturating-float-casts.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,145 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests saturating float->int casts. See u128-as-f32.rs for the opposite direction. -// compile-flags: -Z saturating-float-casts - -#![feature(test, stmt_expr_attributes)] -#![deny(overflowing_literals)] -extern crate test; - -use std::{f32, f64}; -use std::{u8, i8, u16, i16, u32, i32, u64, i64}; -#[cfg(not(target_os="emscripten"))] -use std::{u128, i128}; -use test::black_box; - -macro_rules! test { - ($val:expr, $src_ty:ident -> $dest_ty:ident, $expected:expr) => ( - // black_box disables constant evaluation to test run-time conversions: - assert_eq!(black_box::<$src_ty>($val) as $dest_ty, $expected, - "run-time {} -> {}", stringify!($src_ty), stringify!($dest_ty)); - ); - - ($fval:expr, f* -> $ity:ident, $ival:expr) => ( - test!($fval, f32 -> $ity, $ival); - test!($fval, f64 -> $ity, $ival); - ) -} - -// This macro tests const eval in addition to run-time evaluation. -// If and when saturating casts are adopted, this macro should be merged with test!() to ensure -// that run-time and const eval agree on inputs that currently trigger a const eval error. -macro_rules! test_c { - ($val:expr, $src_ty:ident -> $dest_ty:ident, $expected:expr) => ({ - test!($val, $src_ty -> $dest_ty, $expected); - { - const X: $src_ty = $val; - const Y: $dest_ty = X as $dest_ty; - assert_eq!(Y, $expected, - "const eval {} -> {}", stringify!($src_ty), stringify!($dest_ty)); - } - }); - - ($fval:expr, f* -> $ity:ident, $ival:expr) => ( - test_c!($fval, f32 -> $ity, $ival); - test_c!($fval, f64 -> $ity, $ival); - ) -} - -macro_rules! common_fptoi_tests { - ($fty:ident -> $($ity:ident)+) => ({ $( - test!($fty::NAN, $fty -> $ity, 0); - test!($fty::INFINITY, $fty -> $ity, $ity::MAX); - test!($fty::NEG_INFINITY, $fty -> $ity, $ity::MIN); - // These two tests are not solely float->int tests, in particular the latter relies on - // `u128::MAX as f32` not being UB. But that's okay, since this file tests int->float - // as well, the test is just slightly misplaced. - test!($ity::MIN as $fty, $fty -> $ity, $ity::MIN); - test!($ity::MAX as $fty, $fty -> $ity, $ity::MAX); - test_c!(0., $fty -> $ity, 0); - test_c!($fty::MIN_POSITIVE, $fty -> $ity, 0); - test!(-0.9, $fty -> $ity, 0); - test_c!(1., $fty -> $ity, 1); - test_c!(42., $fty -> $ity, 42); - )+ }); - - (f* -> $($ity:ident)+) => ({ - common_fptoi_tests!(f32 -> $($ity)+); - common_fptoi_tests!(f64 -> $($ity)+); - }) -} - -macro_rules! fptoui_tests { - ($fty: ident -> $($ity: ident)+) => ({ $( - test!(-0., $fty -> $ity, 0); - test!(-$fty::MIN_POSITIVE, $fty -> $ity, 0); - test!(-0.99999994, $fty -> $ity, 0); - test!(-1., $fty -> $ity, 0); - test!(-100., $fty -> $ity, 0); - test!(#[allow(overflowing_literals)] -1e50, $fty -> $ity, 0); - test!(#[allow(overflowing_literals)] -1e130, $fty -> $ity, 0); - )+ }); - - (f* -> $($ity:ident)+) => ({ - fptoui_tests!(f32 -> $($ity)+); - fptoui_tests!(f64 -> $($ity)+); - }) -} - -pub fn main() { - common_fptoi_tests!(f* -> i8 i16 i32 i64 u8 u16 u32 u64); - fptoui_tests!(f* -> u8 u16 u32 u64); - // FIXME emscripten does not support i128 - #[cfg(not(target_os="emscripten"))] { - common_fptoi_tests!(f* -> i128 u128); - fptoui_tests!(f* -> u128); - } - - // The following tests cover edge cases for some integer types. - - // # u8 - test_c!(254., f* -> u8, 254); - test!(256., f* -> u8, 255); - - // # i8 - test_c!(-127., f* -> i8, -127); - test!(-129., f* -> i8, -128); - test_c!(126., f* -> i8, 126); - test!(128., f* -> i8, 127); - - // # i32 - // -2147483648. is i32::MIN (exactly) - test_c!(-2147483648., f* -> i32, i32::MIN); - // 2147483648. is i32::MAX rounded up - test!(2147483648., f32 -> i32, 2147483647); - // With 24 significand bits, floats with magnitude in [2^30 + 1, 2^31] are rounded to - // multiples of 2^7. Therefore, nextDown(round(i32::MAX)) is 2^31 - 128: - test_c!(2147483520., f32 -> i32, 2147483520); - // Similarly, nextUp(i32::MIN) is i32::MIN + 2^8 and nextDown(i32::MIN) is i32::MIN - 2^7 - test!(-2147483904., f* -> i32, i32::MIN); - test_c!(-2147483520., f* -> i32, -2147483520); - - // # u32 - // round(MAX) and nextUp(round(MAX)) - test_c!(4294967040., f* -> u32, 4294967040); - test!(4294967296., f* -> u32, 4294967295); - - // # u128 - #[cfg(not(target_os="emscripten"))] - { - // float->int: - test_c!(f32::MAX, f32 -> u128, 0xffffff00000000000000000000000000); - // nextDown(f32::MAX) = 2^128 - 2 * 2^104 - const SECOND_LARGEST_F32: f32 = 340282326356119256160033759537265639424.; - test_c!(SECOND_LARGEST_F32, f32 -> u128, 0xfffffe00000000000000000000000000); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/shift-near-oflo.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/shift-near-oflo.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/shift-near-oflo.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/shift-near-oflo.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// compile-flags: -C debug-assertions - -// Check that we do *not* overflow on a number of edge cases. -// (compare with test/run-fail/overflowing-{lsh,rsh}*.rs) - -fn main() { - test_left_shift(); - test_right_shift(); -} - -pub static mut HACK: i32 = 0; - -// Work around constant-evaluation -// The point of this test is to exercise the code generated for execution at runtime, -// `id` can never be flagged as a const fn by future aggressive analyses... -// due to the modification of the static -#[inline(never)] -fn id(x: T) -> T { - unsafe { HACK += 1; } - x -} - -fn test_left_shift() { - // negative rhs can panic, but values in [0,N-1] are okay for iN - - macro_rules! tests { - ($iN:ty, $uN:ty, $max_rhs:expr, $expect_i:expr, $expect_u:expr) => { { - let x = (1 as $iN) << id(0); - assert_eq!(x, 1); - let x = (1 as $uN) << id(0); - assert_eq!(x, 1); - let x = (1 as $iN) << id($max_rhs); - assert_eq!(x, $expect_i); - let x = (1 as $uN) << id($max_rhs); - assert_eq!(x, $expect_u); - // high-order bits on LHS are silently discarded without panic. - let x = (3 as $iN) << id($max_rhs); - assert_eq!(x, $expect_i); - let x = (3 as $uN) << id($max_rhs); - assert_eq!(x, $expect_u); - } } - } - - let x = 1_i8 << id(0); - assert_eq!(x, 1); - let x = 1_u8 << id(0); - assert_eq!(x, 1); - let x = 1_i8 << id(7); - assert_eq!(x, std::i8::MIN); - let x = 1_u8 << id(7); - assert_eq!(x, 0x80); - // high-order bits on LHS are silently discarded without panic. - let x = 3_i8 << id(7); - assert_eq!(x, std::i8::MIN); - let x = 3_u8 << id(7); - assert_eq!(x, 0x80); - - // above is (approximately) expanded from: - tests!(i8, u8, 7, std::i8::MIN, 0x80_u8); - - tests!(i16, u16, 15, std::i16::MIN, 0x8000_u16); - tests!(i32, u32, 31, std::i32::MIN, 0x8000_0000_u32); - tests!(i64, u64, 63, std::i64::MIN, 0x8000_0000_0000_0000_u64); -} - -fn test_right_shift() { - // negative rhs can panic, but values in [0,N-1] are okay for iN - - macro_rules! tests { - ($iN:ty, $uN:ty, $max_rhs:expr, - $signbit_i:expr, $highbit_i:expr, $highbit_u:expr) => - { { - let x = (1 as $iN) >> id(0); - assert_eq!(x, 1); - let x = (1 as $uN) >> id(0); - assert_eq!(x, 1); - let x = ($highbit_i) >> id($max_rhs-1); - assert_eq!(x, 1); - let x = ($highbit_u) >> id($max_rhs); - assert_eq!(x, 1); - // sign-bit is carried by arithmetic right shift - let x = ($signbit_i) >> id($max_rhs); - assert_eq!(x, -1); - // low-order bits on LHS are silently discarded without panic. - let x = ($highbit_i + 1) >> id($max_rhs-1); - assert_eq!(x, 1); - let x = ($highbit_u + 1) >> id($max_rhs); - assert_eq!(x, 1); - let x = ($signbit_i + 1) >> id($max_rhs); - assert_eq!(x, -1); - } } - } - - tests!(i8, u8, 7, std::i8::MIN, 0x40_i8, 0x80_u8); - tests!(i16, u16, 15, std::i16::MIN, 0x4000_u16, 0x8000_u16); - tests!(i32, u32, 31, std::i32::MIN, 0x4000_0000_u32, 0x8000_0000_u32); - tests!(i64, u64, 63, std::i64::MIN, - 0x4000_0000_0000_0000_u64, 0x8000_0000_0000_0000_u64); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/shift.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/shift.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/shift.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/shift.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] -#![allow(overflowing_literals)] - -// Testing shifts for various combinations of integers -// Issue #1570 - - -pub fn main() { - test_misc(); - test_expr(); - test_const(); -} - -fn test_misc() { - assert_eq!(1 << 1 << 1 << 1 << 1 << 1, 32); -} - -fn test_expr() { - let v10 = 10 as usize; - let v4 = 4 as u8; - let v2 = 2 as u8; - assert_eq!(v10 >> v2 as usize, v2 as usize); - assert_eq!(v10 << v4 as usize, 160 as usize); - - let v10 = 10 as u8; - let v4 = 4 as usize; - let v2 = 2 as usize; - assert_eq!(v10 >> v2 as usize, v2 as u8); - assert_eq!(v10 << v4 as usize, 160 as u8); - - let v10 = 10 as isize; - let v4 = 4 as i8; - let v2 = 2 as i8; - assert_eq!(v10 >> v2 as usize, v2 as isize); - assert_eq!(v10 << v4 as usize, 160 as isize); - - let v10 = 10 as i8; - let v4 = 4 as isize; - let v2 = 2 as isize; - assert_eq!(v10 >> v2 as usize, v2 as i8); - assert_eq!(v10 << v4 as usize, 160 as i8); - - let v10 = 10 as usize; - let v4 = 4 as isize; - let v2 = 2 as isize; - assert_eq!(v10 >> v2 as usize, v2 as usize); - assert_eq!(v10 << v4 as usize, 160 as usize); -} - -fn test_const() { - static r1_1: usize = 10_usize >> 2_usize; - static r2_1: usize = 10_usize << 4_usize; - assert_eq!(r1_1, 2 as usize); - assert_eq!(r2_1, 160 as usize); - - static r1_2: u8 = 10u8 >> 2_usize; - static r2_2: u8 = 10u8 << 4_usize; - assert_eq!(r1_2, 2 as u8); - assert_eq!(r2_2, 160 as u8); - - static r1_3: isize = 10 >> 2_usize; - static r2_3: isize = 10 << 4_usize; - assert_eq!(r1_3, 2 as isize); - assert_eq!(r2_3, 160 as isize); - - static r1_4: i8 = 10i8 >> 2_usize; - static r2_4: i8 = 10i8 << 4_usize; - assert_eq!(r1_4, 2 as i8); - assert_eq!(r2_4, 160 as i8); - - static r1_5: usize = 10_usize >> 2_usize; - static r2_5: usize = 10_usize << 4_usize; - assert_eq!(r1_5, 2 as usize); - assert_eq!(r2_5, 160 as usize); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/shift-various-types.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/shift-various-types.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/shift-various-types.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/shift-various-types.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we can do shifts by any integral type. - - -struct Panolpy { - i8: i8, - i16: i16, - i32: i32, - i64: i64, - isize: isize, - - u8: u8, - u16: u16, - u32: u32, - u64: u64, - usize: usize, -} - -fn foo(p: &Panolpy) { - assert_eq!(22 >> p.i8, 11); - assert_eq!(22 >> p.i16, 11); - assert_eq!(22 >> p.i32, 11); - assert_eq!(22 >> p.i64, 11); - assert_eq!(22 >> p.isize, 11); - - assert_eq!(22 >> p.u8, 11); - assert_eq!(22 >> p.u16, 11); - assert_eq!(22 >> p.u32, 11); - assert_eq!(22 >> p.u64, 11); - assert_eq!(22 >> p.usize, 11); -} - -fn main() { - let p = Panolpy { - i8: 1, - i16: 1, - i32: 1, - i64: 1, - isize: 1, - - u8: 1, - u16: 1, - u32: 1, - u64: 1, - usize: 1, - }; - foo(&p) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/signed-shift-const-eval.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/signed-shift-const-eval.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/signed-shift-const-eval.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/signed-shift-const-eval.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - -enum test { thing = -5 >> 1_usize } -pub fn main() { - assert_eq!(test::thing as isize, -3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/u128-as-f32.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/u128-as-f32.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/u128-as-f32.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/u128-as-f32.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten u128 not supported - -#![feature(test)] -#![deny(overflowing_literals)] -extern crate test; - -use std::f32; -use std::u128; -use test::black_box; - -macro_rules! test { - ($val:expr, $src_ty:ident -> $dest_ty:ident, $expected:expr) => ({ - { - const X: $src_ty = $val; - const Y: $dest_ty = X as $dest_ty; - assert_eq!(Y, $expected, - "const eval {} -> {}", stringify!($src_ty), stringify!($dest_ty)); - } - // black_box disables constant evaluation to test run-time conversions: - assert_eq!(black_box::<$src_ty>($val) as $dest_ty, $expected, - "run-time {} -> {}", stringify!($src_ty), stringify!($dest_ty)); - }); -} - -pub fn main() { - // nextDown(f32::MAX) = 2^128 - 2 * 2^104 - const SECOND_LARGEST_F32: f32 = 340282326356119256160033759537265639424.; - - // f32::MAX - 0.5 ULP and smaller should be rounded down - test!(0xfffffe00000000000000000000000000, u128 -> f32, SECOND_LARGEST_F32); - test!(0xfffffe7fffffffffffffffffffffffff, u128 -> f32, SECOND_LARGEST_F32); - test!(0xfffffe80000000000000000000000000, u128 -> f32, SECOND_LARGEST_F32); - // numbers within < 0.5 ULP of f32::MAX it should be rounded to f32::MAX - test!(0xfffffe80000000000000000000000001, u128 -> f32, f32::MAX); - test!(0xfffffeffffffffffffffffffffffffff, u128 -> f32, f32::MAX); - test!(0xffffff00000000000000000000000000, u128 -> f32, f32::MAX); - test!(0xffffff00000000000000000000000001, u128 -> f32, f32::MAX); - test!(0xffffff7fffffffffffffffffffffffff, u128 -> f32, f32::MAX); - // f32::MAX + 0.5 ULP and greater should be rounded to infinity - test!(0xffffff80000000000000000000000000, u128 -> f32, f32::INFINITY); - test!(0xffffff80000000f00000000000000000, u128 -> f32, f32::INFINITY); - test!(0xffffff87ffffffffffffffff00000001, u128 -> f32, f32::INFINITY); - - // u128->f64 should not be affected by the u128->f32 checks - test!(0xffffff80000000000000000000000000, u128 -> f64, - 340282356779733661637539395458142568448.0); - test!(u128::MAX, u128 -> f64, 340282366920938463463374607431768211455.0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/u128.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/u128.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/u128.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/u128.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,132 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten u128 not supported - -// compile-flags: -Z borrowck=compare - -#![feature(test)] - -extern crate test; -use test::black_box as b; - -fn main() { - let x: u128 = 0xFFFF_FFFF_FFFF_FFFF__FFFF_FFFF_FFFF_FFFF; - assert_eq!(0, !x); - assert_eq!(0, !x); - let y: u128 = 0xFFFF_FFFF_FFFF_FFFF__FFFF_FFFF_FFFF_FFFE; - assert_eq!(!1, y); - assert_eq!(x, y | 1); - assert_eq!(0xFAFF_0000_FF8F_0000__FFFF_0000_FFFF_FFFE, - y & - 0xFAFF_0000_FF8F_0000__FFFF_0000_FFFF_FFFF); - let z: u128 = 0xABCD_EF; - assert_eq!(z * z, 0x734C_C2F2_A521); - assert_eq!(z * z * z * z, 0x33EE_0E2A_54E2_59DA_A0E7_8E41); - assert_eq!(z + z + z + z, 0x2AF3_7BC); - let k: u128 = 0x1234_5678_9ABC_DEFF_EDCB_A987_6543_210; - assert_eq!(k + k, 0x2468_ACF1_3579_BDFF_DB97_530E_CA86_420); - assert_eq!(0, k - k); - assert_eq!(0x1234_5678_9ABC_DEFF_EDCB_A987_5A86_421, k - z); - assert_eq!(0x1000_0000_0000_0000_0000_0000_0000_000, - k - 0x234_5678_9ABC_DEFF_EDCB_A987_6543_210); - assert_eq!(0x6EF5_DE4C_D3BC_2AAA_3BB4_CC5D_D6EE_8, k / 42); - assert_eq!(0, k % 42); - assert_eq!(15, z % 42); - assert_eq!(0x169D_A8020_CEC18, k % 0x3ACB_FE49_FF24_AC); - assert_eq!(0x91A2_B3C4_D5E6_F7, k >> 65); - assert_eq!(0xFDB9_7530_ECA8_6420_0000_0000_0000_0000, k << 65); - assert!(k > z); - assert!(y > k); - assert!(y < x); - assert_eq!(x as u64, !0); - assert_eq!(z as u64, 0xABCD_EF); - assert_eq!(k as u64, 0xFEDC_BA98_7654_3210); - assert_eq!(k as i128, 0x1234_5678_9ABC_DEFF_EDCB_A987_6543_210); - assert_eq!((z as f64) as u128, z); - assert_eq!((z as f32) as u128, z); - assert_eq!((z as f64 * 16.0) as u128, z * 16); - assert_eq!((z as f32 * 16.0) as u128, z * 16); - let l :u128 = 432 << 100; - assert_eq!((l as f32) as u128, l); - assert_eq!((l as f64) as u128, l); - // formatting - let j: u128 = 1 << 67; - assert_eq!("147573952589676412928", format!("{}", j)); - assert_eq!("80000000000000000", format!("{:x}", j)); - assert_eq!("20000000000000000000000", format!("{:o}", j)); - assert_eq!("10000000000000000000000000000000000000000000000000000000000000000000", - format!("{:b}", j)); - assert_eq!("340282366920938463463374607431768211455", - format!("{}", u128::max_value())); - assert_eq!("147573952589676412928", format!("{:?}", j)); - // common traits - assert_eq!(x, b(x.clone())); - // overflow checks - assert_eq!((z).checked_mul(z), Some(0x734C_C2F2_A521)); - assert_eq!((k).checked_mul(k), None); - let l: u128 = b(u128::max_value() - 10); - let o: u128 = b(17); - assert_eq!(l.checked_add(b(11)), None); - assert_eq!(l.checked_sub(l), Some(0)); - assert_eq!(o.checked_sub(b(18)), None); - assert_eq!(b(1u128).checked_shl(b(127)), Some(1 << 127)); - assert_eq!(o.checked_shl(b(128)), None); - - // Test cases for all udivmodti4 branches. - // case "0X/0X" - assert_eq!(b(0x69545bd57727c050_u128) / - b(0x3283527a3350d88c_u128), - 2u128); - // case "0X/KX" - assert_eq!(b(0x0_8003c9c50b473ae6_u128) / - b(0x1_283e8838c30fa8f4_u128), - 0u128); - // case "K0/K0" - assert_eq!(b(0xc43f42a207978720_u128 << 64) / - b(0x098e62b74c23cf1a_u128 << 64), - 20u128); - // case "KK/K0" for power-of-two D. - assert_eq!(b(0xa9008fb6c9d81e42_0e25730562a601c8_u128) / - b(1u128 << 120), - 169u128); - // case "KK/K0" with N >= D (https://github.com/rust-lang/rust/issues/41228). - assert_eq!(b(0xe4d26e59f0640328_06da5b06efe83a41_u128) / - b(0x330fcb030ea4447c_u128 << 64), - 4u128); - assert_eq!(b(3u128 << 64 | 1) / - b(3u128 << 64), - 1u128); - // case "KK/K0" with N < D. - assert_eq!(b(0x6655c9fb66ca2884_e2d1dfd470158c62_u128) / - b(0xb35b667cab7e355b_u128 << 64), - 0u128); - // case "KX/0K" for power-of-two D. - assert_eq!(b(0x3e49dd84feb2df59_7b2f97d93a253969_u128) / - b(1u128 << 4), - 0x03e49dd84feb2df5_97b2f97d93a25396_u128); - // case "KX/0K" in general. - assert_eq!(b(0x299692b3a1dae5bd_6162e6f489d2620e_u128) / - b(0x900b6f027571d6f7_u128), - 0x49e95f54b0442578_u128); - // case "KX/KK" with N >= D. - assert_eq!(b(0xc7b889180b67b07d_bc1a3c88783d35b5_u128) / - b(0x1d7e69f53160b9e2_60074771e852f244_u128), - 6u128); - // case "KX/KK" with N < D. - assert_eq!(b(0x679289ac23bb334f_36144401cf882172_u128) / - b(0x7b0b271b64865f05_f54a7b72746c062f_u128), - 0u128); - - // iter-arithmetic traits - assert_eq!(10u128, [1u128, 2, 3, 4].iter().sum()); - assert_eq!(24u128, [1u128, 2, 3, 4].iter().product()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/u32-decr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/u32-decr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/u32-decr.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/u32-decr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - - -pub fn main() { - let mut word: u32 = 200000; - word = word - 1; - assert_eq!(word, 199999); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/u8-incr-decr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/u8-incr-decr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/u8-incr-decr.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/u8-incr-decr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - - -// These constants were chosen because they aren't used anywhere -// in the rest of the generated code so they're easily grep-able. - -pub fn main() { - let mut x: u8 = 19; // 0x13 - - let mut y: u8 = 35; // 0x23 - - x = x + 7; // 0x7 - - y = y - 9; // 0x9 - - assert_eq!(x, y); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/u8-incr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/u8-incr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/u8-incr.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/u8-incr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - - -pub fn main() { - let mut x: u8 = 12; - let y: u8 = 12; - x = x + 1; - x = x - 1; - assert_eq!(x, y); - // x = 14; - // x = x + 1; - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/uint.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/uint.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/uint.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/numbers-arithmetic/uint.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - -// pretty-expanded FIXME #23616 - -pub fn main() { let _x: usize = 10 as usize; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/auxiliary/overloaded_autoderef_xc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/auxiliary/overloaded_autoderef_xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/auxiliary/overloaded_autoderef_xc.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/auxiliary/overloaded_autoderef_xc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::ops::Deref; - -struct DerefWithHelper { - pub helper: H, - pub value: Option -} - -trait Helper { - fn helper_borrow(&self) -> &T; -} - -impl Helper for Option { - fn helper_borrow(&self) -> &T { - self.as_ref().unwrap() - } -} - -impl> Deref for DerefWithHelper { - type Target = T; - - fn deref(&self) -> &T { - self.helper.helper_borrow() - } -} - -// Test cross-crate autoderef + vtable. -pub fn check(x: T, y: T) -> bool { - let d: DerefWithHelper, T> = DerefWithHelper { helper: Some(x), value: None }; - d.eq(&y) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef-count.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef-count.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef-count.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef-count.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::cell::Cell; -use std::ops::{Deref, DerefMut}; - -#[derive(PartialEq)] -struct DerefCounter { - count_imm: Cell, - count_mut: usize, - value: T -} - -impl DerefCounter { - fn new(value: T) -> DerefCounter { - DerefCounter { - count_imm: Cell::new(0), - count_mut: 0, - value: value - } - } - - fn counts(&self) -> (usize, usize) { - (self.count_imm.get(), self.count_mut) - } -} - -impl Deref for DerefCounter { - type Target = T; - - fn deref(&self) -> &T { - self.count_imm.set(self.count_imm.get() + 1); - &self.value - } -} - -impl DerefMut for DerefCounter { - fn deref_mut(&mut self) -> &mut T { - self.count_mut += 1; - &mut self.value - } -} - -#[derive(PartialEq, Debug)] -struct Point { - x: isize, - y: isize -} - -impl Point { - fn get(&self) -> (isize, isize) { - (self.x, self.y) - } -} - -pub fn main() { - let mut p = DerefCounter::new(Point {x: 0, y: 0}); - - let _ = p.x; - assert_eq!(p.counts(), (1, 0)); - - let _ = &p.x; - assert_eq!(p.counts(), (2, 0)); - - let _ = &mut p.y; - assert_eq!(p.counts(), (2, 1)); - - p.x += 3; - assert_eq!(p.counts(), (2, 2)); - - p.get(); - assert_eq!(p.counts(), (3, 2)); - - // Check the final state. - assert_eq!(*p, Point {x: 3, y: 0}); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef-indexing.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef-indexing.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef-indexing.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef-indexing.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::ops::Deref; - -struct DerefArray<'a, T:'a> { - inner: &'a [T] -} - -impl<'a, T> Deref for DerefArray<'a, T> { - type Target = &'a [T]; - - fn deref<'b>(&'b self) -> &'b &'a [T] { - &self.inner - } -} - -pub fn main() { - let a = &[1, 2, 3]; - assert_eq!(DerefArray {inner: a}[1], 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef-order.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef-order.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef-order.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef-order.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::rc::Rc; -use std::ops::Deref; - -#[derive(Copy, Clone)] -struct DerefWrapper { - x: X, - y: Y -} - -impl DerefWrapper { - fn get_x(self) -> X { - self.x - } -} - -impl Deref for DerefWrapper { - type Target = Y; - - fn deref(&self) -> &Y { - &self.y - } -} - -mod priv_test { - use std::ops::Deref; - - #[derive(Copy, Clone)] - pub struct DerefWrapperHideX { - x: X, - pub y: Y - } - - impl DerefWrapperHideX { - pub fn new(x: X, y: Y) -> DerefWrapperHideX { - DerefWrapperHideX { - x: x, - y: y - } - } - } - - impl Deref for DerefWrapperHideX { - type Target = Y; - - fn deref(&self) -> &Y { - &self.y - } - } -} - -pub fn main() { - let nested = DerefWrapper {x: true, y: DerefWrapper {x: 0, y: 1}}; - - // Use the first field that you can find. - assert_eq!(nested.x, true); - assert_eq!((*nested).x, 0); - - // Same for methods, even though there are multiple - // candidates (at different nesting levels). - assert_eq!(nested.get_x(), true); - assert_eq!((*nested).get_x(), 0); - - // Also go through multiple levels of indirection. - assert_eq!(Rc::new(nested).x, true); - - let nested_priv = priv_test::DerefWrapperHideX::new(true, DerefWrapper {x: 0, y: 1}); - assert_eq!(nested_priv.x, 0); - assert_eq!((*nested_priv).x, 0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -#![feature(box_syntax, core)] - -use std::cell::RefCell; -use std::rc::Rc; - -#[derive(PartialEq, Debug)] -struct Point { - x: isize, - y: isize -} - -pub fn main() { - let box_5: Box<_> = box 5_usize; - let point = Rc::new(Point {x: 2, y: 4}); - assert_eq!(point.x, 2); - assert_eq!(point.y, 4); - - let i = Rc::new(RefCell::new(2)); - let i_value = *i.borrow(); - *i.borrow_mut() = 5; - assert_eq!((i_value, *i.borrow()), (2, 5)); - - let s = Rc::new("foo".to_string()); - assert_eq!(&**s, "foo"); - - let mut_s = Rc::new(RefCell::new(String::from("foo"))); - mut_s.borrow_mut().push_str("bar"); - // HACK assert_eq! would panic here because it stores the LHS and RHS in two locals. - assert_eq!(&**mut_s.borrow(), "foobar"); - assert_eq!(&**mut_s.borrow_mut(), "foobar"); - - let p = Rc::new(RefCell::new(Point {x: 1, y: 2})); - p.borrow_mut().x = 3; - p.borrow_mut().y += 3; - assert_eq!(*p.borrow(), Point {x: 3, y: 5}); - - let v = Rc::new(RefCell::new([1, 2, 3])); - v.borrow_mut()[0] = 3; - v.borrow_mut()[1] += 3; - assert_eq!((v.borrow()[0], v.borrow()[1], v.borrow()[2]), (3, 5, 3)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef-vtable.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef-vtable.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef-vtable.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef-vtable.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::ops::Deref; - -struct DerefWithHelper { - helper: H, - value: T -} - -trait Helper { - fn helper_borrow(&self) -> &T; -} - -impl Helper for Option { - fn helper_borrow(&self) -> &T { - self.as_ref().unwrap() - } -} - -impl> Deref for DerefWithHelper { - type Target = T; - - fn deref(&self) -> &T { - self.helper.helper_borrow() - } -} - -struct Foo {x: isize} - -impl Foo { - fn foo(&self) -> isize {self.x} -} - -pub fn main() { - let x: DerefWithHelper, Foo> = - DerefWithHelper { helper: Some(Foo {x: 5}), value: Foo { x: 2 } }; - assert_eq!(x.foo(), 5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef-xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef-xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef-xcrate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-autoderef-xcrate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:overloaded_autoderef_xc.rs - - -extern crate overloaded_autoderef_xc; - -fn main() { - assert!(overloaded_autoderef_xc::check(5, 5)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-object-one-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-object-one-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-object-one-arg.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-object-one-arg.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests calls to closure arguments where the closure takes 1 argument. -// This is a bit tricky due to rust-call ABI. - - -fn foo(f: &mut FnMut(isize) -> isize) -> isize { - f(22) -} - -fn main() { - let z = foo(&mut |x| x *100); - assert_eq!(z, 2200); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-object-two-args.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-object-two-args.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-object-two-args.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-object-two-args.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests calls to closure arguments where the closure takes 2 arguments. -// This is a bit tricky due to rust-call ABI. - - -fn foo(f: &mut FnMut(isize, isize) -> isize) -> isize { - f(1, 2) -} - -fn main() { - let z = foo(&mut |x, y| x * 10 + y); - assert_eq!(z, 12); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-object-zero-args.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-object-zero-args.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-object-zero-args.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-object-zero-args.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests calls to closure arguments where the closure takes 0 arguments. -// This is a bit tricky due to rust-call ABI. - - -fn foo(f: &mut FnMut() -> isize) -> isize { - f() -} - -fn main() { - let z = foo(&mut || 22); - assert_eq!(z, 22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-param-vtables.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-param-vtables.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-param-vtables.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-param-vtables.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests that nested vtables work with overloaded calls. - -// pretty-expanded FIXME #23616 - -#![feature(unboxed_closures, fn_traits)] - -use std::marker::PhantomData; -use std::ops::Fn; -use std::ops::Add; - -struct G(PhantomData); - -impl<'a, A: Add> Fn<(A,)> for G { - extern "rust-call" fn call(&self, (arg,): (A,)) -> i32 { - arg.add(1) - } -} - -impl<'a, A: Add> FnMut<(A,)> for G { - extern "rust-call" fn call_mut(&mut self, args: (A,)) -> i32 { self.call(args) } -} - -impl<'a, A: Add> FnOnce<(A,)> for G { - type Output = i32; - extern "rust-call" fn call_once(self, args: (A,)) -> i32 { self.call(args) } -} - -fn main() { - // ICE trigger - (G(PhantomData))(1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-simple.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-simple.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-simple.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(lang_items, unboxed_closures, fn_traits)] - -use std::ops::{Fn, FnMut, FnOnce}; - -struct S1 { - x: i32, - y: i32, -} - -impl FnMut<(i32,)> for S1 { - extern "rust-call" fn call_mut(&mut self, (z,): (i32,)) -> i32 { - self.x * self.y * z - } -} - -impl FnOnce<(i32,)> for S1 { - type Output = i32; - extern "rust-call" fn call_once(mut self, args: (i32,)) -> i32 { - self.call_mut(args) - } -} - -struct S2 { - x: i32, - y: i32, -} - -impl Fn<(i32,)> for S2 { - extern "rust-call" fn call(&self, (z,): (i32,)) -> i32 { - self.x * self.y * z - } -} - -impl FnMut<(i32,)> for S2 { - extern "rust-call" fn call_mut(&mut self, args: (i32,)) -> i32 { self.call(args) } -} - -impl FnOnce<(i32,)> for S2 { - type Output = i32; - extern "rust-call" fn call_once(self, args: (i32,)) -> i32 { self.call(args) } -} - -struct S3 { - x: i32, - y: i32, -} - -impl FnOnce<(i32,i32)> for S3 { - type Output = i32; - extern "rust-call" fn call_once(self, (z,zz): (i32,i32)) -> i32 { - self.x * self.y * z * zz - } -} - -fn main() { - let mut s = S1 { - x: 3, - y: 3, - }; - let ans = s(3); - - assert_eq!(ans, 27); - let s = S2 { - x: 3, - y: 3, - }; - let ans = s.call((3,)); - assert_eq!(ans, 27); - - let s = S3 { - x: 3, - y: 3, - }; - let ans = s(3, 1); - assert_eq!(ans, 27); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-zero-args.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-zero-args.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-zero-args.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-calls-zero-args.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(unboxed_closures, fn_traits)] - -use std::ops::FnMut; - -struct S { - x: i32, - y: i32, -} - -impl FnMut<()> for S { - extern "rust-call" fn call_mut(&mut self, (): ()) -> i32 { - self.x * self.y - } -} - -impl FnOnce<()> for S { - type Output = i32; - extern "rust-call" fn call_once(mut self, args: ()) -> i32 { self.call_mut(args) } -} - -fn main() { - let mut s = S { - x: 3, - y: 3, - }; - let ans = s(); - assert_eq!(ans, 9); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-deref-count.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-deref-count.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-deref-count.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-deref-count.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::cell::Cell; -use std::ops::{Deref, DerefMut}; -use std::vec::Vec; - -struct DerefCounter { - count_imm: Cell, - count_mut: usize, - value: T -} - -impl DerefCounter { - fn new(value: T) -> DerefCounter { - DerefCounter { - count_imm: Cell::new(0), - count_mut: 0, - value: value - } - } - - fn counts(&self) -> (usize, usize) { - (self.count_imm.get(), self.count_mut) - } -} - -impl Deref for DerefCounter { - type Target = T; - - fn deref(&self) -> &T { - self.count_imm.set(self.count_imm.get() + 1); - &self.value - } -} - -impl DerefMut for DerefCounter { - fn deref_mut(&mut self) -> &mut T { - self.count_mut += 1; - &mut self.value - } -} - -pub fn main() { - let mut n = DerefCounter::new(0); - let mut v = DerefCounter::new(Vec::new()); - - let _ = *n; // Immutable deref + copy a POD. - assert_eq!(n.counts(), (1, 0)); - - let _ = (&*n, &*v); // Immutable deref + borrow. - assert_eq!(n.counts(), (2, 0)); assert_eq!(v.counts(), (1, 0)); - - let _ = (&mut *n, &mut *v); // Mutable deref + mutable borrow. - assert_eq!(n.counts(), (2, 1)); assert_eq!(v.counts(), (1, 1)); - - let mut v2 = Vec::new(); - v2.push(1); - - *n = 5; *v = v2; // Mutable deref + assignment. - assert_eq!(n.counts(), (2, 2)); assert_eq!(v.counts(), (1, 2)); - - *n -= 3; // Mutable deref + assignment with binary operation. - assert_eq!(n.counts(), (2, 3)); - - // Immutable deref used for calling a method taking &self. (The - // typechecker is smarter now about doing this.) - (*n).to_string(); - assert_eq!(n.counts(), (3, 3)); - - // Mutable deref used for calling a method taking &mut self. - (*v).push(2); - assert_eq!(v.counts(), (1, 3)); - - // Check the final states. - assert_eq!(*n, 2); - let expected: &[_] = &[1, 2]; - assert_eq!((*v), expected); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-deref.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-deref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-deref.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-deref.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::cell::RefCell; -use std::rc::Rc; -use std::string::String; - -#[derive(PartialEq, Debug)] -struct Point { - x: isize, - y: isize -} - -pub fn main() { - assert_eq!(*Rc::new(5), 5); - assert_eq!(***Rc::new(Box::new(Box::new(5))), 5); - assert_eq!(*Rc::new(Point {x: 2, y: 4}), Point {x: 2, y: 4}); - - let i = Rc::new(RefCell::new(2)); - let i_value = *(*i).borrow(); - *(*i).borrow_mut() = 5; - assert_eq!((i_value, *(*i).borrow()), (2, 5)); - - let s = Rc::new("foo".to_string()); - assert_eq!(*s, "foo".to_string()); - assert_eq!((*s), "foo"); - - let mut_s = Rc::new(RefCell::new(String::from("foo"))); - (*(*mut_s).borrow_mut()).push_str("bar"); - // assert_eq! would panic here because it stores the LHS and RHS in two locals. - assert_eq!((*(*mut_s).borrow()), "foobar"); - assert_eq!((*(*mut_s).borrow_mut()), "foobar"); - - let p = Rc::new(RefCell::new(Point {x: 1, y: 2})); - (*(*p).borrow_mut()).x = 3; - (*(*p).borrow_mut()).y += 3; - assert_eq!(*(*p).borrow(), Point {x: 3, y: 5}); - - let v = Rc::new(RefCell::new(vec![1, 2, 3])); - (*(*v).borrow_mut())[0] = 3; - (*(*v).borrow_mut())[1] += 3; - assert_eq!(((*(*v).borrow())[0], - (*(*v).borrow())[1], - (*(*v).borrow())[2]), (3, 5, 3)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded_deref_with_ref_pattern_issue15609.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded_deref_with_ref_pattern_issue15609.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded_deref_with_ref_pattern_issue15609.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded_deref_with_ref_pattern_issue15609.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we choose Deref or DerefMut appropriately based on mutability of ref bindings (#15609). - -fn main() { - use std::cell::RefCell; - - struct S { - node: E, - } - - enum E { - Foo(u32), - Bar, - } - - // Check match - let x = RefCell::new(S { node: E::Foo(0) }); - - let mut b = x.borrow_mut(); - match b.node { - E::Foo(ref mut n) => *n += 1, - _ => (), - } - - // Check let - let x = RefCell::new(0); - let mut y = x.borrow_mut(); - let ref mut z = *y; - - fn foo(a: &mut RefCell>) { - if let Some(ref mut s) = *a.borrow_mut() { - s.push('a') - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded_deref_with_ref_pattern.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded_deref_with_ref_pattern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded_deref_with_ref_pattern.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded_deref_with_ref_pattern.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we choose Deref or DerefMut appropriately based on mutability of ref bindings (#15609). - -use std::ops::{Deref, DerefMut}; - -struct DerefOk(T); -struct DerefMutOk(T); - -impl Deref for DerefOk { - type Target = T; - fn deref(&self) -> &Self::Target { - &self.0 - } -} - -impl DerefMut for DerefOk { - fn deref_mut(&mut self) -> &mut Self::Target { - panic!() - } -} - -impl Deref for DerefMutOk { - type Target = T; - fn deref(&self) -> &Self::Target { - panic!() - } -} - -impl DerefMut for DerefMutOk { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.0 - } -} - -fn main() { - // Check that mutable ref binding in match picks DerefMut - let mut b = DerefMutOk(0); - match *b { - ref mut n => n, - }; - - // Check that mutable ref binding in let picks DerefMut - let mut y = DerefMutOk(1); - let ref mut z = *y; - - // Check that immutable ref binding in match picks Deref - let mut b = DerefOk(2); - match *b { - ref n => n, - }; - - // Check that immutable ref binding in let picks Deref - let mut y = DerefOk(3); - let ref z = *y; - - // Check that mixed mutable/immutable ref binding in match picks DerefMut - let mut b = DerefMutOk((0, 9)); - match *b { - (ref mut n, ref m) => (n, m), - }; - - let mut b = DerefMutOk((0, 9)); - match *b { - (ref n, ref mut m) => (n, m), - }; - - // Check that mixed mutable/immutable ref binding in let picks DerefMut - let mut y = DerefMutOk((1, 8)); - let (ref mut z, ref a) = *y; - - let mut y = DerefMutOk((1, 8)); - let (ref z, ref mut a) = *y; - - // Check that multiple immutable ref bindings in match picks Deref - let mut b = DerefOk((2, 7)); - match *b { - (ref n, ref m) => (n, m), - }; - - // Check that multiple immutable ref bindings in let picks Deref - let mut y = DerefOk((3, 6)); - let (ref z, ref a) = *y; - - // Check that multiple mutable ref bindings in match picks DerefMut - let mut b = DerefMutOk((4, 5)); - match *b { - (ref mut n, ref mut m) => (n, m), - }; - - // Check that multiple mutable ref bindings in let picks DerefMut - let mut y = DerefMutOk((5, 4)); - let (ref mut z, ref mut a) = *y; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-index-assoc-list.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-index-assoc-list.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-index-assoc-list.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-index-assoc-list.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test overloading of the `[]` operator. In particular test that it -// takes its argument *by reference*. - -use std::ops::Index; - -struct AssociationList { - pairs: Vec> } - -#[derive(Clone)] -struct AssociationPair { - key: K, - value: V -} - -impl AssociationList { - fn push(&mut self, key: K, value: V) { - self.pairs.push(AssociationPair {key: key, value: value}); - } -} - -impl<'a, K: PartialEq + std::fmt::Debug, V:Clone> Index<&'a K> for AssociationList { - type Output = V; - - fn index(&self, index: &K) -> &V { - for pair in &self.pairs { - if pair.key == *index { - return &pair.value - } - } - panic!("No value found for key: {:?}", index); - } -} - -pub fn main() { - let foo = "foo".to_string(); - let bar = "bar".to_string(); - - let mut list = AssociationList {pairs: Vec::new()}; - list.push(foo.clone(), 22); - list.push(bar.clone(), 44); - - assert_eq!(list[&foo], 22); - assert_eq!(list[&bar], 44); - - assert_eq!(list[&foo], 22); - assert_eq!(list[&bar], 44); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-index-autoderef.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-index-autoderef.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-index-autoderef.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-index-autoderef.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -// Test overloaded indexing combined with autoderef. - -#![feature(box_syntax, core)] - -use std::ops::{Index, IndexMut}; - -struct Foo { - x: isize, - y: isize, -} - -impl Index for Foo { - type Output = isize; - - fn index(&self, z: isize) -> &isize { - if z == 0 { - &self.x - } else { - &self.y - } - } -} - -impl IndexMut for Foo { - fn index_mut(&mut self, z: isize) -> &mut isize { - if z == 0 { - &mut self.x - } else { - &mut self.y - } - } -} - -trait Int { - fn get(self) -> isize; - fn get_from_ref(&self) -> isize; - fn inc(&mut self); -} - -impl Int for isize { - fn get(self) -> isize { self } - fn get_from_ref(&self) -> isize { *self } - fn inc(&mut self) { *self += 1; } -} - -fn main() { - let mut f: Box<_> = box Foo { - x: 1, - y: 2, - }; - - assert_eq!(f[1], 2); - - f[0] = 3; - - assert_eq!(f[0], 3); - - // Test explicit IndexMut where `f` must be autoderef: - { - let p = &mut f[1]; - *p = 4; - } - - // Test explicit Index where `f` must be autoderef: - { - let p = &f[1]; - assert_eq!(*p, 4); - } - - // Test calling methods with `&mut self`, `self, and `&self` receivers: - f[1].inc(); - assert_eq!(f[1].get(), 5); - assert_eq!(f[1].get_from_ref(), 5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-index-in-field.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-index-in-field.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-index-in-field.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-index-in-field.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test using overloaded indexing when the "map" is stored in a -// field. This caused problems at some point. - -use std::ops::Index; - -struct Foo { - x: isize, - y: isize, -} - -struct Bar { - foo: Foo -} - -impl Index for Foo { - type Output = isize; - - fn index(&self, z: isize) -> &isize { - if z == 0 { - &self.x - } else { - &self.y - } - } -} - -trait Int { - fn get(self) -> isize; - fn get_from_ref(&self) -> isize; - fn inc(&mut self); -} - -impl Int for isize { - fn get(self) -> isize { self } - fn get_from_ref(&self) -> isize { *self } - fn inc(&mut self) { *self += 1; } -} - -fn main() { - let f = Bar { foo: Foo { - x: 1, - y: 2, - } }; - assert_eq!(f.foo[1].get(), 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-index.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-index.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-index.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/overloaded/overloaded-index.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::ops::{Index, IndexMut}; - -struct Foo { - x: isize, - y: isize, -} - -impl Index for Foo { - type Output = isize; - - fn index(&self, z: isize) -> &isize { - if z == 0 { - &self.x - } else { - &self.y - } - } -} - -impl IndexMut for Foo { - fn index_mut(&mut self, z: isize) -> &mut isize { - if z == 0 { - &mut self.x - } else { - &mut self.y - } - } -} - -trait Int { - fn get(self) -> isize; - fn get_from_ref(&self) -> isize; - fn inc(&mut self); -} - -impl Int for isize { - fn get(self) -> isize { self } - fn get_from_ref(&self) -> isize { *self } - fn inc(&mut self) { *self += 1; } -} - -fn main() { - let mut f = Foo { - x: 1, - y: 2, - }; - assert_eq!(f[1], 2); - f[0] = 3; - assert_eq!(f[0], 3); - { - let p = &mut f[1]; - *p = 4; - } - { - let p = &f[1]; - assert_eq!(*p, 4); - } - - // Test calling methods with `&mut self`, `self, and `&self` receivers: - f[1].inc(); - assert_eq!(f[1].get(), 5); - assert_eq!(f[1].get_from_ref(), 5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/auxiliary/packed.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/auxiliary/packed.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/auxiliary/packed.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/auxiliary/packed.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(repr_packed)] - -#[repr(packed)] -pub struct P1S5 { - a: u8, - b: u32 -} - -#[repr(packed(2))] -pub struct P2S6 { - a: u8, - b: u32, - c: u8 -} - -#[repr(C, packed(2))] -pub struct P2CS8 { - a: u8, - b: u32, - c: u8 -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-borrow-element.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-borrow-element.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-borrow-element.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-borrow-element.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten weird assertion? - -#![feature(repr_packed)] - -#[repr(packed)] -struct Foo1 { - bar: u8, - baz: usize -} - -#[repr(packed(2))] -struct Foo2 { - bar: u8, - baz: usize -} - -#[repr(C, packed(4))] -struct Foo4C { - bar: u8, - baz: usize -} - -pub fn main() { - let foo = Foo1 { bar: 1, baz: 2 }; - let brw = unsafe { &foo.baz }; - assert_eq!(*brw, 2); - - let foo = Foo2 { bar: 1, baz: 2 }; - let brw = unsafe { &foo.baz }; - assert_eq!(*brw, 2); - - let foo = Foo4C { bar: 1, baz: 2 }; - let brw = unsafe { &foo.baz }; - assert_eq!(*brw, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-drop-aligned.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-drop-aligned.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-drop-aligned.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-drop-aligned.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::cell::Cell; -use std::mem; - -struct Aligned<'a> { - drop_count: &'a Cell -} - -#[inline(never)] -fn check_align(ptr: *const Aligned) { - assert_eq!(ptr as usize % mem::align_of::(), - 0); -} - -impl<'a> Drop for Aligned<'a> { - fn drop(&mut self) { - check_align(self); - self.drop_count.set(self.drop_count.get() + 1); - } -} - -#[repr(packed)] -struct Packed<'a>(u8, Aligned<'a>); - -fn main() { - let drop_count = &Cell::new(0); - { - let mut p = Packed(0, Aligned { drop_count }); - p.1 = Aligned { drop_count }; - assert_eq!(drop_count.get(), 1); - } - assert_eq!(drop_count.get(), 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-generic-layout.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-generic-layout.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-generic-layout.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-generic-layout.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(overflowing_literals)] - - -use std::mem; - -#[repr(packed)] -struct S { - a: T, - b: u8, - c: S -} - -pub fn main() { - unsafe { - let s = S { a: 0xff_ff_ff_ffu32, b: 1, c: 0xaa_aa_aa_aa as i32 }; - let transd : [u8; 9] = mem::transmute(s); - // Don't worry about endianness, the numbers are palindromic. - assert_eq!(transd, - [0xff, 0xff, 0xff, 0xff, - 1, - 0xaa, 0xaa, 0xaa, 0xaa]); - - - let s = S { a: 1u8, b: 2u8, c: 0b10000001_10000001 as i16}; - let transd : [u8; 4] = mem::transmute(s); - // Again, no endianness problems. - assert_eq!(transd, - [1, 2, 0b10000001, 0b10000001]); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-generic-size.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-generic-size.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-generic-size.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-generic-size.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] -#![allow(unused_comparisons)] - -#![feature(repr_packed)] - -use std::mem; - -#[repr(packed)] -struct P1 { - a: T, - b: u8, - c: S -} - -#[repr(packed(2))] -struct P2 { - a: T, - b: u8, - c: S -} - -#[repr(C, packed(4))] -struct P4C { - a: T, - b: u8, - c: S -} - -macro_rules! check { - ($t:ty, $align:expr, $size:expr) => ({ - assert_eq!(mem::align_of::<$t>(), $align); - assert_eq!(mem::size_of::<$t>(), $size); - }); -} - -pub fn main() { - check!(P1::, 1, 3); - check!(P1::, 1, 11); - - check!(P2::, 1, 3); - check!(P2::, 2, 12); - - check!(P4C::, 1, 3); - check!(P4C::, 4, 12); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-generic-size.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-generic-size.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-generic-size.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-generic-size.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -warning: unnecessary path disambiguator - --> $DIR/packed-struct-generic-size.rs:48:14 - | -LL | check!(P1::, 1, 3); - | ^^ try removing `::` - -warning: unnecessary path disambiguator - --> $DIR/packed-struct-generic-size.rs:49:14 - | -LL | check!(P1::, 1, 11); - | ^^ try removing `::` - -warning: unnecessary path disambiguator - --> $DIR/packed-struct-generic-size.rs:51:14 - | -LL | check!(P2::, 1, 3); - | ^^ try removing `::` - -warning: unnecessary path disambiguator - --> $DIR/packed-struct-generic-size.rs:52:14 - | -LL | check!(P2::, 2, 12); - | ^^ try removing `::` - -warning: unnecessary path disambiguator - --> $DIR/packed-struct-generic-size.rs:54:15 - | -LL | check!(P4C::, 1, 3); - | ^^ try removing `::` - -warning: unnecessary path disambiguator - --> $DIR/packed-struct-generic-size.rs:55:15 - | -LL | check!(P4C::, 4, 12); - | ^^ try removing `::` - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-layout.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-layout.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-layout.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-layout.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::mem; - -#[repr(packed)] -struct S4 { - a: u8, - b: [u8; 3], -} - -#[repr(packed)] -struct S5 { - a: u8, - b: u32 -} - -pub fn main() { - unsafe { - let s4 = S4 { a: 1, b: [2,3,4] }; - let transd : [u8; 4] = mem::transmute(s4); - assert_eq!(transd, [1, 2, 3, 4]); - - let s5 = S5 { a: 1, b: 0xff_00_00_ff }; - let transd : [u8; 5] = mem::transmute(s5); - // Don't worry about endianness, the u32 is palindromic. - assert_eq!(transd, [1, 0xff, 0, 0, 0xff]); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-match.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-match.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(repr_packed)] - -#[repr(packed)] -struct Foo1 { - bar: u8, - baz: usize -} - -#[repr(packed(2))] -struct Foo2 { - bar: u8, - baz: usize -} - -#[repr(C, packed(4))] -struct Foo4C { - bar: u8, - baz: usize -} - -pub fn main() { - let foo1 = Foo1 { bar: 1, baz: 2 }; - match foo1 { - Foo1 {bar, baz} => { - assert_eq!(bar, 1); - assert_eq!(baz, 2); - } - } - - let foo2 = Foo2 { bar: 1, baz: 2 }; - match foo2 { - Foo2 {bar, baz} => { - assert_eq!(bar, 1); - assert_eq!(baz, 2); - } - } - - let foo4 = Foo4C { bar: 1, baz: 2 }; - match foo4 { - Foo4C {bar, baz} => { - assert_eq!(bar, 1); - assert_eq!(baz, 2); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-optimized-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-optimized-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-optimized-enum.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-optimized-enum.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[repr(packed)] -struct Packed(T); - -impl Copy for Packed {} -impl Clone for Packed { - fn clone(&self) -> Self { *self } -} - -fn sanity_check_size(one: T) { - let two = [one, one]; - let stride = (&two[1] as *const _ as usize) - (&two[0] as *const _ as usize); - let (size, align) = (std::mem::size_of::(), std::mem::align_of::()); - assert_eq!(stride, size); - assert_eq!(size % align, 0); -} - -fn main() { - // This can fail if rustc and LLVM disagree on the size of a type. - // In this case, `Option>` was erroneously not - // marked as packed despite needing alignment `1` and containing - // its `&()` discriminant, which has alignment larger than `1`. - sanity_check_size((Some(Packed((&(), 0))), true)); - - // In #46769, `Option<(Packed<&()>, bool)>` was found to have - // pointer alignment, without actually being aligned in size. - // E.g. on 64-bit platforms, it had alignment `8` but size `9`. - type PackedRefAndBool<'a> = (Packed<&'a ()>, bool); - sanity_check_size::>(Some((Packed(&()), true))); - - // Make sure we don't pay for the enum optimization in size, - // e.g. we shouldn't need extra padding after the packed data. - assert_eq!(std::mem::align_of::>(), 1); - assert_eq!(std::mem::size_of::>(), - std::mem::size_of::()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-size.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-size.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-size.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-size.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,169 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -#![allow(non_upper_case_globals)] - -#![feature(repr_packed)] - - -use std::mem; - -#[repr(packed)] -struct P1S4 { - a: u8, - b: [u8; 3], -} - -#[repr(packed(2))] -struct P2S4 { - a: u8, - b: [u8; 3], -} - -#[repr(packed)] -struct P1S5 { - a: u8, - b: u32 -} - -#[repr(packed(2))] -struct P2S2 { - a: u8, - b: u8 -} - -#[repr(packed(2))] -struct P2S6 { - a: u8, - b: u32 -} - -#[repr(packed(2))] -struct P2S12 { - a: u32, - b: u64 -} - -#[repr(packed)] -struct P1S13 { - a: i64, - b: f32, - c: u8, -} - -#[repr(packed(2))] -struct P2S14 { - a: i64, - b: f32, - c: u8, -} - -#[repr(packed(4))] -struct P4S16 { - a: u8, - b: f32, - c: i64, - d: u16, -} - -#[repr(C, packed(4))] -struct P4CS20 { - a: u8, - b: f32, - c: i64, - d: u16, -} - -enum Foo { - Bar = 1, - Baz = 2 -} - -#[repr(packed)] -struct P1S3_Foo { - a: u8, - b: u16, - c: Foo -} - -#[repr(packed(2))] -struct P2_Foo { - a: Foo, -} - -#[repr(packed(2))] -struct P2S3_Foo { - a: u8, - b: u16, - c: Foo -} - -#[repr(packed)] -struct P1S7_Option { - a: f32, - b: u8, - c: u16, - d: Option> -} - -#[repr(packed(2))] -struct P2_Option { - a: Option> -} - -#[repr(packed(2))] -struct P2S7_Option { - a: f32, - b: u8, - c: u16, - d: Option> -} - -// Placing packed structs in statics should work -static TEST_P1S4: P1S4 = P1S4 { a: 1, b: [2, 3, 4] }; -static TEST_P1S5: P1S5 = P1S5 { a: 3, b: 67 }; -static TEST_P1S3_Foo: P1S3_Foo = P1S3_Foo { a: 1, b: 2, c: Foo::Baz }; -static TEST_P2S2: P2S2 = P2S2 { a: 1, b: 2 }; -static TEST_P2S4: P2S4 = P2S4 { a: 1, b: [2, 3, 4] }; -static TEST_P2S6: P2S6 = P2S6 { a: 1, b: 2 }; -static TEST_P2S12: P2S12 = P2S12 { a: 1, b: 2 }; -static TEST_P4S16: P4S16 = P4S16 { a: 1, b: 2.0, c: 3, d: 4 }; -static TEST_P4CS20: P4CS20 = P4CS20 { a: 1, b: 2.0, c: 3, d: 4 }; - -fn align_to(value: usize, align: usize) -> usize { - (value + (align - 1)) & !(align - 1) -} - -macro_rules! check { - ($t:ty, $align:expr, $size:expr) => ({ - assert_eq!(mem::align_of::<$t>(), $align); - assert_eq!(mem::size_of::<$t>(), $size); - }); -} - -pub fn main() { - check!(P1S4, 1, 4); - check!(P1S5, 1, 5); - check!(P1S13, 1, 13); - check!(P1S3_Foo, 1, 3 + mem::size_of::()); - check!(P1S7_Option, 1, 7 + mem::size_of::>>()); - - check!(P2S2, 1, 2); - check!(P2S4, 1, 4); - check!(P2S6, 2, 6); - check!(P2S12, 2, 12); - check!(P2S14, 2, 14); - check!(P4S16, 4, 16); - check!(P4CS20, 4, 20); - check!(P2S3_Foo, 2, align_to(3 + mem::size_of::(), 2)); - check!(P2S7_Option, 2, align_to(7 + mem::size_of::(), 2)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-size-xc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-size-xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-size-xc.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-size-xc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:packed.rs - - -extern crate packed; - -use std::mem; - -macro_rules! check { - ($t:ty, $align:expr, $size:expr) => ({ - assert_eq!(mem::align_of::<$t>(), $align); - assert_eq!(mem::size_of::<$t>(), $size); - }); -} - -pub fn main() { - check!(packed::P1S5, 1, 5); - check!(packed::P2S6, 2, 6); - check!(packed::P2CS8, 2, 8); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-vec.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-vec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-vec.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-struct-vec.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,131 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(repr_packed)] - -use std::fmt; -use std::mem; - -#[repr(packed)] -#[derive(Copy, Clone)] -struct Foo1 { - bar: u8, - baz: u64 -} - -impl PartialEq for Foo1 { - fn eq(&self, other: &Foo1) -> bool { - self.bar == other.bar && self.baz == other.baz - } -} - -impl fmt::Debug for Foo1 { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let bar = self.bar; - let baz = self.baz; - - f.debug_struct("Foo1") - .field("bar", &bar) - .field("baz", &baz) - .finish() - } -} - -#[repr(packed(2))] -#[derive(Copy, Clone)] -struct Foo2 { - bar: u8, - baz: u64 -} - -impl PartialEq for Foo2 { - fn eq(&self, other: &Foo2) -> bool { - self.bar == other.bar && self.baz == other.baz - } -} - -impl fmt::Debug for Foo2 { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let bar = self.bar; - let baz = self.baz; - - f.debug_struct("Foo2") - .field("bar", &bar) - .field("baz", &baz) - .finish() - } -} - -#[repr(C, packed(4))] -#[derive(Copy, Clone)] -struct Foo4C { - bar: u8, - baz: u64 -} - -impl PartialEq for Foo4C { - fn eq(&self, other: &Foo4C) -> bool { - self.bar == other.bar && self.baz == other.baz - } -} - -impl fmt::Debug for Foo4C { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let bar = self.bar; - let baz = self.baz; - - f.debug_struct("Foo4C") - .field("bar", &bar) - .field("baz", &baz) - .finish() - } -} - -pub fn main() { - let foo1s = [Foo1 { bar: 1, baz: 2 }; 10]; - - assert_eq!(mem::align_of::<[Foo1; 10]>(), 1); - assert_eq!(mem::size_of::<[Foo1; 10]>(), 90); - - for i in 0..10 { - assert_eq!(foo1s[i], Foo1 { bar: 1, baz: 2}); - } - - for &foo in &foo1s { - assert_eq!(foo, Foo1 { bar: 1, baz: 2 }); - } - - let foo2s = [Foo2 { bar: 1, baz: 2 }; 10]; - - assert_eq!(mem::align_of::<[Foo2; 10]>(), 2); - assert_eq!(mem::size_of::<[Foo2; 10]>(), 100); - - for i in 0..10 { - assert_eq!(foo2s[i], Foo2 { bar: 1, baz: 2}); - } - - for &foo in &foo2s { - assert_eq!(foo, Foo2 { bar: 1, baz: 2 }); - } - - let foo4s = [Foo4C { bar: 1, baz: 2 }; 10]; - - assert_eq!(mem::align_of::<[Foo4C; 10]>(), 4); - assert_eq!(mem::size_of::<[Foo4C; 10]>(), 120); - - for i in 0..10 { - assert_eq!(foo4s[i], Foo4C { bar: 1, baz: 2}); - } - - for &foo in &foo4s { - assert_eq!(foo, Foo4C { bar: 1, baz: 2 }); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-tuple-struct-layout.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-tuple-struct-layout.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-tuple-struct-layout.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-tuple-struct-layout.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::mem; - -#[repr(packed)] -struct S4(u8,[u8; 3]); - -#[repr(packed)] -struct S5(u8,u32); - -pub fn main() { - unsafe { - let s4 = S4(1, [2,3,4]); - let transd : [u8; 4] = mem::transmute(s4); - assert_eq!(transd, [1, 2, 3, 4]); - - let s5 = S5(1, 0xff_00_00_ff); - let transd : [u8; 5] = mem::transmute(s5); - // Don't worry about endianness, the u32 is palindromic. - assert_eq!(transd, [1, 0xff, 0, 0, 0xff]); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-tuple-struct-size.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-tuple-struct-size.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-tuple-struct-size.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/packed/packed-tuple-struct-size.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,90 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -#![feature(repr_packed)] - -use std::mem; - -#[repr(packed)] -struct P1S4(u8,[u8; 3]); - -#[repr(packed(2))] -struct P2S4(u8,[u8; 3]); - -#[repr(packed)] -struct P1S5(u8, u32); - -#[repr(packed(2))] -struct P2S6(u8, u32); - -#[repr(packed)] -struct P1S13(i64, f32, u8); - -#[repr(packed(2))] -struct P2S14(i64, f32, u8); - -#[repr(packed(4))] -struct P4S16(u8, f32, i64, u16); - -#[repr(C, packed(4))] -struct P4CS20(u8, f32, i64, u16); - -enum Foo { - Bar = 1, - Baz = 2 -} - -#[repr(packed)] -struct P1S3_Foo(u8, u16, Foo); - -#[repr(packed(2))] -struct P2_Foo(Foo); - -#[repr(packed(2))] -struct P2S3_Foo(u8, u16, Foo); - -#[repr(packed)] -struct P1S7_Option(f32, u8, u16, Option>); - -#[repr(packed(2))] -struct P2_Option(Option>); - -#[repr(packed(2))] -struct P2S7_Option(f32, u8, u16, Option>); - -fn align_to(value: usize, align: usize) -> usize { - (value + (align - 1)) & !(align - 1) -} - -macro_rules! check { - ($t:ty, $align:expr, $size:expr) => ({ - assert_eq!(mem::align_of::<$t>(), $align); - assert_eq!(mem::size_of::<$t>(), $size); - }); -} - -pub fn main() { - check!(P1S4, 1, 4); - check!(P1S5, 1, 5); - check!(P1S13, 1, 13); - check!(P1S3_Foo, 1, 3 + mem::size_of::()); - check!(P1S7_Option, 1, 7 + mem::size_of::>>()); - - check!(P2S4, 1, 4); - check!(P2S6, 2, 6); - check!(P2S14, 2, 14); - check!(P4S16, 4, 16); - check!(P4CS20, 4, 20); - check!(P2S3_Foo, 2, align_to(3 + mem::size_of::(), 2)); - check!(P2S7_Option, 2, align_to(7 + mem::size_of::(), 2)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/abort-link-to-unwinding-crates.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/abort-link-to-unwinding-crates.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/abort-link-to-unwinding-crates.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/abort-link-to-unwinding-crates.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// compile-flags:-C panic=abort -// aux-build:exit-success-if-unwind.rs -// no-prefer-dynamic -// ignore-cloudabi no processes -// ignore-emscripten no processes -// ignore-macos - -extern crate exit_success_if_unwind; - -use std::process::Command; -use std::env; - -fn main() { - let mut args = env::args_os(); - let me = args.next().unwrap(); - - if let Some(s) = args.next() { - if &*s == "foo" { - exit_success_if_unwind::bar(do_panic); - } - } - - let mut cmd = Command::new(env::args_os().next().unwrap()); - cmd.arg("foo"); - - - // ARMv6 hanges while printing the backtrace, see #41004 - if cfg!(target_arch = "arm") && cfg!(target_env = "gnu") { - cmd.env("RUST_BACKTRACE", "0"); - } - - let s = cmd.status(); - assert!(s.unwrap().code() != Some(0)); -} - -fn do_panic() { - panic!("try to catch me"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/abort.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/abort.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/abort.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/abort.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// compile-flags:-C panic=abort -// no-prefer-dynamic -// ignore-cloudabi no processes -// ignore-emscripten no processes -// ignore-macos - -use std::process::Command; -use std::env; - -struct Bomb; - -impl Drop for Bomb { - fn drop(&mut self) { - std::process::exit(0); - } -} - -fn main() { - let mut args = env::args_os(); - let me = args.next().unwrap(); - - if let Some(s) = args.next() { - if &*s == "foo" { - - let _bomb = Bomb; - - panic!("try to catch me"); - } - } - - let mut cmd = Command::new(env::args_os().next().unwrap()); - cmd.arg("foo"); - - // ARMv6 hanges while printing the backtrace, see #41004 - if cfg!(target_arch = "arm") && cfg!(target_env = "gnu") { - cmd.env("RUST_BACKTRACE", "0"); - } - - let s = cmd.status(); - assert!(s.unwrap().code() != Some(0)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/auxiliary/exit-success-if-unwind.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/auxiliary/exit-success-if-unwind.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/auxiliary/exit-success-if-unwind.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/auxiliary/exit-success-if-unwind.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "rlib"] - -struct Bomb; - -impl Drop for Bomb { - fn drop(&mut self) { - std::process::exit(0); - } -} - -pub fn bar(f: fn()) { - let _bomb = Bomb; - f(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/link-to-abort.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/link-to-abort.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/link-to-abort.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/link-to-abort.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// compile-flags:-C panic=abort -// no-prefer-dynamic -// ignore-macos - -#![feature(panic_abort)] - -extern crate panic_abort; - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/link-to-unwind.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/link-to-unwind.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/link-to-unwind.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/link-to-unwind.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// no-prefer-dynamic - -#![feature(panic_unwind)] - -extern crate panic_unwind; - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/lto-abort.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/lto-abort.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/lto-abort.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/lto-abort.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// compile-flags:-C lto -C panic=abort -// no-prefer-dynamic -// ignore-cloudabi no processes -// ignore-emscripten no processes - -use std::process::Command; -use std::env; - -struct Bomb; - -impl Drop for Bomb { - fn drop(&mut self) { - std::process::exit(0); - } -} - -fn main() { - let mut args = env::args_os(); - let me = args.next().unwrap(); - - if let Some(s) = args.next() { - if &*s == "foo" { - - let _bomb = Bomb; - - panic!("try to catch me"); - } - } - let s = Command::new(env::args_os().next().unwrap()).arg("foo").status(); - assert!(s.unwrap().code() != Some(0)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/lto-unwind.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/lto-unwind.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/lto-unwind.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panic-runtime/lto-unwind.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// compile-flags:-C lto -C panic=unwind -// no-prefer-dynamic -// ignore-cloudabi no processes -// ignore-emscripten no processes - -use std::process::Command; -use std::env; - -struct Bomb; - -impl Drop for Bomb { - fn drop(&mut self) { - println!("hurray you ran me"); - } -} - -fn main() { - let mut args = env::args_os(); - let me = args.next().unwrap(); - - if let Some(s) = args.next() { - if &*s == "foo" { - - let _bomb = Bomb; - - panic!("try to catch me"); - } - } - let s = Command::new(env::args_os().next().unwrap()).arg("foo").output(); - let s = s.unwrap(); - assert!(!s.status.success()); - assert!(String::from_utf8_lossy(&s.stdout).contains("hurray you ran me")); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-handler-chain.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-handler-chain.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-handler-chain.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-handler-chain.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -// ignore-emscripten no threads support - -#![feature(std_panic)] - -use std::sync::atomic::{AtomicUsize, Ordering}; -use std::panic; -use std::thread; - -static A: AtomicUsize = AtomicUsize::new(0); -static B: AtomicUsize = AtomicUsize::new(0); - -fn main() { - panic::set_hook(Box::new(|_| { A.fetch_add(1, Ordering::SeqCst); })); - let hook = panic::take_hook(); - panic::set_hook(Box::new(move |info| { - B.fetch_add(1, Ordering::SeqCst); - hook(info); - })); - - let _ = thread::spawn(|| { - panic!(); - }).join(); - - assert_eq!(1, A.load(Ordering::SeqCst)); - assert_eq!(1, B.load(Ordering::SeqCst)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-handler-flail-wildly.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-handler-flail-wildly.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-handler-flail-wildly.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-handler-flail-wildly.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -// ignore-emscripten no threads support - -#![feature(std_panic)] - -use std::panic; -use std::thread; - -fn a() { - panic::set_hook(Box::new(|_| println!("hello yes this is a"))); - panic::take_hook(); - panic::set_hook(Box::new(|_| println!("hello yes this is a part 2"))); - panic::take_hook(); -} - -fn b() { - panic::take_hook(); - panic::take_hook(); - panic::take_hook(); - panic::take_hook(); - panic::take_hook(); - panic!(); -} - -fn c() { - panic::set_hook(Box::new(|_| ())); - panic::set_hook(Box::new(|_| ())); - panic::set_hook(Box::new(|_| ())); - panic::set_hook(Box::new(|_| ())); - panic::set_hook(Box::new(|_| ())); - panic::set_hook(Box::new(|_| ())); - panic!(); -} - -fn main() { - for _ in 0..10 { - let mut handles = vec![]; - for _ in 0..10 { - handles.push(thread::spawn(a)); - } - for _ in 0..10 { - handles.push(thread::spawn(b)); - } - for _ in 0..10 { - handles.push(thread::spawn(c)); - } - for handle in handles { - let _ = handle.join(); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-handler-set-twice.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-handler-set-twice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-handler-set-twice.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-handler-set-twice.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -#![feature(std_panic)] - -// ignore-emscripten no threads support - -use std::sync::atomic::{AtomicUsize, Ordering}; -use std::panic; -use std::thread; - -static A: AtomicUsize = AtomicUsize::new(0); - -fn main() { - panic::set_hook(Box::new(|_| ())); - panic::set_hook(Box::new(|info| { A.fetch_add(1, Ordering::SeqCst); })); - - let _ = thread::spawn(|| { - panic!(); - }).join(); - - assert_eq!(1, A.load(Ordering::SeqCst)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-in-dtor-drops-fields.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-in-dtor-drops-fields.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-in-dtor-drops-fields.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-in-dtor-drops-fields.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -// ignore-emscripten no threads support - -use std::thread; - -static mut dropped: bool = false; - -struct A { - b: B, -} - -struct B { - foo: isize, -} - -impl Drop for A { - fn drop(&mut self) { - panic!() - } -} - -impl Drop for B { - fn drop(&mut self) { - unsafe { dropped = true; } - } -} - -pub fn main() { - let ret = thread::spawn(move|| { - let _a = A { b: B { foo: 3 } }; - }).join(); - assert!(ret.is_err()); - unsafe { assert!(dropped); } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-recover-propagate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-recover-propagate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-recover-propagate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-recover-propagate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; -use std::panic; -use std::thread; - -static A: AtomicUsize = ATOMIC_USIZE_INIT; - -fn main() { - panic::set_hook(Box::new(|_| { - A.fetch_add(1, Ordering::SeqCst); - })); - - let result = thread::spawn(|| { - let result = panic::catch_unwind(|| { - panic!("hi there"); - }); - - panic::resume_unwind(result.unwrap_err()); - }).join(); - - let msg = *result.unwrap_err().downcast::<&'static str>().unwrap(); - assert_eq!("hi there", msg); - assert_eq!(1, A.load(Ordering::SeqCst)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-safe.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-safe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-safe.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/panics/panic-safe.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(dead_code)] - -use std::panic::{UnwindSafe, AssertUnwindSafe}; -use std::cell::RefCell; -use std::sync::{Mutex, RwLock, Arc}; -use std::rc::Rc; - -struct Foo { a: i32 } - -fn assert() {} - -fn main() { - assert::(); - assert::<&i32>(); - assert::<*mut i32>(); - assert::<*const i32>(); - assert::(); - assert::(); - assert::<&str>(); - assert::(); - assert::<&Foo>(); - assert::>(); - assert::(); - assert::>(); - assert::>(); - assert::>(); - assert::>(); - assert::<&Mutex>(); - assert::<&RwLock>(); - assert::>(); - assert::>(); - assert::>(); - - trait Trait: UnwindSafe {} - assert::>(); - - fn bar() { - assert::>(); - assert::>(); - } - fn baz() { - assert::>(); - assert::>(); - assert::>(); - assert::>(); - assert::<&AssertUnwindSafe>(); - assert::>>(); - assert::>>(); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/auxiliary/privacy_reexport.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/auxiliary/privacy_reexport.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/auxiliary/privacy_reexport.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/auxiliary/privacy_reexport.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub extern crate core; -pub use foo as bar; - -pub mod foo { - pub fn frob() {} -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/auxiliary/priv-impl-prim-ty.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/auxiliary/priv-impl-prim-ty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/auxiliary/priv-impl-prim-ty.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/auxiliary/priv-impl-prim-ty.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub trait A { - fn frob(&self); -} - -impl A for isize { fn frob(&self) {} } - -pub fn frob(t: T) { - t.frob(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/auxiliary/pub_use_mods_xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/auxiliary/pub_use_mods_xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/auxiliary/pub_use_mods_xcrate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/auxiliary/pub_use_mods_xcrate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod a { - pub use a::b::c; - - pub mod b { - pub mod c { - fn f(){} - fn g(){} - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/auxiliary/pub_use_xcrate1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/auxiliary/pub_use_xcrate1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/auxiliary/pub_use_xcrate1.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/auxiliary/pub_use_xcrate1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct Foo { - pub name: isize -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/auxiliary/pub_use_xcrate2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/auxiliary/pub_use_xcrate2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/auxiliary/pub_use_xcrate2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/auxiliary/pub_use_xcrate2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate pub_use_xcrate1; - -pub use pub_use_xcrate1::Foo; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/privacy1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/privacy1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/privacy1.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/privacy1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub mod test2 { - // This used to generate an ICE (make sure that default functions are - // parented to their trait to find the first private thing as the trait). - - struct B; - trait A { fn foo(&self) {} } - impl A for B {} - - mod tests { - use super::A; - fn foo() { - let a = super::B; - a.foo(); - } - } -} - - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/privacy-ns.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/privacy-ns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/privacy-ns.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/privacy-ns.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,124 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_snake_case)] - - -// Check we do the correct privacy checks when we import a name and there is an -// item with that name in both the value and type namespaces. - -// pretty-expanded FIXME #23616 - -#![allow(dead_code)] -#![allow(unused_imports)] - - -// public type, private value -pub mod foo1 { - pub trait Bar { - fn dummy(&self) { } - } - pub struct Baz; - - fn Bar() { } -} - -fn test_unused1() { - use foo1::*; -} - -fn test_single1() { - use foo1::Bar; - - let _x: Box; -} - -fn test_list1() { - use foo1::{Bar,Baz}; - - let _x: Box; -} - -fn test_glob1() { - use foo1::*; - - let _x: Box; -} - -// private type, public value -pub mod foo2 { - trait Bar { - fn dummy(&self) { } - } - pub struct Baz; - - pub fn Bar() { } -} - -fn test_unused2() { - use foo2::*; -} - -fn test_single2() { - use foo2::Bar; - - Bar(); -} - -fn test_list2() { - use foo2::{Bar,Baz}; - - Bar(); -} - -fn test_glob2() { - use foo2::*; - - Bar(); -} - -// public type, public value -pub mod foo3 { - pub trait Bar { - fn dummy(&self) { } - } - pub struct Baz; - - pub fn Bar() { } -} - -fn test_unused3() { - use foo3::*; -} - -fn test_single3() { - use foo3::Bar; - - Bar(); - let _x: Box; -} - -fn test_list3() { - use foo3::{Bar,Baz}; - - Bar(); - let _x: Box; -} - -fn test_glob3() { - use foo3::*; - - Bar(); - let _x: Box; -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/privacy-reexport.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/privacy-reexport.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/privacy-reexport.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/privacy-reexport.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:privacy_reexport.rs - -// pretty-expanded FIXME #23616 - -extern crate privacy_reexport; - -pub fn main() { - // Check that public extern crates are visible to outside crates - privacy_reexport::core::cell::Cell::new(0); - - privacy_reexport::bar::frob(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/private-class-field.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/private-class-field.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/private-class-field.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/private-class-field.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - -struct cat { - meows : usize, - - how_hungry : isize, -} - -impl cat { - pub fn meow_count(&mut self) -> usize { self.meows } -} - -fn cat(in_x : usize, in_y : isize) -> cat { - cat { - meows: in_x, - how_hungry: in_y - } -} - -pub fn main() { - let mut nyan : cat = cat(52, 99); - assert_eq!(nyan.meow_count(), 52); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/private-method.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/private-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/private-method.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/private-method.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -struct cat { - meows : usize, - - how_hungry : isize, -} - -impl cat { - pub fn play(&mut self) { - self.meows += 1_usize; - self.nap(); - } -} - -impl cat { - fn nap(&mut self) { for _ in 1_usize..10_usize { } } -} - -fn cat(in_x : usize, in_y : isize) -> cat { - cat { - meows: in_x, - how_hungry: in_y - } -} - -pub fn main() { - let mut nyan : cat = cat(52_usize, 99); - nyan.play(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/priv-impl-prim-ty.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/priv-impl-prim-ty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/priv-impl-prim-ty.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/priv-impl-prim-ty.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:priv-impl-prim-ty.rs - -// pretty-expanded FIXME #23616 - -extern crate priv_impl_prim_ty as bar; - -pub fn main() { - bar::frob(1); - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/pub-extern-privacy.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/pub-extern-privacy.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/pub-extern-privacy.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/pub-extern-privacy.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare no libc to test ffi with - -// pretty-expanded FIXME #23616 - -use std::mem::transmute; - -mod a { - extern { - pub fn free(x: *const u8); - } -} - -pub fn main() { - unsafe { - a::free(transmute(0_usize)); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/pub_use_mods_xcrate_exe.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/pub_use_mods_xcrate_exe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/pub_use_mods_xcrate_exe.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/pub_use_mods_xcrate_exe.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:pub_use_mods_xcrate.rs - -// pretty-expanded FIXME #23616 - -#![allow(unused_imports)] - -extern crate pub_use_mods_xcrate; -use pub_use_mods_xcrate::a::c; - -pub fn main(){} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/pub-use-xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/pub-use-xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/privacy/pub-use-xcrate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/privacy/pub-use-xcrate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:pub_use_xcrate1.rs -// aux-build:pub_use_xcrate2.rs - -// pretty-expanded FIXME #23616 - -extern crate pub_use_xcrate2; - -use pub_use_xcrate2::Foo; - -pub fn main() { - let _foo: Foo = Foo { - name: 0 - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/process/process-envs.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/process/process-envs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/process/process-envs.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/process/process-envs.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -// Copyright 2014, 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-cloudabi no processes -// ignore-emscripten no processes - -use std::process::Command; -use std::env; -use std::collections::HashMap; - -#[cfg(all(unix, not(target_os="android")))] -pub fn env_cmd() -> Command { - Command::new("env") -} -#[cfg(target_os="android")] -pub fn env_cmd() -> Command { - let mut cmd = Command::new("/system/bin/sh"); - cmd.arg("-c").arg("set"); - cmd -} - -#[cfg(windows)] -pub fn env_cmd() -> Command { - let mut cmd = Command::new("cmd"); - cmd.arg("/c").arg("set"); - cmd -} - -fn main() { - // save original environment - let old_env = env::var_os("RUN_TEST_NEW_ENV"); - - env::set_var("RUN_TEST_NEW_ENV", "123"); - - // create filtered environment vector - let filtered_env : HashMap = - env::vars().filter(|&(ref k, _)| k == "PATH").collect(); - - let mut cmd = env_cmd(); - cmd.env_clear(); - cmd.envs(&filtered_env); - - // restore original environment - match old_env { - None => env::remove_var("RUN_TEST_NEW_ENV"), - Some(val) => env::set_var("RUN_TEST_NEW_ENV", &val) - } - - let result = cmd.output().unwrap(); - let output = String::from_utf8_lossy(&result.stdout); - - assert!(!output.contains("RUN_TEST_NEW_ENV"), - "found RUN_TEST_NEW_ENV inside of:\n\n{}", output); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/process/process-exit.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/process/process-exit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/process/process-exit.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/process/process-exit.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-cloudabi no processes -// ignore-emscripten no processes - -use std::env; -use std::process::{self, Command, Stdio}; - -fn main() { - let args: Vec = env::args().collect(); - if args.len() > 1 && args[1] == "child" { - child(); - } else { - parent(); - } -} - -fn parent() { - let args: Vec = env::args().collect(); - let status = Command::new(&args[0]).arg("child").status().unwrap(); - assert_eq!(status.code(), Some(2)); -} - -fn child() -> i32 { - process::exit(2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/process/process-remove-from-env.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/process/process-remove-from-env.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/process/process-remove-from-env.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/process/process-remove-from-env.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-cloudabi no processes -// ignore-emscripten no processes - -use std::process::Command; -use std::env; - -#[cfg(all(unix, not(target_os="android")))] -pub fn env_cmd() -> Command { - Command::new("env") -} -#[cfg(target_os="android")] -pub fn env_cmd() -> Command { - let mut cmd = Command::new("/system/bin/sh"); - cmd.arg("-c").arg("set"); - cmd -} - -#[cfg(windows)] -pub fn env_cmd() -> Command { - let mut cmd = Command::new("cmd"); - cmd.arg("/c").arg("set"); - cmd -} - -fn main() { - // save original environment - let old_env = env::var_os("RUN_TEST_NEW_ENV"); - - env::set_var("RUN_TEST_NEW_ENV", "123"); - - let mut cmd = env_cmd(); - cmd.env_remove("RUN_TEST_NEW_ENV"); - - // restore original environment - match old_env { - None => env::remove_var("RUN_TEST_NEW_ENV"), - Some(val) => env::set_var("RUN_TEST_NEW_ENV", &val) - } - - let result = cmd.output().unwrap(); - let output = String::from_utf8_lossy(&result.stdout); - - assert!(!output.contains("RUN_TEST_NEW_ENV"), - "found RUN_TEST_NEW_ENV inside of:\n\n{}", output); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/process/process-sigpipe.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/process/process-sigpipe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/process/process-sigpipe.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/process/process-sigpipe.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(deprecated)] - -// ignore-android since the dynamic linker sets a SIGPIPE handler (to do -// a crash report) so inheritance is moot on the entire platform - -// libstd ignores SIGPIPE, and other libraries may set signal masks. -// Make sure that these behaviors don't get inherited to children -// spawned via std::process, since they're needed for traditional UNIX -// filter behavior. This test checks that `yes | head` terminates -// (instead of running forever), and that it does not print an error -// message about a broken pipe. - -// ignore-cloudabi no subprocesses support -// ignore-emscripten no threads support - -use std::process; -use std::thread; - -#[cfg(unix)] -fn main() { - // Just in case `yes` doesn't check for EPIPE... - thread::spawn(|| { - thread::sleep_ms(5000); - process::exit(1); - }); - let output = process::Command::new("sh").arg("-c").arg("yes | head").output().unwrap(); - assert!(output.status.success()); - assert!(output.stderr.len() == 0); -} - -#[cfg(not(unix))] -fn main() { - // Not worried about signal masks on other platforms -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/process/process-spawn-nonexistent.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/process/process-spawn-nonexistent.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/process/process-spawn-nonexistent.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/process/process-spawn-nonexistent.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-cloudabi no processes -// ignore-emscripten no processes - -use std::io::ErrorKind; -use std::process::Command; - -fn main() { - assert_eq!(Command::new("nonexistent") - .spawn() - .unwrap_err() - .kind(), - ErrorKind::NotFound); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/process/process-spawn-with-unicode-params.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/process/process-spawn-with-unicode-params.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/process/process-spawn-with-unicode-params.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/process/process-spawn-with-unicode-params.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// no-prefer-dynamic - -// The test copies itself into a subdirectory with a non-ASCII name and then -// runs it as a child process within the subdirectory. The parent process -// also adds an environment variable and an argument, both containing -// non-ASCII characters. The child process ensures all the strings are -// intact. - -// ignore-cloudabi no processes -// ignore-emscripten no processes - -use std::io::prelude::*; -use std::io; -use std::fs; -use std::process::Command; -use std::env; -use std::path::Path; - -fn main() { - let my_args = env::args().collect::>(); - let my_cwd = env::current_dir().unwrap(); - let my_env = env::vars().collect::>(); - let my_path = env::current_exe().unwrap(); - let my_dir = my_path.parent().unwrap(); - let my_ext = my_path.extension().and_then(|s| s.to_str()).unwrap_or(""); - - // some non-ASCII characters - let blah = "\u{3c0}\u{42f}\u{97f3}\u{e6}\u{221e}"; - - let child_name = "child"; - let child_dir = format!("process-spawn-with-unicode-params-{}", blah); - - // parameters sent to child / expected to be received from parent - let arg = blah; - let cwd = my_dir.join(&child_dir); - let env = ("RUST_TEST_PROC_SPAWN_UNICODE".to_string(), blah.to_string()); - - // am I the parent or the child? - if my_args.len() == 1 { // parent - - let child_filestem = Path::new(child_name); - let child_filename = child_filestem.with_extension(my_ext); - let child_path = cwd.join(&child_filename); - - // make a separate directory for the child - let _ = fs::create_dir(&cwd); - fs::copy(&my_path, &child_path).unwrap(); - - // run child - let p = Command::new(&child_path) - .arg(arg) - .current_dir(&cwd) - .env(&env.0, &env.1) - .spawn().unwrap().wait_with_output().unwrap(); - - // display the output - io::stdout().write_all(&p.stdout).unwrap(); - io::stderr().write_all(&p.stderr).unwrap(); - - // make sure the child succeeded - assert!(p.status.success()); - - } else { // child - - // check working directory (don't try to compare with `cwd` here!) - assert!(my_cwd.ends_with(&child_dir)); - - // check arguments - assert_eq!(&*my_args[1], arg); - - // check environment variable - assert!(my_env.contains(&env)); - - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/process/process-status-inherits-stdin.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/process/process-status-inherits-stdin.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/process/process-status-inherits-stdin.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/process/process-status-inherits-stdin.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-cloudabi no processes -// ignore-emscripten no processes - -use std::env; -use std::io; -use std::io::Write; -use std::process::{Command, Stdio}; - -fn main() { - let mut args = env::args(); - let me = args.next().unwrap(); - let arg = args.next(); - match arg.as_ref().map(|s| &s[..]) { - None => { - let mut s = Command::new(&me) - .arg("a1") - .stdin(Stdio::piped()) - .spawn() - .unwrap(); - s.stdin.take().unwrap().write_all(b"foo\n").unwrap(); - let s = s.wait().unwrap(); - assert!(s.success()); - } - Some("a1") => { - let s = Command::new(&me).arg("a2").status().unwrap(); - assert!(s.success()); - } - Some(..) => { - let mut s = String::new(); - io::stdin().read_line(&mut s).unwrap(); - assert_eq!(s, "foo\n"); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-addr-of-interior-of-unique-box.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-addr-of-interior-of-unique-box.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-addr-of-interior-of-unique-box.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-addr-of-interior-of-unique-box.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// pretty-expanded FIXME #23616 - -struct Point { - x: isize, - y: isize -} - -struct Character { - pos: Box, -} - -fn get_x(x: &Character) -> &isize { - // interesting case because the scope of this - // borrow of the unique pointer is in fact - // larger than the fn itself - return &x.pos.x; -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-addr-of-ret.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-addr-of-ret.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-addr-of-ret.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-addr-of-ret.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn f(x: &isize) -> &isize { - return &*x; -} - -pub fn main() { - let three = &3; - println!("{}", *f(three)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-assoc-type-region-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-assoc-type-region-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-assoc-type-region-bound.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-assoc-type-region-bound.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that the compiler considers the 'a bound declared in the -// trait. Issue #20890. - -// pretty-expanded FIXME #23616 - -trait Foo<'a> { - type Value: 'a; - - fn get(&self) -> &'a Self::Value; -} - -fn takes_foo<'a,F: Foo<'a>>(f: &'a F) { - // This call would be illegal, because it results in &'a F::Value, - // and the only way we know that `F::Value : 'a` is because of the - // trait declaration. - - f.get(); -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-assoc-type-static-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-assoc-type-static-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-assoc-type-static-bound.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-assoc-type-static-bound.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that the compiler considers the 'static bound declared in the -// trait. Issue #20890. - -// pretty-expanded FIXME #23616 - -trait Foo { - type Value: 'static; - fn dummy(&self) { } -} - -fn require_static() {} - -fn takes_foo() { - require_static::() -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-borrow-at.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-borrow-at.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-borrow-at.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-borrow-at.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -fn foo(x: &usize) -> usize { - *x -} - -pub fn main() { - let p: Box<_> = box 22; - let r = foo(&*p); - println!("r={}", r); - assert_eq!(r, 22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-borrow-evec-fixed.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-borrow-evec-fixed.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-borrow-evec-fixed.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-borrow-evec-fixed.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn foo(x: &[isize]) -> isize { - x[0] -} - -pub fn main() { - let p = &[1,2,3,4,5]; - assert_eq!(foo(p), 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-borrow-evec-uniq.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-borrow-evec-uniq.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-borrow-evec-uniq.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-borrow-evec-uniq.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -fn foo(x: &[isize]) -> isize { - x[0] -} - -pub fn main() { - let p = vec![1,2,3,4,5]; - let r = foo(&p); - assert_eq!(r, 1); - - let p = vec![5,4,3,2,1]; - let r = foo(&p); - assert_eq!(r, 5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-borrow-uniq.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-borrow-uniq.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-borrow-uniq.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-borrow-uniq.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -fn foo(x: &usize) -> usize { - *x -} - -pub fn main() { - let p: Box<_> = box 3; - let r = foo(&*p); - assert_eq!(r, 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-bot.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-bot.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-bot.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-bot.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// A very limited test of the "bottom" region - - -fn produce_static() -> &'static T { panic!(); } - -fn foo(_x: &T) -> &usize { produce_static() } - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-bound-lists-feature-gate-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-bound-lists-feature-gate-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-bound-lists-feature-gate-2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-bound-lists-feature-gate-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -#![feature(issue_5723_bootstrap)] - -trait Foo { - fn dummy(&self) { } -} - -fn foo<'a, 'b, 'c:'a+'b, 'd>() { -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-bound-lists-feature-gate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-bound-lists-feature-gate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-bound-lists-feature-gate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-bound-lists-feature-gate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -#![feature(issue_5723_bootstrap)] - -trait Foo { - fn dummy(&self) { } -} - -fn foo<'a>(x: Box) { -} - -fn bar<'a, T: 'a>() { -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-close-over-type-parameter-successfully.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-close-over-type-parameter-successfully.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-close-over-type-parameter-successfully.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-close-over-type-parameter-successfully.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// A test where we (successfully) close over a reference into -// an object. - -#![feature(box_syntax)] - -trait SomeTrait { fn get(&self) -> isize; } - -impl<'a> SomeTrait for &'a isize { - fn get(&self) -> isize { - **self - } -} - -fn make_object<'a,A:SomeTrait+'a>(v: A) -> Box { - box v as Box -} - -fn main() { - let i: isize = 22; - let obj = make_object(&i); - assert_eq!(22, obj.get()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-copy-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-copy-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-copy-closure.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-copy-closure.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -struct closure_box<'a> { - cl: Box, -} - -fn box_it<'a>(x: Box) -> closure_box<'a> { - closure_box {cl: x} -} - -pub fn main() { - let mut i = 3; - assert_eq!(i, 3); - { - let cl = || i += 1; - let mut cl_box = box_it(Box::new(cl)); - (cl_box.cl)(); - } - assert_eq!(i, 4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-creating-enums2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-creating-enums2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-creating-enums2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-creating-enums2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -enum ast<'a> { - num(usize), - add(&'a ast<'a>, &'a ast<'a>) -} - -fn mk_add_ok<'r>(x: &'r ast<'r>, y: &'r ast<'r>) -> ast<'r> { - ast::add(x, y) -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-creating-enums5.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-creating-enums5.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-creating-enums5.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-creating-enums5.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -enum ast<'a> { - num(usize), - add(&'a ast<'a>, &'a ast<'a>) -} - -fn mk_add_ok<'a>(x: &'a ast<'a>, y: &'a ast<'a>, _z: &ast) -> ast<'a> { - ast::add(x, y) -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-debruijn-of-object.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-debruijn-of-object.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-debruijn-of-object.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-debruijn-of-object.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -struct ctxt<'tcx> { - x: &'tcx i32 -} - -trait AstConv<'tcx> { - fn tcx<'a>(&'a self) -> &'a ctxt<'tcx>; -} - -fn foo(conv: &AstConv) { } - -fn bar<'tcx>(conv: &AstConv<'tcx>) { - foo(conv) -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-dependent-addr-of.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-dependent-addr-of.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-dependent-addr-of.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-dependent-addr-of.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,123 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test lifetimes are linked properly when we create dependent region pointers. -// Issue #3148. - -#![feature(box_patterns)] -#![feature(box_syntax)] - -struct A { - value: B -} - -struct B { - v1: isize, - v2: [isize; 3], - v3: Vec , - v4: C, - v5: Box, - v6: Option -} - -#[derive(Copy, Clone)] -struct C { - f: isize -} - -fn get_v1(a: &A) -> &isize { - // Region inferencer must deduce that &v < L2 < L1 - let foo = &a.value; // L1 - &foo.v1 // L2 -} - -fn get_v2(a: &A, i: usize) -> &isize { - let foo = &a.value; - &foo.v2[i] -} - -fn get_v3(a: &A, i: usize) -> &isize { - let foo = &a.value; - &foo.v3[i] -} - -fn get_v4(a: &A, _i: usize) -> &isize { - let foo = &a.value; - &foo.v4.f -} - -fn get_v5(a: &A, _i: usize) -> &isize { - let foo = &a.value; - &foo.v5.f -} - -fn get_v6_a(a: &A, _i: usize) -> &isize { - match a.value.v6 { - Some(ref v) => &v.f, - None => panic!() - } -} - -fn get_v6_b(a: &A, _i: usize) -> &isize { - match *a { - A { value: B { v6: Some(ref v), .. } } => &v.f, - _ => panic!() - } -} - -fn get_v6_c(a: &A, _i: usize) -> &isize { - match a { - &A { value: B { v6: Some(ref v), .. } } => &v.f, - _ => panic!() - } -} - -fn get_v5_ref(a: &A, _i: usize) -> &isize { - match &a.value { - &B {v5: box C {f: ref v}, ..} => v - } -} - -pub fn main() { - let a = A {value: B {v1: 22, - v2: [23, 24, 25], - v3: vec![26, 27, 28], - v4: C { f: 29 }, - v5: box C { f: 30 }, - v6: Some(C { f: 31 })}}; - - let p = get_v1(&a); - assert_eq!(*p, a.value.v1); - - let p = get_v2(&a, 1); - assert_eq!(*p, a.value.v2[1]); - - let p = get_v3(&a, 1); - assert_eq!(*p, a.value.v3[1]); - - let p = get_v4(&a, 1); - assert_eq!(*p, a.value.v4.f); - - let p = get_v5(&a, 1); - assert_eq!(*p, a.value.v5.f); - - let p = get_v6_a(&a, 1); - assert_eq!(*p, a.value.v6.unwrap().f); - - let p = get_v6_b(&a, 1); - assert_eq!(*p, a.value.v6.unwrap().f); - - let p = get_v6_c(&a, 1); - assert_eq!(*p, a.value.v6.unwrap().f); - - let p = get_v5_ref(&a, 1); - assert_eq!(*p, a.value.v5.f); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-dependent-autofn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-dependent-autofn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-dependent-autofn.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-dependent-autofn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test lifetimes are linked properly when we autoslice a vector. -// Issue #3148. - -// pretty-expanded FIXME #23616 - -fn subslice(v: F) -> F where F: FnOnce() { v } - -fn both(v: F) -> F where F: FnOnce() { - subslice(subslice(v)) -} - -pub fn main() { - both(main); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-dependent-autoslice.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-dependent-autoslice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-dependent-autoslice.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-dependent-autoslice.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test lifetimes are linked properly when we autoslice a vector. -// Issue #3148. - -fn subslice1<'r>(v: &'r [usize]) -> &'r [usize] { v } - -fn both<'r>(v: &'r [usize]) -> &'r [usize] { - subslice1(subslice1(v)) -} - -pub fn main() { - let v = vec![1,2,3]; - both(&v); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-dependent-let-ref.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-dependent-let-ref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-dependent-let-ref.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-dependent-let-ref.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test lifetimes are linked properly when we take reference -// to interior. - -// pretty-expanded FIXME #23616 - -struct Foo(isize); -pub fn main() { - // Here the lifetime of the `&` should be at least the - // block, since a ref binding is created to the interior. - let &Foo(ref _x) = &Foo(3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-early-bound-lifetime-in-assoc-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-early-bound-lifetime-in-assoc-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-early-bound-lifetime-in-assoc-fn.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-early-bound-lifetime-in-assoc-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we are able to compile calls to associated fns like -// `decode()` where the bound on the `Self` parameter references a -// lifetime parameter of the trait. This example indicates why trait -// lifetime parameters must be early bound in the type of the -// associated item. - -// pretty-expanded FIXME #23616 - -use std::marker; - -pub enum Value<'v> { - A(&'v str), - B, -} - -pub trait Decoder<'v> { - fn read(&mut self) -> Value<'v>; -} - -pub trait Decodable<'v, D: Decoder<'v>> { - fn decode(d: &mut D) -> Self; -} - -impl<'v, D: Decoder<'v>> Decodable<'v, D> for () { - fn decode(d: &mut D) -> () { - match d.read() { - Value::A(..) => (), - Value::B => Decodable::decode(d), - } - } -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-early-bound-trait-param.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-early-bound-trait-param.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-early-bound-trait-param.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-early-bound-trait-param.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,144 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests that you can use an early-bound lifetime parameter as -// on of the generic parameters in a trait. - -#![feature(box_syntax)] - -trait Trait<'a> { - fn long(&'a self) -> isize; - fn short<'b>(&'b self) -> isize; -} - -fn poly_invoke<'c, T: Trait<'c>>(x: &'c T) -> (isize, isize) { - let l = x.long(); - let s = x.short(); - (l,s) -} - -fn object_invoke1<'d>(x: &'d Trait<'d>) -> (isize, isize) { - let l = x.long(); - let s = x.short(); - (l,s) -} - -struct Struct1<'e> { - f: &'e (Trait<'e>+'e) -} - -fn field_invoke1<'f, 'g>(x: &'g Struct1<'f>) -> (isize,isize) { - let l = x.f.long(); - let s = x.f.short(); - (l,s) -} - -struct Struct2<'h, 'i:'h> { - f: &'h (Trait<'i>+'h) -} - -fn object_invoke2<'j, 'k>(x: &'k Trait<'j>) -> isize { - x.short() -} - -fn field_invoke2<'l, 'm, 'n>(x: &'n Struct2<'l,'m>) -> isize { - x.f.short() -} - -trait MakerTrait { - fn mk() -> Self; -} - -fn make_val() -> T { - MakerTrait::mk() -} - -trait RefMakerTrait<'q> { - fn mk(_: Self) -> &'q Self; -} - -fn make_ref<'r, T:RefMakerTrait<'r>>(t:T) -> &'r T { - RefMakerTrait::mk(t) -} - -impl<'s> Trait<'s> for (isize,isize) { - fn long(&'s self) -> isize { - let &(x,_) = self; - x - } - fn short<'b>(&'b self) -> isize { - let &(_,y) = self; - y - } -} - -impl<'t> MakerTrait for Box+'static> { - fn mk() -> Box+'static> { - let tup: Box<(isize, isize)> = box (4,5); - tup as Box - } -} - -enum List<'l> { - Cons(isize, &'l List<'l>), - Null -} - -impl<'l> List<'l> { - fn car<'m>(&'m self) -> isize { - match self { - &List::Cons(car, _) => car, - &List::Null => panic!(), - } - } - fn cdr<'n>(&'n self) -> &'l List<'l> { - match self { - &List::Cons(_, cdr) => cdr, - &List::Null => panic!(), - } - } -} - -impl<'t> RefMakerTrait<'t> for List<'t> { - fn mk(l:List<'t>) -> &'t List<'t> { - l.cdr() - } -} - -pub fn main() { - let t = (2,3); - let o = &t as &Trait; - let s1 = Struct1 { f: o }; - let s2 = Struct2 { f: o }; - assert_eq!(poly_invoke(&t), (2,3)); - assert_eq!(object_invoke1(&t), (2,3)); - assert_eq!(field_invoke1(&s1), (2,3)); - assert_eq!(object_invoke2(&t), 3); - assert_eq!(field_invoke2(&s2), 3); - - let m : Box = make_val(); - // assert_eq!(object_invoke1(&*m), (4,5)); - // ~~~~~~~~~~~~~~~~~~~ - // this call yields a compilation error; see compile-fail/dropck-object-cycle.rs - // for details. - assert_eq!(object_invoke2(&*m), 5); - - // The RefMakerTrait above is pretty strange (i.e. it is strange - // to consume a value of type T and return a &T). Easiest thing - // that came to my mind: consume a cell of a linked list and - // return a reference to the list it points to. - let l0 = List::Null; - let l1 = List::Cons(1, &l0); - let l2 = List::Cons(2, &l1); - let rl1 = &l1; - let r = make_ref(l2); - assert_eq!(rl1.car(), r.car()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-early-bound-used-in-bound-method.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-early-bound-used-in-bound-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-early-bound-used-in-bound-method.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-early-bound-used-in-bound-method.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests that you can use a fn lifetime parameter as part of -// the value for a type parameter in a bound. - - -trait GetRef<'a> { - fn get(&self) -> &'a isize; -} - -#[derive(Copy, Clone)] -struct Box<'a> { - t: &'a isize -} - -impl<'a> GetRef<'a> for Box<'a> { - fn get(&self) -> &'a isize { - self.t - } -} - -impl<'a> Box<'a> { - fn add<'b,G:GetRef<'b>>(&self, g2: G) -> isize { - *self.t + *g2.get() - } -} - -pub fn main() { - let b1 = Box { t: &3 }; - assert_eq!(b1.add(b1), 6); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-early-bound-used-in-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-early-bound-used-in-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-early-bound-used-in-bound.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-early-bound-used-in-bound.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests that you can use a fn lifetime parameter as part of -// the value for a type parameter in a bound. - - -trait GetRef<'a, T> { - fn get(&self) -> &'a T; -} - -#[derive(Copy, Clone)] -struct Box<'a, T:'a> { - t: &'a T -} - -impl<'a,T:Clone> GetRef<'a,T> for Box<'a,T> { - fn get(&self) -> &'a T { - self.t - } -} - -fn add<'a,G:GetRef<'a, isize>>(g1: G, g2: G) -> isize { - *g1.get() + *g2.get() -} - -pub fn main() { - let b1 = Box { t: &3 }; - assert_eq!(add(b1, b1), 6); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-early-bound-used-in-type-param.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-early-bound-used-in-type-param.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-early-bound-used-in-type-param.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-early-bound-used-in-type-param.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests that you can use a fn lifetime parameter as part of -// the value for a type parameter in a bound. - - -trait Get { - fn get(&self) -> T; -} - -#[derive(Copy, Clone)] -struct Box { - t: T -} - -impl Get for Box { - fn get(&self) -> T { - self.t.clone() - } -} - -fn add<'a,G:Get<&'a isize>>(g1: G, g2: G) -> isize { - *g1.get() + *g2.get() -} - -pub fn main() { - let b1 = Box { t: &3 }; - assert_eq!(add(b1, b1), 6); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-escape-into-other-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-escape-into-other-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-escape-into-other-fn.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-escape-into-other-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -fn foo(x: &usize) -> &usize { x } -fn bar(x: &usize) -> usize { *x } - -pub fn main() { - let p: Box<_> = box 3; - assert_eq!(bar(foo(&*p)), 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-expl-self.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-expl-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-expl-self.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-expl-self.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that you can insert an explicit lifetime in explicit self. - -// pretty-expanded FIXME #23616 - -struct Foo { - f: usize -} - -impl Foo { - pub fn foo<'a>(&'a self) {} -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-fn-subtyping-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-fn-subtyping-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-fn-subtyping-2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-fn-subtyping-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #2263. - -// Here, `f` is a function that takes a pointer `x` and a function -// `g`, where `g` requires its argument `y` to be in the same region -// that `x` is in. -// pretty-expanded FIXME #23616 - -fn has_same_region(f: Box FnMut(&'a isize, Box)>) { - // `f` should be the type that `wants_same_region` wants, but - // right now the compiler complains that it isn't. - wants_same_region(f); -} - -fn wants_same_region(_f: Box FnMut(&'b isize, Box)>) { -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-fn-subtyping.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-fn-subtyping.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-fn-subtyping.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-fn-subtyping.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #2263. - -// pretty-expanded FIXME #23616 - -#![allow(unused_variables)] - -// Should pass region checking. -fn ok(f: Box) { - // Here, g is a function that can accept a usize pointer with - // lifetime r, and f is a function that can accept a usize pointer - // with any lifetime. The assignment g = f should be OK (i.e., - // f's type should be a subtype of g's type), because f can be - // used in any context that expects g's type. But this currently - // fails. - let mut g: Box FnMut(&'r usize)> = Box::new(|x| { }); - g = f; -} - -// This version is the same as above, except that here, g's type is -// inferred. -fn ok_inferred(f: Box) { - let mut g: Box FnMut(&'r usize)> = Box::new(|_| {}); - g = f; -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-free-region-outlives-static-outlives-free-region.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-free-region-outlives-static-outlives-free-region.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-free-region-outlives-static-outlives-free-region.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-free-region-outlives-static-outlives-free-region.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we recognize that if you have -// -// 'a : 'static -// -// then -// -// 'a : 'b - -fn test<'a,'b>(x: &'a i32) -> &'b i32 - where 'a: 'static -{ - x -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-borrow-scope-addr-of.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-borrow-scope-addr-of.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-borrow-scope-addr-of.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-borrow-scope-addr-of.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::mem::swap; - -pub fn main() { - let mut x = 4; - - for i in 0_usize..3 { - // ensure that the borrow in this alt - // does not interfere with the swap - // below. note that it would it you - // naively borrowed &x for the lifetime - // of the variable x, as we once did - match i { - i => { - let y = &x; - assert!(i < *y); - } - } - let mut y = 4; - swap(&mut y, &mut x); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-borrow-scope.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-borrow-scope.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-borrow-scope.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-borrow-scope.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -struct Point {x: isize, y: isize} - -fn x_coord(p: &Point) -> &isize { - return &p.x; -} - -pub fn main() { - let p: Box<_> = box Point {x: 3, y: 4}; - let xc = x_coord(&*p); - assert_eq!(*xc, 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-borrow-scope-view.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-borrow-scope-view.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-borrow-scope-view.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-borrow-scope-view.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -fn view(x: &[T]) -> &[T] {x} - -pub fn main() { - let v = vec![1, 2, 3]; - let x = view(&v); - let y = view(x); - assert!((v[0] == x[0]) && (v[0] == y[0])); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-borrow-scope-within-loop-ok.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-borrow-scope-within-loop-ok.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-borrow-scope-within-loop-ok.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-borrow-scope-within-loop-ok.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -fn borrow(x: &T) -> &T {x} - -pub fn main() { - let x: Box<_> = box 3; - loop { - let y = borrow(&*x); - assert_eq!(*x, *y); - break; - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-call-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-call-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-call-2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-call-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn takes_two(x: &isize, y: &isize) -> isize { *x + *y } - -fn with(f: F) -> T where F: FnOnce(&isize) -> T { - f(&20) -} - -fn has_one<'a>(x: &'a isize) -> isize { - with(|y| takes_two(x, y)) -} - -pub fn main() { - assert_eq!(has_one(&2), 22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-call.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-call.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-call.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-call.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn takes_two(x: &isize, y: &isize) -> isize { *x + *y } - -fn has_two<'a,'b>(x: &'a isize, y: &'b isize) -> isize { - takes_two(x, y) -} - -pub fn main() { - assert_eq!(has_two(&20, &2), 22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-contravariance-due-to-ret.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-contravariance-due-to-ret.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-contravariance-due-to-ret.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-contravariance-due-to-ret.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - -struct boxed_int<'a> { - f: &'a isize, -} - -fn max<'r>(bi: &'r boxed_int, f: &'r isize) -> isize { - if *bi.f > *f {*bi.f} else {*f} -} - -fn with(bi: &boxed_int) -> isize { - let i = 22; - max(bi, &i) -} - -pub fn main() { - let g = 21; - let foo = boxed_int { f: &g }; - assert_eq!(with(&foo), 22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-reborrow-ref-mut-recurse.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-reborrow-ref-mut-recurse.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-reborrow-ref-mut-recurse.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-reborrow-ref-mut-recurse.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test an edge case in region inference: the lifetime of the borrow -// of `*x` must be extended to at least 'a. - -// pretty-expanded FIXME #23616 - -fn foo<'a,'b>(x: &'a &'b mut isize) -> &'a isize { - let y = &*x; // should be inferred to have type &'a &'b mut isize... - - // ...because if we inferred, say, &'x &'b mut isize where 'x <= 'a, - // this reborrow would be illegal: - &**y -} - -pub fn main() { - /* Just want to know that it compiles. */ -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-region-in-fn-but-not-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-region-in-fn-but-not-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-region-in-fn-but-not-type.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-region-in-fn-but-not-type.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - -// check that the &isize here does not cause us to think that `foo` -// contains region pointers -// pretty-expanded FIXME #23616 - -struct foo(Box); - -fn take_foo(x: T) {} - -fn have_foo(f: foo) { - take_foo(f); -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-static-from-proc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-static-from-proc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-static-from-proc.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-infer-static-from-proc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -// Check that the 'static bound on a proc influences lifetimes of -// region variables contained within (otherwise, region inference will -// give `x` a very short lifetime). - -// pretty-expanded FIXME #23616 - -static i: usize = 3; -fn foo(_: F) {} -fn read(_: usize) { } -pub fn main() { - let x = &i; - foo(move|| { - read(*x); - }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-issue-21422.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-issue-21422.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-issue-21422.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-issue-21422.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for issue #21422, which was related to failing to -// add inference constraints that the operands of a binary operator -// should outlive the binary operation itself. - -// pretty-expanded FIXME #23616 - -pub struct P<'a> { - _ptr: *const &'a u8, -} - -impl <'a> PartialEq for P<'a> { - fn eq(&self, other: &P<'a>) -> bool { - (self as *const _) == (other as *const _) - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-issue-22246.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-issue-22246.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-issue-22246.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-issue-22246.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for issue #22246 -- we should be able to deduce -// that `&'a B::Owned` implies that `B::Owned : 'a`. - -// pretty-expanded FIXME #23616 - -#![allow(dead_code)] - -use std::ops::Deref; - -pub trait ToOwned: Sized { - type Owned: Borrow; - fn to_owned(&self) -> Self::Owned; -} - -pub trait Borrow { - fn borrow(&self) -> &Borrowed; -} - -pub struct Foo { - owned: B::Owned -} - -fn foo(this: &Foo) -> &B { - this.owned.borrow() -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-lifetime-nonfree-late-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-lifetime-nonfree-late-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-lifetime-nonfree-late-bound.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-lifetime-nonfree-late-bound.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This is a regression test for the ICE from issue #10846. -// -// The original issue causing the ICE: the LUB-computations during -// type inference were encountering late-bound lifetimes, and -// asserting that such lifetimes should have already been substituted -// with a concrete lifetime. -// -// However, those encounters were occurring within the lexical scope -// of the binding for the late-bound lifetime; that is, the late-bound -// lifetimes were perfectly valid. The core problem was that the type -// folding code was over-zealously passing back all lifetimes when -// doing region-folding, when really all clients of the region-folding -// case only want to see FREE lifetime variables, not bound ones. - -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - -pub fn main() { - fn explicit() { - fn test(_x: Option>) where F: FnMut(Box FnMut(&'a isize)>) {} - test(Some(box |_f: Box FnMut(&'a isize)>| {})); - } - - // The code below is shorthand for the code above (and more likely - // to represent what one encounters in practice). - fn implicit() { - fn test(_x: Option>) where F: FnMut(Box< FnMut(& isize)>) {} - test(Some(box |_f: Box< FnMut(& isize)>| {})); - } - - explicit(); - implicit(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-lifetime-static-items-enclosing-scopes.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-lifetime-static-items-enclosing-scopes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-lifetime-static-items-enclosing-scopes.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-lifetime-static-items-enclosing-scopes.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This test verifies that temporary lifetime is correctly computed -// for static objects in enclosing scopes. - - -use std::cmp::PartialEq; - -fn f(o: &mut Option) { - assert_eq!(*o, None); -} - -pub fn main() { - mod t { - enum E {V=1, A=0} - static C: E = E::V; - } - - f::(&mut None); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-link-fn-args.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-link-fn-args.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-link-fn-args.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-link-fn-args.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that region inference correctly links up the regions when a -// `ref` borrow occurs inside a fn argument. - -// pretty-expanded FIXME #23616 - -#![allow(dead_code)] - -fn with<'a, F>(_: F) where F: FnOnce(&'a Vec) -> &'a Vec { } - -fn foo() { - with(|&ref ints| ints); -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-lub-ref-ref-rc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-lub-ref-ref-rc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-lub-ref-ref-rc.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-lub-ref-ref-rc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test a corner case of LUB coercion. In this case, one arm of the -// match requires a deref coercion and the other doesn't, and there -// is an extra `&` on the `rc`. We want to be sure that the lifetime -// assigned to this `&rc` value is not `'a` but something smaller. In -// other words, the type from `rc` is `&'a Rc` and the type -// from `&rc` should be `&'x &'a Rc`, where `'x` is something -// small. - -use std::rc::Rc; - -#[derive(Clone)] -enum CachedMir<'mir> { - Ref(&'mir String), - Owned(Rc), -} - -impl<'mir> CachedMir<'mir> { - fn get_ref<'a>(&'a self) -> &'a String { - match *self { - CachedMir::Ref(r) => r, - CachedMir::Owned(ref rc) => &rc, - } - } -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-mock-codegen.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-mock-codegen.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-mock-codegen.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-mock-codegen.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -#![feature(allocator_api)] - -use std::alloc::{Alloc, Global, Layout, handle_alloc_error}; -use std::ptr::NonNull; - -struct arena(()); - -struct Bcx<'a> { - fcx: &'a Fcx<'a> -} - -struct Fcx<'a> { - arena: &'a arena, - ccx: &'a Ccx -} - -struct Ccx { - x: isize -} - -fn alloc<'a>(_bcx : &'a arena) -> &'a Bcx<'a> { - unsafe { - let layout = Layout::new::(); - let ptr = Global.alloc(layout).unwrap_or_else(|_| handle_alloc_error(layout)); - &*(ptr.as_ptr() as *const _) - } -} - -fn h<'a>(bcx : &'a Bcx<'a>) -> &'a Bcx<'a> { - return alloc(bcx.fcx.arena); -} - -fn g(fcx : &Fcx) { - let bcx = Bcx { fcx: fcx }; - let bcx2 = h(&bcx); - unsafe { - Global.dealloc(NonNull::new_unchecked(bcx2 as *const _ as *mut _), Layout::new::()); - } -} - -fn f(ccx : &Ccx) { - let a = arena(()); - let fcx = Fcx { arena: &a, ccx: ccx }; - return g(&fcx); -} - -pub fn main() { - let ccx = Ccx { x: 0 }; - f(&ccx); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-no-bound-in-argument-cleanup.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-no-bound-in-argument-cleanup.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-no-bound-in-argument-cleanup.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-no-bound-in-argument-cleanup.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -use std::marker; - -pub struct Foo(marker::PhantomData); - -impl Iterator for Foo { - type Item = T; - - fn next(&mut self) -> Option { - None - } -} - -impl Drop for Foo { - fn drop(&mut self) { - self.next(); - } -} - -pub fn foo<'a>(_: Foo<&'a ()>) {} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-no-variance-from-fn-generics.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-no-variance-from-fn-generics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-no-variance-from-fn-generics.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-no-variance-from-fn-generics.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #12856: a lifetime formal binding introduced by a generic fn -// should not upset the variance inference for actual occurrences of -// that lifetime in type expressions. - - -pub trait HasLife<'a> { - fn dummy(&'a self) { } // just to induce a variance on 'a -} - -trait UseLife01 { - fn refs<'a, H: HasLife<'a>>(&'a self) -> H; -} - -trait UseLife02 { - fn refs<'a, T: 'a, H: HasType<&'a T>>(&'a self) -> H; -} - - -pub trait HasType -{ - fn dummy(&self, t: T) -> T { panic!() } -} - - -trait UseLife03 { - fn refs<'a, H: HasType<&'a T>>(&'a self) -> H where T: 'a; -} - - -// (The functions below were not actually a problem observed during -// fixing of #12856; they just seem like natural tests to put in to -// cover a couple more points in the testing space) - -pub fn top_refs_1<'a, H: HasLife<'a>>(_s: &'a ()) -> H { - unimplemented!() -} - -pub fn top_refs_2<'a, T: 'a, H: HasType<&'a T>>(_s: &'a ()) -> H { - unimplemented!() -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-nullary-variant.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-nullary-variant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-nullary-variant.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-nullary-variant.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -enum roption<'a> { - a, b(&'a usize) -} - -fn mk(cond: bool, ptr: &usize) -> roption { - if cond {roption::a} else {roption::b(ptr)} -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-params.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-params.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-params.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-params.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -fn region_identity(x: &usize) -> &usize { x } - -fn apply(t: T, f: F) -> T where F: FnOnce(T) -> T { f(t) } - -fn parameterized(x: &usize) -> usize { - let z = apply(x, ({|y| - region_identity(y) - })); - *z -} - -pub fn main() { - let x = 3; - assert_eq!(parameterized(&x), 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-reassign-let-bound-pointer.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-reassign-let-bound-pointer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-reassign-let-bound-pointer.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-reassign-let-bound-pointer.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check that the type checker permits us to reassign `z` which -// started out with a longer lifetime and was reassigned to a shorter -// one (it should infer to be the intersection). - -// pretty-expanded FIXME #23616 - -fn foo(x: &isize) { - let a = 1; - let mut z = x; - z = &a; -} - -pub fn main() { - foo(&1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-reassign-match-bound-pointer.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-reassign-match-bound-pointer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-reassign-match-bound-pointer.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-reassign-match-bound-pointer.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check that the type checker permits us to reassign `z` which -// started out with a longer lifetime and was reassigned to a shorter -// one (it should infer to be the intersection). - -// pretty-expanded FIXME #23616 - -fn foo(x: &isize) { - let a = 1; - match x { - mut z => { - z = &a; - } - } -} - -pub fn main() { - foo(&1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-refcell.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-refcell.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-refcell.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-refcell.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This is a regression test for something that only came up while -// attempting to bootstrap librustc with new destructor lifetime -// semantics. - - -use std::collections::HashMap; -use std::cell::RefCell; - -// This version does not yet work (associated type issues)... -#[cfg(cannot_use_this_yet)] -fn foo<'a>(map: RefCell>) { - let one = [1]; - assert_eq!(map.borrow().get("one"), Some(&one[..])); -} - -#[cfg(cannot_use_this_yet_either)] -// ... and this version does not work (the lifetime of `one` is -// supposed to match the lifetime `'a`) ... -fn foo<'a>(map: RefCell>) { - let one = [1]; - assert_eq!(map.borrow().get("one"), Some(&&one[..])); -} - -#[cfg(all(not(cannot_use_this_yet),not(cannot_use_this_yet_either)))] -fn foo<'a>(map: RefCell>) { - // ...so instead we walk through the trivial slice and make sure - // it contains the element we expect. - - for (i, &x) in map.borrow().get("one").unwrap().iter().enumerate() { - assert_eq!((i, x), (0, 1)); - } -} - -fn main() { - let zer = [0]; - let one = [1]; - let two = [2]; - let mut map = HashMap::new(); - map.insert("zero", &zer[..]); - map.insert("one", &one[..]); - map.insert("two", &two[..]); - let map = RefCell::new(map); - foo(map); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-relate-bound-regions-on-closures-to-inference-variables.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that this fairly specialized, but also reasonable, pattern -// typechecks. The pattern involves regions bound in closures that -// wind up related to inference variables. -// -// NB. Changes to the region implementations have broken this pattern -// a few times, but it happens to be used in the compiler so those -// changes were caught. However, those uses in the compiler could -// easily get changed or refactored away in the future. - -#![feature(box_syntax)] - -struct Ctxt<'tcx> { - x: &'tcx Vec -} - -struct Foo<'a,'tcx:'a> { - cx: &'a Ctxt<'tcx>, -} - -impl<'a,'tcx> Foo<'a,'tcx> { - fn bother(&mut self) -> isize { - self.elaborate_bounds(Box::new(|this| { - // (*) Here: type of `this` is `&'f0 Foo<&'f1, '_2>`, - // where `'f0` and `'f1` are fresh, free regions that - // result from the bound regions on the closure, and `'2` - // is a region inference variable created by the call. Due - // to the constraints on the type, we find that `'_2 : 'f1 - // + 'f2` must hold (and can be assumed by the callee). - // Region inference has to do some clever stuff to avoid - // inferring `'_2` to be `'static` in this case, because - // it is created outside the closure but then related to - // regions bound by the closure itself. See the - // `region_constraints.rs` file (and the `givens` field, in - // particular) for more details. - this.foo() - })) - } - - fn foo(&mut self) -> isize { - 22 - } - - fn elaborate_bounds( - &mut self, - mut mk_cand: Box FnMut(&mut Foo<'b, 'tcx>) -> isize>) - -> isize - { - mk_cand(self) - } -} - -fn main() { - let v = vec![]; - let cx = Ctxt { x: &v }; - let mut foo = Foo { cx: &cx }; - assert_eq!(foo.bother(), 22); // just so the code is not dead, basically -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-return-interior-of-option.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-return-interior-of-option.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-return-interior-of-option.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-return-interior-of-option.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn get(opt: &Option) -> &T { - match *opt { - Some(ref v) => v, - None => panic!("none") - } -} - -pub fn main() { - let mut x = Some(23); - - { - let y = get(&x); - assert_eq!(*y, 23); - } - - x = Some(24); - - { - let y = get(&x); - assert_eq!(*y, 24); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-scope-chain-example.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-scope-chain-example.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-scope-chain-example.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-scope-chain-example.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This is an example where the older inference algorithm failed. The -// specifics of why it failed are somewhat, but not entirely, tailed -// to the algorithm. Ultimately the problem is that when computing the -// mutual supertype of both sides of the `if` it would be faced with a -// choice of tightening bounds or unifying variables and it took the -// wrong path. The new algorithm avoids this problem and hence this -// example typechecks correctly. - -// pretty-expanded FIXME #23616 - -enum ScopeChain<'a> { - Link(Scope<'a>), - End -} - -type Scope<'a> = &'a ScopeChain<'a>; - -struct OuterContext; - -struct Context<'a> { - foo: &'a OuterContext -} - -impl<'a> Context<'a> { - fn foo(&mut self, scope: Scope) { - let link = if 1 < 2 { - let l = ScopeChain::Link(scope); - self.take_scope(&l); - l - } else { - ScopeChain::Link(scope) - }; - self.take_scope(&link); - } - - fn take_scope(&mut self, x: Scope) { - } -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-self-impls.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-self-impls.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-self-impls.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-self-impls.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -struct Clam<'a> { - chowder: &'a isize -} - -trait get_chowder<'a> { - fn get_chowder(&self) -> &'a isize; -} - -impl<'a> get_chowder<'a> for Clam<'a> { - fn get_chowder(&self) -> &'a isize { return self.chowder; } -} - -pub fn main() { - let clam = Clam { chowder: &3 }; - println!("{}", *clam.get_chowder()); - clam.get_chowder(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-self-in-enums.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-self-in-enums.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-self-in-enums.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-self-in-enums.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -enum int_wrapper<'a> { - int_wrapper_ctor(&'a isize) -} - -pub fn main() { - let x = 3; - let y = int_wrapper::int_wrapper_ctor(&x); - let mut z : &isize; - match y { - int_wrapper::int_wrapper_ctor(zz) => { z = zz; } - } - println!("{}", *z); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-simple.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-simple.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-simple.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn main() { - let mut x: isize = 3; - let y: &mut isize = &mut x; - *y = 5; - println!("{}", *y); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-static-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-static-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-static-bound.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-static-bound.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn invariant_id<'a,'b>(t: &'b mut &'static ()) -> &'b mut &'a () - where 'a: 'static { t } -fn static_id<'a>(t: &'a ()) -> &'static () - where 'a: 'static { t } -fn static_id_indirect<'a,'b>(t: &'a ()) -> &'static () - where 'a: 'b, 'b: 'static { t } -fn ref_id<'a>(t: &'a ()) -> &'a () where 'static: 'a { t } - -static UNIT: () = (); - -fn main() -{ - let mut val : &'static () = &UNIT; - invariant_id(&mut val); - static_id(val); - static_id_indirect(val); - ref_id(val); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-static-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-static-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-static-closure.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-static-closure.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -struct closure_box<'a> { - cl: Box, -} - -fn box_it<'a>(x: Box) -> closure_box<'a> { - closure_box {cl: x} -} - -fn call_static_closure(mut cl: closure_box<'static>) { - (cl.cl)(); -} - -pub fn main() { - let cl_box = box_it(Box::new(|| println!("Hello, world!"))); - call_static_closure(cl_box); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-trait-object-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-trait-object-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-trait-object-1.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-trait-object-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This is a regression test for something that only came up while -// attempting to bootstrap libsyntax; it is adapted from -// `syntax::ext::tt::generic_extension`. - - -pub struct E<'a> { - pub f: &'a u8, -} -impl<'b> E<'b> { - pub fn m(&self) -> &'b u8 { self.f } -} - -pub struct P<'c> { - pub g: &'c u8, -} -pub trait M { - fn n(&self) -> u8; -} -impl<'d> M for P<'d> { - fn n(&self) -> u8 { *self.g } -} - -fn extension<'e>(x: &'e E<'e>) -> Box { - loop { - let p = P { g: x.m() }; - return Box::new(p) as Box; - } -} - -fn main() { - let w = E { f: &10 }; - let o = extension(&w); - assert_eq!(o.n(), 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-variance-contravariant-use-contravariant.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-variance-contravariant-use-contravariant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-variance-contravariant-use-contravariant.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-variance-contravariant-use-contravariant.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that a type which is contravariant with respect to its region -// parameter compiles successfully when used in a contravariant way. -// -// Note: see compile-fail/variance-regions-*.rs for the tests that check that the -// variance inference works in the first place. - -// pretty-expanded FIXME #23616 - -struct Contravariant<'a> { - f: &'a isize -} - -fn use_<'a>(c: Contravariant<'a>) { - let x = 3; - - // 'b winds up being inferred to this call. - // Contravariant<'a> <: Contravariant<'call> is true - // if 'call <= 'a, which is true, so no error. - collapse(&x, c); - - fn collapse<'b>(x: &'b isize, c: Contravariant<'b>) { } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-variance-covariant-use-covariant.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-variance-covariant-use-covariant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-variance-covariant-use-covariant.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/regions/regions-variance-covariant-use-covariant.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that a type which is covariant with respect to its region -// parameter is successful when used in a covariant way. -// -// Note: see compile-fail/variance-regions-*.rs for the tests that -// check that the variance inference works in the first place. - -// This is covariant with respect to 'a, meaning that -// Covariant<'foo> <: Covariant<'static> because -// 'foo <= 'static -// pretty-expanded FIXME #23616 - -struct Covariant<'a> { - f: extern "Rust" fn(&'a isize) -} - -fn use_<'a>(c: Covariant<'a>) { - // OK Because Covariant<'a> <: Covariant<'static> iff 'a <= 'static - let _: Covariant<'static> = c; -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1014-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1014-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1014-2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1014-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(libc)] - -extern crate libc; - -type DWORD = u32; -type HANDLE = *mut u8; -type BOOL = i32; - -#[cfg(windows)] -extern "system" { - fn SetStdHandle(nStdHandle: DWORD, nHandle: HANDLE) -> BOOL; -} - -#[cfg(windows)] -fn close_stdout() { - const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD; - unsafe { SetStdHandle(STD_OUTPUT_HANDLE, 0 as HANDLE); } -} - -#[cfg(windows)] -fn main() { - close_stdout(); - println!("hello world"); -} - -#[cfg(not(windows))] -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1014.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1014.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1014.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1014.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-cloudabi stdout does not map to file descriptor 1 by default -// ignore-wasm32-bare no libc - -#![feature(libc)] - -extern crate libc; - -type DWORD = u32; -type HANDLE = *mut u8; - -#[cfg(windows)] -extern "system" { - fn GetStdHandle(which: DWORD) -> HANDLE; - fn CloseHandle(handle: HANDLE) -> i32; -} - -#[cfg(windows)] -fn close_stdout() { - const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD; - unsafe { CloseHandle(GetStdHandle(STD_OUTPUT_HANDLE)); } -} - -#[cfg(not(windows))] -fn close_stdout() { - unsafe { libc::close(1); } -} - -fn main() { - close_stdout(); - println!("hello world"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1445/eq-allows-match-on-ty-in-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1445/eq-allows-match-on-ty-in-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1445/eq-allows-match-on-ty-in-macro.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1445/eq-allows-match-on-ty-in-macro.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(dead_code)] - -macro_rules! foo { - (#[$attr:meta] $x:ident) => { - #[$attr] - struct $x { - x: u32 - } - } -} - -foo! { #[derive(PartialEq, Eq)] Foo } - -const FOO: Foo = Foo { x: 0 }; - -fn main() { - let y = Foo { x: 1 }; - match y { - FOO => { } - _ => { } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1445/eq-allows-match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1445/eq-allows-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1445/eq-allows-match.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1445/eq-allows-match.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(dead_code)] - -#[derive(PartialEq, Eq)] -struct Foo { - x: u32 -} - -const FOO: Foo = Foo { x: 0 }; - -fn main() { - let y = Foo { x: 1 }; - match y { - FOO => { } - _ => { } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1623.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1623.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1623.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1623.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -#![allow(dead_code)] - -// very simple test for a 'static static with default lifetime -static STATIC_STR: &str = "&'static str"; -const CONST_STR: &str = "&'static str"; - -// this should be the same as without default: -static EXPLICIT_STATIC_STR: &'static str = "&'static str"; -const EXPLICIT_CONST_STR: &'static str = "&'static str"; - -// a function that elides to an unbound lifetime for both in- and output -fn id_u8_slice(arg: &[u8]) -> &[u8] { - arg -} - -// one with a function, argument elided -static STATIC_SIMPLE_FN: &fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]); -const CONST_SIMPLE_FN: &fn(&[u8]) -> &[u8] = &(id_u8_slice as fn(&[u8]) -> &[u8]); - -// this should be the same as without elision -static STATIC_NON_ELIDED_fN: &for<'a> fn(&'a [u8]) -> &'a [u8] = - &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); -const CONST_NON_ELIDED_fN: &for<'a> fn(&'a [u8]) -> &'a [u8] = - &(id_u8_slice as for<'a> fn(&'a [u8]) -> &'a [u8]); - -// another function that elides, each to a different unbound lifetime -fn multi_args(a: &u8, b: &u8, c: &u8) {} - -static STATIC_MULTI_FN: &fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8)); -const CONST_MULTI_FN: &fn(&u8, &u8, &u8) = &(multi_args as fn(&u8, &u8, &u8)); - -struct Foo<'a> { - bools: &'a [bool], -} - -static STATIC_FOO: Foo = Foo { bools: &[true, false] }; -const CONST_FOO: Foo = Foo { bools: &[true, false] }; - -type Bar<'a> = Foo<'a>; - -static STATIC_BAR: Bar = Bar { bools: &[true, false] }; -const CONST_BAR: Bar = Bar { bools: &[true, false] }; - -type Baz<'a> = fn(&'a [u8]) -> Option; - -fn baz(e: &[u8]) -> Option { - e.first().map(|x| *x) -} - -static STATIC_BAZ: &Baz = &(baz as Baz); -const CONST_BAZ: &Baz = &(baz as Baz); - -static BYTES: &[u8] = &[1, 2, 3]; - -fn main() { - // make sure that the lifetime is actually elided (and not defaulted) - let x = &[1u8, 2, 3]; - STATIC_SIMPLE_FN(x); - CONST_SIMPLE_FN(x); - - STATIC_BAZ(BYTES); // neees static lifetime - CONST_BAZ(BYTES); - - // make sure this works with different lifetimes - let a = &1; - { - let b = &2; - let c = &3; - CONST_MULTI_FN(a, b, c); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1717/auxiliary/clibrary.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1717/auxiliary/clibrary.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1717/auxiliary/clibrary.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1717/auxiliary/clibrary.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic -#![crate_type = "staticlib"] - -#[no_mangle] -pub extern "C" fn foo(x:i32) -> i32 { x } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1717/library-override.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1717/library-override.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1717/library-override.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1717/library-override.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare no libc to test ffi with -// compile-flags: -lstatic=wronglibrary:rust_test_helpers - -#[link(name = "wronglibrary", kind = "dylib")] -extern "C" { - pub fn rust_dbg_extern_identity_u32(x: u32) -> u32; -} - -fn main() { - unsafe { - rust_dbg_extern_identity_u32(42); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1789-as-cell/from-mut.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1789-as-cell/from-mut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1789-as-cell/from-mut.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1789-as-cell/from-mut.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(as_cell)] - -use std::cell::Cell; - -fn main() { - let slice: &mut [i32] = &mut [1, 2, 3]; - let cell_slice: &Cell<[i32]> = Cell::from_mut(slice); - let slice_cell: &[Cell] = cell_slice.as_slice_of_cells(); - - assert_eq!(slice_cell.len(), 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1857-drop-order.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1857-drop-order.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1857-drop-order.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc1857-drop-order.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,234 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare compiled with panic=abort by default - -#![allow(dead_code, unreachable_code)] - -use std::cell::RefCell; -use std::rc::Rc; -use std::panic::{self, AssertUnwindSafe, UnwindSafe}; - -// This struct is used to record the order in which elements are dropped -struct PushOnDrop { - vec: Rc>>, - val: u32 -} - -impl PushOnDrop { - fn new(val: u32, vec: Rc>>) -> PushOnDrop { - PushOnDrop { vec, val } - } -} - -impl Drop for PushOnDrop { - fn drop(&mut self) { - self.vec.borrow_mut().push(self.val) - } -} - -impl UnwindSafe for PushOnDrop { } - -// Structs -struct TestStruct { - x: PushOnDrop, - y: PushOnDrop, - z: PushOnDrop -} - -// Tuple structs -struct TestTupleStruct(PushOnDrop, PushOnDrop, PushOnDrop); - -// Enum variants -enum TestEnum { - Tuple(PushOnDrop, PushOnDrop, PushOnDrop), - Struct { x: PushOnDrop, y: PushOnDrop, z: PushOnDrop } -} - -fn test_drop_tuple() { - // Tuple fields are dropped in the same order they are declared - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let test_tuple = (PushOnDrop::new(1, dropped_fields.clone()), - PushOnDrop::new(2, dropped_fields.clone())); - drop(test_tuple); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); - - // Panic during construction means that fields are treated as local variables - // Therefore they are dropped in reverse order of initialization - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - (PushOnDrop::new(2, cloned.clone()), - PushOnDrop::new(1, cloned.clone()), - panic!("this panic is caught :D")); - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); -} - -fn test_drop_struct() { - // Struct fields are dropped in the same order they are declared - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let test_struct = TestStruct { - x: PushOnDrop::new(1, dropped_fields.clone()), - y: PushOnDrop::new(2, dropped_fields.clone()), - z: PushOnDrop::new(3, dropped_fields.clone()), - }; - drop(test_struct); - assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); - - // The same holds for tuple structs - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let test_tuple_struct = TestTupleStruct(PushOnDrop::new(1, dropped_fields.clone()), - PushOnDrop::new(2, dropped_fields.clone()), - PushOnDrop::new(3, dropped_fields.clone())); - drop(test_tuple_struct); - assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); - - // Panic during struct construction means that fields are treated as local variables - // Therefore they are dropped in reverse order of initialization - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - TestStruct { - x: PushOnDrop::new(2, cloned.clone()), - y: PushOnDrop::new(1, cloned.clone()), - z: panic!("this panic is caught :D") - }; - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); - - // Test with different initialization order - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - TestStruct { - y: PushOnDrop::new(2, cloned.clone()), - x: PushOnDrop::new(1, cloned.clone()), - z: panic!("this panic is caught :D") - }; - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); - - // The same holds for tuple structs - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - TestTupleStruct(PushOnDrop::new(2, cloned.clone()), - PushOnDrop::new(1, cloned.clone()), - panic!("this panic is caught :D")); - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); -} - -fn test_drop_enum() { - // Enum variants are dropped in the same order they are declared - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let test_struct_enum = TestEnum::Struct { - x: PushOnDrop::new(1, dropped_fields.clone()), - y: PushOnDrop::new(2, dropped_fields.clone()), - z: PushOnDrop::new(3, dropped_fields.clone()) - }; - drop(test_struct_enum); - assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); - - // The same holds for tuple enum variants - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let test_tuple_enum = TestEnum::Tuple(PushOnDrop::new(1, dropped_fields.clone()), - PushOnDrop::new(2, dropped_fields.clone()), - PushOnDrop::new(3, dropped_fields.clone())); - drop(test_tuple_enum); - assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); - - // Panic during enum construction means that fields are treated as local variables - // Therefore they are dropped in reverse order of initialization - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - TestEnum::Struct { - x: PushOnDrop::new(2, cloned.clone()), - y: PushOnDrop::new(1, cloned.clone()), - z: panic!("this panic is caught :D") - }; - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); - - // Test with different initialization order - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - TestEnum::Struct { - y: PushOnDrop::new(2, cloned.clone()), - x: PushOnDrop::new(1, cloned.clone()), - z: panic!("this panic is caught :D") - }; - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); - - // The same holds for tuple enum variants - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - TestEnum::Tuple(PushOnDrop::new(2, cloned.clone()), - PushOnDrop::new(1, cloned.clone()), - panic!("this panic is caught :D")); - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); -} - -fn test_drop_list() { - // Elements in a Vec are dropped in the same order they are pushed - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let xs = vec![PushOnDrop::new(1, dropped_fields.clone()), - PushOnDrop::new(2, dropped_fields.clone()), - PushOnDrop::new(3, dropped_fields.clone())]; - drop(xs); - assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); - - // The same holds for arrays - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let xs = [PushOnDrop::new(1, dropped_fields.clone()), - PushOnDrop::new(2, dropped_fields.clone()), - PushOnDrop::new(3, dropped_fields.clone())]; - drop(xs); - assert_eq!(*dropped_fields.borrow(), &[1, 2, 3]); - - // Panic during vec construction means that fields are treated as local variables - // Therefore they are dropped in reverse order of initialization - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - vec![ - PushOnDrop::new(2, cloned.clone()), - PushOnDrop::new(1, cloned.clone()), - panic!("this panic is caught :D") - ]; - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); - - // The same holds for arrays - let dropped_fields = Rc::new(RefCell::new(Vec::new())); - let cloned = AssertUnwindSafe(dropped_fields.clone()); - panic::catch_unwind(|| { - [ - PushOnDrop::new(2, cloned.clone()), - PushOnDrop::new(1, cloned.clone()), - panic!("this panic is caught :D") - ]; - }).err().unwrap(); - assert_eq!(*dropped_fields.borrow(), &[1, 2]); -} - -fn main() { - test_drop_tuple(); - test_drop_struct(); - test_drop_enum(); - test_drop_list(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-box-dyn-error.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::error::Error; - -fn main() -> Result<(), Box> { - Ok(()) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-empty.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-empty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-empty.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-empty.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-exitcode.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-exitcode.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-exitcode.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-exitcode.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(process_exitcode_placeholder)] - -use std::process::ExitCode; - -fn main() -> ExitCode { - ExitCode::SUCCESS -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-impl-termination.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-impl-termination.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-impl-termination.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-impl-termination.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(termination_trait_lib)] - -fn main() -> impl std::process::Termination { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-result-box-error_ok.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-result-box-error_ok.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-result-box-error_ok.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-result-box-error_ok.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::io::Error; - -fn main() -> Result<(), Box> { - Ok(()) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-result.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-result.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-result.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-result.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::io::Error; - -fn main() -> Result<(), Error> { - Ok(()) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-str.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-str.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-str.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-1937-termination-trait/termination-trait-for-str.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn main() -> Result<(), &'static str> { - Ok(()) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/box.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/box.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/box.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/box.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax, box_patterns)] - -struct Foo{} - -pub fn main() { - let b = box Foo{}; - let box f = &b; - let _: &Foo = f; - - match &&&b { - box f => { - let _: &Foo = f; - }, - _ => panic!(), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/constref.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/constref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/constref.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/constref.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -const CONST_REF: &[u8; 3] = b"foo"; - -trait Foo { - const CONST_REF_DEFAULT: &'static [u8; 3] = b"bar"; - const CONST_REF: &'static [u8; 3]; -} - -impl Foo for i32 { - const CONST_REF: &'static [u8; 3] = b"jjj"; -} - -impl Foo for i64 { - const CONST_REF_DEFAULT: &'static [u8; 3] = b"ggg"; - const CONST_REF: &'static [u8; 3] = b"fff"; -} - -// Check that (associated and free) const references are not mistaken for a -// non-reference pattern (in which case they would be auto-dereferenced, making -// the types mismatched). - -fn const_ref() -> bool { - let f = b"foo"; - match f { - CONST_REF => true, - _ => false, - } -} - -fn associated_const_ref() -> bool { - match (b"bar", b"jjj", b"ggg", b"fff") { - (i32::CONST_REF_DEFAULT, i32::CONST_REF, i64::CONST_REF_DEFAULT, i64::CONST_REF) => true, - _ => false, - } -} - -pub fn main() { - assert!(const_ref()); - assert!(associated_const_ref()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/enum.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/enum.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -enum Wrapper { - Wrap(i32), -} - -use Wrapper::Wrap; - -pub fn main() { - let Wrap(x) = &Wrap(3); - println!("{}", *x); - - let Wrap(x) = &mut Wrap(3); - println!("{}", *x); - - if let Some(x) = &Some(3) { - println!("{}", *x); - } else { - panic!(); - } - - if let Some(x) = &mut Some(3) { - println!("{}", *x); - } else { - panic!(); - } - - if let Some(x) = &mut Some(3) { - *x += 1; - } else { - panic!(); - } - - while let Some(x) = &Some(3) { - println!("{}", *x); - break; - } - while let Some(x) = &mut Some(3) { - println!("{}", *x); - break; - } - while let Some(x) = &mut Some(3) { - *x += 1; - break; - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/for.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/for.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/for.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/for.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn main() { - let mut tups = vec![(0u8, 1u8)]; - - for (n, m) in &tups { - let _: &u8 = n; - let _: &u8 = m; - } - - for (n, m) in &mut tups { - *n += 1; - *m += 2; - } - - assert_eq!(tups, vec![(1u8, 3u8)]); - - for (n, m) in tups { - println!("{} {}", m, n); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/general.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/general.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/general.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/general.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,258 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn some_or_wildcard(r: &Option, b: &i32) { - let _: &i32 = match r { - Some(a) => a, - _ => b, - }; -} - -fn none_or_wildcard(r: &Option, b: &i32) { - let _: &i32 = match r { - None => b, - _ => b, - }; -} - -fn some_or_ref_none(r: &Option, b: &i32) { - let _: &i32 = match r { - Some(a) => a, - &None => b, - }; -} - -fn ref_some_or_none(r: &Option, b: &i32) { - let _: &i32 = match r { - &Some(ref a) => a, - None => b, - }; -} - -fn some_or_self(r: &Option) { - let _: &Option = match r { - Some(n) => { - let _: &i32 = n; - r - }, - x => x, - }; -} - -fn multiple_deref(r: &&&&&Option) { - let _: i32 = match r { - Some(a) => *a, - None => 5, - }; -} - -fn match_with_or() { - // FIXME(tschottdorf): #44912. - // - // let x = &Some((3, 3)); - // let _: &i32 = match x { - // Some((x, 3)) | &Some((ref x, 5)) => x, - // _ => &5i32, - // }; -} - -fn nested_mixed() { - match (&Some(5), &Some(6)) { - (Some(a), &Some(mut b)) => { - // Here, the `a` will be `&i32`, because in the first half of the tuple - // we hit a non-reference pattern and shift into `ref` mode. - // - // In the second half of the tuple there's no non-reference pattern, - // so `b` will be `i32` (bound with `move` mode). Moreover, `b` is - // mutable. - let _: &i32 = a; - b = 7; - let _: i32 = b; - }, - _ => {}, - }; -} - -fn nested_mixed_multiple_deref_1() { - let x = (1, &Some(5)); - let y = &Some(x); - match y { - Some((a, Some(b))) => { - let _: &i32 = a; - let _: &i32 = b; - }, - _ => {}, - }; -} - -fn nested_mixed_multiple_deref_2() { - let x = &Some(5); - let y = &x; - match y { - Some(z) => { - let _: &i32 = z; - }, - _ => {}, - } -} - -fn new_mutable_reference() { - let mut x = &mut Some(5); - match &mut x { - Some(y) => { - *y = 5; - }, - None => { }, - } - - match &mut x { - Some(y) => { - println!("{}", *y); - }, - None => {}, - } -} - -fn let_implicit_ref_binding() { - struct Foo(i32); - - // Note that these rules apply to any pattern matching - // whether it be in a `match` or a `let`. - // For example, `x` here is a `ref` binding: - let Foo(x) = &Foo(3); - let _: &i32 = x; -} - -fn explicit_mut_binding() { - match &Some(5i32) { - Some(mut n) => { - n += 1; - let _ = n; - } - None => {}, - }; - - match &mut Some(5i32) { - Some(n) => { - *n += 1; - let _ = n; - } - None => {}, - }; - - match &mut &mut Some(5i32) { - Some(n) => { - let _: &mut i32 = n; - } - None => {}, - }; -} - -fn tuple_mut_and_mut_mut() { - match (Some(5i32), &Some(5i32)) { - (Some(n), Some(m)) => { - // `n` and `m` are bound as immutable references. Make new references from them to - // assert that. - let r = n; - let _ = r; - let q = m; - let _ = q; - - // Assert the types. Note that we use `n` and `m` here which would fail had they been - // moved due to the assignments above. - let _: i32 = n; - let _: &i32 = m; - } - (_, _) => {}, - }; - - match (&Some(5i32), &&Some(5i32)) { - (Some(n), Some(m)) => { - let _: &i32 = n; - let _: &i32 = m; - } - (_, _) => {}, - }; - - match &mut &mut (Some(5i32), Some(5i32)) { - (Some(n), Some(m)) => { - // Dereferenced through &mut &mut, so a mutable binding results. - let _: &mut i32 = n; - let _: &mut i32 = m; - } - (_, _) => {}, - }; - - match (&mut Some(5i32), &mut &mut Some(5i32)) { - (Some(n), Some(m)) => { - let _: &mut i32 = n; - let _: &mut i32 = m; - } - (_, _) => {}, - }; -} - -fn min_mir_embedded_type() { - // The reduced invocation that an ICE was diagnosed with (was consuming - // adjustments in wrong order). - match (0u8, &&Some(5i32)) { - (_, Some(m)) => { - let _: &i32 = m; - } - (_, _) => {}, - }; -} - -fn no_autoderef() { - // Binding. - let x = &3; - println!("{}", *x); - - // Wildcard. - let _ = &3; - - // Constant of generic type (string) - const Y: &'static str = "foo"; - assert_eq!(0, match "foo" { - Y => 0, - _ => 1, - }); - - // Reference pattern. - let &x = &3; -} - -pub fn main() { - let r: &Option = &Some(3); - let b = &4i32; - - none_or_wildcard(r, b); - some_or_wildcard(r, b); - some_or_ref_none(r, b); - ref_some_or_none(r, b); - - some_or_self(r); - multiple_deref(&&&&r); - match_with_or(); - - nested_mixed(); - nested_mixed_multiple_deref_1(); - nested_mixed_multiple_deref_2(); - - new_mutable_reference(); - explicit_mut_binding(); - tuple_mut_and_mut_mut(); - min_mir_embedded_type(); - - let_implicit_ref_binding(); - - no_autoderef(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/lit.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/lit.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/lit.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/lit.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn with_u8() { - let s = 5u8; - let r = match &s { - 4 => false, - 5 => true, - _ => false, - }; - assert!(r); -} - -// A string literal isn't mistaken for a non-ref pattern (in which case we'd -// deref `s` and mess things up). -fn with_str() { - let s: &'static str = "abc"; - match s { - "abc" => true, - _ => panic!(), - }; -} - -// Ditto with byte strings. -fn with_bytes() { - let s: &'static [u8] = b"abc"; - match s { - b"abc" => true, - _ => panic!(), - }; -} - -pub fn main() { - with_str(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/range.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/range.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/range.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/range.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn main() { - let i = 5; - match &&&&i { - 1 ..= 3 => panic!(), - 3 ..= 8 => {}, - _ => panic!(), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/ref-region.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/ref-region.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/ref-region.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/ref-region.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn foo<'a, 'b>(x: &'a &'b Option) -> &'a u32 { - let x: &'a &'a Option = x; - match x { - Some(r) => { - let _: &u32 = r; - r - }, - &None => panic!(), - } -} - -pub fn main() { - let x = Some(5); - foo(&&x); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/reset-mode.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/reset-mode.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/reset-mode.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/reset-mode.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we "reset" the mode as we pass through a `&` pattern. -// -// cc #46688 - -fn surprise(x: i32) { - assert_eq!(x, 2); -} - -fn main() { - let x = &(1, &2); - let (_, &b) = x; - surprise(b); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/slice.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/slice.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/slice.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/slice.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(slice_patterns)] - -fn slice_pat() { - let sl: &[u8] = b"foo"; - - match sl { - [first, remainder..] => { - let _: &u8 = first; - assert_eq!(first, &b'f'); - assert_eq!(remainder, b"oo"); - } - [] => panic!(), - } -} - -fn slice_pat_omission() { - match &[0, 1, 2] { - [..] => {} - }; -} - -fn main() { - slice_pat(); - slice_pat_omission(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/struct.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Debug, PartialEq)] -struct Foo { - x: u8, -} - -pub fn main() { - let mut foo = Foo { - x: 1, - }; - - match &mut foo { - Foo{x: n} => { - *n += 1; - }, - }; - - assert_eq!(foo, Foo{x: 2}); - - let Foo{x: n} = &foo; - assert_eq!(*n, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/tuple.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/tuple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/tuple.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/tuple.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn main() { - let foo = (Some(1), (), (), vec![2, 3]); - - match &foo { - (Some(n), .., v) => { - assert_eq!((*v).len(), 2); - assert_eq!(*n, 1); - } - (None, (), (), ..) => panic!(), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/tuple-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/tuple-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/tuple-struct.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2005-default-binding-mode/tuple-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -enum Foo { - Bar(Option, (), (), Vec), - Baz, -} - -pub fn main() { - let foo = Foo::Bar(Some(1), (), (), vec![2, 3]); - - match &foo { - Foo::Baz => panic!(), - Foo::Bar(None, ..) => panic!(), - Foo::Bar(Some(n), .., v) => { - assert_eq!((*v).len(), 2); - assert_eq!(*n, 1); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/enums.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/enums.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/enums.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/enums.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![crate_type = "rlib"] -#![feature(non_exhaustive)] - -#[non_exhaustive] -pub enum NonExhaustiveEnum { - Unit, - Tuple(u32), - Struct { field: u32 } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/structs.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/structs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/structs.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/structs.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(non_exhaustive)] - -#[non_exhaustive] -pub struct NormalStruct { - pub first_field: u16, - pub second_field: u16, -} - -#[non_exhaustive] -pub struct UnitStruct; - -#[non_exhaustive] -pub struct TupleStruct (pub u16, pub u16); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/variants.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/variants.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/variants.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/auxiliary/variants.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![crate_type = "rlib"] -#![feature(non_exhaustive)] - -pub enum NonExhaustiveVariants { - #[non_exhaustive] Unit, - #[non_exhaustive] Tuple(u32), - #[non_exhaustive] Struct { field: u32 } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/enums.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/enums.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/enums.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/enums.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:enums.rs -extern crate enums; - -// ignore-pretty issue #37199 - -use enums::NonExhaustiveEnum; - -fn main() { - let enum_unit = NonExhaustiveEnum::Unit; - - match enum_unit { - NonExhaustiveEnum::Unit => 1, - NonExhaustiveEnum::Tuple(_) => 2, - // This particular arm tests that a enum marked as non-exhaustive - // will not error if its variants are matched exhaustively. - NonExhaustiveEnum::Struct { field } => field, - _ => 0 // no error with wildcard - }; - - match enum_unit { - _ => "no error with only wildcard" - }; - - - // issue #53549 - check that variant constructors can still be called normally. - - match NonExhaustiveEnum::Unit { - NonExhaustiveEnum::Unit => {}, - _ => {} - }; - - match NonExhaustiveEnum::Tuple(2) { - NonExhaustiveEnum::Tuple(2) => {}, - _ => {} - }; - - match (NonExhaustiveEnum::Unit {}) { - NonExhaustiveEnum::Unit {} => {}, - _ => {} - }; - - match (NonExhaustiveEnum::Tuple { 0: 2 }) { - NonExhaustiveEnum::Tuple { 0: 2 } => {}, - _ => {} - }; - - match (NonExhaustiveEnum::Struct { field: 2 }) { - NonExhaustiveEnum::Struct { field: 2 } => {}, - _ => {} - }; - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/enums_same_crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/enums_same_crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/enums_same_crate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/enums_same_crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(non_exhaustive)] - -#[non_exhaustive] -pub enum NonExhaustiveEnum { - Unit, - Tuple(u32), - Struct { field: u32 } -} - -fn main() { - let enum_unit = NonExhaustiveEnum::Unit; - - match enum_unit { - NonExhaustiveEnum::Unit => "first", - NonExhaustiveEnum::Tuple(_) => "second", - NonExhaustiveEnum::Struct { .. } => "third", - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/structs.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/structs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/structs.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/structs.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:structs.rs -extern crate structs; - -use structs::{NormalStruct, UnitStruct, TupleStruct}; - -// We only test matching here as we cannot create non-exhaustive -// structs from another crate. ie. they'll never pass in run-pass tests. - -fn match_structs(ns: NormalStruct, ts: TupleStruct, us: UnitStruct) { - let NormalStruct { first_field, second_field, .. } = ns; - - let TupleStruct { 0: first, 1: second, .. } = ts; - - let UnitStruct { .. } = us; -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/structs_same_crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/structs_same_crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/structs_same_crate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/structs_same_crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(non_exhaustive)] - -#[non_exhaustive] -pub struct NormalStruct { - pub first_field: u16, - pub second_field: u16, -} - -#[non_exhaustive] -pub struct UnitStruct; - -#[non_exhaustive] -pub struct TupleStruct (pub u16, pub u16); - -fn main() { - let ns = NormalStruct { first_field: 640, second_field: 480 }; - - let NormalStruct { first_field, second_field } = ns; - - let ts = TupleStruct { 0: 340, 1: 480 }; - let ts_constructor = TupleStruct(340, 480); - - let TupleStruct { 0: first, 1: second } = ts; - let TupleStruct(first, second) = ts_constructor; - - let us = UnitStruct {}; - let us_constructor = UnitStruct; - - let UnitStruct { } = us; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/variants.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/variants.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/variants.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/variants.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:variants.rs -extern crate variants; - -use variants::NonExhaustiveVariants; - -/* - * The initial implementation of #[non_exhaustive] (RFC 2008) does not include support for - * variants. See issue #44109 and PR 45394. - */ -// ignore-test - -fn main() { - let variant_tuple = NonExhaustiveVariants::Tuple { 0: 340 }; - let variant_struct = NonExhaustiveVariants::Struct { field: 340 }; - - match variant_struct { - NonExhaustiveVariants::Unit => "", - NonExhaustiveVariants::Struct { field, .. } => "", - NonExhaustiveVariants::Tuple(fe_tpl, ..) => "" - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/variants_same_crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/variants_same_crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/variants_same_crate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2008-non-exhaustive/variants_same_crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(non_exhaustive)] - -/* - * The initial implementation of #[non_exhaustive] (RFC 2008) does not include support for - * variants. See issue #44109 and PR 45394. - */ -// ignore-test - -pub enum NonExhaustiveVariants { - #[non_exhaustive] Unit, - #[non_exhaustive] Tuple(u32), - #[non_exhaustive] Struct { field: u32 } -} - -fn main() { - let variant_tuple = NonExhaustiveVariants::Tuple(340); - let variant_struct = NonExhaustiveVariants::Struct { field: 340 }; - - match variant_tuple { - NonExhaustiveVariants::Unit => "", - NonExhaustiveVariants::Tuple(fe_tpl) => "", - NonExhaustiveVariants::Struct { field } => "" - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(crate_in_paths)] - -use crate::m::f; -use crate as root; - -mod m { - pub fn f() -> u8 { 1 } - pub fn g() -> u8 { 2 } - pub fn h() -> u8 { 3 } - - // OK, visibilities are implicitly absolute like imports - pub(in crate::m) struct S; -} - -mod n { - use crate::m::f; - use crate as root; - pub fn check() { - assert_eq!(f(), 1); - assert_eq!(crate::m::g(), 2); - assert_eq!(root::m::h(), 3); - } -} - -mod p { - use {super::f, crate::m::g, self::root::m::h}; - use crate as root; - pub fn check() { - assert_eq!(f(), 1); - assert_eq!(g(), 2); - assert_eq!(h(), 3); - } -} - -fn main() { - assert_eq!(f(), 1); - assert_eq!(crate::m::g(), 2); - assert_eq!(root::m::h(), 3); - n::check(); - p::check(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-absolute.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -warning: the feature `crate_in_paths` has been stable since 1.30.0 and no longer requires an attribute to enable - --> $DIR/crate-path-absolute.rs:12:12 - | -LL | #![feature(crate_in_paths)] - | ^^^^^^^^^^^^^^ - | - = note: #[warn(stable_features)] on by default - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-visibility-ambiguity.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-visibility-ambiguity.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-visibility-ambiguity.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-visibility-ambiguity.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(crate_in_paths)] -#![feature(crate_visibility_modifier)] - -mod m { - pub struct Z; - pub struct S1(crate (::m::Z)); // OK - pub struct S2((crate ::m::Z)); // OK - pub struct S3(crate ::m::Z); // OK - pub struct S4(crate crate::m::Z); // OK -} - -fn main() { - crate struct S; // OK (item in statement position) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-visibility-ambiguity.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-visibility-ambiguity.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-visibility-ambiguity.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-crate-paths/crate-path-visibility-ambiguity.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -warning: the feature `crate_in_paths` has been stable since 1.30.0 and no longer requires an attribute to enable - --> $DIR/crate-path-visibility-ambiguity.rs:12:12 - | -LL | #![feature(crate_in_paths)] - | ^^^^^^^^^^^^^^ - | - = note: #[warn(stable_features)] on by default - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-extern-absolute-paths/auxiliary/xcrate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[derive(Debug, PartialEq)] -pub struct S; - -#[derive(Debug)] -pub struct Z; - -pub trait Tr<'a> {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-extern-absolute-paths/basic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-extern-absolute-paths/basic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-extern-absolute-paths/basic.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-extern-absolute-paths/basic.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:xcrate.rs -// compile-flags:--extern xcrate -// edition:2018 - -use xcrate::Z; - -fn f() { - use xcrate; - use xcrate as ycrate; - let s = xcrate::S; - assert_eq!(format!("{:?}", s), "S"); - let z = ycrate::Z; - assert_eq!(format!("{:?}", z), "Z"); -} - -fn main() { - let s = ::xcrate::S; - assert_eq!(format!("{:?}", s), "S"); - let z = Z; - assert_eq!(format!("{:?}", z), "Z"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-extern-absolute-paths/extern.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-extern-absolute-paths/extern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-extern-absolute-paths/extern.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-extern-absolute-paths/extern.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:xcrate.rs -// compile-flags:--extern xcrate - -#![feature(extern_in_paths)] - -use extern::xcrate::Z; - -type A = extern::xcrate::S; -type B = for<'a> extern::xcrate::Tr<'a>; - -fn f() { - use extern::xcrate; - use extern::xcrate as ycrate; - let s = xcrate::S; - assert_eq!(format!("{:?}", s), "S"); - let z = ycrate::Z; - assert_eq!(format!("{:?}", z), "Z"); -} - -fn main() { - let s = extern::xcrate::S; - assert_eq!(format!("{:?}", s), "S"); - let z = Z; - assert_eq!(format!("{:?}", z), "Z"); - assert_eq!(A {}, extern::xcrate::S {}); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-extern-absolute-paths/test.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-extern-absolute-paths/test.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-extern-absolute-paths/test.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-extern-absolute-paths/test.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check that `#[test]` works with extern-absolute-paths enabled. -// -// Regression test for #47075. - -// edition:2018 -// compile-flags: --test - -#[test] -fn test() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-extern-absolute-paths/whitelisted.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-extern-absolute-paths/whitelisted.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-extern-absolute-paths/whitelisted.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2126-extern-absolute-paths/whitelisted.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// edition:2018 - -// Tests that `core` and `std` are always available. -use core::iter; -use std::io; -// FIXME(eddyb) Add a `meta` crate to the distribution. -// use meta; - -fn main() { - for _ in iter::once(()) { - io::stdout(); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2151-raw-identifiers/attr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2151-raw-identifiers/attr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2151-raw-identifiers/attr.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2151-raw-identifiers/attr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::mem; - -#[r#repr(r#C, r#packed)] -struct Test { - a: bool, b: u64 -} - -#[r#derive(r#Debug)] -struct Test2(u32); - -pub fn main() { - assert_eq!(mem::size_of::(), 9); - assert_eq!("Test2(123)", format!("{:?}", Test2(123))); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2151-raw-identifiers/basic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2151-raw-identifiers/basic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2151-raw-identifiers/basic.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2151-raw-identifiers/basic.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -fn r#fn(r#match: u32) -> u32 { - r#match -} - -pub fn main() { - let r#struct = 1; - assert_eq!(1, r#struct); - - let foo = 2; - assert_eq!(2, r#foo); - - let r#bar = 3; - assert_eq!(3, bar); - - assert_eq!(4, r#fn(4)); - - let r#true = false; - assert_eq!(r#true, false); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2151-raw-identifiers/items.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2151-raw-identifiers/items.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2151-raw-identifiers/items.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2151-raw-identifiers/items.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Debug, PartialEq, Eq)] -struct IntWrapper(u32); - -#[derive(Debug, Ord, PartialOrd, PartialEq, Eq, Hash, Copy, Clone, Default)] -struct HasKeywordField { - r#struct: u32, -} - -struct Generic(T); - -trait Trait { - fn r#trait(&self) -> u32; -} -impl Trait for Generic { - fn r#trait(&self) -> u32 { - self.0 - } -} - -pub fn main() { - assert_eq!(IntWrapper(1), r#IntWrapper(1)); - - match IntWrapper(2) { - r#IntWrapper(r#struct) => assert_eq!(2, r#struct), - } - - assert_eq!("HasKeywordField { struct: 3 }", format!("{:?}", HasKeywordField { r#struct: 3 })); - - assert_eq!(4, Generic(4).0); - assert_eq!(5, Generic(5).r#trait()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2151-raw-identifiers/macros.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2151-raw-identifiers/macros.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2151-raw-identifiers/macros.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2151-raw-identifiers/macros.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(decl_macro)] - -r#macro_rules! r#struct { - ($r#struct:expr) => { $r#struct } -} - -macro_rules! old_macro { - ($a:expr) => {$a} -} - -macro r#decl_macro($r#fn:expr) { - $r#fn -} - -macro passthrough($id:ident) { - $id -} - -macro_rules! test_pat_match { - (a) => { 6 }; - (r#a) => { 7 }; -} - -pub fn main() { - r#println!("{struct}", r#struct = 1); - assert_eq!(2, r#struct!(2)); - assert_eq!(3, r#old_macro!(3)); - assert_eq!(4, decl_macro!(4)); - - let r#match = 5; - assert_eq!(5, passthrough!(r#match)); - - assert_eq!("r#struct", stringify!(r#struct)); - - assert_eq!(6, test_pat_match!(a)); - assert_eq!(7, test_pat_match!(r#a)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2175-or-if-while-let/basic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2175-or-if-while-let/basic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2175-or-if-while-let/basic.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2175-or-if-while-let/basic.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(if_while_or_patterns)] - -enum E { - V(u8), - U(u8), - W, -} -use E::*; - -fn main() { - let mut e = V(10); - - if let V(x) | U(x) = e { - assert_eq!(x, 10); - } - while let V(x) | U(x) = e { - assert_eq!(x, 10); - e = W; - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2302-self-struct-ctor.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2302-self-struct-ctor.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2302-self-struct-ctor.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2302-self-struct-ctor.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,129 +0,0 @@ -// run-pass - -#![feature(self_struct_ctor)] - -#![allow(dead_code)] - -use std::fmt::Display; - -struct ST1(i32, i32); - -impl ST1 { - fn new() -> Self { - ST1(0, 1) - } - - fn ctor() -> Self { - Self(1,2) // Self as a constructor - } - - fn pattern(self) { - match self { - Self(x, y) => println!("{} {}", x, y), // Self as a pattern - } - } -} - -struct ST2(T); // With type parameter - -impl ST2 where T: Display { - - fn ctor(v: T) -> Self { - Self(v) - } - - fn pattern(&self) { - match self { - Self(ref v) => println!("{}", v), - } - } -} - -struct ST3<'a>(&'a i32); // With lifetime parameter - -impl<'a> ST3<'a> { - - fn ctor(v: &'a i32) -> Self { - Self(v) - } - - fn pattern(self) { - let Self(ref v) = self; - println!("{}", v); - } -} - -struct ST4(usize); - -impl ST4 { - fn map(opt: Option) -> Option { - opt.map(Self) // use `Self` as a function passed somewhere - } -} - -struct ST5; // unit struct - -impl ST5 { - fn ctor() -> Self { - Self // `Self` as a unit struct value - } - - fn pattern(self) -> Self { - match self { - Self => Self, // `Self` as a unit struct value for matching - } - } -} - -struct ST6(i32); -type T = ST6; -impl T { - fn ctor() -> Self { - ST6(1) - } - - fn type_alias(self) { - let Self(_x) = match self { Self(x) => Self(x) }; - let _opt: Option = Some(0).map(Self); - } -} - -struct ST7(T1, T2); - -impl ST7 { - - fn ctor() -> Self { - Self(1, 2) - } - - fn pattern(self) -> Self { - match self { - Self(x, y) => Self(x, y), - } - } -} - -fn main() { - let v1 = ST1::ctor(); - v1.pattern(); - - let v2 = ST2::ctor(10); - v2.pattern(); - - let local = 42; - let v3 = ST3::ctor(&local); - v3.pattern(); - - let v4 = Some(1usize); - let _ = ST4::map(v4); - - let v5 = ST5::ctor(); - v5.pattern(); - - let v6 = ST6::ctor(); - v6.type_alias(); - - let v7 = ST7::::ctor(); - let r = v7.pattern(); - println!("{} {}", r.0, r.1) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2421-unreserve-pure-offsetof-sizeof-alignof.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2421-unreserve-pure-offsetof-sizeof-alignof.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2421-unreserve-pure-offsetof-sizeof-alignof.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/rfcs/rfc-2421-unreserve-pure-offsetof-sizeof-alignof.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that removed keywords are allowed as identifiers. -fn main () { - let offsetof = (); - let alignof = (); - let sizeof = (); - let pure = (); -} - -fn offsetof() {} -fn alignof() {} -fn sizeof() {} -fn pure() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_raw_pointer_struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_raw_pointer_struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_raw_pointer_struct.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_raw_pointer_struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(arbitrary_self_types)] - -use std::rc::Rc; - -struct Foo(String); - -impl Foo { - unsafe fn foo(self: *const Self) -> *const str { - (*self).0.as_ref() - } - - fn complicated_1(self: *const Rc) -> &'static str { - "Foo::complicated_1" - } - - unsafe fn complicated_2(self: Rc<*const Self>) -> *const str { - (**self).0.as_ref() - } -} - -fn main() { - let foo = Foo("abc123".into()); - assert_eq!("abc123", unsafe { &*(&foo as *const Foo).foo() }); - assert_eq!("Foo::complicated_1", std::ptr::null::>().complicated_1()); - let rc = Rc::new(&foo as *const Foo); - assert_eq!("abc123", unsafe { &*rc.complicated_2()}); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_raw_pointer_trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_raw_pointer_trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_raw_pointer_trait.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_raw_pointer_trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(arbitrary_self_types)] - -use std::ptr; - -trait Foo { - fn foo(self: *const Self) -> &'static str; - - unsafe fn bar(self: *const Self) -> i64; - - unsafe fn complicated(self: *const *const Self) -> i64 where Self: Sized { - (*self).bar() - } -} - -impl Foo for i32 { - fn foo(self: *const Self) -> &'static str { - "I'm an i32!" - } - - unsafe fn bar(self: *const Self) -> i64 { - *self as i64 - } -} - -impl Foo for u32 { - fn foo(self: *const Self) -> &'static str { - "I'm a u32!" - } - - unsafe fn bar(self: *const Self) -> i64 { - *self as i64 - } -} - -fn main() { - let null_i32 = ptr::null::() as *const Foo; - let null_u32 = ptr::null::() as *const Foo; - - assert_eq!("I'm an i32!", null_i32.foo()); - assert_eq!("I'm a u32!", null_u32.foo()); - - let valid_i32 = 5i32; - let valid_i32_thin = &valid_i32 as *const i32; - assert_eq!("I'm an i32!", valid_i32_thin.foo()); - assert_eq!(5, unsafe { valid_i32_thin.bar() }); - assert_eq!(5, unsafe { (&valid_i32_thin as *const *const i32).complicated() }); - let valid_i32_fat = valid_i32_thin as *const Foo; - assert_eq!("I'm an i32!", valid_i32_fat.foo()); - assert_eq!(5, unsafe { valid_i32_fat.bar() }); - - let valid_u32 = 18u32; - let valid_u32_thin = &valid_u32 as *const u32; - assert_eq!("I'm a u32!", valid_u32_thin.foo()); - assert_eq!(18, unsafe { valid_u32_thin.bar() }); - assert_eq!(18, unsafe { (&valid_u32_thin as *const *const u32).complicated() }); - let valid_u32_fat = valid_u32_thin as *const Foo; - assert_eq!("I'm a u32!", valid_u32_fat.foo()); - assert_eq!(18, unsafe { valid_u32_fat.bar() }); - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_silly.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_silly.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_silly.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_silly.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(arbitrary_self_types)] - -struct Foo; -struct Bar; - -impl std::ops::Deref for Bar { - type Target = Foo; - - fn deref(&self) -> &Foo { - &Foo - } -} - -impl Foo { - fn bar(self: Bar) -> i32 { 3 } -} - -fn main() { - assert_eq!(3, Bar.bar()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_struct.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(arbitrary_self_types)] - -use std::rc::Rc; - -struct Foo { - x: i32, - y: i32, -} - -impl Foo { - fn x(self: &Rc) -> i32 { - self.x - } - - fn y(self: Rc) -> i32 { - self.y - } -} - -fn main() { - let foo = Rc::new(Foo {x: 3, y: 4}); - assert_eq!(3, foo.x()); - assert_eq!(4, foo.y()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_trait.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(arbitrary_self_types)] - -use std::rc::Rc; - -trait Trait { - fn trait_method<'a>(self: &'a Box>) -> &'a [i32]; -} - -impl Trait for Vec { - fn trait_method<'a>(self: &'a Box>) -> &'a [i32] { - &***self - } -} - -fn main() { - let v = vec![1,2,3]; - - assert_eq!(&[1,2,3], Box::new(Rc::new(v)).trait_method()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_unsized_struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_unsized_struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_unsized_struct.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/arbitrary_self_types_unsized_struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(arbitrary_self_types)] - -use std::rc::Rc; - -struct Foo(T); - -impl Foo<[u8]> { - fn len(self: Rc) -> usize { - self.0.len() - } -} - -fn main() { - let rc = Rc::new(Foo([1u8,2,3])) as Rc>; - assert_eq!(3, rc.len()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/auxiliary/explicit_self_xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/auxiliary/explicit_self_xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/auxiliary/explicit_self_xcrate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/auxiliary/explicit_self_xcrate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub trait Foo { - #[inline(always)] - fn f(&self); -} - -pub struct Bar { - pub x: String -} - -impl Foo for Bar { - #[inline(always)] - fn f(&self) { - println!("{}", (*self).x); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/builtin-superkinds-self-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/builtin-superkinds-self-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/builtin-superkinds-self-type.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/builtin-superkinds-self-type.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests the ability for the Self type in default methods to use -// capabilities granted by builtin kinds as supertraits. - - -use std::sync::mpsc::{Sender, channel}; - -trait Foo : Send + Sized + 'static { - fn foo(self, tx: Sender) { - tx.send(self).unwrap(); - } -} - -impl Foo for T { } - -pub fn main() { - let (tx, rx) = channel(); - 1193182.foo(tx); - assert_eq!(rx.recv().unwrap(), 1193182); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/by-value-self-in-mut-slot.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/by-value-self-in-mut-slot.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/by-value-self-in-mut-slot.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/by-value-self-in-mut-slot.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct X { - a: isize -} - -trait Changer { - fn change(self) -> Self; -} - -impl Changer for X { - fn change(mut self) -> X { - self.a = 55; - self - } -} - -pub fn main() { - let x = X { a: 32 }; - let new_x = x.change(); - assert_eq!(new_x.a, 55); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/explicit-self-closures.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/explicit-self-closures.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/explicit-self-closures.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/explicit-self-closures.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test to make sure that explicit self params work inside closures - -// pretty-expanded FIXME #23616 - -struct Box { - x: usize -} - -impl Box { - pub fn set_many(&mut self, xs: &[usize]) { - for x in xs { self.x = *x; } - } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/explicit-self-generic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/explicit-self-generic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/explicit-self-generic.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/explicit-self-generic.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -#[derive(Copy, Clone)] -struct LM { resize_at: usize, size: usize } - -enum HashMap { - HashMap_(LM, Vec<(K,V)>) -} - -fn linear_map() -> HashMap { - HashMap::HashMap_(LM{ - resize_at: 32, - size: 0}, Vec::new()) -} - -impl HashMap { - pub fn len(&mut self) -> usize { - match *self { - HashMap::HashMap_(ref l, _) => l.size - } - } -} - -pub fn main() { - let mut m: Box<_> = box linear_map::<(),()>(); - assert_eq!(m.len(), 0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/explicit-self-objects-uniq.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/explicit-self-objects-uniq.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/explicit-self-objects-uniq.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/explicit-self-objects-uniq.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -trait Foo { - fn f(self: Box); -} - -struct S { - x: isize -} - -impl Foo for S { - fn f(self: Box) { - assert_eq!(self.x, 3); - } -} - -pub fn main() { - let x = box S { x: 3 }; - let y = x as Box; - y.f(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/explicit-self.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/explicit-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/explicit-self.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/explicit-self.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -#![allow(non_upper_case_globals)] - -#![feature(box_syntax)] - -static tau: f64 = 2.0*3.14159265358979323; - -struct Point {x: f64, y: f64} -struct Size {w: f64, h: f64} -enum shape { - circle(Point, f64), - rectangle(Point, Size) -} - - -fn compute_area(shape: &shape) -> f64 { - match *shape { - shape::circle(_, radius) => 0.5 * tau * radius * radius, - shape::rectangle(_, ref size) => size.w * size.h - } -} - -impl shape { - // self is in the implicit self region - pub fn select<'r, T>(&self, threshold: f64, a: &'r T, b: &'r T) - -> &'r T { - if compute_area(self) > threshold {a} else {b} - } -} - -fn select_based_on_unit_circle<'r, T>( - threshold: f64, a: &'r T, b: &'r T) -> &'r T { - - let shape = &shape::circle(Point{x: 0.0, y: 0.0}, 1.0); - shape.select(threshold, a, b) -} - -#[derive(Clone)] -struct thing { - x: A -} - -#[derive(Clone)] -struct A { - a: isize -} - -fn thing(x: A) -> thing { - thing { - x: x - } -} - -impl thing { - pub fn bar(self: Box) -> isize { self.x.a } - pub fn quux(&self) -> isize { self.x.a } - pub fn baz<'a>(&'a self) -> &'a A { &self.x } - pub fn spam(self) -> isize { self.x.a } -} - -trait Nus { fn f(&self); } -impl Nus for thing { fn f(&self) {} } - -pub fn main() { - let y: Box<_> = box thing(A {a: 10}); - assert_eq!(y.clone().bar(), 10); - assert_eq!(y.quux(), 10); - - let z = thing(A {a: 11}); - assert_eq!(z.spam(), 11); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/explicit_self_xcrate_exe.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/explicit_self_xcrate_exe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/explicit_self_xcrate_exe.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/explicit_self_xcrate_exe.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:explicit_self_xcrate.rs - -// pretty-expanded FIXME #23616 - -extern crate explicit_self_xcrate; -use explicit_self_xcrate::{Foo, Bar}; - -pub fn main() { - let x = Bar { x: "hello".to_string() }; - x.f(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/move-self.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/move-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/move-self.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/move-self.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct S { - x: String -} - -impl S { - pub fn foo(self) { - self.bar(); - } - - pub fn bar(self) { - println!("{}", self.x); - } -} - -pub fn main() { - let x = S { x: "Hello!".to_string() }; - x.foo(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/object-safety-sized-self-by-value-self.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/object-safety-sized-self-by-value-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/object-safety-sized-self-by-value-self.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/object-safety-sized-self-by-value-self.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check that a trait is still object-safe (and usable) if it has -// methods with by-value self so long as they require `Self : Sized`. - - -trait Counter { - fn tick(&mut self) -> u32; - fn get(self) -> u32 where Self : Sized; -} - -struct CCounter { - c: u32 -} - -impl Counter for CCounter { - fn tick(&mut self) -> u32 { self.c += 1; self.c } - fn get(self) -> u32 where Self : Sized { self.c } -} - -fn tick1(mut c: C) -> u32 { - tick2(&mut c); - c.get() -} - -fn tick2(c: &mut Counter) { - tick3(c); -} - -fn tick3(c: &mut C) { - c.tick(); - c.tick(); -} - -fn main() { - let mut c = CCounter { c: 0 }; - let value = tick1(c); - assert_eq!(value, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/object-safety-sized-self-generic-method.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/object-safety-sized-self-generic-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/object-safety-sized-self-generic-method.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/object-safety-sized-self-generic-method.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check that a trait is still object-safe (and usable) if it has -// generic methods so long as they require `Self : Sized`. - - -trait Counter { - fn tick(&mut self) -> u32; - fn with(&self, f: F) where Self : Sized; -} - -struct CCounter { - c: u32 -} - -impl Counter for CCounter { - fn tick(&mut self) -> u32 { self.c += 1; self.c } - fn with(&self, f: F) { f(self.c); } -} - -fn tick1(c: &mut C) { - tick2(c); - c.with(|i| ()); -} - -fn tick2(c: &mut Counter) { - tick3(c); -} - -fn tick3(c: &mut C) { - c.tick(); - c.tick(); -} - -fn main() { - let mut c = CCounter { c: 0 }; - tick1(&mut c); - assert_eq!(c.tick(), 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/object-safety-sized-self-return-Self.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/object-safety-sized-self-return-Self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/object-safety-sized-self-return-Self.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/object-safety-sized-self-return-Self.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check that a trait is still object-safe (and usable) if it has -// methods that return `Self` so long as they require `Self : Sized`. - - -trait Counter { - fn new() -> Self where Self : Sized; - fn tick(&mut self) -> u32; -} - -struct CCounter { - c: u32 -} - -impl Counter for CCounter { - fn new() -> CCounter { CCounter { c: 0 } } - fn tick(&mut self) -> u32 { self.c += 1; self.c } -} - -fn preticked() -> C { - let mut c: C = Counter::new(); - tick(&mut c); - c -} - -fn tick(c: &mut Counter) { - tick_generic(c); -} - -fn tick_generic(c: &mut C) { - c.tick(); - c.tick(); -} - -fn main() { - let mut c = preticked::(); - tick(&mut c); - assert_eq!(c.tick(), 5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/self-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/self-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/self-impl.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/self-impl.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we can use `Self` types in impls in the expected way. - -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - -struct Foo; - -// Test uses on inherent impl. -impl Foo { - fn foo(_x: Self, _y: &Self, _z: Box) -> Self { - Foo - } - - fn baz() { - // Test that Self cannot be shadowed. - type Foo = i32; - // There is no empty method on i32. - Self::empty(); - - let _: Self = Foo; - } - - fn empty() {} -} - -// Test uses when implementing a trait and with a type parameter. -pub struct Baz { - pub f: X, -} - -trait SuperBar { - type SuperQux; -} - -trait Bar: SuperBar { - type Qux; - - fn bar(x: Self, y: &Self, z: Box, _: Self::SuperQux) -> Self; - fn dummy(&self, x: X) { } -} - -impl SuperBar for Box> { - type SuperQux = bool; -} - -impl Bar for Box> { - type Qux = i32; - - fn bar(_x: Self, _y: &Self, _z: Box, _: Self::SuperQux) -> Self { - let _: Self::Qux = 42; - let _: >::Qux = 42; - - let _: Self::SuperQux = true; - let _: ::SuperQux = true; - - box Baz { f: 42 } - } -} - -fn main() { - let _: Foo = Foo::foo(Foo, &Foo, box Foo); - let _: Box> = Bar::bar(box Baz { f: 42 }, - &box Baz { f: 42 }, - box box Baz { f: 42 }, - true); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/self-in-mut-slot-default-method.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/self-in-mut-slot-default-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/self-in-mut-slot-default-method.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/self-in-mut-slot-default-method.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -struct X { - a: isize -} - -trait Changer : Sized { - fn change(mut self) -> Self { - self.set_to(55); - self - } - - fn change_again(mut self: Box) -> Box { - self.set_to(45); - self - } - - fn set_to(&mut self, a: isize); -} - -impl Changer for X { - fn set_to(&mut self, a: isize) { - self.a = a; - } -} - -pub fn main() { - let x = X { a: 32 }; - let new_x = x.change(); - assert_eq!(new_x.a, 55); - - let x: Box<_> = box new_x; - let new_x = x.change_again(); - assert_eq!(new_x.a, 45); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/self-in-mut-slot-immediate-value.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/self-in-mut-slot-immediate-value.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/self-in-mut-slot-immediate-value.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/self-in-mut-slot-immediate-value.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Assert that `mut self` on an immediate value doesn't -// allow mutating the original - issue #10615. - - -#[derive(Copy, Clone)] -struct Value { - n: isize -} - -impl Value { - fn squared(mut self) -> Value { - self.n *= self.n; - self - } -} - -pub fn main() { - let x = Value { n: 3 }; - let y = x.squared(); - assert_eq!(x.n, 3); - assert_eq!(y.n, 9); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/self-in-typedefs.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/self-in-typedefs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/self-in-typedefs.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/self-in-typedefs.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(unions_with_drop_fields)] - -#![feature(self_in_typedefs)] -#![feature(untagged_unions)] - -#![allow(dead_code)] - -enum A<'a, T: 'a> -where - Self: Send, T: PartialEq -{ - Foo(&'a Self), - Bar(T), -} - -struct B<'a, T: 'a> -where - Self: Send, T: PartialEq -{ - foo: &'a Self, - bar: T, -} - -union C<'a, T: 'a> -where - Self: Send, T: PartialEq -{ - foo: &'a Self, - bar: T, -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/self-re-assign.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/self-re-assign.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/self-re-assign.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/self-re-assign.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Ensure assigning an owned or managed variable to itself works. In particular, -// that we do not glue_drop before we glue_take (#3290). - -#![feature(box_syntax)] - -use std::rc::Rc; - -pub fn main() { - let mut x: Box<_> = box 3; - x = x; - assert_eq!(*x, 3); - - let mut x = Rc::new(3); - x = x; - assert_eq!(*x, 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/self-shadowing-import.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/self-shadowing-import.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/self-shadowing-import.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/self-shadowing-import.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -mod a { - pub mod b { - pub mod a { - pub fn foo() -> isize { return 1; } - } - } -} - -mod c { - use a::b::a; - pub fn bar() { assert_eq!(a::foo(), 1); } -} - -pub fn main() { c::bar(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/self-type-param.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/self-type-param.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/self-type-param.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/self-type-param.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait MyTrait { - fn f(&self) -> Self; -} - -struct S { - x: isize -} - -impl MyTrait for S { - fn f(&self) -> S { - S { x: 3 } - } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/string-self-append.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/string-self-append.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/string-self-append.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/string-self-append.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub fn main() { - // Make sure we properly handle repeated self-appends. - let mut a: String = "A".to_string(); - let mut i = 20; - let mut expected_len = 1; - while i > 0 { - println!("{}", a.len()); - assert_eq!(a.len(), expected_len); - a = format!("{}{}", a, a); - i -= 1; - expected_len *= 2; - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/ufcs-explicit-self.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/ufcs-explicit-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/ufcs-explicit-self.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/ufcs-explicit-self.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -#[derive(Copy, Clone)] -struct Foo { - f: isize, -} - -impl Foo { - fn foo(self: Foo, x: isize) -> isize { - self.f + x - } - fn bar(self: &Foo, x: isize) -> isize { - self.f + x - } - fn baz(self: Box, x: isize) -> isize { - self.f + x - } -} - -#[derive(Copy, Clone)] -struct Bar { - f: T, -} - -impl Bar { - fn foo(self: Bar, x: isize) -> isize { - x - } - fn bar<'a>(self: &'a Bar, x: isize) -> isize { - x - } - fn baz(self: Bar, x: isize) -> isize { - x - } -} - -fn main() { - let foo: Box<_> = box Foo { - f: 1, - }; - println!("{} {} {}", foo.foo(2), foo.bar(2), foo.baz(2)); - let bar: Box<_> = box Bar { - f: 1, - }; - println!("{} {} {}", bar.foo(2), bar.bar(2), bar.baz(2)); - let bar: Box> = bar; - println!("{} {} {}", bar.foo(2), bar.bar(2), bar.baz(2)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/uniq-self-in-mut-slot.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/uniq-self-in-mut-slot.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/uniq-self-in-mut-slot.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/uniq-self-in-mut-slot.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -struct X { - a: isize -} - -trait Changer { - fn change(self: Box) -> Box; -} - -impl Changer for X { - fn change(mut self: Box) -> Box { - self.a = 55; - self - } -} - -pub fn main() { - let x: Box<_> = box X { a: 32 }; - let new_x = x.change(); - assert_eq!(new_x.a, 55); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/where-for-self.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/where-for-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/self/where-for-self.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/self/where-for-self.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we can quantify lifetimes outside a constraint (i.e., including -// the self type) in a where clause. - - -static mut COUNT: u32 = 1; - -trait Bar<'a> { - fn bar(&self); -} - -trait Baz<'a> -{ - fn baz(&self); -} - -impl<'a, 'b> Bar<'b> for &'a u32 { - fn bar(&self) { - unsafe { COUNT *= 2; } - } -} - -impl<'a, 'b> Baz<'b> for &'a u32 { - fn baz(&self) { - unsafe { COUNT *= 3; } - } -} - -// Test we can use the syntax for HRL including the self type. -fn foo1(x: &T) - where for<'a, 'b> &'a T: Bar<'b> -{ - x.bar() -} - -// Test we can quantify multiple bounds (i.e., the precedence is sensible). -fn foo2(x: &T) - where for<'a, 'b> &'a T: Bar<'b> + Baz<'b> -{ - x.baz(); - x.bar() -} - -fn main() { - let x = 42; - foo1(&x); - foo2(&x); - unsafe { - assert_eq!(COUNT, 12); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/auxiliary/sepcomp_cci_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/auxiliary/sepcomp_cci_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/auxiliary/sepcomp_cci_lib.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/auxiliary/sepcomp_cci_lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[inline] -pub fn cci_fn() -> usize { - 1200 -} - -pub const CCI_CONST: usize = 34; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/auxiliary/sepcomp-extern-lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/auxiliary/sepcomp-extern-lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/auxiliary/sepcomp-extern-lib.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/auxiliary/sepcomp-extern-lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[no_mangle] -pub extern "C" fn foo() -> usize { - 1234 -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/auxiliary/sepcomp_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/auxiliary/sepcomp_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/auxiliary/sepcomp_lib.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/auxiliary/sepcomp_lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -C codegen-units=3 --crate-type=rlib,dylib -g - -pub mod a { - pub fn one() -> usize { - 1 - } -} - -pub mod b { - pub fn two() -> usize { - 2 - } -} - -pub mod c { - use a::one; - use b::two; - pub fn three() -> usize { - one() + two() - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-cci.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-cci.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-cci.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-cci.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-bitrig -// compile-flags: -C codegen-units=3 -// aux-build:sepcomp_cci_lib.rs - -// Test accessing cross-crate inlined items from multiple compilation units. - - -extern crate sepcomp_cci_lib; -use sepcomp_cci_lib::{cci_fn, CCI_CONST}; - -fn call1() -> usize { - cci_fn() + CCI_CONST -} - -mod a { - use sepcomp_cci_lib::{cci_fn, CCI_CONST}; - pub fn call2() -> usize { - cci_fn() + CCI_CONST - } -} - -mod b { - use sepcomp_cci_lib::{cci_fn, CCI_CONST}; - pub fn call3() -> usize { - cci_fn() + CCI_CONST - } -} - -fn main() { - assert_eq!(call1(), 1234); - assert_eq!(a::call2(), 1234); - assert_eq!(b::call3(), 1234); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-extern.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-extern.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-extern.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-extern.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-bitrig -// compile-flags: -C codegen-units=3 -// aux-build:sepcomp-extern-lib.rs - -// Test accessing external items from multiple compilation units. - -extern crate sepcomp_extern_lib; - -extern { - fn foo() -> usize; -} - -fn call1() -> usize { - unsafe { foo() } -} - -mod a { - pub fn call2() -> usize { - unsafe { ::foo() } - } -} - -mod b { - pub fn call3() -> usize { - unsafe { ::foo() } - } -} - -fn main() { - assert_eq!(call1(), 1234); - assert_eq!(a::call2(), 1234); - assert_eq!(b::call3(), 1234); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-fns-backwards.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-fns-backwards.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-fns-backwards.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-fns-backwards.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-bitrig -// compile-flags: -C codegen-units=3 - -// Test references to items that haven't been codegened yet. - -// Generate some code in the first compilation unit before declaring any -// modules. This ensures that the first module doesn't go into the same -// compilation unit as the top-level module. - -fn pad() -> usize { 0 } - -mod b { - pub fn three() -> usize { - ::one() + ::a::two() - } -} - -mod a { - pub fn two() -> usize { - ::one() + ::one() - } -} - -fn one() -> usize { - 1 -} - -fn main() { - assert_eq!(one(), 1); - assert_eq!(a::two(), 2); - assert_eq!(b::three(), 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-fns.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-fns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-fns.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-fns.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-bitrig -// compile-flags: -C codegen-units=3 - -// Test basic separate compilation functionality. The functions should be able -// to call each other even though they will be placed in different compilation -// units. - -// Generate some code in the first compilation unit before declaring any -// modules. This ensures that the first module doesn't go into the same -// compilation unit as the top-level module. - -fn one() -> usize { 1 } - -mod a { - pub fn two() -> usize { - ::one() + ::one() - } -} - -mod b { - pub fn three() -> usize { - ::one() + ::a::two() - } -} - -fn main() { - assert_eq!(one(), 1); - assert_eq!(a::two(), 2); - assert_eq!(b::three(), 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-lib-lto.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-lib-lto.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-lib-lto.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-lib-lto.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Check that we can use `-C lto` when linking against libraries that were -// separately compiled. - -// aux-build:sepcomp_lib.rs -// compile-flags: -C lto -g -// no-prefer-dynamic - -extern crate sepcomp_lib; -use sepcomp_lib::a::one; -use sepcomp_lib::b::two; -use sepcomp_lib::c::three; - -fn main() { - assert_eq!(one(), 1); - assert_eq!(two(), 2); - assert_eq!(three(), 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-lib.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:sepcomp_lib.rs - -// Test linking against a library built with -C codegen-units > 1 - - -extern crate sepcomp_lib; -use sepcomp_lib::a::one; -use sepcomp_lib::b::two; -use sepcomp_lib::c::three; - -fn main() { - assert_eq!(one(), 1); - assert_eq!(two(), 2); - assert_eq!(three(), 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-statics.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-statics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-statics.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-statics.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-bitrig -// compile-flags: -C codegen-units=3 - -// Test references to static items across compilation units. - - -fn pad() -> usize { 0 } - -const ONE: usize = 1; - -mod b { - // Separate compilation always switches to the LLVM module with the fewest - // instructions. Make sure we have some instructions in this module so - // that `a` and `b` don't go into the same compilation unit. - fn pad() -> usize { 0 } - - pub static THREE: usize = ::ONE + ::a::TWO; -} - -mod a { - fn pad() -> usize { 0 } - - pub const TWO: usize = ::ONE + ::ONE; -} - -fn main() { - assert_eq!(ONE, 1); - assert_eq!(a::TWO, 2); - assert_eq!(b::THREE, 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-unwind.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-unwind.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-unwind.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/sepcomp/sepcomp-unwind.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-bitrig -// compile-flags: -C codegen-units=3 -// ignore-emscripten no threads support - -// Test unwinding through multiple compilation units. - -// According to acrichto, in the distant past `ld -r` (which is used during -// linking when codegen-units > 1) was known to produce object files with -// damaged unwinding tables. This may be related to GNU binutils bug #6893 -// ("Partial linking results in corrupt .eh_frame_hdr"), but I'm not certain. -// In any case, this test should let us know if enabling parallel codegen ever -// breaks unwinding. - - -use std::thread; - -fn pad() -> usize { 0 } - -mod a { - pub fn f() { - panic!(); - } -} - -mod b { - pub fn g() { - ::a::f(); - } -} - -fn main() { - thread::spawn(move|| { ::b::g() }).join().unwrap_err(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-generics.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-generics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-generics.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-generics.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - - -#![feature(repr_simd, platform_intrinsics)] - -use std::ops; - -#[repr(simd)] -#[derive(Copy, Clone)] -struct f32x4(f32, f32, f32, f32); - -extern "platform-intrinsic" { - fn simd_add(x: T, y: T) -> T; -} - -fn add>(lhs: T, rhs: T) -> T { - lhs + rhs -} - -impl ops::Add for f32x4 { - type Output = f32x4; - - fn add(self, rhs: f32x4) -> f32x4 { - unsafe {simd_add(self, rhs)} - } -} - -pub fn main() { - let lr = f32x4(1.0f32, 2.0f32, 3.0f32, 4.0f32); - - // lame-o - let f32x4(x, y, z, w) = add(lr, lr); - assert_eq!(x, 2.0f32); - assert_eq!(y, 4.0f32); - assert_eq!(z, 6.0f32); - assert_eq!(w, 8.0f32); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-float-math.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-float-math.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-float-math.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-float-math.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten -// ignore-android - -// FIXME: this test fails on arm-android because the NDK version 14 is too old. -// It needs at least version 18. We disable it on all android build bots because -// there is no way in compile-test to disable it for an (arch,os) pair. - -// Test that the simd floating-point math intrinsics produce correct results. - -#![feature(repr_simd, platform_intrinsics)] -#![allow(non_camel_case_types)] - -#[repr(simd)] -#[derive(Copy, Clone, PartialEq, Debug)] -struct f32x4(pub f32, pub f32, pub f32, pub f32); - -extern "platform-intrinsic" { - fn simd_fsqrt(x: T) -> T; - fn simd_fabs(x: T) -> T; - fn simd_fsin(x: T) -> T; - fn simd_fcos(x: T) -> T; - fn simd_ceil(x: T) -> T; - fn simd_fexp(x: T) -> T; - fn simd_fexp2(x: T) -> T; - fn simd_floor(x: T) -> T; - fn simd_fma(x: T, y: T, z: T) -> T; - fn simd_flog(x: T) -> T; - fn simd_flog10(x: T) -> T; - fn simd_flog2(x: T) -> T; - fn simd_fpow(x: T, y: T) -> T; - fn simd_fpowi(x: T, y: i32) -> T; -} - -macro_rules! assert_approx_eq_f32 { - ($a:expr, $b:expr) => ({ - let (a, b) = (&$a, &$b); - assert!((*a - *b).abs() < 1.0e-6, - "{} is not approximately equal to {}", *a, *b); - }) -} -macro_rules! assert_approx_eq { - ($a:expr, $b:expr) => ({ - let a = $a; - let b = $b; - assert_approx_eq_f32!(a.0, b.0); - assert_approx_eq_f32!(a.1, b.1); - assert_approx_eq_f32!(a.2, b.2); - assert_approx_eq_f32!(a.3, b.3); - }) -} - -fn main() { - let x = f32x4(1.0, 1.0, 1.0, 1.0); - let y = f32x4(-1.0, -1.0, -1.0, -1.0); - let z = f32x4(0.0, 0.0, 0.0, 0.0); - - let h = f32x4(0.5, 0.5, 0.5, 0.5); - - unsafe { - let r = simd_fabs(y); - assert_approx_eq!(x, r); - - let r = simd_fcos(z); - assert_approx_eq!(x, r); - - let r = simd_ceil(h); - assert_approx_eq!(x, r); - - let r = simd_fexp(z); - assert_approx_eq!(x, r); - - let r = simd_fexp2(z); - assert_approx_eq!(x, r); - - let r = simd_floor(h); - assert_approx_eq!(z, r); - - let r = simd_fma(x, h, h); - assert_approx_eq!(x, r); - - let r = simd_fsqrt(x); - assert_approx_eq!(x, r); - - let r = simd_flog(x); - assert_approx_eq!(z, r); - - let r = simd_flog2(x); - assert_approx_eq!(z, r); - - let r = simd_flog10(x); - assert_approx_eq!(z, r); - - let r = simd_fpow(h, x); - assert_approx_eq!(h, r); - - let r = simd_fpowi(h, 1); - assert_approx_eq!(h, r); - - let r = simd_fsin(z); - assert_approx_eq!(z, r); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-float-minmax.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-float-minmax.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-float-minmax.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-float-minmax.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten -// min-llvm-version 7.0 -// error-pattern: panicked - -// Test that the simd_f{min,max} intrinsics produce the correct results. - -#![feature(repr_simd, platform_intrinsics)] -#![allow(non_camel_case_types)] - -#[repr(simd)] -#[derive(Copy, Clone, PartialEq, Debug)] -struct f32x4(pub f32, pub f32, pub f32, pub f32); - -extern "platform-intrinsic" { - fn simd_fmin(x: T, y: T) -> T; - fn simd_fmax(x: T, y: T) -> T; -} - -fn main() { - let x = f32x4(1.0, 2.0, 3.0, 4.0); - let y = f32x4(2.0, 1.0, 4.0, 3.0); - - #[cfg(not(any(target_arch = "mips", target_arch = "mips64")))] - let nan = ::std::f32::NAN; - // MIPS hardware treats f32::NAN as SNAN. Clear the signaling bit. - // See https://github.com/rust-lang/rust/issues/52746. - #[cfg(any(target_arch = "mips", target_arch = "mips64"))] - let nan = f32::from_bits(::std::f32::NAN.to_bits() - 1); - - let n = f32x4(nan, nan, nan, nan); - - unsafe { - let min0 = simd_fmin(x, y); - let min1 = simd_fmin(y, x); - assert_eq!(min0, min1); - let e = f32x4(1.0, 1.0, 3.0, 3.0); - assert_eq!(min0, e); - let minn = simd_fmin(x, n); - assert_eq!(minn, x); - let minn = simd_fmin(y, n); - assert_eq!(minn, y); - - let max0 = simd_fmax(x, y); - let max1 = simd_fmax(y, x); - assert_eq!(max0, max1); - let e = f32x4(2.0, 2.0, 4.0, 4.0); - assert_eq!(max0, e); - let maxn = simd_fmax(x, n); - assert_eq!(maxn, x); - let maxn = simd_fmax(y, n); - assert_eq!(maxn, y); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-arithmetic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-arithmetic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-arithmetic.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-arithmetic.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,130 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// ignore-emscripten FIXME(#45351) hits an LLVM assert - -#![feature(repr_simd, platform_intrinsics)] - -#[repr(simd)] -#[derive(Copy, Clone)] -struct i32x4(pub i32, pub i32, pub i32, pub i32); - -#[repr(simd)] -#[derive(Copy, Clone)] -struct u32x4(pub u32, pub u32, pub u32, pub u32); - -#[repr(simd)] -#[derive(Copy, Clone)] -struct f32x4(pub f32, pub f32, pub f32, pub f32); - -macro_rules! all_eq { - ($a: expr, $b: expr) => {{ - let a = $a; - let b = $b; - assert!(a.0 == b.0 && a.1 == b.1 && a.2 == b.2 && a.3 == b.3); - }} -} - -extern "platform-intrinsic" { - fn simd_add(x: T, y: T) -> T; - fn simd_sub(x: T, y: T) -> T; - fn simd_mul(x: T, y: T) -> T; - fn simd_div(x: T, y: T) -> T; - fn simd_rem(x: T, y: T) -> T; - fn simd_shl(x: T, y: T) -> T; - fn simd_shr(x: T, y: T) -> T; - fn simd_and(x: T, y: T) -> T; - fn simd_or(x: T, y: T) -> T; - fn simd_xor(x: T, y: T) -> T; -} - -fn main() { - let x1 = i32x4(1, 2, 3, 4); - let y1 = u32x4(1, 2, 3, 4); - let z1 = f32x4(1.0, 2.0, 3.0, 4.0); - let x2 = i32x4(2, 3, 4, 5); - let y2 = u32x4(2, 3, 4, 5); - let z2 = f32x4(2.0, 3.0, 4.0, 5.0); - - unsafe { - all_eq!(simd_add(x1, x2), i32x4(3, 5, 7, 9)); - all_eq!(simd_add(x2, x1), i32x4(3, 5, 7, 9)); - all_eq!(simd_add(y1, y2), u32x4(3, 5, 7, 9)); - all_eq!(simd_add(y2, y1), u32x4(3, 5, 7, 9)); - all_eq!(simd_add(z1, z2), f32x4(3.0, 5.0, 7.0, 9.0)); - all_eq!(simd_add(z2, z1), f32x4(3.0, 5.0, 7.0, 9.0)); - - all_eq!(simd_mul(x1, x2), i32x4(2, 6, 12, 20)); - all_eq!(simd_mul(x2, x1), i32x4(2, 6, 12, 20)); - all_eq!(simd_mul(y1, y2), u32x4(2, 6, 12, 20)); - all_eq!(simd_mul(y2, y1), u32x4(2, 6, 12, 20)); - all_eq!(simd_mul(z1, z2), f32x4(2.0, 6.0, 12.0, 20.0)); - all_eq!(simd_mul(z2, z1), f32x4(2.0, 6.0, 12.0, 20.0)); - - all_eq!(simd_sub(x2, x1), i32x4(1, 1, 1, 1)); - all_eq!(simd_sub(x1, x2), i32x4(-1, -1, -1, -1)); - all_eq!(simd_sub(y2, y1), u32x4(1, 1, 1, 1)); - all_eq!(simd_sub(y1, y2), u32x4(!0, !0, !0, !0)); - all_eq!(simd_sub(z2, z1), f32x4(1.0, 1.0, 1.0, 1.0)); - all_eq!(simd_sub(z1, z2), f32x4(-1.0, -1.0, -1.0, -1.0)); - - all_eq!(simd_div(x1, x1), i32x4(1, 1, 1, 1)); - all_eq!(simd_div(i32x4(2, 4, 6, 8), i32x4(2, 2, 2, 2)), x1); - all_eq!(simd_div(y1, y1), u32x4(1, 1, 1, 1)); - all_eq!(simd_div(u32x4(2, 4, 6, 8), u32x4(2, 2, 2, 2)), y1); - all_eq!(simd_div(z1, z1), f32x4(1.0, 1.0, 1.0, 1.0)); - all_eq!(simd_div(z1, z2), f32x4(1.0/2.0, 2.0/3.0, 3.0/4.0, 4.0/5.0)); - all_eq!(simd_div(z2, z1), f32x4(2.0/1.0, 3.0/2.0, 4.0/3.0, 5.0/4.0)); - - all_eq!(simd_rem(x1, x1), i32x4(0, 0, 0, 0)); - all_eq!(simd_rem(x2, x1), i32x4(0, 1, 1, 1)); - all_eq!(simd_rem(y1, y1), u32x4(0, 0, 0, 0)); - all_eq!(simd_rem(y2, y1), u32x4(0, 1, 1, 1)); - all_eq!(simd_rem(z1, z1), f32x4(0.0, 0.0, 0.0, 0.0)); - all_eq!(simd_rem(z1, z2), z1); - all_eq!(simd_rem(z2, z1), f32x4(0.0, 1.0, 1.0, 1.0)); - - all_eq!(simd_shl(x1, x2), i32x4(1 << 2, 2 << 3, 3 << 4, 4 << 5)); - all_eq!(simd_shl(x2, x1), i32x4(2 << 1, 3 << 2, 4 << 3, 5 << 4)); - all_eq!(simd_shl(y1, y2), u32x4(1 << 2, 2 << 3, 3 << 4, 4 << 5)); - all_eq!(simd_shl(y2, y1), u32x4(2 << 1, 3 << 2, 4 << 3, 5 << 4)); - - // test right-shift by assuming left-shift is correct - all_eq!(simd_shr(simd_shl(x1, x2), x2), x1); - all_eq!(simd_shr(simd_shl(x2, x1), x1), x2); - all_eq!(simd_shr(simd_shl(y1, y2), y2), y1); - all_eq!(simd_shr(simd_shl(y2, y1), y1), y2); - - // ensure we get logical vs. arithmetic shifts correct - let (a, b, c, d) = (-12, -123, -1234, -12345); - all_eq!(simd_shr(i32x4(a, b, c, d), x1), i32x4(a >> 1, b >> 2, c >> 3, d >> 4)); - all_eq!(simd_shr(u32x4(a as u32, b as u32, c as u32, d as u32), y1), - u32x4((a as u32) >> 1, (b as u32) >> 2, (c as u32) >> 3, (d as u32) >> 4)); - - all_eq!(simd_and(x1, x2), i32x4(0, 2, 0, 4)); - all_eq!(simd_and(x2, x1), i32x4(0, 2, 0, 4)); - all_eq!(simd_and(y1, y2), u32x4(0, 2, 0, 4)); - all_eq!(simd_and(y2, y1), u32x4(0, 2, 0, 4)); - - all_eq!(simd_or(x1, x2), i32x4(3, 3, 7, 5)); - all_eq!(simd_or(x2, x1), i32x4(3, 3, 7, 5)); - all_eq!(simd_or(y1, y2), u32x4(3, 3, 7, 5)); - all_eq!(simd_or(y2, y1), u32x4(3, 3, 7, 5)); - - all_eq!(simd_xor(x1, x2), i32x4(3, 1, 7, 1)); - all_eq!(simd_xor(x2, x1), i32x4(3, 1, 7, 1)); - all_eq!(simd_xor(y1, y2), u32x4(3, 1, 7, 1)); - all_eq!(simd_xor(y2, y1), u32x4(3, 1, 7, 1)); - - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-cast.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-cast.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-cast.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,130 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten FIXME(#45351) hits an LLVM assert - -#![feature(repr_simd, platform_intrinsics, concat_idents, test)] -#![allow(non_camel_case_types)] - -extern crate test; - -#[repr(simd)] -#[derive(PartialEq, Debug)] -struct i32x4(i32, i32, i32, i32); -#[repr(simd)] -#[derive(PartialEq, Debug)] -struct i8x4(i8, i8, i8, i8); - -#[repr(simd)] -#[derive(PartialEq, Debug)] -struct u32x4(u32, u32, u32, u32); -#[repr(simd)] -#[derive(PartialEq, Debug)] -struct u8x4(u8, u8, u8, u8); - -#[repr(simd)] -#[derive(PartialEq, Debug)] -struct f32x4(f32, f32, f32, f32); - -#[repr(simd)] -#[derive(PartialEq, Debug)] -struct f64x4(f64, f64, f64, f64); - - -extern "platform-intrinsic" { - fn simd_cast(x: T) -> U; -} - -const A: i32 = -1234567; -const B: i32 = 12345678; -const C: i32 = -123456789; -const D: i32 = 1234567890; - -trait Foo { - fn is_float() -> bool { false } - fn in_range(x: i32) -> bool; -} -impl Foo for i32 { - fn in_range(_: i32) -> bool { true } -} -impl Foo for i8 { - fn in_range(x: i32) -> bool { -128 <= x && x < 128 } -} -impl Foo for u32 { - fn in_range(x: i32) -> bool { 0 <= x } -} -impl Foo for u8 { - fn in_range(x: i32) -> bool { 0 <= x && x < 128 } -} -impl Foo for f32 { - fn is_float() -> bool { true } - fn in_range(_: i32) -> bool { true } -} -impl Foo for f64 { - fn is_float() -> bool { true } - fn in_range(_: i32) -> bool { true } -} - -fn main() { - macro_rules! test { - ($from: ident, $to: ident) => {{ - // force the casts to actually happen, or else LLVM/rustc - // may fold them and get slightly different results. - let (a, b, c, d) = test::black_box((A as $from, B as $from, C as $from, D as $from)); - // the SIMD vectors are all FOOx4, so we can concat_idents - // so we don't have to pass in the extra args to the macro - let mut from = simd_cast(concat_idents!($from, x4)(a, b, c, d)); - let mut to = concat_idents!($to, x4)(a as $to, - b as $to, - c as $to, - d as $to); - // assist type inference, it needs to know what `from` is - // for the `if` statements. - to == from; - - // there are platform differences for some out of range - // casts, so we just normalize such things: it's OK for - // "invalid" calculations to result in nonsense answers. - // (E.g. negative float to unsigned integer goes through a - // library routine on the default i686 platforms, and the - // implementation of that routine differs on e.g. Linux - // vs. macOS, resulting in different answers.) - if $from::is_float() { - if !$to::in_range(A) { from.0 = 0 as $to; to.0 = 0 as $to; } - if !$to::in_range(B) { from.1 = 0 as $to; to.1 = 0 as $to; } - if !$to::in_range(C) { from.2 = 0 as $to; to.2 = 0 as $to; } - if !$to::in_range(D) { from.3 = 0 as $to; to.3 = 0 as $to; } - } - - assert!(to == from, - "{} -> {} ({:?} != {:?})", stringify!($from), stringify!($to), - from, to); - }} - } - macro_rules! tests { - (: $($to: ident),*) => { () }; - // repeating the list twice is easier than writing a cartesian - // product macro - ($from: ident $(, $from_: ident)*: $($to: ident),*) => { - fn $from() { unsafe { $( test!($from, $to); )* } } - tests!($($from_),*: $($to),*) - }; - ($($types: ident),*) => {{ - tests!($($types),* : $($types),*); - $($types();)* - }} - } - - // test various combinations, including truncation, - // signed/unsigned extension, and floating point casts. - tests!(i32, i8, u32, u8, f32); - tests!(i32, u32, f32, f64) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-comparison.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-comparison.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-comparison.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-comparison.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,116 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten FIXME(#45351) hits an LLVM assert - -#![feature(repr_simd, platform_intrinsics, concat_idents)] -#![allow(non_camel_case_types)] - -use std::f32::NAN; - -#[repr(simd)] -#[derive(Copy, Clone)] -struct i32x4(i32, i32, i32, i32); -#[repr(simd)] -#[derive(Copy, Clone)] -struct u32x4(pub u32, pub u32, pub u32, pub u32); -#[repr(simd)] -#[derive(Copy, Clone)] -struct f32x4(pub f32, pub f32, pub f32, pub f32); - -extern "platform-intrinsic" { - fn simd_eq(x: T, y: T) -> U; - fn simd_ne(x: T, y: T) -> U; - fn simd_lt(x: T, y: T) -> U; - fn simd_le(x: T, y: T) -> U; - fn simd_gt(x: T, y: T) -> U; - fn simd_ge(x: T, y: T) -> U; -} - -macro_rules! cmp { - ($method: ident($lhs: expr, $rhs: expr)) => {{ - let lhs = $lhs; - let rhs = $rhs; - let e: u32x4 = concat_idents!(simd_, $method)($lhs, $rhs); - // assume the scalar version is correct/the behaviour we want. - assert!((e.0 != 0) == lhs.0 .$method(&rhs.0)); - assert!((e.1 != 0) == lhs.1 .$method(&rhs.1)); - assert!((e.2 != 0) == lhs.2 .$method(&rhs.2)); - assert!((e.3 != 0) == lhs.3 .$method(&rhs.3)); - }} -} -macro_rules! tests { - ($($lhs: ident, $rhs: ident;)*) => {{ - $( - (|| { - cmp!(eq($lhs, $rhs)); - cmp!(ne($lhs, $rhs)); - - // test both directions - cmp!(lt($lhs, $rhs)); - cmp!(lt($rhs, $lhs)); - - cmp!(le($lhs, $rhs)); - cmp!(le($rhs, $lhs)); - - cmp!(gt($lhs, $rhs)); - cmp!(gt($rhs, $lhs)); - - cmp!(ge($lhs, $rhs)); - cmp!(ge($rhs, $lhs)); - })(); - )* - }} -} -fn main() { - // 13 vs. -100 tests that we get signed vs. unsigned comparisons - // correct (i32: 13 > -100, u32: 13 < -100). let i1 = i32x4(10, -11, 12, 13); - let i1 = i32x4(10, -11, 12, 13); - let i2 = i32x4(5, -5, 20, -100); - let i3 = i32x4(10, -11, 20, -100); - - let u1 = u32x4(10, !11+1, 12, 13); - let u2 = u32x4(5, !5+1, 20, !100+1); - let u3 = u32x4(10, !11+1, 20, !100+1); - - let f1 = f32x4(10.0, -11.0, 12.0, 13.0); - let f2 = f32x4(5.0, -5.0, 20.0, -100.0); - let f3 = f32x4(10.0, -11.0, 20.0, -100.0); - - unsafe { - tests! { - i1, i1; - u1, u1; - f1, f1; - - i1, i2; - u1, u2; - f1, f2; - - i1, i3; - u1, u3; - f1, f3; - } - } - - // NAN comparisons are special: - // -11 (*) 13 - // -5 -100 (*) - let f4 = f32x4(NAN, f1.1, NAN, f2.3); - - unsafe { - tests! { - f1, f4; - f2, f4; - f4, f4; - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-elements.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-elements.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-elements.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-elements.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,135 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten FIXME(#45351) hits an LLVM assert - -#![feature(repr_simd, platform_intrinsics)] - -#[repr(simd)] -#[derive(Copy, Clone, Debug, PartialEq)] -#[allow(non_camel_case_types)] -struct i32x2(i32, i32); -#[repr(simd)] -#[derive(Copy, Clone, Debug, PartialEq)] -#[allow(non_camel_case_types)] -struct i32x3(i32, i32, i32); -#[repr(simd)] -#[derive(Copy, Clone, Debug, PartialEq)] -#[allow(non_camel_case_types)] -struct i32x4(i32, i32, i32, i32); -#[repr(simd)] -#[derive(Copy, Clone, Debug, PartialEq)] -#[allow(non_camel_case_types)] -struct i32x8(i32, i32, i32, i32, - i32, i32, i32, i32); - -extern "platform-intrinsic" { - fn simd_insert(x: T, idx: u32, y: E) -> T; - fn simd_extract(x: T, idx: u32) -> E; - - fn simd_shuffle2(x: T, y: T, idx: [u32; 2]) -> U; - fn simd_shuffle3(x: T, y: T, idx: [u32; 3]) -> U; - fn simd_shuffle4(x: T, y: T, idx: [u32; 4]) -> U; - fn simd_shuffle8(x: T, y: T, idx: [u32; 8]) -> U; -} - -macro_rules! all_eq { - ($a: expr, $b: expr) => {{ - let a = $a; - let b = $b; - // type inference works better with the concrete type on the - // left, but humans work better with the expected on the - // right. - assert!(b == a, - "{:?} != {:?}", a, b); - }} -} - -fn main() { - let x2 = i32x2(20, 21); - let x3 = i32x3(30, 31, 32); - let x4 = i32x4(40, 41, 42, 43); - let x8 = i32x8(80, 81, 82, 83, 84, 85, 86, 87); - unsafe { - all_eq!(simd_insert(x2, 0, 100), i32x2(100, 21)); - all_eq!(simd_insert(x2, 1, 100), i32x2(20, 100)); - - all_eq!(simd_insert(x3, 0, 100), i32x3(100, 31, 32)); - all_eq!(simd_insert(x3, 1, 100), i32x3(30, 100, 32)); - all_eq!(simd_insert(x3, 2, 100), i32x3(30, 31, 100)); - - all_eq!(simd_insert(x4, 0, 100), i32x4(100, 41, 42, 43)); - all_eq!(simd_insert(x4, 1, 100), i32x4(40, 100, 42, 43)); - all_eq!(simd_insert(x4, 2, 100), i32x4(40, 41, 100, 43)); - all_eq!(simd_insert(x4, 3, 100), i32x4(40, 41, 42, 100)); - - all_eq!(simd_insert(x8, 0, 100), i32x8(100, 81, 82, 83, 84, 85, 86, 87)); - all_eq!(simd_insert(x8, 1, 100), i32x8(80, 100, 82, 83, 84, 85, 86, 87)); - all_eq!(simd_insert(x8, 2, 100), i32x8(80, 81, 100, 83, 84, 85, 86, 87)); - all_eq!(simd_insert(x8, 3, 100), i32x8(80, 81, 82, 100, 84, 85, 86, 87)); - all_eq!(simd_insert(x8, 4, 100), i32x8(80, 81, 82, 83, 100, 85, 86, 87)); - all_eq!(simd_insert(x8, 5, 100), i32x8(80, 81, 82, 83, 84, 100, 86, 87)); - all_eq!(simd_insert(x8, 6, 100), i32x8(80, 81, 82, 83, 84, 85, 100, 87)); - all_eq!(simd_insert(x8, 7, 100), i32x8(80, 81, 82, 83, 84, 85, 86, 100)); - - all_eq!(simd_extract(x2, 0), 20); - all_eq!(simd_extract(x2, 1), 21); - - all_eq!(simd_extract(x3, 0), 30); - all_eq!(simd_extract(x3, 1), 31); - all_eq!(simd_extract(x3, 2), 32); - - all_eq!(simd_extract(x4, 0), 40); - all_eq!(simd_extract(x4, 1), 41); - all_eq!(simd_extract(x4, 2), 42); - all_eq!(simd_extract(x4, 3), 43); - - all_eq!(simd_extract(x8, 0), 80); - all_eq!(simd_extract(x8, 1), 81); - all_eq!(simd_extract(x8, 2), 82); - all_eq!(simd_extract(x8, 3), 83); - all_eq!(simd_extract(x8, 4), 84); - all_eq!(simd_extract(x8, 5), 85); - all_eq!(simd_extract(x8, 6), 86); - all_eq!(simd_extract(x8, 7), 87); - } - - let y2 = i32x2(120, 121); - let y3 = i32x3(130, 131, 132); - let y4 = i32x4(140, 141, 142, 143); - let y8 = i32x8(180, 181, 182, 183, 184, 185, 186, 187); - unsafe { - all_eq!(simd_shuffle2(x2, y2, [3, 0]), i32x2(121, 20)); - all_eq!(simd_shuffle3(x2, y2, [3, 0, 1]), i32x3(121, 20, 21)); - all_eq!(simd_shuffle4(x2, y2, [3, 0, 1, 2]), i32x4(121, 20, 21, 120)); - all_eq!(simd_shuffle8(x2, y2, [3, 0, 1, 2, 1, 2, 3, 0]), - i32x8(121, 20, 21, 120, 21, 120, 121, 20)); - - all_eq!(simd_shuffle2(x3, y3, [4, 2]), i32x2(131, 32)); - all_eq!(simd_shuffle3(x3, y3, [4, 2, 3]), i32x3(131, 32, 130)); - all_eq!(simd_shuffle4(x3, y3, [4, 2, 3, 0]), i32x4(131, 32, 130, 30)); - all_eq!(simd_shuffle8(x3, y3, [4, 2, 3, 0, 1, 5, 5, 1]), - i32x8(131, 32, 130, 30, 31, 132, 132, 31)); - - all_eq!(simd_shuffle2(x4, y4, [7, 2]), i32x2(143, 42)); - all_eq!(simd_shuffle3(x4, y4, [7, 2, 5]), i32x3(143, 42, 141)); - all_eq!(simd_shuffle4(x4, y4, [7, 2, 5, 0]), i32x4(143, 42, 141, 40)); - all_eq!(simd_shuffle8(x4, y4, [7, 2, 5, 0, 3, 6, 4, 1]), - i32x8(143, 42, 141, 40, 43, 142, 140, 41)); - - all_eq!(simd_shuffle2(x8, y8, [11, 5]), i32x2(183, 85)); - all_eq!(simd_shuffle3(x8, y8, [11, 5, 15]), i32x3(183, 85, 187)); - all_eq!(simd_shuffle4(x8, y8, [11, 5, 15, 0]), i32x4(183, 85, 187, 80)); - all_eq!(simd_shuffle8(x8, y8, [11, 5, 15, 0, 3, 8, 12, 1]), - i32x8(183, 85, 187, 80, 83, 180, 184, 81)); - } - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-gather.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-gather.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-gather.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-gather.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,152 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten -// min-llvm-version 6.0 - -// Test that the simd_{gather,scatter} intrinsics produce the correct results. - -#![feature(repr_simd, platform_intrinsics)] -#![allow(non_camel_case_types)] - -#[repr(simd)] -#[derive(Copy, Clone, PartialEq, Debug)] -struct x4(pub T, pub T, pub T, pub T); - -extern "platform-intrinsic" { - fn simd_gather(x: T, y: U, z: V) -> T; - fn simd_scatter(x: T, y: U, z: V) -> (); -} - -fn main() { - let mut x = [0_f32, 1., 2., 3., 4., 5., 6., 7.]; - - let default = x4(-3_f32, -3., -3., -3.); - let s_strided = x4(0_f32, 2., -3., 6.); - let mask = x4(-1_i32, -1, 0, -1); - - // reading from *const - unsafe { - let pointer = &x[0] as *const f32; - let pointers = x4( - pointer.offset(0) as *const f32, - pointer.offset(2), - pointer.offset(4), - pointer.offset(6) - ); - - let r_strided = simd_gather(default, pointers, mask); - - assert_eq!(r_strided, s_strided); - } - - // reading from *mut - unsafe { - let pointer = &mut x[0] as *mut f32; - let pointers = x4( - pointer.offset(0) as *mut f32, - pointer.offset(2), - pointer.offset(4), - pointer.offset(6) - ); - - let r_strided = simd_gather(default, pointers, mask); - - assert_eq!(r_strided, s_strided); - } - - // writing to *mut - unsafe { - let pointer = &mut x[0] as *mut f32; - let pointers = x4( - pointer.offset(0) as *mut f32, - pointer.offset(2), - pointer.offset(4), - pointer.offset(6) - ); - - let values = x4(42_f32, 43_f32, 44_f32, 45_f32); - simd_scatter(values, pointers, mask); - - assert_eq!(x, [42., 1., 43., 3., 4., 5., 45., 7.]); - } - - // test modifying array of *const f32 - let mut y = [ - &x[0] as *const f32, - &x[1] as *const f32, - &x[2] as *const f32, - &x[3] as *const f32, - &x[4] as *const f32, - &x[5] as *const f32, - &x[6] as *const f32, - &x[7] as *const f32 - ]; - - let default = x4(y[0], y[0], y[0], y[0]); - let s_strided = x4(y[0], y[2], y[0], y[6]); - - // reading from *const - unsafe { - let pointer = &y[0] as *const *const f32; - let pointers = x4( - pointer.offset(0) as *const *const f32, - pointer.offset(2), - pointer.offset(4), - pointer.offset(6) - ); - - let r_strided = simd_gather(default, pointers, mask); - - assert_eq!(r_strided, s_strided); - } - - // reading from *mut - unsafe { - let pointer = &mut y[0] as *mut *const f32; - let pointers = x4( - pointer.offset(0) as *mut *const f32, - pointer.offset(2), - pointer.offset(4), - pointer.offset(6) - ); - - let r_strided = simd_gather(default, pointers, mask); - - assert_eq!(r_strided, s_strided); - } - - // writing to *mut - unsafe { - let pointer = &mut y[0] as *mut *const f32; - let pointers = x4( - pointer.offset(0) as *mut *const f32, - pointer.offset(2), - pointer.offset(4), - pointer.offset(6) - ); - - let values = x4(y[7], y[6], y[5], y[1]); - simd_scatter(values, pointers, mask); - - let s = [ - &x[7] as *const f32, - &x[1] as *const f32, - &x[6] as *const f32, - &x[3] as *const f32, - &x[4] as *const f32, - &x[5] as *const f32, - &x[1] as *const f32, - &x[7] as *const f32 - ]; - assert_eq!(y, s); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-reduction.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-reduction.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-reduction.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-reduction.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,174 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// ignore-emscripten - -// Test that the simd_reduce_{op} intrinsics produce the correct results. - -#![feature(repr_simd, platform_intrinsics)] -#[allow(non_camel_case_types)] - -#[repr(simd)] -#[derive(Copy, Clone)] -struct i32x4(pub i32, pub i32, pub i32, pub i32); - -#[repr(simd)] -#[derive(Copy, Clone)] -struct u32x4(pub u32, pub u32, pub u32, pub u32); - -#[repr(simd)] -#[derive(Copy, Clone)] -struct f32x4(pub f32, pub f32, pub f32, pub f32); - -#[repr(simd)] -#[derive(Copy, Clone)] -struct b8x4(pub i8, pub i8, pub i8, pub i8); - -#[repr(simd)] -#[derive(Copy, Clone)] -struct b8x16( - pub i8, pub i8, pub i8, pub i8, - pub i8, pub i8, pub i8, pub i8, - pub i8, pub i8, pub i8, pub i8, - pub i8, pub i8, pub i8, pub i8 -); - -extern "platform-intrinsic" { - fn simd_reduce_add_unordered(x: T) -> U; - fn simd_reduce_mul_unordered(x: T) -> U; - fn simd_reduce_add_ordered(x: T, acc: U) -> U; - fn simd_reduce_mul_ordered(x: T, acc: U) -> U; - fn simd_reduce_min(x: T) -> U; - fn simd_reduce_max(x: T) -> U; - fn simd_reduce_min_nanless(x: T) -> U; - fn simd_reduce_max_nanless(x: T) -> U; - fn simd_reduce_and(x: T) -> U; - fn simd_reduce_or(x: T) -> U; - fn simd_reduce_xor(x: T) -> U; - fn simd_reduce_all(x: T) -> bool; - fn simd_reduce_any(x: T) -> bool; -} - -fn main() { - unsafe { - let x = i32x4(1, -2, 3, 4); - let r: i32 = simd_reduce_add_unordered(x); - assert_eq!(r, 6_i32); - let r: i32 = simd_reduce_mul_unordered(x); - assert_eq!(r, -24_i32); - let r: i32 = simd_reduce_add_ordered(x, -1); - assert_eq!(r, 5_i32); - let r: i32 = simd_reduce_mul_ordered(x, -1); - assert_eq!(r, 24_i32); - - let r: i32 = simd_reduce_min(x); - assert_eq!(r, -2_i32); - let r: i32 = simd_reduce_max(x); - assert_eq!(r, 4_i32); - - let x = i32x4(-1, -1, -1, -1); - let r: i32 = simd_reduce_and(x); - assert_eq!(r, -1_i32); - let r: i32 = simd_reduce_or(x); - assert_eq!(r, -1_i32); - let r: i32 = simd_reduce_xor(x); - assert_eq!(r, 0_i32); - - let x = i32x4(-1, -1, 0, -1); - let r: i32 = simd_reduce_and(x); - assert_eq!(r, 0_i32); - let r: i32 = simd_reduce_or(x); - assert_eq!(r, -1_i32); - let r: i32 = simd_reduce_xor(x); - assert_eq!(r, -1_i32); - } - - unsafe { - let x = u32x4(1, 2, 3, 4); - let r: u32 = simd_reduce_add_unordered(x); - assert_eq!(r, 10_u32); - let r: u32 = simd_reduce_mul_unordered(x); - assert_eq!(r, 24_u32); - let r: u32 = simd_reduce_add_ordered(x, 1); - assert_eq!(r, 11_u32); - let r: u32 = simd_reduce_mul_ordered(x, 2); - assert_eq!(r, 48_u32); - - let r: u32 = simd_reduce_min(x); - assert_eq!(r, 1_u32); - let r: u32 = simd_reduce_max(x); - assert_eq!(r, 4_u32); - - let t = u32::max_value(); - let x = u32x4(t, t, t, t); - let r: u32 = simd_reduce_and(x); - assert_eq!(r, t); - let r: u32 = simd_reduce_or(x); - assert_eq!(r, t); - let r: u32 = simd_reduce_xor(x); - assert_eq!(r, 0_u32); - - let x = u32x4(t, t, 0, t); - let r: u32 = simd_reduce_and(x); - assert_eq!(r, 0_u32); - let r: u32 = simd_reduce_or(x); - assert_eq!(r, t); - let r: u32 = simd_reduce_xor(x); - assert_eq!(r, t); - } - - unsafe { - let x = f32x4(1., -2., 3., 4.); - let r: f32 = simd_reduce_add_unordered(x); - assert_eq!(r, 6_f32); - let r: f32 = simd_reduce_mul_unordered(x); - assert_eq!(r, -24_f32); - // FIXME: only works correctly for accumulator, 0: - // https://bugs.llvm.org/show_bug.cgi?id=36734 - let r: f32 = simd_reduce_add_ordered(x, 0.); - assert_eq!(r, 6_f32); - // FIXME: only works correctly for accumulator, 1: - // https://bugs.llvm.org/show_bug.cgi?id=36734 - let r: f32 = simd_reduce_mul_ordered(x, 1.); - assert_eq!(r, -24_f32); - - let r: f32 = simd_reduce_min(x); - assert_eq!(r, -2_f32); - let r: f32 = simd_reduce_max(x); - assert_eq!(r, 4_f32); - let r: f32 = simd_reduce_min_nanless(x); - assert_eq!(r, -2_f32); - let r: f32 = simd_reduce_max_nanless(x); - assert_eq!(r, 4_f32); - } - - unsafe { - let x = b8x4(!0, !0, !0, !0); - let r: bool = simd_reduce_all(x); - assert_eq!(r, true); - let r: bool = simd_reduce_any(x); - assert_eq!(r, true); - - let x = b8x4(!0, !0, 0, !0); - let r: bool = simd_reduce_all(x); - assert_eq!(r, false); - let r: bool = simd_reduce_any(x); - assert_eq!(r, true); - - let x = b8x4(0, 0, 0, 0); - let r: bool = simd_reduce_all(x); - assert_eq!(r, false); - let r: bool = simd_reduce_any(x); - assert_eq!(r, false); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-select.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-select.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-select.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-intrinsic-generic-select.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,149 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// ignore-emscripten - -// Test that the simd_select intrinsics produces correct results. - -#![feature(repr_simd, platform_intrinsics)] -#[allow(non_camel_case_types)] - -#[repr(simd)] -#[derive(Copy, Clone, PartialEq, Debug)] -struct i32x4(pub i32, pub i32, pub i32, pub i32); - -#[repr(simd)] -#[derive(Copy, Clone, PartialEq, Debug)] -struct u32x4(pub u32, pub u32, pub u32, pub u32); - -#[repr(simd)] -#[derive(Copy, Clone, PartialEq, Debug)] -struct f32x4(pub f32, pub f32, pub f32, pub f32); - -#[repr(simd)] -#[derive(Copy, Clone, PartialEq, Debug)] -struct b8x4(pub i8, pub i8, pub i8, pub i8); - -extern "platform-intrinsic" { - fn simd_select(x: T, a: U, b: U) -> U; -} - -fn main() { - let m0 = b8x4(!0, !0, !0, !0); - let m1 = b8x4(0, 0, 0, 0); - let m2 = b8x4(!0, !0, 0, 0); - let m3 = b8x4(0, 0, !0, !0); - let m4 = b8x4(!0, 0, !0, 0); - - unsafe { - let a = i32x4(1, -2, 3, 4); - let b = i32x4(5, 6, -7, 8); - - let r: i32x4 = simd_select(m0, a, b); - let e = a; - assert_eq!(r, e); - - let r: i32x4 = simd_select(m1, a, b); - let e = b; - assert_eq!(r, e); - - let r: i32x4 = simd_select(m2, a, b); - let e = i32x4(1, -2, -7, 8); - assert_eq!(r, e); - - let r: i32x4 = simd_select(m3, a, b); - let e = i32x4(5, 6, 3, 4); - assert_eq!(r, e); - - let r: i32x4 = simd_select(m4, a, b); - let e = i32x4(1, 6, 3, 8); - assert_eq!(r, e); - } - - unsafe { - let a = u32x4(1, 2, 3, 4); - let b = u32x4(5, 6, 7, 8); - - let r: u32x4 = simd_select(m0, a, b); - let e = a; - assert_eq!(r, e); - - let r: u32x4 = simd_select(m1, a, b); - let e = b; - assert_eq!(r, e); - - let r: u32x4 = simd_select(m2, a, b); - let e = u32x4(1, 2, 7, 8); - assert_eq!(r, e); - - let r: u32x4 = simd_select(m3, a, b); - let e = u32x4(5, 6, 3, 4); - assert_eq!(r, e); - - let r: u32x4 = simd_select(m4, a, b); - let e = u32x4(1, 6, 3, 8); - assert_eq!(r, e); - } - - unsafe { - let a = f32x4(1., 2., 3., 4.); - let b = f32x4(5., 6., 7., 8.); - - let r: f32x4 = simd_select(m0, a, b); - let e = a; - assert_eq!(r, e); - - let r: f32x4 = simd_select(m1, a, b); - let e = b; - assert_eq!(r, e); - - let r: f32x4 = simd_select(m2, a, b); - let e = f32x4(1., 2., 7., 8.); - assert_eq!(r, e); - - let r: f32x4 = simd_select(m3, a, b); - let e = f32x4(5., 6., 3., 4.); - assert_eq!(r, e); - - let r: f32x4 = simd_select(m4, a, b); - let e = f32x4(1., 6., 3., 8.); - assert_eq!(r, e); - } - - unsafe { - let t = !0 as i8; - let f = 0 as i8; - let a = b8x4(t, f, t, f); - let b = b8x4(f, f, f, t); - - let r: b8x4 = simd_select(m0, a, b); - let e = a; - assert_eq!(r, e); - - let r: b8x4 = simd_select(m1, a, b); - let e = b; - assert_eq!(r, e); - - let r: b8x4 = simd_select(m2, a, b); - let e = b8x4(t, f, f, t); - assert_eq!(r, e); - - let r: b8x4 = simd_select(m3, a, b); - let e = b8x4(f, f, t, f); - assert_eq!(r, e); - - let r: b8x4 = simd_select(m4, a, b); - let e = b8x4(t, f, t, t); - assert_eq!(r, e); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-size-align.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-size-align.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-size-align.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-size-align.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(deprecated)] - - -#![feature(repr_simd)] -#![allow(non_camel_case_types)] - -use std::mem; - -/// `T` should satisfy `size_of T (mod min_align_of T) === 0` to be stored at `Vec` properly -/// Please consult the issue #20460 -fn check() { - assert_eq!(mem::size_of::() % mem::min_align_of::(), 0) -} - -fn main() { - check::(); - check::(); - check::(); - check::(); - check::(); - check::(); - check::(); - - check::(); - check::(); - check::(); - check::(); - check::(); - check::(); - check::(); - - check::(); - check::(); - check::(); - check::(); - check::(); - check::(); - check::(); -} - -#[repr(simd)] struct u8x2(u8, u8); -#[repr(simd)] struct u8x3(u8, u8, u8); -#[repr(simd)] struct u8x4(u8, u8, u8, u8); -#[repr(simd)] struct u8x5(u8, u8, u8, u8, u8); -#[repr(simd)] struct u8x6(u8, u8, u8, u8, u8, u8); -#[repr(simd)] struct u8x7(u8, u8, u8, u8, u8, u8, u8); -#[repr(simd)] struct u8x8(u8, u8, u8, u8, u8, u8, u8, u8); - -#[repr(simd)] struct i16x2(i16, i16); -#[repr(simd)] struct i16x3(i16, i16, i16); -#[repr(simd)] struct i16x4(i16, i16, i16, i16); -#[repr(simd)] struct i16x5(i16, i16, i16, i16, i16); -#[repr(simd)] struct i16x6(i16, i16, i16, i16, i16, i16); -#[repr(simd)] struct i16x7(i16, i16, i16, i16, i16, i16, i16); -#[repr(simd)] struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16); - -#[repr(simd)] struct f32x2(f32, f32); -#[repr(simd)] struct f32x3(f32, f32, f32); -#[repr(simd)] struct f32x4(f32, f32, f32, f32); -#[repr(simd)] struct f32x5(f32, f32, f32, f32, f32); -#[repr(simd)] struct f32x6(f32, f32, f32, f32, f32, f32); -#[repr(simd)] struct f32x7(f32, f32, f32, f32, f32, f32, f32); -#[repr(simd)] struct f32x8(f32, f32, f32, f32, f32, f32, f32, f32); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-target-feature-mixup.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-target-feature-mixup.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-target-feature-mixup.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-target-feature-mixup.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,193 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] -#![allow(overflowing_literals)] - -// ignore-emscripten - -#![feature(repr_simd, target_feature, cfg_target_feature)] -#![feature(avx512_target_feature)] - -use std::process::{Command, ExitStatus}; -use std::env; - -fn main() { - if let Some(level) = env::args().nth(1) { - return test::main(&level) - } - - let me = env::current_exe().unwrap(); - for level in ["sse", "avx", "avx512"].iter() { - let status = Command::new(&me).arg(level).status().unwrap(); - if status.success() { - println!("success with {}", level); - continue - } - - // We don't actually know if our computer has the requisite target features - // for the test below. Testing for that will get added to libstd later so - // for now just assume sigill means this is a machine that can't run this test. - if is_sigill(status) { - println!("sigill with {}, assuming spurious", level); - continue - } - panic!("invalid status at {}: {}", level, status); - } -} - -#[cfg(unix)] -fn is_sigill(status: ExitStatus) -> bool { - use std::os::unix::prelude::*; - status.signal() == Some(4) -} - -#[cfg(windows)] -fn is_sigill(status: ExitStatus) -> bool { - status.code() == Some(0xc000001d) -} - -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -#[allow(nonstandard_style)] -mod test { - // An SSE type - #[repr(simd)] - #[derive(PartialEq, Debug, Clone, Copy)] - struct __m128i(u64, u64); - - // An AVX type - #[repr(simd)] - #[derive(PartialEq, Debug, Clone, Copy)] - struct __m256i(u64, u64, u64, u64); - - // An AVX-512 type - #[repr(simd)] - #[derive(PartialEq, Debug, Clone, Copy)] - struct __m512i(u64, u64, u64, u64, u64, u64, u64, u64); - - pub fn main(level: &str) { - unsafe { - main_normal(level); - main_sse(level); - if level == "sse" { - return - } - main_avx(level); - if level == "avx" { - return - } - main_avx512(level); - } - } - - macro_rules! mains { - ($( - $(#[$attr:meta])* - unsafe fn $main:ident(level: &str) { - ... - } - )*) => ($( - $(#[$attr])* - unsafe fn $main(level: &str) { - let m128 = __m128i(1, 2); - let m256 = __m256i(3, 4, 5, 6); - let m512 = __m512i(7, 8, 9, 10, 11, 12, 13, 14); - assert_eq!(id_sse_128(m128), m128); - assert_eq!(id_sse_256(m256), m256); - assert_eq!(id_sse_512(m512), m512); - - if level == "sse" { - return - } - assert_eq!(id_avx_128(m128), m128); - assert_eq!(id_avx_256(m256), m256); - assert_eq!(id_avx_512(m512), m512); - - if level == "avx" { - return - } - assert_eq!(id_avx512_128(m128), m128); - assert_eq!(id_avx512_256(m256), m256); - assert_eq!(id_avx512_512(m512), m512); - } - )*) - } - - mains! { - unsafe fn main_normal(level: &str) { ... } - #[target_feature(enable = "sse2")] - unsafe fn main_sse(level: &str) { ... } - #[target_feature(enable = "avx")] - unsafe fn main_avx(level: &str) { ... } - #[target_feature(enable = "avx512bw")] - unsafe fn main_avx512(level: &str) { ... } - } - - - #[target_feature(enable = "sse2")] - unsafe fn id_sse_128(a: __m128i) -> __m128i { - assert_eq!(a, __m128i(1, 2)); - a.clone() - } - - #[target_feature(enable = "sse2")] - unsafe fn id_sse_256(a: __m256i) -> __m256i { - assert_eq!(a, __m256i(3, 4, 5, 6)); - a.clone() - } - - #[target_feature(enable = "sse2")] - unsafe fn id_sse_512(a: __m512i) -> __m512i { - assert_eq!(a, __m512i(7, 8, 9, 10, 11, 12, 13, 14)); - a.clone() - } - - #[target_feature(enable = "avx")] - unsafe fn id_avx_128(a: __m128i) -> __m128i { - assert_eq!(a, __m128i(1, 2)); - a.clone() - } - - #[target_feature(enable = "avx")] - unsafe fn id_avx_256(a: __m256i) -> __m256i { - assert_eq!(a, __m256i(3, 4, 5, 6)); - a.clone() - } - - #[target_feature(enable = "avx")] - unsafe fn id_avx_512(a: __m512i) -> __m512i { - assert_eq!(a, __m512i(7, 8, 9, 10, 11, 12, 13, 14)); - a.clone() - } - - #[target_feature(enable = "avx512bw")] - unsafe fn id_avx512_128(a: __m128i) -> __m128i { - assert_eq!(a, __m128i(1, 2)); - a.clone() - } - - #[target_feature(enable = "avx512bw")] - unsafe fn id_avx512_256(a: __m256i) -> __m256i { - assert_eq!(a, __m256i(3, 4, 5, 6)); - a.clone() - } - - #[target_feature(enable = "avx512bw")] - unsafe fn id_avx512_512(a: __m512i) -> __m512i { - assert_eq!(a, __m512i(7, 8, 9, 10, 11, 12, 13, 14)); - a.clone() - } -} - -#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] -mod test { - pub fn main(level: &str) {} -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-type.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-type.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// pretty-expanded FIXME #23616 - -#![feature(repr_simd)] - -#[repr(simd)] -struct RGBA { - r: f32, - g: f32, - b: f32, - a: f32 -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-upgraded.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-upgraded.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-upgraded.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/simd/simd-upgraded.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] -#![allow(non_camel_case_types)] - -// Test that removed LLVM SIMD intrinsics continue -// to work via the "AutoUpgrade" mechanism. - -#![feature(cfg_target_feature, repr_simd)] -#![feature(platform_intrinsics, stmt_expr_attributes)] - -#[repr(simd)] -#[derive(PartialEq, Debug)] -struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16); - -fn main() { - #[cfg(target_feature = "sse2")] unsafe { - extern "platform-intrinsic" { - fn x86_mm_min_epi16(x: i16x8, y: i16x8) -> i16x8; - } - assert_eq!(x86_mm_min_epi16(i16x8(0, 1, 2, 3, 4, 5, 6, 7), - i16x8(7, 6, 5, 4, 3, 2, 1, 0)), - i16x8(0, 1, 2, 3, 3, 2, 1, 0)); - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/assoc-ty-graph-cycle.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/assoc-ty-graph-cycle.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/assoc-ty-graph-cycle.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/assoc-ty-graph-cycle.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Make sure we don't crash with a cycle error during coherence. - -#![feature(specialization)] - -trait Trait { - type Assoc; -} - -impl Trait for Vec { - default type Assoc = (); -} - -impl Trait for Vec { - type Assoc = u8; -} - -impl Trait for String { - type Assoc = (); -} - -impl Trait< as Trait>::Assoc> for String {} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/auxiliary/cross_crates_defaults.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/auxiliary/cross_crates_defaults.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/auxiliary/cross_crates_defaults.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/auxiliary/cross_crates_defaults.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -#![feature(specialization)] - -// First, test only use of explicit `default` items: - -pub trait Foo { - fn foo(&self) -> bool; -} - -impl Foo for T { - default fn foo(&self) -> bool { false } -} - -impl Foo for i32 {} - -impl Foo for i64 { - fn foo(&self) -> bool { true } -} - -// Next, test mixture of explicit `default` and provided methods: - -pub trait Bar { - fn bar(&self) -> i32 { 0 } -} - -impl Bar for T {} // use the provided method - -impl Bar for i32 { - fn bar(&self) -> i32 { 1 } -} -impl<'a> Bar for &'a str {} - -impl Bar for Vec { - default fn bar(&self) -> i32 { 2 } -} -impl Bar for Vec {} -impl Bar for Vec { - fn bar(&self) -> i32 { 3 } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/auxiliary/go_trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/auxiliary/go_trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/auxiliary/go_trait.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/auxiliary/go_trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(specialization)] - -// Common code used for tests that model the Fn/FnMut/FnOnce hierarchy. - -pub trait Go { - fn go(&self, arg: isize); -} - -pub fn go(this: &G, arg: isize) { - this.go(arg) -} - -pub trait GoMut { - fn go_mut(&mut self, arg: isize); -} - -pub fn go_mut(this: &mut G, arg: isize) { - this.go_mut(arg) -} - -pub trait GoOnce { - fn go_once(self, arg: isize); -} - -pub fn go_once(this: G, arg: isize) { - this.go_once(arg) -} - -impl GoMut for G - where G : Go -{ - default fn go_mut(&mut self, arg: isize) { - go(&*self, arg) - } -} - -impl GoOnce for G - where G : GoMut -{ - default fn go_once(mut self, arg: isize) { - go_mut(&mut self, arg) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/auxiliary/specialization_cross_crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/auxiliary/specialization_cross_crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/auxiliary/specialization_cross_crate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/auxiliary/specialization_cross_crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(specialization)] - -pub trait Foo { - fn foo(&self) -> &'static str; -} - -impl Foo for T { - default fn foo(&self) -> &'static str { - "generic" - } -} - -impl Foo for T { - default fn foo(&self) -> &'static str { - "generic Clone" - } -} - -impl Foo for (T, U) where T: Clone, U: Clone { - default fn foo(&self) -> &'static str { - "generic pair" - } -} - -impl Foo for (T, T) { - default fn foo(&self) -> &'static str { - "generic uniform pair" - } -} - -impl Foo for (u8, u32) { - default fn foo(&self) -> &'static str { - "(u8, u32)" - } -} - -impl Foo for (u8, u8) { - default fn foo(&self) -> &'static str { - "(u8, u8)" - } -} - -impl Foo for Vec { - default fn foo(&self) -> &'static str { - "generic Vec" - } -} - -impl Foo for Vec { - fn foo(&self) -> &'static str { - "Vec" - } -} - -impl Foo for String { - fn foo(&self) -> &'static str { - "String" - } -} - -impl Foo for i32 { - fn foo(&self) -> &'static str { - "i32" - } -} - -pub trait MyMarker {} -impl Foo for T { - default fn foo(&self) -> &'static str { - "generic Clone + MyMarker" - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/cross-crate-defaults.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/cross-crate-defaults.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/cross-crate-defaults.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/cross-crate-defaults.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// aux-build:cross_crates_defaults.rs - -#![feature(specialization)] - -extern crate cross_crates_defaults; - -use cross_crates_defaults::*; - -struct LocalDefault; -struct LocalOverride; - -impl Foo for LocalDefault {} - -impl Foo for LocalOverride { - fn foo(&self) -> bool { true } -} - -fn test_foo() { - assert!(!0i8.foo()); - assert!(!0i32.foo()); - assert!(0i64.foo()); - - assert!(!LocalDefault.foo()); - assert!(LocalOverride.foo()); -} - -fn test_bar() { - assert!(0u8.bar() == 0); - assert!(0i32.bar() == 1); - assert!("hello".bar() == 0); - assert!(vec![()].bar() == 2); - assert!(vec![0i32].bar() == 2); - assert!(vec![0i64].bar() == 3); -} - -fn main() { - test_foo(); - test_bar(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/allowed-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/allowed-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/allowed-cross-crate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/allowed-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// aux-build:go_trait.rs - -#![feature(specialization)] - -extern crate go_trait; - -use go_trait::{Go,GoMut}; -use std::fmt::Debug; -use std::default::Default; - -struct MyThingy; - -impl Go for MyThingy { - fn go(&self, arg: isize) { } -} - -impl GoMut for MyThingy { - fn go_mut(&mut self, arg: isize) { } -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/auxiliary/go_trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/auxiliary/go_trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/auxiliary/go_trait.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/auxiliary/go_trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(specialization)] - -// Common code used for tests that model the Fn/FnMut/FnOnce hierarchy. - -pub trait Go { - fn go(&self, arg: isize); -} - -pub fn go(this: &G, arg: isize) { - this.go(arg) -} - -pub trait GoMut { - fn go_mut(&mut self, arg: isize); -} - -pub fn go_mut(this: &mut G, arg: isize) { - this.go_mut(arg) -} - -pub trait GoOnce { - fn go_once(self, arg: isize); -} - -pub fn go_once(this: G, arg: isize) { - this.go_once(arg) -} - -default impl GoMut for G - where G : Go -{ - fn go_mut(&mut self, arg: isize) { - go(&*self, arg) - } -} - -default impl GoOnce for G - where G : GoMut -{ - fn go_once(mut self, arg: isize) { - go_mut(&mut self, arg) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/out-of-order.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/out-of-order.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/out-of-order.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/out-of-order.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Test that you can list the more specific impl before the more general one. - -#![feature(specialization)] - -trait Foo { - type Out; -} - -impl Foo for bool { - type Out = (); -} - -default impl Foo for T { - type Out = bool; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/overlap-projection.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/overlap-projection.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/overlap-projection.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/overlap-projection.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Test that impls on projected self types can resolve overlap, even when the -// projections involve specialization, so long as the associated type is -// provided by the most specialized impl. - -#![feature(specialization)] - -trait Assoc { - type Output; -} - -default impl Assoc for T { - type Output = bool; -} - -impl Assoc for u8 { type Output = u8; } -impl Assoc for u16 { type Output = u16; } - -trait Foo {} -impl Foo for u32 {} -impl Foo for ::Output {} -impl Foo for ::Output {} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/projection.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/projection.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/projection.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/projection.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(specialization)] - -// Make sure we *can* project non-defaulted associated types -// cf compile-fail/specialization-default-projection.rs - -// First, do so without any use of specialization - -trait Foo { - type Assoc; -} - -impl Foo for T { - type Assoc = (); -} - -fn generic_foo() -> ::Assoc { - () -} - -// Next, allow for one layer of specialization - -trait Bar { - type Assoc; -} - -default impl Bar for T { - type Assoc = (); -} - -impl Bar for T { - type Assoc = u8; -} - -fn generic_bar_clone() -> ::Assoc { - 0u8 -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/specialization-trait-item-not-implemented.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/specialization-trait-item-not-implemented.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/specialization-trait-item-not-implemented.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/defaultimpl/specialization-trait-item-not-implemented.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Tests that we can combine a default impl that supplies one method with a -// full impl that supplies the other, and they can invoke one another. - -#![feature(specialization)] - -trait Foo { - fn foo_one(&self) -> &'static str; - fn foo_two(&self) -> &'static str; - fn foo_three(&self) -> &'static str; -} - -struct MyStruct; - -default impl Foo for T { - fn foo_one(&self) -> &'static str { - self.foo_three() - } -} - -impl Foo for MyStruct { - fn foo_two(&self) -> &'static str { - self.foo_one() - } - - fn foo_three(&self) -> &'static str { - "generic" - } -} - -fn main() { - assert!(MyStruct.foo_two() == "generic"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/README.md rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/README.md --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/README.md 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/README.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -Tests that specialization is working correctly: - -- Dispatch - - [On methods](specialization-basics.rs), includes: - - Specialization via adding a trait bound - - Including both remote and local traits - - Specialization via pure structure (e.g. `(T, U)` vs `(T, T)`) - - Specialization via concrete types vs unknown types - - In top level of the trait reference - - Embedded within another type (`Vec` vs `Vec`) - - [Specialization based on super trait relationships](specialization-super-traits.rs) - - [On assoc fns](specialization-assoc-fns.rs) - - [Ensure that impl order doesn't matter](specialization-out-of-order.rs) - -- Item inheritance - - [Correct default cascading for methods](specialization-default-methods.rs) - - Inheritance works across impls with varying generics - - [With projections](specialization-translate-projections.rs) - - [With projections that involve input types](specialization-translate-projections-with-params.rs) - -- Normalization issues - - [Non-default assoc types can be projected](specialization-projection.rs) - - Including non-specialized cases - - Including specialized cases - - [Specialized Impls can happen on projections](specialization-on-projection.rs) - - [Projections and aliases play well together](specialization-projection-alias.rs) - - [Projections involving specialization allowed in the trait ref for impls, and overlap can still be determined](specialization-overlap-projection.rs) - - Only works for the simple case where the most specialized impl directly - provides a non-`default` associated type - -- Across crates - - [For traits defined in upstream crate](specialization-allowed-cross-crate.rs) - - [Full method dispatch tests, drawing from upstream crate](specialization-cross-crate.rs) - - Including *additional* local specializations - - [Full method dispatch tests, *without* turning on specialization in local crate](specialization-cross-crate-no-gate.rs) - - [Test that defaults cascade correctly from upstream crates](specialization-cross-crate-defaults.rs) - - Including *additional* local use of defaults diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-allowed-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-allowed-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-allowed-cross-crate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-allowed-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// aux-build:go_trait.rs - -#![feature(specialization)] - -extern crate go_trait; - -use go_trait::{Go,GoMut}; -use std::fmt::Debug; -use std::default::Default; - -struct MyThingy; - -impl Go for MyThingy { - fn go(&self, arg: isize) { } -} - -impl GoMut for MyThingy { - fn go_mut(&mut self, arg: isize) { } -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-assoc-fns.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-assoc-fns.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-assoc-fns.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-assoc-fns.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Test that non-method associated functions can be specialized - -#![feature(specialization)] - -trait Foo { - fn mk() -> Self; -} - -impl Foo for T { - default fn mk() -> T { - T::default() - } -} - -impl Foo for Vec { - fn mk() -> Vec { - vec![0] - } -} - -fn main() { - let v1: Vec = Foo::mk(); - let v2: Vec = Foo::mk(); - - assert!(v1.len() == 0); - assert!(v2.len() == 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-basics.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-basics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-basics.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-basics.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(specialization)] - -// Tests a variety of basic specialization scenarios and method -// dispatch for them. - -trait Foo { - fn foo(&self) -> &'static str; -} - -impl Foo for T { - default fn foo(&self) -> &'static str { - "generic" - } -} - -impl Foo for T { - default fn foo(&self) -> &'static str { - "generic Clone" - } -} - -impl Foo for (T, U) where T: Clone, U: Clone { - default fn foo(&self) -> &'static str { - "generic pair" - } -} - -impl Foo for (T, T) { - default fn foo(&self) -> &'static str { - "generic uniform pair" - } -} - -impl Foo for (u8, u32) { - default fn foo(&self) -> &'static str { - "(u8, u32)" - } -} - -impl Foo for (u8, u8) { - default fn foo(&self) -> &'static str { - "(u8, u8)" - } -} - -impl Foo for Vec { - default fn foo(&self) -> &'static str { - "generic Vec" - } -} - -impl Foo for Vec { - fn foo(&self) -> &'static str { - "Vec" - } -} - -impl Foo for String { - fn foo(&self) -> &'static str { - "String" - } -} - -impl Foo for i32 { - fn foo(&self) -> &'static str { - "i32" - } -} - -struct NotClone; - -trait MyMarker {} -impl Foo for T { - default fn foo(&self) -> &'static str { - "generic Clone + MyMarker" - } -} - -#[derive(Clone)] -struct MarkedAndClone; -impl MyMarker for MarkedAndClone {} - -fn main() { - assert!(NotClone.foo() == "generic"); - assert!(0u8.foo() == "generic Clone"); - assert!(vec![NotClone].foo() == "generic"); - assert!(vec![0u8].foo() == "generic Vec"); - assert!(vec![0i32].foo() == "Vec"); - assert!(0i32.foo() == "i32"); - assert!(String::new().foo() == "String"); - assert!(((), 0).foo() == "generic pair"); - assert!(((), ()).foo() == "generic uniform pair"); - assert!((0u8, 0u32).foo() == "(u8, u32)"); - assert!((0u8, 0u8).foo() == "(u8, u8)"); - assert!(MarkedAndClone.foo() == "generic Clone + MyMarker"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-cross-crate-no-gate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-cross-crate-no-gate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-cross-crate-no-gate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-cross-crate-no-gate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Test that specialization works even if only the upstream crate enables it - -// aux-build:specialization_cross_crate.rs - -extern crate specialization_cross_crate; - -use specialization_cross_crate::*; - -fn main() { - assert!(0u8.foo() == "generic Clone"); - assert!(vec![0u8].foo() == "generic Vec"); - assert!(vec![0i32].foo() == "Vec"); - assert!(0i32.foo() == "i32"); - assert!(String::new().foo() == "String"); - assert!(((), 0).foo() == "generic pair"); - assert!(((), ()).foo() == "generic uniform pair"); - assert!((0u8, 0u32).foo() == "(u8, u32)"); - assert!((0u8, 0u8).foo() == "(u8, u8)"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-cross-crate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// aux-build:specialization_cross_crate.rs - -#![feature(specialization)] - -extern crate specialization_cross_crate; - -use specialization_cross_crate::*; - -struct NotClone; - -#[derive(Clone)] -struct MarkedAndClone; -impl MyMarker for MarkedAndClone {} - -struct MyType(T); -impl Foo for MyType { - default fn foo(&self) -> &'static str { - "generic MyType" - } -} - -impl Foo for MyType { - fn foo(&self) -> &'static str { - "MyType" - } -} - -struct MyOtherType; -impl Foo for MyOtherType {} - -fn main() { - assert!(NotClone.foo() == "generic"); - assert!(0u8.foo() == "generic Clone"); - assert!(vec![NotClone].foo() == "generic"); - assert!(vec![0u8].foo() == "generic Vec"); - assert!(vec![0i32].foo() == "Vec"); - assert!(0i32.foo() == "i32"); - assert!(String::new().foo() == "String"); - assert!(((), 0).foo() == "generic pair"); - assert!(((), ()).foo() == "generic uniform pair"); - assert!((0u8, 0u32).foo() == "(u8, u32)"); - assert!((0u8, 0u8).foo() == "(u8, u8)"); - assert!(MarkedAndClone.foo() == "generic Clone + MyMarker"); - - assert!(MyType(()).foo() == "generic MyType"); - assert!(MyType(0u8).foo() == "MyType"); - assert!(MyOtherType.foo() == "generic"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-default-methods.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-default-methods.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-default-methods.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-default-methods.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(specialization)] - -// Test that default methods are cascaded correctly - -// First, test only use of explicit `default` items: - -trait Foo { - fn foo(&self) -> bool; -} - -// Specialization tree for Foo: -// -// T -// / \ -// i32 i64 - -impl Foo for T { - default fn foo(&self) -> bool { false } -} - -impl Foo for i32 {} - -impl Foo for i64 { - fn foo(&self) -> bool { true } -} - -fn test_foo() { - assert!(!0i8.foo()); - assert!(!0i32.foo()); - assert!(0i64.foo()); -} - -// Next, test mixture of explicit `default` and provided methods: - -trait Bar { - fn bar(&self) -> i32 { 0 } -} - -// Specialization tree for Bar. -// Uses of $ designate that method is provided -// -// $Bar (the trait) -// | -// T -// /|\ -// / | \ -// / | \ -// / | \ -// / | \ -// / | \ -// $i32 &str $Vec -// /\ -// / \ -// Vec $Vec - -// use the provided method -impl Bar for T {} - -impl Bar for i32 { - fn bar(&self) -> i32 { 1 } -} -impl<'a> Bar for &'a str {} - -impl Bar for Vec { - default fn bar(&self) -> i32 { 2 } -} -impl Bar for Vec {} -impl Bar for Vec { - fn bar(&self) -> i32 { 3 } -} - -fn test_bar() { - assert!(0u8.bar() == 0); - assert!(0i32.bar() == 1); - assert!("hello".bar() == 0); - assert!(vec![()].bar() == 2); - assert!(vec![0i32].bar() == 2); - assert!(vec![0i64].bar() == 3); -} - -fn main() { - test_foo(); - test_bar(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-on-projection.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-on-projection.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-on-projection.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-on-projection.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(specialization)] - -// Ensure that specialization works for impls defined directly on a projection - -trait Foo {} - -trait Assoc { - type Item; -} - -impl Foo for T {} - -struct Struct; - -impl Assoc for Struct { - type Item = u8; -} - -impl Foo for Struct {} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-out-of-order.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-out-of-order.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-out-of-order.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-out-of-order.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Test that you can list the more specific impl before the more general one. - -#![feature(specialization)] - -trait Foo { - type Out; -} - -impl Foo for bool { - type Out = (); -} - -impl Foo for T { - default type Out = bool; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-overlap-projection.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-overlap-projection.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-overlap-projection.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-overlap-projection.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Test that impls on projected self types can resolve overlap, even when the -// projections involve specialization, so long as the associated type is -// provided by the most specialized impl. - -#![feature(specialization)] - -trait Assoc { - type Output; -} - -impl Assoc for T { - default type Output = bool; -} - -impl Assoc for u8 { type Output = u8; } -impl Assoc for u16 { type Output = u16; } - -trait Foo {} -impl Foo for u32 {} -impl Foo for ::Output {} -impl Foo for ::Output {} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-projection-alias.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-projection-alias.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-projection-alias.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-projection-alias.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(specialization)] - -// Regression test for ICE when combining specialized associated types and type -// aliases - -trait Id_ { - type Out; -} - -type Id = ::Out; - -impl Id_ for T { - default type Out = T; -} - -fn test_proection() { - let x: Id = panic!(); -} - -fn main() { - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-projection.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-projection.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-projection.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-projection.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(specialization)] - -// Make sure we *can* project non-defaulted associated types -// cf compile-fail/specialization-default-projection.rs - -// First, do so without any use of specialization - -trait Foo { - type Assoc; -} - -impl Foo for T { - type Assoc = (); -} - -fn generic_foo() -> ::Assoc { - () -} - -// Next, allow for one layer of specialization - -trait Bar { - type Assoc; -} - -impl Bar for T { - default type Assoc = (); -} - -impl Bar for T { - type Assoc = u8; -} - -fn generic_bar_clone() -> ::Assoc { - 0u8 -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-super-traits.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-super-traits.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-super-traits.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-super-traits.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(specialization)] - -// Test that you can specialize via an explicit trait hierarchy - -// FIXME: this doesn't work yet... - -trait Parent {} -trait Child: Parent {} - -trait Foo {} - -impl Foo for T {} -impl Foo for T {} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-translate-projections.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-translate-projections.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-translate-projections.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-translate-projections.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Ensure that provided items are inherited properly even when impls vary in -// type parameters *and* rely on projections. - -#![feature(specialization)] - -use std::convert::Into; - -trait Trait { - fn to_u8(&self) -> u8; -} -trait WithAssoc { - type Item; - fn to_item(&self) -> Self::Item; -} - -impl Trait for T where T: WithAssoc, U: Into { - fn to_u8(&self) -> u8 { - self.to_item().into() - } -} - -impl WithAssoc for u8 { - type Item = u8; - fn to_item(&self) -> u8 { *self } -} - -impl Trait for u8 {} - -fn main() { - assert!(3u8.to_u8() == 3u8); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-translate-projections-with-lifetimes.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-translate-projections-with-lifetimes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-translate-projections-with-lifetimes.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-translate-projections-with-lifetimes.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(specialization)] - -trait Iterator { - fn next(&self); -} - -trait WithAssoc { - type Item; -} - -impl<'a> WithAssoc for &'a () { - type Item = &'a u32; -} - -struct Cloned(I); - -impl<'a, I, T: 'a> Iterator for Cloned - where I: WithAssoc, T: Clone -{ - fn next(&self) {} -} - -impl<'a, I, T: 'a> Iterator for Cloned - where I: WithAssoc, T: Copy -{ - -} - -fn main() { - Cloned(&()).next(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-translate-projections-with-params.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-translate-projections-with-params.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-translate-projections-with-params.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/specialization/specialization-translate-projections-with-params.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// Ensure that provided items are inherited properly even when impls vary in -// type parameters *and* rely on projections, and the type parameters are input -// types on the trait. - -#![feature(specialization)] - -trait Trait { - fn convert(&self) -> T; -} -trait WithAssoc { - type Item; - fn as_item(&self) -> &Self::Item; -} - -impl Trait for T where T: WithAssoc, U: Clone { - fn convert(&self) -> U { - self.as_item().clone() - } -} - -impl WithAssoc for u8 { - type Item = u8; - fn as_item(&self) -> &u8 { self } -} - -impl Trait for u8 {} - -fn main() { - assert!(3u8.convert() == 3u8); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/auxiliary/static_fn_inline_xc_aux.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/auxiliary/static_fn_inline_xc_aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/auxiliary/static_fn_inline_xc_aux.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/auxiliary/static_fn_inline_xc_aux.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -pub mod num { - pub trait Num2 { - fn from_int2(n: isize) -> Self; - } -} - -pub mod f64 { - impl ::num::Num2 for f64 { - #[inline] - fn from_int2(n: isize) -> f64 { return n as f64; } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/auxiliary/static_fn_trait_xc_aux.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/auxiliary/static_fn_trait_xc_aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/auxiliary/static_fn_trait_xc_aux.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/auxiliary/static_fn_trait_xc_aux.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod num { - pub trait Num2 { - fn from_int2(n: isize) -> Self; - } -} - -pub mod f64 { - impl ::num::Num2 for f64 { - fn from_int2(n: isize) -> f64 { return n as f64; } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/auxiliary/static-function-pointer-aux.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/auxiliary/static-function-pointer-aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/auxiliary/static-function-pointer-aux.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/auxiliary/static-function-pointer-aux.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -pub fn f(x: isize) -> isize { -x } - -pub static F: fn(isize) -> isize = f; -pub static mut MutF: fn(isize) -> isize = f; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/auxiliary/static-methods-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/auxiliary/static-methods-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/auxiliary/static-methods-crate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/auxiliary/static-methods-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="static_methods_crate"] -#![crate_type = "lib"] - -pub trait read: Sized { - fn readMaybe(s: String) -> Option; -} - -impl read for isize { - fn readMaybe(s: String) -> Option { - s.parse().ok() - } -} - -impl read for bool { - fn readMaybe(s: String) -> Option { - match &*s { - "true" => Some(true), - "false" => Some(false), - _ => None - } - } -} - -pub fn read(s: String) -> T { - match read::readMaybe(s) { - Some(x) => x, - _ => panic!("read panicked!") - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/auxiliary/static_mut_xc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/auxiliary/static_mut_xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/auxiliary/static_mut_xc.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/auxiliary/static_mut_xc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub static mut a: isize = 3; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-fn-inline-xc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-fn-inline-xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-fn-inline-xc.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-fn-inline-xc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:static_fn_inline_xc_aux.rs - -// pretty-expanded FIXME #23616 - -extern crate static_fn_inline_xc_aux as mycore; - -use mycore::num; - -pub fn main() { - let _1: f64 = num::Num2::from_int2(1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-fn-trait-xc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-fn-trait-xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-fn-trait-xc.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-fn-trait-xc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:static_fn_trait_xc_aux.rs - -// pretty-expanded FIXME #23616 - -extern crate static_fn_trait_xc_aux as mycore; - -use mycore::num; - -pub fn main() { - let _1: f64 = num::Num2::from_int2(1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-function-pointer.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-function-pointer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-function-pointer.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-function-pointer.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -fn f(x: isize) -> isize { x } -fn g(x: isize) -> isize { 2 * x } - -static F: fn(isize) -> isize = f; -static mut G: fn(isize) -> isize = f; - -pub fn main() { - assert_eq!(F(42), 42); - unsafe { - assert_eq!(G(42), 42); - G = g; - assert_eq!(G(42), 84); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-function-pointer-xc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-function-pointer-xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-function-pointer-xc.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-function-pointer-xc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:static-function-pointer-aux.rs - -extern crate static_function_pointer_aux as aux; - -fn f(x: isize) -> isize { x } - -pub fn main() { - assert_eq!(aux::F(42), -42); - unsafe { - assert_eq!(aux::MutF(42), -42); - aux::MutF = f; - assert_eq!(aux::MutF(42), 42); - aux::MutF = aux::f; - assert_eq!(aux::MutF(42), -42); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-impl.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-impl.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - - - -pub trait plus { - fn plus(&self) -> isize; -} - -mod a { - use plus; - impl plus for usize { fn plus(&self) -> isize { *self as isize + 20 } } -} - -mod b { - use plus; - impl plus for String { fn plus(&self) -> isize { 200 } } -} - -trait uint_utils { - fn str(&self) -> String; - fn multi(&self, f: F) where F: FnMut(usize); -} - -impl uint_utils for usize { - fn str(&self) -> String { - self.to_string() - } - fn multi(&self, mut f: F) where F: FnMut(usize) { - let mut c = 0_usize; - while c < *self { f(c); c += 1_usize; } - } -} - -trait vec_utils { - fn length_(&self, ) -> usize; - fn iter_(&self, f: F) where F: FnMut(&T); - fn map_(&self, f: F) -> Vec where F: FnMut(&T) -> U; -} - -impl vec_utils for Vec { - fn length_(&self) -> usize { self.len() } - fn iter_(&self, mut f: F) where F: FnMut(&T) { for x in self { f(x); } } - fn map_(&self, mut f: F) -> Vec where F: FnMut(&T) -> U { - let mut r = Vec::new(); - for elt in self { - r.push(f(elt)); - } - r - } -} - -pub fn main() { - assert_eq!(10_usize.plus(), 30); - assert_eq!(("hi".to_string()).plus(), 200); - - assert_eq!((vec![1]).length_().str(), "1".to_string()); - let vect = vec![3, 4].map_(|a| *a + 4); - assert_eq!(vect[0], 7); - let vect = (vec![3, 4]).map_::(|a| *a as usize + 4_usize); - assert_eq!(vect[0], 7_usize); - let mut x = 0_usize; - 10_usize.multi(|_n| x += 2_usize ); - assert_eq!(x, 20_usize); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-method-in-trait-with-tps-intracrate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-method-in-trait-with-tps-intracrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-method-in-trait-with-tps-intracrate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-method-in-trait-with-tps-intracrate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait Deserializer { - fn read_int(&self) -> isize; -} - -trait Deserializable { - fn deserialize(d: &D) -> Self; -} - -impl Deserializable for isize { - fn deserialize(d: &D) -> isize { - return d.read_int(); - } -} - -struct FromThinAir { dummy: () } - -impl Deserializer for FromThinAir { - fn read_int(&self) -> isize { 22 } -} - -pub fn main() { - let d = FromThinAir { dummy: () }; - let i: isize = Deserializable::deserialize(&d); - assert_eq!(i, 22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-methods-in-traits2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-methods-in-traits2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-methods-in-traits2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-methods-in-traits2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub trait Number: NumConv { - fn from(n: T) -> Self; -} - -impl Number for f64 { - fn from(n: T) -> f64 { n.to_float() } -} - -pub trait NumConv { - fn to_float(&self) -> f64; -} - -impl NumConv for f64 { - fn to_float(&self) -> f64 { *self } -} - -pub fn main() { - let _: f64 = Number::from(0.0f64); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-methods-in-traits.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-methods-in-traits.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-methods-in-traits.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-methods-in-traits.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -mod a { - pub trait Foo { - fn foo() -> Self; - } - - impl Foo for isize { - fn foo() -> isize { - 3 - } - } - - impl Foo for usize { - fn foo() -> usize { - 5 - } - } -} - -pub fn main() { - let x: isize = a::Foo::foo(); - let y: usize = a::Foo::foo(); - assert_eq!(x, 3); - assert_eq!(y, 5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-method-xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-method-xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-method-xcrate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-method-xcrate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:static-methods-crate.rs - -extern crate static_methods_crate; - -use static_methods_crate::read; - -pub fn main() { - let result: isize = read("5".to_string()); - assert_eq!(result, 5); - assert_eq!(read::readMaybe("false".to_string()), Some(false)); - assert_eq!(read::readMaybe("foo".to_string()), None::); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-mut-foreign.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-mut-foreign.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-mut-foreign.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-mut-foreign.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Constants (static variables) can be used to match in patterns, but mutable -// statics cannot. This ensures that there's some form of error if this is -// attempted. - -// ignore-wasm32-bare no libc to test ffi with - -#![feature(libc)] - -extern crate libc; - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - static mut rust_dbg_static_mut: libc::c_int; - pub fn rust_dbg_static_mut_check_four(); -} - -unsafe fn static_bound(_: &'static libc::c_int) {} - -fn static_bound_set(a: &'static mut libc::c_int) { - *a = 3; -} - -unsafe fn run() { - assert_eq!(rust_dbg_static_mut, 3); - rust_dbg_static_mut = 4; - assert_eq!(rust_dbg_static_mut, 4); - rust_dbg_static_mut_check_four(); - rust_dbg_static_mut += 1; - assert_eq!(rust_dbg_static_mut, 5); - rust_dbg_static_mut *= 3; - assert_eq!(rust_dbg_static_mut, 15); - rust_dbg_static_mut = -3; - assert_eq!(rust_dbg_static_mut, -3); - static_bound(&rust_dbg_static_mut); - static_bound_set(&mut rust_dbg_static_mut); -} - -pub fn main() { - unsafe { run() } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-mut-xc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-mut-xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-mut-xc.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-mut-xc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -// Constants (static variables) can be used to match in patterns, but mutable -// statics cannot. This ensures that there's some form of error if this is -// attempted. - -// aux-build:static_mut_xc.rs - - -extern crate static_mut_xc; - -unsafe fn static_bound(_: &'static isize) {} - -fn static_bound_set(a: &'static mut isize) { - *a = 3; -} - -unsafe fn run() { - assert_eq!(static_mut_xc::a, 3); - static_mut_xc::a = 4; - assert_eq!(static_mut_xc::a, 4); - static_mut_xc::a += 1; - assert_eq!(static_mut_xc::a, 5); - static_mut_xc::a *= 3; - assert_eq!(static_mut_xc::a, 15); - static_mut_xc::a = -3; - assert_eq!(static_mut_xc::a, -3); - static_bound(&static_mut_xc::a); - static_bound_set(&mut static_mut_xc::a); -} - -pub fn main() { - unsafe { run() } -} - -pub mod inner { - pub static mut a: isize = 4; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-recursive.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-recursive.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-recursive.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/statics/static-recursive.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -static mut S: *const u8 = unsafe { &S as *const *const u8 as *const u8 }; - -struct StaticDoubleLinked { - prev: &'static StaticDoubleLinked, - next: &'static StaticDoubleLinked, - data: i32, - head: bool -} - -static L1: StaticDoubleLinked = StaticDoubleLinked{prev: &L3, next: &L2, data: 1, head: true}; -static L2: StaticDoubleLinked = StaticDoubleLinked{prev: &L1, next: &L3, data: 2, head: false}; -static L3: StaticDoubleLinked = StaticDoubleLinked{prev: &L2, next: &L1, data: 3, head: false}; - - -pub fn main() { - unsafe { assert_eq!(S, *(S as *const *const u8)); } - - let mut test_vec = Vec::new(); - let mut cur = &L1; - loop { - test_vec.push(cur.data); - cur = cur.next; - if cur.head { break } - } - assert_eq!(&test_vec, &[1,2,3]); - - let mut test_vec = Vec::new(); - let mut cur = &L1; - loop { - cur = cur.prev; - test_vec.push(cur.data); - if cur.head { break } - } - assert_eq!(&test_vec, &[3,2,1]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/align-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/align-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/align-struct.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/align-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,255 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] -#![feature(repr_packed)] - -use std::mem; - -// Raising alignment -#[repr(align(16))] -#[derive(Clone, Copy, Debug)] -struct Align16(i32); - -// Lowering has no effect -#[repr(align(1))] -struct Align1(i32); - -// Multiple attributes take the max -#[repr(align(4))] -#[repr(align(16))] -#[repr(align(8))] -struct AlignMany(i32); - -// Raising alignment may not alter size. -#[repr(align(8))] -#[allow(dead_code)] -struct Align8Many { - a: i32, - b: i32, - c: i32, - d: u8, -} - -enum Enum { - #[allow(dead_code)] - A(i32), - B(Align16) -} - -// Nested alignment - use `#[repr(C)]` to suppress field reordering for sizeof test -#[repr(C)] -struct Nested { - a: i32, - b: i32, - c: Align16, - d: i8, -} - -#[repr(packed)] -struct Packed(i32); - -#[repr(align(16))] -struct AlignContainsPacked { - a: Packed, - b: Packed, -} - -#[repr(C, packed(4))] -struct Packed4C { - a: u32, - b: u64, -} - -#[repr(align(16))] -struct AlignContainsPacked4C { - a: Packed4C, - b: u64, -} - -// The align limit was originally smaller (2^15). -// Check that it works with big numbers. -#[repr(align(0x10000))] -struct AlignLarge { - stuff: [u8; 0x10000], -} - -union UnionContainsAlign { - a: Align16, - b: f32 -} - -impl Align16 { - // return aligned type - pub fn new(i: i32) -> Align16 { - Align16(i) - } - // pass aligned type - pub fn consume(a: Align16) -> i32 { - a.0 - } -} - -const CONST_ALIGN16: Align16 = Align16(7); -static STATIC_ALIGN16: Align16 = Align16(8); - -// Check the actual address is aligned -fn is_aligned_to(p: &T, align: usize) -> bool { - let addr = p as *const T as usize; - (addr & (align - 1)) == 0 -} - -pub fn main() { - // check alignment and size by type and value - assert_eq!(mem::align_of::(), 16); - assert_eq!(mem::size_of::(), 16); - - let a = Align16(7); - assert_eq!(a.0, 7); - assert_eq!(mem::align_of_val(&a), 16); - assert_eq!(mem::size_of_val(&a), 16); - - assert!(is_aligned_to(&a, 16)); - - // lowering should have no effect - assert_eq!(mem::align_of::(), 4); - assert_eq!(mem::size_of::(), 4); - let a = Align1(7); - assert_eq!(a.0, 7); - assert_eq!(mem::align_of_val(&a), 4); - assert_eq!(mem::size_of_val(&a), 4); - assert!(is_aligned_to(&a, 4)); - - // when multiple attributes are specified the max should be used - assert_eq!(mem::align_of::(), 16); - assert_eq!(mem::size_of::(), 16); - let a = AlignMany(7); - assert_eq!(a.0, 7); - assert_eq!(mem::align_of_val(&a), 16); - assert_eq!(mem::size_of_val(&a), 16); - assert!(is_aligned_to(&a, 16)); - - // raising alignment should not reduce size - assert_eq!(mem::align_of::(), 8); - assert_eq!(mem::size_of::(), 16); - let a = Align8Many { a: 1, b: 2, c: 3, d: 4 }; - assert_eq!(a.a, 1); - assert_eq!(mem::align_of_val(&a), 8); - assert_eq!(mem::size_of_val(&a), 16); - assert!(is_aligned_to(&a, 8)); - - // return type - let a = Align16::new(1); - assert_eq!(mem::align_of_val(&a), 16); - assert_eq!(mem::size_of_val(&a), 16); - assert_eq!(a.0, 1); - assert!(is_aligned_to(&a, 16)); - assert_eq!(Align16::consume(a), 1); - - // check const alignment, size and value - assert_eq!(mem::align_of_val(&CONST_ALIGN16), 16); - assert_eq!(mem::size_of_val(&CONST_ALIGN16), 16); - assert_eq!(CONST_ALIGN16.0, 7); - assert!(is_aligned_to(&CONST_ALIGN16, 16)); - - // check global static alignment, size and value - assert_eq!(mem::align_of_val(&STATIC_ALIGN16), 16); - assert_eq!(mem::size_of_val(&STATIC_ALIGN16), 16); - assert_eq!(STATIC_ALIGN16.0, 8); - assert!(is_aligned_to(&STATIC_ALIGN16, 16)); - - // Note that the size of Nested may change if struct field re-ordering is enabled - assert_eq!(mem::align_of::(), 16); - assert_eq!(mem::size_of::(), 48); - let a = Nested{ a: 1, b: 2, c: Align16(3), d: 4}; - assert_eq!(mem::align_of_val(&a), 16); - assert_eq!(mem::align_of_val(&a.b), 4); - assert_eq!(mem::align_of_val(&a.c), 16); - assert_eq!(mem::size_of_val(&a), 48); - assert!(is_aligned_to(&a, 16)); - // check the correct fields are indexed - assert_eq!(a.a, 1); - assert_eq!(a.b, 2); - assert_eq!(a.c.0, 3); - assert_eq!(a.d, 4); - - // enum should be aligned to max alignment - assert_eq!(mem::align_of::(), 16); - assert_eq!(mem::align_of_val(&Enum::B(Align16(0))), 16); - let e = Enum::B(Align16(15)); - match e { - Enum::B(ref a) => { - assert_eq!(a.0, 15); - assert_eq!(mem::align_of_val(a), 16); - assert_eq!(mem::size_of_val(a), 16); - }, - _ => () - } - assert!(is_aligned_to(&e, 16)); - - // check union alignment - assert_eq!(mem::align_of::(), 16); - assert_eq!(mem::size_of::(), 16); - let u = UnionContainsAlign { a: Align16(10) }; - unsafe { - assert_eq!(mem::align_of_val(&u.a), 16); - assert_eq!(mem::size_of_val(&u.a), 16); - assert_eq!(u.a.0, 10); - let UnionContainsAlign { a } = u; - assert_eq!(a.0, 10); - } - - // arrays of aligned elements should also be aligned - assert_eq!(mem::align_of::<[Align16;2]>(), 16); - assert_eq!(mem::size_of::<[Align16;2]>(), 32); - - let a = [Align16(0), Align16(1)]; - assert_eq!(mem::align_of_val(&a[0]), 16); - assert_eq!(mem::align_of_val(&a[1]), 16); - assert!(is_aligned_to(&a, 16)); - - // check heap value is aligned - assert_eq!(mem::align_of_val(Box::new(Align16(0)).as_ref()), 16); - - // check heap array is aligned - let a = vec!(Align16(0), Align16(1)); - assert_eq!(mem::align_of_val(&a[0]), 16); - assert_eq!(mem::align_of_val(&a[1]), 16); - - assert_eq!(mem::align_of::(), 16); - assert_eq!(mem::size_of::(), 16); - let a = AlignContainsPacked { a: Packed(1), b: Packed(2) }; - assert_eq!(mem::align_of_val(&a), 16); - assert_eq!(mem::align_of_val(&a.a), 1); - assert_eq!(mem::align_of_val(&a.b), 1); - assert_eq!(mem::size_of_val(&a), 16); - assert!(is_aligned_to(&a, 16)); - - assert_eq!(mem::align_of::(), 16); - assert_eq!(mem::size_of::(), 32); - let a = AlignContainsPacked4C { a: Packed4C{ a: 1, b: 2 }, b: 3 }; - assert_eq!(mem::align_of_val(&a), 16); - assert_eq!(mem::align_of_val(&a.a), 4); - assert_eq!(mem::align_of_val(&a.b), mem::align_of::()); - assert_eq!(mem::size_of_val(&a), 32); - assert!(is_aligned_to(&a, 16)); - - let mut large = box AlignLarge { - stuff: [0; 0x10000], - }; - large.stuff[0] = 132; - *large.stuff.last_mut().unwrap() = 102; - assert_eq!(large.stuff[0], 132); - assert_eq!(large.stuff.last(), Some(&102)); - assert_eq!(mem::align_of::(), 0x10000); - assert_eq!(mem::align_of_val(&*large), 0x10000); - assert!(is_aligned_to(&*large, 0x10000)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod kitties { - pub struct cat { - meows : usize, - - pub how_hungry : isize, - - } - - impl cat { - pub fn speak(&self) {} - } - - pub fn cat(in_x : usize, in_y : isize) -> cat { - cat { - meows: in_x, - how_hungry: in_y - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_3.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod kitties { - pub struct cat { - meows : usize, - - pub how_hungry : isize, - } - - impl cat { - pub fn speak(&mut self) { self.meows += 1; } - pub fn meow_count(&mut self) -> usize { self.meows } - } - - pub fn cat(in_x : usize, in_y : isize) -> cat { - cat { - meows: in_x, - how_hungry: in_y - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_4.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_4.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_4.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod kitties { - pub struct cat { - meows : usize, - - pub how_hungry : isize, - pub name : String, - } - - impl cat { - pub fn speak(&mut self) { self.meow(); } - - pub fn eat(&mut self) -> bool { - if self.how_hungry > 0 { - println!("OM NOM NOM"); - self.how_hungry -= 2; - return true; - } else { - println!("Not hungry!"); - return false; - } - } - } - - impl cat { - pub fn meow(&mut self) { - println!("Meow"); - self.meows += 1; - if self.meows % 5 == 0 { - self.how_hungry += 1; - } - } - } - - pub fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { - cat { - meows: in_x, - how_hungry: in_y, - name: in_name - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_6.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_6.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_6.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_6.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod kitties { - - pub struct cat { - info : Vec , - meows : usize, - - pub how_hungry : isize, - } - - impl cat { - pub fn speak(&mut self, stuff: Vec ) { - self.meows += stuff.len(); - } - - pub fn meow_count(&mut self) -> usize { self.meows } - } - - pub fn cat(in_x : usize, in_y : isize, in_info: Vec ) -> cat { - cat { - meows: in_x, - how_hungry: in_y, - info: in_info - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_cast.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_cast.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_cast.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod kitty { - use std::fmt; - - pub struct cat { - meows : usize, - pub how_hungry : isize, - pub name : String, - } - - impl fmt::Display for cat { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", self.name) - } - } - - impl cat { - fn meow(&mut self) { - println!("Meow"); - self.meows += 1; - if self.meows % 5 == 0 { - self.how_hungry += 1; - } - } - - } - - impl cat { - pub fn speak(&mut self) { self.meow(); } - - pub fn eat(&mut self) -> bool { - if self.how_hungry > 0 { - println!("OM NOM NOM"); - self.how_hungry -= 2; - return true; - } - else { - println!("Not hungry!"); - return false; - } - } - } - - pub fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { - cat { - meows: in_x, - how_hungry: in_y, - name: in_name - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod kitties { - pub struct cat { - meows : usize, - - pub how_hungry : isize, - } - - pub fn cat(in_x : usize, in_y : isize) -> cat { - cat { - meows: in_x, - how_hungry: in_y - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_trait.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/cci_class_trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub mod animals { - pub trait noisy { - fn speak(&mut self); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/empty-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/empty-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/empty-struct.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/empty-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct XEmpty1 {} -pub struct XEmpty2; -pub struct XEmpty7(); - -pub enum XE { - XEmpty3 {}, - XEmpty4, - XEmpty6(), -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/namespaced_enum_emulate_flat.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/namespaced_enum_emulate_flat.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/namespaced_enum_emulate_flat.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/namespaced_enum_emulate_flat.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub use Foo::*; - -pub enum Foo { - A, - B(isize), - C { a: isize }, -} - -impl Foo { - pub fn foo() {} -} - -pub mod nest { - pub use self::Bar::*; - - pub enum Bar { - D, - E(isize), - F { a: isize }, - } - - impl Bar { - pub fn foo() {} - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/namespaced_enums.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/namespaced_enums.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/namespaced_enums.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/namespaced_enums.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub enum Foo { - A, - B(isize), - C { a: isize }, -} - -impl Foo { - pub fn foo() {} - pub fn bar(&self) {} -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/newtype_struct_xc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/newtype_struct_xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/newtype_struct_xc.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/newtype_struct_xc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] - -pub struct Au(pub isize); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/struct_destructuring_cross_crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/struct_destructuring_cross_crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/struct_destructuring_cross_crate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/struct_destructuring_cross_crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] - -pub struct S { - pub x: isize, - pub y: isize, -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/struct_variant_xc_aux.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/struct_variant_xc_aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/struct_variant_xc_aux.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/struct_variant_xc_aux.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="struct_variant_xc_aux"] -#![crate_type = "lib"] - -#[derive(Copy, Clone)] -pub enum Enum { - Variant(u8), - StructVariant { arg: u8 } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/xcrate_struct_aliases.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/xcrate_struct_aliases.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/xcrate_struct_aliases.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/auxiliary/xcrate_struct_aliases.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct S { - pub x: isize, - pub y: isize, -} - -pub type S2 = S; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/borrow-tuple-fields.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/borrow-tuple-fields.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/borrow-tuple-fields.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/borrow-tuple-fields.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct Foo(isize, isize); - -fn main() { - let x = (1, 2); - let a = &x.0; - let b = &x.0; - assert_eq!(*a, 1); - assert_eq!(*b, 1); - - let mut x = (1, 2); - { - let a = &x.0; - let b = &mut x.1; - *b = 5; - assert_eq!(*a, 1); - } - assert_eq!(x.0, 1); - assert_eq!(x.1, 5); - - - let x = Foo(1, 2); - let a = &x.0; - let b = &x.0; - assert_eq!(*a, 1); - assert_eq!(*b, 1); - - let mut x = Foo(1, 2); - { - let a = &x.0; - let b = &mut x.1; - *b = 5; - assert_eq!(*a, 1); - } - assert_eq!(x.0, 1); - assert_eq!(x.1, 5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-attributes-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-attributes-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-attributes-1.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-attributes-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pp-exact - Make sure we actually print the attributes -#![feature(custom_attribute)] - -struct cat { - name: String, -} - -impl Drop for cat { - #[cat_dropper] - fn drop(&mut self) { println!("{} landed on hir feet" , self . name); } -} - - -#[cat_maker] -fn cat(name: String) -> cat { cat{name: name,} } - -pub fn main() { let _kitty = cat("Spotty".to_string()); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-attributes-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-attributes-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-attributes-2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-attributes-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -#![feature(custom_attribute)] - -struct cat { - name: String, -} - -impl Drop for cat { - #[cat_dropper] - /** - Actually, cats don't always land on their feet when you drop them. - */ - fn drop(&mut self) { - println!("{} landed on hir feet", self.name); - } -} - -#[cat_maker] -/** -Maybe it should technically be a kitten_maker. -*/ -fn cat(name: String) -> cat { - cat { - name: name - } -} - -pub fn main() { - let _kitty = cat("Spotty".to_string()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-cast-to-trait-cross-crate-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-cast-to-trait-cross-crate-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-cast-to-trait-cross-crate-2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-cast-to-trait-cross-crate-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:cci_class_cast.rs - -#![feature(box_syntax)] - -extern crate cci_class_cast; - -use std::string::ToString; -use cci_class_cast::kitty::cat; - -fn print_out(thing: Box, expected: String) { - let actual = (*thing).to_string(); - println!("{}", actual); - assert_eq!(actual.to_string(), expected); -} - -pub fn main() { - let nyan: Box = box cat(0, 2, "nyan".to_string()) as Box; - print_out(nyan, "nyan".to_string()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-cast-to-trait-multiple-types.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-cast-to-trait-multiple-types.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-cast-to-trait-multiple-types.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-cast-to-trait-multiple-types.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -trait noisy { - fn speak(&mut self) -> isize; -} - -struct dog { - barks: usize, - - volume: isize, -} - -impl dog { - fn bark(&mut self) -> isize { - println!("Woof {} {}", self.barks, self.volume); - self.barks += 1_usize; - if self.barks % 3_usize == 0_usize { - self.volume += 1; - } - if self.barks % 10_usize == 0_usize { - self.volume -= 2; - } - println!("Grrr {} {}", self.barks, self.volume); - self.volume - } -} - -impl noisy for dog { - fn speak(&mut self) -> isize { - self.bark() - } -} - -fn dog() -> dog { - dog { - volume: 0, - barks: 0_usize - } -} - -#[derive(Clone)] -struct cat { - meows: usize, - - how_hungry: isize, - name: String, -} - -impl noisy for cat { - fn speak(&mut self) -> isize { - self.meow() as isize - } -} - -impl cat { - pub fn meow_count(&self) -> usize { - self.meows - } -} - -impl cat { - fn meow(&mut self) -> usize { - println!("Meow"); - self.meows += 1_usize; - if self.meows % 5_usize == 0_usize { - self.how_hungry += 1; - } - self.meows - } -} - -fn cat(in_x: usize, in_y: isize, in_name: String) -> cat { - cat { - meows: in_x, - how_hungry: in_y, - name: in_name - } -} - - -fn annoy_neighbors(critter: &mut noisy) { - for _i in 0_usize..10 { critter.speak(); } -} - -pub fn main() { - let mut nyan: cat = cat(0_usize, 2, "nyan".to_string()); - let mut whitefang: dog = dog(); - annoy_neighbors(&mut nyan); - annoy_neighbors(&mut whitefang); - assert_eq!(nyan.meow_count(), 10_usize); - assert_eq!(whitefang.volume, 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-cast-to-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-cast-to-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-cast-to-trait.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-cast-to-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// ignore-freebsd FIXME fails on BSD - - -trait noisy { - fn speak(&mut self); -} - -struct cat { - meows: usize, - how_hungry: isize, - name: String, -} - -impl noisy for cat { - fn speak(&mut self) { self.meow(); } -} - -impl cat { - pub fn eat(&mut self) -> bool { - if self.how_hungry > 0 { - println!("OM NOM NOM"); - self.how_hungry -= 2; - return true; - } - else { - println!("Not hungry!"); - return false; - } - } -} - -impl cat { - fn meow(&mut self) { - println!("Meow"); - self.meows += 1; - if self.meows % 5 == 0 { - self.how_hungry += 1; - } - } -} - -fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { - cat { - meows: in_x, - how_hungry: in_y, - name: in_name - } -} - - -pub fn main() { - let mut nyan = cat(0, 2, "nyan".to_string()); - let mut nyan: &mut noisy = &mut nyan; - nyan.speak(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-dtor.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-dtor.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-dtor.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-dtor.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -struct cat { - done : extern fn(usize), - meows : usize, -} - -impl Drop for cat { - fn drop(&mut self) { - (self.done)(self.meows); - } -} - -fn cat(done: extern fn(usize)) -> cat { - cat { - meows: 0, - done: done - } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes-cross-crate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:cci_class_4.rs - -extern crate cci_class_4; -use cci_class_4::kitties::cat; - -pub fn main() { - let mut nyan = cat(0_usize, 2, "nyan".to_string()); - nyan.eat(); - assert!((!nyan.eat())); - for _ in 1_usize..10_usize { nyan.speak(); }; - assert!((nyan.eat())); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -struct cat { - meows : usize, - - how_hungry : isize, - name : String, -} - -impl cat { - pub fn speak(&mut self) { self.meow(); } - - pub fn eat(&mut self) -> bool { - if self.how_hungry > 0 { - println!("OM NOM NOM"); - self.how_hungry -= 2; - return true; - } else { - println!("Not hungry!"); - return false; - } - } -} - -impl cat { - fn meow(&mut self) { - println!("Meow"); - self.meows += 1_usize; - if self.meows % 5_usize == 0_usize { - self.how_hungry += 1; - } - } -} - -fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { - cat { - meows: in_x, - how_hungry: in_y, - name: in_name - } -} - -pub fn main() { - let mut nyan = cat(0_usize, 2, "nyan".to_string()); - nyan.eat(); - assert!((!nyan.eat())); - for _ in 1_usize..10_usize { nyan.speak(); }; - assert!((nyan.eat())); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes-self-referential.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes-self-referential.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes-self-referential.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes-self-referential.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - -// pretty-expanded FIXME #23616 - -struct kitten { - cat: Option, -} - -fn kitten(cat: Option) -> kitten { - kitten { - cat: cat - } -} - -type cat = Box; - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes-simple-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes-simple-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes-simple-cross-crate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes-simple-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:cci_class.rs - -extern crate cci_class; -use cci_class::kitties::cat; - -pub fn main() { - let nyan : cat = cat(52, 99); - let kitty = cat(1000, 2); - assert_eq!(nyan.how_hungry, 99); - assert_eq!(kitty.how_hungry, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes-simple-method.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes-simple-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes-simple-method.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes-simple-method.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -struct cat { - meows : usize, - - how_hungry : isize, -} - -impl cat { - pub fn speak(&mut self) {} -} - -fn cat(in_x : usize, in_y : isize) -> cat { - cat { - meows: in_x, - how_hungry: in_y - } -} - -pub fn main() { - let mut nyan : cat = cat(52, 99); - let kitty = cat(1000, 2); - assert_eq!(nyan.how_hungry, 99); - assert_eq!(kitty.how_hungry, 2); - nyan.speak(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes-simple.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes-simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes-simple.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/classes-simple.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -struct cat { - meows : usize, - - how_hungry : isize, -} - -fn cat(in_x : usize, in_y : isize) -> cat { - cat { - meows: in_x, - how_hungry: in_y - } -} - -pub fn main() { - let nyan : cat = cat(52, 99); - let kitty = cat(1000, 2); - assert_eq!(nyan.how_hungry, 99); - assert_eq!(kitty.how_hungry, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-exports.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-exports.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-exports.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-exports.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -/* Test that exporting a class also exports its - public fields and methods */ - -use kitty::cat; - -mod kitty { - pub struct cat { - meows: usize, - name: String, - } - - impl cat { - pub fn get_name(&self) -> String { self.name.clone() } - } - - pub fn cat(in_name: String) -> cat { - cat { - name: in_name, - meows: 0 - } - } -} - -pub fn main() { - assert_eq!(cat("Spreckles".to_string()).get_name(), - "Spreckles".to_string()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-implement-trait-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-implement-trait-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-implement-trait-cross-crate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-implement-trait-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// aux-build:cci_class_trait.rs -extern crate cci_class_trait; -use cci_class_trait::animals::noisy; - -struct cat { - meows: usize, - - how_hungry : isize, - name : String, -} - -impl cat { - pub fn eat(&mut self) -> bool { - if self.how_hungry > 0 { - println!("OM NOM NOM"); - self.how_hungry -= 2; - return true; - } - else { - println!("Not hungry!"); - return false; - } - } -} - -impl noisy for cat { - fn speak(&mut self) { self.meow(); } -} - -impl cat { - fn meow(&mut self) { - println!("Meow"); - self.meows += 1_usize; - if self.meows % 5_usize == 0_usize { - self.how_hungry += 1; - } - } -} - -fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { - cat { - meows: in_x, - how_hungry: in_y, - name: in_name - } -} - - -pub fn main() { - let mut nyan = cat(0_usize, 2, "nyan".to_string()); - nyan.eat(); - assert!((!nyan.eat())); - for _ in 1_usize..10_usize { nyan.speak(); }; - assert!((nyan.eat())); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-implement-traits.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-implement-traits.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-implement-traits.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-implement-traits.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -trait noisy { - fn speak(&mut self); -} - -#[derive(Clone)] -struct cat { - meows : usize, - - how_hungry : isize, - name : String, -} - -impl cat { - fn meow(&mut self) { - println!("Meow"); - self.meows += 1_usize; - if self.meows % 5_usize == 0_usize { - self.how_hungry += 1; - } - } -} - -impl cat { - pub fn eat(&mut self) -> bool { - if self.how_hungry > 0 { - println!("OM NOM NOM"); - self.how_hungry -= 2; - return true; - } else { - println!("Not hungry!"); - return false; - } - } -} - -impl noisy for cat { - fn speak(&mut self) { self.meow(); } -} - -fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { - cat { - meows: in_x, - how_hungry: in_y, - name: in_name.clone() - } -} - - -fn make_speak(mut c: C) { - c.speak(); -} - -pub fn main() { - let mut nyan = cat(0_usize, 2, "nyan".to_string()); - nyan.eat(); - assert!((!nyan.eat())); - for _ in 1_usize..10_usize { - make_speak(nyan.clone()); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-impl-very-parameterized-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-impl-very-parameterized-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-impl-very-parameterized-trait.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-impl-very-parameterized-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,116 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -use std::cmp; - -#[derive(Copy, Clone, Debug)] -enum cat_type { tuxedo, tabby, tortoiseshell } - -impl cmp::PartialEq for cat_type { - fn eq(&self, other: &cat_type) -> bool { - ((*self) as usize) == ((*other) as usize) - } - fn ne(&self, other: &cat_type) -> bool { !(*self).eq(other) } -} - -// Very silly -- this just returns the value of the name field -// for any isize value that's less than the meows field - -// ok: T should be in scope when resolving the trait ref for map -struct cat { - // Yes, you can have negative meows - meows : isize, - - how_hungry : isize, - name : T, -} - -impl cat { - pub fn speak(&mut self) { self.meow(); } - - pub fn eat(&mut self) -> bool { - if self.how_hungry > 0 { - println!("OM NOM NOM"); - self.how_hungry -= 2; - return true; - } else { - println!("Not hungry!"); - return false; - } - } - fn len(&self) -> usize { self.meows as usize } - fn is_empty(&self) -> bool { self.meows == 0 } - fn clear(&mut self) {} - fn contains_key(&self, k: &isize) -> bool { *k <= self.meows } - - fn find(&self, k: &isize) -> Option<&T> { - if *k <= self.meows { - Some(&self.name) - } else { - None - } - } - fn insert(&mut self, k: isize, _: T) -> bool { - self.meows += k; - true - } - - fn find_mut(&mut self, _k: &isize) -> Option<&mut T> { panic!() } - - fn remove(&mut self, k: &isize) -> bool { - if self.find(k).is_some() { - self.meows -= *k; true - } else { - false - } - } - - fn pop(&mut self, _k: &isize) -> Option { panic!() } - - fn swap(&mut self, _k: isize, _v: T) -> Option { panic!() } -} - -impl cat { - pub fn get(&self, k: &isize) -> &T { - match self.find(k) { - Some(v) => { v } - None => { panic!("epic fail"); } - } - } - - pub fn new(in_x: isize, in_y: isize, in_name: T) -> cat { - cat{meows: in_x, how_hungry: in_y, name: in_name } - } -} - -impl cat { - fn meow(&mut self) { - self.meows += 1; - println!("Meow {}", self.meows); - if self.meows % 5 == 0 { - self.how_hungry += 1; - } - } -} - -pub fn main() { - let mut nyan: cat = cat::new(0, 2, "nyan".to_string()); - for _ in 1_usize..5 { nyan.speak(); } - assert_eq!(*nyan.find(&1).unwrap(), "nyan".to_string()); - assert_eq!(nyan.find(&10), None); - let mut spotty: cat = cat::new(2, 57, cat_type::tuxedo); - for _ in 0_usize..6 { spotty.speak(); } - assert_eq!(spotty.len(), 8); - assert!((spotty.contains_key(&2))); - assert_eq!(spotty.get(&3), &cat_type::tuxedo); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-method-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-method-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-method-cross-crate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-method-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:cci_class_2.rs - -extern crate cci_class_2; -use cci_class_2::kitties::cat; - -pub fn main() { - let nyan : cat = cat(52, 99); - let kitty = cat(1000, 2); - assert_eq!(nyan.how_hungry, 99); - assert_eq!(kitty.how_hungry, 2); - nyan.speak(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-methods-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-methods-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-methods-cross-crate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-methods-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:cci_class_3.rs - -extern crate cci_class_3; -use cci_class_3::kitties::cat; - -pub fn main() { - let mut nyan : cat = cat(52, 99); - let kitty = cat(1000, 2); - assert_eq!(nyan.how_hungry, 99); - assert_eq!(kitty.how_hungry, 2); - nyan.speak(); - assert_eq!(nyan.meow_count(), 53); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-methods.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-methods.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-methods.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-methods.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - -struct cat { - meows : usize, - - how_hungry : isize, -} - -impl cat { - pub fn speak(&mut self) { self.meows += 1; } - pub fn meow_count(&mut self) -> usize { self.meows } -} - -fn cat(in_x: usize, in_y: isize) -> cat { - cat { - meows: in_x, - how_hungry: in_y - } -} - -pub fn main() { - let mut nyan: cat = cat(52, 99); - let kitty = cat(1000, 2); - assert_eq!(nyan.how_hungry, 99); - assert_eq!(kitty.how_hungry, 2); - nyan.speak(); - assert_eq!(nyan.meow_count(), 53); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-poly-methods-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-poly-methods-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-poly-methods-cross-crate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-poly-methods-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:cci_class_6.rs - -extern crate cci_class_6; -use cci_class_6::kitties::cat; - -pub fn main() { - let mut nyan : cat = cat::(52_usize, 99, vec!['p']); - let mut kitty = cat(1000_usize, 2, vec!["tabby".to_string()]); - assert_eq!(nyan.how_hungry, 99); - assert_eq!(kitty.how_hungry, 2); - nyan.speak(vec![1_usize,2_usize,3_usize]); - assert_eq!(nyan.meow_count(), 55_usize); - kitty.speak(vec!["meow".to_string(), "mew".to_string(), "purr".to_string(), "chirp".to_string()]); - assert_eq!(kitty.meow_count(), 1004_usize); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-poly-methods.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-poly-methods.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-poly-methods.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-poly-methods.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - -struct cat { - info : Vec , - meows : usize, - - how_hungry : isize, -} - -impl cat { - pub fn speak(&mut self, stuff: Vec ) { - self.meows += stuff.len(); - } - pub fn meow_count(&mut self) -> usize { self.meows } -} - -fn cat(in_x : usize, in_y : isize, in_info: Vec ) -> cat { - cat { - meows: in_x, - how_hungry: in_y, - info: in_info - } -} - -pub fn main() { - let mut nyan : cat = cat::(52, 99, vec![9]); - let mut kitty = cat(1000, 2, vec!["tabby".to_string()]); - assert_eq!(nyan.how_hungry, 99); - assert_eq!(kitty.how_hungry, 2); - nyan.speak(vec![1,2,3]); - assert_eq!(nyan.meow_count(), 55); - kitty.speak(vec!["meow".to_string(), "mew".to_string(), "purr".to_string(), "chirp".to_string()]); - assert_eq!(kitty.meow_count(), 1004); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-separate-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-separate-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-separate-impl.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-separate-impl.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -#![feature(box_syntax)] - -use std::fmt; - -struct cat { - meows : usize, - - how_hungry : isize, - name : String, -} - -impl cat { - pub fn speak(&mut self) { self.meow(); } - - pub fn eat(&mut self) -> bool { - if self.how_hungry > 0 { - println!("OM NOM NOM"); - self.how_hungry -= 2; - return true; - } - else { - println!("Not hungry!"); - return false; - } - } -} - -impl cat { - fn meow(&mut self) { - println!("Meow"); - self.meows += 1; - if self.meows % 5 == 0 { - self.how_hungry += 1; - } - } -} - -fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { - cat { - meows: in_x, - how_hungry: in_y, - name: in_name - } -} - -impl fmt::Display for cat { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", self.name) - } -} - -fn print_out(thing: Box, expected: String) { - let actual = (*thing).to_string(); - println!("{}", actual); - assert_eq!(actual.to_string(), expected); -} - -pub fn main() { - let nyan: Box = box cat(0, 2, "nyan".to_string()) as Box; - print_out(nyan, "nyan".to_string()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-str-field.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-str-field.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-str-field.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-str-field.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -struct cat { - - name : String, - -} - -fn cat(in_name: String) -> cat { - cat { - name: in_name - } -} - -pub fn main() { - let _nyan = cat("nyan".to_string()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-typarams.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-typarams.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-typarams.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/class-typarams.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -use std::marker::PhantomData; - -struct cat { - meows : usize, - how_hungry : isize, - m: PhantomData -} - -impl cat { - pub fn speak(&mut self) { self.meows += 1; } - pub fn meow_count(&mut self) -> usize { self.meows } -} - -fn cat(in_x : usize, in_y : isize) -> cat { - cat { - meows: in_x, - how_hungry: in_y, - m: PhantomData - } -} - - -pub fn main() { - let _nyan : cat = cat::(52, 99); - // let mut kitty = cat(1000, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/codegen-tag-static-padding.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/codegen-tag-static-padding.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/codegen-tag-static-padding.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/codegen-tag-static-padding.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -// Issue #13186 - -// For simplicity of explanations assuming code is compiled for x86_64 -// Linux ABI. - -// Size of TestOption is 16, and alignment of TestOption is 8. -// Size of u8 is 1, and alignment of u8 is 1. -// So size of Request is 24, and alignment of Request must be 8: -// the maximum alignment of its fields. -// Last 7 bytes of Request struct are not occupied by any fields. - - - -enum TestOption { - TestNone, - TestSome(T), -} - -pub struct Request { - foo: TestOption, - bar: u8, -} - -fn default_instance() -> &'static Request { - static instance: Request = Request { - // LLVM does not allow to specify alignment of expressions, thus - // alignment of `foo` in constant is 1, not 8. - foo: TestOption::TestNone, - bar: 17, - // Space after last field is not occupied by any data, but it is - // reserved to make struct aligned properly. If compiler does - // not insert padding after last field when emitting constant, - // size of struct may be not equal to size of struct, and - // compiler crashes in internal assertion check. - }; - &instance -} - -fn non_default_instance() -> &'static Request { - static instance: Request = Request { - foo: TestOption::TestSome(0x1020304050607080), - bar: 19, - }; - &instance -} - -pub fn main() { - match default_instance() { - &Request { foo: TestOption::TestNone, bar: 17 } => {}, - _ => panic!(), - }; - match non_default_instance() { - &Request { foo: TestOption::TestSome(0x1020304050607080), bar: 19 } => {}, - _ => panic!(), - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/compare-generic-enums.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/compare-generic-enums.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/compare-generic-enums.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/compare-generic-enums.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - -type an_int = isize; - -fn cmp(x: Option, y: Option) -> bool { - x == y -} - -pub fn main() { - assert!(!cmp(Some(3), None)); - assert!(!cmp(Some(3), Some(4))); - assert!(cmp(Some(3), Some(3))); - assert!(cmp(None, None)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/discrim-explicit-23030.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/discrim-explicit-23030.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/discrim-explicit-23030.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/discrim-explicit-23030.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,157 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue 23030: Workaround overflowing discriminant -// with explicit assignments. - -// See also compile-fail/overflow-discrim.rs, which shows what -// happens if you leave the OhNo explicit cases out here. - -use std::{i8,u8,i16,u16,i32,u32,i64,u64,isize,usize}; - -fn f_i8() { - #[repr(i8)] - enum A { - Ok = i8::MAX - 1, - Ok2, - OhNo = i8::MIN, - NotTheEnd = -1, - Zero, - } - - let _x = (A::Ok, A::Ok2, A::OhNo); - let z = (A::NotTheEnd, A::Zero).1 as i8; - assert_eq!(z, 0); -} - -fn f_u8() { - #[repr(u8)] - enum A { - Ok = u8::MAX - 1, - Ok2, - OhNo = u8::MIN, - } - - let _x = (A::Ok, A::Ok2, A::OhNo); -} - -fn f_i16() { - #[repr(i16)] - enum A { - Ok = i16::MAX - 1, - Ok2, - OhNo = i16::MIN, - NotTheEnd = -1, - Zero, - } - - let _x = (A::Ok, A::Ok2, A::OhNo); - let z = (A::NotTheEnd, A::Zero).1 as i16; - assert_eq!(z, 0); -} - -fn f_u16() { - #[repr(u16)] - enum A { - Ok = u16::MAX - 1, - Ok2, - OhNo = u16::MIN, - } - - let _x = (A::Ok, A::Ok2, A::OhNo); -} - -fn f_i32() { - #[repr(i32)] - enum A { - Ok = i32::MAX - 1, - Ok2, - OhNo = i32::MIN, - NotTheEnd = -1, - Zero, - } - - let _x = (A::Ok, A::Ok2, A::OhNo); - let z = (A::NotTheEnd, A::Zero).1 as i32; - assert_eq!(z, 0); -} - -fn f_u32() { - #[repr(u32)] - enum A { - Ok = u32::MAX - 1, - Ok2, - OhNo = u32::MIN, - } - - let _x = (A::Ok, A::Ok2, A::OhNo); -} - -fn f_i64() { - #[repr(i64)] - enum A { - Ok = i64::MAX - 1, - Ok2, - OhNo = i64::MIN, - NotTheEnd = -1, - Zero, - } - - let _x = (A::Ok, A::Ok2, A::OhNo); - let z = (A::NotTheEnd, A::Zero).1 as i64; - assert_eq!(z, 0); -} - -fn f_u64() { - #[repr(u64)] - enum A { - Ok = u64::MAX - 1, - Ok2, - OhNo = u64::MIN, - } - - let _x = (A::Ok, A::Ok2, A::OhNo); -} - -fn f_isize() { - #[repr(isize)] - enum A { - Ok = isize::MAX - 1, - Ok2, - OhNo = isize::MIN, - NotTheEnd = -1, - Zero, - } - - let _x = (A::Ok, A::Ok2, A::OhNo); - let z = (A::NotTheEnd, A::Zero).1 as isize; - assert_eq!(z, 0); -} - -fn f_usize() { - #[repr(usize)] - enum A { - Ok = usize::MAX - 1, - Ok2, - OhNo = usize::MIN, - } - - let _x = (A::Ok, A::Ok2, A::OhNo); -} - -fn main() { - f_i8(); f_u8(); - f_i16(); f_u16(); - f_i32(); f_u32(); - f_i64(); f_u64(); - - f_isize(); f_usize(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/empty-struct-braces.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/empty-struct-braces.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/empty-struct-braces.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/empty-struct-braces.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,222 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -// Empty struct defined with braces add names into type namespace -// Empty struct defined without braces add names into both type and value namespaces - -// aux-build:empty-struct.rs - -extern crate empty_struct; -use empty_struct::*; - -struct Empty1 {} -struct Empty2; -struct Empty7(); - -#[derive(PartialEq, Eq)] -struct Empty3 {} - -const Empty3: Empty3 = Empty3 {}; - -enum E { - Empty4 {}, - Empty5, - Empty6(), -} - -fn local() { - let e1: Empty1 = Empty1 {}; - let e2: Empty2 = Empty2 {}; - let e2: Empty2 = Empty2; - let e3: Empty3 = Empty3 {}; - let e3: Empty3 = Empty3; - let e4: E = E::Empty4 {}; - let e5: E = E::Empty5 {}; - let e5: E = E::Empty5; - let e6: E = E::Empty6 {}; - let e6: E = E::Empty6(); - let ctor6: fn() -> E = E::Empty6; - let e7: Empty7 = Empty7 {}; - let e7: Empty7 = Empty7(); - let ctor7: fn() -> Empty7 = Empty7; - - match e1 { - Empty1 {} => {} - } - match e2 { - Empty2 {} => {} - } - match e3 { - Empty3 {} => {} - } - match e4 { - E::Empty4 {} => {} - _ => {} - } - match e5 { - E::Empty5 {} => {} - _ => {} - } - match e6 { - E::Empty6 {} => {} - _ => {} - } - match e7 { - Empty7 {} => {} - } - - match e1 { - Empty1 { .. } => {} - } - match e2 { - Empty2 { .. } => {} - } - match e3 { - Empty3 { .. } => {} - } - match e4 { - E::Empty4 { .. } => {} - _ => {} - } - match e5 { - E::Empty5 { .. } => {} - _ => {} - } - match e6 { - E::Empty6 { .. } => {} - _ => {} - } - match e7 { - Empty7 { .. } => {} - } - - match e2 { - Empty2 => {} - } - match e3 { - Empty3 => {} - } - match e5 { - E::Empty5 => {} - _ => {} - } - match e6 { - E::Empty6() => {} - _ => {} - } - match e6 { - E::Empty6(..) => {} - _ => {} - } - match e7 { - Empty7() => {} - } - match e7 { - Empty7(..) => {} - } - - let e11: Empty1 = Empty1 { ..e1 }; - let e22: Empty2 = Empty2 { ..e2 }; - let e33: Empty3 = Empty3 { ..e3 }; - let e77: Empty7 = Empty7 { ..e7 }; -} - -fn xcrate() { - let e1: XEmpty1 = XEmpty1 {}; - let e2: XEmpty2 = XEmpty2 {}; - let e2: XEmpty2 = XEmpty2; - let e3: XE = XE::XEmpty3 {}; - let e4: XE = XE::XEmpty4 {}; - let e4: XE = XE::XEmpty4; - let e6: XE = XE::XEmpty6 {}; - let e6: XE = XE::XEmpty6(); - let ctor6: fn() -> XE = XE::XEmpty6; - let e7: XEmpty7 = XEmpty7 {}; - let e7: XEmpty7 = XEmpty7(); - let ctor7: fn() -> XEmpty7 = XEmpty7; - - match e1 { - XEmpty1 {} => {} - } - match e2 { - XEmpty2 {} => {} - } - match e3 { - XE::XEmpty3 {} => {} - _ => {} - } - match e4 { - XE::XEmpty4 {} => {} - _ => {} - } - match e6 { - XE::XEmpty6 {} => {} - _ => {} - } - match e7 { - XEmpty7 {} => {} - } - - match e1 { - XEmpty1 { .. } => {} - } - match e2 { - XEmpty2 { .. } => {} - } - match e3 { - XE::XEmpty3 { .. } => {} - _ => {} - } - match e4 { - XE::XEmpty4 { .. } => {} - _ => {} - } - match e6 { - XE::XEmpty6 { .. } => {} - _ => {} - } - match e7 { - XEmpty7 { .. } => {} - } - - match e2 { - XEmpty2 => {} - } - match e4 { - XE::XEmpty4 => {} - _ => {} - } - match e6 { - XE::XEmpty6() => {} - _ => {} - } - match e6 { - XE::XEmpty6(..) => {} - _ => {} - } - match e7 { - XEmpty7() => {} - } - match e7 { - XEmpty7(..) => {} - } - - let e11: XEmpty1 = XEmpty1 { ..e1 }; - let e22: XEmpty2 = XEmpty2 { ..e2 }; - let e77: XEmpty7 = XEmpty7 { ..e7 }; -} - -fn main() { - local(); - xcrate(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/empty-tag.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/empty-tag.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/empty-tag.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/empty-tag.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -#[derive(Copy, Clone, Debug)] -enum chan { chan_t, } - -impl PartialEq for chan { - fn eq(&self, other: &chan) -> bool { - ((*self) as usize) == ((*other) as usize) - } - fn ne(&self, other: &chan) -> bool { !(*self).eq(other) } -} - -fn wrapper3(i: chan) { - assert_eq!(i, chan::chan_t); -} - -pub fn main() { - let wrapped = {||wrapper3(chan::chan_t)}; - wrapped(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-alignment.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-alignment.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-alignment.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-alignment.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(deprecated)] - -use std::mem; - -fn addr_of(ptr: &T) -> usize { - ptr as *const T as usize -} - -fn is_aligned(ptr: &T) -> bool { - unsafe { - let addr: usize = mem::transmute(ptr); - (addr % mem::min_align_of::()) == 0 - } -} - -pub fn main() { - let x = Some(0u64); - match x { - None => panic!(), - Some(ref y) => assert!(is_aligned(y)) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-clike-ffi-as-int.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-clike-ffi-as-int.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-clike-ffi-as-int.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-clike-ffi-as-int.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -/*! - * C-like enums have to be represented as LLVM ints, not wrapped in a - * struct, because it's important for the FFI that they interoperate - * with C integers/enums, and the ABI can treat structs differently. - * For example, on i686-linux-gnu, a struct return value is passed by - * storing to a hidden out parameter, whereas an integer would be - * returned in a register. - * - * This test just checks that the ABIs for the enum and the plain - * integer are compatible, rather than actually calling C code. - * The unused parameter to `foo` is to increase the likelihood of - * crashing if something goes wrong here. - */ - -#[repr(u32)] -enum Foo { - A = 0, - B = 23 -} - -#[inline(never)] -extern "C" fn foo(_x: usize) -> Foo { Foo::B } - -pub fn main() { - unsafe { - let f: extern "C" fn(usize) -> u32 = - ::std::mem::transmute(foo as extern "C" fn(usize) -> Foo); - assert_eq!(f(0xDEADBEEF), Foo::B as u32); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-discrim-autosizing.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-discrim-autosizing.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-discrim-autosizing.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-discrim-autosizing.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(overflowing_literals)] - -use std::mem::size_of; - -enum Ei8 { - Ai8 = -1, - Bi8 = 0 -} - -enum Eu8 { - Au8 = 0, - Bu8 = 0x80 -} - -enum Ei16 { - Ai16 = -1, - Bi16 = 0x80 -} - -enum Eu16 { - Au16 = 0, - Bu16 = 0x8000 -} - -enum Ei32 { - Ai32 = -1, - Bi32 = 0x8000 -} - -enum Eu32 { - Au32 = 0, - Bu32 = 0x8000_0000 -} - -enum Ei64 { - Ai64 = -1, - Bi64 = 0x8000_0000 -} - -pub fn main() { - assert_eq!(size_of::(), 1); - assert_eq!(size_of::(), 1); - assert_eq!(size_of::(), 2); - assert_eq!(size_of::(), 2); - assert_eq!(size_of::(), 4); - assert_eq!(size_of::(), 4); - #[cfg(target_pointer_width = "64")] - assert_eq!(size_of::(), 8); - #[cfg(target_pointer_width = "32")] - assert_eq!(size_of::(), 4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-discrim-manual-sizing.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-discrim-manual-sizing.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-discrim-manual-sizing.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-discrim-manual-sizing.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,120 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::mem::{size_of, align_of}; - -#[repr(i8)] -enum Ei8 { - Ai8 = 0, - Bi8 = 1 -} - -#[repr(u8)] -enum Eu8 { - Au8 = 0, - Bu8 = 1 -} - -#[repr(i16)] -enum Ei16 { - Ai16 = 0, - Bi16 = 1 -} - -#[repr(u16)] -enum Eu16 { - Au16 = 0, - Bu16 = 1 -} - -#[repr(i32)] -enum Ei32 { - Ai32 = 0, - Bi32 = 1 -} - -#[repr(u32)] -enum Eu32 { - Au32 = 0, - Bu32 = 1 -} - -#[repr(i64)] -enum Ei64 { - Ai64 = 0, - Bi64 = 1 -} - -#[repr(u64)] -enum Eu64 { - Au64 = 0, - Bu64 = 1 -} - -#[repr(isize)] -enum Eint { - Aint = 0, - Bint = 1 -} - -#[repr(usize)] -enum Euint { - Auint = 0, - Buint = 1 -} - -#[repr(u8)] -enum Eu8NonCLike { - _None, - _Some(T), -} - -#[repr(i64)] -enum Ei64NonCLike { - _None, - _Some(T), -} - -#[repr(u64)] -enum Eu64NonCLike { - _None, - _Some(T), -} - -pub fn main() { - assert_eq!(size_of::(), 1); - assert_eq!(size_of::(), 1); - assert_eq!(size_of::(), 2); - assert_eq!(size_of::(), 2); - assert_eq!(size_of::(), 4); - assert_eq!(size_of::(), 4); - assert_eq!(size_of::(), 8); - assert_eq!(size_of::(), 8); - assert_eq!(size_of::(), size_of::()); - assert_eq!(size_of::(), size_of::()); - assert_eq!(size_of::>(), 1); - assert_eq!(size_of::>(), 8); - assert_eq!(size_of::>(), 8); - let u8_expected_size = round_up(9, align_of::>()); - assert_eq!(size_of::>(), u8_expected_size); - let array_expected_size = round_up(28, align_of::>()); - assert_eq!(size_of::>(), array_expected_size); - assert_eq!(size_of::>(), 32); - - assert_eq!(align_of::(), align_of::()); - assert_eq!(align_of::>(), align_of::()); -} - -// Rounds x up to the next multiple of a -fn round_up(x: usize, a: usize) -> usize { - ((x + (a - 1)) / a) * a -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-discrim-range-overflow.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-discrim-range-overflow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-discrim-range-overflow.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-discrim-range-overflow.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(overflowing_literals)] - -// pretty-expanded FIXME #23616 - -pub enum E64 { - H64 = 0x7FFF_FFFF_FFFF_FFFF, - L64 = 0x8000_0000_0000_0000 -} -pub enum E32 { - H32 = 0x7FFF_FFFF, - L32 = 0x8000_0000 -} - -pub fn f(e64: E64, e32: E32) -> (bool,bool) { - (match e64 { - E64::H64 => true, - E64::L64 => false - }, - match e32 { - E32::H32 => true, - E32::L32 => false - }) -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-discrim-width-stuff.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-discrim-width-stuff.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-discrim-width-stuff.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-discrim-width-stuff.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(overflowing_literals)] -#![allow(dead_code)] - -macro_rules! check { - ($m:ident, $t:ty, $v:expr) => {{ - mod $m { - use std::mem::size_of; - #[derive(Copy, Clone, Debug)] - enum E { - V = $v, - A = 0 - } - static C: E = E::V; - pub fn check() { - assert_eq!(size_of::(), size_of::<$t>()); - assert_eq!(E::V as $t, $v as $t); - assert_eq!(C as $t, $v as $t); - assert_eq!(format!("{:?}", E::V), "V".to_string()); - assert_eq!(format!("{:?}", C), "V".to_string()); - } - } - $m::check(); - }} -} - -pub fn main() { - check!(a, u8, 0x17); - check!(b, u8, 0xe8); - check!(c, u16, 0x1727); - check!(d, u16, 0xe8d8); - check!(e, u32, 0x17273747); - check!(f, u32, 0xe8d8c8b8); - - check!(z, i8, 0x17); - check!(y, i8, -0x17); - check!(x, i16, 0x1727); - check!(w, i16, -0x1727); - check!(v, i32, 0x17273747); - check!(u, i32, -0x17273747); - - enum Simple { A, B } - assert_eq!(::std::mem::size_of::(), 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-discr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-discr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-discr.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-discr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -enum Animal { - Cat = 0, - Dog = 1, - Horse = 2, - Snake = 3, -} - -enum Hero { - Batman = -1, - Superman = -2, - Ironman = -3, - Spiderman = -4 -} - -pub fn main() { - let pet: Animal = Animal::Snake; - let hero: Hero = Hero::Superman; - assert_eq!(pet as usize, 3); - assert_eq!(hero as isize, -2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-disr-val-pretty.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-disr-val-pretty.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-disr-val-pretty.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-disr-val-pretty.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -// pp-exact - - -enum color { red = 1, green, blue, imaginary = -1, } - -pub fn main() { - test_color(color::red, 1, "red".to_string()); - test_color(color::green, 2, "green".to_string()); - test_color(color::blue, 3, "blue".to_string()); - test_color(color::imaginary, -1, "imaginary".to_string()); -} - -fn test_color(color: color, val: isize, _name: String) { - assert_eq!(color as isize , val); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-export-inheritance.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-export-inheritance.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-export-inheritance.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-export-inheritance.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -mod a { - pub enum Foo { - Bar, - Baz, - Boo - } -} - -pub fn main() { - let _x = a::Foo::Bar; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-layout-optimization.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-layout-optimization.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-layout-optimization.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-layout-optimization.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we will do various size optimizations to enum layout, but -// *not* if `#[repr(u8)]` or `#[repr(C)]` is passed. See also #40029. - -#![allow(dead_code)] - -use std::mem; - -enum Nullable { - Alive(T), - Dropped, -} - -#[repr(u8)] -enum NullableU8 { - Alive(T), - Dropped, -} - -#[repr(C)] -enum NullableC { - Alive(T), - Dropped, -} - -struct StructNewtype(T); - -#[repr(C)] -struct StructNewtypeC(T); - -enum EnumNewtype { Variant(T) } - -#[repr(u8)] -enum EnumNewtypeU8 { Variant(T) } - -#[repr(C)] -enum EnumNewtypeC { Variant(T) } - -fn main() { - assert!(mem::size_of::>() == mem::size_of::>>()); - assert!(mem::size_of::>() < mem::size_of::>>()); - assert!(mem::size_of::>() < mem::size_of::>>()); - - assert!(mem::size_of::() == mem::size_of::>()); - assert!(mem::size_of::() == mem::size_of::>()); - - assert!(mem::size_of::() == mem::size_of::>()); - assert!(mem::size_of::() < mem::size_of::>()); - assert!(mem::size_of::() < mem::size_of::>()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-non-c-like-repr-c-and-int.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-non-c-like-repr-c-and-int.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-non-c-like-repr-c-and-int.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-non-c-like-repr-c-and-int.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,178 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This test deserializes an enum in-place by transmuting to a union that -// should have the same layout, and manipulating the tag and payloads -// independently. This verifies that `repr(some_int)` has a stable representation, -// and that we don't miscompile these kinds of manipulations. - -use std::time::Duration; -use std::mem; - -#[repr(C, u8)] -#[derive(Copy, Clone, Eq, PartialEq, Debug)] -enum MyEnum { - A(u32), // Single primitive value - B { x: u8, y: i16 }, // Composite, and the offset of `y` depends on tag being internal - C, // Empty - D(Option), // Contains an enum - E(Duration), // Contains a struct -} - -#[repr(C)] -struct MyEnumRepr { - tag: MyEnumTag, - payload: MyEnumPayload, -} - -#[repr(C)] -#[allow(non_snake_case)] -union MyEnumPayload { - A: MyEnumVariantA, - B: MyEnumVariantB, - D: MyEnumVariantD, - E: MyEnumVariantE, -} - -#[repr(u8)] #[derive(Copy, Clone)] enum MyEnumTag { A, B, C, D, E } -#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantA(u32); -#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantB {x: u8, y: i16 } -#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantD(Option); -#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantE(Duration); - -fn main() { - let result: Vec> = vec![ - Ok(MyEnum::A(17)), - Ok(MyEnum::B { x: 206, y: 1145 }), - Ok(MyEnum::C), - Err(()), - Ok(MyEnum::D(Some(407))), - Ok(MyEnum::D(None)), - Ok(MyEnum::E(Duration::from_secs(100))), - Err(()), - ]; - - // Binary serialized version of the above (little-endian) - let input: Vec = vec![ - 0, 17, 0, 0, 0, - 1, 206, 121, 4, - 2, - 8, /* invalid tag value */ - 3, 0, 151, 1, 0, 0, - 3, 1, - 4, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, /* incomplete value */ - ]; - - let mut output = vec![]; - let mut buf = &input[..]; - - unsafe { - // This should be safe, because we don't match on it unless it's fully formed, - // and it doesn't have a destructor. - let mut dest: MyEnum = mem::uninitialized(); - while buf.len() > 0 { - match parse_my_enum(&mut dest, &mut buf) { - Ok(()) => output.push(Ok(dest)), - Err(()) => output.push(Err(())), - } - } - } - - assert_eq!(output, result); -} - -fn parse_my_enum<'a>(dest: &'a mut MyEnum, buf: &mut &[u8]) -> Result<(), ()> { - unsafe { - // Should be correct to do this transmute. - let dest: &'a mut MyEnumRepr = mem::transmute(dest); - let tag = read_u8(buf)?; - - dest.tag = match tag { - 0 => MyEnumTag::A, - 1 => MyEnumTag::B, - 2 => MyEnumTag::C, - 3 => MyEnumTag::D, - 4 => MyEnumTag::E, - _ => return Err(()), - }; - - match dest.tag { - MyEnumTag::A => { - dest.payload.A.0 = read_u32_le(buf)?; - } - MyEnumTag::B => { - dest.payload.B.x = read_u8(buf)?; - dest.payload.B.y = read_u16_le(buf)? as i16; - } - MyEnumTag::C => { - /* do nothing */ - } - MyEnumTag::D => { - let is_some = read_u8(buf)? == 0; - if is_some { - dest.payload.D.0 = Some(read_u32_le(buf)?); - } else { - dest.payload.D.0 = None; - } - } - MyEnumTag::E => { - let secs = read_u64_le(buf)?; - let nanos = read_u32_le(buf)?; - dest.payload.E.0 = Duration::new(secs, nanos); - } - } - Ok(()) - } -} - - - -// reader helpers - -fn read_u64_le(buf: &mut &[u8]) -> Result { - if buf.len() < 8 { return Err(()) } - let val = (buf[0] as u64) << 0 - | (buf[1] as u64) << 8 - | (buf[2] as u64) << 16 - | (buf[3] as u64) << 24 - | (buf[4] as u64) << 32 - | (buf[5] as u64) << 40 - | (buf[6] as u64) << 48 - | (buf[7] as u64) << 56; - *buf = &buf[8..]; - Ok(val) -} - -fn read_u32_le(buf: &mut &[u8]) -> Result { - if buf.len() < 4 { return Err(()) } - let val = (buf[0] as u32) << 0 - | (buf[1] as u32) << 8 - | (buf[2] as u32) << 16 - | (buf[3] as u32) << 24; - *buf = &buf[4..]; - Ok(val) -} - -fn read_u16_le(buf: &mut &[u8]) -> Result { - if buf.len() < 2 { return Err(()) } - let val = (buf[0] as u16) << 0 - | (buf[1] as u16) << 8; - *buf = &buf[2..]; - Ok(val) -} - -fn read_u8(buf: &mut &[u8]) -> Result { - if buf.len() < 1 { return Err(()) } - let val = buf[0]; - *buf = &buf[1..]; - Ok(val) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-non-c-like-repr-c.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-non-c-like-repr-c.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-non-c-like-repr-c.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-non-c-like-repr-c.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,178 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This test deserializes an enum in-place by transmuting to a union that -// should have the same layout, and manipulating the tag and payloads -// independently. This verifies that `repr(some_int)` has a stable representation, -// and that we don't miscompile these kinds of manipulations. - -use std::time::Duration; -use std::mem; - -#[repr(C)] -#[derive(Copy, Clone, Eq, PartialEq, Debug)] -enum MyEnum { - A(u32), // Single primitive value - B { x: u8, y: i16 }, // Composite, and the offset of `y` depends on tag being internal - C, // Empty - D(Option), // Contains an enum - E(Duration), // Contains a struct -} - -#[repr(C)] -struct MyEnumRepr { - tag: MyEnumTag, - payload: MyEnumPayload, -} - -#[repr(C)] -#[allow(non_snake_case)] -union MyEnumPayload { - A: MyEnumVariantA, - B: MyEnumVariantB, - D: MyEnumVariantD, - E: MyEnumVariantE, -} - -#[repr(C)] #[derive(Copy, Clone)] enum MyEnumTag { A, B, C, D, E } -#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantA(u32); -#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantB {x: u8, y: i16 } -#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantD(Option); -#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantE(Duration); - -fn main() { - let result: Vec> = vec![ - Ok(MyEnum::A(17)), - Ok(MyEnum::B { x: 206, y: 1145 }), - Ok(MyEnum::C), - Err(()), - Ok(MyEnum::D(Some(407))), - Ok(MyEnum::D(None)), - Ok(MyEnum::E(Duration::from_secs(100))), - Err(()), - ]; - - // Binary serialized version of the above (little-endian) - let input: Vec = vec![ - 0, 17, 0, 0, 0, - 1, 206, 121, 4, - 2, - 8, /* invalid tag value */ - 3, 0, 151, 1, 0, 0, - 3, 1, - 4, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, /* incomplete value */ - ]; - - let mut output = vec![]; - let mut buf = &input[..]; - - unsafe { - // This should be safe, because we don't match on it unless it's fully formed, - // and it doesn't have a destructor. - let mut dest: MyEnum = mem::uninitialized(); - while buf.len() > 0 { - match parse_my_enum(&mut dest, &mut buf) { - Ok(()) => output.push(Ok(dest)), - Err(()) => output.push(Err(())), - } - } - } - - assert_eq!(output, result); -} - -fn parse_my_enum<'a>(dest: &'a mut MyEnum, buf: &mut &[u8]) -> Result<(), ()> { - unsafe { - // Should be correct to do this transmute. - let dest: &'a mut MyEnumRepr = mem::transmute(dest); - let tag = read_u8(buf)?; - - dest.tag = match tag { - 0 => MyEnumTag::A, - 1 => MyEnumTag::B, - 2 => MyEnumTag::C, - 3 => MyEnumTag::D, - 4 => MyEnumTag::E, - _ => return Err(()), - }; - - match dest.tag { - MyEnumTag::A => { - dest.payload.A.0 = read_u32_le(buf)?; - } - MyEnumTag::B => { - dest.payload.B.x = read_u8(buf)?; - dest.payload.B.y = read_u16_le(buf)? as i16; - } - MyEnumTag::C => { - /* do nothing */ - } - MyEnumTag::D => { - let is_some = read_u8(buf)? == 0; - if is_some { - dest.payload.D.0 = Some(read_u32_le(buf)?); - } else { - dest.payload.D.0 = None; - } - } - MyEnumTag::E => { - let secs = read_u64_le(buf)?; - let nanos = read_u32_le(buf)?; - dest.payload.E.0 = Duration::new(secs, nanos); - } - } - Ok(()) - } -} - - - -// reader helpers - -fn read_u64_le(buf: &mut &[u8]) -> Result { - if buf.len() < 8 { return Err(()) } - let val = (buf[0] as u64) << 0 - | (buf[1] as u64) << 8 - | (buf[2] as u64) << 16 - | (buf[3] as u64) << 24 - | (buf[4] as u64) << 32 - | (buf[5] as u64) << 40 - | (buf[6] as u64) << 48 - | (buf[7] as u64) << 56; - *buf = &buf[8..]; - Ok(val) -} - -fn read_u32_le(buf: &mut &[u8]) -> Result { - if buf.len() < 4 { return Err(()) } - let val = (buf[0] as u32) << 0 - | (buf[1] as u32) << 8 - | (buf[2] as u32) << 16 - | (buf[3] as u32) << 24; - *buf = &buf[4..]; - Ok(val) -} - -fn read_u16_le(buf: &mut &[u8]) -> Result { - if buf.len() < 2 { return Err(()) } - let val = (buf[0] as u16) << 0 - | (buf[1] as u16) << 8; - *buf = &buf[2..]; - Ok(val) -} - -fn read_u8(buf: &mut &[u8]) -> Result { - if buf.len() < 1 { return Err(()) } - let val = buf[0]; - *buf = &buf[1..]; - Ok(val) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-non-c-like-repr-int.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-non-c-like-repr-int.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-non-c-like-repr-int.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-non-c-like-repr-int.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,174 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// This test deserializes an enum in-place by transmuting to a union that -// should have the same layout, and manipulating the tag and payloads -// independently. This verifies that `repr(some_int)` has a stable representation, -// and that we don't miscompile these kinds of manipulations. - -use std::time::Duration; -use std::mem; - -#[repr(u8)] -#[derive(Copy, Clone, Eq, PartialEq, Debug)] -enum MyEnum { - A(u32), // Single primitive value - B { x: u8, y: i16 }, // Composite, and the offset of `y` depends on tag being internal - C, // Empty - D(Option), // Contains an enum - E(Duration), // Contains a struct -} - -#[allow(non_snake_case)] -#[repr(C)] -union MyEnumRepr { - A: MyEnumVariantA, - B: MyEnumVariantB, - C: MyEnumVariantC, - D: MyEnumVariantD, - E: MyEnumVariantE, -} - -#[repr(u8)] #[derive(Copy, Clone)] enum MyEnumTag { A, B, C, D, E } -#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantA(MyEnumTag, u32); -#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantB { tag: MyEnumTag, x: u8, y: i16 } -#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantC(MyEnumTag); -#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantD(MyEnumTag, Option); -#[repr(C)] #[derive(Copy, Clone)] struct MyEnumVariantE(MyEnumTag, Duration); - -fn main() { - let result: Vec> = vec![ - Ok(MyEnum::A(17)), - Ok(MyEnum::B { x: 206, y: 1145 }), - Ok(MyEnum::C), - Err(()), - Ok(MyEnum::D(Some(407))), - Ok(MyEnum::D(None)), - Ok(MyEnum::E(Duration::from_secs(100))), - Err(()), - ]; - - // Binary serialized version of the above (little-endian) - let input: Vec = vec![ - 0, 17, 0, 0, 0, - 1, 206, 121, 4, - 2, - 8, /* invalid tag value */ - 3, 0, 151, 1, 0, 0, - 3, 1, - 4, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, /* incomplete value */ - ]; - - let mut output = vec![]; - let mut buf = &input[..]; - - unsafe { - // This should be safe, because we don't match on it unless it's fully formed, - // and it doesn't have a destructor. - let mut dest: MyEnum = mem::uninitialized(); - while buf.len() > 0 { - match parse_my_enum(&mut dest, &mut buf) { - Ok(()) => output.push(Ok(dest)), - Err(()) => output.push(Err(())), - } - } - } - - assert_eq!(output, result); -} - -fn parse_my_enum<'a>(dest: &'a mut MyEnum, buf: &mut &[u8]) -> Result<(), ()> { - unsafe { - // Should be correct to do this transmute. - let dest: &'a mut MyEnumRepr = mem::transmute(dest); - let tag = read_u8(buf)?; - - dest.A.0 = match tag { - 0 => MyEnumTag::A, - 1 => MyEnumTag::B, - 2 => MyEnumTag::C, - 3 => MyEnumTag::D, - 4 => MyEnumTag::E, - _ => return Err(()), - }; - - match dest.B.tag { - MyEnumTag::A => { - dest.A.1 = read_u32_le(buf)?; - } - MyEnumTag::B => { - dest.B.x = read_u8(buf)?; - dest.B.y = read_u16_le(buf)? as i16; - } - MyEnumTag::C => { - /* do nothing */ - } - MyEnumTag::D => { - let is_some = read_u8(buf)? == 0; - if is_some { - dest.D.1 = Some(read_u32_le(buf)?); - } else { - dest.D.1 = None; - } - } - MyEnumTag::E => { - let secs = read_u64_le(buf)?; - let nanos = read_u32_le(buf)?; - dest.E.1 = Duration::new(secs, nanos); - } - } - Ok(()) - } -} - - - -// reader helpers - -fn read_u64_le(buf: &mut &[u8]) -> Result { - if buf.len() < 8 { return Err(()) } - let val = (buf[0] as u64) << 0 - | (buf[1] as u64) << 8 - | (buf[2] as u64) << 16 - | (buf[3] as u64) << 24 - | (buf[4] as u64) << 32 - | (buf[5] as u64) << 40 - | (buf[6] as u64) << 48 - | (buf[7] as u64) << 56; - *buf = &buf[8..]; - Ok(val) -} - -fn read_u32_le(buf: &mut &[u8]) -> Result { - if buf.len() < 4 { return Err(()) } - let val = (buf[0] as u32) << 0 - | (buf[1] as u32) << 8 - | (buf[2] as u32) << 16 - | (buf[3] as u32) << 24; - *buf = &buf[4..]; - Ok(val) -} - -fn read_u16_le(buf: &mut &[u8]) -> Result { - if buf.len() < 2 { return Err(()) } - let val = (buf[0] as u16) << 0 - | (buf[1] as u16) << 8; - *buf = &buf[2..]; - Ok(val) -} - -fn read_u8(buf: &mut &[u8]) -> Result { - if buf.len() < 1 { return Err(()) } - let val = buf[0]; - *buf = &buf[1..]; - Ok(val) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-nullable-const-null-with-fields.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-nullable-const-null-with-fields.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-nullable-const-null-with-fields.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-nullable-const-null-with-fields.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::result::Result; -use std::result::Result::Ok; - -static C: Result<(), Box> = Ok(()); - -// This is because of yet another bad assertion (ICE) about the null side of a nullable enum. -// So we won't actually compile if the bug is present, but we check the value in main anyway. - -pub fn main() { - assert!(C.is_ok()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-nullable-simplifycfg-misopt.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-nullable-simplifycfg-misopt.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-nullable-simplifycfg-misopt.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-nullable-simplifycfg-misopt.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -/*! - * This is a regression test for a bug in LLVM, fixed in upstream r179587, - * where the switch instructions generated for destructuring enums - * represented with nullable pointers could be misoptimized in some cases. - */ - -enum List { Nil, Cons(X, Box>) } -pub fn main() { - match List::Cons(10, box List::Nil) { - List::Cons(10, _) => {} - List::Nil => {} - _ => panic!() - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-null-pointer-opt.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-null-pointer-opt.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-null-pointer-opt.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-null-pointer-opt.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::mem::size_of; -use std::num::NonZeroUsize; -use std::ptr::NonNull; -use std::rc::Rc; -use std::sync::Arc; - -trait Trait { fn dummy(&self) { } } -trait Mirror { type Image; } -impl Mirror for T { type Image = T; } -struct ParamTypeStruct(T); -struct AssocTypeStruct(::Image); - -fn main() { - // Functions - assert_eq!(size_of::(), size_of::>()); - assert_eq!(size_of::(), size_of::>()); - - // Slices - &str / &[T] / &mut [T] - assert_eq!(size_of::<&str>(), size_of::>()); - assert_eq!(size_of::<&[isize]>(), size_of::>()); - assert_eq!(size_of::<&mut [isize]>(), size_of::>()); - - // Traits - Box / &Trait / &mut Trait - assert_eq!(size_of::>(), size_of::>>()); - assert_eq!(size_of::<&Trait>(), size_of::>()); - assert_eq!(size_of::<&mut Trait>(), size_of::>()); - - // Pointers - Box - assert_eq!(size_of::>(), size_of::>>()); - - // The optimization can't apply to raw pointers - assert!(size_of::>() != size_of::<*const isize>()); - assert!(Some(0 as *const isize).is_some()); // Can't collapse None to null - - struct Foo { - _a: Box - } - struct Bar(Box); - - // Should apply through structs - assert_eq!(size_of::(), size_of::>()); - assert_eq!(size_of::(), size_of::>()); - // and tuples - assert_eq!(size_of::<(u8, Box)>(), size_of::)>>()); - // and fixed-size arrays - assert_eq!(size_of::<[Box; 1]>(), size_of::; 1]>>()); - - // Should apply to NonZero - assert_eq!(size_of::(), size_of::>()); - assert_eq!(size_of::>(), size_of::>>()); - - // Should apply to types that use NonZero internally - assert_eq!(size_of::>(), size_of::>>()); - assert_eq!(size_of::>(), size_of::>>()); - assert_eq!(size_of::>(), size_of::>>()); - - // Should apply to types that have NonZero transitively - assert_eq!(size_of::(), size_of::>()); - - // Should apply to types where the pointer is substituted - assert_eq!(size_of::<&u8>(), size_of::>>()); - assert_eq!(size_of::<&u8>(), size_of::>>()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-univariant-repr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-univariant-repr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-univariant-repr.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-univariant-repr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::mem; - -// Univariant C-like enum -#[repr(i32)] -enum Univariant { - X = 17 -} - -#[repr(u16)] -enum UnivariantWithoutDescr { - Y -} - -#[repr(u8)] -enum UnivariantWithData { - Z(u8), -} - -pub fn main() { - { - assert_eq!(4, mem::size_of::()); - assert_eq!(17, Univariant::X as i32); - - let enums: &[Univariant] = - &[Univariant::X, Univariant::X, Univariant::X]; - let ints: &[i32] = unsafe { mem::transmute(enums) }; - // check it has the same memory layout as i32 - assert_eq!(&[17, 17, 17], ints); - } - - { - assert_eq!(2, mem::size_of::()); - let descr = UnivariantWithoutDescr::Y as u16; - - let enums: &[UnivariantWithoutDescr] = - &[UnivariantWithoutDescr::Y, UnivariantWithoutDescr::Y, UnivariantWithoutDescr::Y]; - let ints: &[u16] = unsafe { mem::transmute(enums) }; - // check it has the same memory layout as u16 - assert_eq!(&[descr, descr, descr], ints); - } - - { - assert_eq!(2, mem::size_of::()); - - match UnivariantWithData::Z(4) { - UnivariantWithData::Z(x) => assert_eq!(x, 4), - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-variants.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-variants.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-variants.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-variants.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![allow(unused_variables)] - -enum Animal { - Dog (String, f64), - Cat { name: String, weight: f64 } -} - -pub fn main() { - let mut a: Animal = Animal::Dog("Cocoa".to_string(), 37.2); - a = Animal::Cat{ name: "Spotty".to_string(), weight: 2.7 }; - // permuting the fields should work too - let _c = Animal::Cat { weight: 3.1, name: "Spreckles".to_string() }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-vec-initializer.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-vec-initializer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-vec-initializer.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/enum-vec-initializer.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -enum Flopsy { - Bunny = 2 -} - -const BAR:usize = Flopsy::Bunny as usize; -const BAR2:usize = BAR; - -pub fn main() { - let _v = [0; Flopsy::Bunny as usize]; - let _v = [0; BAR]; - let _v = [0; BAR2]; - const BAR3:usize = BAR2; - let _v = [0; BAR3]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/export-abstract-tag.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/export-abstract-tag.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/export-abstract-tag.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/export-abstract-tag.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// We can export tags without exporting the variants to create a simple -// sort of ADT. - -// pretty-expanded FIXME #23616 - -mod foo { - pub enum t { t1, } - - pub fn f() -> t { return t::t1; } -} - -pub fn main() { let _v: foo::t = foo::f(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/export-tag-variant.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/export-tag-variant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/export-tag-variant.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/export-tag-variant.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -// pretty-expanded FIXME #23616 - -mod foo { - pub enum t { t1, } -} - -pub fn main() { let _v = foo::t::t1; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/expr-if-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/expr-if-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/expr-if-struct.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/expr-if-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - - - -// Tests for if as expressions returning nominal types - -#[derive(Copy, Clone)] -struct I { i: isize } - -fn test_rec() { - let rs = if true { I {i: 100} } else { I {i: 101} }; - assert_eq!(rs.i, 100); -} - -#[derive(Copy, Clone, Debug)] -enum mood { happy, sad, } - -impl PartialEq for mood { - fn eq(&self, other: &mood) -> bool { - ((*self) as usize) == ((*other) as usize) - } - fn ne(&self, other: &mood) -> bool { !(*self).eq(other) } -} - -fn test_tag() { - let rs = if true { mood::happy } else { mood::sad }; - assert_eq!(rs, mood::happy); -} - -pub fn main() { test_rec(); test_tag(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/expr-match-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/expr-match-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/expr-match-struct.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/expr-match-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - - - -// Tests for match as expressions resulting in struct types -#[derive(Copy, Clone)] -struct R { i: isize } - -fn test_rec() { - let rs = match true { true => R {i: 100}, _ => panic!() }; - assert_eq!(rs.i, 100); -} - -#[derive(Copy, Clone, Debug)] -enum mood { happy, sad, } - -impl PartialEq for mood { - fn eq(&self, other: &mood) -> bool { - ((*self) as usize) == ((*other) as usize) - } - fn ne(&self, other: &mood) -> bool { !(*self).eq(other) } -} - -fn test_tag() { - let rs = match true { true => { mood::happy } false => { mood::sad } }; - assert_eq!(rs, mood::happy); -} - -pub fn main() { test_rec(); test_tag(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/field-destruction-order.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/field-destruction-order.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/field-destruction-order.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/field-destruction-order.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -// In theory, it doesn't matter what order destructors are run in for rust -// because we have explicit ownership of values meaning that there's no need to -// run one before another. With unsafe code, however, there may be a safe -// interface which relies on fields having their destructors run in a particular -// order. At the time of this writing, std::rt::sched::Scheduler is an example -// of a structure which contains unsafe handles to FFI-like types, and the -// destruction order of the fields matters in the sense that some handles need -// to get destroyed before others. -// -// In C++, destruction order happens bottom-to-top in order of field -// declarations, but we currently run them top-to-bottom. I don't think the -// order really matters that much as long as we define what it is. - - -struct A; -struct B; -struct C { - a: A, - b: B, -} - -static mut hit: bool = false; - -impl Drop for A { - fn drop(&mut self) { - unsafe { - assert!(!hit); - hit = true; - } - } -} - -impl Drop for B { - fn drop(&mut self) { - unsafe { - assert!(hit); - } - } -} - -pub fn main() { - let _c = C { a: A, b: B }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/foreign-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/foreign-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/foreign-struct.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/foreign-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// Passing enums by value - -// pretty-expanded FIXME #23616 - -pub enum void { } - -mod bindgen { - use super::void; - - extern { - pub fn printf(v: void); - } -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/functional-struct-upd.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/functional-struct-upd.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/functional-struct-upd.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/functional-struct-upd.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Debug)] -struct Foo { - x: isize, - y: isize -} - -pub fn main() { - let a = Foo { x: 1, y: 2 }; - let c = Foo { x: 4, .. a}; - println!("{:?}", c); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/ivec-tag.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/ivec-tag.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/ivec-tag.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/ivec-tag.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::thread; -use std::sync::mpsc::{channel, Sender}; - -fn producer(tx: &Sender>) { - tx.send( - vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, - 13]).unwrap(); -} - -pub fn main() { - let (tx, rx) = channel::>(); - let prod = thread::spawn(move|| { - producer(&tx) - }); - - let _data: Vec = rx.recv().unwrap(); - prod.join(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/module-qualified-struct-destructure.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/module-qualified-struct-destructure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/module-qualified-struct-destructure.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/module-qualified-struct-destructure.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -mod m { - pub struct S { - pub x: isize, - pub y: isize - } -} - -pub fn main() { - let x = m::S { x: 1, y: 2 }; - let m::S { x: _a, y: _b } = x; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enum-emulate-flat.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enum-emulate-flat.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enum-emulate-flat.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enum-emulate-flat.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub use Foo::*; -use nest::{Bar, D, E, F}; - -pub enum Foo { - A, - B(isize), - C { a: isize }, -} - -impl Foo { - pub fn foo() {} -} - -fn _f(f: Foo) { - match f { - A | B(_) | C { .. } => {} - } -} - -mod nest { - pub use self::Bar::*; - - pub enum Bar { - D, - E(isize), - F { a: isize }, - } - - impl Bar { - pub fn foo() {} - } -} - -fn _f2(f: Bar) { - match f { - D | E(_) | F { .. } => {} - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enum-emulate-flat-xc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enum-emulate-flat-xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enum-emulate-flat-xc.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enum-emulate-flat-xc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// aux-build:namespaced_enum_emulate_flat.rs - -// pretty-expanded FIXME #23616 - -extern crate namespaced_enum_emulate_flat; - -use namespaced_enum_emulate_flat::{Foo, A, B, C}; -use namespaced_enum_emulate_flat::nest::{Bar, D, E, F}; - -fn _f(f: Foo) { - match f { - A | B(_) | C { .. } => {} - } -} - -fn _f2(f: Bar) { - match f { - D | E(_) | F { .. } => {} - } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enum-glob-import.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enum-glob-import.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enum-glob-import.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enum-glob-import.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -mod m2 { - pub enum Foo { - A, - B(isize), - C { a: isize }, - } - - impl Foo { - pub fn foo() {} - } -} - -mod m { - pub use m2::Foo::*; -} - -fn _f(f: m2::Foo) { - use m2::Foo::*; - - match f { - A | B(_) | C { .. } => {} - } -} - -fn _f2(f: m2::Foo) { - match f { - m::A | m::B(_) | m::C { .. } => {} - } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enum-glob-import-xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enum-glob-import-xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enum-glob-import-xcrate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enum-glob-import-xcrate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:namespaced_enums.rs - -// pretty-expanded FIXME #23616 - -extern crate namespaced_enums; - -fn _f(f: namespaced_enums::Foo) { - use namespaced_enums::Foo::*; - - match f { - A | B(_) | C { .. } => {} - } -} - -mod m { - pub use namespaced_enums::Foo::*; -} - -fn _f2(f: namespaced_enums::Foo) { - match f { - m::A | m::B(_) | m::C { .. } => {} - } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enums.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enums.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enums.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enums.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -enum Foo { - A, - B(isize), - C { a: isize }, -} - -fn _foo (f: Foo) { - match f { - Foo::A | Foo::B(_) | Foo::C { .. } => {} - } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enums-xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enums-xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enums-xcrate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/namespaced-enums-xcrate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:namespaced_enums.rs - -// pretty-expanded FIXME #23616 - -extern crate namespaced_enums; - -use namespaced_enums::Foo; - -fn _foo (f: Foo) { - match f { - Foo::A | Foo::B(_) | Foo::C { .. } => {} - } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/nested-enum-same-names.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/nested-enum-same-names.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/nested-enum-same-names.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/nested-enum-same-names.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -/* - -#7770 ICE with sibling methods containing same-name-enum containing - same-name-member - -If you have two methods in an impl block, each containing an enum -(with the same name), each containing at least one value with the same -name, rustc gives the same LLVM symbol for the two of them and fails, -as it does not include the method name in the symbol name. - -*/ - -pub struct Foo; -impl Foo { - pub fn foo() { - enum Panic { Common }; - } - pub fn bar() { - enum Panic { Common }; - } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/newtype-struct-drop-run.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/newtype-struct-drop-run.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/newtype-struct-drop-run.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/newtype-struct-drop-run.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Make sure the destructor is run for newtype structs. - -use std::cell::Cell; - -struct Foo<'a>(&'a Cell); - -impl<'a> Drop for Foo<'a> { - fn drop(&mut self) { - let Foo(i) = *self; - i.set(23); - } -} - -pub fn main() { - let y = &Cell::new(32); - { - let _x = Foo(y); - } - assert_eq!(y.get(), 23); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/newtype-struct-with-dtor.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/newtype-struct-with-dtor.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/newtype-struct-with-dtor.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/newtype-struct-with-dtor.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub struct Fd(u32); - -fn foo(a: u32) {} - -impl Drop for Fd { - fn drop(&mut self) { - unsafe { - let Fd(s) = *self; - foo(s); - } - } -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/newtype-struct-xc-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/newtype-struct-xc-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/newtype-struct-xc-2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/newtype-struct-xc-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:newtype_struct_xc.rs - -// pretty-expanded FIXME #23616 - -extern crate newtype_struct_xc; -use newtype_struct_xc::Au; - -fn f() -> Au { - Au(2) -} - -pub fn main() { - let _ = f(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/newtype-struct-xc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/newtype-struct-xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/newtype-struct-xc.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/newtype-struct-xc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:newtype_struct_xc.rs - -// pretty-expanded FIXME #23616 - -extern crate newtype_struct_xc; - -pub fn main() { - let _ = newtype_struct_xc::Au(2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/nonzero-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/nonzero-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/nonzero-enum.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/nonzero-enum.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::mem::size_of; - -enum E { - A = 1, - B = 2, - C = 3, -} - -struct S { - a: u16, - b: u8, - e: E, -} - -fn main() { - assert_eq!(size_of::(), 1); - assert_eq!(size_of::>(), 1); - assert_eq!(size_of::>(), 1); - assert_eq!(size_of::>(), size_of::()); - let enone = None::; - let esome = Some(E::A); - if let Some(..) = enone { - panic!(); - } - if let None = esome { - panic!(); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/numeric-fields.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/numeric-fields.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/numeric-fields.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/numeric-fields.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct S(u8, u16); - -fn main() { - let s = S{1: 10, 0: 11}; - match s { - S{0: a, 1: b, ..} => { - assert_eq!(a, 11); - assert_eq!(b, 10); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/object-lifetime-default-from-ref-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/object-lifetime-default-from-ref-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/object-lifetime-default-from-ref-struct.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/object-lifetime-default-from-ref-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that the lifetime of the enclosing `&` is used for the object -// lifetime bound. - -// pretty-expanded FIXME #23616 - -#![allow(dead_code)] - -use std::fmt::Display; - -trait Test { - fn foo(&self) { } -} - -struct Ref<'a,T:'a+?Sized> { - r: &'a T -} - -struct Ref2<'a,'b,T:'a+'b+?Sized> { - a: &'a T, - b: &'b T -} - -struct SomeStruct<'a> { - t: Ref<'a,Test>, - u: Ref<'a,Test+'a>, -} - -fn a<'a>(t: Ref<'a,Test>, mut ss: SomeStruct<'a>) { - ss.t = t; -} - -fn b<'a>(t: Ref<'a,Test>, mut ss: SomeStruct<'a>) { - ss.u = t; -} - -fn c<'a>(t: Ref<'a,Test+'a>, mut ss: SomeStruct<'a>) { - ss.t = t; -} - -fn d<'a>(t: Ref<'a,Test+'a>, mut ss: SomeStruct<'a>) { - ss.u = t; -} - -fn e<'a>(_: Ref<'a, Display+'static>) {} -fn g<'a, 'b>(_: Ref2<'a, 'b, Display+'static>) {} - - -fn main() { - // Inside a function body, we can just infer all - // lifetimes, to allow Ref<'tmp, Display+'static> - // and Ref2<'tmp, 'tmp, Display+'static>. - let x = &0 as &(Display+'static); - let r: Ref = Ref { r: x }; - let r2: Ref2 = Ref2 { a: x, b: x }; - e(r); - g(r2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/object-lifetime-default-from-rptr-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/object-lifetime-default-from-rptr-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/object-lifetime-default-from-rptr-struct.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/object-lifetime-default-from-rptr-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that the lifetime from the enclosing `&` is "inherited" -// through the `MyBox` struct. - -// pretty-expanded FIXME #23616 - -#![allow(dead_code)] - -trait Test { - fn foo(&self) { } -} - -struct SomeStruct<'a> { - t: &'a MyBox, - u: &'a MyBox, -} - -struct MyBox { - b: Box -} - -fn a<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { - ss.t = t; -} - -fn b<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { - ss.u = t; -} - -// see also compile-fail/object-lifetime-default-from-rptr-box-error.rs - -fn d<'a>(t: &'a MyBox, mut ss: SomeStruct<'a>) { - ss.u = t; -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec-align-u32.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec-align-u32.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec-align-u32.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec-align-u32.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -// Copyright 2012-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #2303 - -#![feature(intrinsics)] - -use std::mem; - -mod rusti { - extern "rust-intrinsic" { - pub fn pref_align_of() -> usize; - pub fn min_align_of() -> usize; - } -} - -// This is the type with the questionable alignment -#[derive(Debug)] -struct Inner { - c64: u32 -} - -// This is the type that contains the type with the -// questionable alignment, for testing -#[derive(Debug)] -struct Outer { - c8: u8, - t: Inner -} - -mod m { - pub fn align() -> usize { 4 } - pub fn size() -> usize { 8 } -} - -pub fn main() { - unsafe { - let x = Outer {c8: 22, t: Inner {c64: 44}}; - - // Send it through the shape code - let y = format!("{:?}", x); - - println!("align inner = {:?}", rusti::min_align_of::()); - println!("size outer = {:?}", mem::size_of::()); - println!("y = {:?}", y); - - // per clang/gcc the alignment of `inner` is 4 on x86. - assert_eq!(rusti::min_align_of::(), m::align()); - - // per clang/gcc the size of `outer` should be 12 - // because `inner`s alignment was 4. - assert_eq!(mem::size_of::(), m::size()); - - assert_eq!(y, "Outer { c8: 22, t: Inner { c64: 44 } }".to_string()); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec-align-u64.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec-align-u64.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec-align-u64.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec-align-u64.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ -// Copyright 2012-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare seems unimportant to test - -// Issue #2303 - -#![feature(intrinsics)] - -use std::mem; - -mod rusti { - extern "rust-intrinsic" { - pub fn pref_align_of() -> usize; - pub fn min_align_of() -> usize; - } -} - -// This is the type with the questionable alignment -#[derive(Debug)] -struct Inner { - c64: u64 -} - -// This is the type that contains the type with the -// questionable alignment, for testing -#[derive(Debug)] -struct Outer { - c8: u8, - t: Inner -} - - -#[cfg(any(target_os = "android", - target_os = "cloudabi", - target_os = "dragonfly", - target_os = "emscripten", - target_os = "freebsd", - target_os = "linux", - target_os = "macos", - target_os = "netbsd", - target_os = "openbsd", - target_os = "solaris"))] -mod m { - #[cfg(target_arch = "x86")] - pub mod m { - pub fn align() -> usize { 4 } - pub fn size() -> usize { 12 } - } - - #[cfg(not(target_arch = "x86"))] - pub mod m { - pub fn align() -> usize { 8 } - pub fn size() -> usize { 16 } - } -} - -#[cfg(target_os = "bitrig")] -mod m { - #[cfg(target_arch = "x86_64")] - pub mod m { - pub fn align() -> usize { 8 } - pub fn size() -> usize { 16 } - } -} - -#[cfg(target_os = "windows")] -mod m { - #[cfg(target_arch = "x86")] - pub mod m { - pub fn align() -> usize { 8 } - pub fn size() -> usize { 16 } - } - - #[cfg(target_arch = "x86_64")] - pub mod m { - pub fn align() -> usize { 8 } - pub fn size() -> usize { 16 } - } -} - -pub fn main() { - unsafe { - let x = Outer {c8: 22, t: Inner {c64: 44}}; - - let y = format!("{:?}", x); - - println!("align inner = {:?}", rusti::min_align_of::()); - println!("size outer = {:?}", mem::size_of::()); - println!("y = {:?}", y); - - // per clang/gcc the alignment of `Inner` is 4 on x86. - assert_eq!(rusti::min_align_of::(), m::m::align()); - - // per clang/gcc the size of `Outer` should be 12 - // because `Inner`s alignment was 4. - assert_eq!(mem::size_of::(), m::m::size()); - - assert_eq!(y, "Outer { c8: 22, t: Inner { c64: 44 } }".to_string()); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec-auto.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec-auto.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec-auto.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec-auto.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - - -// Issue #50. - -struct X { foo: String, bar: String } - -pub fn main() { - let x = X {foo: "hello".to_string(), bar: "world".to_string()}; - println!("{}", x.foo.clone()); - println!("{}", x.bar.clone()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec-extend.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec-extend.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec-extend.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec-extend.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - - - -struct Point {x: isize, y: isize} - -pub fn main() { - let origin: Point = Point {x: 0, y: 0}; - let right: Point = Point {x: origin.x + 10,.. origin}; - let up: Point = Point {y: origin.y + 10,.. origin}; - assert_eq!(origin.x, 0); - assert_eq!(origin.y, 0); - assert_eq!(right.x, 10); - assert_eq!(right.y, 0); - assert_eq!(up.x, 0); - assert_eq!(up.y, 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/record-pat.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/record-pat.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/record-pat.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/record-pat.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -#![allow(non_shorthand_field_patterns)] - -enum t1 { a(isize), b(usize), } -struct T2 {x: t1, y: isize} -enum t3 { c(T2, usize), } - -fn m(input: t3) -> isize { - match input { - t3::c(T2 {x: t1::a(m), ..}, _) => { return m; } - t3::c(T2 {x: t1::b(m), y: y}, z) => { return ((m + z) as isize) + y; } - } -} - -pub fn main() { - assert_eq!(m(t3::c(T2 {x: t1::a(10), y: 5}, 4)), 10); - assert_eq!(m(t3::c(T2 {x: t1::b(10), y: 5}, 4)), 19); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#[derive(Copy, Clone)] -struct Rect {x: isize, y: isize, w: isize, h: isize} - -fn f(r: Rect, x: isize, y: isize, w: isize, h: isize) { - assert_eq!(r.x, x); - assert_eq!(r.y, y); - assert_eq!(r.w, w); - assert_eq!(r.h, h); -} - -pub fn main() { - let r: Rect = Rect {x: 10, y: 20, w: 100, h: 200}; - assert_eq!(r.x, 10); - assert_eq!(r.y, 20); - assert_eq!(r.w, 100); - assert_eq!(r.h, 200); - let r2: Rect = r; - let x: isize = r2.x; - assert_eq!(x, 10); - f(r, 10, 20, 100, 200); - f(r2, 10, 20, 100, 200); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec-tup.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec-tup.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec-tup.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/rec-tup.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - -#[derive(Copy, Clone)] -struct Point {x: isize, y: isize} - -type rect = (Point, Point); - -fn fst(r: rect) -> Point { let (fst, _) = r; return fst; } -fn snd(r: rect) -> Point { let (_, snd) = r; return snd; } - -fn f(r: rect, x1: isize, y1: isize, x2: isize, y2: isize) { - assert_eq!(fst(r).x, x1); - assert_eq!(fst(r).y, y1); - assert_eq!(snd(r).x, x2); - assert_eq!(snd(r).y, y2); -} - -pub fn main() { - let r: rect = (Point {x: 10, y: 20}, Point {x: 11, y: 22}); - assert_eq!(fst(r).x, 10); - assert_eq!(fst(r).y, 20); - assert_eq!(snd(r).x, 11); - assert_eq!(snd(r).y, 22); - let r2 = r; - let x: isize = fst(r2).x; - assert_eq!(x, 10); - f(r, 10, 20, 11, 22); - f(r2, 10, 20, 11, 22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/resource-in-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/resource-in-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/resource-in-struct.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/resource-in-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// Ensures that class dtors run if the object is inside an enum -// variant - -use std::cell::Cell; - -type closable<'a> = &'a Cell; - -struct close_res<'a> { - i: closable<'a>, - -} - -impl<'a> Drop for close_res<'a> { - fn drop(&mut self) { - self.i.set(false); - } -} - -fn close_res(i: closable) -> close_res { - close_res { - i: i - } -} - -enum option { none, some(T), } - -fn sink(_res: option) { } - -pub fn main() { - let c = &Cell::new(true); - sink(option::none); - sink(option::some(close_res(c))); - assert!(!c.get()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/simple-generic-tag.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/simple-generic-tag.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/simple-generic-tag.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/simple-generic-tag.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - - -// pretty-expanded FIXME #23616 - -enum clam { a(T), } - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/simple-match-generic-tag.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/simple-match-generic-tag.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/simple-match-generic-tag.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/simple-match-generic-tag.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -enum opt { none, some(T) } - -pub fn main() { - let x = opt::none::; - match x { - opt::none:: => { println!("hello world"); } - opt::some(_) => { } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/small-enum-range-edge.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/small-enum-range-edge.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/small-enum-range-edge.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/small-enum-range-edge.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -// Tests the range assertion wraparound case when reading discriminants. - -#[repr(u8)] -#[derive(Copy, Clone)] -enum Eu { Lu = 0, Hu = 255 } - -static CLu: Eu = Eu::Lu; -static CHu: Eu = Eu::Hu; - -#[repr(i8)] -#[derive(Copy, Clone)] -enum Es { Ls = -128, Hs = 127 } - -static CLs: Es = Es::Ls; -static CHs: Es = Es::Hs; - -pub fn main() { - assert_eq!((Eu::Hu as u8).wrapping_add(1), Eu::Lu as u8); - assert_eq!((Es::Hs as i8).wrapping_add(1), Es::Ls as i8); - assert_eq!(CLu as u8, Eu::Lu as u8); - assert_eq!(CHu as u8, Eu::Hu as u8); - assert_eq!(CLs as i8, Es::Ls as i8); - assert_eq!(CHs as i8, Es::Hs as i8); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/small-enums-with-fields.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/small-enums-with-fields.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/small-enums-with-fields.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/small-enums-with-fields.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::mem::size_of; - -#[derive(PartialEq, Debug)] -enum Either { Left(T), Right(U) } - -macro_rules! check { - ($t:ty, $sz:expr, $($e:expr, $s:expr),*) => {{ - assert_eq!(size_of::<$t>(), $sz); - $({ - static S: $t = $e; - let v: $t = $e; - assert_eq!(S, v); - assert_eq!(format!("{:?}", v), $s); - assert_eq!(format!("{:?}", S), $s); - });* - }} -} - -pub fn main() { - check!(Option, 2, - None, "None", - Some(129), "Some(129)"); - check!(Option, 4, - None, "None", - Some(-20000), "Some(-20000)"); - check!(Either, 2, - Either::Left(132), "Left(132)", - Either::Right(-32), "Right(-32)"); - check!(Either, 4, - Either::Left(132), "Left(132)", - Either::Right(-20000), "Right(-20000)"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-aliases.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-aliases.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-aliases.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-aliases.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_shorthand_field_patterns)] - -use std::mem; - -struct S { - x: isize, - y: isize, -} - -type S2 = S; - -struct S3 { - x: U, - y: V -} - -type S4 = S3; - -fn main() { - let s = S2 { - x: 1, - y: 2, - }; - match s { - S2 { - x: x, - y: y - } => { - assert_eq!(x, 1); - assert_eq!(y, 2); - } - } - // check that generics can be specified from the pattern - let s = S4 { - x: 4, - y: 'a' - }; - match s { - S4:: { - x: x, - y: y - } => { - assert_eq!(x, 4); - assert_eq!(y, 'a'); - assert_eq!(mem::size_of_val(&x), 1); - } - }; - // check that generics can be specified from the constructor - let s = S4:: { - x: 5, - y: 'b' - }; - match s { - S4 { - x: x, - y: y - } => { - assert_eq!(x, 5); - assert_eq!(y, 'b'); - assert_eq!(mem::size_of_val(&x), 2); - } - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-aliases-xcrate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-aliases-xcrate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-aliases-xcrate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-aliases-xcrate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_shorthand_field_patterns)] - -// aux-build:xcrate_struct_aliases.rs - -extern crate xcrate_struct_aliases; - -use xcrate_struct_aliases::{S, S2}; - -fn main() { - let s = S2 { - x: 1, - y: 2, - }; - match s { - S2 { - x: x, - y: y - } => { - assert_eq!(x, 1); - assert_eq!(y, 2); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-destructuring-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-destructuring-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-destructuring-cross-crate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-destructuring-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:struct_destructuring_cross_crate.rs - - -extern crate struct_destructuring_cross_crate; - -pub fn main() { - let x = struct_destructuring_cross_crate::S { x: 1, y: 2 }; - let struct_destructuring_cross_crate::S { x: a, y: b } = x; - assert_eq!(a, 1); - assert_eq!(b, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-field-shorthand.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-field-shorthand.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-field-shorthand.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-field-shorthand.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct Foo { - x: i32, - y: bool, - z: i32 -} - -struct Bar { - x: i32 -} - -pub fn main() { - let (x, y, z) = (1, true, 2); - let a = Foo { x, y: y, z }; - assert_eq!(a.x, x); - assert_eq!(a.y, y); - assert_eq!(a.z, z); - - let b = Bar { x, }; - assert_eq!(b.x, x); - - let c = Foo { z, y, x }; - assert_eq!(c.x, x); - assert_eq!(c.y, y); - assert_eq!(c.z, z); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-like-variant-construct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-like-variant-construct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-like-variant-construct.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-like-variant-construct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -enum Foo { - Bar { - a: isize, - b: isize - }, - Baz { - c: f64, - d: f64 - } -} - -pub fn main() { - let _x = Foo::Bar { a: 2, b: 3 }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-like-variant-match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-like-variant-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-like-variant-match.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-like-variant-match.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_shorthand_field_patterns)] - -enum Foo { - Bar { - x: isize, - y: isize - }, - Baz { - x: f64, - y: f64 - } -} - -fn f(x: &Foo) { - match *x { - Foo::Baz { x: x, y: y } => { - assert_eq!(x, 1.0); - assert_eq!(y, 2.0); - } - Foo::Bar { y: y, x: x } => { - assert_eq!(x, 1); - assert_eq!(y, 2); - } - } -} - -pub fn main() { - let x = Foo::Bar { x: 1, y: 2 }; - f(&x); - let y = Foo::Baz { x: 1.0, y: 2.0 }; - f(&y); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-literal-dtor.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-literal-dtor.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-literal-dtor.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-literal-dtor.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -struct foo { - x: String, -} - -impl Drop for foo { - fn drop(&mut self) { - println!("{}", self.x); - } -} - -pub fn main() { - let _z = foo { - x: "Hello".to_string() - }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-lit-functional-no-fields.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-lit-functional-no-fields.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-lit-functional-no-fields.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-lit-functional-no-fields.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Debug,PartialEq,Clone)] -struct Foo { - bar: T, - baz: T -} - -pub fn main() { - let foo = Foo { - bar: 0, - baz: 1 - }; - - let foo_ = foo.clone(); - let foo = Foo { ..foo }; - assert_eq!(foo, foo_); - - let foo = Foo { - bar: "one".to_string(), - baz: "two".to_string() - }; - - let foo_ = foo.clone(); - let foo = Foo { ..foo }; - assert_eq!(foo, foo_); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-new-as-field-name.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-new-as-field-name.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-new-as-field-name.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-new-as-field-name.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct Foo { - new: isize, -} - -pub fn main() { - let foo = Foo{ new: 3 }; - assert_eq!(foo.new, 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-order-of-eval-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-order-of-eval-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-order-of-eval-1.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-order-of-eval-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct S { f0: String, f1: isize } - -pub fn main() { - let s = "Hello, world!".to_string(); - let s = S { - f0: s.to_string(), - ..S { - f0: s, - f1: 23 - } - }; - assert_eq!(s.f0, "Hello, world!"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-order-of-eval-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-order-of-eval-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-order-of-eval-2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-order-of-eval-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct S { - f0: String, - f1: String, -} - -pub fn main() { - let s = "Hello, world!".to_string(); - let s = S { - f1: s.to_string(), - f0: s - }; - assert_eq!(s.f0, "Hello, world!"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-order-of-eval-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-order-of-eval-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-order-of-eval-3.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-order-of-eval-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Checks that functional-record-update order-of-eval is as expected -// even when no Drop-implementations are involved. - -use std::sync::atomic::{Ordering, AtomicUsize}; - -struct W { wrapped: u32 } -struct S { f0: W, _f1: i32 } - -pub fn main() { - const VAL: u32 = 0x89AB_CDEF; - let w = W { wrapped: VAL }; - let s = S { - f0: { event(0x01); W { wrapped: w.wrapped + 1 } }, - ..S { - f0: { event(0x02); w}, - _f1: 23 - } - }; - assert_eq!(s.f0.wrapped, VAL + 1); - let actual = event_log(); - let expect = 0x01_02; - assert!(expect == actual, - "expect: 0x{:x} actual: 0x{:x}", expect, actual); -} - -static LOG: AtomicUsize = AtomicUsize::new(0); - -fn event_log() -> usize { - LOG.load(Ordering::SeqCst) -} - -fn event(tag: u8) { - let old_log = LOG.load(Ordering::SeqCst); - let new_log = (old_log << 8) + tag as usize; - LOG.store(new_log, Ordering::SeqCst); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-order-of-eval-4.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-order-of-eval-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-order-of-eval-4.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-order-of-eval-4.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Checks that struct-literal expression order-of-eval is as expected -// even when no Drop-implementations are involved. - -use std::sync::atomic::{Ordering, AtomicUsize}; - -struct W { wrapped: u32 } -struct S { f0: W, _f1: i32 } - -pub fn main() { - const VAL: u32 = 0x89AB_CDEF; - let w = W { wrapped: VAL }; - let s = S { - _f1: { event(0x01); 23 }, - f0: { event(0x02); w }, - }; - assert_eq!(s.f0.wrapped, VAL); - let actual = event_log(); - let expect = 0x01_02; - assert!(expect == actual, - "expect: 0x{:x} actual: 0x{:x}", expect, actual); -} - -static LOG: AtomicUsize = AtomicUsize::new(0); - -fn event_log() -> usize { - LOG.load(Ordering::SeqCst) -} - -fn event(tag: u8) { - let old_log = LOG.load(Ordering::SeqCst); - let new_log = (old_log << 8) + tag as usize; - LOG.store(new_log, Ordering::SeqCst); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-partial-move-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-partial-move-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-partial-move-1.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-partial-move-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(PartialEq, Debug)] -pub struct Partial { x: T, y: T } - -#[derive(PartialEq, Debug)] -struct S { val: isize } -impl S { fn new(v: isize) -> S { S { val: v } } } -impl Drop for S { fn drop(&mut self) { } } - -pub fn f((b1, b2): (T, T), mut f: F) -> Partial where F: FnMut(T) -> T { - let p = Partial { x: b1, y: b2 }; - - // Move of `p` is legal even though we are also moving `p.y`; the - // `..p` moves all fields *except* `p.y` in this context. - Partial { y: f(p.y), ..p } -} - -pub fn main() { - let p = f((S::new(3), S::new(4)), |S { val: z }| S::new(z+1)); - assert_eq!(p, Partial { x: S::new(3), y: S::new(5) }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-partial-move-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-partial-move-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-partial-move-2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-partial-move-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(PartialEq, Debug)] -pub struct Partial { x: T, y: T } - -#[derive(PartialEq, Debug)] -struct S { val: isize } -impl S { fn new(v: isize) -> S { S { val: v } } } -impl Drop for S { fn drop(&mut self) { } } - -pub type Two = (Partial, Partial); - -pub fn f((b1, b2): (T, T), (b3, b4): (T, T), mut f: F) -> Two where F: FnMut(T) -> T { - let p = Partial { x: b1, y: b2 }; - let q = Partial { x: b3, y: b4 }; - - // Move of `q` is legal even though we have already moved `q.y`; - // the `..q` moves all fields *except* `q.y` in this context. - // Likewise, the move of `p.x` is legal for similar reasons. - (Partial { x: f(q.y), ..p }, Partial { y: f(p.x), ..q }) -} - -pub fn main() { - let two = f((S::new(1), S::new(3)), - (S::new(5), S::new(7)), - |S { val: z }| S::new(z+1)); - assert_eq!(two, (Partial { x: S::new(8), y: S::new(3) }, - Partial { x: S::new(5), y: S::new(2) })); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-path-associated-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-path-associated-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-path-associated-type.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-path-associated-type.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct S { - a: T, - b: U, -} - -trait Tr { - type A; -} -impl Tr for u8 { - type A = S; -} - -fn f>>() { - let s = T::A { a: 0, b: 1 }; - match s { - T::A { a, b } => { - assert_eq!(a, 0); - assert_eq!(b, 1); - } - } -} - -fn main() { - f::(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-path-self.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-path-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-path-self.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-path-self.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::ops::Add; - -struct S { - a: T, - b: U, -} - -trait Tr { - fn f(&self) -> Self; -} - -impl, U: Default> Tr for S { - fn f(&self) -> Self { - let s = Self { a: Default::default(), b: Default::default() }; - match s { - Self { a, b } => Self { a: a + 1, b: b } - } - } -} - -impl> S { - fn g(&self) -> Self { - let s = Self { a: Default::default(), b: Default::default() }; - match s { - Self { a, b } => Self { a: a, b: b + 1 } - } - } -} - -impl S { - fn new() -> Self { - Self { a: 0, b: 1 } - } -} - -fn main() { - let s0 = S::new(); - let s1 = s0.f(); - assert_eq!(s1.a, 1); - assert_eq!(s1.b, 0); - let s2 = s0.g(); - assert_eq!(s2.a, 0); - assert_eq!(s2.b, 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-pattern-matching.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-pattern-matching.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-pattern-matching.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-pattern-matching.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_shorthand_field_patterns)] - -struct Foo { - x: isize, - y: isize, -} - -pub fn main() { - let a = Foo { x: 1, y: 2 }; - match a { - Foo { x: x, y: y } => println!("yes, {}, {}", x, y) - } - - match a { - Foo { .. } => () - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-return.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-return.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-return.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-return.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -// Copyright 2012-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-wasm32-bare no libc to test ffi with - -#[repr(C)] -#[derive(Copy, Clone)] -pub struct Quad { a: u64, b: u64, c: u64, d: u64 } - -#[repr(C)] -#[derive(Copy, Clone)] -pub struct Floats { a: f64, b: u8, c: f64 } - -mod rustrt { - use super::{Floats, Quad}; - - #[link(name = "rust_test_helpers", kind = "static")] - extern { - pub fn rust_dbg_abi_1(q: Quad) -> Quad; - pub fn rust_dbg_abi_2(f: Floats) -> Floats; - } -} - -fn test1() { - unsafe { - let q = Quad { a: 0xaaaa_aaaa_aaaa_aaaa, - b: 0xbbbb_bbbb_bbbb_bbbb, - c: 0xcccc_cccc_cccc_cccc, - d: 0xdddd_dddd_dddd_dddd }; - let qq = rustrt::rust_dbg_abi_1(q); - println!("a: {:x}", qq.a as usize); - println!("b: {:x}", qq.b as usize); - println!("c: {:x}", qq.c as usize); - println!("d: {:x}", qq.d as usize); - assert_eq!(qq.a, q.c + 1); - assert_eq!(qq.b, q.d - 1); - assert_eq!(qq.c, q.a + 1); - assert_eq!(qq.d, q.b - 1); - } -} - -#[cfg(target_pointer_width = "64")] -fn test2() { - unsafe { - let f = Floats { a: 1.234567890e-15_f64, - b: 0b_1010_1010, - c: 1.0987654321e-15_f64 }; - let ff = rustrt::rust_dbg_abi_2(f); - println!("a: {}", ff.a as f64); - println!("b: {}", ff.b as usize); - println!("c: {}", ff.c as f64); - assert_eq!(ff.a, f.c + 1.0f64); - assert_eq!(ff.b, 0xff); - assert_eq!(ff.c, f.a - 1.0f64); - } -} - -#[cfg(target_pointer_width = "32")] -fn test2() { -} - -pub fn main() { - test1(); - test2(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-variant-field-visibility.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-variant-field-visibility.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-variant-field-visibility.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct-variant-field-visibility.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -mod foo { - pub enum Foo { - Bar { a: isize } - } -} - -fn f(f: foo::Foo) { - match f { - foo::Foo::Bar { a: _a } => {} - } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct_variant_xc_match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct_variant_xc_match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct_variant_xc_match.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct_variant_xc_match.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:struct_variant_xc_aux.rs - -extern crate struct_variant_xc_aux; - -use struct_variant_xc_aux::Enum::{StructVariant, Variant}; - -pub fn main() { - let arg = match (StructVariant { arg: 42 }) { - Variant(_) => unreachable!(), - StructVariant { arg } => arg - }; - assert_eq!(arg, 42); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct_variant_xc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct_variant_xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct_variant_xc.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/struct_variant_xc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:struct_variant_xc_aux.rs -// pretty-expanded FIXME #23616 - -extern crate struct_variant_xc_aux; - -use struct_variant_xc_aux::Enum::StructVariant; - -pub fn main() { - let _ = StructVariant { arg: 1 }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-align-dyn-u64.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-align-dyn-u64.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-align-dyn-u64.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-align-dyn-u64.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(deprecated)] - -use std::mem; - -enum Tag { - Tag2(A) -} - -struct Rec { - c8: u8, - t: Tag -} - -fn mk_rec() -> Rec { - return Rec { c8:0, t:Tag::Tag2(0) }; -} - -fn is_u64_aligned(u: &Tag) -> bool { - let p: usize = unsafe { mem::transmute(u) }; - let u64_align = std::mem::min_align_of::(); - return (p & (u64_align - 1)) == 0; -} - -pub fn main() { - let x = mk_rec(); - assert!(is_u64_aligned(&x.t)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-align-dyn-variants.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-align-dyn-variants.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-align-dyn-variants.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-align-dyn-variants.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(deprecated)] -#![allow(non_snake_case)] - -use std::mem; - -enum Tag { - VarA(A), - VarB(B), -} - -struct Rec { - chA: u8, - tA: Tag, - chB: u8, - tB: Tag, -} - -fn mk_rec(a: A, b: B) -> Rec { - Rec { chA:0, tA:Tag::VarA(a), chB:1, tB:Tag::VarB(b) } -} - -fn is_aligned(amnt: usize, u: &A) -> bool { - let p: usize = unsafe { mem::transmute(u) }; - return (p & (amnt-1)) == 0; -} - -fn variant_data_is_aligned(amnt: usize, u: &Tag) -> bool { - match u { - &Tag::VarA(ref a) => is_aligned(amnt, a), - &Tag::VarB(ref b) => is_aligned(amnt, b) - } -} - -pub fn main() { - let u64_align = std::mem::min_align_of::(); - let x = mk_rec(22u64, 23u64); - assert!(is_aligned(u64_align, &x.tA)); - assert!(variant_data_is_aligned(u64_align, &x.tA)); - assert!(is_aligned(u64_align, &x.tB)); - assert!(variant_data_is_aligned(u64_align, &x.tB)); - - let x = mk_rec(22u64, 23u32); - assert!(is_aligned(u64_align, &x.tA)); - assert!(variant_data_is_aligned(u64_align, &x.tA)); - assert!(is_aligned(u64_align, &x.tB)); - assert!(variant_data_is_aligned(4, &x.tB)); - - let x = mk_rec(22u32, 23u64); - assert!(is_aligned(u64_align, &x.tA)); - assert!(variant_data_is_aligned(4, &x.tA)); - assert!(is_aligned(u64_align, &x.tB)); - assert!(variant_data_is_aligned(u64_align, &x.tB)); - - let x = mk_rec(22u32, 23u32); - assert!(is_aligned(4, &x.tA)); - assert!(variant_data_is_aligned(4, &x.tA)); - assert!(is_aligned(4, &x.tB)); - assert!(variant_data_is_aligned(4, &x.tB)); - - let x = mk_rec(22f64, 23f64); - assert!(is_aligned(u64_align, &x.tA)); - assert!(variant_data_is_aligned(u64_align, &x.tA)); - assert!(is_aligned(u64_align, &x.tB)); - assert!(variant_data_is_aligned(u64_align, &x.tB)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-align-shape.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-align-shape.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-align-shape.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-align-shape.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -#[derive(Debug)] -enum a_tag { - a_tag_var(u64) -} - -#[derive(Debug)] -struct t_rec { - c8: u8, - t: a_tag -} - -pub fn main() { - let x = t_rec {c8: 22, t: a_tag::a_tag_var(44)}; - let y = format!("{:?}", x); - println!("y = {:?}", y); - assert_eq!(y, "t_rec { c8: 22, t: a_tag_var(44) }".to_string()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-align-u64.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-align-u64.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-align-u64.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-align-u64.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(deprecated)] - -use std::mem; - -enum Tag { - TagInner(u64) -} - -struct Rec { - c8: u8, - t: Tag -} - -fn mk_rec() -> Rec { - return Rec { c8:0, t:Tag::TagInner(0) }; -} - -fn is_u64_aligned(u: &Tag) -> bool { - let p: usize = unsafe { mem::transmute(u) }; - let u64_align = std::mem::min_align_of::(); - return (p & (u64_align - 1)) == 0; -} - -pub fn main() { - let x = mk_rec(); - assert!(is_u64_aligned(&x.t)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-disr-val-shape.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-disr-val-shape.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-disr-val-shape.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-disr-val-shape.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -#[derive(Debug)] -enum color { - red = 0xff0000, - green = 0x00ff00, - blue = 0x0000ff, - black = 0x000000, - white = 0xFFFFFF, -} - -pub fn main() { - let act = format!("{:?}", color::red); - println!("{}", act); - assert_eq!("red".to_string(), act); - assert_eq!("green".to_string(), format!("{:?}", color::green)); - assert_eq!("white".to_string(), format!("{:?}", color::white)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-exports.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-exports.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-exports.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-exports.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -use alder::*; - -mod alder { - pub enum burnside { couch, davis } - pub enum everett { flanders, glisan, hoyt } - pub enum irving { johnson, kearney, lovejoy } - pub enum marshall { northrup, overton } -} - -pub fn main() { - let _pettygrove: burnside = burnside::couch; - let _quimby: everett = everett::flanders; - let _raleigh: irving = irving::johnson; - let _savier: marshall; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-in-block.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-in-block.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-in-block.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-in-block.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - - -// pretty-expanded FIXME #23616 - -fn foo() { - fn zed(_z: bar) { } - enum bar { nil, } - fn baz() { zed(bar::nil); } -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - -enum colour { red(isize, isize), green, } - -impl PartialEq for colour { - fn eq(&self, other: &colour) -> bool { - match *self { - colour::red(a0, b0) => { - match (*other) { - colour::red(a1, b1) => a0 == a1 && b0 == b1, - colour::green => false, - } - } - colour::green => { - match (*other) { - colour::red(..) => false, - colour::green => true - } - } - } - } - fn ne(&self, other: &colour) -> bool { !(*self).eq(other) } -} - -fn f() { let x = colour::red(1, 2); let y = colour::green; assert!((x != y)); } - -pub fn main() { f(); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-variant-disr-type-mismatch.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-variant-disr-type-mismatch.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-variant-disr-type-mismatch.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-variant-disr-type-mismatch.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -enum color { - red = 1, - blue = 2, -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-variant-disr-val.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-variant-disr-val.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-variant-disr-val.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tag-variant-disr-val.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -use color::{red, green, blue, black, white, imaginary, purple, orange}; - -#[derive(Copy, Clone)] -enum color { - red = 0xff0000, - green = 0x00ff00, - blue = 0x0000ff, - black = 0x000000, - white = 0xFFFFFF, - imaginary = -1, - purple = 1 << 1, - orange = 8 >> 1 -} - -impl PartialEq for color { - fn eq(&self, other: &color) -> bool { - ((*self) as usize) == ((*other) as usize) - } - fn ne(&self, other: &color) -> bool { !(*self).eq(other) } -} - -pub fn main() { - test_color(red, 0xff0000, "red".to_string()); - test_color(green, 0x00ff00, "green".to_string()); - test_color(blue, 0x0000ff, "blue".to_string()); - test_color(black, 0x000000, "black".to_string()); - test_color(white, 0xFFFFFF, "white".to_string()); - test_color(imaginary, -1, "imaginary".to_string()); - test_color(purple, 2, "purple".to_string()); - test_color(orange, 4, "orange".to_string()); -} - -fn test_color(color: color, val: isize, name: String) { - //assert_eq!(unsafe::transmute(color), val); - assert_eq!(color as isize, val); - assert_eq!(get_color_alt(color), name); - assert_eq!(get_color_if(color), name); -} - -fn get_color_alt(color: color) -> String { - match color { - red => {"red".to_string()} - green => {"green".to_string()} - blue => {"blue".to_string()} - black => {"black".to_string()} - white => {"white".to_string()} - imaginary => {"imaginary".to_string()} - purple => {"purple".to_string()} - orange => {"orange".to_string()} - } -} - -fn get_color_if(color: color) -> String { - if color == red {"red".to_string()} - else if color == green {"green".to_string()} - else if color == blue {"blue".to_string()} - else if color == black {"black".to_string()} - else if color == white {"white".to_string()} - else if color == imaginary {"imaginary".to_string()} - else if color == purple {"purple".to_string()} - else if color == orange {"orange".to_string()} - else {"unknown".to_string()} -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tuple-struct-constructor-pointer.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tuple-struct-constructor-pointer.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tuple-struct-constructor-pointer.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tuple-struct-constructor-pointer.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(PartialEq, Debug)] -struct Foo(isize); -#[derive(PartialEq, Debug)] -struct Bar(isize, isize); - -pub fn main() { - let f: fn(isize) -> Foo = Foo; - let g: fn(isize, isize) -> Bar = Bar; - assert_eq!(f(42), Foo(42)); - assert_eq!(g(4, 7), Bar(4, 7)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tuple-struct-construct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tuple-struct-construct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tuple-struct-construct.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tuple-struct-construct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#[derive(Debug)] -struct Foo(isize, isize); - -pub fn main() { - let x = Foo(1, 2); - println!("{:?}", x); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tuple-struct-destructuring.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tuple-struct-destructuring.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tuple-struct-destructuring.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tuple-struct-destructuring.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct Foo(isize, isize); - -pub fn main() { - let x = Foo(1, 2); - let Foo(y, z) = x; - println!("{} {}", y, z); - assert_eq!(y, 1); - assert_eq!(z, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tuple-struct-matching.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tuple-struct-matching.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tuple-struct-matching.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tuple-struct-matching.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct Foo(isize, isize); - -pub fn main() { - let x = Foo(1, 2); - match x { - Foo(a, b) => { - assert_eq!(a, 1); - assert_eq!(b, 2); - println!("{} {}", a, b); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tuple-struct-trivial.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tuple-struct-trivial.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tuple-struct-trivial.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/tuple-struct-trivial.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -struct Foo(isize, isize, isize); - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/uninstantiable-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/uninstantiable-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/uninstantiable-struct.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/uninstantiable-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub struct Z(&'static Z); - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/unit-like-struct-drop-run.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/unit-like-struct-drop-run.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/unit-like-struct-drop-run.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/unit-like-struct-drop-run.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -// Make sure the destructor is run for unit-like structs. - - -#![feature(alloc)] - -use std::thread; - -struct Foo; - -impl Drop for Foo { - fn drop(&mut self) { - panic!("This panic should happen."); - } -} - -pub fn main() { - let x = thread::spawn(move|| { - let _b = Foo; - }).join(); - - let s = x.unwrap_err().downcast::<&'static str>().unwrap(); - assert_eq!(&**s, "This panic should happen."); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/unit-like-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/unit-like-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/unit-like-struct.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/unit-like-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct Foo; - -pub fn main() { - let x: Foo = Foo; - match x { - Foo => { println!("hi"); } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/variant-structs-trivial.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/variant-structs-trivial.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/variant-structs-trivial.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/structs-enums/variant-structs-trivial.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -enum Foo { - Bar { x: isize }, - Baz { y: isize } -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/all-crates.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/all-crates.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/all-crates.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/all-crates.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// compile-flags: -Clto=thin -// no-prefer-dynamic - -fn main() { - println!("hello!"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/auxiliary/dylib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/auxiliary/dylib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/auxiliary/dylib.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/auxiliary/dylib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z thinlto -C codegen-units=8 - -#[inline] -pub fn foo(b: u8) { - b.to_string(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/auxiliary/msvc-imp-present.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/auxiliary/msvc-imp-present.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/auxiliary/msvc-imp-present.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/auxiliary/msvc-imp-present.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic -// compile-flags: -Z thinlto -C codegen-units=8 -C prefer-dynamic - -#![crate_type = "rlib"] -#![crate_type = "dylib"] - -pub static A: u32 = 43; - -pub mod a { - pub static A: u32 = 43; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/auxiliary/thin-lto-inlines-aux.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/auxiliary/thin-lto-inlines-aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/auxiliary/thin-lto-inlines-aux.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/auxiliary/thin-lto-inlines-aux.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "rlib"] - -pub fn bar() -> u32 { - 3 -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/dylib-works.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/dylib-works.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/dylib-works.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/dylib-works.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// aux-build:dylib.rs - -extern crate dylib; - -fn main() { - dylib::foo(1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/msvc-imp-present.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/msvc-imp-present.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/msvc-imp-present.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/msvc-imp-present.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// aux-build:msvc-imp-present.rs -// compile-flags: -Z thinlto -C codegen-units=8 -// no-prefer-dynamic - -// On MSVC we have a "hack" where we emit symbols that look like `_imp_$name` -// for all exported statics. This is done because we apply `dllimport` to all -// imported constants and this allows everything to actually link correctly. -// -// The ThinLTO passes aggressively remove symbols if they can, and this test -// asserts that the ThinLTO passes don't remove these compiler-generated -// `_imp_*` symbols. The external library that we link in here is compiled with -// ThinLTO and multiple codegen units and has a few exported constants. Note -// that we also namely compile the library as both a dylib and an rlib, but we -// link the rlib to ensure that we assert those generated symbols exist. - -extern crate msvc_imp_present as bar; - -fn main() { - println!("{}", bar::A); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/thin-lto-inlines2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/thin-lto-inlines2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/thin-lto-inlines2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/thin-lto-inlines2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// compile-flags: -C codegen-units=8 -O -C lto=thin -// aux-build:thin-lto-inlines-aux.rs -// no-prefer-dynamic -// ignore-emscripten can't inspect instructions on emscripten - -// We want to assert here that ThinLTO will inline across codegen units. There's -// not really a great way to do that in general so we sort of hack around it by -// praying two functions go into separate codegen units and then assuming that -// if inlining *doesn't* happen the first byte of the functions will differ. - -extern crate thin_lto_inlines_aux as bar; - -pub fn foo() -> u32 { - bar::bar() -} - -fn main() { - println!("{} {}", foo(), bar::bar()); - - unsafe { - let foo = foo as usize as *const u8; - let bar = bar::bar as usize as *const u8; - - assert_eq!(*foo, *bar); - } -} - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/thin-lto-inlines.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/thin-lto-inlines.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/thin-lto-inlines.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/thin-lto-inlines.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// compile-flags: -Z thinlto -C codegen-units=8 -O -// ignore-emscripten can't inspect instructions on emscripten - -// We want to assert here that ThinLTO will inline across codegen units. There's -// not really a great way to do that in general so we sort of hack around it by -// praying two functions go into separate codegen units and then assuming that -// if inlining *doesn't* happen the first byte of the functions will differ. - -pub fn foo() -> u32 { - bar::bar() -} - -mod bar { - pub fn bar() -> u32 { - 3 - } -} - -fn main() { - println!("{} {}", foo(), bar::bar()); - - unsafe { - let foo = foo as usize as *const u8; - let bar = bar::bar as usize as *const u8; - - assert_eq!(*foo, *bar); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/weak-works.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/weak-works.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/weak-works.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/thinlto/weak-works.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// compile-flags: -C codegen-units=8 -Z thinlto -// ignore-windows - -#![feature(linkage)] - -pub mod foo { - #[linkage = "weak"] - #[no_mangle] - pub extern "C" fn FOO() -> i32 { - 0 - } -} - -mod bar { - extern "C" { - fn FOO() -> i32; - } - - pub fn bar() -> i32 { - unsafe { FOO() } - } -} - -fn main() { - bar::bar(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/auxiliary/thread-local-extern-static.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/auxiliary/thread-local-extern-static.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/auxiliary/thread-local-extern-static.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/auxiliary/thread-local-extern-static.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(cfg_target_thread_local, const_fn, thread_local)] -#![crate_type = "lib"] - -#[cfg(target_thread_local)] -use std::cell::Cell; - -#[no_mangle] -#[cfg(target_thread_local)] -#[thread_local] -pub static FOO: Cell = Cell::new(3); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/comm.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/comm.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/comm.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/comm.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::thread; -use std::sync::mpsc::{channel, Sender}; - -pub fn main() { - let (tx, rx) = channel(); - let t = thread::spawn(move|| { child(&tx) }); - let y = rx.recv().unwrap(); - println!("received"); - println!("{}", y); - assert_eq!(y, 10); - t.join(); -} - -fn child(c: &Sender) { - println!("sending"); - c.send(10).unwrap(); - println!("value sent"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sendable-class.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sendable-class.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sendable-class.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sendable-class.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// Test that a class with only sendable fields can be sent - -// pretty-expanded FIXME #23616 - -use std::sync::mpsc::channel; - -struct foo { - i: isize, - j: char, -} - -fn foo(i:isize, j: char) -> foo { - foo { - i: i, - j: j - } -} - -pub fn main() { - let (tx, rx) = channel(); - tx.send(foo(42, 'c')); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sendfn-is-a-block.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sendfn-is-a-block.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sendfn-is-a-block.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sendfn-is-a-block.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -fn test(f: F) -> usize where F: FnOnce(usize) -> usize { - return f(22); -} - -pub fn main() { - let y = test(|x| 4 * x); - assert_eq!(y, 88); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sendfn-spawn-with-fn-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sendfn-spawn-with-fn-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sendfn-spawn-with-fn-arg.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sendfn-spawn-with-fn-arg.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -#![feature(box_syntax)] - -use std::thread; - -pub fn main() { test05(); } - -fn test05_start(f: F) { - f(22); -} - -fn test05() { - let three: Box<_> = box 3; - let fn_to_send = move|n:isize| { - println!("{}", *three + n); // will copy x into the closure - assert_eq!(*three, 3); - }; - thread::spawn(move|| { - test05_start(fn_to_send); - }).join().ok().unwrap(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/send-is-not-static-par-for.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/send-is-not-static-par-for.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/send-is-not-static-par-for.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/send-is-not-static-par-for.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::thread; -use std::sync::Mutex; - -fn par_for(iter: I, f: F) - where I: Iterator, - I::Item: Send, - F: Fn(I::Item) + Sync -{ - for item in iter { - f(item) - } -} - -fn sum(x: &[i32]) { - let sum_lengths = Mutex::new(0); - par_for(x.windows(4), |x| { - *sum_lengths.lock().unwrap() += x.len() - }); - - assert_eq!(*sum_lengths.lock().unwrap(), (x.len() - 3) * 4); -} - -fn main() { - let mut elements = [0; 20]; - - // iterators over references into this stack frame - par_for(elements.iter_mut().enumerate(), |(i, x)| { - *x = i as i32 - }); - - sum(&elements) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/send-resource.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/send-resource.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/send-resource.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/send-resource.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 -// ignore-emscripten no threads support - -use std::thread; -use std::sync::mpsc::channel; - -struct test { - f: isize, -} - -impl Drop for test { - fn drop(&mut self) {} -} - -fn test(f: isize) -> test { - test { - f: f - } -} - -pub fn main() { - let (tx, rx) = channel(); - - let t = thread::spawn(move|| { - let (tx2, rx2) = channel(); - tx.send(tx2).unwrap(); - - let _r = rx2.recv().unwrap(); - }); - - rx.recv().unwrap().send(test(42)).unwrap(); - - t.join(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/send_str_hashmap.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/send_str_hashmap.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/send_str_hashmap.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/send_str_hashmap.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::collections::HashMap; -use std::borrow::Cow; - -use std::borrow::Cow::Borrowed as B; -use std::borrow::Cow::Owned as O; - -type SendStr = Cow<'static, str>; - -fn main() { - let mut map: HashMap = HashMap::new(); - assert!(map.insert(B("foo"), 42).is_none()); - assert!(map.insert(O("foo".to_string()), 42).is_some()); - assert!(map.insert(B("foo"), 42).is_some()); - assert!(map.insert(O("foo".to_string()), 42).is_some()); - - assert!(map.insert(B("foo"), 43).is_some()); - assert!(map.insert(O("foo".to_string()), 44).is_some()); - assert!(map.insert(B("foo"), 45).is_some()); - assert!(map.insert(O("foo".to_string()), 46).is_some()); - - let v = 46; - - assert_eq!(map.get(&O("foo".to_string())), Some(&v)); - assert_eq!(map.get(&B("foo")), Some(&v)); - - let (a, b, c, d) = (50, 51, 52, 53); - - assert!(map.insert(B("abc"), a).is_none()); - assert!(map.insert(O("bcd".to_string()), b).is_none()); - assert!(map.insert(B("cde"), c).is_none()); - assert!(map.insert(O("def".to_string()), d).is_none()); - - assert!(map.insert(B("abc"), a).is_some()); - assert!(map.insert(O("bcd".to_string()), b).is_some()); - assert!(map.insert(B("cde"), c).is_some()); - assert!(map.insert(O("def".to_string()), d).is_some()); - - assert!(map.insert(O("abc".to_string()), a).is_some()); - assert!(map.insert(B("bcd"), b).is_some()); - assert!(map.insert(O("cde".to_string()), c).is_some()); - assert!(map.insert(B("def"), d).is_some()); - - assert_eq!(map.get("abc"), Some(&a)); - assert_eq!(map.get("bcd"), Some(&b)); - assert_eq!(map.get("cde"), Some(&c)); - assert_eq!(map.get("def"), Some(&d)); - - assert_eq!(map.get(&B("abc")), Some(&a)); - assert_eq!(map.get(&B("bcd")), Some(&b)); - assert_eq!(map.get(&B("cde")), Some(&c)); - assert_eq!(map.get(&B("def")), Some(&d)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/send_str_treemap.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/send_str_treemap.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/send_str_treemap.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/send_str_treemap.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::collections::BTreeMap; -use std::borrow::Cow; - -use std::borrow::Cow::{Owned as O, Borrowed as B}; - -type SendStr = Cow<'static, str>; - -fn main() { - let mut map: BTreeMap = BTreeMap::new(); - assert!(map.insert(B("foo"), 42).is_none()); - assert!(map.insert(O("foo".to_string()), 42).is_some()); - assert!(map.insert(B("foo"), 42).is_some()); - assert!(map.insert(O("foo".to_string()), 42).is_some()); - - assert!(map.insert(B("foo"), 43).is_some()); - assert!(map.insert(O("foo".to_string()), 44).is_some()); - assert!(map.insert(B("foo"), 45).is_some()); - assert!(map.insert(O("foo".to_string()), 46).is_some()); - - let v = 46; - - assert_eq!(map.get(&O("foo".to_string())), Some(&v)); - assert_eq!(map.get(&B("foo")), Some(&v)); - - let (a, b, c, d) = (50, 51, 52, 53); - - assert!(map.insert(B("abc"), a).is_none()); - assert!(map.insert(O("bcd".to_string()), b).is_none()); - assert!(map.insert(B("cde"), c).is_none()); - assert!(map.insert(O("def".to_string()), d).is_none()); - - assert!(map.insert(B("abc"), a).is_some()); - assert!(map.insert(O("bcd".to_string()), b).is_some()); - assert!(map.insert(B("cde"), c).is_some()); - assert!(map.insert(O("def".to_string()), d).is_some()); - - assert!(map.insert(O("abc".to_string()), a).is_some()); - assert!(map.insert(B("bcd"), b).is_some()); - assert!(map.insert(O("cde".to_string()), c).is_some()); - assert!(map.insert(B("def"), d).is_some()); - - assert_eq!(map.get(&B("abc")), Some(&a)); - assert_eq!(map.get(&B("bcd")), Some(&b)); - assert_eq!(map.get(&B("cde")), Some(&c)); - assert_eq!(map.get(&B("def")), Some(&d)); - - assert_eq!(map.get(&O("abc".to_string())), Some(&a)); - assert_eq!(map.get(&O("bcd".to_string())), Some(&b)); - assert_eq!(map.get(&O("cde".to_string())), Some(&c)); - assert_eq!(map.get(&O("def".to_string())), Some(&d)); - - assert!(map.remove(&B("foo")).is_some()); - assert_eq!(map.into_iter().map(|(k, v)| format!("{}{}", k, v)) - .collect::>() - .concat(), - "abc50bcd51cde52def53".to_string()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/send-type-inference.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/send-type-inference.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/send-type-inference.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/send-type-inference.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -use std::sync::mpsc::{channel, Sender}; - -// tests that ctrl's type gets inferred properly -struct Command { - key: K, - val: V -} - -fn cache_server(mut tx: Sender>>) { - let (tx1, _rx) = channel(); - tx.send(tx1); -} -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/spawn2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/spawn2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/spawn2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/spawn2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::thread; - -pub fn main() { - let t = thread::spawn(move|| child((10, 20, 30, 40, 50, 60, 70, 80, 90)) ); - t.join().ok().unwrap(); // forget Err value, since it doesn't implement Debug -} - -fn child(args: (isize, isize, isize, isize, isize, isize, isize, isize, isize)) { - let (i1, i2, i3, i4, i5, i6, i7, i8, i9) = args; - println!("{}", i1); - println!("{}", i2); - println!("{}", i3); - println!("{}", i4); - println!("{}", i5); - println!("{}", i6); - println!("{}", i7); - println!("{}", i8); - println!("{}", i9); - assert_eq!(i1, 10); - assert_eq!(i2, 20); - assert_eq!(i3, 30); - assert_eq!(i4, 40); - assert_eq!(i5, 50); - assert_eq!(i6, 60); - assert_eq!(i7, 70); - assert_eq!(i8, 80); - assert_eq!(i9, 90); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/spawn-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/spawn-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/spawn-fn.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/spawn-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::thread; - -fn x(s: String, n: isize) { - println!("{}", s); - println!("{}", n); -} - -pub fn main() { - let t1 = thread::spawn(|| x("hello from first spawned fn".to_string(), 65) ); - let t2 = thread::spawn(|| x("hello from second spawned fn".to_string(), 66) ); - let t3 = thread::spawn(|| x("hello from third spawned fn".to_string(), 67) ); - let mut i = 30; - while i > 0 { - i = i - 1; - println!("parent sleeping"); - thread::yield_now(); - } - t1.join(); - t2.join(); - t3.join(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/spawning-with-debug.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/spawning-with-debug.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/spawning-with-debug.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/spawning-with-debug.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-windows -// exec-env:RUST_LOG=debug -// ignore-emscripten no threads support - -// regression test for issue #10405, make sure we don't call println! too soon. - -use std::thread::Builder; - -pub fn main() { - let mut t = Builder::new(); - t.spawn(move|| ()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/spawn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/spawn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/spawn.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/spawn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::thread; - -pub fn main() { - thread::spawn(move|| child(10)).join().ok().unwrap(); -} - -fn child(i: isize) { println!("{}", i); assert_eq!(i, 10); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/spawn-types.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/spawn-types.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/spawn-types.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/spawn-types.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// ignore-emscripten no threads support - -/* - Make sure we can spawn tasks that take different types of - parameters. This is based on a test case for #520 provided by Rob - Arnold. - */ - -use std::thread; -use std::sync::mpsc::{channel, Sender}; - -type ctx = Sender; - -fn iotask(_tx: &ctx, ip: String) { - assert_eq!(ip, "localhost".to_string()); -} - -pub fn main() { - let (tx, _rx) = channel::(); - let t = thread::spawn(move|| iotask(&tx, "localhost".to_string()) ); - t.join().ok().unwrap(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/std-sync-right-kind-impls.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/std-sync-right-kind-impls.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/std-sync-right-kind-impls.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/std-sync-right-kind-impls.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -use std::sync; - -fn assert_both() {} - -fn main() { - assert_both::>(); - assert_both::(); - assert_both::>(); - assert_both::(); - assert_both::>(); - assert_both::>(); - assert_both::(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sync-send-atomics.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sync-send-atomics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sync-send-atomics.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sync-send-atomics.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// pretty-expanded FIXME #23616 - -use std::sync::atomic::*; - -trait SendSync: Send + Sync {} - -impl SendSync for AtomicBool {} -impl SendSync for AtomicIsize {} -impl SendSync for AtomicUsize {} -impl SendSync for AtomicPtr {} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sync-send-in-std.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sync-send-in-std.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sync-send-in-std.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sync-send-in-std.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// ignore-cloudabi networking not available -// ignore-wasm32-bare networking not available - -use std::net::ToSocketAddrs; - -fn is_sync(_: T) where T: Sync {} -fn is_send(_: T) where T: Send {} - -macro_rules! all_sync_send { - ($ctor:expr, $($iter:ident),+) => ({ - $( - let mut x = $ctor; - is_sync(x.$iter()); - let mut y = $ctor; - is_send(y.$iter()); - )+ - }) -} - -fn main() { - all_sync_send!("localhost:80".to_socket_addrs().unwrap(), next); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sync-send-iterators-in-libcollections.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sync-send-iterators-in-libcollections.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sync-send-iterators-in-libcollections.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sync-send-iterators-in-libcollections.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![allow(warnings)] -#![feature(drain, collections_bound, btree_range)] - -use std::collections::BinaryHeap; -use std::collections::{BTreeMap, BTreeSet}; -use std::collections::LinkedList; -use std::collections::VecDeque; -use std::collections::HashMap; -use std::collections::HashSet; - -use std::mem; -use std::ops::Bound::Included; - -fn is_sync(_: T) where T: Sync {} -fn is_send(_: T) where T: Send {} - -macro_rules! all_sync_send { - ($ctor:expr, $($iter:ident),+) => ({ - $( - let mut x = $ctor; - is_sync(x.$iter()); - let mut y = $ctor; - is_send(y.$iter()); - )+ - }) -} - -macro_rules! is_sync_send { - ($ctor:expr, $iter:ident($($param:expr),+)) => ({ - let mut x = $ctor; - is_sync(x.$iter($( $param ),+)); - let mut y = $ctor; - is_send(y.$iter($( $param ),+)); - }) -} - -fn main() { - // The iterator "generator" list should exhaust what corresponding - // implementations have where `Sync` and `Send` semantics apply. - all_sync_send!(BinaryHeap::::new(), iter, drain, into_iter); - - all_sync_send!(BTreeMap::::new(), iter, iter_mut, into_iter, keys, values); - is_sync_send!(BTreeMap::::new(), range((Included(&0), Included(&9)))); - is_sync_send!(BTreeMap::::new(), range_mut((Included(&0), Included(&9)))); - - all_sync_send!(BTreeSet::::new(), iter, into_iter); - is_sync_send!(BTreeSet::::new(), range((Included(&0), Included(&9)))); - is_sync_send!(BTreeSet::::new(), difference(&BTreeSet::::new())); - is_sync_send!(BTreeSet::::new(), symmetric_difference(&BTreeSet::::new())); - is_sync_send!(BTreeSet::::new(), intersection(&BTreeSet::::new())); - is_sync_send!(BTreeSet::::new(), union(&BTreeSet::::new())); - - all_sync_send!(HashMap::::new(), iter, iter_mut, drain, into_iter, keys, values); - all_sync_send!(HashSet::::new(), iter, drain, into_iter); - is_sync_send!(HashSet::::new(), difference(&HashSet::::new())); - is_sync_send!(HashSet::::new(), symmetric_difference(&HashSet::::new())); - is_sync_send!(HashSet::::new(), intersection(&HashSet::::new())); - is_sync_send!(HashSet::::new(), union(&HashSet::::new())); - - all_sync_send!(LinkedList::::new(), iter, iter_mut, into_iter); - - all_sync_send!(VecDeque::::new(), iter, iter_mut, into_iter); - is_sync_send!(VecDeque::::new(), drain(..)); - - all_sync_send!(Vec::::new(), into_iter); - is_sync_send!(Vec::::new(), drain(..)); - is_sync_send!(String::new(), drain(..)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sync-send-iterators-in-libcore.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sync-send-iterators-in-libcore.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sync-send-iterators-in-libcore.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/sync-send-iterators-in-libcore.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,117 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![allow(warnings)] -#![feature(iter_empty)] -#![feature(iter_once)] -#![feature(str_escape)] - -use std::iter::{empty, once, repeat}; - -fn is_sync(_: T) where T: Sync {} -fn is_send(_: T) where T: Send {} - -macro_rules! all_sync_send { - ($ctor:expr, $iter:ident) => ({ - let mut x = $ctor; - is_sync(x.$iter()); - let mut y = $ctor; - is_send(y.$iter()); - }); - ($ctor:expr, $iter:ident($($param:expr),+)) => ({ - let mut x = $ctor; - is_sync(x.$iter($( $param ),+)); - let mut y = $ctor; - is_send(y.$iter($( $param ),+)); - }); - ($ctor:expr, $iter:ident, $($rest:tt)*) => ({ - all_sync_send!($ctor, $iter); - all_sync_send!($ctor, $($rest)*); - }); - ($ctor:expr, $iter:ident($($param:expr),+), $($rest:tt)*) => ({ - all_sync_send!($ctor, $iter($( $param ),+)); - all_sync_send!($ctor, $($rest)*); - }); -} - -macro_rules! all_sync_send_mutable_ref { - ($ctor:expr, $($iter:ident),+) => ({ - $( - let mut x = $ctor; - is_sync((&mut x).$iter()); - let mut y = $ctor; - is_send((&mut y).$iter()); - )+ - }) -} - -macro_rules! is_sync_send { - ($ctor:expr) => ({ - let x = $ctor; - is_sync(x); - let y = $ctor; - is_send(y); - }) -} - -fn main() { - // for char.rs - all_sync_send!("Я", escape_debug, escape_default, escape_unicode); - - // for iter.rs - all_sync_send_mutable_ref!([1], iter); - - // Bytes implements DoubleEndedIterator - all_sync_send!("a".bytes(), rev); - - let a = [1]; - let b = [2]; - all_sync_send!(a.iter(), - cloned, - cycle, - chain([2].iter()), - zip([2].iter()), - map(|_| 1), - filter(|_| true), - filter_map(|_| Some(1)), - enumerate, - peekable, - skip_while(|_| true), - take_while(|_| true), - skip(1), - take(1), - scan(1, |_, _| Some(1)), - flat_map(|_| b.iter()), - fuse, - inspect(|_| ())); - - is_sync_send!((1..).step_by(2)); - is_sync_send!((1..2).step_by(2)); - is_sync_send!((1..2)); - is_sync_send!((1..)); - is_sync_send!(repeat(1)); - is_sync_send!(empty::()); - is_sync_send!(once(1)); - - // for option.rs - // FIXME - - // for result.rs - // FIXME - - // for slice.rs - // FIXME - - // for str/mod.rs - // FIXME -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-0.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-0.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-0.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-0.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::thread; -use std::sync::mpsc::{channel, Sender}; - -pub fn main() { test05(); } - -fn test05_start(tx : &Sender) { - tx.send(10).unwrap(); - println!("sent 10"); - tx.send(20).unwrap(); - println!("sent 20"); - tx.send(30).unwrap(); - println!("sent 30"); -} - -fn test05() { - let (tx, rx) = channel(); - let t = thread::spawn(move|| { test05_start(&tx) }); - let mut value: isize = rx.recv().unwrap(); - println!("{}", value); - value = rx.recv().unwrap(); - println!("{}", value); - value = rx.recv().unwrap(); - println!("{}", value); - assert_eq!(value, 30); - t.join(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-10.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-10.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-10.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-10.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::thread; -use std::sync::mpsc::{channel, Sender}; - -fn start(tx: &Sender>) { - let (tx2, rx) = channel(); - tx.send(tx2).unwrap(); - - let mut a; - let mut b; - a = rx.recv().unwrap(); - assert_eq!(a, "A".to_string()); - println!("{}", a); - b = rx.recv().unwrap(); - assert_eq!(b, "B".to_string()); - println!("{}", b); -} - -pub fn main() { - let (tx, rx) = channel(); - let child = thread::spawn(move|| { start(&tx) }); - - let mut c = rx.recv().unwrap(); - c.send("A".to_string()).unwrap(); - c.send("B".to_string()).unwrap(); - thread::yield_now(); - - child.join(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-11.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-11.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-11.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-11.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 -// ignore-emscripten no threads support - -use std::sync::mpsc::{channel, Sender}; -use std::thread; - -fn start(tx: &Sender>) { - let (tx2, _rx) = channel(); - tx.send(tx2).unwrap(); -} - -pub fn main() { - let (tx, rx) = channel(); - let child = thread::spawn(move|| { - start(&tx) - }); - let _tx = rx.recv().unwrap(); - child.join(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-12.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-12.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-12.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-12.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::thread; - -pub fn main() { test00(); } - -fn start(_task_number: isize) { println!("Started / Finished task."); } - -fn test00() { - let i: isize = 0; - let mut result = thread::spawn(move|| { - start(i) - }); - - // Sleep long enough for the thread to finish. - let mut i = 0_usize; - while i < 10000 { - thread::yield_now(); - i += 1; - } - - // Try joining threads that have already finished. - result.join(); - - println!("Joined task."); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-13.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-13.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-13.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-13.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::sync::mpsc::{channel, Sender}; -use std::thread; - -fn start(tx: &Sender, start: isize, number_of_messages: isize) { - let mut i: isize = 0; - while i< number_of_messages { tx.send(start + i).unwrap(); i += 1; } -} - -pub fn main() { - println!("Check that we don't deadlock."); - let (tx, rx) = channel(); - let _ = thread::spawn(move|| { start(&tx, 0, 10) }).join(); - println!("Joined task"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-14.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-14.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-14.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-14.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::sync::mpsc::{channel, Sender}; -use std::thread; - -pub fn main() { - let (tx, rx) = channel(); - - // Spawn 10 threads each sending us back one isize. - let mut i = 10; - while (i > 0) { - println!("{}", i); - let tx = tx.clone(); - thread::spawn({let i = i; move|| { child(i, &tx) }}); - i = i - 1; - } - - // Spawned threads are likely killed before they get a chance to send - // anything back, so we deadlock here. - - i = 10; - while (i > 0) { - println!("{}", i); - rx.recv().unwrap(); - i = i - 1; - } - - println!("main thread exiting"); -} - -fn child(x: isize, tx: &Sender) { - println!("{}", x); - tx.send(x).unwrap(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-15.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-15.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-15.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-15.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support -// pretty-expanded FIXME #23616 - -use std::sync::mpsc::{channel, Sender}; -use std::thread; - -fn start(tx: &Sender, i0: isize) { - let mut i = i0; - while i > 0 { - tx.send(0).unwrap(); - i = i - 1; - } -} - -pub fn main() { - // Spawn a thread that sends us back messages. The parent thread - // is likely to terminate before the child completes, so from - // the child's point of view the receiver may die. We should - // drop messages on the floor in this case, and not crash! - let (tx, rx) = channel(); - let t = thread::spawn(move|| { - start(&tx, 10) - }); - rx.recv(); - t.join(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-16.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-16.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-16.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-16.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,119 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -use std::sync::mpsc::channel; -use std::cmp; - -// Tests of ports and channels on various types -fn test_rec() { - struct R {val0: isize, val1: u8, val2: char} - - let (tx, rx) = channel(); - let r0: R = R {val0: 0, val1: 1, val2: '2'}; - tx.send(r0).unwrap(); - let mut r1: R; - r1 = rx.recv().unwrap(); - assert_eq!(r1.val0, 0); - assert_eq!(r1.val1, 1); - assert_eq!(r1.val2, '2'); -} - -fn test_vec() { - let (tx, rx) = channel(); - let v0: Vec = vec![0, 1, 2]; - tx.send(v0).unwrap(); - let v1 = rx.recv().unwrap(); - assert_eq!(v1[0], 0); - assert_eq!(v1[1], 1); - assert_eq!(v1[2], 2); -} - -fn test_str() { - let (tx, rx) = channel(); - let s0 = "test".to_string(); - tx.send(s0).unwrap(); - let s1 = rx.recv().unwrap(); - assert_eq!(s1.as_bytes()[0], 't' as u8); - assert_eq!(s1.as_bytes()[1], 'e' as u8); - assert_eq!(s1.as_bytes()[2], 's' as u8); - assert_eq!(s1.as_bytes()[3], 't' as u8); -} - -#[derive(Debug)] -enum t { - tag1, - tag2(isize), - tag3(isize, u8, char) -} - -impl cmp::PartialEq for t { - fn eq(&self, other: &t) -> bool { - match *self { - t::tag1 => { - match (*other) { - t::tag1 => true, - _ => false - } - } - t::tag2(e0a) => { - match (*other) { - t::tag2(e0b) => e0a == e0b, - _ => false - } - } - t::tag3(e0a, e1a, e2a) => { - match (*other) { - t::tag3(e0b, e1b, e2b) => - e0a == e0b && e1a == e1b && e2a == e2b, - _ => false - } - } - } - } - fn ne(&self, other: &t) -> bool { !(*self).eq(other) } -} - -fn test_tag() { - let (tx, rx) = channel(); - tx.send(t::tag1).unwrap(); - tx.send(t::tag2(10)).unwrap(); - tx.send(t::tag3(10, 11, 'A')).unwrap(); - let mut t1: t; - t1 = rx.recv().unwrap(); - assert_eq!(t1, t::tag1); - t1 = rx.recv().unwrap(); - assert_eq!(t1, t::tag2(10)); - t1 = rx.recv().unwrap(); - assert_eq!(t1, t::tag3(10, 11, 'A')); -} - -fn test_chan() { - let (tx1, rx1) = channel(); - let (tx2, rx2) = channel(); - tx1.send(tx2).unwrap(); - let tx2 = rx1.recv().unwrap(); - // Does the transmitted channel still work? - - tx2.send(10).unwrap(); - let mut i: isize; - i = rx2.recv().unwrap(); - assert_eq!(i, 10); -} - -pub fn main() { - test_rec(); - test_vec(); - test_str(); - test_tag(); - test_chan(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-17.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-17.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-17.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-17.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support -// pretty-expanded FIXME #23616 - -// Issue #922 - -// This test is specifically about spawning temporary closures. - -use std::thread; - -fn f() { -} - -pub fn main() { - thread::spawn(move|| f() ).join(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-1.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::thread; - -pub fn main() { test00(); } - -fn start() { println!("Started / Finished task."); } - -fn test00() { - thread::spawn(move|| start() ).join(); - println!("Completing."); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-3.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::thread; -use std::sync::mpsc::{channel, Sender}; - -pub fn main() { println!("===== WITHOUT THREADS ====="); test00(); } - -fn test00_start(ch: &Sender, message: isize, count: isize) { - println!("Starting test00_start"); - let mut i: isize = 0; - while i < count { - println!("Sending Message"); - ch.send(message + 0).unwrap(); - i = i + 1; - } - println!("Ending test00_start"); -} - -fn test00() { - let number_of_tasks: isize = 16; - let number_of_messages: isize = 4; - - println!("Creating tasks"); - - let (tx, rx) = channel(); - - let mut i: isize = 0; - - // Create and spawn threads... - let mut results = Vec::new(); - while i < number_of_tasks { - let tx = tx.clone(); - results.push(thread::spawn({ - let i = i; - move|| { - test00_start(&tx, i, number_of_messages) - } - })); - i = i + 1; - } - - // Read from spawned threads... - let mut sum = 0; - for _r in &results { - i = 0; - while i < number_of_messages { - let value = rx.recv().unwrap(); - sum += value; - i = i + 1; - } - } - - // Join spawned threads... - for r in results { r.join(); } - - println!("Completed: Final number is: "); - println!("{}", sum); - // assert (sum == (((number_of_threads * (number_of_threads - 1)) / 2) * - // number_of_messages)); - assert_eq!(sum, 480); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-4.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-4.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-4.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::sync::mpsc::channel; - -pub fn main() { test00(); } - -fn test00() { - let mut r: isize = 0; - let mut sum: isize = 0; - let (tx, rx) = channel(); - tx.send(1).unwrap(); - tx.send(2).unwrap(); - tx.send(3).unwrap(); - tx.send(4).unwrap(); - r = rx.recv().unwrap(); - sum += r; - println!("{}", r); - r = rx.recv().unwrap(); - sum += r; - println!("{}", r); - r = rx.recv().unwrap(); - sum += r; - println!("{}", r); - r = rx.recv().unwrap(); - sum += r; - println!("{}", r); - tx.send(5).unwrap(); - tx.send(6).unwrap(); - tx.send(7).unwrap(); - tx.send(8).unwrap(); - r = rx.recv().unwrap(); - sum += r; - println!("{}", r); - r = rx.recv().unwrap(); - sum += r; - println!("{}", r); - r = rx.recv().unwrap(); - sum += r; - println!("{}", r); - r = rx.recv().unwrap(); - sum += r; - println!("{}", r); - assert_eq!(sum, 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-5.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-5.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-5.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-5.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::sync::mpsc::channel; - -pub fn main() { test00(); } - -fn test00() { - let _r: isize = 0; - let mut sum: isize = 0; - let (tx, rx) = channel(); - let number_of_messages: isize = 1000; - let mut i: isize = 0; - while i < number_of_messages { tx.send(i + 0).unwrap(); i += 1; } - i = 0; - while i < number_of_messages { sum += rx.recv().unwrap(); i += 1; } - assert_eq!(sum, number_of_messages * (number_of_messages - 1) / 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-6.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-6.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-6.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-6.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::sync::mpsc::channel; - -pub fn main() { test00(); } - -fn test00() { - let mut r: isize = 0; - let mut sum: isize = 0; - let (tx, rx) = channel(); - let mut tx0 = tx.clone(); - let mut tx1 = tx.clone(); - let mut tx2 = tx.clone(); - let mut tx3 = tx.clone(); - let number_of_messages: isize = 1000; - let mut i: isize = 0; - while i < number_of_messages { - tx0.send(i + 0).unwrap(); - tx1.send(i + 0).unwrap(); - tx2.send(i + 0).unwrap(); - tx3.send(i + 0).unwrap(); - i += 1; - } - i = 0; - while i < number_of_messages { - r = rx.recv().unwrap(); - sum += r; - r = rx.recv().unwrap(); - sum += r; - r = rx.recv().unwrap(); - sum += r; - r = rx.recv().unwrap(); - sum += r; - i += 1; - } - assert_eq!(sum, 1998000); - // assert (sum == 4 * ((number_of_messages * - // (number_of_messages - 1)) / 2)); - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-7.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-7.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-7.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-7.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::sync::mpsc::{channel, Sender}; -use std::thread; - -pub fn main() { test00(); } - -fn test00_start(c: &Sender, start: isize, - number_of_messages: isize) { - let mut i: isize = 0; - while i < number_of_messages { c.send(start + i).unwrap(); i += 1; } -} - -fn test00() { - let mut r: isize = 0; - let mut sum: isize = 0; - let (tx, rx) = channel(); - let number_of_messages: isize = 10; - - let tx2 = tx.clone(); - let t1 = thread::spawn(move|| { - test00_start(&tx2, number_of_messages * 0, number_of_messages); - }); - let tx2 = tx.clone(); - let t2 = thread::spawn(move|| { - test00_start(&tx2, number_of_messages * 1, number_of_messages); - }); - let tx2 = tx.clone(); - let t3 = thread::spawn(move|| { - test00_start(&tx2, number_of_messages * 2, number_of_messages); - }); - let tx2 = tx.clone(); - let t4 = thread::spawn(move|| { - test00_start(&tx2, number_of_messages * 3, number_of_messages); - }); - - let mut i: isize = 0; - while i < number_of_messages { - r = rx.recv().unwrap(); - sum += r; - r = rx.recv().unwrap(); - sum += r; - r = rx.recv().unwrap(); - sum += r; - r = rx.recv().unwrap(); - sum += r; - i += 1; - } - - assert_eq!(sum, number_of_messages * 4 * (number_of_messages * 4 - 1) / 2); - - t1.join(); - t2.join(); - t3.join(); - t4.join(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-9.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-9.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-9.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-9.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::thread; -use std::sync::mpsc::{channel, Sender}; - -pub fn main() { test00(); } - -fn test00_start(c: &Sender, number_of_messages: isize) { - let mut i: isize = 0; - while i < number_of_messages { c.send(i + 0).unwrap(); i += 1; } -} - -fn test00() { - let r: isize = 0; - let mut sum: isize = 0; - let (tx, rx) = channel(); - let number_of_messages: isize = 10; - - let result = thread::spawn(move|| { - test00_start(&tx, number_of_messages); - }); - - let mut i: isize = 0; - while i < number_of_messages { - sum += rx.recv().unwrap(); - println!("{}", r); - i += 1; - } - - result.join(); - - assert_eq!(sum, number_of_messages * (number_of_messages - 1) / 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-chan-nil.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-chan-nil.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-chan-nil.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-comm-chan-nil.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::sync::mpsc::channel; - -// rustboot can't transmit nils across channels because they don't have -// any size, but rustc currently can because they do have size. Whether -// or not this is desirable I don't know, but here's a regression test. -pub fn main() { - let (tx, rx) = channel(); - tx.send(()).unwrap(); - let n: () = rx.recv().unwrap(); - assert_eq!(n, ()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-life-0.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-life-0.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-life-0.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-life-0.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support -// pretty-expanded FIXME #23616 - -use std::thread; - -pub fn main() { - thread::spawn(move|| child("Hello".to_string()) ).join(); -} - -fn child(_s: String) { - -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-spawn-move-and-copy.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-spawn-move-and-copy.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-spawn-move-and-copy.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-spawn-move-and-copy.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -#![feature(box_syntax)] - -use std::thread; -use std::sync::mpsc::channel; - -pub fn main() { - let (tx, rx) = channel::(); - - let x: Box = box 1; - let x_in_parent = &(*x) as *const isize as usize; - - let t = thread::spawn(move || { - let x_in_child = &(*x) as *const isize as usize; - tx.send(x_in_child).unwrap(); - }); - - let x_in_child = rx.recv().unwrap(); - assert_eq!(x_in_parent, x_in_child); - - t.join(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-stderr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-stderr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-stderr.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/task-stderr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -#![feature(box_syntax, set_stdio)] - -use std::io::prelude::*; -use std::io; -use std::str; -use std::sync::{Arc, Mutex}; -use std::thread; - -struct Sink(Arc>>); -impl Write for Sink { - fn write(&mut self, data: &[u8]) -> io::Result { - Write::write(&mut *self.0.lock().unwrap(), data) - } - fn flush(&mut self) -> io::Result<()> { Ok(()) } -} - -fn main() { - let data = Arc::new(Mutex::new(Vec::new())); - let sink = Sink(data.clone()); - let res = thread::Builder::new().spawn(move|| -> () { - io::set_panic(Some(Box::new(sink))); - panic!("Hello, world!") - }).unwrap().join(); - assert!(res.is_err()); - - let output = data.lock().unwrap(); - let output = str::from_utf8(&output).unwrap(); - assert!(output.contains("Hello, world!")); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/thread-local-extern-static.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/thread-local-extern-static.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/thread-local-extern-static.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/thread-local-extern-static.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-windows -// aux-build:thread-local-extern-static.rs - -#![feature(cfg_target_thread_local, thread_local)] - -#[cfg(target_thread_local)] -extern crate thread_local_extern_static; - -#[cfg(target_thread_local)] -use std::cell::Cell; - -#[cfg(target_thread_local)] -extern { - #[thread_local] - static FOO: Cell; -} - -#[cfg(target_thread_local)] -fn main() { - unsafe { - assert_eq!(FOO.get(), 3); - } -} - -#[cfg(not(target_thread_local))] -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/thread-local-syntax.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/thread-local-syntax.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/thread-local-syntax.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/thread-local-syntax.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![deny(missing_docs)] -//! this tests the syntax of `thread_local!` - -mod foo { - mod bar { - thread_local! { - // no docs - #[allow(unused)] - static FOO: i32 = 42; - /// docs - pub static BAR: String = String::from("bar"); - - // look at these restrictions!! - pub(crate) static BAZ: usize = 0; - pub(in foo) static QUUX: usize = 0; - } - thread_local!(static SPLOK: u32 = 0); - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/threads.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/threads.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/threads.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/threads.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -use std::thread; - -pub fn main() { - let mut i = 10; - while i > 0 { - thread::spawn({let i = i; move|| child(i)}).join(); - i = i - 1; - } - println!("main thread exiting"); -} - -fn child(x: isize) { println!("{}", x); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/tls-dtors-are-run-in-a-static-binary.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/tls-dtors-are-run-in-a-static-binary.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/tls-dtors-are-run-in-a-static-binary.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/tls-dtors-are-run-in-a-static-binary.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// no-prefer-dynamic -// ignore-emscripten no threads support - -static mut HIT: bool = false; - -struct Foo; - -impl Drop for Foo { - fn drop(&mut self) { - unsafe { HIT = true; } - } -} - -thread_local!(static FOO: Foo = Foo); - -fn main() { - std::thread::spawn(|| { - FOO.with(|_| {}); - }).join().unwrap(); - assert!(unsafe { HIT }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/tls-init-on-init.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/tls-init-on-init.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/tls-init-on-init.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/tls-init-on-init.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -// ignore-emscripten no threads support - -#![feature(thread_local_try_with)] - -use std::thread; -use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; - -struct Foo { cnt: usize } - -thread_local!(static FOO: Foo = Foo::init()); - -static CNT: AtomicUsize = ATOMIC_USIZE_INIT; - -impl Foo { - fn init() -> Foo { - let cnt = CNT.fetch_add(1, Ordering::SeqCst); - if cnt == 0 { - FOO.with(|_| {}); - } - Foo { cnt: cnt } - } -} - -impl Drop for Foo { - fn drop(&mut self) { - if self.cnt == 1 { - FOO.with(|foo| assert_eq!(foo.cnt, 0)); - } else { - assert_eq!(self.cnt, 0); - if FOO.try_with(|_| ()).is_ok() { - panic!("should not be in valid state"); - } - } - } -} - -fn main() { - thread::spawn(|| { - FOO.with(|_| {}); - }).join().unwrap(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/tls-try-with.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/tls-try-with.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/tls-try-with.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/threads-sendsync/tls-try-with.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(stable_features)] - -// ignore-emscripten no threads support - -#![feature(thread_local_try_with)] - -use std::thread; - -static mut DROP_RUN: bool = false; - -struct Foo; - -thread_local!(static FOO: Foo = Foo {}); - -impl Drop for Foo { - fn drop(&mut self) { - assert!(FOO.try_with(|_| panic!("`try_with` closure run")).is_err()); - unsafe { DROP_RUN = true; } - } -} - -fn main() { - thread::spawn(|| { - assert_eq!(FOO.try_with(|_| { - 132 - }).expect("`try_with` failed"), 132); - }).join().unwrap(); - assert!(unsafe { DROP_RUN }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/anon_trait_static_method_exe.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/anon_trait_static_method_exe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/anon_trait_static_method_exe.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/anon_trait_static_method_exe.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// aux-build:anon_trait_static_method_lib.rs - -extern crate anon_trait_static_method_lib; -use anon_trait_static_method_lib::Foo; - -pub fn main() { - let x = Foo::new(); - println!("{}", x.x); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/anon-trait-static-method.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/anon-trait-static-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/anon-trait-static-method.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/anon-trait-static-method.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -struct Foo { - x: isize -} - -impl Foo { - pub fn new() -> Foo { - Foo { x: 3 } - } -} - -pub fn main() { - let x = Foo::new(); - println!("{}", x.x); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/assignability-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/assignability-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/assignability-trait.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/assignability-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -// Copyright 2012-4 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// Tests that type assignability is used to search for instances when -// making method calls, but only if there aren't any matches without -// it. - -trait iterable { - fn iterate(&self, blk: F) -> bool where F: FnMut(&A) -> bool; -} - -impl<'a,A> iterable for &'a [A] { - fn iterate(&self, f: F) -> bool where F: FnMut(&A) -> bool { - self.iter().all(f) - } -} - -impl iterable for Vec { - fn iterate(&self, f: F) -> bool where F: FnMut(&A) -> bool { - self.iter().all(f) - } -} - -fn length>(x: T) -> usize { - let mut len = 0; - x.iterate(|_y| { - len += 1; - true - }); - return len; -} - -pub fn main() { - let x: Vec = vec![0,1,2,3]; - // Call a method - x.iterate(|y| { assert_eq!(x[*y as usize], *y); true }); - // Call a parameterized function - assert_eq!(length(x.clone()), x.len()); - // Call a parameterized function, with type arguments that require - // a borrow - assert_eq!(length::(&*x), x.len()); - - // Now try it with a type that *needs* to be borrowed - let z = [0,1,2,3]; - // Call a parameterized function - assert_eq!(length::(&z), z.len()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/astconv-cycle-between-trait-and-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/astconv-cycle-between-trait-and-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/astconv-cycle-between-trait-and-type.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/astconv-cycle-between-trait-and-type.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we are able to successfully compile a setup where a trait -// (`Trait1`) references a struct (`SomeType`) which in turn -// carries a predicate that references the trait (`u32 : Trait1`, -// substituted). - -// pretty-expanded FIXME #23616 - -#![allow(dead_code)] - -trait Trait1 : Trait2> { - fn dumb(&self) { } -} - -trait Trait2 { - fn dumber(&self, _: A) { } -} - -struct SomeType - where A : Trait1 -{ - a: A -} - -impl Trait1 for u32 { } - -impl Trait2> for u32 { } - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/augmented-assignments-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/augmented-assignments-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/augmented-assignments-trait.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/augmented-assignments-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::ops::AddAssign; - -struct Int(i32); - -impl AddAssign for Int { - fn add_assign(&mut self, _: Int) { - unimplemented!() - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/auto-traits.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/auto-traits.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/auto-traits.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/auto-traits.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(optin_builtin_traits)] - -auto trait Auto {} -unsafe auto trait AutoUnsafe {} - -impl !Auto for bool {} -impl !AutoUnsafe for bool {} - -struct AutoBool(bool); - -impl Auto for AutoBool {} -unsafe impl AutoUnsafe for AutoBool {} - -fn take_auto(_: T) {} -fn take_auto_unsafe(_: T) {} - -fn main() { - // Parse inside functions. - auto trait AutoInner {} - unsafe auto trait AutoUnsafeInner {} - - take_auto(0); - take_auto(AutoBool(true)); - take_auto_unsafe(0); - take_auto_unsafe(AutoBool(true)); - - /// Auto traits are allowed in trait object bounds. - let _: &(Send + Auto) = &0; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/anon_trait_static_method_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/anon_trait_static_method_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/anon_trait_static_method_lib.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/anon_trait_static_method_lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct Foo { - pub x: isize -} - -impl Foo { - pub fn new() -> Foo { - Foo { x: 3 } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/go_trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/go_trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/go_trait.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/go_trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(specialization)] - -// Common code used for tests that model the Fn/FnMut/FnOnce hierarchy. - -pub trait Go { - fn go(&self, arg: isize); -} - -pub fn go(this: &G, arg: isize) { - this.go(arg) -} - -pub trait GoMut { - fn go_mut(&mut self, arg: isize); -} - -pub fn go_mut(this: &mut G, arg: isize) { - this.go_mut(arg) -} - -pub trait GoOnce { - fn go_once(self, arg: isize); -} - -pub fn go_once(this: G, arg: isize) { - this.go_once(arg) -} - -impl GoMut for G - where G : Go -{ - default fn go_mut(&mut self, arg: isize) { - go(&*self, arg) - } -} - -impl GoOnce for G - where G : GoMut -{ - default fn go_once(mut self, arg: isize) { - go_mut(&mut self, arg) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_default_method_xc_aux_2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_default_method_xc_aux_2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_default_method_xc_aux_2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_default_method_xc_aux_2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:trait_default_method_xc_aux.rs - -extern crate trait_default_method_xc_aux as aux; -use aux::A; - -pub struct a_struct { pub x: isize } - -impl A for a_struct { - fn f(&self) -> isize { 10 } -} - -// This function will need to get inlined, and badness may result. -pub fn welp(x: A) -> A { - let a = a_struct { x: 0 }; - a.g(); - x -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_default_method_xc_aux.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_default_method_xc_aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_default_method_xc_aux.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_default_method_xc_aux.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct Something { pub x: isize } - -pub trait A { - fn f(&self) -> isize; - fn g(&self) -> isize { 10 } - fn h(&self) -> isize { 11 } - fn lurr(x: &Self, y: &Self) -> isize { x.g() + y.h() } -} - - -impl A for isize { - fn f(&self) -> isize { 10 } -} - -impl A for Something { - fn f(&self) -> isize { 10 } -} - -pub trait B { - fn thing(&self, x: T, y: U) -> (T, U) { (x, y) } - fn staticthing(_z: &Self, x: T, y: U) -> (T, U) { (x, y) } -} - -impl B for isize { } -impl B for bool { } - - - -pub trait TestEquality { - fn test_eq(&self, rhs: &Self) -> bool; - fn test_neq(&self, rhs: &Self) -> bool { - !self.test_eq(rhs) - } -} - -impl TestEquality for isize { - fn test_eq(&self, rhs: &isize) -> bool { - *self == *rhs - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/traitimpl.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/traitimpl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/traitimpl.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/traitimpl.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test inherent trait impls work cross-crait. - -pub trait Bar<'a> : 'a {} - -impl<'a> Bar<'a> { - pub fn bar(&self) {} -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_inheritance_auto_xc_2_aux.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_inheritance_auto_xc_2_aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_inheritance_auto_xc_2_aux.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_inheritance_auto_xc_2_aux.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub trait Foo { fn f(&self) -> isize; } -pub trait Bar { fn g(&self) -> isize; } -pub trait Baz { fn h(&self) -> isize; } - -pub struct A { pub x: isize } - -impl Foo for A { fn f(&self) -> isize { 10 } } -impl Bar for A { fn g(&self) -> isize { 20 } } -impl Baz for A { fn h(&self) -> isize { 30 } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_inheritance_auto_xc_aux.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_inheritance_auto_xc_aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_inheritance_auto_xc_aux.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_inheritance_auto_xc_aux.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub trait Foo { fn f(&self) -> isize; } -pub trait Bar { fn g(&self) -> isize; } -pub trait Baz { fn h(&self) -> isize; } - -pub trait Quux: Foo + Bar + Baz { } - -impl Quux for T { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_inheritance_overloading_xc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_inheritance_overloading_xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_inheritance_overloading_xc.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_inheritance_overloading_xc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::cmp::PartialEq; -use std::ops::{Add, Sub, Mul}; - -pub trait MyNum : Add + Sub + Mul + PartialEq + Clone { -} - -#[derive(Clone, Debug)] -pub struct MyInt { - pub val: isize -} - -impl Add for MyInt { - type Output = MyInt; - - fn add(self, other: MyInt) -> MyInt { mi(self.val + other.val) } -} - -impl Sub for MyInt { - type Output = MyInt; - - fn sub(self, other: MyInt) -> MyInt { mi(self.val - other.val) } -} - -impl Mul for MyInt { - type Output = MyInt; - - fn mul(self, other: MyInt) -> MyInt { mi(self.val * other.val) } -} - -impl PartialEq for MyInt { - fn eq(&self, other: &MyInt) -> bool { self.val == other.val } - - fn ne(&self, other: &MyInt) -> bool { !self.eq(other) } -} - -impl MyNum for MyInt {} - -fn mi(v: isize) -> MyInt { MyInt { val: v } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_safety_lib.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_safety_lib.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_safety_lib.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_safety_lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Simple smoke test that unsafe traits can be compiled etc. - -pub unsafe trait Foo { - fn foo(&self) -> isize; -} - -unsafe impl Foo for isize { - fn foo(&self) -> isize { *self } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_xc_call_aux.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_xc_call_aux.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_xc_call_aux.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/auxiliary/trait_xc_call_aux.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -pub trait Foo { - fn f(&self) -> isize; -} - -pub struct A { - pub x: isize -} - -impl Foo for A { - fn f(&self) -> isize { 10 } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/conservative_impl_trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/conservative_impl_trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/conservative_impl_trait.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/conservative_impl_trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// #39665 - -fn batches(n: &u32) -> impl Iterator { - std::iter::once(n) -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/cycle-trait-type-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/cycle-trait-type-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/cycle-trait-type-trait.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/cycle-trait-type-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test a case where a supertrait references a type that references -// the original trait. This poses no problem at the moment. - -// pretty-expanded FIXME #23616 - -trait Chromosome: Get> { -} - -trait Get { - fn get(&self) -> A; -} - -struct Struct { c: C } - -impl Chromosome for i32 { } - -impl Get> for i32 { - fn get(&self) -> Struct { - Struct { c: *self } - } -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/default-method-supertrait-vtable.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/default-method-supertrait-vtable.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/default-method-supertrait-vtable.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/default-method-supertrait-vtable.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -// Tests that we can call a function bounded over a supertrait from -// a default method - -fn require_y(x: T) -> isize { x.y() } - -trait Y { - fn y(self) -> isize; -} - - -trait Z: Y + Sized { - fn x(self) -> isize { - require_y(self) - } -} - -impl Y for isize { - fn y(self) -> isize { self } -} - -impl Z for isize {} - -pub fn main() { - assert_eq!(12.x(), 12); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/dyn-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/dyn-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/dyn-trait.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/dyn-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-pretty `dyn ::foo` parses differently in the current edition - -use std::fmt::Display; - -static BYTE: u8 = 33; - -fn main() { - let x: &(dyn 'static + Display) = &BYTE; - let y: Box = Box::new(BYTE); - let _: &dyn (Display) = &BYTE; - let _: &dyn (::std::fmt::Display) = &BYTE; - let xstr = format!("{}", x); - let ystr = format!("{}", y); - assert_eq!(xstr, "33"); - assert_eq!(ystr, "33"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/fmt-pointer-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/fmt-pointer-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/fmt-pointer-trait.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/fmt-pointer-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::ptr; -use std::rc::Rc; -use std::sync::Arc; - -fn main() { - let p: *const u8 = ptr::null(); - let rc = Rc::new(1usize); - let arc = Arc::new(1usize); - let b = Box::new("hi"); - - let _ = format!("{:p}{:p}{:p}", - rc, arc, b); - - if cfg!(target_pointer_width = "32") { - assert_eq!(format!("{:#p}", p), - "0x00000000"); - } else { - assert_eq!(format!("{:#p}", p), - "0x0000000000000000"); - } - assert_eq!(format!("{:p}", p), - "0x0"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/impl-implicit-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/impl-implicit-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/impl-implicit-trait.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/impl-implicit-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -enum option_ { - none_, - some_(T), -} - -impl option_ { - pub fn foo(&self) -> bool { true } -} - -enum option__ { - none__, - some__(isize) -} - -impl option__ { - pub fn foo(&self) -> bool { true } -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/impl-inherent-prefer-over-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/impl-inherent-prefer-over-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/impl-inherent-prefer-over-trait.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/impl-inherent-prefer-over-trait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct Foo; - -trait Trait { - fn bar(&self); -} - -// Inherent impls should be preferred over trait ones. -impl Foo { - fn bar(&self) {} -} - -impl Trait { - fn baz(_: &Foo) {} -} - -impl Trait for Foo { - fn bar(&self) { panic!("wrong method called!") } -} - -fn main() { - Foo.bar(); - Foo::bar(&Foo); - ::bar(&Foo); - - // Should work even if Trait::baz doesn't exist. - // N.B: `::bar` would be ambiguous. - ::baz(&Foo); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/infer-from-object-trait-issue-26952.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/infer-from-object-trait-issue-26952.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/infer-from-object-trait-issue-26952.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/infer-from-object-trait-issue-26952.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that when we match a trait reference like `Foo: Foo<_#0t>`, -// we unify with `_#0t` with `A`. In this code, if we failed to do -// that, then you get an unconstrained type-variable in `call`. -// -// Also serves as a regression test for issue #26952, though the test -// was derived from another reported regression with the same cause. - -use std::marker::PhantomData; - -trait Trait { fn foo(&self); } - -struct Type { a: PhantomData } - -fn as_trait(t: &Type) -> &Trait { loop { } } - -fn want+?Sized>(t: &T) { } - -fn call(p: Type) { - let q = as_trait(&p); - want(q); // parameter A to `want` *would* be unconstrained -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/inherent-trait-method-order.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/inherent-trait-method-order.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/inherent-trait-method-order.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/inherent-trait-method-order.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -struct Foo; - -impl Foo { - #[allow(dead_code)] - fn foo(self) { - panic!("wrong method!") - } -} - -trait Trait { - fn foo(self); -} - -impl<'a,'b,'c> Trait for &'a &'b &'c Foo { - fn foo(self) { - // ok - } -} - -fn main() { - let x = &(&(&Foo)); - x.foo(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/kindck-owned-trait-contains-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/kindck-owned-trait-contains-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/kindck-owned-trait-contains-1.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/kindck-owned-trait-contains-1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_snake_case)] -#![allow(non_camel_case_types)] - -#![feature(box_syntax)] - -trait repeat { fn get(&self) -> A; } - -impl repeat for Box { - fn get(&self) -> A { - (**self).clone() - } -} - -fn repeater(v: Box) -> Box+'static> { - box v as Box+'static> // No -} - -pub fn main() { - let x = 3; - let y = repeater(box x); - assert_eq!(x, y.get()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/multiple-trait-bounds.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/multiple-trait-bounds.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/multiple-trait-bounds.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/multiple-trait-bounds.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn f(_: T) { -} - -pub fn main() { - f(3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/object-one-type-two-traits.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/object-one-type-two-traits.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/object-one-type-two-traits.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/object-one-type-two-traits.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Testing creating two vtables with the same self type, but different -// traits. - -#![feature(box_syntax)] - -use std::any::Any; - -trait Wrap { - fn get(&self) -> isize; - fn wrap(self: Box) -> Box; -} - -impl Wrap for isize { - fn get(&self) -> isize { - *self - } - fn wrap(self: Box) -> Box { - self as Box - } -} - -fn is(x: &Any) -> bool { - x.is::() -} - -fn main() { - let x = box 22isize as Box; - println!("x={}", x.get()); - let y = x.wrap(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/overlap-permitted-for-marker-traits-neg.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/overlap-permitted-for-marker-traits-neg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/overlap-permitted-for-marker-traits-neg.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/overlap-permitted-for-marker-traits-neg.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(overlapping_marker_traits)] -#![feature(optin_builtin_traits)] - -// Overlapping negative impls for `MyStruct` are permitted: -struct MyStruct; -impl !Send for MyStruct {} -impl !Send for MyStruct {} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/overlap-permitted-for-marker-traits.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/overlap-permitted-for-marker-traits.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/overlap-permitted-for-marker-traits.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/overlap-permitted-for-marker-traits.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests for RFC 1268: we allow overlapping impls of marker traits, -// that is, traits without items. In this case, a type `T` is -// `MyMarker` if it is either `Debug` or `Display`. - -#![feature(overlapping_marker_traits)] -#![feature(optin_builtin_traits)] - -use std::fmt::{Debug, Display}; - -trait MyMarker {} - -impl MyMarker for T {} -impl MyMarker for T {} - -fn foo(t: T) -> T { - t -} - -fn main() { - // Debug && Display: - assert_eq!(1, foo(1)); - assert_eq!(2.0, foo(2.0)); - - // Debug && !Display: - assert_eq!(vec![1], foo(vec![1])); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/parameterized-trait-with-bounds.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/parameterized-trait-with-bounds.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/parameterized-trait-with-bounds.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/parameterized-trait-with-bounds.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![allow(dead_code)] - - -trait A { fn get(self) -> T; } -trait B { fn get(self) -> (T,U); } -trait C<'a, U> { fn get(self) -> &'a U; } - -mod foo { - pub trait D<'a, T> { fn get(self) -> &'a T; } -} - -fn foo1(_: &(A + Send)) {} -fn foo2(_: Box + Send + Sync>) {} -fn foo3(_: Box + 'static>) {} -fn foo4<'a, T>(_: Box + 'static + Send>) {} -fn foo5<'a, T>(_: Box + 'static + Send>) {} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/supertrait-default-generics.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/supertrait-default-generics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/supertrait-default-generics.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/supertrait-default-generics.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_snake_case)] - -// There is some other borrowck bug, so we make the stuff not mut. - - -use std::ops::Add; - -trait Positioned { - fn SetX(&mut self, _: S); - fn X(&self) -> S; -} - -trait Movable>: Positioned { - fn translate(&mut self, dx: S) { - let x = self.X() + dx; - self.SetX(x); - } -} - -struct Point { x: S, y: S } - -impl Positioned for Point { - fn SetX(&mut self, x: S) { - self.x = x; - } - fn X(&self) -> S { - self.x.clone() - } -} - -impl> Movable for Point {} - -pub fn main() { - let mut p = Point{ x: 1, y: 2}; - p.translate(3); - assert_eq!(p.X(), 4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/syntax-trait-polarity.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/syntax-trait-polarity.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/syntax-trait-polarity.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/syntax-trait-polarity.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(optin_builtin_traits)] - -struct TestType; - -impl TestType {} - -trait TestTrait {} - -impl !Send for TestType {} - -struct TestType2(T); - -impl TestType2 {} - -impl !Send for TestType2 {} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds-basic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds-basic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds-basic.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds-basic.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(unconditional_recursion)] - -// pretty-expanded FIXME #23616 - -trait Foo { -} - -fn b(_x: Box) { -} - -fn c(x: Box) { - e(x); -} - -fn d(x: Box) { - e(x); -} - -fn e(x: Box) { - e(x); -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds-impl-comparison-duplicates.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds-impl-comparison-duplicates.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds-impl-comparison-duplicates.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds-impl-comparison-duplicates.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests that type parameter bounds on an implementation need not match the -// trait exactly, as long as the implementation doesn't demand *more* bounds -// than the trait. - -// pretty-expanded FIXME #23616 - -trait A { - fn foo(&self); -} - -impl A for isize { - fn foo(&self) {} // Ord implies Eq, so this is ok. -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds-in-arc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds-in-arc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds-in-arc.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds-in-arc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,118 +0,0 @@ -// Copyright 2013-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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests that a heterogeneous list of existential types can be put inside an Arc -// and shared between threads as long as all types fulfill Send. - -// ignore-emscripten no threads support - -#![feature(box_syntax)] - -use std::sync::Arc; -use std::sync::mpsc::channel; -use std::thread; - -trait Pet { - fn name(&self, blk: Box); - fn num_legs(&self) -> usize; - fn of_good_pedigree(&self) -> bool; -} - -struct Catte { - num_whiskers: usize, - name: String, -} - -struct Dogge { - bark_decibels: usize, - tricks_known: usize, - name: String, -} - -struct Goldfyshe { - swim_speed: usize, - name: String, -} - -impl Pet for Catte { - fn name(&self, mut blk: Box) { blk(&self.name) } - fn num_legs(&self) -> usize { 4 } - fn of_good_pedigree(&self) -> bool { self.num_whiskers >= 4 } -} -impl Pet for Dogge { - fn name(&self, mut blk: Box) { blk(&self.name) } - fn num_legs(&self) -> usize { 4 } - fn of_good_pedigree(&self) -> bool { - self.bark_decibels < 70 || self.tricks_known > 20 - } -} -impl Pet for Goldfyshe { - fn name(&self, mut blk: Box) { blk(&self.name) } - fn num_legs(&self) -> usize { 0 } - fn of_good_pedigree(&self) -> bool { self.swim_speed >= 500 } -} - -pub fn main() { - let catte = Catte { num_whiskers: 7, name: "alonzo_church".to_string() }; - let dogge1 = Dogge { - bark_decibels: 100, - tricks_known: 42, - name: "alan_turing".to_string(), - }; - let dogge2 = Dogge { - bark_decibels: 55, - tricks_known: 11, - name: "albert_einstein".to_string(), - }; - let fishe = Goldfyshe { - swim_speed: 998, - name: "alec_guinness".to_string(), - }; - let arc = Arc::new(vec![box catte as Box, - box dogge1 as Box, - box fishe as Box, - box dogge2 as Box]); - let (tx1, rx1) = channel(); - let arc1 = arc.clone(); - let t1 = thread::spawn(move|| { check_legs(arc1); tx1.send(()); }); - let (tx2, rx2) = channel(); - let arc2 = arc.clone(); - let t2 = thread::spawn(move|| { check_names(arc2); tx2.send(()); }); - let (tx3, rx3) = channel(); - let arc3 = arc.clone(); - let t3 = thread::spawn(move|| { check_pedigree(arc3); tx3.send(()); }); - rx1.recv(); - rx2.recv(); - rx3.recv(); - t1.join(); - t2.join(); - t3.join(); -} - -fn check_legs(arc: Arc>>) { - let mut legs = 0; - for pet in arc.iter() { - legs += pet.num_legs(); - } - assert!(legs == 12); -} -fn check_names(arc: Arc>>) { - for pet in arc.iter() { - pet.name(Box::new(|name| { - assert!(name.as_bytes()[0] == 'a' as u8 && name.as_bytes()[1] == 'l' as u8); - })) - } -} -fn check_pedigree(arc: Arc>>) { - for pet in arc.iter() { - assert!(pet.of_good_pedigree()); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds-on-structs-and-enums.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds-on-structs-and-enums.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds-on-structs-and-enums.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds-on-structs-and-enums.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait U {} -trait T { fn get(self) -> X; } - -trait S2 { - fn m(x: Box+'static>) {} -} - -struct St { - f: Box+'static>, -} - -impl St { - fn blah() {} -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds-recursion.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds-recursion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds-recursion.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds-recursion.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait I { fn i(&self) -> Self; } - -trait A { - fn id(x:T) -> T { x.i() } -} - -trait J { fn j(&self) -> T; } - -trait B> { - fn id(x:T) -> T { x.j() } -} - -trait C { - fn id>(x:T) -> T { x.j() } -} - -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-bounds.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] - -trait connection { - fn read(&self) -> isize; -} - -trait connection_factory { - fn create(&self) -> C; -} - -type my_connection = (); -type my_connection_factory = (); - -impl connection for () { - fn read(&self) -> isize { 43 } -} - -impl connection_factory for my_connection_factory { - fn create(&self) -> my_connection { () } -} - -pub fn main() { - let factory = (); - let connection = factory.create(); - let result = connection.read(); - assert_eq!(result, 43); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-cache-issue-18209.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-cache-issue-18209.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-cache-issue-18209.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-cache-issue-18209.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that the cache results from the default method do not pollute -// the cache for the later call in `load()`. -// -// See issue #18209. - -// pretty-expanded FIXME #23616 - -pub trait Foo { - fn load_from() -> Box; - fn load() -> Box { - Foo::load_from() - } -} - -pub fn load() -> Box { - Foo::load() -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-coercion-generic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-coercion-generic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-coercion-generic.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-coercion-generic.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Trait { - fn f(&self, x: T); -} - -#[derive(Copy, Clone)] -struct Struct { - x: isize, - y: isize, -} - -impl Trait<&'static str> for Struct { - fn f(&self, x: &'static str) { - println!("Hi, {}!", x); - } -} - -pub fn main() { - let a = Struct { x: 1, y: 2 }; - let b: Box> = Box::new(a); - b.f("Mary"); - let c: &Trait<&'static str> = &a; - c.f("Joe"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-coercion.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-coercion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-coercion.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-coercion.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -use std::io::{self, Write}; - -trait Trait { - fn f(&self); -} - -#[derive(Copy, Clone)] -struct Struct { - x: isize, - y: isize, -} - -impl Trait for Struct { - fn f(&self) { - println!("Hi!"); - } -} - -fn foo(mut a: Box) {} - -pub fn main() { - let a = Struct { x: 1, y: 2 }; - let b: Box = Box::new(a); - b.f(); - let c: &Trait = &a; - c.f(); - - let out = io::stdout(); - foo(Box::new(out)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-composition-trivial.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-composition-trivial.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-composition-trivial.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-composition-trivial.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait Foo { - fn foo(&self); -} - -trait Bar : Foo { - fn bar(&self); -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-copy-guessing.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-copy-guessing.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-copy-guessing.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-copy-guessing.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// "guessing" in trait selection can affect `copy_or_move`. Check that this -// is correctly handled. I am not sure what is the "correct" behaviour, -// but we should at least not ICE. - -use std::mem; - -struct U([u8; 1337]); - -struct S<'a,T:'a>(&'a T); -impl<'a, T> Clone for S<'a, T> { fn clone(&self) -> Self { S(self.0) } } -/// This impl triggers inference "guessing" - S<_>: Copy => _ = U -impl<'a> Copy for S<'a, Option> {} - -fn assert_impls_fnR>(_: &T){} - -fn main() { - let n = None; - let e = S(&n); - let f = || { - // S being copy is critical for this to work - drop(e); - mem::size_of_val(e.0) - }; - assert_impls_fn(&f); - assert_eq!(f(), 1337+1); - - assert_eq!((|| { - // S being Copy is not critical here, but - // we check it anyway. - let n = None; - let e = S(&n); - let ret = mem::size_of_val(e.0); - drop(e); - ret - })(), 1337+1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-bound.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-bound.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -trait A { - fn g(&self) -> isize { 10 } -} - -impl A for isize { } - -fn f(i: T) { - assert_eq!(i.g(), 10); -} - -pub fn main () { - f(0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-bound-subst2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-bound-subst2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-bound-subst2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-bound-subst2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -trait A { - fn g(&self, x: T) -> T { x } -} - -impl A for isize { } - -fn f>(i: V, j: T) -> T { - i.g(j) -} - -pub fn main () { - assert_eq!(f(0, 2), 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-bound-subst3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-bound-subst3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-bound-subst3.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-bound-subst3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -trait A { - fn g(&self, x: T, y: T) -> (T, T) { (x, y) } -} - -impl A for isize { } - -fn f(i: V, j: T, k: T) -> (T, T) { - i.g(j, k) -} - -pub fn main () { - assert_eq!(f(0, 1, 2), (1, 2)); - assert_eq!(f(0, 1u8, 2u8), (1u8, 2u8)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-bound-subst4.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-bound-subst4.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-bound-subst4.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-bound-subst4.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -trait A { - fn g(&self, x: usize) -> usize { x } - fn h(&self, x: T) { } -} - -impl A for isize { } - -fn f>(i: V, j: usize) -> usize { - i.g(j) -} - -pub fn main () { - assert_eq!(f::(0, 2), 2); - assert_eq!(f::(0, 2), 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-bound-subst.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-bound-subst.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-bound-subst.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-bound-subst.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -trait A { - fn g(&self, x: T, y: U) -> (T, U) { (x, y) } -} - -impl A for i32 { } -impl A for u32 { } - -fn f>(i: V, j: T, k: U) -> (T, U) { - i.g(j, k) -} - -pub fn main () { - assert_eq!(f(0, 1, 2), (1, 2)); - assert_eq!(f(0, 1, 2), (1, 2)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-xc-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-xc-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-xc-2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-xc-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:trait_default_method_xc_aux.rs -// aux-build:trait_default_method_xc_aux_2.rs - - - -extern crate trait_default_method_xc_aux as aux; -extern crate trait_default_method_xc_aux_2 as aux2; -use aux::A; -use aux2::{a_struct, welp}; - - -pub fn main () { - - let a = a_struct { x: 0 }; - let b = a_struct { x: 1 }; - - assert_eq!(0.g(), 10); - assert_eq!(a.g(), 10); - assert_eq!(a.h(), 11); - assert_eq!(b.g(), 10); - assert_eq!(b.h(), 11); - assert_eq!(A::lurr(&a, &b), 21); - - welp(&0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-xc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-xc.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-default-method-xc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,90 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// aux-build:trait_default_method_xc_aux.rs - - -extern crate trait_default_method_xc_aux as aux; -use aux::{A, TestEquality, Something}; -use aux::B; - -fn f(i: T) { - assert_eq!(i.g(), 10); -} - -fn welp(i: isize, _x: &T) -> isize { - i.g() -} - -mod stuff { - pub struct thing { pub x: isize } -} - -impl A for stuff::thing { - fn f(&self) -> isize { 10 } -} - -fn g>(i: V, j: T, k: U) -> (T, U) { - i.thing(j, k) -} - -fn eq(lhs: &T, rhs: &T) -> bool { - lhs.test_eq(rhs) -} -fn neq(lhs: &T, rhs: &T) -> bool { - lhs.test_neq(rhs) -} - - -impl TestEquality for stuff::thing { - fn test_eq(&self, rhs: &stuff::thing) -> bool { - //self.x.test_eq(&rhs.x) - eq(&self.x, &rhs.x) - } -} - - -pub fn main() { - // Some tests of random things - f(0); - - assert_eq!(A::lurr(&0, &1), 21); - - let a = stuff::thing { x: 0 }; - let b = stuff::thing { x: 1 }; - let c = Something { x: 1 }; - - assert_eq!(0.g(), 10); - assert_eq!(a.g(), 10); - assert_eq!(a.h(), 11); - assert_eq!(c.h(), 11); - - assert_eq!(0.thing(3.14f64, 1), (3.14f64, 1)); - assert_eq!(B::staticthing(&0, 3.14f64, 1), (3.14f64, 1)); - assert_eq!(B::::staticthing::(&0, 3.14, 1), (3.14, 1)); - - assert_eq!(g(0, 3.14f64, 1), (3.14f64, 1)); - assert_eq!(g(false, 3.14f64, 1), (3.14, 1)); - - - // Trying out a real one - assert!(12.test_neq(&10)); - assert!(!10.test_neq(&10)); - assert!(a.test_neq(&b)); - assert!(!a.test_neq(&a)); - - assert!(neq(&12, &10)); - assert!(!neq(&10, &10)); - assert!(neq(&a, &b)); - assert!(!neq(&a, &a)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-false-ambiguity-where-clause-builtin-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-false-ambiguity-where-clause-builtin-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-false-ambiguity-where-clause-builtin-bound.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-false-ambiguity-where-clause-builtin-bound.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we do not error out because of a (False) ambiguity -// between the builtin rules for Sized and the where clause. Issue -// #20959. - -// pretty-expanded FIXME #23616 - -fn foo(x: Option) - where Option : Sized -{ - let _y = x; -} - -fn main() { - foo(Some(22)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-generic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-generic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-generic.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-generic.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - - -trait to_str { - fn to_string_(&self) -> String; -} -impl to_str for isize { - fn to_string_(&self) -> String { self.to_string() } -} -impl to_str for String { - fn to_string_(&self) -> String { self.clone() } -} -impl to_str for () { - fn to_string_(&self) -> String { "()".to_string() } -} - -trait map { - fn map(&self, f: F) -> Vec where F: FnMut(&T) -> U; -} -impl map for Vec { - fn map(&self, mut f: F) -> Vec where F: FnMut(&T) -> U { - let mut r = Vec::new(); - for i in self { - r.push(f(i)); - } - r - } -} - -fn foo>(x: T) -> Vec { - x.map(|_e| "hi".to_string() ) -} -fn bar>(x: T) -> Vec { - x.map(|_e| _e.to_string_() ) -} - -pub fn main() { - assert_eq!(foo(vec![1]), ["hi".to_string()]); - assert_eq!(bar:: >(vec![4, 5]), ["4".to_string(), "5".to_string()]); - assert_eq!(bar:: >(vec!["x".to_string(), "y".to_string()]), - ["x".to_string(), "y".to_string()]); - assert_eq!(bar::<(), Vec<()>>(vec![()]), ["()".to_string()]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-impl-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-impl-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-impl-2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-impl-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_snake_case)] - -// pretty-expanded FIXME #23616 - -pub mod Foo { - pub trait Trait { - fn foo(&self); - } -} - -mod Bar { - impl<'a> ::Foo::Trait+'a { - fn bar(&self) { self.foo() } - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-impl.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-impl.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test calling methods on an impl for a bare trait. - -// aux-build:traitimpl.rs - -extern crate traitimpl; -use traitimpl::Bar; - -static mut COUNT: usize = 1; - -trait T { - fn t(&self) {} -} - -impl<'a> T+'a { - fn foo(&self) { - unsafe { COUNT *= 2; } - } - fn bar() { - unsafe { COUNT *= 3; } - } -} - -impl T for isize {} - -struct Foo; -impl<'a> Bar<'a> for Foo {} - -fn main() { - let x: &T = &42; - - x.foo(); - T::foo(x); - T::bar(); - - unsafe { assert_eq!(COUNT, 12); } - - // Cross-crait case - let x: &Bar = &Foo; - x.bar(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait Foo { fn f(&self) -> isize; } -trait Bar { fn g(&self) -> isize; } -trait Baz { fn h(&self) -> isize; } - -trait Quux: Foo + Bar + Baz { } - -struct A { x: isize } - -impl Foo for A { fn f(&self) -> isize { 10 } } -impl Bar for A { fn g(&self) -> isize { 20 } } -impl Baz for A { fn h(&self) -> isize { 30 } } -impl Quux for A {} - -fn f(a: &T) { - assert_eq!(a.f(), 10); - assert_eq!(a.g(), 20); - assert_eq!(a.h(), 30); -} - -pub fn main() { - let a = &A { x: 3 }; - f(a); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-auto.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-auto.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-auto.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-auto.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Testing that this impl turns A into a Quux, because -// A is already a Foo Bar Baz - -impl Quux for T { } - -trait Foo { fn f(&self) -> isize; } -trait Bar { fn g(&self) -> isize; } -trait Baz { fn h(&self) -> isize; } - -trait Quux: Foo + Bar + Baz { } - -struct A { x: isize } - -impl Foo for A { fn f(&self) -> isize { 10 } } -impl Bar for A { fn g(&self) -> isize { 20 } } -impl Baz for A { fn h(&self) -> isize { 30 } } - -fn f(a: &T) { - assert_eq!(a.f(), 10); - assert_eq!(a.g(), 20); - assert_eq!(a.h(), 30); -} - -pub fn main() { - let a = &A { x: 3 }; - f(a); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-auto-xc-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-auto-xc-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-auto-xc-2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-auto-xc-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:trait_inheritance_auto_xc_2_aux.rs - - -extern crate trait_inheritance_auto_xc_2_aux as aux; - -// aux defines impls of Foo, Bar and Baz for A -use aux::{Foo, Bar, Baz, A}; - -// We want to extend all Foo, Bar, Bazes to Quuxes -pub trait Quux: Foo + Bar + Baz { } -impl Quux for T { } - -fn f(a: &T) { - assert_eq!(a.f(), 10); - assert_eq!(a.g(), 20); - assert_eq!(a.h(), 30); -} - -pub fn main() { - let a = &A { x: 3 }; - f(a); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-auto-xc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-auto-xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-auto-xc.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-auto-xc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:trait_inheritance_auto_xc_aux.rs - - -extern crate trait_inheritance_auto_xc_aux as aux; - -use aux::{Foo, Bar, Baz, Quux}; - -struct A { x: isize } - -impl Foo for A { fn f(&self) -> isize { 10 } } -impl Bar for A { fn g(&self) -> isize { 20 } } -impl Baz for A { fn h(&self) -> isize { 30 } } - -fn f(a: &T) { - assert_eq!(a.f(), 10); - assert_eq!(a.g(), 20); - assert_eq!(a.h(), 30); -} - -pub fn main() { - let a = &A { x: 3 }; - f(a); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-call-bound-inherited2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-call-bound-inherited2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-call-bound-inherited2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-call-bound-inherited2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait Foo { fn f(&self) -> isize; } -trait Bar : Foo { fn g(&self) -> isize; } -trait Baz : Bar { fn h(&self) -> isize; } - -struct A { x: isize } - -impl Foo for A { fn f(&self) -> isize { 10 } } -impl Bar for A { fn g(&self) -> isize { 20 } } -impl Baz for A { fn h(&self) -> isize { 30 } } - -// Call a function on Foo, given a T: Baz, -// which is inherited via Bar -fn gg(a: &T) -> isize { - a.f() -} - -pub fn main() { - let a = &A { x: 3 }; - assert_eq!(gg(a), 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-call-bound-inherited.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-call-bound-inherited.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-call-bound-inherited.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-call-bound-inherited.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait Foo { fn f(&self) -> isize; } -trait Bar : Foo { fn g(&self) -> isize; } - -struct A { x: isize } - -impl Foo for A { fn f(&self) -> isize { 10 } } -impl Bar for A { fn g(&self) -> isize { 20 } } - -// Call a function on Foo, given a T: Bar -fn gg(a: &T) -> isize { - a.f() -} - -pub fn main() { - let a = &A { x: 3 }; - assert_eq!(gg(a), 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-cast.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-cast.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-cast.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-cast.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Testing that supertrait methods can be called on subtrait object types - - -trait Foo { - fn f(&self) -> isize; -} - -trait Bar : Foo { - fn g(&self) -> isize; -} - -struct A { - x: isize -} - -impl Foo for A { - fn f(&self) -> isize { 10 } -} - -impl Bar for A { - fn g(&self) -> isize { 20 } -} - -pub fn main() { - let a = &A { x: 3 }; - let afoo = a as &Foo; - let abar = a as &Bar; - assert_eq!(afoo.f(), 10); - assert_eq!(abar.g(), 20); - assert_eq!(abar.f(), 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-cast-without-call-to-supertrait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-cast-without-call-to-supertrait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-cast-without-call-to-supertrait.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-cast-without-call-to-supertrait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Testing that we can cast to a subtrait and call subtrait -// methods. Not testing supertrait methods - - -trait Foo { - fn f(&self) -> isize; -} - -trait Bar : Foo { - fn g(&self) -> isize; -} - -struct A { - x: isize -} - -impl Foo for A { - fn f(&self) -> isize { 10 } -} - -impl Bar for A { - fn g(&self) -> isize { 20 } -} - -pub fn main() { - let a = &A { x: 3 }; - let afoo = a as &Foo; - let abar = a as &Bar; - assert_eq!(afoo.f(), 10); - assert_eq!(abar.g(), 20); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-cross-trait-call.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-cross-trait-call.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-cross-trait-call.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-cross-trait-call.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait Foo { fn f(&self) -> isize; } -trait Bar : Foo { fn g(&self) -> isize; } - -struct A { x: isize } - -impl Foo for A { fn f(&self) -> isize { 10 } } - -impl Bar for A { - // Testing that this impl can call the impl of Foo - fn g(&self) -> isize { self.f() } -} - -pub fn main() { - let a = &A { x: 3 }; - assert_eq!(a.g(), 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-cross-trait-call-xc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-cross-trait-call-xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-cross-trait-call-xc.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-cross-trait-call-xc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:trait_xc_call_aux.rs - - -extern crate trait_xc_call_aux as aux; - -use aux::Foo; - -trait Bar : Foo { - fn g(&self) -> isize; -} - -impl Bar for aux::A { - fn g(&self) -> isize { self.f() } -} - -pub fn main() { - let a = &aux::A { x: 3 }; - assert_eq!(a.g(), 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-diamond.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-diamond.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-diamond.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-diamond.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// B and C both require A, so D does as well, twice, but that's just fine - - -trait A { fn a(&self) -> isize; } -trait B: A { fn b(&self) -> isize; } -trait C: A { fn c(&self) -> isize; } -trait D: B + C { fn d(&self) -> isize; } - -struct S { bogus: () } - -impl A for S { fn a(&self) -> isize { 10 } } -impl B for S { fn b(&self) -> isize { 20 } } -impl C for S { fn c(&self) -> isize { 30 } } -impl D for S { fn d(&self) -> isize { 40 } } - -fn f(x: &T) { - assert_eq!(x.a(), 10); - assert_eq!(x.b(), 20); - assert_eq!(x.c(), 30); - assert_eq!(x.d(), 40); -} - -pub fn main() { - let value = &S { bogus: () }; - f(value); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-multiple-inheritors.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-multiple-inheritors.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-multiple-inheritors.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-multiple-inheritors.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait A { fn a(&self) -> isize; } -trait B: A { fn b(&self) -> isize; } -trait C: A { fn c(&self) -> isize; } - -struct S { bogus: () } - -impl A for S { fn a(&self) -> isize { 10 } } -impl B for S { fn b(&self) -> isize { 20 } } -impl C for S { fn c(&self) -> isize { 30 } } - -// Both B and C inherit from A -fn f(x: &T) { - assert_eq!(x.a(), 10); - assert_eq!(x.b(), 20); - assert_eq!(x.c(), 30); -} - -pub fn main() { - f(&S { bogus: () }) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-multiple-params.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-multiple-params.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-multiple-params.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-multiple-params.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait A { fn a(&self) -> isize; } -trait B: A { fn b(&self) -> isize; } -trait C: A { fn c(&self) -> isize; } - -struct S { bogus: () } - -impl A for S { fn a(&self) -> isize { 10 } } -impl B for S { fn b(&self) -> isize { 20 } } -impl C for S { fn c(&self) -> isize { 30 } } - -// Multiple type params, multiple levels of inheritance -fn f(x: &X, y: &Y, z: &Z) { - assert_eq!(x.a(), 10); - assert_eq!(y.a(), 10); - assert_eq!(y.b(), 20); - assert_eq!(z.a(), 10); - assert_eq!(z.c(), 30); -} - -pub fn main() { - let s = &S { bogus: () }; - f(s, s, s); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num0.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num0.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num0.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num0.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Extending Num and using inherited static methods - -// pretty-expanded FIXME #23616 - -use std::cmp::PartialOrd; - -pub trait NumCast: Sized { - fn from(i: i32) -> Option; -} - -pub trait Num { - fn from_int(i: isize) -> Self; - fn gt(&self, other: &Self) -> bool; -} - -pub trait NumExt: NumCast + PartialOrd { } - -fn greater_than_one(n: &T) -> bool { - n.gt(&NumCast::from(1).unwrap()) -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num1.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num1.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub trait NumCast: Sized { - fn from(i: i32) -> Option; -} - -pub trait NumExt: NumCast + PartialOrd { } - -fn greater_than_one(n: &T) -> bool { - *n > NumCast::from(1).unwrap() -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// A more complex example of numeric extensions - -pub trait TypeExt {} - -impl TypeExt for u8 {} -impl TypeExt for u16 {} -impl TypeExt for u32 {} -impl TypeExt for u64 {} -impl TypeExt for usize {} - -impl TypeExt for i8 {} -impl TypeExt for i16 {} -impl TypeExt for i32 {} -impl TypeExt for i64 {} -impl TypeExt for isize {} - -impl TypeExt for f32 {} -impl TypeExt for f64 {} - - -pub trait NumExt: TypeExt + PartialEq + PartialOrd {} - -impl NumExt for u8 {} -impl NumExt for u16 {} -impl NumExt for u32 {} -impl NumExt for u64 {} -impl NumExt for usize {} - -impl NumExt for i8 {} -impl NumExt for i16 {} -impl NumExt for i32 {} -impl NumExt for i64 {} -impl NumExt for isize {} - -impl NumExt for f32 {} -impl NumExt for f64 {} - - -pub trait UnSignedExt: NumExt {} - -impl UnSignedExt for u8 {} -impl UnSignedExt for u16 {} -impl UnSignedExt for u32 {} -impl UnSignedExt for u64 {} -impl UnSignedExt for usize {} - - -pub trait SignedExt: NumExt {} - -impl SignedExt for i8 {} -impl SignedExt for i16 {} -impl SignedExt for i32 {} -impl SignedExt for i64 {} -impl SignedExt for isize {} - -impl SignedExt for f32 {} -impl SignedExt for f64 {} - - -pub trait IntegerExt: NumExt {} - -impl IntegerExt for u8 {} -impl IntegerExt for u16 {} -impl IntegerExt for u32 {} -impl IntegerExt for u64 {} -impl IntegerExt for usize {} - -impl IntegerExt for i8 {} -impl IntegerExt for i16 {} -impl IntegerExt for i32 {} -impl IntegerExt for i64 {} -impl IntegerExt for isize {} - - -pub trait FloatExt: NumExt {} - -impl FloatExt for f32 {} -impl FloatExt for f64 {} - - -fn test_float_ext(n: T) { println!("{}", n < n) } - -pub fn main() { - test_float_ext(1f32); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num3.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub trait NumCast: Sized { - fn from(i: i32) -> Option; -} - -pub trait NumExt: PartialEq + PartialOrd + NumCast {} - -impl NumExt for f32 {} -impl NumCast for f32 { - fn from(i: i32) -> Option { Some(i as f32) } -} - -fn num_eq_one(n: T) { - println!("{}", n == NumCast::from(1).unwrap()) -} - -pub fn main() { - num_eq_one(1f32); // you need to actually use the function to trigger the ICE -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num5.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num5.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num5.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num5.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub trait NumCast: Sized { - fn from(i: i32) -> Option; -} - -pub trait NumExt: PartialEq + NumCast {} - -impl NumExt for f32 {} -impl NumExt for isize {} - -impl NumCast for f32 { - fn from(i: i32) -> Option { Some(i as f32) } -} -impl NumCast for isize { - fn from(i: i32) -> Option { Some(i as isize) } -} - -fn num_eq_one() -> T { - NumCast::from(1).unwrap() -} - -pub fn main() { - num_eq_one::(); // you need to actually use the function to trigger the ICE -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-num.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -pub trait NumExt: PartialEq + PartialOrd {} - -pub trait FloatExt: NumExt {} - -fn greater_than_one(n: &T) -> bool { loop {} } -fn greater_than_one_float(n: &T) -> bool { loop {} } - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-overloading.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-overloading.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-overloading.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-overloading.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::cmp::PartialEq; -use std::ops::{Add, Sub, Mul}; - -trait MyNum : Add + Sub + Mul + PartialEq + Clone { } - -#[derive(Clone, Debug)] -struct MyInt { val: isize } - -impl Add for MyInt { - type Output = MyInt; - - fn add(self, other: MyInt) -> MyInt { mi(self.val + other.val) } -} - -impl Sub for MyInt { - type Output = MyInt; - - fn sub(self, other: MyInt) -> MyInt { mi(self.val - other.val) } -} - -impl Mul for MyInt { - type Output = MyInt; - - fn mul(self, other: MyInt) -> MyInt { mi(self.val * other.val) } -} - -impl PartialEq for MyInt { - fn eq(&self, other: &MyInt) -> bool { self.val == other.val } - fn ne(&self, other: &MyInt) -> bool { !self.eq(other) } -} - -impl MyNum for MyInt {} - -fn f(x: T, y: T) -> (T, T, T) { - return (x.clone() + y.clone(), x.clone() - y.clone(), x * y); -} - -fn mi(v: isize) -> MyInt { MyInt { val: v } } - -pub fn main() { - let (x, y) = (mi(3), mi(5)); - let (a, b, c) = f(x, y); - assert_eq!(a, mi(8)); - assert_eq!(b, mi(-2)); - assert_eq!(c, mi(15)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-overloading-simple.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-overloading-simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-overloading-simple.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-overloading-simple.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::cmp::PartialEq; - -trait MyNum : PartialEq { } - -#[derive(Debug)] -struct MyInt { val: isize } - -impl PartialEq for MyInt { - fn eq(&self, other: &MyInt) -> bool { self.val == other.val } - fn ne(&self, other: &MyInt) -> bool { !self.eq(other) } -} - -impl MyNum for MyInt {} - -fn f(x: T, y: T) -> bool { - return x == y; -} - -fn mi(v: isize) -> MyInt { MyInt { val: v } } - -pub fn main() { - let (x, y, z) = (mi(3), mi(5), mi(3)); - assert!(x != y); - assert_eq!(x, z); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-overloading-xc-exe.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-overloading-xc-exe.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-overloading-xc-exe.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-overloading-xc-exe.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:trait_inheritance_overloading_xc.rs - - -extern crate trait_inheritance_overloading_xc; -use trait_inheritance_overloading_xc::{MyNum, MyInt}; - -fn f(x: T, y: T) -> (T, T, T) { - return (x.clone() + y.clone(), x.clone() - y.clone(), x * y); -} - -fn mi(v: isize) -> MyInt { MyInt { val: v } } - -pub fn main() { - let (x, y) = (mi(3), mi(5)); - let (a, b, c) = f(x, y); - assert_eq!(a, mi(8)); - assert_eq!(b, mi(-2)); - assert_eq!(c, mi(15)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-self-in-supertype.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-self-in-supertype.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-self-in-supertype.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-self-in-supertype.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test for issue #4183: use of Self in supertraits. - -pub static FUZZY_EPSILON: f64 = 0.1; - -pub trait FuzzyEq { - fn fuzzy_eq(&self, other: &Self) -> bool; - fn fuzzy_eq_eps(&self, other: &Self, epsilon: &Eps) -> bool; -} - -trait Float: Sized+FuzzyEq { - fn two_pi() -> Self; -} - -impl FuzzyEq for f32 { - fn fuzzy_eq(&self, other: &f32) -> bool { - self.fuzzy_eq_eps(other, &(FUZZY_EPSILON as f32)) - } - - fn fuzzy_eq_eps(&self, other: &f32, epsilon: &f32) -> bool { - (*self - *other).abs() < *epsilon - } -} - -impl Float for f32 { - fn two_pi() -> f32 { 6.28318530717958647692528676655900576_f32 } -} - -impl FuzzyEq for f64 { - fn fuzzy_eq(&self, other: &f64) -> bool { - self.fuzzy_eq_eps(other, &(FUZZY_EPSILON as f64)) - } - - fn fuzzy_eq_eps(&self, other: &f64, epsilon: &f64) -> bool { - (*self - *other).abs() < *epsilon - } -} - -impl Float for f64 { - fn two_pi() -> f64 { 6.28318530717958647692528676655900576_f64 } -} - -fn compare(f1: F) -> bool { - let f2 = Float::two_pi(); - f1.fuzzy_eq(&f2) -} - -pub fn main() { - assert!(compare::(6.28318530717958647692528676655900576)); - assert!(compare::(6.29)); - assert!(compare::(6.3)); - assert!(compare::(6.19)); - assert!(!compare::(7.28318530717958647692528676655900576)); - assert!(!compare::(6.18)); - - assert!(compare::(6.28318530717958647692528676655900576)); - assert!(compare::(6.29)); - assert!(compare::(6.3)); - assert!(compare::(6.19)); - assert!(!compare::(7.28318530717958647692528676655900576)); - assert!(!compare::(6.18)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-self.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-self.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-self.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Foo { - fn f(&self, x: &T); -} - -trait Bar : Sized + Foo { - fn g(&self); -} - -struct S { - x: isize -} - -impl Foo for S { - fn f(&self, x: &S) { - println!("{}", x.x); - } -} - -impl Bar for S { - fn g(&self) { - self.f(self); - } -} - -pub fn main() { - let s = S { x: 1 }; - s.g(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-simple.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-simple.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-simple.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait Foo { fn f(&self) -> isize; } -trait Bar : Foo { fn g(&self) -> isize; } - -struct A { x: isize } - -impl Foo for A { fn f(&self) -> isize { 10 } } -impl Bar for A { fn g(&self) -> isize { 20 } } - -fn ff(a: &T) -> isize { - a.f() -} - -fn gg(a: &T) -> isize { - a.g() -} - -pub fn main() { - let a = &A { x: 3 }; - assert_eq!(ff(a), 10); - assert_eq!(gg(a), 20); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-static2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-static2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-static2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-static2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -pub trait MyEq {} - -pub trait MyNum { - fn from_int(_: isize) -> Self; -} - -pub trait NumExt: MyEq + MyNum { } - -struct S { v: isize } - -impl MyEq for S { } - -impl MyNum for S { - fn from_int(i: isize) -> S { - S { - v: i - } - } -} - -impl NumExt for S { } - -fn greater_than_one() -> T { MyNum::from_int(1) } - -pub fn main() { - let v: S = greater_than_one(); - assert_eq!(v.v, 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-static.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-static.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-static.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-static.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub trait MyNum { - fn from_int(_: isize) -> Self; -} - -pub trait NumExt: MyNum { } - -struct S { v: isize } - -impl MyNum for S { - fn from_int(i: isize) -> S { - S { - v: i - } - } -} - -impl NumExt for S { } - -fn greater_than_one() -> T { MyNum::from_int(1) } - -pub fn main() { - let v: S = greater_than_one(); - assert_eq!(v.v, 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-subst2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-subst2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-subst2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-subst2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -trait Panda { - fn chomp(&self, bamboo: &T) -> T; -} - -trait Add: Panda { - fn add(&self, rhs: &RHS) -> Result; -} - -trait MyNum : Sized + Add { } - -struct MyInt { val: isize } - -impl Panda for MyInt { - fn chomp(&self, bamboo: &MyInt) -> MyInt { - mi(self.val + bamboo.val) - } -} - -impl Add for MyInt { - fn add(&self, other: &MyInt) -> MyInt { self.chomp(other) } -} - -impl MyNum for MyInt {} - -fn f(x: T, y: T) -> T { - return x.add(&y).chomp(&y); -} - -fn mi(v: isize) -> MyInt { MyInt { val: v } } - -pub fn main() { - let (x, y) = (mi(3), mi(5)); - let z = f(x, y); - assert_eq!(z.val, 13); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-subst.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-subst.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-subst.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-subst.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub trait Add { - fn add(&self, rhs: &RHS) -> Result; -} - -trait MyNum : Sized + Add { } - -struct MyInt { val: isize } - -impl Add for MyInt { - fn add(&self, other: &MyInt) -> MyInt { mi(self.val + other.val) } -} - -impl MyNum for MyInt {} - -fn f(x: T, y: T) -> T { - return x.add(&y); -} - -fn mi(v: isize) -> MyInt { MyInt { val: v } } - -pub fn main() { - let (x, y) = (mi(3), mi(5)); - let z = f(x, y); - assert_eq!(z.val, 8) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-visibility.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-visibility.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-visibility.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-inheritance-visibility.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -mod traits { - pub trait Foo { fn f(&self) -> isize; } - - impl Foo for isize { fn f(&self) -> isize { 10 } } -} - -trait Quux: traits::Foo { } -impl Quux for T { } - -// Foo is not in scope but because Quux is we can still access -// Foo's methods on a Quux bound typaram -fn f(x: &T) { - assert_eq!(x.f(), 10); -} - -pub fn main() { - f(&0) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-item-inside-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-item-inside-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-item-inside-macro.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-item-inside-macro.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #34183 - -macro_rules! foo { - () => { - fn foo() { } - } -} - -macro_rules! bar { - () => { - fn bar(); - } -} - -trait Bleh { - foo!(); - bar!(); -} - -struct Test; - -impl Bleh for Test { - fn bar() {} -} - -fn main() { - Test::bar(); - Test::foo(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-object-auto-dedup.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-object-auto-dedup.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-object-auto-dedup.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-object-auto-dedup.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that duplicate auto trait bounds in trait objects don't create new types. -#[allow(unused_assignments)] - -use std::marker::Send as SendAlias; - -// A dummy trait for the non-auto trait. -trait Trait {} - -// A dummy struct to implement Trait, Send, and . -struct Struct; - -impl Trait for Struct {} - -// These three functions should be equivalent. -fn takes_dyn_trait_send(_: Box) {} -fn takes_dyn_trait_send_send(_: Box) {} -fn takes_dyn_trait_send_sendalias(_: Box) {} - -impl dyn Trait + Send + Send { - fn do_nothing(&self) {} -} - -fn main() { - // 1. Moving into a variable with more Sends and back. - let mut dyn_trait_send = Box::new(Struct) as Box; - let dyn_trait_send_send: Box = dyn_trait_send; - dyn_trait_send = dyn_trait_send_send; - - // 2. Calling methods with different number of Sends. - let dyn_trait_send = Box::new(Struct) as Box; - takes_dyn_trait_send_send(dyn_trait_send); - - let dyn_trait_send_send = Box::new(Struct) as Box; - takes_dyn_trait_send(dyn_trait_send_send); - - // 3. Aliases to the trait are transparent. - let dyn_trait_send = Box::new(Struct) as Box; - takes_dyn_trait_send_sendalias(dyn_trait_send); - - // 4. Calling an impl that duplicates an auto trait. - let dyn_trait_send = Box::new(Struct) as Box; - dyn_trait_send.do_nothing(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-object-exclusion.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-object-exclusion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-object-exclusion.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-object-exclusion.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Future: 'static { - // The requirement for Self: Sized must prevent instantiation of - // Future::forget in vtables, otherwise there's an infinite type - // recursion through as Future>::forget. - fn forget(self) where Self: Sized { - Box::new(Map(self)) as Box; - } -} - -struct Map(A); -impl Future for Map {} - -pub struct Promise; -impl Future for Promise {} - -fn main() { - Promise.forget(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-object-generics.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-object-generics.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-object-generics.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-object-generics.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// test for #8664 - -#![feature(box_syntax)] - -use std::marker; - -pub trait Trait2 { - fn doit(&self) -> A; -} - -pub struct Impl { - m1: marker::PhantomData<(A1,A2,A3)>, - /* - * With A2 we get the ICE: - * task failed at 'index out of bounds: the len is 1 but the index is 1', - * src/librustc/middle/subst.rs:58 - */ - t: Box+'static> -} - -impl Impl { - pub fn step(&self) { - self.t.doit(); - } -} - -// test for #8601 - -enum Type { Constant(T) } - -trait Trait { - fn method(&self, _: Type<(K,V)>) -> isize; -} - -impl Trait for () { - fn method(&self, _x: Type<(u8,V)>) -> isize { 0 } -} - -pub fn main() { - let a = box () as Box>; - assert_eq!(a.method(Type::Constant((1, 2))), 0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-object-lifetime-first.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-object-lifetime-first.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-object-lifetime-first.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-object-lifetime-first.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::fmt::Display; - -static BYTE: u8 = 33; - -fn main() { - let x: &('static + Display) = &BYTE; - let y: Box<'static + Display> = Box::new(BYTE); - let xstr = format!("{}", x); - let ystr = format!("{}", y); - assert_eq!(xstr, "33"); - assert_eq!(ystr, "33"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-object-with-lifetime-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-object-with-lifetime-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-object-with-lifetime-bound.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-object-with-lifetime-bound.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Uncovered during work on new scoping rules for safe destructors -// as an important use case to support properly. - - -pub struct E<'a> { - pub f: &'a u8, -} -impl<'b> E<'b> { - pub fn m(&self) -> &'b u8 { self.f } -} - -pub struct P<'c> { - pub g: &'c u8, -} -pub trait M { - fn n(&self) -> u8; -} -impl<'d> M for P<'d> { - fn n(&self) -> u8 { *self.g } -} - -fn extension<'e>(x: &'e E<'e>) -> Box { - loop { - let p = P { g: x.m() }; - return Box::new(p) as Box; - } -} - -fn main() { - let w = E { f: &10 }; - let o = extension(&w); - assert_eq!(o.n(), 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-region-pointer-simple.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-region-pointer-simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-region-pointer-simple.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-region-pointer-simple.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Foo { - fn f(&self) -> isize; -} - -struct A { - x: isize -} - -impl Foo for A { - fn f(&self) -> isize { - println!("Today's number is {}", self.x); - return self.x; - } -} - -pub fn main() { - let a = A { x: 3 }; - let b = (&a) as &Foo; - assert_eq!(b.f(), 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-safety-ok-cc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-safety-ok-cc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-safety-ok-cc.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-safety-ok-cc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:trait_safety_lib.rs - -// Simple smoke test that unsafe traits can be compiled across crates. - - -extern crate trait_safety_lib as lib; - -use lib::Foo; - -struct Bar { x: isize } -unsafe impl Foo for Bar { - fn foo(&self) -> isize { self.x } -} - -fn take_foo(f: &F) -> isize { f.foo() } - -fn main() { - let x: isize = 22; - assert_eq!(22, take_foo(&x)); - - let x: Bar = Bar { x: 23 }; - assert_eq!(23, take_foo(&x)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-safety-ok.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-safety-ok.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-safety-ok.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-safety-ok.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Simple smoke test that unsafe traits can be compiled etc. - - -unsafe trait Foo { - fn foo(&self) -> isize; -} - -unsafe impl Foo for isize { - fn foo(&self) -> isize { *self } -} - -fn take_foo(f: &F) -> isize { f.foo() } - -fn main() { - let x: isize = 22; - assert_eq!(22, take_foo(&x)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-assoc-type-in-supertrait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-assoc-type-in-supertrait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-assoc-type-in-supertrait.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-assoc-type-in-supertrait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test case where an associated type is referenced from within the -// supertrait definition. Issue #20220. - - -use std::vec::IntoIter; - -pub trait Foo: Iterator::Key> { - type Key; -} - -impl Foo for IntoIter { - type Key = i32; -} - -fn sum_foo>(f: F) -> i32 { - f.fold(0, |a,b| a + b) -} - -fn main() { - let x = sum_foo(vec![11, 10, 1].into_iter()); - assert_eq!(x, 22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-conditional-dispatch.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-conditional-dispatch.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-conditional-dispatch.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-conditional-dispatch.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we are able to resolve conditional dispatch. Here, the -// blanket impl for T:Copy coexists with an impl for Box, because -// Box does not impl Copy. - -#![feature(box_syntax)] - -trait Get { - fn get(&self) -> Self; -} - -trait MyCopy { fn copy(&self) -> Self; } -impl MyCopy for u16 { fn copy(&self) -> Self { *self } } -impl MyCopy for u32 { fn copy(&self) -> Self { *self } } -impl MyCopy for i32 { fn copy(&self) -> Self { *self } } -impl MyCopy for Option { fn copy(&self) -> Self { *self } } - -impl Get for T { - fn get(&self) -> T { self.copy() } -} - -impl Get for Box { - fn get(&self) -> Box { box get_it(&**self) } -} - -fn get_it(t: &T) -> T { - (*t).get() -} - -fn main() { - assert_eq!(get_it(&1_u32), 1_u32); - assert_eq!(get_it(&1_u16), 1_u16); - assert_eq!(get_it(&Some(1_u16)), Some(1_u16)); - assert_eq!(get_it(&Box::new(1)), Box::new(1)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-conditional-model-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-conditional-model-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-conditional-model-fn.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-conditional-model-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// A model for how the `Fn` traits could work. You can implement at -// most one of `Go`, `GoMut`, or `GoOnce`, and then the others follow -// automatically. - -// aux-build:go_trait.rs - - -extern crate go_trait; - -use go_trait::{Go, GoMut, GoOnce, go, go_mut, go_once}; - -use std::rc::Rc; -use std::cell::Cell; - -/////////////////////////////////////////////////////////////////////////// - -struct SomeGoableThing { - counter: Rc> -} - -impl Go for SomeGoableThing { - fn go(&self, arg: isize) { - self.counter.set(self.counter.get() + arg); - } -} - -/////////////////////////////////////////////////////////////////////////// - -struct SomeGoOnceableThing { - counter: Rc> -} - -impl GoOnce for SomeGoOnceableThing { - fn go_once(self, arg: isize) { - self.counter.set(self.counter.get() + arg); - } -} - -/////////////////////////////////////////////////////////////////////////// - -fn main() { - let counter = Rc::new(Cell::new(0)); - let mut x = SomeGoableThing { counter: counter.clone() }; - - go(&x, 10); - assert_eq!(counter.get(), 10); - - go_mut(&mut x, 100); - assert_eq!(counter.get(), 110); - - go_once(x, 1_000); - assert_eq!(counter.get(), 1_110); - - let x = SomeGoOnceableThing { counter: counter.clone() }; - - go_once(x, 10_000); - assert_eq!(counter.get(), 11_110); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-default-method-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-default-method-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-default-method-macro.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-default-method-macro.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -trait Foo { - fn bar(&self) -> String { - format!("test") - } -} - -enum Baz { - Quux -} - -impl Foo for Baz { -} - -pub fn main() { - let q = Baz::Quux; - assert_eq!(q.bar(), "test".to_string()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-default-method-mut.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-default-method-mut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-default-method-mut.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-default-method-mut.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![allow(unused_variables)] - -trait Foo { - fn foo(&self, mut v: isize) { v = 1; } -} - -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-default-method-self.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-default-method-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-default-method-self.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-default-method-self.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -trait Cat { - fn meow(&self) -> bool; - fn scratch(&self) -> bool { self.purr() } - fn purr(&self) -> bool { true } -} - -impl Cat for isize { - fn meow(&self) -> bool { - self.scratch() - } -} - -pub fn main() { - assert!(5.meow()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-default-method-trivial.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-default-method-trivial.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-default-method-trivial.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-default-method-trivial.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -trait Cat { - fn meow(&self) -> bool; - fn scratch(&self) -> bool; - fn purr(&self) -> bool { true } -} - -impl Cat for isize { - fn meow(&self) -> bool { - self.scratch() - } - fn scratch(&self) -> bool { - self.purr() - } -} - -pub fn main() { - assert!(5.meow()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-elaborate-type-region.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-elaborate-type-region.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-elaborate-type-region.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-elaborate-type-region.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(dead_code)] - -// Test that we elaborate `Type: 'region` constraints and infer various important things. - -trait Master<'a, T: ?Sized> { - fn foo() where T: 'a; -} - -// [U]: 'a => U: 'a -impl<'a, U> Master<'a, [U]> for () { - fn foo() where U: 'a { } -} - -// &'b U: 'a => 'b: 'a, U: 'a -impl<'a, 'b, U> Master<'a, &'b U> for () { - fn foo() where 'b: 'a, U: 'a { } -} - -// &'b [U]: 'a => 'b: 'a, U: 'a -impl<'a, 'b, U> Master<'a, &'b [U]> for () { - fn foo() where 'b: 'a, U: 'a { } -} - -// Foo<'b>: 'a => 'b: 'a -struct Foo<'a> { x: &'a () } -impl<'a, 'b> Master<'a, Foo<'b>> for () { - fn foo() where 'b: 'a { } -} - -// Bar<'b, T>: 'a => 'b: 'a, T: 'a -struct Bar<'a, T: 'a> { x: &'a T } -impl<'a, 'b, T> Master<'a, Bar<'b, T>> for () { - fn foo() where 'b: 'a, T: 'a { } -} - -// fn(T): 'a => T: 'a -impl<'a, T> Master<'a, fn(T)> for () { - fn foo() where T: 'a { } -} - -// fn() -> T: 'a => T: 'a -impl<'a, T> Master<'a, fn() -> T> for () { - fn foo() where T: 'a { } -} - -fn main() { - println!("Hello, world!"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-impl-object-overlap-issue-23853.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-impl-object-overlap-issue-23853.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-impl-object-overlap-issue-23853.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-impl-object-overlap-issue-23853.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we are able to compile the case where both a blanket impl -// and the object type itself supply the required trait obligation. -// In this case, the blanket impl for `Foo` applies to any type, -// including `Bar`, but the object type `Bar` also implicitly supplies -// this context. - -trait Foo { fn dummy(&self) { } } - -trait Bar: Foo { } - -impl Foo for T { } - -fn want_foo() { } - -fn main() { - want_foo::(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-issue-22019.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-issue-22019.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-issue-22019.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-issue-22019.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test an issue where global caching was causing free regions from -// distinct scopes to be compared (`'g` and `'h`). The only important -// thing is that compilation succeeds here. - -// pretty-expanded FIXME #23616 - -#![allow(missing_copy_implementations)] -#![allow(unused_variables)] - -use std::borrow::ToOwned; - -pub struct CFGNode; - -pub type Node<'a> = &'a CFGNode; - -pub trait GraphWalk<'c, N> { - /// Returns all the nodes in this graph. - fn nodes(&'c self) where [N]:ToOwned>; -} - -impl<'g> GraphWalk<'g, Node<'g>> for u32 -{ - fn nodes(&'g self) where [Node<'g>]:ToOwned>> - { loop { } } -} - -impl<'h> GraphWalk<'h, Node<'h>> for u64 -{ - fn nodes(&'h self) where [Node<'h>]:ToOwned>> - { loop { } } -} - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-issue-22110.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-issue-22110.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-issue-22110.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-issue-22110.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test an issue where we reported ambiguity between the where-clause -// and the blanket impl. The only important thing is that compilation -// succeeds here. Issue #22110. - -// pretty-expanded FIXME #23616 - -#![allow(dead_code)] - -trait Foo { - fn foo(&self, a: A); -} - -impl Foo for F { - fn foo(&self, _: A) { } -} - -fn baz Foo<(&'a A,)>>(_: F) { } - -fn components(t: fn(&A)) - where fn(&A) : for<'a> Foo<(&'a A,)>, -{ - baz(t) -} - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-issue-22655.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-issue-22655.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-issue-22655.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-issue-22655.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Regression test for issue #22655: This test should not lead to -// infinite recursion. - -// pretty-expanded FIXME #23616 - -unsafe impl Send for Unique { } - -pub struct Unique { - pointer: *const T, -} - -pub struct Node { - vals: V, - edges: Unique>, -} - -fn is_send() {} - -fn main() { - is_send::>(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-issue-23003.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-issue-23003.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-issue-23003.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-issue-23003.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test stack overflow triggered by evaluating the implications. To be -// WF, the type `Receipt` would require that `::Cancel` be WF. This normalizes to `Receipt` -// again, leading to an infinite cycle. Issue #23003. - -// pretty-expanded FIXME #23616 - -#![allow(dead_code)] -#![allow(unused_variables)] - -use std::marker::PhantomData; - -trait Async { - type Cancel; -} - -struct Receipt { - marker: PhantomData, -} - -struct Complete { - core: Option<()>, -} - -impl Async for Complete { - type Cancel = Receipt; -} - -fn foo(r: Receipt) { } - -fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-issue-26339.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-issue-26339.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-issue-26339.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-issue-26339.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that the right implementation is called through a trait -// object when supertraits include multiple references to the -// same trait, with different type parameters. - -trait A: PartialEq + PartialEq { } - -struct Foo; -struct Bar; - -struct Aimpl; - -impl PartialEq for Aimpl { - fn eq(&self, _rhs: &Foo) -> bool { - true - } -} - -impl PartialEq for Aimpl { - fn eq(&self, _rhs: &Bar) -> bool { - false - } -} - -impl A for Aimpl { } - -fn main() { - let a = &Aimpl as &A; - - assert!(*a == Foo); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-multidispatch-infer-convert-target.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-multidispatch-infer-convert-target.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-multidispatch-infer-convert-target.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-multidispatch-infer-convert-target.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we can infer the Target based on the Self or vice versa. - - -use std::mem; - -trait Convert { - fn convert(&self) -> Target; -} - -impl Convert for i16 { - fn convert(&self) -> u32 { - *self as u32 - } -} - -impl Convert for u32 { - fn convert(&self) -> i16 { - *self as i16 - } -} - -fn test(_: T, _: U, t_size: usize, u_size: usize) -where T : Convert -{ - assert_eq!(mem::size_of::(), t_size); - assert_eq!(mem::size_of::(), u_size); -} - -fn main() { - use std::default::Default; - // T = i16, U = u32 - test(22_i16, Default::default(), 2, 4); - - // T = u32, U = i16 - test(22_u32, Default::default(), 4, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-negative-impls.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-negative-impls.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-negative-impls.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-negative-impls.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(optin_builtin_traits)] - -use std::marker::Send; - -pub struct WaitToken; -impl !Send for WaitToken {} - -pub struct Test(T); -unsafe impl Send for Test {} - -pub fn spawn(_: F) -> () where F: FnOnce(), F: Send + 'static {} - -fn main() { - let wt = Test(WaitToken); - spawn(move || { - let x = wt; - println!("Hello, World!"); - }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-repeated-supertrait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-repeated-supertrait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-repeated-supertrait.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-repeated-supertrait.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test a case of a trait which extends the same supertrait twice, but -// with difference type parameters. Test that we can invoke the -// various methods in various ways successfully. -// See also `compile-fail/trait-repeated-supertrait-ambig.rs`. - - -trait CompareTo { - fn same_as(&self, t: T) -> bool; -} - -trait CompareToInts : CompareTo + CompareTo { -} - -impl CompareTo for i64 { - fn same_as(&self, t: i64) -> bool { *self == t } -} - -impl CompareTo for i64 { - fn same_as(&self, t: u64) -> bool { *self == (t as i64) } -} - -impl CompareToInts for i64 { } - -fn with_obj(c: &CompareToInts) -> bool { - c.same_as(22_i64) && c.same_as(22_u64) -} - -fn with_trait(c: &C) -> bool { - c.same_as(22_i64) && c.same_as(22_u64) -} - -fn with_ufcs1(c: &C) -> bool { - CompareToInts::same_as(c, 22_i64) && CompareToInts::same_as(c, 22_u64) -} - -fn with_ufcs2(c: &C) -> bool { - CompareTo::same_as(c, 22_i64) && CompareTo::same_as(c, 22_u64) -} - -fn main() { - assert_eq!(22_i64.same_as(22_i64), true); - assert_eq!(22_i64.same_as(22_u64), true); - assert_eq!(with_trait(&22), true); - assert_eq!(with_obj(&22), true); - assert_eq!(with_ufcs1(&22), true); - assert_eq!(with_ufcs2(&22), true); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-static-outlives-a-where-clause.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-static-outlives-a-where-clause.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-static-outlives-a-where-clause.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/traits-static-outlives-a-where-clause.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +trait Foo<'a> { + fn xyz(self); +} +impl<'a, T> Foo<'a> for T where 'static: 'a { + fn xyz(self) {} +} + +trait Bar { + fn uvw(self); +} +impl Bar for T where for<'a> T: Foo<'a> { + fn uvw(self) { self.xyz(); } +} + +fn foo(t: T) where T: Bar { + t.uvw(); +} + +fn main() { + foo(0); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-static-method-overwriting.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-static-method-overwriting.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-static-method-overwriting.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-static-method-overwriting.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -mod base { - pub trait HasNew { - fn new() -> Self; - } - - pub struct Foo { - dummy: (), - } - - impl ::base::HasNew for Foo { - fn new() -> Foo { - println!("Foo"); - Foo { dummy: () } - } - } - - pub struct Bar { - dummy: (), - } - - impl ::base::HasNew for Bar { - fn new() -> Bar { - println!("Bar"); - Bar { dummy: () } - } - } -} - -pub fn main() { - let _f: base::Foo = base::HasNew::new(); - let _b: base::Bar = base::HasNew::new(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-to-str.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-to-str.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-to-str.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-to-str.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - - -trait to_str { - fn to_string_(&self) -> String; -} - -impl to_str for isize { - fn to_string_(&self) -> String { self.to_string() } -} - -impl to_str for Vec { - fn to_string_(&self) -> String { - format!("[{}]", - self.iter() - .map(|e| e.to_string_()) - .collect::>() - .join(", ")) - } -} - -pub fn main() { - assert_eq!(1.to_string_(), "1".to_string()); - assert_eq!((vec![2, 3, 4]).to_string_(), "[2, 3, 4]".to_string()); - - fn indirect(x: T) -> String { - format!("{}!", x.to_string_()) - } - assert_eq!(indirect(vec![10, 20]), "[10, 20]!".to_string()); - - fn indirect2(x: T) -> String { - indirect(x) - } - assert_eq!(indirect2(vec![1]), "[1]!".to_string()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-where-clause-vs-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-where-clause-vs-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-where-clause-vs-impl.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-where-clause-vs-impl.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that when there is a conditional (but blanket) impl and a -// where clause, we don't get confused in trait resolution. -// -// Issue #18453. - -// pretty-expanded FIXME #23616 - -use std::rc::Rc; - -pub trait Foo { - fn foo(&mut self, msg: M); -} - -pub trait Bar { - fn dummy(&self) -> M; -} - -impl> Foo for F { - fn foo(&mut self, msg: M) { - } -} - -pub struct Both { - inner: Rc<(M, F)>, -} - -impl> Clone for Both { - fn clone(&self) -> Both { - Both { inner: self.inner.clone() } - } -} - -fn repro1>(_both: Both) { -} - -fn repro2>(msg: M, foo: F) { - let both = Both { inner: Rc::new((msg, foo)) }; - repro1(both.clone()); // <--- This clone causes problem -} - -pub fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-with-bounds-default.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-with-bounds-default.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-with-bounds-default.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/trait-with-bounds-default.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -pub trait Clone2 { - /// Returns a copy of the value. The contents of boxes - /// are copied to maintain uniqueness, while the contents of - /// managed pointers are not copied. - fn clone(&self) -> Self; -} - -trait Getter { - fn do_get(&self) -> T; - - fn do_get2(&self) -> (T, T) { - let x = self.do_get(); - (x.clone(), x.clone()) - } - -} - -impl Getter for isize { - fn do_get(&self) -> isize { *self } -} - -impl Getter for Option { - fn do_get(&self) -> T { self.as_ref().unwrap().clone() } -} - - -pub fn main() { - assert_eq!(3.do_get2(), (3, 3)); - assert_eq!(Some("hi".to_string()).do_get2(), ("hi".to_string(), "hi".to_string())); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/ufcs-trait-object.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/ufcs-trait-object.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/ufcs-trait-object.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/ufcs-trait-object.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that when you use ufcs form to invoke a trait method (on a -// trait object) everything works fine. - - -trait Foo { - fn test(&self) -> i32; -} - -impl Foo for i32 { - fn test(&self) -> i32 { *self } -} - -fn main() { - let a: &Foo = &22; - assert_eq!(Foo::test(a), 22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/use-trait-before-def.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/use-trait-before-def.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/traits/use-trait-before-def.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/traits/use-trait-before-def.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// Issue #1761 - -// pretty-expanded FIXME #23616 - -impl foo for isize { fn foo(&self) -> isize { 10 } } -trait foo { fn foo(&self) -> isize; } -pub fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/auxiliary/unboxed-closures-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/auxiliary/unboxed-closures-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/auxiliary/unboxed-closures-cross-crate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/auxiliary/unboxed-closures-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::ops::Add; - -#[inline] -pub fn has_closures() -> usize { - let x = 1; - let mut f = move || x; - let y = 1; - let g = || y; - f() + g() -} - -pub fn has_generic_closures + Copy>(x: T, y: T) -> T { - let mut f = move || x; - let g = || y; - f() + g() -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-all-traits.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-all-traits.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-all-traits.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-all-traits.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(lang_items)] - -fn a isize>(f: F) -> isize { - f(1, 2) -} - -fn b isize>(mut f: F) -> isize { - f(3, 4) -} - -fn c isize>(f: F) -> isize { - f(5, 6) -} - -fn main() { - let z: isize = 7; - assert_eq!(a(move |x: isize, y| x + y + z), 10); - assert_eq!(b(move |x: isize, y| x + y + z), 14); - assert_eq!(c(move |x: isize, y| x + y + z), 18); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-blanket-fn-mut.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-blanket-fn-mut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-blanket-fn-mut.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-blanket-fn-mut.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that you can supply `&F` where `F: FnMut()`. - -#![feature(lang_items)] - -fn a i32>(mut f: F) -> i32 { - f() -} - -fn b(f: &mut FnMut() -> i32) -> i32 { - a(f) -} - -fn c i32>(f: &mut F) -> i32 { - a(f) -} - -fn main() { - let z: isize = 7; - - let x = b(&mut || 22); - assert_eq!(x, 22); - - let x = c(&mut || 22); - assert_eq!(x, 22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-blanket-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-blanket-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-blanket-fn.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-blanket-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that you can supply `&F` where `F: Fn()`. - -#![feature(lang_items)] - -fn a i32>(f: F) -> i32 { - f() -} - -fn b(f: &Fn() -> i32) -> i32 { - a(f) -} - -fn c i32>(f: &F) -> i32 { - a(f) -} - -fn main() { - let z: isize = 7; - - let x = b(&|| 22); - assert_eq!(x, 22); - - let x = c(&|| 22); - assert_eq!(x, 22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-boxed.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-boxed.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-boxed.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-boxed.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -use std::ops::FnMut; - - fn make_adder(x: i32) -> Boxi32+'static> { - (box move |y: i32| -> i32 { x + y }) as - Boxi32+'static> -} - -pub fn main() { - let mut adder = make_adder(3); - let z = adder(2); - println!("{}", z); - assert_eq!(z, 5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-by-ref.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-by-ref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-by-ref.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-by-ref.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test by-ref capture of environment in unboxed closure types - -fn call_fn(f: F) { - f() -} - -fn call_fn_mut(mut f: F) { - f() -} - -fn call_fn_once(f: F) { - f() -} - -fn main() { - let mut x = 0_usize; - let y = 2_usize; - - call_fn(|| assert_eq!(x, 0)); - call_fn_mut(|| x += y); - call_fn_once(|| x += y); - assert_eq!(x, y * 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-call-fn-autoderef.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-call-fn-autoderef.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-call-fn-autoderef.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-call-fn-autoderef.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that the call operator autoderefs when calling a bounded type parameter. - -use std::ops::FnMut; - -fn call_with_2(x: &fn(isize) -> isize) -> isize -{ - x(2) // look ma, no `*` -} - -fn subtract_22(x: isize) -> isize { x - 22 } - -pub fn main() { - let subtract_22: fn(isize) -> isize = subtract_22; - let z = call_with_2(&subtract_22); - assert_eq!(z, -20); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-call-sugar-autoderef.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-call-sugar-autoderef.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-call-sugar-autoderef.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-call-sugar-autoderef.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that the call operator autoderefs when calling a bounded type parameter. - -use std::ops::FnMut; - -fn call_with_2(x: &mut F) -> isize - where F : FnMut(isize) -> isize -{ - x(2) // look ma, no `*` -} - -pub fn main() { - let z = call_with_2(&mut |x| x - 22); - assert_eq!(z, -20); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-call-sugar-object-autoderef.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-call-sugar-object-autoderef.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-call-sugar-object-autoderef.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-call-sugar-object-autoderef.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that the call operator autoderefs when calling to an object type. - -use std::ops::FnMut; - -fn make_adder(x: isize) -> Boxisize + 'static> { - Box::new(move |y| { x + y }) -} - -pub fn main() { - let mut adder = make_adder(3); - let z = adder(2); - println!("{}", z); - assert_eq!(z, 5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-call-sugar-object.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-call-sugar-object.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-call-sugar-object.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-call-sugar-object.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::ops::FnMut; - -fn make_adder(x: isize) -> Boxisize + 'static> { - Box::new(move |y| { x + y }) -} - -pub fn main() { - let mut adder = make_adder(3); - let z = (*adder)(2); - println!("{}", z); - assert_eq!(z, 5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-counter-not-moved.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-counter-not-moved.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-counter-not-moved.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-counter-not-moved.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we mutate a counter on the stack only when we expect to. - -fn call(f: F) where F : FnOnce() { - f(); -} - -fn main() { - let y = vec![format!("Hello"), format!("World")]; - let mut counter = 22_u32; - - call(|| { - // Move `y`, but do not move `counter`, even though it is read - // by value (note that it is also mutated). - for item in y { - let v = counter; - counter += v; - } - }); - assert_eq!(counter, 88); - - call(move || { - // this mutates a moved copy, and hence doesn't affect original - counter += 1; - }); - assert_eq!(counter, 88); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-cross-crate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// Test that unboxed closures work with cross-crate inlining -// Acts as a regression test for #16790, #18378 and #18543 - -// aux-build:unboxed-closures-cross-crate.rs - -extern crate unboxed_closures_cross_crate as ubcc; - -fn main() { - assert_eq!(ubcc::has_closures(), 2_usize); - assert_eq!(ubcc::has_generic_closures(2_usize, 3_usize), 5_usize); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-direct-sugary-call.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-direct-sugary-call.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-direct-sugary-call.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-direct-sugary-call.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn main() { - let mut unboxed = || {}; - unboxed(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-drop.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-drop.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-drop.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,125 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// A battery of tests to ensure destructors of unboxed closure environments -// run at the right times. - -static mut DROP_COUNT: usize = 0; - -fn drop_count() -> usize { - unsafe { - DROP_COUNT - } -} - -struct Droppable { - x: isize, -} - -impl Droppable { - fn new() -> Droppable { - Droppable { - x: 1 - } - } -} - -impl Drop for Droppable { - fn drop(&mut self) { - unsafe { - DROP_COUNT += 1 - } - } -} - -fn a isize>(f: F) -> isize { - f(1, 2) -} - -fn b isize>(mut f: F) -> isize { - f(3, 4) -} - -fn c isize>(f: F) -> isize { - f(5, 6) -} - -fn test_fn() { - { - a(move |a: isize, b| { a + b }); - } - assert_eq!(drop_count(), 0); - - { - let z = &Droppable::new(); - a(move |a: isize, b| { z; a + b }); - assert_eq!(drop_count(), 0); - } - assert_eq!(drop_count(), 1); - - { - let z = &Droppable::new(); - let zz = &Droppable::new(); - a(move |a: isize, b| { z; zz; a + b }); - assert_eq!(drop_count(), 1); - } - assert_eq!(drop_count(), 3); -} - -fn test_fn_mut() { - { - b(move |a: isize, b| { a + b }); - } - assert_eq!(drop_count(), 3); - - { - let z = &Droppable::new(); - b(move |a: isize, b| { z; a + b }); - assert_eq!(drop_count(), 3); - } - assert_eq!(drop_count(), 4); - - { - let z = &Droppable::new(); - let zz = &Droppable::new(); - b(move |a: isize, b| { z; zz; a + b }); - assert_eq!(drop_count(), 4); - } - assert_eq!(drop_count(), 6); -} - -fn test_fn_once() { - { - c(move |a: isize, b| { a + b }); - } - assert_eq!(drop_count(), 6); - - { - let z = Droppable::new(); - c(move |a: isize, b| { z; a + b }); - assert_eq!(drop_count(), 7); - } - assert_eq!(drop_count(), 7); - - { - let z = Droppable::new(); - let zz = Droppable::new(); - c(move |a: isize, b| { z; zz; a + b }); - assert_eq!(drop_count(), 9); - } - assert_eq!(drop_count(), 9); -} - -fn main() { - test_fn(); - test_fn_mut(); - test_fn_once(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-extern-fn-hr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-extern-fn-hr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-extern-fn-hr.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-extern-fn-hr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Checks that higher-ranked extern fn pointers implement the full range of Fn traits. - -fn square(x: &isize) -> isize { (*x) * (*x) } - -fn call_itisize>(f: &F, x: isize) -> isize { - (*f)(&x) -} - -fn call_it_boxed(f: &Fn(&isize) -> isize, x: isize) -> isize { - f(&x) -} - -fn call_it_mutisize>(f: &mut F, x: isize) -> isize { - (*f)(&x) -} - -fn call_it_onceisize>(f: F, x: isize) -> isize { - f(&x) -} - -fn main() { - let x = call_it(&square, 22); - let x1 = call_it_boxed(&square, 22); - let y = call_it_mut(&mut square, 22); - let z = call_it_once(square, 22); - assert_eq!(x, square(&22)); - assert_eq!(x1, square(&22)); - assert_eq!(y, square(&22)); - assert_eq!(z, square(&22)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-extern-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-extern-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-extern-fn.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-extern-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Checks that extern fn pointers implement the full range of Fn traits. - -use std::ops::{Fn,FnMut,FnOnce}; - -fn square(x: isize) -> isize { x * x } - -fn call_itisize>(f: &F, x: isize) -> isize { - f(x) -} - -fn call_it_mutisize>(f: &mut F, x: isize) -> isize { - f(x) -} - -fn call_it_onceisize>(f: F, x: isize) -> isize { - f(x) -} - -fn main() { - let x = call_it(&square, 22); - let y = call_it_mut(&mut square, 22); - let z = call_it_once(square, 22); - assert_eq!(x, square(22)); - assert_eq!(y, square(22)); - assert_eq!(z, square(22)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-fn-as-fnmut-and-fnonce.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-fn-as-fnmut-and-fnonce.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-fn-as-fnmut-and-fnonce.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-fn-as-fnmut-and-fnonce.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Checks that the Fn trait hierarchy rules permit -// any Fn trait to be used where Fn is implemented. - -#![feature(unboxed_closures, fn_traits)] - -use std::ops::{Fn,FnMut,FnOnce}; - -struct S; - -impl Fn<(i32,)> for S { - extern "rust-call" fn call(&self, (x,): (i32,)) -> i32 { - x * x - } -} - -impl FnMut<(i32,)> for S { - extern "rust-call" fn call_mut(&mut self, args: (i32,)) -> i32 { self.call(args) } -} - -impl FnOnce<(i32,)> for S { - type Output = i32; - extern "rust-call" fn call_once(self, args: (i32,)) -> i32 { self.call(args) } -} - -fn call_iti32>(f: &F, x: i32) -> i32 { - f(x) -} - -fn call_it_muti32>(f: &mut F, x: i32) -> i32 { - f(x) -} - -fn call_it_oncei32>(f: F, x: i32) -> i32 { - f(x) -} - -fn main() { - let x = call_it(&S, 22); - let y = call_it_mut(&mut S, 22); - let z = call_it_once(S, 22); - assert_eq!(x, y); - assert_eq!(y, z); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-fnmut-as-fnonce.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-fnmut-as-fnonce.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-fnmut-as-fnonce.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-fnmut-as-fnonce.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Checks that the Fn trait hierarchy rules permit -// FnMut or FnOnce to be used where FnMut is implemented. - -#![feature(unboxed_closures, fn_traits)] - -struct S; - -impl FnMut<(i32,)> for S { - extern "rust-call" fn call_mut(&mut self, (x,): (i32,)) -> i32 { - x * x - } -} - -impl FnOnce<(i32,)> for S { - type Output = i32; - - extern "rust-call" fn call_once(mut self, args: (i32,)) -> i32 { self.call_mut(args) } -} - -fn call_it_muti32>(f: &mut F, x: i32) -> i32 { - f(x) -} - -fn call_it_oncei32>(f: F, x: i32) -> i32 { - f(x) -} - -fn main() { - let y = call_it_mut(&mut S, 22); - let z = call_it_once(S, 22); - assert_eq!(y, z); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-generic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-generic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-generic.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-generic.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::ops::FnMut; - -fn call_iti32>(y: i32, mut f: F) -> i32 { - f(2, y) -} - -pub fn main() { - let f = |x: i32, y: i32| -> i32 { x + y }; - let z = call_it(3, f); - println!("{}", z); - assert_eq!(z, 5); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-bound.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-bound.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we are able to infer that the type of `x` is `isize` based -// on the expected type from the object. - -// pretty-expanded FIXME #23616 - -pub trait ToPrimitive { - fn to_int(&self) {} -} - -impl ToPrimitive for isize {} -impl ToPrimitive for i32 {} -impl ToPrimitive for usize {} - -fn doit(val: T, f: &F) - where F : Fn(T) -{ - f(val) -} - -pub fn main() { - doit(0, &|x /*: isize*/ | { x.to_int(); }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-from-expected-object-type.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we are able to infer that the type of `x` is `isize` based -// on the expected type from the object. - -// pretty-expanded FIXME #23616 - -pub trait ToPrimitive { - fn to_int(&self) {} -} - -impl ToPrimitive for isize {} -impl ToPrimitive for i32 {} -impl ToPrimitive for usize {} - -fn doit(val: T, f: &Fn(T)) { f(val) } - -pub fn main() { - doit(0, &|x /*: isize*/ | { x.to_int(); }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-w-bound-regs-from-expected-bound.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-w-bound-regs-from-expected-bound.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-w-bound-regs-from-expected-bound.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-arg-types-w-bound-regs-from-expected-bound.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we are able to infer that the type of `x` is `isize` based -// on the expected type from the object. - -// pretty-expanded FIXME #23616 - -pub trait ToPrimitive { - fn to_int(&self) {} -} - -impl ToPrimitive for isize {} -impl ToPrimitive for i32 {} -impl ToPrimitive for usize {} - -fn doit(val: T, f: &F) - where F : Fn(&T) -{ - f(&val) -} - -pub fn main() { - doit(0, &|x /*: isize*/ | { x.to_int(); }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-explicit-call-early.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-explicit-call-early.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-explicit-call-early.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-explicit-call-early.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(fn_traits)] - -fn main() { - let mut zero = || 0; - let x = zero.call_mut(()); - assert_eq!(x, 0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-fnmut-calling-fnmut.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we are able to infer a suitable kind for this closure -// that is just called (`FnMut`). - -fn main() { - let mut counter = 0; - - { - // Here this must be inferred to FnMut so that it can mutate counter: - let mut tick1 = || counter += 1; - - // In turn, tick2 must be inferred to FnMut so that it can call tick1: - let mut tick2 = || { tick1(); tick1(); }; - - tick2(); - } - - assert_eq!(counter, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-fnmut-move.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-fnmut-move.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-fnmut-move.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-fnmut-move.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we are able to infer a suitable kind for this `move` -// closure that is just called (`FnMut`). - -fn main() { - let mut counter = 0; - - let v = { - let mut tick = move || { counter += 1; counter }; - tick(); - tick() - }; - - assert_eq!(counter, 0); - assert_eq!(v, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-fnmut.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-fnmut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-fnmut.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-fnmut.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we are able to infer a suitable kind for this closure -// that is just called (`FnMut`). - -fn main() { - let mut counter = 0; - - { - let mut tick = || counter += 1; - tick(); - tick(); - } - - assert_eq!(counter, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-fnonce-move.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-fnonce-move.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-fnonce-move.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-fnonce-move.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we are able to infer a suitable kind for this `move` -// closure that is just called (`FnOnce`). - -use std::mem; - -struct DropMe<'a>(&'a mut i32); - -impl<'a> Drop for DropMe<'a> { - fn drop(&mut self) { - *self.0 += 1; - } -} - -fn main() { - let mut counter = 0; - - { - let drop_me = DropMe(&mut counter); - let tick = move || mem::drop(drop_me); - tick(); - } - - assert_eq!(counter, 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-fnonce.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-fnonce.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-fnonce.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-fnonce.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we are able to infer a suitable kind for this closure -// that is just called (`FnOnce`). - -use std::mem; - -struct DropMe<'a>(&'a mut i32); - -impl<'a> Drop for DropMe<'a> { - fn drop(&mut self) { - *self.0 += 1; - } -} - -fn main() { - let mut counter = 0; - - { - let drop_me = DropMe(&mut counter); - let tick = || mem::drop(drop_me); - tick(); - } - - assert_eq!(counter, 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-kind.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-kind.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-kind.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-kind.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that we can infer the "kind" of an unboxed closure based on -// the expected type. - -// Test by-ref capture of environment in unboxed closure types - -fn call_fn(f: F) { - f() -} - -fn call_fn_mut(mut f: F) { - f() -} - -fn call_fn_once(f: F) { - f() -} - -fn main() { - let mut x = 0_usize; - let y = 2_usize; - - call_fn(|| assert_eq!(x, 0)); - call_fn_mut(|| x += y); - call_fn_once(|| x += y); - assert_eq!(x, y * 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-recursive-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-recursive-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-recursive-fn.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-recursive-fn.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(fn_traits, unboxed_closures)] - -use std::marker::PhantomData; - -// Test that we are able to infer a suitable kind for a "recursive" -// closure. As far as I can tell, coding up a recursive closure -// requires the good ol' [Y Combinator]. -// -// [Y Combinator]: http://en.wikipedia.org/wiki/Fixed-point_combinator#Y_combinator - -struct YCombinator { - func: F, - marker: PhantomData<(A,R)>, -} - -impl YCombinator { - fn new(f: F) -> YCombinator { - YCombinator { func: f, marker: PhantomData } - } -} - -impl R, A) -> R> Fn<(A,)> for YCombinator { - extern "rust-call" fn call(&self, (arg,): (A,)) -> R { - (self.func)(self, arg) - } -} - -impl R, A) -> R> FnMut<(A,)> for YCombinator { - extern "rust-call" fn call_mut(&mut self, args: (A,)) -> R { self.call(args) } -} - -impl R, A) -> R> FnOnce<(A,)> for YCombinator { - type Output = R; - extern "rust-call" fn call_once(self, args: (A,)) -> R { self.call(args) } -} - -fn main() { - let factorial = |recur: &Fn(u32) -> u32, arg: u32| -> u32 { - if arg == 0 {1} else {arg * recur(arg-1)} - }; - let factorial: YCombinator<_,u32,u32> = YCombinator::new(factorial); - let r = factorial(10); - assert_eq!(3628800, r); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-upvar.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-upvar.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-upvar.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-infer-upvar.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that the type variable in the type(`Vec<_>`) of a closed over -// variable does not interfere with type inference. - -fn f(mut f: F) { - f(); -} - -fn main() { - let mut v: Vec<_> = vec![]; - f(|| v.push(0)); - assert_eq!(v, [0]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-manual-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-manual-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-manual-impl.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-manual-impl.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(unboxed_closures, fn_traits)] - -struct S; - -impl FnMut<(i32,)> for S { - extern "rust-call" fn call_mut(&mut self, (x,): (i32,)) -> i32 { - x * x - } -} - -impl FnOnce<(i32,)> for S { - type Output = i32; - - extern "rust-call" fn call_once(mut self, args: (i32,)) -> i32 { self.call_mut(args) } -} - -fn call_iti32>(mut f: F, x: i32) -> i32 { - f(x) + 3 -} - -fn call_box(f: &mut FnMut(i32) -> i32, x: i32) -> i32 { - f(x) + 3 -} - -fn main() { - let x = call_it(S, 1); - let y = call_box(&mut S, 1); - assert_eq!(x, 4); - assert_eq!(y, 4); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-monomorphization.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-monomorphization.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-monomorphization.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-monomorphization.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that unboxed closures in contexts with free type parameters -// monomorphize correctly (issue #16791) - -fn main(){ - fn bar<'a, T:Clone+'a> (t: T) -> BoxT + 'a> { - Box::new(move || t.clone()) - } - - let mut f = bar(42_u32); - assert_eq!(f(), 42); - - let mut f = bar("forty-two"); - assert_eq!(f(), "forty-two"); - - let x = 42_u32; - let mut f = bar(&x); - assert_eq!(f(), &x); - - #[derive(Clone, Copy, Debug, PartialEq)] - struct Foo(usize, &'static str); - - let x = Foo(42, "forty-two"); - let mut f = bar(x); - assert_eq!(f(), x); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-move-from-projection-issue-30046.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-move-from-projection-issue-30046.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-move-from-projection-issue-30046.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-move-from-projection-issue-30046.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(unused)] - -fn foo(f: F) - where F: FnOnce() -{ -} - -fn main() { - // Test that this closure is inferred to `FnOnce` - // because it moves from `y.as.0`: - let x = Some(vec![1, 2, 3]); - foo(|| { - match x { - Some(y) => { } - None => { } - } - }); - - // Test that this closure is inferred to `FnOnce` - // because it moves from `y.0`: - let y = (vec![1, 2, 3], 0); - foo(|| { - let x = y.0; - }); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-move-mutable.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-move-mutable.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-move-mutable.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-move-mutable.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![deny(unused_mut)] - -// Test that mutating a mutable upvar in a capture-by-value unboxed -// closure does not ice (issue #18238) and marks the upvar as used -// mutably so we do not get a spurious warning about it not needing to -// be declared mutable (issue #18336 and #18769) - -fn set(x: &mut usize) { *x = 42; } - -fn main() { - { - let mut x = 0_usize; - move || x += 1; - } - { - let mut x = 0_usize; - move || x += 1; - } - { - let mut x = 0_usize; - move || set(&mut x); - } - { - let mut x = 0_usize; - move || set(&mut x); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-move-some-upvars-in-by-ref-closure.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-move-some-upvars-in-by-ref-closure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-move-some-upvars-in-by-ref-closure.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-move-some-upvars-in-by-ref-closure.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that in a by-ref once closure we move some variables even as -// we capture others by mutable reference. - -fn call(f: F) where F : FnOnce() { - f(); -} - -fn main() { - let mut x = vec![format!("Hello")]; - let y = vec![format!("World")]; - call(|| { - // Here: `x` must be captured with a mutable reference in - // order for us to append on it, and `y` must be captured by - // value. - for item in y { - x.push(item); - } - }); - assert_eq!(x.len(), 2); - assert_eq!(&*x[0], "Hello"); - assert_eq!(&*x[1], "World"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-prelude.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-prelude.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-prelude.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-prelude.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Tests that the re-exports of `FnOnce` et al from the prelude work. - -// pretty-expanded FIXME #23616 - -fn main() { - let task: Box isize> = Box::new(|x| x); - task(0); - - let mut task: Box isize> = Box::new(|x| x); - task(0); - - call(|x| x, 22); -} - -fn call isize>(f: F, x: isize) -> isize { - f(x) -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-simple.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-simple.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-simple.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-simple.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::ops::FnMut; - -pub fn main() { - let mut f = |x: isize, y: isize| -> isize { x + y }; - let z = f(1, 2); - assert_eq!(z, 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-single-word-env.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-single-word-env.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-single-word-env.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-single-word-env.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Ensures that single-word environments work right in unboxed closures. -// These take a different path in codegen. - -fn a isize>(f: F) -> isize { - f(1, 2) -} - -fn b isize>(mut f: F) -> isize { - f(3, 4) -} - -fn c isize>(f: F) -> isize { - f(5, 6) -} - -fn main() { - let z = 10; - assert_eq!(a(move |x: isize, y| x + y + z), 13); - assert_eq!(b(move |x: isize, y| x + y + z), 17); - assert_eq!(c(move |x: isize, y| x + y + z), 21); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-static-call-fn-once.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-static-call-fn-once.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-static-call-fn-once.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-static-call-fn-once.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn main() { - let onetime = |x| x; - onetime(0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-sugar-object.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-sugar-object.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-sugar-object.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-sugar-object.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test unboxed closure sugar used in object types. - -#![allow(dead_code)] - -struct Foo { - t: T, u: U -} - -trait Getter { - fn get(&self, arg: A) -> R; -} - -struct Identity; -impl Getter for Identity { - fn get(&self, arg: X) -> X { - arg - } -} - -fn main() { - let x: &Getter<(i32,), (i32,)> = &Identity; - let (y,) = x.get((22,)); - assert_eq!(y, 22); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-unique-type-id.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-unique-type-id.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-unique-type-id.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-unique-type-id.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// This code used to produce the following ICE: -// -// error: internal compiler error: get_unique_type_id_of_type() - -// unexpected type: closure, -// Closure(syntax::ast::DefId{krate: 0, node: 66}, -// ReScope(63)) -// -// This is a regression test for issue #17021. -// -// compile-flags: -g - -use std::ptr; - -pub fn replace_map<'a, T, F>(src: &mut T, prod: F) where F: FnOnce(T) -> T { - unsafe { *src = prod(ptr::read(src as *mut T as *const T)); } -} - -pub fn main() { - let mut a = 7; - let b = &mut a; - replace_map(b, |x: usize| x * 2); - assert_eq!(*b, 14); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-zero-args.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-zero-args.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-zero-args.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unboxed-closures/unboxed-closures-zero-args.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn main() { - let mut zero = || {}; - let () = zero(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/uniform-paths/basic-nested.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/uniform-paths/basic-nested.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/uniform-paths/basic-nested.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/uniform-paths/basic-nested.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// edition:2018 - -#![feature(decl_macro, uniform_paths)] - -// This test is similar to `basic.rs`, but nested in modules. - -mod foo { - // Test that ambiguity errors are not emitted between `self::test` and - // `::test`, assuming the latter (crate) is not in `extern_prelude`. - mod test { - pub struct Foo(pub ()); - } - pub use test::Foo; - - // Test that qualified paths can refer to both the external crate and local item. - mod std { - pub struct io(pub ()); - } - pub use ::std::io as std_io; - pub use self::std::io as local_io; -} - -// Test that we can refer to the external crate unqualified -// (when there isn't a local item with the same name). -use std::io; - -mod bar { - // Also test the unqualified external crate import in a nested module, - // to show that the above import doesn't resolve through a local `std` - // item, e.g. the automatically injected `extern crate std;`, which in - // the Rust 2018 should no longer be visible through `crate::std`. - pub use std::io; - - // Also test that items named `std` in other namespaces don't - // cause ambiguity errors for the import from `std` above. - pub fn std() {} - pub macro std() {} -} - - -fn main() { - foo::Foo(()); - foo::std_io::stdout(); - foo::local_io(()); - io::stdout(); - bar::io::stdout(); - bar::std(); - bar::std!(); - - { - // Test that having `io` in a module scope and a non-module - // scope is allowed, when both resolve to the same definition. - use std::io; - use io::stdout; - stdout(); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/uniform-paths/basic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/uniform-paths/basic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/uniform-paths/basic.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/uniform-paths/basic.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// edition:2018 - -#![feature(uniform_paths)] - -// Test that ambiguity errors are not emitted between `self::test` and -// `::test`, assuming the latter (crate) is not in `extern_prelude`. -mod test { - pub struct Foo(pub ()); -} -use test::Foo; - -// Test that qualified paths can refer to both the external crate and local item. -mod std { - pub struct io(pub ()); -} -use ::std::io as std_io; -use self::std::io as local_io; - -fn main() { - Foo(()); - std_io::stdout(); - local_io(()); - - { - // Test that having `std_io` in a module scope and a non-module - // scope is allowed, when both resolve to the same definition. - use ::std::io as std_io; - use std_io::stdout; - stdout(); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/uniform-paths/macros-nested.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/uniform-paths/macros-nested.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/uniform-paths/macros-nested.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/uniform-paths/macros-nested.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// edition:2018 - -#![feature(uniform_paths)] - -// This test is similar to `macros.rs`, but nested in modules. - -mod foo { - // Test that ambiguity errors are not emitted between `self::test` and - // `::test`, assuming the latter (crate) is not in `extern_prelude`. - macro_rules! m1 { - () => { - mod test { - pub struct Foo(pub ()); - } - } - } - pub use test::Foo; - m1!(); - - // Test that qualified paths can refer to both the external crate and local item. - macro_rules! m2 { - () => { - mod std { - pub struct io(pub ()); - } - } - } - pub use ::std::io as std_io; - pub use self::std::io as local_io; - m2!(); -} - -// Test that we can refer to the external crate unqualified -// (when there isn't a local item with the same name). -use std::io; - -mod bar { - // Also test the unqualified external crate import in a nested module, - // to show that the above import doesn't resolve through a local `std` - // item, e.g. the automatically injected `extern crate std;`, which in - // the Rust 2018 should no longer be visible through `crate::std`. - pub use std::io; -} - - -fn main() { - foo::Foo(()); - foo::std_io::stdout(); - foo::local_io(()); - io::stdout(); - bar::io::stdout(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/uniform-paths/macros.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/uniform-paths/macros.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/uniform-paths/macros.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/uniform-paths/macros.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// edition:2018 - -#![feature(uniform_paths)] - -// This test is similar to `basic.rs`, but with macros defining local items. - -// Test that ambiguity errors are not emitted between `self::test` and -// `::test`, assuming the latter (crate) is not in `extern_prelude`. -macro_rules! m1 { - () => { - mod test { - pub struct Foo(pub ()); - } - } -} -use test::Foo; -m1!(); - -// Test that qualified paths can refer to both the external crate and local item. -macro_rules! m2 { - () => { - mod std { - pub struct io(pub ()); - } - } -} -use ::std::io as std_io; -use self::std::io as local_io; -m2!(); - -fn main() { - Foo(()); - std_io::stdout(); - local_io(()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/uniform-paths/same-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/uniform-paths/same-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/uniform-paths/same-crate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/uniform-paths/same-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// edition:2018 - -#![feature(uniform_paths)] - -pub const A: usize = 0; - -pub mod foo { - pub const B: usize = 1; - - pub mod bar { - pub const C: usize = 2; - - pub enum E { - V1(usize), - V2(String), - } - - pub fn test() -> String { - format!("{} {} {}", crate::A, crate::foo::B, C) - } - - pub fn test_use() -> String { - use crate::A; - use crate::foo::B; - - format!("{} {} {}", A, B, C) - } - - pub fn test_enum() -> String { - use E::*; - match E::V1(10) { - V1(i) => { format!("V1: {}", i) } - V2(s) => { format!("V2: {}", s) } - } - } - } - - pub fn test() -> String { - format!("{} {} {}", crate::A, B, bar::C) - } - - pub fn test_use() -> String { - use crate::A; - use bar::C; - - format!("{} {} {}", A, B, C) - } - - pub fn test_enum() -> String { - use bar::E::*; - match bar::E::V1(10) { - V1(i) => { format!("V1: {}", i) } - V2(s) => { format!("V2: {}", s) } - } - } -} - -pub fn test() -> String { - format!("{} {} {}", A, foo::B, foo::bar::C) -} - -pub fn test_use() -> String { - use foo::B; - use foo::bar::C; - - format!("{} {} {}", A, B, C) -} - -pub fn test_enum() -> String { - use foo::bar::E::*; - match foo::bar::E::V1(10) { - V1(i) => { format!("V1: {}", i) } - V2(s) => { format!("V2: {}", s) } - } -} - -fn main() { - let output = [ - test(), - foo::test(), - foo::bar::test(), - test_use(), - foo::test_use(), - foo::bar::test_use(), - test_enum(), - foo::test_enum(), - foo::bar::test_enum(), - ].join("\n"); - assert_eq!(output, "\ -0 1 2 -0 1 2 -0 1 2 -0 1 2 -0 1 2 -0 1 2 -V1: 10 -V1: 10 -V1: 10"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/auxiliary/union.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/auxiliary/union.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/auxiliary/union.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/auxiliary/union.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub union U { - pub a: u8, - pub b: u16, -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-align.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-align.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-align.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-align.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(untagged_unions)] - -use std::mem::{size_of, size_of_val, align_of, align_of_val}; - -#[repr(align(16))] -pub union U16 { - a: u8, - b: u32 -} - -fn main() { - assert_eq!(align_of::(), 16); - assert_eq!(size_of::(), 16); - let u = U16 { a: 10 }; - unsafe { - assert_eq!(align_of_val(&u.a), 1); - assert_eq!(size_of_val(&u.a), 1); - assert_eq!(u.a, 10); - } - - let u = U16 { b: 11 }; - unsafe { - assert_eq!(align_of_val(&u.b), 4); - assert_eq!(size_of_val(&u.b), 4); - assert_eq!(u.b, 11); - } - - hybrid::check_hybrid(); -} - -mod hybrid { - use std::mem::{size_of, align_of}; - - #[repr(align(16))] - struct S1 { - a: u16, - b: u8, - } - - #[repr(align(32))] - union U { - s: S1, - c: u16, - } - - #[repr(align(64))] - struct S2 { - d: u8, - u: U, - } - - pub fn check_hybrid() { - assert_eq!(align_of::(), 16); - assert_eq!(size_of::(), 16); - assert_eq!(align_of::(), 32); - assert_eq!(size_of::(), 32); - assert_eq!(align_of::(), 64); - assert_eq!(size_of::(), 64); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-backcomp.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-backcomp.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-backcomp.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-backcomp.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -macro_rules! union { - () => (struct S;) -} - -union!(); - -fn union() {} - -fn main() { - union(); - - let union = 10; - - union; - - union as u8; - - union U { - a: u8, - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-basic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-basic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-basic.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-basic.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -// aux-build:union.rs - -extern crate union; -use std::mem::{size_of, align_of, zeroed}; - -union U { - a: u8, - b: u16 -} - -fn local() { - assert_eq!(size_of::(), 2); - assert_eq!(align_of::(), 2); - - let u = U { a: 10 }; - unsafe { - assert_eq!(u.a, 10); - let U { a } = u; - assert_eq!(a, 10); - } - - let mut w = U { b: 0 }; - unsafe { - assert_eq!(w.a, 0); - assert_eq!(w.b, 0); - w.a = 1; - assert_eq!(w.a, 1); - assert_eq!(w.b.to_le(), 1); - } -} - -fn xcrate() { - assert_eq!(size_of::(), 2); - assert_eq!(align_of::(), 2); - - let u = union::U { a: 10 }; - unsafe { - assert_eq!(u.a, 10); - let union::U { a } = u; - assert_eq!(a, 10); - } - - let mut w = union::U { b: 0 }; - unsafe { - assert_eq!(w.a, 0); - assert_eq!(w.b, 0); - w.a = 1; - assert_eq!(w.a, 1); - assert_eq!(w.b.to_le(), 1); - } -} - -fn main() { - local(); - xcrate(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-c-interop.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-c-interop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-c-interop.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-c-interop.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_snake_case)] - -// ignore-wasm32-bare no libc to test ffi with - -#[derive(Clone, Copy)] -#[repr(C)] -struct LARGE_INTEGER_U { - LowPart: u32, - HighPart: u32, -} - -#[derive(Clone, Copy)] -#[repr(C)] -union LARGE_INTEGER { - __unnamed__: LARGE_INTEGER_U, - u: LARGE_INTEGER_U, - QuadPart: u64, -} - -#[link(name = "rust_test_helpers", kind = "static")] -extern "C" { - fn increment_all_parts(_: LARGE_INTEGER) -> LARGE_INTEGER; -} - -fn main() { - unsafe { - let mut li = LARGE_INTEGER { QuadPart: 0 }; - let li_c = increment_all_parts(li); - li.__unnamed__.LowPart += 1; - li.__unnamed__.HighPart += 1; - li.u.LowPart += 1; - li.u.HighPart += 1; - li.QuadPart += 1; - assert_eq!(li.QuadPart, li_c.QuadPart); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-const-codegen.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-const-codegen.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-const-codegen.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-const-codegen.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -union U { - a: u64, - b: u64, -} - -const C: U = U { b: 10 }; - -fn main() { - unsafe { - let a = C.a; - let b = C.b; - assert_eq!(a, 10); - assert_eq!(b, 10); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-const-eval-field.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-const-eval-field.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-const-eval-field.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-const-eval-field.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(const_fn)] - -type Field1 = (i32, u32); -type Field2 = f32; -type Field3 = i64; - -union DummyUnion { - field1: Field1, - field2: Field2, - field3: Field3, -} - -const FLOAT1_AS_I32: i32 = 1065353216; -const UNION: DummyUnion = DummyUnion { field1: (FLOAT1_AS_I32, 0) }; - -const fn read_field1() -> Field1 { - const FIELD1: Field1 = unsafe { UNION.field1 }; - FIELD1 -} - -const fn read_field2() -> Field2 { - const FIELD2: Field2 = unsafe { UNION.field2 }; - FIELD2 -} - -const fn read_field3() -> Field3 { - const FIELD3: Field3 = unsafe { UNION.field3 }; - FIELD3 -} - -fn main() { - let foo = FLOAT1_AS_I32; - assert_eq!(read_field1().0, foo); - assert_eq!(read_field1().0, FLOAT1_AS_I32); - - let foo = 1.0; - assert_eq!(read_field2(), foo); - assert_eq!(read_field2(), 1.0); - - assert_eq!(read_field3(), unsafe { UNION.field3 }); - let foo = unsafe { UNION.field3 }; - assert_eq!(read_field3(), foo); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-derive.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-derive.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-derive.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-derive.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(unions_with_drop_fields)] - -// Some traits can be derived for unions. - -#![feature(untagged_unions)] - -#[derive( - Copy, - Clone, - Eq, -)] -union U { - a: u8, - b: u16, -} - -impl PartialEq for U { fn eq(&self, rhs: &Self) -> bool { true } } - -#[derive( - Clone, - Copy, - Eq -)] -union W { - a: T, -} - -impl PartialEq for W { fn eq(&self, rhs: &Self) -> bool { true } } - -fn main() { - let u = U { b: 0 }; - let u1 = u; - let u2 = u.clone(); - assert!(u1 == u2); - - let w = W { a: 0 }; - let w1 = w.clone(); - assert!(w == w1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-drop-assign.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-drop-assign.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-drop-assign.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-drop-assign.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(unions_with_drop_fields)] - -// Drop works for union itself. - -#![feature(untagged_unions)] - -struct S; - -union U { - a: S -} - -impl Drop for S { - fn drop(&mut self) { - unsafe { CHECK += 10; } - } -} - -impl Drop for U { - fn drop(&mut self) { - unsafe { CHECK += 1; } - } -} - -static mut CHECK: u8 = 0; - -fn main() { - unsafe { - let mut u = U { a: S }; - assert_eq!(CHECK, 0); - u = U { a: S }; - assert_eq!(CHECK, 1); // union itself is assigned, union is dropped, field is not dropped - u.a = S; - assert_eq!(CHECK, 11); // union field is assigned, field is dropped - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-drop.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-drop.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-drop.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(unions_with_drop_fields)] - -// Drop works for union itself. - -#![feature(untagged_unions)] - -struct S; - -union U { - a: u8 -} - -union W { - a: S, -} - -union Y { - a: S, -} - -impl Drop for S { - fn drop(&mut self) { - unsafe { CHECK += 10; } - } -} - -impl Drop for U { - fn drop(&mut self) { - unsafe { CHECK += 1; } - } -} - -impl Drop for W { - fn drop(&mut self) { - unsafe { CHECK += 1; } - } -} - -static mut CHECK: u8 = 0; - -fn main() { - unsafe { - assert_eq!(CHECK, 0); - { - let u = U { a: 1 }; - } - assert_eq!(CHECK, 1); // 1, dtor of U is called - { - let w = W { a: S }; - } - assert_eq!(CHECK, 2); // 2, not 11, dtor of S is not called - { - let y = Y { a: S }; - } - assert_eq!(CHECK, 2); // 2, not 12, dtor of S is not called - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-generic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-generic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-generic.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-generic.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(unions_with_drop_fields)] - -#![feature(untagged_unions)] - -union MaybeItem { - elem: T::Item, - none: (), -} - -union U { - a: A, - b: B, -} - -unsafe fn union_transmute(a: A) -> B { - U { a: a }.b -} - -fn main() { - unsafe { - let u = U::> { a: String::from("abcd") }; - - assert_eq!(u.b.len(), 4); - assert_eq!(u.b[0], b'a'); - - let b = union_transmute::<(u8, u8), u16>((1, 1)); - assert_eq!(b, (1 << 8) + 1); - - let v: Vec = vec![1, 2, 3]; - let mut i = v.iter(); - i.next(); - let mi = MaybeItem::> { elem: i.next().unwrap() }; - assert_eq!(*mi.elem, 2); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-inherent-method.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-inherent-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-inherent-method.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-inherent-method.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -union U { - a: u8, -} - -impl U { - fn method(&self) -> u8 { unsafe { self.a } } -} - -fn main() { - let u = U { a: 10 }; - assert_eq!(u.method(), 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-macro.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-macro.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -macro_rules! duplicate { - ($i: item) => { - mod m1 { - $i - } - mod m2 { - $i - } - } -} - -duplicate! { - pub union U { - pub a: u8 - } -} - -fn main() { - let u1 = m1::U { a: 0 }; - let u2 = m2::U { a: 0 }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-nodrop.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-nodrop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-nodrop.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-nodrop.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(core_intrinsics)] -#![feature(untagged_unions)] - -#![allow(unions_with_drop_fields)] -#![allow(dead_code)] - -use std::intrinsics::needs_drop; - -struct NeedDrop; - -impl Drop for NeedDrop { - fn drop(&mut self) {} -} - -// Constant expressios allow `NoDrop` to go out of scope, -// unlike a value of the interior type implementing `Drop`. -static X: () = (NoDrop { inner: NeedDrop }, ()).1; - -// A union that scrubs the drop glue from its inner type -union NoDrop {inner: T} - -// Copy currently can't be implemented on drop-containing unions, -// this may change later -// https://github.com/rust-lang/rust/pull/38934#issuecomment-271219289 - -// // We should be able to implement Copy for NoDrop -// impl Copy for NoDrop {} -// impl Clone for NoDrop {fn clone(&self) -> Self { *self }} - -// // We should be able to implement Copy for things using NoDrop -// #[derive(Copy, Clone)] -struct Foo { - x: NoDrop> -} - -struct Baz { - x: NoDrop>, - y: Box, -} - -union ActuallyDrop {inner: T} - -impl Drop for ActuallyDrop { - fn drop(&mut self) {} -} - -fn main() { - unsafe { - // NoDrop should not make needs_drop true - assert!(!needs_drop::()); - assert!(!needs_drop::>()); - assert!(!needs_drop::>>()); - // presence of other drop types should still work - assert!(needs_drop::()); - // drop impl on union itself should work - assert!(needs_drop::>()); - assert!(needs_drop::>>()); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-overwrite.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-overwrite.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-overwrite.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-overwrite.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(unions_with_drop_fields)] - -#![feature(untagged_unions)] - -#[repr(C)] -struct Pair(T, U); -#[repr(C)] -struct Triple(T, T, T); - -#[repr(C)] -union U { - a: Pair, - b: B, -} - -#[repr(C)] -union W { - a: A, - b: B, -} - -#[cfg(target_endian = "little")] -unsafe fn check() { - let mut u = U:: { b: 0xDE_DE }; - u.a.0 = 0xBE; - assert_eq!(u.b, 0xDE_BE); - - let mut u = U:: { b: 0xDEAD_DEAD }; - u.a.0 = 0xBEEF; - assert_eq!(u.b, 0xDEAD_BEEF); - - let mut u = U:: { b: 0xDEADBEEF_DEADBEEF }; - u.a.0 = 0xBAADF00D; - assert_eq!(u.b, 0xDEADBEEF_BAADF00D); - - let mut w = W::, u8>, u32> { b: 0xDEAD_DEAD }; - w.a.0 = Triple(0, 0, 0); - assert_eq!(w.b, 0xDE00_0000); - - let mut w = W::>, u32> { b: 0xDEAD_DEAD }; - w.a.1 = Triple(0, 0, 0); - assert_eq!(w.b, 0x0000_00AD); -} - -#[cfg(target_endian = "big")] -unsafe fn check() { - let mut u = U:: { b: 0xDE_DE }; - u.a.0 = 0xBE; - assert_eq!(u.b, 0xBE_DE); - - let mut u = U:: { b: 0xDEAD_DEAD }; - u.a.0 = 0xBEEF; - assert_eq!(u.b, 0xBEEF_DEAD); - - let mut u = U:: { b: 0xDEADBEEF_DEADBEEF }; - u.a.0 = 0xBAADF00D; - assert_eq!(u.b, 0xBAADF00D_DEADBEEF); - - let mut w = W::, u8>, u32> { b: 0xDEAD_DEAD }; - w.a.0 = Triple(0, 0, 0); - assert_eq!(w.b, 0x0000_00AD); - - let mut w = W::>, u32> { b: 0xDEAD_DEAD }; - w.a.1 = Triple(0, 0, 0); - assert_eq!(w.b, 0xDE00_0000); -} - -fn main() { - unsafe { - check(); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-packed.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-packed.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-packed.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-packed.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,181 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_snake_case)] - -#![feature(untagged_unions)] -#![feature(repr_packed)] - -use std::mem::{size_of, size_of_val, align_of, align_of_val}; - -struct S { - a: u16, - b: [u8; 3], -} - -#[repr(packed)] -struct Sp1 { - a: u16, - b: [u8; 3], -} - -#[repr(packed(2))] -struct Sp2 { - a: u16, - b: [u8; 3], -} - -union U { - a: u16, - b: [u8; 3], -} - -#[repr(packed)] -union Up1 { - a: u16, - b: [u8; 3], -} - -#[repr(packed(2))] -union Up2 { - a: u16, - b: [u8; 3], -} - -#[repr(C, packed(4))] -union Up4c { - a: u16, - b: [u8; 3], -} - -const CS: S = S { a: 0, b: [0, 0, 0] }; -const CSP1: Sp1 = Sp1 { a: 0, b: [0, 0, 0] }; -const CSP2: Sp2 = Sp2 { a: 0, b: [0, 0, 0] }; -const CU: U = U { b: [0, 0, 0] }; -const CUP1: Up1 = Up1 { b: [0, 0, 0] }; -const CUP2: Up2 = Up2 { b: [0, 0, 0] }; -const CUP4C: Up4c = Up4c { b: [0, 0, 0] }; - -fn main() { - let s = S { a: 0, b: [0, 0, 0] }; - assert_eq!(size_of::(), 6); - assert_eq!(size_of_val(&s), 6); - assert_eq!(size_of_val(&CS), 6); - assert_eq!(align_of::(), 2); - assert_eq!(align_of_val(&s), 2); - assert_eq!(align_of_val(&CS), 2); - - let sp1 = Sp1 { a: 0, b: [0, 0, 0] }; - assert_eq!(size_of::(), 5); - assert_eq!(size_of_val(&sp1), 5); - assert_eq!(size_of_val(&CSP1), 5); - assert_eq!(align_of::(), 1); - assert_eq!(align_of_val(&sp1), 1); - assert_eq!(align_of_val(&CSP1), 1); - - let sp2 = Sp2 { a: 0, b: [0, 0, 0] }; - assert_eq!(size_of::(), 6); - assert_eq!(size_of_val(&sp2), 6); - assert_eq!(size_of_val(&CSP2), 6); - assert_eq!(align_of::(), 2); - assert_eq!(align_of_val(&sp2), 2); - assert_eq!(align_of_val(&CSP2), 2); - - let u = U { b: [0, 0, 0] }; - assert_eq!(size_of::(), 4); - assert_eq!(size_of_val(&u), 4); - assert_eq!(size_of_val(&CU), 4); - assert_eq!(align_of::(), 2); - assert_eq!(align_of_val(&u), 2); - assert_eq!(align_of_val(&CU), 2); - - let Up1 = Up1 { b: [0, 0, 0] }; - assert_eq!(size_of::(), 3); - assert_eq!(size_of_val(&Up1), 3); - assert_eq!(size_of_val(&CUP1), 3); - assert_eq!(align_of::(), 1); - assert_eq!(align_of_val(&Up1), 1); - assert_eq!(align_of_val(&CUP1), 1); - - let up2 = Up2 { b: [0, 0, 0] }; - assert_eq!(size_of::(), 4); - assert_eq!(size_of_val(&up2), 4); - assert_eq!(size_of_val(&CUP2), 4); - assert_eq!(align_of::(), 2); - assert_eq!(align_of_val(&up2), 2); - assert_eq!(align_of_val(&CUP2), 2); - - let up4c = Up4c { b: [0, 0, 0] }; - assert_eq!(size_of::(), 4); - assert_eq!(size_of_val(&up4c), 4); - assert_eq!(size_of_val(&CUP4C), 4); - assert_eq!(align_of::(), 2); - assert_eq!(align_of_val(&up4c), 2); - assert_eq!(align_of_val(&CUP4C), 2); - - hybrid::check_hybrid(); -} - -mod hybrid { - use std::mem::{size_of, align_of}; - - #[repr(packed)] - struct S1 { - a: u16, - b: u8, - } - - #[repr(packed)] - union U { - s: S1, - c: u16, - } - - #[repr(packed)] - struct S2 { - d: u8, - u: U, - } - - #[repr(C, packed(2))] - struct S1C { - a: u16, - b: u8, - } - - #[repr(C, packed(2))] - union UC { - s: S1, - c: u16, - } - - #[repr(C, packed(2))] - struct S2C { - d: u8, - u: UC, - } - - pub fn check_hybrid() { - assert_eq!(align_of::(), 1); - assert_eq!(size_of::(), 3); - assert_eq!(align_of::(), 1); - assert_eq!(size_of::(), 3); - assert_eq!(align_of::(), 1); - assert_eq!(size_of::(), 4); - - assert_eq!(align_of::(), 2); - assert_eq!(size_of::(), 4); - assert_eq!(align_of::(), 2); - assert_eq!(size_of::(), 4); - assert_eq!(align_of::(), 2); - assert_eq!(size_of::(), 6); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-pat-refutability.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-pat-refutability.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-pat-refutability.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-pat-refutability.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(illegal_floating_point_literal_pattern)] - -#[repr(u32)] -enum Tag { I, F } - -#[repr(C)] -union U { - i: i32, - f: f32, -} - -#[repr(C)] -struct Value { - tag: Tag, - u: U, -} - -fn is_zero(v: Value) -> bool { - unsafe { - match v { - Value { tag: Tag::I, u: U { i: 0 } } => true, - Value { tag: Tag::F, u: U { f: 0.0 } } => true, - _ => false, - } - } -} - -union W { - a: u8, - b: u8, -} - -fn refut(w: W) { - unsafe { - match w { - W { a: 10 } => { - panic!(); - } - W { b } => { - assert_eq!(b, 11); - } - } - } -} - -fn main() { - let v = Value { tag: Tag::I, u: U { i: 1 } }; - assert_eq!(is_zero(v), false); - - let w = W { a: 11 }; - refut(w); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-trait-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-trait-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-trait-impl.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-trait-impl.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -use std::fmt; - -union U { - a: u8 -} - -impl fmt::Display for U { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - unsafe { write!(f, "Oh hai {}", self.a) } - } -} - -fn main() { - assert_eq!(U { a: 2 }.to_string(), "Oh hai 2"); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-transmute.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-transmute.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-transmute.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-transmute.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -extern crate core; -use core::f32; - -union U { - a: (u8, u8), - b: u16, -} - -union W { - a: u32, - b: f32, -} - -fn main() { - unsafe { - let mut u = U { a: (1, 1) }; - assert_eq!(u.b, (1 << 8) + 1); - u.b = (2 << 8) + 2; - assert_eq!(u.a, (2, 2)); - - let mut w = W { a: 0b0_11111111_00000000000000000000000 }; - assert_eq!(w.b, f32::INFINITY); - w.b = f32::NEG_INFINITY; - assert_eq!(w.a, 0b1_11111111_00000000000000000000000); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-with-drop-fields-lint.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-with-drop-fields-lint.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/union/union-with-drop-fields-lint.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/union/union-with-drop-fields-lint.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(untagged_unions)] -#![allow(dead_code)] -#![allow(unions_with_drop_fields)] - -union U { - a: u8, // OK -} - -union W { - a: String, // OK - b: String, // OK -} - -struct S(String); - -// `S` doesn't implement `Drop` trait, but still has non-trivial destructor -union Y { - a: S, // OK -} - -// We don't know if `T` is trivially-destructable or not until trans -union J { - a: T, // OK -} - -union H { - a: T, // OK -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-assign-copy.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-assign-copy.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-assign-copy.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-assign-copy.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -pub fn main() { - let mut i: Box<_> = box 1; - // Should be a copy - let mut j; - j = i.clone(); - *i = 2; - *j = 3; - assert_eq!(*i, 2); - assert_eq!(*j, 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-assign-drop.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-assign-drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-assign-drop.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-assign-drop.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(box_syntax)] - -pub fn main() { - let i: Box<_> = box 1; - let mut j: Box<_> = box 2; - // Should drop the previous value of j - j = i; - assert_eq!(*j, 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-assign-generic.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-assign-generic.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-assign-generic.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-assign-generic.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -fn f(t: T) -> T { - let t1 = t; - t1 -} - -pub fn main() { - let t = f::>(box 100); - assert_eq!(t, box 100); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-assign.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-assign.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-assign.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-assign.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -pub fn main() { - let mut i: Box<_>; - i = box 1; - assert_eq!(*i, 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-autoderef-field.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-autoderef-field.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-autoderef-field.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-autoderef-field.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -struct J { j: isize } - -pub fn main() { - let i: Box<_> = box J { - j: 100 - }; - assert_eq!(i.j, 100); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-autoderef-index.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-autoderef-index.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-autoderef-index.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-autoderef-index.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -pub fn main() { - let i: Box<_> = box vec![100]; - assert_eq!((*i)[0], 100); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-cmp.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-cmp.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-cmp.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-cmp.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -pub fn main() { - let i: Box<_> = box 100; - assert_eq!(i, box 100); - assert!(i < box 101); - assert!(i <= box 100); - assert!(i > box 99); - assert!(i >= box 99); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-containing-tag.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-containing-tag.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-containing-tag.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-containing-tag.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - -pub fn main() { - enum t { t1(isize), t2(isize), } - - let _x: Box<_> = box t::t1(10); - - /*alt *x { - t1(a) { - assert_eq!(a, 10); - } - _ { panic!(); } - }*/ - - /*alt x { - box t1(a) { - assert_eq!(a, 10); - } - _ { panic!(); } - }*/ -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-create.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-create.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-create.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-create.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - -pub fn main() { - let _: Box<_> = box 100; -} - -fn vec() { - vec![0]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-decl-init-copy.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-decl-init-copy.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-decl-init-copy.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-decl-init-copy.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -pub fn main() { - let mut i: Box<_> = box 1; - // Should be a copy - let mut j = i.clone(); - *i = 2; - *j = 3; - assert_eq!(*i, 2); - assert_eq!(*j, 3); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-decl-init.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-decl-init.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-decl-init.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-decl-init.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -pub fn main() { - let i: Box<_> = box 1; - let j = i; - assert_eq!(*j, 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-decl-move.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-decl-move.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-decl-move.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-decl-move.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -pub fn main() { - let i: Box<_> = box 100; - let j = i; - assert_eq!(*j, 100); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-decl.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-decl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-decl.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-decl.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - - -pub fn main() { - let _: Box; -} - -fn f(_i: Box) -> Box { - panic!(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-deref.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-deref.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-deref.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-deref.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -pub fn main() { - let i: Box<_> = box 100; - assert_eq!(*i, 100); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-destructure.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-destructure.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-destructure.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-destructure.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_patterns)] -#![feature(box_syntax)] - -struct Foo { a: isize, b: isize } - -pub fn main() { - let box Foo{a, b} = box Foo{a: 100, b: 200}; - assert_eq!(a + b, 300); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-drop-complex.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-drop-complex.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-drop-complex.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-drop-complex.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - -pub fn main() { - let _x: Box<_> = box vec![0,0,0,0,0]; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-ffi-symbols.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-ffi-symbols.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-ffi-symbols.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-ffi-symbols.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// We used to have a __rust_abi shim that resulted in duplicated symbols -// whenever the item path wasn't enough to disambiguate between them. -fn main() { - let a = { - extern fn good() -> i32 { return 0; } - good as extern fn() -> i32 - }; - let b = { - extern fn good() -> i32 { return 5; } - good as extern fn() -> i32 - }; - - assert!(a != b); - assert_eq!((a(), b()), (0, 5)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-fn-arg-move.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-fn-arg-move.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-fn-arg-move.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-fn-arg-move.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -fn f(i: Box) { - assert_eq!(*i, 100); -} - -pub fn main() { - let i = box 100; - f(i); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-fn-arg-mut.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-fn-arg-mut.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-fn-arg-mut.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-fn-arg-mut.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -fn f(i: &mut Box) { - *i = box 200; -} - -pub fn main() { - let mut i = box 100; - f(&mut i); - assert_eq!(*i, 200); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-fn-arg.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-fn-arg.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-fn-arg.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-fn-arg.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -fn f(i: Box) { - assert_eq!(*i, 100); -} - -pub fn main() { - f(box 100); - let i = box 100; - f(i); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-fn-ret.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-fn-ret.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-fn-ret.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-fn-ret.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -fn f() -> Box { - box 100 -} - -pub fn main() { - assert_eq!(f(), box 100); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-generic-assign.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-generic-assign.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-generic-assign.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-generic-assign.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #976 - - -// pretty-expanded FIXME #23616 - -fn f(x: Box) { - let _x2 = x; -} -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-init.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-init.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-init.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-init.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - -pub fn main() { - let _i: Box<_> = box 100; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-in-tag.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-in-tag.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-in-tag.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-in-tag.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -#![feature(box_syntax)] - -fn test1() { - enum bar { u(Box), w(isize), } - - let x = bar::u(box 10); - assert!(match x { - bar::u(a) => { - println!("{}", a); - *a - } - _ => { 66 } - } == 10); -} - -pub fn main() { - test1(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-in-vec-copy.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-in-vec-copy.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-in-vec-copy.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-in-vec-copy.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -pub fn main() { - let mut a: Vec> = vec![box 10]; - let b = a.clone(); - - assert_eq!(*a[0], 10); - assert_eq!(*b[0], 10); - - // This should only modify the value in a, not b - *a[0] = 20; - - assert_eq!(*a[0], 20); - assert_eq!(*b[0], 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-in-vec.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-in-vec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-in-vec.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-in-vec.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -pub fn main() { - let vect : Vec> = vec![box 100]; - assert_eq!(vect[0], box 100); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-kinds.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-kinds.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-kinds.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-kinds.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -use std::cmp::PartialEq; -use std::fmt::Debug; - -fn sendable() { - - fn f(i: T, j: T) { - assert_eq!(i, j); - } - - fn g(i: T, j: T) { - assert!(i != j); - } - - let i: Box<_> = box 100; - let j: Box<_> = box 100; - f(i, j); - let i: Box<_> = box 100; - let j: Box<_> = box 101; - g(i, j); -} - -fn copyable() { - - fn f(i: T, j: T) { - assert_eq!(i, j); - } - - fn g(i: T, j: T) { - assert!(i != j); - } - - let i: Box<_> = box 100; - let j: Box<_> = box 100; - f(i, j); - let i: Box<_> = box 100; - let j: Box<_> = box 101; - g(i, j); -} - -fn noncopyable() { - - fn f(i: T, j: T) { - assert_eq!(i, j); - } - - fn g(i: T, j: T) { - assert!(i != j); - } - - let i: Box<_> = box 100; - let j: Box<_> = box 100; - f(i, j); - let i: Box<_> = box 100; - let j: Box<_> = box 101; - g(i, j); -} - -pub fn main() { - sendable(); - copyable(); - noncopyable(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-log.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-log.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-log.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-log.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -pub fn main() { - let i: Box<_> = box 100; - println!("{}", i); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-match-discrim.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-match-discrim.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-match-discrim.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-match-discrim.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #961 - -// pretty-expanded FIXME #23616 - -fn altsimple() { - match Box::new(true) { - _ => { } - } -} -pub fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-move-drop.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-move-drop.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-move-drop.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-move-drop.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![allow(unused_variables)] -#![feature(box_syntax)] - -pub fn main() { - let i: Box<_> = box 100; - let j: Box<_> = box 200; - let j = i; - assert_eq!(*j, 100); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-move.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-move.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-move.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-move.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -pub fn main() { - let i: Box<_> = box 100; - let mut j; - j = i; - assert_eq!(*j, 100); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-move-temp.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-move-temp.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-move-temp.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-move-temp.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -pub fn main() { - let mut i: Box<_>; - i = box 100; - assert_eq!(*i, 100); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-mutable.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-mutable.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-mutable.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-mutable.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -pub fn main() { - let mut i: Box<_> = box 0; - *i = 1; - assert_eq!(*i, 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-object-move.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-object-move.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-object-move.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-object-move.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Issue #5192 - -// pretty-expanded FIXME #23616 - -#![feature(box_syntax)] - -pub trait EventLoop { fn foo(&self) {} } - -pub struct UvEventLoop { - uvio: isize -} - -impl EventLoop for UvEventLoop { } - -pub fn main() { - let loop_: Box = box UvEventLoop { uvio: 0 } as Box; - let _loop2_ = loop_; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-pat-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-pat-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-pat-2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-pat-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] -#![allow(non_shorthand_field_patterns)] - -#![feature(box_patterns)] -#![feature(box_syntax)] - -struct Foo {a: isize, b: usize} - -enum bar { u(Box), w(isize), } - -pub fn main() { - assert!(match bar::u(box Foo{a: 10, b: 40}) { - bar::u(box Foo{a: a, b: b}) => { a + (b as isize) } - _ => { 66 } - } == 50); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-pat-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-pat-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-pat-3.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-pat-3.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_camel_case_types)] - -#![feature(box_syntax)] - -enum bar { u(Box), w(isize), } - -pub fn main() { - assert!(match bar::u(box 10) { - bar::u(a) => { - println!("{}", a); - *a - } - _ => { 66 } - } == 10); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-pat.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-pat.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-pat.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-pat.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(box_patterns)] -#![feature(box_syntax)] - -fn simple() { - match box true { - box true => { } - _ => { panic!(); } - } -} - -pub fn main() { - simple(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-rec.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-rec.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-rec.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-rec.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -struct X { x: isize } - -pub fn main() { - let x: Box<_> = box X {x: 1}; - let bar = x; - assert_eq!(bar.x, 1); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-send-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-send-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-send-2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-send-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// ignore-emscripten no threads support - -#![feature(box_syntax)] - -use std::sync::mpsc::{channel, Sender}; -use std::thread; - -fn child(tx: &Sender>, i: usize) { - tx.send(box i).unwrap(); -} - -pub fn main() { - let (tx, rx) = channel(); - let n = 100; - let mut expected = 0; - let ts = (0..n).map(|i| { - expected += i; - let tx = tx.clone(); - thread::spawn(move|| { - child(&tx, i) - }) - }).collect::>(); - - let mut actual = 0; - for _ in 0..n { - let j = rx.recv().unwrap(); - actual += *j; - } - - assert_eq!(expected, actual); - - for t in ts { t.join(); } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-send.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-send.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-send.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-send.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -use std::sync::mpsc::channel; - -pub fn main() { - let (tx, rx) = channel::>(); - tx.send(box 100).unwrap(); - let v = rx.recv().unwrap(); - assert_eq!(v, box 100); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-swap.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-swap.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-swap.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unique/unique-swap.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![feature(box_syntax)] - -use std::mem::swap; - -pub fn main() { - let mut i: Box<_> = box 100; - let mut j: Box<_> = box 200; - swap(&mut i, &mut j); - assert_eq!(i, box 200); - assert_eq!(j, box 100); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unsized-locals/reference-unsized-locals.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unsized-locals/reference-unsized-locals.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unsized-locals/reference-unsized-locals.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unsized-locals/reference-unsized-locals.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(unsized_locals)] - -fn main() { - let foo: Box<[u8]> = Box::new(*b"foo"); - let foo: [u8] = *foo; - assert_eq!(&foo, b"foo" as &[u8]); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unsized-locals/simple-unsized-locals.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unsized-locals/simple-unsized-locals.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unsized-locals/simple-unsized-locals.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unsized-locals/simple-unsized-locals.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(unsized_locals)] - -fn main() { - let foo: Box<[u8]> = Box::new(*b"foo"); - let _foo: [u8] = *foo; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unsized-locals/unsized-exprs.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unsized-locals/unsized-exprs.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unsized-locals/unsized-exprs.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unsized-locals/unsized-exprs.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(unsized_tuple_coercion, unsized_locals)] - -struct A(X); - -fn udrop(_x: T) {} -fn foo() -> Box<[u8]> { - Box::new(*b"foo") -} -fn tfoo() -> Box<(i32, [u8])> { - Box::new((42, *b"foo")) -} -fn afoo() -> Box> { - Box::new(A(*b"foo")) -} - -impl std::ops::Add for A<[u8]> { - type Output = (); - fn add(self, _rhs: i32) -> Self::Output {} -} - -fn main() { - udrop::<[u8]>(loop { - break *foo(); - }); - udrop::<[u8]>(if true { - *foo() - } else { - *foo() - }); - udrop::<[u8]>({*foo()}); - #[allow(unused_parens)] - udrop::<[u8]>((*foo())); - udrop::<[u8]>((*tfoo()).1); - *afoo() + 42; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unsized-locals/unsized-parameters.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unsized-locals/unsized-parameters.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/unsized-locals/unsized-parameters.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/unsized-locals/unsized-parameters.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass - -#![feature(unsized_locals)] - -pub fn f0(_f: dyn FnOnce()) {} -pub fn f1(_s: str) {} -pub fn f2((_x, _y): (i32, [i32])) {} - -fn main() { - let foo = "foo".to_string().into_boxed_str(); - f1(*foo); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/auxiliary/where_clauses_xc.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/auxiliary/where_clauses_xc.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/auxiliary/where_clauses_xc.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/auxiliary/where_clauses_xc.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub trait Equal { - fn equal(&self, other: &Self) -> bool; - fn equals(&self, this: &T, that: &T, x: &U, y: &U) -> bool - where T: Eq, U: Eq; -} - -impl Equal for T where T: Eq { - fn equal(&self, other: &T) -> bool { - self == other - } - fn equals(&self, this: &U, other: &U, x: &X, y: &X) -> bool - where U: Eq, X: Eq { - this == other && x == y - } -} - -pub fn equal(x: &T, y: &T) -> bool where T: Eq { - x == y -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clause-bounds-inconsistency.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clause-bounds-inconsistency.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clause-bounds-inconsistency.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clause-bounds-inconsistency.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait Bound { - fn dummy(&self) { } -} - -trait Trait { - fn a(&self, _: T) where T: Bound; - fn b(&self, _: T) where T: Bound; - fn c(&self, _: T); - fn d(&self, _: T); -} - -impl Trait for bool { - fn a(&self, _: T) {} - //^~ This gets rejected but should be accepted - fn b(&self, _: T) where T: Bound {} - fn c(&self, _: T) {} - fn d(&self, _: T) where T: Bound {} -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clause-early-bound-lifetimes.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clause-early-bound-lifetimes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clause-early-bound-lifetimes.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clause-early-bound-lifetimes.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -// pretty-expanded FIXME #23616 - -trait TheTrait { fn dummy(&self) { } } - -impl TheTrait for &'static isize { } - -fn foo<'a,T>(_: &'a T) where &'a T : TheTrait { } - -fn bar(_: &'static T) where &'static T : TheTrait { } - -fn main() { - static x: isize = 1; - foo(&x); - bar(&x); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clause-method-substituion.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clause-method-substituion.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clause-method-substituion.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clause-method-substituion.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -trait Foo { fn dummy(&self, arg: T) { } } - -trait Bar { - fn method(&self) where A: Foo; -} - -struct S; -struct X; - -impl Foo for X {} - -impl Bar for i32 { - fn method(&self) where X: Foo { - } -} - -fn main() { - 1.method::(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clause-region-outlives.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clause-region-outlives.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clause-region-outlives.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clause-region-outlives.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -struct A<'a, 'b> where 'a : 'b { x: &'a isize, y: &'b isize } - -fn main() { - let x = 1; - let y = 1; - let a = A { x: &x, y: &y }; -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clauses-cross-crate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clauses-cross-crate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clauses-cross-crate.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clauses-cross-crate.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// aux-build:where_clauses_xc.rs - -extern crate where_clauses_xc; - -use where_clauses_xc::{Equal, equal}; - -fn main() { - println!("{}", equal(&1, &2)); - println!("{}", equal(&1, &1)); - println!("{}", "hello".equal(&"hello")); - println!("{}", "hello".equals::(&1, &1, &"foo", &"bar")); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clauses-lifetimes.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clauses-lifetimes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clauses-lifetimes.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clauses-lifetimes.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -fn foo<'a, I>(mut it: I) where I: Iterator {} - -fn main() { - foo([1, 2].iter()); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clauses-method.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clauses-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clauses-method.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clauses-method.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// Test that a where clause attached to a method allows us to add -// additional constraints to a parameter out of scope. - -struct Foo { - value: T -} - -impl Foo { - fn equals(&self, u: &Foo) -> bool where T : Eq { - self.value == u.value - } -} - -fn main() { - let x = Foo { value: 1 }; - let y = Foo { value: 2 }; - println!("{}", x.equals(&x)); - println!("{}", x.equals(&y)); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clauses.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clauses.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clauses.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clauses.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -trait Equal { - fn equal(&self, other: &Self) -> bool; - fn equals(&self, this: &T, that: &T, x: &U, y: &U) -> bool - where T: Eq, U: Eq; -} - -impl Equal for T where T: Eq { - fn equal(&self, other: &T) -> bool { - self == other - } - fn equals(&self, this: &U, other: &U, x: &X, y: &X) -> bool - where U: Eq, X: Eq { - this == other && x == y - } -} - -fn equal(x: &T, y: &T) -> bool where T: Eq { - x == y -} - -fn main() { - println!("{}", equal(&1, &2)); - println!("{}", equal(&1, &1)); - println!("{}", "hello".equal(&"hello")); - println!("{}", "hello".equals::(&1, &1, &"foo", &"bar")); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clauses-unboxed-closures.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clauses-unboxed-closures.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clauses-unboxed-closures.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/where-clauses/where-clauses-unboxed-closures.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// pretty-expanded FIXME #23616 - -struct Bencher; - -// ICE -fn warm_up<'a, F>(f: F) where F: Fn(&'a mut Bencher) { -} - -fn main() { - // ICE trigger - warm_up(|b: &mut Bencher| () ); - - // OK - warm_up(|b| () ); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-binary-heap-push.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-binary-heap-push.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-binary-heap-push.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-binary-heap-push.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::collections::BinaryHeap; -use std::iter::Iterator; - -fn main() { - const N: usize = 8; - - for len in 0..N { - let mut tester = BinaryHeap::with_capacity(len); - assert_eq!(tester.len(), 0); - assert!(tester.capacity() >= len); - for bit in 0..len { - tester.push(()); - } - assert_eq!(tester.len(), len); - assert_eq!(tester.iter().count(), len); - tester.clear(); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-btreemap-insert.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-btreemap-insert.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-btreemap-insert.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-btreemap-insert.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::cmp::{Ord, Ordering, PartialOrd}; -use std::collections::BTreeMap; -use std::iter::Iterator; - -#[derive(Eq, Hash, Debug, Ord, PartialEq, PartialOrd)] -struct Zst; - -fn main() { - const N: usize = 8; - - for len in 0..N { - let mut tester = BTreeMap::new(); - assert_eq!(tester.len(), 0); - for bit in 0..len { - tester.insert(Zst, ()); - } - assert_eq!(tester.len(), if len == 0 { 0 } else { 1 }); - assert_eq!(tester.iter().count(), if len == 0 { 0 } else { 1 }); - assert_eq!(tester.get(&Zst).is_some(), len > 0); - tester.clear(); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-linkedlist-push.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-linkedlist-push.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-linkedlist-push.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-linkedlist-push.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::collections::LinkedList; -use std::iter::Iterator; - -fn main() { - const N: usize = 8; - - // Test that for all possible sequences of push_front / push_back, - // we end up with a LinkedList of the correct size - - for len in 0..N { - let mut tester = LinkedList::new(); - assert_eq!(tester.len(), 0); - assert_eq!(tester.front(), None); - for case in 0..(1 << len) { - assert_eq!(tester.len(), 0); - for bit in 0..len { - if case & (1 << bit) != 0 { - tester.push_front(()); - } else { - tester.push_back(()); - } - } - assert_eq!(tester.len(), len); - assert_eq!(tester.iter().count(), len); - tester.clear(); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-tuple-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-tuple-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-tuple-struct.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-tuple-struct.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(unused_assignments)] - -// Make sure that the constructor args are codegened for zero-sized tuple structs - -struct Foo(()); - -fn main() { - let mut a = 1; - Foo({ a = 2 }); - assert_eq!(a, 2); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-vec-deque-push.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-vec-deque-push.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-vec-deque-push.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-vec-deque-push.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::collections::VecDeque; -use std::iter::Iterator; - -fn main() { - const N: usize = 8; - - // Zero sized type - struct Zst; - - // Test that for all possible sequences of push_front / push_back, - // we end up with a deque of the correct size - - for len in 0..N { - let mut tester = VecDeque::with_capacity(len); - assert_eq!(tester.len(), 0); - assert!(tester.capacity() >= len); - for case in 0..(1 << len) { - assert_eq!(tester.len(), 0); - for bit in 0..len { - if case & (1 << bit) != 0 { - tester.push_front(Zst); - } else { - tester.push_back(Zst); - } - } - assert_eq!(tester.len(), len); - assert_eq!(tester.iter().count(), len); - tester.clear(); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-vec-push.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-vec-push.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-vec-push.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-sized-vec-push.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -use std::iter::Iterator; -use std::vec::Vec; - -fn main() { - const N: usize = 8; - - for len in 0..N { - let mut tester = Vec::with_capacity(len); - assert_eq!(tester.len(), 0); - assert!(tester.capacity() >= len); - for bit in 0..len { - tester.push(()); - } - assert_eq!(tester.len(), len); - assert_eq!(tester.iter().count(), len); - tester.clear(); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-size-type-destructors.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-size-type-destructors.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-size-type-destructors.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/run-pass/zero-sized/zero-size-type-destructors.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(non_upper_case_globals)] - -static mut destructions : isize = 3; - -pub fn foo() { - struct Foo; - - impl Drop for Foo { - fn drop(&mut self) { - unsafe { destructions -= 1 }; - } - }; - - let _x = [Foo, Foo, Foo]; -} - -pub fn main() { - foo(); - assert_eq!(unsafe { destructions }, 0); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/auxiliary/baz.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/auxiliary/baz.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/auxiliary/baz.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/auxiliary/baz.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This file is used as part of the local-path-suggestions.rs test. + +pub mod foobar { + pub struct Baz; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/auxiliary/edition-lint-paths.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/auxiliary/edition-lint-paths.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/auxiliary/edition-lint-paths.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/auxiliary/edition-lint-paths.rs 2018-12-04 23:41:40.000000000 +0000 @@ -9,3 +9,14 @@ // except according to those terms. pub fn foo() {} + +#[macro_export] +macro_rules! macro_2015 { + () => { + use edition_lint_paths as other_name; + use edition_lint_paths::foo as other_foo; + fn check_macro_2015() { + ::edition_lint_paths::foo(); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/auxiliary/trait-import-suggestions.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/auxiliary/trait-import-suggestions.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/auxiliary/trait-import-suggestions.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/auxiliary/trait-import-suggestions.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait Baz { + fn baz(&self) { } +} + +impl Baz for u32 { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/dyn-keyword.fixed rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/dyn-keyword.fixed --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/dyn-keyword.fixed 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/dyn-keyword.fixed 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +// edition:2015 +// run-rustfix + +#![allow(unused_variables)] +#![deny(keyword_idents)] + +fn main() { + let r#dyn = (); //~ ERROR dyn + //~^ WARN hard error in the 2018 edition +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/dyn-keyword.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/dyn-keyword.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/dyn-keyword.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/dyn-keyword.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +// edition:2015 +// run-rustfix + +#![allow(unused_variables)] +#![deny(keyword_idents)] + +fn main() { + let dyn = (); //~ ERROR dyn + //~^ WARN hard error in the 2018 edition +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/dyn-keyword.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/dyn-keyword.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/dyn-keyword.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/dyn-keyword.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +error: `dyn` is a keyword in the 2018 edition + --> $DIR/dyn-keyword.rs:8:9 + | +LL | let dyn = (); //~ ERROR dyn + | ^^^ help: you can use a raw identifier to stay compatible: `r#dyn` + | +note: lint level defined here + --> $DIR/dyn-keyword.rs:5:9 + | +LL | #![deny(keyword_idents)] + | ^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! + = note: for more information, see issue #49716 + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/dyn-trait-compatibility.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/dyn-trait-compatibility.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/dyn-trait-compatibility.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/dyn-trait-compatibility.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +// edition:2018 + +type A0 = dyn; +type A1 = dyn::dyn; //~ERROR expected identifier, found reserved keyword +type A2 = dyn; //~ERROR expected identifier, found `<` +type A3 = dyn<::dyn>; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/dyn-trait-compatibility.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/dyn-trait-compatibility.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/dyn-trait-compatibility.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/dyn-trait-compatibility.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +error: expected identifier, found reserved keyword `dyn` + --> $DIR/dyn-trait-compatibility.rs:4:16 + | +LL | type A1 = dyn::dyn; //~ERROR expected identifier, found reserved keyword + | ^^^ expected identifier, found reserved keyword + +error: expected identifier, found `<` + --> $DIR/dyn-trait-compatibility.rs:5:14 + | +LL | type A2 = dyn; //~ERROR expected identifier, found `<` + | ^ expected identifier + +error: aborting due to 2 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-infer-outlives.fixed rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-infer-outlives.fixed --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-infer-outlives.fixed 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-infer-outlives.fixed 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,212 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-rustfix + +#![allow(unused)] +#![deny(explicit_outlives_requirements)] + +use std::fmt::{Debug, Display}; + + +// Programmatically generated examples! +// +// Exercise outlives bounds for each of the following parameter/position +// combinations— +// +// • one generic parameter (T) bound inline +// • one parameter (T) with a where clause +// • two parameters (T and U), both bound inline +// • two parameters (T and U), one bound inline, one with a where clause +// • two parameters (T and U), both with where clauses +// +// —and for every permutation of 0, 1, or 2 lifetimes to outlive and 0 or 1 +// trait bounds distributed among said parameters (subject to no where clause +// being empty and the struct having at least one lifetime). + + +struct TeeOutlivesAy<'a, T> { + //~^ ERROR outlives requirements can be inferred + tee: &'a T +} + +struct TeeOutlivesAyIsDebug<'a, T: Debug> { + //~^ ERROR outlives requirements can be inferred + tee: &'a T +} + +struct TeeIsDebugOutlivesAy<'a, T: Debug> { + //~^ ERROR outlives requirements can be inferred + tee: &'a T +} + +struct TeeOutlivesAyBee<'a, 'b, T> { + //~^ ERROR outlives requirements can be inferred + tee: &'a &'b T +} + +struct TeeOutlivesAyBeeIsDebug<'a, 'b, T: Debug> { + //~^ ERROR outlives requirements can be inferred + tee: &'a &'b T +} + +struct TeeIsDebugOutlivesAyBee<'a, 'b, T: Debug> { + //~^ ERROR outlives requirements can be inferred + tee: &'a &'b T +} + +struct TeeWhereOutlivesAy<'a, T> { + //~^ ERROR outlives requirements can be inferred + tee: &'a T +} + +struct TeeWhereOutlivesAyIsDebug<'a, T> where T: Debug { + //~^ ERROR outlives requirements can be inferred + tee: &'a T +} + +struct TeeWhereIsDebugOutlivesAy<'a, T> where T: Debug { + //~^ ERROR outlives requirements can be inferred + tee: &'a T +} + +struct TeeWhereOutlivesAyBee<'a, 'b, T> { + //~^ ERROR outlives requirements can be inferred + tee: &'a &'b T +} + +struct TeeWhereOutlivesAyBeeIsDebug<'a, 'b, T> where T: Debug { + //~^ ERROR outlives requirements can be inferred + tee: &'a &'b T +} + +struct TeeWhereIsDebugOutlivesAyBee<'a, 'b, T> where T: Debug { + //~^ ERROR outlives requirements can be inferred + tee: &'a &'b T +} + +struct TeeYooOutlivesAy<'a, T, U> { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a U +} + +struct TeeYooOutlivesAyIsDebug<'a, T, U: Debug> { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a U +} + +struct TeeYooIsDebugOutlivesAy<'a, T, U: Debug> { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a U +} + +struct TeeOutlivesAyYooIsDebug<'a, T, U: Debug> { + //~^ ERROR outlives requirements can be inferred + tee: &'a T, + yoo: U +} + +struct TeeYooOutlivesAyBee<'a, 'b, T, U> { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a &'b U +} + +struct TeeYooOutlivesAyBeeIsDebug<'a, 'b, T, U: Debug> { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a &'b U +} + +struct TeeYooIsDebugOutlivesAyBee<'a, 'b, T, U: Debug> { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a &'b U +} + +struct TeeOutlivesAyBeeYooIsDebug<'a, 'b, T, U: Debug> { + //~^ ERROR outlives requirements can be inferred + tee: &'a &'b T, + yoo: U +} + +struct TeeYooWhereOutlivesAy<'a, T, U> { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a U +} + +struct TeeYooWhereOutlivesAyIsDebug<'a, T, U> where U: Debug { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a U +} + +struct TeeYooWhereIsDebugOutlivesAy<'a, T, U> where U: Debug { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a U +} + +struct TeeOutlivesAyYooWhereIsDebug<'a, T, U> where U: Debug { + //~^ ERROR outlives requirements can be inferred + tee: &'a T, + yoo: U +} + +struct TeeYooWhereOutlivesAyBee<'a, 'b, T, U> { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a &'b U +} + +struct TeeYooWhereOutlivesAyBeeIsDebug<'a, 'b, T, U> where U: Debug { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a &'b U +} + +struct TeeYooWhereIsDebugOutlivesAyBee<'a, 'b, T, U> where U: Debug { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a &'b U +} + +struct TeeOutlivesAyBeeYooWhereIsDebug<'a, 'b, T, U> where U: Debug { + //~^ ERROR outlives requirements can be inferred + tee: &'a &'b T, + yoo: U +} + +struct TeeWhereOutlivesAyYooWhereIsDebug<'a, T, U> where U: Debug { + //~^ ERROR outlives requirements can be inferred + tee: &'a T, + yoo: U +} + +struct TeeWhereOutlivesAyBeeYooWhereIsDebug<'a, 'b, T, U> where U: Debug { + //~^ ERROR outlives requirements can be inferred + tee: &'a &'b T, + yoo: U +} + + +// But outlives inference for 'static lifetimes is under a separate +// feature-gate for now +// (https://github.com/rust-lang/rust/issues/44493#issuecomment-407846046). +struct StaticRef { + field: &'static T +} + + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-infer-outlives-multispan.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-infer-outlives-multispan.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-infer-outlives-multispan.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-infer-outlives-multispan.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,85 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused)] +#![deny(explicit_outlives_requirements)] + +use std::fmt::{Debug, Display}; + +// These examples should live in edition-lint-infer-outlives.rs, but are split +// into this separate file because they can't be `rustfix`'d (and thus, can't +// be part of a `run-rustfix` test file) until rust-lang-nursery/rustfix#141 +// is solved + +struct TeeOutlivesAyIsDebugBee<'a, 'b, T: 'a + Debug + 'b> { + //~^ ERROR outlives requirements can be inferred + tee: &'a &'b T +} + +struct TeeWhereOutlivesAyIsDebugBee<'a, 'b, T> where T: 'a + Debug + 'b { + //~^ ERROR outlives requirements can be inferred + tee: &'a &'b T +} + +struct TeeYooOutlivesAyIsDebugBee<'a, 'b, T, U: 'a + Debug + 'b> { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a &'b U +} + +struct TeeOutlivesAyYooBeeIsDebug<'a, 'b, T: 'a, U: 'b + Debug> { + //~^ ERROR outlives requirements can be inferred + tee: &'a T, + yoo: &'b U +} + +struct TeeOutlivesAyYooIsDebugBee<'a, 'b, T: 'a, U: Debug + 'b> { + //~^ ERROR outlives requirements can be inferred + tee: &'a T, + yoo: &'b U +} + +struct TeeOutlivesAyYooWhereBee<'a, 'b, T: 'a, U> where U: 'b { + //~^ ERROR outlives requirements can be inferred + tee: &'a T, + yoo: &'b U +} + +struct TeeYooWhereOutlivesAyIsDebugBee<'a, 'b, T, U> where U: 'a + Debug + 'b { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a &'b U +} + +struct TeeOutlivesAyYooWhereBeeIsDebug<'a, 'b, T: 'a, U> where U: 'b + Debug { + //~^ ERROR outlives requirements can be inferred + tee: &'a T, + yoo: &'b U +} + +struct TeeOutlivesAyYooWhereIsDebugBee<'a, 'b, T: 'a, U> where U: Debug + 'b { + //~^ ERROR outlives requirements can be inferred + tee: &'a T, + yoo: &'b U +} + +struct TeeWhereOutlivesAyYooWhereBeeIsDebug<'a, 'b, T, U> where T: 'a, U: 'b + Debug { + //~^ ERROR outlives requirements can be inferred + tee: &'a T, + yoo: &'b U +} + +struct TeeWhereOutlivesAyYooWhereIsDebugBee<'a, 'b, T, U> where T: 'a, U: Debug + 'b { + //~^ ERROR outlives requirements can be inferred + tee: &'a T, + yoo: &'b U +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-infer-outlives-multispan.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-infer-outlives-multispan.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-infer-outlives-multispan.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-infer-outlives-multispan.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,118 @@ +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives-multispan.rs:21:43 + | +LL | struct TeeOutlivesAyIsDebugBee<'a, 'b, T: 'a + Debug + 'b> { + | ^^^^^ ^^^^^ + | +note: lint level defined here + --> $DIR/edition-lint-infer-outlives-multispan.rs:12:9 + | +LL | #![deny(explicit_outlives_requirements)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: remove these bounds + | +LL | struct TeeOutlivesAyIsDebugBee<'a, 'b, T: Debug> { + | -- -- + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives-multispan.rs:26:57 + | +LL | struct TeeWhereOutlivesAyIsDebugBee<'a, 'b, T> where T: 'a + Debug + 'b { + | ^^^^^ ^^^^^ +help: remove these bounds + | +LL | struct TeeWhereOutlivesAyIsDebugBee<'a, 'b, T> where T: Debug { + | -- -- + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives-multispan.rs:31:49 + | +LL | struct TeeYooOutlivesAyIsDebugBee<'a, 'b, T, U: 'a + Debug + 'b> { + | ^^^^^ ^^^^^ +help: remove these bounds + | +LL | struct TeeYooOutlivesAyIsDebugBee<'a, 'b, T, U: Debug> { + | -- -- + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives-multispan.rs:37:44 + | +LL | struct TeeOutlivesAyYooBeeIsDebug<'a, 'b, T: 'a, U: 'b + Debug> { + | ^^^^ ^^^^^ +help: remove these bounds + | +LL | struct TeeOutlivesAyYooBeeIsDebug<'a, 'b, T, U: Debug> { + | -- -- + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives-multispan.rs:43:44 + | +LL | struct TeeOutlivesAyYooIsDebugBee<'a, 'b, T: 'a, U: Debug + 'b> { + | ^^^^ ^^^^^ +help: remove these bounds + | +LL | struct TeeOutlivesAyYooIsDebugBee<'a, 'b, T, U: Debug> { + | -- -- + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives-multispan.rs:49:42 + | +LL | struct TeeOutlivesAyYooWhereBee<'a, 'b, T: 'a, U> where U: 'b { + | ^^^^ ^^^^^^^^^^^^ +help: remove these bounds + | +LL | struct TeeOutlivesAyYooWhereBee<'a, 'b, T, U> { + | -- -- + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives-multispan.rs:55:63 + | +LL | struct TeeYooWhereOutlivesAyIsDebugBee<'a, 'b, T, U> where U: 'a + Debug + 'b { + | ^^^^^ ^^^^^ +help: remove these bounds + | +LL | struct TeeYooWhereOutlivesAyIsDebugBee<'a, 'b, T, U> where U: Debug { + | -- -- + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives-multispan.rs:61:49 + | +LL | struct TeeOutlivesAyYooWhereBeeIsDebug<'a, 'b, T: 'a, U> where U: 'b + Debug { + | ^^^^ ^^^^^ +help: remove these bounds + | +LL | struct TeeOutlivesAyYooWhereBeeIsDebug<'a, 'b, T, U> where U: Debug { + | -- -- + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives-multispan.rs:67:49 + | +LL | struct TeeOutlivesAyYooWhereIsDebugBee<'a, 'b, T: 'a, U> where U: Debug + 'b { + | ^^^^ ^^^^^ +help: remove these bounds + | +LL | struct TeeOutlivesAyYooWhereIsDebugBee<'a, 'b, T, U> where U: Debug { + | -- -- + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives-multispan.rs:73:65 + | +LL | struct TeeWhereOutlivesAyYooWhereBeeIsDebug<'a, 'b, T, U> where T: 'a, U: 'b + Debug { + | ^^^^^^^ ^^^^^ +help: remove these bounds + | +LL | struct TeeWhereOutlivesAyYooWhereBeeIsDebug<'a, 'b, T, U> where U: Debug { + | -- -- + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives-multispan.rs:79:65 + | +LL | struct TeeWhereOutlivesAyYooWhereIsDebugBee<'a, 'b, T, U> where T: 'a, U: Debug + 'b { + | ^^^^^^^ ^^^^^ +help: remove these bounds + | +LL | struct TeeWhereOutlivesAyYooWhereIsDebugBee<'a, 'b, T, U> where U: Debug { + | -- -- + +error: aborting due to 11 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-infer-outlives.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-infer-outlives.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-infer-outlives.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-infer-outlives.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,212 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-rustfix + +#![allow(unused)] +#![deny(explicit_outlives_requirements)] + +use std::fmt::{Debug, Display}; + + +// Programmatically generated examples! +// +// Exercise outlives bounds for each of the following parameter/position +// combinations— +// +// • one generic parameter (T) bound inline +// • one parameter (T) with a where clause +// • two parameters (T and U), both bound inline +// • two parameters (T and U), one bound inline, one with a where clause +// • two parameters (T and U), both with where clauses +// +// —and for every permutation of 0, 1, or 2 lifetimes to outlive and 0 or 1 +// trait bounds distributed among said parameters (subject to no where clause +// being empty and the struct having at least one lifetime). + + +struct TeeOutlivesAy<'a, T: 'a> { + //~^ ERROR outlives requirements can be inferred + tee: &'a T +} + +struct TeeOutlivesAyIsDebug<'a, T: 'a + Debug> { + //~^ ERROR outlives requirements can be inferred + tee: &'a T +} + +struct TeeIsDebugOutlivesAy<'a, T: Debug + 'a> { + //~^ ERROR outlives requirements can be inferred + tee: &'a T +} + +struct TeeOutlivesAyBee<'a, 'b, T: 'a + 'b> { + //~^ ERROR outlives requirements can be inferred + tee: &'a &'b T +} + +struct TeeOutlivesAyBeeIsDebug<'a, 'b, T: 'a + 'b + Debug> { + //~^ ERROR outlives requirements can be inferred + tee: &'a &'b T +} + +struct TeeIsDebugOutlivesAyBee<'a, 'b, T: Debug + 'a + 'b> { + //~^ ERROR outlives requirements can be inferred + tee: &'a &'b T +} + +struct TeeWhereOutlivesAy<'a, T> where T: 'a { + //~^ ERROR outlives requirements can be inferred + tee: &'a T +} + +struct TeeWhereOutlivesAyIsDebug<'a, T> where T: 'a + Debug { + //~^ ERROR outlives requirements can be inferred + tee: &'a T +} + +struct TeeWhereIsDebugOutlivesAy<'a, T> where T: Debug + 'a { + //~^ ERROR outlives requirements can be inferred + tee: &'a T +} + +struct TeeWhereOutlivesAyBee<'a, 'b, T> where T: 'a + 'b { + //~^ ERROR outlives requirements can be inferred + tee: &'a &'b T +} + +struct TeeWhereOutlivesAyBeeIsDebug<'a, 'b, T> where T: 'a + 'b + Debug { + //~^ ERROR outlives requirements can be inferred + tee: &'a &'b T +} + +struct TeeWhereIsDebugOutlivesAyBee<'a, 'b, T> where T: Debug + 'a + 'b { + //~^ ERROR outlives requirements can be inferred + tee: &'a &'b T +} + +struct TeeYooOutlivesAy<'a, T, U: 'a> { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a U +} + +struct TeeYooOutlivesAyIsDebug<'a, T, U: 'a + Debug> { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a U +} + +struct TeeYooIsDebugOutlivesAy<'a, T, U: Debug + 'a> { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a U +} + +struct TeeOutlivesAyYooIsDebug<'a, T: 'a, U: Debug> { + //~^ ERROR outlives requirements can be inferred + tee: &'a T, + yoo: U +} + +struct TeeYooOutlivesAyBee<'a, 'b, T, U: 'a + 'b> { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a &'b U +} + +struct TeeYooOutlivesAyBeeIsDebug<'a, 'b, T, U: 'a + 'b + Debug> { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a &'b U +} + +struct TeeYooIsDebugOutlivesAyBee<'a, 'b, T, U: Debug + 'a + 'b> { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a &'b U +} + +struct TeeOutlivesAyBeeYooIsDebug<'a, 'b, T: 'a + 'b, U: Debug> { + //~^ ERROR outlives requirements can be inferred + tee: &'a &'b T, + yoo: U +} + +struct TeeYooWhereOutlivesAy<'a, T, U> where U: 'a { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a U +} + +struct TeeYooWhereOutlivesAyIsDebug<'a, T, U> where U: 'a + Debug { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a U +} + +struct TeeYooWhereIsDebugOutlivesAy<'a, T, U> where U: Debug + 'a { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a U +} + +struct TeeOutlivesAyYooWhereIsDebug<'a, T: 'a, U> where U: Debug { + //~^ ERROR outlives requirements can be inferred + tee: &'a T, + yoo: U +} + +struct TeeYooWhereOutlivesAyBee<'a, 'b, T, U> where U: 'a + 'b { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a &'b U +} + +struct TeeYooWhereOutlivesAyBeeIsDebug<'a, 'b, T, U> where U: 'a + 'b + Debug { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a &'b U +} + +struct TeeYooWhereIsDebugOutlivesAyBee<'a, 'b, T, U> where U: Debug + 'a + 'b { + //~^ ERROR outlives requirements can be inferred + tee: T, + yoo: &'a &'b U +} + +struct TeeOutlivesAyBeeYooWhereIsDebug<'a, 'b, T: 'a + 'b, U> where U: Debug { + //~^ ERROR outlives requirements can be inferred + tee: &'a &'b T, + yoo: U +} + +struct TeeWhereOutlivesAyYooWhereIsDebug<'a, T, U> where T: 'a, U: Debug { + //~^ ERROR outlives requirements can be inferred + tee: &'a T, + yoo: U +} + +struct TeeWhereOutlivesAyBeeYooWhereIsDebug<'a, 'b, T, U> where T: 'a + 'b, U: Debug { + //~^ ERROR outlives requirements can be inferred + tee: &'a &'b T, + yoo: U +} + + +// But outlives inference for 'static lifetimes is under a separate +// feature-gate for now +// (https://github.com/rust-lang/rust/issues/44493#issuecomment-407846046). +struct StaticRef { + field: &'static T +} + + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-infer-outlives.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-infer-outlives.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-infer-outlives.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-infer-outlives.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,188 @@ +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:35:27 + | +LL | struct TeeOutlivesAy<'a, T: 'a> { + | ^^^^ help: remove this bound + | +note: lint level defined here + --> $DIR/edition-lint-infer-outlives.rs:14:9 + | +LL | #![deny(explicit_outlives_requirements)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:40:36 + | +LL | struct TeeOutlivesAyIsDebug<'a, T: 'a + Debug> { + | ^^^^^ help: remove this bound + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:45:41 + | +LL | struct TeeIsDebugOutlivesAy<'a, T: Debug + 'a> { + | ^^^^^ help: remove this bound + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:50:34 + | +LL | struct TeeOutlivesAyBee<'a, 'b, T: 'a + 'b> { + | ^^^^^^^^^ help: remove these bounds + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:55:43 + | +LL | struct TeeOutlivesAyBeeIsDebug<'a, 'b, T: 'a + 'b + Debug> { + | ^^^^^^^^^^ help: remove these bounds + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:60:48 + | +LL | struct TeeIsDebugOutlivesAyBee<'a, 'b, T: Debug + 'a + 'b> { + | ^^^^^^^^^^ help: remove these bounds + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:65:33 + | +LL | struct TeeWhereOutlivesAy<'a, T> where T: 'a { + | ^^^^^^^^^^^^ help: remove this bound + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:70:50 + | +LL | struct TeeWhereOutlivesAyIsDebug<'a, T> where T: 'a + Debug { + | ^^^^^ help: remove this bound + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:75:55 + | +LL | struct TeeWhereIsDebugOutlivesAy<'a, T> where T: Debug + 'a { + | ^^^^^ help: remove this bound + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:80:40 + | +LL | struct TeeWhereOutlivesAyBee<'a, 'b, T> where T: 'a + 'b { + | ^^^^^^^^^^^^^^^^^ help: remove these bounds + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:85:57 + | +LL | struct TeeWhereOutlivesAyBeeIsDebug<'a, 'b, T> where T: 'a + 'b + Debug { + | ^^^^^^^^^^ help: remove these bounds + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:90:62 + | +LL | struct TeeWhereIsDebugOutlivesAyBee<'a, 'b, T> where T: Debug + 'a + 'b { + | ^^^^^^^^^^ help: remove these bounds + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:95:33 + | +LL | struct TeeYooOutlivesAy<'a, T, U: 'a> { + | ^^^^ help: remove this bound + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:101:42 + | +LL | struct TeeYooOutlivesAyIsDebug<'a, T, U: 'a + Debug> { + | ^^^^^ help: remove this bound + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:107:47 + | +LL | struct TeeYooIsDebugOutlivesAy<'a, T, U: Debug + 'a> { + | ^^^^^ help: remove this bound + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:113:37 + | +LL | struct TeeOutlivesAyYooIsDebug<'a, T: 'a, U: Debug> { + | ^^^^ help: remove this bound + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:119:40 + | +LL | struct TeeYooOutlivesAyBee<'a, 'b, T, U: 'a + 'b> { + | ^^^^^^^^^ help: remove these bounds + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:125:49 + | +LL | struct TeeYooOutlivesAyBeeIsDebug<'a, 'b, T, U: 'a + 'b + Debug> { + | ^^^^^^^^^^ help: remove these bounds + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:131:54 + | +LL | struct TeeYooIsDebugOutlivesAyBee<'a, 'b, T, U: Debug + 'a + 'b> { + | ^^^^^^^^^^ help: remove these bounds + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:137:44 + | +LL | struct TeeOutlivesAyBeeYooIsDebug<'a, 'b, T: 'a + 'b, U: Debug> { + | ^^^^^^^^^ help: remove these bounds + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:143:39 + | +LL | struct TeeYooWhereOutlivesAy<'a, T, U> where U: 'a { + | ^^^^^^^^^^^^ help: remove this bound + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:149:56 + | +LL | struct TeeYooWhereOutlivesAyIsDebug<'a, T, U> where U: 'a + Debug { + | ^^^^^ help: remove this bound + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:155:61 + | +LL | struct TeeYooWhereIsDebugOutlivesAy<'a, T, U> where U: Debug + 'a { + | ^^^^^ help: remove this bound + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:161:42 + | +LL | struct TeeOutlivesAyYooWhereIsDebug<'a, T: 'a, U> where U: Debug { + | ^^^^ help: remove this bound + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:167:46 + | +LL | struct TeeYooWhereOutlivesAyBee<'a, 'b, T, U> where U: 'a + 'b { + | ^^^^^^^^^^^^^^^^^ help: remove these bounds + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:173:63 + | +LL | struct TeeYooWhereOutlivesAyBeeIsDebug<'a, 'b, T, U> where U: 'a + 'b + Debug { + | ^^^^^^^^^^ help: remove these bounds + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:179:68 + | +LL | struct TeeYooWhereIsDebugOutlivesAyBee<'a, 'b, T, U> where U: Debug + 'a + 'b { + | ^^^^^^^^^^ help: remove these bounds + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:185:49 + | +LL | struct TeeOutlivesAyBeeYooWhereIsDebug<'a, 'b, T: 'a + 'b, U> where U: Debug { + | ^^^^^^^^^ help: remove these bounds + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:191:58 + | +LL | struct TeeWhereOutlivesAyYooWhereIsDebug<'a, T, U> where T: 'a, U: Debug { + | ^^^^^^^ help: remove this bound + +error: outlives requirements can be inferred + --> $DIR/edition-lint-infer-outlives.rs:197:65 + | +LL | struct TeeWhereOutlivesAyBeeYooWhereIsDebug<'a, 'b, T, U> where T: 'a + 'b, U: Debug { + | ^^^^^^^^^^^^ help: remove these bounds + +error: aborting due to 30 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-paths-2018.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-paths-2018.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-paths-2018.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-paths-2018.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,10 @@ +// compile-pass +// edition:2018 +// compile-flags:--extern edition_lint_paths +// aux-build:edition-lint-paths.rs + +#![deny(absolute_paths_not_starting_with_crate)] + +edition_lint_paths::macro_2015!(); // OK + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-uninferable-outlives.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-uninferable-outlives.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-uninferable-outlives.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/edition-lint-uninferable-outlives.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass + +#![allow(unused)] +#![deny(explicit_outlives_requirements)] + +// A case where we can't infer the outlives requirement. Example copied from +// RFC 2093. +// (https://rust-lang.github.io/rfcs/2093-infer-outlives.html +// #where-explicit-annotations-would-still-be-required) + + +trait MakeRef<'a> { + type Type; +} + +impl<'a, T> MakeRef<'a> for Vec + where T: 'a // still required +{ + type Type = &'a T; +} + + +struct Foo<'a, T> + where T: 'a // still required, not inferred from `field` +{ + field: as MakeRef<'a>>::Type +} + + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/future-proofing-locals.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/future-proofing-locals.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/future-proofing-locals.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/future-proofing-locals.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,49 @@ +// edition:2018 + +#![feature(uniform_paths, underscore_imports)] + +mod T { + pub struct U; +} +mod x { + pub struct y; +} + +fn type_param() { + use T as _; //~ ERROR imports cannot refer to type parameters + use T::U; //~ ERROR imports cannot refer to type parameters + use T::*; //~ ERROR imports cannot refer to type parameters +} + +fn self_import() { + use T; // FIXME Should be an error, but future-proofing fails due to `T` being "self-shadowed" +} + +fn let_binding() { + let x = 10; + + use x as _; //~ ERROR imports cannot refer to local variables + use x::y; // OK + use x::*; // OK +} + +fn param_binding(x: u8) { + use x; //~ ERROR imports cannot refer to local variables +} + +fn match_binding() { + match 0 { + x => { + use x; //~ ERROR imports cannot refer to local variables + } + } +} + +fn nested() { + let x = 10; + + use {T as _, x}; //~ ERROR imports cannot refer to type parameters + //~| ERROR imports cannot refer to local variables +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/future-proofing-locals.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/future-proofing-locals.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/future-proofing-locals.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/future-proofing-locals.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,50 @@ +error: imports cannot refer to type parameters + --> $DIR/future-proofing-locals.rs:13:9 + | +LL | use T as _; //~ ERROR imports cannot refer to type parameters + | ^ + +error: imports cannot refer to type parameters + --> $DIR/future-proofing-locals.rs:14:9 + | +LL | use T::U; //~ ERROR imports cannot refer to type parameters + | ^ + +error: imports cannot refer to type parameters + --> $DIR/future-proofing-locals.rs:15:9 + | +LL | use T::*; //~ ERROR imports cannot refer to type parameters + | ^ + +error: imports cannot refer to local variables + --> $DIR/future-proofing-locals.rs:25:9 + | +LL | use x as _; //~ ERROR imports cannot refer to local variables + | ^ + +error: imports cannot refer to local variables + --> $DIR/future-proofing-locals.rs:31:9 + | +LL | use x; //~ ERROR imports cannot refer to local variables + | ^ + +error: imports cannot refer to local variables + --> $DIR/future-proofing-locals.rs:37:17 + | +LL | use x; //~ ERROR imports cannot refer to local variables + | ^ + +error: imports cannot refer to type parameters + --> $DIR/future-proofing-locals.rs:45:10 + | +LL | use {T as _, x}; //~ ERROR imports cannot refer to type parameters + | ^ + +error: imports cannot refer to local variables + --> $DIR/future-proofing-locals.rs:45:18 + | +LL | use {T as _, x}; //~ ERROR imports cannot refer to type parameters + | ^ + +error: aborting due to 8 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/issue-54006.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/issue-54006.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/issue-54006.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/issue-54006.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/issue-54006.rs:16:5 | LL | use alloc::vec; - | ^^^^^ Could not find `alloc` in `{{root}}` + | ^^^^^ did you mean `core::alloc`? error: cannot determine resolution for the macro `vec` --> $DIR/issue-54006.rs:20:18 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.fixed rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.fixed --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.fixed 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.fixed 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:edition-lint-paths.rs +// run-rustfix +// compile-flags:--extern edition_lint_paths --cfg blandiloquence +// edition:2018 + +#![deny(rust_2018_idioms)] +#![allow(dead_code)] + +// The suggestion span should include the attribute. + + +//~^ ERROR unused extern crate + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,25 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:edition-lint-paths.rs +// run-rustfix +// compile-flags:--extern edition_lint_paths --cfg blandiloquence +// edition:2018 + +#![deny(rust_2018_idioms)] +#![allow(dead_code)] + +// The suggestion span should include the attribute. + +#[cfg(blandiloquence)] //~ HELP remove it +extern crate edition_lint_paths; +//~^ ERROR unused extern crate + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/issue-54400-unused-extern-crate-attr-span.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +error: unused extern crate + --> $DIR/issue-54400-unused-extern-crate-attr-span.rs:22:1 + | +LL | / #[cfg(blandiloquence)] //~ HELP remove it +LL | | extern crate edition_lint_paths; + | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- + | |________________________________| + | help: remove it + | +note: lint level defined here + --> $DIR/issue-54400-unused-extern-crate-attr-span.rs:16:9 + | +LL | #![deny(rust_2018_idioms)] + | ^^^^^^^^^^^^^^^^ + = note: #[deny(unused_extern_crates)] implied by #[deny(rust_2018_idioms)] + +error: aborting due to previous error + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/local-path-suggestions-2015.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/local-path-suggestions-2015.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/local-path-suggestions-2015.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/local-path-suggestions-2015.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,36 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:baz.rs +// compile-flags:--extern baz +// edition:2015 + +// This test exists to demonstrate the behaviour of the import suggestions +// from the `local-path-suggestions-2018.rs` test when not using the 2018 edition. + +extern crate baz as aux_baz; + +mod foo { + pub type Bar = u32; +} + +mod baz { + use foo::Bar; + + fn baz() { + let x: Bar = 22; + } +} + +use foo::Bar; + +use foobar::Baz; + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/local-path-suggestions-2015.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/local-path-suggestions-2015.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/local-path-suggestions-2015.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/local-path-suggestions-2015.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0432]: unresolved import `foobar` + --> $DIR/local-path-suggestions-2015.rs:34:5 + | +LL | use foobar::Baz; + | ^^^^^^ did you mean `aux_baz::foobar`? + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/local-path-suggestions-2018.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/local-path-suggestions-2018.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/local-path-suggestions-2018.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/local-path-suggestions-2018.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,33 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:baz.rs +// compile-flags:--extern baz +// edition:2018 + +#![feature(uniform_paths)] + +mod foo { + pub type Bar = u32; +} + +mod bazz { + use foo::Bar; //~ ERROR unresolved import `foo` + + fn baz() { + let x: Bar = 22; + } +} + +use foo::Bar; + +use foobar::Baz; //~ ERROR unresolved import `foobar` + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/local-path-suggestions-2018.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/local-path-suggestions-2018.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/local-path-suggestions-2018.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/local-path-suggestions-2018.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +error[E0432]: unresolved import `foo` + --> $DIR/local-path-suggestions-2018.rs:22:9 + | +LL | use foo::Bar; //~ ERROR unresolved import `foo` + | ^^^ did you mean `crate::foo`? + | + = note: `use` statements changed in Rust 2018; read more at + +error[E0432]: unresolved import `foobar` + --> $DIR/local-path-suggestions-2018.rs:31:5 + | +LL | use foobar::Baz; //~ ERROR unresolved import `foobar` + | ^^^^^^ did you mean `baz::foobar`? + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0432`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/trait-import-suggestions.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/trait-import-suggestions.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/trait-import-suggestions.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/trait-import-suggestions.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,41 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// edition:2018 +// aux-build:trait-import-suggestions.rs +// compile-flags:--extern trait-import-suggestions + +mod foo { + mod foobar { + pub(crate) trait Foobar { + fn foobar(&self) { } + } + + impl Foobar for u32 { } + } + + pub(crate) trait Bar { + fn bar(&self) { } + } + + impl Bar for u32 { } + + fn in_foo() { + let x: u32 = 22; + x.foobar(); + } +} + +fn main() { + let x: u32 = 22; + x.bar(); + x.baz(); + let y = u32::from_str("33"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/trait-import-suggestions.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/trait-import-suggestions.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/trait-import-suggestions.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/trait-import-suggestions.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +error[E0599]: no method named `foobar` found for type `u32` in the current scope + --> $DIR/trait-import-suggestions.rs:32:11 + | +LL | x.foobar(); + | ^^^^^^ + | + = help: items from traits can only be used if the trait is in scope + = note: the following trait is implemented but not in scope, perhaps add a `use` for it: + `use crate::foo::foobar::Foobar;` + +error[E0599]: no method named `bar` found for type `u32` in the current scope + --> $DIR/trait-import-suggestions.rs:38:7 + | +LL | x.bar(); + | ^^^ + | + = help: items from traits can only be used if the trait is in scope +help: the following trait is implemented but not in scope, perhaps add a `use` for it: + | +LL | use crate::foo::Bar; + | + +error[E0599]: no method named `baz` found for type `u32` in the current scope + --> $DIR/trait-import-suggestions.rs:39:7 + | +LL | x.baz(); + | ^^^ + +error[E0599]: no function or associated item named `from_str` found for type `u32` in the current scope + --> $DIR/trait-import-suggestions.rs:40:13 + | +LL | let y = u32::from_str("33"); + | ^^^^^^^^^^^^^ function or associated item not found in `u32` + | + = help: items from traits can only be used if the trait is in scope +help: the following trait is implemented but not in scope, perhaps add a `use` for it: + | +LL | use std::str::FromStr; + | + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0599`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-macros-nested.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-macros-nested.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-macros-nested.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-macros-nested.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,13 +10,11 @@ // edition:2018 -#![feature(uniform_paths)] - // This test is similar to `ambiguity-macros.rs`, but nested in a module. mod foo { pub use std::io; - //~^ ERROR `std` import is ambiguous + //~^ ERROR `std` is ambiguous macro_rules! m { () => { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-macros-nested.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-macros-nested.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-macros-nested.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-macros-nested.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,16 +1,23 @@ -error: `std` import is ambiguous - --> $DIR/ambiguity-macros-nested.rs:18:13 +error[E0659]: `std` is ambiguous (name vs any other name during import resolution) + --> $DIR/ambiguity-macros-nested.rs:16:13 + | +LL | pub use std::io; + | ^^^ ambiguous name + | + = note: `std` could refer to a built-in extern crate + = help: use `::std` to refer to this extern crate unambiguously +note: `std` could also refer to the module defined here + --> $DIR/ambiguity-macros-nested.rs:21:13 | -LL | pub use std::io; - | ^^^ can refer to external crate `::std` -... LL | / mod std { LL | | pub struct io; LL | | } - | |_____________- can refer to `self::std` - | - = help: write `::std` or `self::std` explicitly instead - = note: relative `use` paths enabled by `#![feature(uniform_paths)]` + | |_____________^ +... +LL | m!(); + | ----- in this macro invocation + = help: use `self::std` to refer to this module unambiguously error: aborting due to previous error +For more information about this error, try `rustc --explain E0659`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-macros.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-macros.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-macros.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-macros.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,12 +10,10 @@ // edition:2018 -#![feature(uniform_paths)] - // This test is similar to `ambiguity.rs`, but with macros defining local items. use std::io; -//~^ ERROR `std` import is ambiguous +//~^ ERROR `std` is ambiguous macro_rules! m { () => { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-macros.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-macros.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-macros.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-macros.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,16 +1,23 @@ -error: `std` import is ambiguous - --> $DIR/ambiguity-macros.rs:17:5 +error[E0659]: `std` is ambiguous (name vs any other name during import resolution) + --> $DIR/ambiguity-macros.rs:15:5 + | +LL | use std::io; + | ^^^ ambiguous name + | + = note: `std` could refer to a built-in extern crate + = help: use `::std` to refer to this extern crate unambiguously +note: `std` could also refer to the module defined here + --> $DIR/ambiguity-macros.rs:20:9 | -LL | use std::io; - | ^^^ can refer to external crate `::std` -... LL | / mod std { LL | | pub struct io; LL | | } - | |_________- can refer to `self::std` - | - = help: write `::std` or `self::std` explicitly instead - = note: relative `use` paths enabled by `#![feature(uniform_paths)]` + | |_________^ +... +LL | m!(); + | ----- in this macro invocation + = help: use `crate::std` to refer to this module unambiguously error: aborting due to previous error +For more information about this error, try `rustc --explain E0659`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-nested.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-nested.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-nested.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-nested.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,13 +10,11 @@ // edition:2018 -#![feature(uniform_paths)] - // This test is similar to `ambiguity.rs`, but nested in a module. mod foo { pub use std::io; - //~^ ERROR `std` import is ambiguous + //~^ ERROR `std` is ambiguous mod std { pub struct io; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-nested.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-nested.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-nested.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity-nested.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,16 +1,20 @@ -error: `std` import is ambiguous - --> $DIR/ambiguity-nested.rs:18:13 +error[E0659]: `std` is ambiguous (name vs any other name during import resolution) + --> $DIR/ambiguity-nested.rs:16:13 + | +LL | pub use std::io; + | ^^^ ambiguous name + | + = note: `std` could refer to a built-in extern crate + = help: use `::std` to refer to this extern crate unambiguously +note: `std` could also refer to the module defined here + --> $DIR/ambiguity-nested.rs:19:5 | -LL | pub use std::io; - | ^^^ can refer to external crate `::std` -... LL | / mod std { LL | | pub struct io; LL | | } - | |_____- can refer to `self::std` - | - = help: write `::std` or `self::std` explicitly instead - = note: relative `use` paths enabled by `#![feature(uniform_paths)]` + | |_____^ + = help: use `self::std` to refer to this module unambiguously error: aborting due to previous error +For more information about this error, try `rustc --explain E0659`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,10 +10,8 @@ // edition:2018 -#![feature(uniform_paths)] - use std::io; -//~^ ERROR `std` import is ambiguous +//~^ ERROR `std` is ambiguous mod std { pub struct io; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/ambiguity.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,16 +1,20 @@ -error: `std` import is ambiguous - --> $DIR/ambiguity.rs:15:5 +error[E0659]: `std` is ambiguous (name vs any other name during import resolution) + --> $DIR/ambiguity.rs:13:5 + | +LL | use std::io; + | ^^^ ambiguous name + | + = note: `std` could refer to a built-in extern crate + = help: use `::std` to refer to this extern crate unambiguously +note: `std` could also refer to the module defined here + --> $DIR/ambiguity.rs:16:1 | -LL | use std::io; - | ^^^ can refer to external crate `::std` -... LL | / mod std { LL | | pub struct io; LL | | } - | |_- can refer to `self::std` - | - = help: write `::std` or `self::std` explicitly instead - = note: relative `use` paths enabled by `#![feature(uniform_paths)]` + | |_^ + = help: use `crate::std` to refer to this module unambiguously error: aborting due to previous error +For more information about this error, try `rustc --explain E0659`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,22 @@ +// edition:2018 + +#![feature(uniform_paths)] + +mod my { + pub mod sub { + pub fn bar() {} + } +} + +mod sub { + pub fn bar() {} +} + +fn foo() { + use my::sub; + { + use sub::bar; //~ ERROR `sub` is ambiguous + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +error[E0659]: `sub` is ambiguous (name vs any other name during import resolution) + --> $DIR/block-scoped-shadow-nested.rs:18:13 + | +LL | use sub::bar; //~ ERROR `sub` is ambiguous + | ^^^ ambiguous name + | +note: `sub` could refer to the module imported here + --> $DIR/block-scoped-shadow-nested.rs:16:9 + | +LL | use my::sub; + | ^^^^^^^ +note: `sub` could also refer to the module defined here + --> $DIR/block-scoped-shadow-nested.rs:11:1 + | +LL | / mod sub { +LL | | pub fn bar() {} +LL | | } + | |_^ + = help: use `crate::sub` to refer to this module unambiguously + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0659`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,22 +10,20 @@ // edition:2018 -#![feature(uniform_paths)] - -enum Foo { A, B } +enum Foo {} struct std; fn main() { - enum Foo {} + enum Foo { A, B } use Foo::*; - //~^ ERROR `Foo` import is ambiguous + //~^ ERROR `Foo` is ambiguous let _ = (A, B); fn std() {} enum std {} use std as foo; - //~^ ERROR `std` import is ambiguous - //~| ERROR `std` import is ambiguous + //~^ ERROR `std` is ambiguous + //~| ERROR `std` is ambiguous } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/block-scoped-shadow.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,45 +1,57 @@ -error: `Foo` import is ambiguous - --> $DIR/block-scoped-shadow.rs:21:9 +error[E0659]: `Foo` is ambiguous (name vs any other name during import resolution) + --> $DIR/block-scoped-shadow.rs:19:9 | -LL | enum Foo { A, B } - | ----------------- can refer to `self::Foo` -... -LL | enum Foo {} - | ----------- shadowed by block-scoped `Foo` LL | use Foo::*; - | ^^^ + | ^^^ ambiguous name | - = help: write `self::Foo` explicitly instead - = note: relative `use` paths enabled by `#![feature(uniform_paths)]` +note: `Foo` could refer to the enum defined here + --> $DIR/block-scoped-shadow.rs:18:5 + | +LL | enum Foo { A, B } + | ^^^^^^^^^^^^^^^^^ +note: `Foo` could also refer to the enum defined here + --> $DIR/block-scoped-shadow.rs:13:1 + | +LL | enum Foo {} + | ^^^^^^^^^^^ + = help: use `crate::Foo` to refer to this enum unambiguously -error: `std` import is ambiguous - --> $DIR/block-scoped-shadow.rs:28:9 +error[E0659]: `std` is ambiguous (name vs any other name during import resolution) + --> $DIR/block-scoped-shadow.rs:26:9 | -LL | struct std; - | ----------- can refer to `self::std` -... -LL | enum std {} - | ----------- shadowed by block-scoped `std` LL | use std as foo; - | ^^^ can refer to external crate `::std` + | ^^^ ambiguous name | - = help: write `::std` or `self::std` explicitly instead - = note: relative `use` paths enabled by `#![feature(uniform_paths)]` - -error: `std` import is ambiguous - --> $DIR/block-scoped-shadow.rs:28:9 +note: `std` could refer to the enum defined here + --> $DIR/block-scoped-shadow.rs:25:5 | -LL | struct std; - | ----------- can refer to `self::std` -... -LL | fn std() {} - | ----------- shadowed by block-scoped `std` LL | enum std {} + | ^^^^^^^^^^^ +note: `std` could also refer to the struct defined here + --> $DIR/block-scoped-shadow.rs:15:1 + | +LL | struct std; + | ^^^^^^^^^^^ + = help: use `crate::std` to refer to this struct unambiguously + +error[E0659]: `std` is ambiguous (name vs any other name during import resolution) + --> $DIR/block-scoped-shadow.rs:26:9 + | LL | use std as foo; - | ^^^ + | ^^^ ambiguous name + | +note: `std` could refer to the function defined here + --> $DIR/block-scoped-shadow.rs:24:5 | - = help: write `self::std` explicitly instead - = note: relative `use` paths enabled by `#![feature(uniform_paths)]` +LL | fn std() {} + | ^^^^^^^^^^^ +note: `std` could also refer to the unit struct defined here + --> $DIR/block-scoped-shadow.rs:15:1 + | +LL | struct std; + | ^^^^^^^^^^^ + = help: use `crate::std` to refer to this unit struct unambiguously error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0659`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/deadlock.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/deadlock.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/deadlock.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/deadlock.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,7 @@ +// edition:2018 +// compile-flags:--extern foo --extern bar + +use foo::bar; //~ ERROR unresolved import +use bar::foo; + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/deadlock.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/deadlock.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/deadlock.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/deadlock.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0432]: unresolved import + --> $DIR/deadlock.rs:4:5 + | +LL | use foo::bar; //~ ERROR unresolved import + | ^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0432`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/fn-local-enum.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/fn-local-enum.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/fn-local-enum.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/fn-local-enum.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +// compile-pass +// edition:2018 + +#![feature(uniform_paths)] + +fn main() { + enum E { A, B, C } + + use E::*; + match A { + A => {} + B => {} + C => {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/from-decl-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/from-decl-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/from-decl-macro.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/from-decl-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +// compile-pass +// edition:2018 + +#![feature(decl_macro)] + +macro check() { + ::std::vec::Vec::::new() +} + +fn main() { + check!(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/issue-54253.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/issue-54253.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/issue-54253.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/issue-54253.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,9 +10,7 @@ // edition:2018 -#![feature(uniform_paths)] - -// Dummy import to introduce `uniform_paths` canaries. +// Dummy import that previously introduced uniform path canaries. use std; // fn version() -> &'static str {""} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/issue-54253.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/issue-54253.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/issue-54253.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/issue-54253.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error[E0432]: unresolved import `crate::version` - --> $DIR/issue-54253.rs:22:9 + --> $DIR/issue-54253.rs:20:9 | LL | use crate::version; //~ ERROR unresolved import `crate::version` | ^^^^^^^^^^^^^^ no `version` in the root diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/issue-54390.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/issue-54390.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/issue-54390.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/issue-54390.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +// edition:2018 + +#![deny(unused)] + +use std::fmt; + +// No "unresolved import" + "unused import" combination here. +use fmt::Write; //~ ERROR imports can only refer to extern crate names + //~| ERROR unused import: `fmt::Write` + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/issue-54390.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/issue-54390.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/issue-54390.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/issue-54390.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,32 @@ +error[E0658]: imports can only refer to extern crate names passed with `--extern` on stable channel (see issue #53130) + --> $DIR/issue-54390.rs:8:5 + | +LL | use std::fmt; + | -------- not an extern crate passed with `--extern` +... +LL | use fmt::Write; //~ ERROR imports can only refer to extern crate names + | ^^^ + | + = help: add #![feature(uniform_paths)] to the crate attributes to enable +note: this import refers to the module imported here + --> $DIR/issue-54390.rs:5:5 + | +LL | use std::fmt; + | ^^^^^^^^ + +error: unused import: `fmt::Write` + --> $DIR/issue-54390.rs:8:5 + | +LL | use fmt::Write; //~ ERROR imports can only refer to extern crate names + | ^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/issue-54390.rs:3:9 + | +LL | #![deny(unused)] + | ^^^^^^ + = note: #[deny(unused_imports)] implied by #[deny(unused)] + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/macro-rules.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/macro-rules.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/macro-rules.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/macro-rules.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,44 @@ +// edition:2018 + +// For the time being `macro_rules` items are treated as *very* private... + +#![feature(underscore_imports, decl_macro, uniform_paths)] + +mod m1 { + macro_rules! legacy_macro { () => () } + + // ... so they can't be imported by themselves, ... + use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported +} + +mod m2 { + macro_rules! legacy_macro { () => () } + + type legacy_macro = u8; + + // ... but don't prevent names from other namespaces from being imported, ... + use legacy_macro as _; // OK +} + +mod m3 { + macro legacy_macro() {} + + fn f() { + macro_rules! legacy_macro { () => () } + + // ... but still create ambiguities with other names in the same namespace. + use legacy_macro as _; //~ ERROR `legacy_macro` is ambiguous + //~| ERROR `legacy_macro` is private, and cannot be re-exported + } +} + +mod exported { + // Exported macros are treated as private as well, + // some better rules need to be figured out later. + #[macro_export] + macro_rules! legacy_macro { () => () } + + use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/macro-rules.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/macro-rules.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/macro-rules.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/macro-rules.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,58 @@ +error[E0364]: `legacy_macro` is private, and cannot be re-exported + --> $DIR/macro-rules.rs:11:9 + | +LL | use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported + | ^^^^^^^^^^^^^^^^^ + | +note: consider marking `legacy_macro` as `pub` in the imported module + --> $DIR/macro-rules.rs:11:9 + | +LL | use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported + | ^^^^^^^^^^^^^^^^^ + +error[E0364]: `legacy_macro` is private, and cannot be re-exported + --> $DIR/macro-rules.rs:30:13 + | +LL | use legacy_macro as _; //~ ERROR `legacy_macro` is ambiguous + | ^^^^^^^^^^^^^^^^^ + | +note: consider marking `legacy_macro` as `pub` in the imported module + --> $DIR/macro-rules.rs:30:13 + | +LL | use legacy_macro as _; //~ ERROR `legacy_macro` is ambiguous + | ^^^^^^^^^^^^^^^^^ + +error[E0364]: `legacy_macro` is private, and cannot be re-exported + --> $DIR/macro-rules.rs:41:9 + | +LL | use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported + | ^^^^^^^^^^^^^^^^^ + | +note: consider marking `legacy_macro` as `pub` in the imported module + --> $DIR/macro-rules.rs:41:9 + | +LL | use legacy_macro as _; //~ ERROR `legacy_macro` is private, and cannot be re-exported + | ^^^^^^^^^^^^^^^^^ + +error[E0659]: `legacy_macro` is ambiguous (name vs any other name during import resolution) + --> $DIR/macro-rules.rs:30:13 + | +LL | use legacy_macro as _; //~ ERROR `legacy_macro` is ambiguous + | ^^^^^^^^^^^^ ambiguous name + | +note: `legacy_macro` could refer to the macro defined here + --> $DIR/macro-rules.rs:27:9 + | +LL | macro_rules! legacy_macro { () => () } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: `legacy_macro` could also refer to the macro defined here + --> $DIR/macro-rules.rs:24:5 + | +LL | macro legacy_macro() {} + | ^^^^^^^^^^^^^^^^^^^^^^^ + = help: use `self::legacy_macro` to refer to this macro unambiguously + +error: aborting due to 4 previous errors + +Some errors occurred: E0364, E0659. +For more information about an error, try `rustc --explain E0364`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/prelude-fail.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/prelude-fail.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/prelude-fail.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/prelude-fail.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// edition:2018 + +#![feature(uniform_paths)] + +// Built-in macro +use env as env_imported; //~ ERROR cannot import a built-in macro + +// Tool attribute +use rustfmt::skip as imported_rustfmt_skip; //~ ERROR unresolved import `rustfmt` + +fn main() { + env_imported!("PATH"); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/prelude-fail.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/prelude-fail.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/prelude-fail.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/prelude-fail.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +error: cannot import a built-in macro + --> $DIR/prelude-fail.rs:6:5 + | +LL | use env as env_imported; //~ ERROR cannot import a built-in macro + | ^^^^^^^^^^^^^^^^^^^ + +error[E0432]: unresolved import `rustfmt` + --> $DIR/prelude-fail.rs:9:5 + | +LL | use rustfmt::skip as imported_rustfmt_skip; //~ ERROR unresolved import `rustfmt` + | ^^^^^^^ not a module `rustfmt` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0432`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/prelude.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/prelude.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/prelude.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/prelude.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +// compile-pass +// edition:2018 + +#![feature(uniform_paths)] + +// Macro imported with `#[macro_use] extern crate` +use vec as imported_vec; + +// Built-in attribute +use inline as imported_inline; + +// Tool module +use rustfmt as imported_rustfmt; + +// Standard library prelude +use Vec as ImportedVec; + +// Built-in type +use u8 as imported_u8; + +type A = imported_u8; + +#[imported_inline] +#[imported_rustfmt::skip] +fn main() { + imported_vec![0]; + ImportedVec::::new(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/redundant.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/redundant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/redundant.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths/redundant.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,8 +11,6 @@ // run-pass // edition:2018 -#![feature(uniform_paths)] - use std; use std::io; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros-nested.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros-nested.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros-nested.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros-nested.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// edition:2018 - -// This test is similar to `ambiguity-macros.rs`, but nested in a module. - -mod foo { - pub use std::io; - //~^ ERROR `std` import is ambiguous - - macro_rules! m { - () => { - mod std { - pub struct io; - } - } - } - m!(); -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros-nested.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros-nested.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros-nested.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros-nested.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -error: `std` import is ambiguous - --> $DIR/ambiguity-macros-nested.rs:16:13 - | -LL | pub use std::io; - | ^^^ can refer to external crate `::std` -... -LL | / mod std { -LL | | pub struct io; -LL | | } - | |_____________- may refer to `self::std` in the future - | - = help: write `::std` or `self::std` explicitly instead - = note: in the future, `#![feature(uniform_paths)]` may become the default - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// edition:2018 - -// This test is similar to `ambiguity.rs`, but with macros defining local items. - -use std::io; -//~^ ERROR `std` import is ambiguous - -macro_rules! m { - () => { - mod std { - pub struct io; - } - } -} -m!(); - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -error: `std` import is ambiguous - --> $DIR/ambiguity-macros.rs:15:5 - | -LL | use std::io; - | ^^^ can refer to external crate `::std` -... -LL | / mod std { -LL | | pub struct io; -LL | | } - | |_________- may refer to `self::std` in the future - | - = help: write `::std` or `self::std` explicitly instead - = note: in the future, `#![feature(uniform_paths)]` may become the default - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-nested.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-nested.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-nested.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-nested.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// edition:2018 - -// This test is similar to `ambiguity.rs`, but nested in a module. - -mod foo { - pub use std::io; - //~^ ERROR `std` import is ambiguous - - mod std { - pub struct io; - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-nested.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-nested.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-nested.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-nested.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -error: `std` import is ambiguous - --> $DIR/ambiguity-nested.rs:16:13 - | -LL | pub use std::io; - | ^^^ can refer to external crate `::std` -... -LL | / mod std { -LL | | pub struct io; -LL | | } - | |_____- may refer to `self::std` in the future - | - = help: write `::std` or `self::std` explicitly instead - = note: in the future, `#![feature(uniform_paths)]` may become the default - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// edition:2018 - -use std::io; -//~^ ERROR `std` import is ambiguous - -mod std { - pub struct io; -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -error: `std` import is ambiguous - --> $DIR/ambiguity.rs:13:5 - | -LL | use std::io; - | ^^^ can refer to external crate `::std` -... -LL | / mod std { -LL | | pub struct io; -LL | | } - | |_- may refer to `self::std` in the future - | - = help: write `::std` or `self::std` explicitly instead - = note: in the future, `#![feature(uniform_paths)]` may become the default - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/block-scoped-shadow.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/block-scoped-shadow.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/block-scoped-shadow.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/block-scoped-shadow.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// edition:2018 - -struct std; - -fn main() { - fn std() {} - enum std {} - use std as foo; - //~^ ERROR `std` import is ambiguous - //~| ERROR `std` import is ambiguous -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/block-scoped-shadow.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/block-scoped-shadow.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/block-scoped-shadow.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/block-scoped-shadow.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -error: `std` import is ambiguous - --> $DIR/block-scoped-shadow.rs:18:9 - | -LL | struct std; - | ----------- may refer to `self::std` in the future -... -LL | enum std {} - | ----------- shadowed by block-scoped `std` -LL | use std as foo; - | ^^^ can refer to external crate `::std` - | - = help: write `::std` or `self::std` explicitly instead - = note: in the future, `#![feature(uniform_paths)]` may become the default - -error: `std` import is ambiguous - --> $DIR/block-scoped-shadow.rs:18:9 - | -LL | struct std; - | ----------- may refer to `self::std` in the future -... -LL | fn std() {} - | ----------- shadowed by block-scoped `std` -LL | enum std {} -LL | use std as foo; - | ^^^ - | - = help: write `self::std` explicitly instead - = note: in the future, `#![feature(uniform_paths)]` may become the default - -error: aborting due to 2 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/issue-54253.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/issue-54253.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/issue-54253.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/issue-54253.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// edition:2018 - -// Dummy import to introduce `uniform_paths` canaries. -use std; - -// fn version() -> &'static str {""} - -mod foo { - // Error wasn't reported, despite `version` being commented out above. - use crate::version; //~ ERROR unresolved import `crate::version` - - fn bar() { - version(); - } -} - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/issue-54253.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/issue-54253.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/issue-54253.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/issue-54253.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -error[E0432]: unresolved import `crate::version` - --> $DIR/issue-54253.rs:20:9 - | -LL | use crate::version; //~ ERROR unresolved import `crate::version` - | ^^^^^^^^^^^^^^ no `version` in the root - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0432`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/redundant.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/redundant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/redundant.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rust-2018/uniform-paths-forward-compat/redundant.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// edition:2018 - -use std; -use std::io; - -mod foo { - pub use std as my_std; -} - -mod bar { - pub use std::{self}; -} - -fn main() { - io::stdout(); - self::std::io::stdout(); - foo::my_std::io::stdout(); - bar::std::io::stdout(); -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rustc-args-required-const.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/rustc-args-required-const.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rustc-args-required-const.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rustc-args-required-const.rs 2018-12-04 23:41:40.000000000 +0000 @@ -27,7 +27,8 @@ fn main() { foo(2); foo(2 + 3); - foo(baz()); + const BAZ: i32 = baz(); + foo(BAZ); let a = 4; foo(A); foo(a); //~ ERROR: argument 1 is required to be a constant diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/rustc-args-required-const.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/rustc-args-required-const.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/rustc-args-required-const.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/rustc-args-required-const.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,11 +1,11 @@ error: argument 1 is required to be a constant - --> $DIR/rustc-args-required-const.rs:33:5 + --> $DIR/rustc-args-required-const.rs:34:5 | LL | foo(a); //~ ERROR: argument 1 is required to be a constant | ^^^^^^ error: argument 2 is required to be a constant - --> $DIR/rustc-args-required-const.rs:35:5 + --> $DIR/rustc-args-required-const.rs:36:5 | LL | bar(a, a); //~ ERROR: argument 2 is required to be a constant | ^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/self/self-impl.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/self/self-impl.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/self/self-impl.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/self/self-impl.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,17 +2,13 @@ --> $DIR/self-impl.rs:33:16 | LL | let _: ::Baz = true; - | ^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `::Baz` + | ^^^^^^^^^^^ help: use fully-qualified syntax: `::Baz` error[E0223]: ambiguous associated type --> $DIR/self-impl.rs:35:16 | LL | let _: Self::Baz = true; - | ^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `::Baz` + | ^^^^^^^^^ help: use fully-qualified syntax: `::Baz` error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/self/suggest-self.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/self/suggest-self.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/self/suggest-self.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/self/suggest-self.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,52 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo { + x: i32, +} + +impl Foo { + fn this1(&self) -> i32 { + let this = self; + let a = 1; + this.x + } + + fn this2(&self) -> i32 { + let a = Foo { + x: 2 + }; + let this = a; + this.x + } + + fn foo(&self) -> i32 { + this.x + //~^ ERROR cannot find value `this` in this scope + } + + fn bar(&self) -> i32 { + this.foo() + //~^ ERROR cannot find value `this` in this scope + } + + fn baz(&self) -> i32 { + my.bar() + //~^ ERROR cannot find value `my` in this scope + } +} + +fn main() { + let this = vec![1, 2, 3]; + let my = vec![1, 2, 3]; + let len = this.len(); + let len = my.len(); +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/self/suggest-self.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/self/suggest-self.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/self/suggest-self.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/self/suggest-self.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,30 @@ +error[E0425]: cannot find value `this` in this scope + --> $DIR/suggest-self.rs:31:9 + | +LL | this.x + | ^^^^ + | | + | not found in this scope + | help: did you mean: `self` + +error[E0425]: cannot find value `this` in this scope + --> $DIR/suggest-self.rs:36:9 + | +LL | this.foo() + | ^^^^ + | | + | not found in this scope + | help: did you mean: `self` + +error[E0425]: cannot find value `my` in this scope + --> $DIR/suggest-self.rs:41:9 + | +LL | my.bar() + | ^^ + | | + | not found in this scope + | help: did you mean: `self` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0425`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/shadowed/shadowed-use-visibility.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/shadowed/shadowed-use-visibility.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/shadowed/shadowed-use-visibility.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/shadowed/shadowed-use-visibility.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,14 +1,14 @@ error[E0603]: module `bar` is private - --> $DIR/shadowed-use-visibility.rs:19:9 + --> $DIR/shadowed-use-visibility.rs:19:14 | LL | use foo::bar::f as g; //~ ERROR module `bar` is private - | ^^^^^^^^^^^^^^^^ + | ^^^ error[E0603]: module `f` is private - --> $DIR/shadowed-use-visibility.rs:25:5 + --> $DIR/shadowed-use-visibility.rs:25:10 | LL | use bar::f::f; //~ ERROR module `f` is private - | ^^^^^^^^^ + | ^ error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/single-use-lifetime/zero-uses-in-fn.fixed rustc-1.31.0+dfsg1+llvm/src/test/ui/single-use-lifetime/zero-uses-in-fn.fixed --- rustc-1.30.0+dfsg1+llvm/src/test/ui/single-use-lifetime/zero-uses-in-fn.fixed 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/single-use-lifetime/zero-uses-in-fn.fixed 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// run-rustfix + +// Test that we DO warn when lifetime name is not used at all. + +#![deny(unused_lifetimes)] +#![allow(dead_code, unused_variables)] + +fn september() {} +//~^ ERROR lifetime parameter `'a` never used +//~| HELP remove it + +fn october<'b, T>(s: &'b T) -> &'b T { + //~^ ERROR lifetime parameter `'a` never used + //~| HELP remove it + s +} + +fn november<'a>(s: &'a str) -> (&'a str) { + //~^ ERROR lifetime parameter `'b` never used + //~| HELP remove it + s +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/single-use-lifetime/zero-uses-in-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/single-use-lifetime/zero-uses-in-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/single-use-lifetime/zero-uses-in-fn.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/single-use-lifetime/zero-uses-in-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -1,19 +1,24 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. +// run-rustfix // Test that we DO warn when lifetime name is not used at all. #![deny(unused_lifetimes)] -#![allow(dead_code)] -#![allow(unused_variables)] +#![allow(dead_code, unused_variables)] -fn d<'a>() { } //~ ERROR `'a` never used +fn september<'a>() {} +//~^ ERROR lifetime parameter `'a` never used +//~| HELP remove it -fn main() { } +fn october<'a, 'b, T>(s: &'b T) -> &'b T { + //~^ ERROR lifetime parameter `'a` never used + //~| HELP remove it + s +} + +fn november<'a, 'b>(s: &'a str) -> (&'a str) { + //~^ ERROR lifetime parameter `'b` never used + //~| HELP remove it + s +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/single-use-lifetime/zero-uses-in-fn.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/single-use-lifetime/zero-uses-in-fn.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/single-use-lifetime/zero-uses-in-fn.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/single-use-lifetime/zero-uses-in-fn.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,14 +1,30 @@ error: lifetime parameter `'a` never used - --> $DIR/zero-uses-in-fn.rs:17:6 + --> $DIR/zero-uses-in-fn.rs:8:14 | -LL | fn d<'a>() { } //~ ERROR `'a` never used - | ^^ +LL | fn september<'a>() {} + | -^^- help: remove it | note: lint level defined here - --> $DIR/zero-uses-in-fn.rs:13:9 + --> $DIR/zero-uses-in-fn.rs:5:9 | LL | #![deny(unused_lifetimes)] | ^^^^^^^^^^^^^^^^ -error: aborting due to previous error +error: lifetime parameter `'a` never used + --> $DIR/zero-uses-in-fn.rs:12:12 + | +LL | fn october<'a, 'b, T>(s: &'b T) -> &'b T { + | ^^-- + | | + | help: remove it + +error: lifetime parameter `'b` never used + --> $DIR/zero-uses-in-fn.rs:18:17 + | +LL | fn november<'a, 'b>(s: &'a str) -> (&'a str) { + | --^^ + | | + | help: remove it + +error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/single-use-lifetime/zero-uses-in-impl.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/single-use-lifetime/zero-uses-in-impl.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/single-use-lifetime/zero-uses-in-impl.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/single-use-lifetime/zero-uses-in-impl.rs 2018-12-04 23:41:40.000000000 +0000 @@ -1,21 +1,10 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - // Test that we DO warn when lifetime name is not used at all. #![deny(unused_lifetimes)] -#![allow(dead_code)] -#![allow(unused_variables)] +#![allow(dead_code, unused_variables)] -struct Foo { } +struct Foo {} -impl<'a> Foo { } //~ ERROR `'a` never used +impl<'a> Foo {} //~ ERROR `'a` never used -fn main() { } +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/single-use-lifetime/zero-uses-in-impl.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/single-use-lifetime/zero-uses-in-impl.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/single-use-lifetime/zero-uses-in-impl.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/single-use-lifetime/zero-uses-in-impl.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,11 +1,11 @@ error: lifetime parameter `'a` never used - --> $DIR/zero-uses-in-impl.rs:19:6 + --> $DIR/zero-uses-in-impl.rs:8:6 | -LL | impl<'a> Foo { } //~ ERROR `'a` never used - | ^^ +LL | impl<'a> Foo {} //~ ERROR `'a` never used + | -^^- help: remove it | note: lint level defined here - --> $DIR/zero-uses-in-impl.rs:13:9 + --> $DIR/zero-uses-in-impl.rs:3:9 | LL | #![deny(unused_lifetimes)] | ^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/borrowck-call-is-borrow-issue-12224.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/borrowck-call-is-borrow-issue-12224.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/borrowck-call-is-borrow-issue-12224.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/borrowck-call-is-borrow-issue-12224.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,16 +1,14 @@ error[E0499]: cannot borrow `f` as mutable more than once at a time --> $DIR/borrowck-call-is-borrow-issue-12224.rs:22:16 | -LL | f(Box::new(|| { - | - ^^ second mutable borrow occurs here - | | - | _____first mutable borrow occurs here - | | -LL | | //~^ ERROR: cannot borrow `f` as mutable more than once -LL | | f((Box::new(|| {}))) - | | - second borrow occurs due to use of `f` in closure -LL | | })); - | |_______- borrow later used here +LL | f(Box::new(|| { + | - ^^ second mutable borrow occurs here + | | + | first mutable borrow occurs here + | first borrow later used by call +LL | //~^ ERROR: cannot borrow `f` as mutable more than once +LL | f((Box::new(|| {}))) + | - second borrow occurs due to use of `f` in closure error[E0596]: cannot borrow `*f` as mutable, as it is behind a `&` reference --> $DIR/borrowck-call-is-borrow-issue-12224.rs:35:5 @@ -40,17 +38,13 @@ error[E0505]: cannot move out of `f` because it is borrowed --> $DIR/borrowck-call-is-borrow-issue-12224.rs:65:16 | -LL | f(Box::new(|a| { - | - ^^^ move out of `f` occurs here - | | - | _____borrow of `f` occurs here - | | -LL | | foo(f); - | | - move occurs due to use in closure -LL | | //~^ ERROR cannot move `f` into closure because it is borrowed -LL | | //~| ERROR cannot move out of captured outer variable in an `FnMut` closure -LL | | }), 3); - | |__________- borrow later used here +LL | f(Box::new(|a| { + | - ^^^ move out of `f` occurs here + | | + | borrow of `f` occurs here + | borrow later used by call +LL | foo(f); + | - move occurs due to use in closure error: aborting due to 5 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/borrowck-let-suggestion-suffixes.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/borrowck-let-suggestion-suffixes.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/borrowck-let-suggestion-suffixes.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/borrowck-let-suggestion-suffixes.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,36 +1,36 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/borrowck-let-suggestion-suffixes.rs:28:14 | LL | v3.push(&id('x')); // statement 6 - | ^^^^^^^ - temporary value only lives until here + | ^^^^^^^ - temporary value is freed at the end of this statement | | - | temporary value does not live long enough + | creates a temporary which is freed while still in use ... LL | (v1, v2, v3, /* v4 is above. */ v5).use_ref(); | -- borrow later used here | = note: consider using a `let` binding to create a longer lived value -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/borrowck-let-suggestion-suffixes.rs:38:18 | LL | v4.push(&id('y')); - | ^^^^^^^ - temporary value only lives until here + | ^^^^^^^ - temporary value is freed at the end of this statement | | - | temporary value does not live long enough + | creates a temporary which is freed while still in use ... LL | v4.use_ref(); | -- borrow later used here | = note: consider using a `let` binding to create a longer lived value -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/borrowck-let-suggestion-suffixes.rs:49:14 | LL | v5.push(&id('z')); - | ^^^^^^^ - temporary value only lives until here + | ^^^^^^^ - temporary value is freed at the end of this statement | | - | temporary value does not live long enough + | creates a temporary which is freed while still in use ... LL | (v1, v2, v3, /* v4 is above. */ v5).use_ref(); | -- borrow later used here @@ -39,4 +39,4 @@ error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/borrowck-ref-into-rvalue.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/borrowck-ref-into-rvalue.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/borrowck-ref-into-rvalue.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/borrowck-ref-into-rvalue.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,11 +1,11 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/borrowck-ref-into-rvalue.rs:13:11 | LL | match Some("Hello".to_string()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use ... LL | } - | - temporary value only lives until here + | - temporary value is freed at the end of this statement LL | println!("{}", *msg); | ---- borrow later used here | @@ -13,4 +13,4 @@ error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/destructor-restrictions.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/destructor-restrictions.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/destructor-restrictions.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/destructor-restrictions.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,9 +2,16 @@ --> $DIR/destructor-restrictions.rs:18:10 | LL | *a.borrow() + 1 - | ^ borrowed value does not live long enough + | ^--------- + | | + | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... LL | }; //~^ ERROR `*a` does not live long enough - | - `*a` dropped here while still borrowed + | -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::cell::Ref<'_, i32>` + | | + | `*a` dropped here while still borrowed + | + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/dropck_arr_cycle_checked.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/dropck_arr_cycle_checked.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/dropck_arr_cycle_checked.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/dropck_arr_cycle_checked.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,9 @@ | - | | | `b2` dropped here while still borrowed - | borrow later used here, when `b1` is dropped + | borrow might be used here, when `b1` is dropped and runs the destructor for type `B<'_>` + | + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `b3` does not live long enough --> $DIR/dropck_arr_cycle_checked.rs:105:24 @@ -20,7 +22,9 @@ | - | | | `b3` dropped here while still borrowed - | borrow later used here, when `b1` is dropped + | borrow might be used here, when `b1` is dropped and runs the destructor for type `B<'_>` + | + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `b1` does not live long enough --> $DIR/dropck_arr_cycle_checked.rs:111:24 @@ -32,7 +36,7 @@ | - | | | `b1` dropped here while still borrowed - | borrow later used here, when `b1` is dropped + | borrow might be used here, when `b1` is dropped and runs the destructor for type `B<'_>` error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/dropck_direct_cycle_with_drop.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/dropck_direct_cycle_with_drop.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/dropck_direct_cycle_with_drop.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/dropck_direct_cycle_with_drop.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | - | | | `d2` dropped here while still borrowed - | borrow later used here, when `d1` is dropped + | borrow might be used here, when `d1` is dropped and runs the `Drop` code for type `D` | = note: values in a scope are dropped in the opposite order they are defined @@ -22,9 +22,7 @@ | - | | | `d1` dropped here while still borrowed - | borrow later used here, when `d1` is dropped - | - = note: values in a scope are dropped in the opposite order they are defined + | borrow might be used here, when `d1` is dropped and runs the `Drop` code for type `D` error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/dropck_misc_variants.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/dropck_misc_variants.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/dropck_misc_variants.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/dropck_misc_variants.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | - | | | `bomb` dropped here while still borrowed - | borrow later used here, when `_w` is dropped + | borrow might be used here, when `_w` is dropped and runs the destructor for type `Wrap<&[&str]>` | = note: values in a scope are dropped in the opposite order they are defined @@ -21,7 +21,7 @@ | - | | | `v` dropped here while still borrowed - | borrow later used here, when `_w` is dropped + | borrow might be used here, when `_w` is dropped and runs the destructor for closure | = note: values in a scope are dropped in the opposite order they are defined diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/dropck-object-cycle.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/dropck-object-cycle.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/dropck-object-cycle.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/dropck-object-cycle.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | - | | | `*m` dropped here while still borrowed - | borrow later used here, when `m` is dropped + | borrow might be used here, when `m` is dropped and runs the destructor for type `std::boxed::Box>` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/dropck_vec_cycle_checked.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/dropck_vec_cycle_checked.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/dropck_vec_cycle_checked.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/dropck_vec_cycle_checked.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,9 @@ | - | | | `c2` dropped here while still borrowed - | borrow later used here, when `c1` is dropped + | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` + | + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `c3` does not live long enough --> $DIR/dropck_vec_cycle_checked.rs:115:24 @@ -20,7 +22,9 @@ | - | | | `c3` dropped here while still borrowed - | borrow later used here, when `c1` is dropped + | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` + | + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `c1` does not live long enough --> $DIR/dropck_vec_cycle_checked.rs:121:24 @@ -32,7 +36,7 @@ | - | | | `c1` dropped here while still borrowed - | borrow later used here, when `c1` is dropped + | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/impl-parsing.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/span/impl-parsing.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/impl-parsing.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/impl-parsing.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -impl ! {} // OK -impl ! where u8: Copy {} // OK - -impl Trait Type {} //~ ERROR missing `for` in a trait impl -impl Trait .. {} //~ ERROR missing `for` in a trait impl -impl ?Sized for Type {} //~ ERROR expected a trait, found type -impl ?Sized for .. {} //~ ERROR expected a trait, found type - -default unsafe FAIL //~ ERROR expected `impl`, found `FAIL` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/impl-parsing.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/impl-parsing.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/impl-parsing.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/impl-parsing.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -error: missing `for` in a trait impl - --> $DIR/impl-parsing.rs:16:11 - | -LL | impl Trait Type {} //~ ERROR missing `for` in a trait impl - | ^ - -error: missing `for` in a trait impl - --> $DIR/impl-parsing.rs:17:11 - | -LL | impl Trait .. {} //~ ERROR missing `for` in a trait impl - | ^ - -error: expected a trait, found type - --> $DIR/impl-parsing.rs:18:6 - | -LL | impl ?Sized for Type {} //~ ERROR expected a trait, found type - | ^^^^^^ - -error: expected a trait, found type - --> $DIR/impl-parsing.rs:19:6 - | -LL | impl ?Sized for .. {} //~ ERROR expected a trait, found type - | ^^^^^^ - -error: expected `impl`, found `FAIL` - --> $DIR/impl-parsing.rs:21:16 - | -LL | default unsafe FAIL //~ ERROR expected `impl`, found `FAIL` - | ^^^^ expected `impl` here - -error: aborting due to 5 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue-11925.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue-11925.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue-11925.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue-11925.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,12 +1,9 @@ -error[E0597]: `x` does not live long enough +error[E0515]: cannot return reference to local data `x` --> $DIR/issue-11925.rs:18:35 | LL | let f = to_fn_once(move|| &x); //~ ERROR does not live long enough - | ^- - | || - | |`x` dropped here while still borrowed - | borrowed value does not live long enough + | ^^ returns a reference to data owned by the current function error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue-15480.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue-15480.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue-15480.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue-15480.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,10 +1,10 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/issue-15480.rs:15:10 | LL | &id(3) - | ^^^^^ temporary value does not live long enough + | ^^^^^ creates a temporary which is freed while still in use LL | ]; - | - temporary value only lives until here + | - temporary value is freed at the end of this statement ... LL | for &&x in &v { | -- borrow later used here @@ -13,4 +13,4 @@ error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue-23338-locals-die-before-temps-of-body.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue-23338-locals-die-before-temps-of-body.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue-23338-locals-die-before-temps-of-body.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue-23338-locals-die-before-temps-of-body.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,17 +2,32 @@ --> $DIR/issue-23338-locals-die-before-temps-of-body.rs:20:5 | LL | y.borrow().clone() - | ^ borrowed value does not live long enough + | ^--------- + | | + | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... LL | } - | - `y` dropped here while still borrowed + | - + | | + | `y` dropped here while still borrowed + | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::cell::Ref<'_, std::string::String>` + | + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. error[E0597]: `y` does not live long enough --> $DIR/issue-23338-locals-die-before-temps-of-body.rs:27:9 | LL | y.borrow().clone() - | ^ borrowed value does not live long enough + | ^--------- + | | + | borrowed value does not live long enough + | a temporary with access to the borrow is created here ... LL | }; - | - `y` dropped here while still borrowed + | -- ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::cell::Ref<'_, std::string::String>` + | | + | `y` dropped here while still borrowed + | + = note: The temporary is part of an expression at the end of a block. Consider forcing this temporary to be dropped sooner, before the block's local variables are dropped. For example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block. error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue-24805-dropck-child-has-items-via-parent.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue-24805-dropck-child-has-items-via-parent.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue-24805-dropck-child-has-items-via-parent.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue-24805-dropck-child-has-items-via-parent.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | - | | | `d1` dropped here while still borrowed - | borrow later used here, when `_d` is dropped + | borrow might be used here, when `_d` is dropped and runs the `Drop` code for type `D_Child` | = note: values in a scope are dropped in the opposite order they are defined diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue-24805-dropck-trait-has-items.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue-24805-dropck-trait-has-items.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue-24805-dropck-trait-has-items.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue-24805-dropck-trait-has-items.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | - | | | `d1` dropped here while still borrowed - | borrow later used here, when `_d` is dropped + | borrow might be used here, when `_d` is dropped and runs the `Drop` code for type `D_HasSelfMethod` | = note: values in a scope are dropped in the opposite order they are defined @@ -20,7 +20,7 @@ | - | | | `d1` dropped here while still borrowed - | borrow later used here, when `_d` is dropped + | borrow might be used here, when `_d` is dropped and runs the `Drop` code for type `D_HasMethodWithSelfArg` | = note: values in a scope are dropped in the opposite order they are defined @@ -33,7 +33,7 @@ | - | | | `d1` dropped here while still borrowed - | borrow later used here, when `_d` is dropped + | borrow might be used here, when `_d` is dropped and runs the `Drop` code for type `D_HasType` | = note: values in a scope are dropped in the opposite order they are defined diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue-24895-copy-clone-dropck.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue-24895-copy-clone-dropck.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue-24895-copy-clone-dropck.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue-24895-copy-clone-dropck.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | - | | | `d1` dropped here while still borrowed - | borrow later used here, when `d2` is dropped + | borrow might be used here, when `d2` is dropped and runs the `Drop` code for type `D` | = note: values in a scope are dropped in the opposite order they are defined diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue-25199.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue-25199.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue-25199.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue-25199.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | - | | | `container` dropped here while still borrowed - | borrow later used here, when `container` is dropped + | borrow might be used here, when `container` is dropped and runs the destructor for type `Container<'_>` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue-26656.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue-26656.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue-26656.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue-26656.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | - | | | `ticking` dropped here while still borrowed - | borrow later used here, when `zook` is dropped + | borrow might be used here, when `zook` is dropped and runs the `Drop` code for type `Zook` | = note: values in a scope are dropped in the opposite order they are defined diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue28498-reject-ex1.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue28498-reject-ex1.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue28498-reject-ex1.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue28498-reject-ex1.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,17 +1,17 @@ -error[E0597]: `foo.data` does not live long enough +error[E0713]: borrow may still be in use when destructor runs --> $DIR/issue28498-reject-ex1.rs:44:29 | LL | foo.data[0].1.set(Some(&foo.data[1])); - | ^^^^^^^^ borrowed value does not live long enough + | ^^^^^^^^ ... LL | } | - | | - | `foo.data` dropped here while still borrowed - | borrow later used here, when `foo` is dropped + | here, drop of `foo` needs exclusive access to `foo.data`, because the type `Foo>` implements the `Drop` trait + | borrow might be used here, when `foo` is dropped and runs the `Drop` code for type `Foo` | - = note: values in a scope are dropped in the opposite order they are defined + = note: consider using a `let` binding to create a longer lived value error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0713`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue28498-reject-lifetime-param.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue28498-reject-lifetime-param.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue28498-reject-lifetime-param.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue28498-reject-lifetime-param.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | - | | | `first_dropped` dropped here while still borrowed - | borrow later used here, when `foo1` is dropped + | borrow might be used here, when `foo1` is dropped and runs the `Drop` code for type `Foo` | = note: values in a scope are dropped in the opposite order they are defined diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue28498-reject-passed-to-fn.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue28498-reject-passed-to-fn.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue28498-reject-passed-to-fn.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue28498-reject-passed-to-fn.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | - | | | `first_dropped` dropped here while still borrowed - | borrow later used here, when `foo1` is dropped + | borrow might be used here, when `foo1` is dropped and runs the `Drop` code for type `Foo` | = note: values in a scope are dropped in the opposite order they are defined diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue28498-reject-trait-bound.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue28498-reject-trait-bound.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue28498-reject-trait-bound.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue28498-reject-trait-bound.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | - | | | `first_dropped` dropped here while still borrowed - | borrow later used here, when `foo1` is dropped + | borrow might be used here, when `foo1` is dropped and runs the `Drop` code for type `Foo` | = note: values in a scope are dropped in the opposite order they are defined diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue-29106.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue-29106.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue-29106.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue-29106.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,9 @@ | - | | | `x` dropped here while still borrowed - | borrow later used here, when `y` is dropped + | borrow might be used here, when `y` is dropped and runs the `Drop` code for type `std::sync::Arc` + | + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `x` does not live long enough --> $DIR/issue-29106.rs:33:25 @@ -18,7 +20,9 @@ | - | | | `x` dropped here while still borrowed - | borrow later used here, when `y` is dropped + | borrow might be used here, when `y` is dropped and runs the `Drop` code for type `std::rc::Rc` + | + = note: values in a scope are dropped in the opposite order they are defined error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue-36530.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue-36530.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/issue-36530.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/issue-36530.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -6,7 +6,7 @@ | = help: add #![feature(custom_attribute)] to the crate attributes to enable -error[E0658]: non-builtin inner attributes are unstable (see issue #38356) +error[E0658]: non-builtin inner attributes are unstable (see issue #54726) --> $DIR/issue-36530.rs:15:5 | LL | #![foo] //~ ERROR is currently unknown to the compiler diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/macro-ty-params.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/macro-ty-params.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/macro-ty-params.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/macro-ty-params.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -5,6 +5,12 @@ | ^^^^^^^^^ error: generic arguments in macro path + --> $DIR/macro-ty-params.rs:20:15 + | +LL | m!(MyTrait<>); //~ ERROR generic arguments in macro path + | ^^ + +error: generic arguments in macro path --> $DIR/macro-ty-params.rs:18:8 | LL | foo::!(); //~ ERROR generic arguments in macro path @@ -16,11 +22,5 @@ LL | foo::<>!(); //~ ERROR generic arguments in macro path | ^^^^ -error: generic arguments in macro path - --> $DIR/macro-ty-params.rs:20:15 - | -LL | m!(MyTrait<>); //~ ERROR generic arguments in macro path - | ^^ - error: aborting due to 4 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/non-existing-module-import.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/non-existing-module-import.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/non-existing-module-import.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/non-existing-module-import.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/non-existing-module-import.rs:11:10 | LL | use std::bar::{foo1, foo2}; //~ ERROR unresolved import - | ^^^ Could not find `bar` in `std` + | ^^^ could not find `bar` in `std` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/range-2.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/range-2.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/range-2.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/range-2.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,24 +1,24 @@ error[E0597]: `a` does not live long enough --> $DIR/range-2.rs:17:9 | +LL | let r = { + | - borrow later stored here +... LL | &a..&b | ^^ borrowed value does not live long enough LL | }; | - `a` dropped here while still borrowed -... -LL | r.use_ref(); - | - borrow later used here error[E0597]: `b` does not live long enough --> $DIR/range-2.rs:17:13 | +LL | let r = { + | - borrow later stored here +... LL | &a..&b | ^^ borrowed value does not live long enough LL | }; | - `b` dropped here while still borrowed -... -LL | r.use_ref(); - | - borrow later used here error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/regions-close-over-borrowed-ref-in-obj.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,16 +1,16 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/regions-close-over-borrowed-ref-in-obj.rs:22:27 | LL | let ss: &isize = &id(1); - | ^^^^^ temporary value does not live long enough + | ^^^^^ creates a temporary which is freed while still in use ... LL | } - | - temporary value only lives until here + | - temporary value is freed at the end of this statement LL | } - | - borrow later used here, when `blah` is dropped + | - borrow might be used here, when `blah` is dropped and runs the destructor for type `std::boxed::Box` | = note: consider using a `let` binding to create a longer lived value error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/regions-close-over-type-parameter-2.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/regions-close-over-type-parameter-2.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/regions-close-over-type-parameter-2.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/regions-close-over-type-parameter-2.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -4,7 +4,7 @@ LL | let tmp1 = &tmp0; | ^^^^^ borrowed value does not live long enough LL | repeater3(tmp1) - | --------------- borrow later used here + | --------------- borrow later captured here by trait object LL | }; | - `tmp0` dropped here while still borrowed diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/regions-escape-loop-via-variable.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/regions-escape-loop-via-variable.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/regions-escape-loop-via-variable.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/regions-escape-loop-via-variable.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/regions-escape-loop-via-variable.rs:21:13 | LL | let x = 1 + *p; - | -- borrow used here in later iteration of loop + | -- borrow used here, in later iteration of loop LL | p = &x; | ^^ borrowed value does not live long enough LL | } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/regions-escape-loop-via-vec.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/regions-escape-loop-via-vec.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/regions-escape-loop-via-vec.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/regions-escape-loop-via-vec.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^ use of borrowed `x` LL | let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed LL | _y.push(&mut z); - | -- borrow used here in later iteration of loop + | -- borrow used here, in later iteration of loop error[E0503]: cannot use `x` because it was mutably borrowed --> $DIR/regions-escape-loop-via-vec.rs:16:21 @@ -18,7 +18,7 @@ LL | let mut z = x; //~ ERROR cannot use `x` because it was mutably borrowed | ^ use of borrowed `x` LL | _y.push(&mut z); - | -- borrow used here in later iteration of loop + | -- borrow used here, in later iteration of loop error[E0597]: `z` does not live long enough --> $DIR/regions-escape-loop-via-vec.rs:17:17 @@ -26,7 +26,7 @@ LL | _y.push(&mut z); | -- ^^^^^^ borrowed value does not live long enough | | - | borrow used here in later iteration of loop + | borrow used here, in later iteration of loop ... LL | } | - `z` dropped here while still borrowed @@ -38,7 +38,7 @@ | ------ borrow of `x` occurs here ... LL | _y.push(&mut z); - | -- borrow used here in later iteration of loop + | -- borrow used here, in later iteration of loop LL | //~^ ERROR `z` does not live long enough LL | x += 1; //~ ERROR cannot assign | ^^^^^^ use of borrowed `x` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/send-is-not-static-ensures-scoping.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/send-is-not-static-ensures-scoping.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/send-is-not-static-ensures-scoping.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/send-is-not-static-ensures-scoping.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,18 +1,21 @@ error[E0597]: `x` does not live long enough --> $DIR/send-is-not-static-ensures-scoping.rs:26:17 | +LL | let bad = { + | --- borrow later stored here +LL | let x = 1; LL | let y = &x; | ^^ borrowed value does not live long enough ... LL | }; | - `x` dropped here while still borrowed -LL | -LL | bad.join(); - | --- borrow later used here error[E0597]: `y` does not live long enough --> $DIR/send-is-not-static-ensures-scoping.rs:30:22 | +LL | let bad = { + | --- borrow later stored here +... LL | scoped(|| { | -- value captured here LL | let _z = y; @@ -20,9 +23,6 @@ ... LL | }; | - `y` dropped here while still borrowed -LL | -LL | bad.join(); - | --- borrow later used here error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/send-is-not-static-std-sync-2.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/send-is-not-static-std-sync-2.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/send-is-not-static-std-sync-2.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/send-is-not-static-std-sync-2.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,24 +1,24 @@ error[E0597]: `x` does not live long enough --> $DIR/send-is-not-static-std-sync-2.rs:21:20 | +LL | let lock = { + | ---- borrow later stored here +LL | let x = 1; LL | Mutex::new(&x) | ^^ borrowed value does not live long enough LL | }; | - `x` dropped here while still borrowed -... -LL | let _dangling = *lock.lock().unwrap(); - | ---- borrow later used here error[E0597]: `x` does not live long enough --> $DIR/send-is-not-static-std-sync-2.rs:31:21 | +LL | let lock = { + | ---- borrow later stored here +LL | let x = 1; LL | RwLock::new(&x) | ^^ borrowed value does not live long enough LL | }; | - `x` dropped here while still borrowed -LL | //~^^ ERROR `x` does not live long enough -LL | let _dangling = *lock.read().unwrap(); - | ---- borrow later used here error[E0597]: `x` does not live long enough --> $DIR/send-is-not-static-std-sync-2.rs:41:25 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/send-is-not-static-std-sync.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/send-is-not-static-std-sync.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/send-is-not-static-std-sync.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/send-is-not-static-std-sync.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -62,7 +62,7 @@ | - `z` dropped here while still borrowed ... LL | } - | - borrow later used here, when `tx` is dropped + | - borrow might be used here, when `tx` is dropped and runs the `Drop` code for type `std::sync::mpsc::Sender` | = note: values in a scope are dropped in the opposite order they are defined diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/slice-borrow.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/slice-borrow.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/slice-borrow.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/slice-borrow.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,11 +1,11 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/slice-borrow.rs:16:28 | LL | let x: &[isize] = &vec![1, 2, 3, 4, 5]; - | ^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough + | ^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use ... LL | } - | - temporary value only lives until here + | - temporary value is freed at the end of this statement LL | y.use_ref(); | - borrow later used here | @@ -14,4 +14,4 @@ error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/vec-must-not-hide-type-from-dropck.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/vec-must-not-hide-type-from-dropck.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/vec-must-not-hide-type-from-dropck.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/vec-must-not-hide-type-from-dropck.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,9 @@ | - | | | `c2` dropped here while still borrowed - | borrow later used here, when `c1` is dropped + | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` + | + = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `c1` does not live long enough --> $DIR/vec-must-not-hide-type-from-dropck.rs:129:24 @@ -20,7 +22,7 @@ | - | | | `c1` dropped here while still borrowed - | borrow later used here, when `c1` is dropped + | borrow might be used here, when `c1` is dropped and runs the destructor for type `C<'_>` error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/vec_refs_data_with_early_death.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/vec_refs_data_with_early_death.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/vec_refs_data_with_early_death.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/vec_refs_data_with_early_death.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | - | | | `x` dropped here while still borrowed - | borrow later used here, when `v` is dropped + | borrow might be used here, when `v` is dropped and runs the `Drop` code for type `Bag` | = note: values in a scope are dropped in the opposite order they are defined @@ -22,7 +22,7 @@ | - | | | `y` dropped here while still borrowed - | borrow later used here, when `v` is dropped + | borrow might be used here, when `v` is dropped and runs the `Drop` code for type `Bag` | = note: values in a scope are dropped in the opposite order they are defined diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/span/wf-method-late-bound-regions.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/span/wf-method-late-bound-regions.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/span/wf-method-late-bound-regions.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/span/wf-method-late-bound-regions.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,13 +1,13 @@ error[E0597]: `pointer` does not live long enough --> $DIR/wf-method-late-bound-regions.rs:30:18 | +LL | let dangling = { + | -------- borrow later stored here +LL | let pointer = Box::new(42); LL | f2.xmute(&pointer) | ^^^^^^^^ borrowed value does not live long enough LL | }; | - `pointer` dropped here while still borrowed -LL | //~^^ ERROR `pointer` does not live long enough -LL | println!("{}", dangling); - | -------- borrow later used here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/specialization/issue-52050.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/specialization/issue-52050.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/specialization/issue-52050.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/specialization/issue-52050.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,7 +12,7 @@ // Regression test for #52050: when inserting the blanket impl `I` // into the tree, we had to replace the child node for `Foo`, which -// led to the struture of the tree being messed up. +// led to the structure of the tree being messed up. use std::iter::Iterator; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/static/static-drop-scope.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/static/static-drop-scope.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/static/static-drop-scope.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/static/static-drop-scope.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,60 @@ +error[E0493]: destructors cannot be evaluated at compile-time + --> $DIR/static-drop-scope.rs:19:60 + | +LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor); + | ^^^^^^^^ statics cannot evaluate destructors + +error[E0716]: temporary value dropped while borrowed + --> $DIR/static-drop-scope.rs:19:60 + | +LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor); + | ------^^^^^^^^- + | | | | + | | | temporary value is freed at the end of this statement + | | creates a temporary which is freed while still in use + | using this value as a static requires that borrow lasts for `'static` + +error[E0493]: destructors cannot be evaluated at compile-time + --> $DIR/static-drop-scope.rs:23:59 + | +LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor); + | ^^^^^^^^ constants cannot evaluate destructors + +error[E0716]: temporary value dropped while borrowed + --> $DIR/static-drop-scope.rs:23:59 + | +LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor); + | ------^^^^^^^^- + | | | | + | | | temporary value is freed at the end of this statement + | | creates a temporary which is freed while still in use + | using this value as a constant requires that borrow lasts for `'static` + +error[E0493]: destructors cannot be evaluated at compile-time + --> $DIR/static-drop-scope.rs:27:28 + | +LL | static EARLY_DROP_S: i32 = (WithDtor, 0).1; + | ^^^^^^^^^^^^^ statics cannot evaluate destructors + +error[E0493]: destructors cannot be evaluated at compile-time + --> $DIR/static-drop-scope.rs:30:27 + | +LL | const EARLY_DROP_C: i32 = (WithDtor, 0).1; + | ^^^^^^^^^^^^^ constants cannot evaluate destructors + +error[E0493]: destructors cannot be evaluated at compile-time + --> $DIR/static-drop-scope.rs:33:24 + | +LL | const fn const_drop(_: T) {} + | ^ constant functions cannot evaluate destructors + +error[E0493]: destructors cannot be evaluated at compile-time + --> $DIR/static-drop-scope.rs:37:5 + | +LL | (x, ()).1 + | ^^^^^^^ constant functions cannot evaluate destructors + +error: aborting due to 8 previous errors + +Some errors occurred: E0493, E0716. +For more information about an error, try `rustc --explain E0493`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/static/static-items-cant-move.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/static/static-items-cant-move.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/static/static-items-cant-move.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/static/static-items-cant-move.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +error[E0507]: cannot move out of static item + --> $DIR/static-items-cant-move.rs:28:10 + | +LL | test(BAR); //~ ERROR cannot move out of static item + | ^^^ cannot move out of static item + +error[E0507]: cannot move out of immutable static item `BAR` + --> $DIR/static-items-cant-move.rs:28:10 + | +LL | test(BAR); //~ ERROR cannot move out of static item + | ^^^ + | | + | cannot move out of immutable static item `BAR` + | cannot move + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/static/static-lifetime-bound.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/static/static-lifetime-bound.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/static/static-lifetime-bound.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/static/static-lifetime-bound.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -10,11 +10,12 @@ --> $DIR/static-lifetime-bound.rs:15:7 | LL | f(&x); //~ERROR does not live long enough - | ^^ borrowed value does not live long enough + | --^^- + | | | + | | borrowed value does not live long enough + | argument requires that `x` is borrowed for `'static` LL | } | - `x` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/static/static-mut-not-pat.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/static/static-mut-not-pat.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/static/static-mut-not-pat.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/static/static-mut-not-pat.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/static-mut-not-pat.rs:23:9 | LL | static mut a: isize = 3; - | ------------------------ a static `a` is defined here + | ------------------------ the static `a` is defined here ... LL | a => {} //~ ERROR match bindings cannot shadow statics | ^ cannot be named the same as a static @@ -11,7 +11,7 @@ --> $DIR/static-mut-not-pat.rs:46:9 | LL | static mut STATIC_MUT_FOO: Foo = Foo { bar: Some(Direction::West), baz: NEW_FALSE }; - | ------------------------------------------------------------------------------------ a static `STATIC_MUT_FOO` is defined here + | ------------------------------------------------------------------------------------ the static `STATIC_MUT_FOO` is defined here ... LL | STATIC_MUT_FOO => (), | ^^^^^^^^^^^^^^ cannot be named the same as a static diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/static/static-priv-by-default2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/static/static-priv-by-default2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/static/static-priv-by-default2.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/static/static-priv-by-default2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,14 +1,14 @@ error[E0603]: static `private` is private - --> $DIR/static-priv-by-default2.rs:25:9 + --> $DIR/static-priv-by-default2.rs:25:30 | LL | use child::childs_child::private; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^ error[E0603]: static `private` is private - --> $DIR/static-priv-by-default2.rs:33:9 + --> $DIR/static-priv-by-default2.rs:33:33 | LL | use static_priv_by_default::private; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^ error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/static/static-reference-to-fn-2.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/static/static-reference-to-fn-2.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/static/static-reference-to-fn-2.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/static/static-reference-to-fn-2.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,68 +1,47 @@ -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/static-reference-to-fn-2.rs:28:22 | +LL | fn state1(self_: &mut StateMachineIter) -> Option<&'static str> { + | ----- has type `&mut StateMachineIter<'1>` LL | self_.statefn = &id(state2 as StateMachineFunc); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | -note: borrowed value must be valid for the anonymous lifetime #2 defined on the function body at 27:1... - --> $DIR/static-reference-to-fn-2.rs:27:1 - | -LL | / fn state1(self_: &mut StateMachineIter) -> Option<&'static str> { -LL | | self_.statefn = &id(state2 as StateMachineFunc); -LL | | //~^ ERROR borrowed value does not live long enough -LL | | return Some("state1"); -LL | | } - | |_^ + | -----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement + | | | + | | creates a temporary which is freed while still in use + | assignment requires that borrow lasts for `'1` -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/static-reference-to-fn-2.rs:34:22 | +LL | fn state2(self_: &mut StateMachineIter) -> Option<(&'static str)> { + | ----- has type `&mut StateMachineIter<'1>` LL | self_.statefn = &id(state3 as StateMachineFunc); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | -note: borrowed value must be valid for the anonymous lifetime #2 defined on the function body at 33:1... - --> $DIR/static-reference-to-fn-2.rs:33:1 - | -LL | / fn state2(self_: &mut StateMachineIter) -> Option<(&'static str)> { -LL | | self_.statefn = &id(state3 as StateMachineFunc); -LL | | //~^ ERROR borrowed value does not live long enough -LL | | return Some("state2"); -LL | | } - | |_^ + | -----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement + | | | + | | creates a temporary which is freed while still in use + | assignment requires that borrow lasts for `'1` -error[E0597]: borrowed value does not live long enough +error[E0716]: temporary value dropped while borrowed --> $DIR/static-reference-to-fn-2.rs:40:22 | +LL | fn state3(self_: &mut StateMachineIter) -> Option<(&'static str)> { + | ----- has type `&mut StateMachineIter<'1>` LL | self_.statefn = &id(finished as StateMachineFunc); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here - | | - | temporary value does not live long enough - | -note: borrowed value must be valid for the anonymous lifetime #2 defined on the function body at 39:1... - --> $DIR/static-reference-to-fn-2.rs:39:1 - | -LL | / fn state3(self_: &mut StateMachineIter) -> Option<(&'static str)> { -LL | | self_.statefn = &id(finished as StateMachineFunc); -LL | | //~^ ERROR borrowed value does not live long enough -LL | | return Some("state3"); -LL | | } - | |_^ + | -----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement + | | | + | | creates a temporary which is freed while still in use + | assignment requires that borrow lasts for `'1` -error[E0597]: borrowed value does not live long enough - --> $DIR/static-reference-to-fn-2.rs:51:19 - | -LL | statefn: &id(state1 as StateMachineFunc) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough -... -LL | } - | - temporary value only lives until here +error[E0515]: cannot return value referencing temporary value + --> $DIR/static-reference-to-fn-2.rs:50:5 | - = note: borrowed value must be valid for the static lifetime... +LL | / StateMachineIter { +LL | | statefn: &id(state1 as StateMachineFunc) + | | ------------------------------ temporary value created here +LL | | //~^ ERROR borrowed value does not live long enough +LL | | } + | |_____^ returns a value referencing data owned by the current function error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0597`. +Some errors occurred: E0515, E0716. +For more information about an error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/static/static-region-bound.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/static/static-region-bound.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/static/static-region-bound.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/static/static-region-bound.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +error[E0716]: temporary value dropped while borrowed + --> $DIR/static-region-bound.rs:20:14 + | +LL | let x = &id(3); //~ ERROR borrowed value does not live long enough + | ^^^^^ creates a temporary which is freed while still in use +LL | f(x); + | ---- argument requires that borrow lasts for `'static` +LL | } + | - temporary value is freed at the end of this statement + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0716`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/static_sized_requirement.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/static_sized_requirement.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/static_sized_requirement.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/static_sized_requirement.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,12 @@ +// compile-pass + +#![feature(no_core, lang_items)] +#![no_core] +#![crate_type = "lib"] + +#[lang = "sized"] +trait Sized {} + +extern { + pub static A: u32; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/std-uncopyable-atomics.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/std-uncopyable-atomics.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/std-uncopyable-atomics.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/std-uncopyable-atomics.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,6 +7,15 @@ | cannot move out of borrowed content | help: consider removing the `*`: `&x` +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/std-uncopyable-atomics.rs:19:13 + | +LL | let x = *&x; //~ ERROR: cannot move out of borrowed content + | ^^^ + | | + | cannot move out of data in a `&` reference + | cannot move + error[E0507]: cannot move out of borrowed content --> $DIR/std-uncopyable-atomics.rs:21:13 | @@ -16,6 +25,15 @@ | cannot move out of borrowed content | help: consider removing the `*`: `&x` +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/std-uncopyable-atomics.rs:21:13 + | +LL | let x = *&x; //~ ERROR: cannot move out of borrowed content + | ^^^ + | | + | cannot move out of data in a `&` reference + | cannot move + error[E0507]: cannot move out of borrowed content --> $DIR/std-uncopyable-atomics.rs:23:13 | @@ -25,6 +43,15 @@ | cannot move out of borrowed content | help: consider removing the `*`: `&x` +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/std-uncopyable-atomics.rs:23:13 + | +LL | let x = *&x; //~ ERROR: cannot move out of borrowed content + | ^^^ + | | + | cannot move out of data in a `&` reference + | cannot move + error[E0507]: cannot move out of borrowed content --> $DIR/std-uncopyable-atomics.rs:25:13 | @@ -34,6 +61,15 @@ | cannot move out of borrowed content | help: consider removing the `*`: `&x` -error: aborting due to 4 previous errors +error[E0507]: cannot move out of data in a `&` reference + --> $DIR/std-uncopyable-atomics.rs:25:13 + | +LL | let x = *&x; //~ ERROR: cannot move out of borrowed content + | ^^^ + | | + | cannot move out of data in a `&` reference + | cannot move + +error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/structs/struct-path-associated-type.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/structs/struct-path-associated-type.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/structs/struct-path-associated-type.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/structs/struct-path-associated-type.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -32,9 +32,7 @@ --> $DIR/struct-path-associated-type.rs:42:13 | LL | let s = S::A {}; //~ ERROR ambiguous associated type - | ^^^^ ambiguous associated type - | - = note: specify the type using the syntax `::A` + | ^^^^ help: use fully-qualified syntax: `::A` error[E0109]: type parameters are not allowed on this type --> $DIR/struct-path-associated-type.rs:43:20 @@ -46,17 +44,13 @@ --> $DIR/struct-path-associated-type.rs:43:13 | LL | let z = S::A:: {}; //~ ERROR ambiguous associated type - | ^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `::A` + | ^^^^^^^^^^ help: use fully-qualified syntax: `::A` error[E0223]: ambiguous associated type --> $DIR/struct-path-associated-type.rs:46:9 | LL | S::A {} => {} //~ ERROR ambiguous associated type - | ^^^^ ambiguous associated type - | - = note: specify the type using the syntax `::A` + | ^^^^ help: use fully-qualified syntax: `::A` error: aborting due to 9 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/structs/struct-variant-privacy.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/structs/struct-variant-privacy.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/structs/struct-variant-privacy.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/structs/struct-variant-privacy.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,14 +1,14 @@ error[E0603]: enum `Bar` is private - --> $DIR/struct-variant-privacy.rs:16:9 + --> $DIR/struct-variant-privacy.rs:16:14 | LL | fn f(b: foo::Bar) { //~ ERROR enum `Bar` is private - | ^^^^^^^^ + | ^^^ error[E0603]: enum `Bar` is private - --> $DIR/struct-variant-privacy.rs:18:9 + --> $DIR/struct-variant-privacy.rs:18:14 | LL | foo::Bar::Baz { a: _a } => {} //~ ERROR enum `Bar` is private - | ^^^^^^^^^^^^^ + | ^^^ error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/structs/struct-variant-privacy-xc.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/structs/struct-variant-privacy-xc.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/structs/struct-variant-privacy-xc.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/structs/struct-variant-privacy-xc.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,14 +1,14 @@ error[E0603]: enum `Bar` is private - --> $DIR/struct-variant-privacy-xc.rs:14:9 + --> $DIR/struct-variant-privacy-xc.rs:14:33 | LL | fn f(b: struct_variant_privacy::Bar) { //~ ERROR enum `Bar` is private - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ error[E0603]: enum `Bar` is private - --> $DIR/struct-variant-privacy-xc.rs:16:9 + --> $DIR/struct-variant-privacy-xc.rs:16:33 | LL | struct_variant_privacy::Bar::Baz { a: _a } => {} //~ ERROR enum `Bar` is private - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/suggestions/path-by-value.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/suggestions/path-by-value.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/suggestions/path-by-value.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/suggestions/path-by-value.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,6 @@ +use std::path::Path; + +fn f(p: Path) { } +//~^ ERROR E0277 + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/suggestions/path-by-value.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/suggestions/path-by-value.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/suggestions/path-by-value.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/suggestions/path-by-value.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/path-by-value.rs:3:6 + | +LL | fn f(p: Path) { } + | ^ borrow the `Path` instead + | + = help: within `std::path::Path`, the trait `std::marker::Sized` is not implemented for `[u8]` + = note: to learn more, visit + = note: required because it appears within the type `std::path::Path` + = note: all local variables must have a statically known size + = help: unsized locals are gated as an unstable feature + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-1.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-1.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-1.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-1.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,7 +12,7 @@ let v = vec![0, 1, 2, 3]; for (i, n) in &v.iter().enumerate() { - //~^ ERROR the trait bound + //~^ ERROR `&std::iter::Enumerate>` is not an iterator println!("{}", i); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-1.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-1.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-1.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-1.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,10 +1,10 @@ -error[E0277]: the trait bound `&std::iter::Enumerate>: std::iter::Iterator` is not satisfied +error[E0277]: `&std::iter::Enumerate>` is not an iterator --> $DIR/suggest-remove-refs-1.rs:14:19 | LL | for (i, n) in &v.iter().enumerate() { | -^^^^^^^^^^^^^^^^^^^^ | | - | `&std::iter::Enumerate>` is not an iterator; maybe try calling `.iter()` or a similar method + | `&std::iter::Enumerate>` is not an iterator | help: consider removing 1 leading `&`-references | = help: the trait `std::iter::Iterator` is not implemented for `&std::iter::Enumerate>` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-2.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,7 +12,7 @@ let v = vec![0, 1, 2, 3]; for (i, n) in & & & & &v.iter().enumerate() { - //~^ ERROR the trait bound + //~^ ERROR `&&&&&std::iter::Enumerate>` is not an iterator println!("{}", i); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-2.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-2.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,10 +1,10 @@ -error[E0277]: the trait bound `&&&&&std::iter::Enumerate>: std::iter::Iterator` is not satisfied +error[E0277]: `&&&&&std::iter::Enumerate>` is not an iterator --> $DIR/suggest-remove-refs-2.rs:14:19 | LL | for (i, n) in & & & & &v.iter().enumerate() { | ---------^^^^^^^^^^^^^^^^^^^^ | | - | `&&&&&std::iter::Enumerate>` is not an iterator; maybe try calling `.iter()` or a similar method + | `&&&&&std::iter::Enumerate>` is not an iterator | help: consider removing 5 leading `&`-references | = help: the trait `std::iter::Iterator` is not implemented for `&&&&&std::iter::Enumerate>` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-3.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -15,7 +15,7 @@ & &v .iter() .enumerate() { - //~^^^^ ERROR the trait bound + //~^^^^ ERROR `&&&&&std::iter::Enumerate>` is not an println!("{}", i); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-3.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-3.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-3.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/suggestions/suggest-remove-refs-3.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `&&&&&std::iter::Enumerate>: std::iter::Iterator` is not satisfied +error[E0277]: `&&&&&std::iter::Enumerate>` is not an iterator --> $DIR/suggest-remove-refs-3.rs:14:19 | LL | for (i, n) in & & & @@ -9,7 +9,7 @@ | ||___________- help: consider removing 5 leading `&`-references LL | | .iter() LL | | .enumerate() { - | |_____________________^ `&&&&&std::iter::Enumerate>` is not an iterator; maybe try calling `.iter()` or a similar method + | |_____________________^ `&&&&&std::iter::Enumerate>` is not an iterator | = help: the trait `std::iter::Iterator` is not implemented for `&&&&&std::iter::Enumerate>` = note: required by `std::iter::IntoIterator::into_iter` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/super-at-top-level.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/super-at-top-level.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/super-at-top-level.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/super-at-top-level.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use super::f; //~ ERROR There are too many initial `super`s +use super::f; //~ ERROR there are too many initial `super`s fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/super-at-top-level.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/super-at-top-level.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/super-at-top-level.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/super-at-top-level.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ -error[E0433]: failed to resolve. There are too many initial `super`s. +error[E0433]: failed to resolve: there are too many initial `super`s. --> $DIR/super-at-top-level.rs:11:5 | -LL | use super::f; //~ ERROR There are too many initial `super`s - | ^^^^^ There are too many initial `super`s. +LL | use super::f; //~ ERROR there are too many initial `super`s + | ^^^^^ there are too many initial `super`s. error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/thread-local-in-ctfe.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/thread-local-in-ctfe.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/thread-local-in-ctfe.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/thread-local-in-ctfe.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -10,13 +10,17 @@ LL | static C: &u32 = &A; | ^^ -error[E0712]: thread-local variable borrowed past end of function +warning[E0712]: thread-local variable borrowed past end of function --> $DIR/thread-local-in-ctfe.rs:19:18 | LL | static C: &u32 = &A; | ^^- end of enclosing function is here | | | thread-local variables cannot be borrowed beyond the end of the function + | + = warning: This error has been downgraded to a warning for backwards compatibility with previous releases. + It represents potential unsoundness in your code. + This warning will become a hard error in the future. error[E0625]: thread-local statics cannot be accessed at compile-time --> $DIR/thread-local-in-ctfe.rs:22:16 @@ -30,13 +34,17 @@ LL | const E: &u32 = &A; | ^^ -error[E0712]: thread-local variable borrowed past end of function +warning[E0712]: thread-local variable borrowed past end of function --> $DIR/thread-local-in-ctfe.rs:25:17 | LL | const E: &u32 = &A; | ^^- end of enclosing function is here | | | thread-local variables cannot be borrowed beyond the end of the function + | + = warning: This error has been downgraded to a warning for backwards compatibility with previous releases. + It represents potential unsoundness in your code. + This warning will become a hard error in the future. error[E0625]: thread-local statics cannot be accessed at compile-time --> $DIR/thread-local-in-ctfe.rs:29:5 @@ -44,7 +52,7 @@ LL | A | ^ -error: aborting due to 7 previous errors +error: aborting due to 5 previous errors Some errors occurred: E0625, E0712. For more information about an error, try `rustc --explain E0625`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/token/bounds-obj-parens.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/token/bounds-obj-parens.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/token/bounds-obj-parens.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/token/bounds-obj-parens.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -type A = Box<(Fn(D::Error) -> E) + 'static + Send + Sync>; // OK (but see #39318) - -FAIL -//~^ ERROR diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/token/bounds-obj-parens.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/token/bounds-obj-parens.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/token/bounds-obj-parens.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/token/bounds-obj-parens.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -error: expected one of `!` or `::`, found `` - --> $DIR/bounds-obj-parens.rs:15:1 - | -LL | FAIL - | ^^^^ expected one of `!` or `::` here - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/token/issue-10636-2.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/token/issue-10636-2.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/token/issue-10636-2.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/token/issue-10636-2.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -// Copyright 2013-2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// FIXME(31528) we emit a bunch of silly errors here due to continuing past the -// first one. This would be easy-ish to address by better recovery in tokenisation. - -pub fn trace_option(option: Option) { - option.map(|some| 42; - //~^ ERROR: expected one of - -} //~ ERROR: incorrect close delimiter -//~^ ERROR: expected expression, found `)` - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/token/issue-10636-2.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/token/issue-10636-2.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/token/issue-10636-2.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/token/issue-10636-2.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -error: incorrect close delimiter: `}` - --> $DIR/issue-10636-2.rs:18:1 - | -LL | pub fn trace_option(option: Option) { - | - close delimiter possibly meant for this -LL | option.map(|some| 42; - | - un-closed delimiter -... -LL | } //~ ERROR: incorrect close delimiter - | ^ incorrect close delimiter - -error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;` - --> $DIR/issue-10636-2.rs:15:25 - | -LL | option.map(|some| 42; - | ^ expected one of `)`, `,`, `.`, `?`, or an operator here - -error: expected expression, found `)` - --> $DIR/issue-10636-2.rs:18:1 - | -LL | } //~ ERROR: incorrect close delimiter - | ^ expected expression - -error: aborting due to 3 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/token/issue-15980.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/token/issue-15980.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/token/issue-15980.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/token/issue-15980.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::io; - -fn main(){ - let x: io::IoResult<()> = Ok(()); - //~^ ERROR cannot find type `IoResult` in module `io` - //~| NOTE did you mean `Result`? - match x { - Err(ref e) if e.kind == io::EndOfFile { - //~^ NOTE while parsing this struct - return - //~^ ERROR expected identifier, found keyword `return` - //~| NOTE expected identifier, found keyword - } - //~^ NOTE expected one of `.`, `=>`, `?`, or an operator here - _ => {} - //~^ ERROR expected one of `.`, `=>`, `?`, or an operator, found `_` - //~| NOTE unexpected token - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/token/issue-15980.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/token/issue-15980.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/token/issue-15980.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/token/issue-15980.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -error: expected identifier, found keyword `return` - --> $DIR/issue-15980.rs:20:13 - | -LL | Err(ref e) if e.kind == io::EndOfFile { - | ------------- while parsing this struct -LL | //~^ NOTE while parsing this struct -LL | return - | ^^^^^^ expected identifier, found keyword - -error: expected one of `.`, `=>`, `?`, or an operator, found `_` - --> $DIR/issue-15980.rs:25:9 - | -LL | } - | - expected one of `.`, `=>`, `?`, or an operator here -LL | //~^ NOTE expected one of `.`, `=>`, `?`, or an operator here -LL | _ => {} - | ^ unexpected token - -error[E0412]: cannot find type `IoResult` in module `io` - --> $DIR/issue-15980.rs:14:16 - | -LL | let x: io::IoResult<()> = Ok(()); - | ^^^^^^^^ did you mean `Result`? - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0412`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/token/issue-41155.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/token/issue-41155.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/token/issue-41155.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/token/issue-41155.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -impl S { //~ ERROR cannot find type - pub -} //~ ERROR expected one of - -fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/token/issue-41155.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/token/issue-41155.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/token/issue-41155.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/token/issue-41155.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -error: expected one of `(`, `async`, `const`, `default`, `existential`, `extern`, `fn`, `type`, or `unsafe`, found `}` - --> $DIR/issue-41155.rs:13:1 - | -LL | pub - | - expected one of 9 possible tokens here -LL | } //~ ERROR expected one of - | ^ unexpected token - -error[E0412]: cannot find type `S` in this scope - --> $DIR/issue-41155.rs:11:6 - | -LL | impl S { //~ ERROR cannot find type - | ^ not found in this scope - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0412`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/token/macro-incomplete-parse.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/token/macro-incomplete-parse.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/token/macro-incomplete-parse.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/token/macro-incomplete-parse.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z continue-parse-after-error - -macro_rules! ignored_item { - () => { - fn foo() {} - fn bar() {} - , //~ ERROR macro expansion ignores token `,` - } -} - -macro_rules! ignored_expr { - () => ( 1, //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `,` - - 2 ) -} - -macro_rules! ignored_pat { - () => ( 1, 2 ) //~ ERROR macro expansion ignores token `,` -} - -ignored_item!(); - -fn main() { - ignored_expr!(); - match 1 { - ignored_pat!() => (), - _ => (), - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/token/macro-incomplete-parse.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/token/macro-incomplete-parse.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/token/macro-incomplete-parse.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/token/macro-incomplete-parse.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -error: macro expansion ignores token `,` and any following - --> $DIR/macro-incomplete-parse.rs:17:9 - | -LL | , //~ ERROR macro expansion ignores token `,` - | ^ - | -note: caused by the macro expansion here; the usage of `ignored_item!` is likely invalid in item context - --> $DIR/macro-incomplete-parse.rs:31:1 - | -LL | ignored_item!(); - | ^^^^^^^^^^^^^^^^ - -error: expected one of `.`, `;`, `?`, `}`, or an operator, found `,` - --> $DIR/macro-incomplete-parse.rs:22:14 - | -LL | () => ( 1, //~ ERROR expected one of `.`, `;`, `?`, `}`, or an operator, found `,` - | ^ expected one of `.`, `;`, `?`, `}`, or an operator here -... -LL | ignored_expr!(); - | ---------------- in this macro invocation - -error: macro expansion ignores token `,` and any following - --> $DIR/macro-incomplete-parse.rs:28:14 - | -LL | () => ( 1, 2 ) //~ ERROR macro expansion ignores token `,` - | ^ - | -note: caused by the macro expansion here; the usage of `ignored_pat!` is likely invalid in pattern context - --> $DIR/macro-incomplete-parse.rs:36:9 - | -LL | ignored_pat!() => (), - | ^^^^^^^^^^^^^^ - -error: aborting due to 3 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/token/trailing-plus-in-bounds.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/token/trailing-plus-in-bounds.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/token/trailing-plus-in-bounds.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/token/trailing-plus-in-bounds.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only -Z continue-parse-after-error - -use std::fmt::Debug; - -fn main() { - let x: Box = box 3 as Box; // Trailing `+` is OK -} - -FAIL -//~^ ERROR diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/token/trailing-plus-in-bounds.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/token/trailing-plus-in-bounds.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/token/trailing-plus-in-bounds.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/token/trailing-plus-in-bounds.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -error: expected one of `!` or `::`, found `` - --> $DIR/trailing-plus-in-bounds.rs:19:1 - | -LL | FAIL - | ^^^^ expected one of `!` or `::` here - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/tool-attributes/tool-attributes-shadowing.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/tool-attributes/tool-attributes-shadowing.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/tool-attributes/tool-attributes-shadowing.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/tool-attributes/tool-attributes-shadowing.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,5 +10,5 @@ mod rustfmt {} -#[rustfmt::skip] //~ ERROR failed to resolve. Could not find `skip` in `rustfmt` +#[rustfmt::skip] //~ ERROR failed to resolve: could not find `skip` in `rustfmt` fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/tool-attributes/tool-attributes-shadowing.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/tool-attributes/tool-attributes-shadowing.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/tool-attributes/tool-attributes-shadowing.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/tool-attributes/tool-attributes-shadowing.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ -error[E0433]: failed to resolve. Could not find `skip` in `rustfmt` +error[E0433]: failed to resolve: could not find `skip` in `rustfmt` --> $DIR/tool-attributes-shadowing.rs:13:12 | -LL | #[rustfmt::skip] //~ ERROR failed to resolve. Could not find `skip` in `rustfmt` - | ^^^^ Could not find `skip` in `rustfmt` +LL | #[rustfmt::skip] //~ ERROR failed to resolve: could not find `skip` in `rustfmt` + | ^^^^ could not find `skip` in `rustfmt` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/tool_lints-fail.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/tool_lints-fail.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/tool_lints-fail.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/tool_lints-fail.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,7 @@ // Don't allow tool_lints, which aren't scoped -#![feature(tool_lints)] + #![deny(unknown_lints)] #![deny(clippy)] //~ ERROR: unknown lint: `clippy` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/tool_lints.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/tool_lints.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/tool_lints.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/tool_lints.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(tool_lints)] + #[warn(foo::bar)] //~^ ERROR an unknown tool name found in scoped lint: `foo::bar` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/traits/conservative_impl_trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/traits/conservative_impl_trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/traits/conservative_impl_trait.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/traits/conservative_impl_trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// #39665 + +fn batches(n: &u32) -> impl Iterator { + std::iter::once(n) +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/traits/trait-bounds-on-structs-and-enums-static.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/traits/trait-bounds-on-structs-and-enums-static.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/traits/trait-bounds-on-structs-and-enums-static.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/traits/trait-bounds-on-structs-and-enums-static.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,11 +1,8 @@ error[E0277]: the trait bound `usize: Trait` is not satisfied - --> $DIR/trait-bounds-on-structs-and-enums-static.rs:19:1 + --> $DIR/trait-bounds-on-structs-and-enums-static.rs:19:11 | -LL | / static X: Foo = Foo { -LL | | //~^ ERROR E0277 -LL | | x: 1, -LL | | }; - | |__^ the trait `Trait` is not implemented for `usize` +LL | static X: Foo = Foo { + | ^^^^^^^^^^ the trait `Trait` is not implemented for `usize` | note: required by `Foo` --> $DIR/trait-bounds-on-structs-and-enums-static.rs:15:1 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/traits/trait-coercion-generic-regions.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/traits/trait-coercion-generic-regions.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/traits/trait-coercion-generic-regions.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/traits/trait-coercion-generic-regions.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,12 +2,13 @@ --> $DIR/trait-coercion-generic-regions.rs:27:24 | LL | let person: &str = &person; //~ ERROR `person` does not live long enough - | ^^^^^^^ borrowed value does not live long enough + | ^^^^^^^ + | | + | borrowed value does not live long enough + | assignment requires that `person` is borrowed for `'static` LL | let s: Box> = Box::new(Struct { person: person }); LL | } | - `person` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/traits/trait-item-privacy.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/traits/trait-item-privacy.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/traits/trait-item-privacy.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/traits/trait-item-privacy.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -138,25 +138,19 @@ --> $DIR/trait-item-privacy.rs:127:12 | LL | let _: S::A; //~ ERROR ambiguous associated type - | ^^^^ ambiguous associated type - | - = note: specify the type using the syntax `::A` + | ^^^^ help: use fully-qualified syntax: `::A` error[E0223]: ambiguous associated type --> $DIR/trait-item-privacy.rs:128:12 | LL | let _: S::B; //~ ERROR ambiguous associated type - | ^^^^ ambiguous associated type - | - = note: specify the type using the syntax `::B` + | ^^^^ help: use fully-qualified syntax: `::B` error[E0223]: ambiguous associated type --> $DIR/trait-item-privacy.rs:129:12 | LL | let _: S::C; //~ ERROR ambiguous associated type - | ^^^^ ambiguous associated type - | - = note: specify the type using the syntax `::C` + | ^^^^ help: use fully-qualified syntax: `::C` error: associated type `A` is private --> $DIR/trait-item-privacy.rs:131:12 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-copy.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-copy.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-copy.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-copy.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,41 +1,26 @@ warning: Trait bound std::string::String: std::marker::Copy does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-copy.rs:16:1 + --> $DIR/trivial-bounds-inconsistent-copy.rs:16:51 | -LL | / fn copy_string(t: String) -> String where String: Copy { -LL | | is_copy(&t); -LL | | let x = t; -LL | | drop(t); -LL | | t -LL | | } - | |_^ +LL | fn copy_string(t: String) -> String where String: Copy { + | ^^^^ | = note: #[warn(trivial_bounds)] on by default warning: Trait bound std::string::String: std::marker::Copy does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-copy.rs:23:1 + --> $DIR/trivial-bounds-inconsistent-copy.rs:23:56 | -LL | / fn copy_out_string(t: &String) -> String where String: Copy { -LL | | *t -LL | | } - | |_^ +LL | fn copy_out_string(t: &String) -> String where String: Copy { + | ^^^^ warning: Trait bound std::string::String: std::marker::Copy does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-copy.rs:27:1 + --> $DIR/trivial-bounds-inconsistent-copy.rs:27:55 | -LL | / fn copy_string_with_param(x: String) where String: Copy { -LL | | let y = x; -LL | | let z = x; -LL | | } - | |_^ +LL | fn copy_string_with_param(x: String) where String: Copy { + | ^^^^ warning: Trait bound for<'b> &'b mut i32: std::marker::Copy does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-copy.rs:33:1 + --> $DIR/trivial-bounds-inconsistent-copy.rs:33:76 | -LL | / fn copy_mut<'a>(t: &&'a mut i32) -> &'a mut i32 where for<'b> &'b mut i32: Copy { -LL | | is_copy(t); -LL | | let x = *t; -LL | | drop(x); -LL | | x -LL | | } - | |_^ +LL | fn copy_mut<'a>(t: &&'a mut i32) -> &'a mut i32 where for<'b> &'b mut i32: Copy { + | ^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-projection.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,57 +1,44 @@ warning: Trait bound B: A does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-projection.rs:29:1 + --> $DIR/trivial-bounds-inconsistent-projection.rs:31:8 | -LL | / fn underspecified_bound() -> u8 -LL | | where -LL | | B: A -LL | | { -LL | | B::get_x() -LL | | } - | |_^ +LL | B: A + | ^ | = note: #[warn(trivial_bounds)] on by default warning: Trait bound B: A does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-projection.rs:36:1 + --> $DIR/trivial-bounds-inconsistent-projection.rs:38:8 | -LL | / fn inconsistent_bound() -> i32 -LL | | where -LL | | B: A -LL | | { -LL | | B::get_x() -LL | | } - | |_^ - -warning: Trait bound B: A does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-projection.rs:43:1 - | -LL | / fn redundant_bound() -> u8 -LL | | where -LL | | B: A -LL | | { -LL | | B::get_x() -LL | | } - | |_^ - -warning: Trait bound B: A does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-projection.rs:50:1 - | -LL | / fn inconsistent_dup_bound() -> i32 -LL | | where -LL | | B: A + A -LL | | { -LL | | B::get_x() -LL | | } - | |_^ - -warning: Trait bound B: A does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-projection.rs:57:1 - | -LL | / fn redundant_dup_bound() -> u8 -LL | | where -LL | | B: A + A -LL | | { -LL | | B::get_x() -LL | | } - | |_^ +LL | B: A + | ^^^^^^^^^^ + +warning: Trait bound B: A does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent-projection.rs:45:8 + | +LL | B: A + | ^^^^^^^^^ + +warning: Trait bound B: A does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent-projection.rs:52:8 + | +LL | B: A + A + | ^^^^^^^^^^ + +warning: Trait bound B: A does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent-projection.rs:52:21 + | +LL | B: A + A + | ^ + +warning: Trait bound B: A does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent-projection.rs:59:8 + | +LL | B: A + A + | ^^^^^^^^^ + +warning: Trait bound B: A does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent-projection.rs:59:20 + | +LL | B: A + A + | ^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-sized.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-sized.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-sized.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-sized.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,24 +1,20 @@ warning: Trait bound str: std::marker::Sized does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-sized.rs:24:1 + --> $DIR/trivial-bounds-inconsistent-sized.rs:24:31 | LL | struct S(str, str) where str: Sized; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ | = note: #[warn(trivial_bounds)] on by default warning: Trait bound for<'a> T<(dyn A + 'a)>: std::marker::Sized does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-sized.rs:26:1 + --> $DIR/trivial-bounds-inconsistent-sized.rs:26:45 | -LL | / fn unsized_local() where for<'a> T: Sized { -LL | | let x: T = *(Box::new(T { x: 1 }) as Box>); -LL | | } - | |_^ +LL | fn unsized_local() where for<'a> T: Sized { + | ^^^^^ warning: Trait bound str: std::marker::Sized does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-sized.rs:30:1 + --> $DIR/trivial-bounds-inconsistent-sized.rs:30:35 | -LL | / fn return_str() -> str where str: Sized { -LL | | *"Sized".to_string().into_boxed_str() -LL | | } - | |_^ +LL | fn return_str() -> str where str: Sized { + | ^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-inconsistent.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,28 +1,28 @@ warning: Trait bound i32: Foo does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent.rs:24:1 + --> $DIR/trivial-bounds-inconsistent.rs:24:19 | LL | enum E where i32: Foo { V } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ | = note: #[warn(trivial_bounds)] on by default warning: Trait bound i32: Foo does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent.rs:26:1 + --> $DIR/trivial-bounds-inconsistent.rs:26:21 | LL | struct S where i32: Foo; - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ warning: Trait bound i32: Foo does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent.rs:28:1 + --> $DIR/trivial-bounds-inconsistent.rs:28:20 | LL | trait T where i32: Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ warning: Trait bound i32: Foo does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent.rs:30:1 + --> $DIR/trivial-bounds-inconsistent.rs:30:20 | LL | union U where i32: Foo { f: i32 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ warning: where clauses are not enforced in type aliases --> $DIR/trivial-bounds-inconsistent.rs:32:14 @@ -34,79 +34,56 @@ = help: the clause will not be checked when the type alias is used, and should be removed warning: Trait bound i32: Foo does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent.rs:32:1 + --> $DIR/trivial-bounds-inconsistent.rs:32:19 | LL | type Y where i32: Foo = (); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ warning: Trait bound i32: Foo does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent.rs:34:1 + --> $DIR/trivial-bounds-inconsistent.rs:34:28 | -LL | / impl Foo for () where i32: Foo { -LL | | fn test(&self) { -LL | | 3i32.test(); -LL | | Foo::test(&4i32); -LL | | generic_function(5i32); -LL | | } -LL | | } - | |_^ - -warning: Trait bound i32: Foo does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent.rs:42:1 - | -LL | / fn f() where i32: Foo { -LL | | let s = S; -LL | | 3i32.test(); -LL | | Foo::test(&4i32); -LL | | generic_function(5i32); -LL | | } - | |_^ +LL | impl Foo for () where i32: Foo { + | ^^^ + +warning: Trait bound i32: Foo does not depend on any type or lifetime parameters + --> $DIR/trivial-bounds-inconsistent.rs:42:19 + | +LL | fn f() where i32: Foo { + | ^^^ warning: Trait bound &'static str: Foo does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent.rs:49:1 + --> $DIR/trivial-bounds-inconsistent.rs:49:28 | -LL | / fn g() where &'static str: Foo { -LL | | "Foo".test(); -LL | | Foo::test(&"Foo"); -LL | | generic_function("Foo"); -LL | | } - | |_^ +LL | fn g() where &'static str: Foo { + | ^^^ warning: Trait bound str: std::marker::Sized does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent.rs:63:1 + --> $DIR/trivial-bounds-inconsistent.rs:63:37 | LL | struct TwoStrs(str, str) where str: Sized; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ warning: Trait bound for<'a> Dst<(dyn A + 'a)>: std::marker::Sized does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent.rs:65:1 + --> $DIR/trivial-bounds-inconsistent.rs:65:47 | -LL | / fn unsized_local() where for<'a> Dst: Sized { -LL | | let x: Dst = *(Box::new(Dst { x: 1 }) as Box>); -LL | | } - | |_^ +LL | fn unsized_local() where for<'a> Dst: Sized { + | ^^^^^ warning: Trait bound str: std::marker::Sized does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent.rs:69:1 + --> $DIR/trivial-bounds-inconsistent.rs:69:35 | -LL | / fn return_str() -> str where str: Sized { -LL | | *"Sized".to_string().into_boxed_str() -LL | | } - | |_^ +LL | fn return_str() -> str where str: Sized { + | ^^^^^ warning: Trait bound std::string::String: std::ops::Neg does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent.rs:73:1 + --> $DIR/trivial-bounds-inconsistent.rs:73:46 | -LL | / fn use_op(s: String) -> String where String: ::std::ops::Neg { -LL | | -s -LL | | } - | |_^ +LL | fn use_op(s: String) -> String where String: ::std::ops::Neg { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: Trait bound i32: std::iter::Iterator does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent.rs:77:1 + --> $DIR/trivial-bounds-inconsistent.rs:77:25 | -LL | / fn use_for() where i32: Iterator { -LL | | for _ in 2i32 {} -LL | | } - | |_^ +LL | fn use_for() where i32: Iterator { + | ^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-well-formed.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-well-formed.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-well-formed.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-inconsistent-well-formed.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,20 +1,14 @@ warning: Trait bound std::vec::Vec: std::fmt::Debug does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-well-formed.rs:17:1 + --> $DIR/trivial-bounds-inconsistent-well-formed.rs:17:30 | -LL | / pub fn foo() where Vec: Debug, str: Copy { -LL | | let x = vec![*"1"]; -LL | | println!("{:?}", x); -LL | | } - | |_^ +LL | pub fn foo() where Vec: Debug, str: Copy { + | ^^^^^ | = note: #[warn(trivial_bounds)] on by default warning: Trait bound str: std::marker::Copy does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-inconsistent-well-formed.rs:17:1 + --> $DIR/trivial-bounds-inconsistent-well-formed.rs:17:42 | -LL | / pub fn foo() where Vec: Debug, str: Copy { -LL | | let x = vec![*"1"]; -LL | | println!("{:?}", x); -LL | | } - | |_^ +LL | pub fn foo() where Vec: Debug, str: Copy { + | ^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-leak-copy.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-leak-copy.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-leak-copy.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-leak-copy.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,20 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/trivial-bounds-leak-copy.rs:19:5 + | +LL | *t //~ ERROR + | ^^ cannot move out of borrowed content + +error[E0507]: cannot move out of `*t` which is behind a `&` reference + --> $DIR/trivial-bounds-leak-copy.rs:19:5 + | +LL | fn move_out_string(t: &String) -> String { + | ------- help: consider changing this to be a mutable reference: `&mut std::string::String` +LL | *t //~ ERROR + | ^^ + | | + | cannot move out of `*t` which is behind a `&` reference + | `t` is a `&` reference, so the data it refers to cannot be moved + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-lint.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-lint.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-lint.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/trivial-bounds/trivial-bounds-lint.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ error: Trait bound i32: std::marker::Copy does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-lint.rs:15:1 + --> $DIR/trivial-bounds-lint.rs:15:21 | LL | struct A where i32: Copy; //~ ERROR - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^ | note: lint level defined here --> $DIR/trivial-bounds-lint.rs:13:9 @@ -11,40 +11,40 @@ | ^^^^^^^^^^^^^^ error: Trait bound i32: X<()> does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-lint.rs:28:1 + --> $DIR/trivial-bounds-lint.rs:28:30 | LL | fn global_param() where i32: X<()> {} //~ ERROR - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ error: Trait bound i32: Z does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-lint.rs:32:1 + --> $DIR/trivial-bounds-lint.rs:32:35 | LL | fn global_projection() where i32: Z {} //~ ERROR - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ error: Lifetime bound i32 : 'static does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-lint.rs:39:1 + --> $DIR/trivial-bounds-lint.rs:39:34 | LL | fn global_lifetimes() where i32: 'static, &'static str: 'static {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^ error: Lifetime bound &'static str : 'static does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-lint.rs:39:1 + --> $DIR/trivial-bounds-lint.rs:39:57 | LL | fn global_lifetimes() where i32: 'static, &'static str: 'static {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^ error: Lifetime bound 'static : 'static does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-lint.rs:45:1 + --> $DIR/trivial-bounds-lint.rs:45:37 | LL | fn global_outlives() where 'static: 'static {} //~ ERROR - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^ error: Trait bound i32: std::marker::Copy does not depend on any type or lifetime parameters - --> $DIR/trivial-bounds-lint.rs:48:1 + --> $DIR/trivial-bounds-lint.rs:48:46 | LL | fn mixed_bounds() where i32: X + Copy {} //~ ERROR - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^ error: aborting due to 7 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/try-block/try-block-bad-lifetime.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/try-block/try-block-bad-lifetime.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/try-block/try-block-bad-lifetime.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/try-block/try-block-bad-lifetime.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/try-block-bad-lifetime.rs:25:33 | LL | let result: Result<(), &str> = try { - | ------ borrow later used here + | ------ borrow later stored here LL | let my_string = String::from(""); LL | let my_str: & str = & my_string; | ^^^^^^^^^^^ borrowed value does not live long enough diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/type/type-path-err-node-types.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/type/type-path-err-node-types.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/type/type-path-err-node-types.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/type/type-path-err-node-types.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ -error[E0433]: failed to resolve. Use of undeclared type or module `NonExistent` +error[E0433]: failed to resolve: use of undeclared type or module `NonExistent` --> $DIR/type-path-err-node-types.rs:25:5 | LL | NonExistent::Assoc::; //~ ERROR undeclared type or module `NonExistent` - | ^^^^^^^^^^^ Use of undeclared type or module `NonExistent` + | ^^^^^^^^^^^ use of undeclared type or module `NonExistent` error[E0412]: cannot find type `Nonexistent` in this scope --> $DIR/type-path-err-node-types.rs:17:12 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/typeck/issue-55810-must-typeck-match-pats-before-guards.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/typeck/issue-55810-must-typeck-match-pats-before-guards.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/typeck/issue-55810-must-typeck-match-pats-before-guards.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/typeck/issue-55810-must-typeck-match-pats-before-guards.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// compile-pass + +// rust-lang/rust#55810: types for a binding in a match arm can be +// inferred from arms that come later in the match. + +struct S; + +impl S { + fn method(&self) -> bool { + unimplemented!() + } +} + +fn get() -> T { + unimplemented!() +} + +fn main() { + match get() { + x if x.method() => {} + &S => {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/typeck/typeck_type_placeholder_item.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/typeck/typeck_type_placeholder_item.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/typeck/typeck_type_placeholder_item.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/typeck/typeck_type_placeholder_item.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -77,6 +77,24 @@ | ^ not allowed in type signatures error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/typeck_type_placeholder_item.rs:112:12 + | +LL | a: _, + | ^ not allowed in type signatures + +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/typeck_type_placeholder_item.rs:114:13 + | +LL | b: (_, _), + | ^ not allowed in type signatures + +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/typeck_type_placeholder_item.rs:114:16 + | +LL | b: (_, _), + | ^ not allowed in type signatures + +error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item.rs:67:21 | LL | fn fn_test() -> _ { 5 } @@ -137,24 +155,6 @@ | ^ not allowed in type signatures error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:112:12 - | -LL | a: _, - | ^ not allowed in type signatures - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:114:13 - | -LL | b: (_, _), - | ^ not allowed in type signatures - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:114:16 - | -LL | b: (_, _), - | ^ not allowed in type signatures - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item.rs:43:24 | LL | fn test9(&self) -> _ { () } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/ufcs/ufcs-partially-resolved.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/ufcs/ufcs-partially-resolved.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/ufcs/ufcs-partially-resolved.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/ufcs/ufcs-partially-resolved.rs 2018-12-04 23:41:40.000000000 +0000 @@ -55,9 +55,9 @@ ::NN; //~ ERROR cannot find method or associated constant `NN` in `E::N` ::NN; //~ ERROR cannot find method or associated constant `NN` in `A::N` let _: ::NN; //~ ERROR cannot find associated type `NN` in `Tr::Y` - let _: ::NN; //~ ERROR failed to resolve. Not a module `Y` + let _: ::NN; //~ ERROR failed to resolve: not a module `Y` ::NN; //~ ERROR cannot find method or associated constant `NN` in `Tr::Y` - ::NN; //~ ERROR failed to resolve. Not a module `Y` + ::NN; //~ ERROR failed to resolve: not a module `Y` let _: ::Z; //~ ERROR expected associated type, found method `Dr::Z` ::X; //~ ERROR expected method or associated constant, found associated type `Dr::X` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/ufcs/ufcs-partially-resolved.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/ufcs/ufcs-partially-resolved.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/ufcs/ufcs-partially-resolved.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/ufcs/ufcs-partially-resolved.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,14 +1,14 @@ -error[E0433]: failed to resolve. Not a module `Y` +error[E0433]: failed to resolve: not a module `Y` --> $DIR/ufcs-partially-resolved.rs:58:22 | -LL | let _: ::NN; //~ ERROR failed to resolve. Not a module `Y` - | ^ Not a module `Y` +LL | let _: ::NN; //~ ERROR failed to resolve: not a module `Y` + | ^ not a module `Y` -error[E0433]: failed to resolve. Not a module `Y` +error[E0433]: failed to resolve: not a module `Y` --> $DIR/ufcs-partially-resolved.rs:60:15 | -LL | ::NN; //~ ERROR failed to resolve. Not a module `Y` - | ^ Not a module `Y` +LL | ::NN; //~ ERROR failed to resolve: not a module `Y` + | ^ not a module `Y` error[E0576]: cannot find associated type `N` in trait `Tr` --> $DIR/ufcs-partially-resolved.rs:29:24 @@ -184,9 +184,7 @@ --> $DIR/ufcs-partially-resolved.rs:46:12 | LL | let _: ::Y::NN; //~ ERROR ambiguous associated type - | ^^^^^^^^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `<::Y as Trait>::NN` + | ^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<::Y as Trait>::NN` error[E0599]: no associated item named `NN` found for type `::Y` in the current scope --> $DIR/ufcs-partially-resolved.rs:48:5 diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closure-illegal-move.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -6,6 +6,21 @@ LL | let f = to_fn(|| drop(x)); //~ ERROR cannot move | ^ cannot move out of captured variable in an `Fn` closure +error[E0507]: cannot move out of `x`, as it is a captured variable in a `Fn` closure + --> $DIR/unboxed-closure-illegal-move.rs:25:31 + | +LL | let f = to_fn(|| drop(x)); //~ ERROR cannot move + | ^ + | | + | cannot move out of `x`, as it is a captured variable in a `Fn` closure + | cannot move + | +help: consider changing this to accept closures that implement `FnMut` + --> $DIR/unboxed-closure-illegal-move.rs:25:23 + | +LL | let f = to_fn(|| drop(x)); //~ ERROR cannot move + | ^^^^^^^^^^ + error[E0507]: cannot move out of captured variable in an `FnMut` closure --> $DIR/unboxed-closure-illegal-move.rs:29:35 | @@ -22,6 +37,21 @@ LL | let f = to_fn(move || drop(x)); //~ ERROR cannot move | ^ cannot move out of captured variable in an `Fn` closure +error[E0507]: cannot move out of `x`, as it is a captured variable in a `Fn` closure + --> $DIR/unboxed-closure-illegal-move.rs:38:36 + | +LL | let f = to_fn(move || drop(x)); //~ ERROR cannot move + | ^ + | | + | cannot move out of `x`, as it is a captured variable in a `Fn` closure + | cannot move + | +help: consider changing this to accept closures that implement `FnMut` + --> $DIR/unboxed-closure-illegal-move.rs:38:23 + | +LL | let f = to_fn(move || drop(x)); //~ ERROR cannot move + | ^^^^^^^^^^^^^^^ + error[E0507]: cannot move out of captured variable in an `FnMut` closure --> $DIR/unboxed-closure-illegal-move.rs:42:40 | @@ -30,6 +60,6 @@ LL | let f = to_fn_mut(move || drop(x)); //~ ERROR cannot move | ^ cannot move out of captured variable in an `FnMut` closure -error: aborting due to 4 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0507`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closure-region.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closure-region.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closure-region.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closure-region.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,14 +1,15 @@ error[E0597]: `x` does not live long enough --> $DIR/unboxed-closure-region.rs:18:12 | +LL | let _f = { + | -- borrow later stored here +LL | let x = 0; LL | || x //~ ERROR `x` does not live long enough | -- ^ borrowed value does not live long enough | | | value captured here LL | }; | - `x` dropped here while still borrowed -LL | _f; - | -- borrow later used here error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -10,9 +10,7 @@ | - | | | `factorial` dropped here while still borrowed - | borrow later used here, when `factorial` is dropped - | - = note: values in a scope are dropped in the opposite order they are defined + | borrow might be used here, when `factorial` is dropped and runs the destructor for type `std::option::Option u32>>` error[E0506]: cannot assign to `factorial` because it is borrowed --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:30:5 @@ -31,6 +29,9 @@ error[E0597]: `factorial` does not live long enough --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:38:17 | +LL | let mut factorial: Option u32 + 'static>> = None; + | ------------------------------------- type annotation requires that `factorial` is borrowed for `'static` +LL | LL | let f = |x: u32| -> u32 { | --------------- value captured here LL | //~^ ERROR closure may outlive the current function, but it borrows `factorial` @@ -39,12 +40,13 @@ ... LL | } | - `factorial` dropped here while still borrowed - | - = note: borrowed value must be valid for the static lifetime... error[E0506]: cannot assign to `factorial` because it is borrowed --> $DIR/unboxed-closures-failed-recursive-fn-1.rs:42:5 | +LL | let mut factorial: Option u32 + 'static>> = None; + | ------------------------------------- type annotation requires that `factorial` is borrowed for `'static` +LL | LL | let f = |x: u32| -> u32 { | --------------- borrow of `factorial` occurs here LL | //~^ ERROR closure may outlive the current function, but it borrows `factorial` @@ -53,8 +55,6 @@ ... LL | factorial = Some(Box::new(f)); | ^^^^^^^^^ assignment to borrowed `factorial` occurs here - | - = note: borrowed value must be valid for the static lifetime... error: aborting due to 4 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closures-infer-argument-types-two-region-pointers.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closures-infer-argument-types-two-region-pointers.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closures-infer-argument-types-two-region-pointers.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closures-infer-argument-types-two-region-pointers.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/unboxed-closures-infer-argument-types-two-region-pointers.rs:27:9 - | -LL | doit(0, &|x, y| { - | - - has type `&'1 i32` - | | - | has type `&std::cell::Cell<&'2 i32>` -LL | x.set(y); //~ ERROR E0312 - | ^^^^^^^^ argument requires that `'1` must outlive `'2` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closures-infer-fnonce-call-twice.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closures-infer-fnonce-call-twice.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closures-infer-fnonce-call-twice.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closures-infer-fnonce-call-twice.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error[E0382]: use of moved value: `tick` - --> $DIR/unboxed-closures-infer-fnonce-call-twice.rs:20:5 - | -LL | tick(); - | ---- value moved here -LL | tick(); //~ ERROR use of moved value: `tick` - | ^^^^ value used here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closures-infer-fnonce-move-call-twice.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closures-infer-fnonce-move-call-twice.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closures-infer-fnonce-move-call-twice.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closures-infer-fnonce-move-call-twice.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error[E0382]: use of moved value: `tick` - --> $DIR/unboxed-closures-infer-fnonce-move-call-twice.rs:20:5 - | -LL | tick(); - | ---- value moved here -LL | tick(); //~ ERROR use of moved value: `tick` - | ^^^^ value used here after move - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/unboxed-closures/unboxed-closures-recursive-fn-using-fn-mut.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,11 +2,10 @@ --> $DIR/unboxed-closures-recursive-fn-using-fn-mut.rs:32:21 | LL | (self.func)(self, arg) - | ------------^^^^------ - | | | - | | second mutable borrow occurs here + | ----------- ^^^^ second mutable borrow occurs here + | | | first mutable borrow occurs here - | borrow later used here + | first borrow later used by call error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore_const_names_feature_gate.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore_const_names_feature_gate.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore_const_names_feature_gate.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore_const_names_feature_gate.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const _: () = (); //~ ERROR is unstable +static _: () = (); //~ ERROR is unstable + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore_const_names_feature_gate.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore_const_names_feature_gate.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore_const_names_feature_gate.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore_const_names_feature_gate.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +error[E0658]: naming constants with `_` is unstable (see issue #54912) + --> $DIR/underscore_const_names_feature_gate.rs:11:1 + | +LL | const _: () = (); //~ ERROR is unstable + | ^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(underscore_const_names)] to the crate attributes to enable + +error[E0658]: naming constants with `_` is unstable (see issue #54912) + --> $DIR/underscore_const_names_feature_gate.rs:12:1 + | +LL | static _: () = (); //~ ERROR is unstable + | ^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(underscore_const_names)] to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore_const_names.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore_const_names.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore_const_names.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore_const_names.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,43 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass + +#![feature(const_let)] +#![feature(underscore_const_names)] + +trait Trt {} +struct Str {} +impl Trt for Str {} + +macro_rules! check_impl { + ($struct:ident,$trait:ident) => { + const _ : () = { + use std::marker::PhantomData; + struct ImplementsTrait(PhantomData); + let _ = ImplementsTrait::<$struct>(PhantomData); + () + }; + } +} + +#[deny(unused)] +const _ : () = (); + +const _ : i32 = 42; +const _ : Str = Str{}; + +check_impl!(Str, Trt); +check_impl!(Str, Trt); + +fn main() { + check_impl!(Str, Trt); + check_impl!(Str, Trt); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/dyn-trait-underscore.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/dyn-trait-underscore.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/dyn-trait-underscore.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/dyn-trait-underscore.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/dyn-trait-underscore.rs:18:5 - | -LL | fn a(items: &[T]) -> Box> { - | - let's call the lifetime of this reference `'1` -LL | // ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static` -LL | Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime - | ^^^^^^^^^^^^^^^^^^^^^^ cast requires that `'1` must outlive `'static` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-binder.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-binder.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-binder.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-binder.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,35 @@ +// Check that we error when `'_` appears as the name of a lifetime parameter. +// +// Regression test for #52098. + +struct IceCube<'a> { + v: Vec<&'a char> +} + +impl<'_> IceCube<'_> {} +//~^ ERROR `'_` cannot be used here + +struct Struct<'_> { +//~^ ERROR `'_` cannot be used here + v: Vec<&'static char> +} + +enum Enum<'_> { +//~^ ERROR `'_` cannot be used here + Variant +} + +union Union<'_> { +//~^ ERROR `'_` cannot be used here + a: u32 +} + +trait Trait<'_> { +//~^ ERROR `'_` cannot be used here +} + +fn foo<'_>() { + //~^ ERROR `'_` cannot be used here +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-binder.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-binder.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-binder.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-binder.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,39 @@ +error[E0637]: `'_` cannot be used here + --> $DIR/in-binder.rs:9:6 + | +LL | impl<'_> IceCube<'_> {} + | ^^ `'_` is a reserved lifetime name + +error[E0637]: `'_` cannot be used here + --> $DIR/in-binder.rs:12:15 + | +LL | struct Struct<'_> { + | ^^ `'_` is a reserved lifetime name + +error[E0637]: `'_` cannot be used here + --> $DIR/in-binder.rs:17:11 + | +LL | enum Enum<'_> { + | ^^ `'_` is a reserved lifetime name + +error[E0637]: `'_` cannot be used here + --> $DIR/in-binder.rs:22:13 + | +LL | union Union<'_> { + | ^^ `'_` is a reserved lifetime name + +error[E0637]: `'_` cannot be used here + --> $DIR/in-binder.rs:27:13 + | +LL | trait Trait<'_> { + | ^^ `'_` is a reserved lifetime name + +error[E0637]: `'_` cannot be used here + --> $DIR/in-binder.rs:31:8 + | +LL | fn foo<'_>() { + | ^^ `'_` is a reserved lifetime name + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0637`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-fn-return-illegal.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-fn-return-illegal.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-fn-return-illegal.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-fn-return-illegal.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that the `'_` used in structs/enums gives an error. + +use std::fmt::Debug; + +fn foo(x: &u32, y: &u32) -> &'_ u32 { loop { } } //~ ERROR missing lifetime specifier + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-fn-return-illegal.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-fn-return-illegal.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-fn-return-illegal.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-fn-return-illegal.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,11 @@ +error[E0106]: missing lifetime specifier + --> $DIR/in-fn-return-illegal.rs:15:30 + | +LL | fn foo(x: &u32, y: &u32) -> &'_ u32 { loop { } } //~ ERROR missing lifetime specifier + | ^^ expected lifetime parameter + | + = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `x` or `y` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0106`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-struct.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-struct.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-struct.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-struct.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Check that the `'_` used in structs/enums gives an error. + +use std::fmt::Debug; + +struct Foo { + x: &'_ u32, //~ ERROR missing lifetime specifier +} + +enum Bar { + Variant(&'_ u32), //~ ERROR missing lifetime specifier +} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-struct.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-struct.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-struct.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/in-struct.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +error[E0106]: missing lifetime specifier + --> $DIR/in-struct.rs:16:9 + | +LL | x: &'_ u32, //~ ERROR missing lifetime specifier + | ^^ expected lifetime parameter + +error[E0106]: missing lifetime specifier + --> $DIR/in-struct.rs:20:14 + | +LL | Variant(&'_ u32), //~ ERROR missing lifetime specifier + | ^^ expected lifetime parameter + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0106`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/underscore-lifetime-binders.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/underscore-lifetime-binders.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/underscore-lifetime-binders.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/underscore-lifetime-binders.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,17 +11,13 @@ struct Foo<'a>(&'a u8); struct Baz<'a>(&'_ &'a u8); //~ ERROR missing lifetime specifier -impl Foo<'_> { //~ ERROR missing lifetime specifier - fn x() {} -} - -fn foo<'_> //~ ERROR invalid lifetime parameter name: `'_` +fn foo<'_> //~ ERROR cannot be used here (_: Foo<'_>) {} trait Meh<'a> {} impl<'a> Meh<'a> for u8 {} -fn meh() -> Box Meh<'_>> //~ ERROR invalid lifetime parameter name: `'_` +fn meh() -> Box Meh<'_>> //~ ERROR cannot be used here //~^ ERROR missing lifetime specifier { Box::new(5u8) diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,45 +1,38 @@ -error[E0106]: missing lifetime specifier - --> $DIR/underscore-lifetime-binders.rs:12:17 +error[E0637]: `'_` cannot be used here + --> $DIR/underscore-lifetime-binders.rs:14:8 | -LL | struct Baz<'a>(&'_ &'a u8); //~ ERROR missing lifetime specifier - | ^^ expected lifetime parameter +LL | fn foo<'_> //~ ERROR cannot be used here + | ^^ `'_` is a reserved lifetime name -error[E0106]: missing lifetime specifier - --> $DIR/underscore-lifetime-binders.rs:14:10 +error[E0637]: `'_` cannot be used here + --> $DIR/underscore-lifetime-binders.rs:20:21 | -LL | impl Foo<'_> { //~ ERROR missing lifetime specifier - | ^^ expected lifetime parameter +LL | fn meh() -> Box Meh<'_>> //~ ERROR cannot be used here + | ^^ `'_` is a reserved lifetime name -error[E0262]: invalid lifetime parameter name: `'_` - --> $DIR/underscore-lifetime-binders.rs:18:8 - | -LL | fn foo<'_> //~ ERROR invalid lifetime parameter name: `'_` - | ^^ '_ is a reserved lifetime name - -error[E0262]: invalid lifetime parameter name: `'_` - --> $DIR/underscore-lifetime-binders.rs:24:21 +error[E0106]: missing lifetime specifier + --> $DIR/underscore-lifetime-binders.rs:12:17 | -LL | fn meh() -> Box Meh<'_>> //~ ERROR invalid lifetime parameter name: `'_` - | ^^ '_ is a reserved lifetime name +LL | struct Baz<'a>(&'_ &'a u8); //~ ERROR missing lifetime specifier + | ^^ expected lifetime parameter error[E0106]: missing lifetime specifier - --> $DIR/underscore-lifetime-binders.rs:24:29 + --> $DIR/underscore-lifetime-binders.rs:20:29 | -LL | fn meh() -> Box Meh<'_>> //~ ERROR invalid lifetime parameter name: `'_` - | ^^ expected lifetime parameter +LL | fn meh() -> Box Meh<'_>> //~ ERROR cannot be used here + | ^^ help: consider giving it a 'static lifetime: `'static` | = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from - = help: consider giving it a 'static lifetime error[E0106]: missing lifetime specifier - --> $DIR/underscore-lifetime-binders.rs:30:35 + --> $DIR/underscore-lifetime-binders.rs:26:35 | LL | fn foo2(_: &'_ u8, y: &'_ u8) -> &'_ u8 { y } //~ ERROR missing lifetime specifier | ^^ expected lifetime parameter | = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `_` or `y` -error: aborting due to 6 previous errors +error: aborting due to 5 previous errors -Some errors occurred: E0106, E0262. +Some errors occurred: E0106, E0637. For more information about an error, try `rustc --explain E0106`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/underscore-lifetime-elison-mismatch.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/underscore-lifetime-elison-mismatch.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/underscore-lifetime-elison-mismatch.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/underscore-lifetime-elison-mismatch.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/underscore-lifetime-elison-mismatch.rs:11:42 - | -LL | fn foo(x: &mut Vec<&'_ u8>, y: &'_ u8) { x.push(y); } //~ ERROR lifetime mismatch - | - - ^^^^^^^^^ argument requires that `'1` must outlive `'2` - | | | - | | let's call the lifetime of this reference `'1` - | let's call the lifetime of this reference `'2` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/underscore-outlives-bounds.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/underscore-outlives-bounds.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/underscore-outlives-bounds.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/underscore-outlives-bounds.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,8 @@ +// Regression test to check that `'b: '_` gets an error, because it's +// basically useless. +// +// #54902 + +trait Foo<'a> {} +impl<'b: '_> Foo<'b> for i32 {} +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/underscore-outlives-bounds.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/underscore-outlives-bounds.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/underscore-outlives-bounds.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/underscore-outlives-bounds.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0637]: `'_` cannot be used here + --> $DIR/underscore-outlives-bounds.rs:7:10 + | +LL | impl<'b: '_> Foo<'b> for i32 {} + | ^^ `'_` is a reserved lifetime name + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0637`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// revisions: rust2015 rust2018 +//[rust2018] edition:2018 + +trait WithType {} +trait WithRegion<'a> { } + +struct Foo { + t: T +} + +impl Foo +where + T: WithType<&u32> +//[rust2015]~^ ERROR `&` without an explicit lifetime name cannot be used here +//[rust2018]~^^ ERROR `&` without an explicit lifetime name cannot be used here +{ } + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2015.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2015.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2015.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2015.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0637]: `&` without an explicit lifetime name cannot be used here + --> $DIR/where-clause-inherent-impl-ampersand.rs:13:17 + | +LL | T: WithType<&u32> + | ^ explicit lifetime name needed here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0637`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2018.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2018.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2018.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-ampersand.rust2018.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0637]: `&` without an explicit lifetime name cannot be used here + --> $DIR/where-clause-inherent-impl-ampersand.rs:13:17 + | +LL | T: WithType<&u32> + | ^ explicit lifetime name needed here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0637`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,18 @@ +// revisions: rust2015 rust2018 +//[rust2018] edition:2018 + +trait WithType {} +trait WithRegion<'a> { } + +struct Foo { + t: T +} + +impl Foo +where + T: WithRegion<'_> +//[rust2015]~^ ERROR `'_` cannot be used here +//[rust2018]~^^ ERROR `'_` cannot be used here +{ } + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rust2015.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rust2015.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rust2015.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rust2015.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0637]: `'_` cannot be used here + --> $DIR/where-clause-inherent-impl-underscore.rs:13:19 + | +LL | T: WithRegion<'_> + | ^^ `'_` is a reserved lifetime name + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0637`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rust2018.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rust2018.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rust2018.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-inherent-impl-underscore.rust2018.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0637]: `'_` cannot be used here + --> $DIR/where-clause-inherent-impl-underscore.rs:13:19 + | +LL | T: WithRegion<'_> + | ^^ `'_` is a reserved lifetime name + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0637`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clauses.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clauses.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clauses.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clauses.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,7 @@ +trait Foo<'a> {} + +impl<'b: '_> Foo<'b> for i32 {} //~ ERROR `'_` cannot be used here + +impl Foo<'static> for Vec {} //~ ERROR `'_` cannot be used here + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clauses.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clauses.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clauses.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clauses.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,15 @@ +error[E0637]: `'_` cannot be used here + --> $DIR/where-clauses.rs:3:10 + | +LL | impl<'b: '_> Foo<'b> for i32 {} //~ ERROR `'_` cannot be used here + | ^^ `'_` is a reserved lifetime name + +error[E0637]: `'_` cannot be used here + --> $DIR/where-clauses.rs:5:9 + | +LL | impl Foo<'static> for Vec {} //~ ERROR `'_` cannot be used here + | ^^ `'_` is a reserved lifetime name + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0637`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// revisions: rust2015 rust2018 +//[rust2018] edition:2018 + +trait WithType {} +trait WithRegion<'a> { } + +trait Foo { } + +impl Foo for Vec +where + T: WithType<&u32> +//[rust2015]~^ ERROR `&` without an explicit lifetime name cannot be used here +//[rust2018]~^^ ERROR `&` without an explicit lifetime name cannot be used here +{ } + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2015.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2015.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2015.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2015.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0637]: `&` without an explicit lifetime name cannot be used here + --> $DIR/where-clause-trait-impl-region.rs:11:17 + | +LL | T: WithType<&u32> + | ^ explicit lifetime name needed here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0637`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2018.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2018.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2018.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-region.rust2018.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0637]: `&` without an explicit lifetime name cannot be used here + --> $DIR/where-clause-trait-impl-region.rs:11:17 + | +LL | T: WithType<&u32> + | ^ explicit lifetime name needed here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0637`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,16 @@ +// revisions: rust2015 rust2018 +//[rust2018] edition:2018 + +trait WithType {} +trait WithRegion<'a> { } + +trait Foo { } + +impl Foo for Vec +where + T: WithRegion<'_> +//[rust2015]~^ ERROR `'_` cannot be used here +//[rust2018]~^^ ERROR `'_` cannot be used here +{ } + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rust2015.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rust2015.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rust2015.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rust2015.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0637]: `'_` cannot be used here + --> $DIR/where-clause-trait-impl-underscore.rs:11:19 + | +LL | T: WithRegion<'_> + | ^^ `'_` is a reserved lifetime name + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0637`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rust2018.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rust2018.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rust2018.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/underscore-lifetime/where-clause-trait-impl-underscore.rust2018.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,9 @@ +error[E0637]: `'_` cannot be used here + --> $DIR/where-clause-trait-impl-underscore.rs:11:19 + | +LL | T: WithRegion<'_> + | ^^ `'_` is a reserved lifetime name + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0637`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/union/union-borrow-move-parent-sibling.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/union/union-borrow-move-parent-sibling.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/union/union-borrow-move-parent-sibling.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/union/union-borrow-move-parent-sibling.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ -error[E0382]: use of moved value: `u.y` +error[E0382]: use of moved value: `u` --> $DIR/union-borrow-move-parent-sibling.rs:29:13 | LL | let a = u.x.0; @@ -8,7 +8,7 @@ | = note: move occurs because `u` has type `U`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `u.y` +error[E0382]: use of moved value: `u` --> $DIR/union-borrow-move-parent-sibling.rs:41:13 | LL | let a = (u.x.0).0; @@ -18,7 +18,7 @@ | = note: move occurs because `u` has type `U`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `u.x` +error[E0382]: use of moved value: `u` --> $DIR/union-borrow-move-parent-sibling.rs:53:13 | LL | let a = *u.y; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/union-ub-fat-ptr.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/union-ub-fat-ptr.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/union-ub-fat-ptr.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/union-ub-fat-ptr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,139 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused)] - -// normalize-stderr-test "alignment \d+" -> "alignment N" -// normalize-stderr-test "offset \d+" -> "offset N" -// normalize-stderr-test "allocation \d+" -> "allocation N" -// normalize-stderr-test "size \d+" -> "size N" - -union BoolTransmute { - val: u8, - bl: bool, -} - -#[repr(C)] -#[derive(Copy, Clone)] -struct SliceRepr { - ptr: *const u8, - len: usize, -} - -#[repr(C)] -#[derive(Copy, Clone)] -struct BadSliceRepr { - ptr: *const u8, - len: &'static u8, -} - -union SliceTransmute { - repr: SliceRepr, - bad: BadSliceRepr, - slice: &'static [u8], - str: &'static str, - my_str: &'static MyStr, - my_slice: &'static MySliceBool, -} - -#[repr(C)] -#[derive(Copy, Clone)] -struct DynRepr { - ptr: *const u8, - vtable: *const u8, -} - -#[repr(C)] -#[derive(Copy, Clone)] -struct DynRepr2 { - ptr: *const u8, - vtable: *const u64, -} - -#[repr(C)] -#[derive(Copy, Clone)] -struct BadDynRepr { - ptr: *const u8, - vtable: usize, -} - -union DynTransmute { - repr: DynRepr, - repr2: DynRepr2, - bad: BadDynRepr, - rust: &'static Trait, -} - -trait Trait {} -impl Trait for bool {} - -// custom unsized type -struct MyStr(str); - -// custom unsized type with sized fields -struct MySlice(bool, T); -type MySliceBool = MySlice<[bool]>; - -// OK -const A: &str = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 1 } }.str}; -// bad str -const B: &str = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.str}; -//~^ ERROR this constant likely exhibits undefined behavior -// bad str -const C: &str = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.str}; -//~^ ERROR this constant likely exhibits undefined behavior -// bad str in user-defined unsized type -const C2: &MyStr = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.my_str}; -//~^ ERROR this constant likely exhibits undefined behavior - -// OK -const A2: &[u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 1 } }.slice}; -// bad slice -const B2: &[u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.slice}; -//~^ ERROR this constant likely exhibits undefined behavior -// bad slice -const C3: &[u8] = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.slice}; -//~^ ERROR this constant likely exhibits undefined behavior - -// bad trait object -const D: &Trait = unsafe { DynTransmute { repr: DynRepr { ptr: &92, vtable: &3 } }.rust}; -//~^ ERROR this constant likely exhibits undefined behavior -// bad trait object -const E: &Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.rust}; -//~^ ERROR this constant likely exhibits undefined behavior -// bad trait object -const F: &Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 3 } }.rust}; -//~^ ERROR this constant likely exhibits undefined behavior - -// bad data *inside* the trait object -const G: &Trait = &unsafe { BoolTransmute { val: 3 }.bl }; -//~^ ERROR this constant likely exhibits undefined behavior -// bad data *inside* the slice -const H: &[bool] = &[unsafe { BoolTransmute { val: 3 }.bl }]; -//~^ ERROR this constant likely exhibits undefined behavior - -// good MySliceBool -const I1: &MySliceBool = &MySlice(true, [false]); -// bad: sized field is not okay -const I2: &MySliceBool = &MySlice(unsafe { BoolTransmute { val: 3 }.bl }, [false]); -//~^ ERROR this constant likely exhibits undefined behavior -// bad: unsized part is not okay -const I3: &MySliceBool = &MySlice(true, [unsafe { BoolTransmute { val: 3 }.bl }]); -//~^ ERROR this constant likely exhibits undefined behavior - -// invalid UTF-8 -const J1: &str = unsafe { SliceTransmute { slice: &[0xFF] }.str }; -//~^ ERROR this constant likely exhibits undefined behavior -// invalid UTF-8 in user-defined str-like -const J2: &MyStr = unsafe { SliceTransmute { slice: &[0xFF] }.my_str }; -//~^ ERROR this constant likely exhibits undefined behavior - -fn main() { -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/union-ub-fat-ptr.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/union-ub-fat-ptr.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/union-ub-fat-ptr.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/union-ub-fat-ptr.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,115 +0,0 @@ -error[E0080]: this constant likely exhibits undefined behavior - --> $DIR/union-ub-fat-ptr.rs:87:1 - | -LL | const B: &str = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.str}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized or out-of-bounds memory at . - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior - -error[E0080]: this constant likely exhibits undefined behavior - --> $DIR/union-ub-fat-ptr.rs:90:1 - | -LL | const C: &str = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.str}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in fat pointer - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior - -error[E0080]: this constant likely exhibits undefined behavior - --> $DIR/union-ub-fat-ptr.rs:93:1 - | -LL | const C2: &MyStr = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.my_str}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in fat pointer - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior - -error[E0080]: this constant likely exhibits undefined behavior - --> $DIR/union-ub-fat-ptr.rs:99:1 - | -LL | const B2: &[u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.slice}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized or out-of-bounds memory at .[1] - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior - -error[E0080]: this constant likely exhibits undefined behavior - --> $DIR/union-ub-fat-ptr.rs:102:1 - | -LL | const C3: &[u8] = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.slice}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-integer slice length in fat pointer - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior - -error[E0080]: this constant likely exhibits undefined behavior - --> $DIR/union-ub-fat-ptr.rs:106:1 - | -LL | const D: &Trait = unsafe { DynTransmute { repr: DynRepr { ptr: &92, vtable: &3 } }.rust}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid vtable in fat pointer at . - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior - -error[E0080]: this constant likely exhibits undefined behavior - --> $DIR/union-ub-fat-ptr.rs:109:1 - | -LL | const E: &Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.rust}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered invalid vtable in fat pointer at . - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior - -error[E0080]: this constant likely exhibits undefined behavior - --> $DIR/union-ub-fat-ptr.rs:112:1 - | -LL | const F: &Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 3 } }.rust}; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-pointer vtable in fat pointer - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior - -error[E0080]: this constant likely exhibits undefined behavior - --> $DIR/union-ub-fat-ptr.rs:116:1 - | -LL | const G: &Trait = &unsafe { BoolTransmute { val: 3 }.bl }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at ., but expected something in the range 0..=1 - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior - -error[E0080]: this constant likely exhibits undefined behavior - --> $DIR/union-ub-fat-ptr.rs:119:1 - | -LL | const H: &[bool] = &[unsafe { BoolTransmute { val: 3 }.bl }]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at .[0], but expected something in the range 0..=1 - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior - -error[E0080]: this constant likely exhibits undefined behavior - --> $DIR/union-ub-fat-ptr.rs:125:1 - | -LL | const I2: &MySliceBool = &MySlice(unsafe { BoolTransmute { val: 3 }.bl }, [false]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at ..0, but expected something in the range 0..=1 - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior - -error[E0080]: this constant likely exhibits undefined behavior - --> $DIR/union-ub-fat-ptr.rs:128:1 - | -LL | const I3: &MySliceBool = &MySlice(true, [unsafe { BoolTransmute { val: 3 }.bl }]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at ..1[0], but expected something in the range 0..=1 - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior - -error[E0080]: this constant likely exhibits undefined behavior - --> $DIR/union-ub-fat-ptr.rs:132:1 - | -LL | const J1: &str = unsafe { SliceTransmute { slice: &[0xFF] }.str }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-UTF-8 data in str at . - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior - -error[E0080]: this constant likely exhibits undefined behavior - --> $DIR/union-ub-fat-ptr.rs:135:1 - | -LL | const J2: &MyStr = unsafe { SliceTransmute { slice: &[0xFF] }.my_str }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered non-UTF-8 data in str at ..0 - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior - -error: aborting due to 14 previous errors - -For more information about this error, try `rustc --explain E0080`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/unknown-lint-tool-name.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/unknown-lint-tool-name.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/unknown-lint-tool-name.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/unknown-lint-tool-name.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(tool_lints)] + #![deny(foo::bar)] //~ ERROR an unknown tool name found in scoped lint: `foo::bar` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/unknown-tool-name.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/unknown-tool-name.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/unknown-tool-name.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/unknown-tool-name.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,5 +8,5 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[foo::bar] //~ ERROR failed to resolve. Use of undeclared type or module `foo` +#[foo::bar] //~ ERROR failed to resolve: use of undeclared type or module `foo` fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/unknown-tool-name.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/unknown-tool-name.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/unknown-tool-name.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/unknown-tool-name.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ -error[E0433]: failed to resolve. Use of undeclared type or module `foo` +error[E0433]: failed to resolve: use of undeclared type or module `foo` --> $DIR/unknown-tool-name.rs:11:3 | -LL | #[foo::bar] //~ ERROR failed to resolve. Use of undeclared type or module `foo` - | ^^^ Use of undeclared type or module `foo` +LL | #[foo::bar] //~ ERROR failed to resolve: use of undeclared type or module `foo` + | ^^^ use of undeclared type or module `foo` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/unop-move-semantics.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/unop-move-semantics.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/unop-move-semantics.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/unop-move-semantics.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -21,7 +21,19 @@ LL | !*n; //~ ERROR: cannot move out of borrowed content | ^^ cannot move out of borrowed content -error: aborting due to 3 previous errors +error[E0507]: cannot move out of `*n` which is behind a `&` reference + --> $DIR/unop-move-semantics.rs:36:6 + | +LL | let n = &y; + | -- help: consider changing this to be a mutable reference: `&mut y` +... +LL | !*n; //~ ERROR: cannot move out of borrowed content + | ^^ + | | + | cannot move out of `*n` which is behind a `&` reference + | `n` is a `&` reference, so the data it refers to cannot be moved + +error: aborting due to 4 previous errors Some errors occurred: E0382, E0507. For more information about an error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/unreachable/unreachable-variant.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/unreachable/unreachable-variant.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/unreachable/unreachable-variant.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/unreachable/unreachable-variant.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ error[E0603]: module `super_sekrit` is private - --> $DIR/unreachable-variant.rs:16:14 + --> $DIR/unreachable-variant.rs:16:21 | LL | let _x = other::super_sekrit::sooper_sekrit::baz; //~ ERROR is private - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/unreachable/unwarned-match-on-never.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/unreachable/unwarned-match-on-never.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/unreachable/unwarned-match-on-never.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/unreachable/unwarned-match-on-never.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +#![deny(unreachable_code)] +#![allow(dead_code)] + +#![feature(never_type)] + +fn foo(x: !) -> bool { + // Explicit matches on the never type are unwarned. + match x {} + // But matches in unreachable code are warned. + match x {} //~ ERROR unreachable expression +} + +fn bar() { + match (return) { + () => () //~ ERROR unreachable arm + } +} + +fn main() { + return; + match () { //~ ERROR unreachable expression + () => (), + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/unreachable/unwarned-match-on-never.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/unreachable/unwarned-match-on-never.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/unreachable/unwarned-match-on-never.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/unreachable/unwarned-match-on-never.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,28 @@ +error: unreachable expression + --> $DIR/unwarned-match-on-never.rs:10:5 + | +LL | match x {} //~ ERROR unreachable expression + | ^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/unwarned-match-on-never.rs:1:9 + | +LL | #![deny(unreachable_code)] + | ^^^^^^^^^^^^^^^^ + +error: unreachable arm + --> $DIR/unwarned-match-on-never.rs:15:15 + | +LL | () => () //~ ERROR unreachable arm + | ^^ + +error: unreachable expression + --> $DIR/unwarned-match-on-never.rs:21:5 + | +LL | / match () { //~ ERROR unreachable expression +LL | | () => (), +LL | | } + | |_____^ + +error: aborting due to 3 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^^^ `core` reimported here | = note: `core` 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 +help: you can use `as` to change the binding name of the import | LL | use core as other_core; | ^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/unresolved/unresolved-import.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/unresolved/unresolved-import.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/unresolved/unresolved-import.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/unresolved/unresolved-import.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ // ignore-tidy-linelength use foo::bar; //~ ERROR unresolved import `foo` [E0432] - //~^ Maybe a missing `extern crate foo;`? + //~^ maybe a missing `extern crate foo;`? use bar::Baz as x; //~ ERROR unresolved import `bar::Baz` [E0432] //~^ no `Baz` in `bar`. Did you mean to use `Bar`? @@ -42,7 +42,7 @@ } use MyEnum::*; //~ ERROR unresolved import `MyEnum` [E0432] - //~^ Did you mean `self::MyEnum`? + //~^ did you mean `self::MyEnum`? } mod items { @@ -51,7 +51,7 @@ } use Enum::*; //~ ERROR unresolved import `Enum` [E0432] - //~^ Did you mean `self::Enum`? + //~^ did you mean `self::Enum`? fn item() {} } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/unresolved/unresolved-import.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/unresolved/unresolved-import.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/unresolved/unresolved-import.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/unresolved/unresolved-import.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -2,7 +2,7 @@ --> $DIR/unresolved-import.rs:13:5 | LL | use foo::bar; //~ ERROR unresolved import `foo` [E0432] - | ^^^ Maybe a missing `extern crate foo;`? + | ^^^ maybe a missing `extern crate foo;`? error[E0432]: unresolved import `bar::Baz` --> $DIR/unresolved-import.rs:16:5 @@ -26,13 +26,13 @@ --> $DIR/unresolved-import.rs:44:9 | LL | use MyEnum::*; //~ ERROR unresolved import `MyEnum` [E0432] - | ^^^^^^ Did you mean `self::MyEnum`? + | ^^^^^^ did you mean `self::MyEnum`? error[E0432]: unresolved import `Enum` --> $DIR/unresolved-import.rs:53:9 | LL | use Enum::*; //~ ERROR unresolved import `Enum` [E0432] - | ^^^^ Did you mean `self::Enum`? + | ^^^^ did you mean `self::Enum`? error: aborting due to 6 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/unsafe/unsafe-const-fn.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/unsafe/unsafe-const-fn.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/unsafe/unsafe-const-fn.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/unsafe/unsafe-const-fn.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,8 +10,6 @@ // A quick test of 'unsafe const fn' functionality -#![feature(min_const_fn)] - const unsafe fn dummy(v: u32) -> u32 { !v } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/unsafe/unsafe-const-fn.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/unsafe/unsafe-const-fn.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/unsafe/unsafe-const-fn.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/unsafe/unsafe-const-fn.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error[E0133]: call to unsafe function is unsafe and requires unsafe function or block - --> $DIR/unsafe-const-fn.rs:19:18 + --> $DIR/unsafe-const-fn.rs:17:18 | LL | const VAL: u32 = dummy(0xFFFF); | ^^^^^^^^^^^^^ call to unsafe function diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/unused/unused-macro-with-bad-frag-spec.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/unused/unused-macro-with-bad-frag-spec.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/unused/unused-macro-with-bad-frag-spec.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/unused/unused-macro-with-bad-frag-spec.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -4,7 +4,7 @@ LL | ($wrong:t_ty) => () //~ ERROR invalid fragment specifier `t_ty` | ^^^^^^^^^^^ | - = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `literal`, `path`, `meta`, `tt`, `item` and `vis` + = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis` error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/unused/unused-result.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/unused/unused-result.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/unused/unused-result.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/unused/unused-result.rs 2018-12-04 23:41:40.000000000 +0000 @@ -28,8 +28,8 @@ #[allow(unused_results)] fn test() { foo::(); - foo::(); //~ ERROR: unused `MustUse` which must be used - foo::(); //~ ERROR: unused `MustUseMsg` which must be used + foo::(); //~ ERROR: unused `MustUse` that must be used + foo::(); //~ ERROR: unused `MustUseMsg` that must be used //~^ NOTE: some message } @@ -42,8 +42,8 @@ fn main() { foo::(); //~ ERROR: unused result - foo::(); //~ ERROR: unused `MustUse` which must be used - foo::(); //~ ERROR: unused `MustUseMsg` which must be used + foo::(); //~ ERROR: unused `MustUse` that must be used + foo::(); //~ ERROR: unused `MustUseMsg` that must be used //~^ NOTE: some message let _ = foo::(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/unused/unused-result.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/unused/unused-result.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/unused/unused-result.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/unused/unused-result.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,7 +1,7 @@ -error: unused `MustUse` which must be used +error: unused `MustUse` that must be used --> $DIR/unused-result.rs:31:5 | -LL | foo::(); //~ ERROR: unused `MustUse` which must be used +LL | foo::(); //~ ERROR: unused `MustUse` that must be used | ^^^^^^^^^^^^^^^^^ | note: lint level defined here @@ -10,10 +10,10 @@ LL | #![deny(unused_results, unused_must_use)] | ^^^^^^^^^^^^^^^ -error: unused `MustUseMsg` which must be used +error: unused `MustUseMsg` that must be used --> $DIR/unused-result.rs:32:5 | -LL | foo::(); //~ ERROR: unused `MustUseMsg` which must be used +LL | foo::(); //~ ERROR: unused `MustUseMsg` that must be used | ^^^^^^^^^^^^^^^^^^^^ | = note: some message @@ -30,16 +30,16 @@ LL | #![deny(unused_results, unused_must_use)] | ^^^^^^^^^^^^^^ -error: unused `MustUse` which must be used +error: unused `MustUse` that must be used --> $DIR/unused-result.rs:45:5 | -LL | foo::(); //~ ERROR: unused `MustUse` which must be used +LL | foo::(); //~ ERROR: unused `MustUse` that must be used | ^^^^^^^^^^^^^^^^^ -error: unused `MustUseMsg` which must be used +error: unused `MustUseMsg` that must be used --> $DIR/unused-result.rs:46:5 | -LL | foo::(); //~ ERROR: unused `MustUseMsg` which must be used +LL | foo::(); //~ ERROR: unused `MustUseMsg` that must be used | ^^^^^^^^^^^^^^^^^^^^ | = note: some message diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-after-move-self-based-on-type.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-after-move-self-based-on-type.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-after-move-self-based-on-type.nll.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-after-move-self-based-on-type.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +error[E0382]: use of moved value: `self` + --> $DIR/use-after-move-self-based-on-type.rs:22:16 + | +LL | self.bar(); + | ---- value moved here +LL | return self.x; //~ ERROR use of moved value: `self.x` + | ^^^^^^ value used here after move + | + = note: move occurs because `self` has type `S`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0382`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-after-move-self.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-after-move-self.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-after-move-self.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-after-move-self.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ -error[E0382]: use of moved value: `*self.x` +error[E0382]: use of moved value: `self` --> $DIR/use-after-move-self.rs:20:16 | LL | self.bar(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-from-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-from-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-from-trait.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-from-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -18,11 +18,11 @@ use Foo::new; //~^ ERROR unresolved import `Foo` [E0432] -//~| Not a module `Foo` +//~| not a module `Foo` use Foo::C2; //~^ ERROR unresolved import `Foo` [E0432] -//~| Not a module `Foo` +//~| not a module `Foo` pub trait Trait { fn foo(); diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-from-trait.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-from-trait.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-from-trait.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-from-trait.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -20,13 +20,13 @@ --> $DIR/use-from-trait.rs:19:5 | LL | use Foo::new; - | ^^^ Not a module `Foo` + | ^^^ not a module `Foo` error[E0432]: unresolved import `Foo` --> $DIR/use-from-trait.rs:23:5 | LL | use Foo::C2; - | ^^^ Not a module `Foo` + | ^^^ not a module `Foo` error: aborting due to 5 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-from-trait-xc.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-from-trait-xc.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-from-trait-xc.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-from-trait-xc.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -20,19 +20,19 @@ --> $DIR/use-from-trait-xc.rs:24:24 | LL | use use_from_trait_xc::Foo::new; //~ ERROR struct `Foo` is private - | ^^^ Not a module `Foo` + | ^^^ not a module `Foo` error[E0432]: unresolved import `use_from_trait_xc::Foo` --> $DIR/use-from-trait-xc.rs:27:24 | LL | use use_from_trait_xc::Foo::C; //~ ERROR struct `Foo` is private - | ^^^ Not a module `Foo` + | ^^^ not a module `Foo` error[E0432]: unresolved import `use_from_trait_xc::Bar` --> $DIR/use-from-trait-xc.rs:30:24 | LL | use use_from_trait_xc::Bar::new as bnew; - | ^^^ Not a module `Bar` + | ^^^ not a module `Bar` error[E0432]: unresolved import `use_from_trait_xc::Baz::new` --> $DIR/use-from-trait-xc.rs:33:5 @@ -41,16 +41,16 @@ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `new` in `Baz` error[E0603]: struct `Foo` is private - --> $DIR/use-from-trait-xc.rs:24:5 + --> $DIR/use-from-trait-xc.rs:24:24 | LL | use use_from_trait_xc::Foo::new; //~ ERROR struct `Foo` is private - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ error[E0603]: struct `Foo` is private - --> $DIR/use-from-trait-xc.rs:27:5 + --> $DIR/use-from-trait-xc.rs:27:24 | LL | use use_from_trait_xc::Foo::C; //~ ERROR struct `Foo` is private - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ error: aborting due to 9 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-mod/use-mod-3.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-mod/use-mod-3.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-mod/use-mod-3.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-mod/use-mod-3.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,11 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use foo::bar::{ - self //~ ERROR module `bar` is private +use foo::bar::{ //~ ERROR module `bar` is private + self }; -use foo::bar::{ - Bar //~ ERROR module `bar` is private +use foo::bar::{ //~ ERROR module `bar` is private + Bar }; mod foo { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-mod/use-mod-3.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-mod/use-mod-3.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-mod/use-mod-3.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-mod/use-mod-3.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,14 +1,14 @@ error[E0603]: module `bar` is private - --> $DIR/use-mod-3.rs:12:5 + --> $DIR/use-mod-3.rs:11:10 | -LL | self //~ ERROR module `bar` is private - | ^^^^ +LL | use foo::bar::{ //~ ERROR module `bar` is private + | ^^^ error[E0603]: module `bar` is private - --> $DIR/use-mod-3.rs:15:5 + --> $DIR/use-mod-3.rs:14:10 | -LL | Bar //~ ERROR module `bar` is private - | ^^^ +LL | use foo::bar::{ //~ ERROR module `bar` is private + | ^^^ error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-mod/use-mod-4.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-mod/use-mod-4.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-mod/use-mod-4.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-mod/use-mod-4.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -14,7 +14,7 @@ --> $DIR/use-mod-4.rs:11:5 | LL | use foo::self; //~ ERROR unresolved import `foo` - | ^^^ Maybe a missing `extern crate foo;`? + | ^^^ maybe a missing `extern crate foo;`? error: aborting due to 3 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-mod.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-mod.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-mod.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-mod.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -23,7 +23,7 @@ | ^^^^ `bar` reimported here | = note: `bar` 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 +help: you can use `as` to change the binding name of the import | LL | self as other_bar | diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-paths-as-items.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-paths-as-items.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-paths-as-items.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-paths-as-items.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -7,7 +7,7 @@ | ^^^^^^^^ `mem` reimported here | = note: `mem` 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 +help: you can use `as` to change the binding name of the import | LL | use std::mem as other_mem; //~ ERROR the name `mem` is defined multiple times | ^^^^^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-self-type.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-self-type.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-self-type.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-self-type.rs 2018-12-04 23:41:40.000000000 +0000 @@ -14,7 +14,7 @@ fn f() {} fn g() { use Self::f; //~ ERROR unresolved import - pub(in Self::f) struct Z; //~ ERROR Use of undeclared type or module `Self` + pub(in Self::f) struct Z; //~ ERROR use of undeclared type or module `Self` } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-self-type.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-self-type.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-self-type.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-self-type.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,14 +1,14 @@ -error[E0433]: failed to resolve. Use of undeclared type or module `Self` +error[E0433]: failed to resolve: use of undeclared type or module `Self` --> $DIR/use-self-type.rs:17:16 | -LL | pub(in Self::f) struct Z; //~ ERROR Use of undeclared type or module `Self` - | ^^^^ Use of undeclared type or module `Self` +LL | pub(in Self::f) struct Z; //~ ERROR use of undeclared type or module `Self` + | ^^^^ use of undeclared type or module `Self` error[E0432]: unresolved import `Self` --> $DIR/use-self-type.rs:16:13 | LL | use Self::f; //~ ERROR unresolved import - | ^^^^ Use of undeclared type or module `Self` + | ^^^^ use of undeclared type or module `Self` error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-super-global-path.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-super-global-path.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/use/use-super-global-path.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/use/use-super-global-path.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,10 +1,10 @@ -error[E0433]: failed to resolve. global paths cannot start with `super` +error[E0433]: failed to resolve: global paths cannot start with `super` --> $DIR/use-super-global-path.rs:17:11 | LL | use ::super::{S, Z}; //~ ERROR global paths cannot start with `super` | ^^^^^ global paths cannot start with `super` -error[E0433]: failed to resolve. global paths cannot start with `super` +error[E0433]: failed to resolve: global paths cannot start with `super` --> $DIR/use-super-global-path.rs:20:15 | LL | use ::super::main; //~ ERROR global paths cannot start with `super` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-btree-invariant-types.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-btree-invariant-types.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-btree-invariant-types.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-btree-invariant-types.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/variance-btree-invariant-types.rs:16:5 - | -LL | fn iter_cov_key<'a, 'new>(v: IterMut<'a, &'static (), ()>) -> IterMut<'a, &'new (), ()> { - | ---- lifetime `'new` defined here -LL | v //~ ERROR mismatched types - | ^ returning this value requires that `'new` must outlive `'static` - -error: unsatisfied lifetime constraints - --> $DIR/variance-btree-invariant-types.rs:19:5 - | -LL | fn iter_cov_val<'a, 'new>(v: IterMut<'a, (), &'static ()>) -> IterMut<'a, (), &'new ()> { - | ---- lifetime `'new` defined here -LL | v //~ ERROR mismatched types - | ^ returning this value requires that `'new` must outlive `'static` - -error: unsatisfied lifetime constraints - --> $DIR/variance-btree-invariant-types.rs:22:5 - | -LL | fn iter_contra_key<'a, 'new>(v: IterMut<'a, &'new (), ()>) -> IterMut<'a, &'static (), ()> { - | ---- lifetime `'new` defined here -LL | v //~ ERROR mismatched types - | ^ returning this value requires that `'new` must outlive `'static` - -error: unsatisfied lifetime constraints - --> $DIR/variance-btree-invariant-types.rs:25:5 - | -LL | fn iter_contra_val<'a, 'new>(v: IterMut<'a, (), &'new ()>) -> IterMut<'a, (), &'static ()> { - | ---- lifetime `'new` defined here -LL | v //~ ERROR mismatched types - | ^ returning this value requires that `'new` must outlive `'static` - -error: unsatisfied lifetime constraints - --> $DIR/variance-btree-invariant-types.rs:30:5 - | -LL | fn occ_cov_key<'a, 'new>(v: OccupiedEntry<'a, &'static (), ()>) - | ---- lifetime `'new` defined here -LL | -> OccupiedEntry<'a, &'new (), ()> { -LL | v //~ ERROR mismatched types - | ^ returning this value requires that `'new` must outlive `'static` - -error: unsatisfied lifetime constraints - --> $DIR/variance-btree-invariant-types.rs:34:5 - | -LL | fn occ_cov_val<'a, 'new>(v: OccupiedEntry<'a, (), &'static ()>) - | ---- lifetime `'new` defined here -LL | -> OccupiedEntry<'a, (), &'new ()> { -LL | v //~ ERROR mismatched types - | ^ returning this value requires that `'new` must outlive `'static` - -error: unsatisfied lifetime constraints - --> $DIR/variance-btree-invariant-types.rs:38:5 - | -LL | fn occ_contra_key<'a, 'new>(v: OccupiedEntry<'a, &'new (), ()>) - | ---- lifetime `'new` defined here -LL | -> OccupiedEntry<'a, &'static (), ()> { -LL | v //~ ERROR mismatched types - | ^ returning this value requires that `'new` must outlive `'static` - -error: unsatisfied lifetime constraints - --> $DIR/variance-btree-invariant-types.rs:42:5 - | -LL | fn occ_contra_val<'a, 'new>(v: OccupiedEntry<'a, (), &'new ()>) - | ---- lifetime `'new` defined here -LL | -> OccupiedEntry<'a, (), &'static ()> { -LL | v //~ ERROR mismatched types - | ^ returning this value requires that `'new` must outlive `'static` - -error: unsatisfied lifetime constraints - --> $DIR/variance-btree-invariant-types.rs:47:5 - | -LL | fn vac_cov_key<'a, 'new>(v: VacantEntry<'a, &'static (), ()>) - | ---- lifetime `'new` defined here -LL | -> VacantEntry<'a, &'new (), ()> { -LL | v //~ ERROR mismatched types - | ^ returning this value requires that `'new` must outlive `'static` - -error: unsatisfied lifetime constraints - --> $DIR/variance-btree-invariant-types.rs:51:5 - | -LL | fn vac_cov_val<'a, 'new>(v: VacantEntry<'a, (), &'static ()>) - | ---- lifetime `'new` defined here -LL | -> VacantEntry<'a, (), &'new ()> { -LL | v //~ ERROR mismatched types - | ^ returning this value requires that `'new` must outlive `'static` - -error: unsatisfied lifetime constraints - --> $DIR/variance-btree-invariant-types.rs:55:5 - | -LL | fn vac_contra_key<'a, 'new>(v: VacantEntry<'a, &'new (), ()>) - | ---- lifetime `'new` defined here -LL | -> VacantEntry<'a, &'static (), ()> { -LL | v //~ ERROR mismatched types - | ^ returning this value requires that `'new` must outlive `'static` - -error: unsatisfied lifetime constraints - --> $DIR/variance-btree-invariant-types.rs:59:5 - | -LL | fn vac_contra_val<'a, 'new>(v: VacantEntry<'a, (), &'new ()>) - | ---- lifetime `'new` defined here -LL | -> VacantEntry<'a, (), &'static ()> { -LL | v //~ ERROR mismatched types - | ^ returning this value requires that `'new` must outlive `'static` - -error: aborting due to 12 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-cell-is-invariant.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-cell-is-invariant.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-cell-is-invariant.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-cell-is-invariant.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - // Test that Cell is considered invariant with respect to its // type. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-cell-is-invariant.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-cell-is-invariant.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-cell-is-invariant.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-cell-is-invariant.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,5 +1,5 @@ error[E0623]: lifetime mismatch - --> $DIR/variance-cell-is-invariant.rs:26:25 + --> $DIR/variance-cell-is-invariant.rs:24:25 | LL | fn use_<'short,'long>(c: Foo<'short>, | ----------- these two types are declared with different lifetimes... diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-contravariant-arg-object.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-contravariant-arg-object.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-contravariant-arg-object.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-contravariant-arg-object.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/variance-contravariant-arg-object.rs:24:5 - | -LL | fn get_min_from_max<'min, 'max>(v: Box>) - | ---- ---- lifetime `'max` defined here - | | - | lifetime `'min` defined here -... -LL | v //~ ERROR mismatched types - | ^ cast requires that `'min` must outlive `'max` - -error: unsatisfied lifetime constraints - --> $DIR/variance-contravariant-arg-object.rs:32:5 - | -LL | fn get_max_from_min<'min, 'max, G>(v: Box>) - | ---- ---- lifetime `'max` defined here - | | - | lifetime `'min` defined here -... -LL | v //~ ERROR mismatched types - | ^ cast requires that `'min` must outlive `'max` - -error: aborting due to 2 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-contravariant-arg-trait-match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-contravariant-arg-trait-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-contravariant-arg-trait-match.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-contravariant-arg-trait-match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - #![allow(dead_code)] // Test that even when `T` is only used in contravariant position, it diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-contravariant-arg-trait-match.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-contravariant-arg-trait-match.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-contravariant-arg-trait-match.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-contravariant-arg-trait-match.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,37 +1,37 @@ error[E0308]: mismatched types - --> $DIR/variance-contravariant-arg-trait-match.rs:25:5 + --> $DIR/variance-contravariant-arg-trait-match.rs:23:5 | LL | impls_get::() //~ ERROR mismatched types | ^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | = note: expected type `Get<&'min i32>` found type `Get<&'max i32>` -note: the lifetime 'min as defined on the function body at 22:21... - --> $DIR/variance-contravariant-arg-trait-match.rs:22:21 +note: the lifetime 'min as defined on the function body at 20:21... + --> $DIR/variance-contravariant-arg-trait-match.rs:20:21 | LL | fn get_min_from_max<'min, 'max, G>() | ^^^^ -note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 22:27 - --> $DIR/variance-contravariant-arg-trait-match.rs:22:27 +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 20:27 + --> $DIR/variance-contravariant-arg-trait-match.rs:20:27 | LL | fn get_min_from_max<'min, 'max, G>() | ^^^^ error[E0308]: mismatched types - --> $DIR/variance-contravariant-arg-trait-match.rs:33:5 + --> $DIR/variance-contravariant-arg-trait-match.rs:31:5 | LL | impls_get::() //~ ERROR mismatched types | ^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | = note: expected type `Get<&'max i32>` found type `Get<&'min i32>` -note: the lifetime 'min as defined on the function body at 28:21... - --> $DIR/variance-contravariant-arg-trait-match.rs:28:21 +note: the lifetime 'min as defined on the function body at 26:21... + --> $DIR/variance-contravariant-arg-trait-match.rs:26:21 | LL | fn get_max_from_min<'min, 'max, G>() | ^^^^ -note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 28:27 - --> $DIR/variance-contravariant-arg-trait-match.rs:28:27 +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 26:27 + --> $DIR/variance-contravariant-arg-trait-match.rs:26:27 | LL | fn get_max_from_min<'min, 'max, G>() | ^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-contravariant-self-trait-match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-contravariant-self-trait-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-contravariant-self-trait-match.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-contravariant-self-trait-match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - #![allow(dead_code)] // Test that even when `Self` is only used in contravariant position, it diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-contravariant-self-trait-match.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-contravariant-self-trait-match.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-contravariant-self-trait-match.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-contravariant-self-trait-match.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,37 +1,37 @@ error[E0308]: mismatched types - --> $DIR/variance-contravariant-self-trait-match.rs:25:5 + --> $DIR/variance-contravariant-self-trait-match.rs:23:5 | LL | impls_get::<&'min G>(); //~ ERROR mismatched types | ^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | = note: expected type `Get` found type `Get` -note: the lifetime 'min as defined on the function body at 22:21... - --> $DIR/variance-contravariant-self-trait-match.rs:22:21 +note: the lifetime 'min as defined on the function body at 20:21... + --> $DIR/variance-contravariant-self-trait-match.rs:20:21 | LL | fn get_min_from_max<'min, 'max, G>() | ^^^^ -note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 22:27 - --> $DIR/variance-contravariant-self-trait-match.rs:22:27 +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 20:27 + --> $DIR/variance-contravariant-self-trait-match.rs:20:27 | LL | fn get_min_from_max<'min, 'max, G>() | ^^^^ error[E0308]: mismatched types - --> $DIR/variance-contravariant-self-trait-match.rs:34:5 + --> $DIR/variance-contravariant-self-trait-match.rs:32:5 | LL | impls_get::<&'max G>(); //~ ERROR mismatched types | ^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | = note: expected type `Get` found type `Get` -note: the lifetime 'min as defined on the function body at 28:21... - --> $DIR/variance-contravariant-self-trait-match.rs:28:21 +note: the lifetime 'min as defined on the function body at 26:21... + --> $DIR/variance-contravariant-self-trait-match.rs:26:21 | LL | fn get_max_from_min<'min, 'max, G>() | ^^^^ -note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 28:27 - --> $DIR/variance-contravariant-self-trait-match.rs:28:27 +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 26:27 + --> $DIR/variance-contravariant-self-trait-match.rs:26:27 | LL | fn get_max_from_min<'min, 'max, G>() | ^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-covariant-arg-object.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-covariant-arg-object.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-covariant-arg-object.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-covariant-arg-object.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/variance-covariant-arg-object.rs:25:5 - | -LL | fn get_min_from_max<'min, 'max>(v: Box>) - | ---- ---- lifetime `'max` defined here - | | - | lifetime `'min` defined here -... -LL | v //~ ERROR mismatched types - | ^ cast requires that `'min` must outlive `'max` - -error: unsatisfied lifetime constraints - --> $DIR/variance-covariant-arg-object.rs:32:5 - | -LL | fn get_max_from_min<'min, 'max, G>(v: Box>) - | ---- ---- lifetime `'max` defined here - | | - | lifetime `'min` defined here -... -LL | v //~ ERROR mismatched types - | ^ cast requires that `'min` must outlive `'max` - -error: aborting due to 2 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-covariant-arg-trait-match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-covariant-arg-trait-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-covariant-arg-trait-match.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-covariant-arg-trait-match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - #![allow(dead_code)] // Test that even when `T` is only used in covariant position, it diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-covariant-arg-trait-match.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-covariant-arg-trait-match.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-covariant-arg-trait-match.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-covariant-arg-trait-match.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,37 +1,37 @@ error[E0308]: mismatched types - --> $DIR/variance-covariant-arg-trait-match.rs:26:5 + --> $DIR/variance-covariant-arg-trait-match.rs:24:5 | LL | impls_get::() //~ ERROR mismatched types | ^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | = note: expected type `Get<&'min i32>` found type `Get<&'max i32>` -note: the lifetime 'min as defined on the function body at 22:21... - --> $DIR/variance-covariant-arg-trait-match.rs:22:21 +note: the lifetime 'min as defined on the function body at 20:21... + --> $DIR/variance-covariant-arg-trait-match.rs:20:21 | LL | fn get_min_from_max<'min, 'max, G>() | ^^^^ -note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 22:27 - --> $DIR/variance-covariant-arg-trait-match.rs:22:27 +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 20:27 + --> $DIR/variance-covariant-arg-trait-match.rs:20:27 | LL | fn get_min_from_max<'min, 'max, G>() | ^^^^ error[E0308]: mismatched types - --> $DIR/variance-covariant-arg-trait-match.rs:32:5 + --> $DIR/variance-covariant-arg-trait-match.rs:30:5 | LL | impls_get::() //~ ERROR mismatched types | ^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | = note: expected type `Get<&'max i32>` found type `Get<&'min i32>` -note: the lifetime 'min as defined on the function body at 29:21... - --> $DIR/variance-covariant-arg-trait-match.rs:29:21 +note: the lifetime 'min as defined on the function body at 27:21... + --> $DIR/variance-covariant-arg-trait-match.rs:27:21 | LL | fn get_max_from_min<'min, 'max, G>() | ^^^^ -note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 29:27 - --> $DIR/variance-covariant-arg-trait-match.rs:29:27 +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 27:27 + --> $DIR/variance-covariant-arg-trait-match.rs:27:27 | LL | fn get_max_from_min<'min, 'max, G>() | ^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-covariant-self-trait-match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-covariant-self-trait-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-covariant-self-trait-match.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-covariant-self-trait-match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - #![allow(dead_code)] // Test that even when `Self` is only used in covariant position, it diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-covariant-self-trait-match.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-covariant-self-trait-match.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-covariant-self-trait-match.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-covariant-self-trait-match.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,37 +1,37 @@ error[E0308]: mismatched types - --> $DIR/variance-covariant-self-trait-match.rs:26:5 + --> $DIR/variance-covariant-self-trait-match.rs:24:5 | LL | impls_get::<&'min G>(); //~ ERROR mismatched types | ^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | = note: expected type `Get` found type `Get` -note: the lifetime 'min as defined on the function body at 22:21... - --> $DIR/variance-covariant-self-trait-match.rs:22:21 +note: the lifetime 'min as defined on the function body at 20:21... + --> $DIR/variance-covariant-self-trait-match.rs:20:21 | LL | fn get_min_from_max<'min, 'max, G>() | ^^^^ -note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 22:27 - --> $DIR/variance-covariant-self-trait-match.rs:22:27 +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 20:27 + --> $DIR/variance-covariant-self-trait-match.rs:20:27 | LL | fn get_min_from_max<'min, 'max, G>() | ^^^^ error[E0308]: mismatched types - --> $DIR/variance-covariant-self-trait-match.rs:32:5 + --> $DIR/variance-covariant-self-trait-match.rs:30:5 | LL | impls_get::<&'max G>(); //~ ERROR mismatched types | ^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | = note: expected type `Get` found type `Get` -note: the lifetime 'min as defined on the function body at 29:21... - --> $DIR/variance-covariant-self-trait-match.rs:29:21 +note: the lifetime 'min as defined on the function body at 27:21... + --> $DIR/variance-covariant-self-trait-match.rs:27:21 | LL | fn get_max_from_min<'min, 'max, G>() | ^^^^ -note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 29:27 - --> $DIR/variance-covariant-self-trait-match.rs:29:27 +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 27:27 + --> $DIR/variance-covariant-self-trait-match.rs:27:27 | LL | fn get_max_from_min<'min, 'max, G>() | ^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-invariant-arg-object.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-invariant-arg-object.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-invariant-arg-object.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-invariant-arg-object.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/variance-invariant-arg-object.rs:21:5 - | -LL | fn get_min_from_max<'min, 'max>(v: Box>) - | ---- ---- lifetime `'max` defined here - | | - | lifetime `'min` defined here -... -LL | v //~ ERROR mismatched types - | ^ cast requires that `'min` must outlive `'max` - -error: unsatisfied lifetime constraints - --> $DIR/variance-invariant-arg-object.rs:28:5 - | -LL | fn get_max_from_min<'min, 'max, G>(v: Box>) - | ---- ---- lifetime `'max` defined here - | | - | lifetime `'min` defined here -... -LL | v //~ ERROR mismatched types - | ^ cast requires that `'min` must outlive `'max` - -error: aborting due to 2 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-invariant-arg-trait-match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-invariant-arg-trait-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-invariant-arg-trait-match.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-invariant-arg-trait-match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - #![allow(dead_code)] trait Get { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-invariant-arg-trait-match.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-invariant-arg-trait-match.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-invariant-arg-trait-match.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-invariant-arg-trait-match.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,37 +1,37 @@ error[E0308]: mismatched types - --> $DIR/variance-invariant-arg-trait-match.rs:22:5 + --> $DIR/variance-invariant-arg-trait-match.rs:20:5 | LL | impls_get::() //~ ERROR mismatched types | ^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | = note: expected type `Get<&'min i32>` found type `Get<&'max i32>` -note: the lifetime 'min as defined on the function body at 19:21... - --> $DIR/variance-invariant-arg-trait-match.rs:19:21 +note: the lifetime 'min as defined on the function body at 17:21... + --> $DIR/variance-invariant-arg-trait-match.rs:17:21 | LL | fn get_min_from_max<'min, 'max, G>() | ^^^^ -note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 19:27 - --> $DIR/variance-invariant-arg-trait-match.rs:19:27 +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 17:27 + --> $DIR/variance-invariant-arg-trait-match.rs:17:27 | LL | fn get_min_from_max<'min, 'max, G>() | ^^^^ error[E0308]: mismatched types - --> $DIR/variance-invariant-arg-trait-match.rs:28:5 + --> $DIR/variance-invariant-arg-trait-match.rs:26:5 | LL | impls_get::() //~ ERROR mismatched types | ^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | = note: expected type `Get<&'max i32>` found type `Get<&'min i32>` -note: the lifetime 'min as defined on the function body at 25:21... - --> $DIR/variance-invariant-arg-trait-match.rs:25:21 +note: the lifetime 'min as defined on the function body at 23:21... + --> $DIR/variance-invariant-arg-trait-match.rs:23:21 | LL | fn get_max_from_min<'min, 'max, G>() | ^^^^ -note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 25:27 - --> $DIR/variance-invariant-arg-trait-match.rs:25:27 +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 23:27 + --> $DIR/variance-invariant-arg-trait-match.rs:23:27 | LL | fn get_max_from_min<'min, 'max, G>() | ^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-invariant-self-trait-match.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-invariant-self-trait-match.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-invariant-self-trait-match.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-invariant-self-trait-match.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-compare-mode-nll - #![allow(dead_code)] trait Get { diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-invariant-self-trait-match.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-invariant-self-trait-match.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-invariant-self-trait-match.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-invariant-self-trait-match.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,37 +1,37 @@ error[E0308]: mismatched types - --> $DIR/variance-invariant-self-trait-match.rs:22:5 + --> $DIR/variance-invariant-self-trait-match.rs:20:5 | LL | impls_get::<&'min G>(); //~ ERROR mismatched types | ^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | = note: expected type `Get` found type `Get` -note: the lifetime 'min as defined on the function body at 19:21... - --> $DIR/variance-invariant-self-trait-match.rs:19:21 +note: the lifetime 'min as defined on the function body at 17:21... + --> $DIR/variance-invariant-self-trait-match.rs:17:21 | LL | fn get_min_from_max<'min, 'max, G>() | ^^^^ -note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 19:27 - --> $DIR/variance-invariant-self-trait-match.rs:19:27 +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 17:27 + --> $DIR/variance-invariant-self-trait-match.rs:17:27 | LL | fn get_min_from_max<'min, 'max, G>() | ^^^^ error[E0308]: mismatched types - --> $DIR/variance-invariant-self-trait-match.rs:28:5 + --> $DIR/variance-invariant-self-trait-match.rs:26:5 | LL | impls_get::<&'max G>(); //~ ERROR mismatched types | ^^^^^^^^^^^^^^^^^^^^ lifetime mismatch | = note: expected type `Get` found type `Get` -note: the lifetime 'min as defined on the function body at 25:21... - --> $DIR/variance-invariant-self-trait-match.rs:25:21 +note: the lifetime 'min as defined on the function body at 23:21... + --> $DIR/variance-invariant-self-trait-match.rs:23:21 | LL | fn get_max_from_min<'min, 'max, G>() | ^^^^ -note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 25:27 - --> $DIR/variance-invariant-self-trait-match.rs:25:27 +note: ...does not necessarily outlive the lifetime 'max as defined on the function body at 23:27 + --> $DIR/variance-invariant-self-trait-match.rs:23:27 | LL | fn get_max_from_min<'min, 'max, G>() | ^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-trait-matching.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-trait-matching.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-trait-matching.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-trait-matching.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -error[E0621]: explicit lifetime required in the type of `get` - --> $DIR/variance-trait-matching.rs:34:5 - | -LL | fn get<'a, G>(get: &G) -> i32 - | -- help: add explicit lifetime `'a` to the type of `get`: `&'a G` -... -LL | pick(get, &22) //~ ERROR 34:5: 34:9: explicit lifetime required in the type of `get` [E0621] - | ^^^^^^^^^^^^^^ lifetime `'a` required - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0621`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-use-contravariant-struct-1.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-use-contravariant-struct-1.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-use-contravariant-struct-1.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-use-contravariant-struct-1.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/variance-use-contravariant-struct-1.rs:22:5 - | -LL | fn foo<'min,'max>(v: SomeStruct<&'max ()>) - | ---- ---- lifetime `'max` defined here - | | - | lifetime `'min` defined here -... -LL | v //~ ERROR mismatched types - | ^ returning this value requires that `'min` must outlive `'max` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-use-covariant-struct-1.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-use-covariant-struct-1.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-use-covariant-struct-1.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-use-covariant-struct-1.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/variance-use-covariant-struct-1.rs:20:5 - | -LL | fn foo<'min,'max>(v: SomeStruct<&'min ()>) - | ---- ---- lifetime `'max` defined here - | | - | lifetime `'min` defined here -... -LL | v //~ ERROR mismatched types - | ^ returning this value requires that `'min` must outlive `'max` - -error: aborting due to previous error - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-use-invariant-struct-1.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-use-invariant-struct-1.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/variance/variance-use-invariant-struct-1.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/variance/variance-use-invariant-struct-1.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/variance-use-invariant-struct-1.rs:22:5 - | -LL | fn foo<'min,'max>(v: SomeStruct<&'max ()>) - | ---- ---- lifetime `'max` defined here - | | - | lifetime `'min` defined here -... -LL | v //~ ERROR mismatched types - | ^ returning this value requires that `'min` must outlive `'max` - -error: unsatisfied lifetime constraints - --> $DIR/variance-use-invariant-struct-1.rs:29:5 - | -LL | fn bar<'min,'max>(v: SomeStruct<&'min ()>) - | ---- ---- lifetime `'max` defined here - | | - | lifetime `'min` defined here -... -LL | v //~ ERROR mismatched types - | ^ returning this value requires that `'min` must outlive `'max` - -error: aborting due to 2 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/variants/variant-namespacing.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/variants/variant-namespacing.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/variants/variant-namespacing.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/variants/variant-namespacing.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -8,7 +8,7 @@ | ^^^^^^^ `XStruct` reimported here | = note: `XStruct` 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 +help: you can use `as` to change the binding name of the import | LL | pub use variant_namespacing::XE::{XStruct as OtherXStruct, XTuple, XUnit}; | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ | ^^^^^^ `XTuple` reimported here | = note: `XTuple` 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 +help: you can use `as` to change the binding name of the import | LL | pub use variant_namespacing::XE::{XStruct, XTuple as OtherXTuple, XUnit}; | ^^^^^^^^^^^^^^^^^^^^^ @@ -38,7 +38,7 @@ | ^^^^^ `XUnit` reimported here | = note: `XUnit` 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 +help: you can use `as` to change the binding name of the import | LL | pub use variant_namespacing::XE::{XStruct, XTuple, XUnit as OtherXUnit}; | ^^^^^^^^^^^^^^^^^^^ @@ -53,7 +53,7 @@ | ^^^^^^ `Struct` reimported here | = note: `Struct` 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 +help: you can use `as` to change the binding name of the import | LL | pub use E::{Struct as OtherStruct, Tuple, Unit}; | ^^^^^^^^^^^^^^^^^^^^^ @@ -68,7 +68,7 @@ | ^^^^^ `Tuple` reimported here | = note: `Tuple` 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 +help: you can use `as` to change the binding name of the import | LL | pub use E::{Struct, Tuple as OtherTuple, Unit}; | ^^^^^^^^^^^^^^^^^^^ @@ -83,7 +83,7 @@ | ^^^^ `Unit` reimported here | = note: `Unit` 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 +help: you can use `as` to change the binding name of the import | LL | pub use E::{Struct, Tuple, Unit as OtherUnit}; | ^^^^^^^^^^^^^^^^^ diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/vec/vec-mut-iter-borrow.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/vec/vec-mut-iter-borrow.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/vec/vec-mut-iter-borrow.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/vec/vec-mut-iter-borrow.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -5,7 +5,7 @@ | ------- | | | first mutable borrow occurs here - | borrow used here in later iteration of loop + | first borrow used here, in later iteration of loop LL | xs.push(1) //~ ERROR cannot borrow `xs` | ^^ second mutable borrow occurs here diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/walk-struct-literal-with.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/walk-struct-literal-with.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/walk-struct-literal-with.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/walk-struct-literal-with.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,4 +1,4 @@ -error[E0382]: borrow of moved value: `start.test` +error[E0382]: borrow of moved value: `start` --> $DIR/walk-struct-literal-with.rs:26:20 | LL | let end = Mine{other_val:1, ..start.make_string_bar()}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/wf/wf-const-type.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/wf/wf-const-type.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/wf/wf-const-type.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/wf/wf-const-type.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ error[E0277]: the trait bound `NotCopy: std::marker::Copy` is not satisfied - --> $DIR/wf-const-type.rs:20:1 + --> $DIR/wf-const-type.rs:20:12 | LL | const FOO: IsCopy> = IsCopy { t: None }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `NotCopy` + | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `NotCopy` | = note: required because of the requirements on the impl of `std::marker::Copy` for `std::option::Option` note: required by `IsCopy` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/wf/wf-misc-methods-issue-28609.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/wf/wf-misc-methods-issue-28609.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/wf/wf-misc-methods-issue-28609.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/wf/wf-misc-methods-issue-28609.nll.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,111 +1,55 @@ -error[E0597]: borrowed value does not live long enough - --> $DIR/wf-misc-methods-issue-28609.rs:32:31 +error[E0515]: cannot return value referencing temporary value + --> $DIR/wf-misc-methods-issue-28609.rs:32:5 | LL | s.transmute_inherent(&mut 42) //~ ERROR does not live long enough - | ^^ temporary value does not live long enough -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 30:1... - --> $DIR/wf-misc-methods-issue-28609.rs:30:1 - | -LL | / fn return_dangling_pointer_inherent(s: S2) -> &u32 { -LL | | let s = s; -LL | | s.transmute_inherent(&mut 42) //~ ERROR does not live long enough -LL | | } - | |_^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^--^ + | | | + | | temporary value created here + | returns a value referencing data owned by the current function -error[E0597]: `four` does not live long enough - --> $DIR/wf-misc-methods-issue-28609.rs:45:19 +error[E0515]: cannot return value referencing local variable `four` + --> $DIR/wf-misc-methods-issue-28609.rs:46:5 | LL | s.bomb = Some(&four); //~ ERROR does not live long enough - | ^^^^^ borrowed value does not live long enough + | ----- `four` is borrowed here LL | &s -LL | } - | - `four` dropped here while still borrowed - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 42:1... - --> $DIR/wf-misc-methods-issue-28609.rs:42:1 - | -LL | / fn return_dangling_pointer_coerce(s: S2) -> &u32 { -LL | | let four = 4; -LL | | let mut s = s; -LL | | s.bomb = Some(&four); //~ ERROR does not live long enough -LL | | &s -LL | | } - | |_^ + | ^^ returns a value referencing data owned by the current function -error[E0597]: `four` does not live long enough - --> $DIR/wf-misc-methods-issue-28609.rs:52:19 +error[E0515]: cannot return value referencing local variable `four` + --> $DIR/wf-misc-methods-issue-28609.rs:53:5 | LL | s.bomb = Some(&four); //~ ERROR does not live long enough - | ^^^^^ borrowed value does not live long enough + | ----- `four` is borrowed here LL | &*s -LL | } - | - `four` dropped here while still borrowed - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 49:1... - --> $DIR/wf-misc-methods-issue-28609.rs:49:1 - | -LL | / fn return_dangling_pointer_unary_op(s: S2) -> &u32 { -LL | | let four = 4; -LL | | let mut s = s; -LL | | s.bomb = Some(&four); //~ ERROR does not live long enough -LL | | &*s -LL | | } - | |_^ + | ^^^ returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/wf-misc-methods-issue-28609.rs:63:15 +error[E0515]: cannot return value referencing temporary value + --> $DIR/wf-misc-methods-issue-28609.rs:63:5 | LL | s << &mut 3 //~ ERROR does not live long enough - | ^ temporary value does not live long enough -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 61:1... - --> $DIR/wf-misc-methods-issue-28609.rs:61:1 - | -LL | / fn return_dangling_pointer_binary_op(s: S2) -> &u32 { -LL | | let s = s; -LL | | s << &mut 3 //~ ERROR does not live long enough -LL | | } - | |_^ + | ^^^^^^^^^^- + | | | + | | temporary value created here + | returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/wf-misc-methods-issue-28609.rs:68:16 +error[E0515]: cannot return value referencing temporary value + --> $DIR/wf-misc-methods-issue-28609.rs:68:5 | LL | s.shl(&mut 3) //~ ERROR does not live long enough - | ^ temporary value does not live long enough -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 66:1... - --> $DIR/wf-misc-methods-issue-28609.rs:66:1 - | -LL | / fn return_dangling_pointer_method(s: S2) -> &u32 { -LL | | let s = s; -LL | | s.shl(&mut 3) //~ ERROR does not live long enough -LL | | } - | |_^ + | ^^^^^^^^^^^-^ + | | | + | | temporary value created here + | returns a value referencing data owned by the current function -error[E0597]: borrowed value does not live long enough - --> $DIR/wf-misc-methods-issue-28609.rs:73:21 +error[E0515]: cannot return value referencing temporary value + --> $DIR/wf-misc-methods-issue-28609.rs:73:5 | LL | S2::shl(s, &mut 3) //~ ERROR does not live long enough - | ^ temporary value does not live long enough -LL | } - | - temporary value only lives until here - | -note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 71:1... - --> $DIR/wf-misc-methods-issue-28609.rs:71:1 - | -LL | / fn return_dangling_pointer_ufcs(s: S2) -> &u32 { -LL | | let s = s; -LL | | S2::shl(s, &mut 3) //~ ERROR does not live long enough -LL | | } - | |_^ + | ^^^^^^^^^^^^^^^^-^ + | | | + | | temporary value created here + | returns a value referencing data owned by the current function error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0515`. diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.rs rustc-1.31.0+dfsg1+llvm/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.rs 2018-12-04 23:41:40.000000000 +0000 @@ -8,25 +8,26 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Test that an appearance of `T` in fn args or in a trait object must -// still meet the outlives bounds. Since this is a new requirement, -// this is currently only a warning, not a hard error. - #![feature(rustc_attrs)] #![allow(dead_code)] -trait Trait { } +trait Trait<'a, T> { + type Out; +} + +impl<'a, T> Trait<'a, T> for usize { + type Out = &'a fn(T); +} struct Foo<'a,T> { f: &'a fn(T), - //~^ ERROR E0309 } -struct Bar<'a,T> { - f: &'a Trait, - //~^ ERROR E0309 +trait Baz { } + +impl<'a, T> Trait<'a, T> for u32 { + type Out = &'a Baz; } -#[rustc_error] fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,30 +1,30 @@ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:21:5 + --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:19:5 | -LL | struct Foo<'a,T> { - | - help: consider adding an explicit lifetime bound `T: 'a`... -LL | f: &'a fn(T), - | ^^^^^^^^^^^^ +LL | impl<'a, T> Trait<'a, T> for usize { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | type Out = &'a fn(T); + | ^^^^^^^^^^^^^^^^^^^^^ | note: ...so that the reference type `&'a fn(T)` does not outlive the data it points at - --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:21:5 + --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:19:5 | -LL | f: &'a fn(T), - | ^^^^^^^^^^^^ +LL | type Out = &'a fn(T); + | ^^^^^^^^^^^^^^^^^^^^^ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:26:5 + --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:29:5 | -LL | struct Bar<'a,T> { - | - help: consider adding an explicit lifetime bound `T: 'a`... -LL | f: &'a Trait, - | ^^^^^^^^^^^^^^^ +LL | impl<'a, T> Trait<'a, T> for u32 { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | type Out = &'a Baz; + | ^^^^^^^^^^^^^^^^^^^^^^ | -note: ...so that the reference type `&'a (dyn Trait + 'a)` does not outlive the data it points at - --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:26:5 +note: ...so that the reference type `&'a (dyn Baz + 'a)` does not outlive the data it points at + --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:29:5 | -LL | f: &'a Trait, - | ^^^^^^^^^^^^^^^ +LL | type Out = &'a Baz; + | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/wf/wf-static-method.nll.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/wf/wf-static-method.nll.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/wf/wf-static-method.nll.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/wf/wf-static-method.nll.stderr 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -error: unsatisfied lifetime constraints - --> $DIR/wf-static-method.rs:27:9 - | -LL | impl<'a, 'b> Foo<'a, 'b, Evil<'a, 'b>> for () { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -... -LL | u //~ ERROR E0312 - | ^ returning this value requires that `'b` must outlive `'a` - -error: unsatisfied lifetime constraints - --> $DIR/wf-static-method.rs:43:9 - | -LL | impl<'a, 'b> Evil<'a, 'b> { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | fn inherent_evil(u: &'b u32) -> &'a u32 { -LL | u //~ ERROR E0312 - | ^ returning this value requires that `'b` must outlive `'a` - -error: aborting due to 2 previous errors - diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/wf/wf-static-type.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/wf/wf-static-type.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/wf/wf-static-type.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/wf/wf-static-type.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,8 +1,8 @@ error[E0277]: the trait bound `NotCopy: std::marker::Copy` is not satisfied - --> $DIR/wf-static-type.rs:20:1 + --> $DIR/wf-static-type.rs:20:13 | LL | static FOO: IsCopy> = IsCopy { t: None }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `NotCopy` + | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `NotCopy` | = note: required because of the requirements on the impl of `std::marker::Copy` for `std::option::Option` note: required by `IsCopy` diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui/xcrate/xcrate-private-by-default.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui/xcrate/xcrate-private-by-default.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui/xcrate/xcrate-private-by-default.stderr 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui/xcrate/xcrate-private-by-default.stderr 2018-12-04 23:41:41.000000000 +0000 @@ -1,62 +1,62 @@ error[E0603]: static `j` is private - --> $DIR/xcrate-private-by-default.rs:33:5 + --> $DIR/xcrate-private-by-default.rs:33:29 | LL | static_priv_by_default::j; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error[E0603]: function `k` is private - --> $DIR/xcrate-private-by-default.rs:35:5 + --> $DIR/xcrate-private-by-default.rs:35:29 | LL | static_priv_by_default::k; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error[E0603]: unit struct `l` is private - --> $DIR/xcrate-private-by-default.rs:37:5 + --> $DIR/xcrate-private-by-default.rs:37:29 | LL | static_priv_by_default::l; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error[E0603]: enum `m` is private - --> $DIR/xcrate-private-by-default.rs:39:11 + --> $DIR/xcrate-private-by-default.rs:39:35 | LL | foo::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error[E0603]: type alias `n` is private - --> $DIR/xcrate-private-by-default.rs:41:11 + --> $DIR/xcrate-private-by-default.rs:41:35 | LL | foo::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error[E0603]: module `foo` is private - --> $DIR/xcrate-private-by-default.rs:45:5 + --> $DIR/xcrate-private-by-default.rs:45:29 | LL | static_priv_by_default::foo::a; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ error[E0603]: module `foo` is private - --> $DIR/xcrate-private-by-default.rs:47:5 + --> $DIR/xcrate-private-by-default.rs:47:29 | LL | static_priv_by_default::foo::b; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ error[E0603]: module `foo` is private - --> $DIR/xcrate-private-by-default.rs:49:5 + --> $DIR/xcrate-private-by-default.rs:49:29 | LL | static_priv_by_default::foo::c; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ error[E0603]: module `foo` is private - --> $DIR/xcrate-private-by-default.rs:51:11 + --> $DIR/xcrate-private-by-default.rs:51:35 | LL | foo::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ error[E0603]: module `foo` is private - --> $DIR/xcrate-private-by-default.rs:53:11 + --> $DIR/xcrate-private-by-default.rs:53:35 | LL | foo::(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ error: aborting due to 10 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/attribute-order-restricted.rs rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/attribute-order-restricted.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/attribute-order-restricted.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/attribute-order-restricted.rs 2018-12-04 23:41:40.000000000 +0000 @@ -1,9 +1,5 @@ // aux-build:attr_proc_macro.rs -// compile-flags:--test -#![feature(test)] - -extern crate test; extern crate attr_proc_macro; use attr_proc_macro::*; @@ -15,18 +11,4 @@ #[attr_proc_macro] //~ ERROR macro attributes must be placed before `#[derive]` struct After; -#[attr_proc_macro] //~ ERROR macro attributes cannot be used together with `#[test]` or `#[bench]` -#[test] -fn test_before() {} - -#[test] -#[attr_proc_macro] //~ ERROR macro attributes cannot be used together with `#[test]` or `#[bench]` -fn test_after() {} - -#[attr_proc_macro] //~ ERROR macro attributes cannot be used together with `#[test]` or `#[bench]` -#[bench] -fn bench_before(b: &mut test::Bencher) {} - -#[bench] -#[attr_proc_macro] //~ ERROR macro attributes cannot be used together with `#[test]` or `#[bench]` -fn bench_after(b: &mut test::Bencher) {} +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/attribute-order-restricted.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/attribute-order-restricted.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/attribute-order-restricted.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/attribute-order-restricted.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,32 +1,8 @@ error: macro attributes must be placed before `#[derive]` - --> $DIR/attribute-order-restricted.rs:15:1 + --> $DIR/attribute-order-restricted.rs:11:1 | LL | #[attr_proc_macro] //~ ERROR macro attributes must be placed before `#[derive]` | ^^^^^^^^^^^^^^^^^^ -error: macro attributes cannot be used together with `#[test]` or `#[bench]` - --> $DIR/attribute-order-restricted.rs:18:1 - | -LL | #[attr_proc_macro] //~ ERROR macro attributes cannot be used together with `#[test]` or `#[bench]` - | ^^^^^^^^^^^^^^^^^^ - -error: macro attributes cannot be used together with `#[test]` or `#[bench]` - --> $DIR/attribute-order-restricted.rs:23:1 - | -LL | #[attr_proc_macro] //~ ERROR macro attributes cannot be used together with `#[test]` or `#[bench]` - | ^^^^^^^^^^^^^^^^^^ - -error: macro attributes cannot be used together with `#[test]` or `#[bench]` - --> $DIR/attribute-order-restricted.rs:26:1 - | -LL | #[attr_proc_macro] //~ ERROR macro attributes cannot be used together with `#[test]` or `#[bench]` - | ^^^^^^^^^^^^^^^^^^ - -error: macro attributes cannot be used together with `#[test]` or `#[bench]` - --> $DIR/attribute-order-restricted.rs:31:1 - | -LL | #[attr_proc_macro] //~ ERROR macro attributes cannot be used together with `#[test]` or `#[bench]` - | ^^^^^^^^^^^^^^^^^^ - -error: aborting due to 5 previous errors +error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/auxiliary/lint_group_plugin_test.rs rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/auxiliary/lint_group_plugin_test.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/auxiliary/lint_group_plugin_test.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/auxiliary/lint_group_plugin_test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,7 +12,6 @@ #![feature(plugin_registrar)] #![feature(box_syntax, rustc_private)] -#![cfg_attr(stage0, feature(macro_vis_matcher))] #![feature(macro_at_most_once_rep)] // Load rustc as a plugin to get macros diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/auxiliary/lint_plugin_test.rs rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/auxiliary/lint_plugin_test.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/auxiliary/lint_plugin_test.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/auxiliary/lint_plugin_test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -12,7 +12,6 @@ #![feature(plugin_registrar)] #![feature(box_syntax, rustc_private)] -#![cfg_attr(stage0, feature(macro_vis_matcher))] #![feature(macro_at_most_once_rep)] extern crate syntax; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/auxiliary/lint_tool_test.rs rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/auxiliary/lint_tool_test.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/auxiliary/lint_tool_test.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/auxiliary/lint_tool_test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,6 @@ #![feature(plugin_registrar)] #![feature(box_syntax, rustc_private)] -#![cfg_attr(stage0, feature(macro_vis_matcher))] #![feature(macro_at_most_once_rep)] extern crate syntax; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/custom-derive/derive-in-mod.rs rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/custom-derive/derive-in-mod.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/custom-derive/derive-in-mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/custom-derive/derive-in-mod.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,13 @@ +// compile-pass +// aux-build:plugin.rs + +extern crate plugin; + +mod inner { + use plugin::WithHelper; + + #[derive(WithHelper)] + struct S; +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,19 +1,20 @@ -error[E0659]: `helper` is ambiguous +error[E0659]: `helper` is ambiguous (derive helper attribute vs any other name) --> $DIR/helper-attr-blocked-by-import-ambig.rs:10:3 | LL | #[helper] //~ ERROR `helper` is ambiguous | ^^^^^^ ambiguous name | -note: `helper` could refer to the name defined here +note: `helper` could refer to the derive helper attribute defined here --> $DIR/helper-attr-blocked-by-import-ambig.rs:9:10 | LL | #[derive(WithHelper)] | ^^^^^^^^^^ -note: `helper` could also refer to the name imported here +note: `helper` could also refer to the attribute macro imported here --> $DIR/helper-attr-blocked-by-import-ambig.rs:7:5 | LL | use plugin::helper; | ^^^^^^^^^^^^^^ + = help: use `crate::helper` to refer to this attribute macro unambiguously error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/lifetimes.rs rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/lifetimes.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/lifetimes.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/lifetimes.rs 2018-12-04 23:41:40.000000000 +0000 @@ -10,7 +10,7 @@ // aux-build:lifetimes.rs -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate lifetimes; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/lint_tool_test.rs rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/lint_tool_test.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/lint_tool_test.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/lint_tool_test.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,40 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:lint_tool_test.rs +// ignore-stage1 +// compile-flags: --cfg foo + +#![feature(plugin)] +#![plugin(lint_tool_test)] +#![allow(dead_code)] +#![cfg_attr(foo, warn(test_lint))] +//~^ WARNING lint name `test_lint` is deprecated and may not have an effect in the future +//~^^ WARNING lint name `test_lint` is deprecated and may not have an effect in the future +#![deny(clippy_group)] +//~^ WARNING lint name `clippy_group` is deprecated and may not have an effect in the future + +fn lintme() { } //~ ERROR item is named 'lintme' + +#[allow(clippy::group)] +fn lintmetoo() {} + +#[allow(clippy::test_lint)] +pub fn main() { + fn lintme() { } + fn lintmetoo() { } //~ ERROR item is named 'lintmetoo' +} + +#[allow(test_group)] +//~^ WARNING lint name `test_group` is deprecated and may not have an effect in the future +#[deny(this_lint_does_not_exist)] //~ WARNING unknown lint: `this_lint_does_not_exist` +fn hello() { + fn lintmetoo() { } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/lint_tool_test.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/lint_tool_test.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/lint_tool_test.stderr 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/lint_tool_test.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,62 @@ +warning: lint name `test_lint` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore + --> $DIR/lint_tool_test.rs:18:23 + | +LL | #![cfg_attr(foo, warn(test_lint))] + | ^^^^^^^^^ help: change it to: `clippy::test_lint` + | + = note: #[warn(renamed_and_removed_lints)] on by default + +warning: lint name `clippy_group` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore + --> $DIR/lint_tool_test.rs:21:9 + | +LL | #![deny(clippy_group)] + | ^^^^^^^^^^^^ help: change it to: `clippy::group` + +warning: lint name `test_group` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore + --> $DIR/lint_tool_test.rs:35:9 + | +LL | #[allow(test_group)] + | ^^^^^^^^^^ help: change it to: `clippy::test_group` + +warning: unknown lint: `this_lint_does_not_exist` + --> $DIR/lint_tool_test.rs:37:8 + | +LL | #[deny(this_lint_does_not_exist)] //~ WARNING unknown lint: `this_lint_does_not_exist` + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: #[warn(unknown_lints)] on by default + +warning: lint name `test_lint` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore + --> $DIR/lint_tool_test.rs:18:23 + | +LL | #![cfg_attr(foo, warn(test_lint))] + | ^^^^^^^^^ help: change it to: `clippy::test_lint` + +error: item is named 'lintme' + --> $DIR/lint_tool_test.rs:24:1 + | +LL | fn lintme() { } //~ ERROR item is named 'lintme' + | ^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint_tool_test.rs:21:9 + | +LL | #![deny(clippy_group)] + | ^^^^^^^^^^^^ + = note: #[deny(clippy::test_lint)] implied by #[deny(clippy::group)] + +error: item is named 'lintmetoo' + --> $DIR/lint_tool_test.rs:32:5 + | +LL | fn lintmetoo() { } //~ ERROR item is named 'lintmetoo' + | ^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/lint_tool_test.rs:21:9 + | +LL | #![deny(clippy_group)] + | ^^^^^^^^^^^^ + = note: #[deny(clippy::test_group)] implied by #[deny(clippy::group)] + +error: aborting due to 2 previous errors + diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,98 +1,78 @@ -error[E0659]: `repr` is ambiguous +error[E0425]: cannot find value `NonExistent` in this scope + --> $DIR/ambiguous-builtin-attrs.rs:30:5 + | +LL | NonExistent; //~ ERROR cannot find value `NonExistent` in this scope + | ^^^^^^^^^^^ not found in this scope + +error[E0659]: `repr` is ambiguous (built-in attribute vs any other name) --> $DIR/ambiguous-builtin-attrs.rs:9:3 | LL | #[repr(C)] //~ ERROR `repr` is ambiguous | ^^^^ ambiguous name | -note: `repr` could refer to the name imported here + = note: `repr` could refer to a built-in attribute +note: `repr` could also refer to the attribute macro imported here --> $DIR/ambiguous-builtin-attrs.rs:7:5 | LL | use builtin_attrs::*; | ^^^^^^^^^^^^^^^^ -note: `repr` could also refer to the name defined here - --> $DIR/ambiguous-builtin-attrs.rs:9:3 - | -LL | #[repr(C)] //~ ERROR `repr` is ambiguous - | ^^^^ - = note: consider adding an explicit import of `repr` to disambiguate + = help: use `crate::repr` to refer to this attribute macro unambiguously -error[E0659]: `repr` is ambiguous +error[E0659]: `repr` is ambiguous (built-in attribute vs any other name) --> $DIR/ambiguous-builtin-attrs.rs:11:19 | LL | #[cfg_attr(all(), repr(C))] //~ ERROR `repr` is ambiguous | ^^^^ ambiguous name | -note: `repr` could refer to the name imported here + = note: `repr` could refer to a built-in attribute +note: `repr` could also refer to the attribute macro imported here --> $DIR/ambiguous-builtin-attrs.rs:7:5 | LL | use builtin_attrs::*; | ^^^^^^^^^^^^^^^^ -note: `repr` could also refer to the name defined here - --> $DIR/ambiguous-builtin-attrs.rs:11:19 - | -LL | #[cfg_attr(all(), repr(C))] //~ ERROR `repr` is ambiguous - | ^^^^ - = note: consider adding an explicit import of `repr` to disambiguate + = help: use `crate::repr` to refer to this attribute macro unambiguously -error[E0659]: `repr` is ambiguous +error[E0659]: `repr` is ambiguous (built-in attribute vs any other name) --> $DIR/ambiguous-builtin-attrs.rs:20:34 | LL | fn non_macro_expanded_location<#[repr(C)] T>() { //~ ERROR `repr` is ambiguous | ^^^^ ambiguous name | -note: `repr` could refer to the name imported here + = note: `repr` could refer to a built-in attribute +note: `repr` could also refer to the attribute macro imported here --> $DIR/ambiguous-builtin-attrs.rs:7:5 | LL | use builtin_attrs::*; | ^^^^^^^^^^^^^^^^ -note: `repr` could also refer to the name defined here - --> $DIR/ambiguous-builtin-attrs.rs:20:34 - | -LL | fn non_macro_expanded_location<#[repr(C)] T>() { //~ ERROR `repr` is ambiguous - | ^^^^ - = note: consider adding an explicit import of `repr` to disambiguate + = help: use `crate::repr` to refer to this attribute macro unambiguously -error[E0659]: `repr` is ambiguous +error[E0659]: `repr` is ambiguous (built-in attribute vs any other name) --> $DIR/ambiguous-builtin-attrs.rs:22:11 | LL | #[repr(C)] //~ ERROR `repr` is ambiguous | ^^^^ ambiguous name | -note: `repr` could refer to the name imported here + = note: `repr` could refer to a built-in attribute +note: `repr` could also refer to the attribute macro imported here --> $DIR/ambiguous-builtin-attrs.rs:7:5 | LL | use builtin_attrs::*; | ^^^^^^^^^^^^^^^^ -note: `repr` could also refer to the name defined here - --> $DIR/ambiguous-builtin-attrs.rs:22:11 - | -LL | #[repr(C)] //~ ERROR `repr` is ambiguous - | ^^^^ - = note: consider adding an explicit import of `repr` to disambiguate + = help: use `crate::repr` to refer to this attribute macro unambiguously -error[E0659]: `feature` is ambiguous +error[E0659]: `feature` is ambiguous (built-in attribute vs any other name) --> $DIR/ambiguous-builtin-attrs.rs:3:4 | LL | #![feature(decl_macro)] //~ ERROR `feature` is ambiguous | ^^^^^^^ ambiguous name | -note: `feature` could refer to the name imported here + = note: `feature` could refer to a built-in attribute +note: `feature` could also refer to the attribute macro imported here --> $DIR/ambiguous-builtin-attrs.rs:7:5 | LL | use builtin_attrs::*; | ^^^^^^^^^^^^^^^^ -note: `feature` could also refer to the name defined here - --> $DIR/ambiguous-builtin-attrs.rs:3:4 - | -LL | #![feature(decl_macro)] //~ ERROR `feature` is ambiguous - | ^^^^^^^ - = note: consider adding an explicit import of `feature` to disambiguate - -error[E0425]: cannot find value `NonExistent` in this scope - --> $DIR/ambiguous-builtin-attrs.rs:30:5 - | -LL | NonExistent; //~ ERROR cannot find value `NonExistent` in this scope - | ^^^^^^^^^^^ not found in this scope + = help: use `crate::feature` to refer to this attribute macro unambiguously error: aborting due to 6 previous errors diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/auxiliary/edition-imports-2015.rs rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/auxiliary/edition-imports-2015.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/auxiliary/edition-imports-2015.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/auxiliary/edition-imports-2015.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,19 @@ +// edition:2015 +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(Derive2015)] +pub fn derive_2015(_: TokenStream) -> TokenStream { + " + use import::Path; + + fn check_absolute() { + let x = ::absolute::Path; + } + ".parse().unwrap() +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/auxiliary/multispan.rs rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/auxiliary/multispan.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/auxiliary/multispan.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/auxiliary/multispan.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ // no-prefer-dynamic #![crate_type = "proc-macro"] -#![feature(proc_macro_diagnostic, proc_macro_span)] +#![feature(proc_macro_diagnostic, proc_macro_span, proc_macro_def_site)] extern crate proc_macro; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/auxiliary/three-equals.rs rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/auxiliary/three-equals.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/auxiliary/three-equals.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/auxiliary/three-equals.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ // no-prefer-dynamic #![crate_type = "proc-macro"] -#![feature(proc_macro_diagnostic, proc_macro_span)] +#![feature(proc_macro_diagnostic, proc_macro_span, proc_macro_def_site)] extern crate proc_macro; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/derive-helper-shadowing.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/derive-helper-shadowing.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/derive-helper-shadowing.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/derive-helper-shadowing.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -1,19 +1,20 @@ -error[E0659]: `my_attr` is ambiguous +error[E0659]: `my_attr` is ambiguous (derive helper attribute vs any other name) --> $DIR/derive-helper-shadowing.rs:6:3 | LL | #[my_attr] //~ ERROR `my_attr` is ambiguous | ^^^^^^^ ambiguous name | -note: `my_attr` could refer to the name defined here +note: `my_attr` could refer to the derive helper attribute defined here --> $DIR/derive-helper-shadowing.rs:7:10 | LL | #[derive(MyTrait)] | ^^^^^^^ -note: `my_attr` could also refer to the name imported here +note: `my_attr` could also refer to the attribute macro imported here --> $DIR/derive-helper-shadowing.rs:4:5 | LL | use derive_helper_shadowing::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: use `crate::my_attr` to refer to this attribute macro unambiguously error: aborting due to previous error diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/edition-imports-2018.rs rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/edition-imports-2018.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/edition-imports-2018.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/edition-imports-2018.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,24 @@ +// compile-pass +// edition:2018 +// aux-build:edition-imports-2015.rs + +#[macro_use] +extern crate edition_imports_2015; + +mod import { + pub struct Path; +} +mod absolute { + pub struct Path; +} + +mod check { + #[derive(Derive2015)] // OK + struct S; + + fn check() { + Path; + } +} + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/extern-prelude-extern-crate-proc-macro.rs rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/extern-prelude-extern-crate-proc-macro.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/extern-prelude-extern-crate-proc-macro.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/extern-prelude-extern-crate-proc-macro.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,7 @@ +// compile-pass +// edition:2018 + +extern crate proc_macro; +use proc_macro::TokenStream; // OK + +fn main() {} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/macro-use-bang.rs rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/macro-use-bang.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/macro-use-bang.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/macro-use-bang.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ // compile-pass // aux-build:bang_proc_macro.rs -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] #[macro_use] extern crate bang_proc_macro; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/multispan.rs rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/multispan.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/multispan.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/multispan.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ // aux-build:multispan.rs // ignore-stage1 -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate multispan; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/parent-source-spans.rs rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/parent-source-spans.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/parent-source-spans.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/parent-source-spans.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ // aux-build:parent-source-spans.rs // ignore-stage1 -#![feature(decl_macro, proc_macro_non_items)] +#![feature(decl_macro, proc_macro_hygiene)] extern crate parent_source_spans; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/three-equals.rs rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/three-equals.rs --- rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/three-equals.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/proc-macro/three-equals.rs 2018-12-04 23:41:40.000000000 +0000 @@ -11,7 +11,7 @@ // aux-build:three-equals.rs // ignore-stage1 -#![feature(proc_macro_non_items)] +#![feature(proc_macro_hygiene)] extern crate three_equals; diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/resolve-error.stderr rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/resolve-error.stderr --- rustc-1.30.0+dfsg1+llvm/src/test/ui-fulldeps/resolve-error.stderr 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/ui-fulldeps/resolve-error.stderr 2018-12-04 23:41:40.000000000 +0000 @@ -20,7 +20,7 @@ --> $DIR/resolve-error.rs:54:10 | LL | #[derive(attr_proc_macra)] - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ help: try: `attr_proc_macro` error: cannot find macro `FooWithLongNama!` in this scope --> $DIR/resolve-error.rs:59:5 diff -Nru rustc-1.30.0+dfsg1+llvm/src/tools/build-manifest/src/main.rs rustc-1.31.0+dfsg1+llvm/src/tools/build-manifest/src/main.rs --- rustc-1.30.0+dfsg1+llvm/src/tools/build-manifest/src/main.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/tools/build-manifest/src/main.rs 2018-12-04 23:41:41.000000000 +0000 @@ -360,6 +360,8 @@ self.package("lldb-preview", &mut manifest.pkg, TARGETS); manifest.renames.insert("rls".to_owned(), Rename { to: "rls-preview".to_owned() }); + manifest.renames.insert("rustfmt".to_owned(), Rename { to: "rustfmt-preview".to_owned() }); + manifest.renames.insert("clippy".to_owned(), Rename { to: "clippy-preview".to_owned() }); let mut pkg = Package { version: self.cached_version("rust") diff -Nru rustc-1.30.0+dfsg1+llvm/src/tools/cargotest/main.rs rustc-1.31.0+dfsg1+llvm/src/tools/cargotest/main.rs --- rustc-1.30.0+dfsg1+llvm/src/tools/cargotest/main.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/tools/cargotest/main.rs 2018-12-04 23:41:41.000000000 +0000 @@ -61,11 +61,11 @@ Test { name: "servo", repo: "https://github.com/servo/servo", - sha: "17e97b9320fdb7cdb33bbc5f4d0fde0653bbf2e4", + sha: "987e376ca7a4245dbc3e0c06e963278ee1ac92d1", lock: None, // Only test Stylo a.k.a. Quantum CSS, the parts of Servo going into Firefox. // This takes much less time to build than all of Servo and supports stable Rust. - packages: &["stylo_tests", "selectors"], + packages: &["selectors"], }, Test { name: "webrender", diff -Nru rustc-1.30.0+dfsg1+llvm/src/tools/compiletest/src/common.rs rustc-1.31.0+dfsg1+llvm/src/tools/compiletest/src/common.rs --- rustc-1.30.0+dfsg1+llvm/src/tools/compiletest/src/common.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/tools/compiletest/src/common.rs 2018-12-04 23:41:41.000000000 +0000 @@ -19,11 +19,12 @@ #[derive(Clone, Copy, PartialEq, Debug)] pub enum Mode { CompileFail, - ParseFail, RunFail, + /// This now behaves like a `ui` test that has an implict `// run-pass`. RunPass, RunPassValgrind, Pretty, + DebugInfoBoth, DebugInfoGdb, DebugInfoLldb, Codegen, @@ -54,11 +55,11 @@ fn from_str(s: &str) -> Result { match s { "compile-fail" => Ok(CompileFail), - "parse-fail" => Ok(ParseFail), "run-fail" => Ok(RunFail), "run-pass" => Ok(RunPass), "run-pass-valgrind" => Ok(RunPassValgrind), "pretty" => Ok(Pretty), + "debuginfo-both" => Ok(DebugInfoBoth), "debuginfo-lldb" => Ok(DebugInfoLldb), "debuginfo-gdb" => Ok(DebugInfoGdb), "codegen" => Ok(Codegen), @@ -77,11 +78,11 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let s = match *self { CompileFail => "compile-fail", - ParseFail => "parse-fail", RunFail => "run-fail", RunPass => "run-pass", RunPassValgrind => "run-pass-valgrind", Pretty => "pretty", + DebugInfoBoth => "debuginfo-both", DebugInfoGdb => "debuginfo-gdb", DebugInfoLldb => "debuginfo-lldb", Codegen => "codegen", @@ -204,6 +205,9 @@ /// Version of LLDB pub lldb_version: Option, + /// Whether LLDB has native rust support + pub lldb_native_rust: bool, + /// Version of LLVM pub llvm_version: Option, diff -Nru rustc-1.30.0+dfsg1+llvm/src/tools/compiletest/src/header.rs rustc-1.31.0+dfsg1+llvm/src/tools/compiletest/src/header.rs --- rustc-1.30.0+dfsg1+llvm/src/tools/compiletest/src/header.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/tools/compiletest/src/header.rs 2018-12-04 23:41:41.000000000 +0000 @@ -19,10 +19,62 @@ use extract_gdb_version; +/// Whether to ignore the test. +#[derive(Clone, Copy, PartialEq, Debug)] +pub enum Ignore { + /// Run it. + Run, + /// Ignore it totally. + Ignore, + /// Ignore only the gdb test, but run the lldb test. + IgnoreGdb, + /// Ignore only the lldb test, but run the gdb test. + IgnoreLldb, +} + +impl Ignore { + pub fn can_run_gdb(&self) -> bool { + *self == Ignore::Run || *self == Ignore::IgnoreLldb + } + + pub fn can_run_lldb(&self) -> bool { + *self == Ignore::Run || *self == Ignore::IgnoreGdb + } + + pub fn no_gdb(&self) -> Ignore { + match *self { + Ignore::Run => Ignore::IgnoreGdb, + Ignore::IgnoreGdb => Ignore::IgnoreGdb, + _ => Ignore::Ignore, + } + } + + pub fn no_lldb(&self) -> Ignore { + match *self { + Ignore::Run => Ignore::IgnoreLldb, + Ignore::IgnoreLldb => Ignore::IgnoreLldb, + _ => Ignore::Ignore, + } + } +} + +/// The result of parse_cfg_name_directive. +#[derive(Clone, Copy, PartialEq, Debug)] +enum ParsedNameDirective { + /// No match. + NoMatch, + /// Match. + Match, + /// Mode was DebugInfoBoth and this matched gdb. + MatchGdb, + /// Mode was DebugInfoBoth and this matched lldb. + MatchLldb, +} + /// Properties which must be known very early, before actually running /// the test. pub struct EarlyProps { - pub ignore: bool, + pub ignore: Ignore, pub should_fail: bool, pub aux: Vec, pub revisions: Vec, @@ -31,20 +83,55 @@ impl EarlyProps { pub fn from_file(config: &Config, testfile: &Path) -> Self { let mut props = EarlyProps { - ignore: false, + ignore: Ignore::Run, should_fail: false, aux: Vec::new(), revisions: vec![], }; + if config.mode == common::DebugInfoBoth { + if config.lldb_python_dir.is_none() { + props.ignore = props.ignore.no_lldb(); + } + if config.gdb_version.is_none() { + props.ignore = props.ignore.no_gdb(); + } + } + iter_header(testfile, None, &mut |ln| { // we should check if any only- exists and if it exists // and does not matches the current platform, skip the test - props.ignore = props.ignore || config.parse_cfg_name_directive(ln, "ignore") - || (config.has_cfg_prefix(ln, "only") - && !config.parse_cfg_name_directive(ln, "only")) - || ignore_gdb(config, ln) || ignore_lldb(config, ln) - || ignore_llvm(config, ln); + if props.ignore != Ignore::Ignore { + props.ignore = match config.parse_cfg_name_directive(ln, "ignore") { + ParsedNameDirective::Match => Ignore::Ignore, + ParsedNameDirective::NoMatch => props.ignore, + ParsedNameDirective::MatchGdb => props.ignore.no_gdb(), + ParsedNameDirective::MatchLldb => props.ignore.no_lldb(), + }; + + if config.has_cfg_prefix(ln, "only") { + props.ignore = match config.parse_cfg_name_directive(ln, "only") { + ParsedNameDirective::Match => props.ignore, + ParsedNameDirective::NoMatch => Ignore::Ignore, + ParsedNameDirective::MatchLldb => props.ignore.no_gdb(), + ParsedNameDirective::MatchGdb => props.ignore.no_lldb(), + }; + } + + if ignore_llvm(config, ln) { + props.ignore = Ignore::Ignore; + } + } + + if (config.mode == common::DebugInfoGdb || config.mode == common::DebugInfoBoth) && + props.ignore.can_run_gdb() && ignore_gdb(config, ln) { + props.ignore = props.ignore.no_gdb(); + } + + if (config.mode == common::DebugInfoLldb || config.mode == common::DebugInfoBoth) && + props.ignore.can_run_lldb() && ignore_lldb(config, ln) { + props.ignore = props.ignore.no_lldb(); + } if let Some(s) = config.parse_aux_build(ln) { props.aux.push(s); @@ -60,10 +147,6 @@ return props; fn ignore_gdb(config: &Config, line: &str) -> bool { - if config.mode != common::DebugInfoGdb { - return false; - } - if let Some(actual_version) = config.gdb_version { if line.starts_with("min-gdb-version") { let (start_ver, end_ver) = extract_gdb_version_range(line); @@ -120,10 +203,6 @@ } fn ignore_lldb(config: &Config, line: &str) -> bool { - if config.mode != common::DebugInfoLldb { - return false; - } - if let Some(ref actual_version) = config.lldb_version { if line.starts_with("min-lldb-version") { let min_version = line.trim_right() @@ -133,6 +212,8 @@ // Ignore if actual version is smaller the minimum required // version lldb_version_to_int(actual_version) < lldb_version_to_int(min_version) + } else if line.starts_with("rust-lldb") && !config.lldb_native_rust { + true } else { false } @@ -199,6 +280,10 @@ pub force_host: bool, // Check stdout for error-pattern output as well as stderr pub check_stdout: bool, + // For UI tests, allows compiler to generate arbitrary output to stdout + pub dont_check_compiler_stdout: bool, + // For UI tests, allows compiler to generate arbitrary output to stderr + pub dont_check_compiler_stderr: bool, // Don't force a --crate-type=dylib flag on the command line pub no_prefer_dynamic: bool, // Run --pretty expanded when running pretty printing tests @@ -249,6 +334,8 @@ build_aux_docs: false, force_host: false, check_stdout: false, + dont_check_compiler_stdout: false, + dont_check_compiler_stderr: false, no_prefer_dynamic: false, pretty_expanded: false, pretty_mode: "normal".to_string(), @@ -327,6 +414,14 @@ self.check_stdout = config.parse_check_stdout(ln); } + if !self.dont_check_compiler_stdout { + self.dont_check_compiler_stdout = config.parse_dont_check_compiler_stdout(ln); + } + + if !self.dont_check_compiler_stderr { + self.dont_check_compiler_stderr = config.parse_dont_check_compiler_stderr(ln); + } + if !self.no_prefer_dynamic { self.no_prefer_dynamic = config.parse_no_prefer_dynamic(ln); } @@ -510,6 +605,14 @@ self.parse_name_directive(line, "check-stdout") } + fn parse_dont_check_compiler_stdout(&self, line: &str) -> bool { + self.parse_name_directive(line, "dont-check-compiler-stdout") + } + + fn parse_dont_check_compiler_stderr(&self, line: &str) -> bool { + self.parse_name_directive(line, "dont-check-compiler-stderr") + } + fn parse_no_prefer_dynamic(&self, line: &str) -> bool { self.parse_name_directive(line, "no-prefer-dynamic") } @@ -580,7 +683,7 @@ } fn parse_custom_normalization(&self, mut line: &str, prefix: &str) -> Option<(String, String)> { - if self.parse_cfg_name_directive(line, prefix) { + if self.parse_cfg_name_directive(line, prefix) == ParsedNameDirective::Match { let from = match parse_normalization_string(&mut line) { Some(s) => s, None => return None, @@ -596,35 +699,59 @@ } /// Parses a name-value directive which contains config-specific information, e.g. `ignore-x86` - /// or `normalize-stderr-32bit`. Returns `true` if the line matches it. - fn parse_cfg_name_directive(&self, line: &str, prefix: &str) -> bool { + /// or `normalize-stderr-32bit`. + fn parse_cfg_name_directive(&self, line: &str, prefix: &str) -> ParsedNameDirective { if line.starts_with(prefix) && line.as_bytes().get(prefix.len()) == Some(&b'-') { let name = line[prefix.len() + 1..] .split(&[':', ' '][..]) .next() .unwrap(); - name == "test" || + if name == "test" || util::matches_os(&self.target, name) || // target name == util::get_arch(&self.target) || // architecture name == util::get_pointer_width(&self.target) || // pointer width name == self.stage_id.split('-').next().unwrap() || // stage Some(name) == util::get_env(&self.target) || // env - match self.mode { - common::DebugInfoGdb => name == "gdb", - common::DebugInfoLldb => name == "lldb", - common::Pretty => name == "pretty", - _ => false, - } || (self.target != self.host && name == "cross-compile") || match self.compare_mode { Some(CompareMode::Nll) => name == "compare-mode-nll", Some(CompareMode::Polonius) => name == "compare-mode-polonius", None => false, } || - (cfg!(debug_assertions) && name == "debug") + (cfg!(debug_assertions) && name == "debug") { + ParsedNameDirective::Match + } else { + match self.mode { + common::DebugInfoBoth => { + if name == "gdb" { + ParsedNameDirective::MatchGdb + } else if name == "lldb" { + ParsedNameDirective::MatchLldb + } else { + ParsedNameDirective::NoMatch + } + }, + common::DebugInfoGdb => if name == "gdb" { + ParsedNameDirective::Match + } else { + ParsedNameDirective::NoMatch + }, + common::DebugInfoLldb => if name == "lldb" { + ParsedNameDirective::Match + } else { + ParsedNameDirective::NoMatch + }, + common::Pretty => if name == "pretty" { + ParsedNameDirective::Match + } else { + ParsedNameDirective::NoMatch + }, + _ => ParsedNameDirective::NoMatch, + } + } } else { - false + ParsedNameDirective::NoMatch } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/tools/compiletest/src/main.rs rustc-1.31.0+dfsg1+llvm/src/tools/compiletest/src/main.rs --- rustc-1.30.0+dfsg1+llvm/src/tools/compiletest/src/main.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/tools/compiletest/src/main.rs 2018-12-04 23:41:41.000000000 +0000 @@ -32,7 +32,7 @@ use common::CompareMode; use common::{expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS}; use common::{Config, TestPaths}; -use common::{DebugInfoGdb, DebugInfoLldb, Mode, Pretty}; +use common::{DebugInfoBoth, DebugInfoGdb, DebugInfoLldb, Mode, Pretty}; use filetime::FileTime; use getopts::Options; use std::env; @@ -44,7 +44,7 @@ use test::ColorConfig; use util::logv; -use self::header::EarlyProps; +use self::header::{EarlyProps, Ignore}; pub mod common; pub mod errors; @@ -139,7 +139,7 @@ "", "mode", "which sort of compile tests to run", - "(compile-fail|parse-fail|run-fail|run-pass|\ + "(compile-fail|run-fail|run-pass|\ run-pass-valgrind|pretty|debug-info|incremental|mir-opt)", ) .optflag("", "ignored", "run tests marked as ignored") @@ -278,7 +278,11 @@ } } - let (gdb, gdb_version, gdb_native_rust) = analyze_gdb(matches.opt_str("gdb")); + let target = opt_str2(matches.opt_str("target")); + let android_cross_path = opt_path(matches, "android-cross-path"); + let (gdb, gdb_version, gdb_native_rust) = analyze_gdb(matches.opt_str("gdb"), &target, + &android_cross_path); + let (lldb_version, lldb_native_rust) = extract_lldb_version(matches.opt_str("lldb-version")); let color = match matches.opt_str("color").as_ref().map(|x| &**x) { Some("auto") | None => ColorConfig::AutoColor, @@ -318,15 +322,16 @@ runtool: matches.opt_str("runtool"), host_rustcflags: matches.opt_str("host-rustcflags"), target_rustcflags: matches.opt_str("target-rustcflags"), - target: opt_str2(matches.opt_str("target")), + target: target, host: opt_str2(matches.opt_str("host")), gdb, gdb_version, gdb_native_rust, - lldb_version: extract_lldb_version(matches.opt_str("lldb-version")), + lldb_version, + lldb_native_rust, llvm_version: matches.opt_str("llvm-version"), system_llvm: matches.opt_present("system-llvm"), - android_cross_path: opt_path(matches, "android-cross-path"), + android_cross_path: android_cross_path, adb_path: opt_str2(matches.opt_str("adb-path")), adb_test_dir: opt_str2(matches.opt_str("adb-test-dir")), adb_device_status: opt_str2(matches.opt_str("target")).contains("android") @@ -420,7 +425,7 @@ pub fn run_tests(config: &Config) { if config.target.contains("android") { - if let DebugInfoGdb = config.mode { + if config.mode == DebugInfoGdb || config.mode == DebugInfoBoth { println!( "{} debug-info test uses tcp 5039 port.\ please reserve it", @@ -438,7 +443,9 @@ } match config.mode { - DebugInfoLldb => { + // Note that we don't need to emit the gdb warning when + // DebugInfoBoth, so it is ok to list that here. + DebugInfoBoth | DebugInfoLldb => { if let Some(lldb_version) = config.lldb_version.as_ref() { if is_blacklisted_lldb_version(&lldb_version[..]) { println!( @@ -642,15 +649,18 @@ .into_iter() .map(|revision| { // Debugging emscripten code doesn't make sense today - let ignore = early_props.ignore + let ignore = early_props.ignore == Ignore::Ignore || !up_to_date( config, testpaths, &early_props, revision.map(|s| s.as_str()), ) - || (config.mode == DebugInfoGdb || config.mode == DebugInfoLldb) - && config.target.contains("emscripten"); + || ((config.mode == DebugInfoBoth || + config.mode == DebugInfoGdb || config.mode == DebugInfoLldb) + && config.target.contains("emscripten")) + || (config.mode == DebugInfoGdb && !early_props.ignore.can_run_gdb()) + || (config.mode == DebugInfoLldb && !early_props.ignore.can_run_lldb()); test::TestDescAndFn { desc: test::TestDesc { name: make_test_name(config, testpaths, revision), @@ -658,7 +668,7 @@ should_panic, allow_fail: false, }, - testfn: make_test_closure(config, testpaths, revision), + testfn: make_test_closure(config, early_props.ignore, testpaths, revision), } }) .collect() @@ -769,10 +779,21 @@ fn make_test_closure( config: &Config, + ignore: Ignore, testpaths: &TestPaths, revision: Option<&String>, ) -> test::TestFn { - let config = config.clone(); + let mut config = config.clone(); + if config.mode == DebugInfoBoth { + // If both gdb and lldb were ignored, then the test as a whole + // would be ignored. + if !ignore.can_run_gdb() { + config.mode = DebugInfoLldb; + } else if !ignore.can_run_lldb() { + config.mode = DebugInfoGdb; + } + } + let testpaths = testpaths.clone(); let revision = revision.cloned(); test::DynTestFn(Box::new(move || { @@ -780,8 +801,18 @@ })) } +/// Returns true if the given target is an Android target for the +/// purposes of GDB testing. +fn is_android_gdb_target(target: &String) -> bool { + match &target[..] { + "arm-linux-androideabi" | "armv7-linux-androideabi" | "aarch64-linux-android" => true, + _ => false, + } +} + /// Returns (Path to GDB, GDB Version, GDB has Rust Support) -fn analyze_gdb(gdb: Option) -> (Option, Option, bool) { +fn analyze_gdb(gdb: Option, target: &String, android_cross_path: &PathBuf) + -> (Option, Option, bool) { #[cfg(not(windows))] const GDB_FALLBACK: &str = "gdb"; #[cfg(windows)] @@ -789,14 +820,27 @@ const MIN_GDB_WITH_RUST: u32 = 7011010; + let fallback_gdb = || { + if is_android_gdb_target(target) { + let mut gdb_path = match android_cross_path.to_str() { + Some(x) => x.to_owned(), + None => panic!("cannot find android cross path"), + }; + gdb_path.push_str("/bin/gdb"); + gdb_path + } else { + GDB_FALLBACK.to_owned() + } + }; + let gdb = match gdb { - None => GDB_FALLBACK, - Some(ref s) if s.is_empty() => GDB_FALLBACK, // may be empty if configure found no gdb - Some(ref s) => s, + None => fallback_gdb(), + Some(ref s) if s.is_empty() => fallback_gdb(), // may be empty if configure found no gdb + Some(ref s) => s.to_owned(), }; let mut version_line = None; - if let Ok(output) = Command::new(gdb).arg("--version").output() { + if let Ok(output) = Command::new(&gdb).arg("--version").output() { if let Some(first_line) = String::from_utf8_lossy(&output.stdout).lines().next() { version_line = Some(first_line.to_string()); } @@ -809,7 +853,7 @@ let gdb_native_rust = version.map_or(false, |v| v >= MIN_GDB_WITH_RUST); - (Some(gdb.to_owned()), version, gdb_native_rust) + (Some(gdb), version, gdb_native_rust) } fn extract_gdb_version(full_version_line: &str) -> Option { @@ -880,17 +924,27 @@ None } -fn extract_lldb_version(full_version_line: Option) -> Option { +/// Returns (LLDB version, LLDB is rust-enabled) +fn extract_lldb_version(full_version_line: Option) -> (Option, bool) { // Extract the major LLDB version from the given version string. // LLDB version strings are different for Apple and non-Apple platforms. - // At the moment, this function only supports the Apple variant, which looks - // like this: + // The Apple variant looks like this: // // LLDB-179.5 (older versions) // lldb-300.2.51 (new versions) // // We are only interested in the major version number, so this function // will return `Some("179")` and `Some("300")` respectively. + // + // Upstream versions look like: + // lldb version 6.0.1 + // + // There doesn't seem to be a way to correlate the Apple version + // with the upstream version, and since the tests were originally + // written against Apple versions, we make a fake Apple version by + // multiplying the first number by 100. This is a hack, but + // normally fine because the only non-Apple version we test is + // rust-enabled. if let Some(ref full_version_line) = full_version_line { if !full_version_line.trim().is_empty() { @@ -925,12 +979,22 @@ .take_while(|c| c.is_digit(10)) .collect::(); if !vers.is_empty() { - return Some(vers); + return (Some(vers), full_version_line.contains("rust-enabled")); + } + } + + if full_version_line.starts_with("lldb version ") { + let vers = full_version_line[13..] + .chars() + .take_while(|c| c.is_digit(10)) + .collect::(); + if !vers.is_empty() { + return (Some(vers + "00"), full_version_line.contains("rust-enabled")); } } } } - None + (None, false) } fn is_blacklisted_lldb_version(version: &str) -> bool { diff -Nru rustc-1.30.0+dfsg1+llvm/src/tools/compiletest/src/runtest.rs rustc-1.31.0+dfsg1+llvm/src/tools/compiletest/src/runtest.rs --- rustc-1.30.0+dfsg1+llvm/src/tools/compiletest/src/runtest.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/tools/compiletest/src/runtest.rs 2018-12-04 23:41:41.000000000 +0000 @@ -11,8 +11,8 @@ use common::CompareMode; use common::{expected_output_path, UI_EXTENSIONS, UI_FIXED, UI_STDERR, UI_STDOUT}; use common::{output_base_dir, output_base_name, output_testname_unique}; -use common::{Codegen, CodegenUnits, DebugInfoGdb, DebugInfoLldb, Rustdoc}; -use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind}; +use common::{Codegen, CodegenUnits, DebugInfoBoth, DebugInfoGdb, DebugInfoLldb, Rustdoc}; +use common::{CompileFail, Pretty, RunFail, RunPass, RunPassValgrind}; use common::{Config, TestPaths}; use common::{Incremental, MirOpt, RunMake, Ui}; use diff; @@ -38,6 +38,7 @@ use std::str; use extract_gdb_version; +use is_android_gdb_target; #[cfg(windows)] fn disable_error_reporting R, R>(f: F) -> R { @@ -224,6 +225,20 @@ pub fn compute_stamp_hash(config: &Config) -> String { let mut hash = DefaultHasher::new(); config.stage_id.hash(&mut hash); + + if config.mode == DebugInfoGdb || config.mode == DebugInfoBoth { + match config.gdb { + None => env::var_os("PATH").hash(&mut hash), + Some(ref s) if s.is_empty() => env::var_os("PATH").hash(&mut hash), + Some(ref s) => s.hash(&mut hash), + }; + } + + if config.mode == DebugInfoLldb || config.mode == DebugInfoBoth { + env::var_os("PATH").hash(&mut hash); + env::var_os("PYTHONPATH").hash(&mut hash); + } + format!("{:x}", hash.finish()) } @@ -240,16 +255,24 @@ breakpoint_lines: Vec, } +enum ReadFrom { + Path, + Stdin(String), +} + impl<'test> TestCx<'test> { /// Code executed for each revision in turn (or, if there are no /// revisions, exactly once, with revision == None). fn run_revision(&self) { match self.config.mode { - CompileFail | ParseFail => self.run_cfail_test(), + CompileFail => self.run_cfail_test(), RunFail => self.run_rfail_test(), - RunPass => self.run_rpass_test(), RunPassValgrind => self.run_valgrind_test(), Pretty => self.run_pretty_test(), + DebugInfoBoth => { + self.run_debuginfo_gdb_test(); + self.run_debuginfo_lldb_test(); + }, DebugInfoGdb => self.run_debuginfo_gdb_test(), DebugInfoLldb => self.run_debuginfo_lldb_test(), Codegen => self.run_codegen_test(), @@ -257,13 +280,43 @@ CodegenUnits => self.run_codegen_units_test(), Incremental => self.run_incremental_test(), RunMake => self.run_rmake_test(), - Ui => self.run_ui_test(), + RunPass | Ui => self.run_ui_test(), MirOpt => self.run_mir_opt_test(), } } + fn should_run_successfully(&self) -> bool { + let run_pass = match self.config.mode { + RunPass => true, + Ui => self.props.run_pass, + _ => unimplemented!(), + }; + return run_pass && !self.props.skip_codegen; + } + + fn should_compile_successfully(&self) -> bool { + match self.config.mode { + CompileFail => self.props.compile_pass, + RunPass => true, + Ui => self.props.compile_pass, + Incremental => { + let revision = self.revision + .expect("incremental tests require a list of revisions"); + if revision.starts_with("rpass") || revision.starts_with("rfail") { + true + } else if revision.starts_with("cfail") { + // FIXME: would be nice if incremental revs could start with "cpass" + self.props.compile_pass + } else { + panic!("revision name must begin with rpass, rfail, or cfail"); + } + } + mode => panic!("unimplemented for mode {:?}", mode), + } + } + fn check_if_test_should_compile(&self, proc_res: &ProcRes) { - if self.props.compile_pass { + if self.should_compile_successfully() { if !proc_res.status.success() { self.fatal_proc_rec("test compilation failed although it shouldn't!", proc_res); } @@ -421,8 +474,14 @@ round, self.revision ), ); - let proc_res = self.print_source(srcs[round].to_owned(), &self.props.pretty_mode); + let read_from = if round == 0 { + ReadFrom::Path + } else { + ReadFrom::Stdin(srcs[round].to_owned()) + }; + let proc_res = self.print_source(read_from, + &self.props.pretty_mode); if !proc_res.status.success() { self.fatal_proc_rec( &format!( @@ -477,7 +536,7 @@ } // additionally, run `--pretty expanded` and try to build it. - let proc_res = self.print_source(srcs[round].clone(), "expanded"); + let proc_res = self.print_source(ReadFrom::Path, "expanded"); if !proc_res.status.success() { self.fatal_proc_rec("pretty-printing (expanded) failed", &proc_res); } @@ -495,12 +554,16 @@ } } - fn print_source(&self, src: String, pretty_type: &str) -> ProcRes { + fn print_source(&self, read_from: ReadFrom, pretty_type: &str) -> ProcRes { let aux_dir = self.aux_output_dir_name(); + let input: &str = match read_from { + ReadFrom::Stdin(_) => "-", + ReadFrom::Path => self.testpaths.file.to_str().unwrap(), + }; let mut rustc = Command::new(&self.config.rustc_path); rustc - .arg("-") + .arg(input) .args(&["-Z", &format!("unpretty={}", pretty_type)]) .args(&["--target", &self.config.target]) .arg("-L") @@ -509,11 +572,16 @@ .args(&self.props.compile_flags) .envs(self.props.exec_env.clone()); + let src = match read_from { + ReadFrom::Stdin(src) => Some(src), + ReadFrom::Path => None + }; + self.compose_and_run( rustc, self.config.compile_lib_path.to_str().unwrap(), Some(aux_dir.to_str().unwrap()), - Some(src), + src, ) } @@ -577,6 +645,7 @@ let config = Config { target_rustcflags: self.cleanup_debug_info_options(&self.config.target_rustcflags), host_rustcflags: self.cleanup_debug_info_options(&self.config.host_rustcflags), + mode: DebugInfoGdb, ..self.config.clone() }; @@ -617,222 +686,217 @@ let exe_file = self.make_exe_name(); let debugger_run_result; - match &*self.config.target { - "arm-linux-androideabi" | "armv7-linux-androideabi" | "aarch64-linux-android" => { - cmds = cmds.replace("run", "continue"); - - let tool_path = match self.config.android_cross_path.to_str() { - Some(x) => x.to_owned(), - None => self.fatal("cannot find android cross path"), - }; + if is_android_gdb_target(&self.config.target) { + cmds = cmds.replace("run", "continue"); - // write debugger script - let mut script_str = String::with_capacity(2048); - script_str.push_str(&format!("set charset {}\n", Self::charset())); - script_str.push_str(&format!("set sysroot {}\n", tool_path)); - script_str.push_str(&format!("file {}\n", exe_file.to_str().unwrap())); - script_str.push_str("target remote :5039\n"); - script_str.push_str(&format!( - "set solib-search-path \ - ./{}/stage2/lib/rustlib/{}/lib/\n", - self.config.host, self.config.target - )); - for line in &breakpoint_lines { - script_str.push_str( - &format!( - "break {:?}:{}\n", - self.testpaths.file.file_name().unwrap().to_string_lossy(), - *line - )[..], - ); - } - script_str.push_str(&cmds); - script_str.push_str("\nquit\n"); + let tool_path = match self.config.android_cross_path.to_str() { + Some(x) => x.to_owned(), + None => self.fatal("cannot find android cross path"), + }; - debug!("script_str = {}", script_str); - self.dump_output_file(&script_str, "debugger.script"); + // write debugger script + let mut script_str = String::with_capacity(2048); + script_str.push_str(&format!("set charset {}\n", Self::charset())); + script_str.push_str(&format!("set sysroot {}\n", tool_path)); + script_str.push_str(&format!("file {}\n", exe_file.to_str().unwrap())); + script_str.push_str("target remote :5039\n"); + script_str.push_str(&format!( + "set solib-search-path \ + ./{}/stage2/lib/rustlib/{}/lib/\n", + self.config.host, self.config.target + )); + for line in &breakpoint_lines { + script_str.push_str( + &format!( + "break {:?}:{}\n", + self.testpaths.file.file_name().unwrap().to_string_lossy(), + *line + )[..], + ); + } + script_str.push_str(&cmds); + script_str.push_str("\nquit\n"); - let adb_path = &self.config.adb_path; + debug!("script_str = {}", script_str); + self.dump_output_file(&script_str, "debugger.script"); - Command::new(adb_path) - .arg("push") - .arg(&exe_file) - .arg(&self.config.adb_test_dir) - .status() - .expect(&format!("failed to exec `{:?}`", adb_path)); - - Command::new(adb_path) - .args(&["forward", "tcp:5039", "tcp:5039"]) - .status() - .expect(&format!("failed to exec `{:?}`", adb_path)); - - let adb_arg = format!( - "export LD_LIBRARY_PATH={}; \ - gdbserver{} :5039 {}/{}", - self.config.adb_test_dir.clone(), - if self.config.target.contains("aarch64") { - "64" - } else { - "" - }, - self.config.adb_test_dir.clone(), - exe_file.file_name().unwrap().to_str().unwrap() - ); + let adb_path = &self.config.adb_path; - debug!("adb arg: {}", adb_arg); - let mut adb = Command::new(adb_path) - .args(&["shell", &adb_arg]) - .stdout(Stdio::piped()) - .stderr(Stdio::inherit()) - .spawn() - .expect(&format!("failed to exec `{:?}`", adb_path)); - - // Wait for the gdbserver to print out "Listening on port ..." - // at which point we know that it's started and then we can - // execute the debugger below. - let mut stdout = BufReader::new(adb.stdout.take().unwrap()); - let mut line = String::new(); - loop { - line.truncate(0); - stdout.read_line(&mut line).unwrap(); - if line.starts_with("Listening on port 5039") { - break; - } - } - drop(stdout); + Command::new(adb_path) + .arg("push") + .arg(&exe_file) + .arg(&self.config.adb_test_dir) + .status() + .expect(&format!("failed to exec `{:?}`", adb_path)); + + Command::new(adb_path) + .args(&["forward", "tcp:5039", "tcp:5039"]) + .status() + .expect(&format!("failed to exec `{:?}`", adb_path)); + + let adb_arg = format!( + "export LD_LIBRARY_PATH={}; \ + gdbserver{} :5039 {}/{}", + self.config.adb_test_dir.clone(), + if self.config.target.contains("aarch64") { + "64" + } else { + "" + }, + self.config.adb_test_dir.clone(), + exe_file.file_name().unwrap().to_str().unwrap() + ); - let debugger_script = self.make_out_name("debugger.script"); - // FIXME (#9639): This needs to handle non-utf8 paths - let debugger_opts = vec![ - "-quiet".to_owned(), - "-batch".to_owned(), - "-nx".to_owned(), - format!("-command={}", debugger_script.to_str().unwrap()), - ]; - - let mut gdb_path = tool_path; - gdb_path.push_str("/bin/gdb"); - let Output { - status, - stdout, - stderr, - } = Command::new(&gdb_path) - .args(&debugger_opts) - .output() - .expect(&format!("failed to exec `{:?}`", gdb_path)); - let cmdline = { - let mut gdb = Command::new(&format!("{}-gdb", self.config.target)); - gdb.args(&debugger_opts); - let cmdline = self.make_cmdline(&gdb, ""); - logv(self.config, format!("executing {}", cmdline)); - cmdline - }; + debug!("adb arg: {}", adb_arg); + let mut adb = Command::new(adb_path) + .args(&["shell", &adb_arg]) + .stdout(Stdio::piped()) + .stderr(Stdio::inherit()) + .spawn() + .expect(&format!("failed to exec `{:?}`", adb_path)); + + // Wait for the gdbserver to print out "Listening on port ..." + // at which point we know that it's started and then we can + // execute the debugger below. + let mut stdout = BufReader::new(adb.stdout.take().unwrap()); + let mut line = String::new(); + loop { + line.truncate(0); + stdout.read_line(&mut line).unwrap(); + if line.starts_with("Listening on port 5039") { + break; + } + } + drop(stdout); + + let debugger_script = self.make_out_name("debugger.script"); + // FIXME (#9639): This needs to handle non-utf8 paths + let debugger_opts = vec![ + "-quiet".to_owned(), + "-batch".to_owned(), + "-nx".to_owned(), + format!("-command={}", debugger_script.to_str().unwrap()), + ]; - debugger_run_result = ProcRes { - status, - stdout: String::from_utf8(stdout).unwrap(), - stderr: String::from_utf8(stderr).unwrap(), - cmdline, - }; - if adb.kill().is_err() { - println!("Adb process is already finished."); - } + let gdb_path = self.config.gdb.as_ref().unwrap(); + let Output { + status, + stdout, + stderr, + } = Command::new(&gdb_path) + .args(&debugger_opts) + .output() + .expect(&format!("failed to exec `{:?}`", gdb_path)); + let cmdline = { + let mut gdb = Command::new(&format!("{}-gdb", self.config.target)); + gdb.args(&debugger_opts); + let cmdline = self.make_cmdline(&gdb, ""); + logv(self.config, format!("executing {}", cmdline)); + cmdline + }; + + debugger_run_result = ProcRes { + status, + stdout: String::from_utf8(stdout).unwrap(), + stderr: String::from_utf8(stderr).unwrap(), + cmdline, + }; + if adb.kill().is_err() { + println!("Adb process is already finished."); } + } else { + let rust_src_root = self + .config + .find_rust_src_root() + .expect("Could not find Rust source root"); + let rust_pp_module_rel_path = Path::new("./src/etc"); + let rust_pp_module_abs_path = rust_src_root + .join(rust_pp_module_rel_path) + .to_str() + .unwrap() + .to_owned(); + // write debugger script + let mut script_str = String::with_capacity(2048); + script_str.push_str(&format!("set charset {}\n", Self::charset())); + script_str.push_str("show version\n"); + + match self.config.gdb_version { + Some(version) => { + println!( + "NOTE: compiletest thinks it is using GDB version {}", + version + ); - _ => { - let rust_src_root = self - .config - .find_rust_src_root() - .expect("Could not find Rust source root"); - let rust_pp_module_rel_path = Path::new("./src/etc"); - let rust_pp_module_abs_path = rust_src_root - .join(rust_pp_module_rel_path) - .to_str() - .unwrap() - .to_owned(); - // write debugger script - let mut script_str = String::with_capacity(2048); - script_str.push_str(&format!("set charset {}\n", Self::charset())); - script_str.push_str("show version\n"); - - match self.config.gdb_version { - Some(version) => { - println!( - "NOTE: compiletest thinks it is using GDB version {}", - version - ); - - if version > extract_gdb_version("7.4").unwrap() { - // Add the directory containing the pretty printers to - // GDB's script auto loading safe path - script_str.push_str(&format!( - "add-auto-load-safe-path {}\n", - rust_pp_module_abs_path.replace(r"\", r"\\") - )); - } - } - _ => { - println!( - "NOTE: compiletest does not know which version of \ - GDB it is using" - ); + if version > extract_gdb_version("7.4").unwrap() { + // Add the directory containing the pretty printers to + // GDB's script auto loading safe path + script_str.push_str(&format!( + "add-auto-load-safe-path {}\n", + rust_pp_module_abs_path.replace(r"\", r"\\") + )); } } + _ => { + println!( + "NOTE: compiletest does not know which version of \ + GDB it is using" + ); + } + } - // The following line actually doesn't have to do anything with - // pretty printing, it just tells GDB to print values on one line: - script_str.push_str("set print pretty off\n"); - - // Add the pretty printer directory to GDB's source-file search path - script_str.push_str(&format!("directory {}\n", rust_pp_module_abs_path)); - - // Load the target executable - script_str.push_str(&format!( - "file {}\n", - exe_file.to_str().unwrap().replace(r"\", r"\\") - )); + // The following line actually doesn't have to do anything with + // pretty printing, it just tells GDB to print values on one line: + script_str.push_str("set print pretty off\n"); - // Force GDB to print values in the Rust format. - if self.config.gdb_native_rust { - script_str.push_str("set language rust\n"); - } + // Add the pretty printer directory to GDB's source-file search path + script_str.push_str(&format!("directory {}\n", rust_pp_module_abs_path)); - // Add line breakpoints - for line in &breakpoint_lines { - script_str.push_str(&format!( - "break '{}':{}\n", - self.testpaths.file.file_name().unwrap().to_string_lossy(), - *line - )); - } + // Load the target executable + script_str.push_str(&format!( + "file {}\n", + exe_file.to_str().unwrap().replace(r"\", r"\\") + )); - script_str.push_str(&cmds); - script_str.push_str("\nquit\n"); + // Force GDB to print values in the Rust format. + if self.config.gdb_native_rust { + script_str.push_str("set language rust\n"); + } - debug!("script_str = {}", script_str); - self.dump_output_file(&script_str, "debugger.script"); + // Add line breakpoints + for line in &breakpoint_lines { + script_str.push_str(&format!( + "break '{}':{}\n", + self.testpaths.file.file_name().unwrap().to_string_lossy(), + *line + )); + } - let debugger_script = self.make_out_name("debugger.script"); + script_str.push_str(&cmds); + script_str.push_str("\nquit\n"); - // FIXME (#9639): This needs to handle non-utf8 paths - let debugger_opts = vec![ - "-quiet".to_owned(), - "-batch".to_owned(), - "-nx".to_owned(), - format!("-command={}", debugger_script.to_str().unwrap()), - ]; + debug!("script_str = {}", script_str); + self.dump_output_file(&script_str, "debugger.script"); - let mut gdb = Command::new(self.config.gdb.as_ref().unwrap()); - gdb.args(&debugger_opts) - .env("PYTHONPATH", rust_pp_module_abs_path); + let debugger_script = self.make_out_name("debugger.script"); - debugger_run_result = self.compose_and_run( - gdb, - self.config.run_lib_path.to_str().unwrap(), - None, - None, - ); - } + // FIXME (#9639): This needs to handle non-utf8 paths + let debugger_opts = vec![ + "-quiet".to_owned(), + "-batch".to_owned(), + "-nx".to_owned(), + format!("-command={}", debugger_script.to_str().unwrap()), + ]; + + let mut gdb = Command::new(self.config.gdb.as_ref().unwrap()); + gdb.args(&debugger_opts) + .env("PYTHONPATH", rust_pp_module_abs_path); + + debugger_run_result = self.compose_and_run( + gdb, + self.config.run_lib_path.to_str().unwrap(), + None, + None, + ); } if !debugger_run_result.status.success() { @@ -852,6 +916,7 @@ let config = Config { target_rustcflags: self.cleanup_debug_info_options(&self.config.target_rustcflags), host_rustcflags: self.cleanup_debug_info_options(&self.config.host_rustcflags), + mode: DebugInfoLldb, ..self.config.clone() }; @@ -887,13 +952,23 @@ } } + let prefixes = if self.config.lldb_native_rust { + static PREFIXES: &'static [&'static str] = &["lldb", "lldbr"]; + println!("NOTE: compiletest thinks it is using LLDB with native rust support"); + PREFIXES + } else { + static PREFIXES: &'static [&'static str] = &["lldb", "lldbg"]; + println!("NOTE: compiletest thinks it is using LLDB without native rust support"); + PREFIXES + }; + // Parse debugger commands etc from test files let DebuggerCommands { commands, check_lines, breakpoint_lines, .. - } = self.parse_debugger_commands(&["lldb"]); + } = self.parse_debugger_commands(prefixes); // Write debugger script: // We don't want to hang when calling `quit` while the process is still running @@ -1666,7 +1741,7 @@ } match self.config.mode { - CompileFail | ParseFail | Incremental => { + CompileFail | Incremental => { // If we are extracting and matching errors in the new // fashion, then you want JSON mode. Old-skool error // patterns still match the raw compiler output. @@ -1677,7 +1752,7 @@ rustc.arg("-Zui-testing"); } } - Ui => { + RunPass | Ui => { if !self .props .compile_flags @@ -1706,7 +1781,7 @@ rustc.arg(dir_opt); } - RunPass | RunFail | RunPassValgrind | Pretty | DebugInfoGdb | DebugInfoLldb + RunFail | RunPassValgrind | Pretty | DebugInfoBoth | DebugInfoGdb | DebugInfoLldb | Codegen | Rustdoc | RunMake | CodegenUnits => { // do not use JSON output } @@ -1742,7 +1817,7 @@ match self.config.compare_mode { Some(CompareMode::Nll) => { - rustc.args(&["-Zborrowck=mir", "-Ztwo-phase-borrows"]); + rustc.args(&["-Zborrowck=migrate", "-Ztwo-phase-borrows"]); } Some(CompareMode::Polonius) => { rustc.args(&["-Zpolonius", "-Zborrowck=mir", "-Ztwo-phase-borrows"]); @@ -2638,8 +2713,12 @@ let normalized_stderr = self.normalize_output(&stderr, &self.props.normalize_stderr); let mut errors = 0; - errors += self.compare_output("stdout", &normalized_stdout, &expected_stdout); - errors += self.compare_output("stderr", &normalized_stderr, &expected_stderr); + if !self.props.dont_check_compiler_stdout { + errors += self.compare_output("stdout", &normalized_stdout, &expected_stdout); + } + if !self.props.dont_check_compiler_stderr { + errors += self.compare_output("stderr", &normalized_stderr, &expected_stderr); + } let modes_to_prune = vec![CompareMode::Nll]; self.prune_duplicate_outputs(&modes_to_prune); @@ -2691,7 +2770,7 @@ let expected_errors = errors::load_errors(&self.testpaths.file, self.revision); - if self.props.run_pass { + if self.should_run_successfully() { let proc_res = self.exec_compiled_test(); if !proc_res.status.success() { diff -Nru rustc-1.30.0+dfsg1+llvm/src/tools/rustc-workspace-hack/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/tools/rustc-workspace-hack/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/tools/rustc-workspace-hack/Cargo.toml 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/tools/rustc-workspace-hack/Cargo.toml 2018-12-04 23:41:41.000000000 +0000 @@ -39,6 +39,7 @@ "schannel", "securitybaseapi", "shellapi", + "sspi", "synchapi", "sysinfoapi", "timezoneapi", @@ -47,3 +48,15 @@ "wincon", "wincrypt", ] + +[dependencies] +serde_json = { version = "1.0.31", features = ["raw_value"] } +rand = { version = "0.5.5", features = ["i128_support"] } +curl-sys = { version = "0.4.13", optional = true } + +[target.'cfg(not(windows))'.dependencies] +openssl = { version = "0.10.12", optional = true } + + +[features] +all-static = ['openssl/vendored', 'curl-sys/static-curl'] diff -Nru rustc-1.30.0+dfsg1+llvm/src/tools/tidy/src/deps.rs rustc-1.31.0+dfsg1+llvm/src/tools/tidy/src/deps.rs --- rustc-1.30.0+dfsg1+llvm/src/tools/tidy/src/deps.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/tools/tidy/src/deps.rs 2018-12-04 23:41:41.000000000 +0000 @@ -51,6 +51,7 @@ "ordslice", // Apache-2.0, rls "cloudabi", // BSD-2-Clause, (rls -> crossbeam-channel 0.2 -> rand 0.5) "ryu", // Apache-2.0, rls/cargo/... (b/c of serde) + "bytesize", // Apache-2.0, cargo ]; /// Which crates to check against the whitelist? diff -Nru rustc-1.30.0+dfsg1+llvm/src/tools/tidy/src/lib.rs rustc-1.31.0+dfsg1+llvm/src/tools/tidy/src/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/tools/tidy/src/lib.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/tools/tidy/src/lib.rs 2018-12-04 23:41:41.000000000 +0000 @@ -78,6 +78,7 @@ "src/tools/lldb", "src/target", "src/stdsimd", + "target", ]; skip.iter().any(|p| path.ends_with(p)) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/tools/tidy/src/pal.rs rustc-1.31.0+dfsg1+llvm/src/tools/tidy/src/pal.rs --- rustc-1.30.0+dfsg1+llvm/src/tools/tidy/src/pal.rs 2018-10-24 20:00:02.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/tools/tidy/src/pal.rs 2018-12-04 23:41:41.000000000 +0000 @@ -163,7 +163,7 @@ fn find_test_mod(contents: &str) -> usize { if let Some(mod_tests_idx) = contents.find("mod tests") { - // Also capture a previos line indicating "mod tests" in cfg-ed out + // Also capture a previous line indicating "mod tests" in cfg-ed out let prev_newline_idx = contents[..mod_tests_idx].rfind('\n').unwrap_or(mod_tests_idx); let prev_newline_idx = contents[..prev_newline_idx].rfind('\n'); if let Some(nl) = prev_newline_idx { diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/.cargo-checksum.json rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/.cargo-checksum.json --- rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/.cargo-checksum.json 2018-10-24 21:38:15.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/.cargo-checksum.json 2018-12-05 01:24:38.000000000 +0000 @@ -1 +1 @@ -{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Cargo.toml":"0b0ab3146bdaac2ddf190bff41b0c984432433394e05016bc18a1fcb27e346b5","Cargo.toml.orig":"2fc5020fe62faed56d40fef3ee745529a1a34e874ae03e2c2cb7293cfcd65ae8","README.md":"7886661b3dd3a689da97f1125f4c479fd8e7acb42fe42f26f288507f4beee784","src/README.md":"aa1296711d42c1c4f01ac626aae966344b424baf6a2516c1d607b3a7c5434dbe","src/context.rs":"3ce6c9240f677f900085e85a29bcaa8855683971f8f4a07e3d56009e178086e5","src/context/prelude.rs":"8b271aba5d8b3364bd3b5e1c1f5908d8dd356c89327c6d1355adadd071605824","src/derived.rs":"3c6eb71f6b912af22d1e4eadcd758243dc9cf25503d47e756646f2364eb6d05f","src/fallible.rs":"bd2d743816b0e9bee3111228f929be091d9195c4d9c1f85c118a528bc581be30","src/forest.rs":"9c10313dd37c4b9f7b0b37cdc4a2cb773582f4fe55dad6be3110c773f3259982","src/hh.rs":"b48c682a88efefadb62dc457a3d1d83a568d0b990d8949566bcab50ad88dbe5b","src/lib.rs":"ef81c83dc270b8c0108c5739d46576039e41e0dfb70cc7b7560fad3e582576f8","src/logic.rs":"fbe9fc5d05936019b4080efa554dbac76577eeee93638a3c5429a38eaa24af5f","src/simplify.rs":"9b4fe7be828caf5f643984813c0a4a94ee68040e5e083cbc79e3caef7155f40f","src/stack.rs":"a5d05dfea806589a60cfad0a6ae29aa29348ba1290a364d896cd490b4ca6fbdc","src/strand.rs":"bb77e9c0a70f629f24066a1bba5c32f4b4080c2c733b334e949af2666a796a15","src/table.rs":"ad069c919869951da964e895074252ce9a64a4797a573df48476c828404f4844","src/tables.rs":"46e17e53153280c85bcb9890e1245be2c1869a5741cc461f23eae607ac35e829"},"package":"25ce2f28f55ed544a2a3756b7acf41dd7d6f27acffb2086439950925506af7d0"} \ No newline at end of file +{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".cargo_vcs_info.json":"df79f8e86ece6a2802b71aebe255e6a519b081cf2aa37622a0e3b98f91511dff","Cargo.toml":"7f9a2de67e17ec9bcd12a2502a3da8236defeb867d145133730f4ea96806c9e3","Cargo.toml.orig":"3c59a68a36a9a3045f34ee753c3b1c41f63016fd2ac7f4ef7a68ce448e8b40fa","README.md":"7886661b3dd3a689da97f1125f4c479fd8e7acb42fe42f26f288507f4beee784","src/README.md":"aa1296711d42c1c4f01ac626aae966344b424baf6a2516c1d607b3a7c5434dbe","src/context.rs":"a1023cc51634478ee0dcb1f19ac43e4386afc65f720d029fd0642093956bb42d","src/context/prelude.rs":"4102ef647914022f421e32d0fdbe78b05b316507dd3d9a514239ce55fe17f9c9","src/derived.rs":"3c6eb71f6b912af22d1e4eadcd758243dc9cf25503d47e756646f2364eb6d05f","src/fallible.rs":"bd2d743816b0e9bee3111228f929be091d9195c4d9c1f85c118a528bc581be30","src/forest.rs":"f9a4ac702d94fbed27822fe7534c60c0cfaffc9c6fe3cc7f9d4744cf53e21d40","src/hh.rs":"12ba9ff1a300c067a37a3a5142f3d2bddc66e4cec4486c4fe5f5e4bb43e67130","src/lib.rs":"43b9157ae19455a5bc08bac73639e65b901b9ab81c7662b0e7e9c1bd18c43a4b","src/logic.rs":"8bb90780defbcc20ebe1ccc3a226fccb5aeed9a582f137ebdfd04ef3cfc54c21","src/simplify.rs":"d2e6c87d07b02a7c5bb42927117d3bf172f97a1f9e7022ea8e295e8bf43ec678","src/stack.rs":"e5ecf948cac5d53c54f31a8085449d977e0c157f69e61d751dc4e17070cec2d9","src/strand.rs":"431fa6439ab191b652f123455ac9f9223826cd076c8ca46443bd0b5849575086","src/table.rs":"9e3542a411ca4524b710a3747154028a99b2e29cfe51bff535b14aa2089ab17d","src/tables.rs":"6b95a382018d9ff6e8de1f0d81c0683508fe3c26613d2f2c65c3f0eb46152c2c"},"package":"9adbe0fe1d6e937c3ee0571739a78f53c1de22f59df616060e868cf13c6c4ce5"} \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/Cargo.toml 2018-10-24 21:38:15.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/Cargo.toml 2018-12-05 01:24:38.000000000 +0000 @@ -12,7 +12,7 @@ [package] name = "chalk-engine" -version = "0.7.0" +version = "0.8.1" authors = ["Rust Compiler Team", "Chalk developers"] description = "Core trait engine from Chalk project" readme = "README.md" diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/Cargo.toml.orig rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/Cargo.toml.orig --- rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/Cargo.toml.orig 2018-10-24 21:38:15.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/Cargo.toml.orig 2018-12-05 01:24:38.000000000 +0000 @@ -1,6 +1,6 @@ [package] name = "chalk-engine" -version = "0.7.0" +version = "0.8.1" description = "Core trait engine from Chalk project" license = "Apache-2.0/MIT" authors = ["Rust Compiler Team", "Chalk developers"] diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/.cargo_vcs_info.json rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/.cargo_vcs_info.json --- rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/.cargo_vcs_info.json 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/.cargo_vcs_info.json 2018-12-05 01:24:38.000000000 +0000 @@ -0,0 +1,5 @@ +{ + "git": { + "sha1": "e9c0a34dff162848f361f0f54ca3aab750ff4683" + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/src/context/prelude.rs rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/src/context/prelude.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/src/context/prelude.rs 2018-10-24 21:38:15.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/src/context/prelude.rs 2018-12-05 01:24:38.000000000 +0000 @@ -1,8 +1,8 @@ #![allow(unused_imports)] // rustc bug -crate use super::Context; -crate use super::ContextOps; -crate use super::AggregateOps; -crate use super::ResolventOps; -crate use super::TruncateOps; -crate use super::InferenceTable; +pub(crate) use super::Context; +pub(crate) use super::ContextOps; +pub(crate) use super::AggregateOps; +pub(crate) use super::ResolventOps; +pub(crate) use super::TruncateOps; +pub(crate) use super::InferenceTable; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/src/context.rs rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/src/context.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/src/context.rs 2018-10-24 21:38:15.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/src/context.rs 2018-12-05 01:24:38.000000000 +0000 @@ -1,10 +1,10 @@ -use crate::fallible::Fallible; -use crate::hh::HhGoal; -use crate::{DelayedLiteral, ExClause, SimplifiedAnswer}; +use fallible::Fallible; +use hh::HhGoal; +use {DelayedLiteral, ExClause, SimplifiedAnswer}; use std::fmt::Debug; use std::hash::Hash; -crate mod prelude; +pub(crate) mod prelude; /// The "context" in which the SLG solver operates. It defines all the /// types that the SLG solver may need to refer to, as well as a few @@ -113,12 +113,6 @@ environment: &Self::Environment, goal: Self::Goal, ) -> Self::GoalInEnvironment; - - /// Upcast this domain goal into a more general goal. - fn into_goal(domain_goal: Self::DomainGoal) -> Self::Goal; - - /// Create a "cannot prove" goal (see `HhGoal::CannotProve`). - fn cannot_prove() -> Self::Goal; } pub trait ContextOps: Sized + Clone + Debug + AggregateOps { @@ -250,6 +244,12 @@ env: &I::Environment, clauses: I::ProgramClauses, ) -> I::Environment; + + /// Upcast this domain goal into a more general goal. + fn into_goal(&self, domain_goal: I::DomainGoal) -> I::Goal; + + /// Create a "cannot prove" goal (see `HhGoal::CannotProve`). + fn cannot_prove(&self) -> I::Goal; } /// Methods for unifying and manipulating terms and binders. diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/src/forest.rs rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/src/forest.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/src/forest.rs 2018-10-24 21:38:15.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/src/forest.rs 2018-12-05 01:24:38.000000000 +0000 @@ -1,16 +1,16 @@ -use crate::{DepthFirstNumber, SimplifiedAnswer, TableIndex}; -use crate::context::prelude::*; -use crate::context::AnswerStream; -use crate::logic::RootSearchFail; -use crate::stack::{Stack, StackIndex}; -use crate::tables::Tables; -use crate::table::{Answer, AnswerIndex}; +use {DepthFirstNumber, SimplifiedAnswer, TableIndex}; +use context::prelude::*; +use context::AnswerStream; +use logic::RootSearchFail; +use stack::{Stack, StackIndex}; +use tables::Tables; +use table::{Answer, AnswerIndex}; pub struct Forest> { #[allow(dead_code)] - crate context: CO, - crate tables: Tables, - crate stack: Stack, + pub(crate) context: CO, + pub(crate) tables: Tables, + pub(crate) stack: Stack, dfn: DepthFirstNumber, } diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/src/hh.rs rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/src/hh.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/src/hh.rs 2018-10-24 21:38:15.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/src/hh.rs 2018-12-05 01:24:38.000000000 +0000 @@ -1,4 +1,4 @@ -use crate::context::Context; +use context::Context; #[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] /// A general goal; this is the full range of questions you can pose to Chalk. @@ -15,7 +15,7 @@ /// Indicates something that cannot be proven to be true or false /// definitively. This can occur with overflow but also with - /// unifications of skolemized variables like `forall { X = Y + /// unifications of placeholder variables like `forall { X = Y /// }`. Of course, that statement is false, as there exist types /// X, Y where `X = Y` is not true. But we treat it as "cannot /// prove" so that `forall { not { X = Y } }` also winds up diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/src/lib.rs rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/src/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/src/lib.rs 2018-10-24 21:38:15.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/src/lib.rs 2018-12-05 01:24:38.000000000 +0000 @@ -49,13 +49,9 @@ //! - HH: Hereditary harrop predicates. What Chalk deals in. //! Popularized by Lambda Prolog. -#![feature(crate_in_paths)] -#![feature(crate_visibility_modifier)] #![feature(in_band_lifetimes)] -#![feature(macro_vis_matcher)] #![feature(step_trait)] #![feature(non_modrs_mods)] -#![feature(rustc_private)] #[macro_use] extern crate chalk_macros; @@ -65,7 +61,7 @@ extern crate rustc_hash; -use crate::context::Context; +use context::Context; use rustc_hash::FxHashSet; use std::cmp::min; use std::usize; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/src/logic.rs rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/src/logic.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/src/logic.rs 2018-10-24 21:38:15.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/src/logic.rs 2018-12-05 01:24:38.000000000 +0000 @@ -1,12 +1,12 @@ -use crate::{DelayedLiteral, DelayedLiteralSet, DepthFirstNumber, ExClause, Literal, Minimums, +use {DelayedLiteral, DelayedLiteralSet, DepthFirstNumber, ExClause, Literal, Minimums, TableIndex}; -use crate::fallible::NoSolution; -use crate::context::{WithInstantiatedExClause, WithInstantiatedUCanonicalGoal, prelude::*}; -use crate::forest::Forest; -use crate::hh::HhGoal; -use crate::stack::StackIndex; -use crate::strand::{CanonicalStrand, SelectedSubgoal, Strand}; -use crate::table::{Answer, AnswerIndex}; +use fallible::NoSolution; +use context::{WithInstantiatedExClause, WithInstantiatedUCanonicalGoal, prelude::*}; +use forest::Forest; +use hh::HhGoal; +use stack::StackIndex; +use strand::{CanonicalStrand, SelectedSubgoal, Strand}; +use table::{Answer, AnswerIndex}; use rustc_hash::FxHashSet; use std::marker::PhantomData; use std::mem; @@ -56,7 +56,8 @@ QuantumExceeded, } -type StrandResult = Result>; +#[allow(type_alias_bounds)] +type StrandResult = Result>; /// Possible failures from pursuing a particular strand. #[derive(Debug)] @@ -183,7 +184,7 @@ result.map(|()| EnsureSuccess::AnswerAvailable) } - crate fn answer(&self, table: TableIndex, answer: AnswerIndex) -> &Answer { + pub(crate) fn answer(&self, table: TableIndex, answer: AnswerIndex) -> &Answer { self.tables[table].answer(answer).unwrap() } @@ -691,7 +692,7 @@ /// In terms of the NFTD paper, creating a new table corresponds /// to the *New Subgoal* step as well as the *Program Clause /// Resolution* steps. - crate fn get_or_create_table_for_ucanonical_goal( + pub(crate) fn get_or_create_table_for_ucanonical_goal( &mut self, goal: C::UCanonicalGoalInEnvironment, ) -> TableIndex { @@ -1166,7 +1167,7 @@ depth: StackIndex, strand: Strand<'_, C, impl Context>, ) -> StrandResult { - crate::maybe_grow_stack(|| self.pursue_strand(depth, strand)) + ::maybe_grow_stack(|| self.pursue_strand(depth, strand)) } /// Invoked when we have found a successful answer to the given diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/src/simplify.rs rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/src/simplify.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/src/simplify.rs 2018-10-24 21:38:15.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/src/simplify.rs 2018-12-05 01:24:38.000000000 +0000 @@ -1,8 +1,8 @@ -use crate::fallible::Fallible; -use crate::{ExClause, Literal}; -use crate::forest::Forest; -use crate::hh::HhGoal; -use crate::context::prelude::*; +use fallible::Fallible; +use {ExClause, Literal}; +use forest::Forest; +use hh::HhGoal; +use context::prelude::*; impl> Forest { /// Simplifies an HH goal into a series of positive domain goals @@ -56,7 +56,7 @@ .subgoals .push(Literal::Positive(I::goal_in_environment( &environment, - I::into_goal(domain_goal), + infer.into_goal(domain_goal), ))); } HhGoal::CannotProve => { @@ -66,7 +66,7 @@ // course, will always create a negative cycle and // hence a delayed literal that cannot be // resolved. - let goal = I::cannot_prove(); + let goal = infer.cannot_prove(); ex_clause .subgoals .push(Literal::Negative(I::goal_in_environment(&environment, goal))); diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/src/stack.rs rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/src/stack.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/src/stack.rs 2018-10-24 21:38:15.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/src/stack.rs 2018-12-05 01:24:38.000000000 +0000 @@ -1,9 +1,9 @@ -use crate::{DepthFirstNumber, TableIndex}; +use {DepthFirstNumber, TableIndex}; use std::ops::{Index, IndexMut, Range}; /// See `Forest`. #[derive(Default)] -crate struct Stack { +pub(crate) struct Stack { /// Stack: as described above, stores the in-progress goals. stack: Vec, } @@ -13,12 +13,12 @@ /// table is completely evaluated, it may be popped from the stack, /// and hence no longer have a stack index. index_struct! { - crate struct StackIndex { + pub(crate) struct StackIndex { value: usize, } } -crate struct StackEntry { +pub(crate) struct StackEntry { /// The goal G from the stack entry `A :- G` represented here. pub(super) table: TableIndex, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/src/strand.rs rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/src/strand.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/src/strand.rs 2018-10-24 21:38:15.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/src/strand.rs 2018-12-05 01:24:38.000000000 +0000 @@ -1,39 +1,39 @@ use std::fmt::{Debug, Error, Formatter}; -use crate::{ExClause, TableIndex}; -use crate::context::{Context, InferenceTable}; -use crate::table::AnswerIndex; +use {ExClause, TableIndex}; +use context::{Context, InferenceTable}; +use table::AnswerIndex; #[derive(Debug)] -crate struct CanonicalStrand { +pub(crate) struct CanonicalStrand { pub(super) canonical_ex_clause: C::CanonicalExClause, /// Index into `ex_clause.subgoals`. - crate selected_subgoal: Option>, + pub(crate) selected_subgoal: Option>, } -crate struct Strand<'table, C: Context + 'table, I: Context + 'table> { - crate infer: &'table mut dyn InferenceTable, +pub(crate) struct Strand<'table, C: Context + 'table, I: Context + 'table> { + pub(crate) infer: &'table mut dyn InferenceTable, pub(super) ex_clause: ExClause, /// Index into `ex_clause.subgoals`. - crate selected_subgoal: Option>, + pub(crate) selected_subgoal: Option>, } #[derive(Clone, Debug)] -crate struct SelectedSubgoal { +pub(crate) struct SelectedSubgoal { /// The index of the subgoal in `ex_clause.subgoals` - crate subgoal_index: usize, + pub(crate) subgoal_index: usize, /// The index of the table that we created or found for this subgoal pub(super) subgoal_table: TableIndex, /// Index of the answer we should request next from the table - crate answer_index: AnswerIndex, + pub(crate) answer_index: AnswerIndex, /// Maps the universes of the subgoal to the canonical universes /// used in the table - crate universe_map: C::UniverseMap, + pub(crate) universe_map: C::UniverseMap, } impl<'table, C: Context, I: Context> Debug for Strand<'table, C, I> { diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/src/table.rs rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/src/table.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/src/table.rs 2018-10-24 21:38:15.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/src/table.rs 2018-12-05 01:24:38.000000000 +0000 @@ -1,19 +1,19 @@ -use crate::{DelayedLiteralSet, DelayedLiteralSets}; -use crate::context::prelude::*; -use crate::strand::CanonicalStrand; +use {DelayedLiteralSet, DelayedLiteralSets}; +use context::prelude::*; +use strand::CanonicalStrand; use rustc_hash::FxHashMap; use std::collections::VecDeque; use std::collections::hash_map::Entry; use std::mem; -crate struct Table { +pub(crate) struct Table { /// The goal this table is trying to solve (also the key to look /// it up). - crate table_goal: C::UCanonicalGoalInEnvironment, + pub(crate) table_goal: C::UCanonicalGoalInEnvironment, /// A goal is coinductive if it can assume itself to be true, more /// or less. This is true for auto traits. - crate coinductive_goal: bool, + pub(crate) coinductive_goal: bool, /// Stores the answers that we have found thus far. When we get a request /// for an answer N, we will first check this vector. @@ -32,7 +32,7 @@ } index_struct! { - crate struct AnswerIndex { + pub(crate) struct AnswerIndex { value: usize, } } @@ -43,12 +43,12 @@ /// a substitution #[derive(Clone, Debug)] pub struct Answer { - crate subst: C::CanonicalConstrainedSubst, - crate delayed_literals: DelayedLiteralSet, + pub(crate) subst: C::CanonicalConstrainedSubst, + pub(crate) delayed_literals: DelayedLiteralSet, } impl Table { - crate fn new(table_goal: C::UCanonicalGoalInEnvironment, coinductive_goal: bool) -> Table { + pub(crate) fn new(table_goal: C::UCanonicalGoalInEnvironment, coinductive_goal: bool) -> Table { Table { table_goal, coinductive_goal, @@ -58,23 +58,23 @@ } } - crate fn push_strand(&mut self, strand: CanonicalStrand) { + pub(crate) fn push_strand(&mut self, strand: CanonicalStrand) { self.strands.push_back(strand); } - crate fn extend_strands(&mut self, strands: impl IntoIterator>) { + pub(crate) fn extend_strands(&mut self, strands: impl IntoIterator>) { self.strands.extend(strands); } - crate fn strands_mut(&mut self) -> impl Iterator> { + pub(crate) fn strands_mut(&mut self) -> impl Iterator> { self.strands.iter_mut() } - crate fn take_strands(&mut self) -> VecDeque> { + pub(crate) fn take_strands(&mut self) -> VecDeque> { mem::replace(&mut self.strands, VecDeque::new()) } - crate fn pop_next_strand(&mut self) -> Option> { + pub(crate) fn pop_next_strand(&mut self) -> Option> { self.strands.pop_front() } @@ -127,7 +127,7 @@ } impl AnswerIndex { - crate const ZERO: AnswerIndex = AnswerIndex { value: 0 }; + pub(crate) const ZERO: AnswerIndex = AnswerIndex { value: 0 }; } impl Answer { diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/src/tables.rs rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/src/tables.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/chalk-engine/src/tables.rs 2018-10-24 21:38:15.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/chalk-engine/src/tables.rs 2018-12-05 01:24:38.000000000 +0000 @@ -1,11 +1,11 @@ -use crate::TableIndex; -use crate::context::prelude::*; -use crate::table::Table; +use TableIndex; +use context::prelude::*; +use table::Table; use rustc_hash::FxHashMap; use std::ops::{Index, IndexMut}; /// See `Forest`. -crate struct Tables { +pub(crate) struct Tables { /// Maps from a canonical goal to the index of its table. table_indices: FxHashMap, @@ -15,7 +15,7 @@ } impl Tables { - crate fn new() -> Tables { + pub(crate) fn new() -> Tables { Tables { table_indices: FxHashMap::default(), tables: Vec::default(), diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/flate2/.cargo-checksum.json rustc-1.31.0+dfsg1+llvm/src/vendor/flate2/.cargo-checksum.json --- rustc-1.30.0+dfsg1+llvm/src/vendor/flate2/.cargo-checksum.json 2018-10-24 21:38:11.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/flate2/.cargo-checksum.json 2018-12-05 01:24:32.000000000 +0000 @@ -1 +1 @@ -{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"f9b1ca6ae27d1c18215265024629a8960c31379f206d9ed20f64e0b2dcf79805",".travis.yml":"ec9f436e398aa09209c1dafb2675fb876d894fd7aca985817f38323d9a650af0","Cargo.toml":"b24927075cf6fcd587f92db846520ca03d67c55f3430da1ef6db7e00cc4f136c","Cargo.toml.orig":"4dce110aee671e8470749d18c26ed1df877fe48846b0b20824cc93a43ab85349","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"29b1dac7c214deaa3f4f8305102cbc166ac9015a2d3d641f3a539103a97b6c8a","appveyor.yml":"7293e690b6b1fb75cbab1f72ffc5077dd145c806282969b595cc1a82ce1a2e62","examples/deflatedecoder-bufread.rs":"286995f7fa968c3cb935f4a9436db035691112fd1999ad001fb17da1a76162be","examples/deflatedecoder-read.rs":"7d7347a31317d288291847369032cefad5688defe6043a3f0d2a72b8567eb056","examples/deflatedecoder-write.rs":"23723a260ac6916243089666d25e2d7c5fdf390fb2fa20d0c2a957647a0e1880","examples/deflateencoder-bufread.rs":"c9a798336ed81c104fc01c3620380bb3369af90a710a89b19c2402f25c25d375","examples/deflateencoder-read.rs":"3af2fe62fb464c2c38a16099c38ce6ce510356ac47de2fc8a8a46ad1660992d7","examples/deflateencoder-write.rs":"0c6d3590b925a731bdd7e4a899ff5783539a4f48f88a8d95e7acecde5d426521","examples/gzbuilder.rs":"d0fe0fc8b6f302f35af80f61d2cbb4e55b1d511f7894e06756bda0d53f9505f9","examples/gzdecoder-bufread.rs":"2ec57910cb86a03566476f9b65562c2bfc661c7e094fb5b847d84e4127b7dd8d","examples/gzdecoder-read.rs":"af29581f5eadd76f1079b3da73b5cd97557c1abe435014ecad4b3be22518a2bb","examples/gzdecoder-write.rs":"6945f92d678454caa44f6c6ff6260c1b8b913cf876ab3c0ce39fe863cabbf2e8","examples/gzencoder-bufread.rs":"ad79e9f8630359ed21b74a1431d49fdb08c0673df7b21e98d0cad05b29357460","examples/gzencoder-read.rs":"b37c7d18e58c916bdaff4d698cbfc7fe99c03b7d440eb386694a268dbc938134","examples/gzencoder-write.rs":"3dc712c3100caab0e29bd8c48314a964392cd2f2443e988dfbe5416909fb5e1d","examples/gzmultidecoder-bufread.rs":"b55840b1139c7351cff67320c88bc8f2e4e74eecc20ed617deb48d27c855a5a4","examples/gzmultidecoder-read.rs":"a5cd59f0ea2543ce8c6ac8a77128a9f9242b0eca27dfd82c7842a2d63930e874","examples/hello_world.txt":"d2a84f4b8b650937ec8f73cd8be2c74add5a911ba64df27458ed8229da804a26","examples/zlibdecoder-bufread.rs":"688999ef801a8ecccb741eb9a6e6a89fbc5c9857bc1fdffd4b613d4522f47407","examples/zlibdecoder-read.rs":"c8d414640ae3e7c356ac06ae3e3802ae88b2db7b40be4f567598335e90f969f4","examples/zlibdecoder-write.rs":"fd581a7bdfb992eba5b96c66eb9e143dabd6970762e8f92fd05215b1566f915c","examples/zlibencoder-bufread.rs":"667d3bdc83878e97d4faae6c820693339799989db1031e976dc52d7bc1e119ce","examples/zlibencoder-read.rs":"8f3e87c001a028f5f38495c1ca4b7b60a92429b0d93f783d7be5c02c4d0043e2","examples/zlibencoder-write.rs":"03e4559325a749ee378739ddc2fb9d43afcf3d60a7be714d0708ec590b2d50af","src/bufreader.rs":"7fc0b74ca751e9e11689d3e57abc3aadbda92f25f2a9a80fca009f43a112642d","src/crc.rs":"2f98a8b14e4e8f1ed6fadb87f62e2c5c23f6019847a1bd5275414bc92f4f061b","src/deflate/bufread.rs":"ed1b17ebeae9dd5549a5c6dfdc983f6b0becd8a588e4674ba36ec463f4b0aad5","src/deflate/mod.rs":"b9123e045fcb205d4f08cc76e904b67d83809349f5699e0ae95d924b73bb4050","src/deflate/read.rs":"8a579ab97396a22cb9196743753d7d6f1c4cc4e7c7ed8f86e4f2d3f6971796cb","src/deflate/write.rs":"3852f51611562237e35791b80dc450558949c173fa875d4b91e13c1d18cf23a7","src/ffi.rs":"296303ccd1967ab866f13661ad9b1336fb2497a53487b0efd08b5600bff30b6b","src/gz/bufread.rs":"b5bf00737dee1b4ffdbe78436726a5a0b12272bf0eadb9e4ab5464bf47eccfd4","src/gz/mod.rs":"b37dde138590a047572f5cf3c5a3d3eaa9032ffb9b9a5dbe567c03bddf56f478","src/gz/read.rs":"d5e5d127a9083ee5ce5a162a2c03965b7fbabc1ca3e221d74bdd68349ba7a7ce","src/gz/write.rs":"3a510433f6f76004599a201a18790c5b2451c1742967665ba51513d79c4f3f0d","src/lib.rs":"67282820b4b0ab9dc1d9c67de6b0d3f8001e5861c163187c9beb1854c048e7f8","src/mem.rs":"9e1a4f24b04fac9c4230bc93389997450f2dc24acd3c9df72d66dc9af3d516cb","src/zio.rs":"98133cafdc0014e075c14cd8a271cfd5e67a4ad4572e798f6f62bbe6425d0cff","src/zlib/bufread.rs":"8eff1bb0c2b557ca0428a087f81e5c93b6e5e71176930eb19fc73322a4b7092c","src/zlib/mod.rs":"7e565ec477d26e80eecd583148a21ba778ebb6eb625388f884f95fc623b3db4f","src/zlib/read.rs":"dd34b36a33257d428b449b41738dae79faf4d02955aea4be905fed313d3cf38f","src/zlib/write.rs":"abd3a640d09e82a890f66d18fd4618ad09d7e25c9e1c23fcd3532a7003d742b6","tests/corrupt-file.gz":"083dd284aa1621916a2d0f66ea048c8d3ba7a722b22d0d618722633f51e7d39c","tests/early-flush.rs":"5b12ab43ddb2dbc458b2fdf05fe2245bf8abea554756dfa7bc64a095adfde365","tests/empty-read.rs":"45477d316f77a048d747e9d18292abfec0cac667768385c8a061e18fd1240238","tests/good-file.gz":"87296963e53024a74752179ce7e54087565d358a85d3e65c3b37ef36eaa3d4a6","tests/good-file.txt":"bc4e03658a441fe2ad2df7cd2197144b87e41696f01e327b380e869cd9b485a0","tests/gunzip.rs":"18c2509e8795337faa955bd8429210217ecc6081e1647d3968d10e01ae876bb0","tests/multi.gz":"efa3341da052f95056314cc6920e02a3da15bdef30234b2552fb407812db5cc6","tests/multi.txt":"dbea9325179efe46ea2add94f7b6b745ca983fabb208dc6d34aa064623d7ee23","tests/tokio.rs":"1d256e3d38abc6a9dde87d9ec78dc94ab56670e102d64e2ed649a46ff0d4d615","tests/zero-write.rs":"ff8d0349a540b54363c55807c5fd7fbbdc363d08a536d35a3a40f0ce92c16489"},"package":"37847f133aae7acf82bb9577ccd8bda241df836787642654286e79679826a54b"} \ No newline at end of file +{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"f9b1ca6ae27d1c18215265024629a8960c31379f206d9ed20f64e0b2dcf79805",".travis.yml":"ec9f436e398aa09209c1dafb2675fb876d894fd7aca985817f38323d9a650af0","Cargo.toml":"82289f6f211051f40f39405850e2b883667247b9e9fd4f6466881389de1fa71b","Cargo.toml.orig":"b9d94f8e1c6c6b7b98eb53cf49c5025a04fbdd221236c027dbf08b81cbb70e38","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"29b1dac7c214deaa3f4f8305102cbc166ac9015a2d3d641f3a539103a97b6c8a","appveyor.yml":"7293e690b6b1fb75cbab1f72ffc5077dd145c806282969b595cc1a82ce1a2e62","examples/deflatedecoder-bufread.rs":"286995f7fa968c3cb935f4a9436db035691112fd1999ad001fb17da1a76162be","examples/deflatedecoder-read.rs":"7d7347a31317d288291847369032cefad5688defe6043a3f0d2a72b8567eb056","examples/deflatedecoder-write.rs":"23723a260ac6916243089666d25e2d7c5fdf390fb2fa20d0c2a957647a0e1880","examples/deflateencoder-bufread.rs":"c9a798336ed81c104fc01c3620380bb3369af90a710a89b19c2402f25c25d375","examples/deflateencoder-read.rs":"3af2fe62fb464c2c38a16099c38ce6ce510356ac47de2fc8a8a46ad1660992d7","examples/deflateencoder-write.rs":"0c6d3590b925a731bdd7e4a899ff5783539a4f48f88a8d95e7acecde5d426521","examples/gzbuilder.rs":"d0fe0fc8b6f302f35af80f61d2cbb4e55b1d511f7894e06756bda0d53f9505f9","examples/gzdecoder-bufread.rs":"2ec57910cb86a03566476f9b65562c2bfc661c7e094fb5b847d84e4127b7dd8d","examples/gzdecoder-read.rs":"af29581f5eadd76f1079b3da73b5cd97557c1abe435014ecad4b3be22518a2bb","examples/gzdecoder-write.rs":"4b14123f9e2d5aa08d1d94fdc911ecc0728cdb9d68888ad2bfd34545975ab6a2","examples/gzencoder-bufread.rs":"ad79e9f8630359ed21b74a1431d49fdb08c0673df7b21e98d0cad05b29357460","examples/gzencoder-read.rs":"b37c7d18e58c916bdaff4d698cbfc7fe99c03b7d440eb386694a268dbc938134","examples/gzencoder-write.rs":"3dc712c3100caab0e29bd8c48314a964392cd2f2443e988dfbe5416909fb5e1d","examples/gzmultidecoder-bufread.rs":"b55840b1139c7351cff67320c88bc8f2e4e74eecc20ed617deb48d27c855a5a4","examples/gzmultidecoder-read.rs":"a5cd59f0ea2543ce8c6ac8a77128a9f9242b0eca27dfd82c7842a2d63930e874","examples/hello_world.txt":"d2a84f4b8b650937ec8f73cd8be2c74add5a911ba64df27458ed8229da804a26","examples/zlibdecoder-bufread.rs":"688999ef801a8ecccb741eb9a6e6a89fbc5c9857bc1fdffd4b613d4522f47407","examples/zlibdecoder-read.rs":"c8d414640ae3e7c356ac06ae3e3802ae88b2db7b40be4f567598335e90f969f4","examples/zlibdecoder-write.rs":"fd581a7bdfb992eba5b96c66eb9e143dabd6970762e8f92fd05215b1566f915c","examples/zlibencoder-bufread.rs":"667d3bdc83878e97d4faae6c820693339799989db1031e976dc52d7bc1e119ce","examples/zlibencoder-read.rs":"8f3e87c001a028f5f38495c1ca4b7b60a92429b0d93f783d7be5c02c4d0043e2","examples/zlibencoder-write.rs":"03e4559325a749ee378739ddc2fb9d43afcf3d60a7be714d0708ec590b2d50af","src/bufreader.rs":"7fc0b74ca751e9e11689d3e57abc3aadbda92f25f2a9a80fca009f43a112642d","src/crc.rs":"2f98a8b14e4e8f1ed6fadb87f62e2c5c23f6019847a1bd5275414bc92f4f061b","src/deflate/bufread.rs":"ed1b17ebeae9dd5549a5c6dfdc983f6b0becd8a588e4674ba36ec463f4b0aad5","src/deflate/mod.rs":"b9123e045fcb205d4f08cc76e904b67d83809349f5699e0ae95d924b73bb4050","src/deflate/read.rs":"8a579ab97396a22cb9196743753d7d6f1c4cc4e7c7ed8f86e4f2d3f6971796cb","src/deflate/write.rs":"3852f51611562237e35791b80dc450558949c173fa875d4b91e13c1d18cf23a7","src/ffi.rs":"296303ccd1967ab866f13661ad9b1336fb2497a53487b0efd08b5600bff30b6b","src/gz/bufread.rs":"b5bf00737dee1b4ffdbe78436726a5a0b12272bf0eadb9e4ab5464bf47eccfd4","src/gz/mod.rs":"b37dde138590a047572f5cf3c5a3d3eaa9032ffb9b9a5dbe567c03bddf56f478","src/gz/read.rs":"d5e5d127a9083ee5ce5a162a2c03965b7fbabc1ca3e221d74bdd68349ba7a7ce","src/gz/write.rs":"3a510433f6f76004599a201a18790c5b2451c1742967665ba51513d79c4f3f0d","src/lib.rs":"65c14a9f37010948c8836b149e21bf48e20ef933d4979e01e59c8b589a3a971c","src/mem.rs":"9e1a4f24b04fac9c4230bc93389997450f2dc24acd3c9df72d66dc9af3d516cb","src/zio.rs":"98133cafdc0014e075c14cd8a271cfd5e67a4ad4572e798f6f62bbe6425d0cff","src/zlib/bufread.rs":"8eff1bb0c2b557ca0428a087f81e5c93b6e5e71176930eb19fc73322a4b7092c","src/zlib/mod.rs":"7e565ec477d26e80eecd583148a21ba778ebb6eb625388f884f95fc623b3db4f","src/zlib/read.rs":"dd34b36a33257d428b449b41738dae79faf4d02955aea4be905fed313d3cf38f","src/zlib/write.rs":"abd3a640d09e82a890f66d18fd4618ad09d7e25c9e1c23fcd3532a7003d742b6","tests/corrupt-file.gz":"083dd284aa1621916a2d0f66ea048c8d3ba7a722b22d0d618722633f51e7d39c","tests/early-flush.rs":"5b12ab43ddb2dbc458b2fdf05fe2245bf8abea554756dfa7bc64a095adfde365","tests/empty-read.rs":"45477d316f77a048d747e9d18292abfec0cac667768385c8a061e18fd1240238","tests/good-file.gz":"87296963e53024a74752179ce7e54087565d358a85d3e65c3b37ef36eaa3d4a6","tests/good-file.txt":"bc4e03658a441fe2ad2df7cd2197144b87e41696f01e327b380e869cd9b485a0","tests/gunzip.rs":"18c2509e8795337faa955bd8429210217ecc6081e1647d3968d10e01ae876bb0","tests/multi.gz":"efa3341da052f95056314cc6920e02a3da15bdef30234b2552fb407812db5cc6","tests/multi.txt":"dbea9325179efe46ea2add94f7b6b745ca983fabb208dc6d34aa064623d7ee23","tests/tokio.rs":"1d256e3d38abc6a9dde87d9ec78dc94ab56670e102d64e2ed649a46ff0d4d615","tests/zero-write.rs":"ff8d0349a540b54363c55807c5fd7fbbdc363d08a536d35a3a40f0ce92c16489"},"package":"4af030962d89d62aa52cd9492083b1cd9b2d1a77764878102a6c0f86b4d5444d"} \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/flate2/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/vendor/flate2/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/vendor/flate2/Cargo.toml 2018-10-24 21:38:11.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/flate2/Cargo.toml 2018-12-05 01:24:32.000000000 +0000 @@ -12,7 +12,7 @@ [package] name = "flate2" -version = "1.0.2" +version = "1.0.3" authors = ["Alex Crichton "] description = "Bindings to miniz.c for DEFLATE compression and decompression exposed as\nReader/Writer streams. Contains bindings for zlib, deflate, and gzip-based\nstreams.\n" homepage = "https://github.com/alexcrichton/flate2-rs" @@ -34,7 +34,7 @@ optional = true [dependencies.miniz-sys] -version = "0.1.7" +version = "0.1.10" optional = true [dependencies.miniz_oxide_c_api] @@ -46,7 +46,7 @@ version = "0.1" optional = true [dev-dependencies.quickcheck] -version = "0.6" +version = "0.7" default-features = false [dev-dependencies.rand] diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/flate2/Cargo.toml.orig rustc-1.31.0+dfsg1+llvm/src/vendor/flate2/Cargo.toml.orig --- rustc-1.30.0+dfsg1+llvm/src/vendor/flate2/Cargo.toml.orig 2018-10-24 21:38:11.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/flate2/Cargo.toml.orig 2018-12-05 01:24:32.000000000 +0000 @@ -2,7 +2,7 @@ name = "flate2" authors = ["Alex Crichton "] -version = "1.0.2" +version = "1.0.3" license = "MIT/Apache-2.0" readme = "README.md" keywords = ["gzip", "flate", "zlib", "encoding"] @@ -21,7 +21,7 @@ [dependencies] libc = "0.2" -miniz-sys = { path = "miniz-sys", version = "0.1.7", optional = true } +miniz-sys = { path = "miniz-sys", version = "0.1.10", optional = true } libz-sys = { version = "1.0", optional = true } tokio-io = { version = "0.1", optional = true } futures = { version = "0.1", optional = true } @@ -29,7 +29,7 @@ [dev-dependencies] rand = "0.5" -quickcheck = { version = "0.6", default-features = false } +quickcheck = { version = "0.7", default-features = false } tokio-core = "0.1" [features] diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/flate2/examples/gzdecoder-write.rs rustc-1.31.0+dfsg1+llvm/src/vendor/flate2/examples/gzdecoder-write.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/flate2/examples/gzdecoder-write.rs 2018-10-24 21:38:11.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/flate2/examples/gzdecoder-write.rs 2018-12-05 01:24:32.000000000 +0000 @@ -8,7 +8,7 @@ // Compress a sample string and print it after transformation. fn main() { let mut e = GzEncoder::new(Vec::new(), Compression::default()); - e.write(b"Hello World").unwrap(); + e.write_all(b"Hello World").unwrap(); let bytes = e.finish().unwrap(); println!("{}", decode_writer(bytes).unwrap()); } @@ -18,7 +18,7 @@ fn decode_writer(bytes: Vec) -> io::Result { let mut writer = Vec::new(); let mut decoder = GzDecoder::new(writer); - decoder.write(&bytes[..])?; + decoder.write_all(&bytes[..])?; decoder.try_finish()?; writer = decoder.finish()?; let return_string = String::from_utf8(writer).expect("String parsing error"); diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/flate2/src/lib.rs rustc-1.31.0+dfsg1+llvm/src/vendor/flate2/src/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/flate2/src/lib.rs 2018-10-24 21:38:11.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/flate2/src/lib.rs 2018-12-05 01:24:32.000000000 +0000 @@ -14,9 +14,12 @@ //! //! This crate consists mainly of three modules, [`read`], [`write`], and //! [`bufread`]. Each module contains a number of types used to encode and -//! decode various streams of data. All types in the [`write`] module work on -//! instances of [`Write`][write], whereas all types in the [`read`] module work on -//! instances of [`Read`][read] and [`bufread`] works with [`BufRead`][bufread]. +//! decode various streams of data. +//! +//! All types in the [`write`] module work on instances of [`Write`][write], +//! whereas all types in the [`read`] module work on instances of +//! [`Read`][read] and [`bufread`] works with [`BufRead`][bufread]. If you +//! are decoding directly from a `&[u8]`, use the [`bufread`] types. //! //! ``` //! use flate2::write::GzEncoder; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/itoa/benches/bench.rs rustc-1.31.0+dfsg1+llvm/src/vendor/itoa/benches/bench.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/itoa/benches/bench.rs 2018-10-24 21:38:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/itoa/benches/bench.rs 2018-12-05 01:24:25.000000000 +0000 @@ -1,7 +1,5 @@ #![cfg_attr(feature = "i128", feature(i128_type, i128))] - #![cfg_attr(feature = "cargo-clippy", allow(cast_lossless))] - #![feature(test)] #![allow(non_snake_case)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/itoa/.cargo-checksum.json rustc-1.31.0+dfsg1+llvm/src/vendor/itoa/.cargo-checksum.json --- rustc-1.30.0+dfsg1+llvm/src/vendor/itoa/.cargo-checksum.json 2018-10-24 21:38:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/itoa/.cargo-checksum.json 2018-12-05 01:24:25.000000000 +0000 @@ -1 +1 @@ -{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"f9b1ca6ae27d1c18215265024629a8960c31379f206d9ed20f64e0b2dcf79805",".travis.yml":"4d95e217e41a0057e49a6fe637bf56bd344014ac136a3c729024ae1a6deae58b","Cargo.toml":"9333fd72ed6454bfb9871f1420437442af3bb7099db858dee5322ae31dc922cb","Cargo.toml.orig":"070420c29d2e3ed3b33f0c6d3bed654bf9d4b628817744133079014abadbec95","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"57b4b49c5ceea9cf94e3856537c01cc1a7e3d071b04d5f5d45155259bfcb83b3","benches/bench.rs":"4cce63083f2e362db65dfad767b777cc39e6555fe635b8551aa485c63080773e","src/lib.rs":"d5d2103aeed48fa1785423f545816db00b200b9538fdd4fd0f0fd7456337b2a4","src/udiv128.rs":"efafb66d62b8229478a448ffb3e11a8ad57f5b336aadd59d5b3bf945cfffba96","tests/test.rs":"55a4b5f21b0f1322d7a42d837ca9f2766eb25416cfcdd9514220fb3bebc0f586"},"package":"5adb58558dcd1d786b5f0bd15f3226ee23486e24b7b58304b60f64dc68e62606"} \ No newline at end of file +{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".cargo_vcs_info.json":"6866f4d14b6799ff440dd8ec8c56ce1a56db06ff2e1fef493559e6c9eed6bb46",".gitignore":"f9b1ca6ae27d1c18215265024629a8960c31379f206d9ed20f64e0b2dcf79805",".travis.yml":"64a8a20ce275a9961b548989432e474c225c0104b630e3ebb6664c30a11a0416","Cargo.toml":"756bd6e9dbd336547e8e982770c4dc36f67cd0b5d90656033f86cf450879674a","Cargo.toml.orig":"eace93cc2f92383ae3101375ff1c779727c600979299d3b32e405602defc571c","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"57b4b49c5ceea9cf94e3856537c01cc1a7e3d071b04d5f5d45155259bfcb83b3","benches/bench.rs":"c4225d539bbc4cee704dcfe59222879b4084bf67d74e0fa973faa69e238c1ff3","src/lib.rs":"21e1c5aa3592989b2a9420303f2fc509b3e55ec7f0ceb2ea01f7fd89758c2cdf","src/udiv128.rs":"efafb66d62b8229478a448ffb3e11a8ad57f5b336aadd59d5b3bf945cfffba96","tests/test.rs":"bca26710b88200a92b0272da6a396a95919a3294a82f928f699b03bd84a838e3"},"package":"1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b"} \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/itoa/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/vendor/itoa/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/vendor/itoa/Cargo.toml 2018-10-24 21:38:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/itoa/Cargo.toml 2018-12-05 01:24:25.000000000 +0000 @@ -12,7 +12,7 @@ [package] name = "itoa" -version = "0.4.2" +version = "0.4.3" authors = ["David Tolnay "] exclude = ["performance.png"] description = "Fast functions for printing integer primitives to an io::Write" @@ -26,3 +26,5 @@ default = ["std"] i128 = [] std = [] +[badges.travis-ci] +repository = "dtolnay/itoa" diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/itoa/Cargo.toml.orig rustc-1.31.0+dfsg1+llvm/src/vendor/itoa/Cargo.toml.orig --- rustc-1.30.0+dfsg1+llvm/src/vendor/itoa/Cargo.toml.orig 2018-10-24 21:38:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/itoa/Cargo.toml.orig 2018-12-05 01:24:25.000000000 +0000 @@ -1,6 +1,6 @@ [package] name = "itoa" -version = "0.4.2" # remember to update html_root_url +version = "0.4.3" # remember to update html_root_url authors = ["David Tolnay "] license = "MIT/Apache-2.0" description = "Fast functions for printing integer primitives to an io::Write" @@ -14,3 +14,6 @@ default = ["std"] i128 = [] std = [] + +[badges] +travis-ci = { repository = "dtolnay/itoa" } diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/itoa/.cargo_vcs_info.json rustc-1.31.0+dfsg1+llvm/src/vendor/itoa/.cargo_vcs_info.json --- rustc-1.30.0+dfsg1+llvm/src/vendor/itoa/.cargo_vcs_info.json 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/itoa/.cargo_vcs_info.json 2018-12-05 01:24:25.000000000 +0000 @@ -0,0 +1,5 @@ +{ + "git": { + "sha1": "caec2745c6f2755a9e698ff73c2c4e7bfcdc2111" + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/itoa/src/lib.rs rustc-1.31.0+dfsg1+llvm/src/vendor/itoa/src/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/itoa/src/lib.rs 2018-10-24 21:38:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/itoa/src/lib.rs 2018-12-05 01:24:25.000000000 +0000 @@ -6,13 +6,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![doc(html_root_url = "https://docs.rs/itoa/0.4.2")] - +#![doc(html_root_url = "https://docs.rs/itoa/0.4.3")] #![cfg_attr(not(feature = "std"), no_std)] - -#![cfg_attr(feature = "i128", feature(i128_type, i128))] - -#![cfg_attr(feature = "cargo-clippy", allow(cast_lossless, unreadable_literal))] +#![cfg_attr( + feature = "cargo-clippy", + allow(cast_lossless, unreadable_literal) +)] #[cfg(feature = "i128")] mod udiv128; @@ -26,14 +25,63 @@ /// Write integer to an `io::Write`. #[cfg(feature = "std")] #[inline] -pub fn write(wr: W, value: V) -> io::Result { - value.write(wr) +pub fn write(mut wr: W, value: V) -> io::Result { + let mut buf = Buffer::new(); + let s = buf.format(value); + try!(wr.write_all(s.as_bytes())); + Ok(s.len()) } /// Write integer to an `fmt::Write`. #[inline] -pub fn fmt(wr: W, value: V) -> fmt::Result { - value.fmt(wr) +pub fn fmt(mut wr: W, value: V) -> fmt::Result { + let mut buf = Buffer::new(); + wr.write_str(buf.format(value)) +} + +/// A safe API for formatting integers to text. +/// +/// # Example +/// +/// ```rust +/// let mut buffer = itoa::Buffer::new(); +/// let printed = buffer.format(1234); +/// assert_eq!(printed, "1234"); +/// ``` +#[derive(Copy)] +pub struct Buffer { + bytes: [u8; I128_MAX_LEN], +} + +impl Default for Buffer { + #[inline] + fn default() -> Buffer { + Buffer::new() + } +} + +impl Clone for Buffer { + #[inline] + fn clone(&self) -> Self { + Buffer::new() + } +} + +impl Buffer { + /// This is a cheap operation; you don't need to worry about reusing buffers + /// for efficiency. + #[inline] + pub fn new() -> Buffer { + Buffer { + bytes: unsafe { mem::uninitialized() }, + } + } + + /// Print an integer into this buffer and return a reference to its string representation + /// within the buffer. + pub fn format(&mut self, i: I) -> &str { + i.write(self) + } } // Seal to prevent downstream implementations of the Integer trait. @@ -47,20 +95,15 @@ pub trait Integer: private::Sealed { // Not public API. #[doc(hidden)] - #[cfg(feature = "std")] - fn write(self, W) -> io::Result; - - // Not public API. - #[doc(hidden)] - fn fmt(self, W) -> fmt::Result; + fn write<'a>(self, buf: &'a mut Buffer) -> &'a str; } trait IntegerPrivate { fn write_to(self, buf: &mut B) -> &[u8]; } -const DEC_DIGITS_LUT: &'static[u8] = - b"0001020304050607080910111213141516171819\ +const DEC_DIGITS_LUT: &'static [u8] = b"\ + 0001020304050607080910111213141516171819\ 2021222324252627282930313233343536373839\ 4041424344454647484950515253545556575859\ 6061626364656667686970717273747576777879\ @@ -71,20 +114,16 @@ macro_rules! impl_IntegerCommon { ($max_len:expr, $t:ident) => { impl Integer for $t { - #[cfg(feature = "std")] #[inline] - fn write(self, mut wr: W) -> io::Result { - let mut buf: [u8; $max_len] = unsafe { mem::uninitialized() }; - let bytes = self.write_to(&mut buf); - try!(wr.write_all(bytes)); - Ok(bytes.len()) - } - - #[inline] - fn fmt(self, mut wr: W) -> fmt::Result { - let mut buf: [u8; $max_len] = unsafe { mem::uninitialized() }; - let bytes = self.write_to(&mut buf); - wr.write_str(unsafe { str::from_utf8_unchecked(bytes) }) + fn write<'a>(self, buf: &'a mut Buffer) -> &'a str { + unsafe { + debug_assert!($max_len <= I128_MAX_LEN); + let buf = mem::transmute::<&mut [u8; I128_MAX_LEN], &mut [u8; $max_len]>( + &mut buf.bytes, + ); + let bytes = self.write_to(buf); + str::from_utf8_unchecked(bytes) + } } } @@ -176,7 +215,7 @@ I16_MAX_LEN => i16, U16_MAX_LEN => u16, I32_MAX_LEN => i32, - U32_MAX_LEN => u32 + U32_MAX_LEN => u32 as u32); impl_Integer!(I64_MAX_LEN => i64, U64_MAX_LEN => u64 as u64); @@ -254,7 +293,6 @@ #[cfg(all(feature = "i128"))] const U128_MAX_LEN: usize = 39; -#[cfg(all(feature = "i128"))] const I128_MAX_LEN: usize = 40; #[cfg(all(feature = "i128"))] diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/itoa/tests/test.rs rustc-1.31.0+dfsg1+llvm/src/vendor/itoa/tests/test.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/itoa/tests/test.rs 2018-10-24 21:38:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/itoa/tests/test.rs 2018-12-05 01:24:25.000000000 +0000 @@ -1,7 +1,8 @@ #![cfg_attr(feature = "i128", feature(i128_type, i128))] - -#![cfg_attr(feature = "cargo-clippy", allow(cast_lossless, string_lit_as_bytes))] - +#![cfg_attr( + feature = "cargo-clippy", + allow(cast_lossless, string_lit_as_bytes) +)] #![allow(non_snake_case)] extern crate itoa; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/itoa/.travis.yml rustc-1.31.0+dfsg1+llvm/src/vendor/itoa/.travis.yml --- rustc-1.30.0+dfsg1+llvm/src/vendor/itoa/.travis.yml 2018-10-24 21:38:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/itoa/.travis.yml 2018-12-05 01:24:25.000000000 +0000 @@ -4,7 +4,9 @@ matrix: include: - rust: stable + - FEATURES="i128" - rust: beta + - FEATURES="i128" - rust: nightly env: - FEATURES="i128" diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/log/.cargo-checksum.json rustc-1.31.0+dfsg1+llvm/src/vendor/log/.cargo-checksum.json --- rustc-1.30.0+dfsg1+llvm/src/vendor/log/.cargo-checksum.json 2018-10-24 21:38:19.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/log/.cargo-checksum.json 2018-12-05 01:24:26.000000000 +0000 @@ -1 +1 @@ -{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"12cc0f91b51fedf41ae1670d1624ee1d78a284bdb101645b60a06a12de16c069",".travis.yml":"8e95f3543ff36e1fd0e2e2fcc98b31e20dcc19d220f3d7d19bfb9aeb61030823","CHANGELOG.md":"eb0b1a32f7132a110bca947b6ada9dfa5a036931aa9a97c8fb842f6daa0a3efd","Cargo.toml":"a501cb04dae75cb780fe56f445060c3b63380fcaed93926387db7e3de787fb51","Cargo.toml.orig":"aaa2e48598e6d37cd7ea1e098f90ff4127513620028f6ec6447609388964957d","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"224146f378b819f78b735156c93002d81dd9d1998b221bf26ca2bca04223f29e","appveyor.yml":"d5376a881aef6dc3bed6a6b51f1f1c3801b88fc77a12895f6953190256e965bc","src/lib.rs":"6c86a076d74e81c5d521bb9ab81e648468e17775f7f84dce0de277db1540d6cc","src/macros.rs":"d5ad0e725cc93012496ca2529aff70c3f896d37e4536c6be849837e8d9c9b286","src/serde.rs":"a5ae50d6f5ac538a5ca57ee58031a2582afa6989c741574584756632a4131ba7","tests/filters.rs":"6aee024d4594b4fde772e35c5d3318e5aa5d9aa4eaeafb04e4c7c922be4ac837"},"package":"cba860f648db8e6f269df990180c2217f333472b4a6e901e97446858487971e2"} \ No newline at end of file +{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".cargo_vcs_info.json":"25aebd6cce4993172e05e26454032cdc621acdf173687f2785263a6782f6f557",".gitignore":"12cc0f91b51fedf41ae1670d1624ee1d78a284bdb101645b60a06a12de16c069",".travis.yml":"8e95f3543ff36e1fd0e2e2fcc98b31e20dcc19d220f3d7d19bfb9aeb61030823","CHANGELOG.md":"f201f429d849e6aaa5c3948770bf7fa29bc77358346a369a2a88cab0e8b76edb","Cargo.toml":"8f9b47fadc3b8250a3869e4bf4da63f6ccf4522bbd962ad5c39be9d072189d5e","Cargo.toml.orig":"293b42130c34ec59a7639e5dca441a57bfdba83c0f9d740cea00fc76269e8659","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"224146f378b819f78b735156c93002d81dd9d1998b221bf26ca2bca04223f29e","appveyor.yml":"d5376a881aef6dc3bed6a6b51f1f1c3801b88fc77a12895f6953190256e965bc","src/lib.rs":"a6590c47262193de32b762330694cd97bc68d0a29840ae86f5fb55c88e12e960","src/macros.rs":"2d180878886c945c6f3a11f556a84c7cef86f6743eaf7063b343754f8aab09d0","src/serde.rs":"a5ae50d6f5ac538a5ca57ee58031a2582afa6989c741574584756632a4131ba7","tests/filters.rs":"6aee024d4594b4fde772e35c5d3318e5aa5d9aa4eaeafb04e4c7c922be4ac837"},"package":"d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f"} \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/log/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/vendor/log/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/vendor/log/Cargo.toml 2018-10-24 21:38:19.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/log/Cargo.toml 2018-12-05 01:24:26.000000000 +0000 @@ -12,7 +12,7 @@ [package] name = "log" -version = "0.4.4" +version = "0.4.5" authors = ["The Rust Project Developers"] description = "A lightweight logging facade for Rust\n" homepage = "https://github.com/rust-lang/log" diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/log/Cargo.toml.orig rustc-1.31.0+dfsg1+llvm/src/vendor/log/Cargo.toml.orig --- rustc-1.30.0+dfsg1+llvm/src/vendor/log/Cargo.toml.orig 2018-10-24 21:38:19.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/log/Cargo.toml.orig 2018-12-05 01:24:26.000000000 +0000 @@ -1,7 +1,7 @@ [package] name = "log" -version = "0.4.4" # remember to update html_root_url +version = "0.4.5" # remember to update html_root_url authors = ["The Rust Project Developers"] license = "MIT/Apache-2.0" readme = "README.md" diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/log/.cargo_vcs_info.json rustc-1.31.0+dfsg1+llvm/src/vendor/log/.cargo_vcs_info.json --- rustc-1.30.0+dfsg1+llvm/src/vendor/log/.cargo_vcs_info.json 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/log/.cargo_vcs_info.json 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,5 @@ +{ + "git": { + "sha1": "d711a6bf4891aedbafddad684b6b42ddc5193c51" + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/log/CHANGELOG.md rustc-1.31.0+dfsg1+llvm/src/vendor/log/CHANGELOG.md --- rustc-1.30.0+dfsg1+llvm/src/vendor/log/CHANGELOG.md 2018-10-24 21:38:19.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/log/CHANGELOG.md 2018-12-05 01:24:26.000000000 +0000 @@ -2,6 +2,13 @@ ## [Unreleased] +## [0.4.5] - 2018-09-03 + +### Improved + +* Make `log`'s internal helper macros less likely to conflict with user-defined + macros. + ## [0.4.4] - 2018-08-17 ### Improved @@ -99,7 +106,8 @@ Look at the [release tags] for information about older releases. -[Unreleased]: https://github.com/rust-lang-nursery/log/compare/0.4.4...HEAD +[Unreleased]: https://github.com/rust-lang-nursery/log/compare/0.4.5...HEAD +[0.4.4]: https://github.com/rust-lang-nursery/log/compare/0.4.4...0.4.5 [0.4.4]: https://github.com/rust-lang-nursery/log/compare/0.4.3...0.4.4 [0.4.3]: https://github.com/rust-lang-nursery/log/compare/0.4.2...0.4.3 [0.4.2]: https://github.com/rust-lang-nursery/log/compare/0.4.1...0.4.2 diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/log/src/lib.rs rustc-1.31.0+dfsg1+llvm/src/vendor/log/src/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/log/src/lib.rs 2018-10-24 21:38:19.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/log/src/lib.rs 2018-12-05 01:24:26.000000000 +0000 @@ -270,7 +270,7 @@ #![doc( html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://www.rust-lang.org/favicon.ico", - html_root_url = "https://docs.rs/log/0.4.4" + html_root_url = "https://docs.rs/log/0.4.5" )] #![warn(missing_docs)] #![deny(missing_debug_implementations)] diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/log/src/macros.rs rustc-1.31.0+dfsg1+llvm/src/vendor/log/src/macros.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/log/src/macros.rs 2018-10-24 21:38:19.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/log/src/macros.rs 2018-12-05 01:24:26.000000000 +0000 @@ -35,13 +35,13 @@ let lvl = $lvl; if lvl <= $crate::STATIC_MAX_LEVEL && lvl <= $crate::max_level() { $crate::__private_api_log( - log_format_args!($($arg)+), + __log_format_args!($($arg)+), lvl, - &($target, log_module_path!(), log_file!(), log_line!()), + &($target, __log_module_path!(), __log_file!(), __log_line!()), ); } }); - ($lvl:expr, $($arg:tt)+) => (log!(target: log_module_path!(), $lvl, $($arg)+)) + ($lvl:expr, $($arg:tt)+) => (log!(target: __log_module_path!(), $lvl, $($arg)+)) } /// Logs a message at the error level. @@ -206,7 +206,7 @@ && $crate::__private_api_enabled(lvl, $target) }}; ($lvl:expr) => { - log_enabled!(target: log_module_path!(), $lvl) + log_enabled!(target: __log_module_path!(), $lvl) }; } @@ -222,7 +222,7 @@ // local macros, and invoke format_args directly. #[doc(hidden)] #[macro_export] -macro_rules! log_format_args { +macro_rules! __log_format_args { ($($args:tt)*) => { format_args!($($args)*) }; @@ -230,7 +230,7 @@ #[doc(hidden)] #[macro_export] -macro_rules! log_module_path { +macro_rules! __log_module_path { () => { module_path!() }; @@ -238,7 +238,7 @@ #[doc(hidden)] #[macro_export] -macro_rules! log_file { +macro_rules! __log_file { () => { file!() }; @@ -246,7 +246,7 @@ #[doc(hidden)] #[macro_export] -macro_rules! log_line { +macro_rules! __log_line { () => { line!() }; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/minifier/.cargo-checksum.json rustc-1.31.0+dfsg1+llvm/src/vendor/minifier/.cargo-checksum.json --- rustc-1.30.0+dfsg1+llvm/src/vendor/minifier/.cargo-checksum.json 2018-10-24 21:38:23.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/minifier/.cargo-checksum.json 2018-12-05 01:24:25.000000000 +0000 @@ -1 +1 @@ -{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"944bf600c6230664922a011cbca026699969f2f89f6c7ff689835836ccd7b1de",".travis.yml":"a31219b294de0c3ac672b7ae4ee7d4399c2e83859424bf19409f5a57ad29c40d","Cargo.toml":"ff5902f0d5ae0fc8abf51b47967abfa09b4de096b49de5bc0118e92b0aaa2018","Cargo.toml.orig":"3eaee031dc4a3a6b054b8ee710eeeb83dfb8eb31894a0530233b97755386a0e7","LICENSE":"d64fe3199be0c90d1f88b363e6b567d5812f64c01accc8957e71381598a3d670","README.md":"4f17fff99fd4094b8032cb367e66131fd84e190a087c88addefbe229667d0a6e","appveyor.yml":"fea1d5001886379c759f5d80e757c8ced54e448dcf45dcce4b94a4571b65d967","src/css/css.rs":"f4a2dabccc2693c383dca6341d129736bb963b81bc3576c1afddeec47411c092","src/css/mod.rs":"5fa129f339574aeea7f63b2d4328c53d569d1f1a3c945b7198294f52323254d3","src/css/token.rs":"be98b7e8c553c4ecae1691e844bb88041ebef3880b5b07b947b972360691c74c","src/html.rs":"391abe3139941a57efe13cbb05aa9d42e4a4446a2a1ef7a658924c9c5cb75e09","src/js/js.rs":"84ccb1698187f732de7ef0e6c35c5be9b71f694a18b50a836ed5b62e20e8d8cf","src/js/mod.rs":"383a02441af9e0bad41f5bcf99d744f33eb3190e2151aea9f4f2e4175e54e922","src/js/token.rs":"e4be8b550c47d3979bb10a92b234536c1ac55fcc1ab04c713923fe1744db3ebe","src/json/json_minifier.rs":"9526327b31822778fc59e3266147d986d66ff7e3bb4958cae800dee987188d7b","src/json/mod.rs":"703726c763bc2ac51306b22e583986ab3ea2768f85516cbdfd52bd30dced9592","src/json/read/byte_to_char.rs":"e7a4512e118577b8bc0dc7f7aa1f2e49addefbf0b703dbcc229a7eeb55d563f6","src/json/read/internal_buffer.rs":"c68bd3e3bab1e6f3384f039ff412d285c166ad02487d04c53576446d91eee23d","src/json/read/internal_reader.rs":"ea648bf2d25d44e52832b7c3735c746530898d3ab9e167e5948b0837491da790","src/json/read/json_read.rs":"758f7ef32b6dd741cc261ceb3efd86308b5b1660e40c1511bd139eead99ebca7","src/json/string.rs":"a9fccc4e9221e2cc4f7d2d10594a751f223ae3cbe618f9b01e71ff9d2a8aea42","src/lib.rs":"dbce5a92f69de45f34e7b4c4565a1fbeed9f961a6f346ceea4082ee8c83bb55a","src/main.rs":"5e71ba75342871eee161da479bda9ab2fb399284fb6cf346f0f12405c80fc73e","tests/files/test.json":"e07a148ef24385057cb7420209a630758c6ce80970bd54c8ffee5be207205608"},"package":"9908ed7c62f990c21ab41fdca53a864a3ada0da69d8729c4de727b397e27bc11"} \ No newline at end of file +{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".cargo_vcs_info.json":"a0512657ca53dba1f38915529214174d743b98eeb0c9da849d1351a43fe324f1",".gitignore":"944bf600c6230664922a011cbca026699969f2f89f6c7ff689835836ccd7b1de",".travis.yml":"a31219b294de0c3ac672b7ae4ee7d4399c2e83859424bf19409f5a57ad29c40d","Cargo.toml":"4205ad85879f1207a06890d93d96473f9060fa83f23edc1bb225cb981c9a3b61","Cargo.toml.orig":"957de4c5b6a072697bdfd1ed9d4e68a03b15f6932b0403eabffbc53a5371cbd2","LICENSE":"d64fe3199be0c90d1f88b363e6b567d5812f64c01accc8957e71381598a3d670","README.md":"4f17fff99fd4094b8032cb367e66131fd84e190a087c88addefbe229667d0a6e","appveyor.yml":"fea1d5001886379c759f5d80e757c8ced54e448dcf45dcce4b94a4571b65d967","src/css/css.rs":"3b818259370cff781e9e93a3c05d76c28adbad6110bb67816eb5c3f8c8659248","src/css/mod.rs":"5fa129f339574aeea7f63b2d4328c53d569d1f1a3c945b7198294f52323254d3","src/css/token.rs":"844b6a5a4b3dcf572b73249a40159185a8adb0862f895282c9eb1390331b74dc","src/html.rs":"391abe3139941a57efe13cbb05aa9d42e4a4446a2a1ef7a658924c9c5cb75e09","src/js/js.rs":"84ccb1698187f732de7ef0e6c35c5be9b71f694a18b50a836ed5b62e20e8d8cf","src/js/mod.rs":"383a02441af9e0bad41f5bcf99d744f33eb3190e2151aea9f4f2e4175e54e922","src/js/token.rs":"e4be8b550c47d3979bb10a92b234536c1ac55fcc1ab04c713923fe1744db3ebe","src/json/json_minifier.rs":"9526327b31822778fc59e3266147d986d66ff7e3bb4958cae800dee987188d7b","src/json/mod.rs":"703726c763bc2ac51306b22e583986ab3ea2768f85516cbdfd52bd30dced9592","src/json/read/byte_to_char.rs":"e7a4512e118577b8bc0dc7f7aa1f2e49addefbf0b703dbcc229a7eeb55d563f6","src/json/read/internal_buffer.rs":"c68bd3e3bab1e6f3384f039ff412d285c166ad02487d04c53576446d91eee23d","src/json/read/internal_reader.rs":"ea648bf2d25d44e52832b7c3735c746530898d3ab9e167e5948b0837491da790","src/json/read/json_read.rs":"758f7ef32b6dd741cc261ceb3efd86308b5b1660e40c1511bd139eead99ebca7","src/json/string.rs":"a9fccc4e9221e2cc4f7d2d10594a751f223ae3cbe618f9b01e71ff9d2a8aea42","src/lib.rs":"dbce5a92f69de45f34e7b4c4565a1fbeed9f961a6f346ceea4082ee8c83bb55a","src/main.rs":"5e71ba75342871eee161da479bda9ab2fb399284fb6cf346f0f12405c80fc73e","tests/files/test.json":"e07a148ef24385057cb7420209a630758c6ce80970bd54c8ffee5be207205608"},"package":"96c269bb45c39b333392b2b18ad71760b34ac65666591386b0e959ed58b3f474"} \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/minifier/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/vendor/minifier/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/vendor/minifier/Cargo.toml 2018-10-24 21:38:23.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/minifier/Cargo.toml 2018-12-05 01:24:25.000000000 +0000 @@ -12,7 +12,7 @@ [package] name = "minifier" -version = "0.0.19" +version = "0.0.20" authors = ["Guillaume Gomez "] description = "Minifier tool/lib for JS/CSS/JSON files" documentation = "https://docs.rs/minifier-rs" diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/minifier/Cargo.toml.orig rustc-1.31.0+dfsg1+llvm/src/vendor/minifier/Cargo.toml.orig --- rustc-1.30.0+dfsg1+llvm/src/vendor/minifier/Cargo.toml.orig 2018-10-24 21:38:23.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/minifier/Cargo.toml.orig 2018-12-05 01:24:25.000000000 +0000 @@ -1,6 +1,6 @@ [package] name = "minifier" -version = "0.0.19" +version = "0.0.20" authors = ["Guillaume Gomez "] description = "Minifier tool/lib for JS/CSS/JSON files" diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/minifier/.cargo_vcs_info.json rustc-1.31.0+dfsg1+llvm/src/vendor/minifier/.cargo_vcs_info.json --- rustc-1.30.0+dfsg1+llvm/src/vendor/minifier/.cargo_vcs_info.json 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/minifier/.cargo_vcs_info.json 2018-12-05 01:24:25.000000000 +0000 @@ -0,0 +1,5 @@ +{ + "git": { + "sha1": "1360410cf246854f5433297852869ae74add75e1" + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/minifier/src/css/css.rs rustc-1.31.0+dfsg1+llvm/src/vendor/minifier/src/css/css.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/minifier/src/css/css.rs 2018-10-24 21:38:23.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/minifier/src/css/css.rs 2018-12-05 01:24:25.000000000 +0000 @@ -253,3 +253,14 @@ let expected = ".docblock:not(.type-decl) a:not(.srclink){}"; assert_eq!(minify(s).expect("minify failed"), expected.to_owned()); } + +#[test] +fn check_whitespaces_in_calc() { + let s = ".foo { width: calc(130px + 10%); }"; + let expected = ".foo{width:calc(130px + 10%);}"; + assert_eq!(minify(s).expect("minify failed"), expected.to_owned()); + + let s = ".foo { width: calc(130px + (45% - 10% + (12 * 2px))); }"; + let expected = ".foo{width:calc(130px + (45% - 10% + (12 * 2px)));}"; + assert_eq!(minify(s).expect("minify failed"), expected.to_owned()); +} \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/minifier/src/css/token.rs rustc-1.31.0+dfsg1+llvm/src/vendor/minifier/src/css/token.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/minifier/src/css/token.rs 2018-10-24 21:38:23.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/minifier/src/css/token.rs 2018-12-05 01:24:25.000000000 +0000 @@ -127,6 +127,60 @@ *self == ReservedChar::Tab || *self == ReservedChar::Backline } + + fn is_operator(&self) -> bool { + Operator::try_from(*self).is_ok() + } +} + +#[derive(Debug, PartialEq, Eq, Clone, Copy)] +pub enum Operator { + Plus, + Multiply, + Minus, + Modulo, + Divide, +} + +impl fmt::Display for Operator { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", + match *self { + Operator::Plus => '+', + Operator::Multiply => '*', + Operator::Minus => '-', + Operator::Modulo => '%', + Operator::Divide => '/', + }) + } +} + +impl MyTryFrom for Operator { + type Error = &'static str; + + fn try_from(value: char) -> Result { + match value { + '+' => Ok(Operator::Plus), + '*' => Ok(Operator::Multiply), + '-' => Ok(Operator::Minus), + '%' => Ok(Operator::Modulo), + '/' => Ok(Operator::Divide), + _ => Err("Unknown operator"), + } + } +} + +impl MyTryFrom for Operator { + type Error = &'static str; + + fn try_from(value: ReservedChar) -> Result { + match value { + ReservedChar::Slash => Ok(Operator::Divide), + ReservedChar::Star => Ok(Operator::Multiply), + ReservedChar::Plus => Ok(Operator::Plus), + _ => Err("Unknown operator"), + } + } } #[derive(Eq, PartialEq, Clone, Debug)] @@ -223,6 +277,7 @@ SelectorElement(SelectorElement<'a>), String(&'a str), SelectorOperator(SelectorOperator), + Operator(Operator), } impl<'a> fmt::Display for Token<'a> { @@ -237,6 +292,7 @@ Token::SelectorElement(ref se) => write!(f, "{}", se), Token::String(s) => write!(f, "{}", s), Token::SelectorOperator(so) => write!(f, "{}", so), + Token::Operator(op) => write!(f, "{}", op), } } } @@ -290,6 +346,14 @@ _ => false, } } + + fn is_operator(&self) -> bool { + match *self { + Token::Operator(_) => true, + Token::Char(c) => c.is_operator(), + _ => false, + } + } } impl<'a> PartialEq for Token<'a> { @@ -492,10 +556,14 @@ }, !v.last().unwrap_or(&Token::Char(ReservedChar::Space)).is_useless() && (!v.last().unwrap_or(&Token::Char(ReservedChar::OpenCurlyBrace)).is_char() || + v.last().unwrap_or(&Token::Char(ReservedChar::OpenCurlyBrace)).is_operator() || v.last().unwrap_or(&Token::Char(ReservedChar::OpenCurlyBrace)) .get_char() == Some(ReservedChar::CloseParenthese)) => { v.push(Token::Char(ReservedChar::Space)); }, + let Ok(op) = Operator::try_from(c) => { + v.push(Token::Operator(op)); + }, } start = pos + 1; } @@ -505,14 +573,30 @@ fn clean_tokens<'a>(mut v: Vec>) -> Vec> { let mut i = 0; + let mut is_in_calc = false; + let mut paren = 0; while i < v.len() { + if v[i] == Token::Other("calc") { + is_in_calc = true; + } else if is_in_calc == true { + if v[i] == Token::Char(ReservedChar::CloseParenthese) { + paren -= 1; + is_in_calc = paren != 0; + } else if v[i] == Token::Char(ReservedChar::OpenParenthese) { + paren += 1; + } + } if v[i].is_useless() { - if (i > 0 && ((v[i - 1].is_char() && + if is_in_calc == false && + ((i > 0 && ((v[i - 1].is_char() && v[i - 1] != Token::Char(ReservedChar::CloseParenthese)) || v[i - 1].is_a_media() || v[i - 1].is_a_license())) || - (i < v.len() - 1 && v[i + 1].is_char()) { + (i < v.len() - 1 && v[i + 1].is_char())) { + v.remove(i); + continue + } else if is_in_calc == true && v[i - 1].is_useless() { v.remove(i); continue } diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/pkg-config/.cargo-checksum.json rustc-1.31.0+dfsg1+llvm/src/vendor/pkg-config/.cargo-checksum.json --- rustc-1.30.0+dfsg1+llvm/src/vendor/pkg-config/.cargo-checksum.json 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/pkg-config/.cargo-checksum.json 2018-12-05 01:24:26.000000000 +0000 @@ -1 +1 @@ -{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"957f19488ac2a2ee9ec6f85f7642b422e4ed0793acfdc74e86a0e4cf981de808",".travis.yml":"2a19febfa814bf6758fbfeeff397f56abf450703a356db40ec2e281c1e80befa","CHANGELOG.md":"f815043afec3567c3a9acfe5dc4447aea7caa27d34c450962a78bff2a006291f","Cargo.toml":"7323b0704324b534ab5d41beafde68e5713b022211fafbfb07c5ba4b592c6507","Cargo.toml.orig":"1dff3a5bb571b5a68aed13a73e0d392c12d4aeb865f8a04d0cc6e633d0cb97c7","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"14261707d3d887a7fef40e3b11d7361968c1026f5da0b473a9b841e11555f444","src/lib.rs":"91170a5cb084473d6e8c243278bb81f34fd07c735b05865673ec1c17d014ae52","tests/escape.pc":"00caa4136799dbe5bd504239ba90d1156c12def365c8d761da319fe8a83b398e","tests/foo.pc":"f77712847e77ea81ac6362de5861dc0eddf14b9c07dce1853b3e3e587ffcac5e","tests/framework.pc":"304fdb6cea92973650e410ab1f70ce1ebeb7718af3f139e806efbf182acd565c","tests/test.rs":"5b42ed42b960b94b14b735b41b34f1251c4760d84e5fefe1103a93eecae2718f"},"package":"104630aa1c83213cbc76db0703630fcb0421dac3585063be4ce9a8a2feeaa745"} \ No newline at end of file +{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"957f19488ac2a2ee9ec6f85f7642b422e4ed0793acfdc74e86a0e4cf981de808",".travis.yml":"f2b3b481e61dee9f83649f2079c7637fef1f3e4c181926bf77d39128f3ea82c7","CHANGELOG.md":"f815043afec3567c3a9acfe5dc4447aea7caa27d34c450962a78bff2a006291f","Cargo.toml":"8da01bb8ffaa01b26e5a4adfee7e2e98fac8500efb9898895ae07aaffd3c80a8","Cargo.toml.orig":"8272a86b09a7788f74adb760eeab160e88677b671b394ec707545cb6fa4fa6f2","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"14261707d3d887a7fef40e3b11d7361968c1026f5da0b473a9b841e11555f444","src/lib.rs":"940764550a50b8e0bca996c25a989510718f08521a2ce78e3a7bd1a6e56e4c0f","tests/escape.pc":"00caa4136799dbe5bd504239ba90d1156c12def365c8d761da319fe8a83b398e","tests/foo.pc":"f77712847e77ea81ac6362de5861dc0eddf14b9c07dce1853b3e3e587ffcac5e","tests/framework.pc":"304fdb6cea92973650e410ab1f70ce1ebeb7718af3f139e806efbf182acd565c","tests/test.rs":"5b42ed42b960b94b14b735b41b34f1251c4760d84e5fefe1103a93eecae2718f"},"package":"676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c"} \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/pkg-config/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/vendor/pkg-config/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/vendor/pkg-config/Cargo.toml 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/pkg-config/Cargo.toml 2018-12-05 01:24:26.000000000 +0000 @@ -12,7 +12,7 @@ [package] name = "pkg-config" -version = "0.3.13" +version = "0.3.14" authors = ["Alex Crichton "] description = "A library to run the pkg-config system tool at build time in order to be used in\nCargo build scripts.\n" documentation = "https://docs.rs/pkg-config" diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/pkg-config/Cargo.toml.orig rustc-1.31.0+dfsg1+llvm/src/vendor/pkg-config/Cargo.toml.orig --- rustc-1.30.0+dfsg1+llvm/src/vendor/pkg-config/Cargo.toml.orig 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/pkg-config/Cargo.toml.orig 2018-12-05 01:24:26.000000000 +0000 @@ -1,7 +1,7 @@ [package] name = "pkg-config" -version = "0.3.13" +version = "0.3.14" authors = ["Alex Crichton "] license = "MIT/Apache-2.0" repository = "https://github.com/alexcrichton/pkg-config-rs" diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/pkg-config/src/lib.rs rustc-1.31.0+dfsg1+llvm/src/vendor/pkg-config/src/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/pkg-config/src/lib.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/pkg-config/src/lib.rs 2018-12-05 01:24:26.000000000 +0000 @@ -485,28 +485,20 @@ self.include_paths.push(PathBuf::from(val)); } "-l" => { - let libname = if is_msvc { - // These are provided by the CRT with MSVC - if ["m", "c", "pthread"].contains(&val) { - continue; - } - - // We need to convert -lfoo to foo.lib for MSVC as that - // is the name of the import library - format!("{}.lib", val) - } else { - val.to_string() - }; + // These are provided by the CRT with MSVC + if is_msvc && ["m", "c", "pthread"].contains(&val) { + continue; + } if statik && is_static_available(val, &dirs) { - let meta = format!("rustc-link-lib=static={}", libname); + let meta = format!("rustc-link-lib=static={}", val); config.print_metadata(&meta); } else { - let meta = format!("rustc-link-lib={}", libname); + let meta = format!("rustc-link-lib={}", val); config.print_metadata(&meta); } - self.libs.push(libname); + self.libs.push(val.to_string()); } "-D" => { let mut iter = val.split("="); diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/pkg-config/.travis.yml rustc-1.31.0+dfsg1+llvm/src/vendor/pkg-config/.travis.yml --- rustc-1.30.0+dfsg1+llvm/src/vendor/pkg-config/.travis.yml 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/pkg-config/.travis.yml 2018-12-05 01:24:26.000000000 +0000 @@ -1,6 +1,5 @@ language: rust rust: - - 1.13.0 - stable - beta - nightly diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/proc-macro2/build.rs rustc-1.31.0+dfsg1+llvm/src/vendor/proc-macro2/build.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/proc-macro2/build.rs 2018-10-24 21:38:14.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/proc-macro2/build.rs 2018-12-05 01:24:25.000000000 +0000 @@ -1,21 +1,67 @@ use std::env; +use std::process::Command; +use std::str; fn main() { println!("cargo:rerun-if-changed=build.rs"); let target = env::var("TARGET").unwrap(); - maybe_enable_use_proc_macro(&target); + let minor = match rustc_minor_version() { + Some(n) => n, + None => return, + }; + + if minor >= 26 { + println!("cargo:rustc-cfg=u128"); + } + + if !enable_use_proc_macro(&target) { + return; + } + println!("cargo:rustc-cfg=use_proc_macro"); + + // Rust 1.29 stabilized the necessary APIs in the `proc_macro` crate + if (minor >= 29 && !cfg!(procmacro2_semver_exempt)) || cfg!(feature = "nightly") { + println!("cargo:rustc-cfg=wrap_proc_macro"); + + if cfg!(procmacro2_semver_exempt) { + println!("cargo:rustc-cfg=super_unstable"); + // https://github.com/alexcrichton/proc-macro2/issues/147 + println!("cargo:rustc-cfg=procmacro2_semver_exempt"); + } + } + + if minor == 29 { + println!("cargo:rustc-cfg=slow_extend"); + } } -fn maybe_enable_use_proc_macro(target: &str) { +fn enable_use_proc_macro(target: &str) -> bool { // wasm targets don't have the `proc_macro` crate, disable this feature. if target.contains("wasm32") { - return; + return false; } // Otherwise, only enable it if our feature is actually enabled. - if cfg!(feature = "proc-macro") { - println!("cargo:rustc-cfg=use_proc_macro"); + cfg!(feature = "proc-macro") +} + +fn rustc_minor_version() -> Option { + macro_rules! otry { + ($e:expr) => { + match $e { + Some(e) => e, + None => return None, + } + }; + } + let rustc = otry!(env::var_os("RUSTC")); + let output = otry!(Command::new(rustc).arg("--version").output().ok()); + let version = otry!(str::from_utf8(&output.stdout).ok()); + let mut pieces = version.split('.'); + if pieces.next() != Some("rustc 1") { + return None; } + otry!(pieces.next()).parse().ok() } diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/proc-macro2/.cargo-checksum.json rustc-1.31.0+dfsg1+llvm/src/vendor/proc-macro2/.cargo-checksum.json --- rustc-1.30.0+dfsg1+llvm/src/vendor/proc-macro2/.cargo-checksum.json 2018-10-24 21:38:15.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/proc-macro2/.cargo-checksum.json 2018-12-05 01:24:25.000000000 +0000 @@ -1 +1 @@ -{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"1405b421de32d7744dd83162e9d640982ece71c6ccbd7ce2dc7df3d0b2c2c47d",".travis.yml":"4eec73d3793220ce6b955d21b932d27ee11f1a2e6b257be1f3de7d855cd852b5","Cargo.toml":"dd51fe0e6b479a9b1a21ef5a945b75047e8b0117af3e777e33fec5b0c7e33bf0","Cargo.toml.orig":"5a2223921007349fbe4954afb29aca15a65d3291bdeeea03bc880eb0823076e6","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"261fb7bbe050bbff8a8e33da68926b44cd1bbd2b1e8b655d19ae681b8fff3c6e","build.rs":"b54baf16e32c70b25f18ba61a37b70e0bae58b72d7021e81f15bd227275fdb3d","src/lib.rs":"ae3d848be2be8a4008db1997ddcb91cc5a520b99c9dab6230430003b5c7e6816","src/stable.rs":"fe1f41c293c2287a9b58ae281af1386af3b39815f60443e22622383571f9b994","src/strnom.rs":"807c377bdb49b8b1c67d013089b8ff33fe93ffd3fa36b6440dbb1d6fe8cd9c17","src/unstable.rs":"871f9747700ad2f1002898d0f8a22815363656d478666cf4d16f84f8bdfa0d0b","tests/test.rs":"428f4298e16a23db8f8fbb6101a30e993f08dc0befa2d95439dcefb364d7a7cf"},"package":"ee5697238f0d893c7f0ecc59c0999f18d2af85e424de441178bcacc9f9e6cf67"} \ No newline at end of file +{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"1405b421de32d7744dd83162e9d640982ece71c6ccbd7ce2dc7df3d0b2c2c47d",".travis.yml":"86bdfc24af6928e7f105bf5a86c4b838f014e99be6f87b6b180d94cc7cdcbbe3","Cargo.toml":"f020c87cba7dd2260861239307b2cb93e16c2bed6e2ef6c9178642b1dfcc43a3","Cargo.toml.orig":"144e6a24624abc7282d37576683fd7d287cf41103efa9cc6745a460d98ede892","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"538fd635d385b6a90ef4cc1e361aad717162a139e932a6192212cad8407aa8e1","build.rs":"7698abdd3087e0f3308916c37ade3349b6b000165186b80913013af18d36ecb6","src/lib.rs":"c5c276236d828189a5151c890a66f2b7d1c02beca98f08f2d9c01166df441eb2","src/stable.rs":"a1f29e850e5fc4c602ee1204847124e266087175695d77ec448016db910acb6b","src/strnom.rs":"807c377bdb49b8b1c67d013089b8ff33fe93ffd3fa36b6440dbb1d6fe8cd9c17","src/unstable.rs":"0b7f86862d8254104330d14837ea6ec89e7b3bf2ffe910b73629269f2bc282de","tests/marker.rs":"0227d07bbc7f2e2ad34662a6acb65668b7dc2f79141c4faa672703a04e27bea0","tests/test.rs":"427821bab498926aa56bfcea7d28c36fb24a7d63d7f59d3e7e097bcfc77fe95b"},"package":"77619697826f31a02ae974457af0b29b723e5619e113e9397b8b82c6bd253f09"} \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/proc-macro2/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/vendor/proc-macro2/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/vendor/proc-macro2/Cargo.toml 2018-10-24 21:38:14.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/proc-macro2/Cargo.toml 2018-12-05 01:24:25.000000000 +0000 @@ -12,7 +12,7 @@ [package] name = "proc-macro2" -version = "0.4.13" +version = "0.4.24" authors = ["Alex Crichton "] build = "build.rs" description = "A stable implementation of the upcoming new `proc_macro` API. Comes with an\noption, off by default, to also reimplement itself in terms of the upstream\nunstable API.\n" @@ -23,12 +23,12 @@ license = "MIT/Apache-2.0" repository = "https://github.com/alexcrichton/proc-macro2" [package.metadata.docs.rs] +rustc-args = ["--cfg", "procmacro2_semver_exempt"] rustdoc-args = ["--cfg", "procmacro2_semver_exempt"] - -[lib] -doctest = false [dependencies.unicode-xid] version = "0.1" +[dev-dependencies.quote] +version = "0.6" [features] default = ["proc-macro"] diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/proc-macro2/Cargo.toml.orig rustc-1.31.0+dfsg1+llvm/src/vendor/proc-macro2/Cargo.toml.orig --- rustc-1.30.0+dfsg1+llvm/src/vendor/proc-macro2/Cargo.toml.orig 2018-10-24 21:38:14.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/proc-macro2/Cargo.toml.orig 2018-12-05 01:24:25.000000000 +0000 @@ -1,6 +1,6 @@ [package] name = "proc-macro2" -version = "0.4.13" # remember to update html_root_url +version = "0.4.24" # remember to update html_root_url authors = ["Alex Crichton "] license = "MIT/Apache-2.0" readme = "README.md" @@ -15,15 +15,16 @@ unstable API. """ -[lib] -doctest = false - [package.metadata.docs.rs] +rustc-args = ["--cfg", "procmacro2_semver_exempt"] rustdoc-args = ["--cfg", "procmacro2_semver_exempt"] [dependencies] unicode-xid = "0.1" +[dev-dependencies] +quote = "0.6" + [features] # When enabled: act as a shim around the nightly compiler's proc_macro crate. # This requires a nightly compiler. diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/proc-macro2/README.md rustc-1.31.0+dfsg1+llvm/src/vendor/proc-macro2/README.md --- rustc-1.30.0+dfsg1+llvm/src/vendor/proc-macro2/README.md 2018-10-24 21:38:14.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/proc-macro2/README.md 2018-12-05 01:24:25.000000000 +0000 @@ -5,25 +5,20 @@ [![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/proc-macro2) A small shim over the `proc_macro` crate in the compiler intended to multiplex -the current stable interface (as of 2017-07-05) and the [upcoming richer -interface][upcoming]. +the stable interface as of 1.15.0 and the interface as of 1.30.0. -[upcoming]: https://github.com/rust-lang/rust/pull/40939 - -The upcoming support has features like: +New features added in Rust 1.30.0 include: * Span information on tokens * No need to go in/out through strings * Structured input/output -The hope is that libraries ported to `proc_macro2` will be trivial to port to -the real `proc_macro` crate once the support on nightly is stabilized. +Libraries ported to `proc_macro2` can retain support for older compilers while +continuing to get all the nice benefits of using a 1.30.0+ compiler. ## Usage -This crate by default compiles on the stable version of the compiler. It only -uses the stable surface area of the `proc_macro` crate upstream in the compiler -itself. Usage is done via: +This crate compiles on all 1.15.0+ stable compilers and usage looks like: ```toml [dependencies] @@ -48,23 +43,13 @@ } ``` -If you'd like you can enable the `nightly` feature in this crate. This will -cause it to compile against the **unstable and nightly-only** features of the -`proc_macro` crate. This in turn requires a nightly compiler. This should help -preserve span information, however, coming in from the compiler itself. - -You can enable this feature via: - -```toml -[dependencies] -proc-macro2 = { version = "0.4", features = ["nightly"] } -``` - +The 1.30.0 compiler is automatically detected and its interfaces are used when +available. ## Unstable Features `proc-macro2` supports exporting some methods from `proc_macro` which are -currently highly unstable, and may not be stabilized in the first pass of +currently highly unstable, and are not stabilized in the first pass of `proc_macro` stabilizations. These features are not exported by default. Minor versions of `proc-macro2` may make breaking changes to them at any time. @@ -79,7 +64,6 @@ depends on your crate. This infectious nature is intentional, as it serves as a reminder that you are outside of the normal semver guarantees. - # License This project is licensed under either of diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/proc-macro2/src/lib.rs rustc-1.31.0+dfsg1+llvm/src/vendor/proc-macro2/src/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/proc-macro2/src/lib.rs 2018-10-24 21:38:15.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/proc-macro2/src/lib.rs 2018-12-05 01:24:25.000000000 +0000 @@ -43,10 +43,10 @@ //! [ts]: https://doc.rust-lang.org/proc_macro/struct.TokenStream.html // Proc-macro2 types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/proc-macro2/0.4.13")] +#![doc(html_root_url = "https://docs.rs/proc-macro2/0.4.24")] #![cfg_attr( - feature = "nightly", - feature(proc_macro_raw_ident, proc_macro_span) + super_unstable, + feature(proc_macro_raw_ident, proc_macro_span, proc_macro_def_site) )] #[cfg(use_proc_macro)] @@ -58,6 +58,8 @@ use std::hash::{Hash, Hasher}; use std::iter::FromIterator; use std::marker; +#[cfg(procmacro2_semver_exempt)] +use std::path::PathBuf; use std::rc::Rc; use std::str::FromStr; @@ -65,10 +67,10 @@ mod strnom; mod stable; -#[cfg(not(feature = "nightly"))] +#[cfg(not(wrap_proc_macro))] use stable as imp; #[path = "unstable.rs"] -#[cfg(feature = "nightly")] +#[cfg(wrap_proc_macro)] mod imp; /// An abstract stream of tokens, or more concretely a sequence of token trees. @@ -182,6 +184,11 @@ TokenStream::_new(streams.into_iter().collect()) } } +impl FromIterator for TokenStream { + fn from_iter>(streams: I) -> Self { + TokenStream::_new(streams.into_iter().map(|i| i.inner).collect()) + } +} /// Prints the token stream as a string that is supposed to be losslessly /// convertible back into the same token stream (modulo spans), except for @@ -206,19 +213,25 @@ } } -// Returned by reference, so we can't easily wrap it. -#[cfg(procmacro2_semver_exempt)] -pub use imp::FileName; - /// The source file of a given `Span`. /// /// This type is semver exempt and not exposed by default. #[cfg(procmacro2_semver_exempt)] #[derive(Clone, PartialEq, Eq)] -pub struct SourceFile(imp::SourceFile); +pub struct SourceFile { + inner: imp::SourceFile, + _marker: marker::PhantomData>, +} #[cfg(procmacro2_semver_exempt)] impl SourceFile { + fn _new(inner: imp::SourceFile) -> Self { + SourceFile { + inner: inner, + _marker: marker::PhantomData, + } + } + /// Get the path to this source file. /// /// ### Note @@ -232,28 +245,21 @@ /// may not actually be valid. /// /// [`is_real`]: #method.is_real - pub fn path(&self) -> &FileName { - self.0.path() + pub fn path(&self) -> PathBuf { + self.inner.path() } /// Returns `true` if this source file is a real source file, and not /// generated by an external macro's expansion. pub fn is_real(&self) -> bool { - self.0.is_real() - } -} - -#[cfg(procmacro2_semver_exempt)] -impl AsRef for SourceFile { - fn as_ref(&self) -> &FileName { - self.0.path() + self.inner.is_real() } } #[cfg(procmacro2_semver_exempt)] impl fmt::Debug for SourceFile { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.0.fmt(f) + self.inner.fmt(f) } } @@ -328,7 +334,8 @@ } /// This method is only available when the `"nightly"` feature is enabled. - #[cfg(all(feature = "nightly", use_proc_macro))] + #[doc(hidden)] + #[cfg(any(feature = "nightly", super_unstable))] pub fn unstable(self) -> proc_macro::Span { self.inner.unstable() } @@ -338,7 +345,7 @@ /// This method is semver exempt and not exposed by default. #[cfg(procmacro2_semver_exempt)] pub fn source_file(&self) -> SourceFile { - SourceFile(self.inner.source_file()) + SourceFile::_new(self.inner.source_file()) } /// Get the starting line/column in the source file for this span. @@ -496,9 +503,7 @@ /// `Delimiter`s. #[derive(Clone)] pub struct Group { - delimiter: Delimiter, - stream: TokenStream, - span: Span, + inner: imp::Group, } /// Describes how a sequence of token trees is delimited. @@ -521,6 +526,18 @@ } impl Group { + fn _new(inner: imp::Group) -> Self { + Group { + inner: inner, + } + } + + fn _new_stable(inner: stable::Group) -> Self { + Group { + inner: inner.into(), + } + } + /// Creates a new `Group` with the given delimiter and token stream. /// /// This constructor will set the span for this group to @@ -528,15 +545,13 @@ /// method below. pub fn new(delimiter: Delimiter, stream: TokenStream) -> Group { Group { - delimiter: delimiter, - stream: stream, - span: Span::call_site(), + inner: imp::Group::new(delimiter, stream.inner), } } /// Returns the delimiter of this `Group` pub fn delimiter(&self) -> Delimiter { - self.delimiter + self.inner.delimiter() } /// Returns the `TokenStream` of tokens that are delimited in this `Group`. @@ -544,13 +559,40 @@ /// Note that the returned token stream does not include the delimiter /// returned above. pub fn stream(&self) -> TokenStream { - self.stream.clone() + TokenStream::_new(self.inner.stream()) } /// Returns the span for the delimiters of this token stream, spanning the /// entire `Group`. + /// + /// ```text + /// pub fn span(&self) -> Span { + /// ^^^^^^^ + /// ``` pub fn span(&self) -> Span { - self.span + Span::_new(self.inner.span()) + } + + /// Returns the span pointing to the opening delimiter of this group. + /// + /// ```text + /// pub fn span_open(&self) -> Span { + /// ^ + /// ``` + #[cfg(procmacro2_semver_exempt)] + pub fn span_open(&self) -> Span { + Span::_new(self.inner.span_open()) + } + + /// Returns the span pointing to the closing delimiter of this group. + /// + /// ```text + /// pub fn span_close(&self) -> Span { + /// ^ + /// ``` + #[cfg(procmacro2_semver_exempt)] + pub fn span_close(&self) -> Span { + Span::_new(self.inner.span_close()) } /// Configures the span for this `Group`'s delimiters, but not its internal @@ -560,7 +602,7 @@ /// by this group, but rather it will only set the span of the delimiter /// tokens at the level of the `Group`. pub fn set_span(&mut self, span: Span) { - self.span = span; + self.inner.set_span(span.inner) } } @@ -568,30 +610,14 @@ /// into the same group (modulo spans), except for possibly `TokenTree::Group`s /// with `Delimiter::None` delimiters. impl fmt::Display for Group { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let (left, right) = match self.delimiter { - Delimiter::Parenthesis => ("(", ")"), - Delimiter::Brace => ("{", "}"), - Delimiter::Bracket => ("[", "]"), - Delimiter::None => ("", ""), - }; - - f.write_str(left)?; - self.stream.fmt(f)?; - f.write_str(right)?; - - Ok(()) + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(&self.inner, formatter) } } impl fmt::Debug for Group { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - let mut debug = fmt.debug_struct("Group"); - debug.field("delimiter", &self.delimiter); - debug.field("stream", &self.stream); - #[cfg(procmacro2_semver_exempt)] - debug.field("span", &self.span); - debug.finish() + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(&self.inner, formatter) } } @@ -689,11 +715,11 @@ /// - A lifetime is not an identifier. Use `syn::Lifetime` instead. /// /// An identifier constructed with `Ident::new` is permitted to be a Rust -/// keyword, though parsing one through its [`Synom`] implementation rejects -/// Rust keywords. Use `call!(Ident::parse_any)` when parsing to match the +/// keyword, though parsing one through its [`Parse`] implementation rejects +/// Rust keywords. Use `input.call(Ident::parse_any)` when parsing to match the /// behaviour of `Ident::new`. /// -/// [`Synom`]: https://docs.rs/syn/0.14/syn/synom/trait.Synom.html +/// [`Parse`]: https://docs.rs/syn/0.15/syn/parse/trait.Parse.html /// /// # Examples /// @@ -821,7 +847,7 @@ impl PartialEq for Ident { fn eq(&self, other: &Ident) -> bool { - self.to_string() == other.to_string() + self.inner == other.inner } } @@ -830,7 +856,7 @@ T: ?Sized + AsRef, { fn eq(&self, other: &T) -> bool { - self.to_string() == other.as_ref() + self.inner == other } } @@ -948,6 +974,12 @@ isize_suffixed => isize, } + #[cfg(u128)] + suffixed_int_literals! { + u128_suffixed => u128, + i128_suffixed => i128, + } + unsuffixed_int_literals! { u8_unsuffixed => u8, u16_unsuffixed => u16, @@ -961,6 +993,12 @@ isize_unsuffixed => isize, } + #[cfg(u128)] + unsuffixed_int_literals! { + u128_unsuffixed => u128, + i128_unsuffixed => i128, + } + pub fn f64_unsuffixed(f: f64) -> Literal { assert!(f.is_finite()); Literal::_new(imp::Literal::f64_unsuffixed(f)) diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/proc-macro2/src/stable.rs rustc-1.31.0+dfsg1+llvm/src/vendor/proc-macro2/src/stable.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/proc-macro2/src/stable.rs 2018-10-24 21:38:15.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/proc-macro2/src/stable.rs 2018-12-05 01:24:25.000000000 +0000 @@ -6,13 +6,16 @@ use std::cmp; use std::fmt; use std::iter; +#[cfg(procmacro2_semver_exempt)] +use std::path::Path; +use std::path::PathBuf; use std::str::FromStr; use std::vec; use strnom::{block_comment, skip_whitespace, whitespace, word_break, Cursor, PResult}; use unicode_xid::UnicodeXID; -use {Delimiter, Group, Punct, Spacing, TokenTree}; +use {Delimiter, Punct, Spacing, TokenTree}; #[derive(Clone)] pub struct TokenStream { @@ -154,6 +157,18 @@ } } +impl iter::FromIterator for TokenStream { + fn from_iter>(streams: I) -> Self { + let mut v = Vec::new(); + + for stream in streams.into_iter() { + v.extend(stream.inner); + } + + TokenStream { inner: v } + } +} + impl Extend for TokenStream { fn extend>(&mut self, streams: I) { self.inner.extend(streams); @@ -178,29 +193,15 @@ } } -#[derive(Clone, PartialEq, Eq, Debug)] -pub struct FileName(String); - -#[allow(dead_code)] -pub fn file_name(s: String) -> FileName { - FileName(s) -} - -impl fmt::Display for FileName { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.0.fmt(f) - } -} - #[derive(Clone, PartialEq, Eq)] pub struct SourceFile { - name: FileName, + path: PathBuf, } impl SourceFile { /// Get the path to this source file as a string. - pub fn path(&self) -> &FileName { - &self.name + pub fn path(&self) -> PathBuf { + self.path.clone() } pub fn is_real(&self) -> bool { @@ -209,12 +210,6 @@ } } -impl AsRef for SourceFile { - fn as_ref(&self) -> &FileName { - self.path() - } -} - impl fmt::Debug for SourceFile { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("SourceFile") @@ -370,7 +365,7 @@ let cm = cm.borrow(); let fi = cm.fileinfo(*self); SourceFile { - name: FileName(fi.name.clone()), + path: Path::new(&fi.name).to_owned(), } }) } @@ -420,6 +415,75 @@ } #[derive(Clone)] +pub struct Group { + delimiter: Delimiter, + stream: TokenStream, + span: Span, +} + +impl Group { + pub fn new(delimiter: Delimiter, stream: TokenStream) -> Group { + Group { + delimiter: delimiter, + stream: stream, + span: Span::call_site(), + } + } + + pub fn delimiter(&self) -> Delimiter { + self.delimiter + } + + pub fn stream(&self) -> TokenStream { + self.stream.clone() + } + + pub fn span(&self) -> Span { + self.span + } + + pub fn span_open(&self) -> Span { + self.span + } + + pub fn span_close(&self) -> Span { + self.span + } + + pub fn set_span(&mut self, span: Span) { + self.span = span; + } +} + +impl fmt::Display for Group { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let (left, right) = match self.delimiter { + Delimiter::Parenthesis => ("(", ")"), + Delimiter::Brace => ("{", "}"), + Delimiter::Bracket => ("[", "]"), + Delimiter::None => ("", ""), + }; + + f.write_str(left)?; + self.stream.fmt(f)?; + f.write_str(right)?; + + Ok(()) + } +} + +impl fmt::Debug for Group { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + let mut debug = fmt.debug_struct("Group"); + debug.field("delimiter", &self.delimiter); + debug.field("stream", &self.stream); + #[cfg(procmacro2_semver_exempt)] + debug.field("span", &self.span); + debug.finish() + } +} + +#[derive(Clone)] pub struct Ident { sym: String, span: Span, @@ -500,6 +564,26 @@ } } +impl PartialEq for Ident { + fn eq(&self, other: &Ident) -> bool { + self.sym == other.sym && self.raw == other.raw + } +} + +impl PartialEq for Ident +where + T: ?Sized + AsRef, +{ + fn eq(&self, other: &T) -> bool { + let other = other.as_ref(); + if self.raw { + other.starts_with("r#") && self.sym == other[2..] + } else { + self.sym == other + } + } +} + impl fmt::Display for Ident { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if self.raw { @@ -577,6 +661,12 @@ f64_suffixed => f64, } + #[cfg(u128)] + suffixed_numbers! { + u128_suffixed => u128, + i128_suffixed => i128, + } + unsuffixed_numbers! { u8_unsuffixed => u8, u16_unsuffixed => u16, @@ -590,6 +680,12 @@ isize_unsuffixed => isize, } + #[cfg(u128)] + unsuffixed_numbers! { + u128_unsuffixed => u128, + i128_unsuffixed => i128, + } + pub fn f32_unsuffixed(f: f32) -> Literal { let mut s = f.to_string(); if !s.contains(".") { @@ -715,7 +811,7 @@ } named!(token_kind -> TokenTree, alt!( - map!(group, TokenTree::Group) + map!(group, |g| TokenTree::Group(::Group::_new_stable(g))) | map!(literal, |l| TokenTree::Literal(::Literal::_new_stable(l))) // must be before symbol | @@ -729,19 +825,19 @@ punct!("("), token_stream, punct!(")") - ) => { |ts| Group::new(Delimiter::Parenthesis, ::TokenStream::_new_stable(ts)) } + ) => { |ts| Group::new(Delimiter::Parenthesis, ts) } | delimited!( punct!("["), token_stream, punct!("]") - ) => { |ts| Group::new(Delimiter::Bracket, ::TokenStream::_new_stable(ts)) } + ) => { |ts| Group::new(Delimiter::Bracket, ts) } | delimited!( punct!("{"), token_stream, punct!("}") - ) => { |ts| Group::new(Delimiter::Brace, ::TokenStream::_new_stable(ts)) } + ) => { |ts| Group::new(Delimiter::Brace, ts) } )); fn symbol_leading_ws(input: Cursor) -> PResult { @@ -1256,7 +1352,8 @@ for tt in stream.iter_mut() { tt.set_span(span); } - trees.push(Group::new(Delimiter::Bracket, stream.into_iter().collect()).into()); + let group = Group::new(Delimiter::Bracket, stream.into_iter().collect()); + trees.push(::Group::_new_stable(group).into()); for tt in trees.iter_mut() { tt.set_span(span); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/proc-macro2/src/unstable.rs rustc-1.31.0+dfsg1+llvm/src/vendor/proc-macro2/src/unstable.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/proc-macro2/src/unstable.rs 2018-10-24 21:38:15.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/proc-macro2/src/unstable.rs 2018-12-05 01:24:25.000000000 +0000 @@ -1,14 +1,16 @@ -#![cfg_attr(not(procmacro2_semver_exempt), allow(dead_code))] +#![cfg_attr(not(super_unstable), allow(dead_code))] use std::fmt; use std::iter; -use std::panic; +use std::panic::{self, PanicInfo}; +#[cfg(super_unstable)] +use std::path::PathBuf; use std::str::FromStr; use proc_macro; use stable; -use {Delimiter, Group, Punct, Spacing, TokenTree}; +use {Delimiter, Punct, Spacing, TokenTree}; #[derive(Clone)] pub enum TokenStream { @@ -23,16 +25,59 @@ fn nightly_works() -> bool { use std::sync::atomic::*; + use std::sync::Once; + static WORKS: AtomicUsize = ATOMIC_USIZE_INIT; + static INIT: Once = Once::new(); match WORKS.load(Ordering::SeqCst) { 1 => return false, 2 => return true, _ => {} } - let works = panic::catch_unwind(|| proc_macro::Span::call_site()).is_ok(); - WORKS.store(works as usize + 1, Ordering::SeqCst); - works + + // Swap in a null panic hook to avoid printing "thread panicked" to stderr, + // then use catch_unwind to determine whether the compiler's proc_macro is + // working. When proc-macro2 is used from outside of a procedural macro all + // of the proc_macro crate's APIs currently panic. + // + // The Once is to prevent the possibility of this ordering: + // + // thread 1 calls take_hook, gets the user's original hook + // thread 1 calls set_hook with the null hook + // thread 2 calls take_hook, thinks null hook is the original hook + // thread 2 calls set_hook with the null hook + // thread 1 calls set_hook with the actual original hook + // thread 2 calls set_hook with what it thinks is the original hook + // + // in which the user's hook has been lost. + // + // There is still a race condition where a panic in a different thread can + // happen during the interval that the user's original panic hook is + // unregistered such that their hook is incorrectly not called. This is + // sufficiently unlikely and less bad than printing panic messages to stderr + // on correct use of this crate. Maybe there is a libstd feature request + // here. For now, if a user needs to guarantee that this failure mode does + // not occur, they need to call e.g. `proc_macro2::Span::call_site()` from + // the main thread before launching any other threads. + INIT.call_once(|| { + type PanicHook = Fn(&PanicInfo) + Sync + Send + 'static; + + let null_hook: Box = Box::new(|_panic_info| { /* ignore */ }); + let sanity_check = &*null_hook as *const PanicHook; + let original_hook = panic::take_hook(); + panic::set_hook(null_hook); + + let works = panic::catch_unwind(|| proc_macro::Span::call_site()).is_ok(); + WORKS.store(works as usize + 1, Ordering::SeqCst); + + let hopefully_null_hook = panic::take_hook(); + panic::set_hook(original_hook); + if sanity_check != &*hopefully_null_hook { + panic!("observed race condition in proc_macro2::nightly_works"); + } + }); + nightly_works() } fn mismatch() -> ! { @@ -118,18 +163,7 @@ return TokenStream::Stable(token.into()); } let tt: proc_macro::TokenTree = match token { - TokenTree::Group(tt) => { - let delim = match tt.delimiter() { - Delimiter::Parenthesis => proc_macro::Delimiter::Parenthesis, - Delimiter::Bracket => proc_macro::Delimiter::Bracket, - Delimiter::Brace => proc_macro::Delimiter::Brace, - Delimiter::None => proc_macro::Delimiter::None, - }; - let span = tt.span(); - let mut group = proc_macro::Group::new(delim, tt.stream.inner.unwrap_nightly()); - group.set_span(span.inner.unwrap_nightly()); - group.into() - } + TokenTree::Group(tt) => tt.inner.unwrap_nightly().into(), TokenTree::Punct(tt) => { let spacing = match tt.spacing() { Spacing::Joint => proc_macro::Spacing::Joint, @@ -163,15 +197,72 @@ } } +impl iter::FromIterator for TokenStream { + fn from_iter>(streams: I) -> Self { + let mut streams = streams.into_iter(); + match streams.next() { + #[cfg(slow_extend)] + Some(TokenStream::Nightly(first)) => { + let stream = iter::once(first).chain(streams.map(|s| { + match s { + TokenStream::Nightly(s) => s, + TokenStream::Stable(_) => mismatch(), + } + })).collect(); + TokenStream::Nightly(stream) + } + #[cfg(not(slow_extend))] + Some(TokenStream::Nightly(mut first)) => { + first.extend(streams.map(|s| { + match s { + TokenStream::Nightly(s) => s, + TokenStream::Stable(_) => mismatch(), + } + })); + TokenStream::Nightly(first) + } + Some(TokenStream::Stable(mut first)) => { + first.extend(streams.map(|s| { + match s { + TokenStream::Stable(s) => s, + TokenStream::Nightly(_) => mismatch(), + } + })); + TokenStream::Stable(first) + } + None => TokenStream::new(), + + } + } +} + impl Extend for TokenStream { fn extend>(&mut self, streams: I) { match self { TokenStream::Nightly(tts) => { - tts.extend( - streams + #[cfg(not(slow_extend))] + { + tts.extend( + streams + .into_iter() + .map(|t| TokenStream::from(t).unwrap_nightly()), + ); + } + #[cfg(slow_extend)] + { + *tts = tts + .clone() .into_iter() - .map(|t| TokenStream::from(t).unwrap_nightly()), - ); + .chain( + streams + .into_iter() + .map(TokenStream::from) + .flat_map(|t| match t { + TokenStream::Nightly(tts) => tts.into_iter(), + _ => mismatch(), + }), + ).collect(); + } } TokenStream::Stable(tts) => tts.extend(streams), } @@ -182,7 +273,24 @@ fn extend>(&mut self, streams: I) { match self { TokenStream::Nightly(tts) => { - tts.extend(streams.into_iter().map(|stream| stream.unwrap_nightly())) + #[cfg(not(slow_extend))] + { + tts.extend(streams.into_iter().map(|stream| stream.unwrap_nightly())); + } + #[cfg(slow_extend)] + { + *tts = tts + .clone() + .into_iter() + .chain( + streams + .into_iter() + .flat_map(|t| match t { + TokenStream::Nightly(tts) => tts.into_iter(), + _ => mismatch(), + }), + ).collect(); + } } TokenStream::Stable(tts) => { tts.extend(streams.into_iter().map(|stream| stream.unwrap_stable())) @@ -247,18 +355,7 @@ TokenTreeIter::Stable(iter) => return iter.next(), }; Some(match token { - proc_macro::TokenTree::Group(tt) => { - let delim = match tt.delimiter() { - proc_macro::Delimiter::Parenthesis => Delimiter::Parenthesis, - proc_macro::Delimiter::Bracket => Delimiter::Bracket, - proc_macro::Delimiter::Brace => Delimiter::Brace, - proc_macro::Delimiter::None => Delimiter::None, - }; - let stream = ::TokenStream::_new(TokenStream::Nightly(tt.stream())); - let mut g = Group::new(delim, stream); - g.set_span(::Span::_new(Span::Nightly(tt.span()))); - g.into() - } + proc_macro::TokenTree::Group(tt) => ::Group::_new(Group::Nightly(tt)).into(), proc_macro::TokenTree::Punct(tt) => { let spacing = match tt.spacing() { proc_macro::Spacing::Joint => Spacing::Joint, @@ -287,48 +384,40 @@ } } -pub use stable::FileName; - -// NOTE: We have to generate our own filename object here because we can't wrap -// the one provided by proc_macro. #[derive(Clone, PartialEq, Eq)] +#[cfg(super_unstable)] pub enum SourceFile { - Nightly(proc_macro::SourceFile, FileName), + Nightly(proc_macro::SourceFile), Stable(stable::SourceFile), } +#[cfg(super_unstable)] impl SourceFile { fn nightly(sf: proc_macro::SourceFile) -> Self { - let filename = stable::file_name(sf.path().display().to_string()); - SourceFile::Nightly(sf, filename) + SourceFile::Nightly(sf) } /// Get the path to this source file as a string. - pub fn path(&self) -> &FileName { + pub fn path(&self) -> PathBuf { match self { - SourceFile::Nightly(_, f) => f, + SourceFile::Nightly(a) => a.path(), SourceFile::Stable(a) => a.path(), } } pub fn is_real(&self) -> bool { match self { - SourceFile::Nightly(a, _) => a.is_real(), + SourceFile::Nightly(a) => a.is_real(), SourceFile::Stable(a) => a.is_real(), } } } -impl AsRef for SourceFile { - fn as_ref(&self) -> &FileName { - self.path() - } -} - +#[cfg(super_unstable)] impl fmt::Debug for SourceFile { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - SourceFile::Nightly(a, _) => a.fmt(f), + SourceFile::Nightly(a) => a.fmt(f), SourceFile::Stable(a) => a.fmt(f), } } @@ -354,6 +443,7 @@ } } + #[cfg(super_unstable)] pub fn def_site() -> Span { if nightly_works() { Span::Nightly(proc_macro::Span::def_site()) @@ -362,6 +452,7 @@ } } + #[cfg(super_unstable)] pub fn resolved_at(&self, other: Span) -> Span { match (self, other) { (Span::Nightly(a), Span::Nightly(b)) => Span::Nightly(a.resolved_at(b)), @@ -370,6 +461,7 @@ } } + #[cfg(super_unstable)] pub fn located_at(&self, other: Span) -> Span { match (self, other) { (Span::Nightly(a), Span::Nightly(b)) => Span::Nightly(a.located_at(b)), @@ -385,7 +477,7 @@ } } - #[cfg(procmacro2_semver_exempt)] + #[cfg(super_unstable)] pub fn source_file(&self) -> SourceFile { match self { Span::Nightly(s) => SourceFile::nightly(s.source_file()), @@ -393,7 +485,7 @@ } } - #[cfg(procmacro2_semver_exempt)] + #[cfg(super_unstable)] pub fn start(&self) -> LineColumn { match self { Span::Nightly(s) => { @@ -407,7 +499,7 @@ } } - #[cfg(procmacro2_semver_exempt)] + #[cfg(super_unstable)] pub fn end(&self) -> LineColumn { match self { Span::Nightly(s) => { @@ -421,7 +513,7 @@ } } - #[cfg(procmacro2_semver_exempt)] + #[cfg(super_unstable)] pub fn join(&self, other: Span) -> Option { let ret = match (self, other) { (Span::Nightly(a), Span::Nightly(b)) => Span::Nightly(a.join(b)?), @@ -431,6 +523,7 @@ Some(ret) } + #[cfg(super_unstable)] pub fn eq(&self, other: &Span) -> bool { match (self, other) { (Span::Nightly(a), Span::Nightly(b)) => a.eq(b), @@ -469,6 +562,112 @@ } #[derive(Clone)] +pub enum Group { + Nightly(proc_macro::Group), + Stable(stable::Group), +} + +impl Group { + pub fn new(delimiter: Delimiter, stream: TokenStream) -> Group { + match stream { + TokenStream::Nightly(stream) => { + let delimiter = match delimiter { + Delimiter::Parenthesis => proc_macro::Delimiter::Parenthesis, + Delimiter::Bracket => proc_macro::Delimiter::Bracket, + Delimiter::Brace => proc_macro::Delimiter::Brace, + Delimiter::None => proc_macro::Delimiter::None, + }; + Group::Nightly(proc_macro::Group::new(delimiter, stream)) + } + TokenStream::Stable(stream) => { + Group::Stable(stable::Group::new(delimiter, stream)) + } + } + } + + pub fn delimiter(&self) -> Delimiter { + match self { + Group::Nightly(g) => match g.delimiter() { + proc_macro::Delimiter::Parenthesis => Delimiter::Parenthesis, + proc_macro::Delimiter::Bracket => Delimiter::Bracket, + proc_macro::Delimiter::Brace => Delimiter::Brace, + proc_macro::Delimiter::None => Delimiter::None, + } + Group::Stable(g) => g.delimiter(), + } + } + + pub fn stream(&self) -> TokenStream { + match self { + Group::Nightly(g) => TokenStream::Nightly(g.stream()), + Group::Stable(g) => TokenStream::Stable(g.stream()), + } + } + + pub fn span(&self) -> Span { + match self { + Group::Nightly(g) => Span::Nightly(g.span()), + Group::Stable(g) => Span::Stable(g.span()), + } + } + + #[cfg(super_unstable)] + pub fn span_open(&self) -> Span { + match self { + Group::Nightly(g) => Span::Nightly(g.span_open()), + Group::Stable(g) => Span::Stable(g.span_open()), + } + } + + #[cfg(super_unstable)] + pub fn span_close(&self) -> Span { + match self { + Group::Nightly(g) => Span::Nightly(g.span_close()), + Group::Stable(g) => Span::Stable(g.span_close()), + } + } + + pub fn set_span(&mut self, span: Span) { + match (self, span) { + (Group::Nightly(g), Span::Nightly(s)) => g.set_span(s), + (Group::Stable(g), Span::Stable(s)) => g.set_span(s), + _ => mismatch(), + } + } + + fn unwrap_nightly(self) -> proc_macro::Group { + match self { + Group::Nightly(g) => g, + Group::Stable(_) => mismatch(), + } + } +} + +impl From for Group { + fn from(g: stable::Group) -> Self { + Group::Stable(g) + } +} + +impl fmt::Display for Group { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + match self { + Group::Nightly(group) => group.fmt(formatter), + Group::Stable(group) => group.fmt(formatter), + } + } +} + +impl fmt::Debug for Group { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + match self { + Group::Nightly(group) => group.fmt(formatter), + Group::Stable(group) => group.fmt(formatter), + } + } +} + +#[derive(Clone)] pub enum Ident { Nightly(proc_macro::Ident), Stable(stable::Ident), @@ -484,7 +683,17 @@ pub fn new_raw(string: &str, span: Span) -> Ident { match span { - Span::Nightly(s) => Ident::Nightly(proc_macro::Ident::new_raw(string, s)), + Span::Nightly(s) => { + let p: proc_macro::TokenStream = string.parse().unwrap(); + let ident = match p.into_iter().next() { + Some(proc_macro::TokenTree::Ident(mut i)) => { + i.set_span(s); + i + } + _ => panic!(), + }; + Ident::Nightly(ident) + } Span::Stable(s) => Ident::Stable(stable::Ident::new_raw(string, s)), } } @@ -512,6 +721,29 @@ } } +impl PartialEq for Ident { + fn eq(&self, other: &Ident) -> bool { + match (self, other) { + (Ident::Nightly(t), Ident::Nightly(o)) => t.to_string() == o.to_string(), + (Ident::Stable(t), Ident::Stable(o)) => t == o, + _ => mismatch(), + } + } +} + +impl PartialEq for Ident +where + T: ?Sized + AsRef, +{ + fn eq(&self, other: &T) -> bool { + let other = other.as_ref(); + match self { + Ident::Nightly(t) => t.to_string() == other, + Ident::Stable(t) => t == other, + } + } +} + impl fmt::Display for Ident { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { @@ -577,6 +809,12 @@ f64_suffixed => f64, } + #[cfg(u128)] + suffixed_numbers! { + i128_suffixed => i128, + u128_suffixed => u128, + } + unsuffixed_integers! { u8_unsuffixed => u8, u16_unsuffixed => u16, @@ -590,6 +828,12 @@ isize_unsuffixed => isize, } + #[cfg(u128)] + unsuffixed_integers! { + i128_unsuffixed => i128, + u128_unsuffixed => u128, + } + pub fn f32_unsuffixed(f: f32) -> Literal { if nightly_works() { Literal::Nightly(proc_macro::Literal::f32_unsuffixed(f)) diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/proc-macro2/tests/marker.rs rustc-1.31.0+dfsg1+llvm/src/vendor/proc-macro2/tests/marker.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/proc-macro2/tests/marker.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/proc-macro2/tests/marker.rs 2018-12-05 01:24:25.000000000 +0000 @@ -0,0 +1,61 @@ +extern crate proc_macro2; + +use proc_macro2::*; + +macro_rules! assert_impl { + ($ty:ident is $($marker:ident) and +) => { + #[test] + #[allow(non_snake_case)] + fn $ty() { + fn assert_implemented() {} + assert_implemented::<$ty>(); + } + }; + + ($ty:ident is not $($marker:ident) or +) => { + #[test] + #[allow(non_snake_case)] + fn $ty() { + $( + { + // Implemented for types that implement $marker. + trait IsNotImplemented { + fn assert_not_implemented() {} + } + impl IsNotImplemented for T {} + + // Implemented for the type being tested. + trait IsImplemented { + fn assert_not_implemented() {} + } + impl IsImplemented for $ty {} + + // If $ty does not implement $marker, there is no ambiguity + // in the following trait method call. + <$ty>::assert_not_implemented(); + } + )+ + } + }; +} + +assert_impl!(Delimiter is Send and Sync); +assert_impl!(Spacing is Send and Sync); + +assert_impl!(Group is not Send or Sync); +assert_impl!(Ident is not Send or Sync); +assert_impl!(LexError is not Send or Sync); +assert_impl!(Literal is not Send or Sync); +assert_impl!(Punct is not Send or Sync); +assert_impl!(Span is not Send or Sync); +assert_impl!(TokenStream is not Send or Sync); +assert_impl!(TokenTree is not Send or Sync); + +#[cfg(procmacro2_semver_exempt)] +mod semver_exempt { + use super::*; + + assert_impl!(LineColumn is Send and Sync); + + assert_impl!(SourceFile is not Send or Sync); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/proc-macro2/tests/test.rs rustc-1.31.0+dfsg1+llvm/src/vendor/proc-macro2/tests/test.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/proc-macro2/tests/test.rs 2018-10-24 21:38:14.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/proc-macro2/tests/test.rs 2018-12-05 01:24:25.000000000 +0000 @@ -203,7 +203,7 @@ assert_eq!(end.line, 1); assert_eq!(end.column, 0); let source_file = Span::call_site().source_file(); - assert_eq!(source_file.path().to_string(), ""); + assert_eq!(source_file.path().to_string_lossy(), ""); assert!(!source_file.is_real()); } diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/proc-macro2/.travis.yml rustc-1.31.0+dfsg1+llvm/src/vendor/proc-macro2/.travis.yml --- rustc-1.30.0+dfsg1+llvm/src/vendor/proc-macro2/.travis.yml 2018-10-24 21:38:14.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/proc-macro2/.travis.yml 2018-12-05 01:24:25.000000000 +0000 @@ -3,7 +3,11 @@ matrix: include: - - rust: 1.15.0 + - rust: 1.15.0 # oldest supported version + script: cargo build + - rust: 1.19.0 # first release with the --tests flag + script: cargo test --tests + - rust: 1.26.0 # first release on which our doc tests pass - rust: stable - rust: beta - rust: nightly diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/rls-data/.cargo-checksum.json rustc-1.31.0+dfsg1+llvm/src/vendor/rls-data/.cargo-checksum.json --- rustc-1.30.0+dfsg1+llvm/src/vendor/rls-data/.cargo-checksum.json 2018-10-24 21:38:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/rls-data/.cargo-checksum.json 2018-12-05 01:24:26.000000000 +0000 @@ -1 +1 @@ -{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"1ef9c846e4e5922b78dd32b3ecccda2965c254f5d30b14a996cb613d49603ab6","Cargo.toml":"ee24cfa50b18ac7ad1413a6f42ec58f5f8470712d558247ccada56ad617c3a1a","Cargo.toml.orig":"a88976d62262e0355ecc3e9b679f269ae6a5946306ec68395b621d03ff4d9a55","README.md":"7bbd124ce5419c1a600dc4d10091f3c822a1b9a7ab51713c53f900e34126ecdf","src/config.rs":"dbfa4ae1db5f6096d88965d5c8fcac937fdf20065f582ffa56c9a1fac65603fd","src/lib.rs":"e64723a75423d5f9f8bf22f3edce9bedf7b947757ef6d30f3a6b6a04c4367c6a"},"package":"4f81e838ecff6830ed33c2907fd236f38d441c206e983a2aa29fbce99295fab9"} \ No newline at end of file +{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".cargo_vcs_info.json":"e9636e349ebcccb1d9ab4e5c16b554e0b5c681700ffb335fb2e1fa28e7f44a95",".gitignore":"1ef9c846e4e5922b78dd32b3ecccda2965c254f5d30b14a996cb613d49603ab6","Cargo.toml":"875d502bc7c29b2ce3f3a07567e087f898e2d0b3989bd654fa006b4584d8ae9f","Cargo.toml.orig":"0de22928695204b3c8eaaebe0009eeb33650119a21ea37d9881b2494837e5eaf","README.md":"7bbd124ce5419c1a600dc4d10091f3c822a1b9a7ab51713c53f900e34126ecdf","src/config.rs":"dbfa4ae1db5f6096d88965d5c8fcac937fdf20065f582ffa56c9a1fac65603fd","src/lib.rs":"c395e03e8559efc117e2f27daf44096ae265ef646f6f1a0d30dea4961cd916e2"},"package":"3a209ce46bb52813cbe0786a7baadc0c1a3f5543ef93f179eda3b841ed72cf2e"} \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/rls-data/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/vendor/rls-data/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/vendor/rls-data/Cargo.toml 2018-10-24 21:38:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/rls-data/Cargo.toml 2018-12-05 01:24:26.000000000 +0000 @@ -12,7 +12,7 @@ [package] name = "rls-data" -version = "0.18.0" +version = "0.18.1" authors = ["Nick Cameron "] description = "Data structures used by the RLS and Rust compiler" categories = ["development-tools"] diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/rls-data/Cargo.toml.orig rustc-1.31.0+dfsg1+llvm/src/vendor/rls-data/Cargo.toml.orig --- rustc-1.30.0+dfsg1+llvm/src/vendor/rls-data/Cargo.toml.orig 2018-10-24 21:38:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/rls-data/Cargo.toml.orig 2018-12-05 01:24:26.000000000 +0000 @@ -1,6 +1,6 @@ [package] name = "rls-data" -version = "0.18.0" +version = "0.18.1" authors = ["Nick Cameron "] description = "Data structures used by the RLS and Rust compiler" license = "Apache-2.0/MIT" diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/rls-data/.cargo_vcs_info.json rustc-1.31.0+dfsg1+llvm/src/vendor/rls-data/.cargo_vcs_info.json --- rustc-1.30.0+dfsg1+llvm/src/vendor/rls-data/.cargo_vcs_info.json 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/rls-data/.cargo_vcs_info.json 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,5 @@ +{ + "git": { + "sha1": "9edbe8b4947c10ef670c4723be375c6944cab640" + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/rls-data/src/lib.rs rustc-1.31.0+dfsg1+llvm/src/vendor/rls-data/src/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/rls-data/src/lib.rs 2018-10-24 21:38:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/rls-data/src/lib.rs 2018-12-05 01:24:26.000000000 +0000 @@ -35,6 +35,7 @@ /// The Config used to generate this analysis data. pub config: Config, pub version: Option, + pub compilation: Option, pub prelude: Option, pub imports: Vec, pub defs: Vec, @@ -53,6 +54,7 @@ config, version: option_env!("CARGO_PKG_VERSION").map(|s| s.to_string()), prelude: None, + compilation: None, imports: vec![], defs: vec![], impls: vec![], @@ -116,6 +118,16 @@ } #[cfg_attr(feature = "serialize-serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serialize-rustc", derive(RustcDecodable, RustcEncodable))] +#[derive(Debug, Clone)] +pub struct CompilationOptions { + pub directory: PathBuf, + pub program: String, + pub arguments: Vec, + pub output: PathBuf, +} + +#[cfg_attr(feature = "serialize-serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serialize-rustc", derive(RustcDecodable, RustcEncodable))] #[derive(Debug, Clone)] pub struct CratePreludeData { diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/.cargo-checksum.json rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/.cargo-checksum.json --- rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/.cargo-checksum.json 2018-10-24 21:38:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/.cargo-checksum.json 2018-12-05 01:24:40.000000000 +0000 @@ -1 +1 @@ -{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Cargo.toml":"0265066945da4da5957f3446cef6f2a52e81254be3a9c4e678cc2c1e1160118b","Cargo.toml.orig":"e3f3c271342a1b72fd0b7180cbdda9740f0b408254541af6ad7c50cc117751d2","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"c4d8690cd2aa2db200ecdf2f2113fc8e3f4ccc88f3dc96da22189f45136932d0","src/de.rs":"42d7aa8cf85baa1b3851180e32af883c11ca2889df6f4eb306670f360af46d3e","src/error.rs":"8ac6d4c861891c133b3359b2a14fccb8a6d463a4b2c13f0d658884c1972186ce","src/iter.rs":"b5c77c5482e45bed1e63bd36a0f991a08f732811546a163228be48303e7f1b4d","src/lib.rs":"698af0adc583d8b5a22f510bb33fbdb35552dd6e0775e038f7ed50f6680580d8","src/macros.rs":"0d9850832f53c8aca337395b2536f1cdaf2d2d2699adc09c9a2001544106a4fc","src/map.rs":"724205f934003c879fb3e48a84b21c54e273e968beec97b85617042911ca88d7","src/number.rs":"47bf5416ca4f8299e98f008bd1bcf7e7311f00d0ce282536a17310fa73788def","src/read.rs":"832bc530dd35ee24df59c1cf648cfbbffc4c2e72e86104b0e186582ae0de545a","src/ser.rs":"d2050d362c23e988141e6c5d08590152b3412ee3464e1a3026b83dda7de0c985","src/value/de.rs":"b25d9192f179f84c0ecb2226216ff663c39ebdde524179f7118718f3202243cf","src/value/from.rs":"13a6c7b0b327f23c2fd899c8390e8ddfd8907bfcfc362e80834b9ae7ddb698e9","src/value/index.rs":"b9a8cc6f37e2a079a5e4ab1bf25fa9ff076c514870e0756a0c88af3ffa0f51a8","src/value/mod.rs":"8d0ac56fcd12aee1c645afdfe0df62b10527cab21d16284fe9f0bd6768457002","src/value/partial_eq.rs":"5924e245408afc8075e2bb9dda479c938c6c8cdd3c18b54697aa2b33fffda57b","src/value/ser.rs":"4bbc3ad0f646464f1e9b9a2c2e48df799d02ef658eacadc35971b897cfe7cd02"},"package":"44dd2cfde475037451fa99b7e5df77aa3cfd1536575fa8e7a538ab36dcde49ae"} \ No newline at end of file +{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".cargo_vcs_info.json":"a67c1f695e9bb102e2ddf11a8688af56becb6d4b423db4021676678996d22894","Cargo.toml":"66c1eda5d0a2b9b32d9d5f60a9beda663a5347b768c902eac5c223a49d7f3583","Cargo.toml.orig":"d1068ae502c09ee0f97fb843b3328fedd53b8b2495f29489c3c2bf96bc0b896c","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb","README.md":"c4d8690cd2aa2db200ecdf2f2113fc8e3f4ccc88f3dc96da22189f45136932d0","src/de.rs":"ecad8f5bf96859496e0b7c4734f359d93878480b4679b1bac53dd5bfc79c1b49","src/error.rs":"8ac6d4c861891c133b3359b2a14fccb8a6d463a4b2c13f0d658884c1972186ce","src/iter.rs":"b5c77c5482e45bed1e63bd36a0f991a08f732811546a163228be48303e7f1b4d","src/lib.rs":"5cb1e0253512bf77404702cd1e68a65f033abd048f2653394c3c126893b7f363","src/macros.rs":"0d9850832f53c8aca337395b2536f1cdaf2d2d2699adc09c9a2001544106a4fc","src/map.rs":"724205f934003c879fb3e48a84b21c54e273e968beec97b85617042911ca88d7","src/number.rs":"67a7295ff771de5be214180b117b2dade7f51ac5331d2d749ecc3203232c918c","src/raw.rs":"374aae841a6a8396c1b253a01a78059231d653940eea1d1a5654160914874517","src/read.rs":"bb6aca5d41385e85d7923b4187b3bca2e39e29aa6b5204c1f2e4cd5d838f822d","src/ser.rs":"7312fe0377c77d6107e5337591d2c7d9eb85b8fb7001599bc200d1015142b05a","src/value/de.rs":"f75afaa0eb8a3a91f3eefbd401384599cd27b37a9361ff3481dcf41956771211","src/value/from.rs":"13a6c7b0b327f23c2fd899c8390e8ddfd8907bfcfc362e80834b9ae7ddb698e9","src/value/index.rs":"b9a8cc6f37e2a079a5e4ab1bf25fa9ff076c514870e0756a0c88af3ffa0f51a8","src/value/mod.rs":"2b7eada7505475954d32ed04b9fb585125fdc96dd20f7c1d3433619b4fd88813","src/value/partial_eq.rs":"5924e245408afc8075e2bb9dda479c938c6c8cdd3c18b54697aa2b33fffda57b","src/value/ser.rs":"6b4b454d48eecf5012353f11cc58820db60b156a1f9639226677185e7b0f8d97"},"package":"bb47a3d5c84320222f66d7db21157c4a7407755de41798f9b4c1c40593397b1a"} \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/Cargo.toml 2018-10-24 21:38:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/Cargo.toml 2018-12-05 01:24:40.000000000 +0000 @@ -12,7 +12,7 @@ [package] name = "serde_json" -version = "1.0.26" +version = "1.0.31" authors = ["Erick Tryzelaar ", "David Tolnay "] include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] description = "A JSON serialization file format" @@ -22,12 +22,17 @@ categories = ["encoding"] license = "MIT/Apache-2.0" repository = "https://github.com/serde-rs/json" +[package.metadata.docs.rs] +features = ["raw_value"] + +[package.metadata.playground] +features = ["raw_value"] [dependencies.indexmap] version = "1.0" optional = true [dependencies.itoa] -version = "0.4" +version = "0.4.3" [dependencies.ryu] version = "0.2" @@ -47,6 +52,7 @@ arbitrary_precision = [] default = [] preserve_order = ["indexmap"] +raw_value = [] [badges.appveyor] repository = "serde-rs/json" diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/Cargo.toml.orig rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/Cargo.toml.orig --- rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/Cargo.toml.orig 2018-10-24 21:38:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/Cargo.toml.orig 2018-12-05 01:24:40.000000000 +0000 @@ -1,6 +1,6 @@ [package] name = "serde_json" -version = "1.0.26" # remember to update html_root_url +version = "1.0.31" # remember to update html_root_url authors = ["Erick Tryzelaar ", "David Tolnay "] license = "MIT/Apache-2.0" description = "A JSON serialization file format" @@ -18,7 +18,7 @@ [dependencies] serde = "1.0.60" indexmap = { version = "1.0", optional = true } -itoa = "0.4" +itoa = "0.4.3" ryu = "0.2" [dev-dependencies] @@ -26,6 +26,12 @@ serde_bytes = "0.10" serde_derive = "1.0" +[package.metadata.docs.rs] +features = ["raw_value"] + +[package.metadata.playground] +features = ["raw_value"] + ### FEATURES ################################################################# @@ -41,3 +47,6 @@ # allows JSON numbers of arbitrary size/precision to be read into a Number and # written back to a JSON string without loss of precision. arbitrary_precision = [] + +# Provide a RawValue type that can hold unprocessed JSON during deserialization. +raw_value = [] diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/.cargo_vcs_info.json rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/.cargo_vcs_info.json --- rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/.cargo_vcs_info.json 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/.cargo_vcs_info.json 2018-12-05 01:24:40.000000000 +0000 @@ -0,0 +1,5 @@ +{ + "git": { + "sha1": "caa3adee150edf97e0ef26ec367f0d5c38cee99b" + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/src/de.rs rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/src/de.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/src/de.rs 2018-10-24 21:38:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/src/de.rs 2018-12-05 01:24:40.000000000 +0000 @@ -31,7 +31,7 @@ /// A structure that deserializes JSON into Rust values. pub struct Deserializer { read: R, - str_buf: Vec, + scratch: Vec, remaining_depth: u8, } @@ -50,7 +50,7 @@ pub fn new(read: R) -> Self { Deserializer { read: read, - str_buf: Vec::with_capacity(128), + scratch: Vec::new(), remaining_depth: 128, } } @@ -234,8 +234,8 @@ }, b'"' => { self.eat_char(); - self.str_buf.clear(); - match self.read.parse_str(&mut self.str_buf) { + self.scratch.clear(); + match self.read.parse_str(&mut self.scratch) { Ok(s) => de::Error::invalid_type(Unexpected::Str(&s), exp), Err(err) => return err, } @@ -745,58 +745,117 @@ } fn ignore_value(&mut self) -> Result<()> { - let peek = match try!(self.parse_whitespace()) { - Some(b) => b, - None => { - return Err(self.peek_error(ErrorCode::EofWhileParsingValue)); - } - }; + self.scratch.clear(); + let mut enclosing = None; - match peek { - b'n' => { - self.eat_char(); - self.parse_ident(b"ull") - } - b't' => { - self.eat_char(); - self.parse_ident(b"rue") - } - b'f' => { - self.eat_char(); - self.parse_ident(b"alse") - } - b'-' => { - self.eat_char(); - self.ignore_integer() - } - b'0'...b'9' => self.ignore_integer(), - b'"' => { - self.eat_char(); - self.read.ignore_str() - } - b'[' => { - self.remaining_depth -= 1; - if self.remaining_depth == 0 { - return Err(self.peek_error(ErrorCode::RecursionLimitExceeded)); + loop { + let peek = match try!(self.parse_whitespace()) { + Some(b) => b, + None => { + return Err(self.peek_error(ErrorCode::EofWhileParsingValue)); } + }; - self.eat_char(); - let res = self.ignore_seq(); - self.remaining_depth += 1; - res - } - b'{' => { - self.remaining_depth -= 1; - if self.remaining_depth == 0 { - return Err(self.peek_error(ErrorCode::RecursionLimitExceeded)); + let frame = match peek { + b'n' => { + self.eat_char(); + try!(self.parse_ident(b"ull")); + None + } + b't' => { + self.eat_char(); + try!(self.parse_ident(b"rue")); + None + } + b'f' => { + self.eat_char(); + try!(self.parse_ident(b"alse")); + None + } + b'-' => { + self.eat_char(); + try!(self.ignore_integer()); + None + } + b'0'...b'9' => { + try!(self.ignore_integer()); + None + } + b'"' => { + self.eat_char(); + try!(self.read.ignore_str()); + None + } + frame @ b'[' | frame @ b'{' => { + self.scratch.extend(enclosing.take()); + self.eat_char(); + Some(frame) + } + _ => return Err(self.peek_error(ErrorCode::ExpectedSomeValue)), + }; + + let (mut accept_comma, mut frame) = match frame { + Some(frame) => (false, frame), + None => match enclosing.take() { + Some(frame) => (true, frame), + None => match self.scratch.pop() { + Some(frame) => (true, frame), + None => return Ok(()), + }, + }, + }; + + loop { + match try!(self.parse_whitespace()) { + Some(b',') if accept_comma => { + self.eat_char(); + break; + } + Some(b']') if frame == b'[' => {} + Some(b'}') if frame == b'{' => {} + Some(_) => { + if accept_comma { + return Err(self.peek_error(match frame { + b'[' => ErrorCode::ExpectedListCommaOrEnd, + b'{' => ErrorCode::ExpectedObjectCommaOrEnd, + _ => unreachable!(), + })); + } else { + break; + } + } + None => { + return Err(self.peek_error(match frame { + b'[' => ErrorCode::EofWhileParsingList, + b'{' => ErrorCode::EofWhileParsingObject, + _ => unreachable!(), + })); + } } self.eat_char(); - let res = self.ignore_map(); - self.remaining_depth += 1; - res + frame = match self.scratch.pop() { + Some(frame) => frame, + None => return Ok(()), + }; + accept_comma = true; } - _ => Err(self.peek_error(ErrorCode::ExpectedSomeValue)), + + if frame == b'{' { + match try!(self.parse_whitespace()) { + Some(b'"') => self.eat_char(), + Some(_) => return Err(self.peek_error(ErrorCode::KeyMustBeAString)), + None => return Err(self.peek_error(ErrorCode::EofWhileParsingObject)), + } + try!(self.read.ignore_str()); + match try!(self.parse_whitespace()) { + Some(b':') => self.eat_char(), + Some(_) => return Err(self.peek_error(ErrorCode::ExpectedColon)), + None => return Err(self.peek_error(ErrorCode::EofWhileParsingObject)), + } + } + + enclosing = Some(frame); } } @@ -865,86 +924,15 @@ Ok(()) } - fn ignore_seq(&mut self) -> Result<()> { - let mut first = true; - - loop { - match try!(self.parse_whitespace()) { - Some(b']') => { - self.eat_char(); - return Ok(()); - } - Some(b',') if !first => { - self.eat_char(); - } - Some(_) => { - if first { - first = false; - } else { - return Err(self.peek_error(ErrorCode::ExpectedListCommaOrEnd)); - } - } - None => { - return Err(self.peek_error(ErrorCode::EofWhileParsingList)); - } - } - - try!(self.ignore_value()); - } - } - - fn ignore_map(&mut self) -> Result<()> { - let mut first = true; - - loop { - let peek = match try!(self.parse_whitespace()) { - Some(b'}') => { - self.eat_char(); - return Ok(()); - } - Some(b',') if !first => { - self.eat_char(); - try!(self.parse_whitespace()) - } - Some(b) => { - if first { - first = false; - Some(b) - } else { - return Err(self.peek_error(ErrorCode::ExpectedObjectCommaOrEnd)); - } - } - None => { - return Err(self.peek_error(ErrorCode::EofWhileParsingObject)); - } - }; - - match peek { - Some(b'"') => { - self.eat_char(); - try!(self.read.ignore_str()); - } - Some(_) => { - return Err(self.peek_error(ErrorCode::KeyMustBeAString)); - } - None => { - return Err(self.peek_error(ErrorCode::EofWhileParsingObject)); - } - } - - match try!(self.parse_whitespace()) { - Some(b':') => { - self.eat_char(); - try!(self.ignore_value()); - } - Some(_) => { - return Err(self.peek_error(ErrorCode::ExpectedColon)); - } - None => { - return Err(self.peek_error(ErrorCode::EofWhileParsingObject)); - } - } - } + #[cfg(feature = "raw_value")] + fn deserialize_raw_value(&mut self, visitor: V) -> Result + where + V: de::Visitor<'de>, + { + self.parse_whitespace()?; + self.read.begin_raw_buffering(); + self.ignore_value()?; + self.read.end_raw_buffering(visitor) } } @@ -1041,8 +1029,8 @@ b'0'...b'9' => try!(self.parse_any_number(true)).visit(visitor), b'"' => { self.eat_char(); - self.str_buf.clear(); - match try!(self.read.parse_str(&mut self.str_buf)) { + self.scratch.clear(); + match try!(self.read.parse_str(&mut self.scratch)) { Reference::Borrowed(s) => visitor.visit_borrowed_str(s), Reference::Copied(s) => visitor.visit_str(s), } @@ -1220,8 +1208,8 @@ let value = match peek { b'"' => { self.eat_char(); - self.str_buf.clear(); - match try!(self.read.parse_str(&mut self.str_buf)) { + self.scratch.clear(); + match try!(self.read.parse_str(&mut self.scratch)) { Reference::Borrowed(s) => visitor.visit_borrowed_str(s), Reference::Copied(s) => visitor.visit_str(s), } @@ -1337,8 +1325,8 @@ let value = match peek { b'"' => { self.eat_char(); - self.str_buf.clear(); - match try!(self.read.parse_str_raw(&mut self.str_buf)) { + self.scratch.clear(); + match try!(self.read.parse_str_raw(&mut self.scratch)) { Reference::Borrowed(b) => visitor.visit_borrowed_bytes(b), Reference::Copied(b) => visitor.visit_bytes(b), } @@ -1412,10 +1400,18 @@ /// Parses a newtype struct as the underlying value. #[inline] - fn deserialize_newtype_struct(self, _name: &str, visitor: V) -> Result + fn deserialize_newtype_struct(self, name: &str, visitor: V) -> Result where V: de::Visitor<'de>, { + #[cfg(feature = "raw_value")] + { + if name == ::raw::TOKEN { + return self.deserialize_raw_value(visitor); + } + } + + let _ = name; visitor.visit_newtype_struct(self) } @@ -1862,8 +1858,8 @@ V: de::Visitor<'de>, { self.de.eat_char(); - self.de.str_buf.clear(); - let string = try!(self.de.read.parse_str(&mut self.de.str_buf)); + self.de.scratch.clear(); + let string = try!(self.de.read.parse_str(&mut self.de.scratch)); match (string.parse(), string) { (Ok(integer), _) => visitor.$visit(integer), (Err(_), Reference::Borrowed(s)) => visitor.visit_borrowed_str(s), @@ -1885,8 +1881,8 @@ V: de::Visitor<'de>, { self.de.eat_char(); - self.de.str_buf.clear(); - match try!(self.de.read.parse_str(&mut self.de.str_buf)) { + self.de.scratch.clear(); + match try!(self.de.read.parse_str(&mut self.de.scratch)) { Reference::Borrowed(s) => visitor.visit_borrowed_str(s), Reference::Copied(s) => visitor.visit_str(s), } diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/src/lib.rs rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/src/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/src/lib.rs 2018-10-24 21:38:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/src/lib.rs 2018-12-05 01:24:40.000000000 +0000 @@ -315,7 +315,8 @@ //! [macro]: https://docs.serde.rs/serde_json/macro.json.html //! [`serde-json-core`]: https://japaric.github.io/serde-json-core/serde_json_core/ -#![doc(html_root_url = "https://docs.rs/serde_json/1.0.26")] +#![doc(html_root_url = "https://docs.rs/serde_json/1.0.31")] +#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))] #![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))] // Whitelisted clippy lints #![cfg_attr( @@ -350,10 +351,10 @@ #[macro_use] extern crate serde; -extern crate ryu; #[cfg(feature = "preserve_order")] extern crate indexmap; extern crate itoa; +extern crate ryu; #[doc(inline)] pub use self::de::{from_reader, from_slice, from_str, Deserializer, StreamDeserializer}; @@ -389,3 +390,6 @@ mod iter; mod number; mod read; + +#[cfg(feature = "raw_value")] +mod raw; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/src/number.rs rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/src/number.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/src/number.rs 2018-10-24 21:38:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/src/number.rs 2018-12-05 01:24:40.000000000 +0000 @@ -12,10 +12,10 @@ use std::fmt::{self, Debug, Display}; #[cfg(feature = "arbitrary_precision")] -use ryu; -#[cfg(feature = "arbitrary_precision")] use itoa; #[cfg(feature = "arbitrary_precision")] +use ryu; +#[cfg(feature = "arbitrary_precision")] use serde::de::{IntoDeserializer, MapAccess}; use de::ParserNumber; @@ -26,12 +26,7 @@ #[cfg(feature = "arbitrary_precision")] /// Not public API. Should be pub(crate). #[doc(hidden)] -pub const SERDE_STRUCT_FIELD_NAME: &'static str = "$__serde_private_number"; - -#[cfg(feature = "arbitrary_precision")] -/// Not public API. Should be pub(crate). -#[doc(hidden)] -pub const SERDE_STRUCT_NAME: &'static str = "$__serde_private_Number"; +pub const TOKEN: &'static str = "$serde_json::private::Number"; /// Represents a JSON number, whether integer or floating point. #[derive(Clone, PartialEq)] @@ -346,8 +341,8 @@ { use serde::ser::SerializeStruct; - let mut s = serializer.serialize_struct(SERDE_STRUCT_NAME, 1)?; - s.serialize_field(SERDE_STRUCT_FIELD_NAME, &self.n)?; + let mut s = serializer.serialize_struct(TOKEN, 1)?; + s.serialize_field(TOKEN, &self.n)?; s.end() } } @@ -426,7 +421,7 @@ where E: de::Error, { - if s == SERDE_STRUCT_FIELD_NAME { + if s == TOKEN { Ok(()) } else { Err(de::Error::custom("expected field with custom name")) @@ -638,7 +633,7 @@ where V: de::Visitor<'de>, { - visitor.visit_borrowed_str(SERDE_STRUCT_FIELD_NAME) + visitor.visit_borrowed_str(TOKEN) } forward_to_deserialize_any! { @@ -701,9 +696,7 @@ { N::PosInt(u as u64) } #[cfg(feature = "arbitrary_precision")] { - let mut buf = Vec::new(); - itoa::write(&mut buf, u).unwrap(); - String::from_utf8(buf).unwrap() + itoa::Buffer::new().format(u).to_owned() } }; Number { n: n } @@ -732,9 +725,7 @@ } #[cfg(feature = "arbitrary_precision")] { - let mut buf = Vec::new(); - itoa::write(&mut buf, i).unwrap(); - String::from_utf8(buf).unwrap() + itoa::Buffer::new().format(i).to_owned() } }; Number { n: n } diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/src/raw.rs rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/src/raw.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/src/raw.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/src/raw.rs 2018-12-05 01:24:40.000000000 +0000 @@ -0,0 +1,469 @@ +use std::fmt::{self, Debug, Display}; +use std::mem; + +use serde::ser::{Serialize, Serializer, SerializeStruct}; +use serde::de::{self, Deserialize, Deserializer, DeserializeSeed, IntoDeserializer, MapAccess, Unexpected, Visitor}; +use serde::de::value::BorrowedStrDeserializer; + +use error::Error; + +/// Reference to a range of bytes encompassing a single valid JSON value in the +/// input data. +/// +/// A `RawValue` can be used to defer parsing parts of a payload until later, +/// or to avoid parsing it at all in the case that part of the payload just +/// needs to be transferred verbatim into a different output object. +/// +/// When serializing, a value of this type will retain its original formatting +/// and will not be minified or pretty-printed. +/// +/// # Example +/// +/// ``` +/// #[macro_use] +/// extern crate serde_derive; +/// extern crate serde_json; +/// +/// use serde_json::{Result, value::RawValue}; +/// +/// #[derive(Deserialize)] +/// struct Input<'a> { +/// code: u32, +/// #[serde(borrow)] +/// payload: &'a RawValue, +/// } +/// +/// #[derive(Serialize)] +/// struct Output<'a> { +/// info: (u32, &'a RawValue), +/// } +/// +/// // Efficiently rearrange JSON input containing separate "code" and "payload" +/// // keys into a single "info" key holding an array of code and payload. +/// // +/// // This could be done equivalently using serde_json::Value as the type for +/// // payload, but &RawValue will perform netter because it does not require +/// // memory allocation. The correct range of bytes is borrowed from the input +/// // data and pasted verbatim into the output. +/// fn rearrange(input: &str) -> Result { +/// let input: Input = serde_json::from_str(input)?; +/// +/// let output = Output { +/// info: (input.code, input.payload), +/// }; +/// +/// serde_json::to_string(&output) +/// } +/// +/// fn main() -> Result<()> { +/// let out = rearrange(r#" {"code": 200, "payload": {}} "#)?; +/// +/// assert_eq!(out, r#"{"info":[200,{}]}"#); +/// +/// Ok(()) +/// } +/// ``` +/// +/// # Ownership +/// +/// The typical usage of `RawValue` will be in the borrowed form: +/// +/// ``` +/// # #[macro_use] +/// # extern crate serde_derive; +/// # extern crate serde_json; +/// # +/// # use serde_json::value::RawValue; +/// # +/// #[derive(Deserialize)] +/// struct SomeStruct<'a> { +/// #[serde(borrow)] +/// raw_value: &'a RawValue, +/// } +/// # +/// # fn main() {} +/// ``` +/// +/// The borrowed form is suitable when deserializing through +/// [`serde_json::from_str`] and [`serde_json::from_slice`] which support +/// borrowing from the input data without memory allocation. +/// +/// When deserializing through [`serde_json::from_reader`] you will need to use +/// the boxed form of `RawValue` instead. This is almost as efficient but +/// involves buffering the raw value from the I/O stream into memory. +/// +/// [`serde_json::from_str`]: ../fn.from_str.html +/// [`serde_json::from_slice`]: ../fn.from_slice.html +/// [`serde_json::from_reader`]: ../fn.from_reader.html +/// +/// ``` +/// # #[macro_use] +/// # extern crate serde_derive; +/// # extern crate serde_json; +/// # +/// # use serde_json::value::RawValue; +/// # +/// #[derive(Deserialize)] +/// struct SomeStruct { +/// raw_value: Box, +/// } +/// # +/// # fn main() {} +/// ``` +/// +/// # Note +/// +/// `RawValue` is only available if serde\_json is built with the `"raw_value"` +/// feature. +/// +/// ```toml +/// [dependencies] +/// serde_json = { version = "1.0", features = ["raw_value"] } +/// ``` +#[repr(C)] +pub struct RawValue { + json: str, +} + +impl RawValue { + fn from_borrowed(json: &str) -> &Self { + unsafe { mem::transmute::<&str, &RawValue>(json) } + } + + fn from_owned(json: Box) -> Box { + unsafe { mem::transmute::, Box>(json) } + } +} + +impl Clone for Box { + fn clone(&self) -> Self { + (**self).to_owned() + } +} + +impl ToOwned for RawValue { + type Owned = Box; + + fn to_owned(&self) -> Self::Owned { + RawValue::from_owned(self.json.to_owned().into_boxed_str()) + } +} + +impl Default for Box { + fn default() -> Self { + RawValue::from_borrowed("null").to_owned() + } +} + +impl Debug for RawValue { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter + .debug_tuple("RawValue") + .field(&format_args!("{}", &self.json)) + .finish() + } +} + +impl Display for RawValue { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str(&self.json) + } +} + +impl RawValue { + /// Convert an owned `String` of JSON data to an owned `RawValue`. + /// + /// This function is equivalent to `serde_json::from_str::>` + /// except that we avoid an allocation and memcpy if both of the following + /// are true: + /// + /// - the input has no leading or trailing whitespace, and + /// - the input has capacity equal to its length. + pub fn from_string(json: String) -> Result, Error> { + { + let borrowed = ::from_str::<&Self>(&json)?; + if borrowed.json.len() < json.len() { + return Ok(borrowed.to_owned()); + } + } + Ok(Self::from_owned(json.into_boxed_str())) + } + + /// Access the JSON text underlying a raw value. + /// + /// # Example + /// + /// ``` + /// #[macro_use] + /// extern crate serde_derive; + /// extern crate serde_json; + /// + /// use serde_json::{Result, value::RawValue}; + /// + /// #[derive(Deserialize)] + /// struct Response<'a> { + /// code: u32, + /// #[serde(borrow)] + /// payload: &'a RawValue, + /// } + /// + /// fn process(input: &str) -> Result<()> { + /// let response: Response = serde_json::from_str(input)?; + /// + /// let payload = response.payload.get(); + /// if payload.starts_with('{') { + /// // handle a payload which is a JSON map + /// } else { + /// // handle any other type + /// } + /// + /// Ok(()) + /// } + /// + /// fn main() -> Result<()> { + /// process(r#" {"code": 200, "payload": {}} "#)?; + /// Ok(()) + /// } + /// ``` + pub fn get(&self) -> &str { + &self.json + } +} + +pub const TOKEN: &'static str = "$serde_json::private::RawValue"; + +impl Serialize for RawValue { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut s = serializer.serialize_struct(TOKEN, 1)?; + s.serialize_field(TOKEN, &self.json)?; + s.end() + } +} + +impl<'de: 'a, 'a> Deserialize<'de> for &'a RawValue { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ReferenceVisitor; + + impl<'de> Visitor<'de> for ReferenceVisitor { + type Value = &'de RawValue; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + write!(formatter, "any valid JSON value") + } + + fn visit_map(self, mut visitor: V) -> Result + where + V: MapAccess<'de>, + { + let value = visitor.next_key::()?; + if value.is_none() { + return Err(de::Error::invalid_type(Unexpected::Map, &self)); + } + visitor.next_value_seed(ReferenceFromString) + } + } + + deserializer.deserialize_newtype_struct(TOKEN, ReferenceVisitor) + } +} + +impl<'de> Deserialize<'de> for Box { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct BoxedVisitor; + + impl<'de> Visitor<'de> for BoxedVisitor { + type Value = Box; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + write!(formatter, "any valid JSON value") + } + + fn visit_map(self, mut visitor: V) -> Result + where + V: MapAccess<'de>, + { + let value = visitor.next_key::()?; + if value.is_none() { + return Err(de::Error::invalid_type(Unexpected::Map, &self)); + } + visitor.next_value_seed(BoxedFromString) + } + } + + deserializer.deserialize_newtype_struct(TOKEN, BoxedVisitor) + } +} + +struct RawKey; + +impl<'de> Deserialize<'de> for RawKey { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FieldVisitor; + + impl<'de> Visitor<'de> for FieldVisitor { + type Value = (); + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("raw value") + } + + fn visit_str(self, s: &str) -> Result<(), E> + where + E: de::Error, + { + if s == TOKEN { + Ok(()) + } else { + Err(de::Error::custom("unexpected raw value")) + } + } + } + + deserializer.deserialize_identifier(FieldVisitor)?; + Ok(RawKey) + } +} + +pub struct ReferenceFromString; + +impl<'de> DeserializeSeed<'de> for ReferenceFromString { + type Value = &'de RawValue; + + fn deserialize(self, deserializer: D) -> Result + where + D: Deserializer<'de>, + { + deserializer.deserialize_str(self) + } +} + +impl<'de> Visitor<'de> for ReferenceFromString { + type Value = &'de RawValue; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("raw value") + } + + fn visit_borrowed_str(self, s: &'de str) -> Result + where + E: de::Error, + { + Ok(RawValue::from_borrowed(s)) + } +} + +pub struct BoxedFromString; + +impl<'de> DeserializeSeed<'de> for BoxedFromString { + type Value = Box; + + fn deserialize(self, deserializer: D) -> Result + where + D: Deserializer<'de>, + { + deserializer.deserialize_str(self) + } +} + +impl<'de> Visitor<'de> for BoxedFromString { + type Value = Box; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("raw value") + } + + fn visit_str(self, s: &str) -> Result + where + E: de::Error, + { + self.visit_string(s.to_owned()) + } + + fn visit_string(self, s: String) -> Result + where + E: de::Error, + { + Ok(RawValue::from_owned(s.into_boxed_str())) + } +} + +struct RawKeyDeserializer; + +impl<'de> Deserializer<'de> for RawKeyDeserializer { + type Error = Error; + + fn deserialize_any(self, visitor: V) -> Result + where + V: de::Visitor<'de>, + { + visitor.visit_borrowed_str(TOKEN) + } + + forward_to_deserialize_any! { + bool u8 u16 u32 u64 u128 i8 i16 i32 i64 i128 f32 f64 char str string seq + bytes byte_buf map struct option unit newtype_struct ignored_any + unit_struct tuple_struct tuple enum identifier + } +} + +pub struct OwnedRawDeserializer { + pub raw_value: Option, +} + +impl<'de> MapAccess<'de> for OwnedRawDeserializer { + type Error = Error; + + fn next_key_seed(&mut self, seed: K) -> Result, Error> + where + K: de::DeserializeSeed<'de>, + { + if self.raw_value.is_none() { + return Ok(None); + } + seed.deserialize(RawKeyDeserializer).map(Some) + } + + fn next_value_seed(&mut self, seed: V) -> Result + where + V: de::DeserializeSeed<'de>, + { + seed.deserialize(self.raw_value.take().unwrap().into_deserializer()) + } +} + +pub struct BorrowedRawDeserializer<'de> { + pub raw_value: Option<&'de str>, +} + +impl<'de> MapAccess<'de> for BorrowedRawDeserializer<'de> { + type Error = Error; + + fn next_key_seed(&mut self, seed: K) -> Result, Error> + where + K: de::DeserializeSeed<'de>, + { + if self.raw_value.is_none() { + return Ok(None); + } + seed.deserialize(RawKeyDeserializer).map(Some) + } + + fn next_value_seed(&mut self, seed: V) -> Result + where + V: de::DeserializeSeed<'de>, + { + seed.deserialize(BorrowedStrDeserializer::new(self.raw_value.take().unwrap())) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/src/read.rs rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/src/read.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/src/read.rs 2018-10-24 21:38:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/src/read.rs 2018-12-05 01:24:40.000000000 +0000 @@ -9,9 +9,15 @@ use std::ops::Deref; use std::{char, cmp, io, str}; +#[cfg(feature = "raw_value")] +use serde::de::Visitor; + use iter::LineColIterator; -use super::error::{Error, ErrorCode, Result}; +use error::{Error, ErrorCode, Result}; + +#[cfg(feature = "raw_value")] +use raw::{BorrowedRawDeserializer, OwnedRawDeserializer}; /// Trait used by the deserializer for iterating over input. This is manually /// "specialized" for iterating over &[u8]. Once feature(specialization) is @@ -76,6 +82,26 @@ /// string until the next quotation mark but discards the data. #[doc(hidden)] fn ignore_str(&mut self) -> Result<()>; + + /// Assumes the previous byte was a hex escape sequnce ('\u') in a string. + /// Parses next hexadecimal sequence. + #[doc(hidden)] + fn decode_hex_escape(&mut self) -> Result; + + /// Switch raw buffering mode on. + /// + /// This is used when deserializing `RawValue`. + #[cfg(feature = "raw_value")] + #[doc(hidden)] + fn begin_raw_buffering(&mut self); + + /// Switch raw buffering mode off and provides the raw buffered data to the + /// given visitor. + #[cfg(feature = "raw_value")] + #[doc(hidden)] + fn end_raw_buffering(&mut self, visitor: V) -> Result + where + V: Visitor<'de>; } pub struct Position { @@ -107,6 +133,8 @@ iter: LineColIterator>, /// Temporary storage of peeked byte. ch: Option, + #[cfg(feature = "raw_value")] + raw_buffer: Option>, } /// JSON input source that reads from a slice of bytes. @@ -117,6 +145,8 @@ slice: &'a [u8], /// Index of the *next* byte that will be returned by next() or peek(). index: usize, + #[cfg(feature = "raw_value")] + raw_buffering_start_index: usize, } /// JSON input source that reads from a UTF-8 string. @@ -124,6 +154,8 @@ // Able to elide UTF-8 checks by assuming that the input is valid UTF-8. pub struct StrRead<'a> { delegate: SliceRead<'a>, + #[cfg(feature = "raw_value")] + data: &'a str, } // Prevent users from implementing the Read trait. @@ -139,9 +171,20 @@ { /// Create a JSON input source to read from a std::io input stream. pub fn new(reader: R) -> Self { - IoRead { - iter: LineColIterator::new(reader.bytes()), - ch: None, + #[cfg(not(feature = "raw_value"))] + { + IoRead { + iter: LineColIterator::new(reader.bytes()), + ch: None, + } + } + #[cfg(feature = "raw_value")] + { + IoRead { + iter: LineColIterator::new(reader.bytes()), + ch: None, + raw_buffer: None, + } } } } @@ -193,10 +236,26 @@ #[inline] fn next(&mut self) -> io::Result> { match self.ch.take() { - Some(ch) => Ok(Some(ch)), + Some(ch) => { + #[cfg(feature = "raw_value")] + { + if let Some(ref mut buf) = self.raw_buffer { + buf.push(ch); + } + } + Ok(Some(ch)) + } None => match self.iter.next() { Some(Err(err)) => Err(err), - Some(Ok(ch)) => Ok(Some(ch)), + Some(Ok(ch)) => { + #[cfg(feature = "raw_value")] + { + if let Some(ref mut buf) = self.raw_buffer { + buf.push(ch); + } + } + Ok(Some(ch)) + } None => Ok(None), }, } @@ -217,11 +276,21 @@ } } + #[cfg(not(feature = "raw_value"))] #[inline] fn discard(&mut self) { self.ch = None; } + #[cfg(feature = "raw_value")] + fn discard(&mut self) { + if let Some(ch) = self.ch.take() { + if let Some(ref mut buf) = self.raw_buffer { + buf.push(ch); + } + } + } + fn position(&self) -> Position { Position { line: self.iter.line(), @@ -274,6 +343,34 @@ } } } + + fn decode_hex_escape(&mut self) -> Result { + let mut n = 0; + for _ in 0..4 { + match decode_hex_val(try!(next_or_eof(self))) { + None => return error(self, ErrorCode::InvalidEscape), + Some(val) => { + n = (n << 4) + val; + } + } + } + Ok(n) + } + + #[cfg(feature = "raw_value")] + fn begin_raw_buffering(&mut self) { + self.raw_buffer = Some(Vec::new()); + } + + #[cfg(feature = "raw_value")] + fn end_raw_buffering(&mut self, visitor: V) -> Result + where + V: Visitor<'de>, + { + let raw = self.raw_buffer.take().unwrap(); + let raw = String::from_utf8(raw).unwrap(); + visitor.visit_map(OwnedRawDeserializer { raw_value: Some(raw) }) + } } ////////////////////////////////////////////////////////////////////////////// @@ -281,9 +378,20 @@ impl<'a> SliceRead<'a> { /// Create a JSON input source to read from a slice of bytes. pub fn new(slice: &'a [u8]) -> Self { - SliceRead { - slice: slice, - index: 0, + #[cfg(not(feature = "raw_value"))] + { + SliceRead { + slice: slice, + index: 0, + } + } + #[cfg(feature = "raw_value")] + { + SliceRead { + slice: slice, + index: 0, + raw_buffering_start_index: 0, + } } } @@ -437,6 +545,38 @@ } } } + + fn decode_hex_escape(&mut self) -> Result { + if self.index + 4 > self.slice.len() { + return error(self, ErrorCode::EofWhileParsingString); + } + let mut n = 0; + for _ in 0..4 { + match decode_hex_val(self.slice[self.index]) { + None => return error(self, ErrorCode::InvalidEscape), + Some(val) => { + n = (n << 4) + val; + } + } + self.index += 1; + } + Ok(n) + } + + #[cfg(feature = "raw_value")] + fn begin_raw_buffering(&mut self) { + self.raw_buffering_start_index = self.index; + } + + #[cfg(feature = "raw_value")] + fn end_raw_buffering(&mut self, visitor: V) -> Result + where + V: Visitor<'a>, + { + let raw = &self.slice[self.raw_buffering_start_index..self.index]; + let raw = str::from_utf8(raw).unwrap(); + visitor.visit_map(BorrowedRawDeserializer { raw_value: Some(raw) }) + } } ////////////////////////////////////////////////////////////////////////////// @@ -444,8 +584,18 @@ impl<'a> StrRead<'a> { /// Create a JSON input source to read from a UTF-8 string. pub fn new(s: &'a str) -> Self { - StrRead { - delegate: SliceRead::new(s.as_bytes()), + #[cfg(not(feature = "raw_value"))] + { + StrRead { + delegate: SliceRead::new(s.as_bytes()), + } + } + #[cfg(feature = "raw_value")] + { + StrRead { + delegate: SliceRead::new(s.as_bytes()), + data: s, + } } } } @@ -498,6 +648,24 @@ fn ignore_str(&mut self) -> Result<()> { self.delegate.ignore_str() } + + fn decode_hex_escape(&mut self) -> Result { + self.delegate.decode_hex_escape() + } + + #[cfg(feature = "raw_value")] + fn begin_raw_buffering(&mut self) { + self.delegate.begin_raw_buffering() + } + + #[cfg(feature = "raw_value")] + fn end_raw_buffering(&mut self, visitor: V) -> Result + where + V: Visitor<'a>, + { + let raw = &self.data[self.delegate.raw_buffering_start_index..self.delegate.index]; + visitor.visit_map(BorrowedRawDeserializer { raw_value: Some(raw) }) + } } ////////////////////////////////////////////////////////////////////////////// @@ -561,7 +729,7 @@ b'r' => scratch.push(b'\r'), b't' => scratch.push(b'\t'), b'u' => { - let c = match try!(decode_hex_escape(read)) { + let c = match try!(read.decode_hex_escape()) { 0xDC00...0xDFFF => { return error(read, ErrorCode::LoneLeadingSurrogateInHexEscape); } @@ -576,7 +744,7 @@ return error(read, ErrorCode::UnexpectedEndOfHexEscape); } - let n2 = try!(decode_hex_escape(read)); + let n2 = try!(read.decode_hex_escape()); if n2 < 0xDC00 || n2 > 0xDFFF { return error(read, ErrorCode::LoneLeadingSurrogateInHexEscape); @@ -618,7 +786,7 @@ match ch { b'"' | b'\\' | b'/' | b'b' | b'f' | b'n' | b'r' | b't' => {} b'u' => { - let n = match try!(decode_hex_escape(read)) { + let n = match try!(read.decode_hex_escape()) { 0xDC00...0xDFFF => { return error(read, ErrorCode::LoneLeadingSurrogateInHexEscape); } @@ -633,7 +801,7 @@ return error(read, ErrorCode::UnexpectedEndOfHexEscape); } - let n2 = try!(decode_hex_escape(read)); + let n2 = try!(read.decode_hex_escape()); if n2 < 0xDC00 || n2 > 0xDFFF { return error(read, ErrorCode::LoneLeadingSurrogateInHexEscape); @@ -657,21 +825,32 @@ Ok(()) } -fn decode_hex_escape<'de, R: ?Sized + Read<'de>>(read: &mut R) -> Result { - let mut n = 0; - for _ in 0..4 { - n = match try!(next_or_eof(read)) { - c @ b'0'...b'9' => n * 16_u16 + ((c as u16) - (b'0' as u16)), - b'a' | b'A' => n * 16_u16 + 10_u16, - b'b' | b'B' => n * 16_u16 + 11_u16, - b'c' | b'C' => n * 16_u16 + 12_u16, - b'd' | b'D' => n * 16_u16 + 13_u16, - b'e' | b'E' => n * 16_u16 + 14_u16, - b'f' | b'F' => n * 16_u16 + 15_u16, - _ => { - return error(read, ErrorCode::InvalidEscape); - } - }; +#[cfg_attr(rustfmt, rustfmt_skip)] +static HEX: [u8; 256] = [ + // 1 2 3 4 5 6 7 8 9 A B C D E F + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // 0 + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // 1 + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // 2 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,255,255,255,255,255,255, // 3 + 255, 10, 11, 12, 13, 14, 15,255,255,255,255,255,255,255,255,255, // 4 + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // 5 + 255, 10, 11, 12, 13, 14, 15,255,255,255,255,255,255,255,255,255, // 6 + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // 7 + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // 8 + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // 9 + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // A + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // B + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // C + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // D + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // E + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // F +]; + +fn decode_hex_val(val: u8) -> Option { + let n = HEX[val as usize] as u16; + if n == 255 { + None + } else { + Some(n) } - Ok(n) } diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/src/ser.rs rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/src/ser.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/src/ser.rs 2018-10-24 21:38:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/src/ser.rs 2018-12-05 01:24:40.000000000 +0000 @@ -14,17 +14,11 @@ use std::str; use super::error::{Error, ErrorCode, Result}; -use serde::ser::{self, Impossible}; +use serde::ser::{self, Impossible, Serialize}; use itoa; use ryu; -#[cfg(feature = "arbitrary_precision")] -use serde::Serialize; - -#[cfg(feature = "arbitrary_precision")] -use number::{SERDE_STRUCT_FIELD_NAME, SERDE_STRUCT_NAME}; - /// A structure for serializing Rust values into JSON. pub struct Serializer { writer: W, @@ -291,7 +285,7 @@ #[inline] fn serialize_newtype_struct(self, _name: &'static str, value: &T) -> Result<()> where - T: ser::Serialize, + T: Serialize, { value.serialize(self) } @@ -305,7 +299,7 @@ value: &T, ) -> Result<()> where - T: ser::Serialize, + T: Serialize, { try!( self.formatter @@ -350,7 +344,7 @@ #[inline] fn serialize_some(self, value: &T) -> Result<()> where - T: ser::Serialize, + T: Serialize, { value.serialize(self) } @@ -461,19 +455,14 @@ } } - #[cfg(not(feature = "arbitrary_precision"))] - #[inline] - fn serialize_struct(self, _name: &'static str, len: usize) -> Result { - self.serialize_map(Some(len)) - } - - #[cfg(feature = "arbitrary_precision")] #[inline] fn serialize_struct(self, name: &'static str, len: usize) -> Result { - if name == SERDE_STRUCT_NAME { - Ok(Compound::Number { ser: self }) - } else { - self.serialize_map(Some(len)) + match name { + #[cfg(feature = "arbitrary_precision")] + ::number::TOKEN => Ok(Compound::Number { ser: self }), + #[cfg(feature = "raw_value")] + ::raw::TOKEN => Ok(Compound::RawValue { ser: self }), + _ => self.serialize_map(Some(len)), } } @@ -583,6 +572,8 @@ }, #[cfg(feature = "arbitrary_precision")] Number { ser: &'a mut Serializer }, + #[cfg(feature = "raw_value")] + RawValue { ser: &'a mut Serializer }, } impl<'a, W, F> ser::SerializeSeq for Compound<'a, W, F> @@ -596,7 +587,7 @@ #[inline] fn serialize_element(&mut self, value: &T) -> Result<()> where - T: ser::Serialize, + T: Serialize, { match *self { Compound::Map { @@ -619,6 +610,8 @@ } #[cfg(feature = "arbitrary_precision")] Compound::Number { .. } => unreachable!(), + #[cfg(feature = "raw_value")] + Compound::RawValue { .. } => unreachable!(), } } @@ -634,6 +627,8 @@ } #[cfg(feature = "arbitrary_precision")] Compound::Number { .. } => unreachable!(), + #[cfg(feature = "raw_value")] + Compound::RawValue { .. } => unreachable!(), } } } @@ -649,7 +644,7 @@ #[inline] fn serialize_element(&mut self, value: &T) -> Result<()> where - T: ser::Serialize, + T: Serialize, { ser::SerializeSeq::serialize_element(self, value) } @@ -671,7 +666,7 @@ #[inline] fn serialize_field(&mut self, value: &T) -> Result<()> where - T: ser::Serialize, + T: Serialize, { ser::SerializeSeq::serialize_element(self, value) } @@ -693,7 +688,7 @@ #[inline] fn serialize_field(&mut self, value: &T) -> Result<()> where - T: ser::Serialize, + T: Serialize, { ser::SerializeSeq::serialize_element(self, value) } @@ -716,6 +711,8 @@ } #[cfg(feature = "arbitrary_precision")] Compound::Number { .. } => unreachable!(), + #[cfg(feature = "raw_value")] + Compound::RawValue { .. } => unreachable!(), } } } @@ -731,7 +728,7 @@ #[inline] fn serialize_key(&mut self, key: &T) -> Result<()> where - T: ser::Serialize, + T: Serialize, { match *self { Compound::Map { @@ -756,13 +753,15 @@ } #[cfg(feature = "arbitrary_precision")] Compound::Number { .. } => unreachable!(), + #[cfg(feature = "raw_value")] + Compound::RawValue { .. } => unreachable!(), } } #[inline] fn serialize_value(&mut self, value: &T) -> Result<()> where - T: ser::Serialize, + T: Serialize, { match *self { Compound::Map { ref mut ser, .. } => { @@ -781,6 +780,8 @@ } #[cfg(feature = "arbitrary_precision")] Compound::Number { .. } => unreachable!(), + #[cfg(feature = "raw_value")] + Compound::RawValue { .. } => unreachable!(), } } @@ -796,6 +797,8 @@ } #[cfg(feature = "arbitrary_precision")] Compound::Number { .. } => unreachable!(), + #[cfg(feature = "raw_value")] + Compound::RawValue { .. } => unreachable!(), } } } @@ -811,7 +814,7 @@ #[inline] fn serialize_field(&mut self, key: &'static str, value: &T) -> Result<()> where - T: ser::Serialize, + T: Serialize, { match *self { Compound::Map { .. } => { @@ -820,13 +823,22 @@ } #[cfg(feature = "arbitrary_precision")] Compound::Number { ref mut ser, .. } => { - if key == SERDE_STRUCT_FIELD_NAME { + if key == ::number::TOKEN { try!(value.serialize(NumberStrEmitter(&mut *ser))); Ok(()) } else { Err(invalid_number()) } } + #[cfg(feature = "raw_value")] + Compound::RawValue { ref mut ser, .. } => { + if key == ::raw::TOKEN { + try!(value.serialize(RawValueStrEmitter(&mut *ser))); + Ok(()) + } else { + Err(invalid_raw_value()) + } + } } } @@ -836,6 +848,8 @@ Compound::Map { .. } => ser::SerializeMap::end(self), #[cfg(feature = "arbitrary_precision")] Compound::Number { .. } => Ok(()), + #[cfg(feature = "raw_value")] + Compound::RawValue { .. } => Ok(()), } } } @@ -851,12 +865,14 @@ #[inline] fn serialize_field(&mut self, key: &'static str, value: &T) -> Result<()> where - T: ser::Serialize, + T: Serialize, { match *self { Compound::Map { .. } => ser::SerializeStruct::serialize_field(self, key, value), #[cfg(feature = "arbitrary_precision")] Compound::Number { .. } => unreachable!(), + #[cfg(feature = "raw_value")] + Compound::RawValue { .. } => unreachable!(), } } @@ -878,6 +894,8 @@ } #[cfg(feature = "arbitrary_precision")] Compound::Number { .. } => unreachable!(), + #[cfg(feature = "raw_value")] + Compound::RawValue { .. } => unreachable!(), } } } @@ -891,6 +909,11 @@ Error::syntax(ErrorCode::InvalidNumber, 0, 0) } +#[cfg(feature = "raw_value")] +fn invalid_raw_value() -> Error { + Error::syntax(ErrorCode::ExpectedSomeValue, 0, 0) +} + fn key_must_be_a_string() -> Error { Error::syntax(ErrorCode::KeyMustBeAString, 0, 0) } @@ -921,7 +944,7 @@ #[inline] fn serialize_newtype_struct(self, _name: &'static str, value: &T) -> Result<()> where - T: ser::Serialize, + T: Serialize, { value.serialize(self) } @@ -1164,7 +1187,7 @@ _value: &T, ) -> Result<()> where - T: ser::Serialize, + T: Serialize, { Err(key_must_be_a_string()) } @@ -1175,7 +1198,7 @@ fn serialize_some(self, _value: &T) -> Result<()> where - T: ser::Serialize, + T: Serialize, { Err(key_must_be_a_string()) } @@ -1410,6 +1433,191 @@ } } +#[cfg(feature = "raw_value")] +struct RawValueStrEmitter<'a, W: 'a + io::Write, F: 'a + Formatter>(&'a mut Serializer); + +#[cfg(feature = "raw_value")] +impl<'a, W: io::Write, F: Formatter> ser::Serializer for RawValueStrEmitter<'a, W, F> { + type Ok = (); + type Error = Error; + + type SerializeSeq = Impossible<(), Error>; + type SerializeTuple = Impossible<(), Error>; + type SerializeTupleStruct = Impossible<(), Error>; + type SerializeTupleVariant = Impossible<(), Error>; + type SerializeMap = Impossible<(), Error>; + type SerializeStruct = Impossible<(), Error>; + type SerializeStructVariant = Impossible<(), Error>; + + fn serialize_bool(self, _v: bool) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_i8(self, _v: i8) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_i16(self, _v: i16) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_i32(self, _v: i32) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_i64(self, _v: i64) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + + serde_if_integer128! { + fn serialize_i128(self, _v: i128) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + } + + fn serialize_u8(self, _v: u8) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_u16(self, _v: u16) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_u32(self, _v: u32) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_u64(self, _v: u64) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + + serde_if_integer128! { + fn serialize_u128(self, _v: u128) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + } + + fn serialize_f32(self, _v: f32) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_f64(self, _v: f64) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_char(self, _v: char) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_str(self, value: &str) -> Result { + let RawValueStrEmitter(serializer) = self; + serializer + .formatter + .write_raw_fragment(&mut serializer.writer, value) + .map_err(Error::io) + } + + fn serialize_bytes(self, _value: &[u8]) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_none(self) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_some(self, _value: &T) -> Result + where + T: Serialize, + { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_unit(self) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_unit_struct(self, _name: &'static str) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_unit_variant( + self, + _name: &'static str, + _variant_index: u32, + _variant: &'static str, + ) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_newtype_struct( + self, + _name: &'static str, + _value: &T, + ) -> Result + where + T: Serialize, + { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_newtype_variant( + self, + _name: &'static str, + _variant_index: u32, + _variant: &'static str, + _value: &T, + ) -> Result + where + T: Serialize, + { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_seq(self, _len: Option) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_tuple(self, _len: usize) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_tuple_struct( + self, + _name: &'static str, + _len: usize, + ) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_tuple_variant( + self, + _name: &'static str, + _variant_index: u32, + _variant: &'static str, + _len: usize, + ) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_map(self, _len: Option) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_struct(self, _name: &'static str, _len: usize) -> Result { + Err(ser::Error::custom("expected RawValue")) + } + + fn serialize_struct_variant( + self, + _name: &'static str, + _variant_index: u32, + _variant: &'static str, + _len: usize, + ) -> Result { + Err(ser::Error::custom("expected RawValue")) + } +} + /// Represents a character escape code in a type-safe manner. pub enum CharEscape { /// An escaped quote `"` @@ -1753,6 +1961,16 @@ { Ok(()) } + + /// Writes a raw JSON fragment that doesn't need any escaping to the + /// specified writer. + #[inline] + fn write_raw_fragment(&mut self, writer: &mut W, fragment: &str) -> io::Result<()> + where + W: io::Write, + { + writer.write_all(fragment.as_bytes()) + } } /// This structure compacts a JSON value with no extra whitespace. @@ -1989,7 +2207,7 @@ pub fn to_writer(writer: W, value: &T) -> Result<()> where W: io::Write, - T: ser::Serialize, + T: Serialize, { let mut ser = Serializer::new(writer); try!(value.serialize(&mut ser)); @@ -2007,7 +2225,7 @@ pub fn to_writer_pretty(writer: W, value: &T) -> Result<()> where W: io::Write, - T: ser::Serialize, + T: Serialize, { let mut ser = Serializer::pretty(writer); try!(value.serialize(&mut ser)); @@ -2023,7 +2241,7 @@ #[inline] pub fn to_vec(value: &T) -> Result> where - T: ser::Serialize, + T: Serialize, { let mut writer = Vec::with_capacity(128); try!(to_writer(&mut writer, value)); @@ -2039,7 +2257,7 @@ #[inline] pub fn to_vec_pretty(value: &T) -> Result> where - T: ser::Serialize, + T: Serialize, { let mut writer = Vec::with_capacity(128); try!(to_writer_pretty(&mut writer, value)); @@ -2055,7 +2273,7 @@ #[inline] pub fn to_string(value: &T) -> Result where - T: ser::Serialize, + T: Serialize, { let vec = try!(to_vec(value)); let string = unsafe { @@ -2074,7 +2292,7 @@ #[inline] pub fn to_string_pretty(value: &T) -> Result where - T: ser::Serialize, + T: Serialize, { let vec = try!(to_vec_pretty(value)); let string = unsafe { diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/src/value/de.rs rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/src/value/de.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/src/value/de.rs 2018-10-24 21:38:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/src/value/de.rs 2018-12-05 01:24:40.000000000 +0000 @@ -23,11 +23,10 @@ use number::Number; use value::Value; -#[cfg(feature = "arbitrary_precision")] use serde::de; #[cfg(feature = "arbitrary_precision")] -use number::{NumberFromString, SERDE_STRUCT_FIELD_NAME}; +use number::NumberFromString; impl<'de> Deserialize<'de> for Value { #[inline] @@ -109,44 +108,33 @@ Ok(Value::Array(vec)) } - #[cfg(not(feature = "arbitrary_precision"))] - fn visit_map(self, mut visitor: V) -> Result - where - V: MapAccess<'de>, - { - let mut values = Map::new(); - - while let Some((key, value)) = try!(visitor.next_entry()) { - values.insert(key, value); - } - - Ok(Value::Object(values)) - } - - #[cfg(feature = "arbitrary_precision")] fn visit_map(self, mut visitor: V) -> Result where V: MapAccess<'de>, { - let mut key = String::new(); - let number = visitor.next_key_seed(NumberOrObject { key: &mut key })?; - match number { - Some(true) => { + match visitor.next_key_seed(KeyClassifier)? { + #[cfg(feature = "arbitrary_precision")] + Some(KeyClass::Number) => { let number: NumberFromString = visitor.next_value()?; - return Ok(Value::Number(number.value)); + Ok(Value::Number(number.value)) } - None => return Ok(Value::Object(Map::new())), - Some(false) => {} - } + #[cfg(feature = "raw_value")] + Some(KeyClass::RawValue) => { + let value = visitor.next_value_seed(::raw::BoxedFromString)?; + ::from_str(value.get()).map_err(de::Error::custom) + } + Some(KeyClass::Map(first_key)) => { + let mut values = Map::new(); - let mut values = Map::new(); + values.insert(first_key, try!(visitor.next_value())); + while let Some((key, value)) = try!(visitor.next_entry()) { + values.insert(key, value); + } - values.insert(key, try!(visitor.next_value())); - while let Some((key, value)) = try!(visitor.next_entry()) { - values.insert(key, value); + Ok(Value::Object(values)) + } + None => Ok(Value::Object(Map::new())), } - - Ok(Value::Object(values)) } } @@ -317,12 +305,22 @@ #[inline] fn deserialize_newtype_struct( self, - _name: &'static str, + name: &'static str, visitor: V, ) -> Result where V: Visitor<'de>, { + #[cfg(feature = "raw_value")] + { + if name == ::raw::TOKEN { + return visitor.visit_map(::raw::OwnedRawDeserializer { + raw_value: Some(self.to_string()), + }); + } + } + + let _ = name; visitor.visit_newtype_struct(self) } @@ -846,12 +844,22 @@ #[inline] fn deserialize_newtype_struct( self, - _name: &'static str, + name: &'static str, visitor: V, ) -> Result where V: Visitor<'de>, { + #[cfg(feature = "raw_value")] + { + if name == ::raw::TOKEN { + return visitor.visit_map(::raw::OwnedRawDeserializer { + raw_value: Some(self.to_string()), + }); + } + } + + let _ = name; visitor.visit_newtype_struct(self) } @@ -1303,52 +1311,57 @@ } } -#[cfg(feature = "arbitrary_precision")] -struct NumberOrObject<'a> { - key: &'a mut String, +struct KeyClassifier; + +enum KeyClass { + Map(String), + #[cfg(feature = "arbitrary_precision")] + Number, + #[cfg(feature = "raw_value")] + RawValue, } -#[cfg(feature = "arbitrary_precision")] -impl<'a, 'de> DeserializeSeed<'de> for NumberOrObject<'a> { - type Value = bool; +impl<'de> DeserializeSeed<'de> for KeyClassifier { + type Value = KeyClass; fn deserialize(self, deserializer: D) -> Result where D: serde::Deserializer<'de>, { - deserializer.deserialize_any(self) + deserializer.deserialize_str(self) } } -#[cfg(feature = "arbitrary_precision")] -impl<'a, 'de> Visitor<'de> for NumberOrObject<'a> { - type Value = bool; +impl<'de> Visitor<'de> for KeyClassifier { + type Value = KeyClass; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("a string key") } - fn visit_str(self, s: &str) -> Result + fn visit_str(self, s: &str) -> Result where E: de::Error, { - if s == SERDE_STRUCT_FIELD_NAME { - Ok(true) - } else { - self.key.push_str(s); - Ok(false) + match s { + #[cfg(feature = "arbitrary_precision")] + ::number::TOKEN => Ok(KeyClass::Number), + #[cfg(feature = "raw_value")] + ::raw::TOKEN => Ok(KeyClass::RawValue), + _ => Ok(KeyClass::Map(s.to_owned())), } } - fn visit_string(self, s: String) -> Result + fn visit_string(self, s: String) -> Result where E: de::Error, { - if s == SERDE_STRUCT_FIELD_NAME { - Ok(true) - } else { - *self.key = s; - Ok(false) + match s.as_str() { + #[cfg(feature = "arbitrary_precision")] + ::number::TOKEN => Ok(KeyClass::Number), + #[cfg(feature = "raw_value")] + ::raw::TOKEN => Ok(KeyClass::RawValue), + _ => Ok(KeyClass::Map(s)), } } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/src/value/mod.rs rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/src/value/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/src/value/mod.rs 2018-10-24 21:38:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/src/value/mod.rs 2018-12-05 01:24:40.000000000 +0000 @@ -68,7 +68,7 @@ //! //! A string of JSON data can be parsed into a `serde_json::Value` by the //! [`serde_json::from_str`][from_str] function. There is also -//! [`from_slice`][from_slice] for parsing from a byte slice &[u8] and +//! [`from_slice`][from_slice] for parsing from a byte slice `&[u8]` and //! [`from_reader`][from_reader] for parsing from any `io::Read` like a File or //! a TCP stream. //! @@ -119,6 +119,9 @@ pub use map::Map; pub use number::Number; +#[cfg(feature = "raw_value")] +pub use raw::RawValue; + pub use self::index::Index; use self::ser::Serializer; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/src/value/ser.rs rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/src/value/ser.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/serde_json/src/value/ser.rs 2018-10-24 21:38:28.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/serde_json/src/value/ser.rs 2018-12-05 01:24:40.000000000 +0000 @@ -14,12 +14,6 @@ use number::Number; use value::{to_value, Value}; -#[cfg(feature = "arbitrary_precision")] -use serde::ser; - -#[cfg(feature = "arbitrary_precision")] -use number::{SERDE_STRUCT_FIELD_NAME, SERDE_STRUCT_NAME}; - impl Serialize for Value { #[inline] fn serialize(&self, serializer: S) -> Result @@ -228,25 +222,17 @@ }) } - #[cfg(not(feature = "arbitrary_precision"))] - fn serialize_struct( - self, - _name: &'static str, - len: usize, - ) -> Result { - self.serialize_map(Some(len)) - } - - #[cfg(feature = "arbitrary_precision")] fn serialize_struct( self, name: &'static str, len: usize, ) -> Result { - if name == SERDE_STRUCT_NAME { - Ok(SerializeMap::Number { out_value: None }) - } else { - self.serialize_map(Some(len)) + match name { + #[cfg(feature = "arbitrary_precision")] + ::number::TOKEN => Ok(SerializeMap::Number { out_value: None }), + #[cfg(feature = "raw_value")] + ::raw::TOKEN => Ok(SerializeMap::RawValue { out_value: None }), + _ => self.serialize_map(Some(len)), } } @@ -280,6 +266,8 @@ }, #[cfg(feature = "arbitrary_precision")] Number { out_value: Option }, + #[cfg(feature = "raw_value")] + RawValue { out_value: Option }, } pub struct SerializeStructVariant { @@ -374,6 +362,8 @@ } #[cfg(feature = "arbitrary_precision")] SerializeMap::Number { .. } => unreachable!(), + #[cfg(feature = "raw_value")] + SerializeMap::RawValue { .. } => unreachable!(), } } @@ -395,6 +385,8 @@ } #[cfg(feature = "arbitrary_precision")] SerializeMap::Number { .. } => unreachable!(), + #[cfg(feature = "raw_value")] + SerializeMap::RawValue { .. } => unreachable!(), } } @@ -403,6 +395,8 @@ SerializeMap::Map { map, .. } => Ok(Value::Object(map)), #[cfg(feature = "arbitrary_precision")] SerializeMap::Number { .. } => unreachable!(), + #[cfg(feature = "raw_value")] + SerializeMap::RawValue { .. } => unreachable!(), } } } @@ -605,13 +599,22 @@ } #[cfg(feature = "arbitrary_precision")] SerializeMap::Number { ref mut out_value } => { - if key == SERDE_STRUCT_FIELD_NAME { + if key == ::number::TOKEN { *out_value = Some(value.serialize(NumberValueEmitter)?); Ok(()) } else { Err(invalid_number()) } } + #[cfg(feature = "raw_value")] + SerializeMap::RawValue { ref mut out_value } => { + if key == ::raw::TOKEN { + *out_value = Some(value.serialize(RawValueEmitter)?); + Ok(()) + } else { + Err(invalid_raw_value()) + } + } } } @@ -622,6 +625,10 @@ SerializeMap::Number { out_value, .. } => { Ok(out_value.expect("number value was not emitted")) } + #[cfg(feature = "raw_value")] + SerializeMap::RawValue { out_value, .. } => { + Ok(out_value.expect("raw value was not emitted")) + } } } } @@ -656,7 +663,7 @@ } #[cfg(feature = "arbitrary_precision")] -impl ser::Serializer for NumberValueEmitter { +impl serde::ser::Serializer for NumberValueEmitter { type Ok = Value; type Error = Error; @@ -825,3 +832,181 @@ Err(invalid_number()) } } + +#[cfg(feature = "raw_value")] +struct RawValueEmitter; + +#[cfg(feature = "raw_value")] +fn invalid_raw_value() -> Error { + Error::syntax(ErrorCode::ExpectedSomeValue, 0, 0) +} + +#[cfg(feature = "raw_value")] +impl serde::ser::Serializer for RawValueEmitter { + type Ok = Value; + type Error = Error; + + type SerializeSeq = Impossible; + type SerializeTuple = Impossible; + type SerializeTupleStruct = Impossible; + type SerializeTupleVariant = Impossible; + type SerializeMap = Impossible; + type SerializeStruct = Impossible; + type SerializeStructVariant = Impossible; + + fn serialize_bool(self, _v: bool) -> Result { + Err(invalid_raw_value()) + } + + fn serialize_i8(self, _v: i8) -> Result { + Err(invalid_raw_value()) + } + + fn serialize_i16(self, _v: i16) -> Result { + Err(invalid_raw_value()) + } + + fn serialize_i32(self, _v: i32) -> Result { + Err(invalid_raw_value()) + } + + fn serialize_i64(self, _v: i64) -> Result { + Err(invalid_raw_value()) + } + + fn serialize_u8(self, _v: u8) -> Result { + Err(invalid_raw_value()) + } + + fn serialize_u16(self, _v: u16) -> Result { + Err(invalid_raw_value()) + } + + fn serialize_u32(self, _v: u32) -> Result { + Err(invalid_raw_value()) + } + + fn serialize_u64(self, _v: u64) -> Result { + Err(invalid_raw_value()) + } + + fn serialize_f32(self, _v: f32) -> Result { + Err(invalid_raw_value()) + } + + fn serialize_f64(self, _v: f64) -> Result { + Err(invalid_raw_value()) + } + + fn serialize_char(self, _v: char) -> Result { + Err(invalid_raw_value()) + } + + fn serialize_str(self, value: &str) -> Result { + ::from_str(value) + } + + fn serialize_bytes(self, _value: &[u8]) -> Result { + Err(invalid_raw_value()) + } + + fn serialize_none(self) -> Result { + Err(invalid_raw_value()) + } + + fn serialize_some(self, _value: &T) -> Result + where + T: Serialize, + { + Err(invalid_raw_value()) + } + + fn serialize_unit(self) -> Result { + Err(invalid_raw_value()) + } + + fn serialize_unit_struct(self, _name: &'static str) -> Result { + Err(invalid_raw_value()) + } + + fn serialize_unit_variant( + self, + _name: &'static str, + _variant_index: u32, + _variant: &'static str, + ) -> Result { + Err(invalid_raw_value()) + } + + fn serialize_newtype_struct( + self, + _name: &'static str, + _value: &T, + ) -> Result + where + T: Serialize, + { + Err(invalid_raw_value()) + } + + fn serialize_newtype_variant( + self, + _name: &'static str, + _variant_index: u32, + _variant: &'static str, + _value: &T, + ) -> Result + where + T: Serialize, + { + Err(invalid_raw_value()) + } + + fn serialize_seq(self, _len: Option) -> Result { + Err(invalid_raw_value()) + } + + fn serialize_tuple(self, _len: usize) -> Result { + Err(invalid_raw_value()) + } + + fn serialize_tuple_struct( + self, + _name: &'static str, + _len: usize, + ) -> Result { + Err(invalid_raw_value()) + } + + fn serialize_tuple_variant( + self, + _name: &'static str, + _variant_index: u32, + _variant: &'static str, + _len: usize, + ) -> Result { + Err(invalid_raw_value()) + } + + fn serialize_map(self, _len: Option) -> Result { + Err(invalid_raw_value()) + } + + fn serialize_struct( + self, + _name: &'static str, + _len: usize, + ) -> Result { + Err(invalid_raw_value()) + } + + fn serialize_struct_variant( + self, + _name: &'static str, + _variant_index: u32, + _variant: &'static str, + _len: usize, + ) -> Result { + Err(invalid_raw_value()) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/socket2/.cargo-checksum.json rustc-1.31.0+dfsg1+llvm/src/vendor/socket2/.cargo-checksum.json --- rustc-1.30.0+dfsg1+llvm/src/vendor/socket2/.cargo-checksum.json 2018-10-24 21:38:27.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/socket2/.cargo-checksum.json 2018-12-05 01:24:24.000000000 +0000 @@ -1 +1 @@ -{"files":{".appveyor.yml":"94e14e041baff03946ec46b123ec667b65ef132e9101195753b425d320a6f0bf",".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"cfdbabbd904ea8347cf7ad1387baacb90b579c33a058c7cf48dbae8d98910902",".travis.yml":"a140fd1361f61d4050f3de1fee08420490d2953771170903a2ecbcb2bacf6dfc","Cargo.toml":"695730e51215a84179f95633bb024615f01213423d292f1ee8e78c15ebc5151c","Cargo.toml.orig":"86368489f6512b8c6d89d7d66b23e35ea122286770b04ef4ba3b96e2515f5656","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"c89dbaf3e81e1ee478e7fdd8cb24c7a6dc6d849eed08de0423ea37e334e7e882","src/lib.rs":"1dd607cde24f8afe21076fa76ffc557690ce751842715a14f1f8578b88a66355","src/sockaddr.rs":"71613f3ef962bf2581f59c0f90d6c46d46e651f49f6aeddce86fb736eb330f01","src/socket.rs":"c90b544c5dcc06e50fbb5e311fd47fffe03c6a8351cc0a7d295d48baf541b57c","src/sys/redox/mod.rs":"d462cb1580a775a45d8864a4c819d868e556f98221eceef566fe58af6faa3b64","src/sys/unix/mod.rs":"2d07562d715cc7e6292c25bd012a004bf3379ecdb8fba6217003c0e8130b4aa2","src/sys/unix/weak.rs":"9b1345ce62188e22d1ec631f4569bb180f6d70ed029d4d3e07062394a5a599ff","src/sys/windows.rs":"370a1ed6e7cbb014b028557e83622a1928ca88f0a2f425549e27ca320c94a968","src/utils.rs":"53968de8c8e078a650fa316438622be9bb78bca95ed07c4f8da2c940ae27e0ae"},"package":"962a516af4d3a7c272cb3a1d50a8cc4e5b41802e4ad54cfb7bee8ba61d37d703"} \ No newline at end of file +{"files":{".appveyor.yml":"94e14e041baff03946ec46b123ec667b65ef132e9101195753b425d320a6f0bf",".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"cfdbabbd904ea8347cf7ad1387baacb90b579c33a058c7cf48dbae8d98910902",".travis.yml":"a140fd1361f61d4050f3de1fee08420490d2953771170903a2ecbcb2bacf6dfc","Cargo.toml":"aded0f06bff3818817cebd94db03cdc5a075cf4cd2e2fae3d0d37b8ab12c7f1f","Cargo.toml.orig":"7f10becd6f553ba80e52c2487e361183f36273f112facb07d76f00586eb5f50b","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"c89dbaf3e81e1ee478e7fdd8cb24c7a6dc6d849eed08de0423ea37e334e7e882","src/lib.rs":"1dd607cde24f8afe21076fa76ffc557690ce751842715a14f1f8578b88a66355","src/sockaddr.rs":"71613f3ef962bf2581f59c0f90d6c46d46e651f49f6aeddce86fb736eb330f01","src/socket.rs":"c90b544c5dcc06e50fbb5e311fd47fffe03c6a8351cc0a7d295d48baf541b57c","src/sys/redox/mod.rs":"d462cb1580a775a45d8864a4c819d868e556f98221eceef566fe58af6faa3b64","src/sys/unix/mod.rs":"2d07562d715cc7e6292c25bd012a004bf3379ecdb8fba6217003c0e8130b4aa2","src/sys/unix/weak.rs":"bdfb4f0e355d84585a782b6058ba60cd828d7fb2027cd0bb0bfc68b9c881f04a","src/sys/windows.rs":"370a1ed6e7cbb014b028557e83622a1928ca88f0a2f425549e27ca320c94a968","src/utils.rs":"53968de8c8e078a650fa316438622be9bb78bca95ed07c4f8da2c940ae27e0ae"},"package":"c4d11a52082057d87cb5caa31ad812f4504b97ab44732cd8359df2e9ff9f48e7"} \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/socket2/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/vendor/socket2/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/vendor/socket2/Cargo.toml 2018-10-24 21:38:27.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/socket2/Cargo.toml 2018-12-05 01:24:24.000000000 +0000 @@ -12,7 +12,7 @@ [package] name = "socket2" -version = "0.3.7" +version = "0.3.8" authors = ["Alex Crichton "] description = "Utilities for handling networking sockets with a maximal amount of configuration\npossible intended.\n" homepage = "https://github.com/alexcrichton/socket2-rs" diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/socket2/Cargo.toml.orig rustc-1.31.0+dfsg1+llvm/src/vendor/socket2/Cargo.toml.orig --- rustc-1.30.0+dfsg1+llvm/src/vendor/socket2/Cargo.toml.orig 2018-10-24 21:38:27.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/socket2/Cargo.toml.orig 2018-12-05 01:24:24.000000000 +0000 @@ -1,6 +1,6 @@ [package] name = "socket2" -version = "0.3.7" +version = "0.3.8" authors = ["Alex Crichton "] license = "MIT/Apache-2.0" readme = "README.md" diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/socket2/src/sys/unix/weak.rs rustc-1.31.0+dfsg1+llvm/src/vendor/socket2/src/sys/unix/weak.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/socket2/src/sys/unix/weak.rs 2018-10-24 21:38:27.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/socket2/src/sys/unix/weak.rs 2018-12-05 01:24:24.000000000 +0000 @@ -43,7 +43,7 @@ }; self.addr.store(ptr, Ordering::SeqCst); } - if self.addr.load(Ordering::SeqCst) == 1 { + if self.addr.load(Ordering::SeqCst) == 0 { None } else { mem::transmute::<&AtomicUsize, Option<&F>>(&self.addr) diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/.cargo-checksum.json rustc-1.31.0+dfsg1+llvm/src/vendor/syn/.cargo-checksum.json --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/.cargo-checksum.json 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/.cargo-checksum.json 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Cargo.toml":"dbbc708f123c27e504bb4d7a2511cc46f8c7d64ffab74eae60acdc13f728c979","Cargo.toml.orig":"5c3d8fe0b7e77041933882d2bace4b849291cbaae642c5426b048eb362f587b4","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"f033c371492a4769d377a8bf1a139adc7bf94ea00595b867a3e234eeab994c8c","README.md":"43062927a3e318771d5c2218e5066147b10cdd51cdeb240b06352506cfb7a72c","src/attr.rs":"4796108202ed2c89a2144039a145f20037465dd3cb9a8f8c712709082b889a5a","src/buffer.rs":"f600f012eaa26d412a3389032e2a78d319f7f1bbfe33ebf2b9d762274aad796b","src/data.rs":"5fbed19b7984502c9451cf446fd86b6489b9f6c52015421bb78c07e4ba294f03","src/derive.rs":"42a52cd1dea50473f3160c6515139bcaaf57c99962517eb2ac57abb04cd03688","src/error.rs":"aa215e0a8a98d85b970a9003565746be9fcdeb24a594b322e591d0ce74ed310b","src/expr.rs":"d0be324be2e4a4ba0e44173c8c4e0188c9ffff474f8cea5fab76e957e4b1e6cf","src/file.rs":"b1ae5b48a1937c475d57de8630d0a99326021e22b107a428342cf8b824330fbc","src/gen/fold.rs":"18795bc0a9a766dd16e78b725bc48c6cef901d12dc3452a8fde0d4f89ce227a3","src/gen/visit.rs":"eb9ff30320305576d0dd9a29c917f8d80e498e9da5f0f6b9f9067c3d0940752f","src/gen/visit_mut.rs":"e9d5ccebfd8eb9f29df68fec8beb694435a91106e48e0256c44a09787b58377d","src/gen_helper.rs":"d128fbd24fadfc5634976bdb9188c649f9905718c9c987a2839c3e6134b155a2","src/generics.rs":"0daf222a841f1965a25703855bbe17401b3edb0eb512ee96840f32940801551b","src/item.rs":"25e471c7c95ae6f6671f0a3413b526906e61fb8d345c7b2413b4edb0528fea24","src/lib.rs":"c733f5ea29df3abaeffc6762650feaaa9fc7060ab01277cb9f226d0970e1407d","src/lifetime.rs":"383cd564a452540f043858c636f19ed5b316a8c2752d83e53aacb5730307a754","src/lit.rs":"7ccdd679878c324ad47b0c29e76eb8d9e5d9b00e53cd3767060563bf7048eee9","src/mac.rs":"07c5aab9af440087315d58edeea733dda80bef0240463bf4d324c1ba1e2a272c","src/macros.rs":"c0bb8312f7ec422cb2c86ad2c20a609eb150fdcc38c74712e68214a4d6161994","src/op.rs":"7f20c79ac0ccc8cb129b550a305d8c57e58fdc2dd241f5fc1d1634450c26c32b","src/parse_quote.rs":"a3fbe5ad2cbeb967fbb8677f925431baa5303445a128c5284254b453284f21ab","src/parsers.rs":"ce324ac0882771b7ba24b110e55fbc2874be19cb7eb93fef7abcfb848d9c3a74","src/path.rs":"102ca22184ecfbfb21f9d82b49d0bc2d0d06fb792895a025dee1a435f9efee6e","src/punctuated.rs":"047cd8095cce72ed0ddae097a556c567ed0ca3294b5eac29a661669fd32a6748","src/spanned.rs":"70e8c7d953e76b1ce5330c73d7c0103c02a9b56e8dd8299c621fe0c91c615e23","src/synom.rs":"98b7fc3899099c5a0a6e659090c56a278237f9471f69f746404474eb5222e41a","src/token.rs":"20b25a6d572225f7e718a13b6e753b138ab9b8d840d31b6bfce5ed764eaaff8c","src/tt.rs":"e0541709fc8038a58156ef590f4449969a752aa96d7722beb41c097a83db5d21","src/ty.rs":"6888b6001c6f5908571684e90c73f43302d9e3a4186971caa8bbd72220d6c611","src/verbatim.rs":"40476ed104ae4cd16517c220becfc008b8ff0a0727d3be6001374d993b3f4b25"},"package":"261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741"} \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/vendor/syn/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/Cargo.toml 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/Cargo.toml 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g. crates.io) dependencies -# -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) - -[package] -name = "syn" -version = "0.14.9" -authors = ["David Tolnay "] -include = ["/Cargo.toml", "/src/**/*.rs", "/README.md", "/LICENSE-APACHE", "/LICENSE-MIT"] -description = "Nom parser for Rust source code" -documentation = "https://docs.rs/syn" -readme = "README.md" -categories = ["development-tools::procedural-macro-helpers"] -license = "MIT/Apache-2.0" -repository = "https://github.com/dtolnay/syn" -[package.metadata.docs.rs] -all-features = true - -[package.metadata.playground] -all-features = true - -[[example]] -name = "dump-syntax" -path = "examples/dump-syntax/main.rs" -required-features = ["full", "parsing", "extra-traits"] -[dependencies.proc-macro2] -version = "0.4.4" -default-features = false - -[dependencies.quote] -version = "0.6" -optional = true -default-features = false - -[dependencies.unicode-xid] -version = "0.1" -[dev-dependencies.rayon] -version = "1.0" - -[dev-dependencies.walkdir] -version = "2.1" - -[features] -clone-impls = [] -default = ["derive", "parsing", "printing", "clone-impls", "proc-macro"] -derive = [] -extra-traits = [] -fold = [] -full = [] -parsing = [] -printing = ["quote"] -proc-macro = ["proc-macro2/proc-macro", "quote/proc-macro"] -visit = [] -visit-mut = [] -[badges.travis-ci] -repository = "dtolnay/syn" diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/Cargo.toml.orig rustc-1.31.0+dfsg1+llvm/src/vendor/syn/Cargo.toml.orig --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/Cargo.toml.orig 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/Cargo.toml.orig 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -[package] -name = "syn" -version = "0.14.9" # don't forget to update html_root_url -authors = ["David Tolnay "] -license = "MIT/Apache-2.0" -description = "Nom parser for Rust source code" -repository = "https://github.com/dtolnay/syn" -documentation = "https://docs.rs/syn" -categories = ["development-tools::procedural-macro-helpers"] -readme = "README.md" -include = ["/Cargo.toml", "/src/**/*.rs", "/README.md", "/LICENSE-APACHE", "/LICENSE-MIT"] - -[[example]] -name = "dump-syntax" -path = "examples/dump-syntax/main.rs" -required-features = ["full", "parsing", "extra-traits"] - -[features] -default = ["derive", "parsing", "printing", "clone-impls", "proc-macro"] -derive = [] -full = [] -parsing = [] -printing = ["quote"] -visit = [] -visit-mut = [] -fold = [] -clone-impls = [] -extra-traits = [] -proc-macro = ["proc-macro2/proc-macro", "quote/proc-macro"] - -[dependencies] -proc-macro2 = { version = "0.4.4", default-features = false } -quote = { version = "0.6", optional = true, default-features = false } -unicode-xid = "0.1" - -[dev-dependencies] -rayon = "1.0" -walkdir = "2.1" - -[package.metadata.docs.rs] -all-features = true - -[package.metadata.playground] -all-features = true - -[badges] -travis-ci = { repository = "dtolnay/syn" } diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/LICENSE-APACHE rustc-1.31.0+dfsg1+llvm/src/vendor/syn/LICENSE-APACHE --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/LICENSE-APACHE 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/LICENSE-APACHE 1970-01-01 00:00:00.000000000 +0000 @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/LICENSE-MIT rustc-1.31.0+dfsg1+llvm/src/vendor/syn/LICENSE-MIT --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/LICENSE-MIT 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/LICENSE-MIT 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -Copyright (c) 2018 Syn Developers - -Permission is hereby granted, free of charge, to any -person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the -Software without restriction, including without -limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice -shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF -ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/README.md rustc-1.31.0+dfsg1+llvm/src/vendor/syn/README.md --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/README.md 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/README.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,282 +0,0 @@ -Nom parser for Rust source code -=============================== - -[![Build Status](https://api.travis-ci.org/dtolnay/syn.svg?branch=master)](https://travis-ci.org/dtolnay/syn) -[![Latest Version](https://img.shields.io/crates/v/syn.svg)](https://crates.io/crates/syn) -[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/syn/0.14/syn/) -[![Rustc Version 1.15+](https://img.shields.io/badge/rustc-1.15+-lightgray.svg)](https://blog.rust-lang.org/2017/02/02/Rust-1.15.html) - -Syn is a parsing library for parsing a stream of Rust tokens into a syntax tree -of Rust source code. - -Currently this library is geared toward the [custom derive] use case but -contains some APIs that may be useful for Rust procedural macros more generally. - -[custom derive]: https://github.com/rust-lang/rfcs/blob/master/text/1681-macros-1.1.md - -- **Data structures** — Syn provides a complete syntax tree that can represent - any valid Rust source code. The syntax tree is rooted at [`syn::File`] which - represents a full source file, but there are other entry points that may be - useful to procedural macros including [`syn::Item`], [`syn::Expr`] and - [`syn::Type`]. - -- **Custom derives** — Of particular interest to custom derives is - [`syn::DeriveInput`] which is any of the three legal input items to a derive - macro. An example below shows using this type in a library that can derive - implementations of a trait of your own. - -- **Parser combinators** — Parsing in Syn is built on a suite of public parser - combinator macros that you can use for parsing any token-based syntax you - dream up within a `functionlike!(...)` procedural macro. Every syntax tree - node defined by Syn is individually parsable and may be used as a building - block for custom syntaxes, or you may do it all yourself working from the most - primitive tokens. - -- **Location information** — Every token parsed by Syn is associated with a - `Span` that tracks line and column information back to the source of that - token. These spans allow a procedural macro to display detailed error messages - pointing to all the right places in the user's code. There is an example of - this below. - -- **Feature flags** — Functionality is aggressively feature gated so your - procedural macros enable only what they need, and do not pay in compile time - for all the rest. - -[`syn::File`]: https://docs.rs/syn/0.14/syn/struct.File.html -[`syn::Item`]: https://docs.rs/syn/0.14/syn/enum.Item.html -[`syn::Expr`]: https://docs.rs/syn/0.14/syn/enum.Expr.html -[`syn::Type`]: https://docs.rs/syn/0.14/syn/enum.Type.html -[`syn::DeriveInput`]: https://docs.rs/syn/0.14/syn/struct.DeriveInput.html - -If you get stuck with anything involving procedural macros in Rust I am happy to -provide help even if the issue is not related to Syn. Please file a ticket in -this repo. - -*Version requirement: Syn supports any compiler version back to Rust's very -first support for procedural macros in Rust 1.15.0. Some features especially -around error reporting are only available in newer compilers or on the nightly -channel.* - -[*Release notes*](https://github.com/dtolnay/syn/releases) - -## Example of a custom derive - -The canonical custom derive using Syn looks like this. We write an ordinary Rust -function tagged with a `proc_macro_derive` attribute and the name of the trait -we are deriving. Any time that derive appears in the user's code, the Rust -compiler passes their data structure as tokens into our macro. We get to execute -arbitrary Rust code to figure out what to do with those tokens, then hand some -tokens back to the compiler to compile into the user's crate. - -[`TokenStream`]: https://doc.rust-lang.org/proc_macro/struct.TokenStream.html - -```toml -[dependencies] -syn = "0.14" -quote = "0.6" - -[lib] -proc-macro = true -``` - -```rust -extern crate proc_macro; -extern crate syn; - -#[macro_use] -extern crate quote; - -use proc_macro::TokenStream; -use syn::DeriveInput; - -#[proc_macro_derive(MyMacro)] -pub fn my_macro(input: TokenStream) -> TokenStream { - // Parse the input tokens into a syntax tree - let input: DeriveInput = syn::parse(input).unwrap(); - - // Build the output, possibly using quasi-quotation - let expanded = quote! { - // ... - }; - - // Hand the output tokens back to the compiler - expanded.into() -} -``` - -The [`heapsize`] example directory shows a complete working Macros 1.1 -implementation of a custom derive. It works on any Rust compiler \>=1.15.0. The -example derives a `HeapSize` trait which computes an estimate of the amount of -heap memory owned by a value. - -[`heapsize`]: examples/heapsize - -```rust -pub trait HeapSize { - /// Total number of bytes of heap memory owned by `self`. - fn heap_size_of_children(&self) -> usize; -} -``` - -The custom derive allows users to write `#[derive(HeapSize)]` on data structures -in their program. - -```rust -#[derive(HeapSize)] -struct Demo<'a, T: ?Sized> { - a: Box, - b: u8, - c: &'a str, - d: String, -} -``` - -## Spans and error reporting - -The [`heapsize2`] example directory is an extension of the `heapsize` example -that demonstrates some of the hygiene and error reporting properties of Macros -2.0. This example currently requires a nightly Rust compiler \>=1.24.0-nightly -but we are working to stabilize all of the APIs involved. - -[`heapsize2`]: examples/heapsize2 - -The token-based procedural macro API provides great control over where the -compiler's error messages are displayed in user code. Consider the error the -user sees if one of their field types does not implement `HeapSize`. - -```rust -#[derive(HeapSize)] -struct Broken { - ok: String, - bad: std::thread::Thread, -} -``` - -In the Macros 1.1 string-based procedural macro world, the resulting error would -point unhelpfully to the invocation of the derive macro and not to the actual -problematic field. - -``` -error[E0599]: no method named `heap_size_of_children` found for type `std::thread::Thread` in the current scope - --> src/main.rs:4:10 - | -4 | #[derive(HeapSize)] - | ^^^^^^^^ -``` - -By tracking span information all the way through the expansion of a procedural -macro as shown in the `heapsize2` example, token-based macros in Syn are able to -trigger errors that directly pinpoint the source of the problem. - -``` -error[E0277]: the trait bound `std::thread::Thread: HeapSize` is not satisfied - --> src/main.rs:7:5 - | -7 | bad: std::thread::Thread, - | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HeapSize` is not implemented for `std::thread::Thread` -``` - -## Parsing a custom syntax using combinators - -The [`lazy-static`] example directory shows the implementation of a -`functionlike!(...)` procedural macro in which the input tokens are parsed using -[`nom`]-style parser combinators. - -[`lazy-static`]: examples/lazy-static -[`nom`]: https://github.com/Geal/nom - -The example reimplements the popular `lazy_static` crate from crates.io as a -procedural macro. - -``` -lazy_static! { - static ref USERNAME: Regex = Regex::new("^[a-z0-9_-]{3,16}$").unwrap(); -} -``` - -The implementation shows how to trigger custom warnings and error messages on -the macro input. - -``` -warning: come on, pick a more creative name - --> src/main.rs:10:16 - | -10 | static ref FOO: String = "lazy_static".to_owned(); - | ^^^ -``` - -## Debugging - -When developing a procedural macro it can be helpful to look at what the -generated code looks like. Use `cargo rustc -- -Zunstable-options ---pretty=expanded` or the [`cargo expand`] subcommand. - -[`cargo expand`]: https://github.com/dtolnay/cargo-expand - -To show the expanded code for some crate that uses your procedural macro, run -`cargo expand` from that crate. To show the expanded code for one of your own -test cases, run `cargo expand --test the_test_case` where the last argument is -the name of the test file without the `.rs` extension. - -This write-up by Brandon W Maister discusses debugging in more detail: -[Debugging Rust's new Custom Derive system][debugging]. - -[debugging]: https://quodlibetor.github.io/posts/debugging-rusts-new-custom-derive-system/ - -## Optional features - -Syn puts a lot of functionality behind optional features in order to optimize -compile time for the most common use cases. The following features are -available. - -- **`derive`** *(enabled by default)* — Data structures for representing the - possible input to a custom derive, including structs and enums and types. -- **`full`** — Data structures for representing the syntax tree of all valid - Rust source code, including items and expressions. -- **`parsing`** *(enabled by default)* — Ability to parse input tokens into a - syntax tree node of a chosen type. -- **`printing`** *(enabled by default)* — Ability to print a syntax tree node as - tokens of Rust source code. -- **`visit`** — Trait for traversing a syntax tree. -- **`visit-mut`** — Trait for traversing and mutating in place a syntax tree. -- **`fold`** — Trait for transforming an owned syntax tree. -- **`clone-impls`** *(enabled by default)* — Clone impls for all syntax tree - types. -- **`extra-traits`** — Debug, Eq, PartialEq, Hash impls for all syntax tree - types. -- **`proc-macro`** *(enabled by default)* — Runtime dependency on the dynamic - library libproc_macro from rustc toolchain. - -## Nightly features - -By default Syn uses the [`proc-macro2`] crate to emulate the nightly compiler's -procedural macro API in a stable way that works all the way back to Rust 1.15.0. -This shim makes it possible to write code without regard for whether the current -compiler version supports the features we use. - -[`proc-macro2`]: https://github.com/alexcrichton/proc-macro2 - -On a nightly compiler, to eliminate the stable shim and use the compiler's -`proc-macro` directly, add `proc-macro2` to your Cargo.toml and set its -`"nightly"` feature which bypasses the stable shim. - -```toml -[dependencies] -syn = "0.14" -proc-macro2 = { version = "0.4", features = ["nightly"] } -``` - -## License - -Licensed under either of - - * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) - * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) - -at your option. - -### Contribution - -Unless you explicitly state otherwise, any contribution intentionally submitted -for inclusion in this crate by you, as defined in the Apache-2.0 license, shall -be dual licensed as above, without any additional terms or conditions. diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/attr.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/attr.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/attr.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/attr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,554 +0,0 @@ -// Copyright 2018 Syn Developers -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use super::*; -use punctuated::Punctuated; - -use std::iter; - -use proc_macro2::{Delimiter, Spacing, TokenStream, TokenTree}; - -#[cfg(feature = "extra-traits")] -use std::hash::{Hash, Hasher}; -#[cfg(feature = "extra-traits")] -use tt::TokenStreamHelper; - -ast_struct! { - /// An attribute like `#[repr(transparent)]`. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - /// - /// # Syntax - /// - /// Rust has six types of attributes. - /// - /// - Outer attributes like `#[repr(transparent)]`. These appear outside or - /// in front of the item they describe. - /// - Inner attributes like `#![feature(proc_macro)]`. These appear inside - /// of the item they describe, usually a module. - /// - Outer doc comments like `/// # Example`. - /// - Inner doc comments like `//! Please file an issue`. - /// - Outer block comments `/** # Example */`. - /// - Inner block comments `/*! Please file an issue */`. - /// - /// The `style` field of type `AttrStyle` distinguishes whether an attribute - /// is outer or inner. Doc comments and block comments are promoted to - /// attributes that have `is_sugared_doc` set to true, as this is how they - /// are processed by the compiler and by `macro_rules!` macros. - /// - /// The `path` field gives the possibly colon-delimited path against which - /// the attribute is resolved. It is equal to `"doc"` for desugared doc - /// comments. The `tts` field contains the rest of the attribute body as - /// tokens. - /// - /// ```text - /// #[derive(Copy)] #[crate::precondition x < 5] - /// ^^^^^^~~~~~~ ^^^^^^^^^^^^^^^^^^^ ~~~~~ - /// path tts path tts - /// ``` - /// - /// Use the [`interpret_meta`] method to try parsing the tokens of an - /// attribute into the structured representation that is used by convention - /// across most Rust libraries. - /// - /// [`interpret_meta`]: #method.interpret_meta - pub struct Attribute #manual_extra_traits { - pub pound_token: Token![#], - pub style: AttrStyle, - pub bracket_token: token::Bracket, - pub path: Path, - pub tts: TokenStream, - pub is_sugared_doc: bool, - } -} - -#[cfg(feature = "extra-traits")] -impl Eq for Attribute {} - -#[cfg(feature = "extra-traits")] -impl PartialEq for Attribute { - fn eq(&self, other: &Self) -> bool { - self.style == other.style - && self.pound_token == other.pound_token - && self.bracket_token == other.bracket_token - && self.path == other.path - && TokenStreamHelper(&self.tts) == TokenStreamHelper(&other.tts) - && self.is_sugared_doc == other.is_sugared_doc - } -} - -#[cfg(feature = "extra-traits")] -impl Hash for Attribute { - fn hash(&self, state: &mut H) - where - H: Hasher, - { - self.style.hash(state); - self.pound_token.hash(state); - self.bracket_token.hash(state); - self.path.hash(state); - TokenStreamHelper(&self.tts).hash(state); - self.is_sugared_doc.hash(state); - } -} - -impl Attribute { - /// Parses the tokens after the path as a [`Meta`](enum.Meta.html) if - /// possible. - pub fn interpret_meta(&self) -> Option { - let name = if self.path.segments.len() == 1 { - &self.path.segments.first().unwrap().value().ident - } else { - return None; - }; - - if self.tts.is_empty() { - return Some(Meta::Word(name.clone())); - } - - let tts = self.tts.clone().into_iter().collect::>(); - - if tts.len() == 1 { - if let Some(meta) = Attribute::extract_meta_list(name.clone(), &tts[0]) { - return Some(meta); - } - } - - if tts.len() == 2 { - if let Some(meta) = Attribute::extract_name_value(name.clone(), &tts[0], &tts[1]) { - return Some(meta); - } - } - - None - } - - fn extract_meta_list(ident: Ident, tt: &TokenTree) -> Option { - let g = match *tt { - TokenTree::Group(ref g) => g, - _ => return None, - }; - if g.delimiter() != Delimiter::Parenthesis { - return None; - } - let tokens = g.stream().clone().into_iter().collect::>(); - let nested = match list_of_nested_meta_items_from_tokens(&tokens) { - Some(n) => n, - None => return None, - }; - Some(Meta::List(MetaList { - paren_token: token::Paren(g.span()), - ident: ident, - nested: nested, - })) - } - - fn extract_name_value(ident: Ident, a: &TokenTree, b: &TokenTree) -> Option { - let a = match *a { - TokenTree::Punct(ref o) => o, - _ => return None, - }; - if a.spacing() != Spacing::Alone { - return None; - } - if a.as_char() != '=' { - return None; - } - - match *b { - TokenTree::Literal(ref l) if !l.to_string().starts_with('/') => { - Some(Meta::NameValue(MetaNameValue { - ident: ident, - eq_token: Token![=]([a.span()]), - lit: Lit::new(l.clone()), - })) - } - TokenTree::Ident(ref v) => match &v.to_string()[..] { - v @ "true" | v @ "false" => Some(Meta::NameValue(MetaNameValue { - ident: ident, - eq_token: Token![=]([a.span()]), - lit: Lit::Bool(LitBool { - value: v == "true", - span: b.span(), - }), - })), - _ => None, - }, - _ => None, - } - } -} - -fn nested_meta_item_from_tokens(tts: &[TokenTree]) -> Option<(NestedMeta, &[TokenTree])> { - assert!(!tts.is_empty()); - - match tts[0] { - TokenTree::Literal(ref lit) => { - if lit.to_string().starts_with('/') { - None - } else { - let lit = Lit::new(lit.clone()); - Some((NestedMeta::Literal(lit), &tts[1..])) - } - } - - TokenTree::Ident(ref ident) => { - if tts.len() >= 3 { - if let Some(meta) = Attribute::extract_name_value(ident.clone(), &tts[1], &tts[2]) { - return Some((NestedMeta::Meta(meta), &tts[3..])); - } - } - - if tts.len() >= 2 { - if let Some(meta) = Attribute::extract_meta_list(ident.clone(), &tts[1]) { - return Some((NestedMeta::Meta(meta), &tts[2..])); - } - } - - Some((Meta::Word(ident.clone()).into(), &tts[1..])) - } - - _ => None, - } -} - -fn list_of_nested_meta_items_from_tokens( - mut tts: &[TokenTree], -) -> Option> { - let mut nested_meta_items = Punctuated::new(); - let mut first = true; - - while !tts.is_empty() { - let prev_comma = if first { - first = false; - None - } else if let TokenTree::Punct(ref op) = tts[0] { - if op.spacing() != Spacing::Alone { - return None; - } - if op.as_char() != ',' { - return None; - } - let tok = Token![,]([op.span()]); - tts = &tts[1..]; - if tts.is_empty() { - break; - } - Some(tok) - } else { - return None; - }; - let (nested, rest) = match nested_meta_item_from_tokens(tts) { - Some(pair) => pair, - None => return None, - }; - if let Some(comma) = prev_comma { - nested_meta_items.push_punct(comma); - } - nested_meta_items.push_value(nested); - tts = rest; - } - - Some(nested_meta_items) -} - -ast_enum! { - /// Distinguishes between attributes that decorate an item and attributes - /// that are contained within an item. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - /// - /// # Outer attributes - /// - /// - `#[repr(transparent)]` - /// - `/// # Example` - /// - `/** Please file an issue */` - /// - /// # Inner attributes - /// - /// - `#![feature(proc_macro)]` - /// - `//! # Example` - /// - `/*! Please file an issue */` - #[cfg_attr(feature = "clone-impls", derive(Copy))] - pub enum AttrStyle { - Outer, - Inner(Token![!]), - } -} - -ast_enum_of_structs! { - /// Content of a compile-time structured attribute. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - /// - /// ## Word - /// - /// A meta word is like the `test` in `#[test]`. - /// - /// ## List - /// - /// A meta list is like the `derive(Copy)` in `#[derive(Copy)]`. - /// - /// ## NameValue - /// - /// A name-value meta is like the `path = "..."` in `#[path = - /// "sys/windows.rs"]`. - /// - /// # Syntax tree enum - /// - /// This type is a [syntax tree enum]. - /// - /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums - pub enum Meta { - pub Word(Ident), - /// A structured list within an attribute, like `derive(Copy, Clone)`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub List(MetaList { - pub ident: Ident, - pub paren_token: token::Paren, - pub nested: Punctuated, - }), - /// A name-value pair within an attribute, like `feature = "nightly"`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub NameValue(MetaNameValue { - pub ident: Ident, - pub eq_token: Token![=], - pub lit: Lit, - }), - } -} - -impl Meta { - /// Returns the identifier that begins this structured meta item. - /// - /// For example this would return the `test` in `#[test]`, the `derive` in - /// `#[derive(Copy)]`, and the `path` in `#[path = "sys/windows.rs"]`. - pub fn name(&self) -> Ident { - match *self { - Meta::Word(ref meta) => meta.clone(), - Meta::List(ref meta) => meta.ident.clone(), - Meta::NameValue(ref meta) => meta.ident.clone(), - } - } -} - -ast_enum_of_structs! { - /// Element of a compile-time attribute list. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - pub enum NestedMeta { - /// A structured meta item, like the `Copy` in `#[derive(Copy)]` which - /// would be a nested `Meta::Word`. - pub Meta(Meta), - - /// A Rust literal, like the `"new_name"` in `#[rename("new_name")]`. - pub Literal(Lit), - } -} - -pub trait FilterAttrs<'a> { - type Ret: Iterator; - - fn outer(self) -> Self::Ret; - fn inner(self) -> Self::Ret; -} - -impl<'a, T> FilterAttrs<'a> for T -where - T: IntoIterator, -{ - type Ret = iter::Filter bool>; - - fn outer(self) -> Self::Ret { - fn is_outer(attr: &&Attribute) -> bool { - match attr.style { - AttrStyle::Outer => true, - _ => false, - } - } - self.into_iter().filter(is_outer) - } - - fn inner(self) -> Self::Ret { - fn is_inner(attr: &&Attribute) -> bool { - match attr.style { - AttrStyle::Inner(_) => true, - _ => false, - } - } - self.into_iter().filter(is_inner) - } -} - -#[cfg(feature = "parsing")] -pub mod parsing { - use super::*; - use buffer::Cursor; - use parse_error; - use proc_macro2::{Literal, Punct, Spacing, Span, TokenTree}; - use synom::PResult; - - fn eq(span: Span) -> TokenTree { - let mut op = Punct::new('=', Spacing::Alone); - op.set_span(span); - op.into() - } - - impl Attribute { - named!(pub parse_inner -> Self, alt!( - do_parse!( - pound: punct!(#) >> - bang: punct!(!) >> - path_and_tts: brackets!(tuple!( - call!(Path::parse_mod_style), - syn!(TokenStream), - )) >> - ({ - let (bracket, (path, tts)) = path_and_tts; - - Attribute { - style: AttrStyle::Inner(bang), - path: path, - tts: tts, - is_sugared_doc: false, - pound_token: pound, - bracket_token: bracket, - } - }) - ) - | - map!( - call!(lit_doc_comment, Comment::Inner), - |lit| { - let span = lit.span(); - Attribute { - style: AttrStyle::Inner(::new(span)), - path: Ident::new("doc", span).into(), - tts: vec![ - eq(span), - lit, - ].into_iter().collect(), - is_sugared_doc: true, - pound_token: ::new(span), - bracket_token: token::Bracket(span), - } - } - ) - )); - - named!(pub parse_outer -> Self, alt!( - do_parse!( - pound: punct!(#) >> - path_and_tts: brackets!(tuple!( - call!(Path::parse_mod_style), - syn!(TokenStream), - )) >> - ({ - let (bracket, (path, tts)) = path_and_tts; - - Attribute { - style: AttrStyle::Outer, - path: path, - tts: tts, - is_sugared_doc: false, - pound_token: pound, - bracket_token: bracket, - } - }) - ) - | - map!( - call!(lit_doc_comment, Comment::Outer), - |lit| { - let span = lit.span(); - Attribute { - style: AttrStyle::Outer, - path: Ident::new("doc", span).into(), - tts: vec![ - eq(span), - lit, - ].into_iter().collect(), - is_sugared_doc: true, - pound_token: ::new(span), - bracket_token: token::Bracket(span), - } - } - ) - )); - } - - enum Comment { - Inner, - Outer, - } - - fn lit_doc_comment(input: Cursor, style: Comment) -> PResult { - match input.literal() { - Some((lit, rest)) => { - let string = lit.to_string(); - let ok = match style { - Comment::Inner => string.starts_with("//!") || string.starts_with("/*!"), - Comment::Outer => string.starts_with("///") || string.starts_with("/**"), - }; - if ok { - let mut new = Literal::string(&string); - new.set_span(lit.span()); - Ok((new.into(), rest)) - } else { - parse_error() - } - } - _ => parse_error(), - } - } -} - -#[cfg(feature = "printing")] -mod printing { - use super::*; - use proc_macro2::TokenStream; - use quote::ToTokens; - - impl ToTokens for Attribute { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.pound_token.to_tokens(tokens); - if let AttrStyle::Inner(ref b) = self.style { - b.to_tokens(tokens); - } - self.bracket_token.surround(tokens, |tokens| { - self.path.to_tokens(tokens); - self.tts.to_tokens(tokens); - }); - } - } - - impl ToTokens for MetaList { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.ident.to_tokens(tokens); - self.paren_token.surround(tokens, |tokens| { - self.nested.to_tokens(tokens); - }) - } - } - - impl ToTokens for MetaNameValue { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.ident.to_tokens(tokens); - self.eq_token.to_tokens(tokens); - self.lit.to_tokens(tokens); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/buffer.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/buffer.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/buffer.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/buffer.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,469 +0,0 @@ -// Copyright 2018 Syn Developers -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! A stably addressed token buffer supporting efficient traversal based on a -//! cheaply copyable cursor. -//! -//! The [`Synom`] trait is implemented for syntax tree types that can be parsed -//! from one of these token cursors. -//! -//! [`Synom`]: ../synom/trait.Synom.html -//! -//! *This module is available if Syn is built with the `"parsing"` feature.* -//! -//! # Example -//! -//! This example shows a basic token parser for parsing a token stream without -//! using Syn's parser combinator macros. -//! -//! ``` -//! #![feature(proc_macro_diagnostic)] -//! -//! extern crate syn; -//! extern crate proc_macro; -//! -//! #[macro_use] -//! extern crate quote; -//! -//! use syn::{token, ExprTuple}; -//! use syn::buffer::{Cursor, TokenBuffer}; -//! use syn::spanned::Spanned; -//! use syn::synom::Synom; -//! use proc_macro::{Diagnostic, Span, TokenStream}; -//! -//! /// A basic token parser for parsing a token stream without using Syn's -//! /// parser combinator macros. -//! pub struct Parser<'a> { -//! cursor: Cursor<'a>, -//! } -//! -//! impl<'a> Parser<'a> { -//! pub fn new(cursor: Cursor<'a>) -> Self { -//! Parser { cursor } -//! } -//! -//! pub fn current_span(&self) -> Span { -//! self.cursor.span().unstable() -//! } -//! -//! pub fn parse(&mut self) -> Result { -//! let (val, rest) = T::parse(self.cursor) -//! .map_err(|e| match T::description() { -//! Some(desc) => { -//! self.current_span().error(format!("{}: expected {}", e, desc)) -//! } -//! None => { -//! self.current_span().error(e.to_string()) -//! } -//! })?; -//! -//! self.cursor = rest; -//! Ok(val) -//! } -//! -//! pub fn expect_eof(&mut self) -> Result<(), Diagnostic> { -//! if !self.cursor.eof() { -//! return Err(self.current_span().error("trailing characters; expected eof")); -//! } -//! -//! Ok(()) -//! } -//! } -//! -//! fn eval(input: TokenStream) -> Result { -//! let buffer = TokenBuffer::new(input); -//! let mut parser = Parser::new(buffer.begin()); -//! -//! // Parse some syntax tree types out of the input tokens. In this case we -//! // expect something like: -//! // -//! // (a, b, c) = (1, 2, 3) -//! let a = parser.parse::()?; -//! parser.parse::()?; -//! let b = parser.parse::()?; -//! parser.expect_eof()?; -//! -//! // Perform some validation and report errors. -//! let (a_len, b_len) = (a.elems.len(), b.elems.len()); -//! if a_len != b_len { -//! let diag = b.span().unstable() -//! .error(format!("expected {} element(s), got {}", a_len, b_len)) -//! .span_note(a.span().unstable(), "because of this"); -//! -//! return Err(diag); -//! } -//! -//! // Build the output tokens. -//! let out = quote! { -//! println!("All good! Received two tuples of size {}", #a_len); -//! }; -//! -//! Ok(out.into()) -//! } -//! # -//! # extern crate proc_macro2; -//! # -//! # // This method exists on proc_macro2::Span but is behind the "nightly" -//! # // feature. -//! # trait ToUnstableSpan { -//! # fn unstable(&self) -> Span; -//! # } -//! # -//! # impl ToUnstableSpan for proc_macro2::Span { -//! # fn unstable(&self) -> Span { -//! # unimplemented!() -//! # } -//! # } -//! # -//! # fn main() {} -//! ``` - -// This module is heavily commented as it contains the only unsafe code in Syn, -// and caution should be used when editing it. The public-facing interface is -// 100% safe but the implementation is fragile internally. - -#[cfg(all( - not(all(target_arch = "wasm32", target_os = "unknown")), - feature = "proc-macro" -))] -use proc_macro as pm; -use proc_macro2::{Delimiter, Ident, Literal, Span, TokenStream}; -use proc_macro2::{Group, Punct, TokenTree}; - -use std::marker::PhantomData; -use std::ptr; - -#[cfg(synom_verbose_trace)] -use std::fmt::{self, Debug}; - -/// Internal type which is used instead of `TokenTree` to represent a token tree -/// within a `TokenBuffer`. -enum Entry { - // Mimicking types from proc-macro. - Group(Span, Delimiter, TokenBuffer), - Ident(Ident), - Punct(Punct), - Literal(Literal), - // End entries contain a raw pointer to the entry from the containing - // token tree, or null if this is the outermost level. - End(*const Entry), -} - -/// A buffer that can be efficiently traversed multiple times, unlike -/// `TokenStream` which requires a deep copy in order to traverse more than -/// once. -/// -/// See the [module documentation] for an example of `TokenBuffer` in action. -/// -/// [module documentation]: index.html -/// -/// *This type is available if Syn is built with the `"parsing"` feature.* -pub struct TokenBuffer { - // NOTE: Do not derive clone on this - there are raw pointers inside which - // will be messed up. Moving the `TokenBuffer` itself is safe as the actual - // backing slices won't be moved. - data: Box<[Entry]>, -} - -impl TokenBuffer { - // NOTE: DO NOT MUTATE THE `Vec` RETURNED FROM THIS FUNCTION ONCE IT - // RETURNS, THE ADDRESS OF ITS BACKING MEMORY MUST REMAIN STABLE. - fn inner_new(stream: TokenStream, up: *const Entry) -> TokenBuffer { - // Build up the entries list, recording the locations of any Groups - // in the list to be processed later. - let mut entries = Vec::new(); - let mut seqs = Vec::new(); - for tt in stream { - match tt { - TokenTree::Ident(sym) => { - entries.push(Entry::Ident(sym)); - } - TokenTree::Punct(op) => { - entries.push(Entry::Punct(op)); - } - TokenTree::Literal(l) => { - entries.push(Entry::Literal(l)); - } - TokenTree::Group(g) => { - // Record the index of the interesting entry, and store an - // `End(null)` there temporarially. - seqs.push((entries.len(), g.span(), g.delimiter(), g.stream().clone())); - entries.push(Entry::End(ptr::null())); - } - } - } - // Add an `End` entry to the end with a reference to the enclosing token - // stream which was passed in. - entries.push(Entry::End(up)); - - // NOTE: This is done to ensure that we don't accidentally modify the - // length of the backing buffer. The backing buffer must remain at a - // constant address after this point, as we are going to store a raw - // pointer into it. - let mut entries = entries.into_boxed_slice(); - for (idx, span, delim, seq_stream) in seqs { - // We know that this index refers to one of the temporary - // `End(null)` entries, and we know that the last entry is - // `End(up)`, so the next index is also valid. - let seq_up = &entries[idx + 1] as *const Entry; - - // The end entry stored at the end of this Entry::Group should - // point to the Entry which follows the Group in the list. - let inner = Self::inner_new(seq_stream, seq_up); - entries[idx] = Entry::Group(span, delim, inner); - } - - TokenBuffer { data: entries } - } - - /// Creates a `TokenBuffer` containing all the tokens from the input - /// `TokenStream`. - /// - /// *This method is available if Syn is built with both the `"parsing"` and - /// `"proc-macro"` features.* - #[cfg(all( - not(all(target_arch = "wasm32", target_os = "unknown")), - feature = "proc-macro" - ))] - pub fn new(stream: pm::TokenStream) -> TokenBuffer { - Self::new2(stream.into()) - } - - /// Creates a `TokenBuffer` containing all the tokens from the input - /// `TokenStream`. - pub fn new2(stream: TokenStream) -> TokenBuffer { - Self::inner_new(stream, ptr::null()) - } - - /// Creates a cursor referencing the first token in the buffer and able to - /// traverse until the end of the buffer. - pub fn begin(&self) -> Cursor { - unsafe { Cursor::create(&self.data[0], &self.data[self.data.len() - 1]) } - } -} - -/// A cheaply copyable cursor into a `TokenBuffer`. -/// -/// This cursor holds a shared reference into the immutable data which is used -/// internally to represent a `TokenStream`, and can be efficiently manipulated -/// and copied around. -/// -/// An empty `Cursor` can be created directly, or one may create a `TokenBuffer` -/// object and get a cursor to its first token with `begin()`. -/// -/// Two cursors are equal if they have the same location in the same input -/// stream, and have the same scope. -/// -/// See the [module documentation] for an example of a `Cursor` in action. -/// -/// [module documentation]: index.html -/// -/// *This type is available if Syn is built with the `"parsing"` feature.* -#[derive(Copy, Clone, Eq, PartialEq)] -pub struct Cursor<'a> { - /// The current entry which the `Cursor` is pointing at. - ptr: *const Entry, - /// This is the only `Entry::End(..)` object which this cursor is allowed to - /// point at. All other `End` objects are skipped over in `Cursor::create`. - scope: *const Entry, - /// This uses the &'a reference which guarantees that these pointers are - /// still valid. - marker: PhantomData<&'a Entry>, -} - -impl<'a> Cursor<'a> { - /// Creates a cursor referencing a static empty TokenStream. - pub fn empty() -> Self { - // It's safe in this situation for us to put an `Entry` object in global - // storage, despite it not actually being safe to send across threads - // (`Ident` is a reference into a thread-local table). This is because - // this entry never includes a `Ident` object. - // - // This wrapper struct allows us to break the rules and put a `Sync` - // object in global storage. - struct UnsafeSyncEntry(Entry); - unsafe impl Sync for UnsafeSyncEntry {} - static EMPTY_ENTRY: UnsafeSyncEntry = UnsafeSyncEntry(Entry::End(0 as *const Entry)); - - Cursor { - ptr: &EMPTY_ENTRY.0, - scope: &EMPTY_ENTRY.0, - marker: PhantomData, - } - } - - /// This create method intelligently exits non-explicitly-entered - /// `None`-delimited scopes when the cursor reaches the end of them, - /// allowing for them to be treated transparently. - unsafe fn create(mut ptr: *const Entry, scope: *const Entry) -> Self { - // NOTE: If we're looking at a `End(..)`, we want to advance the cursor - // past it, unless `ptr == scope`, which means that we're at the edge of - // our cursor's scope. We should only have `ptr != scope` at the exit - // from None-delimited groups entered with `ignore_none`. - while let Entry::End(exit) = *ptr { - if ptr == scope { - break; - } - ptr = exit; - } - - Cursor { - ptr: ptr, - scope: scope, - marker: PhantomData, - } - } - - /// Get the current entry. - fn entry(self) -> &'a Entry { - unsafe { &*self.ptr } - } - - /// Bump the cursor to point at the next token after the current one. This - /// is undefined behavior if the cursor is currently looking at an - /// `Entry::End`. - unsafe fn bump(self) -> Cursor<'a> { - Cursor::create(self.ptr.offset(1), self.scope) - } - - /// If the cursor is looking at a `None`-delimited group, move it to look at - /// the first token inside instead. If the group is empty, this will move - /// the cursor past the `None`-delimited group. - /// - /// WARNING: This mutates its argument. - fn ignore_none(&mut self) { - if let Entry::Group(_, Delimiter::None, ref buf) = *self.entry() { - // NOTE: We call `Cursor::create` here to make sure that situations - // where we should immediately exit the span after entering it are - // handled correctly. - unsafe { - *self = Cursor::create(&buf.data[0], self.scope); - } - } - } - - /// Checks whether the cursor is currently pointing at the end of its valid - /// scope. - #[inline] - pub fn eof(self) -> bool { - // We're at eof if we're at the end of our scope. - self.ptr == self.scope - } - - /// If the cursor is pointing at a `Group` with the given delimiter, returns - /// a cursor into that group and one pointing to the next `TokenTree`. - pub fn group(mut self, delim: Delimiter) -> Option<(Cursor<'a>, Span, Cursor<'a>)> { - // If we're not trying to enter a none-delimited group, we want to - // ignore them. We have to make sure to _not_ ignore them when we want - // to enter them, of course. For obvious reasons. - if delim != Delimiter::None { - self.ignore_none(); - } - - if let Entry::Group(span, group_delim, ref buf) = *self.entry() { - if group_delim == delim { - return Some((buf.begin(), span, unsafe { self.bump() })); - } - } - - None - } - - /// If the cursor is pointing at a `Ident`, returns it along with a cursor - /// pointing at the next `TokenTree`. - pub fn ident(mut self) -> Option<(Ident, Cursor<'a>)> { - self.ignore_none(); - match *self.entry() { - Entry::Ident(ref ident) => Some((ident.clone(), unsafe { self.bump() })), - _ => None, - } - } - - /// If the cursor is pointing at an `Punct`, returns it along with a cursor - /// pointing at the next `TokenTree`. - pub fn punct(mut self) -> Option<(Punct, Cursor<'a>)> { - self.ignore_none(); - match *self.entry() { - Entry::Punct(ref op) => Some((op.clone(), unsafe { self.bump() })), - _ => None, - } - } - - /// If the cursor is pointing at a `Literal`, return it along with a cursor - /// pointing at the next `TokenTree`. - pub fn literal(mut self) -> Option<(Literal, Cursor<'a>)> { - self.ignore_none(); - match *self.entry() { - Entry::Literal(ref lit) => Some((lit.clone(), unsafe { self.bump() })), - _ => None, - } - } - - /// Copies all remaining tokens visible from this cursor into a - /// `TokenStream`. - pub fn token_stream(self) -> TokenStream { - let mut tts = Vec::new(); - let mut cursor = self; - while let Some((tt, rest)) = cursor.token_tree() { - tts.push(tt); - cursor = rest; - } - tts.into_iter().collect() - } - - /// If the cursor is pointing at a `TokenTree`, returns it along with a - /// cursor pointing at the next `TokenTree`. - /// - /// Returns `None` if the cursor has reached the end of its stream. - /// - /// This method does not treat `None`-delimited groups as transparent, and - /// will return a `Group(None, ..)` if the cursor is looking at one. - pub fn token_tree(self) -> Option<(TokenTree, Cursor<'a>)> { - let tree = match *self.entry() { - Entry::Group(span, delim, ref buf) => { - let stream = buf.begin().token_stream(); - let mut g = Group::new(delim, stream); - g.set_span(span); - TokenTree::from(g) - } - Entry::Literal(ref lit) => lit.clone().into(), - Entry::Ident(ref ident) => ident.clone().into(), - Entry::Punct(ref op) => op.clone().into(), - Entry::End(..) => { - return None; - } - }; - - Some((tree, unsafe { self.bump() })) - } - - /// Returns the `Span` of the current token, or `Span::call_site()` if this - /// cursor points to eof. - pub fn span(self) -> Span { - match *self.entry() { - Entry::Group(span, ..) => span, - Entry::Literal(ref l) => l.span(), - Entry::Ident(ref t) => t.span(), - Entry::Punct(ref o) => o.span(), - Entry::End(..) => Span::call_site(), - } - } -} - -// We do a custom implementation for `Debug` as the default implementation is -// pretty useless. -#[cfg(synom_verbose_trace)] -impl<'a> Debug for Cursor<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - // Print what the cursor is currently looking at. - // This will look like Cursor("some remaining tokens here") - f.debug_tuple("Cursor") - .field(&self.token_stream().to_string()) - .finish() - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/data.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/data.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/data.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/data.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,415 +0,0 @@ -// Copyright 2018 Syn Developers -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use super::*; -use punctuated::Punctuated; - -ast_struct! { - /// An enum variant. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - pub struct Variant { - /// Attributes tagged on the variant. - pub attrs: Vec, - - /// Name of the variant. - pub ident: Ident, - - /// Content stored in the variant. - pub fields: Fields, - - /// Explicit discriminant: `Variant = 1` - pub discriminant: Option<(Token![=], Expr)>, - } -} - -ast_enum_of_structs! { - /// Data stored within an enum variant or struct. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - /// - /// # Syntax tree enum - /// - /// This type is a [syntax tree enum]. - /// - /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums - pub enum Fields { - /// Named fields of a struct or struct variant such as `Point { x: f64, - /// y: f64 }`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Named(FieldsNamed { - pub brace_token: token::Brace, - pub named: Punctuated, - }), - - /// Unnamed fields of a tuple struct or tuple variant such as `Some(T)`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Unnamed(FieldsUnnamed { - pub paren_token: token::Paren, - pub unnamed: Punctuated, - }), - - /// Unit struct or unit variant such as `None`. - pub Unit, - } -} - -impl Fields { - /// Get an iterator over the borrowed [`Field`] items in this object. This - /// iterator can be used to iterate over a named or unnamed struct or - /// variant's fields uniformly. - /// - /// [`Field`]: struct.Field.html - pub fn iter(&self) -> punctuated::Iter { - match *self { - Fields::Unit => punctuated::Iter::private_empty(), - Fields::Named(ref f) => f.named.iter(), - Fields::Unnamed(ref f) => f.unnamed.iter(), - } - } - - /// Get an iterator over the mutably borrowed [`Field`] items in this - /// object. This iterator can be used to iterate over a named or unnamed - /// struct or variant's fields uniformly. - /// - /// [`Field`]: struct.Field.html - pub fn iter_mut(&mut self) -> punctuated::IterMut { - match *self { - Fields::Unit => punctuated::IterMut::private_empty(), - Fields::Named(ref mut f) => f.named.iter_mut(), - Fields::Unnamed(ref mut f) => f.unnamed.iter_mut(), - } - } -} - -impl<'a> IntoIterator for &'a Fields { - type Item = &'a Field; - type IntoIter = punctuated::Iter<'a, Field>; - - fn into_iter(self) -> Self::IntoIter { - self.iter() - } -} - -impl<'a> IntoIterator for &'a mut Fields { - type Item = &'a mut Field; - type IntoIter = punctuated::IterMut<'a, Field>; - - fn into_iter(self) -> Self::IntoIter { - self.iter_mut() - } -} - -ast_struct! { - /// A field of a struct or enum variant. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - pub struct Field { - /// Attributes tagged on the field. - pub attrs: Vec, - - /// Visibility of the field. - pub vis: Visibility, - - /// Name of the field, if any. - /// - /// Fields of tuple structs have no names. - pub ident: Option, - - pub colon_token: Option, - - /// Type of the field. - pub ty: Type, - } -} - -ast_enum_of_structs! { - /// The visibility level of an item: inherited or `pub` or - /// `pub(restricted)`. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - /// - /// # Syntax tree enum - /// - /// This type is a [syntax tree enum]. - /// - /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums - pub enum Visibility { - /// A public visibility level: `pub`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Public(VisPublic { - pub pub_token: Token![pub], - }), - - /// A crate-level visibility: `crate`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Crate(VisCrate { - pub crate_token: Token![crate], - }), - - /// A visibility level restricted to some path: `pub(self)` or - /// `pub(super)` or `pub(crate)` or `pub(in some::module)`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Restricted(VisRestricted { - pub pub_token: Token![pub], - pub paren_token: token::Paren, - pub in_token: Option, - pub path: Box, - }), - - /// An inherited visibility, which usually means private. - pub Inherited, - } -} - -#[cfg(feature = "parsing")] -pub mod parsing { - use super::*; - - use synom::Synom; - - impl Synom for Variant { - named!(parse -> Self, do_parse!( - attrs: many0!(Attribute::parse_outer) >> - id: syn!(Ident) >> - fields: alt!( - syn!(FieldsNamed) => { Fields::Named } - | - syn!(FieldsUnnamed) => { Fields::Unnamed } - | - epsilon!() => { |_| Fields::Unit } - ) >> - disr: option!(tuple!(punct!(=), syn!(Expr))) >> - (Variant { - ident: id, - attrs: attrs, - fields: fields, - discriminant: disr, - }) - )); - - fn description() -> Option<&'static str> { - Some("enum variant") - } - } - - impl Synom for FieldsNamed { - named!(parse -> Self, map!( - braces!(call!(Punctuated::parse_terminated_with, Field::parse_named)), - |(brace, fields)| FieldsNamed { - brace_token: brace, - named: fields, - } - )); - - fn description() -> Option<&'static str> { - Some("named fields in a struct or struct variant") - } - } - - impl Synom for FieldsUnnamed { - named!(parse -> Self, map!( - parens!(call!(Punctuated::parse_terminated_with, Field::parse_unnamed)), - |(paren, fields)| FieldsUnnamed { - paren_token: paren, - unnamed: fields, - } - )); - - fn description() -> Option<&'static str> { - Some("unnamed fields in a tuple struct or tuple variant") - } - } - - impl Field { - named!(pub parse_named -> Self, do_parse!( - attrs: many0!(Attribute::parse_outer) >> - vis: syn!(Visibility) >> - id: syn!(Ident) >> - colon: punct!(:) >> - ty: syn!(Type) >> - (Field { - ident: Some(id), - vis: vis, - attrs: attrs, - ty: ty, - colon_token: Some(colon), - }) - )); - - named!(pub parse_unnamed -> Self, do_parse!( - attrs: many0!(Attribute::parse_outer) >> - vis: syn!(Visibility) >> - ty: syn!(Type) >> - (Field { - ident: None, - colon_token: None, - vis: vis, - attrs: attrs, - ty: ty, - }) - )); - } - - impl Synom for Visibility { - named!(parse -> Self, alt!( - do_parse!( - pub_token: keyword!(pub) >> - other: parens!(keyword!(crate)) >> - (Visibility::Restricted(VisRestricted { - pub_token: pub_token, - paren_token: other.0, - in_token: None, - path: Box::new(other.1.into()), - })) - ) - | - do_parse!( - crate_token: keyword!(crate) >> - not!(punct!(::)) >> - (Visibility::Crate(VisCrate { - crate_token: crate_token, - })) - ) - | - do_parse!( - pub_token: keyword!(pub) >> - other: parens!(keyword!(self)) >> - (Visibility::Restricted(VisRestricted { - pub_token: pub_token, - paren_token: other.0, - in_token: None, - path: Box::new(other.1.into()), - })) - ) - | - do_parse!( - pub_token: keyword!(pub) >> - other: parens!(keyword!(super)) >> - (Visibility::Restricted(VisRestricted { - pub_token: pub_token, - paren_token: other.0, - in_token: None, - path: Box::new(other.1.into()), - })) - ) - | - do_parse!( - pub_token: keyword!(pub) >> - other: parens!(do_parse!( - in_tok: keyword!(in) >> - restricted: call!(Path::parse_mod_style) >> - (in_tok, restricted) - )) >> - (Visibility::Restricted(VisRestricted { - pub_token: pub_token, - paren_token: other.0, - in_token: Some((other.1).0), - path: Box::new((other.1).1), - })) - ) - | - keyword!(pub) => { |tok| { - Visibility::Public(VisPublic { - pub_token: tok, - }) - } } - | - epsilon!() => { |_| Visibility::Inherited } - )); - - fn description() -> Option<&'static str> { - Some("visibility qualifier such as `pub`") - } - } -} - -#[cfg(feature = "printing")] -mod printing { - use super::*; - use proc_macro2::TokenStream; - use quote::{ToTokens, TokenStreamExt}; - - impl ToTokens for Variant { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(&self.attrs); - self.ident.to_tokens(tokens); - self.fields.to_tokens(tokens); - if let Some((ref eq_token, ref disc)) = self.discriminant { - eq_token.to_tokens(tokens); - disc.to_tokens(tokens); - } - } - } - - impl ToTokens for FieldsNamed { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.brace_token.surround(tokens, |tokens| { - self.named.to_tokens(tokens); - }); - } - } - - impl ToTokens for FieldsUnnamed { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.paren_token.surround(tokens, |tokens| { - self.unnamed.to_tokens(tokens); - }); - } - } - - impl ToTokens for Field { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(&self.attrs); - self.vis.to_tokens(tokens); - if let Some(ref ident) = self.ident { - ident.to_tokens(tokens); - TokensOrDefault(&self.colon_token).to_tokens(tokens); - } - self.ty.to_tokens(tokens); - } - } - - impl ToTokens for VisPublic { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.pub_token.to_tokens(tokens) - } - } - - impl ToTokens for VisCrate { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.crate_token.to_tokens(tokens); - } - } - - impl ToTokens for VisRestricted { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.pub_token.to_tokens(tokens); - self.paren_token.surround(tokens, |tokens| { - // XXX: If we have a path which is not "self" or "super" or - // "crate", automatically add the "in" token. - self.in_token.to_tokens(tokens); - self.path.to_tokens(tokens); - }); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/derive.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/derive.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/derive.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/derive.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,242 +0,0 @@ -// Copyright 2018 Syn Developers -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use super::*; -use punctuated::Punctuated; - -ast_struct! { - /// Data structure sent to a `proc_macro_derive` macro. - /// - /// *This type is available if Syn is built with the `"derive"` feature.* - pub struct DeriveInput { - /// Attributes tagged on the whole struct or enum. - pub attrs: Vec, - - /// Visibility of the struct or enum. - pub vis: Visibility, - - /// Name of the struct or enum. - pub ident: Ident, - - /// Generics required to complete the definition. - pub generics: Generics, - - /// Data within the struct or enum. - pub data: Data, - } -} - -ast_enum_of_structs! { - /// The storage of a struct, enum or union data structure. - /// - /// *This type is available if Syn is built with the `"derive"` feature.* - /// - /// # Syntax tree enum - /// - /// This type is a [syntax tree enum]. - /// - /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums - pub enum Data { - /// A struct input to a `proc_macro_derive` macro. - /// - /// *This type is available if Syn is built with the `"derive"` - /// feature.* - pub Struct(DataStruct { - pub struct_token: Token![struct], - pub fields: Fields, - pub semi_token: Option, - }), - - /// An enum input to a `proc_macro_derive` macro. - /// - /// *This type is available if Syn is built with the `"derive"` - /// feature.* - pub Enum(DataEnum { - pub enum_token: Token![enum], - pub brace_token: token::Brace, - pub variants: Punctuated, - }), - - /// A tagged union input to a `proc_macro_derive` macro. - /// - /// *This type is available if Syn is built with the `"derive"` - /// feature.* - pub Union(DataUnion { - pub union_token: Token![union], - pub fields: FieldsNamed, - }), - } - - do_not_generate_to_tokens -} - -#[cfg(feature = "parsing")] -pub mod parsing { - use super::*; - - use synom::Synom; - - enum DeriveInputKind { - Struct(Token![struct]), - Enum(Token![enum]), - Union(Token![union]), - } - - impl Synom for DeriveInputKind { - named!(parse -> Self, alt!( - keyword!(struct) => { DeriveInputKind::Struct } - | - keyword!(enum) => { DeriveInputKind::Enum } - | - keyword!(union) => { DeriveInputKind::Union } - )); - } - - impl Synom for DeriveInput { - named!(parse -> Self, do_parse!( - attrs: many0!(Attribute::parse_outer) >> - vis: syn!(Visibility) >> - which: syn!(DeriveInputKind) >> - id: syn!(Ident) >> - generics: syn!(Generics) >> - item: switch!(value!(which), - DeriveInputKind::Struct(s) => map!(data_struct, move |(wh, fields, semi)| DeriveInput { - ident: id, - vis: vis, - attrs: attrs, - generics: Generics { - where_clause: wh, - ..generics - }, - data: Data::Struct(DataStruct { - struct_token: s, - fields: fields, - semi_token: semi, - }), - }) - | - DeriveInputKind::Enum(e) => map!(data_enum, move |(wh, brace, variants)| DeriveInput { - ident: id, - vis: vis, - attrs: attrs, - generics: Generics { - where_clause: wh, - ..generics - }, - data: Data::Enum(DataEnum { - variants: variants, - brace_token: brace, - enum_token: e, - }), - }) - | - DeriveInputKind::Union(u) => map!(data_union, move |(wh, fields)| DeriveInput { - ident: id, - vis: vis, - attrs: attrs, - generics: Generics { - where_clause: wh, - ..generics - }, - data: Data::Union(DataUnion { - union_token: u, - fields: fields, - }), - }) - ) >> - (item) - )); - - fn description() -> Option<&'static str> { - Some("derive input") - } - } - - named!(data_struct -> (Option, Fields, Option), alt!( - do_parse!( - wh: option!(syn!(WhereClause)) >> - fields: syn!(FieldsNamed) >> - (wh, Fields::Named(fields), None) - ) - | - do_parse!( - fields: syn!(FieldsUnnamed) >> - wh: option!(syn!(WhereClause)) >> - semi: punct!(;) >> - (wh, Fields::Unnamed(fields), Some(semi)) - ) - | - do_parse!( - wh: option!(syn!(WhereClause)) >> - semi: punct!(;) >> - (wh, Fields::Unit, Some(semi)) - ) - )); - - named!(data_enum -> (Option, token::Brace, Punctuated), do_parse!( - wh: option!(syn!(WhereClause)) >> - data: braces!(Punctuated::parse_terminated) >> - (wh, data.0, data.1) - )); - - named!(data_union -> (Option, FieldsNamed), tuple!( - option!(syn!(WhereClause)), - syn!(FieldsNamed), - )); -} - -#[cfg(feature = "printing")] -mod printing { - use super::*; - use attr::FilterAttrs; - use proc_macro2::TokenStream; - use quote::ToTokens; - - impl ToTokens for DeriveInput { - fn to_tokens(&self, tokens: &mut TokenStream) { - for attr in self.attrs.outer() { - attr.to_tokens(tokens); - } - self.vis.to_tokens(tokens); - match self.data { - Data::Struct(ref d) => d.struct_token.to_tokens(tokens), - Data::Enum(ref d) => d.enum_token.to_tokens(tokens), - Data::Union(ref d) => d.union_token.to_tokens(tokens), - } - self.ident.to_tokens(tokens); - self.generics.to_tokens(tokens); - match self.data { - Data::Struct(ref data) => match data.fields { - Fields::Named(ref fields) => { - self.generics.where_clause.to_tokens(tokens); - fields.to_tokens(tokens); - } - Fields::Unnamed(ref fields) => { - fields.to_tokens(tokens); - self.generics.where_clause.to_tokens(tokens); - TokensOrDefault(&data.semi_token).to_tokens(tokens); - } - Fields::Unit => { - self.generics.where_clause.to_tokens(tokens); - TokensOrDefault(&data.semi_token).to_tokens(tokens); - } - }, - Data::Enum(ref data) => { - self.generics.where_clause.to_tokens(tokens); - data.brace_token.surround(tokens, |tokens| { - data.variants.to_tokens(tokens); - }); - } - Data::Union(ref data) => { - self.generics.where_clause.to_tokens(tokens); - data.fields.to_tokens(tokens); - } - } - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/error.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/error.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/error.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/error.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -// Copyright 2018 Syn Developers -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use buffer::Cursor; -use std::error::Error; -use std::fmt::{self, Display}; - -/// The result of a `Synom` parser. -/// -/// Refer to the [module documentation] for details about parsing in Syn. -/// -/// [module documentation]: index.html -/// -/// *This type is available if Syn is built with the `"parsing"` feature.* -pub type PResult<'a, O> = Result<(O, Cursor<'a>), ParseError>; - -/// An error with a default error message. -/// -/// NOTE: We should provide better error messages in the future. -pub fn parse_error<'a, O>() -> PResult<'a, O> { - Err(ParseError(None)) -} - -/// Error returned when a `Synom` parser cannot parse the input tokens. -/// -/// Refer to the [module documentation] for details about parsing in Syn. -/// -/// [module documentation]: index.html -/// -/// *This type is available if Syn is built with the `"parsing"` feature.* -#[derive(Debug)] -pub struct ParseError(Option); - -impl Error for ParseError { - fn description(&self) -> &str { - match self.0 { - Some(ref desc) => desc, - None => "failed to parse", - } - } -} - -impl Display for ParseError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - Display::fmt(self.description(), f) - } -} - -impl ParseError { - // For syn use only. Not public API. - #[doc(hidden)] - pub fn new>(msg: T) -> Self { - ParseError(Some(msg.into())) - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/expr.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/expr.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/expr.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/expr.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,3836 +0,0 @@ -// Copyright 2018 Syn Developers -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use super::*; -use proc_macro2::{Span, TokenStream}; -use punctuated::Punctuated; -#[cfg(feature = "extra-traits")] -use std::hash::{Hash, Hasher}; -#[cfg(feature = "full")] -use std::mem; -#[cfg(feature = "extra-traits")] -use tt::TokenStreamHelper; - -ast_enum_of_structs! { - /// A Rust expression. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - /// - /// # Syntax tree enums - /// - /// This type is a syntax tree enum. In Syn this and other syntax tree enums - /// are designed to be traversed using the following rebinding idiom. - /// - /// ``` - /// # use syn::Expr; - /// # - /// # fn example(expr: Expr) { - /// # const IGNORE: &str = stringify! { - /// let expr: Expr = /* ... */; - /// # }; - /// match expr { - /// Expr::MethodCall(expr) => { - /// /* ... */ - /// } - /// Expr::Cast(expr) => { - /// /* ... */ - /// } - /// Expr::IfLet(expr) => { - /// /* ... */ - /// } - /// /* ... */ - /// # _ => {} - /// } - /// # } - /// ``` - /// - /// We begin with a variable `expr` of type `Expr` that has no fields - /// (because it is an enum), and by matching on it and rebinding a variable - /// with the same name `expr` we effectively imbue our variable with all of - /// the data fields provided by the variant that it turned out to be. So for - /// example above if we ended up in the `MethodCall` case then we get to use - /// `expr.receiver`, `expr.args` etc; if we ended up in the `IfLet` case we - /// get to use `expr.pat`, `expr.then_branch`, `expr.else_branch`. - /// - /// The pattern is similar if the input expression is borrowed: - /// - /// ``` - /// # use syn::Expr; - /// # - /// # fn example(expr: &Expr) { - /// match *expr { - /// Expr::MethodCall(ref expr) => { - /// # } - /// # _ => {} - /// # } - /// # } - /// ``` - /// - /// This approach avoids repeating the variant names twice on every line. - /// - /// ``` - /// # use syn::{Expr, ExprMethodCall}; - /// # - /// # fn example(expr: Expr) { - /// # match expr { - /// Expr::MethodCall(ExprMethodCall { method, args, .. }) => { // repetitive - /// # } - /// # _ => {} - /// # } - /// # } - /// ``` - /// - /// In general, the name to which a syntax tree enum variant is bound should - /// be a suitable name for the complete syntax tree enum type. - /// - /// ``` - /// # use syn::{Expr, ExprField}; - /// # - /// # fn example(discriminant: &ExprField) { - /// // Binding is called `base` which is the name I would use if I were - /// // assigning `*discriminant.base` without an `if let`. - /// if let Expr::Tuple(ref base) = *discriminant.base { - /// # } - /// # } - /// ``` - /// - /// A sign that you may not be choosing the right variable names is if you - /// see names getting repeated in your code, like accessing - /// `receiver.receiver` or `pat.pat` or `cond.cond`. - pub enum Expr { - /// A box expression: `box f`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Box(ExprBox #full { - pub attrs: Vec, - pub box_token: Token![box], - pub expr: Box, - }), - - /// A placement expression: `place <- value`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub InPlace(ExprInPlace #full { - pub attrs: Vec, - pub place: Box, - pub arrow_token: Token![<-], - pub value: Box, - }), - - /// A slice literal expression: `[a, b, c, d]`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Array(ExprArray #full { - pub attrs: Vec, - pub bracket_token: token::Bracket, - pub elems: Punctuated, - }), - - /// A function call expression: `invoke(a, b)`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Call(ExprCall { - pub attrs: Vec, - pub func: Box, - pub paren_token: token::Paren, - pub args: Punctuated, - }), - - /// A method call expression: `x.foo::(a, b)`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub MethodCall(ExprMethodCall #full { - pub attrs: Vec, - pub receiver: Box, - pub dot_token: Token![.], - pub method: Ident, - pub turbofish: Option, - pub paren_token: token::Paren, - pub args: Punctuated, - }), - - /// A tuple expression: `(a, b, c, d)`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Tuple(ExprTuple #full { - pub attrs: Vec, - pub paren_token: token::Paren, - pub elems: Punctuated, - }), - - /// A binary operation: `a + b`, `a * b`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Binary(ExprBinary { - pub attrs: Vec, - pub left: Box, - pub op: BinOp, - pub right: Box, - }), - - /// A unary operation: `!x`, `*x`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Unary(ExprUnary { - pub attrs: Vec, - pub op: UnOp, - pub expr: Box, - }), - - /// A literal in place of an expression: `1`, `"foo"`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Lit(ExprLit { - pub attrs: Vec, - pub lit: Lit, - }), - - /// A cast expression: `foo as f64`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Cast(ExprCast { - pub attrs: Vec, - pub expr: Box, - pub as_token: Token![as], - pub ty: Box, - }), - - /// A type ascription expression: `foo: f64`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Type(ExprType #full { - pub attrs: Vec, - pub expr: Box, - pub colon_token: Token![:], - pub ty: Box, - }), - - /// An `if` expression with an optional `else` block: `if expr { ... } - /// else { ... }`. - /// - /// The `else` branch expression may only be an `If`, `IfLet`, or - /// `Block` expression, not any of the other types of expression. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub If(ExprIf #full { - pub attrs: Vec, - pub if_token: Token![if], - pub cond: Box, - pub then_branch: Block, - pub else_branch: Option<(Token![else], Box)>, - }), - - /// An `if let` expression with an optional `else` block: `if let pat = - /// expr { ... } else { ... }`. - /// - /// The `else` branch expression may only be an `If`, `IfLet`, or - /// `Block` expression, not any of the other types of expression. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub IfLet(ExprIfLet #full { - pub attrs: Vec, - pub if_token: Token![if], - pub let_token: Token![let], - pub pats: Punctuated, - pub eq_token: Token![=], - pub expr: Box, - pub then_branch: Block, - pub else_branch: Option<(Token![else], Box)>, - }), - - /// A while loop: `while expr { ... }`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub While(ExprWhile #full { - pub attrs: Vec, - pub label: Option::B::C` and `::B::C` can only legally refer to - /// associated constants. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Path(PatPath { - pub qself: Option, - pub path: Path, - }), - - /// A tuple pattern: `(a, b)`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Tuple(PatTuple { - pub paren_token: token::Paren, - pub front: Punctuated, - pub dot2_token: Option, - pub comma_token: Option, - pub back: Punctuated, - }), - - /// A box pattern: `box v`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Box(PatBox { - pub box_token: Token![box], - pub pat: Box, - }), - - /// A reference pattern: `&mut (first, second)`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Ref(PatRef { - pub and_token: Token![&], - pub mutability: Option, - pub pat: Box, - }), - - /// A literal pattern: `0`. - /// - /// This holds an `Expr` rather than a `Lit` because negative numbers - /// are represented as an `Expr::Unary`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Lit(PatLit { - pub expr: Box, - }), - - /// A range pattern: `1..=2`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Range(PatRange { - pub lo: Box, - pub limits: RangeLimits, - pub hi: Box, - }), - - /// A dynamically sized slice pattern: `[a, b, i.., y, z]`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Slice(PatSlice { - pub bracket_token: token::Bracket, - pub front: Punctuated, - pub middle: Option>, - pub dot2_token: Option, - pub comma_token: Option, - pub back: Punctuated, - }), - - /// A macro in expression position. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Macro(PatMacro { - pub mac: Macro, - }), - - /// Tokens in pattern position not interpreted by Syn. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Verbatim(PatVerbatim #manual_extra_traits { - pub tts: TokenStream, - }), - } -} - -#[cfg(all(feature = "full", feature = "extra-traits"))] -impl Eq for PatVerbatim {} - -#[cfg(all(feature = "full", feature = "extra-traits"))] -impl PartialEq for PatVerbatim { - fn eq(&self, other: &Self) -> bool { - TokenStreamHelper(&self.tts) == TokenStreamHelper(&other.tts) - } -} - -#[cfg(all(feature = "full", feature = "extra-traits"))] -impl Hash for PatVerbatim { - fn hash(&self, state: &mut H) - where - H: Hasher, - { - TokenStreamHelper(&self.tts).hash(state); - } -} - -#[cfg(feature = "full")] -ast_struct! { - /// One arm of a `match` expression: `0...10 => { return true; }`. - /// - /// As in: - /// - /// ```rust - /// # fn f() -> bool { - /// # let n = 0; - /// match n { - /// 0...10 => { - /// return true; - /// } - /// // ... - /// # _ => {} - /// } - /// # false - /// # } - /// ``` - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub struct Arm { - pub attrs: Vec, - pub leading_vert: Option, - pub pats: Punctuated, - pub guard: Option<(Token![if], Box)>, - pub fat_arrow_token: Token![=>], - pub body: Box, - pub comma: Option, - } -} - -#[cfg(feature = "full")] -ast_enum! { - /// Limit types of a range, inclusive or exclusive. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - #[cfg_attr(feature = "clone-impls", derive(Copy))] - pub enum RangeLimits { - /// Inclusive at the beginning, exclusive at the end. - HalfOpen(Token![..]), - /// Inclusive at the beginning and end. - Closed(Token![..=]), - } -} - -#[cfg(feature = "full")] -ast_struct! { - /// A single field in a struct pattern. - /// - /// Patterns like the fields of Foo `{ x, ref y, ref mut z }` are treated - /// the same as `x: x, y: ref y, z: ref mut z` but there is no colon token. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub struct FieldPat { - pub attrs: Vec, - pub member: Member, - pub colon_token: Option, - pub pat: Box, - } -} - -#[cfg(any(feature = "parsing", feature = "printing"))] -#[cfg(feature = "full")] -fn arm_expr_requires_comma(expr: &Expr) -> bool { - // see https://github.com/rust-lang/rust/blob/eb8f2586e - // /src/libsyntax/parse/classify.rs#L17-L37 - match *expr { - Expr::Unsafe(..) - | Expr::Block(..) - | Expr::If(..) - | Expr::IfLet(..) - | Expr::Match(..) - | Expr::While(..) - | Expr::WhileLet(..) - | Expr::Loop(..) - | Expr::ForLoop(..) - | Expr::Catch(..) => false, - _ => true, - } -} - -#[cfg(feature = "parsing")] -pub mod parsing { - use super::*; - use path::parsing::qpath; - #[cfg(feature = "full")] - use path::parsing::ty_no_eq_after; - - use buffer::Cursor; - #[cfg(feature = "full")] - use parse_error; - #[cfg(feature = "full")] - use proc_macro2::TokenStream; - use synom::PResult; - use synom::Synom; - - // When we're parsing expressions which occur before blocks, like in an if - // statement's condition, we cannot parse a struct literal. - // - // Struct literals are ambiguous in certain positions - // https://github.com/rust-lang/rfcs/pull/92 - macro_rules! ambiguous_expr { - ($i:expr, $allow_struct:ident) => { - ambiguous_expr($i, $allow_struct, true) - }; - } - - // When we are parsing an optional suffix expression, we cannot allow blocks - // if structs are not allowed. - // - // Example: - // - // if break {} {} - // - // is ambiguous between: - // - // if (break {}) {} - // if (break) {} {} - #[cfg(feature = "full")] - macro_rules! opt_ambiguous_expr { - ($i:expr, $allow_struct:ident) => { - option!($i, call!(ambiguous_expr, $allow_struct, $allow_struct)) - }; - } - - impl Synom for Expr { - named!(parse -> Self, ambiguous_expr!(true)); - - fn description() -> Option<&'static str> { - Some("expression") - } - } - - #[cfg(feature = "full")] - named!(expr_no_struct -> Expr, ambiguous_expr!(false)); - - // Parse an arbitrary expression. - #[cfg(feature = "full")] - fn ambiguous_expr(i: Cursor, allow_struct: bool, allow_block: bool) -> PResult { - call!(i, assign_expr, allow_struct, allow_block) - } - - #[cfg(not(feature = "full"))] - fn ambiguous_expr(i: Cursor, allow_struct: bool, allow_block: bool) -> PResult { - // NOTE: We intentionally skip assign_expr, placement_expr, and - // range_expr, as they are not parsed in non-full mode. - call!(i, or_expr, allow_struct, allow_block) - } - - // Parse a left-associative binary operator. - macro_rules! binop { - ( - $name: ident, - $next: ident, - $submac: ident!( $($args:tt)* ) - ) => { - named!($name(allow_struct: bool, allow_block: bool) -> Expr, do_parse!( - mut e: call!($next, allow_struct, allow_block) >> - many0!(do_parse!( - op: $submac!($($args)*) >> - rhs: call!($next, allow_struct, true) >> - ({ - e = ExprBinary { - attrs: Vec::new(), - left: Box::new(e.into()), - op: op, - right: Box::new(rhs.into()), - }.into(); - }) - )) >> - (e) - )); - } - } - - // = .. - // += .. - // -= .. - // *= .. - // /= .. - // %= .. - // ^= .. - // &= .. - // |= .. - // <<= .. - // >>= .. - // - // NOTE: This operator is right-associative. - #[cfg(feature = "full")] - named!(assign_expr(allow_struct: bool, allow_block: bool) -> Expr, do_parse!( - mut e: call!(placement_expr, allow_struct, allow_block) >> - alt!( - do_parse!( - eq: punct!(=) >> - // Recurse into self to parse right-associative operator. - rhs: call!(assign_expr, allow_struct, true) >> - ({ - e = ExprAssign { - attrs: Vec::new(), - left: Box::new(e), - eq_token: eq, - right: Box::new(rhs), - }.into(); - }) - ) - | - do_parse!( - op: call!(BinOp::parse_assign_op) >> - // Recurse into self to parse right-associative operator. - rhs: call!(assign_expr, allow_struct, true) >> - ({ - e = ExprAssignOp { - attrs: Vec::new(), - left: Box::new(e), - op: op, - right: Box::new(rhs), - }.into(); - }) - ) - | - epsilon!() - ) >> - (e) - )); - - // <- .. - // - // NOTE: The `in place { expr }` version of this syntax is parsed in - // `atom_expr`, not here. - // - // NOTE: This operator is right-associative. - #[cfg(feature = "full")] - named!(placement_expr(allow_struct: bool, allow_block: bool) -> Expr, do_parse!( - mut e: call!(range_expr, allow_struct, allow_block) >> - alt!( - do_parse!( - arrow: punct!(<-) >> - // Recurse into self to parse right-associative operator. - rhs: call!(placement_expr, allow_struct, true) >> - ({ - e = ExprInPlace { - attrs: Vec::new(), - // op: BinOp::Place(larrow), - place: Box::new(e), - arrow_token: arrow, - value: Box::new(rhs), - }.into(); - }) - ) - | - epsilon!() - ) >> - (e) - )); - - // ... .. - // .. .. - // .. - // - // NOTE: This is currently parsed oddly - I'm not sure of what the exact - // rules are for parsing these expressions are, but this is not correct. - // For example, `a .. b .. c` is not a legal expression. It should not - // be parsed as either `(a .. b) .. c` or `a .. (b .. c)` apparently. - // - // NOTE: The form of ranges which don't include a preceding expression are - // parsed by `atom_expr`, rather than by this function. - #[cfg(feature = "full")] - named!(range_expr(allow_struct: bool, allow_block: bool) -> Expr, do_parse!( - mut e: call!(or_expr, allow_struct, allow_block) >> - many0!(do_parse!( - limits: syn!(RangeLimits) >> - // We don't want to allow blocks here if we don't allow structs. See - // the reasoning for `opt_ambiguous_expr!` above. - hi: option!(call!(or_expr, allow_struct, allow_struct)) >> - ({ - e = ExprRange { - attrs: Vec::new(), - from: Some(Box::new(e)), - limits: limits, - to: hi.map(|e| Box::new(e)), - }.into(); - }) - )) >> - (e) - )); - - // || ... - binop!(or_expr, and_expr, map!(punct!(||), BinOp::Or)); - - // && ... - binop!(and_expr, compare_expr, map!(punct!(&&), BinOp::And)); - - // == ... - // != ... - // >= ... - // <= ... - // > ... - // < ... - // - // NOTE: This operator appears to be parsed as left-associative, but errors - // if it is used in a non-associative manner. - binop!( - compare_expr, - bitor_expr, - alt!( - punct!(==) => { BinOp::Eq } - | - punct!(!=) => { BinOp::Ne } - | - // must be above Lt - punct!(<=) => { BinOp::Le } - | - // must be above Gt - punct!(>=) => { BinOp::Ge } - | - do_parse!( - // Make sure that we don't eat the < part of a <- operator - not!(punct!(<-)) >> - t: punct!(<) >> - (BinOp::Lt(t)) - ) - | - punct!(>) => { BinOp::Gt } - ) - ); - - // | ... - binop!( - bitor_expr, - bitxor_expr, - do_parse!(not!(punct!(||)) >> not!(punct!(|=)) >> t: punct!(|) >> (BinOp::BitOr(t))) - ); - - // ^ ... - binop!( - bitxor_expr, - bitand_expr, - do_parse!( - // NOTE: Make sure we aren't looking at ^=. - not!(punct!(^=)) >> t: punct!(^) >> (BinOp::BitXor(t)) - ) - ); - - // & ... - binop!( - bitand_expr, - shift_expr, - do_parse!( - // NOTE: Make sure we aren't looking at && or &=. - not!(punct!(&&)) >> not!(punct!(&=)) >> t: punct!(&) >> (BinOp::BitAnd(t)) - ) - ); - - // << ... - // >> ... - binop!( - shift_expr, - arith_expr, - alt!( - punct!(<<) => { BinOp::Shl } - | - punct!(>>) => { BinOp::Shr } - ) - ); - - // + ... - // - ... - binop!( - arith_expr, - term_expr, - alt!( - punct!(+) => { BinOp::Add } - | - punct!(-) => { BinOp::Sub } - ) - ); - - // * ... - // / ... - // % ... - binop!( - term_expr, - cast_expr, - alt!( - punct!(*) => { BinOp::Mul } - | - punct!(/) => { BinOp::Div } - | - punct!(%) => { BinOp::Rem } - ) - ); - - // as - // : - #[cfg(feature = "full")] - named!(cast_expr(allow_struct: bool, allow_block: bool) -> Expr, do_parse!( - mut e: call!(unary_expr, allow_struct, allow_block) >> - many0!(alt!( - do_parse!( - as_: keyword!(as) >> - // We can't accept `A + B` in cast expressions, as it's - // ambiguous with the + expression. - ty: call!(Type::without_plus) >> - ({ - e = ExprCast { - attrs: Vec::new(), - expr: Box::new(e), - as_token: as_, - ty: Box::new(ty), - }.into(); - }) - ) - | - do_parse!( - colon: punct!(:) >> - // We can't accept `A + B` in cast expressions, as it's - // ambiguous with the + expression. - ty: call!(Type::without_plus) >> - ({ - e = ExprType { - attrs: Vec::new(), - expr: Box::new(e), - colon_token: colon, - ty: Box::new(ty), - }.into(); - }) - ) - )) >> - (e) - )); - - // as - #[cfg(not(feature = "full"))] - named!(cast_expr(allow_struct: bool, allow_block: bool) -> Expr, do_parse!( - mut e: call!(unary_expr, allow_struct, allow_block) >> - many0!(do_parse!( - as_: keyword!(as) >> - // We can't accept `A + B` in cast expressions, as it's - // ambiguous with the + expression. - ty: call!(Type::without_plus) >> - ({ - e = ExprCast { - attrs: Vec::new(), - expr: Box::new(e), - as_token: as_, - ty: Box::new(ty), - }.into(); - }) - )) >> - (e) - )); - - // - // & - // &mut - // box - #[cfg(feature = "full")] - named!(unary_expr(allow_struct: bool, allow_block: bool) -> Expr, alt!( - do_parse!( - attrs: many0!(Attribute::parse_outer) >> - op: syn!(UnOp) >> - expr: call!(unary_expr, allow_struct, true) >> - (ExprUnary { - attrs: attrs, - op: op, - expr: Box::new(expr), - }.into()) - ) - | - do_parse!( - attrs: many0!(Attribute::parse_outer) >> - and: punct!(&) >> - mutability: option!(keyword!(mut)) >> - expr: call!(unary_expr, allow_struct, true) >> - (ExprReference { - attrs: attrs, - and_token: and, - mutability: mutability, - expr: Box::new(expr), - }.into()) - ) - | - do_parse!( - attrs: many0!(Attribute::parse_outer) >> - box_: keyword!(box) >> - expr: call!(unary_expr, allow_struct, true) >> - (ExprBox { - attrs: attrs, - box_token: box_, - expr: Box::new(expr), - }.into()) - ) - | - call!(trailer_expr, allow_struct, allow_block) - )); - - // XXX: This duplication is ugly - #[cfg(not(feature = "full"))] - named!(unary_expr(allow_struct: bool, allow_block: bool) -> Expr, alt!( - do_parse!( - op: syn!(UnOp) >> - expr: call!(unary_expr, allow_struct, true) >> - (ExprUnary { - attrs: Vec::new(), - op: op, - expr: Box::new(expr), - }.into()) - ) - | - call!(trailer_expr, allow_struct, allow_block) - )); - - #[cfg(feature = "full")] - fn take_outer(attrs: &mut Vec) -> Vec { - let mut outer = Vec::new(); - let mut inner = Vec::new(); - for attr in mem::replace(attrs, Vec::new()) { - match attr.style { - AttrStyle::Outer => outer.push(attr), - AttrStyle::Inner(_) => inner.push(attr), - } - } - *attrs = inner; - outer - } - - // (..) ... - // . (..) ... - // . ... - // . ... - // [ ] ... - // ? ... - #[cfg(feature = "full")] - named!(trailer_expr(allow_struct: bool, allow_block: bool) -> Expr, do_parse!( - mut e: call!(atom_expr, allow_struct, allow_block) >> - outer_attrs: value!({ - let mut attrs = e.replace_attrs(Vec::new()); - let outer_attrs = take_outer(&mut attrs); - e.replace_attrs(attrs); - outer_attrs - }) >> - many0!(alt!( - tap!(args: and_call => { - let (paren, args) = args; - e = ExprCall { - attrs: Vec::new(), - func: Box::new(e), - args: args, - paren_token: paren, - }.into(); - }) - | - tap!(more: and_method_call => { - let mut call = more; - call.receiver = Box::new(e); - e = call.into(); - }) - | - tap!(field: and_field => { - let (token, member) = field; - e = ExprField { - attrs: Vec::new(), - base: Box::new(e), - dot_token: token, - member: member, - }.into(); - }) - | - tap!(i: and_index => { - let (bracket, i) = i; - e = ExprIndex { - attrs: Vec::new(), - expr: Box::new(e), - bracket_token: bracket, - index: Box::new(i), - }.into(); - }) - | - tap!(question: punct!(?) => { - e = ExprTry { - attrs: Vec::new(), - expr: Box::new(e), - question_token: question, - }.into(); - }) - )) >> - ({ - let mut attrs = outer_attrs; - attrs.extend(e.replace_attrs(Vec::new())); - e.replace_attrs(attrs); - e - }) - )); - - // XXX: Duplication == ugly - #[cfg(not(feature = "full"))] - named!(trailer_expr(allow_struct: bool, allow_block: bool) -> Expr, do_parse!( - mut e: call!(atom_expr, allow_struct, allow_block) >> - many0!(alt!( - tap!(args: and_call => { - e = ExprCall { - attrs: Vec::new(), - func: Box::new(e), - paren_token: args.0, - args: args.1, - }.into(); - }) - | - tap!(field: and_field => { - let (token, member) = field; - e = ExprField { - attrs: Vec::new(), - base: Box::new(e), - dot_token: token, - member: member, - }.into(); - }) - | - tap!(i: and_index => { - e = ExprIndex { - attrs: Vec::new(), - expr: Box::new(e), - bracket_token: i.0, - index: Box::new(i.1), - }.into(); - }) - )) >> - (e) - )); - - // Parse all atomic expressions which don't have to worry about precedence - // interactions, as they are fully contained. - #[cfg(feature = "full")] - named!(atom_expr(allow_struct: bool, allow_block: bool) -> Expr, alt!( - syn!(ExprGroup) => { Expr::Group } // must be placed first - | - syn!(ExprLit) => { Expr::Lit } // must be before expr_struct - | - // must be before ExprStruct - call!(unstable_async_block) => { Expr::Verbatim } - | - // must be before expr_path - cond_reduce!(allow_struct, syn!(ExprStruct)) => { Expr::Struct } - | - syn!(ExprParen) => { Expr::Paren } // must be before expr_tup - | - syn!(ExprMacro) => { Expr::Macro } // must be before expr_path - | - call!(expr_break, allow_struct) // must be before expr_path - | - syn!(ExprContinue) => { Expr::Continue } // must be before expr_path - | - call!(expr_ret, allow_struct) // must be before expr_path - | - syn!(ExprArray) => { Expr::Array } - | - syn!(ExprTuple) => { Expr::Tuple } - | - syn!(ExprIf) => { Expr::If } - | - syn!(ExprIfLet) => { Expr::IfLet } - | - syn!(ExprWhile) => { Expr::While } - | - syn!(ExprWhileLet) => { Expr::WhileLet } - | - syn!(ExprForLoop) => { Expr::ForLoop } - | - syn!(ExprLoop) => { Expr::Loop } - | - syn!(ExprMatch) => { Expr::Match } - | - syn!(ExprCatch) => { Expr::Catch } - | - syn!(ExprYield) => { Expr::Yield } - | - syn!(ExprUnsafe) => { Expr::Unsafe } - | - call!(expr_closure, allow_struct) - | - cond_reduce!(allow_block, syn!(ExprBlock)) => { Expr::Block } - | - call!(unstable_labeled_block) => { Expr::Verbatim } - | - // NOTE: This is the prefix-form of range - call!(expr_range, allow_struct) - | - syn!(ExprPath) => { Expr::Path } - | - syn!(ExprRepeat) => { Expr::Repeat } - )); - - #[cfg(not(feature = "full"))] - named!(atom_expr(_allow_struct: bool, _allow_block: bool) -> Expr, alt!( - syn!(ExprLit) => { Expr::Lit } - | - syn!(ExprParen) => { Expr::Paren } - | - syn!(ExprPath) => { Expr::Path } - )); - - #[cfg(feature = "full")] - named!(expr_nosemi -> Expr, do_parse!( - nosemi: alt!( - syn!(ExprIf) => { Expr::If } - | - syn!(ExprIfLet) => { Expr::IfLet } - | - syn!(ExprWhile) => { Expr::While } - | - syn!(ExprWhileLet) => { Expr::WhileLet } - | - syn!(ExprForLoop) => { Expr::ForLoop } - | - syn!(ExprLoop) => { Expr::Loop } - | - syn!(ExprMatch) => { Expr::Match } - | - syn!(ExprCatch) => { Expr::Catch } - | - syn!(ExprYield) => { Expr::Yield } - | - syn!(ExprUnsafe) => { Expr::Unsafe } - | - syn!(ExprBlock) => { Expr::Block } - | - call!(unstable_labeled_block) => { Expr::Verbatim } - ) >> - // If the next token is a `.` or a `?` it is special-cased to parse - // as an expression instead of a blockexpression. - not!(punct!(.)) >> - not!(punct!(?)) >> - (nosemi) - )); - - impl Synom for ExprLit { - #[cfg(not(feature = "full"))] - named!(parse -> Self, do_parse!( - lit: syn!(Lit) >> - (ExprLit { - attrs: Vec::new(), - lit: lit, - }) - )); - - #[cfg(feature = "full")] - named!(parse -> Self, do_parse!( - attrs: many0!(Attribute::parse_outer) >> - lit: syn!(Lit) >> - (ExprLit { - attrs: attrs, - lit: lit, - }) - )); - - fn description() -> Option<&'static str> { - Some("literal") - } - } - - #[cfg(feature = "full")] - impl Synom for ExprMacro { - named!(parse -> Self, do_parse!( - attrs: many0!(Attribute::parse_outer) >> - mac: syn!(Macro) >> - (ExprMacro { - attrs: attrs, - mac: mac, - }) - )); - - fn description() -> Option<&'static str> { - Some("macro invocation expression") - } - } - - #[cfg(feature = "full")] - impl Synom for ExprGroup { - named!(parse -> Self, do_parse!( - e: grouped!(syn!(Expr)) >> - (ExprGroup { - attrs: Vec::new(), - expr: Box::new(e.1), - group_token: e.0, - }) - )); - - fn description() -> Option<&'static str> { - Some("expression surrounded by invisible delimiters") - } - } - - impl Synom for ExprParen { - #[cfg(not(feature = "full"))] - named!(parse -> Self, do_parse!( - e: parens!(syn!(Expr)) >> - (ExprParen { - attrs: Vec::new(), - paren_token: e.0, - expr: Box::new(e.1), - }) - )); - - #[cfg(feature = "full")] - named!(parse -> Self, do_parse!( - outer_attrs: many0!(Attribute::parse_outer) >> - e: parens!(tuple!( - many0!(Attribute::parse_inner), - syn!(Expr), - )) >> - (ExprParen { - attrs: { - let mut attrs = outer_attrs; - attrs.extend((e.1).0); - attrs - }, - paren_token: e.0, - expr: Box::new((e.1).1), - }) - )); - - fn description() -> Option<&'static str> { - Some("parenthesized expression") - } - } - - #[cfg(feature = "full")] - impl Synom for ExprArray { - named!(parse -> Self, do_parse!( - outer_attrs: many0!(Attribute::parse_outer) >> - elems: brackets!(tuple!( - many0!(Attribute::parse_inner), - call!(Punctuated::parse_terminated), - )) >> - (ExprArray { - attrs: { - let mut attrs = outer_attrs; - attrs.extend((elems.1).0); - attrs - }, - bracket_token: elems.0, - elems: (elems.1).1, - }) - )); - - fn description() -> Option<&'static str> { - Some("array expression") - } - } - - named!(and_call -> (token::Paren, Punctuated), - parens!(Punctuated::parse_terminated) - ); - - #[cfg(feature = "full")] - named!(and_method_call -> ExprMethodCall, do_parse!( - dot: punct!(.) >> - method: syn!(Ident) >> - turbofish: option!(tuple!( - punct!(::), - punct!(<), - call!(Punctuated::parse_terminated), - punct!(>), - )) >> - args: parens!(Punctuated::parse_terminated) >> - ({ - ExprMethodCall { - attrs: Vec::new(), - // this expr will get overwritten after being returned - receiver: Box::new(Expr::Verbatim(ExprVerbatim { - tts: TokenStream::new(), - })), - - method: method, - turbofish: turbofish.map(|fish| MethodTurbofish { - colon2_token: fish.0, - lt_token: fish.1, - args: fish.2, - gt_token: fish.3, - }), - args: args.1, - paren_token: args.0, - dot_token: dot, - } - }) - )); - - #[cfg(feature = "full")] - impl Synom for GenericMethodArgument { - // TODO parse const generics as well - named!(parse -> Self, map!(ty_no_eq_after, GenericMethodArgument::Type)); - - fn description() -> Option<&'static str> { - Some("generic method argument") - } - } - - #[cfg(feature = "full")] - impl Synom for ExprTuple { - named!(parse -> Self, do_parse!( - outer_attrs: many0!(Attribute::parse_outer) >> - elems: parens!(tuple!( - many0!(Attribute::parse_inner), - call!(Punctuated::parse_terminated), - )) >> - (ExprTuple { - attrs: { - let mut attrs = outer_attrs; - attrs.extend((elems.1).0); - attrs - }, - elems: (elems.1).1, - paren_token: elems.0, - }) - )); - - fn description() -> Option<&'static str> { - Some("tuple") - } - } - - #[cfg(feature = "full")] - impl Synom for ExprIfLet { - named!(parse -> Self, do_parse!( - if_: keyword!(if) >> - let_: keyword!(let) >> - pats: call!(Punctuated::parse_separated_nonempty) >> - eq: punct!(=) >> - cond: expr_no_struct >> - then_block: braces!(Block::parse_within) >> - else_block: option!(else_block) >> - (ExprIfLet { - attrs: Vec::new(), - pats: pats, - let_token: let_, - eq_token: eq, - expr: Box::new(cond), - then_branch: Block { - brace_token: then_block.0, - stmts: then_block.1, - }, - if_token: if_, - else_branch: else_block, - }) - )); - - fn description() -> Option<&'static str> { - Some("`if let` expression") - } - } - - #[cfg(feature = "full")] - impl Synom for ExprIf { - named!(parse -> Self, do_parse!( - if_: keyword!(if) >> - cond: expr_no_struct >> - then_block: braces!(Block::parse_within) >> - else_block: option!(else_block) >> - (ExprIf { - attrs: Vec::new(), - cond: Box::new(cond), - then_branch: Block { - brace_token: then_block.0, - stmts: then_block.1, - }, - if_token: if_, - else_branch: else_block, - }) - )); - - fn description() -> Option<&'static str> { - Some("`if` expression") - } - } - - #[cfg(feature = "full")] - named!(else_block -> (Token![else], Box), do_parse!( - else_: keyword!(else) >> - expr: alt!( - syn!(ExprIf) => { Expr::If } - | - syn!(ExprIfLet) => { Expr::IfLet } - | - do_parse!( - else_block: braces!(Block::parse_within) >> - (Expr::Block(ExprBlock { - attrs: Vec::new(), - block: Block { - brace_token: else_block.0, - stmts: else_block.1, - }, - })) - ) - ) >> - (else_, Box::new(expr)) - )); - - #[cfg(feature = "full")] - impl Synom for ExprForLoop { - named!(parse -> Self, do_parse!( - outer_attrs: many0!(Attribute::parse_outer) >> - label: option!(syn!(Label)) >> - for_: keyword!(for) >> - pat: syn!(Pat) >> - in_: keyword!(in) >> - expr: expr_no_struct >> - block: braces!(tuple!( - many0!(Attribute::parse_inner), - call!(Block::parse_within), - )) >> - (ExprForLoop { - attrs: { - let mut attrs = outer_attrs; - attrs.extend((block.1).0); - attrs - }, - label: label, - for_token: for_, - pat: Box::new(pat), - in_token: in_, - expr: Box::new(expr), - body: Block { - brace_token: block.0, - stmts: (block.1).1, - }, - }) - )); - - fn description() -> Option<&'static str> { - Some("`for` loop") - } - } - - #[cfg(feature = "full")] - impl Synom for ExprLoop { - named!(parse -> Self, do_parse!( - outer_attrs: many0!(Attribute::parse_outer) >> - label: option!(syn!(Label)) >> - loop_: keyword!(loop) >> - block: braces!(tuple!( - many0!(Attribute::parse_inner), - call!(Block::parse_within), - )) >> - (ExprLoop { - attrs: { - let mut attrs = outer_attrs; - attrs.extend((block.1).0); - attrs - }, - label: label, - loop_token: loop_, - body: Block { - brace_token: block.0, - stmts: (block.1).1, - }, - }) - )); - - fn description() -> Option<&'static str> { - Some("`loop`") - } - } - - #[cfg(feature = "full")] - impl Synom for ExprMatch { - named!(parse -> Self, do_parse!( - outer_attrs: many0!(Attribute::parse_outer) >> - match_: keyword!(match) >> - obj: expr_no_struct >> - braced_content: braces!(tuple!( - many0!(Attribute::parse_inner), - many0!(syn!(Arm)), - )) >> - (ExprMatch { - attrs: { - let mut attrs = outer_attrs; - attrs.extend((braced_content.1).0); - attrs - }, - expr: Box::new(obj), - match_token: match_, - brace_token: braced_content.0, - arms: (braced_content.1).1, - }) - )); - - fn description() -> Option<&'static str> { - Some("`match` expression") - } - } - - #[cfg(feature = "full")] - impl Synom for ExprCatch { - named!(parse -> Self, do_parse!( - do_: keyword!(do) >> - catch_: keyword!(catch) >> - catch_block: syn!(Block) >> - (ExprCatch { - attrs: Vec::new(), - block: catch_block, - do_token: do_, - catch_token: catch_, - }) - )); - - fn description() -> Option<&'static str> { - Some("`catch` expression") - } - } - - #[cfg(feature = "full")] - impl Synom for ExprYield { - named!(parse -> Self, do_parse!( - yield_: keyword!(yield) >> - expr: option!(syn!(Expr)) >> - (ExprYield { - attrs: Vec::new(), - yield_token: yield_, - expr: expr.map(Box::new), - }) - )); - - fn description() -> Option<&'static str> { - Some("`yield` expression") - } - } - - #[cfg(feature = "full")] - impl Synom for Arm { - named!(parse -> Self, do_parse!( - attrs: many0!(Attribute::parse_outer) >> - leading_vert: option!(punct!(|)) >> - pats: call!(Punctuated::parse_separated_nonempty) >> - guard: option!(tuple!(keyword!(if), syn!(Expr))) >> - fat_arrow: punct!(=>) >> - body: do_parse!( - expr: alt!(expr_nosemi | syn!(Expr)) >> - comma: switch!(value!(arm_expr_requires_comma(&expr)), - true => alt!( - input_end!() => { |_| None } - | - punct!(,) => { Some } - ) - | - false => option!(punct!(,)) - ) >> - (expr, comma) - ) >> - (Arm { - fat_arrow_token: fat_arrow, - attrs: attrs, - leading_vert: leading_vert, - pats: pats, - guard: guard.map(|(if_, guard)| (if_, Box::new(guard))), - body: Box::new(body.0), - comma: body.1, - }) - )); - - fn description() -> Option<&'static str> { - Some("`match` arm") - } - } - - #[cfg(feature = "full")] - named!(expr_closure(allow_struct: bool) -> Expr, do_parse!( - begin: call!(verbatim::grab_cursor) >> - attrs: many0!(Attribute::parse_outer) >> - asyncness: option!(keyword!(async)) >> - movability: option!(cond_reduce!(asyncness.is_none(), keyword!(static))) >> - capture: option!(keyword!(move)) >> - or1: punct!(|) >> - inputs: call!(Punctuated::parse_terminated_with, fn_arg) >> - or2: punct!(|) >> - ret_and_body: alt!( - do_parse!( - arrow: punct!(->) >> - ty: syn!(Type) >> - body: syn!(Block) >> - ( - ReturnType::Type(arrow, Box::new(ty)), - Expr::Block(ExprBlock { - attrs: Vec::new(), - block: body, - }, - )) - ) - | - map!(ambiguous_expr!(allow_struct), |e| (ReturnType::Default, e)) - ) >> - end: call!(verbatim::grab_cursor) >> - ({ - if asyncness.is_some() { - // TODO: include asyncness in ExprClosure - // https://github.com/dtolnay/syn/issues/396 - Expr::Verbatim(ExprVerbatim { - tts: verbatim::token_range(begin..end), - }) - } else { - Expr::Closure(ExprClosure { - attrs: attrs, - movability: movability, - capture: capture, - or1_token: or1, - inputs: inputs, - or2_token: or2, - output: ret_and_body.0, - body: Box::new(ret_and_body.1), - }) - } - }) - )); - - #[cfg(feature = "full")] - named!(unstable_async_block -> ExprVerbatim, do_parse!( - begin: call!(verbatim::grab_cursor) >> - many0!(Attribute::parse_outer) >> - keyword!(async) >> - option!(keyword!(move)) >> - syn!(Block) >> - end: call!(verbatim::grab_cursor) >> - (ExprVerbatim { - tts: verbatim::token_range(begin..end), - }) - )); - - #[cfg(feature = "full")] - named!(fn_arg -> FnArg, do_parse!( - pat: syn!(Pat) >> - ty: option!(tuple!(punct!(:), syn!(Type))) >> - ({ - if let Some((colon, ty)) = ty { - FnArg::Captured(ArgCaptured { - pat: pat, - colon_token: colon, - ty: ty, - }) - } else { - FnArg::Inferred(pat) - } - }) - )); - - #[cfg(feature = "full")] - impl Synom for ExprWhile { - named!(parse -> Self, do_parse!( - outer_attrs: many0!(Attribute::parse_outer) >> - label: option!(syn!(Label)) >> - while_: keyword!(while) >> - cond: expr_no_struct >> - block: braces!(tuple!( - many0!(Attribute::parse_inner), - call!(Block::parse_within), - )) >> - (ExprWhile { - attrs: { - let mut attrs = outer_attrs; - attrs.extend((block.1).0); - attrs - }, - label: label, - while_token: while_, - cond: Box::new(cond), - body: Block { - brace_token: block.0, - stmts: (block.1).1, - }, - }) - )); - - fn description() -> Option<&'static str> { - Some("`while` expression") - } - } - - #[cfg(feature = "full")] - impl Synom for ExprWhileLet { - named!(parse -> Self, do_parse!( - outer_attrs: many0!(Attribute::parse_outer) >> - label: option!(syn!(Label)) >> - while_: keyword!(while) >> - let_: keyword!(let) >> - pats: call!(Punctuated::parse_separated_nonempty) >> - eq: punct!(=) >> - value: expr_no_struct >> - block: braces!(tuple!( - many0!(Attribute::parse_inner), - call!(Block::parse_within), - )) >> - (ExprWhileLet { - attrs: { - let mut attrs = outer_attrs; - attrs.extend((block.1).0); - attrs - }, - label: label, - while_token: while_, - let_token: let_, - pats: pats, - eq_token: eq, - expr: Box::new(value), - body: Block { - brace_token: block.0, - stmts: (block.1).1, - }, - }) - )); - - fn description() -> Option<&'static str> { - Some("`while let` expression") - } - } - - #[cfg(feature = "full")] - impl Synom for Label { - named!(parse -> Self, do_parse!( - name: syn!(Lifetime) >> - colon: punct!(:) >> - (Label { - name: name, - colon_token: colon, - }) - )); - - fn description() -> Option<&'static str> { - Some("`while let` expression") - } - } - - #[cfg(feature = "full")] - impl Synom for ExprContinue { - named!(parse -> Self, do_parse!( - attrs: many0!(Attribute::parse_outer) >> - cont: keyword!(continue) >> - label: option!(syn!(Lifetime)) >> - (ExprContinue { - attrs: attrs, - continue_token: cont, - label: label, - }) - )); - - fn description() -> Option<&'static str> { - Some("`continue`") - } - } - - #[cfg(feature = "full")] - named!(expr_break(allow_struct: bool) -> Expr, do_parse!( - attrs: many0!(Attribute::parse_outer) >> - break_: keyword!(break) >> - label: option!(syn!(Lifetime)) >> - // We can't allow blocks after a `break` expression when we wouldn't - // allow structs, as this expression is ambiguous. - val: opt_ambiguous_expr!(allow_struct) >> - (ExprBreak { - attrs: attrs, - label: label, - expr: val.map(Box::new), - break_token: break_, - }.into()) - )); - - #[cfg(feature = "full")] - named!(expr_ret(allow_struct: bool) -> Expr, do_parse!( - attrs: many0!(Attribute::parse_outer) >> - return_: keyword!(return) >> - // NOTE: return is greedy and eats blocks after it even when in a - // position where structs are not allowed, such as in if statement - // conditions. For example: - // - // if return { println!("A") } {} // Prints "A" - ret_value: option!(ambiguous_expr!(allow_struct)) >> - (ExprReturn { - attrs: attrs, - expr: ret_value.map(Box::new), - return_token: return_, - }.into()) - )); - - #[cfg(feature = "full")] - impl Synom for ExprStruct { - named!(parse -> Self, do_parse!( - outer_attrs: many0!(Attribute::parse_outer) >> - path: syn!(Path) >> - data: braces!(do_parse!( - inner_attrs: many0!(Attribute::parse_inner) >> - fields: call!(Punctuated::parse_terminated) >> - base: option!(cond!(fields.empty_or_trailing(), do_parse!( - dots: punct!(..) >> - base: syn!(Expr) >> - (dots, base) - ))) >> - (inner_attrs, fields, base) - )) >> - ({ - let (brace, (inner_attrs, fields, base)) = data; - let (dots, rest) = match base.and_then(|b| b) { - Some((dots, base)) => (Some(dots), Some(base)), - None => (None, None), - }; - ExprStruct { - attrs: { - let mut attrs = outer_attrs; - attrs.extend(inner_attrs); - attrs - }, - brace_token: brace, - path: path, - fields: fields, - dot2_token: dots, - rest: rest.map(Box::new), - } - }) - )); - - fn description() -> Option<&'static str> { - Some("struct literal expression") - } - } - - #[cfg(feature = "full")] - impl Synom for FieldValue { - named!(parse -> Self, do_parse!( - attrs: many0!(Attribute::parse_outer) >> - field_value: alt!( - tuple!(syn!(Member), map!(punct!(:), Some), syn!(Expr)) - | - map!(syn!(Ident), |name| ( - Member::Named(name.clone()), - None, - Expr::Path(ExprPath { - attrs: Vec::new(), - qself: None, - path: name.into(), - }), - )) - ) >> - (FieldValue { - attrs: attrs, - member: field_value.0, - colon_token: field_value.1, - expr: field_value.2, - }) - )); - - fn description() -> Option<&'static str> { - Some("field-value pair: `field: value`") - } - } - - #[cfg(feature = "full")] - impl Synom for ExprRepeat { - named!(parse -> Self, do_parse!( - outer_attrs: many0!(Attribute::parse_outer) >> - data: brackets!(tuple!( - many0!(Attribute::parse_inner), - syn!(Expr), - punct!(;), - syn!(Expr), - )) >> - (ExprRepeat { - attrs: { - let mut attrs = outer_attrs; - attrs.extend((data.1).0); - attrs - }, - expr: Box::new((data.1).1), - len: Box::new((data.1).3), - bracket_token: data.0, - semi_token: (data.1).2, - }) - )); - - fn description() -> Option<&'static str> { - Some("repeated array literal: `[val; N]`") - } - } - - #[cfg(feature = "full")] - impl Synom for ExprUnsafe { - named!(parse -> Self, do_parse!( - unsafe_: keyword!(unsafe) >> - b: syn!(Block) >> - (ExprUnsafe { - attrs: Vec::new(), - unsafe_token: unsafe_, - block: b, - }) - )); - - fn description() -> Option<&'static str> { - Some("unsafe block: `unsafe { .. }`") - } - } - - #[cfg(feature = "full")] - impl Synom for ExprBlock { - named!(parse -> Self, do_parse!( - outer_attrs: many0!(Attribute::parse_outer) >> - block: braces!(tuple!( - many0!(Attribute::parse_inner), - call!(Block::parse_within), - )) >> - (ExprBlock { - attrs: { - let mut attrs = outer_attrs; - attrs.extend((block.1).0); - attrs - }, - block: Block { - brace_token: block.0, - stmts: (block.1).1, - }, - }) - )); - - fn description() -> Option<&'static str> { - Some("block: `{ .. }`") - } - } - - #[cfg(feature = "full")] - named!(unstable_labeled_block -> ExprVerbatim, do_parse!( - begin: call!(verbatim::grab_cursor) >> - many0!(Attribute::parse_outer) >> - syn!(Label) >> - braces!(tuple!( - many0!(Attribute::parse_inner), - call!(Block::parse_within), - )) >> - end: call!(verbatim::grab_cursor) >> - (ExprVerbatim { - tts: verbatim::token_range(begin..end), - }) - )); - - #[cfg(feature = "full")] - named!(expr_range(allow_struct: bool) -> Expr, do_parse!( - limits: syn!(RangeLimits) >> - hi: opt_ambiguous_expr!(allow_struct) >> - (ExprRange { - attrs: Vec::new(), - from: None, - to: hi.map(Box::new), - limits: limits, - }.into()) - )); - - #[cfg(feature = "full")] - impl Synom for RangeLimits { - named!(parse -> Self, alt!( - // Must come before Dot2 - punct!(..=) => { RangeLimits::Closed } - | - // Must come before Dot2 - punct!(...) => { |dot3| RangeLimits::Closed(Token![..=](dot3.0)) } - | - punct!(..) => { RangeLimits::HalfOpen } - )); - - fn description() -> Option<&'static str> { - Some("range limit: `..`, `...` or `..=`") - } - } - - impl Synom for ExprPath { - #[cfg(not(feature = "full"))] - named!(parse -> Self, do_parse!( - pair: qpath >> - (ExprPath { - attrs: Vec::new(), - qself: pair.0, - path: pair.1, - }) - )); - - #[cfg(feature = "full")] - named!(parse -> Self, do_parse!( - attrs: many0!(Attribute::parse_outer) >> - pair: qpath >> - (ExprPath { - attrs: attrs, - qself: pair.0, - path: pair.1, - }) - )); - - fn description() -> Option<&'static str> { - Some("path: `a::b::c`") - } - } - - named!(and_field -> (Token![.], Member), tuple!(punct!(.), syn!(Member))); - - named!(and_index -> (token::Bracket, Expr), brackets!(syn!(Expr))); - - #[cfg(feature = "full")] - impl Synom for Block { - named!(parse -> Self, do_parse!( - stmts: braces!(Block::parse_within) >> - (Block { - brace_token: stmts.0, - stmts: stmts.1, - }) - )); - - fn description() -> Option<&'static str> { - Some("block: `{ .. }`") - } - } - - #[cfg(feature = "full")] - impl Block { - named!(pub parse_within -> Vec, do_parse!( - many0!(punct!(;)) >> - mut standalone: many0!(do_parse!( - stmt: syn!(Stmt) >> - many0!(punct!(;)) >> - (stmt) - )) >> - last: option!(do_parse!( - attrs: many0!(Attribute::parse_outer) >> - mut e: syn!(Expr) >> - ({ - e.replace_attrs(attrs); - Stmt::Expr(e) - }) - )) >> - (match last { - None => standalone, - Some(last) => { - standalone.push(last); - standalone - } - }) - )); - } - - #[cfg(feature = "full")] - impl Synom for Stmt { - named!(parse -> Self, alt!( - stmt_mac - | - stmt_local - | - stmt_item - | - stmt_blockexpr - | - stmt_expr - )); - - fn description() -> Option<&'static str> { - Some("statement") - } - } - - #[cfg(feature = "full")] - named!(stmt_mac -> Stmt, do_parse!( - attrs: many0!(Attribute::parse_outer) >> - what: call!(Path::parse_mod_style) >> - bang: punct!(!) >> - // Only parse braces here; paren and bracket will get parsed as - // expression statements - data: braces!(syn!(TokenStream)) >> - semi: option!(punct!(;)) >> - (Stmt::Item(Item::Macro(ItemMacro { - attrs: attrs, - ident: None, - mac: Macro { - path: what, - bang_token: bang, - delimiter: MacroDelimiter::Brace(data.0), - tts: data.1, - }, - semi_token: semi, - }))) - )); - - #[cfg(feature = "full")] - named!(stmt_local -> Stmt, do_parse!( - attrs: many0!(Attribute::parse_outer) >> - let_: keyword!(let) >> - pats: call!(Punctuated::parse_separated_nonempty) >> - ty: option!(tuple!(punct!(:), syn!(Type))) >> - init: option!(tuple!(punct!(=), syn!(Expr))) >> - semi: punct!(;) >> - (Stmt::Local(Local { - attrs: attrs, - let_token: let_, - pats: pats, - ty: ty.map(|(colon, ty)| (colon, Box::new(ty))), - init: init.map(|(eq, expr)| (eq, Box::new(expr))), - semi_token: semi, - })) - )); - - #[cfg(feature = "full")] - named!(stmt_item -> Stmt, map!(syn!(Item), |i| Stmt::Item(i))); - - #[cfg(feature = "full")] - named!(stmt_blockexpr -> Stmt, do_parse!( - mut attrs: many0!(Attribute::parse_outer) >> - mut e: expr_nosemi >> - semi: option!(punct!(;)) >> - ({ - attrs.extend(e.replace_attrs(Vec::new())); - e.replace_attrs(attrs); - if let Some(semi) = semi { - Stmt::Semi(e, semi) - } else { - Stmt::Expr(e) - } - }) - )); - - #[cfg(feature = "full")] - named!(stmt_expr -> Stmt, do_parse!( - mut attrs: many0!(Attribute::parse_outer) >> - mut e: syn!(Expr) >> - semi: punct!(;) >> - ({ - attrs.extend(e.replace_attrs(Vec::new())); - e.replace_attrs(attrs); - Stmt::Semi(e, semi) - }) - )); - - #[cfg(feature = "full")] - impl Synom for Pat { - named!(parse -> Self, alt!( - syn!(PatWild) => { Pat::Wild } // must be before pat_ident - | - syn!(PatBox) => { Pat::Box } // must be before pat_ident - | - syn!(PatRange) => { Pat::Range } // must be before pat_lit - | - syn!(PatTupleStruct) => { Pat::TupleStruct } // must be before pat_ident - | - syn!(PatStruct) => { Pat::Struct } // must be before pat_ident - | - syn!(PatMacro) => { Pat::Macro } // must be before pat_ident - | - syn!(PatLit) => { Pat::Lit } // must be before pat_ident - | - syn!(PatIdent) => { Pat::Ident } // must be before pat_path - | - syn!(PatPath) => { Pat::Path } - | - syn!(PatTuple) => { Pat::Tuple } - | - syn!(PatRef) => { Pat::Ref } - | - syn!(PatSlice) => { Pat::Slice } - )); - - fn description() -> Option<&'static str> { - Some("pattern") - } - } - - #[cfg(feature = "full")] - impl Synom for PatWild { - named!(parse -> Self, map!( - punct!(_), - |u| PatWild { underscore_token: u } - )); - - fn description() -> Option<&'static str> { - Some("wild pattern: `_`") - } - } - - #[cfg(feature = "full")] - impl Synom for PatBox { - named!(parse -> Self, do_parse!( - boxed: keyword!(box) >> - pat: syn!(Pat) >> - (PatBox { - pat: Box::new(pat), - box_token: boxed, - }) - )); - - fn description() -> Option<&'static str> { - Some("box pattern") - } - } - - #[cfg(feature = "full")] - impl Synom for PatIdent { - named!(parse -> Self, do_parse!( - by_ref: option!(keyword!(ref)) >> - mutability: option!(keyword!(mut)) >> - name: alt!( - syn!(Ident) - | - keyword!(self) => { Into::into } - ) >> - not!(punct!(<)) >> - not!(punct!(::)) >> - subpat: option!(tuple!(punct!(@), syn!(Pat))) >> - (PatIdent { - by_ref: by_ref, - mutability: mutability, - ident: name, - subpat: subpat.map(|(at, pat)| (at, Box::new(pat))), - }) - )); - - fn description() -> Option<&'static str> { - Some("pattern identifier binding") - } - } - - #[cfg(feature = "full")] - impl Synom for PatTupleStruct { - named!(parse -> Self, do_parse!( - path: syn!(Path) >> - tuple: syn!(PatTuple) >> - (PatTupleStruct { - path: path, - pat: tuple, - }) - )); - - fn description() -> Option<&'static str> { - Some("tuple struct pattern") - } - } - - #[cfg(feature = "full")] - impl Synom for PatStruct { - named!(parse -> Self, do_parse!( - path: syn!(Path) >> - data: braces!(do_parse!( - fields: call!(Punctuated::parse_terminated) >> - base: option!(cond!(fields.empty_or_trailing(), punct!(..))) >> - (fields, base) - )) >> - (PatStruct { - path: path, - fields: (data.1).0, - brace_token: data.0, - dot2_token: (data.1).1.and_then(|m| m), - }) - )); - - fn description() -> Option<&'static str> { - Some("struct pattern") - } - } - - #[cfg(feature = "full")] - impl Synom for FieldPat { - named!(parse -> Self, alt!( - do_parse!( - member: syn!(Member) >> - colon: punct!(:) >> - pat: syn!(Pat) >> - (FieldPat { - member: member, - pat: Box::new(pat), - attrs: Vec::new(), - colon_token: Some(colon), - }) - ) - | - do_parse!( - boxed: option!(keyword!(box)) >> - by_ref: option!(keyword!(ref)) >> - mutability: option!(keyword!(mut)) >> - ident: syn!(Ident) >> - ({ - let mut pat: Pat = PatIdent { - by_ref: by_ref, - mutability: mutability, - ident: ident.clone(), - subpat: None, - }.into(); - if let Some(boxed) = boxed { - pat = PatBox { - pat: Box::new(pat), - box_token: boxed, - }.into(); - } - FieldPat { - member: Member::Named(ident), - pat: Box::new(pat), - attrs: Vec::new(), - colon_token: None, - } - }) - ) - )); - - fn description() -> Option<&'static str> { - Some("field pattern") - } - } - - impl Synom for Member { - named!(parse -> Self, alt!( - syn!(Ident) => { Member::Named } - | - syn!(Index) => { Member::Unnamed } - )); - - fn description() -> Option<&'static str> { - Some("field member") - } - } - - impl Synom for Index { - named!(parse -> Self, do_parse!( - lit: syn!(LitInt) >> - ({ - if let IntSuffix::None = lit.suffix() { - Index { index: lit.value() as u32, span: lit.span() } - } else { - return parse_error(); - } - }) - )); - - fn description() -> Option<&'static str> { - Some("field index") - } - } - - #[cfg(feature = "full")] - impl Synom for PatPath { - named!(parse -> Self, map!( - syn!(ExprPath), - |p| PatPath { qself: p.qself, path: p.path } - )); - - fn description() -> Option<&'static str> { - Some("path pattern") - } - } - - #[cfg(feature = "full")] - impl Synom for PatTuple { - named!(parse -> Self, do_parse!( - data: parens!(do_parse!( - front: call!(Punctuated::parse_terminated) >> - dotdot: option!(cond_reduce!(front.empty_or_trailing(), - tuple!(punct!(..), option!(punct!(,))) - )) >> - back: cond!(match dotdot { - Some((_, Some(_))) => true, - _ => false, - }, - Punctuated::parse_terminated) >> - (front, dotdot, back) - )) >> - ({ - let (parens, (front, dotdot, back)) = data; - let (dotdot, trailing) = match dotdot { - Some((a, b)) => (Some(a), Some(b)), - None => (None, None), - }; - PatTuple { - paren_token: parens, - front: front, - dot2_token: dotdot, - comma_token: trailing.unwrap_or_default(), - back: back.unwrap_or_default(), - } - }) - )); - - fn description() -> Option<&'static str> { - Some("tuple pattern") - } - } - - #[cfg(feature = "full")] - impl Synom for PatRef { - named!(parse -> Self, do_parse!( - and: punct!(&) >> - mutability: option!(keyword!(mut)) >> - pat: syn!(Pat) >> - (PatRef { - pat: Box::new(pat), - mutability: mutability, - and_token: and, - }) - )); - - fn description() -> Option<&'static str> { - Some("reference pattern") - } - } - - #[cfg(feature = "full")] - impl Synom for PatLit { - named!(parse -> Self, do_parse!( - lit: pat_lit_expr >> - (if let Expr::Path(_) = lit { - return parse_error(); // these need to be parsed by pat_path - } else { - PatLit { - expr: Box::new(lit), - } - }) - )); - - fn description() -> Option<&'static str> { - Some("literal pattern") - } - } - - #[cfg(feature = "full")] - impl Synom for PatRange { - named!(parse -> Self, do_parse!( - lo: pat_lit_expr >> - limits: syn!(RangeLimits) >> - hi: pat_lit_expr >> - (PatRange { - lo: Box::new(lo), - hi: Box::new(hi), - limits: limits, - }) - )); - - fn description() -> Option<&'static str> { - Some("range pattern") - } - } - - #[cfg(feature = "full")] - named!(pat_lit_expr -> Expr, do_parse!( - neg: option!(punct!(-)) >> - v: alt!( - syn!(ExprLit) => { Expr::Lit } - | - syn!(ExprPath) => { Expr::Path } - ) >> - (if let Some(neg) = neg { - Expr::Unary(ExprUnary { - attrs: Vec::new(), - op: UnOp::Neg(neg), - expr: Box::new(v) - }) - } else { - v - }) - )); - - #[cfg(feature = "full")] - impl Synom for PatSlice { - named!(parse -> Self, map!( - brackets!(do_parse!( - before: call!(Punctuated::parse_terminated) >> - middle: option!(do_parse!( - dots: punct!(..) >> - trailing: option!(punct!(,)) >> - (dots, trailing) - )) >> - after: cond!( - match middle { - Some((_, ref trailing)) => trailing.is_some(), - _ => false, - }, - Punctuated::parse_terminated - ) >> - (before, middle, after) - )), - |(brackets, (before, middle, after))| { - let mut before: Punctuated = before; - let after: Option> = after; - let middle: Option<(Token![..], Option)> = middle; - PatSlice { - dot2_token: middle.as_ref().map(|m| Token![..]((m.0).0)), - comma_token: middle.as_ref().and_then(|m| { - m.1.as_ref().map(|m| Token![,](m.0)) - }), - bracket_token: brackets, - middle: middle.and_then(|_| { - if before.empty_or_trailing() { - None - } else { - Some(Box::new(before.pop().unwrap().into_value())) - } - }), - front: before, - back: after.unwrap_or_default(), - } - } - )); - - fn description() -> Option<&'static str> { - Some("slice pattern") - } - } - - #[cfg(feature = "full")] - impl Synom for PatMacro { - named!(parse -> Self, map!(syn!(Macro), |mac| PatMacro { mac: mac })); - - fn description() -> Option<&'static str> { - Some("macro pattern") - } - } -} - -#[cfg(feature = "printing")] -mod printing { - use super::*; - #[cfg(feature = "full")] - use attr::FilterAttrs; - use proc_macro2::{Literal, TokenStream}; - use quote::{ToTokens, TokenStreamExt}; - - // If the given expression is a bare `ExprStruct`, wraps it in parenthesis - // before appending it to `TokenStream`. - #[cfg(feature = "full")] - fn wrap_bare_struct(tokens: &mut TokenStream, e: &Expr) { - if let Expr::Struct(_) = *e { - token::Paren::default().surround(tokens, |tokens| { - e.to_tokens(tokens); - }); - } else { - e.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - fn outer_attrs_to_tokens(attrs: &[Attribute], tokens: &mut TokenStream) { - tokens.append_all(attrs.outer()); - } - - #[cfg(feature = "full")] - fn inner_attrs_to_tokens(attrs: &[Attribute], tokens: &mut TokenStream) { - tokens.append_all(attrs.inner()); - } - - #[cfg(not(feature = "full"))] - fn outer_attrs_to_tokens(_attrs: &[Attribute], _tokens: &mut TokenStream) {} - - #[cfg(not(feature = "full"))] - fn inner_attrs_to_tokens(_attrs: &[Attribute], _tokens: &mut TokenStream) {} - - #[cfg(feature = "full")] - impl ToTokens for ExprBox { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.box_token.to_tokens(tokens); - self.expr.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprInPlace { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.place.to_tokens(tokens); - self.arrow_token.to_tokens(tokens); - self.value.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprArray { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.bracket_token.surround(tokens, |tokens| { - inner_attrs_to_tokens(&self.attrs, tokens); - self.elems.to_tokens(tokens); - }) - } - } - - impl ToTokens for ExprCall { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.func.to_tokens(tokens); - self.paren_token.surround(tokens, |tokens| { - self.args.to_tokens(tokens); - }) - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprMethodCall { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.receiver.to_tokens(tokens); - self.dot_token.to_tokens(tokens); - self.method.to_tokens(tokens); - self.turbofish.to_tokens(tokens); - self.paren_token.surround(tokens, |tokens| { - self.args.to_tokens(tokens); - }); - } - } - - #[cfg(feature = "full")] - impl ToTokens for MethodTurbofish { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.colon2_token.to_tokens(tokens); - self.lt_token.to_tokens(tokens); - self.args.to_tokens(tokens); - self.gt_token.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for GenericMethodArgument { - fn to_tokens(&self, tokens: &mut TokenStream) { - match *self { - GenericMethodArgument::Type(ref t) => t.to_tokens(tokens), - GenericMethodArgument::Const(ref c) => c.to_tokens(tokens), - } - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprTuple { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.paren_token.surround(tokens, |tokens| { - inner_attrs_to_tokens(&self.attrs, tokens); - self.elems.to_tokens(tokens); - // If we only have one argument, we need a trailing comma to - // distinguish ExprTuple from ExprParen. - if self.elems.len() == 1 && !self.elems.trailing_punct() { - ::default().to_tokens(tokens); - } - }) - } - } - - impl ToTokens for ExprBinary { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.left.to_tokens(tokens); - self.op.to_tokens(tokens); - self.right.to_tokens(tokens); - } - } - - impl ToTokens for ExprUnary { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.op.to_tokens(tokens); - self.expr.to_tokens(tokens); - } - } - - impl ToTokens for ExprLit { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.lit.to_tokens(tokens); - } - } - - impl ToTokens for ExprCast { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.expr.to_tokens(tokens); - self.as_token.to_tokens(tokens); - self.ty.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprType { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.expr.to_tokens(tokens); - self.colon_token.to_tokens(tokens); - self.ty.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - fn maybe_wrap_else(tokens: &mut TokenStream, else_: &Option<(Token![else], Box)>) { - if let Some((ref else_token, ref else_)) = *else_ { - else_token.to_tokens(tokens); - - // If we are not one of the valid expressions to exist in an else - // clause, wrap ourselves in a block. - match **else_ { - Expr::If(_) | Expr::IfLet(_) | Expr::Block(_) => { - else_.to_tokens(tokens); - } - _ => { - token::Brace::default().surround(tokens, |tokens| { - else_.to_tokens(tokens); - }); - } - } - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprIf { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.if_token.to_tokens(tokens); - wrap_bare_struct(tokens, &self.cond); - self.then_branch.to_tokens(tokens); - maybe_wrap_else(tokens, &self.else_branch); - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprIfLet { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.if_token.to_tokens(tokens); - self.let_token.to_tokens(tokens); - self.pats.to_tokens(tokens); - self.eq_token.to_tokens(tokens); - wrap_bare_struct(tokens, &self.expr); - self.then_branch.to_tokens(tokens); - maybe_wrap_else(tokens, &self.else_branch); - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprWhile { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.label.to_tokens(tokens); - self.while_token.to_tokens(tokens); - wrap_bare_struct(tokens, &self.cond); - self.body.brace_token.surround(tokens, |tokens| { - inner_attrs_to_tokens(&self.attrs, tokens); - tokens.append_all(&self.body.stmts); - }); - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprWhileLet { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.label.to_tokens(tokens); - self.while_token.to_tokens(tokens); - self.let_token.to_tokens(tokens); - self.pats.to_tokens(tokens); - self.eq_token.to_tokens(tokens); - wrap_bare_struct(tokens, &self.expr); - self.body.brace_token.surround(tokens, |tokens| { - inner_attrs_to_tokens(&self.attrs, tokens); - tokens.append_all(&self.body.stmts); - }); - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprForLoop { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.label.to_tokens(tokens); - self.for_token.to_tokens(tokens); - self.pat.to_tokens(tokens); - self.in_token.to_tokens(tokens); - wrap_bare_struct(tokens, &self.expr); - self.body.brace_token.surround(tokens, |tokens| { - inner_attrs_to_tokens(&self.attrs, tokens); - tokens.append_all(&self.body.stmts); - }); - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprLoop { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.label.to_tokens(tokens); - self.loop_token.to_tokens(tokens); - self.body.brace_token.surround(tokens, |tokens| { - inner_attrs_to_tokens(&self.attrs, tokens); - tokens.append_all(&self.body.stmts); - }); - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprMatch { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.match_token.to_tokens(tokens); - wrap_bare_struct(tokens, &self.expr); - self.brace_token.surround(tokens, |tokens| { - inner_attrs_to_tokens(&self.attrs, tokens); - for (i, arm) in self.arms.iter().enumerate() { - arm.to_tokens(tokens); - // Ensure that we have a comma after a non-block arm, except - // for the last one. - let is_last = i == self.arms.len() - 1; - if !is_last && arm_expr_requires_comma(&arm.body) && arm.comma.is_none() { - ::default().to_tokens(tokens); - } - } - }); - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprCatch { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.do_token.to_tokens(tokens); - self.catch_token.to_tokens(tokens); - self.block.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprYield { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.yield_token.to_tokens(tokens); - self.expr.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprClosure { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.movability.to_tokens(tokens); - self.capture.to_tokens(tokens); - self.or1_token.to_tokens(tokens); - for input in self.inputs.pairs() { - match **input.value() { - FnArg::Captured(ArgCaptured { - ref pat, - ty: Type::Infer(_), - .. - }) => { - pat.to_tokens(tokens); - } - _ => input.value().to_tokens(tokens), - } - input.punct().to_tokens(tokens); - } - self.or2_token.to_tokens(tokens); - self.output.to_tokens(tokens); - self.body.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprUnsafe { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.unsafe_token.to_tokens(tokens); - self.block.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprBlock { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.block.brace_token.surround(tokens, |tokens| { - inner_attrs_to_tokens(&self.attrs, tokens); - tokens.append_all(&self.block.stmts); - }); - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprAssign { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.left.to_tokens(tokens); - self.eq_token.to_tokens(tokens); - self.right.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprAssignOp { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.left.to_tokens(tokens); - self.op.to_tokens(tokens); - self.right.to_tokens(tokens); - } - } - - impl ToTokens for ExprField { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.base.to_tokens(tokens); - self.dot_token.to_tokens(tokens); - self.member.to_tokens(tokens); - } - } - - impl ToTokens for Member { - fn to_tokens(&self, tokens: &mut TokenStream) { - match *self { - Member::Named(ref ident) => ident.to_tokens(tokens), - Member::Unnamed(ref index) => index.to_tokens(tokens), - } - } - } - - impl ToTokens for Index { - fn to_tokens(&self, tokens: &mut TokenStream) { - let mut lit = Literal::i64_unsuffixed(i64::from(self.index)); - lit.set_span(self.span); - tokens.append(lit); - } - } - - impl ToTokens for ExprIndex { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.expr.to_tokens(tokens); - self.bracket_token.surround(tokens, |tokens| { - self.index.to_tokens(tokens); - }); - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprRange { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.from.to_tokens(tokens); - match self.limits { - RangeLimits::HalfOpen(ref t) => t.to_tokens(tokens), - RangeLimits::Closed(ref t) => t.to_tokens(tokens), - } - self.to.to_tokens(tokens); - } - } - - impl ToTokens for ExprPath { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - ::PathTokens(&self.qself, &self.path).to_tokens(tokens) - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprReference { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.and_token.to_tokens(tokens); - self.mutability.to_tokens(tokens); - self.expr.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprBreak { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.break_token.to_tokens(tokens); - self.label.to_tokens(tokens); - self.expr.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprContinue { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.continue_token.to_tokens(tokens); - self.label.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprReturn { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.return_token.to_tokens(tokens); - self.expr.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprMacro { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.mac.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprStruct { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.path.to_tokens(tokens); - self.brace_token.surround(tokens, |tokens| { - inner_attrs_to_tokens(&self.attrs, tokens); - self.fields.to_tokens(tokens); - if self.rest.is_some() { - TokensOrDefault(&self.dot2_token).to_tokens(tokens); - self.rest.to_tokens(tokens); - } - }) - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprRepeat { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.bracket_token.surround(tokens, |tokens| { - inner_attrs_to_tokens(&self.attrs, tokens); - self.expr.to_tokens(tokens); - self.semi_token.to_tokens(tokens); - self.len.to_tokens(tokens); - }) - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprGroup { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.group_token.surround(tokens, |tokens| { - self.expr.to_tokens(tokens); - }); - } - } - - impl ToTokens for ExprParen { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.paren_token.surround(tokens, |tokens| { - inner_attrs_to_tokens(&self.attrs, tokens); - self.expr.to_tokens(tokens); - }); - } - } - - #[cfg(feature = "full")] - impl ToTokens for ExprTry { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.expr.to_tokens(tokens); - self.question_token.to_tokens(tokens); - } - } - - impl ToTokens for ExprVerbatim { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.tts.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for Label { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.name.to_tokens(tokens); - self.colon_token.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for FieldValue { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.member.to_tokens(tokens); - if let Some(ref colon_token) = self.colon_token { - colon_token.to_tokens(tokens); - self.expr.to_tokens(tokens); - } - } - } - - #[cfg(feature = "full")] - impl ToTokens for Arm { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(&self.attrs); - self.leading_vert.to_tokens(tokens); - self.pats.to_tokens(tokens); - if let Some((ref if_token, ref guard)) = self.guard { - if_token.to_tokens(tokens); - guard.to_tokens(tokens); - } - self.fat_arrow_token.to_tokens(tokens); - self.body.to_tokens(tokens); - self.comma.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for PatWild { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.underscore_token.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for PatIdent { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.by_ref.to_tokens(tokens); - self.mutability.to_tokens(tokens); - self.ident.to_tokens(tokens); - if let Some((ref at_token, ref subpat)) = self.subpat { - at_token.to_tokens(tokens); - subpat.to_tokens(tokens); - } - } - } - - #[cfg(feature = "full")] - impl ToTokens for PatStruct { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.path.to_tokens(tokens); - self.brace_token.surround(tokens, |tokens| { - self.fields.to_tokens(tokens); - // NOTE: We need a comma before the dot2 token if it is present. - if !self.fields.empty_or_trailing() && self.dot2_token.is_some() { - ::default().to_tokens(tokens); - } - self.dot2_token.to_tokens(tokens); - }); - } - } - - #[cfg(feature = "full")] - impl ToTokens for PatTupleStruct { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.path.to_tokens(tokens); - self.pat.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for PatPath { - fn to_tokens(&self, tokens: &mut TokenStream) { - ::PathTokens(&self.qself, &self.path).to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for PatTuple { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.paren_token.surround(tokens, |tokens| { - self.front.to_tokens(tokens); - if let Some(ref dot2_token) = self.dot2_token { - if !self.front.empty_or_trailing() { - // Ensure there is a comma before the .. token. - ::default().to_tokens(tokens); - } - dot2_token.to_tokens(tokens); - self.comma_token.to_tokens(tokens); - if self.comma_token.is_none() && !self.back.is_empty() { - // Ensure there is a comma after the .. token. - ::default().to_tokens(tokens); - } - } - self.back.to_tokens(tokens); - }); - } - } - - #[cfg(feature = "full")] - impl ToTokens for PatBox { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.box_token.to_tokens(tokens); - self.pat.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for PatRef { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.and_token.to_tokens(tokens); - self.mutability.to_tokens(tokens); - self.pat.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for PatLit { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.expr.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for PatRange { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.lo.to_tokens(tokens); - match self.limits { - RangeLimits::HalfOpen(ref t) => t.to_tokens(tokens), - RangeLimits::Closed(ref t) => Token![...](t.0).to_tokens(tokens), - } - self.hi.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for PatSlice { - fn to_tokens(&self, tokens: &mut TokenStream) { - // XXX: This is a mess, and it will be so easy to screw it up. How - // do we make this correct itself better? - self.bracket_token.surround(tokens, |tokens| { - self.front.to_tokens(tokens); - - // If we need a comma before the middle or standalone .. token, - // then make sure it's present. - if !self.front.empty_or_trailing() - && (self.middle.is_some() || self.dot2_token.is_some()) - { - ::default().to_tokens(tokens); - } - - // If we have an identifier, we always need a .. token. - if self.middle.is_some() { - self.middle.to_tokens(tokens); - TokensOrDefault(&self.dot2_token).to_tokens(tokens); - } else if self.dot2_token.is_some() { - self.dot2_token.to_tokens(tokens); - } - - // Make sure we have a comma before the back half. - if !self.back.is_empty() { - TokensOrDefault(&self.comma_token).to_tokens(tokens); - self.back.to_tokens(tokens); - } else { - self.comma_token.to_tokens(tokens); - } - }) - } - } - - #[cfg(feature = "full")] - impl ToTokens for PatMacro { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.mac.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for PatVerbatim { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.tts.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for FieldPat { - fn to_tokens(&self, tokens: &mut TokenStream) { - if let Some(ref colon_token) = self.colon_token { - self.member.to_tokens(tokens); - colon_token.to_tokens(tokens); - } - self.pat.to_tokens(tokens); - } - } - - #[cfg(feature = "full")] - impl ToTokens for Block { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.brace_token.surround(tokens, |tokens| { - tokens.append_all(&self.stmts); - }); - } - } - - #[cfg(feature = "full")] - impl ToTokens for Stmt { - fn to_tokens(&self, tokens: &mut TokenStream) { - match *self { - Stmt::Local(ref local) => local.to_tokens(tokens), - Stmt::Item(ref item) => item.to_tokens(tokens), - Stmt::Expr(ref expr) => expr.to_tokens(tokens), - Stmt::Semi(ref expr, ref semi) => { - expr.to_tokens(tokens); - semi.to_tokens(tokens); - } - } - } - } - - #[cfg(feature = "full")] - impl ToTokens for Local { - fn to_tokens(&self, tokens: &mut TokenStream) { - outer_attrs_to_tokens(&self.attrs, tokens); - self.let_token.to_tokens(tokens); - self.pats.to_tokens(tokens); - if let Some((ref colon_token, ref ty)) = self.ty { - colon_token.to_tokens(tokens); - ty.to_tokens(tokens); - } - if let Some((ref eq_token, ref init)) = self.init { - eq_token.to_tokens(tokens); - init.to_tokens(tokens); - } - self.semi_token.to_tokens(tokens); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/file.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/file.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/file.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/file.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,123 +0,0 @@ -// Copyright 2018 Syn Developers -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use super::*; - -ast_struct! { - /// A complete file of Rust source code. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - /// - /// # Example - /// - /// Parse a Rust source file into a `syn::File` and print out a debug - /// representation of the syntax tree. - /// - /// ``` - /// extern crate syn; - /// - /// use std::env; - /// use std::fs::File; - /// use std::io::Read; - /// use std::process; - /// - /// fn main() { - /// # } - /// # - /// # fn fake_main() { - /// let mut args = env::args(); - /// let _ = args.next(); // executable name - /// - /// let filename = match (args.next(), args.next()) { - /// (Some(filename), None) => filename, - /// _ => { - /// eprintln!("Usage: dump-syntax path/to/filename.rs"); - /// process::exit(1); - /// } - /// }; - /// - /// let mut file = File::open(&filename).expect("Unable to open file"); - /// - /// let mut src = String::new(); - /// file.read_to_string(&mut src).expect("Unable to read file"); - /// - /// let syntax = syn::parse_file(&src).expect("Unable to parse file"); - /// println!("{:#?}", syntax); - /// } - /// ``` - /// - /// Running with its own source code as input, this program prints output - /// that begins with: - /// - /// ```text - /// File { - /// shebang: None, - /// attrs: [], - /// items: [ - /// ExternCrate( - /// ItemExternCrate { - /// attrs: [], - /// vis: Inherited, - /// extern_token: Extern, - /// crate_token: Crate, - /// ident: Ident { - /// term: Term( - /// "syn" - /// ), - /// span: Span - /// }, - /// rename: None, - /// semi_token: Semi - /// } - /// ), - /// ... - /// ``` - pub struct File { - pub shebang: Option, - pub attrs: Vec, - pub items: Vec, - } -} - -#[cfg(feature = "parsing")] -pub mod parsing { - use super::*; - - use synom::Synom; - - impl Synom for File { - named!(parse -> Self, do_parse!( - attrs: many0!(Attribute::parse_inner) >> - items: many0!(Item::parse) >> - (File { - shebang: None, - attrs: attrs, - items: items, - }) - )); - - fn description() -> Option<&'static str> { - Some("crate") - } - } -} - -#[cfg(feature = "printing")] -mod printing { - use super::*; - use attr::FilterAttrs; - use proc_macro2::TokenStream; - use quote::{ToTokens, TokenStreamExt}; - - impl ToTokens for File { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.inner()); - tokens.append_all(&self.items); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/gen/fold.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/gen/fold.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/gen/fold.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/gen/fold.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,2948 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED; DO NOT EDIT - -#![allow(unreachable_code)] -#![cfg_attr(feature = "cargo-clippy", allow(needless_pass_by_value))] -#[cfg(any(feature = "full", feature = "derive"))] -use gen::helper::fold::*; -use proc_macro2::Span; -#[cfg(any(feature = "full", feature = "derive"))] -use token::{Brace, Bracket, Group, Paren}; -use *; -#[cfg(feature = "full")] -macro_rules! full { - ($e:expr) => { - $e - }; -} -#[cfg(all(feature = "derive", not(feature = "full")))] -macro_rules! full { - ($e:expr) => { - unreachable!() - }; -} -#[doc = r" Syntax tree traversal to transform the nodes of an owned syntax tree."] -#[doc = r""] -#[doc = r" See the [module documentation] for details."] -#[doc = r""] -#[doc = r" [module documentation]: index.html"] -#[doc = r""] -#[doc = r#" *This trait is available if Syn is built with the `"fold"` feature.*"#] -pub trait Fold { - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_abi(&mut self, i: Abi) -> Abi { - fold_abi(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_angle_bracketed_generic_arguments( - &mut self, - i: AngleBracketedGenericArguments, - ) -> AngleBracketedGenericArguments { - fold_angle_bracketed_generic_arguments(self, i) - } - #[cfg(feature = "full")] - fn fold_arg_captured(&mut self, i: ArgCaptured) -> ArgCaptured { - fold_arg_captured(self, i) - } - #[cfg(feature = "full")] - fn fold_arg_self(&mut self, i: ArgSelf) -> ArgSelf { - fold_arg_self(self, i) - } - #[cfg(feature = "full")] - fn fold_arg_self_ref(&mut self, i: ArgSelfRef) -> ArgSelfRef { - fold_arg_self_ref(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_arm(&mut self, i: Arm) -> Arm { - fold_arm(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_attr_style(&mut self, i: AttrStyle) -> AttrStyle { - fold_attr_style(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_attribute(&mut self, i: Attribute) -> Attribute { - fold_attribute(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_bare_fn_arg(&mut self, i: BareFnArg) -> BareFnArg { - fold_bare_fn_arg(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_bare_fn_arg_name(&mut self, i: BareFnArgName) -> BareFnArgName { - fold_bare_fn_arg_name(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_bin_op(&mut self, i: BinOp) -> BinOp { - fold_bin_op(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_binding(&mut self, i: Binding) -> Binding { - fold_binding(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_block(&mut self, i: Block) -> Block { - fold_block(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_bound_lifetimes(&mut self, i: BoundLifetimes) -> BoundLifetimes { - fold_bound_lifetimes(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_const_param(&mut self, i: ConstParam) -> ConstParam { - fold_const_param(self, i) - } - #[cfg(feature = "derive")] - fn fold_data(&mut self, i: Data) -> Data { - fold_data(self, i) - } - #[cfg(feature = "derive")] - fn fold_data_enum(&mut self, i: DataEnum) -> DataEnum { - fold_data_enum(self, i) - } - #[cfg(feature = "derive")] - fn fold_data_struct(&mut self, i: DataStruct) -> DataStruct { - fold_data_struct(self, i) - } - #[cfg(feature = "derive")] - fn fold_data_union(&mut self, i: DataUnion) -> DataUnion { - fold_data_union(self, i) - } - #[cfg(feature = "derive")] - fn fold_derive_input(&mut self, i: DeriveInput) -> DeriveInput { - fold_derive_input(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr(&mut self, i: Expr) -> Expr { - fold_expr(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_array(&mut self, i: ExprArray) -> ExprArray { - fold_expr_array(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_assign(&mut self, i: ExprAssign) -> ExprAssign { - fold_expr_assign(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_assign_op(&mut self, i: ExprAssignOp) -> ExprAssignOp { - fold_expr_assign_op(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_binary(&mut self, i: ExprBinary) -> ExprBinary { - fold_expr_binary(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_block(&mut self, i: ExprBlock) -> ExprBlock { - fold_expr_block(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_box(&mut self, i: ExprBox) -> ExprBox { - fold_expr_box(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_break(&mut self, i: ExprBreak) -> ExprBreak { - fold_expr_break(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_call(&mut self, i: ExprCall) -> ExprCall { - fold_expr_call(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_cast(&mut self, i: ExprCast) -> ExprCast { - fold_expr_cast(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_catch(&mut self, i: ExprCatch) -> ExprCatch { - fold_expr_catch(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_closure(&mut self, i: ExprClosure) -> ExprClosure { - fold_expr_closure(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_continue(&mut self, i: ExprContinue) -> ExprContinue { - fold_expr_continue(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_field(&mut self, i: ExprField) -> ExprField { - fold_expr_field(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_for_loop(&mut self, i: ExprForLoop) -> ExprForLoop { - fold_expr_for_loop(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_group(&mut self, i: ExprGroup) -> ExprGroup { - fold_expr_group(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_if(&mut self, i: ExprIf) -> ExprIf { - fold_expr_if(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_if_let(&mut self, i: ExprIfLet) -> ExprIfLet { - fold_expr_if_let(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_in_place(&mut self, i: ExprInPlace) -> ExprInPlace { - fold_expr_in_place(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_index(&mut self, i: ExprIndex) -> ExprIndex { - fold_expr_index(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_lit(&mut self, i: ExprLit) -> ExprLit { - fold_expr_lit(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_loop(&mut self, i: ExprLoop) -> ExprLoop { - fold_expr_loop(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_macro(&mut self, i: ExprMacro) -> ExprMacro { - fold_expr_macro(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_match(&mut self, i: ExprMatch) -> ExprMatch { - fold_expr_match(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_method_call(&mut self, i: ExprMethodCall) -> ExprMethodCall { - fold_expr_method_call(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_paren(&mut self, i: ExprParen) -> ExprParen { - fold_expr_paren(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_path(&mut self, i: ExprPath) -> ExprPath { - fold_expr_path(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_range(&mut self, i: ExprRange) -> ExprRange { - fold_expr_range(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_reference(&mut self, i: ExprReference) -> ExprReference { - fold_expr_reference(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_repeat(&mut self, i: ExprRepeat) -> ExprRepeat { - fold_expr_repeat(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_return(&mut self, i: ExprReturn) -> ExprReturn { - fold_expr_return(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_struct(&mut self, i: ExprStruct) -> ExprStruct { - fold_expr_struct(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_try(&mut self, i: ExprTry) -> ExprTry { - fold_expr_try(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_tuple(&mut self, i: ExprTuple) -> ExprTuple { - fold_expr_tuple(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_type(&mut self, i: ExprType) -> ExprType { - fold_expr_type(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_unary(&mut self, i: ExprUnary) -> ExprUnary { - fold_expr_unary(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_unsafe(&mut self, i: ExprUnsafe) -> ExprUnsafe { - fold_expr_unsafe(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_verbatim(&mut self, i: ExprVerbatim) -> ExprVerbatim { - fold_expr_verbatim(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_while(&mut self, i: ExprWhile) -> ExprWhile { - fold_expr_while(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_while_let(&mut self, i: ExprWhileLet) -> ExprWhileLet { - fold_expr_while_let(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_expr_yield(&mut self, i: ExprYield) -> ExprYield { - fold_expr_yield(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_field(&mut self, i: Field) -> Field { - fold_field(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_field_pat(&mut self, i: FieldPat) -> FieldPat { - fold_field_pat(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_field_value(&mut self, i: FieldValue) -> FieldValue { - fold_field_value(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_fields(&mut self, i: Fields) -> Fields { - fold_fields(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_fields_named(&mut self, i: FieldsNamed) -> FieldsNamed { - fold_fields_named(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_fields_unnamed(&mut self, i: FieldsUnnamed) -> FieldsUnnamed { - fold_fields_unnamed(self, i) - } - #[cfg(feature = "full")] - fn fold_file(&mut self, i: File) -> File { - fold_file(self, i) - } - #[cfg(feature = "full")] - fn fold_fn_arg(&mut self, i: FnArg) -> FnArg { - fold_fn_arg(self, i) - } - #[cfg(feature = "full")] - fn fold_fn_decl(&mut self, i: FnDecl) -> FnDecl { - fold_fn_decl(self, i) - } - #[cfg(feature = "full")] - fn fold_foreign_item(&mut self, i: ForeignItem) -> ForeignItem { - fold_foreign_item(self, i) - } - #[cfg(feature = "full")] - fn fold_foreign_item_fn(&mut self, i: ForeignItemFn) -> ForeignItemFn { - fold_foreign_item_fn(self, i) - } - #[cfg(feature = "full")] - fn fold_foreign_item_static(&mut self, i: ForeignItemStatic) -> ForeignItemStatic { - fold_foreign_item_static(self, i) - } - #[cfg(feature = "full")] - fn fold_foreign_item_type(&mut self, i: ForeignItemType) -> ForeignItemType { - fold_foreign_item_type(self, i) - } - #[cfg(feature = "full")] - fn fold_foreign_item_verbatim(&mut self, i: ForeignItemVerbatim) -> ForeignItemVerbatim { - fold_foreign_item_verbatim(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_generic_argument(&mut self, i: GenericArgument) -> GenericArgument { - fold_generic_argument(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_generic_method_argument(&mut self, i: GenericMethodArgument) -> GenericMethodArgument { - fold_generic_method_argument(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_generic_param(&mut self, i: GenericParam) -> GenericParam { - fold_generic_param(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_generics(&mut self, i: Generics) -> Generics { - fold_generics(self, i) - } - fn fold_ident(&mut self, i: Ident) -> Ident { - fold_ident(self, i) - } - #[cfg(feature = "full")] - fn fold_impl_item(&mut self, i: ImplItem) -> ImplItem { - fold_impl_item(self, i) - } - #[cfg(feature = "full")] - fn fold_impl_item_const(&mut self, i: ImplItemConst) -> ImplItemConst { - fold_impl_item_const(self, i) - } - #[cfg(feature = "full")] - fn fold_impl_item_macro(&mut self, i: ImplItemMacro) -> ImplItemMacro { - fold_impl_item_macro(self, i) - } - #[cfg(feature = "full")] - fn fold_impl_item_method(&mut self, i: ImplItemMethod) -> ImplItemMethod { - fold_impl_item_method(self, i) - } - #[cfg(feature = "full")] - fn fold_impl_item_type(&mut self, i: ImplItemType) -> ImplItemType { - fold_impl_item_type(self, i) - } - #[cfg(feature = "full")] - fn fold_impl_item_verbatim(&mut self, i: ImplItemVerbatim) -> ImplItemVerbatim { - fold_impl_item_verbatim(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_index(&mut self, i: Index) -> Index { - fold_index(self, i) - } - #[cfg(feature = "full")] - fn fold_item(&mut self, i: Item) -> Item { - fold_item(self, i) - } - #[cfg(feature = "full")] - fn fold_item_const(&mut self, i: ItemConst) -> ItemConst { - fold_item_const(self, i) - } - #[cfg(feature = "full")] - fn fold_item_enum(&mut self, i: ItemEnum) -> ItemEnum { - fold_item_enum(self, i) - } - #[cfg(feature = "full")] - fn fold_item_extern_crate(&mut self, i: ItemExternCrate) -> ItemExternCrate { - fold_item_extern_crate(self, i) - } - #[cfg(feature = "full")] - fn fold_item_fn(&mut self, i: ItemFn) -> ItemFn { - fold_item_fn(self, i) - } - #[cfg(feature = "full")] - fn fold_item_foreign_mod(&mut self, i: ItemForeignMod) -> ItemForeignMod { - fold_item_foreign_mod(self, i) - } - #[cfg(feature = "full")] - fn fold_item_impl(&mut self, i: ItemImpl) -> ItemImpl { - fold_item_impl(self, i) - } - #[cfg(feature = "full")] - fn fold_item_macro(&mut self, i: ItemMacro) -> ItemMacro { - fold_item_macro(self, i) - } - #[cfg(feature = "full")] - fn fold_item_macro2(&mut self, i: ItemMacro2) -> ItemMacro2 { - fold_item_macro2(self, i) - } - #[cfg(feature = "full")] - fn fold_item_mod(&mut self, i: ItemMod) -> ItemMod { - fold_item_mod(self, i) - } - #[cfg(feature = "full")] - fn fold_item_static(&mut self, i: ItemStatic) -> ItemStatic { - fold_item_static(self, i) - } - #[cfg(feature = "full")] - fn fold_item_struct(&mut self, i: ItemStruct) -> ItemStruct { - fold_item_struct(self, i) - } - #[cfg(feature = "full")] - fn fold_item_trait(&mut self, i: ItemTrait) -> ItemTrait { - fold_item_trait(self, i) - } - #[cfg(feature = "full")] - fn fold_item_type(&mut self, i: ItemType) -> ItemType { - fold_item_type(self, i) - } - #[cfg(feature = "full")] - fn fold_item_union(&mut self, i: ItemUnion) -> ItemUnion { - fold_item_union(self, i) - } - #[cfg(feature = "full")] - fn fold_item_use(&mut self, i: ItemUse) -> ItemUse { - fold_item_use(self, i) - } - #[cfg(feature = "full")] - fn fold_item_verbatim(&mut self, i: ItemVerbatim) -> ItemVerbatim { - fold_item_verbatim(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_label(&mut self, i: Label) -> Label { - fold_label(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_lifetime(&mut self, i: Lifetime) -> Lifetime { - fold_lifetime(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_lifetime_def(&mut self, i: LifetimeDef) -> LifetimeDef { - fold_lifetime_def(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_lit(&mut self, i: Lit) -> Lit { - fold_lit(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_lit_bool(&mut self, i: LitBool) -> LitBool { - fold_lit_bool(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_lit_byte(&mut self, i: LitByte) -> LitByte { - fold_lit_byte(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_lit_byte_str(&mut self, i: LitByteStr) -> LitByteStr { - fold_lit_byte_str(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_lit_char(&mut self, i: LitChar) -> LitChar { - fold_lit_char(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_lit_float(&mut self, i: LitFloat) -> LitFloat { - fold_lit_float(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_lit_int(&mut self, i: LitInt) -> LitInt { - fold_lit_int(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_lit_str(&mut self, i: LitStr) -> LitStr { - fold_lit_str(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_lit_verbatim(&mut self, i: LitVerbatim) -> LitVerbatim { - fold_lit_verbatim(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_local(&mut self, i: Local) -> Local { - fold_local(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_macro(&mut self, i: Macro) -> Macro { - fold_macro(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_macro_delimiter(&mut self, i: MacroDelimiter) -> MacroDelimiter { - fold_macro_delimiter(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_member(&mut self, i: Member) -> Member { - fold_member(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_meta(&mut self, i: Meta) -> Meta { - fold_meta(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_meta_list(&mut self, i: MetaList) -> MetaList { - fold_meta_list(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_meta_name_value(&mut self, i: MetaNameValue) -> MetaNameValue { - fold_meta_name_value(self, i) - } - #[cfg(feature = "full")] - fn fold_method_sig(&mut self, i: MethodSig) -> MethodSig { - fold_method_sig(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_method_turbofish(&mut self, i: MethodTurbofish) -> MethodTurbofish { - fold_method_turbofish(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_nested_meta(&mut self, i: NestedMeta) -> NestedMeta { - fold_nested_meta(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_parenthesized_generic_arguments( - &mut self, - i: ParenthesizedGenericArguments, - ) -> ParenthesizedGenericArguments { - fold_parenthesized_generic_arguments(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_pat(&mut self, i: Pat) -> Pat { - fold_pat(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_pat_box(&mut self, i: PatBox) -> PatBox { - fold_pat_box(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_pat_ident(&mut self, i: PatIdent) -> PatIdent { - fold_pat_ident(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_pat_lit(&mut self, i: PatLit) -> PatLit { - fold_pat_lit(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_pat_macro(&mut self, i: PatMacro) -> PatMacro { - fold_pat_macro(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_pat_path(&mut self, i: PatPath) -> PatPath { - fold_pat_path(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_pat_range(&mut self, i: PatRange) -> PatRange { - fold_pat_range(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_pat_ref(&mut self, i: PatRef) -> PatRef { - fold_pat_ref(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_pat_slice(&mut self, i: PatSlice) -> PatSlice { - fold_pat_slice(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_pat_struct(&mut self, i: PatStruct) -> PatStruct { - fold_pat_struct(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_pat_tuple(&mut self, i: PatTuple) -> PatTuple { - fold_pat_tuple(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_pat_tuple_struct(&mut self, i: PatTupleStruct) -> PatTupleStruct { - fold_pat_tuple_struct(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_pat_verbatim(&mut self, i: PatVerbatim) -> PatVerbatim { - fold_pat_verbatim(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_pat_wild(&mut self, i: PatWild) -> PatWild { - fold_pat_wild(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_path(&mut self, i: Path) -> Path { - fold_path(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_path_arguments(&mut self, i: PathArguments) -> PathArguments { - fold_path_arguments(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_path_segment(&mut self, i: PathSegment) -> PathSegment { - fold_path_segment(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_predicate_eq(&mut self, i: PredicateEq) -> PredicateEq { - fold_predicate_eq(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_predicate_lifetime(&mut self, i: PredicateLifetime) -> PredicateLifetime { - fold_predicate_lifetime(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_predicate_type(&mut self, i: PredicateType) -> PredicateType { - fold_predicate_type(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_qself(&mut self, i: QSelf) -> QSelf { - fold_qself(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_range_limits(&mut self, i: RangeLimits) -> RangeLimits { - fold_range_limits(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_return_type(&mut self, i: ReturnType) -> ReturnType { - fold_return_type(self, i) - } - fn fold_span(&mut self, i: Span) -> Span { - fold_span(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn fold_stmt(&mut self, i: Stmt) -> Stmt { - fold_stmt(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_trait_bound(&mut self, i: TraitBound) -> TraitBound { - fold_trait_bound(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_trait_bound_modifier(&mut self, i: TraitBoundModifier) -> TraitBoundModifier { - fold_trait_bound_modifier(self, i) - } - #[cfg(feature = "full")] - fn fold_trait_item(&mut self, i: TraitItem) -> TraitItem { - fold_trait_item(self, i) - } - #[cfg(feature = "full")] - fn fold_trait_item_const(&mut self, i: TraitItemConst) -> TraitItemConst { - fold_trait_item_const(self, i) - } - #[cfg(feature = "full")] - fn fold_trait_item_macro(&mut self, i: TraitItemMacro) -> TraitItemMacro { - fold_trait_item_macro(self, i) - } - #[cfg(feature = "full")] - fn fold_trait_item_method(&mut self, i: TraitItemMethod) -> TraitItemMethod { - fold_trait_item_method(self, i) - } - #[cfg(feature = "full")] - fn fold_trait_item_type(&mut self, i: TraitItemType) -> TraitItemType { - fold_trait_item_type(self, i) - } - #[cfg(feature = "full")] - fn fold_trait_item_verbatim(&mut self, i: TraitItemVerbatim) -> TraitItemVerbatim { - fold_trait_item_verbatim(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_type(&mut self, i: Type) -> Type { - fold_type(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_type_array(&mut self, i: TypeArray) -> TypeArray { - fold_type_array(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_type_bare_fn(&mut self, i: TypeBareFn) -> TypeBareFn { - fold_type_bare_fn(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_type_group(&mut self, i: TypeGroup) -> TypeGroup { - fold_type_group(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_type_impl_trait(&mut self, i: TypeImplTrait) -> TypeImplTrait { - fold_type_impl_trait(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_type_infer(&mut self, i: TypeInfer) -> TypeInfer { - fold_type_infer(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_type_macro(&mut self, i: TypeMacro) -> TypeMacro { - fold_type_macro(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_type_never(&mut self, i: TypeNever) -> TypeNever { - fold_type_never(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_type_param(&mut self, i: TypeParam) -> TypeParam { - fold_type_param(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_type_param_bound(&mut self, i: TypeParamBound) -> TypeParamBound { - fold_type_param_bound(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_type_paren(&mut self, i: TypeParen) -> TypeParen { - fold_type_paren(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_type_path(&mut self, i: TypePath) -> TypePath { - fold_type_path(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_type_ptr(&mut self, i: TypePtr) -> TypePtr { - fold_type_ptr(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_type_reference(&mut self, i: TypeReference) -> TypeReference { - fold_type_reference(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_type_slice(&mut self, i: TypeSlice) -> TypeSlice { - fold_type_slice(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_type_trait_object(&mut self, i: TypeTraitObject) -> TypeTraitObject { - fold_type_trait_object(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_type_tuple(&mut self, i: TypeTuple) -> TypeTuple { - fold_type_tuple(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_type_verbatim(&mut self, i: TypeVerbatim) -> TypeVerbatim { - fold_type_verbatim(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_un_op(&mut self, i: UnOp) -> UnOp { - fold_un_op(self, i) - } - #[cfg(feature = "full")] - fn fold_use_glob(&mut self, i: UseGlob) -> UseGlob { - fold_use_glob(self, i) - } - #[cfg(feature = "full")] - fn fold_use_group(&mut self, i: UseGroup) -> UseGroup { - fold_use_group(self, i) - } - #[cfg(feature = "full")] - fn fold_use_name(&mut self, i: UseName) -> UseName { - fold_use_name(self, i) - } - #[cfg(feature = "full")] - fn fold_use_path(&mut self, i: UsePath) -> UsePath { - fold_use_path(self, i) - } - #[cfg(feature = "full")] - fn fold_use_rename(&mut self, i: UseRename) -> UseRename { - fold_use_rename(self, i) - } - #[cfg(feature = "full")] - fn fold_use_tree(&mut self, i: UseTree) -> UseTree { - fold_use_tree(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_variant(&mut self, i: Variant) -> Variant { - fold_variant(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_vis_crate(&mut self, i: VisCrate) -> VisCrate { - fold_vis_crate(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_vis_public(&mut self, i: VisPublic) -> VisPublic { - fold_vis_public(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_vis_restricted(&mut self, i: VisRestricted) -> VisRestricted { - fold_vis_restricted(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_visibility(&mut self, i: Visibility) -> Visibility { - fold_visibility(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_where_clause(&mut self, i: WhereClause) -> WhereClause { - fold_where_clause(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn fold_where_predicate(&mut self, i: WherePredicate) -> WherePredicate { - fold_where_predicate(self, i) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -macro_rules! fold_span_only { - ($f:ident : $t:ident) => { - pub fn $f(_visitor: &mut V, mut _i: $t) -> $t { - let span = _visitor.fold_span(_i.span()); - _i.set_span(span); - _i - } - }; -} -#[cfg(any(feature = "full", feature = "derive"))] -fold_span_only!(fold_lit_byte: LitByte); -#[cfg(any(feature = "full", feature = "derive"))] -fold_span_only!(fold_lit_byte_str: LitByteStr); -#[cfg(any(feature = "full", feature = "derive"))] -fold_span_only!(fold_lit_char: LitChar); -#[cfg(any(feature = "full", feature = "derive"))] -fold_span_only!(fold_lit_float: LitFloat); -#[cfg(any(feature = "full", feature = "derive"))] -fold_span_only!(fold_lit_int: LitInt); -#[cfg(any(feature = "full", feature = "derive"))] -fold_span_only!(fold_lit_str: LitStr); -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_abi(_visitor: &mut V, _i: Abi) -> Abi { - Abi { - extern_token: Token![extern](tokens_helper(_visitor, &(_i.extern_token).0)), - name: (_i.name).map(|it| _visitor.fold_lit_str(it)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_angle_bracketed_generic_arguments( - _visitor: &mut V, - _i: AngleBracketedGenericArguments, -) -> AngleBracketedGenericArguments { - AngleBracketedGenericArguments { - colon2_token: (_i.colon2_token).map(|it| Token ! [ :: ](tokens_helper(_visitor, &(it).0))), - lt_token: Token ! [ < ](tokens_helper(_visitor, &(_i.lt_token).0)), - args: FoldHelper::lift(_i.args, |it| _visitor.fold_generic_argument(it)), - gt_token: Token ! [ > ](tokens_helper(_visitor, &(_i.gt_token).0)), - } -} -#[cfg(feature = "full")] -pub fn fold_arg_captured(_visitor: &mut V, _i: ArgCaptured) -> ArgCaptured { - ArgCaptured { - pat: _visitor.fold_pat(_i.pat), - colon_token: Token ! [ : ](tokens_helper(_visitor, &(_i.colon_token).0)), - ty: _visitor.fold_type(_i.ty), - } -} -#[cfg(feature = "full")] -pub fn fold_arg_self(_visitor: &mut V, _i: ArgSelf) -> ArgSelf { - ArgSelf { - mutability: (_i.mutability).map(|it| Token ! [ mut ](tokens_helper(_visitor, &(it).0))), - self_token: Token![self](tokens_helper(_visitor, &(_i.self_token).0)), - } -} -#[cfg(feature = "full")] -pub fn fold_arg_self_ref(_visitor: &mut V, _i: ArgSelfRef) -> ArgSelfRef { - ArgSelfRef { - and_token: Token ! [ & ](tokens_helper(_visitor, &(_i.and_token).0)), - lifetime: (_i.lifetime).map(|it| _visitor.fold_lifetime(it)), - mutability: (_i.mutability).map(|it| Token ! [ mut ](tokens_helper(_visitor, &(it).0))), - self_token: Token![self](tokens_helper(_visitor, &(_i.self_token).0)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_arm(_visitor: &mut V, _i: Arm) -> Arm { - Arm { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - leading_vert: (_i.leading_vert).map(|it| Token ! [ | ](tokens_helper(_visitor, &(it).0))), - pats: FoldHelper::lift(_i.pats, |it| _visitor.fold_pat(it)), - guard: (_i.guard).map(|it| { - ( - Token ! [ if ](tokens_helper(_visitor, &((it).0).0)), - Box::new(_visitor.fold_expr(*(it).1)), - ) - }), - fat_arrow_token: Token ! [ => ](tokens_helper(_visitor, &(_i.fat_arrow_token).0)), - body: Box::new(_visitor.fold_expr(*_i.body)), - comma: (_i.comma).map(|it| Token ! [ , ](tokens_helper(_visitor, &(it).0))), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_attr_style(_visitor: &mut V, _i: AttrStyle) -> AttrStyle { - match _i { - AttrStyle::Outer => AttrStyle::Outer, - AttrStyle::Inner(_binding_0) => { - AttrStyle::Inner(Token![!](tokens_helper(_visitor, &(_binding_0).0))) - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_attribute(_visitor: &mut V, _i: Attribute) -> Attribute { - Attribute { - pound_token: Token ! [ # ](tokens_helper(_visitor, &(_i.pound_token).0)), - style: _visitor.fold_attr_style(_i.style), - bracket_token: Bracket(tokens_helper(_visitor, &(_i.bracket_token).0)), - path: _visitor.fold_path(_i.path), - tts: _i.tts, - is_sugared_doc: _i.is_sugared_doc, - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_bare_fn_arg(_visitor: &mut V, _i: BareFnArg) -> BareFnArg { - BareFnArg { - name: (_i.name).map(|it| { - ( - _visitor.fold_bare_fn_arg_name((it).0), - Token ! [ : ](tokens_helper(_visitor, &((it).1).0)), - ) - }), - ty: _visitor.fold_type(_i.ty), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_bare_fn_arg_name( - _visitor: &mut V, - _i: BareFnArgName, -) -> BareFnArgName { - match _i { - BareFnArgName::Named(_binding_0) => BareFnArgName::Named(_visitor.fold_ident(_binding_0)), - BareFnArgName::Wild(_binding_0) => { - BareFnArgName::Wild(Token![_](tokens_helper(_visitor, &(_binding_0).0))) - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_bin_op(_visitor: &mut V, _i: BinOp) -> BinOp { - match _i { - BinOp::Add(_binding_0) => { - BinOp::Add(Token ! [ + ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::Sub(_binding_0) => { - BinOp::Sub(Token ! [ - ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::Mul(_binding_0) => { - BinOp::Mul(Token ! [ * ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::Div(_binding_0) => { - BinOp::Div(Token ! [ / ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::Rem(_binding_0) => { - BinOp::Rem(Token ! [ % ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::And(_binding_0) => { - BinOp::And(Token ! [ && ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::Or(_binding_0) => { - BinOp::Or(Token ! [ || ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::BitXor(_binding_0) => { - BinOp::BitXor(Token ! [ ^ ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::BitAnd(_binding_0) => { - BinOp::BitAnd(Token ! [ & ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::BitOr(_binding_0) => { - BinOp::BitOr(Token ! [ | ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::Shl(_binding_0) => { - BinOp::Shl(Token ! [ << ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::Shr(_binding_0) => { - BinOp::Shr(Token ! [ >> ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::Eq(_binding_0) => { - BinOp::Eq(Token ! [ == ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::Lt(_binding_0) => BinOp::Lt(Token ! [ < ](tokens_helper(_visitor, &(_binding_0).0))), - BinOp::Le(_binding_0) => { - BinOp::Le(Token ! [ <= ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::Ne(_binding_0) => { - BinOp::Ne(Token ! [ != ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::Ge(_binding_0) => { - BinOp::Ge(Token ! [ >= ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::Gt(_binding_0) => BinOp::Gt(Token ! [ > ](tokens_helper(_visitor, &(_binding_0).0))), - BinOp::AddEq(_binding_0) => { - BinOp::AddEq(Token ! [ += ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::SubEq(_binding_0) => { - BinOp::SubEq(Token ! [ -= ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::MulEq(_binding_0) => { - BinOp::MulEq(Token ! [ *= ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::DivEq(_binding_0) => { - BinOp::DivEq(Token ! [ /= ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::RemEq(_binding_0) => { - BinOp::RemEq(Token ! [ %= ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::BitXorEq(_binding_0) => { - BinOp::BitXorEq(Token ! [ ^= ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::BitAndEq(_binding_0) => { - BinOp::BitAndEq(Token ! [ &= ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::BitOrEq(_binding_0) => { - BinOp::BitOrEq(Token ! [ |= ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::ShlEq(_binding_0) => { - BinOp::ShlEq(Token ! [ <<= ](tokens_helper(_visitor, &(_binding_0).0))) - } - BinOp::ShrEq(_binding_0) => { - BinOp::ShrEq(Token ! [ >>= ](tokens_helper(_visitor, &(_binding_0).0))) - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_binding(_visitor: &mut V, _i: Binding) -> Binding { - Binding { - ident: _visitor.fold_ident(_i.ident), - eq_token: Token ! [ = ](tokens_helper(_visitor, &(_i.eq_token).0)), - ty: _visitor.fold_type(_i.ty), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_block(_visitor: &mut V, _i: Block) -> Block { - Block { - brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), - stmts: FoldHelper::lift(_i.stmts, |it| _visitor.fold_stmt(it)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_bound_lifetimes( - _visitor: &mut V, - _i: BoundLifetimes, -) -> BoundLifetimes { - BoundLifetimes { - for_token: Token ! [ for ](tokens_helper(_visitor, &(_i.for_token).0)), - lt_token: Token ! [ < ](tokens_helper(_visitor, &(_i.lt_token).0)), - lifetimes: FoldHelper::lift(_i.lifetimes, |it| _visitor.fold_lifetime_def(it)), - gt_token: Token ! [ > ](tokens_helper(_visitor, &(_i.gt_token).0)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_const_param(_visitor: &mut V, _i: ConstParam) -> ConstParam { - ConstParam { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - const_token: Token ! [ const ](tokens_helper(_visitor, &(_i.const_token).0)), - ident: _visitor.fold_ident(_i.ident), - colon_token: Token ! [ : ](tokens_helper(_visitor, &(_i.colon_token).0)), - ty: _visitor.fold_type(_i.ty), - eq_token: (_i.eq_token).map(|it| Token ! [ = ](tokens_helper(_visitor, &(it).0))), - default: (_i.default).map(|it| _visitor.fold_expr(it)), - } -} -#[cfg(feature = "derive")] -pub fn fold_data(_visitor: &mut V, _i: Data) -> Data { - match _i { - Data::Struct(_binding_0) => Data::Struct(_visitor.fold_data_struct(_binding_0)), - Data::Enum(_binding_0) => Data::Enum(_visitor.fold_data_enum(_binding_0)), - Data::Union(_binding_0) => Data::Union(_visitor.fold_data_union(_binding_0)), - } -} -#[cfg(feature = "derive")] -pub fn fold_data_enum(_visitor: &mut V, _i: DataEnum) -> DataEnum { - DataEnum { - enum_token: Token ! [ enum ](tokens_helper(_visitor, &(_i.enum_token).0)), - brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), - variants: FoldHelper::lift(_i.variants, |it| _visitor.fold_variant(it)), - } -} -#[cfg(feature = "derive")] -pub fn fold_data_struct(_visitor: &mut V, _i: DataStruct) -> DataStruct { - DataStruct { - struct_token: Token ! [ struct ](tokens_helper(_visitor, &(_i.struct_token).0)), - fields: _visitor.fold_fields(_i.fields), - semi_token: (_i.semi_token).map(|it| Token ! [ ; ](tokens_helper(_visitor, &(it).0))), - } -} -#[cfg(feature = "derive")] -pub fn fold_data_union(_visitor: &mut V, _i: DataUnion) -> DataUnion { - DataUnion { - union_token: Token![union](tokens_helper(_visitor, &(_i.union_token).0)), - fields: _visitor.fold_fields_named(_i.fields), - } -} -#[cfg(feature = "derive")] -pub fn fold_derive_input(_visitor: &mut V, _i: DeriveInput) -> DeriveInput { - DeriveInput { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - vis: _visitor.fold_visibility(_i.vis), - ident: _visitor.fold_ident(_i.ident), - generics: _visitor.fold_generics(_i.generics), - data: _visitor.fold_data(_i.data), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr(_visitor: &mut V, _i: Expr) -> Expr { - match _i { - Expr::Box(_binding_0) => Expr::Box(full!(_visitor.fold_expr_box(_binding_0))), - Expr::InPlace(_binding_0) => Expr::InPlace(full!(_visitor.fold_expr_in_place(_binding_0))), - Expr::Array(_binding_0) => Expr::Array(full!(_visitor.fold_expr_array(_binding_0))), - Expr::Call(_binding_0) => Expr::Call(_visitor.fold_expr_call(_binding_0)), - Expr::MethodCall(_binding_0) => { - Expr::MethodCall(full!(_visitor.fold_expr_method_call(_binding_0))) - } - Expr::Tuple(_binding_0) => Expr::Tuple(full!(_visitor.fold_expr_tuple(_binding_0))), - Expr::Binary(_binding_0) => Expr::Binary(_visitor.fold_expr_binary(_binding_0)), - Expr::Unary(_binding_0) => Expr::Unary(_visitor.fold_expr_unary(_binding_0)), - Expr::Lit(_binding_0) => Expr::Lit(_visitor.fold_expr_lit(_binding_0)), - Expr::Cast(_binding_0) => Expr::Cast(_visitor.fold_expr_cast(_binding_0)), - Expr::Type(_binding_0) => Expr::Type(full!(_visitor.fold_expr_type(_binding_0))), - Expr::If(_binding_0) => Expr::If(full!(_visitor.fold_expr_if(_binding_0))), - Expr::IfLet(_binding_0) => Expr::IfLet(full!(_visitor.fold_expr_if_let(_binding_0))), - Expr::While(_binding_0) => Expr::While(full!(_visitor.fold_expr_while(_binding_0))), - Expr::WhileLet(_binding_0) => { - Expr::WhileLet(full!(_visitor.fold_expr_while_let(_binding_0))) - } - Expr::ForLoop(_binding_0) => Expr::ForLoop(full!(_visitor.fold_expr_for_loop(_binding_0))), - Expr::Loop(_binding_0) => Expr::Loop(full!(_visitor.fold_expr_loop(_binding_0))), - Expr::Match(_binding_0) => Expr::Match(full!(_visitor.fold_expr_match(_binding_0))), - Expr::Closure(_binding_0) => Expr::Closure(full!(_visitor.fold_expr_closure(_binding_0))), - Expr::Unsafe(_binding_0) => Expr::Unsafe(full!(_visitor.fold_expr_unsafe(_binding_0))), - Expr::Block(_binding_0) => Expr::Block(full!(_visitor.fold_expr_block(_binding_0))), - Expr::Assign(_binding_0) => Expr::Assign(full!(_visitor.fold_expr_assign(_binding_0))), - Expr::AssignOp(_binding_0) => { - Expr::AssignOp(full!(_visitor.fold_expr_assign_op(_binding_0))) - } - Expr::Field(_binding_0) => Expr::Field(_visitor.fold_expr_field(_binding_0)), - Expr::Index(_binding_0) => Expr::Index(_visitor.fold_expr_index(_binding_0)), - Expr::Range(_binding_0) => Expr::Range(full!(_visitor.fold_expr_range(_binding_0))), - Expr::Path(_binding_0) => Expr::Path(_visitor.fold_expr_path(_binding_0)), - Expr::Reference(_binding_0) => { - Expr::Reference(full!(_visitor.fold_expr_reference(_binding_0))) - } - Expr::Break(_binding_0) => Expr::Break(full!(_visitor.fold_expr_break(_binding_0))), - Expr::Continue(_binding_0) => { - Expr::Continue(full!(_visitor.fold_expr_continue(_binding_0))) - } - Expr::Return(_binding_0) => Expr::Return(full!(_visitor.fold_expr_return(_binding_0))), - Expr::Macro(_binding_0) => Expr::Macro(full!(_visitor.fold_expr_macro(_binding_0))), - Expr::Struct(_binding_0) => Expr::Struct(full!(_visitor.fold_expr_struct(_binding_0))), - Expr::Repeat(_binding_0) => Expr::Repeat(full!(_visitor.fold_expr_repeat(_binding_0))), - Expr::Paren(_binding_0) => Expr::Paren(_visitor.fold_expr_paren(_binding_0)), - Expr::Group(_binding_0) => Expr::Group(full!(_visitor.fold_expr_group(_binding_0))), - Expr::Try(_binding_0) => Expr::Try(full!(_visitor.fold_expr_try(_binding_0))), - Expr::Catch(_binding_0) => Expr::Catch(full!(_visitor.fold_expr_catch(_binding_0))), - Expr::Yield(_binding_0) => Expr::Yield(full!(_visitor.fold_expr_yield(_binding_0))), - Expr::Verbatim(_binding_0) => Expr::Verbatim(_visitor.fold_expr_verbatim(_binding_0)), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_array(_visitor: &mut V, _i: ExprArray) -> ExprArray { - ExprArray { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - bracket_token: Bracket(tokens_helper(_visitor, &(_i.bracket_token).0)), - elems: FoldHelper::lift(_i.elems, |it| _visitor.fold_expr(it)), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_assign(_visitor: &mut V, _i: ExprAssign) -> ExprAssign { - ExprAssign { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - left: Box::new(_visitor.fold_expr(*_i.left)), - eq_token: Token ! [ = ](tokens_helper(_visitor, &(_i.eq_token).0)), - right: Box::new(_visitor.fold_expr(*_i.right)), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_assign_op(_visitor: &mut V, _i: ExprAssignOp) -> ExprAssignOp { - ExprAssignOp { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - left: Box::new(_visitor.fold_expr(*_i.left)), - op: _visitor.fold_bin_op(_i.op), - right: Box::new(_visitor.fold_expr(*_i.right)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_binary(_visitor: &mut V, _i: ExprBinary) -> ExprBinary { - ExprBinary { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - left: Box::new(_visitor.fold_expr(*_i.left)), - op: _visitor.fold_bin_op(_i.op), - right: Box::new(_visitor.fold_expr(*_i.right)), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_block(_visitor: &mut V, _i: ExprBlock) -> ExprBlock { - ExprBlock { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - block: _visitor.fold_block(_i.block), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_box(_visitor: &mut V, _i: ExprBox) -> ExprBox { - ExprBox { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - box_token: Token ! [ box ](tokens_helper(_visitor, &(_i.box_token).0)), - expr: Box::new(_visitor.fold_expr(*_i.expr)), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_break(_visitor: &mut V, _i: ExprBreak) -> ExprBreak { - ExprBreak { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - break_token: Token![break](tokens_helper(_visitor, &(_i.break_token).0)), - label: (_i.label).map(|it| _visitor.fold_lifetime(it)), - expr: (_i.expr).map(|it| Box::new(_visitor.fold_expr(*it))), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_call(_visitor: &mut V, _i: ExprCall) -> ExprCall { - ExprCall { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - func: Box::new(_visitor.fold_expr(*_i.func)), - paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), - args: FoldHelper::lift(_i.args, |it| _visitor.fold_expr(it)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_cast(_visitor: &mut V, _i: ExprCast) -> ExprCast { - ExprCast { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - expr: Box::new(_visitor.fold_expr(*_i.expr)), - as_token: Token ! [ as ](tokens_helper(_visitor, &(_i.as_token).0)), - ty: Box::new(_visitor.fold_type(*_i.ty)), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_catch(_visitor: &mut V, _i: ExprCatch) -> ExprCatch { - ExprCatch { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - do_token: Token ! [ do ](tokens_helper(_visitor, &(_i.do_token).0)), - catch_token: Token![catch](tokens_helper(_visitor, &(_i.catch_token).0)), - block: _visitor.fold_block(_i.block), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_closure(_visitor: &mut V, _i: ExprClosure) -> ExprClosure { - ExprClosure { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - movability: (_i.movability).map(|it| Token ! [ static ](tokens_helper(_visitor, &(it).0))), - capture: (_i.capture).map(|it| Token ! [ move ](tokens_helper(_visitor, &(it).0))), - or1_token: Token ! [ | ](tokens_helper(_visitor, &(_i.or1_token).0)), - inputs: FoldHelper::lift(_i.inputs, |it| _visitor.fold_fn_arg(it)), - or2_token: Token ! [ | ](tokens_helper(_visitor, &(_i.or2_token).0)), - output: _visitor.fold_return_type(_i.output), - body: Box::new(_visitor.fold_expr(*_i.body)), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_continue(_visitor: &mut V, _i: ExprContinue) -> ExprContinue { - ExprContinue { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - continue_token: Token![continue](tokens_helper(_visitor, &(_i.continue_token).0)), - label: (_i.label).map(|it| _visitor.fold_lifetime(it)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_field(_visitor: &mut V, _i: ExprField) -> ExprField { - ExprField { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - base: Box::new(_visitor.fold_expr(*_i.base)), - dot_token: Token ! [ . ](tokens_helper(_visitor, &(_i.dot_token).0)), - member: _visitor.fold_member(_i.member), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_for_loop(_visitor: &mut V, _i: ExprForLoop) -> ExprForLoop { - ExprForLoop { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - label: (_i.label).map(|it| _visitor.fold_label(it)), - for_token: Token ! [ for ](tokens_helper(_visitor, &(_i.for_token).0)), - pat: Box::new(_visitor.fold_pat(*_i.pat)), - in_token: Token ! [ in ](tokens_helper(_visitor, &(_i.in_token).0)), - expr: Box::new(_visitor.fold_expr(*_i.expr)), - body: _visitor.fold_block(_i.body), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_group(_visitor: &mut V, _i: ExprGroup) -> ExprGroup { - ExprGroup { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - group_token: Group(tokens_helper(_visitor, &(_i.group_token).0)), - expr: Box::new(_visitor.fold_expr(*_i.expr)), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_if(_visitor: &mut V, _i: ExprIf) -> ExprIf { - ExprIf { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - if_token: Token ! [ if ](tokens_helper(_visitor, &(_i.if_token).0)), - cond: Box::new(_visitor.fold_expr(*_i.cond)), - then_branch: _visitor.fold_block(_i.then_branch), - else_branch: (_i.else_branch).map(|it| { - ( - Token ! [ else ](tokens_helper(_visitor, &((it).0).0)), - Box::new(_visitor.fold_expr(*(it).1)), - ) - }), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_if_let(_visitor: &mut V, _i: ExprIfLet) -> ExprIfLet { - ExprIfLet { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - if_token: Token ! [ if ](tokens_helper(_visitor, &(_i.if_token).0)), - let_token: Token ! [ let ](tokens_helper(_visitor, &(_i.let_token).0)), - pats: FoldHelper::lift(_i.pats, |it| _visitor.fold_pat(it)), - eq_token: Token ! [ = ](tokens_helper(_visitor, &(_i.eq_token).0)), - expr: Box::new(_visitor.fold_expr(*_i.expr)), - then_branch: _visitor.fold_block(_i.then_branch), - else_branch: (_i.else_branch).map(|it| { - ( - Token ! [ else ](tokens_helper(_visitor, &((it).0).0)), - Box::new(_visitor.fold_expr(*(it).1)), - ) - }), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_in_place(_visitor: &mut V, _i: ExprInPlace) -> ExprInPlace { - ExprInPlace { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - place: Box::new(_visitor.fold_expr(*_i.place)), - arrow_token: Token ! [ <- ](tokens_helper(_visitor, &(_i.arrow_token).0)), - value: Box::new(_visitor.fold_expr(*_i.value)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_index(_visitor: &mut V, _i: ExprIndex) -> ExprIndex { - ExprIndex { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - expr: Box::new(_visitor.fold_expr(*_i.expr)), - bracket_token: Bracket(tokens_helper(_visitor, &(_i.bracket_token).0)), - index: Box::new(_visitor.fold_expr(*_i.index)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_lit(_visitor: &mut V, _i: ExprLit) -> ExprLit { - ExprLit { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - lit: _visitor.fold_lit(_i.lit), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_loop(_visitor: &mut V, _i: ExprLoop) -> ExprLoop { - ExprLoop { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - label: (_i.label).map(|it| _visitor.fold_label(it)), - loop_token: Token ! [ loop ](tokens_helper(_visitor, &(_i.loop_token).0)), - body: _visitor.fold_block(_i.body), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_macro(_visitor: &mut V, _i: ExprMacro) -> ExprMacro { - ExprMacro { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - mac: _visitor.fold_macro(_i.mac), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_match(_visitor: &mut V, _i: ExprMatch) -> ExprMatch { - ExprMatch { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - match_token: Token ! [ match ](tokens_helper(_visitor, &(_i.match_token).0)), - expr: Box::new(_visitor.fold_expr(*_i.expr)), - brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), - arms: FoldHelper::lift(_i.arms, |it| _visitor.fold_arm(it)), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_method_call( - _visitor: &mut V, - _i: ExprMethodCall, -) -> ExprMethodCall { - ExprMethodCall { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - receiver: Box::new(_visitor.fold_expr(*_i.receiver)), - dot_token: Token ! [ . ](tokens_helper(_visitor, &(_i.dot_token).0)), - method: _visitor.fold_ident(_i.method), - turbofish: (_i.turbofish).map(|it| _visitor.fold_method_turbofish(it)), - paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), - args: FoldHelper::lift(_i.args, |it| _visitor.fold_expr(it)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_paren(_visitor: &mut V, _i: ExprParen) -> ExprParen { - ExprParen { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), - expr: Box::new(_visitor.fold_expr(*_i.expr)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_path(_visitor: &mut V, _i: ExprPath) -> ExprPath { - ExprPath { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - qself: (_i.qself).map(|it| _visitor.fold_qself(it)), - path: _visitor.fold_path(_i.path), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_range(_visitor: &mut V, _i: ExprRange) -> ExprRange { - ExprRange { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - from: (_i.from).map(|it| Box::new(_visitor.fold_expr(*it))), - limits: _visitor.fold_range_limits(_i.limits), - to: (_i.to).map(|it| Box::new(_visitor.fold_expr(*it))), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_reference(_visitor: &mut V, _i: ExprReference) -> ExprReference { - ExprReference { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - and_token: Token ! [ & ](tokens_helper(_visitor, &(_i.and_token).0)), - mutability: (_i.mutability).map(|it| Token ! [ mut ](tokens_helper(_visitor, &(it).0))), - expr: Box::new(_visitor.fold_expr(*_i.expr)), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_repeat(_visitor: &mut V, _i: ExprRepeat) -> ExprRepeat { - ExprRepeat { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - bracket_token: Bracket(tokens_helper(_visitor, &(_i.bracket_token).0)), - expr: Box::new(_visitor.fold_expr(*_i.expr)), - semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), - len: Box::new(_visitor.fold_expr(*_i.len)), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_return(_visitor: &mut V, _i: ExprReturn) -> ExprReturn { - ExprReturn { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - return_token: Token![return](tokens_helper(_visitor, &(_i.return_token).0)), - expr: (_i.expr).map(|it| Box::new(_visitor.fold_expr(*it))), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_struct(_visitor: &mut V, _i: ExprStruct) -> ExprStruct { - ExprStruct { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - path: _visitor.fold_path(_i.path), - brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), - fields: FoldHelper::lift(_i.fields, |it| _visitor.fold_field_value(it)), - dot2_token: (_i.dot2_token).map(|it| Token![..](tokens_helper(_visitor, &(it).0))), - rest: (_i.rest).map(|it| Box::new(_visitor.fold_expr(*it))), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_try(_visitor: &mut V, _i: ExprTry) -> ExprTry { - ExprTry { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - expr: Box::new(_visitor.fold_expr(*_i.expr)), - question_token: Token ! [ ? ](tokens_helper(_visitor, &(_i.question_token).0)), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_tuple(_visitor: &mut V, _i: ExprTuple) -> ExprTuple { - ExprTuple { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), - elems: FoldHelper::lift(_i.elems, |it| _visitor.fold_expr(it)), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_type(_visitor: &mut V, _i: ExprType) -> ExprType { - ExprType { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - expr: Box::new(_visitor.fold_expr(*_i.expr)), - colon_token: Token ! [ : ](tokens_helper(_visitor, &(_i.colon_token).0)), - ty: Box::new(_visitor.fold_type(*_i.ty)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_unary(_visitor: &mut V, _i: ExprUnary) -> ExprUnary { - ExprUnary { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - op: _visitor.fold_un_op(_i.op), - expr: Box::new(_visitor.fold_expr(*_i.expr)), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_unsafe(_visitor: &mut V, _i: ExprUnsafe) -> ExprUnsafe { - ExprUnsafe { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - unsafe_token: Token ! [ unsafe ](tokens_helper(_visitor, &(_i.unsafe_token).0)), - block: _visitor.fold_block(_i.block), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_verbatim(_visitor: &mut V, _i: ExprVerbatim) -> ExprVerbatim { - ExprVerbatim { tts: _i.tts } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_while(_visitor: &mut V, _i: ExprWhile) -> ExprWhile { - ExprWhile { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - label: (_i.label).map(|it| _visitor.fold_label(it)), - while_token: Token ! [ while ](tokens_helper(_visitor, &(_i.while_token).0)), - cond: Box::new(_visitor.fold_expr(*_i.cond)), - body: _visitor.fold_block(_i.body), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_while_let(_visitor: &mut V, _i: ExprWhileLet) -> ExprWhileLet { - ExprWhileLet { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - label: (_i.label).map(|it| _visitor.fold_label(it)), - while_token: Token ! [ while ](tokens_helper(_visitor, &(_i.while_token).0)), - let_token: Token ! [ let ](tokens_helper(_visitor, &(_i.let_token).0)), - pats: FoldHelper::lift(_i.pats, |it| _visitor.fold_pat(it)), - eq_token: Token ! [ = ](tokens_helper(_visitor, &(_i.eq_token).0)), - expr: Box::new(_visitor.fold_expr(*_i.expr)), - body: _visitor.fold_block(_i.body), - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_expr_yield(_visitor: &mut V, _i: ExprYield) -> ExprYield { - ExprYield { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - yield_token: Token![yield](tokens_helper(_visitor, &(_i.yield_token).0)), - expr: (_i.expr).map(|it| Box::new(_visitor.fold_expr(*it))), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_field(_visitor: &mut V, _i: Field) -> Field { - Field { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - vis: _visitor.fold_visibility(_i.vis), - ident: (_i.ident).map(|it| _visitor.fold_ident(it)), - colon_token: (_i.colon_token).map(|it| Token ! [ : ](tokens_helper(_visitor, &(it).0))), - ty: _visitor.fold_type(_i.ty), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_field_pat(_visitor: &mut V, _i: FieldPat) -> FieldPat { - FieldPat { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - member: _visitor.fold_member(_i.member), - colon_token: (_i.colon_token).map(|it| Token ! [ : ](tokens_helper(_visitor, &(it).0))), - pat: Box::new(_visitor.fold_pat(*_i.pat)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_field_value(_visitor: &mut V, _i: FieldValue) -> FieldValue { - FieldValue { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - member: _visitor.fold_member(_i.member), - colon_token: (_i.colon_token).map(|it| Token ! [ : ](tokens_helper(_visitor, &(it).0))), - expr: _visitor.fold_expr(_i.expr), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_fields(_visitor: &mut V, _i: Fields) -> Fields { - match _i { - Fields::Named(_binding_0) => Fields::Named(_visitor.fold_fields_named(_binding_0)), - Fields::Unnamed(_binding_0) => Fields::Unnamed(_visitor.fold_fields_unnamed(_binding_0)), - Fields::Unit => Fields::Unit, - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_fields_named(_visitor: &mut V, _i: FieldsNamed) -> FieldsNamed { - FieldsNamed { - brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), - named: FoldHelper::lift(_i.named, |it| _visitor.fold_field(it)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_fields_unnamed(_visitor: &mut V, _i: FieldsUnnamed) -> FieldsUnnamed { - FieldsUnnamed { - paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), - unnamed: FoldHelper::lift(_i.unnamed, |it| _visitor.fold_field(it)), - } -} -#[cfg(feature = "full")] -pub fn fold_file(_visitor: &mut V, _i: File) -> File { - File { - shebang: _i.shebang, - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - items: FoldHelper::lift(_i.items, |it| _visitor.fold_item(it)), - } -} -#[cfg(feature = "full")] -pub fn fold_fn_arg(_visitor: &mut V, _i: FnArg) -> FnArg { - match _i { - FnArg::SelfRef(_binding_0) => FnArg::SelfRef(_visitor.fold_arg_self_ref(_binding_0)), - FnArg::SelfValue(_binding_0) => FnArg::SelfValue(_visitor.fold_arg_self(_binding_0)), - FnArg::Captured(_binding_0) => FnArg::Captured(_visitor.fold_arg_captured(_binding_0)), - FnArg::Inferred(_binding_0) => FnArg::Inferred(_visitor.fold_pat(_binding_0)), - FnArg::Ignored(_binding_0) => FnArg::Ignored(_visitor.fold_type(_binding_0)), - } -} -#[cfg(feature = "full")] -pub fn fold_fn_decl(_visitor: &mut V, _i: FnDecl) -> FnDecl { - FnDecl { - fn_token: Token ! [ fn ](tokens_helper(_visitor, &(_i.fn_token).0)), - generics: _visitor.fold_generics(_i.generics), - paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), - inputs: FoldHelper::lift(_i.inputs, |it| _visitor.fold_fn_arg(it)), - variadic: (_i.variadic).map(|it| Token ! [ ... ](tokens_helper(_visitor, &(it).0))), - output: _visitor.fold_return_type(_i.output), - } -} -#[cfg(feature = "full")] -pub fn fold_foreign_item(_visitor: &mut V, _i: ForeignItem) -> ForeignItem { - match _i { - ForeignItem::Fn(_binding_0) => ForeignItem::Fn(_visitor.fold_foreign_item_fn(_binding_0)), - ForeignItem::Static(_binding_0) => { - ForeignItem::Static(_visitor.fold_foreign_item_static(_binding_0)) - } - ForeignItem::Type(_binding_0) => { - ForeignItem::Type(_visitor.fold_foreign_item_type(_binding_0)) - } - ForeignItem::Verbatim(_binding_0) => { - ForeignItem::Verbatim(_visitor.fold_foreign_item_verbatim(_binding_0)) - } - } -} -#[cfg(feature = "full")] -pub fn fold_foreign_item_fn( - _visitor: &mut V, - _i: ForeignItemFn, -) -> ForeignItemFn { - ForeignItemFn { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - vis: _visitor.fold_visibility(_i.vis), - ident: _visitor.fold_ident(_i.ident), - decl: Box::new(_visitor.fold_fn_decl(*_i.decl)), - semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), - } -} -#[cfg(feature = "full")] -pub fn fold_foreign_item_static( - _visitor: &mut V, - _i: ForeignItemStatic, -) -> ForeignItemStatic { - ForeignItemStatic { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - vis: _visitor.fold_visibility(_i.vis), - static_token: Token ! [ static ](tokens_helper(_visitor, &(_i.static_token).0)), - mutability: (_i.mutability).map(|it| Token ! [ mut ](tokens_helper(_visitor, &(it).0))), - ident: _visitor.fold_ident(_i.ident), - colon_token: Token ! [ : ](tokens_helper(_visitor, &(_i.colon_token).0)), - ty: Box::new(_visitor.fold_type(*_i.ty)), - semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), - } -} -#[cfg(feature = "full")] -pub fn fold_foreign_item_type( - _visitor: &mut V, - _i: ForeignItemType, -) -> ForeignItemType { - ForeignItemType { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - vis: _visitor.fold_visibility(_i.vis), - type_token: Token ! [ type ](tokens_helper(_visitor, &(_i.type_token).0)), - ident: _visitor.fold_ident(_i.ident), - semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), - } -} -#[cfg(feature = "full")] -pub fn fold_foreign_item_verbatim( - _visitor: &mut V, - _i: ForeignItemVerbatim, -) -> ForeignItemVerbatim { - ForeignItemVerbatim { tts: _i.tts } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_generic_argument( - _visitor: &mut V, - _i: GenericArgument, -) -> GenericArgument { - match _i { - GenericArgument::Lifetime(_binding_0) => { - GenericArgument::Lifetime(_visitor.fold_lifetime(_binding_0)) - } - GenericArgument::Type(_binding_0) => GenericArgument::Type(_visitor.fold_type(_binding_0)), - GenericArgument::Binding(_binding_0) => { - GenericArgument::Binding(_visitor.fold_binding(_binding_0)) - } - GenericArgument::Const(_binding_0) => { - GenericArgument::Const(_visitor.fold_expr(_binding_0)) - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_generic_method_argument( - _visitor: &mut V, - _i: GenericMethodArgument, -) -> GenericMethodArgument { - match _i { - GenericMethodArgument::Type(_binding_0) => { - GenericMethodArgument::Type(_visitor.fold_type(_binding_0)) - } - GenericMethodArgument::Const(_binding_0) => { - GenericMethodArgument::Const(_visitor.fold_expr(_binding_0)) - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_generic_param(_visitor: &mut V, _i: GenericParam) -> GenericParam { - match _i { - GenericParam::Type(_binding_0) => GenericParam::Type(_visitor.fold_type_param(_binding_0)), - GenericParam::Lifetime(_binding_0) => { - GenericParam::Lifetime(_visitor.fold_lifetime_def(_binding_0)) - } - GenericParam::Const(_binding_0) => { - GenericParam::Const(_visitor.fold_const_param(_binding_0)) - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_generics(_visitor: &mut V, _i: Generics) -> Generics { - Generics { - lt_token: (_i.lt_token).map(|it| Token ! [ < ](tokens_helper(_visitor, &(it).0))), - params: FoldHelper::lift(_i.params, |it| _visitor.fold_generic_param(it)), - gt_token: (_i.gt_token).map(|it| Token ! [ > ](tokens_helper(_visitor, &(it).0))), - where_clause: (_i.where_clause).map(|it| _visitor.fold_where_clause(it)), - } -} -pub fn fold_ident(_visitor: &mut V, _i: Ident) -> Ident { - let mut _i = _i; - let span = _visitor.fold_span(_i.span()); - _i.set_span(span); - _i -} -#[cfg(feature = "full")] -pub fn fold_impl_item(_visitor: &mut V, _i: ImplItem) -> ImplItem { - match _i { - ImplItem::Const(_binding_0) => ImplItem::Const(_visitor.fold_impl_item_const(_binding_0)), - ImplItem::Method(_binding_0) => { - ImplItem::Method(_visitor.fold_impl_item_method(_binding_0)) - } - ImplItem::Type(_binding_0) => ImplItem::Type(_visitor.fold_impl_item_type(_binding_0)), - ImplItem::Macro(_binding_0) => ImplItem::Macro(_visitor.fold_impl_item_macro(_binding_0)), - ImplItem::Verbatim(_binding_0) => { - ImplItem::Verbatim(_visitor.fold_impl_item_verbatim(_binding_0)) - } - } -} -#[cfg(feature = "full")] -pub fn fold_impl_item_const( - _visitor: &mut V, - _i: ImplItemConst, -) -> ImplItemConst { - ImplItemConst { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - vis: _visitor.fold_visibility(_i.vis), - defaultness: (_i.defaultness).map(|it| Token![default](tokens_helper(_visitor, &(it).0))), - const_token: Token ! [ const ](tokens_helper(_visitor, &(_i.const_token).0)), - ident: _visitor.fold_ident(_i.ident), - colon_token: Token ! [ : ](tokens_helper(_visitor, &(_i.colon_token).0)), - ty: _visitor.fold_type(_i.ty), - eq_token: Token ! [ = ](tokens_helper(_visitor, &(_i.eq_token).0)), - expr: _visitor.fold_expr(_i.expr), - semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), - } -} -#[cfg(feature = "full")] -pub fn fold_impl_item_macro( - _visitor: &mut V, - _i: ImplItemMacro, -) -> ImplItemMacro { - ImplItemMacro { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - mac: _visitor.fold_macro(_i.mac), - semi_token: (_i.semi_token).map(|it| Token ! [ ; ](tokens_helper(_visitor, &(it).0))), - } -} -#[cfg(feature = "full")] -pub fn fold_impl_item_method( - _visitor: &mut V, - _i: ImplItemMethod, -) -> ImplItemMethod { - ImplItemMethod { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - vis: _visitor.fold_visibility(_i.vis), - defaultness: (_i.defaultness).map(|it| Token![default](tokens_helper(_visitor, &(it).0))), - sig: _visitor.fold_method_sig(_i.sig), - block: _visitor.fold_block(_i.block), - } -} -#[cfg(feature = "full")] -pub fn fold_impl_item_type(_visitor: &mut V, _i: ImplItemType) -> ImplItemType { - ImplItemType { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - vis: _visitor.fold_visibility(_i.vis), - defaultness: (_i.defaultness).map(|it| Token![default](tokens_helper(_visitor, &(it).0))), - type_token: Token ! [ type ](tokens_helper(_visitor, &(_i.type_token).0)), - ident: _visitor.fold_ident(_i.ident), - generics: _visitor.fold_generics(_i.generics), - eq_token: Token ! [ = ](tokens_helper(_visitor, &(_i.eq_token).0)), - ty: _visitor.fold_type(_i.ty), - semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), - } -} -#[cfg(feature = "full")] -pub fn fold_impl_item_verbatim( - _visitor: &mut V, - _i: ImplItemVerbatim, -) -> ImplItemVerbatim { - ImplItemVerbatim { tts: _i.tts } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_index(_visitor: &mut V, _i: Index) -> Index { - Index { - index: _i.index, - span: _visitor.fold_span(_i.span), - } -} -#[cfg(feature = "full")] -pub fn fold_item(_visitor: &mut V, _i: Item) -> Item { - match _i { - Item::ExternCrate(_binding_0) => { - Item::ExternCrate(_visitor.fold_item_extern_crate(_binding_0)) - } - Item::Use(_binding_0) => Item::Use(_visitor.fold_item_use(_binding_0)), - Item::Static(_binding_0) => Item::Static(_visitor.fold_item_static(_binding_0)), - Item::Const(_binding_0) => Item::Const(_visitor.fold_item_const(_binding_0)), - Item::Fn(_binding_0) => Item::Fn(_visitor.fold_item_fn(_binding_0)), - Item::Mod(_binding_0) => Item::Mod(_visitor.fold_item_mod(_binding_0)), - Item::ForeignMod(_binding_0) => { - Item::ForeignMod(_visitor.fold_item_foreign_mod(_binding_0)) - } - Item::Type(_binding_0) => Item::Type(_visitor.fold_item_type(_binding_0)), - Item::Struct(_binding_0) => Item::Struct(_visitor.fold_item_struct(_binding_0)), - Item::Enum(_binding_0) => Item::Enum(_visitor.fold_item_enum(_binding_0)), - Item::Union(_binding_0) => Item::Union(_visitor.fold_item_union(_binding_0)), - Item::Trait(_binding_0) => Item::Trait(_visitor.fold_item_trait(_binding_0)), - Item::Impl(_binding_0) => Item::Impl(_visitor.fold_item_impl(_binding_0)), - Item::Macro(_binding_0) => Item::Macro(_visitor.fold_item_macro(_binding_0)), - Item::Macro2(_binding_0) => Item::Macro2(_visitor.fold_item_macro2(_binding_0)), - Item::Verbatim(_binding_0) => Item::Verbatim(_visitor.fold_item_verbatim(_binding_0)), - } -} -#[cfg(feature = "full")] -pub fn fold_item_const(_visitor: &mut V, _i: ItemConst) -> ItemConst { - ItemConst { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - vis: _visitor.fold_visibility(_i.vis), - const_token: Token ! [ const ](tokens_helper(_visitor, &(_i.const_token).0)), - ident: _visitor.fold_ident(_i.ident), - colon_token: Token ! [ : ](tokens_helper(_visitor, &(_i.colon_token).0)), - ty: Box::new(_visitor.fold_type(*_i.ty)), - eq_token: Token ! [ = ](tokens_helper(_visitor, &(_i.eq_token).0)), - expr: Box::new(_visitor.fold_expr(*_i.expr)), - semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), - } -} -#[cfg(feature = "full")] -pub fn fold_item_enum(_visitor: &mut V, _i: ItemEnum) -> ItemEnum { - ItemEnum { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - vis: _visitor.fold_visibility(_i.vis), - enum_token: Token ! [ enum ](tokens_helper(_visitor, &(_i.enum_token).0)), - ident: _visitor.fold_ident(_i.ident), - generics: _visitor.fold_generics(_i.generics), - brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), - variants: FoldHelper::lift(_i.variants, |it| _visitor.fold_variant(it)), - } -} -#[cfg(feature = "full")] -pub fn fold_item_extern_crate( - _visitor: &mut V, - _i: ItemExternCrate, -) -> ItemExternCrate { - ItemExternCrate { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - vis: _visitor.fold_visibility(_i.vis), - extern_token: Token![extern](tokens_helper(_visitor, &(_i.extern_token).0)), - crate_token: Token![crate](tokens_helper(_visitor, &(_i.crate_token).0)), - ident: _visitor.fold_ident(_i.ident), - rename: (_i.rename).map(|it| { - ( - Token ! [ as ](tokens_helper(_visitor, &((it).0).0)), - _visitor.fold_ident((it).1), - ) - }), - semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), - } -} -#[cfg(feature = "full")] -pub fn fold_item_fn(_visitor: &mut V, _i: ItemFn) -> ItemFn { - ItemFn { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - vis: _visitor.fold_visibility(_i.vis), - constness: (_i.constness).map(|it| Token ! [ const ](tokens_helper(_visitor, &(it).0))), - unsafety: (_i.unsafety).map(|it| Token ! [ unsafe ](tokens_helper(_visitor, &(it).0))), - abi: (_i.abi).map(|it| _visitor.fold_abi(it)), - ident: _visitor.fold_ident(_i.ident), - decl: Box::new(_visitor.fold_fn_decl(*_i.decl)), - block: Box::new(_visitor.fold_block(*_i.block)), - } -} -#[cfg(feature = "full")] -pub fn fold_item_foreign_mod( - _visitor: &mut V, - _i: ItemForeignMod, -) -> ItemForeignMod { - ItemForeignMod { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - abi: _visitor.fold_abi(_i.abi), - brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), - items: FoldHelper::lift(_i.items, |it| _visitor.fold_foreign_item(it)), - } -} -#[cfg(feature = "full")] -pub fn fold_item_impl(_visitor: &mut V, _i: ItemImpl) -> ItemImpl { - ItemImpl { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - defaultness: (_i.defaultness).map(|it| Token![default](tokens_helper(_visitor, &(it).0))), - unsafety: (_i.unsafety).map(|it| Token ! [ unsafe ](tokens_helper(_visitor, &(it).0))), - impl_token: Token![impl ](tokens_helper(_visitor, &(_i.impl_token).0)), - generics: _visitor.fold_generics(_i.generics), - trait_: (_i.trait_).map(|it| { - ( - ((it).0).map(|it| Token![!](tokens_helper(_visitor, &(it).0))), - _visitor.fold_path((it).1), - Token ! [ for ](tokens_helper(_visitor, &((it).2).0)), - ) - }), - self_ty: Box::new(_visitor.fold_type(*_i.self_ty)), - brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), - items: FoldHelper::lift(_i.items, |it| _visitor.fold_impl_item(it)), - } -} -#[cfg(feature = "full")] -pub fn fold_item_macro(_visitor: &mut V, _i: ItemMacro) -> ItemMacro { - ItemMacro { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - ident: (_i.ident).map(|it| _visitor.fold_ident(it)), - mac: _visitor.fold_macro(_i.mac), - semi_token: (_i.semi_token).map(|it| Token ! [ ; ](tokens_helper(_visitor, &(it).0))), - } -} -#[cfg(feature = "full")] -pub fn fold_item_macro2(_visitor: &mut V, _i: ItemMacro2) -> ItemMacro2 { - ItemMacro2 { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - vis: _visitor.fold_visibility(_i.vis), - macro_token: Token ! [ macro ](tokens_helper(_visitor, &(_i.macro_token).0)), - ident: _visitor.fold_ident(_i.ident), - paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), - args: _i.args, - brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), - body: _i.body, - } -} -#[cfg(feature = "full")] -pub fn fold_item_mod(_visitor: &mut V, _i: ItemMod) -> ItemMod { - ItemMod { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - vis: _visitor.fold_visibility(_i.vis), - mod_token: Token ! [ mod ](tokens_helper(_visitor, &(_i.mod_token).0)), - ident: _visitor.fold_ident(_i.ident), - content: (_i.content).map(|it| { - ( - Brace(tokens_helper(_visitor, &((it).0).0)), - FoldHelper::lift((it).1, |it| _visitor.fold_item(it)), - ) - }), - semi: (_i.semi).map(|it| Token ! [ ; ](tokens_helper(_visitor, &(it).0))), - } -} -#[cfg(feature = "full")] -pub fn fold_item_static(_visitor: &mut V, _i: ItemStatic) -> ItemStatic { - ItemStatic { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - vis: _visitor.fold_visibility(_i.vis), - static_token: Token ! [ static ](tokens_helper(_visitor, &(_i.static_token).0)), - mutability: (_i.mutability).map(|it| Token ! [ mut ](tokens_helper(_visitor, &(it).0))), - ident: _visitor.fold_ident(_i.ident), - colon_token: Token ! [ : ](tokens_helper(_visitor, &(_i.colon_token).0)), - ty: Box::new(_visitor.fold_type(*_i.ty)), - eq_token: Token ! [ = ](tokens_helper(_visitor, &(_i.eq_token).0)), - expr: Box::new(_visitor.fold_expr(*_i.expr)), - semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), - } -} -#[cfg(feature = "full")] -pub fn fold_item_struct(_visitor: &mut V, _i: ItemStruct) -> ItemStruct { - ItemStruct { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - vis: _visitor.fold_visibility(_i.vis), - struct_token: Token ! [ struct ](tokens_helper(_visitor, &(_i.struct_token).0)), - ident: _visitor.fold_ident(_i.ident), - generics: _visitor.fold_generics(_i.generics), - fields: _visitor.fold_fields(_i.fields), - semi_token: (_i.semi_token).map(|it| Token ! [ ; ](tokens_helper(_visitor, &(it).0))), - } -} -#[cfg(feature = "full")] -pub fn fold_item_trait(_visitor: &mut V, _i: ItemTrait) -> ItemTrait { - ItemTrait { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - vis: _visitor.fold_visibility(_i.vis), - unsafety: (_i.unsafety).map(|it| Token ! [ unsafe ](tokens_helper(_visitor, &(it).0))), - auto_token: (_i.auto_token).map(|it| Token![auto](tokens_helper(_visitor, &(it).0))), - trait_token: Token ! [ trait ](tokens_helper(_visitor, &(_i.trait_token).0)), - ident: _visitor.fold_ident(_i.ident), - generics: _visitor.fold_generics(_i.generics), - colon_token: (_i.colon_token).map(|it| Token ! [ : ](tokens_helper(_visitor, &(it).0))), - supertraits: FoldHelper::lift(_i.supertraits, |it| _visitor.fold_type_param_bound(it)), - brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), - items: FoldHelper::lift(_i.items, |it| _visitor.fold_trait_item(it)), - } -} -#[cfg(feature = "full")] -pub fn fold_item_type(_visitor: &mut V, _i: ItemType) -> ItemType { - ItemType { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - vis: _visitor.fold_visibility(_i.vis), - type_token: Token ! [ type ](tokens_helper(_visitor, &(_i.type_token).0)), - ident: _visitor.fold_ident(_i.ident), - generics: _visitor.fold_generics(_i.generics), - eq_token: Token ! [ = ](tokens_helper(_visitor, &(_i.eq_token).0)), - ty: Box::new(_visitor.fold_type(*_i.ty)), - semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), - } -} -#[cfg(feature = "full")] -pub fn fold_item_union(_visitor: &mut V, _i: ItemUnion) -> ItemUnion { - ItemUnion { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - vis: _visitor.fold_visibility(_i.vis), - union_token: Token![union](tokens_helper(_visitor, &(_i.union_token).0)), - ident: _visitor.fold_ident(_i.ident), - generics: _visitor.fold_generics(_i.generics), - fields: _visitor.fold_fields_named(_i.fields), - } -} -#[cfg(feature = "full")] -pub fn fold_item_use(_visitor: &mut V, _i: ItemUse) -> ItemUse { - ItemUse { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - vis: _visitor.fold_visibility(_i.vis), - use_token: Token ! [ use ](tokens_helper(_visitor, &(_i.use_token).0)), - leading_colon: (_i.leading_colon) - .map(|it| Token ! [ :: ](tokens_helper(_visitor, &(it).0))), - tree: _visitor.fold_use_tree(_i.tree), - semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), - } -} -#[cfg(feature = "full")] -pub fn fold_item_verbatim(_visitor: &mut V, _i: ItemVerbatim) -> ItemVerbatim { - ItemVerbatim { tts: _i.tts } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_label(_visitor: &mut V, _i: Label) -> Label { - Label { - name: _visitor.fold_lifetime(_i.name), - colon_token: Token ! [ : ](tokens_helper(_visitor, &(_i.colon_token).0)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_lifetime(_visitor: &mut V, _i: Lifetime) -> Lifetime { - Lifetime { - apostrophe: _i.apostrophe, - ident: _visitor.fold_ident(_i.ident), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_lifetime_def(_visitor: &mut V, _i: LifetimeDef) -> LifetimeDef { - LifetimeDef { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - lifetime: _visitor.fold_lifetime(_i.lifetime), - colon_token: (_i.colon_token).map(|it| Token ! [ : ](tokens_helper(_visitor, &(it).0))), - bounds: FoldHelper::lift(_i.bounds, |it| _visitor.fold_lifetime(it)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_lit(_visitor: &mut V, _i: Lit) -> Lit { - match _i { - Lit::Str(_binding_0) => Lit::Str(_visitor.fold_lit_str(_binding_0)), - Lit::ByteStr(_binding_0) => Lit::ByteStr(_visitor.fold_lit_byte_str(_binding_0)), - Lit::Byte(_binding_0) => Lit::Byte(_visitor.fold_lit_byte(_binding_0)), - Lit::Char(_binding_0) => Lit::Char(_visitor.fold_lit_char(_binding_0)), - Lit::Int(_binding_0) => Lit::Int(_visitor.fold_lit_int(_binding_0)), - Lit::Float(_binding_0) => Lit::Float(_visitor.fold_lit_float(_binding_0)), - Lit::Bool(_binding_0) => Lit::Bool(_visitor.fold_lit_bool(_binding_0)), - Lit::Verbatim(_binding_0) => Lit::Verbatim(_visitor.fold_lit_verbatim(_binding_0)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_lit_bool(_visitor: &mut V, _i: LitBool) -> LitBool { - LitBool { - value: _i.value, - span: _visitor.fold_span(_i.span), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_lit_verbatim(_visitor: &mut V, _i: LitVerbatim) -> LitVerbatim { - LitVerbatim { token: _i.token } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_local(_visitor: &mut V, _i: Local) -> Local { - Local { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - let_token: Token ! [ let ](tokens_helper(_visitor, &(_i.let_token).0)), - pats: FoldHelper::lift(_i.pats, |it| _visitor.fold_pat(it)), - ty: (_i.ty).map(|it| { - ( - Token ! [ : ](tokens_helper(_visitor, &((it).0).0)), - Box::new(_visitor.fold_type(*(it).1)), - ) - }), - init: (_i.init).map(|it| { - ( - Token ! [ = ](tokens_helper(_visitor, &((it).0).0)), - Box::new(_visitor.fold_expr(*(it).1)), - ) - }), - semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_macro(_visitor: &mut V, _i: Macro) -> Macro { - Macro { - path: _visitor.fold_path(_i.path), - bang_token: Token![!](tokens_helper(_visitor, &(_i.bang_token).0)), - delimiter: _visitor.fold_macro_delimiter(_i.delimiter), - tts: _i.tts, - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_macro_delimiter( - _visitor: &mut V, - _i: MacroDelimiter, -) -> MacroDelimiter { - match _i { - MacroDelimiter::Paren(_binding_0) => { - MacroDelimiter::Paren(Paren(tokens_helper(_visitor, &(_binding_0).0))) - } - MacroDelimiter::Brace(_binding_0) => { - MacroDelimiter::Brace(Brace(tokens_helper(_visitor, &(_binding_0).0))) - } - MacroDelimiter::Bracket(_binding_0) => { - MacroDelimiter::Bracket(Bracket(tokens_helper(_visitor, &(_binding_0).0))) - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_member(_visitor: &mut V, _i: Member) -> Member { - match _i { - Member::Named(_binding_0) => Member::Named(_visitor.fold_ident(_binding_0)), - Member::Unnamed(_binding_0) => Member::Unnamed(_visitor.fold_index(_binding_0)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_meta(_visitor: &mut V, _i: Meta) -> Meta { - match _i { - Meta::Word(_binding_0) => Meta::Word(_visitor.fold_ident(_binding_0)), - Meta::List(_binding_0) => Meta::List(_visitor.fold_meta_list(_binding_0)), - Meta::NameValue(_binding_0) => Meta::NameValue(_visitor.fold_meta_name_value(_binding_0)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_meta_list(_visitor: &mut V, _i: MetaList) -> MetaList { - MetaList { - ident: _visitor.fold_ident(_i.ident), - paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), - nested: FoldHelper::lift(_i.nested, |it| _visitor.fold_nested_meta(it)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_meta_name_value( - _visitor: &mut V, - _i: MetaNameValue, -) -> MetaNameValue { - MetaNameValue { - ident: _visitor.fold_ident(_i.ident), - eq_token: Token ! [ = ](tokens_helper(_visitor, &(_i.eq_token).0)), - lit: _visitor.fold_lit(_i.lit), - } -} -#[cfg(feature = "full")] -pub fn fold_method_sig(_visitor: &mut V, _i: MethodSig) -> MethodSig { - MethodSig { - constness: (_i.constness).map(|it| Token ! [ const ](tokens_helper(_visitor, &(it).0))), - unsafety: (_i.unsafety).map(|it| Token ! [ unsafe ](tokens_helper(_visitor, &(it).0))), - abi: (_i.abi).map(|it| _visitor.fold_abi(it)), - ident: _visitor.fold_ident(_i.ident), - decl: _visitor.fold_fn_decl(_i.decl), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_method_turbofish( - _visitor: &mut V, - _i: MethodTurbofish, -) -> MethodTurbofish { - MethodTurbofish { - colon2_token: Token ! [ :: ](tokens_helper(_visitor, &(_i.colon2_token).0)), - lt_token: Token ! [ < ](tokens_helper(_visitor, &(_i.lt_token).0)), - args: FoldHelper::lift(_i.args, |it| _visitor.fold_generic_method_argument(it)), - gt_token: Token ! [ > ](tokens_helper(_visitor, &(_i.gt_token).0)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_nested_meta(_visitor: &mut V, _i: NestedMeta) -> NestedMeta { - match _i { - NestedMeta::Meta(_binding_0) => NestedMeta::Meta(_visitor.fold_meta(_binding_0)), - NestedMeta::Literal(_binding_0) => NestedMeta::Literal(_visitor.fold_lit(_binding_0)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_parenthesized_generic_arguments( - _visitor: &mut V, - _i: ParenthesizedGenericArguments, -) -> ParenthesizedGenericArguments { - ParenthesizedGenericArguments { - paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), - inputs: FoldHelper::lift(_i.inputs, |it| _visitor.fold_type(it)), - output: _visitor.fold_return_type(_i.output), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_pat(_visitor: &mut V, _i: Pat) -> Pat { - match _i { - Pat::Wild(_binding_0) => Pat::Wild(_visitor.fold_pat_wild(_binding_0)), - Pat::Ident(_binding_0) => Pat::Ident(_visitor.fold_pat_ident(_binding_0)), - Pat::Struct(_binding_0) => Pat::Struct(_visitor.fold_pat_struct(_binding_0)), - Pat::TupleStruct(_binding_0) => { - Pat::TupleStruct(_visitor.fold_pat_tuple_struct(_binding_0)) - } - Pat::Path(_binding_0) => Pat::Path(_visitor.fold_pat_path(_binding_0)), - Pat::Tuple(_binding_0) => Pat::Tuple(_visitor.fold_pat_tuple(_binding_0)), - Pat::Box(_binding_0) => Pat::Box(_visitor.fold_pat_box(_binding_0)), - Pat::Ref(_binding_0) => Pat::Ref(_visitor.fold_pat_ref(_binding_0)), - Pat::Lit(_binding_0) => Pat::Lit(_visitor.fold_pat_lit(_binding_0)), - Pat::Range(_binding_0) => Pat::Range(_visitor.fold_pat_range(_binding_0)), - Pat::Slice(_binding_0) => Pat::Slice(_visitor.fold_pat_slice(_binding_0)), - Pat::Macro(_binding_0) => Pat::Macro(_visitor.fold_pat_macro(_binding_0)), - Pat::Verbatim(_binding_0) => Pat::Verbatim(_visitor.fold_pat_verbatim(_binding_0)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_pat_box(_visitor: &mut V, _i: PatBox) -> PatBox { - PatBox { - box_token: Token ! [ box ](tokens_helper(_visitor, &(_i.box_token).0)), - pat: Box::new(_visitor.fold_pat(*_i.pat)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_pat_ident(_visitor: &mut V, _i: PatIdent) -> PatIdent { - PatIdent { - by_ref: (_i.by_ref).map(|it| Token ! [ ref ](tokens_helper(_visitor, &(it).0))), - mutability: (_i.mutability).map(|it| Token ! [ mut ](tokens_helper(_visitor, &(it).0))), - ident: _visitor.fold_ident(_i.ident), - subpat: (_i.subpat).map(|it| { - ( - Token ! [ @ ](tokens_helper(_visitor, &((it).0).0)), - Box::new(_visitor.fold_pat(*(it).1)), - ) - }), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_pat_lit(_visitor: &mut V, _i: PatLit) -> PatLit { - PatLit { - expr: Box::new(_visitor.fold_expr(*_i.expr)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_pat_macro(_visitor: &mut V, _i: PatMacro) -> PatMacro { - PatMacro { - mac: _visitor.fold_macro(_i.mac), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_pat_path(_visitor: &mut V, _i: PatPath) -> PatPath { - PatPath { - qself: (_i.qself).map(|it| _visitor.fold_qself(it)), - path: _visitor.fold_path(_i.path), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_pat_range(_visitor: &mut V, _i: PatRange) -> PatRange { - PatRange { - lo: Box::new(_visitor.fold_expr(*_i.lo)), - limits: _visitor.fold_range_limits(_i.limits), - hi: Box::new(_visitor.fold_expr(*_i.hi)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_pat_ref(_visitor: &mut V, _i: PatRef) -> PatRef { - PatRef { - and_token: Token ! [ & ](tokens_helper(_visitor, &(_i.and_token).0)), - mutability: (_i.mutability).map(|it| Token ! [ mut ](tokens_helper(_visitor, &(it).0))), - pat: Box::new(_visitor.fold_pat(*_i.pat)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_pat_slice(_visitor: &mut V, _i: PatSlice) -> PatSlice { - PatSlice { - bracket_token: Bracket(tokens_helper(_visitor, &(_i.bracket_token).0)), - front: FoldHelper::lift(_i.front, |it| _visitor.fold_pat(it)), - middle: (_i.middle).map(|it| Box::new(_visitor.fold_pat(*it))), - dot2_token: (_i.dot2_token).map(|it| Token![..](tokens_helper(_visitor, &(it).0))), - comma_token: (_i.comma_token).map(|it| Token ! [ , ](tokens_helper(_visitor, &(it).0))), - back: FoldHelper::lift(_i.back, |it| _visitor.fold_pat(it)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_pat_struct(_visitor: &mut V, _i: PatStruct) -> PatStruct { - PatStruct { - path: _visitor.fold_path(_i.path), - brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), - fields: FoldHelper::lift(_i.fields, |it| _visitor.fold_field_pat(it)), - dot2_token: (_i.dot2_token).map(|it| Token![..](tokens_helper(_visitor, &(it).0))), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_pat_tuple(_visitor: &mut V, _i: PatTuple) -> PatTuple { - PatTuple { - paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), - front: FoldHelper::lift(_i.front, |it| _visitor.fold_pat(it)), - dot2_token: (_i.dot2_token).map(|it| Token![..](tokens_helper(_visitor, &(it).0))), - comma_token: (_i.comma_token).map(|it| Token ! [ , ](tokens_helper(_visitor, &(it).0))), - back: FoldHelper::lift(_i.back, |it| _visitor.fold_pat(it)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_pat_tuple_struct( - _visitor: &mut V, - _i: PatTupleStruct, -) -> PatTupleStruct { - PatTupleStruct { - path: _visitor.fold_path(_i.path), - pat: _visitor.fold_pat_tuple(_i.pat), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_pat_verbatim(_visitor: &mut V, _i: PatVerbatim) -> PatVerbatim { - PatVerbatim { tts: _i.tts } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_pat_wild(_visitor: &mut V, _i: PatWild) -> PatWild { - PatWild { - underscore_token: Token![_](tokens_helper(_visitor, &(_i.underscore_token).0)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_path(_visitor: &mut V, _i: Path) -> Path { - Path { - leading_colon: (_i.leading_colon) - .map(|it| Token ! [ :: ](tokens_helper(_visitor, &(it).0))), - segments: FoldHelper::lift(_i.segments, |it| _visitor.fold_path_segment(it)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_path_arguments(_visitor: &mut V, _i: PathArguments) -> PathArguments { - match _i { - PathArguments::None => PathArguments::None, - PathArguments::AngleBracketed(_binding_0) => PathArguments::AngleBracketed( - _visitor.fold_angle_bracketed_generic_arguments(_binding_0), - ), - PathArguments::Parenthesized(_binding_0) => { - PathArguments::Parenthesized(_visitor.fold_parenthesized_generic_arguments(_binding_0)) - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_path_segment(_visitor: &mut V, _i: PathSegment) -> PathSegment { - PathSegment { - ident: _visitor.fold_ident(_i.ident), - arguments: _visitor.fold_path_arguments(_i.arguments), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_predicate_eq(_visitor: &mut V, _i: PredicateEq) -> PredicateEq { - PredicateEq { - lhs_ty: _visitor.fold_type(_i.lhs_ty), - eq_token: Token ! [ = ](tokens_helper(_visitor, &(_i.eq_token).0)), - rhs_ty: _visitor.fold_type(_i.rhs_ty), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_predicate_lifetime( - _visitor: &mut V, - _i: PredicateLifetime, -) -> PredicateLifetime { - PredicateLifetime { - lifetime: _visitor.fold_lifetime(_i.lifetime), - colon_token: (_i.colon_token).map(|it| Token ! [ : ](tokens_helper(_visitor, &(it).0))), - bounds: FoldHelper::lift(_i.bounds, |it| _visitor.fold_lifetime(it)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_predicate_type(_visitor: &mut V, _i: PredicateType) -> PredicateType { - PredicateType { - lifetimes: (_i.lifetimes).map(|it| _visitor.fold_bound_lifetimes(it)), - bounded_ty: _visitor.fold_type(_i.bounded_ty), - colon_token: Token ! [ : ](tokens_helper(_visitor, &(_i.colon_token).0)), - bounds: FoldHelper::lift(_i.bounds, |it| _visitor.fold_type_param_bound(it)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_qself(_visitor: &mut V, _i: QSelf) -> QSelf { - QSelf { - lt_token: Token ! [ < ](tokens_helper(_visitor, &(_i.lt_token).0)), - ty: Box::new(_visitor.fold_type(*_i.ty)), - position: _i.position, - as_token: (_i.as_token).map(|it| Token ! [ as ](tokens_helper(_visitor, &(it).0))), - gt_token: Token ! [ > ](tokens_helper(_visitor, &(_i.gt_token).0)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_range_limits(_visitor: &mut V, _i: RangeLimits) -> RangeLimits { - match _i { - RangeLimits::HalfOpen(_binding_0) => { - RangeLimits::HalfOpen(Token![..](tokens_helper(_visitor, &(_binding_0).0))) - } - RangeLimits::Closed(_binding_0) => { - RangeLimits::Closed(Token ! [ ..= ](tokens_helper(_visitor, &(_binding_0).0))) - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_return_type(_visitor: &mut V, _i: ReturnType) -> ReturnType { - match _i { - ReturnType::Default => ReturnType::Default, - ReturnType::Type(_binding_0, _binding_1) => ReturnType::Type( - Token ! [ -> ](tokens_helper(_visitor, &(_binding_0).0)), - Box::new(_visitor.fold_type(*_binding_1)), - ), - } -} -pub fn fold_span(_visitor: &mut V, _i: Span) -> Span { - _i -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn fold_stmt(_visitor: &mut V, _i: Stmt) -> Stmt { - match _i { - Stmt::Local(_binding_0) => Stmt::Local(_visitor.fold_local(_binding_0)), - Stmt::Item(_binding_0) => Stmt::Item(_visitor.fold_item(_binding_0)), - Stmt::Expr(_binding_0) => Stmt::Expr(_visitor.fold_expr(_binding_0)), - Stmt::Semi(_binding_0, _binding_1) => Stmt::Semi( - _visitor.fold_expr(_binding_0), - Token ! [ ; ](tokens_helper(_visitor, &(_binding_1).0)), - ), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_trait_bound(_visitor: &mut V, _i: TraitBound) -> TraitBound { - TraitBound { - paren_token: (_i.paren_token).map(|it| Paren(tokens_helper(_visitor, &(it).0))), - modifier: _visitor.fold_trait_bound_modifier(_i.modifier), - lifetimes: (_i.lifetimes).map(|it| _visitor.fold_bound_lifetimes(it)), - path: _visitor.fold_path(_i.path), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_trait_bound_modifier( - _visitor: &mut V, - _i: TraitBoundModifier, -) -> TraitBoundModifier { - match _i { - TraitBoundModifier::None => TraitBoundModifier::None, - TraitBoundModifier::Maybe(_binding_0) => { - TraitBoundModifier::Maybe(Token ! [ ? ](tokens_helper(_visitor, &(_binding_0).0))) - } - } -} -#[cfg(feature = "full")] -pub fn fold_trait_item(_visitor: &mut V, _i: TraitItem) -> TraitItem { - match _i { - TraitItem::Const(_binding_0) => { - TraitItem::Const(_visitor.fold_trait_item_const(_binding_0)) - } - TraitItem::Method(_binding_0) => { - TraitItem::Method(_visitor.fold_trait_item_method(_binding_0)) - } - TraitItem::Type(_binding_0) => TraitItem::Type(_visitor.fold_trait_item_type(_binding_0)), - TraitItem::Macro(_binding_0) => { - TraitItem::Macro(_visitor.fold_trait_item_macro(_binding_0)) - } - TraitItem::Verbatim(_binding_0) => { - TraitItem::Verbatim(_visitor.fold_trait_item_verbatim(_binding_0)) - } - } -} -#[cfg(feature = "full")] -pub fn fold_trait_item_const( - _visitor: &mut V, - _i: TraitItemConst, -) -> TraitItemConst { - TraitItemConst { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - const_token: Token ! [ const ](tokens_helper(_visitor, &(_i.const_token).0)), - ident: _visitor.fold_ident(_i.ident), - colon_token: Token ! [ : ](tokens_helper(_visitor, &(_i.colon_token).0)), - ty: _visitor.fold_type(_i.ty), - default: (_i.default).map(|it| { - ( - Token ! [ = ](tokens_helper(_visitor, &((it).0).0)), - _visitor.fold_expr((it).1), - ) - }), - semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), - } -} -#[cfg(feature = "full")] -pub fn fold_trait_item_macro( - _visitor: &mut V, - _i: TraitItemMacro, -) -> TraitItemMacro { - TraitItemMacro { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - mac: _visitor.fold_macro(_i.mac), - semi_token: (_i.semi_token).map(|it| Token ! [ ; ](tokens_helper(_visitor, &(it).0))), - } -} -#[cfg(feature = "full")] -pub fn fold_trait_item_method( - _visitor: &mut V, - _i: TraitItemMethod, -) -> TraitItemMethod { - TraitItemMethod { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - sig: _visitor.fold_method_sig(_i.sig), - default: (_i.default).map(|it| _visitor.fold_block(it)), - semi_token: (_i.semi_token).map(|it| Token ! [ ; ](tokens_helper(_visitor, &(it).0))), - } -} -#[cfg(feature = "full")] -pub fn fold_trait_item_type( - _visitor: &mut V, - _i: TraitItemType, -) -> TraitItemType { - TraitItemType { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - type_token: Token ! [ type ](tokens_helper(_visitor, &(_i.type_token).0)), - ident: _visitor.fold_ident(_i.ident), - generics: _visitor.fold_generics(_i.generics), - colon_token: (_i.colon_token).map(|it| Token ! [ : ](tokens_helper(_visitor, &(it).0))), - bounds: FoldHelper::lift(_i.bounds, |it| _visitor.fold_type_param_bound(it)), - default: (_i.default).map(|it| { - ( - Token ! [ = ](tokens_helper(_visitor, &((it).0).0)), - _visitor.fold_type((it).1), - ) - }), - semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), - } -} -#[cfg(feature = "full")] -pub fn fold_trait_item_verbatim( - _visitor: &mut V, - _i: TraitItemVerbatim, -) -> TraitItemVerbatim { - TraitItemVerbatim { tts: _i.tts } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_type(_visitor: &mut V, _i: Type) -> Type { - match _i { - Type::Slice(_binding_0) => Type::Slice(_visitor.fold_type_slice(_binding_0)), - Type::Array(_binding_0) => Type::Array(_visitor.fold_type_array(_binding_0)), - Type::Ptr(_binding_0) => Type::Ptr(_visitor.fold_type_ptr(_binding_0)), - Type::Reference(_binding_0) => Type::Reference(_visitor.fold_type_reference(_binding_0)), - Type::BareFn(_binding_0) => Type::BareFn(_visitor.fold_type_bare_fn(_binding_0)), - Type::Never(_binding_0) => Type::Never(_visitor.fold_type_never(_binding_0)), - Type::Tuple(_binding_0) => Type::Tuple(_visitor.fold_type_tuple(_binding_0)), - Type::Path(_binding_0) => Type::Path(_visitor.fold_type_path(_binding_0)), - Type::TraitObject(_binding_0) => { - Type::TraitObject(_visitor.fold_type_trait_object(_binding_0)) - } - Type::ImplTrait(_binding_0) => Type::ImplTrait(_visitor.fold_type_impl_trait(_binding_0)), - Type::Paren(_binding_0) => Type::Paren(_visitor.fold_type_paren(_binding_0)), - Type::Group(_binding_0) => Type::Group(_visitor.fold_type_group(_binding_0)), - Type::Infer(_binding_0) => Type::Infer(_visitor.fold_type_infer(_binding_0)), - Type::Macro(_binding_0) => Type::Macro(_visitor.fold_type_macro(_binding_0)), - Type::Verbatim(_binding_0) => Type::Verbatim(_visitor.fold_type_verbatim(_binding_0)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_type_array(_visitor: &mut V, _i: TypeArray) -> TypeArray { - TypeArray { - bracket_token: Bracket(tokens_helper(_visitor, &(_i.bracket_token).0)), - elem: Box::new(_visitor.fold_type(*_i.elem)), - semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), - len: _visitor.fold_expr(_i.len), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_type_bare_fn(_visitor: &mut V, _i: TypeBareFn) -> TypeBareFn { - TypeBareFn { - unsafety: (_i.unsafety).map(|it| Token ! [ unsafe ](tokens_helper(_visitor, &(it).0))), - abi: (_i.abi).map(|it| _visitor.fold_abi(it)), - fn_token: Token ! [ fn ](tokens_helper(_visitor, &(_i.fn_token).0)), - lifetimes: (_i.lifetimes).map(|it| _visitor.fold_bound_lifetimes(it)), - paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), - inputs: FoldHelper::lift(_i.inputs, |it| _visitor.fold_bare_fn_arg(it)), - variadic: (_i.variadic).map(|it| Token ! [ ... ](tokens_helper(_visitor, &(it).0))), - output: _visitor.fold_return_type(_i.output), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_type_group(_visitor: &mut V, _i: TypeGroup) -> TypeGroup { - TypeGroup { - group_token: Group(tokens_helper(_visitor, &(_i.group_token).0)), - elem: Box::new(_visitor.fold_type(*_i.elem)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_type_impl_trait( - _visitor: &mut V, - _i: TypeImplTrait, -) -> TypeImplTrait { - TypeImplTrait { - impl_token: Token![impl ](tokens_helper(_visitor, &(_i.impl_token).0)), - bounds: FoldHelper::lift(_i.bounds, |it| _visitor.fold_type_param_bound(it)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_type_infer(_visitor: &mut V, _i: TypeInfer) -> TypeInfer { - TypeInfer { - underscore_token: Token![_](tokens_helper(_visitor, &(_i.underscore_token).0)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_type_macro(_visitor: &mut V, _i: TypeMacro) -> TypeMacro { - TypeMacro { - mac: _visitor.fold_macro(_i.mac), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_type_never(_visitor: &mut V, _i: TypeNever) -> TypeNever { - TypeNever { - bang_token: Token![!](tokens_helper(_visitor, &(_i.bang_token).0)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_type_param(_visitor: &mut V, _i: TypeParam) -> TypeParam { - TypeParam { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - ident: _visitor.fold_ident(_i.ident), - colon_token: (_i.colon_token).map(|it| Token ! [ : ](tokens_helper(_visitor, &(it).0))), - bounds: FoldHelper::lift(_i.bounds, |it| _visitor.fold_type_param_bound(it)), - eq_token: (_i.eq_token).map(|it| Token ! [ = ](tokens_helper(_visitor, &(it).0))), - default: (_i.default).map(|it| _visitor.fold_type(it)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_type_param_bound( - _visitor: &mut V, - _i: TypeParamBound, -) -> TypeParamBound { - match _i { - TypeParamBound::Trait(_binding_0) => { - TypeParamBound::Trait(_visitor.fold_trait_bound(_binding_0)) - } - TypeParamBound::Lifetime(_binding_0) => { - TypeParamBound::Lifetime(_visitor.fold_lifetime(_binding_0)) - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_type_paren(_visitor: &mut V, _i: TypeParen) -> TypeParen { - TypeParen { - paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), - elem: Box::new(_visitor.fold_type(*_i.elem)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_type_path(_visitor: &mut V, _i: TypePath) -> TypePath { - TypePath { - qself: (_i.qself).map(|it| _visitor.fold_qself(it)), - path: _visitor.fold_path(_i.path), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_type_ptr(_visitor: &mut V, _i: TypePtr) -> TypePtr { - TypePtr { - star_token: Token ! [ * ](tokens_helper(_visitor, &(_i.star_token).0)), - const_token: (_i.const_token).map(|it| Token ! [ const ](tokens_helper(_visitor, &(it).0))), - mutability: (_i.mutability).map(|it| Token ! [ mut ](tokens_helper(_visitor, &(it).0))), - elem: Box::new(_visitor.fold_type(*_i.elem)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_type_reference(_visitor: &mut V, _i: TypeReference) -> TypeReference { - TypeReference { - and_token: Token ! [ & ](tokens_helper(_visitor, &(_i.and_token).0)), - lifetime: (_i.lifetime).map(|it| _visitor.fold_lifetime(it)), - mutability: (_i.mutability).map(|it| Token ! [ mut ](tokens_helper(_visitor, &(it).0))), - elem: Box::new(_visitor.fold_type(*_i.elem)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_type_slice(_visitor: &mut V, _i: TypeSlice) -> TypeSlice { - TypeSlice { - bracket_token: Bracket(tokens_helper(_visitor, &(_i.bracket_token).0)), - elem: Box::new(_visitor.fold_type(*_i.elem)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_type_trait_object( - _visitor: &mut V, - _i: TypeTraitObject, -) -> TypeTraitObject { - TypeTraitObject { - dyn_token: (_i.dyn_token).map(|it| Token![dyn](tokens_helper(_visitor, &(it).0))), - bounds: FoldHelper::lift(_i.bounds, |it| _visitor.fold_type_param_bound(it)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_type_tuple(_visitor: &mut V, _i: TypeTuple) -> TypeTuple { - TypeTuple { - paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), - elems: FoldHelper::lift(_i.elems, |it| _visitor.fold_type(it)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_type_verbatim(_visitor: &mut V, _i: TypeVerbatim) -> TypeVerbatim { - TypeVerbatim { tts: _i.tts } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_un_op(_visitor: &mut V, _i: UnOp) -> UnOp { - match _i { - UnOp::Deref(_binding_0) => { - UnOp::Deref(Token ! [ * ](tokens_helper(_visitor, &(_binding_0).0))) - } - UnOp::Not(_binding_0) => UnOp::Not(Token![!](tokens_helper(_visitor, &(_binding_0).0))), - UnOp::Neg(_binding_0) => UnOp::Neg(Token ! [ - ](tokens_helper(_visitor, &(_binding_0).0))), - } -} -#[cfg(feature = "full")] -pub fn fold_use_glob(_visitor: &mut V, _i: UseGlob) -> UseGlob { - UseGlob { - star_token: Token ! [ * ](tokens_helper(_visitor, &(_i.star_token).0)), - } -} -#[cfg(feature = "full")] -pub fn fold_use_group(_visitor: &mut V, _i: UseGroup) -> UseGroup { - UseGroup { - brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), - items: FoldHelper::lift(_i.items, |it| _visitor.fold_use_tree(it)), - } -} -#[cfg(feature = "full")] -pub fn fold_use_name(_visitor: &mut V, _i: UseName) -> UseName { - UseName { - ident: _visitor.fold_ident(_i.ident), - } -} -#[cfg(feature = "full")] -pub fn fold_use_path(_visitor: &mut V, _i: UsePath) -> UsePath { - UsePath { - ident: _visitor.fold_ident(_i.ident), - colon2_token: Token ! [ :: ](tokens_helper(_visitor, &(_i.colon2_token).0)), - tree: Box::new(_visitor.fold_use_tree(*_i.tree)), - } -} -#[cfg(feature = "full")] -pub fn fold_use_rename(_visitor: &mut V, _i: UseRename) -> UseRename { - UseRename { - ident: _visitor.fold_ident(_i.ident), - as_token: Token ! [ as ](tokens_helper(_visitor, &(_i.as_token).0)), - rename: _visitor.fold_ident(_i.rename), - } -} -#[cfg(feature = "full")] -pub fn fold_use_tree(_visitor: &mut V, _i: UseTree) -> UseTree { - match _i { - UseTree::Path(_binding_0) => UseTree::Path(_visitor.fold_use_path(_binding_0)), - UseTree::Name(_binding_0) => UseTree::Name(_visitor.fold_use_name(_binding_0)), - UseTree::Rename(_binding_0) => UseTree::Rename(_visitor.fold_use_rename(_binding_0)), - UseTree::Glob(_binding_0) => UseTree::Glob(_visitor.fold_use_glob(_binding_0)), - UseTree::Group(_binding_0) => UseTree::Group(_visitor.fold_use_group(_binding_0)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_variant(_visitor: &mut V, _i: Variant) -> Variant { - Variant { - attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), - ident: _visitor.fold_ident(_i.ident), - fields: _visitor.fold_fields(_i.fields), - discriminant: (_i.discriminant).map(|it| { - ( - Token ! [ = ](tokens_helper(_visitor, &((it).0).0)), - _visitor.fold_expr((it).1), - ) - }), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_vis_crate(_visitor: &mut V, _i: VisCrate) -> VisCrate { - VisCrate { - crate_token: Token![crate](tokens_helper(_visitor, &(_i.crate_token).0)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_vis_public(_visitor: &mut V, _i: VisPublic) -> VisPublic { - VisPublic { - pub_token: Token ! [ pub ](tokens_helper(_visitor, &(_i.pub_token).0)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_vis_restricted(_visitor: &mut V, _i: VisRestricted) -> VisRestricted { - VisRestricted { - pub_token: Token ! [ pub ](tokens_helper(_visitor, &(_i.pub_token).0)), - paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), - in_token: (_i.in_token).map(|it| Token ! [ in ](tokens_helper(_visitor, &(it).0))), - path: Box::new(_visitor.fold_path(*_i.path)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_visibility(_visitor: &mut V, _i: Visibility) -> Visibility { - match _i { - Visibility::Public(_binding_0) => Visibility::Public(_visitor.fold_vis_public(_binding_0)), - Visibility::Crate(_binding_0) => Visibility::Crate(_visitor.fold_vis_crate(_binding_0)), - Visibility::Restricted(_binding_0) => { - Visibility::Restricted(_visitor.fold_vis_restricted(_binding_0)) - } - Visibility::Inherited => Visibility::Inherited, - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_where_clause(_visitor: &mut V, _i: WhereClause) -> WhereClause { - WhereClause { - where_token: Token ! [ where ](tokens_helper(_visitor, &(_i.where_token).0)), - predicates: FoldHelper::lift(_i.predicates, |it| _visitor.fold_where_predicate(it)), - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn fold_where_predicate( - _visitor: &mut V, - _i: WherePredicate, -) -> WherePredicate { - match _i { - WherePredicate::Type(_binding_0) => { - WherePredicate::Type(_visitor.fold_predicate_type(_binding_0)) - } - WherePredicate::Lifetime(_binding_0) => { - WherePredicate::Lifetime(_visitor.fold_predicate_lifetime(_binding_0)) - } - WherePredicate::Eq(_binding_0) => { - WherePredicate::Eq(_visitor.fold_predicate_eq(_binding_0)) - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/gen/visit_mut.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/gen/visit_mut.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/gen/visit_mut.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/gen/visit_mut.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,3290 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED; DO NOT EDIT - -#![cfg_attr(feature = "cargo-clippy", allow(match_same_arms))] -#[cfg(any(feature = "full", feature = "derive"))] -use gen::helper::visit_mut::*; -use proc_macro2::Span; -#[cfg(any(feature = "full", feature = "derive"))] -use punctuated::Punctuated; -use *; -#[cfg(feature = "full")] -macro_rules! full { - ($e:expr) => { - $e - }; -} -#[cfg(all(feature = "derive", not(feature = "full")))] -macro_rules! full { - ($e:expr) => { - unreachable!() - }; -} -#[cfg(any(feature = "full", feature = "derive"))] -macro_rules! skip { - ($($tt:tt)*) => {}; -} -#[doc = r" Syntax tree traversal to mutate an exclusive borrow of a syntax tree in"] -#[doc = r" place."] -#[doc = r""] -#[doc = r" See the [module documentation] for details."] -#[doc = r""] -#[doc = r" [module documentation]: index.html"] -#[doc = r""] -#[doc = r#" *This trait is available if Syn is built with the `"visit-mut"` feature.*"#] -pub trait VisitMut { - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_abi_mut(&mut self, i: &mut Abi) { - visit_abi_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_angle_bracketed_generic_arguments_mut( - &mut self, - i: &mut AngleBracketedGenericArguments, - ) { - visit_angle_bracketed_generic_arguments_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_arg_captured_mut(&mut self, i: &mut ArgCaptured) { - visit_arg_captured_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_arg_self_mut(&mut self, i: &mut ArgSelf) { - visit_arg_self_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_arg_self_ref_mut(&mut self, i: &mut ArgSelfRef) { - visit_arg_self_ref_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_arm_mut(&mut self, i: &mut Arm) { - visit_arm_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_attr_style_mut(&mut self, i: &mut AttrStyle) { - visit_attr_style_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_attribute_mut(&mut self, i: &mut Attribute) { - visit_attribute_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_bare_fn_arg_mut(&mut self, i: &mut BareFnArg) { - visit_bare_fn_arg_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_bare_fn_arg_name_mut(&mut self, i: &mut BareFnArgName) { - visit_bare_fn_arg_name_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_bin_op_mut(&mut self, i: &mut BinOp) { - visit_bin_op_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_binding_mut(&mut self, i: &mut Binding) { - visit_binding_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_block_mut(&mut self, i: &mut Block) { - visit_block_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_bound_lifetimes_mut(&mut self, i: &mut BoundLifetimes) { - visit_bound_lifetimes_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_const_param_mut(&mut self, i: &mut ConstParam) { - visit_const_param_mut(self, i) - } - #[cfg(feature = "derive")] - fn visit_data_mut(&mut self, i: &mut Data) { - visit_data_mut(self, i) - } - #[cfg(feature = "derive")] - fn visit_data_enum_mut(&mut self, i: &mut DataEnum) { - visit_data_enum_mut(self, i) - } - #[cfg(feature = "derive")] - fn visit_data_struct_mut(&mut self, i: &mut DataStruct) { - visit_data_struct_mut(self, i) - } - #[cfg(feature = "derive")] - fn visit_data_union_mut(&mut self, i: &mut DataUnion) { - visit_data_union_mut(self, i) - } - #[cfg(feature = "derive")] - fn visit_derive_input_mut(&mut self, i: &mut DeriveInput) { - visit_derive_input_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_mut(&mut self, i: &mut Expr) { - visit_expr_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_array_mut(&mut self, i: &mut ExprArray) { - visit_expr_array_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_assign_mut(&mut self, i: &mut ExprAssign) { - visit_expr_assign_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_assign_op_mut(&mut self, i: &mut ExprAssignOp) { - visit_expr_assign_op_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_binary_mut(&mut self, i: &mut ExprBinary) { - visit_expr_binary_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_block_mut(&mut self, i: &mut ExprBlock) { - visit_expr_block_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_box_mut(&mut self, i: &mut ExprBox) { - visit_expr_box_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_break_mut(&mut self, i: &mut ExprBreak) { - visit_expr_break_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_call_mut(&mut self, i: &mut ExprCall) { - visit_expr_call_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_cast_mut(&mut self, i: &mut ExprCast) { - visit_expr_cast_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_catch_mut(&mut self, i: &mut ExprCatch) { - visit_expr_catch_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_closure_mut(&mut self, i: &mut ExprClosure) { - visit_expr_closure_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_continue_mut(&mut self, i: &mut ExprContinue) { - visit_expr_continue_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_field_mut(&mut self, i: &mut ExprField) { - visit_expr_field_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_for_loop_mut(&mut self, i: &mut ExprForLoop) { - visit_expr_for_loop_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_group_mut(&mut self, i: &mut ExprGroup) { - visit_expr_group_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_if_mut(&mut self, i: &mut ExprIf) { - visit_expr_if_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_if_let_mut(&mut self, i: &mut ExprIfLet) { - visit_expr_if_let_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_in_place_mut(&mut self, i: &mut ExprInPlace) { - visit_expr_in_place_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_index_mut(&mut self, i: &mut ExprIndex) { - visit_expr_index_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_lit_mut(&mut self, i: &mut ExprLit) { - visit_expr_lit_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_loop_mut(&mut self, i: &mut ExprLoop) { - visit_expr_loop_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_macro_mut(&mut self, i: &mut ExprMacro) { - visit_expr_macro_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_match_mut(&mut self, i: &mut ExprMatch) { - visit_expr_match_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_method_call_mut(&mut self, i: &mut ExprMethodCall) { - visit_expr_method_call_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_paren_mut(&mut self, i: &mut ExprParen) { - visit_expr_paren_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_path_mut(&mut self, i: &mut ExprPath) { - visit_expr_path_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_range_mut(&mut self, i: &mut ExprRange) { - visit_expr_range_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_reference_mut(&mut self, i: &mut ExprReference) { - visit_expr_reference_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_repeat_mut(&mut self, i: &mut ExprRepeat) { - visit_expr_repeat_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_return_mut(&mut self, i: &mut ExprReturn) { - visit_expr_return_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_struct_mut(&mut self, i: &mut ExprStruct) { - visit_expr_struct_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_try_mut(&mut self, i: &mut ExprTry) { - visit_expr_try_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_tuple_mut(&mut self, i: &mut ExprTuple) { - visit_expr_tuple_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_type_mut(&mut self, i: &mut ExprType) { - visit_expr_type_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_unary_mut(&mut self, i: &mut ExprUnary) { - visit_expr_unary_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_unsafe_mut(&mut self, i: &mut ExprUnsafe) { - visit_expr_unsafe_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_verbatim_mut(&mut self, i: &mut ExprVerbatim) { - visit_expr_verbatim_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_while_mut(&mut self, i: &mut ExprWhile) { - visit_expr_while_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_while_let_mut(&mut self, i: &mut ExprWhileLet) { - visit_expr_while_let_mut(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_yield_mut(&mut self, i: &mut ExprYield) { - visit_expr_yield_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_field_mut(&mut self, i: &mut Field) { - visit_field_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_field_pat_mut(&mut self, i: &mut FieldPat) { - visit_field_pat_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_field_value_mut(&mut self, i: &mut FieldValue) { - visit_field_value_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_fields_mut(&mut self, i: &mut Fields) { - visit_fields_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_fields_named_mut(&mut self, i: &mut FieldsNamed) { - visit_fields_named_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_fields_unnamed_mut(&mut self, i: &mut FieldsUnnamed) { - visit_fields_unnamed_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_file_mut(&mut self, i: &mut File) { - visit_file_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_fn_arg_mut(&mut self, i: &mut FnArg) { - visit_fn_arg_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_fn_decl_mut(&mut self, i: &mut FnDecl) { - visit_fn_decl_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_foreign_item_mut(&mut self, i: &mut ForeignItem) { - visit_foreign_item_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_foreign_item_fn_mut(&mut self, i: &mut ForeignItemFn) { - visit_foreign_item_fn_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_foreign_item_static_mut(&mut self, i: &mut ForeignItemStatic) { - visit_foreign_item_static_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_foreign_item_type_mut(&mut self, i: &mut ForeignItemType) { - visit_foreign_item_type_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_foreign_item_verbatim_mut(&mut self, i: &mut ForeignItemVerbatim) { - visit_foreign_item_verbatim_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_generic_argument_mut(&mut self, i: &mut GenericArgument) { - visit_generic_argument_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_generic_method_argument_mut(&mut self, i: &mut GenericMethodArgument) { - visit_generic_method_argument_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_generic_param_mut(&mut self, i: &mut GenericParam) { - visit_generic_param_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_generics_mut(&mut self, i: &mut Generics) { - visit_generics_mut(self, i) - } - fn visit_ident_mut(&mut self, i: &mut Ident) { - visit_ident_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_impl_item_mut(&mut self, i: &mut ImplItem) { - visit_impl_item_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_impl_item_const_mut(&mut self, i: &mut ImplItemConst) { - visit_impl_item_const_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_impl_item_macro_mut(&mut self, i: &mut ImplItemMacro) { - visit_impl_item_macro_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_impl_item_method_mut(&mut self, i: &mut ImplItemMethod) { - visit_impl_item_method_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_impl_item_type_mut(&mut self, i: &mut ImplItemType) { - visit_impl_item_type_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_impl_item_verbatim_mut(&mut self, i: &mut ImplItemVerbatim) { - visit_impl_item_verbatim_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_index_mut(&mut self, i: &mut Index) { - visit_index_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_item_mut(&mut self, i: &mut Item) { - visit_item_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_item_const_mut(&mut self, i: &mut ItemConst) { - visit_item_const_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_item_enum_mut(&mut self, i: &mut ItemEnum) { - visit_item_enum_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_item_extern_crate_mut(&mut self, i: &mut ItemExternCrate) { - visit_item_extern_crate_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_item_fn_mut(&mut self, i: &mut ItemFn) { - visit_item_fn_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_item_foreign_mod_mut(&mut self, i: &mut ItemForeignMod) { - visit_item_foreign_mod_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_item_impl_mut(&mut self, i: &mut ItemImpl) { - visit_item_impl_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_item_macro_mut(&mut self, i: &mut ItemMacro) { - visit_item_macro_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_item_macro2_mut(&mut self, i: &mut ItemMacro2) { - visit_item_macro2_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_item_mod_mut(&mut self, i: &mut ItemMod) { - visit_item_mod_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_item_static_mut(&mut self, i: &mut ItemStatic) { - visit_item_static_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_item_struct_mut(&mut self, i: &mut ItemStruct) { - visit_item_struct_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_item_trait_mut(&mut self, i: &mut ItemTrait) { - visit_item_trait_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_item_type_mut(&mut self, i: &mut ItemType) { - visit_item_type_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_item_union_mut(&mut self, i: &mut ItemUnion) { - visit_item_union_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_item_use_mut(&mut self, i: &mut ItemUse) { - visit_item_use_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_item_verbatim_mut(&mut self, i: &mut ItemVerbatim) { - visit_item_verbatim_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_label_mut(&mut self, i: &mut Label) { - visit_label_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_lifetime_mut(&mut self, i: &mut Lifetime) { - visit_lifetime_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_lifetime_def_mut(&mut self, i: &mut LifetimeDef) { - visit_lifetime_def_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_lit_mut(&mut self, i: &mut Lit) { - visit_lit_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_lit_bool_mut(&mut self, i: &mut LitBool) { - visit_lit_bool_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_lit_byte_mut(&mut self, i: &mut LitByte) { - visit_lit_byte_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_lit_byte_str_mut(&mut self, i: &mut LitByteStr) { - visit_lit_byte_str_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_lit_char_mut(&mut self, i: &mut LitChar) { - visit_lit_char_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_lit_float_mut(&mut self, i: &mut LitFloat) { - visit_lit_float_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_lit_int_mut(&mut self, i: &mut LitInt) { - visit_lit_int_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_lit_str_mut(&mut self, i: &mut LitStr) { - visit_lit_str_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_lit_verbatim_mut(&mut self, i: &mut LitVerbatim) { - visit_lit_verbatim_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_local_mut(&mut self, i: &mut Local) { - visit_local_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_macro_mut(&mut self, i: &mut Macro) { - visit_macro_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_macro_delimiter_mut(&mut self, i: &mut MacroDelimiter) { - visit_macro_delimiter_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_member_mut(&mut self, i: &mut Member) { - visit_member_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_meta_mut(&mut self, i: &mut Meta) { - visit_meta_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_meta_list_mut(&mut self, i: &mut MetaList) { - visit_meta_list_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_meta_name_value_mut(&mut self, i: &mut MetaNameValue) { - visit_meta_name_value_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_method_sig_mut(&mut self, i: &mut MethodSig) { - visit_method_sig_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_method_turbofish_mut(&mut self, i: &mut MethodTurbofish) { - visit_method_turbofish_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_nested_meta_mut(&mut self, i: &mut NestedMeta) { - visit_nested_meta_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_parenthesized_generic_arguments_mut(&mut self, i: &mut ParenthesizedGenericArguments) { - visit_parenthesized_generic_arguments_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_mut(&mut self, i: &mut Pat) { - visit_pat_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_box_mut(&mut self, i: &mut PatBox) { - visit_pat_box_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_ident_mut(&mut self, i: &mut PatIdent) { - visit_pat_ident_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_lit_mut(&mut self, i: &mut PatLit) { - visit_pat_lit_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_macro_mut(&mut self, i: &mut PatMacro) { - visit_pat_macro_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_path_mut(&mut self, i: &mut PatPath) { - visit_pat_path_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_range_mut(&mut self, i: &mut PatRange) { - visit_pat_range_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_ref_mut(&mut self, i: &mut PatRef) { - visit_pat_ref_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_slice_mut(&mut self, i: &mut PatSlice) { - visit_pat_slice_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_struct_mut(&mut self, i: &mut PatStruct) { - visit_pat_struct_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_tuple_mut(&mut self, i: &mut PatTuple) { - visit_pat_tuple_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_tuple_struct_mut(&mut self, i: &mut PatTupleStruct) { - visit_pat_tuple_struct_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_verbatim_mut(&mut self, i: &mut PatVerbatim) { - visit_pat_verbatim_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_wild_mut(&mut self, i: &mut PatWild) { - visit_pat_wild_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_path_mut(&mut self, i: &mut Path) { - visit_path_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_path_arguments_mut(&mut self, i: &mut PathArguments) { - visit_path_arguments_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_path_segment_mut(&mut self, i: &mut PathSegment) { - visit_path_segment_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_predicate_eq_mut(&mut self, i: &mut PredicateEq) { - visit_predicate_eq_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_predicate_lifetime_mut(&mut self, i: &mut PredicateLifetime) { - visit_predicate_lifetime_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_predicate_type_mut(&mut self, i: &mut PredicateType) { - visit_predicate_type_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_qself_mut(&mut self, i: &mut QSelf) { - visit_qself_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_range_limits_mut(&mut self, i: &mut RangeLimits) { - visit_range_limits_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_return_type_mut(&mut self, i: &mut ReturnType) { - visit_return_type_mut(self, i) - } - fn visit_span_mut(&mut self, i: &mut Span) { - visit_span_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_stmt_mut(&mut self, i: &mut Stmt) { - visit_stmt_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_trait_bound_mut(&mut self, i: &mut TraitBound) { - visit_trait_bound_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_trait_bound_modifier_mut(&mut self, i: &mut TraitBoundModifier) { - visit_trait_bound_modifier_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_trait_item_mut(&mut self, i: &mut TraitItem) { - visit_trait_item_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_trait_item_const_mut(&mut self, i: &mut TraitItemConst) { - visit_trait_item_const_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_trait_item_macro_mut(&mut self, i: &mut TraitItemMacro) { - visit_trait_item_macro_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_trait_item_method_mut(&mut self, i: &mut TraitItemMethod) { - visit_trait_item_method_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_trait_item_type_mut(&mut self, i: &mut TraitItemType) { - visit_trait_item_type_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_trait_item_verbatim_mut(&mut self, i: &mut TraitItemVerbatim) { - visit_trait_item_verbatim_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_mut(&mut self, i: &mut Type) { - visit_type_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_array_mut(&mut self, i: &mut TypeArray) { - visit_type_array_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_bare_fn_mut(&mut self, i: &mut TypeBareFn) { - visit_type_bare_fn_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_group_mut(&mut self, i: &mut TypeGroup) { - visit_type_group_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_impl_trait_mut(&mut self, i: &mut TypeImplTrait) { - visit_type_impl_trait_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_infer_mut(&mut self, i: &mut TypeInfer) { - visit_type_infer_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_macro_mut(&mut self, i: &mut TypeMacro) { - visit_type_macro_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_never_mut(&mut self, i: &mut TypeNever) { - visit_type_never_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_param_mut(&mut self, i: &mut TypeParam) { - visit_type_param_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_param_bound_mut(&mut self, i: &mut TypeParamBound) { - visit_type_param_bound_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_paren_mut(&mut self, i: &mut TypeParen) { - visit_type_paren_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_path_mut(&mut self, i: &mut TypePath) { - visit_type_path_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_ptr_mut(&mut self, i: &mut TypePtr) { - visit_type_ptr_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_reference_mut(&mut self, i: &mut TypeReference) { - visit_type_reference_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_slice_mut(&mut self, i: &mut TypeSlice) { - visit_type_slice_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_trait_object_mut(&mut self, i: &mut TypeTraitObject) { - visit_type_trait_object_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_tuple_mut(&mut self, i: &mut TypeTuple) { - visit_type_tuple_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_verbatim_mut(&mut self, i: &mut TypeVerbatim) { - visit_type_verbatim_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_un_op_mut(&mut self, i: &mut UnOp) { - visit_un_op_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_use_glob_mut(&mut self, i: &mut UseGlob) { - visit_use_glob_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_use_group_mut(&mut self, i: &mut UseGroup) { - visit_use_group_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_use_name_mut(&mut self, i: &mut UseName) { - visit_use_name_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_use_path_mut(&mut self, i: &mut UsePath) { - visit_use_path_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_use_rename_mut(&mut self, i: &mut UseRename) { - visit_use_rename_mut(self, i) - } - #[cfg(feature = "full")] - fn visit_use_tree_mut(&mut self, i: &mut UseTree) { - visit_use_tree_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_variant_mut(&mut self, i: &mut Variant) { - visit_variant_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_vis_crate_mut(&mut self, i: &mut VisCrate) { - visit_vis_crate_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_vis_public_mut(&mut self, i: &mut VisPublic) { - visit_vis_public_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_vis_restricted_mut(&mut self, i: &mut VisRestricted) { - visit_vis_restricted_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_visibility_mut(&mut self, i: &mut Visibility) { - visit_visibility_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_where_clause_mut(&mut self, i: &mut WhereClause) { - visit_where_clause_mut(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_where_predicate_mut(&mut self, i: &mut WherePredicate) { - visit_where_predicate_mut(self, i) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_abi_mut(_visitor: &mut V, _i: &mut Abi) { - tokens_helper(_visitor, &mut (_i.extern_token).0); - if let Some(ref mut it) = _i.name { - _visitor.visit_lit_str_mut(it) - }; -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_angle_bracketed_generic_arguments_mut( - _visitor: &mut V, - _i: &mut AngleBracketedGenericArguments, -) { - if let Some(ref mut it) = _i.colon2_token { - tokens_helper(_visitor, &mut (it).0) - }; - tokens_helper(_visitor, &mut (_i.lt_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.args) { - let it = el.value_mut(); - _visitor.visit_generic_argument_mut(it) - } - tokens_helper(_visitor, &mut (_i.gt_token).0); -} -#[cfg(feature = "full")] -pub fn visit_arg_captured_mut(_visitor: &mut V, _i: &mut ArgCaptured) { - _visitor.visit_pat_mut(&mut _i.pat); - tokens_helper(_visitor, &mut (_i.colon_token).0); - _visitor.visit_type_mut(&mut _i.ty); -} -#[cfg(feature = "full")] -pub fn visit_arg_self_mut(_visitor: &mut V, _i: &mut ArgSelf) { - if let Some(ref mut it) = _i.mutability { - tokens_helper(_visitor, &mut (it).0) - }; - tokens_helper(_visitor, &mut (_i.self_token).0); -} -#[cfg(feature = "full")] -pub fn visit_arg_self_ref_mut(_visitor: &mut V, _i: &mut ArgSelfRef) { - tokens_helper(_visitor, &mut (_i.and_token).0); - if let Some(ref mut it) = _i.lifetime { - _visitor.visit_lifetime_mut(it) - }; - if let Some(ref mut it) = _i.mutability { - tokens_helper(_visitor, &mut (it).0) - }; - tokens_helper(_visitor, &mut (_i.self_token).0); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_arm_mut(_visitor: &mut V, _i: &mut Arm) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - if let Some(ref mut it) = _i.leading_vert { - tokens_helper(_visitor, &mut (it).0) - }; - for mut el in Punctuated::pairs_mut(&mut _i.pats) { - let it = el.value_mut(); - _visitor.visit_pat_mut(it) - } - if let Some(ref mut it) = _i.guard { - tokens_helper(_visitor, &mut ((it).0).0); - _visitor.visit_expr_mut(&mut *(it).1); - }; - tokens_helper(_visitor, &mut (_i.fat_arrow_token).0); - _visitor.visit_expr_mut(&mut *_i.body); - if let Some(ref mut it) = _i.comma { - tokens_helper(_visitor, &mut (it).0) - }; -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_attr_style_mut(_visitor: &mut V, _i: &mut AttrStyle) { - match *_i { - AttrStyle::Outer => {} - AttrStyle::Inner(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_attribute_mut(_visitor: &mut V, _i: &mut Attribute) { - tokens_helper(_visitor, &mut (_i.pound_token).0); - _visitor.visit_attr_style_mut(&mut _i.style); - tokens_helper(_visitor, &mut (_i.bracket_token).0); - _visitor.visit_path_mut(&mut _i.path); - skip!(_i.tts); - skip!(_i.is_sugared_doc); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_bare_fn_arg_mut(_visitor: &mut V, _i: &mut BareFnArg) { - if let Some(ref mut it) = _i.name { - _visitor.visit_bare_fn_arg_name_mut(&mut (it).0); - tokens_helper(_visitor, &mut ((it).1).0); - }; - _visitor.visit_type_mut(&mut _i.ty); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_bare_fn_arg_name_mut(_visitor: &mut V, _i: &mut BareFnArgName) { - match *_i { - BareFnArgName::Named(ref mut _binding_0) => { - _visitor.visit_ident_mut(_binding_0); - } - BareFnArgName::Wild(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_bin_op_mut(_visitor: &mut V, _i: &mut BinOp) { - match *_i { - BinOp::Add(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::Sub(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::Mul(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::Div(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::Rem(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::And(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::Or(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::BitXor(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::BitAnd(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::BitOr(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::Shl(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::Shr(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::Eq(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::Lt(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::Le(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::Ne(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::Ge(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::Gt(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::AddEq(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::SubEq(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::MulEq(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::DivEq(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::RemEq(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::BitXorEq(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::BitAndEq(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::BitOrEq(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::ShlEq(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - BinOp::ShrEq(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_binding_mut(_visitor: &mut V, _i: &mut Binding) { - _visitor.visit_ident_mut(&mut _i.ident); - tokens_helper(_visitor, &mut (_i.eq_token).0); - _visitor.visit_type_mut(&mut _i.ty); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_block_mut(_visitor: &mut V, _i: &mut Block) { - tokens_helper(_visitor, &mut (_i.brace_token).0); - for it in &mut _i.stmts { - _visitor.visit_stmt_mut(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_bound_lifetimes_mut(_visitor: &mut V, _i: &mut BoundLifetimes) { - tokens_helper(_visitor, &mut (_i.for_token).0); - tokens_helper(_visitor, &mut (_i.lt_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.lifetimes) { - let it = el.value_mut(); - _visitor.visit_lifetime_def_mut(it) - } - tokens_helper(_visitor, &mut (_i.gt_token).0); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_const_param_mut(_visitor: &mut V, _i: &mut ConstParam) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - tokens_helper(_visitor, &mut (_i.const_token).0); - _visitor.visit_ident_mut(&mut _i.ident); - tokens_helper(_visitor, &mut (_i.colon_token).0); - _visitor.visit_type_mut(&mut _i.ty); - if let Some(ref mut it) = _i.eq_token { - tokens_helper(_visitor, &mut (it).0) - }; - if let Some(ref mut it) = _i.default { - _visitor.visit_expr_mut(it) - }; -} -#[cfg(feature = "derive")] -pub fn visit_data_mut(_visitor: &mut V, _i: &mut Data) { - match *_i { - Data::Struct(ref mut _binding_0) => { - _visitor.visit_data_struct_mut(_binding_0); - } - Data::Enum(ref mut _binding_0) => { - _visitor.visit_data_enum_mut(_binding_0); - } - Data::Union(ref mut _binding_0) => { - _visitor.visit_data_union_mut(_binding_0); - } - } -} -#[cfg(feature = "derive")] -pub fn visit_data_enum_mut(_visitor: &mut V, _i: &mut DataEnum) { - tokens_helper(_visitor, &mut (_i.enum_token).0); - tokens_helper(_visitor, &mut (_i.brace_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.variants) { - let it = el.value_mut(); - _visitor.visit_variant_mut(it) - } -} -#[cfg(feature = "derive")] -pub fn visit_data_struct_mut(_visitor: &mut V, _i: &mut DataStruct) { - tokens_helper(_visitor, &mut (_i.struct_token).0); - _visitor.visit_fields_mut(&mut _i.fields); - if let Some(ref mut it) = _i.semi_token { - tokens_helper(_visitor, &mut (it).0) - }; -} -#[cfg(feature = "derive")] -pub fn visit_data_union_mut(_visitor: &mut V, _i: &mut DataUnion) { - tokens_helper(_visitor, &mut (_i.union_token).0); - _visitor.visit_fields_named_mut(&mut _i.fields); -} -#[cfg(feature = "derive")] -pub fn visit_derive_input_mut(_visitor: &mut V, _i: &mut DeriveInput) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_visibility_mut(&mut _i.vis); - _visitor.visit_ident_mut(&mut _i.ident); - _visitor.visit_generics_mut(&mut _i.generics); - _visitor.visit_data_mut(&mut _i.data); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_mut(_visitor: &mut V, _i: &mut Expr) { - match *_i { - Expr::Box(ref mut _binding_0) => { - full!(_visitor.visit_expr_box_mut(_binding_0)); - } - Expr::InPlace(ref mut _binding_0) => { - full!(_visitor.visit_expr_in_place_mut(_binding_0)); - } - Expr::Array(ref mut _binding_0) => { - full!(_visitor.visit_expr_array_mut(_binding_0)); - } - Expr::Call(ref mut _binding_0) => { - _visitor.visit_expr_call_mut(_binding_0); - } - Expr::MethodCall(ref mut _binding_0) => { - full!(_visitor.visit_expr_method_call_mut(_binding_0)); - } - Expr::Tuple(ref mut _binding_0) => { - full!(_visitor.visit_expr_tuple_mut(_binding_0)); - } - Expr::Binary(ref mut _binding_0) => { - _visitor.visit_expr_binary_mut(_binding_0); - } - Expr::Unary(ref mut _binding_0) => { - _visitor.visit_expr_unary_mut(_binding_0); - } - Expr::Lit(ref mut _binding_0) => { - _visitor.visit_expr_lit_mut(_binding_0); - } - Expr::Cast(ref mut _binding_0) => { - _visitor.visit_expr_cast_mut(_binding_0); - } - Expr::Type(ref mut _binding_0) => { - full!(_visitor.visit_expr_type_mut(_binding_0)); - } - Expr::If(ref mut _binding_0) => { - full!(_visitor.visit_expr_if_mut(_binding_0)); - } - Expr::IfLet(ref mut _binding_0) => { - full!(_visitor.visit_expr_if_let_mut(_binding_0)); - } - Expr::While(ref mut _binding_0) => { - full!(_visitor.visit_expr_while_mut(_binding_0)); - } - Expr::WhileLet(ref mut _binding_0) => { - full!(_visitor.visit_expr_while_let_mut(_binding_0)); - } - Expr::ForLoop(ref mut _binding_0) => { - full!(_visitor.visit_expr_for_loop_mut(_binding_0)); - } - Expr::Loop(ref mut _binding_0) => { - full!(_visitor.visit_expr_loop_mut(_binding_0)); - } - Expr::Match(ref mut _binding_0) => { - full!(_visitor.visit_expr_match_mut(_binding_0)); - } - Expr::Closure(ref mut _binding_0) => { - full!(_visitor.visit_expr_closure_mut(_binding_0)); - } - Expr::Unsafe(ref mut _binding_0) => { - full!(_visitor.visit_expr_unsafe_mut(_binding_0)); - } - Expr::Block(ref mut _binding_0) => { - full!(_visitor.visit_expr_block_mut(_binding_0)); - } - Expr::Assign(ref mut _binding_0) => { - full!(_visitor.visit_expr_assign_mut(_binding_0)); - } - Expr::AssignOp(ref mut _binding_0) => { - full!(_visitor.visit_expr_assign_op_mut(_binding_0)); - } - Expr::Field(ref mut _binding_0) => { - _visitor.visit_expr_field_mut(_binding_0); - } - Expr::Index(ref mut _binding_0) => { - _visitor.visit_expr_index_mut(_binding_0); - } - Expr::Range(ref mut _binding_0) => { - full!(_visitor.visit_expr_range_mut(_binding_0)); - } - Expr::Path(ref mut _binding_0) => { - _visitor.visit_expr_path_mut(_binding_0); - } - Expr::Reference(ref mut _binding_0) => { - full!(_visitor.visit_expr_reference_mut(_binding_0)); - } - Expr::Break(ref mut _binding_0) => { - full!(_visitor.visit_expr_break_mut(_binding_0)); - } - Expr::Continue(ref mut _binding_0) => { - full!(_visitor.visit_expr_continue_mut(_binding_0)); - } - Expr::Return(ref mut _binding_0) => { - full!(_visitor.visit_expr_return_mut(_binding_0)); - } - Expr::Macro(ref mut _binding_0) => { - full!(_visitor.visit_expr_macro_mut(_binding_0)); - } - Expr::Struct(ref mut _binding_0) => { - full!(_visitor.visit_expr_struct_mut(_binding_0)); - } - Expr::Repeat(ref mut _binding_0) => { - full!(_visitor.visit_expr_repeat_mut(_binding_0)); - } - Expr::Paren(ref mut _binding_0) => { - _visitor.visit_expr_paren_mut(_binding_0); - } - Expr::Group(ref mut _binding_0) => { - full!(_visitor.visit_expr_group_mut(_binding_0)); - } - Expr::Try(ref mut _binding_0) => { - full!(_visitor.visit_expr_try_mut(_binding_0)); - } - Expr::Catch(ref mut _binding_0) => { - full!(_visitor.visit_expr_catch_mut(_binding_0)); - } - Expr::Yield(ref mut _binding_0) => { - full!(_visitor.visit_expr_yield_mut(_binding_0)); - } - Expr::Verbatim(ref mut _binding_0) => { - _visitor.visit_expr_verbatim_mut(_binding_0); - } - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_array_mut(_visitor: &mut V, _i: &mut ExprArray) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - tokens_helper(_visitor, &mut (_i.bracket_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.elems) { - let it = el.value_mut(); - _visitor.visit_expr_mut(it) - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_assign_mut(_visitor: &mut V, _i: &mut ExprAssign) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_expr_mut(&mut *_i.left); - tokens_helper(_visitor, &mut (_i.eq_token).0); - _visitor.visit_expr_mut(&mut *_i.right); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_assign_op_mut(_visitor: &mut V, _i: &mut ExprAssignOp) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_expr_mut(&mut *_i.left); - _visitor.visit_bin_op_mut(&mut _i.op); - _visitor.visit_expr_mut(&mut *_i.right); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_binary_mut(_visitor: &mut V, _i: &mut ExprBinary) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_expr_mut(&mut *_i.left); - _visitor.visit_bin_op_mut(&mut _i.op); - _visitor.visit_expr_mut(&mut *_i.right); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_block_mut(_visitor: &mut V, _i: &mut ExprBlock) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_block_mut(&mut _i.block); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_box_mut(_visitor: &mut V, _i: &mut ExprBox) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - tokens_helper(_visitor, &mut (_i.box_token).0); - _visitor.visit_expr_mut(&mut *_i.expr); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_break_mut(_visitor: &mut V, _i: &mut ExprBreak) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - tokens_helper(_visitor, &mut (_i.break_token).0); - if let Some(ref mut it) = _i.label { - _visitor.visit_lifetime_mut(it) - }; - if let Some(ref mut it) = _i.expr { - _visitor.visit_expr_mut(&mut **it) - }; -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_call_mut(_visitor: &mut V, _i: &mut ExprCall) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_expr_mut(&mut *_i.func); - tokens_helper(_visitor, &mut (_i.paren_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.args) { - let it = el.value_mut(); - _visitor.visit_expr_mut(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_cast_mut(_visitor: &mut V, _i: &mut ExprCast) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_expr_mut(&mut *_i.expr); - tokens_helper(_visitor, &mut (_i.as_token).0); - _visitor.visit_type_mut(&mut *_i.ty); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_catch_mut(_visitor: &mut V, _i: &mut ExprCatch) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - tokens_helper(_visitor, &mut (_i.do_token).0); - tokens_helper(_visitor, &mut (_i.catch_token).0); - _visitor.visit_block_mut(&mut _i.block); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_closure_mut(_visitor: &mut V, _i: &mut ExprClosure) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - if let Some(ref mut it) = _i.movability { - tokens_helper(_visitor, &mut (it).0) - }; - if let Some(ref mut it) = _i.capture { - tokens_helper(_visitor, &mut (it).0) - }; - tokens_helper(_visitor, &mut (_i.or1_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.inputs) { - let it = el.value_mut(); - _visitor.visit_fn_arg_mut(it) - } - tokens_helper(_visitor, &mut (_i.or2_token).0); - _visitor.visit_return_type_mut(&mut _i.output); - _visitor.visit_expr_mut(&mut *_i.body); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_continue_mut(_visitor: &mut V, _i: &mut ExprContinue) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - tokens_helper(_visitor, &mut (_i.continue_token).0); - if let Some(ref mut it) = _i.label { - _visitor.visit_lifetime_mut(it) - }; -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_field_mut(_visitor: &mut V, _i: &mut ExprField) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_expr_mut(&mut *_i.base); - tokens_helper(_visitor, &mut (_i.dot_token).0); - _visitor.visit_member_mut(&mut _i.member); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_for_loop_mut(_visitor: &mut V, _i: &mut ExprForLoop) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - if let Some(ref mut it) = _i.label { - _visitor.visit_label_mut(it) - }; - tokens_helper(_visitor, &mut (_i.for_token).0); - _visitor.visit_pat_mut(&mut *_i.pat); - tokens_helper(_visitor, &mut (_i.in_token).0); - _visitor.visit_expr_mut(&mut *_i.expr); - _visitor.visit_block_mut(&mut _i.body); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_group_mut(_visitor: &mut V, _i: &mut ExprGroup) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - tokens_helper(_visitor, &mut (_i.group_token).0); - _visitor.visit_expr_mut(&mut *_i.expr); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_if_mut(_visitor: &mut V, _i: &mut ExprIf) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - tokens_helper(_visitor, &mut (_i.if_token).0); - _visitor.visit_expr_mut(&mut *_i.cond); - _visitor.visit_block_mut(&mut _i.then_branch); - if let Some(ref mut it) = _i.else_branch { - tokens_helper(_visitor, &mut ((it).0).0); - _visitor.visit_expr_mut(&mut *(it).1); - }; -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_if_let_mut(_visitor: &mut V, _i: &mut ExprIfLet) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - tokens_helper(_visitor, &mut (_i.if_token).0); - tokens_helper(_visitor, &mut (_i.let_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.pats) { - let it = el.value_mut(); - _visitor.visit_pat_mut(it) - } - tokens_helper(_visitor, &mut (_i.eq_token).0); - _visitor.visit_expr_mut(&mut *_i.expr); - _visitor.visit_block_mut(&mut _i.then_branch); - if let Some(ref mut it) = _i.else_branch { - tokens_helper(_visitor, &mut ((it).0).0); - _visitor.visit_expr_mut(&mut *(it).1); - }; -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_in_place_mut(_visitor: &mut V, _i: &mut ExprInPlace) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_expr_mut(&mut *_i.place); - tokens_helper(_visitor, &mut (_i.arrow_token).0); - _visitor.visit_expr_mut(&mut *_i.value); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_index_mut(_visitor: &mut V, _i: &mut ExprIndex) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_expr_mut(&mut *_i.expr); - tokens_helper(_visitor, &mut (_i.bracket_token).0); - _visitor.visit_expr_mut(&mut *_i.index); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_lit_mut(_visitor: &mut V, _i: &mut ExprLit) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_lit_mut(&mut _i.lit); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_loop_mut(_visitor: &mut V, _i: &mut ExprLoop) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - if let Some(ref mut it) = _i.label { - _visitor.visit_label_mut(it) - }; - tokens_helper(_visitor, &mut (_i.loop_token).0); - _visitor.visit_block_mut(&mut _i.body); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_macro_mut(_visitor: &mut V, _i: &mut ExprMacro) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_macro_mut(&mut _i.mac); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_match_mut(_visitor: &mut V, _i: &mut ExprMatch) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - tokens_helper(_visitor, &mut (_i.match_token).0); - _visitor.visit_expr_mut(&mut *_i.expr); - tokens_helper(_visitor, &mut (_i.brace_token).0); - for it in &mut _i.arms { - _visitor.visit_arm_mut(it) - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_method_call_mut(_visitor: &mut V, _i: &mut ExprMethodCall) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_expr_mut(&mut *_i.receiver); - tokens_helper(_visitor, &mut (_i.dot_token).0); - _visitor.visit_ident_mut(&mut _i.method); - if let Some(ref mut it) = _i.turbofish { - _visitor.visit_method_turbofish_mut(it) - }; - tokens_helper(_visitor, &mut (_i.paren_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.args) { - let it = el.value_mut(); - _visitor.visit_expr_mut(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_paren_mut(_visitor: &mut V, _i: &mut ExprParen) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - tokens_helper(_visitor, &mut (_i.paren_token).0); - _visitor.visit_expr_mut(&mut *_i.expr); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_path_mut(_visitor: &mut V, _i: &mut ExprPath) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - if let Some(ref mut it) = _i.qself { - _visitor.visit_qself_mut(it) - }; - _visitor.visit_path_mut(&mut _i.path); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_range_mut(_visitor: &mut V, _i: &mut ExprRange) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - if let Some(ref mut it) = _i.from { - _visitor.visit_expr_mut(&mut **it) - }; - _visitor.visit_range_limits_mut(&mut _i.limits); - if let Some(ref mut it) = _i.to { - _visitor.visit_expr_mut(&mut **it) - }; -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_reference_mut(_visitor: &mut V, _i: &mut ExprReference) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - tokens_helper(_visitor, &mut (_i.and_token).0); - if let Some(ref mut it) = _i.mutability { - tokens_helper(_visitor, &mut (it).0) - }; - _visitor.visit_expr_mut(&mut *_i.expr); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_repeat_mut(_visitor: &mut V, _i: &mut ExprRepeat) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - tokens_helper(_visitor, &mut (_i.bracket_token).0); - _visitor.visit_expr_mut(&mut *_i.expr); - tokens_helper(_visitor, &mut (_i.semi_token).0); - _visitor.visit_expr_mut(&mut *_i.len); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_return_mut(_visitor: &mut V, _i: &mut ExprReturn) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - tokens_helper(_visitor, &mut (_i.return_token).0); - if let Some(ref mut it) = _i.expr { - _visitor.visit_expr_mut(&mut **it) - }; -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_struct_mut(_visitor: &mut V, _i: &mut ExprStruct) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_path_mut(&mut _i.path); - tokens_helper(_visitor, &mut (_i.brace_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.fields) { - let it = el.value_mut(); - _visitor.visit_field_value_mut(it) - } - if let Some(ref mut it) = _i.dot2_token { - tokens_helper(_visitor, &mut (it).0) - }; - if let Some(ref mut it) = _i.rest { - _visitor.visit_expr_mut(&mut **it) - }; -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_try_mut(_visitor: &mut V, _i: &mut ExprTry) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_expr_mut(&mut *_i.expr); - tokens_helper(_visitor, &mut (_i.question_token).0); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_tuple_mut(_visitor: &mut V, _i: &mut ExprTuple) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - tokens_helper(_visitor, &mut (_i.paren_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.elems) { - let it = el.value_mut(); - _visitor.visit_expr_mut(it) - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_type_mut(_visitor: &mut V, _i: &mut ExprType) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_expr_mut(&mut *_i.expr); - tokens_helper(_visitor, &mut (_i.colon_token).0); - _visitor.visit_type_mut(&mut *_i.ty); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_unary_mut(_visitor: &mut V, _i: &mut ExprUnary) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_un_op_mut(&mut _i.op); - _visitor.visit_expr_mut(&mut *_i.expr); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_unsafe_mut(_visitor: &mut V, _i: &mut ExprUnsafe) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - tokens_helper(_visitor, &mut (_i.unsafe_token).0); - _visitor.visit_block_mut(&mut _i.block); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_verbatim_mut(_visitor: &mut V, _i: &mut ExprVerbatim) { - skip!(_i.tts); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_while_mut(_visitor: &mut V, _i: &mut ExprWhile) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - if let Some(ref mut it) = _i.label { - _visitor.visit_label_mut(it) - }; - tokens_helper(_visitor, &mut (_i.while_token).0); - _visitor.visit_expr_mut(&mut *_i.cond); - _visitor.visit_block_mut(&mut _i.body); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_while_let_mut(_visitor: &mut V, _i: &mut ExprWhileLet) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - if let Some(ref mut it) = _i.label { - _visitor.visit_label_mut(it) - }; - tokens_helper(_visitor, &mut (_i.while_token).0); - tokens_helper(_visitor, &mut (_i.let_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.pats) { - let it = el.value_mut(); - _visitor.visit_pat_mut(it) - } - tokens_helper(_visitor, &mut (_i.eq_token).0); - _visitor.visit_expr_mut(&mut *_i.expr); - _visitor.visit_block_mut(&mut _i.body); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_yield_mut(_visitor: &mut V, _i: &mut ExprYield) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - tokens_helper(_visitor, &mut (_i.yield_token).0); - if let Some(ref mut it) = _i.expr { - _visitor.visit_expr_mut(&mut **it) - }; -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_field_mut(_visitor: &mut V, _i: &mut Field) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_visibility_mut(&mut _i.vis); - if let Some(ref mut it) = _i.ident { - _visitor.visit_ident_mut(it) - }; - if let Some(ref mut it) = _i.colon_token { - tokens_helper(_visitor, &mut (it).0) - }; - _visitor.visit_type_mut(&mut _i.ty); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_field_pat_mut(_visitor: &mut V, _i: &mut FieldPat) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_member_mut(&mut _i.member); - if let Some(ref mut it) = _i.colon_token { - tokens_helper(_visitor, &mut (it).0) - }; - _visitor.visit_pat_mut(&mut *_i.pat); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_field_value_mut(_visitor: &mut V, _i: &mut FieldValue) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_member_mut(&mut _i.member); - if let Some(ref mut it) = _i.colon_token { - tokens_helper(_visitor, &mut (it).0) - }; - _visitor.visit_expr_mut(&mut _i.expr); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_fields_mut(_visitor: &mut V, _i: &mut Fields) { - match *_i { - Fields::Named(ref mut _binding_0) => { - _visitor.visit_fields_named_mut(_binding_0); - } - Fields::Unnamed(ref mut _binding_0) => { - _visitor.visit_fields_unnamed_mut(_binding_0); - } - Fields::Unit => {} - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_fields_named_mut(_visitor: &mut V, _i: &mut FieldsNamed) { - tokens_helper(_visitor, &mut (_i.brace_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.named) { - let it = el.value_mut(); - _visitor.visit_field_mut(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_fields_unnamed_mut(_visitor: &mut V, _i: &mut FieldsUnnamed) { - tokens_helper(_visitor, &mut (_i.paren_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.unnamed) { - let it = el.value_mut(); - _visitor.visit_field_mut(it) - } -} -#[cfg(feature = "full")] -pub fn visit_file_mut(_visitor: &mut V, _i: &mut File) { - skip!(_i.shebang); - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - for it in &mut _i.items { - _visitor.visit_item_mut(it) - } -} -#[cfg(feature = "full")] -pub fn visit_fn_arg_mut(_visitor: &mut V, _i: &mut FnArg) { - match *_i { - FnArg::SelfRef(ref mut _binding_0) => { - _visitor.visit_arg_self_ref_mut(_binding_0); - } - FnArg::SelfValue(ref mut _binding_0) => { - _visitor.visit_arg_self_mut(_binding_0); - } - FnArg::Captured(ref mut _binding_0) => { - _visitor.visit_arg_captured_mut(_binding_0); - } - FnArg::Inferred(ref mut _binding_0) => { - _visitor.visit_pat_mut(_binding_0); - } - FnArg::Ignored(ref mut _binding_0) => { - _visitor.visit_type_mut(_binding_0); - } - } -} -#[cfg(feature = "full")] -pub fn visit_fn_decl_mut(_visitor: &mut V, _i: &mut FnDecl) { - tokens_helper(_visitor, &mut (_i.fn_token).0); - _visitor.visit_generics_mut(&mut _i.generics); - tokens_helper(_visitor, &mut (_i.paren_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.inputs) { - let it = el.value_mut(); - _visitor.visit_fn_arg_mut(it) - } - if let Some(ref mut it) = _i.variadic { - tokens_helper(_visitor, &mut (it).0) - }; - _visitor.visit_return_type_mut(&mut _i.output); -} -#[cfg(feature = "full")] -pub fn visit_foreign_item_mut(_visitor: &mut V, _i: &mut ForeignItem) { - match *_i { - ForeignItem::Fn(ref mut _binding_0) => { - _visitor.visit_foreign_item_fn_mut(_binding_0); - } - ForeignItem::Static(ref mut _binding_0) => { - _visitor.visit_foreign_item_static_mut(_binding_0); - } - ForeignItem::Type(ref mut _binding_0) => { - _visitor.visit_foreign_item_type_mut(_binding_0); - } - ForeignItem::Verbatim(ref mut _binding_0) => { - _visitor.visit_foreign_item_verbatim_mut(_binding_0); - } - } -} -#[cfg(feature = "full")] -pub fn visit_foreign_item_fn_mut(_visitor: &mut V, _i: &mut ForeignItemFn) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_visibility_mut(&mut _i.vis); - _visitor.visit_ident_mut(&mut _i.ident); - _visitor.visit_fn_decl_mut(&mut *_i.decl); - tokens_helper(_visitor, &mut (_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_foreign_item_static_mut( - _visitor: &mut V, - _i: &mut ForeignItemStatic, -) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_visibility_mut(&mut _i.vis); - tokens_helper(_visitor, &mut (_i.static_token).0); - if let Some(ref mut it) = _i.mutability { - tokens_helper(_visitor, &mut (it).0) - }; - _visitor.visit_ident_mut(&mut _i.ident); - tokens_helper(_visitor, &mut (_i.colon_token).0); - _visitor.visit_type_mut(&mut *_i.ty); - tokens_helper(_visitor, &mut (_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_foreign_item_type_mut( - _visitor: &mut V, - _i: &mut ForeignItemType, -) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_visibility_mut(&mut _i.vis); - tokens_helper(_visitor, &mut (_i.type_token).0); - _visitor.visit_ident_mut(&mut _i.ident); - tokens_helper(_visitor, &mut (_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_foreign_item_verbatim_mut( - _visitor: &mut V, - _i: &mut ForeignItemVerbatim, -) { - skip!(_i.tts); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_generic_argument_mut( - _visitor: &mut V, - _i: &mut GenericArgument, -) { - match *_i { - GenericArgument::Lifetime(ref mut _binding_0) => { - _visitor.visit_lifetime_mut(_binding_0); - } - GenericArgument::Type(ref mut _binding_0) => { - _visitor.visit_type_mut(_binding_0); - } - GenericArgument::Binding(ref mut _binding_0) => { - _visitor.visit_binding_mut(_binding_0); - } - GenericArgument::Const(ref mut _binding_0) => { - _visitor.visit_expr_mut(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_generic_method_argument_mut( - _visitor: &mut V, - _i: &mut GenericMethodArgument, -) { - match *_i { - GenericMethodArgument::Type(ref mut _binding_0) => { - _visitor.visit_type_mut(_binding_0); - } - GenericMethodArgument::Const(ref mut _binding_0) => { - _visitor.visit_expr_mut(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_generic_param_mut(_visitor: &mut V, _i: &mut GenericParam) { - match *_i { - GenericParam::Type(ref mut _binding_0) => { - _visitor.visit_type_param_mut(_binding_0); - } - GenericParam::Lifetime(ref mut _binding_0) => { - _visitor.visit_lifetime_def_mut(_binding_0); - } - GenericParam::Const(ref mut _binding_0) => { - _visitor.visit_const_param_mut(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_generics_mut(_visitor: &mut V, _i: &mut Generics) { - if let Some(ref mut it) = _i.lt_token { - tokens_helper(_visitor, &mut (it).0) - }; - for mut el in Punctuated::pairs_mut(&mut _i.params) { - let it = el.value_mut(); - _visitor.visit_generic_param_mut(it) - } - if let Some(ref mut it) = _i.gt_token { - tokens_helper(_visitor, &mut (it).0) - }; - if let Some(ref mut it) = _i.where_clause { - _visitor.visit_where_clause_mut(it) - }; -} -pub fn visit_ident_mut(_visitor: &mut V, _i: &mut Ident) {} -#[cfg(feature = "full")] -pub fn visit_impl_item_mut(_visitor: &mut V, _i: &mut ImplItem) { - match *_i { - ImplItem::Const(ref mut _binding_0) => { - _visitor.visit_impl_item_const_mut(_binding_0); - } - ImplItem::Method(ref mut _binding_0) => { - _visitor.visit_impl_item_method_mut(_binding_0); - } - ImplItem::Type(ref mut _binding_0) => { - _visitor.visit_impl_item_type_mut(_binding_0); - } - ImplItem::Macro(ref mut _binding_0) => { - _visitor.visit_impl_item_macro_mut(_binding_0); - } - ImplItem::Verbatim(ref mut _binding_0) => { - _visitor.visit_impl_item_verbatim_mut(_binding_0); - } - } -} -#[cfg(feature = "full")] -pub fn visit_impl_item_const_mut(_visitor: &mut V, _i: &mut ImplItemConst) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_visibility_mut(&mut _i.vis); - if let Some(ref mut it) = _i.defaultness { - tokens_helper(_visitor, &mut (it).0) - }; - tokens_helper(_visitor, &mut (_i.const_token).0); - _visitor.visit_ident_mut(&mut _i.ident); - tokens_helper(_visitor, &mut (_i.colon_token).0); - _visitor.visit_type_mut(&mut _i.ty); - tokens_helper(_visitor, &mut (_i.eq_token).0); - _visitor.visit_expr_mut(&mut _i.expr); - tokens_helper(_visitor, &mut (_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_impl_item_macro_mut(_visitor: &mut V, _i: &mut ImplItemMacro) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_macro_mut(&mut _i.mac); - if let Some(ref mut it) = _i.semi_token { - tokens_helper(_visitor, &mut (it).0) - }; -} -#[cfg(feature = "full")] -pub fn visit_impl_item_method_mut(_visitor: &mut V, _i: &mut ImplItemMethod) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_visibility_mut(&mut _i.vis); - if let Some(ref mut it) = _i.defaultness { - tokens_helper(_visitor, &mut (it).0) - }; - _visitor.visit_method_sig_mut(&mut _i.sig); - _visitor.visit_block_mut(&mut _i.block); -} -#[cfg(feature = "full")] -pub fn visit_impl_item_type_mut(_visitor: &mut V, _i: &mut ImplItemType) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_visibility_mut(&mut _i.vis); - if let Some(ref mut it) = _i.defaultness { - tokens_helper(_visitor, &mut (it).0) - }; - tokens_helper(_visitor, &mut (_i.type_token).0); - _visitor.visit_ident_mut(&mut _i.ident); - _visitor.visit_generics_mut(&mut _i.generics); - tokens_helper(_visitor, &mut (_i.eq_token).0); - _visitor.visit_type_mut(&mut _i.ty); - tokens_helper(_visitor, &mut (_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_impl_item_verbatim_mut( - _visitor: &mut V, - _i: &mut ImplItemVerbatim, -) { - skip!(_i.tts); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_index_mut(_visitor: &mut V, _i: &mut Index) { - skip!(_i.index); - _visitor.visit_span_mut(&mut _i.span); -} -#[cfg(feature = "full")] -pub fn visit_item_mut(_visitor: &mut V, _i: &mut Item) { - match *_i { - Item::ExternCrate(ref mut _binding_0) => { - _visitor.visit_item_extern_crate_mut(_binding_0); - } - Item::Use(ref mut _binding_0) => { - _visitor.visit_item_use_mut(_binding_0); - } - Item::Static(ref mut _binding_0) => { - _visitor.visit_item_static_mut(_binding_0); - } - Item::Const(ref mut _binding_0) => { - _visitor.visit_item_const_mut(_binding_0); - } - Item::Fn(ref mut _binding_0) => { - _visitor.visit_item_fn_mut(_binding_0); - } - Item::Mod(ref mut _binding_0) => { - _visitor.visit_item_mod_mut(_binding_0); - } - Item::ForeignMod(ref mut _binding_0) => { - _visitor.visit_item_foreign_mod_mut(_binding_0); - } - Item::Type(ref mut _binding_0) => { - _visitor.visit_item_type_mut(_binding_0); - } - Item::Struct(ref mut _binding_0) => { - _visitor.visit_item_struct_mut(_binding_0); - } - Item::Enum(ref mut _binding_0) => { - _visitor.visit_item_enum_mut(_binding_0); - } - Item::Union(ref mut _binding_0) => { - _visitor.visit_item_union_mut(_binding_0); - } - Item::Trait(ref mut _binding_0) => { - _visitor.visit_item_trait_mut(_binding_0); - } - Item::Impl(ref mut _binding_0) => { - _visitor.visit_item_impl_mut(_binding_0); - } - Item::Macro(ref mut _binding_0) => { - _visitor.visit_item_macro_mut(_binding_0); - } - Item::Macro2(ref mut _binding_0) => { - _visitor.visit_item_macro2_mut(_binding_0); - } - Item::Verbatim(ref mut _binding_0) => { - _visitor.visit_item_verbatim_mut(_binding_0); - } - } -} -#[cfg(feature = "full")] -pub fn visit_item_const_mut(_visitor: &mut V, _i: &mut ItemConst) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_visibility_mut(&mut _i.vis); - tokens_helper(_visitor, &mut (_i.const_token).0); - _visitor.visit_ident_mut(&mut _i.ident); - tokens_helper(_visitor, &mut (_i.colon_token).0); - _visitor.visit_type_mut(&mut *_i.ty); - tokens_helper(_visitor, &mut (_i.eq_token).0); - _visitor.visit_expr_mut(&mut *_i.expr); - tokens_helper(_visitor, &mut (_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_item_enum_mut(_visitor: &mut V, _i: &mut ItemEnum) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_visibility_mut(&mut _i.vis); - tokens_helper(_visitor, &mut (_i.enum_token).0); - _visitor.visit_ident_mut(&mut _i.ident); - _visitor.visit_generics_mut(&mut _i.generics); - tokens_helper(_visitor, &mut (_i.brace_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.variants) { - let it = el.value_mut(); - _visitor.visit_variant_mut(it) - } -} -#[cfg(feature = "full")] -pub fn visit_item_extern_crate_mut( - _visitor: &mut V, - _i: &mut ItemExternCrate, -) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_visibility_mut(&mut _i.vis); - tokens_helper(_visitor, &mut (_i.extern_token).0); - tokens_helper(_visitor, &mut (_i.crate_token).0); - _visitor.visit_ident_mut(&mut _i.ident); - if let Some(ref mut it) = _i.rename { - tokens_helper(_visitor, &mut ((it).0).0); - _visitor.visit_ident_mut(&mut (it).1); - }; - tokens_helper(_visitor, &mut (_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_item_fn_mut(_visitor: &mut V, _i: &mut ItemFn) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_visibility_mut(&mut _i.vis); - if let Some(ref mut it) = _i.constness { - tokens_helper(_visitor, &mut (it).0) - }; - if let Some(ref mut it) = _i.unsafety { - tokens_helper(_visitor, &mut (it).0) - }; - if let Some(ref mut it) = _i.abi { - _visitor.visit_abi_mut(it) - }; - _visitor.visit_ident_mut(&mut _i.ident); - _visitor.visit_fn_decl_mut(&mut *_i.decl); - _visitor.visit_block_mut(&mut *_i.block); -} -#[cfg(feature = "full")] -pub fn visit_item_foreign_mod_mut(_visitor: &mut V, _i: &mut ItemForeignMod) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_abi_mut(&mut _i.abi); - tokens_helper(_visitor, &mut (_i.brace_token).0); - for it in &mut _i.items { - _visitor.visit_foreign_item_mut(it) - } -} -#[cfg(feature = "full")] -pub fn visit_item_impl_mut(_visitor: &mut V, _i: &mut ItemImpl) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - if let Some(ref mut it) = _i.defaultness { - tokens_helper(_visitor, &mut (it).0) - }; - if let Some(ref mut it) = _i.unsafety { - tokens_helper(_visitor, &mut (it).0) - }; - tokens_helper(_visitor, &mut (_i.impl_token).0); - _visitor.visit_generics_mut(&mut _i.generics); - if let Some(ref mut it) = _i.trait_ { - if let Some(ref mut it) = (it).0 { - tokens_helper(_visitor, &mut (it).0) - }; - _visitor.visit_path_mut(&mut (it).1); - tokens_helper(_visitor, &mut ((it).2).0); - }; - _visitor.visit_type_mut(&mut *_i.self_ty); - tokens_helper(_visitor, &mut (_i.brace_token).0); - for it in &mut _i.items { - _visitor.visit_impl_item_mut(it) - } -} -#[cfg(feature = "full")] -pub fn visit_item_macro_mut(_visitor: &mut V, _i: &mut ItemMacro) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - if let Some(ref mut it) = _i.ident { - _visitor.visit_ident_mut(it) - }; - _visitor.visit_macro_mut(&mut _i.mac); - if let Some(ref mut it) = _i.semi_token { - tokens_helper(_visitor, &mut (it).0) - }; -} -#[cfg(feature = "full")] -pub fn visit_item_macro2_mut(_visitor: &mut V, _i: &mut ItemMacro2) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_visibility_mut(&mut _i.vis); - tokens_helper(_visitor, &mut (_i.macro_token).0); - _visitor.visit_ident_mut(&mut _i.ident); - tokens_helper(_visitor, &mut (_i.paren_token).0); - skip!(_i.args); - tokens_helper(_visitor, &mut (_i.brace_token).0); - skip!(_i.body); -} -#[cfg(feature = "full")] -pub fn visit_item_mod_mut(_visitor: &mut V, _i: &mut ItemMod) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_visibility_mut(&mut _i.vis); - tokens_helper(_visitor, &mut (_i.mod_token).0); - _visitor.visit_ident_mut(&mut _i.ident); - if let Some(ref mut it) = _i.content { - tokens_helper(_visitor, &mut ((it).0).0); - for it in &mut (it).1 { - _visitor.visit_item_mut(it) - } - }; - if let Some(ref mut it) = _i.semi { - tokens_helper(_visitor, &mut (it).0) - }; -} -#[cfg(feature = "full")] -pub fn visit_item_static_mut(_visitor: &mut V, _i: &mut ItemStatic) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_visibility_mut(&mut _i.vis); - tokens_helper(_visitor, &mut (_i.static_token).0); - if let Some(ref mut it) = _i.mutability { - tokens_helper(_visitor, &mut (it).0) - }; - _visitor.visit_ident_mut(&mut _i.ident); - tokens_helper(_visitor, &mut (_i.colon_token).0); - _visitor.visit_type_mut(&mut *_i.ty); - tokens_helper(_visitor, &mut (_i.eq_token).0); - _visitor.visit_expr_mut(&mut *_i.expr); - tokens_helper(_visitor, &mut (_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_item_struct_mut(_visitor: &mut V, _i: &mut ItemStruct) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_visibility_mut(&mut _i.vis); - tokens_helper(_visitor, &mut (_i.struct_token).0); - _visitor.visit_ident_mut(&mut _i.ident); - _visitor.visit_generics_mut(&mut _i.generics); - _visitor.visit_fields_mut(&mut _i.fields); - if let Some(ref mut it) = _i.semi_token { - tokens_helper(_visitor, &mut (it).0) - }; -} -#[cfg(feature = "full")] -pub fn visit_item_trait_mut(_visitor: &mut V, _i: &mut ItemTrait) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_visibility_mut(&mut _i.vis); - if let Some(ref mut it) = _i.unsafety { - tokens_helper(_visitor, &mut (it).0) - }; - if let Some(ref mut it) = _i.auto_token { - tokens_helper(_visitor, &mut (it).0) - }; - tokens_helper(_visitor, &mut (_i.trait_token).0); - _visitor.visit_ident_mut(&mut _i.ident); - _visitor.visit_generics_mut(&mut _i.generics); - if let Some(ref mut it) = _i.colon_token { - tokens_helper(_visitor, &mut (it).0) - }; - for mut el in Punctuated::pairs_mut(&mut _i.supertraits) { - let it = el.value_mut(); - _visitor.visit_type_param_bound_mut(it) - } - tokens_helper(_visitor, &mut (_i.brace_token).0); - for it in &mut _i.items { - _visitor.visit_trait_item_mut(it) - } -} -#[cfg(feature = "full")] -pub fn visit_item_type_mut(_visitor: &mut V, _i: &mut ItemType) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_visibility_mut(&mut _i.vis); - tokens_helper(_visitor, &mut (_i.type_token).0); - _visitor.visit_ident_mut(&mut _i.ident); - _visitor.visit_generics_mut(&mut _i.generics); - tokens_helper(_visitor, &mut (_i.eq_token).0); - _visitor.visit_type_mut(&mut *_i.ty); - tokens_helper(_visitor, &mut (_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_item_union_mut(_visitor: &mut V, _i: &mut ItemUnion) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_visibility_mut(&mut _i.vis); - tokens_helper(_visitor, &mut (_i.union_token).0); - _visitor.visit_ident_mut(&mut _i.ident); - _visitor.visit_generics_mut(&mut _i.generics); - _visitor.visit_fields_named_mut(&mut _i.fields); -} -#[cfg(feature = "full")] -pub fn visit_item_use_mut(_visitor: &mut V, _i: &mut ItemUse) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_visibility_mut(&mut _i.vis); - tokens_helper(_visitor, &mut (_i.use_token).0); - if let Some(ref mut it) = _i.leading_colon { - tokens_helper(_visitor, &mut (it).0) - }; - _visitor.visit_use_tree_mut(&mut _i.tree); - tokens_helper(_visitor, &mut (_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_item_verbatim_mut(_visitor: &mut V, _i: &mut ItemVerbatim) { - skip!(_i.tts); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_label_mut(_visitor: &mut V, _i: &mut Label) { - _visitor.visit_lifetime_mut(&mut _i.name); - tokens_helper(_visitor, &mut (_i.colon_token).0); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_lifetime_mut(_visitor: &mut V, _i: &mut Lifetime) { - skip!(_i.apostrophe); - _visitor.visit_ident_mut(&mut _i.ident); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_lifetime_def_mut(_visitor: &mut V, _i: &mut LifetimeDef) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_lifetime_mut(&mut _i.lifetime); - if let Some(ref mut it) = _i.colon_token { - tokens_helper(_visitor, &mut (it).0) - }; - for mut el in Punctuated::pairs_mut(&mut _i.bounds) { - let it = el.value_mut(); - _visitor.visit_lifetime_mut(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_lit_mut(_visitor: &mut V, _i: &mut Lit) { - match *_i { - Lit::Str(ref mut _binding_0) => { - _visitor.visit_lit_str_mut(_binding_0); - } - Lit::ByteStr(ref mut _binding_0) => { - _visitor.visit_lit_byte_str_mut(_binding_0); - } - Lit::Byte(ref mut _binding_0) => { - _visitor.visit_lit_byte_mut(_binding_0); - } - Lit::Char(ref mut _binding_0) => { - _visitor.visit_lit_char_mut(_binding_0); - } - Lit::Int(ref mut _binding_0) => { - _visitor.visit_lit_int_mut(_binding_0); - } - Lit::Float(ref mut _binding_0) => { - _visitor.visit_lit_float_mut(_binding_0); - } - Lit::Bool(ref mut _binding_0) => { - _visitor.visit_lit_bool_mut(_binding_0); - } - Lit::Verbatim(ref mut _binding_0) => { - _visitor.visit_lit_verbatim_mut(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_lit_bool_mut(_visitor: &mut V, _i: &mut LitBool) { - skip!(_i.value); - _visitor.visit_span_mut(&mut _i.span); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_lit_byte_mut(_visitor: &mut V, _i: &mut LitByte) { - skip!(_i.token); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_lit_byte_str_mut(_visitor: &mut V, _i: &mut LitByteStr) { - skip!(_i.token); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_lit_char_mut(_visitor: &mut V, _i: &mut LitChar) { - skip!(_i.token); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_lit_float_mut(_visitor: &mut V, _i: &mut LitFloat) { - skip!(_i.token); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_lit_int_mut(_visitor: &mut V, _i: &mut LitInt) { - skip!(_i.token); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_lit_str_mut(_visitor: &mut V, _i: &mut LitStr) { - skip!(_i.token); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_lit_verbatim_mut(_visitor: &mut V, _i: &mut LitVerbatim) { - skip!(_i.token); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_local_mut(_visitor: &mut V, _i: &mut Local) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - tokens_helper(_visitor, &mut (_i.let_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.pats) { - let it = el.value_mut(); - _visitor.visit_pat_mut(it) - } - if let Some(ref mut it) = _i.ty { - tokens_helper(_visitor, &mut ((it).0).0); - _visitor.visit_type_mut(&mut *(it).1); - }; - if let Some(ref mut it) = _i.init { - tokens_helper(_visitor, &mut ((it).0).0); - _visitor.visit_expr_mut(&mut *(it).1); - }; - tokens_helper(_visitor, &mut (_i.semi_token).0); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_macro_mut(_visitor: &mut V, _i: &mut Macro) { - _visitor.visit_path_mut(&mut _i.path); - tokens_helper(_visitor, &mut (_i.bang_token).0); - _visitor.visit_macro_delimiter_mut(&mut _i.delimiter); - skip!(_i.tts); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_macro_delimiter_mut(_visitor: &mut V, _i: &mut MacroDelimiter) { - match *_i { - MacroDelimiter::Paren(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - MacroDelimiter::Brace(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - MacroDelimiter::Bracket(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_member_mut(_visitor: &mut V, _i: &mut Member) { - match *_i { - Member::Named(ref mut _binding_0) => { - _visitor.visit_ident_mut(_binding_0); - } - Member::Unnamed(ref mut _binding_0) => { - _visitor.visit_index_mut(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_meta_mut(_visitor: &mut V, _i: &mut Meta) { - match *_i { - Meta::Word(ref mut _binding_0) => { - _visitor.visit_ident_mut(_binding_0); - } - Meta::List(ref mut _binding_0) => { - _visitor.visit_meta_list_mut(_binding_0); - } - Meta::NameValue(ref mut _binding_0) => { - _visitor.visit_meta_name_value_mut(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_meta_list_mut(_visitor: &mut V, _i: &mut MetaList) { - _visitor.visit_ident_mut(&mut _i.ident); - tokens_helper(_visitor, &mut (_i.paren_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.nested) { - let it = el.value_mut(); - _visitor.visit_nested_meta_mut(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_meta_name_value_mut(_visitor: &mut V, _i: &mut MetaNameValue) { - _visitor.visit_ident_mut(&mut _i.ident); - tokens_helper(_visitor, &mut (_i.eq_token).0); - _visitor.visit_lit_mut(&mut _i.lit); -} -#[cfg(feature = "full")] -pub fn visit_method_sig_mut(_visitor: &mut V, _i: &mut MethodSig) { - if let Some(ref mut it) = _i.constness { - tokens_helper(_visitor, &mut (it).0) - }; - if let Some(ref mut it) = _i.unsafety { - tokens_helper(_visitor, &mut (it).0) - }; - if let Some(ref mut it) = _i.abi { - _visitor.visit_abi_mut(it) - }; - _visitor.visit_ident_mut(&mut _i.ident); - _visitor.visit_fn_decl_mut(&mut _i.decl); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_method_turbofish_mut( - _visitor: &mut V, - _i: &mut MethodTurbofish, -) { - tokens_helper(_visitor, &mut (_i.colon2_token).0); - tokens_helper(_visitor, &mut (_i.lt_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.args) { - let it = el.value_mut(); - _visitor.visit_generic_method_argument_mut(it) - } - tokens_helper(_visitor, &mut (_i.gt_token).0); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_nested_meta_mut(_visitor: &mut V, _i: &mut NestedMeta) { - match *_i { - NestedMeta::Meta(ref mut _binding_0) => { - _visitor.visit_meta_mut(_binding_0); - } - NestedMeta::Literal(ref mut _binding_0) => { - _visitor.visit_lit_mut(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_parenthesized_generic_arguments_mut( - _visitor: &mut V, - _i: &mut ParenthesizedGenericArguments, -) { - tokens_helper(_visitor, &mut (_i.paren_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.inputs) { - let it = el.value_mut(); - _visitor.visit_type_mut(it) - } - _visitor.visit_return_type_mut(&mut _i.output); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_mut(_visitor: &mut V, _i: &mut Pat) { - match *_i { - Pat::Wild(ref mut _binding_0) => { - _visitor.visit_pat_wild_mut(_binding_0); - } - Pat::Ident(ref mut _binding_0) => { - _visitor.visit_pat_ident_mut(_binding_0); - } - Pat::Struct(ref mut _binding_0) => { - _visitor.visit_pat_struct_mut(_binding_0); - } - Pat::TupleStruct(ref mut _binding_0) => { - _visitor.visit_pat_tuple_struct_mut(_binding_0); - } - Pat::Path(ref mut _binding_0) => { - _visitor.visit_pat_path_mut(_binding_0); - } - Pat::Tuple(ref mut _binding_0) => { - _visitor.visit_pat_tuple_mut(_binding_0); - } - Pat::Box(ref mut _binding_0) => { - _visitor.visit_pat_box_mut(_binding_0); - } - Pat::Ref(ref mut _binding_0) => { - _visitor.visit_pat_ref_mut(_binding_0); - } - Pat::Lit(ref mut _binding_0) => { - _visitor.visit_pat_lit_mut(_binding_0); - } - Pat::Range(ref mut _binding_0) => { - _visitor.visit_pat_range_mut(_binding_0); - } - Pat::Slice(ref mut _binding_0) => { - _visitor.visit_pat_slice_mut(_binding_0); - } - Pat::Macro(ref mut _binding_0) => { - _visitor.visit_pat_macro_mut(_binding_0); - } - Pat::Verbatim(ref mut _binding_0) => { - _visitor.visit_pat_verbatim_mut(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_box_mut(_visitor: &mut V, _i: &mut PatBox) { - tokens_helper(_visitor, &mut (_i.box_token).0); - _visitor.visit_pat_mut(&mut *_i.pat); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_ident_mut(_visitor: &mut V, _i: &mut PatIdent) { - if let Some(ref mut it) = _i.by_ref { - tokens_helper(_visitor, &mut (it).0) - }; - if let Some(ref mut it) = _i.mutability { - tokens_helper(_visitor, &mut (it).0) - }; - _visitor.visit_ident_mut(&mut _i.ident); - if let Some(ref mut it) = _i.subpat { - tokens_helper(_visitor, &mut ((it).0).0); - _visitor.visit_pat_mut(&mut *(it).1); - }; -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_lit_mut(_visitor: &mut V, _i: &mut PatLit) { - _visitor.visit_expr_mut(&mut *_i.expr); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_macro_mut(_visitor: &mut V, _i: &mut PatMacro) { - _visitor.visit_macro_mut(&mut _i.mac); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_path_mut(_visitor: &mut V, _i: &mut PatPath) { - if let Some(ref mut it) = _i.qself { - _visitor.visit_qself_mut(it) - }; - _visitor.visit_path_mut(&mut _i.path); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_range_mut(_visitor: &mut V, _i: &mut PatRange) { - _visitor.visit_expr_mut(&mut *_i.lo); - _visitor.visit_range_limits_mut(&mut _i.limits); - _visitor.visit_expr_mut(&mut *_i.hi); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_ref_mut(_visitor: &mut V, _i: &mut PatRef) { - tokens_helper(_visitor, &mut (_i.and_token).0); - if let Some(ref mut it) = _i.mutability { - tokens_helper(_visitor, &mut (it).0) - }; - _visitor.visit_pat_mut(&mut *_i.pat); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_slice_mut(_visitor: &mut V, _i: &mut PatSlice) { - tokens_helper(_visitor, &mut (_i.bracket_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.front) { - let it = el.value_mut(); - _visitor.visit_pat_mut(it) - } - if let Some(ref mut it) = _i.middle { - _visitor.visit_pat_mut(&mut **it) - }; - if let Some(ref mut it) = _i.dot2_token { - tokens_helper(_visitor, &mut (it).0) - }; - if let Some(ref mut it) = _i.comma_token { - tokens_helper(_visitor, &mut (it).0) - }; - for mut el in Punctuated::pairs_mut(&mut _i.back) { - let it = el.value_mut(); - _visitor.visit_pat_mut(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_struct_mut(_visitor: &mut V, _i: &mut PatStruct) { - _visitor.visit_path_mut(&mut _i.path); - tokens_helper(_visitor, &mut (_i.brace_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.fields) { - let it = el.value_mut(); - _visitor.visit_field_pat_mut(it) - } - if let Some(ref mut it) = _i.dot2_token { - tokens_helper(_visitor, &mut (it).0) - }; -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_tuple_mut(_visitor: &mut V, _i: &mut PatTuple) { - tokens_helper(_visitor, &mut (_i.paren_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.front) { - let it = el.value_mut(); - _visitor.visit_pat_mut(it) - } - if let Some(ref mut it) = _i.dot2_token { - tokens_helper(_visitor, &mut (it).0) - }; - if let Some(ref mut it) = _i.comma_token { - tokens_helper(_visitor, &mut (it).0) - }; - for mut el in Punctuated::pairs_mut(&mut _i.back) { - let it = el.value_mut(); - _visitor.visit_pat_mut(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_tuple_struct_mut(_visitor: &mut V, _i: &mut PatTupleStruct) { - _visitor.visit_path_mut(&mut _i.path); - _visitor.visit_pat_tuple_mut(&mut _i.pat); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_verbatim_mut(_visitor: &mut V, _i: &mut PatVerbatim) { - skip!(_i.tts); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_wild_mut(_visitor: &mut V, _i: &mut PatWild) { - tokens_helper(_visitor, &mut (_i.underscore_token).0); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_path_mut(_visitor: &mut V, _i: &mut Path) { - if let Some(ref mut it) = _i.leading_colon { - tokens_helper(_visitor, &mut (it).0) - }; - for mut el in Punctuated::pairs_mut(&mut _i.segments) { - let it = el.value_mut(); - _visitor.visit_path_segment_mut(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_path_arguments_mut(_visitor: &mut V, _i: &mut PathArguments) { - match *_i { - PathArguments::None => {} - PathArguments::AngleBracketed(ref mut _binding_0) => { - _visitor.visit_angle_bracketed_generic_arguments_mut(_binding_0); - } - PathArguments::Parenthesized(ref mut _binding_0) => { - _visitor.visit_parenthesized_generic_arguments_mut(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_path_segment_mut(_visitor: &mut V, _i: &mut PathSegment) { - _visitor.visit_ident_mut(&mut _i.ident); - _visitor.visit_path_arguments_mut(&mut _i.arguments); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_predicate_eq_mut(_visitor: &mut V, _i: &mut PredicateEq) { - _visitor.visit_type_mut(&mut _i.lhs_ty); - tokens_helper(_visitor, &mut (_i.eq_token).0); - _visitor.visit_type_mut(&mut _i.rhs_ty); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_predicate_lifetime_mut( - _visitor: &mut V, - _i: &mut PredicateLifetime, -) { - _visitor.visit_lifetime_mut(&mut _i.lifetime); - if let Some(ref mut it) = _i.colon_token { - tokens_helper(_visitor, &mut (it).0) - }; - for mut el in Punctuated::pairs_mut(&mut _i.bounds) { - let it = el.value_mut(); - _visitor.visit_lifetime_mut(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_predicate_type_mut(_visitor: &mut V, _i: &mut PredicateType) { - if let Some(ref mut it) = _i.lifetimes { - _visitor.visit_bound_lifetimes_mut(it) - }; - _visitor.visit_type_mut(&mut _i.bounded_ty); - tokens_helper(_visitor, &mut (_i.colon_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.bounds) { - let it = el.value_mut(); - _visitor.visit_type_param_bound_mut(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_qself_mut(_visitor: &mut V, _i: &mut QSelf) { - tokens_helper(_visitor, &mut (_i.lt_token).0); - _visitor.visit_type_mut(&mut *_i.ty); - skip!(_i.position); - if let Some(ref mut it) = _i.as_token { - tokens_helper(_visitor, &mut (it).0) - }; - tokens_helper(_visitor, &mut (_i.gt_token).0); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_range_limits_mut(_visitor: &mut V, _i: &mut RangeLimits) { - match *_i { - RangeLimits::HalfOpen(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - RangeLimits::Closed(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_return_type_mut(_visitor: &mut V, _i: &mut ReturnType) { - match *_i { - ReturnType::Default => {} - ReturnType::Type(ref mut _binding_0, ref mut _binding_1) => { - tokens_helper(_visitor, &mut (_binding_0).0); - _visitor.visit_type_mut(&mut **_binding_1); - } - } -} -pub fn visit_span_mut(_visitor: &mut V, _i: &mut Span) {} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_stmt_mut(_visitor: &mut V, _i: &mut Stmt) { - match *_i { - Stmt::Local(ref mut _binding_0) => { - _visitor.visit_local_mut(_binding_0); - } - Stmt::Item(ref mut _binding_0) => { - _visitor.visit_item_mut(_binding_0); - } - Stmt::Expr(ref mut _binding_0) => { - _visitor.visit_expr_mut(_binding_0); - } - Stmt::Semi(ref mut _binding_0, ref mut _binding_1) => { - _visitor.visit_expr_mut(_binding_0); - tokens_helper(_visitor, &mut (_binding_1).0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_trait_bound_mut(_visitor: &mut V, _i: &mut TraitBound) { - if let Some(ref mut it) = _i.paren_token { - tokens_helper(_visitor, &mut (it).0) - }; - _visitor.visit_trait_bound_modifier_mut(&mut _i.modifier); - if let Some(ref mut it) = _i.lifetimes { - _visitor.visit_bound_lifetimes_mut(it) - }; - _visitor.visit_path_mut(&mut _i.path); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_trait_bound_modifier_mut( - _visitor: &mut V, - _i: &mut TraitBoundModifier, -) { - match *_i { - TraitBoundModifier::None => {} - TraitBoundModifier::Maybe(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - } -} -#[cfg(feature = "full")] -pub fn visit_trait_item_mut(_visitor: &mut V, _i: &mut TraitItem) { - match *_i { - TraitItem::Const(ref mut _binding_0) => { - _visitor.visit_trait_item_const_mut(_binding_0); - } - TraitItem::Method(ref mut _binding_0) => { - _visitor.visit_trait_item_method_mut(_binding_0); - } - TraitItem::Type(ref mut _binding_0) => { - _visitor.visit_trait_item_type_mut(_binding_0); - } - TraitItem::Macro(ref mut _binding_0) => { - _visitor.visit_trait_item_macro_mut(_binding_0); - } - TraitItem::Verbatim(ref mut _binding_0) => { - _visitor.visit_trait_item_verbatim_mut(_binding_0); - } - } -} -#[cfg(feature = "full")] -pub fn visit_trait_item_const_mut(_visitor: &mut V, _i: &mut TraitItemConst) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - tokens_helper(_visitor, &mut (_i.const_token).0); - _visitor.visit_ident_mut(&mut _i.ident); - tokens_helper(_visitor, &mut (_i.colon_token).0); - _visitor.visit_type_mut(&mut _i.ty); - if let Some(ref mut it) = _i.default { - tokens_helper(_visitor, &mut ((it).0).0); - _visitor.visit_expr_mut(&mut (it).1); - }; - tokens_helper(_visitor, &mut (_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_trait_item_macro_mut(_visitor: &mut V, _i: &mut TraitItemMacro) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_macro_mut(&mut _i.mac); - if let Some(ref mut it) = _i.semi_token { - tokens_helper(_visitor, &mut (it).0) - }; -} -#[cfg(feature = "full")] -pub fn visit_trait_item_method_mut( - _visitor: &mut V, - _i: &mut TraitItemMethod, -) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_method_sig_mut(&mut _i.sig); - if let Some(ref mut it) = _i.default { - _visitor.visit_block_mut(it) - }; - if let Some(ref mut it) = _i.semi_token { - tokens_helper(_visitor, &mut (it).0) - }; -} -#[cfg(feature = "full")] -pub fn visit_trait_item_type_mut(_visitor: &mut V, _i: &mut TraitItemType) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - tokens_helper(_visitor, &mut (_i.type_token).0); - _visitor.visit_ident_mut(&mut _i.ident); - _visitor.visit_generics_mut(&mut _i.generics); - if let Some(ref mut it) = _i.colon_token { - tokens_helper(_visitor, &mut (it).0) - }; - for mut el in Punctuated::pairs_mut(&mut _i.bounds) { - let it = el.value_mut(); - _visitor.visit_type_param_bound_mut(it) - } - if let Some(ref mut it) = _i.default { - tokens_helper(_visitor, &mut ((it).0).0); - _visitor.visit_type_mut(&mut (it).1); - }; - tokens_helper(_visitor, &mut (_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_trait_item_verbatim_mut( - _visitor: &mut V, - _i: &mut TraitItemVerbatim, -) { - skip!(_i.tts); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_mut(_visitor: &mut V, _i: &mut Type) { - match *_i { - Type::Slice(ref mut _binding_0) => { - _visitor.visit_type_slice_mut(_binding_0); - } - Type::Array(ref mut _binding_0) => { - _visitor.visit_type_array_mut(_binding_0); - } - Type::Ptr(ref mut _binding_0) => { - _visitor.visit_type_ptr_mut(_binding_0); - } - Type::Reference(ref mut _binding_0) => { - _visitor.visit_type_reference_mut(_binding_0); - } - Type::BareFn(ref mut _binding_0) => { - _visitor.visit_type_bare_fn_mut(_binding_0); - } - Type::Never(ref mut _binding_0) => { - _visitor.visit_type_never_mut(_binding_0); - } - Type::Tuple(ref mut _binding_0) => { - _visitor.visit_type_tuple_mut(_binding_0); - } - Type::Path(ref mut _binding_0) => { - _visitor.visit_type_path_mut(_binding_0); - } - Type::TraitObject(ref mut _binding_0) => { - _visitor.visit_type_trait_object_mut(_binding_0); - } - Type::ImplTrait(ref mut _binding_0) => { - _visitor.visit_type_impl_trait_mut(_binding_0); - } - Type::Paren(ref mut _binding_0) => { - _visitor.visit_type_paren_mut(_binding_0); - } - Type::Group(ref mut _binding_0) => { - _visitor.visit_type_group_mut(_binding_0); - } - Type::Infer(ref mut _binding_0) => { - _visitor.visit_type_infer_mut(_binding_0); - } - Type::Macro(ref mut _binding_0) => { - _visitor.visit_type_macro_mut(_binding_0); - } - Type::Verbatim(ref mut _binding_0) => { - _visitor.visit_type_verbatim_mut(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_array_mut(_visitor: &mut V, _i: &mut TypeArray) { - tokens_helper(_visitor, &mut (_i.bracket_token).0); - _visitor.visit_type_mut(&mut *_i.elem); - tokens_helper(_visitor, &mut (_i.semi_token).0); - _visitor.visit_expr_mut(&mut _i.len); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_bare_fn_mut(_visitor: &mut V, _i: &mut TypeBareFn) { - if let Some(ref mut it) = _i.unsafety { - tokens_helper(_visitor, &mut (it).0) - }; - if let Some(ref mut it) = _i.abi { - _visitor.visit_abi_mut(it) - }; - tokens_helper(_visitor, &mut (_i.fn_token).0); - if let Some(ref mut it) = _i.lifetimes { - _visitor.visit_bound_lifetimes_mut(it) - }; - tokens_helper(_visitor, &mut (_i.paren_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.inputs) { - let it = el.value_mut(); - _visitor.visit_bare_fn_arg_mut(it) - } - if let Some(ref mut it) = _i.variadic { - tokens_helper(_visitor, &mut (it).0) - }; - _visitor.visit_return_type_mut(&mut _i.output); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_group_mut(_visitor: &mut V, _i: &mut TypeGroup) { - tokens_helper(_visitor, &mut (_i.group_token).0); - _visitor.visit_type_mut(&mut *_i.elem); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_impl_trait_mut(_visitor: &mut V, _i: &mut TypeImplTrait) { - tokens_helper(_visitor, &mut (_i.impl_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.bounds) { - let it = el.value_mut(); - _visitor.visit_type_param_bound_mut(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_infer_mut(_visitor: &mut V, _i: &mut TypeInfer) { - tokens_helper(_visitor, &mut (_i.underscore_token).0); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_macro_mut(_visitor: &mut V, _i: &mut TypeMacro) { - _visitor.visit_macro_mut(&mut _i.mac); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_never_mut(_visitor: &mut V, _i: &mut TypeNever) { - tokens_helper(_visitor, &mut (_i.bang_token).0); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_param_mut(_visitor: &mut V, _i: &mut TypeParam) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_ident_mut(&mut _i.ident); - if let Some(ref mut it) = _i.colon_token { - tokens_helper(_visitor, &mut (it).0) - }; - for mut el in Punctuated::pairs_mut(&mut _i.bounds) { - let it = el.value_mut(); - _visitor.visit_type_param_bound_mut(it) - } - if let Some(ref mut it) = _i.eq_token { - tokens_helper(_visitor, &mut (it).0) - }; - if let Some(ref mut it) = _i.default { - _visitor.visit_type_mut(it) - }; -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_param_bound_mut(_visitor: &mut V, _i: &mut TypeParamBound) { - match *_i { - TypeParamBound::Trait(ref mut _binding_0) => { - _visitor.visit_trait_bound_mut(_binding_0); - } - TypeParamBound::Lifetime(ref mut _binding_0) => { - _visitor.visit_lifetime_mut(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_paren_mut(_visitor: &mut V, _i: &mut TypeParen) { - tokens_helper(_visitor, &mut (_i.paren_token).0); - _visitor.visit_type_mut(&mut *_i.elem); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_path_mut(_visitor: &mut V, _i: &mut TypePath) { - if let Some(ref mut it) = _i.qself { - _visitor.visit_qself_mut(it) - }; - _visitor.visit_path_mut(&mut _i.path); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_ptr_mut(_visitor: &mut V, _i: &mut TypePtr) { - tokens_helper(_visitor, &mut (_i.star_token).0); - if let Some(ref mut it) = _i.const_token { - tokens_helper(_visitor, &mut (it).0) - }; - if let Some(ref mut it) = _i.mutability { - tokens_helper(_visitor, &mut (it).0) - }; - _visitor.visit_type_mut(&mut *_i.elem); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_reference_mut(_visitor: &mut V, _i: &mut TypeReference) { - tokens_helper(_visitor, &mut (_i.and_token).0); - if let Some(ref mut it) = _i.lifetime { - _visitor.visit_lifetime_mut(it) - }; - if let Some(ref mut it) = _i.mutability { - tokens_helper(_visitor, &mut (it).0) - }; - _visitor.visit_type_mut(&mut *_i.elem); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_slice_mut(_visitor: &mut V, _i: &mut TypeSlice) { - tokens_helper(_visitor, &mut (_i.bracket_token).0); - _visitor.visit_type_mut(&mut *_i.elem); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_trait_object_mut( - _visitor: &mut V, - _i: &mut TypeTraitObject, -) { - if let Some(ref mut it) = _i.dyn_token { - tokens_helper(_visitor, &mut (it).0) - }; - for mut el in Punctuated::pairs_mut(&mut _i.bounds) { - let it = el.value_mut(); - _visitor.visit_type_param_bound_mut(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_tuple_mut(_visitor: &mut V, _i: &mut TypeTuple) { - tokens_helper(_visitor, &mut (_i.paren_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.elems) { - let it = el.value_mut(); - _visitor.visit_type_mut(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_verbatim_mut(_visitor: &mut V, _i: &mut TypeVerbatim) { - skip!(_i.tts); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_un_op_mut(_visitor: &mut V, _i: &mut UnOp) { - match *_i { - UnOp::Deref(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - UnOp::Not(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - UnOp::Neg(ref mut _binding_0) => { - tokens_helper(_visitor, &mut (_binding_0).0); - } - } -} -#[cfg(feature = "full")] -pub fn visit_use_glob_mut(_visitor: &mut V, _i: &mut UseGlob) { - tokens_helper(_visitor, &mut (_i.star_token).0); -} -#[cfg(feature = "full")] -pub fn visit_use_group_mut(_visitor: &mut V, _i: &mut UseGroup) { - tokens_helper(_visitor, &mut (_i.brace_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.items) { - let it = el.value_mut(); - _visitor.visit_use_tree_mut(it) - } -} -#[cfg(feature = "full")] -pub fn visit_use_name_mut(_visitor: &mut V, _i: &mut UseName) { - _visitor.visit_ident_mut(&mut _i.ident); -} -#[cfg(feature = "full")] -pub fn visit_use_path_mut(_visitor: &mut V, _i: &mut UsePath) { - _visitor.visit_ident_mut(&mut _i.ident); - tokens_helper(_visitor, &mut (_i.colon2_token).0); - _visitor.visit_use_tree_mut(&mut *_i.tree); -} -#[cfg(feature = "full")] -pub fn visit_use_rename_mut(_visitor: &mut V, _i: &mut UseRename) { - _visitor.visit_ident_mut(&mut _i.ident); - tokens_helper(_visitor, &mut (_i.as_token).0); - _visitor.visit_ident_mut(&mut _i.rename); -} -#[cfg(feature = "full")] -pub fn visit_use_tree_mut(_visitor: &mut V, _i: &mut UseTree) { - match *_i { - UseTree::Path(ref mut _binding_0) => { - _visitor.visit_use_path_mut(_binding_0); - } - UseTree::Name(ref mut _binding_0) => { - _visitor.visit_use_name_mut(_binding_0); - } - UseTree::Rename(ref mut _binding_0) => { - _visitor.visit_use_rename_mut(_binding_0); - } - UseTree::Glob(ref mut _binding_0) => { - _visitor.visit_use_glob_mut(_binding_0); - } - UseTree::Group(ref mut _binding_0) => { - _visitor.visit_use_group_mut(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_variant_mut(_visitor: &mut V, _i: &mut Variant) { - for it in &mut _i.attrs { - _visitor.visit_attribute_mut(it) - } - _visitor.visit_ident_mut(&mut _i.ident); - _visitor.visit_fields_mut(&mut _i.fields); - if let Some(ref mut it) = _i.discriminant { - tokens_helper(_visitor, &mut ((it).0).0); - _visitor.visit_expr_mut(&mut (it).1); - }; -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_vis_crate_mut(_visitor: &mut V, _i: &mut VisCrate) { - tokens_helper(_visitor, &mut (_i.crate_token).0); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_vis_public_mut(_visitor: &mut V, _i: &mut VisPublic) { - tokens_helper(_visitor, &mut (_i.pub_token).0); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_vis_restricted_mut(_visitor: &mut V, _i: &mut VisRestricted) { - tokens_helper(_visitor, &mut (_i.pub_token).0); - tokens_helper(_visitor, &mut (_i.paren_token).0); - if let Some(ref mut it) = _i.in_token { - tokens_helper(_visitor, &mut (it).0) - }; - _visitor.visit_path_mut(&mut *_i.path); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_visibility_mut(_visitor: &mut V, _i: &mut Visibility) { - match *_i { - Visibility::Public(ref mut _binding_0) => { - _visitor.visit_vis_public_mut(_binding_0); - } - Visibility::Crate(ref mut _binding_0) => { - _visitor.visit_vis_crate_mut(_binding_0); - } - Visibility::Restricted(ref mut _binding_0) => { - _visitor.visit_vis_restricted_mut(_binding_0); - } - Visibility::Inherited => {} - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_where_clause_mut(_visitor: &mut V, _i: &mut WhereClause) { - tokens_helper(_visitor, &mut (_i.where_token).0); - for mut el in Punctuated::pairs_mut(&mut _i.predicates) { - let it = el.value_mut(); - _visitor.visit_where_predicate_mut(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_where_predicate_mut(_visitor: &mut V, _i: &mut WherePredicate) { - match *_i { - WherePredicate::Type(ref mut _binding_0) => { - _visitor.visit_predicate_type_mut(_binding_0); - } - WherePredicate::Lifetime(ref mut _binding_0) => { - _visitor.visit_predicate_lifetime_mut(_binding_0); - } - WherePredicate::Eq(ref mut _binding_0) => { - _visitor.visit_predicate_eq_mut(_binding_0); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/gen/visit.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/gen/visit.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/gen/visit.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/gen/visit.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,3379 +0,0 @@ -// THIS FILE IS AUTOMATICALLY GENERATED; DO NOT EDIT - -#![cfg_attr(feature = "cargo-clippy", allow(match_same_arms))] -#[cfg(any(feature = "full", feature = "derive"))] -use gen::helper::visit::*; -use proc_macro2::Span; -#[cfg(any(feature = "full", feature = "derive"))] -use punctuated::Punctuated; -use *; -#[cfg(feature = "full")] -macro_rules! full { - ($e:expr) => { - $e - }; -} -#[cfg(all(feature = "derive", not(feature = "full")))] -macro_rules! full { - ($e:expr) => { - unreachable!() - }; -} -#[cfg(any(feature = "full", feature = "derive"))] -macro_rules! skip { - ($($tt:tt)*) => {}; -} -#[doc = r" Syntax tree traversal to walk a shared borrow of a syntax tree."] -#[doc = r""] -#[doc = r" See the [module documentation] for details."] -#[doc = r""] -#[doc = r" [module documentation]: index.html"] -#[doc = r""] -#[doc = r#" *This trait is available if Syn is built with the `"visit"` feature.*"#] -pub trait Visit<'ast> { - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_abi(&mut self, i: &'ast Abi) { - visit_abi(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_angle_bracketed_generic_arguments(&mut self, i: &'ast AngleBracketedGenericArguments) { - visit_angle_bracketed_generic_arguments(self, i) - } - #[cfg(feature = "full")] - fn visit_arg_captured(&mut self, i: &'ast ArgCaptured) { - visit_arg_captured(self, i) - } - #[cfg(feature = "full")] - fn visit_arg_self(&mut self, i: &'ast ArgSelf) { - visit_arg_self(self, i) - } - #[cfg(feature = "full")] - fn visit_arg_self_ref(&mut self, i: &'ast ArgSelfRef) { - visit_arg_self_ref(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_arm(&mut self, i: &'ast Arm) { - visit_arm(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_attr_style(&mut self, i: &'ast AttrStyle) { - visit_attr_style(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_attribute(&mut self, i: &'ast Attribute) { - visit_attribute(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_bare_fn_arg(&mut self, i: &'ast BareFnArg) { - visit_bare_fn_arg(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_bare_fn_arg_name(&mut self, i: &'ast BareFnArgName) { - visit_bare_fn_arg_name(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_bin_op(&mut self, i: &'ast BinOp) { - visit_bin_op(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_binding(&mut self, i: &'ast Binding) { - visit_binding(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_block(&mut self, i: &'ast Block) { - visit_block(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_bound_lifetimes(&mut self, i: &'ast BoundLifetimes) { - visit_bound_lifetimes(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_const_param(&mut self, i: &'ast ConstParam) { - visit_const_param(self, i) - } - #[cfg(feature = "derive")] - fn visit_data(&mut self, i: &'ast Data) { - visit_data(self, i) - } - #[cfg(feature = "derive")] - fn visit_data_enum(&mut self, i: &'ast DataEnum) { - visit_data_enum(self, i) - } - #[cfg(feature = "derive")] - fn visit_data_struct(&mut self, i: &'ast DataStruct) { - visit_data_struct(self, i) - } - #[cfg(feature = "derive")] - fn visit_data_union(&mut self, i: &'ast DataUnion) { - visit_data_union(self, i) - } - #[cfg(feature = "derive")] - fn visit_derive_input(&mut self, i: &'ast DeriveInput) { - visit_derive_input(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr(&mut self, i: &'ast Expr) { - visit_expr(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_array(&mut self, i: &'ast ExprArray) { - visit_expr_array(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_assign(&mut self, i: &'ast ExprAssign) { - visit_expr_assign(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_assign_op(&mut self, i: &'ast ExprAssignOp) { - visit_expr_assign_op(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_binary(&mut self, i: &'ast ExprBinary) { - visit_expr_binary(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_block(&mut self, i: &'ast ExprBlock) { - visit_expr_block(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_box(&mut self, i: &'ast ExprBox) { - visit_expr_box(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_break(&mut self, i: &'ast ExprBreak) { - visit_expr_break(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_call(&mut self, i: &'ast ExprCall) { - visit_expr_call(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_cast(&mut self, i: &'ast ExprCast) { - visit_expr_cast(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_catch(&mut self, i: &'ast ExprCatch) { - visit_expr_catch(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_closure(&mut self, i: &'ast ExprClosure) { - visit_expr_closure(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_continue(&mut self, i: &'ast ExprContinue) { - visit_expr_continue(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_field(&mut self, i: &'ast ExprField) { - visit_expr_field(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_for_loop(&mut self, i: &'ast ExprForLoop) { - visit_expr_for_loop(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_group(&mut self, i: &'ast ExprGroup) { - visit_expr_group(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_if(&mut self, i: &'ast ExprIf) { - visit_expr_if(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_if_let(&mut self, i: &'ast ExprIfLet) { - visit_expr_if_let(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_in_place(&mut self, i: &'ast ExprInPlace) { - visit_expr_in_place(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_index(&mut self, i: &'ast ExprIndex) { - visit_expr_index(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_lit(&mut self, i: &'ast ExprLit) { - visit_expr_lit(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_loop(&mut self, i: &'ast ExprLoop) { - visit_expr_loop(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_macro(&mut self, i: &'ast ExprMacro) { - visit_expr_macro(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_match(&mut self, i: &'ast ExprMatch) { - visit_expr_match(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_method_call(&mut self, i: &'ast ExprMethodCall) { - visit_expr_method_call(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_paren(&mut self, i: &'ast ExprParen) { - visit_expr_paren(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_path(&mut self, i: &'ast ExprPath) { - visit_expr_path(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_range(&mut self, i: &'ast ExprRange) { - visit_expr_range(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_reference(&mut self, i: &'ast ExprReference) { - visit_expr_reference(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_repeat(&mut self, i: &'ast ExprRepeat) { - visit_expr_repeat(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_return(&mut self, i: &'ast ExprReturn) { - visit_expr_return(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_struct(&mut self, i: &'ast ExprStruct) { - visit_expr_struct(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_try(&mut self, i: &'ast ExprTry) { - visit_expr_try(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_tuple(&mut self, i: &'ast ExprTuple) { - visit_expr_tuple(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_type(&mut self, i: &'ast ExprType) { - visit_expr_type(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_unary(&mut self, i: &'ast ExprUnary) { - visit_expr_unary(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_unsafe(&mut self, i: &'ast ExprUnsafe) { - visit_expr_unsafe(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_verbatim(&mut self, i: &'ast ExprVerbatim) { - visit_expr_verbatim(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_while(&mut self, i: &'ast ExprWhile) { - visit_expr_while(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_while_let(&mut self, i: &'ast ExprWhileLet) { - visit_expr_while_let(self, i) - } - #[cfg(feature = "full")] - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_expr_yield(&mut self, i: &'ast ExprYield) { - visit_expr_yield(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_field(&mut self, i: &'ast Field) { - visit_field(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_field_pat(&mut self, i: &'ast FieldPat) { - visit_field_pat(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_field_value(&mut self, i: &'ast FieldValue) { - visit_field_value(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_fields(&mut self, i: &'ast Fields) { - visit_fields(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_fields_named(&mut self, i: &'ast FieldsNamed) { - visit_fields_named(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_fields_unnamed(&mut self, i: &'ast FieldsUnnamed) { - visit_fields_unnamed(self, i) - } - #[cfg(feature = "full")] - fn visit_file(&mut self, i: &'ast File) { - visit_file(self, i) - } - #[cfg(feature = "full")] - fn visit_fn_arg(&mut self, i: &'ast FnArg) { - visit_fn_arg(self, i) - } - #[cfg(feature = "full")] - fn visit_fn_decl(&mut self, i: &'ast FnDecl) { - visit_fn_decl(self, i) - } - #[cfg(feature = "full")] - fn visit_foreign_item(&mut self, i: &'ast ForeignItem) { - visit_foreign_item(self, i) - } - #[cfg(feature = "full")] - fn visit_foreign_item_fn(&mut self, i: &'ast ForeignItemFn) { - visit_foreign_item_fn(self, i) - } - #[cfg(feature = "full")] - fn visit_foreign_item_static(&mut self, i: &'ast ForeignItemStatic) { - visit_foreign_item_static(self, i) - } - #[cfg(feature = "full")] - fn visit_foreign_item_type(&mut self, i: &'ast ForeignItemType) { - visit_foreign_item_type(self, i) - } - #[cfg(feature = "full")] - fn visit_foreign_item_verbatim(&mut self, i: &'ast ForeignItemVerbatim) { - visit_foreign_item_verbatim(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_generic_argument(&mut self, i: &'ast GenericArgument) { - visit_generic_argument(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_generic_method_argument(&mut self, i: &'ast GenericMethodArgument) { - visit_generic_method_argument(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_generic_param(&mut self, i: &'ast GenericParam) { - visit_generic_param(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_generics(&mut self, i: &'ast Generics) { - visit_generics(self, i) - } - fn visit_ident(&mut self, i: &'ast Ident) { - visit_ident(self, i) - } - #[cfg(feature = "full")] - fn visit_impl_item(&mut self, i: &'ast ImplItem) { - visit_impl_item(self, i) - } - #[cfg(feature = "full")] - fn visit_impl_item_const(&mut self, i: &'ast ImplItemConst) { - visit_impl_item_const(self, i) - } - #[cfg(feature = "full")] - fn visit_impl_item_macro(&mut self, i: &'ast ImplItemMacro) { - visit_impl_item_macro(self, i) - } - #[cfg(feature = "full")] - fn visit_impl_item_method(&mut self, i: &'ast ImplItemMethod) { - visit_impl_item_method(self, i) - } - #[cfg(feature = "full")] - fn visit_impl_item_type(&mut self, i: &'ast ImplItemType) { - visit_impl_item_type(self, i) - } - #[cfg(feature = "full")] - fn visit_impl_item_verbatim(&mut self, i: &'ast ImplItemVerbatim) { - visit_impl_item_verbatim(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_index(&mut self, i: &'ast Index) { - visit_index(self, i) - } - #[cfg(feature = "full")] - fn visit_item(&mut self, i: &'ast Item) { - visit_item(self, i) - } - #[cfg(feature = "full")] - fn visit_item_const(&mut self, i: &'ast ItemConst) { - visit_item_const(self, i) - } - #[cfg(feature = "full")] - fn visit_item_enum(&mut self, i: &'ast ItemEnum) { - visit_item_enum(self, i) - } - #[cfg(feature = "full")] - fn visit_item_extern_crate(&mut self, i: &'ast ItemExternCrate) { - visit_item_extern_crate(self, i) - } - #[cfg(feature = "full")] - fn visit_item_fn(&mut self, i: &'ast ItemFn) { - visit_item_fn(self, i) - } - #[cfg(feature = "full")] - fn visit_item_foreign_mod(&mut self, i: &'ast ItemForeignMod) { - visit_item_foreign_mod(self, i) - } - #[cfg(feature = "full")] - fn visit_item_impl(&mut self, i: &'ast ItemImpl) { - visit_item_impl(self, i) - } - #[cfg(feature = "full")] - fn visit_item_macro(&mut self, i: &'ast ItemMacro) { - visit_item_macro(self, i) - } - #[cfg(feature = "full")] - fn visit_item_macro2(&mut self, i: &'ast ItemMacro2) { - visit_item_macro2(self, i) - } - #[cfg(feature = "full")] - fn visit_item_mod(&mut self, i: &'ast ItemMod) { - visit_item_mod(self, i) - } - #[cfg(feature = "full")] - fn visit_item_static(&mut self, i: &'ast ItemStatic) { - visit_item_static(self, i) - } - #[cfg(feature = "full")] - fn visit_item_struct(&mut self, i: &'ast ItemStruct) { - visit_item_struct(self, i) - } - #[cfg(feature = "full")] - fn visit_item_trait(&mut self, i: &'ast ItemTrait) { - visit_item_trait(self, i) - } - #[cfg(feature = "full")] - fn visit_item_type(&mut self, i: &'ast ItemType) { - visit_item_type(self, i) - } - #[cfg(feature = "full")] - fn visit_item_union(&mut self, i: &'ast ItemUnion) { - visit_item_union(self, i) - } - #[cfg(feature = "full")] - fn visit_item_use(&mut self, i: &'ast ItemUse) { - visit_item_use(self, i) - } - #[cfg(feature = "full")] - fn visit_item_verbatim(&mut self, i: &'ast ItemVerbatim) { - visit_item_verbatim(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_label(&mut self, i: &'ast Label) { - visit_label(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_lifetime(&mut self, i: &'ast Lifetime) { - visit_lifetime(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_lifetime_def(&mut self, i: &'ast LifetimeDef) { - visit_lifetime_def(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_lit(&mut self, i: &'ast Lit) { - visit_lit(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_lit_bool(&mut self, i: &'ast LitBool) { - visit_lit_bool(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_lit_byte(&mut self, i: &'ast LitByte) { - visit_lit_byte(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_lit_byte_str(&mut self, i: &'ast LitByteStr) { - visit_lit_byte_str(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_lit_char(&mut self, i: &'ast LitChar) { - visit_lit_char(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_lit_float(&mut self, i: &'ast LitFloat) { - visit_lit_float(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_lit_int(&mut self, i: &'ast LitInt) { - visit_lit_int(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_lit_str(&mut self, i: &'ast LitStr) { - visit_lit_str(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_lit_verbatim(&mut self, i: &'ast LitVerbatim) { - visit_lit_verbatim(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_local(&mut self, i: &'ast Local) { - visit_local(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_macro(&mut self, i: &'ast Macro) { - visit_macro(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_macro_delimiter(&mut self, i: &'ast MacroDelimiter) { - visit_macro_delimiter(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_member(&mut self, i: &'ast Member) { - visit_member(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_meta(&mut self, i: &'ast Meta) { - visit_meta(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_meta_list(&mut self, i: &'ast MetaList) { - visit_meta_list(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_meta_name_value(&mut self, i: &'ast MetaNameValue) { - visit_meta_name_value(self, i) - } - #[cfg(feature = "full")] - fn visit_method_sig(&mut self, i: &'ast MethodSig) { - visit_method_sig(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_method_turbofish(&mut self, i: &'ast MethodTurbofish) { - visit_method_turbofish(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_nested_meta(&mut self, i: &'ast NestedMeta) { - visit_nested_meta(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_parenthesized_generic_arguments(&mut self, i: &'ast ParenthesizedGenericArguments) { - visit_parenthesized_generic_arguments(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat(&mut self, i: &'ast Pat) { - visit_pat(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_box(&mut self, i: &'ast PatBox) { - visit_pat_box(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_ident(&mut self, i: &'ast PatIdent) { - visit_pat_ident(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_lit(&mut self, i: &'ast PatLit) { - visit_pat_lit(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_macro(&mut self, i: &'ast PatMacro) { - visit_pat_macro(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_path(&mut self, i: &'ast PatPath) { - visit_pat_path(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_range(&mut self, i: &'ast PatRange) { - visit_pat_range(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_ref(&mut self, i: &'ast PatRef) { - visit_pat_ref(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_slice(&mut self, i: &'ast PatSlice) { - visit_pat_slice(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_struct(&mut self, i: &'ast PatStruct) { - visit_pat_struct(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_tuple(&mut self, i: &'ast PatTuple) { - visit_pat_tuple(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_tuple_struct(&mut self, i: &'ast PatTupleStruct) { - visit_pat_tuple_struct(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_verbatim(&mut self, i: &'ast PatVerbatim) { - visit_pat_verbatim(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_pat_wild(&mut self, i: &'ast PatWild) { - visit_pat_wild(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_path(&mut self, i: &'ast Path) { - visit_path(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_path_arguments(&mut self, i: &'ast PathArguments) { - visit_path_arguments(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_path_segment(&mut self, i: &'ast PathSegment) { - visit_path_segment(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_predicate_eq(&mut self, i: &'ast PredicateEq) { - visit_predicate_eq(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_predicate_lifetime(&mut self, i: &'ast PredicateLifetime) { - visit_predicate_lifetime(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_predicate_type(&mut self, i: &'ast PredicateType) { - visit_predicate_type(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_qself(&mut self, i: &'ast QSelf) { - visit_qself(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_range_limits(&mut self, i: &'ast RangeLimits) { - visit_range_limits(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_return_type(&mut self, i: &'ast ReturnType) { - visit_return_type(self, i) - } - fn visit_span(&mut self, i: &'ast Span) { - visit_span(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - #[cfg(feature = "full")] - fn visit_stmt(&mut self, i: &'ast Stmt) { - visit_stmt(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_trait_bound(&mut self, i: &'ast TraitBound) { - visit_trait_bound(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_trait_bound_modifier(&mut self, i: &'ast TraitBoundModifier) { - visit_trait_bound_modifier(self, i) - } - #[cfg(feature = "full")] - fn visit_trait_item(&mut self, i: &'ast TraitItem) { - visit_trait_item(self, i) - } - #[cfg(feature = "full")] - fn visit_trait_item_const(&mut self, i: &'ast TraitItemConst) { - visit_trait_item_const(self, i) - } - #[cfg(feature = "full")] - fn visit_trait_item_macro(&mut self, i: &'ast TraitItemMacro) { - visit_trait_item_macro(self, i) - } - #[cfg(feature = "full")] - fn visit_trait_item_method(&mut self, i: &'ast TraitItemMethod) { - visit_trait_item_method(self, i) - } - #[cfg(feature = "full")] - fn visit_trait_item_type(&mut self, i: &'ast TraitItemType) { - visit_trait_item_type(self, i) - } - #[cfg(feature = "full")] - fn visit_trait_item_verbatim(&mut self, i: &'ast TraitItemVerbatim) { - visit_trait_item_verbatim(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type(&mut self, i: &'ast Type) { - visit_type(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_array(&mut self, i: &'ast TypeArray) { - visit_type_array(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_bare_fn(&mut self, i: &'ast TypeBareFn) { - visit_type_bare_fn(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_group(&mut self, i: &'ast TypeGroup) { - visit_type_group(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_impl_trait(&mut self, i: &'ast TypeImplTrait) { - visit_type_impl_trait(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_infer(&mut self, i: &'ast TypeInfer) { - visit_type_infer(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_macro(&mut self, i: &'ast TypeMacro) { - visit_type_macro(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_never(&mut self, i: &'ast TypeNever) { - visit_type_never(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_param(&mut self, i: &'ast TypeParam) { - visit_type_param(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_param_bound(&mut self, i: &'ast TypeParamBound) { - visit_type_param_bound(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_paren(&mut self, i: &'ast TypeParen) { - visit_type_paren(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_path(&mut self, i: &'ast TypePath) { - visit_type_path(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_ptr(&mut self, i: &'ast TypePtr) { - visit_type_ptr(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_reference(&mut self, i: &'ast TypeReference) { - visit_type_reference(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_slice(&mut self, i: &'ast TypeSlice) { - visit_type_slice(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_trait_object(&mut self, i: &'ast TypeTraitObject) { - visit_type_trait_object(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_tuple(&mut self, i: &'ast TypeTuple) { - visit_type_tuple(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_type_verbatim(&mut self, i: &'ast TypeVerbatim) { - visit_type_verbatim(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_un_op(&mut self, i: &'ast UnOp) { - visit_un_op(self, i) - } - #[cfg(feature = "full")] - fn visit_use_glob(&mut self, i: &'ast UseGlob) { - visit_use_glob(self, i) - } - #[cfg(feature = "full")] - fn visit_use_group(&mut self, i: &'ast UseGroup) { - visit_use_group(self, i) - } - #[cfg(feature = "full")] - fn visit_use_name(&mut self, i: &'ast UseName) { - visit_use_name(self, i) - } - #[cfg(feature = "full")] - fn visit_use_path(&mut self, i: &'ast UsePath) { - visit_use_path(self, i) - } - #[cfg(feature = "full")] - fn visit_use_rename(&mut self, i: &'ast UseRename) { - visit_use_rename(self, i) - } - #[cfg(feature = "full")] - fn visit_use_tree(&mut self, i: &'ast UseTree) { - visit_use_tree(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_variant(&mut self, i: &'ast Variant) { - visit_variant(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_vis_crate(&mut self, i: &'ast VisCrate) { - visit_vis_crate(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_vis_public(&mut self, i: &'ast VisPublic) { - visit_vis_public(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_vis_restricted(&mut self, i: &'ast VisRestricted) { - visit_vis_restricted(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_visibility(&mut self, i: &'ast Visibility) { - visit_visibility(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_where_clause(&mut self, i: &'ast WhereClause) { - visit_where_clause(self, i) - } - #[cfg(any(feature = "full", feature = "derive"))] - fn visit_where_predicate(&mut self, i: &'ast WherePredicate) { - visit_where_predicate(self, i) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_abi<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Abi) { - tokens_helper(_visitor, &(_i.extern_token).0); - if let Some(ref it) = _i.name { - _visitor.visit_lit_str(it) - }; -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_angle_bracketed_generic_arguments<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast AngleBracketedGenericArguments, -) { - if let Some(ref it) = _i.colon2_token { - tokens_helper(_visitor, &(it).0) - }; - tokens_helper(_visitor, &(_i.lt_token).0); - for el in Punctuated::pairs(&_i.args) { - let it = el.value(); - _visitor.visit_generic_argument(it) - } - tokens_helper(_visitor, &(_i.gt_token).0); -} -#[cfg(feature = "full")] -pub fn visit_arg_captured<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ArgCaptured) { - _visitor.visit_pat(&_i.pat); - tokens_helper(_visitor, &(_i.colon_token).0); - _visitor.visit_type(&_i.ty); -} -#[cfg(feature = "full")] -pub fn visit_arg_self<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ArgSelf) { - if let Some(ref it) = _i.mutability { - tokens_helper(_visitor, &(it).0) - }; - tokens_helper(_visitor, &(_i.self_token).0); -} -#[cfg(feature = "full")] -pub fn visit_arg_self_ref<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ArgSelfRef) { - tokens_helper(_visitor, &(_i.and_token).0); - if let Some(ref it) = _i.lifetime { - _visitor.visit_lifetime(it) - }; - if let Some(ref it) = _i.mutability { - tokens_helper(_visitor, &(it).0) - }; - tokens_helper(_visitor, &(_i.self_token).0); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_arm<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Arm) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - if let Some(ref it) = _i.leading_vert { - tokens_helper(_visitor, &(it).0) - }; - for el in Punctuated::pairs(&_i.pats) { - let it = el.value(); - _visitor.visit_pat(it) - } - if let Some(ref it) = _i.guard { - tokens_helper(_visitor, &((it).0).0); - _visitor.visit_expr(&*(it).1); - }; - tokens_helper(_visitor, &(_i.fat_arrow_token).0); - _visitor.visit_expr(&*_i.body); - if let Some(ref it) = _i.comma { - tokens_helper(_visitor, &(it).0) - }; -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_attr_style<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast AttrStyle) { - match *_i { - AttrStyle::Outer => {} - AttrStyle::Inner(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_attribute<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Attribute) { - tokens_helper(_visitor, &(_i.pound_token).0); - _visitor.visit_attr_style(&_i.style); - tokens_helper(_visitor, &(_i.bracket_token).0); - _visitor.visit_path(&_i.path); - skip!(_i.tts); - skip!(_i.is_sugared_doc); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_bare_fn_arg<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast BareFnArg) { - if let Some(ref it) = _i.name { - _visitor.visit_bare_fn_arg_name(&(it).0); - tokens_helper(_visitor, &((it).1).0); - }; - _visitor.visit_type(&_i.ty); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_bare_fn_arg_name<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast BareFnArgName, -) { - match *_i { - BareFnArgName::Named(ref _binding_0) => { - _visitor.visit_ident(_binding_0); - } - BareFnArgName::Wild(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_bin_op<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast BinOp) { - match *_i { - BinOp::Add(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::Sub(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::Mul(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::Div(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::Rem(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::And(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::Or(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::BitXor(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::BitAnd(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::BitOr(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::Shl(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::Shr(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::Eq(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::Lt(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::Le(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::Ne(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::Ge(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::Gt(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::AddEq(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::SubEq(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::MulEq(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::DivEq(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::RemEq(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::BitXorEq(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::BitAndEq(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::BitOrEq(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::ShlEq(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - BinOp::ShrEq(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_binding<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Binding) { - _visitor.visit_ident(&_i.ident); - tokens_helper(_visitor, &(_i.eq_token).0); - _visitor.visit_type(&_i.ty); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_block<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Block) { - tokens_helper(_visitor, &(_i.brace_token).0); - for it in &_i.stmts { - _visitor.visit_stmt(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_bound_lifetimes<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast BoundLifetimes, -) { - tokens_helper(_visitor, &(_i.for_token).0); - tokens_helper(_visitor, &(_i.lt_token).0); - for el in Punctuated::pairs(&_i.lifetimes) { - let it = el.value(); - _visitor.visit_lifetime_def(it) - } - tokens_helper(_visitor, &(_i.gt_token).0); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_const_param<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ConstParam) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - tokens_helper(_visitor, &(_i.const_token).0); - _visitor.visit_ident(&_i.ident); - tokens_helper(_visitor, &(_i.colon_token).0); - _visitor.visit_type(&_i.ty); - if let Some(ref it) = _i.eq_token { - tokens_helper(_visitor, &(it).0) - }; - if let Some(ref it) = _i.default { - _visitor.visit_expr(it) - }; -} -#[cfg(feature = "derive")] -pub fn visit_data<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Data) { - match *_i { - Data::Struct(ref _binding_0) => { - _visitor.visit_data_struct(_binding_0); - } - Data::Enum(ref _binding_0) => { - _visitor.visit_data_enum(_binding_0); - } - Data::Union(ref _binding_0) => { - _visitor.visit_data_union(_binding_0); - } - } -} -#[cfg(feature = "derive")] -pub fn visit_data_enum<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast DataEnum) { - tokens_helper(_visitor, &(_i.enum_token).0); - tokens_helper(_visitor, &(_i.brace_token).0); - for el in Punctuated::pairs(&_i.variants) { - let it = el.value(); - _visitor.visit_variant(it) - } -} -#[cfg(feature = "derive")] -pub fn visit_data_struct<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast DataStruct) { - tokens_helper(_visitor, &(_i.struct_token).0); - _visitor.visit_fields(&_i.fields); - if let Some(ref it) = _i.semi_token { - tokens_helper(_visitor, &(it).0) - }; -} -#[cfg(feature = "derive")] -pub fn visit_data_union<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast DataUnion) { - tokens_helper(_visitor, &(_i.union_token).0); - _visitor.visit_fields_named(&_i.fields); -} -#[cfg(feature = "derive")] -pub fn visit_derive_input<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast DeriveInput) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_visibility(&_i.vis); - _visitor.visit_ident(&_i.ident); - _visitor.visit_generics(&_i.generics); - _visitor.visit_data(&_i.data); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Expr) { - match *_i { - Expr::Box(ref _binding_0) => { - full!(_visitor.visit_expr_box(_binding_0)); - } - Expr::InPlace(ref _binding_0) => { - full!(_visitor.visit_expr_in_place(_binding_0)); - } - Expr::Array(ref _binding_0) => { - full!(_visitor.visit_expr_array(_binding_0)); - } - Expr::Call(ref _binding_0) => { - _visitor.visit_expr_call(_binding_0); - } - Expr::MethodCall(ref _binding_0) => { - full!(_visitor.visit_expr_method_call(_binding_0)); - } - Expr::Tuple(ref _binding_0) => { - full!(_visitor.visit_expr_tuple(_binding_0)); - } - Expr::Binary(ref _binding_0) => { - _visitor.visit_expr_binary(_binding_0); - } - Expr::Unary(ref _binding_0) => { - _visitor.visit_expr_unary(_binding_0); - } - Expr::Lit(ref _binding_0) => { - _visitor.visit_expr_lit(_binding_0); - } - Expr::Cast(ref _binding_0) => { - _visitor.visit_expr_cast(_binding_0); - } - Expr::Type(ref _binding_0) => { - full!(_visitor.visit_expr_type(_binding_0)); - } - Expr::If(ref _binding_0) => { - full!(_visitor.visit_expr_if(_binding_0)); - } - Expr::IfLet(ref _binding_0) => { - full!(_visitor.visit_expr_if_let(_binding_0)); - } - Expr::While(ref _binding_0) => { - full!(_visitor.visit_expr_while(_binding_0)); - } - Expr::WhileLet(ref _binding_0) => { - full!(_visitor.visit_expr_while_let(_binding_0)); - } - Expr::ForLoop(ref _binding_0) => { - full!(_visitor.visit_expr_for_loop(_binding_0)); - } - Expr::Loop(ref _binding_0) => { - full!(_visitor.visit_expr_loop(_binding_0)); - } - Expr::Match(ref _binding_0) => { - full!(_visitor.visit_expr_match(_binding_0)); - } - Expr::Closure(ref _binding_0) => { - full!(_visitor.visit_expr_closure(_binding_0)); - } - Expr::Unsafe(ref _binding_0) => { - full!(_visitor.visit_expr_unsafe(_binding_0)); - } - Expr::Block(ref _binding_0) => { - full!(_visitor.visit_expr_block(_binding_0)); - } - Expr::Assign(ref _binding_0) => { - full!(_visitor.visit_expr_assign(_binding_0)); - } - Expr::AssignOp(ref _binding_0) => { - full!(_visitor.visit_expr_assign_op(_binding_0)); - } - Expr::Field(ref _binding_0) => { - _visitor.visit_expr_field(_binding_0); - } - Expr::Index(ref _binding_0) => { - _visitor.visit_expr_index(_binding_0); - } - Expr::Range(ref _binding_0) => { - full!(_visitor.visit_expr_range(_binding_0)); - } - Expr::Path(ref _binding_0) => { - _visitor.visit_expr_path(_binding_0); - } - Expr::Reference(ref _binding_0) => { - full!(_visitor.visit_expr_reference(_binding_0)); - } - Expr::Break(ref _binding_0) => { - full!(_visitor.visit_expr_break(_binding_0)); - } - Expr::Continue(ref _binding_0) => { - full!(_visitor.visit_expr_continue(_binding_0)); - } - Expr::Return(ref _binding_0) => { - full!(_visitor.visit_expr_return(_binding_0)); - } - Expr::Macro(ref _binding_0) => { - full!(_visitor.visit_expr_macro(_binding_0)); - } - Expr::Struct(ref _binding_0) => { - full!(_visitor.visit_expr_struct(_binding_0)); - } - Expr::Repeat(ref _binding_0) => { - full!(_visitor.visit_expr_repeat(_binding_0)); - } - Expr::Paren(ref _binding_0) => { - _visitor.visit_expr_paren(_binding_0); - } - Expr::Group(ref _binding_0) => { - full!(_visitor.visit_expr_group(_binding_0)); - } - Expr::Try(ref _binding_0) => { - full!(_visitor.visit_expr_try(_binding_0)); - } - Expr::Catch(ref _binding_0) => { - full!(_visitor.visit_expr_catch(_binding_0)); - } - Expr::Yield(ref _binding_0) => { - full!(_visitor.visit_expr_yield(_binding_0)); - } - Expr::Verbatim(ref _binding_0) => { - _visitor.visit_expr_verbatim(_binding_0); - } - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_array<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprArray) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - tokens_helper(_visitor, &(_i.bracket_token).0); - for el in Punctuated::pairs(&_i.elems) { - let it = el.value(); - _visitor.visit_expr(it) - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_assign<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprAssign) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_expr(&*_i.left); - tokens_helper(_visitor, &(_i.eq_token).0); - _visitor.visit_expr(&*_i.right); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_assign_op<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast ExprAssignOp, -) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_expr(&*_i.left); - _visitor.visit_bin_op(&_i.op); - _visitor.visit_expr(&*_i.right); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_binary<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprBinary) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_expr(&*_i.left); - _visitor.visit_bin_op(&_i.op); - _visitor.visit_expr(&*_i.right); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_block<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprBlock) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_block(&_i.block); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_box<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprBox) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - tokens_helper(_visitor, &(_i.box_token).0); - _visitor.visit_expr(&*_i.expr); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_break<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprBreak) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - tokens_helper(_visitor, &(_i.break_token).0); - if let Some(ref it) = _i.label { - _visitor.visit_lifetime(it) - }; - if let Some(ref it) = _i.expr { - _visitor.visit_expr(&**it) - }; -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_call<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprCall) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_expr(&*_i.func); - tokens_helper(_visitor, &(_i.paren_token).0); - for el in Punctuated::pairs(&_i.args) { - let it = el.value(); - _visitor.visit_expr(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_cast<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprCast) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_expr(&*_i.expr); - tokens_helper(_visitor, &(_i.as_token).0); - _visitor.visit_type(&*_i.ty); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_catch<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprCatch) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - tokens_helper(_visitor, &(_i.do_token).0); - tokens_helper(_visitor, &(_i.catch_token).0); - _visitor.visit_block(&_i.block); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_closure<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprClosure) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - if let Some(ref it) = _i.movability { - tokens_helper(_visitor, &(it).0) - }; - if let Some(ref it) = _i.capture { - tokens_helper(_visitor, &(it).0) - }; - tokens_helper(_visitor, &(_i.or1_token).0); - for el in Punctuated::pairs(&_i.inputs) { - let it = el.value(); - _visitor.visit_fn_arg(it) - } - tokens_helper(_visitor, &(_i.or2_token).0); - _visitor.visit_return_type(&_i.output); - _visitor.visit_expr(&*_i.body); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_continue<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast ExprContinue, -) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - tokens_helper(_visitor, &(_i.continue_token).0); - if let Some(ref it) = _i.label { - _visitor.visit_lifetime(it) - }; -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_field<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprField) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_expr(&*_i.base); - tokens_helper(_visitor, &(_i.dot_token).0); - _visitor.visit_member(&_i.member); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_for_loop<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprForLoop) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - if let Some(ref it) = _i.label { - _visitor.visit_label(it) - }; - tokens_helper(_visitor, &(_i.for_token).0); - _visitor.visit_pat(&*_i.pat); - tokens_helper(_visitor, &(_i.in_token).0); - _visitor.visit_expr(&*_i.expr); - _visitor.visit_block(&_i.body); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_group<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprGroup) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - tokens_helper(_visitor, &(_i.group_token).0); - _visitor.visit_expr(&*_i.expr); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_if<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprIf) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - tokens_helper(_visitor, &(_i.if_token).0); - _visitor.visit_expr(&*_i.cond); - _visitor.visit_block(&_i.then_branch); - if let Some(ref it) = _i.else_branch { - tokens_helper(_visitor, &((it).0).0); - _visitor.visit_expr(&*(it).1); - }; -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_if_let<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprIfLet) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - tokens_helper(_visitor, &(_i.if_token).0); - tokens_helper(_visitor, &(_i.let_token).0); - for el in Punctuated::pairs(&_i.pats) { - let it = el.value(); - _visitor.visit_pat(it) - } - tokens_helper(_visitor, &(_i.eq_token).0); - _visitor.visit_expr(&*_i.expr); - _visitor.visit_block(&_i.then_branch); - if let Some(ref it) = _i.else_branch { - tokens_helper(_visitor, &((it).0).0); - _visitor.visit_expr(&*(it).1); - }; -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_in_place<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprInPlace) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_expr(&*_i.place); - tokens_helper(_visitor, &(_i.arrow_token).0); - _visitor.visit_expr(&*_i.value); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_index<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprIndex) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_expr(&*_i.expr); - tokens_helper(_visitor, &(_i.bracket_token).0); - _visitor.visit_expr(&*_i.index); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_lit<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprLit) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_lit(&_i.lit); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_loop<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprLoop) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - if let Some(ref it) = _i.label { - _visitor.visit_label(it) - }; - tokens_helper(_visitor, &(_i.loop_token).0); - _visitor.visit_block(&_i.body); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_macro<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprMacro) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_macro(&_i.mac); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_match<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprMatch) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - tokens_helper(_visitor, &(_i.match_token).0); - _visitor.visit_expr(&*_i.expr); - tokens_helper(_visitor, &(_i.brace_token).0); - for it in &_i.arms { - _visitor.visit_arm(it) - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_method_call<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast ExprMethodCall, -) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_expr(&*_i.receiver); - tokens_helper(_visitor, &(_i.dot_token).0); - _visitor.visit_ident(&_i.method); - if let Some(ref it) = _i.turbofish { - _visitor.visit_method_turbofish(it) - }; - tokens_helper(_visitor, &(_i.paren_token).0); - for el in Punctuated::pairs(&_i.args) { - let it = el.value(); - _visitor.visit_expr(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_paren<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprParen) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - tokens_helper(_visitor, &(_i.paren_token).0); - _visitor.visit_expr(&*_i.expr); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_path<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprPath) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - if let Some(ref it) = _i.qself { - _visitor.visit_qself(it) - }; - _visitor.visit_path(&_i.path); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_range<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprRange) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - if let Some(ref it) = _i.from { - _visitor.visit_expr(&**it) - }; - _visitor.visit_range_limits(&_i.limits); - if let Some(ref it) = _i.to { - _visitor.visit_expr(&**it) - }; -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_reference<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast ExprReference, -) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - tokens_helper(_visitor, &(_i.and_token).0); - if let Some(ref it) = _i.mutability { - tokens_helper(_visitor, &(it).0) - }; - _visitor.visit_expr(&*_i.expr); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_repeat<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprRepeat) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - tokens_helper(_visitor, &(_i.bracket_token).0); - _visitor.visit_expr(&*_i.expr); - tokens_helper(_visitor, &(_i.semi_token).0); - _visitor.visit_expr(&*_i.len); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_return<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprReturn) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - tokens_helper(_visitor, &(_i.return_token).0); - if let Some(ref it) = _i.expr { - _visitor.visit_expr(&**it) - }; -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_struct<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprStruct) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_path(&_i.path); - tokens_helper(_visitor, &(_i.brace_token).0); - for el in Punctuated::pairs(&_i.fields) { - let it = el.value(); - _visitor.visit_field_value(it) - } - if let Some(ref it) = _i.dot2_token { - tokens_helper(_visitor, &(it).0) - }; - if let Some(ref it) = _i.rest { - _visitor.visit_expr(&**it) - }; -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_try<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprTry) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_expr(&*_i.expr); - tokens_helper(_visitor, &(_i.question_token).0); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_tuple<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprTuple) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - tokens_helper(_visitor, &(_i.paren_token).0); - for el in Punctuated::pairs(&_i.elems) { - let it = el.value(); - _visitor.visit_expr(it) - } -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_type<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprType) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_expr(&*_i.expr); - tokens_helper(_visitor, &(_i.colon_token).0); - _visitor.visit_type(&*_i.ty); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_unary<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprUnary) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_un_op(&_i.op); - _visitor.visit_expr(&*_i.expr); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_unsafe<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprUnsafe) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - tokens_helper(_visitor, &(_i.unsafe_token).0); - _visitor.visit_block(&_i.block); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_verbatim<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast ExprVerbatim, -) { - skip!(_i.tts); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_while<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprWhile) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - if let Some(ref it) = _i.label { - _visitor.visit_label(it) - }; - tokens_helper(_visitor, &(_i.while_token).0); - _visitor.visit_expr(&*_i.cond); - _visitor.visit_block(&_i.body); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_while_let<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast ExprWhileLet, -) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - if let Some(ref it) = _i.label { - _visitor.visit_label(it) - }; - tokens_helper(_visitor, &(_i.while_token).0); - tokens_helper(_visitor, &(_i.let_token).0); - for el in Punctuated::pairs(&_i.pats) { - let it = el.value(); - _visitor.visit_pat(it) - } - tokens_helper(_visitor, &(_i.eq_token).0); - _visitor.visit_expr(&*_i.expr); - _visitor.visit_block(&_i.body); -} -#[cfg(feature = "full")] -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_expr_yield<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprYield) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - tokens_helper(_visitor, &(_i.yield_token).0); - if let Some(ref it) = _i.expr { - _visitor.visit_expr(&**it) - }; -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_field<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Field) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_visibility(&_i.vis); - if let Some(ref it) = _i.ident { - _visitor.visit_ident(it) - }; - if let Some(ref it) = _i.colon_token { - tokens_helper(_visitor, &(it).0) - }; - _visitor.visit_type(&_i.ty); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_field_pat<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast FieldPat) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_member(&_i.member); - if let Some(ref it) = _i.colon_token { - tokens_helper(_visitor, &(it).0) - }; - _visitor.visit_pat(&*_i.pat); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_field_value<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast FieldValue) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_member(&_i.member); - if let Some(ref it) = _i.colon_token { - tokens_helper(_visitor, &(it).0) - }; - _visitor.visit_expr(&_i.expr); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_fields<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Fields) { - match *_i { - Fields::Named(ref _binding_0) => { - _visitor.visit_fields_named(_binding_0); - } - Fields::Unnamed(ref _binding_0) => { - _visitor.visit_fields_unnamed(_binding_0); - } - Fields::Unit => {} - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_fields_named<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast FieldsNamed) { - tokens_helper(_visitor, &(_i.brace_token).0); - for el in Punctuated::pairs(&_i.named) { - let it = el.value(); - _visitor.visit_field(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_fields_unnamed<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast FieldsUnnamed, -) { - tokens_helper(_visitor, &(_i.paren_token).0); - for el in Punctuated::pairs(&_i.unnamed) { - let it = el.value(); - _visitor.visit_field(it) - } -} -#[cfg(feature = "full")] -pub fn visit_file<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast File) { - skip!(_i.shebang); - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - for it in &_i.items { - _visitor.visit_item(it) - } -} -#[cfg(feature = "full")] -pub fn visit_fn_arg<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast FnArg) { - match *_i { - FnArg::SelfRef(ref _binding_0) => { - _visitor.visit_arg_self_ref(_binding_0); - } - FnArg::SelfValue(ref _binding_0) => { - _visitor.visit_arg_self(_binding_0); - } - FnArg::Captured(ref _binding_0) => { - _visitor.visit_arg_captured(_binding_0); - } - FnArg::Inferred(ref _binding_0) => { - _visitor.visit_pat(_binding_0); - } - FnArg::Ignored(ref _binding_0) => { - _visitor.visit_type(_binding_0); - } - } -} -#[cfg(feature = "full")] -pub fn visit_fn_decl<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast FnDecl) { - tokens_helper(_visitor, &(_i.fn_token).0); - _visitor.visit_generics(&_i.generics); - tokens_helper(_visitor, &(_i.paren_token).0); - for el in Punctuated::pairs(&_i.inputs) { - let it = el.value(); - _visitor.visit_fn_arg(it) - } - if let Some(ref it) = _i.variadic { - tokens_helper(_visitor, &(it).0) - }; - _visitor.visit_return_type(&_i.output); -} -#[cfg(feature = "full")] -pub fn visit_foreign_item<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ForeignItem) { - match *_i { - ForeignItem::Fn(ref _binding_0) => { - _visitor.visit_foreign_item_fn(_binding_0); - } - ForeignItem::Static(ref _binding_0) => { - _visitor.visit_foreign_item_static(_binding_0); - } - ForeignItem::Type(ref _binding_0) => { - _visitor.visit_foreign_item_type(_binding_0); - } - ForeignItem::Verbatim(ref _binding_0) => { - _visitor.visit_foreign_item_verbatim(_binding_0); - } - } -} -#[cfg(feature = "full")] -pub fn visit_foreign_item_fn<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast ForeignItemFn, -) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_visibility(&_i.vis); - _visitor.visit_ident(&_i.ident); - _visitor.visit_fn_decl(&*_i.decl); - tokens_helper(_visitor, &(_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_foreign_item_static<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast ForeignItemStatic, -) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_visibility(&_i.vis); - tokens_helper(_visitor, &(_i.static_token).0); - if let Some(ref it) = _i.mutability { - tokens_helper(_visitor, &(it).0) - }; - _visitor.visit_ident(&_i.ident); - tokens_helper(_visitor, &(_i.colon_token).0); - _visitor.visit_type(&*_i.ty); - tokens_helper(_visitor, &(_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_foreign_item_type<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast ForeignItemType, -) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_visibility(&_i.vis); - tokens_helper(_visitor, &(_i.type_token).0); - _visitor.visit_ident(&_i.ident); - tokens_helper(_visitor, &(_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_foreign_item_verbatim<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast ForeignItemVerbatim, -) { - skip!(_i.tts); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_generic_argument<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast GenericArgument, -) { - match *_i { - GenericArgument::Lifetime(ref _binding_0) => { - _visitor.visit_lifetime(_binding_0); - } - GenericArgument::Type(ref _binding_0) => { - _visitor.visit_type(_binding_0); - } - GenericArgument::Binding(ref _binding_0) => { - _visitor.visit_binding(_binding_0); - } - GenericArgument::Const(ref _binding_0) => { - _visitor.visit_expr(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_generic_method_argument<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast GenericMethodArgument, -) { - match *_i { - GenericMethodArgument::Type(ref _binding_0) => { - _visitor.visit_type(_binding_0); - } - GenericMethodArgument::Const(ref _binding_0) => { - _visitor.visit_expr(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_generic_param<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast GenericParam, -) { - match *_i { - GenericParam::Type(ref _binding_0) => { - _visitor.visit_type_param(_binding_0); - } - GenericParam::Lifetime(ref _binding_0) => { - _visitor.visit_lifetime_def(_binding_0); - } - GenericParam::Const(ref _binding_0) => { - _visitor.visit_const_param(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_generics<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Generics) { - if let Some(ref it) = _i.lt_token { - tokens_helper(_visitor, &(it).0) - }; - for el in Punctuated::pairs(&_i.params) { - let it = el.value(); - _visitor.visit_generic_param(it) - } - if let Some(ref it) = _i.gt_token { - tokens_helper(_visitor, &(it).0) - }; - if let Some(ref it) = _i.where_clause { - _visitor.visit_where_clause(it) - }; -} -pub fn visit_ident<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Ident) {} -#[cfg(feature = "full")] -pub fn visit_impl_item<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ImplItem) { - match *_i { - ImplItem::Const(ref _binding_0) => { - _visitor.visit_impl_item_const(_binding_0); - } - ImplItem::Method(ref _binding_0) => { - _visitor.visit_impl_item_method(_binding_0); - } - ImplItem::Type(ref _binding_0) => { - _visitor.visit_impl_item_type(_binding_0); - } - ImplItem::Macro(ref _binding_0) => { - _visitor.visit_impl_item_macro(_binding_0); - } - ImplItem::Verbatim(ref _binding_0) => { - _visitor.visit_impl_item_verbatim(_binding_0); - } - } -} -#[cfg(feature = "full")] -pub fn visit_impl_item_const<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast ImplItemConst, -) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_visibility(&_i.vis); - if let Some(ref it) = _i.defaultness { - tokens_helper(_visitor, &(it).0) - }; - tokens_helper(_visitor, &(_i.const_token).0); - _visitor.visit_ident(&_i.ident); - tokens_helper(_visitor, &(_i.colon_token).0); - _visitor.visit_type(&_i.ty); - tokens_helper(_visitor, &(_i.eq_token).0); - _visitor.visit_expr(&_i.expr); - tokens_helper(_visitor, &(_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_impl_item_macro<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast ImplItemMacro, -) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_macro(&_i.mac); - if let Some(ref it) = _i.semi_token { - tokens_helper(_visitor, &(it).0) - }; -} -#[cfg(feature = "full")] -pub fn visit_impl_item_method<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast ImplItemMethod, -) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_visibility(&_i.vis); - if let Some(ref it) = _i.defaultness { - tokens_helper(_visitor, &(it).0) - }; - _visitor.visit_method_sig(&_i.sig); - _visitor.visit_block(&_i.block); -} -#[cfg(feature = "full")] -pub fn visit_impl_item_type<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast ImplItemType, -) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_visibility(&_i.vis); - if let Some(ref it) = _i.defaultness { - tokens_helper(_visitor, &(it).0) - }; - tokens_helper(_visitor, &(_i.type_token).0); - _visitor.visit_ident(&_i.ident); - _visitor.visit_generics(&_i.generics); - tokens_helper(_visitor, &(_i.eq_token).0); - _visitor.visit_type(&_i.ty); - tokens_helper(_visitor, &(_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_impl_item_verbatim<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast ImplItemVerbatim, -) { - skip!(_i.tts); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_index<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Index) { - skip!(_i.index); - _visitor.visit_span(&_i.span); -} -#[cfg(feature = "full")] -pub fn visit_item<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Item) { - match *_i { - Item::ExternCrate(ref _binding_0) => { - _visitor.visit_item_extern_crate(_binding_0); - } - Item::Use(ref _binding_0) => { - _visitor.visit_item_use(_binding_0); - } - Item::Static(ref _binding_0) => { - _visitor.visit_item_static(_binding_0); - } - Item::Const(ref _binding_0) => { - _visitor.visit_item_const(_binding_0); - } - Item::Fn(ref _binding_0) => { - _visitor.visit_item_fn(_binding_0); - } - Item::Mod(ref _binding_0) => { - _visitor.visit_item_mod(_binding_0); - } - Item::ForeignMod(ref _binding_0) => { - _visitor.visit_item_foreign_mod(_binding_0); - } - Item::Type(ref _binding_0) => { - _visitor.visit_item_type(_binding_0); - } - Item::Struct(ref _binding_0) => { - _visitor.visit_item_struct(_binding_0); - } - Item::Enum(ref _binding_0) => { - _visitor.visit_item_enum(_binding_0); - } - Item::Union(ref _binding_0) => { - _visitor.visit_item_union(_binding_0); - } - Item::Trait(ref _binding_0) => { - _visitor.visit_item_trait(_binding_0); - } - Item::Impl(ref _binding_0) => { - _visitor.visit_item_impl(_binding_0); - } - Item::Macro(ref _binding_0) => { - _visitor.visit_item_macro(_binding_0); - } - Item::Macro2(ref _binding_0) => { - _visitor.visit_item_macro2(_binding_0); - } - Item::Verbatim(ref _binding_0) => { - _visitor.visit_item_verbatim(_binding_0); - } - } -} -#[cfg(feature = "full")] -pub fn visit_item_const<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemConst) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_visibility(&_i.vis); - tokens_helper(_visitor, &(_i.const_token).0); - _visitor.visit_ident(&_i.ident); - tokens_helper(_visitor, &(_i.colon_token).0); - _visitor.visit_type(&*_i.ty); - tokens_helper(_visitor, &(_i.eq_token).0); - _visitor.visit_expr(&*_i.expr); - tokens_helper(_visitor, &(_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_item_enum<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemEnum) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_visibility(&_i.vis); - tokens_helper(_visitor, &(_i.enum_token).0); - _visitor.visit_ident(&_i.ident); - _visitor.visit_generics(&_i.generics); - tokens_helper(_visitor, &(_i.brace_token).0); - for el in Punctuated::pairs(&_i.variants) { - let it = el.value(); - _visitor.visit_variant(it) - } -} -#[cfg(feature = "full")] -pub fn visit_item_extern_crate<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast ItemExternCrate, -) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_visibility(&_i.vis); - tokens_helper(_visitor, &(_i.extern_token).0); - tokens_helper(_visitor, &(_i.crate_token).0); - _visitor.visit_ident(&_i.ident); - if let Some(ref it) = _i.rename { - tokens_helper(_visitor, &((it).0).0); - _visitor.visit_ident(&(it).1); - }; - tokens_helper(_visitor, &(_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_item_fn<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemFn) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_visibility(&_i.vis); - if let Some(ref it) = _i.constness { - tokens_helper(_visitor, &(it).0) - }; - if let Some(ref it) = _i.unsafety { - tokens_helper(_visitor, &(it).0) - }; - if let Some(ref it) = _i.abi { - _visitor.visit_abi(it) - }; - _visitor.visit_ident(&_i.ident); - _visitor.visit_fn_decl(&*_i.decl); - _visitor.visit_block(&*_i.block); -} -#[cfg(feature = "full")] -pub fn visit_item_foreign_mod<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast ItemForeignMod, -) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_abi(&_i.abi); - tokens_helper(_visitor, &(_i.brace_token).0); - for it in &_i.items { - _visitor.visit_foreign_item(it) - } -} -#[cfg(feature = "full")] -pub fn visit_item_impl<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemImpl) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - if let Some(ref it) = _i.defaultness { - tokens_helper(_visitor, &(it).0) - }; - if let Some(ref it) = _i.unsafety { - tokens_helper(_visitor, &(it).0) - }; - tokens_helper(_visitor, &(_i.impl_token).0); - _visitor.visit_generics(&_i.generics); - if let Some(ref it) = _i.trait_ { - if let Some(ref it) = (it).0 { - tokens_helper(_visitor, &(it).0) - }; - _visitor.visit_path(&(it).1); - tokens_helper(_visitor, &((it).2).0); - }; - _visitor.visit_type(&*_i.self_ty); - tokens_helper(_visitor, &(_i.brace_token).0); - for it in &_i.items { - _visitor.visit_impl_item(it) - } -} -#[cfg(feature = "full")] -pub fn visit_item_macro<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemMacro) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - if let Some(ref it) = _i.ident { - _visitor.visit_ident(it) - }; - _visitor.visit_macro(&_i.mac); - if let Some(ref it) = _i.semi_token { - tokens_helper(_visitor, &(it).0) - }; -} -#[cfg(feature = "full")] -pub fn visit_item_macro2<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemMacro2) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_visibility(&_i.vis); - tokens_helper(_visitor, &(_i.macro_token).0); - _visitor.visit_ident(&_i.ident); - tokens_helper(_visitor, &(_i.paren_token).0); - skip!(_i.args); - tokens_helper(_visitor, &(_i.brace_token).0); - skip!(_i.body); -} -#[cfg(feature = "full")] -pub fn visit_item_mod<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemMod) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_visibility(&_i.vis); - tokens_helper(_visitor, &(_i.mod_token).0); - _visitor.visit_ident(&_i.ident); - if let Some(ref it) = _i.content { - tokens_helper(_visitor, &((it).0).0); - for it in &(it).1 { - _visitor.visit_item(it) - } - }; - if let Some(ref it) = _i.semi { - tokens_helper(_visitor, &(it).0) - }; -} -#[cfg(feature = "full")] -pub fn visit_item_static<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemStatic) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_visibility(&_i.vis); - tokens_helper(_visitor, &(_i.static_token).0); - if let Some(ref it) = _i.mutability { - tokens_helper(_visitor, &(it).0) - }; - _visitor.visit_ident(&_i.ident); - tokens_helper(_visitor, &(_i.colon_token).0); - _visitor.visit_type(&*_i.ty); - tokens_helper(_visitor, &(_i.eq_token).0); - _visitor.visit_expr(&*_i.expr); - tokens_helper(_visitor, &(_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_item_struct<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemStruct) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_visibility(&_i.vis); - tokens_helper(_visitor, &(_i.struct_token).0); - _visitor.visit_ident(&_i.ident); - _visitor.visit_generics(&_i.generics); - _visitor.visit_fields(&_i.fields); - if let Some(ref it) = _i.semi_token { - tokens_helper(_visitor, &(it).0) - }; -} -#[cfg(feature = "full")] -pub fn visit_item_trait<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemTrait) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_visibility(&_i.vis); - if let Some(ref it) = _i.unsafety { - tokens_helper(_visitor, &(it).0) - }; - if let Some(ref it) = _i.auto_token { - tokens_helper(_visitor, &(it).0) - }; - tokens_helper(_visitor, &(_i.trait_token).0); - _visitor.visit_ident(&_i.ident); - _visitor.visit_generics(&_i.generics); - if let Some(ref it) = _i.colon_token { - tokens_helper(_visitor, &(it).0) - }; - for el in Punctuated::pairs(&_i.supertraits) { - let it = el.value(); - _visitor.visit_type_param_bound(it) - } - tokens_helper(_visitor, &(_i.brace_token).0); - for it in &_i.items { - _visitor.visit_trait_item(it) - } -} -#[cfg(feature = "full")] -pub fn visit_item_type<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemType) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_visibility(&_i.vis); - tokens_helper(_visitor, &(_i.type_token).0); - _visitor.visit_ident(&_i.ident); - _visitor.visit_generics(&_i.generics); - tokens_helper(_visitor, &(_i.eq_token).0); - _visitor.visit_type(&*_i.ty); - tokens_helper(_visitor, &(_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_item_union<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemUnion) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_visibility(&_i.vis); - tokens_helper(_visitor, &(_i.union_token).0); - _visitor.visit_ident(&_i.ident); - _visitor.visit_generics(&_i.generics); - _visitor.visit_fields_named(&_i.fields); -} -#[cfg(feature = "full")] -pub fn visit_item_use<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemUse) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_visibility(&_i.vis); - tokens_helper(_visitor, &(_i.use_token).0); - if let Some(ref it) = _i.leading_colon { - tokens_helper(_visitor, &(it).0) - }; - _visitor.visit_use_tree(&_i.tree); - tokens_helper(_visitor, &(_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_item_verbatim<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast ItemVerbatim, -) { - skip!(_i.tts); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_label<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Label) { - _visitor.visit_lifetime(&_i.name); - tokens_helper(_visitor, &(_i.colon_token).0); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_lifetime<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Lifetime) { - skip!(_i.apostrophe); - _visitor.visit_ident(&_i.ident); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_lifetime_def<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast LifetimeDef) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_lifetime(&_i.lifetime); - if let Some(ref it) = _i.colon_token { - tokens_helper(_visitor, &(it).0) - }; - for el in Punctuated::pairs(&_i.bounds) { - let it = el.value(); - _visitor.visit_lifetime(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_lit<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Lit) { - match *_i { - Lit::Str(ref _binding_0) => { - _visitor.visit_lit_str(_binding_0); - } - Lit::ByteStr(ref _binding_0) => { - _visitor.visit_lit_byte_str(_binding_0); - } - Lit::Byte(ref _binding_0) => { - _visitor.visit_lit_byte(_binding_0); - } - Lit::Char(ref _binding_0) => { - _visitor.visit_lit_char(_binding_0); - } - Lit::Int(ref _binding_0) => { - _visitor.visit_lit_int(_binding_0); - } - Lit::Float(ref _binding_0) => { - _visitor.visit_lit_float(_binding_0); - } - Lit::Bool(ref _binding_0) => { - _visitor.visit_lit_bool(_binding_0); - } - Lit::Verbatim(ref _binding_0) => { - _visitor.visit_lit_verbatim(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_lit_bool<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast LitBool) { - skip!(_i.value); - _visitor.visit_span(&_i.span); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_lit_byte<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast LitByte) { - skip!(_i.token); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_lit_byte_str<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast LitByteStr) { - skip!(_i.token); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_lit_char<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast LitChar) { - skip!(_i.token); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_lit_float<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast LitFloat) { - skip!(_i.token); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_lit_int<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast LitInt) { - skip!(_i.token); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_lit_str<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast LitStr) { - skip!(_i.token); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_lit_verbatim<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast LitVerbatim) { - skip!(_i.token); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_local<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Local) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - tokens_helper(_visitor, &(_i.let_token).0); - for el in Punctuated::pairs(&_i.pats) { - let it = el.value(); - _visitor.visit_pat(it) - } - if let Some(ref it) = _i.ty { - tokens_helper(_visitor, &((it).0).0); - _visitor.visit_type(&*(it).1); - }; - if let Some(ref it) = _i.init { - tokens_helper(_visitor, &((it).0).0); - _visitor.visit_expr(&*(it).1); - }; - tokens_helper(_visitor, &(_i.semi_token).0); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_macro<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Macro) { - _visitor.visit_path(&_i.path); - tokens_helper(_visitor, &(_i.bang_token).0); - _visitor.visit_macro_delimiter(&_i.delimiter); - skip!(_i.tts); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_macro_delimiter<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast MacroDelimiter, -) { - match *_i { - MacroDelimiter::Paren(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - MacroDelimiter::Brace(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - MacroDelimiter::Bracket(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_member<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Member) { - match *_i { - Member::Named(ref _binding_0) => { - _visitor.visit_ident(_binding_0); - } - Member::Unnamed(ref _binding_0) => { - _visitor.visit_index(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_meta<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Meta) { - match *_i { - Meta::Word(ref _binding_0) => { - _visitor.visit_ident(_binding_0); - } - Meta::List(ref _binding_0) => { - _visitor.visit_meta_list(_binding_0); - } - Meta::NameValue(ref _binding_0) => { - _visitor.visit_meta_name_value(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_meta_list<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast MetaList) { - _visitor.visit_ident(&_i.ident); - tokens_helper(_visitor, &(_i.paren_token).0); - for el in Punctuated::pairs(&_i.nested) { - let it = el.value(); - _visitor.visit_nested_meta(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_meta_name_value<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast MetaNameValue, -) { - _visitor.visit_ident(&_i.ident); - tokens_helper(_visitor, &(_i.eq_token).0); - _visitor.visit_lit(&_i.lit); -} -#[cfg(feature = "full")] -pub fn visit_method_sig<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast MethodSig) { - if let Some(ref it) = _i.constness { - tokens_helper(_visitor, &(it).0) - }; - if let Some(ref it) = _i.unsafety { - tokens_helper(_visitor, &(it).0) - }; - if let Some(ref it) = _i.abi { - _visitor.visit_abi(it) - }; - _visitor.visit_ident(&_i.ident); - _visitor.visit_fn_decl(&_i.decl); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_method_turbofish<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast MethodTurbofish, -) { - tokens_helper(_visitor, &(_i.colon2_token).0); - tokens_helper(_visitor, &(_i.lt_token).0); - for el in Punctuated::pairs(&_i.args) { - let it = el.value(); - _visitor.visit_generic_method_argument(it) - } - tokens_helper(_visitor, &(_i.gt_token).0); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_nested_meta<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast NestedMeta) { - match *_i { - NestedMeta::Meta(ref _binding_0) => { - _visitor.visit_meta(_binding_0); - } - NestedMeta::Literal(ref _binding_0) => { - _visitor.visit_lit(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_parenthesized_generic_arguments<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast ParenthesizedGenericArguments, -) { - tokens_helper(_visitor, &(_i.paren_token).0); - for el in Punctuated::pairs(&_i.inputs) { - let it = el.value(); - _visitor.visit_type(it) - } - _visitor.visit_return_type(&_i.output); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Pat) { - match *_i { - Pat::Wild(ref _binding_0) => { - _visitor.visit_pat_wild(_binding_0); - } - Pat::Ident(ref _binding_0) => { - _visitor.visit_pat_ident(_binding_0); - } - Pat::Struct(ref _binding_0) => { - _visitor.visit_pat_struct(_binding_0); - } - Pat::TupleStruct(ref _binding_0) => { - _visitor.visit_pat_tuple_struct(_binding_0); - } - Pat::Path(ref _binding_0) => { - _visitor.visit_pat_path(_binding_0); - } - Pat::Tuple(ref _binding_0) => { - _visitor.visit_pat_tuple(_binding_0); - } - Pat::Box(ref _binding_0) => { - _visitor.visit_pat_box(_binding_0); - } - Pat::Ref(ref _binding_0) => { - _visitor.visit_pat_ref(_binding_0); - } - Pat::Lit(ref _binding_0) => { - _visitor.visit_pat_lit(_binding_0); - } - Pat::Range(ref _binding_0) => { - _visitor.visit_pat_range(_binding_0); - } - Pat::Slice(ref _binding_0) => { - _visitor.visit_pat_slice(_binding_0); - } - Pat::Macro(ref _binding_0) => { - _visitor.visit_pat_macro(_binding_0); - } - Pat::Verbatim(ref _binding_0) => { - _visitor.visit_pat_verbatim(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_box<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatBox) { - tokens_helper(_visitor, &(_i.box_token).0); - _visitor.visit_pat(&*_i.pat); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_ident<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatIdent) { - if let Some(ref it) = _i.by_ref { - tokens_helper(_visitor, &(it).0) - }; - if let Some(ref it) = _i.mutability { - tokens_helper(_visitor, &(it).0) - }; - _visitor.visit_ident(&_i.ident); - if let Some(ref it) = _i.subpat { - tokens_helper(_visitor, &((it).0).0); - _visitor.visit_pat(&*(it).1); - }; -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_lit<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatLit) { - _visitor.visit_expr(&*_i.expr); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_macro<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatMacro) { - _visitor.visit_macro(&_i.mac); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_path<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatPath) { - if let Some(ref it) = _i.qself { - _visitor.visit_qself(it) - }; - _visitor.visit_path(&_i.path); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_range<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatRange) { - _visitor.visit_expr(&*_i.lo); - _visitor.visit_range_limits(&_i.limits); - _visitor.visit_expr(&*_i.hi); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_ref<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatRef) { - tokens_helper(_visitor, &(_i.and_token).0); - if let Some(ref it) = _i.mutability { - tokens_helper(_visitor, &(it).0) - }; - _visitor.visit_pat(&*_i.pat); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_slice<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatSlice) { - tokens_helper(_visitor, &(_i.bracket_token).0); - for el in Punctuated::pairs(&_i.front) { - let it = el.value(); - _visitor.visit_pat(it) - } - if let Some(ref it) = _i.middle { - _visitor.visit_pat(&**it) - }; - if let Some(ref it) = _i.dot2_token { - tokens_helper(_visitor, &(it).0) - }; - if let Some(ref it) = _i.comma_token { - tokens_helper(_visitor, &(it).0) - }; - for el in Punctuated::pairs(&_i.back) { - let it = el.value(); - _visitor.visit_pat(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_struct<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatStruct) { - _visitor.visit_path(&_i.path); - tokens_helper(_visitor, &(_i.brace_token).0); - for el in Punctuated::pairs(&_i.fields) { - let it = el.value(); - _visitor.visit_field_pat(it) - } - if let Some(ref it) = _i.dot2_token { - tokens_helper(_visitor, &(it).0) - }; -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_tuple<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatTuple) { - tokens_helper(_visitor, &(_i.paren_token).0); - for el in Punctuated::pairs(&_i.front) { - let it = el.value(); - _visitor.visit_pat(it) - } - if let Some(ref it) = _i.dot2_token { - tokens_helper(_visitor, &(it).0) - }; - if let Some(ref it) = _i.comma_token { - tokens_helper(_visitor, &(it).0) - }; - for el in Punctuated::pairs(&_i.back) { - let it = el.value(); - _visitor.visit_pat(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_tuple_struct<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast PatTupleStruct, -) { - _visitor.visit_path(&_i.path); - _visitor.visit_pat_tuple(&_i.pat); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_verbatim<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatVerbatim) { - skip!(_i.tts); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_pat_wild<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatWild) { - tokens_helper(_visitor, &(_i.underscore_token).0); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_path<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Path) { - if let Some(ref it) = _i.leading_colon { - tokens_helper(_visitor, &(it).0) - }; - for el in Punctuated::pairs(&_i.segments) { - let it = el.value(); - _visitor.visit_path_segment(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_path_arguments<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast PathArguments, -) { - match *_i { - PathArguments::None => {} - PathArguments::AngleBracketed(ref _binding_0) => { - _visitor.visit_angle_bracketed_generic_arguments(_binding_0); - } - PathArguments::Parenthesized(ref _binding_0) => { - _visitor.visit_parenthesized_generic_arguments(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_path_segment<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PathSegment) { - _visitor.visit_ident(&_i.ident); - _visitor.visit_path_arguments(&_i.arguments); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_predicate_eq<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PredicateEq) { - _visitor.visit_type(&_i.lhs_ty); - tokens_helper(_visitor, &(_i.eq_token).0); - _visitor.visit_type(&_i.rhs_ty); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_predicate_lifetime<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast PredicateLifetime, -) { - _visitor.visit_lifetime(&_i.lifetime); - if let Some(ref it) = _i.colon_token { - tokens_helper(_visitor, &(it).0) - }; - for el in Punctuated::pairs(&_i.bounds) { - let it = el.value(); - _visitor.visit_lifetime(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_predicate_type<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast PredicateType, -) { - if let Some(ref it) = _i.lifetimes { - _visitor.visit_bound_lifetimes(it) - }; - _visitor.visit_type(&_i.bounded_ty); - tokens_helper(_visitor, &(_i.colon_token).0); - for el in Punctuated::pairs(&_i.bounds) { - let it = el.value(); - _visitor.visit_type_param_bound(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_qself<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast QSelf) { - tokens_helper(_visitor, &(_i.lt_token).0); - _visitor.visit_type(&*_i.ty); - skip!(_i.position); - if let Some(ref it) = _i.as_token { - tokens_helper(_visitor, &(it).0) - }; - tokens_helper(_visitor, &(_i.gt_token).0); -} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_range_limits<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast RangeLimits) { - match *_i { - RangeLimits::HalfOpen(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - RangeLimits::Closed(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_return_type<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ReturnType) { - match *_i { - ReturnType::Default => {} - ReturnType::Type(ref _binding_0, ref _binding_1) => { - tokens_helper(_visitor, &(_binding_0).0); - _visitor.visit_type(&**_binding_1); - } - } -} -pub fn visit_span<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Span) {} -#[cfg(any(feature = "full", feature = "derive"))] -#[cfg(feature = "full")] -pub fn visit_stmt<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Stmt) { - match *_i { - Stmt::Local(ref _binding_0) => { - _visitor.visit_local(_binding_0); - } - Stmt::Item(ref _binding_0) => { - _visitor.visit_item(_binding_0); - } - Stmt::Expr(ref _binding_0) => { - _visitor.visit_expr(_binding_0); - } - Stmt::Semi(ref _binding_0, ref _binding_1) => { - _visitor.visit_expr(_binding_0); - tokens_helper(_visitor, &(_binding_1).0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_trait_bound<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TraitBound) { - if let Some(ref it) = _i.paren_token { - tokens_helper(_visitor, &(it).0) - }; - _visitor.visit_trait_bound_modifier(&_i.modifier); - if let Some(ref it) = _i.lifetimes { - _visitor.visit_bound_lifetimes(it) - }; - _visitor.visit_path(&_i.path); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_trait_bound_modifier<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast TraitBoundModifier, -) { - match *_i { - TraitBoundModifier::None => {} - TraitBoundModifier::Maybe(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - } -} -#[cfg(feature = "full")] -pub fn visit_trait_item<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TraitItem) { - match *_i { - TraitItem::Const(ref _binding_0) => { - _visitor.visit_trait_item_const(_binding_0); - } - TraitItem::Method(ref _binding_0) => { - _visitor.visit_trait_item_method(_binding_0); - } - TraitItem::Type(ref _binding_0) => { - _visitor.visit_trait_item_type(_binding_0); - } - TraitItem::Macro(ref _binding_0) => { - _visitor.visit_trait_item_macro(_binding_0); - } - TraitItem::Verbatim(ref _binding_0) => { - _visitor.visit_trait_item_verbatim(_binding_0); - } - } -} -#[cfg(feature = "full")] -pub fn visit_trait_item_const<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast TraitItemConst, -) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - tokens_helper(_visitor, &(_i.const_token).0); - _visitor.visit_ident(&_i.ident); - tokens_helper(_visitor, &(_i.colon_token).0); - _visitor.visit_type(&_i.ty); - if let Some(ref it) = _i.default { - tokens_helper(_visitor, &((it).0).0); - _visitor.visit_expr(&(it).1); - }; - tokens_helper(_visitor, &(_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_trait_item_macro<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast TraitItemMacro, -) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_macro(&_i.mac); - if let Some(ref it) = _i.semi_token { - tokens_helper(_visitor, &(it).0) - }; -} -#[cfg(feature = "full")] -pub fn visit_trait_item_method<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast TraitItemMethod, -) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_method_sig(&_i.sig); - if let Some(ref it) = _i.default { - _visitor.visit_block(it) - }; - if let Some(ref it) = _i.semi_token { - tokens_helper(_visitor, &(it).0) - }; -} -#[cfg(feature = "full")] -pub fn visit_trait_item_type<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast TraitItemType, -) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - tokens_helper(_visitor, &(_i.type_token).0); - _visitor.visit_ident(&_i.ident); - _visitor.visit_generics(&_i.generics); - if let Some(ref it) = _i.colon_token { - tokens_helper(_visitor, &(it).0) - }; - for el in Punctuated::pairs(&_i.bounds) { - let it = el.value(); - _visitor.visit_type_param_bound(it) - } - if let Some(ref it) = _i.default { - tokens_helper(_visitor, &((it).0).0); - _visitor.visit_type(&(it).1); - }; - tokens_helper(_visitor, &(_i.semi_token).0); -} -#[cfg(feature = "full")] -pub fn visit_trait_item_verbatim<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast TraitItemVerbatim, -) { - skip!(_i.tts); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Type) { - match *_i { - Type::Slice(ref _binding_0) => { - _visitor.visit_type_slice(_binding_0); - } - Type::Array(ref _binding_0) => { - _visitor.visit_type_array(_binding_0); - } - Type::Ptr(ref _binding_0) => { - _visitor.visit_type_ptr(_binding_0); - } - Type::Reference(ref _binding_0) => { - _visitor.visit_type_reference(_binding_0); - } - Type::BareFn(ref _binding_0) => { - _visitor.visit_type_bare_fn(_binding_0); - } - Type::Never(ref _binding_0) => { - _visitor.visit_type_never(_binding_0); - } - Type::Tuple(ref _binding_0) => { - _visitor.visit_type_tuple(_binding_0); - } - Type::Path(ref _binding_0) => { - _visitor.visit_type_path(_binding_0); - } - Type::TraitObject(ref _binding_0) => { - _visitor.visit_type_trait_object(_binding_0); - } - Type::ImplTrait(ref _binding_0) => { - _visitor.visit_type_impl_trait(_binding_0); - } - Type::Paren(ref _binding_0) => { - _visitor.visit_type_paren(_binding_0); - } - Type::Group(ref _binding_0) => { - _visitor.visit_type_group(_binding_0); - } - Type::Infer(ref _binding_0) => { - _visitor.visit_type_infer(_binding_0); - } - Type::Macro(ref _binding_0) => { - _visitor.visit_type_macro(_binding_0); - } - Type::Verbatim(ref _binding_0) => { - _visitor.visit_type_verbatim(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_array<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypeArray) { - tokens_helper(_visitor, &(_i.bracket_token).0); - _visitor.visit_type(&*_i.elem); - tokens_helper(_visitor, &(_i.semi_token).0); - _visitor.visit_expr(&_i.len); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_bare_fn<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypeBareFn) { - if let Some(ref it) = _i.unsafety { - tokens_helper(_visitor, &(it).0) - }; - if let Some(ref it) = _i.abi { - _visitor.visit_abi(it) - }; - tokens_helper(_visitor, &(_i.fn_token).0); - if let Some(ref it) = _i.lifetimes { - _visitor.visit_bound_lifetimes(it) - }; - tokens_helper(_visitor, &(_i.paren_token).0); - for el in Punctuated::pairs(&_i.inputs) { - let it = el.value(); - _visitor.visit_bare_fn_arg(it) - } - if let Some(ref it) = _i.variadic { - tokens_helper(_visitor, &(it).0) - }; - _visitor.visit_return_type(&_i.output); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_group<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypeGroup) { - tokens_helper(_visitor, &(_i.group_token).0); - _visitor.visit_type(&*_i.elem); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_impl_trait<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast TypeImplTrait, -) { - tokens_helper(_visitor, &(_i.impl_token).0); - for el in Punctuated::pairs(&_i.bounds) { - let it = el.value(); - _visitor.visit_type_param_bound(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_infer<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypeInfer) { - tokens_helper(_visitor, &(_i.underscore_token).0); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_macro<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypeMacro) { - _visitor.visit_macro(&_i.mac); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_never<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypeNever) { - tokens_helper(_visitor, &(_i.bang_token).0); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_param<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypeParam) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_ident(&_i.ident); - if let Some(ref it) = _i.colon_token { - tokens_helper(_visitor, &(it).0) - }; - for el in Punctuated::pairs(&_i.bounds) { - let it = el.value(); - _visitor.visit_type_param_bound(it) - } - if let Some(ref it) = _i.eq_token { - tokens_helper(_visitor, &(it).0) - }; - if let Some(ref it) = _i.default { - _visitor.visit_type(it) - }; -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_param_bound<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast TypeParamBound, -) { - match *_i { - TypeParamBound::Trait(ref _binding_0) => { - _visitor.visit_trait_bound(_binding_0); - } - TypeParamBound::Lifetime(ref _binding_0) => { - _visitor.visit_lifetime(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_paren<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypeParen) { - tokens_helper(_visitor, &(_i.paren_token).0); - _visitor.visit_type(&*_i.elem); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_path<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypePath) { - if let Some(ref it) = _i.qself { - _visitor.visit_qself(it) - }; - _visitor.visit_path(&_i.path); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_ptr<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypePtr) { - tokens_helper(_visitor, &(_i.star_token).0); - if let Some(ref it) = _i.const_token { - tokens_helper(_visitor, &(it).0) - }; - if let Some(ref it) = _i.mutability { - tokens_helper(_visitor, &(it).0) - }; - _visitor.visit_type(&*_i.elem); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_reference<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast TypeReference, -) { - tokens_helper(_visitor, &(_i.and_token).0); - if let Some(ref it) = _i.lifetime { - _visitor.visit_lifetime(it) - }; - if let Some(ref it) = _i.mutability { - tokens_helper(_visitor, &(it).0) - }; - _visitor.visit_type(&*_i.elem); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_slice<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypeSlice) { - tokens_helper(_visitor, &(_i.bracket_token).0); - _visitor.visit_type(&*_i.elem); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_trait_object<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast TypeTraitObject, -) { - if let Some(ref it) = _i.dyn_token { - tokens_helper(_visitor, &(it).0) - }; - for el in Punctuated::pairs(&_i.bounds) { - let it = el.value(); - _visitor.visit_type_param_bound(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_tuple<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypeTuple) { - tokens_helper(_visitor, &(_i.paren_token).0); - for el in Punctuated::pairs(&_i.elems) { - let it = el.value(); - _visitor.visit_type(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_type_verbatim<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast TypeVerbatim, -) { - skip!(_i.tts); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_un_op<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast UnOp) { - match *_i { - UnOp::Deref(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - UnOp::Not(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - UnOp::Neg(ref _binding_0) => { - tokens_helper(_visitor, &(_binding_0).0); - } - } -} -#[cfg(feature = "full")] -pub fn visit_use_glob<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast UseGlob) { - tokens_helper(_visitor, &(_i.star_token).0); -} -#[cfg(feature = "full")] -pub fn visit_use_group<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast UseGroup) { - tokens_helper(_visitor, &(_i.brace_token).0); - for el in Punctuated::pairs(&_i.items) { - let it = el.value(); - _visitor.visit_use_tree(it) - } -} -#[cfg(feature = "full")] -pub fn visit_use_name<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast UseName) { - _visitor.visit_ident(&_i.ident); -} -#[cfg(feature = "full")] -pub fn visit_use_path<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast UsePath) { - _visitor.visit_ident(&_i.ident); - tokens_helper(_visitor, &(_i.colon2_token).0); - _visitor.visit_use_tree(&*_i.tree); -} -#[cfg(feature = "full")] -pub fn visit_use_rename<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast UseRename) { - _visitor.visit_ident(&_i.ident); - tokens_helper(_visitor, &(_i.as_token).0); - _visitor.visit_ident(&_i.rename); -} -#[cfg(feature = "full")] -pub fn visit_use_tree<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast UseTree) { - match *_i { - UseTree::Path(ref _binding_0) => { - _visitor.visit_use_path(_binding_0); - } - UseTree::Name(ref _binding_0) => { - _visitor.visit_use_name(_binding_0); - } - UseTree::Rename(ref _binding_0) => { - _visitor.visit_use_rename(_binding_0); - } - UseTree::Glob(ref _binding_0) => { - _visitor.visit_use_glob(_binding_0); - } - UseTree::Group(ref _binding_0) => { - _visitor.visit_use_group(_binding_0); - } - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_variant<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Variant) { - for it in &_i.attrs { - _visitor.visit_attribute(it) - } - _visitor.visit_ident(&_i.ident); - _visitor.visit_fields(&_i.fields); - if let Some(ref it) = _i.discriminant { - tokens_helper(_visitor, &((it).0).0); - _visitor.visit_expr(&(it).1); - }; -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_vis_crate<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast VisCrate) { - tokens_helper(_visitor, &(_i.crate_token).0); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_vis_public<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast VisPublic) { - tokens_helper(_visitor, &(_i.pub_token).0); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_vis_restricted<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast VisRestricted, -) { - tokens_helper(_visitor, &(_i.pub_token).0); - tokens_helper(_visitor, &(_i.paren_token).0); - if let Some(ref it) = _i.in_token { - tokens_helper(_visitor, &(it).0) - }; - _visitor.visit_path(&*_i.path); -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_visibility<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Visibility) { - match *_i { - Visibility::Public(ref _binding_0) => { - _visitor.visit_vis_public(_binding_0); - } - Visibility::Crate(ref _binding_0) => { - _visitor.visit_vis_crate(_binding_0); - } - Visibility::Restricted(ref _binding_0) => { - _visitor.visit_vis_restricted(_binding_0); - } - Visibility::Inherited => {} - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_where_clause<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast WhereClause) { - tokens_helper(_visitor, &(_i.where_token).0); - for el in Punctuated::pairs(&_i.predicates) { - let it = el.value(); - _visitor.visit_where_predicate(it) - } -} -#[cfg(any(feature = "full", feature = "derive"))] -pub fn visit_where_predicate<'ast, V: Visit<'ast> + ?Sized>( - _visitor: &mut V, - _i: &'ast WherePredicate, -) { - match *_i { - WherePredicate::Type(ref _binding_0) => { - _visitor.visit_predicate_type(_binding_0); - } - WherePredicate::Lifetime(ref _binding_0) => { - _visitor.visit_predicate_lifetime(_binding_0); - } - WherePredicate::Eq(ref _binding_0) => { - _visitor.visit_predicate_eq(_binding_0); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/generics.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/generics.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/generics.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/generics.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,1015 +0,0 @@ -// Copyright 2018 Syn Developers -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use super::*; -use punctuated::{Iter, IterMut, Punctuated}; - -ast_struct! { - /// Lifetimes and type parameters attached to a declaration of a function, - /// enum, trait, etc. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - #[derive(Default)] - pub struct Generics { - pub lt_token: Option, - pub params: Punctuated, - pub gt_token: Option]>, - pub where_clause: Option, - } -} - -ast_enum_of_structs! { - /// A generic type parameter, lifetime, or const generic: `T: Into`, - /// `'a: 'b`, `const LEN: usize`. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - /// - /// # Syntax tree enum - /// - /// This type is a [syntax tree enum]. - /// - /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums - pub enum GenericParam { - /// A generic type parameter: `T: Into`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Type(TypeParam { - pub attrs: Vec, - pub ident: Ident, - pub colon_token: Option, - pub bounds: Punctuated, - pub eq_token: Option, - pub default: Option, - }), - - /// A lifetime definition: `'a: 'b + 'c + 'd`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Lifetime(LifetimeDef { - pub attrs: Vec, - pub lifetime: Lifetime, - pub colon_token: Option, - pub bounds: Punctuated, - }), - - /// A const generic parameter: `const LENGTH: usize`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Const(ConstParam { - pub attrs: Vec, - pub const_token: Token![const], - pub ident: Ident, - pub colon_token: Token![:], - pub ty: Type, - pub eq_token: Option, - pub default: Option, - }), - } -} - -impl Generics { - /// Returns an - /// Iterator<Item = &TypeParam> - /// over the type parameters in `self.params`. - pub fn type_params(&self) -> TypeParams { - TypeParams(self.params.iter()) - } - - /// Returns an - /// Iterator<Item = &mut TypeParam> - /// over the type parameters in `self.params`. - pub fn type_params_mut(&mut self) -> TypeParamsMut { - TypeParamsMut(self.params.iter_mut()) - } - - /// Returns an - /// Iterator<Item = &LifetimeDef> - /// over the lifetime parameters in `self.params`. - pub fn lifetimes(&self) -> Lifetimes { - Lifetimes(self.params.iter()) - } - - /// Returns an - /// Iterator<Item = &mut LifetimeDef> - /// over the lifetime parameters in `self.params`. - pub fn lifetimes_mut(&mut self) -> LifetimesMut { - LifetimesMut(self.params.iter_mut()) - } - - /// Returns an - /// Iterator<Item = &ConstParam> - /// over the constant parameters in `self.params`. - pub fn const_params(&self) -> ConstParams { - ConstParams(self.params.iter()) - } - - /// Returns an - /// Iterator<Item = &mut ConstParam> - /// over the constant parameters in `self.params`. - pub fn const_params_mut(&mut self) -> ConstParamsMut { - ConstParamsMut(self.params.iter_mut()) - } - - /// Initializes an empty `where`-clause if there is not one present already. - pub fn make_where_clause(&mut self) -> &mut WhereClause { - // This is Option::get_or_insert_with in Rust 1.20. - if self.where_clause.is_none() { - self.where_clause = Some(WhereClause { - where_token: ::default(), - predicates: Punctuated::new(), - }); - } - match self.where_clause { - Some(ref mut where_clause) => where_clause, - None => unreachable!(), - } - } -} - -pub struct TypeParams<'a>(Iter<'a, GenericParam>); - -impl<'a> Iterator for TypeParams<'a> { - type Item = &'a TypeParam; - - fn next(&mut self) -> Option { - // FIXME: Remove this when ? on Option is stable - let next = match self.0.next() { - Some(item) => item, - None => return None, - }; - if let GenericParam::Type(ref type_param) = *next { - Some(type_param) - } else { - self.next() - } - } -} - -pub struct TypeParamsMut<'a>(IterMut<'a, GenericParam>); - -impl<'a> Iterator for TypeParamsMut<'a> { - type Item = &'a mut TypeParam; - - fn next(&mut self) -> Option { - // FIXME: Remove this when ? on Option is stable - let next = match self.0.next() { - Some(item) => item, - None => return None, - }; - if let GenericParam::Type(ref mut type_param) = *next { - Some(type_param) - } else { - self.next() - } - } -} - -pub struct Lifetimes<'a>(Iter<'a, GenericParam>); - -impl<'a> Iterator for Lifetimes<'a> { - type Item = &'a LifetimeDef; - - fn next(&mut self) -> Option { - // FIXME: Remove this when ? on Option is stable - let next = match self.0.next() { - Some(item) => item, - None => return None, - }; - if let GenericParam::Lifetime(ref lifetime) = *next { - Some(lifetime) - } else { - self.next() - } - } -} - -pub struct LifetimesMut<'a>(IterMut<'a, GenericParam>); - -impl<'a> Iterator for LifetimesMut<'a> { - type Item = &'a mut LifetimeDef; - - fn next(&mut self) -> Option { - // FIXME: Remove this when ? on Option is stable - let next = match self.0.next() { - Some(item) => item, - None => return None, - }; - if let GenericParam::Lifetime(ref mut lifetime) = *next { - Some(lifetime) - } else { - self.next() - } - } -} - -pub struct ConstParams<'a>(Iter<'a, GenericParam>); - -impl<'a> Iterator for ConstParams<'a> { - type Item = &'a ConstParam; - - fn next(&mut self) -> Option { - // FIXME: Remove this when ? on Option is stable - let next = match self.0.next() { - Some(item) => item, - None => return None, - }; - if let GenericParam::Const(ref const_param) = *next { - Some(const_param) - } else { - self.next() - } - } -} - -pub struct ConstParamsMut<'a>(IterMut<'a, GenericParam>); - -impl<'a> Iterator for ConstParamsMut<'a> { - type Item = &'a mut ConstParam; - - fn next(&mut self) -> Option { - // FIXME: Remove this when ? on Option is stable - let next = match self.0.next() { - Some(item) => item, - None => return None, - }; - if let GenericParam::Const(ref mut const_param) = *next { - Some(const_param) - } else { - self.next() - } - } -} - -/// Returned by `Generics::split_for_impl`. -/// -/// *This type is available if Syn is built with the `"derive"` or `"full"` -/// feature and the `"printing"` feature.* -#[cfg(feature = "printing")] -#[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))] -#[cfg_attr(feature = "clone-impls", derive(Clone))] -pub struct ImplGenerics<'a>(&'a Generics); - -/// Returned by `Generics::split_for_impl`. -/// -/// *This type is available if Syn is built with the `"derive"` or `"full"` -/// feature and the `"printing"` feature.* -#[cfg(feature = "printing")] -#[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))] -#[cfg_attr(feature = "clone-impls", derive(Clone))] -pub struct TypeGenerics<'a>(&'a Generics); - -/// Returned by `TypeGenerics::as_turbofish`. -/// -/// *This type is available if Syn is built with the `"derive"` or `"full"` -/// feature and the `"printing"` feature.* -#[cfg(feature = "printing")] -#[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))] -#[cfg_attr(feature = "clone-impls", derive(Clone))] -pub struct Turbofish<'a>(&'a Generics); - -#[cfg(feature = "printing")] -impl Generics { - /// Split a type's generics into the pieces required for impl'ing a trait - /// for that type. - /// - /// ``` - /// # extern crate proc_macro2; - /// # extern crate syn; - /// # #[macro_use] - /// # extern crate quote; - /// # use proc_macro2::{Span, Ident}; - /// # fn main() { - /// # let generics: syn::Generics = Default::default(); - /// # let name = Ident::new("MyType", Span::call_site()); - /// let (impl_generics, ty_generics, where_clause) = generics.split_for_impl(); - /// quote! { - /// impl #impl_generics MyTrait for #name #ty_generics #where_clause { - /// // ... - /// } - /// } - /// # ; - /// # } - /// ``` - /// - /// *This method is available if Syn is built with the `"derive"` or - /// `"full"` feature and the `"printing"` feature.* - pub fn split_for_impl(&self) -> (ImplGenerics, TypeGenerics, Option<&WhereClause>) { - ( - ImplGenerics(self), - TypeGenerics(self), - self.where_clause.as_ref(), - ) - } -} - -#[cfg(feature = "printing")] -impl<'a> TypeGenerics<'a> { - /// Turn a type's generics like `` into a turbofish like `::`. - /// - /// *This method is available if Syn is built with the `"derive"` or - /// `"full"` feature and the `"printing"` feature.* - pub fn as_turbofish(&self) -> Turbofish { - Turbofish(self.0) - } -} - -ast_struct! { - /// A set of bound lifetimes: `for<'a, 'b, 'c>`. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - #[derive(Default)] - pub struct BoundLifetimes { - pub for_token: Token![for], - pub lt_token: Token![<], - pub lifetimes: Punctuated, - pub gt_token: Token![>], - } -} - -impl LifetimeDef { - pub fn new(lifetime: Lifetime) -> Self { - LifetimeDef { - attrs: Vec::new(), - lifetime: lifetime, - colon_token: None, - bounds: Punctuated::new(), - } - } -} - -impl From for TypeParam { - fn from(ident: Ident) -> Self { - TypeParam { - attrs: vec![], - ident: ident, - colon_token: None, - bounds: Punctuated::new(), - eq_token: None, - default: None, - } - } -} - -ast_enum_of_structs! { - /// A trait or lifetime used as a bound on a type parameter. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - pub enum TypeParamBound { - pub Trait(TraitBound), - pub Lifetime(Lifetime), - } -} - -ast_struct! { - /// A trait used as a bound on a type parameter. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - pub struct TraitBound { - pub paren_token: Option, - pub modifier: TraitBoundModifier, - /// The `for<'a>` in `for<'a> Foo<&'a T>` - pub lifetimes: Option, - /// The `Foo<&'a T>` in `for<'a> Foo<&'a T>` - pub path: Path, - } -} - -ast_enum! { - /// A modifier on a trait bound, currently only used for the `?` in - /// `?Sized`. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - #[cfg_attr(feature = "clone-impls", derive(Copy))] - pub enum TraitBoundModifier { - None, - Maybe(Token![?]), - } -} - -ast_struct! { - /// A `where` clause in a definition: `where T: Deserialize<'de>, D: - /// 'static`. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - pub struct WhereClause { - pub where_token: Token![where], - pub predicates: Punctuated, - } -} - -ast_enum_of_structs! { - /// A single predicate in a `where` clause: `T: Deserialize<'de>`. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - /// - /// # Syntax tree enum - /// - /// This type is a [syntax tree enum]. - /// - /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums - pub enum WherePredicate { - /// A type predicate in a `where` clause: `for<'c> Foo<'c>: Trait<'c>`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Type(PredicateType { - /// Any lifetimes from a `for` binding - pub lifetimes: Option, - /// The type being bounded - pub bounded_ty: Type, - pub colon_token: Token![:], - /// Trait and lifetime bounds (`Clone+Send+'static`) - pub bounds: Punctuated, - }), - - /// A lifetime predicate in a `where` clause: `'a: 'b + 'c`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Lifetime(PredicateLifetime { - pub lifetime: Lifetime, - pub colon_token: Option, - pub bounds: Punctuated, - }), - - /// An equality predicate in a `where` clause (unsupported). - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Eq(PredicateEq { - pub lhs_ty: Type, - pub eq_token: Token![=], - pub rhs_ty: Type, - }), - } -} - -#[cfg(feature = "parsing")] -pub mod parsing { - use super::*; - - use punctuated::Pair; - use synom::Synom; - - impl Synom for Generics { - named!(parse -> Self, map!( - alt!( - do_parse!( - lt: punct!(<) >> - lifetimes: call!(Punctuated::::parse_terminated) >> - ty_params: cond!( - lifetimes.empty_or_trailing(), - Punctuated::::parse_terminated - ) >> - gt: punct!(>) >> - (lifetimes, ty_params, Some(lt), Some(gt)) - ) - | - epsilon!() => { |_| (Punctuated::new(), None, None, None) } - ), - |(lifetimes, ty_params, lt, gt)| Generics { - lt_token: lt, - params: lifetimes.into_pairs() - .map(Pair::into_tuple) - .map(|(life, comma)| Pair::new(GenericParam::Lifetime(life), comma)) - .chain(ty_params.unwrap_or_default() - .into_pairs() - .map(Pair::into_tuple) - .map(|(ty, comma)| Pair::new(GenericParam::Type(ty), comma))) - .collect(), - gt_token: gt, - where_clause: None, - } - )); - - fn description() -> Option<&'static str> { - Some("generic parameters in declaration") - } - } - - impl Synom for GenericParam { - named!(parse -> Self, alt!( - syn!(TypeParam) => { GenericParam::Type } - | - syn!(LifetimeDef) => { GenericParam::Lifetime } - | - syn!(ConstParam) => { GenericParam::Const } - )); - - fn description() -> Option<&'static str> { - Some("generic parameter") - } - } - - impl Synom for LifetimeDef { - named!(parse -> Self, do_parse!( - attrs: many0!(Attribute::parse_outer) >> - life: syn!(Lifetime) >> - colon: option!(punct!(:)) >> - bounds: cond!( - colon.is_some(), - Punctuated::parse_separated_nonempty - ) >> - (LifetimeDef { - attrs: attrs, - lifetime: life, - bounds: bounds.unwrap_or_default(), - colon_token: colon, - }) - )); - - fn description() -> Option<&'static str> { - Some("lifetime definition") - } - } - - impl Synom for BoundLifetimes { - named!(parse -> Self, do_parse!( - for_: keyword!(for) >> - lt: punct!(<) >> - lifetimes: call!(Punctuated::parse_terminated) >> - gt: punct!(>) >> - (BoundLifetimes { - for_token: for_, - lt_token: lt, - gt_token: gt, - lifetimes: lifetimes, - }) - )); - - fn description() -> Option<&'static str> { - Some("bound lifetimes") - } - } - - impl Synom for TypeParam { - named!(parse -> Self, do_parse!( - attrs: many0!(Attribute::parse_outer) >> - id: syn!(Ident) >> - colon: option!(punct!(:)) >> - bounds: cond!( - colon.is_some(), - Punctuated::parse_separated_nonempty - ) >> - default: option!(do_parse!( - eq: punct!(=) >> - ty: syn!(Type) >> - (eq, ty) - )) >> - (TypeParam { - attrs: attrs, - ident: id, - bounds: bounds.unwrap_or_default(), - colon_token: colon, - eq_token: default.as_ref().map(|d| Token![=]((d.0).0)), - default: default.map(|d| d.1), - }) - )); - - fn description() -> Option<&'static str> { - Some("type parameter") - } - } - - impl Synom for TypeParamBound { - named!(parse -> Self, alt!( - syn!(Lifetime) => { TypeParamBound::Lifetime } - | - syn!(TraitBound) => { TypeParamBound::Trait } - | - parens!(syn!(TraitBound)) => {|(parens, mut bound)| { - bound.paren_token = Some(parens); - TypeParamBound::Trait(bound) - }} - )); - - fn description() -> Option<&'static str> { - Some("type parameter bound") - } - } - - impl Synom for TraitBound { - named!(parse -> Self, do_parse!( - modifier: syn!(TraitBoundModifier) >> - lifetimes: option!(syn!(BoundLifetimes)) >> - mut path: syn!(Path) >> - parenthesized: option!(cond_reduce!( - path.segments.last().unwrap().value().arguments.is_empty(), - syn!(ParenthesizedGenericArguments) - )) >> - ({ - if let Some(parenthesized) = parenthesized { - let parenthesized = PathArguments::Parenthesized(parenthesized); - path.segments.last_mut().unwrap().value_mut().arguments = parenthesized; - } - TraitBound { - paren_token: None, - modifier: modifier, - lifetimes: lifetimes, - path: path, - } - }) - )); - - fn description() -> Option<&'static str> { - Some("trait bound") - } - } - - impl Synom for TraitBoundModifier { - named!(parse -> Self, alt!( - punct!(?) => { TraitBoundModifier::Maybe } - | - epsilon!() => { |_| TraitBoundModifier::None } - )); - - fn description() -> Option<&'static str> { - Some("trait bound modifier") - } - } - - impl Synom for ConstParam { - named!(parse -> Self, do_parse!( - attrs: many0!(Attribute::parse_outer) >> - const_: keyword!(const) >> - ident: syn!(Ident) >> - colon: punct!(:) >> - ty: syn!(Type) >> - eq_def: option!(tuple!(punct!(=), syn!(Expr))) >> - ({ - let (eq_token, default) = match eq_def { - Some((eq_token, default)) => (Some(eq_token), Some(default)), - None => (None, None), - }; - ConstParam { - attrs: attrs, - const_token: const_, - ident: ident, - colon_token: colon, - ty: ty, - eq_token: eq_token, - default: default, - } - }) - )); - - fn description() -> Option<&'static str> { - Some("generic `const` parameter") - } - } - - impl Synom for WhereClause { - named!(parse -> Self, do_parse!( - where_: keyword!(where) >> - predicates: call!(Punctuated::parse_terminated) >> - (WhereClause { - predicates: predicates, - where_token: where_, - }) - )); - - fn description() -> Option<&'static str> { - Some("where clause") - } - } - - impl Synom for WherePredicate { - named!(parse -> Self, alt!( - do_parse!( - ident: syn!(Lifetime) >> - colon: option!(punct!(:)) >> - bounds: cond!( - colon.is_some(), - Punctuated::parse_separated - ) >> - (WherePredicate::Lifetime(PredicateLifetime { - lifetime: ident, - bounds: bounds.unwrap_or_default(), - colon_token: colon, - })) - ) - | - do_parse!( - lifetimes: option!(syn!(BoundLifetimes)) >> - bounded_ty: syn!(Type) >> - colon: punct!(:) >> - bounds: call!(Punctuated::parse_separated_nonempty) >> - (WherePredicate::Type(PredicateType { - lifetimes: lifetimes, - bounded_ty: bounded_ty, - bounds: bounds, - colon_token: colon, - })) - ) - )); - - fn description() -> Option<&'static str> { - Some("predicate in where clause") - } - } -} - -#[cfg(feature = "printing")] -mod printing { - use super::*; - use attr::FilterAttrs; - use proc_macro2::TokenStream; - use quote::{ToTokens, TokenStreamExt}; - - impl ToTokens for Generics { - fn to_tokens(&self, tokens: &mut TokenStream) { - if self.params.is_empty() { - return; - } - - TokensOrDefault(&self.lt_token).to_tokens(tokens); - - // Print lifetimes before types and consts, regardless of their - // order in self.params. - // - // TODO: ordering rules for const parameters vs type parameters have - // not been settled yet. https://github.com/rust-lang/rust/issues/44580 - let mut trailing_or_empty = true; - for param in self.params.pairs() { - if let GenericParam::Lifetime(_) = **param.value() { - param.to_tokens(tokens); - trailing_or_empty = param.punct().is_some(); - } - } - for param in self.params.pairs() { - match **param.value() { - GenericParam::Type(_) | GenericParam::Const(_) => { - if !trailing_or_empty { - ::default().to_tokens(tokens); - trailing_or_empty = true; - } - param.to_tokens(tokens); - } - GenericParam::Lifetime(_) => {} - } - } - - TokensOrDefault(&self.gt_token).to_tokens(tokens); - } - } - - impl<'a> ToTokens for ImplGenerics<'a> { - fn to_tokens(&self, tokens: &mut TokenStream) { - if self.0.params.is_empty() { - return; - } - - TokensOrDefault(&self.0.lt_token).to_tokens(tokens); - - // Print lifetimes before types and consts, regardless of their - // order in self.params. - // - // TODO: ordering rules for const parameters vs type parameters have - // not been settled yet. https://github.com/rust-lang/rust/issues/44580 - let mut trailing_or_empty = true; - for param in self.0.params.pairs() { - if let GenericParam::Lifetime(_) = **param.value() { - param.to_tokens(tokens); - trailing_or_empty = param.punct().is_some(); - } - } - for param in self.0.params.pairs() { - if let GenericParam::Lifetime(_) = **param.value() { - continue; - } - if !trailing_or_empty { - ::default().to_tokens(tokens); - trailing_or_empty = true; - } - match **param.value() { - GenericParam::Lifetime(_) => unreachable!(), - GenericParam::Type(ref param) => { - // Leave off the type parameter defaults - tokens.append_all(param.attrs.outer()); - param.ident.to_tokens(tokens); - if !param.bounds.is_empty() { - TokensOrDefault(¶m.colon_token).to_tokens(tokens); - param.bounds.to_tokens(tokens); - } - } - GenericParam::Const(ref param) => { - // Leave off the const parameter defaults - tokens.append_all(param.attrs.outer()); - param.const_token.to_tokens(tokens); - param.ident.to_tokens(tokens); - param.colon_token.to_tokens(tokens); - param.ty.to_tokens(tokens); - } - } - param.punct().to_tokens(tokens); - } - - TokensOrDefault(&self.0.gt_token).to_tokens(tokens); - } - } - - impl<'a> ToTokens for TypeGenerics<'a> { - fn to_tokens(&self, tokens: &mut TokenStream) { - if self.0.params.is_empty() { - return; - } - - TokensOrDefault(&self.0.lt_token).to_tokens(tokens); - - // Print lifetimes before types and consts, regardless of their - // order in self.params. - // - // TODO: ordering rules for const parameters vs type parameters have - // not been settled yet. https://github.com/rust-lang/rust/issues/44580 - let mut trailing_or_empty = true; - for param in self.0.params.pairs() { - if let GenericParam::Lifetime(ref def) = **param.value() { - // Leave off the lifetime bounds and attributes - def.lifetime.to_tokens(tokens); - param.punct().to_tokens(tokens); - trailing_or_empty = param.punct().is_some(); - } - } - for param in self.0.params.pairs() { - if let GenericParam::Lifetime(_) = **param.value() { - continue; - } - if !trailing_or_empty { - ::default().to_tokens(tokens); - trailing_or_empty = true; - } - match **param.value() { - GenericParam::Lifetime(_) => unreachable!(), - GenericParam::Type(ref param) => { - // Leave off the type parameter defaults - param.ident.to_tokens(tokens); - } - GenericParam::Const(ref param) => { - // Leave off the const parameter defaults - param.ident.to_tokens(tokens); - } - } - param.punct().to_tokens(tokens); - } - - TokensOrDefault(&self.0.gt_token).to_tokens(tokens); - } - } - - impl<'a> ToTokens for Turbofish<'a> { - fn to_tokens(&self, tokens: &mut TokenStream) { - if !self.0.params.is_empty() { - ::default().to_tokens(tokens); - TypeGenerics(self.0).to_tokens(tokens); - } - } - } - - impl ToTokens for BoundLifetimes { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.for_token.to_tokens(tokens); - self.lt_token.to_tokens(tokens); - self.lifetimes.to_tokens(tokens); - self.gt_token.to_tokens(tokens); - } - } - - impl ToTokens for LifetimeDef { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.lifetime.to_tokens(tokens); - if !self.bounds.is_empty() { - TokensOrDefault(&self.colon_token).to_tokens(tokens); - self.bounds.to_tokens(tokens); - } - } - } - - impl ToTokens for TypeParam { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.ident.to_tokens(tokens); - if !self.bounds.is_empty() { - TokensOrDefault(&self.colon_token).to_tokens(tokens); - self.bounds.to_tokens(tokens); - } - if self.default.is_some() { - TokensOrDefault(&self.eq_token).to_tokens(tokens); - self.default.to_tokens(tokens); - } - } - } - - impl ToTokens for TraitBound { - fn to_tokens(&self, tokens: &mut TokenStream) { - let to_tokens = |tokens: &mut TokenStream| { - self.modifier.to_tokens(tokens); - self.lifetimes.to_tokens(tokens); - self.path.to_tokens(tokens); - }; - match self.paren_token { - Some(ref paren) => paren.surround(tokens, to_tokens), - None => to_tokens(tokens), - } - } - } - - impl ToTokens for TraitBoundModifier { - fn to_tokens(&self, tokens: &mut TokenStream) { - match *self { - TraitBoundModifier::None => {} - TraitBoundModifier::Maybe(ref t) => t.to_tokens(tokens), - } - } - } - - impl ToTokens for ConstParam { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.const_token.to_tokens(tokens); - self.ident.to_tokens(tokens); - self.colon_token.to_tokens(tokens); - self.ty.to_tokens(tokens); - if self.default.is_some() { - TokensOrDefault(&self.eq_token).to_tokens(tokens); - self.default.to_tokens(tokens); - } - } - } - - impl ToTokens for WhereClause { - fn to_tokens(&self, tokens: &mut TokenStream) { - if !self.predicates.is_empty() { - self.where_token.to_tokens(tokens); - self.predicates.to_tokens(tokens); - } - } - } - - impl ToTokens for PredicateType { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.lifetimes.to_tokens(tokens); - self.bounded_ty.to_tokens(tokens); - self.colon_token.to_tokens(tokens); - self.bounds.to_tokens(tokens); - } - } - - impl ToTokens for PredicateLifetime { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.lifetime.to_tokens(tokens); - if !self.bounds.is_empty() { - TokensOrDefault(&self.colon_token).to_tokens(tokens); - self.bounds.to_tokens(tokens); - } - } - } - - impl ToTokens for PredicateEq { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.lhs_ty.to_tokens(tokens); - self.eq_token.to_tokens(tokens); - self.rhs_ty.to_tokens(tokens); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/gen_helper.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/gen_helper.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/gen_helper.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/gen_helper.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,162 +0,0 @@ -// Copyright 2018 Syn Developers -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[cfg(feature = "fold")] -pub mod fold { - use fold::Fold; - use proc_macro2::Span; - use punctuated::{Pair, Punctuated}; - - pub trait FoldHelper { - type Item; - fn lift(self, f: F) -> Self - where - F: FnMut(Self::Item) -> Self::Item; - } - - impl FoldHelper for Vec { - type Item = T; - fn lift(self, f: F) -> Self - where - F: FnMut(Self::Item) -> Self::Item, - { - self.into_iter().map(f).collect() - } - } - - impl FoldHelper for Punctuated { - type Item = T; - fn lift(self, mut f: F) -> Self - where - F: FnMut(Self::Item) -> Self::Item, - { - self.into_pairs() - .map(Pair::into_tuple) - .map(|(t, u)| Pair::new(f(t), u)) - .collect() - } - } - - pub fn tokens_helper(folder: &mut F, spans: &S) -> S { - spans.fold(folder) - } - - pub trait Spans { - fn fold(&self, folder: &mut F) -> Self; - } - - impl Spans for Span { - fn fold(&self, folder: &mut F) -> Self { - folder.fold_span(*self) - } - } - - impl Spans for [Span; 1] { - fn fold(&self, folder: &mut F) -> Self { - [folder.fold_span(self[0])] - } - } - - impl Spans for [Span; 2] { - fn fold(&self, folder: &mut F) -> Self { - [folder.fold_span(self[0]), folder.fold_span(self[1])] - } - } - - impl Spans for [Span; 3] { - fn fold(&self, folder: &mut F) -> Self { - [ - folder.fold_span(self[0]), - folder.fold_span(self[1]), - folder.fold_span(self[2]), - ] - } - } -} - -#[cfg(feature = "visit")] -pub mod visit { - use proc_macro2::Span; - use visit::Visit; - - pub fn tokens_helper<'ast, V: Visit<'ast> + ?Sized, S: Spans>(visitor: &mut V, spans: &'ast S) { - spans.visit(visitor); - } - - pub trait Spans { - fn visit<'ast, V: Visit<'ast> + ?Sized>(&'ast self, visitor: &mut V); - } - - impl Spans for Span { - fn visit<'ast, V: Visit<'ast> + ?Sized>(&'ast self, visitor: &mut V) { - visitor.visit_span(self); - } - } - - impl Spans for [Span; 1] { - fn visit<'ast, V: Visit<'ast> + ?Sized>(&'ast self, visitor: &mut V) { - visitor.visit_span(&self[0]); - } - } - - impl Spans for [Span; 2] { - fn visit<'ast, V: Visit<'ast> + ?Sized>(&'ast self, visitor: &mut V) { - visitor.visit_span(&self[0]); - visitor.visit_span(&self[1]); - } - } - - impl Spans for [Span; 3] { - fn visit<'ast, V: Visit<'ast> + ?Sized>(&'ast self, visitor: &mut V) { - visitor.visit_span(&self[0]); - visitor.visit_span(&self[1]); - visitor.visit_span(&self[2]); - } - } -} - -#[cfg(feature = "visit-mut")] -pub mod visit_mut { - use proc_macro2::Span; - use visit_mut::VisitMut; - - pub fn tokens_helper(visitor: &mut V, spans: &mut S) { - spans.visit_mut(visitor); - } - - pub trait Spans { - fn visit_mut(&mut self, visitor: &mut V); - } - - impl Spans for Span { - fn visit_mut(&mut self, visitor: &mut V) { - visitor.visit_span_mut(self); - } - } - - impl Spans for [Span; 1] { - fn visit_mut(&mut self, visitor: &mut V) { - visitor.visit_span_mut(&mut self[0]); - } - } - - impl Spans for [Span; 2] { - fn visit_mut(&mut self, visitor: &mut V) { - visitor.visit_span_mut(&mut self[0]); - visitor.visit_span_mut(&mut self[1]); - } - } - - impl Spans for [Span; 3] { - fn visit_mut(&mut self, visitor: &mut V) { - visitor.visit_span_mut(&mut self[0]); - visitor.visit_span_mut(&mut self[1]); - visitor.visit_span_mut(&mut self[2]); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/item.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/item.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/item.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/item.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,2158 +0,0 @@ -// Copyright 2018 Syn Developers -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use super::*; -use derive::{Data, DeriveInput}; -use proc_macro2::TokenStream; -use punctuated::Punctuated; -use token::{Brace, Paren}; - -#[cfg(feature = "extra-traits")] -use std::hash::{Hash, Hasher}; -#[cfg(feature = "extra-traits")] -use tt::TokenStreamHelper; - -ast_enum_of_structs! { - /// Things that can appear directly inside of a module or scope. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - /// - /// # Syntax tree enum - /// - /// This type is a [syntax tree enum]. - /// - /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums - pub enum Item { - /// An `extern crate` item: `extern crate serde`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub ExternCrate(ItemExternCrate { - pub attrs: Vec, - pub vis: Visibility, - pub extern_token: Token![extern], - pub crate_token: Token![crate], - pub ident: Ident, - pub rename: Option<(Token![as], Ident)>, - pub semi_token: Token![;], - }), - - /// A use declaration: `use std::collections::HashMap`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Use(ItemUse { - pub attrs: Vec, - pub vis: Visibility, - pub use_token: Token![use], - pub leading_colon: Option, - pub tree: UseTree, - pub semi_token: Token![;], - }), - - /// A static item: `static BIKE: Shed = Shed(42)`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Static(ItemStatic { - pub attrs: Vec, - pub vis: Visibility, - pub static_token: Token![static], - pub mutability: Option, - pub ident: Ident, - pub colon_token: Token![:], - pub ty: Box, - pub eq_token: Token![=], - pub expr: Box, - pub semi_token: Token![;], - }), - - /// A constant item: `const MAX: u16 = 65535`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Const(ItemConst { - pub attrs: Vec, - pub vis: Visibility, - pub const_token: Token![const], - pub ident: Ident, - pub colon_token: Token![:], - pub ty: Box, - pub eq_token: Token![=], - pub expr: Box, - pub semi_token: Token![;], - }), - - /// A free-standing function: `fn process(n: usize) -> Result<()> { ... - /// }`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Fn(ItemFn { - pub attrs: Vec, - pub vis: Visibility, - pub constness: Option, - pub unsafety: Option, - pub abi: Option, - pub ident: Ident, - pub decl: Box, - pub block: Box, - }), - - /// A module or module declaration: `mod m` or `mod m { ... }`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Mod(ItemMod { - pub attrs: Vec, - pub vis: Visibility, - pub mod_token: Token![mod], - pub ident: Ident, - pub content: Option<(token::Brace, Vec)>, - pub semi: Option, - }), - - /// A block of foreign items: `extern "C" { ... }`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub ForeignMod(ItemForeignMod { - pub attrs: Vec, - pub abi: Abi, - pub brace_token: token::Brace, - pub items: Vec, - }), - - /// A type alias: `type Result = std::result::Result`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Type(ItemType { - pub attrs: Vec, - pub vis: Visibility, - pub type_token: Token![type], - pub ident: Ident, - pub generics: Generics, - pub eq_token: Token![=], - pub ty: Box, - pub semi_token: Token![;], - }), - - /// A struct definition: `struct Foo { x: A }`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Struct(ItemStruct { - pub attrs: Vec, - pub vis: Visibility, - pub struct_token: Token![struct], - pub ident: Ident, - pub generics: Generics, - pub fields: Fields, - pub semi_token: Option, - }), - - /// An enum definition: `enum Foo { C, D }`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Enum(ItemEnum { - pub attrs: Vec, - pub vis: Visibility, - pub enum_token: Token![enum], - pub ident: Ident, - pub generics: Generics, - pub brace_token: token::Brace, - pub variants: Punctuated, - }), - - /// A union definition: `union Foo { x: A, y: B }`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Union(ItemUnion { - pub attrs: Vec, - pub vis: Visibility, - pub union_token: Token![union], - pub ident: Ident, - pub generics: Generics, - pub fields: FieldsNamed, - }), - - /// A trait definition: `pub trait Iterator { ... }`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Trait(ItemTrait { - pub attrs: Vec, - pub vis: Visibility, - pub unsafety: Option, - pub auto_token: Option, - pub trait_token: Token![trait], - pub ident: Ident, - pub generics: Generics, - pub colon_token: Option, - pub supertraits: Punctuated, - pub brace_token: token::Brace, - pub items: Vec, - }), - - /// An impl block providing trait or associated items: `impl Trait - /// for Data { ... }`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Impl(ItemImpl { - pub attrs: Vec, - pub defaultness: Option, - pub unsafety: Option, - pub impl_token: Token![impl], - pub generics: Generics, - /// Trait this impl implements. - pub trait_: Option<(Option, Path, Token![for])>, - /// The Self type of the impl. - pub self_ty: Box, - pub brace_token: token::Brace, - pub items: Vec, - }), - - /// A macro invocation, which includes `macro_rules!` definitions. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Macro(ItemMacro { - pub attrs: Vec, - /// The `example` in `macro_rules! example { ... }`. - pub ident: Option, - pub mac: Macro, - pub semi_token: Option, - }), - - /// A 2.0-style declarative macro introduced by the `macro` keyword. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Macro2(ItemMacro2 #manual_extra_traits { - pub attrs: Vec, - pub vis: Visibility, - pub macro_token: Token![macro], - pub ident: Ident, - pub paren_token: Paren, - pub args: TokenStream, - pub brace_token: Brace, - pub body: TokenStream, - }), - - /// Tokens forming an item not interpreted by Syn. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Verbatim(ItemVerbatim #manual_extra_traits { - pub tts: TokenStream, - }), - } -} - -#[cfg(feature = "extra-traits")] -impl Eq for ItemMacro2 {} - -#[cfg(feature = "extra-traits")] -impl PartialEq for ItemMacro2 { - fn eq(&self, other: &Self) -> bool { - self.attrs == other.attrs - && self.vis == other.vis - && self.macro_token == other.macro_token - && self.ident == other.ident - && self.paren_token == other.paren_token - && TokenStreamHelper(&self.args) == TokenStreamHelper(&other.args) - && self.brace_token == other.brace_token - && TokenStreamHelper(&self.body) == TokenStreamHelper(&other.body) - } -} - -#[cfg(feature = "extra-traits")] -impl Hash for ItemMacro2 { - fn hash(&self, state: &mut H) - where - H: Hasher, - { - self.attrs.hash(state); - self.vis.hash(state); - self.macro_token.hash(state); - self.ident.hash(state); - self.paren_token.hash(state); - TokenStreamHelper(&self.args).hash(state); - self.brace_token.hash(state); - TokenStreamHelper(&self.body).hash(state); - } -} - -#[cfg(feature = "extra-traits")] -impl Eq for ItemVerbatim {} - -#[cfg(feature = "extra-traits")] -impl PartialEq for ItemVerbatim { - fn eq(&self, other: &Self) -> bool { - TokenStreamHelper(&self.tts) == TokenStreamHelper(&other.tts) - } -} - -#[cfg(feature = "extra-traits")] -impl Hash for ItemVerbatim { - fn hash(&self, state: &mut H) - where - H: Hasher, - { - TokenStreamHelper(&self.tts).hash(state); - } -} - -impl From for Item { - fn from(input: DeriveInput) -> Item { - match input.data { - Data::Struct(data) => Item::Struct(ItemStruct { - attrs: input.attrs, - vis: input.vis, - struct_token: data.struct_token, - ident: input.ident, - generics: input.generics, - fields: data.fields, - semi_token: data.semi_token, - }), - Data::Enum(data) => Item::Enum(ItemEnum { - attrs: input.attrs, - vis: input.vis, - enum_token: data.enum_token, - ident: input.ident, - generics: input.generics, - brace_token: data.brace_token, - variants: data.variants, - }), - Data::Union(data) => Item::Union(ItemUnion { - attrs: input.attrs, - vis: input.vis, - union_token: data.union_token, - ident: input.ident, - generics: input.generics, - fields: data.fields, - }), - } - } -} - -ast_enum_of_structs! { - /// A suffix of an import tree in a `use` item: `Type as Renamed` or `*`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - /// - /// # Syntax tree enum - /// - /// This type is a [syntax tree enum]. - /// - /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums - pub enum UseTree { - /// A path prefix of imports in a `use` item: `std::...`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Path(UsePath { - pub ident: Ident, - pub colon2_token: Token![::], - pub tree: Box, - }), - - /// An identifier imported by a `use` item: `HashMap`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Name(UseName { - pub ident: Ident, - }), - - /// An renamed identifier imported by a `use` item: `HashMap as Map`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Rename(UseRename { - pub ident: Ident, - pub as_token: Token![as], - pub rename: Ident, - }), - - /// A glob import in a `use` item: `*`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Glob(UseGlob { - pub star_token: Token![*], - }), - - /// A braced group of imports in a `use` item: `{A, B, C}`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Group(UseGroup { - pub brace_token: token::Brace, - pub items: Punctuated, - }), - } -} - -ast_enum_of_structs! { - /// An item within an `extern` block. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - /// - /// # Syntax tree enum - /// - /// This type is a [syntax tree enum]. - /// - /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums - pub enum ForeignItem { - /// A foreign function in an `extern` block. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Fn(ForeignItemFn { - pub attrs: Vec, - pub vis: Visibility, - pub ident: Ident, - pub decl: Box, - pub semi_token: Token![;], - }), - - /// A foreign static item in an `extern` block: `static ext: u8`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Static(ForeignItemStatic { - pub attrs: Vec, - pub vis: Visibility, - pub static_token: Token![static], - pub mutability: Option, - pub ident: Ident, - pub colon_token: Token![:], - pub ty: Box, - pub semi_token: Token![;], - }), - - /// A foreign type in an `extern` block: `type void`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Type(ForeignItemType { - pub attrs: Vec, - pub vis: Visibility, - pub type_token: Token![type], - pub ident: Ident, - pub semi_token: Token![;], - }), - - /// Tokens in an `extern` block not interpreted by Syn. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Verbatim(ForeignItemVerbatim #manual_extra_traits { - pub tts: TokenStream, - }), - } -} - -#[cfg(feature = "extra-traits")] -impl Eq for ForeignItemVerbatim {} - -#[cfg(feature = "extra-traits")] -impl PartialEq for ForeignItemVerbatim { - fn eq(&self, other: &Self) -> bool { - TokenStreamHelper(&self.tts) == TokenStreamHelper(&other.tts) - } -} - -#[cfg(feature = "extra-traits")] -impl Hash for ForeignItemVerbatim { - fn hash(&self, state: &mut H) - where - H: Hasher, - { - TokenStreamHelper(&self.tts).hash(state); - } -} - -ast_enum_of_structs! { - /// An item declaration within the definition of a trait. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - /// - /// # Syntax tree enum - /// - /// This type is a [syntax tree enum]. - /// - /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums - pub enum TraitItem { - /// An associated constant within the definition of a trait. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Const(TraitItemConst { - pub attrs: Vec, - pub const_token: Token![const], - pub ident: Ident, - pub colon_token: Token![:], - pub ty: Type, - pub default: Option<(Token![=], Expr)>, - pub semi_token: Token![;], - }), - - /// A trait method within the definition of a trait. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Method(TraitItemMethod { - pub attrs: Vec, - pub sig: MethodSig, - pub default: Option, - pub semi_token: Option, - }), - - /// An associated type within the definition of a trait. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Type(TraitItemType { - pub attrs: Vec, - pub type_token: Token![type], - pub ident: Ident, - pub generics: Generics, - pub colon_token: Option, - pub bounds: Punctuated, - pub default: Option<(Token![=], Type)>, - pub semi_token: Token![;], - }), - - /// A macro invocation within the definition of a trait. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Macro(TraitItemMacro { - pub attrs: Vec, - pub mac: Macro, - pub semi_token: Option, - }), - - /// Tokens within the definition of a trait not interpreted by Syn. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Verbatim(TraitItemVerbatim #manual_extra_traits { - pub tts: TokenStream, - }), - } -} - -#[cfg(feature = "extra-traits")] -impl Eq for TraitItemVerbatim {} - -#[cfg(feature = "extra-traits")] -impl PartialEq for TraitItemVerbatim { - fn eq(&self, other: &Self) -> bool { - TokenStreamHelper(&self.tts) == TokenStreamHelper(&other.tts) - } -} - -#[cfg(feature = "extra-traits")] -impl Hash for TraitItemVerbatim { - fn hash(&self, state: &mut H) - where - H: Hasher, - { - TokenStreamHelper(&self.tts).hash(state); - } -} - -ast_enum_of_structs! { - /// An item within an impl block. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - /// - /// # Syntax tree enum - /// - /// This type is a [syntax tree enum]. - /// - /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums - pub enum ImplItem { - /// An associated constant within an impl block. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Const(ImplItemConst { - pub attrs: Vec, - pub vis: Visibility, - pub defaultness: Option, - pub const_token: Token![const], - pub ident: Ident, - pub colon_token: Token![:], - pub ty: Type, - pub eq_token: Token![=], - pub expr: Expr, - pub semi_token: Token![;], - }), - - /// A method within an impl block. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Method(ImplItemMethod { - pub attrs: Vec, - pub vis: Visibility, - pub defaultness: Option, - pub sig: MethodSig, - pub block: Block, - }), - - /// An associated type within an impl block. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Type(ImplItemType { - pub attrs: Vec, - pub vis: Visibility, - pub defaultness: Option, - pub type_token: Token![type], - pub ident: Ident, - pub generics: Generics, - pub eq_token: Token![=], - pub ty: Type, - pub semi_token: Token![;], - }), - - /// A macro invocation within an impl block. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Macro(ImplItemMacro { - pub attrs: Vec, - pub mac: Macro, - pub semi_token: Option, - }), - - /// Tokens within an impl block not interpreted by Syn. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Verbatim(ImplItemVerbatim #manual_extra_traits { - pub tts: TokenStream, - }), - } -} - -#[cfg(feature = "extra-traits")] -impl Eq for ImplItemVerbatim {} - -#[cfg(feature = "extra-traits")] -impl PartialEq for ImplItemVerbatim { - fn eq(&self, other: &Self) -> bool { - TokenStreamHelper(&self.tts) == TokenStreamHelper(&other.tts) - } -} - -#[cfg(feature = "extra-traits")] -impl Hash for ImplItemVerbatim { - fn hash(&self, state: &mut H) - where - H: Hasher, - { - TokenStreamHelper(&self.tts).hash(state); - } -} - -ast_struct! { - /// A method's signature in a trait or implementation: `unsafe fn - /// initialize(&self)`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub struct MethodSig { - pub constness: Option, - pub unsafety: Option, - pub abi: Option, - pub ident: Ident, - pub decl: FnDecl, - } -} - -ast_struct! { - /// Header of a function declaration, without including the body. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub struct FnDecl { - pub fn_token: Token![fn], - pub generics: Generics, - pub paren_token: token::Paren, - pub inputs: Punctuated, - pub variadic: Option, - pub output: ReturnType, - } -} - -ast_enum_of_structs! { - /// An argument in a function signature: the `n: usize` in `fn f(n: usize)`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - /// - /// # Syntax tree enum - /// - /// This type is a [syntax tree enum]. - /// - /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums - pub enum FnArg { - /// Self captured by reference in a function signature: `&self` or `&mut - /// self`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub SelfRef(ArgSelfRef { - pub and_token: Token![&], - pub lifetime: Option, - pub mutability: Option, - pub self_token: Token![self], - }), - - /// Self captured by value in a function signature: `self` or `mut - /// self`. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub SelfValue(ArgSelf { - pub mutability: Option, - pub self_token: Token![self], - }), - - /// An explicitly typed pattern captured by a function signature. - /// - /// *This type is available if Syn is built with the `"full"` feature.* - pub Captured(ArgCaptured { - pub pat: Pat, - pub colon_token: Token![:], - pub ty: Type, - }), - - /// A pattern whose type is inferred captured by a function signature. - pub Inferred(Pat), - /// A type not bound to any pattern in a function signature. - pub Ignored(Type), - } -} - -#[cfg(feature = "parsing")] -pub mod parsing { - use super::*; - - use synom::Synom; - - impl_synom!(Item "item" alt!( - syn!(ItemExternCrate) => { Item::ExternCrate } - | - syn!(ItemUse) => { Item::Use } - | - syn!(ItemStatic) => { Item::Static } - | - syn!(ItemConst) => { Item::Const } - | - syn!(ItemFn) => { Item::Fn } - | - call!(unstable_async_fn) => { Item::Verbatim } - | - syn!(ItemMod) => { Item::Mod } - | - syn!(ItemForeignMod) => { Item::ForeignMod } - | - syn!(ItemType) => { Item::Type } - | - call!(unstable_existential_type) => { Item::Verbatim } - | - syn!(ItemStruct) => { Item::Struct } - | - syn!(ItemEnum) => { Item::Enum } - | - syn!(ItemUnion) => { Item::Union } - | - syn!(ItemTrait) => { Item::Trait } - | - syn!(ItemImpl) => { Item::Impl } - | - syn!(ItemMacro) => { Item::Macro } - | - syn!(ItemMacro2) => { Item::Macro2 } - )); - - impl_synom!(ItemMacro "macro item" do_parse!( - attrs: many0!(Attribute::parse_outer) >> - what: call!(Path::parse_mod_style) >> - bang: punct!(!) >> - ident: option!(syn!(Ident)) >> - body: call!(tt::delimited) >> - semi: cond!(!is_brace(&body.0), punct!(;)) >> - (ItemMacro { - attrs: attrs, - ident: ident, - mac: Macro { - path: what, - bang_token: bang, - delimiter: body.0, - tts: body.1, - }, - semi_token: semi, - }) - )); - - // TODO: figure out the actual grammar; is body required to be braced? - impl_synom!(ItemMacro2 "macro2 item" do_parse!( - attrs: many0!(Attribute::parse_outer) >> - vis: syn!(Visibility) >> - macro_: keyword!(macro) >> - ident: syn!(Ident) >> - args: call!(tt::parenthesized) >> - body: call!(tt::braced) >> - (ItemMacro2 { - attrs: attrs, - vis: vis, - macro_token: macro_, - ident: ident, - paren_token: args.0, - args: args.1, - brace_token: body.0, - body: body.1, - }) - )); - - impl_synom!(ItemExternCrate "extern crate item" do_parse!( - attrs: many0!(Attribute::parse_outer) >> - vis: syn!(Visibility) >> - extern_: keyword!(extern) >> - crate_: keyword!(crate) >> - ident: syn!(Ident) >> - rename: option!(tuple!(keyword!(as), syn!(Ident))) >> - semi: punct!(;) >> - (ItemExternCrate { - attrs: attrs, - vis: vis, - extern_token: extern_, - crate_token: crate_, - ident: ident, - rename: rename, - semi_token: semi, - }) - )); - - impl_synom!(ItemUse "use item" do_parse!( - attrs: many0!(Attribute::parse_outer) >> - vis: syn!(Visibility) >> - use_: keyword!(use) >> - leading_colon: option!(punct!(::)) >> - tree: syn!(UseTree) >> - semi: punct!(;) >> - (ItemUse { - attrs: attrs, - vis: vis, - use_token: use_, - leading_colon: leading_colon, - tree: tree, - semi_token: semi, - }) - )); - - named!(use_element -> Ident, alt!( - syn!(Ident) - | - keyword!(self) => { Into::into } - | - keyword!(super) => { Into::into } - | - keyword!(crate) => { Into::into } - | - keyword!(extern) => { Into::into } - )); - - impl_synom!(UseTree "use tree" alt!( - syn!(UseRename) => { UseTree::Rename } - | - syn!(UsePath) => { UseTree::Path } - | - syn!(UseName) => { UseTree::Name } - | - syn!(UseGlob) => { UseTree::Glob } - | - syn!(UseGroup) => { UseTree::Group } - )); - - impl_synom!(UsePath "use path" do_parse!( - ident: call!(use_element) >> - colon2_token: punct!(::) >> - tree: syn!(UseTree) >> - (UsePath { - ident: ident, - colon2_token: colon2_token, - tree: Box::new(tree), - }) - )); - - impl_synom!(UseName "use name" do_parse!( - ident: call!(use_element) >> - (UseName { - ident: ident, - }) - )); - - impl_synom!(UseRename "use rename" do_parse!( - ident: call!(use_element) >> - as_token: keyword!(as) >> - rename: syn!(Ident) >> - (UseRename { - ident: ident, - as_token: as_token, - rename: rename, - }) - )); - - impl_synom!(UseGlob "use glob" do_parse!( - star: punct!(*) >> - (UseGlob { - star_token: star, - }) - )); - - impl_synom!(UseGroup "use group" do_parse!( - list: braces!(Punctuated::parse_terminated) >> - (UseGroup { - brace_token: list.0, - items: list.1, - }) - )); - - impl_synom!(ItemStatic "static item" do_parse!( - attrs: many0!(Attribute::parse_outer) >> - vis: syn!(Visibility) >> - static_: keyword!(static) >> - mutability: option!(keyword!(mut)) >> - ident: syn!(Ident) >> - colon: punct!(:) >> - ty: syn!(Type) >> - eq: punct!(=) >> - value: syn!(Expr) >> - semi: punct!(;) >> - (ItemStatic { - attrs: attrs, - vis: vis, - static_token: static_, - mutability: mutability, - ident: ident, - colon_token: colon, - ty: Box::new(ty), - eq_token: eq, - expr: Box::new(value), - semi_token: semi, - }) - )); - - impl_synom!(ItemConst "const item" do_parse!( - attrs: many0!(Attribute::parse_outer) >> - vis: syn!(Visibility) >> - const_: keyword!(const) >> - ident: syn!(Ident) >> - colon: punct!(:) >> - ty: syn!(Type) >> - eq: punct!(=) >> - value: syn!(Expr) >> - semi: punct!(;) >> - (ItemConst { - attrs: attrs, - vis: vis, - const_token: const_, - ident: ident, - colon_token: colon, - ty: Box::new(ty), - eq_token: eq, - expr: Box::new(value), - semi_token: semi, - }) - )); - - impl_synom!(ItemFn "fn item" do_parse!( - outer_attrs: many0!(Attribute::parse_outer) >> - vis: syn!(Visibility) >> - constness: option!(keyword!(const)) >> - unsafety: option!(keyword!(unsafe)) >> - abi: option!(syn!(Abi)) >> - fn_: keyword!(fn) >> - ident: syn!(Ident) >> - generics: syn!(Generics) >> - inputs: parens!(Punctuated::parse_terminated) >> - ret: syn!(ReturnType) >> - where_clause: option!(syn!(WhereClause)) >> - inner_attrs_stmts: braces!(tuple!( - many0!(Attribute::parse_inner), - call!(Block::parse_within), - )) >> - (ItemFn { - attrs: { - let mut attrs = outer_attrs; - attrs.extend((inner_attrs_stmts.1).0); - attrs - }, - vis: vis, - constness: constness, - unsafety: unsafety, - abi: abi, - decl: Box::new(FnDecl { - fn_token: fn_, - paren_token: inputs.0, - inputs: inputs.1, - output: ret, - variadic: None, - generics: Generics { - where_clause: where_clause, - ..generics - }, - }), - ident: ident, - block: Box::new(Block { - brace_token: inner_attrs_stmts.0, - stmts: (inner_attrs_stmts.1).1, - }), - }) - )); - - named!(unstable_async_fn -> ItemVerbatim, do_parse!( - begin: call!(verbatim::grab_cursor) >> - many0!(Attribute::parse_outer) >> - syn!(Visibility) >> - option!(keyword!(const)) >> - option!(keyword!(unsafe)) >> - keyword!(async) >> - option!(syn!(Abi)) >> - keyword!(fn) >> - syn!(Ident) >> - syn!(Generics) >> - parens!(Punctuated::::parse_terminated) >> - syn!(ReturnType) >> - option!(syn!(WhereClause)) >> - braces!(tuple!( - many0!(Attribute::parse_inner), - call!(Block::parse_within), - )) >> - end: call!(verbatim::grab_cursor) >> - (ItemVerbatim { - tts: verbatim::token_range(begin..end), - }) - )); - - impl Synom for FnArg { - named!(parse -> Self, alt!( - do_parse!( - and: punct!(&) >> - lt: option!(syn!(Lifetime)) >> - mutability: option!(keyword!(mut)) >> - self_: keyword!(self) >> - not!(punct!(:)) >> - (ArgSelfRef { - lifetime: lt, - mutability: mutability, - and_token: and, - self_token: self_, - }.into()) - ) - | - do_parse!( - mutability: option!(keyword!(mut)) >> - self_: keyword!(self) >> - not!(punct!(:)) >> - (ArgSelf { - mutability: mutability, - self_token: self_, - }.into()) - ) - | - do_parse!( - pat: syn!(Pat) >> - colon: punct!(:) >> - ty: syn!(Type) >> - (ArgCaptured { - pat: pat, - ty: ty, - colon_token: colon, - }.into()) - ) - | - syn!(Type) => { FnArg::Ignored } - )); - - fn description() -> Option<&'static str> { - Some("function argument") - } - } - - impl_synom!(ItemMod "mod item" do_parse!( - outer_attrs: many0!(Attribute::parse_outer) >> - vis: syn!(Visibility) >> - mod_: keyword!(mod) >> - ident: syn!(Ident) >> - content_semi: alt!( - punct!(;) => {|semi| ( - Vec::new(), - None, - Some(semi), - )} - | - braces!( - tuple!( - many0!(Attribute::parse_inner), - many0!(Item::parse), - ) - ) => {|(brace, (inner_attrs, items))| ( - inner_attrs, - Some((brace, items)), - None, - )} - ) >> - (ItemMod { - attrs: { - let mut attrs = outer_attrs; - attrs.extend(content_semi.0); - attrs - }, - vis: vis, - mod_token: mod_, - ident: ident, - content: content_semi.1, - semi: content_semi.2, - }) - )); - - impl_synom!(ItemForeignMod "foreign mod item" do_parse!( - outer_attrs: many0!(Attribute::parse_outer) >> - abi: syn!(Abi) >> - braced_content: braces!(tuple!( - many0!(Attribute::parse_inner), - many0!(ForeignItem::parse), - )) >> - (ItemForeignMod { - attrs: { - let mut attrs = outer_attrs; - attrs.extend((braced_content.1).0); - attrs - }, - abi: abi, - brace_token: braced_content.0, - items: (braced_content.1).1, - }) - )); - - impl_synom!(ForeignItem "foreign item" alt!( - syn!(ForeignItemFn) => { ForeignItem::Fn } - | - syn!(ForeignItemStatic) => { ForeignItem::Static } - | - syn!(ForeignItemType) => { ForeignItem::Type } - | - call!(foreign_item_macro) => { ForeignItem::Verbatim } - )); - - impl_synom!(ForeignItemFn "foreign function" do_parse!( - attrs: many0!(Attribute::parse_outer) >> - vis: syn!(Visibility) >> - fn_: keyword!(fn) >> - ident: syn!(Ident) >> - generics: syn!(Generics) >> - inputs: parens!(do_parse!( - args: call!(Punctuated::parse_terminated) >> - variadic: option!(cond_reduce!(args.empty_or_trailing(), punct!(...))) >> - (args, variadic) - )) >> - ret: syn!(ReturnType) >> - where_clause: option!(syn!(WhereClause)) >> - semi: punct!(;) >> - ({ - let (parens, (inputs, variadic)) = inputs; - ForeignItemFn { - ident: ident, - attrs: attrs, - semi_token: semi, - decl: Box::new(FnDecl { - fn_token: fn_, - paren_token: parens, - inputs: inputs, - variadic: variadic, - output: ret, - generics: Generics { - where_clause: where_clause, - ..generics - }, - }), - vis: vis, - } - }) - )); - - impl_synom!(ForeignItemStatic "foreign static" do_parse!( - attrs: many0!(Attribute::parse_outer) >> - vis: syn!(Visibility) >> - static_: keyword!(static) >> - mutability: option!(keyword!(mut)) >> - ident: syn!(Ident) >> - colon: punct!(:) >> - ty: syn!(Type) >> - semi: punct!(;) >> - (ForeignItemStatic { - ident: ident, - attrs: attrs, - semi_token: semi, - ty: Box::new(ty), - mutability: mutability, - static_token: static_, - colon_token: colon, - vis: vis, - }) - )); - - impl_synom!(ForeignItemType "foreign type" do_parse!( - attrs: many0!(Attribute::parse_outer) >> - vis: syn!(Visibility) >> - type_: keyword!(type) >> - ident: syn!(Ident) >> - semi: punct!(;) >> - (ForeignItemType { - attrs: attrs, - vis: vis, - type_token: type_, - ident: ident, - semi_token: semi, - }) - )); - - named!(foreign_item_macro -> ForeignItemVerbatim, do_parse!( - begin: call!(verbatim::grab_cursor) >> - many0!(Attribute::parse_outer) >> - mac: syn!(Macro) >> - cond!(!is_brace(&mac.delimiter), punct!(;)) >> - end: call!(verbatim::grab_cursor) >> - (ForeignItemVerbatim { - tts: verbatim::token_range(begin..end), - }) - )); - - impl_synom!(ItemType "type item" do_parse!( - attrs: many0!(Attribute::parse_outer) >> - vis: syn!(Visibility) >> - type_: keyword!(type) >> - ident: syn!(Ident) >> - generics: syn!(Generics) >> - where_clause: option!(syn!(WhereClause)) >> - eq: punct!(=) >> - ty: syn!(Type) >> - semi: punct!(;) >> - (ItemType { - attrs: attrs, - vis: vis, - type_token: type_, - ident: ident, - generics: Generics { - where_clause: where_clause, - ..generics - }, - eq_token: eq, - ty: Box::new(ty), - semi_token: semi, - }) - )); - - named!(existential_type_helper(vis: bool) -> TokenStream, do_parse!( - begin: call!(verbatim::grab_cursor) >> - many0!(Attribute::parse_outer) >> - cond_reduce!(vis, syn!(Visibility)) >> - custom_keyword!(existential) >> - keyword!(type) >> - syn!(Ident) >> - syn!(Generics) >> - option!(syn!(WhereClause)) >> - colon: option!(punct!(:)) >> - cond!( - colon.is_some(), - Punctuated::::parse_separated_nonempty - ) >> - punct!(;) >> - end: call!(verbatim::grab_cursor) >> - (verbatim::token_range(begin..end)) - )); - - named!(unstable_existential_type -> ItemVerbatim, map!( - call!(existential_type_helper, true), - |tts| ItemVerbatim { tts: tts } - )); - - impl_synom!(ItemStruct "struct item" switch!( - map!(syn!(DeriveInput), Into::into), - Item::Struct(item) => value!(item) - | - _ => reject!() - )); - - impl_synom!(ItemEnum "enum item" switch!( - map!(syn!(DeriveInput), Into::into), - Item::Enum(item) => value!(item) - | - _ => reject!() - )); - - impl_synom!(ItemUnion "union item" do_parse!( - attrs: many0!(Attribute::parse_outer) >> - vis: syn!(Visibility) >> - union_: keyword!(union) >> - ident: syn!(Ident) >> - generics: syn!(Generics) >> - where_clause: option!(syn!(WhereClause)) >> - fields: syn!(FieldsNamed) >> - (ItemUnion { - attrs: attrs, - vis: vis, - union_token: union_, - ident: ident, - generics: Generics { - where_clause: where_clause, - ..generics - }, - fields: fields, - }) - )); - - impl_synom!(ItemTrait "trait item" do_parse!( - attrs: many0!(Attribute::parse_outer) >> - vis: syn!(Visibility) >> - unsafety: option!(keyword!(unsafe)) >> - auto_: option!(keyword!(auto)) >> - trait_: keyword!(trait) >> - ident: syn!(Ident) >> - generics: syn!(Generics) >> - colon: option!(punct!(:)) >> - bounds: cond!(colon.is_some(), Punctuated::parse_separated_nonempty) >> - where_clause: option!(syn!(WhereClause)) >> - body: braces!(many0!(TraitItem::parse)) >> - (ItemTrait { - attrs: attrs, - vis: vis, - unsafety: unsafety, - auto_token: auto_, - trait_token: trait_, - ident: ident, - generics: Generics { - where_clause: where_clause, - ..generics - }, - colon_token: colon, - supertraits: bounds.unwrap_or_default(), - brace_token: body.0, - items: body.1, - }) - )); - - impl_synom!(TraitItem "trait item" alt!( - syn!(TraitItemConst) => { TraitItem::Const } - | - syn!(TraitItemMethod) => { TraitItem::Method } - | - syn!(TraitItemType) => { TraitItem::Type } - | - call!(unstable_trait_existential_type) => { TraitItem::Verbatim } - | - syn!(TraitItemMacro) => { TraitItem::Macro } - )); - - impl_synom!(TraitItemConst "const trait item" do_parse!( - attrs: many0!(Attribute::parse_outer) >> - const_: keyword!(const) >> - ident: syn!(Ident) >> - colon: punct!(:) >> - ty: syn!(Type) >> - default: option!(tuple!(punct!(=), syn!(Expr))) >> - semi: punct!(;) >> - (TraitItemConst { - attrs: attrs, - const_token: const_, - ident: ident, - colon_token: colon, - ty: ty, - default: default, - semi_token: semi, - }) - )); - - impl_synom!(TraitItemMethod "method trait item" do_parse!( - outer_attrs: many0!(Attribute::parse_outer) >> - constness: option!(keyword!(const)) >> - unsafety: option!(keyword!(unsafe)) >> - abi: option!(syn!(Abi)) >> - fn_: keyword!(fn) >> - ident: syn!(Ident) >> - generics: syn!(Generics) >> - inputs: parens!(Punctuated::parse_terminated) >> - ret: syn!(ReturnType) >> - where_clause: option!(syn!(WhereClause)) >> - body: option!(braces!(tuple!( - many0!(Attribute::parse_inner), - call!(Block::parse_within), - ))) >> - semi: cond!(body.is_none(), punct!(;)) >> - ({ - let (inner_attrs, stmts) = match body { - Some((b, (inner_attrs, stmts))) => (inner_attrs, Some((stmts, b))), - None => (Vec::new(), None), - }; - TraitItemMethod { - attrs: { - let mut attrs = outer_attrs; - attrs.extend(inner_attrs); - attrs - }, - sig: MethodSig { - constness: constness, - unsafety: unsafety, - abi: abi, - ident: ident, - decl: FnDecl { - inputs: inputs.1, - output: ret, - fn_token: fn_, - paren_token: inputs.0, - variadic: None, - generics: Generics { - where_clause: where_clause, - ..generics - }, - }, - }, - default: stmts.map(|stmts| { - Block { - stmts: stmts.0, - brace_token: stmts.1, - } - }), - semi_token: semi, - } - }) - )); - - impl_synom!(TraitItemType "trait item type" do_parse!( - attrs: many0!(Attribute::parse_outer) >> - type_: keyword!(type) >> - ident: syn!(Ident) >> - generics: syn!(Generics) >> - colon: option!(punct!(:)) >> - bounds: cond!(colon.is_some(), Punctuated::parse_separated_nonempty) >> - where_clause: option!(syn!(WhereClause)) >> - default: option!(tuple!(punct!(=), syn!(Type))) >> - semi: punct!(;) >> - (TraitItemType { - attrs: attrs, - type_token: type_, - ident: ident, - generics: Generics { - where_clause: where_clause, - ..generics - }, - colon_token: colon, - bounds: bounds.unwrap_or_default(), - default: default, - semi_token: semi, - }) - )); - - named!(unstable_trait_existential_type -> TraitItemVerbatim, map!( - call!(existential_type_helper, false), - |tts| TraitItemVerbatim { tts: tts } - )); - - impl_synom!(TraitItemMacro "trait item macro" do_parse!( - attrs: many0!(Attribute::parse_outer) >> - mac: syn!(Macro) >> - semi: cond!(!is_brace(&mac.delimiter), punct!(;)) >> - (TraitItemMacro { - attrs: attrs, - mac: mac, - semi_token: semi, - }) - )); - - impl_synom!(ItemImpl "impl item" do_parse!( - outer_attrs: many0!(Attribute::parse_outer) >> - defaultness: option!(keyword!(default)) >> - unsafety: option!(keyword!(unsafe)) >> - impl_: keyword!(impl) >> - generics: syn!(Generics) >> - polarity_path: alt!( - do_parse!( - polarity: option!(punct!(!)) >> - path: syn!(Path) >> - for_: keyword!(for) >> - (Some((polarity, path, for_))) - ) - | - epsilon!() => { |_| None } - ) >> - self_ty: syn!(Type) >> - where_clause: option!(syn!(WhereClause)) >> - inner: braces!(tuple!( - many0!(Attribute::parse_inner), - many0!(ImplItem::parse), - )) >> - (ItemImpl { - attrs: { - let mut attrs = outer_attrs; - attrs.extend((inner.1).0); - attrs - }, - defaultness: defaultness, - unsafety: unsafety, - impl_token: impl_, - generics: Generics { - where_clause: where_clause, - ..generics - }, - trait_: polarity_path, - self_ty: Box::new(self_ty), - brace_token: inner.0, - items: (inner.1).1, - }) - )); - - impl_synom!(ImplItem "item in impl block" alt!( - syn!(ImplItemConst) => { ImplItem::Const } - | - syn!(ImplItemMethod) => { ImplItem::Method } - | - call!(unstable_async_method) => { ImplItem::Verbatim } - | - syn!(ImplItemType) => { ImplItem::Type } - | - call!(unstable_impl_existential_type) => { ImplItem::Verbatim } - | - syn!(ImplItemMacro) => { ImplItem::Macro } - )); - - impl_synom!(ImplItemConst "const item in impl block" do_parse!( - attrs: many0!(Attribute::parse_outer) >> - vis: syn!(Visibility) >> - defaultness: option!(keyword!(default)) >> - const_: keyword!(const) >> - ident: syn!(Ident) >> - colon: punct!(:) >> - ty: syn!(Type) >> - eq: punct!(=) >> - value: syn!(Expr) >> - semi: punct!(;) >> - (ImplItemConst { - attrs: attrs, - vis: vis, - defaultness: defaultness, - const_token: const_, - ident: ident, - colon_token: colon, - ty: ty, - eq_token: eq, - expr: value, - semi_token: semi, - }) - )); - - impl_synom!(ImplItemMethod "method in impl block" do_parse!( - outer_attrs: many0!(Attribute::parse_outer) >> - vis: syn!(Visibility) >> - defaultness: option!(keyword!(default)) >> - constness: option!(keyword!(const)) >> - unsafety: option!(keyword!(unsafe)) >> - abi: option!(syn!(Abi)) >> - fn_: keyword!(fn) >> - ident: syn!(Ident) >> - generics: syn!(Generics) >> - inputs: parens!(Punctuated::parse_terminated) >> - ret: syn!(ReturnType) >> - where_clause: option!(syn!(WhereClause)) >> - inner_attrs_stmts: braces!(tuple!( - many0!(Attribute::parse_inner), - call!(Block::parse_within), - )) >> - (ImplItemMethod { - attrs: { - let mut attrs = outer_attrs; - attrs.extend((inner_attrs_stmts.1).0); - attrs - }, - vis: vis, - defaultness: defaultness, - sig: MethodSig { - constness: constness, - unsafety: unsafety, - abi: abi, - ident: ident, - decl: FnDecl { - fn_token: fn_, - paren_token: inputs.0, - inputs: inputs.1, - output: ret, - generics: Generics { - where_clause: where_clause, - ..generics - }, - variadic: None, - }, - }, - block: Block { - brace_token: inner_attrs_stmts.0, - stmts: (inner_attrs_stmts.1).1, - }, - }) - )); - - named!(unstable_async_method -> ImplItemVerbatim, do_parse!( - begin: call!(verbatim::grab_cursor) >> - many0!(Attribute::parse_outer) >> - syn!(Visibility) >> - option!(keyword!(default)) >> - option!(keyword!(const)) >> - option!(keyword!(unsafe)) >> - keyword!(async) >> - option!(syn!(Abi)) >> - keyword!(fn) >> - syn!(Ident) >> - syn!(Generics) >> - parens!(Punctuated::::parse_terminated) >> - syn!(ReturnType) >> - option!(syn!(WhereClause)) >> - braces!(tuple!( - many0!(Attribute::parse_inner), - call!(Block::parse_within), - )) >> - end: call!(verbatim::grab_cursor) >> - (ImplItemVerbatim { - tts: verbatim::token_range(begin..end), - }) - )); - - impl_synom!(ImplItemType "type in impl block" do_parse!( - attrs: many0!(Attribute::parse_outer) >> - vis: syn!(Visibility) >> - defaultness: option!(keyword!(default)) >> - type_: keyword!(type) >> - ident: syn!(Ident) >> - generics: syn!(Generics) >> - where_clause: option!(syn!(WhereClause)) >> - eq: punct!(=) >> - ty: syn!(Type) >> - semi: punct!(;) >> - (ImplItemType { - attrs: attrs, - vis: vis, - defaultness: defaultness, - type_token: type_, - ident: ident, - generics: Generics { - where_clause: where_clause, - ..generics - }, - eq_token: eq, - ty: ty, - semi_token: semi, - }) - )); - - named!(unstable_impl_existential_type -> ImplItemVerbatim, map!( - call!(existential_type_helper, true), - |tts| ImplItemVerbatim { tts: tts } - )); - - impl_synom!(ImplItemMacro "macro in impl block" do_parse!( - attrs: many0!(Attribute::parse_outer) >> - mac: syn!(Macro) >> - semi: cond!(!is_brace(&mac.delimiter), punct!(;)) >> - (ImplItemMacro { - attrs: attrs, - mac: mac, - semi_token: semi, - }) - )); - - fn is_brace(delimiter: &MacroDelimiter) -> bool { - match *delimiter { - MacroDelimiter::Brace(_) => true, - MacroDelimiter::Paren(_) | MacroDelimiter::Bracket(_) => false, - } - } -} - -#[cfg(feature = "printing")] -mod printing { - use super::*; - use attr::FilterAttrs; - use proc_macro2::TokenStream; - use quote::{ToTokens, TokenStreamExt}; - - impl ToTokens for ItemExternCrate { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.vis.to_tokens(tokens); - self.extern_token.to_tokens(tokens); - self.crate_token.to_tokens(tokens); - self.ident.to_tokens(tokens); - if let Some((ref as_token, ref rename)) = self.rename { - as_token.to_tokens(tokens); - rename.to_tokens(tokens); - } - self.semi_token.to_tokens(tokens); - } - } - - impl ToTokens for ItemUse { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.vis.to_tokens(tokens); - self.use_token.to_tokens(tokens); - self.leading_colon.to_tokens(tokens); - self.tree.to_tokens(tokens); - self.semi_token.to_tokens(tokens); - } - } - - impl ToTokens for ItemStatic { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.vis.to_tokens(tokens); - self.static_token.to_tokens(tokens); - self.mutability.to_tokens(tokens); - self.ident.to_tokens(tokens); - self.colon_token.to_tokens(tokens); - self.ty.to_tokens(tokens); - self.eq_token.to_tokens(tokens); - self.expr.to_tokens(tokens); - self.semi_token.to_tokens(tokens); - } - } - - impl ToTokens for ItemConst { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.vis.to_tokens(tokens); - self.const_token.to_tokens(tokens); - self.ident.to_tokens(tokens); - self.colon_token.to_tokens(tokens); - self.ty.to_tokens(tokens); - self.eq_token.to_tokens(tokens); - self.expr.to_tokens(tokens); - self.semi_token.to_tokens(tokens); - } - } - - impl ToTokens for ItemFn { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.vis.to_tokens(tokens); - self.constness.to_tokens(tokens); - self.unsafety.to_tokens(tokens); - self.abi.to_tokens(tokens); - NamedDecl(&self.decl, &self.ident).to_tokens(tokens); - self.block.brace_token.surround(tokens, |tokens| { - tokens.append_all(self.attrs.inner()); - tokens.append_all(&self.block.stmts); - }); - } - } - - impl ToTokens for ItemMod { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.vis.to_tokens(tokens); - self.mod_token.to_tokens(tokens); - self.ident.to_tokens(tokens); - if let Some((ref brace, ref items)) = self.content { - brace.surround(tokens, |tokens| { - tokens.append_all(self.attrs.inner()); - tokens.append_all(items); - }); - } else { - TokensOrDefault(&self.semi).to_tokens(tokens); - } - } - } - - impl ToTokens for ItemForeignMod { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.abi.to_tokens(tokens); - self.brace_token.surround(tokens, |tokens| { - tokens.append_all(self.attrs.inner()); - tokens.append_all(&self.items); - }); - } - } - - impl ToTokens for ItemType { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.vis.to_tokens(tokens); - self.type_token.to_tokens(tokens); - self.ident.to_tokens(tokens); - self.generics.to_tokens(tokens); - self.generics.where_clause.to_tokens(tokens); - self.eq_token.to_tokens(tokens); - self.ty.to_tokens(tokens); - self.semi_token.to_tokens(tokens); - } - } - - impl ToTokens for ItemEnum { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.vis.to_tokens(tokens); - self.enum_token.to_tokens(tokens); - self.ident.to_tokens(tokens); - self.generics.to_tokens(tokens); - self.generics.where_clause.to_tokens(tokens); - self.brace_token.surround(tokens, |tokens| { - self.variants.to_tokens(tokens); - }); - } - } - - impl ToTokens for ItemStruct { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.vis.to_tokens(tokens); - self.struct_token.to_tokens(tokens); - self.ident.to_tokens(tokens); - self.generics.to_tokens(tokens); - match self.fields { - Fields::Named(ref fields) => { - self.generics.where_clause.to_tokens(tokens); - fields.to_tokens(tokens); - } - Fields::Unnamed(ref fields) => { - fields.to_tokens(tokens); - self.generics.where_clause.to_tokens(tokens); - TokensOrDefault(&self.semi_token).to_tokens(tokens); - } - Fields::Unit => { - self.generics.where_clause.to_tokens(tokens); - TokensOrDefault(&self.semi_token).to_tokens(tokens); - } - } - } - } - - impl ToTokens for ItemUnion { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.vis.to_tokens(tokens); - self.union_token.to_tokens(tokens); - self.ident.to_tokens(tokens); - self.generics.to_tokens(tokens); - self.generics.where_clause.to_tokens(tokens); - self.fields.to_tokens(tokens); - } - } - - impl ToTokens for ItemTrait { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.vis.to_tokens(tokens); - self.unsafety.to_tokens(tokens); - self.auto_token.to_tokens(tokens); - self.trait_token.to_tokens(tokens); - self.ident.to_tokens(tokens); - self.generics.to_tokens(tokens); - if !self.supertraits.is_empty() { - TokensOrDefault(&self.colon_token).to_tokens(tokens); - self.supertraits.to_tokens(tokens); - } - self.generics.where_clause.to_tokens(tokens); - self.brace_token.surround(tokens, |tokens| { - tokens.append_all(&self.items); - }); - } - } - - impl ToTokens for ItemImpl { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.defaultness.to_tokens(tokens); - self.unsafety.to_tokens(tokens); - self.impl_token.to_tokens(tokens); - self.generics.to_tokens(tokens); - if let Some((ref polarity, ref path, ref for_token)) = self.trait_ { - polarity.to_tokens(tokens); - path.to_tokens(tokens); - for_token.to_tokens(tokens); - } - self.self_ty.to_tokens(tokens); - self.generics.where_clause.to_tokens(tokens); - self.brace_token.surround(tokens, |tokens| { - tokens.append_all(self.attrs.inner()); - tokens.append_all(&self.items); - }); - } - } - - impl ToTokens for ItemMacro { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.mac.path.to_tokens(tokens); - self.mac.bang_token.to_tokens(tokens); - self.ident.to_tokens(tokens); - match self.mac.delimiter { - MacroDelimiter::Paren(ref paren) => { - paren.surround(tokens, |tokens| self.mac.tts.to_tokens(tokens)); - } - MacroDelimiter::Brace(ref brace) => { - brace.surround(tokens, |tokens| self.mac.tts.to_tokens(tokens)); - } - MacroDelimiter::Bracket(ref bracket) => { - bracket.surround(tokens, |tokens| self.mac.tts.to_tokens(tokens)); - } - } - self.semi_token.to_tokens(tokens); - } - } - - impl ToTokens for ItemMacro2 { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.vis.to_tokens(tokens); - self.macro_token.to_tokens(tokens); - self.ident.to_tokens(tokens); - self.paren_token.surround(tokens, |tokens| { - self.args.to_tokens(tokens); - }); - self.brace_token.surround(tokens, |tokens| { - self.body.to_tokens(tokens); - }); - } - } - - impl ToTokens for ItemVerbatim { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.tts.to_tokens(tokens); - } - } - - impl ToTokens for UsePath { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.ident.to_tokens(tokens); - self.colon2_token.to_tokens(tokens); - self.tree.to_tokens(tokens); - } - } - - impl ToTokens for UseName { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.ident.to_tokens(tokens); - } - } - - impl ToTokens for UseRename { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.ident.to_tokens(tokens); - self.as_token.to_tokens(tokens); - self.rename.to_tokens(tokens); - } - } - - impl ToTokens for UseGlob { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.star_token.to_tokens(tokens); - } - } - - impl ToTokens for UseGroup { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.brace_token.surround(tokens, |tokens| { - self.items.to_tokens(tokens); - }); - } - } - - impl ToTokens for TraitItemConst { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.const_token.to_tokens(tokens); - self.ident.to_tokens(tokens); - self.colon_token.to_tokens(tokens); - self.ty.to_tokens(tokens); - if let Some((ref eq_token, ref default)) = self.default { - eq_token.to_tokens(tokens); - default.to_tokens(tokens); - } - self.semi_token.to_tokens(tokens); - } - } - - impl ToTokens for TraitItemMethod { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.sig.to_tokens(tokens); - match self.default { - Some(ref block) => { - block.brace_token.surround(tokens, |tokens| { - tokens.append_all(self.attrs.inner()); - tokens.append_all(&block.stmts); - }); - } - None => { - TokensOrDefault(&self.semi_token).to_tokens(tokens); - } - } - } - } - - impl ToTokens for TraitItemType { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.type_token.to_tokens(tokens); - self.ident.to_tokens(tokens); - self.generics.to_tokens(tokens); - if !self.bounds.is_empty() { - TokensOrDefault(&self.colon_token).to_tokens(tokens); - self.bounds.to_tokens(tokens); - } - self.generics.where_clause.to_tokens(tokens); - if let Some((ref eq_token, ref default)) = self.default { - eq_token.to_tokens(tokens); - default.to_tokens(tokens); - } - self.semi_token.to_tokens(tokens); - } - } - - impl ToTokens for TraitItemMacro { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.mac.to_tokens(tokens); - self.semi_token.to_tokens(tokens); - } - } - - impl ToTokens for TraitItemVerbatim { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.tts.to_tokens(tokens); - } - } - - impl ToTokens for ImplItemConst { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.vis.to_tokens(tokens); - self.defaultness.to_tokens(tokens); - self.const_token.to_tokens(tokens); - self.ident.to_tokens(tokens); - self.colon_token.to_tokens(tokens); - self.ty.to_tokens(tokens); - self.eq_token.to_tokens(tokens); - self.expr.to_tokens(tokens); - self.semi_token.to_tokens(tokens); - } - } - - impl ToTokens for ImplItemMethod { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.vis.to_tokens(tokens); - self.defaultness.to_tokens(tokens); - self.sig.to_tokens(tokens); - self.block.brace_token.surround(tokens, |tokens| { - tokens.append_all(self.attrs.inner()); - tokens.append_all(&self.block.stmts); - }); - } - } - - impl ToTokens for ImplItemType { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.vis.to_tokens(tokens); - self.defaultness.to_tokens(tokens); - self.type_token.to_tokens(tokens); - self.ident.to_tokens(tokens); - self.generics.to_tokens(tokens); - self.generics.where_clause.to_tokens(tokens); - self.eq_token.to_tokens(tokens); - self.ty.to_tokens(tokens); - self.semi_token.to_tokens(tokens); - } - } - - impl ToTokens for ImplItemMacro { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.mac.to_tokens(tokens); - self.semi_token.to_tokens(tokens); - } - } - - impl ToTokens for ImplItemVerbatim { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.tts.to_tokens(tokens); - } - } - - impl ToTokens for ForeignItemFn { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.vis.to_tokens(tokens); - NamedDecl(&self.decl, &self.ident).to_tokens(tokens); - self.semi_token.to_tokens(tokens); - } - } - - impl ToTokens for ForeignItemStatic { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.vis.to_tokens(tokens); - self.static_token.to_tokens(tokens); - self.mutability.to_tokens(tokens); - self.ident.to_tokens(tokens); - self.colon_token.to_tokens(tokens); - self.ty.to_tokens(tokens); - self.semi_token.to_tokens(tokens); - } - } - - impl ToTokens for ForeignItemType { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.attrs.outer()); - self.vis.to_tokens(tokens); - self.type_token.to_tokens(tokens); - self.ident.to_tokens(tokens); - self.semi_token.to_tokens(tokens); - } - } - - impl ToTokens for ForeignItemVerbatim { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.tts.to_tokens(tokens); - } - } - - impl ToTokens for MethodSig { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.constness.to_tokens(tokens); - self.unsafety.to_tokens(tokens); - self.abi.to_tokens(tokens); - NamedDecl(&self.decl, &self.ident).to_tokens(tokens); - } - } - - struct NamedDecl<'a>(&'a FnDecl, &'a Ident); - - impl<'a> ToTokens for NamedDecl<'a> { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.0.fn_token.to_tokens(tokens); - self.1.to_tokens(tokens); - self.0.generics.to_tokens(tokens); - self.0.paren_token.surround(tokens, |tokens| { - self.0.inputs.to_tokens(tokens); - if self.0.variadic.is_some() && !self.0.inputs.empty_or_trailing() { - ::default().to_tokens(tokens); - } - self.0.variadic.to_tokens(tokens); - }); - self.0.output.to_tokens(tokens); - self.0.generics.where_clause.to_tokens(tokens); - } - } - - impl ToTokens for ArgSelfRef { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.and_token.to_tokens(tokens); - self.lifetime.to_tokens(tokens); - self.mutability.to_tokens(tokens); - self.self_token.to_tokens(tokens); - } - } - - impl ToTokens for ArgSelf { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.mutability.to_tokens(tokens); - self.self_token.to_tokens(tokens); - } - } - - impl ToTokens for ArgCaptured { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.pat.to_tokens(tokens); - self.colon_token.to_tokens(tokens); - self.ty.to_tokens(tokens); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/lib.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/lib.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/lib.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,788 +0,0 @@ -// Copyright 2018 Syn Developers -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Syn is a parsing library for parsing a stream of Rust tokens into a syntax -//! tree of Rust source code. -//! -//! Currently this library is geared toward the [custom derive] use case but -//! contains some APIs that may be useful for Rust procedural macros more -//! generally. -//! -//! [custom derive]: https://github.com/rust-lang/rfcs/blob/master/text/1681-macros-1.1.md -//! -//! - **Data structures** — Syn provides a complete syntax tree that can -//! represent any valid Rust source code. The syntax tree is rooted at -//! [`syn::File`] which represents a full source file, but there are other -//! entry points that may be useful to procedural macros including -//! [`syn::Item`], [`syn::Expr`] and [`syn::Type`]. -//! -//! - **Custom derives** — Of particular interest to custom derives is -//! [`syn::DeriveInput`] which is any of the three legal input items to a -//! derive macro. An example below shows using this type in a library that can -//! derive implementations of a trait of your own. -//! -//! - **Parser combinators** — Parsing in Syn is built on a suite of public -//! parser combinator macros that you can use for parsing any token-based -//! syntax you dream up within a `functionlike!(...)` procedural macro. Every -//! syntax tree node defined by Syn is individually parsable and may be used -//! as a building block for custom syntaxes, or you may do it all yourself -//! working from the most primitive tokens. -//! -//! - **Location information** — Every token parsed by Syn is associated with a -//! `Span` that tracks line and column information back to the source of that -//! token. These spans allow a procedural macro to display detailed error -//! messages pointing to all the right places in the user's code. There is an -//! example of this below. -//! -//! - **Feature flags** — Functionality is aggressively feature gated so your -//! procedural macros enable only what they need, and do not pay in compile -//! time for all the rest. -//! -//! [`syn::File`]: struct.File.html -//! [`syn::Item`]: enum.Item.html -//! [`syn::Expr`]: enum.Expr.html -//! [`syn::Type`]: enum.Type.html -//! [`syn::DeriveInput`]: struct.DeriveInput.html -//! -//! *Version requirement: Syn supports any compiler version back to Rust's very -//! first support for procedural macros in Rust 1.15.0. Some features especially -//! around error reporting are only available in newer compilers or on the -//! nightly channel.* -//! -//! ## Example of a custom derive -//! -//! The canonical custom derive using Syn looks like this. We write an ordinary -//! Rust function tagged with a `proc_macro_derive` attribute and the name of -//! the trait we are deriving. Any time that derive appears in the user's code, -//! the Rust compiler passes their data structure as tokens into our macro. We -//! get to execute arbitrary Rust code to figure out what to do with those -//! tokens, then hand some tokens back to the compiler to compile into the -//! user's crate. -//! -//! [`TokenStream`]: https://doc.rust-lang.org/proc_macro/struct.TokenStream.html -//! -//! ```toml -//! [dependencies] -//! syn = "0.14" -//! quote = "0.6" -//! -//! [lib] -//! proc-macro = true -//! ``` -//! -//! ```rust -//! extern crate proc_macro; -//! extern crate syn; -//! -//! #[macro_use] -//! extern crate quote; -//! -//! use proc_macro::TokenStream; -//! use syn::DeriveInput; -//! -//! # const IGNORE_TOKENS: &str = stringify! { -//! #[proc_macro_derive(MyMacro)] -//! # }; -//! pub fn my_macro(input: TokenStream) -> TokenStream { -//! // Parse the input tokens into a syntax tree -//! let input: DeriveInput = syn::parse(input).unwrap(); -//! -//! // Build the output, possibly using quasi-quotation -//! let expanded = quote! { -//! // ... -//! }; -//! -//! // Hand the output tokens back to the compiler -//! expanded.into() -//! } -//! # -//! # fn main() {} -//! ``` -//! -//! The [`heapsize`] example directory shows a complete working Macros 1.1 -//! implementation of a custom derive. It works on any Rust compiler \>=1.15.0. -//! The example derives a `HeapSize` trait which computes an estimate of the -//! amount of heap memory owned by a value. -//! -//! [`heapsize`]: https://github.com/dtolnay/syn/tree/master/examples/heapsize -//! -//! ```rust -//! pub trait HeapSize { -//! /// Total number of bytes of heap memory owned by `self`. -//! fn heap_size_of_children(&self) -> usize; -//! } -//! ``` -//! -//! The custom derive allows users to write `#[derive(HeapSize)]` on data -//! structures in their program. -//! -//! ```rust -//! # const IGNORE_TOKENS: &str = stringify! { -//! #[derive(HeapSize)] -//! # }; -//! struct Demo<'a, T: ?Sized> { -//! a: Box, -//! b: u8, -//! c: &'a str, -//! d: String, -//! } -//! ``` -//! -//! ## Spans and error reporting -//! -//! The [`heapsize2`] example directory is an extension of the `heapsize` -//! example that demonstrates some of the hygiene and error reporting properties -//! of Macros 2.0. This example currently requires a nightly Rust compiler -//! \>=1.24.0-nightly but we are working to stabilize all of the APIs involved. -//! -//! [`heapsize2`]: https://github.com/dtolnay/syn/tree/master/examples/heapsize2 -//! -//! The token-based procedural macro API provides great control over where the -//! compiler's error messages are displayed in user code. Consider the error the -//! user sees if one of their field types does not implement `HeapSize`. -//! -//! ```rust -//! # const IGNORE_TOKENS: &str = stringify! { -//! #[derive(HeapSize)] -//! # }; -//! struct Broken { -//! ok: String, -//! bad: std::thread::Thread, -//! } -//! ``` -//! -//! In the Macros 1.1 string-based procedural macro world, the resulting error -//! would point unhelpfully to the invocation of the derive macro and not to the -//! actual problematic field. -//! -//! ```text -//! error[E0599]: no method named `heap_size_of_children` found for type `std::thread::Thread` in the current scope -//! --> src/main.rs:4:10 -//! | -//! 4 | #[derive(HeapSize)] -//! | ^^^^^^^^ -//! ``` -//! -//! By tracking span information all the way through the expansion of a -//! procedural macro as shown in the `heapsize2` example, token-based macros in -//! Syn are able to trigger errors that directly pinpoint the source of the -//! problem. -//! -//! ```text -//! error[E0277]: the trait bound `std::thread::Thread: HeapSize` is not satisfied -//! --> src/main.rs:7:5 -//! | -//! 7 | bad: std::thread::Thread, -//! | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HeapSize` is not implemented for `Thread` -//! ``` -//! -//! ## Parsing a custom syntax using combinators -//! -//! The [`lazy-static`] example directory shows the implementation of a -//! `functionlike!(...)` procedural macro in which the input tokens are parsed -//! using [`nom`]-style parser combinators. -//! -//! [`lazy-static`]: https://github.com/dtolnay/syn/tree/master/examples/lazy-static -//! [`nom`]: https://github.com/Geal/nom -//! -//! The example reimplements the popular `lazy_static` crate from crates.io as a -//! procedural macro. -//! -//! ``` -//! # macro_rules! lazy_static { -//! # ($($tt:tt)*) => {} -//! # } -//! # -//! lazy_static! { -//! static ref USERNAME: Regex = Regex::new("^[a-z0-9_-]{3,16}$").unwrap(); -//! } -//! ``` -//! -//! The implementation shows how to trigger custom warnings and error messages -//! on the macro input. -//! -//! ```text -//! warning: come on, pick a more creative name -//! --> src/main.rs:10:16 -//! | -//! 10 | static ref FOO: String = "lazy_static".to_owned(); -//! | ^^^ -//! ``` -//! -//! ## Debugging -//! -//! When developing a procedural macro it can be helpful to look at what the -//! generated code looks like. Use `cargo rustc -- -Zunstable-options -//! --pretty=expanded` or the [`cargo expand`] subcommand. -//! -//! [`cargo expand`]: https://github.com/dtolnay/cargo-expand -//! -//! To show the expanded code for some crate that uses your procedural macro, -//! run `cargo expand` from that crate. To show the expanded code for one of -//! your own test cases, run `cargo expand --test the_test_case` where the last -//! argument is the name of the test file without the `.rs` extension. -//! -//! This write-up by Brandon W Maister discusses debugging in more detail: -//! [Debugging Rust's new Custom Derive system][debugging]. -//! -//! [debugging]: https://quodlibetor.github.io/posts/debugging-rusts-new-custom-derive-system/ -//! -//! ## Optional features -//! -//! Syn puts a lot of functionality behind optional features in order to -//! optimize compile time for the most common use cases. The following features -//! are available. -//! -//! - **`derive`** *(enabled by default)* — Data structures for representing the -//! possible input to a custom derive, including structs and enums and types. -//! - **`full`** — Data structures for representing the syntax tree of all valid -//! Rust source code, including items and expressions. -//! - **`parsing`** *(enabled by default)* — Ability to parse input tokens into -//! a syntax tree node of a chosen type. -//! - **`printing`** *(enabled by default)* — Ability to print a syntax tree -//! node as tokens of Rust source code. -//! - **`visit`** — Trait for traversing a syntax tree. -//! - **`visit-mut`** — Trait for traversing and mutating in place a syntax -//! tree. -//! - **`fold`** — Trait for transforming an owned syntax tree. -//! - **`clone-impls`** *(enabled by default)* — Clone impls for all syntax tree -//! types. -//! - **`extra-traits`** — Debug, Eq, PartialEq, Hash impls for all syntax tree -//! types. -//! - **`proc-macro`** *(enabled by default)* — Runtime dependency on the -//! dynamic library libproc_macro from rustc toolchain. - -// Syn types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/syn/0.14.9")] -#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))] -// Ignored clippy lints. -#![cfg_attr( - feature = "cargo-clippy", - allow( - const_static_lifetime, - doc_markdown, - large_enum_variant, - match_bool, - redundant_closure, - needless_pass_by_value, - redundant_field_names, - trivially_copy_pass_by_ref - ) -)] -// Ignored clippy_pedantic lints. -#![cfg_attr( - feature = "cargo-clippy", - allow( - cast_possible_truncation, - cast_possible_wrap, - if_not_else, - indexing_slicing, - items_after_statements, - shadow_unrelated, - similar_names, - single_match_else, - stutter, - unseparated_literal_suffix, - use_self, - used_underscore_binding - ) -)] - -#[cfg(all( - not(all(target_arch = "wasm32", target_os = "unknown")), - feature = "proc-macro" -))] -extern crate proc_macro; -extern crate proc_macro2; -extern crate unicode_xid; - -#[cfg(feature = "printing")] -extern crate quote; - -#[cfg(feature = "parsing")] -#[macro_use] -#[doc(hidden)] -pub mod parsers; - -#[macro_use] -mod macros; - -#[macro_use] -pub mod token; - -pub use proc_macro2::Ident; - -#[cfg(any(feature = "full", feature = "derive"))] -mod attr; -#[cfg(any(feature = "full", feature = "derive"))] -pub use attr::{AttrStyle, Attribute, Meta, MetaList, MetaNameValue, NestedMeta}; - -#[cfg(any(feature = "full", feature = "derive"))] -mod data; -#[cfg(any(feature = "full", feature = "derive"))] -pub use data::{ - Field, Fields, FieldsNamed, FieldsUnnamed, Variant, VisCrate, VisPublic, VisRestricted, - Visibility, -}; - -#[cfg(any(feature = "full", feature = "derive"))] -mod expr; -#[cfg(any(feature = "full", feature = "derive"))] -pub use expr::{ - Expr, ExprArray, ExprAssign, ExprAssignOp, ExprBinary, ExprBlock, ExprBox, ExprBreak, ExprCall, - ExprCast, ExprCatch, ExprClosure, ExprContinue, ExprField, ExprForLoop, ExprGroup, ExprIf, - ExprIfLet, ExprInPlace, ExprIndex, ExprLit, ExprLoop, ExprMacro, ExprMatch, ExprMethodCall, - ExprParen, ExprPath, ExprRange, ExprReference, ExprRepeat, ExprReturn, ExprStruct, ExprTry, - ExprTuple, ExprType, ExprUnary, ExprUnsafe, ExprVerbatim, ExprWhile, ExprWhileLet, ExprYield, - Index, Member, -}; - -#[cfg(feature = "full")] -pub use expr::{ - Arm, Block, FieldPat, FieldValue, GenericMethodArgument, Label, Local, MethodTurbofish, Pat, - PatBox, PatIdent, PatLit, PatMacro, PatPath, PatRange, PatRef, PatSlice, PatStruct, PatTuple, - PatTupleStruct, PatVerbatim, PatWild, RangeLimits, Stmt, -}; - -#[cfg(any(feature = "full", feature = "derive"))] -mod generics; -#[cfg(any(feature = "full", feature = "derive"))] -pub use generics::{ - BoundLifetimes, ConstParam, GenericParam, Generics, LifetimeDef, PredicateEq, - PredicateLifetime, PredicateType, TraitBound, TraitBoundModifier, TypeParam, TypeParamBound, - WhereClause, WherePredicate, -}; -#[cfg(all( - any(feature = "full", feature = "derive"), - feature = "printing" -))] -pub use generics::{ImplGenerics, Turbofish, TypeGenerics}; - -#[cfg(feature = "full")] -mod item; -#[cfg(feature = "full")] -pub use item::{ - ArgCaptured, ArgSelf, ArgSelfRef, FnArg, FnDecl, ForeignItem, ForeignItemFn, ForeignItemStatic, - ForeignItemType, ForeignItemVerbatim, ImplItem, ImplItemConst, ImplItemMacro, ImplItemMethod, - ImplItemType, ImplItemVerbatim, Item, ItemConst, ItemEnum, ItemExternCrate, ItemFn, - ItemForeignMod, ItemImpl, ItemMacro, ItemMacro2, ItemMod, ItemStatic, ItemStruct, ItemTrait, - ItemType, ItemUnion, ItemUse, ItemVerbatim, MethodSig, TraitItem, TraitItemConst, - TraitItemMacro, TraitItemMethod, TraitItemType, TraitItemVerbatim, UseGlob, UseGroup, UseName, - UsePath, UseRename, UseTree, -}; - -#[cfg(feature = "full")] -mod file; -#[cfg(feature = "full")] -pub use file::File; - -#[cfg(any(feature = "full", feature = "derive"))] -mod lifetime; -#[cfg(any(feature = "full", feature = "derive"))] -pub use lifetime::Lifetime; - -#[cfg(any(feature = "full", feature = "derive"))] -mod lit; -#[cfg(any(feature = "full", feature = "derive"))] -pub use lit::{ - FloatSuffix, IntSuffix, Lit, LitBool, LitByte, LitByteStr, LitChar, LitFloat, LitInt, LitStr, - LitVerbatim, StrStyle, -}; - -#[cfg(any(feature = "full", feature = "derive"))] -mod mac; -#[cfg(any(feature = "full", feature = "derive"))] -pub use mac::{Macro, MacroDelimiter}; - -#[cfg(any(feature = "full", feature = "derive"))] -mod derive; -#[cfg(feature = "derive")] -pub use derive::{Data, DataEnum, DataStruct, DataUnion, DeriveInput}; - -#[cfg(any(feature = "full", feature = "derive"))] -mod op; -#[cfg(any(feature = "full", feature = "derive"))] -pub use op::{BinOp, UnOp}; - -#[cfg(any(feature = "full", feature = "derive"))] -mod ty; -#[cfg(any(feature = "full", feature = "derive"))] -pub use ty::{ - Abi, BareFnArg, BareFnArgName, ReturnType, Type, TypeArray, TypeBareFn, TypeGroup, - TypeImplTrait, TypeInfer, TypeMacro, TypeNever, TypeParen, TypePath, TypePtr, TypeReference, - TypeSlice, TypeTraitObject, TypeTuple, TypeVerbatim, -}; - -#[cfg(any(feature = "full", feature = "derive"))] -mod path; -#[cfg(all( - any(feature = "full", feature = "derive"), - feature = "printing" -))] -pub use path::PathTokens; -#[cfg(any(feature = "full", feature = "derive"))] -pub use path::{ - AngleBracketedGenericArguments, Binding, GenericArgument, ParenthesizedGenericArguments, Path, - PathArguments, PathSegment, QSelf, -}; - -#[cfg(feature = "parsing")] -pub mod buffer; -pub mod punctuated; -#[cfg(feature = "parsing")] -pub mod synom; -#[cfg(any(feature = "full", feature = "derive"))] -mod tt; - -// Not public API except the `parse_quote!` macro. -#[cfg(feature = "parsing")] -#[doc(hidden)] -pub mod parse_quote; - -#[cfg(all(feature = "parsing", feature = "printing"))] -pub mod spanned; - -#[cfg(all(feature = "parsing", feature = "full"))] -mod verbatim; - -mod gen { - /// Syntax tree traversal to walk a shared borrow of a syntax tree. - /// - /// Each method of the [`Visit`] trait is a hook that can be overridden to - /// customize the behavior when visiting the corresponding type of node. By - /// default, every method recursively visits the substructure of the input - /// by invoking the right visitor method of each of its fields. - /// - /// [`Visit`]: trait.Visit.html - /// - /// ```rust - /// # use syn::{Attribute, BinOp, Expr, ExprBinary}; - /// # - /// pub trait Visit<'ast> { - /// /* ... */ - /// - /// fn visit_expr_binary(&mut self, node: &'ast ExprBinary) { - /// for attr in &node.attrs { - /// self.visit_attribute(attr); - /// } - /// self.visit_expr(&*node.left); - /// self.visit_bin_op(&node.op); - /// self.visit_expr(&*node.right); - /// } - /// - /// /* ... */ - /// # fn visit_attribute(&mut self, node: &'ast Attribute); - /// # fn visit_expr(&mut self, node: &'ast Expr); - /// # fn visit_bin_op(&mut self, node: &'ast BinOp); - /// } - /// ``` - /// - /// *This module is available if Syn is built with the `"visit"` feature.* - #[cfg(feature = "visit")] - pub mod visit; - - /// Syntax tree traversal to mutate an exclusive borrow of a syntax tree in - /// place. - /// - /// Each method of the [`VisitMut`] trait is a hook that can be overridden - /// to customize the behavior when mutating the corresponding type of node. - /// By default, every method recursively visits the substructure of the - /// input by invoking the right visitor method of each of its fields. - /// - /// [`VisitMut`]: trait.VisitMut.html - /// - /// ```rust - /// # use syn::{Attribute, BinOp, Expr, ExprBinary}; - /// # - /// pub trait VisitMut { - /// /* ... */ - /// - /// fn visit_expr_binary_mut(&mut self, node: &mut ExprBinary) { - /// for attr in &mut node.attrs { - /// self.visit_attribute_mut(attr); - /// } - /// self.visit_expr_mut(&mut *node.left); - /// self.visit_bin_op_mut(&mut node.op); - /// self.visit_expr_mut(&mut *node.right); - /// } - /// - /// /* ... */ - /// # fn visit_attribute_mut(&mut self, node: &mut Attribute); - /// # fn visit_expr_mut(&mut self, node: &mut Expr); - /// # fn visit_bin_op_mut(&mut self, node: &mut BinOp); - /// } - /// ``` - /// - /// *This module is available if Syn is built with the `"visit-mut"` - /// feature.* - #[cfg(feature = "visit-mut")] - pub mod visit_mut; - - /// Syntax tree traversal to transform the nodes of an owned syntax tree. - /// - /// Each method of the [`Fold`] trait is a hook that can be overridden to - /// customize the behavior when transforming the corresponding type of node. - /// By default, every method recursively visits the substructure of the - /// input by invoking the right visitor method of each of its fields. - /// - /// [`Fold`]: trait.Fold.html - /// - /// ```rust - /// # use syn::{Attribute, BinOp, Expr, ExprBinary}; - /// # - /// pub trait Fold { - /// /* ... */ - /// - /// fn fold_expr_binary(&mut self, node: ExprBinary) -> ExprBinary { - /// ExprBinary { - /// attrs: node.attrs - /// .into_iter() - /// .map(|attr| self.fold_attribute(attr)) - /// .collect(), - /// left: Box::new(self.fold_expr(*node.left)), - /// op: self.fold_bin_op(node.op), - /// right: Box::new(self.fold_expr(*node.right)), - /// } - /// } - /// - /// /* ... */ - /// # fn fold_attribute(&mut self, node: Attribute) -> Attribute; - /// # fn fold_expr(&mut self, node: Expr) -> Expr; - /// # fn fold_bin_op(&mut self, node: BinOp) -> BinOp; - /// } - /// ``` - /// - /// *This module is available if Syn is built with the `"fold"` feature.* - #[cfg(feature = "fold")] - pub mod fold; - - #[cfg(any(feature = "full", feature = "derive"))] - #[path = "../gen_helper.rs"] - mod helper; -} -pub use gen::*; - -//////////////////////////////////////////////////////////////////////////////// - -#[cfg(feature = "parsing")] -use synom::{Parser, Synom}; - -#[cfg(feature = "parsing")] -mod error; -#[cfg(feature = "parsing")] -use error::ParseError; - -// Not public API. -#[cfg(feature = "parsing")] -#[doc(hidden)] -pub use error::parse_error; - -/// Parse tokens of source code into the chosen syntax tree node. -/// -/// This is preferred over parsing a string because tokens are able to preserve -/// information about where in the user's code they were originally written (the -/// "span" of the token), possibly allowing the compiler to produce better error -/// messages. -/// -/// This function parses a `proc_macro::TokenStream` which is the type used for -/// interop with the compiler in a procedural macro. To parse a -/// `proc_macro2::TokenStream`, use [`syn::parse2`] instead. -/// -/// [`syn::parse2`]: fn.parse2.html -/// -/// *This function is available if Syn is built with both the `"parsing"` and -/// `"proc-macro"` features.* -/// -/// # Examples -/// -/// ```rust -/// extern crate proc_macro; -/// use proc_macro::TokenStream; -/// -/// extern crate syn; -/// -/// #[macro_use] -/// extern crate quote; -/// -/// use syn::DeriveInput; -/// -/// # const IGNORE_TOKENS: &str = stringify! { -/// #[proc_macro_derive(MyMacro)] -/// # }; -/// pub fn my_macro(input: TokenStream) -> TokenStream { -/// // Parse the tokens into a syntax tree -/// let ast: DeriveInput = syn::parse(input).unwrap(); -/// -/// // Build the output, possibly using quasi-quotation -/// let expanded = quote! { -/// /* ... */ -/// }; -/// -/// // Convert into a token stream and return it -/// expanded.into() -/// } -/// # -/// # fn main() {} -/// ``` -#[cfg(all( - not(all(target_arch = "wasm32", target_os = "unknown")), - feature = "parsing", - feature = "proc-macro" -))] -pub fn parse(tokens: proc_macro::TokenStream) -> Result -where - T: Synom, -{ - parse2(tokens.into()) -} - -/// Parse a proc-macro2 token stream into the chosen syntax tree node. -/// -/// This function parses a `proc_macro2::TokenStream` which is commonly useful -/// when the input comes from a node of the Syn syntax tree, for example the tts -/// of a [`Macro`] node. When in a procedural macro parsing the -/// `proc_macro::TokenStream` provided by the compiler, use [`syn::parse`] -/// instead. -/// -/// [`Macro`]: struct.Macro.html -/// [`syn::parse`]: fn.parse.html -/// -/// *This function is available if Syn is built with the `"parsing"` feature.* -#[cfg(feature = "parsing")] -pub fn parse2(tokens: proc_macro2::TokenStream) -> Result -where - T: Synom, -{ - let parser = T::parse; - parser.parse2(tokens).map_err(|err| match T::description() { - Some(s) => ParseError::new(format!("failed to parse {}: {}", s, err)), - None => err, - }) -} - -/// Parse a string of Rust code into the chosen syntax tree node. -/// -/// *This function is available if Syn is built with the `"parsing"` feature.* -/// -/// # Hygiene -/// -/// Every span in the resulting syntax tree will be set to resolve at the macro -/// call site. -/// -/// # Examples -/// -/// ```rust -/// extern crate syn; -/// # -/// # -/// # type Result = std::result::Result>; -/// -/// use syn::Expr; -/// -/// fn run() -> Result<()> { -/// let code = "assert_eq!(u8::max_value(), 255)"; -/// let expr = syn::parse_str::(code)?; -/// println!("{:#?}", expr); -/// Ok(()) -/// } -/// # -/// # fn main() { run().unwrap() } -/// ``` -#[cfg(feature = "parsing")] -pub fn parse_str(s: &str) -> Result { - match s.parse() { - Ok(tts) => parse2(tts), - Err(_) => Err(ParseError::new("error while lexing input string")), - } -} - -// FIXME the name parse_file makes it sound like you might pass in a path to a -// file, rather than the content. -/// Parse the content of a file of Rust code. -/// -/// This is different from `syn::parse_str::(content)` in two ways: -/// -/// - It discards a leading byte order mark `\u{FEFF}` if the file has one. -/// - It preserves the shebang line of the file, such as `#!/usr/bin/env rustx`. -/// -/// If present, either of these would be an error using `from_str`. -/// -/// *This function is available if Syn is built with the `"parsing"` and `"full"` features.* -/// -/// # Examples -/// -/// ```rust,no_run -/// extern crate syn; -/// # -/// # -/// # type Result = std::result::Result>; -/// -/// use std::fs::File; -/// use std::io::Read; -/// -/// fn run() -> Result<()> { -/// let mut file = File::open("path/to/code.rs")?; -/// let mut content = String::new(); -/// file.read_to_string(&mut content)?; -/// -/// let ast = syn::parse_file(&content)?; -/// if let Some(shebang) = ast.shebang { -/// println!("{}", shebang); -/// } -/// println!("{} items", ast.items.len()); -/// -/// Ok(()) -/// } -/// # -/// # fn main() { run().unwrap() } -/// ``` -#[cfg(all(feature = "parsing", feature = "full"))] -pub fn parse_file(mut content: &str) -> Result { - // Strip the BOM if it is present - const BOM: &'static str = "\u{feff}"; - if content.starts_with(BOM) { - content = &content[BOM.len()..]; - } - - let mut shebang = None; - if content.starts_with("#!") && !content.starts_with("#![") { - if let Some(idx) = content.find('\n') { - shebang = Some(content[..idx].to_string()); - content = &content[idx..]; - } else { - shebang = Some(content.to_string()); - content = ""; - } - } - - let mut file: File = parse_str(content)?; - file.shebang = shebang; - Ok(file) -} - -#[cfg(all( - any(feature = "full", feature = "derive"), - feature = "printing" -))] -struct TokensOrDefault<'a, T: 'a>(&'a Option); - -#[cfg(all( - any(feature = "full", feature = "derive"), - feature = "printing" -))] -impl<'a, T> quote::ToTokens for TokensOrDefault<'a, T> -where - T: quote::ToTokens + Default, -{ - fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) { - match *self.0 { - Some(ref t) => t.to_tokens(tokens), - None => T::default().to_tokens(tokens), - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/lifetime.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/lifetime.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/lifetime.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/lifetime.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,150 +0,0 @@ -// Copyright 2018 Syn Developers -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::cmp::Ordering; -use std::fmt::{self, Display}; -use std::hash::{Hash, Hasher}; - -use proc_macro2::{Ident, Span}; -use unicode_xid::UnicodeXID; - -use token::Apostrophe; - -/// A Rust lifetime: `'a`. -/// -/// Lifetime names must conform to the following rules: -/// -/// - Must start with an apostrophe. -/// - Must not consist of just an apostrophe: `'`. -/// - Character after the apostrophe must be `_` or a Unicode code point with -/// the XID_Start property. -/// - All following characters must be Unicode code points with the XID_Continue -/// property. -/// -/// *This type is available if Syn is built with the `"derive"` or `"full"` -/// feature.* -#[cfg_attr(feature = "extra-traits", derive(Debug))] -#[derive(Clone)] -pub struct Lifetime { - pub apostrophe: Apostrophe, - pub ident: Ident, -} - -impl Lifetime { - pub fn new(s: &str, span: Span) -> Self { - if !s.starts_with('\'') { - panic!( - "lifetime name must start with apostrophe as in \"'a\", got {:?}", - s - ); - } - - if s == "'" { - panic!("lifetime name must not be empty"); - } - - fn xid_ok(s: &str) -> bool { - let mut chars = s.chars(); - let first = chars.next().unwrap(); - if !(UnicodeXID::is_xid_start(first) || first == '_') { - return false; - } - for ch in chars { - if !UnicodeXID::is_xid_continue(ch) { - return false; - } - } - true - } - - if !xid_ok(&s[1..]) { - panic!("{:?} is not a valid lifetime name", s); - } - - Lifetime { - apostrophe: Apostrophe::default(), - ident: Ident::new(&s[1..], span), - } - } -} - -impl Display for Lifetime { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - "'".fmt(formatter)?; - self.ident.fmt(formatter) - } -} - -impl PartialEq for Lifetime { - fn eq(&self, other: &Lifetime) -> bool { - self.ident.eq(&other.ident) - } -} - -impl Eq for Lifetime {} - -impl PartialOrd for Lifetime { - fn partial_cmp(&self, other: &Lifetime) -> Option { - Some(self.cmp(other)) - } -} - -impl Ord for Lifetime { - fn cmp(&self, other: &Lifetime) -> Ordering { - self.ident.cmp(&other.ident) - } -} - -impl Hash for Lifetime { - fn hash(&self, h: &mut H) { - self.ident.hash(h) - } -} - -#[cfg(feature = "parsing")] -pub mod parsing { - use super::*; - use buffer::Cursor; - use parse_error; - use synom::PResult; - use synom::Synom; - - impl Synom for Lifetime { - fn parse(input: Cursor) -> PResult { - let (apostrophe, rest) = Apostrophe::parse(input)?; - let (ident, rest) = match rest.ident() { - Some(pair) => pair, - None => return parse_error(), - }; - - let ret = Lifetime { - ident: ident, - apostrophe: apostrophe, - }; - Ok((ret, rest)) - } - - fn description() -> Option<&'static str> { - Some("lifetime") - } - } -} - -#[cfg(feature = "printing")] -mod printing { - use super::*; - use proc_macro2::TokenStream; - use quote::ToTokens; - - impl ToTokens for Lifetime { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.apostrophe.to_tokens(tokens); - self.ident.to_tokens(tokens); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/lit.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/lit.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/lit.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/lit.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,1026 +0,0 @@ -// Copyright 2018 Syn Developers -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use proc_macro2::{Literal, Span}; -use std::str; - -#[cfg(feature = "printing")] -use proc_macro2::Ident; - -#[cfg(feature = "parsing")] -use proc_macro2::TokenStream; -#[cfg(feature = "parsing")] -use {ParseError, Synom}; - -use proc_macro2::TokenTree; - -#[cfg(feature = "extra-traits")] -use std::hash::{Hash, Hasher}; - -ast_enum_of_structs! { - /// A Rust literal such as a string or integer or boolean. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - /// - /// # Syntax tree enum - /// - /// This type is a [syntax tree enum]. - /// - /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums - pub enum Lit { - /// A UTF-8 string literal: `"foo"`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Str(LitStr #manual_extra_traits { - token: Literal, - }), - - /// A byte string literal: `b"foo"`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub ByteStr(LitByteStr #manual_extra_traits { - token: Literal, - }), - - /// A byte literal: `b'f'`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Byte(LitByte #manual_extra_traits { - token: Literal, - }), - - /// A character literal: `'a'`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Char(LitChar #manual_extra_traits { - token: Literal, - }), - - /// An integer literal: `1` or `1u16`. - /// - /// Holds up to 64 bits of data. Use `LitVerbatim` for any larger - /// integer literal. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Int(LitInt #manual_extra_traits { - token: Literal, - }), - - /// A floating point literal: `1f64` or `1.0e10f64`. - /// - /// Must be finite. May not be infinte or NaN. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Float(LitFloat #manual_extra_traits { - token: Literal, - }), - - /// A boolean literal: `true` or `false`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Bool(LitBool #manual_extra_traits { - pub value: bool, - pub span: Span, - }), - - /// A raw token literal not interpreted by Syn, possibly because it - /// represents an integer larger than 64 bits. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Verbatim(LitVerbatim #manual_extra_traits { - pub token: Literal, - }), - } -} - -impl LitStr { - pub fn new(value: &str, span: Span) -> Self { - let mut lit = Literal::string(value); - lit.set_span(span); - LitStr { token: lit } - } - - pub fn value(&self) -> String { - value::parse_lit_str(&self.token.to_string()) - } - - /// Parse a syntax tree node from the content of this string literal. - /// - /// All spans in the syntax tree will point to the span of this `LitStr`. - #[cfg(feature = "parsing")] - pub fn parse(&self) -> Result { - use proc_macro2::Group; - - // Parse string literal into a token stream with every span equal to the - // original literal's span. - fn spanned_tokens(s: &LitStr) -> Result { - let stream = ::parse_str(&s.value())?; - Ok(respan_token_stream(stream, s.span())) - } - - // Token stream with every span replaced by the given one. - fn respan_token_stream(stream: TokenStream, span: Span) -> TokenStream { - stream - .into_iter() - .map(|token| respan_token_tree(token, span)) - .collect() - } - - // Token tree with every span replaced by the given one. - fn respan_token_tree(mut token: TokenTree, span: Span) -> TokenTree { - match token { - TokenTree::Group(ref mut g) => { - let stream = respan_token_stream(g.stream().clone(), span); - *g = Group::new(g.delimiter(), stream); - g.set_span(span); - } - ref mut other => other.set_span(span), - } - token - } - - spanned_tokens(self).and_then(::parse2) - } - - pub fn span(&self) -> Span { - self.token.span() - } - - pub fn set_span(&mut self, span: Span) { - self.token.set_span(span) - } -} - -impl LitByteStr { - pub fn new(value: &[u8], span: Span) -> Self { - let mut token = Literal::byte_string(value); - token.set_span(span); - LitByteStr { token: token } - } - - pub fn value(&self) -> Vec { - value::parse_lit_byte_str(&self.token.to_string()) - } - - pub fn span(&self) -> Span { - self.token.span() - } - - pub fn set_span(&mut self, span: Span) { - self.token.set_span(span) - } -} - -impl LitByte { - pub fn new(value: u8, span: Span) -> Self { - let mut token = Literal::u8_suffixed(value); - token.set_span(span); - LitByte { token: token } - } - - pub fn value(&self) -> u8 { - value::parse_lit_byte(&self.token.to_string()) - } - - pub fn span(&self) -> Span { - self.token.span() - } - - pub fn set_span(&mut self, span: Span) { - self.token.set_span(span) - } -} - -impl LitChar { - pub fn new(value: char, span: Span) -> Self { - let mut token = Literal::character(value); - token.set_span(span); - LitChar { token: token } - } - - pub fn value(&self) -> char { - value::parse_lit_char(&self.token.to_string()) - } - - pub fn span(&self) -> Span { - self.token.span() - } - - pub fn set_span(&mut self, span: Span) { - self.token.set_span(span) - } -} - -impl LitInt { - pub fn new(value: u64, suffix: IntSuffix, span: Span) -> Self { - let mut token = match suffix { - IntSuffix::Isize => Literal::isize_suffixed(value as isize), - IntSuffix::I8 => Literal::i8_suffixed(value as i8), - IntSuffix::I16 => Literal::i16_suffixed(value as i16), - IntSuffix::I32 => Literal::i32_suffixed(value as i32), - IntSuffix::I64 => Literal::i64_suffixed(value as i64), - IntSuffix::I128 => value::to_literal(&format!("{}i128", value)), - IntSuffix::Usize => Literal::usize_suffixed(value as usize), - IntSuffix::U8 => Literal::u8_suffixed(value as u8), - IntSuffix::U16 => Literal::u16_suffixed(value as u16), - IntSuffix::U32 => Literal::u32_suffixed(value as u32), - IntSuffix::U64 => Literal::u64_suffixed(value), - IntSuffix::U128 => value::to_literal(&format!("{}u128", value)), - IntSuffix::None => Literal::u64_unsuffixed(value), - }; - token.set_span(span); - LitInt { token: token } - } - - pub fn value(&self) -> u64 { - value::parse_lit_int(&self.token.to_string()).unwrap() - } - - pub fn suffix(&self) -> IntSuffix { - let value = self.token.to_string(); - for (s, suffix) in vec![ - ("i8", IntSuffix::I8), - ("i16", IntSuffix::I16), - ("i32", IntSuffix::I32), - ("i64", IntSuffix::I64), - ("i128", IntSuffix::I128), - ("isize", IntSuffix::Isize), - ("u8", IntSuffix::U8), - ("u16", IntSuffix::U16), - ("u32", IntSuffix::U32), - ("u64", IntSuffix::U64), - ("u128", IntSuffix::U128), - ("usize", IntSuffix::Usize), - ] { - if value.ends_with(s) { - return suffix; - } - } - IntSuffix::None - } - - pub fn span(&self) -> Span { - self.token.span() - } - - pub fn set_span(&mut self, span: Span) { - self.token.set_span(span) - } -} - -impl LitFloat { - pub fn new(value: f64, suffix: FloatSuffix, span: Span) -> Self { - let mut token = match suffix { - FloatSuffix::F32 => Literal::f32_suffixed(value as f32), - FloatSuffix::F64 => Literal::f64_suffixed(value), - FloatSuffix::None => Literal::f64_unsuffixed(value), - }; - token.set_span(span); - LitFloat { token: token } - } - - pub fn value(&self) -> f64 { - value::parse_lit_float(&self.token.to_string()) - } - - pub fn suffix(&self) -> FloatSuffix { - let value = self.token.to_string(); - for (s, suffix) in vec![("f32", FloatSuffix::F32), ("f64", FloatSuffix::F64)] { - if value.ends_with(s) { - return suffix; - } - } - FloatSuffix::None - } - - pub fn span(&self) -> Span { - self.token.span() - } - - pub fn set_span(&mut self, span: Span) { - self.token.set_span(span) - } -} - -macro_rules! lit_extra_traits { - ($ty:ident, $field:ident) => { - #[cfg(feature = "extra-traits")] - impl Eq for $ty {} - - #[cfg(feature = "extra-traits")] - impl PartialEq for $ty { - fn eq(&self, other: &Self) -> bool { - self.$field.to_string() == other.$field.to_string() - } - } - - #[cfg(feature = "extra-traits")] - impl Hash for $ty { - fn hash(&self, state: &mut H) - where - H: Hasher, - { - self.$field.to_string().hash(state); - } - } - }; -} - -impl LitVerbatim { - pub fn span(&self) -> Span { - self.token.span() - } - - pub fn set_span(&mut self, span: Span) { - self.token.set_span(span) - } -} - -lit_extra_traits!(LitStr, token); -lit_extra_traits!(LitByteStr, token); -lit_extra_traits!(LitByte, token); -lit_extra_traits!(LitChar, token); -lit_extra_traits!(LitInt, token); -lit_extra_traits!(LitFloat, token); -lit_extra_traits!(LitBool, value); -lit_extra_traits!(LitVerbatim, token); - -ast_enum! { - /// The style of a string literal, either plain quoted or a raw string like - /// `r##"data"##`. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - pub enum StrStyle #no_visit { - /// An ordinary string like `"data"`. - Cooked, - /// A raw string like `r##"data"##`. - /// - /// The unsigned integer is the number of `#` symbols used. - Raw(usize), - } -} - -ast_enum! { - /// The suffix on an integer literal if any, like the `u8` in `127u8`. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - pub enum IntSuffix #no_visit { - I8, - I16, - I32, - I64, - I128, - Isize, - U8, - U16, - U32, - U64, - U128, - Usize, - None, - } -} - -ast_enum! { - /// The suffix on a floating point literal if any, like the `f32` in - /// `1.0f32`. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - pub enum FloatSuffix #no_visit { - F32, - F64, - None, - } -} - -#[cfg(feature = "parsing")] -pub mod parsing { - use super::*; - use buffer::Cursor; - use parse_error; - use synom::PResult; - use synom::Synom; - - impl Synom for Lit { - fn parse(input: Cursor) -> PResult { - match input.literal() { - Some((lit, rest)) => { - if lit.to_string().starts_with('/') { - // Doc comment literal which is not a Syn literal - parse_error() - } else { - Ok((Lit::new(lit), rest)) - } - } - _ => match input.ident() { - Some((ident, rest)) => Ok(( - Lit::Bool(LitBool { - value: if ident == "true" { - true - } else if ident == "false" { - false - } else { - return parse_error(); - }, - span: ident.span(), - }), - rest, - )), - _ => parse_error(), - }, - } - } - - fn description() -> Option<&'static str> { - Some("literal") - } - } - - impl_synom!(LitStr "string literal" switch!( - syn!(Lit), - Lit::Str(lit) => value!(lit) - | - _ => reject!() - )); - - impl_synom!(LitByteStr "byte string literal" switch!( - syn!(Lit), - Lit::ByteStr(lit) => value!(lit) - | - _ => reject!() - )); - - impl_synom!(LitByte "byte literal" switch!( - syn!(Lit), - Lit::Byte(lit) => value!(lit) - | - _ => reject!() - )); - - impl_synom!(LitChar "character literal" switch!( - syn!(Lit), - Lit::Char(lit) => value!(lit) - | - _ => reject!() - )); - - impl_synom!(LitInt "integer literal" switch!( - syn!(Lit), - Lit::Int(lit) => value!(lit) - | - _ => reject!() - )); - - impl_synom!(LitFloat "floating point literal" switch!( - syn!(Lit), - Lit::Float(lit) => value!(lit) - | - _ => reject!() - )); - - impl_synom!(LitBool "boolean literal" switch!( - syn!(Lit), - Lit::Bool(lit) => value!(lit) - | - _ => reject!() - )); -} - -#[cfg(feature = "printing")] -mod printing { - use super::*; - use proc_macro2::TokenStream; - use quote::{ToTokens, TokenStreamExt}; - - impl ToTokens for LitStr { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.token.to_tokens(tokens); - } - } - - impl ToTokens for LitByteStr { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.token.to_tokens(tokens); - } - } - - impl ToTokens for LitByte { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.token.to_tokens(tokens); - } - } - - impl ToTokens for LitChar { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.token.to_tokens(tokens); - } - } - - impl ToTokens for LitInt { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.token.to_tokens(tokens); - } - } - - impl ToTokens for LitFloat { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.token.to_tokens(tokens); - } - } - - impl ToTokens for LitBool { - fn to_tokens(&self, tokens: &mut TokenStream) { - let s = if self.value { "true" } else { "false" }; - tokens.append(Ident::new(s, self.span)); - } - } - - impl ToTokens for LitVerbatim { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.token.to_tokens(tokens); - } - } -} - -mod value { - use super::*; - use proc_macro2::TokenStream; - use std::char; - use std::ops::{Index, RangeFrom}; - - impl Lit { - /// Interpret a Syn literal from a proc-macro2 literal. - /// - /// Not all proc-macro2 literals are valid Syn literals. In particular, - /// doc comments are considered by proc-macro2 to be literals but in Syn - /// they are [`Attribute`]. - /// - /// [`Attribute`]: struct.Attribute.html - /// - /// # Panics - /// - /// Panics if the input is a doc comment literal. - pub fn new(token: Literal) -> Self { - let value = token.to_string(); - - match value::byte(&value, 0) { - b'"' | b'r' => return Lit::Str(LitStr { token: token }), - b'b' => match value::byte(&value, 1) { - b'"' | b'r' => return Lit::ByteStr(LitByteStr { token: token }), - b'\'' => return Lit::Byte(LitByte { token: token }), - _ => {} - }, - b'\'' => return Lit::Char(LitChar { token: token }), - b'0'...b'9' => if number_is_int(&value) { - return Lit::Int(LitInt { token: token }); - } else if number_is_float(&value) { - return Lit::Float(LitFloat { token: token }); - } else { - // number overflow - return Lit::Verbatim(LitVerbatim { token: token }); - }, - _ => if value == "true" || value == "false" { - return Lit::Bool(LitBool { - value: value == "true", - span: token.span(), - }); - }, - } - - panic!("Unrecognized literal: {}", value); - } - } - - fn number_is_int(value: &str) -> bool { - if number_is_float(value) { - false - } else { - value::parse_lit_int(value).is_some() - } - } - - fn number_is_float(value: &str) -> bool { - if value.contains('.') { - true - } else if value.starts_with("0x") || value.ends_with("size") { - false - } else { - value.contains('e') || value.contains('E') - } - } - - /// Get the byte at offset idx, or a default of `b'\0'` if we're looking - /// past the end of the input buffer. - pub fn byte + ?Sized>(s: &S, idx: usize) -> u8 { - let s = s.as_ref(); - if idx < s.len() { - s[idx] - } else { - 0 - } - } - - fn next_chr(s: &str) -> char { - s.chars().next().unwrap_or('\0') - } - - pub fn parse_lit_str(s: &str) -> String { - match byte(s, 0) { - b'"' => parse_lit_str_cooked(s), - b'r' => parse_lit_str_raw(s), - _ => unreachable!(), - } - } - - // Clippy false positive - // https://github.com/rust-lang-nursery/rust-clippy/issues/2329 - #[cfg_attr(feature = "cargo-clippy", allow(needless_continue))] - fn parse_lit_str_cooked(mut s: &str) -> String { - assert_eq!(byte(s, 0), b'"'); - s = &s[1..]; - - let mut out = String::new(); - 'outer: loop { - let ch = match byte(s, 0) { - b'"' => break, - b'\\' => { - let b = byte(s, 1); - s = &s[2..]; - match b { - b'x' => { - let (byte, rest) = backslash_x(s); - s = rest; - assert!(byte <= 0x80, "Invalid \\x byte in string literal"); - char::from_u32(u32::from(byte)).unwrap() - } - b'u' => { - let (chr, rest) = backslash_u(s); - s = rest; - chr - } - b'n' => '\n', - b'r' => '\r', - b't' => '\t', - b'\\' => '\\', - b'0' => '\0', - b'\'' => '\'', - b'"' => '"', - b'\r' | b'\n' => loop { - let ch = next_chr(s); - if ch.is_whitespace() { - s = &s[ch.len_utf8()..]; - } else { - continue 'outer; - } - }, - b => panic!("unexpected byte {:?} after \\ character in byte literal", b), - } - } - b'\r' => { - assert_eq!(byte(s, 1), b'\n', "Bare CR not allowed in string"); - s = &s[2..]; - '\n' - } - _ => { - let ch = next_chr(s); - s = &s[ch.len_utf8()..]; - ch - } - }; - out.push(ch); - } - - assert_eq!(s, "\""); - out - } - - fn parse_lit_str_raw(mut s: &str) -> String { - assert_eq!(byte(s, 0), b'r'); - s = &s[1..]; - - let mut pounds = 0; - while byte(s, pounds) == b'#' { - pounds += 1; - } - assert_eq!(byte(s, pounds), b'"'); - assert_eq!(byte(s, s.len() - pounds - 1), b'"'); - for end in s[s.len() - pounds..].bytes() { - assert_eq!(end, b'#'); - } - - s[pounds + 1..s.len() - pounds - 1].to_owned() - } - - pub fn parse_lit_byte_str(s: &str) -> Vec { - assert_eq!(byte(s, 0), b'b'); - match byte(s, 1) { - b'"' => parse_lit_byte_str_cooked(s), - b'r' => parse_lit_byte_str_raw(s), - _ => unreachable!(), - } - } - - // Clippy false positive - // https://github.com/rust-lang-nursery/rust-clippy/issues/2329 - #[cfg_attr(feature = "cargo-clippy", allow(needless_continue))] - fn parse_lit_byte_str_cooked(mut s: &str) -> Vec { - assert_eq!(byte(s, 0), b'b'); - assert_eq!(byte(s, 1), b'"'); - s = &s[2..]; - - // We're going to want to have slices which don't respect codepoint boundaries. - let mut s = s.as_bytes(); - - let mut out = Vec::new(); - 'outer: loop { - let byte = match byte(s, 0) { - b'"' => break, - b'\\' => { - let b = byte(s, 1); - s = &s[2..]; - match b { - b'x' => { - let (b, rest) = backslash_x(s); - s = rest; - b - } - b'n' => b'\n', - b'r' => b'\r', - b't' => b'\t', - b'\\' => b'\\', - b'0' => b'\0', - b'\'' => b'\'', - b'"' => b'"', - b'\r' | b'\n' => loop { - let byte = byte(s, 0); - let ch = char::from_u32(u32::from(byte)).unwrap(); - if ch.is_whitespace() { - s = &s[1..]; - } else { - continue 'outer; - } - }, - b => panic!("unexpected byte {:?} after \\ character in byte literal", b), - } - } - b'\r' => { - assert_eq!(byte(s, 1), b'\n', "Bare CR not allowed in string"); - s = &s[2..]; - b'\n' - } - b => { - s = &s[1..]; - b - } - }; - out.push(byte); - } - - assert_eq!(s, b"\""); - out - } - - fn parse_lit_byte_str_raw(s: &str) -> Vec { - assert_eq!(byte(s, 0), b'b'); - parse_lit_str_raw(&s[1..]).into_bytes() - } - - pub fn parse_lit_byte(s: &str) -> u8 { - assert_eq!(byte(s, 0), b'b'); - assert_eq!(byte(s, 1), b'\''); - - // We're going to want to have slices which don't respect codepoint boundaries. - let mut s = s[2..].as_bytes(); - - let b = match byte(s, 0) { - b'\\' => { - let b = byte(s, 1); - s = &s[2..]; - match b { - b'x' => { - let (b, rest) = backslash_x(s); - s = rest; - b - } - b'n' => b'\n', - b'r' => b'\r', - b't' => b'\t', - b'\\' => b'\\', - b'0' => b'\0', - b'\'' => b'\'', - b'"' => b'"', - b => panic!("unexpected byte {:?} after \\ character in byte literal", b), - } - } - b => { - s = &s[1..]; - b - } - }; - - assert_eq!(byte(s, 0), b'\''); - b - } - - pub fn parse_lit_char(mut s: &str) -> char { - assert_eq!(byte(s, 0), b'\''); - s = &s[1..]; - - let ch = match byte(s, 0) { - b'\\' => { - let b = byte(s, 1); - s = &s[2..]; - match b { - b'x' => { - let (byte, rest) = backslash_x(s); - s = rest; - assert!(byte <= 0x80, "Invalid \\x byte in string literal"); - char::from_u32(u32::from(byte)).unwrap() - } - b'u' => { - let (chr, rest) = backslash_u(s); - s = rest; - chr - } - b'n' => '\n', - b'r' => '\r', - b't' => '\t', - b'\\' => '\\', - b'0' => '\0', - b'\'' => '\'', - b'"' => '"', - b => panic!("unexpected byte {:?} after \\ character in byte literal", b), - } - } - _ => { - let ch = next_chr(s); - s = &s[ch.len_utf8()..]; - ch - } - }; - assert_eq!(s, "\'", "Expected end of char literal"); - ch - } - - fn backslash_x(s: &S) -> (u8, &S) - where - S: Index, Output = S> + AsRef<[u8]> + ?Sized, - { - let mut ch = 0; - let b0 = byte(s, 0); - let b1 = byte(s, 1); - ch += 0x10 * match b0 { - b'0'...b'9' => b0 - b'0', - b'a'...b'f' => 10 + (b0 - b'a'), - b'A'...b'F' => 10 + (b0 - b'A'), - _ => panic!("unexpected non-hex character after \\x"), - }; - ch += match b1 { - b'0'...b'9' => b1 - b'0', - b'a'...b'f' => 10 + (b1 - b'a'), - b'A'...b'F' => 10 + (b1 - b'A'), - _ => panic!("unexpected non-hex character after \\x"), - }; - (ch, &s[2..]) - } - - fn backslash_u(mut s: &str) -> (char, &str) { - if byte(s, 0) != b'{' { - panic!("expected {{ after \\u"); - } - s = &s[1..]; - - let mut ch = 0; - for _ in 0..6 { - let b = byte(s, 0); - match b { - b'0'...b'9' => { - ch *= 0x10; - ch += u32::from(b - b'0'); - s = &s[1..]; - } - b'a'...b'f' => { - ch *= 0x10; - ch += u32::from(10 + b - b'a'); - s = &s[1..]; - } - b'A'...b'F' => { - ch *= 0x10; - ch += u32::from(10 + b - b'A'); - s = &s[1..]; - } - b'}' => break, - _ => panic!("unexpected non-hex character after \\u"), - } - } - assert!(byte(s, 0) == b'}'); - s = &s[1..]; - - if let Some(ch) = char::from_u32(ch) { - (ch, s) - } else { - panic!("character code {:x} is not a valid unicode character", ch); - } - } - - pub fn parse_lit_int(mut s: &str) -> Option { - let base = match (byte(s, 0), byte(s, 1)) { - (b'0', b'x') => { - s = &s[2..]; - 16 - } - (b'0', b'o') => { - s = &s[2..]; - 8 - } - (b'0', b'b') => { - s = &s[2..]; - 2 - } - (b'0'...b'9', _) => 10, - _ => unreachable!(), - }; - - let mut value = 0u64; - loop { - let b = byte(s, 0); - let digit = match b { - b'0'...b'9' => u64::from(b - b'0'), - b'a'...b'f' if base > 10 => 10 + u64::from(b - b'a'), - b'A'...b'F' if base > 10 => 10 + u64::from(b - b'A'), - b'_' => { - s = &s[1..]; - continue; - } - // NOTE: Looking at a floating point literal, we don't want to - // consider these integers. - b'.' if base == 10 => return None, - b'e' | b'E' if base == 10 => return None, - _ => break, - }; - - if digit >= base { - panic!("Unexpected digit {:x} out of base range", digit); - } - - value = match value.checked_mul(base) { - Some(value) => value, - None => return None, - }; - value = match value.checked_add(digit) { - Some(value) => value, - None => return None, - }; - s = &s[1..]; - } - - Some(value) - } - - pub fn parse_lit_float(input: &str) -> f64 { - // Rust's floating point literals are very similar to the ones parsed by - // the standard library, except that rust's literals can contain - // ignorable underscores. Let's remove those underscores. - let mut bytes = input.to_owned().into_bytes(); - let mut write = 0; - for read in 0..bytes.len() { - if bytes[read] == b'_' { - continue; // Don't increase write - } - if write != read { - let x = bytes[read]; - bytes[write] = x; - } - write += 1; - } - bytes.truncate(write); - let input = String::from_utf8(bytes).unwrap(); - let end = input.find('f').unwrap_or_else(|| input.len()); - input[..end].parse().unwrap() - } - - pub fn to_literal(s: &str) -> Literal { - let stream = s.parse::().unwrap(); - match stream.into_iter().next().unwrap() { - TokenTree::Literal(l) => l, - _ => unreachable!(), - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/macros.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/macros.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/macros.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/macros.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,196 +0,0 @@ -// Copyright 2018 Syn Developers -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[cfg(any(feature = "full", feature = "derive"))] -macro_rules! ast_struct { - ( - $(#[$attr:meta])* - pub struct $name:ident #full $($rest:tt)* - ) => { - #[cfg(feature = "full")] - $(#[$attr])* - #[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))] - #[cfg_attr(feature = "clone-impls", derive(Clone))] - pub struct $name $($rest)* - - #[cfg(not(feature = "full"))] - $(#[$attr])* - #[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))] - #[cfg_attr(feature = "clone-impls", derive(Clone))] - pub struct $name { - _noconstruct: (), - } - }; - - ( - $(#[$attr:meta])* - pub struct $name:ident #manual_extra_traits $($rest:tt)* - ) => { - $(#[$attr])* - #[cfg_attr(feature = "extra-traits", derive(Debug))] - #[cfg_attr(feature = "clone-impls", derive(Clone))] - pub struct $name $($rest)* - }; - - ( - $(#[$attr:meta])* - pub struct $name:ident $($rest:tt)* - ) => { - $(#[$attr])* - #[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))] - #[cfg_attr(feature = "clone-impls", derive(Clone))] - pub struct $name $($rest)* - }; -} - -#[cfg(any(feature = "full", feature = "derive"))] -macro_rules! ast_enum { - ( - $(#[$enum_attr:meta])* - pub enum $name:ident $(# $tags:ident)* { $($variants:tt)* } - ) => ( - $(#[$enum_attr])* - #[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))] - #[cfg_attr(feature = "clone-impls", derive(Clone))] - pub enum $name { - $($variants)* - } - ) -} - -#[cfg(any(feature = "full", feature = "derive"))] -macro_rules! ast_enum_of_structs { - ( - $(#[$enum_attr:meta])* - pub enum $name:ident { - $( - $(#[$variant_attr:meta])* - pub $variant:ident $( ($member:ident $($rest:tt)*) )*, - )* - } - - $($remaining:tt)* - ) => ( - ast_enum! { - $(#[$enum_attr])* - pub enum $name { - $( - $(#[$variant_attr])* - $variant $( ($member) )*, - )* - } - } - - $( - maybe_ast_struct! { - $(#[$variant_attr])* - $( - pub struct $member $($rest)* - )* - } - - $( - impl From<$member> for $name { - fn from(e: $member) -> $name { - $name::$variant(e) - } - } - )* - )* - - #[cfg(feature = "printing")] - generate_to_tokens! { - $($remaining)* - () - tokens - $name { $($variant $( [$($rest)*] )*,)* } - } - ) -} - -#[cfg(all( - feature = "printing", - any(feature = "full", feature = "derive") -))] -macro_rules! generate_to_tokens { - (do_not_generate_to_tokens $($foo:tt)*) => (); - - (($($arms:tt)*) $tokens:ident $name:ident { $variant:ident, $($next:tt)*}) => { - generate_to_tokens!( - ($($arms)* $name::$variant => {}) - $tokens $name { $($next)* } - ); - }; - - (($($arms:tt)*) $tokens:ident $name:ident { $variant:ident [$($rest:tt)*], $($next:tt)*}) => { - generate_to_tokens!( - ($($arms)* $name::$variant(ref _e) => to_tokens_call!(_e, $tokens, $($rest)*),) - $tokens $name { $($next)* } - ); - }; - - (($($arms:tt)*) $tokens:ident $name:ident {}) => { - impl ::quote::ToTokens for $name { - fn to_tokens(&self, $tokens: &mut ::proc_macro2::TokenStream) { - match *self { - $($arms)* - } - } - } - }; -} - -#[cfg(all(feature = "printing", feature = "full"))] -macro_rules! to_tokens_call { - ($e:ident, $tokens:ident, $($rest:tt)*) => { - $e.to_tokens($tokens) - }; -} - -#[cfg(all( - feature = "printing", - feature = "derive", - not(feature = "full") -))] -macro_rules! to_tokens_call { - // If the variant is marked as #full, don't auto-generate to-tokens for it. - ($e:ident, $tokens:ident, #full $($rest:tt)*) => { - unreachable!() - }; - ($e:ident, $tokens:ident, $($rest:tt)*) => { - $e.to_tokens($tokens) - }; -} - -#[cfg(any(feature = "full", feature = "derive"))] -macro_rules! maybe_ast_struct { - ( - $(#[$attr:meta])* - $( - pub struct $name:ident - )* - ) => (); - - ($($rest:tt)*) => (ast_struct! { $($rest)* }); -} - -#[cfg(all( - feature = "parsing", - any(feature = "full", feature = "derive") -))] -macro_rules! impl_synom { - ($t:ident $description:tt $($parser:tt)+) => { - impl Synom for $t { - named!(parse -> Self, $($parser)+); - - fn description() -> Option<&'static str> { - Some($description) - } - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/mac.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/mac.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/mac.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/mac.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,117 +0,0 @@ -// Copyright 2018 Syn Developers -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use super::*; -use proc_macro2::TokenStream; -use token::{Brace, Bracket, Paren}; - -#[cfg(feature = "extra-traits")] -use std::hash::{Hash, Hasher}; -#[cfg(feature = "extra-traits")] -use tt::TokenStreamHelper; - -ast_struct! { - /// A macro invocation: `println!("{}", mac)`. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - pub struct Macro #manual_extra_traits { - pub path: Path, - pub bang_token: Token![!], - pub delimiter: MacroDelimiter, - pub tts: TokenStream, - } -} - -ast_enum! { - /// A grouping token that surrounds a macro body: `m!(...)` or `m!{...}` or `m![...]`. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - pub enum MacroDelimiter { - Paren(Paren), - Brace(Brace), - Bracket(Bracket), - } -} - -#[cfg(feature = "extra-traits")] -impl Eq for Macro {} - -#[cfg(feature = "extra-traits")] -impl PartialEq for Macro { - fn eq(&self, other: &Self) -> bool { - self.path == other.path - && self.bang_token == other.bang_token - && self.delimiter == other.delimiter - && TokenStreamHelper(&self.tts) == TokenStreamHelper(&other.tts) - } -} - -#[cfg(feature = "extra-traits")] -impl Hash for Macro { - fn hash(&self, state: &mut H) - where - H: Hasher, - { - self.path.hash(state); - self.bang_token.hash(state); - self.delimiter.hash(state); - TokenStreamHelper(&self.tts).hash(state); - } -} - -#[cfg(feature = "parsing")] -pub mod parsing { - use super::*; - - use synom::Synom; - - impl Synom for Macro { - named!(parse -> Self, do_parse!( - what: call!(Path::parse_mod_style) >> - bang: punct!(!) >> - body: call!(tt::delimited) >> - (Macro { - path: what, - bang_token: bang, - delimiter: body.0, - tts: body.1, - }) - )); - - fn description() -> Option<&'static str> { - Some("macro invocation") - } - } -} - -#[cfg(feature = "printing")] -mod printing { - use super::*; - use proc_macro2::TokenStream; - use quote::ToTokens; - - impl ToTokens for Macro { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.path.to_tokens(tokens); - self.bang_token.to_tokens(tokens); - match self.delimiter { - MacroDelimiter::Paren(ref paren) => { - paren.surround(tokens, |tokens| self.tts.to_tokens(tokens)); - } - MacroDelimiter::Brace(ref brace) => { - brace.surround(tokens, |tokens| self.tts.to_tokens(tokens)); - } - MacroDelimiter::Bracket(ref bracket) => { - bracket.surround(tokens, |tokens| self.tts.to_tokens(tokens)); - } - } - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/op.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/op.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/op.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/op.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,224 +0,0 @@ -// Copyright 2018 Syn Developers -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -ast_enum! { - /// A binary operator: `+`, `+=`, `&`. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - #[cfg_attr(feature = "clone-impls", derive(Copy))] - pub enum BinOp { - /// The `+` operator (addition) - Add(Token![+]), - /// The `-` operator (subtraction) - Sub(Token![-]), - /// The `*` operator (multiplication) - Mul(Token![*]), - /// The `/` operator (division) - Div(Token![/]), - /// The `%` operator (modulus) - Rem(Token![%]), - /// The `&&` operator (logical and) - And(Token![&&]), - /// The `||` operator (logical or) - Or(Token![||]), - /// The `^` operator (bitwise xor) - BitXor(Token![^]), - /// The `&` operator (bitwise and) - BitAnd(Token![&]), - /// The `|` operator (bitwise or) - BitOr(Token![|]), - /// The `<<` operator (shift left) - Shl(Token![<<]), - /// The `>>` operator (shift right) - Shr(Token![>>]), - /// The `==` operator (equality) - Eq(Token![==]), - /// The `<` operator (less than) - Lt(Token![<]), - /// The `<=` operator (less than or equal to) - Le(Token![<=]), - /// The `!=` operator (not equal to) - Ne(Token![!=]), - /// The `>=` operator (greater than or equal to) - Ge(Token![>=]), - /// The `>` operator (greater than) - Gt(Token![>]), - /// The `+=` operator - AddEq(Token![+=]), - /// The `-=` operator - SubEq(Token![-=]), - /// The `*=` operator - MulEq(Token![*=]), - /// The `/=` operator - DivEq(Token![/=]), - /// The `%=` operator - RemEq(Token![%=]), - /// The `^=` operator - BitXorEq(Token![^=]), - /// The `&=` operator - BitAndEq(Token![&=]), - /// The `|=` operator - BitOrEq(Token![|=]), - /// The `<<=` operator - ShlEq(Token![<<=]), - /// The `>>=` operator - ShrEq(Token![>>=]), - } -} - -ast_enum! { - /// A unary operator: `*`, `!`, `-`. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - #[cfg_attr(feature = "clone-impls", derive(Copy))] - pub enum UnOp { - /// The `*` operator for dereferencing - Deref(Token![*]), - /// The `!` operator for logical inversion - Not(Token![!]), - /// The `-` operator for negation - Neg(Token![-]), - } -} - -#[cfg(feature = "parsing")] -pub mod parsing { - use super::*; - use synom::Synom; - - impl BinOp { - named!(pub parse_binop -> Self, alt!( - punct!(&&) => { BinOp::And } - | - punct!(||) => { BinOp::Or } - | - punct!(<<) => { BinOp::Shl } - | - punct!(>>) => { BinOp::Shr } - | - punct!(==) => { BinOp::Eq } - | - punct!(<=) => { BinOp::Le } - | - punct!(!=) => { BinOp::Ne } - | - punct!(>=) => { BinOp::Ge } - | - punct!(+) => { BinOp::Add } - | - punct!(-) => { BinOp::Sub } - | - punct!(*) => { BinOp::Mul } - | - punct!(/) => { BinOp::Div } - | - punct!(%) => { BinOp::Rem } - | - punct!(^) => { BinOp::BitXor } - | - punct!(&) => { BinOp::BitAnd } - | - punct!(|) => { BinOp::BitOr } - | - punct!(<) => { BinOp::Lt } - | - punct!(>) => { BinOp::Gt } - )); - - #[cfg(feature = "full")] - named!(pub parse_assign_op -> Self, alt!( - punct!(+=) => { BinOp::AddEq } - | - punct!(-=) => { BinOp::SubEq } - | - punct!(*=) => { BinOp::MulEq } - | - punct!(/=) => { BinOp::DivEq } - | - punct!(%=) => { BinOp::RemEq } - | - punct!(^=) => { BinOp::BitXorEq } - | - punct!(&=) => { BinOp::BitAndEq } - | - punct!(|=) => { BinOp::BitOrEq } - | - punct!(<<=) => { BinOp::ShlEq } - | - punct!(>>=) => { BinOp::ShrEq } - )); - } - - impl Synom for UnOp { - named!(parse -> Self, alt!( - punct!(*) => { UnOp::Deref } - | - punct!(!) => { UnOp::Not } - | - punct!(-) => { UnOp::Neg } - )); - - fn description() -> Option<&'static str> { - Some("unary operator: `*`, `!`, or `-`") - } - } -} - -#[cfg(feature = "printing")] -mod printing { - use super::*; - use proc_macro2::TokenStream; - use quote::ToTokens; - - impl ToTokens for BinOp { - fn to_tokens(&self, tokens: &mut TokenStream) { - match *self { - BinOp::Add(ref t) => t.to_tokens(tokens), - BinOp::Sub(ref t) => t.to_tokens(tokens), - BinOp::Mul(ref t) => t.to_tokens(tokens), - BinOp::Div(ref t) => t.to_tokens(tokens), - BinOp::Rem(ref t) => t.to_tokens(tokens), - BinOp::And(ref t) => t.to_tokens(tokens), - BinOp::Or(ref t) => t.to_tokens(tokens), - BinOp::BitXor(ref t) => t.to_tokens(tokens), - BinOp::BitAnd(ref t) => t.to_tokens(tokens), - BinOp::BitOr(ref t) => t.to_tokens(tokens), - BinOp::Shl(ref t) => t.to_tokens(tokens), - BinOp::Shr(ref t) => t.to_tokens(tokens), - BinOp::Eq(ref t) => t.to_tokens(tokens), - BinOp::Lt(ref t) => t.to_tokens(tokens), - BinOp::Le(ref t) => t.to_tokens(tokens), - BinOp::Ne(ref t) => t.to_tokens(tokens), - BinOp::Ge(ref t) => t.to_tokens(tokens), - BinOp::Gt(ref t) => t.to_tokens(tokens), - BinOp::AddEq(ref t) => t.to_tokens(tokens), - BinOp::SubEq(ref t) => t.to_tokens(tokens), - BinOp::MulEq(ref t) => t.to_tokens(tokens), - BinOp::DivEq(ref t) => t.to_tokens(tokens), - BinOp::RemEq(ref t) => t.to_tokens(tokens), - BinOp::BitXorEq(ref t) => t.to_tokens(tokens), - BinOp::BitAndEq(ref t) => t.to_tokens(tokens), - BinOp::BitOrEq(ref t) => t.to_tokens(tokens), - BinOp::ShlEq(ref t) => t.to_tokens(tokens), - BinOp::ShrEq(ref t) => t.to_tokens(tokens), - } - } - } - - impl ToTokens for UnOp { - fn to_tokens(&self, tokens: &mut TokenStream) { - match *self { - UnOp::Deref(ref t) => t.to_tokens(tokens), - UnOp::Not(ref t) => t.to_tokens(tokens), - UnOp::Neg(ref t) => t.to_tokens(tokens), - } - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/parse_quote.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/parse_quote.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/parse_quote.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/parse_quote.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,163 +0,0 @@ -/// Quasi-quotation macro that accepts input like the [`quote!`] macro but uses -/// type inference to figure out a return type for those tokens. -/// -/// [`quote!`]: https://docs.rs/quote/0.4/quote/index.html -/// -/// The return type can be any syntax tree node that implements the [`Synom`] -/// trait. -/// -/// [`Synom`]: synom/trait.Synom.html -/// -/// ``` -/// #[macro_use] -/// extern crate syn; -/// -/// #[macro_use] -/// extern crate quote; -/// -/// use syn::Stmt; -/// -/// fn main() { -/// let name = quote!(v); -/// let ty = quote!(u8); -/// -/// let stmt: Stmt = parse_quote! { -/// let #name: #ty = Default::default(); -/// }; -/// -/// println!("{:#?}", stmt); -/// } -/// ``` -/// -/// *This macro is available if Syn is built with the `"parsing"` feature, -/// although interpolation of syntax tree nodes into the quoted tokens is only -/// supported if Syn is built with the `"printing"` feature as well.* -/// -/// # Example -/// -/// The following helper function adds a bound `T: HeapSize` to every type -/// parameter `T` in the input generics. -/// -/// ``` -/// # #[macro_use] -/// # extern crate syn; -/// # -/// # #[macro_use] -/// # extern crate quote; -/// # -/// # use syn::{Generics, GenericParam}; -/// # -/// // Add a bound `T: HeapSize` to every type parameter T. -/// fn add_trait_bounds(mut generics: Generics) -> Generics { -/// for param in &mut generics.params { -/// if let GenericParam::Type(ref mut type_param) = *param { -/// type_param.bounds.push(parse_quote!(HeapSize)); -/// } -/// } -/// generics -/// } -/// # -/// # fn main() {} -/// ``` -/// -/// # Special cases -/// -/// This macro can parse the following additional types as a special case even -/// though they do not implement the `Synom` trait. -/// -/// - [`Attribute`] — parses one attribute, allowing either outer like `#[...]` -/// or inner like `#![...]` -/// - [`Punctuated`] — parses zero or more `T` separated by punctuation -/// `P` with optional trailing punctuation -/// -/// [`Attribute`]: struct.Attribute.html -/// [`Punctuated`]: punctuated/struct.Punctuated.html -/// -/// # Panics -/// -/// Panics if the tokens fail to parse as the expected syntax tree type. The -/// caller is responsible for ensuring that the input tokens are syntactically -/// valid. -#[macro_export] -macro_rules! parse_quote { - ($($tt:tt)*) => { - $crate::parse_quote::parse($crate::parse_quote::From::from(quote!($($tt)*))) - }; -} - -//////////////////////////////////////////////////////////////////////////////// -// Can parse any type that implements Synom. - -use buffer::Cursor; -use proc_macro2::TokenStream; -use synom::{PResult, Parser, Synom}; - -// Not public API. -#[doc(hidden)] -pub use std::convert::From; - -// Not public API. -#[doc(hidden)] -pub fn parse(token_stream: TokenStream) -> T { - let parser = T::parse; - match parser.parse2(token_stream) { - Ok(t) => t, - Err(err) => match T::description() { - Some(s) => panic!("failed to parse {}: {}", s, err), - None => panic!("{}", err), - }, - } -} - -// Not public API. -#[doc(hidden)] -pub trait ParseQuote: Sized { - fn parse(input: Cursor) -> PResult; - fn description() -> Option<&'static str>; -} - -impl ParseQuote for T -where - T: Synom, -{ - fn parse(input: Cursor) -> PResult { - ::parse(input) - } - - fn description() -> Option<&'static str> { - ::description() - } -} - -//////////////////////////////////////////////////////////////////////////////// -// Any other types that we want `parse_quote!` to be able to parse. - -use punctuated::Punctuated; - -#[cfg(any(feature = "full", feature = "derive"))] -use Attribute; - -impl ParseQuote for Punctuated -where - T: Synom, - P: Synom, -{ - named!(parse -> Self, call!(Punctuated::parse_terminated)); - - fn description() -> Option<&'static str> { - Some("punctuated sequence") - } -} - -#[cfg(any(feature = "full", feature = "derive"))] -impl ParseQuote for Attribute { - named!(parse -> Self, alt!( - call!(Attribute::parse_outer) - | - call!(Attribute::parse_inner) - )); - - fn description() -> Option<&'static str> { - Some("attribute") - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/parsers.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/parsers.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/parsers.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/parsers.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,1428 +0,0 @@ -// Copyright 2018 Syn Developers -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use buffer::Cursor; -use parse_error; -use synom::PResult; - -/// Define a parser function with the signature expected by syn parser -/// combinators. -/// -/// The function may be the `parse` function of the [`Synom`] trait, or it may -/// be a free-standing function with an arbitrary name. When implementing the -/// `Synom` trait, the function name is `parse` and the return type is `Self`. -/// -/// [`Synom`]: synom/trait.Synom.html -/// -/// - **Syntax:** `named!(NAME -> TYPE, PARSER)` or `named!(pub NAME -> TYPE, PARSER)` -/// -/// ```rust -/// #[macro_use] -/// extern crate syn; -/// -/// use syn::Type; -/// use syn::punctuated::Punctuated; -/// use syn::synom::Synom; -/// -/// /// Parses one or more Rust types separated by commas. -/// /// -/// /// Example: `String, Vec, [u8; LEN + 1]` -/// named!(pub comma_separated_types -> Punctuated, -/// call!(Punctuated::parse_separated_nonempty) -/// ); -/// -/// /// The same function as a `Synom` implementation. -/// struct CommaSeparatedTypes { -/// types: Punctuated, -/// } -/// -/// impl Synom for CommaSeparatedTypes { -/// /// As the default behavior, we want there to be at least 1 type. -/// named!(parse -> Self, do_parse!( -/// types: call!(Punctuated::parse_separated_nonempty) >> -/// (CommaSeparatedTypes { types }) -/// )); -/// } -/// -/// impl CommaSeparatedTypes { -/// /// A separate parser that the user can invoke explicitly which allows -/// /// for parsing 0 or more types, rather than the default 1 or more. -/// named!(pub parse0 -> Self, do_parse!( -/// types: call!(Punctuated::parse_separated) >> -/// (CommaSeparatedTypes { types }) -/// )); -/// } -/// # -/// # fn main() {} -/// ``` -/// -/// *This macro is available if Syn is built with the `"parsing"` feature.* -#[macro_export] -macro_rules! named { - ($name:ident -> $o:ty, $submac:ident!( $($args:tt)* )) => { - fn $name(i: $crate::buffer::Cursor) -> $crate::synom::PResult<$o> { - $submac!(i, $($args)*) - } - }; - - (pub $name:ident -> $o:ty, $submac:ident!( $($args:tt)* )) => { - pub fn $name(i: $crate::buffer::Cursor) -> $crate::synom::PResult<$o> { - $submac!(i, $($args)*) - } - }; - - // These two variants are for defining named parsers which have custom - // arguments, and are called with `call!()` - ($name:ident($($params:tt)*) -> $o:ty, $submac:ident!( $($args:tt)* )) => { - fn $name(i: $crate::buffer::Cursor, $($params)*) -> $crate::synom::PResult<$o> { - $submac!(i, $($args)*) - } - }; - - (pub $name:ident($($params:tt)*) -> $o:ty, $submac:ident!( $($args:tt)* )) => { - pub fn $name(i: $crate::buffer::Cursor, $($params)*) -> $crate::synom::PResult<$o> { - $submac!(i, $($args)*) - } - }; -} - -#[cfg(synom_verbose_trace)] -#[macro_export] -macro_rules! call { - ($i:expr, $fun:expr $(, $args:expr)*) => {{ - #[allow(unused_imports)] - use $crate::synom::ext::*; - let i = $i; - eprintln!(concat!(" -> ", stringify!($fun), " @ {:?}"), i); - let r = $fun(i $(, $args)*); - match r { - Ok((_, i)) => eprintln!(concat!("OK ", stringify!($fun), " @ {:?}"), i), - Err(_) => eprintln!(concat!("ERR ", stringify!($fun), " @ {:?}"), i), - } - r - }}; -} - -/// Invoke the given parser function with zero or more arguments. -/// -/// - **Syntax:** `call!(FN, ARGS...)` -/// -/// where the signature of the function is `fn(Cursor, ARGS...) -> PResult` -/// -/// - **Output:** `T`, the result of invoking the function `FN` -/// -/// ```rust -/// #[macro_use] -/// extern crate syn; -/// -/// use syn::Type; -/// use syn::punctuated::Punctuated; -/// use syn::synom::Synom; -/// -/// /// Parses one or more Rust types separated by commas. -/// /// -/// /// Example: `String, Vec, [u8; LEN + 1]` -/// struct CommaSeparatedTypes { -/// types: Punctuated, -/// } -/// -/// impl Synom for CommaSeparatedTypes { -/// named!(parse -> Self, do_parse!( -/// types: call!(Punctuated::parse_separated_nonempty) >> -/// (CommaSeparatedTypes { types }) -/// )); -/// } -/// # -/// # fn main() {} -/// ``` -/// -/// *This macro is available if Syn is built with the `"parsing"` feature.* -#[cfg(not(synom_verbose_trace))] -#[macro_export] -macro_rules! call { - ($i:expr, $fun:expr $(, $args:expr)*) => {{ - #[allow(unused_imports)] - use $crate::synom::ext::*; - $fun($i $(, $args)*) - }}; -} - -/// Transform the result of a parser by applying a function or closure. -/// -/// - **Syntax:** `map!(THING, FN)` -/// - **Output:** the return type of function FN applied to THING -/// -/// ```rust -/// #[macro_use] -/// extern crate syn; -/// -/// use syn::{Expr, ExprIf}; -/// -/// /// Extracts the branch condition of an `if`-expression. -/// fn get_cond(if_: ExprIf) -> Expr { -/// *if_.cond -/// } -/// -/// /// Parses a full `if`-expression but returns the condition part only. -/// /// -/// /// Example: `if x > 0xFF { "big" } else { "small" }` -/// /// The return would be the expression `x > 0xFF`. -/// named!(if_condition -> Expr, -/// map!(syn!(ExprIf), get_cond) -/// ); -/// -/// /// Equivalent using a closure. -/// named!(if_condition2 -> Expr, -/// map!(syn!(ExprIf), |if_| *if_.cond) -/// ); -/// # -/// # fn main() {} -/// ``` -/// -/// *This macro is available if Syn is built with the `"parsing"` feature.* -#[macro_export] -macro_rules! map { - ($i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => { - match $submac!($i, $($args)*) { - ::std::result::Result::Err(err) => - ::std::result::Result::Err(err), - ::std::result::Result::Ok((o, i)) => - ::std::result::Result::Ok(($crate::parsers::invoke($g, o), i)), - } - }; - - ($i:expr, $f:expr, $g:expr) => { - map!($i, call!($f), $g) - }; -} - -// Somehow this helps with type inference in `map!` and `alt!`. -// -// Not public API. -#[doc(hidden)] -pub fn invoke R>(f: F, t: T) -> R { - f(t) -} - -/// Invert the result of a parser by parsing successfully if the given parser -/// fails to parse and vice versa. -/// -/// Does not consume any of the input. -/// -/// - **Syntax:** `not!(THING)` -/// - **Output:** `()` -/// -/// ```rust -/// #[macro_use] -/// extern crate syn; -/// -/// use syn::Expr; -/// -/// /// Parses any expression that does not begin with a `-` minus sign. -/// named!(not_negative_expr -> Expr, do_parse!( -/// not!(punct!(-)) >> -/// e: syn!(Expr) >> -/// (e) -/// )); -/// # -/// # fn main() {} -/// ``` -/// -/// *This macro is available if Syn is built with the `"parsing"` feature.* -#[macro_export] -macro_rules! not { - ($i:expr, $submac:ident!( $($args:tt)* )) => { - match $submac!($i, $($args)*) { - ::std::result::Result::Ok(_) => $crate::parse_error(), - ::std::result::Result::Err(_) => - ::std::result::Result::Ok(((), $i)), - } - }; -} - -/// Execute a parser only if a condition is met, otherwise return None. -/// -/// If you are familiar with nom, this is nom's `cond_with_error` parser. -/// -/// - **Syntax:** `cond!(CONDITION, THING)` -/// - **Output:** `Some(THING)` if the condition is true, else `None` -/// -/// ```rust -/// #[macro_use] -/// extern crate syn; -/// -/// use syn::{Ident, MacroDelimiter}; -/// use syn::token::{Paren, Bracket, Brace}; -/// use syn::synom::Synom; -/// -/// /// Parses a macro call with empty input. If the macro is written with -/// /// parentheses or brackets, a trailing semicolon is required. -/// /// -/// /// Example: `my_macro!{}` or `my_macro!();` or `my_macro![];` -/// struct EmptyMacroCall { -/// name: Ident, -/// bang_token: Token![!], -/// empty_body: MacroDelimiter, -/// semi_token: Option, -/// } -/// -/// fn requires_semi(delimiter: &MacroDelimiter) -> bool { -/// match *delimiter { -/// MacroDelimiter::Paren(_) | MacroDelimiter::Bracket(_) => true, -/// MacroDelimiter::Brace(_) => false, -/// } -/// } -/// -/// impl Synom for EmptyMacroCall { -/// named!(parse -> Self, do_parse!( -/// name: syn!(Ident) >> -/// bang_token: punct!(!) >> -/// empty_body: alt!( -/// parens!(epsilon!()) => { |d| MacroDelimiter::Paren(d.0) } -/// | -/// brackets!(epsilon!()) => { |d| MacroDelimiter::Bracket(d.0) } -/// | -/// braces!(epsilon!()) => { |d| MacroDelimiter::Brace(d.0) } -/// ) >> -/// semi_token: cond!(requires_semi(&empty_body), punct!(;)) >> -/// (EmptyMacroCall { -/// name, -/// bang_token, -/// empty_body, -/// semi_token, -/// }) -/// )); -/// } -/// # -/// # fn main() {} -/// ``` -/// -/// *This macro is available if Syn is built with the `"parsing"` feature.* -#[macro_export] -macro_rules! cond { - ($i:expr, $cond:expr, $submac:ident!( $($args:tt)* )) => { - if $cond { - match $submac!($i, $($args)*) { - ::std::result::Result::Ok((o, i)) => - ::std::result::Result::Ok((::std::option::Option::Some(o), i)), - ::std::result::Result::Err(x) => ::std::result::Result::Err(x), - } - } else { - ::std::result::Result::Ok((::std::option::Option::None, $i)) - } - }; - - ($i:expr, $cond:expr, $f:expr) => { - cond!($i, $cond, call!($f)) - }; -} - -/// Execute a parser only if a condition is met, otherwise fail to parse. -/// -/// This is typically used inside of [`option!`] or [`alt!`]. -/// -/// [`option!`]: macro.option.html -/// [`alt!`]: macro.alt.html -/// -/// - **Syntax:** `cond_reduce!(CONDITION, THING)` -/// - **Output:** `THING` -/// -/// The subparser may be omitted in which case it defaults to [`epsilon!`]. -/// -/// [`epsilon!`]: macro.epsilon.html -/// -/// - **Syntax:** `cond_reduce!(CONDITION)` -/// - **Output:** `()` -/// -/// ```rust -/// #[macro_use] -/// extern crate syn; -/// -/// use syn::Type; -/// use syn::token::Paren; -/// use syn::punctuated::Punctuated; -/// use syn::synom::Synom; -/// -/// /// Parses a possibly variadic function signature. -/// /// -/// /// Example: `fn(A) or `fn(A, B, C, ...)` or `fn(...)` -/// /// Rejected: `fn(A, B...)` -/// struct VariadicFn { -/// fn_token: Token![fn], -/// paren_token: Paren, -/// types: Punctuated, -/// variadic: Option, -/// } -/// -/// // Example of using `cond_reduce!` inside of `option!`. -/// impl Synom for VariadicFn { -/// named!(parse -> Self, do_parse!( -/// fn_token: keyword!(fn) >> -/// params: parens!(do_parse!( -/// types: call!(Punctuated::parse_terminated) >> -/// // Allow, but do not require, an ending `...` but only if the -/// // preceding list of types is empty or ends with a trailing comma. -/// variadic: option!(cond_reduce!(types.empty_or_trailing(), punct!(...))) >> -/// (types, variadic) -/// )) >> -/// ({ -/// let (paren_token, (types, variadic)) = params; -/// VariadicFn { -/// fn_token, -/// paren_token, -/// types, -/// variadic, -/// } -/// }) -/// )); -/// } -/// # -/// # fn main() {} -/// ``` -/// -/// *This macro is available if Syn is built with the `"parsing"` feature.* -#[macro_export] -macro_rules! cond_reduce { - ($i:expr, $cond:expr, $submac:ident!( $($args:tt)* )) => { - if $cond { - $submac!($i, $($args)*) - } else { - $crate::parse_error() - } - }; - - ($i:expr, $cond:expr) => { - cond_reduce!($i, $cond, epsilon!()) - }; - - ($i:expr, $cond:expr, $f:expr) => { - cond_reduce!($i, $cond, call!($f)) - }; -} - -/// Parse zero or more values using the given parser. -/// -/// - **Syntax:** `many0!(THING)` -/// - **Output:** `Vec` -/// -/// You may also be looking for: -/// -/// - `call!(Punctuated::parse_separated)` - zero or more values with separator -/// - `call!(Punctuated::parse_separated_nonempty)` - one or more values -/// - `call!(Punctuated::parse_terminated)` - zero or more, allows trailing separator -/// - `call!(Punctuated::parse_terminated_nonempty)` - one or more -/// -/// ```rust -/// #[macro_use] -/// extern crate syn; -/// -/// use syn::{Ident, Item}; -/// use syn::token::Brace; -/// use syn::synom::Synom; -/// -/// /// Parses a module containing zero or more Rust items. -/// /// -/// /// Example: `mod m { type Result = ::std::result::Result; }` -/// struct SimpleMod { -/// mod_token: Token![mod], -/// name: Ident, -/// brace_token: Brace, -/// items: Vec, -/// } -/// -/// impl Synom for SimpleMod { -/// named!(parse -> Self, do_parse!( -/// mod_token: keyword!(mod) >> -/// name: syn!(Ident) >> -/// body: braces!(many0!(syn!(Item))) >> -/// (SimpleMod { -/// mod_token, -/// name, -/// brace_token: body.0, -/// items: body.1, -/// }) -/// )); -/// } -/// # -/// # fn main() {} -/// ``` -/// -/// *This macro is available if Syn is built with the `"parsing"` feature.* -#[macro_export] -macro_rules! many0 { - ($i:expr, $submac:ident!( $($args:tt)* )) => {{ - let ret; - let mut res = ::std::vec::Vec::new(); - let mut input = $i; - - loop { - if input.eof() { - ret = ::std::result::Result::Ok((res, input)); - break; - } - - match $submac!(input, $($args)*) { - ::std::result::Result::Err(_) => { - ret = ::std::result::Result::Ok((res, input)); - break; - } - ::std::result::Result::Ok((o, i)) => { - // loop trip must always consume (otherwise infinite loops) - if i == input { - ret = $crate::parse_error(); - break; - } - - res.push(o); - input = i; - } - } - } - - ret - }}; - - ($i:expr, $f:expr) => { - $crate::parsers::many0($i, $f) - }; -} - -// Improve compile time by compiling this loop only once per type it is used -// with. -// -// Not public API. -#[doc(hidden)] -pub fn many0(mut input: Cursor, f: fn(Cursor) -> PResult) -> PResult> { - let mut res = Vec::new(); - - loop { - if input.eof() { - return Ok((res, input)); - } - - match f(input) { - Err(_) => { - return Ok((res, input)); - } - Ok((o, i)) => { - // loop trip must always consume (otherwise infinite loops) - if i == input { - return parse_error(); - } - - res.push(o); - input = i; - } - } - } -} - -/// Pattern-match the result of a parser to select which other parser to run. -/// -/// - **Syntax:** `switch!(TARGET, PAT1 => THEN1 | PAT2 => THEN2 | ...)` -/// - **Output:** `T`, the return type of `THEN1` and `THEN2` and ... -/// -/// ```rust -/// #[macro_use] -/// extern crate syn; -/// -/// use syn::Ident; -/// use syn::token::Brace; -/// use syn::synom::Synom; -/// -/// /// Parse a unit struct or enum: either `struct S;` or `enum E { V }`. -/// enum UnitType { -/// Struct { -/// struct_token: Token![struct], -/// name: Ident, -/// semi_token: Token![;], -/// }, -/// Enum { -/// enum_token: Token![enum], -/// name: Ident, -/// brace_token: Brace, -/// variant: Ident, -/// }, -/// } -/// -/// enum StructOrEnum { -/// Struct(Token![struct]), -/// Enum(Token![enum]), -/// } -/// -/// impl Synom for StructOrEnum { -/// named!(parse -> Self, alt!( -/// keyword!(struct) => { StructOrEnum::Struct } -/// | -/// keyword!(enum) => { StructOrEnum::Enum } -/// )); -/// } -/// -/// impl Synom for UnitType { -/// named!(parse -> Self, do_parse!( -/// which: syn!(StructOrEnum) >> -/// name: syn!(Ident) >> -/// item: switch!(value!(which), -/// StructOrEnum::Struct(struct_token) => map!( -/// punct!(;), -/// |semi_token| UnitType::Struct { -/// struct_token, -/// name, -/// semi_token, -/// } -/// ) -/// | -/// StructOrEnum::Enum(enum_token) => map!( -/// braces!(syn!(Ident)), -/// |(brace_token, variant)| UnitType::Enum { -/// enum_token, -/// name, -/// brace_token, -/// variant, -/// } -/// ) -/// ) >> -/// (item) -/// )); -/// } -/// # -/// # fn main() {} -/// ``` -/// -/// *This macro is available if Syn is built with the `"parsing"` feature.* -#[macro_export] -macro_rules! switch { - ($i:expr, $submac:ident!( $($args:tt)* ), $($p:pat => $subrule:ident!( $($args2:tt)* ))|* ) => { - match $submac!($i, $($args)*) { - ::std::result::Result::Err(err) => ::std::result::Result::Err(err), - ::std::result::Result::Ok((o, i)) => match o { - $( - $p => $subrule!(i, $($args2)*), - )* - } - } - }; -} - -/// Produce the given value without parsing anything. -/// -/// This can be needed where you have an existing parsed value but a parser -/// macro's syntax expects you to provide a submacro, such as in the first -/// argument of [`switch!`] or one of the branches of [`alt!`]. -/// -/// [`switch!`]: macro.switch.html -/// [`alt!`]: macro.alt.html -/// -/// - **Syntax:** `value!(VALUE)` -/// - **Output:** `VALUE` -/// -/// ```rust -/// #[macro_use] -/// extern crate syn; -/// -/// use syn::Ident; -/// use syn::token::Brace; -/// use syn::synom::Synom; -/// -/// /// Parse a unit struct or enum: either `struct S;` or `enum E { V }`. -/// enum UnitType { -/// Struct { -/// struct_token: Token![struct], -/// name: Ident, -/// semi_token: Token![;], -/// }, -/// Enum { -/// enum_token: Token![enum], -/// name: Ident, -/// brace_token: Brace, -/// variant: Ident, -/// }, -/// } -/// -/// enum StructOrEnum { -/// Struct(Token![struct]), -/// Enum(Token![enum]), -/// } -/// -/// impl Synom for StructOrEnum { -/// named!(parse -> Self, alt!( -/// keyword!(struct) => { StructOrEnum::Struct } -/// | -/// keyword!(enum) => { StructOrEnum::Enum } -/// )); -/// } -/// -/// impl Synom for UnitType { -/// named!(parse -> Self, do_parse!( -/// which: syn!(StructOrEnum) >> -/// name: syn!(Ident) >> -/// item: switch!(value!(which), -/// StructOrEnum::Struct(struct_token) => map!( -/// punct!(;), -/// |semi_token| UnitType::Struct { -/// struct_token, -/// name, -/// semi_token, -/// } -/// ) -/// | -/// StructOrEnum::Enum(enum_token) => map!( -/// braces!(syn!(Ident)), -/// |(brace_token, variant)| UnitType::Enum { -/// enum_token, -/// name, -/// brace_token, -/// variant, -/// } -/// ) -/// ) >> -/// (item) -/// )); -/// } -/// # -/// # fn main() {} -/// ``` -/// -/// *This macro is available if Syn is built with the `"parsing"` feature.* -#[macro_export] -macro_rules! value { - ($i:expr, $res:expr) => { - ::std::result::Result::Ok(($res, $i)) - }; -} - -/// Unconditionally fail to parse anything. -/// -/// This may be useful in rejecting some arms of a `switch!` parser. -/// -/// - **Syntax:** `reject!()` -/// - **Output:** never succeeds -/// -/// ```rust -/// #[macro_use] -/// extern crate syn; -/// -/// use syn::Item; -/// -/// // Parse any item, except for a module. -/// named!(almost_any_item -> Item, -/// switch!(syn!(Item), -/// Item::Mod(_) => reject!() -/// | -/// ok => value!(ok) -/// ) -/// ); -/// # -/// # fn main() {} -/// ``` -/// -/// *This macro is available if Syn is built with the `"parsing"` feature.* -#[macro_export] -macro_rules! reject { - ($i:expr,) => {{ - let _ = $i; - $crate::parse_error() - }}; -} - -/// Run a series of parsers and produce all of the results in a tuple. -/// -/// - **Syntax:** `tuple!(A, B, C, ...)` -/// - **Output:** `(A, B, C, ...)` -/// -/// ```rust -/// #[macro_use] -/// extern crate syn; -/// -/// use syn::Type; -/// -/// named!(two_types -> (Type, Type), tuple!(syn!(Type), syn!(Type))); -/// # -/// # fn main() {} -/// ``` -/// -/// *This macro is available if Syn is built with the `"parsing"` feature.* -#[macro_export] -macro_rules! tuple { - ($i:expr, $($rest:tt)+) => { - tuple_parser!($i, (), $($rest)+) - }; -} - -// Internal parser, do not use directly. -#[doc(hidden)] -#[macro_export] -macro_rules! tuple_parser { - ($i:expr, ($($parsed:ident,)*), $e:ident) => { - tuple_parser!($i, ($($parsed,)*), call!($e)) - }; - - ($i:expr, ($($parsed:ident,)*), $e:ident, $($rest:tt)*) => { - tuple_parser!($i, ($($parsed,)*), call!($e), $($rest)*) - }; - - ($i:expr, ($($parsed:ident,)*), $submac:ident!( $($args:tt)* )) => { - match $submac!($i, $($args)*) { - ::std::result::Result::Err(err) => - ::std::result::Result::Err(err), - ::std::result::Result::Ok((o, i)) => - ::std::result::Result::Ok((($($parsed,)* o,), i)), - } - }; - - ($i:expr, ($($parsed:ident,)*), $submac:ident!( $($args:tt)* ), $($rest:tt)*) => { - match $submac!($i, $($args)*) { - ::std::result::Result::Err(err) => - ::std::result::Result::Err(err), - ::std::result::Result::Ok((o, i)) => - tuple_parser!(i, ($($parsed,)* o,), $($rest)*), - } - }; - - ($i:expr, ($($parsed:ident,)*),) => { - ::std::result::Result::Ok((($($parsed,)*), $i)) - }; -} - -/// Run a series of parsers, returning the result of the first one which -/// succeeds. -/// -/// Optionally allows for the result to be transformed. -/// -/// - **Syntax:** `alt!(THING1 | THING2 => { FUNC } | ...)` -/// - **Output:** `T`, the return type of `THING1` and `FUNC(THING2)` and ... -/// -/// # Example -/// -/// ```rust -/// #[macro_use] -/// extern crate syn; -/// extern crate proc_macro2; -/// -/// use proc_macro2::{Ident, Span}; -/// -/// // Parse any identifier token, or the `!` token in which case the -/// // identifier is treated as `"BANG"`. -/// named!(ident_or_bang -> Ident, alt!( -/// syn!(Ident) -/// | -/// punct!(!) => { |_| Ident::new("BANG", Span::call_site()) } -/// )); -/// # -/// # fn main() {} -/// ``` -/// -/// The `alt!` macro is most commonly seen when parsing a syntax tree enum such -/// as the [`Item`] enum. -/// -/// [`Item`]: enum.Item.html -/// -/// ``` -/// # #[macro_use] -/// # extern crate syn; -/// # -/// # use syn::synom::Synom; -/// # -/// # struct Item; -/// # -/// impl Synom for Item { -/// named!(parse -> Self, alt!( -/// # epsilon!() => { |_| unimplemented!() } -/// # )); -/// # } -/// # -/// # mod example { -/// # use syn::*; -/// # -/// # named!(parse -> Item, alt!( -/// syn!(ItemExternCrate) => { Item::ExternCrate } -/// | -/// syn!(ItemUse) => { Item::Use } -/// | -/// syn!(ItemStatic) => { Item::Static } -/// | -/// syn!(ItemConst) => { Item::Const } -/// | -/// /* ... */ -/// # syn!(ItemFn) => { Item::Fn } -/// )); -/// } -/// # -/// # fn main() {} -/// ``` -/// -/// *This macro is available if Syn is built with the `"parsing"` feature.* -#[macro_export] -macro_rules! alt { - ($i:expr, $e:ident | $($rest:tt)*) => { - alt!($i, call!($e) | $($rest)*) - }; - - ($i:expr, $subrule:ident!( $($args:tt)*) | $($rest:tt)*) => { - match $subrule!($i, $($args)*) { - res @ ::std::result::Result::Ok(_) => res, - _ => alt!($i, $($rest)*) - } - }; - - ($i:expr, $subrule:ident!( $($args:tt)* ) => { $gen:expr } | $($rest:tt)+) => { - match $subrule!($i, $($args)*) { - ::std::result::Result::Ok((o, i)) => - ::std::result::Result::Ok(($crate::parsers::invoke($gen, o), i)), - ::std::result::Result::Err(_) => alt!($i, $($rest)*), - } - }; - - ($i:expr, $e:ident => { $gen:expr } | $($rest:tt)*) => { - alt!($i, call!($e) => { $gen } | $($rest)*) - }; - - ($i:expr, $e:ident => { $gen:expr }) => { - alt!($i, call!($e) => { $gen }) - }; - - ($i:expr, $subrule:ident!( $($args:tt)* ) => { $gen:expr }) => { - match $subrule!($i, $($args)*) { - ::std::result::Result::Ok((o, i)) => - ::std::result::Result::Ok(($crate::parsers::invoke($gen, o), i)), - ::std::result::Result::Err(err) => - ::std::result::Result::Err(err), - } - }; - - ($i:expr, $e:ident) => { - alt!($i, call!($e)) - }; - - ($i:expr, $subrule:ident!( $($args:tt)*)) => { - $subrule!($i, $($args)*) - }; -} - -/// Run a series of parsers, optionally naming each intermediate result, -/// followed by a step to combine the intermediate results. -/// -/// Produces the result of evaluating the final expression in parentheses with -/// all of the previously named results bound. -/// -/// - **Syntax:** `do_parse!(name: THING1 >> THING2 >> (RESULT))` -/// - **Output:** `RESULT` -/// -/// ```rust -/// #[macro_use] -/// extern crate syn; -/// extern crate proc_macro2; -/// -/// use proc_macro2::Ident; -/// use proc_macro2::TokenStream; -/// use syn::token::Paren; -/// use syn::synom::Synom; -/// -/// /// Parse a macro invocation that uses `(` `)` parentheses. -/// /// -/// /// Example: `stringify!($args)`. -/// struct Macro { -/// name: Ident, -/// bang_token: Token![!], -/// paren_token: Paren, -/// tts: TokenStream, -/// } -/// -/// impl Synom for Macro { -/// named!(parse -> Self, do_parse!( -/// name: syn!(Ident) >> -/// bang_token: punct!(!) >> -/// body: parens!(syn!(TokenStream)) >> -/// (Macro { -/// name, -/// bang_token, -/// paren_token: body.0, -/// tts: body.1, -/// }) -/// )); -/// } -/// # -/// # fn main() {} -/// ``` -/// -/// *This macro is available if Syn is built with the `"parsing"` feature.* -#[macro_export] -macro_rules! do_parse { - ($i:expr, ( $($rest:expr),* )) => { - ::std::result::Result::Ok((( $($rest),* ), $i)) - }; - - ($i:expr, $e:ident >> $($rest:tt)*) => { - do_parse!($i, call!($e) >> $($rest)*) - }; - - ($i:expr, $submac:ident!( $($args:tt)* ) >> $($rest:tt)*) => { - match $submac!($i, $($args)*) { - ::std::result::Result::Err(err) => - ::std::result::Result::Err(err), - ::std::result::Result::Ok((_, i)) => - do_parse!(i, $($rest)*), - } - }; - - ($i:expr, $field:ident : $e:ident >> $($rest:tt)*) => { - do_parse!($i, $field: call!($e) >> $($rest)*) - }; - - ($i:expr, $field:ident : $submac:ident!( $($args:tt)* ) >> $($rest:tt)*) => { - match $submac!($i, $($args)*) { - ::std::result::Result::Err(err) => - ::std::result::Result::Err(err), - ::std::result::Result::Ok((o, i)) => { - let $field = o; - do_parse!(i, $($rest)*) - }, - } - }; - - ($i:expr, mut $field:ident : $e:ident >> $($rest:tt)*) => { - do_parse!($i, mut $field: call!($e) >> $($rest)*) - }; - - ($i:expr, mut $field:ident : $submac:ident!( $($args:tt)* ) >> $($rest:tt)*) => { - match $submac!($i, $($args)*) { - ::std::result::Result::Err(err) => - ::std::result::Result::Err(err), - ::std::result::Result::Ok((o, i)) => { - let mut $field = o; - do_parse!(i, $($rest)*) - }, - } - }; -} - -/// Parse nothing and succeed only if the end of the enclosing block has been -/// reached. -/// -/// The enclosing block may be the full input if we are parsing at the top -/// level, or the surrounding parenthesis/bracket/brace if we are parsing within -/// those. -/// -/// - **Syntax:** `input_end!()` -/// - **Output:** `()` -/// -/// ```rust -/// #[macro_use] -/// extern crate syn; -/// -/// use syn::Expr; -/// use syn::synom::Synom; -/// -/// /// Parses any Rust expression followed either by a semicolon or by the end -/// /// of the input. -/// /// -/// /// For example `many0!(syn!(TerminatedExpr))` would successfully parse the -/// /// following input into three expressions. -/// /// -/// /// 1 + 1; second.two(); third!() -/// /// -/// /// Similarly within a block, `braced!(many0!(syn!(TerminatedExpr)))` would -/// /// successfully parse three expressions. -/// /// -/// /// { 1 + 1; second.two(); third!() } -/// struct TerminatedExpr { -/// expr: Expr, -/// semi_token: Option, -/// } -/// -/// impl Synom for TerminatedExpr { -/// named!(parse -> Self, do_parse!( -/// expr: syn!(Expr) >> -/// semi_token: alt!( -/// input_end!() => { |_| None } -/// | -/// punct!(;) => { Some } -/// ) >> -/// (TerminatedExpr { -/// expr, -/// semi_token, -/// }) -/// )); -/// } -/// # -/// # fn main() {} -/// ``` -/// -/// *This macro is available if Syn is built with the `"parsing"` feature.* -#[macro_export] -macro_rules! input_end { - ($i:expr,) => { - $crate::parsers::input_end($i) - }; -} - -// Not a public API -#[doc(hidden)] -pub fn input_end(input: Cursor) -> PResult<'static, ()> { - if input.eof() { - Ok(((), Cursor::empty())) - } else { - parse_error() - } -} - -/// Turn a failed parse into `None` and a successful parse into `Some`. -/// -/// A failed parse consumes none of the input. -/// -/// - **Syntax:** `option!(THING)` -/// - **Output:** `Option` -/// -/// ```rust -/// #[macro_use] -/// extern crate syn; -/// -/// use syn::{Label, Block}; -/// use syn::synom::Synom; -/// -/// /// Parses a Rust loop. Equivalent to syn::ExprLoop. -/// /// -/// /// Examples: -/// /// loop { println!("y"); } -/// /// 'x: loop { break 'x; } -/// struct ExprLoop { -/// label: Option

) -> Self { - match d { - Some(d) => Pair::Punctuated(t, d), - None => Pair::End(t), - } - } - - /// Produces this punctuated pair as a tuple of syntax tree node and - /// optional following punctuation. - pub fn into_tuple(self) -> (T, Option

) { - match self { - Pair::Punctuated(t, d) => (t, Some(d)), - Pair::End(t) => (t, None), - } - } -} - -impl Index for Punctuated { - type Output = T; - - fn index(&self, index: usize) -> &Self::Output { - if index == self.len() - 1 { - match self.last { - Some(ref t) => t, - None => &self.inner[index].0, - } - } else { - &self.inner[index].0 - } - } -} - -impl IndexMut for Punctuated { - fn index_mut(&mut self, index: usize) -> &mut Self::Output { - if index == self.len() - 1 { - match self.last { - Some(ref mut t) => t, - None => &mut self.inner[index].0, - } - } else { - &mut self.inner[index].0 - } - } -} - -#[cfg(feature = "parsing")] -impl Punctuated -where - T: Synom, - P: Synom, -{ - /// Parse **zero or more** syntax tree nodes with punctuation in between and - /// **no trailing** punctuation. - pub fn parse_separated(input: Cursor) -> PResult { - Self::parse_separated_with(input, T::parse) - } - - /// Parse **one or more** syntax tree nodes with punctuation in bewteen and - /// **no trailing** punctuation. - /// allowing trailing punctuation. - pub fn parse_separated_nonempty(input: Cursor) -> PResult { - Self::parse_separated_nonempty_with(input, T::parse) - } - - /// Parse **zero or more** syntax tree nodes with punctuation in between and - /// **optional trailing** punctuation. - pub fn parse_terminated(input: Cursor) -> PResult { - Self::parse_terminated_with(input, T::parse) - } - - /// Parse **one or more** syntax tree nodes with punctuation in between and - /// **optional trailing** punctuation. - pub fn parse_terminated_nonempty(input: Cursor) -> PResult { - Self::parse_terminated_nonempty_with(input, T::parse) - } -} - -#[cfg(feature = "parsing")] -impl Punctuated -where - P: Synom, -{ - /// Parse **zero or more** syntax tree nodes using the given parser with - /// punctuation in between and **no trailing** punctuation. - pub fn parse_separated_with(input: Cursor, parse: fn(Cursor) -> PResult) -> PResult { - Self::parse(input, parse, false) - } - - /// Parse **one or more** syntax tree nodes using the given parser with - /// punctuation in between and **no trailing** punctuation. - pub fn parse_separated_nonempty_with( - input: Cursor, - parse: fn(Cursor) -> PResult, - ) -> PResult { - match Self::parse(input, parse, false) { - Ok((ref b, _)) if b.is_empty() => parse_error(), - other => other, - } - } - - /// Parse **zero or more** syntax tree nodes using the given parser with - /// punctuation in between and **optional trailing** punctuation. - pub fn parse_terminated_with(input: Cursor, parse: fn(Cursor) -> PResult) -> PResult { - Self::parse(input, parse, true) - } - - /// Parse **one or more** syntax tree nodes using the given parser with - /// punctuation in between and **optional trailing** punctuation. - pub fn parse_terminated_nonempty_with( - input: Cursor, - parse: fn(Cursor) -> PResult, - ) -> PResult { - match Self::parse(input, parse, true) { - Ok((ref b, _)) if b.is_empty() => parse_error(), - other => other, - } - } - - fn parse( - mut input: Cursor, - parse: fn(Cursor) -> PResult, - terminated: bool, - ) -> PResult { - let mut res = Punctuated::new(); - - // get the first element - match parse(input) { - Err(_) => Ok((res, input)), - Ok((o, i)) => { - if i == input { - return parse_error(); - } - input = i; - res.push_value(o); - - // get the separator first - while let Ok((s, i2)) = P::parse(input) { - if i2 == input { - break; - } - - // get the element next - if let Ok((o3, i3)) = parse(i2) { - if i3 == i2 { - break; - } - res.push_punct(s); - res.push_value(o3); - input = i3; - } else { - break; - } - } - if terminated { - if let Ok((sep, after)) = P::parse(input) { - res.push_punct(sep); - input = after; - } - } - Ok((res, input)) - } - } - } -} - -#[cfg(feature = "printing")] -mod printing { - use super::*; - use proc_macro2::TokenStream; - use quote::{ToTokens, TokenStreamExt}; - - impl ToTokens for Punctuated - where - T: ToTokens, - P: ToTokens, - { - fn to_tokens(&self, tokens: &mut TokenStream) { - tokens.append_all(self.pairs()) - } - } - - impl ToTokens for Pair - where - T: ToTokens, - P: ToTokens, - { - fn to_tokens(&self, tokens: &mut TokenStream) { - match *self { - Pair::Punctuated(ref a, ref b) => { - a.to_tokens(tokens); - b.to_tokens(tokens); - } - Pair::End(ref a) => a.to_tokens(tokens), - } - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/spanned.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/spanned.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/spanned.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/spanned.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,142 +0,0 @@ -// Copyright 2018 Syn Developers -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! A trait that can provide the `Span` of the complete contents of a syntax -//! tree node. -//! -//! *This module is available if Syn is built with both the `"parsing"` and -//! `"printing"` features.* -//! -//! # Example -//! -//! Suppose in a procedural macro we have a [`Type`] that we want to assert -//! implements the [`Sync`] trait. Maybe this is the type of one of the fields -//! of a struct for which we are deriving a trait implementation, and we need to -//! be able to pass a reference to one of those fields across threads. -//! -//! [`Type`]: ../enum.Type.html -//! [`Sync`]: https://doc.rust-lang.org/std/marker/trait.Sync.html -//! -//! If the field type does *not* implement `Sync` as required, we want the -//! compiler to report an error pointing out exactly which type it was. -//! -//! The following macro code takes a variable `ty` of type `Type` and produces a -//! static assertion that `Sync` is implemented for that type. -//! -//! ``` -//! #[macro_use] -//! extern crate quote; -//! -//! extern crate syn; -//! extern crate proc_macro; -//! extern crate proc_macro2; -//! -//! use syn::Type; -//! use syn::spanned::Spanned; -//! use proc_macro::TokenStream; -//! use proc_macro2::Span; -//! -//! # const IGNORE_TOKENS: &str = stringify! { -//! #[proc_macro_derive(MyMacro)] -//! # }; -//! pub fn my_macro(input: TokenStream) -> TokenStream { -//! # let ty = get_a_type(); -//! /* ... */ -//! -//! let assert_sync = quote_spanned! {ty.span()=> -//! struct _AssertSync where #ty: Sync; -//! }; -//! -//! /* ... */ -//! # input -//! } -//! # -//! # fn get_a_type() -> Type { -//! # unimplemented!() -//! # } -//! # -//! # fn main() {} -//! ``` -//! -//! By inserting this `assert_sync` fragment into the output code generated by -//! our macro, the user's code will fail to compile if `ty` does not implement -//! `Sync`. The errors they would see look like the following. -//! -//! ```text -//! error[E0277]: the trait bound `*const i32: std::marker::Sync` is not satisfied -//! --> src/main.rs:10:21 -//! | -//! 10 | bad_field: *const i32, -//! | ^^^^^^^^^^ `*const i32` cannot be shared between threads safely -//! ``` -//! -//! In this technique, using the `Type`'s span for the error message makes the -//! error appear in the correct place underlining the right type. - -use proc_macro2::{Span, TokenStream}; -use quote::ToTokens; - -/// A trait that can provide the `Span` of the complete contents of a syntax -/// tree node. -/// -/// This trait is automatically implemented for all types that implement -/// [`ToTokens`] from the `quote` crate. -/// -/// [`ToTokens`]: https://docs.rs/quote/0.4/quote/trait.ToTokens.html -/// -/// See the [module documentation] for an example. -/// -/// [module documentation]: index.html -/// -/// *This trait is available if Syn is built with both the `"parsing"` and -/// `"printing"` features.* -pub trait Spanned { - /// Returns a `Span` covering the complete contents of this syntax tree - /// node, or [`Span::call_site()`] if this node is empty. - /// - /// [`Span::call_site()`]: https://docs.rs/proc-macro2/0.2/proc_macro2/struct.Span.html#method.call_site - fn span(&self) -> Span; -} - -impl Spanned for T -where - T: ToTokens, -{ - #[cfg(procmacro2_semver_exempt)] - fn span(&self) -> Span { - let mut tokens = TokenStream::new(); - self.to_tokens(&mut tokens); - let mut iter = tokens.into_iter(); - let mut span = match iter.next() { - Some(tt) => tt.span(), - None => { - return Span::call_site(); - } - }; - for tt in iter { - if let Some(joined) = span.join(tt.span()) { - span = joined; - } - } - span - } - - #[cfg(not(procmacro2_semver_exempt))] - fn span(&self) -> Span { - let mut tokens = TokenStream::new(); - self.to_tokens(&mut tokens); - let mut iter = tokens.into_iter(); - - // We can't join spans without procmacro2_semver_exempt so just grab the - // first one. - match iter.next() { - Some(tt) => tt.span(), - None => Span::call_site(), - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/synom.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/synom.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/synom.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/synom.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,419 +0,0 @@ -// Copyright 2018 Syn Developers -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Parsing interface for parsing a token stream into a syntax tree node. -//! -//! Parsing in Syn is built on parser functions that take in a [`Cursor`] and -//! produce a [`PResult`] where `T` is some syntax tree node. `Cursor` is a -//! cheaply copyable cursor over a range of tokens in a token stream, and -//! `PResult` is a result that packages together a parsed syntax tree node `T` -//! with a stream of remaining unparsed tokens after `T` represented as another -//! `Cursor`, or a [`ParseError`] if parsing failed. -//! -//! [`Cursor`]: ../buffer/index.html -//! [`PResult`]: type.PResult.html -//! [`ParseError`]: struct.ParseError.html -//! -//! This `Cursor`- and `PResult`-based interface is convenient for parser -//! combinators and parser implementations, but not necessarily when you just -//! have some tokens that you want to parse. For that we expose the following -//! two entry points. -//! -//! ## The `syn::parse*` functions -//! -//! The [`syn::parse`], [`syn::parse2`], and [`syn::parse_str`] functions serve -//! as an entry point for parsing syntax tree nodes that can be parsed in an -//! obvious default way. These functions can return any syntax tree node that -//! implements the [`Synom`] trait, which includes most types in Syn. -//! -//! [`syn::parse`]: ../fn.parse.html -//! [`syn::parse2`]: ../fn.parse2.html -//! [`syn::parse_str`]: ../fn.parse_str.html -//! [`Synom`]: trait.Synom.html -//! -//! ``` -//! use syn::Type; -//! -//! # fn run_parser() -> Result<(), syn::synom::ParseError> { -//! let t: Type = syn::parse_str("std::collections::HashMap")?; -//! # Ok(()) -//! # } -//! # -//! # fn main() { -//! # run_parser().unwrap(); -//! # } -//! ``` -//! -//! The [`parse_quote!`] macro also uses this approach. -//! -//! [`parse_quote!`]: ../macro.parse_quote.html -//! -//! ## The `Parser` trait -//! -//! Some types can be parsed in several ways depending on context. For example -//! an [`Attribute`] can be either "outer" like `#[...]` or "inner" like -//! `#![...]` and parsing the wrong one would be a bug. Similarly [`Punctuated`] -//! may or may not allow trailing punctuation, and parsing it the wrong way -//! would either reject valid input or accept invalid input. -//! -//! [`Attribute`]: ../struct.Attribute.html -//! [`Punctuated`]: ../punctuated/index.html -//! -//! The `Synom` trait is not implemented in these cases because there is no good -//! behavior to consider the default. -//! -//! ```ignore -//! // Can't parse `Punctuated` without knowing whether trailing punctuation -//! // should be allowed in this context. -//! let path: Punctuated = syn::parse(tokens)?; -//! ``` -//! -//! In these cases the types provide a choice of parser functions rather than a -//! single `Synom` implementation, and those parser functions can be invoked -//! through the [`Parser`] trait. -//! -//! [`Parser`]: trait.Parser.html -//! -//! ``` -//! # #[macro_use] -//! # extern crate syn; -//! # -//! # extern crate proc_macro2; -//! # use proc_macro2::TokenStream; -//! # -//! use syn::synom::Parser; -//! use syn::punctuated::Punctuated; -//! use syn::{PathSegment, Expr, Attribute}; -//! -//! # fn run_parsers() -> Result<(), syn::synom::ParseError> { -//! # let tokens = TokenStream::new().into(); -//! // Parse a nonempty sequence of path segments separated by `::` punctuation -//! // with no trailing punctuation. -//! let parser = Punctuated::::parse_separated_nonempty; -//! let path = parser.parse(tokens)?; -//! -//! # let tokens = TokenStream::new().into(); -//! // Parse a possibly empty sequence of expressions terminated by commas with -//! // an optional trailing punctuation. -//! let parser = Punctuated::::parse_terminated; -//! let args = parser.parse(tokens)?; -//! -//! # let tokens = TokenStream::new().into(); -//! // Parse zero or more outer attributes but not inner attributes. -//! named!(outer_attrs -> Vec, many0!(Attribute::parse_outer)); -//! let attrs = outer_attrs.parse(tokens)?; -//! # -//! # Ok(()) -//! # } -//! # -//! # fn main() {} -//! ``` -//! -//! # Implementing a parser function -//! -//! Parser functions are usually implemented using the [`nom`]-style parser -//! combinator macros provided by Syn, but may also be implemented without -//! macros be using the low-level [`Cursor`] API directly. -//! -//! [`nom`]: https://github.com/Geal/nom -//! -//! The following parser combinator macros are available and a `Synom` parsing -//! example is provided for each one. -//! -//! - [`alt!`](../macro.alt.html) -//! - [`braces!`](../macro.braces.html) -//! - [`brackets!`](../macro.brackets.html) -//! - [`call!`](../macro.call.html) -//! - [`cond!`](../macro.cond.html) -//! - [`cond_reduce!`](../macro.cond_reduce.html) -//! - [`custom_keyword!`](../macro.custom_keyword.html) -//! - [`do_parse!`](../macro.do_parse.html) -//! - [`epsilon!`](../macro.epsilon.html) -//! - [`input_end!`](../macro.input_end.html) -//! - [`keyword!`](../macro.keyword.html) -//! - [`many0!`](../macro.many0.html) -//! - [`map!`](../macro.map.html) -//! - [`not!`](../macro.not.html) -//! - [`option!`](../macro.option.html) -//! - [`parens!`](../macro.parens.html) -//! - [`punct!`](../macro.punct.html) -//! - [`reject!`](../macro.reject.html) -//! - [`switch!`](../macro.switch.html) -//! - [`syn!`](../macro.syn.html) -//! - [`tuple!`](../macro.tuple.html) -//! - [`value!`](../macro.value.html) -//! -//! *This module is available if Syn is built with the `"parsing"` feature.* - -#[cfg(all( - not(all(target_arch = "wasm32", target_os = "unknown")), - feature = "proc-macro" -))] -use proc_macro; -use proc_macro2::{Delimiter, Group, Ident, Literal, Punct, TokenStream, TokenTree}; - -use error::parse_error; -pub use error::{PResult, ParseError}; - -use buffer::{Cursor, TokenBuffer}; - -/// Parsing interface implemented by all types that can be parsed in a default -/// way from a token stream. -/// -/// Refer to the [module documentation] for details about parsing in Syn. -/// -/// [module documentation]: index.html -/// -/// *This trait is available if Syn is built with the `"parsing"` feature.* -pub trait Synom: Sized { - fn parse(input: Cursor) -> PResult; - - /// A short name of the type being parsed. - /// - /// The description should only be used for a simple name. It should not - /// contain newlines or sentence-ending punctuation, to facilitate embedding in - /// larger user-facing strings. Syn will use this description when building - /// error messages about parse failures. - /// - /// # Examples - /// - /// ``` - /// # use syn::buffer::Cursor; - /// # use syn::synom::{Synom, PResult}; - /// # - /// struct ExprMacro { - /// // ... - /// } - /// - /// impl Synom for ExprMacro { - /// # fn parse(input: Cursor) -> PResult { unimplemented!() } - /// // fn parse(...) -> ... { ... } - /// - /// fn description() -> Option<&'static str> { - /// // Will result in messages like - /// // - /// // "failed to parse macro invocation expression: $reason" - /// Some("macro invocation expression") - /// } - /// } - /// ``` - fn description() -> Option<&'static str> { - None - } -} - -impl Synom for TokenStream { - fn parse(input: Cursor) -> PResult { - Ok((input.token_stream(), Cursor::empty())) - } - - fn description() -> Option<&'static str> { - Some("arbitrary token stream") - } -} - -impl Synom for TokenTree { - fn parse(input: Cursor) -> PResult { - match input.token_tree() { - Some((tt, rest)) => Ok((tt, rest)), - None => parse_error(), - } - } - - fn description() -> Option<&'static str> { - Some("token tree") - } -} - -impl Synom for Group { - fn parse(input: Cursor) -> PResult { - for delim in &[Delimiter::Parenthesis, Delimiter::Brace, Delimiter::Bracket] { - if let Some((inside, span, rest)) = input.group(*delim) { - let mut group = Group::new(*delim, inside.token_stream()); - group.set_span(span); - return Ok((group, rest)); - } - } - parse_error() - } - - fn description() -> Option<&'static str> { - Some("group token") - } -} - -impl Synom for Ident { - fn parse(input: Cursor) -> PResult { - let (ident, rest) = match input.ident() { - Some(ident) => ident, - _ => return parse_error(), - }; - match &ident.to_string()[..] { - "_" - // Based on https://doc.rust-lang.org/grammar.html#keywords - // and https://github.com/rust-lang/rfcs/blob/master/text/2421-unreservations-2018.md - | "abstract" | "as" | "become" | "box" | "break" | "const" - | "continue" | "crate" | "do" | "else" | "enum" | "extern" | "false" | "final" - | "fn" | "for" | "if" | "impl" | "in" | "let" | "loop" | "macro" | "match" - | "mod" | "move" | "mut" | "override" | "priv" | "proc" | "pub" - | "ref" | "return" | "Self" | "self" | "static" | "struct" - | "super" | "trait" | "true" | "type" | "typeof" | "unsafe" | "unsized" | "use" - | "virtual" | "where" | "while" | "yield" => return parse_error(), - _ => {} - } - - Ok((ident, rest)) - } - - fn description() -> Option<&'static str> { - Some("identifier") - } -} - -impl Synom for Punct { - fn parse(input: Cursor) -> PResult { - match input.punct() { - Some((punct, rest)) => Ok((punct, rest)), - None => parse_error(), - } - } - - fn description() -> Option<&'static str> { - Some("punctuation token") - } -} - -impl Synom for Literal { - fn parse(input: Cursor) -> PResult { - match input.literal() { - Some((literal, rest)) => Ok((literal, rest)), - None => parse_error(), - } - } - - fn description() -> Option<&'static str> { - Some("literal token") - } -} - -/// Parser that can parse Rust tokens into a particular syntax tree node. -/// -/// Refer to the [module documentation] for details about parsing in Syn. -/// -/// [module documentation]: index.html -/// -/// *This trait is available if Syn is built with the `"parsing"` feature.* -pub trait Parser: Sized { - type Output; - - /// Parse a proc-macro2 token stream into the chosen syntax tree node. - fn parse2(self, tokens: TokenStream) -> Result; - - /// Parse tokens of source code into the chosen syntax tree node. - /// - /// *This method is available if Syn is built with both the `"parsing"` and - /// `"proc-macro"` features.* - #[cfg(all( - not(all(target_arch = "wasm32", target_os = "unknown")), - feature = "proc-macro" - ))] - fn parse(self, tokens: proc_macro::TokenStream) -> Result { - self.parse2(tokens.into()) - } - - /// Parse a string of Rust code into the chosen syntax tree node. - /// - /// # Hygiene - /// - /// Every span in the resulting syntax tree will be set to resolve at the - /// macro call site. - fn parse_str(self, s: &str) -> Result { - match s.parse() { - Ok(tts) => self.parse2(tts), - Err(_) => Err(ParseError::new("error while lexing input string")), - } - } -} - -impl Parser for F -where - F: FnOnce(Cursor) -> PResult, -{ - type Output = T; - - fn parse2(self, tokens: TokenStream) -> Result { - let buf = TokenBuffer::new2(tokens); - let (t, rest) = self(buf.begin())?; - if rest.eof() { - Ok(t) - } else if rest == buf.begin() { - // parsed nothing - Err(ParseError::new("failed to parse anything")) - } else { - Err(ParseError::new("failed to parse all tokens")) - } - } -} - -/// Extension traits that are made available within the `call!` parser. -/// -/// *This module is available if Syn is built with the `"parsing"` feature.* -pub mod ext { - use super::*; - use proc_macro2::Ident; - - /// Additional parsing methods for `Ident`. - /// - /// This trait is sealed and cannot be implemented for types outside of Syn. - /// - /// *This trait is available if Syn is built with the `"parsing"` feature.* - pub trait IdentExt: Sized + private::Sealed { - /// Parses any identifier including keywords. - /// - /// This is useful when parsing a DSL which allows Rust keywords as - /// identifiers. - /// - /// ```rust - /// #[macro_use] - /// extern crate syn; - /// - /// use syn::Ident; - /// - /// // Parses input that looks like `name = NAME` where `NAME` can be - /// // any identifier. - /// // - /// // Examples: - /// // - /// // name = anything - /// // name = impl - /// named!(parse_dsl -> Ident, do_parse!( - /// custom_keyword!(name) >> - /// punct!(=) >> - /// name: call!(Ident::parse_any) >> - /// (name) - /// )); - /// # - /// # fn main() {} - /// ``` - fn parse_any(input: Cursor) -> PResult; - } - - impl IdentExt for Ident { - fn parse_any(input: Cursor) -> PResult { - input.ident().map_or_else(parse_error, Ok) - } - } - - mod private { - use proc_macro2::Ident; - - pub trait Sealed {} - - impl Sealed for Ident {} - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/token.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/token.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/token.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/token.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,889 +0,0 @@ -// Copyright 2018 Syn Developers -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Tokens representing Rust punctuation, keywords, and delimiters. -//! -//! The type names in this module can be difficult to keep straight, so we -//! prefer to use the [`Token!`] macro instead. This is a type-macro that -//! expands to the token type of the given token. -//! -//! [`Token!`]: ../macro.Token.html -//! -//! # Example -//! -//! The [`ItemStatic`] syntax tree node is defined like this. -//! -//! [`ItemStatic`]: ../struct.ItemStatic.html -//! -//! ``` -//! # #[macro_use] -//! # extern crate syn; -//! # -//! # use syn::{Attribute, Visibility, Ident, Type, Expr}; -//! # -//! pub struct ItemStatic { -//! pub attrs: Vec, -//! pub vis: Visibility, -//! pub static_token: Token![static], -//! pub mutability: Option, -//! pub ident: Ident, -//! pub colon_token: Token![:], -//! pub ty: Box, -//! pub eq_token: Token![=], -//! pub expr: Box, -//! pub semi_token: Token![;], -//! } -//! # -//! # fn main() {} -//! ``` -//! -//! # Parsing -//! -//! These tokens can be parsed using the [`Synom`] trait and the parser -//! combinator macros [`punct!`], [`keyword!`], [`parens!`], [`braces!`], and -//! [`brackets!`]. -//! -//! [`Synom`]: ../synom/trait.Synom.html -//! [`punct!`]: ../macro.punct.html -//! [`keyword!`]: ../macro.keyword.html -//! [`parens!`]: ../macro.parens.html -//! [`braces!`]: ../macro.braces.html -//! [`brackets!`]: ../macro.brackets.html -//! -//! ``` -//! #[macro_use] -//! extern crate syn; -//! -//! use syn::synom::Synom; -//! use syn::{Attribute, Visibility, Ident, Type, Expr}; -//! # -//! # struct ItemStatic; -//! # use syn::ItemStatic as SynItemStatic; -//! -//! // Parse the ItemStatic struct shown above. -//! impl Synom for ItemStatic { -//! named!(parse -> Self, do_parse!( -//! # (ItemStatic) -//! # )); -//! # } -//! # -//! # mod example { -//! # use super::*; -//! # use super::SynItemStatic as ItemStatic; -//! # -//! # named!(parse -> ItemStatic, do_parse!( -//! attrs: many0!(Attribute::parse_outer) >> -//! vis: syn!(Visibility) >> -//! static_token: keyword!(static) >> -//! mutability: option!(keyword!(mut)) >> -//! ident: syn!(Ident) >> -//! colon_token: punct!(:) >> -//! ty: syn!(Type) >> -//! eq_token: punct!(=) >> -//! expr: syn!(Expr) >> -//! semi_token: punct!(;) >> -//! (ItemStatic { -//! attrs, vis, static_token, mutability, ident, colon_token, -//! ty: Box::new(ty), eq_token, expr: Box::new(expr), semi_token, -//! }) -//! )); -//! } -//! # -//! # fn main() {} -//! ``` - -use proc_macro2::{Ident, Span}; - -macro_rules! tokens { - ( - punct: { - $($punct:tt pub struct $punct_name:ident/$len:tt #[$punct_doc:meta])* - } - delimiter: { - $($delimiter:tt pub struct $delimiter_name:ident #[$delimiter_doc:meta])* - } - keyword: { - $($keyword:tt pub struct $keyword_name:ident #[$keyword_doc:meta])* - } - ) => ( - $(token_punct_def! { #[$punct_doc] pub struct $punct_name/$len })* - $(token_punct_parser! { $punct pub struct $punct_name })* - $(token_delimiter! { #[$delimiter_doc] $delimiter pub struct $delimiter_name })* - $(token_keyword! { #[$keyword_doc] $keyword pub struct $keyword_name })* - ) -} - -macro_rules! token_punct_def { - (#[$doc:meta]pub struct $name:ident / $len:tt) => { - #[cfg_attr(feature = "clone-impls", derive(Copy, Clone))] - #[$doc] - /// - /// Don't try to remember the name of this type -- use the [`Token!`] - /// macro instead. - /// - /// [`Token!`]: index.html - pub struct $name(pub [Span; $len]); - - impl $name { - pub fn new(span: Span) -> Self { - $name([span; $len]) - } - } - - impl ::std::default::Default for $name { - fn default() -> Self { - $name([Span::call_site(); $len]) - } - } - - #[cfg(feature = "extra-traits")] - impl ::std::fmt::Debug for $name { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.write_str(stringify!($name)) - } - } - - #[cfg(feature = "extra-traits")] - impl ::std::cmp::Eq for $name {} - - #[cfg(feature = "extra-traits")] - impl ::std::cmp::PartialEq for $name { - fn eq(&self, _other: &$name) -> bool { - true - } - } - - #[cfg(feature = "extra-traits")] - impl ::std::hash::Hash for $name { - fn hash(&self, _state: &mut H) - where - H: ::std::hash::Hasher, - { - } - } - - impl From for $name { - fn from(span: Span) -> Self { - $name([span; $len]) - } - } - }; -} - -macro_rules! token_punct_parser { - ($s:tt pub struct $name:ident) => { - #[cfg(feature = "printing")] - impl ::quote::ToTokens for $name { - fn to_tokens(&self, tokens: &mut ::proc_macro2::TokenStream) { - printing::punct($s, &self.0, tokens); - } - } - - #[cfg(feature = "parsing")] - impl ::Synom for $name { - fn parse(tokens: $crate::buffer::Cursor) -> $crate::synom::PResult<$name> { - parsing::punct($s, tokens, $name) - } - - fn description() -> Option<&'static str> { - Some(concat!("`", $s, "`")) - } - } - }; -} - -macro_rules! token_keyword { - (#[$doc:meta] $s:tt pub struct $name:ident) => { - #[cfg_attr(feature = "clone-impls", derive(Copy, Clone))] - #[$doc] - /// - /// Don't try to remember the name of this type -- use the [`Token!`] - /// macro instead. - /// - /// [`Token!`]: index.html - pub struct $name(pub Span); - - impl ::std::default::Default for $name { - fn default() -> Self { - $name(Span::call_site()) - } - } - - #[cfg(feature = "extra-traits")] - impl ::std::fmt::Debug for $name { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.write_str(stringify!($name)) - } - } - - #[cfg(feature = "extra-traits")] - impl ::std::cmp::Eq for $name {} - - #[cfg(feature = "extra-traits")] - impl ::std::cmp::PartialEq for $name { - fn eq(&self, _other: &$name) -> bool { - true - } - } - - #[cfg(feature = "extra-traits")] - impl ::std::hash::Hash for $name { - fn hash(&self, _state: &mut H) - where - H: ::std::hash::Hasher, - { - } - } - - #[cfg(feature = "printing")] - impl ::quote::ToTokens for $name { - fn to_tokens(&self, tokens: &mut ::proc_macro2::TokenStream) { - printing::keyword($s, &self.0, tokens); - } - } - - #[cfg(feature = "parsing")] - impl ::Synom for $name { - fn parse(tokens: $crate::buffer::Cursor) -> $crate::synom::PResult<$name> { - parsing::keyword($s, tokens, $name) - } - - fn description() -> Option<&'static str> { - Some(concat!("`", $s, "`")) - } - } - - impl From for $name { - fn from(span: Span) -> Self { - $name(span) - } - } - }; -} - -macro_rules! token_delimiter { - (#[$doc:meta] $s:tt pub struct $name:ident) => { - #[cfg_attr(feature = "clone-impls", derive(Copy, Clone))] - #[$doc] - pub struct $name(pub Span); - - impl ::std::default::Default for $name { - fn default() -> Self { - $name(Span::call_site()) - } - } - - #[cfg(feature = "extra-traits")] - impl ::std::fmt::Debug for $name { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.write_str(stringify!($name)) - } - } - - #[cfg(feature = "extra-traits")] - impl ::std::cmp::Eq for $name {} - - #[cfg(feature = "extra-traits")] - impl ::std::cmp::PartialEq for $name { - fn eq(&self, _other: &$name) -> bool { - true - } - } - - #[cfg(feature = "extra-traits")] - impl ::std::hash::Hash for $name { - fn hash(&self, _state: &mut H) - where - H: ::std::hash::Hasher, - { - } - } - - impl $name { - #[cfg(feature = "printing")] - pub fn surround(&self, tokens: &mut ::proc_macro2::TokenStream, f: F) - where - F: FnOnce(&mut ::proc_macro2::TokenStream), - { - printing::delim($s, &self.0, tokens, f); - } - - #[cfg(feature = "parsing")] - pub fn parse( - tokens: $crate::buffer::Cursor, - f: F, - ) -> $crate::synom::PResult<($name, R)> - where - F: FnOnce($crate::buffer::Cursor) -> $crate::synom::PResult, - { - parsing::delim($s, tokens, $name, f) - } - } - - impl From for $name { - fn from(span: Span) -> Self { - $name(span) - } - } - }; -} - -token_punct_def! { - /// `_` - pub struct Underscore/1 -} - -#[cfg(feature = "printing")] -impl ::quote::ToTokens for Underscore { - fn to_tokens(&self, tokens: &mut ::proc_macro2::TokenStream) { - use quote::TokenStreamExt; - tokens.append(::proc_macro2::Ident::new("_", self.0[0])); - } -} - -#[cfg(feature = "parsing")] -impl ::Synom for Underscore { - fn parse(input: ::buffer::Cursor) -> ::synom::PResult { - match input.ident() { - Some((ident, rest)) => { - if ident == "_" { - Ok((Underscore([ident.span()]), rest)) - } else { - ::parse_error() - } - } - None => parsing::punct("_", input, Underscore), - } - } - - fn description() -> Option<&'static str> { - Some("`_`") - } -} - -token_punct_def! { - /// `'` - pub struct Apostrophe/1 -} - -// Implement Clone anyway because it is required for cloning Lifetime. -#[cfg(not(feature = "clone-impls"))] -impl Clone for Apostrophe { - fn clone(&self) -> Self { - Apostrophe(self.0) - } -} - -#[cfg(feature = "printing")] -impl ::quote::ToTokens for Apostrophe { - fn to_tokens(&self, tokens: &mut ::proc_macro2::TokenStream) { - use quote::TokenStreamExt; - let mut token = ::proc_macro2::Punct::new('\'', ::proc_macro2::Spacing::Joint); - token.set_span(self.0[0]); - tokens.append(token); - } -} - -#[cfg(feature = "parsing")] -impl ::Synom for Apostrophe { - fn parse(input: ::buffer::Cursor) -> ::synom::PResult { - match input.punct() { - Some((op, rest)) => { - if op.as_char() == '\'' && op.spacing() == ::proc_macro2::Spacing::Joint { - Ok((Apostrophe([op.span()]), rest)) - } else { - ::parse_error() - } - } - None => ::parse_error(), - } - } - - fn description() -> Option<&'static str> { - Some("`'`") - } -} - -tokens! { - punct: { - "+" pub struct Add/1 /// `+` - "+=" pub struct AddEq/2 /// `+=` - "&" pub struct And/1 /// `&` - "&&" pub struct AndAnd/2 /// `&&` - "&=" pub struct AndEq/2 /// `&=` - "@" pub struct At/1 /// `@` - "!" pub struct Bang/1 /// `!` - "^" pub struct Caret/1 /// `^` - "^=" pub struct CaretEq/2 /// `^=` - ":" pub struct Colon/1 /// `:` - "::" pub struct Colon2/2 /// `::` - "," pub struct Comma/1 /// `,` - "/" pub struct Div/1 /// `/` - "/=" pub struct DivEq/2 /// `/=` - "$" pub struct Dollar/1 /// `$` - "." pub struct Dot/1 /// `.` - ".." pub struct Dot2/2 /// `..` - "..." pub struct Dot3/3 /// `...` - "..=" pub struct DotDotEq/3 /// `..=` - "=" pub struct Eq/1 /// `=` - "==" pub struct EqEq/2 /// `==` - ">=" pub struct Ge/2 /// `>=` - ">" pub struct Gt/1 /// `>` - "<=" pub struct Le/2 /// `<=` - "<" pub struct Lt/1 /// `<` - "*=" pub struct MulEq/2 /// `*=` - "!=" pub struct Ne/2 /// `!=` - "|" pub struct Or/1 /// `|` - "|=" pub struct OrEq/2 /// `|=` - "||" pub struct OrOr/2 /// `||` - "#" pub struct Pound/1 /// `#` - "?" pub struct Question/1 /// `?` - "->" pub struct RArrow/2 /// `->` - "<-" pub struct LArrow/2 /// `<-` - "%" pub struct Rem/1 /// `%` - "%=" pub struct RemEq/2 /// `%=` - "=>" pub struct FatArrow/2 /// `=>` - ";" pub struct Semi/1 /// `;` - "<<" pub struct Shl/2 /// `<<` - "<<=" pub struct ShlEq/3 /// `<<=` - ">>" pub struct Shr/2 /// `>>` - ">>=" pub struct ShrEq/3 /// `>>=` - "*" pub struct Star/1 /// `*` - "-" pub struct Sub/1 /// `-` - "-=" pub struct SubEq/2 /// `-=` - } - delimiter: { - "{" pub struct Brace /// `{...}` - "[" pub struct Bracket /// `[...]` - "(" pub struct Paren /// `(...)` - " " pub struct Group /// None-delimited group - } - keyword: { - "as" pub struct As /// `as` - "async" pub struct Async /// `async` - "auto" pub struct Auto /// `auto` - "box" pub struct Box /// `box` - "break" pub struct Break /// `break` - "Self" pub struct CapSelf /// `Self` - "catch" pub struct Catch /// `catch` - "const" pub struct Const /// `const` - "continue" pub struct Continue /// `continue` - "crate" pub struct Crate /// `crate` - "default" pub struct Default /// `default` - "do" pub struct Do /// `do` - "dyn" pub struct Dyn /// `dyn` - "else" pub struct Else /// `else` - "enum" pub struct Enum /// `enum` - "extern" pub struct Extern /// `extern` - "fn" pub struct Fn /// `fn` - "for" pub struct For /// `for` - "if" pub struct If /// `if` - "impl" pub struct Impl /// `impl` - "in" pub struct In /// `in` - "let" pub struct Let /// `let` - "loop" pub struct Loop /// `loop` - "macro" pub struct Macro /// `macro` - "match" pub struct Match /// `match` - "mod" pub struct Mod /// `mod` - "move" pub struct Move /// `move` - "mut" pub struct Mut /// `mut` - "pub" pub struct Pub /// `pub` - "ref" pub struct Ref /// `ref` - "return" pub struct Return /// `return` - "self" pub struct Self_ /// `self` - "static" pub struct Static /// `static` - "struct" pub struct Struct /// `struct` - "super" pub struct Super /// `super` - "trait" pub struct Trait /// `trait` - "type" pub struct Type /// `type` - "union" pub struct Union /// `union` - "unsafe" pub struct Unsafe /// `unsafe` - "use" pub struct Use /// `use` - "where" pub struct Where /// `where` - "while" pub struct While /// `while` - "yield" pub struct Yield /// `yield` - } -} - -/// A type-macro that expands to the name of the Rust type representation of a -/// given token. -/// -/// See the [token module] documentation for details and examples. -/// -/// [token module]: token/index.html -// Unfortunate duplication due to a rustdoc bug. -// https://github.com/rust-lang/rust/issues/45939 -#[macro_export] -#[cfg_attr(rustfmt, rustfmt_skip)] -macro_rules! Token { - (+) => { $crate::token::Add }; - (+=) => { $crate::token::AddEq }; - (&) => { $crate::token::And }; - (&&) => { $crate::token::AndAnd }; - (&=) => { $crate::token::AndEq }; - (@) => { $crate::token::At }; - (!) => { $crate::token::Bang }; - (^) => { $crate::token::Caret }; - (^=) => { $crate::token::CaretEq }; - (:) => { $crate::token::Colon }; - (::) => { $crate::token::Colon2 }; - (,) => { $crate::token::Comma }; - (/) => { $crate::token::Div }; - (/=) => { $crate::token::DivEq }; - (.) => { $crate::token::Dot }; - (..) => { $crate::token::Dot2 }; - (...) => { $crate::token::Dot3 }; - (..=) => { $crate::token::DotDotEq }; - (=) => { $crate::token::Eq }; - (==) => { $crate::token::EqEq }; - (>=) => { $crate::token::Ge }; - (>) => { $crate::token::Gt }; - (<=) => { $crate::token::Le }; - (<) => { $crate::token::Lt }; - (*=) => { $crate::token::MulEq }; - (!=) => { $crate::token::Ne }; - (|) => { $crate::token::Or }; - (|=) => { $crate::token::OrEq }; - (||) => { $crate::token::OrOr }; - (#) => { $crate::token::Pound }; - (?) => { $crate::token::Question }; - (->) => { $crate::token::RArrow }; - (<-) => { $crate::token::LArrow }; - (%) => { $crate::token::Rem }; - (%=) => { $crate::token::RemEq }; - (=>) => { $crate::token::FatArrow }; - (;) => { $crate::token::Semi }; - (<<) => { $crate::token::Shl }; - (<<=) => { $crate::token::ShlEq }; - (>>) => { $crate::token::Shr }; - (>>=) => { $crate::token::ShrEq }; - (*) => { $crate::token::Star }; - (-) => { $crate::token::Sub }; - (-=) => { $crate::token::SubEq }; - (_) => { $crate::token::Underscore }; - (as) => { $crate::token::As }; - (async) => { $crate::token::Async }; - (auto) => { $crate::token::Auto }; - (box) => { $crate::token::Box }; - (break) => { $crate::token::Break }; - (Self) => { $crate::token::CapSelf }; - (catch) => { $crate::token::Catch }; - (const) => { $crate::token::Const }; - (continue) => { $crate::token::Continue }; - (crate) => { $crate::token::Crate }; - (default) => { $crate::token::Default }; - (do) => { $crate::token::Do }; - (dyn) => { $crate::token::Dyn }; - (else) => { $crate::token::Else }; - (enum) => { $crate::token::Enum }; - (extern) => { $crate::token::Extern }; - (fn) => { $crate::token::Fn }; - (for) => { $crate::token::For }; - (if) => { $crate::token::If }; - (impl) => { $crate::token::Impl }; - (in) => { $crate::token::In }; - (let) => { $crate::token::Let }; - (loop) => { $crate::token::Loop }; - (macro) => { $crate::token::Macro }; - (match) => { $crate::token::Match }; - (mod) => { $crate::token::Mod }; - (move) => { $crate::token::Move }; - (mut) => { $crate::token::Mut }; - (pub) => { $crate::token::Pub }; - (ref) => { $crate::token::Ref }; - (return) => { $crate::token::Return }; - (self) => { $crate::token::Self_ }; - (static) => { $crate::token::Static }; - (struct) => { $crate::token::Struct }; - (super) => { $crate::token::Super }; - (trait) => { $crate::token::Trait }; - (type) => { $crate::token::Type }; - (union) => { $crate::token::Union }; - (unsafe) => { $crate::token::Unsafe }; - (use) => { $crate::token::Use }; - (where) => { $crate::token::Where }; - (while) => { $crate::token::While }; - (yield) => { $crate::token::Yield }; -} - -/// Parse a single Rust punctuation token. -/// -/// See the [token module] documentation for details and examples. -/// -/// [token module]: token/index.html -/// -/// *This macro is available if Syn is built with the `"parsing"` feature.* -#[cfg(feature = "parsing")] -#[macro_export] -#[cfg_attr(rustfmt, rustfmt_skip)] -macro_rules! punct { - ($i:expr, +) => { call!($i, <$crate::token::Add as $crate::synom::Synom>::parse) }; - ($i:expr, +=) => { call!($i, <$crate::token::AddEq as $crate::synom::Synom>::parse) }; - ($i:expr, &) => { call!($i, <$crate::token::And as $crate::synom::Synom>::parse) }; - ($i:expr, &&) => { call!($i, <$crate::token::AndAnd as $crate::synom::Synom>::parse) }; - ($i:expr, &=) => { call!($i, <$crate::token::AndEq as $crate::synom::Synom>::parse) }; - ($i:expr, @) => { call!($i, <$crate::token::At as $crate::synom::Synom>::parse) }; - ($i:expr, !) => { call!($i, <$crate::token::Bang as $crate::synom::Synom>::parse) }; - ($i:expr, ^) => { call!($i, <$crate::token::Caret as $crate::synom::Synom>::parse) }; - ($i:expr, ^=) => { call!($i, <$crate::token::CaretEq as $crate::synom::Synom>::parse) }; - ($i:expr, :) => { call!($i, <$crate::token::Colon as $crate::synom::Synom>::parse) }; - ($i:expr, ::) => { call!($i, <$crate::token::Colon2 as $crate::synom::Synom>::parse) }; - ($i:expr, ,) => { call!($i, <$crate::token::Comma as $crate::synom::Synom>::parse) }; - ($i:expr, /) => { call!($i, <$crate::token::Div as $crate::synom::Synom>::parse) }; - ($i:expr, /=) => { call!($i, <$crate::token::DivEq as $crate::synom::Synom>::parse) }; - ($i:expr, .) => { call!($i, <$crate::token::Dot as $crate::synom::Synom>::parse) }; - ($i:expr, ..) => { call!($i, <$crate::token::Dot2 as $crate::synom::Synom>::parse) }; - ($i:expr, ...) => { call!($i, <$crate::token::Dot3 as $crate::synom::Synom>::parse) }; - ($i:expr, ..=) => { call!($i, <$crate::token::DotDotEq as $crate::synom::Synom>::parse) }; - ($i:expr, =) => { call!($i, <$crate::token::Eq as $crate::synom::Synom>::parse) }; - ($i:expr, ==) => { call!($i, <$crate::token::EqEq as $crate::synom::Synom>::parse) }; - ($i:expr, >=) => { call!($i, <$crate::token::Ge as $crate::synom::Synom>::parse) }; - ($i:expr, >) => { call!($i, <$crate::token::Gt as $crate::synom::Synom>::parse) }; - ($i:expr, <=) => { call!($i, <$crate::token::Le as $crate::synom::Synom>::parse) }; - ($i:expr, <) => { call!($i, <$crate::token::Lt as $crate::synom::Synom>::parse) }; - ($i:expr, *=) => { call!($i, <$crate::token::MulEq as $crate::synom::Synom>::parse) }; - ($i:expr, !=) => { call!($i, <$crate::token::Ne as $crate::synom::Synom>::parse) }; - ($i:expr, |) => { call!($i, <$crate::token::Or as $crate::synom::Synom>::parse) }; - ($i:expr, |=) => { call!($i, <$crate::token::OrEq as $crate::synom::Synom>::parse) }; - ($i:expr, ||) => { call!($i, <$crate::token::OrOr as $crate::synom::Synom>::parse) }; - ($i:expr, #) => { call!($i, <$crate::token::Pound as $crate::synom::Synom>::parse) }; - ($i:expr, ?) => { call!($i, <$crate::token::Question as $crate::synom::Synom>::parse) }; - ($i:expr, ->) => { call!($i, <$crate::token::RArrow as $crate::synom::Synom>::parse) }; - ($i:expr, <-) => { call!($i, <$crate::token::LArrow as $crate::synom::Synom>::parse) }; - ($i:expr, %) => { call!($i, <$crate::token::Rem as $crate::synom::Synom>::parse) }; - ($i:expr, %=) => { call!($i, <$crate::token::RemEq as $crate::synom::Synom>::parse) }; - ($i:expr, =>) => { call!($i, <$crate::token::FatArrow as $crate::synom::Synom>::parse) }; - ($i:expr, ;) => { call!($i, <$crate::token::Semi as $crate::synom::Synom>::parse) }; - ($i:expr, <<) => { call!($i, <$crate::token::Shl as $crate::synom::Synom>::parse) }; - ($i:expr, <<=) => { call!($i, <$crate::token::ShlEq as $crate::synom::Synom>::parse) }; - ($i:expr, >>) => { call!($i, <$crate::token::Shr as $crate::synom::Synom>::parse) }; - ($i:expr, >>=) => { call!($i, <$crate::token::ShrEq as $crate::synom::Synom>::parse) }; - ($i:expr, *) => { call!($i, <$crate::token::Star as $crate::synom::Synom>::parse) }; - ($i:expr, -) => { call!($i, <$crate::token::Sub as $crate::synom::Synom>::parse) }; - ($i:expr, -=) => { call!($i, <$crate::token::SubEq as $crate::synom::Synom>::parse) }; - ($i:expr, _) => { call!($i, <$crate::token::Underscore as $crate::synom::Synom>::parse) }; -} - -/// Parse a single Rust keyword token. -/// -/// See the [token module] documentation for details and examples. -/// -/// [token module]: token/index.html -/// -/// *This macro is available if Syn is built with the `"parsing"` feature.* -#[cfg(feature = "parsing")] -#[macro_export] -#[cfg_attr(rustfmt, rustfmt_skip)] -macro_rules! keyword { - ($i:expr, as) => { call!($i, <$crate::token::As as $crate::synom::Synom>::parse) }; - ($i:expr, async) => { call!($i, <$crate::token::Async as $crate::synom::Synom>::parse) }; - ($i:expr, auto) => { call!($i, <$crate::token::Auto as $crate::synom::Synom>::parse) }; - ($i:expr, box) => { call!($i, <$crate::token::Box as $crate::synom::Synom>::parse) }; - ($i:expr, break) => { call!($i, <$crate::token::Break as $crate::synom::Synom>::parse) }; - ($i:expr, Self) => { call!($i, <$crate::token::CapSelf as $crate::synom::Synom>::parse) }; - ($i:expr, catch) => { call!($i, <$crate::token::Catch as $crate::synom::Synom>::parse) }; - ($i:expr, const) => { call!($i, <$crate::token::Const as $crate::synom::Synom>::parse) }; - ($i:expr, continue) => { call!($i, <$crate::token::Continue as $crate::synom::Synom>::parse) }; - ($i:expr, crate) => { call!($i, <$crate::token::Crate as $crate::synom::Synom>::parse) }; - ($i:expr, default) => { call!($i, <$crate::token::Default as $crate::synom::Synom>::parse) }; - ($i:expr, do) => { call!($i, <$crate::token::Do as $crate::synom::Synom>::parse) }; - ($i:expr, dyn) => { call!($i, <$crate::token::Dyn as $crate::synom::Synom>::parse) }; - ($i:expr, else) => { call!($i, <$crate::token::Else as $crate::synom::Synom>::parse) }; - ($i:expr, enum) => { call!($i, <$crate::token::Enum as $crate::synom::Synom>::parse) }; - ($i:expr, extern) => { call!($i, <$crate::token::Extern as $crate::synom::Synom>::parse) }; - ($i:expr, fn) => { call!($i, <$crate::token::Fn as $crate::synom::Synom>::parse) }; - ($i:expr, for) => { call!($i, <$crate::token::For as $crate::synom::Synom>::parse) }; - ($i:expr, if) => { call!($i, <$crate::token::If as $crate::synom::Synom>::parse) }; - ($i:expr, impl) => { call!($i, <$crate::token::Impl as $crate::synom::Synom>::parse) }; - ($i:expr, in) => { call!($i, <$crate::token::In as $crate::synom::Synom>::parse) }; - ($i:expr, let) => { call!($i, <$crate::token::Let as $crate::synom::Synom>::parse) }; - ($i:expr, loop) => { call!($i, <$crate::token::Loop as $crate::synom::Synom>::parse) }; - ($i:expr, macro) => { call!($i, <$crate::token::Macro as $crate::synom::Synom>::parse) }; - ($i:expr, match) => { call!($i, <$crate::token::Match as $crate::synom::Synom>::parse) }; - ($i:expr, mod) => { call!($i, <$crate::token::Mod as $crate::synom::Synom>::parse) }; - ($i:expr, move) => { call!($i, <$crate::token::Move as $crate::synom::Synom>::parse) }; - ($i:expr, mut) => { call!($i, <$crate::token::Mut as $crate::synom::Synom>::parse) }; - ($i:expr, pub) => { call!($i, <$crate::token::Pub as $crate::synom::Synom>::parse) }; - ($i:expr, ref) => { call!($i, <$crate::token::Ref as $crate::synom::Synom>::parse) }; - ($i:expr, return) => { call!($i, <$crate::token::Return as $crate::synom::Synom>::parse) }; - ($i:expr, self) => { call!($i, <$crate::token::Self_ as $crate::synom::Synom>::parse) }; - ($i:expr, static) => { call!($i, <$crate::token::Static as $crate::synom::Synom>::parse) }; - ($i:expr, struct) => { call!($i, <$crate::token::Struct as $crate::synom::Synom>::parse) }; - ($i:expr, super) => { call!($i, <$crate::token::Super as $crate::synom::Synom>::parse) }; - ($i:expr, trait) => { call!($i, <$crate::token::Trait as $crate::synom::Synom>::parse) }; - ($i:expr, type) => { call!($i, <$crate::token::Type as $crate::synom::Synom>::parse) }; - ($i:expr, union) => { call!($i, <$crate::token::Union as $crate::synom::Synom>::parse) }; - ($i:expr, unsafe) => { call!($i, <$crate::token::Unsafe as $crate::synom::Synom>::parse) }; - ($i:expr, use) => { call!($i, <$crate::token::Use as $crate::synom::Synom>::parse) }; - ($i:expr, where) => { call!($i, <$crate::token::Where as $crate::synom::Synom>::parse) }; - ($i:expr, while) => { call!($i, <$crate::token::While as $crate::synom::Synom>::parse) }; - ($i:expr, yield) => { call!($i, <$crate::token::Yield as $crate::synom::Synom>::parse) }; -} - -macro_rules! ident_from_token { - ($token:ident) => { - impl From for Ident { - fn from(token: Token![$token]) -> Ident { - Ident::new(stringify!($token), token.0) - } - } - }; -} - -ident_from_token!(self); -ident_from_token!(Self); -ident_from_token!(super); -ident_from_token!(crate); -ident_from_token!(extern); - -#[cfg(feature = "parsing")] -mod parsing { - use proc_macro2::{Delimiter, Spacing, Span}; - - use buffer::Cursor; - use parse_error; - use synom::PResult; - - pub trait FromSpans: Sized { - fn from_spans(spans: &[Span]) -> Self; - } - - impl FromSpans for [Span; 1] { - fn from_spans(spans: &[Span]) -> Self { - [spans[0]] - } - } - - impl FromSpans for [Span; 2] { - fn from_spans(spans: &[Span]) -> Self { - [spans[0], spans[1]] - } - } - - impl FromSpans for [Span; 3] { - fn from_spans(spans: &[Span]) -> Self { - [spans[0], spans[1], spans[2]] - } - } - - pub fn punct<'a, T, R>(s: &str, mut tokens: Cursor<'a>, new: fn(T) -> R) -> PResult<'a, R> - where - T: FromSpans, - { - let mut spans = [Span::call_site(); 3]; - assert!(s.len() <= spans.len()); - let chars = s.chars(); - - for (i, (ch, slot)) in chars.zip(&mut spans).enumerate() { - match tokens.punct() { - Some((op, rest)) => { - if op.as_char() == ch { - if i != s.len() - 1 { - match op.spacing() { - Spacing::Joint => {} - _ => return parse_error(), - } - } - *slot = op.span(); - tokens = rest; - } else { - return parse_error(); - } - } - _ => return parse_error(), - } - } - Ok((new(T::from_spans(&spans)), tokens)) - } - - pub fn keyword<'a, T>(keyword: &str, tokens: Cursor<'a>, new: fn(Span) -> T) -> PResult<'a, T> { - if let Some((ident, rest)) = tokens.ident() { - if ident == keyword { - return Ok((new(ident.span()), rest)); - } - } - parse_error() - } - - pub fn delim<'a, F, R, T>( - delim: &str, - tokens: Cursor<'a>, - new: fn(Span) -> T, - f: F, - ) -> PResult<'a, (T, R)> - where - F: FnOnce(Cursor) -> PResult, - { - // NOTE: We should support none-delimited sequences here. - let delim = match delim { - "(" => Delimiter::Parenthesis, - "{" => Delimiter::Brace, - "[" => Delimiter::Bracket, - " " => Delimiter::None, - _ => panic!("unknown delimiter: {}", delim), - }; - - if let Some((inside, span, rest)) = tokens.group(delim) { - match f(inside) { - Ok((ret, remaining)) => { - if remaining.eof() { - return Ok(((new(span), ret), rest)); - } - } - Err(err) => return Err(err), - } - } - parse_error() - } -} - -#[cfg(feature = "printing")] -mod printing { - use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream}; - use quote::TokenStreamExt; - - pub fn punct(s: &str, spans: &[Span], tokens: &mut TokenStream) { - assert_eq!(s.len(), spans.len()); - - let mut chars = s.chars(); - let mut spans = spans.iter(); - let ch = chars.next_back().unwrap(); - let span = spans.next_back().unwrap(); - for (ch, span) in chars.zip(spans) { - let mut op = Punct::new(ch, Spacing::Joint); - op.set_span(*span); - tokens.append(op); - } - - let mut op = Punct::new(ch, Spacing::Alone); - op.set_span(*span); - tokens.append(op); - } - - pub fn keyword(s: &str, span: &Span, tokens: &mut TokenStream) { - tokens.append(Ident::new(s, *span)); - } - - pub fn delim(s: &str, span: &Span, tokens: &mut TokenStream, f: F) - where - F: FnOnce(&mut TokenStream), - { - let delim = match s { - "(" => Delimiter::Parenthesis, - "[" => Delimiter::Bracket, - "{" => Delimiter::Brace, - " " => Delimiter::None, - _ => panic!("unknown delimiter: {}", s), - }; - let mut inner = TokenStream::new(); - f(&mut inner); - let mut g = Group::new(delim, inner); - g.set_span(*span); - tokens.append(g); - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/tt.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/tt.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/tt.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/tt.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,170 +0,0 @@ -// Copyright 2018 Syn Developers -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[cfg(feature = "parsing")] -use buffer::Cursor; -#[cfg(feature = "parsing")] -use synom::PResult; -#[cfg(feature = "parsing")] -use token::{Brace, Bracket, Paren}; -#[cfg(feature = "parsing")] -use {parse_error, MacroDelimiter}; - -#[cfg(feature = "extra-traits")] -use std::hash::{Hash, Hasher}; - -#[cfg(any(feature = "parsing", feature = "extra-traits"))] -use proc_macro2::{Delimiter, TokenStream, TokenTree}; - -#[cfg(feature = "parsing")] -pub fn delimited(input: Cursor) -> PResult<(MacroDelimiter, TokenStream)> { - if let Some((TokenTree::Group(g), rest)) = input.token_tree() { - let span = g.span(); - let delimiter = match g.delimiter() { - Delimiter::Parenthesis => MacroDelimiter::Paren(Paren(span)), - Delimiter::Brace => MacroDelimiter::Brace(Brace(span)), - Delimiter::Bracket => MacroDelimiter::Bracket(Bracket(span)), - Delimiter::None => return parse_error(), - }; - - return Ok(((delimiter, g.stream().clone()), rest)); - } - parse_error() -} - -#[cfg(all(feature = "full", feature = "parsing"))] -pub fn braced(input: Cursor) -> PResult<(Brace, TokenStream)> { - if let Some((TokenTree::Group(g), rest)) = input.token_tree() { - if g.delimiter() == Delimiter::Brace { - return Ok(((Brace(g.span()), g.stream().clone()), rest)); - } - } - parse_error() -} - -#[cfg(all(feature = "full", feature = "parsing"))] -pub fn parenthesized(input: Cursor) -> PResult<(Paren, TokenStream)> { - if let Some((TokenTree::Group(g), rest)) = input.token_tree() { - if g.delimiter() == Delimiter::Parenthesis { - return Ok(((Paren(g.span()), g.stream().clone()), rest)); - } - } - parse_error() -} - -#[cfg(feature = "extra-traits")] -pub struct TokenTreeHelper<'a>(pub &'a TokenTree); - -#[cfg(feature = "extra-traits")] -impl<'a> PartialEq for TokenTreeHelper<'a> { - fn eq(&self, other: &Self) -> bool { - use proc_macro2::Spacing; - - match (self.0, other.0) { - (&TokenTree::Group(ref g1), &TokenTree::Group(ref g2)) => { - match (g1.delimiter(), g2.delimiter()) { - (Delimiter::Parenthesis, Delimiter::Parenthesis) - | (Delimiter::Brace, Delimiter::Brace) - | (Delimiter::Bracket, Delimiter::Bracket) - | (Delimiter::None, Delimiter::None) => {} - _ => return false, - } - - let s1 = g1.stream().clone().into_iter(); - let mut s2 = g2.stream().clone().into_iter(); - - for item1 in s1 { - let item2 = match s2.next() { - Some(item) => item, - None => return false, - }; - if TokenTreeHelper(&item1) != TokenTreeHelper(&item2) { - return false; - } - } - s2.next().is_none() - } - (&TokenTree::Punct(ref o1), &TokenTree::Punct(ref o2)) => { - o1.as_char() == o2.as_char() && match (o1.spacing(), o2.spacing()) { - (Spacing::Alone, Spacing::Alone) | (Spacing::Joint, Spacing::Joint) => true, - _ => false, - } - } - (&TokenTree::Literal(ref l1), &TokenTree::Literal(ref l2)) => { - l1.to_string() == l2.to_string() - } - (&TokenTree::Ident(ref s1), &TokenTree::Ident(ref s2)) => s1 == s2, - _ => false, - } - } -} - -#[cfg(feature = "extra-traits")] -impl<'a> Hash for TokenTreeHelper<'a> { - fn hash(&self, h: &mut H) { - use proc_macro2::Spacing; - - match *self.0 { - TokenTree::Group(ref g) => { - 0u8.hash(h); - match g.delimiter() { - Delimiter::Parenthesis => 0u8.hash(h), - Delimiter::Brace => 1u8.hash(h), - Delimiter::Bracket => 2u8.hash(h), - Delimiter::None => 3u8.hash(h), - } - - for item in g.stream().clone() { - TokenTreeHelper(&item).hash(h); - } - 0xffu8.hash(h); // terminator w/ a variant we don't normally hash - } - TokenTree::Punct(ref op) => { - 1u8.hash(h); - op.as_char().hash(h); - match op.spacing() { - Spacing::Alone => 0u8.hash(h), - Spacing::Joint => 1u8.hash(h), - } - } - TokenTree::Literal(ref lit) => (2u8, lit.to_string()).hash(h), - TokenTree::Ident(ref word) => (3u8, word).hash(h), - } - } -} - -#[cfg(feature = "extra-traits")] -pub struct TokenStreamHelper<'a>(pub &'a TokenStream); - -#[cfg(feature = "extra-traits")] -impl<'a> PartialEq for TokenStreamHelper<'a> { - fn eq(&self, other: &Self) -> bool { - let left = self.0.clone().into_iter().collect::>(); - let right = other.0.clone().into_iter().collect::>(); - if left.len() != right.len() { - return false; - } - for (a, b) in left.into_iter().zip(right) { - if TokenTreeHelper(&a) != TokenTreeHelper(&b) { - return false; - } - } - true - } -} - -#[cfg(feature = "extra-traits")] -impl<'a> Hash for TokenStreamHelper<'a> { - fn hash(&self, state: &mut H) { - let tts = self.0.clone().into_iter().collect::>(); - tts.len().hash(state); - for tt in tts { - TokenTreeHelper(&tt).hash(state); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/ty.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/ty.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/ty.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/ty.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,818 +0,0 @@ -// Copyright 2018 Syn Developers -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use super::*; -use proc_macro2::TokenStream; -use punctuated::Punctuated; -#[cfg(feature = "extra-traits")] -use std::hash::{Hash, Hasher}; -#[cfg(feature = "extra-traits")] -use tt::TokenStreamHelper; - -ast_enum_of_structs! { - /// The possible types that a Rust value could have. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - /// - /// # Syntax tree enum - /// - /// This type is a [syntax tree enum]. - /// - /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums - pub enum Type { - /// A dynamically sized slice type: `[T]`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Slice(TypeSlice { - pub bracket_token: token::Bracket, - pub elem: Box, - }), - - /// A fixed size array type: `[T; n]`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Array(TypeArray { - pub bracket_token: token::Bracket, - pub elem: Box, - pub semi_token: Token![;], - pub len: Expr, - }), - - /// A raw pointer type: `*const T` or `*mut T`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Ptr(TypePtr { - pub star_token: Token![*], - pub const_token: Option, - pub mutability: Option, - pub elem: Box, - }), - - /// A reference type: `&'a T` or `&'a mut T`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Reference(TypeReference { - pub and_token: Token![&], - pub lifetime: Option, - pub mutability: Option, - pub elem: Box, - }), - - /// A bare function type: `fn(usize) -> bool`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub BareFn(TypeBareFn { - pub unsafety: Option, - pub abi: Option, - pub fn_token: Token![fn], - pub lifetimes: Option, - pub paren_token: token::Paren, - pub inputs: Punctuated, - pub variadic: Option, - pub output: ReturnType, - }), - - /// The never type: `!`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Never(TypeNever { - pub bang_token: Token![!], - }), - - /// A tuple type: `(A, B, C, String)`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Tuple(TypeTuple { - pub paren_token: token::Paren, - pub elems: Punctuated, - }), - - /// A path like `std::slice::Iter`, optionally qualified with a - /// self-type as in ` as SomeTrait>::Associated`. - /// - /// Type arguments are stored in the Path itself. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Path(TypePath { - pub qself: Option, - pub path: Path, - }), - - /// A trait object type `Bound1 + Bound2 + Bound3` where `Bound` is a - /// trait or a lifetime. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub TraitObject(TypeTraitObject { - pub dyn_token: Option, - pub bounds: Punctuated, - }), - - /// An `impl Bound1 + Bound2 + Bound3` type where `Bound` is a trait or - /// a lifetime. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub ImplTrait(TypeImplTrait { - pub impl_token: Token![impl], - pub bounds: Punctuated, - }), - - /// A parenthesized type equivalent to the inner type. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Paren(TypeParen { - pub paren_token: token::Paren, - pub elem: Box, - }), - - /// A type contained within invisible delimiters. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Group(TypeGroup { - pub group_token: token::Group, - pub elem: Box, - }), - - /// Indication that a type should be inferred by the compiler: `_`. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Infer(TypeInfer { - pub underscore_token: Token![_], - }), - - /// A macro in the type position. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Macro(TypeMacro { - pub mac: Macro, - }), - - /// Tokens in type position not interpreted by Syn. - /// - /// *This type is available if Syn is built with the `"derive"` or - /// `"full"` feature.* - pub Verbatim(TypeVerbatim #manual_extra_traits { - pub tts: TokenStream, - }), - } -} - -#[cfg(feature = "extra-traits")] -impl Eq for TypeVerbatim {} - -#[cfg(feature = "extra-traits")] -impl PartialEq for TypeVerbatim { - fn eq(&self, other: &Self) -> bool { - TokenStreamHelper(&self.tts) == TokenStreamHelper(&other.tts) - } -} - -#[cfg(feature = "extra-traits")] -impl Hash for TypeVerbatim { - fn hash(&self, state: &mut H) - where - H: Hasher, - { - TokenStreamHelper(&self.tts).hash(state); - } -} - -ast_struct! { - /// The binary interface of a function: `extern "C"`. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - pub struct Abi { - pub extern_token: Token![extern], - pub name: Option, - } -} - -ast_struct! { - /// An argument in a function type: the `usize` in `fn(usize) -> bool`. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - pub struct BareFnArg { - pub name: Option<(BareFnArgName, Token![:])>, - pub ty: Type, - } -} - -ast_enum! { - /// Name of an argument in a function type: the `n` in `fn(n: usize)`. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - pub enum BareFnArgName { - /// Argument given a name. - Named(Ident), - /// Argument not given a name, matched with `_`. - Wild(Token![_]), - } -} - -ast_enum! { - /// Return type of a function signature. - /// - /// *This type is available if Syn is built with the `"derive"` or `"full"` - /// feature.* - pub enum ReturnType { - /// Return type is not specified. - /// - /// Functions default to `()` and closures default to type inference. - Default, - /// A particular type is returned. - Type(Token![->], Box), - } -} - -#[cfg(feature = "parsing")] -pub mod parsing { - use super::*; - use path::parsing::qpath; - use synom::Synom; - - impl Synom for Type { - named!(parse -> Self, call!(ambig_ty, true)); - - fn description() -> Option<&'static str> { - Some("type") - } - } - - impl Type { - /// In some positions, types may not contain the `+` character, to - /// disambiguate them. For example in the expression `1 as T`, T may not - /// contain a `+` character. - /// - /// This parser does not allow a `+`, while the default parser does. - named!(pub without_plus -> Self, call!(ambig_ty, false)); - } - - named!(ambig_ty(allow_plus: bool) -> Type, alt!( - syn!(TypeGroup) => { Type::Group } - | - // must be before TypeTuple - call!(TypeParen::parse, allow_plus) => { Type::Paren } - | - // must be before TypePath - syn!(TypeMacro) => { Type::Macro } - | - // must be before TypePath - syn!(TypeBareFn) => { Type::BareFn } - | - // must be before TypeTraitObject - call!(TypePath::parse, allow_plus) => { Type::Path } - | - // Don't try parsing more than one trait bound if we aren't allowing it. - // must be before TypeTuple - call!(TypeTraitObject::parse, allow_plus) => { Type::TraitObject } - | - syn!(TypeSlice) => { Type::Slice } - | - syn!(TypeArray) => { Type::Array } - | - syn!(TypePtr) => { Type::Ptr } - | - syn!(TypeReference) => { Type::Reference } - | - syn!(TypeNever) => { Type::Never } - | - syn!(TypeTuple) => { Type::Tuple } - | - syn!(TypeImplTrait) => { Type::ImplTrait } - | - syn!(TypeInfer) => { Type::Infer } - )); - - impl Synom for TypeSlice { - named!(parse -> Self, map!( - brackets!(syn!(Type)), - |(b, ty)| TypeSlice { - elem: Box::new(ty), - bracket_token: b, - } - )); - - fn description() -> Option<&'static str> { - Some("slice type") - } - } - - impl Synom for TypeArray { - named!(parse -> Self, map!( - brackets!(do_parse!( - elem: syn!(Type) >> - semi: punct!(;) >> - len: syn!(Expr) >> - (elem, semi, len) - )), - |(brackets, (elem, semi, len))| { - TypeArray { - elem: Box::new(elem), - len: len, - bracket_token: brackets, - semi_token: semi, - } - } - )); - - fn description() -> Option<&'static str> { - Some("array type") - } - } - - impl Synom for TypePtr { - named!(parse -> Self, do_parse!( - star: punct!(*) >> - mutability: alt!( - keyword!(const) => { |c| (None, Some(c)) } - | - keyword!(mut) => { |m| (Some(m), None) } - ) >> - target: call!(Type::without_plus) >> - (TypePtr { - const_token: mutability.1, - star_token: star, - mutability: mutability.0, - elem: Box::new(target), - }) - )); - - fn description() -> Option<&'static str> { - Some("raw pointer type") - } - } - - impl Synom for TypeReference { - named!(parse -> Self, do_parse!( - amp: punct!(&) >> - life: option!(syn!(Lifetime)) >> - mutability: option!(keyword!(mut)) >> - // & binds tighter than +, so we don't allow + here. - target: call!(Type::without_plus) >> - (TypeReference { - lifetime: life, - mutability: mutability, - elem: Box::new(target), - and_token: amp, - }) - )); - - fn description() -> Option<&'static str> { - Some("reference type") - } - } - - impl Synom for TypeBareFn { - named!(parse -> Self, do_parse!( - lifetimes: option!(syn!(BoundLifetimes)) >> - unsafety: option!(keyword!(unsafe)) >> - abi: option!(syn!(Abi)) >> - fn_: keyword!(fn) >> - parens: parens!(do_parse!( - inputs: call!(Punctuated::parse_terminated) >> - variadic: option!(cond_reduce!(inputs.empty_or_trailing(), punct!(...))) >> - (inputs, variadic) - )) >> - output: call!(ReturnType::without_plus) >> - (TypeBareFn { - unsafety: unsafety, - abi: abi, - lifetimes: lifetimes, - output: output, - variadic: (parens.1).1, - fn_token: fn_, - paren_token: parens.0, - inputs: (parens.1).0, - }) - )); - - fn description() -> Option<&'static str> { - Some("`fn` type") - } - } - - impl Synom for TypeNever { - named!(parse -> Self, map!( - punct!(!), - |b| TypeNever { bang_token: b } - )); - - fn description() -> Option<&'static str> { - Some("never type: `!`") - } - } - - impl Synom for TypeInfer { - named!(parse -> Self, map!( - punct!(_), - |u| TypeInfer { underscore_token: u } - )); - - fn description() -> Option<&'static str> { - Some("inferred type: `_`") - } - } - - impl Synom for TypeTuple { - named!(parse -> Self, do_parse!( - data: parens!(Punctuated::parse_terminated) >> - (TypeTuple { - paren_token: data.0, - elems: data.1, - }) - )); - - fn description() -> Option<&'static str> { - Some("tuple type") - } - } - - impl Synom for TypeMacro { - named!(parse -> Self, map!(syn!(Macro), |mac| TypeMacro { mac: mac })); - - fn description() -> Option<&'static str> { - Some("macro invocation") - } - } - - impl Synom for TypePath { - named!(parse -> Self, call!(Self::parse, false)); - - fn description() -> Option<&'static str> { - Some("type path") - } - } - - impl TypePath { - named!(parse(allow_plus: bool) -> Self, do_parse!( - qpath: qpath >> - parenthesized: option!(cond_reduce!( - qpath.1.segments.last().unwrap().value().arguments.is_empty(), - syn!(ParenthesizedGenericArguments) - )) >> - cond!(allow_plus, not!(punct!(+))) >> - ({ - let (qself, mut path) = qpath; - if let Some(parenthesized) = parenthesized { - let parenthesized = PathArguments::Parenthesized(parenthesized); - path.segments.last_mut().unwrap().value_mut().arguments = parenthesized; - } - TypePath { qself: qself, path: path } - }) - )); - } - - impl ReturnType { - named!(pub without_plus -> Self, call!(Self::parse, false)); - named!(parse(allow_plus: bool) -> Self, alt!( - do_parse!( - arrow: punct!(->) >> - ty: call!(ambig_ty, allow_plus) >> - (ReturnType::Type(arrow, Box::new(ty))) - ) - | - epsilon!() => { |_| ReturnType::Default } - )); - } - - impl Synom for ReturnType { - named!(parse -> Self, call!(Self::parse, true)); - - fn description() -> Option<&'static str> { - Some("return type") - } - } - - impl Synom for TypeTraitObject { - named!(parse -> Self, call!(Self::parse, true)); - - fn description() -> Option<&'static str> { - Some("trait object type") - } - } - - fn at_least_one_type(bounds: &Punctuated) -> bool { - for bound in bounds { - if let TypeParamBound::Trait(_) = *bound { - return true; - } - } - false - } - - impl TypeTraitObject { - named!(pub without_plus -> Self, call!(Self::parse, false)); - - // Only allow multiple trait references if allow_plus is true. - named!(parse(allow_plus: bool) -> Self, do_parse!( - dyn_token: option!(keyword!(dyn)) >> - bounds: alt!( - cond_reduce!(allow_plus, Punctuated::parse_terminated_nonempty) - | - syn!(TypeParamBound) => {|x| { - let mut bounds = Punctuated::new(); - bounds.push_value(x); - bounds - }} - ) >> - // Just lifetimes like `'a + 'b` is not a TraitObject. - cond_reduce!(at_least_one_type(&bounds)) >> - (TypeTraitObject { - dyn_token: dyn_token, - bounds: bounds, - }) - )); - } - - impl Synom for TypeImplTrait { - named!(parse -> Self, do_parse!( - impl_: keyword!(impl) >> - // NOTE: rust-lang/rust#34511 includes discussion about whether or - // not + should be allowed in ImplTrait directly without (). - elem: call!(Punctuated::parse_terminated_nonempty) >> - (TypeImplTrait { - impl_token: impl_, - bounds: elem, - }) - )); - - fn description() -> Option<&'static str> { - Some("`impl Trait` type") - } - } - - impl Synom for TypeGroup { - named!(parse -> Self, do_parse!( - data: grouped!(syn!(Type)) >> - (TypeGroup { - group_token: data.0, - elem: Box::new(data.1), - }) - )); - - fn description() -> Option<&'static str> { - Some("type surrounded by invisible delimiters") - } - } - - impl Synom for TypeParen { - named!(parse -> Self, call!(Self::parse, false)); - - fn description() -> Option<&'static str> { - Some("parenthesized type") - } - } - - impl TypeParen { - named!(parse(allow_plus: bool) -> Self, do_parse!( - data: parens!(syn!(Type)) >> - cond!(allow_plus, not!(punct!(+))) >> - (TypeParen { - paren_token: data.0, - elem: Box::new(data.1), - }) - )); - } - - impl Synom for BareFnArg { - named!(parse -> Self, do_parse!( - name: option!(do_parse!( - name: syn!(BareFnArgName) >> - not!(punct!(::)) >> - colon: punct!(:) >> - (name, colon) - )) >> - ty: syn!(Type) >> - (BareFnArg { - name: name, - ty: ty, - }) - )); - - fn description() -> Option<&'static str> { - Some("function type argument") - } - } - - impl Synom for BareFnArgName { - named!(parse -> Self, alt!( - map!(syn!(Ident), BareFnArgName::Named) - | - map!(punct!(_), BareFnArgName::Wild) - )); - - fn description() -> Option<&'static str> { - Some("function argument name") - } - } - - impl Synom for Abi { - named!(parse -> Self, do_parse!( - extern_: keyword!(extern) >> - name: option!(syn!(LitStr)) >> - (Abi { - extern_token: extern_, - name: name, - }) - )); - - fn description() -> Option<&'static str> { - Some("`extern` ABI qualifier") - } - } -} - -#[cfg(feature = "printing")] -mod printing { - use super::*; - use proc_macro2::TokenStream; - use quote::ToTokens; - - impl ToTokens for TypeSlice { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.bracket_token.surround(tokens, |tokens| { - self.elem.to_tokens(tokens); - }); - } - } - - impl ToTokens for TypeArray { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.bracket_token.surround(tokens, |tokens| { - self.elem.to_tokens(tokens); - self.semi_token.to_tokens(tokens); - self.len.to_tokens(tokens); - }); - } - } - - impl ToTokens for TypePtr { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.star_token.to_tokens(tokens); - match self.mutability { - Some(ref tok) => tok.to_tokens(tokens), - None => { - TokensOrDefault(&self.const_token).to_tokens(tokens); - } - } - self.elem.to_tokens(tokens); - } - } - - impl ToTokens for TypeReference { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.and_token.to_tokens(tokens); - self.lifetime.to_tokens(tokens); - self.mutability.to_tokens(tokens); - self.elem.to_tokens(tokens); - } - } - - impl ToTokens for TypeBareFn { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.lifetimes.to_tokens(tokens); - self.unsafety.to_tokens(tokens); - self.abi.to_tokens(tokens); - self.fn_token.to_tokens(tokens); - self.paren_token.surround(tokens, |tokens| { - self.inputs.to_tokens(tokens); - if let Some(ref variadic) = self.variadic { - if !self.inputs.empty_or_trailing() { - let span = variadic.0[0]; - ::new(span).to_tokens(tokens); - } - variadic.to_tokens(tokens); - } - }); - self.output.to_tokens(tokens); - } - } - - impl ToTokens for TypeNever { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.bang_token.to_tokens(tokens); - } - } - - impl ToTokens for TypeTuple { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.paren_token.surround(tokens, |tokens| { - self.elems.to_tokens(tokens); - }); - } - } - - impl ToTokens for TypePath { - fn to_tokens(&self, tokens: &mut TokenStream) { - PathTokens(&self.qself, &self.path).to_tokens(tokens); - } - } - - impl ToTokens for TypeTraitObject { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.dyn_token.to_tokens(tokens); - self.bounds.to_tokens(tokens); - } - } - - impl ToTokens for TypeImplTrait { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.impl_token.to_tokens(tokens); - self.bounds.to_tokens(tokens); - } - } - - impl ToTokens for TypeGroup { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.group_token.surround(tokens, |tokens| { - self.elem.to_tokens(tokens); - }); - } - } - - impl ToTokens for TypeParen { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.paren_token.surround(tokens, |tokens| { - self.elem.to_tokens(tokens); - }); - } - } - - impl ToTokens for TypeInfer { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.underscore_token.to_tokens(tokens); - } - } - - impl ToTokens for TypeMacro { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.mac.to_tokens(tokens); - } - } - - impl ToTokens for TypeVerbatim { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.tts.to_tokens(tokens); - } - } - - impl ToTokens for ReturnType { - fn to_tokens(&self, tokens: &mut TokenStream) { - match *self { - ReturnType::Default => {} - ReturnType::Type(ref arrow, ref ty) => { - arrow.to_tokens(tokens); - ty.to_tokens(tokens); - } - } - } - } - - impl ToTokens for BareFnArg { - fn to_tokens(&self, tokens: &mut TokenStream) { - if let Some((ref name, ref colon)) = self.name { - name.to_tokens(tokens); - colon.to_tokens(tokens); - } - self.ty.to_tokens(tokens); - } - } - - impl ToTokens for BareFnArgName { - fn to_tokens(&self, tokens: &mut TokenStream) { - match *self { - BareFnArgName::Named(ref t) => t.to_tokens(tokens), - BareFnArgName::Wild(ref t) => t.to_tokens(tokens), - } - } - } - - impl ToTokens for Abi { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.extern_token.to_tokens(tokens); - self.name.to_tokens(tokens); - } - } -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/verbatim.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/verbatim.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn/src/verbatim.rs 2018-10-24 21:38:26.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn/src/verbatim.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -use std::ops::Range; - -use buffer::Cursor; -use proc_macro2::TokenStream; -use synom::PResult; - -pub fn grab_cursor(cursor: Cursor) -> PResult { - Ok((cursor, cursor)) -} - -pub fn token_range(range: Range) -> TokenStream { - let mut tts = Vec::new(); - let mut cursor = range.start; - while cursor != range.end { - let (tt, next) = cursor.token_tree().expect("malformed token range"); - tts.push(tt); - cursor = next; - } - tts.into_iter().collect() -} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/.cargo-checksum.json rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/.cargo-checksum.json --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/.cargo-checksum.json 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/.cargo-checksum.json 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1 @@ +{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Cargo.toml":"dbbc708f123c27e504bb4d7a2511cc46f8c7d64ffab74eae60acdc13f728c979","Cargo.toml.orig":"5c3d8fe0b7e77041933882d2bace4b849291cbaae642c5426b048eb362f587b4","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"f033c371492a4769d377a8bf1a139adc7bf94ea00595b867a3e234eeab994c8c","README.md":"43062927a3e318771d5c2218e5066147b10cdd51cdeb240b06352506cfb7a72c","src/attr.rs":"4796108202ed2c89a2144039a145f20037465dd3cb9a8f8c712709082b889a5a","src/buffer.rs":"f600f012eaa26d412a3389032e2a78d319f7f1bbfe33ebf2b9d762274aad796b","src/data.rs":"5fbed19b7984502c9451cf446fd86b6489b9f6c52015421bb78c07e4ba294f03","src/derive.rs":"42a52cd1dea50473f3160c6515139bcaaf57c99962517eb2ac57abb04cd03688","src/error.rs":"aa215e0a8a98d85b970a9003565746be9fcdeb24a594b322e591d0ce74ed310b","src/expr.rs":"d0be324be2e4a4ba0e44173c8c4e0188c9ffff474f8cea5fab76e957e4b1e6cf","src/file.rs":"b1ae5b48a1937c475d57de8630d0a99326021e22b107a428342cf8b824330fbc","src/gen/fold.rs":"18795bc0a9a766dd16e78b725bc48c6cef901d12dc3452a8fde0d4f89ce227a3","src/gen/visit.rs":"eb9ff30320305576d0dd9a29c917f8d80e498e9da5f0f6b9f9067c3d0940752f","src/gen/visit_mut.rs":"e9d5ccebfd8eb9f29df68fec8beb694435a91106e48e0256c44a09787b58377d","src/gen_helper.rs":"d128fbd24fadfc5634976bdb9188c649f9905718c9c987a2839c3e6134b155a2","src/generics.rs":"0daf222a841f1965a25703855bbe17401b3edb0eb512ee96840f32940801551b","src/item.rs":"25e471c7c95ae6f6671f0a3413b526906e61fb8d345c7b2413b4edb0528fea24","src/lib.rs":"c733f5ea29df3abaeffc6762650feaaa9fc7060ab01277cb9f226d0970e1407d","src/lifetime.rs":"383cd564a452540f043858c636f19ed5b316a8c2752d83e53aacb5730307a754","src/lit.rs":"7ccdd679878c324ad47b0c29e76eb8d9e5d9b00e53cd3767060563bf7048eee9","src/mac.rs":"07c5aab9af440087315d58edeea733dda80bef0240463bf4d324c1ba1e2a272c","src/macros.rs":"c0bb8312f7ec422cb2c86ad2c20a609eb150fdcc38c74712e68214a4d6161994","src/op.rs":"7f20c79ac0ccc8cb129b550a305d8c57e58fdc2dd241f5fc1d1634450c26c32b","src/parse_quote.rs":"a3fbe5ad2cbeb967fbb8677f925431baa5303445a128c5284254b453284f21ab","src/parsers.rs":"ce324ac0882771b7ba24b110e55fbc2874be19cb7eb93fef7abcfb848d9c3a74","src/path.rs":"102ca22184ecfbfb21f9d82b49d0bc2d0d06fb792895a025dee1a435f9efee6e","src/punctuated.rs":"047cd8095cce72ed0ddae097a556c567ed0ca3294b5eac29a661669fd32a6748","src/spanned.rs":"70e8c7d953e76b1ce5330c73d7c0103c02a9b56e8dd8299c621fe0c91c615e23","src/synom.rs":"98b7fc3899099c5a0a6e659090c56a278237f9471f69f746404474eb5222e41a","src/token.rs":"20b25a6d572225f7e718a13b6e753b138ab9b8d840d31b6bfce5ed764eaaff8c","src/tt.rs":"e0541709fc8038a58156ef590f4449969a752aa96d7722beb41c097a83db5d21","src/ty.rs":"6888b6001c6f5908571684e90c73f43302d9e3a4186971caa8bbd72220d6c611","src/verbatim.rs":"40476ed104ae4cd16517c220becfc008b8ff0a0727d3be6001374d993b3f4b25"},"package":"261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741"} \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/Cargo.toml 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/Cargo.toml 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,64 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g. crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +name = "syn" +version = "0.14.9" +authors = ["David Tolnay "] +include = ["/Cargo.toml", "/src/**/*.rs", "/README.md", "/LICENSE-APACHE", "/LICENSE-MIT"] +description = "Nom parser for Rust source code" +documentation = "https://docs.rs/syn" +readme = "README.md" +categories = ["development-tools::procedural-macro-helpers"] +license = "MIT/Apache-2.0" +repository = "https://github.com/dtolnay/syn" +[package.metadata.docs.rs] +all-features = true + +[package.metadata.playground] +all-features = true + +[[example]] +name = "dump-syntax" +path = "examples/dump-syntax/main.rs" +required-features = ["full", "parsing", "extra-traits"] +[dependencies.proc-macro2] +version = "0.4.4" +default-features = false + +[dependencies.quote] +version = "0.6" +optional = true +default-features = false + +[dependencies.unicode-xid] +version = "0.1" +[dev-dependencies.rayon] +version = "1.0" + +[dev-dependencies.walkdir] +version = "2.1" + +[features] +clone-impls = [] +default = ["derive", "parsing", "printing", "clone-impls", "proc-macro"] +derive = [] +extra-traits = [] +fold = [] +full = [] +parsing = [] +printing = ["quote"] +proc-macro = ["proc-macro2/proc-macro", "quote/proc-macro"] +visit = [] +visit-mut = [] +[badges.travis-ci] +repository = "dtolnay/syn" diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/Cargo.toml.orig rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/Cargo.toml.orig --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/Cargo.toml.orig 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/Cargo.toml.orig 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,47 @@ +[package] +name = "syn" +version = "0.14.9" # don't forget to update html_root_url +authors = ["David Tolnay "] +license = "MIT/Apache-2.0" +description = "Nom parser for Rust source code" +repository = "https://github.com/dtolnay/syn" +documentation = "https://docs.rs/syn" +categories = ["development-tools::procedural-macro-helpers"] +readme = "README.md" +include = ["/Cargo.toml", "/src/**/*.rs", "/README.md", "/LICENSE-APACHE", "/LICENSE-MIT"] + +[[example]] +name = "dump-syntax" +path = "examples/dump-syntax/main.rs" +required-features = ["full", "parsing", "extra-traits"] + +[features] +default = ["derive", "parsing", "printing", "clone-impls", "proc-macro"] +derive = [] +full = [] +parsing = [] +printing = ["quote"] +visit = [] +visit-mut = [] +fold = [] +clone-impls = [] +extra-traits = [] +proc-macro = ["proc-macro2/proc-macro", "quote/proc-macro"] + +[dependencies] +proc-macro2 = { version = "0.4.4", default-features = false } +quote = { version = "0.6", optional = true, default-features = false } +unicode-xid = "0.1" + +[dev-dependencies] +rayon = "1.0" +walkdir = "2.1" + +[package.metadata.docs.rs] +all-features = true + +[package.metadata.playground] +all-features = true + +[badges] +travis-ci = { repository = "dtolnay/syn" } diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/LICENSE-APACHE rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/LICENSE-APACHE --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/LICENSE-APACHE 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/LICENSE-APACHE 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/LICENSE-MIT rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/LICENSE-MIT --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/LICENSE-MIT 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/LICENSE-MIT 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,25 @@ +Copyright (c) 2018 Syn Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/README.md rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/README.md --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/README.md 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/README.md 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,282 @@ +Nom parser for Rust source code +=============================== + +[![Build Status](https://api.travis-ci.org/dtolnay/syn.svg?branch=master)](https://travis-ci.org/dtolnay/syn) +[![Latest Version](https://img.shields.io/crates/v/syn.svg)](https://crates.io/crates/syn) +[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/syn/0.14/syn/) +[![Rustc Version 1.15+](https://img.shields.io/badge/rustc-1.15+-lightgray.svg)](https://blog.rust-lang.org/2017/02/02/Rust-1.15.html) + +Syn is a parsing library for parsing a stream of Rust tokens into a syntax tree +of Rust source code. + +Currently this library is geared toward the [custom derive] use case but +contains some APIs that may be useful for Rust procedural macros more generally. + +[custom derive]: https://github.com/rust-lang/rfcs/blob/master/text/1681-macros-1.1.md + +- **Data structures** — Syn provides a complete syntax tree that can represent + any valid Rust source code. The syntax tree is rooted at [`syn::File`] which + represents a full source file, but there are other entry points that may be + useful to procedural macros including [`syn::Item`], [`syn::Expr`] and + [`syn::Type`]. + +- **Custom derives** — Of particular interest to custom derives is + [`syn::DeriveInput`] which is any of the three legal input items to a derive + macro. An example below shows using this type in a library that can derive + implementations of a trait of your own. + +- **Parser combinators** — Parsing in Syn is built on a suite of public parser + combinator macros that you can use for parsing any token-based syntax you + dream up within a `functionlike!(...)` procedural macro. Every syntax tree + node defined by Syn is individually parsable and may be used as a building + block for custom syntaxes, or you may do it all yourself working from the most + primitive tokens. + +- **Location information** — Every token parsed by Syn is associated with a + `Span` that tracks line and column information back to the source of that + token. These spans allow a procedural macro to display detailed error messages + pointing to all the right places in the user's code. There is an example of + this below. + +- **Feature flags** — Functionality is aggressively feature gated so your + procedural macros enable only what they need, and do not pay in compile time + for all the rest. + +[`syn::File`]: https://docs.rs/syn/0.14/syn/struct.File.html +[`syn::Item`]: https://docs.rs/syn/0.14/syn/enum.Item.html +[`syn::Expr`]: https://docs.rs/syn/0.14/syn/enum.Expr.html +[`syn::Type`]: https://docs.rs/syn/0.14/syn/enum.Type.html +[`syn::DeriveInput`]: https://docs.rs/syn/0.14/syn/struct.DeriveInput.html + +If you get stuck with anything involving procedural macros in Rust I am happy to +provide help even if the issue is not related to Syn. Please file a ticket in +this repo. + +*Version requirement: Syn supports any compiler version back to Rust's very +first support for procedural macros in Rust 1.15.0. Some features especially +around error reporting are only available in newer compilers or on the nightly +channel.* + +[*Release notes*](https://github.com/dtolnay/syn/releases) + +## Example of a custom derive + +The canonical custom derive using Syn looks like this. We write an ordinary Rust +function tagged with a `proc_macro_derive` attribute and the name of the trait +we are deriving. Any time that derive appears in the user's code, the Rust +compiler passes their data structure as tokens into our macro. We get to execute +arbitrary Rust code to figure out what to do with those tokens, then hand some +tokens back to the compiler to compile into the user's crate. + +[`TokenStream`]: https://doc.rust-lang.org/proc_macro/struct.TokenStream.html + +```toml +[dependencies] +syn = "0.14" +quote = "0.6" + +[lib] +proc-macro = true +``` + +```rust +extern crate proc_macro; +extern crate syn; + +#[macro_use] +extern crate quote; + +use proc_macro::TokenStream; +use syn::DeriveInput; + +#[proc_macro_derive(MyMacro)] +pub fn my_macro(input: TokenStream) -> TokenStream { + // Parse the input tokens into a syntax tree + let input: DeriveInput = syn::parse(input).unwrap(); + + // Build the output, possibly using quasi-quotation + let expanded = quote! { + // ... + }; + + // Hand the output tokens back to the compiler + expanded.into() +} +``` + +The [`heapsize`] example directory shows a complete working Macros 1.1 +implementation of a custom derive. It works on any Rust compiler \>=1.15.0. The +example derives a `HeapSize` trait which computes an estimate of the amount of +heap memory owned by a value. + +[`heapsize`]: examples/heapsize + +```rust +pub trait HeapSize { + /// Total number of bytes of heap memory owned by `self`. + fn heap_size_of_children(&self) -> usize; +} +``` + +The custom derive allows users to write `#[derive(HeapSize)]` on data structures +in their program. + +```rust +#[derive(HeapSize)] +struct Demo<'a, T: ?Sized> { + a: Box, + b: u8, + c: &'a str, + d: String, +} +``` + +## Spans and error reporting + +The [`heapsize2`] example directory is an extension of the `heapsize` example +that demonstrates some of the hygiene and error reporting properties of Macros +2.0. This example currently requires a nightly Rust compiler \>=1.24.0-nightly +but we are working to stabilize all of the APIs involved. + +[`heapsize2`]: examples/heapsize2 + +The token-based procedural macro API provides great control over where the +compiler's error messages are displayed in user code. Consider the error the +user sees if one of their field types does not implement `HeapSize`. + +```rust +#[derive(HeapSize)] +struct Broken { + ok: String, + bad: std::thread::Thread, +} +``` + +In the Macros 1.1 string-based procedural macro world, the resulting error would +point unhelpfully to the invocation of the derive macro and not to the actual +problematic field. + +``` +error[E0599]: no method named `heap_size_of_children` found for type `std::thread::Thread` in the current scope + --> src/main.rs:4:10 + | +4 | #[derive(HeapSize)] + | ^^^^^^^^ +``` + +By tracking span information all the way through the expansion of a procedural +macro as shown in the `heapsize2` example, token-based macros in Syn are able to +trigger errors that directly pinpoint the source of the problem. + +``` +error[E0277]: the trait bound `std::thread::Thread: HeapSize` is not satisfied + --> src/main.rs:7:5 + | +7 | bad: std::thread::Thread, + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HeapSize` is not implemented for `std::thread::Thread` +``` + +## Parsing a custom syntax using combinators + +The [`lazy-static`] example directory shows the implementation of a +`functionlike!(...)` procedural macro in which the input tokens are parsed using +[`nom`]-style parser combinators. + +[`lazy-static`]: examples/lazy-static +[`nom`]: https://github.com/Geal/nom + +The example reimplements the popular `lazy_static` crate from crates.io as a +procedural macro. + +``` +lazy_static! { + static ref USERNAME: Regex = Regex::new("^[a-z0-9_-]{3,16}$").unwrap(); +} +``` + +The implementation shows how to trigger custom warnings and error messages on +the macro input. + +``` +warning: come on, pick a more creative name + --> src/main.rs:10:16 + | +10 | static ref FOO: String = "lazy_static".to_owned(); + | ^^^ +``` + +## Debugging + +When developing a procedural macro it can be helpful to look at what the +generated code looks like. Use `cargo rustc -- -Zunstable-options +--pretty=expanded` or the [`cargo expand`] subcommand. + +[`cargo expand`]: https://github.com/dtolnay/cargo-expand + +To show the expanded code for some crate that uses your procedural macro, run +`cargo expand` from that crate. To show the expanded code for one of your own +test cases, run `cargo expand --test the_test_case` where the last argument is +the name of the test file without the `.rs` extension. + +This write-up by Brandon W Maister discusses debugging in more detail: +[Debugging Rust's new Custom Derive system][debugging]. + +[debugging]: https://quodlibetor.github.io/posts/debugging-rusts-new-custom-derive-system/ + +## Optional features + +Syn puts a lot of functionality behind optional features in order to optimize +compile time for the most common use cases. The following features are +available. + +- **`derive`** *(enabled by default)* — Data structures for representing the + possible input to a custom derive, including structs and enums and types. +- **`full`** — Data structures for representing the syntax tree of all valid + Rust source code, including items and expressions. +- **`parsing`** *(enabled by default)* — Ability to parse input tokens into a + syntax tree node of a chosen type. +- **`printing`** *(enabled by default)* — Ability to print a syntax tree node as + tokens of Rust source code. +- **`visit`** — Trait for traversing a syntax tree. +- **`visit-mut`** — Trait for traversing and mutating in place a syntax tree. +- **`fold`** — Trait for transforming an owned syntax tree. +- **`clone-impls`** *(enabled by default)* — Clone impls for all syntax tree + types. +- **`extra-traits`** — Debug, Eq, PartialEq, Hash impls for all syntax tree + types. +- **`proc-macro`** *(enabled by default)* — Runtime dependency on the dynamic + library libproc_macro from rustc toolchain. + +## Nightly features + +By default Syn uses the [`proc-macro2`] crate to emulate the nightly compiler's +procedural macro API in a stable way that works all the way back to Rust 1.15.0. +This shim makes it possible to write code without regard for whether the current +compiler version supports the features we use. + +[`proc-macro2`]: https://github.com/alexcrichton/proc-macro2 + +On a nightly compiler, to eliminate the stable shim and use the compiler's +`proc-macro` directly, add `proc-macro2` to your Cargo.toml and set its +`"nightly"` feature which bypasses the stable shim. + +```toml +[dependencies] +syn = "0.14" +proc-macro2 = { version = "0.4", features = ["nightly"] } +``` + +## License + +Licensed under either of + + * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in this crate by you, as defined in the Apache-2.0 license, shall +be dual licensed as above, without any additional terms or conditions. diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/attr.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/attr.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/attr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/attr.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,554 @@ +// Copyright 2018 Syn Developers +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use super::*; +use punctuated::Punctuated; + +use std::iter; + +use proc_macro2::{Delimiter, Spacing, TokenStream, TokenTree}; + +#[cfg(feature = "extra-traits")] +use std::hash::{Hash, Hasher}; +#[cfg(feature = "extra-traits")] +use tt::TokenStreamHelper; + +ast_struct! { + /// An attribute like `#[repr(transparent)]`. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + /// + /// # Syntax + /// + /// Rust has six types of attributes. + /// + /// - Outer attributes like `#[repr(transparent)]`. These appear outside or + /// in front of the item they describe. + /// - Inner attributes like `#![feature(proc_macro)]`. These appear inside + /// of the item they describe, usually a module. + /// - Outer doc comments like `/// # Example`. + /// - Inner doc comments like `//! Please file an issue`. + /// - Outer block comments `/** # Example */`. + /// - Inner block comments `/*! Please file an issue */`. + /// + /// The `style` field of type `AttrStyle` distinguishes whether an attribute + /// is outer or inner. Doc comments and block comments are promoted to + /// attributes that have `is_sugared_doc` set to true, as this is how they + /// are processed by the compiler and by `macro_rules!` macros. + /// + /// The `path` field gives the possibly colon-delimited path against which + /// the attribute is resolved. It is equal to `"doc"` for desugared doc + /// comments. The `tts` field contains the rest of the attribute body as + /// tokens. + /// + /// ```text + /// #[derive(Copy)] #[crate::precondition x < 5] + /// ^^^^^^~~~~~~ ^^^^^^^^^^^^^^^^^^^ ~~~~~ + /// path tts path tts + /// ``` + /// + /// Use the [`interpret_meta`] method to try parsing the tokens of an + /// attribute into the structured representation that is used by convention + /// across most Rust libraries. + /// + /// [`interpret_meta`]: #method.interpret_meta + pub struct Attribute #manual_extra_traits { + pub pound_token: Token![#], + pub style: AttrStyle, + pub bracket_token: token::Bracket, + pub path: Path, + pub tts: TokenStream, + pub is_sugared_doc: bool, + } +} + +#[cfg(feature = "extra-traits")] +impl Eq for Attribute {} + +#[cfg(feature = "extra-traits")] +impl PartialEq for Attribute { + fn eq(&self, other: &Self) -> bool { + self.style == other.style + && self.pound_token == other.pound_token + && self.bracket_token == other.bracket_token + && self.path == other.path + && TokenStreamHelper(&self.tts) == TokenStreamHelper(&other.tts) + && self.is_sugared_doc == other.is_sugared_doc + } +} + +#[cfg(feature = "extra-traits")] +impl Hash for Attribute { + fn hash(&self, state: &mut H) + where + H: Hasher, + { + self.style.hash(state); + self.pound_token.hash(state); + self.bracket_token.hash(state); + self.path.hash(state); + TokenStreamHelper(&self.tts).hash(state); + self.is_sugared_doc.hash(state); + } +} + +impl Attribute { + /// Parses the tokens after the path as a [`Meta`](enum.Meta.html) if + /// possible. + pub fn interpret_meta(&self) -> Option { + let name = if self.path.segments.len() == 1 { + &self.path.segments.first().unwrap().value().ident + } else { + return None; + }; + + if self.tts.is_empty() { + return Some(Meta::Word(name.clone())); + } + + let tts = self.tts.clone().into_iter().collect::>(); + + if tts.len() == 1 { + if let Some(meta) = Attribute::extract_meta_list(name.clone(), &tts[0]) { + return Some(meta); + } + } + + if tts.len() == 2 { + if let Some(meta) = Attribute::extract_name_value(name.clone(), &tts[0], &tts[1]) { + return Some(meta); + } + } + + None + } + + fn extract_meta_list(ident: Ident, tt: &TokenTree) -> Option { + let g = match *tt { + TokenTree::Group(ref g) => g, + _ => return None, + }; + if g.delimiter() != Delimiter::Parenthesis { + return None; + } + let tokens = g.stream().clone().into_iter().collect::>(); + let nested = match list_of_nested_meta_items_from_tokens(&tokens) { + Some(n) => n, + None => return None, + }; + Some(Meta::List(MetaList { + paren_token: token::Paren(g.span()), + ident: ident, + nested: nested, + })) + } + + fn extract_name_value(ident: Ident, a: &TokenTree, b: &TokenTree) -> Option { + let a = match *a { + TokenTree::Punct(ref o) => o, + _ => return None, + }; + if a.spacing() != Spacing::Alone { + return None; + } + if a.as_char() != '=' { + return None; + } + + match *b { + TokenTree::Literal(ref l) if !l.to_string().starts_with('/') => { + Some(Meta::NameValue(MetaNameValue { + ident: ident, + eq_token: Token![=]([a.span()]), + lit: Lit::new(l.clone()), + })) + } + TokenTree::Ident(ref v) => match &v.to_string()[..] { + v @ "true" | v @ "false" => Some(Meta::NameValue(MetaNameValue { + ident: ident, + eq_token: Token![=]([a.span()]), + lit: Lit::Bool(LitBool { + value: v == "true", + span: b.span(), + }), + })), + _ => None, + }, + _ => None, + } + } +} + +fn nested_meta_item_from_tokens(tts: &[TokenTree]) -> Option<(NestedMeta, &[TokenTree])> { + assert!(!tts.is_empty()); + + match tts[0] { + TokenTree::Literal(ref lit) => { + if lit.to_string().starts_with('/') { + None + } else { + let lit = Lit::new(lit.clone()); + Some((NestedMeta::Literal(lit), &tts[1..])) + } + } + + TokenTree::Ident(ref ident) => { + if tts.len() >= 3 { + if let Some(meta) = Attribute::extract_name_value(ident.clone(), &tts[1], &tts[2]) { + return Some((NestedMeta::Meta(meta), &tts[3..])); + } + } + + if tts.len() >= 2 { + if let Some(meta) = Attribute::extract_meta_list(ident.clone(), &tts[1]) { + return Some((NestedMeta::Meta(meta), &tts[2..])); + } + } + + Some((Meta::Word(ident.clone()).into(), &tts[1..])) + } + + _ => None, + } +} + +fn list_of_nested_meta_items_from_tokens( + mut tts: &[TokenTree], +) -> Option> { + let mut nested_meta_items = Punctuated::new(); + let mut first = true; + + while !tts.is_empty() { + let prev_comma = if first { + first = false; + None + } else if let TokenTree::Punct(ref op) = tts[0] { + if op.spacing() != Spacing::Alone { + return None; + } + if op.as_char() != ',' { + return None; + } + let tok = Token![,]([op.span()]); + tts = &tts[1..]; + if tts.is_empty() { + break; + } + Some(tok) + } else { + return None; + }; + let (nested, rest) = match nested_meta_item_from_tokens(tts) { + Some(pair) => pair, + None => return None, + }; + if let Some(comma) = prev_comma { + nested_meta_items.push_punct(comma); + } + nested_meta_items.push_value(nested); + tts = rest; + } + + Some(nested_meta_items) +} + +ast_enum! { + /// Distinguishes between attributes that decorate an item and attributes + /// that are contained within an item. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + /// + /// # Outer attributes + /// + /// - `#[repr(transparent)]` + /// - `/// # Example` + /// - `/** Please file an issue */` + /// + /// # Inner attributes + /// + /// - `#![feature(proc_macro)]` + /// - `//! # Example` + /// - `/*! Please file an issue */` + #[cfg_attr(feature = "clone-impls", derive(Copy))] + pub enum AttrStyle { + Outer, + Inner(Token![!]), + } +} + +ast_enum_of_structs! { + /// Content of a compile-time structured attribute. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + /// + /// ## Word + /// + /// A meta word is like the `test` in `#[test]`. + /// + /// ## List + /// + /// A meta list is like the `derive(Copy)` in `#[derive(Copy)]`. + /// + /// ## NameValue + /// + /// A name-value meta is like the `path = "..."` in `#[path = + /// "sys/windows.rs"]`. + /// + /// # Syntax tree enum + /// + /// This type is a [syntax tree enum]. + /// + /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums + pub enum Meta { + pub Word(Ident), + /// A structured list within an attribute, like `derive(Copy, Clone)`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub List(MetaList { + pub ident: Ident, + pub paren_token: token::Paren, + pub nested: Punctuated, + }), + /// A name-value pair within an attribute, like `feature = "nightly"`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub NameValue(MetaNameValue { + pub ident: Ident, + pub eq_token: Token![=], + pub lit: Lit, + }), + } +} + +impl Meta { + /// Returns the identifier that begins this structured meta item. + /// + /// For example this would return the `test` in `#[test]`, the `derive` in + /// `#[derive(Copy)]`, and the `path` in `#[path = "sys/windows.rs"]`. + pub fn name(&self) -> Ident { + match *self { + Meta::Word(ref meta) => meta.clone(), + Meta::List(ref meta) => meta.ident.clone(), + Meta::NameValue(ref meta) => meta.ident.clone(), + } + } +} + +ast_enum_of_structs! { + /// Element of a compile-time attribute list. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + pub enum NestedMeta { + /// A structured meta item, like the `Copy` in `#[derive(Copy)]` which + /// would be a nested `Meta::Word`. + pub Meta(Meta), + + /// A Rust literal, like the `"new_name"` in `#[rename("new_name")]`. + pub Literal(Lit), + } +} + +pub trait FilterAttrs<'a> { + type Ret: Iterator; + + fn outer(self) -> Self::Ret; + fn inner(self) -> Self::Ret; +} + +impl<'a, T> FilterAttrs<'a> for T +where + T: IntoIterator, +{ + type Ret = iter::Filter bool>; + + fn outer(self) -> Self::Ret { + fn is_outer(attr: &&Attribute) -> bool { + match attr.style { + AttrStyle::Outer => true, + _ => false, + } + } + self.into_iter().filter(is_outer) + } + + fn inner(self) -> Self::Ret { + fn is_inner(attr: &&Attribute) -> bool { + match attr.style { + AttrStyle::Inner(_) => true, + _ => false, + } + } + self.into_iter().filter(is_inner) + } +} + +#[cfg(feature = "parsing")] +pub mod parsing { + use super::*; + use buffer::Cursor; + use parse_error; + use proc_macro2::{Literal, Punct, Spacing, Span, TokenTree}; + use synom::PResult; + + fn eq(span: Span) -> TokenTree { + let mut op = Punct::new('=', Spacing::Alone); + op.set_span(span); + op.into() + } + + impl Attribute { + named!(pub parse_inner -> Self, alt!( + do_parse!( + pound: punct!(#) >> + bang: punct!(!) >> + path_and_tts: brackets!(tuple!( + call!(Path::parse_mod_style), + syn!(TokenStream), + )) >> + ({ + let (bracket, (path, tts)) = path_and_tts; + + Attribute { + style: AttrStyle::Inner(bang), + path: path, + tts: tts, + is_sugared_doc: false, + pound_token: pound, + bracket_token: bracket, + } + }) + ) + | + map!( + call!(lit_doc_comment, Comment::Inner), + |lit| { + let span = lit.span(); + Attribute { + style: AttrStyle::Inner(::new(span)), + path: Ident::new("doc", span).into(), + tts: vec![ + eq(span), + lit, + ].into_iter().collect(), + is_sugared_doc: true, + pound_token: ::new(span), + bracket_token: token::Bracket(span), + } + } + ) + )); + + named!(pub parse_outer -> Self, alt!( + do_parse!( + pound: punct!(#) >> + path_and_tts: brackets!(tuple!( + call!(Path::parse_mod_style), + syn!(TokenStream), + )) >> + ({ + let (bracket, (path, tts)) = path_and_tts; + + Attribute { + style: AttrStyle::Outer, + path: path, + tts: tts, + is_sugared_doc: false, + pound_token: pound, + bracket_token: bracket, + } + }) + ) + | + map!( + call!(lit_doc_comment, Comment::Outer), + |lit| { + let span = lit.span(); + Attribute { + style: AttrStyle::Outer, + path: Ident::new("doc", span).into(), + tts: vec![ + eq(span), + lit, + ].into_iter().collect(), + is_sugared_doc: true, + pound_token: ::new(span), + bracket_token: token::Bracket(span), + } + } + ) + )); + } + + enum Comment { + Inner, + Outer, + } + + fn lit_doc_comment(input: Cursor, style: Comment) -> PResult { + match input.literal() { + Some((lit, rest)) => { + let string = lit.to_string(); + let ok = match style { + Comment::Inner => string.starts_with("//!") || string.starts_with("/*!"), + Comment::Outer => string.starts_with("///") || string.starts_with("/**"), + }; + if ok { + let mut new = Literal::string(&string); + new.set_span(lit.span()); + Ok((new.into(), rest)) + } else { + parse_error() + } + } + _ => parse_error(), + } + } +} + +#[cfg(feature = "printing")] +mod printing { + use super::*; + use proc_macro2::TokenStream; + use quote::ToTokens; + + impl ToTokens for Attribute { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.pound_token.to_tokens(tokens); + if let AttrStyle::Inner(ref b) = self.style { + b.to_tokens(tokens); + } + self.bracket_token.surround(tokens, |tokens| { + self.path.to_tokens(tokens); + self.tts.to_tokens(tokens); + }); + } + } + + impl ToTokens for MetaList { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.ident.to_tokens(tokens); + self.paren_token.surround(tokens, |tokens| { + self.nested.to_tokens(tokens); + }) + } + } + + impl ToTokens for MetaNameValue { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.ident.to_tokens(tokens); + self.eq_token.to_tokens(tokens); + self.lit.to_tokens(tokens); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/buffer.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/buffer.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/buffer.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/buffer.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,469 @@ +// Copyright 2018 Syn Developers +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! A stably addressed token buffer supporting efficient traversal based on a +//! cheaply copyable cursor. +//! +//! The [`Synom`] trait is implemented for syntax tree types that can be parsed +//! from one of these token cursors. +//! +//! [`Synom`]: ../synom/trait.Synom.html +//! +//! *This module is available if Syn is built with the `"parsing"` feature.* +//! +//! # Example +//! +//! This example shows a basic token parser for parsing a token stream without +//! using Syn's parser combinator macros. +//! +//! ``` +//! #![feature(proc_macro_diagnostic)] +//! +//! extern crate syn; +//! extern crate proc_macro; +//! +//! #[macro_use] +//! extern crate quote; +//! +//! use syn::{token, ExprTuple}; +//! use syn::buffer::{Cursor, TokenBuffer}; +//! use syn::spanned::Spanned; +//! use syn::synom::Synom; +//! use proc_macro::{Diagnostic, Span, TokenStream}; +//! +//! /// A basic token parser for parsing a token stream without using Syn's +//! /// parser combinator macros. +//! pub struct Parser<'a> { +//! cursor: Cursor<'a>, +//! } +//! +//! impl<'a> Parser<'a> { +//! pub fn new(cursor: Cursor<'a>) -> Self { +//! Parser { cursor } +//! } +//! +//! pub fn current_span(&self) -> Span { +//! self.cursor.span().unstable() +//! } +//! +//! pub fn parse(&mut self) -> Result { +//! let (val, rest) = T::parse(self.cursor) +//! .map_err(|e| match T::description() { +//! Some(desc) => { +//! self.current_span().error(format!("{}: expected {}", e, desc)) +//! } +//! None => { +//! self.current_span().error(e.to_string()) +//! } +//! })?; +//! +//! self.cursor = rest; +//! Ok(val) +//! } +//! +//! pub fn expect_eof(&mut self) -> Result<(), Diagnostic> { +//! if !self.cursor.eof() { +//! return Err(self.current_span().error("trailing characters; expected eof")); +//! } +//! +//! Ok(()) +//! } +//! } +//! +//! fn eval(input: TokenStream) -> Result { +//! let buffer = TokenBuffer::new(input); +//! let mut parser = Parser::new(buffer.begin()); +//! +//! // Parse some syntax tree types out of the input tokens. In this case we +//! // expect something like: +//! // +//! // (a, b, c) = (1, 2, 3) +//! let a = parser.parse::()?; +//! parser.parse::()?; +//! let b = parser.parse::()?; +//! parser.expect_eof()?; +//! +//! // Perform some validation and report errors. +//! let (a_len, b_len) = (a.elems.len(), b.elems.len()); +//! if a_len != b_len { +//! let diag = b.span().unstable() +//! .error(format!("expected {} element(s), got {}", a_len, b_len)) +//! .span_note(a.span().unstable(), "because of this"); +//! +//! return Err(diag); +//! } +//! +//! // Build the output tokens. +//! let out = quote! { +//! println!("All good! Received two tuples of size {}", #a_len); +//! }; +//! +//! Ok(out.into()) +//! } +//! # +//! # extern crate proc_macro2; +//! # +//! # // This method exists on proc_macro2::Span but is behind the "nightly" +//! # // feature. +//! # trait ToUnstableSpan { +//! # fn unstable(&self) -> Span; +//! # } +//! # +//! # impl ToUnstableSpan for proc_macro2::Span { +//! # fn unstable(&self) -> Span { +//! # unimplemented!() +//! # } +//! # } +//! # +//! # fn main() {} +//! ``` + +// This module is heavily commented as it contains the only unsafe code in Syn, +// and caution should be used when editing it. The public-facing interface is +// 100% safe but the implementation is fragile internally. + +#[cfg(all( + not(all(target_arch = "wasm32", target_os = "unknown")), + feature = "proc-macro" +))] +use proc_macro as pm; +use proc_macro2::{Delimiter, Ident, Literal, Span, TokenStream}; +use proc_macro2::{Group, Punct, TokenTree}; + +use std::marker::PhantomData; +use std::ptr; + +#[cfg(synom_verbose_trace)] +use std::fmt::{self, Debug}; + +/// Internal type which is used instead of `TokenTree` to represent a token tree +/// within a `TokenBuffer`. +enum Entry { + // Mimicking types from proc-macro. + Group(Span, Delimiter, TokenBuffer), + Ident(Ident), + Punct(Punct), + Literal(Literal), + // End entries contain a raw pointer to the entry from the containing + // token tree, or null if this is the outermost level. + End(*const Entry), +} + +/// A buffer that can be efficiently traversed multiple times, unlike +/// `TokenStream` which requires a deep copy in order to traverse more than +/// once. +/// +/// See the [module documentation] for an example of `TokenBuffer` in action. +/// +/// [module documentation]: index.html +/// +/// *This type is available if Syn is built with the `"parsing"` feature.* +pub struct TokenBuffer { + // NOTE: Do not derive clone on this - there are raw pointers inside which + // will be messed up. Moving the `TokenBuffer` itself is safe as the actual + // backing slices won't be moved. + data: Box<[Entry]>, +} + +impl TokenBuffer { + // NOTE: DO NOT MUTATE THE `Vec` RETURNED FROM THIS FUNCTION ONCE IT + // RETURNS, THE ADDRESS OF ITS BACKING MEMORY MUST REMAIN STABLE. + fn inner_new(stream: TokenStream, up: *const Entry) -> TokenBuffer { + // Build up the entries list, recording the locations of any Groups + // in the list to be processed later. + let mut entries = Vec::new(); + let mut seqs = Vec::new(); + for tt in stream { + match tt { + TokenTree::Ident(sym) => { + entries.push(Entry::Ident(sym)); + } + TokenTree::Punct(op) => { + entries.push(Entry::Punct(op)); + } + TokenTree::Literal(l) => { + entries.push(Entry::Literal(l)); + } + TokenTree::Group(g) => { + // Record the index of the interesting entry, and store an + // `End(null)` there temporarially. + seqs.push((entries.len(), g.span(), g.delimiter(), g.stream().clone())); + entries.push(Entry::End(ptr::null())); + } + } + } + // Add an `End` entry to the end with a reference to the enclosing token + // stream which was passed in. + entries.push(Entry::End(up)); + + // NOTE: This is done to ensure that we don't accidentally modify the + // length of the backing buffer. The backing buffer must remain at a + // constant address after this point, as we are going to store a raw + // pointer into it. + let mut entries = entries.into_boxed_slice(); + for (idx, span, delim, seq_stream) in seqs { + // We know that this index refers to one of the temporary + // `End(null)` entries, and we know that the last entry is + // `End(up)`, so the next index is also valid. + let seq_up = &entries[idx + 1] as *const Entry; + + // The end entry stored at the end of this Entry::Group should + // point to the Entry which follows the Group in the list. + let inner = Self::inner_new(seq_stream, seq_up); + entries[idx] = Entry::Group(span, delim, inner); + } + + TokenBuffer { data: entries } + } + + /// Creates a `TokenBuffer` containing all the tokens from the input + /// `TokenStream`. + /// + /// *This method is available if Syn is built with both the `"parsing"` and + /// `"proc-macro"` features.* + #[cfg(all( + not(all(target_arch = "wasm32", target_os = "unknown")), + feature = "proc-macro" + ))] + pub fn new(stream: pm::TokenStream) -> TokenBuffer { + Self::new2(stream.into()) + } + + /// Creates a `TokenBuffer` containing all the tokens from the input + /// `TokenStream`. + pub fn new2(stream: TokenStream) -> TokenBuffer { + Self::inner_new(stream, ptr::null()) + } + + /// Creates a cursor referencing the first token in the buffer and able to + /// traverse until the end of the buffer. + pub fn begin(&self) -> Cursor { + unsafe { Cursor::create(&self.data[0], &self.data[self.data.len() - 1]) } + } +} + +/// A cheaply copyable cursor into a `TokenBuffer`. +/// +/// This cursor holds a shared reference into the immutable data which is used +/// internally to represent a `TokenStream`, and can be efficiently manipulated +/// and copied around. +/// +/// An empty `Cursor` can be created directly, or one may create a `TokenBuffer` +/// object and get a cursor to its first token with `begin()`. +/// +/// Two cursors are equal if they have the same location in the same input +/// stream, and have the same scope. +/// +/// See the [module documentation] for an example of a `Cursor` in action. +/// +/// [module documentation]: index.html +/// +/// *This type is available if Syn is built with the `"parsing"` feature.* +#[derive(Copy, Clone, Eq, PartialEq)] +pub struct Cursor<'a> { + /// The current entry which the `Cursor` is pointing at. + ptr: *const Entry, + /// This is the only `Entry::End(..)` object which this cursor is allowed to + /// point at. All other `End` objects are skipped over in `Cursor::create`. + scope: *const Entry, + /// This uses the &'a reference which guarantees that these pointers are + /// still valid. + marker: PhantomData<&'a Entry>, +} + +impl<'a> Cursor<'a> { + /// Creates a cursor referencing a static empty TokenStream. + pub fn empty() -> Self { + // It's safe in this situation for us to put an `Entry` object in global + // storage, despite it not actually being safe to send across threads + // (`Ident` is a reference into a thread-local table). This is because + // this entry never includes a `Ident` object. + // + // This wrapper struct allows us to break the rules and put a `Sync` + // object in global storage. + struct UnsafeSyncEntry(Entry); + unsafe impl Sync for UnsafeSyncEntry {} + static EMPTY_ENTRY: UnsafeSyncEntry = UnsafeSyncEntry(Entry::End(0 as *const Entry)); + + Cursor { + ptr: &EMPTY_ENTRY.0, + scope: &EMPTY_ENTRY.0, + marker: PhantomData, + } + } + + /// This create method intelligently exits non-explicitly-entered + /// `None`-delimited scopes when the cursor reaches the end of them, + /// allowing for them to be treated transparently. + unsafe fn create(mut ptr: *const Entry, scope: *const Entry) -> Self { + // NOTE: If we're looking at a `End(..)`, we want to advance the cursor + // past it, unless `ptr == scope`, which means that we're at the edge of + // our cursor's scope. We should only have `ptr != scope` at the exit + // from None-delimited groups entered with `ignore_none`. + while let Entry::End(exit) = *ptr { + if ptr == scope { + break; + } + ptr = exit; + } + + Cursor { + ptr: ptr, + scope: scope, + marker: PhantomData, + } + } + + /// Get the current entry. + fn entry(self) -> &'a Entry { + unsafe { &*self.ptr } + } + + /// Bump the cursor to point at the next token after the current one. This + /// is undefined behavior if the cursor is currently looking at an + /// `Entry::End`. + unsafe fn bump(self) -> Cursor<'a> { + Cursor::create(self.ptr.offset(1), self.scope) + } + + /// If the cursor is looking at a `None`-delimited group, move it to look at + /// the first token inside instead. If the group is empty, this will move + /// the cursor past the `None`-delimited group. + /// + /// WARNING: This mutates its argument. + fn ignore_none(&mut self) { + if let Entry::Group(_, Delimiter::None, ref buf) = *self.entry() { + // NOTE: We call `Cursor::create` here to make sure that situations + // where we should immediately exit the span after entering it are + // handled correctly. + unsafe { + *self = Cursor::create(&buf.data[0], self.scope); + } + } + } + + /// Checks whether the cursor is currently pointing at the end of its valid + /// scope. + #[inline] + pub fn eof(self) -> bool { + // We're at eof if we're at the end of our scope. + self.ptr == self.scope + } + + /// If the cursor is pointing at a `Group` with the given delimiter, returns + /// a cursor into that group and one pointing to the next `TokenTree`. + pub fn group(mut self, delim: Delimiter) -> Option<(Cursor<'a>, Span, Cursor<'a>)> { + // If we're not trying to enter a none-delimited group, we want to + // ignore them. We have to make sure to _not_ ignore them when we want + // to enter them, of course. For obvious reasons. + if delim != Delimiter::None { + self.ignore_none(); + } + + if let Entry::Group(span, group_delim, ref buf) = *self.entry() { + if group_delim == delim { + return Some((buf.begin(), span, unsafe { self.bump() })); + } + } + + None + } + + /// If the cursor is pointing at a `Ident`, returns it along with a cursor + /// pointing at the next `TokenTree`. + pub fn ident(mut self) -> Option<(Ident, Cursor<'a>)> { + self.ignore_none(); + match *self.entry() { + Entry::Ident(ref ident) => Some((ident.clone(), unsafe { self.bump() })), + _ => None, + } + } + + /// If the cursor is pointing at an `Punct`, returns it along with a cursor + /// pointing at the next `TokenTree`. + pub fn punct(mut self) -> Option<(Punct, Cursor<'a>)> { + self.ignore_none(); + match *self.entry() { + Entry::Punct(ref op) => Some((op.clone(), unsafe { self.bump() })), + _ => None, + } + } + + /// If the cursor is pointing at a `Literal`, return it along with a cursor + /// pointing at the next `TokenTree`. + pub fn literal(mut self) -> Option<(Literal, Cursor<'a>)> { + self.ignore_none(); + match *self.entry() { + Entry::Literal(ref lit) => Some((lit.clone(), unsafe { self.bump() })), + _ => None, + } + } + + /// Copies all remaining tokens visible from this cursor into a + /// `TokenStream`. + pub fn token_stream(self) -> TokenStream { + let mut tts = Vec::new(); + let mut cursor = self; + while let Some((tt, rest)) = cursor.token_tree() { + tts.push(tt); + cursor = rest; + } + tts.into_iter().collect() + } + + /// If the cursor is pointing at a `TokenTree`, returns it along with a + /// cursor pointing at the next `TokenTree`. + /// + /// Returns `None` if the cursor has reached the end of its stream. + /// + /// This method does not treat `None`-delimited groups as transparent, and + /// will return a `Group(None, ..)` if the cursor is looking at one. + pub fn token_tree(self) -> Option<(TokenTree, Cursor<'a>)> { + let tree = match *self.entry() { + Entry::Group(span, delim, ref buf) => { + let stream = buf.begin().token_stream(); + let mut g = Group::new(delim, stream); + g.set_span(span); + TokenTree::from(g) + } + Entry::Literal(ref lit) => lit.clone().into(), + Entry::Ident(ref ident) => ident.clone().into(), + Entry::Punct(ref op) => op.clone().into(), + Entry::End(..) => { + return None; + } + }; + + Some((tree, unsafe { self.bump() })) + } + + /// Returns the `Span` of the current token, or `Span::call_site()` if this + /// cursor points to eof. + pub fn span(self) -> Span { + match *self.entry() { + Entry::Group(span, ..) => span, + Entry::Literal(ref l) => l.span(), + Entry::Ident(ref t) => t.span(), + Entry::Punct(ref o) => o.span(), + Entry::End(..) => Span::call_site(), + } + } +} + +// We do a custom implementation for `Debug` as the default implementation is +// pretty useless. +#[cfg(synom_verbose_trace)] +impl<'a> Debug for Cursor<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + // Print what the cursor is currently looking at. + // This will look like Cursor("some remaining tokens here") + f.debug_tuple("Cursor") + .field(&self.token_stream().to_string()) + .finish() + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/data.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/data.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/data.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/data.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,415 @@ +// Copyright 2018 Syn Developers +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use super::*; +use punctuated::Punctuated; + +ast_struct! { + /// An enum variant. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + pub struct Variant { + /// Attributes tagged on the variant. + pub attrs: Vec, + + /// Name of the variant. + pub ident: Ident, + + /// Content stored in the variant. + pub fields: Fields, + + /// Explicit discriminant: `Variant = 1` + pub discriminant: Option<(Token![=], Expr)>, + } +} + +ast_enum_of_structs! { + /// Data stored within an enum variant or struct. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + /// + /// # Syntax tree enum + /// + /// This type is a [syntax tree enum]. + /// + /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums + pub enum Fields { + /// Named fields of a struct or struct variant such as `Point { x: f64, + /// y: f64 }`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Named(FieldsNamed { + pub brace_token: token::Brace, + pub named: Punctuated, + }), + + /// Unnamed fields of a tuple struct or tuple variant such as `Some(T)`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Unnamed(FieldsUnnamed { + pub paren_token: token::Paren, + pub unnamed: Punctuated, + }), + + /// Unit struct or unit variant such as `None`. + pub Unit, + } +} + +impl Fields { + /// Get an iterator over the borrowed [`Field`] items in this object. This + /// iterator can be used to iterate over a named or unnamed struct or + /// variant's fields uniformly. + /// + /// [`Field`]: struct.Field.html + pub fn iter(&self) -> punctuated::Iter { + match *self { + Fields::Unit => punctuated::Iter::private_empty(), + Fields::Named(ref f) => f.named.iter(), + Fields::Unnamed(ref f) => f.unnamed.iter(), + } + } + + /// Get an iterator over the mutably borrowed [`Field`] items in this + /// object. This iterator can be used to iterate over a named or unnamed + /// struct or variant's fields uniformly. + /// + /// [`Field`]: struct.Field.html + pub fn iter_mut(&mut self) -> punctuated::IterMut { + match *self { + Fields::Unit => punctuated::IterMut::private_empty(), + Fields::Named(ref mut f) => f.named.iter_mut(), + Fields::Unnamed(ref mut f) => f.unnamed.iter_mut(), + } + } +} + +impl<'a> IntoIterator for &'a Fields { + type Item = &'a Field; + type IntoIter = punctuated::Iter<'a, Field>; + + fn into_iter(self) -> Self::IntoIter { + self.iter() + } +} + +impl<'a> IntoIterator for &'a mut Fields { + type Item = &'a mut Field; + type IntoIter = punctuated::IterMut<'a, Field>; + + fn into_iter(self) -> Self::IntoIter { + self.iter_mut() + } +} + +ast_struct! { + /// A field of a struct or enum variant. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + pub struct Field { + /// Attributes tagged on the field. + pub attrs: Vec, + + /// Visibility of the field. + pub vis: Visibility, + + /// Name of the field, if any. + /// + /// Fields of tuple structs have no names. + pub ident: Option, + + pub colon_token: Option, + + /// Type of the field. + pub ty: Type, + } +} + +ast_enum_of_structs! { + /// The visibility level of an item: inherited or `pub` or + /// `pub(restricted)`. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + /// + /// # Syntax tree enum + /// + /// This type is a [syntax tree enum]. + /// + /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums + pub enum Visibility { + /// A public visibility level: `pub`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Public(VisPublic { + pub pub_token: Token![pub], + }), + + /// A crate-level visibility: `crate`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Crate(VisCrate { + pub crate_token: Token![crate], + }), + + /// A visibility level restricted to some path: `pub(self)` or + /// `pub(super)` or `pub(crate)` or `pub(in some::module)`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Restricted(VisRestricted { + pub pub_token: Token![pub], + pub paren_token: token::Paren, + pub in_token: Option, + pub path: Box, + }), + + /// An inherited visibility, which usually means private. + pub Inherited, + } +} + +#[cfg(feature = "parsing")] +pub mod parsing { + use super::*; + + use synom::Synom; + + impl Synom for Variant { + named!(parse -> Self, do_parse!( + attrs: many0!(Attribute::parse_outer) >> + id: syn!(Ident) >> + fields: alt!( + syn!(FieldsNamed) => { Fields::Named } + | + syn!(FieldsUnnamed) => { Fields::Unnamed } + | + epsilon!() => { |_| Fields::Unit } + ) >> + disr: option!(tuple!(punct!(=), syn!(Expr))) >> + (Variant { + ident: id, + attrs: attrs, + fields: fields, + discriminant: disr, + }) + )); + + fn description() -> Option<&'static str> { + Some("enum variant") + } + } + + impl Synom for FieldsNamed { + named!(parse -> Self, map!( + braces!(call!(Punctuated::parse_terminated_with, Field::parse_named)), + |(brace, fields)| FieldsNamed { + brace_token: brace, + named: fields, + } + )); + + fn description() -> Option<&'static str> { + Some("named fields in a struct or struct variant") + } + } + + impl Synom for FieldsUnnamed { + named!(parse -> Self, map!( + parens!(call!(Punctuated::parse_terminated_with, Field::parse_unnamed)), + |(paren, fields)| FieldsUnnamed { + paren_token: paren, + unnamed: fields, + } + )); + + fn description() -> Option<&'static str> { + Some("unnamed fields in a tuple struct or tuple variant") + } + } + + impl Field { + named!(pub parse_named -> Self, do_parse!( + attrs: many0!(Attribute::parse_outer) >> + vis: syn!(Visibility) >> + id: syn!(Ident) >> + colon: punct!(:) >> + ty: syn!(Type) >> + (Field { + ident: Some(id), + vis: vis, + attrs: attrs, + ty: ty, + colon_token: Some(colon), + }) + )); + + named!(pub parse_unnamed -> Self, do_parse!( + attrs: many0!(Attribute::parse_outer) >> + vis: syn!(Visibility) >> + ty: syn!(Type) >> + (Field { + ident: None, + colon_token: None, + vis: vis, + attrs: attrs, + ty: ty, + }) + )); + } + + impl Synom for Visibility { + named!(parse -> Self, alt!( + do_parse!( + pub_token: keyword!(pub) >> + other: parens!(keyword!(crate)) >> + (Visibility::Restricted(VisRestricted { + pub_token: pub_token, + paren_token: other.0, + in_token: None, + path: Box::new(other.1.into()), + })) + ) + | + do_parse!( + crate_token: keyword!(crate) >> + not!(punct!(::)) >> + (Visibility::Crate(VisCrate { + crate_token: crate_token, + })) + ) + | + do_parse!( + pub_token: keyword!(pub) >> + other: parens!(keyword!(self)) >> + (Visibility::Restricted(VisRestricted { + pub_token: pub_token, + paren_token: other.0, + in_token: None, + path: Box::new(other.1.into()), + })) + ) + | + do_parse!( + pub_token: keyword!(pub) >> + other: parens!(keyword!(super)) >> + (Visibility::Restricted(VisRestricted { + pub_token: pub_token, + paren_token: other.0, + in_token: None, + path: Box::new(other.1.into()), + })) + ) + | + do_parse!( + pub_token: keyword!(pub) >> + other: parens!(do_parse!( + in_tok: keyword!(in) >> + restricted: call!(Path::parse_mod_style) >> + (in_tok, restricted) + )) >> + (Visibility::Restricted(VisRestricted { + pub_token: pub_token, + paren_token: other.0, + in_token: Some((other.1).0), + path: Box::new((other.1).1), + })) + ) + | + keyword!(pub) => { |tok| { + Visibility::Public(VisPublic { + pub_token: tok, + }) + } } + | + epsilon!() => { |_| Visibility::Inherited } + )); + + fn description() -> Option<&'static str> { + Some("visibility qualifier such as `pub`") + } + } +} + +#[cfg(feature = "printing")] +mod printing { + use super::*; + use proc_macro2::TokenStream; + use quote::{ToTokens, TokenStreamExt}; + + impl ToTokens for Variant { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(&self.attrs); + self.ident.to_tokens(tokens); + self.fields.to_tokens(tokens); + if let Some((ref eq_token, ref disc)) = self.discriminant { + eq_token.to_tokens(tokens); + disc.to_tokens(tokens); + } + } + } + + impl ToTokens for FieldsNamed { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.brace_token.surround(tokens, |tokens| { + self.named.to_tokens(tokens); + }); + } + } + + impl ToTokens for FieldsUnnamed { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.paren_token.surround(tokens, |tokens| { + self.unnamed.to_tokens(tokens); + }); + } + } + + impl ToTokens for Field { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(&self.attrs); + self.vis.to_tokens(tokens); + if let Some(ref ident) = self.ident { + ident.to_tokens(tokens); + TokensOrDefault(&self.colon_token).to_tokens(tokens); + } + self.ty.to_tokens(tokens); + } + } + + impl ToTokens for VisPublic { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.pub_token.to_tokens(tokens) + } + } + + impl ToTokens for VisCrate { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.crate_token.to_tokens(tokens); + } + } + + impl ToTokens for VisRestricted { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.pub_token.to_tokens(tokens); + self.paren_token.surround(tokens, |tokens| { + // XXX: If we have a path which is not "self" or "super" or + // "crate", automatically add the "in" token. + self.in_token.to_tokens(tokens); + self.path.to_tokens(tokens); + }); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/derive.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/derive.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/derive.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/derive.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,242 @@ +// Copyright 2018 Syn Developers +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use super::*; +use punctuated::Punctuated; + +ast_struct! { + /// Data structure sent to a `proc_macro_derive` macro. + /// + /// *This type is available if Syn is built with the `"derive"` feature.* + pub struct DeriveInput { + /// Attributes tagged on the whole struct or enum. + pub attrs: Vec, + + /// Visibility of the struct or enum. + pub vis: Visibility, + + /// Name of the struct or enum. + pub ident: Ident, + + /// Generics required to complete the definition. + pub generics: Generics, + + /// Data within the struct or enum. + pub data: Data, + } +} + +ast_enum_of_structs! { + /// The storage of a struct, enum or union data structure. + /// + /// *This type is available if Syn is built with the `"derive"` feature.* + /// + /// # Syntax tree enum + /// + /// This type is a [syntax tree enum]. + /// + /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums + pub enum Data { + /// A struct input to a `proc_macro_derive` macro. + /// + /// *This type is available if Syn is built with the `"derive"` + /// feature.* + pub Struct(DataStruct { + pub struct_token: Token![struct], + pub fields: Fields, + pub semi_token: Option, + }), + + /// An enum input to a `proc_macro_derive` macro. + /// + /// *This type is available if Syn is built with the `"derive"` + /// feature.* + pub Enum(DataEnum { + pub enum_token: Token![enum], + pub brace_token: token::Brace, + pub variants: Punctuated, + }), + + /// A tagged union input to a `proc_macro_derive` macro. + /// + /// *This type is available if Syn is built with the `"derive"` + /// feature.* + pub Union(DataUnion { + pub union_token: Token![union], + pub fields: FieldsNamed, + }), + } + + do_not_generate_to_tokens +} + +#[cfg(feature = "parsing")] +pub mod parsing { + use super::*; + + use synom::Synom; + + enum DeriveInputKind { + Struct(Token![struct]), + Enum(Token![enum]), + Union(Token![union]), + } + + impl Synom for DeriveInputKind { + named!(parse -> Self, alt!( + keyword!(struct) => { DeriveInputKind::Struct } + | + keyword!(enum) => { DeriveInputKind::Enum } + | + keyword!(union) => { DeriveInputKind::Union } + )); + } + + impl Synom for DeriveInput { + named!(parse -> Self, do_parse!( + attrs: many0!(Attribute::parse_outer) >> + vis: syn!(Visibility) >> + which: syn!(DeriveInputKind) >> + id: syn!(Ident) >> + generics: syn!(Generics) >> + item: switch!(value!(which), + DeriveInputKind::Struct(s) => map!(data_struct, move |(wh, fields, semi)| DeriveInput { + ident: id, + vis: vis, + attrs: attrs, + generics: Generics { + where_clause: wh, + ..generics + }, + data: Data::Struct(DataStruct { + struct_token: s, + fields: fields, + semi_token: semi, + }), + }) + | + DeriveInputKind::Enum(e) => map!(data_enum, move |(wh, brace, variants)| DeriveInput { + ident: id, + vis: vis, + attrs: attrs, + generics: Generics { + where_clause: wh, + ..generics + }, + data: Data::Enum(DataEnum { + variants: variants, + brace_token: brace, + enum_token: e, + }), + }) + | + DeriveInputKind::Union(u) => map!(data_union, move |(wh, fields)| DeriveInput { + ident: id, + vis: vis, + attrs: attrs, + generics: Generics { + where_clause: wh, + ..generics + }, + data: Data::Union(DataUnion { + union_token: u, + fields: fields, + }), + }) + ) >> + (item) + )); + + fn description() -> Option<&'static str> { + Some("derive input") + } + } + + named!(data_struct -> (Option, Fields, Option), alt!( + do_parse!( + wh: option!(syn!(WhereClause)) >> + fields: syn!(FieldsNamed) >> + (wh, Fields::Named(fields), None) + ) + | + do_parse!( + fields: syn!(FieldsUnnamed) >> + wh: option!(syn!(WhereClause)) >> + semi: punct!(;) >> + (wh, Fields::Unnamed(fields), Some(semi)) + ) + | + do_parse!( + wh: option!(syn!(WhereClause)) >> + semi: punct!(;) >> + (wh, Fields::Unit, Some(semi)) + ) + )); + + named!(data_enum -> (Option, token::Brace, Punctuated), do_parse!( + wh: option!(syn!(WhereClause)) >> + data: braces!(Punctuated::parse_terminated) >> + (wh, data.0, data.1) + )); + + named!(data_union -> (Option, FieldsNamed), tuple!( + option!(syn!(WhereClause)), + syn!(FieldsNamed), + )); +} + +#[cfg(feature = "printing")] +mod printing { + use super::*; + use attr::FilterAttrs; + use proc_macro2::TokenStream; + use quote::ToTokens; + + impl ToTokens for DeriveInput { + fn to_tokens(&self, tokens: &mut TokenStream) { + for attr in self.attrs.outer() { + attr.to_tokens(tokens); + } + self.vis.to_tokens(tokens); + match self.data { + Data::Struct(ref d) => d.struct_token.to_tokens(tokens), + Data::Enum(ref d) => d.enum_token.to_tokens(tokens), + Data::Union(ref d) => d.union_token.to_tokens(tokens), + } + self.ident.to_tokens(tokens); + self.generics.to_tokens(tokens); + match self.data { + Data::Struct(ref data) => match data.fields { + Fields::Named(ref fields) => { + self.generics.where_clause.to_tokens(tokens); + fields.to_tokens(tokens); + } + Fields::Unnamed(ref fields) => { + fields.to_tokens(tokens); + self.generics.where_clause.to_tokens(tokens); + TokensOrDefault(&data.semi_token).to_tokens(tokens); + } + Fields::Unit => { + self.generics.where_clause.to_tokens(tokens); + TokensOrDefault(&data.semi_token).to_tokens(tokens); + } + }, + Data::Enum(ref data) => { + self.generics.where_clause.to_tokens(tokens); + data.brace_token.surround(tokens, |tokens| { + data.variants.to_tokens(tokens); + }); + } + Data::Union(ref data) => { + self.generics.where_clause.to_tokens(tokens); + data.fields.to_tokens(tokens); + } + } + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/error.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/error.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/error.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/error.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,60 @@ +// Copyright 2018 Syn Developers +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use buffer::Cursor; +use std::error::Error; +use std::fmt::{self, Display}; + +/// The result of a `Synom` parser. +/// +/// Refer to the [module documentation] for details about parsing in Syn. +/// +/// [module documentation]: index.html +/// +/// *This type is available if Syn is built with the `"parsing"` feature.* +pub type PResult<'a, O> = Result<(O, Cursor<'a>), ParseError>; + +/// An error with a default error message. +/// +/// NOTE: We should provide better error messages in the future. +pub fn parse_error<'a, O>() -> PResult<'a, O> { + Err(ParseError(None)) +} + +/// Error returned when a `Synom` parser cannot parse the input tokens. +/// +/// Refer to the [module documentation] for details about parsing in Syn. +/// +/// [module documentation]: index.html +/// +/// *This type is available if Syn is built with the `"parsing"` feature.* +#[derive(Debug)] +pub struct ParseError(Option); + +impl Error for ParseError { + fn description(&self) -> &str { + match self.0 { + Some(ref desc) => desc, + None => "failed to parse", + } + } +} + +impl Display for ParseError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + Display::fmt(self.description(), f) + } +} + +impl ParseError { + // For syn use only. Not public API. + #[doc(hidden)] + pub fn new>(msg: T) -> Self { + ParseError(Some(msg.into())) + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/expr.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/expr.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/expr.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/expr.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,3836 @@ +// Copyright 2018 Syn Developers +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use super::*; +use proc_macro2::{Span, TokenStream}; +use punctuated::Punctuated; +#[cfg(feature = "extra-traits")] +use std::hash::{Hash, Hasher}; +#[cfg(feature = "full")] +use std::mem; +#[cfg(feature = "extra-traits")] +use tt::TokenStreamHelper; + +ast_enum_of_structs! { + /// A Rust expression. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + /// + /// # Syntax tree enums + /// + /// This type is a syntax tree enum. In Syn this and other syntax tree enums + /// are designed to be traversed using the following rebinding idiom. + /// + /// ``` + /// # use syn::Expr; + /// # + /// # fn example(expr: Expr) { + /// # const IGNORE: &str = stringify! { + /// let expr: Expr = /* ... */; + /// # }; + /// match expr { + /// Expr::MethodCall(expr) => { + /// /* ... */ + /// } + /// Expr::Cast(expr) => { + /// /* ... */ + /// } + /// Expr::IfLet(expr) => { + /// /* ... */ + /// } + /// /* ... */ + /// # _ => {} + /// } + /// # } + /// ``` + /// + /// We begin with a variable `expr` of type `Expr` that has no fields + /// (because it is an enum), and by matching on it and rebinding a variable + /// with the same name `expr` we effectively imbue our variable with all of + /// the data fields provided by the variant that it turned out to be. So for + /// example above if we ended up in the `MethodCall` case then we get to use + /// `expr.receiver`, `expr.args` etc; if we ended up in the `IfLet` case we + /// get to use `expr.pat`, `expr.then_branch`, `expr.else_branch`. + /// + /// The pattern is similar if the input expression is borrowed: + /// + /// ``` + /// # use syn::Expr; + /// # + /// # fn example(expr: &Expr) { + /// match *expr { + /// Expr::MethodCall(ref expr) => { + /// # } + /// # _ => {} + /// # } + /// # } + /// ``` + /// + /// This approach avoids repeating the variant names twice on every line. + /// + /// ``` + /// # use syn::{Expr, ExprMethodCall}; + /// # + /// # fn example(expr: Expr) { + /// # match expr { + /// Expr::MethodCall(ExprMethodCall { method, args, .. }) => { // repetitive + /// # } + /// # _ => {} + /// # } + /// # } + /// ``` + /// + /// In general, the name to which a syntax tree enum variant is bound should + /// be a suitable name for the complete syntax tree enum type. + /// + /// ``` + /// # use syn::{Expr, ExprField}; + /// # + /// # fn example(discriminant: &ExprField) { + /// // Binding is called `base` which is the name I would use if I were + /// // assigning `*discriminant.base` without an `if let`. + /// if let Expr::Tuple(ref base) = *discriminant.base { + /// # } + /// # } + /// ``` + /// + /// A sign that you may not be choosing the right variable names is if you + /// see names getting repeated in your code, like accessing + /// `receiver.receiver` or `pat.pat` or `cond.cond`. + pub enum Expr { + /// A box expression: `box f`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Box(ExprBox #full { + pub attrs: Vec, + pub box_token: Token![box], + pub expr: Box, + }), + + /// A placement expression: `place <- value`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub InPlace(ExprInPlace #full { + pub attrs: Vec, + pub place: Box, + pub arrow_token: Token![<-], + pub value: Box, + }), + + /// A slice literal expression: `[a, b, c, d]`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Array(ExprArray #full { + pub attrs: Vec, + pub bracket_token: token::Bracket, + pub elems: Punctuated, + }), + + /// A function call expression: `invoke(a, b)`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Call(ExprCall { + pub attrs: Vec, + pub func: Box, + pub paren_token: token::Paren, + pub args: Punctuated, + }), + + /// A method call expression: `x.foo::(a, b)`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub MethodCall(ExprMethodCall #full { + pub attrs: Vec, + pub receiver: Box, + pub dot_token: Token![.], + pub method: Ident, + pub turbofish: Option, + pub paren_token: token::Paren, + pub args: Punctuated, + }), + + /// A tuple expression: `(a, b, c, d)`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Tuple(ExprTuple #full { + pub attrs: Vec, + pub paren_token: token::Paren, + pub elems: Punctuated, + }), + + /// A binary operation: `a + b`, `a * b`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Binary(ExprBinary { + pub attrs: Vec, + pub left: Box, + pub op: BinOp, + pub right: Box, + }), + + /// A unary operation: `!x`, `*x`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Unary(ExprUnary { + pub attrs: Vec, + pub op: UnOp, + pub expr: Box, + }), + + /// A literal in place of an expression: `1`, `"foo"`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Lit(ExprLit { + pub attrs: Vec, + pub lit: Lit, + }), + + /// A cast expression: `foo as f64`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Cast(ExprCast { + pub attrs: Vec, + pub expr: Box, + pub as_token: Token![as], + pub ty: Box, + }), + + /// A type ascription expression: `foo: f64`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Type(ExprType #full { + pub attrs: Vec, + pub expr: Box, + pub colon_token: Token![:], + pub ty: Box, + }), + + /// An `if` expression with an optional `else` block: `if expr { ... } + /// else { ... }`. + /// + /// The `else` branch expression may only be an `If`, `IfLet`, or + /// `Block` expression, not any of the other types of expression. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub If(ExprIf #full { + pub attrs: Vec, + pub if_token: Token![if], + pub cond: Box, + pub then_branch: Block, + pub else_branch: Option<(Token![else], Box)>, + }), + + /// An `if let` expression with an optional `else` block: `if let pat = + /// expr { ... } else { ... }`. + /// + /// The `else` branch expression may only be an `If`, `IfLet`, or + /// `Block` expression, not any of the other types of expression. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub IfLet(ExprIfLet #full { + pub attrs: Vec, + pub if_token: Token![if], + pub let_token: Token![let], + pub pats: Punctuated, + pub eq_token: Token![=], + pub expr: Box, + pub then_branch: Block, + pub else_branch: Option<(Token![else], Box)>, + }), + + /// A while loop: `while expr { ... }`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub While(ExprWhile #full { + pub attrs: Vec, + pub label: Option::B::C` and `::B::C` can only legally refer to + /// associated constants. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Path(PatPath { + pub qself: Option, + pub path: Path, + }), + + /// A tuple pattern: `(a, b)`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Tuple(PatTuple { + pub paren_token: token::Paren, + pub front: Punctuated, + pub dot2_token: Option, + pub comma_token: Option, + pub back: Punctuated, + }), + + /// A box pattern: `box v`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Box(PatBox { + pub box_token: Token![box], + pub pat: Box, + }), + + /// A reference pattern: `&mut (first, second)`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Ref(PatRef { + pub and_token: Token![&], + pub mutability: Option, + pub pat: Box, + }), + + /// A literal pattern: `0`. + /// + /// This holds an `Expr` rather than a `Lit` because negative numbers + /// are represented as an `Expr::Unary`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Lit(PatLit { + pub expr: Box, + }), + + /// A range pattern: `1..=2`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Range(PatRange { + pub lo: Box, + pub limits: RangeLimits, + pub hi: Box, + }), + + /// A dynamically sized slice pattern: `[a, b, i.., y, z]`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Slice(PatSlice { + pub bracket_token: token::Bracket, + pub front: Punctuated, + pub middle: Option>, + pub dot2_token: Option, + pub comma_token: Option, + pub back: Punctuated, + }), + + /// A macro in expression position. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Macro(PatMacro { + pub mac: Macro, + }), + + /// Tokens in pattern position not interpreted by Syn. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Verbatim(PatVerbatim #manual_extra_traits { + pub tts: TokenStream, + }), + } +} + +#[cfg(all(feature = "full", feature = "extra-traits"))] +impl Eq for PatVerbatim {} + +#[cfg(all(feature = "full", feature = "extra-traits"))] +impl PartialEq for PatVerbatim { + fn eq(&self, other: &Self) -> bool { + TokenStreamHelper(&self.tts) == TokenStreamHelper(&other.tts) + } +} + +#[cfg(all(feature = "full", feature = "extra-traits"))] +impl Hash for PatVerbatim { + fn hash(&self, state: &mut H) + where + H: Hasher, + { + TokenStreamHelper(&self.tts).hash(state); + } +} + +#[cfg(feature = "full")] +ast_struct! { + /// One arm of a `match` expression: `0...10 => { return true; }`. + /// + /// As in: + /// + /// ```rust + /// # fn f() -> bool { + /// # let n = 0; + /// match n { + /// 0...10 => { + /// return true; + /// } + /// // ... + /// # _ => {} + /// } + /// # false + /// # } + /// ``` + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub struct Arm { + pub attrs: Vec, + pub leading_vert: Option, + pub pats: Punctuated, + pub guard: Option<(Token![if], Box)>, + pub fat_arrow_token: Token![=>], + pub body: Box, + pub comma: Option, + } +} + +#[cfg(feature = "full")] +ast_enum! { + /// Limit types of a range, inclusive or exclusive. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + #[cfg_attr(feature = "clone-impls", derive(Copy))] + pub enum RangeLimits { + /// Inclusive at the beginning, exclusive at the end. + HalfOpen(Token![..]), + /// Inclusive at the beginning and end. + Closed(Token![..=]), + } +} + +#[cfg(feature = "full")] +ast_struct! { + /// A single field in a struct pattern. + /// + /// Patterns like the fields of Foo `{ x, ref y, ref mut z }` are treated + /// the same as `x: x, y: ref y, z: ref mut z` but there is no colon token. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub struct FieldPat { + pub attrs: Vec, + pub member: Member, + pub colon_token: Option, + pub pat: Box, + } +} + +#[cfg(any(feature = "parsing", feature = "printing"))] +#[cfg(feature = "full")] +fn arm_expr_requires_comma(expr: &Expr) -> bool { + // see https://github.com/rust-lang/rust/blob/eb8f2586e + // /src/libsyntax/parse/classify.rs#L17-L37 + match *expr { + Expr::Unsafe(..) + | Expr::Block(..) + | Expr::If(..) + | Expr::IfLet(..) + | Expr::Match(..) + | Expr::While(..) + | Expr::WhileLet(..) + | Expr::Loop(..) + | Expr::ForLoop(..) + | Expr::Catch(..) => false, + _ => true, + } +} + +#[cfg(feature = "parsing")] +pub mod parsing { + use super::*; + use path::parsing::qpath; + #[cfg(feature = "full")] + use path::parsing::ty_no_eq_after; + + use buffer::Cursor; + #[cfg(feature = "full")] + use parse_error; + #[cfg(feature = "full")] + use proc_macro2::TokenStream; + use synom::PResult; + use synom::Synom; + + // When we're parsing expressions which occur before blocks, like in an if + // statement's condition, we cannot parse a struct literal. + // + // Struct literals are ambiguous in certain positions + // https://github.com/rust-lang/rfcs/pull/92 + macro_rules! ambiguous_expr { + ($i:expr, $allow_struct:ident) => { + ambiguous_expr($i, $allow_struct, true) + }; + } + + // When we are parsing an optional suffix expression, we cannot allow blocks + // if structs are not allowed. + // + // Example: + // + // if break {} {} + // + // is ambiguous between: + // + // if (break {}) {} + // if (break) {} {} + #[cfg(feature = "full")] + macro_rules! opt_ambiguous_expr { + ($i:expr, $allow_struct:ident) => { + option!($i, call!(ambiguous_expr, $allow_struct, $allow_struct)) + }; + } + + impl Synom for Expr { + named!(parse -> Self, ambiguous_expr!(true)); + + fn description() -> Option<&'static str> { + Some("expression") + } + } + + #[cfg(feature = "full")] + named!(expr_no_struct -> Expr, ambiguous_expr!(false)); + + // Parse an arbitrary expression. + #[cfg(feature = "full")] + fn ambiguous_expr(i: Cursor, allow_struct: bool, allow_block: bool) -> PResult { + call!(i, assign_expr, allow_struct, allow_block) + } + + #[cfg(not(feature = "full"))] + fn ambiguous_expr(i: Cursor, allow_struct: bool, allow_block: bool) -> PResult { + // NOTE: We intentionally skip assign_expr, placement_expr, and + // range_expr, as they are not parsed in non-full mode. + call!(i, or_expr, allow_struct, allow_block) + } + + // Parse a left-associative binary operator. + macro_rules! binop { + ( + $name: ident, + $next: ident, + $submac: ident!( $($args:tt)* ) + ) => { + named!($name(allow_struct: bool, allow_block: bool) -> Expr, do_parse!( + mut e: call!($next, allow_struct, allow_block) >> + many0!(do_parse!( + op: $submac!($($args)*) >> + rhs: call!($next, allow_struct, true) >> + ({ + e = ExprBinary { + attrs: Vec::new(), + left: Box::new(e.into()), + op: op, + right: Box::new(rhs.into()), + }.into(); + }) + )) >> + (e) + )); + } + } + + // = .. + // += .. + // -= .. + // *= .. + // /= .. + // %= .. + // ^= .. + // &= .. + // |= .. + // <<= .. + // >>= .. + // + // NOTE: This operator is right-associative. + #[cfg(feature = "full")] + named!(assign_expr(allow_struct: bool, allow_block: bool) -> Expr, do_parse!( + mut e: call!(placement_expr, allow_struct, allow_block) >> + alt!( + do_parse!( + eq: punct!(=) >> + // Recurse into self to parse right-associative operator. + rhs: call!(assign_expr, allow_struct, true) >> + ({ + e = ExprAssign { + attrs: Vec::new(), + left: Box::new(e), + eq_token: eq, + right: Box::new(rhs), + }.into(); + }) + ) + | + do_parse!( + op: call!(BinOp::parse_assign_op) >> + // Recurse into self to parse right-associative operator. + rhs: call!(assign_expr, allow_struct, true) >> + ({ + e = ExprAssignOp { + attrs: Vec::new(), + left: Box::new(e), + op: op, + right: Box::new(rhs), + }.into(); + }) + ) + | + epsilon!() + ) >> + (e) + )); + + // <- .. + // + // NOTE: The `in place { expr }` version of this syntax is parsed in + // `atom_expr`, not here. + // + // NOTE: This operator is right-associative. + #[cfg(feature = "full")] + named!(placement_expr(allow_struct: bool, allow_block: bool) -> Expr, do_parse!( + mut e: call!(range_expr, allow_struct, allow_block) >> + alt!( + do_parse!( + arrow: punct!(<-) >> + // Recurse into self to parse right-associative operator. + rhs: call!(placement_expr, allow_struct, true) >> + ({ + e = ExprInPlace { + attrs: Vec::new(), + // op: BinOp::Place(larrow), + place: Box::new(e), + arrow_token: arrow, + value: Box::new(rhs), + }.into(); + }) + ) + | + epsilon!() + ) >> + (e) + )); + + // ... .. + // .. .. + // .. + // + // NOTE: This is currently parsed oddly - I'm not sure of what the exact + // rules are for parsing these expressions are, but this is not correct. + // For example, `a .. b .. c` is not a legal expression. It should not + // be parsed as either `(a .. b) .. c` or `a .. (b .. c)` apparently. + // + // NOTE: The form of ranges which don't include a preceding expression are + // parsed by `atom_expr`, rather than by this function. + #[cfg(feature = "full")] + named!(range_expr(allow_struct: bool, allow_block: bool) -> Expr, do_parse!( + mut e: call!(or_expr, allow_struct, allow_block) >> + many0!(do_parse!( + limits: syn!(RangeLimits) >> + // We don't want to allow blocks here if we don't allow structs. See + // the reasoning for `opt_ambiguous_expr!` above. + hi: option!(call!(or_expr, allow_struct, allow_struct)) >> + ({ + e = ExprRange { + attrs: Vec::new(), + from: Some(Box::new(e)), + limits: limits, + to: hi.map(|e| Box::new(e)), + }.into(); + }) + )) >> + (e) + )); + + // || ... + binop!(or_expr, and_expr, map!(punct!(||), BinOp::Or)); + + // && ... + binop!(and_expr, compare_expr, map!(punct!(&&), BinOp::And)); + + // == ... + // != ... + // >= ... + // <= ... + // > ... + // < ... + // + // NOTE: This operator appears to be parsed as left-associative, but errors + // if it is used in a non-associative manner. + binop!( + compare_expr, + bitor_expr, + alt!( + punct!(==) => { BinOp::Eq } + | + punct!(!=) => { BinOp::Ne } + | + // must be above Lt + punct!(<=) => { BinOp::Le } + | + // must be above Gt + punct!(>=) => { BinOp::Ge } + | + do_parse!( + // Make sure that we don't eat the < part of a <- operator + not!(punct!(<-)) >> + t: punct!(<) >> + (BinOp::Lt(t)) + ) + | + punct!(>) => { BinOp::Gt } + ) + ); + + // | ... + binop!( + bitor_expr, + bitxor_expr, + do_parse!(not!(punct!(||)) >> not!(punct!(|=)) >> t: punct!(|) >> (BinOp::BitOr(t))) + ); + + // ^ ... + binop!( + bitxor_expr, + bitand_expr, + do_parse!( + // NOTE: Make sure we aren't looking at ^=. + not!(punct!(^=)) >> t: punct!(^) >> (BinOp::BitXor(t)) + ) + ); + + // & ... + binop!( + bitand_expr, + shift_expr, + do_parse!( + // NOTE: Make sure we aren't looking at && or &=. + not!(punct!(&&)) >> not!(punct!(&=)) >> t: punct!(&) >> (BinOp::BitAnd(t)) + ) + ); + + // << ... + // >> ... + binop!( + shift_expr, + arith_expr, + alt!( + punct!(<<) => { BinOp::Shl } + | + punct!(>>) => { BinOp::Shr } + ) + ); + + // + ... + // - ... + binop!( + arith_expr, + term_expr, + alt!( + punct!(+) => { BinOp::Add } + | + punct!(-) => { BinOp::Sub } + ) + ); + + // * ... + // / ... + // % ... + binop!( + term_expr, + cast_expr, + alt!( + punct!(*) => { BinOp::Mul } + | + punct!(/) => { BinOp::Div } + | + punct!(%) => { BinOp::Rem } + ) + ); + + // as + // : + #[cfg(feature = "full")] + named!(cast_expr(allow_struct: bool, allow_block: bool) -> Expr, do_parse!( + mut e: call!(unary_expr, allow_struct, allow_block) >> + many0!(alt!( + do_parse!( + as_: keyword!(as) >> + // We can't accept `A + B` in cast expressions, as it's + // ambiguous with the + expression. + ty: call!(Type::without_plus) >> + ({ + e = ExprCast { + attrs: Vec::new(), + expr: Box::new(e), + as_token: as_, + ty: Box::new(ty), + }.into(); + }) + ) + | + do_parse!( + colon: punct!(:) >> + // We can't accept `A + B` in cast expressions, as it's + // ambiguous with the + expression. + ty: call!(Type::without_plus) >> + ({ + e = ExprType { + attrs: Vec::new(), + expr: Box::new(e), + colon_token: colon, + ty: Box::new(ty), + }.into(); + }) + ) + )) >> + (e) + )); + + // as + #[cfg(not(feature = "full"))] + named!(cast_expr(allow_struct: bool, allow_block: bool) -> Expr, do_parse!( + mut e: call!(unary_expr, allow_struct, allow_block) >> + many0!(do_parse!( + as_: keyword!(as) >> + // We can't accept `A + B` in cast expressions, as it's + // ambiguous with the + expression. + ty: call!(Type::without_plus) >> + ({ + e = ExprCast { + attrs: Vec::new(), + expr: Box::new(e), + as_token: as_, + ty: Box::new(ty), + }.into(); + }) + )) >> + (e) + )); + + // + // & + // &mut + // box + #[cfg(feature = "full")] + named!(unary_expr(allow_struct: bool, allow_block: bool) -> Expr, alt!( + do_parse!( + attrs: many0!(Attribute::parse_outer) >> + op: syn!(UnOp) >> + expr: call!(unary_expr, allow_struct, true) >> + (ExprUnary { + attrs: attrs, + op: op, + expr: Box::new(expr), + }.into()) + ) + | + do_parse!( + attrs: many0!(Attribute::parse_outer) >> + and: punct!(&) >> + mutability: option!(keyword!(mut)) >> + expr: call!(unary_expr, allow_struct, true) >> + (ExprReference { + attrs: attrs, + and_token: and, + mutability: mutability, + expr: Box::new(expr), + }.into()) + ) + | + do_parse!( + attrs: many0!(Attribute::parse_outer) >> + box_: keyword!(box) >> + expr: call!(unary_expr, allow_struct, true) >> + (ExprBox { + attrs: attrs, + box_token: box_, + expr: Box::new(expr), + }.into()) + ) + | + call!(trailer_expr, allow_struct, allow_block) + )); + + // XXX: This duplication is ugly + #[cfg(not(feature = "full"))] + named!(unary_expr(allow_struct: bool, allow_block: bool) -> Expr, alt!( + do_parse!( + op: syn!(UnOp) >> + expr: call!(unary_expr, allow_struct, true) >> + (ExprUnary { + attrs: Vec::new(), + op: op, + expr: Box::new(expr), + }.into()) + ) + | + call!(trailer_expr, allow_struct, allow_block) + )); + + #[cfg(feature = "full")] + fn take_outer(attrs: &mut Vec) -> Vec { + let mut outer = Vec::new(); + let mut inner = Vec::new(); + for attr in mem::replace(attrs, Vec::new()) { + match attr.style { + AttrStyle::Outer => outer.push(attr), + AttrStyle::Inner(_) => inner.push(attr), + } + } + *attrs = inner; + outer + } + + // (..) ... + // . (..) ... + // . ... + // . ... + // [ ] ... + // ? ... + #[cfg(feature = "full")] + named!(trailer_expr(allow_struct: bool, allow_block: bool) -> Expr, do_parse!( + mut e: call!(atom_expr, allow_struct, allow_block) >> + outer_attrs: value!({ + let mut attrs = e.replace_attrs(Vec::new()); + let outer_attrs = take_outer(&mut attrs); + e.replace_attrs(attrs); + outer_attrs + }) >> + many0!(alt!( + tap!(args: and_call => { + let (paren, args) = args; + e = ExprCall { + attrs: Vec::new(), + func: Box::new(e), + args: args, + paren_token: paren, + }.into(); + }) + | + tap!(more: and_method_call => { + let mut call = more; + call.receiver = Box::new(e); + e = call.into(); + }) + | + tap!(field: and_field => { + let (token, member) = field; + e = ExprField { + attrs: Vec::new(), + base: Box::new(e), + dot_token: token, + member: member, + }.into(); + }) + | + tap!(i: and_index => { + let (bracket, i) = i; + e = ExprIndex { + attrs: Vec::new(), + expr: Box::new(e), + bracket_token: bracket, + index: Box::new(i), + }.into(); + }) + | + tap!(question: punct!(?) => { + e = ExprTry { + attrs: Vec::new(), + expr: Box::new(e), + question_token: question, + }.into(); + }) + )) >> + ({ + let mut attrs = outer_attrs; + attrs.extend(e.replace_attrs(Vec::new())); + e.replace_attrs(attrs); + e + }) + )); + + // XXX: Duplication == ugly + #[cfg(not(feature = "full"))] + named!(trailer_expr(allow_struct: bool, allow_block: bool) -> Expr, do_parse!( + mut e: call!(atom_expr, allow_struct, allow_block) >> + many0!(alt!( + tap!(args: and_call => { + e = ExprCall { + attrs: Vec::new(), + func: Box::new(e), + paren_token: args.0, + args: args.1, + }.into(); + }) + | + tap!(field: and_field => { + let (token, member) = field; + e = ExprField { + attrs: Vec::new(), + base: Box::new(e), + dot_token: token, + member: member, + }.into(); + }) + | + tap!(i: and_index => { + e = ExprIndex { + attrs: Vec::new(), + expr: Box::new(e), + bracket_token: i.0, + index: Box::new(i.1), + }.into(); + }) + )) >> + (e) + )); + + // Parse all atomic expressions which don't have to worry about precedence + // interactions, as they are fully contained. + #[cfg(feature = "full")] + named!(atom_expr(allow_struct: bool, allow_block: bool) -> Expr, alt!( + syn!(ExprGroup) => { Expr::Group } // must be placed first + | + syn!(ExprLit) => { Expr::Lit } // must be before expr_struct + | + // must be before ExprStruct + call!(unstable_async_block) => { Expr::Verbatim } + | + // must be before expr_path + cond_reduce!(allow_struct, syn!(ExprStruct)) => { Expr::Struct } + | + syn!(ExprParen) => { Expr::Paren } // must be before expr_tup + | + syn!(ExprMacro) => { Expr::Macro } // must be before expr_path + | + call!(expr_break, allow_struct) // must be before expr_path + | + syn!(ExprContinue) => { Expr::Continue } // must be before expr_path + | + call!(expr_ret, allow_struct) // must be before expr_path + | + syn!(ExprArray) => { Expr::Array } + | + syn!(ExprTuple) => { Expr::Tuple } + | + syn!(ExprIf) => { Expr::If } + | + syn!(ExprIfLet) => { Expr::IfLet } + | + syn!(ExprWhile) => { Expr::While } + | + syn!(ExprWhileLet) => { Expr::WhileLet } + | + syn!(ExprForLoop) => { Expr::ForLoop } + | + syn!(ExprLoop) => { Expr::Loop } + | + syn!(ExprMatch) => { Expr::Match } + | + syn!(ExprCatch) => { Expr::Catch } + | + syn!(ExprYield) => { Expr::Yield } + | + syn!(ExprUnsafe) => { Expr::Unsafe } + | + call!(expr_closure, allow_struct) + | + cond_reduce!(allow_block, syn!(ExprBlock)) => { Expr::Block } + | + call!(unstable_labeled_block) => { Expr::Verbatim } + | + // NOTE: This is the prefix-form of range + call!(expr_range, allow_struct) + | + syn!(ExprPath) => { Expr::Path } + | + syn!(ExprRepeat) => { Expr::Repeat } + )); + + #[cfg(not(feature = "full"))] + named!(atom_expr(_allow_struct: bool, _allow_block: bool) -> Expr, alt!( + syn!(ExprLit) => { Expr::Lit } + | + syn!(ExprParen) => { Expr::Paren } + | + syn!(ExprPath) => { Expr::Path } + )); + + #[cfg(feature = "full")] + named!(expr_nosemi -> Expr, do_parse!( + nosemi: alt!( + syn!(ExprIf) => { Expr::If } + | + syn!(ExprIfLet) => { Expr::IfLet } + | + syn!(ExprWhile) => { Expr::While } + | + syn!(ExprWhileLet) => { Expr::WhileLet } + | + syn!(ExprForLoop) => { Expr::ForLoop } + | + syn!(ExprLoop) => { Expr::Loop } + | + syn!(ExprMatch) => { Expr::Match } + | + syn!(ExprCatch) => { Expr::Catch } + | + syn!(ExprYield) => { Expr::Yield } + | + syn!(ExprUnsafe) => { Expr::Unsafe } + | + syn!(ExprBlock) => { Expr::Block } + | + call!(unstable_labeled_block) => { Expr::Verbatim } + ) >> + // If the next token is a `.` or a `?` it is special-cased to parse + // as an expression instead of a blockexpression. + not!(punct!(.)) >> + not!(punct!(?)) >> + (nosemi) + )); + + impl Synom for ExprLit { + #[cfg(not(feature = "full"))] + named!(parse -> Self, do_parse!( + lit: syn!(Lit) >> + (ExprLit { + attrs: Vec::new(), + lit: lit, + }) + )); + + #[cfg(feature = "full")] + named!(parse -> Self, do_parse!( + attrs: many0!(Attribute::parse_outer) >> + lit: syn!(Lit) >> + (ExprLit { + attrs: attrs, + lit: lit, + }) + )); + + fn description() -> Option<&'static str> { + Some("literal") + } + } + + #[cfg(feature = "full")] + impl Synom for ExprMacro { + named!(parse -> Self, do_parse!( + attrs: many0!(Attribute::parse_outer) >> + mac: syn!(Macro) >> + (ExprMacro { + attrs: attrs, + mac: mac, + }) + )); + + fn description() -> Option<&'static str> { + Some("macro invocation expression") + } + } + + #[cfg(feature = "full")] + impl Synom for ExprGroup { + named!(parse -> Self, do_parse!( + e: grouped!(syn!(Expr)) >> + (ExprGroup { + attrs: Vec::new(), + expr: Box::new(e.1), + group_token: e.0, + }) + )); + + fn description() -> Option<&'static str> { + Some("expression surrounded by invisible delimiters") + } + } + + impl Synom for ExprParen { + #[cfg(not(feature = "full"))] + named!(parse -> Self, do_parse!( + e: parens!(syn!(Expr)) >> + (ExprParen { + attrs: Vec::new(), + paren_token: e.0, + expr: Box::new(e.1), + }) + )); + + #[cfg(feature = "full")] + named!(parse -> Self, do_parse!( + outer_attrs: many0!(Attribute::parse_outer) >> + e: parens!(tuple!( + many0!(Attribute::parse_inner), + syn!(Expr), + )) >> + (ExprParen { + attrs: { + let mut attrs = outer_attrs; + attrs.extend((e.1).0); + attrs + }, + paren_token: e.0, + expr: Box::new((e.1).1), + }) + )); + + fn description() -> Option<&'static str> { + Some("parenthesized expression") + } + } + + #[cfg(feature = "full")] + impl Synom for ExprArray { + named!(parse -> Self, do_parse!( + outer_attrs: many0!(Attribute::parse_outer) >> + elems: brackets!(tuple!( + many0!(Attribute::parse_inner), + call!(Punctuated::parse_terminated), + )) >> + (ExprArray { + attrs: { + let mut attrs = outer_attrs; + attrs.extend((elems.1).0); + attrs + }, + bracket_token: elems.0, + elems: (elems.1).1, + }) + )); + + fn description() -> Option<&'static str> { + Some("array expression") + } + } + + named!(and_call -> (token::Paren, Punctuated), + parens!(Punctuated::parse_terminated) + ); + + #[cfg(feature = "full")] + named!(and_method_call -> ExprMethodCall, do_parse!( + dot: punct!(.) >> + method: syn!(Ident) >> + turbofish: option!(tuple!( + punct!(::), + punct!(<), + call!(Punctuated::parse_terminated), + punct!(>), + )) >> + args: parens!(Punctuated::parse_terminated) >> + ({ + ExprMethodCall { + attrs: Vec::new(), + // this expr will get overwritten after being returned + receiver: Box::new(Expr::Verbatim(ExprVerbatim { + tts: TokenStream::new(), + })), + + method: method, + turbofish: turbofish.map(|fish| MethodTurbofish { + colon2_token: fish.0, + lt_token: fish.1, + args: fish.2, + gt_token: fish.3, + }), + args: args.1, + paren_token: args.0, + dot_token: dot, + } + }) + )); + + #[cfg(feature = "full")] + impl Synom for GenericMethodArgument { + // TODO parse const generics as well + named!(parse -> Self, map!(ty_no_eq_after, GenericMethodArgument::Type)); + + fn description() -> Option<&'static str> { + Some("generic method argument") + } + } + + #[cfg(feature = "full")] + impl Synom for ExprTuple { + named!(parse -> Self, do_parse!( + outer_attrs: many0!(Attribute::parse_outer) >> + elems: parens!(tuple!( + many0!(Attribute::parse_inner), + call!(Punctuated::parse_terminated), + )) >> + (ExprTuple { + attrs: { + let mut attrs = outer_attrs; + attrs.extend((elems.1).0); + attrs + }, + elems: (elems.1).1, + paren_token: elems.0, + }) + )); + + fn description() -> Option<&'static str> { + Some("tuple") + } + } + + #[cfg(feature = "full")] + impl Synom for ExprIfLet { + named!(parse -> Self, do_parse!( + if_: keyword!(if) >> + let_: keyword!(let) >> + pats: call!(Punctuated::parse_separated_nonempty) >> + eq: punct!(=) >> + cond: expr_no_struct >> + then_block: braces!(Block::parse_within) >> + else_block: option!(else_block) >> + (ExprIfLet { + attrs: Vec::new(), + pats: pats, + let_token: let_, + eq_token: eq, + expr: Box::new(cond), + then_branch: Block { + brace_token: then_block.0, + stmts: then_block.1, + }, + if_token: if_, + else_branch: else_block, + }) + )); + + fn description() -> Option<&'static str> { + Some("`if let` expression") + } + } + + #[cfg(feature = "full")] + impl Synom for ExprIf { + named!(parse -> Self, do_parse!( + if_: keyword!(if) >> + cond: expr_no_struct >> + then_block: braces!(Block::parse_within) >> + else_block: option!(else_block) >> + (ExprIf { + attrs: Vec::new(), + cond: Box::new(cond), + then_branch: Block { + brace_token: then_block.0, + stmts: then_block.1, + }, + if_token: if_, + else_branch: else_block, + }) + )); + + fn description() -> Option<&'static str> { + Some("`if` expression") + } + } + + #[cfg(feature = "full")] + named!(else_block -> (Token![else], Box), do_parse!( + else_: keyword!(else) >> + expr: alt!( + syn!(ExprIf) => { Expr::If } + | + syn!(ExprIfLet) => { Expr::IfLet } + | + do_parse!( + else_block: braces!(Block::parse_within) >> + (Expr::Block(ExprBlock { + attrs: Vec::new(), + block: Block { + brace_token: else_block.0, + stmts: else_block.1, + }, + })) + ) + ) >> + (else_, Box::new(expr)) + )); + + #[cfg(feature = "full")] + impl Synom for ExprForLoop { + named!(parse -> Self, do_parse!( + outer_attrs: many0!(Attribute::parse_outer) >> + label: option!(syn!(Label)) >> + for_: keyword!(for) >> + pat: syn!(Pat) >> + in_: keyword!(in) >> + expr: expr_no_struct >> + block: braces!(tuple!( + many0!(Attribute::parse_inner), + call!(Block::parse_within), + )) >> + (ExprForLoop { + attrs: { + let mut attrs = outer_attrs; + attrs.extend((block.1).0); + attrs + }, + label: label, + for_token: for_, + pat: Box::new(pat), + in_token: in_, + expr: Box::new(expr), + body: Block { + brace_token: block.0, + stmts: (block.1).1, + }, + }) + )); + + fn description() -> Option<&'static str> { + Some("`for` loop") + } + } + + #[cfg(feature = "full")] + impl Synom for ExprLoop { + named!(parse -> Self, do_parse!( + outer_attrs: many0!(Attribute::parse_outer) >> + label: option!(syn!(Label)) >> + loop_: keyword!(loop) >> + block: braces!(tuple!( + many0!(Attribute::parse_inner), + call!(Block::parse_within), + )) >> + (ExprLoop { + attrs: { + let mut attrs = outer_attrs; + attrs.extend((block.1).0); + attrs + }, + label: label, + loop_token: loop_, + body: Block { + brace_token: block.0, + stmts: (block.1).1, + }, + }) + )); + + fn description() -> Option<&'static str> { + Some("`loop`") + } + } + + #[cfg(feature = "full")] + impl Synom for ExprMatch { + named!(parse -> Self, do_parse!( + outer_attrs: many0!(Attribute::parse_outer) >> + match_: keyword!(match) >> + obj: expr_no_struct >> + braced_content: braces!(tuple!( + many0!(Attribute::parse_inner), + many0!(syn!(Arm)), + )) >> + (ExprMatch { + attrs: { + let mut attrs = outer_attrs; + attrs.extend((braced_content.1).0); + attrs + }, + expr: Box::new(obj), + match_token: match_, + brace_token: braced_content.0, + arms: (braced_content.1).1, + }) + )); + + fn description() -> Option<&'static str> { + Some("`match` expression") + } + } + + #[cfg(feature = "full")] + impl Synom for ExprCatch { + named!(parse -> Self, do_parse!( + do_: keyword!(do) >> + catch_: keyword!(catch) >> + catch_block: syn!(Block) >> + (ExprCatch { + attrs: Vec::new(), + block: catch_block, + do_token: do_, + catch_token: catch_, + }) + )); + + fn description() -> Option<&'static str> { + Some("`catch` expression") + } + } + + #[cfg(feature = "full")] + impl Synom for ExprYield { + named!(parse -> Self, do_parse!( + yield_: keyword!(yield) >> + expr: option!(syn!(Expr)) >> + (ExprYield { + attrs: Vec::new(), + yield_token: yield_, + expr: expr.map(Box::new), + }) + )); + + fn description() -> Option<&'static str> { + Some("`yield` expression") + } + } + + #[cfg(feature = "full")] + impl Synom for Arm { + named!(parse -> Self, do_parse!( + attrs: many0!(Attribute::parse_outer) >> + leading_vert: option!(punct!(|)) >> + pats: call!(Punctuated::parse_separated_nonempty) >> + guard: option!(tuple!(keyword!(if), syn!(Expr))) >> + fat_arrow: punct!(=>) >> + body: do_parse!( + expr: alt!(expr_nosemi | syn!(Expr)) >> + comma: switch!(value!(arm_expr_requires_comma(&expr)), + true => alt!( + input_end!() => { |_| None } + | + punct!(,) => { Some } + ) + | + false => option!(punct!(,)) + ) >> + (expr, comma) + ) >> + (Arm { + fat_arrow_token: fat_arrow, + attrs: attrs, + leading_vert: leading_vert, + pats: pats, + guard: guard.map(|(if_, guard)| (if_, Box::new(guard))), + body: Box::new(body.0), + comma: body.1, + }) + )); + + fn description() -> Option<&'static str> { + Some("`match` arm") + } + } + + #[cfg(feature = "full")] + named!(expr_closure(allow_struct: bool) -> Expr, do_parse!( + begin: call!(verbatim::grab_cursor) >> + attrs: many0!(Attribute::parse_outer) >> + asyncness: option!(keyword!(async)) >> + movability: option!(cond_reduce!(asyncness.is_none(), keyword!(static))) >> + capture: option!(keyword!(move)) >> + or1: punct!(|) >> + inputs: call!(Punctuated::parse_terminated_with, fn_arg) >> + or2: punct!(|) >> + ret_and_body: alt!( + do_parse!( + arrow: punct!(->) >> + ty: syn!(Type) >> + body: syn!(Block) >> + ( + ReturnType::Type(arrow, Box::new(ty)), + Expr::Block(ExprBlock { + attrs: Vec::new(), + block: body, + }, + )) + ) + | + map!(ambiguous_expr!(allow_struct), |e| (ReturnType::Default, e)) + ) >> + end: call!(verbatim::grab_cursor) >> + ({ + if asyncness.is_some() { + // TODO: include asyncness in ExprClosure + // https://github.com/dtolnay/syn/issues/396 + Expr::Verbatim(ExprVerbatim { + tts: verbatim::token_range(begin..end), + }) + } else { + Expr::Closure(ExprClosure { + attrs: attrs, + movability: movability, + capture: capture, + or1_token: or1, + inputs: inputs, + or2_token: or2, + output: ret_and_body.0, + body: Box::new(ret_and_body.1), + }) + } + }) + )); + + #[cfg(feature = "full")] + named!(unstable_async_block -> ExprVerbatim, do_parse!( + begin: call!(verbatim::grab_cursor) >> + many0!(Attribute::parse_outer) >> + keyword!(async) >> + option!(keyword!(move)) >> + syn!(Block) >> + end: call!(verbatim::grab_cursor) >> + (ExprVerbatim { + tts: verbatim::token_range(begin..end), + }) + )); + + #[cfg(feature = "full")] + named!(fn_arg -> FnArg, do_parse!( + pat: syn!(Pat) >> + ty: option!(tuple!(punct!(:), syn!(Type))) >> + ({ + if let Some((colon, ty)) = ty { + FnArg::Captured(ArgCaptured { + pat: pat, + colon_token: colon, + ty: ty, + }) + } else { + FnArg::Inferred(pat) + } + }) + )); + + #[cfg(feature = "full")] + impl Synom for ExprWhile { + named!(parse -> Self, do_parse!( + outer_attrs: many0!(Attribute::parse_outer) >> + label: option!(syn!(Label)) >> + while_: keyword!(while) >> + cond: expr_no_struct >> + block: braces!(tuple!( + many0!(Attribute::parse_inner), + call!(Block::parse_within), + )) >> + (ExprWhile { + attrs: { + let mut attrs = outer_attrs; + attrs.extend((block.1).0); + attrs + }, + label: label, + while_token: while_, + cond: Box::new(cond), + body: Block { + brace_token: block.0, + stmts: (block.1).1, + }, + }) + )); + + fn description() -> Option<&'static str> { + Some("`while` expression") + } + } + + #[cfg(feature = "full")] + impl Synom for ExprWhileLet { + named!(parse -> Self, do_parse!( + outer_attrs: many0!(Attribute::parse_outer) >> + label: option!(syn!(Label)) >> + while_: keyword!(while) >> + let_: keyword!(let) >> + pats: call!(Punctuated::parse_separated_nonempty) >> + eq: punct!(=) >> + value: expr_no_struct >> + block: braces!(tuple!( + many0!(Attribute::parse_inner), + call!(Block::parse_within), + )) >> + (ExprWhileLet { + attrs: { + let mut attrs = outer_attrs; + attrs.extend((block.1).0); + attrs + }, + label: label, + while_token: while_, + let_token: let_, + pats: pats, + eq_token: eq, + expr: Box::new(value), + body: Block { + brace_token: block.0, + stmts: (block.1).1, + }, + }) + )); + + fn description() -> Option<&'static str> { + Some("`while let` expression") + } + } + + #[cfg(feature = "full")] + impl Synom for Label { + named!(parse -> Self, do_parse!( + name: syn!(Lifetime) >> + colon: punct!(:) >> + (Label { + name: name, + colon_token: colon, + }) + )); + + fn description() -> Option<&'static str> { + Some("`while let` expression") + } + } + + #[cfg(feature = "full")] + impl Synom for ExprContinue { + named!(parse -> Self, do_parse!( + attrs: many0!(Attribute::parse_outer) >> + cont: keyword!(continue) >> + label: option!(syn!(Lifetime)) >> + (ExprContinue { + attrs: attrs, + continue_token: cont, + label: label, + }) + )); + + fn description() -> Option<&'static str> { + Some("`continue`") + } + } + + #[cfg(feature = "full")] + named!(expr_break(allow_struct: bool) -> Expr, do_parse!( + attrs: many0!(Attribute::parse_outer) >> + break_: keyword!(break) >> + label: option!(syn!(Lifetime)) >> + // We can't allow blocks after a `break` expression when we wouldn't + // allow structs, as this expression is ambiguous. + val: opt_ambiguous_expr!(allow_struct) >> + (ExprBreak { + attrs: attrs, + label: label, + expr: val.map(Box::new), + break_token: break_, + }.into()) + )); + + #[cfg(feature = "full")] + named!(expr_ret(allow_struct: bool) -> Expr, do_parse!( + attrs: many0!(Attribute::parse_outer) >> + return_: keyword!(return) >> + // NOTE: return is greedy and eats blocks after it even when in a + // position where structs are not allowed, such as in if statement + // conditions. For example: + // + // if return { println!("A") } {} // Prints "A" + ret_value: option!(ambiguous_expr!(allow_struct)) >> + (ExprReturn { + attrs: attrs, + expr: ret_value.map(Box::new), + return_token: return_, + }.into()) + )); + + #[cfg(feature = "full")] + impl Synom for ExprStruct { + named!(parse -> Self, do_parse!( + outer_attrs: many0!(Attribute::parse_outer) >> + path: syn!(Path) >> + data: braces!(do_parse!( + inner_attrs: many0!(Attribute::parse_inner) >> + fields: call!(Punctuated::parse_terminated) >> + base: option!(cond!(fields.empty_or_trailing(), do_parse!( + dots: punct!(..) >> + base: syn!(Expr) >> + (dots, base) + ))) >> + (inner_attrs, fields, base) + )) >> + ({ + let (brace, (inner_attrs, fields, base)) = data; + let (dots, rest) = match base.and_then(|b| b) { + Some((dots, base)) => (Some(dots), Some(base)), + None => (None, None), + }; + ExprStruct { + attrs: { + let mut attrs = outer_attrs; + attrs.extend(inner_attrs); + attrs + }, + brace_token: brace, + path: path, + fields: fields, + dot2_token: dots, + rest: rest.map(Box::new), + } + }) + )); + + fn description() -> Option<&'static str> { + Some("struct literal expression") + } + } + + #[cfg(feature = "full")] + impl Synom for FieldValue { + named!(parse -> Self, do_parse!( + attrs: many0!(Attribute::parse_outer) >> + field_value: alt!( + tuple!(syn!(Member), map!(punct!(:), Some), syn!(Expr)) + | + map!(syn!(Ident), |name| ( + Member::Named(name.clone()), + None, + Expr::Path(ExprPath { + attrs: Vec::new(), + qself: None, + path: name.into(), + }), + )) + ) >> + (FieldValue { + attrs: attrs, + member: field_value.0, + colon_token: field_value.1, + expr: field_value.2, + }) + )); + + fn description() -> Option<&'static str> { + Some("field-value pair: `field: value`") + } + } + + #[cfg(feature = "full")] + impl Synom for ExprRepeat { + named!(parse -> Self, do_parse!( + outer_attrs: many0!(Attribute::parse_outer) >> + data: brackets!(tuple!( + many0!(Attribute::parse_inner), + syn!(Expr), + punct!(;), + syn!(Expr), + )) >> + (ExprRepeat { + attrs: { + let mut attrs = outer_attrs; + attrs.extend((data.1).0); + attrs + }, + expr: Box::new((data.1).1), + len: Box::new((data.1).3), + bracket_token: data.0, + semi_token: (data.1).2, + }) + )); + + fn description() -> Option<&'static str> { + Some("repeated array literal: `[val; N]`") + } + } + + #[cfg(feature = "full")] + impl Synom for ExprUnsafe { + named!(parse -> Self, do_parse!( + unsafe_: keyword!(unsafe) >> + b: syn!(Block) >> + (ExprUnsafe { + attrs: Vec::new(), + unsafe_token: unsafe_, + block: b, + }) + )); + + fn description() -> Option<&'static str> { + Some("unsafe block: `unsafe { .. }`") + } + } + + #[cfg(feature = "full")] + impl Synom for ExprBlock { + named!(parse -> Self, do_parse!( + outer_attrs: many0!(Attribute::parse_outer) >> + block: braces!(tuple!( + many0!(Attribute::parse_inner), + call!(Block::parse_within), + )) >> + (ExprBlock { + attrs: { + let mut attrs = outer_attrs; + attrs.extend((block.1).0); + attrs + }, + block: Block { + brace_token: block.0, + stmts: (block.1).1, + }, + }) + )); + + fn description() -> Option<&'static str> { + Some("block: `{ .. }`") + } + } + + #[cfg(feature = "full")] + named!(unstable_labeled_block -> ExprVerbatim, do_parse!( + begin: call!(verbatim::grab_cursor) >> + many0!(Attribute::parse_outer) >> + syn!(Label) >> + braces!(tuple!( + many0!(Attribute::parse_inner), + call!(Block::parse_within), + )) >> + end: call!(verbatim::grab_cursor) >> + (ExprVerbatim { + tts: verbatim::token_range(begin..end), + }) + )); + + #[cfg(feature = "full")] + named!(expr_range(allow_struct: bool) -> Expr, do_parse!( + limits: syn!(RangeLimits) >> + hi: opt_ambiguous_expr!(allow_struct) >> + (ExprRange { + attrs: Vec::new(), + from: None, + to: hi.map(Box::new), + limits: limits, + }.into()) + )); + + #[cfg(feature = "full")] + impl Synom for RangeLimits { + named!(parse -> Self, alt!( + // Must come before Dot2 + punct!(..=) => { RangeLimits::Closed } + | + // Must come before Dot2 + punct!(...) => { |dot3| RangeLimits::Closed(Token![..=](dot3.0)) } + | + punct!(..) => { RangeLimits::HalfOpen } + )); + + fn description() -> Option<&'static str> { + Some("range limit: `..`, `...` or `..=`") + } + } + + impl Synom for ExprPath { + #[cfg(not(feature = "full"))] + named!(parse -> Self, do_parse!( + pair: qpath >> + (ExprPath { + attrs: Vec::new(), + qself: pair.0, + path: pair.1, + }) + )); + + #[cfg(feature = "full")] + named!(parse -> Self, do_parse!( + attrs: many0!(Attribute::parse_outer) >> + pair: qpath >> + (ExprPath { + attrs: attrs, + qself: pair.0, + path: pair.1, + }) + )); + + fn description() -> Option<&'static str> { + Some("path: `a::b::c`") + } + } + + named!(and_field -> (Token![.], Member), tuple!(punct!(.), syn!(Member))); + + named!(and_index -> (token::Bracket, Expr), brackets!(syn!(Expr))); + + #[cfg(feature = "full")] + impl Synom for Block { + named!(parse -> Self, do_parse!( + stmts: braces!(Block::parse_within) >> + (Block { + brace_token: stmts.0, + stmts: stmts.1, + }) + )); + + fn description() -> Option<&'static str> { + Some("block: `{ .. }`") + } + } + + #[cfg(feature = "full")] + impl Block { + named!(pub parse_within -> Vec, do_parse!( + many0!(punct!(;)) >> + mut standalone: many0!(do_parse!( + stmt: syn!(Stmt) >> + many0!(punct!(;)) >> + (stmt) + )) >> + last: option!(do_parse!( + attrs: many0!(Attribute::parse_outer) >> + mut e: syn!(Expr) >> + ({ + e.replace_attrs(attrs); + Stmt::Expr(e) + }) + )) >> + (match last { + None => standalone, + Some(last) => { + standalone.push(last); + standalone + } + }) + )); + } + + #[cfg(feature = "full")] + impl Synom for Stmt { + named!(parse -> Self, alt!( + stmt_mac + | + stmt_local + | + stmt_item + | + stmt_blockexpr + | + stmt_expr + )); + + fn description() -> Option<&'static str> { + Some("statement") + } + } + + #[cfg(feature = "full")] + named!(stmt_mac -> Stmt, do_parse!( + attrs: many0!(Attribute::parse_outer) >> + what: call!(Path::parse_mod_style) >> + bang: punct!(!) >> + // Only parse braces here; paren and bracket will get parsed as + // expression statements + data: braces!(syn!(TokenStream)) >> + semi: option!(punct!(;)) >> + (Stmt::Item(Item::Macro(ItemMacro { + attrs: attrs, + ident: None, + mac: Macro { + path: what, + bang_token: bang, + delimiter: MacroDelimiter::Brace(data.0), + tts: data.1, + }, + semi_token: semi, + }))) + )); + + #[cfg(feature = "full")] + named!(stmt_local -> Stmt, do_parse!( + attrs: many0!(Attribute::parse_outer) >> + let_: keyword!(let) >> + pats: call!(Punctuated::parse_separated_nonempty) >> + ty: option!(tuple!(punct!(:), syn!(Type))) >> + init: option!(tuple!(punct!(=), syn!(Expr))) >> + semi: punct!(;) >> + (Stmt::Local(Local { + attrs: attrs, + let_token: let_, + pats: pats, + ty: ty.map(|(colon, ty)| (colon, Box::new(ty))), + init: init.map(|(eq, expr)| (eq, Box::new(expr))), + semi_token: semi, + })) + )); + + #[cfg(feature = "full")] + named!(stmt_item -> Stmt, map!(syn!(Item), |i| Stmt::Item(i))); + + #[cfg(feature = "full")] + named!(stmt_blockexpr -> Stmt, do_parse!( + mut attrs: many0!(Attribute::parse_outer) >> + mut e: expr_nosemi >> + semi: option!(punct!(;)) >> + ({ + attrs.extend(e.replace_attrs(Vec::new())); + e.replace_attrs(attrs); + if let Some(semi) = semi { + Stmt::Semi(e, semi) + } else { + Stmt::Expr(e) + } + }) + )); + + #[cfg(feature = "full")] + named!(stmt_expr -> Stmt, do_parse!( + mut attrs: many0!(Attribute::parse_outer) >> + mut e: syn!(Expr) >> + semi: punct!(;) >> + ({ + attrs.extend(e.replace_attrs(Vec::new())); + e.replace_attrs(attrs); + Stmt::Semi(e, semi) + }) + )); + + #[cfg(feature = "full")] + impl Synom for Pat { + named!(parse -> Self, alt!( + syn!(PatWild) => { Pat::Wild } // must be before pat_ident + | + syn!(PatBox) => { Pat::Box } // must be before pat_ident + | + syn!(PatRange) => { Pat::Range } // must be before pat_lit + | + syn!(PatTupleStruct) => { Pat::TupleStruct } // must be before pat_ident + | + syn!(PatStruct) => { Pat::Struct } // must be before pat_ident + | + syn!(PatMacro) => { Pat::Macro } // must be before pat_ident + | + syn!(PatLit) => { Pat::Lit } // must be before pat_ident + | + syn!(PatIdent) => { Pat::Ident } // must be before pat_path + | + syn!(PatPath) => { Pat::Path } + | + syn!(PatTuple) => { Pat::Tuple } + | + syn!(PatRef) => { Pat::Ref } + | + syn!(PatSlice) => { Pat::Slice } + )); + + fn description() -> Option<&'static str> { + Some("pattern") + } + } + + #[cfg(feature = "full")] + impl Synom for PatWild { + named!(parse -> Self, map!( + punct!(_), + |u| PatWild { underscore_token: u } + )); + + fn description() -> Option<&'static str> { + Some("wild pattern: `_`") + } + } + + #[cfg(feature = "full")] + impl Synom for PatBox { + named!(parse -> Self, do_parse!( + boxed: keyword!(box) >> + pat: syn!(Pat) >> + (PatBox { + pat: Box::new(pat), + box_token: boxed, + }) + )); + + fn description() -> Option<&'static str> { + Some("box pattern") + } + } + + #[cfg(feature = "full")] + impl Synom for PatIdent { + named!(parse -> Self, do_parse!( + by_ref: option!(keyword!(ref)) >> + mutability: option!(keyword!(mut)) >> + name: alt!( + syn!(Ident) + | + keyword!(self) => { Into::into } + ) >> + not!(punct!(<)) >> + not!(punct!(::)) >> + subpat: option!(tuple!(punct!(@), syn!(Pat))) >> + (PatIdent { + by_ref: by_ref, + mutability: mutability, + ident: name, + subpat: subpat.map(|(at, pat)| (at, Box::new(pat))), + }) + )); + + fn description() -> Option<&'static str> { + Some("pattern identifier binding") + } + } + + #[cfg(feature = "full")] + impl Synom for PatTupleStruct { + named!(parse -> Self, do_parse!( + path: syn!(Path) >> + tuple: syn!(PatTuple) >> + (PatTupleStruct { + path: path, + pat: tuple, + }) + )); + + fn description() -> Option<&'static str> { + Some("tuple struct pattern") + } + } + + #[cfg(feature = "full")] + impl Synom for PatStruct { + named!(parse -> Self, do_parse!( + path: syn!(Path) >> + data: braces!(do_parse!( + fields: call!(Punctuated::parse_terminated) >> + base: option!(cond!(fields.empty_or_trailing(), punct!(..))) >> + (fields, base) + )) >> + (PatStruct { + path: path, + fields: (data.1).0, + brace_token: data.0, + dot2_token: (data.1).1.and_then(|m| m), + }) + )); + + fn description() -> Option<&'static str> { + Some("struct pattern") + } + } + + #[cfg(feature = "full")] + impl Synom for FieldPat { + named!(parse -> Self, alt!( + do_parse!( + member: syn!(Member) >> + colon: punct!(:) >> + pat: syn!(Pat) >> + (FieldPat { + member: member, + pat: Box::new(pat), + attrs: Vec::new(), + colon_token: Some(colon), + }) + ) + | + do_parse!( + boxed: option!(keyword!(box)) >> + by_ref: option!(keyword!(ref)) >> + mutability: option!(keyword!(mut)) >> + ident: syn!(Ident) >> + ({ + let mut pat: Pat = PatIdent { + by_ref: by_ref, + mutability: mutability, + ident: ident.clone(), + subpat: None, + }.into(); + if let Some(boxed) = boxed { + pat = PatBox { + pat: Box::new(pat), + box_token: boxed, + }.into(); + } + FieldPat { + member: Member::Named(ident), + pat: Box::new(pat), + attrs: Vec::new(), + colon_token: None, + } + }) + ) + )); + + fn description() -> Option<&'static str> { + Some("field pattern") + } + } + + impl Synom for Member { + named!(parse -> Self, alt!( + syn!(Ident) => { Member::Named } + | + syn!(Index) => { Member::Unnamed } + )); + + fn description() -> Option<&'static str> { + Some("field member") + } + } + + impl Synom for Index { + named!(parse -> Self, do_parse!( + lit: syn!(LitInt) >> + ({ + if let IntSuffix::None = lit.suffix() { + Index { index: lit.value() as u32, span: lit.span() } + } else { + return parse_error(); + } + }) + )); + + fn description() -> Option<&'static str> { + Some("field index") + } + } + + #[cfg(feature = "full")] + impl Synom for PatPath { + named!(parse -> Self, map!( + syn!(ExprPath), + |p| PatPath { qself: p.qself, path: p.path } + )); + + fn description() -> Option<&'static str> { + Some("path pattern") + } + } + + #[cfg(feature = "full")] + impl Synom for PatTuple { + named!(parse -> Self, do_parse!( + data: parens!(do_parse!( + front: call!(Punctuated::parse_terminated) >> + dotdot: option!(cond_reduce!(front.empty_or_trailing(), + tuple!(punct!(..), option!(punct!(,))) + )) >> + back: cond!(match dotdot { + Some((_, Some(_))) => true, + _ => false, + }, + Punctuated::parse_terminated) >> + (front, dotdot, back) + )) >> + ({ + let (parens, (front, dotdot, back)) = data; + let (dotdot, trailing) = match dotdot { + Some((a, b)) => (Some(a), Some(b)), + None => (None, None), + }; + PatTuple { + paren_token: parens, + front: front, + dot2_token: dotdot, + comma_token: trailing.unwrap_or_default(), + back: back.unwrap_or_default(), + } + }) + )); + + fn description() -> Option<&'static str> { + Some("tuple pattern") + } + } + + #[cfg(feature = "full")] + impl Synom for PatRef { + named!(parse -> Self, do_parse!( + and: punct!(&) >> + mutability: option!(keyword!(mut)) >> + pat: syn!(Pat) >> + (PatRef { + pat: Box::new(pat), + mutability: mutability, + and_token: and, + }) + )); + + fn description() -> Option<&'static str> { + Some("reference pattern") + } + } + + #[cfg(feature = "full")] + impl Synom for PatLit { + named!(parse -> Self, do_parse!( + lit: pat_lit_expr >> + (if let Expr::Path(_) = lit { + return parse_error(); // these need to be parsed by pat_path + } else { + PatLit { + expr: Box::new(lit), + } + }) + )); + + fn description() -> Option<&'static str> { + Some("literal pattern") + } + } + + #[cfg(feature = "full")] + impl Synom for PatRange { + named!(parse -> Self, do_parse!( + lo: pat_lit_expr >> + limits: syn!(RangeLimits) >> + hi: pat_lit_expr >> + (PatRange { + lo: Box::new(lo), + hi: Box::new(hi), + limits: limits, + }) + )); + + fn description() -> Option<&'static str> { + Some("range pattern") + } + } + + #[cfg(feature = "full")] + named!(pat_lit_expr -> Expr, do_parse!( + neg: option!(punct!(-)) >> + v: alt!( + syn!(ExprLit) => { Expr::Lit } + | + syn!(ExprPath) => { Expr::Path } + ) >> + (if let Some(neg) = neg { + Expr::Unary(ExprUnary { + attrs: Vec::new(), + op: UnOp::Neg(neg), + expr: Box::new(v) + }) + } else { + v + }) + )); + + #[cfg(feature = "full")] + impl Synom for PatSlice { + named!(parse -> Self, map!( + brackets!(do_parse!( + before: call!(Punctuated::parse_terminated) >> + middle: option!(do_parse!( + dots: punct!(..) >> + trailing: option!(punct!(,)) >> + (dots, trailing) + )) >> + after: cond!( + match middle { + Some((_, ref trailing)) => trailing.is_some(), + _ => false, + }, + Punctuated::parse_terminated + ) >> + (before, middle, after) + )), + |(brackets, (before, middle, after))| { + let mut before: Punctuated = before; + let after: Option> = after; + let middle: Option<(Token![..], Option)> = middle; + PatSlice { + dot2_token: middle.as_ref().map(|m| Token![..]((m.0).0)), + comma_token: middle.as_ref().and_then(|m| { + m.1.as_ref().map(|m| Token![,](m.0)) + }), + bracket_token: brackets, + middle: middle.and_then(|_| { + if before.empty_or_trailing() { + None + } else { + Some(Box::new(before.pop().unwrap().into_value())) + } + }), + front: before, + back: after.unwrap_or_default(), + } + } + )); + + fn description() -> Option<&'static str> { + Some("slice pattern") + } + } + + #[cfg(feature = "full")] + impl Synom for PatMacro { + named!(parse -> Self, map!(syn!(Macro), |mac| PatMacro { mac: mac })); + + fn description() -> Option<&'static str> { + Some("macro pattern") + } + } +} + +#[cfg(feature = "printing")] +mod printing { + use super::*; + #[cfg(feature = "full")] + use attr::FilterAttrs; + use proc_macro2::{Literal, TokenStream}; + use quote::{ToTokens, TokenStreamExt}; + + // If the given expression is a bare `ExprStruct`, wraps it in parenthesis + // before appending it to `TokenStream`. + #[cfg(feature = "full")] + fn wrap_bare_struct(tokens: &mut TokenStream, e: &Expr) { + if let Expr::Struct(_) = *e { + token::Paren::default().surround(tokens, |tokens| { + e.to_tokens(tokens); + }); + } else { + e.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + fn outer_attrs_to_tokens(attrs: &[Attribute], tokens: &mut TokenStream) { + tokens.append_all(attrs.outer()); + } + + #[cfg(feature = "full")] + fn inner_attrs_to_tokens(attrs: &[Attribute], tokens: &mut TokenStream) { + tokens.append_all(attrs.inner()); + } + + #[cfg(not(feature = "full"))] + fn outer_attrs_to_tokens(_attrs: &[Attribute], _tokens: &mut TokenStream) {} + + #[cfg(not(feature = "full"))] + fn inner_attrs_to_tokens(_attrs: &[Attribute], _tokens: &mut TokenStream) {} + + #[cfg(feature = "full")] + impl ToTokens for ExprBox { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.box_token.to_tokens(tokens); + self.expr.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprInPlace { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.place.to_tokens(tokens); + self.arrow_token.to_tokens(tokens); + self.value.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprArray { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.bracket_token.surround(tokens, |tokens| { + inner_attrs_to_tokens(&self.attrs, tokens); + self.elems.to_tokens(tokens); + }) + } + } + + impl ToTokens for ExprCall { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.func.to_tokens(tokens); + self.paren_token.surround(tokens, |tokens| { + self.args.to_tokens(tokens); + }) + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprMethodCall { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.receiver.to_tokens(tokens); + self.dot_token.to_tokens(tokens); + self.method.to_tokens(tokens); + self.turbofish.to_tokens(tokens); + self.paren_token.surround(tokens, |tokens| { + self.args.to_tokens(tokens); + }); + } + } + + #[cfg(feature = "full")] + impl ToTokens for MethodTurbofish { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.colon2_token.to_tokens(tokens); + self.lt_token.to_tokens(tokens); + self.args.to_tokens(tokens); + self.gt_token.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for GenericMethodArgument { + fn to_tokens(&self, tokens: &mut TokenStream) { + match *self { + GenericMethodArgument::Type(ref t) => t.to_tokens(tokens), + GenericMethodArgument::Const(ref c) => c.to_tokens(tokens), + } + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprTuple { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.paren_token.surround(tokens, |tokens| { + inner_attrs_to_tokens(&self.attrs, tokens); + self.elems.to_tokens(tokens); + // If we only have one argument, we need a trailing comma to + // distinguish ExprTuple from ExprParen. + if self.elems.len() == 1 && !self.elems.trailing_punct() { + ::default().to_tokens(tokens); + } + }) + } + } + + impl ToTokens for ExprBinary { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.left.to_tokens(tokens); + self.op.to_tokens(tokens); + self.right.to_tokens(tokens); + } + } + + impl ToTokens for ExprUnary { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.op.to_tokens(tokens); + self.expr.to_tokens(tokens); + } + } + + impl ToTokens for ExprLit { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.lit.to_tokens(tokens); + } + } + + impl ToTokens for ExprCast { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.expr.to_tokens(tokens); + self.as_token.to_tokens(tokens); + self.ty.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprType { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.expr.to_tokens(tokens); + self.colon_token.to_tokens(tokens); + self.ty.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + fn maybe_wrap_else(tokens: &mut TokenStream, else_: &Option<(Token![else], Box)>) { + if let Some((ref else_token, ref else_)) = *else_ { + else_token.to_tokens(tokens); + + // If we are not one of the valid expressions to exist in an else + // clause, wrap ourselves in a block. + match **else_ { + Expr::If(_) | Expr::IfLet(_) | Expr::Block(_) => { + else_.to_tokens(tokens); + } + _ => { + token::Brace::default().surround(tokens, |tokens| { + else_.to_tokens(tokens); + }); + } + } + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprIf { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.if_token.to_tokens(tokens); + wrap_bare_struct(tokens, &self.cond); + self.then_branch.to_tokens(tokens); + maybe_wrap_else(tokens, &self.else_branch); + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprIfLet { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.if_token.to_tokens(tokens); + self.let_token.to_tokens(tokens); + self.pats.to_tokens(tokens); + self.eq_token.to_tokens(tokens); + wrap_bare_struct(tokens, &self.expr); + self.then_branch.to_tokens(tokens); + maybe_wrap_else(tokens, &self.else_branch); + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprWhile { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.label.to_tokens(tokens); + self.while_token.to_tokens(tokens); + wrap_bare_struct(tokens, &self.cond); + self.body.brace_token.surround(tokens, |tokens| { + inner_attrs_to_tokens(&self.attrs, tokens); + tokens.append_all(&self.body.stmts); + }); + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprWhileLet { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.label.to_tokens(tokens); + self.while_token.to_tokens(tokens); + self.let_token.to_tokens(tokens); + self.pats.to_tokens(tokens); + self.eq_token.to_tokens(tokens); + wrap_bare_struct(tokens, &self.expr); + self.body.brace_token.surround(tokens, |tokens| { + inner_attrs_to_tokens(&self.attrs, tokens); + tokens.append_all(&self.body.stmts); + }); + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprForLoop { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.label.to_tokens(tokens); + self.for_token.to_tokens(tokens); + self.pat.to_tokens(tokens); + self.in_token.to_tokens(tokens); + wrap_bare_struct(tokens, &self.expr); + self.body.brace_token.surround(tokens, |tokens| { + inner_attrs_to_tokens(&self.attrs, tokens); + tokens.append_all(&self.body.stmts); + }); + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprLoop { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.label.to_tokens(tokens); + self.loop_token.to_tokens(tokens); + self.body.brace_token.surround(tokens, |tokens| { + inner_attrs_to_tokens(&self.attrs, tokens); + tokens.append_all(&self.body.stmts); + }); + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprMatch { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.match_token.to_tokens(tokens); + wrap_bare_struct(tokens, &self.expr); + self.brace_token.surround(tokens, |tokens| { + inner_attrs_to_tokens(&self.attrs, tokens); + for (i, arm) in self.arms.iter().enumerate() { + arm.to_tokens(tokens); + // Ensure that we have a comma after a non-block arm, except + // for the last one. + let is_last = i == self.arms.len() - 1; + if !is_last && arm_expr_requires_comma(&arm.body) && arm.comma.is_none() { + ::default().to_tokens(tokens); + } + } + }); + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprCatch { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.do_token.to_tokens(tokens); + self.catch_token.to_tokens(tokens); + self.block.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprYield { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.yield_token.to_tokens(tokens); + self.expr.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprClosure { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.movability.to_tokens(tokens); + self.capture.to_tokens(tokens); + self.or1_token.to_tokens(tokens); + for input in self.inputs.pairs() { + match **input.value() { + FnArg::Captured(ArgCaptured { + ref pat, + ty: Type::Infer(_), + .. + }) => { + pat.to_tokens(tokens); + } + _ => input.value().to_tokens(tokens), + } + input.punct().to_tokens(tokens); + } + self.or2_token.to_tokens(tokens); + self.output.to_tokens(tokens); + self.body.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprUnsafe { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.unsafe_token.to_tokens(tokens); + self.block.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprBlock { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.block.brace_token.surround(tokens, |tokens| { + inner_attrs_to_tokens(&self.attrs, tokens); + tokens.append_all(&self.block.stmts); + }); + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprAssign { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.left.to_tokens(tokens); + self.eq_token.to_tokens(tokens); + self.right.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprAssignOp { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.left.to_tokens(tokens); + self.op.to_tokens(tokens); + self.right.to_tokens(tokens); + } + } + + impl ToTokens for ExprField { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.base.to_tokens(tokens); + self.dot_token.to_tokens(tokens); + self.member.to_tokens(tokens); + } + } + + impl ToTokens for Member { + fn to_tokens(&self, tokens: &mut TokenStream) { + match *self { + Member::Named(ref ident) => ident.to_tokens(tokens), + Member::Unnamed(ref index) => index.to_tokens(tokens), + } + } + } + + impl ToTokens for Index { + fn to_tokens(&self, tokens: &mut TokenStream) { + let mut lit = Literal::i64_unsuffixed(i64::from(self.index)); + lit.set_span(self.span); + tokens.append(lit); + } + } + + impl ToTokens for ExprIndex { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.expr.to_tokens(tokens); + self.bracket_token.surround(tokens, |tokens| { + self.index.to_tokens(tokens); + }); + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprRange { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.from.to_tokens(tokens); + match self.limits { + RangeLimits::HalfOpen(ref t) => t.to_tokens(tokens), + RangeLimits::Closed(ref t) => t.to_tokens(tokens), + } + self.to.to_tokens(tokens); + } + } + + impl ToTokens for ExprPath { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + ::PathTokens(&self.qself, &self.path).to_tokens(tokens) + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprReference { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.and_token.to_tokens(tokens); + self.mutability.to_tokens(tokens); + self.expr.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprBreak { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.break_token.to_tokens(tokens); + self.label.to_tokens(tokens); + self.expr.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprContinue { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.continue_token.to_tokens(tokens); + self.label.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprReturn { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.return_token.to_tokens(tokens); + self.expr.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprMacro { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.mac.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprStruct { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.path.to_tokens(tokens); + self.brace_token.surround(tokens, |tokens| { + inner_attrs_to_tokens(&self.attrs, tokens); + self.fields.to_tokens(tokens); + if self.rest.is_some() { + TokensOrDefault(&self.dot2_token).to_tokens(tokens); + self.rest.to_tokens(tokens); + } + }) + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprRepeat { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.bracket_token.surround(tokens, |tokens| { + inner_attrs_to_tokens(&self.attrs, tokens); + self.expr.to_tokens(tokens); + self.semi_token.to_tokens(tokens); + self.len.to_tokens(tokens); + }) + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprGroup { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.group_token.surround(tokens, |tokens| { + self.expr.to_tokens(tokens); + }); + } + } + + impl ToTokens for ExprParen { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.paren_token.surround(tokens, |tokens| { + inner_attrs_to_tokens(&self.attrs, tokens); + self.expr.to_tokens(tokens); + }); + } + } + + #[cfg(feature = "full")] + impl ToTokens for ExprTry { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.expr.to_tokens(tokens); + self.question_token.to_tokens(tokens); + } + } + + impl ToTokens for ExprVerbatim { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.tts.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for Label { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.name.to_tokens(tokens); + self.colon_token.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for FieldValue { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.member.to_tokens(tokens); + if let Some(ref colon_token) = self.colon_token { + colon_token.to_tokens(tokens); + self.expr.to_tokens(tokens); + } + } + } + + #[cfg(feature = "full")] + impl ToTokens for Arm { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(&self.attrs); + self.leading_vert.to_tokens(tokens); + self.pats.to_tokens(tokens); + if let Some((ref if_token, ref guard)) = self.guard { + if_token.to_tokens(tokens); + guard.to_tokens(tokens); + } + self.fat_arrow_token.to_tokens(tokens); + self.body.to_tokens(tokens); + self.comma.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for PatWild { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.underscore_token.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for PatIdent { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.by_ref.to_tokens(tokens); + self.mutability.to_tokens(tokens); + self.ident.to_tokens(tokens); + if let Some((ref at_token, ref subpat)) = self.subpat { + at_token.to_tokens(tokens); + subpat.to_tokens(tokens); + } + } + } + + #[cfg(feature = "full")] + impl ToTokens for PatStruct { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.path.to_tokens(tokens); + self.brace_token.surround(tokens, |tokens| { + self.fields.to_tokens(tokens); + // NOTE: We need a comma before the dot2 token if it is present. + if !self.fields.empty_or_trailing() && self.dot2_token.is_some() { + ::default().to_tokens(tokens); + } + self.dot2_token.to_tokens(tokens); + }); + } + } + + #[cfg(feature = "full")] + impl ToTokens for PatTupleStruct { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.path.to_tokens(tokens); + self.pat.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for PatPath { + fn to_tokens(&self, tokens: &mut TokenStream) { + ::PathTokens(&self.qself, &self.path).to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for PatTuple { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.paren_token.surround(tokens, |tokens| { + self.front.to_tokens(tokens); + if let Some(ref dot2_token) = self.dot2_token { + if !self.front.empty_or_trailing() { + // Ensure there is a comma before the .. token. + ::default().to_tokens(tokens); + } + dot2_token.to_tokens(tokens); + self.comma_token.to_tokens(tokens); + if self.comma_token.is_none() && !self.back.is_empty() { + // Ensure there is a comma after the .. token. + ::default().to_tokens(tokens); + } + } + self.back.to_tokens(tokens); + }); + } + } + + #[cfg(feature = "full")] + impl ToTokens for PatBox { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.box_token.to_tokens(tokens); + self.pat.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for PatRef { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.and_token.to_tokens(tokens); + self.mutability.to_tokens(tokens); + self.pat.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for PatLit { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.expr.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for PatRange { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.lo.to_tokens(tokens); + match self.limits { + RangeLimits::HalfOpen(ref t) => t.to_tokens(tokens), + RangeLimits::Closed(ref t) => Token![...](t.0).to_tokens(tokens), + } + self.hi.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for PatSlice { + fn to_tokens(&self, tokens: &mut TokenStream) { + // XXX: This is a mess, and it will be so easy to screw it up. How + // do we make this correct itself better? + self.bracket_token.surround(tokens, |tokens| { + self.front.to_tokens(tokens); + + // If we need a comma before the middle or standalone .. token, + // then make sure it's present. + if !self.front.empty_or_trailing() + && (self.middle.is_some() || self.dot2_token.is_some()) + { + ::default().to_tokens(tokens); + } + + // If we have an identifier, we always need a .. token. + if self.middle.is_some() { + self.middle.to_tokens(tokens); + TokensOrDefault(&self.dot2_token).to_tokens(tokens); + } else if self.dot2_token.is_some() { + self.dot2_token.to_tokens(tokens); + } + + // Make sure we have a comma before the back half. + if !self.back.is_empty() { + TokensOrDefault(&self.comma_token).to_tokens(tokens); + self.back.to_tokens(tokens); + } else { + self.comma_token.to_tokens(tokens); + } + }) + } + } + + #[cfg(feature = "full")] + impl ToTokens for PatMacro { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.mac.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for PatVerbatim { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.tts.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for FieldPat { + fn to_tokens(&self, tokens: &mut TokenStream) { + if let Some(ref colon_token) = self.colon_token { + self.member.to_tokens(tokens); + colon_token.to_tokens(tokens); + } + self.pat.to_tokens(tokens); + } + } + + #[cfg(feature = "full")] + impl ToTokens for Block { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.brace_token.surround(tokens, |tokens| { + tokens.append_all(&self.stmts); + }); + } + } + + #[cfg(feature = "full")] + impl ToTokens for Stmt { + fn to_tokens(&self, tokens: &mut TokenStream) { + match *self { + Stmt::Local(ref local) => local.to_tokens(tokens), + Stmt::Item(ref item) => item.to_tokens(tokens), + Stmt::Expr(ref expr) => expr.to_tokens(tokens), + Stmt::Semi(ref expr, ref semi) => { + expr.to_tokens(tokens); + semi.to_tokens(tokens); + } + } + } + } + + #[cfg(feature = "full")] + impl ToTokens for Local { + fn to_tokens(&self, tokens: &mut TokenStream) { + outer_attrs_to_tokens(&self.attrs, tokens); + self.let_token.to_tokens(tokens); + self.pats.to_tokens(tokens); + if let Some((ref colon_token, ref ty)) = self.ty { + colon_token.to_tokens(tokens); + ty.to_tokens(tokens); + } + if let Some((ref eq_token, ref init)) = self.init { + eq_token.to_tokens(tokens); + init.to_tokens(tokens); + } + self.semi_token.to_tokens(tokens); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/file.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/file.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/file.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/file.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,123 @@ +// Copyright 2018 Syn Developers +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use super::*; + +ast_struct! { + /// A complete file of Rust source code. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + /// + /// # Example + /// + /// Parse a Rust source file into a `syn::File` and print out a debug + /// representation of the syntax tree. + /// + /// ``` + /// extern crate syn; + /// + /// use std::env; + /// use std::fs::File; + /// use std::io::Read; + /// use std::process; + /// + /// fn main() { + /// # } + /// # + /// # fn fake_main() { + /// let mut args = env::args(); + /// let _ = args.next(); // executable name + /// + /// let filename = match (args.next(), args.next()) { + /// (Some(filename), None) => filename, + /// _ => { + /// eprintln!("Usage: dump-syntax path/to/filename.rs"); + /// process::exit(1); + /// } + /// }; + /// + /// let mut file = File::open(&filename).expect("Unable to open file"); + /// + /// let mut src = String::new(); + /// file.read_to_string(&mut src).expect("Unable to read file"); + /// + /// let syntax = syn::parse_file(&src).expect("Unable to parse file"); + /// println!("{:#?}", syntax); + /// } + /// ``` + /// + /// Running with its own source code as input, this program prints output + /// that begins with: + /// + /// ```text + /// File { + /// shebang: None, + /// attrs: [], + /// items: [ + /// ExternCrate( + /// ItemExternCrate { + /// attrs: [], + /// vis: Inherited, + /// extern_token: Extern, + /// crate_token: Crate, + /// ident: Ident { + /// term: Term( + /// "syn" + /// ), + /// span: Span + /// }, + /// rename: None, + /// semi_token: Semi + /// } + /// ), + /// ... + /// ``` + pub struct File { + pub shebang: Option, + pub attrs: Vec, + pub items: Vec, + } +} + +#[cfg(feature = "parsing")] +pub mod parsing { + use super::*; + + use synom::Synom; + + impl Synom for File { + named!(parse -> Self, do_parse!( + attrs: many0!(Attribute::parse_inner) >> + items: many0!(Item::parse) >> + (File { + shebang: None, + attrs: attrs, + items: items, + }) + )); + + fn description() -> Option<&'static str> { + Some("crate") + } + } +} + +#[cfg(feature = "printing")] +mod printing { + use super::*; + use attr::FilterAttrs; + use proc_macro2::TokenStream; + use quote::{ToTokens, TokenStreamExt}; + + impl ToTokens for File { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.inner()); + tokens.append_all(&self.items); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/gen/fold.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/gen/fold.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/gen/fold.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/gen/fold.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,2948 @@ +// THIS FILE IS AUTOMATICALLY GENERATED; DO NOT EDIT + +#![allow(unreachable_code)] +#![cfg_attr(feature = "cargo-clippy", allow(needless_pass_by_value))] +#[cfg(any(feature = "full", feature = "derive"))] +use gen::helper::fold::*; +use proc_macro2::Span; +#[cfg(any(feature = "full", feature = "derive"))] +use token::{Brace, Bracket, Group, Paren}; +use *; +#[cfg(feature = "full")] +macro_rules! full { + ($e:expr) => { + $e + }; +} +#[cfg(all(feature = "derive", not(feature = "full")))] +macro_rules! full { + ($e:expr) => { + unreachable!() + }; +} +#[doc = r" Syntax tree traversal to transform the nodes of an owned syntax tree."] +#[doc = r""] +#[doc = r" See the [module documentation] for details."] +#[doc = r""] +#[doc = r" [module documentation]: index.html"] +#[doc = r""] +#[doc = r#" *This trait is available if Syn is built with the `"fold"` feature.*"#] +pub trait Fold { + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_abi(&mut self, i: Abi) -> Abi { + fold_abi(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_angle_bracketed_generic_arguments( + &mut self, + i: AngleBracketedGenericArguments, + ) -> AngleBracketedGenericArguments { + fold_angle_bracketed_generic_arguments(self, i) + } + #[cfg(feature = "full")] + fn fold_arg_captured(&mut self, i: ArgCaptured) -> ArgCaptured { + fold_arg_captured(self, i) + } + #[cfg(feature = "full")] + fn fold_arg_self(&mut self, i: ArgSelf) -> ArgSelf { + fold_arg_self(self, i) + } + #[cfg(feature = "full")] + fn fold_arg_self_ref(&mut self, i: ArgSelfRef) -> ArgSelfRef { + fold_arg_self_ref(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_arm(&mut self, i: Arm) -> Arm { + fold_arm(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_attr_style(&mut self, i: AttrStyle) -> AttrStyle { + fold_attr_style(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_attribute(&mut self, i: Attribute) -> Attribute { + fold_attribute(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_bare_fn_arg(&mut self, i: BareFnArg) -> BareFnArg { + fold_bare_fn_arg(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_bare_fn_arg_name(&mut self, i: BareFnArgName) -> BareFnArgName { + fold_bare_fn_arg_name(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_bin_op(&mut self, i: BinOp) -> BinOp { + fold_bin_op(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_binding(&mut self, i: Binding) -> Binding { + fold_binding(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_block(&mut self, i: Block) -> Block { + fold_block(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_bound_lifetimes(&mut self, i: BoundLifetimes) -> BoundLifetimes { + fold_bound_lifetimes(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_const_param(&mut self, i: ConstParam) -> ConstParam { + fold_const_param(self, i) + } + #[cfg(feature = "derive")] + fn fold_data(&mut self, i: Data) -> Data { + fold_data(self, i) + } + #[cfg(feature = "derive")] + fn fold_data_enum(&mut self, i: DataEnum) -> DataEnum { + fold_data_enum(self, i) + } + #[cfg(feature = "derive")] + fn fold_data_struct(&mut self, i: DataStruct) -> DataStruct { + fold_data_struct(self, i) + } + #[cfg(feature = "derive")] + fn fold_data_union(&mut self, i: DataUnion) -> DataUnion { + fold_data_union(self, i) + } + #[cfg(feature = "derive")] + fn fold_derive_input(&mut self, i: DeriveInput) -> DeriveInput { + fold_derive_input(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr(&mut self, i: Expr) -> Expr { + fold_expr(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_array(&mut self, i: ExprArray) -> ExprArray { + fold_expr_array(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_assign(&mut self, i: ExprAssign) -> ExprAssign { + fold_expr_assign(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_assign_op(&mut self, i: ExprAssignOp) -> ExprAssignOp { + fold_expr_assign_op(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_binary(&mut self, i: ExprBinary) -> ExprBinary { + fold_expr_binary(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_block(&mut self, i: ExprBlock) -> ExprBlock { + fold_expr_block(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_box(&mut self, i: ExprBox) -> ExprBox { + fold_expr_box(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_break(&mut self, i: ExprBreak) -> ExprBreak { + fold_expr_break(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_call(&mut self, i: ExprCall) -> ExprCall { + fold_expr_call(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_cast(&mut self, i: ExprCast) -> ExprCast { + fold_expr_cast(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_catch(&mut self, i: ExprCatch) -> ExprCatch { + fold_expr_catch(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_closure(&mut self, i: ExprClosure) -> ExprClosure { + fold_expr_closure(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_continue(&mut self, i: ExprContinue) -> ExprContinue { + fold_expr_continue(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_field(&mut self, i: ExprField) -> ExprField { + fold_expr_field(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_for_loop(&mut self, i: ExprForLoop) -> ExprForLoop { + fold_expr_for_loop(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_group(&mut self, i: ExprGroup) -> ExprGroup { + fold_expr_group(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_if(&mut self, i: ExprIf) -> ExprIf { + fold_expr_if(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_if_let(&mut self, i: ExprIfLet) -> ExprIfLet { + fold_expr_if_let(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_in_place(&mut self, i: ExprInPlace) -> ExprInPlace { + fold_expr_in_place(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_index(&mut self, i: ExprIndex) -> ExprIndex { + fold_expr_index(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_lit(&mut self, i: ExprLit) -> ExprLit { + fold_expr_lit(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_loop(&mut self, i: ExprLoop) -> ExprLoop { + fold_expr_loop(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_macro(&mut self, i: ExprMacro) -> ExprMacro { + fold_expr_macro(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_match(&mut self, i: ExprMatch) -> ExprMatch { + fold_expr_match(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_method_call(&mut self, i: ExprMethodCall) -> ExprMethodCall { + fold_expr_method_call(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_paren(&mut self, i: ExprParen) -> ExprParen { + fold_expr_paren(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_path(&mut self, i: ExprPath) -> ExprPath { + fold_expr_path(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_range(&mut self, i: ExprRange) -> ExprRange { + fold_expr_range(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_reference(&mut self, i: ExprReference) -> ExprReference { + fold_expr_reference(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_repeat(&mut self, i: ExprRepeat) -> ExprRepeat { + fold_expr_repeat(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_return(&mut self, i: ExprReturn) -> ExprReturn { + fold_expr_return(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_struct(&mut self, i: ExprStruct) -> ExprStruct { + fold_expr_struct(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_try(&mut self, i: ExprTry) -> ExprTry { + fold_expr_try(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_tuple(&mut self, i: ExprTuple) -> ExprTuple { + fold_expr_tuple(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_type(&mut self, i: ExprType) -> ExprType { + fold_expr_type(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_unary(&mut self, i: ExprUnary) -> ExprUnary { + fold_expr_unary(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_unsafe(&mut self, i: ExprUnsafe) -> ExprUnsafe { + fold_expr_unsafe(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_verbatim(&mut self, i: ExprVerbatim) -> ExprVerbatim { + fold_expr_verbatim(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_while(&mut self, i: ExprWhile) -> ExprWhile { + fold_expr_while(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_while_let(&mut self, i: ExprWhileLet) -> ExprWhileLet { + fold_expr_while_let(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_expr_yield(&mut self, i: ExprYield) -> ExprYield { + fold_expr_yield(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_field(&mut self, i: Field) -> Field { + fold_field(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_field_pat(&mut self, i: FieldPat) -> FieldPat { + fold_field_pat(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_field_value(&mut self, i: FieldValue) -> FieldValue { + fold_field_value(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_fields(&mut self, i: Fields) -> Fields { + fold_fields(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_fields_named(&mut self, i: FieldsNamed) -> FieldsNamed { + fold_fields_named(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_fields_unnamed(&mut self, i: FieldsUnnamed) -> FieldsUnnamed { + fold_fields_unnamed(self, i) + } + #[cfg(feature = "full")] + fn fold_file(&mut self, i: File) -> File { + fold_file(self, i) + } + #[cfg(feature = "full")] + fn fold_fn_arg(&mut self, i: FnArg) -> FnArg { + fold_fn_arg(self, i) + } + #[cfg(feature = "full")] + fn fold_fn_decl(&mut self, i: FnDecl) -> FnDecl { + fold_fn_decl(self, i) + } + #[cfg(feature = "full")] + fn fold_foreign_item(&mut self, i: ForeignItem) -> ForeignItem { + fold_foreign_item(self, i) + } + #[cfg(feature = "full")] + fn fold_foreign_item_fn(&mut self, i: ForeignItemFn) -> ForeignItemFn { + fold_foreign_item_fn(self, i) + } + #[cfg(feature = "full")] + fn fold_foreign_item_static(&mut self, i: ForeignItemStatic) -> ForeignItemStatic { + fold_foreign_item_static(self, i) + } + #[cfg(feature = "full")] + fn fold_foreign_item_type(&mut self, i: ForeignItemType) -> ForeignItemType { + fold_foreign_item_type(self, i) + } + #[cfg(feature = "full")] + fn fold_foreign_item_verbatim(&mut self, i: ForeignItemVerbatim) -> ForeignItemVerbatim { + fold_foreign_item_verbatim(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_generic_argument(&mut self, i: GenericArgument) -> GenericArgument { + fold_generic_argument(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_generic_method_argument(&mut self, i: GenericMethodArgument) -> GenericMethodArgument { + fold_generic_method_argument(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_generic_param(&mut self, i: GenericParam) -> GenericParam { + fold_generic_param(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_generics(&mut self, i: Generics) -> Generics { + fold_generics(self, i) + } + fn fold_ident(&mut self, i: Ident) -> Ident { + fold_ident(self, i) + } + #[cfg(feature = "full")] + fn fold_impl_item(&mut self, i: ImplItem) -> ImplItem { + fold_impl_item(self, i) + } + #[cfg(feature = "full")] + fn fold_impl_item_const(&mut self, i: ImplItemConst) -> ImplItemConst { + fold_impl_item_const(self, i) + } + #[cfg(feature = "full")] + fn fold_impl_item_macro(&mut self, i: ImplItemMacro) -> ImplItemMacro { + fold_impl_item_macro(self, i) + } + #[cfg(feature = "full")] + fn fold_impl_item_method(&mut self, i: ImplItemMethod) -> ImplItemMethod { + fold_impl_item_method(self, i) + } + #[cfg(feature = "full")] + fn fold_impl_item_type(&mut self, i: ImplItemType) -> ImplItemType { + fold_impl_item_type(self, i) + } + #[cfg(feature = "full")] + fn fold_impl_item_verbatim(&mut self, i: ImplItemVerbatim) -> ImplItemVerbatim { + fold_impl_item_verbatim(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_index(&mut self, i: Index) -> Index { + fold_index(self, i) + } + #[cfg(feature = "full")] + fn fold_item(&mut self, i: Item) -> Item { + fold_item(self, i) + } + #[cfg(feature = "full")] + fn fold_item_const(&mut self, i: ItemConst) -> ItemConst { + fold_item_const(self, i) + } + #[cfg(feature = "full")] + fn fold_item_enum(&mut self, i: ItemEnum) -> ItemEnum { + fold_item_enum(self, i) + } + #[cfg(feature = "full")] + fn fold_item_extern_crate(&mut self, i: ItemExternCrate) -> ItemExternCrate { + fold_item_extern_crate(self, i) + } + #[cfg(feature = "full")] + fn fold_item_fn(&mut self, i: ItemFn) -> ItemFn { + fold_item_fn(self, i) + } + #[cfg(feature = "full")] + fn fold_item_foreign_mod(&mut self, i: ItemForeignMod) -> ItemForeignMod { + fold_item_foreign_mod(self, i) + } + #[cfg(feature = "full")] + fn fold_item_impl(&mut self, i: ItemImpl) -> ItemImpl { + fold_item_impl(self, i) + } + #[cfg(feature = "full")] + fn fold_item_macro(&mut self, i: ItemMacro) -> ItemMacro { + fold_item_macro(self, i) + } + #[cfg(feature = "full")] + fn fold_item_macro2(&mut self, i: ItemMacro2) -> ItemMacro2 { + fold_item_macro2(self, i) + } + #[cfg(feature = "full")] + fn fold_item_mod(&mut self, i: ItemMod) -> ItemMod { + fold_item_mod(self, i) + } + #[cfg(feature = "full")] + fn fold_item_static(&mut self, i: ItemStatic) -> ItemStatic { + fold_item_static(self, i) + } + #[cfg(feature = "full")] + fn fold_item_struct(&mut self, i: ItemStruct) -> ItemStruct { + fold_item_struct(self, i) + } + #[cfg(feature = "full")] + fn fold_item_trait(&mut self, i: ItemTrait) -> ItemTrait { + fold_item_trait(self, i) + } + #[cfg(feature = "full")] + fn fold_item_type(&mut self, i: ItemType) -> ItemType { + fold_item_type(self, i) + } + #[cfg(feature = "full")] + fn fold_item_union(&mut self, i: ItemUnion) -> ItemUnion { + fold_item_union(self, i) + } + #[cfg(feature = "full")] + fn fold_item_use(&mut self, i: ItemUse) -> ItemUse { + fold_item_use(self, i) + } + #[cfg(feature = "full")] + fn fold_item_verbatim(&mut self, i: ItemVerbatim) -> ItemVerbatim { + fold_item_verbatim(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_label(&mut self, i: Label) -> Label { + fold_label(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_lifetime(&mut self, i: Lifetime) -> Lifetime { + fold_lifetime(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_lifetime_def(&mut self, i: LifetimeDef) -> LifetimeDef { + fold_lifetime_def(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_lit(&mut self, i: Lit) -> Lit { + fold_lit(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_lit_bool(&mut self, i: LitBool) -> LitBool { + fold_lit_bool(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_lit_byte(&mut self, i: LitByte) -> LitByte { + fold_lit_byte(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_lit_byte_str(&mut self, i: LitByteStr) -> LitByteStr { + fold_lit_byte_str(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_lit_char(&mut self, i: LitChar) -> LitChar { + fold_lit_char(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_lit_float(&mut self, i: LitFloat) -> LitFloat { + fold_lit_float(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_lit_int(&mut self, i: LitInt) -> LitInt { + fold_lit_int(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_lit_str(&mut self, i: LitStr) -> LitStr { + fold_lit_str(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_lit_verbatim(&mut self, i: LitVerbatim) -> LitVerbatim { + fold_lit_verbatim(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_local(&mut self, i: Local) -> Local { + fold_local(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_macro(&mut self, i: Macro) -> Macro { + fold_macro(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_macro_delimiter(&mut self, i: MacroDelimiter) -> MacroDelimiter { + fold_macro_delimiter(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_member(&mut self, i: Member) -> Member { + fold_member(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_meta(&mut self, i: Meta) -> Meta { + fold_meta(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_meta_list(&mut self, i: MetaList) -> MetaList { + fold_meta_list(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_meta_name_value(&mut self, i: MetaNameValue) -> MetaNameValue { + fold_meta_name_value(self, i) + } + #[cfg(feature = "full")] + fn fold_method_sig(&mut self, i: MethodSig) -> MethodSig { + fold_method_sig(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_method_turbofish(&mut self, i: MethodTurbofish) -> MethodTurbofish { + fold_method_turbofish(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_nested_meta(&mut self, i: NestedMeta) -> NestedMeta { + fold_nested_meta(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_parenthesized_generic_arguments( + &mut self, + i: ParenthesizedGenericArguments, + ) -> ParenthesizedGenericArguments { + fold_parenthesized_generic_arguments(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_pat(&mut self, i: Pat) -> Pat { + fold_pat(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_pat_box(&mut self, i: PatBox) -> PatBox { + fold_pat_box(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_pat_ident(&mut self, i: PatIdent) -> PatIdent { + fold_pat_ident(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_pat_lit(&mut self, i: PatLit) -> PatLit { + fold_pat_lit(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_pat_macro(&mut self, i: PatMacro) -> PatMacro { + fold_pat_macro(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_pat_path(&mut self, i: PatPath) -> PatPath { + fold_pat_path(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_pat_range(&mut self, i: PatRange) -> PatRange { + fold_pat_range(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_pat_ref(&mut self, i: PatRef) -> PatRef { + fold_pat_ref(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_pat_slice(&mut self, i: PatSlice) -> PatSlice { + fold_pat_slice(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_pat_struct(&mut self, i: PatStruct) -> PatStruct { + fold_pat_struct(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_pat_tuple(&mut self, i: PatTuple) -> PatTuple { + fold_pat_tuple(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_pat_tuple_struct(&mut self, i: PatTupleStruct) -> PatTupleStruct { + fold_pat_tuple_struct(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_pat_verbatim(&mut self, i: PatVerbatim) -> PatVerbatim { + fold_pat_verbatim(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_pat_wild(&mut self, i: PatWild) -> PatWild { + fold_pat_wild(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_path(&mut self, i: Path) -> Path { + fold_path(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_path_arguments(&mut self, i: PathArguments) -> PathArguments { + fold_path_arguments(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_path_segment(&mut self, i: PathSegment) -> PathSegment { + fold_path_segment(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_predicate_eq(&mut self, i: PredicateEq) -> PredicateEq { + fold_predicate_eq(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_predicate_lifetime(&mut self, i: PredicateLifetime) -> PredicateLifetime { + fold_predicate_lifetime(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_predicate_type(&mut self, i: PredicateType) -> PredicateType { + fold_predicate_type(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_qself(&mut self, i: QSelf) -> QSelf { + fold_qself(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_range_limits(&mut self, i: RangeLimits) -> RangeLimits { + fold_range_limits(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_return_type(&mut self, i: ReturnType) -> ReturnType { + fold_return_type(self, i) + } + fn fold_span(&mut self, i: Span) -> Span { + fold_span(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn fold_stmt(&mut self, i: Stmt) -> Stmt { + fold_stmt(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_trait_bound(&mut self, i: TraitBound) -> TraitBound { + fold_trait_bound(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_trait_bound_modifier(&mut self, i: TraitBoundModifier) -> TraitBoundModifier { + fold_trait_bound_modifier(self, i) + } + #[cfg(feature = "full")] + fn fold_trait_item(&mut self, i: TraitItem) -> TraitItem { + fold_trait_item(self, i) + } + #[cfg(feature = "full")] + fn fold_trait_item_const(&mut self, i: TraitItemConst) -> TraitItemConst { + fold_trait_item_const(self, i) + } + #[cfg(feature = "full")] + fn fold_trait_item_macro(&mut self, i: TraitItemMacro) -> TraitItemMacro { + fold_trait_item_macro(self, i) + } + #[cfg(feature = "full")] + fn fold_trait_item_method(&mut self, i: TraitItemMethod) -> TraitItemMethod { + fold_trait_item_method(self, i) + } + #[cfg(feature = "full")] + fn fold_trait_item_type(&mut self, i: TraitItemType) -> TraitItemType { + fold_trait_item_type(self, i) + } + #[cfg(feature = "full")] + fn fold_trait_item_verbatim(&mut self, i: TraitItemVerbatim) -> TraitItemVerbatim { + fold_trait_item_verbatim(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_type(&mut self, i: Type) -> Type { + fold_type(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_type_array(&mut self, i: TypeArray) -> TypeArray { + fold_type_array(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_type_bare_fn(&mut self, i: TypeBareFn) -> TypeBareFn { + fold_type_bare_fn(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_type_group(&mut self, i: TypeGroup) -> TypeGroup { + fold_type_group(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_type_impl_trait(&mut self, i: TypeImplTrait) -> TypeImplTrait { + fold_type_impl_trait(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_type_infer(&mut self, i: TypeInfer) -> TypeInfer { + fold_type_infer(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_type_macro(&mut self, i: TypeMacro) -> TypeMacro { + fold_type_macro(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_type_never(&mut self, i: TypeNever) -> TypeNever { + fold_type_never(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_type_param(&mut self, i: TypeParam) -> TypeParam { + fold_type_param(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_type_param_bound(&mut self, i: TypeParamBound) -> TypeParamBound { + fold_type_param_bound(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_type_paren(&mut self, i: TypeParen) -> TypeParen { + fold_type_paren(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_type_path(&mut self, i: TypePath) -> TypePath { + fold_type_path(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_type_ptr(&mut self, i: TypePtr) -> TypePtr { + fold_type_ptr(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_type_reference(&mut self, i: TypeReference) -> TypeReference { + fold_type_reference(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_type_slice(&mut self, i: TypeSlice) -> TypeSlice { + fold_type_slice(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_type_trait_object(&mut self, i: TypeTraitObject) -> TypeTraitObject { + fold_type_trait_object(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_type_tuple(&mut self, i: TypeTuple) -> TypeTuple { + fold_type_tuple(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_type_verbatim(&mut self, i: TypeVerbatim) -> TypeVerbatim { + fold_type_verbatim(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_un_op(&mut self, i: UnOp) -> UnOp { + fold_un_op(self, i) + } + #[cfg(feature = "full")] + fn fold_use_glob(&mut self, i: UseGlob) -> UseGlob { + fold_use_glob(self, i) + } + #[cfg(feature = "full")] + fn fold_use_group(&mut self, i: UseGroup) -> UseGroup { + fold_use_group(self, i) + } + #[cfg(feature = "full")] + fn fold_use_name(&mut self, i: UseName) -> UseName { + fold_use_name(self, i) + } + #[cfg(feature = "full")] + fn fold_use_path(&mut self, i: UsePath) -> UsePath { + fold_use_path(self, i) + } + #[cfg(feature = "full")] + fn fold_use_rename(&mut self, i: UseRename) -> UseRename { + fold_use_rename(self, i) + } + #[cfg(feature = "full")] + fn fold_use_tree(&mut self, i: UseTree) -> UseTree { + fold_use_tree(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_variant(&mut self, i: Variant) -> Variant { + fold_variant(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_vis_crate(&mut self, i: VisCrate) -> VisCrate { + fold_vis_crate(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_vis_public(&mut self, i: VisPublic) -> VisPublic { + fold_vis_public(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_vis_restricted(&mut self, i: VisRestricted) -> VisRestricted { + fold_vis_restricted(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_visibility(&mut self, i: Visibility) -> Visibility { + fold_visibility(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_where_clause(&mut self, i: WhereClause) -> WhereClause { + fold_where_clause(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn fold_where_predicate(&mut self, i: WherePredicate) -> WherePredicate { + fold_where_predicate(self, i) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +macro_rules! fold_span_only { + ($f:ident : $t:ident) => { + pub fn $f(_visitor: &mut V, mut _i: $t) -> $t { + let span = _visitor.fold_span(_i.span()); + _i.set_span(span); + _i + } + }; +} +#[cfg(any(feature = "full", feature = "derive"))] +fold_span_only!(fold_lit_byte: LitByte); +#[cfg(any(feature = "full", feature = "derive"))] +fold_span_only!(fold_lit_byte_str: LitByteStr); +#[cfg(any(feature = "full", feature = "derive"))] +fold_span_only!(fold_lit_char: LitChar); +#[cfg(any(feature = "full", feature = "derive"))] +fold_span_only!(fold_lit_float: LitFloat); +#[cfg(any(feature = "full", feature = "derive"))] +fold_span_only!(fold_lit_int: LitInt); +#[cfg(any(feature = "full", feature = "derive"))] +fold_span_only!(fold_lit_str: LitStr); +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_abi(_visitor: &mut V, _i: Abi) -> Abi { + Abi { + extern_token: Token![extern](tokens_helper(_visitor, &(_i.extern_token).0)), + name: (_i.name).map(|it| _visitor.fold_lit_str(it)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_angle_bracketed_generic_arguments( + _visitor: &mut V, + _i: AngleBracketedGenericArguments, +) -> AngleBracketedGenericArguments { + AngleBracketedGenericArguments { + colon2_token: (_i.colon2_token).map(|it| Token ! [ :: ](tokens_helper(_visitor, &(it).0))), + lt_token: Token ! [ < ](tokens_helper(_visitor, &(_i.lt_token).0)), + args: FoldHelper::lift(_i.args, |it| _visitor.fold_generic_argument(it)), + gt_token: Token ! [ > ](tokens_helper(_visitor, &(_i.gt_token).0)), + } +} +#[cfg(feature = "full")] +pub fn fold_arg_captured(_visitor: &mut V, _i: ArgCaptured) -> ArgCaptured { + ArgCaptured { + pat: _visitor.fold_pat(_i.pat), + colon_token: Token ! [ : ](tokens_helper(_visitor, &(_i.colon_token).0)), + ty: _visitor.fold_type(_i.ty), + } +} +#[cfg(feature = "full")] +pub fn fold_arg_self(_visitor: &mut V, _i: ArgSelf) -> ArgSelf { + ArgSelf { + mutability: (_i.mutability).map(|it| Token ! [ mut ](tokens_helper(_visitor, &(it).0))), + self_token: Token![self](tokens_helper(_visitor, &(_i.self_token).0)), + } +} +#[cfg(feature = "full")] +pub fn fold_arg_self_ref(_visitor: &mut V, _i: ArgSelfRef) -> ArgSelfRef { + ArgSelfRef { + and_token: Token ! [ & ](tokens_helper(_visitor, &(_i.and_token).0)), + lifetime: (_i.lifetime).map(|it| _visitor.fold_lifetime(it)), + mutability: (_i.mutability).map(|it| Token ! [ mut ](tokens_helper(_visitor, &(it).0))), + self_token: Token![self](tokens_helper(_visitor, &(_i.self_token).0)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_arm(_visitor: &mut V, _i: Arm) -> Arm { + Arm { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + leading_vert: (_i.leading_vert).map(|it| Token ! [ | ](tokens_helper(_visitor, &(it).0))), + pats: FoldHelper::lift(_i.pats, |it| _visitor.fold_pat(it)), + guard: (_i.guard).map(|it| { + ( + Token ! [ if ](tokens_helper(_visitor, &((it).0).0)), + Box::new(_visitor.fold_expr(*(it).1)), + ) + }), + fat_arrow_token: Token ! [ => ](tokens_helper(_visitor, &(_i.fat_arrow_token).0)), + body: Box::new(_visitor.fold_expr(*_i.body)), + comma: (_i.comma).map(|it| Token ! [ , ](tokens_helper(_visitor, &(it).0))), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_attr_style(_visitor: &mut V, _i: AttrStyle) -> AttrStyle { + match _i { + AttrStyle::Outer => AttrStyle::Outer, + AttrStyle::Inner(_binding_0) => { + AttrStyle::Inner(Token![!](tokens_helper(_visitor, &(_binding_0).0))) + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_attribute(_visitor: &mut V, _i: Attribute) -> Attribute { + Attribute { + pound_token: Token ! [ # ](tokens_helper(_visitor, &(_i.pound_token).0)), + style: _visitor.fold_attr_style(_i.style), + bracket_token: Bracket(tokens_helper(_visitor, &(_i.bracket_token).0)), + path: _visitor.fold_path(_i.path), + tts: _i.tts, + is_sugared_doc: _i.is_sugared_doc, + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_bare_fn_arg(_visitor: &mut V, _i: BareFnArg) -> BareFnArg { + BareFnArg { + name: (_i.name).map(|it| { + ( + _visitor.fold_bare_fn_arg_name((it).0), + Token ! [ : ](tokens_helper(_visitor, &((it).1).0)), + ) + }), + ty: _visitor.fold_type(_i.ty), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_bare_fn_arg_name( + _visitor: &mut V, + _i: BareFnArgName, +) -> BareFnArgName { + match _i { + BareFnArgName::Named(_binding_0) => BareFnArgName::Named(_visitor.fold_ident(_binding_0)), + BareFnArgName::Wild(_binding_0) => { + BareFnArgName::Wild(Token![_](tokens_helper(_visitor, &(_binding_0).0))) + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_bin_op(_visitor: &mut V, _i: BinOp) -> BinOp { + match _i { + BinOp::Add(_binding_0) => { + BinOp::Add(Token ! [ + ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::Sub(_binding_0) => { + BinOp::Sub(Token ! [ - ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::Mul(_binding_0) => { + BinOp::Mul(Token ! [ * ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::Div(_binding_0) => { + BinOp::Div(Token ! [ / ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::Rem(_binding_0) => { + BinOp::Rem(Token ! [ % ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::And(_binding_0) => { + BinOp::And(Token ! [ && ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::Or(_binding_0) => { + BinOp::Or(Token ! [ || ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::BitXor(_binding_0) => { + BinOp::BitXor(Token ! [ ^ ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::BitAnd(_binding_0) => { + BinOp::BitAnd(Token ! [ & ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::BitOr(_binding_0) => { + BinOp::BitOr(Token ! [ | ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::Shl(_binding_0) => { + BinOp::Shl(Token ! [ << ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::Shr(_binding_0) => { + BinOp::Shr(Token ! [ >> ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::Eq(_binding_0) => { + BinOp::Eq(Token ! [ == ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::Lt(_binding_0) => BinOp::Lt(Token ! [ < ](tokens_helper(_visitor, &(_binding_0).0))), + BinOp::Le(_binding_0) => { + BinOp::Le(Token ! [ <= ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::Ne(_binding_0) => { + BinOp::Ne(Token ! [ != ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::Ge(_binding_0) => { + BinOp::Ge(Token ! [ >= ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::Gt(_binding_0) => BinOp::Gt(Token ! [ > ](tokens_helper(_visitor, &(_binding_0).0))), + BinOp::AddEq(_binding_0) => { + BinOp::AddEq(Token ! [ += ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::SubEq(_binding_0) => { + BinOp::SubEq(Token ! [ -= ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::MulEq(_binding_0) => { + BinOp::MulEq(Token ! [ *= ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::DivEq(_binding_0) => { + BinOp::DivEq(Token ! [ /= ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::RemEq(_binding_0) => { + BinOp::RemEq(Token ! [ %= ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::BitXorEq(_binding_0) => { + BinOp::BitXorEq(Token ! [ ^= ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::BitAndEq(_binding_0) => { + BinOp::BitAndEq(Token ! [ &= ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::BitOrEq(_binding_0) => { + BinOp::BitOrEq(Token ! [ |= ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::ShlEq(_binding_0) => { + BinOp::ShlEq(Token ! [ <<= ](tokens_helper(_visitor, &(_binding_0).0))) + } + BinOp::ShrEq(_binding_0) => { + BinOp::ShrEq(Token ! [ >>= ](tokens_helper(_visitor, &(_binding_0).0))) + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_binding(_visitor: &mut V, _i: Binding) -> Binding { + Binding { + ident: _visitor.fold_ident(_i.ident), + eq_token: Token ! [ = ](tokens_helper(_visitor, &(_i.eq_token).0)), + ty: _visitor.fold_type(_i.ty), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_block(_visitor: &mut V, _i: Block) -> Block { + Block { + brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), + stmts: FoldHelper::lift(_i.stmts, |it| _visitor.fold_stmt(it)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_bound_lifetimes( + _visitor: &mut V, + _i: BoundLifetimes, +) -> BoundLifetimes { + BoundLifetimes { + for_token: Token ! [ for ](tokens_helper(_visitor, &(_i.for_token).0)), + lt_token: Token ! [ < ](tokens_helper(_visitor, &(_i.lt_token).0)), + lifetimes: FoldHelper::lift(_i.lifetimes, |it| _visitor.fold_lifetime_def(it)), + gt_token: Token ! [ > ](tokens_helper(_visitor, &(_i.gt_token).0)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_const_param(_visitor: &mut V, _i: ConstParam) -> ConstParam { + ConstParam { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + const_token: Token ! [ const ](tokens_helper(_visitor, &(_i.const_token).0)), + ident: _visitor.fold_ident(_i.ident), + colon_token: Token ! [ : ](tokens_helper(_visitor, &(_i.colon_token).0)), + ty: _visitor.fold_type(_i.ty), + eq_token: (_i.eq_token).map(|it| Token ! [ = ](tokens_helper(_visitor, &(it).0))), + default: (_i.default).map(|it| _visitor.fold_expr(it)), + } +} +#[cfg(feature = "derive")] +pub fn fold_data(_visitor: &mut V, _i: Data) -> Data { + match _i { + Data::Struct(_binding_0) => Data::Struct(_visitor.fold_data_struct(_binding_0)), + Data::Enum(_binding_0) => Data::Enum(_visitor.fold_data_enum(_binding_0)), + Data::Union(_binding_0) => Data::Union(_visitor.fold_data_union(_binding_0)), + } +} +#[cfg(feature = "derive")] +pub fn fold_data_enum(_visitor: &mut V, _i: DataEnum) -> DataEnum { + DataEnum { + enum_token: Token ! [ enum ](tokens_helper(_visitor, &(_i.enum_token).0)), + brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), + variants: FoldHelper::lift(_i.variants, |it| _visitor.fold_variant(it)), + } +} +#[cfg(feature = "derive")] +pub fn fold_data_struct(_visitor: &mut V, _i: DataStruct) -> DataStruct { + DataStruct { + struct_token: Token ! [ struct ](tokens_helper(_visitor, &(_i.struct_token).0)), + fields: _visitor.fold_fields(_i.fields), + semi_token: (_i.semi_token).map(|it| Token ! [ ; ](tokens_helper(_visitor, &(it).0))), + } +} +#[cfg(feature = "derive")] +pub fn fold_data_union(_visitor: &mut V, _i: DataUnion) -> DataUnion { + DataUnion { + union_token: Token![union](tokens_helper(_visitor, &(_i.union_token).0)), + fields: _visitor.fold_fields_named(_i.fields), + } +} +#[cfg(feature = "derive")] +pub fn fold_derive_input(_visitor: &mut V, _i: DeriveInput) -> DeriveInput { + DeriveInput { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + vis: _visitor.fold_visibility(_i.vis), + ident: _visitor.fold_ident(_i.ident), + generics: _visitor.fold_generics(_i.generics), + data: _visitor.fold_data(_i.data), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr(_visitor: &mut V, _i: Expr) -> Expr { + match _i { + Expr::Box(_binding_0) => Expr::Box(full!(_visitor.fold_expr_box(_binding_0))), + Expr::InPlace(_binding_0) => Expr::InPlace(full!(_visitor.fold_expr_in_place(_binding_0))), + Expr::Array(_binding_0) => Expr::Array(full!(_visitor.fold_expr_array(_binding_0))), + Expr::Call(_binding_0) => Expr::Call(_visitor.fold_expr_call(_binding_0)), + Expr::MethodCall(_binding_0) => { + Expr::MethodCall(full!(_visitor.fold_expr_method_call(_binding_0))) + } + Expr::Tuple(_binding_0) => Expr::Tuple(full!(_visitor.fold_expr_tuple(_binding_0))), + Expr::Binary(_binding_0) => Expr::Binary(_visitor.fold_expr_binary(_binding_0)), + Expr::Unary(_binding_0) => Expr::Unary(_visitor.fold_expr_unary(_binding_0)), + Expr::Lit(_binding_0) => Expr::Lit(_visitor.fold_expr_lit(_binding_0)), + Expr::Cast(_binding_0) => Expr::Cast(_visitor.fold_expr_cast(_binding_0)), + Expr::Type(_binding_0) => Expr::Type(full!(_visitor.fold_expr_type(_binding_0))), + Expr::If(_binding_0) => Expr::If(full!(_visitor.fold_expr_if(_binding_0))), + Expr::IfLet(_binding_0) => Expr::IfLet(full!(_visitor.fold_expr_if_let(_binding_0))), + Expr::While(_binding_0) => Expr::While(full!(_visitor.fold_expr_while(_binding_0))), + Expr::WhileLet(_binding_0) => { + Expr::WhileLet(full!(_visitor.fold_expr_while_let(_binding_0))) + } + Expr::ForLoop(_binding_0) => Expr::ForLoop(full!(_visitor.fold_expr_for_loop(_binding_0))), + Expr::Loop(_binding_0) => Expr::Loop(full!(_visitor.fold_expr_loop(_binding_0))), + Expr::Match(_binding_0) => Expr::Match(full!(_visitor.fold_expr_match(_binding_0))), + Expr::Closure(_binding_0) => Expr::Closure(full!(_visitor.fold_expr_closure(_binding_0))), + Expr::Unsafe(_binding_0) => Expr::Unsafe(full!(_visitor.fold_expr_unsafe(_binding_0))), + Expr::Block(_binding_0) => Expr::Block(full!(_visitor.fold_expr_block(_binding_0))), + Expr::Assign(_binding_0) => Expr::Assign(full!(_visitor.fold_expr_assign(_binding_0))), + Expr::AssignOp(_binding_0) => { + Expr::AssignOp(full!(_visitor.fold_expr_assign_op(_binding_0))) + } + Expr::Field(_binding_0) => Expr::Field(_visitor.fold_expr_field(_binding_0)), + Expr::Index(_binding_0) => Expr::Index(_visitor.fold_expr_index(_binding_0)), + Expr::Range(_binding_0) => Expr::Range(full!(_visitor.fold_expr_range(_binding_0))), + Expr::Path(_binding_0) => Expr::Path(_visitor.fold_expr_path(_binding_0)), + Expr::Reference(_binding_0) => { + Expr::Reference(full!(_visitor.fold_expr_reference(_binding_0))) + } + Expr::Break(_binding_0) => Expr::Break(full!(_visitor.fold_expr_break(_binding_0))), + Expr::Continue(_binding_0) => { + Expr::Continue(full!(_visitor.fold_expr_continue(_binding_0))) + } + Expr::Return(_binding_0) => Expr::Return(full!(_visitor.fold_expr_return(_binding_0))), + Expr::Macro(_binding_0) => Expr::Macro(full!(_visitor.fold_expr_macro(_binding_0))), + Expr::Struct(_binding_0) => Expr::Struct(full!(_visitor.fold_expr_struct(_binding_0))), + Expr::Repeat(_binding_0) => Expr::Repeat(full!(_visitor.fold_expr_repeat(_binding_0))), + Expr::Paren(_binding_0) => Expr::Paren(_visitor.fold_expr_paren(_binding_0)), + Expr::Group(_binding_0) => Expr::Group(full!(_visitor.fold_expr_group(_binding_0))), + Expr::Try(_binding_0) => Expr::Try(full!(_visitor.fold_expr_try(_binding_0))), + Expr::Catch(_binding_0) => Expr::Catch(full!(_visitor.fold_expr_catch(_binding_0))), + Expr::Yield(_binding_0) => Expr::Yield(full!(_visitor.fold_expr_yield(_binding_0))), + Expr::Verbatim(_binding_0) => Expr::Verbatim(_visitor.fold_expr_verbatim(_binding_0)), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_array(_visitor: &mut V, _i: ExprArray) -> ExprArray { + ExprArray { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + bracket_token: Bracket(tokens_helper(_visitor, &(_i.bracket_token).0)), + elems: FoldHelper::lift(_i.elems, |it| _visitor.fold_expr(it)), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_assign(_visitor: &mut V, _i: ExprAssign) -> ExprAssign { + ExprAssign { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + left: Box::new(_visitor.fold_expr(*_i.left)), + eq_token: Token ! [ = ](tokens_helper(_visitor, &(_i.eq_token).0)), + right: Box::new(_visitor.fold_expr(*_i.right)), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_assign_op(_visitor: &mut V, _i: ExprAssignOp) -> ExprAssignOp { + ExprAssignOp { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + left: Box::new(_visitor.fold_expr(*_i.left)), + op: _visitor.fold_bin_op(_i.op), + right: Box::new(_visitor.fold_expr(*_i.right)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_binary(_visitor: &mut V, _i: ExprBinary) -> ExprBinary { + ExprBinary { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + left: Box::new(_visitor.fold_expr(*_i.left)), + op: _visitor.fold_bin_op(_i.op), + right: Box::new(_visitor.fold_expr(*_i.right)), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_block(_visitor: &mut V, _i: ExprBlock) -> ExprBlock { + ExprBlock { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + block: _visitor.fold_block(_i.block), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_box(_visitor: &mut V, _i: ExprBox) -> ExprBox { + ExprBox { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + box_token: Token ! [ box ](tokens_helper(_visitor, &(_i.box_token).0)), + expr: Box::new(_visitor.fold_expr(*_i.expr)), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_break(_visitor: &mut V, _i: ExprBreak) -> ExprBreak { + ExprBreak { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + break_token: Token![break](tokens_helper(_visitor, &(_i.break_token).0)), + label: (_i.label).map(|it| _visitor.fold_lifetime(it)), + expr: (_i.expr).map(|it| Box::new(_visitor.fold_expr(*it))), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_call(_visitor: &mut V, _i: ExprCall) -> ExprCall { + ExprCall { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + func: Box::new(_visitor.fold_expr(*_i.func)), + paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), + args: FoldHelper::lift(_i.args, |it| _visitor.fold_expr(it)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_cast(_visitor: &mut V, _i: ExprCast) -> ExprCast { + ExprCast { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + expr: Box::new(_visitor.fold_expr(*_i.expr)), + as_token: Token ! [ as ](tokens_helper(_visitor, &(_i.as_token).0)), + ty: Box::new(_visitor.fold_type(*_i.ty)), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_catch(_visitor: &mut V, _i: ExprCatch) -> ExprCatch { + ExprCatch { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + do_token: Token ! [ do ](tokens_helper(_visitor, &(_i.do_token).0)), + catch_token: Token![catch](tokens_helper(_visitor, &(_i.catch_token).0)), + block: _visitor.fold_block(_i.block), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_closure(_visitor: &mut V, _i: ExprClosure) -> ExprClosure { + ExprClosure { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + movability: (_i.movability).map(|it| Token ! [ static ](tokens_helper(_visitor, &(it).0))), + capture: (_i.capture).map(|it| Token ! [ move ](tokens_helper(_visitor, &(it).0))), + or1_token: Token ! [ | ](tokens_helper(_visitor, &(_i.or1_token).0)), + inputs: FoldHelper::lift(_i.inputs, |it| _visitor.fold_fn_arg(it)), + or2_token: Token ! [ | ](tokens_helper(_visitor, &(_i.or2_token).0)), + output: _visitor.fold_return_type(_i.output), + body: Box::new(_visitor.fold_expr(*_i.body)), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_continue(_visitor: &mut V, _i: ExprContinue) -> ExprContinue { + ExprContinue { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + continue_token: Token![continue](tokens_helper(_visitor, &(_i.continue_token).0)), + label: (_i.label).map(|it| _visitor.fold_lifetime(it)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_field(_visitor: &mut V, _i: ExprField) -> ExprField { + ExprField { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + base: Box::new(_visitor.fold_expr(*_i.base)), + dot_token: Token ! [ . ](tokens_helper(_visitor, &(_i.dot_token).0)), + member: _visitor.fold_member(_i.member), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_for_loop(_visitor: &mut V, _i: ExprForLoop) -> ExprForLoop { + ExprForLoop { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + label: (_i.label).map(|it| _visitor.fold_label(it)), + for_token: Token ! [ for ](tokens_helper(_visitor, &(_i.for_token).0)), + pat: Box::new(_visitor.fold_pat(*_i.pat)), + in_token: Token ! [ in ](tokens_helper(_visitor, &(_i.in_token).0)), + expr: Box::new(_visitor.fold_expr(*_i.expr)), + body: _visitor.fold_block(_i.body), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_group(_visitor: &mut V, _i: ExprGroup) -> ExprGroup { + ExprGroup { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + group_token: Group(tokens_helper(_visitor, &(_i.group_token).0)), + expr: Box::new(_visitor.fold_expr(*_i.expr)), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_if(_visitor: &mut V, _i: ExprIf) -> ExprIf { + ExprIf { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + if_token: Token ! [ if ](tokens_helper(_visitor, &(_i.if_token).0)), + cond: Box::new(_visitor.fold_expr(*_i.cond)), + then_branch: _visitor.fold_block(_i.then_branch), + else_branch: (_i.else_branch).map(|it| { + ( + Token ! [ else ](tokens_helper(_visitor, &((it).0).0)), + Box::new(_visitor.fold_expr(*(it).1)), + ) + }), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_if_let(_visitor: &mut V, _i: ExprIfLet) -> ExprIfLet { + ExprIfLet { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + if_token: Token ! [ if ](tokens_helper(_visitor, &(_i.if_token).0)), + let_token: Token ! [ let ](tokens_helper(_visitor, &(_i.let_token).0)), + pats: FoldHelper::lift(_i.pats, |it| _visitor.fold_pat(it)), + eq_token: Token ! [ = ](tokens_helper(_visitor, &(_i.eq_token).0)), + expr: Box::new(_visitor.fold_expr(*_i.expr)), + then_branch: _visitor.fold_block(_i.then_branch), + else_branch: (_i.else_branch).map(|it| { + ( + Token ! [ else ](tokens_helper(_visitor, &((it).0).0)), + Box::new(_visitor.fold_expr(*(it).1)), + ) + }), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_in_place(_visitor: &mut V, _i: ExprInPlace) -> ExprInPlace { + ExprInPlace { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + place: Box::new(_visitor.fold_expr(*_i.place)), + arrow_token: Token ! [ <- ](tokens_helper(_visitor, &(_i.arrow_token).0)), + value: Box::new(_visitor.fold_expr(*_i.value)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_index(_visitor: &mut V, _i: ExprIndex) -> ExprIndex { + ExprIndex { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + expr: Box::new(_visitor.fold_expr(*_i.expr)), + bracket_token: Bracket(tokens_helper(_visitor, &(_i.bracket_token).0)), + index: Box::new(_visitor.fold_expr(*_i.index)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_lit(_visitor: &mut V, _i: ExprLit) -> ExprLit { + ExprLit { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + lit: _visitor.fold_lit(_i.lit), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_loop(_visitor: &mut V, _i: ExprLoop) -> ExprLoop { + ExprLoop { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + label: (_i.label).map(|it| _visitor.fold_label(it)), + loop_token: Token ! [ loop ](tokens_helper(_visitor, &(_i.loop_token).0)), + body: _visitor.fold_block(_i.body), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_macro(_visitor: &mut V, _i: ExprMacro) -> ExprMacro { + ExprMacro { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + mac: _visitor.fold_macro(_i.mac), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_match(_visitor: &mut V, _i: ExprMatch) -> ExprMatch { + ExprMatch { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + match_token: Token ! [ match ](tokens_helper(_visitor, &(_i.match_token).0)), + expr: Box::new(_visitor.fold_expr(*_i.expr)), + brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), + arms: FoldHelper::lift(_i.arms, |it| _visitor.fold_arm(it)), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_method_call( + _visitor: &mut V, + _i: ExprMethodCall, +) -> ExprMethodCall { + ExprMethodCall { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + receiver: Box::new(_visitor.fold_expr(*_i.receiver)), + dot_token: Token ! [ . ](tokens_helper(_visitor, &(_i.dot_token).0)), + method: _visitor.fold_ident(_i.method), + turbofish: (_i.turbofish).map(|it| _visitor.fold_method_turbofish(it)), + paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), + args: FoldHelper::lift(_i.args, |it| _visitor.fold_expr(it)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_paren(_visitor: &mut V, _i: ExprParen) -> ExprParen { + ExprParen { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), + expr: Box::new(_visitor.fold_expr(*_i.expr)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_path(_visitor: &mut V, _i: ExprPath) -> ExprPath { + ExprPath { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + qself: (_i.qself).map(|it| _visitor.fold_qself(it)), + path: _visitor.fold_path(_i.path), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_range(_visitor: &mut V, _i: ExprRange) -> ExprRange { + ExprRange { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + from: (_i.from).map(|it| Box::new(_visitor.fold_expr(*it))), + limits: _visitor.fold_range_limits(_i.limits), + to: (_i.to).map(|it| Box::new(_visitor.fold_expr(*it))), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_reference(_visitor: &mut V, _i: ExprReference) -> ExprReference { + ExprReference { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + and_token: Token ! [ & ](tokens_helper(_visitor, &(_i.and_token).0)), + mutability: (_i.mutability).map(|it| Token ! [ mut ](tokens_helper(_visitor, &(it).0))), + expr: Box::new(_visitor.fold_expr(*_i.expr)), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_repeat(_visitor: &mut V, _i: ExprRepeat) -> ExprRepeat { + ExprRepeat { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + bracket_token: Bracket(tokens_helper(_visitor, &(_i.bracket_token).0)), + expr: Box::new(_visitor.fold_expr(*_i.expr)), + semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), + len: Box::new(_visitor.fold_expr(*_i.len)), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_return(_visitor: &mut V, _i: ExprReturn) -> ExprReturn { + ExprReturn { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + return_token: Token![return](tokens_helper(_visitor, &(_i.return_token).0)), + expr: (_i.expr).map(|it| Box::new(_visitor.fold_expr(*it))), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_struct(_visitor: &mut V, _i: ExprStruct) -> ExprStruct { + ExprStruct { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + path: _visitor.fold_path(_i.path), + brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), + fields: FoldHelper::lift(_i.fields, |it| _visitor.fold_field_value(it)), + dot2_token: (_i.dot2_token).map(|it| Token![..](tokens_helper(_visitor, &(it).0))), + rest: (_i.rest).map(|it| Box::new(_visitor.fold_expr(*it))), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_try(_visitor: &mut V, _i: ExprTry) -> ExprTry { + ExprTry { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + expr: Box::new(_visitor.fold_expr(*_i.expr)), + question_token: Token ! [ ? ](tokens_helper(_visitor, &(_i.question_token).0)), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_tuple(_visitor: &mut V, _i: ExprTuple) -> ExprTuple { + ExprTuple { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), + elems: FoldHelper::lift(_i.elems, |it| _visitor.fold_expr(it)), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_type(_visitor: &mut V, _i: ExprType) -> ExprType { + ExprType { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + expr: Box::new(_visitor.fold_expr(*_i.expr)), + colon_token: Token ! [ : ](tokens_helper(_visitor, &(_i.colon_token).0)), + ty: Box::new(_visitor.fold_type(*_i.ty)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_unary(_visitor: &mut V, _i: ExprUnary) -> ExprUnary { + ExprUnary { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + op: _visitor.fold_un_op(_i.op), + expr: Box::new(_visitor.fold_expr(*_i.expr)), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_unsafe(_visitor: &mut V, _i: ExprUnsafe) -> ExprUnsafe { + ExprUnsafe { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + unsafe_token: Token ! [ unsafe ](tokens_helper(_visitor, &(_i.unsafe_token).0)), + block: _visitor.fold_block(_i.block), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_verbatim(_visitor: &mut V, _i: ExprVerbatim) -> ExprVerbatim { + ExprVerbatim { tts: _i.tts } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_while(_visitor: &mut V, _i: ExprWhile) -> ExprWhile { + ExprWhile { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + label: (_i.label).map(|it| _visitor.fold_label(it)), + while_token: Token ! [ while ](tokens_helper(_visitor, &(_i.while_token).0)), + cond: Box::new(_visitor.fold_expr(*_i.cond)), + body: _visitor.fold_block(_i.body), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_while_let(_visitor: &mut V, _i: ExprWhileLet) -> ExprWhileLet { + ExprWhileLet { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + label: (_i.label).map(|it| _visitor.fold_label(it)), + while_token: Token ! [ while ](tokens_helper(_visitor, &(_i.while_token).0)), + let_token: Token ! [ let ](tokens_helper(_visitor, &(_i.let_token).0)), + pats: FoldHelper::lift(_i.pats, |it| _visitor.fold_pat(it)), + eq_token: Token ! [ = ](tokens_helper(_visitor, &(_i.eq_token).0)), + expr: Box::new(_visitor.fold_expr(*_i.expr)), + body: _visitor.fold_block(_i.body), + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_expr_yield(_visitor: &mut V, _i: ExprYield) -> ExprYield { + ExprYield { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + yield_token: Token![yield](tokens_helper(_visitor, &(_i.yield_token).0)), + expr: (_i.expr).map(|it| Box::new(_visitor.fold_expr(*it))), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_field(_visitor: &mut V, _i: Field) -> Field { + Field { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + vis: _visitor.fold_visibility(_i.vis), + ident: (_i.ident).map(|it| _visitor.fold_ident(it)), + colon_token: (_i.colon_token).map(|it| Token ! [ : ](tokens_helper(_visitor, &(it).0))), + ty: _visitor.fold_type(_i.ty), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_field_pat(_visitor: &mut V, _i: FieldPat) -> FieldPat { + FieldPat { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + member: _visitor.fold_member(_i.member), + colon_token: (_i.colon_token).map(|it| Token ! [ : ](tokens_helper(_visitor, &(it).0))), + pat: Box::new(_visitor.fold_pat(*_i.pat)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_field_value(_visitor: &mut V, _i: FieldValue) -> FieldValue { + FieldValue { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + member: _visitor.fold_member(_i.member), + colon_token: (_i.colon_token).map(|it| Token ! [ : ](tokens_helper(_visitor, &(it).0))), + expr: _visitor.fold_expr(_i.expr), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_fields(_visitor: &mut V, _i: Fields) -> Fields { + match _i { + Fields::Named(_binding_0) => Fields::Named(_visitor.fold_fields_named(_binding_0)), + Fields::Unnamed(_binding_0) => Fields::Unnamed(_visitor.fold_fields_unnamed(_binding_0)), + Fields::Unit => Fields::Unit, + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_fields_named(_visitor: &mut V, _i: FieldsNamed) -> FieldsNamed { + FieldsNamed { + brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), + named: FoldHelper::lift(_i.named, |it| _visitor.fold_field(it)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_fields_unnamed(_visitor: &mut V, _i: FieldsUnnamed) -> FieldsUnnamed { + FieldsUnnamed { + paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), + unnamed: FoldHelper::lift(_i.unnamed, |it| _visitor.fold_field(it)), + } +} +#[cfg(feature = "full")] +pub fn fold_file(_visitor: &mut V, _i: File) -> File { + File { + shebang: _i.shebang, + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + items: FoldHelper::lift(_i.items, |it| _visitor.fold_item(it)), + } +} +#[cfg(feature = "full")] +pub fn fold_fn_arg(_visitor: &mut V, _i: FnArg) -> FnArg { + match _i { + FnArg::SelfRef(_binding_0) => FnArg::SelfRef(_visitor.fold_arg_self_ref(_binding_0)), + FnArg::SelfValue(_binding_0) => FnArg::SelfValue(_visitor.fold_arg_self(_binding_0)), + FnArg::Captured(_binding_0) => FnArg::Captured(_visitor.fold_arg_captured(_binding_0)), + FnArg::Inferred(_binding_0) => FnArg::Inferred(_visitor.fold_pat(_binding_0)), + FnArg::Ignored(_binding_0) => FnArg::Ignored(_visitor.fold_type(_binding_0)), + } +} +#[cfg(feature = "full")] +pub fn fold_fn_decl(_visitor: &mut V, _i: FnDecl) -> FnDecl { + FnDecl { + fn_token: Token ! [ fn ](tokens_helper(_visitor, &(_i.fn_token).0)), + generics: _visitor.fold_generics(_i.generics), + paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), + inputs: FoldHelper::lift(_i.inputs, |it| _visitor.fold_fn_arg(it)), + variadic: (_i.variadic).map(|it| Token ! [ ... ](tokens_helper(_visitor, &(it).0))), + output: _visitor.fold_return_type(_i.output), + } +} +#[cfg(feature = "full")] +pub fn fold_foreign_item(_visitor: &mut V, _i: ForeignItem) -> ForeignItem { + match _i { + ForeignItem::Fn(_binding_0) => ForeignItem::Fn(_visitor.fold_foreign_item_fn(_binding_0)), + ForeignItem::Static(_binding_0) => { + ForeignItem::Static(_visitor.fold_foreign_item_static(_binding_0)) + } + ForeignItem::Type(_binding_0) => { + ForeignItem::Type(_visitor.fold_foreign_item_type(_binding_0)) + } + ForeignItem::Verbatim(_binding_0) => { + ForeignItem::Verbatim(_visitor.fold_foreign_item_verbatim(_binding_0)) + } + } +} +#[cfg(feature = "full")] +pub fn fold_foreign_item_fn( + _visitor: &mut V, + _i: ForeignItemFn, +) -> ForeignItemFn { + ForeignItemFn { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + vis: _visitor.fold_visibility(_i.vis), + ident: _visitor.fold_ident(_i.ident), + decl: Box::new(_visitor.fold_fn_decl(*_i.decl)), + semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), + } +} +#[cfg(feature = "full")] +pub fn fold_foreign_item_static( + _visitor: &mut V, + _i: ForeignItemStatic, +) -> ForeignItemStatic { + ForeignItemStatic { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + vis: _visitor.fold_visibility(_i.vis), + static_token: Token ! [ static ](tokens_helper(_visitor, &(_i.static_token).0)), + mutability: (_i.mutability).map(|it| Token ! [ mut ](tokens_helper(_visitor, &(it).0))), + ident: _visitor.fold_ident(_i.ident), + colon_token: Token ! [ : ](tokens_helper(_visitor, &(_i.colon_token).0)), + ty: Box::new(_visitor.fold_type(*_i.ty)), + semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), + } +} +#[cfg(feature = "full")] +pub fn fold_foreign_item_type( + _visitor: &mut V, + _i: ForeignItemType, +) -> ForeignItemType { + ForeignItemType { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + vis: _visitor.fold_visibility(_i.vis), + type_token: Token ! [ type ](tokens_helper(_visitor, &(_i.type_token).0)), + ident: _visitor.fold_ident(_i.ident), + semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), + } +} +#[cfg(feature = "full")] +pub fn fold_foreign_item_verbatim( + _visitor: &mut V, + _i: ForeignItemVerbatim, +) -> ForeignItemVerbatim { + ForeignItemVerbatim { tts: _i.tts } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_generic_argument( + _visitor: &mut V, + _i: GenericArgument, +) -> GenericArgument { + match _i { + GenericArgument::Lifetime(_binding_0) => { + GenericArgument::Lifetime(_visitor.fold_lifetime(_binding_0)) + } + GenericArgument::Type(_binding_0) => GenericArgument::Type(_visitor.fold_type(_binding_0)), + GenericArgument::Binding(_binding_0) => { + GenericArgument::Binding(_visitor.fold_binding(_binding_0)) + } + GenericArgument::Const(_binding_0) => { + GenericArgument::Const(_visitor.fold_expr(_binding_0)) + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_generic_method_argument( + _visitor: &mut V, + _i: GenericMethodArgument, +) -> GenericMethodArgument { + match _i { + GenericMethodArgument::Type(_binding_0) => { + GenericMethodArgument::Type(_visitor.fold_type(_binding_0)) + } + GenericMethodArgument::Const(_binding_0) => { + GenericMethodArgument::Const(_visitor.fold_expr(_binding_0)) + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_generic_param(_visitor: &mut V, _i: GenericParam) -> GenericParam { + match _i { + GenericParam::Type(_binding_0) => GenericParam::Type(_visitor.fold_type_param(_binding_0)), + GenericParam::Lifetime(_binding_0) => { + GenericParam::Lifetime(_visitor.fold_lifetime_def(_binding_0)) + } + GenericParam::Const(_binding_0) => { + GenericParam::Const(_visitor.fold_const_param(_binding_0)) + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_generics(_visitor: &mut V, _i: Generics) -> Generics { + Generics { + lt_token: (_i.lt_token).map(|it| Token ! [ < ](tokens_helper(_visitor, &(it).0))), + params: FoldHelper::lift(_i.params, |it| _visitor.fold_generic_param(it)), + gt_token: (_i.gt_token).map(|it| Token ! [ > ](tokens_helper(_visitor, &(it).0))), + where_clause: (_i.where_clause).map(|it| _visitor.fold_where_clause(it)), + } +} +pub fn fold_ident(_visitor: &mut V, _i: Ident) -> Ident { + let mut _i = _i; + let span = _visitor.fold_span(_i.span()); + _i.set_span(span); + _i +} +#[cfg(feature = "full")] +pub fn fold_impl_item(_visitor: &mut V, _i: ImplItem) -> ImplItem { + match _i { + ImplItem::Const(_binding_0) => ImplItem::Const(_visitor.fold_impl_item_const(_binding_0)), + ImplItem::Method(_binding_0) => { + ImplItem::Method(_visitor.fold_impl_item_method(_binding_0)) + } + ImplItem::Type(_binding_0) => ImplItem::Type(_visitor.fold_impl_item_type(_binding_0)), + ImplItem::Macro(_binding_0) => ImplItem::Macro(_visitor.fold_impl_item_macro(_binding_0)), + ImplItem::Verbatim(_binding_0) => { + ImplItem::Verbatim(_visitor.fold_impl_item_verbatim(_binding_0)) + } + } +} +#[cfg(feature = "full")] +pub fn fold_impl_item_const( + _visitor: &mut V, + _i: ImplItemConst, +) -> ImplItemConst { + ImplItemConst { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + vis: _visitor.fold_visibility(_i.vis), + defaultness: (_i.defaultness).map(|it| Token![default](tokens_helper(_visitor, &(it).0))), + const_token: Token ! [ const ](tokens_helper(_visitor, &(_i.const_token).0)), + ident: _visitor.fold_ident(_i.ident), + colon_token: Token ! [ : ](tokens_helper(_visitor, &(_i.colon_token).0)), + ty: _visitor.fold_type(_i.ty), + eq_token: Token ! [ = ](tokens_helper(_visitor, &(_i.eq_token).0)), + expr: _visitor.fold_expr(_i.expr), + semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), + } +} +#[cfg(feature = "full")] +pub fn fold_impl_item_macro( + _visitor: &mut V, + _i: ImplItemMacro, +) -> ImplItemMacro { + ImplItemMacro { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + mac: _visitor.fold_macro(_i.mac), + semi_token: (_i.semi_token).map(|it| Token ! [ ; ](tokens_helper(_visitor, &(it).0))), + } +} +#[cfg(feature = "full")] +pub fn fold_impl_item_method( + _visitor: &mut V, + _i: ImplItemMethod, +) -> ImplItemMethod { + ImplItemMethod { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + vis: _visitor.fold_visibility(_i.vis), + defaultness: (_i.defaultness).map(|it| Token![default](tokens_helper(_visitor, &(it).0))), + sig: _visitor.fold_method_sig(_i.sig), + block: _visitor.fold_block(_i.block), + } +} +#[cfg(feature = "full")] +pub fn fold_impl_item_type(_visitor: &mut V, _i: ImplItemType) -> ImplItemType { + ImplItemType { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + vis: _visitor.fold_visibility(_i.vis), + defaultness: (_i.defaultness).map(|it| Token![default](tokens_helper(_visitor, &(it).0))), + type_token: Token ! [ type ](tokens_helper(_visitor, &(_i.type_token).0)), + ident: _visitor.fold_ident(_i.ident), + generics: _visitor.fold_generics(_i.generics), + eq_token: Token ! [ = ](tokens_helper(_visitor, &(_i.eq_token).0)), + ty: _visitor.fold_type(_i.ty), + semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), + } +} +#[cfg(feature = "full")] +pub fn fold_impl_item_verbatim( + _visitor: &mut V, + _i: ImplItemVerbatim, +) -> ImplItemVerbatim { + ImplItemVerbatim { tts: _i.tts } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_index(_visitor: &mut V, _i: Index) -> Index { + Index { + index: _i.index, + span: _visitor.fold_span(_i.span), + } +} +#[cfg(feature = "full")] +pub fn fold_item(_visitor: &mut V, _i: Item) -> Item { + match _i { + Item::ExternCrate(_binding_0) => { + Item::ExternCrate(_visitor.fold_item_extern_crate(_binding_0)) + } + Item::Use(_binding_0) => Item::Use(_visitor.fold_item_use(_binding_0)), + Item::Static(_binding_0) => Item::Static(_visitor.fold_item_static(_binding_0)), + Item::Const(_binding_0) => Item::Const(_visitor.fold_item_const(_binding_0)), + Item::Fn(_binding_0) => Item::Fn(_visitor.fold_item_fn(_binding_0)), + Item::Mod(_binding_0) => Item::Mod(_visitor.fold_item_mod(_binding_0)), + Item::ForeignMod(_binding_0) => { + Item::ForeignMod(_visitor.fold_item_foreign_mod(_binding_0)) + } + Item::Type(_binding_0) => Item::Type(_visitor.fold_item_type(_binding_0)), + Item::Struct(_binding_0) => Item::Struct(_visitor.fold_item_struct(_binding_0)), + Item::Enum(_binding_0) => Item::Enum(_visitor.fold_item_enum(_binding_0)), + Item::Union(_binding_0) => Item::Union(_visitor.fold_item_union(_binding_0)), + Item::Trait(_binding_0) => Item::Trait(_visitor.fold_item_trait(_binding_0)), + Item::Impl(_binding_0) => Item::Impl(_visitor.fold_item_impl(_binding_0)), + Item::Macro(_binding_0) => Item::Macro(_visitor.fold_item_macro(_binding_0)), + Item::Macro2(_binding_0) => Item::Macro2(_visitor.fold_item_macro2(_binding_0)), + Item::Verbatim(_binding_0) => Item::Verbatim(_visitor.fold_item_verbatim(_binding_0)), + } +} +#[cfg(feature = "full")] +pub fn fold_item_const(_visitor: &mut V, _i: ItemConst) -> ItemConst { + ItemConst { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + vis: _visitor.fold_visibility(_i.vis), + const_token: Token ! [ const ](tokens_helper(_visitor, &(_i.const_token).0)), + ident: _visitor.fold_ident(_i.ident), + colon_token: Token ! [ : ](tokens_helper(_visitor, &(_i.colon_token).0)), + ty: Box::new(_visitor.fold_type(*_i.ty)), + eq_token: Token ! [ = ](tokens_helper(_visitor, &(_i.eq_token).0)), + expr: Box::new(_visitor.fold_expr(*_i.expr)), + semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), + } +} +#[cfg(feature = "full")] +pub fn fold_item_enum(_visitor: &mut V, _i: ItemEnum) -> ItemEnum { + ItemEnum { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + vis: _visitor.fold_visibility(_i.vis), + enum_token: Token ! [ enum ](tokens_helper(_visitor, &(_i.enum_token).0)), + ident: _visitor.fold_ident(_i.ident), + generics: _visitor.fold_generics(_i.generics), + brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), + variants: FoldHelper::lift(_i.variants, |it| _visitor.fold_variant(it)), + } +} +#[cfg(feature = "full")] +pub fn fold_item_extern_crate( + _visitor: &mut V, + _i: ItemExternCrate, +) -> ItemExternCrate { + ItemExternCrate { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + vis: _visitor.fold_visibility(_i.vis), + extern_token: Token![extern](tokens_helper(_visitor, &(_i.extern_token).0)), + crate_token: Token![crate](tokens_helper(_visitor, &(_i.crate_token).0)), + ident: _visitor.fold_ident(_i.ident), + rename: (_i.rename).map(|it| { + ( + Token ! [ as ](tokens_helper(_visitor, &((it).0).0)), + _visitor.fold_ident((it).1), + ) + }), + semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), + } +} +#[cfg(feature = "full")] +pub fn fold_item_fn(_visitor: &mut V, _i: ItemFn) -> ItemFn { + ItemFn { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + vis: _visitor.fold_visibility(_i.vis), + constness: (_i.constness).map(|it| Token ! [ const ](tokens_helper(_visitor, &(it).0))), + unsafety: (_i.unsafety).map(|it| Token ! [ unsafe ](tokens_helper(_visitor, &(it).0))), + abi: (_i.abi).map(|it| _visitor.fold_abi(it)), + ident: _visitor.fold_ident(_i.ident), + decl: Box::new(_visitor.fold_fn_decl(*_i.decl)), + block: Box::new(_visitor.fold_block(*_i.block)), + } +} +#[cfg(feature = "full")] +pub fn fold_item_foreign_mod( + _visitor: &mut V, + _i: ItemForeignMod, +) -> ItemForeignMod { + ItemForeignMod { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + abi: _visitor.fold_abi(_i.abi), + brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), + items: FoldHelper::lift(_i.items, |it| _visitor.fold_foreign_item(it)), + } +} +#[cfg(feature = "full")] +pub fn fold_item_impl(_visitor: &mut V, _i: ItemImpl) -> ItemImpl { + ItemImpl { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + defaultness: (_i.defaultness).map(|it| Token![default](tokens_helper(_visitor, &(it).0))), + unsafety: (_i.unsafety).map(|it| Token ! [ unsafe ](tokens_helper(_visitor, &(it).0))), + impl_token: Token![impl ](tokens_helper(_visitor, &(_i.impl_token).0)), + generics: _visitor.fold_generics(_i.generics), + trait_: (_i.trait_).map(|it| { + ( + ((it).0).map(|it| Token![!](tokens_helper(_visitor, &(it).0))), + _visitor.fold_path((it).1), + Token ! [ for ](tokens_helper(_visitor, &((it).2).0)), + ) + }), + self_ty: Box::new(_visitor.fold_type(*_i.self_ty)), + brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), + items: FoldHelper::lift(_i.items, |it| _visitor.fold_impl_item(it)), + } +} +#[cfg(feature = "full")] +pub fn fold_item_macro(_visitor: &mut V, _i: ItemMacro) -> ItemMacro { + ItemMacro { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + ident: (_i.ident).map(|it| _visitor.fold_ident(it)), + mac: _visitor.fold_macro(_i.mac), + semi_token: (_i.semi_token).map(|it| Token ! [ ; ](tokens_helper(_visitor, &(it).0))), + } +} +#[cfg(feature = "full")] +pub fn fold_item_macro2(_visitor: &mut V, _i: ItemMacro2) -> ItemMacro2 { + ItemMacro2 { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + vis: _visitor.fold_visibility(_i.vis), + macro_token: Token ! [ macro ](tokens_helper(_visitor, &(_i.macro_token).0)), + ident: _visitor.fold_ident(_i.ident), + paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), + args: _i.args, + brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), + body: _i.body, + } +} +#[cfg(feature = "full")] +pub fn fold_item_mod(_visitor: &mut V, _i: ItemMod) -> ItemMod { + ItemMod { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + vis: _visitor.fold_visibility(_i.vis), + mod_token: Token ! [ mod ](tokens_helper(_visitor, &(_i.mod_token).0)), + ident: _visitor.fold_ident(_i.ident), + content: (_i.content).map(|it| { + ( + Brace(tokens_helper(_visitor, &((it).0).0)), + FoldHelper::lift((it).1, |it| _visitor.fold_item(it)), + ) + }), + semi: (_i.semi).map(|it| Token ! [ ; ](tokens_helper(_visitor, &(it).0))), + } +} +#[cfg(feature = "full")] +pub fn fold_item_static(_visitor: &mut V, _i: ItemStatic) -> ItemStatic { + ItemStatic { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + vis: _visitor.fold_visibility(_i.vis), + static_token: Token ! [ static ](tokens_helper(_visitor, &(_i.static_token).0)), + mutability: (_i.mutability).map(|it| Token ! [ mut ](tokens_helper(_visitor, &(it).0))), + ident: _visitor.fold_ident(_i.ident), + colon_token: Token ! [ : ](tokens_helper(_visitor, &(_i.colon_token).0)), + ty: Box::new(_visitor.fold_type(*_i.ty)), + eq_token: Token ! [ = ](tokens_helper(_visitor, &(_i.eq_token).0)), + expr: Box::new(_visitor.fold_expr(*_i.expr)), + semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), + } +} +#[cfg(feature = "full")] +pub fn fold_item_struct(_visitor: &mut V, _i: ItemStruct) -> ItemStruct { + ItemStruct { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + vis: _visitor.fold_visibility(_i.vis), + struct_token: Token ! [ struct ](tokens_helper(_visitor, &(_i.struct_token).0)), + ident: _visitor.fold_ident(_i.ident), + generics: _visitor.fold_generics(_i.generics), + fields: _visitor.fold_fields(_i.fields), + semi_token: (_i.semi_token).map(|it| Token ! [ ; ](tokens_helper(_visitor, &(it).0))), + } +} +#[cfg(feature = "full")] +pub fn fold_item_trait(_visitor: &mut V, _i: ItemTrait) -> ItemTrait { + ItemTrait { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + vis: _visitor.fold_visibility(_i.vis), + unsafety: (_i.unsafety).map(|it| Token ! [ unsafe ](tokens_helper(_visitor, &(it).0))), + auto_token: (_i.auto_token).map(|it| Token![auto](tokens_helper(_visitor, &(it).0))), + trait_token: Token ! [ trait ](tokens_helper(_visitor, &(_i.trait_token).0)), + ident: _visitor.fold_ident(_i.ident), + generics: _visitor.fold_generics(_i.generics), + colon_token: (_i.colon_token).map(|it| Token ! [ : ](tokens_helper(_visitor, &(it).0))), + supertraits: FoldHelper::lift(_i.supertraits, |it| _visitor.fold_type_param_bound(it)), + brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), + items: FoldHelper::lift(_i.items, |it| _visitor.fold_trait_item(it)), + } +} +#[cfg(feature = "full")] +pub fn fold_item_type(_visitor: &mut V, _i: ItemType) -> ItemType { + ItemType { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + vis: _visitor.fold_visibility(_i.vis), + type_token: Token ! [ type ](tokens_helper(_visitor, &(_i.type_token).0)), + ident: _visitor.fold_ident(_i.ident), + generics: _visitor.fold_generics(_i.generics), + eq_token: Token ! [ = ](tokens_helper(_visitor, &(_i.eq_token).0)), + ty: Box::new(_visitor.fold_type(*_i.ty)), + semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), + } +} +#[cfg(feature = "full")] +pub fn fold_item_union(_visitor: &mut V, _i: ItemUnion) -> ItemUnion { + ItemUnion { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + vis: _visitor.fold_visibility(_i.vis), + union_token: Token![union](tokens_helper(_visitor, &(_i.union_token).0)), + ident: _visitor.fold_ident(_i.ident), + generics: _visitor.fold_generics(_i.generics), + fields: _visitor.fold_fields_named(_i.fields), + } +} +#[cfg(feature = "full")] +pub fn fold_item_use(_visitor: &mut V, _i: ItemUse) -> ItemUse { + ItemUse { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + vis: _visitor.fold_visibility(_i.vis), + use_token: Token ! [ use ](tokens_helper(_visitor, &(_i.use_token).0)), + leading_colon: (_i.leading_colon) + .map(|it| Token ! [ :: ](tokens_helper(_visitor, &(it).0))), + tree: _visitor.fold_use_tree(_i.tree), + semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), + } +} +#[cfg(feature = "full")] +pub fn fold_item_verbatim(_visitor: &mut V, _i: ItemVerbatim) -> ItemVerbatim { + ItemVerbatim { tts: _i.tts } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_label(_visitor: &mut V, _i: Label) -> Label { + Label { + name: _visitor.fold_lifetime(_i.name), + colon_token: Token ! [ : ](tokens_helper(_visitor, &(_i.colon_token).0)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_lifetime(_visitor: &mut V, _i: Lifetime) -> Lifetime { + Lifetime { + apostrophe: _i.apostrophe, + ident: _visitor.fold_ident(_i.ident), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_lifetime_def(_visitor: &mut V, _i: LifetimeDef) -> LifetimeDef { + LifetimeDef { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + lifetime: _visitor.fold_lifetime(_i.lifetime), + colon_token: (_i.colon_token).map(|it| Token ! [ : ](tokens_helper(_visitor, &(it).0))), + bounds: FoldHelper::lift(_i.bounds, |it| _visitor.fold_lifetime(it)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_lit(_visitor: &mut V, _i: Lit) -> Lit { + match _i { + Lit::Str(_binding_0) => Lit::Str(_visitor.fold_lit_str(_binding_0)), + Lit::ByteStr(_binding_0) => Lit::ByteStr(_visitor.fold_lit_byte_str(_binding_0)), + Lit::Byte(_binding_0) => Lit::Byte(_visitor.fold_lit_byte(_binding_0)), + Lit::Char(_binding_0) => Lit::Char(_visitor.fold_lit_char(_binding_0)), + Lit::Int(_binding_0) => Lit::Int(_visitor.fold_lit_int(_binding_0)), + Lit::Float(_binding_0) => Lit::Float(_visitor.fold_lit_float(_binding_0)), + Lit::Bool(_binding_0) => Lit::Bool(_visitor.fold_lit_bool(_binding_0)), + Lit::Verbatim(_binding_0) => Lit::Verbatim(_visitor.fold_lit_verbatim(_binding_0)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_lit_bool(_visitor: &mut V, _i: LitBool) -> LitBool { + LitBool { + value: _i.value, + span: _visitor.fold_span(_i.span), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_lit_verbatim(_visitor: &mut V, _i: LitVerbatim) -> LitVerbatim { + LitVerbatim { token: _i.token } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_local(_visitor: &mut V, _i: Local) -> Local { + Local { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + let_token: Token ! [ let ](tokens_helper(_visitor, &(_i.let_token).0)), + pats: FoldHelper::lift(_i.pats, |it| _visitor.fold_pat(it)), + ty: (_i.ty).map(|it| { + ( + Token ! [ : ](tokens_helper(_visitor, &((it).0).0)), + Box::new(_visitor.fold_type(*(it).1)), + ) + }), + init: (_i.init).map(|it| { + ( + Token ! [ = ](tokens_helper(_visitor, &((it).0).0)), + Box::new(_visitor.fold_expr(*(it).1)), + ) + }), + semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_macro(_visitor: &mut V, _i: Macro) -> Macro { + Macro { + path: _visitor.fold_path(_i.path), + bang_token: Token![!](tokens_helper(_visitor, &(_i.bang_token).0)), + delimiter: _visitor.fold_macro_delimiter(_i.delimiter), + tts: _i.tts, + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_macro_delimiter( + _visitor: &mut V, + _i: MacroDelimiter, +) -> MacroDelimiter { + match _i { + MacroDelimiter::Paren(_binding_0) => { + MacroDelimiter::Paren(Paren(tokens_helper(_visitor, &(_binding_0).0))) + } + MacroDelimiter::Brace(_binding_0) => { + MacroDelimiter::Brace(Brace(tokens_helper(_visitor, &(_binding_0).0))) + } + MacroDelimiter::Bracket(_binding_0) => { + MacroDelimiter::Bracket(Bracket(tokens_helper(_visitor, &(_binding_0).0))) + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_member(_visitor: &mut V, _i: Member) -> Member { + match _i { + Member::Named(_binding_0) => Member::Named(_visitor.fold_ident(_binding_0)), + Member::Unnamed(_binding_0) => Member::Unnamed(_visitor.fold_index(_binding_0)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_meta(_visitor: &mut V, _i: Meta) -> Meta { + match _i { + Meta::Word(_binding_0) => Meta::Word(_visitor.fold_ident(_binding_0)), + Meta::List(_binding_0) => Meta::List(_visitor.fold_meta_list(_binding_0)), + Meta::NameValue(_binding_0) => Meta::NameValue(_visitor.fold_meta_name_value(_binding_0)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_meta_list(_visitor: &mut V, _i: MetaList) -> MetaList { + MetaList { + ident: _visitor.fold_ident(_i.ident), + paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), + nested: FoldHelper::lift(_i.nested, |it| _visitor.fold_nested_meta(it)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_meta_name_value( + _visitor: &mut V, + _i: MetaNameValue, +) -> MetaNameValue { + MetaNameValue { + ident: _visitor.fold_ident(_i.ident), + eq_token: Token ! [ = ](tokens_helper(_visitor, &(_i.eq_token).0)), + lit: _visitor.fold_lit(_i.lit), + } +} +#[cfg(feature = "full")] +pub fn fold_method_sig(_visitor: &mut V, _i: MethodSig) -> MethodSig { + MethodSig { + constness: (_i.constness).map(|it| Token ! [ const ](tokens_helper(_visitor, &(it).0))), + unsafety: (_i.unsafety).map(|it| Token ! [ unsafe ](tokens_helper(_visitor, &(it).0))), + abi: (_i.abi).map(|it| _visitor.fold_abi(it)), + ident: _visitor.fold_ident(_i.ident), + decl: _visitor.fold_fn_decl(_i.decl), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_method_turbofish( + _visitor: &mut V, + _i: MethodTurbofish, +) -> MethodTurbofish { + MethodTurbofish { + colon2_token: Token ! [ :: ](tokens_helper(_visitor, &(_i.colon2_token).0)), + lt_token: Token ! [ < ](tokens_helper(_visitor, &(_i.lt_token).0)), + args: FoldHelper::lift(_i.args, |it| _visitor.fold_generic_method_argument(it)), + gt_token: Token ! [ > ](tokens_helper(_visitor, &(_i.gt_token).0)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_nested_meta(_visitor: &mut V, _i: NestedMeta) -> NestedMeta { + match _i { + NestedMeta::Meta(_binding_0) => NestedMeta::Meta(_visitor.fold_meta(_binding_0)), + NestedMeta::Literal(_binding_0) => NestedMeta::Literal(_visitor.fold_lit(_binding_0)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_parenthesized_generic_arguments( + _visitor: &mut V, + _i: ParenthesizedGenericArguments, +) -> ParenthesizedGenericArguments { + ParenthesizedGenericArguments { + paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), + inputs: FoldHelper::lift(_i.inputs, |it| _visitor.fold_type(it)), + output: _visitor.fold_return_type(_i.output), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_pat(_visitor: &mut V, _i: Pat) -> Pat { + match _i { + Pat::Wild(_binding_0) => Pat::Wild(_visitor.fold_pat_wild(_binding_0)), + Pat::Ident(_binding_0) => Pat::Ident(_visitor.fold_pat_ident(_binding_0)), + Pat::Struct(_binding_0) => Pat::Struct(_visitor.fold_pat_struct(_binding_0)), + Pat::TupleStruct(_binding_0) => { + Pat::TupleStruct(_visitor.fold_pat_tuple_struct(_binding_0)) + } + Pat::Path(_binding_0) => Pat::Path(_visitor.fold_pat_path(_binding_0)), + Pat::Tuple(_binding_0) => Pat::Tuple(_visitor.fold_pat_tuple(_binding_0)), + Pat::Box(_binding_0) => Pat::Box(_visitor.fold_pat_box(_binding_0)), + Pat::Ref(_binding_0) => Pat::Ref(_visitor.fold_pat_ref(_binding_0)), + Pat::Lit(_binding_0) => Pat::Lit(_visitor.fold_pat_lit(_binding_0)), + Pat::Range(_binding_0) => Pat::Range(_visitor.fold_pat_range(_binding_0)), + Pat::Slice(_binding_0) => Pat::Slice(_visitor.fold_pat_slice(_binding_0)), + Pat::Macro(_binding_0) => Pat::Macro(_visitor.fold_pat_macro(_binding_0)), + Pat::Verbatim(_binding_0) => Pat::Verbatim(_visitor.fold_pat_verbatim(_binding_0)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_pat_box(_visitor: &mut V, _i: PatBox) -> PatBox { + PatBox { + box_token: Token ! [ box ](tokens_helper(_visitor, &(_i.box_token).0)), + pat: Box::new(_visitor.fold_pat(*_i.pat)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_pat_ident(_visitor: &mut V, _i: PatIdent) -> PatIdent { + PatIdent { + by_ref: (_i.by_ref).map(|it| Token ! [ ref ](tokens_helper(_visitor, &(it).0))), + mutability: (_i.mutability).map(|it| Token ! [ mut ](tokens_helper(_visitor, &(it).0))), + ident: _visitor.fold_ident(_i.ident), + subpat: (_i.subpat).map(|it| { + ( + Token ! [ @ ](tokens_helper(_visitor, &((it).0).0)), + Box::new(_visitor.fold_pat(*(it).1)), + ) + }), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_pat_lit(_visitor: &mut V, _i: PatLit) -> PatLit { + PatLit { + expr: Box::new(_visitor.fold_expr(*_i.expr)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_pat_macro(_visitor: &mut V, _i: PatMacro) -> PatMacro { + PatMacro { + mac: _visitor.fold_macro(_i.mac), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_pat_path(_visitor: &mut V, _i: PatPath) -> PatPath { + PatPath { + qself: (_i.qself).map(|it| _visitor.fold_qself(it)), + path: _visitor.fold_path(_i.path), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_pat_range(_visitor: &mut V, _i: PatRange) -> PatRange { + PatRange { + lo: Box::new(_visitor.fold_expr(*_i.lo)), + limits: _visitor.fold_range_limits(_i.limits), + hi: Box::new(_visitor.fold_expr(*_i.hi)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_pat_ref(_visitor: &mut V, _i: PatRef) -> PatRef { + PatRef { + and_token: Token ! [ & ](tokens_helper(_visitor, &(_i.and_token).0)), + mutability: (_i.mutability).map(|it| Token ! [ mut ](tokens_helper(_visitor, &(it).0))), + pat: Box::new(_visitor.fold_pat(*_i.pat)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_pat_slice(_visitor: &mut V, _i: PatSlice) -> PatSlice { + PatSlice { + bracket_token: Bracket(tokens_helper(_visitor, &(_i.bracket_token).0)), + front: FoldHelper::lift(_i.front, |it| _visitor.fold_pat(it)), + middle: (_i.middle).map(|it| Box::new(_visitor.fold_pat(*it))), + dot2_token: (_i.dot2_token).map(|it| Token![..](tokens_helper(_visitor, &(it).0))), + comma_token: (_i.comma_token).map(|it| Token ! [ , ](tokens_helper(_visitor, &(it).0))), + back: FoldHelper::lift(_i.back, |it| _visitor.fold_pat(it)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_pat_struct(_visitor: &mut V, _i: PatStruct) -> PatStruct { + PatStruct { + path: _visitor.fold_path(_i.path), + brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), + fields: FoldHelper::lift(_i.fields, |it| _visitor.fold_field_pat(it)), + dot2_token: (_i.dot2_token).map(|it| Token![..](tokens_helper(_visitor, &(it).0))), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_pat_tuple(_visitor: &mut V, _i: PatTuple) -> PatTuple { + PatTuple { + paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), + front: FoldHelper::lift(_i.front, |it| _visitor.fold_pat(it)), + dot2_token: (_i.dot2_token).map(|it| Token![..](tokens_helper(_visitor, &(it).0))), + comma_token: (_i.comma_token).map(|it| Token ! [ , ](tokens_helper(_visitor, &(it).0))), + back: FoldHelper::lift(_i.back, |it| _visitor.fold_pat(it)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_pat_tuple_struct( + _visitor: &mut V, + _i: PatTupleStruct, +) -> PatTupleStruct { + PatTupleStruct { + path: _visitor.fold_path(_i.path), + pat: _visitor.fold_pat_tuple(_i.pat), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_pat_verbatim(_visitor: &mut V, _i: PatVerbatim) -> PatVerbatim { + PatVerbatim { tts: _i.tts } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_pat_wild(_visitor: &mut V, _i: PatWild) -> PatWild { + PatWild { + underscore_token: Token![_](tokens_helper(_visitor, &(_i.underscore_token).0)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_path(_visitor: &mut V, _i: Path) -> Path { + Path { + leading_colon: (_i.leading_colon) + .map(|it| Token ! [ :: ](tokens_helper(_visitor, &(it).0))), + segments: FoldHelper::lift(_i.segments, |it| _visitor.fold_path_segment(it)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_path_arguments(_visitor: &mut V, _i: PathArguments) -> PathArguments { + match _i { + PathArguments::None => PathArguments::None, + PathArguments::AngleBracketed(_binding_0) => PathArguments::AngleBracketed( + _visitor.fold_angle_bracketed_generic_arguments(_binding_0), + ), + PathArguments::Parenthesized(_binding_0) => { + PathArguments::Parenthesized(_visitor.fold_parenthesized_generic_arguments(_binding_0)) + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_path_segment(_visitor: &mut V, _i: PathSegment) -> PathSegment { + PathSegment { + ident: _visitor.fold_ident(_i.ident), + arguments: _visitor.fold_path_arguments(_i.arguments), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_predicate_eq(_visitor: &mut V, _i: PredicateEq) -> PredicateEq { + PredicateEq { + lhs_ty: _visitor.fold_type(_i.lhs_ty), + eq_token: Token ! [ = ](tokens_helper(_visitor, &(_i.eq_token).0)), + rhs_ty: _visitor.fold_type(_i.rhs_ty), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_predicate_lifetime( + _visitor: &mut V, + _i: PredicateLifetime, +) -> PredicateLifetime { + PredicateLifetime { + lifetime: _visitor.fold_lifetime(_i.lifetime), + colon_token: (_i.colon_token).map(|it| Token ! [ : ](tokens_helper(_visitor, &(it).0))), + bounds: FoldHelper::lift(_i.bounds, |it| _visitor.fold_lifetime(it)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_predicate_type(_visitor: &mut V, _i: PredicateType) -> PredicateType { + PredicateType { + lifetimes: (_i.lifetimes).map(|it| _visitor.fold_bound_lifetimes(it)), + bounded_ty: _visitor.fold_type(_i.bounded_ty), + colon_token: Token ! [ : ](tokens_helper(_visitor, &(_i.colon_token).0)), + bounds: FoldHelper::lift(_i.bounds, |it| _visitor.fold_type_param_bound(it)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_qself(_visitor: &mut V, _i: QSelf) -> QSelf { + QSelf { + lt_token: Token ! [ < ](tokens_helper(_visitor, &(_i.lt_token).0)), + ty: Box::new(_visitor.fold_type(*_i.ty)), + position: _i.position, + as_token: (_i.as_token).map(|it| Token ! [ as ](tokens_helper(_visitor, &(it).0))), + gt_token: Token ! [ > ](tokens_helper(_visitor, &(_i.gt_token).0)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_range_limits(_visitor: &mut V, _i: RangeLimits) -> RangeLimits { + match _i { + RangeLimits::HalfOpen(_binding_0) => { + RangeLimits::HalfOpen(Token![..](tokens_helper(_visitor, &(_binding_0).0))) + } + RangeLimits::Closed(_binding_0) => { + RangeLimits::Closed(Token ! [ ..= ](tokens_helper(_visitor, &(_binding_0).0))) + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_return_type(_visitor: &mut V, _i: ReturnType) -> ReturnType { + match _i { + ReturnType::Default => ReturnType::Default, + ReturnType::Type(_binding_0, _binding_1) => ReturnType::Type( + Token ! [ -> ](tokens_helper(_visitor, &(_binding_0).0)), + Box::new(_visitor.fold_type(*_binding_1)), + ), + } +} +pub fn fold_span(_visitor: &mut V, _i: Span) -> Span { + _i +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn fold_stmt(_visitor: &mut V, _i: Stmt) -> Stmt { + match _i { + Stmt::Local(_binding_0) => Stmt::Local(_visitor.fold_local(_binding_0)), + Stmt::Item(_binding_0) => Stmt::Item(_visitor.fold_item(_binding_0)), + Stmt::Expr(_binding_0) => Stmt::Expr(_visitor.fold_expr(_binding_0)), + Stmt::Semi(_binding_0, _binding_1) => Stmt::Semi( + _visitor.fold_expr(_binding_0), + Token ! [ ; ](tokens_helper(_visitor, &(_binding_1).0)), + ), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_trait_bound(_visitor: &mut V, _i: TraitBound) -> TraitBound { + TraitBound { + paren_token: (_i.paren_token).map(|it| Paren(tokens_helper(_visitor, &(it).0))), + modifier: _visitor.fold_trait_bound_modifier(_i.modifier), + lifetimes: (_i.lifetimes).map(|it| _visitor.fold_bound_lifetimes(it)), + path: _visitor.fold_path(_i.path), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_trait_bound_modifier( + _visitor: &mut V, + _i: TraitBoundModifier, +) -> TraitBoundModifier { + match _i { + TraitBoundModifier::None => TraitBoundModifier::None, + TraitBoundModifier::Maybe(_binding_0) => { + TraitBoundModifier::Maybe(Token ! [ ? ](tokens_helper(_visitor, &(_binding_0).0))) + } + } +} +#[cfg(feature = "full")] +pub fn fold_trait_item(_visitor: &mut V, _i: TraitItem) -> TraitItem { + match _i { + TraitItem::Const(_binding_0) => { + TraitItem::Const(_visitor.fold_trait_item_const(_binding_0)) + } + TraitItem::Method(_binding_0) => { + TraitItem::Method(_visitor.fold_trait_item_method(_binding_0)) + } + TraitItem::Type(_binding_0) => TraitItem::Type(_visitor.fold_trait_item_type(_binding_0)), + TraitItem::Macro(_binding_0) => { + TraitItem::Macro(_visitor.fold_trait_item_macro(_binding_0)) + } + TraitItem::Verbatim(_binding_0) => { + TraitItem::Verbatim(_visitor.fold_trait_item_verbatim(_binding_0)) + } + } +} +#[cfg(feature = "full")] +pub fn fold_trait_item_const( + _visitor: &mut V, + _i: TraitItemConst, +) -> TraitItemConst { + TraitItemConst { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + const_token: Token ! [ const ](tokens_helper(_visitor, &(_i.const_token).0)), + ident: _visitor.fold_ident(_i.ident), + colon_token: Token ! [ : ](tokens_helper(_visitor, &(_i.colon_token).0)), + ty: _visitor.fold_type(_i.ty), + default: (_i.default).map(|it| { + ( + Token ! [ = ](tokens_helper(_visitor, &((it).0).0)), + _visitor.fold_expr((it).1), + ) + }), + semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), + } +} +#[cfg(feature = "full")] +pub fn fold_trait_item_macro( + _visitor: &mut V, + _i: TraitItemMacro, +) -> TraitItemMacro { + TraitItemMacro { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + mac: _visitor.fold_macro(_i.mac), + semi_token: (_i.semi_token).map(|it| Token ! [ ; ](tokens_helper(_visitor, &(it).0))), + } +} +#[cfg(feature = "full")] +pub fn fold_trait_item_method( + _visitor: &mut V, + _i: TraitItemMethod, +) -> TraitItemMethod { + TraitItemMethod { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + sig: _visitor.fold_method_sig(_i.sig), + default: (_i.default).map(|it| _visitor.fold_block(it)), + semi_token: (_i.semi_token).map(|it| Token ! [ ; ](tokens_helper(_visitor, &(it).0))), + } +} +#[cfg(feature = "full")] +pub fn fold_trait_item_type( + _visitor: &mut V, + _i: TraitItemType, +) -> TraitItemType { + TraitItemType { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + type_token: Token ! [ type ](tokens_helper(_visitor, &(_i.type_token).0)), + ident: _visitor.fold_ident(_i.ident), + generics: _visitor.fold_generics(_i.generics), + colon_token: (_i.colon_token).map(|it| Token ! [ : ](tokens_helper(_visitor, &(it).0))), + bounds: FoldHelper::lift(_i.bounds, |it| _visitor.fold_type_param_bound(it)), + default: (_i.default).map(|it| { + ( + Token ! [ = ](tokens_helper(_visitor, &((it).0).0)), + _visitor.fold_type((it).1), + ) + }), + semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), + } +} +#[cfg(feature = "full")] +pub fn fold_trait_item_verbatim( + _visitor: &mut V, + _i: TraitItemVerbatim, +) -> TraitItemVerbatim { + TraitItemVerbatim { tts: _i.tts } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_type(_visitor: &mut V, _i: Type) -> Type { + match _i { + Type::Slice(_binding_0) => Type::Slice(_visitor.fold_type_slice(_binding_0)), + Type::Array(_binding_0) => Type::Array(_visitor.fold_type_array(_binding_0)), + Type::Ptr(_binding_0) => Type::Ptr(_visitor.fold_type_ptr(_binding_0)), + Type::Reference(_binding_0) => Type::Reference(_visitor.fold_type_reference(_binding_0)), + Type::BareFn(_binding_0) => Type::BareFn(_visitor.fold_type_bare_fn(_binding_0)), + Type::Never(_binding_0) => Type::Never(_visitor.fold_type_never(_binding_0)), + Type::Tuple(_binding_0) => Type::Tuple(_visitor.fold_type_tuple(_binding_0)), + Type::Path(_binding_0) => Type::Path(_visitor.fold_type_path(_binding_0)), + Type::TraitObject(_binding_0) => { + Type::TraitObject(_visitor.fold_type_trait_object(_binding_0)) + } + Type::ImplTrait(_binding_0) => Type::ImplTrait(_visitor.fold_type_impl_trait(_binding_0)), + Type::Paren(_binding_0) => Type::Paren(_visitor.fold_type_paren(_binding_0)), + Type::Group(_binding_0) => Type::Group(_visitor.fold_type_group(_binding_0)), + Type::Infer(_binding_0) => Type::Infer(_visitor.fold_type_infer(_binding_0)), + Type::Macro(_binding_0) => Type::Macro(_visitor.fold_type_macro(_binding_0)), + Type::Verbatim(_binding_0) => Type::Verbatim(_visitor.fold_type_verbatim(_binding_0)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_type_array(_visitor: &mut V, _i: TypeArray) -> TypeArray { + TypeArray { + bracket_token: Bracket(tokens_helper(_visitor, &(_i.bracket_token).0)), + elem: Box::new(_visitor.fold_type(*_i.elem)), + semi_token: Token ! [ ; ](tokens_helper(_visitor, &(_i.semi_token).0)), + len: _visitor.fold_expr(_i.len), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_type_bare_fn(_visitor: &mut V, _i: TypeBareFn) -> TypeBareFn { + TypeBareFn { + unsafety: (_i.unsafety).map(|it| Token ! [ unsafe ](tokens_helper(_visitor, &(it).0))), + abi: (_i.abi).map(|it| _visitor.fold_abi(it)), + fn_token: Token ! [ fn ](tokens_helper(_visitor, &(_i.fn_token).0)), + lifetimes: (_i.lifetimes).map(|it| _visitor.fold_bound_lifetimes(it)), + paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), + inputs: FoldHelper::lift(_i.inputs, |it| _visitor.fold_bare_fn_arg(it)), + variadic: (_i.variadic).map(|it| Token ! [ ... ](tokens_helper(_visitor, &(it).0))), + output: _visitor.fold_return_type(_i.output), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_type_group(_visitor: &mut V, _i: TypeGroup) -> TypeGroup { + TypeGroup { + group_token: Group(tokens_helper(_visitor, &(_i.group_token).0)), + elem: Box::new(_visitor.fold_type(*_i.elem)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_type_impl_trait( + _visitor: &mut V, + _i: TypeImplTrait, +) -> TypeImplTrait { + TypeImplTrait { + impl_token: Token![impl ](tokens_helper(_visitor, &(_i.impl_token).0)), + bounds: FoldHelper::lift(_i.bounds, |it| _visitor.fold_type_param_bound(it)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_type_infer(_visitor: &mut V, _i: TypeInfer) -> TypeInfer { + TypeInfer { + underscore_token: Token![_](tokens_helper(_visitor, &(_i.underscore_token).0)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_type_macro(_visitor: &mut V, _i: TypeMacro) -> TypeMacro { + TypeMacro { + mac: _visitor.fold_macro(_i.mac), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_type_never(_visitor: &mut V, _i: TypeNever) -> TypeNever { + TypeNever { + bang_token: Token![!](tokens_helper(_visitor, &(_i.bang_token).0)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_type_param(_visitor: &mut V, _i: TypeParam) -> TypeParam { + TypeParam { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + ident: _visitor.fold_ident(_i.ident), + colon_token: (_i.colon_token).map(|it| Token ! [ : ](tokens_helper(_visitor, &(it).0))), + bounds: FoldHelper::lift(_i.bounds, |it| _visitor.fold_type_param_bound(it)), + eq_token: (_i.eq_token).map(|it| Token ! [ = ](tokens_helper(_visitor, &(it).0))), + default: (_i.default).map(|it| _visitor.fold_type(it)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_type_param_bound( + _visitor: &mut V, + _i: TypeParamBound, +) -> TypeParamBound { + match _i { + TypeParamBound::Trait(_binding_0) => { + TypeParamBound::Trait(_visitor.fold_trait_bound(_binding_0)) + } + TypeParamBound::Lifetime(_binding_0) => { + TypeParamBound::Lifetime(_visitor.fold_lifetime(_binding_0)) + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_type_paren(_visitor: &mut V, _i: TypeParen) -> TypeParen { + TypeParen { + paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), + elem: Box::new(_visitor.fold_type(*_i.elem)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_type_path(_visitor: &mut V, _i: TypePath) -> TypePath { + TypePath { + qself: (_i.qself).map(|it| _visitor.fold_qself(it)), + path: _visitor.fold_path(_i.path), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_type_ptr(_visitor: &mut V, _i: TypePtr) -> TypePtr { + TypePtr { + star_token: Token ! [ * ](tokens_helper(_visitor, &(_i.star_token).0)), + const_token: (_i.const_token).map(|it| Token ! [ const ](tokens_helper(_visitor, &(it).0))), + mutability: (_i.mutability).map(|it| Token ! [ mut ](tokens_helper(_visitor, &(it).0))), + elem: Box::new(_visitor.fold_type(*_i.elem)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_type_reference(_visitor: &mut V, _i: TypeReference) -> TypeReference { + TypeReference { + and_token: Token ! [ & ](tokens_helper(_visitor, &(_i.and_token).0)), + lifetime: (_i.lifetime).map(|it| _visitor.fold_lifetime(it)), + mutability: (_i.mutability).map(|it| Token ! [ mut ](tokens_helper(_visitor, &(it).0))), + elem: Box::new(_visitor.fold_type(*_i.elem)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_type_slice(_visitor: &mut V, _i: TypeSlice) -> TypeSlice { + TypeSlice { + bracket_token: Bracket(tokens_helper(_visitor, &(_i.bracket_token).0)), + elem: Box::new(_visitor.fold_type(*_i.elem)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_type_trait_object( + _visitor: &mut V, + _i: TypeTraitObject, +) -> TypeTraitObject { + TypeTraitObject { + dyn_token: (_i.dyn_token).map(|it| Token![dyn](tokens_helper(_visitor, &(it).0))), + bounds: FoldHelper::lift(_i.bounds, |it| _visitor.fold_type_param_bound(it)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_type_tuple(_visitor: &mut V, _i: TypeTuple) -> TypeTuple { + TypeTuple { + paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), + elems: FoldHelper::lift(_i.elems, |it| _visitor.fold_type(it)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_type_verbatim(_visitor: &mut V, _i: TypeVerbatim) -> TypeVerbatim { + TypeVerbatim { tts: _i.tts } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_un_op(_visitor: &mut V, _i: UnOp) -> UnOp { + match _i { + UnOp::Deref(_binding_0) => { + UnOp::Deref(Token ! [ * ](tokens_helper(_visitor, &(_binding_0).0))) + } + UnOp::Not(_binding_0) => UnOp::Not(Token![!](tokens_helper(_visitor, &(_binding_0).0))), + UnOp::Neg(_binding_0) => UnOp::Neg(Token ! [ - ](tokens_helper(_visitor, &(_binding_0).0))), + } +} +#[cfg(feature = "full")] +pub fn fold_use_glob(_visitor: &mut V, _i: UseGlob) -> UseGlob { + UseGlob { + star_token: Token ! [ * ](tokens_helper(_visitor, &(_i.star_token).0)), + } +} +#[cfg(feature = "full")] +pub fn fold_use_group(_visitor: &mut V, _i: UseGroup) -> UseGroup { + UseGroup { + brace_token: Brace(tokens_helper(_visitor, &(_i.brace_token).0)), + items: FoldHelper::lift(_i.items, |it| _visitor.fold_use_tree(it)), + } +} +#[cfg(feature = "full")] +pub fn fold_use_name(_visitor: &mut V, _i: UseName) -> UseName { + UseName { + ident: _visitor.fold_ident(_i.ident), + } +} +#[cfg(feature = "full")] +pub fn fold_use_path(_visitor: &mut V, _i: UsePath) -> UsePath { + UsePath { + ident: _visitor.fold_ident(_i.ident), + colon2_token: Token ! [ :: ](tokens_helper(_visitor, &(_i.colon2_token).0)), + tree: Box::new(_visitor.fold_use_tree(*_i.tree)), + } +} +#[cfg(feature = "full")] +pub fn fold_use_rename(_visitor: &mut V, _i: UseRename) -> UseRename { + UseRename { + ident: _visitor.fold_ident(_i.ident), + as_token: Token ! [ as ](tokens_helper(_visitor, &(_i.as_token).0)), + rename: _visitor.fold_ident(_i.rename), + } +} +#[cfg(feature = "full")] +pub fn fold_use_tree(_visitor: &mut V, _i: UseTree) -> UseTree { + match _i { + UseTree::Path(_binding_0) => UseTree::Path(_visitor.fold_use_path(_binding_0)), + UseTree::Name(_binding_0) => UseTree::Name(_visitor.fold_use_name(_binding_0)), + UseTree::Rename(_binding_0) => UseTree::Rename(_visitor.fold_use_rename(_binding_0)), + UseTree::Glob(_binding_0) => UseTree::Glob(_visitor.fold_use_glob(_binding_0)), + UseTree::Group(_binding_0) => UseTree::Group(_visitor.fold_use_group(_binding_0)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_variant(_visitor: &mut V, _i: Variant) -> Variant { + Variant { + attrs: FoldHelper::lift(_i.attrs, |it| _visitor.fold_attribute(it)), + ident: _visitor.fold_ident(_i.ident), + fields: _visitor.fold_fields(_i.fields), + discriminant: (_i.discriminant).map(|it| { + ( + Token ! [ = ](tokens_helper(_visitor, &((it).0).0)), + _visitor.fold_expr((it).1), + ) + }), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_vis_crate(_visitor: &mut V, _i: VisCrate) -> VisCrate { + VisCrate { + crate_token: Token![crate](tokens_helper(_visitor, &(_i.crate_token).0)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_vis_public(_visitor: &mut V, _i: VisPublic) -> VisPublic { + VisPublic { + pub_token: Token ! [ pub ](tokens_helper(_visitor, &(_i.pub_token).0)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_vis_restricted(_visitor: &mut V, _i: VisRestricted) -> VisRestricted { + VisRestricted { + pub_token: Token ! [ pub ](tokens_helper(_visitor, &(_i.pub_token).0)), + paren_token: Paren(tokens_helper(_visitor, &(_i.paren_token).0)), + in_token: (_i.in_token).map(|it| Token ! [ in ](tokens_helper(_visitor, &(it).0))), + path: Box::new(_visitor.fold_path(*_i.path)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_visibility(_visitor: &mut V, _i: Visibility) -> Visibility { + match _i { + Visibility::Public(_binding_0) => Visibility::Public(_visitor.fold_vis_public(_binding_0)), + Visibility::Crate(_binding_0) => Visibility::Crate(_visitor.fold_vis_crate(_binding_0)), + Visibility::Restricted(_binding_0) => { + Visibility::Restricted(_visitor.fold_vis_restricted(_binding_0)) + } + Visibility::Inherited => Visibility::Inherited, + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_where_clause(_visitor: &mut V, _i: WhereClause) -> WhereClause { + WhereClause { + where_token: Token ! [ where ](tokens_helper(_visitor, &(_i.where_token).0)), + predicates: FoldHelper::lift(_i.predicates, |it| _visitor.fold_where_predicate(it)), + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn fold_where_predicate( + _visitor: &mut V, + _i: WherePredicate, +) -> WherePredicate { + match _i { + WherePredicate::Type(_binding_0) => { + WherePredicate::Type(_visitor.fold_predicate_type(_binding_0)) + } + WherePredicate::Lifetime(_binding_0) => { + WherePredicate::Lifetime(_visitor.fold_predicate_lifetime(_binding_0)) + } + WherePredicate::Eq(_binding_0) => { + WherePredicate::Eq(_visitor.fold_predicate_eq(_binding_0)) + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/gen/visit_mut.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/gen/visit_mut.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/gen/visit_mut.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/gen/visit_mut.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,3290 @@ +// THIS FILE IS AUTOMATICALLY GENERATED; DO NOT EDIT + +#![cfg_attr(feature = "cargo-clippy", allow(match_same_arms))] +#[cfg(any(feature = "full", feature = "derive"))] +use gen::helper::visit_mut::*; +use proc_macro2::Span; +#[cfg(any(feature = "full", feature = "derive"))] +use punctuated::Punctuated; +use *; +#[cfg(feature = "full")] +macro_rules! full { + ($e:expr) => { + $e + }; +} +#[cfg(all(feature = "derive", not(feature = "full")))] +macro_rules! full { + ($e:expr) => { + unreachable!() + }; +} +#[cfg(any(feature = "full", feature = "derive"))] +macro_rules! skip { + ($($tt:tt)*) => {}; +} +#[doc = r" Syntax tree traversal to mutate an exclusive borrow of a syntax tree in"] +#[doc = r" place."] +#[doc = r""] +#[doc = r" See the [module documentation] for details."] +#[doc = r""] +#[doc = r" [module documentation]: index.html"] +#[doc = r""] +#[doc = r#" *This trait is available if Syn is built with the `"visit-mut"` feature.*"#] +pub trait VisitMut { + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_abi_mut(&mut self, i: &mut Abi) { + visit_abi_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_angle_bracketed_generic_arguments_mut( + &mut self, + i: &mut AngleBracketedGenericArguments, + ) { + visit_angle_bracketed_generic_arguments_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_arg_captured_mut(&mut self, i: &mut ArgCaptured) { + visit_arg_captured_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_arg_self_mut(&mut self, i: &mut ArgSelf) { + visit_arg_self_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_arg_self_ref_mut(&mut self, i: &mut ArgSelfRef) { + visit_arg_self_ref_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_arm_mut(&mut self, i: &mut Arm) { + visit_arm_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_attr_style_mut(&mut self, i: &mut AttrStyle) { + visit_attr_style_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_attribute_mut(&mut self, i: &mut Attribute) { + visit_attribute_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_bare_fn_arg_mut(&mut self, i: &mut BareFnArg) { + visit_bare_fn_arg_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_bare_fn_arg_name_mut(&mut self, i: &mut BareFnArgName) { + visit_bare_fn_arg_name_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_bin_op_mut(&mut self, i: &mut BinOp) { + visit_bin_op_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_binding_mut(&mut self, i: &mut Binding) { + visit_binding_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_block_mut(&mut self, i: &mut Block) { + visit_block_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_bound_lifetimes_mut(&mut self, i: &mut BoundLifetimes) { + visit_bound_lifetimes_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_const_param_mut(&mut self, i: &mut ConstParam) { + visit_const_param_mut(self, i) + } + #[cfg(feature = "derive")] + fn visit_data_mut(&mut self, i: &mut Data) { + visit_data_mut(self, i) + } + #[cfg(feature = "derive")] + fn visit_data_enum_mut(&mut self, i: &mut DataEnum) { + visit_data_enum_mut(self, i) + } + #[cfg(feature = "derive")] + fn visit_data_struct_mut(&mut self, i: &mut DataStruct) { + visit_data_struct_mut(self, i) + } + #[cfg(feature = "derive")] + fn visit_data_union_mut(&mut self, i: &mut DataUnion) { + visit_data_union_mut(self, i) + } + #[cfg(feature = "derive")] + fn visit_derive_input_mut(&mut self, i: &mut DeriveInput) { + visit_derive_input_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_mut(&mut self, i: &mut Expr) { + visit_expr_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_array_mut(&mut self, i: &mut ExprArray) { + visit_expr_array_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_assign_mut(&mut self, i: &mut ExprAssign) { + visit_expr_assign_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_assign_op_mut(&mut self, i: &mut ExprAssignOp) { + visit_expr_assign_op_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_binary_mut(&mut self, i: &mut ExprBinary) { + visit_expr_binary_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_block_mut(&mut self, i: &mut ExprBlock) { + visit_expr_block_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_box_mut(&mut self, i: &mut ExprBox) { + visit_expr_box_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_break_mut(&mut self, i: &mut ExprBreak) { + visit_expr_break_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_call_mut(&mut self, i: &mut ExprCall) { + visit_expr_call_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_cast_mut(&mut self, i: &mut ExprCast) { + visit_expr_cast_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_catch_mut(&mut self, i: &mut ExprCatch) { + visit_expr_catch_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_closure_mut(&mut self, i: &mut ExprClosure) { + visit_expr_closure_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_continue_mut(&mut self, i: &mut ExprContinue) { + visit_expr_continue_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_field_mut(&mut self, i: &mut ExprField) { + visit_expr_field_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_for_loop_mut(&mut self, i: &mut ExprForLoop) { + visit_expr_for_loop_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_group_mut(&mut self, i: &mut ExprGroup) { + visit_expr_group_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_if_mut(&mut self, i: &mut ExprIf) { + visit_expr_if_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_if_let_mut(&mut self, i: &mut ExprIfLet) { + visit_expr_if_let_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_in_place_mut(&mut self, i: &mut ExprInPlace) { + visit_expr_in_place_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_index_mut(&mut self, i: &mut ExprIndex) { + visit_expr_index_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_lit_mut(&mut self, i: &mut ExprLit) { + visit_expr_lit_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_loop_mut(&mut self, i: &mut ExprLoop) { + visit_expr_loop_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_macro_mut(&mut self, i: &mut ExprMacro) { + visit_expr_macro_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_match_mut(&mut self, i: &mut ExprMatch) { + visit_expr_match_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_method_call_mut(&mut self, i: &mut ExprMethodCall) { + visit_expr_method_call_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_paren_mut(&mut self, i: &mut ExprParen) { + visit_expr_paren_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_path_mut(&mut self, i: &mut ExprPath) { + visit_expr_path_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_range_mut(&mut self, i: &mut ExprRange) { + visit_expr_range_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_reference_mut(&mut self, i: &mut ExprReference) { + visit_expr_reference_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_repeat_mut(&mut self, i: &mut ExprRepeat) { + visit_expr_repeat_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_return_mut(&mut self, i: &mut ExprReturn) { + visit_expr_return_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_struct_mut(&mut self, i: &mut ExprStruct) { + visit_expr_struct_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_try_mut(&mut self, i: &mut ExprTry) { + visit_expr_try_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_tuple_mut(&mut self, i: &mut ExprTuple) { + visit_expr_tuple_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_type_mut(&mut self, i: &mut ExprType) { + visit_expr_type_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_unary_mut(&mut self, i: &mut ExprUnary) { + visit_expr_unary_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_unsafe_mut(&mut self, i: &mut ExprUnsafe) { + visit_expr_unsafe_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_verbatim_mut(&mut self, i: &mut ExprVerbatim) { + visit_expr_verbatim_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_while_mut(&mut self, i: &mut ExprWhile) { + visit_expr_while_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_while_let_mut(&mut self, i: &mut ExprWhileLet) { + visit_expr_while_let_mut(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_yield_mut(&mut self, i: &mut ExprYield) { + visit_expr_yield_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_field_mut(&mut self, i: &mut Field) { + visit_field_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_field_pat_mut(&mut self, i: &mut FieldPat) { + visit_field_pat_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_field_value_mut(&mut self, i: &mut FieldValue) { + visit_field_value_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_fields_mut(&mut self, i: &mut Fields) { + visit_fields_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_fields_named_mut(&mut self, i: &mut FieldsNamed) { + visit_fields_named_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_fields_unnamed_mut(&mut self, i: &mut FieldsUnnamed) { + visit_fields_unnamed_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_file_mut(&mut self, i: &mut File) { + visit_file_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_fn_arg_mut(&mut self, i: &mut FnArg) { + visit_fn_arg_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_fn_decl_mut(&mut self, i: &mut FnDecl) { + visit_fn_decl_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_foreign_item_mut(&mut self, i: &mut ForeignItem) { + visit_foreign_item_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_foreign_item_fn_mut(&mut self, i: &mut ForeignItemFn) { + visit_foreign_item_fn_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_foreign_item_static_mut(&mut self, i: &mut ForeignItemStatic) { + visit_foreign_item_static_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_foreign_item_type_mut(&mut self, i: &mut ForeignItemType) { + visit_foreign_item_type_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_foreign_item_verbatim_mut(&mut self, i: &mut ForeignItemVerbatim) { + visit_foreign_item_verbatim_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_generic_argument_mut(&mut self, i: &mut GenericArgument) { + visit_generic_argument_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_generic_method_argument_mut(&mut self, i: &mut GenericMethodArgument) { + visit_generic_method_argument_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_generic_param_mut(&mut self, i: &mut GenericParam) { + visit_generic_param_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_generics_mut(&mut self, i: &mut Generics) { + visit_generics_mut(self, i) + } + fn visit_ident_mut(&mut self, i: &mut Ident) { + visit_ident_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_impl_item_mut(&mut self, i: &mut ImplItem) { + visit_impl_item_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_impl_item_const_mut(&mut self, i: &mut ImplItemConst) { + visit_impl_item_const_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_impl_item_macro_mut(&mut self, i: &mut ImplItemMacro) { + visit_impl_item_macro_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_impl_item_method_mut(&mut self, i: &mut ImplItemMethod) { + visit_impl_item_method_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_impl_item_type_mut(&mut self, i: &mut ImplItemType) { + visit_impl_item_type_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_impl_item_verbatim_mut(&mut self, i: &mut ImplItemVerbatim) { + visit_impl_item_verbatim_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_index_mut(&mut self, i: &mut Index) { + visit_index_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_item_mut(&mut self, i: &mut Item) { + visit_item_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_item_const_mut(&mut self, i: &mut ItemConst) { + visit_item_const_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_item_enum_mut(&mut self, i: &mut ItemEnum) { + visit_item_enum_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_item_extern_crate_mut(&mut self, i: &mut ItemExternCrate) { + visit_item_extern_crate_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_item_fn_mut(&mut self, i: &mut ItemFn) { + visit_item_fn_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_item_foreign_mod_mut(&mut self, i: &mut ItemForeignMod) { + visit_item_foreign_mod_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_item_impl_mut(&mut self, i: &mut ItemImpl) { + visit_item_impl_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_item_macro_mut(&mut self, i: &mut ItemMacro) { + visit_item_macro_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_item_macro2_mut(&mut self, i: &mut ItemMacro2) { + visit_item_macro2_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_item_mod_mut(&mut self, i: &mut ItemMod) { + visit_item_mod_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_item_static_mut(&mut self, i: &mut ItemStatic) { + visit_item_static_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_item_struct_mut(&mut self, i: &mut ItemStruct) { + visit_item_struct_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_item_trait_mut(&mut self, i: &mut ItemTrait) { + visit_item_trait_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_item_type_mut(&mut self, i: &mut ItemType) { + visit_item_type_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_item_union_mut(&mut self, i: &mut ItemUnion) { + visit_item_union_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_item_use_mut(&mut self, i: &mut ItemUse) { + visit_item_use_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_item_verbatim_mut(&mut self, i: &mut ItemVerbatim) { + visit_item_verbatim_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_label_mut(&mut self, i: &mut Label) { + visit_label_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_lifetime_mut(&mut self, i: &mut Lifetime) { + visit_lifetime_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_lifetime_def_mut(&mut self, i: &mut LifetimeDef) { + visit_lifetime_def_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_lit_mut(&mut self, i: &mut Lit) { + visit_lit_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_lit_bool_mut(&mut self, i: &mut LitBool) { + visit_lit_bool_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_lit_byte_mut(&mut self, i: &mut LitByte) { + visit_lit_byte_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_lit_byte_str_mut(&mut self, i: &mut LitByteStr) { + visit_lit_byte_str_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_lit_char_mut(&mut self, i: &mut LitChar) { + visit_lit_char_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_lit_float_mut(&mut self, i: &mut LitFloat) { + visit_lit_float_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_lit_int_mut(&mut self, i: &mut LitInt) { + visit_lit_int_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_lit_str_mut(&mut self, i: &mut LitStr) { + visit_lit_str_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_lit_verbatim_mut(&mut self, i: &mut LitVerbatim) { + visit_lit_verbatim_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_local_mut(&mut self, i: &mut Local) { + visit_local_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_macro_mut(&mut self, i: &mut Macro) { + visit_macro_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_macro_delimiter_mut(&mut self, i: &mut MacroDelimiter) { + visit_macro_delimiter_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_member_mut(&mut self, i: &mut Member) { + visit_member_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_meta_mut(&mut self, i: &mut Meta) { + visit_meta_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_meta_list_mut(&mut self, i: &mut MetaList) { + visit_meta_list_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_meta_name_value_mut(&mut self, i: &mut MetaNameValue) { + visit_meta_name_value_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_method_sig_mut(&mut self, i: &mut MethodSig) { + visit_method_sig_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_method_turbofish_mut(&mut self, i: &mut MethodTurbofish) { + visit_method_turbofish_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_nested_meta_mut(&mut self, i: &mut NestedMeta) { + visit_nested_meta_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_parenthesized_generic_arguments_mut(&mut self, i: &mut ParenthesizedGenericArguments) { + visit_parenthesized_generic_arguments_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_mut(&mut self, i: &mut Pat) { + visit_pat_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_box_mut(&mut self, i: &mut PatBox) { + visit_pat_box_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_ident_mut(&mut self, i: &mut PatIdent) { + visit_pat_ident_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_lit_mut(&mut self, i: &mut PatLit) { + visit_pat_lit_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_macro_mut(&mut self, i: &mut PatMacro) { + visit_pat_macro_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_path_mut(&mut self, i: &mut PatPath) { + visit_pat_path_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_range_mut(&mut self, i: &mut PatRange) { + visit_pat_range_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_ref_mut(&mut self, i: &mut PatRef) { + visit_pat_ref_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_slice_mut(&mut self, i: &mut PatSlice) { + visit_pat_slice_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_struct_mut(&mut self, i: &mut PatStruct) { + visit_pat_struct_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_tuple_mut(&mut self, i: &mut PatTuple) { + visit_pat_tuple_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_tuple_struct_mut(&mut self, i: &mut PatTupleStruct) { + visit_pat_tuple_struct_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_verbatim_mut(&mut self, i: &mut PatVerbatim) { + visit_pat_verbatim_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_wild_mut(&mut self, i: &mut PatWild) { + visit_pat_wild_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_path_mut(&mut self, i: &mut Path) { + visit_path_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_path_arguments_mut(&mut self, i: &mut PathArguments) { + visit_path_arguments_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_path_segment_mut(&mut self, i: &mut PathSegment) { + visit_path_segment_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_predicate_eq_mut(&mut self, i: &mut PredicateEq) { + visit_predicate_eq_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_predicate_lifetime_mut(&mut self, i: &mut PredicateLifetime) { + visit_predicate_lifetime_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_predicate_type_mut(&mut self, i: &mut PredicateType) { + visit_predicate_type_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_qself_mut(&mut self, i: &mut QSelf) { + visit_qself_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_range_limits_mut(&mut self, i: &mut RangeLimits) { + visit_range_limits_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_return_type_mut(&mut self, i: &mut ReturnType) { + visit_return_type_mut(self, i) + } + fn visit_span_mut(&mut self, i: &mut Span) { + visit_span_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_stmt_mut(&mut self, i: &mut Stmt) { + visit_stmt_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_trait_bound_mut(&mut self, i: &mut TraitBound) { + visit_trait_bound_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_trait_bound_modifier_mut(&mut self, i: &mut TraitBoundModifier) { + visit_trait_bound_modifier_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_trait_item_mut(&mut self, i: &mut TraitItem) { + visit_trait_item_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_trait_item_const_mut(&mut self, i: &mut TraitItemConst) { + visit_trait_item_const_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_trait_item_macro_mut(&mut self, i: &mut TraitItemMacro) { + visit_trait_item_macro_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_trait_item_method_mut(&mut self, i: &mut TraitItemMethod) { + visit_trait_item_method_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_trait_item_type_mut(&mut self, i: &mut TraitItemType) { + visit_trait_item_type_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_trait_item_verbatim_mut(&mut self, i: &mut TraitItemVerbatim) { + visit_trait_item_verbatim_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_mut(&mut self, i: &mut Type) { + visit_type_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_array_mut(&mut self, i: &mut TypeArray) { + visit_type_array_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_bare_fn_mut(&mut self, i: &mut TypeBareFn) { + visit_type_bare_fn_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_group_mut(&mut self, i: &mut TypeGroup) { + visit_type_group_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_impl_trait_mut(&mut self, i: &mut TypeImplTrait) { + visit_type_impl_trait_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_infer_mut(&mut self, i: &mut TypeInfer) { + visit_type_infer_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_macro_mut(&mut self, i: &mut TypeMacro) { + visit_type_macro_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_never_mut(&mut self, i: &mut TypeNever) { + visit_type_never_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_param_mut(&mut self, i: &mut TypeParam) { + visit_type_param_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_param_bound_mut(&mut self, i: &mut TypeParamBound) { + visit_type_param_bound_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_paren_mut(&mut self, i: &mut TypeParen) { + visit_type_paren_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_path_mut(&mut self, i: &mut TypePath) { + visit_type_path_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_ptr_mut(&mut self, i: &mut TypePtr) { + visit_type_ptr_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_reference_mut(&mut self, i: &mut TypeReference) { + visit_type_reference_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_slice_mut(&mut self, i: &mut TypeSlice) { + visit_type_slice_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_trait_object_mut(&mut self, i: &mut TypeTraitObject) { + visit_type_trait_object_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_tuple_mut(&mut self, i: &mut TypeTuple) { + visit_type_tuple_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_verbatim_mut(&mut self, i: &mut TypeVerbatim) { + visit_type_verbatim_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_un_op_mut(&mut self, i: &mut UnOp) { + visit_un_op_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_use_glob_mut(&mut self, i: &mut UseGlob) { + visit_use_glob_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_use_group_mut(&mut self, i: &mut UseGroup) { + visit_use_group_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_use_name_mut(&mut self, i: &mut UseName) { + visit_use_name_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_use_path_mut(&mut self, i: &mut UsePath) { + visit_use_path_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_use_rename_mut(&mut self, i: &mut UseRename) { + visit_use_rename_mut(self, i) + } + #[cfg(feature = "full")] + fn visit_use_tree_mut(&mut self, i: &mut UseTree) { + visit_use_tree_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_variant_mut(&mut self, i: &mut Variant) { + visit_variant_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_vis_crate_mut(&mut self, i: &mut VisCrate) { + visit_vis_crate_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_vis_public_mut(&mut self, i: &mut VisPublic) { + visit_vis_public_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_vis_restricted_mut(&mut self, i: &mut VisRestricted) { + visit_vis_restricted_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_visibility_mut(&mut self, i: &mut Visibility) { + visit_visibility_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_where_clause_mut(&mut self, i: &mut WhereClause) { + visit_where_clause_mut(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_where_predicate_mut(&mut self, i: &mut WherePredicate) { + visit_where_predicate_mut(self, i) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_abi_mut(_visitor: &mut V, _i: &mut Abi) { + tokens_helper(_visitor, &mut (_i.extern_token).0); + if let Some(ref mut it) = _i.name { + _visitor.visit_lit_str_mut(it) + }; +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_angle_bracketed_generic_arguments_mut( + _visitor: &mut V, + _i: &mut AngleBracketedGenericArguments, +) { + if let Some(ref mut it) = _i.colon2_token { + tokens_helper(_visitor, &mut (it).0) + }; + tokens_helper(_visitor, &mut (_i.lt_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.args) { + let it = el.value_mut(); + _visitor.visit_generic_argument_mut(it) + } + tokens_helper(_visitor, &mut (_i.gt_token).0); +} +#[cfg(feature = "full")] +pub fn visit_arg_captured_mut(_visitor: &mut V, _i: &mut ArgCaptured) { + _visitor.visit_pat_mut(&mut _i.pat); + tokens_helper(_visitor, &mut (_i.colon_token).0); + _visitor.visit_type_mut(&mut _i.ty); +} +#[cfg(feature = "full")] +pub fn visit_arg_self_mut(_visitor: &mut V, _i: &mut ArgSelf) { + if let Some(ref mut it) = _i.mutability { + tokens_helper(_visitor, &mut (it).0) + }; + tokens_helper(_visitor, &mut (_i.self_token).0); +} +#[cfg(feature = "full")] +pub fn visit_arg_self_ref_mut(_visitor: &mut V, _i: &mut ArgSelfRef) { + tokens_helper(_visitor, &mut (_i.and_token).0); + if let Some(ref mut it) = _i.lifetime { + _visitor.visit_lifetime_mut(it) + }; + if let Some(ref mut it) = _i.mutability { + tokens_helper(_visitor, &mut (it).0) + }; + tokens_helper(_visitor, &mut (_i.self_token).0); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_arm_mut(_visitor: &mut V, _i: &mut Arm) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + if let Some(ref mut it) = _i.leading_vert { + tokens_helper(_visitor, &mut (it).0) + }; + for mut el in Punctuated::pairs_mut(&mut _i.pats) { + let it = el.value_mut(); + _visitor.visit_pat_mut(it) + } + if let Some(ref mut it) = _i.guard { + tokens_helper(_visitor, &mut ((it).0).0); + _visitor.visit_expr_mut(&mut *(it).1); + }; + tokens_helper(_visitor, &mut (_i.fat_arrow_token).0); + _visitor.visit_expr_mut(&mut *_i.body); + if let Some(ref mut it) = _i.comma { + tokens_helper(_visitor, &mut (it).0) + }; +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_attr_style_mut(_visitor: &mut V, _i: &mut AttrStyle) { + match *_i { + AttrStyle::Outer => {} + AttrStyle::Inner(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_attribute_mut(_visitor: &mut V, _i: &mut Attribute) { + tokens_helper(_visitor, &mut (_i.pound_token).0); + _visitor.visit_attr_style_mut(&mut _i.style); + tokens_helper(_visitor, &mut (_i.bracket_token).0); + _visitor.visit_path_mut(&mut _i.path); + skip!(_i.tts); + skip!(_i.is_sugared_doc); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_bare_fn_arg_mut(_visitor: &mut V, _i: &mut BareFnArg) { + if let Some(ref mut it) = _i.name { + _visitor.visit_bare_fn_arg_name_mut(&mut (it).0); + tokens_helper(_visitor, &mut ((it).1).0); + }; + _visitor.visit_type_mut(&mut _i.ty); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_bare_fn_arg_name_mut(_visitor: &mut V, _i: &mut BareFnArgName) { + match *_i { + BareFnArgName::Named(ref mut _binding_0) => { + _visitor.visit_ident_mut(_binding_0); + } + BareFnArgName::Wild(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_bin_op_mut(_visitor: &mut V, _i: &mut BinOp) { + match *_i { + BinOp::Add(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::Sub(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::Mul(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::Div(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::Rem(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::And(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::Or(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::BitXor(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::BitAnd(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::BitOr(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::Shl(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::Shr(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::Eq(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::Lt(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::Le(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::Ne(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::Ge(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::Gt(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::AddEq(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::SubEq(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::MulEq(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::DivEq(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::RemEq(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::BitXorEq(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::BitAndEq(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::BitOrEq(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::ShlEq(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + BinOp::ShrEq(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_binding_mut(_visitor: &mut V, _i: &mut Binding) { + _visitor.visit_ident_mut(&mut _i.ident); + tokens_helper(_visitor, &mut (_i.eq_token).0); + _visitor.visit_type_mut(&mut _i.ty); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_block_mut(_visitor: &mut V, _i: &mut Block) { + tokens_helper(_visitor, &mut (_i.brace_token).0); + for it in &mut _i.stmts { + _visitor.visit_stmt_mut(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_bound_lifetimes_mut(_visitor: &mut V, _i: &mut BoundLifetimes) { + tokens_helper(_visitor, &mut (_i.for_token).0); + tokens_helper(_visitor, &mut (_i.lt_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.lifetimes) { + let it = el.value_mut(); + _visitor.visit_lifetime_def_mut(it) + } + tokens_helper(_visitor, &mut (_i.gt_token).0); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_const_param_mut(_visitor: &mut V, _i: &mut ConstParam) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + tokens_helper(_visitor, &mut (_i.const_token).0); + _visitor.visit_ident_mut(&mut _i.ident); + tokens_helper(_visitor, &mut (_i.colon_token).0); + _visitor.visit_type_mut(&mut _i.ty); + if let Some(ref mut it) = _i.eq_token { + tokens_helper(_visitor, &mut (it).0) + }; + if let Some(ref mut it) = _i.default { + _visitor.visit_expr_mut(it) + }; +} +#[cfg(feature = "derive")] +pub fn visit_data_mut(_visitor: &mut V, _i: &mut Data) { + match *_i { + Data::Struct(ref mut _binding_0) => { + _visitor.visit_data_struct_mut(_binding_0); + } + Data::Enum(ref mut _binding_0) => { + _visitor.visit_data_enum_mut(_binding_0); + } + Data::Union(ref mut _binding_0) => { + _visitor.visit_data_union_mut(_binding_0); + } + } +} +#[cfg(feature = "derive")] +pub fn visit_data_enum_mut(_visitor: &mut V, _i: &mut DataEnum) { + tokens_helper(_visitor, &mut (_i.enum_token).0); + tokens_helper(_visitor, &mut (_i.brace_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.variants) { + let it = el.value_mut(); + _visitor.visit_variant_mut(it) + } +} +#[cfg(feature = "derive")] +pub fn visit_data_struct_mut(_visitor: &mut V, _i: &mut DataStruct) { + tokens_helper(_visitor, &mut (_i.struct_token).0); + _visitor.visit_fields_mut(&mut _i.fields); + if let Some(ref mut it) = _i.semi_token { + tokens_helper(_visitor, &mut (it).0) + }; +} +#[cfg(feature = "derive")] +pub fn visit_data_union_mut(_visitor: &mut V, _i: &mut DataUnion) { + tokens_helper(_visitor, &mut (_i.union_token).0); + _visitor.visit_fields_named_mut(&mut _i.fields); +} +#[cfg(feature = "derive")] +pub fn visit_derive_input_mut(_visitor: &mut V, _i: &mut DeriveInput) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_visibility_mut(&mut _i.vis); + _visitor.visit_ident_mut(&mut _i.ident); + _visitor.visit_generics_mut(&mut _i.generics); + _visitor.visit_data_mut(&mut _i.data); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_mut(_visitor: &mut V, _i: &mut Expr) { + match *_i { + Expr::Box(ref mut _binding_0) => { + full!(_visitor.visit_expr_box_mut(_binding_0)); + } + Expr::InPlace(ref mut _binding_0) => { + full!(_visitor.visit_expr_in_place_mut(_binding_0)); + } + Expr::Array(ref mut _binding_0) => { + full!(_visitor.visit_expr_array_mut(_binding_0)); + } + Expr::Call(ref mut _binding_0) => { + _visitor.visit_expr_call_mut(_binding_0); + } + Expr::MethodCall(ref mut _binding_0) => { + full!(_visitor.visit_expr_method_call_mut(_binding_0)); + } + Expr::Tuple(ref mut _binding_0) => { + full!(_visitor.visit_expr_tuple_mut(_binding_0)); + } + Expr::Binary(ref mut _binding_0) => { + _visitor.visit_expr_binary_mut(_binding_0); + } + Expr::Unary(ref mut _binding_0) => { + _visitor.visit_expr_unary_mut(_binding_0); + } + Expr::Lit(ref mut _binding_0) => { + _visitor.visit_expr_lit_mut(_binding_0); + } + Expr::Cast(ref mut _binding_0) => { + _visitor.visit_expr_cast_mut(_binding_0); + } + Expr::Type(ref mut _binding_0) => { + full!(_visitor.visit_expr_type_mut(_binding_0)); + } + Expr::If(ref mut _binding_0) => { + full!(_visitor.visit_expr_if_mut(_binding_0)); + } + Expr::IfLet(ref mut _binding_0) => { + full!(_visitor.visit_expr_if_let_mut(_binding_0)); + } + Expr::While(ref mut _binding_0) => { + full!(_visitor.visit_expr_while_mut(_binding_0)); + } + Expr::WhileLet(ref mut _binding_0) => { + full!(_visitor.visit_expr_while_let_mut(_binding_0)); + } + Expr::ForLoop(ref mut _binding_0) => { + full!(_visitor.visit_expr_for_loop_mut(_binding_0)); + } + Expr::Loop(ref mut _binding_0) => { + full!(_visitor.visit_expr_loop_mut(_binding_0)); + } + Expr::Match(ref mut _binding_0) => { + full!(_visitor.visit_expr_match_mut(_binding_0)); + } + Expr::Closure(ref mut _binding_0) => { + full!(_visitor.visit_expr_closure_mut(_binding_0)); + } + Expr::Unsafe(ref mut _binding_0) => { + full!(_visitor.visit_expr_unsafe_mut(_binding_0)); + } + Expr::Block(ref mut _binding_0) => { + full!(_visitor.visit_expr_block_mut(_binding_0)); + } + Expr::Assign(ref mut _binding_0) => { + full!(_visitor.visit_expr_assign_mut(_binding_0)); + } + Expr::AssignOp(ref mut _binding_0) => { + full!(_visitor.visit_expr_assign_op_mut(_binding_0)); + } + Expr::Field(ref mut _binding_0) => { + _visitor.visit_expr_field_mut(_binding_0); + } + Expr::Index(ref mut _binding_0) => { + _visitor.visit_expr_index_mut(_binding_0); + } + Expr::Range(ref mut _binding_0) => { + full!(_visitor.visit_expr_range_mut(_binding_0)); + } + Expr::Path(ref mut _binding_0) => { + _visitor.visit_expr_path_mut(_binding_0); + } + Expr::Reference(ref mut _binding_0) => { + full!(_visitor.visit_expr_reference_mut(_binding_0)); + } + Expr::Break(ref mut _binding_0) => { + full!(_visitor.visit_expr_break_mut(_binding_0)); + } + Expr::Continue(ref mut _binding_0) => { + full!(_visitor.visit_expr_continue_mut(_binding_0)); + } + Expr::Return(ref mut _binding_0) => { + full!(_visitor.visit_expr_return_mut(_binding_0)); + } + Expr::Macro(ref mut _binding_0) => { + full!(_visitor.visit_expr_macro_mut(_binding_0)); + } + Expr::Struct(ref mut _binding_0) => { + full!(_visitor.visit_expr_struct_mut(_binding_0)); + } + Expr::Repeat(ref mut _binding_0) => { + full!(_visitor.visit_expr_repeat_mut(_binding_0)); + } + Expr::Paren(ref mut _binding_0) => { + _visitor.visit_expr_paren_mut(_binding_0); + } + Expr::Group(ref mut _binding_0) => { + full!(_visitor.visit_expr_group_mut(_binding_0)); + } + Expr::Try(ref mut _binding_0) => { + full!(_visitor.visit_expr_try_mut(_binding_0)); + } + Expr::Catch(ref mut _binding_0) => { + full!(_visitor.visit_expr_catch_mut(_binding_0)); + } + Expr::Yield(ref mut _binding_0) => { + full!(_visitor.visit_expr_yield_mut(_binding_0)); + } + Expr::Verbatim(ref mut _binding_0) => { + _visitor.visit_expr_verbatim_mut(_binding_0); + } + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_array_mut(_visitor: &mut V, _i: &mut ExprArray) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + tokens_helper(_visitor, &mut (_i.bracket_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.elems) { + let it = el.value_mut(); + _visitor.visit_expr_mut(it) + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_assign_mut(_visitor: &mut V, _i: &mut ExprAssign) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_expr_mut(&mut *_i.left); + tokens_helper(_visitor, &mut (_i.eq_token).0); + _visitor.visit_expr_mut(&mut *_i.right); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_assign_op_mut(_visitor: &mut V, _i: &mut ExprAssignOp) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_expr_mut(&mut *_i.left); + _visitor.visit_bin_op_mut(&mut _i.op); + _visitor.visit_expr_mut(&mut *_i.right); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_binary_mut(_visitor: &mut V, _i: &mut ExprBinary) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_expr_mut(&mut *_i.left); + _visitor.visit_bin_op_mut(&mut _i.op); + _visitor.visit_expr_mut(&mut *_i.right); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_block_mut(_visitor: &mut V, _i: &mut ExprBlock) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_block_mut(&mut _i.block); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_box_mut(_visitor: &mut V, _i: &mut ExprBox) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + tokens_helper(_visitor, &mut (_i.box_token).0); + _visitor.visit_expr_mut(&mut *_i.expr); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_break_mut(_visitor: &mut V, _i: &mut ExprBreak) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + tokens_helper(_visitor, &mut (_i.break_token).0); + if let Some(ref mut it) = _i.label { + _visitor.visit_lifetime_mut(it) + }; + if let Some(ref mut it) = _i.expr { + _visitor.visit_expr_mut(&mut **it) + }; +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_call_mut(_visitor: &mut V, _i: &mut ExprCall) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_expr_mut(&mut *_i.func); + tokens_helper(_visitor, &mut (_i.paren_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.args) { + let it = el.value_mut(); + _visitor.visit_expr_mut(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_cast_mut(_visitor: &mut V, _i: &mut ExprCast) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_expr_mut(&mut *_i.expr); + tokens_helper(_visitor, &mut (_i.as_token).0); + _visitor.visit_type_mut(&mut *_i.ty); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_catch_mut(_visitor: &mut V, _i: &mut ExprCatch) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + tokens_helper(_visitor, &mut (_i.do_token).0); + tokens_helper(_visitor, &mut (_i.catch_token).0); + _visitor.visit_block_mut(&mut _i.block); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_closure_mut(_visitor: &mut V, _i: &mut ExprClosure) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + if let Some(ref mut it) = _i.movability { + tokens_helper(_visitor, &mut (it).0) + }; + if let Some(ref mut it) = _i.capture { + tokens_helper(_visitor, &mut (it).0) + }; + tokens_helper(_visitor, &mut (_i.or1_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.inputs) { + let it = el.value_mut(); + _visitor.visit_fn_arg_mut(it) + } + tokens_helper(_visitor, &mut (_i.or2_token).0); + _visitor.visit_return_type_mut(&mut _i.output); + _visitor.visit_expr_mut(&mut *_i.body); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_continue_mut(_visitor: &mut V, _i: &mut ExprContinue) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + tokens_helper(_visitor, &mut (_i.continue_token).0); + if let Some(ref mut it) = _i.label { + _visitor.visit_lifetime_mut(it) + }; +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_field_mut(_visitor: &mut V, _i: &mut ExprField) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_expr_mut(&mut *_i.base); + tokens_helper(_visitor, &mut (_i.dot_token).0); + _visitor.visit_member_mut(&mut _i.member); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_for_loop_mut(_visitor: &mut V, _i: &mut ExprForLoop) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + if let Some(ref mut it) = _i.label { + _visitor.visit_label_mut(it) + }; + tokens_helper(_visitor, &mut (_i.for_token).0); + _visitor.visit_pat_mut(&mut *_i.pat); + tokens_helper(_visitor, &mut (_i.in_token).0); + _visitor.visit_expr_mut(&mut *_i.expr); + _visitor.visit_block_mut(&mut _i.body); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_group_mut(_visitor: &mut V, _i: &mut ExprGroup) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + tokens_helper(_visitor, &mut (_i.group_token).0); + _visitor.visit_expr_mut(&mut *_i.expr); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_if_mut(_visitor: &mut V, _i: &mut ExprIf) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + tokens_helper(_visitor, &mut (_i.if_token).0); + _visitor.visit_expr_mut(&mut *_i.cond); + _visitor.visit_block_mut(&mut _i.then_branch); + if let Some(ref mut it) = _i.else_branch { + tokens_helper(_visitor, &mut ((it).0).0); + _visitor.visit_expr_mut(&mut *(it).1); + }; +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_if_let_mut(_visitor: &mut V, _i: &mut ExprIfLet) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + tokens_helper(_visitor, &mut (_i.if_token).0); + tokens_helper(_visitor, &mut (_i.let_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.pats) { + let it = el.value_mut(); + _visitor.visit_pat_mut(it) + } + tokens_helper(_visitor, &mut (_i.eq_token).0); + _visitor.visit_expr_mut(&mut *_i.expr); + _visitor.visit_block_mut(&mut _i.then_branch); + if let Some(ref mut it) = _i.else_branch { + tokens_helper(_visitor, &mut ((it).0).0); + _visitor.visit_expr_mut(&mut *(it).1); + }; +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_in_place_mut(_visitor: &mut V, _i: &mut ExprInPlace) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_expr_mut(&mut *_i.place); + tokens_helper(_visitor, &mut (_i.arrow_token).0); + _visitor.visit_expr_mut(&mut *_i.value); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_index_mut(_visitor: &mut V, _i: &mut ExprIndex) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_expr_mut(&mut *_i.expr); + tokens_helper(_visitor, &mut (_i.bracket_token).0); + _visitor.visit_expr_mut(&mut *_i.index); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_lit_mut(_visitor: &mut V, _i: &mut ExprLit) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_lit_mut(&mut _i.lit); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_loop_mut(_visitor: &mut V, _i: &mut ExprLoop) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + if let Some(ref mut it) = _i.label { + _visitor.visit_label_mut(it) + }; + tokens_helper(_visitor, &mut (_i.loop_token).0); + _visitor.visit_block_mut(&mut _i.body); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_macro_mut(_visitor: &mut V, _i: &mut ExprMacro) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_macro_mut(&mut _i.mac); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_match_mut(_visitor: &mut V, _i: &mut ExprMatch) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + tokens_helper(_visitor, &mut (_i.match_token).0); + _visitor.visit_expr_mut(&mut *_i.expr); + tokens_helper(_visitor, &mut (_i.brace_token).0); + for it in &mut _i.arms { + _visitor.visit_arm_mut(it) + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_method_call_mut(_visitor: &mut V, _i: &mut ExprMethodCall) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_expr_mut(&mut *_i.receiver); + tokens_helper(_visitor, &mut (_i.dot_token).0); + _visitor.visit_ident_mut(&mut _i.method); + if let Some(ref mut it) = _i.turbofish { + _visitor.visit_method_turbofish_mut(it) + }; + tokens_helper(_visitor, &mut (_i.paren_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.args) { + let it = el.value_mut(); + _visitor.visit_expr_mut(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_paren_mut(_visitor: &mut V, _i: &mut ExprParen) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + tokens_helper(_visitor, &mut (_i.paren_token).0); + _visitor.visit_expr_mut(&mut *_i.expr); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_path_mut(_visitor: &mut V, _i: &mut ExprPath) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + if let Some(ref mut it) = _i.qself { + _visitor.visit_qself_mut(it) + }; + _visitor.visit_path_mut(&mut _i.path); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_range_mut(_visitor: &mut V, _i: &mut ExprRange) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + if let Some(ref mut it) = _i.from { + _visitor.visit_expr_mut(&mut **it) + }; + _visitor.visit_range_limits_mut(&mut _i.limits); + if let Some(ref mut it) = _i.to { + _visitor.visit_expr_mut(&mut **it) + }; +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_reference_mut(_visitor: &mut V, _i: &mut ExprReference) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + tokens_helper(_visitor, &mut (_i.and_token).0); + if let Some(ref mut it) = _i.mutability { + tokens_helper(_visitor, &mut (it).0) + }; + _visitor.visit_expr_mut(&mut *_i.expr); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_repeat_mut(_visitor: &mut V, _i: &mut ExprRepeat) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + tokens_helper(_visitor, &mut (_i.bracket_token).0); + _visitor.visit_expr_mut(&mut *_i.expr); + tokens_helper(_visitor, &mut (_i.semi_token).0); + _visitor.visit_expr_mut(&mut *_i.len); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_return_mut(_visitor: &mut V, _i: &mut ExprReturn) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + tokens_helper(_visitor, &mut (_i.return_token).0); + if let Some(ref mut it) = _i.expr { + _visitor.visit_expr_mut(&mut **it) + }; +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_struct_mut(_visitor: &mut V, _i: &mut ExprStruct) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_path_mut(&mut _i.path); + tokens_helper(_visitor, &mut (_i.brace_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.fields) { + let it = el.value_mut(); + _visitor.visit_field_value_mut(it) + } + if let Some(ref mut it) = _i.dot2_token { + tokens_helper(_visitor, &mut (it).0) + }; + if let Some(ref mut it) = _i.rest { + _visitor.visit_expr_mut(&mut **it) + }; +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_try_mut(_visitor: &mut V, _i: &mut ExprTry) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_expr_mut(&mut *_i.expr); + tokens_helper(_visitor, &mut (_i.question_token).0); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_tuple_mut(_visitor: &mut V, _i: &mut ExprTuple) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + tokens_helper(_visitor, &mut (_i.paren_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.elems) { + let it = el.value_mut(); + _visitor.visit_expr_mut(it) + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_type_mut(_visitor: &mut V, _i: &mut ExprType) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_expr_mut(&mut *_i.expr); + tokens_helper(_visitor, &mut (_i.colon_token).0); + _visitor.visit_type_mut(&mut *_i.ty); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_unary_mut(_visitor: &mut V, _i: &mut ExprUnary) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_un_op_mut(&mut _i.op); + _visitor.visit_expr_mut(&mut *_i.expr); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_unsafe_mut(_visitor: &mut V, _i: &mut ExprUnsafe) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + tokens_helper(_visitor, &mut (_i.unsafe_token).0); + _visitor.visit_block_mut(&mut _i.block); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_verbatim_mut(_visitor: &mut V, _i: &mut ExprVerbatim) { + skip!(_i.tts); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_while_mut(_visitor: &mut V, _i: &mut ExprWhile) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + if let Some(ref mut it) = _i.label { + _visitor.visit_label_mut(it) + }; + tokens_helper(_visitor, &mut (_i.while_token).0); + _visitor.visit_expr_mut(&mut *_i.cond); + _visitor.visit_block_mut(&mut _i.body); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_while_let_mut(_visitor: &mut V, _i: &mut ExprWhileLet) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + if let Some(ref mut it) = _i.label { + _visitor.visit_label_mut(it) + }; + tokens_helper(_visitor, &mut (_i.while_token).0); + tokens_helper(_visitor, &mut (_i.let_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.pats) { + let it = el.value_mut(); + _visitor.visit_pat_mut(it) + } + tokens_helper(_visitor, &mut (_i.eq_token).0); + _visitor.visit_expr_mut(&mut *_i.expr); + _visitor.visit_block_mut(&mut _i.body); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_yield_mut(_visitor: &mut V, _i: &mut ExprYield) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + tokens_helper(_visitor, &mut (_i.yield_token).0); + if let Some(ref mut it) = _i.expr { + _visitor.visit_expr_mut(&mut **it) + }; +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_field_mut(_visitor: &mut V, _i: &mut Field) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_visibility_mut(&mut _i.vis); + if let Some(ref mut it) = _i.ident { + _visitor.visit_ident_mut(it) + }; + if let Some(ref mut it) = _i.colon_token { + tokens_helper(_visitor, &mut (it).0) + }; + _visitor.visit_type_mut(&mut _i.ty); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_field_pat_mut(_visitor: &mut V, _i: &mut FieldPat) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_member_mut(&mut _i.member); + if let Some(ref mut it) = _i.colon_token { + tokens_helper(_visitor, &mut (it).0) + }; + _visitor.visit_pat_mut(&mut *_i.pat); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_field_value_mut(_visitor: &mut V, _i: &mut FieldValue) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_member_mut(&mut _i.member); + if let Some(ref mut it) = _i.colon_token { + tokens_helper(_visitor, &mut (it).0) + }; + _visitor.visit_expr_mut(&mut _i.expr); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_fields_mut(_visitor: &mut V, _i: &mut Fields) { + match *_i { + Fields::Named(ref mut _binding_0) => { + _visitor.visit_fields_named_mut(_binding_0); + } + Fields::Unnamed(ref mut _binding_0) => { + _visitor.visit_fields_unnamed_mut(_binding_0); + } + Fields::Unit => {} + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_fields_named_mut(_visitor: &mut V, _i: &mut FieldsNamed) { + tokens_helper(_visitor, &mut (_i.brace_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.named) { + let it = el.value_mut(); + _visitor.visit_field_mut(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_fields_unnamed_mut(_visitor: &mut V, _i: &mut FieldsUnnamed) { + tokens_helper(_visitor, &mut (_i.paren_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.unnamed) { + let it = el.value_mut(); + _visitor.visit_field_mut(it) + } +} +#[cfg(feature = "full")] +pub fn visit_file_mut(_visitor: &mut V, _i: &mut File) { + skip!(_i.shebang); + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + for it in &mut _i.items { + _visitor.visit_item_mut(it) + } +} +#[cfg(feature = "full")] +pub fn visit_fn_arg_mut(_visitor: &mut V, _i: &mut FnArg) { + match *_i { + FnArg::SelfRef(ref mut _binding_0) => { + _visitor.visit_arg_self_ref_mut(_binding_0); + } + FnArg::SelfValue(ref mut _binding_0) => { + _visitor.visit_arg_self_mut(_binding_0); + } + FnArg::Captured(ref mut _binding_0) => { + _visitor.visit_arg_captured_mut(_binding_0); + } + FnArg::Inferred(ref mut _binding_0) => { + _visitor.visit_pat_mut(_binding_0); + } + FnArg::Ignored(ref mut _binding_0) => { + _visitor.visit_type_mut(_binding_0); + } + } +} +#[cfg(feature = "full")] +pub fn visit_fn_decl_mut(_visitor: &mut V, _i: &mut FnDecl) { + tokens_helper(_visitor, &mut (_i.fn_token).0); + _visitor.visit_generics_mut(&mut _i.generics); + tokens_helper(_visitor, &mut (_i.paren_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.inputs) { + let it = el.value_mut(); + _visitor.visit_fn_arg_mut(it) + } + if let Some(ref mut it) = _i.variadic { + tokens_helper(_visitor, &mut (it).0) + }; + _visitor.visit_return_type_mut(&mut _i.output); +} +#[cfg(feature = "full")] +pub fn visit_foreign_item_mut(_visitor: &mut V, _i: &mut ForeignItem) { + match *_i { + ForeignItem::Fn(ref mut _binding_0) => { + _visitor.visit_foreign_item_fn_mut(_binding_0); + } + ForeignItem::Static(ref mut _binding_0) => { + _visitor.visit_foreign_item_static_mut(_binding_0); + } + ForeignItem::Type(ref mut _binding_0) => { + _visitor.visit_foreign_item_type_mut(_binding_0); + } + ForeignItem::Verbatim(ref mut _binding_0) => { + _visitor.visit_foreign_item_verbatim_mut(_binding_0); + } + } +} +#[cfg(feature = "full")] +pub fn visit_foreign_item_fn_mut(_visitor: &mut V, _i: &mut ForeignItemFn) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_visibility_mut(&mut _i.vis); + _visitor.visit_ident_mut(&mut _i.ident); + _visitor.visit_fn_decl_mut(&mut *_i.decl); + tokens_helper(_visitor, &mut (_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_foreign_item_static_mut( + _visitor: &mut V, + _i: &mut ForeignItemStatic, +) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_visibility_mut(&mut _i.vis); + tokens_helper(_visitor, &mut (_i.static_token).0); + if let Some(ref mut it) = _i.mutability { + tokens_helper(_visitor, &mut (it).0) + }; + _visitor.visit_ident_mut(&mut _i.ident); + tokens_helper(_visitor, &mut (_i.colon_token).0); + _visitor.visit_type_mut(&mut *_i.ty); + tokens_helper(_visitor, &mut (_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_foreign_item_type_mut( + _visitor: &mut V, + _i: &mut ForeignItemType, +) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_visibility_mut(&mut _i.vis); + tokens_helper(_visitor, &mut (_i.type_token).0); + _visitor.visit_ident_mut(&mut _i.ident); + tokens_helper(_visitor, &mut (_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_foreign_item_verbatim_mut( + _visitor: &mut V, + _i: &mut ForeignItemVerbatim, +) { + skip!(_i.tts); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_generic_argument_mut( + _visitor: &mut V, + _i: &mut GenericArgument, +) { + match *_i { + GenericArgument::Lifetime(ref mut _binding_0) => { + _visitor.visit_lifetime_mut(_binding_0); + } + GenericArgument::Type(ref mut _binding_0) => { + _visitor.visit_type_mut(_binding_0); + } + GenericArgument::Binding(ref mut _binding_0) => { + _visitor.visit_binding_mut(_binding_0); + } + GenericArgument::Const(ref mut _binding_0) => { + _visitor.visit_expr_mut(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_generic_method_argument_mut( + _visitor: &mut V, + _i: &mut GenericMethodArgument, +) { + match *_i { + GenericMethodArgument::Type(ref mut _binding_0) => { + _visitor.visit_type_mut(_binding_0); + } + GenericMethodArgument::Const(ref mut _binding_0) => { + _visitor.visit_expr_mut(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_generic_param_mut(_visitor: &mut V, _i: &mut GenericParam) { + match *_i { + GenericParam::Type(ref mut _binding_0) => { + _visitor.visit_type_param_mut(_binding_0); + } + GenericParam::Lifetime(ref mut _binding_0) => { + _visitor.visit_lifetime_def_mut(_binding_0); + } + GenericParam::Const(ref mut _binding_0) => { + _visitor.visit_const_param_mut(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_generics_mut(_visitor: &mut V, _i: &mut Generics) { + if let Some(ref mut it) = _i.lt_token { + tokens_helper(_visitor, &mut (it).0) + }; + for mut el in Punctuated::pairs_mut(&mut _i.params) { + let it = el.value_mut(); + _visitor.visit_generic_param_mut(it) + } + if let Some(ref mut it) = _i.gt_token { + tokens_helper(_visitor, &mut (it).0) + }; + if let Some(ref mut it) = _i.where_clause { + _visitor.visit_where_clause_mut(it) + }; +} +pub fn visit_ident_mut(_visitor: &mut V, _i: &mut Ident) {} +#[cfg(feature = "full")] +pub fn visit_impl_item_mut(_visitor: &mut V, _i: &mut ImplItem) { + match *_i { + ImplItem::Const(ref mut _binding_0) => { + _visitor.visit_impl_item_const_mut(_binding_0); + } + ImplItem::Method(ref mut _binding_0) => { + _visitor.visit_impl_item_method_mut(_binding_0); + } + ImplItem::Type(ref mut _binding_0) => { + _visitor.visit_impl_item_type_mut(_binding_0); + } + ImplItem::Macro(ref mut _binding_0) => { + _visitor.visit_impl_item_macro_mut(_binding_0); + } + ImplItem::Verbatim(ref mut _binding_0) => { + _visitor.visit_impl_item_verbatim_mut(_binding_0); + } + } +} +#[cfg(feature = "full")] +pub fn visit_impl_item_const_mut(_visitor: &mut V, _i: &mut ImplItemConst) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_visibility_mut(&mut _i.vis); + if let Some(ref mut it) = _i.defaultness { + tokens_helper(_visitor, &mut (it).0) + }; + tokens_helper(_visitor, &mut (_i.const_token).0); + _visitor.visit_ident_mut(&mut _i.ident); + tokens_helper(_visitor, &mut (_i.colon_token).0); + _visitor.visit_type_mut(&mut _i.ty); + tokens_helper(_visitor, &mut (_i.eq_token).0); + _visitor.visit_expr_mut(&mut _i.expr); + tokens_helper(_visitor, &mut (_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_impl_item_macro_mut(_visitor: &mut V, _i: &mut ImplItemMacro) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_macro_mut(&mut _i.mac); + if let Some(ref mut it) = _i.semi_token { + tokens_helper(_visitor, &mut (it).0) + }; +} +#[cfg(feature = "full")] +pub fn visit_impl_item_method_mut(_visitor: &mut V, _i: &mut ImplItemMethod) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_visibility_mut(&mut _i.vis); + if let Some(ref mut it) = _i.defaultness { + tokens_helper(_visitor, &mut (it).0) + }; + _visitor.visit_method_sig_mut(&mut _i.sig); + _visitor.visit_block_mut(&mut _i.block); +} +#[cfg(feature = "full")] +pub fn visit_impl_item_type_mut(_visitor: &mut V, _i: &mut ImplItemType) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_visibility_mut(&mut _i.vis); + if let Some(ref mut it) = _i.defaultness { + tokens_helper(_visitor, &mut (it).0) + }; + tokens_helper(_visitor, &mut (_i.type_token).0); + _visitor.visit_ident_mut(&mut _i.ident); + _visitor.visit_generics_mut(&mut _i.generics); + tokens_helper(_visitor, &mut (_i.eq_token).0); + _visitor.visit_type_mut(&mut _i.ty); + tokens_helper(_visitor, &mut (_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_impl_item_verbatim_mut( + _visitor: &mut V, + _i: &mut ImplItemVerbatim, +) { + skip!(_i.tts); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_index_mut(_visitor: &mut V, _i: &mut Index) { + skip!(_i.index); + _visitor.visit_span_mut(&mut _i.span); +} +#[cfg(feature = "full")] +pub fn visit_item_mut(_visitor: &mut V, _i: &mut Item) { + match *_i { + Item::ExternCrate(ref mut _binding_0) => { + _visitor.visit_item_extern_crate_mut(_binding_0); + } + Item::Use(ref mut _binding_0) => { + _visitor.visit_item_use_mut(_binding_0); + } + Item::Static(ref mut _binding_0) => { + _visitor.visit_item_static_mut(_binding_0); + } + Item::Const(ref mut _binding_0) => { + _visitor.visit_item_const_mut(_binding_0); + } + Item::Fn(ref mut _binding_0) => { + _visitor.visit_item_fn_mut(_binding_0); + } + Item::Mod(ref mut _binding_0) => { + _visitor.visit_item_mod_mut(_binding_0); + } + Item::ForeignMod(ref mut _binding_0) => { + _visitor.visit_item_foreign_mod_mut(_binding_0); + } + Item::Type(ref mut _binding_0) => { + _visitor.visit_item_type_mut(_binding_0); + } + Item::Struct(ref mut _binding_0) => { + _visitor.visit_item_struct_mut(_binding_0); + } + Item::Enum(ref mut _binding_0) => { + _visitor.visit_item_enum_mut(_binding_0); + } + Item::Union(ref mut _binding_0) => { + _visitor.visit_item_union_mut(_binding_0); + } + Item::Trait(ref mut _binding_0) => { + _visitor.visit_item_trait_mut(_binding_0); + } + Item::Impl(ref mut _binding_0) => { + _visitor.visit_item_impl_mut(_binding_0); + } + Item::Macro(ref mut _binding_0) => { + _visitor.visit_item_macro_mut(_binding_0); + } + Item::Macro2(ref mut _binding_0) => { + _visitor.visit_item_macro2_mut(_binding_0); + } + Item::Verbatim(ref mut _binding_0) => { + _visitor.visit_item_verbatim_mut(_binding_0); + } + } +} +#[cfg(feature = "full")] +pub fn visit_item_const_mut(_visitor: &mut V, _i: &mut ItemConst) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_visibility_mut(&mut _i.vis); + tokens_helper(_visitor, &mut (_i.const_token).0); + _visitor.visit_ident_mut(&mut _i.ident); + tokens_helper(_visitor, &mut (_i.colon_token).0); + _visitor.visit_type_mut(&mut *_i.ty); + tokens_helper(_visitor, &mut (_i.eq_token).0); + _visitor.visit_expr_mut(&mut *_i.expr); + tokens_helper(_visitor, &mut (_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_item_enum_mut(_visitor: &mut V, _i: &mut ItemEnum) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_visibility_mut(&mut _i.vis); + tokens_helper(_visitor, &mut (_i.enum_token).0); + _visitor.visit_ident_mut(&mut _i.ident); + _visitor.visit_generics_mut(&mut _i.generics); + tokens_helper(_visitor, &mut (_i.brace_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.variants) { + let it = el.value_mut(); + _visitor.visit_variant_mut(it) + } +} +#[cfg(feature = "full")] +pub fn visit_item_extern_crate_mut( + _visitor: &mut V, + _i: &mut ItemExternCrate, +) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_visibility_mut(&mut _i.vis); + tokens_helper(_visitor, &mut (_i.extern_token).0); + tokens_helper(_visitor, &mut (_i.crate_token).0); + _visitor.visit_ident_mut(&mut _i.ident); + if let Some(ref mut it) = _i.rename { + tokens_helper(_visitor, &mut ((it).0).0); + _visitor.visit_ident_mut(&mut (it).1); + }; + tokens_helper(_visitor, &mut (_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_item_fn_mut(_visitor: &mut V, _i: &mut ItemFn) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_visibility_mut(&mut _i.vis); + if let Some(ref mut it) = _i.constness { + tokens_helper(_visitor, &mut (it).0) + }; + if let Some(ref mut it) = _i.unsafety { + tokens_helper(_visitor, &mut (it).0) + }; + if let Some(ref mut it) = _i.abi { + _visitor.visit_abi_mut(it) + }; + _visitor.visit_ident_mut(&mut _i.ident); + _visitor.visit_fn_decl_mut(&mut *_i.decl); + _visitor.visit_block_mut(&mut *_i.block); +} +#[cfg(feature = "full")] +pub fn visit_item_foreign_mod_mut(_visitor: &mut V, _i: &mut ItemForeignMod) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_abi_mut(&mut _i.abi); + tokens_helper(_visitor, &mut (_i.brace_token).0); + for it in &mut _i.items { + _visitor.visit_foreign_item_mut(it) + } +} +#[cfg(feature = "full")] +pub fn visit_item_impl_mut(_visitor: &mut V, _i: &mut ItemImpl) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + if let Some(ref mut it) = _i.defaultness { + tokens_helper(_visitor, &mut (it).0) + }; + if let Some(ref mut it) = _i.unsafety { + tokens_helper(_visitor, &mut (it).0) + }; + tokens_helper(_visitor, &mut (_i.impl_token).0); + _visitor.visit_generics_mut(&mut _i.generics); + if let Some(ref mut it) = _i.trait_ { + if let Some(ref mut it) = (it).0 { + tokens_helper(_visitor, &mut (it).0) + }; + _visitor.visit_path_mut(&mut (it).1); + tokens_helper(_visitor, &mut ((it).2).0); + }; + _visitor.visit_type_mut(&mut *_i.self_ty); + tokens_helper(_visitor, &mut (_i.brace_token).0); + for it in &mut _i.items { + _visitor.visit_impl_item_mut(it) + } +} +#[cfg(feature = "full")] +pub fn visit_item_macro_mut(_visitor: &mut V, _i: &mut ItemMacro) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + if let Some(ref mut it) = _i.ident { + _visitor.visit_ident_mut(it) + }; + _visitor.visit_macro_mut(&mut _i.mac); + if let Some(ref mut it) = _i.semi_token { + tokens_helper(_visitor, &mut (it).0) + }; +} +#[cfg(feature = "full")] +pub fn visit_item_macro2_mut(_visitor: &mut V, _i: &mut ItemMacro2) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_visibility_mut(&mut _i.vis); + tokens_helper(_visitor, &mut (_i.macro_token).0); + _visitor.visit_ident_mut(&mut _i.ident); + tokens_helper(_visitor, &mut (_i.paren_token).0); + skip!(_i.args); + tokens_helper(_visitor, &mut (_i.brace_token).0); + skip!(_i.body); +} +#[cfg(feature = "full")] +pub fn visit_item_mod_mut(_visitor: &mut V, _i: &mut ItemMod) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_visibility_mut(&mut _i.vis); + tokens_helper(_visitor, &mut (_i.mod_token).0); + _visitor.visit_ident_mut(&mut _i.ident); + if let Some(ref mut it) = _i.content { + tokens_helper(_visitor, &mut ((it).0).0); + for it in &mut (it).1 { + _visitor.visit_item_mut(it) + } + }; + if let Some(ref mut it) = _i.semi { + tokens_helper(_visitor, &mut (it).0) + }; +} +#[cfg(feature = "full")] +pub fn visit_item_static_mut(_visitor: &mut V, _i: &mut ItemStatic) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_visibility_mut(&mut _i.vis); + tokens_helper(_visitor, &mut (_i.static_token).0); + if let Some(ref mut it) = _i.mutability { + tokens_helper(_visitor, &mut (it).0) + }; + _visitor.visit_ident_mut(&mut _i.ident); + tokens_helper(_visitor, &mut (_i.colon_token).0); + _visitor.visit_type_mut(&mut *_i.ty); + tokens_helper(_visitor, &mut (_i.eq_token).0); + _visitor.visit_expr_mut(&mut *_i.expr); + tokens_helper(_visitor, &mut (_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_item_struct_mut(_visitor: &mut V, _i: &mut ItemStruct) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_visibility_mut(&mut _i.vis); + tokens_helper(_visitor, &mut (_i.struct_token).0); + _visitor.visit_ident_mut(&mut _i.ident); + _visitor.visit_generics_mut(&mut _i.generics); + _visitor.visit_fields_mut(&mut _i.fields); + if let Some(ref mut it) = _i.semi_token { + tokens_helper(_visitor, &mut (it).0) + }; +} +#[cfg(feature = "full")] +pub fn visit_item_trait_mut(_visitor: &mut V, _i: &mut ItemTrait) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_visibility_mut(&mut _i.vis); + if let Some(ref mut it) = _i.unsafety { + tokens_helper(_visitor, &mut (it).0) + }; + if let Some(ref mut it) = _i.auto_token { + tokens_helper(_visitor, &mut (it).0) + }; + tokens_helper(_visitor, &mut (_i.trait_token).0); + _visitor.visit_ident_mut(&mut _i.ident); + _visitor.visit_generics_mut(&mut _i.generics); + if let Some(ref mut it) = _i.colon_token { + tokens_helper(_visitor, &mut (it).0) + }; + for mut el in Punctuated::pairs_mut(&mut _i.supertraits) { + let it = el.value_mut(); + _visitor.visit_type_param_bound_mut(it) + } + tokens_helper(_visitor, &mut (_i.brace_token).0); + for it in &mut _i.items { + _visitor.visit_trait_item_mut(it) + } +} +#[cfg(feature = "full")] +pub fn visit_item_type_mut(_visitor: &mut V, _i: &mut ItemType) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_visibility_mut(&mut _i.vis); + tokens_helper(_visitor, &mut (_i.type_token).0); + _visitor.visit_ident_mut(&mut _i.ident); + _visitor.visit_generics_mut(&mut _i.generics); + tokens_helper(_visitor, &mut (_i.eq_token).0); + _visitor.visit_type_mut(&mut *_i.ty); + tokens_helper(_visitor, &mut (_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_item_union_mut(_visitor: &mut V, _i: &mut ItemUnion) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_visibility_mut(&mut _i.vis); + tokens_helper(_visitor, &mut (_i.union_token).0); + _visitor.visit_ident_mut(&mut _i.ident); + _visitor.visit_generics_mut(&mut _i.generics); + _visitor.visit_fields_named_mut(&mut _i.fields); +} +#[cfg(feature = "full")] +pub fn visit_item_use_mut(_visitor: &mut V, _i: &mut ItemUse) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_visibility_mut(&mut _i.vis); + tokens_helper(_visitor, &mut (_i.use_token).0); + if let Some(ref mut it) = _i.leading_colon { + tokens_helper(_visitor, &mut (it).0) + }; + _visitor.visit_use_tree_mut(&mut _i.tree); + tokens_helper(_visitor, &mut (_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_item_verbatim_mut(_visitor: &mut V, _i: &mut ItemVerbatim) { + skip!(_i.tts); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_label_mut(_visitor: &mut V, _i: &mut Label) { + _visitor.visit_lifetime_mut(&mut _i.name); + tokens_helper(_visitor, &mut (_i.colon_token).0); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_lifetime_mut(_visitor: &mut V, _i: &mut Lifetime) { + skip!(_i.apostrophe); + _visitor.visit_ident_mut(&mut _i.ident); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_lifetime_def_mut(_visitor: &mut V, _i: &mut LifetimeDef) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_lifetime_mut(&mut _i.lifetime); + if let Some(ref mut it) = _i.colon_token { + tokens_helper(_visitor, &mut (it).0) + }; + for mut el in Punctuated::pairs_mut(&mut _i.bounds) { + let it = el.value_mut(); + _visitor.visit_lifetime_mut(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_lit_mut(_visitor: &mut V, _i: &mut Lit) { + match *_i { + Lit::Str(ref mut _binding_0) => { + _visitor.visit_lit_str_mut(_binding_0); + } + Lit::ByteStr(ref mut _binding_0) => { + _visitor.visit_lit_byte_str_mut(_binding_0); + } + Lit::Byte(ref mut _binding_0) => { + _visitor.visit_lit_byte_mut(_binding_0); + } + Lit::Char(ref mut _binding_0) => { + _visitor.visit_lit_char_mut(_binding_0); + } + Lit::Int(ref mut _binding_0) => { + _visitor.visit_lit_int_mut(_binding_0); + } + Lit::Float(ref mut _binding_0) => { + _visitor.visit_lit_float_mut(_binding_0); + } + Lit::Bool(ref mut _binding_0) => { + _visitor.visit_lit_bool_mut(_binding_0); + } + Lit::Verbatim(ref mut _binding_0) => { + _visitor.visit_lit_verbatim_mut(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_lit_bool_mut(_visitor: &mut V, _i: &mut LitBool) { + skip!(_i.value); + _visitor.visit_span_mut(&mut _i.span); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_lit_byte_mut(_visitor: &mut V, _i: &mut LitByte) { + skip!(_i.token); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_lit_byte_str_mut(_visitor: &mut V, _i: &mut LitByteStr) { + skip!(_i.token); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_lit_char_mut(_visitor: &mut V, _i: &mut LitChar) { + skip!(_i.token); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_lit_float_mut(_visitor: &mut V, _i: &mut LitFloat) { + skip!(_i.token); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_lit_int_mut(_visitor: &mut V, _i: &mut LitInt) { + skip!(_i.token); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_lit_str_mut(_visitor: &mut V, _i: &mut LitStr) { + skip!(_i.token); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_lit_verbatim_mut(_visitor: &mut V, _i: &mut LitVerbatim) { + skip!(_i.token); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_local_mut(_visitor: &mut V, _i: &mut Local) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + tokens_helper(_visitor, &mut (_i.let_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.pats) { + let it = el.value_mut(); + _visitor.visit_pat_mut(it) + } + if let Some(ref mut it) = _i.ty { + tokens_helper(_visitor, &mut ((it).0).0); + _visitor.visit_type_mut(&mut *(it).1); + }; + if let Some(ref mut it) = _i.init { + tokens_helper(_visitor, &mut ((it).0).0); + _visitor.visit_expr_mut(&mut *(it).1); + }; + tokens_helper(_visitor, &mut (_i.semi_token).0); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_macro_mut(_visitor: &mut V, _i: &mut Macro) { + _visitor.visit_path_mut(&mut _i.path); + tokens_helper(_visitor, &mut (_i.bang_token).0); + _visitor.visit_macro_delimiter_mut(&mut _i.delimiter); + skip!(_i.tts); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_macro_delimiter_mut(_visitor: &mut V, _i: &mut MacroDelimiter) { + match *_i { + MacroDelimiter::Paren(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + MacroDelimiter::Brace(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + MacroDelimiter::Bracket(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_member_mut(_visitor: &mut V, _i: &mut Member) { + match *_i { + Member::Named(ref mut _binding_0) => { + _visitor.visit_ident_mut(_binding_0); + } + Member::Unnamed(ref mut _binding_0) => { + _visitor.visit_index_mut(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_meta_mut(_visitor: &mut V, _i: &mut Meta) { + match *_i { + Meta::Word(ref mut _binding_0) => { + _visitor.visit_ident_mut(_binding_0); + } + Meta::List(ref mut _binding_0) => { + _visitor.visit_meta_list_mut(_binding_0); + } + Meta::NameValue(ref mut _binding_0) => { + _visitor.visit_meta_name_value_mut(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_meta_list_mut(_visitor: &mut V, _i: &mut MetaList) { + _visitor.visit_ident_mut(&mut _i.ident); + tokens_helper(_visitor, &mut (_i.paren_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.nested) { + let it = el.value_mut(); + _visitor.visit_nested_meta_mut(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_meta_name_value_mut(_visitor: &mut V, _i: &mut MetaNameValue) { + _visitor.visit_ident_mut(&mut _i.ident); + tokens_helper(_visitor, &mut (_i.eq_token).0); + _visitor.visit_lit_mut(&mut _i.lit); +} +#[cfg(feature = "full")] +pub fn visit_method_sig_mut(_visitor: &mut V, _i: &mut MethodSig) { + if let Some(ref mut it) = _i.constness { + tokens_helper(_visitor, &mut (it).0) + }; + if let Some(ref mut it) = _i.unsafety { + tokens_helper(_visitor, &mut (it).0) + }; + if let Some(ref mut it) = _i.abi { + _visitor.visit_abi_mut(it) + }; + _visitor.visit_ident_mut(&mut _i.ident); + _visitor.visit_fn_decl_mut(&mut _i.decl); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_method_turbofish_mut( + _visitor: &mut V, + _i: &mut MethodTurbofish, +) { + tokens_helper(_visitor, &mut (_i.colon2_token).0); + tokens_helper(_visitor, &mut (_i.lt_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.args) { + let it = el.value_mut(); + _visitor.visit_generic_method_argument_mut(it) + } + tokens_helper(_visitor, &mut (_i.gt_token).0); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_nested_meta_mut(_visitor: &mut V, _i: &mut NestedMeta) { + match *_i { + NestedMeta::Meta(ref mut _binding_0) => { + _visitor.visit_meta_mut(_binding_0); + } + NestedMeta::Literal(ref mut _binding_0) => { + _visitor.visit_lit_mut(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_parenthesized_generic_arguments_mut( + _visitor: &mut V, + _i: &mut ParenthesizedGenericArguments, +) { + tokens_helper(_visitor, &mut (_i.paren_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.inputs) { + let it = el.value_mut(); + _visitor.visit_type_mut(it) + } + _visitor.visit_return_type_mut(&mut _i.output); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_mut(_visitor: &mut V, _i: &mut Pat) { + match *_i { + Pat::Wild(ref mut _binding_0) => { + _visitor.visit_pat_wild_mut(_binding_0); + } + Pat::Ident(ref mut _binding_0) => { + _visitor.visit_pat_ident_mut(_binding_0); + } + Pat::Struct(ref mut _binding_0) => { + _visitor.visit_pat_struct_mut(_binding_0); + } + Pat::TupleStruct(ref mut _binding_0) => { + _visitor.visit_pat_tuple_struct_mut(_binding_0); + } + Pat::Path(ref mut _binding_0) => { + _visitor.visit_pat_path_mut(_binding_0); + } + Pat::Tuple(ref mut _binding_0) => { + _visitor.visit_pat_tuple_mut(_binding_0); + } + Pat::Box(ref mut _binding_0) => { + _visitor.visit_pat_box_mut(_binding_0); + } + Pat::Ref(ref mut _binding_0) => { + _visitor.visit_pat_ref_mut(_binding_0); + } + Pat::Lit(ref mut _binding_0) => { + _visitor.visit_pat_lit_mut(_binding_0); + } + Pat::Range(ref mut _binding_0) => { + _visitor.visit_pat_range_mut(_binding_0); + } + Pat::Slice(ref mut _binding_0) => { + _visitor.visit_pat_slice_mut(_binding_0); + } + Pat::Macro(ref mut _binding_0) => { + _visitor.visit_pat_macro_mut(_binding_0); + } + Pat::Verbatim(ref mut _binding_0) => { + _visitor.visit_pat_verbatim_mut(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_box_mut(_visitor: &mut V, _i: &mut PatBox) { + tokens_helper(_visitor, &mut (_i.box_token).0); + _visitor.visit_pat_mut(&mut *_i.pat); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_ident_mut(_visitor: &mut V, _i: &mut PatIdent) { + if let Some(ref mut it) = _i.by_ref { + tokens_helper(_visitor, &mut (it).0) + }; + if let Some(ref mut it) = _i.mutability { + tokens_helper(_visitor, &mut (it).0) + }; + _visitor.visit_ident_mut(&mut _i.ident); + if let Some(ref mut it) = _i.subpat { + tokens_helper(_visitor, &mut ((it).0).0); + _visitor.visit_pat_mut(&mut *(it).1); + }; +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_lit_mut(_visitor: &mut V, _i: &mut PatLit) { + _visitor.visit_expr_mut(&mut *_i.expr); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_macro_mut(_visitor: &mut V, _i: &mut PatMacro) { + _visitor.visit_macro_mut(&mut _i.mac); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_path_mut(_visitor: &mut V, _i: &mut PatPath) { + if let Some(ref mut it) = _i.qself { + _visitor.visit_qself_mut(it) + }; + _visitor.visit_path_mut(&mut _i.path); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_range_mut(_visitor: &mut V, _i: &mut PatRange) { + _visitor.visit_expr_mut(&mut *_i.lo); + _visitor.visit_range_limits_mut(&mut _i.limits); + _visitor.visit_expr_mut(&mut *_i.hi); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_ref_mut(_visitor: &mut V, _i: &mut PatRef) { + tokens_helper(_visitor, &mut (_i.and_token).0); + if let Some(ref mut it) = _i.mutability { + tokens_helper(_visitor, &mut (it).0) + }; + _visitor.visit_pat_mut(&mut *_i.pat); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_slice_mut(_visitor: &mut V, _i: &mut PatSlice) { + tokens_helper(_visitor, &mut (_i.bracket_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.front) { + let it = el.value_mut(); + _visitor.visit_pat_mut(it) + } + if let Some(ref mut it) = _i.middle { + _visitor.visit_pat_mut(&mut **it) + }; + if let Some(ref mut it) = _i.dot2_token { + tokens_helper(_visitor, &mut (it).0) + }; + if let Some(ref mut it) = _i.comma_token { + tokens_helper(_visitor, &mut (it).0) + }; + for mut el in Punctuated::pairs_mut(&mut _i.back) { + let it = el.value_mut(); + _visitor.visit_pat_mut(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_struct_mut(_visitor: &mut V, _i: &mut PatStruct) { + _visitor.visit_path_mut(&mut _i.path); + tokens_helper(_visitor, &mut (_i.brace_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.fields) { + let it = el.value_mut(); + _visitor.visit_field_pat_mut(it) + } + if let Some(ref mut it) = _i.dot2_token { + tokens_helper(_visitor, &mut (it).0) + }; +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_tuple_mut(_visitor: &mut V, _i: &mut PatTuple) { + tokens_helper(_visitor, &mut (_i.paren_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.front) { + let it = el.value_mut(); + _visitor.visit_pat_mut(it) + } + if let Some(ref mut it) = _i.dot2_token { + tokens_helper(_visitor, &mut (it).0) + }; + if let Some(ref mut it) = _i.comma_token { + tokens_helper(_visitor, &mut (it).0) + }; + for mut el in Punctuated::pairs_mut(&mut _i.back) { + let it = el.value_mut(); + _visitor.visit_pat_mut(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_tuple_struct_mut(_visitor: &mut V, _i: &mut PatTupleStruct) { + _visitor.visit_path_mut(&mut _i.path); + _visitor.visit_pat_tuple_mut(&mut _i.pat); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_verbatim_mut(_visitor: &mut V, _i: &mut PatVerbatim) { + skip!(_i.tts); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_wild_mut(_visitor: &mut V, _i: &mut PatWild) { + tokens_helper(_visitor, &mut (_i.underscore_token).0); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_path_mut(_visitor: &mut V, _i: &mut Path) { + if let Some(ref mut it) = _i.leading_colon { + tokens_helper(_visitor, &mut (it).0) + }; + for mut el in Punctuated::pairs_mut(&mut _i.segments) { + let it = el.value_mut(); + _visitor.visit_path_segment_mut(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_path_arguments_mut(_visitor: &mut V, _i: &mut PathArguments) { + match *_i { + PathArguments::None => {} + PathArguments::AngleBracketed(ref mut _binding_0) => { + _visitor.visit_angle_bracketed_generic_arguments_mut(_binding_0); + } + PathArguments::Parenthesized(ref mut _binding_0) => { + _visitor.visit_parenthesized_generic_arguments_mut(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_path_segment_mut(_visitor: &mut V, _i: &mut PathSegment) { + _visitor.visit_ident_mut(&mut _i.ident); + _visitor.visit_path_arguments_mut(&mut _i.arguments); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_predicate_eq_mut(_visitor: &mut V, _i: &mut PredicateEq) { + _visitor.visit_type_mut(&mut _i.lhs_ty); + tokens_helper(_visitor, &mut (_i.eq_token).0); + _visitor.visit_type_mut(&mut _i.rhs_ty); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_predicate_lifetime_mut( + _visitor: &mut V, + _i: &mut PredicateLifetime, +) { + _visitor.visit_lifetime_mut(&mut _i.lifetime); + if let Some(ref mut it) = _i.colon_token { + tokens_helper(_visitor, &mut (it).0) + }; + for mut el in Punctuated::pairs_mut(&mut _i.bounds) { + let it = el.value_mut(); + _visitor.visit_lifetime_mut(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_predicate_type_mut(_visitor: &mut V, _i: &mut PredicateType) { + if let Some(ref mut it) = _i.lifetimes { + _visitor.visit_bound_lifetimes_mut(it) + }; + _visitor.visit_type_mut(&mut _i.bounded_ty); + tokens_helper(_visitor, &mut (_i.colon_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.bounds) { + let it = el.value_mut(); + _visitor.visit_type_param_bound_mut(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_qself_mut(_visitor: &mut V, _i: &mut QSelf) { + tokens_helper(_visitor, &mut (_i.lt_token).0); + _visitor.visit_type_mut(&mut *_i.ty); + skip!(_i.position); + if let Some(ref mut it) = _i.as_token { + tokens_helper(_visitor, &mut (it).0) + }; + tokens_helper(_visitor, &mut (_i.gt_token).0); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_range_limits_mut(_visitor: &mut V, _i: &mut RangeLimits) { + match *_i { + RangeLimits::HalfOpen(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + RangeLimits::Closed(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_return_type_mut(_visitor: &mut V, _i: &mut ReturnType) { + match *_i { + ReturnType::Default => {} + ReturnType::Type(ref mut _binding_0, ref mut _binding_1) => { + tokens_helper(_visitor, &mut (_binding_0).0); + _visitor.visit_type_mut(&mut **_binding_1); + } + } +} +pub fn visit_span_mut(_visitor: &mut V, _i: &mut Span) {} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_stmt_mut(_visitor: &mut V, _i: &mut Stmt) { + match *_i { + Stmt::Local(ref mut _binding_0) => { + _visitor.visit_local_mut(_binding_0); + } + Stmt::Item(ref mut _binding_0) => { + _visitor.visit_item_mut(_binding_0); + } + Stmt::Expr(ref mut _binding_0) => { + _visitor.visit_expr_mut(_binding_0); + } + Stmt::Semi(ref mut _binding_0, ref mut _binding_1) => { + _visitor.visit_expr_mut(_binding_0); + tokens_helper(_visitor, &mut (_binding_1).0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_trait_bound_mut(_visitor: &mut V, _i: &mut TraitBound) { + if let Some(ref mut it) = _i.paren_token { + tokens_helper(_visitor, &mut (it).0) + }; + _visitor.visit_trait_bound_modifier_mut(&mut _i.modifier); + if let Some(ref mut it) = _i.lifetimes { + _visitor.visit_bound_lifetimes_mut(it) + }; + _visitor.visit_path_mut(&mut _i.path); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_trait_bound_modifier_mut( + _visitor: &mut V, + _i: &mut TraitBoundModifier, +) { + match *_i { + TraitBoundModifier::None => {} + TraitBoundModifier::Maybe(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + } +} +#[cfg(feature = "full")] +pub fn visit_trait_item_mut(_visitor: &mut V, _i: &mut TraitItem) { + match *_i { + TraitItem::Const(ref mut _binding_0) => { + _visitor.visit_trait_item_const_mut(_binding_0); + } + TraitItem::Method(ref mut _binding_0) => { + _visitor.visit_trait_item_method_mut(_binding_0); + } + TraitItem::Type(ref mut _binding_0) => { + _visitor.visit_trait_item_type_mut(_binding_0); + } + TraitItem::Macro(ref mut _binding_0) => { + _visitor.visit_trait_item_macro_mut(_binding_0); + } + TraitItem::Verbatim(ref mut _binding_0) => { + _visitor.visit_trait_item_verbatim_mut(_binding_0); + } + } +} +#[cfg(feature = "full")] +pub fn visit_trait_item_const_mut(_visitor: &mut V, _i: &mut TraitItemConst) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + tokens_helper(_visitor, &mut (_i.const_token).0); + _visitor.visit_ident_mut(&mut _i.ident); + tokens_helper(_visitor, &mut (_i.colon_token).0); + _visitor.visit_type_mut(&mut _i.ty); + if let Some(ref mut it) = _i.default { + tokens_helper(_visitor, &mut ((it).0).0); + _visitor.visit_expr_mut(&mut (it).1); + }; + tokens_helper(_visitor, &mut (_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_trait_item_macro_mut(_visitor: &mut V, _i: &mut TraitItemMacro) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_macro_mut(&mut _i.mac); + if let Some(ref mut it) = _i.semi_token { + tokens_helper(_visitor, &mut (it).0) + }; +} +#[cfg(feature = "full")] +pub fn visit_trait_item_method_mut( + _visitor: &mut V, + _i: &mut TraitItemMethod, +) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_method_sig_mut(&mut _i.sig); + if let Some(ref mut it) = _i.default { + _visitor.visit_block_mut(it) + }; + if let Some(ref mut it) = _i.semi_token { + tokens_helper(_visitor, &mut (it).0) + }; +} +#[cfg(feature = "full")] +pub fn visit_trait_item_type_mut(_visitor: &mut V, _i: &mut TraitItemType) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + tokens_helper(_visitor, &mut (_i.type_token).0); + _visitor.visit_ident_mut(&mut _i.ident); + _visitor.visit_generics_mut(&mut _i.generics); + if let Some(ref mut it) = _i.colon_token { + tokens_helper(_visitor, &mut (it).0) + }; + for mut el in Punctuated::pairs_mut(&mut _i.bounds) { + let it = el.value_mut(); + _visitor.visit_type_param_bound_mut(it) + } + if let Some(ref mut it) = _i.default { + tokens_helper(_visitor, &mut ((it).0).0); + _visitor.visit_type_mut(&mut (it).1); + }; + tokens_helper(_visitor, &mut (_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_trait_item_verbatim_mut( + _visitor: &mut V, + _i: &mut TraitItemVerbatim, +) { + skip!(_i.tts); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_mut(_visitor: &mut V, _i: &mut Type) { + match *_i { + Type::Slice(ref mut _binding_0) => { + _visitor.visit_type_slice_mut(_binding_0); + } + Type::Array(ref mut _binding_0) => { + _visitor.visit_type_array_mut(_binding_0); + } + Type::Ptr(ref mut _binding_0) => { + _visitor.visit_type_ptr_mut(_binding_0); + } + Type::Reference(ref mut _binding_0) => { + _visitor.visit_type_reference_mut(_binding_0); + } + Type::BareFn(ref mut _binding_0) => { + _visitor.visit_type_bare_fn_mut(_binding_0); + } + Type::Never(ref mut _binding_0) => { + _visitor.visit_type_never_mut(_binding_0); + } + Type::Tuple(ref mut _binding_0) => { + _visitor.visit_type_tuple_mut(_binding_0); + } + Type::Path(ref mut _binding_0) => { + _visitor.visit_type_path_mut(_binding_0); + } + Type::TraitObject(ref mut _binding_0) => { + _visitor.visit_type_trait_object_mut(_binding_0); + } + Type::ImplTrait(ref mut _binding_0) => { + _visitor.visit_type_impl_trait_mut(_binding_0); + } + Type::Paren(ref mut _binding_0) => { + _visitor.visit_type_paren_mut(_binding_0); + } + Type::Group(ref mut _binding_0) => { + _visitor.visit_type_group_mut(_binding_0); + } + Type::Infer(ref mut _binding_0) => { + _visitor.visit_type_infer_mut(_binding_0); + } + Type::Macro(ref mut _binding_0) => { + _visitor.visit_type_macro_mut(_binding_0); + } + Type::Verbatim(ref mut _binding_0) => { + _visitor.visit_type_verbatim_mut(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_array_mut(_visitor: &mut V, _i: &mut TypeArray) { + tokens_helper(_visitor, &mut (_i.bracket_token).0); + _visitor.visit_type_mut(&mut *_i.elem); + tokens_helper(_visitor, &mut (_i.semi_token).0); + _visitor.visit_expr_mut(&mut _i.len); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_bare_fn_mut(_visitor: &mut V, _i: &mut TypeBareFn) { + if let Some(ref mut it) = _i.unsafety { + tokens_helper(_visitor, &mut (it).0) + }; + if let Some(ref mut it) = _i.abi { + _visitor.visit_abi_mut(it) + }; + tokens_helper(_visitor, &mut (_i.fn_token).0); + if let Some(ref mut it) = _i.lifetimes { + _visitor.visit_bound_lifetimes_mut(it) + }; + tokens_helper(_visitor, &mut (_i.paren_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.inputs) { + let it = el.value_mut(); + _visitor.visit_bare_fn_arg_mut(it) + } + if let Some(ref mut it) = _i.variadic { + tokens_helper(_visitor, &mut (it).0) + }; + _visitor.visit_return_type_mut(&mut _i.output); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_group_mut(_visitor: &mut V, _i: &mut TypeGroup) { + tokens_helper(_visitor, &mut (_i.group_token).0); + _visitor.visit_type_mut(&mut *_i.elem); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_impl_trait_mut(_visitor: &mut V, _i: &mut TypeImplTrait) { + tokens_helper(_visitor, &mut (_i.impl_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.bounds) { + let it = el.value_mut(); + _visitor.visit_type_param_bound_mut(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_infer_mut(_visitor: &mut V, _i: &mut TypeInfer) { + tokens_helper(_visitor, &mut (_i.underscore_token).0); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_macro_mut(_visitor: &mut V, _i: &mut TypeMacro) { + _visitor.visit_macro_mut(&mut _i.mac); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_never_mut(_visitor: &mut V, _i: &mut TypeNever) { + tokens_helper(_visitor, &mut (_i.bang_token).0); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_param_mut(_visitor: &mut V, _i: &mut TypeParam) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_ident_mut(&mut _i.ident); + if let Some(ref mut it) = _i.colon_token { + tokens_helper(_visitor, &mut (it).0) + }; + for mut el in Punctuated::pairs_mut(&mut _i.bounds) { + let it = el.value_mut(); + _visitor.visit_type_param_bound_mut(it) + } + if let Some(ref mut it) = _i.eq_token { + tokens_helper(_visitor, &mut (it).0) + }; + if let Some(ref mut it) = _i.default { + _visitor.visit_type_mut(it) + }; +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_param_bound_mut(_visitor: &mut V, _i: &mut TypeParamBound) { + match *_i { + TypeParamBound::Trait(ref mut _binding_0) => { + _visitor.visit_trait_bound_mut(_binding_0); + } + TypeParamBound::Lifetime(ref mut _binding_0) => { + _visitor.visit_lifetime_mut(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_paren_mut(_visitor: &mut V, _i: &mut TypeParen) { + tokens_helper(_visitor, &mut (_i.paren_token).0); + _visitor.visit_type_mut(&mut *_i.elem); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_path_mut(_visitor: &mut V, _i: &mut TypePath) { + if let Some(ref mut it) = _i.qself { + _visitor.visit_qself_mut(it) + }; + _visitor.visit_path_mut(&mut _i.path); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_ptr_mut(_visitor: &mut V, _i: &mut TypePtr) { + tokens_helper(_visitor, &mut (_i.star_token).0); + if let Some(ref mut it) = _i.const_token { + tokens_helper(_visitor, &mut (it).0) + }; + if let Some(ref mut it) = _i.mutability { + tokens_helper(_visitor, &mut (it).0) + }; + _visitor.visit_type_mut(&mut *_i.elem); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_reference_mut(_visitor: &mut V, _i: &mut TypeReference) { + tokens_helper(_visitor, &mut (_i.and_token).0); + if let Some(ref mut it) = _i.lifetime { + _visitor.visit_lifetime_mut(it) + }; + if let Some(ref mut it) = _i.mutability { + tokens_helper(_visitor, &mut (it).0) + }; + _visitor.visit_type_mut(&mut *_i.elem); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_slice_mut(_visitor: &mut V, _i: &mut TypeSlice) { + tokens_helper(_visitor, &mut (_i.bracket_token).0); + _visitor.visit_type_mut(&mut *_i.elem); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_trait_object_mut( + _visitor: &mut V, + _i: &mut TypeTraitObject, +) { + if let Some(ref mut it) = _i.dyn_token { + tokens_helper(_visitor, &mut (it).0) + }; + for mut el in Punctuated::pairs_mut(&mut _i.bounds) { + let it = el.value_mut(); + _visitor.visit_type_param_bound_mut(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_tuple_mut(_visitor: &mut V, _i: &mut TypeTuple) { + tokens_helper(_visitor, &mut (_i.paren_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.elems) { + let it = el.value_mut(); + _visitor.visit_type_mut(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_verbatim_mut(_visitor: &mut V, _i: &mut TypeVerbatim) { + skip!(_i.tts); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_un_op_mut(_visitor: &mut V, _i: &mut UnOp) { + match *_i { + UnOp::Deref(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + UnOp::Not(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + UnOp::Neg(ref mut _binding_0) => { + tokens_helper(_visitor, &mut (_binding_0).0); + } + } +} +#[cfg(feature = "full")] +pub fn visit_use_glob_mut(_visitor: &mut V, _i: &mut UseGlob) { + tokens_helper(_visitor, &mut (_i.star_token).0); +} +#[cfg(feature = "full")] +pub fn visit_use_group_mut(_visitor: &mut V, _i: &mut UseGroup) { + tokens_helper(_visitor, &mut (_i.brace_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.items) { + let it = el.value_mut(); + _visitor.visit_use_tree_mut(it) + } +} +#[cfg(feature = "full")] +pub fn visit_use_name_mut(_visitor: &mut V, _i: &mut UseName) { + _visitor.visit_ident_mut(&mut _i.ident); +} +#[cfg(feature = "full")] +pub fn visit_use_path_mut(_visitor: &mut V, _i: &mut UsePath) { + _visitor.visit_ident_mut(&mut _i.ident); + tokens_helper(_visitor, &mut (_i.colon2_token).0); + _visitor.visit_use_tree_mut(&mut *_i.tree); +} +#[cfg(feature = "full")] +pub fn visit_use_rename_mut(_visitor: &mut V, _i: &mut UseRename) { + _visitor.visit_ident_mut(&mut _i.ident); + tokens_helper(_visitor, &mut (_i.as_token).0); + _visitor.visit_ident_mut(&mut _i.rename); +} +#[cfg(feature = "full")] +pub fn visit_use_tree_mut(_visitor: &mut V, _i: &mut UseTree) { + match *_i { + UseTree::Path(ref mut _binding_0) => { + _visitor.visit_use_path_mut(_binding_0); + } + UseTree::Name(ref mut _binding_0) => { + _visitor.visit_use_name_mut(_binding_0); + } + UseTree::Rename(ref mut _binding_0) => { + _visitor.visit_use_rename_mut(_binding_0); + } + UseTree::Glob(ref mut _binding_0) => { + _visitor.visit_use_glob_mut(_binding_0); + } + UseTree::Group(ref mut _binding_0) => { + _visitor.visit_use_group_mut(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_variant_mut(_visitor: &mut V, _i: &mut Variant) { + for it in &mut _i.attrs { + _visitor.visit_attribute_mut(it) + } + _visitor.visit_ident_mut(&mut _i.ident); + _visitor.visit_fields_mut(&mut _i.fields); + if let Some(ref mut it) = _i.discriminant { + tokens_helper(_visitor, &mut ((it).0).0); + _visitor.visit_expr_mut(&mut (it).1); + }; +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_vis_crate_mut(_visitor: &mut V, _i: &mut VisCrate) { + tokens_helper(_visitor, &mut (_i.crate_token).0); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_vis_public_mut(_visitor: &mut V, _i: &mut VisPublic) { + tokens_helper(_visitor, &mut (_i.pub_token).0); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_vis_restricted_mut(_visitor: &mut V, _i: &mut VisRestricted) { + tokens_helper(_visitor, &mut (_i.pub_token).0); + tokens_helper(_visitor, &mut (_i.paren_token).0); + if let Some(ref mut it) = _i.in_token { + tokens_helper(_visitor, &mut (it).0) + }; + _visitor.visit_path_mut(&mut *_i.path); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_visibility_mut(_visitor: &mut V, _i: &mut Visibility) { + match *_i { + Visibility::Public(ref mut _binding_0) => { + _visitor.visit_vis_public_mut(_binding_0); + } + Visibility::Crate(ref mut _binding_0) => { + _visitor.visit_vis_crate_mut(_binding_0); + } + Visibility::Restricted(ref mut _binding_0) => { + _visitor.visit_vis_restricted_mut(_binding_0); + } + Visibility::Inherited => {} + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_where_clause_mut(_visitor: &mut V, _i: &mut WhereClause) { + tokens_helper(_visitor, &mut (_i.where_token).0); + for mut el in Punctuated::pairs_mut(&mut _i.predicates) { + let it = el.value_mut(); + _visitor.visit_where_predicate_mut(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_where_predicate_mut(_visitor: &mut V, _i: &mut WherePredicate) { + match *_i { + WherePredicate::Type(ref mut _binding_0) => { + _visitor.visit_predicate_type_mut(_binding_0); + } + WherePredicate::Lifetime(ref mut _binding_0) => { + _visitor.visit_predicate_lifetime_mut(_binding_0); + } + WherePredicate::Eq(ref mut _binding_0) => { + _visitor.visit_predicate_eq_mut(_binding_0); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/gen/visit.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/gen/visit.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/gen/visit.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/gen/visit.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,3379 @@ +// THIS FILE IS AUTOMATICALLY GENERATED; DO NOT EDIT + +#![cfg_attr(feature = "cargo-clippy", allow(match_same_arms))] +#[cfg(any(feature = "full", feature = "derive"))] +use gen::helper::visit::*; +use proc_macro2::Span; +#[cfg(any(feature = "full", feature = "derive"))] +use punctuated::Punctuated; +use *; +#[cfg(feature = "full")] +macro_rules! full { + ($e:expr) => { + $e + }; +} +#[cfg(all(feature = "derive", not(feature = "full")))] +macro_rules! full { + ($e:expr) => { + unreachable!() + }; +} +#[cfg(any(feature = "full", feature = "derive"))] +macro_rules! skip { + ($($tt:tt)*) => {}; +} +#[doc = r" Syntax tree traversal to walk a shared borrow of a syntax tree."] +#[doc = r""] +#[doc = r" See the [module documentation] for details."] +#[doc = r""] +#[doc = r" [module documentation]: index.html"] +#[doc = r""] +#[doc = r#" *This trait is available if Syn is built with the `"visit"` feature.*"#] +pub trait Visit<'ast> { + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_abi(&mut self, i: &'ast Abi) { + visit_abi(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_angle_bracketed_generic_arguments(&mut self, i: &'ast AngleBracketedGenericArguments) { + visit_angle_bracketed_generic_arguments(self, i) + } + #[cfg(feature = "full")] + fn visit_arg_captured(&mut self, i: &'ast ArgCaptured) { + visit_arg_captured(self, i) + } + #[cfg(feature = "full")] + fn visit_arg_self(&mut self, i: &'ast ArgSelf) { + visit_arg_self(self, i) + } + #[cfg(feature = "full")] + fn visit_arg_self_ref(&mut self, i: &'ast ArgSelfRef) { + visit_arg_self_ref(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_arm(&mut self, i: &'ast Arm) { + visit_arm(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_attr_style(&mut self, i: &'ast AttrStyle) { + visit_attr_style(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_attribute(&mut self, i: &'ast Attribute) { + visit_attribute(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_bare_fn_arg(&mut self, i: &'ast BareFnArg) { + visit_bare_fn_arg(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_bare_fn_arg_name(&mut self, i: &'ast BareFnArgName) { + visit_bare_fn_arg_name(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_bin_op(&mut self, i: &'ast BinOp) { + visit_bin_op(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_binding(&mut self, i: &'ast Binding) { + visit_binding(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_block(&mut self, i: &'ast Block) { + visit_block(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_bound_lifetimes(&mut self, i: &'ast BoundLifetimes) { + visit_bound_lifetimes(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_const_param(&mut self, i: &'ast ConstParam) { + visit_const_param(self, i) + } + #[cfg(feature = "derive")] + fn visit_data(&mut self, i: &'ast Data) { + visit_data(self, i) + } + #[cfg(feature = "derive")] + fn visit_data_enum(&mut self, i: &'ast DataEnum) { + visit_data_enum(self, i) + } + #[cfg(feature = "derive")] + fn visit_data_struct(&mut self, i: &'ast DataStruct) { + visit_data_struct(self, i) + } + #[cfg(feature = "derive")] + fn visit_data_union(&mut self, i: &'ast DataUnion) { + visit_data_union(self, i) + } + #[cfg(feature = "derive")] + fn visit_derive_input(&mut self, i: &'ast DeriveInput) { + visit_derive_input(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr(&mut self, i: &'ast Expr) { + visit_expr(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_array(&mut self, i: &'ast ExprArray) { + visit_expr_array(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_assign(&mut self, i: &'ast ExprAssign) { + visit_expr_assign(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_assign_op(&mut self, i: &'ast ExprAssignOp) { + visit_expr_assign_op(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_binary(&mut self, i: &'ast ExprBinary) { + visit_expr_binary(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_block(&mut self, i: &'ast ExprBlock) { + visit_expr_block(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_box(&mut self, i: &'ast ExprBox) { + visit_expr_box(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_break(&mut self, i: &'ast ExprBreak) { + visit_expr_break(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_call(&mut self, i: &'ast ExprCall) { + visit_expr_call(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_cast(&mut self, i: &'ast ExprCast) { + visit_expr_cast(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_catch(&mut self, i: &'ast ExprCatch) { + visit_expr_catch(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_closure(&mut self, i: &'ast ExprClosure) { + visit_expr_closure(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_continue(&mut self, i: &'ast ExprContinue) { + visit_expr_continue(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_field(&mut self, i: &'ast ExprField) { + visit_expr_field(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_for_loop(&mut self, i: &'ast ExprForLoop) { + visit_expr_for_loop(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_group(&mut self, i: &'ast ExprGroup) { + visit_expr_group(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_if(&mut self, i: &'ast ExprIf) { + visit_expr_if(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_if_let(&mut self, i: &'ast ExprIfLet) { + visit_expr_if_let(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_in_place(&mut self, i: &'ast ExprInPlace) { + visit_expr_in_place(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_index(&mut self, i: &'ast ExprIndex) { + visit_expr_index(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_lit(&mut self, i: &'ast ExprLit) { + visit_expr_lit(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_loop(&mut self, i: &'ast ExprLoop) { + visit_expr_loop(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_macro(&mut self, i: &'ast ExprMacro) { + visit_expr_macro(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_match(&mut self, i: &'ast ExprMatch) { + visit_expr_match(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_method_call(&mut self, i: &'ast ExprMethodCall) { + visit_expr_method_call(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_paren(&mut self, i: &'ast ExprParen) { + visit_expr_paren(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_path(&mut self, i: &'ast ExprPath) { + visit_expr_path(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_range(&mut self, i: &'ast ExprRange) { + visit_expr_range(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_reference(&mut self, i: &'ast ExprReference) { + visit_expr_reference(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_repeat(&mut self, i: &'ast ExprRepeat) { + visit_expr_repeat(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_return(&mut self, i: &'ast ExprReturn) { + visit_expr_return(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_struct(&mut self, i: &'ast ExprStruct) { + visit_expr_struct(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_try(&mut self, i: &'ast ExprTry) { + visit_expr_try(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_tuple(&mut self, i: &'ast ExprTuple) { + visit_expr_tuple(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_type(&mut self, i: &'ast ExprType) { + visit_expr_type(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_unary(&mut self, i: &'ast ExprUnary) { + visit_expr_unary(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_unsafe(&mut self, i: &'ast ExprUnsafe) { + visit_expr_unsafe(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_verbatim(&mut self, i: &'ast ExprVerbatim) { + visit_expr_verbatim(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_while(&mut self, i: &'ast ExprWhile) { + visit_expr_while(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_while_let(&mut self, i: &'ast ExprWhileLet) { + visit_expr_while_let(self, i) + } + #[cfg(feature = "full")] + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_expr_yield(&mut self, i: &'ast ExprYield) { + visit_expr_yield(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_field(&mut self, i: &'ast Field) { + visit_field(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_field_pat(&mut self, i: &'ast FieldPat) { + visit_field_pat(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_field_value(&mut self, i: &'ast FieldValue) { + visit_field_value(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_fields(&mut self, i: &'ast Fields) { + visit_fields(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_fields_named(&mut self, i: &'ast FieldsNamed) { + visit_fields_named(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_fields_unnamed(&mut self, i: &'ast FieldsUnnamed) { + visit_fields_unnamed(self, i) + } + #[cfg(feature = "full")] + fn visit_file(&mut self, i: &'ast File) { + visit_file(self, i) + } + #[cfg(feature = "full")] + fn visit_fn_arg(&mut self, i: &'ast FnArg) { + visit_fn_arg(self, i) + } + #[cfg(feature = "full")] + fn visit_fn_decl(&mut self, i: &'ast FnDecl) { + visit_fn_decl(self, i) + } + #[cfg(feature = "full")] + fn visit_foreign_item(&mut self, i: &'ast ForeignItem) { + visit_foreign_item(self, i) + } + #[cfg(feature = "full")] + fn visit_foreign_item_fn(&mut self, i: &'ast ForeignItemFn) { + visit_foreign_item_fn(self, i) + } + #[cfg(feature = "full")] + fn visit_foreign_item_static(&mut self, i: &'ast ForeignItemStatic) { + visit_foreign_item_static(self, i) + } + #[cfg(feature = "full")] + fn visit_foreign_item_type(&mut self, i: &'ast ForeignItemType) { + visit_foreign_item_type(self, i) + } + #[cfg(feature = "full")] + fn visit_foreign_item_verbatim(&mut self, i: &'ast ForeignItemVerbatim) { + visit_foreign_item_verbatim(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_generic_argument(&mut self, i: &'ast GenericArgument) { + visit_generic_argument(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_generic_method_argument(&mut self, i: &'ast GenericMethodArgument) { + visit_generic_method_argument(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_generic_param(&mut self, i: &'ast GenericParam) { + visit_generic_param(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_generics(&mut self, i: &'ast Generics) { + visit_generics(self, i) + } + fn visit_ident(&mut self, i: &'ast Ident) { + visit_ident(self, i) + } + #[cfg(feature = "full")] + fn visit_impl_item(&mut self, i: &'ast ImplItem) { + visit_impl_item(self, i) + } + #[cfg(feature = "full")] + fn visit_impl_item_const(&mut self, i: &'ast ImplItemConst) { + visit_impl_item_const(self, i) + } + #[cfg(feature = "full")] + fn visit_impl_item_macro(&mut self, i: &'ast ImplItemMacro) { + visit_impl_item_macro(self, i) + } + #[cfg(feature = "full")] + fn visit_impl_item_method(&mut self, i: &'ast ImplItemMethod) { + visit_impl_item_method(self, i) + } + #[cfg(feature = "full")] + fn visit_impl_item_type(&mut self, i: &'ast ImplItemType) { + visit_impl_item_type(self, i) + } + #[cfg(feature = "full")] + fn visit_impl_item_verbatim(&mut self, i: &'ast ImplItemVerbatim) { + visit_impl_item_verbatim(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_index(&mut self, i: &'ast Index) { + visit_index(self, i) + } + #[cfg(feature = "full")] + fn visit_item(&mut self, i: &'ast Item) { + visit_item(self, i) + } + #[cfg(feature = "full")] + fn visit_item_const(&mut self, i: &'ast ItemConst) { + visit_item_const(self, i) + } + #[cfg(feature = "full")] + fn visit_item_enum(&mut self, i: &'ast ItemEnum) { + visit_item_enum(self, i) + } + #[cfg(feature = "full")] + fn visit_item_extern_crate(&mut self, i: &'ast ItemExternCrate) { + visit_item_extern_crate(self, i) + } + #[cfg(feature = "full")] + fn visit_item_fn(&mut self, i: &'ast ItemFn) { + visit_item_fn(self, i) + } + #[cfg(feature = "full")] + fn visit_item_foreign_mod(&mut self, i: &'ast ItemForeignMod) { + visit_item_foreign_mod(self, i) + } + #[cfg(feature = "full")] + fn visit_item_impl(&mut self, i: &'ast ItemImpl) { + visit_item_impl(self, i) + } + #[cfg(feature = "full")] + fn visit_item_macro(&mut self, i: &'ast ItemMacro) { + visit_item_macro(self, i) + } + #[cfg(feature = "full")] + fn visit_item_macro2(&mut self, i: &'ast ItemMacro2) { + visit_item_macro2(self, i) + } + #[cfg(feature = "full")] + fn visit_item_mod(&mut self, i: &'ast ItemMod) { + visit_item_mod(self, i) + } + #[cfg(feature = "full")] + fn visit_item_static(&mut self, i: &'ast ItemStatic) { + visit_item_static(self, i) + } + #[cfg(feature = "full")] + fn visit_item_struct(&mut self, i: &'ast ItemStruct) { + visit_item_struct(self, i) + } + #[cfg(feature = "full")] + fn visit_item_trait(&mut self, i: &'ast ItemTrait) { + visit_item_trait(self, i) + } + #[cfg(feature = "full")] + fn visit_item_type(&mut self, i: &'ast ItemType) { + visit_item_type(self, i) + } + #[cfg(feature = "full")] + fn visit_item_union(&mut self, i: &'ast ItemUnion) { + visit_item_union(self, i) + } + #[cfg(feature = "full")] + fn visit_item_use(&mut self, i: &'ast ItemUse) { + visit_item_use(self, i) + } + #[cfg(feature = "full")] + fn visit_item_verbatim(&mut self, i: &'ast ItemVerbatim) { + visit_item_verbatim(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_label(&mut self, i: &'ast Label) { + visit_label(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_lifetime(&mut self, i: &'ast Lifetime) { + visit_lifetime(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_lifetime_def(&mut self, i: &'ast LifetimeDef) { + visit_lifetime_def(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_lit(&mut self, i: &'ast Lit) { + visit_lit(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_lit_bool(&mut self, i: &'ast LitBool) { + visit_lit_bool(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_lit_byte(&mut self, i: &'ast LitByte) { + visit_lit_byte(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_lit_byte_str(&mut self, i: &'ast LitByteStr) { + visit_lit_byte_str(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_lit_char(&mut self, i: &'ast LitChar) { + visit_lit_char(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_lit_float(&mut self, i: &'ast LitFloat) { + visit_lit_float(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_lit_int(&mut self, i: &'ast LitInt) { + visit_lit_int(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_lit_str(&mut self, i: &'ast LitStr) { + visit_lit_str(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_lit_verbatim(&mut self, i: &'ast LitVerbatim) { + visit_lit_verbatim(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_local(&mut self, i: &'ast Local) { + visit_local(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_macro(&mut self, i: &'ast Macro) { + visit_macro(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_macro_delimiter(&mut self, i: &'ast MacroDelimiter) { + visit_macro_delimiter(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_member(&mut self, i: &'ast Member) { + visit_member(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_meta(&mut self, i: &'ast Meta) { + visit_meta(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_meta_list(&mut self, i: &'ast MetaList) { + visit_meta_list(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_meta_name_value(&mut self, i: &'ast MetaNameValue) { + visit_meta_name_value(self, i) + } + #[cfg(feature = "full")] + fn visit_method_sig(&mut self, i: &'ast MethodSig) { + visit_method_sig(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_method_turbofish(&mut self, i: &'ast MethodTurbofish) { + visit_method_turbofish(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_nested_meta(&mut self, i: &'ast NestedMeta) { + visit_nested_meta(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_parenthesized_generic_arguments(&mut self, i: &'ast ParenthesizedGenericArguments) { + visit_parenthesized_generic_arguments(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat(&mut self, i: &'ast Pat) { + visit_pat(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_box(&mut self, i: &'ast PatBox) { + visit_pat_box(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_ident(&mut self, i: &'ast PatIdent) { + visit_pat_ident(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_lit(&mut self, i: &'ast PatLit) { + visit_pat_lit(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_macro(&mut self, i: &'ast PatMacro) { + visit_pat_macro(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_path(&mut self, i: &'ast PatPath) { + visit_pat_path(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_range(&mut self, i: &'ast PatRange) { + visit_pat_range(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_ref(&mut self, i: &'ast PatRef) { + visit_pat_ref(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_slice(&mut self, i: &'ast PatSlice) { + visit_pat_slice(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_struct(&mut self, i: &'ast PatStruct) { + visit_pat_struct(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_tuple(&mut self, i: &'ast PatTuple) { + visit_pat_tuple(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_tuple_struct(&mut self, i: &'ast PatTupleStruct) { + visit_pat_tuple_struct(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_verbatim(&mut self, i: &'ast PatVerbatim) { + visit_pat_verbatim(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_pat_wild(&mut self, i: &'ast PatWild) { + visit_pat_wild(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_path(&mut self, i: &'ast Path) { + visit_path(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_path_arguments(&mut self, i: &'ast PathArguments) { + visit_path_arguments(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_path_segment(&mut self, i: &'ast PathSegment) { + visit_path_segment(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_predicate_eq(&mut self, i: &'ast PredicateEq) { + visit_predicate_eq(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_predicate_lifetime(&mut self, i: &'ast PredicateLifetime) { + visit_predicate_lifetime(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_predicate_type(&mut self, i: &'ast PredicateType) { + visit_predicate_type(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_qself(&mut self, i: &'ast QSelf) { + visit_qself(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_range_limits(&mut self, i: &'ast RangeLimits) { + visit_range_limits(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_return_type(&mut self, i: &'ast ReturnType) { + visit_return_type(self, i) + } + fn visit_span(&mut self, i: &'ast Span) { + visit_span(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + #[cfg(feature = "full")] + fn visit_stmt(&mut self, i: &'ast Stmt) { + visit_stmt(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_trait_bound(&mut self, i: &'ast TraitBound) { + visit_trait_bound(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_trait_bound_modifier(&mut self, i: &'ast TraitBoundModifier) { + visit_trait_bound_modifier(self, i) + } + #[cfg(feature = "full")] + fn visit_trait_item(&mut self, i: &'ast TraitItem) { + visit_trait_item(self, i) + } + #[cfg(feature = "full")] + fn visit_trait_item_const(&mut self, i: &'ast TraitItemConst) { + visit_trait_item_const(self, i) + } + #[cfg(feature = "full")] + fn visit_trait_item_macro(&mut self, i: &'ast TraitItemMacro) { + visit_trait_item_macro(self, i) + } + #[cfg(feature = "full")] + fn visit_trait_item_method(&mut self, i: &'ast TraitItemMethod) { + visit_trait_item_method(self, i) + } + #[cfg(feature = "full")] + fn visit_trait_item_type(&mut self, i: &'ast TraitItemType) { + visit_trait_item_type(self, i) + } + #[cfg(feature = "full")] + fn visit_trait_item_verbatim(&mut self, i: &'ast TraitItemVerbatim) { + visit_trait_item_verbatim(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type(&mut self, i: &'ast Type) { + visit_type(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_array(&mut self, i: &'ast TypeArray) { + visit_type_array(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_bare_fn(&mut self, i: &'ast TypeBareFn) { + visit_type_bare_fn(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_group(&mut self, i: &'ast TypeGroup) { + visit_type_group(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_impl_trait(&mut self, i: &'ast TypeImplTrait) { + visit_type_impl_trait(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_infer(&mut self, i: &'ast TypeInfer) { + visit_type_infer(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_macro(&mut self, i: &'ast TypeMacro) { + visit_type_macro(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_never(&mut self, i: &'ast TypeNever) { + visit_type_never(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_param(&mut self, i: &'ast TypeParam) { + visit_type_param(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_param_bound(&mut self, i: &'ast TypeParamBound) { + visit_type_param_bound(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_paren(&mut self, i: &'ast TypeParen) { + visit_type_paren(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_path(&mut self, i: &'ast TypePath) { + visit_type_path(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_ptr(&mut self, i: &'ast TypePtr) { + visit_type_ptr(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_reference(&mut self, i: &'ast TypeReference) { + visit_type_reference(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_slice(&mut self, i: &'ast TypeSlice) { + visit_type_slice(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_trait_object(&mut self, i: &'ast TypeTraitObject) { + visit_type_trait_object(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_tuple(&mut self, i: &'ast TypeTuple) { + visit_type_tuple(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_type_verbatim(&mut self, i: &'ast TypeVerbatim) { + visit_type_verbatim(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_un_op(&mut self, i: &'ast UnOp) { + visit_un_op(self, i) + } + #[cfg(feature = "full")] + fn visit_use_glob(&mut self, i: &'ast UseGlob) { + visit_use_glob(self, i) + } + #[cfg(feature = "full")] + fn visit_use_group(&mut self, i: &'ast UseGroup) { + visit_use_group(self, i) + } + #[cfg(feature = "full")] + fn visit_use_name(&mut self, i: &'ast UseName) { + visit_use_name(self, i) + } + #[cfg(feature = "full")] + fn visit_use_path(&mut self, i: &'ast UsePath) { + visit_use_path(self, i) + } + #[cfg(feature = "full")] + fn visit_use_rename(&mut self, i: &'ast UseRename) { + visit_use_rename(self, i) + } + #[cfg(feature = "full")] + fn visit_use_tree(&mut self, i: &'ast UseTree) { + visit_use_tree(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_variant(&mut self, i: &'ast Variant) { + visit_variant(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_vis_crate(&mut self, i: &'ast VisCrate) { + visit_vis_crate(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_vis_public(&mut self, i: &'ast VisPublic) { + visit_vis_public(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_vis_restricted(&mut self, i: &'ast VisRestricted) { + visit_vis_restricted(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_visibility(&mut self, i: &'ast Visibility) { + visit_visibility(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_where_clause(&mut self, i: &'ast WhereClause) { + visit_where_clause(self, i) + } + #[cfg(any(feature = "full", feature = "derive"))] + fn visit_where_predicate(&mut self, i: &'ast WherePredicate) { + visit_where_predicate(self, i) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_abi<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Abi) { + tokens_helper(_visitor, &(_i.extern_token).0); + if let Some(ref it) = _i.name { + _visitor.visit_lit_str(it) + }; +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_angle_bracketed_generic_arguments<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast AngleBracketedGenericArguments, +) { + if let Some(ref it) = _i.colon2_token { + tokens_helper(_visitor, &(it).0) + }; + tokens_helper(_visitor, &(_i.lt_token).0); + for el in Punctuated::pairs(&_i.args) { + let it = el.value(); + _visitor.visit_generic_argument(it) + } + tokens_helper(_visitor, &(_i.gt_token).0); +} +#[cfg(feature = "full")] +pub fn visit_arg_captured<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ArgCaptured) { + _visitor.visit_pat(&_i.pat); + tokens_helper(_visitor, &(_i.colon_token).0); + _visitor.visit_type(&_i.ty); +} +#[cfg(feature = "full")] +pub fn visit_arg_self<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ArgSelf) { + if let Some(ref it) = _i.mutability { + tokens_helper(_visitor, &(it).0) + }; + tokens_helper(_visitor, &(_i.self_token).0); +} +#[cfg(feature = "full")] +pub fn visit_arg_self_ref<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ArgSelfRef) { + tokens_helper(_visitor, &(_i.and_token).0); + if let Some(ref it) = _i.lifetime { + _visitor.visit_lifetime(it) + }; + if let Some(ref it) = _i.mutability { + tokens_helper(_visitor, &(it).0) + }; + tokens_helper(_visitor, &(_i.self_token).0); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_arm<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Arm) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + if let Some(ref it) = _i.leading_vert { + tokens_helper(_visitor, &(it).0) + }; + for el in Punctuated::pairs(&_i.pats) { + let it = el.value(); + _visitor.visit_pat(it) + } + if let Some(ref it) = _i.guard { + tokens_helper(_visitor, &((it).0).0); + _visitor.visit_expr(&*(it).1); + }; + tokens_helper(_visitor, &(_i.fat_arrow_token).0); + _visitor.visit_expr(&*_i.body); + if let Some(ref it) = _i.comma { + tokens_helper(_visitor, &(it).0) + }; +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_attr_style<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast AttrStyle) { + match *_i { + AttrStyle::Outer => {} + AttrStyle::Inner(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_attribute<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Attribute) { + tokens_helper(_visitor, &(_i.pound_token).0); + _visitor.visit_attr_style(&_i.style); + tokens_helper(_visitor, &(_i.bracket_token).0); + _visitor.visit_path(&_i.path); + skip!(_i.tts); + skip!(_i.is_sugared_doc); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_bare_fn_arg<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast BareFnArg) { + if let Some(ref it) = _i.name { + _visitor.visit_bare_fn_arg_name(&(it).0); + tokens_helper(_visitor, &((it).1).0); + }; + _visitor.visit_type(&_i.ty); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_bare_fn_arg_name<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast BareFnArgName, +) { + match *_i { + BareFnArgName::Named(ref _binding_0) => { + _visitor.visit_ident(_binding_0); + } + BareFnArgName::Wild(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_bin_op<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast BinOp) { + match *_i { + BinOp::Add(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::Sub(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::Mul(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::Div(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::Rem(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::And(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::Or(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::BitXor(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::BitAnd(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::BitOr(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::Shl(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::Shr(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::Eq(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::Lt(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::Le(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::Ne(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::Ge(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::Gt(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::AddEq(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::SubEq(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::MulEq(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::DivEq(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::RemEq(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::BitXorEq(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::BitAndEq(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::BitOrEq(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::ShlEq(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + BinOp::ShrEq(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_binding<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Binding) { + _visitor.visit_ident(&_i.ident); + tokens_helper(_visitor, &(_i.eq_token).0); + _visitor.visit_type(&_i.ty); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_block<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Block) { + tokens_helper(_visitor, &(_i.brace_token).0); + for it in &_i.stmts { + _visitor.visit_stmt(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_bound_lifetimes<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast BoundLifetimes, +) { + tokens_helper(_visitor, &(_i.for_token).0); + tokens_helper(_visitor, &(_i.lt_token).0); + for el in Punctuated::pairs(&_i.lifetimes) { + let it = el.value(); + _visitor.visit_lifetime_def(it) + } + tokens_helper(_visitor, &(_i.gt_token).0); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_const_param<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ConstParam) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + tokens_helper(_visitor, &(_i.const_token).0); + _visitor.visit_ident(&_i.ident); + tokens_helper(_visitor, &(_i.colon_token).0); + _visitor.visit_type(&_i.ty); + if let Some(ref it) = _i.eq_token { + tokens_helper(_visitor, &(it).0) + }; + if let Some(ref it) = _i.default { + _visitor.visit_expr(it) + }; +} +#[cfg(feature = "derive")] +pub fn visit_data<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Data) { + match *_i { + Data::Struct(ref _binding_0) => { + _visitor.visit_data_struct(_binding_0); + } + Data::Enum(ref _binding_0) => { + _visitor.visit_data_enum(_binding_0); + } + Data::Union(ref _binding_0) => { + _visitor.visit_data_union(_binding_0); + } + } +} +#[cfg(feature = "derive")] +pub fn visit_data_enum<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast DataEnum) { + tokens_helper(_visitor, &(_i.enum_token).0); + tokens_helper(_visitor, &(_i.brace_token).0); + for el in Punctuated::pairs(&_i.variants) { + let it = el.value(); + _visitor.visit_variant(it) + } +} +#[cfg(feature = "derive")] +pub fn visit_data_struct<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast DataStruct) { + tokens_helper(_visitor, &(_i.struct_token).0); + _visitor.visit_fields(&_i.fields); + if let Some(ref it) = _i.semi_token { + tokens_helper(_visitor, &(it).0) + }; +} +#[cfg(feature = "derive")] +pub fn visit_data_union<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast DataUnion) { + tokens_helper(_visitor, &(_i.union_token).0); + _visitor.visit_fields_named(&_i.fields); +} +#[cfg(feature = "derive")] +pub fn visit_derive_input<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast DeriveInput) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_visibility(&_i.vis); + _visitor.visit_ident(&_i.ident); + _visitor.visit_generics(&_i.generics); + _visitor.visit_data(&_i.data); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Expr) { + match *_i { + Expr::Box(ref _binding_0) => { + full!(_visitor.visit_expr_box(_binding_0)); + } + Expr::InPlace(ref _binding_0) => { + full!(_visitor.visit_expr_in_place(_binding_0)); + } + Expr::Array(ref _binding_0) => { + full!(_visitor.visit_expr_array(_binding_0)); + } + Expr::Call(ref _binding_0) => { + _visitor.visit_expr_call(_binding_0); + } + Expr::MethodCall(ref _binding_0) => { + full!(_visitor.visit_expr_method_call(_binding_0)); + } + Expr::Tuple(ref _binding_0) => { + full!(_visitor.visit_expr_tuple(_binding_0)); + } + Expr::Binary(ref _binding_0) => { + _visitor.visit_expr_binary(_binding_0); + } + Expr::Unary(ref _binding_0) => { + _visitor.visit_expr_unary(_binding_0); + } + Expr::Lit(ref _binding_0) => { + _visitor.visit_expr_lit(_binding_0); + } + Expr::Cast(ref _binding_0) => { + _visitor.visit_expr_cast(_binding_0); + } + Expr::Type(ref _binding_0) => { + full!(_visitor.visit_expr_type(_binding_0)); + } + Expr::If(ref _binding_0) => { + full!(_visitor.visit_expr_if(_binding_0)); + } + Expr::IfLet(ref _binding_0) => { + full!(_visitor.visit_expr_if_let(_binding_0)); + } + Expr::While(ref _binding_0) => { + full!(_visitor.visit_expr_while(_binding_0)); + } + Expr::WhileLet(ref _binding_0) => { + full!(_visitor.visit_expr_while_let(_binding_0)); + } + Expr::ForLoop(ref _binding_0) => { + full!(_visitor.visit_expr_for_loop(_binding_0)); + } + Expr::Loop(ref _binding_0) => { + full!(_visitor.visit_expr_loop(_binding_0)); + } + Expr::Match(ref _binding_0) => { + full!(_visitor.visit_expr_match(_binding_0)); + } + Expr::Closure(ref _binding_0) => { + full!(_visitor.visit_expr_closure(_binding_0)); + } + Expr::Unsafe(ref _binding_0) => { + full!(_visitor.visit_expr_unsafe(_binding_0)); + } + Expr::Block(ref _binding_0) => { + full!(_visitor.visit_expr_block(_binding_0)); + } + Expr::Assign(ref _binding_0) => { + full!(_visitor.visit_expr_assign(_binding_0)); + } + Expr::AssignOp(ref _binding_0) => { + full!(_visitor.visit_expr_assign_op(_binding_0)); + } + Expr::Field(ref _binding_0) => { + _visitor.visit_expr_field(_binding_0); + } + Expr::Index(ref _binding_0) => { + _visitor.visit_expr_index(_binding_0); + } + Expr::Range(ref _binding_0) => { + full!(_visitor.visit_expr_range(_binding_0)); + } + Expr::Path(ref _binding_0) => { + _visitor.visit_expr_path(_binding_0); + } + Expr::Reference(ref _binding_0) => { + full!(_visitor.visit_expr_reference(_binding_0)); + } + Expr::Break(ref _binding_0) => { + full!(_visitor.visit_expr_break(_binding_0)); + } + Expr::Continue(ref _binding_0) => { + full!(_visitor.visit_expr_continue(_binding_0)); + } + Expr::Return(ref _binding_0) => { + full!(_visitor.visit_expr_return(_binding_0)); + } + Expr::Macro(ref _binding_0) => { + full!(_visitor.visit_expr_macro(_binding_0)); + } + Expr::Struct(ref _binding_0) => { + full!(_visitor.visit_expr_struct(_binding_0)); + } + Expr::Repeat(ref _binding_0) => { + full!(_visitor.visit_expr_repeat(_binding_0)); + } + Expr::Paren(ref _binding_0) => { + _visitor.visit_expr_paren(_binding_0); + } + Expr::Group(ref _binding_0) => { + full!(_visitor.visit_expr_group(_binding_0)); + } + Expr::Try(ref _binding_0) => { + full!(_visitor.visit_expr_try(_binding_0)); + } + Expr::Catch(ref _binding_0) => { + full!(_visitor.visit_expr_catch(_binding_0)); + } + Expr::Yield(ref _binding_0) => { + full!(_visitor.visit_expr_yield(_binding_0)); + } + Expr::Verbatim(ref _binding_0) => { + _visitor.visit_expr_verbatim(_binding_0); + } + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_array<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprArray) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + tokens_helper(_visitor, &(_i.bracket_token).0); + for el in Punctuated::pairs(&_i.elems) { + let it = el.value(); + _visitor.visit_expr(it) + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_assign<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprAssign) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_expr(&*_i.left); + tokens_helper(_visitor, &(_i.eq_token).0); + _visitor.visit_expr(&*_i.right); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_assign_op<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast ExprAssignOp, +) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_expr(&*_i.left); + _visitor.visit_bin_op(&_i.op); + _visitor.visit_expr(&*_i.right); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_binary<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprBinary) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_expr(&*_i.left); + _visitor.visit_bin_op(&_i.op); + _visitor.visit_expr(&*_i.right); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_block<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprBlock) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_block(&_i.block); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_box<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprBox) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + tokens_helper(_visitor, &(_i.box_token).0); + _visitor.visit_expr(&*_i.expr); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_break<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprBreak) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + tokens_helper(_visitor, &(_i.break_token).0); + if let Some(ref it) = _i.label { + _visitor.visit_lifetime(it) + }; + if let Some(ref it) = _i.expr { + _visitor.visit_expr(&**it) + }; +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_call<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprCall) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_expr(&*_i.func); + tokens_helper(_visitor, &(_i.paren_token).0); + for el in Punctuated::pairs(&_i.args) { + let it = el.value(); + _visitor.visit_expr(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_cast<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprCast) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_expr(&*_i.expr); + tokens_helper(_visitor, &(_i.as_token).0); + _visitor.visit_type(&*_i.ty); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_catch<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprCatch) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + tokens_helper(_visitor, &(_i.do_token).0); + tokens_helper(_visitor, &(_i.catch_token).0); + _visitor.visit_block(&_i.block); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_closure<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprClosure) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + if let Some(ref it) = _i.movability { + tokens_helper(_visitor, &(it).0) + }; + if let Some(ref it) = _i.capture { + tokens_helper(_visitor, &(it).0) + }; + tokens_helper(_visitor, &(_i.or1_token).0); + for el in Punctuated::pairs(&_i.inputs) { + let it = el.value(); + _visitor.visit_fn_arg(it) + } + tokens_helper(_visitor, &(_i.or2_token).0); + _visitor.visit_return_type(&_i.output); + _visitor.visit_expr(&*_i.body); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_continue<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast ExprContinue, +) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + tokens_helper(_visitor, &(_i.continue_token).0); + if let Some(ref it) = _i.label { + _visitor.visit_lifetime(it) + }; +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_field<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprField) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_expr(&*_i.base); + tokens_helper(_visitor, &(_i.dot_token).0); + _visitor.visit_member(&_i.member); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_for_loop<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprForLoop) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + if let Some(ref it) = _i.label { + _visitor.visit_label(it) + }; + tokens_helper(_visitor, &(_i.for_token).0); + _visitor.visit_pat(&*_i.pat); + tokens_helper(_visitor, &(_i.in_token).0); + _visitor.visit_expr(&*_i.expr); + _visitor.visit_block(&_i.body); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_group<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprGroup) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + tokens_helper(_visitor, &(_i.group_token).0); + _visitor.visit_expr(&*_i.expr); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_if<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprIf) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + tokens_helper(_visitor, &(_i.if_token).0); + _visitor.visit_expr(&*_i.cond); + _visitor.visit_block(&_i.then_branch); + if let Some(ref it) = _i.else_branch { + tokens_helper(_visitor, &((it).0).0); + _visitor.visit_expr(&*(it).1); + }; +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_if_let<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprIfLet) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + tokens_helper(_visitor, &(_i.if_token).0); + tokens_helper(_visitor, &(_i.let_token).0); + for el in Punctuated::pairs(&_i.pats) { + let it = el.value(); + _visitor.visit_pat(it) + } + tokens_helper(_visitor, &(_i.eq_token).0); + _visitor.visit_expr(&*_i.expr); + _visitor.visit_block(&_i.then_branch); + if let Some(ref it) = _i.else_branch { + tokens_helper(_visitor, &((it).0).0); + _visitor.visit_expr(&*(it).1); + }; +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_in_place<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprInPlace) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_expr(&*_i.place); + tokens_helper(_visitor, &(_i.arrow_token).0); + _visitor.visit_expr(&*_i.value); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_index<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprIndex) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_expr(&*_i.expr); + tokens_helper(_visitor, &(_i.bracket_token).0); + _visitor.visit_expr(&*_i.index); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_lit<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprLit) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_lit(&_i.lit); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_loop<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprLoop) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + if let Some(ref it) = _i.label { + _visitor.visit_label(it) + }; + tokens_helper(_visitor, &(_i.loop_token).0); + _visitor.visit_block(&_i.body); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_macro<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprMacro) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_macro(&_i.mac); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_match<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprMatch) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + tokens_helper(_visitor, &(_i.match_token).0); + _visitor.visit_expr(&*_i.expr); + tokens_helper(_visitor, &(_i.brace_token).0); + for it in &_i.arms { + _visitor.visit_arm(it) + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_method_call<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast ExprMethodCall, +) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_expr(&*_i.receiver); + tokens_helper(_visitor, &(_i.dot_token).0); + _visitor.visit_ident(&_i.method); + if let Some(ref it) = _i.turbofish { + _visitor.visit_method_turbofish(it) + }; + tokens_helper(_visitor, &(_i.paren_token).0); + for el in Punctuated::pairs(&_i.args) { + let it = el.value(); + _visitor.visit_expr(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_paren<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprParen) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + tokens_helper(_visitor, &(_i.paren_token).0); + _visitor.visit_expr(&*_i.expr); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_path<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprPath) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + if let Some(ref it) = _i.qself { + _visitor.visit_qself(it) + }; + _visitor.visit_path(&_i.path); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_range<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprRange) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + if let Some(ref it) = _i.from { + _visitor.visit_expr(&**it) + }; + _visitor.visit_range_limits(&_i.limits); + if let Some(ref it) = _i.to { + _visitor.visit_expr(&**it) + }; +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_reference<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast ExprReference, +) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + tokens_helper(_visitor, &(_i.and_token).0); + if let Some(ref it) = _i.mutability { + tokens_helper(_visitor, &(it).0) + }; + _visitor.visit_expr(&*_i.expr); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_repeat<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprRepeat) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + tokens_helper(_visitor, &(_i.bracket_token).0); + _visitor.visit_expr(&*_i.expr); + tokens_helper(_visitor, &(_i.semi_token).0); + _visitor.visit_expr(&*_i.len); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_return<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprReturn) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + tokens_helper(_visitor, &(_i.return_token).0); + if let Some(ref it) = _i.expr { + _visitor.visit_expr(&**it) + }; +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_struct<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprStruct) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_path(&_i.path); + tokens_helper(_visitor, &(_i.brace_token).0); + for el in Punctuated::pairs(&_i.fields) { + let it = el.value(); + _visitor.visit_field_value(it) + } + if let Some(ref it) = _i.dot2_token { + tokens_helper(_visitor, &(it).0) + }; + if let Some(ref it) = _i.rest { + _visitor.visit_expr(&**it) + }; +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_try<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprTry) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_expr(&*_i.expr); + tokens_helper(_visitor, &(_i.question_token).0); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_tuple<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprTuple) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + tokens_helper(_visitor, &(_i.paren_token).0); + for el in Punctuated::pairs(&_i.elems) { + let it = el.value(); + _visitor.visit_expr(it) + } +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_type<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprType) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_expr(&*_i.expr); + tokens_helper(_visitor, &(_i.colon_token).0); + _visitor.visit_type(&*_i.ty); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_unary<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprUnary) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_un_op(&_i.op); + _visitor.visit_expr(&*_i.expr); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_unsafe<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprUnsafe) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + tokens_helper(_visitor, &(_i.unsafe_token).0); + _visitor.visit_block(&_i.block); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_verbatim<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast ExprVerbatim, +) { + skip!(_i.tts); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_while<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprWhile) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + if let Some(ref it) = _i.label { + _visitor.visit_label(it) + }; + tokens_helper(_visitor, &(_i.while_token).0); + _visitor.visit_expr(&*_i.cond); + _visitor.visit_block(&_i.body); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_while_let<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast ExprWhileLet, +) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + if let Some(ref it) = _i.label { + _visitor.visit_label(it) + }; + tokens_helper(_visitor, &(_i.while_token).0); + tokens_helper(_visitor, &(_i.let_token).0); + for el in Punctuated::pairs(&_i.pats) { + let it = el.value(); + _visitor.visit_pat(it) + } + tokens_helper(_visitor, &(_i.eq_token).0); + _visitor.visit_expr(&*_i.expr); + _visitor.visit_block(&_i.body); +} +#[cfg(feature = "full")] +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_expr_yield<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ExprYield) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + tokens_helper(_visitor, &(_i.yield_token).0); + if let Some(ref it) = _i.expr { + _visitor.visit_expr(&**it) + }; +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_field<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Field) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_visibility(&_i.vis); + if let Some(ref it) = _i.ident { + _visitor.visit_ident(it) + }; + if let Some(ref it) = _i.colon_token { + tokens_helper(_visitor, &(it).0) + }; + _visitor.visit_type(&_i.ty); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_field_pat<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast FieldPat) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_member(&_i.member); + if let Some(ref it) = _i.colon_token { + tokens_helper(_visitor, &(it).0) + }; + _visitor.visit_pat(&*_i.pat); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_field_value<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast FieldValue) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_member(&_i.member); + if let Some(ref it) = _i.colon_token { + tokens_helper(_visitor, &(it).0) + }; + _visitor.visit_expr(&_i.expr); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_fields<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Fields) { + match *_i { + Fields::Named(ref _binding_0) => { + _visitor.visit_fields_named(_binding_0); + } + Fields::Unnamed(ref _binding_0) => { + _visitor.visit_fields_unnamed(_binding_0); + } + Fields::Unit => {} + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_fields_named<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast FieldsNamed) { + tokens_helper(_visitor, &(_i.brace_token).0); + for el in Punctuated::pairs(&_i.named) { + let it = el.value(); + _visitor.visit_field(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_fields_unnamed<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast FieldsUnnamed, +) { + tokens_helper(_visitor, &(_i.paren_token).0); + for el in Punctuated::pairs(&_i.unnamed) { + let it = el.value(); + _visitor.visit_field(it) + } +} +#[cfg(feature = "full")] +pub fn visit_file<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast File) { + skip!(_i.shebang); + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + for it in &_i.items { + _visitor.visit_item(it) + } +} +#[cfg(feature = "full")] +pub fn visit_fn_arg<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast FnArg) { + match *_i { + FnArg::SelfRef(ref _binding_0) => { + _visitor.visit_arg_self_ref(_binding_0); + } + FnArg::SelfValue(ref _binding_0) => { + _visitor.visit_arg_self(_binding_0); + } + FnArg::Captured(ref _binding_0) => { + _visitor.visit_arg_captured(_binding_0); + } + FnArg::Inferred(ref _binding_0) => { + _visitor.visit_pat(_binding_0); + } + FnArg::Ignored(ref _binding_0) => { + _visitor.visit_type(_binding_0); + } + } +} +#[cfg(feature = "full")] +pub fn visit_fn_decl<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast FnDecl) { + tokens_helper(_visitor, &(_i.fn_token).0); + _visitor.visit_generics(&_i.generics); + tokens_helper(_visitor, &(_i.paren_token).0); + for el in Punctuated::pairs(&_i.inputs) { + let it = el.value(); + _visitor.visit_fn_arg(it) + } + if let Some(ref it) = _i.variadic { + tokens_helper(_visitor, &(it).0) + }; + _visitor.visit_return_type(&_i.output); +} +#[cfg(feature = "full")] +pub fn visit_foreign_item<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ForeignItem) { + match *_i { + ForeignItem::Fn(ref _binding_0) => { + _visitor.visit_foreign_item_fn(_binding_0); + } + ForeignItem::Static(ref _binding_0) => { + _visitor.visit_foreign_item_static(_binding_0); + } + ForeignItem::Type(ref _binding_0) => { + _visitor.visit_foreign_item_type(_binding_0); + } + ForeignItem::Verbatim(ref _binding_0) => { + _visitor.visit_foreign_item_verbatim(_binding_0); + } + } +} +#[cfg(feature = "full")] +pub fn visit_foreign_item_fn<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast ForeignItemFn, +) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_visibility(&_i.vis); + _visitor.visit_ident(&_i.ident); + _visitor.visit_fn_decl(&*_i.decl); + tokens_helper(_visitor, &(_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_foreign_item_static<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast ForeignItemStatic, +) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_visibility(&_i.vis); + tokens_helper(_visitor, &(_i.static_token).0); + if let Some(ref it) = _i.mutability { + tokens_helper(_visitor, &(it).0) + }; + _visitor.visit_ident(&_i.ident); + tokens_helper(_visitor, &(_i.colon_token).0); + _visitor.visit_type(&*_i.ty); + tokens_helper(_visitor, &(_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_foreign_item_type<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast ForeignItemType, +) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_visibility(&_i.vis); + tokens_helper(_visitor, &(_i.type_token).0); + _visitor.visit_ident(&_i.ident); + tokens_helper(_visitor, &(_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_foreign_item_verbatim<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast ForeignItemVerbatim, +) { + skip!(_i.tts); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_generic_argument<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast GenericArgument, +) { + match *_i { + GenericArgument::Lifetime(ref _binding_0) => { + _visitor.visit_lifetime(_binding_0); + } + GenericArgument::Type(ref _binding_0) => { + _visitor.visit_type(_binding_0); + } + GenericArgument::Binding(ref _binding_0) => { + _visitor.visit_binding(_binding_0); + } + GenericArgument::Const(ref _binding_0) => { + _visitor.visit_expr(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_generic_method_argument<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast GenericMethodArgument, +) { + match *_i { + GenericMethodArgument::Type(ref _binding_0) => { + _visitor.visit_type(_binding_0); + } + GenericMethodArgument::Const(ref _binding_0) => { + _visitor.visit_expr(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_generic_param<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast GenericParam, +) { + match *_i { + GenericParam::Type(ref _binding_0) => { + _visitor.visit_type_param(_binding_0); + } + GenericParam::Lifetime(ref _binding_0) => { + _visitor.visit_lifetime_def(_binding_0); + } + GenericParam::Const(ref _binding_0) => { + _visitor.visit_const_param(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_generics<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Generics) { + if let Some(ref it) = _i.lt_token { + tokens_helper(_visitor, &(it).0) + }; + for el in Punctuated::pairs(&_i.params) { + let it = el.value(); + _visitor.visit_generic_param(it) + } + if let Some(ref it) = _i.gt_token { + tokens_helper(_visitor, &(it).0) + }; + if let Some(ref it) = _i.where_clause { + _visitor.visit_where_clause(it) + }; +} +pub fn visit_ident<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Ident) {} +#[cfg(feature = "full")] +pub fn visit_impl_item<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ImplItem) { + match *_i { + ImplItem::Const(ref _binding_0) => { + _visitor.visit_impl_item_const(_binding_0); + } + ImplItem::Method(ref _binding_0) => { + _visitor.visit_impl_item_method(_binding_0); + } + ImplItem::Type(ref _binding_0) => { + _visitor.visit_impl_item_type(_binding_0); + } + ImplItem::Macro(ref _binding_0) => { + _visitor.visit_impl_item_macro(_binding_0); + } + ImplItem::Verbatim(ref _binding_0) => { + _visitor.visit_impl_item_verbatim(_binding_0); + } + } +} +#[cfg(feature = "full")] +pub fn visit_impl_item_const<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast ImplItemConst, +) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_visibility(&_i.vis); + if let Some(ref it) = _i.defaultness { + tokens_helper(_visitor, &(it).0) + }; + tokens_helper(_visitor, &(_i.const_token).0); + _visitor.visit_ident(&_i.ident); + tokens_helper(_visitor, &(_i.colon_token).0); + _visitor.visit_type(&_i.ty); + tokens_helper(_visitor, &(_i.eq_token).0); + _visitor.visit_expr(&_i.expr); + tokens_helper(_visitor, &(_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_impl_item_macro<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast ImplItemMacro, +) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_macro(&_i.mac); + if let Some(ref it) = _i.semi_token { + tokens_helper(_visitor, &(it).0) + }; +} +#[cfg(feature = "full")] +pub fn visit_impl_item_method<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast ImplItemMethod, +) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_visibility(&_i.vis); + if let Some(ref it) = _i.defaultness { + tokens_helper(_visitor, &(it).0) + }; + _visitor.visit_method_sig(&_i.sig); + _visitor.visit_block(&_i.block); +} +#[cfg(feature = "full")] +pub fn visit_impl_item_type<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast ImplItemType, +) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_visibility(&_i.vis); + if let Some(ref it) = _i.defaultness { + tokens_helper(_visitor, &(it).0) + }; + tokens_helper(_visitor, &(_i.type_token).0); + _visitor.visit_ident(&_i.ident); + _visitor.visit_generics(&_i.generics); + tokens_helper(_visitor, &(_i.eq_token).0); + _visitor.visit_type(&_i.ty); + tokens_helper(_visitor, &(_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_impl_item_verbatim<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast ImplItemVerbatim, +) { + skip!(_i.tts); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_index<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Index) { + skip!(_i.index); + _visitor.visit_span(&_i.span); +} +#[cfg(feature = "full")] +pub fn visit_item<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Item) { + match *_i { + Item::ExternCrate(ref _binding_0) => { + _visitor.visit_item_extern_crate(_binding_0); + } + Item::Use(ref _binding_0) => { + _visitor.visit_item_use(_binding_0); + } + Item::Static(ref _binding_0) => { + _visitor.visit_item_static(_binding_0); + } + Item::Const(ref _binding_0) => { + _visitor.visit_item_const(_binding_0); + } + Item::Fn(ref _binding_0) => { + _visitor.visit_item_fn(_binding_0); + } + Item::Mod(ref _binding_0) => { + _visitor.visit_item_mod(_binding_0); + } + Item::ForeignMod(ref _binding_0) => { + _visitor.visit_item_foreign_mod(_binding_0); + } + Item::Type(ref _binding_0) => { + _visitor.visit_item_type(_binding_0); + } + Item::Struct(ref _binding_0) => { + _visitor.visit_item_struct(_binding_0); + } + Item::Enum(ref _binding_0) => { + _visitor.visit_item_enum(_binding_0); + } + Item::Union(ref _binding_0) => { + _visitor.visit_item_union(_binding_0); + } + Item::Trait(ref _binding_0) => { + _visitor.visit_item_trait(_binding_0); + } + Item::Impl(ref _binding_0) => { + _visitor.visit_item_impl(_binding_0); + } + Item::Macro(ref _binding_0) => { + _visitor.visit_item_macro(_binding_0); + } + Item::Macro2(ref _binding_0) => { + _visitor.visit_item_macro2(_binding_0); + } + Item::Verbatim(ref _binding_0) => { + _visitor.visit_item_verbatim(_binding_0); + } + } +} +#[cfg(feature = "full")] +pub fn visit_item_const<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemConst) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_visibility(&_i.vis); + tokens_helper(_visitor, &(_i.const_token).0); + _visitor.visit_ident(&_i.ident); + tokens_helper(_visitor, &(_i.colon_token).0); + _visitor.visit_type(&*_i.ty); + tokens_helper(_visitor, &(_i.eq_token).0); + _visitor.visit_expr(&*_i.expr); + tokens_helper(_visitor, &(_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_item_enum<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemEnum) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_visibility(&_i.vis); + tokens_helper(_visitor, &(_i.enum_token).0); + _visitor.visit_ident(&_i.ident); + _visitor.visit_generics(&_i.generics); + tokens_helper(_visitor, &(_i.brace_token).0); + for el in Punctuated::pairs(&_i.variants) { + let it = el.value(); + _visitor.visit_variant(it) + } +} +#[cfg(feature = "full")] +pub fn visit_item_extern_crate<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast ItemExternCrate, +) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_visibility(&_i.vis); + tokens_helper(_visitor, &(_i.extern_token).0); + tokens_helper(_visitor, &(_i.crate_token).0); + _visitor.visit_ident(&_i.ident); + if let Some(ref it) = _i.rename { + tokens_helper(_visitor, &((it).0).0); + _visitor.visit_ident(&(it).1); + }; + tokens_helper(_visitor, &(_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_item_fn<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemFn) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_visibility(&_i.vis); + if let Some(ref it) = _i.constness { + tokens_helper(_visitor, &(it).0) + }; + if let Some(ref it) = _i.unsafety { + tokens_helper(_visitor, &(it).0) + }; + if let Some(ref it) = _i.abi { + _visitor.visit_abi(it) + }; + _visitor.visit_ident(&_i.ident); + _visitor.visit_fn_decl(&*_i.decl); + _visitor.visit_block(&*_i.block); +} +#[cfg(feature = "full")] +pub fn visit_item_foreign_mod<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast ItemForeignMod, +) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_abi(&_i.abi); + tokens_helper(_visitor, &(_i.brace_token).0); + for it in &_i.items { + _visitor.visit_foreign_item(it) + } +} +#[cfg(feature = "full")] +pub fn visit_item_impl<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemImpl) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + if let Some(ref it) = _i.defaultness { + tokens_helper(_visitor, &(it).0) + }; + if let Some(ref it) = _i.unsafety { + tokens_helper(_visitor, &(it).0) + }; + tokens_helper(_visitor, &(_i.impl_token).0); + _visitor.visit_generics(&_i.generics); + if let Some(ref it) = _i.trait_ { + if let Some(ref it) = (it).0 { + tokens_helper(_visitor, &(it).0) + }; + _visitor.visit_path(&(it).1); + tokens_helper(_visitor, &((it).2).0); + }; + _visitor.visit_type(&*_i.self_ty); + tokens_helper(_visitor, &(_i.brace_token).0); + for it in &_i.items { + _visitor.visit_impl_item(it) + } +} +#[cfg(feature = "full")] +pub fn visit_item_macro<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemMacro) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + if let Some(ref it) = _i.ident { + _visitor.visit_ident(it) + }; + _visitor.visit_macro(&_i.mac); + if let Some(ref it) = _i.semi_token { + tokens_helper(_visitor, &(it).0) + }; +} +#[cfg(feature = "full")] +pub fn visit_item_macro2<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemMacro2) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_visibility(&_i.vis); + tokens_helper(_visitor, &(_i.macro_token).0); + _visitor.visit_ident(&_i.ident); + tokens_helper(_visitor, &(_i.paren_token).0); + skip!(_i.args); + tokens_helper(_visitor, &(_i.brace_token).0); + skip!(_i.body); +} +#[cfg(feature = "full")] +pub fn visit_item_mod<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemMod) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_visibility(&_i.vis); + tokens_helper(_visitor, &(_i.mod_token).0); + _visitor.visit_ident(&_i.ident); + if let Some(ref it) = _i.content { + tokens_helper(_visitor, &((it).0).0); + for it in &(it).1 { + _visitor.visit_item(it) + } + }; + if let Some(ref it) = _i.semi { + tokens_helper(_visitor, &(it).0) + }; +} +#[cfg(feature = "full")] +pub fn visit_item_static<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemStatic) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_visibility(&_i.vis); + tokens_helper(_visitor, &(_i.static_token).0); + if let Some(ref it) = _i.mutability { + tokens_helper(_visitor, &(it).0) + }; + _visitor.visit_ident(&_i.ident); + tokens_helper(_visitor, &(_i.colon_token).0); + _visitor.visit_type(&*_i.ty); + tokens_helper(_visitor, &(_i.eq_token).0); + _visitor.visit_expr(&*_i.expr); + tokens_helper(_visitor, &(_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_item_struct<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemStruct) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_visibility(&_i.vis); + tokens_helper(_visitor, &(_i.struct_token).0); + _visitor.visit_ident(&_i.ident); + _visitor.visit_generics(&_i.generics); + _visitor.visit_fields(&_i.fields); + if let Some(ref it) = _i.semi_token { + tokens_helper(_visitor, &(it).0) + }; +} +#[cfg(feature = "full")] +pub fn visit_item_trait<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemTrait) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_visibility(&_i.vis); + if let Some(ref it) = _i.unsafety { + tokens_helper(_visitor, &(it).0) + }; + if let Some(ref it) = _i.auto_token { + tokens_helper(_visitor, &(it).0) + }; + tokens_helper(_visitor, &(_i.trait_token).0); + _visitor.visit_ident(&_i.ident); + _visitor.visit_generics(&_i.generics); + if let Some(ref it) = _i.colon_token { + tokens_helper(_visitor, &(it).0) + }; + for el in Punctuated::pairs(&_i.supertraits) { + let it = el.value(); + _visitor.visit_type_param_bound(it) + } + tokens_helper(_visitor, &(_i.brace_token).0); + for it in &_i.items { + _visitor.visit_trait_item(it) + } +} +#[cfg(feature = "full")] +pub fn visit_item_type<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemType) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_visibility(&_i.vis); + tokens_helper(_visitor, &(_i.type_token).0); + _visitor.visit_ident(&_i.ident); + _visitor.visit_generics(&_i.generics); + tokens_helper(_visitor, &(_i.eq_token).0); + _visitor.visit_type(&*_i.ty); + tokens_helper(_visitor, &(_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_item_union<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemUnion) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_visibility(&_i.vis); + tokens_helper(_visitor, &(_i.union_token).0); + _visitor.visit_ident(&_i.ident); + _visitor.visit_generics(&_i.generics); + _visitor.visit_fields_named(&_i.fields); +} +#[cfg(feature = "full")] +pub fn visit_item_use<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ItemUse) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_visibility(&_i.vis); + tokens_helper(_visitor, &(_i.use_token).0); + if let Some(ref it) = _i.leading_colon { + tokens_helper(_visitor, &(it).0) + }; + _visitor.visit_use_tree(&_i.tree); + tokens_helper(_visitor, &(_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_item_verbatim<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast ItemVerbatim, +) { + skip!(_i.tts); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_label<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Label) { + _visitor.visit_lifetime(&_i.name); + tokens_helper(_visitor, &(_i.colon_token).0); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_lifetime<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Lifetime) { + skip!(_i.apostrophe); + _visitor.visit_ident(&_i.ident); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_lifetime_def<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast LifetimeDef) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_lifetime(&_i.lifetime); + if let Some(ref it) = _i.colon_token { + tokens_helper(_visitor, &(it).0) + }; + for el in Punctuated::pairs(&_i.bounds) { + let it = el.value(); + _visitor.visit_lifetime(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_lit<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Lit) { + match *_i { + Lit::Str(ref _binding_0) => { + _visitor.visit_lit_str(_binding_0); + } + Lit::ByteStr(ref _binding_0) => { + _visitor.visit_lit_byte_str(_binding_0); + } + Lit::Byte(ref _binding_0) => { + _visitor.visit_lit_byte(_binding_0); + } + Lit::Char(ref _binding_0) => { + _visitor.visit_lit_char(_binding_0); + } + Lit::Int(ref _binding_0) => { + _visitor.visit_lit_int(_binding_0); + } + Lit::Float(ref _binding_0) => { + _visitor.visit_lit_float(_binding_0); + } + Lit::Bool(ref _binding_0) => { + _visitor.visit_lit_bool(_binding_0); + } + Lit::Verbatim(ref _binding_0) => { + _visitor.visit_lit_verbatim(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_lit_bool<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast LitBool) { + skip!(_i.value); + _visitor.visit_span(&_i.span); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_lit_byte<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast LitByte) { + skip!(_i.token); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_lit_byte_str<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast LitByteStr) { + skip!(_i.token); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_lit_char<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast LitChar) { + skip!(_i.token); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_lit_float<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast LitFloat) { + skip!(_i.token); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_lit_int<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast LitInt) { + skip!(_i.token); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_lit_str<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast LitStr) { + skip!(_i.token); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_lit_verbatim<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast LitVerbatim) { + skip!(_i.token); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_local<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Local) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + tokens_helper(_visitor, &(_i.let_token).0); + for el in Punctuated::pairs(&_i.pats) { + let it = el.value(); + _visitor.visit_pat(it) + } + if let Some(ref it) = _i.ty { + tokens_helper(_visitor, &((it).0).0); + _visitor.visit_type(&*(it).1); + }; + if let Some(ref it) = _i.init { + tokens_helper(_visitor, &((it).0).0); + _visitor.visit_expr(&*(it).1); + }; + tokens_helper(_visitor, &(_i.semi_token).0); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_macro<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Macro) { + _visitor.visit_path(&_i.path); + tokens_helper(_visitor, &(_i.bang_token).0); + _visitor.visit_macro_delimiter(&_i.delimiter); + skip!(_i.tts); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_macro_delimiter<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast MacroDelimiter, +) { + match *_i { + MacroDelimiter::Paren(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + MacroDelimiter::Brace(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + MacroDelimiter::Bracket(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_member<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Member) { + match *_i { + Member::Named(ref _binding_0) => { + _visitor.visit_ident(_binding_0); + } + Member::Unnamed(ref _binding_0) => { + _visitor.visit_index(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_meta<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Meta) { + match *_i { + Meta::Word(ref _binding_0) => { + _visitor.visit_ident(_binding_0); + } + Meta::List(ref _binding_0) => { + _visitor.visit_meta_list(_binding_0); + } + Meta::NameValue(ref _binding_0) => { + _visitor.visit_meta_name_value(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_meta_list<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast MetaList) { + _visitor.visit_ident(&_i.ident); + tokens_helper(_visitor, &(_i.paren_token).0); + for el in Punctuated::pairs(&_i.nested) { + let it = el.value(); + _visitor.visit_nested_meta(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_meta_name_value<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast MetaNameValue, +) { + _visitor.visit_ident(&_i.ident); + tokens_helper(_visitor, &(_i.eq_token).0); + _visitor.visit_lit(&_i.lit); +} +#[cfg(feature = "full")] +pub fn visit_method_sig<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast MethodSig) { + if let Some(ref it) = _i.constness { + tokens_helper(_visitor, &(it).0) + }; + if let Some(ref it) = _i.unsafety { + tokens_helper(_visitor, &(it).0) + }; + if let Some(ref it) = _i.abi { + _visitor.visit_abi(it) + }; + _visitor.visit_ident(&_i.ident); + _visitor.visit_fn_decl(&_i.decl); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_method_turbofish<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast MethodTurbofish, +) { + tokens_helper(_visitor, &(_i.colon2_token).0); + tokens_helper(_visitor, &(_i.lt_token).0); + for el in Punctuated::pairs(&_i.args) { + let it = el.value(); + _visitor.visit_generic_method_argument(it) + } + tokens_helper(_visitor, &(_i.gt_token).0); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_nested_meta<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast NestedMeta) { + match *_i { + NestedMeta::Meta(ref _binding_0) => { + _visitor.visit_meta(_binding_0); + } + NestedMeta::Literal(ref _binding_0) => { + _visitor.visit_lit(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_parenthesized_generic_arguments<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast ParenthesizedGenericArguments, +) { + tokens_helper(_visitor, &(_i.paren_token).0); + for el in Punctuated::pairs(&_i.inputs) { + let it = el.value(); + _visitor.visit_type(it) + } + _visitor.visit_return_type(&_i.output); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Pat) { + match *_i { + Pat::Wild(ref _binding_0) => { + _visitor.visit_pat_wild(_binding_0); + } + Pat::Ident(ref _binding_0) => { + _visitor.visit_pat_ident(_binding_0); + } + Pat::Struct(ref _binding_0) => { + _visitor.visit_pat_struct(_binding_0); + } + Pat::TupleStruct(ref _binding_0) => { + _visitor.visit_pat_tuple_struct(_binding_0); + } + Pat::Path(ref _binding_0) => { + _visitor.visit_pat_path(_binding_0); + } + Pat::Tuple(ref _binding_0) => { + _visitor.visit_pat_tuple(_binding_0); + } + Pat::Box(ref _binding_0) => { + _visitor.visit_pat_box(_binding_0); + } + Pat::Ref(ref _binding_0) => { + _visitor.visit_pat_ref(_binding_0); + } + Pat::Lit(ref _binding_0) => { + _visitor.visit_pat_lit(_binding_0); + } + Pat::Range(ref _binding_0) => { + _visitor.visit_pat_range(_binding_0); + } + Pat::Slice(ref _binding_0) => { + _visitor.visit_pat_slice(_binding_0); + } + Pat::Macro(ref _binding_0) => { + _visitor.visit_pat_macro(_binding_0); + } + Pat::Verbatim(ref _binding_0) => { + _visitor.visit_pat_verbatim(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_box<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatBox) { + tokens_helper(_visitor, &(_i.box_token).0); + _visitor.visit_pat(&*_i.pat); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_ident<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatIdent) { + if let Some(ref it) = _i.by_ref { + tokens_helper(_visitor, &(it).0) + }; + if let Some(ref it) = _i.mutability { + tokens_helper(_visitor, &(it).0) + }; + _visitor.visit_ident(&_i.ident); + if let Some(ref it) = _i.subpat { + tokens_helper(_visitor, &((it).0).0); + _visitor.visit_pat(&*(it).1); + }; +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_lit<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatLit) { + _visitor.visit_expr(&*_i.expr); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_macro<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatMacro) { + _visitor.visit_macro(&_i.mac); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_path<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatPath) { + if let Some(ref it) = _i.qself { + _visitor.visit_qself(it) + }; + _visitor.visit_path(&_i.path); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_range<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatRange) { + _visitor.visit_expr(&*_i.lo); + _visitor.visit_range_limits(&_i.limits); + _visitor.visit_expr(&*_i.hi); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_ref<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatRef) { + tokens_helper(_visitor, &(_i.and_token).0); + if let Some(ref it) = _i.mutability { + tokens_helper(_visitor, &(it).0) + }; + _visitor.visit_pat(&*_i.pat); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_slice<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatSlice) { + tokens_helper(_visitor, &(_i.bracket_token).0); + for el in Punctuated::pairs(&_i.front) { + let it = el.value(); + _visitor.visit_pat(it) + } + if let Some(ref it) = _i.middle { + _visitor.visit_pat(&**it) + }; + if let Some(ref it) = _i.dot2_token { + tokens_helper(_visitor, &(it).0) + }; + if let Some(ref it) = _i.comma_token { + tokens_helper(_visitor, &(it).0) + }; + for el in Punctuated::pairs(&_i.back) { + let it = el.value(); + _visitor.visit_pat(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_struct<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatStruct) { + _visitor.visit_path(&_i.path); + tokens_helper(_visitor, &(_i.brace_token).0); + for el in Punctuated::pairs(&_i.fields) { + let it = el.value(); + _visitor.visit_field_pat(it) + } + if let Some(ref it) = _i.dot2_token { + tokens_helper(_visitor, &(it).0) + }; +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_tuple<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatTuple) { + tokens_helper(_visitor, &(_i.paren_token).0); + for el in Punctuated::pairs(&_i.front) { + let it = el.value(); + _visitor.visit_pat(it) + } + if let Some(ref it) = _i.dot2_token { + tokens_helper(_visitor, &(it).0) + }; + if let Some(ref it) = _i.comma_token { + tokens_helper(_visitor, &(it).0) + }; + for el in Punctuated::pairs(&_i.back) { + let it = el.value(); + _visitor.visit_pat(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_tuple_struct<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast PatTupleStruct, +) { + _visitor.visit_path(&_i.path); + _visitor.visit_pat_tuple(&_i.pat); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_verbatim<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatVerbatim) { + skip!(_i.tts); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_pat_wild<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PatWild) { + tokens_helper(_visitor, &(_i.underscore_token).0); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_path<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Path) { + if let Some(ref it) = _i.leading_colon { + tokens_helper(_visitor, &(it).0) + }; + for el in Punctuated::pairs(&_i.segments) { + let it = el.value(); + _visitor.visit_path_segment(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_path_arguments<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast PathArguments, +) { + match *_i { + PathArguments::None => {} + PathArguments::AngleBracketed(ref _binding_0) => { + _visitor.visit_angle_bracketed_generic_arguments(_binding_0); + } + PathArguments::Parenthesized(ref _binding_0) => { + _visitor.visit_parenthesized_generic_arguments(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_path_segment<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PathSegment) { + _visitor.visit_ident(&_i.ident); + _visitor.visit_path_arguments(&_i.arguments); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_predicate_eq<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast PredicateEq) { + _visitor.visit_type(&_i.lhs_ty); + tokens_helper(_visitor, &(_i.eq_token).0); + _visitor.visit_type(&_i.rhs_ty); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_predicate_lifetime<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast PredicateLifetime, +) { + _visitor.visit_lifetime(&_i.lifetime); + if let Some(ref it) = _i.colon_token { + tokens_helper(_visitor, &(it).0) + }; + for el in Punctuated::pairs(&_i.bounds) { + let it = el.value(); + _visitor.visit_lifetime(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_predicate_type<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast PredicateType, +) { + if let Some(ref it) = _i.lifetimes { + _visitor.visit_bound_lifetimes(it) + }; + _visitor.visit_type(&_i.bounded_ty); + tokens_helper(_visitor, &(_i.colon_token).0); + for el in Punctuated::pairs(&_i.bounds) { + let it = el.value(); + _visitor.visit_type_param_bound(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_qself<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast QSelf) { + tokens_helper(_visitor, &(_i.lt_token).0); + _visitor.visit_type(&*_i.ty); + skip!(_i.position); + if let Some(ref it) = _i.as_token { + tokens_helper(_visitor, &(it).0) + }; + tokens_helper(_visitor, &(_i.gt_token).0); +} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_range_limits<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast RangeLimits) { + match *_i { + RangeLimits::HalfOpen(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + RangeLimits::Closed(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_return_type<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast ReturnType) { + match *_i { + ReturnType::Default => {} + ReturnType::Type(ref _binding_0, ref _binding_1) => { + tokens_helper(_visitor, &(_binding_0).0); + _visitor.visit_type(&**_binding_1); + } + } +} +pub fn visit_span<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Span) {} +#[cfg(any(feature = "full", feature = "derive"))] +#[cfg(feature = "full")] +pub fn visit_stmt<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Stmt) { + match *_i { + Stmt::Local(ref _binding_0) => { + _visitor.visit_local(_binding_0); + } + Stmt::Item(ref _binding_0) => { + _visitor.visit_item(_binding_0); + } + Stmt::Expr(ref _binding_0) => { + _visitor.visit_expr(_binding_0); + } + Stmt::Semi(ref _binding_0, ref _binding_1) => { + _visitor.visit_expr(_binding_0); + tokens_helper(_visitor, &(_binding_1).0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_trait_bound<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TraitBound) { + if let Some(ref it) = _i.paren_token { + tokens_helper(_visitor, &(it).0) + }; + _visitor.visit_trait_bound_modifier(&_i.modifier); + if let Some(ref it) = _i.lifetimes { + _visitor.visit_bound_lifetimes(it) + }; + _visitor.visit_path(&_i.path); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_trait_bound_modifier<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast TraitBoundModifier, +) { + match *_i { + TraitBoundModifier::None => {} + TraitBoundModifier::Maybe(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + } +} +#[cfg(feature = "full")] +pub fn visit_trait_item<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TraitItem) { + match *_i { + TraitItem::Const(ref _binding_0) => { + _visitor.visit_trait_item_const(_binding_0); + } + TraitItem::Method(ref _binding_0) => { + _visitor.visit_trait_item_method(_binding_0); + } + TraitItem::Type(ref _binding_0) => { + _visitor.visit_trait_item_type(_binding_0); + } + TraitItem::Macro(ref _binding_0) => { + _visitor.visit_trait_item_macro(_binding_0); + } + TraitItem::Verbatim(ref _binding_0) => { + _visitor.visit_trait_item_verbatim(_binding_0); + } + } +} +#[cfg(feature = "full")] +pub fn visit_trait_item_const<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast TraitItemConst, +) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + tokens_helper(_visitor, &(_i.const_token).0); + _visitor.visit_ident(&_i.ident); + tokens_helper(_visitor, &(_i.colon_token).0); + _visitor.visit_type(&_i.ty); + if let Some(ref it) = _i.default { + tokens_helper(_visitor, &((it).0).0); + _visitor.visit_expr(&(it).1); + }; + tokens_helper(_visitor, &(_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_trait_item_macro<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast TraitItemMacro, +) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_macro(&_i.mac); + if let Some(ref it) = _i.semi_token { + tokens_helper(_visitor, &(it).0) + }; +} +#[cfg(feature = "full")] +pub fn visit_trait_item_method<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast TraitItemMethod, +) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_method_sig(&_i.sig); + if let Some(ref it) = _i.default { + _visitor.visit_block(it) + }; + if let Some(ref it) = _i.semi_token { + tokens_helper(_visitor, &(it).0) + }; +} +#[cfg(feature = "full")] +pub fn visit_trait_item_type<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast TraitItemType, +) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + tokens_helper(_visitor, &(_i.type_token).0); + _visitor.visit_ident(&_i.ident); + _visitor.visit_generics(&_i.generics); + if let Some(ref it) = _i.colon_token { + tokens_helper(_visitor, &(it).0) + }; + for el in Punctuated::pairs(&_i.bounds) { + let it = el.value(); + _visitor.visit_type_param_bound(it) + } + if let Some(ref it) = _i.default { + tokens_helper(_visitor, &((it).0).0); + _visitor.visit_type(&(it).1); + }; + tokens_helper(_visitor, &(_i.semi_token).0); +} +#[cfg(feature = "full")] +pub fn visit_trait_item_verbatim<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast TraitItemVerbatim, +) { + skip!(_i.tts); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Type) { + match *_i { + Type::Slice(ref _binding_0) => { + _visitor.visit_type_slice(_binding_0); + } + Type::Array(ref _binding_0) => { + _visitor.visit_type_array(_binding_0); + } + Type::Ptr(ref _binding_0) => { + _visitor.visit_type_ptr(_binding_0); + } + Type::Reference(ref _binding_0) => { + _visitor.visit_type_reference(_binding_0); + } + Type::BareFn(ref _binding_0) => { + _visitor.visit_type_bare_fn(_binding_0); + } + Type::Never(ref _binding_0) => { + _visitor.visit_type_never(_binding_0); + } + Type::Tuple(ref _binding_0) => { + _visitor.visit_type_tuple(_binding_0); + } + Type::Path(ref _binding_0) => { + _visitor.visit_type_path(_binding_0); + } + Type::TraitObject(ref _binding_0) => { + _visitor.visit_type_trait_object(_binding_0); + } + Type::ImplTrait(ref _binding_0) => { + _visitor.visit_type_impl_trait(_binding_0); + } + Type::Paren(ref _binding_0) => { + _visitor.visit_type_paren(_binding_0); + } + Type::Group(ref _binding_0) => { + _visitor.visit_type_group(_binding_0); + } + Type::Infer(ref _binding_0) => { + _visitor.visit_type_infer(_binding_0); + } + Type::Macro(ref _binding_0) => { + _visitor.visit_type_macro(_binding_0); + } + Type::Verbatim(ref _binding_0) => { + _visitor.visit_type_verbatim(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_array<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypeArray) { + tokens_helper(_visitor, &(_i.bracket_token).0); + _visitor.visit_type(&*_i.elem); + tokens_helper(_visitor, &(_i.semi_token).0); + _visitor.visit_expr(&_i.len); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_bare_fn<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypeBareFn) { + if let Some(ref it) = _i.unsafety { + tokens_helper(_visitor, &(it).0) + }; + if let Some(ref it) = _i.abi { + _visitor.visit_abi(it) + }; + tokens_helper(_visitor, &(_i.fn_token).0); + if let Some(ref it) = _i.lifetimes { + _visitor.visit_bound_lifetimes(it) + }; + tokens_helper(_visitor, &(_i.paren_token).0); + for el in Punctuated::pairs(&_i.inputs) { + let it = el.value(); + _visitor.visit_bare_fn_arg(it) + } + if let Some(ref it) = _i.variadic { + tokens_helper(_visitor, &(it).0) + }; + _visitor.visit_return_type(&_i.output); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_group<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypeGroup) { + tokens_helper(_visitor, &(_i.group_token).0); + _visitor.visit_type(&*_i.elem); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_impl_trait<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast TypeImplTrait, +) { + tokens_helper(_visitor, &(_i.impl_token).0); + for el in Punctuated::pairs(&_i.bounds) { + let it = el.value(); + _visitor.visit_type_param_bound(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_infer<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypeInfer) { + tokens_helper(_visitor, &(_i.underscore_token).0); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_macro<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypeMacro) { + _visitor.visit_macro(&_i.mac); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_never<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypeNever) { + tokens_helper(_visitor, &(_i.bang_token).0); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_param<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypeParam) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_ident(&_i.ident); + if let Some(ref it) = _i.colon_token { + tokens_helper(_visitor, &(it).0) + }; + for el in Punctuated::pairs(&_i.bounds) { + let it = el.value(); + _visitor.visit_type_param_bound(it) + } + if let Some(ref it) = _i.eq_token { + tokens_helper(_visitor, &(it).0) + }; + if let Some(ref it) = _i.default { + _visitor.visit_type(it) + }; +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_param_bound<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast TypeParamBound, +) { + match *_i { + TypeParamBound::Trait(ref _binding_0) => { + _visitor.visit_trait_bound(_binding_0); + } + TypeParamBound::Lifetime(ref _binding_0) => { + _visitor.visit_lifetime(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_paren<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypeParen) { + tokens_helper(_visitor, &(_i.paren_token).0); + _visitor.visit_type(&*_i.elem); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_path<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypePath) { + if let Some(ref it) = _i.qself { + _visitor.visit_qself(it) + }; + _visitor.visit_path(&_i.path); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_ptr<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypePtr) { + tokens_helper(_visitor, &(_i.star_token).0); + if let Some(ref it) = _i.const_token { + tokens_helper(_visitor, &(it).0) + }; + if let Some(ref it) = _i.mutability { + tokens_helper(_visitor, &(it).0) + }; + _visitor.visit_type(&*_i.elem); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_reference<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast TypeReference, +) { + tokens_helper(_visitor, &(_i.and_token).0); + if let Some(ref it) = _i.lifetime { + _visitor.visit_lifetime(it) + }; + if let Some(ref it) = _i.mutability { + tokens_helper(_visitor, &(it).0) + }; + _visitor.visit_type(&*_i.elem); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_slice<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypeSlice) { + tokens_helper(_visitor, &(_i.bracket_token).0); + _visitor.visit_type(&*_i.elem); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_trait_object<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast TypeTraitObject, +) { + if let Some(ref it) = _i.dyn_token { + tokens_helper(_visitor, &(it).0) + }; + for el in Punctuated::pairs(&_i.bounds) { + let it = el.value(); + _visitor.visit_type_param_bound(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_tuple<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast TypeTuple) { + tokens_helper(_visitor, &(_i.paren_token).0); + for el in Punctuated::pairs(&_i.elems) { + let it = el.value(); + _visitor.visit_type(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_type_verbatim<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast TypeVerbatim, +) { + skip!(_i.tts); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_un_op<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast UnOp) { + match *_i { + UnOp::Deref(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + UnOp::Not(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + UnOp::Neg(ref _binding_0) => { + tokens_helper(_visitor, &(_binding_0).0); + } + } +} +#[cfg(feature = "full")] +pub fn visit_use_glob<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast UseGlob) { + tokens_helper(_visitor, &(_i.star_token).0); +} +#[cfg(feature = "full")] +pub fn visit_use_group<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast UseGroup) { + tokens_helper(_visitor, &(_i.brace_token).0); + for el in Punctuated::pairs(&_i.items) { + let it = el.value(); + _visitor.visit_use_tree(it) + } +} +#[cfg(feature = "full")] +pub fn visit_use_name<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast UseName) { + _visitor.visit_ident(&_i.ident); +} +#[cfg(feature = "full")] +pub fn visit_use_path<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast UsePath) { + _visitor.visit_ident(&_i.ident); + tokens_helper(_visitor, &(_i.colon2_token).0); + _visitor.visit_use_tree(&*_i.tree); +} +#[cfg(feature = "full")] +pub fn visit_use_rename<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast UseRename) { + _visitor.visit_ident(&_i.ident); + tokens_helper(_visitor, &(_i.as_token).0); + _visitor.visit_ident(&_i.rename); +} +#[cfg(feature = "full")] +pub fn visit_use_tree<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast UseTree) { + match *_i { + UseTree::Path(ref _binding_0) => { + _visitor.visit_use_path(_binding_0); + } + UseTree::Name(ref _binding_0) => { + _visitor.visit_use_name(_binding_0); + } + UseTree::Rename(ref _binding_0) => { + _visitor.visit_use_rename(_binding_0); + } + UseTree::Glob(ref _binding_0) => { + _visitor.visit_use_glob(_binding_0); + } + UseTree::Group(ref _binding_0) => { + _visitor.visit_use_group(_binding_0); + } + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_variant<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Variant) { + for it in &_i.attrs { + _visitor.visit_attribute(it) + } + _visitor.visit_ident(&_i.ident); + _visitor.visit_fields(&_i.fields); + if let Some(ref it) = _i.discriminant { + tokens_helper(_visitor, &((it).0).0); + _visitor.visit_expr(&(it).1); + }; +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_vis_crate<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast VisCrate) { + tokens_helper(_visitor, &(_i.crate_token).0); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_vis_public<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast VisPublic) { + tokens_helper(_visitor, &(_i.pub_token).0); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_vis_restricted<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast VisRestricted, +) { + tokens_helper(_visitor, &(_i.pub_token).0); + tokens_helper(_visitor, &(_i.paren_token).0); + if let Some(ref it) = _i.in_token { + tokens_helper(_visitor, &(it).0) + }; + _visitor.visit_path(&*_i.path); +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_visibility<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast Visibility) { + match *_i { + Visibility::Public(ref _binding_0) => { + _visitor.visit_vis_public(_binding_0); + } + Visibility::Crate(ref _binding_0) => { + _visitor.visit_vis_crate(_binding_0); + } + Visibility::Restricted(ref _binding_0) => { + _visitor.visit_vis_restricted(_binding_0); + } + Visibility::Inherited => {} + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_where_clause<'ast, V: Visit<'ast> + ?Sized>(_visitor: &mut V, _i: &'ast WhereClause) { + tokens_helper(_visitor, &(_i.where_token).0); + for el in Punctuated::pairs(&_i.predicates) { + let it = el.value(); + _visitor.visit_where_predicate(it) + } +} +#[cfg(any(feature = "full", feature = "derive"))] +pub fn visit_where_predicate<'ast, V: Visit<'ast> + ?Sized>( + _visitor: &mut V, + _i: &'ast WherePredicate, +) { + match *_i { + WherePredicate::Type(ref _binding_0) => { + _visitor.visit_predicate_type(_binding_0); + } + WherePredicate::Lifetime(ref _binding_0) => { + _visitor.visit_predicate_lifetime(_binding_0); + } + WherePredicate::Eq(ref _binding_0) => { + _visitor.visit_predicate_eq(_binding_0); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/generics.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/generics.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/generics.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/generics.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,1015 @@ +// Copyright 2018 Syn Developers +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use super::*; +use punctuated::{Iter, IterMut, Punctuated}; + +ast_struct! { + /// Lifetimes and type parameters attached to a declaration of a function, + /// enum, trait, etc. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + #[derive(Default)] + pub struct Generics { + pub lt_token: Option, + pub params: Punctuated, + pub gt_token: Option]>, + pub where_clause: Option, + } +} + +ast_enum_of_structs! { + /// A generic type parameter, lifetime, or const generic: `T: Into`, + /// `'a: 'b`, `const LEN: usize`. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + /// + /// # Syntax tree enum + /// + /// This type is a [syntax tree enum]. + /// + /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums + pub enum GenericParam { + /// A generic type parameter: `T: Into`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Type(TypeParam { + pub attrs: Vec, + pub ident: Ident, + pub colon_token: Option, + pub bounds: Punctuated, + pub eq_token: Option, + pub default: Option, + }), + + /// A lifetime definition: `'a: 'b + 'c + 'd`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Lifetime(LifetimeDef { + pub attrs: Vec, + pub lifetime: Lifetime, + pub colon_token: Option, + pub bounds: Punctuated, + }), + + /// A const generic parameter: `const LENGTH: usize`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Const(ConstParam { + pub attrs: Vec, + pub const_token: Token![const], + pub ident: Ident, + pub colon_token: Token![:], + pub ty: Type, + pub eq_token: Option, + pub default: Option, + }), + } +} + +impl Generics { + /// Returns an + /// Iterator<Item = &TypeParam> + /// over the type parameters in `self.params`. + pub fn type_params(&self) -> TypeParams { + TypeParams(self.params.iter()) + } + + /// Returns an + /// Iterator<Item = &mut TypeParam> + /// over the type parameters in `self.params`. + pub fn type_params_mut(&mut self) -> TypeParamsMut { + TypeParamsMut(self.params.iter_mut()) + } + + /// Returns an + /// Iterator<Item = &LifetimeDef> + /// over the lifetime parameters in `self.params`. + pub fn lifetimes(&self) -> Lifetimes { + Lifetimes(self.params.iter()) + } + + /// Returns an + /// Iterator<Item = &mut LifetimeDef> + /// over the lifetime parameters in `self.params`. + pub fn lifetimes_mut(&mut self) -> LifetimesMut { + LifetimesMut(self.params.iter_mut()) + } + + /// Returns an + /// Iterator<Item = &ConstParam> + /// over the constant parameters in `self.params`. + pub fn const_params(&self) -> ConstParams { + ConstParams(self.params.iter()) + } + + /// Returns an + /// Iterator<Item = &mut ConstParam> + /// over the constant parameters in `self.params`. + pub fn const_params_mut(&mut self) -> ConstParamsMut { + ConstParamsMut(self.params.iter_mut()) + } + + /// Initializes an empty `where`-clause if there is not one present already. + pub fn make_where_clause(&mut self) -> &mut WhereClause { + // This is Option::get_or_insert_with in Rust 1.20. + if self.where_clause.is_none() { + self.where_clause = Some(WhereClause { + where_token: ::default(), + predicates: Punctuated::new(), + }); + } + match self.where_clause { + Some(ref mut where_clause) => where_clause, + None => unreachable!(), + } + } +} + +pub struct TypeParams<'a>(Iter<'a, GenericParam>); + +impl<'a> Iterator for TypeParams<'a> { + type Item = &'a TypeParam; + + fn next(&mut self) -> Option { + // FIXME: Remove this when ? on Option is stable + let next = match self.0.next() { + Some(item) => item, + None => return None, + }; + if let GenericParam::Type(ref type_param) = *next { + Some(type_param) + } else { + self.next() + } + } +} + +pub struct TypeParamsMut<'a>(IterMut<'a, GenericParam>); + +impl<'a> Iterator for TypeParamsMut<'a> { + type Item = &'a mut TypeParam; + + fn next(&mut self) -> Option { + // FIXME: Remove this when ? on Option is stable + let next = match self.0.next() { + Some(item) => item, + None => return None, + }; + if let GenericParam::Type(ref mut type_param) = *next { + Some(type_param) + } else { + self.next() + } + } +} + +pub struct Lifetimes<'a>(Iter<'a, GenericParam>); + +impl<'a> Iterator for Lifetimes<'a> { + type Item = &'a LifetimeDef; + + fn next(&mut self) -> Option { + // FIXME: Remove this when ? on Option is stable + let next = match self.0.next() { + Some(item) => item, + None => return None, + }; + if let GenericParam::Lifetime(ref lifetime) = *next { + Some(lifetime) + } else { + self.next() + } + } +} + +pub struct LifetimesMut<'a>(IterMut<'a, GenericParam>); + +impl<'a> Iterator for LifetimesMut<'a> { + type Item = &'a mut LifetimeDef; + + fn next(&mut self) -> Option { + // FIXME: Remove this when ? on Option is stable + let next = match self.0.next() { + Some(item) => item, + None => return None, + }; + if let GenericParam::Lifetime(ref mut lifetime) = *next { + Some(lifetime) + } else { + self.next() + } + } +} + +pub struct ConstParams<'a>(Iter<'a, GenericParam>); + +impl<'a> Iterator for ConstParams<'a> { + type Item = &'a ConstParam; + + fn next(&mut self) -> Option { + // FIXME: Remove this when ? on Option is stable + let next = match self.0.next() { + Some(item) => item, + None => return None, + }; + if let GenericParam::Const(ref const_param) = *next { + Some(const_param) + } else { + self.next() + } + } +} + +pub struct ConstParamsMut<'a>(IterMut<'a, GenericParam>); + +impl<'a> Iterator for ConstParamsMut<'a> { + type Item = &'a mut ConstParam; + + fn next(&mut self) -> Option { + // FIXME: Remove this when ? on Option is stable + let next = match self.0.next() { + Some(item) => item, + None => return None, + }; + if let GenericParam::Const(ref mut const_param) = *next { + Some(const_param) + } else { + self.next() + } + } +} + +/// Returned by `Generics::split_for_impl`. +/// +/// *This type is available if Syn is built with the `"derive"` or `"full"` +/// feature and the `"printing"` feature.* +#[cfg(feature = "printing")] +#[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))] +#[cfg_attr(feature = "clone-impls", derive(Clone))] +pub struct ImplGenerics<'a>(&'a Generics); + +/// Returned by `Generics::split_for_impl`. +/// +/// *This type is available if Syn is built with the `"derive"` or `"full"` +/// feature and the `"printing"` feature.* +#[cfg(feature = "printing")] +#[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))] +#[cfg_attr(feature = "clone-impls", derive(Clone))] +pub struct TypeGenerics<'a>(&'a Generics); + +/// Returned by `TypeGenerics::as_turbofish`. +/// +/// *This type is available if Syn is built with the `"derive"` or `"full"` +/// feature and the `"printing"` feature.* +#[cfg(feature = "printing")] +#[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))] +#[cfg_attr(feature = "clone-impls", derive(Clone))] +pub struct Turbofish<'a>(&'a Generics); + +#[cfg(feature = "printing")] +impl Generics { + /// Split a type's generics into the pieces required for impl'ing a trait + /// for that type. + /// + /// ``` + /// # extern crate proc_macro2; + /// # extern crate syn; + /// # #[macro_use] + /// # extern crate quote; + /// # use proc_macro2::{Span, Ident}; + /// # fn main() { + /// # let generics: syn::Generics = Default::default(); + /// # let name = Ident::new("MyType", Span::call_site()); + /// let (impl_generics, ty_generics, where_clause) = generics.split_for_impl(); + /// quote! { + /// impl #impl_generics MyTrait for #name #ty_generics #where_clause { + /// // ... + /// } + /// } + /// # ; + /// # } + /// ``` + /// + /// *This method is available if Syn is built with the `"derive"` or + /// `"full"` feature and the `"printing"` feature.* + pub fn split_for_impl(&self) -> (ImplGenerics, TypeGenerics, Option<&WhereClause>) { + ( + ImplGenerics(self), + TypeGenerics(self), + self.where_clause.as_ref(), + ) + } +} + +#[cfg(feature = "printing")] +impl<'a> TypeGenerics<'a> { + /// Turn a type's generics like `` into a turbofish like `::`. + /// + /// *This method is available if Syn is built with the `"derive"` or + /// `"full"` feature and the `"printing"` feature.* + pub fn as_turbofish(&self) -> Turbofish { + Turbofish(self.0) + } +} + +ast_struct! { + /// A set of bound lifetimes: `for<'a, 'b, 'c>`. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + #[derive(Default)] + pub struct BoundLifetimes { + pub for_token: Token![for], + pub lt_token: Token![<], + pub lifetimes: Punctuated, + pub gt_token: Token![>], + } +} + +impl LifetimeDef { + pub fn new(lifetime: Lifetime) -> Self { + LifetimeDef { + attrs: Vec::new(), + lifetime: lifetime, + colon_token: None, + bounds: Punctuated::new(), + } + } +} + +impl From for TypeParam { + fn from(ident: Ident) -> Self { + TypeParam { + attrs: vec![], + ident: ident, + colon_token: None, + bounds: Punctuated::new(), + eq_token: None, + default: None, + } + } +} + +ast_enum_of_structs! { + /// A trait or lifetime used as a bound on a type parameter. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + pub enum TypeParamBound { + pub Trait(TraitBound), + pub Lifetime(Lifetime), + } +} + +ast_struct! { + /// A trait used as a bound on a type parameter. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + pub struct TraitBound { + pub paren_token: Option, + pub modifier: TraitBoundModifier, + /// The `for<'a>` in `for<'a> Foo<&'a T>` + pub lifetimes: Option, + /// The `Foo<&'a T>` in `for<'a> Foo<&'a T>` + pub path: Path, + } +} + +ast_enum! { + /// A modifier on a trait bound, currently only used for the `?` in + /// `?Sized`. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + #[cfg_attr(feature = "clone-impls", derive(Copy))] + pub enum TraitBoundModifier { + None, + Maybe(Token![?]), + } +} + +ast_struct! { + /// A `where` clause in a definition: `where T: Deserialize<'de>, D: + /// 'static`. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + pub struct WhereClause { + pub where_token: Token![where], + pub predicates: Punctuated, + } +} + +ast_enum_of_structs! { + /// A single predicate in a `where` clause: `T: Deserialize<'de>`. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + /// + /// # Syntax tree enum + /// + /// This type is a [syntax tree enum]. + /// + /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums + pub enum WherePredicate { + /// A type predicate in a `where` clause: `for<'c> Foo<'c>: Trait<'c>`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Type(PredicateType { + /// Any lifetimes from a `for` binding + pub lifetimes: Option, + /// The type being bounded + pub bounded_ty: Type, + pub colon_token: Token![:], + /// Trait and lifetime bounds (`Clone+Send+'static`) + pub bounds: Punctuated, + }), + + /// A lifetime predicate in a `where` clause: `'a: 'b + 'c`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Lifetime(PredicateLifetime { + pub lifetime: Lifetime, + pub colon_token: Option, + pub bounds: Punctuated, + }), + + /// An equality predicate in a `where` clause (unsupported). + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Eq(PredicateEq { + pub lhs_ty: Type, + pub eq_token: Token![=], + pub rhs_ty: Type, + }), + } +} + +#[cfg(feature = "parsing")] +pub mod parsing { + use super::*; + + use punctuated::Pair; + use synom::Synom; + + impl Synom for Generics { + named!(parse -> Self, map!( + alt!( + do_parse!( + lt: punct!(<) >> + lifetimes: call!(Punctuated::::parse_terminated) >> + ty_params: cond!( + lifetimes.empty_or_trailing(), + Punctuated::::parse_terminated + ) >> + gt: punct!(>) >> + (lifetimes, ty_params, Some(lt), Some(gt)) + ) + | + epsilon!() => { |_| (Punctuated::new(), None, None, None) } + ), + |(lifetimes, ty_params, lt, gt)| Generics { + lt_token: lt, + params: lifetimes.into_pairs() + .map(Pair::into_tuple) + .map(|(life, comma)| Pair::new(GenericParam::Lifetime(life), comma)) + .chain(ty_params.unwrap_or_default() + .into_pairs() + .map(Pair::into_tuple) + .map(|(ty, comma)| Pair::new(GenericParam::Type(ty), comma))) + .collect(), + gt_token: gt, + where_clause: None, + } + )); + + fn description() -> Option<&'static str> { + Some("generic parameters in declaration") + } + } + + impl Synom for GenericParam { + named!(parse -> Self, alt!( + syn!(TypeParam) => { GenericParam::Type } + | + syn!(LifetimeDef) => { GenericParam::Lifetime } + | + syn!(ConstParam) => { GenericParam::Const } + )); + + fn description() -> Option<&'static str> { + Some("generic parameter") + } + } + + impl Synom for LifetimeDef { + named!(parse -> Self, do_parse!( + attrs: many0!(Attribute::parse_outer) >> + life: syn!(Lifetime) >> + colon: option!(punct!(:)) >> + bounds: cond!( + colon.is_some(), + Punctuated::parse_separated_nonempty + ) >> + (LifetimeDef { + attrs: attrs, + lifetime: life, + bounds: bounds.unwrap_or_default(), + colon_token: colon, + }) + )); + + fn description() -> Option<&'static str> { + Some("lifetime definition") + } + } + + impl Synom for BoundLifetimes { + named!(parse -> Self, do_parse!( + for_: keyword!(for) >> + lt: punct!(<) >> + lifetimes: call!(Punctuated::parse_terminated) >> + gt: punct!(>) >> + (BoundLifetimes { + for_token: for_, + lt_token: lt, + gt_token: gt, + lifetimes: lifetimes, + }) + )); + + fn description() -> Option<&'static str> { + Some("bound lifetimes") + } + } + + impl Synom for TypeParam { + named!(parse -> Self, do_parse!( + attrs: many0!(Attribute::parse_outer) >> + id: syn!(Ident) >> + colon: option!(punct!(:)) >> + bounds: cond!( + colon.is_some(), + Punctuated::parse_separated_nonempty + ) >> + default: option!(do_parse!( + eq: punct!(=) >> + ty: syn!(Type) >> + (eq, ty) + )) >> + (TypeParam { + attrs: attrs, + ident: id, + bounds: bounds.unwrap_or_default(), + colon_token: colon, + eq_token: default.as_ref().map(|d| Token![=]((d.0).0)), + default: default.map(|d| d.1), + }) + )); + + fn description() -> Option<&'static str> { + Some("type parameter") + } + } + + impl Synom for TypeParamBound { + named!(parse -> Self, alt!( + syn!(Lifetime) => { TypeParamBound::Lifetime } + | + syn!(TraitBound) => { TypeParamBound::Trait } + | + parens!(syn!(TraitBound)) => {|(parens, mut bound)| { + bound.paren_token = Some(parens); + TypeParamBound::Trait(bound) + }} + )); + + fn description() -> Option<&'static str> { + Some("type parameter bound") + } + } + + impl Synom for TraitBound { + named!(parse -> Self, do_parse!( + modifier: syn!(TraitBoundModifier) >> + lifetimes: option!(syn!(BoundLifetimes)) >> + mut path: syn!(Path) >> + parenthesized: option!(cond_reduce!( + path.segments.last().unwrap().value().arguments.is_empty(), + syn!(ParenthesizedGenericArguments) + )) >> + ({ + if let Some(parenthesized) = parenthesized { + let parenthesized = PathArguments::Parenthesized(parenthesized); + path.segments.last_mut().unwrap().value_mut().arguments = parenthesized; + } + TraitBound { + paren_token: None, + modifier: modifier, + lifetimes: lifetimes, + path: path, + } + }) + )); + + fn description() -> Option<&'static str> { + Some("trait bound") + } + } + + impl Synom for TraitBoundModifier { + named!(parse -> Self, alt!( + punct!(?) => { TraitBoundModifier::Maybe } + | + epsilon!() => { |_| TraitBoundModifier::None } + )); + + fn description() -> Option<&'static str> { + Some("trait bound modifier") + } + } + + impl Synom for ConstParam { + named!(parse -> Self, do_parse!( + attrs: many0!(Attribute::parse_outer) >> + const_: keyword!(const) >> + ident: syn!(Ident) >> + colon: punct!(:) >> + ty: syn!(Type) >> + eq_def: option!(tuple!(punct!(=), syn!(Expr))) >> + ({ + let (eq_token, default) = match eq_def { + Some((eq_token, default)) => (Some(eq_token), Some(default)), + None => (None, None), + }; + ConstParam { + attrs: attrs, + const_token: const_, + ident: ident, + colon_token: colon, + ty: ty, + eq_token: eq_token, + default: default, + } + }) + )); + + fn description() -> Option<&'static str> { + Some("generic `const` parameter") + } + } + + impl Synom for WhereClause { + named!(parse -> Self, do_parse!( + where_: keyword!(where) >> + predicates: call!(Punctuated::parse_terminated) >> + (WhereClause { + predicates: predicates, + where_token: where_, + }) + )); + + fn description() -> Option<&'static str> { + Some("where clause") + } + } + + impl Synom for WherePredicate { + named!(parse -> Self, alt!( + do_parse!( + ident: syn!(Lifetime) >> + colon: option!(punct!(:)) >> + bounds: cond!( + colon.is_some(), + Punctuated::parse_separated + ) >> + (WherePredicate::Lifetime(PredicateLifetime { + lifetime: ident, + bounds: bounds.unwrap_or_default(), + colon_token: colon, + })) + ) + | + do_parse!( + lifetimes: option!(syn!(BoundLifetimes)) >> + bounded_ty: syn!(Type) >> + colon: punct!(:) >> + bounds: call!(Punctuated::parse_separated_nonempty) >> + (WherePredicate::Type(PredicateType { + lifetimes: lifetimes, + bounded_ty: bounded_ty, + bounds: bounds, + colon_token: colon, + })) + ) + )); + + fn description() -> Option<&'static str> { + Some("predicate in where clause") + } + } +} + +#[cfg(feature = "printing")] +mod printing { + use super::*; + use attr::FilterAttrs; + use proc_macro2::TokenStream; + use quote::{ToTokens, TokenStreamExt}; + + impl ToTokens for Generics { + fn to_tokens(&self, tokens: &mut TokenStream) { + if self.params.is_empty() { + return; + } + + TokensOrDefault(&self.lt_token).to_tokens(tokens); + + // Print lifetimes before types and consts, regardless of their + // order in self.params. + // + // TODO: ordering rules for const parameters vs type parameters have + // not been settled yet. https://github.com/rust-lang/rust/issues/44580 + let mut trailing_or_empty = true; + for param in self.params.pairs() { + if let GenericParam::Lifetime(_) = **param.value() { + param.to_tokens(tokens); + trailing_or_empty = param.punct().is_some(); + } + } + for param in self.params.pairs() { + match **param.value() { + GenericParam::Type(_) | GenericParam::Const(_) => { + if !trailing_or_empty { + ::default().to_tokens(tokens); + trailing_or_empty = true; + } + param.to_tokens(tokens); + } + GenericParam::Lifetime(_) => {} + } + } + + TokensOrDefault(&self.gt_token).to_tokens(tokens); + } + } + + impl<'a> ToTokens for ImplGenerics<'a> { + fn to_tokens(&self, tokens: &mut TokenStream) { + if self.0.params.is_empty() { + return; + } + + TokensOrDefault(&self.0.lt_token).to_tokens(tokens); + + // Print lifetimes before types and consts, regardless of their + // order in self.params. + // + // TODO: ordering rules for const parameters vs type parameters have + // not been settled yet. https://github.com/rust-lang/rust/issues/44580 + let mut trailing_or_empty = true; + for param in self.0.params.pairs() { + if let GenericParam::Lifetime(_) = **param.value() { + param.to_tokens(tokens); + trailing_or_empty = param.punct().is_some(); + } + } + for param in self.0.params.pairs() { + if let GenericParam::Lifetime(_) = **param.value() { + continue; + } + if !trailing_or_empty { + ::default().to_tokens(tokens); + trailing_or_empty = true; + } + match **param.value() { + GenericParam::Lifetime(_) => unreachable!(), + GenericParam::Type(ref param) => { + // Leave off the type parameter defaults + tokens.append_all(param.attrs.outer()); + param.ident.to_tokens(tokens); + if !param.bounds.is_empty() { + TokensOrDefault(¶m.colon_token).to_tokens(tokens); + param.bounds.to_tokens(tokens); + } + } + GenericParam::Const(ref param) => { + // Leave off the const parameter defaults + tokens.append_all(param.attrs.outer()); + param.const_token.to_tokens(tokens); + param.ident.to_tokens(tokens); + param.colon_token.to_tokens(tokens); + param.ty.to_tokens(tokens); + } + } + param.punct().to_tokens(tokens); + } + + TokensOrDefault(&self.0.gt_token).to_tokens(tokens); + } + } + + impl<'a> ToTokens for TypeGenerics<'a> { + fn to_tokens(&self, tokens: &mut TokenStream) { + if self.0.params.is_empty() { + return; + } + + TokensOrDefault(&self.0.lt_token).to_tokens(tokens); + + // Print lifetimes before types and consts, regardless of their + // order in self.params. + // + // TODO: ordering rules for const parameters vs type parameters have + // not been settled yet. https://github.com/rust-lang/rust/issues/44580 + let mut trailing_or_empty = true; + for param in self.0.params.pairs() { + if let GenericParam::Lifetime(ref def) = **param.value() { + // Leave off the lifetime bounds and attributes + def.lifetime.to_tokens(tokens); + param.punct().to_tokens(tokens); + trailing_or_empty = param.punct().is_some(); + } + } + for param in self.0.params.pairs() { + if let GenericParam::Lifetime(_) = **param.value() { + continue; + } + if !trailing_or_empty { + ::default().to_tokens(tokens); + trailing_or_empty = true; + } + match **param.value() { + GenericParam::Lifetime(_) => unreachable!(), + GenericParam::Type(ref param) => { + // Leave off the type parameter defaults + param.ident.to_tokens(tokens); + } + GenericParam::Const(ref param) => { + // Leave off the const parameter defaults + param.ident.to_tokens(tokens); + } + } + param.punct().to_tokens(tokens); + } + + TokensOrDefault(&self.0.gt_token).to_tokens(tokens); + } + } + + impl<'a> ToTokens for Turbofish<'a> { + fn to_tokens(&self, tokens: &mut TokenStream) { + if !self.0.params.is_empty() { + ::default().to_tokens(tokens); + TypeGenerics(self.0).to_tokens(tokens); + } + } + } + + impl ToTokens for BoundLifetimes { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.for_token.to_tokens(tokens); + self.lt_token.to_tokens(tokens); + self.lifetimes.to_tokens(tokens); + self.gt_token.to_tokens(tokens); + } + } + + impl ToTokens for LifetimeDef { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.lifetime.to_tokens(tokens); + if !self.bounds.is_empty() { + TokensOrDefault(&self.colon_token).to_tokens(tokens); + self.bounds.to_tokens(tokens); + } + } + } + + impl ToTokens for TypeParam { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.ident.to_tokens(tokens); + if !self.bounds.is_empty() { + TokensOrDefault(&self.colon_token).to_tokens(tokens); + self.bounds.to_tokens(tokens); + } + if self.default.is_some() { + TokensOrDefault(&self.eq_token).to_tokens(tokens); + self.default.to_tokens(tokens); + } + } + } + + impl ToTokens for TraitBound { + fn to_tokens(&self, tokens: &mut TokenStream) { + let to_tokens = |tokens: &mut TokenStream| { + self.modifier.to_tokens(tokens); + self.lifetimes.to_tokens(tokens); + self.path.to_tokens(tokens); + }; + match self.paren_token { + Some(ref paren) => paren.surround(tokens, to_tokens), + None => to_tokens(tokens), + } + } + } + + impl ToTokens for TraitBoundModifier { + fn to_tokens(&self, tokens: &mut TokenStream) { + match *self { + TraitBoundModifier::None => {} + TraitBoundModifier::Maybe(ref t) => t.to_tokens(tokens), + } + } + } + + impl ToTokens for ConstParam { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.const_token.to_tokens(tokens); + self.ident.to_tokens(tokens); + self.colon_token.to_tokens(tokens); + self.ty.to_tokens(tokens); + if self.default.is_some() { + TokensOrDefault(&self.eq_token).to_tokens(tokens); + self.default.to_tokens(tokens); + } + } + } + + impl ToTokens for WhereClause { + fn to_tokens(&self, tokens: &mut TokenStream) { + if !self.predicates.is_empty() { + self.where_token.to_tokens(tokens); + self.predicates.to_tokens(tokens); + } + } + } + + impl ToTokens for PredicateType { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.lifetimes.to_tokens(tokens); + self.bounded_ty.to_tokens(tokens); + self.colon_token.to_tokens(tokens); + self.bounds.to_tokens(tokens); + } + } + + impl ToTokens for PredicateLifetime { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.lifetime.to_tokens(tokens); + if !self.bounds.is_empty() { + TokensOrDefault(&self.colon_token).to_tokens(tokens); + self.bounds.to_tokens(tokens); + } + } + } + + impl ToTokens for PredicateEq { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.lhs_ty.to_tokens(tokens); + self.eq_token.to_tokens(tokens); + self.rhs_ty.to_tokens(tokens); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/gen_helper.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/gen_helper.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/gen_helper.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/gen_helper.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,162 @@ +// Copyright 2018 Syn Developers +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[cfg(feature = "fold")] +pub mod fold { + use fold::Fold; + use proc_macro2::Span; + use punctuated::{Pair, Punctuated}; + + pub trait FoldHelper { + type Item; + fn lift(self, f: F) -> Self + where + F: FnMut(Self::Item) -> Self::Item; + } + + impl FoldHelper for Vec { + type Item = T; + fn lift(self, f: F) -> Self + where + F: FnMut(Self::Item) -> Self::Item, + { + self.into_iter().map(f).collect() + } + } + + impl FoldHelper for Punctuated { + type Item = T; + fn lift(self, mut f: F) -> Self + where + F: FnMut(Self::Item) -> Self::Item, + { + self.into_pairs() + .map(Pair::into_tuple) + .map(|(t, u)| Pair::new(f(t), u)) + .collect() + } + } + + pub fn tokens_helper(folder: &mut F, spans: &S) -> S { + spans.fold(folder) + } + + pub trait Spans { + fn fold(&self, folder: &mut F) -> Self; + } + + impl Spans for Span { + fn fold(&self, folder: &mut F) -> Self { + folder.fold_span(*self) + } + } + + impl Spans for [Span; 1] { + fn fold(&self, folder: &mut F) -> Self { + [folder.fold_span(self[0])] + } + } + + impl Spans for [Span; 2] { + fn fold(&self, folder: &mut F) -> Self { + [folder.fold_span(self[0]), folder.fold_span(self[1])] + } + } + + impl Spans for [Span; 3] { + fn fold(&self, folder: &mut F) -> Self { + [ + folder.fold_span(self[0]), + folder.fold_span(self[1]), + folder.fold_span(self[2]), + ] + } + } +} + +#[cfg(feature = "visit")] +pub mod visit { + use proc_macro2::Span; + use visit::Visit; + + pub fn tokens_helper<'ast, V: Visit<'ast> + ?Sized, S: Spans>(visitor: &mut V, spans: &'ast S) { + spans.visit(visitor); + } + + pub trait Spans { + fn visit<'ast, V: Visit<'ast> + ?Sized>(&'ast self, visitor: &mut V); + } + + impl Spans for Span { + fn visit<'ast, V: Visit<'ast> + ?Sized>(&'ast self, visitor: &mut V) { + visitor.visit_span(self); + } + } + + impl Spans for [Span; 1] { + fn visit<'ast, V: Visit<'ast> + ?Sized>(&'ast self, visitor: &mut V) { + visitor.visit_span(&self[0]); + } + } + + impl Spans for [Span; 2] { + fn visit<'ast, V: Visit<'ast> + ?Sized>(&'ast self, visitor: &mut V) { + visitor.visit_span(&self[0]); + visitor.visit_span(&self[1]); + } + } + + impl Spans for [Span; 3] { + fn visit<'ast, V: Visit<'ast> + ?Sized>(&'ast self, visitor: &mut V) { + visitor.visit_span(&self[0]); + visitor.visit_span(&self[1]); + visitor.visit_span(&self[2]); + } + } +} + +#[cfg(feature = "visit-mut")] +pub mod visit_mut { + use proc_macro2::Span; + use visit_mut::VisitMut; + + pub fn tokens_helper(visitor: &mut V, spans: &mut S) { + spans.visit_mut(visitor); + } + + pub trait Spans { + fn visit_mut(&mut self, visitor: &mut V); + } + + impl Spans for Span { + fn visit_mut(&mut self, visitor: &mut V) { + visitor.visit_span_mut(self); + } + } + + impl Spans for [Span; 1] { + fn visit_mut(&mut self, visitor: &mut V) { + visitor.visit_span_mut(&mut self[0]); + } + } + + impl Spans for [Span; 2] { + fn visit_mut(&mut self, visitor: &mut V) { + visitor.visit_span_mut(&mut self[0]); + visitor.visit_span_mut(&mut self[1]); + } + } + + impl Spans for [Span; 3] { + fn visit_mut(&mut self, visitor: &mut V) { + visitor.visit_span_mut(&mut self[0]); + visitor.visit_span_mut(&mut self[1]); + visitor.visit_span_mut(&mut self[2]); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/item.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/item.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/item.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/item.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,2158 @@ +// Copyright 2018 Syn Developers +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use super::*; +use derive::{Data, DeriveInput}; +use proc_macro2::TokenStream; +use punctuated::Punctuated; +use token::{Brace, Paren}; + +#[cfg(feature = "extra-traits")] +use std::hash::{Hash, Hasher}; +#[cfg(feature = "extra-traits")] +use tt::TokenStreamHelper; + +ast_enum_of_structs! { + /// Things that can appear directly inside of a module or scope. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + /// + /// # Syntax tree enum + /// + /// This type is a [syntax tree enum]. + /// + /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums + pub enum Item { + /// An `extern crate` item: `extern crate serde`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub ExternCrate(ItemExternCrate { + pub attrs: Vec, + pub vis: Visibility, + pub extern_token: Token![extern], + pub crate_token: Token![crate], + pub ident: Ident, + pub rename: Option<(Token![as], Ident)>, + pub semi_token: Token![;], + }), + + /// A use declaration: `use std::collections::HashMap`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Use(ItemUse { + pub attrs: Vec, + pub vis: Visibility, + pub use_token: Token![use], + pub leading_colon: Option, + pub tree: UseTree, + pub semi_token: Token![;], + }), + + /// A static item: `static BIKE: Shed = Shed(42)`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Static(ItemStatic { + pub attrs: Vec, + pub vis: Visibility, + pub static_token: Token![static], + pub mutability: Option, + pub ident: Ident, + pub colon_token: Token![:], + pub ty: Box, + pub eq_token: Token![=], + pub expr: Box, + pub semi_token: Token![;], + }), + + /// A constant item: `const MAX: u16 = 65535`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Const(ItemConst { + pub attrs: Vec, + pub vis: Visibility, + pub const_token: Token![const], + pub ident: Ident, + pub colon_token: Token![:], + pub ty: Box, + pub eq_token: Token![=], + pub expr: Box, + pub semi_token: Token![;], + }), + + /// A free-standing function: `fn process(n: usize) -> Result<()> { ... + /// }`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Fn(ItemFn { + pub attrs: Vec, + pub vis: Visibility, + pub constness: Option, + pub unsafety: Option, + pub abi: Option, + pub ident: Ident, + pub decl: Box, + pub block: Box, + }), + + /// A module or module declaration: `mod m` or `mod m { ... }`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Mod(ItemMod { + pub attrs: Vec, + pub vis: Visibility, + pub mod_token: Token![mod], + pub ident: Ident, + pub content: Option<(token::Brace, Vec)>, + pub semi: Option, + }), + + /// A block of foreign items: `extern "C" { ... }`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub ForeignMod(ItemForeignMod { + pub attrs: Vec, + pub abi: Abi, + pub brace_token: token::Brace, + pub items: Vec, + }), + + /// A type alias: `type Result = std::result::Result`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Type(ItemType { + pub attrs: Vec, + pub vis: Visibility, + pub type_token: Token![type], + pub ident: Ident, + pub generics: Generics, + pub eq_token: Token![=], + pub ty: Box, + pub semi_token: Token![;], + }), + + /// A struct definition: `struct Foo { x: A }`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Struct(ItemStruct { + pub attrs: Vec, + pub vis: Visibility, + pub struct_token: Token![struct], + pub ident: Ident, + pub generics: Generics, + pub fields: Fields, + pub semi_token: Option, + }), + + /// An enum definition: `enum Foo { C, D }`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Enum(ItemEnum { + pub attrs: Vec, + pub vis: Visibility, + pub enum_token: Token![enum], + pub ident: Ident, + pub generics: Generics, + pub brace_token: token::Brace, + pub variants: Punctuated, + }), + + /// A union definition: `union Foo { x: A, y: B }`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Union(ItemUnion { + pub attrs: Vec, + pub vis: Visibility, + pub union_token: Token![union], + pub ident: Ident, + pub generics: Generics, + pub fields: FieldsNamed, + }), + + /// A trait definition: `pub trait Iterator { ... }`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Trait(ItemTrait { + pub attrs: Vec, + pub vis: Visibility, + pub unsafety: Option, + pub auto_token: Option, + pub trait_token: Token![trait], + pub ident: Ident, + pub generics: Generics, + pub colon_token: Option, + pub supertraits: Punctuated, + pub brace_token: token::Brace, + pub items: Vec, + }), + + /// An impl block providing trait or associated items: `impl Trait + /// for Data { ... }`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Impl(ItemImpl { + pub attrs: Vec, + pub defaultness: Option, + pub unsafety: Option, + pub impl_token: Token![impl], + pub generics: Generics, + /// Trait this impl implements. + pub trait_: Option<(Option, Path, Token![for])>, + /// The Self type of the impl. + pub self_ty: Box, + pub brace_token: token::Brace, + pub items: Vec, + }), + + /// A macro invocation, which includes `macro_rules!` definitions. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Macro(ItemMacro { + pub attrs: Vec, + /// The `example` in `macro_rules! example { ... }`. + pub ident: Option, + pub mac: Macro, + pub semi_token: Option, + }), + + /// A 2.0-style declarative macro introduced by the `macro` keyword. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Macro2(ItemMacro2 #manual_extra_traits { + pub attrs: Vec, + pub vis: Visibility, + pub macro_token: Token![macro], + pub ident: Ident, + pub paren_token: Paren, + pub args: TokenStream, + pub brace_token: Brace, + pub body: TokenStream, + }), + + /// Tokens forming an item not interpreted by Syn. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Verbatim(ItemVerbatim #manual_extra_traits { + pub tts: TokenStream, + }), + } +} + +#[cfg(feature = "extra-traits")] +impl Eq for ItemMacro2 {} + +#[cfg(feature = "extra-traits")] +impl PartialEq for ItemMacro2 { + fn eq(&self, other: &Self) -> bool { + self.attrs == other.attrs + && self.vis == other.vis + && self.macro_token == other.macro_token + && self.ident == other.ident + && self.paren_token == other.paren_token + && TokenStreamHelper(&self.args) == TokenStreamHelper(&other.args) + && self.brace_token == other.brace_token + && TokenStreamHelper(&self.body) == TokenStreamHelper(&other.body) + } +} + +#[cfg(feature = "extra-traits")] +impl Hash for ItemMacro2 { + fn hash(&self, state: &mut H) + where + H: Hasher, + { + self.attrs.hash(state); + self.vis.hash(state); + self.macro_token.hash(state); + self.ident.hash(state); + self.paren_token.hash(state); + TokenStreamHelper(&self.args).hash(state); + self.brace_token.hash(state); + TokenStreamHelper(&self.body).hash(state); + } +} + +#[cfg(feature = "extra-traits")] +impl Eq for ItemVerbatim {} + +#[cfg(feature = "extra-traits")] +impl PartialEq for ItemVerbatim { + fn eq(&self, other: &Self) -> bool { + TokenStreamHelper(&self.tts) == TokenStreamHelper(&other.tts) + } +} + +#[cfg(feature = "extra-traits")] +impl Hash for ItemVerbatim { + fn hash(&self, state: &mut H) + where + H: Hasher, + { + TokenStreamHelper(&self.tts).hash(state); + } +} + +impl From for Item { + fn from(input: DeriveInput) -> Item { + match input.data { + Data::Struct(data) => Item::Struct(ItemStruct { + attrs: input.attrs, + vis: input.vis, + struct_token: data.struct_token, + ident: input.ident, + generics: input.generics, + fields: data.fields, + semi_token: data.semi_token, + }), + Data::Enum(data) => Item::Enum(ItemEnum { + attrs: input.attrs, + vis: input.vis, + enum_token: data.enum_token, + ident: input.ident, + generics: input.generics, + brace_token: data.brace_token, + variants: data.variants, + }), + Data::Union(data) => Item::Union(ItemUnion { + attrs: input.attrs, + vis: input.vis, + union_token: data.union_token, + ident: input.ident, + generics: input.generics, + fields: data.fields, + }), + } + } +} + +ast_enum_of_structs! { + /// A suffix of an import tree in a `use` item: `Type as Renamed` or `*`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + /// + /// # Syntax tree enum + /// + /// This type is a [syntax tree enum]. + /// + /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums + pub enum UseTree { + /// A path prefix of imports in a `use` item: `std::...`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Path(UsePath { + pub ident: Ident, + pub colon2_token: Token![::], + pub tree: Box, + }), + + /// An identifier imported by a `use` item: `HashMap`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Name(UseName { + pub ident: Ident, + }), + + /// An renamed identifier imported by a `use` item: `HashMap as Map`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Rename(UseRename { + pub ident: Ident, + pub as_token: Token![as], + pub rename: Ident, + }), + + /// A glob import in a `use` item: `*`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Glob(UseGlob { + pub star_token: Token![*], + }), + + /// A braced group of imports in a `use` item: `{A, B, C}`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Group(UseGroup { + pub brace_token: token::Brace, + pub items: Punctuated, + }), + } +} + +ast_enum_of_structs! { + /// An item within an `extern` block. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + /// + /// # Syntax tree enum + /// + /// This type is a [syntax tree enum]. + /// + /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums + pub enum ForeignItem { + /// A foreign function in an `extern` block. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Fn(ForeignItemFn { + pub attrs: Vec, + pub vis: Visibility, + pub ident: Ident, + pub decl: Box, + pub semi_token: Token![;], + }), + + /// A foreign static item in an `extern` block: `static ext: u8`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Static(ForeignItemStatic { + pub attrs: Vec, + pub vis: Visibility, + pub static_token: Token![static], + pub mutability: Option, + pub ident: Ident, + pub colon_token: Token![:], + pub ty: Box, + pub semi_token: Token![;], + }), + + /// A foreign type in an `extern` block: `type void`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Type(ForeignItemType { + pub attrs: Vec, + pub vis: Visibility, + pub type_token: Token![type], + pub ident: Ident, + pub semi_token: Token![;], + }), + + /// Tokens in an `extern` block not interpreted by Syn. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Verbatim(ForeignItemVerbatim #manual_extra_traits { + pub tts: TokenStream, + }), + } +} + +#[cfg(feature = "extra-traits")] +impl Eq for ForeignItemVerbatim {} + +#[cfg(feature = "extra-traits")] +impl PartialEq for ForeignItemVerbatim { + fn eq(&self, other: &Self) -> bool { + TokenStreamHelper(&self.tts) == TokenStreamHelper(&other.tts) + } +} + +#[cfg(feature = "extra-traits")] +impl Hash for ForeignItemVerbatim { + fn hash(&self, state: &mut H) + where + H: Hasher, + { + TokenStreamHelper(&self.tts).hash(state); + } +} + +ast_enum_of_structs! { + /// An item declaration within the definition of a trait. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + /// + /// # Syntax tree enum + /// + /// This type is a [syntax tree enum]. + /// + /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums + pub enum TraitItem { + /// An associated constant within the definition of a trait. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Const(TraitItemConst { + pub attrs: Vec, + pub const_token: Token![const], + pub ident: Ident, + pub colon_token: Token![:], + pub ty: Type, + pub default: Option<(Token![=], Expr)>, + pub semi_token: Token![;], + }), + + /// A trait method within the definition of a trait. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Method(TraitItemMethod { + pub attrs: Vec, + pub sig: MethodSig, + pub default: Option, + pub semi_token: Option, + }), + + /// An associated type within the definition of a trait. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Type(TraitItemType { + pub attrs: Vec, + pub type_token: Token![type], + pub ident: Ident, + pub generics: Generics, + pub colon_token: Option, + pub bounds: Punctuated, + pub default: Option<(Token![=], Type)>, + pub semi_token: Token![;], + }), + + /// A macro invocation within the definition of a trait. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Macro(TraitItemMacro { + pub attrs: Vec, + pub mac: Macro, + pub semi_token: Option, + }), + + /// Tokens within the definition of a trait not interpreted by Syn. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Verbatim(TraitItemVerbatim #manual_extra_traits { + pub tts: TokenStream, + }), + } +} + +#[cfg(feature = "extra-traits")] +impl Eq for TraitItemVerbatim {} + +#[cfg(feature = "extra-traits")] +impl PartialEq for TraitItemVerbatim { + fn eq(&self, other: &Self) -> bool { + TokenStreamHelper(&self.tts) == TokenStreamHelper(&other.tts) + } +} + +#[cfg(feature = "extra-traits")] +impl Hash for TraitItemVerbatim { + fn hash(&self, state: &mut H) + where + H: Hasher, + { + TokenStreamHelper(&self.tts).hash(state); + } +} + +ast_enum_of_structs! { + /// An item within an impl block. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + /// + /// # Syntax tree enum + /// + /// This type is a [syntax tree enum]. + /// + /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums + pub enum ImplItem { + /// An associated constant within an impl block. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Const(ImplItemConst { + pub attrs: Vec, + pub vis: Visibility, + pub defaultness: Option, + pub const_token: Token![const], + pub ident: Ident, + pub colon_token: Token![:], + pub ty: Type, + pub eq_token: Token![=], + pub expr: Expr, + pub semi_token: Token![;], + }), + + /// A method within an impl block. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Method(ImplItemMethod { + pub attrs: Vec, + pub vis: Visibility, + pub defaultness: Option, + pub sig: MethodSig, + pub block: Block, + }), + + /// An associated type within an impl block. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Type(ImplItemType { + pub attrs: Vec, + pub vis: Visibility, + pub defaultness: Option, + pub type_token: Token![type], + pub ident: Ident, + pub generics: Generics, + pub eq_token: Token![=], + pub ty: Type, + pub semi_token: Token![;], + }), + + /// A macro invocation within an impl block. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Macro(ImplItemMacro { + pub attrs: Vec, + pub mac: Macro, + pub semi_token: Option, + }), + + /// Tokens within an impl block not interpreted by Syn. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Verbatim(ImplItemVerbatim #manual_extra_traits { + pub tts: TokenStream, + }), + } +} + +#[cfg(feature = "extra-traits")] +impl Eq for ImplItemVerbatim {} + +#[cfg(feature = "extra-traits")] +impl PartialEq for ImplItemVerbatim { + fn eq(&self, other: &Self) -> bool { + TokenStreamHelper(&self.tts) == TokenStreamHelper(&other.tts) + } +} + +#[cfg(feature = "extra-traits")] +impl Hash for ImplItemVerbatim { + fn hash(&self, state: &mut H) + where + H: Hasher, + { + TokenStreamHelper(&self.tts).hash(state); + } +} + +ast_struct! { + /// A method's signature in a trait or implementation: `unsafe fn + /// initialize(&self)`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub struct MethodSig { + pub constness: Option, + pub unsafety: Option, + pub abi: Option, + pub ident: Ident, + pub decl: FnDecl, + } +} + +ast_struct! { + /// Header of a function declaration, without including the body. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub struct FnDecl { + pub fn_token: Token![fn], + pub generics: Generics, + pub paren_token: token::Paren, + pub inputs: Punctuated, + pub variadic: Option, + pub output: ReturnType, + } +} + +ast_enum_of_structs! { + /// An argument in a function signature: the `n: usize` in `fn f(n: usize)`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + /// + /// # Syntax tree enum + /// + /// This type is a [syntax tree enum]. + /// + /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums + pub enum FnArg { + /// Self captured by reference in a function signature: `&self` or `&mut + /// self`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub SelfRef(ArgSelfRef { + pub and_token: Token![&], + pub lifetime: Option, + pub mutability: Option, + pub self_token: Token![self], + }), + + /// Self captured by value in a function signature: `self` or `mut + /// self`. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub SelfValue(ArgSelf { + pub mutability: Option, + pub self_token: Token![self], + }), + + /// An explicitly typed pattern captured by a function signature. + /// + /// *This type is available if Syn is built with the `"full"` feature.* + pub Captured(ArgCaptured { + pub pat: Pat, + pub colon_token: Token![:], + pub ty: Type, + }), + + /// A pattern whose type is inferred captured by a function signature. + pub Inferred(Pat), + /// A type not bound to any pattern in a function signature. + pub Ignored(Type), + } +} + +#[cfg(feature = "parsing")] +pub mod parsing { + use super::*; + + use synom::Synom; + + impl_synom!(Item "item" alt!( + syn!(ItemExternCrate) => { Item::ExternCrate } + | + syn!(ItemUse) => { Item::Use } + | + syn!(ItemStatic) => { Item::Static } + | + syn!(ItemConst) => { Item::Const } + | + syn!(ItemFn) => { Item::Fn } + | + call!(unstable_async_fn) => { Item::Verbatim } + | + syn!(ItemMod) => { Item::Mod } + | + syn!(ItemForeignMod) => { Item::ForeignMod } + | + syn!(ItemType) => { Item::Type } + | + call!(unstable_existential_type) => { Item::Verbatim } + | + syn!(ItemStruct) => { Item::Struct } + | + syn!(ItemEnum) => { Item::Enum } + | + syn!(ItemUnion) => { Item::Union } + | + syn!(ItemTrait) => { Item::Trait } + | + syn!(ItemImpl) => { Item::Impl } + | + syn!(ItemMacro) => { Item::Macro } + | + syn!(ItemMacro2) => { Item::Macro2 } + )); + + impl_synom!(ItemMacro "macro item" do_parse!( + attrs: many0!(Attribute::parse_outer) >> + what: call!(Path::parse_mod_style) >> + bang: punct!(!) >> + ident: option!(syn!(Ident)) >> + body: call!(tt::delimited) >> + semi: cond!(!is_brace(&body.0), punct!(;)) >> + (ItemMacro { + attrs: attrs, + ident: ident, + mac: Macro { + path: what, + bang_token: bang, + delimiter: body.0, + tts: body.1, + }, + semi_token: semi, + }) + )); + + // TODO: figure out the actual grammar; is body required to be braced? + impl_synom!(ItemMacro2 "macro2 item" do_parse!( + attrs: many0!(Attribute::parse_outer) >> + vis: syn!(Visibility) >> + macro_: keyword!(macro) >> + ident: syn!(Ident) >> + args: call!(tt::parenthesized) >> + body: call!(tt::braced) >> + (ItemMacro2 { + attrs: attrs, + vis: vis, + macro_token: macro_, + ident: ident, + paren_token: args.0, + args: args.1, + brace_token: body.0, + body: body.1, + }) + )); + + impl_synom!(ItemExternCrate "extern crate item" do_parse!( + attrs: many0!(Attribute::parse_outer) >> + vis: syn!(Visibility) >> + extern_: keyword!(extern) >> + crate_: keyword!(crate) >> + ident: syn!(Ident) >> + rename: option!(tuple!(keyword!(as), syn!(Ident))) >> + semi: punct!(;) >> + (ItemExternCrate { + attrs: attrs, + vis: vis, + extern_token: extern_, + crate_token: crate_, + ident: ident, + rename: rename, + semi_token: semi, + }) + )); + + impl_synom!(ItemUse "use item" do_parse!( + attrs: many0!(Attribute::parse_outer) >> + vis: syn!(Visibility) >> + use_: keyword!(use) >> + leading_colon: option!(punct!(::)) >> + tree: syn!(UseTree) >> + semi: punct!(;) >> + (ItemUse { + attrs: attrs, + vis: vis, + use_token: use_, + leading_colon: leading_colon, + tree: tree, + semi_token: semi, + }) + )); + + named!(use_element -> Ident, alt!( + syn!(Ident) + | + keyword!(self) => { Into::into } + | + keyword!(super) => { Into::into } + | + keyword!(crate) => { Into::into } + | + keyword!(extern) => { Into::into } + )); + + impl_synom!(UseTree "use tree" alt!( + syn!(UseRename) => { UseTree::Rename } + | + syn!(UsePath) => { UseTree::Path } + | + syn!(UseName) => { UseTree::Name } + | + syn!(UseGlob) => { UseTree::Glob } + | + syn!(UseGroup) => { UseTree::Group } + )); + + impl_synom!(UsePath "use path" do_parse!( + ident: call!(use_element) >> + colon2_token: punct!(::) >> + tree: syn!(UseTree) >> + (UsePath { + ident: ident, + colon2_token: colon2_token, + tree: Box::new(tree), + }) + )); + + impl_synom!(UseName "use name" do_parse!( + ident: call!(use_element) >> + (UseName { + ident: ident, + }) + )); + + impl_synom!(UseRename "use rename" do_parse!( + ident: call!(use_element) >> + as_token: keyword!(as) >> + rename: syn!(Ident) >> + (UseRename { + ident: ident, + as_token: as_token, + rename: rename, + }) + )); + + impl_synom!(UseGlob "use glob" do_parse!( + star: punct!(*) >> + (UseGlob { + star_token: star, + }) + )); + + impl_synom!(UseGroup "use group" do_parse!( + list: braces!(Punctuated::parse_terminated) >> + (UseGroup { + brace_token: list.0, + items: list.1, + }) + )); + + impl_synom!(ItemStatic "static item" do_parse!( + attrs: many0!(Attribute::parse_outer) >> + vis: syn!(Visibility) >> + static_: keyword!(static) >> + mutability: option!(keyword!(mut)) >> + ident: syn!(Ident) >> + colon: punct!(:) >> + ty: syn!(Type) >> + eq: punct!(=) >> + value: syn!(Expr) >> + semi: punct!(;) >> + (ItemStatic { + attrs: attrs, + vis: vis, + static_token: static_, + mutability: mutability, + ident: ident, + colon_token: colon, + ty: Box::new(ty), + eq_token: eq, + expr: Box::new(value), + semi_token: semi, + }) + )); + + impl_synom!(ItemConst "const item" do_parse!( + attrs: many0!(Attribute::parse_outer) >> + vis: syn!(Visibility) >> + const_: keyword!(const) >> + ident: syn!(Ident) >> + colon: punct!(:) >> + ty: syn!(Type) >> + eq: punct!(=) >> + value: syn!(Expr) >> + semi: punct!(;) >> + (ItemConst { + attrs: attrs, + vis: vis, + const_token: const_, + ident: ident, + colon_token: colon, + ty: Box::new(ty), + eq_token: eq, + expr: Box::new(value), + semi_token: semi, + }) + )); + + impl_synom!(ItemFn "fn item" do_parse!( + outer_attrs: many0!(Attribute::parse_outer) >> + vis: syn!(Visibility) >> + constness: option!(keyword!(const)) >> + unsafety: option!(keyword!(unsafe)) >> + abi: option!(syn!(Abi)) >> + fn_: keyword!(fn) >> + ident: syn!(Ident) >> + generics: syn!(Generics) >> + inputs: parens!(Punctuated::parse_terminated) >> + ret: syn!(ReturnType) >> + where_clause: option!(syn!(WhereClause)) >> + inner_attrs_stmts: braces!(tuple!( + many0!(Attribute::parse_inner), + call!(Block::parse_within), + )) >> + (ItemFn { + attrs: { + let mut attrs = outer_attrs; + attrs.extend((inner_attrs_stmts.1).0); + attrs + }, + vis: vis, + constness: constness, + unsafety: unsafety, + abi: abi, + decl: Box::new(FnDecl { + fn_token: fn_, + paren_token: inputs.0, + inputs: inputs.1, + output: ret, + variadic: None, + generics: Generics { + where_clause: where_clause, + ..generics + }, + }), + ident: ident, + block: Box::new(Block { + brace_token: inner_attrs_stmts.0, + stmts: (inner_attrs_stmts.1).1, + }), + }) + )); + + named!(unstable_async_fn -> ItemVerbatim, do_parse!( + begin: call!(verbatim::grab_cursor) >> + many0!(Attribute::parse_outer) >> + syn!(Visibility) >> + option!(keyword!(const)) >> + option!(keyword!(unsafe)) >> + keyword!(async) >> + option!(syn!(Abi)) >> + keyword!(fn) >> + syn!(Ident) >> + syn!(Generics) >> + parens!(Punctuated::::parse_terminated) >> + syn!(ReturnType) >> + option!(syn!(WhereClause)) >> + braces!(tuple!( + many0!(Attribute::parse_inner), + call!(Block::parse_within), + )) >> + end: call!(verbatim::grab_cursor) >> + (ItemVerbatim { + tts: verbatim::token_range(begin..end), + }) + )); + + impl Synom for FnArg { + named!(parse -> Self, alt!( + do_parse!( + and: punct!(&) >> + lt: option!(syn!(Lifetime)) >> + mutability: option!(keyword!(mut)) >> + self_: keyword!(self) >> + not!(punct!(:)) >> + (ArgSelfRef { + lifetime: lt, + mutability: mutability, + and_token: and, + self_token: self_, + }.into()) + ) + | + do_parse!( + mutability: option!(keyword!(mut)) >> + self_: keyword!(self) >> + not!(punct!(:)) >> + (ArgSelf { + mutability: mutability, + self_token: self_, + }.into()) + ) + | + do_parse!( + pat: syn!(Pat) >> + colon: punct!(:) >> + ty: syn!(Type) >> + (ArgCaptured { + pat: pat, + ty: ty, + colon_token: colon, + }.into()) + ) + | + syn!(Type) => { FnArg::Ignored } + )); + + fn description() -> Option<&'static str> { + Some("function argument") + } + } + + impl_synom!(ItemMod "mod item" do_parse!( + outer_attrs: many0!(Attribute::parse_outer) >> + vis: syn!(Visibility) >> + mod_: keyword!(mod) >> + ident: syn!(Ident) >> + content_semi: alt!( + punct!(;) => {|semi| ( + Vec::new(), + None, + Some(semi), + )} + | + braces!( + tuple!( + many0!(Attribute::parse_inner), + many0!(Item::parse), + ) + ) => {|(brace, (inner_attrs, items))| ( + inner_attrs, + Some((brace, items)), + None, + )} + ) >> + (ItemMod { + attrs: { + let mut attrs = outer_attrs; + attrs.extend(content_semi.0); + attrs + }, + vis: vis, + mod_token: mod_, + ident: ident, + content: content_semi.1, + semi: content_semi.2, + }) + )); + + impl_synom!(ItemForeignMod "foreign mod item" do_parse!( + outer_attrs: many0!(Attribute::parse_outer) >> + abi: syn!(Abi) >> + braced_content: braces!(tuple!( + many0!(Attribute::parse_inner), + many0!(ForeignItem::parse), + )) >> + (ItemForeignMod { + attrs: { + let mut attrs = outer_attrs; + attrs.extend((braced_content.1).0); + attrs + }, + abi: abi, + brace_token: braced_content.0, + items: (braced_content.1).1, + }) + )); + + impl_synom!(ForeignItem "foreign item" alt!( + syn!(ForeignItemFn) => { ForeignItem::Fn } + | + syn!(ForeignItemStatic) => { ForeignItem::Static } + | + syn!(ForeignItemType) => { ForeignItem::Type } + | + call!(foreign_item_macro) => { ForeignItem::Verbatim } + )); + + impl_synom!(ForeignItemFn "foreign function" do_parse!( + attrs: many0!(Attribute::parse_outer) >> + vis: syn!(Visibility) >> + fn_: keyword!(fn) >> + ident: syn!(Ident) >> + generics: syn!(Generics) >> + inputs: parens!(do_parse!( + args: call!(Punctuated::parse_terminated) >> + variadic: option!(cond_reduce!(args.empty_or_trailing(), punct!(...))) >> + (args, variadic) + )) >> + ret: syn!(ReturnType) >> + where_clause: option!(syn!(WhereClause)) >> + semi: punct!(;) >> + ({ + let (parens, (inputs, variadic)) = inputs; + ForeignItemFn { + ident: ident, + attrs: attrs, + semi_token: semi, + decl: Box::new(FnDecl { + fn_token: fn_, + paren_token: parens, + inputs: inputs, + variadic: variadic, + output: ret, + generics: Generics { + where_clause: where_clause, + ..generics + }, + }), + vis: vis, + } + }) + )); + + impl_synom!(ForeignItemStatic "foreign static" do_parse!( + attrs: many0!(Attribute::parse_outer) >> + vis: syn!(Visibility) >> + static_: keyword!(static) >> + mutability: option!(keyword!(mut)) >> + ident: syn!(Ident) >> + colon: punct!(:) >> + ty: syn!(Type) >> + semi: punct!(;) >> + (ForeignItemStatic { + ident: ident, + attrs: attrs, + semi_token: semi, + ty: Box::new(ty), + mutability: mutability, + static_token: static_, + colon_token: colon, + vis: vis, + }) + )); + + impl_synom!(ForeignItemType "foreign type" do_parse!( + attrs: many0!(Attribute::parse_outer) >> + vis: syn!(Visibility) >> + type_: keyword!(type) >> + ident: syn!(Ident) >> + semi: punct!(;) >> + (ForeignItemType { + attrs: attrs, + vis: vis, + type_token: type_, + ident: ident, + semi_token: semi, + }) + )); + + named!(foreign_item_macro -> ForeignItemVerbatim, do_parse!( + begin: call!(verbatim::grab_cursor) >> + many0!(Attribute::parse_outer) >> + mac: syn!(Macro) >> + cond!(!is_brace(&mac.delimiter), punct!(;)) >> + end: call!(verbatim::grab_cursor) >> + (ForeignItemVerbatim { + tts: verbatim::token_range(begin..end), + }) + )); + + impl_synom!(ItemType "type item" do_parse!( + attrs: many0!(Attribute::parse_outer) >> + vis: syn!(Visibility) >> + type_: keyword!(type) >> + ident: syn!(Ident) >> + generics: syn!(Generics) >> + where_clause: option!(syn!(WhereClause)) >> + eq: punct!(=) >> + ty: syn!(Type) >> + semi: punct!(;) >> + (ItemType { + attrs: attrs, + vis: vis, + type_token: type_, + ident: ident, + generics: Generics { + where_clause: where_clause, + ..generics + }, + eq_token: eq, + ty: Box::new(ty), + semi_token: semi, + }) + )); + + named!(existential_type_helper(vis: bool) -> TokenStream, do_parse!( + begin: call!(verbatim::grab_cursor) >> + many0!(Attribute::parse_outer) >> + cond_reduce!(vis, syn!(Visibility)) >> + custom_keyword!(existential) >> + keyword!(type) >> + syn!(Ident) >> + syn!(Generics) >> + option!(syn!(WhereClause)) >> + colon: option!(punct!(:)) >> + cond!( + colon.is_some(), + Punctuated::::parse_separated_nonempty + ) >> + punct!(;) >> + end: call!(verbatim::grab_cursor) >> + (verbatim::token_range(begin..end)) + )); + + named!(unstable_existential_type -> ItemVerbatim, map!( + call!(existential_type_helper, true), + |tts| ItemVerbatim { tts: tts } + )); + + impl_synom!(ItemStruct "struct item" switch!( + map!(syn!(DeriveInput), Into::into), + Item::Struct(item) => value!(item) + | + _ => reject!() + )); + + impl_synom!(ItemEnum "enum item" switch!( + map!(syn!(DeriveInput), Into::into), + Item::Enum(item) => value!(item) + | + _ => reject!() + )); + + impl_synom!(ItemUnion "union item" do_parse!( + attrs: many0!(Attribute::parse_outer) >> + vis: syn!(Visibility) >> + union_: keyword!(union) >> + ident: syn!(Ident) >> + generics: syn!(Generics) >> + where_clause: option!(syn!(WhereClause)) >> + fields: syn!(FieldsNamed) >> + (ItemUnion { + attrs: attrs, + vis: vis, + union_token: union_, + ident: ident, + generics: Generics { + where_clause: where_clause, + ..generics + }, + fields: fields, + }) + )); + + impl_synom!(ItemTrait "trait item" do_parse!( + attrs: many0!(Attribute::parse_outer) >> + vis: syn!(Visibility) >> + unsafety: option!(keyword!(unsafe)) >> + auto_: option!(keyword!(auto)) >> + trait_: keyword!(trait) >> + ident: syn!(Ident) >> + generics: syn!(Generics) >> + colon: option!(punct!(:)) >> + bounds: cond!(colon.is_some(), Punctuated::parse_separated_nonempty) >> + where_clause: option!(syn!(WhereClause)) >> + body: braces!(many0!(TraitItem::parse)) >> + (ItemTrait { + attrs: attrs, + vis: vis, + unsafety: unsafety, + auto_token: auto_, + trait_token: trait_, + ident: ident, + generics: Generics { + where_clause: where_clause, + ..generics + }, + colon_token: colon, + supertraits: bounds.unwrap_or_default(), + brace_token: body.0, + items: body.1, + }) + )); + + impl_synom!(TraitItem "trait item" alt!( + syn!(TraitItemConst) => { TraitItem::Const } + | + syn!(TraitItemMethod) => { TraitItem::Method } + | + syn!(TraitItemType) => { TraitItem::Type } + | + call!(unstable_trait_existential_type) => { TraitItem::Verbatim } + | + syn!(TraitItemMacro) => { TraitItem::Macro } + )); + + impl_synom!(TraitItemConst "const trait item" do_parse!( + attrs: many0!(Attribute::parse_outer) >> + const_: keyword!(const) >> + ident: syn!(Ident) >> + colon: punct!(:) >> + ty: syn!(Type) >> + default: option!(tuple!(punct!(=), syn!(Expr))) >> + semi: punct!(;) >> + (TraitItemConst { + attrs: attrs, + const_token: const_, + ident: ident, + colon_token: colon, + ty: ty, + default: default, + semi_token: semi, + }) + )); + + impl_synom!(TraitItemMethod "method trait item" do_parse!( + outer_attrs: many0!(Attribute::parse_outer) >> + constness: option!(keyword!(const)) >> + unsafety: option!(keyword!(unsafe)) >> + abi: option!(syn!(Abi)) >> + fn_: keyword!(fn) >> + ident: syn!(Ident) >> + generics: syn!(Generics) >> + inputs: parens!(Punctuated::parse_terminated) >> + ret: syn!(ReturnType) >> + where_clause: option!(syn!(WhereClause)) >> + body: option!(braces!(tuple!( + many0!(Attribute::parse_inner), + call!(Block::parse_within), + ))) >> + semi: cond!(body.is_none(), punct!(;)) >> + ({ + let (inner_attrs, stmts) = match body { + Some((b, (inner_attrs, stmts))) => (inner_attrs, Some((stmts, b))), + None => (Vec::new(), None), + }; + TraitItemMethod { + attrs: { + let mut attrs = outer_attrs; + attrs.extend(inner_attrs); + attrs + }, + sig: MethodSig { + constness: constness, + unsafety: unsafety, + abi: abi, + ident: ident, + decl: FnDecl { + inputs: inputs.1, + output: ret, + fn_token: fn_, + paren_token: inputs.0, + variadic: None, + generics: Generics { + where_clause: where_clause, + ..generics + }, + }, + }, + default: stmts.map(|stmts| { + Block { + stmts: stmts.0, + brace_token: stmts.1, + } + }), + semi_token: semi, + } + }) + )); + + impl_synom!(TraitItemType "trait item type" do_parse!( + attrs: many0!(Attribute::parse_outer) >> + type_: keyword!(type) >> + ident: syn!(Ident) >> + generics: syn!(Generics) >> + colon: option!(punct!(:)) >> + bounds: cond!(colon.is_some(), Punctuated::parse_separated_nonempty) >> + where_clause: option!(syn!(WhereClause)) >> + default: option!(tuple!(punct!(=), syn!(Type))) >> + semi: punct!(;) >> + (TraitItemType { + attrs: attrs, + type_token: type_, + ident: ident, + generics: Generics { + where_clause: where_clause, + ..generics + }, + colon_token: colon, + bounds: bounds.unwrap_or_default(), + default: default, + semi_token: semi, + }) + )); + + named!(unstable_trait_existential_type -> TraitItemVerbatim, map!( + call!(existential_type_helper, false), + |tts| TraitItemVerbatim { tts: tts } + )); + + impl_synom!(TraitItemMacro "trait item macro" do_parse!( + attrs: many0!(Attribute::parse_outer) >> + mac: syn!(Macro) >> + semi: cond!(!is_brace(&mac.delimiter), punct!(;)) >> + (TraitItemMacro { + attrs: attrs, + mac: mac, + semi_token: semi, + }) + )); + + impl_synom!(ItemImpl "impl item" do_parse!( + outer_attrs: many0!(Attribute::parse_outer) >> + defaultness: option!(keyword!(default)) >> + unsafety: option!(keyword!(unsafe)) >> + impl_: keyword!(impl) >> + generics: syn!(Generics) >> + polarity_path: alt!( + do_parse!( + polarity: option!(punct!(!)) >> + path: syn!(Path) >> + for_: keyword!(for) >> + (Some((polarity, path, for_))) + ) + | + epsilon!() => { |_| None } + ) >> + self_ty: syn!(Type) >> + where_clause: option!(syn!(WhereClause)) >> + inner: braces!(tuple!( + many0!(Attribute::parse_inner), + many0!(ImplItem::parse), + )) >> + (ItemImpl { + attrs: { + let mut attrs = outer_attrs; + attrs.extend((inner.1).0); + attrs + }, + defaultness: defaultness, + unsafety: unsafety, + impl_token: impl_, + generics: Generics { + where_clause: where_clause, + ..generics + }, + trait_: polarity_path, + self_ty: Box::new(self_ty), + brace_token: inner.0, + items: (inner.1).1, + }) + )); + + impl_synom!(ImplItem "item in impl block" alt!( + syn!(ImplItemConst) => { ImplItem::Const } + | + syn!(ImplItemMethod) => { ImplItem::Method } + | + call!(unstable_async_method) => { ImplItem::Verbatim } + | + syn!(ImplItemType) => { ImplItem::Type } + | + call!(unstable_impl_existential_type) => { ImplItem::Verbatim } + | + syn!(ImplItemMacro) => { ImplItem::Macro } + )); + + impl_synom!(ImplItemConst "const item in impl block" do_parse!( + attrs: many0!(Attribute::parse_outer) >> + vis: syn!(Visibility) >> + defaultness: option!(keyword!(default)) >> + const_: keyword!(const) >> + ident: syn!(Ident) >> + colon: punct!(:) >> + ty: syn!(Type) >> + eq: punct!(=) >> + value: syn!(Expr) >> + semi: punct!(;) >> + (ImplItemConst { + attrs: attrs, + vis: vis, + defaultness: defaultness, + const_token: const_, + ident: ident, + colon_token: colon, + ty: ty, + eq_token: eq, + expr: value, + semi_token: semi, + }) + )); + + impl_synom!(ImplItemMethod "method in impl block" do_parse!( + outer_attrs: many0!(Attribute::parse_outer) >> + vis: syn!(Visibility) >> + defaultness: option!(keyword!(default)) >> + constness: option!(keyword!(const)) >> + unsafety: option!(keyword!(unsafe)) >> + abi: option!(syn!(Abi)) >> + fn_: keyword!(fn) >> + ident: syn!(Ident) >> + generics: syn!(Generics) >> + inputs: parens!(Punctuated::parse_terminated) >> + ret: syn!(ReturnType) >> + where_clause: option!(syn!(WhereClause)) >> + inner_attrs_stmts: braces!(tuple!( + many0!(Attribute::parse_inner), + call!(Block::parse_within), + )) >> + (ImplItemMethod { + attrs: { + let mut attrs = outer_attrs; + attrs.extend((inner_attrs_stmts.1).0); + attrs + }, + vis: vis, + defaultness: defaultness, + sig: MethodSig { + constness: constness, + unsafety: unsafety, + abi: abi, + ident: ident, + decl: FnDecl { + fn_token: fn_, + paren_token: inputs.0, + inputs: inputs.1, + output: ret, + generics: Generics { + where_clause: where_clause, + ..generics + }, + variadic: None, + }, + }, + block: Block { + brace_token: inner_attrs_stmts.0, + stmts: (inner_attrs_stmts.1).1, + }, + }) + )); + + named!(unstable_async_method -> ImplItemVerbatim, do_parse!( + begin: call!(verbatim::grab_cursor) >> + many0!(Attribute::parse_outer) >> + syn!(Visibility) >> + option!(keyword!(default)) >> + option!(keyword!(const)) >> + option!(keyword!(unsafe)) >> + keyword!(async) >> + option!(syn!(Abi)) >> + keyword!(fn) >> + syn!(Ident) >> + syn!(Generics) >> + parens!(Punctuated::::parse_terminated) >> + syn!(ReturnType) >> + option!(syn!(WhereClause)) >> + braces!(tuple!( + many0!(Attribute::parse_inner), + call!(Block::parse_within), + )) >> + end: call!(verbatim::grab_cursor) >> + (ImplItemVerbatim { + tts: verbatim::token_range(begin..end), + }) + )); + + impl_synom!(ImplItemType "type in impl block" do_parse!( + attrs: many0!(Attribute::parse_outer) >> + vis: syn!(Visibility) >> + defaultness: option!(keyword!(default)) >> + type_: keyword!(type) >> + ident: syn!(Ident) >> + generics: syn!(Generics) >> + where_clause: option!(syn!(WhereClause)) >> + eq: punct!(=) >> + ty: syn!(Type) >> + semi: punct!(;) >> + (ImplItemType { + attrs: attrs, + vis: vis, + defaultness: defaultness, + type_token: type_, + ident: ident, + generics: Generics { + where_clause: where_clause, + ..generics + }, + eq_token: eq, + ty: ty, + semi_token: semi, + }) + )); + + named!(unstable_impl_existential_type -> ImplItemVerbatim, map!( + call!(existential_type_helper, true), + |tts| ImplItemVerbatim { tts: tts } + )); + + impl_synom!(ImplItemMacro "macro in impl block" do_parse!( + attrs: many0!(Attribute::parse_outer) >> + mac: syn!(Macro) >> + semi: cond!(!is_brace(&mac.delimiter), punct!(;)) >> + (ImplItemMacro { + attrs: attrs, + mac: mac, + semi_token: semi, + }) + )); + + fn is_brace(delimiter: &MacroDelimiter) -> bool { + match *delimiter { + MacroDelimiter::Brace(_) => true, + MacroDelimiter::Paren(_) | MacroDelimiter::Bracket(_) => false, + } + } +} + +#[cfg(feature = "printing")] +mod printing { + use super::*; + use attr::FilterAttrs; + use proc_macro2::TokenStream; + use quote::{ToTokens, TokenStreamExt}; + + impl ToTokens for ItemExternCrate { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.vis.to_tokens(tokens); + self.extern_token.to_tokens(tokens); + self.crate_token.to_tokens(tokens); + self.ident.to_tokens(tokens); + if let Some((ref as_token, ref rename)) = self.rename { + as_token.to_tokens(tokens); + rename.to_tokens(tokens); + } + self.semi_token.to_tokens(tokens); + } + } + + impl ToTokens for ItemUse { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.vis.to_tokens(tokens); + self.use_token.to_tokens(tokens); + self.leading_colon.to_tokens(tokens); + self.tree.to_tokens(tokens); + self.semi_token.to_tokens(tokens); + } + } + + impl ToTokens for ItemStatic { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.vis.to_tokens(tokens); + self.static_token.to_tokens(tokens); + self.mutability.to_tokens(tokens); + self.ident.to_tokens(tokens); + self.colon_token.to_tokens(tokens); + self.ty.to_tokens(tokens); + self.eq_token.to_tokens(tokens); + self.expr.to_tokens(tokens); + self.semi_token.to_tokens(tokens); + } + } + + impl ToTokens for ItemConst { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.vis.to_tokens(tokens); + self.const_token.to_tokens(tokens); + self.ident.to_tokens(tokens); + self.colon_token.to_tokens(tokens); + self.ty.to_tokens(tokens); + self.eq_token.to_tokens(tokens); + self.expr.to_tokens(tokens); + self.semi_token.to_tokens(tokens); + } + } + + impl ToTokens for ItemFn { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.vis.to_tokens(tokens); + self.constness.to_tokens(tokens); + self.unsafety.to_tokens(tokens); + self.abi.to_tokens(tokens); + NamedDecl(&self.decl, &self.ident).to_tokens(tokens); + self.block.brace_token.surround(tokens, |tokens| { + tokens.append_all(self.attrs.inner()); + tokens.append_all(&self.block.stmts); + }); + } + } + + impl ToTokens for ItemMod { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.vis.to_tokens(tokens); + self.mod_token.to_tokens(tokens); + self.ident.to_tokens(tokens); + if let Some((ref brace, ref items)) = self.content { + brace.surround(tokens, |tokens| { + tokens.append_all(self.attrs.inner()); + tokens.append_all(items); + }); + } else { + TokensOrDefault(&self.semi).to_tokens(tokens); + } + } + } + + impl ToTokens for ItemForeignMod { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.abi.to_tokens(tokens); + self.brace_token.surround(tokens, |tokens| { + tokens.append_all(self.attrs.inner()); + tokens.append_all(&self.items); + }); + } + } + + impl ToTokens for ItemType { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.vis.to_tokens(tokens); + self.type_token.to_tokens(tokens); + self.ident.to_tokens(tokens); + self.generics.to_tokens(tokens); + self.generics.where_clause.to_tokens(tokens); + self.eq_token.to_tokens(tokens); + self.ty.to_tokens(tokens); + self.semi_token.to_tokens(tokens); + } + } + + impl ToTokens for ItemEnum { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.vis.to_tokens(tokens); + self.enum_token.to_tokens(tokens); + self.ident.to_tokens(tokens); + self.generics.to_tokens(tokens); + self.generics.where_clause.to_tokens(tokens); + self.brace_token.surround(tokens, |tokens| { + self.variants.to_tokens(tokens); + }); + } + } + + impl ToTokens for ItemStruct { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.vis.to_tokens(tokens); + self.struct_token.to_tokens(tokens); + self.ident.to_tokens(tokens); + self.generics.to_tokens(tokens); + match self.fields { + Fields::Named(ref fields) => { + self.generics.where_clause.to_tokens(tokens); + fields.to_tokens(tokens); + } + Fields::Unnamed(ref fields) => { + fields.to_tokens(tokens); + self.generics.where_clause.to_tokens(tokens); + TokensOrDefault(&self.semi_token).to_tokens(tokens); + } + Fields::Unit => { + self.generics.where_clause.to_tokens(tokens); + TokensOrDefault(&self.semi_token).to_tokens(tokens); + } + } + } + } + + impl ToTokens for ItemUnion { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.vis.to_tokens(tokens); + self.union_token.to_tokens(tokens); + self.ident.to_tokens(tokens); + self.generics.to_tokens(tokens); + self.generics.where_clause.to_tokens(tokens); + self.fields.to_tokens(tokens); + } + } + + impl ToTokens for ItemTrait { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.vis.to_tokens(tokens); + self.unsafety.to_tokens(tokens); + self.auto_token.to_tokens(tokens); + self.trait_token.to_tokens(tokens); + self.ident.to_tokens(tokens); + self.generics.to_tokens(tokens); + if !self.supertraits.is_empty() { + TokensOrDefault(&self.colon_token).to_tokens(tokens); + self.supertraits.to_tokens(tokens); + } + self.generics.where_clause.to_tokens(tokens); + self.brace_token.surround(tokens, |tokens| { + tokens.append_all(&self.items); + }); + } + } + + impl ToTokens for ItemImpl { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.defaultness.to_tokens(tokens); + self.unsafety.to_tokens(tokens); + self.impl_token.to_tokens(tokens); + self.generics.to_tokens(tokens); + if let Some((ref polarity, ref path, ref for_token)) = self.trait_ { + polarity.to_tokens(tokens); + path.to_tokens(tokens); + for_token.to_tokens(tokens); + } + self.self_ty.to_tokens(tokens); + self.generics.where_clause.to_tokens(tokens); + self.brace_token.surround(tokens, |tokens| { + tokens.append_all(self.attrs.inner()); + tokens.append_all(&self.items); + }); + } + } + + impl ToTokens for ItemMacro { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.mac.path.to_tokens(tokens); + self.mac.bang_token.to_tokens(tokens); + self.ident.to_tokens(tokens); + match self.mac.delimiter { + MacroDelimiter::Paren(ref paren) => { + paren.surround(tokens, |tokens| self.mac.tts.to_tokens(tokens)); + } + MacroDelimiter::Brace(ref brace) => { + brace.surround(tokens, |tokens| self.mac.tts.to_tokens(tokens)); + } + MacroDelimiter::Bracket(ref bracket) => { + bracket.surround(tokens, |tokens| self.mac.tts.to_tokens(tokens)); + } + } + self.semi_token.to_tokens(tokens); + } + } + + impl ToTokens for ItemMacro2 { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.vis.to_tokens(tokens); + self.macro_token.to_tokens(tokens); + self.ident.to_tokens(tokens); + self.paren_token.surround(tokens, |tokens| { + self.args.to_tokens(tokens); + }); + self.brace_token.surround(tokens, |tokens| { + self.body.to_tokens(tokens); + }); + } + } + + impl ToTokens for ItemVerbatim { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.tts.to_tokens(tokens); + } + } + + impl ToTokens for UsePath { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.ident.to_tokens(tokens); + self.colon2_token.to_tokens(tokens); + self.tree.to_tokens(tokens); + } + } + + impl ToTokens for UseName { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.ident.to_tokens(tokens); + } + } + + impl ToTokens for UseRename { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.ident.to_tokens(tokens); + self.as_token.to_tokens(tokens); + self.rename.to_tokens(tokens); + } + } + + impl ToTokens for UseGlob { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.star_token.to_tokens(tokens); + } + } + + impl ToTokens for UseGroup { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.brace_token.surround(tokens, |tokens| { + self.items.to_tokens(tokens); + }); + } + } + + impl ToTokens for TraitItemConst { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.const_token.to_tokens(tokens); + self.ident.to_tokens(tokens); + self.colon_token.to_tokens(tokens); + self.ty.to_tokens(tokens); + if let Some((ref eq_token, ref default)) = self.default { + eq_token.to_tokens(tokens); + default.to_tokens(tokens); + } + self.semi_token.to_tokens(tokens); + } + } + + impl ToTokens for TraitItemMethod { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.sig.to_tokens(tokens); + match self.default { + Some(ref block) => { + block.brace_token.surround(tokens, |tokens| { + tokens.append_all(self.attrs.inner()); + tokens.append_all(&block.stmts); + }); + } + None => { + TokensOrDefault(&self.semi_token).to_tokens(tokens); + } + } + } + } + + impl ToTokens for TraitItemType { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.type_token.to_tokens(tokens); + self.ident.to_tokens(tokens); + self.generics.to_tokens(tokens); + if !self.bounds.is_empty() { + TokensOrDefault(&self.colon_token).to_tokens(tokens); + self.bounds.to_tokens(tokens); + } + self.generics.where_clause.to_tokens(tokens); + if let Some((ref eq_token, ref default)) = self.default { + eq_token.to_tokens(tokens); + default.to_tokens(tokens); + } + self.semi_token.to_tokens(tokens); + } + } + + impl ToTokens for TraitItemMacro { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.mac.to_tokens(tokens); + self.semi_token.to_tokens(tokens); + } + } + + impl ToTokens for TraitItemVerbatim { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.tts.to_tokens(tokens); + } + } + + impl ToTokens for ImplItemConst { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.vis.to_tokens(tokens); + self.defaultness.to_tokens(tokens); + self.const_token.to_tokens(tokens); + self.ident.to_tokens(tokens); + self.colon_token.to_tokens(tokens); + self.ty.to_tokens(tokens); + self.eq_token.to_tokens(tokens); + self.expr.to_tokens(tokens); + self.semi_token.to_tokens(tokens); + } + } + + impl ToTokens for ImplItemMethod { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.vis.to_tokens(tokens); + self.defaultness.to_tokens(tokens); + self.sig.to_tokens(tokens); + self.block.brace_token.surround(tokens, |tokens| { + tokens.append_all(self.attrs.inner()); + tokens.append_all(&self.block.stmts); + }); + } + } + + impl ToTokens for ImplItemType { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.vis.to_tokens(tokens); + self.defaultness.to_tokens(tokens); + self.type_token.to_tokens(tokens); + self.ident.to_tokens(tokens); + self.generics.to_tokens(tokens); + self.generics.where_clause.to_tokens(tokens); + self.eq_token.to_tokens(tokens); + self.ty.to_tokens(tokens); + self.semi_token.to_tokens(tokens); + } + } + + impl ToTokens for ImplItemMacro { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.mac.to_tokens(tokens); + self.semi_token.to_tokens(tokens); + } + } + + impl ToTokens for ImplItemVerbatim { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.tts.to_tokens(tokens); + } + } + + impl ToTokens for ForeignItemFn { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.vis.to_tokens(tokens); + NamedDecl(&self.decl, &self.ident).to_tokens(tokens); + self.semi_token.to_tokens(tokens); + } + } + + impl ToTokens for ForeignItemStatic { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.vis.to_tokens(tokens); + self.static_token.to_tokens(tokens); + self.mutability.to_tokens(tokens); + self.ident.to_tokens(tokens); + self.colon_token.to_tokens(tokens); + self.ty.to_tokens(tokens); + self.semi_token.to_tokens(tokens); + } + } + + impl ToTokens for ForeignItemType { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.attrs.outer()); + self.vis.to_tokens(tokens); + self.type_token.to_tokens(tokens); + self.ident.to_tokens(tokens); + self.semi_token.to_tokens(tokens); + } + } + + impl ToTokens for ForeignItemVerbatim { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.tts.to_tokens(tokens); + } + } + + impl ToTokens for MethodSig { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.constness.to_tokens(tokens); + self.unsafety.to_tokens(tokens); + self.abi.to_tokens(tokens); + NamedDecl(&self.decl, &self.ident).to_tokens(tokens); + } + } + + struct NamedDecl<'a>(&'a FnDecl, &'a Ident); + + impl<'a> ToTokens for NamedDecl<'a> { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.0.fn_token.to_tokens(tokens); + self.1.to_tokens(tokens); + self.0.generics.to_tokens(tokens); + self.0.paren_token.surround(tokens, |tokens| { + self.0.inputs.to_tokens(tokens); + if self.0.variadic.is_some() && !self.0.inputs.empty_or_trailing() { + ::default().to_tokens(tokens); + } + self.0.variadic.to_tokens(tokens); + }); + self.0.output.to_tokens(tokens); + self.0.generics.where_clause.to_tokens(tokens); + } + } + + impl ToTokens for ArgSelfRef { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.and_token.to_tokens(tokens); + self.lifetime.to_tokens(tokens); + self.mutability.to_tokens(tokens); + self.self_token.to_tokens(tokens); + } + } + + impl ToTokens for ArgSelf { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.mutability.to_tokens(tokens); + self.self_token.to_tokens(tokens); + } + } + + impl ToTokens for ArgCaptured { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.pat.to_tokens(tokens); + self.colon_token.to_tokens(tokens); + self.ty.to_tokens(tokens); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/lib.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/lib.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,788 @@ +// Copyright 2018 Syn Developers +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Syn is a parsing library for parsing a stream of Rust tokens into a syntax +//! tree of Rust source code. +//! +//! Currently this library is geared toward the [custom derive] use case but +//! contains some APIs that may be useful for Rust procedural macros more +//! generally. +//! +//! [custom derive]: https://github.com/rust-lang/rfcs/blob/master/text/1681-macros-1.1.md +//! +//! - **Data structures** — Syn provides a complete syntax tree that can +//! represent any valid Rust source code. The syntax tree is rooted at +//! [`syn::File`] which represents a full source file, but there are other +//! entry points that may be useful to procedural macros including +//! [`syn::Item`], [`syn::Expr`] and [`syn::Type`]. +//! +//! - **Custom derives** — Of particular interest to custom derives is +//! [`syn::DeriveInput`] which is any of the three legal input items to a +//! derive macro. An example below shows using this type in a library that can +//! derive implementations of a trait of your own. +//! +//! - **Parser combinators** — Parsing in Syn is built on a suite of public +//! parser combinator macros that you can use for parsing any token-based +//! syntax you dream up within a `functionlike!(...)` procedural macro. Every +//! syntax tree node defined by Syn is individually parsable and may be used +//! as a building block for custom syntaxes, or you may do it all yourself +//! working from the most primitive tokens. +//! +//! - **Location information** — Every token parsed by Syn is associated with a +//! `Span` that tracks line and column information back to the source of that +//! token. These spans allow a procedural macro to display detailed error +//! messages pointing to all the right places in the user's code. There is an +//! example of this below. +//! +//! - **Feature flags** — Functionality is aggressively feature gated so your +//! procedural macros enable only what they need, and do not pay in compile +//! time for all the rest. +//! +//! [`syn::File`]: struct.File.html +//! [`syn::Item`]: enum.Item.html +//! [`syn::Expr`]: enum.Expr.html +//! [`syn::Type`]: enum.Type.html +//! [`syn::DeriveInput`]: struct.DeriveInput.html +//! +//! *Version requirement: Syn supports any compiler version back to Rust's very +//! first support for procedural macros in Rust 1.15.0. Some features especially +//! around error reporting are only available in newer compilers or on the +//! nightly channel.* +//! +//! ## Example of a custom derive +//! +//! The canonical custom derive using Syn looks like this. We write an ordinary +//! Rust function tagged with a `proc_macro_derive` attribute and the name of +//! the trait we are deriving. Any time that derive appears in the user's code, +//! the Rust compiler passes their data structure as tokens into our macro. We +//! get to execute arbitrary Rust code to figure out what to do with those +//! tokens, then hand some tokens back to the compiler to compile into the +//! user's crate. +//! +//! [`TokenStream`]: https://doc.rust-lang.org/proc_macro/struct.TokenStream.html +//! +//! ```toml +//! [dependencies] +//! syn = "0.14" +//! quote = "0.6" +//! +//! [lib] +//! proc-macro = true +//! ``` +//! +//! ```rust +//! extern crate proc_macro; +//! extern crate syn; +//! +//! #[macro_use] +//! extern crate quote; +//! +//! use proc_macro::TokenStream; +//! use syn::DeriveInput; +//! +//! # const IGNORE_TOKENS: &str = stringify! { +//! #[proc_macro_derive(MyMacro)] +//! # }; +//! pub fn my_macro(input: TokenStream) -> TokenStream { +//! // Parse the input tokens into a syntax tree +//! let input: DeriveInput = syn::parse(input).unwrap(); +//! +//! // Build the output, possibly using quasi-quotation +//! let expanded = quote! { +//! // ... +//! }; +//! +//! // Hand the output tokens back to the compiler +//! expanded.into() +//! } +//! # +//! # fn main() {} +//! ``` +//! +//! The [`heapsize`] example directory shows a complete working Macros 1.1 +//! implementation of a custom derive. It works on any Rust compiler \>=1.15.0. +//! The example derives a `HeapSize` trait which computes an estimate of the +//! amount of heap memory owned by a value. +//! +//! [`heapsize`]: https://github.com/dtolnay/syn/tree/master/examples/heapsize +//! +//! ```rust +//! pub trait HeapSize { +//! /// Total number of bytes of heap memory owned by `self`. +//! fn heap_size_of_children(&self) -> usize; +//! } +//! ``` +//! +//! The custom derive allows users to write `#[derive(HeapSize)]` on data +//! structures in their program. +//! +//! ```rust +//! # const IGNORE_TOKENS: &str = stringify! { +//! #[derive(HeapSize)] +//! # }; +//! struct Demo<'a, T: ?Sized> { +//! a: Box, +//! b: u8, +//! c: &'a str, +//! d: String, +//! } +//! ``` +//! +//! ## Spans and error reporting +//! +//! The [`heapsize2`] example directory is an extension of the `heapsize` +//! example that demonstrates some of the hygiene and error reporting properties +//! of Macros 2.0. This example currently requires a nightly Rust compiler +//! \>=1.24.0-nightly but we are working to stabilize all of the APIs involved. +//! +//! [`heapsize2`]: https://github.com/dtolnay/syn/tree/master/examples/heapsize2 +//! +//! The token-based procedural macro API provides great control over where the +//! compiler's error messages are displayed in user code. Consider the error the +//! user sees if one of their field types does not implement `HeapSize`. +//! +//! ```rust +//! # const IGNORE_TOKENS: &str = stringify! { +//! #[derive(HeapSize)] +//! # }; +//! struct Broken { +//! ok: String, +//! bad: std::thread::Thread, +//! } +//! ``` +//! +//! In the Macros 1.1 string-based procedural macro world, the resulting error +//! would point unhelpfully to the invocation of the derive macro and not to the +//! actual problematic field. +//! +//! ```text +//! error[E0599]: no method named `heap_size_of_children` found for type `std::thread::Thread` in the current scope +//! --> src/main.rs:4:10 +//! | +//! 4 | #[derive(HeapSize)] +//! | ^^^^^^^^ +//! ``` +//! +//! By tracking span information all the way through the expansion of a +//! procedural macro as shown in the `heapsize2` example, token-based macros in +//! Syn are able to trigger errors that directly pinpoint the source of the +//! problem. +//! +//! ```text +//! error[E0277]: the trait bound `std::thread::Thread: HeapSize` is not satisfied +//! --> src/main.rs:7:5 +//! | +//! 7 | bad: std::thread::Thread, +//! | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HeapSize` is not implemented for `Thread` +//! ``` +//! +//! ## Parsing a custom syntax using combinators +//! +//! The [`lazy-static`] example directory shows the implementation of a +//! `functionlike!(...)` procedural macro in which the input tokens are parsed +//! using [`nom`]-style parser combinators. +//! +//! [`lazy-static`]: https://github.com/dtolnay/syn/tree/master/examples/lazy-static +//! [`nom`]: https://github.com/Geal/nom +//! +//! The example reimplements the popular `lazy_static` crate from crates.io as a +//! procedural macro. +//! +//! ``` +//! # macro_rules! lazy_static { +//! # ($($tt:tt)*) => {} +//! # } +//! # +//! lazy_static! { +//! static ref USERNAME: Regex = Regex::new("^[a-z0-9_-]{3,16}$").unwrap(); +//! } +//! ``` +//! +//! The implementation shows how to trigger custom warnings and error messages +//! on the macro input. +//! +//! ```text +//! warning: come on, pick a more creative name +//! --> src/main.rs:10:16 +//! | +//! 10 | static ref FOO: String = "lazy_static".to_owned(); +//! | ^^^ +//! ``` +//! +//! ## Debugging +//! +//! When developing a procedural macro it can be helpful to look at what the +//! generated code looks like. Use `cargo rustc -- -Zunstable-options +//! --pretty=expanded` or the [`cargo expand`] subcommand. +//! +//! [`cargo expand`]: https://github.com/dtolnay/cargo-expand +//! +//! To show the expanded code for some crate that uses your procedural macro, +//! run `cargo expand` from that crate. To show the expanded code for one of +//! your own test cases, run `cargo expand --test the_test_case` where the last +//! argument is the name of the test file without the `.rs` extension. +//! +//! This write-up by Brandon W Maister discusses debugging in more detail: +//! [Debugging Rust's new Custom Derive system][debugging]. +//! +//! [debugging]: https://quodlibetor.github.io/posts/debugging-rusts-new-custom-derive-system/ +//! +//! ## Optional features +//! +//! Syn puts a lot of functionality behind optional features in order to +//! optimize compile time for the most common use cases. The following features +//! are available. +//! +//! - **`derive`** *(enabled by default)* — Data structures for representing the +//! possible input to a custom derive, including structs and enums and types. +//! - **`full`** — Data structures for representing the syntax tree of all valid +//! Rust source code, including items and expressions. +//! - **`parsing`** *(enabled by default)* — Ability to parse input tokens into +//! a syntax tree node of a chosen type. +//! - **`printing`** *(enabled by default)* — Ability to print a syntax tree +//! node as tokens of Rust source code. +//! - **`visit`** — Trait for traversing a syntax tree. +//! - **`visit-mut`** — Trait for traversing and mutating in place a syntax +//! tree. +//! - **`fold`** — Trait for transforming an owned syntax tree. +//! - **`clone-impls`** *(enabled by default)* — Clone impls for all syntax tree +//! types. +//! - **`extra-traits`** — Debug, Eq, PartialEq, Hash impls for all syntax tree +//! types. +//! - **`proc-macro`** *(enabled by default)* — Runtime dependency on the +//! dynamic library libproc_macro from rustc toolchain. + +// Syn types in rustdoc of other crates get linked to here. +#![doc(html_root_url = "https://docs.rs/syn/0.14.9")] +#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))] +// Ignored clippy lints. +#![cfg_attr( + feature = "cargo-clippy", + allow( + const_static_lifetime, + doc_markdown, + large_enum_variant, + match_bool, + redundant_closure, + needless_pass_by_value, + redundant_field_names, + trivially_copy_pass_by_ref + ) +)] +// Ignored clippy_pedantic lints. +#![cfg_attr( + feature = "cargo-clippy", + allow( + cast_possible_truncation, + cast_possible_wrap, + if_not_else, + indexing_slicing, + items_after_statements, + shadow_unrelated, + similar_names, + single_match_else, + stutter, + unseparated_literal_suffix, + use_self, + used_underscore_binding + ) +)] + +#[cfg(all( + not(all(target_arch = "wasm32", target_os = "unknown")), + feature = "proc-macro" +))] +extern crate proc_macro; +extern crate proc_macro2; +extern crate unicode_xid; + +#[cfg(feature = "printing")] +extern crate quote; + +#[cfg(feature = "parsing")] +#[macro_use] +#[doc(hidden)] +pub mod parsers; + +#[macro_use] +mod macros; + +#[macro_use] +pub mod token; + +pub use proc_macro2::Ident; + +#[cfg(any(feature = "full", feature = "derive"))] +mod attr; +#[cfg(any(feature = "full", feature = "derive"))] +pub use attr::{AttrStyle, Attribute, Meta, MetaList, MetaNameValue, NestedMeta}; + +#[cfg(any(feature = "full", feature = "derive"))] +mod data; +#[cfg(any(feature = "full", feature = "derive"))] +pub use data::{ + Field, Fields, FieldsNamed, FieldsUnnamed, Variant, VisCrate, VisPublic, VisRestricted, + Visibility, +}; + +#[cfg(any(feature = "full", feature = "derive"))] +mod expr; +#[cfg(any(feature = "full", feature = "derive"))] +pub use expr::{ + Expr, ExprArray, ExprAssign, ExprAssignOp, ExprBinary, ExprBlock, ExprBox, ExprBreak, ExprCall, + ExprCast, ExprCatch, ExprClosure, ExprContinue, ExprField, ExprForLoop, ExprGroup, ExprIf, + ExprIfLet, ExprInPlace, ExprIndex, ExprLit, ExprLoop, ExprMacro, ExprMatch, ExprMethodCall, + ExprParen, ExprPath, ExprRange, ExprReference, ExprRepeat, ExprReturn, ExprStruct, ExprTry, + ExprTuple, ExprType, ExprUnary, ExprUnsafe, ExprVerbatim, ExprWhile, ExprWhileLet, ExprYield, + Index, Member, +}; + +#[cfg(feature = "full")] +pub use expr::{ + Arm, Block, FieldPat, FieldValue, GenericMethodArgument, Label, Local, MethodTurbofish, Pat, + PatBox, PatIdent, PatLit, PatMacro, PatPath, PatRange, PatRef, PatSlice, PatStruct, PatTuple, + PatTupleStruct, PatVerbatim, PatWild, RangeLimits, Stmt, +}; + +#[cfg(any(feature = "full", feature = "derive"))] +mod generics; +#[cfg(any(feature = "full", feature = "derive"))] +pub use generics::{ + BoundLifetimes, ConstParam, GenericParam, Generics, LifetimeDef, PredicateEq, + PredicateLifetime, PredicateType, TraitBound, TraitBoundModifier, TypeParam, TypeParamBound, + WhereClause, WherePredicate, +}; +#[cfg(all( + any(feature = "full", feature = "derive"), + feature = "printing" +))] +pub use generics::{ImplGenerics, Turbofish, TypeGenerics}; + +#[cfg(feature = "full")] +mod item; +#[cfg(feature = "full")] +pub use item::{ + ArgCaptured, ArgSelf, ArgSelfRef, FnArg, FnDecl, ForeignItem, ForeignItemFn, ForeignItemStatic, + ForeignItemType, ForeignItemVerbatim, ImplItem, ImplItemConst, ImplItemMacro, ImplItemMethod, + ImplItemType, ImplItemVerbatim, Item, ItemConst, ItemEnum, ItemExternCrate, ItemFn, + ItemForeignMod, ItemImpl, ItemMacro, ItemMacro2, ItemMod, ItemStatic, ItemStruct, ItemTrait, + ItemType, ItemUnion, ItemUse, ItemVerbatim, MethodSig, TraitItem, TraitItemConst, + TraitItemMacro, TraitItemMethod, TraitItemType, TraitItemVerbatim, UseGlob, UseGroup, UseName, + UsePath, UseRename, UseTree, +}; + +#[cfg(feature = "full")] +mod file; +#[cfg(feature = "full")] +pub use file::File; + +#[cfg(any(feature = "full", feature = "derive"))] +mod lifetime; +#[cfg(any(feature = "full", feature = "derive"))] +pub use lifetime::Lifetime; + +#[cfg(any(feature = "full", feature = "derive"))] +mod lit; +#[cfg(any(feature = "full", feature = "derive"))] +pub use lit::{ + FloatSuffix, IntSuffix, Lit, LitBool, LitByte, LitByteStr, LitChar, LitFloat, LitInt, LitStr, + LitVerbatim, StrStyle, +}; + +#[cfg(any(feature = "full", feature = "derive"))] +mod mac; +#[cfg(any(feature = "full", feature = "derive"))] +pub use mac::{Macro, MacroDelimiter}; + +#[cfg(any(feature = "full", feature = "derive"))] +mod derive; +#[cfg(feature = "derive")] +pub use derive::{Data, DataEnum, DataStruct, DataUnion, DeriveInput}; + +#[cfg(any(feature = "full", feature = "derive"))] +mod op; +#[cfg(any(feature = "full", feature = "derive"))] +pub use op::{BinOp, UnOp}; + +#[cfg(any(feature = "full", feature = "derive"))] +mod ty; +#[cfg(any(feature = "full", feature = "derive"))] +pub use ty::{ + Abi, BareFnArg, BareFnArgName, ReturnType, Type, TypeArray, TypeBareFn, TypeGroup, + TypeImplTrait, TypeInfer, TypeMacro, TypeNever, TypeParen, TypePath, TypePtr, TypeReference, + TypeSlice, TypeTraitObject, TypeTuple, TypeVerbatim, +}; + +#[cfg(any(feature = "full", feature = "derive"))] +mod path; +#[cfg(all( + any(feature = "full", feature = "derive"), + feature = "printing" +))] +pub use path::PathTokens; +#[cfg(any(feature = "full", feature = "derive"))] +pub use path::{ + AngleBracketedGenericArguments, Binding, GenericArgument, ParenthesizedGenericArguments, Path, + PathArguments, PathSegment, QSelf, +}; + +#[cfg(feature = "parsing")] +pub mod buffer; +pub mod punctuated; +#[cfg(feature = "parsing")] +pub mod synom; +#[cfg(any(feature = "full", feature = "derive"))] +mod tt; + +// Not public API except the `parse_quote!` macro. +#[cfg(feature = "parsing")] +#[doc(hidden)] +pub mod parse_quote; + +#[cfg(all(feature = "parsing", feature = "printing"))] +pub mod spanned; + +#[cfg(all(feature = "parsing", feature = "full"))] +mod verbatim; + +mod gen { + /// Syntax tree traversal to walk a shared borrow of a syntax tree. + /// + /// Each method of the [`Visit`] trait is a hook that can be overridden to + /// customize the behavior when visiting the corresponding type of node. By + /// default, every method recursively visits the substructure of the input + /// by invoking the right visitor method of each of its fields. + /// + /// [`Visit`]: trait.Visit.html + /// + /// ```rust + /// # use syn::{Attribute, BinOp, Expr, ExprBinary}; + /// # + /// pub trait Visit<'ast> { + /// /* ... */ + /// + /// fn visit_expr_binary(&mut self, node: &'ast ExprBinary) { + /// for attr in &node.attrs { + /// self.visit_attribute(attr); + /// } + /// self.visit_expr(&*node.left); + /// self.visit_bin_op(&node.op); + /// self.visit_expr(&*node.right); + /// } + /// + /// /* ... */ + /// # fn visit_attribute(&mut self, node: &'ast Attribute); + /// # fn visit_expr(&mut self, node: &'ast Expr); + /// # fn visit_bin_op(&mut self, node: &'ast BinOp); + /// } + /// ``` + /// + /// *This module is available if Syn is built with the `"visit"` feature.* + #[cfg(feature = "visit")] + pub mod visit; + + /// Syntax tree traversal to mutate an exclusive borrow of a syntax tree in + /// place. + /// + /// Each method of the [`VisitMut`] trait is a hook that can be overridden + /// to customize the behavior when mutating the corresponding type of node. + /// By default, every method recursively visits the substructure of the + /// input by invoking the right visitor method of each of its fields. + /// + /// [`VisitMut`]: trait.VisitMut.html + /// + /// ```rust + /// # use syn::{Attribute, BinOp, Expr, ExprBinary}; + /// # + /// pub trait VisitMut { + /// /* ... */ + /// + /// fn visit_expr_binary_mut(&mut self, node: &mut ExprBinary) { + /// for attr in &mut node.attrs { + /// self.visit_attribute_mut(attr); + /// } + /// self.visit_expr_mut(&mut *node.left); + /// self.visit_bin_op_mut(&mut node.op); + /// self.visit_expr_mut(&mut *node.right); + /// } + /// + /// /* ... */ + /// # fn visit_attribute_mut(&mut self, node: &mut Attribute); + /// # fn visit_expr_mut(&mut self, node: &mut Expr); + /// # fn visit_bin_op_mut(&mut self, node: &mut BinOp); + /// } + /// ``` + /// + /// *This module is available if Syn is built with the `"visit-mut"` + /// feature.* + #[cfg(feature = "visit-mut")] + pub mod visit_mut; + + /// Syntax tree traversal to transform the nodes of an owned syntax tree. + /// + /// Each method of the [`Fold`] trait is a hook that can be overridden to + /// customize the behavior when transforming the corresponding type of node. + /// By default, every method recursively visits the substructure of the + /// input by invoking the right visitor method of each of its fields. + /// + /// [`Fold`]: trait.Fold.html + /// + /// ```rust + /// # use syn::{Attribute, BinOp, Expr, ExprBinary}; + /// # + /// pub trait Fold { + /// /* ... */ + /// + /// fn fold_expr_binary(&mut self, node: ExprBinary) -> ExprBinary { + /// ExprBinary { + /// attrs: node.attrs + /// .into_iter() + /// .map(|attr| self.fold_attribute(attr)) + /// .collect(), + /// left: Box::new(self.fold_expr(*node.left)), + /// op: self.fold_bin_op(node.op), + /// right: Box::new(self.fold_expr(*node.right)), + /// } + /// } + /// + /// /* ... */ + /// # fn fold_attribute(&mut self, node: Attribute) -> Attribute; + /// # fn fold_expr(&mut self, node: Expr) -> Expr; + /// # fn fold_bin_op(&mut self, node: BinOp) -> BinOp; + /// } + /// ``` + /// + /// *This module is available if Syn is built with the `"fold"` feature.* + #[cfg(feature = "fold")] + pub mod fold; + + #[cfg(any(feature = "full", feature = "derive"))] + #[path = "../gen_helper.rs"] + mod helper; +} +pub use gen::*; + +//////////////////////////////////////////////////////////////////////////////// + +#[cfg(feature = "parsing")] +use synom::{Parser, Synom}; + +#[cfg(feature = "parsing")] +mod error; +#[cfg(feature = "parsing")] +use error::ParseError; + +// Not public API. +#[cfg(feature = "parsing")] +#[doc(hidden)] +pub use error::parse_error; + +/// Parse tokens of source code into the chosen syntax tree node. +/// +/// This is preferred over parsing a string because tokens are able to preserve +/// information about where in the user's code they were originally written (the +/// "span" of the token), possibly allowing the compiler to produce better error +/// messages. +/// +/// This function parses a `proc_macro::TokenStream` which is the type used for +/// interop with the compiler in a procedural macro. To parse a +/// `proc_macro2::TokenStream`, use [`syn::parse2`] instead. +/// +/// [`syn::parse2`]: fn.parse2.html +/// +/// *This function is available if Syn is built with both the `"parsing"` and +/// `"proc-macro"` features.* +/// +/// # Examples +/// +/// ```rust +/// extern crate proc_macro; +/// use proc_macro::TokenStream; +/// +/// extern crate syn; +/// +/// #[macro_use] +/// extern crate quote; +/// +/// use syn::DeriveInput; +/// +/// # const IGNORE_TOKENS: &str = stringify! { +/// #[proc_macro_derive(MyMacro)] +/// # }; +/// pub fn my_macro(input: TokenStream) -> TokenStream { +/// // Parse the tokens into a syntax tree +/// let ast: DeriveInput = syn::parse(input).unwrap(); +/// +/// // Build the output, possibly using quasi-quotation +/// let expanded = quote! { +/// /* ... */ +/// }; +/// +/// // Convert into a token stream and return it +/// expanded.into() +/// } +/// # +/// # fn main() {} +/// ``` +#[cfg(all( + not(all(target_arch = "wasm32", target_os = "unknown")), + feature = "parsing", + feature = "proc-macro" +))] +pub fn parse(tokens: proc_macro::TokenStream) -> Result +where + T: Synom, +{ + parse2(tokens.into()) +} + +/// Parse a proc-macro2 token stream into the chosen syntax tree node. +/// +/// This function parses a `proc_macro2::TokenStream` which is commonly useful +/// when the input comes from a node of the Syn syntax tree, for example the tts +/// of a [`Macro`] node. When in a procedural macro parsing the +/// `proc_macro::TokenStream` provided by the compiler, use [`syn::parse`] +/// instead. +/// +/// [`Macro`]: struct.Macro.html +/// [`syn::parse`]: fn.parse.html +/// +/// *This function is available if Syn is built with the `"parsing"` feature.* +#[cfg(feature = "parsing")] +pub fn parse2(tokens: proc_macro2::TokenStream) -> Result +where + T: Synom, +{ + let parser = T::parse; + parser.parse2(tokens).map_err(|err| match T::description() { + Some(s) => ParseError::new(format!("failed to parse {}: {}", s, err)), + None => err, + }) +} + +/// Parse a string of Rust code into the chosen syntax tree node. +/// +/// *This function is available if Syn is built with the `"parsing"` feature.* +/// +/// # Hygiene +/// +/// Every span in the resulting syntax tree will be set to resolve at the macro +/// call site. +/// +/// # Examples +/// +/// ```rust +/// extern crate syn; +/// # +/// # +/// # type Result = std::result::Result>; +/// +/// use syn::Expr; +/// +/// fn run() -> Result<()> { +/// let code = "assert_eq!(u8::max_value(), 255)"; +/// let expr = syn::parse_str::(code)?; +/// println!("{:#?}", expr); +/// Ok(()) +/// } +/// # +/// # fn main() { run().unwrap() } +/// ``` +#[cfg(feature = "parsing")] +pub fn parse_str(s: &str) -> Result { + match s.parse() { + Ok(tts) => parse2(tts), + Err(_) => Err(ParseError::new("error while lexing input string")), + } +} + +// FIXME the name parse_file makes it sound like you might pass in a path to a +// file, rather than the content. +/// Parse the content of a file of Rust code. +/// +/// This is different from `syn::parse_str::(content)` in two ways: +/// +/// - It discards a leading byte order mark `\u{FEFF}` if the file has one. +/// - It preserves the shebang line of the file, such as `#!/usr/bin/env rustx`. +/// +/// If present, either of these would be an error using `from_str`. +/// +/// *This function is available if Syn is built with the `"parsing"` and `"full"` features.* +/// +/// # Examples +/// +/// ```rust,no_run +/// extern crate syn; +/// # +/// # +/// # type Result = std::result::Result>; +/// +/// use std::fs::File; +/// use std::io::Read; +/// +/// fn run() -> Result<()> { +/// let mut file = File::open("path/to/code.rs")?; +/// let mut content = String::new(); +/// file.read_to_string(&mut content)?; +/// +/// let ast = syn::parse_file(&content)?; +/// if let Some(shebang) = ast.shebang { +/// println!("{}", shebang); +/// } +/// println!("{} items", ast.items.len()); +/// +/// Ok(()) +/// } +/// # +/// # fn main() { run().unwrap() } +/// ``` +#[cfg(all(feature = "parsing", feature = "full"))] +pub fn parse_file(mut content: &str) -> Result { + // Strip the BOM if it is present + const BOM: &'static str = "\u{feff}"; + if content.starts_with(BOM) { + content = &content[BOM.len()..]; + } + + let mut shebang = None; + if content.starts_with("#!") && !content.starts_with("#![") { + if let Some(idx) = content.find('\n') { + shebang = Some(content[..idx].to_string()); + content = &content[idx..]; + } else { + shebang = Some(content.to_string()); + content = ""; + } + } + + let mut file: File = parse_str(content)?; + file.shebang = shebang; + Ok(file) +} + +#[cfg(all( + any(feature = "full", feature = "derive"), + feature = "printing" +))] +struct TokensOrDefault<'a, T: 'a>(&'a Option); + +#[cfg(all( + any(feature = "full", feature = "derive"), + feature = "printing" +))] +impl<'a, T> quote::ToTokens for TokensOrDefault<'a, T> +where + T: quote::ToTokens + Default, +{ + fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) { + match *self.0 { + Some(ref t) => t.to_tokens(tokens), + None => T::default().to_tokens(tokens), + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/lifetime.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/lifetime.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/lifetime.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/lifetime.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,150 @@ +// Copyright 2018 Syn Developers +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::cmp::Ordering; +use std::fmt::{self, Display}; +use std::hash::{Hash, Hasher}; + +use proc_macro2::{Ident, Span}; +use unicode_xid::UnicodeXID; + +use token::Apostrophe; + +/// A Rust lifetime: `'a`. +/// +/// Lifetime names must conform to the following rules: +/// +/// - Must start with an apostrophe. +/// - Must not consist of just an apostrophe: `'`. +/// - Character after the apostrophe must be `_` or a Unicode code point with +/// the XID_Start property. +/// - All following characters must be Unicode code points with the XID_Continue +/// property. +/// +/// *This type is available if Syn is built with the `"derive"` or `"full"` +/// feature.* +#[cfg_attr(feature = "extra-traits", derive(Debug))] +#[derive(Clone)] +pub struct Lifetime { + pub apostrophe: Apostrophe, + pub ident: Ident, +} + +impl Lifetime { + pub fn new(s: &str, span: Span) -> Self { + if !s.starts_with('\'') { + panic!( + "lifetime name must start with apostrophe as in \"'a\", got {:?}", + s + ); + } + + if s == "'" { + panic!("lifetime name must not be empty"); + } + + fn xid_ok(s: &str) -> bool { + let mut chars = s.chars(); + let first = chars.next().unwrap(); + if !(UnicodeXID::is_xid_start(first) || first == '_') { + return false; + } + for ch in chars { + if !UnicodeXID::is_xid_continue(ch) { + return false; + } + } + true + } + + if !xid_ok(&s[1..]) { + panic!("{:?} is not a valid lifetime name", s); + } + + Lifetime { + apostrophe: Apostrophe::default(), + ident: Ident::new(&s[1..], span), + } + } +} + +impl Display for Lifetime { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + "'".fmt(formatter)?; + self.ident.fmt(formatter) + } +} + +impl PartialEq for Lifetime { + fn eq(&self, other: &Lifetime) -> bool { + self.ident.eq(&other.ident) + } +} + +impl Eq for Lifetime {} + +impl PartialOrd for Lifetime { + fn partial_cmp(&self, other: &Lifetime) -> Option { + Some(self.cmp(other)) + } +} + +impl Ord for Lifetime { + fn cmp(&self, other: &Lifetime) -> Ordering { + self.ident.cmp(&other.ident) + } +} + +impl Hash for Lifetime { + fn hash(&self, h: &mut H) { + self.ident.hash(h) + } +} + +#[cfg(feature = "parsing")] +pub mod parsing { + use super::*; + use buffer::Cursor; + use parse_error; + use synom::PResult; + use synom::Synom; + + impl Synom for Lifetime { + fn parse(input: Cursor) -> PResult { + let (apostrophe, rest) = Apostrophe::parse(input)?; + let (ident, rest) = match rest.ident() { + Some(pair) => pair, + None => return parse_error(), + }; + + let ret = Lifetime { + ident: ident, + apostrophe: apostrophe, + }; + Ok((ret, rest)) + } + + fn description() -> Option<&'static str> { + Some("lifetime") + } + } +} + +#[cfg(feature = "printing")] +mod printing { + use super::*; + use proc_macro2::TokenStream; + use quote::ToTokens; + + impl ToTokens for Lifetime { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.apostrophe.to_tokens(tokens); + self.ident.to_tokens(tokens); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/lit.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/lit.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/lit.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/lit.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,1026 @@ +// Copyright 2018 Syn Developers +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use proc_macro2::{Literal, Span}; +use std::str; + +#[cfg(feature = "printing")] +use proc_macro2::Ident; + +#[cfg(feature = "parsing")] +use proc_macro2::TokenStream; +#[cfg(feature = "parsing")] +use {ParseError, Synom}; + +use proc_macro2::TokenTree; + +#[cfg(feature = "extra-traits")] +use std::hash::{Hash, Hasher}; + +ast_enum_of_structs! { + /// A Rust literal such as a string or integer or boolean. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + /// + /// # Syntax tree enum + /// + /// This type is a [syntax tree enum]. + /// + /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums + pub enum Lit { + /// A UTF-8 string literal: `"foo"`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Str(LitStr #manual_extra_traits { + token: Literal, + }), + + /// A byte string literal: `b"foo"`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub ByteStr(LitByteStr #manual_extra_traits { + token: Literal, + }), + + /// A byte literal: `b'f'`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Byte(LitByte #manual_extra_traits { + token: Literal, + }), + + /// A character literal: `'a'`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Char(LitChar #manual_extra_traits { + token: Literal, + }), + + /// An integer literal: `1` or `1u16`. + /// + /// Holds up to 64 bits of data. Use `LitVerbatim` for any larger + /// integer literal. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Int(LitInt #manual_extra_traits { + token: Literal, + }), + + /// A floating point literal: `1f64` or `1.0e10f64`. + /// + /// Must be finite. May not be infinte or NaN. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Float(LitFloat #manual_extra_traits { + token: Literal, + }), + + /// A boolean literal: `true` or `false`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Bool(LitBool #manual_extra_traits { + pub value: bool, + pub span: Span, + }), + + /// A raw token literal not interpreted by Syn, possibly because it + /// represents an integer larger than 64 bits. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Verbatim(LitVerbatim #manual_extra_traits { + pub token: Literal, + }), + } +} + +impl LitStr { + pub fn new(value: &str, span: Span) -> Self { + let mut lit = Literal::string(value); + lit.set_span(span); + LitStr { token: lit } + } + + pub fn value(&self) -> String { + value::parse_lit_str(&self.token.to_string()) + } + + /// Parse a syntax tree node from the content of this string literal. + /// + /// All spans in the syntax tree will point to the span of this `LitStr`. + #[cfg(feature = "parsing")] + pub fn parse(&self) -> Result { + use proc_macro2::Group; + + // Parse string literal into a token stream with every span equal to the + // original literal's span. + fn spanned_tokens(s: &LitStr) -> Result { + let stream = ::parse_str(&s.value())?; + Ok(respan_token_stream(stream, s.span())) + } + + // Token stream with every span replaced by the given one. + fn respan_token_stream(stream: TokenStream, span: Span) -> TokenStream { + stream + .into_iter() + .map(|token| respan_token_tree(token, span)) + .collect() + } + + // Token tree with every span replaced by the given one. + fn respan_token_tree(mut token: TokenTree, span: Span) -> TokenTree { + match token { + TokenTree::Group(ref mut g) => { + let stream = respan_token_stream(g.stream().clone(), span); + *g = Group::new(g.delimiter(), stream); + g.set_span(span); + } + ref mut other => other.set_span(span), + } + token + } + + spanned_tokens(self).and_then(::parse2) + } + + pub fn span(&self) -> Span { + self.token.span() + } + + pub fn set_span(&mut self, span: Span) { + self.token.set_span(span) + } +} + +impl LitByteStr { + pub fn new(value: &[u8], span: Span) -> Self { + let mut token = Literal::byte_string(value); + token.set_span(span); + LitByteStr { token: token } + } + + pub fn value(&self) -> Vec { + value::parse_lit_byte_str(&self.token.to_string()) + } + + pub fn span(&self) -> Span { + self.token.span() + } + + pub fn set_span(&mut self, span: Span) { + self.token.set_span(span) + } +} + +impl LitByte { + pub fn new(value: u8, span: Span) -> Self { + let mut token = Literal::u8_suffixed(value); + token.set_span(span); + LitByte { token: token } + } + + pub fn value(&self) -> u8 { + value::parse_lit_byte(&self.token.to_string()) + } + + pub fn span(&self) -> Span { + self.token.span() + } + + pub fn set_span(&mut self, span: Span) { + self.token.set_span(span) + } +} + +impl LitChar { + pub fn new(value: char, span: Span) -> Self { + let mut token = Literal::character(value); + token.set_span(span); + LitChar { token: token } + } + + pub fn value(&self) -> char { + value::parse_lit_char(&self.token.to_string()) + } + + pub fn span(&self) -> Span { + self.token.span() + } + + pub fn set_span(&mut self, span: Span) { + self.token.set_span(span) + } +} + +impl LitInt { + pub fn new(value: u64, suffix: IntSuffix, span: Span) -> Self { + let mut token = match suffix { + IntSuffix::Isize => Literal::isize_suffixed(value as isize), + IntSuffix::I8 => Literal::i8_suffixed(value as i8), + IntSuffix::I16 => Literal::i16_suffixed(value as i16), + IntSuffix::I32 => Literal::i32_suffixed(value as i32), + IntSuffix::I64 => Literal::i64_suffixed(value as i64), + IntSuffix::I128 => value::to_literal(&format!("{}i128", value)), + IntSuffix::Usize => Literal::usize_suffixed(value as usize), + IntSuffix::U8 => Literal::u8_suffixed(value as u8), + IntSuffix::U16 => Literal::u16_suffixed(value as u16), + IntSuffix::U32 => Literal::u32_suffixed(value as u32), + IntSuffix::U64 => Literal::u64_suffixed(value), + IntSuffix::U128 => value::to_literal(&format!("{}u128", value)), + IntSuffix::None => Literal::u64_unsuffixed(value), + }; + token.set_span(span); + LitInt { token: token } + } + + pub fn value(&self) -> u64 { + value::parse_lit_int(&self.token.to_string()).unwrap() + } + + pub fn suffix(&self) -> IntSuffix { + let value = self.token.to_string(); + for (s, suffix) in vec![ + ("i8", IntSuffix::I8), + ("i16", IntSuffix::I16), + ("i32", IntSuffix::I32), + ("i64", IntSuffix::I64), + ("i128", IntSuffix::I128), + ("isize", IntSuffix::Isize), + ("u8", IntSuffix::U8), + ("u16", IntSuffix::U16), + ("u32", IntSuffix::U32), + ("u64", IntSuffix::U64), + ("u128", IntSuffix::U128), + ("usize", IntSuffix::Usize), + ] { + if value.ends_with(s) { + return suffix; + } + } + IntSuffix::None + } + + pub fn span(&self) -> Span { + self.token.span() + } + + pub fn set_span(&mut self, span: Span) { + self.token.set_span(span) + } +} + +impl LitFloat { + pub fn new(value: f64, suffix: FloatSuffix, span: Span) -> Self { + let mut token = match suffix { + FloatSuffix::F32 => Literal::f32_suffixed(value as f32), + FloatSuffix::F64 => Literal::f64_suffixed(value), + FloatSuffix::None => Literal::f64_unsuffixed(value), + }; + token.set_span(span); + LitFloat { token: token } + } + + pub fn value(&self) -> f64 { + value::parse_lit_float(&self.token.to_string()) + } + + pub fn suffix(&self) -> FloatSuffix { + let value = self.token.to_string(); + for (s, suffix) in vec![("f32", FloatSuffix::F32), ("f64", FloatSuffix::F64)] { + if value.ends_with(s) { + return suffix; + } + } + FloatSuffix::None + } + + pub fn span(&self) -> Span { + self.token.span() + } + + pub fn set_span(&mut self, span: Span) { + self.token.set_span(span) + } +} + +macro_rules! lit_extra_traits { + ($ty:ident, $field:ident) => { + #[cfg(feature = "extra-traits")] + impl Eq for $ty {} + + #[cfg(feature = "extra-traits")] + impl PartialEq for $ty { + fn eq(&self, other: &Self) -> bool { + self.$field.to_string() == other.$field.to_string() + } + } + + #[cfg(feature = "extra-traits")] + impl Hash for $ty { + fn hash(&self, state: &mut H) + where + H: Hasher, + { + self.$field.to_string().hash(state); + } + } + }; +} + +impl LitVerbatim { + pub fn span(&self) -> Span { + self.token.span() + } + + pub fn set_span(&mut self, span: Span) { + self.token.set_span(span) + } +} + +lit_extra_traits!(LitStr, token); +lit_extra_traits!(LitByteStr, token); +lit_extra_traits!(LitByte, token); +lit_extra_traits!(LitChar, token); +lit_extra_traits!(LitInt, token); +lit_extra_traits!(LitFloat, token); +lit_extra_traits!(LitBool, value); +lit_extra_traits!(LitVerbatim, token); + +ast_enum! { + /// The style of a string literal, either plain quoted or a raw string like + /// `r##"data"##`. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + pub enum StrStyle #no_visit { + /// An ordinary string like `"data"`. + Cooked, + /// A raw string like `r##"data"##`. + /// + /// The unsigned integer is the number of `#` symbols used. + Raw(usize), + } +} + +ast_enum! { + /// The suffix on an integer literal if any, like the `u8` in `127u8`. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + pub enum IntSuffix #no_visit { + I8, + I16, + I32, + I64, + I128, + Isize, + U8, + U16, + U32, + U64, + U128, + Usize, + None, + } +} + +ast_enum! { + /// The suffix on a floating point literal if any, like the `f32` in + /// `1.0f32`. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + pub enum FloatSuffix #no_visit { + F32, + F64, + None, + } +} + +#[cfg(feature = "parsing")] +pub mod parsing { + use super::*; + use buffer::Cursor; + use parse_error; + use synom::PResult; + use synom::Synom; + + impl Synom for Lit { + fn parse(input: Cursor) -> PResult { + match input.literal() { + Some((lit, rest)) => { + if lit.to_string().starts_with('/') { + // Doc comment literal which is not a Syn literal + parse_error() + } else { + Ok((Lit::new(lit), rest)) + } + } + _ => match input.ident() { + Some((ident, rest)) => Ok(( + Lit::Bool(LitBool { + value: if ident == "true" { + true + } else if ident == "false" { + false + } else { + return parse_error(); + }, + span: ident.span(), + }), + rest, + )), + _ => parse_error(), + }, + } + } + + fn description() -> Option<&'static str> { + Some("literal") + } + } + + impl_synom!(LitStr "string literal" switch!( + syn!(Lit), + Lit::Str(lit) => value!(lit) + | + _ => reject!() + )); + + impl_synom!(LitByteStr "byte string literal" switch!( + syn!(Lit), + Lit::ByteStr(lit) => value!(lit) + | + _ => reject!() + )); + + impl_synom!(LitByte "byte literal" switch!( + syn!(Lit), + Lit::Byte(lit) => value!(lit) + | + _ => reject!() + )); + + impl_synom!(LitChar "character literal" switch!( + syn!(Lit), + Lit::Char(lit) => value!(lit) + | + _ => reject!() + )); + + impl_synom!(LitInt "integer literal" switch!( + syn!(Lit), + Lit::Int(lit) => value!(lit) + | + _ => reject!() + )); + + impl_synom!(LitFloat "floating point literal" switch!( + syn!(Lit), + Lit::Float(lit) => value!(lit) + | + _ => reject!() + )); + + impl_synom!(LitBool "boolean literal" switch!( + syn!(Lit), + Lit::Bool(lit) => value!(lit) + | + _ => reject!() + )); +} + +#[cfg(feature = "printing")] +mod printing { + use super::*; + use proc_macro2::TokenStream; + use quote::{ToTokens, TokenStreamExt}; + + impl ToTokens for LitStr { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.token.to_tokens(tokens); + } + } + + impl ToTokens for LitByteStr { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.token.to_tokens(tokens); + } + } + + impl ToTokens for LitByte { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.token.to_tokens(tokens); + } + } + + impl ToTokens for LitChar { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.token.to_tokens(tokens); + } + } + + impl ToTokens for LitInt { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.token.to_tokens(tokens); + } + } + + impl ToTokens for LitFloat { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.token.to_tokens(tokens); + } + } + + impl ToTokens for LitBool { + fn to_tokens(&self, tokens: &mut TokenStream) { + let s = if self.value { "true" } else { "false" }; + tokens.append(Ident::new(s, self.span)); + } + } + + impl ToTokens for LitVerbatim { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.token.to_tokens(tokens); + } + } +} + +mod value { + use super::*; + use proc_macro2::TokenStream; + use std::char; + use std::ops::{Index, RangeFrom}; + + impl Lit { + /// Interpret a Syn literal from a proc-macro2 literal. + /// + /// Not all proc-macro2 literals are valid Syn literals. In particular, + /// doc comments are considered by proc-macro2 to be literals but in Syn + /// they are [`Attribute`]. + /// + /// [`Attribute`]: struct.Attribute.html + /// + /// # Panics + /// + /// Panics if the input is a doc comment literal. + pub fn new(token: Literal) -> Self { + let value = token.to_string(); + + match value::byte(&value, 0) { + b'"' | b'r' => return Lit::Str(LitStr { token: token }), + b'b' => match value::byte(&value, 1) { + b'"' | b'r' => return Lit::ByteStr(LitByteStr { token: token }), + b'\'' => return Lit::Byte(LitByte { token: token }), + _ => {} + }, + b'\'' => return Lit::Char(LitChar { token: token }), + b'0'...b'9' => if number_is_int(&value) { + return Lit::Int(LitInt { token: token }); + } else if number_is_float(&value) { + return Lit::Float(LitFloat { token: token }); + } else { + // number overflow + return Lit::Verbatim(LitVerbatim { token: token }); + }, + _ => if value == "true" || value == "false" { + return Lit::Bool(LitBool { + value: value == "true", + span: token.span(), + }); + }, + } + + panic!("Unrecognized literal: {}", value); + } + } + + fn number_is_int(value: &str) -> bool { + if number_is_float(value) { + false + } else { + value::parse_lit_int(value).is_some() + } + } + + fn number_is_float(value: &str) -> bool { + if value.contains('.') { + true + } else if value.starts_with("0x") || value.ends_with("size") { + false + } else { + value.contains('e') || value.contains('E') + } + } + + /// Get the byte at offset idx, or a default of `b'\0'` if we're looking + /// past the end of the input buffer. + pub fn byte + ?Sized>(s: &S, idx: usize) -> u8 { + let s = s.as_ref(); + if idx < s.len() { + s[idx] + } else { + 0 + } + } + + fn next_chr(s: &str) -> char { + s.chars().next().unwrap_or('\0') + } + + pub fn parse_lit_str(s: &str) -> String { + match byte(s, 0) { + b'"' => parse_lit_str_cooked(s), + b'r' => parse_lit_str_raw(s), + _ => unreachable!(), + } + } + + // Clippy false positive + // https://github.com/rust-lang-nursery/rust-clippy/issues/2329 + #[cfg_attr(feature = "cargo-clippy", allow(needless_continue))] + fn parse_lit_str_cooked(mut s: &str) -> String { + assert_eq!(byte(s, 0), b'"'); + s = &s[1..]; + + let mut out = String::new(); + 'outer: loop { + let ch = match byte(s, 0) { + b'"' => break, + b'\\' => { + let b = byte(s, 1); + s = &s[2..]; + match b { + b'x' => { + let (byte, rest) = backslash_x(s); + s = rest; + assert!(byte <= 0x80, "Invalid \\x byte in string literal"); + char::from_u32(u32::from(byte)).unwrap() + } + b'u' => { + let (chr, rest) = backslash_u(s); + s = rest; + chr + } + b'n' => '\n', + b'r' => '\r', + b't' => '\t', + b'\\' => '\\', + b'0' => '\0', + b'\'' => '\'', + b'"' => '"', + b'\r' | b'\n' => loop { + let ch = next_chr(s); + if ch.is_whitespace() { + s = &s[ch.len_utf8()..]; + } else { + continue 'outer; + } + }, + b => panic!("unexpected byte {:?} after \\ character in byte literal", b), + } + } + b'\r' => { + assert_eq!(byte(s, 1), b'\n', "Bare CR not allowed in string"); + s = &s[2..]; + '\n' + } + _ => { + let ch = next_chr(s); + s = &s[ch.len_utf8()..]; + ch + } + }; + out.push(ch); + } + + assert_eq!(s, "\""); + out + } + + fn parse_lit_str_raw(mut s: &str) -> String { + assert_eq!(byte(s, 0), b'r'); + s = &s[1..]; + + let mut pounds = 0; + while byte(s, pounds) == b'#' { + pounds += 1; + } + assert_eq!(byte(s, pounds), b'"'); + assert_eq!(byte(s, s.len() - pounds - 1), b'"'); + for end in s[s.len() - pounds..].bytes() { + assert_eq!(end, b'#'); + } + + s[pounds + 1..s.len() - pounds - 1].to_owned() + } + + pub fn parse_lit_byte_str(s: &str) -> Vec { + assert_eq!(byte(s, 0), b'b'); + match byte(s, 1) { + b'"' => parse_lit_byte_str_cooked(s), + b'r' => parse_lit_byte_str_raw(s), + _ => unreachable!(), + } + } + + // Clippy false positive + // https://github.com/rust-lang-nursery/rust-clippy/issues/2329 + #[cfg_attr(feature = "cargo-clippy", allow(needless_continue))] + fn parse_lit_byte_str_cooked(mut s: &str) -> Vec { + assert_eq!(byte(s, 0), b'b'); + assert_eq!(byte(s, 1), b'"'); + s = &s[2..]; + + // We're going to want to have slices which don't respect codepoint boundaries. + let mut s = s.as_bytes(); + + let mut out = Vec::new(); + 'outer: loop { + let byte = match byte(s, 0) { + b'"' => break, + b'\\' => { + let b = byte(s, 1); + s = &s[2..]; + match b { + b'x' => { + let (b, rest) = backslash_x(s); + s = rest; + b + } + b'n' => b'\n', + b'r' => b'\r', + b't' => b'\t', + b'\\' => b'\\', + b'0' => b'\0', + b'\'' => b'\'', + b'"' => b'"', + b'\r' | b'\n' => loop { + let byte = byte(s, 0); + let ch = char::from_u32(u32::from(byte)).unwrap(); + if ch.is_whitespace() { + s = &s[1..]; + } else { + continue 'outer; + } + }, + b => panic!("unexpected byte {:?} after \\ character in byte literal", b), + } + } + b'\r' => { + assert_eq!(byte(s, 1), b'\n', "Bare CR not allowed in string"); + s = &s[2..]; + b'\n' + } + b => { + s = &s[1..]; + b + } + }; + out.push(byte); + } + + assert_eq!(s, b"\""); + out + } + + fn parse_lit_byte_str_raw(s: &str) -> Vec { + assert_eq!(byte(s, 0), b'b'); + parse_lit_str_raw(&s[1..]).into_bytes() + } + + pub fn parse_lit_byte(s: &str) -> u8 { + assert_eq!(byte(s, 0), b'b'); + assert_eq!(byte(s, 1), b'\''); + + // We're going to want to have slices which don't respect codepoint boundaries. + let mut s = s[2..].as_bytes(); + + let b = match byte(s, 0) { + b'\\' => { + let b = byte(s, 1); + s = &s[2..]; + match b { + b'x' => { + let (b, rest) = backslash_x(s); + s = rest; + b + } + b'n' => b'\n', + b'r' => b'\r', + b't' => b'\t', + b'\\' => b'\\', + b'0' => b'\0', + b'\'' => b'\'', + b'"' => b'"', + b => panic!("unexpected byte {:?} after \\ character in byte literal", b), + } + } + b => { + s = &s[1..]; + b + } + }; + + assert_eq!(byte(s, 0), b'\''); + b + } + + pub fn parse_lit_char(mut s: &str) -> char { + assert_eq!(byte(s, 0), b'\''); + s = &s[1..]; + + let ch = match byte(s, 0) { + b'\\' => { + let b = byte(s, 1); + s = &s[2..]; + match b { + b'x' => { + let (byte, rest) = backslash_x(s); + s = rest; + assert!(byte <= 0x80, "Invalid \\x byte in string literal"); + char::from_u32(u32::from(byte)).unwrap() + } + b'u' => { + let (chr, rest) = backslash_u(s); + s = rest; + chr + } + b'n' => '\n', + b'r' => '\r', + b't' => '\t', + b'\\' => '\\', + b'0' => '\0', + b'\'' => '\'', + b'"' => '"', + b => panic!("unexpected byte {:?} after \\ character in byte literal", b), + } + } + _ => { + let ch = next_chr(s); + s = &s[ch.len_utf8()..]; + ch + } + }; + assert_eq!(s, "\'", "Expected end of char literal"); + ch + } + + fn backslash_x(s: &S) -> (u8, &S) + where + S: Index, Output = S> + AsRef<[u8]> + ?Sized, + { + let mut ch = 0; + let b0 = byte(s, 0); + let b1 = byte(s, 1); + ch += 0x10 * match b0 { + b'0'...b'9' => b0 - b'0', + b'a'...b'f' => 10 + (b0 - b'a'), + b'A'...b'F' => 10 + (b0 - b'A'), + _ => panic!("unexpected non-hex character after \\x"), + }; + ch += match b1 { + b'0'...b'9' => b1 - b'0', + b'a'...b'f' => 10 + (b1 - b'a'), + b'A'...b'F' => 10 + (b1 - b'A'), + _ => panic!("unexpected non-hex character after \\x"), + }; + (ch, &s[2..]) + } + + fn backslash_u(mut s: &str) -> (char, &str) { + if byte(s, 0) != b'{' { + panic!("expected {{ after \\u"); + } + s = &s[1..]; + + let mut ch = 0; + for _ in 0..6 { + let b = byte(s, 0); + match b { + b'0'...b'9' => { + ch *= 0x10; + ch += u32::from(b - b'0'); + s = &s[1..]; + } + b'a'...b'f' => { + ch *= 0x10; + ch += u32::from(10 + b - b'a'); + s = &s[1..]; + } + b'A'...b'F' => { + ch *= 0x10; + ch += u32::from(10 + b - b'A'); + s = &s[1..]; + } + b'}' => break, + _ => panic!("unexpected non-hex character after \\u"), + } + } + assert!(byte(s, 0) == b'}'); + s = &s[1..]; + + if let Some(ch) = char::from_u32(ch) { + (ch, s) + } else { + panic!("character code {:x} is not a valid unicode character", ch); + } + } + + pub fn parse_lit_int(mut s: &str) -> Option { + let base = match (byte(s, 0), byte(s, 1)) { + (b'0', b'x') => { + s = &s[2..]; + 16 + } + (b'0', b'o') => { + s = &s[2..]; + 8 + } + (b'0', b'b') => { + s = &s[2..]; + 2 + } + (b'0'...b'9', _) => 10, + _ => unreachable!(), + }; + + let mut value = 0u64; + loop { + let b = byte(s, 0); + let digit = match b { + b'0'...b'9' => u64::from(b - b'0'), + b'a'...b'f' if base > 10 => 10 + u64::from(b - b'a'), + b'A'...b'F' if base > 10 => 10 + u64::from(b - b'A'), + b'_' => { + s = &s[1..]; + continue; + } + // NOTE: Looking at a floating point literal, we don't want to + // consider these integers. + b'.' if base == 10 => return None, + b'e' | b'E' if base == 10 => return None, + _ => break, + }; + + if digit >= base { + panic!("Unexpected digit {:x} out of base range", digit); + } + + value = match value.checked_mul(base) { + Some(value) => value, + None => return None, + }; + value = match value.checked_add(digit) { + Some(value) => value, + None => return None, + }; + s = &s[1..]; + } + + Some(value) + } + + pub fn parse_lit_float(input: &str) -> f64 { + // Rust's floating point literals are very similar to the ones parsed by + // the standard library, except that rust's literals can contain + // ignorable underscores. Let's remove those underscores. + let mut bytes = input.to_owned().into_bytes(); + let mut write = 0; + for read in 0..bytes.len() { + if bytes[read] == b'_' { + continue; // Don't increase write + } + if write != read { + let x = bytes[read]; + bytes[write] = x; + } + write += 1; + } + bytes.truncate(write); + let input = String::from_utf8(bytes).unwrap(); + let end = input.find('f').unwrap_or_else(|| input.len()); + input[..end].parse().unwrap() + } + + pub fn to_literal(s: &str) -> Literal { + let stream = s.parse::().unwrap(); + match stream.into_iter().next().unwrap() { + TokenTree::Literal(l) => l, + _ => unreachable!(), + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/macros.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/macros.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/macros.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/macros.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,196 @@ +// Copyright 2018 Syn Developers +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[cfg(any(feature = "full", feature = "derive"))] +macro_rules! ast_struct { + ( + $(#[$attr:meta])* + pub struct $name:ident #full $($rest:tt)* + ) => { + #[cfg(feature = "full")] + $(#[$attr])* + #[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))] + #[cfg_attr(feature = "clone-impls", derive(Clone))] + pub struct $name $($rest)* + + #[cfg(not(feature = "full"))] + $(#[$attr])* + #[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))] + #[cfg_attr(feature = "clone-impls", derive(Clone))] + pub struct $name { + _noconstruct: (), + } + }; + + ( + $(#[$attr:meta])* + pub struct $name:ident #manual_extra_traits $($rest:tt)* + ) => { + $(#[$attr])* + #[cfg_attr(feature = "extra-traits", derive(Debug))] + #[cfg_attr(feature = "clone-impls", derive(Clone))] + pub struct $name $($rest)* + }; + + ( + $(#[$attr:meta])* + pub struct $name:ident $($rest:tt)* + ) => { + $(#[$attr])* + #[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))] + #[cfg_attr(feature = "clone-impls", derive(Clone))] + pub struct $name $($rest)* + }; +} + +#[cfg(any(feature = "full", feature = "derive"))] +macro_rules! ast_enum { + ( + $(#[$enum_attr:meta])* + pub enum $name:ident $(# $tags:ident)* { $($variants:tt)* } + ) => ( + $(#[$enum_attr])* + #[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))] + #[cfg_attr(feature = "clone-impls", derive(Clone))] + pub enum $name { + $($variants)* + } + ) +} + +#[cfg(any(feature = "full", feature = "derive"))] +macro_rules! ast_enum_of_structs { + ( + $(#[$enum_attr:meta])* + pub enum $name:ident { + $( + $(#[$variant_attr:meta])* + pub $variant:ident $( ($member:ident $($rest:tt)*) )*, + )* + } + + $($remaining:tt)* + ) => ( + ast_enum! { + $(#[$enum_attr])* + pub enum $name { + $( + $(#[$variant_attr])* + $variant $( ($member) )*, + )* + } + } + + $( + maybe_ast_struct! { + $(#[$variant_attr])* + $( + pub struct $member $($rest)* + )* + } + + $( + impl From<$member> for $name { + fn from(e: $member) -> $name { + $name::$variant(e) + } + } + )* + )* + + #[cfg(feature = "printing")] + generate_to_tokens! { + $($remaining)* + () + tokens + $name { $($variant $( [$($rest)*] )*,)* } + } + ) +} + +#[cfg(all( + feature = "printing", + any(feature = "full", feature = "derive") +))] +macro_rules! generate_to_tokens { + (do_not_generate_to_tokens $($foo:tt)*) => (); + + (($($arms:tt)*) $tokens:ident $name:ident { $variant:ident, $($next:tt)*}) => { + generate_to_tokens!( + ($($arms)* $name::$variant => {}) + $tokens $name { $($next)* } + ); + }; + + (($($arms:tt)*) $tokens:ident $name:ident { $variant:ident [$($rest:tt)*], $($next:tt)*}) => { + generate_to_tokens!( + ($($arms)* $name::$variant(ref _e) => to_tokens_call!(_e, $tokens, $($rest)*),) + $tokens $name { $($next)* } + ); + }; + + (($($arms:tt)*) $tokens:ident $name:ident {}) => { + impl ::quote::ToTokens for $name { + fn to_tokens(&self, $tokens: &mut ::proc_macro2::TokenStream) { + match *self { + $($arms)* + } + } + } + }; +} + +#[cfg(all(feature = "printing", feature = "full"))] +macro_rules! to_tokens_call { + ($e:ident, $tokens:ident, $($rest:tt)*) => { + $e.to_tokens($tokens) + }; +} + +#[cfg(all( + feature = "printing", + feature = "derive", + not(feature = "full") +))] +macro_rules! to_tokens_call { + // If the variant is marked as #full, don't auto-generate to-tokens for it. + ($e:ident, $tokens:ident, #full $($rest:tt)*) => { + unreachable!() + }; + ($e:ident, $tokens:ident, $($rest:tt)*) => { + $e.to_tokens($tokens) + }; +} + +#[cfg(any(feature = "full", feature = "derive"))] +macro_rules! maybe_ast_struct { + ( + $(#[$attr:meta])* + $( + pub struct $name:ident + )* + ) => (); + + ($($rest:tt)*) => (ast_struct! { $($rest)* }); +} + +#[cfg(all( + feature = "parsing", + any(feature = "full", feature = "derive") +))] +macro_rules! impl_synom { + ($t:ident $description:tt $($parser:tt)+) => { + impl Synom for $t { + named!(parse -> Self, $($parser)+); + + fn description() -> Option<&'static str> { + Some($description) + } + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/mac.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/mac.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/mac.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/mac.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,117 @@ +// Copyright 2018 Syn Developers +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use super::*; +use proc_macro2::TokenStream; +use token::{Brace, Bracket, Paren}; + +#[cfg(feature = "extra-traits")] +use std::hash::{Hash, Hasher}; +#[cfg(feature = "extra-traits")] +use tt::TokenStreamHelper; + +ast_struct! { + /// A macro invocation: `println!("{}", mac)`. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + pub struct Macro #manual_extra_traits { + pub path: Path, + pub bang_token: Token![!], + pub delimiter: MacroDelimiter, + pub tts: TokenStream, + } +} + +ast_enum! { + /// A grouping token that surrounds a macro body: `m!(...)` or `m!{...}` or `m![...]`. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + pub enum MacroDelimiter { + Paren(Paren), + Brace(Brace), + Bracket(Bracket), + } +} + +#[cfg(feature = "extra-traits")] +impl Eq for Macro {} + +#[cfg(feature = "extra-traits")] +impl PartialEq for Macro { + fn eq(&self, other: &Self) -> bool { + self.path == other.path + && self.bang_token == other.bang_token + && self.delimiter == other.delimiter + && TokenStreamHelper(&self.tts) == TokenStreamHelper(&other.tts) + } +} + +#[cfg(feature = "extra-traits")] +impl Hash for Macro { + fn hash(&self, state: &mut H) + where + H: Hasher, + { + self.path.hash(state); + self.bang_token.hash(state); + self.delimiter.hash(state); + TokenStreamHelper(&self.tts).hash(state); + } +} + +#[cfg(feature = "parsing")] +pub mod parsing { + use super::*; + + use synom::Synom; + + impl Synom for Macro { + named!(parse -> Self, do_parse!( + what: call!(Path::parse_mod_style) >> + bang: punct!(!) >> + body: call!(tt::delimited) >> + (Macro { + path: what, + bang_token: bang, + delimiter: body.0, + tts: body.1, + }) + )); + + fn description() -> Option<&'static str> { + Some("macro invocation") + } + } +} + +#[cfg(feature = "printing")] +mod printing { + use super::*; + use proc_macro2::TokenStream; + use quote::ToTokens; + + impl ToTokens for Macro { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.path.to_tokens(tokens); + self.bang_token.to_tokens(tokens); + match self.delimiter { + MacroDelimiter::Paren(ref paren) => { + paren.surround(tokens, |tokens| self.tts.to_tokens(tokens)); + } + MacroDelimiter::Brace(ref brace) => { + brace.surround(tokens, |tokens| self.tts.to_tokens(tokens)); + } + MacroDelimiter::Bracket(ref bracket) => { + bracket.surround(tokens, |tokens| self.tts.to_tokens(tokens)); + } + } + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/op.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/op.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/op.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/op.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,224 @@ +// Copyright 2018 Syn Developers +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +ast_enum! { + /// A binary operator: `+`, `+=`, `&`. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + #[cfg_attr(feature = "clone-impls", derive(Copy))] + pub enum BinOp { + /// The `+` operator (addition) + Add(Token![+]), + /// The `-` operator (subtraction) + Sub(Token![-]), + /// The `*` operator (multiplication) + Mul(Token![*]), + /// The `/` operator (division) + Div(Token![/]), + /// The `%` operator (modulus) + Rem(Token![%]), + /// The `&&` operator (logical and) + And(Token![&&]), + /// The `||` operator (logical or) + Or(Token![||]), + /// The `^` operator (bitwise xor) + BitXor(Token![^]), + /// The `&` operator (bitwise and) + BitAnd(Token![&]), + /// The `|` operator (bitwise or) + BitOr(Token![|]), + /// The `<<` operator (shift left) + Shl(Token![<<]), + /// The `>>` operator (shift right) + Shr(Token![>>]), + /// The `==` operator (equality) + Eq(Token![==]), + /// The `<` operator (less than) + Lt(Token![<]), + /// The `<=` operator (less than or equal to) + Le(Token![<=]), + /// The `!=` operator (not equal to) + Ne(Token![!=]), + /// The `>=` operator (greater than or equal to) + Ge(Token![>=]), + /// The `>` operator (greater than) + Gt(Token![>]), + /// The `+=` operator + AddEq(Token![+=]), + /// The `-=` operator + SubEq(Token![-=]), + /// The `*=` operator + MulEq(Token![*=]), + /// The `/=` operator + DivEq(Token![/=]), + /// The `%=` operator + RemEq(Token![%=]), + /// The `^=` operator + BitXorEq(Token![^=]), + /// The `&=` operator + BitAndEq(Token![&=]), + /// The `|=` operator + BitOrEq(Token![|=]), + /// The `<<=` operator + ShlEq(Token![<<=]), + /// The `>>=` operator + ShrEq(Token![>>=]), + } +} + +ast_enum! { + /// A unary operator: `*`, `!`, `-`. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + #[cfg_attr(feature = "clone-impls", derive(Copy))] + pub enum UnOp { + /// The `*` operator for dereferencing + Deref(Token![*]), + /// The `!` operator for logical inversion + Not(Token![!]), + /// The `-` operator for negation + Neg(Token![-]), + } +} + +#[cfg(feature = "parsing")] +pub mod parsing { + use super::*; + use synom::Synom; + + impl BinOp { + named!(pub parse_binop -> Self, alt!( + punct!(&&) => { BinOp::And } + | + punct!(||) => { BinOp::Or } + | + punct!(<<) => { BinOp::Shl } + | + punct!(>>) => { BinOp::Shr } + | + punct!(==) => { BinOp::Eq } + | + punct!(<=) => { BinOp::Le } + | + punct!(!=) => { BinOp::Ne } + | + punct!(>=) => { BinOp::Ge } + | + punct!(+) => { BinOp::Add } + | + punct!(-) => { BinOp::Sub } + | + punct!(*) => { BinOp::Mul } + | + punct!(/) => { BinOp::Div } + | + punct!(%) => { BinOp::Rem } + | + punct!(^) => { BinOp::BitXor } + | + punct!(&) => { BinOp::BitAnd } + | + punct!(|) => { BinOp::BitOr } + | + punct!(<) => { BinOp::Lt } + | + punct!(>) => { BinOp::Gt } + )); + + #[cfg(feature = "full")] + named!(pub parse_assign_op -> Self, alt!( + punct!(+=) => { BinOp::AddEq } + | + punct!(-=) => { BinOp::SubEq } + | + punct!(*=) => { BinOp::MulEq } + | + punct!(/=) => { BinOp::DivEq } + | + punct!(%=) => { BinOp::RemEq } + | + punct!(^=) => { BinOp::BitXorEq } + | + punct!(&=) => { BinOp::BitAndEq } + | + punct!(|=) => { BinOp::BitOrEq } + | + punct!(<<=) => { BinOp::ShlEq } + | + punct!(>>=) => { BinOp::ShrEq } + )); + } + + impl Synom for UnOp { + named!(parse -> Self, alt!( + punct!(*) => { UnOp::Deref } + | + punct!(!) => { UnOp::Not } + | + punct!(-) => { UnOp::Neg } + )); + + fn description() -> Option<&'static str> { + Some("unary operator: `*`, `!`, or `-`") + } + } +} + +#[cfg(feature = "printing")] +mod printing { + use super::*; + use proc_macro2::TokenStream; + use quote::ToTokens; + + impl ToTokens for BinOp { + fn to_tokens(&self, tokens: &mut TokenStream) { + match *self { + BinOp::Add(ref t) => t.to_tokens(tokens), + BinOp::Sub(ref t) => t.to_tokens(tokens), + BinOp::Mul(ref t) => t.to_tokens(tokens), + BinOp::Div(ref t) => t.to_tokens(tokens), + BinOp::Rem(ref t) => t.to_tokens(tokens), + BinOp::And(ref t) => t.to_tokens(tokens), + BinOp::Or(ref t) => t.to_tokens(tokens), + BinOp::BitXor(ref t) => t.to_tokens(tokens), + BinOp::BitAnd(ref t) => t.to_tokens(tokens), + BinOp::BitOr(ref t) => t.to_tokens(tokens), + BinOp::Shl(ref t) => t.to_tokens(tokens), + BinOp::Shr(ref t) => t.to_tokens(tokens), + BinOp::Eq(ref t) => t.to_tokens(tokens), + BinOp::Lt(ref t) => t.to_tokens(tokens), + BinOp::Le(ref t) => t.to_tokens(tokens), + BinOp::Ne(ref t) => t.to_tokens(tokens), + BinOp::Ge(ref t) => t.to_tokens(tokens), + BinOp::Gt(ref t) => t.to_tokens(tokens), + BinOp::AddEq(ref t) => t.to_tokens(tokens), + BinOp::SubEq(ref t) => t.to_tokens(tokens), + BinOp::MulEq(ref t) => t.to_tokens(tokens), + BinOp::DivEq(ref t) => t.to_tokens(tokens), + BinOp::RemEq(ref t) => t.to_tokens(tokens), + BinOp::BitXorEq(ref t) => t.to_tokens(tokens), + BinOp::BitAndEq(ref t) => t.to_tokens(tokens), + BinOp::BitOrEq(ref t) => t.to_tokens(tokens), + BinOp::ShlEq(ref t) => t.to_tokens(tokens), + BinOp::ShrEq(ref t) => t.to_tokens(tokens), + } + } + } + + impl ToTokens for UnOp { + fn to_tokens(&self, tokens: &mut TokenStream) { + match *self { + UnOp::Deref(ref t) => t.to_tokens(tokens), + UnOp::Not(ref t) => t.to_tokens(tokens), + UnOp::Neg(ref t) => t.to_tokens(tokens), + } + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/parse_quote.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/parse_quote.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/parse_quote.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/parse_quote.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,163 @@ +/// Quasi-quotation macro that accepts input like the [`quote!`] macro but uses +/// type inference to figure out a return type for those tokens. +/// +/// [`quote!`]: https://docs.rs/quote/0.4/quote/index.html +/// +/// The return type can be any syntax tree node that implements the [`Synom`] +/// trait. +/// +/// [`Synom`]: synom/trait.Synom.html +/// +/// ``` +/// #[macro_use] +/// extern crate syn; +/// +/// #[macro_use] +/// extern crate quote; +/// +/// use syn::Stmt; +/// +/// fn main() { +/// let name = quote!(v); +/// let ty = quote!(u8); +/// +/// let stmt: Stmt = parse_quote! { +/// let #name: #ty = Default::default(); +/// }; +/// +/// println!("{:#?}", stmt); +/// } +/// ``` +/// +/// *This macro is available if Syn is built with the `"parsing"` feature, +/// although interpolation of syntax tree nodes into the quoted tokens is only +/// supported if Syn is built with the `"printing"` feature as well.* +/// +/// # Example +/// +/// The following helper function adds a bound `T: HeapSize` to every type +/// parameter `T` in the input generics. +/// +/// ``` +/// # #[macro_use] +/// # extern crate syn; +/// # +/// # #[macro_use] +/// # extern crate quote; +/// # +/// # use syn::{Generics, GenericParam}; +/// # +/// // Add a bound `T: HeapSize` to every type parameter T. +/// fn add_trait_bounds(mut generics: Generics) -> Generics { +/// for param in &mut generics.params { +/// if let GenericParam::Type(ref mut type_param) = *param { +/// type_param.bounds.push(parse_quote!(HeapSize)); +/// } +/// } +/// generics +/// } +/// # +/// # fn main() {} +/// ``` +/// +/// # Special cases +/// +/// This macro can parse the following additional types as a special case even +/// though they do not implement the `Synom` trait. +/// +/// - [`Attribute`] — parses one attribute, allowing either outer like `#[...]` +/// or inner like `#![...]` +/// - [`Punctuated`] — parses zero or more `T` separated by punctuation +/// `P` with optional trailing punctuation +/// +/// [`Attribute`]: struct.Attribute.html +/// [`Punctuated`]: punctuated/struct.Punctuated.html +/// +/// # Panics +/// +/// Panics if the tokens fail to parse as the expected syntax tree type. The +/// caller is responsible for ensuring that the input tokens are syntactically +/// valid. +#[macro_export] +macro_rules! parse_quote { + ($($tt:tt)*) => { + $crate::parse_quote::parse($crate::parse_quote::From::from(quote!($($tt)*))) + }; +} + +//////////////////////////////////////////////////////////////////////////////// +// Can parse any type that implements Synom. + +use buffer::Cursor; +use proc_macro2::TokenStream; +use synom::{PResult, Parser, Synom}; + +// Not public API. +#[doc(hidden)] +pub use std::convert::From; + +// Not public API. +#[doc(hidden)] +pub fn parse(token_stream: TokenStream) -> T { + let parser = T::parse; + match parser.parse2(token_stream) { + Ok(t) => t, + Err(err) => match T::description() { + Some(s) => panic!("failed to parse {}: {}", s, err), + None => panic!("{}", err), + }, + } +} + +// Not public API. +#[doc(hidden)] +pub trait ParseQuote: Sized { + fn parse(input: Cursor) -> PResult; + fn description() -> Option<&'static str>; +} + +impl ParseQuote for T +where + T: Synom, +{ + fn parse(input: Cursor) -> PResult { + ::parse(input) + } + + fn description() -> Option<&'static str> { + ::description() + } +} + +//////////////////////////////////////////////////////////////////////////////// +// Any other types that we want `parse_quote!` to be able to parse. + +use punctuated::Punctuated; + +#[cfg(any(feature = "full", feature = "derive"))] +use Attribute; + +impl ParseQuote for Punctuated +where + T: Synom, + P: Synom, +{ + named!(parse -> Self, call!(Punctuated::parse_terminated)); + + fn description() -> Option<&'static str> { + Some("punctuated sequence") + } +} + +#[cfg(any(feature = "full", feature = "derive"))] +impl ParseQuote for Attribute { + named!(parse -> Self, alt!( + call!(Attribute::parse_outer) + | + call!(Attribute::parse_inner) + )); + + fn description() -> Option<&'static str> { + Some("attribute") + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/parsers.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/parsers.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/parsers.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/parsers.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,1428 @@ +// Copyright 2018 Syn Developers +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use buffer::Cursor; +use parse_error; +use synom::PResult; + +/// Define a parser function with the signature expected by syn parser +/// combinators. +/// +/// The function may be the `parse` function of the [`Synom`] trait, or it may +/// be a free-standing function with an arbitrary name. When implementing the +/// `Synom` trait, the function name is `parse` and the return type is `Self`. +/// +/// [`Synom`]: synom/trait.Synom.html +/// +/// - **Syntax:** `named!(NAME -> TYPE, PARSER)` or `named!(pub NAME -> TYPE, PARSER)` +/// +/// ```rust +/// #[macro_use] +/// extern crate syn; +/// +/// use syn::Type; +/// use syn::punctuated::Punctuated; +/// use syn::synom::Synom; +/// +/// /// Parses one or more Rust types separated by commas. +/// /// +/// /// Example: `String, Vec, [u8; LEN + 1]` +/// named!(pub comma_separated_types -> Punctuated, +/// call!(Punctuated::parse_separated_nonempty) +/// ); +/// +/// /// The same function as a `Synom` implementation. +/// struct CommaSeparatedTypes { +/// types: Punctuated, +/// } +/// +/// impl Synom for CommaSeparatedTypes { +/// /// As the default behavior, we want there to be at least 1 type. +/// named!(parse -> Self, do_parse!( +/// types: call!(Punctuated::parse_separated_nonempty) >> +/// (CommaSeparatedTypes { types }) +/// )); +/// } +/// +/// impl CommaSeparatedTypes { +/// /// A separate parser that the user can invoke explicitly which allows +/// /// for parsing 0 or more types, rather than the default 1 or more. +/// named!(pub parse0 -> Self, do_parse!( +/// types: call!(Punctuated::parse_separated) >> +/// (CommaSeparatedTypes { types }) +/// )); +/// } +/// # +/// # fn main() {} +/// ``` +/// +/// *This macro is available if Syn is built with the `"parsing"` feature.* +#[macro_export] +macro_rules! named { + ($name:ident -> $o:ty, $submac:ident!( $($args:tt)* )) => { + fn $name(i: $crate::buffer::Cursor) -> $crate::synom::PResult<$o> { + $submac!(i, $($args)*) + } + }; + + (pub $name:ident -> $o:ty, $submac:ident!( $($args:tt)* )) => { + pub fn $name(i: $crate::buffer::Cursor) -> $crate::synom::PResult<$o> { + $submac!(i, $($args)*) + } + }; + + // These two variants are for defining named parsers which have custom + // arguments, and are called with `call!()` + ($name:ident($($params:tt)*) -> $o:ty, $submac:ident!( $($args:tt)* )) => { + fn $name(i: $crate::buffer::Cursor, $($params)*) -> $crate::synom::PResult<$o> { + $submac!(i, $($args)*) + } + }; + + (pub $name:ident($($params:tt)*) -> $o:ty, $submac:ident!( $($args:tt)* )) => { + pub fn $name(i: $crate::buffer::Cursor, $($params)*) -> $crate::synom::PResult<$o> { + $submac!(i, $($args)*) + } + }; +} + +#[cfg(synom_verbose_trace)] +#[macro_export] +macro_rules! call { + ($i:expr, $fun:expr $(, $args:expr)*) => {{ + #[allow(unused_imports)] + use $crate::synom::ext::*; + let i = $i; + eprintln!(concat!(" -> ", stringify!($fun), " @ {:?}"), i); + let r = $fun(i $(, $args)*); + match r { + Ok((_, i)) => eprintln!(concat!("OK ", stringify!($fun), " @ {:?}"), i), + Err(_) => eprintln!(concat!("ERR ", stringify!($fun), " @ {:?}"), i), + } + r + }}; +} + +/// Invoke the given parser function with zero or more arguments. +/// +/// - **Syntax:** `call!(FN, ARGS...)` +/// +/// where the signature of the function is `fn(Cursor, ARGS...) -> PResult` +/// +/// - **Output:** `T`, the result of invoking the function `FN` +/// +/// ```rust +/// #[macro_use] +/// extern crate syn; +/// +/// use syn::Type; +/// use syn::punctuated::Punctuated; +/// use syn::synom::Synom; +/// +/// /// Parses one or more Rust types separated by commas. +/// /// +/// /// Example: `String, Vec, [u8; LEN + 1]` +/// struct CommaSeparatedTypes { +/// types: Punctuated, +/// } +/// +/// impl Synom for CommaSeparatedTypes { +/// named!(parse -> Self, do_parse!( +/// types: call!(Punctuated::parse_separated_nonempty) >> +/// (CommaSeparatedTypes { types }) +/// )); +/// } +/// # +/// # fn main() {} +/// ``` +/// +/// *This macro is available if Syn is built with the `"parsing"` feature.* +#[cfg(not(synom_verbose_trace))] +#[macro_export] +macro_rules! call { + ($i:expr, $fun:expr $(, $args:expr)*) => {{ + #[allow(unused_imports)] + use $crate::synom::ext::*; + $fun($i $(, $args)*) + }}; +} + +/// Transform the result of a parser by applying a function or closure. +/// +/// - **Syntax:** `map!(THING, FN)` +/// - **Output:** the return type of function FN applied to THING +/// +/// ```rust +/// #[macro_use] +/// extern crate syn; +/// +/// use syn::{Expr, ExprIf}; +/// +/// /// Extracts the branch condition of an `if`-expression. +/// fn get_cond(if_: ExprIf) -> Expr { +/// *if_.cond +/// } +/// +/// /// Parses a full `if`-expression but returns the condition part only. +/// /// +/// /// Example: `if x > 0xFF { "big" } else { "small" }` +/// /// The return would be the expression `x > 0xFF`. +/// named!(if_condition -> Expr, +/// map!(syn!(ExprIf), get_cond) +/// ); +/// +/// /// Equivalent using a closure. +/// named!(if_condition2 -> Expr, +/// map!(syn!(ExprIf), |if_| *if_.cond) +/// ); +/// # +/// # fn main() {} +/// ``` +/// +/// *This macro is available if Syn is built with the `"parsing"` feature.* +#[macro_export] +macro_rules! map { + ($i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => { + match $submac!($i, $($args)*) { + ::std::result::Result::Err(err) => + ::std::result::Result::Err(err), + ::std::result::Result::Ok((o, i)) => + ::std::result::Result::Ok(($crate::parsers::invoke($g, o), i)), + } + }; + + ($i:expr, $f:expr, $g:expr) => { + map!($i, call!($f), $g) + }; +} + +// Somehow this helps with type inference in `map!` and `alt!`. +// +// Not public API. +#[doc(hidden)] +pub fn invoke R>(f: F, t: T) -> R { + f(t) +} + +/// Invert the result of a parser by parsing successfully if the given parser +/// fails to parse and vice versa. +/// +/// Does not consume any of the input. +/// +/// - **Syntax:** `not!(THING)` +/// - **Output:** `()` +/// +/// ```rust +/// #[macro_use] +/// extern crate syn; +/// +/// use syn::Expr; +/// +/// /// Parses any expression that does not begin with a `-` minus sign. +/// named!(not_negative_expr -> Expr, do_parse!( +/// not!(punct!(-)) >> +/// e: syn!(Expr) >> +/// (e) +/// )); +/// # +/// # fn main() {} +/// ``` +/// +/// *This macro is available if Syn is built with the `"parsing"` feature.* +#[macro_export] +macro_rules! not { + ($i:expr, $submac:ident!( $($args:tt)* )) => { + match $submac!($i, $($args)*) { + ::std::result::Result::Ok(_) => $crate::parse_error(), + ::std::result::Result::Err(_) => + ::std::result::Result::Ok(((), $i)), + } + }; +} + +/// Execute a parser only if a condition is met, otherwise return None. +/// +/// If you are familiar with nom, this is nom's `cond_with_error` parser. +/// +/// - **Syntax:** `cond!(CONDITION, THING)` +/// - **Output:** `Some(THING)` if the condition is true, else `None` +/// +/// ```rust +/// #[macro_use] +/// extern crate syn; +/// +/// use syn::{Ident, MacroDelimiter}; +/// use syn::token::{Paren, Bracket, Brace}; +/// use syn::synom::Synom; +/// +/// /// Parses a macro call with empty input. If the macro is written with +/// /// parentheses or brackets, a trailing semicolon is required. +/// /// +/// /// Example: `my_macro!{}` or `my_macro!();` or `my_macro![];` +/// struct EmptyMacroCall { +/// name: Ident, +/// bang_token: Token![!], +/// empty_body: MacroDelimiter, +/// semi_token: Option, +/// } +/// +/// fn requires_semi(delimiter: &MacroDelimiter) -> bool { +/// match *delimiter { +/// MacroDelimiter::Paren(_) | MacroDelimiter::Bracket(_) => true, +/// MacroDelimiter::Brace(_) => false, +/// } +/// } +/// +/// impl Synom for EmptyMacroCall { +/// named!(parse -> Self, do_parse!( +/// name: syn!(Ident) >> +/// bang_token: punct!(!) >> +/// empty_body: alt!( +/// parens!(epsilon!()) => { |d| MacroDelimiter::Paren(d.0) } +/// | +/// brackets!(epsilon!()) => { |d| MacroDelimiter::Bracket(d.0) } +/// | +/// braces!(epsilon!()) => { |d| MacroDelimiter::Brace(d.0) } +/// ) >> +/// semi_token: cond!(requires_semi(&empty_body), punct!(;)) >> +/// (EmptyMacroCall { +/// name, +/// bang_token, +/// empty_body, +/// semi_token, +/// }) +/// )); +/// } +/// # +/// # fn main() {} +/// ``` +/// +/// *This macro is available if Syn is built with the `"parsing"` feature.* +#[macro_export] +macro_rules! cond { + ($i:expr, $cond:expr, $submac:ident!( $($args:tt)* )) => { + if $cond { + match $submac!($i, $($args)*) { + ::std::result::Result::Ok((o, i)) => + ::std::result::Result::Ok((::std::option::Option::Some(o), i)), + ::std::result::Result::Err(x) => ::std::result::Result::Err(x), + } + } else { + ::std::result::Result::Ok((::std::option::Option::None, $i)) + } + }; + + ($i:expr, $cond:expr, $f:expr) => { + cond!($i, $cond, call!($f)) + }; +} + +/// Execute a parser only if a condition is met, otherwise fail to parse. +/// +/// This is typically used inside of [`option!`] or [`alt!`]. +/// +/// [`option!`]: macro.option.html +/// [`alt!`]: macro.alt.html +/// +/// - **Syntax:** `cond_reduce!(CONDITION, THING)` +/// - **Output:** `THING` +/// +/// The subparser may be omitted in which case it defaults to [`epsilon!`]. +/// +/// [`epsilon!`]: macro.epsilon.html +/// +/// - **Syntax:** `cond_reduce!(CONDITION)` +/// - **Output:** `()` +/// +/// ```rust +/// #[macro_use] +/// extern crate syn; +/// +/// use syn::Type; +/// use syn::token::Paren; +/// use syn::punctuated::Punctuated; +/// use syn::synom::Synom; +/// +/// /// Parses a possibly variadic function signature. +/// /// +/// /// Example: `fn(A) or `fn(A, B, C, ...)` or `fn(...)` +/// /// Rejected: `fn(A, B...)` +/// struct VariadicFn { +/// fn_token: Token![fn], +/// paren_token: Paren, +/// types: Punctuated, +/// variadic: Option, +/// } +/// +/// // Example of using `cond_reduce!` inside of `option!`. +/// impl Synom for VariadicFn { +/// named!(parse -> Self, do_parse!( +/// fn_token: keyword!(fn) >> +/// params: parens!(do_parse!( +/// types: call!(Punctuated::parse_terminated) >> +/// // Allow, but do not require, an ending `...` but only if the +/// // preceding list of types is empty or ends with a trailing comma. +/// variadic: option!(cond_reduce!(types.empty_or_trailing(), punct!(...))) >> +/// (types, variadic) +/// )) >> +/// ({ +/// let (paren_token, (types, variadic)) = params; +/// VariadicFn { +/// fn_token, +/// paren_token, +/// types, +/// variadic, +/// } +/// }) +/// )); +/// } +/// # +/// # fn main() {} +/// ``` +/// +/// *This macro is available if Syn is built with the `"parsing"` feature.* +#[macro_export] +macro_rules! cond_reduce { + ($i:expr, $cond:expr, $submac:ident!( $($args:tt)* )) => { + if $cond { + $submac!($i, $($args)*) + } else { + $crate::parse_error() + } + }; + + ($i:expr, $cond:expr) => { + cond_reduce!($i, $cond, epsilon!()) + }; + + ($i:expr, $cond:expr, $f:expr) => { + cond_reduce!($i, $cond, call!($f)) + }; +} + +/// Parse zero or more values using the given parser. +/// +/// - **Syntax:** `many0!(THING)` +/// - **Output:** `Vec` +/// +/// You may also be looking for: +/// +/// - `call!(Punctuated::parse_separated)` - zero or more values with separator +/// - `call!(Punctuated::parse_separated_nonempty)` - one or more values +/// - `call!(Punctuated::parse_terminated)` - zero or more, allows trailing separator +/// - `call!(Punctuated::parse_terminated_nonempty)` - one or more +/// +/// ```rust +/// #[macro_use] +/// extern crate syn; +/// +/// use syn::{Ident, Item}; +/// use syn::token::Brace; +/// use syn::synom::Synom; +/// +/// /// Parses a module containing zero or more Rust items. +/// /// +/// /// Example: `mod m { type Result = ::std::result::Result; }` +/// struct SimpleMod { +/// mod_token: Token![mod], +/// name: Ident, +/// brace_token: Brace, +/// items: Vec, +/// } +/// +/// impl Synom for SimpleMod { +/// named!(parse -> Self, do_parse!( +/// mod_token: keyword!(mod) >> +/// name: syn!(Ident) >> +/// body: braces!(many0!(syn!(Item))) >> +/// (SimpleMod { +/// mod_token, +/// name, +/// brace_token: body.0, +/// items: body.1, +/// }) +/// )); +/// } +/// # +/// # fn main() {} +/// ``` +/// +/// *This macro is available if Syn is built with the `"parsing"` feature.* +#[macro_export] +macro_rules! many0 { + ($i:expr, $submac:ident!( $($args:tt)* )) => {{ + let ret; + let mut res = ::std::vec::Vec::new(); + let mut input = $i; + + loop { + if input.eof() { + ret = ::std::result::Result::Ok((res, input)); + break; + } + + match $submac!(input, $($args)*) { + ::std::result::Result::Err(_) => { + ret = ::std::result::Result::Ok((res, input)); + break; + } + ::std::result::Result::Ok((o, i)) => { + // loop trip must always consume (otherwise infinite loops) + if i == input { + ret = $crate::parse_error(); + break; + } + + res.push(o); + input = i; + } + } + } + + ret + }}; + + ($i:expr, $f:expr) => { + $crate::parsers::many0($i, $f) + }; +} + +// Improve compile time by compiling this loop only once per type it is used +// with. +// +// Not public API. +#[doc(hidden)] +pub fn many0(mut input: Cursor, f: fn(Cursor) -> PResult) -> PResult> { + let mut res = Vec::new(); + + loop { + if input.eof() { + return Ok((res, input)); + } + + match f(input) { + Err(_) => { + return Ok((res, input)); + } + Ok((o, i)) => { + // loop trip must always consume (otherwise infinite loops) + if i == input { + return parse_error(); + } + + res.push(o); + input = i; + } + } + } +} + +/// Pattern-match the result of a parser to select which other parser to run. +/// +/// - **Syntax:** `switch!(TARGET, PAT1 => THEN1 | PAT2 => THEN2 | ...)` +/// - **Output:** `T`, the return type of `THEN1` and `THEN2` and ... +/// +/// ```rust +/// #[macro_use] +/// extern crate syn; +/// +/// use syn::Ident; +/// use syn::token::Brace; +/// use syn::synom::Synom; +/// +/// /// Parse a unit struct or enum: either `struct S;` or `enum E { V }`. +/// enum UnitType { +/// Struct { +/// struct_token: Token![struct], +/// name: Ident, +/// semi_token: Token![;], +/// }, +/// Enum { +/// enum_token: Token![enum], +/// name: Ident, +/// brace_token: Brace, +/// variant: Ident, +/// }, +/// } +/// +/// enum StructOrEnum { +/// Struct(Token![struct]), +/// Enum(Token![enum]), +/// } +/// +/// impl Synom for StructOrEnum { +/// named!(parse -> Self, alt!( +/// keyword!(struct) => { StructOrEnum::Struct } +/// | +/// keyword!(enum) => { StructOrEnum::Enum } +/// )); +/// } +/// +/// impl Synom for UnitType { +/// named!(parse -> Self, do_parse!( +/// which: syn!(StructOrEnum) >> +/// name: syn!(Ident) >> +/// item: switch!(value!(which), +/// StructOrEnum::Struct(struct_token) => map!( +/// punct!(;), +/// |semi_token| UnitType::Struct { +/// struct_token, +/// name, +/// semi_token, +/// } +/// ) +/// | +/// StructOrEnum::Enum(enum_token) => map!( +/// braces!(syn!(Ident)), +/// |(brace_token, variant)| UnitType::Enum { +/// enum_token, +/// name, +/// brace_token, +/// variant, +/// } +/// ) +/// ) >> +/// (item) +/// )); +/// } +/// # +/// # fn main() {} +/// ``` +/// +/// *This macro is available if Syn is built with the `"parsing"` feature.* +#[macro_export] +macro_rules! switch { + ($i:expr, $submac:ident!( $($args:tt)* ), $($p:pat => $subrule:ident!( $($args2:tt)* ))|* ) => { + match $submac!($i, $($args)*) { + ::std::result::Result::Err(err) => ::std::result::Result::Err(err), + ::std::result::Result::Ok((o, i)) => match o { + $( + $p => $subrule!(i, $($args2)*), + )* + } + } + }; +} + +/// Produce the given value without parsing anything. +/// +/// This can be needed where you have an existing parsed value but a parser +/// macro's syntax expects you to provide a submacro, such as in the first +/// argument of [`switch!`] or one of the branches of [`alt!`]. +/// +/// [`switch!`]: macro.switch.html +/// [`alt!`]: macro.alt.html +/// +/// - **Syntax:** `value!(VALUE)` +/// - **Output:** `VALUE` +/// +/// ```rust +/// #[macro_use] +/// extern crate syn; +/// +/// use syn::Ident; +/// use syn::token::Brace; +/// use syn::synom::Synom; +/// +/// /// Parse a unit struct or enum: either `struct S;` or `enum E { V }`. +/// enum UnitType { +/// Struct { +/// struct_token: Token![struct], +/// name: Ident, +/// semi_token: Token![;], +/// }, +/// Enum { +/// enum_token: Token![enum], +/// name: Ident, +/// brace_token: Brace, +/// variant: Ident, +/// }, +/// } +/// +/// enum StructOrEnum { +/// Struct(Token![struct]), +/// Enum(Token![enum]), +/// } +/// +/// impl Synom for StructOrEnum { +/// named!(parse -> Self, alt!( +/// keyword!(struct) => { StructOrEnum::Struct } +/// | +/// keyword!(enum) => { StructOrEnum::Enum } +/// )); +/// } +/// +/// impl Synom for UnitType { +/// named!(parse -> Self, do_parse!( +/// which: syn!(StructOrEnum) >> +/// name: syn!(Ident) >> +/// item: switch!(value!(which), +/// StructOrEnum::Struct(struct_token) => map!( +/// punct!(;), +/// |semi_token| UnitType::Struct { +/// struct_token, +/// name, +/// semi_token, +/// } +/// ) +/// | +/// StructOrEnum::Enum(enum_token) => map!( +/// braces!(syn!(Ident)), +/// |(brace_token, variant)| UnitType::Enum { +/// enum_token, +/// name, +/// brace_token, +/// variant, +/// } +/// ) +/// ) >> +/// (item) +/// )); +/// } +/// # +/// # fn main() {} +/// ``` +/// +/// *This macro is available if Syn is built with the `"parsing"` feature.* +#[macro_export] +macro_rules! value { + ($i:expr, $res:expr) => { + ::std::result::Result::Ok(($res, $i)) + }; +} + +/// Unconditionally fail to parse anything. +/// +/// This may be useful in rejecting some arms of a `switch!` parser. +/// +/// - **Syntax:** `reject!()` +/// - **Output:** never succeeds +/// +/// ```rust +/// #[macro_use] +/// extern crate syn; +/// +/// use syn::Item; +/// +/// // Parse any item, except for a module. +/// named!(almost_any_item -> Item, +/// switch!(syn!(Item), +/// Item::Mod(_) => reject!() +/// | +/// ok => value!(ok) +/// ) +/// ); +/// # +/// # fn main() {} +/// ``` +/// +/// *This macro is available if Syn is built with the `"parsing"` feature.* +#[macro_export] +macro_rules! reject { + ($i:expr,) => {{ + let _ = $i; + $crate::parse_error() + }}; +} + +/// Run a series of parsers and produce all of the results in a tuple. +/// +/// - **Syntax:** `tuple!(A, B, C, ...)` +/// - **Output:** `(A, B, C, ...)` +/// +/// ```rust +/// #[macro_use] +/// extern crate syn; +/// +/// use syn::Type; +/// +/// named!(two_types -> (Type, Type), tuple!(syn!(Type), syn!(Type))); +/// # +/// # fn main() {} +/// ``` +/// +/// *This macro is available if Syn is built with the `"parsing"` feature.* +#[macro_export] +macro_rules! tuple { + ($i:expr, $($rest:tt)+) => { + tuple_parser!($i, (), $($rest)+) + }; +} + +// Internal parser, do not use directly. +#[doc(hidden)] +#[macro_export] +macro_rules! tuple_parser { + ($i:expr, ($($parsed:ident,)*), $e:ident) => { + tuple_parser!($i, ($($parsed,)*), call!($e)) + }; + + ($i:expr, ($($parsed:ident,)*), $e:ident, $($rest:tt)*) => { + tuple_parser!($i, ($($parsed,)*), call!($e), $($rest)*) + }; + + ($i:expr, ($($parsed:ident,)*), $submac:ident!( $($args:tt)* )) => { + match $submac!($i, $($args)*) { + ::std::result::Result::Err(err) => + ::std::result::Result::Err(err), + ::std::result::Result::Ok((o, i)) => + ::std::result::Result::Ok((($($parsed,)* o,), i)), + } + }; + + ($i:expr, ($($parsed:ident,)*), $submac:ident!( $($args:tt)* ), $($rest:tt)*) => { + match $submac!($i, $($args)*) { + ::std::result::Result::Err(err) => + ::std::result::Result::Err(err), + ::std::result::Result::Ok((o, i)) => + tuple_parser!(i, ($($parsed,)* o,), $($rest)*), + } + }; + + ($i:expr, ($($parsed:ident,)*),) => { + ::std::result::Result::Ok((($($parsed,)*), $i)) + }; +} + +/// Run a series of parsers, returning the result of the first one which +/// succeeds. +/// +/// Optionally allows for the result to be transformed. +/// +/// - **Syntax:** `alt!(THING1 | THING2 => { FUNC } | ...)` +/// - **Output:** `T`, the return type of `THING1` and `FUNC(THING2)` and ... +/// +/// # Example +/// +/// ```rust +/// #[macro_use] +/// extern crate syn; +/// extern crate proc_macro2; +/// +/// use proc_macro2::{Ident, Span}; +/// +/// // Parse any identifier token, or the `!` token in which case the +/// // identifier is treated as `"BANG"`. +/// named!(ident_or_bang -> Ident, alt!( +/// syn!(Ident) +/// | +/// punct!(!) => { |_| Ident::new("BANG", Span::call_site()) } +/// )); +/// # +/// # fn main() {} +/// ``` +/// +/// The `alt!` macro is most commonly seen when parsing a syntax tree enum such +/// as the [`Item`] enum. +/// +/// [`Item`]: enum.Item.html +/// +/// ``` +/// # #[macro_use] +/// # extern crate syn; +/// # +/// # use syn::synom::Synom; +/// # +/// # struct Item; +/// # +/// impl Synom for Item { +/// named!(parse -> Self, alt!( +/// # epsilon!() => { |_| unimplemented!() } +/// # )); +/// # } +/// # +/// # mod example { +/// # use syn::*; +/// # +/// # named!(parse -> Item, alt!( +/// syn!(ItemExternCrate) => { Item::ExternCrate } +/// | +/// syn!(ItemUse) => { Item::Use } +/// | +/// syn!(ItemStatic) => { Item::Static } +/// | +/// syn!(ItemConst) => { Item::Const } +/// | +/// /* ... */ +/// # syn!(ItemFn) => { Item::Fn } +/// )); +/// } +/// # +/// # fn main() {} +/// ``` +/// +/// *This macro is available if Syn is built with the `"parsing"` feature.* +#[macro_export] +macro_rules! alt { + ($i:expr, $e:ident | $($rest:tt)*) => { + alt!($i, call!($e) | $($rest)*) + }; + + ($i:expr, $subrule:ident!( $($args:tt)*) | $($rest:tt)*) => { + match $subrule!($i, $($args)*) { + res @ ::std::result::Result::Ok(_) => res, + _ => alt!($i, $($rest)*) + } + }; + + ($i:expr, $subrule:ident!( $($args:tt)* ) => { $gen:expr } | $($rest:tt)+) => { + match $subrule!($i, $($args)*) { + ::std::result::Result::Ok((o, i)) => + ::std::result::Result::Ok(($crate::parsers::invoke($gen, o), i)), + ::std::result::Result::Err(_) => alt!($i, $($rest)*), + } + }; + + ($i:expr, $e:ident => { $gen:expr } | $($rest:tt)*) => { + alt!($i, call!($e) => { $gen } | $($rest)*) + }; + + ($i:expr, $e:ident => { $gen:expr }) => { + alt!($i, call!($e) => { $gen }) + }; + + ($i:expr, $subrule:ident!( $($args:tt)* ) => { $gen:expr }) => { + match $subrule!($i, $($args)*) { + ::std::result::Result::Ok((o, i)) => + ::std::result::Result::Ok(($crate::parsers::invoke($gen, o), i)), + ::std::result::Result::Err(err) => + ::std::result::Result::Err(err), + } + }; + + ($i:expr, $e:ident) => { + alt!($i, call!($e)) + }; + + ($i:expr, $subrule:ident!( $($args:tt)*)) => { + $subrule!($i, $($args)*) + }; +} + +/// Run a series of parsers, optionally naming each intermediate result, +/// followed by a step to combine the intermediate results. +/// +/// Produces the result of evaluating the final expression in parentheses with +/// all of the previously named results bound. +/// +/// - **Syntax:** `do_parse!(name: THING1 >> THING2 >> (RESULT))` +/// - **Output:** `RESULT` +/// +/// ```rust +/// #[macro_use] +/// extern crate syn; +/// extern crate proc_macro2; +/// +/// use proc_macro2::Ident; +/// use proc_macro2::TokenStream; +/// use syn::token::Paren; +/// use syn::synom::Synom; +/// +/// /// Parse a macro invocation that uses `(` `)` parentheses. +/// /// +/// /// Example: `stringify!($args)`. +/// struct Macro { +/// name: Ident, +/// bang_token: Token![!], +/// paren_token: Paren, +/// tts: TokenStream, +/// } +/// +/// impl Synom for Macro { +/// named!(parse -> Self, do_parse!( +/// name: syn!(Ident) >> +/// bang_token: punct!(!) >> +/// body: parens!(syn!(TokenStream)) >> +/// (Macro { +/// name, +/// bang_token, +/// paren_token: body.0, +/// tts: body.1, +/// }) +/// )); +/// } +/// # +/// # fn main() {} +/// ``` +/// +/// *This macro is available if Syn is built with the `"parsing"` feature.* +#[macro_export] +macro_rules! do_parse { + ($i:expr, ( $($rest:expr),* )) => { + ::std::result::Result::Ok((( $($rest),* ), $i)) + }; + + ($i:expr, $e:ident >> $($rest:tt)*) => { + do_parse!($i, call!($e) >> $($rest)*) + }; + + ($i:expr, $submac:ident!( $($args:tt)* ) >> $($rest:tt)*) => { + match $submac!($i, $($args)*) { + ::std::result::Result::Err(err) => + ::std::result::Result::Err(err), + ::std::result::Result::Ok((_, i)) => + do_parse!(i, $($rest)*), + } + }; + + ($i:expr, $field:ident : $e:ident >> $($rest:tt)*) => { + do_parse!($i, $field: call!($e) >> $($rest)*) + }; + + ($i:expr, $field:ident : $submac:ident!( $($args:tt)* ) >> $($rest:tt)*) => { + match $submac!($i, $($args)*) { + ::std::result::Result::Err(err) => + ::std::result::Result::Err(err), + ::std::result::Result::Ok((o, i)) => { + let $field = o; + do_parse!(i, $($rest)*) + }, + } + }; + + ($i:expr, mut $field:ident : $e:ident >> $($rest:tt)*) => { + do_parse!($i, mut $field: call!($e) >> $($rest)*) + }; + + ($i:expr, mut $field:ident : $submac:ident!( $($args:tt)* ) >> $($rest:tt)*) => { + match $submac!($i, $($args)*) { + ::std::result::Result::Err(err) => + ::std::result::Result::Err(err), + ::std::result::Result::Ok((o, i)) => { + let mut $field = o; + do_parse!(i, $($rest)*) + }, + } + }; +} + +/// Parse nothing and succeed only if the end of the enclosing block has been +/// reached. +/// +/// The enclosing block may be the full input if we are parsing at the top +/// level, or the surrounding parenthesis/bracket/brace if we are parsing within +/// those. +/// +/// - **Syntax:** `input_end!()` +/// - **Output:** `()` +/// +/// ```rust +/// #[macro_use] +/// extern crate syn; +/// +/// use syn::Expr; +/// use syn::synom::Synom; +/// +/// /// Parses any Rust expression followed either by a semicolon or by the end +/// /// of the input. +/// /// +/// /// For example `many0!(syn!(TerminatedExpr))` would successfully parse the +/// /// following input into three expressions. +/// /// +/// /// 1 + 1; second.two(); third!() +/// /// +/// /// Similarly within a block, `braced!(many0!(syn!(TerminatedExpr)))` would +/// /// successfully parse three expressions. +/// /// +/// /// { 1 + 1; second.two(); third!() } +/// struct TerminatedExpr { +/// expr: Expr, +/// semi_token: Option, +/// } +/// +/// impl Synom for TerminatedExpr { +/// named!(parse -> Self, do_parse!( +/// expr: syn!(Expr) >> +/// semi_token: alt!( +/// input_end!() => { |_| None } +/// | +/// punct!(;) => { Some } +/// ) >> +/// (TerminatedExpr { +/// expr, +/// semi_token, +/// }) +/// )); +/// } +/// # +/// # fn main() {} +/// ``` +/// +/// *This macro is available if Syn is built with the `"parsing"` feature.* +#[macro_export] +macro_rules! input_end { + ($i:expr,) => { + $crate::parsers::input_end($i) + }; +} + +// Not a public API +#[doc(hidden)] +pub fn input_end(input: Cursor) -> PResult<'static, ()> { + if input.eof() { + Ok(((), Cursor::empty())) + } else { + parse_error() + } +} + +/// Turn a failed parse into `None` and a successful parse into `Some`. +/// +/// A failed parse consumes none of the input. +/// +/// - **Syntax:** `option!(THING)` +/// - **Output:** `Option` +/// +/// ```rust +/// #[macro_use] +/// extern crate syn; +/// +/// use syn::{Label, Block}; +/// use syn::synom::Synom; +/// +/// /// Parses a Rust loop. Equivalent to syn::ExprLoop. +/// /// +/// /// Examples: +/// /// loop { println!("y"); } +/// /// 'x: loop { break 'x; } +/// struct ExprLoop { +/// label: Option

) -> Self { + match d { + Some(d) => Pair::Punctuated(t, d), + None => Pair::End(t), + } + } + + /// Produces this punctuated pair as a tuple of syntax tree node and + /// optional following punctuation. + pub fn into_tuple(self) -> (T, Option

) { + match self { + Pair::Punctuated(t, d) => (t, Some(d)), + Pair::End(t) => (t, None), + } + } +} + +impl Index for Punctuated { + type Output = T; + + fn index(&self, index: usize) -> &Self::Output { + if index == self.len() - 1 { + match self.last { + Some(ref t) => t, + None => &self.inner[index].0, + } + } else { + &self.inner[index].0 + } + } +} + +impl IndexMut for Punctuated { + fn index_mut(&mut self, index: usize) -> &mut Self::Output { + if index == self.len() - 1 { + match self.last { + Some(ref mut t) => t, + None => &mut self.inner[index].0, + } + } else { + &mut self.inner[index].0 + } + } +} + +#[cfg(feature = "parsing")] +impl Punctuated +where + T: Synom, + P: Synom, +{ + /// Parse **zero or more** syntax tree nodes with punctuation in between and + /// **no trailing** punctuation. + pub fn parse_separated(input: Cursor) -> PResult { + Self::parse_separated_with(input, T::parse) + } + + /// Parse **one or more** syntax tree nodes with punctuation in bewteen and + /// **no trailing** punctuation. + /// allowing trailing punctuation. + pub fn parse_separated_nonempty(input: Cursor) -> PResult { + Self::parse_separated_nonempty_with(input, T::parse) + } + + /// Parse **zero or more** syntax tree nodes with punctuation in between and + /// **optional trailing** punctuation. + pub fn parse_terminated(input: Cursor) -> PResult { + Self::parse_terminated_with(input, T::parse) + } + + /// Parse **one or more** syntax tree nodes with punctuation in between and + /// **optional trailing** punctuation. + pub fn parse_terminated_nonempty(input: Cursor) -> PResult { + Self::parse_terminated_nonempty_with(input, T::parse) + } +} + +#[cfg(feature = "parsing")] +impl Punctuated +where + P: Synom, +{ + /// Parse **zero or more** syntax tree nodes using the given parser with + /// punctuation in between and **no trailing** punctuation. + pub fn parse_separated_with(input: Cursor, parse: fn(Cursor) -> PResult) -> PResult { + Self::parse(input, parse, false) + } + + /// Parse **one or more** syntax tree nodes using the given parser with + /// punctuation in between and **no trailing** punctuation. + pub fn parse_separated_nonempty_with( + input: Cursor, + parse: fn(Cursor) -> PResult, + ) -> PResult { + match Self::parse(input, parse, false) { + Ok((ref b, _)) if b.is_empty() => parse_error(), + other => other, + } + } + + /// Parse **zero or more** syntax tree nodes using the given parser with + /// punctuation in between and **optional trailing** punctuation. + pub fn parse_terminated_with(input: Cursor, parse: fn(Cursor) -> PResult) -> PResult { + Self::parse(input, parse, true) + } + + /// Parse **one or more** syntax tree nodes using the given parser with + /// punctuation in between and **optional trailing** punctuation. + pub fn parse_terminated_nonempty_with( + input: Cursor, + parse: fn(Cursor) -> PResult, + ) -> PResult { + match Self::parse(input, parse, true) { + Ok((ref b, _)) if b.is_empty() => parse_error(), + other => other, + } + } + + fn parse( + mut input: Cursor, + parse: fn(Cursor) -> PResult, + terminated: bool, + ) -> PResult { + let mut res = Punctuated::new(); + + // get the first element + match parse(input) { + Err(_) => Ok((res, input)), + Ok((o, i)) => { + if i == input { + return parse_error(); + } + input = i; + res.push_value(o); + + // get the separator first + while let Ok((s, i2)) = P::parse(input) { + if i2 == input { + break; + } + + // get the element next + if let Ok((o3, i3)) = parse(i2) { + if i3 == i2 { + break; + } + res.push_punct(s); + res.push_value(o3); + input = i3; + } else { + break; + } + } + if terminated { + if let Ok((sep, after)) = P::parse(input) { + res.push_punct(sep); + input = after; + } + } + Ok((res, input)) + } + } + } +} + +#[cfg(feature = "printing")] +mod printing { + use super::*; + use proc_macro2::TokenStream; + use quote::{ToTokens, TokenStreamExt}; + + impl ToTokens for Punctuated + where + T: ToTokens, + P: ToTokens, + { + fn to_tokens(&self, tokens: &mut TokenStream) { + tokens.append_all(self.pairs()) + } + } + + impl ToTokens for Pair + where + T: ToTokens, + P: ToTokens, + { + fn to_tokens(&self, tokens: &mut TokenStream) { + match *self { + Pair::Punctuated(ref a, ref b) => { + a.to_tokens(tokens); + b.to_tokens(tokens); + } + Pair::End(ref a) => a.to_tokens(tokens), + } + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/spanned.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/spanned.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/spanned.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/spanned.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,142 @@ +// Copyright 2018 Syn Developers +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! A trait that can provide the `Span` of the complete contents of a syntax +//! tree node. +//! +//! *This module is available if Syn is built with both the `"parsing"` and +//! `"printing"` features.* +//! +//! # Example +//! +//! Suppose in a procedural macro we have a [`Type`] that we want to assert +//! implements the [`Sync`] trait. Maybe this is the type of one of the fields +//! of a struct for which we are deriving a trait implementation, and we need to +//! be able to pass a reference to one of those fields across threads. +//! +//! [`Type`]: ../enum.Type.html +//! [`Sync`]: https://doc.rust-lang.org/std/marker/trait.Sync.html +//! +//! If the field type does *not* implement `Sync` as required, we want the +//! compiler to report an error pointing out exactly which type it was. +//! +//! The following macro code takes a variable `ty` of type `Type` and produces a +//! static assertion that `Sync` is implemented for that type. +//! +//! ``` +//! #[macro_use] +//! extern crate quote; +//! +//! extern crate syn; +//! extern crate proc_macro; +//! extern crate proc_macro2; +//! +//! use syn::Type; +//! use syn::spanned::Spanned; +//! use proc_macro::TokenStream; +//! use proc_macro2::Span; +//! +//! # const IGNORE_TOKENS: &str = stringify! { +//! #[proc_macro_derive(MyMacro)] +//! # }; +//! pub fn my_macro(input: TokenStream) -> TokenStream { +//! # let ty = get_a_type(); +//! /* ... */ +//! +//! let assert_sync = quote_spanned! {ty.span()=> +//! struct _AssertSync where #ty: Sync; +//! }; +//! +//! /* ... */ +//! # input +//! } +//! # +//! # fn get_a_type() -> Type { +//! # unimplemented!() +//! # } +//! # +//! # fn main() {} +//! ``` +//! +//! By inserting this `assert_sync` fragment into the output code generated by +//! our macro, the user's code will fail to compile if `ty` does not implement +//! `Sync`. The errors they would see look like the following. +//! +//! ```text +//! error[E0277]: the trait bound `*const i32: std::marker::Sync` is not satisfied +//! --> src/main.rs:10:21 +//! | +//! 10 | bad_field: *const i32, +//! | ^^^^^^^^^^ `*const i32` cannot be shared between threads safely +//! ``` +//! +//! In this technique, using the `Type`'s span for the error message makes the +//! error appear in the correct place underlining the right type. + +use proc_macro2::{Span, TokenStream}; +use quote::ToTokens; + +/// A trait that can provide the `Span` of the complete contents of a syntax +/// tree node. +/// +/// This trait is automatically implemented for all types that implement +/// [`ToTokens`] from the `quote` crate. +/// +/// [`ToTokens`]: https://docs.rs/quote/0.4/quote/trait.ToTokens.html +/// +/// See the [module documentation] for an example. +/// +/// [module documentation]: index.html +/// +/// *This trait is available if Syn is built with both the `"parsing"` and +/// `"printing"` features.* +pub trait Spanned { + /// Returns a `Span` covering the complete contents of this syntax tree + /// node, or [`Span::call_site()`] if this node is empty. + /// + /// [`Span::call_site()`]: https://docs.rs/proc-macro2/0.2/proc_macro2/struct.Span.html#method.call_site + fn span(&self) -> Span; +} + +impl Spanned for T +where + T: ToTokens, +{ + #[cfg(procmacro2_semver_exempt)] + fn span(&self) -> Span { + let mut tokens = TokenStream::new(); + self.to_tokens(&mut tokens); + let mut iter = tokens.into_iter(); + let mut span = match iter.next() { + Some(tt) => tt.span(), + None => { + return Span::call_site(); + } + }; + for tt in iter { + if let Some(joined) = span.join(tt.span()) { + span = joined; + } + } + span + } + + #[cfg(not(procmacro2_semver_exempt))] + fn span(&self) -> Span { + let mut tokens = TokenStream::new(); + self.to_tokens(&mut tokens); + let mut iter = tokens.into_iter(); + + // We can't join spans without procmacro2_semver_exempt so just grab the + // first one. + match iter.next() { + Some(tt) => tt.span(), + None => Span::call_site(), + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/synom.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/synom.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/synom.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/synom.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,419 @@ +// Copyright 2018 Syn Developers +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Parsing interface for parsing a token stream into a syntax tree node. +//! +//! Parsing in Syn is built on parser functions that take in a [`Cursor`] and +//! produce a [`PResult`] where `T` is some syntax tree node. `Cursor` is a +//! cheaply copyable cursor over a range of tokens in a token stream, and +//! `PResult` is a result that packages together a parsed syntax tree node `T` +//! with a stream of remaining unparsed tokens after `T` represented as another +//! `Cursor`, or a [`ParseError`] if parsing failed. +//! +//! [`Cursor`]: ../buffer/index.html +//! [`PResult`]: type.PResult.html +//! [`ParseError`]: struct.ParseError.html +//! +//! This `Cursor`- and `PResult`-based interface is convenient for parser +//! combinators and parser implementations, but not necessarily when you just +//! have some tokens that you want to parse. For that we expose the following +//! two entry points. +//! +//! ## The `syn::parse*` functions +//! +//! The [`syn::parse`], [`syn::parse2`], and [`syn::parse_str`] functions serve +//! as an entry point for parsing syntax tree nodes that can be parsed in an +//! obvious default way. These functions can return any syntax tree node that +//! implements the [`Synom`] trait, which includes most types in Syn. +//! +//! [`syn::parse`]: ../fn.parse.html +//! [`syn::parse2`]: ../fn.parse2.html +//! [`syn::parse_str`]: ../fn.parse_str.html +//! [`Synom`]: trait.Synom.html +//! +//! ``` +//! use syn::Type; +//! +//! # fn run_parser() -> Result<(), syn::synom::ParseError> { +//! let t: Type = syn::parse_str("std::collections::HashMap")?; +//! # Ok(()) +//! # } +//! # +//! # fn main() { +//! # run_parser().unwrap(); +//! # } +//! ``` +//! +//! The [`parse_quote!`] macro also uses this approach. +//! +//! [`parse_quote!`]: ../macro.parse_quote.html +//! +//! ## The `Parser` trait +//! +//! Some types can be parsed in several ways depending on context. For example +//! an [`Attribute`] can be either "outer" like `#[...]` or "inner" like +//! `#![...]` and parsing the wrong one would be a bug. Similarly [`Punctuated`] +//! may or may not allow trailing punctuation, and parsing it the wrong way +//! would either reject valid input or accept invalid input. +//! +//! [`Attribute`]: ../struct.Attribute.html +//! [`Punctuated`]: ../punctuated/index.html +//! +//! The `Synom` trait is not implemented in these cases because there is no good +//! behavior to consider the default. +//! +//! ```ignore +//! // Can't parse `Punctuated` without knowing whether trailing punctuation +//! // should be allowed in this context. +//! let path: Punctuated = syn::parse(tokens)?; +//! ``` +//! +//! In these cases the types provide a choice of parser functions rather than a +//! single `Synom` implementation, and those parser functions can be invoked +//! through the [`Parser`] trait. +//! +//! [`Parser`]: trait.Parser.html +//! +//! ``` +//! # #[macro_use] +//! # extern crate syn; +//! # +//! # extern crate proc_macro2; +//! # use proc_macro2::TokenStream; +//! # +//! use syn::synom::Parser; +//! use syn::punctuated::Punctuated; +//! use syn::{PathSegment, Expr, Attribute}; +//! +//! # fn run_parsers() -> Result<(), syn::synom::ParseError> { +//! # let tokens = TokenStream::new().into(); +//! // Parse a nonempty sequence of path segments separated by `::` punctuation +//! // with no trailing punctuation. +//! let parser = Punctuated::::parse_separated_nonempty; +//! let path = parser.parse(tokens)?; +//! +//! # let tokens = TokenStream::new().into(); +//! // Parse a possibly empty sequence of expressions terminated by commas with +//! // an optional trailing punctuation. +//! let parser = Punctuated::::parse_terminated; +//! let args = parser.parse(tokens)?; +//! +//! # let tokens = TokenStream::new().into(); +//! // Parse zero or more outer attributes but not inner attributes. +//! named!(outer_attrs -> Vec, many0!(Attribute::parse_outer)); +//! let attrs = outer_attrs.parse(tokens)?; +//! # +//! # Ok(()) +//! # } +//! # +//! # fn main() {} +//! ``` +//! +//! # Implementing a parser function +//! +//! Parser functions are usually implemented using the [`nom`]-style parser +//! combinator macros provided by Syn, but may also be implemented without +//! macros be using the low-level [`Cursor`] API directly. +//! +//! [`nom`]: https://github.com/Geal/nom +//! +//! The following parser combinator macros are available and a `Synom` parsing +//! example is provided for each one. +//! +//! - [`alt!`](../macro.alt.html) +//! - [`braces!`](../macro.braces.html) +//! - [`brackets!`](../macro.brackets.html) +//! - [`call!`](../macro.call.html) +//! - [`cond!`](../macro.cond.html) +//! - [`cond_reduce!`](../macro.cond_reduce.html) +//! - [`custom_keyword!`](../macro.custom_keyword.html) +//! - [`do_parse!`](../macro.do_parse.html) +//! - [`epsilon!`](../macro.epsilon.html) +//! - [`input_end!`](../macro.input_end.html) +//! - [`keyword!`](../macro.keyword.html) +//! - [`many0!`](../macro.many0.html) +//! - [`map!`](../macro.map.html) +//! - [`not!`](../macro.not.html) +//! - [`option!`](../macro.option.html) +//! - [`parens!`](../macro.parens.html) +//! - [`punct!`](../macro.punct.html) +//! - [`reject!`](../macro.reject.html) +//! - [`switch!`](../macro.switch.html) +//! - [`syn!`](../macro.syn.html) +//! - [`tuple!`](../macro.tuple.html) +//! - [`value!`](../macro.value.html) +//! +//! *This module is available if Syn is built with the `"parsing"` feature.* + +#[cfg(all( + not(all(target_arch = "wasm32", target_os = "unknown")), + feature = "proc-macro" +))] +use proc_macro; +use proc_macro2::{Delimiter, Group, Ident, Literal, Punct, TokenStream, TokenTree}; + +use error::parse_error; +pub use error::{PResult, ParseError}; + +use buffer::{Cursor, TokenBuffer}; + +/// Parsing interface implemented by all types that can be parsed in a default +/// way from a token stream. +/// +/// Refer to the [module documentation] for details about parsing in Syn. +/// +/// [module documentation]: index.html +/// +/// *This trait is available if Syn is built with the `"parsing"` feature.* +pub trait Synom: Sized { + fn parse(input: Cursor) -> PResult; + + /// A short name of the type being parsed. + /// + /// The description should only be used for a simple name. It should not + /// contain newlines or sentence-ending punctuation, to facilitate embedding in + /// larger user-facing strings. Syn will use this description when building + /// error messages about parse failures. + /// + /// # Examples + /// + /// ``` + /// # use syn::buffer::Cursor; + /// # use syn::synom::{Synom, PResult}; + /// # + /// struct ExprMacro { + /// // ... + /// } + /// + /// impl Synom for ExprMacro { + /// # fn parse(input: Cursor) -> PResult { unimplemented!() } + /// // fn parse(...) -> ... { ... } + /// + /// fn description() -> Option<&'static str> { + /// // Will result in messages like + /// // + /// // "failed to parse macro invocation expression: $reason" + /// Some("macro invocation expression") + /// } + /// } + /// ``` + fn description() -> Option<&'static str> { + None + } +} + +impl Synom for TokenStream { + fn parse(input: Cursor) -> PResult { + Ok((input.token_stream(), Cursor::empty())) + } + + fn description() -> Option<&'static str> { + Some("arbitrary token stream") + } +} + +impl Synom for TokenTree { + fn parse(input: Cursor) -> PResult { + match input.token_tree() { + Some((tt, rest)) => Ok((tt, rest)), + None => parse_error(), + } + } + + fn description() -> Option<&'static str> { + Some("token tree") + } +} + +impl Synom for Group { + fn parse(input: Cursor) -> PResult { + for delim in &[Delimiter::Parenthesis, Delimiter::Brace, Delimiter::Bracket] { + if let Some((inside, span, rest)) = input.group(*delim) { + let mut group = Group::new(*delim, inside.token_stream()); + group.set_span(span); + return Ok((group, rest)); + } + } + parse_error() + } + + fn description() -> Option<&'static str> { + Some("group token") + } +} + +impl Synom for Ident { + fn parse(input: Cursor) -> PResult { + let (ident, rest) = match input.ident() { + Some(ident) => ident, + _ => return parse_error(), + }; + match &ident.to_string()[..] { + "_" + // Based on https://doc.rust-lang.org/grammar.html#keywords + // and https://github.com/rust-lang/rfcs/blob/master/text/2421-unreservations-2018.md + | "abstract" | "as" | "become" | "box" | "break" | "const" + | "continue" | "crate" | "do" | "else" | "enum" | "extern" | "false" | "final" + | "fn" | "for" | "if" | "impl" | "in" | "let" | "loop" | "macro" | "match" + | "mod" | "move" | "mut" | "override" | "priv" | "proc" | "pub" + | "ref" | "return" | "Self" | "self" | "static" | "struct" + | "super" | "trait" | "true" | "type" | "typeof" | "unsafe" | "unsized" | "use" + | "virtual" | "where" | "while" | "yield" => return parse_error(), + _ => {} + } + + Ok((ident, rest)) + } + + fn description() -> Option<&'static str> { + Some("identifier") + } +} + +impl Synom for Punct { + fn parse(input: Cursor) -> PResult { + match input.punct() { + Some((punct, rest)) => Ok((punct, rest)), + None => parse_error(), + } + } + + fn description() -> Option<&'static str> { + Some("punctuation token") + } +} + +impl Synom for Literal { + fn parse(input: Cursor) -> PResult { + match input.literal() { + Some((literal, rest)) => Ok((literal, rest)), + None => parse_error(), + } + } + + fn description() -> Option<&'static str> { + Some("literal token") + } +} + +/// Parser that can parse Rust tokens into a particular syntax tree node. +/// +/// Refer to the [module documentation] for details about parsing in Syn. +/// +/// [module documentation]: index.html +/// +/// *This trait is available if Syn is built with the `"parsing"` feature.* +pub trait Parser: Sized { + type Output; + + /// Parse a proc-macro2 token stream into the chosen syntax tree node. + fn parse2(self, tokens: TokenStream) -> Result; + + /// Parse tokens of source code into the chosen syntax tree node. + /// + /// *This method is available if Syn is built with both the `"parsing"` and + /// `"proc-macro"` features.* + #[cfg(all( + not(all(target_arch = "wasm32", target_os = "unknown")), + feature = "proc-macro" + ))] + fn parse(self, tokens: proc_macro::TokenStream) -> Result { + self.parse2(tokens.into()) + } + + /// Parse a string of Rust code into the chosen syntax tree node. + /// + /// # Hygiene + /// + /// Every span in the resulting syntax tree will be set to resolve at the + /// macro call site. + fn parse_str(self, s: &str) -> Result { + match s.parse() { + Ok(tts) => self.parse2(tts), + Err(_) => Err(ParseError::new("error while lexing input string")), + } + } +} + +impl Parser for F +where + F: FnOnce(Cursor) -> PResult, +{ + type Output = T; + + fn parse2(self, tokens: TokenStream) -> Result { + let buf = TokenBuffer::new2(tokens); + let (t, rest) = self(buf.begin())?; + if rest.eof() { + Ok(t) + } else if rest == buf.begin() { + // parsed nothing + Err(ParseError::new("failed to parse anything")) + } else { + Err(ParseError::new("failed to parse all tokens")) + } + } +} + +/// Extension traits that are made available within the `call!` parser. +/// +/// *This module is available if Syn is built with the `"parsing"` feature.* +pub mod ext { + use super::*; + use proc_macro2::Ident; + + /// Additional parsing methods for `Ident`. + /// + /// This trait is sealed and cannot be implemented for types outside of Syn. + /// + /// *This trait is available if Syn is built with the `"parsing"` feature.* + pub trait IdentExt: Sized + private::Sealed { + /// Parses any identifier including keywords. + /// + /// This is useful when parsing a DSL which allows Rust keywords as + /// identifiers. + /// + /// ```rust + /// #[macro_use] + /// extern crate syn; + /// + /// use syn::Ident; + /// + /// // Parses input that looks like `name = NAME` where `NAME` can be + /// // any identifier. + /// // + /// // Examples: + /// // + /// // name = anything + /// // name = impl + /// named!(parse_dsl -> Ident, do_parse!( + /// custom_keyword!(name) >> + /// punct!(=) >> + /// name: call!(Ident::parse_any) >> + /// (name) + /// )); + /// # + /// # fn main() {} + /// ``` + fn parse_any(input: Cursor) -> PResult; + } + + impl IdentExt for Ident { + fn parse_any(input: Cursor) -> PResult { + input.ident().map_or_else(parse_error, Ok) + } + } + + mod private { + use proc_macro2::Ident; + + pub trait Sealed {} + + impl Sealed for Ident {} + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/token.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/token.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/token.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/token.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,889 @@ +// Copyright 2018 Syn Developers +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Tokens representing Rust punctuation, keywords, and delimiters. +//! +//! The type names in this module can be difficult to keep straight, so we +//! prefer to use the [`Token!`] macro instead. This is a type-macro that +//! expands to the token type of the given token. +//! +//! [`Token!`]: ../macro.Token.html +//! +//! # Example +//! +//! The [`ItemStatic`] syntax tree node is defined like this. +//! +//! [`ItemStatic`]: ../struct.ItemStatic.html +//! +//! ``` +//! # #[macro_use] +//! # extern crate syn; +//! # +//! # use syn::{Attribute, Visibility, Ident, Type, Expr}; +//! # +//! pub struct ItemStatic { +//! pub attrs: Vec, +//! pub vis: Visibility, +//! pub static_token: Token![static], +//! pub mutability: Option, +//! pub ident: Ident, +//! pub colon_token: Token![:], +//! pub ty: Box, +//! pub eq_token: Token![=], +//! pub expr: Box, +//! pub semi_token: Token![;], +//! } +//! # +//! # fn main() {} +//! ``` +//! +//! # Parsing +//! +//! These tokens can be parsed using the [`Synom`] trait and the parser +//! combinator macros [`punct!`], [`keyword!`], [`parens!`], [`braces!`], and +//! [`brackets!`]. +//! +//! [`Synom`]: ../synom/trait.Synom.html +//! [`punct!`]: ../macro.punct.html +//! [`keyword!`]: ../macro.keyword.html +//! [`parens!`]: ../macro.parens.html +//! [`braces!`]: ../macro.braces.html +//! [`brackets!`]: ../macro.brackets.html +//! +//! ``` +//! #[macro_use] +//! extern crate syn; +//! +//! use syn::synom::Synom; +//! use syn::{Attribute, Visibility, Ident, Type, Expr}; +//! # +//! # struct ItemStatic; +//! # use syn::ItemStatic as SynItemStatic; +//! +//! // Parse the ItemStatic struct shown above. +//! impl Synom for ItemStatic { +//! named!(parse -> Self, do_parse!( +//! # (ItemStatic) +//! # )); +//! # } +//! # +//! # mod example { +//! # use super::*; +//! # use super::SynItemStatic as ItemStatic; +//! # +//! # named!(parse -> ItemStatic, do_parse!( +//! attrs: many0!(Attribute::parse_outer) >> +//! vis: syn!(Visibility) >> +//! static_token: keyword!(static) >> +//! mutability: option!(keyword!(mut)) >> +//! ident: syn!(Ident) >> +//! colon_token: punct!(:) >> +//! ty: syn!(Type) >> +//! eq_token: punct!(=) >> +//! expr: syn!(Expr) >> +//! semi_token: punct!(;) >> +//! (ItemStatic { +//! attrs, vis, static_token, mutability, ident, colon_token, +//! ty: Box::new(ty), eq_token, expr: Box::new(expr), semi_token, +//! }) +//! )); +//! } +//! # +//! # fn main() {} +//! ``` + +use proc_macro2::{Ident, Span}; + +macro_rules! tokens { + ( + punct: { + $($punct:tt pub struct $punct_name:ident/$len:tt #[$punct_doc:meta])* + } + delimiter: { + $($delimiter:tt pub struct $delimiter_name:ident #[$delimiter_doc:meta])* + } + keyword: { + $($keyword:tt pub struct $keyword_name:ident #[$keyword_doc:meta])* + } + ) => ( + $(token_punct_def! { #[$punct_doc] pub struct $punct_name/$len })* + $(token_punct_parser! { $punct pub struct $punct_name })* + $(token_delimiter! { #[$delimiter_doc] $delimiter pub struct $delimiter_name })* + $(token_keyword! { #[$keyword_doc] $keyword pub struct $keyword_name })* + ) +} + +macro_rules! token_punct_def { + (#[$doc:meta]pub struct $name:ident / $len:tt) => { + #[cfg_attr(feature = "clone-impls", derive(Copy, Clone))] + #[$doc] + /// + /// Don't try to remember the name of this type -- use the [`Token!`] + /// macro instead. + /// + /// [`Token!`]: index.html + pub struct $name(pub [Span; $len]); + + impl $name { + pub fn new(span: Span) -> Self { + $name([span; $len]) + } + } + + impl ::std::default::Default for $name { + fn default() -> Self { + $name([Span::call_site(); $len]) + } + } + + #[cfg(feature = "extra-traits")] + impl ::std::fmt::Debug for $name { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.write_str(stringify!($name)) + } + } + + #[cfg(feature = "extra-traits")] + impl ::std::cmp::Eq for $name {} + + #[cfg(feature = "extra-traits")] + impl ::std::cmp::PartialEq for $name { + fn eq(&self, _other: &$name) -> bool { + true + } + } + + #[cfg(feature = "extra-traits")] + impl ::std::hash::Hash for $name { + fn hash(&self, _state: &mut H) + where + H: ::std::hash::Hasher, + { + } + } + + impl From for $name { + fn from(span: Span) -> Self { + $name([span; $len]) + } + } + }; +} + +macro_rules! token_punct_parser { + ($s:tt pub struct $name:ident) => { + #[cfg(feature = "printing")] + impl ::quote::ToTokens for $name { + fn to_tokens(&self, tokens: &mut ::proc_macro2::TokenStream) { + printing::punct($s, &self.0, tokens); + } + } + + #[cfg(feature = "parsing")] + impl ::Synom for $name { + fn parse(tokens: $crate::buffer::Cursor) -> $crate::synom::PResult<$name> { + parsing::punct($s, tokens, $name) + } + + fn description() -> Option<&'static str> { + Some(concat!("`", $s, "`")) + } + } + }; +} + +macro_rules! token_keyword { + (#[$doc:meta] $s:tt pub struct $name:ident) => { + #[cfg_attr(feature = "clone-impls", derive(Copy, Clone))] + #[$doc] + /// + /// Don't try to remember the name of this type -- use the [`Token!`] + /// macro instead. + /// + /// [`Token!`]: index.html + pub struct $name(pub Span); + + impl ::std::default::Default for $name { + fn default() -> Self { + $name(Span::call_site()) + } + } + + #[cfg(feature = "extra-traits")] + impl ::std::fmt::Debug for $name { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.write_str(stringify!($name)) + } + } + + #[cfg(feature = "extra-traits")] + impl ::std::cmp::Eq for $name {} + + #[cfg(feature = "extra-traits")] + impl ::std::cmp::PartialEq for $name { + fn eq(&self, _other: &$name) -> bool { + true + } + } + + #[cfg(feature = "extra-traits")] + impl ::std::hash::Hash for $name { + fn hash(&self, _state: &mut H) + where + H: ::std::hash::Hasher, + { + } + } + + #[cfg(feature = "printing")] + impl ::quote::ToTokens for $name { + fn to_tokens(&self, tokens: &mut ::proc_macro2::TokenStream) { + printing::keyword($s, &self.0, tokens); + } + } + + #[cfg(feature = "parsing")] + impl ::Synom for $name { + fn parse(tokens: $crate::buffer::Cursor) -> $crate::synom::PResult<$name> { + parsing::keyword($s, tokens, $name) + } + + fn description() -> Option<&'static str> { + Some(concat!("`", $s, "`")) + } + } + + impl From for $name { + fn from(span: Span) -> Self { + $name(span) + } + } + }; +} + +macro_rules! token_delimiter { + (#[$doc:meta] $s:tt pub struct $name:ident) => { + #[cfg_attr(feature = "clone-impls", derive(Copy, Clone))] + #[$doc] + pub struct $name(pub Span); + + impl ::std::default::Default for $name { + fn default() -> Self { + $name(Span::call_site()) + } + } + + #[cfg(feature = "extra-traits")] + impl ::std::fmt::Debug for $name { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.write_str(stringify!($name)) + } + } + + #[cfg(feature = "extra-traits")] + impl ::std::cmp::Eq for $name {} + + #[cfg(feature = "extra-traits")] + impl ::std::cmp::PartialEq for $name { + fn eq(&self, _other: &$name) -> bool { + true + } + } + + #[cfg(feature = "extra-traits")] + impl ::std::hash::Hash for $name { + fn hash(&self, _state: &mut H) + where + H: ::std::hash::Hasher, + { + } + } + + impl $name { + #[cfg(feature = "printing")] + pub fn surround(&self, tokens: &mut ::proc_macro2::TokenStream, f: F) + where + F: FnOnce(&mut ::proc_macro2::TokenStream), + { + printing::delim($s, &self.0, tokens, f); + } + + #[cfg(feature = "parsing")] + pub fn parse( + tokens: $crate::buffer::Cursor, + f: F, + ) -> $crate::synom::PResult<($name, R)> + where + F: FnOnce($crate::buffer::Cursor) -> $crate::synom::PResult, + { + parsing::delim($s, tokens, $name, f) + } + } + + impl From for $name { + fn from(span: Span) -> Self { + $name(span) + } + } + }; +} + +token_punct_def! { + /// `_` + pub struct Underscore/1 +} + +#[cfg(feature = "printing")] +impl ::quote::ToTokens for Underscore { + fn to_tokens(&self, tokens: &mut ::proc_macro2::TokenStream) { + use quote::TokenStreamExt; + tokens.append(::proc_macro2::Ident::new("_", self.0[0])); + } +} + +#[cfg(feature = "parsing")] +impl ::Synom for Underscore { + fn parse(input: ::buffer::Cursor) -> ::synom::PResult { + match input.ident() { + Some((ident, rest)) => { + if ident == "_" { + Ok((Underscore([ident.span()]), rest)) + } else { + ::parse_error() + } + } + None => parsing::punct("_", input, Underscore), + } + } + + fn description() -> Option<&'static str> { + Some("`_`") + } +} + +token_punct_def! { + /// `'` + pub struct Apostrophe/1 +} + +// Implement Clone anyway because it is required for cloning Lifetime. +#[cfg(not(feature = "clone-impls"))] +impl Clone for Apostrophe { + fn clone(&self) -> Self { + Apostrophe(self.0) + } +} + +#[cfg(feature = "printing")] +impl ::quote::ToTokens for Apostrophe { + fn to_tokens(&self, tokens: &mut ::proc_macro2::TokenStream) { + use quote::TokenStreamExt; + let mut token = ::proc_macro2::Punct::new('\'', ::proc_macro2::Spacing::Joint); + token.set_span(self.0[0]); + tokens.append(token); + } +} + +#[cfg(feature = "parsing")] +impl ::Synom for Apostrophe { + fn parse(input: ::buffer::Cursor) -> ::synom::PResult { + match input.punct() { + Some((op, rest)) => { + if op.as_char() == '\'' && op.spacing() == ::proc_macro2::Spacing::Joint { + Ok((Apostrophe([op.span()]), rest)) + } else { + ::parse_error() + } + } + None => ::parse_error(), + } + } + + fn description() -> Option<&'static str> { + Some("`'`") + } +} + +tokens! { + punct: { + "+" pub struct Add/1 /// `+` + "+=" pub struct AddEq/2 /// `+=` + "&" pub struct And/1 /// `&` + "&&" pub struct AndAnd/2 /// `&&` + "&=" pub struct AndEq/2 /// `&=` + "@" pub struct At/1 /// `@` + "!" pub struct Bang/1 /// `!` + "^" pub struct Caret/1 /// `^` + "^=" pub struct CaretEq/2 /// `^=` + ":" pub struct Colon/1 /// `:` + "::" pub struct Colon2/2 /// `::` + "," pub struct Comma/1 /// `,` + "/" pub struct Div/1 /// `/` + "/=" pub struct DivEq/2 /// `/=` + "$" pub struct Dollar/1 /// `$` + "." pub struct Dot/1 /// `.` + ".." pub struct Dot2/2 /// `..` + "..." pub struct Dot3/3 /// `...` + "..=" pub struct DotDotEq/3 /// `..=` + "=" pub struct Eq/1 /// `=` + "==" pub struct EqEq/2 /// `==` + ">=" pub struct Ge/2 /// `>=` + ">" pub struct Gt/1 /// `>` + "<=" pub struct Le/2 /// `<=` + "<" pub struct Lt/1 /// `<` + "*=" pub struct MulEq/2 /// `*=` + "!=" pub struct Ne/2 /// `!=` + "|" pub struct Or/1 /// `|` + "|=" pub struct OrEq/2 /// `|=` + "||" pub struct OrOr/2 /// `||` + "#" pub struct Pound/1 /// `#` + "?" pub struct Question/1 /// `?` + "->" pub struct RArrow/2 /// `->` + "<-" pub struct LArrow/2 /// `<-` + "%" pub struct Rem/1 /// `%` + "%=" pub struct RemEq/2 /// `%=` + "=>" pub struct FatArrow/2 /// `=>` + ";" pub struct Semi/1 /// `;` + "<<" pub struct Shl/2 /// `<<` + "<<=" pub struct ShlEq/3 /// `<<=` + ">>" pub struct Shr/2 /// `>>` + ">>=" pub struct ShrEq/3 /// `>>=` + "*" pub struct Star/1 /// `*` + "-" pub struct Sub/1 /// `-` + "-=" pub struct SubEq/2 /// `-=` + } + delimiter: { + "{" pub struct Brace /// `{...}` + "[" pub struct Bracket /// `[...]` + "(" pub struct Paren /// `(...)` + " " pub struct Group /// None-delimited group + } + keyword: { + "as" pub struct As /// `as` + "async" pub struct Async /// `async` + "auto" pub struct Auto /// `auto` + "box" pub struct Box /// `box` + "break" pub struct Break /// `break` + "Self" pub struct CapSelf /// `Self` + "catch" pub struct Catch /// `catch` + "const" pub struct Const /// `const` + "continue" pub struct Continue /// `continue` + "crate" pub struct Crate /// `crate` + "default" pub struct Default /// `default` + "do" pub struct Do /// `do` + "dyn" pub struct Dyn /// `dyn` + "else" pub struct Else /// `else` + "enum" pub struct Enum /// `enum` + "extern" pub struct Extern /// `extern` + "fn" pub struct Fn /// `fn` + "for" pub struct For /// `for` + "if" pub struct If /// `if` + "impl" pub struct Impl /// `impl` + "in" pub struct In /// `in` + "let" pub struct Let /// `let` + "loop" pub struct Loop /// `loop` + "macro" pub struct Macro /// `macro` + "match" pub struct Match /// `match` + "mod" pub struct Mod /// `mod` + "move" pub struct Move /// `move` + "mut" pub struct Mut /// `mut` + "pub" pub struct Pub /// `pub` + "ref" pub struct Ref /// `ref` + "return" pub struct Return /// `return` + "self" pub struct Self_ /// `self` + "static" pub struct Static /// `static` + "struct" pub struct Struct /// `struct` + "super" pub struct Super /// `super` + "trait" pub struct Trait /// `trait` + "type" pub struct Type /// `type` + "union" pub struct Union /// `union` + "unsafe" pub struct Unsafe /// `unsafe` + "use" pub struct Use /// `use` + "where" pub struct Where /// `where` + "while" pub struct While /// `while` + "yield" pub struct Yield /// `yield` + } +} + +/// A type-macro that expands to the name of the Rust type representation of a +/// given token. +/// +/// See the [token module] documentation for details and examples. +/// +/// [token module]: token/index.html +// Unfortunate duplication due to a rustdoc bug. +// https://github.com/rust-lang/rust/issues/45939 +#[macro_export] +#[cfg_attr(rustfmt, rustfmt_skip)] +macro_rules! Token { + (+) => { $crate::token::Add }; + (+=) => { $crate::token::AddEq }; + (&) => { $crate::token::And }; + (&&) => { $crate::token::AndAnd }; + (&=) => { $crate::token::AndEq }; + (@) => { $crate::token::At }; + (!) => { $crate::token::Bang }; + (^) => { $crate::token::Caret }; + (^=) => { $crate::token::CaretEq }; + (:) => { $crate::token::Colon }; + (::) => { $crate::token::Colon2 }; + (,) => { $crate::token::Comma }; + (/) => { $crate::token::Div }; + (/=) => { $crate::token::DivEq }; + (.) => { $crate::token::Dot }; + (..) => { $crate::token::Dot2 }; + (...) => { $crate::token::Dot3 }; + (..=) => { $crate::token::DotDotEq }; + (=) => { $crate::token::Eq }; + (==) => { $crate::token::EqEq }; + (>=) => { $crate::token::Ge }; + (>) => { $crate::token::Gt }; + (<=) => { $crate::token::Le }; + (<) => { $crate::token::Lt }; + (*=) => { $crate::token::MulEq }; + (!=) => { $crate::token::Ne }; + (|) => { $crate::token::Or }; + (|=) => { $crate::token::OrEq }; + (||) => { $crate::token::OrOr }; + (#) => { $crate::token::Pound }; + (?) => { $crate::token::Question }; + (->) => { $crate::token::RArrow }; + (<-) => { $crate::token::LArrow }; + (%) => { $crate::token::Rem }; + (%=) => { $crate::token::RemEq }; + (=>) => { $crate::token::FatArrow }; + (;) => { $crate::token::Semi }; + (<<) => { $crate::token::Shl }; + (<<=) => { $crate::token::ShlEq }; + (>>) => { $crate::token::Shr }; + (>>=) => { $crate::token::ShrEq }; + (*) => { $crate::token::Star }; + (-) => { $crate::token::Sub }; + (-=) => { $crate::token::SubEq }; + (_) => { $crate::token::Underscore }; + (as) => { $crate::token::As }; + (async) => { $crate::token::Async }; + (auto) => { $crate::token::Auto }; + (box) => { $crate::token::Box }; + (break) => { $crate::token::Break }; + (Self) => { $crate::token::CapSelf }; + (catch) => { $crate::token::Catch }; + (const) => { $crate::token::Const }; + (continue) => { $crate::token::Continue }; + (crate) => { $crate::token::Crate }; + (default) => { $crate::token::Default }; + (do) => { $crate::token::Do }; + (dyn) => { $crate::token::Dyn }; + (else) => { $crate::token::Else }; + (enum) => { $crate::token::Enum }; + (extern) => { $crate::token::Extern }; + (fn) => { $crate::token::Fn }; + (for) => { $crate::token::For }; + (if) => { $crate::token::If }; + (impl) => { $crate::token::Impl }; + (in) => { $crate::token::In }; + (let) => { $crate::token::Let }; + (loop) => { $crate::token::Loop }; + (macro) => { $crate::token::Macro }; + (match) => { $crate::token::Match }; + (mod) => { $crate::token::Mod }; + (move) => { $crate::token::Move }; + (mut) => { $crate::token::Mut }; + (pub) => { $crate::token::Pub }; + (ref) => { $crate::token::Ref }; + (return) => { $crate::token::Return }; + (self) => { $crate::token::Self_ }; + (static) => { $crate::token::Static }; + (struct) => { $crate::token::Struct }; + (super) => { $crate::token::Super }; + (trait) => { $crate::token::Trait }; + (type) => { $crate::token::Type }; + (union) => { $crate::token::Union }; + (unsafe) => { $crate::token::Unsafe }; + (use) => { $crate::token::Use }; + (where) => { $crate::token::Where }; + (while) => { $crate::token::While }; + (yield) => { $crate::token::Yield }; +} + +/// Parse a single Rust punctuation token. +/// +/// See the [token module] documentation for details and examples. +/// +/// [token module]: token/index.html +/// +/// *This macro is available if Syn is built with the `"parsing"` feature.* +#[cfg(feature = "parsing")] +#[macro_export] +#[cfg_attr(rustfmt, rustfmt_skip)] +macro_rules! punct { + ($i:expr, +) => { call!($i, <$crate::token::Add as $crate::synom::Synom>::parse) }; + ($i:expr, +=) => { call!($i, <$crate::token::AddEq as $crate::synom::Synom>::parse) }; + ($i:expr, &) => { call!($i, <$crate::token::And as $crate::synom::Synom>::parse) }; + ($i:expr, &&) => { call!($i, <$crate::token::AndAnd as $crate::synom::Synom>::parse) }; + ($i:expr, &=) => { call!($i, <$crate::token::AndEq as $crate::synom::Synom>::parse) }; + ($i:expr, @) => { call!($i, <$crate::token::At as $crate::synom::Synom>::parse) }; + ($i:expr, !) => { call!($i, <$crate::token::Bang as $crate::synom::Synom>::parse) }; + ($i:expr, ^) => { call!($i, <$crate::token::Caret as $crate::synom::Synom>::parse) }; + ($i:expr, ^=) => { call!($i, <$crate::token::CaretEq as $crate::synom::Synom>::parse) }; + ($i:expr, :) => { call!($i, <$crate::token::Colon as $crate::synom::Synom>::parse) }; + ($i:expr, ::) => { call!($i, <$crate::token::Colon2 as $crate::synom::Synom>::parse) }; + ($i:expr, ,) => { call!($i, <$crate::token::Comma as $crate::synom::Synom>::parse) }; + ($i:expr, /) => { call!($i, <$crate::token::Div as $crate::synom::Synom>::parse) }; + ($i:expr, /=) => { call!($i, <$crate::token::DivEq as $crate::synom::Synom>::parse) }; + ($i:expr, .) => { call!($i, <$crate::token::Dot as $crate::synom::Synom>::parse) }; + ($i:expr, ..) => { call!($i, <$crate::token::Dot2 as $crate::synom::Synom>::parse) }; + ($i:expr, ...) => { call!($i, <$crate::token::Dot3 as $crate::synom::Synom>::parse) }; + ($i:expr, ..=) => { call!($i, <$crate::token::DotDotEq as $crate::synom::Synom>::parse) }; + ($i:expr, =) => { call!($i, <$crate::token::Eq as $crate::synom::Synom>::parse) }; + ($i:expr, ==) => { call!($i, <$crate::token::EqEq as $crate::synom::Synom>::parse) }; + ($i:expr, >=) => { call!($i, <$crate::token::Ge as $crate::synom::Synom>::parse) }; + ($i:expr, >) => { call!($i, <$crate::token::Gt as $crate::synom::Synom>::parse) }; + ($i:expr, <=) => { call!($i, <$crate::token::Le as $crate::synom::Synom>::parse) }; + ($i:expr, <) => { call!($i, <$crate::token::Lt as $crate::synom::Synom>::parse) }; + ($i:expr, *=) => { call!($i, <$crate::token::MulEq as $crate::synom::Synom>::parse) }; + ($i:expr, !=) => { call!($i, <$crate::token::Ne as $crate::synom::Synom>::parse) }; + ($i:expr, |) => { call!($i, <$crate::token::Or as $crate::synom::Synom>::parse) }; + ($i:expr, |=) => { call!($i, <$crate::token::OrEq as $crate::synom::Synom>::parse) }; + ($i:expr, ||) => { call!($i, <$crate::token::OrOr as $crate::synom::Synom>::parse) }; + ($i:expr, #) => { call!($i, <$crate::token::Pound as $crate::synom::Synom>::parse) }; + ($i:expr, ?) => { call!($i, <$crate::token::Question as $crate::synom::Synom>::parse) }; + ($i:expr, ->) => { call!($i, <$crate::token::RArrow as $crate::synom::Synom>::parse) }; + ($i:expr, <-) => { call!($i, <$crate::token::LArrow as $crate::synom::Synom>::parse) }; + ($i:expr, %) => { call!($i, <$crate::token::Rem as $crate::synom::Synom>::parse) }; + ($i:expr, %=) => { call!($i, <$crate::token::RemEq as $crate::synom::Synom>::parse) }; + ($i:expr, =>) => { call!($i, <$crate::token::FatArrow as $crate::synom::Synom>::parse) }; + ($i:expr, ;) => { call!($i, <$crate::token::Semi as $crate::synom::Synom>::parse) }; + ($i:expr, <<) => { call!($i, <$crate::token::Shl as $crate::synom::Synom>::parse) }; + ($i:expr, <<=) => { call!($i, <$crate::token::ShlEq as $crate::synom::Synom>::parse) }; + ($i:expr, >>) => { call!($i, <$crate::token::Shr as $crate::synom::Synom>::parse) }; + ($i:expr, >>=) => { call!($i, <$crate::token::ShrEq as $crate::synom::Synom>::parse) }; + ($i:expr, *) => { call!($i, <$crate::token::Star as $crate::synom::Synom>::parse) }; + ($i:expr, -) => { call!($i, <$crate::token::Sub as $crate::synom::Synom>::parse) }; + ($i:expr, -=) => { call!($i, <$crate::token::SubEq as $crate::synom::Synom>::parse) }; + ($i:expr, _) => { call!($i, <$crate::token::Underscore as $crate::synom::Synom>::parse) }; +} + +/// Parse a single Rust keyword token. +/// +/// See the [token module] documentation for details and examples. +/// +/// [token module]: token/index.html +/// +/// *This macro is available if Syn is built with the `"parsing"` feature.* +#[cfg(feature = "parsing")] +#[macro_export] +#[cfg_attr(rustfmt, rustfmt_skip)] +macro_rules! keyword { + ($i:expr, as) => { call!($i, <$crate::token::As as $crate::synom::Synom>::parse) }; + ($i:expr, async) => { call!($i, <$crate::token::Async as $crate::synom::Synom>::parse) }; + ($i:expr, auto) => { call!($i, <$crate::token::Auto as $crate::synom::Synom>::parse) }; + ($i:expr, box) => { call!($i, <$crate::token::Box as $crate::synom::Synom>::parse) }; + ($i:expr, break) => { call!($i, <$crate::token::Break as $crate::synom::Synom>::parse) }; + ($i:expr, Self) => { call!($i, <$crate::token::CapSelf as $crate::synom::Synom>::parse) }; + ($i:expr, catch) => { call!($i, <$crate::token::Catch as $crate::synom::Synom>::parse) }; + ($i:expr, const) => { call!($i, <$crate::token::Const as $crate::synom::Synom>::parse) }; + ($i:expr, continue) => { call!($i, <$crate::token::Continue as $crate::synom::Synom>::parse) }; + ($i:expr, crate) => { call!($i, <$crate::token::Crate as $crate::synom::Synom>::parse) }; + ($i:expr, default) => { call!($i, <$crate::token::Default as $crate::synom::Synom>::parse) }; + ($i:expr, do) => { call!($i, <$crate::token::Do as $crate::synom::Synom>::parse) }; + ($i:expr, dyn) => { call!($i, <$crate::token::Dyn as $crate::synom::Synom>::parse) }; + ($i:expr, else) => { call!($i, <$crate::token::Else as $crate::synom::Synom>::parse) }; + ($i:expr, enum) => { call!($i, <$crate::token::Enum as $crate::synom::Synom>::parse) }; + ($i:expr, extern) => { call!($i, <$crate::token::Extern as $crate::synom::Synom>::parse) }; + ($i:expr, fn) => { call!($i, <$crate::token::Fn as $crate::synom::Synom>::parse) }; + ($i:expr, for) => { call!($i, <$crate::token::For as $crate::synom::Synom>::parse) }; + ($i:expr, if) => { call!($i, <$crate::token::If as $crate::synom::Synom>::parse) }; + ($i:expr, impl) => { call!($i, <$crate::token::Impl as $crate::synom::Synom>::parse) }; + ($i:expr, in) => { call!($i, <$crate::token::In as $crate::synom::Synom>::parse) }; + ($i:expr, let) => { call!($i, <$crate::token::Let as $crate::synom::Synom>::parse) }; + ($i:expr, loop) => { call!($i, <$crate::token::Loop as $crate::synom::Synom>::parse) }; + ($i:expr, macro) => { call!($i, <$crate::token::Macro as $crate::synom::Synom>::parse) }; + ($i:expr, match) => { call!($i, <$crate::token::Match as $crate::synom::Synom>::parse) }; + ($i:expr, mod) => { call!($i, <$crate::token::Mod as $crate::synom::Synom>::parse) }; + ($i:expr, move) => { call!($i, <$crate::token::Move as $crate::synom::Synom>::parse) }; + ($i:expr, mut) => { call!($i, <$crate::token::Mut as $crate::synom::Synom>::parse) }; + ($i:expr, pub) => { call!($i, <$crate::token::Pub as $crate::synom::Synom>::parse) }; + ($i:expr, ref) => { call!($i, <$crate::token::Ref as $crate::synom::Synom>::parse) }; + ($i:expr, return) => { call!($i, <$crate::token::Return as $crate::synom::Synom>::parse) }; + ($i:expr, self) => { call!($i, <$crate::token::Self_ as $crate::synom::Synom>::parse) }; + ($i:expr, static) => { call!($i, <$crate::token::Static as $crate::synom::Synom>::parse) }; + ($i:expr, struct) => { call!($i, <$crate::token::Struct as $crate::synom::Synom>::parse) }; + ($i:expr, super) => { call!($i, <$crate::token::Super as $crate::synom::Synom>::parse) }; + ($i:expr, trait) => { call!($i, <$crate::token::Trait as $crate::synom::Synom>::parse) }; + ($i:expr, type) => { call!($i, <$crate::token::Type as $crate::synom::Synom>::parse) }; + ($i:expr, union) => { call!($i, <$crate::token::Union as $crate::synom::Synom>::parse) }; + ($i:expr, unsafe) => { call!($i, <$crate::token::Unsafe as $crate::synom::Synom>::parse) }; + ($i:expr, use) => { call!($i, <$crate::token::Use as $crate::synom::Synom>::parse) }; + ($i:expr, where) => { call!($i, <$crate::token::Where as $crate::synom::Synom>::parse) }; + ($i:expr, while) => { call!($i, <$crate::token::While as $crate::synom::Synom>::parse) }; + ($i:expr, yield) => { call!($i, <$crate::token::Yield as $crate::synom::Synom>::parse) }; +} + +macro_rules! ident_from_token { + ($token:ident) => { + impl From for Ident { + fn from(token: Token![$token]) -> Ident { + Ident::new(stringify!($token), token.0) + } + } + }; +} + +ident_from_token!(self); +ident_from_token!(Self); +ident_from_token!(super); +ident_from_token!(crate); +ident_from_token!(extern); + +#[cfg(feature = "parsing")] +mod parsing { + use proc_macro2::{Delimiter, Spacing, Span}; + + use buffer::Cursor; + use parse_error; + use synom::PResult; + + pub trait FromSpans: Sized { + fn from_spans(spans: &[Span]) -> Self; + } + + impl FromSpans for [Span; 1] { + fn from_spans(spans: &[Span]) -> Self { + [spans[0]] + } + } + + impl FromSpans for [Span; 2] { + fn from_spans(spans: &[Span]) -> Self { + [spans[0], spans[1]] + } + } + + impl FromSpans for [Span; 3] { + fn from_spans(spans: &[Span]) -> Self { + [spans[0], spans[1], spans[2]] + } + } + + pub fn punct<'a, T, R>(s: &str, mut tokens: Cursor<'a>, new: fn(T) -> R) -> PResult<'a, R> + where + T: FromSpans, + { + let mut spans = [Span::call_site(); 3]; + assert!(s.len() <= spans.len()); + let chars = s.chars(); + + for (i, (ch, slot)) in chars.zip(&mut spans).enumerate() { + match tokens.punct() { + Some((op, rest)) => { + if op.as_char() == ch { + if i != s.len() - 1 { + match op.spacing() { + Spacing::Joint => {} + _ => return parse_error(), + } + } + *slot = op.span(); + tokens = rest; + } else { + return parse_error(); + } + } + _ => return parse_error(), + } + } + Ok((new(T::from_spans(&spans)), tokens)) + } + + pub fn keyword<'a, T>(keyword: &str, tokens: Cursor<'a>, new: fn(Span) -> T) -> PResult<'a, T> { + if let Some((ident, rest)) = tokens.ident() { + if ident == keyword { + return Ok((new(ident.span()), rest)); + } + } + parse_error() + } + + pub fn delim<'a, F, R, T>( + delim: &str, + tokens: Cursor<'a>, + new: fn(Span) -> T, + f: F, + ) -> PResult<'a, (T, R)> + where + F: FnOnce(Cursor) -> PResult, + { + // NOTE: We should support none-delimited sequences here. + let delim = match delim { + "(" => Delimiter::Parenthesis, + "{" => Delimiter::Brace, + "[" => Delimiter::Bracket, + " " => Delimiter::None, + _ => panic!("unknown delimiter: {}", delim), + }; + + if let Some((inside, span, rest)) = tokens.group(delim) { + match f(inside) { + Ok((ret, remaining)) => { + if remaining.eof() { + return Ok(((new(span), ret), rest)); + } + } + Err(err) => return Err(err), + } + } + parse_error() + } +} + +#[cfg(feature = "printing")] +mod printing { + use proc_macro2::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream}; + use quote::TokenStreamExt; + + pub fn punct(s: &str, spans: &[Span], tokens: &mut TokenStream) { + assert_eq!(s.len(), spans.len()); + + let mut chars = s.chars(); + let mut spans = spans.iter(); + let ch = chars.next_back().unwrap(); + let span = spans.next_back().unwrap(); + for (ch, span) in chars.zip(spans) { + let mut op = Punct::new(ch, Spacing::Joint); + op.set_span(*span); + tokens.append(op); + } + + let mut op = Punct::new(ch, Spacing::Alone); + op.set_span(*span); + tokens.append(op); + } + + pub fn keyword(s: &str, span: &Span, tokens: &mut TokenStream) { + tokens.append(Ident::new(s, *span)); + } + + pub fn delim(s: &str, span: &Span, tokens: &mut TokenStream, f: F) + where + F: FnOnce(&mut TokenStream), + { + let delim = match s { + "(" => Delimiter::Parenthesis, + "[" => Delimiter::Bracket, + "{" => Delimiter::Brace, + " " => Delimiter::None, + _ => panic!("unknown delimiter: {}", s), + }; + let mut inner = TokenStream::new(); + f(&mut inner); + let mut g = Group::new(delim, inner); + g.set_span(*span); + tokens.append(g); + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/tt.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/tt.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/tt.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/tt.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,170 @@ +// Copyright 2018 Syn Developers +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[cfg(feature = "parsing")] +use buffer::Cursor; +#[cfg(feature = "parsing")] +use synom::PResult; +#[cfg(feature = "parsing")] +use token::{Brace, Bracket, Paren}; +#[cfg(feature = "parsing")] +use {parse_error, MacroDelimiter}; + +#[cfg(feature = "extra-traits")] +use std::hash::{Hash, Hasher}; + +#[cfg(any(feature = "parsing", feature = "extra-traits"))] +use proc_macro2::{Delimiter, TokenStream, TokenTree}; + +#[cfg(feature = "parsing")] +pub fn delimited(input: Cursor) -> PResult<(MacroDelimiter, TokenStream)> { + if let Some((TokenTree::Group(g), rest)) = input.token_tree() { + let span = g.span(); + let delimiter = match g.delimiter() { + Delimiter::Parenthesis => MacroDelimiter::Paren(Paren(span)), + Delimiter::Brace => MacroDelimiter::Brace(Brace(span)), + Delimiter::Bracket => MacroDelimiter::Bracket(Bracket(span)), + Delimiter::None => return parse_error(), + }; + + return Ok(((delimiter, g.stream().clone()), rest)); + } + parse_error() +} + +#[cfg(all(feature = "full", feature = "parsing"))] +pub fn braced(input: Cursor) -> PResult<(Brace, TokenStream)> { + if let Some((TokenTree::Group(g), rest)) = input.token_tree() { + if g.delimiter() == Delimiter::Brace { + return Ok(((Brace(g.span()), g.stream().clone()), rest)); + } + } + parse_error() +} + +#[cfg(all(feature = "full", feature = "parsing"))] +pub fn parenthesized(input: Cursor) -> PResult<(Paren, TokenStream)> { + if let Some((TokenTree::Group(g), rest)) = input.token_tree() { + if g.delimiter() == Delimiter::Parenthesis { + return Ok(((Paren(g.span()), g.stream().clone()), rest)); + } + } + parse_error() +} + +#[cfg(feature = "extra-traits")] +pub struct TokenTreeHelper<'a>(pub &'a TokenTree); + +#[cfg(feature = "extra-traits")] +impl<'a> PartialEq for TokenTreeHelper<'a> { + fn eq(&self, other: &Self) -> bool { + use proc_macro2::Spacing; + + match (self.0, other.0) { + (&TokenTree::Group(ref g1), &TokenTree::Group(ref g2)) => { + match (g1.delimiter(), g2.delimiter()) { + (Delimiter::Parenthesis, Delimiter::Parenthesis) + | (Delimiter::Brace, Delimiter::Brace) + | (Delimiter::Bracket, Delimiter::Bracket) + | (Delimiter::None, Delimiter::None) => {} + _ => return false, + } + + let s1 = g1.stream().clone().into_iter(); + let mut s2 = g2.stream().clone().into_iter(); + + for item1 in s1 { + let item2 = match s2.next() { + Some(item) => item, + None => return false, + }; + if TokenTreeHelper(&item1) != TokenTreeHelper(&item2) { + return false; + } + } + s2.next().is_none() + } + (&TokenTree::Punct(ref o1), &TokenTree::Punct(ref o2)) => { + o1.as_char() == o2.as_char() && match (o1.spacing(), o2.spacing()) { + (Spacing::Alone, Spacing::Alone) | (Spacing::Joint, Spacing::Joint) => true, + _ => false, + } + } + (&TokenTree::Literal(ref l1), &TokenTree::Literal(ref l2)) => { + l1.to_string() == l2.to_string() + } + (&TokenTree::Ident(ref s1), &TokenTree::Ident(ref s2)) => s1 == s2, + _ => false, + } + } +} + +#[cfg(feature = "extra-traits")] +impl<'a> Hash for TokenTreeHelper<'a> { + fn hash(&self, h: &mut H) { + use proc_macro2::Spacing; + + match *self.0 { + TokenTree::Group(ref g) => { + 0u8.hash(h); + match g.delimiter() { + Delimiter::Parenthesis => 0u8.hash(h), + Delimiter::Brace => 1u8.hash(h), + Delimiter::Bracket => 2u8.hash(h), + Delimiter::None => 3u8.hash(h), + } + + for item in g.stream().clone() { + TokenTreeHelper(&item).hash(h); + } + 0xffu8.hash(h); // terminator w/ a variant we don't normally hash + } + TokenTree::Punct(ref op) => { + 1u8.hash(h); + op.as_char().hash(h); + match op.spacing() { + Spacing::Alone => 0u8.hash(h), + Spacing::Joint => 1u8.hash(h), + } + } + TokenTree::Literal(ref lit) => (2u8, lit.to_string()).hash(h), + TokenTree::Ident(ref word) => (3u8, word).hash(h), + } + } +} + +#[cfg(feature = "extra-traits")] +pub struct TokenStreamHelper<'a>(pub &'a TokenStream); + +#[cfg(feature = "extra-traits")] +impl<'a> PartialEq for TokenStreamHelper<'a> { + fn eq(&self, other: &Self) -> bool { + let left = self.0.clone().into_iter().collect::>(); + let right = other.0.clone().into_iter().collect::>(); + if left.len() != right.len() { + return false; + } + for (a, b) in left.into_iter().zip(right) { + if TokenTreeHelper(&a) != TokenTreeHelper(&b) { + return false; + } + } + true + } +} + +#[cfg(feature = "extra-traits")] +impl<'a> Hash for TokenStreamHelper<'a> { + fn hash(&self, state: &mut H) { + let tts = self.0.clone().into_iter().collect::>(); + tts.len().hash(state); + for tt in tts { + TokenTreeHelper(&tt).hash(state); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/ty.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/ty.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/ty.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/ty.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,818 @@ +// Copyright 2018 Syn Developers +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use super::*; +use proc_macro2::TokenStream; +use punctuated::Punctuated; +#[cfg(feature = "extra-traits")] +use std::hash::{Hash, Hasher}; +#[cfg(feature = "extra-traits")] +use tt::TokenStreamHelper; + +ast_enum_of_structs! { + /// The possible types that a Rust value could have. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + /// + /// # Syntax tree enum + /// + /// This type is a [syntax tree enum]. + /// + /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums + pub enum Type { + /// A dynamically sized slice type: `[T]`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Slice(TypeSlice { + pub bracket_token: token::Bracket, + pub elem: Box, + }), + + /// A fixed size array type: `[T; n]`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Array(TypeArray { + pub bracket_token: token::Bracket, + pub elem: Box, + pub semi_token: Token![;], + pub len: Expr, + }), + + /// A raw pointer type: `*const T` or `*mut T`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Ptr(TypePtr { + pub star_token: Token![*], + pub const_token: Option, + pub mutability: Option, + pub elem: Box, + }), + + /// A reference type: `&'a T` or `&'a mut T`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Reference(TypeReference { + pub and_token: Token![&], + pub lifetime: Option, + pub mutability: Option, + pub elem: Box, + }), + + /// A bare function type: `fn(usize) -> bool`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub BareFn(TypeBareFn { + pub unsafety: Option, + pub abi: Option, + pub fn_token: Token![fn], + pub lifetimes: Option, + pub paren_token: token::Paren, + pub inputs: Punctuated, + pub variadic: Option, + pub output: ReturnType, + }), + + /// The never type: `!`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Never(TypeNever { + pub bang_token: Token![!], + }), + + /// A tuple type: `(A, B, C, String)`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Tuple(TypeTuple { + pub paren_token: token::Paren, + pub elems: Punctuated, + }), + + /// A path like `std::slice::Iter`, optionally qualified with a + /// self-type as in ` as SomeTrait>::Associated`. + /// + /// Type arguments are stored in the Path itself. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Path(TypePath { + pub qself: Option, + pub path: Path, + }), + + /// A trait object type `Bound1 + Bound2 + Bound3` where `Bound` is a + /// trait or a lifetime. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub TraitObject(TypeTraitObject { + pub dyn_token: Option, + pub bounds: Punctuated, + }), + + /// An `impl Bound1 + Bound2 + Bound3` type where `Bound` is a trait or + /// a lifetime. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub ImplTrait(TypeImplTrait { + pub impl_token: Token![impl], + pub bounds: Punctuated, + }), + + /// A parenthesized type equivalent to the inner type. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Paren(TypeParen { + pub paren_token: token::Paren, + pub elem: Box, + }), + + /// A type contained within invisible delimiters. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Group(TypeGroup { + pub group_token: token::Group, + pub elem: Box, + }), + + /// Indication that a type should be inferred by the compiler: `_`. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Infer(TypeInfer { + pub underscore_token: Token![_], + }), + + /// A macro in the type position. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Macro(TypeMacro { + pub mac: Macro, + }), + + /// Tokens in type position not interpreted by Syn. + /// + /// *This type is available if Syn is built with the `"derive"` or + /// `"full"` feature.* + pub Verbatim(TypeVerbatim #manual_extra_traits { + pub tts: TokenStream, + }), + } +} + +#[cfg(feature = "extra-traits")] +impl Eq for TypeVerbatim {} + +#[cfg(feature = "extra-traits")] +impl PartialEq for TypeVerbatim { + fn eq(&self, other: &Self) -> bool { + TokenStreamHelper(&self.tts) == TokenStreamHelper(&other.tts) + } +} + +#[cfg(feature = "extra-traits")] +impl Hash for TypeVerbatim { + fn hash(&self, state: &mut H) + where + H: Hasher, + { + TokenStreamHelper(&self.tts).hash(state); + } +} + +ast_struct! { + /// The binary interface of a function: `extern "C"`. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + pub struct Abi { + pub extern_token: Token![extern], + pub name: Option, + } +} + +ast_struct! { + /// An argument in a function type: the `usize` in `fn(usize) -> bool`. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + pub struct BareFnArg { + pub name: Option<(BareFnArgName, Token![:])>, + pub ty: Type, + } +} + +ast_enum! { + /// Name of an argument in a function type: the `n` in `fn(n: usize)`. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + pub enum BareFnArgName { + /// Argument given a name. + Named(Ident), + /// Argument not given a name, matched with `_`. + Wild(Token![_]), + } +} + +ast_enum! { + /// Return type of a function signature. + /// + /// *This type is available if Syn is built with the `"derive"` or `"full"` + /// feature.* + pub enum ReturnType { + /// Return type is not specified. + /// + /// Functions default to `()` and closures default to type inference. + Default, + /// A particular type is returned. + Type(Token![->], Box), + } +} + +#[cfg(feature = "parsing")] +pub mod parsing { + use super::*; + use path::parsing::qpath; + use synom::Synom; + + impl Synom for Type { + named!(parse -> Self, call!(ambig_ty, true)); + + fn description() -> Option<&'static str> { + Some("type") + } + } + + impl Type { + /// In some positions, types may not contain the `+` character, to + /// disambiguate them. For example in the expression `1 as T`, T may not + /// contain a `+` character. + /// + /// This parser does not allow a `+`, while the default parser does. + named!(pub without_plus -> Self, call!(ambig_ty, false)); + } + + named!(ambig_ty(allow_plus: bool) -> Type, alt!( + syn!(TypeGroup) => { Type::Group } + | + // must be before TypeTuple + call!(TypeParen::parse, allow_plus) => { Type::Paren } + | + // must be before TypePath + syn!(TypeMacro) => { Type::Macro } + | + // must be before TypePath + syn!(TypeBareFn) => { Type::BareFn } + | + // must be before TypeTraitObject + call!(TypePath::parse, allow_plus) => { Type::Path } + | + // Don't try parsing more than one trait bound if we aren't allowing it. + // must be before TypeTuple + call!(TypeTraitObject::parse, allow_plus) => { Type::TraitObject } + | + syn!(TypeSlice) => { Type::Slice } + | + syn!(TypeArray) => { Type::Array } + | + syn!(TypePtr) => { Type::Ptr } + | + syn!(TypeReference) => { Type::Reference } + | + syn!(TypeNever) => { Type::Never } + | + syn!(TypeTuple) => { Type::Tuple } + | + syn!(TypeImplTrait) => { Type::ImplTrait } + | + syn!(TypeInfer) => { Type::Infer } + )); + + impl Synom for TypeSlice { + named!(parse -> Self, map!( + brackets!(syn!(Type)), + |(b, ty)| TypeSlice { + elem: Box::new(ty), + bracket_token: b, + } + )); + + fn description() -> Option<&'static str> { + Some("slice type") + } + } + + impl Synom for TypeArray { + named!(parse -> Self, map!( + brackets!(do_parse!( + elem: syn!(Type) >> + semi: punct!(;) >> + len: syn!(Expr) >> + (elem, semi, len) + )), + |(brackets, (elem, semi, len))| { + TypeArray { + elem: Box::new(elem), + len: len, + bracket_token: brackets, + semi_token: semi, + } + } + )); + + fn description() -> Option<&'static str> { + Some("array type") + } + } + + impl Synom for TypePtr { + named!(parse -> Self, do_parse!( + star: punct!(*) >> + mutability: alt!( + keyword!(const) => { |c| (None, Some(c)) } + | + keyword!(mut) => { |m| (Some(m), None) } + ) >> + target: call!(Type::without_plus) >> + (TypePtr { + const_token: mutability.1, + star_token: star, + mutability: mutability.0, + elem: Box::new(target), + }) + )); + + fn description() -> Option<&'static str> { + Some("raw pointer type") + } + } + + impl Synom for TypeReference { + named!(parse -> Self, do_parse!( + amp: punct!(&) >> + life: option!(syn!(Lifetime)) >> + mutability: option!(keyword!(mut)) >> + // & binds tighter than +, so we don't allow + here. + target: call!(Type::without_plus) >> + (TypeReference { + lifetime: life, + mutability: mutability, + elem: Box::new(target), + and_token: amp, + }) + )); + + fn description() -> Option<&'static str> { + Some("reference type") + } + } + + impl Synom for TypeBareFn { + named!(parse -> Self, do_parse!( + lifetimes: option!(syn!(BoundLifetimes)) >> + unsafety: option!(keyword!(unsafe)) >> + abi: option!(syn!(Abi)) >> + fn_: keyword!(fn) >> + parens: parens!(do_parse!( + inputs: call!(Punctuated::parse_terminated) >> + variadic: option!(cond_reduce!(inputs.empty_or_trailing(), punct!(...))) >> + (inputs, variadic) + )) >> + output: call!(ReturnType::without_plus) >> + (TypeBareFn { + unsafety: unsafety, + abi: abi, + lifetimes: lifetimes, + output: output, + variadic: (parens.1).1, + fn_token: fn_, + paren_token: parens.0, + inputs: (parens.1).0, + }) + )); + + fn description() -> Option<&'static str> { + Some("`fn` type") + } + } + + impl Synom for TypeNever { + named!(parse -> Self, map!( + punct!(!), + |b| TypeNever { bang_token: b } + )); + + fn description() -> Option<&'static str> { + Some("never type: `!`") + } + } + + impl Synom for TypeInfer { + named!(parse -> Self, map!( + punct!(_), + |u| TypeInfer { underscore_token: u } + )); + + fn description() -> Option<&'static str> { + Some("inferred type: `_`") + } + } + + impl Synom for TypeTuple { + named!(parse -> Self, do_parse!( + data: parens!(Punctuated::parse_terminated) >> + (TypeTuple { + paren_token: data.0, + elems: data.1, + }) + )); + + fn description() -> Option<&'static str> { + Some("tuple type") + } + } + + impl Synom for TypeMacro { + named!(parse -> Self, map!(syn!(Macro), |mac| TypeMacro { mac: mac })); + + fn description() -> Option<&'static str> { + Some("macro invocation") + } + } + + impl Synom for TypePath { + named!(parse -> Self, call!(Self::parse, false)); + + fn description() -> Option<&'static str> { + Some("type path") + } + } + + impl TypePath { + named!(parse(allow_plus: bool) -> Self, do_parse!( + qpath: qpath >> + parenthesized: option!(cond_reduce!( + qpath.1.segments.last().unwrap().value().arguments.is_empty(), + syn!(ParenthesizedGenericArguments) + )) >> + cond!(allow_plus, not!(punct!(+))) >> + ({ + let (qself, mut path) = qpath; + if let Some(parenthesized) = parenthesized { + let parenthesized = PathArguments::Parenthesized(parenthesized); + path.segments.last_mut().unwrap().value_mut().arguments = parenthesized; + } + TypePath { qself: qself, path: path } + }) + )); + } + + impl ReturnType { + named!(pub without_plus -> Self, call!(Self::parse, false)); + named!(parse(allow_plus: bool) -> Self, alt!( + do_parse!( + arrow: punct!(->) >> + ty: call!(ambig_ty, allow_plus) >> + (ReturnType::Type(arrow, Box::new(ty))) + ) + | + epsilon!() => { |_| ReturnType::Default } + )); + } + + impl Synom for ReturnType { + named!(parse -> Self, call!(Self::parse, true)); + + fn description() -> Option<&'static str> { + Some("return type") + } + } + + impl Synom for TypeTraitObject { + named!(parse -> Self, call!(Self::parse, true)); + + fn description() -> Option<&'static str> { + Some("trait object type") + } + } + + fn at_least_one_type(bounds: &Punctuated) -> bool { + for bound in bounds { + if let TypeParamBound::Trait(_) = *bound { + return true; + } + } + false + } + + impl TypeTraitObject { + named!(pub without_plus -> Self, call!(Self::parse, false)); + + // Only allow multiple trait references if allow_plus is true. + named!(parse(allow_plus: bool) -> Self, do_parse!( + dyn_token: option!(keyword!(dyn)) >> + bounds: alt!( + cond_reduce!(allow_plus, Punctuated::parse_terminated_nonempty) + | + syn!(TypeParamBound) => {|x| { + let mut bounds = Punctuated::new(); + bounds.push_value(x); + bounds + }} + ) >> + // Just lifetimes like `'a + 'b` is not a TraitObject. + cond_reduce!(at_least_one_type(&bounds)) >> + (TypeTraitObject { + dyn_token: dyn_token, + bounds: bounds, + }) + )); + } + + impl Synom for TypeImplTrait { + named!(parse -> Self, do_parse!( + impl_: keyword!(impl) >> + // NOTE: rust-lang/rust#34511 includes discussion about whether or + // not + should be allowed in ImplTrait directly without (). + elem: call!(Punctuated::parse_terminated_nonempty) >> + (TypeImplTrait { + impl_token: impl_, + bounds: elem, + }) + )); + + fn description() -> Option<&'static str> { + Some("`impl Trait` type") + } + } + + impl Synom for TypeGroup { + named!(parse -> Self, do_parse!( + data: grouped!(syn!(Type)) >> + (TypeGroup { + group_token: data.0, + elem: Box::new(data.1), + }) + )); + + fn description() -> Option<&'static str> { + Some("type surrounded by invisible delimiters") + } + } + + impl Synom for TypeParen { + named!(parse -> Self, call!(Self::parse, false)); + + fn description() -> Option<&'static str> { + Some("parenthesized type") + } + } + + impl TypeParen { + named!(parse(allow_plus: bool) -> Self, do_parse!( + data: parens!(syn!(Type)) >> + cond!(allow_plus, not!(punct!(+))) >> + (TypeParen { + paren_token: data.0, + elem: Box::new(data.1), + }) + )); + } + + impl Synom for BareFnArg { + named!(parse -> Self, do_parse!( + name: option!(do_parse!( + name: syn!(BareFnArgName) >> + not!(punct!(::)) >> + colon: punct!(:) >> + (name, colon) + )) >> + ty: syn!(Type) >> + (BareFnArg { + name: name, + ty: ty, + }) + )); + + fn description() -> Option<&'static str> { + Some("function type argument") + } + } + + impl Synom for BareFnArgName { + named!(parse -> Self, alt!( + map!(syn!(Ident), BareFnArgName::Named) + | + map!(punct!(_), BareFnArgName::Wild) + )); + + fn description() -> Option<&'static str> { + Some("function argument name") + } + } + + impl Synom for Abi { + named!(parse -> Self, do_parse!( + extern_: keyword!(extern) >> + name: option!(syn!(LitStr)) >> + (Abi { + extern_token: extern_, + name: name, + }) + )); + + fn description() -> Option<&'static str> { + Some("`extern` ABI qualifier") + } + } +} + +#[cfg(feature = "printing")] +mod printing { + use super::*; + use proc_macro2::TokenStream; + use quote::ToTokens; + + impl ToTokens for TypeSlice { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.bracket_token.surround(tokens, |tokens| { + self.elem.to_tokens(tokens); + }); + } + } + + impl ToTokens for TypeArray { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.bracket_token.surround(tokens, |tokens| { + self.elem.to_tokens(tokens); + self.semi_token.to_tokens(tokens); + self.len.to_tokens(tokens); + }); + } + } + + impl ToTokens for TypePtr { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.star_token.to_tokens(tokens); + match self.mutability { + Some(ref tok) => tok.to_tokens(tokens), + None => { + TokensOrDefault(&self.const_token).to_tokens(tokens); + } + } + self.elem.to_tokens(tokens); + } + } + + impl ToTokens for TypeReference { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.and_token.to_tokens(tokens); + self.lifetime.to_tokens(tokens); + self.mutability.to_tokens(tokens); + self.elem.to_tokens(tokens); + } + } + + impl ToTokens for TypeBareFn { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.lifetimes.to_tokens(tokens); + self.unsafety.to_tokens(tokens); + self.abi.to_tokens(tokens); + self.fn_token.to_tokens(tokens); + self.paren_token.surround(tokens, |tokens| { + self.inputs.to_tokens(tokens); + if let Some(ref variadic) = self.variadic { + if !self.inputs.empty_or_trailing() { + let span = variadic.0[0]; + ::new(span).to_tokens(tokens); + } + variadic.to_tokens(tokens); + } + }); + self.output.to_tokens(tokens); + } + } + + impl ToTokens for TypeNever { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.bang_token.to_tokens(tokens); + } + } + + impl ToTokens for TypeTuple { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.paren_token.surround(tokens, |tokens| { + self.elems.to_tokens(tokens); + }); + } + } + + impl ToTokens for TypePath { + fn to_tokens(&self, tokens: &mut TokenStream) { + PathTokens(&self.qself, &self.path).to_tokens(tokens); + } + } + + impl ToTokens for TypeTraitObject { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.dyn_token.to_tokens(tokens); + self.bounds.to_tokens(tokens); + } + } + + impl ToTokens for TypeImplTrait { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.impl_token.to_tokens(tokens); + self.bounds.to_tokens(tokens); + } + } + + impl ToTokens for TypeGroup { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.group_token.surround(tokens, |tokens| { + self.elem.to_tokens(tokens); + }); + } + } + + impl ToTokens for TypeParen { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.paren_token.surround(tokens, |tokens| { + self.elem.to_tokens(tokens); + }); + } + } + + impl ToTokens for TypeInfer { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.underscore_token.to_tokens(tokens); + } + } + + impl ToTokens for TypeMacro { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.mac.to_tokens(tokens); + } + } + + impl ToTokens for TypeVerbatim { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.tts.to_tokens(tokens); + } + } + + impl ToTokens for ReturnType { + fn to_tokens(&self, tokens: &mut TokenStream) { + match *self { + ReturnType::Default => {} + ReturnType::Type(ref arrow, ref ty) => { + arrow.to_tokens(tokens); + ty.to_tokens(tokens); + } + } + } + } + + impl ToTokens for BareFnArg { + fn to_tokens(&self, tokens: &mut TokenStream) { + if let Some((ref name, ref colon)) = self.name { + name.to_tokens(tokens); + colon.to_tokens(tokens); + } + self.ty.to_tokens(tokens); + } + } + + impl ToTokens for BareFnArgName { + fn to_tokens(&self, tokens: &mut TokenStream) { + match *self { + BareFnArgName::Named(ref t) => t.to_tokens(tokens), + BareFnArgName::Wild(ref t) => t.to_tokens(tokens), + } + } + } + + impl ToTokens for Abi { + fn to_tokens(&self, tokens: &mut TokenStream) { + self.extern_token.to_tokens(tokens); + self.name.to_tokens(tokens); + } + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/verbatim.rs rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/verbatim.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/verbatim.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/syn-0.14.9/src/verbatim.rs 2018-12-05 01:24:26.000000000 +0000 @@ -0,0 +1,20 @@ +use std::ops::Range; + +use buffer::Cursor; +use proc_macro2::TokenStream; +use synom::PResult; + +pub fn grab_cursor(cursor: Cursor) -> PResult { + Ok((cursor, cursor)) +} + +pub fn token_range(range: Range) -> TokenStream { + let mut tts = Vec::new(); + let mut cursor = range.start; + while cursor != range.end { + let (tt, next) = cursor.token_tree().expect("malformed token range"); + tts.push(tt); + cursor = next; + } + tts.into_iter().collect() +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/version_check/.cargo-checksum.json rustc-1.31.0+dfsg1+llvm/src/vendor/version_check/.cargo-checksum.json --- rustc-1.30.0+dfsg1+llvm/src/vendor/version_check/.cargo-checksum.json 2018-10-24 21:38:22.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/version_check/.cargo-checksum.json 2018-12-05 01:24:32.000000000 +0000 @@ -1 +1 @@ -{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"f9b1ca6ae27d1c18215265024629a8960c31379f206d9ed20f64e0b2dcf79805","Cargo.toml":"bb373b313645fa25e9f7f209a3f182ef91b710578df148b7f467c685b8587e38","Cargo.toml.orig":"2403be34a8b06bb52addda10a2efe8539cacd22e280e4add652020431583b3be","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"b7e650f3fce5c53249d1cdc608b54df156a97edd636cf9d23498d0cfe7aec63e","README.md":"8e5c0390f2dd2e9c082ea8feb1539af74f60c536faf6b836b8afd17fe605004c","src/lib.rs":"8d73765fea27c9171502c57707801b4afd3fd355cad087a84f523677d2444978"},"package":"7716c242968ee87e5542f8021178248f267f295a5c4803beae8b8b7fd9bc6051"} \ No newline at end of file +{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".cargo_vcs_info.json":"0b61b4c9e304925b81de6f3c4b9ec9cde6894ebf3ce10654959366b1b0e001cf",".gitignore":"f9b1ca6ae27d1c18215265024629a8960c31379f206d9ed20f64e0b2dcf79805","Cargo.toml":"95aa7965cb8a20e6b196cda8122e9855cc04ac4a42bc93e0616b45605a11bc2b","Cargo.toml.orig":"4dda0c2314098a2a63971a5d15572ea533e73c3f82447ad75cf9b2cd6a55da79","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"b7e650f3fce5c53249d1cdc608b54df156a97edd636cf9d23498d0cfe7aec63e","README.md":"8e5c0390f2dd2e9c082ea8feb1539af74f60c536faf6b836b8afd17fe605004c","src/lib.rs":"100373e52a857267090c78910b7b3f734949dd74092c1caf31f49cc64f8835e7"},"package":"914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"} \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/version_check/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/vendor/version_check/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/vendor/version_check/Cargo.toml 2018-10-24 21:38:22.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/version_check/Cargo.toml 2018-12-05 01:24:32.000000000 +0000 @@ -12,7 +12,7 @@ [package] name = "version_check" -version = "0.1.4" +version = "0.1.5" authors = ["Sergio Benitez "] description = "Tiny crate to check the version of the installed/running rustc." documentation = "https://docs.rs/version_check/" diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/version_check/Cargo.toml.orig rustc-1.31.0+dfsg1+llvm/src/vendor/version_check/Cargo.toml.orig --- rustc-1.30.0+dfsg1+llvm/src/vendor/version_check/Cargo.toml.orig 2018-10-24 21:38:22.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/version_check/Cargo.toml.orig 2018-12-05 01:24:32.000000000 +0000 @@ -1,6 +1,6 @@ [package] name = "version_check" -version = "0.1.4" +version = "0.1.5" authors = ["Sergio Benitez "] description = "Tiny crate to check the version of the installed/running rustc." documentation = "https://docs.rs/version_check/" diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/version_check/.cargo_vcs_info.json rustc-1.31.0+dfsg1+llvm/src/vendor/version_check/.cargo_vcs_info.json --- rustc-1.30.0+dfsg1+llvm/src/vendor/version_check/.cargo_vcs_info.json 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/version_check/.cargo_vcs_info.json 2018-12-05 01:24:32.000000000 +0000 @@ -0,0 +1,5 @@ +{ + "git": { + "sha1": "f2d5df160f2c533852e45ddf6670906f3406a17b" + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/version_check/src/lib.rs rustc-1.31.0+dfsg1+llvm/src/vendor/version_check/src/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/version_check/src/lib.rs 2018-10-24 21:38:22.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/version_check/src/lib.rs 2018-12-05 01:24:32.000000000 +0000 @@ -86,7 +86,8 @@ /// Returns (version, date) as available. fn version_and_date_from_rustc_version(s: &str) -> (Option, Option) { - let mut components = s.split(" "); + let last_line = s.lines().last().unwrap_or(s); + let mut components = last_line.trim().split(" "); let version = components.nth(1); let date = components.nth(1).map(|s| s.trim_right().trim_right_matches(")")); (version.map(|s| s.to_string()), date.map(|s| s.to_string())) @@ -198,10 +199,10 @@ if let Some(mmp) = str_to_mmp($string) { let expected = $x << 32 | $y << 16 | $z; if mmp != expected { - panic!("{} didn't parse as {}.{}.{}.", $string, $x, $y, $z); + panic!("{:?} didn't parse as {}.{}.{}.", $string, $x, $y, $z); } } else { - panic!("{} didn't parse for mmp testing.", $string); + panic!("{:?} didn't parse for mmp testing.", $string); } ) } @@ -211,7 +212,7 @@ if let (Some(version_str), _) = version_and_date_from_rustc_version($s) { check_mmp!(&version_str => ($x, $y, $z)); } else { - panic!("{} didn't parse for version testing.", $s); + panic!("{:?} didn't parse for version testing.", $s); } ) } @@ -242,5 +243,13 @@ check_version!("rustc 1.20.0 (d84693b93 2017-07-09)" => (1, 20, 0)); check_version!("rustc 1.20.0 (2017-07-09)" => (1, 20, 0)); check_version!("rustc 1.20.0-dev (2017-07-09)" => (1, 20, 0)); + + check_version!("warning: invalid logging spec 'warning', ignoring it + rustc 1.30.0-nightly (3bc2ca7e4 2018-09-20)" => (1, 30, 0)); + check_version!("warning: invalid logging spec 'warning', ignoring it\n + rustc 1.30.0-nightly (3bc2ca7e4 2018-09-20)" => (1, 30, 0)); + check_version!("warning: invalid logging spec 'warning', ignoring it + warning: something else went wrong + rustc 1.30.0-nightly (3bc2ca7e4 2018-09-20)" => (1, 30, 0)); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/build.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/build.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/build.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/build.rs 2018-12-05 01:24:41.000000000 +0000 @@ -30,7 +30,7 @@ ("dxgi1_3", &["dxgi", "dxgi1_2", "dxgiformat", "guiddef", "minwindef", "unknwnbase", "windef", "winnt"], &["dxgi"]), ("dxgi1_4", &["basetsd", "dxgi1_2", "dxgi1_3", "dxgiformat", "dxgitype", "guiddef", "minwindef", "unknwnbase", "winnt"], &[]), ("dxgi1_5", &["basetsd", "dxgi", "dxgi1_2", "dxgi1_3", "dxgi1_4", "dxgiformat", "minwindef", "unknwnbase", "winnt"], &[]), - ("dxgi1_6", &["basetsd", "dxgi1_2", "dxgi1_4", "dxgi1_5", "dxgitype", "minwindef", "windef", "winnt"], &[]), + ("dxgi1_6", &["basetsd", "dxgi1_2", "dxgi1_4", "dxgi1_5", "dxgitype", "guiddef", "minwindef", "windef", "winnt"], &[]), ("dxgiformat", &[], &[]), ("dxgitype", &["d3d9types", "dxgiformat", "minwindef"], &[]), ("evntprov", &["basetsd", "guiddef", "minwindef", "winnt"], &["advapi32"]), @@ -43,6 +43,7 @@ ("in6addr", &["minwindef"], &[]), ("inaddr", &["minwindef"], &[]), ("intsafe", &[], &[]), + ("ks", &[], &[]), ("ksmedia", &[], &[]), ("ktmtypes", &["guiddef", "minwindef", "winnt"], &[]), ("lmcons", &["minwindef", "winnt"], &[]), @@ -122,13 +123,14 @@ ("d3d10sdklayers", &[], &[]), ("d3d10shader", &["d3d10", "d3dcommon", "minwindef", "unknwnbase", "winnt"], &[]), ("d3d11", &["basetsd", "d3dcommon", "dxgi", "dxgiformat", "dxgitype", "guiddef", "minwindef", "unknwnbase", "windef", "winnt"], &["d3d11"]), - ("d3d11_1", &[], &[]), - ("d3d11_2", &[], &[]), + ("d3d11_1", &["basetsd", "d3d11", "d3dcommon", "dxgiformat", "dxgitype", "guiddef", "minwindef", "unknwnbase", "winnt"], &[]), + ("d3d11_2", &["basetsd", "d3d11", "d3d11_1", "dxgiformat", "minwindef", "winnt"], &[]), ("d3d11_3", &[], &[]), ("d3d11_4", &[], &[]), ("d3d11on12", &["d3d11", "d3d12", "d3dcommon", "guiddef", "minwindef", "unknwnbase", "winnt"], &["d3d11"]), ("d3d11sdklayers", &["basetsd", "d3d11", "dxgi", "minwindef", "unknwnbase", "winnt"], &[]), ("d3d11shader", &["basetsd", "d3dcommon", "minwindef", "unknwnbase", "winnt"], &[]), + ("d3d11tokenizedprogramformat", &["minwindef"], &[]), ("d3d12", &["basetsd", "d3dcommon", "dxgiformat", "dxgitype", "guiddef", "minwinbase", "minwindef", "unknwnbase", "windef", "winnt"], &["d3d12"]), ("d3d12sdklayers", &["basetsd", "d3d12", "minwindef", "unknwnbase", "winnt"], &[]), ("d3d12shader", &["basetsd", "d3dcommon", "minwindef", "unknwnbase", "winnt"], &[]), @@ -141,6 +143,7 @@ ("datetimeapi", &["minwinbase", "minwindef", "winnt"], &["kernel32"]), ("davclnt", &["minwindef", "winnt"], &["netapi32"]), ("dbghelp", &["basetsd", "guiddef", "minwindef", "vcruntime", "winnt"], &["dbghelp"]), + ("dbt", &["basetsd", "guiddef", "minwindef", "winnt", "winuser"], &[]), ("dcommon", &["basetsd", "dxgiformat", "minwindef", "windef"], &[]), ("dcomp", &["d2d1", "d2d1_1", "d2d1effects", "d2dbasetypes", "d3d9types", "d3dcommon", "dcompanimation", "dcomptypes", "dxgi", "dxgi1_2", "dxgiformat", "guiddef", "minwinbase", "minwindef", "ntdef", "unknwnbase", "windef"], &["dcomp"]), ("dcompanimation", &["ntdef", "unknwnbase"], &[]), @@ -149,6 +152,7 @@ ("ddrawi", &[], &[]), ("ddrawint", &[], &[]), ("debugapi", &["minwinbase", "minwindef", "winnt"], &["kernel32"]), + ("devicetopology", &["guiddef", "minwindef", "unknwnbase", "windef", "winnt", "wtypes"], &[]), ("dinput", &[], &[]), ("dmksctl", &[], &[]), ("dmusicc", &[], &[]), @@ -160,7 +164,7 @@ ("dsound", &["guiddef", "minwindef", "mmsystem", "unknwnbase", "windef", "winerror", "winnt"], &["dsound"]), ("dsrole", &["guiddef", "minwindef", "winnt"], &["netapi32"]), ("dvp", &[], &[]), - ("dwmapi", &["basetsd", "minwindef", "windef", "winnt"], &["dwmapi"]), + ("dwmapi", &["basetsd", "minwindef", "uxtheme", "windef", "winnt"], &["dwmapi"]), ("dwrite", &["basetsd", "d2d1", "dcommon", "guiddef", "minwindef", "unknwnbase", "windef", "winerror", "wingdi", "winnt"], &["dwrite"]), ("dwrite_1", &["basetsd", "dcommon", "dwrite", "minwindef", "winnt"], &[]), ("dwrite_2", &["basetsd", "d3d9types", "dcommon", "dwrite", "dwrite_1", "minwindef", "unknwnbase", "winnt"], &[]), @@ -173,6 +177,7 @@ ("endpointvolume", &["basetsd", "guiddef", "minwindef", "unknwnbase", "winnt"], &[]), ("errhandlingapi", &["basetsd", "minwindef", "winnt"], &["kernel32"]), ("evntcons", &["basetsd", "evntprov", "evntrace", "guiddef", "minwindef", "winnt"], &["advapi32"]), + ("exdisp", &["basetsd", "docobj", "oaidl", "ocidl", "winnt", "wtypes"], &[]), ("fibersapi", &["minwindef", "winnt"], &["kernel32"]), ("fileapi", &["minwinbase", "minwindef", "winnt"], &["kernel32"]), ("gl-gl", &[], &["opengl32"]), @@ -219,16 +224,18 @@ ("namedpipeapi", &["minwinbase", "minwindef", "winnt"], &["advapi32", "kernel32"]), ("namespaceapi", &["minwinbase", "minwindef", "ntdef", "winnt"], &["kernel32"]), ("nb30", &["minwindef", "winnt"], &["netapi32"]), - ("ncrypt", &["basetsd", "sspi"], &["ncrypt"]), + ("ncrypt", &["basetsd", "bcrypt", "minwindef", "winnt"], &["ncrypt"]), ("ntlsa", &["basetsd", "guiddef", "lsalookup", "minwindef", "ntdef", "ntsecapi", "subauth", "winnt"], &["advapi32"]), ("ntsecapi", &["basetsd", "guiddef", "lsalookup", "minwindef", "ntdef", "sspi", "subauth", "winnt"], &["advapi32"]), ("oaidl", &["basetsd", "guiddef", "minwindef", "rpcndr", "unknwnbase", "winnt", "wtypes", "wtypesbase"], &[]), ("objbase", &["combaseapi", "minwindef", "winnt"], &["ole32"]), - ("objidl", &["basetsd", "guiddef", "minwindef", "objidlbase", "unknwnbase", "winnt", "wtypesbase"], &[]), + ("objidl", &["basetsd", "guiddef", "minwindef", "ntdef", "objidlbase", "unknwnbase", "windef", "winnt", "wtypes", "wtypesbase"], &[]), ("objidlbase", &["basetsd", "guiddef", "minwindef", "unknwnbase", "winnt", "wtypesbase"], &[]), ("ocidl", &["guiddef", "minwindef", "ntdef", "oaidl", "unknwnbase", "wtypes", "wtypesbase"], &[]), + ("ole2", &["minwindef", "oleidl", "windef", "winnt"], &["ole32"]), ("oleauto", &["basetsd", "minwinbase", "minwindef", "oaidl", "winnt", "wtypes", "wtypesbase"], &["oleaut32"]), ("olectl", &["winerror", "winnt"], &[]), + ("oleidl", &["minwindef", "ntdef", "objidl", "unknwnbase", "windef"], &[]), ("opmapi", &["basetsd", "d3d9", "d3d9types", "dxva2api", "guiddef", "minwindef", "unknwnbase", "windef", "winnt"], &["dxva2"]), ("pdh", &["basetsd", "guiddef", "minwindef", "windef", "winnt"], &["pdh"]), ("perflib", &["basetsd", "guiddef", "minwinbase", "minwindef", "winnt"], &["advapi32"]), @@ -292,12 +299,13 @@ ("userenv", &["minwindef", "winnt", "winreg"], &["userenv"]), ("usp10", &["minwindef", "ntdef", "windef", "winerror", "wingdi", "winnt"], &["usp10"]), ("utilapiset", &["minwindef", "ntdef"], &["kernel32"]), + ("uxtheme", &["commctrl", "minwindef", "windef", "wingdi", "winnt"], &["uxtheme"]), ("vsbackup", &["guiddef", "minwindef", "unknwnbase", "vss", "vswriter", "winnt", "wtypes"], &["vssapi"]), ("vss", &["guiddef", "minwindef", "unknwnbase", "winnt"], &[]), ("vsserror", &["winnt"], &[]), ("vswriter", &["minwindef", "unknwnbase", "vss", "winnt", "wtypes"], &[]), ("wct", &["basetsd", "guiddef", "minwindef", "winnt"], &["advapi32"]), - ("werapi", &["minwindef", "winnt"], &["kernel32"]), + ("werapi", &["minwindef", "winnt"], &["kernel32", "wer"]), ("winbase", &["basetsd", "cfgmgr32", "fileapi", "guiddef", "libloaderapi", "minwinbase", "minwindef", "processthreadsapi", "vadefs", "windef", "winnt"], &["kernel32"]), ("wincodec", &["basetsd", "d2d1", "d2d1_1", "dcommon", "dxgiformat", "dxgitype", "guiddef", "minwindef", "ntdef", "objidlbase", "ocidl", "propidl", "unknwnbase", "windef", "winerror", "winnt"], &["windowscodecs"]), ("wincodecsdk", &["guiddef", "minwindef", "oaidl", "objidl", "objidlbase", "ocidl", "propidl", "unknwnbase", "wincodec", "winnt", "wtypes"], &["ole32", "oleaut32", "windowscodecs"]), diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/.cargo-checksum.json rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/.cargo-checksum.json --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/.cargo-checksum.json 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/.cargo-checksum.json 2018-12-05 01:24:42.000000000 +0000 @@ -1 +1 @@ -{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Cargo.toml":"653c4c200e8797919407b68ead9ab3599cd1c315f696e1f4cf59da756fa85832","Cargo.toml.orig":"6e534d7c39cfcb5151ecf1a3d06931ed75c92edd0e4f1defce342b94b456fc88","LICENSE-APACHE":"b40930bbcf80744c86c46a12bc9da056641d722716c378f5659b9e555ef833e1","LICENSE-MIT":"5b19674a1db628a475850a131956ed49521b744e3dda8f5a94141f9aba681219","README.md":"2fd4c0142b8d6f03e838255ae0eb111cd003d61cbf435d532d501bb4578d0fae","build.rs":"b0a1aae160b468699c83f62abd5510fd276459591224959f360eb9d38384f7e1","src/lib.rs":"ff1ba38871a371c1cbc2a958239904809bb00b34537a2c5d7e0fa8f36ae8b4bf","src/macros.rs":"70497c980cf8f6425afe3a1420cbc252ff0603f184306dd674b6ac5289c30acb","src/shared/basetsd.rs":"99856b585ba67a0e1cc0c6ce6f4a1ce3d43a47974bcfa9341ac7fbe0d3f66a0b","src/shared/bcrypt.rs":"c4af763c7ab609d00a5c0131dbeeaf81363320f7872f7f978c96e46e5709f963","src/shared/bugcodes.rs":"17ce3b68a8110846a4ce1ec1447944e44ba8e852098714176dfde8cb55d8c3b3","src/shared/cderr.rs":"23fafc514089bc50fa7dd7843a21c3ac3bf956f20430177eac2adabdff1dc47a","src/shared/cfg.rs":"8863b6a485e99956c03ebd5b921890877d059d2260db786aebeefb09b69b5409","src/shared/d3d9.rs":"d006692019459d28e1d62537f2f031b3999b56494cc70e1824c5f7fc48a793f2","src/shared/d3d9caps.rs":"191d7e6a120049eb510f268b178a192ac26b851373e7e9d5dee06112eaa7532f","src/shared/d3d9types.rs":"24c2aa38144e83b0089a7adde2b3dc2b93c103e520313d38cbad1444463cbd0b","src/shared/dcomptypes.rs":"24105520e49bff0249a7ce9a77a7cb9776f4a3977019ecc915d09a2fe187411a","src/shared/devguid.rs":"c7306502b0a9b7cf74382b85d87cb010356088b163a62cd19af3e8371ea315e7","src/shared/devpkey.rs":"df9d46b1494754f3b48d62866af443cd9f7b49409fa7ccc749a011d66346df9d","src/shared/devpropdef.rs":"b30c0e0984dc72e35223754cceb81a433fb21847d1a99ef7580c691e7c46c1e0","src/shared/dinputd.rs":"d3b6509875f1b65326faa59ec301ffba275d5c2ba7932937cbc388feecca6355","src/shared/dxgi.rs":"a2bb4f072ecdf9aea063ebedca39dbb53b1da8b7f173a1bbc000194e4d8757db","src/shared/dxgi1_2.rs":"65189e09fad5d4f8492d6e0f73f6fa3c6f7c8a90a4aadc30e69252a18f220c80","src/shared/dxgi1_3.rs":"c855e2bfcfd37c0573d171ad9229c4bade07e6b4032addf72def238181a63f10","src/shared/dxgi1_4.rs":"d8b9bd67f4b4908da6f41acc82133ef150a8e1b1ef7317d28087d9554f0b2339","src/shared/dxgi1_5.rs":"30f49ac821998f746f1f4df8397daa6d9d80a2be3fee94bac82f5e427aa84579","src/shared/dxgi1_6.rs":"e8a0634fcbaf47683ea19f958c3553f33a29dbb556f2a982708bbd9f31490c4a","src/shared/dxgiformat.rs":"2052f3be936634aca5eb969fe53b9b24ce49e4a20d10ae20db5b4290d53d1bcc","src/shared/dxgitype.rs":"38d402cbf838ac6a27c5ecf03c7527400c7736e1756d11398533f570db0a4d1a","src/shared/evntprov.rs":"d9fcf3cf701abd9839aa6b45a567912b0154b2e9cc1397380ac0c0e4e76f180e","src/shared/evntrace.rs":"6a04e0e855d7371059a020123e738a3e2a4af015598e30918a4e66a92ce5b097","src/shared/guiddef.rs":"66aaf8c071b578d0d8576c1cbe89b858d590dc5436ed3c47f17cdf4f2b73b9f5","src/shared/hidclass.rs":"374185e80183ff79a3c0797daeca3af94f4e2bacb579ad79ba60bec5d76215ab","src/shared/hidpi.rs":"9b4d6b5cb4c198c5d47b233a8e896acd04a42fcf37f632999970ed0850f2b8f4","src/shared/hidsdi.rs":"206ac6152e920628398f2d0f3e3778007ac421a8ed09b85aabe1fb6712d7b0d4","src/shared/hidusage.rs":"7133890999bd672ad502a8f1d87c347a3e3f7624480fad7101f3b83322d6208c","src/shared/in6addr.rs":"927dacfbe1b76450673771f7f1c43cb7fe8c7cf3b808bf448b5d1a3c50defb9d","src/shared/inaddr.rs":"5162a678484065a012447b5e9182ef3b297e9f0e2f10c3fcef52d3fc77b72e7f","src/shared/intsafe.rs":"d0730302935824a06be422274f9018d5a4f9c7753f7d7a8b81489efc0e8afd70","src/shared/ksmedia.rs":"2ab9f9791b2e46b5e9c84cd81c8b8c86bf97f9981711be3441e996f84e1782ac","src/shared/ktmtypes.rs":"bbdaa6b33b732e3d162cf248f6c6a95a99301091bf29eec51126411c2bed5621","src/shared/lmcons.rs":"0d1efca38ea4e7f2a84b3309c27c453e4f1f87b1889443e39b27409616a04410","src/shared/minwindef.rs":"82f59281e5761597ac032fc017daa78fd55cb259694644228c2256480d6ac338","src/shared/mmreg.rs":"61de7fcf55ddb536aec4d7bfe2322d36f2e56ba6d9a8d84c35a96d034c919819","src/shared/mod.rs":"798b1ade3f58865a9864817934cd9e8026c8f95716155c70d897f5966156aa9c","src/shared/mstcpip.rs":"4db1b2a9ddcecec6cd51da22bab57d1595a1c58958616511a056f9608fd79869","src/shared/ntddscsi.rs":"caddc023577f97aeb004176dc2713606b057eae52a764f59f4ebcd3e7fed7a2b","src/shared/ntddser.rs":"3c49b36f7928557453637a69736b80529dd02eea47149f419a2edff28db5711d","src/shared/ntdef.rs":"fc50df4331dfdc2c7622ee63d457e93c2f587f9e15d4da317c29363925970bde","src/shared/ntstatus.rs":"2bc2fa4a8e57056222ec77491590a85a9d536d755d2786780ffa156c2f4b1481","src/shared/qos.rs":"0a9f83173195068a9e0a021eafa2d79964ceff2739b248842feeb707322f95ad","src/shared/rpc.rs":"eeec3424555f01232818fd381e772f1fd9694e04bdb26f90552c0bae9841ee1e","src/shared/rpcdce.rs":"ea3bba0248cd51c36dc3a8b4292e964cffdc94700f1230e04d5efc507d7fdd2d","src/shared/rpcndr.rs":"c91e74ab64d935c15b2712f1572c71db99d94036cd7796d543f5ccf730745ee7","src/shared/sddl.rs":"8eea1b33e4f45db129850b9b44fd26aafae11cbce9eb2b7dcbbcb0c7128c7aa6","src/shared/sspi.rs":"217ea7c629d35af3d715bee6f20f1faae2d04c3d86d43ce33db134e2957481ae","src/shared/stralign.rs":"ec74ee5c0a62de19d823a0e48106cba3848d0c086e54806f64d786c821e67d21","src/shared/transportsettingcommon.rs":"ad62b70f178b3c0525a5da5f18322326b12be812aecb3c75e03232eca4f2e077","src/shared/tvout.rs":"e30c0876a2ed1a91a533e7361f22175023864bd4d4b543bf92093ae758b07ca3","src/shared/usb.rs":"4d58ece0cfc7263a09d57d716a07d846b202bb5cd720439a1f10a1454a9fa05e","src/shared/usbiodef.rs":"ecc1bc9aa8c45197457e1b0447e73813c3546c73ed9fa6edf141c62242dbbac4","src/shared/usbspec.rs":"5e11da75acb9f2246651fc6aa0d56fb06ed5fcafd72d2592c864fcc3b561cb6c","src/shared/windef.rs":"96f38d39b0fd6f6364be1a64ed167b299c0f856bb8505eda485e0392336997a3","src/shared/windowsx.rs":"feca97a15762c381300db6dfa69630cef6c0bb6f4830fa3341be38ed5aee838e","src/shared/winerror.rs":"1ca025e81f40cc1263115d1efa037a0c4b80f2a67b9f473c6489a0725f5fa180","src/shared/winusbio.rs":"c1c6da5151682b1bdf0c8f3080258f8181ff4fb5470d586e2ec58e8825e33a36","src/shared/wmistr.rs":"828b13923db418743c1fc8f5e9cb1a148a77d4ee4e1f8680d420792c20be334d","src/shared/wnnc.rs":"274de0229564512d3217082bbd73dc3f2f64bbbe1dd441af16633d0f48d1ea3a","src/shared/ws2def.rs":"eb2e953dbc086acd9f18f835ae994266c5d648637209d3ebf042165509c23d27","src/shared/ws2ipdef.rs":"82ec54204d3dc9952c1285f3562621392a1aebd159f3cad6a2f817b99d5b44c0","src/shared/wtypes.rs":"0b4bc5dc98f65ec00fcdaa62c2efa6120839c801d806d7a5c5e0509495be76f2","src/shared/wtypesbase.rs":"595b91044a9b12d0fc53ed6f4b629521fa4a0f48940eda372076b0c34edf0011","src/um/accctrl.rs":"66aa0198be3e584c85ae7446c1d311a6669b36b24c98fc0e1206c46bc12f99a4","src/um/aclapi.rs":"3c0f53cb156a9a044d3636c436f4a908aab3ac15159b03cbbe662bde15cf0899","src/um/appmgmt.rs":"650dcf28cb56da23ed7e35f736901f7f6c628447ced712576e915e5df7aea03b","src/um/audioclient.rs":"87423a9d08536b109ee8512c589c0c00ebc06e99c35ca2c67e22f3309d39be8e","src/um/audiosessiontypes.rs":"1b055c75524449f7b290c0dadb53518ffc19d1948b99e676c6be6c4146ba17e4","src/um/avrt.rs":"12eafc929b90f8b77cf01cefee9219324e43f25a2270bff1adad23f3572ea9ae","src/um/bits.rs":"9c95cc5f7bf6f23aa8165e087f1a8e5ef77a2fcf67c46facdd46175d04f5ac0c","src/um/bits10_1.rs":"63652261494b61eda47b8ad992c81e3da4ded10a6ca3378f856261fe3ed63c36","src/um/bits1_5.rs":"b82341ec893ff71dc28dcf2bef9142e908c4a72562b011e2bef7301a3a93ca17","src/um/bits2_0.rs":"c083d84445bec03828b3917e3b28011bd52898bf53b513fb9a15a050d2273922","src/um/bits2_5.rs":"0a47843f067ddadf903099ce214f237872ddd51fac4f358a7252395ea4d1216b","src/um/bits3_0.rs":"19a4869afaaffba4673a151f2285246a0ae88728b6889a166c2c09f732b130b1","src/um/bits4_0.rs":"b9c7f4bc8a9988c689b0b0db71170792d0d41baa36b837192d910f841d71c794","src/um/bits5_0.rs":"b2877a2a3f03869a2431520f048be56eb80176fdf9de8c6e4b47214336b32492","src/um/bitscfg.rs":"68416d5d35b995c15681246a7cc673290b8b33902e6add688f870031fddff693","src/um/bitsmsg.rs":"06f7ad83542b30341f232bf6fc218001f6dacf5fec848314eddb9aece57db7d1","src/um/cfgmgr32.rs":"04757ab57327211a235ff4de4b25d08acff024ed3bb29c8830d23c7a5dd8193c","src/um/cguid.rs":"677e800cdc5fa8fc168dede555b1efd2a750052cafb7ab8276b4d568e1c01f21","src/um/combaseapi.rs":"7681eb93196f1bad57dd4ecebd09424fe17b2756b477b935265ce23a5441e86e","src/um/coml2api.rs":"9d2d9d211120d3ea584c3dabc4c30d3e238135b43de68136c1f371d39496656f","src/um/commapi.rs":"011e41c05decaec9aca1f80615261ad7b6298cb709c5dc6c5a7c9bf1731faffe","src/um/commctrl.rs":"4b28f88fa18e2a57624109da57e5bbe1419f602475f2144f847debe59160c86e","src/um/commdlg.rs":"8d501adbf6b143b9c0ee574203b51f6e76201c66462767868497ecda28d22a58","src/um/commoncontrols.rs":"5e6a8d450e8649d301d31e8ea10721fadc7c2a93757ef5d284977f17c18e5ed4","src/um/consoleapi.rs":"94c81d472d3b295b592f1d4f35fccbdda6e17890a05563d0974800a5432261cf","src/um/corsym.rs":"426c36e0b8d9bff003c8221b6bf97489ec705e4e30ea6bac7d5c0375d9cdbc55","src/um/d2d1.rs":"3484ef55281b7da84eb0e837f91a0cafeb0c63acb0360e56dded4428a319a313","src/um/d2d1_1.rs":"fd1c1be2d1aa199232e2c1d1a00c9eb3ef607382aeb46e637692bf73dff9b37f","src/um/d2d1_2.rs":"c65a1edc4f0f9137345cc015829c80adff1a4b9566a7d32eec11cc02521fc69c","src/um/d2d1_3.rs":"ea1aafb7cdd1ad16c3612e975b4cc5ce64a2787f08cd0f716c85c2495c94fdf2","src/um/d2d1effectauthor.rs":"03461591cd2a20fc92a34313b5f9054293d4ea61c3563e33a7af5d2974cb0788","src/um/d2d1effects.rs":"7690360c6a0f4749aec71a602b0b3e905b9f8ecfce47a9ab4d7f1e12e0ec8327","src/um/d2d1effects_1.rs":"ea08450655b94679d41f263dc083df1ff6ca8437f8e796c8d79a513d6e110da9","src/um/d2d1effects_2.rs":"49477c515fa8fadbc6e3eccd5ba2cb7c85c4eb1d228a2bced08c32535614cf4b","src/um/d2d1svg.rs":"d1cc370b6304c20f8fd3321a6e6232c3bca05fcd8dc283ce3f3dc1d9434a4920","src/um/d2dbasetypes.rs":"ee2bceb96466aae77bff23b74d3daeca77a3335bda5ecc4e4c96a9375205a2ba","src/um/d3d.rs":"330569cb4fb4ec02d1d5dd2532071ecc7abe52b9a3e4e584a16506a4345ad28b","src/um/d3d10.rs":"fb1f897edf2183baca997e630273f37cab944d665185e49bcca188576bba97ba","src/um/d3d10_1.rs":"928b097741a4fe136a5dde080f1c017b57ab220051f37596f390b82b2ab31125","src/um/d3d10_1shader.rs":"fe44c5fe7dae6a306e146904a1887d7d6475e324616a773210c73189fd6628ff","src/um/d3d10effect.rs":"e80e7e03c73f3d75351ec4702202d47b4923f5157eae7cd0032b984b0f3b70d8","src/um/d3d10misc.rs":"e6c5ea73e6bebf870364eae9dd21c58c98d51121b00241e8cabf4a54d0801d0d","src/um/d3d10sdklayers.rs":"b8dc7f1cffc609129f468d8e09f104127ab9cd14c1e960fe8bf081efaace89df","src/um/d3d10shader.rs":"aeac67df2bc3030b78b520270edbdf7c88868e0b69cdb7dd568dd34d4b53ee95","src/um/d3d11.rs":"2faa706945c8190d43f121314057ef34cee8a8e521535fcfaae606ffb69116a9","src/um/d3d11_1.rs":"a600581bcbb15784eddeff5bab4b19a00dc5745d5aa939aeedc4bb48fa8c7659","src/um/d3d11_2.rs":"c530723f9267b44f25c1cf903d633a3440cab763b22b2bc18c9695f37c304880","src/um/d3d11_3.rs":"f5d9fa55a43e19fe3586a3e9238103c58e5fd34c6e7ccdc1a05cf9fd18c1b025","src/um/d3d11_4.rs":"e770c8058d7120dc5c49244df8b53c5bd4fd2b2614c33402eeb91dc90511c0fe","src/um/d3d11on12.rs":"6d5fce57d92cbb200527af592925865d88433b78504ec4c6b5a43b9f8ec9fdf6","src/um/d3d11sdklayers.rs":"872af4ad36b48c509719d29e58677c31cbed285aa3cfcbc25906299f343ab0e0","src/um/d3d11shader.rs":"08c2179817999cba7da419ffc04b5cc431589f4bf5c7d9bb8e9301f063e4c38b","src/um/d3d12.rs":"54446d8b3b61428c28319a615411da45825d70409d8292103d511aeb65ac1f2e","src/um/d3d12sdklayers.rs":"f9436bab026a6193df5cca63288e5cba4f5e1cee210ea44905b0be0f30241d5c","src/um/d3d12shader.rs":"5fa55c73c12ec83de58519e7aa1bfe6375868b698ed1b83c380403f550c719fe","src/um/d3dcommon.rs":"7cf2b64bd954e1f93f7e3a5bfb8fa05902ea9cef1ad401e41e16ee841631fbf2","src/um/d3dcompiler.rs":"5fa5f430d07cff934e47b173c976c6c7a1e5dddec243003a220c7608c747461e","src/um/d3dcsx.rs":"1a859c5ecff97c768cec6b07f380b7d95461a841028f549a83b6878403125521","src/um/d3dx10core.rs":"693dafd6755452d282d4f2739b0ca23f7ef4c91c7ded1a422e81dc9f45910781","src/um/d3dx10math.rs":"eb45ac39eac6459eef2942eb652e7b7876b7c9a3593a43d81e7a3ae929d468fe","src/um/d3dx10mesh.rs":"ed4e70afa27dda8ebdf7b69692f639b6c86d9121cbf0cf80fd7b4b0fbb6a8938","src/um/datetimeapi.rs":"e280d15f02b260e0b6c3ccea3ee2f989ef93bc954a098c66903c4ce8a5f0ad92","src/um/davclnt.rs":"e282bbf42babaed01e6bdb0f20ea3ddb59395b594da5f70b6d61706756d86c09","src/um/dbghelp.rs":"0802044ac232f3f3b6eda5d4922ac9959190ecbf014dac00b301fd5a332aae26","src/um/dcommon.rs":"00a4d0f24d9d615146bb7e93760e6298e0be95b61c8b96a362bb1a46659fab33","src/um/dcomp.rs":"3a8daf77acfc5c615ddd11f2c2b83795136ace427ae586a817bfb7af087229ec","src/um/dcompanimation.rs":"5eebf243c1988e282b13e3edf615622b359b045dbb8dcc49df3e44b3b3405258","src/um/dde.rs":"ac010bf6cc6c3c72b2e13f5c62aeabd1c5ff0fa087babafa3323f01b5719b1de","src/um/ddraw.rs":"d9485ed844c2b4576bf5ef91ac4d012e505032559434f6e71f94fb856a979d9c","src/um/ddrawi.rs":"3b5db96b3cc668261223fd57e033a6d65f02ef1c7120faa76a365212529cb693","src/um/ddrawint.rs":"4de466a4f12d11c8a5463bc045a78cd9bdcae6ac71c5a200cc97e9618bec5d67","src/um/debugapi.rs":"2fc48ef68740503afd7411e2a58ae7e27691ee7a8e7fc5de96b17693ca7c82f1","src/um/dinput.rs":"5d61e3dd3e3743ea31fc594518733a114c5f1e3ac1eebd61b5f0282d63cc5456","src/um/dmksctl.rs":"8b7f64a5f1320168a9e047af93b8e4608b3c8ad985e60287c0d1a3f8f68e39f0","src/um/dmusicc.rs":"c04ebba40f56a73f357371980dca6ddca5ec3ed5b7ab99ddc4ea3a5cddb85fab","src/um/docobj.rs":"3a5eca71ac71dbc3dd3090fa5f297e5702d8d7a5c381b2db5fc85c16c2e6c6df","src/um/documenttarget.rs":"1ce701a5ad7a0a62f3f65059d6f53e231ccf303d1600b5ecd469a84ff8ca283c","src/um/dpa_dsa.rs":"d8e2a95660e517d487250c7200d6309667177799dea5173b3f72fdffa134824a","src/um/dpapi.rs":"d905df74cebad05b55cd649d0e7cd991dcaca417d98f455470077708253cbbfb","src/um/dsgetdc.rs":"10a39c907d4f14fb26c6e243905ee9ae3ec4cf13e70214cbdae5747f95a9e1c7","src/um/dsound.rs":"a0863c647b60423b87afdb11cf660cce27223c836d15e15109d46ce6e861fade","src/um/dsrole.rs":"14fbdc0d01d63bd95422300cda3a03a633b5fc04e2624e02a93afcc9024eb8a1","src/um/dvp.rs":"d1eb0e0ba08a455d65563e687753795118ce535727d61175703c435e91e6f4bd","src/um/dwmapi.rs":"c191c9c14a25109d50495356abeb832a3b2da3c49b7ab45db161fb227df4aa35","src/um/dwrite.rs":"70323c9959272610426ed5494531e0340a2e6be2867f7bc236b12729846ac6a2","src/um/dwrite_1.rs":"e3bc9ff0edae57e8bb46c2a4a66428777709638dbb921d468143e61dac42344b","src/um/dwrite_2.rs":"18fc9de6626b5f0cf47cf5ae31eb65e63ecf158e714bb1079dbe3bd87cc30e11","src/um/dwrite_3.rs":"d68a9ba403102c0b0a1acf16f9239589a2dd02779c0312a3b7e044635a3b17e9","src/um/dxdiag.rs":"6e02c1a1b174b774f2d02cc0007b240ecbb551159c7221a81780db05caba9af2","src/um/dxfile.rs":"97a87d87ceff6c8aa2c1624c3ee891a7adc0914e1b0750d3df05ace6d20eeccc","src/um/dxgidebug.rs":"ea1aa8d9ddfbc9f87019908bb7ac35d022a6c7a667de73adba9b51d8c9a3f617","src/um/dxva2api.rs":"7ad1f734e7900b844985f0acb876e1dca162eab448c10ddefd0cf84c2dd155d0","src/um/dxvahd.rs":"89193df159458e49fa65acebbefc5becca6e291fc6a32c3223d387acb23e4d55","src/um/endpointvolume.rs":"860c50bd2d41c5aa156c0f6a87fca67a4bc40ad9ba5c40e45115b18c2ec7b470","src/um/errhandlingapi.rs":"5336cf6d97cd1278b783d861319a0521302788dd929b1dca0d8c404ac3bb4346","src/um/evntcons.rs":"1785f557277bd359f9385b333e612d11d6adbb65dc825dd1d99547dfb81c3a6c","src/um/fibersapi.rs":"2240d53df44c605e09cc7b36c91ffe860c5af0bf834943aec3c6879564711205","src/um/fileapi.rs":"89fe72af0c76dfa48dd7898af98d32fe5c456c58112835db3105b9e07f5b1605","src/um/gl/gl.rs":"9add9a323d87613a4586f4c688599b864cbf3d862d3d70ed0c18dc0da041d8bf","src/um/gl/mod.rs":"3e3fb3789ce9bfe7692fe2939121f65887f71005d5b0b3b1775f131c9b69222f","src/um/handleapi.rs":"3c3ba7150e50fe603f0a1e14f67777a5ba2d7221a4b66ab1df84566dcb07eb81","src/um/heapapi.rs":"7284592bea7212d0554dc7ed63b0888786f2ae3af4df59ac1e4b697c85edb922","src/um/highlevelmonitorconfigurationapi.rs":"eec1fc57db896d9cd72c09b4cb3281c51d5163fc3f84169358c5cd9b0ccc302c","src/um/http.rs":"755e53f3ef8f7bd0f3cbbcd619ea303980688343451f3ca36df71cedf2dcd3d4","src/um/imm.rs":"001827cd91d5c81765f80b3a8b4d96b7e94a5deff492274d5709af05920a70d5","src/um/interlockedapi.rs":"e9d2e12f2a2076f4cf26e19ba29d871f3a652b1acfef44670c05be7255103d2c","src/um/ioapiset.rs":"f4f99ecb0230020c6cf169e2bd987db085af8a6d25307d32196a0e08e5c6c66d","src/um/jobapi.rs":"e12153c40a82c3acb889d8b2f3d2ccf5cc1de40b2e4396d7e1bbff0d3594043f","src/um/jobapi2.rs":"5e919f05a84149b7dea9057a8d583b5c35cda9fd36432675260cd15c65ab5be9","src/um/knownfolders.rs":"02de8af90f560227c1cf1067efe1c40b4c7f308f02dda427651bd6fe29ffe511","src/um/ktmw32.rs":"43a6387979a79ac365667e73b9659d6ce608bc4440cc23aec5748fd2bf3af646","src/um/libloaderapi.rs":"130ff661c6ec51c16c4e5ac4111f01732d4767e5f9f9a286339d885742e1d3c1","src/um/lmaccess.rs":"03a4c77c728600d00edca52cfb35d4acfce6aa83c19fd64ce8a57de7dff6c66e","src/um/lmalert.rs":"f4510d6a8524f1950979500cee86aded86a46afb5249cb227e99a61b79f9d1d6","src/um/lmapibuf.rs":"3e761bb15d8c7e83683c1138624ce7606053ba6bc9077f4c2a87545d3efa56fd","src/um/lmat.rs":"fac23bdfcc071052de2fdb1e1cd6ac164cc4e35d502af709b3b634844f7ac449","src/um/lmdfs.rs":"228ab0745f456aa8e11a630014907eb124e1380377456701fa99353c763df4e8","src/um/lmerrlog.rs":"73d51724f07316ec0c8ace1febfdc0bd5958d637d253f79f36aa5331ec2bbbdf","src/um/lmjoin.rs":"9dafd3c9317c566e628824cb6d16d806fb95fff5813ced1948cea8882752832a","src/um/lmmsg.rs":"1b3566b3a1595dcdfb471304719af37f739b4223bc6c08744e3e7f7aaa14b597","src/um/lmremutl.rs":"4401f095e6db493b56ebc3fe2daa69317bd59e361bb71f1eb3cf6b672ba21cbe","src/um/lmrepl.rs":"4090bb897cdb9991c417e53850e333191527cea4d06258a497a3a5b1a448593f","src/um/lmserver.rs":"c1a123fb6ec29d743e4e7a42e9b28f450f2230234559592b6ea2b21709810e27","src/um/lmshare.rs":"13b15ba3eb252fe9e2a20d97b38849eb4b617a177cbc70c88d5ab210a031a58a","src/um/lmstats.rs":"3a114d58d9c564414421437285acab7f2262bcebb78517bb6e9b7b36c34ab36b","src/um/lmsvc.rs":"f3dce4607017e785c60142b55631a4f25854434fb9e50a11eb4dc37599e125cb","src/um/lmuse.rs":"6a3dbf4ebdef73dffed0dde131e52d7afcc2675e1537c01872dff43f6f5147ed","src/um/lmwksta.rs":"de6964159b6c08f0e5e57559653027cd210ddaeade7cad9e5e2af3dbc8c15835","src/um/lowlevelmonitorconfigurationapi.rs":"b860615f855a40091d903a08a166d4659ce31493a895647695fb3bf5f70e7fb4","src/um/lsalookup.rs":"6c3549cc763d4c0fb72c1af8b6be0c5434a55e7d2127c4b7f48db532778c0ddb","src/um/memoryapi.rs":"ac65f2ea269607480e06921fa47fb3c64dce617c9f5f8cb97535dddd7b6e102f","src/um/minschannel.rs":"86c4b7ea3012a879dfe66e54aade2cffb787918cfee06f7e4498c42b14b88127","src/um/minwinbase.rs":"89f02e72a7d639f440a3e13c4326e2c0c1fbbfe3915483d5ba8500bd5513cde8","src/um/mmdeviceapi.rs":"a2879ff838d85b277a34cfc76aa9d83a3d235371db6254e712ffb1d67e8d6c13","src/um/mmeapi.rs":"955a2d66ff240db263be0b9054b27897228f6997e61c8daa2b701bc977d288d6","src/um/mmsystem.rs":"31188f292f50c41bf99e0b91b5dd4637c209541b3e86eb24d8bd240b3154260c","src/um/mod.rs":"e0c140c91f9f327896da740209933fe505dc232dddb7c840233d23336059bf60","src/um/msaatext.rs":"f7a04ed96e0767a435856bb84bb835ef31617a30e49a6157e4a51c99dccecaea","src/um/mscat.rs":"c3ceae9899811610a4b2f15a80eb2e41eae566262d26ad6c68f2f95d1785a1a2","src/um/mschapp.rs":"f432c8a1d67b521e8e031c7662d7ad394d3f0383f6c44f09d3fbbddc5c208e5b","src/um/mssip.rs":"0ec2cda4bc2cb2cc1c6ca83ff0a63ee6c85b731f6b90206909a3473c9084e79c","src/um/namedpipeapi.rs":"f324b25161e2f2ae592ee59607bdc49af9815c001a6ec4d2a79b0c4e7e73df51","src/um/namespaceapi.rs":"30c2a4e7b05c1426af95eb36216d9ac9c1219ee64f472b999286027a27a6e8fa","src/um/nb30.rs":"c16c9fceab92a52a5587a22760cbbff0b2bb8564dac1f9528f51eced3fcb8b69","src/um/ncrypt.rs":"d3efcc1526a29e14ad14dd114a64c848a3cadb948ecb138707b8f2c5528ef742","src/um/ntlsa.rs":"d06e3ac75c16f5e6c0447aff02161e499f52e0e20db749f66b1198766857af9c","src/um/ntsecapi.rs":"937d2e4c95c4cef64b0759feae734662b6268298306e608e8b0d9e6aeb8d336d","src/um/oaidl.rs":"21e15244d1ca7afbe427b8f80839db1e1820363f03a367c8c60f40e173a8a6fc","src/um/objbase.rs":"17297f27028765c3e40c5b47a83cbb083723259956a064344e2b681816c65d87","src/um/objidl.rs":"4ebe979aa0a42aa5b4dcf5d10c4d684b10e546ef039c5094db984b897117bf0c","src/um/objidlbase.rs":"3cb828436c7603301886a5c97a32547ae4fb787df40e5ecb79e40a01e75b3648","src/um/ocidl.rs":"f1b42dc297b6e267c5411f92b626072e4f4efb8de2b6b53054f6aaf15938874b","src/um/oleauto.rs":"bae109c6c013f5d3a62c553b43e0cbe3ba6906946927d5f497124df94e03e726","src/um/olectl.rs":"29ca0c1151fb7e19eee5839ad0960a052bbe94c770299ab1f2ca72bd518b2cd5","src/um/opmapi.rs":"b10c513bb24a7e43af80b0526090ae23dbfc74fb02fde9de720eeee6a8bf69ba","src/um/pdh.rs":"086285ae0108b0cf43223352222f2c85437bc44d59acc6f515ecc9e44d561fb7","src/um/perflib.rs":"5b0b9363ca8f0cea2a0b704d6e78246d120aedeb8c8cd035027aab39e0eeef33","src/um/physicalmonitorenumerationapi.rs":"41e56c449742934c636f2a7890bcc158c2b269175fbb4bca365bb91b535b98fd","src/um/playsoundapi.rs":"1b20c049d6c6762c7ad046131c4f2ff7038112149ca43ab95c63c149f6f84639","src/um/powerbase.rs":"6e3409c14abd9827439c736907b8a172f405181a6f803233dd260d12dc3ecc33","src/um/powersetting.rs":"a80e15926ace650cfbe28e294545a00672b6e3ab3d4c04d54dbec8a8f54bab1d","src/um/powrprof.rs":"41f649be8d3b449e8bcc0dd50704d4b2b62d26cf821b609c198673974528cbb0","src/um/processenv.rs":"82d4d1d41b2254da608703a060f641a2ee08a43ededdad827137285bac68c549","src/um/processsnapshot.rs":"f1a4370e674017afdf9653df653efbb42ccab4cc1b6886e3988a053da8587bca","src/um/processthreadsapi.rs":"ee86fd3323a19896d3aa050d2b1de184cf0df7087d9d557fd1d3ff095ad2eb58","src/um/processtopologyapi.rs":"e01d180d97b07885a034d2bd0286c38bee0e7f74452b786495a498f9145ba410","src/um/profileapi.rs":"8e2b70fff8d54996afa70dbff1d0feea56bf0ae6c3c872eeb76a08d5317d0a06","src/um/propidl.rs":"7595aa6e58ed166b21f550ebbe7b50cc45f847cd4d5685cf2c72492137c987c0","src/um/propkeydef.rs":"a96c903b81af6155ab032aaf1629e5f74dffb1567b38428c5da0c15456b26117","src/um/propsys.rs":"092d119997a4febbbe8ea3985230d05aa209c3e21a37c4ec88a6b448ecfa654f","src/um/prsht.rs":"e8171b46042b169095c6ab2f6ef0fc34c9912e6d53fdddfd083c2dbc80296436","src/um/psapi.rs":"242ad484c2d2c178bbc37e806c5e077c5dff6e6ed7ac1fd9cc196e3c9003aef0","src/um/realtimeapiset.rs":"9411d06bbbab05eb9700bda4dfd7355b34fe834d4616812d81bde24107a4d0ec","src/um/reason.rs":"d03dea55f23a29fcd2bc76202ddee5d42860f591830294d296fde52c05086ca5","src/um/restartmanager.rs":"dbafff8065b89b2fa8d634a64abfa19d5441d338ebe09030ff0a9241d6bc81c0","src/um/restrictederrorinfo.rs":"b9db66ace1034701632037cc2a8466e5f7206724d5674decbdb4b952f8b15beb","src/um/rmxfguid.rs":"7a683ff98d3eaaacf4746c2f4cd1b97cca4a025d6060d24ea4ad0c4b12a31edb","src/um/sapi.rs":"cdb2d4394a1668393a61a910c24bdf0c8b77b4bb0a736d3a9ce3d9a52cc61df7","src/um/sapi51.rs":"64ee2af4d66e5095e7609349b58eea61c77e6e2aa75e2eff2c1c4e630b74a87b","src/um/sapi53.rs":"48849e3e0bab4d186c5cda86d3aa029543da5c5390fc981147310a9c4949fa81","src/um/sapiddk.rs":"ccd29c6ef0acd5a824b4958a6c8a66c57b2706681ef545fffba0dd6d2babad14","src/um/sapiddk51.rs":"362133f09f6f02c53401de2216de549f9944c96c6f0dd51845c4eceda32e2f36","src/um/schannel.rs":"9ba7437b82cbac1fe6ad0dc82ef58b1ec3484bbbaeac5b4a2fe12f56c46e5d13","src/um/securityappcontainer.rs":"933038334262d99c3f8f4160358758f16acdce8b95387f8fea449ce7749cd940","src/um/securitybaseapi.rs":"855e8aef2eff7da05cc5672b711a6c12eb670cf33f69fc7a00df4fd3c54ec490","src/um/servprov.rs":"7edf50368c727efde70880ec230c7a8fde4afc2cfb3c2893a2c4d1ba319627b8","src/um/setupapi.rs":"9807107f00decc94fab7ba49fe4984a48f9b87e4162415a0c2693c0cde8da27a","src/um/shellapi.rs":"92190c1c806e7eee876c13a4bb9279a41c8b31d55f1e903f3e2e5c42315c6fea","src/um/shellscalingapi.rs":"2cded3fba4480871733ba141b0a1a790e883d77e9f144ea34135215c89a40cf8","src/um/shlobj.rs":"bd604c083a0e8331049f9ac1200a03cffa2744d63d9d470c4aa94400482d4d44","src/um/shobjidl.rs":"1dbf4ea1d5469bc80702e28149a6ce200824b69169edb9ae0cc6ad05de6d536e","src/um/shobjidl_core.rs":"c4a92b054c9cf3217ce23c2dcbe8255ef19e25c77eaaf6a62d600072e8dba670","src/um/shtypes.rs":"360bffc27d51e0414736f53dbc3703b4a8419440412d310f07fc053c0c70e72a","src/um/spapidef.rs":"575b0632cb7ef628cf86130936c31f8a35c6f6269fb57d2a4cbd5bcdef539a1c","src/um/sporder.rs":"64d365a773a864fbf6789ff8156214ed669baee6b3cd90819c2d2b36324248a1","src/um/sql.rs":"abff2a2fb5f08be9f565eb03a65244043720348829f04b98656a89686e807216","src/um/sqlext.rs":"9545e0390ffde6ab4a620e0800265b399144cd4fc8bd94258041c1af9375573a","src/um/sqltypes.rs":"77c6c920023498820e51ede76942e9628c544a6024cfce5ea484b8995e664ba2","src/um/sqlucode.rs":"758a8e581fe6f0a960bef2a478a4047a494ee18995f1e7dfa34282ee2b0d18f5","src/um/sspi.rs":"0855fd38942aef19f613702506329c8103df99721b5e1bf6d508434a7cc24920","src/um/stringapiset.rs":"585f3051bec63cd82909b7edc10c76bb7bf92596c90f33792de28eabbe57ca8f","src/um/strmif.rs":"302d470618e6e5225c5168838228ba9773295e87c8864d6ad2c148cf28c7c3ed","src/um/subauth.rs":"203278f313af5f60dd6eef4cb3475988d16197521baf61882892ecd5b13c05da","src/um/synchapi.rs":"a53963ba8b51b2b8ac91039d91b7f5879b900910f913cf879e31177ead04039c","src/um/sysinfoapi.rs":"37ea5a4b3b120da417d2e1585210cdfd09b1280c3b546e3d53bd2975cbb5a4f8","src/um/systemtopologyapi.rs":"362c015c1799605fb5bcd28de53357805206f6fd4a4eb713e1c0bbc61d11ddba","src/um/textstor.rs":"3c2980ae947ea25a8299f7bc670ca73ec3c9a13a3ab7884c96b55575113d28c7","src/um/threadpoolapiset.rs":"0a96fd29497b2ece591d5a65a74a70ec40b444bf6e128fed8a03041460ea699a","src/um/threadpoollegacyapiset.rs":"d63f2aa225ba0587b567af78eb2b5a8a196f6ab878d97f9b022968cfba5e9141","src/um/timeapi.rs":"8c493994fb39f8e22f951b12d4b03d6287597b640150d5e605dc3b51a3237db9","src/um/timezoneapi.rs":"6cfb38964a156f77a94c51380a3c0e986c39aee3e0f85c1c773a34bf057147f4","src/um/tlhelp32.rs":"493508be1c33e426bf778067dc8650c49135dff39be776d2aa0488744009baa3","src/um/unknwnbase.rs":"071fc08d973b4167b5350bc73d28af7f872f803973c0ef10db2075c9980006ef","src/um/urlhist.rs":"d3cab3bd881fd21ac2b07066e30abb5e4733c700159ed3611846e2d4cbc324a3","src/um/urlmon.rs":"c56f1f5af41e8ee7c7c02f553327b2e5ac39f3abc2f7dc44c0cedbbe6fbfaa3f","src/um/userenv.rs":"3ed27bb291217613d32179deb6275526fb7647ef667cacd7cfc2fdb2f7b5f42c","src/um/usp10.rs":"38abde24499aacdc229ec9581dc9000dc1bfb4f566b9c5b535adabc2b86300f0","src/um/utilapiset.rs":"f02a26c4a3c908bb0c80ffb29a667dc66b7b9ffa29d48ef190dbeda03a0cd78a","src/um/vsbackup.rs":"2181be0a43723a4cd1b0532ddf86bac784ddc4365aba17e6888e6fb8958b11ac","src/um/vss.rs":"a1f80c29d7099fa5fb588144908eaa4fa47e7311d1feca84e2fbf4bd64d11418","src/um/vsserror.rs":"1b43c769bc7377405ad286e0fa1442e02d0d7ee025ea949a04161653499d24fb","src/um/vswriter.rs":"4578dd1e785eac6324779507ab10307a6e8558a44b1980eb925df0419f7552a8","src/um/wct.rs":"25ca4451b22306f0b22c22007bb5366500e38bfe9e9321d15d66405526b0f18c","src/um/werapi.rs":"4e3563a6da5fccb6b05fb9ea4b01a50f2444d8290056e30ef040917079cfed00","src/um/winbase.rs":"50b34e4783dc8014236d6934a532050334a0daeaebbb7e5c2d5de4ffedc40ff9","src/um/wincodec.rs":"aae6b424042ce05136660aa075ef113efc8bc428e02fea7bb08213e8b95f2a2c","src/um/wincodecsdk.rs":"0e3215ea2347925b09412e631aacf4e071a451ff0999af0cb9d03cfd113e8f77","src/um/wincon.rs":"9aef7bf262c9b9ed0ec85e6ca97c25327d8f97df04d83aea5d8c9ae4b6d50604","src/um/wincred.rs":"9376ae548ca883523c0f6f60813cbca30e3145e9fb04934067d3927b99e1f741","src/um/wincrypt.rs":"5a14682178100e7886dcb1553d3a3a239500e697b09eecdc549ec96b88e2c181","src/um/windowsceip.rs":"cfc2062daac6a9195690af64bd817fb41f086206c5091539da29d6e51a3a00c6","src/um/winefs.rs":"5072c32e71b40a4b11f00b6aa61537ea28d0a41e42ee8e029760ee5e493c664f","src/um/winevt.rs":"29f85bb49424efa7ac921cb10f2da4b77e4cfe863ca2fe17026137dc5dc2ca8d","src/um/wingdi.rs":"351d4325426f5bce4effd527f5131bc7c81229b7a55a49d8ad0f5b3ad93295b6","src/um/winhttp.rs":"f163b3b7ef893b6d769fd3886bba182972dd886674af382174ad0c96c774f54e","src/um/wininet.rs":"c96ff6e03d1602b50422ab2847f28c6e4ab80bb3f992d2e6a4e87c20ee17d83d","src/um/winineti.rs":"8624f54b40da0ceb7949b43f8eb54e3e07ca59f5b805328de2b9aa030adb341d","src/um/winioctl.rs":"2dd66814f6203188f6ea1bc1bb7a376cfa1bbb33eccbcbb1ddff5b97c05cbc26","src/um/winnetwk.rs":"bf3c503f6e6d99d8640d66102679522ffda0ac918022f0873dae8bf3fb837ba0","src/um/winnls.rs":"bdea7ae691328e1fa8ab6cc479b5c612c6542ced215870993a6498baaea301aa","src/um/winnt.rs":"299cc3e87286f47a09ef229ec1732f7dfc54bc705329375f07274fda3c2e062d","src/um/winreg.rs":"f7fda9bfa992566453b3f6651d18545924a1e81191540700216aa856e2fb0650","src/um/winsafer.rs":"3a732415ca489dfe5f9aeb402d9af0fc36c0e655db0ca489851ca3d0d49f3b78","src/um/winscard.rs":"0fe23a54544c530838774f7c03708b2d375a3678fbf2f0390e6abddd128a3f33","src/um/winsmcrd.rs":"328de1e80ae94550590f11e000734d463b311190022953a770ae32dad365105b","src/um/winsock2.rs":"3ecedee15dae16920c39b880f32d5d39686651e6b232496c8e10cd32ce9aa81f","src/um/winspool.rs":"8ca9532933aa6bb35a1fa3ec7609a12bd5db82fde49fdd6f1d9aea61479df131","src/um/winsvc.rs":"d4b81710303d152f316939e81c9c606c82de5ac2b1f881d7dee8ca38d4dbb72b","src/um/winusb.rs":"6e223e0916aaac8ce08ae21c328c38c042f193aefbd3ee56b325a467c9941da0","src/um/winuser.rs":"6ac60bebf21f66a506b96a059267552dc05c3d2da919b85070b1290275a4a08a","src/um/winver.rs":"c0437e334c919489b02c7e14e0aedf64ece4ef1ad80569cc99f4e126c8c8d287","src/um/wow64apiset.rs":"42f0fbea817164c78133c014821486f2e312fcb79060f922435a60fdebfb07f3","src/um/ws2spi.rs":"79a2cceb67b4e632ee890000d8e2c00f2d578ab895af6d80d5df96883136ece9","src/um/ws2tcpip.rs":"ec7d0af8a43fb608e827e52b98937339359ffb9fdd47dcf5f9f3c4c086145527","src/um/xinput.rs":"5e55915c432e4b8de8cf489d35d774e9f3e259cfd3bbd9a09e3271cd78a2e00a","src/vc/excpt.rs":"c1000ba67ad7dc36a00433dadcc20633fba6b1a7306fb1e59e60a32369fe22d0","src/vc/limits.rs":"1421607eee3fd422ed26d8d764b09de271791f5223909c757ac53ed3a69dee4a","src/vc/mod.rs":"cb61848f0bcee5c96ebf2a6c3a69eebc31d84d29c108b0664d104f9c040e3aa2","src/vc/vadefs.rs":"3dc2f47dc3db9f6ff0e3c5ce5dc1487b031094240cb00d8ff194e333c959492e","src/vc/vcruntime.rs":"a9e21c05716dbbfeed5a17918e7b742103a80ca9923fcda3871859c0e863606e","src/winrt/activation.rs":"d3839c4c9f9fed955e64d87ee7e43a0e56b9a225061c2342350387e696ca771e","src/winrt/hstring.rs":"a1cfcb0e752360f56145382bd850938df4c63d00da9d0f1608bd104e2cba5bae","src/winrt/inspectable.rs":"7252d0813a1f3f734a8cb7134a6bf1a91518966bca3f57a35fbb3c447b513a9f","src/winrt/mod.rs":"13530a7c2b7bebc529d2c12666551d0fe4d30f0f653eedc9f38ddc833daea05f","src/winrt/roapi.rs":"0959be9cd87aefc2edd56a78201e332c535ddd36b3b93ef9668b8904d50f3909","src/winrt/robuffer.rs":"6c974c04c3c20784058753d8a4d6a640bd2f2d52f644249ffaed6886e12ec241","src/winrt/roerrorapi.rs":"90c1e113dc54121a72957b9b64dc3592eb688fc91015a03a04edffad4e62813e","src/winrt/winstring.rs":"a3875b317bd598040f98deb4838f5dbfb38b40f3eac0d450debc9084971f1386"},"package":"773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd"} \ No newline at end of file +{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".cargo_vcs_info.json":"1131534d7c50bd6fd26d898a7c15f0bd76ce9f1b1bf82a3fb104d54ee542d690","Cargo.toml":"8fe71fe24e0871d8f8d9017437a62294a5bc15af0c7b91f329e45c24f559f5c6","Cargo.toml.orig":"35b46f0936d8b9a25210599a089422e8d9f3e677626c39cf25f677aca5b25845","LICENSE-APACHE":"b40930bbcf80744c86c46a12bc9da056641d722716c378f5659b9e555ef833e1","LICENSE-MIT":"ce7bc3499fee93d5022ef430d5e4201e79a6d9154f3974e42f41349f0569e09b","README.md":"2e56258b8dc251147ea20d320a1dfa742ee82bf0c77343ee1486d1f7293d9433","build.rs":"30fde3f2ead4646ad9c01932a55f7c208d2443e91d7c819ef69bc25b7ef62d85","src/lib.rs":"901d757f46ebc728d06357106ddb5ada2c7baba97b3d44d5808b3bbde75cc6de","src/macros.rs":"f862510f303c9ee3477e16b770e17f5efaff3d81140dcf9c5641c1807c39946f","src/shared/basetsd.rs":"99856b585ba67a0e1cc0c6ce6f4a1ce3d43a47974bcfa9341ac7fbe0d3f66a0b","src/shared/bcrypt.rs":"c4af763c7ab609d00a5c0131dbeeaf81363320f7872f7f978c96e46e5709f963","src/shared/bugcodes.rs":"17ce3b68a8110846a4ce1ec1447944e44ba8e852098714176dfde8cb55d8c3b3","src/shared/cderr.rs":"23fafc514089bc50fa7dd7843a21c3ac3bf956f20430177eac2adabdff1dc47a","src/shared/cfg.rs":"8863b6a485e99956c03ebd5b921890877d059d2260db786aebeefb09b69b5409","src/shared/d3d9.rs":"1ce6dbea9705f5f5523d0a77fb7fd18915957ad4b0c1a0d8fe8850f895770516","src/shared/d3d9caps.rs":"191d7e6a120049eb510f268b178a192ac26b851373e7e9d5dee06112eaa7532f","src/shared/d3d9types.rs":"025fe770e98576054cd75c83cc6929a832831ab50a5768bd3420572a6de23f2e","src/shared/dcomptypes.rs":"24105520e49bff0249a7ce9a77a7cb9776f4a3977019ecc915d09a2fe187411a","src/shared/devguid.rs":"c7306502b0a9b7cf74382b85d87cb010356088b163a62cd19af3e8371ea315e7","src/shared/devpkey.rs":"df9d46b1494754f3b48d62866af443cd9f7b49409fa7ccc749a011d66346df9d","src/shared/devpropdef.rs":"b30c0e0984dc72e35223754cceb81a433fb21847d1a99ef7580c691e7c46c1e0","src/shared/dinputd.rs":"d3b6509875f1b65326faa59ec301ffba275d5c2ba7932937cbc388feecca6355","src/shared/dxgi.rs":"3ff787b1e9634b7c3ca2aefc82414596546d636c70499df0b0a35d2678c2f00f","src/shared/dxgi1_2.rs":"9bf580c31bca78c477a9d4f0ab7a94422150c8fefa4e55426e33d8d89b17c276","src/shared/dxgi1_3.rs":"ef50aec5663a85ba947cf660a2658d521e09fcbf60a57bf048341103a431767d","src/shared/dxgi1_4.rs":"459751cc2b5778571cb6d50a754fec88c29f6423a9d96d008c018330e1b51338","src/shared/dxgi1_5.rs":"2a4791a15eb6110ae17c454f9d24ce4607db893b1494b0e740d1aa65f1bdc483","src/shared/dxgi1_6.rs":"9e18900b36725b353a6ca20c6cea8892b31c85613ae6e22eef233ee1d4ba7198","src/shared/dxgiformat.rs":"2052f3be936634aca5eb969fe53b9b24ce49e4a20d10ae20db5b4290d53d1bcc","src/shared/dxgitype.rs":"38d402cbf838ac6a27c5ecf03c7527400c7736e1756d11398533f570db0a4d1a","src/shared/evntprov.rs":"d9fcf3cf701abd9839aa6b45a567912b0154b2e9cc1397380ac0c0e4e76f180e","src/shared/evntrace.rs":"158f489ec7b2130f5f01351cb2ba8f497345196c793e6caad37236085dc50833","src/shared/guiddef.rs":"66aaf8c071b578d0d8576c1cbe89b858d590dc5436ed3c47f17cdf4f2b73b9f5","src/shared/hidclass.rs":"374185e80183ff79a3c0797daeca3af94f4e2bacb579ad79ba60bec5d76215ab","src/shared/hidpi.rs":"9b4d6b5cb4c198c5d47b233a8e896acd04a42fcf37f632999970ed0850f2b8f4","src/shared/hidsdi.rs":"206ac6152e920628398f2d0f3e3778007ac421a8ed09b85aabe1fb6712d7b0d4","src/shared/hidusage.rs":"7133890999bd672ad502a8f1d87c347a3e3f7624480fad7101f3b83322d6208c","src/shared/in6addr.rs":"927dacfbe1b76450673771f7f1c43cb7fe8c7cf3b808bf448b5d1a3c50defb9d","src/shared/inaddr.rs":"5162a678484065a012447b5e9182ef3b297e9f0e2f10c3fcef52d3fc77b72e7f","src/shared/intsafe.rs":"d0730302935824a06be422274f9018d5a4f9c7753f7d7a8b81489efc0e8afd70","src/shared/ks.rs":"8a2b5b4415f217e62ec9e3c735b06dc39b91ca254d385ab1ae3999ebc93aa092","src/shared/ksmedia.rs":"91ed284e2bc794543d94d0508a57edbab9b9a1e514ffd8df903999340c6b0e3c","src/shared/ktmtypes.rs":"bbdaa6b33b732e3d162cf248f6c6a95a99301091bf29eec51126411c2bed5621","src/shared/lmcons.rs":"0d1efca38ea4e7f2a84b3309c27c453e4f1f87b1889443e39b27409616a04410","src/shared/minwindef.rs":"f33ad709f41e78e40113a1bb1b88a4abeafafcac88a1efd49e6ab55306bf0296","src/shared/mmreg.rs":"61de7fcf55ddb536aec4d7bfe2322d36f2e56ba6d9a8d84c35a96d034c919819","src/shared/mod.rs":"221f9a24eaa9d26998ac17953f5ea293180377ecf76bde35e129f09eb530d5a2","src/shared/mstcpip.rs":"58c41a8cf6c5f403fd0adad4e7a8a693978bd6c55b7c4f1b317a7d9f3f9e234e","src/shared/ntddscsi.rs":"e1e0e5161894deb1c791b639cc036faeb61d6308cb2e3a9577eb2c2902102d60","src/shared/ntddser.rs":"3c49b36f7928557453637a69736b80529dd02eea47149f419a2edff28db5711d","src/shared/ntdef.rs":"fc50df4331dfdc2c7622ee63d457e93c2f587f9e15d4da317c29363925970bde","src/shared/ntstatus.rs":"2bc2fa4a8e57056222ec77491590a85a9d536d755d2786780ffa156c2f4b1481","src/shared/qos.rs":"0a9f83173195068a9e0a021eafa2d79964ceff2739b248842feeb707322f95ad","src/shared/rpc.rs":"c1c7777e17d02791b49533aa33b712323cb97ded0395c345730971372fa10769","src/shared/rpcdce.rs":"a8ea45131b63d115b3628218a3812dcecdc52e1b8635285bcf99b7418054d7ca","src/shared/rpcndr.rs":"c91e74ab64d935c15b2712f1572c71db99d94036cd7796d543f5ccf730745ee7","src/shared/sddl.rs":"8eea1b33e4f45db129850b9b44fd26aafae11cbce9eb2b7dcbbcb0c7128c7aa6","src/shared/sspi.rs":"96c156efe84906647d34ff0acb25cc0fc7b691a5d1e684f638c31075cd976911","src/shared/stralign.rs":"ec74ee5c0a62de19d823a0e48106cba3848d0c086e54806f64d786c821e67d21","src/shared/transportsettingcommon.rs":"ad62b70f178b3c0525a5da5f18322326b12be812aecb3c75e03232eca4f2e077","src/shared/tvout.rs":"e30c0876a2ed1a91a533e7361f22175023864bd4d4b543bf92093ae758b07ca3","src/shared/usb.rs":"4d58ece0cfc7263a09d57d716a07d846b202bb5cd720439a1f10a1454a9fa05e","src/shared/usbiodef.rs":"ecc1bc9aa8c45197457e1b0447e73813c3546c73ed9fa6edf141c62242dbbac4","src/shared/usbspec.rs":"5e11da75acb9f2246651fc6aa0d56fb06ed5fcafd72d2592c864fcc3b561cb6c","src/shared/windef.rs":"ac0ae42d0da6747e31e7fa2099a55470cea52403137090983ede1909d720d296","src/shared/windowsx.rs":"feca97a15762c381300db6dfa69630cef6c0bb6f4830fa3341be38ed5aee838e","src/shared/winerror.rs":"1ca025e81f40cc1263115d1efa037a0c4b80f2a67b9f473c6489a0725f5fa180","src/shared/winusbio.rs":"c1c6da5151682b1bdf0c8f3080258f8181ff4fb5470d586e2ec58e8825e33a36","src/shared/wmistr.rs":"828b13923db418743c1fc8f5e9cb1a148a77d4ee4e1f8680d420792c20be334d","src/shared/wnnc.rs":"795f937c8883b3cf653d7b7fc018ef0b54fd9a3d8b3f52f78e1b80881f4b2df0","src/shared/ws2def.rs":"eb2e953dbc086acd9f18f835ae994266c5d648637209d3ebf042165509c23d27","src/shared/ws2ipdef.rs":"2dc179c0018f1f6156343835ee2840a1a2d60afd59f62403f1070a9a776da9d4","src/shared/wtypes.rs":"6236e984a865e9e3727516be95f708075b9a913cee519bdb6bf9803254759217","src/shared/wtypesbase.rs":"595b91044a9b12d0fc53ed6f4b629521fa4a0f48940eda372076b0c34edf0011","src/um/accctrl.rs":"66aa0198be3e584c85ae7446c1d311a6669b36b24c98fc0e1206c46bc12f99a4","src/um/aclapi.rs":"3c0f53cb156a9a044d3636c436f4a908aab3ac15159b03cbbe662bde15cf0899","src/um/appmgmt.rs":"650dcf28cb56da23ed7e35f736901f7f6c628447ced712576e915e5df7aea03b","src/um/audioclient.rs":"87423a9d08536b109ee8512c589c0c00ebc06e99c35ca2c67e22f3309d39be8e","src/um/audiosessiontypes.rs":"1b055c75524449f7b290c0dadb53518ffc19d1948b99e676c6be6c4146ba17e4","src/um/avrt.rs":"12eafc929b90f8b77cf01cefee9219324e43f25a2270bff1adad23f3572ea9ae","src/um/bits.rs":"9c95cc5f7bf6f23aa8165e087f1a8e5ef77a2fcf67c46facdd46175d04f5ac0c","src/um/bits10_1.rs":"63652261494b61eda47b8ad992c81e3da4ded10a6ca3378f856261fe3ed63c36","src/um/bits1_5.rs":"b82341ec893ff71dc28dcf2bef9142e908c4a72562b011e2bef7301a3a93ca17","src/um/bits2_0.rs":"c083d84445bec03828b3917e3b28011bd52898bf53b513fb9a15a050d2273922","src/um/bits2_5.rs":"0a47843f067ddadf903099ce214f237872ddd51fac4f358a7252395ea4d1216b","src/um/bits3_0.rs":"19a4869afaaffba4673a151f2285246a0ae88728b6889a166c2c09f732b130b1","src/um/bits4_0.rs":"b9c7f4bc8a9988c689b0b0db71170792d0d41baa36b837192d910f841d71c794","src/um/bits5_0.rs":"b2877a2a3f03869a2431520f048be56eb80176fdf9de8c6e4b47214336b32492","src/um/bitscfg.rs":"68416d5d35b995c15681246a7cc673290b8b33902e6add688f870031fddff693","src/um/bitsmsg.rs":"06f7ad83542b30341f232bf6fc218001f6dacf5fec848314eddb9aece57db7d1","src/um/cfgmgr32.rs":"e36ac0925e6f47a6973f562240b9781330712fdbc0e34eb96dc34d47fbf908c7","src/um/cguid.rs":"677e800cdc5fa8fc168dede555b1efd2a750052cafb7ab8276b4d568e1c01f21","src/um/combaseapi.rs":"fb4274c3d31e77adea4e82ca48475a8f6cd3b20e8154eeb15fd73cc7ac1a77dd","src/um/coml2api.rs":"9d2d9d211120d3ea584c3dabc4c30d3e238135b43de68136c1f371d39496656f","src/um/commapi.rs":"1792eaa4f96fbdbd176eb54139688894e4f11d8a61f9896ed2e08e52b982fe03","src/um/commctrl.rs":"63cd191940875f56b733a0c2c35ac79e6392d649cae55e81a74043ba95a42c78","src/um/commdlg.rs":"c0bcdd429820a8e4c0cb4be1582c92ae94002395301afb7866b4a1ee38ecc803","src/um/commoncontrols.rs":"5e6a8d450e8649d301d31e8ea10721fadc7c2a93757ef5d284977f17c18e5ed4","src/um/consoleapi.rs":"94c81d472d3b295b592f1d4f35fccbdda6e17890a05563d0974800a5432261cf","src/um/corsym.rs":"3c9a63914a7497b46c6401cc012be2f2ff606a8f4df3b67efe623bf1c8e2f725","src/um/d2d1.rs":"3484ef55281b7da84eb0e837f91a0cafeb0c63acb0360e56dded4428a319a313","src/um/d2d1_1.rs":"3f9e39760eadc65af3ad220f15eec33559058afcca28e41b0d0a6e0e67c5b5cd","src/um/d2d1_2.rs":"c65a1edc4f0f9137345cc015829c80adff1a4b9566a7d32eec11cc02521fc69c","src/um/d2d1_3.rs":"ea1aafb7cdd1ad16c3612e975b4cc5ce64a2787f08cd0f716c85c2495c94fdf2","src/um/d2d1effectauthor.rs":"03461591cd2a20fc92a34313b5f9054293d4ea61c3563e33a7af5d2974cb0788","src/um/d2d1effects.rs":"7690360c6a0f4749aec71a602b0b3e905b9f8ecfce47a9ab4d7f1e12e0ec8327","src/um/d2d1effects_1.rs":"ea08450655b94679d41f263dc083df1ff6ca8437f8e796c8d79a513d6e110da9","src/um/d2d1effects_2.rs":"49477c515fa8fadbc6e3eccd5ba2cb7c85c4eb1d228a2bced08c32535614cf4b","src/um/d2d1svg.rs":"d1cc370b6304c20f8fd3321a6e6232c3bca05fcd8dc283ce3f3dc1d9434a4920","src/um/d2dbasetypes.rs":"ee2bceb96466aae77bff23b74d3daeca77a3335bda5ecc4e4c96a9375205a2ba","src/um/d3d.rs":"330569cb4fb4ec02d1d5dd2532071ecc7abe52b9a3e4e584a16506a4345ad28b","src/um/d3d10.rs":"fb1f897edf2183baca997e630273f37cab944d665185e49bcca188576bba97ba","src/um/d3d10_1.rs":"928b097741a4fe136a5dde080f1c017b57ab220051f37596f390b82b2ab31125","src/um/d3d10_1shader.rs":"fe44c5fe7dae6a306e146904a1887d7d6475e324616a773210c73189fd6628ff","src/um/d3d10effect.rs":"e80e7e03c73f3d75351ec4702202d47b4923f5157eae7cd0032b984b0f3b70d8","src/um/d3d10misc.rs":"e6c5ea73e6bebf870364eae9dd21c58c98d51121b00241e8cabf4a54d0801d0d","src/um/d3d10sdklayers.rs":"b8dc7f1cffc609129f468d8e09f104127ab9cd14c1e960fe8bf081efaace89df","src/um/d3d10shader.rs":"aeac67df2bc3030b78b520270edbdf7c88868e0b69cdb7dd568dd34d4b53ee95","src/um/d3d11.rs":"c0b817e41f97dbf5961f3a0c9c7b99edb8d8db0a34bcd82528ba791d74cfbc43","src/um/d3d11_1.rs":"6aa7a0a080e1b824efe3bd0e7e8f33d552e475c6536c7cfb515d604729c8e7e8","src/um/d3d11_2.rs":"0c85d56a5d8e1516484f8cfe03c253d60a8d5075e0b6bb34b0584e85215424f3","src/um/d3d11_3.rs":"f5d9fa55a43e19fe3586a3e9238103c58e5fd34c6e7ccdc1a05cf9fd18c1b025","src/um/d3d11_4.rs":"e770c8058d7120dc5c49244df8b53c5bd4fd2b2614c33402eeb91dc90511c0fe","src/um/d3d11on12.rs":"6d5fce57d92cbb200527af592925865d88433b78504ec4c6b5a43b9f8ec9fdf6","src/um/d3d11sdklayers.rs":"2fd441db12b58480fb3738bcbc615b1fdc9512c556aef1d2b3bb31cb99da30c6","src/um/d3d11shader.rs":"08c2179817999cba7da419ffc04b5cc431589f4bf5c7d9bb8e9301f063e4c38b","src/um/d3d11tokenizedprogramformat.rs":"b20d02f167b2ff4760568d4437db174ea26fd7e13faefab0ac5070c5dc50e186","src/um/d3d12.rs":"2f0477b8da4a996eca53f1c5f721f64ede016b8cc31bb1f56729470cb613ba27","src/um/d3d12sdklayers.rs":"f9436bab026a6193df5cca63288e5cba4f5e1cee210ea44905b0be0f30241d5c","src/um/d3d12shader.rs":"d939fb8ebd41f45fc0f317808c75af87435e56a628b9edb0d55d31db07761c6a","src/um/d3dcommon.rs":"e0f3c13f131d62f36c316bad020d5f0905f1bf7570da9fd68d080ee1d2f40446","src/um/d3dcompiler.rs":"5fa5f430d07cff934e47b173c976c6c7a1e5dddec243003a220c7608c747461e","src/um/d3dcsx.rs":"1a859c5ecff97c768cec6b07f380b7d95461a841028f549a83b6878403125521","src/um/d3dx10core.rs":"693dafd6755452d282d4f2739b0ca23f7ef4c91c7ded1a422e81dc9f45910781","src/um/d3dx10math.rs":"eb45ac39eac6459eef2942eb652e7b7876b7c9a3593a43d81e7a3ae929d468fe","src/um/d3dx10mesh.rs":"ed4e70afa27dda8ebdf7b69692f639b6c86d9121cbf0cf80fd7b4b0fbb6a8938","src/um/datetimeapi.rs":"e280d15f02b260e0b6c3ccea3ee2f989ef93bc954a098c66903c4ce8a5f0ad92","src/um/davclnt.rs":"e282bbf42babaed01e6bdb0f20ea3ddb59395b594da5f70b6d61706756d86c09","src/um/dbghelp.rs":"f5fc25d89a18cf12132fbd8922ecd081a3cd32961038805d39372cd789c37695","src/um/dbt.rs":"afd59a2fae9a8780367097a982b3e89c3180939338e40a9faeb5348cbb9520ce","src/um/dcommon.rs":"33803f74eb870fbbdaaa3201573154b5b294454ebe7acc92b010aae433afd0fe","src/um/dcomp.rs":"258ded4806208dc6ba071a5b30e50c4ff8be57cb7539400d35f5ff0b38ec1886","src/um/dcompanimation.rs":"7ba55595569f855e625237dbe3edaaf5aaaf0e91afced3aa7aeb2e5efd3b100e","src/um/dde.rs":"ac010bf6cc6c3c72b2e13f5c62aeabd1c5ff0fa087babafa3323f01b5719b1de","src/um/ddraw.rs":"d9485ed844c2b4576bf5ef91ac4d012e505032559434f6e71f94fb856a979d9c","src/um/ddrawi.rs":"3b5db96b3cc668261223fd57e033a6d65f02ef1c7120faa76a365212529cb693","src/um/ddrawint.rs":"4de466a4f12d11c8a5463bc045a78cd9bdcae6ac71c5a200cc97e9618bec5d67","src/um/debugapi.rs":"2fc48ef68740503afd7411e2a58ae7e27691ee7a8e7fc5de96b17693ca7c82f1","src/um/devicetopology.rs":"3b4ead355274636e2d0420e82bbbbb2f3b36c50b14f598e56db3a7e4ea221dbb","src/um/dinput.rs":"5d61e3dd3e3743ea31fc594518733a114c5f1e3ac1eebd61b5f0282d63cc5456","src/um/dmksctl.rs":"8b7f64a5f1320168a9e047af93b8e4608b3c8ad985e60287c0d1a3f8f68e39f0","src/um/dmusicc.rs":"c04ebba40f56a73f357371980dca6ddca5ec3ed5b7ab99ddc4ea3a5cddb85fab","src/um/docobj.rs":"e1d395c472657b154601cdf10665b51b46a0b24f3ae4b63a81a7f6350d30e335","src/um/documenttarget.rs":"1ce701a5ad7a0a62f3f65059d6f53e231ccf303d1600b5ecd469a84ff8ca283c","src/um/dpa_dsa.rs":"499700fc662dbc314338502db360d7d33014dc2e44f118096744e153f242ba89","src/um/dpapi.rs":"d905df74cebad05b55cd649d0e7cd991dcaca417d98f455470077708253cbbfb","src/um/dsgetdc.rs":"10a39c907d4f14fb26c6e243905ee9ae3ec4cf13e70214cbdae5747f95a9e1c7","src/um/dsound.rs":"e93f9a09be03eff437181204b577eca94fa0bdcd448018a18d2c0fdae38be85b","src/um/dsrole.rs":"14fbdc0d01d63bd95422300cda3a03a633b5fc04e2624e02a93afcc9024eb8a1","src/um/dvp.rs":"d1eb0e0ba08a455d65563e687753795118ce535727d61175703c435e91e6f4bd","src/um/dwmapi.rs":"f7200b10789fee50f5cd4ef40642db377ff97267b20c705c5a4e5038e7161a4c","src/um/dwrite.rs":"70323c9959272610426ed5494531e0340a2e6be2867f7bc236b12729846ac6a2","src/um/dwrite_1.rs":"e3bc9ff0edae57e8bb46c2a4a66428777709638dbb921d468143e61dac42344b","src/um/dwrite_2.rs":"18fc9de6626b5f0cf47cf5ae31eb65e63ecf158e714bb1079dbe3bd87cc30e11","src/um/dwrite_3.rs":"e60f76f7128b7dcd5aa57bb90db952603caa5a0a9bcad21eb2a0fbc9d143c767","src/um/dxdiag.rs":"6e02c1a1b174b774f2d02cc0007b240ecbb551159c7221a81780db05caba9af2","src/um/dxfile.rs":"97a87d87ceff6c8aa2c1624c3ee891a7adc0914e1b0750d3df05ace6d20eeccc","src/um/dxgidebug.rs":"3f1be2abf364db3e70e173feb6c4eddea7b56c5daf10f5a84963602097a011dd","src/um/dxva2api.rs":"7ad1f734e7900b844985f0acb876e1dca162eab448c10ddefd0cf84c2dd155d0","src/um/dxvahd.rs":"89193df159458e49fa65acebbefc5becca6e291fc6a32c3223d387acb23e4d55","src/um/endpointvolume.rs":"bea3f64307823529f1f73ac3853297089496bc70c57f381ca7c78ab888491a3b","src/um/errhandlingapi.rs":"5336cf6d97cd1278b783d861319a0521302788dd929b1dca0d8c404ac3bb4346","src/um/evntcons.rs":"910a5c14d77465ba57ab05a98e3ec17130946b28557a00cd0ef85b8566dbf9d7","src/um/exdisp.rs":"147f59b0b106cffdbd8d6e02fdad8f39685ce0bf5938b488bfedefebf69de877","src/um/fibersapi.rs":"424c69269dce6f0a1afaa5140d95b8c1719b3719ff46bc05b3db7101dbb50649","src/um/fileapi.rs":"89fe72af0c76dfa48dd7898af98d32fe5c456c58112835db3105b9e07f5b1605","src/um/gl/gl.rs":"9add9a323d87613a4586f4c688599b864cbf3d862d3d70ed0c18dc0da041d8bf","src/um/gl/mod.rs":"3e3fb3789ce9bfe7692fe2939121f65887f71005d5b0b3b1775f131c9b69222f","src/um/handleapi.rs":"3c3ba7150e50fe603f0a1e14f67777a5ba2d7221a4b66ab1df84566dcb07eb81","src/um/heapapi.rs":"7284592bea7212d0554dc7ed63b0888786f2ae3af4df59ac1e4b697c85edb922","src/um/highlevelmonitorconfigurationapi.rs":"eec1fc57db896d9cd72c09b4cb3281c51d5163fc3f84169358c5cd9b0ccc302c","src/um/http.rs":"11e274e2cae05a9806418caac57b673617eab5d44162b2cc6712c7d4bb1c9002","src/um/imm.rs":"8ac25c6ec9e29b4649e0d96dd76455493c25b66dce983d95dff8f50d4bcb77fa","src/um/interlockedapi.rs":"e9d2e12f2a2076f4cf26e19ba29d871f3a652b1acfef44670c05be7255103d2c","src/um/ioapiset.rs":"35ad02dfced8b111ccbac26e2c3c8cb14d3febb757790299961b90a8692e3065","src/um/jobapi.rs":"7dd7a2cf7732407b501588b07185af35dff4458e103318583efcb1d12b2196ee","src/um/jobapi2.rs":"5e919f05a84149b7dea9057a8d583b5c35cda9fd36432675260cd15c65ab5be9","src/um/knownfolders.rs":"02de8af90f560227c1cf1067efe1c40b4c7f308f02dda427651bd6fe29ffe511","src/um/ktmw32.rs":"43a6387979a79ac365667e73b9659d6ce608bc4440cc23aec5748fd2bf3af646","src/um/libloaderapi.rs":"130ff661c6ec51c16c4e5ac4111f01732d4767e5f9f9a286339d885742e1d3c1","src/um/lmaccess.rs":"4985651ea5949852f7adce4b527f47aed139f4dc877055f651fe6f9b046d6406","src/um/lmalert.rs":"f4510d6a8524f1950979500cee86aded86a46afb5249cb227e99a61b79f9d1d6","src/um/lmapibuf.rs":"3e761bb15d8c7e83683c1138624ce7606053ba6bc9077f4c2a87545d3efa56fd","src/um/lmat.rs":"fac23bdfcc071052de2fdb1e1cd6ac164cc4e35d502af709b3b634844f7ac449","src/um/lmdfs.rs":"228ab0745f456aa8e11a630014907eb124e1380377456701fa99353c763df4e8","src/um/lmerrlog.rs":"73d51724f07316ec0c8ace1febfdc0bd5958d637d253f79f36aa5331ec2bbbdf","src/um/lmjoin.rs":"9dafd3c9317c566e628824cb6d16d806fb95fff5813ced1948cea8882752832a","src/um/lmmsg.rs":"1b3566b3a1595dcdfb471304719af37f739b4223bc6c08744e3e7f7aaa14b597","src/um/lmremutl.rs":"4401f095e6db493b56ebc3fe2daa69317bd59e361bb71f1eb3cf6b672ba21cbe","src/um/lmrepl.rs":"4090bb897cdb9991c417e53850e333191527cea4d06258a497a3a5b1a448593f","src/um/lmserver.rs":"c1a123fb6ec29d743e4e7a42e9b28f450f2230234559592b6ea2b21709810e27","src/um/lmshare.rs":"13b15ba3eb252fe9e2a20d97b38849eb4b617a177cbc70c88d5ab210a031a58a","src/um/lmstats.rs":"3a114d58d9c564414421437285acab7f2262bcebb78517bb6e9b7b36c34ab36b","src/um/lmsvc.rs":"1d032afa6bf643a6049024a11a5be89722cd3df332f1e50953f93402e092d8fa","src/um/lmuse.rs":"6a3dbf4ebdef73dffed0dde131e52d7afcc2675e1537c01872dff43f6f5147ed","src/um/lmwksta.rs":"de6964159b6c08f0e5e57559653027cd210ddaeade7cad9e5e2af3dbc8c15835","src/um/lowlevelmonitorconfigurationapi.rs":"b860615f855a40091d903a08a166d4659ce31493a895647695fb3bf5f70e7fb4","src/um/lsalookup.rs":"b01ec0f2b1edb618af0683b4434da1ddea0bcda03797a95d638d93410ddf1761","src/um/memoryapi.rs":"ac65f2ea269607480e06921fa47fb3c64dce617c9f5f8cb97535dddd7b6e102f","src/um/minschannel.rs":"86c4b7ea3012a879dfe66e54aade2cffb787918cfee06f7e4498c42b14b88127","src/um/minwinbase.rs":"89f02e72a7d639f440a3e13c4326e2c0c1fbbfe3915483d5ba8500bd5513cde8","src/um/mmdeviceapi.rs":"5c64507cee87e4bad896a2a3d60766fafc01e8b85930f4800ee4702ea0cb4e99","src/um/mmeapi.rs":"955a2d66ff240db263be0b9054b27897228f6997e61c8daa2b701bc977d288d6","src/um/mmsystem.rs":"efa92923ed0dfed83e41104a8e3da0cb3fb11c6e21b43253d4ff561bb9577382","src/um/mod.rs":"a31dbf870d1e725f5e824836850adb1d3d1551321a29638e4266fed8c514f9f8","src/um/msaatext.rs":"f7a04ed96e0767a435856bb84bb835ef31617a30e49a6157e4a51c99dccecaea","src/um/mscat.rs":"c3ceae9899811610a4b2f15a80eb2e41eae566262d26ad6c68f2f95d1785a1a2","src/um/mschapp.rs":"f432c8a1d67b521e8e031c7662d7ad394d3f0383f6c44f09d3fbbddc5c208e5b","src/um/mssip.rs":"0ec2cda4bc2cb2cc1c6ca83ff0a63ee6c85b731f6b90206909a3473c9084e79c","src/um/namedpipeapi.rs":"f324b25161e2f2ae592ee59607bdc49af9815c001a6ec4d2a79b0c4e7e73df51","src/um/namespaceapi.rs":"30c2a4e7b05c1426af95eb36216d9ac9c1219ee64f472b999286027a27a6e8fa","src/um/nb30.rs":"c16c9fceab92a52a5587a22760cbbff0b2bb8564dac1f9528f51eced3fcb8b69","src/um/ncrypt.rs":"acc09d30e0256e922130f1bca8e0ec3d8717fb818f9071893940098e87e1efaf","src/um/ntlsa.rs":"f2198c2d358936bee1e6246fe2637c1b1c55d5d0109f92be380ec96a857ab84b","src/um/ntsecapi.rs":"3de4fea1eb7de0a8c99ead6bf5175414f6d7b082bfd0cd4d95bc2f165c497f1c","src/um/oaidl.rs":"4f0d4fdd6844a5ec96922cbe19fdc793cce3c82bdb23f9a8ca05738e0b638bf0","src/um/objbase.rs":"17297f27028765c3e40c5b47a83cbb083723259956a064344e2b681816c65d87","src/um/objidl.rs":"89693c5a3fa9247c50071da60d7f0561d3e6231f93a288767125412d4b8b2168","src/um/objidlbase.rs":"3cb828436c7603301886a5c97a32547ae4fb787df40e5ecb79e40a01e75b3648","src/um/ocidl.rs":"87e9c1973c25669ff7e8c4c28b47f750b8b002c429e8d262d12d1414129d051f","src/um/ole2.rs":"2c3b68683ea0e259d7ff3a56aa96ebcbd01a0fad880482802b7a7514105688e0","src/um/oleauto.rs":"ca201f00229bf13906667a9deb1422b4825439555c0dd570979321eb73180cee","src/um/olectl.rs":"29ca0c1151fb7e19eee5839ad0960a052bbe94c770299ab1f2ca72bd518b2cd5","src/um/oleidl.rs":"56253f3b4d2a18c6610de79b7f3f5cb5a120c07be4bf14475d122deaa083f262","src/um/opmapi.rs":"b10c513bb24a7e43af80b0526090ae23dbfc74fb02fde9de720eeee6a8bf69ba","src/um/pdh.rs":"79cf08ba4b73bd8fd4a2d256c7547654ad489dee86d0a020efa2c738f93aa9e0","src/um/perflib.rs":"5b0b9363ca8f0cea2a0b704d6e78246d120aedeb8c8cd035027aab39e0eeef33","src/um/physicalmonitorenumerationapi.rs":"41e56c449742934c636f2a7890bcc158c2b269175fbb4bca365bb91b535b98fd","src/um/playsoundapi.rs":"1b20c049d6c6762c7ad046131c4f2ff7038112149ca43ab95c63c149f6f84639","src/um/powerbase.rs":"6e3409c14abd9827439c736907b8a172f405181a6f803233dd260d12dc3ecc33","src/um/powersetting.rs":"c266b3cf87ab2224bdad52dfb9442ab4bde4370228cf32fd995c78e03c8370f5","src/um/powrprof.rs":"41f649be8d3b449e8bcc0dd50704d4b2b62d26cf821b609c198673974528cbb0","src/um/processenv.rs":"82d4d1d41b2254da608703a060f641a2ee08a43ededdad827137285bac68c549","src/um/processsnapshot.rs":"bb6fb908067b60d6d2984fb6a82e019aef8e2d14a36829e3fd6033e9a421c69a","src/um/processthreadsapi.rs":"f33f9ef0d9dd681418f744c6d1f138068097e1488123866714a949de14300e8f","src/um/processtopologyapi.rs":"660cb88cf5fd340ef3b83858059d3b3d920ec53e710490c9c28684534e042cf6","src/um/profileapi.rs":"f58d7d6f1dc916db6b87d9b1d9ff50fab9afe6280af5d75228e5ec8b2588f264","src/um/propidl.rs":"7595aa6e58ed166b21f550ebbe7b50cc45f847cd4d5685cf2c72492137c987c0","src/um/propkeydef.rs":"8cc9b032622404ce3e5fd2956198237c2ba2a2d28f0aefc9bd3cd137a4d93454","src/um/propsys.rs":"6627270787fb0c7b2b6db791d4445df04937a91e7df64e8f5eb74461649769b9","src/um/prsht.rs":"e8171b46042b169095c6ab2f6ef0fc34c9912e6d53fdddfd083c2dbc80296436","src/um/psapi.rs":"242ad484c2d2c178bbc37e806c5e077c5dff6e6ed7ac1fd9cc196e3c9003aef0","src/um/realtimeapiset.rs":"9411d06bbbab05eb9700bda4dfd7355b34fe834d4616812d81bde24107a4d0ec","src/um/reason.rs":"6923c46f0ceb308e2306cdb92763a385582197ea1aa50379c799dfa6736cd5c1","src/um/restartmanager.rs":"62f21e87bb521bb371f2c2ac7623d1b56db4d6bb5169ac1b2651ebf19d25c212","src/um/restrictederrorinfo.rs":"aa5cd16d7b9e0bae1243718500ec4d184261abb279e821c821f2424ea2ebfd4c","src/um/rmxfguid.rs":"7a683ff98d3eaaacf4746c2f4cd1b97cca4a025d6060d24ea4ad0c4b12a31edb","src/um/sapi.rs":"d7ee73e0b59515e829ad6047636a7901c6f6dac2d637fe66faab210b4cdec2b3","src/um/sapi51.rs":"429bb46e49be4a5e9dd66aa1251b6552cc67d924020d601d222a0769ee12b264","src/um/sapi53.rs":"7dcee1e8b24d056fdba01ad085b7d514284f01ee89f6c494853ce81066ac45c3","src/um/sapiddk.rs":"845b3574616ba748295cce6f6c94c0e9a9296a360027ccba0d5c6d542d2a084d","src/um/sapiddk51.rs":"b6706222ce6d6d8f786618f2d01c48c65e6629290ef010a27dc376f2cb395d15","src/um/schannel.rs":"9ba7437b82cbac1fe6ad0dc82ef58b1ec3484bbbaeac5b4a2fe12f56c46e5d13","src/um/securityappcontainer.rs":"933038334262d99c3f8f4160358758f16acdce8b95387f8fea449ce7749cd940","src/um/securitybaseapi.rs":"b94268651c80e75e00a9eb5a790e5063453cac1923b9145384191a77f3e3a7eb","src/um/servprov.rs":"116adfb7ed8cfaff0b6e1d0df46bb456b2936fe0b840485a4fefde87b0207885","src/um/setupapi.rs":"9807107f00decc94fab7ba49fe4984a48f9b87e4162415a0c2693c0cde8da27a","src/um/shellapi.rs":"6141aabc9741f2fc8685bf619944607c96c1c5e7682444f716d4658dbd70b9d5","src/um/shellscalingapi.rs":"2cded3fba4480871733ba141b0a1a790e883d77e9f144ea34135215c89a40cf8","src/um/shlobj.rs":"bd604c083a0e8331049f9ac1200a03cffa2744d63d9d470c4aa94400482d4d44","src/um/shobjidl.rs":"046bf4ef1607496e143d2d825bae587a0e235c9991e8fbaed03a59a7875b7dd4","src/um/shobjidl_core.rs":"cf6351bf9ae4a56fb257a176ebe31ccb621616553e6a8775e43b403b126c2fc4","src/um/shtypes.rs":"0570e723dbc2712a019c522fbb01e87667aa9db32b6a7891e763137b256c1b18","src/um/spapidef.rs":"575b0632cb7ef628cf86130936c31f8a35c6f6269fb57d2a4cbd5bcdef539a1c","src/um/sporder.rs":"64d365a773a864fbf6789ff8156214ed669baee6b3cd90819c2d2b36324248a1","src/um/sql.rs":"abff2a2fb5f08be9f565eb03a65244043720348829f04b98656a89686e807216","src/um/sqlext.rs":"9545e0390ffde6ab4a620e0800265b399144cd4fc8bd94258041c1af9375573a","src/um/sqltypes.rs":"77c6c920023498820e51ede76942e9628c544a6024cfce5ea484b8995e664ba2","src/um/sqlucode.rs":"758a8e581fe6f0a960bef2a478a4047a494ee18995f1e7dfa34282ee2b0d18f5","src/um/sspi.rs":"0855fd38942aef19f613702506329c8103df99721b5e1bf6d508434a7cc24920","src/um/stringapiset.rs":"585f3051bec63cd82909b7edc10c76bb7bf92596c90f33792de28eabbe57ca8f","src/um/strmif.rs":"302d470618e6e5225c5168838228ba9773295e87c8864d6ad2c148cf28c7c3ed","src/um/subauth.rs":"51b44012d506c35fe608bf7abdd8b5db1bf9f61a626ad5431618448795f5a3e0","src/um/synchapi.rs":"a53963ba8b51b2b8ac91039d91b7f5879b900910f913cf879e31177ead04039c","src/um/sysinfoapi.rs":"37ea5a4b3b120da417d2e1585210cdfd09b1280c3b546e3d53bd2975cbb5a4f8","src/um/systemtopologyapi.rs":"e535d6d30d631ebf8a6a311cd9f526d737b020a654b283e4267ee34b0226132e","src/um/textstor.rs":"3c2980ae947ea25a8299f7bc670ca73ec3c9a13a3ab7884c96b55575113d28c7","src/um/threadpoolapiset.rs":"0a96fd29497b2ece591d5a65a74a70ec40b444bf6e128fed8a03041460ea699a","src/um/threadpoollegacyapiset.rs":"d63f2aa225ba0587b567af78eb2b5a8a196f6ab878d97f9b022968cfba5e9141","src/um/timeapi.rs":"8c493994fb39f8e22f951b12d4b03d6287597b640150d5e605dc3b51a3237db9","src/um/timezoneapi.rs":"6cfb38964a156f77a94c51380a3c0e986c39aee3e0f85c1c773a34bf057147f4","src/um/tlhelp32.rs":"493508be1c33e426bf778067dc8650c49135dff39be776d2aa0488744009baa3","src/um/unknwnbase.rs":"071fc08d973b4167b5350bc73d28af7f872f803973c0ef10db2075c9980006ef","src/um/urlhist.rs":"f54090d2042a629cb9542c6d3f4121c74707063f13809269cd2c9d29c3b81db9","src/um/urlmon.rs":"dba8dcfb8e3e3753a41147946f5ed336d822d1df807cb9b3e1dd1357822f88a8","src/um/userenv.rs":"3ed27bb291217613d32179deb6275526fb7647ef667cacd7cfc2fdb2f7b5f42c","src/um/usp10.rs":"85147d47f29d172bc6d3f3a51720cc1df2ec0803e007c9c6eb29cd18e66444a3","src/um/utilapiset.rs":"f02a26c4a3c908bb0c80ffb29a667dc66b7b9ffa29d48ef190dbeda03a0cd78a","src/um/uxtheme.rs":"749fa1edf068ab9a98160f64f628ac57b25141451dcec125f9a9d8dc7cdac3af","src/um/vsbackup.rs":"951c9aa850c1c59d7beb554fc117025abac3c85b2d08d70dcf0552450684bdeb","src/um/vss.rs":"daca19c9438618b2ec0f869b442214ed96be66d4c0ba2eb920b0ab42fdc1cb8c","src/um/vsserror.rs":"1b43c769bc7377405ad286e0fa1442e02d0d7ee025ea949a04161653499d24fb","src/um/vswriter.rs":"0d70f32a5ddf938647cd744a6eee237bfea16415d37c25a8f93a0a9ceb2b4661","src/um/wct.rs":"3f2a2602987ec838e05e1663bd01cb720bcd4471ff05bc207beed642ea1ab4f8","src/um/werapi.rs":"d41c0ec1d067a453a283676aebb9cc30627205aebdcfcffc5da374ed4c9aecad","src/um/winbase.rs":"e764934a4141e8361f015405dbe1a23dcc0e0c28c59af4acffc660d3ccb31c4a","src/um/wincodec.rs":"666feceab4eaa75ba77423f0623d0b35711e490b8546795d918ab4d304569a53","src/um/wincodecsdk.rs":"46b7a9a2b24dd354c3f8e079ae75a6d3f93ae472639902e0974fcb9827cc1abc","src/um/wincon.rs":"9aef7bf262c9b9ed0ec85e6ca97c25327d8f97df04d83aea5d8c9ae4b6d50604","src/um/wincred.rs":"7626c80a3e1e34496fdecd6d2f44509632c99f33f3c3241f73fe32c927595bc9","src/um/wincrypt.rs":"033e2ec801ea5dcd6ca179780ef2ba115db97b0de7508a499c87440cc514fc77","src/um/windowsceip.rs":"cfc2062daac6a9195690af64bd817fb41f086206c5091539da29d6e51a3a00c6","src/um/winefs.rs":"5072c32e71b40a4b11f00b6aa61537ea28d0a41e42ee8e029760ee5e493c664f","src/um/winevt.rs":"29f85bb49424efa7ac921cb10f2da4b77e4cfe863ca2fe17026137dc5dc2ca8d","src/um/wingdi.rs":"e02491bac6cd84970f98a5ebcbb68815a78b33a18bf5ca25474c9aab088cb5fe","src/um/winhttp.rs":"f163b3b7ef893b6d769fd3886bba182972dd886674af382174ad0c96c774f54e","src/um/wininet.rs":"c96ff6e03d1602b50422ab2847f28c6e4ab80bb3f992d2e6a4e87c20ee17d83d","src/um/winineti.rs":"8624f54b40da0ceb7949b43f8eb54e3e07ca59f5b805328de2b9aa030adb341d","src/um/winioctl.rs":"2dd66814f6203188f6ea1bc1bb7a376cfa1bbb33eccbcbb1ddff5b97c05cbc26","src/um/winnetwk.rs":"bf3c503f6e6d99d8640d66102679522ffda0ac918022f0873dae8bf3fb837ba0","src/um/winnls.rs":"bdea7ae691328e1fa8ab6cc479b5c612c6542ced215870993a6498baaea301aa","src/um/winnt.rs":"8247bc9131a54fdb8a4c4b551a733c7a21d1eeef0ebe4cc64904076e23754d6c","src/um/winreg.rs":"f7fda9bfa992566453b3f6651d18545924a1e81191540700216aa856e2fb0650","src/um/winsafer.rs":"623e4849c38ea24850d05cfc99349099e9ef37278fdf1353dd0102d5d54a70cd","src/um/winscard.rs":"0fe23a54544c530838774f7c03708b2d375a3678fbf2f0390e6abddd128a3f33","src/um/winsmcrd.rs":"f3c91490cf7c07a3b7df260097df95d976ce4af6fde258f5e2d2a3f95ad9d0bb","src/um/winsock2.rs":"3ecedee15dae16920c39b880f32d5d39686651e6b232496c8e10cd32ce9aa81f","src/um/winspool.rs":"8ca9532933aa6bb35a1fa3ec7609a12bd5db82fde49fdd6f1d9aea61479df131","src/um/winsvc.rs":"a30d607dced7c1fb75524b845d78ac0516228c270139f659bce0cf56771937d6","src/um/winusb.rs":"8a5b539a14c8fa6175a10fe6adc6cc5e643df27fb0a78dd2b7466aa3039492eb","src/um/winuser.rs":"e200be8d7a8e8cecf3c04f3ad96298cb5035216fa13849d7f756a6eb6057a4f3","src/um/winver.rs":"c0437e334c919489b02c7e14e0aedf64ece4ef1ad80569cc99f4e126c8c8d287","src/um/wow64apiset.rs":"42f0fbea817164c78133c014821486f2e312fcb79060f922435a60fdebfb07f3","src/um/ws2spi.rs":"79a2cceb67b4e632ee890000d8e2c00f2d578ab895af6d80d5df96883136ece9","src/um/ws2tcpip.rs":"ec7d0af8a43fb608e827e52b98937339359ffb9fdd47dcf5f9f3c4c086145527","src/um/xinput.rs":"5e55915c432e4b8de8cf489d35d774e9f3e259cfd3bbd9a09e3271cd78a2e00a","src/vc/excpt.rs":"c1000ba67ad7dc36a00433dadcc20633fba6b1a7306fb1e59e60a32369fe22d0","src/vc/limits.rs":"0b97c2538434c4d734c9a6da80a6f690755374e66f4cf83e82417318f96f8ed8","src/vc/mod.rs":"cb61848f0bcee5c96ebf2a6c3a69eebc31d84d29c108b0664d104f9c040e3aa2","src/vc/vadefs.rs":"3dc2f47dc3db9f6ff0e3c5ce5dc1487b031094240cb00d8ff194e333c959492e","src/vc/vcruntime.rs":"a9e21c05716dbbfeed5a17918e7b742103a80ca9923fcda3871859c0e863606e","src/winrt/activation.rs":"536d50f4f1cd2f4e631fb89ae4044d353d38f03a6c7487db23c0aee956ff973e","src/winrt/hstring.rs":"ce9c550121838a2df0a840c46714374ec317ed0a8f5323f0467e00234b417d22","src/winrt/inspectable.rs":"7252d0813a1f3f734a8cb7134a6bf1a91518966bca3f57a35fbb3c447b513a9f","src/winrt/mod.rs":"13530a7c2b7bebc529d2c12666551d0fe4d30f0f653eedc9f38ddc833daea05f","src/winrt/roapi.rs":"50eed24313e08c451db27e7ab02cecae2b8331af4d3d686369218c652d8df9a9","src/winrt/robuffer.rs":"6c974c04c3c20784058753d8a4d6a640bd2f2d52f644249ffaed6886e12ec241","src/winrt/roerrorapi.rs":"90c1e113dc54121a72957b9b64dc3592eb688fc91015a03a04edffad4e62813e","src/winrt/winstring.rs":"a3875b317bd598040f98deb4838f5dbfb38b40f3eac0d450debc9084971f1386"},"package":"92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"} \ No newline at end of file diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/Cargo.toml rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/Cargo.toml --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/Cargo.toml 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/Cargo.toml 2018-12-05 01:24:41.000000000 +0000 @@ -12,7 +12,7 @@ [package] name = "winapi" -version = "0.3.5" +version = "0.3.6" authors = ["Peter Atashian "] build = "build.rs" include = ["/src/**/*", "/Cargo.toml", "/LICENSE-MIT", "/LICENSE-APACHE", "/build.rs", "/README.md"] @@ -86,6 +86,7 @@ d3d11on12 = [] d3d11sdklayers = [] d3d11shader = [] +d3d11tokenizedprogramformat = [] d3d12 = [] d3d12sdklayers = [] d3d12shader = [] @@ -101,6 +102,7 @@ datetimeapi = [] davclnt = [] dbghelp = [] +dbt = [] dcommon = [] dcomp = [] dcompanimation = [] @@ -112,6 +114,7 @@ debug = [] debugapi = [] devguid = [] +devicetopology = [] devpkey = [] devpropdef = [] dinput = [] @@ -151,6 +154,7 @@ evntprov = [] evntrace = [] excpt = [] +exdisp = [] fibersapi = [] fileapi = [] gl-gl = [] @@ -175,6 +179,7 @@ jobapi = [] jobapi2 = [] knownfolders = [] +ks = [] ksmedia = [] ktmtypes = [] ktmw32 = [] @@ -227,8 +232,10 @@ objidl = [] objidlbase = [] ocidl = [] +ole2 = [] oleauto = [] olectl = [] +oleidl = [] opmapi = [] pdh = [] perflib = [] @@ -308,6 +315,7 @@ userenv = [] usp10 = [] utilapiset = [] +uxtheme = [] vadefs = [] vcruntime = [] vsbackup = [] diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/Cargo.toml.orig rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/Cargo.toml.orig --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/Cargo.toml.orig 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/Cargo.toml.orig 2018-12-05 01:24:41.000000000 +0000 @@ -1,6 +1,6 @@ [package] name = "winapi" -version = "0.3.5" +version = "0.3.6" authors = ["Peter Atashian "] license = "MIT/Apache-2.0" description = "Raw FFI bindings for all of Windows API." @@ -56,6 +56,7 @@ dxgitype = [] evntprov = [] evntrace = [] +exdisp = [] guiddef = [] hidclass = [] hidpi = [] @@ -64,6 +65,7 @@ in6addr = [] inaddr = [] intsafe = [] +ks = [] ksmedia = [] ktmtypes = [] lmcons = [] @@ -150,6 +152,7 @@ d3d11on12 = [] d3d11sdklayers = [] d3d11shader = [] +d3d11tokenizedprogramformat = [] d3d12 = [] d3d12sdklayers = [] d3d12shader = [] @@ -162,6 +165,7 @@ datetimeapi = [] davclnt = [] dbghelp = [] +dbt = [] dcommon = [] dcomp = [] dcompanimation = [] @@ -170,6 +174,7 @@ ddrawi = [] ddrawint = [] debugapi = [] +devicetopology = [] dinput = [] dmksctl = [] dmusicc = [] @@ -248,8 +253,10 @@ objidl = [] objidlbase = [] ocidl = [] +ole2 = [] oleauto = [] olectl = [] +oleidl = [] opmapi = [] pdh = [] perflib = [] @@ -313,6 +320,7 @@ userenv = [] usp10 = [] utilapiset = [] +uxtheme = [] vsbackup = [] vss = [] vsserror = [] diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/.cargo_vcs_info.json rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/.cargo_vcs_info.json --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/.cargo_vcs_info.json 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/.cargo_vcs_info.json 2018-12-05 01:24:41.000000000 +0000 @@ -0,0 +1,5 @@ +{ + "git": { + "sha1": "4ac6c90e4ab92850c78b6103137290fe4ab9d273" + } +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/LICENSE-MIT rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/LICENSE-MIT --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/LICENSE-MIT 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/LICENSE-MIT 2018-12-05 01:24:41.000000000 +0000 @@ -1,4 +1,4 @@ -Copyright (c) 2015 The winapi-rs Developers +Copyright (c) 2015-2018 The winapi-rs Developers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/README.md rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/README.md --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/README.md 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/README.md 2018-12-05 01:24:41.000000000 +0000 @@ -1,4 +1,13 @@ -# winapi-rs [![Build status](https://ci.appveyor.com/api/projects/status/i47oonf5e7qm5utq/branch/master?svg=true)](https://ci.appveyor.com/project/retep998/winapi-rs/branch/master) [![Build Status](https://travis-ci.org/retep998/winapi-rs.svg?branch=master)](https://travis-ci.org/retep998/winapi-rs) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/retep998/winapi-rs) [![Crates.io](https://img.shields.io/crates/v/winapi.svg)](https://crates.io/crates/winapi) ![Lines of Code](https://tokei.rs/b1/github/retep998/winapi-rs) ![100% unsafe](https://img.shields.io/badge/unsafe-100%25-blue.svg) # +# winapi-rs +[![Build status](https://ci.appveyor.com/api/projects/status/i47oonf5e7qm5utq/branch/0.3?svg=true)](https://ci.appveyor.com/project/retep998/winapi-rs/branch/0.3) +[![Build Status](https://travis-ci.org/retep998/winapi-rs.svg?branch=0.3)](https://travis-ci.org/retep998/winapi-rs) +[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/retep998/winapi-rs) +[![Crates.io](https://img.shields.io/crates/v/winapi.svg)](https://crates.io/crates/winapi) +![Lines of Code](https://tokei.rs/b1/github/retep998/winapi-rs) +![100% unsafe](https://img.shields.io/badge/unsafe-100%25-blue.svg) +[![Open issues](https://img.shields.io/github/issues-raw/retep998/winapi-rs.svg)](https://github.com/retep998/winapi-rs/issues) +[![License](https://img.shields.io/crates/l/winapi.svg)](https://github.com/retep998/winapi-rs) + [Documentation](https://docs.rs/winapi/*/x86_64-pc-windows-msvc/winapi/) @@ -28,6 +37,14 @@ This crate is nothing more than raw bindings to Windows API. If you wish to know how to use the various functionality in Windows API, you can look up the various items on [MSDN](https://msdn.microsoft.com/en-us/library/windows/desktop/aa906039) which is full of detailed documentation. +### Can I use this library in `no_std` projects? + +Yes, absolutely! By default the `std` feature of `winapi` is disabled, allowing you to write Windows applications using nothing but `core` and `winapi`. + +### Why is `winapi`'s `HANDLE` incompatible with `std`'s `HANDLE`? + +Because `winapi` does not depend on `std` by default, it has to define `c_void` itself instead of using `std::os::raw::c_void`. However, if you enable the `std` feature of `winapi` then it will re-export `c_void` from `std` and cause `winapi`'s `HANDLE` to be the same type as `std`'s `HANDLE`. + ## Example ## Cargo.toml: diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/lib.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/lib.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/lib.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/lib.rs 2018-12-05 01:24:42.000000000 +0000 @@ -56,6 +56,13 @@ pub type __uint64 = u64; pub type wchar_t = u16; } +// This trait should be implemented for all COM interfaces pub trait Interface { + // Returns the IID of the Interface + fn uuidof() -> shared::guiddef::GUID; +} +// This trait should be implemented for all COM classes +pub trait Class { + // Returns the CLSID of the Class fn uuidof() -> shared::guiddef::GUID; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/macros.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/macros.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/macros.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/macros.rs 2018-12-05 01:24:41.000000000 +0000 @@ -129,6 +129,22 @@ } #[macro_export] macro_rules! RIDL { + (#[uuid($l:expr, $w1:expr, $w2:expr, + $b1:expr, $b2:expr, $b3:expr, $b4:expr, $b5:expr, $b6:expr, $b7:expr, $b8:expr)] + class $class:ident;) => ( + pub enum $class {} + impl $crate::Class for $class { + #[inline] + fn uuidof() -> $crate::shared::guiddef::GUID { + $crate::shared::guiddef::GUID { + Data1: $l, + Data2: $w1, + Data3: $w2, + Data4: [$b1, $b2, $b3, $b4, $b5, $b6, $b7, $b8], + } + } + } + ); (#[uuid($($uuid:expr),+)] interface $interface:ident ($vtbl:ident) {$( $(#[$($attrs:tt)*])* fn $method:ident($($p:ident : $t:ty,)*) -> $rtr:ty, @@ -356,11 +372,10 @@ ($(#[$attrs:meta])* struct $name:ident { $($field:ident: $ftype:ty,)+ }) => ( - #[repr(C)] $(#[$attrs])* + #[repr(C)] #[derive(Copy)] $(#[$attrs])* pub struct $name { $(pub $field: $ftype,)+ } - impl Copy for $name {} impl Clone for $name { #[inline] fn clone(&self) -> $name { *self } diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/d3d9.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/d3d9.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/d3d9.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/d3d9.rs 2018-12-05 01:24:41.000000000 +0000 @@ -100,7 +100,7 @@ ) -> (); pub fn D3DPERF_GetStatus() -> DWORD; } -RIDL!(#[uuid(0x81bdcbca, 0x64d4, 0x426d, 0xae, 0x8d, 0xad, 0x1, 0x47, 0xf4, 0x27, 0x5c)] +RIDL!{#[uuid(0x81bdcbca, 0x64d4, 0x426d, 0xae, 0x8d, 0xad, 0x1, 0x47, 0xf4, 0x27, 0x5c)] interface IDirect3D9(IDirect3D9Vtbl): IUnknown(IUnknownVtbl) { fn RegisterSoftwareDevice( pInitializeFunction: *mut VOID, @@ -177,11 +177,10 @@ pPresentationParameters: *mut D3DPRESENT_PARAMETERS, ppReturnedDeviceInterface: *mut *mut IDirect3DDevice9, ) -> HRESULT, -} -); +}} pub type LPDIRECT3D9 = *mut IDirect3D9; pub type PDIRECT3D9 = *mut IDirect3D9; -RIDL!(#[uuid(0xd0223b96, 0xbf7a, 0x43fd, 0x92, 0xbd, 0xa4, 0x3b, 0xd, 0x82, 0xb9, 0xeb)] +RIDL!{#[uuid(0xd0223b96, 0xbf7a, 0x43fd, 0x92, 0xbd, 0xa4, 0x3b, 0xd, 0x82, 0xb9, 0xeb)] interface IDirect3DDevice9(IDirect3DDevice9Vtbl): IUnknown(IUnknownVtbl) { fn TestCooperativeLevel() -> HRESULT, fn GetAvailableTextureMem() -> UINT, @@ -685,22 +684,20 @@ Type: D3DQUERYTYPE, ppQuery: *mut *mut IDirect3DQuery9, ) -> HRESULT, -} -); +}} pub type LPDIRECT3DDEVICE9 = *mut IDirect3DDevice9; pub type PDIRECT3DDEVICE9 = *mut IDirect3DDevice9; -RIDL!(#[uuid(0xb07c4fe5, 0x310d, 0x4ba8, 0xa2, 0x3c, 0x4f, 0xf, 0x20, 0x6f, 0x21, 0x8b)] +RIDL!{#[uuid(0xb07c4fe5, 0x310d, 0x4ba8, 0xa2, 0x3c, 0x4f, 0xf, 0x20, 0x6f, 0x21, 0x8b)] interface IDirect3DStateBlock9(IDirect3DStateBlock9Vtbl): IUnknown(IUnknownVtbl) { fn GetDevice( ppDevice: *mut *mut IDirect3DDevice9, ) -> HRESULT, fn Capture() -> HRESULT, fn Apply() -> HRESULT, -} -); +}} pub type LPDIRECT3DSTATEBLOCK9 = *mut IDirect3DStateBlock9; pub type PDIRECT3DSTATEBLOCK9 = *mut IDirect3DStateBlock9; -RIDL!(#[uuid(0x794950f2, 0xadfc, 0x458a, 0x90, 0x5e, 0x10, 0xa1, 0xb, 0xb, 0x50, 0x3b)] +RIDL!{#[uuid(0x794950f2, 0xadfc, 0x458a, 0x90, 0x5e, 0x10, 0xa1, 0xb, 0xb, 0x50, 0x3b)] interface IDirect3DSwapChain9(IDirect3DSwapChain9Vtbl): IUnknown(IUnknownVtbl) { fn Present( pSourceRect: *const RECT, @@ -729,11 +726,10 @@ fn GetPresentParameters( pPresentationParameters: *mut D3DPRESENT_PARAMETERS, ) -> HRESULT, -} -); +}} pub type LPDIRECT3DSWAPCHAIN9 = *mut IDirect3DSwapChain9; pub type PDIRECT3DSWAPCHAIN9 = *mut IDirect3DSwapChain9; -RIDL!(#[uuid(0x5eec05d, 0x8f7d, 0x4362, 0xb9, 0x99, 0xd1, 0xba, 0xf3, 0x57, 0xc7, 0x4)] +RIDL!{#[uuid(0x5eec05d, 0x8f7d, 0x4362, 0xb9, 0x99, 0xd1, 0xba, 0xf3, 0x57, 0xc7, 0x4)] interface IDirect3DResource9(IDirect3DResource9Vtbl): IUnknown(IUnknownVtbl) { fn GetDevice( ppDevice: *mut *mut IDirect3DDevice9, @@ -758,11 +754,10 @@ fn GetPriority() -> DWORD, fn PreLoad() -> (), fn GetType() -> D3DRESOURCETYPE, -} -); +}} pub type LPDIRECT3DRESOURCE9 = *mut IDirect3DResource9; pub type PDIRECT3DRESOURCE9 = *mut IDirect3DResource9; -RIDL!(#[uuid(0xdd13c59c, 0x36fa, 0x4098, 0xa8, 0xfb, 0xc7, 0xed, 0x39, 0xdc, 0x85, 0x46)] +RIDL!{#[uuid(0xdd13c59c, 0x36fa, 0x4098, 0xa8, 0xfb, 0xc7, 0xed, 0x39, 0xdc, 0x85, 0x46)] interface IDirect3DVertexDeclaration9(IDirect3DVertexDeclaration9Vtbl): IUnknown(IUnknownVtbl) { fn GetDevice( ppDevice: *mut *mut IDirect3DDevice9, @@ -771,11 +766,10 @@ pElement: *mut D3DVERTEXELEMENT9, pNumElements: *mut UINT, ) -> HRESULT, -} -); +}} pub type LPDIRECT3DVERTEXDECLARATION9 = *mut IDirect3DVertexDeclaration9; pub type PDIRECT3DVERTEXDECLARATION9 = *mut IDirect3DVertexDeclaration9; -RIDL!(#[uuid(0xefc5557e, 0x6265, 0x4613, 0x8a, 0x94, 0x43, 0x85, 0x78, 0x89, 0xeb, 0x36)] +RIDL!{#[uuid(0xefc5557e, 0x6265, 0x4613, 0x8a, 0x94, 0x43, 0x85, 0x78, 0x89, 0xeb, 0x36)] interface IDirect3DVertexShader9(IDirect3DVertexShader9Vtbl): IUnknown(IUnknownVtbl) { fn GetDevice( ppDevice: *mut *mut IDirect3DDevice9, @@ -784,11 +778,10 @@ arg1: *mut VOID, pSizeOfData: *mut UINT, ) -> HRESULT, -} -); +}} pub type LPDIRECT3DVERTEXSHADER9 = *mut IDirect3DVertexShader9; pub type PDIRECT3DVERTEXSHADER9 = *mut IDirect3DVertexShader9; -RIDL!(#[uuid(0x6d3bdbdc, 0x5b02, 0x4415, 0xb8, 0x52, 0xce, 0x5e, 0x8b, 0xcc, 0xb2, 0x89)] +RIDL!{#[uuid(0x6d3bdbdc, 0x5b02, 0x4415, 0xb8, 0x52, 0xce, 0x5e, 0x8b, 0xcc, 0xb2, 0x89)] interface IDirect3DPixelShader9(IDirect3DPixelShader9Vtbl): IUnknown(IUnknownVtbl) { fn GetDevice( ppDevice: *mut *mut IDirect3DDevice9, @@ -797,8 +790,7 @@ arg1: *mut VOID, pSizeOfData: *mut UINT, ) -> HRESULT, -} -); +}} pub type LPDIRECT3DPIXELSHADER9 = *mut IDirect3DPixelShader9; pub type PDIRECT3DPIXELSHADER9 = *mut IDirect3DPixelShader9; RIDL!{#[uuid(0x580ca87e, 0x1d3c, 0x4d54, 0x99, 0x1d, 0xb7, 0xd3, 0xe3, 0xc2, 0x98, 0xce)] @@ -1204,7 +1196,7 @@ }} pub type LPDIRECT3DDEVICE9VIDEO = *mut IDirect3DDevice9Video; pub type PDIRECT3DDEVICE9VIDEO = *mut IDirect3DDevice9Video; -RIDL!(#[uuid(0xff24beee, 0xda21, 0x4beb, 0x98, 0xb5, 0xd2, 0xf8, 0x99, 0xf9, 0x8a, 0xf9)] +RIDL!{#[uuid(0xff24beee, 0xda21, 0x4beb, 0x98, 0xb5, 0xd2, 0xf8, 0x99, 0xf9, 0x8a, 0xf9)] interface IDirect3DAuthenticatedChannel9(IDirect3DAuthenticatedChannel9Vtbl): IUnknown(IUnknownVtbl) { fn GetCertificateSize( @@ -1229,11 +1221,10 @@ pInput: *const VOID, pOutput: *mut D3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT, ) -> HRESULT, -} -); +}} pub type LPDIRECT3DAUTHENTICATEDCHANNEL9 = *mut IDirect3DAuthenticatedChannel9; pub type PDIRECT3DAUTHENTICATEDCHANNEL9 = *mut IDirect3DAuthenticatedChannel9; -RIDL!(#[uuid(0xfa0ab799, 0x7a9c, 0x48ca, 0x8c, 0x5b, 0x23, 0x7e, 0x71, 0xa5, 0x44, 0x34)] +RIDL!{#[uuid(0xfa0ab799, 0x7a9c, 0x48ca, 0x8c, 0x5b, 0x23, 0x7e, 0x71, 0xa5, 0x44, 0x34)] interface IDirect3DCryptoSession9(IDirect3DCryptoSession9Vtbl): IUnknown(IUnknownVtbl) { fn GetCertificateSize( pCertificateSize: *mut UINT, @@ -1273,7 +1264,6 @@ pReadbackKey: *mut VOID, KeySize: UINT, ) -> HRESULT, -} -); +}} pub type LPDIRECT3DCRYPTOSESSION9 = *mut IDirect3DCryptoSession9; pub type PDIRECT3DCRYPTOSESSION9 = *mut IDirect3DCryptoSession9; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/d3d9types.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/d3d9types.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/d3d9types.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/d3d9types.rs 2018-12-05 01:24:41.000000000 +0000 @@ -12,6 +12,35 @@ use shared::windef::HWND; use um::winnt::{HANDLE, HRESULT, LARGE_INTEGER, LONG, SHORT}; pub type D3DCOLOR = DWORD; +#[inline] +pub fn D3DCOLOR_ARGB(a: DWORD, r: DWORD, g: DWORD, b: DWORD) -> D3DCOLOR { + (((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff)) as D3DCOLOR +} +#[inline] +pub fn D3DCOLOR_RGBA(r: DWORD, g: DWORD, b: DWORD, a: DWORD) -> D3DCOLOR { + D3DCOLOR_ARGB(a, r, g, b) +} +#[inline] +pub fn D3DCOLOR_XRGB(r: DWORD, g: DWORD, b: DWORD) -> D3DCOLOR { + D3DCOLOR_ARGB(0xff, r, g, b) +} +#[inline] +pub fn D3DCOLOR_XYUV(y: DWORD, u: DWORD, v: DWORD) -> D3DCOLOR { + D3DCOLOR_ARGB(0xff, y, u, v) +} +#[inline] +pub fn D3DCOLOR_AYUV(a: DWORD, y: DWORD, u: DWORD, v: DWORD) -> D3DCOLOR { + D3DCOLOR_ARGB(a, y, u, v) +} +#[inline] +pub fn D3DCOLOR_COLORVALUE(r: f32, g: f32, b: f32, a: f32) -> D3DCOLOR { + D3DCOLOR_ARGB( + (r * 255f32) as DWORD, + (g * 255f32) as DWORD, + (b * 255f32) as DWORD, + (a * 255f32) as DWORD, + ) +} STRUCT!{struct D3DVECTOR { x: c_float, y: c_float, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi1_2.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi1_2.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi1_2.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi1_2.rs 2018-12-05 01:24:41.000000000 +0000 @@ -138,13 +138,13 @@ Scaling: DXGI_MODE_SCALING, Windowed: BOOL, }} -RIDL!(#[uuid(0x0aa1ae0a, 0xfa0e, 0x4b84, 0x86, 0x44, 0xe0, 0x5f, 0xf8, 0xe5, 0xac, 0xb5)] +RIDL!{#[uuid(0x0aa1ae0a, 0xfa0e, 0x4b84, 0x86, 0x44, 0xe0, 0x5f, 0xf8, 0xe5, 0xac, 0xb5)] interface IDXGIAdapter2(IDXGIAdapter2Vtbl): IDXGIAdapter1(IDXGIAdapter1Vtbl) { fn GetDesc2( pDesc: *mut DXGI_ADAPTER_DESC2, ) -> HRESULT, -}); -RIDL!(#[uuid(0x05008617, 0xfbfd, 0x4051, 0xa7, 0x90, 0x14, 0x48, 0x84, 0xb4, 0xf6, 0xa9)] +}} +RIDL!{#[uuid(0x05008617, 0xfbfd, 0x4051, 0xa7, 0x90, 0x14, 0x48, 0x84, 0xb4, 0xf6, 0xa9)] interface IDXGIDevice2(IDXGIDevice2Vtbl): IDXGIDevice1(IDXGIDevice1Vtbl) { fn OfferResources( NumResources: UINT, @@ -159,15 +159,15 @@ fn EnqueueSetEvent( hEvent: HANDLE, ) -> HRESULT, -}); -RIDL!(#[uuid(0xea9dbf1a, 0xc88e, 0x4486, 0x85, 0x4a, 0x98, 0xaa, 0x01, 0x38, 0xf3, 0x0c)] +}} +RIDL!{#[uuid(0xea9dbf1a, 0xc88e, 0x4486, 0x85, 0x4a, 0x98, 0xaa, 0x01, 0x38, 0xf3, 0x0c)] interface IDXGIDisplayControl(IDXGIDisplayControlVtbl): IUnknown(IUnknownVtbl) { fn IsStereoEnabled() -> BOOL, fn SetStereoEnabled( enabled: BOOL, ) -> (), -}); -RIDL!(#[uuid(0x50c83a1c, 0xe072, 0x4c48, 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0)] +}} +RIDL!{#[uuid(0x50c83a1c, 0xe072, 0x4c48, 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0)] interface IDXGIFactory2(IDXGIFactory2Vtbl): IDXGIFactory1(IDXGIFactory1Vtbl) { fn IsWindowedStereoEnabled() -> BOOL, fn CreateSwapChainForHwnd( @@ -219,8 +219,8 @@ pRestrictToOutput: *mut IDXGIOutput, ppSwapChain: *mut *mut IDXGISwapChain1, ) -> HRESULT, -}); -RIDL!(#[uuid(0x00cddea8, 0x939b, 0x4b83, 0xa3, 0x40, 0xa6, 0x85, 0x22, 0x66, 0x66, 0xcc)] +}} +RIDL!{#[uuid(0x00cddea8, 0x939b, 0x4b83, 0xa3, 0x40, 0xa6, 0x85, 0x22, 0x66, 0x66, 0xcc)] interface IDXGIOutput1(IDXGIOutput1Vtbl): IDXGIOutput(IDXGIOutputVtbl) { fn GetDisplayModeList1( EnumFormat: DXGI_FORMAT, @@ -240,8 +240,8 @@ pDevice: *mut IUnknown, ppOutputDuplication: *mut *mut IDXGIOutputDuplication, ) -> HRESULT, -}); -RIDL!(#[uuid(0x191cfac3, 0xa341, 0x470d, 0xb2, 0x6e, 0xa8, 0x64, 0xf4, 0x28, 0x31, 0x9c)] +}} +RIDL!{#[uuid(0x191cfac3, 0xa341, 0x470d, 0xb2, 0x6e, 0xa8, 0x64, 0xf4, 0x28, 0x31, 0x9c)] interface IDXGIOutputDuplication(IDXGIOutputDuplicationVtbl): IDXGIObject(IDXGIObjectVtbl) { fn GetDesc( pDesc: *mut DXGI_OUTDUPL_DESC, @@ -272,8 +272,8 @@ ) -> HRESULT, fn UnMapDesktopSurface() -> HRESULT, fn ReleaseFrame() -> HRESULT, -}); -RIDL!(#[uuid(0x30961379, 0x4609, 0x4a41, 0x99, 0x8e, 0x54, 0xfe, 0x56, 0x7e, 0xe0, 0xc1)] +}} +RIDL!{#[uuid(0x30961379, 0x4609, 0x4a41, 0x99, 0x8e, 0x54, 0xfe, 0x56, 0x7e, 0xe0, 0xc1)] interface IDXGIResource1(IDXGIResource1Vtbl): IDXGIResource(IDXGIResourceVtbl) { fn CreateSubresourceSurface( index: UINT, @@ -285,16 +285,16 @@ lpName: LPCWSTR, pHandle: *mut HANDLE, ) -> HRESULT, -}); -RIDL!(#[uuid(0xaba496dd, 0xb617, 0x4cb8, 0xa8, 0x66, 0xbc, 0x44, 0xd7, 0xeb, 0x1f, 0xa2)] +}} +RIDL!{#[uuid(0xaba496dd, 0xb617, 0x4cb8, 0xa8, 0x66, 0xbc, 0x44, 0xd7, 0xeb, 0x1f, 0xa2)] interface IDXGISurface2(IDXGISurface2Vtbl): IDXGISurface1(IDXGISurface1Vtbl) { fn GetResource( riid: REFGUID, ppParentResource: *mut *mut c_void, pSubresourceIndex: *mut UINT, ) -> HRESULT, -}); -RIDL!(#[uuid(0x790a45f7, 0x0d42, 0x4876, 0x98, 0x3a, 0x0a, 0x55, 0xcf, 0xe6, 0xf4, 0xaa)] +}} +RIDL!{#[uuid(0x790a45f7, 0x0d42, 0x4876, 0x98, 0x3a, 0x0a, 0x55, 0xcf, 0xe6, 0xf4, 0xaa)] interface IDXGISwapChain1(IDXGISwapChain1Vtbl): IDXGISwapChain(IDXGISwapChainVtbl) { fn GetDesc1( pDesc: *mut DXGI_SWAP_CHAIN_DESC1, @@ -330,7 +330,7 @@ fn GetRotation( pRotation: *mut DXGI_MODE_ROTATION, ) -> HRESULT, -}); +}} pub type DXGI_OFFER_RESOURCE_PRIORITY = _DXGI_OFFER_RESOURCE_PRIORITY; pub const DXGI_ENUM_MODES_DISABLED_STEREO: UINT = 8; pub const DXGI_ENUM_MODES_STEREO: UINT = 4; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi1_3.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi1_3.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi1_3.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi1_3.rs 2018-12-05 01:24:41.000000000 +0000 @@ -52,7 +52,7 @@ _31: FLOAT, _32: FLOAT, }} -RIDL!(#[uuid(0x2633066b, 0x4514, 0x4c7a, 0x8f, 0xd8, 0x12, 0xea, 0x98, 0x05, 0x9d, 0x18)] +RIDL!{#[uuid(0x2633066b, 0x4514, 0x4c7a, 0x8f, 0xd8, 0x12, 0xea, 0x98, 0x05, 0x9d, 0x18)] interface IDXGIDecodeSwapChain(IDXGIDecodeSwapChainVtbl): IUnknown(IUnknownVtbl) { fn PresentBuffer( BufferToPresent: UINT, @@ -83,7 +83,7 @@ ColorSpace: DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAGS, ) -> HRESULT, fn GetColorSpace() -> DXGI_MULTIPLANE_OVERLAY_YCbCr_FLAGS, -}); +}} extern "system" { pub fn CreateDXGIFactory2( Flags: UINT, @@ -96,15 +96,15 @@ pDebug: *mut *mut c_void, ) -> HRESULT; } -RIDL!(#[uuid(0x6007896c, 0x3244, 0x4afd, 0xbf, 0x18, 0xa6, 0xd3, 0xbe, 0xda, 0x50, 0x23)] +RIDL!{#[uuid(0x6007896c, 0x3244, 0x4afd, 0xbf, 0x18, 0xa6, 0xd3, 0xbe, 0xda, 0x50, 0x23)] interface IDXGIDevice3(IDXGIDevice3Vtbl): IDXGIDevice2(IDXGIDevice2Vtbl) { fn Trim() -> (), -}); -RIDL!(#[uuid(0x25483823, 0xcd46, 0x4c7d, 0x86, 0xca, 0x47, 0xaa, 0x95, 0xb8, 0x37, 0xbd)] +}} +RIDL!{#[uuid(0x25483823, 0xcd46, 0x4c7d, 0x86, 0xca, 0x47, 0xaa, 0x95, 0xb8, 0x37, 0xbd)] interface IDXGIFactory3(IDXGIFactory3Vtbl): IDXGIFactory2(IDXGIFactory2Vtbl) { fn GetCreationFlags() -> UINT, -}); -RIDL!(#[uuid(0x41e7d1f2, 0xa591, 0x4f7b, 0xa2, 0xe5, 0xfa, 0x9c, 0x84, 0x3e, 0x1c, 0x12)] +}} +RIDL!{#[uuid(0x41e7d1f2, 0xa591, 0x4f7b, 0xa2, 0xe5, 0xfa, 0x9c, 0x84, 0x3e, 0x1c, 0x12)] interface IDXGIFactoryMedia(IDXGIFactoryMediaVtbl): IUnknown(IUnknownVtbl) { fn CreateSwapChainForCompositionSurfaceHandle( pDevice: *mut IUnknown, @@ -121,20 +121,20 @@ pRestrictToOutput: *mut IDXGIOutput, ppSwapChain: *mut *mut IDXGIDecodeSwapChain, ) -> HRESULT, -}); -RIDL!(#[uuid(0x595e39d1, 0x2724, 0x4663, 0x99, 0xb1, 0xda, 0x96, 0x9d, 0xe2, 0x83, 0x64)] +}} +RIDL!{#[uuid(0x595e39d1, 0x2724, 0x4663, 0x99, 0xb1, 0xda, 0x96, 0x9d, 0xe2, 0x83, 0x64)] interface IDXGIOutput2(IDXGIOutput2Vtbl): IDXGIOutput1(IDXGIOutput1Vtbl) { fn SupportsOverlays() -> BOOL, -}); -RIDL!(#[uuid(0x8a6bb301, 0x7e7e, 0x41f4, 0xa8, 0xe0, 0x5b, 0x32, 0xf7, 0xf9, 0x9b, 0x18)] +}} +RIDL!{#[uuid(0x8a6bb301, 0x7e7e, 0x41f4, 0xa8, 0xe0, 0x5b, 0x32, 0xf7, 0xf9, 0x9b, 0x18)] interface IDXGIOutput3(IDXGIOutput3Vtbl): IDXGIOutput2(IDXGIOutput2Vtbl) { fn CheckOverlaySupport( EnumFormat: DXGI_FORMAT, pConcernedDevice: *mut IUnknown, pFlags: *mut UINT, ) -> HRESULT, -}); -RIDL!(#[uuid(0xa8be2ac4, 0x199f, 0x4946, 0xb3, 0x31, 0x79, 0x59, 0x9f, 0xb9, 0x8d, 0xe7)] +}} +RIDL!{#[uuid(0xa8be2ac4, 0x199f, 0x4946, 0xb3, 0x31, 0x79, 0x59, 0x9f, 0xb9, 0x8d, 0xe7)] interface IDXGISwapChain2(IDXGISwapChain2Vtbl): IDXGISwapChain1(IDXGISwapChain1Vtbl) { fn SetSourceSize( Width: UINT, @@ -157,8 +157,8 @@ fn GetMatrixTransform( pMatrix: *mut DXGI_MATRIX_3X2_F, ) -> HRESULT, -}); -RIDL!(#[uuid(0xdd95b90b, 0xf05f, 0x4f6a, 0xbd, 0x65, 0x25, 0xbf, 0xb2, 0x64, 0xbd, 0x84)] +}} +RIDL!{#[uuid(0xdd95b90b, 0xf05f, 0x4f6a, 0xbd, 0x65, 0x25, 0xbf, 0xb2, 0x64, 0xbd, 0x84)] interface IDXGISwapChainMedia(IDXGISwapChainMediaVtbl): IUnknown(IUnknownVtbl) { fn GetFrameStatisticsMedia( pStats: *mut DXGI_FRAME_STATISTICS_MEDIA, @@ -171,7 +171,7 @@ pClosestSmallerPresentDuration: *mut UINT, pClosestLargerPresentDuration: *mut UINT, ) -> HRESULT, -}); +}} pub const DXGI_CREATE_FACTORY_DEBUG: UINT = 0x1; DEFINE_GUID!{IID_IDXGIDevice3, 0x6007896c, 0x3244, 0x4afd, 0xbf, 0x18, 0xa6, 0xd3, 0xbe, 0xda, 0x50, 0x23} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi1_4.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi1_4.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi1_4.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi1_4.rs 2018-12-05 01:24:41.000000000 +0000 @@ -35,7 +35,7 @@ AvailableForReservation: UINT64, CurrentReservation: UINT64, }} -RIDL!(#[uuid(0x645967a4, 0x1392, 0x4310, 0xa7, 0x98, 0x80, 0x53, 0xce, 0x3e, 0x93, 0xfd)] +RIDL!{#[uuid(0x645967a4, 0x1392, 0x4310, 0xa7, 0x98, 0x80, 0x53, 0xce, 0x3e, 0x93, 0xfd)] interface IDXGIAdapter3(IDXGIAdapter3Vtbl): IDXGIAdapter2(IDXGIAdapter2Vtbl) { fn RegisterHardwareContentProtectionTeardownStatusEvent( hEvent: HANDLE, @@ -61,8 +61,8 @@ fn UnregisterVideoMemoryBudgetChangeNotification( dwCookie: DWORD, ) -> (), -}); -RIDL!(#[uuid(0x1bc6ea02, 0xef36, 0x464f, 0xbf, 0x0c, 0x21, 0xca, 0x39, 0xe5, 0x16, 0x8a)] +}} +RIDL!{#[uuid(0x1bc6ea02, 0xef36, 0x464f, 0xbf, 0x0c, 0x21, 0xca, 0x39, 0xe5, 0x16, 0x8a)] interface IDXGIFactory4(IDXGIFactory4Vtbl): IDXGIFactory3(IDXGIFactory3Vtbl) { fn EnumAdapterByLuid( AdapterLuid: LUID, @@ -73,8 +73,8 @@ riid: REFGUID, ppvAdapter: *mut *mut c_void, ) -> HRESULT, -}); -RIDL!(#[uuid(0xdc7dca35, 0x2196, 0x414d, 0x9f, 0x53, 0x61, 0x78, 0x84, 0x03, 0x2a, 0x60)] +}} +RIDL!{#[uuid(0xdc7dca35, 0x2196, 0x414d, 0x9f, 0x53, 0x61, 0x78, 0x84, 0x03, 0x2a, 0x60)] interface IDXGIOutput4(IDXGIOutput4Vtbl): IDXGIOutput3(IDXGIOutput3Vtbl) { fn CheckOverlayColorSpaceSupport( Format: DXGI_FORMAT, @@ -82,8 +82,8 @@ pConcernedDevice: *mut IUnknown, pFlags: *mut UINT, ) -> HRESULT, -}); -RIDL!(#[uuid(0x94d99bdb, 0xf1f8, 0x4ab0, 0xb2, 0x36, 0x7d, 0xa0, 0x17, 0x0e, 0xda, 0xb1)] +}} +RIDL!{#[uuid(0x94d99bdb, 0xf1f8, 0x4ab0, 0xb2, 0x36, 0x7d, 0xa0, 0x17, 0x0e, 0xda, 0xb1)] interface IDXGISwapChain3(IDXGISwapChain3Vtbl): IDXGISwapChain2(IDXGISwapChain2Vtbl) { fn GetCurrentBackBufferIndex() -> UINT, fn CheckColorSpaceSupport( @@ -102,7 +102,7 @@ pCreationNodeMask: *const UINT, ppPresentQueue: *mut *mut IUnknown, ) -> HRESULT, -}); +}} DEFINE_GUID!{IID_IDXGISwapChain3, 0x94d99bdb, 0xf1f8, 0x4ab0, 0xb2, 0x36, 0x7d, 0xa0, 0x17, 0x0e, 0xda, 0xb1} DEFINE_GUID!{IID_IDXGIOutput4, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi1_5.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi1_5.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi1_5.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi1_5.rs 2018-12-05 01:24:41.000000000 +0000 @@ -18,7 +18,7 @@ use shared::minwindef::UINT; use um::unknwnbase::IUnknown; use um::winnt::HRESULT; -RIDL!(#[uuid(0x80a07424, 0xab52, 0x42eb, 0x83, 0x3c, 0x0c, 0x42, 0xfd, 0x28, 0x2d, 0x98)] +RIDL!{#[uuid(0x80a07424, 0xab52, 0x42eb, 0x83, 0x3c, 0x0c, 0x42, 0xfd, 0x28, 0x2d, 0x98)] interface IDXGIOutput5(IDXGIOutput5Vtbl): IDXGIOutput4(IDXGIOutput4Vtbl) { fn DuplicateOutput1( pDevice: *mut IUnknown, @@ -27,7 +27,7 @@ pSupportedFormats: *const DXGI_FORMAT, ppOutputDuplication: *mut *mut IDXGIOutputDuplication, )-> HRESULT, -}); +}} ENUM!{enum DXGI_HDR_METADATA_TYPE { DXGI_HDR_METADATA_TYPE_NONE = 0, DXGI_HDR_METADATA_TYPE_HDR10 = 1, @@ -42,14 +42,14 @@ MaxContentLightLevel: UINT16, MaxFrameAverageLightLevel: UINT16, }} -RIDL!(#[uuid(0x3d585d5a, 0xbd4a, 0x489e, 0xb1, 0xf4, 0x3d, 0xbc, 0xb6, 0x45, 0x2f, 0xfb)] +RIDL!{#[uuid(0x3d585d5a, 0xbd4a, 0x489e, 0xb1, 0xf4, 0x3d, 0xbc, 0xb6, 0x45, 0x2f, 0xfb)] interface IDXGISwapChain4(IDXGISwapChain4Vtbl): IDXGISwapChain3(IDXGISwapChain3Vtbl) { fn SetHDRMetaData( Type: DXGI_HDR_METADATA_TYPE, Size: UINT, pMetaData: *mut c_void, )-> HRESULT, -}); +}} ENUM!{enum DXGI_OFFER_RESOURCE_FLAGS { DXGI_OFFER_RESOURCE_FLAG_ALLOW_DECOMMIT = 0x1, }} @@ -58,7 +58,7 @@ DXGI_RECLAIM_RESOURCE_RESULT_DISCARDED = 1, DXGI_RECLAIM_RESOURCE_RESULT_NOT_COMMITTED = 2, }} -RIDL!(#[uuid(0x95b4f95f, 0xd8da, 0x4ca4, 0x9e, 0xe6, 0x3b, 0x76, 0xd5, 0x96, 0x8a, 0x10)] +RIDL!{#[uuid(0x95b4f95f, 0xd8da, 0x4ca4, 0x9e, 0xe6, 0x3b, 0x76, 0xd5, 0x96, 0x8a, 0x10)] interface IDXGIDevice4(IDXGIDevice4Vtbl): IDXGIDevice3(IDXGIDevice3Vtbl) { fn OfferResources1( NumResources: UINT, @@ -71,18 +71,18 @@ ppResources: *mut *mut IDXGIResource, pResults: *mut DXGI_RECLAIM_RESOURCE_RESULTS, ) -> HRESULT, -}); +}} ENUM!{enum DXGI_FEATURE { DXGI_FEATURE_PRESENT_ALLOW_TEARING = 0, }} -RIDL!(#[uuid(0x7632e1f5, 0xee65, 0x4dca, 0x87, 0xfd, 0x84, 0xcd, 0x75, 0xf8, 0x83, 0x8d)] +RIDL!{#[uuid(0x7632e1f5, 0xee65, 0x4dca, 0x87, 0xfd, 0x84, 0xcd, 0x75, 0xf8, 0x83, 0x8d)] interface IDXGIFactory5(IDXGIFactory5Vtbl): IDXGIFactory4(IDXGIFactory4Vtbl) { fn CheckFeatureSupport( Feature: DXGI_FEATURE, pFeatureSupportData: *mut c_void, FeatureSupportDataSize: UINT, ) -> HRESULT, -}); +}} DEFINE_GUID!{IID_IDXGIOutput5, 0x80A07424, 0xAB52, 0x42EB, 0x83, 0x3C, 0x0C, 0x42, 0xFD, 0x28, 0x2D, 0x98} DEFINE_GUID!{IID_IDXGISwapChain4, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi1_6.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi1_6.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi1_6.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi1_6.rs 2018-12-05 01:24:41.000000000 +0000 @@ -5,13 +5,15 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. //! Mappings for the contents of dxgi1_6.h +use ctypes::c_void; use shared::basetsd::SIZE_T; use shared::dxgi1_2::{ DXGI_COMPUTE_PREEMPTION_GRANULARITY, DXGI_GRAPHICS_PREEMPTION_GRANULARITY, }; use shared::dxgi1_4::{IDXGIAdapter3, IDXGIAdapter3Vtbl}; -use shared::dxgi1_5::{IDXGIOutput5, IDXGIOutput5Vtbl}; +use shared::dxgi1_5::{IDXGIFactory5, IDXGIFactory5Vtbl, IDXGIOutput5, IDXGIOutput5Vtbl}; use shared::dxgitype::{DXGI_COLOR_SPACE_TYPE, DXGI_MODE_ROTATION}; +use shared::guiddef::REFIID; use shared::minwindef::{BOOL, FLOAT, UINT}; use shared::windef::{HMONITOR, RECT}; use um::winnt::{HRESULT, LUID, WCHAR}; @@ -39,12 +41,12 @@ GraphicsPreemptionGranularity: DXGI_GRAPHICS_PREEMPTION_GRANULARITY, ComputePreemptionGranularity: DXGI_COMPUTE_PREEMPTION_GRANULARITY, }} -RIDL!(#[uuid(0x3c8d99d1, 0x4fbf, 0x4181, 0xa8, 0x2c, 0xaf, 0x66, 0xbf, 0x7b, 0xd2, 0x4e)] +RIDL!{#[uuid(0x3c8d99d1, 0x4fbf, 0x4181, 0xa8, 0x2c, 0xaf, 0x66, 0xbf, 0x7b, 0xd2, 0x4e)] interface IDXGIAdapter4(IDXGIAdapter4Vtbl): IDXGIAdapter3(IDXGIAdapter3Vtbl) { fn GetDesc3( pDesc: *mut DXGI_ADAPTER_DESC3, ) -> HRESULT, -}); +}} STRUCT!{struct DXGI_OUTPUT_DESC1 { DeviceName: [WCHAR; 32], DesktopCoordinates: RECT, @@ -66,7 +68,7 @@ DXGI_HARDWARE_COMPOSITION_SUPPORT_FLAG_WINDOWED = 2, DXGI_HARDWARE_COMPOSITION_SUPPORT_FLAG_CURSOR_STRETCHED = 4, }} -RIDL!(#[uuid(0x068346e8, 0xaaec, 0x4b84, 0xad, 0xd7, 0x13, 0x7f, 0x51, 0x3f, 0x77, 0xa1)] +RIDL!{#[uuid(0x068346e8, 0xaaec, 0x4b84, 0xad, 0xd7, 0x13, 0x7f, 0x51, 0x3f, 0x77, 0xa1)] interface IDXGIOutput6(IDXGIOutput6Vtbl): IDXGIOutput5(IDXGIOutput5Vtbl) { fn GetDesc1( pDesc: *mut DXGI_OUTPUT_DESC1, @@ -74,8 +76,24 @@ fn CheckHardwareCompositionSupport( pFlags: *mut UINT, ) -> HRESULT, -}); +}} +ENUM!{enum DXGI_GPU_PREFERENCE { + DXGI_GPU_PREFERENCE_UNSPECIFIED = 0, + DXGI_GPU_PREFERENCE_MINIMUM_POWER = 1, + DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE = 2, +}} +RIDL!{#[uuid(0xc1b6694f, 0xff09, 0x44a9, 0xb0, 0x3c, 0x77, 0x90, 0x0a, 0x0a, 0x1d, 0x17)] +interface IDXGIFactory6(IDXGIFactory6Vtbl): IDXGIFactory5(IDXGIFactory5Vtbl) { + fn EnumAdapterByGpuPreference( + Adapter: UINT, + GpuPreference: DXGI_GPU_PREFERENCE, + riid: REFIID, + ppvAdapter: *mut *mut c_void, + ) -> HRESULT, +}} DEFINE_GUID!{IID_IDXGIAdapter4, 0x3c8d99d1, 0x4fbf, 0x4181, 0xa8, 0x2c, 0xaf, 0x66, 0xbf, 0x7b, 0xd2, 0x4e} DEFINE_GUID!{IID_IDXGIOutput6, 0x068346e8, 0xaaec, 0x4b84, 0xad, 0xd7, 0x13, 0x7f, 0x51, 0x3f, 0x77, 0xa1} +DEFINE_GUID!{IID_IDXGIFactory6, + 0xc1b6694f, 0xff09, 0x44a9, 0xb0, 0x3c, 0x77, 0x90, 0x0a, 0x0a, 0x1d, 0x17} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/dxgi.rs 2018-12-05 01:24:41.000000000 +0000 @@ -95,7 +95,7 @@ SwapEffect: DXGI_SWAP_EFFECT, Flags: UINT, }} -RIDL!(#[uuid(0xaec22fb8, 0x76f3, 0x4639, 0x9b, 0xe0, 0x28, 0xeb, 0x43, 0xa6, 0x7a, 0x2e)] +RIDL!{#[uuid(0xaec22fb8, 0x76f3, 0x4639, 0x9b, 0xe0, 0x28, 0xeb, 0x43, 0xa6, 0x7a, 0x2e)] interface IDXGIObject(IDXGIObjectVtbl): IUnknown(IUnknownVtbl) { fn SetPrivateData( Name: REFGUID, @@ -115,15 +115,15 @@ riid: REFIID, ppParent: *mut *mut c_void, ) -> HRESULT, -}); -RIDL!(#[uuid(0x3d3e0379, 0xf9de, 0x4d58, 0xbb, 0x6c, 0x18, 0xd6, 0x29, 0x92, 0xf1, 0xa6)] +}} +RIDL!{#[uuid(0x3d3e0379, 0xf9de, 0x4d58, 0xbb, 0x6c, 0x18, 0xd6, 0x29, 0x92, 0xf1, 0xa6)] interface IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl): IDXGIObject(IDXGIObjectVtbl) { fn GetDevice( riid: REFIID, ppDevice: *mut *mut c_void, ) -> HRESULT, -}); -RIDL!(#[uuid(0x035f3ab4, 0x482e, 0x4e50, 0xb4, 0x1f, 0x8a, 0x7f, 0x8b, 0xd8, 0x96, 0x0b)] +}} +RIDL!{#[uuid(0x035f3ab4, 0x482e, 0x4e50, 0xb4, 0x1f, 0x8a, 0x7f, 0x8b, 0xd8, 0x96, 0x0b)] interface IDXGIResource(IDXGIResourceVtbl): IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl) { fn GetSharedHandle( pSharedHandle: *mut HANDLE, @@ -137,8 +137,8 @@ fn GetEvictionPriority( pEvictionPriority: *mut UINT, ) -> HRESULT, -}); -RIDL!(#[uuid(0x9d8e1289, 0xd7b3, 0x465f, 0x81, 0x26, 0x25, 0x0e, 0x34, 0x9a, 0xf8, 0x5d)] +}} +RIDL!{#[uuid(0x9d8e1289, 0xd7b3, 0x465f, 0x81, 0x26, 0x25, 0x0e, 0x34, 0x9a, 0xf8, 0x5d)] interface IDXGIKeyedMutex(IDXGIKeyedMutexVtbl): IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl) { fn AcquireSync( Key: UINT64, @@ -147,11 +147,11 @@ fn ReleaseSync( Key: UINT64, ) -> HRESULT, -}); +}} pub const DXGI_MAP_READ: UINT = 1; pub const DXGI_MAP_WRITE: UINT = 2; pub const DXGI_MAP_DISCARD: UINT = 4; -RIDL!(#[uuid(0xcafcb56c, 0x6ac3, 0x4889, 0xbf, 0x47, 0x9e, 0x23, 0xbb, 0xd2, 0x60, 0xec)] +RIDL!{#[uuid(0xcafcb56c, 0x6ac3, 0x4889, 0xbf, 0x47, 0x9e, 0x23, 0xbb, 0xd2, 0x60, 0xec)] interface IDXGISurface(IDXGISurfaceVtbl): IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl) { fn GetDesc( pDesc: *mut DXGI_SURFACE_DESC, @@ -161,8 +161,8 @@ MapFlags: UINT, ) -> HRESULT, fn Unmap() -> HRESULT, -}); -RIDL!(#[uuid(0x4ae63092, 0x6327, 0x4c1b, 0x80, 0xae, 0xbf, 0xe1, 0x2e, 0xa3, 0x2b, 0x86)] +}} +RIDL!{#[uuid(0x4ae63092, 0x6327, 0x4c1b, 0x80, 0xae, 0xbf, 0xe1, 0x2e, 0xa3, 0x2b, 0x86)] interface IDXGISurface1(IDXGISurface1Vtbl): IDXGISurface(IDXGISurfaceVtbl) { fn GetDC( Discard: BOOL, @@ -171,8 +171,8 @@ fn ReleaseDC( pDirtyRect: *mut RECT, ) -> HRESULT, -}); -RIDL!(#[uuid(0x2411e7e1, 0x12ac, 0x4ccf, 0xbd, 0x14, 0x97, 0x98, 0xe8, 0x53, 0x4d, 0xc0)] +}} +RIDL!{#[uuid(0x2411e7e1, 0x12ac, 0x4ccf, 0xbd, 0x14, 0x97, 0x98, 0xe8, 0x53, 0x4d, 0xc0)] interface IDXGIAdapter(IDXGIAdapterVtbl): IDXGIObject(IDXGIObjectVtbl) { fn EnumOutputs( Output: UINT, @@ -185,8 +185,8 @@ InterfaceName: REFGUID, pUMDVersion: *mut LARGE_INTEGER, ) -> HRESULT, -}); -RIDL!(#[uuid(0xae02eedb, 0xc735, 0x4690, 0x8d, 0x52, 0x5a, 0x8d, 0xc2, 0x02, 0x13, 0xaa)] +}} +RIDL!{#[uuid(0xae02eedb, 0xc735, 0x4690, 0x8d, 0x52, 0x5a, 0x8d, 0xc2, 0x02, 0x13, 0xaa)] interface IDXGIOutput(IDXGIOutputVtbl): IDXGIObject(IDXGIObjectVtbl) { fn GetDesc( pDesc: *mut DXGI_OUTPUT_DESC, @@ -226,7 +226,7 @@ fn GetFrameStatistics( pStats: *mut DXGI_FRAME_STATISTICS, ) -> HRESULT, -}); +}} pub const DXGI_MAX_SWAP_CHAIN_BUFFERS: DWORD = 16; pub const DXGI_PRESENT_TEST: DWORD = 0x00000001; pub const DXGI_PRESENT_DO_NOT_SEQUENCE: DWORD = 0x00000002; @@ -236,9 +236,10 @@ pub const DXGI_PRESENT_STEREO_TEMPORARY_MONO: DWORD = 0x00000020; pub const DXGI_PRESENT_RESTRICT_TO_OUTPUT: DWORD = 0x00000040; pub const DXGI_PRESENT_USE_DURATION: DWORD = 0x00000100; +pub const DXGI_PRESENT_ALLOW_TEARING: DWORD = 0x00000200; pub const DXGI_ENUM_MODES_INTERLACED: UINT = 1; pub const DXGI_ENUM_MODES_SCALING: UINT = 2; -RIDL!(#[uuid(0x310d36a0, 0xd2e7, 0x4c0a, 0xaa, 0x04, 0x6a, 0x9d, 0x23, 0xb8, 0x88, 0x6a)] +RIDL!{#[uuid(0x310d36a0, 0xd2e7, 0x4c0a, 0xaa, 0x04, 0x6a, 0x9d, 0x23, 0xb8, 0x88, 0x6a)] interface IDXGISwapChain(IDXGISwapChainVtbl): IDXGIDeviceSubObject(IDXGIDeviceSubObjectVtbl) { fn Present( SyncInterval: UINT, @@ -279,8 +280,8 @@ fn GetLastPresentCount( pLastPresentCount: *mut UINT, ) -> HRESULT, -}); -RIDL!(#[uuid(0x7b7166ec, 0x21c7, 0x44ae, 0xb2, 0x1a, 0xc9, 0xae, 0x32, 0x1a, 0xe3, 0x69)] +}} +RIDL!{#[uuid(0x7b7166ec, 0x21c7, 0x44ae, 0xb2, 0x1a, 0xc9, 0xae, 0x32, 0x1a, 0xe3, 0x69)] interface IDXGIFactory(IDXGIFactoryVtbl): IDXGIObject(IDXGIObjectVtbl) { fn EnumAdapters( Adapter: UINT, @@ -302,7 +303,7 @@ Module: HMODULE, ppAdapter: *mut *mut IDXGIAdapter, ) -> HRESULT, -}); +}} extern "system" { pub fn CreateDXGIFactory( riid: REFIID, @@ -313,7 +314,7 @@ ppFactory: *mut *mut c_void, ) -> HRESULT; } -RIDL!(#[uuid(0x54ec77fa, 0x1377, 0x44e6, 0x8c, 0x32, 0x88, 0xfd, 0x5f, 0x44, 0xc8, 0x4c)] +RIDL!{#[uuid(0x54ec77fa, 0x1377, 0x44e6, 0x8c, 0x32, 0x88, 0xfd, 0x5f, 0x44, 0xc8, 0x4c)] interface IDXGIDevice(IDXGIDeviceVtbl): IDXGIObject(IDXGIObjectVtbl) { fn GetAdapter( pAdapter: *mut *mut IDXGIAdapter, @@ -336,7 +337,7 @@ fn GetGPUThreadPriority( pPriority: *mut INT, ) -> HRESULT, -}); +}} ENUM!{enum DXGI_ADAPTER_FLAG { DXGI_ADAPTER_FLAG_NONE, DXGI_ADAPTER_FLAG_REMOTE, @@ -358,21 +359,21 @@ PrimaryCoordinates: [[FLOAT; 2]; 8], WhitePoints: [[FLOAT; 2]; 16], }} -RIDL!(#[uuid(0x770aae78, 0xf26f, 0x4dba, 0xa8, 0x29, 0x25, 0x3c, 0x83, 0xd1, 0xb3, 0x87)] +RIDL!{#[uuid(0x770aae78, 0xf26f, 0x4dba, 0xa8, 0x29, 0x25, 0x3c, 0x83, 0xd1, 0xb3, 0x87)] interface IDXGIFactory1(IDXGIFactory1Vtbl): IDXGIFactory(IDXGIFactoryVtbl) { fn EnumAdapters1( Adapter: UINT, ppAdapter: *mut *mut IDXGIAdapter1, ) -> HRESULT, fn IsCurrent() -> BOOL, -}); -RIDL!(#[uuid(0x29038f61, 0x3839, 0x4626, 0x91, 0xfd, 0x08, 0x68, 0x79, 0x01, 0x1a, 0x05)] +}} +RIDL!{#[uuid(0x29038f61, 0x3839, 0x4626, 0x91, 0xfd, 0x08, 0x68, 0x79, 0x01, 0x1a, 0x05)] interface IDXGIAdapter1(IDXGIAdapter1Vtbl): IDXGIAdapter(IDXGIAdapterVtbl) { fn GetDesc1( pDesc: *mut DXGI_ADAPTER_DESC1, ) -> HRESULT, -}); -RIDL!(#[uuid(0x77db970f, 0x6276, 0x48ba, 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c)] +}} +RIDL!{#[uuid(0x77db970f, 0x6276, 0x48ba, 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c)] interface IDXGIDevice1(IDXGIDevice1Vtbl): IDXGIDevice(IDXGIDeviceVtbl) { fn SetMaximumFrameLatency( MaxLatency: UINT, @@ -380,7 +381,7 @@ fn GetMaximumFrameLatency( pMaxLatency: *mut UINT, ) -> HRESULT, -}); +}} DEFINE_GUID!{IID_IDXGIObject, 0xaec22fb8, 0x76f3, 0x4639, 0x9b, 0xe0, 0x28, 0xeb, 0x43, 0xa6, 0x7a, 0x2e} DEFINE_GUID!{IID_IDXGIDeviceSubObject, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/evntrace.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/evntrace.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/evntrace.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/evntrace.rs 2018-12-05 01:24:41.000000000 +0000 @@ -32,7 +32,7 @@ pub const EVENT_LOGGER_NAME: &'static str = "EventLog"; pub const DIAG_LOGGER_NAME: &'static str = "DiagLog"; pub const MAX_MOF_FIELDS: SIZE_T = 16; -DECLARE_HANDLE!(TRACEHANDLE, __TRACEHANDLE); +DECLARE_HANDLE!{TRACEHANDLE, __TRACEHANDLE} pub type PTRACEHANDLE = *mut TRACEHANDLE; pub const EVENT_TRACE_TYPE_INFO: DWORD = 0x00; pub const EVENT_TRACE_TYPE_START: DWORD = 0x01; @@ -981,11 +981,11 @@ ... ) -> ULONG; pub fn TraceMessageVa( - SessionHandle: TRACEHANDLE, - MessageFlags: ULONG, - MessageGuid: LPGUID, - MessageNumber: USHORT, - MessageArgList: va_list, + SessionHandle: TRACEHANDLE, + MessageFlags: ULONG, + MessageGuid: LPGUID, + MessageNumber: USHORT, + MessageArgList: va_list, ); } pub const INVALID_PROCESSTRACE_HANDLE: TRACEHANDLE = INVALID_HANDLE_VALUE as TRACEHANDLE; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/ksmedia.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/ksmedia.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/ksmedia.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/ksmedia.rs 2018-12-05 01:24:41.000000000 +0000 @@ -1,10 +1,47 @@ -// Copyright © 2015-2017 winapi-rs developers +// Copyright © 2015-2018 winapi-rs developers // Licensed under the Apache License, Version 2.0 // or the MIT license // , at your option. // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms // Licensed under the MIT License +//! Mappings for the contents of ksmedia.h +DEFINE_GUID!{KSCATEGORY_AUDIO, + 0x6994AD04, 0x93EF, 0x11D0, 0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_VIDEO, + 0x6994AD05, 0x93EF, 0x11D0, 0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_REALTIME, + 0xEB115FFC, 0x10C8, 0x4964, 0x83, 0x1D, 0x6D, 0xCB, 0x02, 0xE6, 0xF2, 0x3F} +DEFINE_GUID!{KSCATEGORY_TEXT, + 0x6994AD06, 0x93EF, 0x11D0, 0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_NETWORK, + 0x67C9CC3C, 0x69C4, 0x11D2, 0x87, 0x59, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_TOPOLOGY, + 0xDDA54A40, 0x1E4C, 0x11D1, 0xA0, 0x50, 0x40, 0x57, 0x05, 0xC1, 0x00, 0x00} +DEFINE_GUID!{KSCATEGORY_VIRTUAL, + 0x3503EAC4, 0x1F26, 0x11D1, 0x8A, 0xB0, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_ACOUSTIC_ECHO_CANCEL, + 0xBF963D80, 0xC559, 0x11D0, 0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1} +DEFINE_GUID!{KSCATEGORY_SYSAUDIO, + 0xA7C7A5B1, 0x5AF3, 0x11D1, 0x9C, 0xED, 0x00, 0xA0, 0x24, 0xBF, 0x04, 0x07} +DEFINE_GUID!{KSCATEGORY_WDMAUD, + 0x3E227E76, 0x690D, 0x11D2, 0x81, 0x61, 0x00, 0x00, 0xF8, 0x77, 0x5B, 0xF1} +DEFINE_GUID!{KSCATEGORY_AUDIO_GFX, + 0x9BAF9572, 0x340C, 0x11D3, 0xAB, 0xDC, 0x00, 0xA0, 0xC9, 0x0A, 0xB1, 0x6F} +DEFINE_GUID!{KSCATEGORY_AUDIO_SPLITTER, + 0x9EA331FA, 0xB91B, 0x45F8, 0x92, 0x85, 0xBD, 0x2B, 0xC7, 0x7A, 0xFC, 0xDE} +DEFINE_GUID!{KSCATEGORY_AUDIO_DEVICE, + 0xFBF6F530, 0x07B9, 0x11D2, 0xA7, 0x1E, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88} +DEFINE_GUID!{KSCATEGORY_PREFERRED_WAVEOUT_DEVICE, + 0xD6C5066E, 0x72C1, 0x11D2, 0x97, 0x55, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88} +DEFINE_GUID!{KSCATEGORY_PREFERRED_WAVEIN_DEVICE, + 0xD6C50671, 0x72C1, 0x11D2, 0x97, 0x55, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88} +DEFINE_GUID!{KSCATEGORY_PREFERRED_MIDIOUT_DEVICE, + 0xD6C50674, 0x72C1, 0x11D2, 0x97, 0x55, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88} +DEFINE_GUID!{KSCATEGORY_WDMAUD_USE_PIN_NAME, + 0x47A4FA20, 0xA251, 0x11D1, 0xA0, 0x50, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88} +DEFINE_GUID!{KSCATEGORY_ESCALANTE_PLATFORM_DRIVER, + 0x74F3AEA8, 0x9768, 0x11D1, 0x8E, 0x07, 0x00, 0xA0, 0xC9, 0x5E, 0xC2, 0x2E} DEFINE_GUID!{KSDATAFORMAT_SUBTYPE_ANALOG, 0x6DBA3190, 0x67BD, 0x11CF, 0xA0, 0xF7, 0x00, 0x20, 0xAF, 0xD1, 0x56, 0xE4} DEFINE_GUID!{KSDATAFORMAT_SUBTYPE_PCM, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/ks.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/ks.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/ks.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/ks.rs 2018-12-05 01:24:41.000000000 +0000 @@ -0,0 +1,64 @@ +// Copyright © 2018 winapi-rs developers +// Licensed under the Apache License, Version 2.0 +// or the MIT license +// , at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms +// Licensed under the MIT License +//! Mappings for the contents of ks.h +DEFINE_GUID!{KSCATEGORY_BRIDGE, + 0x085AFF00, 0x62CE, 0x11CF, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00} +DEFINE_GUID!{KSCATEGORY_CAPTURE, + 0x65E8773D, 0x8F56, 0x11D0, 0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_VIDEO_CAMERA, + 0xe5323777, 0xf976, 0x4f5b, 0x9b, 0x55, 0xb9, 0x46, 0x99, 0xc4, 0x6e, 0x44} +DEFINE_GUID!{KSCATEGORY_SENSOR_CAMERA, + 0x24e552d7, 0x6523, 0x47f7, 0xa6, 0x47, 0xd3, 0x46, 0x5b, 0xf1, 0xf5, 0xca} +DEFINE_GUID!{KSCATEGORY_SENSOR_GROUP, + 0x669C7214, 0x0A88, 0x4311, 0xA7, 0xF3, 0x4E, 0x79, 0x82, 0x0E, 0x33, 0xBD} +DEFINE_GUID!{KSCATEGORY_RENDER, + 0x65E8773E, 0x8F56, 0x11D0, 0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_MIXER, + 0xAD809C00, 0x7B88, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00} +DEFINE_GUID!{KSCATEGORY_SPLITTER, + 0x0A4252A0, 0x7E70, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00} +DEFINE_GUID!{KSCATEGORY_DATACOMPRESSOR, + 0x1E84C900, 0x7E70, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00} +DEFINE_GUID!{KSCATEGORY_DATADECOMPRESSOR, + 0x2721AE20, 0x7E70, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00} +DEFINE_GUID!{KSCATEGORY_DATATRANSFORM, + 0x2EB07EA0, 0x7E70, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00} +DEFINE_GUID!{KSMFT_CATEGORY_VIDEO_DECODER, + 0xd6c02d4b, 0x6833, 0x45b4, 0x97, 0x1a, 0x05, 0xa4, 0xb0, 0x4b, 0xab, 0x91} +DEFINE_GUID!{KSMFT_CATEGORY_VIDEO_ENCODER, + 0xf79eac7d, 0xe545, 0x4387, 0xbd, 0xee, 0xd6, 0x47, 0xd7, 0xbd, 0xe4, 0x2a} +DEFINE_GUID!{KSMFT_CATEGORY_VIDEO_EFFECT, + 0x12e17c21, 0x532c, 0x4a6e, 0x8a, 0x1c, 0x40, 0x82, 0x5a, 0x73, 0x63, 0x97} +DEFINE_GUID!{KSMFT_CATEGORY_MULTIPLEXER, + 0x059c561e, 0x05ae, 0x4b61, 0xb6, 0x9d, 0x55, 0xb6, 0x1e, 0xe5, 0x4a, 0x7b} +DEFINE_GUID!{KSMFT_CATEGORY_DEMULTIPLEXER, + 0xa8700a7a, 0x939b, 0x44c5, 0x99, 0xd7, 0x76, 0x22, 0x6b, 0x23, 0xb3, 0xf1} +DEFINE_GUID!{KSMFT_CATEGORY_AUDIO_DECODER, + 0x9ea73fb4, 0xef7a, 0x4559, 0x8d, 0x5d, 0x71, 0x9d, 0x8f, 0x04, 0x26, 0xc7} +DEFINE_GUID!{KSMFT_CATEGORY_AUDIO_ENCODER, + 0x91c64bd0, 0xf91e, 0x4d8c, 0x92, 0x76, 0xdb, 0x24, 0x82, 0x79, 0xd9, 0x75} +DEFINE_GUID!{KSMFT_CATEGORY_AUDIO_EFFECT, + 0x11064c48, 0x3648, 0x4ed0, 0x93, 0x2e, 0x05, 0xce, 0x8a, 0xc8, 0x11, 0xb7} +DEFINE_GUID!{KSMFT_CATEGORY_VIDEO_PROCESSOR, + 0x302ea3fc, 0xaa5f, 0x47f9, 0x9f, 0x7a, 0xc2, 0x18, 0x8b, 0xb1, 0x63, 0x02} +DEFINE_GUID!{KSMFT_CATEGORY_OTHER, + 0x90175d57, 0xb7ea, 0x4901, 0xae, 0xb3, 0x93, 0x3a, 0x87, 0x47, 0x75, 0x6f} +DEFINE_GUID!{KSCATEGORY_COMMUNICATIONSTRANSFORM, + 0xCF1DDA2C, 0x9743, 0x11D0, 0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_INTERFACETRANSFORM, + 0xCF1DDA2D, 0x9743, 0x11D0, 0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_MEDIUMTRANSFORM, + 0xCF1DDA2E, 0x9743, 0x11D0, 0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_FILESYSTEM, + 0x760FED5E, 0x9357, 0x11D0, 0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_CLOCK, + 0x53172480, 0x4791, 0x11D0, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00} +DEFINE_GUID!{KSCATEGORY_PROXY, + 0x97EBAACA, 0x95BD, 0x11D0, 0xA3, 0xEA, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} +DEFINE_GUID!{KSCATEGORY_QUALITY, + 0x97EBAACB, 0x95BD, 0x11D0, 0xA3, 0xEA, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/minwindef.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/minwindef.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/minwindef.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/minwindef.rs 2018-12-05 01:24:41.000000000 +0000 @@ -81,19 +81,19 @@ /// Pointer to a function with unknown type signature. pub type PROC = *mut __some_function; pub type ATOM = WORD; -DECLARE_HANDLE!(HKEY, HKEY__); +DECLARE_HANDLE!{HKEY, HKEY__} pub type PHKEY = *mut HKEY; -DECLARE_HANDLE!(HMETAFILE, HMETAFILE__); -DECLARE_HANDLE!(HINSTANCE, HINSTANCE__); +DECLARE_HANDLE!{HMETAFILE, HMETAFILE__} +DECLARE_HANDLE!{HINSTANCE, HINSTANCE__} pub type HMODULE = HINSTANCE; -DECLARE_HANDLE!(HRGN, HRGN__); -DECLARE_HANDLE!(HRSRC, HRSRC__); -DECLARE_HANDLE!(HSPRITE, HSPRITE__); -DECLARE_HANDLE!(HLSURF, HLSURF__); -DECLARE_HANDLE!(HSTR, HSTR__); -DECLARE_HANDLE!(HTASK, HTASK__); -DECLARE_HANDLE!(HWINSTA, HWINSTA__); -DECLARE_HANDLE!(HKL, HKL__); +DECLARE_HANDLE!{HRGN, HRGN__} +DECLARE_HANDLE!{HRSRC, HRSRC__} +DECLARE_HANDLE!{HSPRITE, HSPRITE__} +DECLARE_HANDLE!{HLSURF, HLSURF__} +DECLARE_HANDLE!{HSTR, HSTR__} +DECLARE_HANDLE!{HTASK, HTASK__} +DECLARE_HANDLE!{HWINSTA, HWINSTA__} +DECLARE_HANDLE!{HKL, HKL__} pub type HFILE = c_int; STRUCT!{#[debug] struct FILETIME { dwLowDateTime: DWORD, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/mod.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/mod.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/mod.rs 2018-12-05 01:24:41.000000000 +0000 @@ -36,6 +36,7 @@ #[cfg(feature = "in6addr")] pub mod in6addr; #[cfg(feature = "inaddr")] pub mod inaddr; #[cfg(feature = "intsafe")] pub mod intsafe; +#[cfg(feature = "ks")] pub mod ks; #[cfg(feature = "ksmedia")] pub mod ksmedia; #[cfg(feature = "ktmtypes")] pub mod ktmtypes; #[cfg(feature = "lmcons")] pub mod lmcons; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/mstcpip.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/mstcpip.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/mstcpip.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/mstcpip.rs 2018-12-05 01:24:41.000000000 +0000 @@ -198,9 +198,9 @@ }} ENUM!{enum SOCKET_SECURITY_PROTOCOL { SOCKET_SECURITY_PROTOCOL_DEFAULT, - SOCKET_SECURITY_PROTOCOL_IPSEC, - SOCKET_SECURITY_PROTOCOL_IPSEC2, - SOCKET_SECURITY_PROTOCOL_INVALID, + SOCKET_SECURITY_PROTOCOL_IPSEC, + SOCKET_SECURITY_PROTOCOL_IPSEC2, + SOCKET_SECURITY_PROTOCOL_INVALID, }} STRUCT!{struct SOCKET_SECURITY_SETTINGS { SecurityProtocol: SOCKET_SECURITY_PROTOCOL, @@ -472,7 +472,7 @@ Port: PUSHORT, ) -> LONG; } -DECLARE_HANDLE!(DL_EUI48, _DL_EUI48); +DECLARE_HANDLE!{DL_EUI48, _DL_EUI48} pub type PDL_EUI48 = *mut DL_EUI48; extern "system" { pub fn RtlEthernetAddressToStringA( diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/ntddscsi.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/ntddscsi.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/ntddscsi.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/ntddscsi.rs 2018-12-05 01:24:41.000000000 +0000 @@ -13,10 +13,10 @@ FILE_WRITE_ACCESS, METHOD_BUFFERED }; use um::winnt::{ANYSIZE_ARRAY, BOOLEAN, PBOOLEAN}; -DEFINE_GUID!(ScsiRawInterfaceGuid, - 0x53f56309, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b); -DEFINE_GUID!(WmiScsiAddressGuid, - 0x53f5630f, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b); +DEFINE_GUID!{ScsiRawInterfaceGuid, + 0x53f56309, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b} +DEFINE_GUID!{WmiScsiAddressGuid, + 0x53f5630f, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b} pub const IOCTL_SCSI_BASE: DEVICE_TYPE = FILE_DEVICE_CONTROLLER; pub const FILE_DEVICE_SCSI: ULONG = 0x0000001; pub const DD_SCSI_DEVICE_NAME: &'static str = "\\Device\\ScsiPort"; @@ -482,13 +482,13 @@ STRUCT!{struct NV_SEP_CACHE_PARAMETER_Flags_CacheFlags { Bitfield: UCHAR, }} -BITFIELD!(NV_SEP_CACHE_PARAMETER_Flags_CacheFlags Bitfield: UCHAR [ +BITFIELD!{NV_SEP_CACHE_PARAMETER_Flags_CacheFlags Bitfield: UCHAR [ WriteCacheEnabled set_WriteCacheEnabled[0..1], WriteCacheChangeable set_WriteCacheChangeable[1..2], WriteThroughIOSupported set_WriteThroughIOSupported[2..3], FlushCacheSupported set_FlushCacheSupported[3..4], ReservedBits set_ReservedBits[4..8], -]); +]} pub const NV_SEP_CACHE_PARAMETER_VERSION_1: ULONG = 1; pub const NV_SEP_CACHE_PARAMETER_VERSION: ULONG = NV_SEP_CACHE_PARAMETER_VERSION_1; ENUM!{enum NV_SEP_WRITE_CACHE_TYPE { @@ -580,13 +580,13 @@ STRUCT!{struct HYBRID_INFORMATION_Attributes { Bitfield: ULONG, }} -BITFIELD!(HYBRID_INFORMATION_Attributes Bitfield: ULONG [ +BITFIELD!{HYBRID_INFORMATION_Attributes Bitfield: ULONG [ WriteCacheChangeable set_WriteCacheChangeable[0..1], WriteThroughIoSupported set_WriteThroughIoSupported[1..2], FlushCacheSupported set_FlushCacheSupported[2..3], Removable set_Removable[3..4], ReservedBits set_ReservedBits[4..32], -]); +]} STRUCT!{struct HYBRID_INFORMATION_Priorities { PriorityLevelCount: UCHAR, MaxPriorityBehavior: BOOLEAN, @@ -603,14 +603,14 @@ MaxLbaRangeCountForEvict: ULONG, MaxLbaRangeCountForChangeLba: ULONG, }} -BITFIELD!(HYBRID_INFORMATION_Priorities_SupportedCommands Bitfield: ULONG [ +BITFIELD!{HYBRID_INFORMATION_Priorities_SupportedCommands Bitfield: ULONG [ CacheDisable set_CacheDisable[0..1], SetDirtyThreshold set_SetDirtyThreshold[1..2], PriorityDemoteBySize set_PriorityDemoteBySize[2..3], PriorityChangeByLbaRange set_PriorityChangeByLbaRange[3..4], Evict set_Evict[4..5], ReservedBits set_ReservedBits[5..32], -]); +]} STRUCT!{struct HYBRID_DIRTY_THRESHOLDS { Version: ULONG, Size: ULONG, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/rpcdce.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/rpcdce.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/rpcdce.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/rpcdce.rs 2018-12-05 01:24:41.000000000 +0000 @@ -5,12 +5,10 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. //! This module contains the DCE RPC runtime APIs. - use ctypes::{c_int, c_uchar, c_uint, c_ulong, c_ushort, c_void, wchar_t}; use shared::guiddef::GUID; use shared::minwindef::DWORD; use shared::rpc::{I_RPC_HANDLE, RPC_STATUS}; - pub type RPC_CSTR = *mut c_uchar; pub type RPC_WSTR = *mut wchar_t; pub type RPC_CWSTR = *const wchar_t; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/rpc.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/rpc.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/rpc.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/rpc.rs 2018-12-05 01:24:41.000000000 +0000 @@ -5,8 +5,6 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. //! Master include file for RPC applications. - use ctypes::{c_long, c_void}; - pub type I_RPC_HANDLE = *mut c_void; pub type RPC_STATUS = c_long; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/sspi.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/sspi.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/sspi.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/sspi.rs 2018-12-05 01:24:41.000000000 +0000 @@ -5,9 +5,8 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. //! Security Support Provider Interface Prototypes and structure definitions - use ctypes::{c_char, c_int, c_uchar, c_ulong, c_ushort, c_void}; -use shared::basetsd::{ULONG_PTR}; +use shared::basetsd::ULONG_PTR; use shared::guiddef::GUID; use shared::minwindef::{PUCHAR, ULONG, USHORT}; use um::subauth::PUNICODE_STRING; @@ -16,7 +15,6 @@ ANYSIZE_ARRAY, BOOLEAN, CHAR, HANDLE, LARGE_INTEGER, LONG, LPSTR, LPWSTR, LUID, PCSTR, PCWSTR, PVOID, WCHAR }; - pub type SEC_WCHAR = WCHAR; pub type SEC_CHAR = CHAR; pub type SECURITY_STATUS = LONG; @@ -980,16 +978,16 @@ AuthData: SEC_WINNT_AUTH_DATA, }} pub type PSEC_WINNT_AUTH_PACKED_CREDENTIALS = *mut SEC_WINNT_AUTH_PACKED_CREDENTIALS; -DEFINE_GUID!(SEC_WINNT_AUTH_DATA_TYPE_PASSWORD, - 0x28bfc32f, 0x10f6, 0x4738, 0x98, 0xd1, 0x1a, 0xc0, 0x61, 0xdf, 0x71, 0x6a); -DEFINE_GUID!(SEC_WINNT_AUTH_DATA_TYPE_CERT, - 0x235f69ad, 0x73fb, 0x4dbc, 0x82, 0x3, 0x6, 0x29, 0xe7, 0x39, 0x33, 0x9b); +DEFINE_GUID!{SEC_WINNT_AUTH_DATA_TYPE_PASSWORD, + 0x28bfc32f, 0x10f6, 0x4738, 0x98, 0xd1, 0x1a, 0xc0, 0x61, 0xdf, 0x71, 0x6a} +DEFINE_GUID!{SEC_WINNT_AUTH_DATA_TYPE_CERT, + 0x235f69ad, 0x73fb, 0x4dbc, 0x82, 0x3, 0x6, 0x29, 0xe7, 0x39, 0x33, 0x9b} STRUCT!{struct SEC_WINNT_AUTH_DATA_PASSWORD { UnicodePassword: SEC_WINNT_AUTH_BYTE_VECTOR, }} pub type PSEC_WINNT_AUTH_DATA_PASSWORD = *mut SEC_WINNT_AUTH_DATA_PASSWORD; -DEFINE_GUID!(SEC_WINNT_AUTH_DATA_TYPE_CSP_DATA, - 0x68fd9879, 0x79c, 0x4dfe, 0x82, 0x81, 0x57, 0x8a, 0xad, 0xc1, 0xc1, 0x0); +DEFINE_GUID!{SEC_WINNT_AUTH_DATA_TYPE_CSP_DATA, + 0x68fd9879, 0x79c, 0x4dfe, 0x82, 0x81, 0x57, 0x8a, 0xad, 0xc1, 0xc1, 0x0} // GUID SEC_WINNT_AUTH_DATA_TYPE_SMARTCARD_CONTEXTS STRUCT!{struct SEC_WINNT_AUTH_CERTIFICATE_DATA { cbHeaderLength: c_ushort, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/windef.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/windef.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/windef.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/windef.rs 2018-12-05 01:24:41.000000000 +0000 @@ -8,25 +8,25 @@ use ctypes::c_void; use shared::minwindef::{DWORD, HFILE, WORD}; use um::winnt::{LONG, SHORT}; -DECLARE_HANDLE!(HWND, HWND__); -DECLARE_HANDLE!(HHOOK, HHOOK__); +DECLARE_HANDLE!{HWND, HWND__} +DECLARE_HANDLE!{HHOOK, HHOOK__} pub type HGDIOBJ = *mut c_void; -DECLARE_HANDLE!(HACCEL, HACCEL__); -DECLARE_HANDLE!(HBITMAP, HBITMAP__); -DECLARE_HANDLE!(HBRUSH, HBRUSH__); -DECLARE_HANDLE!(HCOLORSPACE, HCOLORSPACE__); -DECLARE_HANDLE!(HDC, HDC__); -DECLARE_HANDLE!(HGLRC, HGLRC__); -DECLARE_HANDLE!(HDESK, HDESK__); -DECLARE_HANDLE!(HENHMETAFILE, HENHMETAFILE__); -DECLARE_HANDLE!(HFONT, HFONT__); -DECLARE_HANDLE!(HICON, HICON__); -DECLARE_HANDLE!(HMENU, HMENU__); -DECLARE_HANDLE!(HPALETTE, HPALETTE__); -DECLARE_HANDLE!(HPEN, HPEN__); -DECLARE_HANDLE!(HWINEVENTHOOK, HWINEVENTHOOK__); -DECLARE_HANDLE!(HMONITOR, HMONITOR__); -DECLARE_HANDLE!(HUMPD, HUMPD__); +DECLARE_HANDLE!{HACCEL, HACCEL__} +DECLARE_HANDLE!{HBITMAP, HBITMAP__} +DECLARE_HANDLE!{HBRUSH, HBRUSH__} +DECLARE_HANDLE!{HCOLORSPACE, HCOLORSPACE__} +DECLARE_HANDLE!{HDC, HDC__} +DECLARE_HANDLE!{HGLRC, HGLRC__} +DECLARE_HANDLE!{HDESK, HDESK__} +DECLARE_HANDLE!{HENHMETAFILE, HENHMETAFILE__} +DECLARE_HANDLE!{HFONT, HFONT__} +DECLARE_HANDLE!{HICON, HICON__} +DECLARE_HANDLE!{HMENU, HMENU__} +DECLARE_HANDLE!{HPALETTE, HPALETTE__} +DECLARE_HANDLE!{HPEN, HPEN__} +DECLARE_HANDLE!{HWINEVENTHOOK, HWINEVENTHOOK__} +DECLARE_HANDLE!{HMONITOR, HMONITOR__} +DECLARE_HANDLE!{HUMPD, HUMPD__} pub type HCURSOR = HICON; pub type COLORREF = DWORD; pub type LPCOLORREF = *mut DWORD; @@ -103,7 +103,7 @@ pub const DC_PAPERNAMES: DWORD = 16; pub const DC_ORIENTATION: DWORD = 17; pub const DC_COPIES: DWORD = 18; -DECLARE_HANDLE!(DPI_AWARENESS_CONTEXT, DPI_AWARENESS_CONTEXT__); +DECLARE_HANDLE!{DPI_AWARENESS_CONTEXT, DPI_AWARENESS_CONTEXT__} ENUM!{enum DPI_AWARENESS { DPI_AWARENESS_INVALID = -1i32 as u32, DPI_AWARENESS_UNAWARE = 0, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/wnnc.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/wnnc.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/wnnc.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/wnnc.rs 2018-12-05 01:24:41.000000000 +0000 @@ -5,9 +5,7 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. //! Provides the Windows Networking WNNC_NET definitions to winnetwk.h and the IFS Kit. - use shared::minwindef::DWORD; - pub const WNNC_NET_MSNET: DWORD = 0x00010000; pub const WNNC_NET_SMB: DWORD = 0x00020000; pub const WNNC_NET_NETWARE: DWORD = 0x00030000; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/ws2ipdef.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/ws2ipdef.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/ws2ipdef.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/ws2ipdef.rs 2018-12-05 01:24:41.000000000 +0000 @@ -5,13 +5,16 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. //! TCP/IP specific information for use by WinSock2 compatible applications. - use ctypes::c_int; use shared::in6addr::IN6_ADDR; use shared::inaddr::IN_ADDR; use shared::minwindef::{ULONG, USHORT}; use shared::ws2def::{ADDRESS_FAMILY, SCOPE_ID}; - +pub const IFF_UP: ULONG = 0x00000001; +pub const IFF_BROADCAST: ULONG = 0x00000002; +pub const IFF_LOOPBACK: ULONG = 0x00000004; +pub const IFF_POINTTOPOINT: ULONG = 0x00000008; +pub const IFF_MULTICAST: ULONG = 0x00000010; pub const IP_OPTIONS: c_int = 1; pub const IP_HDRINCL: c_int = 2; pub const IP_TOS: c_int = 3; @@ -28,6 +31,19 @@ pub const IP_UNBLOCK_SOURCE: c_int = 18; pub const IP_PKTINFO: c_int = 19; pub const IP_RECEIVE_BROADCAST: c_int = 22; +UNION!{union SOCKADDR_IN6_LH_u { + [u32; 1], + sin6_scope_id sin6_scope_id_mut: ULONG, + sin6_scope_struct sin6_scope_struct_mut: SCOPE_ID, +}} +STRUCT!{struct SOCKADDR_IN6_LH { + sin6_family: ADDRESS_FAMILY, + sin6_port: USHORT, + sin6_flowinfo: ULONG, + sin6_addr: IN6_ADDR, + u: SOCKADDR_IN6_LH_u, +}} +pub type PSOCKADDR_IN6_LH = *mut SOCKADDR_IN6_LH; STRUCT!{struct IP_MREQ { imr_multiaddr: IN_ADDR, imr_interface: IN_ADDR, @@ -64,16 +80,3 @@ ipv6mr_interface: ULONG, }} pub type PIPV6_MREQ = *mut IPV6_MREQ; -UNION!{union SOCKADDR_IN6_LH_u { - [u32; 1], - sin6_scope_id sin6_scope_id_mut: ULONG, - sin6_scope_struct sin6_scope_struct_mut: SCOPE_ID, -}} -STRUCT!{struct SOCKADDR_IN6_LH { - sin6_family: ADDRESS_FAMILY, - sin6_port: USHORT, - sin6_flowinfo: ULONG, - sin6_addr: IN6_ADDR, - u: SOCKADDR_IN6_LH_u, -}} -pub type PSOCKADDR_IN6_LH = *mut SOCKADDR_IN6_LH; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/wtypes.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/wtypes.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/shared/wtypes.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/shared/wtypes.rs 2018-12-05 01:24:41.000000000 +0000 @@ -5,8 +5,8 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. //! Mappings for the contents of wstypes.h -use ctypes::{c_double, c_short, c_ushort, wchar_t}; -use shared::guiddef::{GUID}; +use ctypes::{c_double, c_short, c_ushort, c_void, wchar_t}; +use shared::guiddef::GUID; use shared::minwindef::{BYTE, DWORD, ULONG, USHORT, WORD}; use shared::ntdef::{LONG, LONGLONG, ULONGLONG}; use shared::wtypesbase::{FLAGGED_WORD_BLOB, OLECHAR}; @@ -62,6 +62,12 @@ VT_RESERVED = 0x8000, VT_ILLEGAL = 0xffff, }} +ENUM!{enum DVASPECT { + DVASPECT_CONTENT = 1, + DVASPECT_THUMBNAIL = 2, + DVASPECT_ICON = 4, + DVASPECT_DOCPRINT = 8, +}} pub const VT_ILLEGALMASKED: VARENUM = VT_BSTR_BLOB; pub const VT_TYPEMASK: VARENUM = VT_BSTR_BLOB; pub type PROPID = ULONG; @@ -69,6 +75,7 @@ fmtid: GUID, pid: DWORD, }} +pub type HMETAFILEPICT = *mut c_void; pub type DATE = c_double; STRUCT!{struct CY { int64: LONGLONG, @@ -87,6 +94,7 @@ pub type BSTR = *mut OLECHAR; pub type LPBSTR = *mut BSTR; pub type VARIANT_BOOL = c_short; +pub const VARIANT_TRUE: VARIANT_BOOL = -1; UNION!{union __MIDL_IWinTypes_0001 { [usize; 1], dwValue dwValue_mut: DWORD, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/cfgmgr32.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/cfgmgr32.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/cfgmgr32.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/cfgmgr32.rs 2018-12-05 01:24:42.000000000 +0000 @@ -626,7 +626,7 @@ pub const CM_CLASS_PROPERTY_INSTALLER: ULONG = 0x00000000; pub const CM_CLASS_PROPERTY_INTERFACE: ULONG = 0x00000001; pub const CM_CLASS_PROPERTY_BITS: ULONG = 0x00000001; -DECLARE_HANDLE!(HCMNOTIFICATION, HCMNOTIFICATION__); +DECLARE_HANDLE!{HCMNOTIFICATION, HCMNOTIFICATION__} pub type PHCMNOTIFICATION = *mut HCMNOTIFICATION; pub const CM_NOTIFY_FILTER_FLAG_ALL_INTERFACE_CLASSES: ULONG = 0x00000001; pub const CM_NOTIFY_FILTER_FLAG_ALL_DEVICE_INSTANCES: ULONG = 0x00000002; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/combaseapi.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/combaseapi.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/combaseapi.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/combaseapi.rs 2018-12-05 01:24:41.000000000 +0000 @@ -108,7 +108,7 @@ pServerInformation: PServerInformation, ) -> HRESULT; } -DECLARE_HANDLE!(CO_MTA_USAGE_COOKIE, CO_MTA_USAGE_COOKIE__); +DECLARE_HANDLE!{CO_MTA_USAGE_COOKIE, CO_MTA_USAGE_COOKIE__} extern "system" { pub fn CoIncrementMTAUsage( pCookie: *mut CO_MTA_USAGE_COOKIE, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/commapi.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/commapi.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/commapi.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/commapi.rs 2018-12-05 01:24:41.000000000 +0000 @@ -8,7 +8,7 @@ use shared::minwindef::{BOOL, DWORD, LPDWORD}; use um::minwinbase::LPOVERLAPPED; use um::winbase::{LPCOMMCONFIG, LPCOMMPROP, LPCOMMTIMEOUTS, LPCOMSTAT, LPDCB}; -use um::winnt::{HANDLE}; +use um::winnt::HANDLE; extern "system" { pub fn ClearCommBreak( hFile: HANDLE diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/commctrl.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/commctrl.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/commctrl.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/commctrl.rs 2018-12-05 01:24:41.000000000 +0000 @@ -50,13 +50,11 @@ pub const ICC_NATIVEFNTCTL_CLASS: DWORD = 0x2000; pub const ICC_STANDARD_CLASSES: DWORD = 0x4000; pub const ICC_LINK_CLASS: DWORD = 0x8000; - extern "system" { pub fn InitCommonControlsEx( lpInitCtrls: *const INITCOMMONCONTROLSEX, ) -> BOOL; } - pub const ODT_HEADER: UINT = 100; pub const ODT_TAB: UINT = 101; pub const ODT_LISTVIEW: UINT = 102; @@ -293,7 +291,6 @@ pub const ILC_PERITEMMIRROR: UINT = 0x00008000; pub const ILC_ORIGINALSIZE: UINT = 0x00010000; pub const ILC_HIGHQUALITYSCALE: UINT = 0x00020000; - extern "system" { pub fn ImageList_Create( cx: c_int, @@ -366,7 +363,6 @@ pub const ILS_ALPHA: DWORD = 0x00000008; pub const ILGT_NORMAL: DWORD = 0x00000000; pub const ILGT_ASYNC : DWORD = 0x00000001; - extern "system" { pub fn ImageList_Draw( himl: HIMAGELIST, @@ -378,7 +374,6 @@ ) -> BOOL; } pub const HBITMAP_CALLBACK: HBITMAP = -1isize as HBITMAP; - extern "system" { pub fn ImageList_Replace( himl: HIMAGELIST, @@ -436,7 +431,6 @@ } pub const ILCF_MOVE: UINT = 0x00000000; pub const ILCF_SWAP: UINT = 0x00000001; - extern "system" { pub fn ImageList_Copy( himlDst: HIMAGELIST, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/commdlg.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/commdlg.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/commdlg.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/commdlg.rs 2018-12-05 01:24:41.000000000 +0000 @@ -497,7 +497,7 @@ pPD: LPPRINTDLGW, ) -> BOOL; } -RIDL!(#[uuid(0x5852a2c3, 0x6530, 0x11d1, 0xb6, 0xa3, 0x0, 0x0, 0xf8, 0x75, 0x7b, 0xf9)] +RIDL!{#[uuid(0x5852a2c3, 0x6530, 0x11d1, 0xb6, 0xa3, 0x0, 0x0, 0xf8, 0x75, 0x7b, 0xf9)] interface IPrintDialogCallback(IPrintDialogCallbackVtbl): IUnknown(IUnknownVtbl) { fn InitDone() -> HRESULT, fn SelectionChange() -> HRESULT, @@ -508,9 +508,8 @@ lParam: LPARAM, pResult: *mut LRESULT, ) -> HRESULT, -} -); -RIDL!(#[uuid(0x509aaeda, 0x5639, 0x11d1, 0xb6, 0xa1, 0x0, 0x0, 0xf8, 0x75, 0x7b, 0xf9)] +}} +RIDL!{#[uuid(0x509aaeda, 0x5639, 0x11d1, 0xb6, 0xa1, 0x0, 0x0, 0xf8, 0x75, 0x7b, 0xf9)] interface IPrintDialogServices(IPrintDialogServicesVtbl): IUnknown(IUnknownVtbl) { fn GetCurrentDevMode( pDevMode: LPDEVMODEW, @@ -524,8 +523,7 @@ pPortName: LPWSTR, pcchSize: *mut UINT, ) -> HRESULT, -} -); +}} STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct PRINTPAGERANGE { nFromPage: DWORD, nToPage: DWORD, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/corsym.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/corsym.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/corsym.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/corsym.rs 2018-12-05 01:24:41.000000000 +0000 @@ -56,7 +56,7 @@ ENUM!{enum CorSymVarFlag { VAR_IS_COMP_GEN = 1, }} -RIDL!(#[uuid(0xaa544d42, 0x28cb, 0x11d3, 0xbd, 0x22, 0x00, 0x00, 0xf8, 0x08, 0x49, 0xbd)] +RIDL!{#[uuid(0xaa544d42, 0x28cb, 0x11d3, 0xbd, 0x22, 0x00, 0x00, 0xf8, 0x08, 0x49, 0xbd)] interface ISymUnmanagedBinder(ISymUnmanagedBinderVtbl): IUnknown(IUnknownVtbl) { fn GetReaderForFile( importer: *mut IUnknown, @@ -69,15 +69,14 @@ pstream: *mut IStream, pRetVal: *mut *mut ISymUnmanagedReader, ) -> HRESULT, -} -); +}} ENUM!{enum CorSymSearchPolicyAttributes { AllowRegistryAccess = 0x1, AllowSymbolServerAccess = 0x2, AllowOriginalPathAccess = 0x4, AllowReferencePathAccess = 0x8, }} -RIDL!(#[uuid(0xaccee350, 0x89af, 0x4ccb, 0x8b, 0x40, 0x1c, 0x2c, 0x4c, 0x6f, 0x94, 0x34)] +RIDL!{#[uuid(0xaccee350, 0x89af, 0x4ccb, 0x8b, 0x40, 0x1c, 0x2c, 0x4c, 0x6f, 0x94, 0x34)] interface ISymUnmanagedBinder2(ISymUnmanagedBinder2Vtbl): ISymUnmanagedBinder(ISymUnmanagedBinderVtbl) { fn GetReaderForFile2( @@ -87,6 +86,5 @@ searchPolicy: ULONG32, pRetVal: *mut *mut ISymUnmanagedReader, ) -> HRESULT, -} -); +}} pub enum ISymUnmanagedReader {} // TODO diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/d2d1_1.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/d2d1_1.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/d2d1_1.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/d2d1_1.rs 2018-12-05 01:24:41.000000000 +0000 @@ -274,15 +274,15 @@ debugLevel: D2D1_DEBUG_LEVEL, options: D2D1_DEVICE_CONTEXT_OPTIONS, }} -RIDL!(#[uuid(0x82237326, 0x8111, 0x4f7c, 0xbc, 0xf4, 0xb5, 0xc1, 0x17, 0x55, 0x64, 0xfe)] +RIDL!{#[uuid(0x82237326, 0x8111, 0x4f7c, 0xbc, 0xf4, 0xb5, 0xc1, 0x17, 0x55, 0x64, 0xfe)] interface ID2D1GdiMetafileSink(ID2D1GdiMetafileSinkVtbl): IUnknown(IUnknownVtbl) { fn ProcessRecord( recordType: DWORD, recordData: *const c_void, recordDataSize: DWORD, ) -> HRESULT, -}); -RIDL!(#[uuid(0x2f543dc3, 0xcfc1, 0x4211, 0x86, 0x4f, 0xcf, 0xd9, 0x1c, 0x6f, 0x33, 0x95)] +}} +RIDL!{#[uuid(0x2f543dc3, 0xcfc1, 0x4211, 0x86, 0x4f, 0xcf, 0xd9, 0x1c, 0x6f, 0x33, 0x95)] interface ID2D1GdiMetafile(ID2D1GdiMetafileVtbl): ID2D1Resource(ID2D1ResourceVtbl) { fn Stream( sink: *const ID2D1GdiMetafileSink, @@ -290,8 +290,8 @@ fn GetBounds( bounds: *mut D2D1_RECT_F, ) -> HRESULT, -}); -RIDL!(#[uuid(0x54d7898a, 0xa061, 0x40a7, 0xbe, 0xc7, 0xe4, 0x65, 0xbc, 0xba, 0x2c, 0x4f)] +}} +RIDL!{#[uuid(0x54d7898a, 0xa061, 0x40a7, 0xbe, 0xc7, 0xe4, 0x65, 0xbc, 0xba, 0x2c, 0x4f)] interface ID2D1CommandSink(ID2D1CommandSinkVtbl): IUnknown(IUnknownVtbl) { fn BeginDraw() -> HRESULT, fn EndDraw() -> HRESULT, @@ -394,15 +394,15 @@ ) -> HRESULT, fn PopAxisAlignedClip() -> HRESULT, fn PopLayer() -> HRESULT, -}); -RIDL!(#[uuid(0xb4f34a19, 0x2383, 0x4d76, 0x94, 0xf6, 0xec, 0x34, 0x36, 0x57, 0xc3, 0xdc)] +}} +RIDL!{#[uuid(0xb4f34a19, 0x2383, 0x4d76, 0x94, 0xf6, 0xec, 0x34, 0x36, 0x57, 0xc3, 0xdc)] interface ID2D1CommandList(ID2D1CommandListVtbl): ID2D1Image(ID2D1ImageVtbl) { fn Stream( sink: *const ID2D1CommandSink, ) -> HRESULT, fn Close() -> HRESULT, -}); -RIDL!(#[uuid(0x2c1d867d, 0xc290, 0x41c8, 0xae, 0x7e, 0x34, 0xa9, 0x87, 0x02, 0xe9, 0xa5)] +}} +RIDL!{#[uuid(0x2c1d867d, 0xc290, 0x41c8, 0xae, 0x7e, 0x34, 0xa9, 0x87, 0x02, 0xe9, 0xa5)] interface ID2D1PrintControl(ID2D1PrintControlVtbl): IUnknown(IUnknownVtbl) { fn AddPage( commandList: *const ID2D1CommandList, @@ -412,8 +412,8 @@ tag2: *mut D2D1_TAG, ) -> HRESULT, fn Close() -> HRESULT, -}); -RIDL!(#[uuid(0xfe9e984d, 0x3f95, 0x407c, 0xb5, 0xdb, 0xcb, 0x94, 0xd4, 0xe8, 0xf8, 0x7c)] +}} +RIDL!{#[uuid(0xfe9e984d, 0x3f95, 0x407c, 0xb5, 0xdb, 0xcb, 0x94, 0xd4, 0xe8, 0xf8, 0x7c)] interface ID2D1ImageBrush(ID2D1ImageBrushVtbl): ID2D1Brush(ID2D1BrushVtbl) { fn SetImage( image: *const ID2D1Image, @@ -439,19 +439,19 @@ fn GetSourceRectangle( sourceRectangle: *mut D2D1_RECT_F, ) -> (), -}); -RIDL!(#[uuid(0x41343a53, 0xe41a, 0x49a2, 0x91, 0xcd, 0x21, 0x79, 0x3b, 0xbb, 0x62, 0xe5)] +}} +RIDL!{#[uuid(0x41343a53, 0xe41a, 0x49a2, 0x91, 0xcd, 0x21, 0x79, 0x3b, 0xbb, 0x62, 0xe5)] interface ID2D1BitmapBrush1(ID2D1BitmapBrush1Vtbl): ID2D1BitmapBrush(ID2D1BitmapBrushVtbl) { fn SetInterpolationMode1( interpolationMode: D2D1_INTERPOLATION_MODE, ) -> (), fn GetInterpolationMode1() -> D2D1_INTERPOLATION_MODE, -}); -RIDL!(#[uuid(0x10a72a66, 0xe91c, 0x43f4, 0x99, 0x3f, 0xdd, 0xf4, 0xb8, 0x2b, 0x0b, 0x4a)] +}} +RIDL!{#[uuid(0x10a72a66, 0xe91c, 0x43f4, 0x99, 0x3f, 0xdd, 0xf4, 0xb8, 0x2b, 0x0b, 0x4a)] interface ID2D1StrokeStyle1(ID2D1StrokeStyle1Vtbl): ID2D1StrokeStyle(ID2D1StrokeStyleVtbl) { fn GetStrokeTransformType() -> D2D1_STROKE_TRANSFORM_TYPE, -}); -RIDL!(#[uuid(0x62baa2d2, 0xab54, 0x41b7, 0xb8, 0x72, 0x78, 0x7e, 0x01, 0x06, 0xa4, 0x21)] +}} +RIDL!{#[uuid(0x62baa2d2, 0xab54, 0x41b7, 0xb8, 0x72, 0x78, 0x7e, 0x01, 0x06, 0xa4, 0x21)] interface ID2D1PathGeometry1(ID2D1PathGeometry1Vtbl): ID2D1PathGeometry(ID2D1PathGeometryVtbl) { fn ComputePointAndSegmentAtLength( length: FLOAT, @@ -460,8 +460,8 @@ flatteningTolerance: FLOAT, pointDescription: *mut D2D1_POINT_DESCRIPTION, ) -> HRESULT, -}); -RIDL!(#[uuid(0x483473d7, 0xcd46, 0x4f9d, 0x9d, 0x3a, 0x31, 0x12, 0xaa, 0x80, 0x15, 0x9d)] +}} +RIDL!{#[uuid(0x483473d7, 0xcd46, 0x4f9d, 0x9d, 0x3a, 0x31, 0x12, 0xaa, 0x80, 0x15, 0x9d)] interface ID2D1Properties(ID2D1PropertiesVtbl): IUnknown(IUnknownVtbl) { fn GetPropertyCount() -> UINT32, fn GetPropertyName( @@ -509,8 +509,8 @@ index: UINT32, subProperties: *mut *mut ID2D1Properties, ) -> HRESULT, -}); -RIDL!(#[uuid(0x28211a43, 0x7d89, 0x476f, 0x81, 0x81, 0x2d, 0x61, 0x59, 0xb2, 0x20, 0xad)] +}} +RIDL!{#[uuid(0x28211a43, 0x7d89, 0x476f, 0x81, 0x81, 0x2d, 0x61, 0x59, 0xb2, 0x20, 0xad)] interface ID2D1Effect(ID2D1EffectVtbl): ID2D1Properties(ID2D1PropertiesVtbl) { fn SetInput( index: UINT32, @@ -528,8 +528,8 @@ fn GetOutput( outputImage: *mut *mut ID2D1Image, ) -> (), -}); -RIDL!(#[uuid(0xa898a84c, 0x3873, 0x4588, 0xb0, 0x8b, 0xeb, 0xbf, 0x97, 0x8d, 0xf0, 0x41)] +}} +RIDL!{#[uuid(0xa898a84c, 0x3873, 0x4588, 0xb0, 0x8b, 0xeb, 0xbf, 0x97, 0x8d, 0xf0, 0x41)] interface ID2D1Bitmap1(ID2D1Bitmap1Vtbl): ID2D1Bitmap(ID2D1BitmapVtbl) { fn GetColorContext( colorContext: *mut *mut ID2D1ColorContext, @@ -543,8 +543,8 @@ mappedRect: *mut D2D1_MAPPED_RECT, ) -> HRESULT, fn Unmap() -> HRESULT, -}); -RIDL!(#[uuid(0x1c4820bb, 0x5771, 0x4518, 0xa5, 0x81, 0x2f, 0xe4, 0xdd, 0x0e, 0xc6, 0x57)] +}} +RIDL!{#[uuid(0x1c4820bb, 0x5771, 0x4518, 0xa5, 0x81, 0x2f, 0xe4, 0xdd, 0x0e, 0xc6, 0x57)] interface ID2D1ColorContext(ID2D1ColorContextVtbl): ID2D1Resource(ID2D1ResourceVtbl) { fn GetColorSpace() -> D2D1_COLOR_SPACE, fn GetProfileSize() -> UINT32, @@ -552,8 +552,8 @@ profile: *mut BYTE, profileSize: UINT32, ) -> HRESULT, -}); -RIDL!(#[uuid(0xae1572f4, 0x5dd0, 0x4777, 0x99, 0x8b, 0x92, 0x79, 0x47, 0x2a, 0xe6, 0x3b)] +}} +RIDL!{#[uuid(0xae1572f4, 0x5dd0, 0x4777, 0x99, 0x8b, 0x92, 0x79, 0x47, 0x2a, 0xe6, 0x3b)] interface ID2D1GradientStopCollection1(ID2D1GradientStopCollection1Vtbl): ID2D1GradientStopCollection(ID2D1GradientStopCollectionVtbl) { fn GetGradientStops1( @@ -564,8 +564,8 @@ fn GetPostInterpolationSpace() -> D2D1_COLOR_SPACE, fn GetBufferPrecision() -> D2D1_BUFFER_PRECISION, fn GetColorInterpolationMode() -> D2D1_COLOR_INTERPOLATION_MODE, -}); -RIDL!(#[uuid(0x689f1f85, 0xc72e, 0x4e33, 0x8f, 0x19, 0x85, 0x75, 0x4e, 0xfd, 0x5a, 0xce)] +}} +RIDL!{#[uuid(0x689f1f85, 0xc72e, 0x4e33, 0x8f, 0x19, 0x85, 0x75, 0x4e, 0xfd, 0x5a, 0xce)] interface ID2D1DrawingStateBlock1(ID2D1DrawingStateBlock1Vtbl): ID2D1DrawingStateBlock(ID2D1DrawingStateBlockVtbl) { fn GetDescription( @@ -574,8 +574,8 @@ fn SetDescription( stateDescription: *const D2D1_DRAWING_STATE_DESCRIPTION1, ) -> (), -}); -RIDL!(#[uuid(0xe8f7fe7a, 0x191c, 0x466d, 0xad, 0x95, 0x97, 0x56, 0x78, 0xbd, 0xa9, 0x98)] +}} +RIDL!{#[uuid(0xe8f7fe7a, 0x191c, 0x466d, 0xad, 0x95, 0x97, 0x56, 0x78, 0xbd, 0xa9, 0x98)] interface ID2D1DeviceContext(ID2D1DeviceContextVtbl): ID2D1RenderTarget(ID2D1RenderTargetVtbl) { fn CreateBitmap( size: D2D1_SIZE_U, @@ -737,8 +737,8 @@ destinationRectangle: *const D2D1_RECT_F, sourceRectangle: *const D2D1_RECT_F, ) -> (), -}); -RIDL!(#[uuid(0x47dd575d, 0xac05, 0x4cdd, 0x80, 0x49, 0x9b, 0x02, 0xcd, 0x16, 0xf4, 0x4c)] +}} +RIDL!{#[uuid(0x47dd575d, 0xac05, 0x4cdd, 0x80, 0x49, 0x9b, 0x02, 0xcd, 0x16, 0xf4, 0x4c)] interface ID2D1Device(ID2D1DeviceVtbl): ID2D1Resource(ID2D1ResourceVtbl) { fn CreateDeviceContext( options: D2D1_DEVICE_CONTEXT_OPTIONS, @@ -757,8 +757,8 @@ fn ClearResources( millisecondsSinceUse: UINT32, ) -> (), -}); -RIDL!(#[uuid(0xbb12d362, 0xdaee, 0x4b9a, 0xaa, 0x1d, 0x14, 0xba, 0x40, 0x1c, 0xfa, 0x1f)] +}} +RIDL!{#[uuid(0xbb12d362, 0xdaee, 0x4b9a, 0xaa, 0x1d, 0x14, 0xba, 0x40, 0x1c, 0xfa, 0x1f)] interface ID2D1Factory1(ID2D1Factory1Vtbl): ID2D1Factory(ID2D1FactoryVtbl) { fn CreateDevice( dxgiDevice: *const IDXGIDevice, @@ -809,13 +809,13 @@ effectId: REFCLSID, properties: *mut *mut ID2D1Properties, ) -> HRESULT, -}); -RIDL!(#[uuid(0x31e6e7bc, 0xe0ff, 0x4d46, 0x8c, 0x64, 0xa0, 0xa8, 0xc4, 0x1c, 0x15, 0xd3)] +}} +RIDL!{#[uuid(0x31e6e7bc, 0xe0ff, 0x4d46, 0x8c, 0x64, 0xa0, 0xa8, 0xc4, 0x1c, 0x15, 0xd3)] interface ID2D1Multithread(ID2D1MultithreadVtbl): IUnknown(IUnknownVtbl) { fn GetMultithreadProtected() -> BOOL, fn Enter() -> (), fn Leave() -> (), -}); +}} extern "system" { pub fn D2D1CreateDevice( dxgiDevice: *const IDXGIDevice, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d11_1.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d11_1.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d11_1.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d11_1.rs 2018-12-05 01:24:42.000000000 +0000 @@ -4,6 +4,25 @@ // , at your option. // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. +use ctypes::c_void; +use shared::basetsd::{UINT64, UINT8}; +use shared::dxgiformat::DXGI_FORMAT; +use shared::dxgitype::{DXGI_COLOR_SPACE_TYPE, DXGI_RATIONAL}; +use shared::guiddef::{GUID, REFIID}; +use shared::minwindef::{BOOL, BYTE, DWORD, FLOAT, INT, UINT}; +use um::d3d11::{ + D3D11_BLEND, D3D11_BLEND_OP, D3D11_BOX, D3D11_CULL_MODE, D3D11_FILL_MODE, D3D11_RECT, + D3D11_VIDEO_DECODER_BUFFER_TYPE, D3D11_VIDEO_DECODER_CONFIG, D3D11_VIDEO_DECODER_DESC, + ID3D11BlendState, ID3D11BlendStateVtbl, ID3D11Buffer, ID3D11CryptoSession, ID3D11Device, + ID3D11DeviceChild, ID3D11DeviceChildVtbl, ID3D11DeviceContext, ID3D11DeviceContextVtbl, + ID3D11DeviceVtbl, ID3D11RasterizerState, ID3D11RasterizerStateVtbl, ID3D11Resource, + ID3D11VideoContext, ID3D11VideoContextVtbl, ID3D11VideoDecoder, ID3D11VideoDevice, + ID3D11VideoDeviceVtbl, ID3D11VideoProcessor, ID3D11VideoProcessorEnumerator, + ID3D11VideoProcessorEnumeratorVtbl, ID3D11View +}; +use um::d3dcommon::D3D_FEATURE_LEVEL; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HANDLE, HRESULT, LPCWSTR}; DEFINE_GUID!{IID_ID3D11BlendState1, 0xcc86fabe, 0xda55, 0x401d, 0x85, 0xe7, 0xe3, 0xc9, 0xde, 0x28, 0x77, 0xe9} DEFINE_GUID!{IID_ID3D11RasterizerState1, @@ -22,3 +41,446 @@ 0xa04bfb29, 0x08ef, 0x43d6, 0xa4, 0x9c, 0xa9, 0xbd, 0xbd, 0xcb, 0xe6, 0x86} DEFINE_GUID!{IID_ID3DUserDefinedAnnotation, 0xb2daad8b, 0x03d4, 0x4dbf, 0x95, 0xeb, 0x32, 0xab, 0x4b, 0x63, 0xd0, 0xab} +ENUM!{enum D3D11_COPY_FLAGS { + D3D11_COPY_NO_OVERWRITE = 0x00000001, + D3D11_COPY_DISCARD = 0x00000002, +}} +ENUM!{enum D3D11_LOGIC_OP { + D3D11_LOGIC_OP_CLEAR = 0, + D3D11_LOGIC_OP_SET = 1, + D3D11_LOGIC_OP_COPY = 2, + D3D11_LOGIC_OP_COPY_INVERTED = 3, + D3D11_LOGIC_OP_NOOP = 4, + D3D11_LOGIC_OP_INVERT = 5, + D3D11_LOGIC_OP_AND = 6, + D3D11_LOGIC_OP_NAND = 7, + D3D11_LOGIC_OP_OR = 8, + D3D11_LOGIC_OP_NOR = 9, + D3D11_LOGIC_OP_XOR = 10, + D3D11_LOGIC_OP_EQUIV = 11, + D3D11_LOGIC_OP_AND_REVERSE = 12, + D3D11_LOGIC_OP_AND_INVERTED = 13, + D3D11_LOGIC_OP_OR_REVERSE = 14, + D3D11_LOGIC_OP_OR_INVERTED = 15, +}} +STRUCT!{struct D3D11_RENDER_TARGET_BLEND_DESC1 { + BlendEnable: BOOL, + LogicOpEnable: BOOL, + SrcBlend: D3D11_BLEND, + DestBlend: D3D11_BLEND, + BlendOp: D3D11_BLEND_OP, + SrcBlendAlpha: D3D11_BLEND, + DestBlendAlpha: D3D11_BLEND, + BlendOpAlpha: D3D11_BLEND_OP, + LogicOp: D3D11_LOGIC_OP, + RenderTargetWriteMask: UINT8, +}} +STRUCT!{struct D3D11_BLEND_DESC1 { + AlphaToCoverageEnable: BOOL, + IndependentBlendEnable: BOOL, + RenderTarget: [D3D11_RENDER_TARGET_BLEND_DESC1; 8], +}} +RIDL!{#[uuid(0xcc86fabe, 0xda55, 0x401d, 0x85, 0xe7, 0xe3, 0xc9, 0xde, 0x28, 0x77, 0xe9)] +interface ID3D11BlendState1(ID3D11BlendState1Vtbl): ID3D11BlendState(ID3D11BlendStateVtbl) { + fn GetDesc1( + pDesc: *mut D3D11_BLEND_DESC1, + ) -> (), +}} +STRUCT!{struct D3D11_RASTERIZER_DESC1 { + FillMode: D3D11_FILL_MODE, + CullMode: D3D11_CULL_MODE, + FrontCounterClockwise: BOOL, + DepthBias: INT, + DepthBiasClamp: FLOAT, + SlopeScaledDepthBias: FLOAT, + DepthClipEnable: BOOL, + ScissorEnable: BOOL, + MultisampleEnable: BOOL, + AntialiasedLineEnable: BOOL, + ForcedSampleCount: UINT, +}} +RIDL!{#[uuid(0x1217d7a6, 0x5039, 0x418c, 0xb0, 0x42, 0x9c, 0xbe, 0x25, 0x6a, 0xfd, 0x6e)] +interface ID3D11RasterizerState1(ID3D11RasterizerState1Vtbl): + ID3D11RasterizerState(ID3D11RasterizerStateVtbl) { + fn GetDesc1( + pDesc: *mut D3D11_RASTERIZER_DESC1, + ) -> (), +}} +ENUM!{enum D3D11_1_CREATE_DEVICE_CONTEXT_STATE_FLAG { + D3D11_1_CREATE_DEVICE_CONTEXT_STATE_SINGLETHREADED = 0x1, +}} +RIDL!{#[uuid(0x5c1e0d8a, 0x7c23, 0x48f9, 0x8c, 0x59, 0xa9, 0x29, 0x58, 0xce, 0xff, 0x11)] +interface ID3DDeviceContextState(ID3DDeviceContextStateVtbl): + ID3D11DeviceChild(ID3D11DeviceChildVtbl) { +}} +RIDL!{#[uuid(0xbb2c6faa, 0xb5fb, 0x4082, 0x8e, 0x6b, 0x38, 0x8b, 0x8c, 0xfa, 0x90, 0xe1)] +interface ID3D11DeviceContext1(ID3D11DeviceContext1Vtbl): + ID3D11DeviceContext(ID3D11DeviceContextVtbl) { + fn CopySubresourceRegion1( + pDstResource: *mut ID3D11Resource, + DstSubresource: UINT, + DstX: UINT, + DstY: UINT, + DstZ: UINT, + pSrcResource: *mut ID3D11Resource, + SrcSubresource: UINT, + pSrcBox: *const D3D11_BOX, + CopyFlags: UINT, + ) -> (), + fn UpdateSubresource1( + pDstResource: *mut ID3D11Resource, + DstSubresource: UINT, + pDstBox: *const D3D11_BOX, + pSrcData: *mut c_void, + SrcRowPitch: UINT, + SrcDepthPitch: UINT, + CopyFlags: UINT, + ) -> (), + fn DiscardResource( + pResource: *mut ID3D11Resource, + ) -> (), + fn DiscardView( + pResource: *mut ID3D11Resource, + ) -> (), + fn VSSetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *const *mut ID3D11Buffer, + pFirstConstant: *const UINT, + pNumConstants: *const UINT, + ) -> (), + fn HSSetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *const *mut ID3D11Buffer, + pFirstConstant: *const UINT, + pNumConstants: *const UINT, + ) -> (), + fn DSSetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *const *mut ID3D11Buffer, + pFirstConstant: *const UINT, + pNumConstants: *const UINT, + ) -> (), + fn GSSetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *const *mut ID3D11Buffer, + pFirstConstant: *const UINT, + pNumConstants: *const UINT, + ) -> (), + fn PSSetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *const *mut ID3D11Buffer, + pFirstConstant: *const UINT, + pNumConstants: *const UINT, + ) -> (), + fn CSSetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *const *mut ID3D11Buffer, + pFirstConstant: *const UINT, + pNumConstants: *const UINT, + ) -> (), + fn VSGetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *mut *mut ID3D11Buffer, + pFirstConstant: *mut UINT, + pNumConstants: *mut UINT, + ) -> (), + fn HSGetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *mut *mut ID3D11Buffer, + pFirstConstant: *mut UINT, + pNumConstants: *mut UINT, + ) -> (), + fn DSGetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *mut *mut ID3D11Buffer, + pFirstConstant: *mut UINT, + pNumConstants: *mut UINT, + ) -> (), + fn GSGetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *mut *mut ID3D11Buffer, + pFirstConstant: *mut UINT, + pNumConstants: *mut UINT, + ) -> (), + fn PSGetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *mut *mut ID3D11Buffer, + pFirstConstant: *mut UINT, + pNumConstants: *mut UINT, + ) -> (), + fn CSGetConstantBuffers1( + StartSlot: UINT, + NumBuffers: UINT, + ppConstantBuffers: *mut *mut ID3D11Buffer, + pFirstConstant: *mut UINT, + pNumConstants: *mut UINT, + ) -> (), + fn SwapDeviceContextState( + pState: *mut ID3DDeviceContextState, + ppPreviousState: *mut *mut ID3DDeviceContextState, + ) -> (), + fn ClearView( + pView: *mut ID3D11View, + Color: [FLOAT; 4], + pRect: *const D3D11_RECT, + NumRects: UINT, + ) -> (), + fn DiscardView1( + pResourceView: *mut ID3D11View, + pRects: *const D3D11_RECT, + NumRects: UINT, + ) -> (), +}} +STRUCT!{struct D3D11_VIDEO_DECODER_SUB_SAMPLE_MAPPING_BLOCK { + ClearSize: UINT, + EncryptedSize: UINT, +}} +STRUCT!{struct D3D11_VIDEO_DECODER_BUFFER_DESC1 { + BufferType: D3D11_VIDEO_DECODER_BUFFER_TYPE, + DataOffset: UINT, + DataSize: UINT, + pIV: *mut c_void, + IVSize: UINT, + pSubSampleMappingBlock: *mut D3D11_VIDEO_DECODER_SUB_SAMPLE_MAPPING_BLOCK, + SubSampleMappingCount: UINT, +}} +STRUCT!{struct D3D11_VIDEO_DECODER_BEGIN_FRAME_CRYPTO_SESSION { + pCryptoSession: *mut ID3D11CryptoSession, + BlobSize: UINT, + pBlob: *mut c_void, + pKeyInfoId: *mut GUID, + PrivateDataSize: UINT, + pPrivateData: *mut c_void, +}} +ENUM!{enum D3D11_VIDEO_DECODER_CAPS { + D3D11_VIDEO_DECODER_CAPS_DOWNSAMPLE = 0x1, + D3D11_VIDEO_DECODER_CAPS_NON_REAL_TIME = 0x02, + D3D11_VIDEO_DECODER_CAPS_DOWNSAMPLE_DYNAMIC = 0x04, + D3D11_VIDEO_DECODER_CAPS_DOWNSAMPLE_REQUIRED = 0x08, + D3D11_VIDEO_DECODER_CAPS_UNSUPPORTED = 0x10, +}} +ENUM!{enum D3D11_VIDEO_PROCESSOR_BEHAVIOR_HINTS { + D3D11_VIDEO_PROCESSOR_BEHAVIOR_HINT_MULTIPLANE_OVERLAY_ROTATION = 0x01, + D3D11_VIDEO_PROCESSOR_BEHAVIOR_HINT_MULTIPLANE_OVERLAY_RESIZE = 0x02, + D3D11_VIDEO_PROCESSOR_BEHAVIOR_HINT_MULTIPLANE_OVERLAY_COLOR_SPACE_CONVERSION = 0x04, + D3D11_VIDEO_PROCESSOR_BEHAVIOR_HINT_TRIPLE_BUFFER_OUTPUT = 0x08, +}} +STRUCT!{struct D3D11_VIDEO_PROCESSOR_STREAM_BEHAVIOR_HINT { + Enable: BOOL, + Width: UINT, + Height: UINT, + Format: DXGI_FORMAT, +}} +ENUM!{enum D3D11_CRYPTO_SESSION_STATUS { + D3D11_CRYPTO_SESSION_STATUS_OK = 0, + D3D11_CRYPTO_SESSION_STATUS_KEY_LOST = 1, + D3D11_CRYPTO_SESSION_STATUS_KEY_AND_CONTENT_LOST = 2, +}} +STRUCT!{struct D3D11_KEY_EXCHANGE_HW_PROTECTION_INPUT_DATA { + PrivateDataSize: UINT, + HWProtectionDataSize: UINT, + pbInput: [BYTE; 4], +}} +STRUCT!{struct D3D11_KEY_EXCHANGE_HW_PROTECTION_OUTPUT_DATA { + PrivateDataSize: UINT, + MaxHWProtectionDataSize: UINT, + HWProtectionDataSize: UINT, + TransportTime: UINT64, + ExecutionTime: UINT64, + pbOutput: [BYTE; 4], +}} +STRUCT!{struct D3D11_KEY_EXCHANGE_HW_PROTECTION_DATA { + HWProtectionFunctionID: UINT, + pInputData: *mut D3D11_KEY_EXCHANGE_HW_PROTECTION_INPUT_DATA, + pOutputData: *mut D3D11_KEY_EXCHANGE_HW_PROTECTION_OUTPUT_DATA, + Status: HRESULT, +}} +STRUCT!{struct D3D11_VIDEO_SAMPLE_DESC { + Width: UINT, + Height: UINT, + Format: DXGI_FORMAT, + ColorSpace: DXGI_COLOR_SPACE_TYPE, +}} +RIDL!{#[uuid(0xa7f026da, 0xa5f8, 0x4487, 0xa5, 0x64, 0x15, 0xe3, 0x43, 0x57, 0x65, 0x1e)] +interface ID3D11VideoContext1(ID3D11VideoContext1Vtbl): + ID3D11VideoContext(ID3D11VideoContextVtbl) { + fn SubmitDecoderBuffers1( + pDecoder: *mut ID3D11VideoDecoder, + NumBuffers: UINT, + pBufferDesc: *const D3D11_VIDEO_DECODER_BUFFER_DESC1, + ) -> HRESULT, + fn GetDataForNewHardwareKey( + pCryptoSession: *mut ID3D11CryptoSession, + PrivateInputSize: UINT, + pPrivateInputData: *const c_void, + pPrivateOutputData: *mut UINT64, + ) -> HRESULT, + fn CheckCryptoSessionStatus( + pCryptoSession: *mut ID3D11CryptoSession, + pStatus: *mut D3D11_CRYPTO_SESSION_STATUS, + ) -> HRESULT, + fn DecoderEnableDownsampling( + pDecoder: *mut ID3D11VideoDecoder, + InputColorSpace: DXGI_COLOR_SPACE_TYPE, + pOutputDesc: *const D3D11_VIDEO_SAMPLE_DESC, + ReferenceFrameCount: UINT, + ) -> HRESULT, + fn DecoderUpdateDownsampling( + pDecoder: *mut ID3D11VideoDecoder, + pOutputDesc: *const D3D11_VIDEO_SAMPLE_DESC, + ) -> HRESULT, + fn VideoProcessorSetOutputColorSpace1( + pVideoProcessor: *mut ID3D11VideoProcessor, + ColorSpace: DXGI_COLOR_SPACE_TYPE, + ) -> (), + fn VideoProcessorSetOutputShaderUsage( + pVideoProcessor: *mut ID3D11VideoProcessor, + ShaderUsage: BOOL, + ) -> (), + fn VideoProcessorGetOutputColorSpace1( + pVideoProcessor: *mut ID3D11VideoProcessor, + pColorSpace: *mut DXGI_COLOR_SPACE_TYPE, + ) -> (), + fn VideoProcessorGetOutputShaderUsage( + pVideoProcessor: *mut ID3D11VideoProcessor, + pShaderUsage: *mut BOOL, + ) -> (), + fn VideoProcessorSetStreamColorSpace1( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + ColorSpace: DXGI_COLOR_SPACE_TYPE, + ) -> (), + fn VideoProcessorSetStreamMirror( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + Enable: BOOL, + FlipHorizontal: BOOL, + FlipVertical: BOOL, + ) -> (), + fn VideoProcessorGetStreamColorSpace1( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + pColorSpace: *mut DXGI_COLOR_SPACE_TYPE, + ) -> (), + fn VideoProcessorGetStreamMirror( + pVideoProcessor: *mut ID3D11VideoProcessor, + StreamIndex: UINT, + pEnable: *mut BOOL, + pFlipHorizontal: *mut BOOL, + pFlipVertical: *mut BOOL, + ) -> (), + fn VideoProcessorGetBehaviorHints( + pVideoProcessor: *mut ID3D11VideoProcessor, + OutputWidth: UINT, + OutputHeight: UINT, + OutputFormat: DXGI_FORMAT, + StreamCount: UINT, + pStreams: *const D3D11_VIDEO_PROCESSOR_STREAM_BEHAVIOR_HINT, + pBehaviorHints: *mut UINT, + ) -> (), +}} +RIDL!{#[uuid(0x29da1d51, 0x1321, 0x4454, 0x80, 0x4b, 0xf5, 0xfc, 0x9f, 0x86, 0x1f, 0x0f)] +interface ID3D11VideoDevice1(ID3D11VideoDevice1Vtbl): ID3D11VideoDevice(ID3D11VideoDeviceVtbl) { + fn GetCryptoSessionPrivateDataSize( + pCryptoType: *const GUID, + pDecoderProfile: *const GUID, + pKeyExchangeType: *const GUID, + pPrivateInputSize: *mut UINT, + pPrivateOutputSize: *mut UINT, + ) -> HRESULT, + fn GetVideoDecoderCaps( + pDecoderProfile: *const GUID, + SampleWidth: UINT, + SampleHeight: UINT, + pFrameRate: *const DXGI_RATIONAL, + BitRate: UINT, + pCryptoType: *const GUID, + pDecoderCaps: *mut UINT, + ) -> HRESULT, + fn CheckVideoDecoderDownsampling( + pInputDesc: *const D3D11_VIDEO_DECODER_DESC, + InputColorSpace: DXGI_COLOR_SPACE_TYPE, + pInputConfig: *const D3D11_VIDEO_DECODER_CONFIG, + pFrameRate: *const DXGI_RATIONAL, + pOutputDesc: *const D3D11_VIDEO_SAMPLE_DESC, + pSupported: *mut BOOL, + pRealTimeHint: *mut BOOL, + ) -> HRESULT, + fn RecommendVideoDecoderDownsampleParameters( + pInputDesc: *const D3D11_VIDEO_DECODER_DESC, + InputColorSpace: DXGI_COLOR_SPACE_TYPE, + pInputConfig: *const D3D11_VIDEO_DECODER_CONFIG, + pRecommendedOutputDesc: *mut D3D11_VIDEO_SAMPLE_DESC, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x465217f2, 0x5568, 0x43cf, 0xb5, 0xb9, 0xf6, 0x1d, 0x54, 0x53, 0x1c, 0xa1)] +interface ID3D11VideoProcessorEnumerator1(ID3D11VideoProcessorEnumerator1Vtbl): + ID3D11VideoProcessorEnumerator(ID3D11VideoProcessorEnumeratorVtbl) { + fn CheckVideoProcessorFormatConversion( + InputFormat: DXGI_FORMAT, + InputCOlorSpace: DXGI_COLOR_SPACE_TYPE, + OutputFormat: DXGI_FORMAT, + OutputColorSpace: DXGI_COLOR_SPACE_TYPE, + pSupported: *mut BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa04bfb29, 0x08ef, 0x43d6, 0xa4, 0x9c, 0xa9, 0xbd, 0xbd, 0xcb, 0xe6, 0x86)] +interface ID3D11Device1(ID3D11Device1Vtbl): ID3D11Device(ID3D11DeviceVtbl) { + fn GetImmediateContext1( + ppImmediateContext: *mut *mut ID3D11DeviceContext1, + ) -> (), + fn CreateDeferredContext1( + ContextFlags: UINT, + ppDeferredContext: *mut *mut ID3D11DeviceContext1, + ) -> HRESULT, + fn CreateBlendState( + pBlendStateDesc: *const D3D11_BLEND_DESC1, + ppBlendState: *mut *mut ID3D11BlendState1, + ) -> HRESULT, + fn CreateRasterizerState( + pRasterizerDesc: *const D3D11_RASTERIZER_DESC1, + ppRasterizerState: *mut *mut ID3D11RasterizerState1, + ) -> HRESULT, + fn CreateDeviceContextState( + Flags: UINT, + pFeatureLevels: *const D3D_FEATURE_LEVEL, + FeatureLevels: UINT, + SDKVersion: UINT, + EmulatedInterface: REFIID, + pChosenFeatureLevel: *mut D3D_FEATURE_LEVEL, + ppContextState: *mut *mut ID3DDeviceContextState, + ) -> HRESULT, + fn OpenSharedResource1( + hResource: HANDLE, + returnedInterface: REFIID, + ppResource: *mut *mut c_void, + ) -> HRESULT, + fn OpenSharedResourceByName( + Name: LPCWSTR, + dwDesiredAccess: DWORD, + returnedInterface: REFIID, + ppResource: *mut *mut c_void, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xb2daad8b, 0x03d4, 0x4dbf, 0x95, 0xeb, 0x32, 0xab, 0x4b, 0x63, 0xd0, 0xab)] +interface ID3DUserDefinedAnnotation(ID3DUserDefinedAnnotationVtbl): IUnknown(IUnknownVtbl) { + fn BeginEvent( + Name: LPCWSTR, + ) -> INT, + fn EndEvent() -> INT, + fn SetMarker( + Name: LPCWSTR, + ) -> (), + fn GetStatus() -> BOOL, +}} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d11_2.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d11_2.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d11_2.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d11_2.rs 2018-12-05 01:24:42.000000000 +0000 @@ -4,7 +4,144 @@ // , at your option. // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. +use ctypes::c_void; +use shared::basetsd::{UINT16, UINT64, UINT8}; +use shared::dxgiformat::DXGI_FORMAT; +use shared::minwindef::{BOOL, INT, UINT}; +use um::d3d11::{ID3D11Buffer, ID3D11DeviceChild, ID3D11Resource}; +use um::d3d11_1::{ + ID3D11Device1, ID3D11Device1Vtbl, ID3D11DeviceContext1, ID3D11DeviceContext1Vtbl, +}; +use um::winnt::{HRESULT, LPCWSTR}; DEFINE_GUID!{IID_ID3D11DeviceContext2, 0x420d5b32, 0xb90c, 0x4da4, 0xbe, 0xf0, 0x35, 0x9f, 0x6a, 0x24, 0xa8, 0x3a} DEFINE_GUID!{IID_ID3D11Device2, 0x9d06dffa, 0xd1e5, 0x4d07, 0x83, 0xa8, 0x1b, 0xb1, 0x23, 0xf2, 0xf8, 0x41} +STRUCT!{struct D3D11_TILED_RESOURCE_COORDINATE { + X: UINT, + Y: UINT, + Z: UINT, + Subresource: UINT, +}} +STRUCT!{struct D3D11_TILE_REGION_SIZE { + NumTiles: UINT, + bUseBox: BOOL, + Width: UINT, + Height: UINT16, + Depth: UINT16, +}} +ENUM!{enum D3D11_TILE_MAPPING_FLAG { + D3D11_TILE_MAPPING_NO_OVERWRITE = 0x00000001, +}} +ENUM!{enum D3D11_TILE_RANGE_FLAG { + D3D11_TILE_RANGE_NULL = 0x00000001, + D3D11_TILE_RANGE_SKIP = 0x00000002, + D3D11_TILE_RANGE_REUSE_SINGLE_TILE = 0x00000004, +}} +STRUCT!{struct D3D11_SUBRESOURCE_TILING { + WidthInTiles: UINT, + HeightInTiles: UINT16, + DepthInTiles: UINT16, + StartTileIndexInOverallResource: UINT, +}} +STRUCT!{struct D3D11_TILE_SHAPE { + WidthInTexels: UINT, + HeightInTexels: UINT, + DepthInTexels: UINT, +}} +STRUCT!{struct D3D11_PACKED_MIP_DESC { + NumStandardMips: UINT8, + NumPackedMips: UINT8, + NumTilesForPackedMips: UINT, + StartTileIndexInOverallResource: UINT, +}} +ENUM!{enum D3D11_CHECK_MULTISAMPLE_QUALITY_LEVELS_FLAG { + D3D11_CHECK_MULTISAMPLE_QUALITY_LEVELS_TILED_RESOURCE = 0x00000001, +}} +ENUM!{enum D3D11_TILE_COPY_FLAG { + D3D11_TILE_COPY_NO_OVERWRITE = 0x00000001, + D3D11_TILE_COPY_LINEAR_BUFFER_TO_SWIZZLED_TILED_RESOURCE = 0x00000002, + D3D11_TILE_COPY_SWIZZLED_TILED_RESOURCE_TO_LINEAR_BUFFER = 0x00000004, +}} +RIDL!{#[uuid(0x420d5b32, 0xb90c, 0x4da4, 0xbe, 0xf0, 0x35, 0x9f, 0x6a, 0x24, 0xa8, 0x3a)] +interface ID3D11DeviceContext2(ID3D11DeviceContext2Vtbl): + ID3D11DeviceContext1(ID3D11DeviceContext1Vtbl) { + fn UpdateTileMappings( + pTiledResource: *mut ID3D11Resource, + NumTiledResourceRegions: UINT, + pTiledResourceRegionStartCoordinates: *const D3D11_TILED_RESOURCE_COORDINATE, + pTiledResourceRegionSizes: *const D3D11_TILE_REGION_SIZE, + pTilePool: *mut ID3D11Buffer, + NumRanges: UINT, + pRangeFlags: *const UINT, + pTilePoolStartOffsets: *const UINT, + pRangeTileCounts: *const UINT, + Flags: UINT, + ) -> HRESULT, + fn CopyTileMappings( + pDestTiledResource: *mut ID3D11Resource, + pDestRegionStartCoordinate: *const D3D11_TILED_RESOURCE_COORDINATE, + pSourceTiledResource: *mut ID3D11Resource, + pSourceRegionStartCoordinate: *const D3D11_TILED_RESOURCE_COORDINATE, + pTileRegionSize: *const D3D11_TILE_REGION_SIZE, + Flags: UINT, + ) -> HRESULT, + fn CopyTiles( + pTiledResource: *mut ID3D11Resource, + pTileRegionStartCoordinate: *const D3D11_TILED_RESOURCE_COORDINATE, + pTileRegionSize: *const D3D11_TILE_REGION_SIZE, + pBuffer: *mut ID3D11Buffer, + BufferStartOffsetInBytes: UINT64, + Flags: UINT, + ) -> (), + fn UpdateTiles( + pDestTiledResource: *mut ID3D11Resource, + pDestTileRegionStartCoordinate: *const D3D11_TILED_RESOURCE_COORDINATE, + pDestTileRegionSize: *const D3D11_TILE_REGION_SIZE, + pSourceTileData: *const c_void, + Flags: UINT, + ) -> (), + fn ResizeTilePool( + pTilePool: *mut ID3D11Buffer, + NewSizeInBytes: UINT64, + ) -> HRESULT, + fn TiledResourceBarrier( + pTiledResourceOrViewAccessBeforeBarrier: *mut ID3D11DeviceChild, + pTiledResourceOrViewAccessAfterBarrier: *mut ID3D11DeviceChild, + ) -> (), + fn IsAnnotationEnabled() -> BOOL, + fn SetMarkerInt( + pLabel: LPCWSTR, + Data: INT, + ) -> (), + fn BeginEventInt( + pLabel: LPCWSTR, + Data: INT, + ) -> (), + fn EndEvent() -> (), +}} +RIDL!{#[uuid(0x9d06dffa, 0xd1e5, 0x4d07, 0x83, 0xa8, 0x1b, 0xb1, 0x23, 0xf2, 0xf8, 0x41)] +interface ID3D11Device2(ID3D11Device2Vtbl): ID3D11Device1(ID3D11Device1Vtbl) { + fn GetImmediateContext2( + ppImmediateContext: *mut *mut ID3D11DeviceContext2, + ) -> (), + fn CreateDeferredContext2( + ContextFlags: UINT, + ppDeferredContext: *mut *mut ID3D11DeviceContext2, + ) -> HRESULT, + fn GetResourceTiling( + pTiledResource: *mut ID3D11Resource, + pNumTilesForEntireResource: *mut UINT, + pPackedMipDesc: *mut D3D11_PACKED_MIP_DESC, + pStandardTileShapeForNonPackedMips: *mut D3D11_TILE_SHAPE, + pNumSubresourceTilings: *mut UINT, + FirstSubresourceTilingToGet: UINT, + pSubresourceTilingsForNonPackedMips: *mut D3D11_SUBRESOURCE_TILING, + ) -> (), + fn CheckMultisampleQualityLevels1( + Format: DXGI_FORMAT, + SampleCount: UINT, + Flags: UINT, + pNumQualityLevels: *mut UINT, + ) -> HRESULT, +}} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d11.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d11.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d11.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d11.rs 2018-12-05 01:24:42.000000000 +0000 @@ -7,7 +7,7 @@ use ctypes::{c_float, c_int, c_long, c_void}; use shared::basetsd::{SIZE_T, UINT64, UINT8}; use shared::dxgi::{DXGI_SWAP_CHAIN_DESC, IDXGIAdapter, IDXGISwapChain}; -use shared::dxgiformat::{DXGI_FORMAT}; +use shared::dxgiformat::DXGI_FORMAT; use shared::dxgitype::{DXGI_RATIONAL, DXGI_SAMPLE_DESC}; use shared::guiddef::{GUID, REFGUID, REFIID}; use shared::minwindef::{BOOL, BYTE, DWORD, FLOAT, HMODULE, INT, UINT, USHORT}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d11sdklayers.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d11sdklayers.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d11sdklayers.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d11sdklayers.rs 2018-12-05 01:24:42.000000000 +0000 @@ -6,7 +6,7 @@ // except according to those terms. use ctypes::c_char; use shared::basetsd::{SIZE_T, UINT64}; -use shared::dxgi::{IDXGISwapChain}; +use shared::dxgi::IDXGISwapChain; use shared::minwindef::{BOOL, UINT}; use um::d3d11::ID3D11DeviceContext; use um::unknwnbase::{IUnknown, IUnknownVtbl}; @@ -28,33 +28,33 @@ interface ID3D11Debug(ID3D11DebugVtbl): IUnknown(IUnknownVtbl) { fn SetFeatureMask( Mask: UINT, - ) -> HRESULT, + ) -> HRESULT, fn GetFeatureMask() -> UINT, fn SetPresentPerRenderOpDelay( Milliseconds: UINT, - ) -> HRESULT, + ) -> HRESULT, fn GetPresentPerRenderOpDelay() -> UINT, fn SetSwapChain( pSwapChain: *mut IDXGISwapChain, - ) -> HRESULT, + ) -> HRESULT, fn GetSwapChain( ppSwapChain: *mut *mut IDXGISwapChain, - ) -> HRESULT, + ) -> HRESULT, fn ValidateContext( pContext: *const ID3D11DeviceContext, - ) -> HRESULT, + ) -> HRESULT, fn ReportLiveDeviceObjects( Flags: D3D11_RLDO_FLAGS, - ) -> HRESULT, + ) -> HRESULT, fn ValidateContextForDispatch( pContext: *mut ID3D11DeviceContext, - ) -> HRESULT, + ) -> HRESULT, }} RIDL!{#[uuid(0x1ef337e3, 0x58e7, 0x4f83, 0xa6, 0x92, 0xdb, 0x22, 0x1f, 0x5e, 0xd4, 0x7e)] interface ID3D11SwitchToRef(ID3D11SwitchToRefVtbl): IUnknown(IUnknownVtbl) { fn SetUseRef( UseRef: BOOL, - ) -> BOOL, + ) -> BOOL, fn GetUseRef() -> BOOL, }} ENUM!{enum D3D11_SHADER_TRACKING_RESOURCE_TYPE { @@ -102,24 +102,24 @@ fn SetShaderTrackingOptionsByType( ResourceTypeFlags: UINT, Options: UINT, - ) -> HRESULT, + ) -> HRESULT, fn SetShaderTrackingOptions( pShader: *const IUnknown, Options: UINT, - ) -> HRESULT, + ) -> HRESULT, }} RIDL!{#[uuid(0x193dacdf, 0x0db2, 0x4c05, 0xa5, 0x5c, 0xef, 0x06, 0xca, 0xc5, 0x6f, 0xd9)] interface ID3D11RefTrackingOptions(ID3D11RefTrackingOptionsVtbl): IUnknown(IUnknownVtbl) { fn SetTrackingOptions( Options: UINT, - ) -> HRESULT, + ) -> HRESULT, }} RIDL!{#[uuid(0x03916615, 0xc644, 0x418c, 0x9b, 0xf4, 0x75, 0xdb, 0x5b, 0xe6, 0x3c, 0xa0)] interface ID3D11RefDefaultTrackingOptions(ID3D11RefDefaultTrackingOptionsVtbl): IUnknown(IUnknownVtbl) { - fn SetTrackingOptions( - ResourceTypeFlags: UINT, - Options: UINT, + fn SetTrackingOptions( + ResourceTypeFlags: UINT, + Options: UINT, ) -> HRESULT, }} DEFINE_GUID!{DXGI_DEBUG_D3D11, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d11tokenizedprogramformat.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d11tokenizedprogramformat.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d11tokenizedprogramformat.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d11tokenizedprogramformat.rs 2018-12-05 01:24:41.000000000 +0000 @@ -0,0 +1,1191 @@ +// Copyright © 2015-2017 winapi-rs developers +// Licensed under the Apache License, Version 2.0 +// or the MIT license +// , at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::{DWORD, UINT}; +ENUM!{enum D3D10_SB_TOKENIZED_PROGRAM_TYPE { + D3D10_SB_PIXEL_SHADER = 0, + D3D10_SB_VERTEX_SHADER = 1, + D3D10_SB_GEOMETRY_SHADER = 2, + D3D11_SB_HULL_SHADER = 3, + D3D11_SB_DOMAIN_SHADER = 4, + D3D11_SB_COMPUTE_SHADER = 5, + D3D11_SB_RESERVED0 = 0xFFF0, +}} +pub const D3D10_SB_TOKENIZED_PROGRAM_TYPE_MASK: DWORD = 0xffff0000; +pub const D3D10_SB_TOKENIZED_PROGRAM_TYPE_SHIFT: DWORD = 16; +#[inline] +pub fn DECODE_D3D10_SB_TOKENIZED_PROGRAM_TYPE(VerTok: DWORD) -> DWORD { + (((VerTok & D3D10_SB_TOKENIZED_PROGRAM_TYPE_MASK) >> D3D10_SB_TOKENIZED_PROGRAM_TYPE_SHIFT) as D3D10_SB_TOKENIZED_PROGRAM_TYPE) +} +pub const D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION_MASK: DWORD = 0x000000f0; +pub const D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION_SHIFT: DWORD = 4; +pub const D3D10_SB_TOKENIZED_PROGRAM_MINOR_VERSION_MASK: DWORD = 0x0000000f; +#[inline] +pub fn DECODE_D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION(VerTok: DWORD) -> DWORD { + ((VerTok & D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION_MASK) >> D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION_SHIFT) +} +#[inline] +pub fn DECODE_D3D10_SB_TOKENIZED_PROGRAM_MINOR_VERSION(VerTok: DWORD) -> DWORD { + (VerTok & D3D10_SB_TOKENIZED_PROGRAM_MINOR_VERSION_MASK) +} +#[inline] +pub fn ENCODE_D3D10_SB_TOKENIZED_PROGRAM_VERSION_TOKEN(ProgType: DWORD, MajorVer: DWORD, MinorVer: DWORD) -> DWORD { + ((ProgType << D3D10_SB_TOKENIZED_PROGRAM_TYPE_SHIFT) & D3D10_SB_TOKENIZED_PROGRAM_TYPE_MASK) | + (((MajorVer << D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION_SHIFT) & D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION_MASK)) | + (MinorVer & D3D10_SB_TOKENIZED_PROGRAM_MINOR_VERSION_MASK) +} +#[inline] +pub fn DECODE_D3D10_SB_TOKENIZED_PROGRAM_LENGTH(LenTok: DWORD) -> DWORD { + LenTok +} +#[inline] +pub fn ENCODE_D3D10_SB_TOKENIZED_PROGRAM_LENGTH(Length: DWORD) -> DWORD { + Length +} +pub const MAX_D3D10_SB_TOKENIZED_PROGRAM_LENGTH: DWORD = 0xffffffff; +ENUM!{enum D3D10_SB_OPCODE_TYPE { + D3D10_SB_OPCODE_ADD = 0, + D3D10_SB_OPCODE_AND = 1, + D3D10_SB_OPCODE_BREAK = 2, + D3D10_SB_OPCODE_BREAKC = 3, + D3D10_SB_OPCODE_CALL = 4, + D3D10_SB_OPCODE_CALLC = 5, + D3D10_SB_OPCODE_CASE = 6, + D3D10_SB_OPCODE_CONTINUE = 7, + D3D10_SB_OPCODE_CONTINUEC = 8, + D3D10_SB_OPCODE_CUT = 9, + D3D10_SB_OPCODE_DEFAULT = 10, + D3D10_SB_OPCODE_DERIV_RTX = 11, + D3D10_SB_OPCODE_DERIV_RTY = 12, + D3D10_SB_OPCODE_DISCARD = 13, + D3D10_SB_OPCODE_DIV = 14, + D3D10_SB_OPCODE_DP2 = 15, + D3D10_SB_OPCODE_DP3 = 16, + D3D10_SB_OPCODE_DP4 = 17, + D3D10_SB_OPCODE_ELSE = 18, + D3D10_SB_OPCODE_EMIT = 19, + D3D10_SB_OPCODE_EMITTHENCUT = 20, + D3D10_SB_OPCODE_ENDIF = 21, + D3D10_SB_OPCODE_ENDLOOP = 22, + D3D10_SB_OPCODE_ENDSWITCH = 23, + D3D10_SB_OPCODE_EQ = 24, + D3D10_SB_OPCODE_EXP = 25, + D3D10_SB_OPCODE_FRC = 26, + D3D10_SB_OPCODE_FTOI = 27, + D3D10_SB_OPCODE_FTOU = 28, + D3D10_SB_OPCODE_GE = 29, + D3D10_SB_OPCODE_IADD = 30, + D3D10_SB_OPCODE_IF = 31, + D3D10_SB_OPCODE_IEQ = 32, + D3D10_SB_OPCODE_IGE = 33, + D3D10_SB_OPCODE_ILT = 34, + D3D10_SB_OPCODE_IMAD = 35, + D3D10_SB_OPCODE_IMAX = 36, + D3D10_SB_OPCODE_IMIN = 37, + D3D10_SB_OPCODE_IMUL = 38, + D3D10_SB_OPCODE_INE = 39, + D3D10_SB_OPCODE_INEG = 40, + D3D10_SB_OPCODE_ISHL = 41, + D3D10_SB_OPCODE_ISHR = 42, + D3D10_SB_OPCODE_ITOF = 43, + D3D10_SB_OPCODE_LABEL = 44, + D3D10_SB_OPCODE_LD = 45, + D3D10_SB_OPCODE_LD_MS = 46, + D3D10_SB_OPCODE_LOG = 47, + D3D10_SB_OPCODE_LOOP = 48, + D3D10_SB_OPCODE_LT = 49, + D3D10_SB_OPCODE_MAD = 50, + D3D10_SB_OPCODE_MIN = 51, + D3D10_SB_OPCODE_MAX = 52, + D3D10_SB_OPCODE_CUSTOMDATA = 53, + D3D10_SB_OPCODE_MOV = 54, + D3D10_SB_OPCODE_MOVC = 55, + D3D10_SB_OPCODE_MUL = 56, + D3D10_SB_OPCODE_NE = 57, + D3D10_SB_OPCODE_NOP = 58, + D3D10_SB_OPCODE_NOT = 59, + D3D10_SB_OPCODE_OR = 60, + D3D10_SB_OPCODE_RESINFO = 61, + D3D10_SB_OPCODE_RET = 62, + D3D10_SB_OPCODE_RETC = 63, + D3D10_SB_OPCODE_ROUND_NE = 64, + D3D10_SB_OPCODE_ROUND_NI = 65, + D3D10_SB_OPCODE_ROUND_PI = 66, + D3D10_SB_OPCODE_ROUND_Z = 67, + D3D10_SB_OPCODE_RSQ = 68, + D3D10_SB_OPCODE_SAMPLE = 69, + D3D10_SB_OPCODE_SAMPLE_C = 70, + D3D10_SB_OPCODE_SAMPLE_C_LZ = 71, + D3D10_SB_OPCODE_SAMPLE_L = 72, + D3D10_SB_OPCODE_SAMPLE_D = 73, + D3D10_SB_OPCODE_SAMPLE_B = 74, + D3D10_SB_OPCODE_SQRT = 75, + D3D10_SB_OPCODE_SWITCH = 76, + D3D10_SB_OPCODE_SINCOS = 77, + D3D10_SB_OPCODE_UDIV = 78, + D3D10_SB_OPCODE_ULT = 79, + D3D10_SB_OPCODE_UGE = 80, + D3D10_SB_OPCODE_UMUL = 81, + D3D10_SB_OPCODE_UMAD = 82, + D3D10_SB_OPCODE_UMAX = 83, + D3D10_SB_OPCODE_UMIN = 84, + D3D10_SB_OPCODE_USHR = 85, + D3D10_SB_OPCODE_UTOF = 86, + D3D10_SB_OPCODE_XOR = 87, + D3D10_SB_OPCODE_DCL_RESOURCE = 88, + D3D10_SB_OPCODE_DCL_CONSTANT_BUFFER = 89, + D3D10_SB_OPCODE_DCL_SAMPLER = 90, + D3D10_SB_OPCODE_DCL_INDEX_RANGE = 91, + D3D10_SB_OPCODE_DCL_GS_OUTPUT_PRIMITIVE_TOPOLOGY = 92, + D3D10_SB_OPCODE_DCL_GS_INPUT_PRIMITIVE = 93, + D3D10_SB_OPCODE_DCL_MAX_OUTPUT_VERTEX_COUNT = 94, + D3D10_SB_OPCODE_DCL_INPUT = 95, + D3D10_SB_OPCODE_DCL_INPUT_SGV = 96, + D3D10_SB_OPCODE_DCL_INPUT_SIV = 97, + D3D10_SB_OPCODE_DCL_INPUT_PS = 98, + D3D10_SB_OPCODE_DCL_INPUT_PS_SGV = 99, + D3D10_SB_OPCODE_DCL_INPUT_PS_SIV = 100, + D3D10_SB_OPCODE_DCL_OUTPUT = 101, + D3D10_SB_OPCODE_DCL_OUTPUT_SGV = 102, + D3D10_SB_OPCODE_DCL_OUTPUT_SIV = 103, + D3D10_SB_OPCODE_DCL_TEMPS = 104, + D3D10_SB_OPCODE_DCL_INDEXABLE_TEMP = 105, + D3D10_SB_OPCODE_DCL_GLOBAL_FLAGS = 106, + D3D10_SB_OPCODE_RESERVED0 = 107, + D3D10_1_SB_OPCODE_LOD = 108, + D3D10_1_SB_OPCODE_GATHER4 = 109, + D3D10_1_SB_OPCODE_SAMPLE_POS = 110, + D3D10_1_SB_OPCODE_SAMPLE_INFO = 111, + D3D10_1_SB_OPCODE_RESERVED1 = 112, + D3D11_SB_OPCODE_HS_DECLS = 113, + D3D11_SB_OPCODE_HS_CONTROL_POINT_PHASE = 114, + D3D11_SB_OPCODE_HS_FORK_PHASE = 115, + D3D11_SB_OPCODE_HS_JOIN_PHASE = 116, + D3D11_SB_OPCODE_EMIT_STREAM = 117, + D3D11_SB_OPCODE_CUT_STREAM = 118, + D3D11_SB_OPCODE_EMITTHENCUT_STREAM = 119, + D3D11_SB_OPCODE_INTERFACE_CALL = 120, + D3D11_SB_OPCODE_BUFINFO = 121, + D3D11_SB_OPCODE_DERIV_RTX_COARSE = 122, + D3D11_SB_OPCODE_DERIV_RTX_FINE = 123, + D3D11_SB_OPCODE_DERIV_RTY_COARSE = 124, + D3D11_SB_OPCODE_DERIV_RTY_FINE = 125, + D3D11_SB_OPCODE_GATHER4_C = 126, + D3D11_SB_OPCODE_GATHER4_PO = 127, + D3D11_SB_OPCODE_GATHER4_PO_C = 128, + D3D11_SB_OPCODE_RCP = 129, + D3D11_SB_OPCODE_F32TOF16 = 130, + D3D11_SB_OPCODE_F16TOF32 = 131, + D3D11_SB_OPCODE_UADDC = 132, + D3D11_SB_OPCODE_USUBB = 133, + D3D11_SB_OPCODE_COUNTBITS = 134, + D3D11_SB_OPCODE_FIRSTBIT_HI = 135, + D3D11_SB_OPCODE_FIRSTBIT_LO = 136, + D3D11_SB_OPCODE_FIRSTBIT_SHI = 137, + D3D11_SB_OPCODE_UBFE = 138, + D3D11_SB_OPCODE_IBFE = 139, + D3D11_SB_OPCODE_BFI = 140, + D3D11_SB_OPCODE_BFREV = 141, + D3D11_SB_OPCODE_SWAPC = 142, + D3D11_SB_OPCODE_DCL_STREAM = 143, + D3D11_SB_OPCODE_DCL_FUNCTION_BODY = 144, + D3D11_SB_OPCODE_DCL_FUNCTION_TABLE = 145, + D3D11_SB_OPCODE_DCL_INTERFACE = 146, + D3D11_SB_OPCODE_DCL_INPUT_CONTROL_POINT_COUNT = 147, + D3D11_SB_OPCODE_DCL_OUTPUT_CONTROL_POINT_COUNT = 148, + D3D11_SB_OPCODE_DCL_TESS_DOMAIN = 149, + D3D11_SB_OPCODE_DCL_TESS_PARTITIONING = 150, + D3D11_SB_OPCODE_DCL_TESS_OUTPUT_PRIMITIVE = 151, + D3D11_SB_OPCODE_DCL_HS_MAX_TESSFACTOR = 152, + D3D11_SB_OPCODE_DCL_HS_FORK_PHASE_INSTANCE_COUNT = 153, + D3D11_SB_OPCODE_DCL_HS_JOIN_PHASE_INSTANCE_COUNT = 154, + D3D11_SB_OPCODE_DCL_THREAD_GROUP = 155, + D3D11_SB_OPCODE_DCL_UNORDERED_ACCESS_VIEW_TYPED = 156, + D3D11_SB_OPCODE_DCL_UNORDERED_ACCESS_VIEW_RAW = 157, + D3D11_SB_OPCODE_DCL_UNORDERED_ACCESS_VIEW_STRUCTURED = 158, + D3D11_SB_OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_RAW = 159, + D3D11_SB_OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_STRUCTURED = 160, + D3D11_SB_OPCODE_DCL_RESOURCE_RAW = 161, + D3D11_SB_OPCODE_DCL_RESOURCE_STRUCTURED = 162, + D3D11_SB_OPCODE_LD_UAV_TYPED = 163, + D3D11_SB_OPCODE_STORE_UAV_TYPED = 164, + D3D11_SB_OPCODE_LD_RAW = 165, + D3D11_SB_OPCODE_STORE_RAW = 166, + D3D11_SB_OPCODE_LD_STRUCTURED = 167, + D3D11_SB_OPCODE_STORE_STRUCTURED = 168, + D3D11_SB_OPCODE_ATOMIC_AND = 169, + D3D11_SB_OPCODE_ATOMIC_OR = 170, + D3D11_SB_OPCODE_ATOMIC_XOR = 171, + D3D11_SB_OPCODE_ATOMIC_CMP_STORE = 172, + D3D11_SB_OPCODE_ATOMIC_IADD = 173, + D3D11_SB_OPCODE_ATOMIC_IMAX = 174, + D3D11_SB_OPCODE_ATOMIC_IMIN = 175, + D3D11_SB_OPCODE_ATOMIC_UMAX = 176, + D3D11_SB_OPCODE_ATOMIC_UMIN = 177, + D3D11_SB_OPCODE_IMM_ATOMIC_ALLOC = 178, + D3D11_SB_OPCODE_IMM_ATOMIC_CONSUME = 179, + D3D11_SB_OPCODE_IMM_ATOMIC_IADD = 180, + D3D11_SB_OPCODE_IMM_ATOMIC_AND = 181, + D3D11_SB_OPCODE_IMM_ATOMIC_OR = 182, + D3D11_SB_OPCODE_IMM_ATOMIC_XOR = 183, + D3D11_SB_OPCODE_IMM_ATOMIC_EXCH = 184, + D3D11_SB_OPCODE_IMM_ATOMIC_CMP_EXCH = 185, + D3D11_SB_OPCODE_IMM_ATOMIC_IMAX = 186, + D3D11_SB_OPCODE_IMM_ATOMIC_IMIN = 187, + D3D11_SB_OPCODE_IMM_ATOMIC_UMAX = 188, + D3D11_SB_OPCODE_IMM_ATOMIC_UMIN = 189, + D3D11_SB_OPCODE_SYNC = 190, + D3D11_SB_OPCODE_DADD = 191, + D3D11_SB_OPCODE_DMAX = 192, + D3D11_SB_OPCODE_DMIN = 193, + D3D11_SB_OPCODE_DMUL = 194, + D3D11_SB_OPCODE_DEQ = 195, + D3D11_SB_OPCODE_DGE = 196, + D3D11_SB_OPCODE_DLT = 197, + D3D11_SB_OPCODE_DNE = 198, + D3D11_SB_OPCODE_DMOV = 199, + D3D11_SB_OPCODE_DMOVC = 200, + D3D11_SB_OPCODE_DTOF = 201, + D3D11_SB_OPCODE_FTOD = 202, + D3D11_SB_OPCODE_EVAL_SNAPPED = 203, + D3D11_SB_OPCODE_EVAL_SAMPLE_INDEX = 204, + D3D11_SB_OPCODE_EVAL_CENTROID = 205, + D3D11_SB_OPCODE_DCL_GS_INSTANCE_COUNT = 206, + D3D11_SB_OPCODE_ABORT = 207, + D3D11_SB_OPCODE_DEBUG_BREAK = 208, + D3D11_SB_OPCODE_RESERVED0 = 209, + D3D11_1_SB_OPCODE_DDIV = 210, + D3D11_1_SB_OPCODE_DFMA = 211, + D3D11_1_SB_OPCODE_DRCP = 212, + D3D11_1_SB_OPCODE_MSAD = 213, + D3D11_1_SB_OPCODE_DTOI = 214, + D3D11_1_SB_OPCODE_DTOU = 215, + D3D11_1_SB_OPCODE_ITOD = 216, + D3D11_1_SB_OPCODE_UTOD = 217, + D3D11_1_SB_OPCODE_RESERVED0 = 218, + D3DWDDM1_3_SB_OPCODE_GATHER4_FEEDBACK = 219, + D3DWDDM1_3_SB_OPCODE_GATHER4_C_FEEDBACK = 220, + D3DWDDM1_3_SB_OPCODE_GATHER4_PO_FEEDBACK = 221, + D3DWDDM1_3_SB_OPCODE_GATHER4_PO_C_FEEDBACK = 222, + D3DWDDM1_3_SB_OPCODE_LD_FEEDBACK = 223, + D3DWDDM1_3_SB_OPCODE_LD_MS_FEEDBACK = 224, + D3DWDDM1_3_SB_OPCODE_LD_UAV_TYPED_FEEDBACK = 225, + D3DWDDM1_3_SB_OPCODE_LD_RAW_FEEDBACK = 226, + D3DWDDM1_3_SB_OPCODE_LD_STRUCTURED_FEEDBACK = 227, + D3DWDDM1_3_SB_OPCODE_SAMPLE_L_FEEDBACK = 228, + D3DWDDM1_3_SB_OPCODE_SAMPLE_C_LZ_FEEDBACK = 229, + D3DWDDM1_3_SB_OPCODE_SAMPLE_CLAMP_FEEDBACK = 230, + D3DWDDM1_3_SB_OPCODE_SAMPLE_B_CLAMP_FEEDBACK = 231, + D3DWDDM1_3_SB_OPCODE_SAMPLE_D_CLAMP_FEEDBACK = 232, + D3DWDDM1_3_SB_OPCODE_SAMPLE_C_CLAMP_FEEDBACK = 233, + D3DWDDM1_3_SB_OPCODE_CHECK_ACCESS_FULLY_MAPPED = 234, + D3DWDDM1_3_SB_OPCODE_RESERVED0 = 235, + D3D10_SB_NUM_OPCODES = 236, +}} +pub const D3D10_SB_OPCODE_TYPE_MASK: DWORD = 0x00007ff; +#[inline] +pub fn DECODE_D3D10_SB_OPCODE_TYPE(OpcodeToken0: DWORD) -> D3D10_SB_OPCODE_TYPE { + (OpcodeToken0 & D3D10_SB_OPCODE_TYPE_MASK) as D3D10_SB_OPCODE_TYPE +} +#[inline] +pub fn ENCODE_D3D10_SB_OPCODE_TYPE(OpcodeName: D3D10_SB_OPCODE_TYPE) -> DWORD { + OpcodeName & D3D10_SB_OPCODE_TYPE_MASK +} +pub const D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH_MASK: DWORD = 0x7f000000; +pub const D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH_SHIFT: DWORD = 24; +#[inline] +pub fn DECODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(OpcodeToken0: DWORD) -> DWORD { + (OpcodeToken0 & D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH_MASK) >> D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH_SHIFT +} +#[inline] +pub fn ENCODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(Length: DWORD) -> DWORD { + (Length << D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH_SHIFT) & D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH_MASK +} +pub const MAX_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH: DWORD = 127; +pub const D3D10_SB_INSTRUCTION_SATURATE_MASK: DWORD = 0x00002000; +#[inline] +pub fn DECODE_IS_D3D10_SB_INSTRUCTION_SATURATE_ENABLED(OpcodeToken0: DWORD) -> DWORD { + OpcodeToken0 & D3D10_SB_INSTRUCTION_SATURATE_MASK +} +#[inline] +pub fn ENCODE_D3D10_SB_INSTRUCTION_SATURATE(bSat: DWORD) -> DWORD { + if bSat != 0 { + D3D10_SB_INSTRUCTION_SATURATE_MASK + } else { + 0 + } +} +ENUM!{enum D3D10_SB_INSTRUCTION_TEST_BOOLEAN { + D3D10_SB_INSTRUCTION_TEST_ZERO = 0, + D3D10_SB_INSTRUCTION_TEST_NONZERO = 1, +}} +pub const D3D10_SB_INSTRUCTION_TEST_BOOLEAN_MASK: DWORD = 0x00040000; +pub const D3D10_SB_INSTRUCTION_TEST_BOOLEAN_SHIFT: DWORD = 18; +#[inline] +pub fn DECODE_D3D10_SB_INSTRUCTION_TEST_BOOLEAN(OpcodeToken0: DWORD) -> D3D10_SB_INSTRUCTION_TEST_BOOLEAN { + ((OpcodeToken0 & D3D10_SB_INSTRUCTION_TEST_BOOLEAN_MASK) >> D3D10_SB_INSTRUCTION_TEST_BOOLEAN_SHIFT) as D3D10_SB_INSTRUCTION_TEST_BOOLEAN +} +#[inline] +pub fn ENCODE_D3D10_SB_INSTRUCTION_TEST_BOOLEAN(Boolean: D3D10_SB_INSTRUCTION_TEST_BOOLEAN) -> DWORD { + (Boolean << D3D10_SB_INSTRUCTION_TEST_BOOLEAN_SHIFT) & D3D10_SB_INSTRUCTION_TEST_BOOLEAN_MASK +} +pub const D3D11_SB_INSTRUCTION_PRECISE_VALUES_MASK: DWORD = 0x00780000; +pub const D3D11_SB_INSTRUCTION_PRECISE_VALUES_SHIFT: DWORD = 19; +#[inline] +pub fn DECODE_D3D11_SB_INSTRUCTION_PRECISE_VALUES(OpcodeToken0: DWORD) -> DWORD { + (OpcodeToken0 & D3D11_SB_INSTRUCTION_PRECISE_VALUES_MASK) >> D3D11_SB_INSTRUCTION_PRECISE_VALUES_SHIFT +} +#[inline] +pub fn ENCODE_D3D11_SB_INSTRUCTION_PRECISE_VALUES(ComponentMask: DWORD) -> DWORD { + (ComponentMask << D3D11_SB_INSTRUCTION_PRECISE_VALUES_SHIFT) & D3D11_SB_INSTRUCTION_PRECISE_VALUES_MASK +} +ENUM!{enum D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE { + D3D10_SB_RESINFO_INSTRUCTION_RETURN_FLOAT = 0, + D3D10_SB_RESINFO_INSTRUCTION_RETURN_RCPFLOAT = 1, + D3D10_SB_RESINFO_INSTRUCTION_RETURN_UINT = 2, +}} +pub const D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE_MASK: DWORD = 0x00001800; +pub const D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE(OpcodeToken0: DWORD) -> D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE { + ((OpcodeToken0 & D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE_MASK) >> D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE_SHIFT) as D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE +} +#[inline] +pub fn ENCODE_D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE(ReturnType: D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE) -> DWORD { + (ReturnType << D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE_SHIFT) & D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE_MASK +} +pub const D3D11_SB_SYNC_THREADS_IN_GROUP: DWORD = 0x00000800; +pub const D3D11_SB_SYNC_THREAD_GROUP_SHARED_MEMORY: DWORD = 0x00001000; +pub const D3D11_SB_SYNC_UNORDERED_ACCESS_VIEW_MEMORY_GROUP: DWORD = 0x00002000; +pub const D3D11_SB_SYNC_UNORDERED_ACCESS_VIEW_MEMORY_GLOBAL: DWORD = 0x00004000; +pub const D3D11_SB_SYNC_FLAGS_MASK: DWORD = 0x00007800; +#[inline] +pub fn DECODE_D3D11_SB_SYNC_FLAGS(OperandToken0: DWORD) -> DWORD { + OperandToken0 & D3D11_SB_SYNC_FLAGS_MASK +} +#[inline] +pub fn ENCODE_D3D11_SB_SYNC_FLAGS(Flags: DWORD) -> DWORD { + Flags & D3D11_SB_SYNC_FLAGS_MASK +} +pub const D3D10_SB_OPCODE_EXTENDED_MASK: DWORD = 0x80000000; +pub const D3D10_SB_OPCODE_EXTENDED_SHIFT: DWORD = 31; +#[inline] +pub fn DECODE_IS_D3D10_SB_OPCODE_EXTENDED(OpcodeToken0: DWORD) -> DWORD { + (OpcodeToken0 & D3D10_SB_OPCODE_EXTENDED_MASK) >> D3D10_SB_OPCODE_EXTENDED_SHIFT +} +#[inline] +pub fn ENCODE_D3D10_SB_OPCODE_EXTENDED(bExtended: DWORD) -> DWORD { + if bExtended != 0 { + D3D10_SB_OPCODE_EXTENDED_MASK + } else { + 0 + } +} +ENUM!{enum D3D10_SB_EXTENDED_OPCODE_TYPE { + D3D10_SB_EXTENDED_OPCODE_EMPTY = 0, + D3D10_SB_EXTENDED_OPCODE_SAMPLE_CONTROLS = 1, + D3D11_SB_EXTENDED_OPCODE_RESOURCE_DIM = 2, + D3D11_SB_EXTENDED_OPCODE_RESOURCE_RETURN_TYPE = 3, +}} +pub const D3D11_SB_MAX_SIMULTANEOUS_EXTENDED_OPCODES: DWORD = 3; +pub const D3D10_SB_EXTENDED_OPCODE_TYPE_MASK: DWORD = 0x0000003f; +#[inline] +pub fn DECODE_D3D10_SB_EXTENDED_OPCODE_TYPE(OpcodeToken1: DWORD) -> D3D10_SB_EXTENDED_OPCODE_TYPE { + (OpcodeToken1 & D3D10_SB_EXTENDED_OPCODE_TYPE_MASK) as D3D10_SB_EXTENDED_OPCODE_TYPE +} +#[inline] +pub fn ENCODE_D3D10_SB_EXTENDED_OPCODE_TYPE(ExtOpcodeType: D3D10_SB_EXTENDED_OPCODE_TYPE) -> DWORD { + ExtOpcodeType & D3D10_SB_EXTENDED_OPCODE_TYPE_MASK +} +ENUM!{enum D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_COORD { + D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_U = 0, + D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_V = 1, + D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_W = 2, +}} +pub const D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_COORD_MASK: DWORD = 3; +#[inline] +pub fn D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_SHIFT(Coord: DWORD) -> DWORD { + 9 + 4 * (Coord & D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_COORD_MASK) +} +#[inline] +pub fn D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_MASK(Coord: DWORD) -> DWORD { + 0x0000000f << D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_SHIFT(Coord) +} +#[inline] +pub fn DECODE_IMMEDIATE_D3D10_SB_ADDRESS_OFFSET(Coord: DWORD, OpcodeToken1: DWORD) -> DWORD { + (OpcodeToken1 & D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_MASK(Coord)) >> D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_SHIFT(Coord) +} +#[inline] +pub fn ENCODE_IMMEDIATE_D3D10_SB_ADDRESS_OFFSET(Coord: DWORD, ImmediateOffset: DWORD) -> DWORD { + (ImmediateOffset << D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_SHIFT(Coord)) & D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_MASK(Coord) +} +pub const D3D11_SB_EXTENDED_RESOURCE_DIMENSION_MASK: DWORD = 0x000007C0; +pub const D3D11_SB_EXTENDED_RESOURCE_DIMENSION_SHIFT: DWORD = 6; +#[inline] +pub fn DECODE_D3D11_SB_EXTENDED_RESOURCE_DIMENSION(OpcodeTokenN: DWORD) -> D3D10_SB_RESOURCE_DIMENSION { + ((OpcodeTokenN & D3D11_SB_EXTENDED_RESOURCE_DIMENSION_MASK) >> D3D11_SB_EXTENDED_RESOURCE_DIMENSION_SHIFT) as D3D10_SB_RESOURCE_DIMENSION +} +#[inline] +pub fn ENCODE_D3D11_SB_EXTENDED_RESOURCE_DIMENSION(ResourceDim: D3D10_SB_RESOURCE_DIMENSION) -> DWORD { + (ResourceDim << D3D11_SB_EXTENDED_RESOURCE_DIMENSION_SHIFT) & D3D11_SB_EXTENDED_RESOURCE_DIMENSION_MASK +} +pub const D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE_MASK: DWORD = 0x007FF800; +pub const D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE(OpcodeTokenN: DWORD) -> DWORD { + (OpcodeTokenN & D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE_MASK) >> D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE_SHIFT +} +#[inline] +pub fn ENCODE_D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE(Stride: DWORD) -> DWORD { + (Stride << D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE_SHIFT) & D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE_MASK +} +pub const D3D10_SB_RESOURCE_RETURN_TYPE_MASK: DWORD = 0x0000000f; +pub const D3D10_SB_RESOURCE_RETURN_TYPE_NUMBITS: DWORD = 0x00000004; +pub const D3D11_SB_EXTENDED_RESOURCE_RETURN_TYPE_SHIFT: DWORD = 6; +#[inline] +pub fn DECODE_D3D11_SB_EXTENDED_RESOURCE_RETURN_TYPE(OpcodeTokenN: DWORD, Component: DWORD) -> DWORD { + ((OpcodeTokenN >> (Component * D3D10_SB_RESOURCE_RETURN_TYPE_NUMBITS + D3D11_SB_EXTENDED_RESOURCE_RETURN_TYPE_SHIFT)) & D3D10_SB_RESOURCE_RETURN_TYPE_MASK) as D3D10_SB_RESOURCE_RETURN_TYPE +} +#[inline] +pub fn ENCODE_D3D11_SB_EXTENDED_RESOURCE_RETURN_TYPE(ReturnType: DWORD, Component: DWORD) -> DWORD { + (ReturnType & D3D10_SB_RESOURCE_RETURN_TYPE_MASK) << (Component * D3D10_SB_RESOURCE_RETURN_TYPE_NUMBITS + D3D11_SB_EXTENDED_RESOURCE_RETURN_TYPE_SHIFT) +} +ENUM!{enum D3D10_SB_CUSTOMDATA_CLASS { + D3D10_SB_CUSTOMDATA_COMMENT = 0, + D3D10_SB_CUSTOMDATA_DEBUGINFO = 1, + D3D10_SB_CUSTOMDATA_OPAQUE = 2, + D3D10_SB_CUSTOMDATA_DCL_IMMEDIATE_CONSTANT_BUFFER = 3, + D3D11_SB_CUSTOMDATA_SHADER_MESSAGE = 4, + D3D11_SB_CUSTOMDATA_SHADER_CLIP_PLANE_CONSTANT_MAPPINGS_FOR_DX9 = 5, +}} +pub const D3D10_SB_CUSTOMDATA_CLASS_MASK: DWORD = 0xfffff800; +pub const D3D10_SB_CUSTOMDATA_CLASS_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D10_SB_CUSTOMDATA_CLASS(CustomDataDescTok: DWORD) -> D3D10_SB_CUSTOMDATA_CLASS { + ((CustomDataDescTok & D3D10_SB_CUSTOMDATA_CLASS_MASK) >> D3D10_SB_CUSTOMDATA_CLASS_SHIFT) as D3D10_SB_CUSTOMDATA_CLASS +} +#[inline] +pub fn ENCODE_D3D10_SB_CUSTOMDATA_CLASS(CustomDataClass: D3D10_SB_CUSTOMDATA_CLASS) -> DWORD { + ENCODE_D3D10_SB_OPCODE_TYPE(D3D10_SB_OPCODE_CUSTOMDATA) | ((CustomDataClass << D3D10_SB_CUSTOMDATA_CLASS_SHIFT) & D3D10_SB_CUSTOMDATA_CLASS_MASK) +} +ENUM!{enum D3D10_SB_OPERAND_NUM_COMPONENTS { + D3D10_SB_OPERAND_0_COMPONENT = 0, + D3D10_SB_OPERAND_1_COMPONENT = 1, + D3D10_SB_OPERAND_4_COMPONENT = 2, + D3D10_SB_OPERAND_N_COMPONENT = 3, +}} +pub const D3D10_SB_OPERAND_NUM_COMPONENTS_MASK: DWORD = 0x00000003; +#[inline] +pub fn DECODE_D3D10_SB_OPERAND_NUM_COMPONENTS(OperandToken0: DWORD) -> DWORD { + (OperandToken0 & D3D10_SB_OPERAND_NUM_COMPONENTS_MASK) as D3D10_SB_OPERAND_NUM_COMPONENTS +} +#[inline] +pub fn ENCODE_D3D10_SB_OPERAND_NUM_COMPONENTS(NumComp: DWORD) -> DWORD { + NumComp & D3D10_SB_OPERAND_NUM_COMPONENTS_MASK +} + +ENUM!{enum D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE { + D3D10_SB_OPERAND_4_COMPONENT_MASK_MODE = 0, + D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_MODE = 1, + D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_MODE = 2, +}} +pub const D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE_MASK: DWORD = 0x0000000c; +pub const D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE_SHIFT: DWORD = 2; +#[inline] +pub fn DECODE_D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE(OperandToken0: DWORD) -> D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE { + ((OperandToken0 & D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE_MASK) >> D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE_SHIFT) as D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE +} +#[inline] +pub fn ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE(SelectionMode: D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE) -> DWORD { + (SelectionMode << D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE_SHIFT) & D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE_MASK +} +ENUM!{enum D3D10_SB_4_COMPONENT_NAME { + D3D10_SB_4_COMPONENT_X = 0, + D3D10_SB_4_COMPONENT_Y = 1, + D3D10_SB_4_COMPONENT_Z = 2, + D3D10_SB_4_COMPONENT_W = 3, + D3D10_SB_4_COMPONENT_R = 0, + D3D10_SB_4_COMPONENT_G = 1, + D3D10_SB_4_COMPONENT_B = 2, + D3D10_SB_4_COMPONENT_A = 3, +}} +pub const D3D10_SB_4_COMPONENT_NAME_MASK: DWORD = 3; +pub const D3D10_SB_OPERAND_4_COMPONENT_MASK_MASK: DWORD = 0x000000f0; +pub const D3D10_SB_OPERAND_4_COMPONENT_MASK_SHIFT: DWORD = 4; +pub const D3D10_SB_OPERAND_4_COMPONENT_MASK_X: DWORD = 0x00000010; +pub const D3D10_SB_OPERAND_4_COMPONENT_MASK_Y: DWORD = 0x00000020; +pub const D3D10_SB_OPERAND_4_COMPONENT_MASK_Z: DWORD = 0x00000040; +pub const D3D10_SB_OPERAND_4_COMPONENT_MASK_W: DWORD = 0x00000080; +pub const D3D10_SB_OPERAND_4_COMPONENT_MASK_R: DWORD = D3D10_SB_OPERAND_4_COMPONENT_MASK_X; +pub const D3D10_SB_OPERAND_4_COMPONENT_MASK_G: DWORD = D3D10_SB_OPERAND_4_COMPONENT_MASK_Y; +pub const D3D10_SB_OPERAND_4_COMPONENT_MASK_B: DWORD = D3D10_SB_OPERAND_4_COMPONENT_MASK_Z; +pub const D3D10_SB_OPERAND_4_COMPONENT_MASK_A: DWORD = D3D10_SB_OPERAND_4_COMPONENT_MASK_W; +pub const D3D10_SB_OPERAND_4_COMPONENT_MASK_ALL: DWORD = D3D10_SB_OPERAND_4_COMPONENT_MASK_MASK; +#[inline] +pub fn DECODE_D3D10_SB_OPERAND_4_COMPONENT_MASK(OperandToken0: DWORD) -> DWORD { + OperandToken0 & D3D10_SB_OPERAND_4_COMPONENT_MASK_MASK +} +#[inline] +pub fn ENCODE_D3D10_SB_OPERAND_4_COMPONENT_MASK(ComponentMask: DWORD) -> DWORD { + ComponentMask & D3D10_SB_OPERAND_4_COMPONENT_MASK_MASK +} +#[inline] +pub fn D3D10_SB_OPERAND_4_COMPONENT_MASK(ComponentName: DWORD) -> DWORD { + (1 << (D3D10_SB_OPERAND_4_COMPONENT_MASK_SHIFT + ComponentName)) & D3D10_SB_OPERAND_4_COMPONENT_MASK_MASK +} +pub const D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_MASK: DWORD = 0x00000ff0; +pub const D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_SHIFT: DWORD = 4; +#[inline] +pub fn DECODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE(OperandToken0: DWORD) -> DWORD { + OperandToken0 & D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_MASK +} +#[inline] +pub fn DECODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_SOURCE(OperandToken0: DWORD, DestComp: DWORD) -> D3D10_SB_4_COMPONENT_NAME { + ((OperandToken0 >> (D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_SHIFT + 2 * (DestComp & D3D10_SB_4_COMPONENT_NAME_MASK))) & D3D10_SB_4_COMPONENT_NAME_MASK) as D3D10_SB_4_COMPONENT_NAME +} +#[inline] +pub fn ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE(XSrc: DWORD, YSrc: DWORD, ZSrc: DWORD, WSrc: DWORD) -> DWORD { + ((XSrc & D3D10_SB_4_COMPONENT_NAME_MASK) | + ((YSrc & D3D10_SB_4_COMPONENT_NAME_MASK) << 2) | + ((ZSrc & D3D10_SB_4_COMPONENT_NAME_MASK) << 4) | + ((WSrc & D3D10_SB_4_COMPONENT_NAME_MASK) << 6)) << D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_SHIFT +} +#[inline] +pub fn D3D10_SB_OPERAND_4_COMPONENT_NOSWIZZLE() -> DWORD { + ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE( + D3D10_SB_4_COMPONENT_X, + D3D10_SB_4_COMPONENT_Y, + D3D10_SB_4_COMPONENT_Z, + D3D10_SB_4_COMPONENT_W, + ) +} +#[inline] +pub fn D3D10_SB_OPERAND_4_COMPONENT_REPLICATEX() -> DWORD { + ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE( + D3D10_SB_4_COMPONENT_X, + D3D10_SB_4_COMPONENT_X, + D3D10_SB_4_COMPONENT_X, + D3D10_SB_4_COMPONENT_X, + ) +} +#[inline] +pub fn D3D10_SB_OPERAND_4_COMPONENT_REPLICATEY() -> DWORD { + ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE( + D3D10_SB_4_COMPONENT_Y, + D3D10_SB_4_COMPONENT_Y, + D3D10_SB_4_COMPONENT_Y, + D3D10_SB_4_COMPONENT_Y, + ) +} +#[inline] +pub fn D3D10_SB_OPERAND_4_COMPONENT_REPLICATEZ() -> DWORD { + ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE( + D3D10_SB_4_COMPONENT_Z, + D3D10_SB_4_COMPONENT_Z, + D3D10_SB_4_COMPONENT_Z, + D3D10_SB_4_COMPONENT_Z, + ) +} +#[inline] +pub fn D3D10_SB_OPERAND_4_COMPONENT_REPLICATEW() -> DWORD { + ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE( + D3D10_SB_4_COMPONENT_W, + D3D10_SB_4_COMPONENT_W, + D3D10_SB_4_COMPONENT_W, + D3D10_SB_4_COMPONENT_W, + ) +} +#[inline] +pub fn D3D10_SB_OPERAND_4_COMPONENT_REPLICATERED() -> DWORD { + D3D10_SB_OPERAND_4_COMPONENT_REPLICATEX() +} +#[inline] +pub fn D3D10_SB_OPERAND_4_COMPONENT_REPLICATEGREEN() -> DWORD { + D3D10_SB_OPERAND_4_COMPONENT_REPLICATEY() +} +#[inline] +pub fn D3D10_SB_OPERAND_4_COMPONENT_REPLICATEBLUE() -> DWORD { + D3D10_SB_OPERAND_4_COMPONENT_REPLICATEZ() +} +#[inline] +pub fn D3D10_SB_OPERAND_4_COMPONENT_REPLICATEALPHA() -> DWORD { + D3D10_SB_OPERAND_4_COMPONENT_REPLICATEW() +} +pub const D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_MASK: DWORD = 0x00000030; +pub const D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_SHIFT: DWORD = 4; +#[inline] +pub fn DECODE_D3D10_SB_OPERAND_4_COMPONENT_SELECT_1(OperandToken0: DWORD) -> D3D10_SB_4_COMPONENT_NAME { + ((OperandToken0 & D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_MASK) >> D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_SHIFT) as D3D10_SB_4_COMPONENT_NAME +} +#[inline] +pub fn ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SELECT_1(SelectedComp: D3D10_SB_4_COMPONENT_NAME) -> DWORD { + (SelectedComp << D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_SHIFT) & D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_MASK +} +ENUM!{enum D3D10_SB_OPERAND_TYPE { + D3D10_SB_OPERAND_TYPE_TEMP = 0, + D3D10_SB_OPERAND_TYPE_INPUT = 1, + D3D10_SB_OPERAND_TYPE_OUTPUT = 2, + D3D10_SB_OPERAND_TYPE_INDEXABLE_TEMP = 3, + D3D10_SB_OPERAND_TYPE_IMMEDIATE32 = 4, + D3D10_SB_OPERAND_TYPE_IMMEDIATE64 = 5, + D3D10_SB_OPERAND_TYPE_SAMPLER = 6, + D3D10_SB_OPERAND_TYPE_RESOURCE = 7, + D3D10_SB_OPERAND_TYPE_CONSTANT_BUFFER= 8, + D3D10_SB_OPERAND_TYPE_IMMEDIATE_CONSTANT_BUFFER= 9, + D3D10_SB_OPERAND_TYPE_LABEL = 10, + D3D10_SB_OPERAND_TYPE_INPUT_PRIMITIVEID = 11, + D3D10_SB_OPERAND_TYPE_OUTPUT_DEPTH = 12, + D3D10_SB_OPERAND_TYPE_NULL = 13, + D3D10_SB_OPERAND_TYPE_RASTERIZER = 14, + D3D10_SB_OPERAND_TYPE_OUTPUT_COVERAGE_MASK = 15, + D3D11_SB_OPERAND_TYPE_STREAM = 16, + D3D11_SB_OPERAND_TYPE_FUNCTION_BODY = 17, + D3D11_SB_OPERAND_TYPE_FUNCTION_TABLE = 18, + D3D11_SB_OPERAND_TYPE_INTERFACE = 19, + D3D11_SB_OPERAND_TYPE_FUNCTION_INPUT = 20, + D3D11_SB_OPERAND_TYPE_FUNCTION_OUTPUT = 21, + D3D11_SB_OPERAND_TYPE_OUTPUT_CONTROL_POINT_ID = 22, + D3D11_SB_OPERAND_TYPE_INPUT_FORK_INSTANCE_ID = 23, + D3D11_SB_OPERAND_TYPE_INPUT_JOIN_INSTANCE_ID = 24, + D3D11_SB_OPERAND_TYPE_INPUT_CONTROL_POINT = 25, + D3D11_SB_OPERAND_TYPE_OUTPUT_CONTROL_POINT = 26, + D3D11_SB_OPERAND_TYPE_INPUT_PATCH_CONSTANT = 27, + D3D11_SB_OPERAND_TYPE_INPUT_DOMAIN_POINT = 28, + D3D11_SB_OPERAND_TYPE_THIS_POINTER = 29, + D3D11_SB_OPERAND_TYPE_UNORDERED_ACCESS_VIEW = 30, + D3D11_SB_OPERAND_TYPE_THREAD_GROUP_SHARED_MEMORY = 31, + D3D11_SB_OPERAND_TYPE_INPUT_THREAD_ID = 32, + D3D11_SB_OPERAND_TYPE_INPUT_THREAD_GROUP_ID = 33, + D3D11_SB_OPERAND_TYPE_INPUT_THREAD_ID_IN_GROUP = 34, + D3D11_SB_OPERAND_TYPE_INPUT_COVERAGE_MASK = 35, + D3D11_SB_OPERAND_TYPE_INPUT_THREAD_ID_IN_GROUP_FLATTENED = 36, + D3D11_SB_OPERAND_TYPE_INPUT_GS_INSTANCE_ID = 37, + D3D11_SB_OPERAND_TYPE_OUTPUT_DEPTH_GREATER_EQUAL = 38, + D3D11_SB_OPERAND_TYPE_OUTPUT_DEPTH_LESS_EQUAL = 39, + D3D11_SB_OPERAND_TYPE_CYCLE_COUNTER = 40, +}} +pub const D3D10_SB_OPERAND_TYPE_MASK: DWORD = 0x000ff000; +pub const D3D10_SB_OPERAND_TYPE_SHIFT: DWORD = 12; +#[inline] +pub fn DECODE_D3D10_SB_OPERAND_TYPE(OperandToken0: DWORD) -> D3D10_SB_OPERAND_TYPE { + ((OperandToken0 & D3D10_SB_OPERAND_TYPE_MASK) >> D3D10_SB_OPERAND_TYPE_SHIFT) as D3D10_SB_OPERAND_TYPE +} +#[inline] +pub fn ENCODE_D3D10_SB_OPERAND_TYPE(OperandType: D3D10_SB_OPERAND_TYPE) -> DWORD { + (OperandType << D3D10_SB_OPERAND_TYPE_SHIFT) & D3D10_SB_OPERAND_TYPE_MASK +} +ENUM!{enum D3D10_SB_OPERAND_INDEX_DIMENSION { + D3D10_SB_OPERAND_INDEX_0D = 0, + D3D10_SB_OPERAND_INDEX_1D = 1, + D3D10_SB_OPERAND_INDEX_2D = 2, + D3D10_SB_OPERAND_INDEX_3D = 3, +}} +pub const D3D10_SB_OPERAND_INDEX_DIMENSION_MASK: DWORD = 0x00300000; +pub const D3D10_SB_OPERAND_INDEX_DIMENSION_SHIFT: DWORD = 20; +#[inline] +pub fn DECODE_D3D10_SB_OPERAND_INDEX_DIMENSION(OperandToken0: DWORD) -> D3D10_SB_OPERAND_INDEX_DIMENSION { + ((OperandToken0 & D3D10_SB_OPERAND_INDEX_DIMENSION_MASK) >> D3D10_SB_OPERAND_INDEX_DIMENSION_SHIFT) as D3D10_SB_OPERAND_INDEX_DIMENSION +} +#[inline] +pub fn ENCODE_D3D10_SB_OPERAND_INDEX_DIMENSION(OperandIndexDim: D3D10_SB_OPERAND_INDEX_DIMENSION) -> DWORD { + (OperandIndexDim << D3D10_SB_OPERAND_INDEX_DIMENSION_SHIFT) & D3D10_SB_OPERAND_INDEX_DIMENSION_MASK +} +ENUM!{enum D3D10_SB_OPERAND_INDEX_REPRESENTATION { + D3D10_SB_OPERAND_INDEX_IMMEDIATE32 = 0, + D3D10_SB_OPERAND_INDEX_IMMEDIATE64 = 1, + D3D10_SB_OPERAND_INDEX_RELATIVE = 2, + D3D10_SB_OPERAND_INDEX_IMMEDIATE32_PLUS_RELATIVE = 3, + D3D10_SB_OPERAND_INDEX_IMMEDIATE64_PLUS_RELATIVE = 4, +}} +#[inline] +pub fn D3D10_SB_OPERAND_INDEX_REPRESENTATION_SHIFT(Dim: DWORD) -> DWORD { + 22 + 3 * (Dim & 3) +} +#[inline] +pub fn D3D10_SB_OPERAND_INDEX_REPRESENTATION_MASK(Dim: DWORD) -> DWORD { + 0x3 << D3D10_SB_OPERAND_INDEX_REPRESENTATION_SHIFT(Dim) +} +#[inline] +pub fn DECODE_D3D10_SB_OPERAND_INDEX_REPRESENTATION(Dim: DWORD, OperandToken0: DWORD) -> D3D10_SB_OPERAND_INDEX_REPRESENTATION { + ((OperandToken0 & D3D10_SB_OPERAND_INDEX_REPRESENTATION_MASK(Dim)) >> D3D10_SB_OPERAND_INDEX_REPRESENTATION_SHIFT(Dim)) as D3D10_SB_OPERAND_INDEX_REPRESENTATION +} +#[inline] +pub fn ENCODE_D3D10_SB_OPERAND_INDEX_REPRESENTATION(Dim: DWORD, IndexRepresentation: D3D10_SB_OPERAND_INDEX_REPRESENTATION) -> DWORD { + (IndexRepresentation << D3D10_SB_OPERAND_INDEX_REPRESENTATION_SHIFT(Dim)) & D3D10_SB_OPERAND_INDEX_REPRESENTATION_MASK(Dim) +} +pub const D3D10_SB_OPERAND_EXTENDED_MASK: DWORD = 0x80000000; +pub const D3D10_SB_OPERAND_EXTENDED_SHIFT: DWORD = 31; +#[inline] +pub fn DECODE_IS_D3D10_SB_OPERAND_EXTENDED(OperandToken0: DWORD) -> DWORD { + (OperandToken0 & D3D10_SB_OPERAND_EXTENDED_MASK) >> D3D10_SB_OPERAND_EXTENDED_SHIFT +} +#[inline] +pub fn ENCODE_D3D10_SB_OPERAND_EXTENDED(bExtended: DWORD) -> DWORD { + if bExtended != 0 { + D3D10_SB_OPERAND_EXTENDED_MASK + } else { + 0 + } +} +ENUM!{enum D3D10_SB_EXTENDED_OPERAND_TYPE { + D3D10_SB_EXTENDED_OPERAND_EMPTY = 0, + D3D10_SB_EXTENDED_OPERAND_MODIFIER = 1, +}} +pub const D3D10_SB_EXTENDED_OPERAND_TYPE_MASK: DWORD = 0x0000003f; +#[inline] +pub fn DECODE_D3D10_SB_EXTENDED_OPERAND_TYPE(OperandToken1: DWORD) -> D3D10_SB_EXTENDED_OPERAND_TYPE { + (OperandToken1 & D3D10_SB_EXTENDED_OPERAND_TYPE_MASK) as D3D10_SB_EXTENDED_OPERAND_TYPE +} +#[inline] +pub fn ENCODE_D3D10_SB_EXTENDED_OPERAND_TYPE(ExtOperandType: D3D10_SB_EXTENDED_OPERAND_TYPE) -> DWORD { + ExtOperandType & D3D10_SB_EXTENDED_OPERAND_TYPE_MASK +} +ENUM!{enum D3D10_SB_OPERAND_MODIFIER { + D3D10_SB_OPERAND_MODIFIER_NONE = 0, + D3D10_SB_OPERAND_MODIFIER_NEG = 1, + D3D10_SB_OPERAND_MODIFIER_ABS = 2, + D3D10_SB_OPERAND_MODIFIER_ABSNEG = 3, +}} +pub const D3D10_SB_OPERAND_MODIFIER_MASK: DWORD = 0x00003fc0; +pub const D3D10_SB_OPERAND_MODIFIER_SHIFT: DWORD = 6; +#[inline] +pub fn DECODE_D3D10_SB_OPERAND_MODIFIER(OperandToken1: DWORD) -> D3D10_SB_OPERAND_MODIFIER { + ((OperandToken1 & D3D10_SB_OPERAND_MODIFIER_MASK) >> D3D10_SB_OPERAND_MODIFIER_SHIFT) as D3D10_SB_OPERAND_MODIFIER +} +#[inline] +pub fn ENCODE_D3D10_SB_EXTENDED_OPERAND_MODIFIER(SourceMod: D3D10_SB_OPERAND_MODIFIER) -> DWORD { + ((SourceMod << D3D10_SB_OPERAND_MODIFIER_SHIFT) & D3D10_SB_OPERAND_MODIFIER_MASK) | + ENCODE_D3D10_SB_EXTENDED_OPERAND_TYPE(D3D10_SB_EXTENDED_OPERAND_MODIFIER) | + ENCODE_D3D10_SB_OPERAND_DOUBLE_EXTENDED(0) +} +ENUM!{enum D3D11_SB_OPERAND_MIN_PRECISION { + D3D11_SB_OPERAND_MIN_PRECISION_DEFAULT = 0, + D3D11_SB_OPERAND_MIN_PRECISION_FLOAT_16 = 1, + D3D11_SB_OPERAND_MIN_PRECISION_FLOAT_2_8 = 2, + D3D11_SB_OPERAND_MIN_PRECISION_SINT_16 = 4, + D3D11_SB_OPERAND_MIN_PRECISION_UINT_16 = 5, +}} +pub const D3D11_SB_OPERAND_MIN_PRECISION_MASK: DWORD = 0x0001C000; +pub const D3D11_SB_OPERAND_MIN_PRECISION_SHIFT: DWORD = 14; + +#[inline] +pub fn DECODE_D3D11_SB_OPERAND_MIN_PRECISION(OperandToken1: DWORD) -> D3D11_SB_OPERAND_MIN_PRECISION { + ((OperandToken1 & D3D11_SB_OPERAND_MIN_PRECISION_MASK) >> D3D11_SB_OPERAND_MIN_PRECISION_SHIFT) as D3D11_SB_OPERAND_MIN_PRECISION +} +#[inline] +pub fn ENCODE_D3D11_SB_OPERAND_MIN_PRECISION(MinPrecision: D3D11_SB_OPERAND_MIN_PRECISION) -> DWORD { + (MinPrecision << D3D11_SB_OPERAND_MIN_PRECISION_SHIFT) & D3D11_SB_OPERAND_MIN_PRECISION_MASK +} +pub const D3D10_SB_OPERAND_DOUBLE_EXTENDED_MASK: DWORD = 0x80000000; +pub const D3D10_SB_OPERAND_DOUBLE_EXTENDED_SHIFT: DWORD = 31; +#[inline] +pub fn DECODE_IS_D3D10_SB_OPERAND_DOUBLE_EXTENDED(OperandToken1: DWORD) -> DWORD { + (OperandToken1 & D3D10_SB_OPERAND_DOUBLE_EXTENDED_MASK) >> D3D10_SB_OPERAND_DOUBLE_EXTENDED_SHIFT +} +#[inline] +pub fn ENCODE_D3D10_SB_OPERAND_DOUBLE_EXTENDED(bExtended: DWORD) -> DWORD { + if bExtended != 0 { + D3D10_SB_OPERAND_DOUBLE_EXTENDED_MASK + } else { + 0 + } +} +pub const D3D10_SB_NAME_MASK: DWORD = 0x0000ffff; +#[inline] +pub fn DECODE_D3D10_SB_NAME(NameToken: DWORD) -> D3D10_SB_NAME { + (NameToken & D3D10_SB_NAME_MASK) as D3D10_SB_NAME +} +#[inline] +pub fn ENCODE_D3D10_SB_NAME(Name: D3D10_SB_NAME) -> DWORD { + Name & D3D10_SB_NAME_MASK +} +pub const D3D10_SB_GLOBAL_FLAG_REFACTORING_ALLOWED: DWORD = (1<<11); +pub const D3D11_SB_GLOBAL_FLAG_ENABLE_DOUBLE_PRECISION_FLOAT_OPS: DWORD = (1<<12); +pub const D3D11_SB_GLOBAL_FLAG_FORCE_EARLY_DEPTH_STENCIL: DWORD = (1<<13); +pub const D3D11_SB_GLOBAL_FLAG_ENABLE_RAW_AND_STRUCTURED_BUFFERS: DWORD = (1<<14); +pub const D3D11_1_SB_GLOBAL_FLAG_SKIP_OPTIMIZATION: DWORD = (1<<15); +pub const D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION: DWORD = (1<<16); +pub const D3D11_1_SB_GLOBAL_FLAG_ENABLE_DOUBLE_EXTENSIONS: DWORD = (1<<17); +pub const D3D11_1_SB_GLOBAL_FLAG_ENABLE_SHADER_EXTENSIONS: DWORD = (1<<18); +pub const D3D10_SB_GLOBAL_FLAGS_MASK: DWORD = 0x00fff800; +#[inline] +pub fn DECODE_D3D10_SB_GLOBAL_FLAGS(OpcodeToken0: DWORD) -> DWORD { + OpcodeToken0 & D3D10_SB_GLOBAL_FLAGS_MASK +} +#[inline] +pub fn ENCODE_D3D10_SB_GLOBAL_FLAGS(Flags: DWORD) -> DWORD { + Flags & D3D10_SB_GLOBAL_FLAGS_MASK +} +pub const D3D10_SB_RESOURCE_DIMENSION_MASK: DWORD = 0x0000F800; +pub const D3D10_SB_RESOURCE_DIMENSION_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D10_SB_RESOURCE_DIMENSION(OpcodeToken0: DWORD) -> D3D10_SB_RESOURCE_DIMENSION { + ((OpcodeToken0 & D3D10_SB_RESOURCE_DIMENSION_MASK) >> D3D10_SB_RESOURCE_DIMENSION_SHIFT) as D3D10_SB_RESOURCE_DIMENSION +} +#[inline] +pub fn ENCODE_D3D10_SB_RESOURCE_DIMENSION(ResourceDim: D3D10_SB_RESOURCE_DIMENSION) -> DWORD { + (ResourceDim << D3D10_SB_RESOURCE_DIMENSION_SHIFT) & D3D10_SB_RESOURCE_DIMENSION_MASK +} +pub const D3D10_SB_RESOURCE_SAMPLE_COUNT_MASK: DWORD = 0x07F0000; +pub const D3D10_SB_RESOURCE_SAMPLE_COUNT_SHIFT: DWORD = 16; +#[inline] +pub fn DECODE_D3D10_SB_RESOURCE_SAMPLE_COUNT(OpcodeToken0: DWORD) -> UINT { + ((OpcodeToken0 & D3D10_SB_RESOURCE_SAMPLE_COUNT_MASK) >> D3D10_SB_RESOURCE_SAMPLE_COUNT_SHIFT) as UINT +} +#[inline] +pub fn ENCODE_D3D10_SB_RESOURCE_SAMPLE_COUNT(SampleCount: DWORD) -> DWORD { + (if SampleCount > 127 { + 127 + } else { + SampleCount + } << D3D10_SB_RESOURCE_SAMPLE_COUNT_SHIFT) & D3D10_SB_RESOURCE_SAMPLE_COUNT_MASK +} +#[inline] +pub fn DECODE_D3D10_SB_RESOURCE_RETURN_TYPE(ResourceReturnTypeToken: D3D10_SB_RESOURCE_RETURN_TYPE, Component: DWORD) -> D3D10_SB_RESOURCE_RETURN_TYPE { + ((ResourceReturnTypeToken >> (Component * D3D10_SB_RESOURCE_RETURN_TYPE_NUMBITS)) & D3D10_SB_RESOURCE_RETURN_TYPE_MASK) as D3D10_SB_RESOURCE_RETURN_TYPE +} +#[inline] +pub fn ENCODE_D3D10_SB_RESOURCE_RETURN_TYPE(ReturnType: DWORD, Component: DWORD) -> D3D10_SB_RESOURCE_RETURN_TYPE { + (ReturnType & D3D10_SB_RESOURCE_RETURN_TYPE_MASK) << (Component * D3D10_SB_RESOURCE_RETURN_TYPE_NUMBITS) +} +ENUM!{enum D3D10_SB_SAMPLER_MODE { + D3D10_SB_SAMPLER_MODE_DEFAULT = 0, + D3D10_SB_SAMPLER_MODE_COMPARISON = 1, + D3D10_SB_SAMPLER_MODE_MONO = 2, +}} +pub const D3D10_SB_SAMPLER_MODE_MASK: DWORD = 0x00007800; +pub const D3D10_SB_SAMPLER_MODE_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D10_SB_SAMPLER_MODE(OpcodeToken0: DWORD) -> D3D10_SB_SAMPLER_MODE { + ((OpcodeToken0 & D3D10_SB_SAMPLER_MODE_MASK) >> D3D10_SB_SAMPLER_MODE_SHIFT) as D3D10_SB_SAMPLER_MODE +} +#[inline] +pub fn ENCODE_D3D10_SB_SAMPLER_MODE(SamplerMode: D3D10_SB_SAMPLER_MODE) -> DWORD { + (SamplerMode << D3D10_SB_SAMPLER_MODE_SHIFT) & D3D10_SB_SAMPLER_MODE_MASK +} +pub const D3D10_SB_INPUT_INTERPOLATION_MODE_MASK: DWORD = 0x00007800; +pub const D3D10_SB_INPUT_INTERPOLATION_MODE_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D10_SB_INPUT_INTERPOLATION_MODE(OpcodeToken0: DWORD) -> D3D10_SB_INTERPOLATION_MODE { + ((OpcodeToken0 & D3D10_SB_INPUT_INTERPOLATION_MODE_MASK) >> D3D10_SB_INPUT_INTERPOLATION_MODE_SHIFT) as D3D10_SB_INTERPOLATION_MODE +} +#[inline] +pub fn ENCODE_D3D10_SB_INPUT_INTERPOLATION_MODE(InterpolationMode: D3D10_SB_INTERPOLATION_MODE) -> DWORD { + (InterpolationMode << D3D10_SB_INPUT_INTERPOLATION_MODE_SHIFT) & D3D10_SB_INPUT_INTERPOLATION_MODE_MASK +} +ENUM!{enum D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN { + D3D10_SB_CONSTANT_BUFFER_IMMEDIATE_INDEXED = 0, + D3D10_SB_CONSTANT_BUFFER_DYNAMIC_INDEXED = 1, +}} +pub const D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN_MASK: DWORD = 0x00000800; +pub const D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN(OpcodeToken0: DWORD) -> D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN { + ((OpcodeToken0 & D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN_MASK) >> D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN_SHIFT) as D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN + +} +#[inline] +pub fn ENCODE_D3D10_SB_D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN(AccessPattern: D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN) -> DWORD { + (AccessPattern << D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN_SHIFT) & D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN_MASK +} +ENUM!{enum D3D11_SB_SHADER_MESSAGE_ID { + D3D11_SB_SHADER_MESSAGE_ID_MESSAGE = 0x00200102, + D3D11_SB_SHADER_MESSAGE_ID_ERROR = 0x00200103, +}} + +ENUM!{enum D3D11_SB_SHADER_MESSAGE_FORMAT { + D3D11_SB_SHADER_MESSAGE_FORMAT_ANSI_TEXT = 0, + D3D11_SB_SHADER_MESSAGE_FORMAT_ANSI_PRINTF = 1, +}} +pub const D3D10_SB_GS_INPUT_PRIMITIVE_MASK: DWORD = 0x0001f800; +pub const D3D10_SB_GS_INPUT_PRIMITIVE_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D10_SB_GS_INPUT_PRIMITIVE(OpcodeToken0: DWORD) -> D3D10_SB_PRIMITIVE { + ((OpcodeToken0 & D3D10_SB_GS_INPUT_PRIMITIVE_MASK) >> D3D10_SB_GS_INPUT_PRIMITIVE_SHIFT) as D3D10_SB_PRIMITIVE +} +#[inline] +pub fn ENCODE_D3D10_SB_GS_INPUT_PRIMITIVE(Prim: D3D10_SB_PRIMITIVE) -> DWORD { + (Prim << D3D10_SB_GS_INPUT_PRIMITIVE_SHIFT) & D3D10_SB_GS_INPUT_PRIMITIVE_MASK +} +pub const D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY_MASK: DWORD = 0x0001f800; +pub const D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY(OpcodeToken0: DWORD) -> D3D10_SB_PRIMITIVE_TOPOLOGY { + ((OpcodeToken0 & D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY_MASK) >> D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY_SHIFT) as D3D10_SB_PRIMITIVE_TOPOLOGY +} +#[inline] +pub fn ENCODE_D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY(PrimTopology: D3D10_SB_PRIMITIVE_TOPOLOGY) -> DWORD { + (PrimTopology << D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY_SHIFT) & D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY_MASK +} +pub const D3D11_SB_INPUT_CONTROL_POINT_COUNT_MASK: DWORD = 0x0001f800; +pub const D3D11_SB_INPUT_CONTROL_POINT_COUNT_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D11_SB_INPUT_CONTROL_POINT_COUNT(OpcodeToken0: DWORD) -> UINT { + ((OpcodeToken0 & D3D11_SB_INPUT_CONTROL_POINT_COUNT_MASK) >> D3D11_SB_INPUT_CONTROL_POINT_COUNT_SHIFT) as UINT +} +#[inline] +pub fn ENCODE_D3D11_SB_INPUT_CONTROL_POINT_COUNT(Count: DWORD) -> DWORD { + (Count << D3D11_SB_INPUT_CONTROL_POINT_COUNT_SHIFT) & D3D11_SB_INPUT_CONTROL_POINT_COUNT_MASK +} +pub const D3D11_SB_OUTPUT_CONTROL_POINT_COUNT_MASK: DWORD = 0x0001f800; +pub const D3D11_SB_OUTPUT_CONTROL_POINT_COUNT_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D11_SB_OUTPUT_CONTROL_POINT_COUNT(OpcodeToken0: DWORD) -> UINT { + ((OpcodeToken0 & D3D11_SB_OUTPUT_CONTROL_POINT_COUNT_MASK) >> D3D11_SB_OUTPUT_CONTROL_POINT_COUNT_SHIFT) as UINT +} +#[inline] +pub fn ENCODE_D3D11_SB_OUTPUT_CONTROL_POINT_COUNT(Count: DWORD) -> DWORD { + (Count << D3D11_SB_OUTPUT_CONTROL_POINT_COUNT_SHIFT) & D3D11_SB_OUTPUT_CONTROL_POINT_COUNT_MASK +} +ENUM!{enum D3D11_SB_TESSELLATOR_DOMAIN { + D3D11_SB_TESSELLATOR_DOMAIN_UNDEFINED = 0, + D3D11_SB_TESSELLATOR_DOMAIN_ISOLINE = 1, + D3D11_SB_TESSELLATOR_DOMAIN_TRI = 2, + D3D11_SB_TESSELLATOR_DOMAIN_QUAD = 3, +}} +pub const D3D11_SB_TESS_DOMAIN_MASK: DWORD = 0x00001800; +pub const D3D11_SB_TESS_DOMAIN_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D11_SB_TESS_DOMAIN(OpcodeToken0: DWORD) -> D3D11_SB_TESSELLATOR_DOMAIN { + ((OpcodeToken0 & D3D11_SB_TESS_DOMAIN_MASK) >> D3D11_SB_TESS_DOMAIN_SHIFT) as D3D11_SB_TESSELLATOR_DOMAIN +} +#[inline] +pub fn ENCODE_D3D11_SB_TESS_DOMAIN(Domain: D3D11_SB_TESSELLATOR_DOMAIN) -> DWORD { + (Domain << D3D11_SB_TESS_DOMAIN_SHIFT) & D3D11_SB_TESS_DOMAIN_MASK +} +ENUM!{enum D3D11_SB_TESSELLATOR_PARTITIONING { + D3D11_SB_TESSELLATOR_PARTITIONING_UNDEFINED = 0, + D3D11_SB_TESSELLATOR_PARTITIONING_INTEGER = 1, + D3D11_SB_TESSELLATOR_PARTITIONING_POW2 = 2, + D3D11_SB_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD = 3, + D3D11_SB_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN = 4, +}} +pub const D3D11_SB_TESS_PARTITIONING_MASK: DWORD = 0x00003800; +pub const D3D11_SB_TESS_PARTITIONING_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D11_SB_TESS_PARTITIONING(OpcodeToken0: DWORD) -> D3D11_SB_TESSELLATOR_PARTITIONING { + ((OpcodeToken0 & D3D11_SB_TESS_PARTITIONING_MASK) >> D3D11_SB_TESS_PARTITIONING_SHIFT) as D3D11_SB_TESSELLATOR_PARTITIONING +} +#[inline] +pub fn ENCODE_D3D11_SB_TESS_PARTITIONING(Partitioning: D3D11_SB_TESSELLATOR_PARTITIONING) -> DWORD { + (Partitioning << D3D11_SB_TESS_PARTITIONING_SHIFT) & D3D11_SB_TESS_PARTITIONING_MASK +} +ENUM!{enum D3D11_SB_TESSELLATOR_OUTPUT_PRIMITIVE { + D3D11_SB_TESSELLATOR_OUTPUT_UNDEFINED = 0, + D3D11_SB_TESSELLATOR_OUTPUT_POINT = 1, + D3D11_SB_TESSELLATOR_OUTPUT_LINE = 2, + D3D11_SB_TESSELLATOR_OUTPUT_TRIANGLE_CW = 3, + D3D11_SB_TESSELLATOR_OUTPUT_TRIANGLE_CCW = 4, +}} +pub const D3D11_SB_TESS_OUTPUT_PRIMITIVE_MASK: DWORD = 0x00003800; +pub const D3D11_SB_TESS_OUTPUT_PRIMITIVE_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D11_SB_TESS_OUTPUT_PRIMITIVE(OpcodeToken0: DWORD) -> D3D11_SB_TESSELLATOR_OUTPUT_PRIMITIVE { + ((OpcodeToken0 & D3D11_SB_TESS_OUTPUT_PRIMITIVE_MASK) >> D3D11_SB_TESS_OUTPUT_PRIMITIVE_SHIFT) as D3D11_SB_TESSELLATOR_OUTPUT_PRIMITIVE +} +#[inline] +pub fn ENCODE_D3D11_SB_TESS_OUTPUT_PRIMITIVE(OutputPrimitive: D3D11_SB_TESSELLATOR_OUTPUT_PRIMITIVE) -> DWORD { + (OutputPrimitive << D3D11_SB_TESS_OUTPUT_PRIMITIVE_SHIFT) & D3D11_SB_TESS_OUTPUT_PRIMITIVE_MASK +} +ENUM!{enum D3D10_SB_INTERPOLATION_MODE { + D3D10_SB_INTERPOLATION_UNDEFINED = 0, + D3D10_SB_INTERPOLATION_CONSTANT = 1, + D3D10_SB_INTERPOLATION_LINEAR = 2, + D3D10_SB_INTERPOLATION_LINEAR_CENTROID = 3, + D3D10_SB_INTERPOLATION_LINEAR_NOPERSPECTIVE = 4, + D3D10_SB_INTERPOLATION_LINEAR_NOPERSPECTIVE_CENTROID = 5, + D3D10_SB_INTERPOLATION_LINEAR_SAMPLE = 6, + D3D10_SB_INTERPOLATION_LINEAR_NOPERSPECTIVE_SAMPLE = 7, +}} +ENUM!{enum D3D10_SB_PRIMITIVE_TOPOLOGY { + D3D10_SB_PRIMITIVE_TOPOLOGY_UNDEFINED = 0, + D3D10_SB_PRIMITIVE_TOPOLOGY_POINTLIST = 1, + D3D10_SB_PRIMITIVE_TOPOLOGY_LINELIST = 2, + D3D10_SB_PRIMITIVE_TOPOLOGY_LINESTRIP = 3, + D3D10_SB_PRIMITIVE_TOPOLOGY_TRIANGLELIST = 4, + D3D10_SB_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP = 5, + D3D10_SB_PRIMITIVE_TOPOLOGY_LINELIST_ADJ = 10, + D3D10_SB_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ = 11, + D3D10_SB_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ = 12, + D3D10_SB_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ = 13, +}} +ENUM!{enum D3D10_SB_PRIMITIVE { + D3D10_SB_PRIMITIVE_UNDEFINED = 0, + D3D10_SB_PRIMITIVE_POINT = 1, + D3D10_SB_PRIMITIVE_LINE = 2, + D3D10_SB_PRIMITIVE_TRIANGLE = 3, + D3D10_SB_PRIMITIVE_LINE_ADJ = 6, + D3D10_SB_PRIMITIVE_TRIANGLE_ADJ = 7, + D3D11_SB_PRIMITIVE_1_CONTROL_POINT_PATCH = 8, + D3D11_SB_PRIMITIVE_2_CONTROL_POINT_PATCH = 9, + D3D11_SB_PRIMITIVE_3_CONTROL_POINT_PATCH = 10, + D3D11_SB_PRIMITIVE_4_CONTROL_POINT_PATCH = 11, + D3D11_SB_PRIMITIVE_5_CONTROL_POINT_PATCH = 12, + D3D11_SB_PRIMITIVE_6_CONTROL_POINT_PATCH = 13, + D3D11_SB_PRIMITIVE_7_CONTROL_POINT_PATCH = 14, + D3D11_SB_PRIMITIVE_8_CONTROL_POINT_PATCH = 15, + D3D11_SB_PRIMITIVE_9_CONTROL_POINT_PATCH = 16, + D3D11_SB_PRIMITIVE_10_CONTROL_POINT_PATCH = 17, + D3D11_SB_PRIMITIVE_11_CONTROL_POINT_PATCH = 18, + D3D11_SB_PRIMITIVE_12_CONTROL_POINT_PATCH = 19, + D3D11_SB_PRIMITIVE_13_CONTROL_POINT_PATCH = 20, + D3D11_SB_PRIMITIVE_14_CONTROL_POINT_PATCH = 21, + D3D11_SB_PRIMITIVE_15_CONTROL_POINT_PATCH = 22, + D3D11_SB_PRIMITIVE_16_CONTROL_POINT_PATCH = 23, + D3D11_SB_PRIMITIVE_17_CONTROL_POINT_PATCH = 24, + D3D11_SB_PRIMITIVE_18_CONTROL_POINT_PATCH = 25, + D3D11_SB_PRIMITIVE_19_CONTROL_POINT_PATCH = 26, + D3D11_SB_PRIMITIVE_20_CONTROL_POINT_PATCH = 27, + D3D11_SB_PRIMITIVE_21_CONTROL_POINT_PATCH = 28, + D3D11_SB_PRIMITIVE_22_CONTROL_POINT_PATCH = 29, + D3D11_SB_PRIMITIVE_23_CONTROL_POINT_PATCH = 30, + D3D11_SB_PRIMITIVE_24_CONTROL_POINT_PATCH = 31, + D3D11_SB_PRIMITIVE_25_CONTROL_POINT_PATCH = 32, + D3D11_SB_PRIMITIVE_26_CONTROL_POINT_PATCH = 33, + D3D11_SB_PRIMITIVE_27_CONTROL_POINT_PATCH = 34, + D3D11_SB_PRIMITIVE_28_CONTROL_POINT_PATCH = 35, + D3D11_SB_PRIMITIVE_29_CONTROL_POINT_PATCH = 36, + D3D11_SB_PRIMITIVE_30_CONTROL_POINT_PATCH = 37, + D3D11_SB_PRIMITIVE_31_CONTROL_POINT_PATCH = 38, + D3D11_SB_PRIMITIVE_32_CONTROL_POINT_PATCH = 39, +}} +ENUM!{enum D3D10_SB_COMPONENT_MASK { + D3D10_SB_COMPONENT_MASK_X = 1, + D3D10_SB_COMPONENT_MASK_Y = 2, + D3D10_SB_COMPONENT_MASK_Z = 4, + D3D10_SB_COMPONENT_MASK_W = 8, + D3D10_SB_COMPONENT_MASK_R = 1, + D3D10_SB_COMPONENT_MASK_G = 2, + D3D10_SB_COMPONENT_MASK_B = 4, + D3D10_SB_COMPONENT_MASK_A = 8, + D3D10_SB_COMPONENT_MASK_ALL = 15, +}} +ENUM!{enum D3D10_SB_NAME { + D3D10_SB_NAME_UNDEFINED = 0, + D3D10_SB_NAME_POSITION = 1, + D3D10_SB_NAME_CLIP_DISTANCE = 2, + D3D10_SB_NAME_CULL_DISTANCE = 3, + D3D10_SB_NAME_RENDER_TARGET_ARRAY_INDEX = 4, + D3D10_SB_NAME_VIEWPORT_ARRAY_INDEX = 5, + D3D10_SB_NAME_VERTEX_ID = 6, + D3D10_SB_NAME_PRIMITIVE_ID = 7, + D3D10_SB_NAME_INSTANCE_ID = 8, + D3D10_SB_NAME_IS_FRONT_FACE = 9, + D3D10_SB_NAME_SAMPLE_INDEX = 10, + D3D11_SB_NAME_FINAL_QUAD_U_EQ_0_EDGE_TESSFACTOR = 11, + D3D11_SB_NAME_FINAL_QUAD_V_EQ_0_EDGE_TESSFACTOR = 12, + D3D11_SB_NAME_FINAL_QUAD_U_EQ_1_EDGE_TESSFACTOR = 13, + D3D11_SB_NAME_FINAL_QUAD_V_EQ_1_EDGE_TESSFACTOR = 14, + D3D11_SB_NAME_FINAL_QUAD_U_INSIDE_TESSFACTOR = 15, + D3D11_SB_NAME_FINAL_QUAD_V_INSIDE_TESSFACTOR = 16, + D3D11_SB_NAME_FINAL_TRI_U_EQ_0_EDGE_TESSFACTOR = 17, + D3D11_SB_NAME_FINAL_TRI_V_EQ_0_EDGE_TESSFACTOR = 18, + D3D11_SB_NAME_FINAL_TRI_W_EQ_0_EDGE_TESSFACTOR = 19, + D3D11_SB_NAME_FINAL_TRI_INSIDE_TESSFACTOR = 20, + D3D11_SB_NAME_FINAL_LINE_DETAIL_TESSFACTOR = 21, + D3D11_SB_NAME_FINAL_LINE_DENSITY_TESSFACTOR = 22, +}} +ENUM!{enum D3D10_SB_RESOURCE_DIMENSION { + D3D10_SB_RESOURCE_DIMENSION_UNKNOWN = 0, + D3D10_SB_RESOURCE_DIMENSION_BUFFER = 1, + D3D10_SB_RESOURCE_DIMENSION_TEXTURE1D = 2, + D3D10_SB_RESOURCE_DIMENSION_TEXTURE2D = 3, + D3D10_SB_RESOURCE_DIMENSION_TEXTURE2DMS = 4, + D3D10_SB_RESOURCE_DIMENSION_TEXTURE3D = 5, + D3D10_SB_RESOURCE_DIMENSION_TEXTURECUBE = 6, + D3D10_SB_RESOURCE_DIMENSION_TEXTURE1DARRAY = 7, + D3D10_SB_RESOURCE_DIMENSION_TEXTURE2DARRAY = 8, + D3D10_SB_RESOURCE_DIMENSION_TEXTURE2DMSARRAY = 9, + D3D10_SB_RESOURCE_DIMENSION_TEXTURECUBEARRAY = 10, + D3D11_SB_RESOURCE_DIMENSION_RAW_BUFFER = 11, + D3D11_SB_RESOURCE_DIMENSION_STRUCTURED_BUFFER = 12, +}} +ENUM!{enum D3D10_SB_RESOURCE_RETURN_TYPE { + D3D10_SB_RETURN_TYPE_UNORM = 1, + D3D10_SB_RETURN_TYPE_SNORM = 2, + D3D10_SB_RETURN_TYPE_SINT = 3, + D3D10_SB_RETURN_TYPE_UINT = 4, + D3D10_SB_RETURN_TYPE_FLOAT = 5, + D3D10_SB_RETURN_TYPE_MIXED = 6, + D3D11_SB_RETURN_TYPE_DOUBLE = 7, + D3D11_SB_RETURN_TYPE_CONTINUED = 8, + D3D11_SB_RETURN_TYPE_UNUSED = 9, +}} +ENUM!{enum D3D10_SB_REGISTER_COMPONENT_TYPE { + D3D10_SB_REGISTER_COMPONENT_UNKNOWN = 0, + D3D10_SB_REGISTER_COMPONENT_UINT32 = 1, + D3D10_SB_REGISTER_COMPONENT_SINT32 = 2, + D3D10_SB_REGISTER_COMPONENT_FLOAT32 = 3, +}} +ENUM!{enum D3D10_SB_INSTRUCTION_RETURN_TYPE { + D3D10_SB_INSTRUCTION_RETURN_FLOAT = 0, + D3D10_SB_INSTRUCTION_RETURN_UINT = 1, +}} +pub const D3D10_SB_INSTRUCTION_RETURN_TYPE_MASK: DWORD = 0x00001800; +pub const D3D10_SB_INSTRUCTION_RETURN_TYPE_SHIFT: DWORD = 11; +#[inline] +pub fn DECODE_D3D10_SB_INSTRUCTION_RETURN_TYPE(OpcodeToken0: DWORD) -> D3D10_SB_INSTRUCTION_RETURN_TYPE { + ((OpcodeToken0 & D3D10_SB_INSTRUCTION_RETURN_TYPE_MASK) >> D3D10_SB_INSTRUCTION_RETURN_TYPE_SHIFT) as D3D10_SB_INSTRUCTION_RETURN_TYPE +} +#[inline] +pub fn ENCODE_D3D10_SB_INSTRUCTION_RETURN_TYPE(ReturnType: D3D10_SB_INSTRUCTION_RETURN_TYPE) -> DWORD { + (ReturnType << D3D10_SB_INSTRUCTION_RETURN_TYPE_SHIFT) & D3D10_SB_INSTRUCTION_RETURN_TYPE_MASK +} +pub const D3D11_SB_INTERFACE_INDEXED_BIT_MASK: DWORD = 0x00000800; +pub const D3D11_SB_INTERFACE_INDEXED_BIT_SHIFT: DWORD = 11; +pub const D3D11_SB_INTERFACE_TABLE_LENGTH_MASK: DWORD = 0x0000ffff; +pub const D3D11_SB_INTERFACE_TABLE_LENGTH_SHIFT: DWORD = 0; +pub const D3D11_SB_INTERFACE_ARRAY_LENGTH_MASK: DWORD = 0xffff0000; +pub const D3D11_SB_INTERFACE_ARRAY_LENGTH_SHIFT: DWORD = 16; +#[inline] +pub fn DECODE_D3D11_SB_INTERFACE_INDEXED_BIT(OpcodeToken0: DWORD) -> DWORD { + if (OpcodeToken0 & D3D11_SB_INTERFACE_INDEXED_BIT_MASK) >> D3D11_SB_INTERFACE_INDEXED_BIT_SHIFT != 0 { + 1 + } else { + 0 + } +} +#[inline] +pub fn ENCODE_D3D11_SB_INTERFACE_INDEXED_BIT(IndexedBit: DWORD) -> DWORD { + (IndexedBit << D3D11_SB_INTERFACE_INDEXED_BIT_SHIFT) & D3D11_SB_INTERFACE_INDEXED_BIT_MASK +} +#[inline] +pub fn DECODE_D3D11_SB_INTERFACE_TABLE_LENGTH(OpcodeToken0: DWORD) -> UINT { + ((OpcodeToken0 & D3D11_SB_INTERFACE_TABLE_LENGTH_MASK) >> D3D11_SB_INTERFACE_TABLE_LENGTH_SHIFT) as UINT +} +#[inline] +pub fn ENCODE_D3D11_SB_INTERFACE_TABLE_LENGTH(TableLength: DWORD) -> DWORD { + (TableLength << D3D11_SB_INTERFACE_TABLE_LENGTH_SHIFT) & D3D11_SB_INTERFACE_TABLE_LENGTH_MASK +} +#[inline] +pub fn DECODE_D3D11_SB_INTERFACE_ARRAY_LENGTH(OpcodeToken0: DWORD) -> UINT { + ((OpcodeToken0 & D3D11_SB_INTERFACE_ARRAY_LENGTH_MASK) >> D3D11_SB_INTERFACE_ARRAY_LENGTH_SHIFT) as UINT +} +#[inline] +pub fn ENCODE_D3D11_SB_INTERFACE_ARRAY_LENGTH(ArrayLength: DWORD) -> DWORD { + (ArrayLength << D3D11_SB_INTERFACE_ARRAY_LENGTH_SHIFT) & D3D11_SB_INTERFACE_ARRAY_LENGTH_MASK +} +pub const D3D11_SB_GLOBALLY_COHERENT_ACCESS: DWORD = 0x00010000; +pub const D3D11_SB_ACCESS_COHERENCY_MASK: DWORD = 0x00010000; +#[inline] +pub fn DECODE_D3D11_SB_ACCESS_COHERENCY_FLAGS(OperandToken0: DWORD) -> DWORD { + OperandToken0 & D3D11_SB_ACCESS_COHERENCY_MASK +} +#[inline] +pub fn ENCODE_D3D11_SB_ACCESS_COHERENCY_FLAGS(Flags: DWORD) -> DWORD { + Flags & D3D11_SB_ACCESS_COHERENCY_MASK +} +pub const D3D11_SB_UAV_HAS_ORDER_PRESERVING_COUNTER: DWORD = 0x00800000; +pub const D3D11_SB_UAV_FLAGS_MASK: DWORD = 0x00800000; +#[inline] +pub fn DECODE_D3D11_SB_UAV_FLAGS(OperandToken0: DWORD) -> DWORD { + OperandToken0 & D3D11_SB_UAV_FLAGS_MASK +} +#[inline] +pub fn ENCODE_D3D11_SB_UAV_FLAGS(Flags: DWORD) -> DWORD { + Flags & D3D11_SB_UAV_FLAGS_MASK +} + diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d12.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d12.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d12.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d12.rs 2018-12-05 01:24:41.000000000 +0000 @@ -1931,11 +1931,11 @@ }} RIDL!{#[uuid(0x63ee58fb, 0x1268, 0x4835, 0x86, 0xda, 0xf0, 0x08, 0xce, 0x62, 0xf0, 0xd6)] interface ID3D12Pageable(ID3D12PageableVtbl): ID3D12DeviceChild(ID3D12DeviceChildVtbl) {}} -RIDL!(#[uuid(0x6b3b2502, 0x6e51, 0x45b3, 0x90, 0xee, 0x98, 0x84, 0x26, 0x5e, 0x8d, 0xf3)] +RIDL!{#[uuid(0x6b3b2502, 0x6e51, 0x45b3, 0x90, 0xee, 0x98, 0x84, 0x26, 0x5e, 0x8d, 0xf3)] interface ID3D12Heap(ID3D12HeapVtbl): ID3D12Pageable(ID3D12PageableVtbl) { #[fixme] fn GetDesc() -> D3D12_HEAP_DESC, -}); -RIDL!(#[uuid(0x696442be, 0xa72e, 0x4059, 0xbc, 0x79, 0x5b, 0x5c, 0x98, 0x04, 0x0f, 0xad)] +}} +RIDL!{#[uuid(0x696442be, 0xa72e, 0x4059, 0xbc, 0x79, 0x5b, 0x5c, 0x98, 0x04, 0x0f, 0xad)] interface ID3D12Resource(ID3D12ResourceVtbl): ID3D12Pageable(ID3D12PageableVtbl) { fn Map( Subresource: UINT, @@ -1966,12 +1966,12 @@ pHeapProperties: *mut D3D12_HEAP_PROPERTIES, pHeapFlags: *mut D3D12_HEAP_FLAGS, ) -> HRESULT, -}); -RIDL!(#[uuid(0x6102dee4, 0xaf59, 0x4b09, 0xb9, 0x99, 0xb4, 0x4d, 0x73, 0xf0, 0x9b, 0x24)] +}} +RIDL!{#[uuid(0x6102dee4, 0xaf59, 0x4b09, 0xb9, 0x99, 0xb4, 0x4d, 0x73, 0xf0, 0x9b, 0x24)] interface ID3D12CommandAllocator(ID3D12CommandAllocatorVtbl): ID3D12Pageable(ID3D12PageableVtbl) { fn Reset() -> HRESULT, -}); -RIDL!(#[uuid(0x0a753dcf, 0xc4d8, 0x4b91, 0xad, 0xf6, 0xbe, 0x5a, 0x60, 0xd9, 0x5a, 0x76)] +}} +RIDL!{#[uuid(0x0a753dcf, 0xc4d8, 0x4b91, 0xad, 0xf6, 0xbe, 0x5a, 0x60, 0xd9, 0x5a, 0x76)] interface ID3D12Fence(ID3D12FenceVtbl): ID3D12Pageable(ID3D12PageableVtbl) { fn GetCompletedValue() -> UINT64, fn SetEventOnCompletion( @@ -1981,28 +1981,28 @@ fn Signal( Value: UINT64, ) -> HRESULT, -}); -RIDL!(#[uuid(0x765a30f3, 0xf624, 0x4c6f, 0xa8, 0x28, 0xac, 0xe9, 0x48, 0x62, 0x24, 0x45)] +}} +RIDL!{#[uuid(0x765a30f3, 0xf624, 0x4c6f, 0xa8, 0x28, 0xac, 0xe9, 0x48, 0x62, 0x24, 0x45)] interface ID3D12PipelineState(ID3D12PipelineStateVtbl): ID3D12Pageable(ID3D12PageableVtbl) { fn GetCachedBlob( ppBlob: *mut *mut ID3DBlob, ) -> HRESULT, -}); -RIDL!(#[uuid(0x8efb471d, 0x616c, 0x4f49, 0x90, 0xf7, 0x12, 0x7b, 0xb7, 0x63, 0xfa, 0x51)] +}} +RIDL!{#[uuid(0x8efb471d, 0x616c, 0x4f49, 0x90, 0xf7, 0x12, 0x7b, 0xb7, 0x63, 0xfa, 0x51)] interface ID3D12DescriptorHeap(ID3D12DescriptorHeapVtbl): ID3D12Pageable(ID3D12PageableVtbl) { #[fixme] fn GetDesc() -> D3D12_DESCRIPTOR_HEAP_DESC, #[fixme] fn GetCPUDescriptorHandleForHeapStart() -> D3D12_CPU_DESCRIPTOR_HANDLE, #[fixme] fn GetGPUDescriptorHandleForHeapStart() -> D3D12_GPU_DESCRIPTOR_HANDLE, -}); +}} RIDL!{#[uuid(0x0d9658ae, 0xed45, 0x469e, 0xa6, 0x1d, 0x97, 0x0e, 0xc5, 0x83, 0xca, 0xb4)] interface ID3D12QueryHeap(ID3D12QueryHeapVtbl): ID3D12Pageable(ID3D12PageableVtbl) {}} RIDL!{#[uuid(0xc36a797c, 0xec80, 0x4f0a, 0x89, 0x85, 0xa7, 0xb2, 0x47, 0x50, 0x82, 0xd1)] interface ID3D12CommandSignature(ID3D12CommandSignatureVtbl): ID3D12Pageable(ID3D12PageableVtbl) {}} -RIDL!(#[uuid(0x7116d91c, 0xe7e4, 0x47ce, 0xb8, 0xc6, 0xec, 0x81, 0x68, 0xf4, 0x37, 0xe5)] +RIDL!{#[uuid(0x7116d91c, 0xe7e4, 0x47ce, 0xb8, 0xc6, 0xec, 0x81, 0x68, 0xf4, 0x37, 0xe5)] interface ID3D12CommandList(ID3D12CommandListVtbl): ID3D12DeviceChild(ID3D12DeviceChildVtbl) { fn GetType() -> D3D12_COMMAND_LIST_TYPE, -}); +}} RIDL!{#[uuid(0x5b160d0f, 0xac1b, 0x4185, 0x8b, 0xa8, 0xb3, 0xae, 0x42, 0xa5, 0xa4, 0x55)] interface ID3D12GraphicsCommandList(ID3D12GraphicsCommandListVtbl): ID3D12CommandList(ID3D12CommandListVtbl) { @@ -2295,7 +2295,7 @@ ResolveMode: D3D12_RESOLVE_MODE, ) -> (), }} -RIDL!(#[uuid(0x0ec870a6, 0x5d7e, 0x4c22, 0x8c, 0xfc, 0x5b, 0xaa, 0xe0, 0x76, 0x16, 0xed)] +RIDL!{#[uuid(0x0ec870a6, 0x5d7e, 0x4c22, 0x8c, 0xfc, 0x5b, 0xaa, 0xe0, 0x76, 0x16, 0xed)] interface ID3D12CommandQueue(ID3D12CommandQueueVtbl): ID3D12Pageable(ID3D12PageableVtbl) { fn UpdateTileMappings( pResource: *mut ID3D12Resource, @@ -2348,8 +2348,8 @@ pCpuTimestamp: *mut UINT64, ) -> HRESULT, #[fixme] fn GetDesc() -> D3D12_COMMAND_QUEUE_DESC, -}); -RIDL!(#[uuid(0x189819f1, 0x1db6, 0x4b57, 0xbe, 0x54, 0x18, 0x21, 0x33, 0x9b, 0x85, 0xf7)] +}} +RIDL!{#[uuid(0x189819f1, 0x1db6, 0x4b57, 0xbe, 0x54, 0x18, 0x21, 0x33, 0x9b, 0x85, 0xf7)] interface ID3D12Device(ID3D12DeviceVtbl): ID3D12Object(ID3D12ObjectVtbl) { fn GetNodeCount() -> UINT, fn CreateCommandQueue( @@ -2549,8 +2549,8 @@ pSubresourceTilingsForNonPackedMips: *mut D3D12_SUBRESOURCE_TILING, ) -> (), #[fixme] fn GetAdapterLuid() -> LUID, -}); -RIDL!(#[uuid(0xc64226a8, 0x9201, 0x46af, 0xb4, 0xcc, 0x53, 0xfb, 0x9f, 0xf7, 0x41, 0x4f)] +}} +RIDL!{#[uuid(0xc64226a8, 0x9201, 0x46af, 0xb4, 0xcc, 0x53, 0xfb, 0x9f, 0xf7, 0x41, 0x4f)] interface ID3D12PipelineLibrary(ID3D12PipelineLibraryVtbl): ID3D12DeviceChild(ID3D12DeviceChildVtbl) { fn StorePipeline( pName: LPCWSTR, @@ -2573,8 +2573,8 @@ pData: *mut c_void, DataSizeInBytes: SIZE_T, ) -> HRESULT, -}); -RIDL!(#[uuid(0x80eabf42, 0x2568, 0x4e5e, 0xbd, 0x82, 0xc3, 0x7f, 0x86, 0x96, 0x1d, 0xc3)] +}} +RIDL!{#[uuid(0x80eabf42, 0x2568, 0x4e5e, 0xbd, 0x82, 0xc3, 0x7f, 0x86, 0x96, 0x1d, 0xc3)] interface ID3D12PipelineLibrary1(ID3D12PipelineLibrary1Vtbl): ID3D12PipelineLibrary(ID3D12PipelineLibraryVtbl) { fn LoadPipeline( pName: LPCWSTR, @@ -2582,7 +2582,7 @@ riid: REFIID, ppPipelineState: *mut *mut c_void, ) -> HRESULT, -}); +}} ENUM!{enum D3D12_MULTIPLE_FENCE_WAIT_FLAGS { D3D12_MULTIPLE_FENCE_WAIT_FLAG_NONE = 0, D3D12_MULTIPLE_FENCE_WAIT_FLAG_ANY = 0x1, @@ -2595,7 +2595,7 @@ D3D12_RESIDENCY_PRIORITY_HIGH = 0xa0010000, D3D12_RESIDENCY_PRIORITY_MAXIMUM = 0xc8000000, }} -RIDL!(#[uuid(0x77acce80, 0x638e, 0x4e65, 0x88, 0x95, 0xc1, 0xf2, 0x33, 0x86, 0x86, 0x3e)] +RIDL!{#[uuid(0x77acce80, 0x638e, 0x4e65, 0x88, 0x95, 0xc1, 0xf2, 0x33, 0x86, 0x86, 0x3e)] interface ID3D12Device1(ID3D12Device1Vtbl): ID3D12Device(ID3D12DeviceVtbl) { fn CreatePipelineLibrary( pLibraryBlob: *const c_void, @@ -2615,22 +2615,22 @@ ppObjects: *const *mut ID3D12Pageable, pPriorities: *const D3D12_RESIDENCY_PRIORITY, ) -> HRESULT, -}); -RIDL!(#[uuid(0x30baa41e, 0xb15b, 0x475c, 0xa0, 0xbb, 0x1a, 0xf5, 0xc5, 0xb6, 0x43, 0x28)] +}} +RIDL!{#[uuid(0x30baa41e, 0xb15b, 0x475c, 0xa0, 0xbb, 0x1a, 0xf5, 0xc5, 0xb6, 0x43, 0x28)] interface ID3D12Device2(ID3D12Device2Vtbl): ID3D12Device1(ID3D12Device1Vtbl) { fn CreatePipelineState( pDesc: *const D3D12_PIPELINE_STATE_STREAM_DESC, riid: REFIID, ppPipelineState: *mut *mut c_void, ) -> HRESULT, -}); -RIDL!(#[uuid(0x7071e1f0, 0xe84b, 0x4b33, 0x97, 0x4f, 0x12, 0xfa, 0x49, 0xde, 0x65, 0xc5)] +}} +RIDL!{#[uuid(0x7071e1f0, 0xe84b, 0x4b33, 0x97, 0x4f, 0x12, 0xfa, 0x49, 0xde, 0x65, 0xc5)] interface ID3D12Tools(ID3D12ToolsVtbl): IUnknown(IUnknownVtbl) { fn EnableShaderInstrumentation( bEnable: BOOL, ) -> (), fn ShaderInstrumentationEnabled() -> BOOL, -}); +}} STRUCT!{struct D3D12_SUBRESOURCE_DATA { pData: *const c_void, RowPitch: LONG_PTR, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d12shader.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d12shader.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d12shader.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/d3d12shader.rs 2018-12-05 01:24:42.000000000 +0000 @@ -201,7 +201,7 @@ ParameterIndex: INT, ) -> *mut ID3D12FunctionParameterReflection, }} -RIDL!(#[uuid(0x8e349d19, 0x54db, 0x4a56, 0x9d, 0xc9, 0x11, 0x9d, 0x87, 0xbd, 0xb8, 0x4)] +RIDL!{#[uuid(0x8e349d19, 0x54db, 0x4a56, 0x9d, 0xc9, 0x11, 0x9d, 0x87, 0xbd, 0xb8, 0x4)] interface ID3D12LibraryReflection(ID3D12LibraryReflectionVtbl): IUnknown(IUnknownVtbl) { fn GetDesc( pDesc: *mut D3D12_LIBRARY_DESC, @@ -209,7 +209,7 @@ fn GetFunctionByIndex( FunctionIndex: INT, ) -> *mut ID3D12FunctionReflection, -}); +}} DEFINE_GUID!{IID_ID3D12ShaderReflectionConstantBuffer, 0xc59598b4, 0x48b3, 0x4869, 0xb9, 0xb1, 0xb1, 0x61, 0x8b, 0x14, 0xa8, 0xb7} RIDL!{#[uuid(0xc59598b4, 0x48b3, 0x4869, 0xb9, 0xb1, 0xb1, 0x61, 0x8b, 0x14, 0xa8, 0xb7)] @@ -271,7 +271,7 @@ }} DEFINE_GUID!{IID_ID3D12ShaderReflection, 0x5a58797d, 0xa72c, 0x478d, 0x8b, 0xa2, 0xef, 0xc6, 0xb0, 0xef, 0xe8, 0x8e} -RIDL!(#[uuid(0x5a58797d, 0xa72c, 0x478d, 0x8b, 0xa2, 0xef, 0xc6, 0xb0, 0xef, 0xe8, 0x8e)] +RIDL!{#[uuid(0x5a58797d, 0xa72c, 0x478d, 0x8b, 0xa2, 0xef, 0xc6, 0xb0, 0xef, 0xe8, 0x8e)] interface ID3D12ShaderReflection(ID3D12ShaderReflectionVtbl): IUnknown(IUnknownVtbl) { fn GetDesc( pDesc: *mut D3D12_SHADER_DESC, @@ -321,7 +321,7 @@ pSizeZ: *mut UINT, ) -> UINT, fn GetRequiresFlags() -> UINT64, -}); +}} DEFINE_GUID!{IID_ID3D12LibraryReflection, 0x8e349d19, 0x54db, 0x4a56, 0x9d, 0xc9, 0x11, 0x9d, 0x87, 0xbd, 0xb8, 0x04} DEFINE_GUID!{IID_ID3D12FunctionReflection, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/d3dcommon.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/d3dcommon.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/d3dcommon.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/d3dcommon.rs 2018-12-05 01:24:42.000000000 +0000 @@ -353,12 +353,11 @@ pub type LPD3D_SHADER_MACRO = *mut D3D_SHADER_MACRO; DEFINE_GUID!{IID_ID3D10Blob, 0x8ba5fb08, 0x5195, 0x40e2, 0xac, 0x58, 0x0d, 0x98, 0x9c, 0x3a, 0x01, 0x02} -RIDL!(#[uuid(0x8ba5fb08, 0x5195, 0x40e2, 0xac, 0x58, 0xd, 0x98, 0x9c, 0x3a, 0x1, 0x2)] +RIDL!{#[uuid(0x8ba5fb08, 0x5195, 0x40e2, 0xac, 0x58, 0xd, 0x98, 0x9c, 0x3a, 0x1, 0x2)] interface ID3D10Blob(ID3D10BlobVtbl): IUnknown(IUnknownVtbl) { fn GetBufferPointer() -> LPVOID, fn GetBufferSize() -> SIZE_T, -} -); +}} pub type LPD3D10BLOB = *mut ID3D10Blob; pub type ID3DBlob = ID3D10Blob; pub type LPD3DBLOB = *mut ID3DBlob; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/dbghelp.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/dbghelp.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/dbghelp.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/dbghelp.rs 2018-12-05 01:24:42.000000000 +0000 @@ -88,6 +88,11 @@ FileName: PCWSTR, CallerData: PVOID, ) -> BOOL} +FN!{stdcall PSYM_ENUMERATESYMBOLS_CALLBACKW( + pSymInfo: PSYMBOL_INFOW, + SymbolSize: ULONG, + CallerData: PVOID, +) -> BOOL} #[cfg(target_arch = "x86")] STRUCT!{struct IMAGE_DEBUG_INFORMATION { List: LIST_ENTRY, @@ -536,6 +541,13 @@ pub fn SymCleanup( hProcess: HANDLE ) -> BOOL; + pub fn SymEnumSymbolsW( + hProcess: HANDLE, + BaseOfDll: ULONG64, + Mask: PCWSTR, + EnumSymbolsCallback: PSYM_ENUMERATESYMBOLS_CALLBACKW, + CallerData: PVOID + ) -> BOOL; pub fn SymFindDebugInfoFile( hProcess: HANDLE, FileName: PCSTR, @@ -594,6 +606,11 @@ Displacement: PDWORD64, Symbol: PSYMBOL_INFOW, ) -> BOOL; + pub fn SymFromNameW( + hProcess: HANDLE, + Name: PCWSTR, + Symbol: PSYMBOL_INFOW + ) -> BOOL; pub fn SymFunctionTableAccess64( hProcess: HANDLE, AddrBase: DWORD64, @@ -619,6 +636,24 @@ UserSearchPath: PCWSTR, fInvadeProcess: BOOL, ) -> BOOL; + pub fn SymLoadModuleExW( + hProcess: HANDLE, + hFile: HANDLE, + ImageName: PCWSTR, + ModuleName: PCWSTR, + BaseOfDll: DWORD64, + SizeOfDll: DWORD, + Data: PMODLOAD_DATA, + Flags: DWORD + ) -> DWORD64; + pub fn SymUnloadModule( + hProcess: HANDLE, + BaseOfDll: DWORD + ) -> BOOL; + pub fn SymUnloadModule64( + hProcess: HANDLE, + BaseOfDll: DWORD64 + ) -> BOOL; #[cfg(any(target_arch = "x86", target_arch = "arm"))] pub fn MapDebugInformation( FileHandle: HANDLE, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/dbt.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/dbt.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/dbt.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/dbt.rs 2018-12-05 01:24:41.000000000 +0000 @@ -0,0 +1,193 @@ +// Copyright © 2018 winapi-rs developers +// Licensed under the Apache License, Version 2.0 +// or the MIT license +// , at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use ctypes::{c_char, wchar_t}; +use shared::basetsd::{ULONG32, ULONG64}; +use shared::guiddef::GUID; +use shared::minwindef::{BYTE, DWORD, UINT, WORD, WPARAM}; +use um::winnt::{HANDLE, LONG}; +use um::winuser::HDEVNOTIFY; +pub const WM_DEVICECHANGE: UINT = 0x0219; +pub const BSF_QUERY: DWORD = 0x00000001; +pub const BSF_IGNORECURRENTTASK: DWORD = 0x00000002; +pub const BSF_FLUSHDISK: DWORD = 0x00000004; +pub const BSF_NOHANG: DWORD = 0x00000008; +pub const BSF_POSTMESSAGE: DWORD = 0x00000010; +pub const BSF_FORCEIFHUNG: DWORD = 0x00000020; +pub const BSF_NOTIMEOUTIFNOTHUNG: DWORD = 0x00000040; +pub const BSF_MSGSRV32ISOK: DWORD = 0x80000000; +pub const BSF_MSGSRV32ISOK_BIT: usize = 31; +pub const BSM_ALLCOMPONENTS: DWORD = 0x00000000; +pub const BSM_VXDS: DWORD = 0x00000001; +pub const BSM_NETDRIVER: DWORD = 0x00000002; +pub const BSM_INSTALLABLEDRIVERS: DWORD = 0x00000004; +pub const BSM_APPLICATIONS: DWORD = 0x00000008; +pub const DBT_APPYBEGIN: WPARAM = 0x0000; +pub const DBT_APPYEND: WPARAM = 0x0001; +pub const DBT_DEVNODES_CHANGED: WPARAM = 0x0007; +pub const DBT_QUERYCHANGECONFIG: WPARAM = 0x0017; +pub const DBT_CONFIGCHANGED: WPARAM = 0x0018; +pub const DBT_CONFIGCHANGECANCELED: WPARAM = 0x0019; +pub const DBT_MONITORCHANGE: WPARAM = 0x001B; +pub const DBT_SHELLLOGGEDON: WPARAM = 0x0020; +pub const DBT_CONFIGMGAPI32: WPARAM = 0x0022; +pub const DBT_VXDINITCOMPLETE: WPARAM = 0x0023; +pub const DBT_VOLLOCKQUERYLOCK: WPARAM = 0x8041; +pub const DBT_VOLLOCKLOCKTAKEN: WPARAM = 0x8042; +pub const DBT_VOLLOCKLOCKFAILED: WPARAM = 0x8043; +pub const DBT_VOLLOCKQUERYUNLOCK: WPARAM = 0x8044; +pub const DBT_VOLLOCKLOCKRELEASED: WPARAM = 0x8045; +pub const DBT_VOLLOCKUNLOCKFAILED: WPARAM = 0x8046; +STRUCT!{struct DEV_BROADCAST_HDR { + dbch_size: DWORD, + dbch_devicetype: DWORD, + dbch_reserved: DWORD, +}} +pub type PDEV_BROADCAST_HDR = *mut DEV_BROADCAST_HDR; +STRUCT!{struct VolLockBroadcast { + vlb_dbh: DEV_BROADCAST_HDR, + vlb_owner: DWORD, + vlb_perms: BYTE, + vlb_lockType: BYTE, + vlb_drive: BYTE, + vlb_flags: BYTE, +}} +pub type pVolLockBroadcast = *mut VolLockBroadcast; +pub const LOCKP_ALLOW_WRITES: BYTE = 0x01; +pub const LOCKP_FAIL_WRITES: BYTE = 0x00; +pub const LOCKP_FAIL_MEM_MAPPING: BYTE = 0x02; +pub const LOCKP_ALLOW_MEM_MAPPING: BYTE = 0x00; +pub const LOCKP_USER_MASK: BYTE = 0x03; +pub const LOCKP_LOCK_FOR_FORMAT: BYTE = 0x04; +pub const LOCKF_LOGICAL_LOCK: BYTE = 0x00; +pub const LOCKF_PHYSICAL_LOCK: BYTE = 0x01; +pub const DBT_NO_DISK_SPACE: WPARAM = 0x0047; +pub const DBT_LOW_DISK_SPACE: WPARAM = 0x0048; +pub const DBT_CONFIGMGPRIVATE: WPARAM = 0x7FFF; +pub const DBT_DEVICEARRIVAL: WPARAM = 0x8000; +pub const DBT_DEVICEQUERYREMOVE: WPARAM = 0x8001; +pub const DBT_DEVICEQUERYREMOVEFAILED: WPARAM = 0x8002; +pub const DBT_DEVICEREMOVEPENDING: WPARAM = 0x8003; +pub const DBT_DEVICEREMOVECOMPLETE: WPARAM = 0x8004; +pub const DBT_DEVICETYPESPECIFIC: WPARAM = 0x8005; +pub const DBT_CUSTOMEVENT: WPARAM = 0x8006; +pub const DBT_DEVTYP_OEM: DWORD = 0x00000000; +pub const DBT_DEVTYP_DEVNODE: DWORD = 0x00000001; +pub const DBT_DEVTYP_VOLUME: DWORD = 0x00000002; +pub const DBT_DEVTYP_PORT: DWORD = 0x00000003; +pub const DBT_DEVTYP_NET: DWORD = 0x00000004; +pub const DBT_DEVTYP_DEVICEINTERFACE: DWORD = 0x00000005; +pub const DBT_DEVTYP_HANDLE: DWORD = 0x00000006; +STRUCT!{struct _DEV_BROADCAST_HEADER { + dbcd_size: DWORD, + dbcd_devicetype: DWORD, + dbcd_reserved: DWORD, +}} +STRUCT!{struct DEV_BROADCAST_OEM { + dbco_size: DWORD, + dbco_devicetype: DWORD, + dbco_reserved: DWORD, + dbco_identifier: DWORD, + dbco_suppfunc: DWORD, +}} +pub type PDEV_BROADCAST_OEM = *mut DEV_BROADCAST_OEM; +STRUCT!{struct DEV_BROADCAST_DEVNODE { + dbcd_size: DWORD, + dbcd_devicetype: DWORD, + dbcd_reserved: DWORD, + dbcd_devnode: DWORD, +}} +pub type PDEV_BROADCAST_DEVNODE = *mut DEV_BROADCAST_DEVNODE; +STRUCT!{struct DEV_BROADCAST_VOLUME { + dbcv_size: DWORD, + dbcv_devicetype: DWORD, + dbcv_reserved: DWORD, + dbcv_unitmask: DWORD, + dbcv_flags: WORD, +}} +pub type PDEV_BROADCAST_VOLUME = *mut DEV_BROADCAST_VOLUME; +pub const DBTF_MEDIA: WORD = 0x0001; +pub const DBTF_NET: WORD = 0x0002; +STRUCT!{struct DEV_BROADCAST_PORT_A { + dbcp_size: DWORD, + dbcp_devicetype: DWORD, + dbcp_reserved: DWORD, + dbcp_name: [c_char; 1], +}} +pub type PDEV_BROADCAST_PORT_A = *mut DEV_BROADCAST_PORT_A; +STRUCT!{struct DEV_BROADCAST_PORT_W { + dbcp_size: DWORD, + dbcp_devicetype: DWORD, + dbcp_reserved: DWORD, + dbcp_name: [wchar_t; 1], +}} +pub type PDEV_BROADCAST_PORT_W = *mut DEV_BROADCAST_PORT_W; +STRUCT!{struct DEV_BROADCAST_NET { + dbcn_size: DWORD, + dbcn_devicetype: DWORD, + dbcn_reserved: DWORD, + dbcn_resource: DWORD, + dbcn_flags: DWORD, +}} +pub type PDEV_BROADCAST_NET = *mut DEV_BROADCAST_NET; +STRUCT!{struct DEV_BROADCAST_DEVICEINTERFACE_A { + dbcc_size: DWORD, + dbcc_devicetype: DWORD, + dbcc_reserved: DWORD, + dbcc_classguid: GUID, + dbcc_name: [c_char; 1], +}} +pub type PDEV_BROADCAST_DEVICEINTERFACE_A = *mut DEV_BROADCAST_DEVICEINTERFACE_A; +STRUCT!{struct DEV_BROADCAST_DEVICEINTERFACE_W { + dbcc_size: DWORD, + dbcc_devicetype: DWORD, + dbcc_reserved: DWORD, + dbcc_classguid: GUID, + dbcc_name: [wchar_t; 1], +}} +pub type PDEV_BROADCAST_DEVICEINTERFACE_W = *mut DEV_BROADCAST_DEVICEINTERFACE_W; +STRUCT!{struct DEV_BROADCAST_HANDLE { + dbch_size: DWORD, + dbch_devicetype: DWORD, + dbch_reserved: DWORD, + dbch_handle: HANDLE, + dbch_hdevnotify: HDEVNOTIFY, + dbch_eventguid: GUID, + dbch_nameoffset: LONG, + dbch_data: [BYTE; 1], +}} +pub type PDEV_BROADCAST_HANDLE = *mut DEV_BROADCAST_HANDLE; +STRUCT!{struct DEV_BROADCAST_HANDLE32 { + dbch_size: DWORD, + dbch_devicetype: DWORD, + dbch_reserved: DWORD, + dbch_handle: ULONG32, + dbch_hdevnotify: ULONG32, + dbch_eventguid: GUID, + dbch_nameoffset: LONG, + dbch_data: [BYTE; 1], +}} +pub type PDEV_BROADCAST_HANDLE32 = *mut DEV_BROADCAST_HANDLE32; +STRUCT!{struct DEV_BROADCAST_HANDLE64 { + dbch_size: DWORD, + dbch_devicetype: DWORD, + dbch_reserved: DWORD, + dbch_handle: ULONG64, + dbch_hdevnotify: ULONG64, + dbch_eventguid: GUID, + dbch_nameoffset: LONG, + dbch_data: [BYTE; 1], +}} +pub type PDEV_BROADCAST_HANDLE64 = *mut DEV_BROADCAST_HANDLE64; +pub const DBTF_RESOURCE: DWORD = 0x00000001; +pub const DBTF_XPORT: DWORD = 0x00000002; +pub const DBTF_SLOWNET: DWORD = 0x00000004; +pub const DBT_VPOWERDAPI: WPARAM = 0x8100; +pub const DBT_USERDEFINED: WPARAM = 0xFFFF; +STRUCT!{struct _DEV_BROADCAST_USERDEFINED { + dbud_dbh: DEV_BROADCAST_HDR, + dbud_szName: [c_char; 1], +}} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/dcommon.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/dcommon.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/dcommon.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/dcommon.rs 2018-12-05 01:24:42.000000000 +0000 @@ -5,9 +5,10 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. //! Mappings for the contents of dcommon.h -use shared::basetsd::{UINT32}; +use ctypes::c_void; +use shared::basetsd::UINT32; use shared::dxgiformat::DXGI_FORMAT; -use shared::minwindef::{FLOAT}; +use shared::minwindef::FLOAT; use shared::windef::{POINT, RECT}; ENUM!{enum DWRITE_MEASURING_MODE { DWRITE_MEASURING_MODE_NATURAL = 0, @@ -25,6 +26,17 @@ DWRITE_GLYPH_IMAGE_FORMATS_TIFF = 0x00000040, DWRITE_GLYPH_IMAGE_FORMATS_PREMULTIPLIED_B8G8R8A8 = 0x00000080, }} +STRUCT!{struct DWRITE_GLYPH_IMAGE_DATA { + imageData: *const c_void, + imageDataSize: UINT32, + uniqueDataId: UINT32, + pixelsPerEm: UINT32, + pixelSize: D2D1_SIZE_U, + horizontalLeftOrigin: D2D1_POINT_2L, + horizontalRightOrigin: D2D1_POINT_2L, + verticalTopOrigin: D2D1_POINT_2L, + verticalBottomOrigin: D2D1_POINT_2L, +}} ENUM!{enum D2D1_ALPHA_MODE { D2D1_ALPHA_MODE_UNKNOWN = 0, D2D1_ALPHA_MODE_PREMULTIPLIED = 1, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/dcompanimation.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/dcompanimation.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/dcompanimation.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/dcompanimation.rs 2018-12-05 01:24:41.000000000 +0000 @@ -8,7 +8,7 @@ use ctypes::{c_double, c_float}; use shared::ntdef::{HRESULT, LARGE_INTEGER}; use um::unknwnbase::{IUnknown, IUnknownVtbl}; -RIDL!(#[uuid(0xcbfd91d9, 0x51b2, 0x45e4, 0xb3, 0xde, 0xd1, 0x9c, 0xcf, 0xb8, 0x63, 0xc5)] +RIDL!{#[uuid(0xcbfd91d9, 0x51b2, 0x45e4, 0xb3, 0xde, 0xd1, 0x9c, 0xcf, 0xb8, 0x63, 0xc5)] interface IDCompositionAnimation(IDCompositionAnimationVtbl): IUnknown(IUnknownVtbl) { fn Reset() -> HRESULT, fn SetAbsoluteBeginTime( @@ -36,4 +36,4 @@ endOffset: c_double, endValue: c_float, ) -> HRESULT, -}); +}} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/dcomp.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/dcomp.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/dcomp.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/dcomp.rs 2018-12-05 01:24:42.000000000 +0000 @@ -67,7 +67,7 @@ enable: BOOL, ) -> HRESULT; } -RIDL!(#[uuid(0xc37ea93a, 0xe7aa, 0x450d, 0xb1, 0x6f, 0x97, 0x46, 0xcb, 0x04, 0x07, 0xf3)] +RIDL!{#[uuid(0xc37ea93a, 0xe7aa, 0x450d, 0xb1, 0x6f, 0x97, 0x46, 0xcb, 0x04, 0x07, 0xf3)] interface IDCompositionDevice(IDCompositionDeviceVtbl): IUnknown(IUnknownVtbl) { fn Commit() -> HRESULT, fn WaitForCommitCompletion() -> HRESULT, @@ -153,14 +153,14 @@ fn CheckDeviceState( pfValid: *mut BOOL, ) -> HRESULT, -}); -RIDL!(#[uuid(0xeacdd04c, 0x117e, 0x4e17, 0x88, 0xf4, 0xd1, 0xb1, 0x2b, 0x0e, 0x3d, 0x89)] +}} +RIDL!{#[uuid(0xeacdd04c, 0x117e, 0x4e17, 0x88, 0xf4, 0xd1, 0xb1, 0x2b, 0x0e, 0x3d, 0x89)] interface IDCompositionTarget(IDCompositionTargetVtbl): IUnknown(IUnknownVtbl) { fn SetRoot( visual: *const IDCompositionVisual, ) -> HRESULT, -}); -RIDL!(#[uuid(0x4d93059d, 0x097b, 0x4651, 0x9a, 0x60, 0xf0, 0xf2, 0x51, 0x16, 0xe2, 0xf3)] +}} +RIDL!{#[uuid(0x4d93059d, 0x097b, 0x4651, 0x9a, 0x60, 0xf0, 0xf2, 0x51, 0x16, 0xe2, 0xf3)] interface IDCompositionVisual(IDCompositionVisualVtbl): IUnknown(IUnknownVtbl) { fn SetOffsetX_2( animation: *const IDCompositionAnimation, @@ -214,19 +214,19 @@ fn SetCompositeMode( compositeMode: DCOMPOSITION_COMPOSITE_MODE, ) -> HRESULT, -}); -RIDL!(#[uuid(0xec81b08f, 0xbfcb, 0x4e8d, 0xb1, 0x93, 0xa9, 0x15, 0x58, 0x79, 0x99, 0xe8)] +}} +RIDL!{#[uuid(0xec81b08f, 0xbfcb, 0x4e8d, 0xb1, 0x93, 0xa9, 0x15, 0x58, 0x79, 0x99, 0xe8)] interface IDCompositionEffect(IDCompositionEffectVtbl): IUnknown(IUnknownVtbl) { -}); -RIDL!(#[uuid(0x71185722, 0x246b, 0x41f2, 0xaa, 0xd1, 0x04, 0x43, 0xf7, 0xf4, 0xbf, 0xc2)] +}} +RIDL!{#[uuid(0x71185722, 0x246b, 0x41f2, 0xaa, 0xd1, 0x04, 0x43, 0xf7, 0xf4, 0xbf, 0xc2)] interface IDCompositionTransform3D(IDCompositionTransform3DVtbl): IDCompositionEffect(IDCompositionEffectVtbl) { -}); -RIDL!(#[uuid(0xfd55faa7, 0x37e0, 0x4c20, 0x95, 0xd2, 0x9b, 0xe4, 0x5b, 0xc3, 0x3f, 0x55)] +}} +RIDL!{#[uuid(0xfd55faa7, 0x37e0, 0x4c20, 0x95, 0xd2, 0x9b, 0xe4, 0x5b, 0xc3, 0x3f, 0x55)] interface IDCompositionTransform(IDCompositionTransformVtbl): IDCompositionTransform3D(IDCompositionTransform3DVtbl) { -}); -RIDL!(#[uuid(0x06791122, 0xc6f0, 0x417d, 0x83, 0x23, 0x26, 0x9e, 0x98, 0x7f, 0x59, 0x54)] +}} +RIDL!{#[uuid(0x06791122, 0xc6f0, 0x417d, 0x83, 0x23, 0x26, 0x9e, 0x98, 0x7f, 0x59, 0x54)] interface IDCompositionTranslateTransform(IDCompositionTranslateTransformVtbl): IDCompositionTransform(IDCompositionTransformVtbl) { fn SetOffsetX_2( @@ -241,8 +241,8 @@ fn SetOffsetY_1( offsetY: c_float, ) -> HRESULT, -}); -RIDL!(#[uuid(0x71fde914, 0x40ef, 0x45ef, 0xbd, 0x51, 0x68, 0xb0, 0x37, 0xc3, 0x39, 0xf9)] +}} +RIDL!{#[uuid(0x71fde914, 0x40ef, 0x45ef, 0xbd, 0x51, 0x68, 0xb0, 0x37, 0xc3, 0x39, 0xf9)] interface IDCompositionScaleTransform(IDCompositionScaleTransformVtbl): IDCompositionTransform(IDCompositionTransformVtbl) { fn SetScaleX_2( @@ -269,8 +269,8 @@ fn SetCenterY_1( centerY: c_float, ) -> HRESULT, -}); -RIDL!(#[uuid(0x641ed83c, 0xae96, 0x46c5, 0x90, 0xdc, 0x32, 0x77, 0x4c, 0xc5, 0xc6, 0xd5)] +}} +RIDL!{#[uuid(0x641ed83c, 0xae96, 0x46c5, 0x90, 0xdc, 0x32, 0x77, 0x4c, 0xc5, 0xc6, 0xd5)] interface IDCompositionRotateTransform(IDCompositionRotateTransformVtbl): IDCompositionTransform(IDCompositionTransformVtbl) { fn SetAngle_2( @@ -291,8 +291,8 @@ fn SetCenterY_1( centerY: c_float, ) -> HRESULT, -}); -RIDL!(#[uuid(0xe57aa735, 0xdcdb, 0x4c72, 0x9c, 0x61, 0x05, 0x91, 0xf5, 0x88, 0x89, 0xee)] +}} +RIDL!{#[uuid(0xe57aa735, 0xdcdb, 0x4c72, 0x9c, 0x61, 0x05, 0x91, 0xf5, 0x88, 0x89, 0xee)] interface IDCompositionSkewTransform(IDCompositionSkewTransformVtbl): IDCompositionTransform(IDCompositionTransformVtbl) { fn SetAngleX_2( @@ -319,8 +319,8 @@ fn SetCenterY_1( centerY: c_float, ) -> HRESULT, -}); -RIDL!(#[uuid(0x16cdff07, 0xc503, 0x419c, 0x83, 0xf2, 0x09, 0x65, 0xc7, 0xaf, 0x1f, 0xa6)] +}} +RIDL!{#[uuid(0x16cdff07, 0xc503, 0x419c, 0x83, 0xf2, 0x09, 0x65, 0xc7, 0xaf, 0x1f, 0xa6)] interface IDCompositionMatrixTransform(IDCompositionMatrixTransformVtbl): IDCompositionTransform(IDCompositionTransformVtbl) { fn SetMatrix( @@ -336,8 +336,8 @@ column: c_int, value: c_float, ) -> HRESULT, -}); -RIDL!(#[uuid(0xa7929a74, 0xe6b2, 0x4bd6, 0x8b, 0x95, 0x40, 0x40, 0x11, 0x9c, 0xa3, 0x4d)] +}} +RIDL!{#[uuid(0xa7929a74, 0xe6b2, 0x4bd6, 0x8b, 0x95, 0x40, 0x40, 0x11, 0x9c, 0xa3, 0x4d)] interface IDCompositionEffectGroup(IDCompositionEffectGroupVtbl): IDCompositionEffect(IDCompositionEffectVtbl) { fn SetOpacity_2( @@ -349,8 +349,8 @@ fn SetTransform3D( transform3D: *const IDCompositionTransform3D, ) -> HRESULT, -}); -RIDL!(#[uuid(0x91636d4b, 0x9ba1, 0x4532, 0xaa, 0xf7, 0xe3, 0x34, 0x49, 0x94, 0xd7, 0x88)] +}} +RIDL!{#[uuid(0x91636d4b, 0x9ba1, 0x4532, 0xaa, 0xf7, 0xe3, 0x34, 0x49, 0x94, 0xd7, 0x88)] interface IDCompositionTranslateTransform3D(IDCompositionTranslateTransform3DVtbl): IDCompositionTransform3D(IDCompositionTransform3DVtbl) { fn SetOffsetX_2( @@ -371,8 +371,8 @@ fn SetOffsetZ_1( offsetZ: c_float, ) -> HRESULT, -}); -RIDL!(#[uuid(0x2a9e9ead, 0x364b, 0x4b15, 0xa7, 0xc4, 0xa1, 0x99, 0x7f, 0x78, 0xb3, 0x89)] +}} +RIDL!{#[uuid(0x2a9e9ead, 0x364b, 0x4b15, 0xa7, 0xc4, 0xa1, 0x99, 0x7f, 0x78, 0xb3, 0x89)] interface IDCompositionScaleTransform3D(IDCompositionScaleTransform3DVtbl): IDCompositionTransform3D(IDCompositionTransform3DVtbl) { fn SetScaleX_2( @@ -411,8 +411,8 @@ fn SetCenterZ_1( centerZ: c_float, ) -> HRESULT, -}); -RIDL!(#[uuid(0xd8f5b23f, 0xd429, 0x4a91, 0xb5, 0x5a, 0xd2, 0xf4, 0x5f, 0xd7, 0x5b, 0x18)] +}} +RIDL!{#[uuid(0xd8f5b23f, 0xd429, 0x4a91, 0xb5, 0x5a, 0xd2, 0xf4, 0x5f, 0xd7, 0x5b, 0x18)] interface IDCompositionRotateTransform3D(IDCompositionRotateTransform3DVtbl): IDCompositionTransform3D(IDCompositionTransform3DVtbl) { fn SetAngle_2( @@ -457,8 +457,8 @@ fn SetCenterZ_1( centerZ: c_float, ) -> HRESULT, -}); -RIDL!(#[uuid(0x4b3363f0, 0x643b, 0x41b7, 0xb6, 0xe0, 0xcc, 0xf2, 0x2d, 0x34, 0x46, 0x7c)] +}} +RIDL!{#[uuid(0x4b3363f0, 0x643b, 0x41b7, 0xb6, 0xe0, 0xcc, 0xf2, 0x2d, 0x34, 0x46, 0x7c)] interface IDCompositionMatrixTransform3D(IDCompositionMatrixTransform3DVtbl): IDCompositionTransform3D(IDCompositionTransform3DVtbl) { fn SetMatrix( @@ -474,11 +474,11 @@ column: c_int, value: c_float, ) -> HRESULT, -}); -RIDL!(#[uuid(0x64ac3703, 0x9d3f, 0x45ec, 0xa1, 0x09, 0x7c, 0xac, 0x0e, 0x7a, 0x13, 0xa7)] +}} +RIDL!{#[uuid(0x64ac3703, 0x9d3f, 0x45ec, 0xa1, 0x09, 0x7c, 0xac, 0x0e, 0x7a, 0x13, 0xa7)] interface IDCompositionClip(IDCompositionClipVtbl): IUnknown(IUnknownVtbl) { -}); -RIDL!(#[uuid(0x9842ad7d, 0xd9cf, 0x4908, 0xae, 0xd7, 0x48, 0xb5, 0x1d, 0xa5, 0xe7, 0xc2)] +}} +RIDL!{#[uuid(0x9842ad7d, 0xd9cf, 0x4908, 0xae, 0xd7, 0x48, 0xb5, 0x1d, 0xa5, 0xe7, 0xc2)] interface IDCompositionRectangleClip(IDCompositionRectangleClipVtbl): IDCompositionClip(IDCompositionClipVtbl) { fn SetLeft_2( @@ -553,8 +553,8 @@ fn SetBottomRightRadiusY_1( radius: c_float, ) -> HRESULT, -}); -RIDL!(#[uuid(0xbb8a4953, 0x2c99, 0x4f5a, 0x96, 0xf5, 0x48, 0x19, 0x02, 0x7f, 0xa3, 0xac)] +}} +RIDL!{#[uuid(0xbb8a4953, 0x2c99, 0x4f5a, 0x96, 0xf5, 0x48, 0x19, 0x02, 0x7f, 0xa3, 0xac)] interface IDCompositionSurface(IDCompositionSurfaceVtbl): IUnknown(IUnknownVtbl) { fn BeginDraw( updateRect: *const RECT, @@ -571,8 +571,8 @@ offsetX: c_int, offsetY: c_int, ) -> HRESULT, -}); -RIDL!(#[uuid(0xae471c51, 0x5f53, 0x4a24, 0x8d, 0x3e, 0xd0, 0xc3, 0x9c, 0x30, 0xb3, 0xf0)] +}} +RIDL!{#[uuid(0xae471c51, 0x5f53, 0x4a24, 0x8d, 0x3e, 0xd0, 0xc3, 0x9c, 0x30, 0xb3, 0xf0)] interface IDCompositionVirtualSurface(IDCompositionVirtualSurfaceVtbl): IDCompositionSurface(IDCompositionSurfaceVtbl) { fn Resize( @@ -583,8 +583,8 @@ rectangles: *const RECT, count: UINT, ) -> HRESULT, -}); -RIDL!(#[uuid(0x75f6468d, 0x1b8e, 0x447c, 0x9b, 0xc6, 0x75, 0xfe, 0xa8, 0x0b, 0x5b, 0x25)] +}} +RIDL!{#[uuid(0x75f6468d, 0x1b8e, 0x447c, 0x9b, 0xc6, 0x75, 0xfe, 0xa8, 0x0b, 0x5b, 0x25)] interface IDCompositionDevice2(IDCompositionDevice2Vtbl): IUnknown(IUnknownVtbl) { fn Commit() -> HRESULT, fn WaitForCommitCompletion() -> HRESULT, @@ -658,8 +658,8 @@ fn CreateAnimation( animation: *mut *mut IDCompositionAnimation, ) -> HRESULT, -}); -RIDL!(#[uuid(0x5f4633fe, 0x1e08, 0x4cb8, 0x8c, 0x75, 0xce, 0x24, 0x33, 0x3f, 0x56, 0x02)] +}} +RIDL!{#[uuid(0x5f4633fe, 0x1e08, 0x4cb8, 0x8c, 0x75, 0xce, 0x24, 0x33, 0x3f, 0x56, 0x02)] interface IDCompositionDesktopDevice(IDCompositionDesktopDeviceVtbl): IDCompositionDevice2(IDCompositionDevice2Vtbl) { fn CreateTargetForHwnd( @@ -675,13 +675,13 @@ hwnd: HWND, surface: *mut *mut IUnknown, ) -> HRESULT, -}); -RIDL!(#[uuid(0xa1a3c64a, 0x224f, 0x4a81, 0x97, 0x73, 0x4f, 0x03, 0xa8, 0x9d, 0x3c, 0x6c)] +}} +RIDL!{#[uuid(0xa1a3c64a, 0x224f, 0x4a81, 0x97, 0x73, 0x4f, 0x03, 0xa8, 0x9d, 0x3c, 0x6c)] interface IDCompositionDeviceDebug(IDCompositionDeviceDebugVtbl): IUnknown(IUnknownVtbl) { fn EnableDebugCounters() -> HRESULT, fn DisableDebugCounters() -> HRESULT, -}); -RIDL!(#[uuid(0xe334bc12, 0x3937, 0x4e02, 0x85, 0xeb, 0xfc, 0xf4, 0xeb, 0x30, 0xd2, 0xc8)] +}} +RIDL!{#[uuid(0xe334bc12, 0x3937, 0x4e02, 0x85, 0xeb, 0xfc, 0xf4, 0xeb, 0x30, 0xd2, 0xc8)] interface IDCompositionSurfaceFactory(IDCompositionSurfaceFactoryVtbl): IUnknown(IUnknownVtbl) { fn CreateSurface( width: UINT, @@ -697,8 +697,8 @@ alphaMode: DXGI_ALPHA_MODE, virtualSurface: *mut *mut IDCompositionVirtualSurface, ) -> HRESULT, -}); -RIDL!(#[uuid(0xe8de1639, 0x4331, 0x4b26, 0xbc, 0x5f, 0x6a, 0x32, 0x1d, 0x34, 0x7a, 0x85)] +}} +RIDL!{#[uuid(0xe8de1639, 0x4331, 0x4b26, 0xbc, 0x5f, 0x6a, 0x32, 0x1d, 0x34, 0x7a, 0x85)] interface IDCompositionVisual2(IDCompositionVisual2Vtbl): IDCompositionVisual(IDCompositionVisualVtbl) { fn SetOpacityMode( @@ -707,8 +707,8 @@ fn SetBackFaceVisibility( visibility: DCOMPOSITION_BACKFACE_VISIBILITY, ) -> HRESULT, -}); -RIDL!(#[uuid(0xfed2b808, 0x5eb4, 0x43a0, 0xae, 0xa3, 0x35, 0xf6, 0x52, 0x80, 0xf9, 0x1b)] +}} +RIDL!{#[uuid(0xfed2b808, 0x5eb4, 0x43a0, 0xae, 0xa3, 0x35, 0xf6, 0x52, 0x80, 0xf9, 0x1b)] interface IDCompositionVisualDebug(IDCompositionVisualDebugVtbl): IDCompositionVisual2(IDCompositionVisual2Vtbl) { fn EnableHeatMap( @@ -717,8 +717,8 @@ fn DisableHeatMap() -> HRESULT, fn EnableRedrawRegions() -> HRESULT, fn DisableRedrawRegions() -> HRESULT, -}); -RIDL!(#[uuid(0x2775f462, 0xb6c1, 0x4015, 0xb0, 0xbe, 0xb3, 0xe7, 0xd6, 0xa4, 0x97, 0x6d)] +}} +RIDL!{#[uuid(0x2775f462, 0xb6c1, 0x4015, 0xb0, 0xbe, 0xb3, 0xe7, 0xd6, 0xa4, 0x97, 0x6d)] interface IDCompositionVisual3(IDCompositionVisual3Vtbl): IDCompositionVisualDebug(IDCompositionVisualDebugVtbl) { fn SetDepthMode( @@ -745,8 +745,8 @@ fn SetVisible( visible: BOOL, ) -> HRESULT, -}); -RIDL!(#[uuid(0x0987cb06, 0xf916, 0x48bf, 0x8d, 0x35, 0xce, 0x76, 0x41, 0x78, 0x1b, 0xd9)] +}} +RIDL!{#[uuid(0x0987cb06, 0xf916, 0x48bf, 0x8d, 0x35, 0xce, 0x76, 0x41, 0x78, 0x1b, 0xd9)] interface IDCompositionDevice3(IDCompositionDevice3Vtbl): IDCompositionDevice2(IDCompositionDevice2Vtbl) { fn CreateGaussianBlurEffect( @@ -788,8 +788,8 @@ fn CreateAffineTransform2DEffect( affineTransform2dEffect: *mut *mut IDCompositionAffineTransform2DEffect, ) -> HRESULT, -}); -RIDL!(#[uuid(0x30c421d5, 0x8cb2, 0x4e9f, 0xb1, 0x33, 0x37, 0xbe, 0x27, 0x0d, 0x4a, 0xc2)] +}} +RIDL!{#[uuid(0x30c421d5, 0x8cb2, 0x4e9f, 0xb1, 0x33, 0x37, 0xbe, 0x27, 0x0d, 0x4a, 0xc2)] interface IDCompositionFilterEffect(IDCompositionFilterEffectVtbl): IDCompositionEffect(IDCompositionEffectVtbl) { fn SetInput( @@ -797,8 +797,8 @@ input: *const IUnknown, flags: UINT, ) -> HRESULT, -}); -RIDL!(#[uuid(0x45d4d0b7, 0x1bd4, 0x454e, 0x88, 0x94, 0x2b, 0xfa, 0x68, 0x44, 0x30, 0x33)] +}} +RIDL!{#[uuid(0x45d4d0b7, 0x1bd4, 0x454e, 0x88, 0x94, 0x2b, 0xfa, 0x68, 0x44, 0x30, 0x33)] interface IDCompositionGaussianBlurEffect(IDCompositionGaussianBlurEffectVtbl): IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { fn SetStandardDeviation_2( @@ -810,8 +810,8 @@ fn SetBorderMode( mode: D2D1_BORDER_MODE, ) -> HRESULT, -}); -RIDL!(#[uuid(0x6027496e, 0xcb3a, 0x49ab, 0x93, 0x4f, 0xd7, 0x98, 0xda, 0x4f, 0x7d, 0xa6)] +}} +RIDL!{#[uuid(0x6027496e, 0xcb3a, 0x49ab, 0x93, 0x4f, 0xd7, 0x98, 0xda, 0x4f, 0x7d, 0xa6)] interface IDCompositionBrightnessEffect(IDCompositionBrightnessEffectVtbl): IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { fn SetWhitePoint( @@ -844,8 +844,8 @@ fn SetBlackPointY_1( blackPointY: c_float, ) -> HRESULT, -}); -RIDL!(#[uuid(0xc1170a22, 0x3ce2, 0x4966, 0x90, 0xd4, 0x55, 0x40, 0x8b, 0xfc, 0x84, 0xc4)] +}} +RIDL!{#[uuid(0xc1170a22, 0x3ce2, 0x4966, 0x90, 0xd4, 0x55, 0x40, 0x8b, 0xfc, 0x84, 0xc4)] interface IDCompositionColorMatrixEffect(IDCompositionColorMatrixEffectVtbl): IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { fn SetMatrix( @@ -867,8 +867,8 @@ fn SetClampOutput( clamp: BOOL, ) -> HRESULT, -}); -RIDL!(#[uuid(0x4ad18ac0, 0xcfd2, 0x4c2f, 0xbb, 0x62, 0x96, 0xe5, 0x4f, 0xdb, 0x68, 0x79)] +}} +RIDL!{#[uuid(0x4ad18ac0, 0xcfd2, 0x4c2f, 0xbb, 0x62, 0x96, 0xe5, 0x4f, 0xdb, 0x68, 0x79)] interface IDCompositionShadowEffect(IDCompositionShadowEffectVtbl): IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { fn SetStandardDeviation_2( @@ -904,8 +904,8 @@ fn SetAlpha_1( amount: c_float, ) -> HRESULT, -}); -RIDL!(#[uuid(0x6db9f920, 0x0770, 0x4781, 0xb0, 0xc6, 0x38, 0x19, 0x12, 0xf9, 0xd1, 0x67)] +}} +RIDL!{#[uuid(0x6db9f920, 0x0770, 0x4781, 0xb0, 0xc6, 0x38, 0x19, 0x12, 0xf9, 0xd1, 0x67)] interface IDCompositionHueRotationEffect(IDCompositionHueRotationEffectVtbl): IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { // Changes the angle of rotation @@ -915,8 +915,8 @@ fn SetAngle_1( amountDegrees: c_float, ) -> HRESULT, -}); -RIDL!(#[uuid(0xa08debda, 0x3258, 0x4fa4, 0x9f, 0x16, 0x91, 0x74, 0xd3, 0xfe, 0x93, 0xb1)] +}} +RIDL!{#[uuid(0xa08debda, 0x3258, 0x4fa4, 0x9f, 0x16, 0x91, 0x74, 0xd3, 0xfe, 0x93, 0xb1)] interface IDCompositionSaturationEffect(IDCompositionSaturationEffectVtbl): IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { // Changes the amount of saturation to be applied. @@ -926,8 +926,8 @@ fn SetSaturation_1( ratio: c_float, ) -> HRESULT, -}); -RIDL!(#[uuid(0xa6a55bda, 0xc09c, 0x49f3, 0x91, 0x93, 0xa4, 0x19, 0x22, 0xc8, 0x97, 0x15)] +}} +RIDL!{#[uuid(0xa6a55bda, 0xc09c, 0x49f3, 0x91, 0x93, 0xa4, 0x19, 0x22, 0xc8, 0x97, 0x15)] interface IDCompositionTurbulenceEffect(IDCompositionTurbulenceEffectVtbl): IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { fn SetOffset( @@ -951,8 +951,8 @@ fn SetStitchable( stitchable: BOOL, ) -> HRESULT, -}); -RIDL!(#[uuid(0x4305ee5b, 0xc4a0, 0x4c88, 0x93, 0x85, 0x67, 0x12, 0x4e, 0x01, 0x76, 0x83)] +}} +RIDL!{#[uuid(0x4305ee5b, 0xc4a0, 0x4c88, 0x93, 0x85, 0x67, 0x12, 0x4e, 0x01, 0x76, 0x83)] interface IDCompositionLinearTransferEffect(IDCompositionLinearTransferEffectVtbl): IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { fn SetRedYIntercept_2( @@ -1018,8 +1018,8 @@ fn SetClampOutput( clampOutput: BOOL, ) -> HRESULT, -}); -RIDL!(#[uuid(0x9b7e82e2, 0x69c5, 0x4eb4, 0xa5, 0xf5, 0xa7, 0x03, 0x3f, 0x51, 0x32, 0xcd)] +}} +RIDL!{#[uuid(0x9b7e82e2, 0x69c5, 0x4eb4, 0xa5, 0xf5, 0xa7, 0x03, 0x3f, 0x51, 0x32, 0xcd)] interface IDCompositionTableTransferEffect(IDCompositionTableTransferEffectVtbl): IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { fn SetRedTable( @@ -1085,22 +1085,22 @@ index: UINT, value: c_float, ) -> HRESULT, -}); -RIDL!(#[uuid(0x576616c0, 0xa231, 0x494d, 0xa3, 0x8d, 0x00, 0xfd, 0x5e, 0xc4, 0xdb, 0x46)] +}} +RIDL!{#[uuid(0x576616c0, 0xa231, 0x494d, 0xa3, 0x8d, 0x00, 0xfd, 0x5e, 0xc4, 0xdb, 0x46)] interface IDCompositionCompositeEffect(IDCompositionCompositeEffectVtbl): IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { fn SetMode( mode: D2D1_COMPOSITE_MODE, ) -> HRESULT, -}); -RIDL!(#[uuid(0x33ecdc0a, 0x578a, 0x4a11, 0x9c, 0x14, 0x0c, 0xb9, 0x05, 0x17, 0xf9, 0xc5)] +}} +RIDL!{#[uuid(0x33ecdc0a, 0x578a, 0x4a11, 0x9c, 0x14, 0x0c, 0xb9, 0x05, 0x17, 0xf9, 0xc5)] interface IDCompositionBlendEffect(IDCompositionBlendEffectVtbl): IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { fn SetMode( mode: D2D1_BLEND_MODE, ) -> HRESULT, -}); -RIDL!(#[uuid(0x3b67dfa8, 0xe3dd, 0x4e61, 0xb6, 0x40, 0x46, 0xc2, 0xf3, 0xd7, 0x39, 0xdc)] +}} +RIDL!{#[uuid(0x3b67dfa8, 0xe3dd, 0x4e61, 0xb6, 0x40, 0x46, 0xc2, 0xf3, 0xd7, 0x39, 0xdc)] interface IDCompositionArithmeticCompositeEffect(IDCompositionArithmeticCompositeEffectVtbl): IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { fn SetCoefficients( @@ -1133,8 +1133,8 @@ fn SetCoefficient4_1( Coefficient4: c_float, ) -> HRESULT, -}); -RIDL!(#[uuid(0x0b74b9e8, 0xcdd6, 0x492f, 0xbb, 0xbc, 0x5e, 0xd3, 0x21, 0x57, 0x02, 0x6d)] +}} +RIDL!{#[uuid(0x0b74b9e8, 0xcdd6, 0x492f, 0xbb, 0xbc, 0x5e, 0xd3, 0x21, 0x57, 0x02, 0x6d)] interface IDCompositionAffineTransform2DEffect(IDCompositionAffineTransform2DEffectVtbl): IDCompositionFilterEffect(IDCompositionFilterEffectVtbl) { fn SetInterpolationMode( @@ -1162,4 +1162,4 @@ fn SetSharpness_1( sharpness: c_float, ) -> HRESULT, -}); +}} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/devicetopology.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/devicetopology.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/devicetopology.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/devicetopology.rs 2018-12-05 01:24:42.000000000 +0000 @@ -0,0 +1,461 @@ +// Copyright © 2018 winapi-rs developers +// Licensed under the Apache License, Version 2.0 +// or the MIT license +// , at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! The DeviceTopology API gives clients control over a variety of internal functions of audio +//! adapters that they cannot access through the MMDevice API, WASAPI, or the EndpointVolume API. +use ctypes::{c_float, c_void}; +use shared::guiddef::{GUID, LPCGUID, REFGUID, REFIID}; +use shared::minwindef::{BOOL, DWORD, UCHAR, UINT, ULONG, WORD}; +use shared::windef::COLORREF; +use shared::wtypes::VARTYPE; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +use um::winnt::{HRESULT, LONG, LONGLONG, LPWSTR, WCHAR}; +DEFINE_GUID!{EVENTCONTEXT_VOLUMESLIDER, + 0xe2c2e9de, 0x09b1, 0x4b04, 0x84, 0xe5, 0x07, 0x93, 0x12, 0x25, 0xee, 0x04} +STRUCT!{struct KSDATAFORMAT { + FormatSize: ULONG, + Flags: ULONG, + SampleSize: ULONG, + Reserved: ULONG, + MajorFormat: GUID, + SubFormat: GUID, + Specifier: GUID, +}} +pub type PKSDATAFORMAT = *mut KSDATAFORMAT; +STRUCT!{struct KSIDENTIFIER_s { + Set: GUID, + Id: ULONG, + Flags: ULONG, +}} +UNION!{union KSIDENTIFIER { + [u64; 3], + s s_mut: KSIDENTIFIER_s, + Alignment Alignment_mut: LONGLONG, +}} +pub type KSPROPERTY = KSIDENTIFIER; +pub type PKSPROPERTY = *mut KSIDENTIFIER; +pub type KSMETHOD = KSIDENTIFIER; +pub type PKSMETHOD = *mut KSIDENTIFIER; +pub type KSEVENT = KSIDENTIFIER; +pub type PKSEVENT = *mut KSIDENTIFIER; +ENUM!{enum EPcxConnectionType { + eConnTypeUnknown = 0, + eConnType3Point5mm = 1, + eConnTypeQuarter = 2, + eConnTypeAtapiInternal = 3, + eConnTypeRCA = 4, + eConnTypeOptical = 5, + eConnTypeOtherDigital = 6, + eConnTypeOtherAnalog = 7, + eConnTypeMultichannelAnalogDIN = 8, + eConnTypeXlrProfessional = 9, + eConnTypeRJ11Modem = 10, + eConnTypeCombination = 11, +}} +ENUM!{enum EPcxGeoLocation { + eGeoLocRear = 1, + eGeoLocFront = 2, + eGeoLocLeft = 3, + eGeoLocRight = 4, + eGeoLocTop = 5, + eGeoLocBottom = 6, + eGeoLocRearPanel = 7, + eGeoLocRiser = 8, + eGeoLocInsideMobileLid = 9, + eGeoLocDrivebay = 10, + eGeoLocHDMI = 11, + eGeoLocOutsideMobileLid = 12, + eGeoLocATAPI = 13, + eGeoLocNotApplicable = 14, + eGeoLocReserved6 = 15, +}} +ENUM!{enum EPcxGenLocation { + eGenLocPrimaryBox = 0, + eGenLocInternal = 1, + eGenLocSeparate = 2, + eGenLocOther = 3, +}} +ENUM!{enum EPxcPortConnection { + ePortConnJack = 0, + ePortConnIntegratedDevice = 1, + ePortConnBothIntegratedAndJack = 2, + ePortConnUnknown = 3, +}} +STRUCT!{struct KSJACK_DESCRIPTION { + ChannelMapping: DWORD, + Color: COLORREF, + ConnectionType: EPcxConnectionType, + GeoLocation: EPcxGeoLocation, + GenLocation: EPcxGenLocation, + PortConnection: EPxcPortConnection, + IsConnected: BOOL, +}} +pub type PKSJACK_DESCRIPTION = *mut KSJACK_DESCRIPTION; +STRUCT!{struct LUID { + LowPart: DWORD, + HighPart: LONG, +}} +pub type PLUID = *mut LUID; +ENUM!{enum KSJACK_SINK_CONNECTIONTYPE { + KSJACK_SINK_CONNECTIONTYPE_HDMI = 0, + KSJACK_SINK_CONNECTIONTYPE_DISPLAYPORT = 1, +}} +STRUCT!{struct KSJACK_SINK_INFORMATION { + ConnType: KSJACK_SINK_CONNECTIONTYPE, + ManufacturerId: WORD, + ProductId: WORD, + AudioLatency: WORD, + HDCPCapable: BOOL, + AICapable: BOOL, + SinkDescriptionLength: UCHAR, + SinkDescription: [WCHAR; 32], + PortId: LUID, +}} +STRUCT!{struct KSJACK_DESCRIPTION2 { + DeviceStateInfo: DWORD, + JackCapabilities: DWORD, +}} +pub type PKSJACK_DESCRIPTION2 = *mut KSJACK_DESCRIPTION2; +ENUM!{enum DataFlow { + In = 0, + Out = 1, +}} +ENUM!{enum PartType { + Connector = 0, + Subunit = 1, +}} +ENUM!{enum ConnectorType { + Unknown_Connector = 0, + Physical_Internal = 1, + Physical_External = 2, + Software_IO = 3, + Software_Fixed = 4, + Network = 5, +}} +RIDL!{#[uuid(0x28f54685, 0x06fd, 0x11d2, 0xb2, 0x7a, 0x00, 0xa0, 0xc9, 0x22, 0x31, 0x96)] +interface IKsControl(IKsControlVtbl): IUnknown(IUnknownVtbl) { + fn KsProperty( + Property: PKSPROPERTY, + PropertyLength: ULONG, + PropertyData: *mut c_void, + DataLength: ULONG, + BytesReturned: *mut ULONG, + ) -> HRESULT, + fn KsMethod( + Method: PKSMETHOD, + MethodLength: ULONG, + MethodData: *mut c_void, + DataLength: ULONG, + BytesReturned: *mut ULONG, + ) -> HRESULT, + fn KsEvent( + Event: PKSEVENT, + EventLength: ULONG, + EventData: *mut c_void, + DataLength: ULONG, + BytesReturned: *mut ULONG, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xc2f8e001, 0xf205, 0x4bc9, 0x99, 0xbc, 0xc1, 0x3b, 0x1e, 0x04, 0x8c, 0xcb)] +interface IPerChannelDbLevel(IPerChannelDbLevelVtbl): IUnknown(IUnknownVtbl) { + fn GetChannelCount( + pcChannels: *mut UINT, + ) -> HRESULT, + fn GetLevelRange( + nChannel: UINT, + pfMinLevelDB: *mut c_float, + pfMaxLevelDB: *mut c_float, + pfStepping: *mut c_float, + ) -> HRESULT, + fn GetLevel( + nChannel: UINT, + pfLevelDB: *mut c_float, + ) -> HRESULT, + fn SetLevel( + nChannel: UINT, + fLevelDB: c_float, + pguidEventContext: LPCGUID, + ) -> HRESULT, + fn SetLevelUniform( + fLevelDB: c_float, + pguidEventContext: LPCGUID, + ) -> HRESULT, + fn SetLevelAllChannels( + aLevelsDB: *mut c_float, + cChannels: ULONG, + pguidEventContext: LPCGUID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x7fb7b48f, 0x531d, 0x44a2, 0xbc, 0xb3, 0x5a, 0xd5, 0xa1, 0x34, 0xb3, 0xdc)] +interface IAudioVolumeLevel(IAudioVolumeLevelVtbl): IPerChannelDbLevel(IPerChannelDbLevelVtbl) {}} +RIDL!{#[uuid(0xbb11c46f, 0xec28, 0x493c, 0xb8, 0x8a, 0x5d, 0xb8, 0x80, 0x62, 0xce, 0x98)] +interface IAudioChannelConfig(IAudioChannelConfigVtbl): IUnknown(IUnknownVtbl) { + fn SetChannelConfig( + dwConfig: DWORD, + pguidEventContext: LPCGUID, + ) -> HRESULT, + fn GetChannelConfig( + pdwConfig: *mut DWORD, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x7d8b1437, 0xdd53, 0x4350, 0x9c, 0x1b, 0x1e, 0xe2, 0x89, 0x0b, 0xd9, 0x38)] +interface IAudioLoudness(IAudioLoudnessVtbl): IUnknown(IUnknownVtbl) { + fn GetEnabled( + pbEnabled: *mut BOOL, + ) -> HRESULT, + fn SetEnabled( + bEnable: BOOL, + pguidEventContext: LPCGUID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x4f03dc02, 0x5e6e, 0x4653, 0x8f, 0x72, 0xa0, 0x30, 0xc1, 0x23, 0xd5, 0x98)] +interface IAudioInputSelector(IAudioInputSelectorVtbl): IUnknown(IUnknownVtbl) { + fn GetSelection( + pnIdSelected: *mut UINT, + ) -> HRESULT, + fn SetSelection( + nIdSelect: UINT, + pguidEventContext: LPCGUID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xbb515f69, 0x94a7, 0x429e, 0x8b, 0x9c, 0x27, 0x1b, 0x3f, 0x11, 0xa3, 0xab)] +interface IAudioOutputSelector(IAudioOutputSelectorVtbl): IUnknown(IUnknownVtbl) { + fn GetSelection( + pnIdSelected: *mut UINT, + ) -> HRESULT, + fn SetSelection( + nIdSelect: UINT, + pguidEventContext: LPCGUID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xdf45aeea, 0xb74a, 0x4b6b, 0xaf, 0xad, 0x23, 0x66, 0xb6, 0xaa, 0x01, 0x2e)] +interface IAudioMute(IAudioMuteVtbl): IUnknown(IUnknownVtbl) { + fn SetMute( + bMuted: BOOL, + pguidEventContext: LPCGUID, + ) -> HRESULT, + fn GetMute( + pbMuted: *mut BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa2b1a1d9, 0x4db3, 0x425d, 0xa2, 0xb2, 0xbd, 0x33, 0x5c, 0xb3, 0xe2, 0xe5)] +interface IAudioBass(IAudioBassVtbl): IPerChannelDbLevel(IPerChannelDbLevelVtbl) {}} +RIDL!{#[uuid(0x5e54b6d7, 0xb44b, 0x40d9, 0x9a, 0x9e, 0xe6, 0x91, 0xd9, 0xce, 0x6e, 0xdf)] +interface IAudioMidrange(IAudioMidrangeVtbl): IPerChannelDbLevel(IPerChannelDbLevelVtbl) {}} +RIDL!{#[uuid(0x0a717812, 0x694e, 0x4907, 0xb7, 0x4b, 0xba, 0xfa, 0x5c, 0xfd, 0xca, 0x7b)] +interface IAudioTreble(IAudioTrebleVtbl): IPerChannelDbLevel(IPerChannelDbLevelVtbl) {}} +RIDL!{#[uuid(0x85401fd4, 0x6de4, 0x4b9d, 0x98, 0x69, 0x2d, 0x67, 0x53, 0xa8, 0x2f, 0x3c)] +interface IAudioAutoGainControl(IAudioAutoGainControlVtbl): IUnknown(IUnknownVtbl) { + fn GetEnabled( + pbEnabled: *mut BOOL, + ) -> HRESULT, + fn SetEnabled( + bEnable: BOOL, + pguidEventContext: LPCGUID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xdd79923c, 0x0599, 0x45e0, 0xb8, 0xb6, 0xc8, 0xdf, 0x7d, 0xb6, 0xe7, 0x96)] +interface IAudioPeakMeter(IAudioPeakMeterVtbl): IUnknown(IUnknownVtbl) { + fn GetChannelCount( + pcChannels: *mut UINT, + ) -> HRESULT, + fn GetLevel( + nChannel: UINT, + pfLevel: *mut c_float, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x3b22bcbf, 0x2586, 0x4af0, 0x85, 0x83, 0x20, 0x5d, 0x39, 0x1b, 0x80, 0x7c)] +interface IDeviceSpecificProperty(IDeviceSpecificPropertyVtbl): IUnknown(IUnknownVtbl) { + fn GetType( + pVType: *mut VARTYPE, + ) -> HRESULT, + fn GetValue( + pvValue: *mut c_void, + pcbValue: *mut DWORD, + ) -> HRESULT, + fn SetValue( + pvValue: *mut c_void, + cbValue: DWORD, + pguidEventContext: LPCGUID, + ) -> HRESULT, + fn Get4BRange( + plMin: *mut LONG, + plMax: *mut LONG, + plStepping: *mut LONG, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x3cb4a69d, 0xbb6f, 0x4d2b, 0x95, 0xb7, 0x45, 0x2d, 0x2c, 0x15, 0x5d, 0xb5)] +interface IKsFormatSupport(IKsFormatSupportVtbl): IUnknown(IUnknownVtbl) { + fn IsFormatSupported( + pKsFormat: PKSDATAFORMAT, + cbFormat: DWORD, + pbSupported: *mut BOOL, + ) -> HRESULT, + fn GetDevicePreferredFormat( + ppKsFormat: *mut PKSDATAFORMAT, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x4509f757, 0x2d46, 0x4637, 0x8e, 0x62, 0xce, 0x7d, 0xb9, 0x44, 0xf5, 0x7b)] +interface IKsJackDescription(IKsJackDescriptionVtbl): IUnknown(IUnknownVtbl) { + fn GetJackCount( + pcJacks: *mut UINT, + ) -> HRESULT, + fn GetJackDescription( + nJack: UINT, + pDescription: *mut KSJACK_DESCRIPTION, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x478f3a9b, 0xe0c9, 0x4827, 0x92, 0x28, 0x6f, 0x55, 0x05, 0xff, 0xe7, 0x6a)] +interface IKsJackDescription2(IKsJackDescription2Vtbl): IUnknown(IUnknownVtbl) { + fn GetJackCount( + pcJacks: *mut UINT, + ) -> HRESULT, + fn GetJackDescription2( + nJack: UINT, + pDescription2: *mut KSJACK_DESCRIPTION2, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xd9bd72ed, 0x290f, 0x4581, 0x9f, 0xf3, 0x61, 0x02, 0x7a, 0x8f, 0xe5, 0x32)] +interface IKsJackSinkInformation(IKsJackSinkInformationVtbl): IUnknown(IUnknownVtbl) { + fn GetJackSinkInformation( + pJackSinkInformation: *mut KSJACK_SINK_INFORMATION, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xc99af463, 0xd629, 0x4ec4, 0x8c, 0x00, 0xe5, 0x4d, 0x68, 0x15, 0x42, 0x48)] +interface IKsJackContainerId(IKsJackContainerIdVtbl): IUnknown(IUnknownVtbl) { + fn GetJackContainerId( + pJackContainerId: *mut GUID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x6daa848c, 0x5eb0, 0x45cc, 0xae, 0xa5, 0x99, 0x8a, 0x2c, 0xda, 0x1f, 0xfb)] +interface IPartsList(IPartsListVtbl): IUnknown(IUnknownVtbl) { + fn GetCount( + pCount: *mut UINT, + ) -> HRESULT, + fn GetPart( + nIndex: UINT, + ppPart: *mut *mut IPart, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xae2de0e4, 0x5bca, 0x4f2d, 0xaa, 0x46, 0x5d, 0x13, 0xf8, 0xfd, 0xb3, 0xa9)] +interface IPart(IPartVtbl): IUnknown(IUnknownVtbl) { + fn GetName( + ppwstrName: *mut LPWSTR, + ) -> HRESULT, + fn GetLocalId( + pnId: *mut UINT, + ) -> HRESULT, + fn GetGlobalId( + ppwstrGlobalId: *mut LPWSTR, + ) -> HRESULT, + fn GetPartType( + pPartType: *mut PartType, + ) -> HRESULT, + fn GetSubType( + pSubType: *mut GUID, + ) -> HRESULT, + fn GetControlInterfaceCount( + pCount: *mut UINT, + ) -> HRESULT, + fn GetControlInterface( + nIndex: UINT, + ppInterfaceDesc: *mut *mut IControlInterface, + ) -> HRESULT, + fn EnumPartsIncoming( + ppParts: *mut *mut IPartsList, + ) -> HRESULT, + fn EnumPartsOutgoing( + ppParts: *mut *mut IPartsList, + ) -> HRESULT, + fn GetTopologyObject( + ppTopology: *mut *mut IDeviceTopology, + ) -> HRESULT, + fn Activate( + dwClsContext: DWORD, + refiid: REFIID, + ppvObject: *mut *mut c_void, + ) -> HRESULT, + fn RegisterControlChangeCallback( + riid: REFGUID, + pNotify: *mut IControlChangeNotify, + ) -> HRESULT, + fn UnregisterControlChangeCallback( + pNotify: *mut IControlChangeNotify, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x9c2c4058, 0x23f5, 0x41de, 0x87, 0x7a, 0xdf, 0x3a, 0xf2, 0x36, 0xa0, 0x9e)] +interface IConnector(IConnectorVtbl): IUnknown(IUnknownVtbl) { + fn GetType( + pType: *mut ConnectorType, + ) -> HRESULT, + fn GetDataFlow( + pFlow: *mut DataFlow, + ) -> HRESULT, + fn ConnectTo( + pConnectTo: *mut IConnector, + ) -> HRESULT, + fn Disconnect() -> HRESULT, + fn IsConnected( + pbConnected: *mut BOOL, + ) -> HRESULT, + fn GetConnectedTo( + ppConTo: *mut *mut IConnector, + ) -> HRESULT, + fn GetConnectorIdConnectedTo( + ppwstrConnectorId: *mut LPWSTR, + ) -> HRESULT, + fn GetDeviceIdConnectedTo( + ppwstrDeviceId: *mut LPWSTR, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x82149a85, 0xdba6, 0x4487, 0x86, 0xbb, 0xea, 0x8f, 0x7f, 0xef, 0xcc, 0x71)] +interface ISubunit(ISubunitVtbl): IUnknown(IUnknownVtbl) {}} +RIDL!{#[uuid(0x45d37c3f, 0x5140, 0x444a, 0xae, 0x24, 0x40, 0x07, 0x89, 0xf3, 0xcb, 0xf3)] +interface IControlInterface(IControlInterfaceVtbl): IUnknown(IUnknownVtbl) { + fn GetName( + ppwstrName: *mut LPWSTR, + ) -> HRESULT, + fn GetIID( + pIID: *mut GUID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa09513ed, 0xc709, 0x4d21, 0xbd, 0x7b, 0x5f, 0x34, 0xc4, 0x7f, 0x39, 0x47)] +interface IControlChangeNotify(IControlChangeNotifyVtbl): IUnknown(IUnknownVtbl) { + fn OnNotify( + dwSenderProcessId: DWORD, + pguidEventContext: LPCGUID, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x2a07407e, 0x6497, 0x4a18, 0x97, 0x87, 0x32, 0xf7, 0x9b, 0xd0, 0xd9, 0x8f)] +interface IDeviceTopology(IDeviceTopologyVtbl): IUnknown(IUnknownVtbl) { + fn GetConnectorCount( + pCount: *mut UINT, + ) -> HRESULT, + fn GetConnector( + nIndex: UINT, + ppConnector: *mut *mut IConnector, + ) -> HRESULT, + fn GetSubunitCount( + pCount: *mut UINT, + ) -> HRESULT, + fn GetSubunit( + nIndex: UINT, + ppSubunit: *mut *mut ISubunit, + ) -> HRESULT, + fn GetPartById( + nId: UINT, + ppPart: *mut *mut IPart, + ) -> HRESULT, + fn GetDeviceId( + ppwstrDeviceId: *mut LPWSTR, + ) -> HRESULT, + fn GetSignalPath( + pIPartFrom: *mut IPart, + pIPartTo: *mut IPart, + bRejectMixedPaths: BOOL, + ppParts: *mut *mut IPartsList, + ) -> HRESULT, +}} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/docobj.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/docobj.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/docobj.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/docobj.rs 2018-12-05 01:24:41.000000000 +0000 @@ -10,6 +10,14 @@ use um::oaidl::VARIANT; use um::unknwnbase::{IUnknown, IUnknownVtbl}; use um::winnt::HRESULT; +ENUM!{enum OLECMDF { + OLECMDF_SUPPORTED = 0x1, + OLECMDF_ENABLED = 0x2, + OLECMDF_LATCHED = 0x4, + OLECMDF_NINCHED = 0x8, + OLECMDF_INVISIBLE = 0x10, + OLECMDF_DEFHIDEONCTXTMENU = 0x20, +}} STRUCT!{struct OLECMD { cmdID: ULONG, cmdf: DWORD, @@ -20,6 +28,97 @@ cwBuf: ULONG, rgwz: [wchar_t; 1], }} +ENUM!{enum OLECMDEXECOPT { + OLECMDEXECOPT_DODEFAULT = 0, + OLECMDEXECOPT_PROMPTUSER = 1, + OLECMDEXECOPT_DONTPROMPTUSER = 2, + OLECMDEXECOPT_SHOWHELP = 3, +}} +ENUM!{enum OLECMDID { + OLECMDID_OPEN = 1, + OLECMDID_NEW = 2, + OLECMDID_SAVE = 3, + OLECMDID_SAVEAS = 4, + OLECMDID_SAVECOPYAS = 5, + OLECMDID_PRINT = 6, + OLECMDID_PRINTPREVIEW = 7, + OLECMDID_PAGESETUP = 8, + OLECMDID_SPELL = 9, + OLECMDID_PROPERTIES = 10, + OLECMDID_CUT = 11, + OLECMDID_COPY = 12, + OLECMDID_PASTE = 13, + OLECMDID_PASTESPECIAL = 14, + OLECMDID_UNDO = 15, + OLECMDID_REDO = 16, + OLECMDID_SELECTALL = 17, + OLECMDID_CLEARSELECTION = 18, + OLECMDID_ZOOM = 19, + OLECMDID_GETZOOMRANGE = 20, + OLECMDID_UPDATECOMMANDS = 21, + OLECMDID_REFRESH = 22, + OLECMDID_STOP = 23, + OLECMDID_HIDETOOLBARS = 24, + OLECMDID_SETPROGRESSMAX = 25, + OLECMDID_SETPROGRESSPOS = 26, + OLECMDID_SETPROGRESSTEXT = 27, + OLECMDID_SETTITLE = 28, + OLECMDID_SETDOWNLOADSTATE = 29, + OLECMDID_STOPDOWNLOAD = 30, + OLECMDID_ONTOOLBARACTIVATED = 31, + OLECMDID_FIND = 32, + OLECMDID_DELETE = 33, + OLECMDID_HTTPEQUIV = 34, + OLECMDID_HTTPEQUIV_DONE = 35, + OLECMDID_ENABLE_INTERACTION = 36, + OLECMDID_ONUNLOAD = 37, + OLECMDID_PROPERTYBAG2 = 38, + OLECMDID_PREREFRESH = 39, + OLECMDID_SHOWSCRIPTERROR = 40, + OLECMDID_SHOWMESSAGE = 41, + OLECMDID_SHOWFIND = 42, + OLECMDID_SHOWPAGESETUP = 43, + OLECMDID_SHOWPRINT = 44, + OLECMDID_CLOSE = 45, + OLECMDID_ALLOWUILESSSAVEAS = 46, + OLECMDID_DONTDOWNLOADCSS = 47, + OLECMDID_UPDATEPAGESTATUS = 48, + OLECMDID_PRINT2 = 49, + OLECMDID_PRINTPREVIEW2 = 50, + OLECMDID_SETPRINTTEMPLATE = 51, + OLECMDID_GETPRINTTEMPLATE = 52, + OLECMDID_PAGEACTIONBLOCKED = 55, + OLECMDID_PAGEACTIONUIQUERY = 56, + OLECMDID_FOCUSVIEWCONTROLS = 57, + OLECMDID_FOCUSVIEWCONTROLSQUERY = 58, + OLECMDID_SHOWPAGEACTIONMENU = 59, + OLECMDID_ADDTRAVELENTRY = 60, + OLECMDID_UPDATETRAVELENTRY = 61, + OLECMDID_UPDATEBACKFORWARDSTATE = 62, + OLECMDID_OPTICAL_ZOOM = 63, + OLECMDID_OPTICAL_GETZOOMRANGE = 64, + OLECMDID_WINDOWSTATECHANGED = 65, + OLECMDID_ACTIVEXINSTALLSCOPE = 66, + OLECMDID_UPDATETRAVELENTRY_DATARECOVERY = 67, + OLECMDID_SHOWTASKDLG = 68, + OLECMDID_POPSTATEEVENT = 69, + OLECMDID_VIEWPORT_MODE = 70, + OLECMDID_LAYOUT_VIEWPORT_WIDTH = 71, + OLECMDID_VISUAL_VIEWPORT_EXCLUDE_BOTTOM = 72, + OLECMDID_USER_OPTICAL_ZOOM = 73, + OLECMDID_PAGEAVAILABLE = 74, + OLECMDID_GETUSERSCALABLE = 75, + OLECMDID_UPDATE_CARET = 76, + OLECMDID_ENABLE_VISIBILITY = 77, + OLECMDID_MEDIA_PLAYBACK = 78, + OLECMDID_SETFAVICON = 79, + OLECMDID_SET_HOST_FULLSCREENMODE = 80, + OLECMDID_EXITFULLSCREEN = 81, + OLECMDID_SCROLLCOMPLETE = 82, + OLECMDID_ONBEFOREUNLOAD = 83, + OLECMDID_SHOWMESSAGE_BLOCKABLE = 84, + OLECMDID_SHOWTASKDLG_BLOCKABLE = 85, +}} RIDL!{#[uuid(0xb722bccb, 0x4e68, 0x101b, 0xa2, 0xbc, 0x00, 0xaa, 0x00, 0x40, 0x47, 0x70)] interface IOleCommandTarget(IOleCommandTargetVtbl): IUnknown(IUnknownVtbl) { fn QueryStatus( diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/dpa_dsa.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/dpa_dsa.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/dpa_dsa.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/dpa_dsa.rs 2018-12-05 01:24:42.000000000 +0000 @@ -265,9 +265,9 @@ DPA_InsertPtr( hdpa, DPA_Search( - hdpa, pFind, iStart, pfnCompare, lParam, DPAS_SORTED | options + hdpa, pFind, iStart, pfnCompare, lParam, DPAS_SORTED | options, ), - pitem + pitem, ) } pub const DPA_APPEND: c_int = DA_LAST; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/dsound.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/dsound.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/dsound.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/dsound.rs 2018-12-05 01:24:41.000000000 +0000 @@ -74,7 +74,7 @@ guid3DAlgorithm: GUID, }} pub type LPCDSBUFFERDESC = *const DSBUFFERDESC; -RIDL!(#[uuid(0x279afa85, 0x4981, 0x11ce, 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60)] +RIDL!{#[uuid(0x279afa85, 0x4981, 0x11ce, 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60)] interface IDirectSoundBuffer(IDirectSoundBufferVtbl): IUnknown(IUnknownVtbl) { fn GetCaps( pDSBufferCaps: LPDSBCAPS, @@ -141,14 +141,13 @@ dwAudioBytes2: DWORD, ) -> HRESULT, fn Restore() -> HRESULT, -} -); +}} pub type LPDIRECTSOUNDBUFFER = *mut IDirectSoundBuffer; DEFINE_GUID!{IID_IReferenceClock, 0x56a86897, 0x0ad4, 0x11ce, 0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70} DEFINE_GUID!{IID_IDirectSound, 0x279afa83, 0x4981, 0x11ce, 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60} -RIDL!(#[uuid(0x279afa83, 0x4981, 0x11ce, 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60)] +RIDL!{#[uuid(0x279afa83, 0x4981, 0x11ce, 0xa5, 0x21, 0x00, 0x20, 0xaf, 0x0b, 0xe5, 0x60)] interface IDirectSound(IDirectSoundVtbl): IUnknown(IUnknownVtbl) { fn CreateSoundBuffer( pcDSBufferDesc: LPCDSBUFFERDESC, @@ -176,8 +175,7 @@ fn Initialize( pcGuidDevice: LPCGUID, ) -> HRESULT, -} -); +}} pub type LPDIRECTSOUND = *mut IDirectSound; DEFINE_GUID!{IID_IDirectSound8, 0xc50a7e93, 0xf395, 0x4834, 0x9e, 0xf6, 0x7f, 0xa9, 0x9d, 0xe5, 0x09, 0x66} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/dwmapi.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/dwmapi.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/dwmapi.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/dwmapi.rs 2018-12-05 01:24:42.000000000 +0000 @@ -1,4 +1,4 @@ -// Copyright © 2015-2017 winapi-rs developers +// Copyright © 2015-2018 winapi-rs developers // Licensed under the Apache License, Version 2.0 // or the MIT license // , at your option. @@ -6,17 +6,72 @@ // except according to those terms. //! Procedure declarations, constant definitions, and macros for the NLS component. use shared::basetsd::UINT32; -use shared::minwindef::{BOOL, DWORD, HRGN, LPCVOID, LPVOID, UINT}; -use shared::windef::HWND; -use um::winnt::{HRESULT, ULONGLONG}; -pub type DWM_FRAME_COUNT = ULONGLONG; -pub type QPC_TIME = ULONGLONG; +use shared::minwindef::{ + BOOL, BYTE, DWORD, HRGN, INT, LPARAM, LPCVOID, LPVOID, LRESULT, UINT, WPARAM +}; +use shared::windef::{HBITMAP, HWND, POINT, PSIZE, RECT}; +use um::uxtheme::MARGINS; +use um::winnt::{HANDLE, HRESULT, ULONGLONG}; +pub const DWM_BB_ENABLE: DWORD = 0x00000001; +pub const DWM_BB_BLURREGION: DWORD = 0x00000002; +pub const DWM_BB_TRANSITIONONMAXIMIZED: DWORD = 0x00000004; STRUCT!{#[repr(packed)] struct DWM_BLURBEHIND { dwFlags: DWORD, fEnable: BOOL, hRgnBlur: HRGN, fTransitionOnMaximized: BOOL, }} +ENUM!{enum DWMWINDOWATTRIBUTE { + DWMWA_NCRENDERING_ENABLED = 1, + DWMWA_NCRENDERING_POLICY = 2, + DWMWA_TRANSITIONS_FORCEDISABLED = 3, + DWMWA_ALLOW_NCPAINT = 4, + DWMWA_CAPTION_BUTTON_BOUNDS = 5, + DWMWA_NONCLIENT_RTL_LAYOUT = 6, + DWMWA_FORCE_ICONIC_REPRESENTATION = 7, + DWMWA_FLIP3D_POLICY = 8, + DWMWA_EXTENDED_FRAME_BOUNDS = 9, + DWMWA_HAS_ICONIC_BITMAP = 10, + DWMWA_DISALLOW_PEEK = 11, + DWMWA_EXCLUDED_FROM_PEEK = 12, + DWMWA_CLOAK = 13, + DWMWA_CLOAKED = 14, + DWMWA_FREEZE_REPRESENTATION = 15, + DWMWA_LAST = 16, +}} +ENUM!{enum DWMNCRENDERINGPOLICY { + DWMNCRP_USEWINDOWSTYLE = 0, + DWMNCRP_DISABLED = 1, + DWMNCRP_ENABLED = 2, + DWMNCRP_LAST = 3, +}} +ENUM!{enum DWMFLIP3DWINDOWPOLICY { + DWMFLIP3D_DEFAULT = 0, + DWMFLIP3D_EXCLUDEBELOW = 1, + DWMFLIP3D_EXCLUDEABOVE = 2, + DWMFLIP3D_LAST = 3, +}} +pub const DWM_CLOAKED_APP: u32 = 0x00000001; +pub const DWM_CLOAKED_SHELL: u32 = 0x00000002; +pub const DWM_CLOAKED_INHERITED: u32 = 0x00000004; +pub type HTHUMBNAIL = HANDLE; +pub type PHTHUMBNAIL = *mut HTHUMBNAIL; +pub const DWM_TNP_RECTDESTINATION: DWORD = 0x00000001; +pub const DWM_TNP_RECTSOURCE: DWORD = 0x00000002; +pub const DWM_TNP_OPACITY: DWORD = 0x00000004; +pub const DWM_TNP_VISIBLE: DWORD = 0x00000008; +pub const DWM_TNP_SOURCECLIENTAREAONLY: DWORD = 0x00000010; +STRUCT!{#[repr(packed)] struct DWM_THUMBNAIL_PROPERTIES { + dwFlags: DWORD, + rcDestination: RECT, + rcSource: RECT, + opacity: BYTE, + fVisible: BOOL, + fSourceClientAreaOnly: BOOL, +}} +pub type PDWM_THUMBNAIL_PROPERTIES = *mut DWM_THUMBNAIL_PROPERTIES; +pub type DWM_FRAME_COUNT = ULONGLONG; +pub type QPC_TIME = ULONGLONG; STRUCT!{#[repr(packed)] struct UNSIGNED_RATIO { uiNumerator: UINT32, uiDenominator: UINT32, @@ -63,32 +118,55 @@ cPixelsDrawn: ULONGLONG, cBuffersEmpty: DWM_FRAME_COUNT, }} -pub const DWMWA_NCRENDERING_ENABLED: DWORD = 1; -pub const DWMWA_NCRENDERING_POLICY: DWORD = 2; -pub const DWMWA_TRANSITIONS_FORCEDISABLED: DWORD = 2; -pub const DWMWA_ALLOW_NCPAINT: DWORD = 4; -pub const DWMWA_CAPTION_BUTTON_BOUNDS: DWORD = 5; -pub const DWMWA_NONCLIENT_RTL_LAYOUT: DWORD = 6; -pub const DWMWA_FORCE_ICONIC_REPRESENTATION: DWORD = 7; -pub const DWMWA_FLIP3D_POLICY: DWORD = 8; -pub const DWMWA_EXTENDED_FRAME_BOUNDS: DWORD = 9; -pub const DWMWA_HAS_ICONIC_BITMAP: DWORD = 10; -pub const DWMWA_DISALLOW_PEEK: DWORD = 11; -pub const DWMWA_EXCLUDED_FROM_PEEK: DWORD = 12; -pub const DWMWA_CLOAK: DWORD = 13; -pub const DWMWA_CLOAKED: DWORD = 14; -pub const DWMWA_FREEZE_REPRESENTATION: DWORD = 15; -pub const DWMWA_LAST: DWORD = 16; +ENUM!{enum DWM_SOURCE_FRAME_SAMPLING { + DWM_SOURCE_FRAME_SAMPLING_POINT = 0, + DWM_SOURCE_FRAME_SAMPLING_COVERAGE = 1, + DWM_SOURCE_FRAME_SAMPLING_LAST = 2, +}} +// pub const c_DwmMaxQueuedBuffers: UINT = 8; +// pub const c_DwmMaxMonitors: UINT = 16; +// pub const c_DwmMaxAdapters: UINT = 16; +STRUCT!{#[repr(packed)] struct DWM_PRESENT_PARAMETERS { + cbSize: UINT32, + fQueue: BOOL, + cRefreshStart: DWM_FRAME_COUNT, + cBuffer: UINT, + fUseSourceRate: BOOL, + rateSource: UNSIGNED_RATIO, + cRefreshesPerFrame: UINT, + eSampling: DWM_SOURCE_FRAME_SAMPLING, +}} +// pub const DWM_FRAME_DURATION_DEFAULT: i32 = -1; +FN!{stdcall DwmDefWindowProc( + hWnd: HWND, + msg: UINT, + wParam: WPARAM, + lParam: LPARAM, + plResult: *mut LRESULT, +) -> BOOL} extern "system" { - // pub fn DwmDefWindowProc(); pub fn DwmEnableBlurBehindWindow( hWnd: HWND, pBlurBehind: *const DWM_BLURBEHIND, ) -> HRESULT; - // pub fn DwmEnableComposition(); - // pub fn DwmEnableMMCSS(); - // pub fn DwmExtendFrameIntoClientArea(); - // pub fn DwmGetColorizationColor(); +} +pub const DWM_EC_DISABLECOMPOSITION: UINT = 0; +pub const DWM_EC_ENABLECOMPOSITION: UINT = 1; +extern "system" { + pub fn DwmEnableComposition( + uCompositionAction: UINT, + ) -> HRESULT; + pub fn DwmEnableMMCSS( + fEnableMMCSS: BOOL, + ) -> HRESULT; + pub fn DwmExtendFrameIntoClientArea( + hWnd: HWND, + pMarInset: *const MARGINS, + ) -> HRESULT; + pub fn DwmGetColorizationColor( + pcrColorization: *mut DWORD, + pfOpaqueBlend: *mut BOOL, + ) -> HRESULT; pub fn DwmGetCompositionTimingInfo( hWnd: HWND, pTimingInfo: *mut DWM_TIMING_INFO, @@ -99,31 +177,120 @@ pvAttribute: LPVOID, cbAttribute: DWORD, ) -> HRESULT; - // pub fn DwmIsCompositionEnabled(); - // pub fn DwmModifyPreviousDxFrameDuration(); - // pub fn DwmQueryThumbnailSourceSize(); - // pub fn DwmRegisterThumbnail(); - // pub fn DwmSetDxFrameDuration(); - // pub fn DwmSetPresentParameters(); + pub fn DwmIsCompositionEnabled( + pfEnabled: *mut BOOL, + ) -> HRESULT; + pub fn DwmModifyPreviousDxFrameDuration( + hwnd: HWND, + cRefreshes: INT, + fRelative: BOOL, + ) -> HRESULT; + pub fn DwmQueryThumbnailSourceSize( + hThumbnail: HTHUMBNAIL, + pSize: PSIZE, + ) -> HRESULT; + pub fn DwmRegisterThumbnail( + hwndDestination: HWND, + hwndSource: HWND, + phThumbnailId: PHTHUMBNAIL, + ) -> HRESULT; + pub fn DwmSetDxFrameDuration( + hwnd: HWND, + cRefreshes: INT, + ) -> HRESULT; + pub fn DwmSetPresentParameters( + hwnd: HWND, + pPresentParams: *mut DWM_PRESENT_PARAMETERS, + ) -> HRESULT; pub fn DwmSetWindowAttribute( hWnd: HWND, dwAttribute: DWORD, pvAttribute: LPCVOID, cbAttribute: DWORD, ) -> HRESULT; - // pub fn DwmUnregisterThumbnail(); - // pub fn DwmUpdateThumbnailProperties(); - // pub fn DwmSetIconicThumbnail(); - // pub fn DwmSetIconicLivePreviewBitmap(); - // pub fn DwmInvalidateIconicBitmaps(); - // pub fn DwmAttachMilContent(); - // pub fn DwmDetachMilContent(); - pub fn DwmFlush(); + pub fn DwmUnregisterThumbnail( + hThumbnailId: HTHUMBNAIL, + ) -> HRESULT; + pub fn DwmUpdateThumbnailProperties( + hThumbnailId: HTHUMBNAIL, + ptnProperties: *const DWM_THUMBNAIL_PROPERTIES, + ) -> HRESULT; +} +pub const DWM_SIT_DISPLAYFRAME: DWORD = 0x00000001; +extern "system" { + pub fn DwmSetIconicThumbnail( + hwnd: HWND, + hbmp: HBITMAP, + dwSITFlags: DWORD, + ) -> HRESULT; + pub fn DwmSetIconicLivePreviewBitmap( + hwnd: HWND, + hbmp: HBITMAP, + pptClient: *mut POINT, + dwSITFlags: DWORD, + ) -> HRESULT; + pub fn DwmInvalidateIconicBitmaps( + hwnd: HWND, + ) -> HRESULT; + // pub fn DwmAttachMilContent(hwnd: HWND) -> HRESULT; + // pub fn DwmDetachMilContent(hwnd: HWND) -> HRESULT; + pub fn DwmFlush() -> HRESULT; // pub fn DwmGetGraphicsStreamTransformHint(); // pub fn DwmGetGraphicsStreamClient(); - // pub fn DwmGetTransportAttributes(); - // pub fn DwmTransitionOwnedWindow(); - // pub fn DwmRenderGesture(); - // pub fn DwmTetherContact(); - // pub fn DwmShowContact(); + pub fn DwmGetTransportAttributes( + pfIsRemoting: *mut BOOL, + pfIsConnected: *mut BOOL, + pDwGeneration: *mut DWORD, + ) -> HRESULT; +} +ENUM!{enum DWMTRANSITION_OWNEDWINDOW_TARGET { + DWMTRANSITION_OWNEDWINDOW_NULL = -1i32 as u32, + DWMTRANSITION_OWNEDWINDOW_REPOSITION = 0, +}} +extern "system" { + pub fn DwmTransitionOwnedWindow( + hwnd: HWND, + target: DWMTRANSITION_OWNEDWINDOW_TARGET, + ) -> HRESULT; +} +ENUM!{enum GESTURE_TYPE { + GT_PEN_TAP = 0, + GT_PEN_DOUBLETAP = 1, + GT_PEN_RIGHTTAP = 2, + GT_PEN_PRESSANDHOLD = 3, + GT_PEN_PRESSANDHOLDABORT = 4, + GT_TOUCH_TAP = 5, + GT_TOUCH_DOUBLETAP = 6, + GT_TOUCH_RIGHTTAP = 7, + GT_TOUCH_PRESSANDHOLD = 8, + GT_TOUCH_PRESSANDHOLDABORT = 9, + GT_TOUCH_PRESSANDTAP = 10, +}} +extern "system" { + pub fn DwmRenderGesture( + gt: GESTURE_TYPE, + cContacts: UINT, + pdwPointerID: *const DWORD, + pPoints: *const POINT, + ) -> HRESULT; + pub fn DwmTetherContact( + dwPointerID: DWORD, + fEnable: BOOL, + ptTether: POINT, + ) -> HRESULT; +} +ENUM!{enum DWM_SHOWCONTACT { + DWMSC_DOWN = 0x00000001, + DWMSC_UP = 0x00000002, + DWMSC_DRAG = 0x00000004, + DWMSC_HOLD = 0x00000008, + DWMSC_PENBARREL = 0x00000010, + DWMSC_NONE = 0x00000000, + DWMSC_ALL = 0xFFFFFFFF, +}} +extern "system" { + pub fn DwmShowContact( + dwPointerID: DWORD, + eShowContact: DWM_SHOWCONTACT, + ) -> HRESULT; } diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/dwrite_3.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/dwrite_3.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/dwrite_3.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/dwrite_3.rs 2018-12-05 01:24:41.000000000 +0000 @@ -5,9 +5,10 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. //! Mappings for the content of dwrite_3.h +use ctypes::c_void; use shared::basetsd::{UINT16, UINT32, UINT64}; use shared::minwindef::{BOOL, FILETIME, FLOAT}; -use um::dcommon::DWRITE_MEASURING_MODE; +use um::dcommon::{DWRITE_GLYPH_IMAGE_DATA, DWRITE_GLYPH_IMAGE_FORMATS, DWRITE_MEASURING_MODE}; use um::dwrite::{ DWRITE_FONT_SIMULATIONS, DWRITE_FONT_STRETCH, DWRITE_FONT_STYLE, DWRITE_FONT_WEIGHT, DWRITE_GLYPH_RUN, DWRITE_INFORMATIONAL_STRING_ID, DWRITE_LINE_SPACING_METHOD, DWRITE_MATRIX, @@ -463,3 +464,116 @@ actualLineCount: *mut UINT32, ) -> HRESULT, }} +RIDL!{#[uuid(0x27f2a904, 0x4eb8, 0x441d, 0x96, 0x78, 0x05, 0x63, 0xf5, 0x3e, 0x3e, 0x2f)] +interface IDWriteFontFace4(IDWriteFontFace4Vtbl): IDWriteFontFace3(IDWriteFontFace3Vtbl) { + fn GetGlyphImageFormats_2( + glyph: UINT16, + ppemFirst: UINT32, + ppemLast: UINT32, + formats: *mut DWRITE_GLYPH_IMAGE_FORMATS, + ) -> HRESULT, + fn GetGlyphImageFormats_1() -> DWRITE_GLYPH_IMAGE_FORMATS, + fn GetGlyphImageData( + glyph: UINT16, + ppem: UINT32, + format: DWRITE_GLYPH_IMAGE_FORMATS, + data: *mut DWRITE_GLYPH_IMAGE_DATA, + context: *mut *mut c_void, + ) -> HRESULT, + fn ReleaseGlyphImageData( + context: *mut c_void, + ) -> (), +}} +ENUM!{enum DWRITE_FONT_AXIS_TAG { + DWRITE_FONT_AXIS_TAG_WEIGHT = 0x74686777, + DWRITE_FONT_AXIS_TAG_WIDTH = 0x68746477, + DWRITE_FONT_AXIS_TAG_SLANT = 0x746e6c73, + DWRITE_FONT_AXIS_TAG_OPTICAL_SIZE = 0x7a73706f, + DWRITE_FONT_AXIS_TAG_ITALIC = 0x6c617469, +}} +STRUCT!{struct DWRITE_FONT_AXIS_VALUE { + axisTag: DWRITE_FONT_AXIS_TAG, + value: FLOAT, +}} +STRUCT!{struct DWRITE_FONT_AXIS_RANGE { + axisTag: DWRITE_FONT_AXIS_TAG, + minValue: FLOAT, + maxValue: FLOAT, +}} +ENUM!{enum DWRITE_FONT_AXIS_ATTRIBUTES { + DWRITE_FONT_AXIS_ATTRIBUTES_NONE, + DWRITE_FONT_AXIS_ATTRIBUTES_VARIABLE, + DWRITE_FONT_AXIS_ATTRIBUTES_HIDDEN, +}} +RIDL!{#[uuid(0x98eff3a5, 0xb667, 0x479a, 0xb1, 0x45, 0xe2, 0xfa, 0x5b, 0x9f, 0xdc, 0x29)] +interface IDWriteFontFace5(IDWriteFontFace5Vtbl): IDWriteFontFace4(IDWriteFontFace4Vtbl) { + fn GetFontAxisValueCount() -> UINT32, + fn GetFontAxisValues( + values: *mut DWRITE_FONT_AXIS_VALUE, + valueCount: UINT32, + ) -> HRESULT, + fn HasVariations() -> BOOL, + fn GetFontResource( + resource: *mut *mut IDWriteFontResource, + ) -> HRESULT, + fn Equals( + fontFace: *mut IDWriteFontFace, + ) -> BOOL, +}} +RIDL!{#[uuid(0xc081fe77, 0x2fd1, 0x41ac, 0xa5, 0xa3, 0x34, 0x98, 0x3c, 0x4b, 0xa6, 0x1a)] +interface IDWriteFontFaceReference1(IDWriteFontFaceReference1Vtbl): + IDWriteFontFaceReference(IDWriteFontFaceReferenceVtbl) { + fn CreateFontFace( + fontFace: *mut *mut IDWriteFontFace5, + ) -> HRESULT, + fn GetFontAxisValueCount() -> UINT32, + fn GetFontAxisValues( + values: *mut DWRITE_FONT_AXIS_VALUE, + numValues: UINT32, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x1f803a76, 0x6871, 0x48e8, 0x98, 0x7f, 0xb9, 0x75, 0x55, 0x1c, 0x50, 0xf2)] +interface IDWriteFontResource(IDWriteFontResourceVtbl): IUnknown(IUnknownVtbl) { + fn GetFontFile( + fontFile: *mut *mut IDWriteFontFile, + ) -> HRESULT, + fn GetFontFaceIndex() -> UINT32, + fn GetFontAxisCount() -> UINT32, + fn GetDefaultFontAxisValues( + values: *const DWRITE_FONT_AXIS_VALUE, + numValues: UINT32, + ) -> HRESULT, + fn GetFontAxisRanges( + ranges: *const DWRITE_FONT_AXIS_RANGE, + numRanges: UINT32, + ) -> HRESULT, + fn GetFontAxisAttributes( + axis: UINT32, + ) -> DWRITE_FONT_AXIS_ATTRIBUTES, + fn GetAxisNames( + axis: UINT32, + names: *mut *mut IDWriteLocalizedStrings, + ) -> HRESULT, + fn GetAxisValueNameCount( + axis: UINT32, + ) -> UINT32, + fn GetAxisValueNames( + axis: UINT32, + axisValue: UINT32, + axisRange: *mut DWRITE_FONT_AXIS_RANGE, + names: *mut *mut IDWriteLocalizedStrings, + ) -> HRESULT, + fn HasVariations() -> BOOL, + fn CreateFontFace( + simulations: DWRITE_FONT_SIMULATIONS, + axisValues: *const DWRITE_FONT_AXIS_VALUE, + numValues: UINT32, + fontFace: *mut *mut IDWriteFontFace5, + ) -> HRESULT, + fn CreateFontFaceReference( + simulations: DWRITE_FONT_SIMULATIONS, + axisValues: *const DWRITE_FONT_AXIS_VALUE, + numValues: UINT32, + reference: *mut *mut IDWriteFontFaceReference1, + ) -> HRESULT, +}} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/dxgidebug.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/dxgidebug.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/dxgidebug.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/dxgidebug.rs 2018-12-05 01:24:41.000000000 +0000 @@ -10,7 +10,6 @@ use shared::minwindef::{BOOL, DWORD, UINT}; use um::unknwnbase::{IUnknown, IUnknownVtbl}; use um::winnt::{HRESULT, LPCSTR}; - pub const DXGI_DEBUG_BINARY_VERSION: DWORD = 1; ENUM!{enum DXGI_DEBUG_RLO_FLAGS { DXGI_DEBUG_RLO_SUMMARY = 0x1, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/endpointvolume.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/endpointvolume.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/endpointvolume.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/endpointvolume.rs 2018-12-05 01:24:42.000000000 +0000 @@ -21,14 +21,13 @@ pub const ENDPOINT_HARDWARE_SUPPORT_VOLUME: DWORD = 0x00000001; pub const ENDPOINT_HARDWARE_SUPPORT_MUTE: DWORD = 0x00000002; pub const ENDPOINT_HARDWARE_SUPPORT_METER: DWORD = 0x00000004; -RIDL!(#[uuid(0x657804fa, 0xd6ad, 0x4496, 0x8a, 0x60, 0x35, 0x27, 0x52, 0xaf, 0x4f, 0x89)] +RIDL!{#[uuid(0x657804fa, 0xd6ad, 0x4496, 0x8a, 0x60, 0x35, 0x27, 0x52, 0xaf, 0x4f, 0x89)] interface IAudioEndpointVolumeCallback(IAudioEndpointVolumeCallbackVtbl): IUnknown(IUnknownVtbl) { fn OnNotify( pNotify: PAUDIO_VOLUME_NOTIFICATION_DATA, ) -> HRESULT, -} -); -RIDL!(#[uuid(0x5cdf2c82, 0x841e, 0x4546, 0x97, 0x22, 0x0c, 0xf7, 0x40, 0x78, 0x22, 0x9a)] +}} +RIDL!{#[uuid(0x5cdf2c82, 0x841e, 0x4546, 0x97, 0x22, 0x0c, 0xf7, 0x40, 0x78, 0x22, 0x9a)] interface IAudioEndpointVolume(IAudioEndpointVolumeVtbl): IUnknown(IUnknownVtbl) { fn RegisterControlChangeNotify( pNotify: *mut IAudioEndpointVolumeCallback, @@ -96,9 +95,8 @@ pflVolumeMaxdB: *mut c_float, pflVolumeIncrementdB: *mut c_float, ) -> HRESULT, -} -); -RIDL!(#[uuid(0x66e11784, 0xf695, 0x4f28, 0xa5, 0x05, 0xa7, 0x08, 0x00, 0x81, 0xa7, 0x8f)] +}} +RIDL!{#[uuid(0x66e11784, 0xf695, 0x4f28, 0xa5, 0x05, 0xa7, 0x08, 0x00, 0x81, 0xa7, 0x8f)] interface IAudioEndpointVolumeEx(IAudioEndpointVolumeExVtbl): IAudioEndpointVolume(IAudioEndpointVolumeVtbl) { fn GetVolumeRangeChannel( @@ -107,9 +105,8 @@ pflVolumeMaxdB: *mut c_float, pflVolumeIncrementdB: *mut c_float, ) -> HRESULT, -} -); -RIDL!(#[uuid(0xc02216f6, 0x8c67, 0x4b5b, 0x9d, 0x00, 0xd0, 0x08, 0xe7, 0x3e, 0x00, 0x64)] +}} +RIDL!{#[uuid(0xc02216f6, 0x8c67, 0x4b5b, 0x9d, 0x00, 0xd0, 0x08, 0xe7, 0x3e, 0x00, 0x64)] interface IAudioMeterInformation(IAudioMeterInformationVtbl): IUnknown(IUnknownVtbl) { fn GetPeakValue( pfPeak: *mut c_float, @@ -124,5 +121,4 @@ fn QueryHardwareSupport( pdwHardwareSupportMask: *mut DWORD, ) -> HRESULT, -} -); +}} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/evntcons.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/evntcons.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/evntcons.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/evntcons.rs 2018-12-05 01:24:41.000000000 +0000 @@ -26,18 +26,18 @@ pub const EVENT_HEADER_EXT_TYPE_CONTROL_GUID: USHORT = 0x000E; pub const EVENT_HEADER_EXT_TYPE_MAX: USHORT = 0x000F; STRUCT!{struct EVENT_HEADER_EXTENDED_DATA_ITEM_s { - bitfield: USHORT, + bitfield: USHORT, }} BITFIELD!{EVENT_HEADER_EXTENDED_DATA_ITEM_s bitfield: USHORT [ Linkage set_Linkage[0..1], Reserved2 set_Reserved2[1..16], ]} STRUCT!{struct EVENT_HEADER_EXTENDED_DATA_ITEM { - Reserved1: USHORT, - ExtType: USHORT, - s: EVENT_HEADER_EXTENDED_DATA_ITEM_s, - DataSize: USHORT, - DataPtr: ULONGLONG, + Reserved1: USHORT, + ExtType: USHORT, + s: EVENT_HEADER_EXTENDED_DATA_ITEM_s, + DataSize: USHORT, + DataPtr: ULONGLONG, }} pub type PEVENT_HEADER_EXTENDED_DATA_ITEM = *mut EVENT_HEADER_EXTENDED_DATA_ITEM; STRUCT!{struct EVENT_EXTENDED_ITEM_INSTANCE { @@ -165,44 +165,41 @@ #[inline] unsafe fn read_unaligned(src: *const T) -> T { use core::{mem, ptr}; - let mut tmp: T = mem::uninitialized(); - ptr::copy_nonoverlapping(src as *const u8, - &mut tmp as *mut T as *mut u8, - mem::size_of::()); + ptr::copy_nonoverlapping( + src as *const u8, + &mut tmp as *mut T as *mut u8, + mem::size_of::(), + ); tmp } #[inline] pub unsafe fn EtwGetTraitFromProviderTraits( - ProviderTraits: PVOID, TraitType: UCHAR, Trait: *mut PVOID, Size: PUSHORT, + ProviderTraits: PVOID, TraitType: UCHAR, Trait: *mut PVOID, Size: PUSHORT, ) { use core::ptr::null_mut; - + let ByteCount = read_unaligned(ProviderTraits as *mut USHORT) as isize; let mut Ptr = ProviderTraits as PUCHAR; let PtrEnd = Ptr.offset(ByteCount); *Trait = null_mut(); *Size = 0; if ByteCount < 3 { - return; + return; } - Ptr = Ptr.offset(2); Ptr = Ptr.offset(strnlen(Ptr as PCSTR, (ByteCount - 3) as isize)); Ptr = Ptr.offset(1); - while Ptr < PtrEnd { let TraitByteCount = read_unaligned(Ptr as *const USHORT); if TraitByteCount < 3 { return; } - if *Ptr.offset(2) == TraitType && Ptr.offset(TraitByteCount as isize) <= PtrEnd { *Trait = Ptr.offset(3) as PVOID; *Size = TraitByteCount - 3; return; } - Ptr = Ptr.offset(TraitByteCount as isize); } } diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/exdisp.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/exdisp.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/exdisp.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/exdisp.rs 2018-12-05 01:24:41.000000000 +0000 @@ -0,0 +1,221 @@ +// Copyright © 2017 winapi-rs developers +// Licensed under the Apache License, Version 2.0 +// or the MIT license +// , at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! Mappings for the contents of ExDisp.h +use shared::basetsd::SHANDLE_PTR; +use shared::wtypes::{BSTR, VARIANT_BOOL}; +use um::docobj::{OLECMDEXECOPT, OLECMDF, OLECMDID}; +use um::oaidl::{IDispatch, IDispatchVtbl, VARIANT}; +use um::ocidl::READYSTATE; +use um::winnt::{HRESULT, INT, LONG}; +DEFINE_GUID!{IID_IWebBrowser2, + 0xd30c1661, 0xcdaf, 0x11d0, 0x8a, 0x3e, 0x00, 0xc0, 0x4f, 0xc9, 0xe2, 0x6e} +RIDL!{#[uuid(0xeab22ac1, 0x30c1, 0x11cf, 0xa7, 0xeb, 0x00, 0x00, 0xc0, 0x5b, 0xae, 0x0b)] +interface IWebBrowser(IWebBrowserVtbl): IDispatch(IDispatchVtbl) { + fn GoBack() -> HRESULT, + fn GoForward() -> HRESULT, + fn GoHome() -> HRESULT, + fn GoSearch() -> HRESULT, + fn Navigate( + URL: BSTR, + Flags: *const VARIANT, + TargetFrameName: *const VARIANT, + PostData: *const VARIANT, + Headers: *const VARIANT, + ) -> HRESULT, + fn Refresh() -> HRESULT, + fn Refresh2( + Level: *const VARIANT, + ) -> HRESULT, + fn Stop() -> HRESULT, + fn get_Application( + ppDisp: *mut *mut IDispatch, + ) -> HRESULT, + fn get_Parent( + ppDisp: *mut *mut IDispatch, + ) -> HRESULT, + fn get_Container( + ppDisp: *mut *mut IDispatch, + ) -> HRESULT, + fn get_Document( + ppDisp: *mut *mut IDispatch, + ) -> HRESULT, + fn get_TopLevelContainer( + pBool: *mut VARIANT_BOOL, + ) -> HRESULT, + fn get_Type( + Type: *mut BSTR, + ) -> HRESULT, + fn get_Left( + pl: *mut LONG, + ) -> HRESULT, + fn put_Left( + Left: LONG, + ) -> HRESULT, + fn get_Top( + pl: *mut LONG, + ) -> HRESULT, + fn put_Top( + Top: LONG, + ) -> HRESULT, + fn get_Width( + pl: *mut LONG, + ) -> HRESULT, + fn put_Width( + Width: LONG, + ) -> HRESULT, + fn get_Height( + pl: *mut LONG, + ) -> HRESULT, + fn put_Height( + Height: LONG, + ) -> HRESULT, + fn get_LocationName( + LocationName: *mut BSTR, + ) -> HRESULT, + fn get_LocationURL( + LocationURL: *mut BSTR, + ) -> HRESULT, + fn get_Busy( + pBool: *mut VARIANT_BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0x0002df05, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IWebBrowserApp(IWebBrowserAppVtbl): IWebBrowser(IWebBrowserVtbl) { + fn Quit() -> HRESULT, + fn ClientToWindow( + pcx: *mut INT, + pcy: *mut INT, + ) -> HRESULT, + fn PutProperty( + Property: BSTR, + vtValue: VARIANT, + ) -> HRESULT, + fn GetProperty( + Property: BSTR, + pvtValue: *mut VARIANT, + ) -> HRESULT, + fn get_Name( + Name: *mut BSTR, + ) -> HRESULT, + fn get_HWND( + pHWND: *mut SHANDLE_PTR, + ) -> HRESULT, + fn get_FullName( + FullName: *mut BSTR, + ) -> HRESULT, + fn get_Path( + Path: *mut BSTR, + ) -> HRESULT, + fn get_Visible( + pBool: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_Visible( + Value: VARIANT_BOOL, + ) -> HRESULT, + fn get_StatusBar( + pBool: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_StatusBar( + Value: VARIANT_BOOL, + ) -> HRESULT, + fn get_StatusText( + StatusText: *mut BSTR, + ) -> HRESULT, + fn put_StatusText( + StatusText: BSTR, + ) -> HRESULT, + fn get_ToolBar( + Value: *mut INT, + ) -> HRESULT, + fn put_ToolBar( + Value: INT, + ) -> HRESULT, + fn get_MenuBar( + Value: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_MenuBar( + Value: VARIANT_BOOL, + ) -> HRESULT, + fn get_FullScreen( + pbFullScreen: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_FullScreen( + bFullScreen: VARIANT_BOOL, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xd30c1661, 0xcdaf, 0x11d0, 0x8a, 0x3e, 0x00, 0xc0, 0x4f, 0xc9, 0xe2, 0x6e)] +interface IWebBrowser2(IWebBrowser2Vtbl): IWebBrowserApp(IWebBrowserAppVtbl) { + fn Navigate2( + URL: *const VARIANT, + Flags: *const VARIANT, + TargetFrameName: *const VARIANT, + PostData: *const VARIANT, + Headers: *const VARIANT, + ) -> HRESULT, + fn QueryStatusWB( + cmdID: OLECMDID, + pcmdf: *mut OLECMDF, + ) -> HRESULT, + fn ExecWB( + cmdID: OLECMDID, + cmdexecopt: OLECMDEXECOPT, + pvaIn: *const VARIANT, + pvaOut: *mut VARIANT, + ) -> HRESULT, + fn ShowBrowserBar( + pvaClsid: *const VARIANT, + pvarShow: *const VARIANT, + pvarSize: *const VARIANT, + ) -> HRESULT, + fn get_ReadyState( + plReadyState: *mut READYSTATE, + ) -> HRESULT, + fn get_Offline( + pbOffline: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_Offline( + bOffline: VARIANT_BOOL, + ) -> HRESULT, + fn get_Silent( + pbSilent: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_Silent( + bSilent: VARIANT_BOOL, + ) -> HRESULT, + fn get_RegisterAsBrowser( + pbRegister: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_RegisterAsBrowser( + bRegister: VARIANT_BOOL, + ) -> HRESULT, + fn get_RegisterAsDropTarget( + pbRegister: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_RegisterAsDropTarget( + bRegister: VARIANT_BOOL, + ) -> HRESULT, + fn get_TheaterMode( + pbRegister: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_TheaterMode( + bRegister: VARIANT_BOOL, + ) -> HRESULT, + fn get_AddressBar( + Value: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_AddressBar( + Value: VARIANT_BOOL, + ) -> HRESULT, + fn get_Resizable( + Value: *mut VARIANT_BOOL, + ) -> HRESULT, + fn put_Resizable( + Value: VARIANT_BOOL, + ) -> HRESULT, +}} +DEFINE_GUID!{CLSID_InternetExplorer, + 0x0002df01, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/fibersapi.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/fibersapi.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/fibersapi.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/fibersapi.rs 2018-12-05 01:24:41.000000000 +0000 @@ -22,4 +22,3 @@ ) -> BOOL; pub fn IsThreadAFiber() -> BOOL; } - diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/http.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/http.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/http.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/http.rs 2018-12-05 01:24:41.000000000 +0000 @@ -35,9 +35,9 @@ STRUCT!{struct HTTP_PROPERTY_FLAGS { BitFields: ULONG, }} -BITFIELD!(HTTP_PROPERTY_FLAGS BitFields: ULONG [ +BITFIELD!{HTTP_PROPERTY_FLAGS BitFields: ULONG [ Present set_Present[0..1], -]); +]} pub type PHTTP_PROPERTY_FLAGS = *mut HTTP_PROPERTY_FLAGS; ENUM!{enum HTTP_ENABLED_STATE { HttpEnabledStateActive, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/imm.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/imm.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/imm.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/imm.rs 2018-12-05 01:24:41.000000000 +0000 @@ -13,7 +13,7 @@ ptCurrentPos: POINT, rcArea: RECT, }} -DECLARE_HANDLE!(HIMC, HIMC__); +DECLARE_HANDLE!{HIMC, HIMC__} pub type LPCOMPOSITIONFORM = *mut COMPOSITIONFORM; extern "system" { pub fn ImmGetContext( diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/ioapiset.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/ioapiset.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/ioapiset.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/ioapiset.rs 2018-12-05 01:24:42.000000000 +0000 @@ -7,7 +7,7 @@ use shared::basetsd::{PULONG_PTR, ULONG_PTR}; use shared::minwindef::{BOOL, DWORD, LPDWORD, LPVOID, PULONG, ULONG}; use um::minwinbase::{LPOVERLAPPED, LPOVERLAPPED_ENTRY}; -use um::winnt::{HANDLE}; +use um::winnt::HANDLE; extern "system" { pub fn CreateIoCompletionPort( FileHandle: HANDLE, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/jobapi.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/jobapi.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/jobapi.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/jobapi.rs 2018-12-05 01:24:41.000000000 +0000 @@ -13,4 +13,3 @@ Result: PBOOL, ) -> BOOL; } - diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/lmaccess.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/lmaccess.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/lmaccess.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/lmaccess.rs 2018-12-05 01:24:41.000000000 +0000 @@ -1157,8 +1157,8 @@ pub const SERVICE_ACCOUNT_PASSWORD: &'static str = "_SA_{262E99C9-6160-4871-ACEC-4E61736B6F21}"; pub const SERVICE_ACCOUNT_SECRET_PREFIX: &'static str = "_SC_{262E99C9-6160-4871-ACEC-4E61736B6F21}_"; -DEFINE_GUID!(ServiceAccountPasswordGUID, - 0x262E99C9, 0x6160, 0x4871, 0xAC, 0xEC, 0x4E, 0x61, 0x73, 0x6B, 0x6F, 0x21); +DEFINE_GUID!{ServiceAccountPasswordGUID, + 0x262E99C9, 0x6160, 0x4871, 0xAC, 0xEC, 0x4E, 0x61, 0x73, 0x6B, 0x6F, 0x21} extern "system" { pub fn NetAddServiceAccount( ServerName: LPWSTR, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/lmsvc.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/lmsvc.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/lmsvc.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/lmsvc.rs 2018-12-05 01:24:42.000000000 +0000 @@ -5,7 +5,7 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms //! This file contains structures, function prototypes, and definitions for the NetService API -use ctypes::{c_long}; +use ctypes::c_long; use shared::lmcons::NET_API_STATUS; use shared::minwindef::{DWORD, LPBYTE, LPDWORD}; use um::winnt::{LPCWSTR, LPWSTR}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/lsalookup.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/lsalookup.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/lsalookup.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/lsalookup.rs 2018-12-05 01:24:41.000000000 +0000 @@ -5,7 +5,7 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. //! LSA Policy Lookup API -use shared::guiddef::{GUID}; +use shared::guiddef::GUID; use shared::minwindef::{ULONG, USHORT}; use shared::ntdef::NTSTATUS; use um::winnt::{ACCESS_MASK, HANDLE, LONG, PCHAR, PSID, PVOID, PWSTR, SID_NAME_USE}; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/mmdeviceapi.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/mmdeviceapi.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/mmdeviceapi.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/mmdeviceapi.rs 2018-12-05 01:24:41.000000000 +0000 @@ -21,40 +21,40 @@ pub const DEVICE_STATE_NOTPRESENT: DWORD = 0x00000004; pub const DEVICE_STATE_UNPLUGGED: DWORD = 0x00000008; pub const DEVICE_STATEMASK_ALL: DWORD = 0x0000000F; -DEFINE_PROPERTYKEY!(PKEY_AudioEndpoint_FormFactor, - 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 0); -DEFINE_PROPERTYKEY!(PKEY_AudioEndpoint_ControlPanelPageProvider, - 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 1); -DEFINE_PROPERTYKEY!(PKEY_AudioEndpoint_Association, - 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 2); -DEFINE_PROPERTYKEY!(PKEY_AudioEndpoint_PhysicalSpeakers, - 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 3); -DEFINE_PROPERTYKEY!(PKEY_AudioEndpoint_GUID, - 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 4); -DEFINE_PROPERTYKEY!(PKEY_AudioEndpoint_Disable_SysFx, - 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 5); +DEFINE_PROPERTYKEY!{PKEY_AudioEndpoint_FormFactor, + 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 0} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpoint_ControlPanelPageProvider, + 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 1} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpoint_Association, + 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 2} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpoint_PhysicalSpeakers, + 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 3} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpoint_GUID, + 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 4} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpoint_Disable_SysFx, + 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 5} pub const ENDPOINT_SYSFX_ENABLED: DWORD = 0x00000000; pub const ENDPOINT_SYSFX_DISABLED: DWORD = 0x00000001; -DEFINE_PROPERTYKEY!(PKEY_AudioEndpoint_FullRangeSpeakers, - 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 6); -DEFINE_PROPERTYKEY!(PKEY_AudioEndpoint_Supports_EventDriven_Mode, - 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 7); -DEFINE_PROPERTYKEY!(PKEY_AudioEndpoint_JackSubType, - 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 8); -DEFINE_PROPERTYKEY!(PKEY_AudioEndpoint_Default_VolumeInDb, - 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 9); -DEFINE_PROPERTYKEY!(PKEY_AudioEngine_DeviceFormat, - 0xf19f064d, 0x82c, 0x4e27, 0xbc, 0x73, 0x68, 0x82, 0xa1, 0xbb, 0x8e, 0x4c, 0); -DEFINE_PROPERTYKEY!(PKEY_AudioEngine_OEMFormat, - 0xe4870e26, 0x3cc5, 0x4cd2, 0xba, 0x46, 0xca, 0xa, 0x9a, 0x70, 0xed, 0x4, 3); -DEFINE_PROPERTYKEY!(PKEY_AudioEndpointLogo_IconEffects, - 0xf1ab780d, 0x2010, 0x4ed3, 0xa3, 0xa6, 0x8b, 0x87, 0xf0, 0xf0, 0xc4, 0x76, 0); -DEFINE_PROPERTYKEY!(PKEY_AudioEndpointLogo_IconPath, - 0xf1ab780d, 0x2010, 0x4ed3, 0xa3, 0xa6, 0x8b, 0x87, 0xf0, 0xf0, 0xc4, 0x76, 1); -DEFINE_PROPERTYKEY!(PKEY_AudioEndpointSettings_MenuText, - 0x14242002, 0x0320, 0x4de4, 0x95, 0x55, 0xa7, 0xd8, 0x2b, 0x73, 0xc2, 0x86, 0); -DEFINE_PROPERTYKEY!(PKEY_AudioEndpointSettings_LaunchContract, - 0x14242002, 0x0320, 0x4de4, 0x95, 0x55, 0xa7, 0xd8, 0x2b, 0x73, 0xc2, 0x86, 1); +DEFINE_PROPERTYKEY!{PKEY_AudioEndpoint_FullRangeSpeakers, + 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 6} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpoint_Supports_EventDriven_Mode, + 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 7} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpoint_JackSubType, + 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 8} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpoint_Default_VolumeInDb, + 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x23, 0xe0, 0xc0, 0xff, 0xee, 0x7f, 0x0e, 9} +DEFINE_PROPERTYKEY!{PKEY_AudioEngine_DeviceFormat, + 0xf19f064d, 0x82c, 0x4e27, 0xbc, 0x73, 0x68, 0x82, 0xa1, 0xbb, 0x8e, 0x4c, 0} +DEFINE_PROPERTYKEY!{PKEY_AudioEngine_OEMFormat, + 0xe4870e26, 0x3cc5, 0x4cd2, 0xba, 0x46, 0xca, 0xa, 0x9a, 0x70, 0xed, 0x4, 3} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpointLogo_IconEffects, + 0xf1ab780d, 0x2010, 0x4ed3, 0xa3, 0xa6, 0x8b, 0x87, 0xf0, 0xf0, 0xc4, 0x76, 0} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpointLogo_IconPath, + 0xf1ab780d, 0x2010, 0x4ed3, 0xa3, 0xa6, 0x8b, 0x87, 0xf0, 0xf0, 0xc4, 0x76, 1} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpointSettings_MenuText, + 0x14242002, 0x0320, 0x4de4, 0x95, 0x55, 0xa7, 0xd8, 0x2b, 0x73, 0xc2, 0x86, 0} +DEFINE_PROPERTYKEY!{PKEY_AudioEndpointSettings_LaunchContract, + 0x14242002, 0x0320, 0x4de4, 0x95, 0x55, 0xa7, 0xd8, 0x2b, 0x73, 0xc2, 0x86, 1} STRUCT!{struct DIRECTX_AUDIO_ACTIVATION_PARAMS { cbDirectXAudioActivationParams: DWORD, guidAudioSession: GUID, @@ -88,15 +88,15 @@ EndpointFormFactor_enum_count, }} pub const HDMI: EndpointFormFactor = DigitalAudioDisplayDevice; -DEFINE_GUID!(DEVINTERFACE_AUDIO_RENDER, - 0xe6327cad, 0xdcec, 0x4949, 0xae, 0x8a, 0x99, 0x1e, 0x97, 0x6a, 0x79, 0xd2); -DEFINE_GUID!(DEVINTERFACE_AUDIO_CAPTURE, - 0x2eef81be, 0x33fa, 0x4800, 0x96, 0x70, 0x1c, 0xd4, 0x74, 0x97, 0x2c, 0x3f); -DEFINE_GUID!(DEVINTERFACE_MIDI_OUTPUT, - 0x6dc23320, 0xab33, 0x4ce4, 0x80, 0xd4, 0xbb, 0xb3, 0xeb, 0xbf, 0x28, 0x14); -DEFINE_GUID!(DEVINTERFACE_MIDI_INPUT, - 0x504be32c, 0xccf6, 0x4d2c, 0xb7, 0x3f, 0x6f, 0x8b, 0x37, 0x47, 0xe2, 0x2b); -RIDL!(#[uuid(0x7991eec9, 0x7e89, 0x4d85, 0x83, 0x90, 0x6c, 0x70, 0x3c, 0xec, 0x60, 0xc0)] +DEFINE_GUID!{DEVINTERFACE_AUDIO_RENDER, + 0xe6327cad, 0xdcec, 0x4949, 0xae, 0x8a, 0x99, 0x1e, 0x97, 0x6a, 0x79, 0xd2} +DEFINE_GUID!{DEVINTERFACE_AUDIO_CAPTURE, + 0x2eef81be, 0x33fa, 0x4800, 0x96, 0x70, 0x1c, 0xd4, 0x74, 0x97, 0x2c, 0x3f} +DEFINE_GUID!{DEVINTERFACE_MIDI_OUTPUT, + 0x6dc23320, 0xab33, 0x4ce4, 0x80, 0xd4, 0xbb, 0xb3, 0xeb, 0xbf, 0x28, 0x14} +DEFINE_GUID!{DEVINTERFACE_MIDI_INPUT, + 0x504be32c, 0xccf6, 0x4d2c, 0xb7, 0x3f, 0x6f, 0x8b, 0x37, 0x47, 0xe2, 0x2b} +RIDL!{#[uuid(0x7991eec9, 0x7e89, 0x4d85, 0x83, 0x90, 0x6c, 0x70, 0x3c, 0xec, 0x60, 0xc0)] interface IMMNotificationClient(IMMNotificationClientVtbl): IUnknown(IUnknownVtbl) { fn OnDeviceStateChanged( pwstrDeviceId: LPCWSTR, @@ -117,9 +117,8 @@ pwstrDeviceId: LPCWSTR, key: PROPERTYKEY, ) -> HRESULT, -} -); -RIDL!(#[uuid(0xd666063f, 0x1587, 0x4e43, 0x81, 0xf1, 0xb9, 0x48, 0xe8, 0x07, 0x36, 0x3f)] +}} +RIDL!{#[uuid(0xd666063f, 0x1587, 0x4e43, 0x81, 0xf1, 0xb9, 0x48, 0xe8, 0x07, 0x36, 0x3f)] interface IMMDevice(IMMDeviceVtbl): IUnknown(IUnknownVtbl) { fn Activate( iid: REFIID, @@ -137,9 +136,8 @@ fn GetState( pdwState: *mut DWORD, ) -> HRESULT, -} -); -RIDL!(#[uuid(0x0bd7a1be, 0x7a1a, 0x44db, 0x83, 0x97, 0xcc, 0x53, 0x92, 0x38, 0x7b, 0x5e)] +}} +RIDL!{#[uuid(0x0bd7a1be, 0x7a1a, 0x44db, 0x83, 0x97, 0xcc, 0x53, 0x92, 0x38, 0x7b, 0x5e)] interface IMMDeviceCollection(IMMDeviceCollectionVtbl): IUnknown(IUnknownVtbl) { fn GetCount( pcDevices: *const UINT, @@ -148,16 +146,14 @@ nDevice: UINT, ppDevice: *mut *mut IMMDevice, ) -> HRESULT, -} -); -RIDL!(#[uuid(0x1be09788, 0x6894, 0x4089, 0x85, 0x86, 0x9a, 0x2a, 0x6c, 0x26, 0x5a, 0xc5)] +}} +RIDL!{#[uuid(0x1be09788, 0x6894, 0x4089, 0x85, 0x86, 0x9a, 0x2a, 0x6c, 0x26, 0x5a, 0xc5)] interface IMMEndpoint(IMMEndpointVtbl): IUnknown(IUnknownVtbl) { fn GetDataFlow( pDataFlow: *mut EDataFlow, ) -> HRESULT, -} -); -RIDL!(#[uuid(0xa95664d2, 0x9614, 0x4f35, 0xa7, 0x46, 0xde, 0x8d, 0xb6, 0x36, 0x17, 0xe6)] +}} +RIDL!{#[uuid(0xa95664d2, 0x9614, 0x4f35, 0xa7, 0x46, 0xde, 0x8d, 0xb6, 0x36, 0x17, 0xe6)] interface IMMDeviceEnumerator(IMMDeviceEnumeratorVtbl): IUnknown(IUnknownVtbl) { fn EnumAudioEndpoints( dataFlow: EDataFlow, @@ -179,9 +175,8 @@ fn UnregisterEndpointNotificationCallback( pClient: *mut IMMNotificationClient, ) -> HRESULT, -} -); -RIDL!(#[uuid(0x3b0d0ea4, 0xd0a9, 0x4b0e, 0x93, 0x5b, 0x09, 0x51, 0x67, 0x46, 0xfa, 0xc0)] +}} +RIDL!{#[uuid(0x3b0d0ea4, 0xd0a9, 0x4b0e, 0x93, 0x5b, 0x09, 0x51, 0x67, 0x46, 0xfa, 0xc0)] interface IMMDeviceActivator(IMMDeviceActivatorVtbl): IUnknown(IUnknownVtbl) { fn Activate( iid: REFIID, @@ -189,25 +184,22 @@ pActivationParams: *mut PROPVARIANT, ppInterface: *mut *mut c_void, ) -> HRESULT, -} -); -RIDL!(#[uuid(0x41d949ab, 0x9862, 0x444a, 0x80, 0xf6, 0xc2, 0x61, 0x33, 0x4d, 0xa5, 0xeb)] +}} +RIDL!{#[uuid(0x41d949ab, 0x9862, 0x444a, 0x80, 0xf6, 0xc2, 0x61, 0x33, 0x4d, 0xa5, 0xeb)] interface IActivateAudioInterfaceCompletionHandler(IActivateAudioInterfaceCompletionHandlerVtbl): IUnknown(IUnknownVtbl) { fn ActivateCompleted( activateOperation: *mut IActivateAudioInterfaceAsyncOperation, ) -> HRESULT, -} -); -RIDL!(#[uuid(0x72a22d78, 0xcde4, 0x431d, 0xb8, 0xcc, 0x84, 0x3a, 0x71, 0x19, 0x9b, 0x6d)] +}} +RIDL!{#[uuid(0x72a22d78, 0xcde4, 0x431d, 0xb8, 0xcc, 0x84, 0x3a, 0x71, 0x19, 0x9b, 0x6d)] interface IActivateAudioInterfaceAsyncOperation(IActivateAudioInterfaceAsyncOperationVtbl): IUnknown(IUnknownVtbl) { fn GetActivateResult( activateResult: *mut HRESULT, activatedInterface: *mut *mut IUnknown, ) -> HRESULT, -} -); +}} extern "system" { pub fn ActivateAudioInterfaceAsync( deviceInterfacePath: LPCWSTR, @@ -223,5 +215,5 @@ pPnpInterface: *mut IMMDevice, pPnpDevnode: *mut IMMDevice, }} -DEFINE_GUID!(CLSID_MMDeviceEnumerator, 0xBCDE0395, 0xE52F, 0x467C, - 0x8E, 0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E); +DEFINE_GUID!{CLSID_MMDeviceEnumerator, + 0xBCDE0395, 0xE52F, 0x467C, 0x8E, 0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/mmsystem.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/mmsystem.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/mmsystem.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/mmsystem.rs 2018-12-05 01:24:41.000000000 +0000 @@ -122,8 +122,8 @@ pub const WAVERR_UNPREPARED: MMRESULT = WAVERR_BASE + 2; pub const WAVERR_SYNC: MMRESULT = WAVERR_BASE + 3; pub const WAVERR_LASTERROR: MMRESULT = WAVERR_BASE + 3; -DECLARE_HANDLE!(HWAVEIN, HWAVEIN__); -DECLARE_HANDLE!(HWAVEOUT, HWAVEOUT__); +DECLARE_HANDLE!{HWAVEIN, HWAVEIN__} +DECLARE_HANDLE!{HWAVEOUT, HWAVEOUT__} pub type LPHWAVEIN = *mut HWAVEIN; pub type LPHWAVEOUT = *mut HWAVEOUT; pub const WOM_OPEN: UINT = MM_WOM_OPEN; @@ -257,11 +257,11 @@ pub type PMIDIOUTCAPSW = *mut MIDIOUTCAPSW; pub type NPMIDIOUTCAPSW = *mut MIDIOUTCAPSW; pub type LPMIDIOUTCAPSW = *mut MIDIOUTCAPSW; -DECLARE_HANDLE!(HMIDIIN, HMIDIIN__); -DECLARE_HANDLE!(HMIDIOUT, HMIDIOUT__); +DECLARE_HANDLE!{HMIDIIN, HMIDIIN__} +DECLARE_HANDLE!{HMIDIOUT, HMIDIOUT__} pub type LPHMIDIIN = *mut HMIDIIN; pub type LPHMIDIOUT = *mut HMIDIOUT; -DECLARE_HANDLE!(HMIDISTRM, HMIDISTRM__); -DECLARE_HANDLE!(HMIDI, HMIDI__); +DECLARE_HANDLE!{HMIDISTRM, HMIDISTRM__} +DECLARE_HANDLE!{HMIDI, HMIDI__} pub type LPHMIDISTRM = *mut HMIDISTRM; pub type LPHMIDI = *mut HMIDI; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/mod.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/mod.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/mod.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/mod.rs 2018-12-05 01:24:41.000000000 +0000 @@ -58,6 +58,7 @@ #[cfg(feature = "d3d11on12")] pub mod d3d11on12; #[cfg(feature = "d3d11sdklayers")] pub mod d3d11sdklayers; #[cfg(feature = "d3d11shader")] pub mod d3d11shader; +#[cfg(feature = "d3d11tokenizedprogramformat")] pub mod d3d11tokenizedprogramformat; #[cfg(feature = "d3d12")] pub mod d3d12; #[cfg(feature = "d3d12sdklayers")] pub mod d3d12sdklayers; #[cfg(feature = "d3d12shader")] pub mod d3d12shader; @@ -70,6 +71,7 @@ #[cfg(feature = "datetimeapi")] pub mod datetimeapi; #[cfg(feature = "davclnt")] pub mod davclnt; #[cfg(feature = "dbghelp")] pub mod dbghelp; +#[cfg(feature = "dbt")] pub mod dbt; #[cfg(feature = "dcommon")] pub mod dcommon; #[cfg(feature = "dcomp")] pub mod dcomp; #[cfg(feature = "dcompanimation")] pub mod dcompanimation; @@ -78,6 +80,7 @@ #[cfg(feature = "ddrawi")] pub mod ddrawi; #[cfg(feature = "ddrawint")] pub mod ddrawint; #[cfg(feature = "debugapi")] pub mod debugapi; +#[cfg(feature = "devicetopology")] pub mod devicetopology; #[cfg(feature = "dinput")] pub mod dinput; #[cfg(feature = "dmksctl")] pub mod dmksctl; #[cfg(feature = "dmusicc")] pub mod dmusicc; @@ -102,6 +105,7 @@ #[cfg(feature = "endpointvolume")] pub mod endpointvolume; #[cfg(feature = "errhandlingapi")] pub mod errhandlingapi; #[cfg(feature = "evntcons")] pub mod evntcons; +#[cfg(feature = "exdisp")] pub mod exdisp; #[cfg(feature = "fibersapi")] pub mod fibersapi; #[cfg(feature = "fileapi")] pub mod fileapi; #[cfg(feature = "handleapi")] pub mod handleapi; @@ -155,8 +159,10 @@ #[cfg(feature = "objidl")] pub mod objidl; #[cfg(feature = "objidlbase")] pub mod objidlbase; #[cfg(feature = "ocidl")] pub mod ocidl; +#[cfg(feature = "ole2")] pub mod ole2; #[cfg(feature = "oleauto")] pub mod oleauto; #[cfg(feature = "olectl")] pub mod olectl; +#[cfg(feature = "oleidl")] pub mod oleidl; #[cfg(feature = "opmapi")] pub mod opmapi; #[cfg(feature = "pdh")] pub mod pdh; #[cfg(feature = "perflib")] pub mod perflib; @@ -221,6 +227,7 @@ #[cfg(feature = "userenv")] pub mod userenv; #[cfg(feature = "usp10")] pub mod usp10; #[cfg(feature = "utilapiset")] pub mod utilapiset; +#[cfg(feature = "uxtheme")] pub mod uxtheme; #[cfg(feature = "vsbackup")] pub mod vsbackup; #[cfg(feature = "vss")] pub mod vss; #[cfg(feature = "vsserror")] pub mod vsserror; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/ncrypt.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/ncrypt.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/ncrypt.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/ncrypt.rs 2018-12-05 01:24:41.000000000 +0000 @@ -4,14 +4,85 @@ // , at your option. // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. -use shared::basetsd::ULONG_PTR; -use shared::sspi::SECURITY_STATUS; +use shared::basetsd::{SIZE_T, ULONG_PTR}; +use shared::bcrypt::{BCRYPT_NO_KEY_VALIDATION, BCryptBufferDesc}; +use shared::minwindef::{DWORD, LPVOID, PBYTE}; +use um::winnt::{LONG, LPCWSTR, VOID}; +pub type SECURITY_STATUS = LONG; +pub type HCRYPTPROV = ULONG_PTR; +pub type HCRYPTKEY = ULONG_PTR; +pub type HCRYPTHASH = ULONG_PTR; +FN!{stdcall PFN_NCRYPT_ALLOC( + cbSize: SIZE_T, +) -> LPVOID} +FN!{stdcall PFN_NCRYPT_FREE( + pv: LPVOID, +) -> VOID} +STRUCT!{struct NCRYPT_ALLOC_PARA { + cbSize: DWORD, + pfnAlloc: PFN_NCRYPT_ALLOC, + pfnFree: PFN_NCRYPT_FREE, +}} +pub type NCryptBufferDesc = BCryptBufferDesc; pub type NCRYPT_HANDLE = ULONG_PTR; pub type NCRYPT_PROV_HANDLE = ULONG_PTR; pub type NCRYPT_KEY_HANDLE = ULONG_PTR; pub type NCRYPT_HASH_HANDLE = ULONG_PTR; pub type NCRYPT_SECRET_HANDLE = ULONG_PTR; +pub const NCRYPT_NO_PADDING_FLAG: DWORD = 0x00000001; +pub const NCRYPT_PAD_PKCS1_FLAG: DWORD = 0x00000002; +pub const NCRYPT_PAD_OAEP_FLAG: DWORD = 0x00000004; +pub const NCRYPT_PAD_PSS_FLAG: DWORD = 0x00000008; +pub const NCRYPT_PAD_CIPHER_FLAG: DWORD = 0x00000010; +pub const NCRYPT_ATTESTATION_FLAG: DWORD = 0x00000020; +pub const NCRYPT_SEALING_FLAG: DWORD = 0x00000100; +pub const NCRYPT_REGISTER_NOTIFY_FLAG: DWORD = 0x00000001; +pub const NCRYPT_UNREGISTER_NOTIFY_FLAG: DWORD = 0x00000002; +pub const NCRYPT_NO_KEY_VALIDATION: DWORD = BCRYPT_NO_KEY_VALIDATION; +pub const NCRYPT_MACHINE_KEY_FLAG: DWORD = 0x00000020; +pub const NCRYPT_SILENT_FLAG: DWORD = 0x00000040; +pub const NCRYPT_OVERWRITE_KEY_FLAG: DWORD = 0x00000080; +pub const NCRYPT_WRITE_KEY_TO_LEGACY_STORE_FLAG: DWORD = 0x00000200; +pub const NCRYPT_DO_NOT_FINALIZE_FLAG: DWORD = 0x00000400; +pub const NCRYPT_EXPORT_LEGACY_FLAG: DWORD = 0x00000800; +pub const NCRYPT_IGNORE_DEVICE_STATE_FLAG: DWORD = 0x00001000; +pub const NCRYPT_TREAT_NIST_AS_GENERIC_ECC_FLAG: DWORD = 0x00002000; +pub const NCRYPT_NO_CACHED_PASSWORD: DWORD = 0x00004000; +pub const NCRYPT_PROTECT_TO_LOCAL_SYSTEM: DWORD = 0x00008000; +pub const NCRYPT_PERSIST_ONLY_FLAG: DWORD = 0x40000000; +pub const NCRYPT_PERSIST_FLAG: DWORD = 0x80000000; +pub const NCRYPT_PREFER_VIRTUAL_ISOLATION_FLAG: DWORD = 0x00010000; +pub const NCRYPT_USE_VIRTUAL_ISOLATION_FLAG: DWORD = 0x00020000; +pub const NCRYPT_USE_PER_BOOT_KEY_FLAG: DWORD = 0x00040000; extern "system" { + pub fn NCryptOpenStorageProvider( + phProvider: *mut NCRYPT_PROV_HANDLE, + pszProviderName: LPCWSTR, + dwFlags: DWORD, + ) -> SECURITY_STATUS; +} +pub const NCRYPT_ALLOW_EXPORT_FLAG: DWORD = 0x00000001; +pub const NCRYPT_ALLOW_PLAINTEXT_EXPORT_FLAG: DWORD = 0x00000002; +pub const NCRYPT_ALLOW_ARCHIVING_FLAG: DWORD = 0x00000004; +pub const NCRYPT_ALLOW_PLAINTEXT_ARCHIVING_FLAG: DWORD = 0x00000008; +extern "system" { + pub fn NCryptSetProperty( + hObject: NCRYPT_HANDLE, + pszProperty: LPCWSTR, + pbInput: PBYTE, + cbInput: DWORD, + dwFlags: DWORD, + ) -> SECURITY_STATUS; + pub fn NCryptImportKey( + hProvider: NCRYPT_PROV_HANDLE, + hImportKey: NCRYPT_KEY_HANDLE, + pszBlobType: LPCWSTR, + pParameterList: *const NCryptBufferDesc, + phKey: *mut NCRYPT_KEY_HANDLE, + pbData: PBYTE, + cbData: DWORD, + dwFlags: DWORD, + ) -> SECURITY_STATUS; pub fn NCryptFreeObject( hObject: NCRYPT_HANDLE, ) -> SECURITY_STATUS; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/ntlsa.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/ntlsa.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/ntlsa.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/ntlsa.rs 2018-12-05 01:24:42.000000000 +0000 @@ -774,7 +774,7 @@ pub const ACCOUNT_WRITE: ULONG = STANDARD_RIGHTS_WRITE | ACCOUNT_ADJUST_PRIVILEGES | ACCOUNT_ADJUST_QUOTAS | ACCOUNT_ADJUST_SYSTEM_ACCESS; pub const ACCOUNT_EXECUTE: ULONG = STANDARD_RIGHTS_EXECUTE; -DECLARE_HANDLE!(LSA_HANDLE, __LSA_HANDLE); +DECLARE_HANDLE!{LSA_HANDLE, __LSA_HANDLE} pub const TRUSTED_QUERY_DOMAIN_NAME: ULONG = 0x00000001; pub const TRUSTED_QUERY_CONTROLLERS: ULONG = 0x00000002; pub const TRUSTED_SET_CONTROLLERS: ULONG = 0x00000004; @@ -981,7 +981,7 @@ pub const LSA_MACHINE_SECRET_PREFIX_LENGTH: SIZE_T = 2; pub const LSA_SECRET_MAXIMUM_COUNT: SIZE_T = 0x00001000; pub const LSA_SECRET_MAXIMUM_LENGTH: SIZE_T = 0x00000200; -DECLARE_HANDLE!(LSA_ENUMERATION_HANDLE, __LSA_ENUMERATION_HANDLE); +DECLARE_HANDLE!{LSA_ENUMERATION_HANDLE, __LSA_ENUMERATION_HANDLE} pub type PLSA_ENUMERATION_HANDLE = *mut LSA_ENUMERATION_HANDLE; STRUCT!{struct LSA_ENUMERATION_INFORMATION { Sid: PSID, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/ntsecapi.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/ntsecapi.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/ntsecapi.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/ntsecapi.rs 2018-12-05 01:24:41.000000000 +0000 @@ -5,7 +5,6 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. //! This module defines the Local Security Authority APIs. - use shared::basetsd::{ULONG64, ULONG_PTR}; use shared::guiddef::GUID; use shared::minwindef::{PUCHAR, PULONG, UCHAR, ULONG, USHORT}; @@ -21,137 +20,136 @@ SID_NAME_USE, STANDARD_RIGHTS_EXECUTE, STANDARD_RIGHTS_READ, STANDARD_RIGHTS_REQUIRED, STANDARD_RIGHTS_WRITE, ULONGLONG }; - -DEFINE_GUID!(Audit_System_SecurityStateChange, - 0x0cce9210, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_System_SecuritySubsystemExtension, - 0x0cce9211, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_System_Integrity, - 0x0cce9212, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_System_IPSecDriverEvents, - 0x0cce9213, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_System_Others, - 0x0cce9214, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_Logon_Logon, - 0x0cce9215, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_Logon_Logoff, - 0x0cce9216, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_Logon_AccountLockout, - 0x0cce9217, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_Logon_IPSecMainMode, - 0x0cce9218, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_Logon_IPSecQuickMode, - 0x0cce9219, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_Logon_IPSecUserMode, - 0x0cce921a, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_Logon_SpecialLogon, - 0x0cce921b, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_Logon_Others, - 0x0cce921c, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_ObjectAccess_FileSystem, - 0x0cce921d, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_ObjectAccess_Registry, - 0x0cce921e, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_ObjectAccess_Kernel, - 0x0cce921f, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_ObjectAccess_Sam, - 0x0cce9220, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_ObjectAccess_CertificationServices, - 0x0cce9221, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_ObjectAccess_ApplicationGenerated, - 0x0cce9222, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_ObjectAccess_Handle, - 0x0cce9223, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_ObjectAccess_Share, - 0x0cce9224, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_ObjectAccess_FirewallPacketDrops, - 0x0cce9225, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_ObjectAccess_FirewallConnection, - 0x0cce9226, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_ObjectAccess_Other, - 0x0cce9227, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_PrivilegeUse_Sensitive, - 0x0cce9228, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_PrivilegeUse_NonSensitive, - 0x0cce9229, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_PrivilegeUse_Others, - 0x0cce922a, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_DetailedTracking_ProcessCreation, - 0x0cce922b, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_DetailedTracking_ProcessTermination, - 0x0cce922c, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_DetailedTracking_DpapiActivity, - 0x0cce922d, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_DetailedTracking_RpcCall, - 0x0cce922e, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_PolicyChange_AuditPolicy, - 0x0cce922f, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_PolicyChange_AuthenticationPolicy, - 0x0cce9230, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_PolicyChange_AuthorizationPolicy, - 0x0cce9231, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_PolicyChange_MpsscvRulePolicy, - 0x0cce9232, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_PolicyChange_WfpIPSecPolicy, - 0x0cce9233, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_PolicyChange_Others, - 0x0cce9234, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_AccountManagement_UserAccount, - 0x0cce9235, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_AccountManagement_ComputerAccount, - 0x0cce9236, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_AccountManagement_SecurityGroup, - 0x0cce9237, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_AccountManagement_DistributionGroup, - 0x0cce9238, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_AccountManagement_ApplicationGroup, - 0x0cce9239, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_AccountManagement_Others, - 0x0cce923a, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_DSAccess_DSAccess, - 0x0cce923b, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_DsAccess_AdAuditChanges, - 0x0cce923c, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_Ds_Replication, - 0x0cce923d, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_Ds_DetailedReplication, - 0x0cce923e, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_AccountLogon_CredentialValidation, - 0x0cce923f, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_AccountLogon_Kerberos, - 0x0cce9240, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_AccountLogon_Others, - 0x0cce9241, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_AccountLogon_KerbCredentialValidation, - 0x0cce9242, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_Logon_NPS, - 0x0cce9243, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_ObjectAccess_DetailedFileShare, - 0x0cce9244, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_ObjectAccess_RemovableStorage, - 0x0cce9245, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_ObjectAccess_CbacStaging, - 0x0cce9246, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_Logon_Claims, - 0x0cce9247, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_System, - 0x69979848, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_Logon, - 0x69979849, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_ObjectAccess, - 0x6997984a, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_PrivilegeUse, - 0x6997984b, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_DetailedTracking, - 0x6997984c, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_PolicyChange, - 0x6997984d, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_AccountManagement, - 0x6997984e, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_DirectoryServiceAccess, - 0x6997984f, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); -DEFINE_GUID!(Audit_AccountLogon, - 0x69979850, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30); +DEFINE_GUID!{Audit_System_SecurityStateChange, + 0x0cce9210, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_System_SecuritySubsystemExtension, + 0x0cce9211, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_System_Integrity, + 0x0cce9212, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_System_IPSecDriverEvents, + 0x0cce9213, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_System_Others, + 0x0cce9214, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Logon_Logon, + 0x0cce9215, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Logon_Logoff, + 0x0cce9216, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Logon_AccountLockout, + 0x0cce9217, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Logon_IPSecMainMode, + 0x0cce9218, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Logon_IPSecQuickMode, + 0x0cce9219, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Logon_IPSecUserMode, + 0x0cce921a, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Logon_SpecialLogon, + 0x0cce921b, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Logon_Others, + 0x0cce921c, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_FileSystem, + 0x0cce921d, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_Registry, + 0x0cce921e, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_Kernel, + 0x0cce921f, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_Sam, + 0x0cce9220, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_CertificationServices, + 0x0cce9221, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_ApplicationGenerated, + 0x0cce9222, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_Handle, + 0x0cce9223, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_Share, + 0x0cce9224, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_FirewallPacketDrops, + 0x0cce9225, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_FirewallConnection, + 0x0cce9226, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_Other, + 0x0cce9227, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_PrivilegeUse_Sensitive, + 0x0cce9228, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_PrivilegeUse_NonSensitive, + 0x0cce9229, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_PrivilegeUse_Others, + 0x0cce922a, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_DetailedTracking_ProcessCreation, + 0x0cce922b, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_DetailedTracking_ProcessTermination, + 0x0cce922c, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_DetailedTracking_DpapiActivity, + 0x0cce922d, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_DetailedTracking_RpcCall, + 0x0cce922e, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_PolicyChange_AuditPolicy, + 0x0cce922f, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_PolicyChange_AuthenticationPolicy, + 0x0cce9230, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_PolicyChange_AuthorizationPolicy, + 0x0cce9231, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_PolicyChange_MpsscvRulePolicy, + 0x0cce9232, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_PolicyChange_WfpIPSecPolicy, + 0x0cce9233, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_PolicyChange_Others, + 0x0cce9234, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountManagement_UserAccount, + 0x0cce9235, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountManagement_ComputerAccount, + 0x0cce9236, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountManagement_SecurityGroup, + 0x0cce9237, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountManagement_DistributionGroup, + 0x0cce9238, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountManagement_ApplicationGroup, + 0x0cce9239, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountManagement_Others, + 0x0cce923a, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_DSAccess_DSAccess, + 0x0cce923b, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_DsAccess_AdAuditChanges, + 0x0cce923c, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Ds_Replication, + 0x0cce923d, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Ds_DetailedReplication, + 0x0cce923e, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountLogon_CredentialValidation, + 0x0cce923f, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountLogon_Kerberos, + 0x0cce9240, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountLogon_Others, + 0x0cce9241, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountLogon_KerbCredentialValidation, + 0x0cce9242, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Logon_NPS, + 0x0cce9243, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_DetailedFileShare, + 0x0cce9244, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_RemovableStorage, + 0x0cce9245, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess_CbacStaging, + 0x0cce9246, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Logon_Claims, + 0x0cce9247, 0x69ae, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_System, + 0x69979848, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_Logon, + 0x69979849, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_ObjectAccess, + 0x6997984a, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_PrivilegeUse, + 0x6997984b, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_DetailedTracking, + 0x6997984c, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_PolicyChange, + 0x6997984d, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountManagement, + 0x6997984e, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_DirectoryServiceAccess, + 0x6997984f, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} +DEFINE_GUID!{Audit_AccountLogon, + 0x69979850, 0x797a, 0x11d9, 0xbe, 0xd3, 0x50, 0x50, 0x54, 0x50, 0x30, 0x30} ENUM!{enum POLICY_AUDIT_EVENT_TYPE { AuditCategorySystem = 0, AuditCategoryLogon, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/oaidl.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/oaidl.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/oaidl.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/oaidl.rs 2018-12-05 01:24:41.000000000 +0000 @@ -626,7 +626,69 @@ // IEnumVARIANT // IEnumVARIANT_RemoteNext_Proxy // IEnumVARIANT_RemoteNext_Stub -pub enum IRecordInfo {} // FIXME +RIDL!{#[uuid(0x0000002F, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IRecordInfo(IRecordInfoVtbl): IUnknown(IUnknownVtbl){ + fn RecordInit( + pvNew: PVOID, + ) -> HRESULT, + fn RecordClear( + pvExisting: PVOID, + ) -> HRESULT, + fn RecordCopy( + pvExisting: PVOID, + pvNew: PVOID, + ) -> HRESULT, + fn GetGuid( + pguid: *mut GUID, + ) -> HRESULT, + fn GetName( + pbstrName: *mut BSTR, + ) -> HRESULT, + fn GetSize( + pcbSize: *mut ULONG, + ) -> HRESULT, + fn GetTypeInfo( + ppTypeInfo: *mut *mut ITypeInfo, + ) -> HRESULT, + fn GetField( + pvData: PVOID, + szFieldName: LPCOLESTR, + pvarField: *mut VARIANT, + ) -> HRESULT, + fn GetFieldNoCopy( + pvData: PVOID, + szFieldName: LPCOLESTR, + pvarField: *mut VARIANT, + ppvDataCArray: *mut PVOID, + ) -> HRESULT, + fn PutField( + wFlags: ULONG, + pvData: PVOID, + szFieldName: LPCOLESTR, + pvarField: *mut VARIANT, + ) -> HRESULT, + fn PutFieldNoCopy( + wFlags: ULONG, + pvData: PVOID, + szFieldName: LPCOLESTR, + pvarField: *mut VARIANT, + ) -> HRESULT, + fn GetFieldNames( + pcNames: *mut ULONG, + rgBstrNames: *mut BSTR, + ) -> HRESULT, + fn IsMatchingType( + pRecordInfo: *mut IRecordInfo, + ) -> BOOL, + fn RecordCreate() -> PVOID, + fn RecordCreateCopy( + pvSource: PVOID, + ppvDest: *mut PVOID, + ) -> HRESULT, + fn RecordDestroy( + pvRecord: PVOID, + ) -> HRESULT, +}} pub enum ITypeComp {} // FIXME ENUM!{enum SYSKIND { SYS_WIN16 = 0, @@ -686,7 +748,7 @@ pTLibAttr: *const TLIBATTR, ) -> HRESULT, }} -RIDL!(#[uuid(0x00020401, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +RIDL!{#[uuid(0x00020401, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] interface ITypeInfo(ITypeInfoVtbl): IUnknown(IUnknownVtbl) { fn GetTypeAttr( ppTypeAttr: *mut *mut TYPEATTR, @@ -775,13 +837,12 @@ fn ReleaseVarDesc( pVarDesc: *mut VARDESC, ) -> (), -} -); -RIDL!(#[uuid(0x3127ca40, 0x446e, 0x11ce, 0x81, 0x35, 0x00, 0xaa, 0x00, 0x4b, 0xb8, 0x51)] +}} +RIDL!{#[uuid(0x3127ca40, 0x446e, 0x11ce, 0x81, 0x35, 0x00, 0xaa, 0x00, 0x4b, 0xb8, 0x51)] interface IErrorLog(IErrorLogVtbl): IUnknown(IUnknownVtbl) { fn AddError( pszPropName: LPCOLESTR, pExcepInfo: *const EXCEPINFO, ) -> HRESULT, -}); +}} pub type LPERRORLOG = *mut IErrorLog; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/objidl.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/objidl.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/objidl.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/objidl.rs 2018-12-05 01:24:41.000000000 +0000 @@ -7,10 +7,13 @@ //! this ALWAYS GENERATED file contains the definitions for the interfaces use ctypes::c_void; use shared::basetsd::UINT64; -use shared::guiddef::{CLSID, REFIID}; -use shared::minwindef::{BOOL, DWORD, FILETIME, ULONG}; +use shared::guiddef::{CLSID, IID, REFCLSID, REFIID}; +use shared::minwindef::{BOOL, BYTE, DWORD, FILETIME, HGLOBAL, ULONG, WORD}; +use shared::ntdef::LONG; +use shared::windef::{HBITMAP, HENHMETAFILE}; +use shared::wtypes::{CLIPFORMAT, HMETAFILEPICT}; use shared::wtypesbase::{LPOLESTR, OLECHAR}; -use um::objidlbase::{IEnumString, IStream}; +use um::objidlbase::{IEnumString, IStream, STATSTG}; use um::unknwnbase::{IUnknown, IUnknownVtbl}; use um::winnt::{HRESULT, ULARGE_INTEGER}; //8402 @@ -22,8 +25,7 @@ }} pub type LPBIND_OPTS = *mut BIND_OPTS; //8479 -RIDL!( -#[uuid(0x0000000e, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +RIDL!{#[uuid(0x0000000e, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] interface IBindCtx(IBindCtxVtbl): IUnknown(IUnknownVtbl) { fn RegisterObjectBound( punk: *mut IUnknown, @@ -55,11 +57,9 @@ fn RevokeObjectParam( pszKey: LPOLESTR, ) -> HRESULT, -} -); +}} //8681 -RIDL!( -#[uuid(0x00000102, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +RIDL!{#[uuid(0x00000102, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] interface IEnumMoniker(IEnumMonikerVtbl): IUnknown(IUnknownVtbl) { fn Next( celt: ULONG, @@ -73,11 +73,9 @@ fn Clone( ppenum: *mut *mut IEnumMoniker, ) -> HRESULT, -} -); +}} //8958 -RIDL!( -#[uuid(0x00000010, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +RIDL!{#[uuid(0x00000010, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] interface IRunningObjectTable(IRunningObjectTableVtbl): IUnknown(IUnknownVtbl) { fn Register( grfFlags: DWORD, @@ -106,20 +104,16 @@ fn EnumRunning( ppenumMoniker: *mut *mut IEnumMoniker, ) -> HRESULT, -} -); +}} //9125 -RIDL!( -#[uuid(0x0000010c, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +RIDL!{#[uuid(0x0000010c, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] interface IPersist(IPersistVtbl): IUnknown(IUnknownVtbl) { fn GetClassID( pClassID: *mut CLSID, ) -> HRESULT, -} -); +}} //9207 -RIDL!( -#[uuid(0x00000109, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +RIDL!{#[uuid(0x00000109, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] interface IPersistStream(IPersistStreamVtbl): IPersist(IPersistVtbl) { fn IsDirty() -> HRESULT, fn Load( @@ -132,11 +126,9 @@ fn GetSizeMax( pcbSize: *mut ULARGE_INTEGER, ) -> HRESULT, -} -); +}} //9350 -RIDL!( -#[uuid(0x0000000f, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +RIDL!{#[uuid(0x0000000f, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] interface IMoniker(IMonikerVtbl): IPersistStream(IPersistStreamVtbl) { fn BindToObject( pbc: *mut IBindCtx, @@ -207,8 +199,7 @@ fn IsSystemMoniker( pdwMksys: *mut DWORD, ) -> HRESULT, -} -); +}} ENUM!{enum EOLE_AUTHENTICATION_CAPABILITIES { EOAC_NONE = 0, EOAC_MUTUAL_AUTH = 0x1, @@ -232,16 +223,252 @@ pPrincipalName: *mut OLECHAR, hr: HRESULT, }} -RIDL!( -#[uuid(0xa2f05a09, 0x27a2, 0x42b5, 0xbc, 0x0e, 0xac, 0x16, 0x3e, 0xf4, 0x9d, 0x9b)] +RIDL!{#[uuid(0x0000000d, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IEnumSTATSTG(IEnumSTATSTGVtbl): IUnknown(IUnknownVtbl) { + fn Next( + celt: ULONG, + rgelt: *mut STATSTG, + pceltFetched: *mut ULONG, + ) -> HRESULT, + fn Skip( + celt: ULONG, + ) -> HRESULT, + fn Reset() -> HRESULT, + fn Clone( + ppenum: *mut *mut IEnumSTATSTG, + ) -> HRESULT, +}} +pub type SNB = *const *const OLECHAR; +RIDL!{#[uuid(0x0000000b, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IStorage(IStorageVtbl): IUnknown(IUnknownVtbl) { + fn CreateStream( + pwcsName: *const OLECHAR, + grfMode: DWORD, + reserved1: DWORD, + reserved2: DWORD, + ppstm: *mut *mut IStream, + ) -> HRESULT, + fn OpenStream( + pwcsName: *const OLECHAR, + reserved1: *const c_void, + grfMode: DWORD, + reserved2: DWORD, + ppstm: *mut *mut IStream, + ) -> HRESULT, + fn CreateStorage( + pwcsName: *const OLECHAR, + grfMode: DWORD, + reserved1: DWORD, + reserved2: DWORD, + ppstg: *mut *mut IStorage, + ) -> HRESULT, + fn OpenStorage( + pwcsName: *const OLECHAR, + pstgPriority: IStorage, + grfMode: DWORD, + snbExclude: SNB, + reserved: DWORD, + ppstg: *mut *mut IStorage, + ) -> HRESULT, + fn CopyTo( + ciidExclude: DWORD, + rgiidExclude: *const IID, + snbExclude: SNB, + pstgDest: *const IStorage, + ) -> HRESULT, + fn MoveElementTo( + pwcsName: *const OLECHAR, + pstgDest: *const IStorage, + pwcsNewName: *const OLECHAR, + grfFlags: DWORD, + ) -> HRESULT, + fn Commit( + grfCommitFlags: DWORD, + ) -> HRESULT, + fn Revert() -> HRESULT, + fn EnumElements( + reserved1: DWORD, + reserved2: *const c_void, + reserved3: DWORD, + ppenum: *mut *mut IEnumSTATSTG, + ) -> HRESULT, + fn DestroyElement( + pwcsName: *const OLECHAR, + ) -> HRESULT, + fn RenameElement( + pwcsOldName: *const OLECHAR, + pwcsNewName: *const OLECHAR, + ) -> HRESULT, + fn SetElementTimes( + pwcsName: *const OLECHAR, + pctime: *const FILETIME, + patime: *const FILETIME, + pmtime: *const FILETIME, + ) -> HRESULT, + fn SetClass( + clsid: REFCLSID, + ) -> HRESULT, + fn SetStateBits( + grfStateBits: DWORD, + grfMask: DWORD, + ) -> HRESULT, + fn Stat( + pstatstg: *mut STATSTG, + grfStatFlag: DWORD, + ) -> HRESULT, +}} +STRUCT!{struct DVTARGETDEVICE { + tdSize: DWORD, + tdDriverNameOffset: WORD, + tdDeviceNameOffset: WORD, + tdPortNameOffset: WORD, + tdExtDevmodeOFfset: WORD, + tdData: [BYTE; 1], +}} +STRUCT!{struct FORMATETC { + cfFormat: CLIPFORMAT, + ptd: *const DVTARGETDEVICE, + dwAspect: DWORD, + lindex: LONG, + tymed: DWORD, +}} +RIDL!{#[uuid(0x00000103, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IEnumFORMATETC(IEnumFORMATETCVtbl): IUnknown(IUnknownVtbl) { + fn Next( + celt: ULONG, + rgelt: *mut FORMATETC, + pceltFetched: *mut ULONG, + ) -> HRESULT, + fn Skip( + celt: ULONG, + ) -> HRESULT, + fn Reset() -> HRESULT, + fn Clone( + ppenum: *mut *mut IEnumFORMATETC, + ) -> HRESULT, +}} +ENUM!{enum ADVF { + ADVF_NODATA = 1, + ADVF_PRIMEFIRST = 2, + ADVF_ONLYONCE = 4, + ADVF_DATAONSTOP = 64, + ADVFCACHE_NOHANDLER = 8, + ADVFCACHE_FORCEBUILTIN = 16, + ADVFCACHE_ONSAVE = 32, +}} +STRUCT!{struct STATDATA { + formatetc: FORMATETC, + advf: DWORD, + pAdvSInk: *mut IAdviseSink, + dwConnection: DWORD, +}} +RIDL!{#[uuid(0x00000105, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IEnumSTATDATA(IEnumSTATDATAVtbl): IUnknown(IUnknownVtbl) { + fn Next( + celt: ULONG, + rgelt: *mut STATDATA, + pceltFetched: *mut ULONG, + ) -> HRESULT, + fn Skip( + celt: ULONG, + ) -> HRESULT, + fn Reset() -> HRESULT, + fn Clone( + ppenum: *mut *mut IEnumSTATDATA, + ) -> HRESULT, +}} +ENUM!{enum TYMED { + TYMED_HGLOBAL = 1, + TYMED_FILE = 2, + TYMED_ISTREAM = 4, + TYMED_ISTORAGE = 8, + TYMED_GDI = 16, + TYMED_MFPICT = 32, + TYMED_ENHMF = 64, + TYMED_NULL = 0, +}} +UNION!{union STGMEDIUM_u { + [u64; 7], //TODO: I guessed to move on + hBitmap hBitmap_mut: HBITMAP, + hMetaFilePict hMetaFilePict_mut: HMETAFILEPICT, + hEnhMetaFile hEnhMetaFile_mut: HENHMETAFILE, + hGlobal hGlobal_mut: HGLOBAL, + lpszFileName lpszFileName_mut: LPOLESTR, + pstm pstm_mut: *mut IStream, + pstg pstg_mut: *mut IStorage, +}} +STRUCT!{struct STGMEDIUM { + tymed: DWORD, + u: *mut STGMEDIUM_u, + pUnkForRelease: *mut IUnknown, +}} +RIDL!{#[uuid(0x0000010f, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IAdviseSink(IAdviseSinkVtbl): IUnknown(IUnknownVtbl) { + fn OnDataChange( + pformatetc: *mut FORMATETC, + pStgmed: *mut STGMEDIUM, + ) -> c_void, + fn OnViewChange( + dwAspect: DWORD, + lindex: LONG, + ) -> c_void, + fn OnRename( + pmk: *mut IMoniker, + ) -> c_void, + fn OnSave() -> c_void, + fn OnClose() -> c_void, +}} +ENUM!{enum DATADIR { + DATADIR_GET = 1, + DATADIR_SET = 2, +}} +pub type LPDATAOBJECT = *mut IDataObject; +RIDL!{#[uuid(0x0000010e, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IDataObject(IDataObjectVtbl): IUnknown(IUnknownVtbl) { + fn GetData( + pformatetcIn: *const FORMATETC, + pmedium: *mut STGMEDIUM, + ) -> HRESULT, + fn GetDataHere( + pformatetc: *const FORMATETC, + pmedium: *mut STGMEDIUM, + ) -> HRESULT, + fn QueryGetData( + pformatetc: *const FORMATETC, + ) -> HRESULT, + fn GetCanonicalFormatEtc( + pformatetcIn: *const FORMATETC, + pformatetcOut: *mut FORMATETC, + ) -> HRESULT, + fn SetData( + pformatetc: *const FORMATETC, + pformatetcOut: *const FORMATETC, + fRelease: BOOL, + ) -> HRESULT, + fn EnumFormatEtc( + dwDirection: DWORD, + ppenumFormatEtc: *mut *mut IEnumFORMATETC, + ) -> HRESULT, + fn DAdvise( + pformatetc: *const FORMATETC, + advf: DWORD, + pAdvSInk: *const IAdviseSink, + pdwConnection: *mut DWORD, + ) -> HRESULT, + fn DUnadvise( + dwConnection: DWORD, + ) -> HRESULT, + fn EnumDAdvise( + ppenumAdvise: *const *const IEnumSTATDATA, + ) -> HRESULT, +}} +RIDL!{#[uuid(0xa2f05a09, 0x27a2, 0x42b5, 0xbc, 0x0e, 0xac, 0x16, 0x3e, 0xf4, 0x9d, 0x9b)] interface IApartmentShutdown(IApartmentShutdownVtbl): IUnknown(IUnknownVtbl) { fn OnUninitialize( ui64ApartmentIdentifier: UINT64, ) -> (), -} -); -RIDL!( -#[uuid(0x00000003, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +}} +RIDL!{#[uuid(0x00000003, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] interface IMarshal(IMarshalVtbl): IUnknown(IUnknownVtbl) { fn GetUnmarshalClass( riid: REFIID, @@ -278,5 +505,4 @@ fn DisconnectObject( dwReserved: DWORD, ) -> HRESULT, -} -); +}} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/ocidl.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/ocidl.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/ocidl.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/ocidl.rs 2018-12-05 01:24:42.000000000 +0000 @@ -12,6 +12,13 @@ use shared::wtypesbase::{LPCOLESTR, LPOLESTR}; use um::oaidl::{IErrorLog, VARIANT}; use um::unknwnbase::{IUnknown, IUnknownVtbl}; +ENUM!{enum READYSTATE { + READYSTATE_UNINITIALIZED = 0, + READYSTATE_LOADING = 1, + READYSTATE_LOADED = 2, + READYSTATE_INTERACTIVE = 3, + READYSTATE_COMPLETE = 4, +}} ENUM!{enum PROPBAG2_TYPE { PROPBAG2_TYPE_UNDEFINED = 0, PROPBAG2_TYPE_DATA = 1, @@ -29,7 +36,7 @@ pstrName: LPOLESTR, clsid: CLSID, }} -RIDL!(#[uuid(0x22f55882, 0x280b, 0x11d0, 0xa8, 0xa9, 0x00, 0xa0, 0xc9, 0x0c, 0x20, 0x04)] +RIDL!{#[uuid(0x22f55882, 0x280b, 0x11d0, 0xa8, 0xa9, 0x00, 0xa0, 0xc9, 0x0c, 0x20, 0x04)] interface IPropertyBag2(IPropertyBag2Vtbl): IUnknown(IUnknownVtbl) { fn Read( cProperties: ULONG, @@ -58,5 +65,5 @@ pUnkObject: *const IUnknown, pErrLog: *const IErrorLog, ) -> HRESULT, -}); +}} pub type LPPROPERTYBAG2 = *mut IPropertyBag2; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/ole2.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/ole2.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/ole2.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/ole2.rs 2018-12-05 01:24:42.000000000 +0000 @@ -0,0 +1,22 @@ +// Copyright © 2018 winapi-rs developers +// Licensed under the Apache License, Version 2.0 +// or the MIT license +// , at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::LPVOID; +use shared::windef::HWND; +use um::oleidl::LPDROPTARGET; +use um::winnt::HRESULT; +extern "system" { + pub fn OleInitialize( + pvReserved: LPVOID + ) -> HRESULT; + pub fn RegisterDragDrop( + hwnd: HWND, + pDropTarget: LPDROPTARGET, + ) -> HRESULT; + pub fn RevokeDragDrop( + hwnd: HWND, + ) -> HRESULT; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/oleauto.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/oleauto.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/oleauto.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/oleauto.rs 2018-12-05 01:24:41.000000000 +0000 @@ -11,7 +11,7 @@ use shared::wtypes::{BSTR, DATE, DECIMAL, LPBSTR, LPDECIMAL, VARTYPE}; use shared::wtypesbase::{DOUBLE, LPCOLESTR, LPOLESTR, OLECHAR}; use um::minwinbase::LPSYSTEMTIME; -use um::oaidl::{DISPID_UNKNOWN, ITypeLib, VARIANT, VARIANTARG}; +use um::oaidl::{DISPID_UNKNOWN, ITypeLib, SAFEARRAY, VARIANT, VARIANTARG}; use um::winnt::{CHAR, HRESULT, INT, LCID, LONG, LPCSTR, SHORT}; extern "system" { pub fn SysAllocString( @@ -61,6 +61,18 @@ vtime: DOUBLE, lpSystemTime: LPSYSTEMTIME, ) -> INT; + pub fn SafeArrayAccessData( + psa: *mut SAFEARRAY, + ppvData: *mut *mut c_void, + ) -> HRESULT; + pub fn SafeArrayUnaccessData( + psa: *mut SAFEARRAY, + ) -> HRESULT; + pub fn SafeArrayCreateVector( + vt: VARTYPE, + lLbound: LONG, + cElements: ULONG, + ) -> *mut SAFEARRAY; pub fn VariantInit( pvarg: *mut VARIANTARG, ); diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/oleidl.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/oleidl.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/oleidl.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/oleidl.rs 2018-12-05 01:24:41.000000000 +0000 @@ -0,0 +1,44 @@ +// Copyright © 2018 winapi-rs developers +// Licensed under the Apache License, Version 2.0 +// or the MIT license +// , at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +use shared::minwindef::DWORD; +use shared::ntdef::HRESULT; +use shared::windef::POINTL; +use um::objidl::IDataObject; +use um::unknwnbase::{IUnknown, IUnknownVtbl}; +pub const MK_ALT: DWORD = 20; +pub const DROPEFFECT_NONE: DWORD = 0; +pub const DROPEFFECT_COPY: DWORD = 1; +pub const DROPEFFECT_MOVE: DWORD = 2; +pub const DROPEFFECT_LINK: DWORD = 4; +pub const DROPEFFECT_SCROLL: DWORD = 0x80000000; +pub const DD_DEFSCROLLINSET: DWORD = 11; +pub const DD_DEFSCROLLDELAY: DWORD = 50; +pub const DD_DEFSCROLLINTERVAL: DWORD = 50; +pub const DD_DEFDRAGDELAY: DWORD = 200; +pub const DD_DEFDRAGMINDIST: DWORD = 2; +pub type LPDROPTARGET = *mut IDropTarget; +RIDL!{#[uuid(0x00000122, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IDropTarget(IDropTargetVtbl): IUnknown(IUnknownVtbl) { + fn DragEnter( + pDataObj: *const IDataObject, + grfKeyState: DWORD, + pt: *const POINTL, + pdwEffect: *mut DWORD, + ) -> HRESULT, + fn DragOver( + grfKeyState: DWORD, + pt: *const POINTL, + pdwEffect: *mut DWORD, + ) -> HRESULT, + fn DragLeave() -> HRESULT, + fn Drop( + pDataObj: *const IDataObject, + grfKeyState: DWORD, + pt: *const POINTL, + pdwEffect: *mut DWORD, + ) -> HRESULT, +}} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/pdh.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/pdh.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/pdh.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/pdh.rs 2018-12-05 01:24:42.000000000 +0000 @@ -106,7 +106,7 @@ dwDefaultDetailLevel: DWORD, szDialogBoxCaption: LPSTR, }} -BITFIELD!(PDH_BROWSE_DLG_CONFIG_A flags: DWORD [ +BITFIELD!{PDH_BROWSE_DLG_CONFIG_A flags: DWORD [ IncludeInstanceIndex set_IncludeInstanceIndex[0..1], SingleCounterPerAdd set_SingleCounterPerAdd[1..2], SingleCounterPerDialog set_SingleCounterPerDialog[2..3], @@ -117,7 +117,7 @@ DisableMachineSelection set_DisableMachineSelection[7..8], IncludeCostlyObjects set_IncludeCostlyObjects[8..9], ShowObjectBrowser set_ShowObjectBrowser[9..10], -]); +]} STRUCT!{struct PDH_BROWSE_DLG_CONFIG_W { flags: DWORD, hWndOwner: HWND, @@ -130,7 +130,7 @@ dwDefaultDetailLevel: DWORD, szDialogBoxCaption: LPWSTR, }} -BITFIELD!(PDH_BROWSE_DLG_CONFIG_W flags: DWORD [ +BITFIELD!{PDH_BROWSE_DLG_CONFIG_W flags: DWORD [ IncludeInstanceIndex set_IncludeInstanceIndex[0..1], SingleCounterPerAdd set_SingleCounterPerAdd[1..2], SingleCounterPerDialog set_SingleCounterPerDialog[2..3], @@ -141,7 +141,7 @@ DisableMachineSelection set_DisableMachineSelection[7..8], IncludeCostlyObjects set_IncludeCostlyObjects[8..9], ShowObjectBrowser set_ShowObjectBrowser[9..10], -]); +]} STRUCT!{struct PDH_COUNTER_PATH_ELEMENTS_A { szMachineName: LPSTR, szObjectName: LPSTR, @@ -238,7 +238,7 @@ dwDefaultDetailLevel: DWORD, szDialogBoxCaption: LPSTR, }} -BITFIELD!(PDH_BROWSE_DLG_CONFIG_HA flags: DWORD [ +BITFIELD!{PDH_BROWSE_DLG_CONFIG_HA flags: DWORD [ IncludeInstanceIndex set_IncludeInstanceIndex[0..1], SingleCounterPerAdd set_SingleCounterPerAdd[1..2], SingleCounterPerDialog set_SingleCounterPerDialog[2..3], @@ -249,7 +249,7 @@ DisableMachineSelection set_DisableMachineSelection[7..8], IncludeCostlyObjects set_IncludeCostlyObjects[8..9], ShowObjectBrowser set_ShowObjectBrowser[9..10], -]); +]} STRUCT!{struct PDH_BROWSE_DLG_CONFIG_HW { flags: DWORD, hWndOwner: HWND, @@ -262,7 +262,7 @@ dwDefaultDetailLevel: DWORD, szDialogBoxCaption: LPWSTR, }} -BITFIELD!(PDH_BROWSE_DLG_CONFIG_HW flags: DWORD [ +BITFIELD!{PDH_BROWSE_DLG_CONFIG_HW flags: DWORD [ IncludeInstanceIndex set_IncludeInstanceIndex[0..1], SingleCounterPerAdd set_SingleCounterPerAdd[1..2], SingleCounterPerDialog set_SingleCounterPerDialog[2..3], @@ -273,7 +273,7 @@ DisableMachineSelection set_DisableMachineSelection[7..8], IncludeCostlyObjects set_IncludeCostlyObjects[8..9], ShowObjectBrowser set_ShowObjectBrowser[9..10], -]); +]} extern "system" { pub fn PdhGetDllVersion( lpdwVersion: LPDWORD, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/powersetting.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/powersetting.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/powersetting.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/powersetting.rs 2018-12-05 01:24:41.000000000 +0000 @@ -6,7 +6,7 @@ // except according to those terms. use shared::guiddef::{GUID, LPCGUID}; use shared::minwindef::{DWORD, HKEY, LPBYTE, LPDWORD, PUCHAR, PULONG}; -use um::winnt::{HANDLE}; +use um::winnt::HANDLE; use um::winuser::{HPOWERNOTIFY, PHPOWERNOTIFY}; extern "system" { pub fn PowerReadACValue( diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/processsnapshot.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/processsnapshot.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/processsnapshot.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/processsnapshot.rs 2018-12-05 01:24:42.000000000 +0000 @@ -51,8 +51,8 @@ PSS_DUPLICATE_NONE = 0x00, PSS_DUPLICATE_CLOSE_SOURCE = 0x01, }} -DECLARE_HANDLE!(HPSS, HPSS__); -DECLARE_HANDLE!(HPSSWALK, HPSSWALK__); +DECLARE_HANDLE!{HPSS, HPSS__} +DECLARE_HANDLE!{HPSSWALK, HPSSWALK__} FN!{stdcall pAllocRoutine( Context: *mut c_void, Size: DWORD, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/processthreadsapi.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/processthreadsapi.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/processthreadsapi.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/processthreadsapi.rs 2018-12-05 01:24:42.000000000 +0000 @@ -5,7 +5,6 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms //! ApiSet Contract for api-ms-win-core-processthreads-l1 - use ctypes::{c_int, c_void}; use shared::basetsd::{DWORD_PTR, PSIZE_T, PULONG_PTR, SIZE_T, ULONG_PTR}; use shared::guiddef::LPCGUID; @@ -17,7 +16,6 @@ CONTEXT, HANDLE, LPCSTR, LPCWSTR, LPSTR, LPWSTR, PAPCFUNC, PHANDLE, PPROCESSOR_NUMBER, PROCESS_MITIGATION_POLICY, PVOID }; - STRUCT!{struct PROCESS_INFORMATION { hProcess: HANDLE, hThread: HANDLE, @@ -393,7 +391,7 @@ ThreadInformationClass: THREAD_INFORMATION_CLASS, ThreadInformation: LPVOID, ThreadInformationSize: DWORD, - ); + ) -> BOOL; pub fn IsProcessCritical( hProcess: HANDLE, Critical: PBOOL, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/processtopologyapi.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/processtopologyapi.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/processtopologyapi.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/processtopologyapi.rs 2018-12-05 01:24:42.000000000 +0000 @@ -22,4 +22,3 @@ PreviousGroupAffinity: PGROUP_AFFINITY, ) -> BOOL; } - diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/profileapi.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/profileapi.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/profileapi.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/profileapi.rs 2018-12-05 01:24:42.000000000 +0000 @@ -14,4 +14,3 @@ lpFrequency: *mut LARGE_INTEGER, ) -> BOOL; } - diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/propkeydef.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/propkeydef.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/propkeydef.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/propkeydef.rs 2018-12-05 01:24:41.000000000 +0000 @@ -4,7 +4,7 @@ // , at your option. // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms -use shared::guiddef::{IsEqualIID}; +use shared::guiddef::IsEqualIID; use shared::wtypes::{PROPERTYKEY, PROPID}; pub const PID_FIRST_USABLE: PROPID = 2; pub type REFPROPERTYKEY = *const PROPERTYKEY; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/propsys.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/propsys.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/propsys.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/propsys.rs 2018-12-05 01:24:41.000000000 +0000 @@ -11,7 +11,7 @@ use um::unknwnbase::{IUnknown, IUnknownVtbl}; use um::winnt::HRESULT; pub type IPropertyDescriptionList = IUnknown; // TODO -RIDL!(#[uuid(0x886d8eeb, 0x8cf2, 0x4446, 0x8d, 0x02, 0xcd, 0xba, 0x1d, 0xbd, 0xcf, 0x99)] +RIDL!{#[uuid(0x886d8eeb, 0x8cf2, 0x4446, 0x8d, 0x02, 0xcd, 0xba, 0x1d, 0xbd, 0xcf, 0x99)] interface IPropertyStore(IPropertyStoreVtbl): IUnknown(IUnknownVtbl) { fn GetCount( cProps: *mut DWORD, @@ -29,8 +29,7 @@ propvar: REFPROPVARIANT, ) -> HRESULT, fn Commit() -> HRESULT, -} -); +}} ENUM!{enum GETPROPERTYSTOREFLAGS { GPS_DEFAULT = 0, GPS_HANDLERPROPERTIESONLY = 0x1, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/reason.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/reason.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/reason.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/reason.rs 2018-12-05 01:24:41.000000000 +0000 @@ -4,9 +4,7 @@ // , at your option. // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. - use shared::minwindef::DWORD; - pub const SHTDN_REASON_FLAG_COMMENT_REQUIRED: DWORD = 0x01000000; pub const SHTDN_REASON_FLAG_DIRTY_PROBLEM_ID_REQUIRED: DWORD = 0x02000000; pub const SHTDN_REASON_FLAG_CLEAN_UI: DWORD = 0x04000000; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/restartmanager.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/restartmanager.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/restartmanager.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/restartmanager.rs 2018-12-05 01:24:42.000000000 +0000 @@ -72,10 +72,10 @@ RmNoShutdown = 2, }} UNION!{union RM_FILTER_INFO_u { - [u32; 3] [u64; 2], - strFilename strFilename_mut: LPWSTR, - Process Process_mut: RM_UNIQUE_PROCESS, - strServiceShortName strServiceShortName_mut: LPWSTR, + [u32; 3] [u64; 2], + strFilename strFilename_mut: LPWSTR, + Process Process_mut: RM_UNIQUE_PROCESS, + strServiceShortName strServiceShortName_mut: LPWSTR, }} STRUCT!{struct RM_FILTER_INFO { FilterAction: RM_FILTER_ACTION, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/restrictederrorinfo.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/restrictederrorinfo.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/restrictederrorinfo.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/restrictederrorinfo.rs 2018-12-05 01:24:42.000000000 +0000 @@ -4,13 +4,10 @@ // , at your option. // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. - use shared::wtypes::BSTR; use um::unknwnbase::{IUnknown, IUnknownVtbl}; use um::winnt::HRESULT; - -RIDL!( -#[uuid(0x82ba7092, 0x4c88, 0x427d, 0xa7, 0xbc, 0x16, 0xdd, 0x93, 0xfe, 0xb6, 0x7e)] +RIDL!{#[uuid(0x82ba7092, 0x4c88, 0x427d, 0xa7, 0xbc, 0x16, 0xdd, 0x93, 0xfe, 0xb6, 0x7e)] interface IRestrictedErrorInfo(IRestrictedErrorInfoVtbl): IUnknown(IUnknownVtbl) { fn GetErrorDetails( description: *mut BSTR, @@ -21,5 +18,4 @@ fn GetReference( reference: *mut BSTR, ) -> HRESULT, -} -); +}} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/sapi51.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/sapi51.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/sapi51.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/sapi51.rs 2018-12-05 01:24:42.000000000 +0000 @@ -167,17 +167,18 @@ pub const DEFAULT_WEIGHT: c_float = 1.0; pub const SP_MAX_WORD_LENGTH: ULONG = 128; pub const SP_MAX_PRON_LENGTH: ULONG = 384; -RIDL!(#[uuid(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)] +RIDL!{#[uuid(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)] interface ISpNotifyCallback(ISpNotifyCallbackVtbl) { fn NotifyCallback( wParam: WPARAM, lParam: LPARAM, ) -> HRESULT, -}); -FN!( - stdcall SPNOTIFYCALLBACK(wParam: WPARAM, lParam: LPARAM, - ) -> ()); -RIDL!(#[uuid(0x5eff4aef, 0x8487, 0x11d2, 0x96, 0x1c, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0x28)] +}} +FN!{stdcall SPNOTIFYCALLBACK( + wParam: WPARAM, + lParam: LPARAM, +) -> ()} +RIDL!{#[uuid(0x5eff4aef, 0x8487, 0x11d2, 0x96, 0x1c, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0x28)] interface ISpNotifySource(ISpNotifySourceVtbl): IUnknown(IUnknownVtbl) { fn SetNotifySink( pNotifySink: *mut ISpNotifySink, @@ -203,12 +204,12 @@ dwMilliseconds: DWORD, ) -> HRESULT, fn GetNotifyEventHandle() -> HANDLE, -}); -RIDL!(#[uuid(0x259684dc, 0x37c3, 0x11d2, 0x96, 0x03, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0x28)] +}} +RIDL!{#[uuid(0x259684dc, 0x37c3, 0x11d2, 0x96, 0x03, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0x28)] interface ISpNotifySink(ISpNotifySinkVtbl): IUnknown(IUnknownVtbl) { fn Notify() -> HRESULT, -}); -RIDL!(#[uuid(0xaca16614, 0x5d3d, 0x11d2, 0x96, 0x0e, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0x28)] +}} +RIDL!{#[uuid(0xaca16614, 0x5d3d, 0x11d2, 0x96, 0x0e, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0x28)] interface ISpNotifyTranslator(ISpNotifyTranslatorVtbl): ISpNotifySink(ISpNotifySinkVtbl) { fn InitWindowMessage( hWnd: HWND, @@ -234,8 +235,8 @@ dwMilliseconds: DWORD, ) -> HRESULT, fn GetEventHandle() -> HANDLE, -}); -RIDL!(#[uuid(0x14056581, 0xe16c, 0x11d2, 0xbb, 0x90, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0xc0)] +}} +RIDL!{#[uuid(0x14056581, 0xe16c, 0x11d2, 0xbb, 0x90, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0xc0)] interface ISpDataKey(ISpDataKeyVtbl): IUnknown(IUnknownVtbl) { fn SetData( pszValueName: LPCWSTR, @@ -285,15 +286,15 @@ Index: ULONG, ppszValueName: *mut LPWSTR, ) -> HRESULT, -}); -RIDL!(#[uuid(0x92a66e2b, 0xc830, 0x4149, 0x83, 0xdf, 0x6f, 0xc2, 0xba, 0x1e, 0x7a, 0x5b)] +}} +RIDL!{#[uuid(0x92a66e2b, 0xc830, 0x4149, 0x83, 0xdf, 0x6f, 0xc2, 0xba, 0x1e, 0x7a, 0x5b)] interface ISpRegDataKey(ISpRegDataKeyVtbl): ISpDataKey(ISpDataKeyVtbl) { fn SetKey( hkey: HKEY, fReadOnly: BOOL, ) -> HRESULT, -}); -RIDL!(#[uuid(0x2d3d3845, 0x39af, 0x4850, 0xbb, 0xf9, 0x40, 0xb4, 0x97, 0x80, 0x01, 0x1d)] +}} +RIDL!{#[uuid(0x2d3d3845, 0x39af, 0x4850, 0xbb, 0xf9, 0x40, 0xb4, 0x97, 0x80, 0x01, 0x1d)] interface ISpObjectTokenCategory(ISpObjectTokenCategoryVtbl): ISpDataKey(ISpDataKeyVtbl) { fn SetId( pszCategoryId: LPCWSTR, @@ -317,8 +318,8 @@ fn GetDefaultTokenId( ppszCoMemTokenId: *mut LPWSTR, ) -> HRESULT, -}); -RIDL!(#[uuid(0x14056589, 0xe16c, 0x11d2, 0xbb, 0x90, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0xc0)] +}} +RIDL!{#[uuid(0x14056589, 0xe16c, 0x11d2, 0xbb, 0x90, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0xc0)] interface ISpObjectToken(ISpObjectTokenVtbl): ISpDataKey(ISpDataKeyVtbl) { fn SetId( pszCategoryId: LPCWSTR, @@ -370,16 +371,16 @@ pszAttributes: LPCWSTR, pfMatches: *mut BOOL, ) -> HRESULT, -}); -RIDL!(#[uuid(0xb8aab0cf, 0x346f, 0x49d8, 0x94, 0x99, 0xc8, 0xb0, 0x3f, 0x16, 0x1d, 0x51)] +}} +RIDL!{#[uuid(0xb8aab0cf, 0x346f, 0x49d8, 0x94, 0x99, 0xc8, 0xb0, 0x3f, 0x16, 0x1d, 0x51)] interface ISpObjectTokenInit(ISpObjectTokenInitVtbl): ISpObjectToken(ISpObjectTokenVtbl) { fn InitFromDataKey( pszCategoryId: LPCWSTR, pszTokenId: LPCWSTR, pDataKey: *mut ISpDataKey, ) -> HRESULT, -}); -RIDL!(#[uuid(0x06b64f9e, 0x7fda, 0x11d2, 0xb4, 0xf2, 0x00, 0xc0, 0x4f, 0x79, 0x73, 0x96)] +}} +RIDL!{#[uuid(0x06b64f9e, 0x7fda, 0x11d2, 0xb4, 0xf2, 0x00, 0xc0, 0x4f, 0x79, 0x73, 0x96)] interface IEnumSpObjectTokens(IEnumSpObjectTokensVtbl): IUnknown(IUnknownVtbl) { fn Next( celt: ULONG, @@ -400,8 +401,8 @@ fn GetCount( pCount: *mut ULONG, ) -> HRESULT, -}); -RIDL!(#[uuid(0x5b559f40, 0xe952, 0x11d2, 0xbb, 0x91, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0xc0)] +}} +RIDL!{#[uuid(0x5b559f40, 0xe952, 0x11d2, 0xbb, 0x91, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0xc0)] interface ISpObjectWithToken(ISpObjectWithTokenVtbl): IUnknown(IUnknownVtbl) { fn SetObjectToken( pToken: *mut ISpObjectToken, @@ -409,8 +410,8 @@ fn GetObjectToken( ppToken: *mut *mut ISpObjectToken, ) -> HRESULT, -}); -RIDL!(#[uuid(0x93384e18, 0x5014, 0x43d5, 0xad, 0xbb, 0xa7, 0x8e, 0x05, 0x59, 0x26, 0xbd)] +}} +RIDL!{#[uuid(0x93384e18, 0x5014, 0x43d5, 0xad, 0xbb, 0xa7, 0x8e, 0x05, 0x59, 0x26, 0xbd)] interface ISpResourceManager(ISpResourceManagerVtbl): IServiceProvider(IServiceProviderVtbl) { fn SetObject( guidServiceId: REFGUID, @@ -423,7 +424,7 @@ fReleaseWhenLastExternalRefReleased: BOOL, ppObject: *mut *mut c_void, ) -> HRESULT, -}); +}} ENUM!{enum SPEVENTLPARAMTYPE { SPET_LPARAM_IS_UNDEFINED = 0, SPET_LPARAM_IS_TOKEN, @@ -560,7 +561,7 @@ ullQueuedInterest: ULONGLONG, ulCount: ULONG, }} -RIDL!(#[uuid(0xbe7a9cce, 0x5f9e, 0x11d2, 0x96, 0x0f, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0x28)] +RIDL!{#[uuid(0xbe7a9cce, 0x5f9e, 0x11d2, 0x96, 0x0f, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0x28)] interface ISpEventSource(ISpEventSourceVtbl): ISpNotifySource(ISpNotifySourceVtbl) { fn SetInterest( ullEventInterest: ULONGLONG, @@ -574,8 +575,8 @@ fn GetInfo( pInfo: *mut SPEVENTSOURCEINFO, ) -> HRESULT, -}); -RIDL!(#[uuid(0xbe7a9cc9, 0x5f9e, 0x11d2, 0x96, 0x0f, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0x28)] +}} +RIDL!{#[uuid(0xbe7a9cc9, 0x5f9e, 0x11d2, 0x96, 0x0f, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0x28)] interface ISpEventSink(ISpEventSinkVtbl): IUnknown(IUnknownVtbl) { fn AddEvents( pEventArray: *const SPEVENT, @@ -584,14 +585,14 @@ fn GetEventInterest( pullEventInterest: *mut ULONGLONG, ) -> HRESULT, -}); -RIDL!(#[uuid(0xbed530be, 0x2606, 0x4f4d, 0xa1, 0xc0, 0x54, 0xc5, 0xcd, 0xa5, 0x56, 0x6f)] +}} +RIDL!{#[uuid(0xbed530be, 0x2606, 0x4f4d, 0xa1, 0xc0, 0x54, 0xc5, 0xcd, 0xa5, 0x56, 0x6f)] interface ISpStreamFormat(ISpStreamFormatVtbl): IStream(IStreamVtbl) { fn GetFormat( pguidFormatId: *mut GUID, ppCoMemWaveFormatEx: *mut *mut WAVEFORMATEX, ) -> HRESULT, -}); +}} ENUM!{enum SPFILEMODE { SPFM_OPEN_READONLY, SPFM_OPEN_READWRITE, @@ -599,7 +600,7 @@ SPFM_CREATE_ALWAYS, SPFM_NUM_MODES, }} -RIDL!(#[uuid(0x12e3cca9, 0x7518, 0x44c5, 0xa5, 0xe7, 0xba, 0x5a, 0x79, 0xcb, 0x92, 0x9e)] +RIDL!{#[uuid(0x12e3cca9, 0x7518, 0x44c5, 0xa5, 0xe7, 0xba, 0x5a, 0x79, 0xcb, 0x92, 0x9e)] interface ISpStream(ISpStreamVtbl): ISpStreamFormat(ISpStreamFormatVtbl) { fn SetBaseStream( pStream: *mut IStream, @@ -617,8 +618,8 @@ ullEventInterest: ULONGLONG, ) -> HRESULT, fn Close() -> HRESULT, -}); -RIDL!(#[uuid(0x678a932c, 0xea71, 0x4446, 0x9b, 0x41, 0x78, 0xfd, 0xa6, 0x28, 0x0a, 0x29)] +}} +RIDL!{#[uuid(0x678a932c, 0xea71, 0x4446, 0x9b, 0x41, 0x78, 0xfd, 0xa6, 0x28, 0x0a, 0x29)] interface ISpStreamFormatConverter(ISpStreamFormatConverterVtbl): ISpStreamFormat(ISpStreamFormatVtbl) { fn SetBaseStream( @@ -642,7 +643,7 @@ ullOffsetBaseStream: ULONGLONG, pullOffsetConvertedStream: *mut ULONGLONG, ) -> HRESULT, -}); +}} ENUM!{enum SPAUDIOSTATE { SPAS_CLOSED, SPAS_STOP, @@ -663,7 +664,7 @@ ulMsBufferSize: ULONG, ulMsEventBias: ULONG, }} -RIDL!(#[uuid(0xc05c768f, 0xfae8, 0x4ec2, 0x8e, 0x07, 0x33, 0x83, 0x21, 0xc1, 0x24, 0x52)] +RIDL!{#[uuid(0xc05c768f, 0xfae8, 0x4ec2, 0x8e, 0x07, 0x33, 0x83, 0x21, 0xc1, 0x24, 0x52)] interface ISpAudio(ISpAudioVtbl): ISpStreamFormat(ISpStreamFormatVtbl) { fn SetState( NewState: SPAUDIOSTATE, @@ -699,8 +700,8 @@ fn SetBufferNotifySize( cbSize: ULONG, ) -> HRESULT, -}); -RIDL!(#[uuid(0x15806f6e, 0x1d70, 0x4b48, 0x98, 0xe6, 0x3b, 0x1a, 0x00, 0x75, 0x09, 0xab)] +}} +RIDL!{#[uuid(0x15806f6e, 0x1d70, 0x4b48, 0x98, 0xe6, 0x3b, 0x1a, 0x00, 0x75, 0x09, 0xab)] interface ISpMMSysAudio(ISpMMSysAudioVtbl): ISpAudio(ISpAudioVtbl) { fn GetDeviceId( puDeviceId: *mut UINT, @@ -717,8 +718,8 @@ fn SetLineId( uLineId: UINT, ) -> HRESULT, -}); -RIDL!(#[uuid(0x10f63bce, 0x201a, 0x11d3, 0xac, 0x70, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0xc0)] +}} +RIDL!{#[uuid(0x10f63bce, 0x201a, 0x11d3, 0xac, 0x70, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0xc0)] interface ISpTranscript(ISpTranscriptVtbl): IUnknown(IUnknownVtbl) { fn GetTranscript( ppszTranscript: *mut LPWSTR, @@ -726,7 +727,7 @@ fn AppendTranscript( pszTranscript: LPCWSTR, ) -> HRESULT, -}); +}} ENUM!{enum SPDISPLAYATTRIBUTES { SPAF_ONE_TRAILING_SPACE = 0x2, SPAF_TWO_TRAILING_SPACES = 0x4, @@ -835,7 +836,7 @@ }} pub const SP_GETWHOLEPHRASE: SPPHRASERNG = SPPR_ALL_ELEMENTS; pub const SPRR_ALL_ELEMENTS: SPPHRASERNG = SPPR_ALL_ELEMENTS; -DECLARE_HANDLE!(SPSTATEHANDLE, SPSTATEHANDLE__); +DECLARE_HANDLE!{SPSTATEHANDLE, SPSTATEHANDLE__} ENUM!{enum SPRECOEVENTFLAGS { SPREF_AutoPause = 1 << 0, SPREF_Emulated = 1 << 1, @@ -913,7 +914,7 @@ pvBuffer: *mut BYTE, pFirstWord: *mut SPWORD, }} -RIDL!(#[uuid(0xda41a7c2, 0x5383, 0x4db2, 0x91, 0x6b, 0x6c, 0x17, 0x19, 0xe3, 0xdb, 0x58)] +RIDL!{#[uuid(0xda41a7c2, 0x5383, 0x4db2, 0x91, 0x6b, 0x6c, 0x17, 0x19, 0xe3, 0xdb, 0x58)] interface ISpLexicon(ISpLexiconVtbl): IUnknown(IUnknownVtbl) { fn GetPronunciations( pszWord: LPCWSTR, @@ -947,15 +948,15 @@ pdwCookie: *mut DWORD, pWordList: *mut SPWORDLIST, ) -> HRESULT, -}); -RIDL!(#[uuid(0x8565572f, 0xc094, 0x41cc, 0xb5, 0x6e, 0x10, 0xbd, 0x9c, 0x3f, 0xf0, 0x44)] +}} +RIDL!{#[uuid(0x8565572f, 0xc094, 0x41cc, 0xb5, 0x6e, 0x10, 0xbd, 0x9c, 0x3f, 0xf0, 0x44)] interface ISpContainerLexicon(ISpContainerLexiconVtbl): ISpLexicon(ISpLexiconVtbl) { fn AddLexicon( pAddLexicon: *mut ISpLexicon, dwFlags: DWORD, ) -> HRESULT, -}); -RIDL!(#[uuid(0x8445c581, 0x0cac, 0x4a38, 0xab, 0xfe, 0x9b, 0x2c, 0xe2, 0x82, 0x64, 0x55)] +}} +RIDL!{#[uuid(0x8445c581, 0x0cac, 0x4a38, 0xab, 0xfe, 0x9b, 0x2c, 0xe2, 0x82, 0x64, 0x55)] interface ISpPhoneConverter(ISpPhoneConverterVtbl): ISpObjectWithToken(ISpObjectWithTokenVtbl) { fn PhoneToId( pszPhone: LPCWSTR, @@ -965,7 +966,7 @@ pId: PCSPPHONEID, pszPhone: *mut WCHAR, ) -> HRESULT, -}); +}} STRUCT!{struct SPVPITCH { MiddleAdj: c_long, RangeAdj: c_long, @@ -1042,7 +1043,7 @@ | SPF_NLP_MASK | SPF_PERSIST_XML, SPF_UNUSED_FLAGS = !SPF_VOICE_MASK, }} -RIDL!(#[uuid(0x6c44df74, 0x72b9, 0x4992, 0xa1, 0xec, 0xef, 0x99, 0x6e, 0x04, 0x22, 0xd4)] +RIDL!{#[uuid(0x6c44df74, 0x72b9, 0x4992, 0xa1, 0xec, 0xef, 0x99, 0x6e, 0x04, 0x22, 0xd4)] interface ISpVoice(ISpVoiceVtbl): ISpEventSource(ISpEventSourceVtbl) { fn SetOutput( pUnkOutput: *mut IUnknown, @@ -1128,8 +1129,8 @@ pvExtraData: *mut c_void, cbExtraData: ULONG, ) -> HRESULT, -}); -RIDL!(#[uuid(0x1a5c0354, 0xb621, 0x4b5a, 0x87, 0x91, 0xd3, 0x06, 0xed, 0x37, 0x9e, 0x53)] +}} +RIDL!{#[uuid(0x1a5c0354, 0xb621, 0x4b5a, 0x87, 0x91, 0xd3, 0x06, 0xed, 0x37, 0x9e, 0x53)] interface ISpPhrase(ISpPhraseVtbl): IUnknown(IUnknownVtbl) { fn GetPhrase( ppCoMemPhrase: *mut *mut SPPHRASE, @@ -1147,8 +1148,8 @@ fn Discard( dwValueTypes: DWORD, ) -> HRESULT, -}); -RIDL!(#[uuid(0x8fcebc98, 0x4e49, 0x4067, 0x9c, 0x6c, 0xd8, 0x6a, 0x0e, 0x09, 0x2e, 0x3d)] +}} +RIDL!{#[uuid(0x8fcebc98, 0x4e49, 0x4067, 0x9c, 0x6c, 0xd8, 0x6a, 0x0e, 0x09, 0x2e, 0x3d)] interface ISpPhraseAlt(ISpPhraseAltVtbl): ISpPhrase(ISpPhraseVtbl) { fn GetAltInfo( pParent: *mut *mut ISpPhrase, @@ -1157,7 +1158,7 @@ pcElementsInAlt: *mut ULONG, ) -> HRESULT, fn Commit() -> HRESULT, -}); +}} STRUCT!{struct SPRECORESULTTIMES { ftStreamTime: FILETIME, ullLength: ULONGLONG, @@ -1167,7 +1168,7 @@ STRUCT!{struct SPSERIALIZEDRESULT { ulSerializedSize: ULONG, }} -RIDL!(#[uuid(0x20b053be, 0xe235, 0x43cd, 0x9a, 0x2a, 0x8d, 0x17, 0xa4, 0x8b, 0x78, 0x42)] +RIDL!{#[uuid(0x20b053be, 0xe235, 0x43cd, 0x9a, 0x2a, 0x8d, 0x17, 0xa4, 0x8b, 0x78, 0x42)] interface ISpRecoResult(ISpRecoResultVtbl): ISpPhrase(ISpPhraseVtbl) { fn GetResultTimes( pTimes: *mut SPRECORESULTTIMES, @@ -1200,7 +1201,7 @@ fn GetRecoContext( ppRecoContext: *mut *mut ISpRecoContext, ) -> HRESULT, -}); +}} STRUCT!{struct SPTEXTSELECTIONINFO { ulStartActiveOffset: ULONG, cchActiveChars: ULONG, @@ -1252,7 +1253,7 @@ SPRAF_Dynamic = 1 << 5, SPRAF_AutoPause = 1 << 16, }} -RIDL!(#[uuid(0x8137828f, 0x591a, 0x4a42, 0xbe, 0x58, 0x49, 0xea, 0x7e, 0xba, 0xac, 0x68)] +RIDL!{#[uuid(0x8137828f, 0x591a, 0x4a42, 0xbe, 0x58, 0x49, 0xea, 0x7e, 0xba, 0xac, 0x68)] interface ISpGrammarBuilder(ISpGrammarBuilderVtbl): IUnknown(IUnknownVtbl) { fn ResetGrammar( NewLanguage: WORD, @@ -1295,12 +1296,12 @@ fn Commit( dwReserved: DWORD, ) -> HRESULT, -}); +}} ENUM!{enum SPLOADOPTIONS { SPLO_STATIC = 0, SPLO_DYNAMIC = 1, }} -RIDL!(#[uuid(0x2177db29, 0x7f45, 0x47d0, 0x85, 0x54, 0x06, 0x7e, 0x91, 0xc8, 0x05, 0x02)] +RIDL!{#[uuid(0x2177db29, 0x7f45, 0x47d0, 0x85, 0x54, 0x06, 0x7e, 0x91, 0xc8, 0x05, 0x02)] interface ISpRecoGrammar(ISpRecoGrammarVtbl): ISpGrammarBuilder(ISpGrammarBuilderVtbl) { fn GetGrammarId( pullGrammarId: *mut ULONGLONG, @@ -1374,7 +1375,7 @@ fn GetGrammarState( peGrammarState: *mut SPGRAMMARSTATE, ) -> HRESULT, -}); +}} STRUCT!{struct SPRECOCONTEXTSTATUS { eInterference: SPINTERFERENCE, szRequestTypeOfUI: [WCHAR; 255], @@ -1389,7 +1390,7 @@ SPAO_NONE = 0, SPAO_RETAIN_AUDIO = 1 << 0, }} -RIDL!(#[uuid(0xf740a62f, 0x7c15, 0x489e, 0x82, 0x34, 0x94, 0x0a, 0x33, 0xd9, 0x27, 0x2d)] +RIDL!{#[uuid(0xf740a62f, 0x7c15, 0x489e, 0x82, 0x34, 0x94, 0x0a, 0x33, 0xd9, 0x27, 0x2d)] interface ISpRecoContext(ISpRecoContextVtbl): ISpEventSource(ISpEventSourceVtbl) { fn GetRecognizer( ppRecognizer: *mut *mut ISpRecognizer, @@ -1455,8 +1456,8 @@ fn GetContextState( peContextState: *mut SPCONTEXTSTATE, ) -> HRESULT, -}); -RIDL!(#[uuid(0x5b4fb971, 0xb115, 0x4de1, 0xad, 0x97, 0xe4, 0x82, 0xe3, 0xbf, 0x6e, 0xe4)] +}} +RIDL!{#[uuid(0x5b4fb971, 0xb115, 0x4de1, 0xad, 0x97, 0xe4, 0x82, 0xe3, 0xbf, 0x6e, 0xe4)] interface ISpProperties(ISpPropertiesVtbl): IUnknown(IUnknownVtbl) { fn SetPropertyNum( pName: LPCWSTR, @@ -1474,7 +1475,7 @@ pName: LPCWSTR, ppCoMemValue: *mut LPWSTR, ) -> HRESULT, -}); +}} pub const SP_MAX_LANGIDS: usize = 20; STRUCT!{struct SPRECOGNIZERSTATUS { AudioStatus: SPAUDIOSTATUS, @@ -1498,7 +1499,7 @@ SPRST_INACTIVE_WITH_PURGE, SPRST_NUM_STATES, }} -RIDL!(#[uuid(0xc2b5f241, 0xdaa0, 0x4507, 0x9e, 0x16, 0x5a, 0x1e, 0xaa, 0x2b, 0x7a, 0x5c)] +RIDL!{#[uuid(0xc2b5f241, 0xdaa0, 0x4507, 0x9e, 0x16, 0x5a, 0x1e, 0xaa, 0x2b, 0x7a, 0x5c)] interface ISpRecognizer(ISpRecognizerVtbl): ISpProperties(ISpPropertiesVtbl) { fn SetRecognizer( pRecognizer: *mut ISpObjectToken, @@ -1556,7 +1557,7 @@ fn EmulateRecognition( pPhrase: *mut ISpPhrase, ) -> HRESULT, -}); +}} pub type SpeechLanguageId = c_long; ENUM!{enum DISPID_SpeechDataKey { DISPID_SDKSetBinaryValue = 1, @@ -2311,7 +2312,7 @@ extern { pub static LIBID_SpeechLib: IID; } -RIDL!(#[uuid(0xce17c09b, 0x4efa, 0x44d5, 0xa4, 0xc9, 0x59, 0xd9, 0x58, 0x5a, 0xb0, 0xcd)] +RIDL!{#[uuid(0xce17c09b, 0x4efa, 0x44d5, 0xa4, 0xc9, 0x59, 0xd9, 0x58, 0x5a, 0xb0, 0xcd)] interface ISpeechDataKey(ISpeechDataKeyVtbl): IDispatch(IDispatchVtbl) { fn SetBinaryValue( ValueName: BSTR, @@ -2359,8 +2360,8 @@ Index: c_long, ValueName: *mut BSTR, ) -> HRESULT, -}); -RIDL!(#[uuid(0xc74a3adc, 0xb727, 0x4500, 0xa8, 0x4a, 0xb5, 0x26, 0x72, 0x1c, 0x8b, 0x8c)] +}} +RIDL!{#[uuid(0xc74a3adc, 0xb727, 0x4500, 0xa8, 0x4a, 0xb5, 0x26, 0x72, 0x1c, 0x8b, 0x8c)] interface ISpeechObjectToken(ISpeechObjectTokenVtbl): IDispatch(IDispatchVtbl) { fn get_Id( ObjectId: *mut BSTR, @@ -2421,8 +2422,8 @@ Attributes: BSTR, Matches: *mut VARIANT_BOOL, ) -> HRESULT, -}); -RIDL!(#[uuid(0x9285b776, 0x2e7b, 0x4bc0, 0xb5, 0x3e, 0x58, 0x0e, 0xb6, 0xfa, 0x96, 0x7f)] +}} +RIDL!{#[uuid(0x9285b776, 0x2e7b, 0x4bc0, 0xb5, 0x3e, 0x58, 0x0e, 0xb6, 0xfa, 0x96, 0x7f)] interface ISpeechObjectTokens(ISpeechObjectTokensVtbl): IDispatch(IDispatchVtbl) { fn get_Count( Count: *mut c_long, @@ -2434,8 +2435,8 @@ fn get__NewEnum( ppEnumVARIANT: *mut *mut IUnknown, ) -> HRESULT, -}); -RIDL!(#[uuid(0xca7eac50, 0x2d01, 0x4145, 0x86, 0xd4, 0x5a, 0xe7, 0xd7, 0x0f, 0x44, 0x69)] +}} +RIDL!{#[uuid(0xca7eac50, 0x2d01, 0x4145, 0x86, 0xd4, 0x5a, 0xe7, 0xd7, 0x0f, 0x44, 0x69)] interface ISpeechObjectTokenCategory(ISpeechObjectTokenCategoryVtbl): IDispatch(IDispatchVtbl) { fn get_Id( Id: *mut BSTR, @@ -2459,8 +2460,8 @@ OptionalAttributes: BSTR, Tokens: *mut *mut ISpeechObjectTokens, ) -> HRESULT, -}); -RIDL!(#[uuid(0x11b103d8, 0x1142, 0x4edf, 0xa0, 0x93, 0x82, 0xfb, 0x39, 0x15, 0xf8, 0xcc)] +}} +RIDL!{#[uuid(0x11b103d8, 0x1142, 0x4edf, 0xa0, 0x93, 0x82, 0xfb, 0x39, 0x15, 0xf8, 0xcc)] interface ISpeechAudioBufferInfo(ISpeechAudioBufferInfoVtbl): IDispatch(IDispatchVtbl) { fn get_MinNotification( MinNotification: *mut c_long, @@ -2480,8 +2481,8 @@ fn put_EventBias( EventBias: c_long, ) -> HRESULT, -}); -RIDL!(#[uuid(0xc62d9c91, 0x7458, 0x47f6, 0x86, 0x2d, 0x1e, 0xf8, 0x6f, 0xb0, 0xb2, 0x78)] +}} +RIDL!{#[uuid(0xc62d9c91, 0x7458, 0x47f6, 0x86, 0x2d, 0x1e, 0xf8, 0x6f, 0xb0, 0xb2, 0x78)] interface ISpeechAudioStatus(ISpeechAudioStatusVtbl): IDispatch(IDispatchVtbl) { fn get_FreeBufferSpace( FreeBufferSpace: *mut c_long, @@ -2498,8 +2499,8 @@ fn get_CurrentDevicePosition( CurrentDevicePosition: *mut VARIANT, ) -> HRESULT, -}); -RIDL!(#[uuid(0xe6e9c590, 0x3e18, 0x40e3, 0x82, 0x99, 0x06, 0x1f, 0x98, 0xbd, 0xe7, 0xc7)] +}} +RIDL!{#[uuid(0xe6e9c590, 0x3e18, 0x40e3, 0x82, 0x99, 0x06, 0x1f, 0x98, 0xbd, 0xe7, 0xc7)] interface ISpeechAudioFormat(ISpeechAudioFormatVtbl): IDispatch(IDispatchVtbl) { fn get_Type( AudioFormat: *mut SpeechAudioFormatType, @@ -2519,8 +2520,8 @@ fn SetWaveFormatEx( SpeechWaveFormatEx: *mut ISpeechWaveFormatEx, ) -> HRESULT, -}); -RIDL!(#[uuid(0x7a1ef0d5, 0x1581, 0x4741, 0x88, 0xe4, 0x20, 0x9a, 0x49, 0xf1, 0x1a, 0x10)] +}} +RIDL!{#[uuid(0x7a1ef0d5, 0x1581, 0x4741, 0x88, 0xe4, 0x20, 0x9a, 0x49, 0xf1, 0x1a, 0x10)] interface ISpeechWaveFormatEx(ISpeechWaveFormatExVtbl): IDispatch(IDispatchVtbl) { fn get_FormatTag( FormatTag: *mut c_short, @@ -2564,8 +2565,8 @@ fn put_ExtraData( ExtraData: VARIANT, ) -> HRESULT, -}); -RIDL!(#[uuid(0x6450336f, 0x7d49, 0x4ced, 0x80, 0x97, 0x49, 0xd6, 0xde, 0xe3, 0x72, 0x94)] +}} +RIDL!{#[uuid(0x6450336f, 0x7d49, 0x4ced, 0x80, 0x97, 0x49, 0xd6, 0xde, 0xe3, 0x72, 0x94)] interface ISpeechBaseStream(ISpeechBaseStreamVtbl): IDispatch(IDispatchVtbl) { fn get_Format( AudioFormat: *mut *mut ISpeechAudioFormat, @@ -2587,8 +2588,8 @@ Origin: SpeechStreamSeekPositionType, NewPosition: *mut VARIANT, ) -> HRESULT, -}); -RIDL!(#[uuid(0xaf67f125, 0xab39, 0x4e93, 0xb4, 0xa2, 0xcc, 0x2e, 0x66, 0xe1, 0x82, 0xa7)] +}} +RIDL!{#[uuid(0xaf67f125, 0xab39, 0x4e93, 0xb4, 0xa2, 0xcc, 0x2e, 0x66, 0xe1, 0x82, 0xa7)] interface ISpeechFileStream(ISpeechFileStreamVtbl): ISpeechBaseStream(ISpeechBaseStreamVtbl) { fn Open( FileName: BSTR, @@ -2596,8 +2597,8 @@ DoEvents: VARIANT_BOOL, ) -> HRESULT, fn Close() -> HRESULT, -}); -RIDL!(#[uuid(0xeeb14b68, 0x808b, 0x4abe, 0xa5, 0xea, 0xb5, 0x1d, 0xa7, 0x58, 0x80, 0x08)] +}} +RIDL!{#[uuid(0xeeb14b68, 0x808b, 0x4abe, 0xa5, 0xea, 0xb5, 0x1d, 0xa7, 0x58, 0x80, 0x08)] interface ISpeechMemoryStream(ISpeechMemoryStreamVtbl): ISpeechBaseStream(ISpeechBaseStreamVtbl) { fn SetData( Data: VARIANT, @@ -2605,8 +2606,8 @@ fn GetData( pData: *mut VARIANT, ) -> HRESULT, -}); -RIDL!(#[uuid(0x1a9e9f4f, 0x104f, 0x4db8, 0xa1, 0x15, 0xef, 0xd7, 0xfd, 0x0c, 0x97, 0xae)] +}} +RIDL!{#[uuid(0x1a9e9f4f, 0x104f, 0x4db8, 0xa1, 0x15, 0xef, 0xd7, 0xfd, 0x0c, 0x97, 0xae)] interface ISpeechCustomStream(ISpeechCustomStreamVtbl): ISpeechBaseStream(ISpeechBaseStreamVtbl) { fn get_BaseStream( ppUnkStream: *mut *mut IUnknown, @@ -2614,8 +2615,8 @@ fn putref_BaseStream( pUnkStream: *mut IUnknown, ) -> HRESULT, -}); -RIDL!(#[uuid(0xcff8e175, 0x019e, 0x11d3, 0xa0, 0x8e, 0x00, 0xc0, 0x4f, 0x8e, 0xf9, 0xb5)] +}} +RIDL!{#[uuid(0xcff8e175, 0x019e, 0x11d3, 0xa0, 0x8e, 0x00, 0xc0, 0x4f, 0x8e, 0xf9, 0xb5)] interface ISpeechAudio(ISpeechAudioVtbl): ISpeechBaseStream(ISpeechBaseStreamVtbl) { fn get_Status( Status: *mut *mut ISpeechAudioStatus, @@ -2644,8 +2645,8 @@ fn SetState( State: SpeechAudioState, ) -> HRESULT, -}); -RIDL!(#[uuid(0x3c76af6d, 0x1fd7, 0x4831, 0x81, 0xd1, 0x3b, 0x71, 0xd5, 0xa1, 0x3c, 0x44)] +}} +RIDL!{#[uuid(0x3c76af6d, 0x1fd7, 0x4831, 0x81, 0xd1, 0x3b, 0x71, 0xd5, 0xa1, 0x3c, 0x44)] interface ISpeechMMSysAudio(ISpeechMMSysAudioVtbl): ISpeechAudio(ISpeechAudioVtbl) { fn get_DeviceId( DeviceId: *mut c_long, @@ -2662,8 +2663,8 @@ fn get_MMHandle( Handle: *mut c_long, ) -> HRESULT, -}); -RIDL!(#[uuid(0x269316d8, 0x57bd, 0x11d2, 0x9e, 0xee, 0x00, 0xc0, 0x4f, 0x79, 0x73, 0x96)] +}} +RIDL!{#[uuid(0x269316d8, 0x57bd, 0x11d2, 0x9e, 0xee, 0x00, 0xc0, 0x4f, 0x79, 0x73, 0x96)] interface ISpeechVoice(ISpeechVoiceVtbl): IDispatch(IDispatchVtbl) { fn get_Status( Status: *mut *mut ISpeechVoiceStatus, @@ -2773,8 +2774,8 @@ TypeOfUI: BSTR, ExtraData: *const VARIANT, ) -> HRESULT, -}); -RIDL!(#[uuid(0x8be47b07, 0x57f6, 0x11d2, 0x9e, 0xee, 0x00, 0xc0, 0x4f, 0x79, 0x73, 0x96)] +}} +RIDL!{#[uuid(0x8be47b07, 0x57f6, 0x11d2, 0x9e, 0xee, 0x00, 0xc0, 0x4f, 0x79, 0x73, 0x96)] interface ISpeechVoiceStatus(ISpeechVoiceStatusVtbl): IDispatch(IDispatchVtbl) { fn get_CurrentStreamNumber( StreamNumber: *mut c_long, @@ -2812,11 +2813,11 @@ fn get_VisemeId( VisemeId: *mut c_short, ) -> HRESULT, -}); -RIDL!(#[uuid(0xa372acd1, 0x3bef, 0x4bbd, 0x8f, 0xfb, 0xcb, 0x3e, 0x2b, 0x41, 0x6a, 0xf8)] +}} +RIDL!{#[uuid(0xa372acd1, 0x3bef, 0x4bbd, 0x8f, 0xfb, 0xcb, 0x3e, 0x2b, 0x41, 0x6a, 0xf8)] interface _ISpeechVoiceEvents(_ISpeechVoiceEventsVtbl): IDispatch(IDispatchVtbl) { -}); -RIDL!(#[uuid(0x2d5f1c0c, 0xbd75, 0x4b08, 0x94, 0x78, 0x3b, 0x11, 0xfe, 0xa2, 0x58, 0x6c)] +}} +RIDL!{#[uuid(0x2d5f1c0c, 0xbd75, 0x4b08, 0x94, 0x78, 0x3b, 0x11, 0xfe, 0xa2, 0x58, 0x6c)] interface ISpeechRecognizer(ISpeechRecognizerVtbl): IDispatch(IDispatchVtbl) { fn putref_Recognizer( Recognizer: *mut ISpeechObjectToken, @@ -2918,8 +2919,8 @@ OptionalAttributes: BSTR, ObjectTokens: *mut *mut ISpeechObjectTokens, ) -> HRESULT, -}); -RIDL!(#[uuid(0xbff9e781, 0x53ec, 0x484e, 0xbb, 0x8a, 0x0e, 0x1b, 0x55, 0x51, 0xe3, 0x5c)] +}} +RIDL!{#[uuid(0xbff9e781, 0x53ec, 0x484e, 0xbb, 0x8a, 0x0e, 0x1b, 0x55, 0x51, 0xe3, 0x5c)] interface ISpeechRecognizerStatus(ISpeechRecognizerStatusVtbl): IDispatch(IDispatchVtbl) { fn get_AudioStatus( AudioStatus: *mut *mut ISpeechAudioStatus, @@ -2939,8 +2940,8 @@ fn get_SupportedLanguages( SupportedLanguages: *mut VARIANT, ) -> HRESULT, -}); -RIDL!(#[uuid(0x580aa49d, 0x7e1e, 0x4809, 0xb8, 0xe2, 0x57, 0xda, 0x80, 0x61, 0x04, 0xb8)] +}} +RIDL!{#[uuid(0x580aa49d, 0x7e1e, 0x4809, 0xb8, 0xe2, 0x57, 0xda, 0x80, 0x61, 0x04, 0xb8)] interface ISpeechRecoContext(ISpeechRecoContextVtbl): IDispatch(IDispatchVtbl) { fn get_Recognizer( Recognizer: *mut *mut ISpeechRecognizer, @@ -3017,8 +3018,8 @@ fn SetAdaptationData( AdaptationString: BSTR, ) -> HRESULT, -}); -RIDL!(#[uuid(0xb6d6f79f, 0x2158, 0x4e50, 0xb5, 0xbc, 0x9a, 0x9c, 0xcd, 0x85, 0x2a, 0x09)] +}} +RIDL!{#[uuid(0xb6d6f79f, 0x2158, 0x4e50, 0xb5, 0xbc, 0x9a, 0x9c, 0xcd, 0x85, 0x2a, 0x09)] interface ISpeechRecoGrammar(ISpeechRecoGrammarVtbl): IDispatch(IDispatchVtbl) { fn get_Id( Id: *mut VARIANT, @@ -3092,11 +3093,11 @@ Word: BSTR, WordPronounceable: *mut SpeechWordPronounceable, ) -> HRESULT, -}); -RIDL!(#[uuid(0x7b8fcb42, 0x0e9d, 0x4f00, 0xa0, 0x48, 0x7b, 0x04, 0xd6, 0x17, 0x9d, 0x3d)] +}} +RIDL!{#[uuid(0x7b8fcb42, 0x0e9d, 0x4f00, 0xa0, 0x48, 0x7b, 0x04, 0xd6, 0x17, 0x9d, 0x3d)] interface _ISpeechRecoContextEvents(_ISpeechRecoContextEventsVtbl): IDispatch(IDispatchVtbl) { -}); -RIDL!(#[uuid(0xafe719cf, 0x5dd1, 0x44f2, 0x99, 0x9c, 0x7a, 0x39, 0x9f, 0x1c, 0xfc, 0xcc)] +}} +RIDL!{#[uuid(0xafe719cf, 0x5dd1, 0x44f2, 0x99, 0x9c, 0x7a, 0x39, 0x9f, 0x1c, 0xfc, 0xcc)] interface ISpeechGrammarRule(ISpeechGrammarRuleVtbl): IDispatch(IDispatchVtbl) { fn get_Attributes( Attributes: *mut SpeechRuleAttributes, @@ -3118,8 +3119,8 @@ fn AddState( State: *mut *mut ISpeechGrammarRuleState, ) -> HRESULT, -}); -RIDL!(#[uuid(0x6ffa3b44, 0xfc2d, 0x40d1, 0x8a, 0xfc, 0x32, 0x91, 0x1c, 0x7f, 0x1a, 0xd1)] +}} +RIDL!{#[uuid(0x6ffa3b44, 0xfc2d, 0x40d1, 0x8a, 0xfc, 0x32, 0x91, 0x1c, 0x7f, 0x1a, 0xd1)] interface ISpeechGrammarRules(ISpeechGrammarRulesVtbl): IDispatch(IDispatchVtbl) { fn get_Count( Count: *mut c_long, @@ -3149,8 +3150,8 @@ ErrorText: *mut BSTR, SaveStream: *mut VARIANT, ) -> HRESULT, -}); -RIDL!(#[uuid(0xd4286f2c, 0xee67, 0x45ae, 0xb9, 0x28, 0x28, 0xd6, 0x95, 0x36, 0x2e, 0xda)] +}} +RIDL!{#[uuid(0xd4286f2c, 0xee67, 0x45ae, 0xb9, 0x28, 0x28, 0xd6, 0x95, 0x36, 0x2e, 0xda)] interface ISpeechGrammarRuleState(ISpeechGrammarRuleStateVtbl): IDispatch(IDispatchVtbl) { fn get_Rule( Rule: *mut *mut ISpeechGrammarRule, @@ -3184,8 +3185,8 @@ PropertyValue: *mut VARIANT, Weight: c_float, ) -> HRESULT, -}); -RIDL!(#[uuid(0xcafd1db1, 0x41d1, 0x4a06, 0x98, 0x63, 0xe2, 0xe8, 0x1d, 0xa1, 0x7a, 0x9a)] +}} +RIDL!{#[uuid(0xcafd1db1, 0x41d1, 0x4a06, 0x98, 0x63, 0xe2, 0xe8, 0x1d, 0xa1, 0x7a, 0x9a)] interface ISpeechGrammarRuleStateTransition(ISpeechGrammarRuleStateTransitionVtbl): IDispatch(IDispatchVtbl) { fn get_Type( @@ -3212,8 +3213,8 @@ fn get_NextState( NextState: *mut *mut ISpeechGrammarRuleState, ) -> HRESULT, -}); -RIDL!(#[uuid(0xeabce657, 0x75bc, 0x44a2, 0xaa, 0x7f, 0xc5, 0x64, 0x76, 0x74, 0x29, 0x63)] +}} +RIDL!{#[uuid(0xeabce657, 0x75bc, 0x44a2, 0xaa, 0x7f, 0xc5, 0x64, 0x76, 0x74, 0x29, 0x63)] interface ISpeechGrammarRuleStateTransitions(ISpeechGrammarRuleStateTransitionsVtbl): IDispatch(IDispatchVtbl) { fn get_Count( @@ -3226,8 +3227,8 @@ fn get__NewEnum( EnumVARIANT: *mut *mut IUnknown, ) -> HRESULT, -}); -RIDL!(#[uuid(0x3b9c7e7a, 0x6eee, 0x4ded, 0x90, 0x92, 0x11, 0x65, 0x72, 0x79, 0xad, 0xbe)] +}} +RIDL!{#[uuid(0x3b9c7e7a, 0x6eee, 0x4ded, 0x90, 0x92, 0x11, 0x65, 0x72, 0x79, 0xad, 0xbe)] interface ISpeechTextSelectionInformation(ISpeechTextSelectionInformationVtbl): IDispatch(IDispatchVtbl) { fn put_ActiveOffset( @@ -3254,8 +3255,8 @@ fn get_SelectionLength( SelectionLength: *mut c_long, ) -> HRESULT, -}); -RIDL!(#[uuid(0xed2879cf, 0xced9, 0x4ee6, 0xa5, 0x34, 0xde, 0x01, 0x91, 0xd5, 0x46, 0x8d)] +}} +RIDL!{#[uuid(0xed2879cf, 0xced9, 0x4ee6, 0xa5, 0x34, 0xde, 0x01, 0x91, 0xd5, 0x46, 0x8d)] interface ISpeechRecoResult(ISpeechRecoResultVtbl): IDispatch(IDispatchVtbl) { fn get_RecoContext( RecoContext: *mut *mut ISpeechRecoContext, @@ -3295,8 +3296,8 @@ fn DiscardResultInfo( ValueTypes: SpeechDiscardType, ) -> HRESULT, -}); -RIDL!(#[uuid(0x62b3b8fb, 0xf6e7, 0x41be, 0xbd, 0xcb, 0x05, 0x6b, 0x1c, 0x29, 0xef, 0xc0)] +}} +RIDL!{#[uuid(0x62b3b8fb, 0xf6e7, 0x41be, 0xbd, 0xcb, 0x05, 0x6b, 0x1c, 0x29, 0xef, 0xc0)] interface ISpeechRecoResultTimes(ISpeechRecoResultTimesVtbl): IDispatch(IDispatchVtbl) { fn get_StreamTime( Time: *mut VARIANT, @@ -3310,8 +3311,8 @@ fn get_OffsetFromStart( OffsetFromStart: *mut VARIANT, ) -> HRESULT, -}); -RIDL!(#[uuid(0x27864a2a, 0x2b9f, 0x4cb8, 0x92, 0xd3, 0x0d, 0x27, 0x22, 0xfd, 0x1e, 0x73)] +}} +RIDL!{#[uuid(0x27864a2a, 0x2b9f, 0x4cb8, 0x92, 0xd3, 0x0d, 0x27, 0x22, 0xfd, 0x1e, 0x73)] interface ISpeechPhraseAlternate(ISpeechPhraseAlternateVtbl): IDispatch(IDispatchVtbl) { fn get_RecoResult( RecoResult: *mut *mut ISpeechRecoResult, @@ -3326,8 +3327,8 @@ PhraseInfo: *mut *mut ISpeechPhraseInfo, ) -> HRESULT, fn Commit() -> HRESULT, -}); -RIDL!(#[uuid(0xb238b6d5, 0xf276, 0x4c3d, 0xa6, 0xc1, 0x29, 0x74, 0x80, 0x1c, 0x3c, 0xc2)] +}} +RIDL!{#[uuid(0xb238b6d5, 0xf276, 0x4c3d, 0xa6, 0xc1, 0x29, 0x74, 0x80, 0x1c, 0x3c, 0xc2)] interface ISpeechPhraseAlternates(ISpeechPhraseAlternatesVtbl): IDispatch(IDispatchVtbl) { fn get_Count( Count: *mut c_long, @@ -3339,8 +3340,8 @@ fn get__NewEnum( EnumVARIANT: *mut *mut IUnknown, ) -> HRESULT, -}); -RIDL!(#[uuid(0x961559cf, 0x4e67, 0x4662, 0x8b, 0xf0, 0xd9, 0x3f, 0x1f, 0xcd, 0x61, 0xb3)] +}} +RIDL!{#[uuid(0x961559cf, 0x4e67, 0x4662, 0x8b, 0xf0, 0xd9, 0x3f, 0x1f, 0xcd, 0x61, 0xb3)] interface ISpeechPhraseInfo(ISpeechPhraseInfoVtbl): IDispatch(IDispatchVtbl) { fn get_LanguageId( LanguageId: *mut c_long, @@ -3396,8 +3397,8 @@ UseReplacements: VARIANT_BOOL, DisplayAttributes: *mut SpeechDisplayAttributes, ) -> HRESULT, -}); -RIDL!(#[uuid(0xe6176f96, 0xe373, 0x4801, 0xb2, 0x23, 0x3b, 0x62, 0xc0, 0x68, 0xc0, 0xb4)] +}} +RIDL!{#[uuid(0xe6176f96, 0xe373, 0x4801, 0xb2, 0x23, 0x3b, 0x62, 0xc0, 0x68, 0xc0, 0xb4)] interface ISpeechPhraseElement(ISpeechPhraseElementVtbl): IDispatch(IDispatchVtbl) { fn get_AudioTimeOffset( AudioTimeOffset: *mut c_long, @@ -3438,8 +3439,8 @@ fn get_EngineConfidence( EngineConfident: *mut c_float, ) -> HRESULT, -}); -RIDL!(#[uuid(0x0626b328, 0x3478, 0x467d, 0xa0, 0xb3, 0xd0, 0x85, 0x3b, 0x93, 0xdd, 0xa3)] +}} +RIDL!{#[uuid(0x0626b328, 0x3478, 0x467d, 0xa0, 0xb3, 0xd0, 0x85, 0x3b, 0x93, 0xdd, 0xa3)] interface ISpeechPhraseElements(ISpeechPhraseElementsVtbl): IDispatch(IDispatchVtbl) { fn get_Count( Count: *mut c_long, @@ -3451,8 +3452,8 @@ fn get__NewEnum( EnumVARIANT: *mut *mut IUnknown, ) -> HRESULT, -}); -RIDL!(#[uuid(0x2890a410, 0x53a7, 0x4fb5, 0x94, 0xec, 0x06, 0xd4, 0x99, 0x8e, 0x3d, 0x02)] +}} +RIDL!{#[uuid(0x2890a410, 0x53a7, 0x4fb5, 0x94, 0xec, 0x06, 0xd4, 0x99, 0x8e, 0x3d, 0x02)] interface ISpeechPhraseReplacement(ISpeechPhraseReplacementVtbl): IDispatch(IDispatchVtbl) { fn get_DisplayAttributes( DisplayAttributes: *mut SpeechDisplayAttributes, @@ -3466,8 +3467,8 @@ fn get_NumberOfElements( NumberOfElements: *mut c_long, ) -> HRESULT, -}); -RIDL!(#[uuid(0x38bc662f, 0x2257, 0x4525, 0x95, 0x9e, 0x20, 0x69, 0xd2, 0x59, 0x6c, 0x05)] +}} +RIDL!{#[uuid(0x38bc662f, 0x2257, 0x4525, 0x95, 0x9e, 0x20, 0x69, 0xd2, 0x59, 0x6c, 0x05)] interface ISpeechPhraseReplacements(ISpeechPhraseReplacementsVtbl): IDispatch(IDispatchVtbl) { fn get_Count( Count: *mut c_long, @@ -3479,8 +3480,8 @@ fn get__NewEnum( EnumVARIANT: *mut *mut IUnknown, ) -> HRESULT, -}); -RIDL!(#[uuid(0xce563d48, 0x961e, 0x4732, 0xa2, 0xe1, 0x37, 0x8a, 0x42, 0xb4, 0x30, 0xbe)] +}} +RIDL!{#[uuid(0xce563d48, 0x961e, 0x4732, 0xa2, 0xe1, 0x37, 0x8a, 0x42, 0xb4, 0x30, 0xbe)] interface ISpeechPhraseProperty(ISpeechPhrasePropertyVtbl): IDispatch(IDispatchVtbl) { fn get_Name( Name: *mut BSTR, @@ -3509,8 +3510,8 @@ fn get_Children( Children: *mut *mut ISpeechPhraseProperties, ) -> HRESULT, -}); -RIDL!(#[uuid(0x08166b47, 0x102e, 0x4b23, 0xa5, 0x99, 0xbd, 0xb9, 0x8d, 0xbf, 0xd1, 0xf4)] +}} +RIDL!{#[uuid(0x08166b47, 0x102e, 0x4b23, 0xa5, 0x99, 0xbd, 0xb9, 0x8d, 0xbf, 0xd1, 0xf4)] interface ISpeechPhraseProperties(ISpeechPhrasePropertiesVtbl): IDispatch(IDispatchVtbl) { fn get_Count( Count: *mut c_long, @@ -3522,8 +3523,8 @@ fn get__NewEnum( EnumVARIANT: *mut *mut IUnknown, ) -> HRESULT, -}); -RIDL!(#[uuid(0xa7bfe112, 0xa4a0, 0x48d9, 0xb6, 0x02, 0xc3, 0x13, 0x84, 0x3f, 0x69, 0x64)] +}} +RIDL!{#[uuid(0xa7bfe112, 0xa4a0, 0x48d9, 0xb6, 0x02, 0xc3, 0x13, 0x84, 0x3f, 0x69, 0x64)] interface ISpeechPhraseRule(ISpeechPhraseRuleVtbl): IDispatch(IDispatchVtbl) { fn get_Name( Name: *mut BSTR, @@ -3549,8 +3550,8 @@ fn get_EngineConfidence( Confidence: *mut c_float, ) -> HRESULT, -}); -RIDL!(#[uuid(0x9047d593, 0x01dd, 0x4b72, 0x81, 0xa3, 0xe4, 0xa0, 0xca, 0x69, 0xf4, 0x07)] +}} +RIDL!{#[uuid(0x9047d593, 0x01dd, 0x4b72, 0x81, 0xa3, 0xe4, 0xa0, 0xca, 0x69, 0xf4, 0x07)] interface ISpeechPhraseRules(ISpeechPhraseRulesVtbl): IDispatch(IDispatchVtbl) { fn get_Count( Count: *mut c_long, @@ -3562,8 +3563,8 @@ fn get__NewEnum( EnumVARIANT: *mut *mut IUnknown, ) -> HRESULT, -}); -RIDL!(#[uuid(0x3da7627a, 0xc7ae, 0x4b23, 0x87, 0x08, 0x63, 0x8c, 0x50, 0x36, 0x2c, 0x25)] +}} +RIDL!{#[uuid(0x3da7627a, 0xc7ae, 0x4b23, 0x87, 0x08, 0x63, 0x8c, 0x50, 0x36, 0x2c, 0x25)] interface ISpeechLexicon(ISpeechLexiconVtbl): IDispatch(IDispatchVtbl) { fn get_GenerationId( GenerationId: *mut c_long, @@ -3607,8 +3608,8 @@ GenerationID: *mut c_long, ppWords: *mut *mut ISpeechLexiconWords, ) -> HRESULT, -}); -RIDL!(#[uuid(0x8d199862, 0x415e, 0x47d5, 0xac, 0x4f, 0xfa, 0xa6, 0x08, 0xb4, 0x24, 0xe6)] +}} +RIDL!{#[uuid(0x8d199862, 0x415e, 0x47d5, 0xac, 0x4f, 0xfa, 0xa6, 0x08, 0xb4, 0x24, 0xe6)] interface ISpeechLexiconWords(ISpeechLexiconWordsVtbl): IDispatch(IDispatchVtbl) { fn get_Count( Count: *mut c_long, @@ -3620,8 +3621,8 @@ fn get__NewEnum( EnumVARIANT: *mut *mut IUnknown, ) -> HRESULT, -}); -RIDL!(#[uuid(0x4e5b933c, 0xc9be, 0x48ed, 0x88, 0x42, 0x1e, 0xe5, 0x1b, 0xb1, 0xd4, 0xff)] +}} +RIDL!{#[uuid(0x4e5b933c, 0xc9be, 0x48ed, 0x88, 0x42, 0x1e, 0xe5, 0x1b, 0xb1, 0xd4, 0xff)] interface ISpeechLexiconWord(ISpeechLexiconWordVtbl): IDispatch(IDispatchVtbl) { fn get_LangId( LangId: *mut SpeechLanguageId, @@ -3635,8 +3636,8 @@ fn get_Pronunciations( Pronunciations: *mut *mut ISpeechLexiconPronunciations, ) -> HRESULT, -}); -RIDL!(#[uuid(0x72829128, 0x5682, 0x4704, 0xa0, 0xd4, 0x3e, 0x2b, 0xb6, 0xf2, 0xea, 0xd3)] +}} +RIDL!{#[uuid(0x72829128, 0x5682, 0x4704, 0xa0, 0xd4, 0x3e, 0x2b, 0xb6, 0xf2, 0xea, 0xd3)] interface ISpeechLexiconPronunciations(ISpeechLexiconPronunciationsVtbl): IDispatch(IDispatchVtbl) { fn get_Count( @@ -3649,8 +3650,8 @@ fn get__NewEnum( EnumVARIANT: *mut *mut IUnknown, ) -> HRESULT, -}); -RIDL!(#[uuid(0x95252c5d, 0x9e43, 0x4f4a, 0x98, 0x99, 0x48, 0xee, 0x73, 0x35, 0x2f, 0x9f)] +}} +RIDL!{#[uuid(0x95252c5d, 0x9e43, 0x4f4a, 0x98, 0x99, 0x48, 0xee, 0x73, 0x35, 0x2f, 0x9f)] interface ISpeechLexiconPronunciation(ISpeechLexiconPronunciationVtbl): IDispatch(IDispatchVtbl) { fn get_Type( LexiconType: *mut SpeechLexiconType, @@ -3667,21 +3668,21 @@ fn get_Symbolic( Symbolic: *mut BSTR, ) -> HRESULT, -}); +}} pub const Speech_Default_Weight: c_float = DEFAULT_WEIGHT; pub const Speech_Max_Word_Length: LONG = SP_MAX_WORD_LENGTH as i32; pub const Speech_Max_Pron_Length: LONG = SP_MAX_PRON_LENGTH as i32; pub const Speech_StreamPos_Asap: LONG = SP_STREAMPOS_ASAP as i32; pub const Speech_StreamPos_RealTime: LONG = SP_STREAMPOS_REALTIME as i32; pub const SpeechAllElements: LONG = SPPR_ALL_ELEMENTS as i32; -RIDL!(#[uuid(0x3b151836, 0xdf3a, 0x4e0a, 0x84, 0x6c, 0xd2, 0xad, 0xc9, 0x33, 0x43, 0x33)] +RIDL!{#[uuid(0x3b151836, 0xdf3a, 0x4e0a, 0x84, 0x6c, 0xd2, 0xad, 0xc9, 0x33, 0x43, 0x33)] interface ISpeechPhraseInfoBuilder(ISpeechPhraseInfoBuilderVtbl): IDispatch(IDispatchVtbl) { fn RestorePhraseFromMemory( PhraseInMemory: *mut VARIANT, PhraseInfo: *mut *mut ISpeechPhraseInfo, ) -> HRESULT, -}); -RIDL!(#[uuid(0xc3e4f353, 0x433f, 0x43d6, 0x89, 0xa1, 0x6a, 0x62, 0xa7, 0x05, 0x4c, 0x3d)] +}} +RIDL!{#[uuid(0xc3e4f353, 0x433f, 0x43d6, 0x89, 0xa1, 0x6a, 0x62, 0xa7, 0x05, 0x4c, 0x3d)] interface ISpeechPhoneConverter(ISpeechPhoneConverterVtbl): IDispatch(IDispatchVtbl) { fn get_LanguageId( LanguageId: *mut SpeechLanguageId, @@ -3697,7 +3698,7 @@ IdArray: VARIANT, Phonemes: *mut BSTR, ) -> HRESULT, -}); +}} extern { pub static CLSID_SpNotifyTranslator: CLSID; pub static CLSID_SpObjectTokenCategory: CLSID; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/sapi53.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/sapi53.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/sapi53.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/sapi53.rs 2018-12-05 01:24:41.000000000 +0000 @@ -281,14 +281,14 @@ SPEVENTSOURCEINFO, ISpEventSource, ISpEventSourceVtbl, }; -RIDL!(#[uuid(0x2373a435, 0x6a4b, 0x429e, 0xa6, 0xac, 0xd4, 0x23, 0x1a, 0x61, 0x97, 0x5b)] +RIDL!{#[uuid(0x2373a435, 0x6a4b, 0x429e, 0xa6, 0xac, 0xd4, 0x23, 0x1a, 0x61, 0x97, 0x5b)] interface ISpEventSource2(ISpEventSource2Vtbl): ISpEventSource(ISpEventSourceVtbl) { fn GetEventsEx( ulCount: ULONG, pEventArray: *mut SPEVENTEX, pulFetched: *mut ULONG, ) -> HRESULT, -}); +}} pub use um::sapi51::{ ISpEventSink, ISpEventSinkVtbl, ISpStreamFormat, ISpStreamFormatVtbl, @@ -483,7 +483,7 @@ pvBuffer: *mut BYTE, pFirstShortcutPair: *mut SPSHORTCUTPAIR, }} -RIDL!(#[uuid(0x3df681e2, 0xea56, 0x11d9, 0x8b, 0xde, 0xf6, 0x6b, 0xad, 0x1e, 0x3f, 0x3a)] +RIDL!{#[uuid(0x3df681e2, 0xea56, 0x11d9, 0x8b, 0xde, 0xf6, 0x6b, 0xad, 0x1e, 0x3f, 0x3a)] interface ISpShortcut(ISpShortcutVtbl): IUnknown(IUnknownVtbl) { fn AddShortcut( pszDisplay: LPCWSTR, @@ -522,9 +522,9 @@ pdwGeneration: *mut DWORD, pShortcutpairList: *mut SPSHORTCUTPAIRLIST, ) -> HRESULT, -}); +}} pub use um::sapi51::{ISpPhoneConverter, ISpPhoneConverterVtbl}; -RIDL!(#[uuid(0x133adcd4, 0x19b4, 0x4020, 0x9f, 0xdc, 0x84, 0x2e, 0x78, 0x25, 0x3b, 0x17)] +RIDL!{#[uuid(0x133adcd4, 0x19b4, 0x4020, 0x9f, 0xdc, 0x84, 0x2e, 0x78, 0x25, 0x3b, 0x17)] interface ISpPhoneticAlphabetConverter(ISpPhoneticAlphabetConverterVtbl): IUnknown(IUnknownVtbl) { fn GetLangId( pLangID: *mut WORD, @@ -547,8 +547,8 @@ bSAPI2UPS: BOOL, pcMaxDestLength: *mut DWORD, ) -> HRESULT, -}); -RIDL!(#[uuid(0xb2745efd, 0x42ce, 0x48ca, 0x81, 0xf1, 0xa9, 0x6e, 0x02, 0x53, 0x8a, 0x90)] +}} +RIDL!{#[uuid(0xb2745efd, 0x42ce, 0x48ca, 0x81, 0xf1, 0xa9, 0x6e, 0x02, 0x53, 0x8a, 0x90)] interface ISpPhoneticAlphabetSelection(ISpPhoneticAlphabetSelectionVtbl): IUnknown(IUnknownVtbl) { fn IsAlphabetUPS( pfIsUPS: *mut BOOL, @@ -556,7 +556,7 @@ fn SetAlphabetToUPS( fForceUPS: BOOL, ) -> HRESULT, -}); +}} pub use um::sapi51::{ SPVPITCH, SPVACTIONS, @@ -608,7 +608,7 @@ SPXRO_SML = 0, SPXRO_Alternates_SML = 1, }} -RIDL!(#[uuid(0xf264da52, 0xe457, 0x4696, 0xb8, 0x56, 0xa7, 0x37, 0xb7, 0x17, 0xaf, 0x79)] +RIDL!{#[uuid(0xf264da52, 0xe457, 0x4696, 0xb8, 0x56, 0xa7, 0x37, 0xb7, 0x17, 0xaf, 0x79)] interface ISpPhrase2(ISpPhrase2Vtbl): ISpPhrase(ISpPhraseVtbl) { fn GetXMLResult( ppszCoMemXMLResult: *mut LPWSTR, @@ -622,7 +622,7 @@ cElements: ULONG, ppStream: *mut *mut ISpStreamFormat, ) -> HRESULT, -}); +}} pub use um::sapi51::{ SPRECORESULTTIMES, SPSERIALIZEDRESULT, @@ -633,7 +633,7 @@ SPCF_ADD_TO_USER_LEXICON = 1 << 0, SPCF_DEFINITE_CORRECTION = 1 << 1, }} -RIDL!(#[uuid(0x27cac6c4, 0x88f2, 0x41f2, 0x88, 0x17, 0x0c, 0x95, 0xe5, 0x9f, 0x1e, 0x6e)] +RIDL!{#[uuid(0x27cac6c4, 0x88f2, 0x41f2, 0x88, 0x17, 0x0c, 0x95, 0xe5, 0x9f, 0x1e, 0x6e)] interface ISpRecoResult2(ISpRecoResult2Vtbl): ISpRecoResult(ISpRecoResultVtbl) { fn CommitAlternate( pPhraseAlt: *mut ISpPhraseAlt, @@ -649,8 +649,8 @@ pszFeedback: LPCWSTR, fSuccessful: BOOL, ) -> HRESULT, -}); -RIDL!(#[uuid(0xae39362b, 0x45a8, 0x4074, 0x9b, 0x9e, 0xcc, 0xf4, 0x9a, 0xa2, 0xd0, 0xb6)] +}} +RIDL!{#[uuid(0xae39362b, 0x45a8, 0x4074, 0x9b, 0x9e, 0xcc, 0xf4, 0x9a, 0xa2, 0xd0, 0xb6)] interface ISpXMLRecoResult(ISpXMLRecoResultVtbl): ISpRecoResult(ISpRecoResultVtbl) { fn GetXMLResult( ppszCoMemXMLResult: *mut LPWSTR, @@ -659,7 +659,7 @@ fn GetXMLErrorInfo( pSemanticErrorInfo: *mut SPSEMANTICERRORINFO, ) -> HRESULT, -}); +}} pub use um::sapi51::{ SPTEXTSELECTIONINFO, SPWORDPRONOUNCEABLE, @@ -723,7 +723,7 @@ PA_Ups = 1, PA_Sapi = 2, }} -RIDL!(#[uuid(0x8ab10026, 0x20cc, 0x4b20, 0x8c, 0x22, 0xa4, 0x9c, 0x9b, 0xa7, 0x8f, 0x60)] +RIDL!{#[uuid(0x8ab10026, 0x20cc, 0x4b20, 0x8c, 0x22, 0xa4, 0x9c, 0x9b, 0xa7, 0x8f, 0x60)] interface ISpGrammarBuilder2(ISpGrammarBuilder2Vtbl): IUnknown(IUnknownVtbl) { fn AddTextSubset( hFromState: SPSTATEHANDLE, @@ -734,9 +734,9 @@ fn SetPhoneticAlphabet( phoneticALphabet: PHONETICALPHABET, ) -> HRESULT, -}); +}} pub const SPRP_NORMAL: i32 = 0; // TODO: Unknown purpose and type -RIDL!(#[uuid(0x4b37bc9e, 0x9ed6, 0x44a3, 0x93, 0xd3, 0x18, 0xf0, 0x22, 0xb7, 0x9e, 0xc3)] +RIDL!{#[uuid(0x4b37bc9e, 0x9ed6, 0x44a3, 0x93, 0xd3, 0x18, 0xf0, 0x22, 0xb7, 0x9e, 0xc3)] interface ISpRecoGrammar2(ISpRecoGrammar2Vtbl): IUnknown(IUnknownVtbl) { fn GetRules( ppCoMemRules: *mut *mut SPRULE, @@ -773,8 +773,8 @@ fn SetSMLSecurityManager( pSMLSecurityManager: *mut IInternetSecurityManager, ) -> HRESULT, -}); -RIDL!(#[uuid(0xb9ac5783, 0xfcd0, 0x4b21, 0xb1, 0x19, 0xb4, 0xf8, 0xda, 0x8f, 0xd2, 0xc3)] +}} +RIDL!{#[uuid(0xb9ac5783, 0xfcd0, 0x4b21, 0xb1, 0x19, 0xb4, 0xf8, 0xda, 0x8f, 0xd2, 0xc3)] interface ISpeechResourceLoader(ISpeechResourceLoaderVtbl): IDispatch(IDispatchVtbl) { fn LoadResource( bstrResourceUri: BSTR, @@ -793,7 +793,7 @@ fn ReleaseLocalCopy( pbstrLocalPath: BSTR, ) -> HRESULT, -}); +}} pub use um::sapi51::{ SPRECOCONTEXTSTATUS, SPBOOKMARKOPTIONS, @@ -838,7 +838,7 @@ SPAR_Medium = 2, SPAR_High = 3, }} -RIDL!(#[uuid(0xbead311c, 0x52ff, 0x437f, 0x94, 0x64, 0x6b, 0x21, 0x05, 0x4c, 0xa7, 0x3d)] +RIDL!{#[uuid(0xbead311c, 0x52ff, 0x437f, 0x94, 0x64, 0x6b, 0x21, 0x05, 0x4c, 0xa7, 0x3d)] interface ISpRecoContext2(ISpRecoContext2Vtbl): IUnknown(IUnknownVtbl) { fn SetGrammarOptions( eGrammarOptions: DWORD, @@ -853,7 +853,7 @@ eAdaptationSettings: DWORD, eRelevance: SPADAPTATIONRELEVANCE, ) -> HRESULT, -}); +}} pub use um::sapi51::{ ISpProperties, ISpPropertiesVtbl, SP_MAX_LANGIDS, @@ -870,7 +870,7 @@ SPRST_NUM_STATES, ISpRecognizer, ISpRecognizerVtbl, }; -RIDL!(#[uuid(0x21b501a0, 0x0ec7, 0x46c9, 0x92, 0xc3, 0xa2, 0xbc, 0x78, 0x4c, 0x54, 0xb9)] +RIDL!{#[uuid(0x21b501a0, 0x0ec7, 0x46c9, 0x92, 0xc3, 0xa2, 0xbc, 0x78, 0x4c, 0x54, 0xb9)] interface ISpSerializeState(ISpSerializeStateVtbl): IUnknown(IUnknownVtbl) { fn GetSerializedState( ppbData: *mut *mut BYTE, @@ -882,8 +882,8 @@ ulSize: ULONG, dwReserved: DWORD, ) -> HRESULT, -}); -RIDL!(#[uuid(0x8fc6d974, 0xc81e, 0x4098, 0x93, 0xc5, 0x01, 0x47, 0xf6, 0x1e, 0xd4, 0xd3)] +}} +RIDL!{#[uuid(0x8fc6d974, 0xc81e, 0x4098, 0x93, 0xc5, 0x01, 0x47, 0xf6, 0x1e, 0xd4, 0xd3)] interface ISpRecognizer2(ISpRecognizer2Vtbl): IUnknown(IUnknownVtbl) { fn EmulateRecognitionEx( pPhrase: *mut ISpPhrase, @@ -894,12 +894,12 @@ fAdaptFromTrainingData: BOOL, ) -> HRESULT, fn ResetAcousticModelAdaptation() -> HRESULT, -}); +}} STRUCT!{struct SPNORMALIZATIONLIST { ulSize: ULONG, ppszzNormalizedList: *mut *mut WCHAR, }} -RIDL!(#[uuid(0xc360ce4b, 0x76d1, 0x4214, 0xad, 0x68, 0x52, 0x65, 0x7d, 0x50, 0x83, 0xda)] +RIDL!{#[uuid(0xc360ce4b, 0x76d1, 0x4214, 0xad, 0x68, 0x52, 0x65, 0x7d, 0x50, 0x83, 0xda)] interface ISpEnginePronunciation(ISpEnginePronunciationVtbl): IUnknown(IUnknownVtbl) { fn Normalize( pszWord: LPCWSTR, @@ -915,7 +915,7 @@ LangID: WORD, pEnginePronunciationList: *mut SPWORDPRONUNCIATIONLIST, ) -> HRESULT, -}); +}} STRUCT!{struct SPDISPLAYTOKEN { pszLexical: *const WCHAR, pszDisplay: *const WCHAR, @@ -925,7 +925,7 @@ ulNumTokens: ULONG, pTokens: *mut SPDISPLAYTOKEN, }} -RIDL!(#[uuid(0xc8d7c7e2, 0x0dde, 0x44b7, 0xaf, 0xe3, 0xb0, 0xc9, 0x91, 0xfb, 0xeb, 0x5e)] +RIDL!{#[uuid(0xc8d7c7e2, 0x0dde, 0x44b7, 0xaf, 0xe3, 0xb0, 0xc9, 0x91, 0xfb, 0xeb, 0x5e)] interface ISpDisplayAlternates(ISpDisplayAlternatesVtbl): IUnknown(IUnknownVtbl) { fn GetDisplayAlternates( pPhrase: *const SPDISPLAYPHRASE, @@ -936,7 +936,7 @@ fn SetFullStopTrailSpace( ulTrailSpace: ULONG, ) -> HRESULT, -}); +}} pub use um::sapi51::{ SpeechLanguageId, DISPID_SpeechDataKey, @@ -1679,13 +1679,13 @@ ISpeechTextSelectionInformation, ISpeechTextSelectionInformationVtbl, ISpeechRecoResult, ISpeechRecoResultVtbl, }; -RIDL!(#[uuid(0x8e0a246d, 0xd3c8, 0x45de, 0x86, 0x57, 0x04, 0x29, 0x0c, 0x45, 0x8c, 0x3c)] +RIDL!{#[uuid(0x8e0a246d, 0xd3c8, 0x45de, 0x86, 0x57, 0x04, 0x29, 0x0c, 0x45, 0x8c, 0x3c)] interface ISpeechRecoResult2(ISpeechRecoResult2Vtbl): ISpeechRecoResult(ISpeechRecoResultVtbl) { fn SetTextFeedback( Feedback: BSTR, WasSuccessful: VARIANT_BOOL, ) -> HRESULT, -}); +}} pub use um::sapi51::{ ISpeechRecoResultTimes, ISpeechRecoResultTimesVtbl, ISpeechPhraseAlternate, ISpeechPhraseAlternateVtbl, @@ -1711,7 +1711,7 @@ Speech_StreamPos_RealTime, SpeechAllElements, }; -RIDL!(#[uuid(0xaaec54af, 0x8f85, 0x4924, 0x94, 0x4d, 0xb7, 0x9d, 0x39, 0xd7, 0x2e, 0x19)] +RIDL!{#[uuid(0xaaec54af, 0x8f85, 0x4924, 0x94, 0x4d, 0xb7, 0x9d, 0x39, 0xd7, 0x2e, 0x19)] interface ISpeechXMLRecoResult(ISpeechXMLRecoResultVtbl): ISpeechRecoResult(ISpeechRecoResultVtbl) { fn GetXMLResult( @@ -1726,8 +1726,8 @@ ResultCode: *mut c_long, IsError: *mut VARIANT_BOOL, ) -> HRESULT, -}); -RIDL!(#[uuid(0x6d60eb64, 0xaced, 0x40a6, 0xbb, 0xf3, 0x4e, 0x55, 0x7f, 0x71, 0xde, 0xe2)] +}} +RIDL!{#[uuid(0x6d60eb64, 0xaced, 0x40a6, 0xbb, 0xf3, 0x4e, 0x55, 0x7f, 0x71, 0xde, 0xe2)] interface ISpeechRecoResultDispatch(ISpeechRecoResultDispatchVtbl): IDispatch(IDispatchVtbl) { fn get_RecoContext( RecoContext: *mut ISpeechRecoContext, @@ -1783,7 +1783,7 @@ Feedback: BSTR, WasSuccessful: VARIANT_BOOL, ) -> HRESULT, -}); +}} pub use um::sapi51::{ ISpeechPhraseInfoBuilder, ISpeechPhraseInfoBuilderVtbl, ISpeechPhoneConverter, ISpeechPhoneConverterVtbl, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/sapiddk51.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/sapiddk51.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/sapiddk51.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/sapiddk51.rs 2018-12-05 01:24:41.000000000 +0000 @@ -16,7 +16,7 @@ use um::winnt::{HANDLE, HRESULT, LONG, LPCWSTR, LPWSTR, PVOID, ULONGLONG, WCHAR}; pub const SPRECOEXTENSION: &'static str = "RecoExtension"; pub const SPALTERNATESCLSID: &'static str = "AlternatesCLSID"; -RIDL!(#[uuid(0xf8e690f0, 0x39cb, 0x4843, 0xb8, 0xd7, 0xc8, 0x46, 0x96, 0xe1, 0x11, 0x9d)] +RIDL!{#[uuid(0xf8e690f0, 0x39cb, 0x4843, 0xb8, 0xd7, 0xc8, 0x46, 0x96, 0xe1, 0x11, 0x9d)] interface ISpTokenUI(ISpTokenUIVtbl): IUnknown(IUnknownVtbl) { fn IsUISupported( pszTypeOfUI: LPCWSTR, @@ -34,8 +34,8 @@ pToken: *mut ISpObjectToken, punkObject: *mut IUnknown, ) -> HRESULT, -}); -RIDL!(#[uuid(0x06b64f9f, 0x7fda, 0x11d2, 0xb4, 0xf2, 0x00, 0xc0, 0x4f, 0x79, 0x73, 0x96)] +}} +RIDL!{#[uuid(0x06b64f9f, 0x7fda, 0x11d2, 0xb4, 0xf2, 0x00, 0xc0, 0x4f, 0x79, 0x73, 0x96)] interface ISpObjectTokenEnumBuilder(ISpObjectTokenEnumBuilderVtbl): IEnumSpObjectTokens(IEnumSpObjectTokensVtbl) { fn SetAttribs( @@ -57,15 +57,15 @@ fn Sort( pszTokenIdToListFirst: LPCWSTR, ) -> HRESULT, -}); -DECLARE_HANDLE!(SPWORDHANDLE, SPWORDHANDLE__); -DECLARE_HANDLE!(SPRULEHANDLE, SPRULEHANDLE__); -DECLARE_HANDLE!(SPGRAMMARHANDLE, SPGRAMMARHANDLE__); -DECLARE_HANDLE!(SPRECOCONTEXTHANDLE, SPRECOCONTEXTHANDLE__); -DECLARE_HANDLE!(SPPHRASERULEHANDLE, SPPHRASERULEHANDLE__); -DECLARE_HANDLE!(SPPHRASEPROPERTYHANDLE, SPPHRASEPROPERTYHANDLE__); -DECLARE_HANDLE!(SPTRANSITIONID, SPTRANSITIONID__); -RIDL!(#[uuid(0xf4711347, 0xe608, 0x11d2, 0xa0, 0x86, 0x00, 0xc0, 0x4f, 0x8e, 0xf9, 0xb5)] +}} +DECLARE_HANDLE!{SPWORDHANDLE, SPWORDHANDLE__} +DECLARE_HANDLE!{SPRULEHANDLE, SPRULEHANDLE__} +DECLARE_HANDLE!{SPGRAMMARHANDLE, SPGRAMMARHANDLE__} +DECLARE_HANDLE!{SPRECOCONTEXTHANDLE, SPRECOCONTEXTHANDLE__} +DECLARE_HANDLE!{SPPHRASERULEHANDLE, SPPHRASERULEHANDLE__} +DECLARE_HANDLE!{SPPHRASEPROPERTYHANDLE, SPPHRASEPROPERTYHANDLE__} +DECLARE_HANDLE!{SPTRANSITIONID, SPTRANSITIONID__} +RIDL!{#[uuid(0xf4711347, 0xe608, 0x11d2, 0xa0, 0x86, 0x00, 0xc0, 0x4f, 0x8e, 0xf9, 0xb5)] interface ISpErrorLog(ISpErrorLogVtbl): IUnknown(IUnknownVtbl) { fn AddError( lLineNumber: c_long, @@ -74,8 +74,8 @@ pszHelpFile: LPCWSTR, dwHelpContext: DWORD, ) -> HRESULT, -}); -RIDL!(#[uuid(0xb1e29d58, 0xa675, 0x11d2, 0x83, 0x02, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0xc0)] +}} +RIDL!{#[uuid(0xb1e29d58, 0xa675, 0x11d2, 0x83, 0x02, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0xc0)] interface ISpGrammarCompiler(ISpGrammarCompilerVtbl): IUnknown(IUnknownVtbl) { fn CompileStream( pSource: *mut IStream, @@ -85,8 +85,8 @@ pErrorLog: *mut ISpErrorLog, dwFlags: DWORD, ) -> HRESULT, -}); -RIDL!(#[uuid(0x3ddca27c, 0x665c, 0x4786, 0x9f, 0x97, 0x8c, 0x90, 0xc3, 0x48, 0x8b, 0x61)] +}} +RIDL!{#[uuid(0x3ddca27c, 0x665c, 0x4786, 0x9f, 0x97, 0x8c, 0x90, 0xc3, 0x48, 0x8b, 0x61)] interface ISpGramCompBackend(ISpGramCompBackendVtbl): ISpGrammarBuilder(ISpGrammarBuilderVtbl) { fn SetSaveObjects( pStream: *mut IStream, @@ -95,8 +95,8 @@ fn InitFromBinaryGrammar( pBinaryData: *const SPBINARYGRAMMAR, ) -> HRESULT, -}); -RIDL!(#[uuid(0x12d7360f, 0xa1c9, 0x11d3, 0xbc, 0x90, 0x00, 0xc0, 0x4f, 0x72, 0xdf, 0x9f)] +}} +RIDL!{#[uuid(0x12d7360f, 0xa1c9, 0x11d3, 0xbc, 0x90, 0x00, 0xc0, 0x4f, 0x72, 0xdf, 0x9f)] interface ISpITNProcessor(ISpITNProcessorVtbl): IUnknown(IUnknownVtbl) { fn LoadITNGrammar( pszCLSID: LPWSTR, @@ -104,8 +104,8 @@ fn ITNPhrase( pPhrase: *mut ISpPhraseBuilder, ) -> HRESULT, -}); -RIDL!(#[uuid(0x88a3342a, 0x0bed, 0x4834, 0x92, 0x2b, 0x88, 0xd4, 0x31, 0x73, 0x16, 0x2f)] +}} +RIDL!{#[uuid(0x88a3342a, 0x0bed, 0x4834, 0x92, 0x2b, 0x88, 0xd4, 0x31, 0x73, 0x16, 0x2f)] interface ISpPhraseBuilder(ISpPhraseBuilderVtbl): ISpPhrase(ISpPhraseVtbl) { fn InitFromPhrase( pPhrase: *const SPPHRASE, @@ -131,10 +131,10 @@ cReplacements: ULONG, pReplacements: *const SPPHRASEREPLACEMENT, ) -> HRESULT, -}); +}} pub type ISpTask = *mut c_void; pub type ISpThreadTask = *mut c_void; -RIDL!(#[uuid(0xa6be4d73, 0x4403, 0x4358, 0xb2, 0x2d, 0x03, 0x46, 0xe2, 0x3b, 0x17, 0x64)] +RIDL!{#[uuid(0xa6be4d73, 0x4403, 0x4358, 0xb2, 0x2d, 0x03, 0x46, 0xe2, 0x3b, 0x17, 0x64)] interface ISpThreadControl(ISpThreadControlVtbl): ISpNotifySink(ISpNotifySinkVtbl) { fn StartThread( dwFlags: DWORD, @@ -152,14 +152,14 @@ fn WindowHandle() -> HWND, fn ThreadCompleteEvent() -> HANDLE, fn ExitThreadEvent() -> HANDLE, -}); +}} STRUCT!{struct SPTMTHREADINFO { lPoolSize: c_long, lPriority: c_long, ulConcurrencyLimit: ULONG, ulMaxQuickAllocThreads: ULONG, }} -RIDL!(#[uuid(0x2baeef81, 0x2ca3, 0x4331, 0x98, 0xf3, 0x26, 0xec, 0x5a, 0xbe, 0xfb, 0x03)] +RIDL!{#[uuid(0x2baeef81, 0x2ca3, 0x4331, 0x98, 0xf3, 0x26, 0xec, 0x5a, 0xbe, 0xfb, 0x03)] interface ISpTaskManager(ISpTaskManagerVtbl): IUnknown(IUnknownVtbl) { fn SetThreadPoolInfo( pPoolInfo: *const SPTMTHREADINFO, @@ -190,7 +190,7 @@ dwGroupId: DWORD, ulWaitPeriod: ULONG, ) -> HRESULT, -}); +}} ENUM!{enum SPVSKIPTYPE { SPVST_SENTENCE = 1 << 0, }} @@ -201,7 +201,7 @@ SPVES_RATE = 1 << 2, SPVES_VOLUME = 1 << 3, }} -RIDL!(#[uuid(0x9880499b, 0xcce9, 0x11d2, 0xb5, 0x03, 0x00, 0xc0, 0x4f, 0x79, 0x73, 0x96)] +RIDL!{#[uuid(0x9880499b, 0xcce9, 0x11d2, 0xb5, 0x03, 0x00, 0xc0, 0x4f, 0x79, 0x73, 0x96)] interface ISpTTSEngineSite(ISpTTSEngineSiteVtbl): ISpEventSink(ISpEventSinkVtbl) { fn GetActions() -> DWORD, fn Write( @@ -221,7 +221,7 @@ fn CompleteSkip( ulNumSkipped: c_long, ) -> HRESULT, -}); +}} STRUCT!{struct SPVTEXTFRAG { pNext: *mut SPVTEXTFRAG, State: SPVSTATE, @@ -229,7 +229,7 @@ ulTextLen: ULONG, ulTextSrcOffset: ULONG, }} -RIDL!(#[uuid(0xa74d7c8e, 0x4cc5, 0x4f2f, 0xa6, 0xeb, 0x80, 0x4d, 0xee, 0x18, 0x50, 0x0e)] +RIDL!{#[uuid(0xa74d7c8e, 0x4cc5, 0x4f2f, 0xa6, 0xeb, 0x80, 0x4d, 0xee, 0x18, 0x50, 0x0e)] interface ISpTTSEngine(ISpTTSEngineVtbl): IUnknown(IUnknownVtbl) { fn Speak( dwSpeakFlags: DWORD, @@ -244,7 +244,7 @@ pOutputFormatId: *mut GUID, ppCoMemOutputWaveFormatEx: *mut WAVEFORMATEX, ) -> HRESULT, -}); +}} STRUCT!{struct SPWORDENTRY { hWord: SPWORDHANDLE, LangID: WORD, @@ -310,7 +310,7 @@ hTransition: SPTRANSITIONID, elem: SPPHRASEELEMENT, }} -RIDL!(#[uuid(0x6a6ffad8, 0x78b6, 0x473d, 0xb8, 0x44, 0x98, 0x15, 0x2e, 0x4f, 0xb1, 0x6b)] +RIDL!{#[uuid(0x6a6ffad8, 0x78b6, 0x473d, 0xb8, 0x44, 0x98, 0x15, 0x2e, 0x4f, 0xb1, 0x6b)] interface ISpCFGInterpreterSite(ISpCFGInterpreterSiteVtbl): IUnknown(IUnknownVtbl) { fn AddTextReplacement( pReplace: *mut SPPHRASEREPLACEMENT, @@ -322,8 +322,8 @@ pszResourceName: LPCWSTR, ppCoMemResource: *mut LPWSTR, ) -> HRESULT, -}); -RIDL!(#[uuid(0xf3d3f926, 0x11fc, 0x11d3, 0xbb, 0x97, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0xc0)] +}} +RIDL!{#[uuid(0xf3d3f926, 0x11fc, 0x11d3, 0xbb, 0x97, 0x00, 0xc0, 0x4f, 0x8e, 0xe6, 0xc0)] interface ISpCFGInterpreter(ISpCFGInterpreterVtbl): IUnknown(IUnknownVtbl) { fn InitGrammar( pszGrammarName: LPCWSTR, @@ -335,7 +335,7 @@ ulCountOfElements: *const ULONG, pSite: *mut ISpCFGInterpreterSite, ) -> HRESULT, -}); +}} ENUM!{enum SPCFGNOTIFY { SPCFGN_ADD, SPCFGN_REMOVE, @@ -390,7 +390,7 @@ pSREnginePrivateData: *const BYTE, fHypothesis: BOOL, }} -RIDL!(#[uuid(0x3b414aec, 0x720c, 0x4883, 0xb9, 0xef, 0x17, 0x8c, 0xd3, 0x94, 0xfb, 0x3a)] +RIDL!{#[uuid(0x3b414aec, 0x720c, 0x4883, 0xb9, 0xef, 0x17, 0x8c, 0xd3, 0x94, 0xfb, 0x3a)] interface ISpSREngineSite(ISpSREngineSiteVtbl): IUnknown(IUnknownVtbl) { fn Read( pv: *mut c_void, @@ -461,13 +461,13 @@ fn UpdateRecoPos( ullCurrentRecoPos: ULONGLONG, ) -> HRESULT, -}); +}} ENUM!{enum SPPROPSRC { SPPROPSRC_RECO_INST, SPPROPSRC_RECO_CTX, SPPROPSRC_RECO_GRAMMAR, }} -RIDL!(#[uuid(0x2f472991, 0x854b, 0x4465, 0xb6, 0x13, 0xfb, 0xaf, 0xb3, 0xad, 0x8e, 0xd8)] +RIDL!{#[uuid(0x2f472991, 0x854b, 0x4465, 0xb6, 0x13, 0xfb, 0xaf, 0xb3, 0xad, 0x8e, 0xd8)] interface ISpSREngine(ISpSREngineVtbl): IUnknown(IUnknownVtbl) { fn SetSite( pSite: *mut ISpSREngineSite, @@ -614,7 +614,7 @@ pvEngineContext: *mut c_void, eContextState: SPCONTEXTSTATE, ) -> HRESULT, -}); +}} STRUCT!{struct SPPHRASEALTREQUEST { ulStartElement: ULONG, cElements: ULONG, @@ -624,7 +624,7 @@ pPhrase: *mut ISpPhrase, pRecoContext: *mut ISpRecoContext, }} -RIDL!(#[uuid(0x8e7c791e, 0x4467, 0x11d3, 0x97, 0x23, 0x00, 0xc0, 0x4f, 0x72, 0xdb, 0x08)] +RIDL!{#[uuid(0x8e7c791e, 0x4467, 0x11d3, 0x97, 0x23, 0x00, 0xc0, 0x4f, 0x72, 0xdb, 0x08)] interface _ISpPrivateEngineCall(_ISpPrivateEngineCallVtbl): IUnknown(IUnknownVtbl) { fn CallEngine( pCallFrame: *mut c_void, @@ -636,10 +636,14 @@ ppCoMemOutFrame: *mut *mut c_void, pulOutFrameSize: *mut ULONG, ) -> HRESULT, -}); +}} extern { pub static LIBID_SpeechDDKLib: IID; pub static CLSID_SpDataKey: CLSID; +} +RIDL!{#[uuid(0xd9f6ee60, 0x58c9, 0x458b, 0x88, 0xe1, 0x2f, 0x90, 0x8f, 0xd7, 0xf8, 0x7c)] +class SpDataKey;} +extern { pub static CLSID_SpObjectTokenEnum: CLSID; pub static CLSID_SpPhraseBuilder: CLSID; pub static CLSID_SpITNProcessor: CLSID; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/sapiddk.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/sapiddk.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/sapiddk.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/sapiddk.rs 2018-12-05 01:24:41.000000000 +0000 @@ -105,7 +105,7 @@ SPPARSEINFO, ISpSREngineSite, ISpSREngineSiteVtbl, }; -RIDL!(#[uuid(0x7bc6e012, 0x684a, 0x493e, 0xbd, 0xd4, 0x2b, 0xf5, 0xfb, 0xf4, 0x8c, 0xfe)] +RIDL!{#[uuid(0x7bc6e012, 0x684a, 0x493e, 0xbd, 0xd4, 0x2b, 0xf5, 0xfb, 0xf4, 0x8c, 0xfe)] interface ISpSREngineSite2(ISpSREngineSite2Vtbl): ISpSREngineSite(ISpSREngineSiteVtbl) { fn AddEventEx( pEvent: *const SPEVENTEX, @@ -123,7 +123,7 @@ fn RecognitionEx( pResultInfo: *const SPRECORESULTINFOEX, ) -> HRESULT, -}); +}} pub use um::sapiddk51::{ SPPROPSRC, SPPROPSRC_RECO_INST, @@ -131,7 +131,7 @@ SPPROPSRC_RECO_GRAMMAR, ISpSREngine, ISpSREngineVtbl, }; -RIDL!(#[uuid(0x7ba627d8, 0x33f9, 0x4375, 0x90, 0xc5, 0x99, 0x85, 0xae, 0xe5, 0xed, 0xe5)] +RIDL!{#[uuid(0x7ba627d8, 0x33f9, 0x4375, 0x90, 0xc5, 0x99, 0x85, 0xae, 0xe5, 0xed, 0xe5)] interface ISpSREngine2(ISpSREngine2Vtbl): ISpSREngine(ISpSREngineVtbl) { fn PrivateCallImmediate( pvEngineContext: *mut c_void, @@ -185,9 +185,9 @@ pvEngineGrammar: *mut c_void, ulGrammarID: ULONG, ) -> HRESULT, -}); +}} pub use um::sapiddk51::SPPHRASEALTREQUEST; -RIDL!(#[uuid(0xfece8294, 0x2be1, 0x408f, 0x8e, 0x68, 0x2d, 0xe3, 0x77, 0x09, 0x2f, 0x0e)] +RIDL!{#[uuid(0xfece8294, 0x2be1, 0x408f, 0x8e, 0x68, 0x2d, 0xe3, 0x77, 0x09, 0x2f, 0x0e)] interface ISpSRAlternates(ISpSRAlternatesVtbl): IUnknown(IUnknownVtbl) { fn GetAlternates( pAltRequest: *mut SPPHRASEALTREQUEST, @@ -200,17 +200,17 @@ ppvResultExtra: *mut c_void, pcbResultExtra: *mut ULONG, ) -> HRESULT, -}); -RIDL!(#[uuid(0xf338f437, 0xcb33, 0x4020, 0x9c, 0xab, 0xc7, 0x1f, 0xf9, 0xce, 0x12, 0xd3)] +}} +RIDL!{#[uuid(0xf338f437, 0xcb33, 0x4020, 0x9c, 0xab, 0xc7, 0x1f, 0xf9, 0xce, 0x12, 0xd3)] interface ISpSRAlternates2(ISpSRAlternates2Vtbl): ISpSRAlternates(ISpSRAlternatesVtbl) { fn CommitText( pAltRequest: *mut SPPHRASEALTREQUEST, pcszNewText: LPCWSTR, commitFlags: SPCOMMITFLAGS, ) -> HRESULT, -}); +}} pub use um::sapiddk51::{_ISpPrivateEngineCall, _ISpPrivateEngineCallVtbl}; -RIDL!(#[uuid(0xdefd682a, 0xfe0a, 0x42b9, 0xbf, 0xa1, 0x56, 0xd3, 0xd6, 0xce, 0xcf, 0xaf)] +RIDL!{#[uuid(0xdefd682a, 0xfe0a, 0x42b9, 0xbf, 0xa1, 0x56, 0xd3, 0xd6, 0xce, 0xcf, 0xaf)] interface ISpPrivateEngineCallEx(ISpPrivateEngineCallExVtbl): IUnknown(IUnknownVtbl) { fn CallEngineSynchronize( pInFrame: *const c_void, @@ -224,7 +224,7 @@ ppCoMemOutFrame: *mut *mut c_void, pulOutFrameSize: *mut ULONG, ) -> HRESULT, -}); +}} pub use um::sapiddk51::{ LIBID_SpeechDDKLib, CLSID_SpDataKey, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/sapi.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/sapi.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/sapi.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/sapi.rs 2018-12-05 01:24:42.000000000 +0000 @@ -584,13 +584,13 @@ SPCT_SUB_COMMAND, SPCT_SUB_DICTATION, }} -RIDL!(#[uuid(0xda0cd0f9, 0x14a2, 0x4f09, 0x8c, 0x2a, 0x85, 0xcc, 0x48, 0x97, 0x93, 0x45)] +RIDL!{#[uuid(0xda0cd0f9, 0x14a2, 0x4f09, 0x8c, 0x2a, 0x85, 0xcc, 0x48, 0x97, 0x93, 0x45)] interface ISpRecoCategory(ISpRecoCategoryVtbl): IUnknown(IUnknownVtbl) { fn GetType( peCategoryType: *mut SPCATEGORYTYPE, ) -> HRESULT, -}); -RIDL!(#[uuid(0xdf1b943c, 0x5838, 0x4aa2, 0x87, 0x06, 0xd7, 0xcd, 0x5b, 0x33, 0x34, 0x99)] +}} +RIDL!{#[uuid(0xdf1b943c, 0x5838, 0x4aa2, 0x87, 0x06, 0xd7, 0xcd, 0x5b, 0x33, 0x34, 0x99)] interface ISpRecognizer3(ISpRecognizer3Vtbl): IUnknown(IUnknownVtbl) { fn GetCategory( categoryType: SPCATEGORYTYPE, @@ -602,7 +602,7 @@ fn GetActiveCategory( ppCategory: *mut *mut ISpRecoCategory, ) -> HRESULT, -}); +}} pub use um::sapi53::{ SPNORMALIZATIONLIST, ISpEnginePronunciation, ISpEnginePronunciationVtbl, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/securitybaseapi.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/securitybaseapi.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/securitybaseapi.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/securitybaseapi.rs 2018-12-05 01:24:41.000000000 +0000 @@ -5,7 +5,6 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. //! FFI bindings to psapi. - use shared::guiddef::GUID; use shared::minwindef::{ BOOL, BYTE, DWORD, LPBOOL, LPDWORD, LPVOID, PBOOL, PDWORD, PUCHAR, PULONG, UCHAR, ULONG @@ -20,7 +19,6 @@ SECURITY_IMPERSONATION_LEVEL, SECURITY_INFORMATION, TOKEN_INFORMATION_CLASS, TOKEN_TYPE, WELL_KNOWN_SID_TYPE }; - extern "system" { pub fn AccessCheck( pSecurityDescriptor: PSECURITY_DESCRIPTOR, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/servprov.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/servprov.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/servprov.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/servprov.rs 2018-12-05 01:24:41.000000000 +0000 @@ -9,7 +9,7 @@ use um::unknwnbase::{IUnknown, IUnknownVtbl}; use um::winnt::HRESULT; pub type LPSERVICEPROVIDER = *mut IServiceProvider; -RIDL!(#[uuid(0x6d5140c1, 0x7436, 0x11ce, 0x80, 0x34, 0x00, 0xaa, 0x00, 0x60, 0x09, 0xfa)] +RIDL!{#[uuid(0x6d5140c1, 0x7436, 0x11ce, 0x80, 0x34, 0x00, 0xaa, 0x00, 0x60, 0x09, 0xfa)] interface IServiceProvider(IServiceProviderVtbl): IUnknown(IUnknownVtbl) { fn QueryService( guidService: REFGUID, @@ -21,4 +21,4 @@ riid: REFIID, ppvObject: *mut *mut IUnknown, ) -> HRESULT, -}); +}} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/shellapi.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/shellapi.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/shellapi.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/shellapi.rs 2018-12-05 01:24:42.000000000 +0000 @@ -19,7 +19,7 @@ PZZSTR, PZZWSTR, ULARGE_INTEGER, WCHAR, }; use um::winuser::WM_USER; -DECLARE_HANDLE!(HDROP, HDROP__); +DECLARE_HANDLE!{HDROP, HDROP__} extern "system" { pub fn DragQueryFileA( hDrop: HDROP, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/shobjidl_core.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/shobjidl_core.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/shobjidl_core.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/shobjidl_core.rs 2018-12-05 01:24:41.000000000 +0000 @@ -4,15 +4,13 @@ // , at your option. // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. - use ctypes::{c_int, c_void}; use shared::guiddef::{REFGUID, REFIID}; use shared::minwindef::{BOOL, ULONG}; -use shared::windef::{HWND}; +use shared::windef::HWND; use um::objidl::IBindCtx; use um::unknwnbase::{IUnknown, IUnknownVtbl}; use um::winnt::{HRESULT, LPWSTR}; - DEFINE_GUID!{CLSID_TaskbarList, 0x56fdf344, 0xfd6d, 0x11d0, 0x95, 0x8a, 0x00, 0x60, 0x97, 0xc9, 0xa0, 0x90} //4498 @@ -36,7 +34,7 @@ SICHINT_CANONICAL = 0x10000000, SICHINT_TEST_FILESYSPATH_IF_NOT_EQUAL = 0x20000000, }} -RIDL!(#[uuid(0x43826d1e, 0xe718, 0x42ee, 0xbc, 0x55, 0xa1, 0xe2, 0x61, 0xc3, 0x7b, 0xfe)] +RIDL!{#[uuid(0x43826d1e, 0xe718, 0x42ee, 0xbc, 0x55, 0xa1, 0xe2, 0x61, 0xc3, 0x7b, 0xfe)] interface IShellItem(IShellItemVtbl): IUnknown(IUnknownVtbl) { fn BindToHandler( pbc: *mut IBindCtx, @@ -60,18 +58,17 @@ hint: SICHINTF, piOrder: *mut c_int, ) -> HRESULT, -}); +}} //20869 -RIDL!(#[uuid(0xb4db1657, 0x70d7, 0x485e, 0x8e, 0x3e, 0x6f, 0xcb, 0x5a, 0x5c, 0x18, 0x02)] +RIDL!{#[uuid(0xb4db1657, 0x70d7, 0x485e, 0x8e, 0x3e, 0x6f, 0xcb, 0x5a, 0x5c, 0x18, 0x02)] interface IModalWindow(IModalWindowVtbl): IUnknown(IUnknownVtbl) { fn Show( hwndOwner: HWND, ) -> HRESULT, -}); +}} //22307 //27457 pub type IShellItemFilter = IUnknown; // TODO - RIDL!{#[uuid(0x56fdf342, 0xfd6d, 0x11d0, 0x95, 0x8a, 0x00, 0x60, 0x97, 0xc9, 0xa0, 0x90)] interface ITaskbarList(ITaskbarListVtbl): IUnknown(IUnknownVtbl) { fn HrInit() -> HRESULT, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/shobjidl.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/shobjidl.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/shobjidl.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/shobjidl.rs 2018-12-05 01:24:41.000000000 +0000 @@ -4,7 +4,6 @@ // , at your option. // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. - use ctypes::c_void; use shared::guiddef::{REFGUID, REFIID}; use shared::minwindef::{BOOL, DWORD, UINT}; @@ -16,7 +15,6 @@ use um::shtypes::COMDLG_FILTERSPEC; use um::unknwnbase::{IUnknown, IUnknownVtbl}; use um::winnt::{HRESULT, LPCWSTR, LPWSTR, WCHAR}; - pub type IFileOperationProgressSink = IUnknown; // TODO ENUM!{enum SIATTRIBFLAGS { SIATTRIBFLAGS_AND = 0x1, @@ -25,8 +23,7 @@ SIATTRIBFLAGS_MASK = 0x3, SIATTRIBFLAGS_ALLITEMS = 0x4000, }} -RIDL!( -#[uuid(0xb63ea76d, 0x1f85, 0x456f, 0xa1, 0x9c, 0x48, 0x15, 0x9e, 0xfa, 0x85, 0x8b)] +RIDL!{#[uuid(0xb63ea76d, 0x1f85, 0x456f, 0xa1, 0x9c, 0x48, 0x15, 0x9e, 0xfa, 0x85, 0x8b)] interface IShellItemArray(IShellItemArrayVtbl): IUnknown(IUnknownVtbl) { fn BindToHandler( pbc: *mut IBindCtx, @@ -60,7 +57,7 @@ //fn EnumItems( // ppenumShellItems: *mut *mut IEnumShellItems, //) -> HRESULT, -}); +}} ENUM!{enum FDE_OVERWRITE_RESPONSE { FDEOR_DEFAULT = 0, FDEOR_ACCEPT = 1, @@ -75,8 +72,7 @@ FDAP_BOTTOM = 0, FDAP_TOP = 1, }} -RIDL!( -#[uuid(0x973510db, 0x7d7f, 0x452b, 0x89, 0x75, 0x74, 0xa8, 0x58, 0x28, 0xd3, 0x54)] +RIDL!{#[uuid(0x973510db, 0x7d7f, 0x452b, 0x89, 0x75, 0x74, 0xa8, 0x58, 0x28, 0xd3, 0x54)] interface IFileDialogEvents(IFileDialogEventsVtbl): IUnknown(IUnknownVtbl) { fn OnFileOk( pfd: *mut IFileDialog, @@ -104,7 +100,7 @@ psi: *mut IShellItem, pResponse: *mut FDE_OVERWRITE_RESPONSE, ) -> HRESULT, -}); +}} ENUM!{enum FILEOPENDIALOGOPTIONS { FOS_OVERWRITEPROMPT = 0x2, FOS_STRICTFILETYPES = 0x4, @@ -129,8 +125,7 @@ FOS_FORCEPREVIEWPANEON = 0x40000000, FOS_SUPPORTSTREAMABLEITEMS = 0x80000000, }} -RIDL!( -#[uuid(0x42f85136, 0xdb7e, 0x439c, 0x85, 0xf1, 0xe4, 0x07, 0x5d, 0x13, 0x5f, 0xc8)] +RIDL!{#[uuid(0x42f85136, 0xdb7e, 0x439c, 0x85, 0xf1, 0xe4, 0x07, 0x5d, 0x13, 0x5f, 0xc8)] interface IFileDialog(IFileDialogVtbl): IModalWindow(IModalWindowVtbl) { fn SetFileTypes( cFileTypes: UINT, @@ -202,9 +197,8 @@ fn SetFilter( pFilter: *mut IShellItemFilter, ) -> HRESULT, -}); -RIDL!( -#[uuid(0x84bccd23, 0x5fde, 0x4cdb, 0xae, 0xa4, 0xaf, 0x64, 0xb8, 0x3d, 0x78, 0xab)] +}} +RIDL!{#[uuid(0x84bccd23, 0x5fde, 0x4cdb, 0xae, 0xa4, 0xaf, 0x64, 0xb8, 0x3d, 0x78, 0xab)] interface IFileSaveDialog(IFileSaveDialogVtbl): IFileDialog(IFileDialogVtbl) { fn SetSaveAsItem( psi: *mut IShellItem, @@ -225,9 +219,8 @@ hwnd: HWND, pSink: *mut IFileOperationProgressSink, ) -> HRESULT, -}); -RIDL!( -#[uuid(0xd57c7288, 0xd4ad, 0x4768, 0xbe, 0x02, 0x9d, 0x96, 0x95, 0x32, 0xd9, 0x60)] +}} +RIDL!{#[uuid(0xd57c7288, 0xd4ad, 0x4768, 0xbe, 0x02, 0x9d, 0x96, 0x95, 0x32, 0xd9, 0x60)] interface IFileOpenDialog(IFileOpenDialogVtbl): IFileDialog(IFileDialogVtbl) { fn GetResults( ppenum: *mut *mut IShellItemArray, @@ -235,15 +228,14 @@ fn GetSelectedItems( ppsai: *mut *mut IShellItemArray, ) -> HRESULT, -}); +}} ENUM!{enum CDCONTROLSTATEF { CDCS_INACTIVE = 0, CDCS_ENABLED = 0x1, CDCS_VISIBLE = 0x2, CDCS_ENABLEDVISIBLE = 0x3, }} -RIDL!( -#[uuid(0xe6fdd21a, 0x163f, 0x4975, 0x9c, 0x8c, 0xa6, 0x9f, 0x1b, 0xa3, 0x70, 0x34)] +RIDL!{#[uuid(0xe6fdd21a, 0x163f, 0x4975, 0x9c, 0x8c, 0xa6, 0x9f, 0x1b, 0xa3, 0x70, 0x34)] interface IFileDialogCustomize(IFileDialogCustomizeVtbl): IUnknown(IUnknownVtbl) { fn EnableOpenDropDown( dwIDCtl: DWORD, @@ -349,9 +341,8 @@ dwIDItem: DWORD, pszLabel: LPCWSTR, ) -> HRESULT, -}); -RIDL!( -#[uuid(0x36116642, 0xd713, 0x4b97, 0x9b, 0x83, 0x74, 0x84, 0xa9, 0xd0, 0x04, 0x33)] +}} +RIDL!{#[uuid(0x36116642, 0xd713, 0x4b97, 0x9b, 0x83, 0x74, 0x84, 0xa9, 0xd0, 0x04, 0x33)] interface IFileDialogControlEvents(IFileDialogControlEventsVtbl): IUnknown(IUnknownVtbl) { fn OnItemSelected( pfdc: *mut IFileDialogCustomize, @@ -371,9 +362,8 @@ pfdc: *mut IFileDialogCustomize, dwIDCtl: DWORD, ) -> HRESULT, -}); -RIDL!( -#[uuid(0x61744fc7, 0x85b5, 0x4791, 0xa9, 0xb0, 0x27, 0x22, 0x76, 0x30, 0x9b, 0x13)] +}} +RIDL!{#[uuid(0x61744fc7, 0x85b5, 0x4791, 0xa9, 0xb0, 0x27, 0x22, 0x76, 0x30, 0x9b, 0x13)] interface IFileDialog2(IFileDialog2Vtbl): IFileDialog(IFileDialogVtbl) { fn SetCancelButtonLabel( pszLabel: LPCWSTR, @@ -381,4 +371,4 @@ fn SetNavigationRoot( psi: IShellItem, ) -> HRESULT, -}); +}} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/shtypes.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/shtypes.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/shtypes.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/shtypes.rs 2018-12-05 01:24:41.000000000 +0000 @@ -5,11 +5,9 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. //! this ALWAYS GENERATED file contains the definitions for the interfaces - use shared::guiddef::GUID; use shared::minwindef::{BYTE, USHORT}; use um::winnt::LPCWSTR; - STRUCT!{#[repr(packed)] struct SHITEMID { cb: USHORT, abID: [BYTE; 1], diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/subauth.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/subauth.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/subauth.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/subauth.rs 2018-12-05 01:24:41.000000000 +0000 @@ -5,10 +5,8 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. //! Types and macros for Subauthentication Packages. - use shared::minwindef::{PUCHAR, ULONG, USHORT}; use um::winnt::{BOOLEAN, CHAR, LARGE_INTEGER, LONG, PCHAR, PVOID, PWSTR}; - STRUCT!{struct UNICODE_STRING { Length: USHORT, MaximumLength: USHORT, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/systemtopologyapi.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/systemtopologyapi.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/systemtopologyapi.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/systemtopologyapi.rs 2018-12-05 01:24:42.000000000 +0000 @@ -19,4 +19,3 @@ NodeNumber: PUSHORT, ) -> BOOL; } - diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/urlhist.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/urlhist.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/urlhist.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/urlhist.rs 2018-12-05 01:24:42.000000000 +0000 @@ -35,8 +35,7 @@ dwFlags: DWORD, }} pub type LPSTATURL = *mut STATURL; -RIDL!{ -#[uuid(0x3c374a42, 0xbae4, 0x11cf, 0xbf, 0x7d, 0x00, 0xaa, 0x00, 0x69, 0x46, 0xee)] +RIDL!{#[uuid(0x3c374a42, 0xbae4, 0x11cf, 0xbf, 0x7d, 0x00, 0xaa, 0x00, 0x69, 0x46, 0xee)] interface IEnumSTATURL(IEnumSTATURLVtbl): IUnknown(IUnknownVtbl) { fn Next( celt: ULONG, @@ -56,8 +55,7 @@ ) -> HRESULT, }} pub type LPURLHISTORYSTG = *mut IUrlHistoryStg; -RIDL!{ -#[uuid(0x3c374a41, 0xbae4, 0x11cf, 0xbf, 0x7d, 0x00, 0xaa, 0x00, 0x69, 0x46, 0xee)] +RIDL!{#[uuid(0x3c374a41, 0xbae4, 0x11cf, 0xbf, 0x7d, 0x00, 0xaa, 0x00, 0x69, 0x46, 0xee)] interface IUrlHistoryStg(IUrlHistoryStgVtbl): IUnknown(IUnknownVtbl) { fn AddUrl( pocsUrl: LPCOLESTR, @@ -81,8 +79,7 @@ ) -> HRESULT, }} pub type LPURLHISTORYSTG2 = *mut IUrlHistoryStg2; -RIDL!{ -#[uuid(0xafa0dc11, 0xc313, 0x11d0, 0x83, 0x1a, 0x00, 0xc0, 0x4f, 0xd5, 0xae, 0x38)] +RIDL!{#[uuid(0xafa0dc11, 0xc313, 0x11d0, 0x83, 0x1a, 0x00, 0xc0, 0x4f, 0xd5, 0xae, 0x38)] interface IUrlHistoryStg2(IUrlHistoryStg2Vtbl): IUrlHistoryStg(IUrlHistoryStgVtbl) { fn AddUrlAndNotify( pocsUrl: LPCOLESTR, @@ -95,8 +92,7 @@ fn ClearHistory() -> HRESULT, }} pub type LPURLHISTORYNOTIFY = *mut IUrlHistoryNotify; -RIDL!{ -#[uuid(0xbc40bec1, 0xc493, 0x11d0, 0x83, 0x1b, 0x00, 0xc0, 0x4f, 0xd5, 0xae, 0x38)] +RIDL!{#[uuid(0xbc40bec1, 0xc493, 0x11d0, 0x83, 0x1b, 0x00, 0xc0, 0x4f, 0xd5, 0xae, 0x38)] interface IUrlHistoryNotify(IUrlHistoryNotifyVtbl): IOleCommandTarget(IOleCommandTargetVtbl) {} } diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/urlmon.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/urlmon.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/urlmon.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/urlmon.rs 2018-12-05 01:24:42.000000000 +0000 @@ -8,7 +8,7 @@ use shared::minwindef::DWORD; use um::unknwnbase::{IUnknown, IUnknownVtbl}; use um::winnt::{HRESULT, LPCWSTR}; -RIDL!(#[uuid(0x79eac9ee, 0xbaf9, 0x11ce, 0x8c, 0x82, 0x00, 0xaa, 0x00, 0x4b, 0xa9, 0x0b)] +RIDL!{#[uuid(0x79eac9ee, 0xbaf9, 0x11ce, 0x8c, 0x82, 0x00, 0xaa, 0x00, 0x4b, 0xa9, 0x0b)] interface IInternetSecurityManager(IInternetSecurityManagerVtbl): IUnknown(IUnknownVtbl) { fn SetSecuritySite() -> HRESULT, fn GetSecuritySite() -> HRESULT, @@ -18,5 +18,5 @@ dwFlags: DWORD, ) -> HRESULT, // TODO: the rest -}); +}} // TODO: the rest diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/usp10.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/usp10.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/usp10.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/usp10.rs 2018-12-05 01:24:42.000000000 +0000 @@ -16,7 +16,7 @@ pub const USP_E_SCRIPT_NOT_IN_FONT: HRESULT = MAKE_HRESULT!( SEVERITY_ERROR, FACILITY_ITF, 0x200 ); -DECLARE_HANDLE!(SCRIPT_CACHE, SCRIPT_CACHE__); +DECLARE_HANDLE!{SCRIPT_CACHE, SCRIPT_CACHE__} extern "system" { pub fn ScriptFreeCache( psc: *mut SCRIPT_CACHE @@ -25,7 +25,7 @@ STRUCT!{struct SCRIPT_CONTROL { bit_fields: DWORD, }} -BITFIELD!(SCRIPT_CONTROL bit_fields: DWORD [ +BITFIELD!{SCRIPT_CONTROL bit_fields: DWORD [ uDefaultLanguage set_uDefaultLanguage[0..16], fContextDigits set_fContextDigits[16..17], fInvertPreBoundDir set_fInvertPreBoundDir[17..18], @@ -37,11 +37,11 @@ fLegacyBidiClass set_fLegacyBidiClass[23..24], fMergeNeutralItems set_fMergeNeutralItems[24..25], fReserved set_fReserved[25..32], -]); +]} STRUCT!{struct SCRIPT_STATE { bit_fields: WORD, }} -BITFIELD!(SCRIPT_STATE bit_fields: WORD [ +BITFIELD!{SCRIPT_STATE bit_fields: WORD [ uBidiLevel set_uBidiLevel[0..5], fOverrideDirection set_fOverrideDirection[5..6], fInhibitSymSwap set_fInhibitSymSwap[6..7], @@ -53,12 +53,12 @@ fGcpClusters set_fGcpClusters[12..13], fReserved set_fReserved[13..14], fEngineReserved set_fEngineReserved[14..16], -]); +]} STRUCT!{struct SCRIPT_ANALYSIS { bit_fields: WORD, s: SCRIPT_STATE, }} -BITFIELD!(SCRIPT_ANALYSIS bit_fields: WORD [ +BITFIELD!{SCRIPT_ANALYSIS bit_fields: WORD [ eScript set_eScript[0..10], fRTL set_fRTL[10..11], fLayoutRTL set_fLayoutRTL[11..12], @@ -66,7 +66,7 @@ fLinkAfter set_fLinkAfter[13..14], fLogicalOrder set_fLogicalOrder[14..15], fNoGlyphIndex set_fNoGlyphIndex[15..16], -]); +]} STRUCT!{struct SCRIPT_ITEM { iCharPos: c_int, a: SCRIPT_ANALYSIS, @@ -107,14 +107,14 @@ STRUCT!{struct SCRIPT_VISATTR { bit_fields: WORD, }} -BITFIELD!(SCRIPT_VISATTR bit_fields: WORD [ +BITFIELD!{SCRIPT_VISATTR bit_fields: WORD [ uJustification set_uJustification[0..4], fClusterStart set_fClusterStart[4..5], fDiacritic set_fDiacritic[5..6], fZeroWidth set_fZeroWidth[6..7], fReserved set_fReserved[7..8], fShapeReserved set_fShapeReserved[8..16], -]); +]} extern "system" { pub fn ScriptShape( hdc: HDC, @@ -173,14 +173,14 @@ STRUCT!{struct SCRIPT_LOGATTR { bit_fields: BYTE, }} -BITFIELD!(SCRIPT_LOGATTR bit_fields: BYTE [ +BITFIELD!{SCRIPT_LOGATTR bit_fields: BYTE [ fSoftBreak set_fSoftBreak[0..1], fWhiteSpace set_fWhiteSpace[1..2], fCharStop set_fCharStop[2..3], fWordStop set_fWordStop[3..4], fInvalid set_fInvalid[4..5], fReserved set_fReserved[5..8], -]); +]} extern "system" { pub fn ScriptBreak( pwcChars: *const WCHAR, @@ -252,7 +252,7 @@ bit_fields1: DWORD, bit_fields2: DWORD, }} -BITFIELD!(SCRIPT_PROPERTIES bit_fields1: DWORD [ +BITFIELD!{SCRIPT_PROPERTIES bit_fields1: DWORD [ langid set_langid[0..16], fNumeric set_fNumeric[16..17], fComplex set_fComplex[17..18], @@ -263,14 +263,14 @@ fPrivateUseArea set_fPrivateUseArea[29..30], fNeedsCharacterJustify set_fNeedsCharacterJustify[30..31], fInvalidGlyph set_fInvalidGlyph[31..32], -]); -BITFIELD!(SCRIPT_PROPERTIES bit_fields2: DWORD [ +]} +BITFIELD!{SCRIPT_PROPERTIES bit_fields2: DWORD [ fInvalidLogAttr set_fInvalidLogAttr[0..1], fCDM set_fCDM[1..2], fAmbiguousCharSet set_fAmbiguousCharSet[2..3], fClusterSizeVaries set_fClusterSizeVaries[3..4], fRejectInvalid set_fRejectInvalid[4..5], -]); +]} extern "system" { pub fn ScriptGetProperties( ppSp: *mut *mut *const SCRIPT_PROPERTIES, @@ -324,7 +324,7 @@ pTabStops: *mut c_int, iTabOrigin: c_int, }} -DECLARE_HANDLE!(SCRIPT_STRING_ANALYSIS, SCRIPT_STRING_ANALYSIS__); +DECLARE_HANDLE!{SCRIPT_STRING_ANALYSIS, SCRIPT_STRING_ANALYSIS__} extern "system" { pub fn ScriptStringAnalyse( hdc: HDC, @@ -402,13 +402,13 @@ bit_fields2: DWORD, dwReserved: DWORD, }} -BITFIELD!(SCRIPT_DIGITSUBSTITUTE bit_fields1: DWORD [ +BITFIELD!{SCRIPT_DIGITSUBSTITUTE bit_fields1: DWORD [ NationalDigitLanguage set_NationalDigitLanguage[0..16], TraditionalDigitLanguage set_TraditionalDigitLanguage[16..32], -]); -BITFIELD!(SCRIPT_DIGITSUBSTITUTE bit_fields2: DWORD [ +]} +BITFIELD!{SCRIPT_DIGITSUBSTITUTE bit_fields2: DWORD [ DigitSubstitute set_DigitSubstitute[0..8], -]); +]} extern "system" { pub fn ScriptRecordDigitSubstitution( Locale: LCID, @@ -439,10 +439,10 @@ STRUCT!{struct SCRIPT_CHARPROP { bit_fields: WORD, }} -BITFIELD!(SCRIPT_CHARPROP bit_fields: WORD [ +BITFIELD!{SCRIPT_CHARPROP bit_fields: WORD [ fCanGlyphAlone set_fCanGlyphAlone[0..1], reserved set_reserved[1..16], -]); +]} STRUCT!{struct SCRIPT_GLYPHPROP { sva: SCRIPT_VISATTR, reserved: WORD, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/uxtheme.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/uxtheme.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/uxtheme.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/uxtheme.rs 2018-12-05 01:24:41.000000000 +0000 @@ -0,0 +1,773 @@ +// Copyright © 2018 winapi-rs developers +// Licensed under the Apache License, Version 2.0 +// or the MIT license +// , at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. +//! theming API +use ctypes::{c_float, c_int, c_void}; +use shared::minwindef::{BOOL, BYTE, DWORD, HINSTANCE, HRGN, LPARAM, UINT, ULONG, WORD}; +use shared::windef::{COLORREF, HBITMAP, HBRUSH, HDC, HWND, LPCRECT, LPRECT, POINT, RECT, SIZE}; +use um::commctrl::HIMAGELIST; +use um::wingdi::{BLENDFUNCTION, LOGFONTW, RGBQUAD, TEXTMETRICW}; +use um::winnt::{HANDLE, HRESULT, LONG, LPCWSTR, LPWSTR, PVOID, VOID}; +pub type HTHEME = HANDLE; +//pub const MAX_THEMECOLOR: u32 = 64; +//pub const MAX_THEMESIZE: u32 = 64; +extern "system" { + pub fn BeginPanningFeedback( + hwnd: HWND, + ) -> BOOL; + pub fn UpdatePanningFeedback( + hwnd: HWND, + lTotalOverpanOffsetX: LONG, + lTotalOverpanOffsetY: LONG, + fInInertia: BOOL, + ) -> BOOL; + pub fn EndPanningFeedback( + hwnd: HWND, + fAnimateBack: BOOL, + ) -> BOOL; +} +ENUM!{enum TA_PROPERTY { + TAP_FLAGS = 0, + TAP_TRANSFORMCOUNT = 1, + TAP_STAGGERDELAY = 2, + TAP_STAGGERDELAYCAP = 3, + TAP_STAGGERDELAYFACTOR = 4, + TAP_ZORDER = 5, +}} +ENUM!{enum TA_PROPERTY_FLAG { + TAPF_NONE = 0x0, + TAPF_HASSTAGGER = 0x1, + TAPF_ISRTLAWARE = 0x2, + TAPF_ALLOWCOLLECTION = 0x4, + TAPF_HASBACKGROUND = 0x8, + TAPF_HASPERSPECTIVE = 0x10, +}} +extern "system" { + pub fn GetThemeAnimationProperty( + hTheme: HTHEME, + iStoryboardId: c_int, + iTargetId: c_int, + eProperty: TA_PROPERTY, + pvProperty: *mut VOID, + cbSize: DWORD, + pcbSizeOut: *mut DWORD, + ) -> HRESULT; +} +ENUM!{enum TA_TRANSFORM_TYPE { + TATT_TRANSLATE_2D = 0, + TATT_SCALE_2D = 1, + TATT_OPACITY = 2, + TATT_CLIP = 3, +}} +ENUM!{enum TA_TRANSFORM_FLAG { + TATF_NONE = 0x0, + TATF_TARGETVALUES_USER = 0x1, + TATF_HASINITIALVALUES = 0x2, + TATF_HASORIGINVALUES = 0x4, +}} +STRUCT!{struct TA_TRANSFORM { + eTransformType: TA_TRANSFORM_TYPE, + dwTimingFunctionId: DWORD, + dwStartTime: DWORD, + dwDurationTime: DWORD, + eFlags: TA_TRANSFORM_FLAG, +}} +pub type PTA_TRANSFORM = *mut TA_TRANSFORM; +STRUCT!{struct TA_TRANSFORM_2D { + header: TA_TRANSFORM, + rX: c_float, + rY: c_float, + rInitialX: c_float, + rInitialY: c_float, + rOriginX: c_float, + rOriginY: c_float, +}} +pub type PTA_TRANSFORM_2D = *mut TA_TRANSFORM_2D; +STRUCT!{struct TA_TRANSFORM_OPACITY { + header: TA_TRANSFORM, + rOpacity: c_float, + rInitialOpacity: c_float, +}} +pub type PTA_TRANSFORM_OPACITY = *mut TA_TRANSFORM_OPACITY; +STRUCT!{struct TA_TRANSFORM_CLIP { + header: TA_TRANSFORM, + rLeft: c_float, + rTop: c_float, + rRight: c_float, + rBottom: c_float, + rInitialLeft: c_float, + rInitialTop: c_float, + rInitialRight: c_float, + rInitialBottom: c_float, +}} +pub type PTA_TRANSFORM_CLIP = *mut TA_TRANSFORM_CLIP; +extern "system" { + pub fn GetThemeAnimationTransform( + hTheme: HTHEME, + iStoryboardId: c_int, + iTargetId: c_int, + dwTransformIndex: DWORD, + pTransform: *mut TA_TRANSFORM, + cbSize: DWORD, + pcbSizeOut: *mut DWORD, + ) -> HRESULT; +} +ENUM!{enum TA_TIMINGFUNCTION_TYPE { + TTFT_UNDEFINED = 0, + TTFT_CUBIC_BEZIER = 1, +}} +STRUCT!{struct TA_TIMINGFUNCTION { + eTimingFunctionType: TA_TIMINGFUNCTION_TYPE, +}} +pub type PTA_TIMINGFUNCTION = *mut TA_TIMINGFUNCTION; +STRUCT!{struct TA_CUBIC_BEZIER { + header: TA_TIMINGFUNCTION, + rX0: c_float, + rY0: c_float, + rX1: c_float, + rY1: c_float, +}} +pub type PTA_CUBIC_BEZIER = *mut TA_CUBIC_BEZIER; +extern "system" { + pub fn GetThemeTimingFunction( + hTheme: HTHEME, + iTimingFunctionId: c_int, + pTimingFunction: *mut TA_TIMINGFUNCTION, + cbSize: DWORD, + pcbSizeOut: *mut DWORD, + ) -> HRESULT; + pub fn OpenThemeData( + hwnd: HWND, + pszClassList: LPCWSTR, + ) -> HTHEME; +} +pub const OTD_FORCE_RECT_SIZING: DWORD = 0x00000001; +pub const OTD_NONCLIENT: DWORD = 0x00000002; +pub const OTD_VALIDBITS: DWORD = OTD_FORCE_RECT_SIZING | OTD_NONCLIENT; +extern "system" { + pub fn OpenThemeDataForDpi( + hwnd: HWND, + pszClassList: LPCWSTR, + dpi: UINT, + ) -> HTHEME; + pub fn OpenThemeDataEx( + hwnd: HWND, + pszClassList: LPCWSTR, + dwFlags: DWORD, + ) -> HTHEME; + pub fn CloseThemeData( + hTheme: HTHEME, + ) -> HRESULT; + pub fn DrawThemeBackground( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + pRect: LPCRECT, + pClipRect: LPCRECT, + ) -> HRESULT; +} +pub const DTBG_CLIPRECT: DWORD = 0x00000001; +pub const DTBG_DRAWSOLID: DWORD = 0x00000002; +pub const DTBG_OMITBORDER: DWORD = 0x00000004; +pub const DTBG_OMITCONTENT: DWORD = 0x00000008; +pub const DTBG_COMPUTINGREGION: DWORD = 0x00000010; +pub const DTBG_MIRRORDC: DWORD = 0x00000020; +pub const DTBG_NOMIRROR: DWORD = 0x00000040; +pub const DTBG_VALIDBITS: DWORD = DTBG_CLIPRECT | DTBG_DRAWSOLID | DTBG_OMITBORDER + | DTBG_OMITCONTENT | DTBG_COMPUTINGREGION | DTBG_MIRRORDC | DTBG_NOMIRROR; +STRUCT!{struct DTBGOPTS { + dwSize: DWORD, + dwFlags: DWORD, + rcClip: RECT, +}} +pub type PDTBGOPTS = *mut DTBGOPTS; +extern "system" { + pub fn DrawThemeBackgroundEx( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + pRect: LPCRECT, + pOptions: *const DTBGOPTS, + ) -> HRESULT; +} +//pub const DTT_GRAYED: u32 = 0x00000001; +//pub const DTT_FLAGS2VALIDBITS: u32 = DTT_GRAYED; +extern "system" { + pub fn DrawThemeText( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + pszText: LPCWSTR, + cchText: c_int, + dwTextFlags: DWORD, + dwTextFlags2: DWORD, + pRect: LPCRECT, + ) -> HRESULT; + pub fn GetThemeBackgroundContentRect( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + pBoundingRect: LPCRECT, + pContentRect: LPRECT, + ) -> HRESULT; + pub fn GetThemeBackgroundExtent( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + pContentRect: LPCRECT, + pExtentRect: LPRECT, + ) -> HRESULT; + pub fn GetThemeBackgroundRegion( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + pRect: LPCRECT, + pRegion: *mut HRGN, + ) -> HRESULT; +} +ENUM!{enum THEMESIZE { + TS_MIN = 0, + TS_TRUE = 1, + TS_DRAW = 2, +}} +extern "system" { + pub fn GetThemePartSize( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + prc: LPCRECT, + eSize: THEMESIZE, + psz: *mut SIZE, + ) -> HRESULT; + pub fn GetThemeTextExtent( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + pszText: LPCWSTR, + cchCharCount: c_int, + dwTextFlags: DWORD, + pBoundingRect: LPCRECT, + pExtentRect: LPRECT, + ) -> HRESULT; + pub fn GetThemeTextMetrics( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + ptm: *mut TEXTMETRICW, + ) -> HRESULT; +} +pub const HTTB_BACKGROUNDSEG: DWORD = 0x00000000; +pub const HTTB_FIXEDBORDER: DWORD = 0x00000002; +pub const HTTB_CAPTION: DWORD = 0x00000004; +pub const HTTB_RESIZINGBORDER_LEFT: DWORD = 0x00000010; +pub const HTTB_RESIZINGBORDER_TOP: DWORD = 0x00000020; +pub const HTTB_RESIZINGBORDER_RIGHT: DWORD = 0x00000040; +pub const HTTB_RESIZINGBORDER_BOTTOM: DWORD = 0x00000080; +pub const HTTB_RESIZINGBORDER: DWORD = HTTB_RESIZINGBORDER_LEFT | HTTB_RESIZINGBORDER_TOP + | HTTB_RESIZINGBORDER_RIGHT | HTTB_RESIZINGBORDER_BOTTOM; +pub const HTTB_SIZINGTEMPLATE: DWORD = 0x00000100; +pub const HTTB_SYSTEMSIZINGMARGINS: DWORD = 0x00000200; +extern "system" { + pub fn HitTestThemeBackground( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + dwOptions: DWORD, + pRect: LPCRECT, + hrgn: HRGN, + ptTest: POINT, + pwHitTestCode: *mut WORD, + ) -> HRESULT; + pub fn DrawThemeEdge( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + pDestRect: LPCRECT, + uEdge: UINT, + uFlags: UINT, + pContentRect: LPRECT, + ) -> HRESULT; + pub fn DrawThemeIcon( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + pRect: LPCRECT, + himl: HIMAGELIST, + iImageIndex: c_int, + ) -> HRESULT; + pub fn IsThemePartDefined( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + ) -> BOOL; + pub fn IsThemeBackgroundPartiallyTransparent( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + ) -> BOOL; + pub fn GetThemeColor( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + pColor: *mut COLORREF, + ) -> HRESULT; + pub fn GetThemeMetric( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + piVal: *mut c_int, + ) -> HRESULT; + pub fn GetThemeString( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + pszBuff: LPWSTR, + cchMaxBuffChars: c_int, + ) -> HRESULT; + pub fn GetThemeBool( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + pfVal: *mut BOOL, + ) -> HRESULT; + pub fn GetThemeInt( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + piVal: *mut c_int, + ) -> HRESULT; + pub fn GetThemeEnumValue( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + piVal: *mut c_int, + ) -> HRESULT; + pub fn GetThemePosition( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + pPoint: *mut POINT, + ) -> HRESULT; + pub fn GetThemeFont( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + pFont: *mut LOGFONTW, + ) -> HRESULT; + pub fn GetThemeRect( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + pRect: LPRECT, + ) -> HRESULT; +} +STRUCT!{struct MARGINS { + cxLeftWidth: c_int, + cxRightWidth: c_int, + cyTopHeight: c_int, + cyBottomHeight: c_int, +}} +pub type PMARGINS = *mut MARGINS; +extern "system" { + pub fn GetThemeMargins( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + prc: LPCRECT, + pMargins: *mut MARGINS, + ) -> HRESULT; +} +pub const MAX_INTLIST_COUNT: usize = 402; +STRUCT!{struct INTLIST { + iValueCount: c_int, + iValues: [c_int; MAX_INTLIST_COUNT], +}} +pub type PINTLIST = *mut INTLIST; +extern "system" { + pub fn GetThemeIntList( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + pIntList: *mut INTLIST, + ) -> HRESULT; +} +ENUM!{enum PROPERTYORIGIN { + PO_STATE = 0, + PO_PART = 1, + PO_CLASS = 2, + PO_GLOBAL = 3, + PO_NOTFOUND = 4, +}} +extern "system" { + pub fn GetThemePropertyOrigin( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + pOrigin: *mut PROPERTYORIGIN, + ) -> HRESULT; + pub fn SetWindowTheme( + hwnd: HWND, + pszSubAppName: LPCWSTR, + pszSubIdList: LPCWSTR, + ) -> HRESULT; + pub fn GetThemeFilename( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + pszThemeFileName: LPWSTR, + cchMaxBuffChars: c_int, + ) -> HRESULT; + pub fn GetThemeSysColor( + hTheme: HTHEME, + iColorId: c_int, + ) -> COLORREF; + pub fn GetThemeSysColorBrush( + hTheme: HTHEME, + iColorId: c_int, + ) -> HBRUSH; + pub fn GetThemeSysBool( + hTheme: HTHEME, + iBoolId: c_int, + ) -> BOOL; + pub fn GetThemeSysSize( + hTheme: HTHEME, + iSizeId: c_int, + ) -> c_int; + pub fn GetThemeSysFont( + hTheme: HTHEME, + iFontId: c_int, + plf: *mut LOGFONTW, + ) -> HRESULT; + pub fn GetThemeSysString( + hTheme: HTHEME, + iStringId: c_int, + pszStringBuff: LPWSTR, + cchMaxStringChars: c_int, + ) -> HRESULT; + pub fn GetThemeSysInt( + hTheme: HTHEME, + iIntId: c_int, + piValue: *mut c_int, + ) -> HRESULT; + pub fn IsThemeActive() -> BOOL; + pub fn IsAppThemed() -> BOOL; + pub fn GetWindowTheme( + hwnd: HWND, + ) -> HTHEME; +} +pub const ETDT_DISABLE: DWORD = 0x00000001; +pub const ETDT_ENABLE: DWORD = 0x00000002; +pub const ETDT_USETABTEXTURE: DWORD = 0x00000004; +pub const ETDT_ENABLETAB: DWORD = ETDT_ENABLE | ETDT_USETABTEXTURE; +pub const ETDT_USEAEROWIZARDTABTEXTURE: DWORD = 0x00000008; +pub const ETDT_ENABLEAEROWIZARDTAB: DWORD = ETDT_ENABLE | ETDT_USEAEROWIZARDTABTEXTURE; +pub const ETDT_VALIDBITS: DWORD = ETDT_DISABLE | ETDT_ENABLE | ETDT_USETABTEXTURE + | ETDT_USEAEROWIZARDTABTEXTURE; +extern "system" { + pub fn EnableThemeDialogTexture( + hwnd: HWND, + dwFlags: DWORD, + ) -> HRESULT; + pub fn IsThemeDialogTextureEnabled( + hwnd: HWND, + ) -> BOOL; +} +pub const STAP_ALLOW_NONCLIENT: DWORD = 1 << 0; +pub const STAP_ALLOW_CONTROLS: DWORD = 1 << 1; +pub const STAP_ALLOW_WEBCONTENT: DWORD = 1 << 2; +pub const STAP_VALIDBITS: DWORD = STAP_ALLOW_NONCLIENT | STAP_ALLOW_CONTROLS + | STAP_ALLOW_WEBCONTENT; +extern "system" { + pub fn GetThemeAppProperties() -> DWORD; + pub fn SetThemeAppProperties( + dwFlags: DWORD, + ); + pub fn GetCurrentThemeName( + pszThemeFileName: LPWSTR, + cchMaxNameChars: c_int, + pszColorBuff: LPWSTR, + cchMaxColorChars: c_int, + pszSizeBuff: LPWSTR, + cchMaxSizeChars: c_int, + ) -> HRESULT; +} +pub const SZ_THDOCPROP_DISPLAYNAME: &'static str = "DisplayName"; +pub const SZ_THDOCPROP_CANONICALNAME: &'static str = "ThemeName"; +pub const SZ_THDOCPROP_TOOLTIP: &'static str = "ToolTip"; +pub const SZ_THDOCPROP_AUTHOR: &'static str = "author"; +extern "system" { + pub fn GetThemeDocumentationProperty( + pszThemeName: LPCWSTR, + pszPropertyName: LPCWSTR, + pszValueBuff: LPWSTR, + cchMaxValChars: c_int, + ) -> HRESULT; + pub fn DrawThemeParentBackground( + hwnd: HWND, + hdc: HDC, + prc: *const RECT, + ) -> HRESULT; + pub fn EnableTheming( + fEnable: BOOL, + ) -> HRESULT; +} +pub const GBF_DIRECT: ULONG = 0x00000001; +pub const GBF_COPY: ULONG = 0x00000002; +pub const GBF_VALIDBITS: ULONG = GBF_DIRECT | GBF_COPY; +pub const DTPB_WINDOWDC: DWORD = 0x00000001; +pub const DTPB_USECTLCOLORSTATIC: DWORD = 0x00000002; +pub const DTPB_USEERASEBKGND: DWORD = 0x00000004; +extern "system" { + pub fn DrawThemeParentBackgroundEx( + hwnd: HWND, + hdc: HDC, + dwFlags: DWORD, + prc: *const RECT, + ) -> HRESULT; +} +ENUM!{enum WINDOWTHEMEATTRIBUTETYPE { + WTA_NONCLIENT = 1, +}} +STRUCT!{struct WTA_OPTIONS { + dwFlags: DWORD, + dwMask: DWORD, +}} +pub type PWTA_OPTIONS = *mut WTA_OPTIONS; +pub const WTNCA_NODRAWCAPTION: DWORD = 0x00000001; +pub const WTNCA_NODRAWICON: DWORD = 0x00000002; +pub const WTNCA_NOSYSMENU: DWORD = 0x00000004; +pub const WTNCA_NOMIRRORHELP: DWORD = 0x00000008; +pub const WTNCA_VALIDBITS: DWORD = WTNCA_NODRAWCAPTION | WTNCA_NODRAWICON | WTNCA_NOSYSMENU + | WTNCA_NOMIRRORHELP; +extern "system" { + pub fn SetWindowThemeAttribute( + hwnd: HWND, + eAttribute: WINDOWTHEMEATTRIBUTETYPE, + pvAttribute: PVOID, + cbAttribute: DWORD, + ) -> HRESULT; +} +#[inline] +pub unsafe fn SetWindowThemeNonClientAttributes( + hwnd: HWND, + dwMask: DWORD, + dwAttributes: DWORD, +) -> HRESULT { + use core::mem::{size_of, zeroed}; + let mut wta: WTA_OPTIONS = zeroed(); + wta.dwFlags = dwAttributes; + wta.dwMask = dwMask; + SetWindowThemeAttribute( + hwnd, + WTA_NONCLIENT, + &mut wta as *mut WTA_OPTIONS as *mut c_void, + size_of::() as u32, + ) +} +FN!{stdcall DTT_CALLBACK_PROC( + hdc: HDC, + pszText: LPWSTR, + cchText: c_int, + prc: LPRECT, + dwFlags: UINT, + lParam: LPARAM, +) -> c_int} +pub const DTT_TEXTCOLOR: DWORD = 1 << 0; +pub const DTT_BORDERCOLOR: DWORD = 1 << 1; +pub const DTT_SHADOWCOLOR: DWORD = 1 << 2; +pub const DTT_SHADOWTYPE: DWORD = 1 << 3; +pub const DTT_SHADOWOFFSET: DWORD = 1 << 4; +pub const DTT_BORDERSIZE: DWORD = 1 << 5; +pub const DTT_FONTPROP: DWORD = 1 << 6; +pub const DTT_COLORPROP: DWORD = 1 << 7; +pub const DTT_STATEID: DWORD = 1 << 8; +pub const DTT_CALCRECT: DWORD = 1 << 9; +pub const DTT_APPLYOVERLAY: DWORD = 1 << 10; +pub const DTT_GLOWSIZE: DWORD = 1 << 11; +pub const DTT_CALLBACK: DWORD = 1 << 12; +pub const DTT_COMPOSITED: DWORD = 1 << 13; +pub const DTT_VALIDBITS: DWORD = DTT_TEXTCOLOR | DTT_BORDERCOLOR | DTT_SHADOWCOLOR + | DTT_SHADOWTYPE | DTT_SHADOWOFFSET | DTT_BORDERSIZE | DTT_FONTPROP | DTT_COLORPROP + | DTT_STATEID | DTT_CALCRECT | DTT_APPLYOVERLAY | DTT_GLOWSIZE | DTT_COMPOSITED; +STRUCT!{struct DTTOPTS { + dwSize: DWORD, + dwFlags: DWORD, + crText: COLORREF, + crBorder: COLORREF, + crShadow: COLORREF, + iTextShadowType: c_int, + ptShadowOffset: POINT, + iBorderSize: c_int, + iFontPropId: c_int, + iColorPropId: c_int, + iStateId: c_int, + fApplyOverlay: BOOL, + iGlowSize: c_int, + pfnDrawTextCallback: DTT_CALLBACK_PROC, + lParam: LPARAM, +}} +pub type PDTTOPTS = *mut DTTOPTS; +extern "system" { + pub fn DrawThemeTextEx( + hTheme: HTHEME, + hdc: HDC, + iPartId: c_int, + iStateId: c_int, + pszText: LPCWSTR, + cchText: c_int, + dwTextFlags: DWORD, + pRect: LPRECT, + pOptions: *const DTTOPTS, + ) -> HRESULT; + pub fn GetThemeBitmap( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + dwFlags: ULONG, + phBitmap: *mut HBITMAP, + ) -> HRESULT; + pub fn GetThemeStream( + hTheme: HTHEME, + iPartId: c_int, + iStateId: c_int, + iPropId: c_int, + ppvStream: *mut *mut VOID, + pcbStream: *mut DWORD, + hInst: HINSTANCE, + ) -> HRESULT; + pub fn BufferedPaintInit() -> HRESULT; + pub fn BufferedPaintUnInit() -> HRESULT; +} +pub type HPAINTBUFFER = HANDLE; +ENUM!{enum BP_BUFFERFORMAT { + BPBF_COMPATIBLEBITMAP = 0, + BPBF_DIB = 1, + BPBF_TOPDOWNDIB = 2, + BPBF_TOPDOWNMONODIB = 3, +}} +pub const BPBF_COMPOSITED: BP_BUFFERFORMAT = BPBF_TOPDOWNDIB; +ENUM!{enum BP_ANIMATIONSTYLE { + BPAS_NONE = 0, + BPAS_LINEAR = 1, + BPAS_CUBIC = 2, + BPAS_SINE = 3, +}} +STRUCT!{struct BP_ANIMATIONPARAMS { + cbSize: DWORD, + dwFlags: DWORD, + style: BP_ANIMATIONSTYLE, + dwDuration: DWORD, +}} +pub type PBP_ANIMATIONPARAMS = *mut BP_ANIMATIONPARAMS; +pub const BPPF_ERASE: DWORD = 0x0001; +pub const BPPF_NOCLIP: DWORD = 0x0002; +pub const BPPF_NONCLIENT: DWORD = 0x0004; +STRUCT!{struct BP_PAINTPARAMS { + cbSize: DWORD, + dwFlags: DWORD, + prcExclude: *const RECT, + pBlendFunction: *const BLENDFUNCTION, +}} +pub type PBP_PAINTPARAMS = *mut BP_PAINTPARAMS; +extern "system" { + pub fn BeginBufferedPaint( + hdcTarget: HDC, + prcTarget: *const RECT, + dwFormat: BP_BUFFERFORMAT, + pPaintParams: *mut BP_PAINTPARAMS, + phdc: *mut HDC, + ) -> HPAINTBUFFER; + pub fn EndBufferedPaint( + hBufferedPaint: HPAINTBUFFER, + fUpdateTarget: BOOL, + ) -> HRESULT; + pub fn GetBufferedPaintTargetRect( + hBufferedPaint: HPAINTBUFFER, + prc: *mut RECT, + ) -> HRESULT; + pub fn GetBufferedPaintTargetDC( + hBufferedPaint: HPAINTBUFFER, + ) -> HDC; + pub fn GetBufferedPaintDC( + hBufferedPaint: HPAINTBUFFER, + ) -> HDC; + pub fn GetBufferedPaintBits( + hBufferedPaint: HPAINTBUFFER, + ppbBuffer: *mut *mut RGBQUAD, + pcxRow: *mut c_int, + ) -> HRESULT; + pub fn BufferedPaintClear( + hBufferedPaint: HPAINTBUFFER, + prc: *const RECT, + ) -> HRESULT; + pub fn BufferedPaintSetAlpha( + hBufferedPaint: HPAINTBUFFER, + prc: *const RECT, + alpha: BYTE, + ) -> HRESULT; + pub fn BufferedPaintStopAllAnimations( + hwnd: HWND, + ) -> HRESULT; +} +pub type HANIMATIONBUFFER = HANDLE; +extern "system" { + pub fn BeginBufferedAnimation( + hwnd: HWND, + hdcTarget: HDC, + prcTarget: *const RECT, + dwFormat: BP_BUFFERFORMAT, + pPaintParams: *mut BP_PAINTPARAMS, + pAnimationParams: *mut BP_ANIMATIONPARAMS, + phdcFrom: *mut HDC, + phdcTo: *mut HDC, + ) -> HANIMATIONBUFFER; + pub fn EndBufferedAnimation( + hbpAnimation: HANIMATIONBUFFER, + fUpdateTarget: BOOL, + ) -> HRESULT; + pub fn BufferedPaintRenderAnimation( + hwnd: HWND, + hdcTarget: HDC, + ) -> BOOL; + pub fn IsCompositionActive() -> BOOL; + pub fn GetThemeTransitionDuration( + hTheme: HTHEME, + iPartId: c_int, + iStateIdFrom: c_int, + iStateIdTo: c_int, + iPropId: c_int, + pdwDuration: *mut DWORD, + ) -> HRESULT; +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/vsbackup.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/vsbackup.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/vsbackup.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/vsbackup.rs 2018-12-05 01:24:41.000000000 +0000 @@ -20,14 +20,14 @@ VSS_WRITERRESTORE_ENUM }; use um::winnt::{HRESULT, LONG, LPCWSTR}; -DEFINE_GUID!(IID_IVssExamineWriterMetadata, - 0x902fcf7f, 0xb7fd, 0x42f8, 0x81, 0xf1, 0xb2, 0xe4, 0x00, 0xb1, 0xe5, 0xbd); -DEFINE_GUID!(IID_IVssExamineWriterMetadataEx, - 0x0c0e5ec0, 0xca44, 0x472b, 0xb7, 0x02, 0xe6, 0x52, 0xdb, 0x1c, 0x04, 0x51); -DEFINE_GUID!(IID_IVssBackupComponents, - 0x665c1d5f, 0xc218, 0x414d, 0xa0, 0x5d, 0x7f, 0xef, 0x5f, 0x9d, 0x5c, 0x86); -DEFINE_GUID!(IID_IVssBackupComponentsEx, - 0x963f03ad, 0x9e4c, 0x4a34, 0xac, 0x15, 0xe4, 0xb6, 0x17, 0x4e, 0x50, 0x36); +DEFINE_GUID!{IID_IVssExamineWriterMetadata, + 0x902fcf7f, 0xb7fd, 0x42f8, 0x81, 0xf1, 0xb2, 0xe4, 0x00, 0xb1, 0xe5, 0xbd} +DEFINE_GUID!{IID_IVssExamineWriterMetadataEx, + 0x0c0e5ec0, 0xca44, 0x472b, 0xb7, 0x02, 0xe6, 0x52, 0xdb, 0x1c, 0x04, 0x51} +DEFINE_GUID!{IID_IVssBackupComponents, + 0x665c1d5f, 0xc218, 0x414d, 0xa0, 0x5d, 0x7f, 0xef, 0x5f, 0x9d, 0x5c, 0x86} +DEFINE_GUID!{IID_IVssBackupComponentsEx, + 0x963f03ad, 0x9e4c, 0x4a34, 0xac, 0x15, 0xe4, 0xb6, 0x17, 0x4e, 0x50, 0x36} STRUCT!{struct VSS_COMPONENTINFO { type_: VSS_COMPONENT_TYPE, // type is a keyword in rust bstrLogicalPath: BSTR, @@ -46,8 +46,7 @@ cDependencies: UINT, }} pub type PVSSCOMPONENTINFO = *const VSS_COMPONENTINFO; -RIDL!( -#[uuid(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)] +RIDL!{#[uuid(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)] interface IVssWMComponent(IVssWMComponentVtbl): IUnknown(IUnknownVtbl) { fn GetComponentInfo( ppInfo: *mut PVSSCOMPONENTINFO, @@ -71,10 +70,8 @@ iDependency: UINT, ppDependency: *mut *mut IVssWMDependency, ) -> HRESULT, -} -); -RIDL!( -#[uuid(0x902fcf7f, 0xb7fd, 0x42f8, 0x81, 0xf1, 0xb2, 0xe4, 0x00, 0xb1, 0xe5, 0xbd)] +}} +RIDL!{#[uuid(0x902fcf7f, 0xb7fd, 0x42f8, 0x81, 0xf1, 0xb2, 0xe4, 0x00, 0xb1, 0xe5, 0xbd)] interface IVssExamineWriterMetadata(IVssExamineWriterMetadataVtbl): IUnknown(IUnknownVtbl) { fn GetIdentity( pidInstance: *mut VSS_ID, @@ -124,10 +121,8 @@ fn LoadFromXML( pbstrXML: *mut BSTR, ) -> HRESULT, -} -); -RIDL!( -#[uuid(0x0c0e5ec0, 0xca44, 0x472b, 0xb7, 0x02, 0xe6, 0x52, 0xdb, 0x1c, 0x04, 0x51)] +}} +RIDL!{#[uuid(0x0c0e5ec0, 0xca44, 0x472b, 0xb7, 0x02, 0xe6, 0x52, 0xdb, 0x1c, 0x04, 0x51)] interface IVssExamineWriterMetadataEx(IVssExamineWriterMetadataExVtbl): IVssExamineWriterMetadata(IVssExamineWriterMetadataVtbl) { fn GetIdentityEx( @@ -138,10 +133,8 @@ pUsage: *mut VSS_USAGE_TYPE, pSource: *mut VSS_SOURCE_TYPE, ) -> HRESULT, -} -); -RIDL!( -#[uuid(0xce115780, 0xa611, 0x431b, 0xb5, 0x7f, 0xc3, 0x83, 0x03, 0xab, 0x6a, 0xee)] +}} +RIDL!{#[uuid(0xce115780, 0xa611, 0x431b, 0xb5, 0x7f, 0xc3, 0x83, 0x03, 0xab, 0x6a, 0xee)] interface IVssExamineWriterMetadataEx2(IVssExamineWriterMetadataEx2Vtbl): IVssExamineWriterMetadataEx(IVssExamineWriterMetadataExVtbl) { fn GetVersion( @@ -155,8 +148,7 @@ iFile: UINT, ppFiledesc: *mut *mut IVssWMFiledesc, ) -> HRESULT, -} -); +}} #[repr(C)] pub struct IVssWriterComponentsExt { pub lpVtbl: *const IVssWriterComponentsExtVtbl, @@ -166,8 +158,7 @@ pub parent1: IVssWriterComponentsVtbl, pub parent2: IUnknownVtbl, } -RIDL!( -#[uuid(0x665c1d5f, 0xc218, 0x414d, 0xa0, 0x5d, 0x7f, 0xef, 0x5f, 0x9d, 0x5c, 0x86)] +RIDL!{#[uuid(0x665c1d5f, 0xc218, 0x414d, 0xa0, 0x5d, 0x7f, 0xef, 0x5f, 0x9d, 0x5c, 0x86)] interface IVssBackupComponents(IVssBackupComponentsVtbl): IUnknown(IUnknownVtbl) { fn GetWriterComponentsCount( pcComponents: *mut UINT, @@ -397,10 +388,8 @@ pwszVolume: VSS_PWSZ, ppAsync: *mut *mut IVssAsync, ) -> HRESULT, -} -); -RIDL!( -#[uuid(0x963f03ad, 0x9e4c, 0x4a34, 0xac, 0x15, 0xe4, 0xb6, 0x17, 0x4e, 0x50, 0x36)] +}} +RIDL!{#[uuid(0x963f03ad, 0x9e4c, 0x4a34, 0xac, 0x15, 0xe4, 0xb6, 0x17, 0x4e, 0x50, 0x36)] interface IVssBackupComponentsEx(IVssBackupComponentsExVtbl): IVssBackupComponents(IVssBackupComponentsVtbl) { fn GetWriterMetadataEx( @@ -416,10 +405,8 @@ bSelectedForRestore: bool, instanceId: VSS_ID, ) -> HRESULT, -} -); -RIDL!( -#[uuid(0xacfe2b3a, 0x22c9, 0x4ef8, 0xbd, 0x03, 0x2f, 0x9c, 0xa2, 0x30, 0x08, 0x4e)] +}} +RIDL!{#[uuid(0xacfe2b3a, 0x22c9, 0x4ef8, 0xbd, 0x03, 0x2f, 0x9c, 0xa2, 0x30, 0x08, 0x4e)] interface IVssBackupComponentsEx2(IVssBackupComponentsEx2Vtbl): IVssBackupComponentsEx(IVssBackupComponentsExVtbl) { fn UnexposeSnapshot( @@ -462,10 +449,8 @@ dwFastRecoveryFlags: DWORD, ppAsync: *mut *mut IVssAsync, ) -> HRESULT, -} -); -RIDL!( -#[uuid(0xc191bfbc, 0xb602, 0x4675, 0x8b, 0xd1, 0x67, 0xd6, 0x42, 0xf5, 0x29, 0xd5)] +}} +RIDL!{#[uuid(0xc191bfbc, 0xb602, 0x4675, 0x8b, 0xd1, 0x67, 0xd6, 0x42, 0xf5, 0x29, 0xd5)] interface IVssBackupComponentsEx3(IVssBackupComponentsEx3Vtbl): IVssBackupComponentsEx2(IVssBackupComponentsEx2Vtbl) { fn GetWriterStatusEx( @@ -490,10 +475,8 @@ fn GetSessionId( idSession: *mut VSS_ID, ) -> HRESULT, -} -); -RIDL!( -#[uuid(0xf434c2fd, 0xb553, 0x4961, 0xa9, 0xf9, 0xa8, 0xe9, 0x0b, 0x67, 0x3e, 0x53)] +}} +RIDL!{#[uuid(0xf434c2fd, 0xb553, 0x4961, 0xa9, 0xf9, 0xa8, 0xe9, 0x0b, 0x67, 0x3e, 0x53)] interface IVssBackupComponentsEx4(IVssBackupComponentsEx4Vtbl): IVssBackupComponentsEx3(IVssBackupComponentsEx3Vtbl) { fn GetRootAndLogicalPrefixPaths( @@ -502,8 +485,7 @@ ppwszLogicalPrefix: *mut VSS_PWSZ, bNormalizeFQDNforRootPath: BOOL, ) -> HRESULT, -} -); +}} pub const VSS_SW_BOOTABLE_STATE: DWORD = 1; extern "system" { #[link_name="CreateVssBackupComponentsInternal"] diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/vss.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/vss.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/vss.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/vss.rs 2018-12-05 01:24:42.000000000 +0000 @@ -5,12 +5,10 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. //! VSS header file - use shared::guiddef::{CLSID, GUID}; use shared::minwindef::{DWORD, INT, ULONG}; use um::unknwnbase::{IUnknown, IUnknownVtbl}; use um::winnt::{HRESULT, LONG, LONGLONG, WCHAR}; - ENUM!{enum VSS_OBJECT_TYPE { VSS_OBJECT_UNKNOWN = 0, VSS_OBJECT_NONE = 1, @@ -259,8 +257,7 @@ Obj: VSS_OBJECT_UNION, }} pub type PVSS_OBJECT_PROP = *mut VSS_OBJECT_PROP; -RIDL!( -#[uuid(0xae1c7110, 0x2f60, 0x11d3, 0x8a, 0x39, 0x00, 0xc0, 0x4f, 0x72, 0xd8, 0xe3)] +RIDL!{#[uuid(0xae1c7110, 0x2f60, 0x11d3, 0x8a, 0x39, 0x00, 0xc0, 0x4f, 0x72, 0xd8, 0xe3)] interface IVssEnumObject(IVssEnumObjectVtbl): IUnknown(IUnknownVtbl) { fn Next( celt: ULONG, @@ -274,10 +271,8 @@ fn Clone( ppenum: *mut *mut IVssEnumObject, ) -> HRESULT, -} -); -RIDL!( -#[uuid(0x507c37b4, 0xcf5b, 0x4e95, 0xb0, 0xaf, 0x14, 0xeb, 0x97, 0x67, 0x46, 0x7e)] +}} +RIDL!{#[uuid(0x507c37b4, 0xcf5b, 0x4e95, 0xb0, 0xaf, 0x14, 0xeb, 0x97, 0x67, 0x46, 0x7e)] interface IVssAsync(IVssAsyncVtbl): IUnknown(IUnknownVtbl) { fn Cancel() -> HRESULT, fn Wait( @@ -287,5 +282,4 @@ pHrResult: *mut HRESULT, pReserved: *mut INT, ) -> HRESULT, -} -); +}} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/vswriter.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/vswriter.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/vswriter.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/vswriter.rs 2018-12-05 01:24:42.000000000 +0000 @@ -5,13 +5,11 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. //! Declaration of Writer - use shared::minwindef::{BOOL, BYTE, DWORD, FILETIME, UINT}; use shared::wtypes::BSTR; use um::unknwnbase::{IUnknown, IUnknownVtbl}; use um::vss::{VSS_ID, VSS_ROLLFORWARD_TYPE}; use um::winnt::{HRESULT, LPCWSTR, VOID}; - ENUM!{enum VSS_USAGE_TYPE { VSS_UT_UNDEFINED = 0, VSS_UT_BOOTABLESYSTEMSTATE = 1, @@ -78,8 +76,7 @@ VSS_CF_APP_ROLLBACK_RECOVERY = 0x00000002, VSS_CF_NOT_SYSTEM_STATE = 0x00000004, }} -RIDL!( -#[uuid(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)] +RIDL!{#[uuid(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)] interface IVssWMFiledesc(IVssWMFiledescVtbl): IUnknown(IUnknownVtbl) { fn GetPath( pbstrPath: *mut BSTR, @@ -96,10 +93,8 @@ fn GetBackupTypeMask( pdwTypeMask: *mut DWORD, ) -> HRESULT, -} -); -RIDL!( -#[uuid(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)] +}} +RIDL!{#[uuid(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)] interface IVssWMDependency(IVssWMDependencyVtbl): IUnknown(IUnknownVtbl) { fn GetWriterId( pWriterId: *mut VSS_ID, @@ -110,10 +105,8 @@ fn GetComponentName( pbstrComponentName: *mut BSTR, ) -> HRESULT, -} -); -RIDL!( -#[uuid(0xd2c72c96, 0xc121, 0x4518, 0xb6, 0x27, 0xe5, 0xa9, 0x3d, 0x01, 0x0e, 0xad)] +}} +RIDL!{#[uuid(0xd2c72c96, 0xc121, 0x4518, 0xb6, 0x27, 0xe5, 0xa9, 0x3d, 0x01, 0x0e, 0xad)] interface IVssComponent(IVssComponentVtbl): IUnknown(IUnknownVtbl) { fn GetLogicalPath( pbstrPath: *mut BSTR, @@ -263,10 +256,8 @@ pbstrLsnString: *mut BSTR, pftLastModifyTime: *mut FILETIME, ) -> HRESULT, -} -); -RIDL!( -#[uuid(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)] +}} +RIDL!{#[uuid(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)] interface IVssWriterComponents(IVssWriterComponentsVtbl) { fn GetComponentCount( pcComponents: *mut UINT, @@ -279,10 +270,8 @@ iComponent: UINT, ppComponent: *mut *mut IVssComponent, ) -> HRESULT, -} -); -RIDL!( -#[uuid(0x156c8b5e, 0xf131, 0x4bd7, 0x9c, 0x97, 0xd1, 0x92, 0x3b, 0xe7, 0xe1, 0xfa)] +}} +RIDL!{#[uuid(0x156c8b5e, 0xf131, 0x4bd7, 0x9c, 0x97, 0xd1, 0x92, 0x3b, 0xe7, 0xe1, 0xfa)] interface IVssComponentEx(IVssComponentExVtbl): IVssComponent(IVssComponentVtbl) { fn SetPrepareForBackupFailureMsg( wszFailureMsg: LPCWSTR, @@ -306,10 +295,8 @@ fn GetRestoreName( pbstrName: *mut BSTR, ) -> HRESULT, -} -); -RIDL!( -#[uuid(0x3b5be0f2, 0x07a9, 0x4e4b, 0xbd, 0xd3, 0xcf, 0xdc, 0x8e, 0x2c, 0x0d, 0x2d)] +}} +RIDL!{#[uuid(0x3b5be0f2, 0x07a9, 0x4e4b, 0xbd, 0xd3, 0xcf, 0xdc, 0x8e, 0x2c, 0x0d, 0x2d)] interface IVssComponentEx2(IVssComponentEx2Vtbl): IVssComponentEx(IVssComponentExVtbl) { fn SetFailure( hr: HRESULT, @@ -323,10 +310,8 @@ pbstrApplicationMessage: *mut BSTR, pdwReserved: *mut DWORD, ) -> HRESULT, -} -); -RIDL!( -#[uuid(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)] +}} +RIDL!{#[uuid(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)] interface IVssCreateWriterMetadata(IVssCreateWriterMetadataVtbl) { fn AddIncludeFiles( wszPath: LPCWSTR, @@ -403,8 +388,7 @@ fn SaveAsXML( pbstrXML: *mut BSTR, ) -> HRESULT, -} -); +}} //IVssCreateWriterMetadataEx //IVssWriterImpl //IVssCreateExpressWriterMetadata diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/wct.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/wct.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/wct.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/wct.rs 2018-12-05 01:24:41.000000000 +0000 @@ -61,7 +61,7 @@ u: WAITCHAIN_NODE_INFO_u, }} pub type PWAITCHAIN_NODE_INFO = *mut WAITCHAIN_NODE_INFO; -DECLARE_HANDLE!(HWCT, HWCT__); +DECLARE_HANDLE!{HWCT, HWCT__} FN!{cdecl PWAITCHAINCALLBACK( WctHandle: HWCT, Context: DWORD_PTR, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/werapi.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/werapi.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/werapi.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/werapi.rs 2018-12-05 01:24:41.000000000 +0000 @@ -5,7 +5,7 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. //! Function prototypes for Windows Error Reporting (WER) -use shared::minwindef::{DWORD, PDWORD}; +use shared::minwindef::{BOOL, DWORD, PDWORD}; use um::winnt::{HANDLE, HRESULT, PCWSTR, PVOID}; ENUM!{enum WER_REGISTER_FILE_TYPE { WerRegFileTypeUserDocument = 1, @@ -35,6 +35,14 @@ hProcess: HANDLE, pdwFlags: PDWORD ) -> HRESULT; + pub fn WerAddExcludedApplication( + pwzExeName: PCWSTR, + bAllUsers: BOOL + ) -> HRESULT; + pub fn WerRemoveExcludedApplication( + pwzExeName: PCWSTR, + bAllUsers: BOOL + ) -> HRESULT; pub fn WerRegisterRuntimeExceptionModule( pwszOutOfProcessCallbackDll: PCWSTR, pContext: PVOID, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/winbase.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/winbase.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/winbase.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/winbase.rs 2018-12-05 01:24:42.000000000 +0000 @@ -26,18 +26,22 @@ FILE_INFO_BY_HANDLE_CLASS, FINDEX_INFO_LEVELS, FINDEX_SEARCH_OPS, GET_FILEEX_INFO_LEVELS, LPOVERLAPPED, LPOVERLAPPED_COMPLETION_ROUTINE, LPSECURITY_ATTRIBUTES, PREASON_CONTEXT, }; -use um::processthreadsapi::LPSTARTUPINFOA; +use um::processthreadsapi::{LPPROC_THREAD_ATTRIBUTE_LIST, LPSTARTUPINFOA, STARTUPINFOA, STARTUPINFOW}; use um::winnt::{ BOOLEAN, CHAR, DWORDLONG, EXECUTION_STATE, FILE_ID_128, HANDLE, HRESULT, INT, LANGID, LARGE_INTEGER, LATENCY_TIME, LONG, LPCCH, LPCH, LPCSTR, LPCWSTR, LPOSVERSIONINFOEXA, LPOSVERSIONINFOEXW, LPSTR, LPWSTR, MAXLONG, PBOOLEAN, PCONTEXT, PCWSTR, PFIRMWARE_TYPE, PHANDLE, PIO_COUNTERS, PJOB_SET_ARRAY, PLUID, POWER_REQUEST_TYPE, PPERFORMANCE_DATA, - PPROCESSOR_NUMBER, PQUOTA_LIMITS, PRTL_UMS_SCHEDULER_ENTRY_POINT, PSECURE_MEMORY_CACHE_CALLBACK, - PSID, PSID_NAME_USE, PULONGLONG, PVOID, PWOW64_CONTEXT, PWOW64_LDT_ENTRY, PWSTR, - RTL_UMS_THREAD_INFO_CLASS, STATUS_ABANDONED_WAIT_0, STATUS_USER_APC, STATUS_WAIT_0, - THREAD_BASE_PRIORITY_IDLE, THREAD_BASE_PRIORITY_LOWRT, THREAD_BASE_PRIORITY_MAX, - THREAD_BASE_PRIORITY_MIN, ULARGE_INTEGER, VOID, WAITORTIMERCALLBACK, WCHAR, WOW64_CONTEXT, + PPROCESSOR_NUMBER, PQUOTA_LIMITS, PRTL_UMS_SCHEDULER_ENTRY_POINT, + PSECURE_MEMORY_CACHE_CALLBACK, PSID, PSID_NAME_USE, PULONGLONG, PVOID, PWOW64_CONTEXT, + PWOW64_LDT_ENTRY, PWSTR, RTL_UMS_THREAD_INFO_CLASS, STATUS_ABANDONED_WAIT_0, STATUS_USER_APC, + STATUS_WAIT_0, SecurityAnonymous, SecurityDelegation, SecurityIdentification, + SecurityImpersonation, THREAD_BASE_PRIORITY_IDLE, THREAD_BASE_PRIORITY_LOWRT, + THREAD_BASE_PRIORITY_MAX, THREAD_BASE_PRIORITY_MIN, ULARGE_INTEGER, VOID, WAITORTIMERCALLBACK, + WCHAR, WOW64_CONTEXT, }; +#[cfg(target_arch = "x86")] +use um::winnt::PLDT_ENTRY; use vc::vadefs::va_list; pub const FILE_BEGIN: DWORD = 0; pub const FILE_CURRENT: DWORD = 1; @@ -75,6 +79,8 @@ pub const COPY_FILE_REQUEST_SECURITY_PRIVILEGES: DWORD = 0x00002000; pub const COPY_FILE_RESUME_FROM_PAUSE: DWORD = 0x00004000; pub const COPY_FILE_NO_OFFLOAD: DWORD = 0x00040000; +pub const COPY_FILE_IGNORE_EDP_BLOCK: DWORD = 0x00400000; +pub const COPY_FILE_IGNORE_SOURCE_ENCRYPTION: DWORD = 0x00800000; pub const REPLACEFILE_WRITE_THROUGH: DWORD = 0x00000001; pub const REPLACEFILE_IGNORE_MERGE_ERRORS: DWORD = 0x00000002; pub const REPLACEFILE_IGNORE_ACL_ERRORS: DWORD = 0x00000004; @@ -92,6 +98,10 @@ pub const PIPE_ACCEPT_REMOTE_CLIENTS: DWORD = 0x00000000; pub const PIPE_REJECT_REMOTE_CLIENTS: DWORD = 0x00000008; pub const PIPE_UNLIMITED_INSTANCES: DWORD = 255; +pub const SECURITY_ANONYMOUS: DWORD = SecurityAnonymous << 16; +pub const SECURITY_IDENTIFICATION: DWORD = SecurityIdentification << 16; +pub const SECURITY_IMPERSONATION: DWORD = SecurityImpersonation << 16; +pub const SECURITY_DELEGATION: DWORD = SecurityDelegation << 16; pub const SECURITY_CONTEXT_TRACKING: DWORD = 0x00040000; pub const SECURITY_EFFECTIVE_ONLY: DWORD = 0x00080000; pub const SECURITY_SQOS_PRESENT: DWORD = 0x00100000; @@ -104,6 +114,9 @@ lpParameter: LPVOID, ) -> LPVOID} // FAIL_FAST_* +#[cfg(target_arch = "x86")] +pub type LPLDT_ENTRY = PLDT_ENTRY; +#[cfg(target_arch = "x86_64")] pub type LPLDT_ENTRY = LPVOID; // TODO - fix this for 32-bit //SP_SERIALCOMM //PST_* @@ -139,7 +152,7 @@ cbInQue: DWORD, cbOutQue: DWORD, }} -BITFIELD!(COMSTAT BitFields: DWORD [ +BITFIELD!{COMSTAT BitFields: DWORD [ fCtsHold set_fCtsHold[0..1], fDsrHold set_fDsrHold[1..2], fRlsdHold set_fRlsdHold[2..3], @@ -148,7 +161,7 @@ fEof set_fEof[5..6], fTxim set_fTxim[6..7], fReserved set_fReserved[7..32], -]); +]} pub type LPCOMSTAT = *mut COMSTAT; pub const DTR_CONTROL_DISABLE: DWORD = 0x00; pub const DTR_CONTROL_ENABLE: DWORD = 0x01; @@ -174,7 +187,7 @@ EvtChar: c_char, wReserved1: WORD, }} -BITFIELD!(DCB BitFields: DWORD [ +BITFIELD!{DCB BitFields: DWORD [ fBinary set_fBinary[0..1], fParity set_fParity[1..2], fOutxCtsFlow set_fOutxCtsFlow[2..3], @@ -189,7 +202,7 @@ fRtsControl set_fRtsControl[12..14], fAbortOnError set_fAbortOnError[14..15], fDummy2 set_fDummy2[15..32], -]); +]} pub type LPDCB = *mut DCB; STRUCT!{struct COMMTIMEOUTS { ReadIntervalTimeout: DWORD, @@ -281,9 +294,9 @@ pub const FILE_TYPE_CHAR: DWORD = 0x0002; pub const FILE_TYPE_PIPE: DWORD = 0x0003; pub const FILE_TYPE_REMOTE: DWORD = 0x8000; -pub const STD_INPUT_HANDLE: DWORD = 0xFFFFFFF6; -pub const STD_OUTPUT_HANDLE: DWORD = 0xFFFFFFF5; -pub const STD_ERROR_HANDLE: DWORD = 0xFFFFFFF4; +pub const STD_INPUT_HANDLE: DWORD = -10i32 as u32; +pub const STD_OUTPUT_HANDLE: DWORD = -11i32 as u32; +pub const STD_ERROR_HANDLE: DWORD = -12i32 as u32; pub const NOPARITY: BYTE = 0; pub const ODDPARITY: BYTE = 1; pub const EVENPARITY: BYTE = 2; @@ -321,7 +334,10 @@ pub const RESETDEV: DWORD = 7; pub const SETBREAK: DWORD = 8; pub const CLRBREAK: DWORD = 9; -// PURGE_* +pub const PURGE_TXABORT: DWORD = 0x0001; +pub const PURGE_RXABORT: DWORD = 0x0002; +pub const PURGE_TXCLEAR: DWORD = 0x0004; +pub const PURGE_RXCLEAR: DWORD = 0x0008; pub const MS_CTS_ON: DWORD = 0x0010; pub const MS_DSR_ON: DWORD = 0x0020; pub const MS_RING_ON: DWORD = 0x0040; @@ -699,6 +715,10 @@ hFile: HANDLE, lpShortName: LPCWSTR ) -> BOOL; +} +pub const HANDLE_FLAG_INHERIT: DWORD = 0x00000001; +pub const HANDLE_FLAG_PROTECT_FROM_CLOSE: DWORD = 0x00000002; +extern "system" { pub fn LoadModule( lpModuleName: LPCSTR, lpParameterBlock: LPVOID @@ -999,6 +1019,16 @@ pub const STARTF_TITLEISAPPID: DWORD = 0x00001000; pub const STARTF_PREVENTPINNING: DWORD = 0x00002000; pub const STARTF_UNTRUSTEDSOURCE: DWORD = 0x00008000; +STRUCT!{struct STARTUPINFOEXA { + StartupInfo: STARTUPINFOA, + lpAttributeList: LPPROC_THREAD_ATTRIBUTE_LIST, +}} +pub type LPSTARTUPINFOEXA = *mut STARTUPINFOEXA; +STRUCT!{struct STARTUPINFOEXW { + StartupInfo: STARTUPINFOW, + lpAttributeList: LPPROC_THREAD_ATTRIBUTE_LIST, +}} +pub type LPSTARTUPINFOEXW = *mut STARTUPINFOEXW; extern "system" { pub fn OpenMutexA( dwDesiredAccess: DWORD, @@ -2063,8 +2093,24 @@ lpsz: LPCWSTR, ucchMax: UINT_PTR ) -> BOOL; - // pub fn LookupAccountSidA(); - // pub fn LookupAccountSidW(); + pub fn LookupAccountSidA( + lpSystemName: LPCSTR, + Sid: PSID, + Name: LPSTR, + cchName: LPDWORD, + ReferencedDomainName: LPSTR, + cchReferencedDomainName: LPDWORD, + peUse: PSID_NAME_USE, + ) -> BOOL; + pub fn LookupAccountSidW( + lpSystemName: LPCWSTR, + Sid: PSID, + Name: LPWSTR, + cchName: LPDWORD, + ReferencedDomainName: LPWSTR, + cchReferencedDomainName: LPDWORD, + peUse: PSID_NAME_USE, + ) -> BOOL; pub fn LookupAccountNameA( lpSystemName: LPCSTR, lpAccountName: LPCSTR, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/wincodec.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/wincodec.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/wincodec.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/wincodec.rs 2018-12-05 01:24:41.000000000 +0000 @@ -645,7 +645,7 @@ SuccessiveApproximationHigh: BYTE, SuccessiveApproximationLow: BYTE, }} -RIDL!(#[uuid(0x00000040, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] +RIDL!{#[uuid(0x00000040, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] interface IWICPalette(IWICPaletteVtbl): IUnknown(IUnknownVtbl) { fn InitializePredefined( ePaletteType: WICBitmapPaletteType, @@ -683,8 +683,8 @@ fn HasAlpha( pfHasAlpha: *mut BOOL, ) -> HRESULT, -}); -RIDL!(#[uuid(0x00000120, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] +}} +RIDL!{#[uuid(0x00000120, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] interface IWICBitmapSource(IWICBitmapSourceVtbl): IUnknown(IUnknownVtbl) { fn GetSize( puiWidth: *mut UINT, @@ -706,8 +706,8 @@ cbBufferSize: UINT, pbBuffer: *mut BYTE, ) -> HRESULT, -}); -RIDL!(#[uuid(0x00000301, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] +}} +RIDL!{#[uuid(0x00000301, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] interface IWICFormatConverter(IWICFormatConverterVtbl): IWICBitmapSource(IWICBitmapSourceVtbl) { fn Initialize( pISource: *const IWICBitmapSource, @@ -722,8 +722,8 @@ dstPixelFormat: REFWICPixelFormatGUID, pfCanConvert: *mut BOOL, ) -> HRESULT, -}); -RIDL!(#[uuid(0xbebee9cb, 0x83b0, 0x4dcc, 0x81, 0x32, 0xb0, 0xaa, 0xa5, 0x5e, 0xac, 0x96)] +}} +RIDL!{#[uuid(0xbebee9cb, 0x83b0, 0x4dcc, 0x81, 0x32, 0xb0, 0xaa, 0xa5, 0x5e, 0xac, 0x96)] interface IWICPlanarFormatConverter(IWICPlanarFormatConverterVtbl): IWICBitmapSource(IWICBitmapSourceVtbl) { fn Initialize( @@ -741,8 +741,8 @@ dstPixelFormat: REFWICPixelFormatGUID, pfCanConvert: *mut BOOL, ) -> HRESULT, -}); -RIDL!(#[uuid(0x00000302, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] +}} +RIDL!{#[uuid(0x00000302, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] interface IWICBitmapScaler(IWICBitmapScalerVtbl): IWICBitmapSource(IWICBitmapSourceVtbl) { fn Initialize( pISource: *const IWICBitmapSource, @@ -750,23 +750,23 @@ uiHeight: UINT, mode: WICBitmapInterpolationMode, ) -> HRESULT, -}); -RIDL!(#[uuid(0xe4fbcf03, 0x223d, 0x4e81, 0x93, 0x33, 0xd6, 0x35, 0x55, 0x6d, 0xd1, 0xb5)] +}} +RIDL!{#[uuid(0xe4fbcf03, 0x223d, 0x4e81, 0x93, 0x33, 0xd6, 0x35, 0x55, 0x6d, 0xd1, 0xb5)] interface IWICBitmapClipper(IWICBitmapClipperVtbl): IWICBitmapSource(IWICBitmapSourceVtbl) { fn Initialize( pISource: *const IWICBitmapSource, prc: *const WICRect, ) -> HRESULT, -}); -RIDL!(#[uuid(0x5009834f, 0x2d6a, 0x41ce, 0x9e, 0x1b, 0x17, 0xc5, 0xaf, 0xf7, 0xa7, 0x82)] +}} +RIDL!{#[uuid(0x5009834f, 0x2d6a, 0x41ce, 0x9e, 0x1b, 0x17, 0xc5, 0xaf, 0xf7, 0xa7, 0x82)] interface IWICBitmapFlipRotator(IWICBitmapFlipRotatorVtbl): IWICBitmapSource(IWICBitmapSourceVtbl) { fn Initialize( pISource: *const IWICBitmapSource, options: WICBitmapTransformOptions, ) -> HRESULT, -}); -RIDL!(#[uuid(0x00000123, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] +}} +RIDL!{#[uuid(0x00000123, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] interface IWICBitmapLock(IWICBitmapLockVtbl): IUnknown(IUnknownVtbl) { fn GetSize( puiWidth: *mut UINT, @@ -782,8 +782,8 @@ fn GetPixelFormat( pPixelFormat: *mut WICPixelFormatGUID, ) -> HRESULT, -}); -RIDL!(#[uuid(0x00000121, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] +}} +RIDL!{#[uuid(0x00000121, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] interface IWICBitmap(IWICBitmapVtbl): IWICBitmapSource(IWICBitmapSourceVtbl) { fn Lock( prcLock: *const WICRect, @@ -797,8 +797,8 @@ dpiX: c_double, dpiY: c_double, ) -> HRESULT, -}); -RIDL!(#[uuid(0x3c613a02, 0x34b2, 0x44ea, 0x9a, 0x7c, 0x45, 0xae, 0xa9, 0xc6, 0xfd, 0x6d)] +}} +RIDL!{#[uuid(0x3c613a02, 0x34b2, 0x44ea, 0x9a, 0x7c, 0x45, 0xae, 0xa9, 0xc6, 0xfd, 0x6d)] interface IWICColorContext(IWICColorContextVtbl): IUnknown(IUnknownVtbl) { fn InitializeFromFilename( wzFilename: LPCWSTR, @@ -821,8 +821,8 @@ fn GetExifColorSpace( pValue: *mut UINT, ) -> HRESULT, -}); -RIDL!(#[uuid(0xb66f034f, 0xd0e2, 0x40ab, 0xb4, 0x36, 0x6d, 0xe3, 0x9e, 0x32, 0x1a, 0x94)] +}} +RIDL!{#[uuid(0xb66f034f, 0xd0e2, 0x40ab, 0xb4, 0x36, 0x6d, 0xe3, 0x9e, 0x32, 0x1a, 0x94)] interface IWICColorTransform(IWICColorTransformVtbl): IWICBitmapSource(IWICBitmapSourceVtbl) { fn Initialize( pIBitmapSource: *const IWICBitmapSource, @@ -830,16 +830,16 @@ pIContextDest: *const IWICColorContext, pixelFmtDest: REFWICPixelFormatGUID, ) -> HRESULT, -}); -RIDL!(#[uuid(0xb84e2c09, 0x78c9, 0x4ac4, 0x8b, 0xd3, 0x52, 0x4a, 0xe1, 0x66, 0x3a, 0x2f)] +}} +RIDL!{#[uuid(0xb84e2c09, 0x78c9, 0x4ac4, 0x8b, 0xd3, 0x52, 0x4a, 0xe1, 0x66, 0x3a, 0x2f)] interface IWICFastMetadataEncoder(IWICFastMetadataEncoderVtbl): IUnknown(IUnknownVtbl) { fn Commit( ) -> HRESULT, fn GetMetadataQueryWriter( ppIMetadataQueryWriter: *mut *mut IWICMetadataQueryWriter, ) -> HRESULT, -}); -RIDL!(#[uuid(0x135ff860, 0x22b7, 0x4ddf, 0xb0, 0xf6, 0x21, 0x8f, 0x4f, 0x29, 0x9a, 0x43)] +}} +RIDL!{#[uuid(0x135ff860, 0x22b7, 0x4ddf, 0xb0, 0xf6, 0x21, 0x8f, 0x4f, 0x29, 0x9a, 0x43)] interface IWICStream(IWICStreamVtbl): IStream(IStreamVtbl) { fn InitializeFromIStream( pIStream: *const IStream, @@ -857,8 +857,8 @@ ulOffset: ULARGE_INTEGER, ulMaxSize: ULARGE_INTEGER, ) -> HRESULT, -}); -RIDL!(#[uuid(0xdc2bb46d, 0x3f07, 0x481e, 0x86, 0x25, 0x22, 0x0c, 0x4a, 0xed, 0xbb, 0x33)] +}} +RIDL!{#[uuid(0xdc2bb46d, 0x3f07, 0x481e, 0x86, 0x25, 0x22, 0x0c, 0x4a, 0xed, 0xbb, 0x33)] interface IWICEnumMetadataItem(IWICEnumMetadataItemVtbl): IUnknown(IUnknownVtbl) { fn Next( celt: ULONG, @@ -874,8 +874,8 @@ fn Clone( ppIEnumMetadataItem: *mut *mut IWICEnumMetadataItem, ) -> HRESULT, -}); -RIDL!(#[uuid(0x30989668, 0xe1c9, 0x4597, 0xb3, 0x95, 0x45, 0x8e, 0xed, 0xb8, 0x08, 0xdf)] +}} +RIDL!{#[uuid(0x30989668, 0xe1c9, 0x4597, 0xb3, 0x95, 0x45, 0x8e, 0xed, 0xb8, 0x08, 0xdf)] interface IWICMetadataQueryReader(IWICMetadataQueryReaderVtbl): IUnknown(IUnknownVtbl) { fn GetContainerFormat( pguidContainerFormat: *mut GUID, @@ -892,8 +892,8 @@ fn GetEnumerator( ppIEnumString: *mut *mut IEnumString, ) -> HRESULT, -}); -RIDL!(#[uuid(0xa721791a, 0x0def, 0x4d06, 0xbd, 0x91, 0x21, 0x18, 0xbf, 0x1d, 0xb1, 0x0b)] +}} +RIDL!{#[uuid(0xa721791a, 0x0def, 0x4d06, 0xbd, 0x91, 0x21, 0x18, 0xbf, 0x1d, 0xb1, 0x0b)] interface IWICMetadataQueryWriter(IWICMetadataQueryWriterVtbl): IWICMetadataQueryReader(IWICMetadataQueryReaderVtbl) { fn SetMetadataByName( @@ -903,8 +903,8 @@ fn RemoveMetadataByName( wzName: LPCWSTR, ) -> HRESULT, -}); -RIDL!(#[uuid(0x00000103, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] +}} +RIDL!{#[uuid(0x00000103, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] interface IWICBitmapEncoder(IWICBitmapEncoderVtbl): IUnknown(IUnknownVtbl) { fn Initialize( pIStream: *const IStream, @@ -938,8 +938,8 @@ fn GetMetadataQueryWriter( ppIMetadataQueryWriter: *mut *mut IWICMetadataQueryWriter, ) -> HRESULT, -}); -RIDL!(#[uuid(0x00000105, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] +}} +RIDL!{#[uuid(0x00000105, 0xa8f2, 0x4877, 0xba, 0x0a, 0xfd, 0x2b, 0x66, 0x45, 0xfb, 0x94)] interface IWICBitmapFrameEncode(IWICBitmapFrameEncodeVtbl): IUnknown(IUnknownVtbl) { fn Initialize( pIEncoderOptions: *const IPropertyBag2, @@ -980,8 +980,8 @@ fn GetMetadataQueryWriter( ppIMetadataQueryWriter: *mut *mut IWICMetadataQueryWriter, ) -> HRESULT, -}); -RIDL!(#[uuid(0xf928b7b8, 0x2221, 0x40c1, 0xb7, 0x2e, 0x7e, 0x82, 0xf1, 0x97, 0x4d, 0x1a)] +}} +RIDL!{#[uuid(0xf928b7b8, 0x2221, 0x40c1, 0xb7, 0x2e, 0x7e, 0x82, 0xf1, 0x97, 0x4d, 0x1a)] interface IWICPlanarBitmapFrameEncode(IWICPlanarBitmapFrameEncodeVtbl): IUnknown(IUnknownVtbl) { fn WritePixels( lineCount: UINT, @@ -993,8 +993,8 @@ cPlanes: UINT, prcSource: *const WICRect, ) -> HRESULT, -}); -RIDL!(#[uuid(0x04c75bf8, 0x3ce1, 0x473b, 0xac, 0xc5, 0x3c, 0xc4, 0xf5, 0xe9, 0x49, 0x99)] +}} +RIDL!{#[uuid(0x04c75bf8, 0x3ce1, 0x473b, 0xac, 0xc5, 0x3c, 0xc4, 0xf5, 0xe9, 0x49, 0x99)] interface IWICImageEncoder(IWICImageEncoderVtbl): IUnknown(IUnknownVtbl) { fn WriteFrame( pImage: *const ID2D1Image, @@ -1011,8 +1011,8 @@ pEncoder: *const IWICBitmapEncoder, pImageParameters: *const WICImageParameters, ) -> HRESULT, -}); -RIDL!(#[uuid(0x9edde9e7, 0x8dee, 0x47ea, 0x99, 0xdf, 0xe6, 0xfa, 0xf2, 0xed, 0x44, 0xbf)] +}} +RIDL!{#[uuid(0x9edde9e7, 0x8dee, 0x47ea, 0x99, 0xdf, 0xe6, 0xfa, 0xf2, 0xed, 0x44, 0xbf)] interface IWICBitmapDecoder(IWICBitmapDecoderVtbl): IUnknown(IUnknownVtbl) { fn QueryCapability( pIStream: *const IStream, @@ -1052,8 +1052,8 @@ index: UINT, ppIBitmapFrame: *mut *mut IWICBitmapFrameDecode, ) -> HRESULT, -}); -RIDL!(#[uuid(0x3b16811b, 0x6a43, 0x4ec9, 0xb7, 0x13, 0x3d, 0x5a, 0x0c, 0x13, 0xb9, 0x40)] +}} +RIDL!{#[uuid(0x3b16811b, 0x6a43, 0x4ec9, 0xb7, 0x13, 0x3d, 0x5a, 0x0c, 0x13, 0xb9, 0x40)] interface IWICBitmapSourceTransform(IWICBitmapSourceTransformVtbl): IUnknown(IUnknownVtbl) { fn CopyPixels( prc: *const WICRect, @@ -1076,8 +1076,8 @@ dstTransform: WICBitmapTransformOptions, pfIsSupported: *mut BOOL, ) -> HRESULT, -}); -RIDL!(#[uuid(0x3aff9cce, 0xbe95, 0x4303, 0xb9, 0x27, 0xe7, 0xd1, 0x6f, 0xf4, 0xa6, 0x13)] +}} +RIDL!{#[uuid(0x3aff9cce, 0xbe95, 0x4303, 0xb9, 0x27, 0xe7, 0xd1, 0x6f, 0xf4, 0xa6, 0x13)] interface IWICPlanarBitmapSourceTransform(IWICPlanarBitmapSourceTransformVtbl): IUnknown(IUnknownVtbl) { fn DoesSupportTransform( @@ -1099,8 +1099,8 @@ pDstPlanes: *const WICBitmapPlane, cPlanes: UINT, ) -> HRESULT, -}); -RIDL!(#[uuid(0x3b16811b, 0x6a43, 0x4ec9, 0xa8, 0x13, 0x3d, 0x93, 0x0c, 0x13, 0xb9, 0x40)] +}} +RIDL!{#[uuid(0x3b16811b, 0x6a43, 0x4ec9, 0xa8, 0x13, 0x3d, 0x93, 0x0c, 0x13, 0xb9, 0x40)] interface IWICBitmapFrameDecode(IWICBitmapFrameDecodeVtbl): IWICBitmapSource(IWICBitmapSourceVtbl) { fn GetMetadataQueryReader( @@ -1114,8 +1114,8 @@ fn GetThumbnail( ppIThumbnail: *mut *mut IWICBitmapSource, ) -> HRESULT, -}); -RIDL!(#[uuid(0xdaac296f, 0x7aa5, 0x4dbf, 0x8d, 0x15, 0x22, 0x5c, 0x59, 0x76, 0xf8, 0x91)] +}} +RIDL!{#[uuid(0xdaac296f, 0x7aa5, 0x4dbf, 0x8d, 0x15, 0x22, 0x5c, 0x59, 0x76, 0xf8, 0x91)] interface IWICProgressiveLevelControl(IWICProgressiveLevelControlVtbl): IUnknown(IUnknownVtbl) { fn GetLevelCount( pcLevels: *mut UINT, @@ -1126,22 +1126,22 @@ fn SetCurrentLevel( nLevel: UINT, ) -> HRESULT, -}); -RIDL!(#[uuid(0x4776f9cd, 0x9517, 0x45fa, 0xbf, 0x24, 0xe8, 0x9c, 0x5e, 0xc5, 0xc6, 0x0c)] +}} +RIDL!{#[uuid(0x4776f9cd, 0x9517, 0x45fa, 0xbf, 0x24, 0xe8, 0x9c, 0x5e, 0xc5, 0xc6, 0x0c)] interface IWICProgressCallback(IWICProgressCallbackVtbl): IUnknown(IUnknownVtbl) { fn Notify( uFrameNum: ULONG, operation: WICProgressOperation, dblProgress: c_double, ) -> HRESULT, -}); +}} FN!{stdcall PFNProgressNotification( pvData: LPVOID, uFrameNum: ULONG, operation: WICProgressOperation, dblProgress: c_double, ) -> HRESULT} -RIDL!(#[uuid(0x64c1024e, 0xc3cf, 0x4462, 0x80, 0x78, 0x88, 0xc2, 0xb1, 0x1c, 0x46, 0xd9)] +RIDL!{#[uuid(0x64c1024e, 0xc3cf, 0x4462, 0x80, 0x78, 0x88, 0xc2, 0xb1, 0x1c, 0x46, 0xd9)] interface IWICBitmapCodecProgressNotification(IWICBitmapCodecProgressNotificationVtbl): IUnknown(IUnknownVtbl) { fn RegisterProgressNotification( @@ -1149,8 +1149,8 @@ pvData: LPVOID, dwProgressFlags: DWORD, ) -> HRESULT, -}); -RIDL!(#[uuid(0x23bc3f0a, 0x698b, 0x4357, 0x88, 0x6b, 0xf2, 0x4d, 0x50, 0x67, 0x13, 0x34)] +}} +RIDL!{#[uuid(0x23bc3f0a, 0x698b, 0x4357, 0x88, 0x6b, 0xf2, 0x4d, 0x50, 0x67, 0x13, 0x34)] interface IWICComponentInfo(IWICComponentInfoVtbl): IUnknown(IUnknownVtbl) { fn GetComponentType( pType: *mut WICComponentType, @@ -1184,8 +1184,8 @@ wzFriendlyName: *mut WCHAR, pcchActual: *mut UINT, ) -> HRESULT, -}); -RIDL!(#[uuid(0x9f34fb65, 0x13f4, 0x4f15, 0xbc, 0x57, 0x37, 0x26, 0xb5, 0xe5, 0x3d, 0x9f)] +}} +RIDL!{#[uuid(0x9f34fb65, 0x13f4, 0x4f15, 0xbc, 0x57, 0x37, 0x26, 0xb5, 0xe5, 0x3d, 0x9f)] interface IWICFormatConverterInfo(IWICFormatConverterInfoVtbl): IWICComponentInfo(IWICComponentInfoVtbl) { fn GetPixelFormats( @@ -1196,8 +1196,8 @@ fn CreateInstance( ppIConverter: *mut *mut IWICFormatConverter, ) -> HRESULT, -}); -RIDL!(#[uuid(0xe87a44c4, 0xb76e, 0x4c47, 0x8b, 0x09, 0x29, 0x8e, 0xb1, 0x2a, 0x27, 0x14)] +}} +RIDL!{#[uuid(0xe87a44c4, 0xb76e, 0x4c47, 0x8b, 0x09, 0x29, 0x8e, 0xb1, 0x2a, 0x27, 0x14)] interface IWICBitmapCodecInfo(IWICBitmapCodecInfoVtbl): IWICComponentInfo(IWICComponentInfoVtbl) { fn GetContainerFormat( pguidContainerFormat: *mut GUID, @@ -1248,15 +1248,15 @@ wzMimeType: LPCWSTR, pfMatches: *mut BOOL, ) -> HRESULT, -}); -RIDL!(#[uuid(0x94c9b4ee, 0xa09f, 0x4f92, 0x8a, 0x1e, 0x4a, 0x9b, 0xce, 0x7e, 0x76, 0xfb)] +}} +RIDL!{#[uuid(0x94c9b4ee, 0xa09f, 0x4f92, 0x8a, 0x1e, 0x4a, 0x9b, 0xce, 0x7e, 0x76, 0xfb)] interface IWICBitmapEncoderInfo(IWICBitmapEncoderInfoVtbl): IWICBitmapCodecInfo(IWICBitmapCodecInfoVtbl) { fn CreateInstance( ppIBitmapEncoder: *mut *mut IWICBitmapEncoder, ) -> HRESULT, -}); -RIDL!(#[uuid(0xd8cd007f, 0xd08f, 0x4191, 0x9b, 0xfc, 0x23, 0x6e, 0xa7, 0xf0, 0xe4, 0xb5)] +}} +RIDL!{#[uuid(0xd8cd007f, 0xd08f, 0x4191, 0x9b, 0xfc, 0x23, 0x6e, 0xa7, 0xf0, 0xe4, 0xb5)] interface IWICBitmapDecoderInfo(IWICBitmapDecoderInfoVtbl): IWICBitmapCodecInfo(IWICBitmapCodecInfoVtbl) { fn GetPatterns( @@ -1272,8 +1272,8 @@ fn CreateInstance( ppIBitmapDecoder: *mut *mut IWICBitmapDecoder, ) -> HRESULT, -}); -RIDL!(#[uuid(0xe8eda601, 0x3d48, 0x431a, 0xab, 0x44, 0x69, 0x05, 0x9b, 0xe8, 0x8b, 0xbe)] +}} +RIDL!{#[uuid(0xe8eda601, 0x3d48, 0x431a, 0xab, 0x44, 0x69, 0x05, 0x9b, 0xe8, 0x8b, 0xbe)] interface IWICPixelFormatInfo(IWICPixelFormatInfoVtbl): IWICComponentInfo(IWICComponentInfoVtbl) { fn GetFormatGUID( pFormat: *mut GUID, @@ -1293,8 +1293,8 @@ pbMaskBuffer: *mut BYTE, pcbActual: *mut UINT, ) -> HRESULT, -}); -RIDL!(#[uuid(0xa9db33a2, 0xaf5f, 0x43c7, 0xb6, 0x79, 0x74, 0xf5, 0x98, 0x4b, 0x5a, 0xa4)] +}} +RIDL!{#[uuid(0xa9db33a2, 0xaf5f, 0x43c7, 0xb6, 0x79, 0x74, 0xf5, 0x98, 0x4b, 0x5a, 0xa4)] interface IWICPixelFormatInfo2(IWICPixelFormatInfo2Vtbl): IWICPixelFormatInfo(IWICPixelFormatInfoVtbl) { fn SupportsTransparency( @@ -1303,8 +1303,8 @@ fn GetNumericRepresentation( pNumericRepresentation: *mut WICPixelFormatNumericRepresentation, ) -> HRESULT, -}); -RIDL!(#[uuid(0xec5ec8a9, 0xc395, 0x4314, 0x9c, 0x77, 0x54, 0xd7, 0xa9, 0x35, 0xff, 0x70)] +}} +RIDL!{#[uuid(0xec5ec8a9, 0xc395, 0x4314, 0x9c, 0x77, 0x54, 0xd7, 0xa9, 0x35, 0xff, 0x70)] interface IWICImagingFactory(IWICImagingFactoryVtbl): IUnknown(IUnknownVtbl) { fn CreateDecoderFromFilename( wzFilename: LPCWSTR, @@ -1425,15 +1425,15 @@ pguidVendor: *const GUID, ppIQueryWriter: *mut *mut IWICMetadataQueryWriter, ) -> HRESULT, -}); -RIDL!(#[uuid(0x7b816b45, 0x1996, 0x4476, 0xb1, 0x32, 0xde, 0x9e, 0x24, 0x7c, 0x8a, 0xf0)] +}} +RIDL!{#[uuid(0x7b816b45, 0x1996, 0x4476, 0xb1, 0x32, 0xde, 0x9e, 0x24, 0x7c, 0x8a, 0xf0)] interface IWICImagingFactory2(IWICImagingFactory2Vtbl): IWICImagingFactory(IWICImagingFactoryVtbl) { fn CreateImageEncoder( pD2DDevice: *const ID2D1Device, ppWICImageEncoder: *mut *mut IWICImageEncoder, ) -> HRESULT, -}); +}} extern "system" { pub fn WICConvertBitmapSource( dstFormat: REFWICPixelFormatGUID, @@ -1606,14 +1606,14 @@ pub const WICRawChangeNotification_ToneCurve: UINT = 0x00000800; pub const WICRawChangeNotification_Rotation: UINT = 0x00001000; pub const WICRawChangeNotification_RenderMode: UINT = 0x00002000; -RIDL!(#[uuid(0x95c75a6e, 0x3e8c, 0x4ec2, 0x85, 0xa8, 0xae, 0xbc, 0xc5, 0x51, 0xe5, 0x9b)] +RIDL!{#[uuid(0x95c75a6e, 0x3e8c, 0x4ec2, 0x85, 0xa8, 0xae, 0xbc, 0xc5, 0x51, 0xe5, 0x9b)] interface IWICDevelopRawNotificationCallback(IWICDevelopRawNotificationCallbackVtbl): IUnknown(IUnknownVtbl) { fn Notify( NotificationMask: UINT, ) -> HRESULT, -}); -RIDL!(#[uuid(0xfbec5e44, 0xf7be, 0x4b65, 0xb7, 0xf8, 0xc0, 0xc8, 0x1f, 0xef, 0x02, 0x6d)] +}} +RIDL!{#[uuid(0xfbec5e44, 0xf7be, 0x4b65, 0xb7, 0xf8, 0xc0, 0xc8, 0x1f, 0xef, 0x02, 0x6d)] interface IWICDevelopRaw(IWICDevelopRawVtbl): IWICBitmapFrameDecode(IWICBitmapFrameDecodeVtbl) { fn QueryRawCapabilitiesInfo( pInfo: *mut WICRawCapabilitiesInfo, @@ -1720,7 +1720,7 @@ fn SetNotificationCallback( pCallback: *const IWICDevelopRawNotificationCallback, ) -> HRESULT, -}); +}} ENUM!{enum WICDdsDimension { WICDdsTexture1D = 0x00000000, WICDdsTexture2D = 0x00000001, @@ -1746,7 +1746,7 @@ Dimension: WICDdsDimension, AlphaMode: WICDdsAlphaMode, }} -RIDL!(#[uuid(0x409cd537, 0x8532, 0x40cb, 0x97, 0x74, 0xe2, 0xfe, 0xb2, 0xdf, 0x4e, 0x9c)] +RIDL!{#[uuid(0x409cd537, 0x8532, 0x40cb, 0x97, 0x74, 0xe2, 0xfe, 0xb2, 0xdf, 0x4e, 0x9c)] interface IWICDdsDecoder(IWICDdsDecoderVtbl): IUnknown(IUnknownVtbl) { fn GetParameters( pParameters: *mut WICDdsParameters, @@ -1757,8 +1757,8 @@ sliceIndex: UINT, ppIBitmapFrame: *mut *mut IWICBitmapFrameDecode, ) -> HRESULT, -}); -RIDL!(#[uuid(0x5cacdb4c, 0x407e, 0x41b3, 0xb9, 0x36, 0xd0, 0xf0, 0x10, 0xcd, 0x67, 0x32)] +}} +RIDL!{#[uuid(0x5cacdb4c, 0x407e, 0x41b3, 0xb9, 0x36, 0xd0, 0xf0, 0x10, 0xcd, 0x67, 0x32)] interface IWICDdsEncoder(IWICDdsEncoderVtbl): IUnknown(IUnknownVtbl) { fn SetParameters( pParameters: *const WICDdsParameters, @@ -1772,14 +1772,14 @@ pMipLevel: *mut UINT, pSliceIndex: *mut UINT, ) -> HRESULT, -}); +}} STRUCT!{struct WICDdsFormatInfo { DxgiFormat: DXGI_FORMAT, BytesPerBlock: UINT, BlockWidth: UINT, BlockHeight: UINT, }} -RIDL!(#[uuid(0x3d4c0c61, 0x18a4, 0x41e4, 0xbd, 0x80, 0x48, 0x1a, 0x4f, 0xc9, 0xf4, 0x64)] +RIDL!{#[uuid(0x3d4c0c61, 0x18a4, 0x41e4, 0xbd, 0x80, 0x48, 0x1a, 0x4f, 0xc9, 0xf4, 0x64)] interface IWICDdsFrameDecode(IWICDdsFrameDecodeVtbl): IUnknown(IUnknownVtbl) { fn GetSizeInBlocks( pWidthInBlocks: *mut UINT, @@ -1794,8 +1794,8 @@ cbBufferSize: UINT, pbBuffer: *mut BYTE, ) -> HRESULT, -}); -RIDL!(#[uuid(0x8939f66e, 0xc46a, 0x4c21, 0xa9, 0xd1, 0x98, 0xb3, 0x27, 0xce, 0x16, 0x79)] +}} +RIDL!{#[uuid(0x8939f66e, 0xc46a, 0x4c21, 0xa9, 0xd1, 0x98, 0xb3, 0x27, 0xce, 0x16, 0x79)] interface IWICJpegFrameDecode(IWICJpegFrameDecodeVtbl): IUnknown(IUnknownVtbl) { fn DoesSupportIndexing( pfIndexingSupported: *mut BOOL, @@ -1840,8 +1840,8 @@ pbStreamData: *mut BYTE, pcbStreamDataActual: *mut UINT, ) -> HRESULT, -}); -RIDL!(#[uuid(0x2f0c601f, 0xd2c6, 0x468c, 0xab, 0xfa, 0x49, 0x49, 0x5d, 0x98, 0x3e, 0xd1)] +}} +RIDL!{#[uuid(0x2f0c601f, 0xd2c6, 0x468c, 0xab, 0xfa, 0x49, 0x49, 0x5d, 0x98, 0x3e, 0xd1)] interface IWICJpegFrameEncode(IWICJpegFrameEncodeVtbl): IUnknown(IUnknownVtbl) { fn GetAcHuffmanTable( scanIndex: UINT, @@ -1862,4 +1862,4 @@ cbScanData: UINT, pbScanData: *const BYTE, ) -> HRESULT, -}); +}} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/wincodecsdk.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/wincodecsdk.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/wincodecsdk.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/wincodecsdk.rs 2018-12-05 01:24:41.000000000 +0000 @@ -262,7 +262,7 @@ WICPersistOptionPreferUTF8 = 0x8, WICPersistOptionMask = 0xffff, }} -RIDL!(#[uuid(0xfeaa2a8d, 0xb3f3, 0x43e4, 0xb2, 0x5c, 0xd1, 0xde, 0x99, 0x0a, 0x1a, 0xe1)] +RIDL!{#[uuid(0xfeaa2a8d, 0xb3f3, 0x43e4, 0xb2, 0x5c, 0xd1, 0xde, 0x99, 0x0a, 0x1a, 0xe1)] interface IWICMetadataBlockReader(IWICMetadataBlockReaderVtbl): IUnknown(IUnknownVtbl) { fn GetContainerFormat( pguidContainerFormat: *mut GUID, @@ -276,8 +276,8 @@ fn GetEnumerator( ppIEnumMetadata: *mut IEnumUnknown, ) -> HRESULT, -}); -RIDL!(#[uuid(0x08fb9676, 0xb444, 0x41e8, 0x8d, 0xbe, 0x6a, 0x53, 0xa5, 0x42, 0xbf, 0xf1)] +}} +RIDL!{#[uuid(0x08fb9676, 0xb444, 0x41e8, 0x8d, 0xbe, 0x6a, 0x53, 0xa5, 0x42, 0xbf, 0xf1)] interface IWICMetadataBlockWriter(IWICMetadataBlockWriterVtbl): IWICMetadataBlockReader(IWICMetadataBlockReaderVtbl) { fn InitializeFromBlockReader( @@ -295,8 +295,8 @@ fn RemoveWriterByIndex( nIndex: UINT, ) -> HRESULT, -}); -RIDL!(#[uuid(0x9204fe99, 0xd8fc, 0x4fd5, 0xa0, 0x01, 0x95, 0x36, 0xb0, 0x67, 0xa8, 0x99)] +}} +RIDL!{#[uuid(0x9204fe99, 0xd8fc, 0x4fd5, 0xa0, 0x01, 0x95, 0x36, 0xb0, 0x67, 0xa8, 0x99)] interface IWICMetadataReader(IWICMetadataReaderVtbl): IUnknown(IUnknownVtbl) { fn GetMetadataFormat( pguidMetadataFormat: *mut GUID, @@ -321,8 +321,8 @@ fn GetEnumerator( ppIEnumMetadata: *mut *mut IWICEnumMetadataItem, ) -> HRESULT, -}); -RIDL!(#[uuid(0xf7836e16, 0x3be0, 0x470b, 0x86, 0xbb, 0x16, 0x0d, 0x0a, 0xec, 0xd7, 0xde)] +}} +RIDL!{#[uuid(0xf7836e16, 0x3be0, 0x470b, 0x86, 0xbb, 0x16, 0x0d, 0x0a, 0xec, 0xd7, 0xde)] interface IWICMetadataWriter(IWICMetadataWriterVtbl): IWICMetadataReader(IWICMetadataReaderVtbl) { fn SetValue( pvarSchema: *const PROPVARIANT, @@ -342,8 +342,8 @@ fn RemoveValueByIndex( nIndex: UINT, ) -> HRESULT, -}); -RIDL!(#[uuid(0x449494bc, 0xb468, 0x4927, 0x96, 0xd7, 0xba, 0x90, 0xd3, 0x1a, 0xb5, 0x05)] +}} +RIDL!{#[uuid(0x449494bc, 0xb468, 0x4927, 0x96, 0xd7, 0xba, 0x90, 0xd3, 0x1a, 0xb5, 0x05)] interface IWICStreamProvider(IWICStreamProviderVtbl): IUnknown(IUnknownVtbl) { fn GetStream( ppIStream: *mut *mut IStream, @@ -355,8 +355,8 @@ pguidPreferredVendor: *mut GUID, ) -> HRESULT, fn RefreshStream() -> HRESULT, -}); -RIDL!(#[uuid(0x00675040, 0x6908, 0x45f8, 0x86, 0xa3, 0x49, 0xc7, 0xdf, 0xd6, 0xd9, 0xad)] +}} +RIDL!{#[uuid(0x00675040, 0x6908, 0x45f8, 0x86, 0xa3, 0x49, 0xc7, 0xdf, 0xd6, 0xd9, 0xad)] interface IWICPersistStream(IWICPersistStreamVtbl): IPersistStream(IPersistStreamVtbl) { fn LoadEx( pIStream: *mut IStream, @@ -368,8 +368,8 @@ dwPersistOptions: DWORD, fClearDirty: BOOL, ) -> HRESULT, -}); -RIDL!(#[uuid(0xaba958bf, 0xc672, 0x44d1, 0x8d, 0x61, 0xce, 0x6d, 0xf2, 0xe6, 0x82, 0xc2)] +}} +RIDL!{#[uuid(0xaba958bf, 0xc672, 0x44d1, 0x8d, 0x61, 0xce, 0x6d, 0xf2, 0xe6, 0x82, 0xc2)] interface IWICMetadataHandlerInfo(IWICMetadataHandlerInfoVtbl): IWICComponentInfo(IWICComponentInfoVtbl) { fn GetMetadataFormat( @@ -399,7 +399,7 @@ fn DoesRequireFixedSize( pfFixedSize: *mut BOOL, ) -> HRESULT, -}); +}} STRUCT!{struct WICMetadataPattern { Position: ULARGE_INTEGER, Length: ULONG, @@ -407,7 +407,7 @@ Mask: *mut BYTE, DataOffset: ULARGE_INTEGER, }} -RIDL!(#[uuid(0xeebf1f5b, 0x07c1, 0x4447, 0xa3, 0xab, 0x22, 0xac, 0xaf, 0x78, 0xa8, 0x04)] +RIDL!{#[uuid(0xeebf1f5b, 0x07c1, 0x4447, 0xa3, 0xab, 0x22, 0xac, 0xaf, 0x78, 0xa8, 0x04)] interface IWICMetadataReaderInfo(IWICMetadataReaderInfoVtbl): IWICMetadataHandlerInfo(IWICMetadataHandlerInfoVtbl) { fn GetPatterns( @@ -425,14 +425,14 @@ fn CreateInstance( ppIReader: *mut *mut IWICMetadataReader, ) -> HRESULT, -}); +}} STRUCT!{struct WICMetadataHeader { Position: ULARGE_INTEGER, Length: ULONG, Header: *mut BYTE, DataOffset: ULARGE_INTEGER, }} -RIDL!(#[uuid(0xb22e3fba, 0x3925, 0x4323, 0xb5, 0xc1, 0x9e, 0xbf, 0xc4, 0x30, 0xf2, 0x36)] +RIDL!{#[uuid(0xb22e3fba, 0x3925, 0x4323, 0xb5, 0xc1, 0x9e, 0xbf, 0xc4, 0x30, 0xf2, 0x36)] interface IWICMetadataWriterInfo(IWICMetadataWriterInfoVtbl): IWICMetadataHandlerInfo(IWICMetadataHandlerInfoVtbl) { fn GetHeader( @@ -444,8 +444,8 @@ fn CreateInstance( ppIWriter: *mut *mut IWICMetadataWriter, ) -> HRESULT, -}); -RIDL!(#[uuid(0x412d0c3a, 0x9650, 0x44fa, 0xaf, 0x5b, 0xdd, 0x2a, 0x06, 0xc8, 0xe8, 0xfb)] +}} +RIDL!{#[uuid(0x412d0c3a, 0x9650, 0x44fa, 0xaf, 0x5b, 0xdd, 0x2a, 0x06, 0xc8, 0xe8, 0xfb)] interface IWICComponentFactory(IWICComponentFactoryVtbl): IWICImagingFactory(IWICImagingFactoryVtbl) { fn CreateMetadataReader( @@ -486,7 +486,7 @@ cCount: UINT, ppIPropertyBag: *mut *mut IPropertyBag2, ) -> HRESULT, -}); +}} extern "system" { pub fn WICMatchMetadataContent( guidContainerFormat: REFGUID, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/wincred.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/wincred.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/wincred.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/wincred.rs 2018-12-05 01:24:42.000000000 +0000 @@ -5,14 +5,12 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. //! Authentication API Prototypes and Definitions - use shared::minwindef::{ BOOL, DWORD, FILETIME, LPBYTE, LPCVOID, LPDWORD, LPVOID, PBOOL, PBYTE, UCHAR, ULONG }; use shared::windef::{HBITMAP, HWND}; use um::sspi::PCtxtHandle; use um::winnt::{CHAR, LPCSTR, LPCWSTR, LPSTR, LPWSTR, PCSTR, PCWSTR, PSTR, PVOID, PWSTR, WCHAR}; - // STATUS_* pub const NERR_BASE: DWORD = 2100; pub const NERR_PasswordExpired: DWORD = NERR_BASE + 142; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/wincrypt.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/wincrypt.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/wincrypt.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/wincrypt.rs 2018-12-05 01:24:41.000000000 +0000 @@ -6819,7 +6819,6 @@ } pub const CRYPT_OID_VERIFY_CERTIFICATE_CHAIN_POLICY_FUNC: &'static str = "CertDllVerifyCertificateChainPolicy"; - pub const CERT_CHAIN_POLICY_BASE: LPCSTR = 1 as LPCSTR; pub const CERT_CHAIN_POLICY_AUTHENTICODE: LPCSTR = 2 as LPCSTR; pub const CERT_CHAIN_POLICY_AUTHENTICODE_TS: LPCSTR = 3 as LPCSTR; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/wingdi.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/wingdi.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/wingdi.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/wingdi.rs 2018-12-05 01:24:41.000000000 +0000 @@ -2955,7 +2955,7 @@ lpBuffer: PFLOAT, ) -> BOOL; pub fn GetCharABCWidthsA( - hdc: HDC, + hdc: HDC, wFirst: UINT, wLast: UINT, lpABC: LPABC, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/winnt.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/winnt.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/winnt.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/winnt.rs 2018-12-05 01:24:41.000000000 +0000 @@ -1,4 +1,4 @@ -// Copyright © 2016-2017 winapi-rs developers +// Copyright © 2016-2018 winapi-rs developers // Licensed under the Apache License, Version 2.0 // or the MIT license // , at your option. @@ -11,7 +11,7 @@ DWORD64, KAFFINITY, LONG64, LONG_PTR, PDWORD64, PLONG64, SIZE_T, ULONG64, ULONG_PTR, }; use shared::guiddef::{CLSID, GUID}; -use shared::ktmtypes::{UOW}; +use shared::ktmtypes::UOW; use shared::minwindef::{BYTE, DWORD, FALSE, PDWORD, TRUE, ULONG, USHORT, WORD}; use vc::excpt::EXCEPTION_DISPOSITION; use vc::vcruntime::size_t; @@ -1371,7 +1371,7 @@ STRUCT!{struct WOW64_LDT_ENTRY_Bits { BitFields: DWORD, }} -BITFIELD!(WOW64_LDT_ENTRY_Bits BitFields: DWORD [ +BITFIELD!{WOW64_LDT_ENTRY_Bits BitFields: DWORD [ BaseMid set_BaseMid[0..8], Type set_Type[8..13], Dpl set_Dpl[13..15], @@ -1382,7 +1382,7 @@ Default_Big set_Default_Big[22..23], Granularity set_Granularity[23..24], BaseHi set_BaseHi[24..32], -]); +]} UNION!{union WOW64_LDT_ENTRY_HighWord { [u32; 1], Bytes Bytes_mut: WOW64_LDT_ENTRY_Bytes, @@ -2819,14 +2819,14 @@ BitFields: DWORD, }} pub type PWOW64_ARCHITECTURE_INFORMATION = *mut WOW64_ARCHITECTURE_INFORMATION; -BITFIELD!(WOW64_ARCHITECTURE_INFORMATION BitFields: DWORD [ +BITFIELD!{WOW64_ARCHITECTURE_INFORMATION BitFields: DWORD [ Machine set_Machine[0..16], KernelMode set_KernelMode[16..17], UserMode set_UserMode[17..18], Native set_Native[18..19], Process set_Process[19..20], ReservedZero0 set_ReservedZero0[20..32], -]); +]} pub const MEMORY_PRIORITY_LOWEST: ULONG = 0; pub const MEMORY_PRIORITY_VERY_LOW: ULONG = 1; pub const MEMORY_PRIORITY_LOW: ULONG = 2; @@ -2850,10 +2850,10 @@ STRUCT!{struct RATE_QUOTA_LIMIT { RateData: DWORD, }} -BITFIELD!(RATE_QUOTA_LIMIT RateData: DWORD [ +BITFIELD!{RATE_QUOTA_LIMIT RateData: DWORD [ RatePercent set_RatePercent[0..7], Reserved0 set_Reserved0[7..32], -]); +]} pub type PRATE_QUOTA_LIMIT = *mut RATE_QUOTA_LIMIT; STRUCT!{struct QUOTA_LIMITS_EX { PagedPoolLimit: SIZE_T, @@ -2904,103 +2904,142 @@ STRUCT!{struct PROCESS_MITIGATION_ASLR_POLICY { Flags: DWORD, }} -BITFIELD!(PROCESS_MITIGATION_ASLR_POLICY Flags: DWORD [ +BITFIELD!{PROCESS_MITIGATION_ASLR_POLICY Flags: DWORD [ EnableBottomUpRandomization set_EnableBottomUpRandomization[0..1], EnableForceRelocateImages set_EnableForceRelocateImages[1..2], EnableHighEntropy set_EnableHighEntropy[2..3], DisallowStrippedImages set_DisallowStrippedImages[3..4], ReservedFlags set_ReservedFlags[4..32], -]); +]} pub type PPROCESS_MITIGATION_ASLR_POLICY = *mut PROCESS_MITIGATION_ASLR_POLICY; STRUCT!{struct PROCESS_MITIGATION_DEP_POLICY { Flags: DWORD, Permanent: BOOLEAN, }} -BITFIELD!(PROCESS_MITIGATION_DEP_POLICY Flags: DWORD [ +BITFIELD!{PROCESS_MITIGATION_DEP_POLICY Flags: DWORD [ Enable set_Enable[0..1], DisableAtlThunkEmulation set_DisableAtlThunkEmulation[1..2], ReservedFlags set_ReservedFlags[2..32], -]); +]} pub type PPROCESS_MITIGATION_DEP_POLICY = *mut PROCESS_MITIGATION_DEP_POLICY; STRUCT!{struct PROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY { Flags: DWORD, }} -BITFIELD!(PROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY Flags: DWORD [ +BITFIELD!{PROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY Flags: DWORD [ RaiseExceptionOnInvalidHandleReference set_RaiseExceptionOnInvalidHandleReference[0..1], HandleExceptionsPermanentlyEnabled set_HandleExceptionsPermanentlyEnabled[1..2], ReservedFlags set_ReservedFlags[2..32], -]); +]} pub type PPROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY = *mut PROCESS_MITIGATION_STRICT_HANDLE_CHECK_POLICY; STRUCT!{struct PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY { Flags: DWORD, }} -BITFIELD!(PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY Flags: DWORD [ +BITFIELD!{PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY Flags: DWORD [ DisallowWin32kSystemCalls set_DisallowWin32kSystemCalls[0..1], ReservedFlags set_ReservedFlags[1..32], -]); +]} pub type PPROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY = *mut PROCESS_MITIGATION_SYSTEM_CALL_DISABLE_POLICY; STRUCT!{struct PROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY { Flags: DWORD, }} -BITFIELD!(PROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY Flags: DWORD [ +BITFIELD!{PROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY Flags: DWORD [ DisableExtensionPoints set_DisableExtensionPoints[0..1], ReservedFlags set_ReservedFlags[1..32], -]); +]} pub type PPROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY = *mut PROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY; STRUCT!{struct PROCESS_MITIGATION_DYNAMIC_CODE_POLICY { Flags: DWORD, }} -BITFIELD!(PROCESS_MITIGATION_DYNAMIC_CODE_POLICY Flags: DWORD [ +BITFIELD!{PROCESS_MITIGATION_DYNAMIC_CODE_POLICY Flags: DWORD [ ProhibitDynamicCode set_ProhibitDynamicCode[0..1], AllowThreadOptOut set_AllowThreadOptOut[1..2], AllowRemoteDowngrade set_AllowRemoteDowngrade[2..3], ReservedFlags set_ReservedFlags[3..32], -]); +]} pub type PPROCESS_MITIGATION_DYNAMIC_CODE_POLICY = *mut PROCESS_MITIGATION_DYNAMIC_CODE_POLICY; STRUCT!{struct PROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY { Flags: DWORD, }} -BITFIELD!(PROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY Flags: DWORD [ +BITFIELD!{PROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY Flags: DWORD [ EnableControlFlowGuard set_EnableControlFlowGuard[0..1], EnableExportSuppression set_EnableExportSuppression[1..2], StrictMode set_StrictMode[2..3], ReservedFlags set_ReservedFlags[3..32], -]); +]} pub type PPROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY = *mut PROCESS_MITIGATION_CONTROL_FLOW_GUARD_POLICY; STRUCT!{struct PROCESS_MITIGATION_BINARY_SIGNATURE_POLICY { Flags: DWORD, }} -BITFIELD!(PROCESS_MITIGATION_BINARY_SIGNATURE_POLICY Flags: DWORD [ +BITFIELD!{PROCESS_MITIGATION_BINARY_SIGNATURE_POLICY Flags: DWORD [ MicrosoftSignedOnly set_MicrosoftSignedOnly[0..1], StoreSignedOnly set_StoreSignedOnly[1..2], MitigationOptIn set_MitigationOptIn[2..3], ReservedFlags set_ReservedFlags[3..32], -]); +]} pub type PPROCESS_MITIGATION_BINARY_SIGNATURE_POLICY = *mut PROCESS_MITIGATION_BINARY_SIGNATURE_POLICY; STRUCT!{struct PROCESS_MITIGATION_FONT_DISABLE_POLICY { Flags: DWORD, }} -BITFIELD!(PROCESS_MITIGATION_FONT_DISABLE_POLICY Flags: DWORD [ +BITFIELD!{PROCESS_MITIGATION_FONT_DISABLE_POLICY Flags: DWORD [ DisableNonSystemFonts set_DisableNonSystemFonts[0..1], AuditNonSystemFontLoading set_AuditNonSystemFontLoading[1..2], ReservedFlags set_ReservedFlags[2..32], -]); +]} pub type PPROCESS_MITIGATION_FONT_DISABLE_POLICY = *mut PROCESS_MITIGATION_FONT_DISABLE_POLICY; STRUCT!{struct PROCESS_MITIGATION_IMAGE_LOAD_POLICY { Flags: DWORD, }} -BITFIELD!(PROCESS_MITIGATION_IMAGE_LOAD_POLICY Flags: DWORD [ +BITFIELD!{PROCESS_MITIGATION_IMAGE_LOAD_POLICY Flags: DWORD [ NoRemoteImages set_NoRemoteImages[0..1], NoLowMandatoryLabelImages set_NoLowMandatoryLabelImages[1..2], PreferSystem32Images set_PreferSystem32Images[2..3], ReservedFlags set_ReservedFlags[3..32], -]); +]} pub type PPROCESS_MITIGATION_IMAGE_LOAD_POLICY = *mut PROCESS_MITIGATION_IMAGE_LOAD_POLICY; +STRUCT!{struct PROCESS_MITIGATION_SYSTEM_CALL_FILTER_POLICY { + Flags: DWORD, +}} +pub type PPPROCESS_MITIGATION_SYSTEM_CALL_FILTER_POLICY = + *mut PROCESS_MITIGATION_SYSTEM_CALL_FILTER_POLICY; +BITFIELD!{PROCESS_MITIGATION_SYSTEM_CALL_FILTER_POLICY Flags: DWORD [ + FilterId set_FilterId[0..4], + ReservedFlags set_ReservedFlags[4..32], +]} +STRUCT!{struct PROCESS_MITIGATION_PAYLOAD_RESTRICTION_POLICY { + Flags: DWORD, +}} +pub type PPROCESS_MITIGATION_PAYLOAD_RESTRICTION_POLICY = + *mut PROCESS_MITIGATION_PAYLOAD_RESTRICTION_POLICY; +BITFIELD!{PROCESS_MITIGATION_PAYLOAD_RESTRICTION_POLICY Flags: DWORD [ + EnableExportAddressFilter set_EnableExportAddressFilter[0..1], + AuditExportAddressFilter set_AuditExportAddressFilter[1..2], + EnableExportAddressFilterPlus set_EnableExportAddressFilterPlus[2..3], + AuditExportAddressFilterPlus set_AuditExportAddressFilterPlus[3..4], + EnableImportAddressFilter set_EnableImportAddressFilter[4..5], + AuditImportAddressFilter set_AuditImportAddressFilter[5..6], + EnableRopStackPivot set_EnableRopStackPivot[6..7], + AuditRopStackPivot set_AuditRopStackPivot[7..8], + EnableRopCallerCheck set_EnableRopCallerCheck[8..9], + AuditRopCallerCheck set_AuditRopCallerCheck[9..10], + EnableRopSimExec set_EnableRopSimExec[10..11], + AuditRopSimExec set_AuditRopSimExec[11..12], + ReservedFlags set_ReservedFlags[12..32], +]} +STRUCT!{struct PROCESS_MITIGATION_CHILD_PROCESS_POLICY { + Flags: DWORD, +}} +pub type PPROCESS_MITIGATION_CHILD_PROCESS_POLICY = *mut PROCESS_MITIGATION_CHILD_PROCESS_POLICY; +BITFIELD!{PROCESS_MITIGATION_CHILD_PROCESS_POLICY Flags: DWORD [ + NoChildProcessCreation set_NoChildProcessCreation[0..1], + AuditNoChildProcessCreation set_AuditNoChildProcessCreation[1..2], + AllowSecureProcessCreation set_AllowSecureProcessCreation[2..3], + ReservedFlags set_ReservedFlags[3..32], +]} STRUCT!{struct JOBOBJECT_BASIC_ACCOUNTING_INFORMATION { TotalUserTime: LARGE_INTEGER, TotalKernelTime: LARGE_INTEGER, @@ -3549,13 +3588,13 @@ Reserved: DWORD, AllocationTag: DWORD64, }} -BITFIELD!(SYSTEM_CPU_SET_INFORMATION_CpuSet AllFlags: BYTE [ +BITFIELD!{SYSTEM_CPU_SET_INFORMATION_CpuSet AllFlags: BYTE [ Parked set_Parked[0..1], Allocated set_Allocated[1..2], AllocatedToTargetProcess set_AllocatedToTargetProcess[2..3], RealTime set_RealTime[3..4], ReservedFlags set_ReservedFlags[4..8], -]); +]} STRUCT!{struct SYSTEM_CPU_SET_INFORMATION { Size: DWORD, Type: CPU_SET_INFORMATION_TYPE, @@ -3687,10 +3726,10 @@ AllFeatureSize: DWORD, AllFeatures: [DWORD; MAXIMUM_XSTATE_FEATURES], }} -BITFIELD!(XSTATE_CONFIGURATION ControlFlags: DWORD [ +BITFIELD!{XSTATE_CONFIGURATION ControlFlags: DWORD [ OptimizedSave set_OptimizedSave[0..1], CompactionEnabled set_CompactionEnabled[1..2], -]); +]} pub type PXSTATE_CONFIGURATION = *mut XSTATE_CONFIGURATION; STRUCT!{struct MEMORY_BASIC_INFORMATION { BaseAddress: PVOID, @@ -4413,7 +4452,7 @@ DEFINE_GUID!{GUID_ACDC_POWER_SOURCE, 0x5d3e9a59, 0xe9d5, 0x4b00, 0xa6, 0xbd, 0xff, 0x34, 0xff, 0x51, 0x65, 0x48} DEFINE_GUID!{GUID_LIDSWITCH_STATE_CHANGE, - 0xba3e0f4d, 0xb817, 0x4094, 0xa2, 0xd1, 0xd5, 0x63, 0x79, 0xe6, 0xa0, 0xf3} + 0xba3e0f4d, 0xb817, 0x4094, 0xa2, 0xd1, 0xd5, 0x63, 0x79, 0xe6, 0xa0, 0xf3} DEFINE_GUID!{GUID_BATTERY_PERCENTAGE_REMAINING, 0xa7ad8041, 0xb45a, 0x4cae, 0x87, 0xa3, 0xee, 0xcb, 0xb4, 0x68, 0xa9, 0xe1} DEFINE_GUID!{GUID_BATTERY_COUNT, @@ -5085,11 +5124,11 @@ STRUCT!{struct PROCESSOR_IDLESTATE_POLICY_Flags { AsWORD: WORD, }} -BITFIELD!(PROCESSOR_IDLESTATE_POLICY_Flags AsWORD: WORD [ +BITFIELD!{PROCESSOR_IDLESTATE_POLICY_Flags AsWORD: WORD [ AllowScaling set_AllowScaling[0..1], Disabled set_Disabled[1..2], Reserved set_Reserved[2..16], -]); +]} STRUCT!{struct PROCESSOR_IDLESTATE_POLICY { Revision: WORD, Flags: PROCESSOR_IDLESTATE_POLICY_Flags, @@ -5111,11 +5150,11 @@ Spare: [BYTE; 2], Reserved: DWORD, }} -BITFIELD!(PROCESSOR_POWER_POLICY_INFO Reserved: DWORD [ +BITFIELD!{PROCESSOR_POWER_POLICY_INFO Reserved: DWORD [ AllowDemotion set_AllowDemotion[0..1], AllowPromotion set_AllowPromotion[1..2], Reserved set_Reserved[2..32], -]); +]} pub type PPROCESSOR_POWER_POLICY_INFO = *mut PROCESSOR_POWER_POLICY_INFO; STRUCT!{struct PROCESSOR_POWER_POLICY { Revision: DWORD, @@ -5125,20 +5164,20 @@ PolicyCount: DWORD, Policy: [PROCESSOR_POWER_POLICY_INFO; 3], }} -BITFIELD!(PROCESSOR_POWER_POLICY BitFields: DWORD [ +BITFIELD!{PROCESSOR_POWER_POLICY BitFields: DWORD [ DisableCStates set_DisableCStates[0..1], Reserved set_Reserved[1..32], -]); +]} pub type PPROCESSOR_POWER_POLICY = *mut PROCESSOR_POWER_POLICY; STRUCT!{struct PROCESSOR_PERFSTATE_POLICY_u_Flags { AsBYTE: BYTE, }} -BITFIELD!(PROCESSOR_PERFSTATE_POLICY_u_Flags AsBYTE: BYTE [ +BITFIELD!{PROCESSOR_PERFSTATE_POLICY_u_Flags AsBYTE: BYTE [ NoDomainAccounting set_NoDomainAccounting[0..1], IncreasePolicy set_IncreasePolicy[1..3], DecreasePolicy set_DecreasePolicy[3..5], Reserved set_Reserved[5..8], -]); +]} UNION!{union PROCESSOR_PERFSTATE_POLICY_u { [u8; 1], Spare Spare_mut: BYTE, @@ -6275,11 +6314,11 @@ SizeOfZeroFill: DWORD, Characteristics: DWORD, }} -BITFIELD!(IMAGE_TLS_DIRECTORY64 Characteristics: DWORD [ +BITFIELD!{IMAGE_TLS_DIRECTORY64 Characteristics: DWORD [ Reserved0 set_Reserved0[0..20], Alignment set_Alignment[20..24], Reserved1 set_Reserved1[24..32], -]); +]} pub type PIMAGE_TLS_DIRECTORY64 = *mut IMAGE_TLS_DIRECTORY64; STRUCT!{struct IMAGE_TLS_DIRECTORY32 { StartAddressOfRawData: DWORD, @@ -6289,11 +6328,11 @@ SizeOfZeroFill: DWORD, Characteristics: DWORD, }} -BITFIELD!(IMAGE_TLS_DIRECTORY32 Characteristics: DWORD [ +BITFIELD!{IMAGE_TLS_DIRECTORY32 Characteristics: DWORD [ Reserved0 set_Reserved0[0..20], Alignment set_Alignment[20..24], Reserved1 set_Reserved1[24..32], -]); +]} pub type PIMAGE_TLS_DIRECTORY32 = *mut IMAGE_TLS_DIRECTORY32; #[cfg(target_arch = "x86_64")] IFDEF!{ @@ -6355,10 +6394,10 @@ STRUCT!{struct IMAGE_DELAYLOAD_DESCRIPTOR_Attributes { AllAttributes: DWORD, }} -BITFIELD!(IMAGE_DELAYLOAD_DESCRIPTOR_Attributes AllAttributes: DWORD [ +BITFIELD!{IMAGE_DELAYLOAD_DESCRIPTOR_Attributes AllAttributes: DWORD [ RvaBased set_RvaBased[0..1], ReservedAttributes set_ReservedAttributes[1..32], -]); +]} STRUCT!{struct IMAGE_DELAYLOAD_DESCRIPTOR { Attributes: IMAGE_DELAYLOAD_DESCRIPTOR_Attributes, DllNameRVA: DWORD, @@ -6385,10 +6424,10 @@ STRUCT!{struct IMAGE_RESOURCE_DIRECTORY_ENTRY_u_s { BitFields: DWORD, }} -BITFIELD!(IMAGE_RESOURCE_DIRECTORY_ENTRY_u_s BitFields: DWORD [ +BITFIELD!{IMAGE_RESOURCE_DIRECTORY_ENTRY_u_s BitFields: DWORD [ NameOffset set_NameOffset[0..31], NameIsString set_NameIsString[31..32], -]); +]} UNION!{union IMAGE_RESOURCE_DIRECTORY_ENTRY_u { [u32; 1], s s_mut: IMAGE_RESOURCE_DIRECTORY_ENTRY_u_s, @@ -6399,10 +6438,10 @@ u: IMAGE_RESOURCE_DIRECTORY_ENTRY_u, OffsetToData: DWORD, }} -BITFIELD!(IMAGE_RESOURCE_DIRECTORY_ENTRY OffsetToData: DWORD [ +BITFIELD!{IMAGE_RESOURCE_DIRECTORY_ENTRY OffsetToData: DWORD [ OffsetToDirectory set_OffsetToDirectory[0..31], DataIsDirectory set_DataIsDirectory[31..32], -]); +]} pub type PIMAGE_RESOURCE_DIRECTORY_ENTRY = *mut IMAGE_RESOURCE_DIRECTORY_ENTRY; STRUCT!{struct IMAGE_RESOURCE_DIRECTORY_STRING { Length: WORD, @@ -6645,18 +6684,18 @@ FuncStart: DWORD, BitFields: DWORD, }} -BITFIELD!(IMAGE_CE_RUNTIME_FUNCTION_ENTRY BitFields: DWORD [ +BITFIELD!{IMAGE_CE_RUNTIME_FUNCTION_ENTRY BitFields: DWORD [ PrologLen set_PrologLen[0..8], FuncLen set_FuncLen[8..30], ThirtyTwoBit set_ThirtyTwoBit[30..31], ExceptionFlag set_ExceptionFlag[31..32], -]); +]} pub type PIMAGE_CE_RUNTIME_FUNCTION_ENTRY = *mut IMAGE_CE_RUNTIME_FUNCTION_ENTRY; STRUCT!{struct IMAGE_ARM_RUNTIME_FUNCTION_ENTRY { BeginAddress: DWORD, UnwindData: DWORD, }} -BITFIELD!(IMAGE_ARM_RUNTIME_FUNCTION_ENTRY UnwindData: DWORD [ +BITFIELD!{IMAGE_ARM_RUNTIME_FUNCTION_ENTRY UnwindData: DWORD [ Flag set_Flag[0..2], FunctionLength set_FunctionLength[2..13], Ret set_Ret[13..15], @@ -6666,13 +6705,13 @@ L set_L[20..21], C set_c[21..22], StackAdjust set_StackAdjust[22..32], -]); +]} pub type PIMAGE_ARM_RUNTIME_FUNCTION_ENTRY = *mut IMAGE_ARM_RUNTIME_FUNCTION_ENTRY; STRUCT!{struct IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY { BeginAddress: DWORD, UnwindData: DWORD, }} -BITFIELD!(IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY UnwindData: DWORD [ +BITFIELD!{IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY UnwindData: DWORD [ Flag set_Flag[0..2], FunctionLength set_FunctionLength[2..13], RegF set_RegF[13..16], @@ -6680,7 +6719,7 @@ H set_H[20..21], CR set_cR[21..23], FrameSize set_FrameSize[23..32], -]); +]} pub type PIMAGE_ARM64_RUNTIME_FUNCTION_ENTRY = *mut IMAGE_ARM64_RUNTIME_FUNCTION_ENTRY; STRUCT!{struct IMAGE_ALPHA64_RUNTIME_FUNCTION_ENTRY { BeginAddress: ULONGLONG, @@ -6761,14 +6800,14 @@ cdwParams: WORD, BitFields: WORD, }} -BITFIELD!(FPO_DATA BitFields: WORD [ +BITFIELD!{FPO_DATA BitFields: WORD [ cbProlog set_cbProlog[0..8], cbRegs set_cbRegs[8..11], fHasSEH set_fHasSEH[11..12], fUseBP set_fUseBP[12..13], reserved set_reserved[13..14], cbFrame set_cbFrame[14..16], -]); +]} pub type PFPO_DATA = *mut FPO_DATA; pub const SIZEOF_RFPO_DATA: usize = 16; pub const IMAGE_DEBUG_MISC_EXENAME: DWORD = 1; @@ -6833,12 +6872,12 @@ BitFields: c_uint, FirstEntryRVA: DWORD, }} -BITFIELD!(IMAGE_ARCHITECTURE_HEADER BitFields: c_uint [ +BITFIELD!{IMAGE_ARCHITECTURE_HEADER BitFields: c_uint [ AmaskValue set_AmaskValue[0..1], unused1 set_unused1[1..8], AmaskShift set_AmaskShift[8..16], unused2 set_unused2[8..32], -]); +]} pub type PIMAGE_ARCHITECTURE_HEADER = *mut IMAGE_ARCHITECTURE_HEADER; STRUCT!{struct IMAGE_ARCHITECTURE_ENTRY { FixupInstRVA: DWORD, @@ -6861,11 +6900,11 @@ u: IMPORT_OBJECT_HEADER_u, BitFields: WORD, }} -BITFIELD!(IMPORT_OBJECT_HEADER BitFields: WORD [ +BITFIELD!{IMPORT_OBJECT_HEADER BitFields: WORD [ Type set_Type[0..2], NameType set_NameType[2..5], Reserved set_Reserved[5..16], -]); +]} ENUM!{enum IMPORT_OBJECT_TYPE { IMPORT_OBJECT_CODE = 0, IMPORT_OBJECT_DATA = 1, @@ -7035,14 +7074,14 @@ BitFields1: ULONGLONG, BitFields2: ULONGLONG, }} -BITFIELD!(SLIST_HEADER_HeaderX64 BitFields1: ULONGLONG [ +BITFIELD!{SLIST_HEADER_HeaderX64 BitFields1: ULONGLONG [ Depth set_Depth[0..16], Sequence set_Sequence[16..64], -]); -BITFIELD!(SLIST_HEADER_HeaderX64 BitFields2: ULONGLONG [ +]} +BITFIELD!{SLIST_HEADER_HeaderX64 BitFields2: ULONGLONG [ Reserved set_Reserved[0..4], NextEntry set_NextEntry[4..64], -]); +]} UNION!{union SLIST_HEADER { [u64; 2], s s_mut: SLIST_HEADER_s, @@ -8317,11 +8356,11 @@ STRUCT!{struct TP_CALLBACK_ENVIRON_V3_u_s { BitFields: DWORD, }} -BITFIELD!(TP_CALLBACK_ENVIRON_V3_u_s BitFields: DWORD [ +BITFIELD!{TP_CALLBACK_ENVIRON_V3_u_s BitFields: DWORD [ LongFunction set_LongFunction[0..1], Persistent set_Persistent[1..2], Private set_Private[2..32], -]); +]} UNION!{union TP_CALLBACK_ENVIRON_V3_u { [u32; 1], Flags Flags_mut: DWORD, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/winsafer.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/winsafer.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/winsafer.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/winsafer.rs 2018-12-05 01:24:41.000000000 +0000 @@ -10,7 +10,7 @@ use shared::windef::HWND; use um::wincrypt::ALG_ID; use um::winnt::{BOOLEAN, HANDLE, LARGE_INTEGER, LPCWSTR, PHANDLE, PVOID, PWCHAR, WCHAR}; -DECLARE_HANDLE!(SAFER_LEVEL_HANDLE, __SAFER_LEVEL_HANDLE); +DECLARE_HANDLE!{SAFER_LEVEL_HANDLE, __SAFER_LEVEL_HANDLE} pub const SAFER_SCOPEID_MACHINE: DWORD = 1; pub const SAFER_SCOPEID_USER: DWORD = 2; pub const SAFER_LEVELID_DISALLOWED: DWORD = 0x00000; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/winsmcrd.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/winsmcrd.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/winsmcrd.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/winsmcrd.rs 2018-12-05 01:24:41.000000000 +0000 @@ -8,8 +8,8 @@ use shared::minwindef::{BYTE, DWORD, ULONG, WORD}; use um::winioctl::{FILE_ANY_ACCESS, FILE_DEVICE_SMARTCARD, METHOD_BUFFERED}; pub type UWORD = WORD; -DEFINE_GUID!(GUID_DEVINTERFACE_SMARTCARD_READER, 0x50DD5230, 0xBA8A, 0x11D1, - 0xBF, 0x5D, 0x00, 0x00, 0xF8, 0x05, 0xF5, 0x30); +DEFINE_GUID!{GUID_DEVINTERFACE_SMARTCARD_READER, + 0x50DD5230, 0xBA8A, 0x11D1, 0xBF, 0x5D, 0x00, 0x00, 0xF8, 0x05, 0xF5, 0x30} pub const SCARD_ATR_LENGTHL: DWORD = 33; pub const SCARD_PROTOCOL_UNDEFINED: DWORD = 0x00000000; pub const SCARD_PROTOCOL_T0: DWORD = 0x00000001; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/winsvc.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/winsvc.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/winsvc.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/winsvc.rs 2018-12-05 01:24:41.000000000 +0000 @@ -5,7 +5,6 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. //! Header file for the Service Control Manager - use shared::minwindef::{BOOL, DWORD, LPBYTE, LPDWORD, LPVOID}; use um::winnt::{ HANDLE, LPCSTR, LPCWSTR, LPSTR, LPWSTR, PSECURITY_DESCRIPTOR, PVOID, @@ -187,9 +186,9 @@ 0x1f81d131, 0x3fac, 0x4537, 0x9e, 0x0c, 0x7e, 0x7b, 0x0c, 0x2f, 0x4b, 0x55} DEFINE_GUID!{CUSTOM_SYSTEM_STATE_CHANGE_EVENT_GUID, 0x2d7a2816, 0x0c5e, 0x45fc, 0x9c, 0xe7, 0x57, 0x0e, 0x5e, 0xcd, 0xe9, 0xc9} -DECLARE_HANDLE!(SC_HANDLE, SC_HANDLE__); +DECLARE_HANDLE!{SC_HANDLE, SC_HANDLE__} pub type LPSC_HANDLE = *mut SC_HANDLE; -DECLARE_HANDLE!(SERVICE_STATUS_HANDLE, SERVICE_STATUS_HANDLE__); +DECLARE_HANDLE!{SERVICE_STATUS_HANDLE, SERVICE_STATUS_HANDLE__} ENUM!{enum SC_STATUS_TYPE { SC_STATUS_PROCESS_INFO = 0, }} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/winusb.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/winusb.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/winusb.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/winusb.rs 2018-12-05 01:24:42.000000000 +0000 @@ -211,7 +211,6 @@ Overlapped: LPOVERLAPPED, ) -> BOOL; } - STRUCT!{struct USB_INTERFACE_DESCRIPTOR { bLength: UCHAR, bDescriptorType: UCHAR, diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/winuser.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/winuser.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/um/winuser.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/um/winuser.rs 2018-12-05 01:24:42.000000000 +0000 @@ -3048,7 +3048,7 @@ cbSize: c_int, ) -> UINT; } -DECLARE_HANDLE!(HTOUCHINPUT, HTOUCHINPUT__); +DECLARE_HANDLE!{HTOUCHINPUT, HTOUCHINPUT__} STRUCT!{struct TOUCHINPUT { x: LONG, y: LONG, @@ -6483,9 +6483,132 @@ pub fn IsWinEventHookInstalled( event: DWORD, ) -> BOOL; +} +pub const WINEVENT_OUTOFCONTEXT: UINT = 0x0000; +pub const WINEVENT_SKIPOWNTHREAD: UINT = 0x0001; +pub const WINEVENT_SKIPOWNPROCESS: UINT = 0x0002; +pub const WINEVENT_INCONTEXT: UINT = 0x0004; +extern "system" { pub fn UnhookWinEvent( hWinEventHook: HWINEVENTHOOK, ) -> BOOL; +} +pub const CHILDID_SELF: LONG = 0; +pub const INDEXID_OBJECT: LONG = 0; +pub const INDEXID_CONTAINER: LONG = 0; +pub const OBJID_WINDOW: LONG = 0x0000; +pub const OBJID_SYSMENU: LONG = 0xFFFFFFFF; +pub const OBJID_TITLEBAR: LONG = 0xFFFFFFFE; +pub const OBJID_MENU: LONG = 0xFFFFFFFD; +pub const OBJID_CLIENT: LONG = 0xFFFFFFFC; +pub const OBJID_VSCROLL: LONG = 0xFFFFFFFB; +pub const OBJID_HSCROLL: LONG = 0xFFFFFFFA; +pub const OBJID_SIZEGRIP: LONG = 0xFFFFFFF9; +pub const OBJID_CARET: LONG = 0xFFFFFFF8; +pub const OBJID_CURSOR: LONG = 0xFFFFFFF7; +pub const OBJID_ALERT: LONG = 0xFFFFFFF6; +pub const OBJID_SOUND: LONG = 0xFFFFFFF5; +pub const OBJID_QUERYCLASSNAMEIDX: LONG = 0xFFFFFFF4; +pub const OBJID_NATIVEOM: LONG = 0xFFFFFFF0; +pub const EVENT_MIN: UINT = 0x0001; +pub const EVENT_MAX: UINT = 0x7FFFFFFF; +pub const EVENT_SYSTEM_SOUND: UINT = 0x0001; +pub const EVENT_SYSTEM_ALERT: UINT = 0x0002; +pub const EVENT_SYSTEM_FOREGROUND: UINT = 0x0003; +pub const EVENT_SYSTEM_MENUSTART: UINT = 0x0004; +pub const EVENT_SYSTEM_MENUEND: UINT = 0x0005; +pub const EVENT_SYSTEM_MENUPOPUPSTART: UINT = 0x0006; +pub const EVENT_SYSTEM_MENUPOPUPEND: UINT = 0x0007; +pub const EVENT_SYSTEM_CAPTURESTART: UINT = 0x0008; +pub const EVENT_SYSTEM_CAPTUREEND: UINT = 0x0009; +pub const EVENT_SYSTEM_MOVESIZESTART: UINT = 0x000A; +pub const EVENT_SYSTEM_MOVESIZEEND: UINT = 0x000B; +pub const EVENT_SYSTEM_CONTEXTHELPSTART: UINT = 0x000C; +pub const EVENT_SYSTEM_CONTEXTHELPEND: UINT = 0x000D; +pub const EVENT_SYSTEM_DRAGDROPSTART: UINT = 0x000E; +pub const EVENT_SYSTEM_DRAGDROPEND: UINT = 0x000F; +pub const EVENT_SYSTEM_DIALOGSTART: UINT = 0x0010; +pub const EVENT_SYSTEM_DIALOGEND: UINT = 0x0011; +pub const EVENT_SYSTEM_SCROLLINGSTART: UINT = 0x0012; +pub const EVENT_SYSTEM_SCROLLINGEND: UINT = 0x0013; +pub const EVENT_SYSTEM_SWITCHSTART: UINT = 0x0014; +pub const EVENT_SYSTEM_SWITCHEND: UINT = 0x0015; +pub const EVENT_SYSTEM_MINIMIZESTART: UINT = 0x0016; +pub const EVENT_SYSTEM_MINIMIZEEND: UINT = 0x0017; +pub const EVENT_SYSTEM_DESKTOPSWITCH: UINT = 0x0020; +pub const EVENT_SYSTEM_SWITCHER_APPGRABBED: UINT = 0x0024; +pub const EVENT_SYSTEM_SWITCHER_APPOVERTARGET: UINT = 0x0025; +pub const EVENT_SYSTEM_SWITCHER_APPDROPPED: UINT = 0x0026; +pub const EVENT_SYSTEM_SWITCHER_CANCELLED: UINT = 0x0027; +pub const EVENT_SYSTEM_IME_KEY_NOTIFICATION: UINT = 0x0029; +pub const EVENT_SYSTEM_END: UINT = 0x00FF; +pub const EVENT_OEM_DEFINED_START: UINT = 0x0101; +pub const EVENT_OEM_DEFINED_END: UINT = 0x01FF; +pub const EVENT_UIA_EVENTID_START: UINT = 0x4E00; +pub const EVENT_UIA_EVENTID_END: UINT = 0x4EFF; +pub const EVENT_UIA_PROPID_START: UINT = 0x7500; +pub const EVENT_UIA_PROPID_END: UINT = 0x75FF; +pub const EVENT_CONSOLE_CARET: UINT = 0x4001; +pub const EVENT_CONSOLE_UPDATE_REGION: UINT = 0x4002; +pub const EVENT_CONSOLE_UPDATE_SIMPLE: UINT = 0x4003; +pub const EVENT_CONSOLE_UPDATE_SCROLL: UINT = 0x4004; +pub const EVENT_CONSOLE_LAYOUT: UINT = 0x4005; +pub const EVENT_CONSOLE_START_APPLICATION: UINT = 0x4006; +pub const EVENT_CONSOLE_END_APPLICATION: UINT = 0x4007; +#[cfg(target_arch = "x86_64")] +pub const CONSOLE_APPLICATION_16BIT: LONG = 0x0000; +#[cfg(target_arch = "x86")] +pub const CONSOLE_APPLICATION_16BIT: LONG = 0x0001; +pub const CONSOLE_CARET_SELECTION: LONG = 0x0001; +pub const CONSOLE_CARET_VISIBLE: LONG = 0x0002; +pub const EVENT_CONSOLE_END: UINT = 0x40FF; +pub const EVENT_OBJECT_CREATE: UINT = 0x8000; +pub const EVENT_OBJECT_DESTROY: UINT = 0x8001; +pub const EVENT_OBJECT_SHOW: UINT = 0x8002; +pub const EVENT_OBJECT_HIDE: UINT = 0x8003; +pub const EVENT_OBJECT_REORDER: UINT = 0x8004; +pub const EVENT_OBJECT_FOCUS: UINT = 0x8005; +pub const EVENT_OBJECT_SELECTION: UINT = 0x8006; +pub const EVENT_OBJECT_SELECTIONADD: UINT = 0x8007; +pub const EVENT_OBJECT_SELECTIONREMOVE: UINT = 0x8008; +pub const EVENT_OBJECT_SELECTIONWITHIN: UINT = 0x8009; +pub const EVENT_OBJECT_STATECHANGE: UINT = 0x800A; +pub const EVENT_OBJECT_LOCATIONCHANGE: UINT = 0x800B; +pub const EVENT_OBJECT_NAMECHANGE: UINT = 0x800C; +pub const EVENT_OBJECT_DESCRIPTIONCHANGE: UINT = 0x800D; +pub const EVENT_OBJECT_VALUECHANGE: UINT = 0x800E; +pub const EVENT_OBJECT_PARENTCHANGE: UINT = 0x800F; +pub const EVENT_OBJECT_HELPCHANGE: UINT = 0x8010; +pub const EVENT_OBJECT_DEFACTIONCHANGE: UINT = 0x8011; +pub const EVENT_OBJECT_ACCELERATORCHANGE: UINT = 0x8012; +pub const EVENT_OBJECT_INVOKED: UINT = 0x8013; +pub const EVENT_OBJECT_TEXTSELECTIONCHANGED: UINT = 0x8014; +pub const EVENT_OBJECT_CONTENTSCROLLED: UINT = 0x8015; +pub const EVENT_SYSTEM_ARRANGMENTPREVIEW: UINT = 0x8016; +pub const EVENT_OBJECT_CLOAKED: UINT = 0x8017; +pub const EVENT_OBJECT_UNCLOAKED: UINT = 0x8018; +pub const EVENT_OBJECT_LIVEREGIONCHANGED: UINT = 0x8019; +pub const EVENT_OBJECT_HOSTEDOBJECTSINVALIDATED: UINT = 0x8020; +pub const EVENT_OBJECT_DRAGSTART: UINT = 0x8021; +pub const EVENT_OBJECT_DRAGCANCEL: UINT = 0x8022; +pub const EVENT_OBJECT_DRAGCOMPLETE: UINT = 0x8023; +pub const EVENT_OBJECT_DRAGENTER: UINT = 0x8024; +pub const EVENT_OBJECT_DRAGLEAVE: UINT = 0x8025; +pub const EVENT_OBJECT_DRAGDROPPED: UINT = 0x8026; +pub const EVENT_OBJECT_IME_SHOW: UINT = 0x8027; +pub const EVENT_OBJECT_IME_HIDE: UINT = 0x8028; +pub const EVENT_OBJECT_IME_CHANGE: UINT = 0x8029; +pub const EVENT_OBJECT_TEXTEDIT_CONVERSIONTARGETCHANGED: UINT = 0x8030; +pub const EVENT_OBJECT_END: UINT = 0x80FF; +pub const EVENT_AIA_START: UINT = 0xA000; +pub const EVENT_AIA_END: UINT = 0xAFFF; +pub const ALERT_SYSTEM_INFORMATIONAL: LONG = 1; +pub const ALERT_SYSTEM_WARNING: LONG = 2; +pub const ALERT_SYSTEM_ERROR: LONG = 3; +pub const ALERT_SYSTEM_QUERY: LONG = 4; +pub const ALERT_SYSTEM_CRITICAL: LONG = 5; +pub const CALERT_SYSTEM: LONG = 6; +extern "system" { //14098 pub fn BlockInput( fBlockIt: BOOL, @@ -6526,7 +6649,7 @@ bGrant: BOOL, ) -> BOOL; } -DECLARE_HANDLE!(HRAWINPUT, HRAWINPUT__); +DECLARE_HANDLE!{HRAWINPUT, HRAWINPUT__} #[inline] pub fn GET_RAWINPUT_CODE_WPARAM(wParam: WPARAM) -> WPARAM { wParam & 0xff } pub const RIM_INPUT: WPARAM = 0; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/vc/limits.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/vc/limits.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/vc/limits.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/vc/limits.rs 2018-12-05 01:24:42.000000000 +0000 @@ -4,5 +4,5 @@ // , at your option. // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. -use ctypes::{c_uint}; +use ctypes::c_uint; pub const UINT_MAX: c_uint = 0xffffffff; diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/winrt/activation.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/winrt/activation.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/winrt/activation.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/winrt/activation.rs 2018-12-05 01:24:42.000000000 +0000 @@ -4,7 +4,7 @@ // , at your option. // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. -use um::winnt::{HRESULT}; +use um::winnt::HRESULT; use winrt::inspectable::{IInspectable, IInspectableVtbl}; RIDL!{#[uuid(0x00000035, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] interface IActivationFactory(IActivationFactoryVtbl): IInspectable(IInspectableVtbl) { diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/winrt/hstring.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/winrt/hstring.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/winrt/hstring.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/winrt/hstring.rs 2018-12-05 01:24:42.000000000 +0000 @@ -7,7 +7,7 @@ //! This interface definition contains typedefs for Windows Runtime data types. use ctypes::c_char; use um::winnt::PVOID; -DECLARE_HANDLE!(HSTRING, HSTRING__); +DECLARE_HANDLE!{HSTRING, HSTRING__} #[cfg(target_arch = "x86")] UNION!{union HSTRING_HEADER_Reserved { [u32; 5], @@ -23,4 +23,4 @@ STRUCT!{struct HSTRING_HEADER { Reserved: HSTRING_HEADER_Reserved, }} -DECLARE_HANDLE!(HSTRING_BUFFER, HSTRING_BUFFER__); +DECLARE_HANDLE!{HSTRING_BUFFER, HSTRING_BUFFER__} diff -Nru rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/winrt/roapi.rs rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/winrt/roapi.rs --- rustc-1.30.0+dfsg1+llvm/src/vendor/winapi/src/winrt/roapi.rs 2018-10-24 21:38:10.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/vendor/winapi/src/winrt/roapi.rs 2018-12-05 01:24:42.000000000 +0000 @@ -45,7 +45,7 @@ factory: *mut *mut VOID, ) -> HRESULT; } -DECLARE_HANDLE!(APARTMENT_SHUTDOWN_REGISTRATION_COOKIE, APARTMENT_SHUTDOWN_REGISTRATION_COOKIE__); +DECLARE_HANDLE!{APARTMENT_SHUTDOWN_REGISTRATION_COOKIE, APARTMENT_SHUTDOWN_REGISTRATION_COOKIE__} extern "system" { pub fn RoRegisterForApartmentShutdown( callbackObject: *const IApartmentShutdown, diff -Nru rustc-1.30.0+dfsg1+llvm/version rustc-1.31.0+dfsg1+llvm/version --- rustc-1.30.0+dfsg1+llvm/version 2018-10-24 21:34:08.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/version 2018-12-05 01:22:15.000000000 +0000 @@ -1 +1 @@ -1.30.0 (da5f414c2 2018-10-24) \ No newline at end of file +1.31.0 (abe02cefd 2018-12-04) \ No newline at end of file

Parser for P { + type Input = (); +} + +fn main() { +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-iterator-binding.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-iterator-binding.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-iterator-binding.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-iterator-binding.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,29 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass + +fn pairwise_sub>(mut t: T) -> isize { + let mut result = 0; + loop { + let front = t.next(); + let back = t.next_back(); + match (front, back) { + (Some(f), Some(b)) => { result += b - f; } + _ => { return result; } + } + } +} + +fn main() { + let v = vec![1, 2, 3, 4, 5, 6]; + let r = pairwise_sub(v.into_iter()); + assert_eq!(r, 9); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-method.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-method.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-method.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-method.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,37 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// Test that methods whose impl-trait-ref contains associated types +// are supported. + +trait Device { + type Resources; +} +struct Foo(D, R); + +trait Tr { + fn present(&self) {} +} + +impl Tr for Foo { + fn present(&self) {} +} + +struct Res; +struct Dev; +impl Device for Dev { + type Resources = Res; +} + +fn main() { + let foo = Foo(Dev, Res); + foo.present(); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-nested-projections.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-nested-projections.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-nested-projections.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-nested-projections.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,54 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// Test that we can resolve nested projection types. Issue #20666. + +// pretty-expanded FIXME #23616 + +use std::slice; + +trait Bound {} + +impl<'a> Bound for &'a i32 {} + +trait IntoIterator { + type Iter: Iterator; + + fn into_iter(self) -> Self::Iter; +} + +impl<'a, T> IntoIterator for &'a [T; 3] { + type Iter = slice::Iter<'a, T>; + + fn into_iter(self) -> slice::Iter<'a, T> { + self.iter() + } +} + +fn foo(x: X) where + X: IntoIterator, + <::Iter as Iterator>::Item: Bound, +{ +} + +fn bar(x: X) where + T: Bound, + I: Iterator, + X: IntoIterator, +{ + +} + +fn main() { + foo(&[0, 1, 2]); + bar(&[0, 1, 2]); +} diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-normalize-in-bounds-binding.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-normalize-in-bounds-binding.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-normalize-in-bounds-binding.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-normalize-in-bounds-binding.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,48 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// Test that we normalize associated types that appear in a bound that +// contains a binding. Issue #21664. + +// pretty-expanded FIXME #23616 + +#![allow(dead_code)] + +pub trait Integral { + type Opposite; +} + +impl Integral for i32 { + type Opposite = u32; +} + +impl Integral for u32 { + type Opposite = i32; +} + +pub trait FnLike { + type R; + + fn dummy(&self, a: A) -> Self::R { loop { } } +} + +fn foo() + where T : FnLike<::Opposite, R=bool> +{ + bar::(); +} + +fn bar() + where T : FnLike +{} + +fn main() { } diff -Nru rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-normalize-in-bounds.rs rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-normalize-in-bounds.rs --- rustc-1.30.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-normalize-in-bounds.rs 1970-01-01 00:00:00.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/test/run-pass/associated-types/associated-types-normalize-in-bounds.rs 2018-12-04 23:41:40.000000000 +0000 @@ -0,0 +1,45 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_variables)] +// Test that we normalize associated types that appear in bounds; if +// we didn't, the call to `self.split2()` fails to type check. + +// pretty-expanded FIXME #23616 + +use std::marker::PhantomData; + +struct Splits<'a, T, P>(PhantomData<(&'a(),T,P)>); +struct SplitsN(PhantomData); + +trait SliceExt2 { + type Item; + + fn split2<'a, P>(&'a self, pred: P) -> Splits<'a, Self::Item, P> + where P: FnMut(&Self::Item) -> bool; + fn splitn2<'a, P>(&'a self, n: usize, pred: P) -> SplitsN> + where P: FnMut(&Self::Item) -> bool; +} + +impl SliceExt2 for [T] { + type Item = T; + + fn split2

\ \ \ diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/html/markdown.rs rustc-1.31.0+dfsg1+llvm/src/librustdoc/html/markdown.rs --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/html/markdown.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/html/markdown.rs 2018-12-04 23:41:40.000000000 +0000 @@ -37,6 +37,7 @@ use std::borrow::Cow; use std::ops::Range; use std::str; +use syntax::edition::Edition; use html::toc::TocBuilder; use html::highlight; @@ -170,6 +171,7 @@ let event = self.inner.next(); let compile_fail; let ignore; + let edition; if let Some(Event::Start(Tag::CodeBlock(lang))) = event { let parse_result = LangString::parse(&lang, self.check_error_codes); if !parse_result.rust { @@ -177,6 +179,7 @@ } compile_fail = parse_result.compile_fail; ignore = parse_result.ignore; + edition = parse_result.edition; } else { return event; } @@ -212,6 +215,17 @@ } else { "" }; + + let edition_string = if let Some(e @ Edition::Edition2018) = edition { + format!("&edition={}{}", e, + if channel == "&version=nightly" { "" } + else { "&version=nightly" }) + } else if let Some(e) = edition { + format!("&edition={}", e) + } else { + "".to_owned() + }; + // These characters don't need to be escaped in a URI. // FIXME: use a library function for percent encoding. fn dont_escape(c: u8) -> bool { @@ -231,26 +245,44 @@ } } Some(format!( - r#"Run"#, - url, test_escaped, channel + r#"Run"#, + url, test_escaped, channel, edition_string )) }); + let tooltip = if ignore { - Some(("This example is not tested", "ignore")) + Some(("This example is not tested".to_owned(), "ignore")) } else if compile_fail { - Some(("This example deliberately fails to compile", "compile_fail")) + Some(("This example deliberately fails to compile".to_owned(), "compile_fail")) + } else if let Some(e) = edition { + Some((format!("This code runs with edition {}", e), "edition")) } else { None }; - s.push_str(&highlight::render_with_highlighting( - &text, - Some(&format!("rust-example-rendered{}", - if ignore { " ignore" } - else if compile_fail { " compile_fail" } - else { "" })), - playground_button.as_ref().map(String::as_str), - tooltip)); - Some(Event::Html(s.into())) + + if let Some((s1, s2)) = tooltip { + s.push_str(&highlight::render_with_highlighting( + &text, + Some(&format!("rust-example-rendered{}", + if ignore { " ignore" } + else if compile_fail { " compile_fail" } + else if edition.is_some() { " edition " } + else { "" })), + playground_button.as_ref().map(String::as_str), + Some((s1.as_str(), s2)))); + Some(Event::Html(s.into())) + } else { + s.push_str(&highlight::render_with_highlighting( + &text, + Some(&format!("rust-example-rendered{}", + if ignore { " ignore" } + else if compile_fail { " compile_fail" } + else if edition.is_some() { " edition " } + else { "" })), + playground_button.as_ref().map(String::as_str), + None)); + Some(Event::Html(s.into())) + } }) } } @@ -500,8 +532,10 @@ } } -pub fn find_testable_code( - doc: &str, tests: &mut test::Collector, error_codes: ErrorCodes, +pub fn find_testable_code( + doc: &str, + tests: &mut T, + error_codes: ErrorCodes, ) -> Result<(), TestableCodeError> { let mut parser = Parser::new(doc); let mut prev_offset = 0; @@ -577,6 +611,7 @@ pub compile_fail: bool, pub error_codes: Vec, pub allow_fail: bool, + pub edition: Option } impl LangString { @@ -591,6 +626,7 @@ compile_fail: false, error_codes: Vec::new(), allow_fail: false, + edition: None, } } @@ -625,6 +661,11 @@ seen_rust_tags = !seen_other_tags || seen_rust_tags; data.no_run = true; } + x if allow_error_code_check && x.starts_with("edition") => { + // allow_error_code_check is true if we're on nightly, which + // is needed for edition support + data.edition = x[7..].parse::().ok(); + } x if allow_error_code_check && x.starts_with("E") && x.len() == 5 => { if x[1..].parse::().is_ok() { data.error_codes.push(x.to_owned()); @@ -925,12 +966,14 @@ use super::{ErrorCodes, LangString, Markdown, MarkdownHtml, IdMap}; use super::plain_summary_line; use std::cell::RefCell; + use syntax::edition::Edition; #[test] fn test_lang_string_parse() { fn t(s: &str, should_panic: bool, no_run: bool, ignore: bool, rust: bool, test_harness: bool, - compile_fail: bool, allow_fail: bool, error_codes: Vec) { + compile_fail: bool, allow_fail: bool, error_codes: Vec, + edition: Option) { assert_eq!(LangString::parse(s, ErrorCodes::Yes), LangString { should_panic, no_run, @@ -941,6 +984,7 @@ error_codes, original: s.to_owned(), allow_fail, + edition, }) } @@ -948,23 +992,26 @@ Vec::new() } - // marker | should_panic| no_run| ignore| rust | test_harness| compile_fail - // | allow_fail | error_codes - t("", false, false, false, true, false, false, false, v()); - t("rust", false, false, false, true, false, false, false, v()); - t("sh", false, false, false, false, false, false, false, v()); - t("ignore", false, false, true, true, false, false, false, v()); - t("should_panic", true, false, false, true, false, false, false, v()); - t("no_run", false, true, false, true, false, false, false, v()); - t("test_harness", false, false, false, true, true, false, false, v()); - t("compile_fail", false, true, false, true, false, true, false, v()); - t("allow_fail", false, false, false, true, false, false, true, v()); - t("{.no_run .example}", false, true, false, true, false, false, false, v()); - t("{.sh .should_panic}", true, false, false, false, false, false, false, v()); - t("{.example .rust}", false, false, false, true, false, false, false, v()); - t("{.test_harness .rust}", false, false, false, true, true, false, false, v()); - t("text, no_run", false, true, false, false, false, false, false, v()); - t("text,no_run", false, true, false, false, false, false, false, v()); + // ignore-tidy-linelength + // marker | should_panic | no_run | ignore | rust | test_harness + // | compile_fail | allow_fail | error_codes | edition + t("", false, false, false, true, false, false, false, v(), None); + t("rust", false, false, false, true, false, false, false, v(), None); + t("sh", false, false, false, false, false, false, false, v(), None); + t("ignore", false, false, true, true, false, false, false, v(), None); + t("should_panic", true, false, false, true, false, false, false, v(), None); + t("no_run", false, true, false, true, false, false, false, v(), None); + t("test_harness", false, false, false, true, true, false, false, v(), None); + t("compile_fail", false, true, false, true, false, true, false, v(), None); + t("allow_fail", false, false, false, true, false, false, true, v(), None); + t("{.no_run .example}", false, true, false, true, false, false, false, v(), None); + t("{.sh .should_panic}", true, false, false, false, false, false, false, v(), None); + t("{.example .rust}", false, false, false, true, false, false, false, v(), None); + t("{.test_harness .rust}", false, false, false, true, true, false, false, v(), None); + t("text, no_run", false, true, false, false, false, false, false, v(), None); + t("text,no_run", false, true, false, false, false, false, false, v(), None); + t("edition2015", false, false, false, true, false, false, false, v(), Some(Edition::Edition2015)); + t("edition2018", false, false, false, true, false, false, false, v(), Some(Edition::Edition2018)); } #[test] diff -Nru rustc-1.30.0+dfsg1+llvm/src/librustdoc/html/render.rs rustc-1.31.0+dfsg1+llvm/src/librustdoc/html/render.rs --- rustc-1.30.0+dfsg1+llvm/src/librustdoc/html/render.rs 2018-10-24 20:00:01.000000000 +0000 +++ rustc-1.31.0+dfsg1+llvm/src/librustdoc/html/render.rs 2018-12-04 23:41:40.000000000 +0000 @@ -56,6 +56,7 @@ use serialize::json::{ToJson, Json, as_json}; use syntax::ast; +use syntax::ext::base::MacroKind; use syntax::source_map::FileName; use syntax::feature_gate::UnstableFeatures; use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId}; @@ -313,7 +314,7 @@ // Note that external items for which `doc(hidden)` applies to are shown as // non-reachable while local items aren't. This is because we're reusing // the access levels from crateanalysis. - pub access_levels: Arc>, + pub access_levels: AccessLevels, /// The version of the crate being documented, if given from the `--crate-version` flag. pub crate_version: Option, @@ -337,6 +338,15 @@ // and their parent id here and indexes them at the end of crate parsing. orphan_impl_items: Vec<(DefId, clean::Item)>, + // Similarly to `orphan_impl_items`, sometimes trait impls are picked up + // even though the trait itself is not exported. This can happen if a trait + // was defined in function/expression scope, since the impl will be picked + // up by `collect-trait-impls` but the trait won't be scraped out in the HIR + // crawl. In order to prevent crashes when looking for spotlight traits or + // when gathering trait documentation on a type, hold impls here while + // folding and add them to the cache later on if we find the trait. + orphan_trait_impls: Vec<(DefId, FxHashSet, Impl)>, + /// Aliases added through `#[doc(alias = "...")]`. Since a few items can have the same alias, /// we need the alias element to have an array of items. aliases: FxHashMap>, @@ -350,6 +360,7 @@ pub external_paths: ::core::ExternalPaths, pub external_typarams: FxHashMap, pub exact_paths: FxHashMap>, + pub access_levels: AccessLevels, pub deref_trait_did: Option, pub deref_mut_trait_did: Option, pub owned_box_did: Option, @@ -502,7 +513,7 @@ src_root, passes, include_sources: true, - local_sources: FxHashMap(), + local_sources: Default::default(), issue_tracker_base_url: None, layout: layout::Layout { logo: String::new(), @@ -510,8 +521,8 @@ external_html: external_html.clone(), krate: krate.name.clone(), }, - css_file_extension: css_file_extension.clone(), - created_dirs: RefCell::new(FxHashSet()), + css_file_extension, + created_dirs: Default::default(), sort_modules_alphabetically, themes, resource_suffix, @@ -569,6 +580,7 @@ external_paths, external_typarams, exact_paths, + access_levels, deref_trait_did, deref_mut_trait_did, owned_box_did, @@ -579,28 +591,29 @@ .collect(); let mut cache = Cache { - impls: FxHashMap(), + impls: Default::default(), external_paths, exact_paths, - paths: FxHashMap(), - implementors: FxHashMap(), + paths: Default::default(), + implementors: Default::default(), stack: Vec::new(), parent_stack: Vec::new(), search_index: Vec::new(), parent_is_trait_impl: false, - extern_locations: FxHashMap(), - primitive_locations: FxHashMap(), + extern_locations: Default::default(), + primitive_locations: Default::default(), stripped_mod: false, - access_levels: krate.access_levels.clone(), + access_levels, crate_version: krate.version.take(), orphan_impl_items: Vec::new(), - traits: mem::replace(&mut krate.external_traits, FxHashMap()), + orphan_trait_impls: Vec::new(), + traits: krate.external_traits.lock().replace(Default::default()), deref_trait_did, deref_mut_trait_did, owned_box_did, - masked_crates: mem::replace(&mut krate.masked_crates, FxHashSet()), + masked_crates: mem::replace(&mut krate.masked_crates, Default::default()), typarams: external_typarams, - aliases: FxHashMap(), + aliases: Default::default(), }; // Cache where all our extern crates are located @@ -636,6 +649,14 @@ cache.stack.push(krate.name.clone()); krate = cache.fold_crate(krate); + for (trait_did, dids, impl_) in cache.orphan_trait_impls.drain(..) { + if cache.traits.contains_key(&trait_did) { + for did in dids { + cache.impls.entry(did).or_insert(vec![]).push(impl_.clone()); + } + } + } + // Build our search index let index = build_index(&krate, &mut cache); @@ -653,7 +674,7 @@ /// Build the search index from the collected metadata fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String { - let mut nodeid_to_pathid = FxHashMap(); + let mut nodeid_to_pathid = FxHashMap::default(); let mut crate_items = Vec::with_capacity(cache.search_index.len()); let mut crate_paths = Vec::::new(); @@ -1223,6 +1244,10 @@ impl DocFolder for Cache { fn fold_item(&mut self, item: clean::Item) -> Option { + if item.def_id.is_local() { + debug!("folding {} \"{:?}\", id {:?}", item.type_(), item.name, item.def_id); + } + // If this is a stripped module, // we don't want it or its children in the search index. let orig_stripped_mod = match item.inner { @@ -1318,7 +1343,7 @@ self.search_index.push(IndexItem { ty: item.type_(), name: s.to_string(), - path: path.join("::").to_string(), + path: path.join("::"), desc: plain_summary_line(item.doc_value()), parent, parent_idx: None, @@ -1423,7 +1448,7 @@ // Figure out the id of this impl. This may map to a // primitive rather than always to a struct/enum. // Note: matching twice to restrict the lifetime of the `i` borrow. - let mut dids = FxHashSet(); + let mut dids = FxHashSet::default(); if let clean::Item { inner: clean::ImplItem(ref i), .. } = item { match i.for_ { clean::ResolvedPath { did, .. } | @@ -1453,10 +1478,16 @@ } else { unreachable!() }; - for did in dids { - self.impls.entry(did).or_default().push(Impl { - impl_item: item.clone(), - }); + let impl_item = Impl { + impl_item: item, + }; + if impl_item.trait_did().map_or(true, |d| self.traits.contains_key(&d)) { + for did in dids { + self.impls.entry(did).or_insert(vec![]).push(impl_item.clone()); + } + } else { + let trait_did = impl_item.trait_did().unwrap(); + self.orphan_trait_impls.push((trait_did, dids, impl_item)); } None } else { @@ -1565,6 +1596,8 @@ statics: FxHashSet, constants: FxHashSet, keywords: FxHashSet, + attributes: FxHashSet, + derives: FxHashSet, } impl AllTypes { @@ -1583,6 +1616,8 @@ statics: new_set(100), constants: new_set(100), keywords: new_set(100), + attributes: new_set(100), + derives: new_set(100), } } @@ -1604,6 +1639,8 @@ ItemType::Existential => self.existentials.insert(ItemEntry::new(new_url, name)), ItemType::Static => self.statics.insert(ItemEntry::new(new_url, name)), ItemType::Constant => self.constants.insert(ItemEntry::new(new_url, name)), + ItemType::ProcAttribute => self.attributes.insert(ItemEntry::new(new_url, name)), + ItemType::ProcDerive => self.derives.insert(ItemEntry::new(new_url, name)), _ => true, }; } @@ -1643,6 +1680,8 @@ print_entries(f, &self.primitives, "Primitives", "primitives")?; print_entries(f, &self.traits, "Traits", "traits")?; print_entries(f, &self.macros, "Macros", "macros")?; + print_entries(f, &self.attributes, "Attribute Macros", "attributes")?; + print_entries(f, &self.derives, "Derive Macros", "derives")?; print_entries(f, &self.functions, "Functions", "functions")?; print_entries(f, &self.typedefs, "Typedefs", "typedefs")?; print_entries(f, &self.existentials, "Existentials", "existentials")?; @@ -1830,8 +1869,8 @@ *slot.borrow_mut() = self.current.clone(); }); - let mut title = if it.is_primitive() { - // No need to include the namespace for primitive types + let mut title = if it.is_primitive() || it.is_keyword() { + // No need to include the namespace for primitive types and keywords String::new() } else { self.current.join("::") @@ -2125,6 +2164,12 @@ clean::EnumItem(..) => write!(fmt, "Enum ")?, clean::TypedefItem(..) => write!(fmt, "Type Definition ")?, clean::MacroItem(..) => write!(fmt, "Macro ")?, + clean::ProcMacroItem(ref mac) => match mac.kind { + MacroKind::Bang => write!(fmt, "Macro ")?, + MacroKind::Attr => write!(fmt, "Attribute Macro ")?, + MacroKind::Derive => write!(fmt, "Derive Macro ")?, + MacroKind::ProcMacroStub => unreachable!(), + } clean::PrimitiveItem(..) => write!(fmt, "Primitive Type ")?, clean::StaticItem(..) | clean::ForeignStaticItem(..) => write!(fmt, "Static ")?, clean::ConstantItem(..) => write!(fmt, "Constant ")?, @@ -2161,6 +2206,7 @@ clean::EnumItem(ref e) => item_enum(fmt, self.cx, self.item, e), clean::TypedefItem(ref t, _) => item_typedef(fmt, self.cx, self.item, t), clean::MacroItem(ref m) => item_macro(fmt, self.cx, self.item, m), + clean::ProcMacroItem(ref m) => item_proc_macro(fmt, self.cx, self.item, m), clean::PrimitiveItem(ref p) => item_primitive(fmt, self.cx, self.item, p), clean::StaticItem(ref i) | clean::ForeignStaticItem(ref i) => item_static(fmt, self.cx, self.item, i), @@ -2237,7 +2283,7 @@ format!("{} [Read more]({})", &plain_summary_line(Some(s)), naive_assoc_href(item, link)) } else { - plain_summary_line(Some(s)).to_string() + plain_summary_line(Some(s)) }; render_markdown(w, cx, &markdown, item.links(), prefix)?; } else if !prefix.is_empty() { @@ -2389,7 +2435,7 @@ // (which is the position in the vector). indices.dedup_by_key(|i| (items[*i].def_id, if items[*i].name.as_ref().is_some() { - Some(full_path(cx, &items[*i]).clone()) + Some(full_path(cx, &items[*i])) } else { None }, @@ -2894,7 +2940,7 @@ if let Some(implementors) = cache.implementors.get(&it.def_id) { // The DefId is for the first Type found with that name. The bool is // if any Types with the same name but different DefId have been found. - let mut implementor_dups: FxHashMap<&str, (DefId, bool)> = FxHashMap(); + let mut implementor_dups: FxHashMap<&str, (DefId, bool)> = FxHashMap::default(); for implementor in implementors { match implementor.inner_impl().for_ { clean::ResolvedPath { ref path, did, is_generic: false, .. } | @@ -3747,7 +3793,7 @@ out.push_str(" "); assoc_type(&mut out, it, &[], Some(&tydef.type_), - AssocItemLink::GotoSource(t_did, &FxHashSet()))?; + AssocItemLink::GotoSource(t_did, &FxHashSet::default()))?; out.push_str(";"); } } @@ -4049,14 +4095,16 @@ write!(fmt, "
\

Version {}

\ -
-

See all {}'s items

", - version, - it.name.as_ref().unwrap())?; +